]>
Commit | Line | Data |
---|---|---|
28db6da4 | 1 | /** @file\r |
f3816027 | 2 | Implementation of managing the multicast receive filters of a network\r |
3 | interface.\r | |
4 | \r | |
d1102dba | 5 | Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>\r |
9d510e61 | 6 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
28db6da4 | 7 | \r |
28db6da4 | 8 | **/\r |
9 | \r | |
28db6da4 | 10 | #include "Snp.h"\r |
11 | \r | |
12 | /**\r | |
f3816027 | 13 | Call undi to enable the receive filters.\r |
14 | \r | |
15 | @param Snp Pointer to snp driver structure.\r | |
16 | @param EnableFlags Bit mask for enabling the receive filters.\r | |
17 | @param MCastAddressCount Multicast address count for a new multicast address\r | |
18 | list.\r | |
d1102dba LG |
19 | @param MCastAddressList List of new multicast addresses.\r |
20 | \r | |
f3816027 | 21 | @retval EFI_SUCCESS The multicast receive filter list was updated.\r |
22 | @retval EFI_INVALID_PARAMETER Invalid UNDI command.\r | |
23 | @retval EFI_UNSUPPORTED Command is not supported by UNDI.\r | |
24 | @retval EFI_DEVICE_ERROR Fail to execute UNDI command.\r | |
28db6da4 | 25 | \r |
26 | **/\r | |
28db6da4 | 27 | EFI_STATUS\r |
4cda7726 | 28 | PxeRecvFilterEnable (\r |
d1050b9d MK |
29 | SNP_DRIVER *Snp,\r |
30 | UINT32 EnableFlags,\r | |
31 | UINTN MCastAddressCount,\r | |
32 | EFI_MAC_ADDRESS *MCastAddressList\r | |
28db6da4 | 33 | )\r |
34 | {\r | |
d1050b9d MK |
35 | Snp->Cdb.OpCode = PXE_OPCODE_RECEIVE_FILTERS;\r |
36 | Snp->Cdb.OpFlags = PXE_OPFLAGS_RECEIVE_FILTER_ENABLE;\r | |
37 | Snp->Cdb.CPBsize = PXE_CPBSIZE_NOT_USED;\r | |
38 | Snp->Cdb.DBsize = PXE_DBSIZE_NOT_USED;\r | |
39 | Snp->Cdb.CPBaddr = PXE_CPBADDR_NOT_USED;\r | |
40 | Snp->Cdb.DBaddr = PXE_DBADDR_NOT_USED;\r | |
41 | Snp->Cdb.StatCode = PXE_STATCODE_INITIALIZE;\r | |
42 | Snp->Cdb.StatFlags = PXE_STATFLAGS_INITIALIZE;\r | |
43 | Snp->Cdb.IFnum = Snp->IfNum;\r | |
44 | Snp->Cdb.Control = PXE_CONTROL_LAST_CDB_IN_LIST;\r | |
28db6da4 | 45 | \r |
46 | if ((EnableFlags & EFI_SIMPLE_NETWORK_RECEIVE_UNICAST) != 0) {\r | |
4cda7726 | 47 | Snp->Cdb.OpFlags |= PXE_OPFLAGS_RECEIVE_FILTER_UNICAST;\r |
28db6da4 | 48 | }\r |
49 | \r | |
50 | if ((EnableFlags & EFI_SIMPLE_NETWORK_RECEIVE_BROADCAST) != 0) {\r | |
4cda7726 | 51 | Snp->Cdb.OpFlags |= PXE_OPFLAGS_RECEIVE_FILTER_BROADCAST;\r |
28db6da4 | 52 | }\r |
53 | \r | |
54 | if ((EnableFlags & EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS) != 0) {\r | |
4cda7726 | 55 | Snp->Cdb.OpFlags |= PXE_OPFLAGS_RECEIVE_FILTER_PROMISCUOUS;\r |
28db6da4 | 56 | }\r |
57 | \r | |
58 | if ((EnableFlags & EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST) != 0) {\r | |
4cda7726 | 59 | Snp->Cdb.OpFlags |= PXE_OPFLAGS_RECEIVE_FILTER_ALL_MULTICAST;\r |
28db6da4 | 60 | }\r |
61 | \r | |
62 | if ((EnableFlags & EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST) != 0) {\r | |
4cda7726 | 63 | Snp->Cdb.OpFlags |= PXE_OPFLAGS_RECEIVE_FILTER_FILTERED_MULTICAST;\r |
28db6da4 | 64 | }\r |
65 | \r | |
66 | if (MCastAddressCount != 0) {\r | |
d1050b9d MK |
67 | Snp->Cdb.CPBsize = (UINT16)(MCastAddressCount * sizeof (EFI_MAC_ADDRESS));\r |
68 | Snp->Cdb.CPBaddr = (UINT64)(UINTN)Snp->Cpb;\r | |
4cda7726 | 69 | CopyMem (Snp->Cpb, MCastAddressList, Snp->Cdb.CPBsize);\r |
28db6da4 | 70 | }\r |
d1050b9d | 71 | \r |
28db6da4 | 72 | //\r |
73 | // Issue UNDI command and check result.\r | |
74 | //\r | |
c49ca4a2 | 75 | DEBUG ((DEBUG_NET, "\nsnp->undi.receive_filters() "));\r |
28db6da4 | 76 | \r |
d1050b9d | 77 | (*Snp->IssueUndi32Command)((UINT64)(UINTN)&Snp->Cdb);\r |
28db6da4 | 78 | \r |
3af347b3 | 79 | if (Snp->Cdb.StatCode != PXE_STATCODE_SUCCESS) {\r |
28db6da4 | 80 | //\r |
81 | // UNDI command failed. Return UNDI status to caller.\r | |
82 | //\r | |
83 | DEBUG (\r | |
c49ca4a2 | 84 | (DEBUG_ERROR,\r |
d1050b9d MK |
85 | "\nsnp->undi.receive_filters() %xh:%xh\n",\r |
86 | Snp->Cdb.StatFlags,\r | |
87 | Snp->Cdb.StatCode)\r | |
28db6da4 | 88 | );\r |
89 | \r | |
4cda7726 | 90 | switch (Snp->Cdb.StatCode) {\r |
d1050b9d MK |
91 | case PXE_STATCODE_INVALID_CDB:\r |
92 | case PXE_STATCODE_INVALID_CPB:\r | |
93 | case PXE_STATCODE_INVALID_PARAMETER:\r | |
94 | return EFI_INVALID_PARAMETER;\r | |
28db6da4 | 95 | \r |
d1050b9d MK |
96 | case PXE_STATCODE_UNSUPPORTED:\r |
97 | return EFI_UNSUPPORTED;\r | |
28db6da4 | 98 | }\r |
99 | \r | |
100 | return EFI_DEVICE_ERROR;\r | |
101 | }\r | |
102 | \r | |
103 | return EFI_SUCCESS;\r | |
104 | }\r | |
105 | \r | |
106 | /**\r | |
f3816027 | 107 | Call undi to disable the receive filters.\r |
28db6da4 | 108 | \r |
f3816027 | 109 | @param Snp Pointer to snp driver structure\r |
110 | @param DisableFlags Bit mask for disabling the receive filters\r | |
d1102dba | 111 | @param ResetMCastList Boolean flag to reset/delete the multicast filter\r |
f3816027 | 112 | list.\r |
28db6da4 | 113 | \r |
f3816027 | 114 | @retval EFI_SUCCESS The multicast receive filter list was updated.\r |
115 | @retval EFI_DEVICE_ERROR Fail to execute UNDI command.\r | |
d1102dba LG |
116 | \r |
117 | **/\r | |
28db6da4 | 118 | EFI_STATUS\r |
4cda7726 | 119 | PxeRecvFilterDisable (\r |
d1050b9d MK |
120 | SNP_DRIVER *Snp,\r |
121 | UINT32 DisableFlags,\r | |
122 | BOOLEAN ResetMCastList\r | |
28db6da4 | 123 | )\r |
124 | {\r | |
d1050b9d MK |
125 | Snp->Cdb.OpCode = PXE_OPCODE_RECEIVE_FILTERS;\r |
126 | Snp->Cdb.CPBsize = PXE_CPBSIZE_NOT_USED;\r | |
127 | Snp->Cdb.DBsize = PXE_DBSIZE_NOT_USED;\r | |
128 | Snp->Cdb.CPBaddr = PXE_CPBADDR_NOT_USED;\r | |
129 | Snp->Cdb.DBaddr = PXE_DBADDR_NOT_USED;\r | |
130 | Snp->Cdb.StatCode = PXE_STATCODE_INITIALIZE;\r | |
131 | Snp->Cdb.StatFlags = PXE_STATFLAGS_INITIALIZE;\r | |
132 | Snp->Cdb.IFnum = Snp->IfNum;\r | |
133 | Snp->Cdb.Control = PXE_CONTROL_LAST_CDB_IN_LIST;\r | |
134 | \r | |
135 | Snp->Cdb.OpFlags = (UINT16)((DisableFlags != 0) ? PXE_OPFLAGS_RECEIVE_FILTER_DISABLE : PXE_OPFLAGS_NOT_USED);\r | |
28db6da4 | 136 | \r |
137 | if (ResetMCastList) {\r | |
4cda7726 | 138 | Snp->Cdb.OpFlags |= PXE_OPFLAGS_RECEIVE_FILTER_RESET_MCAST_LIST;\r |
28db6da4 | 139 | }\r |
140 | \r | |
141 | if ((DisableFlags & EFI_SIMPLE_NETWORK_RECEIVE_UNICAST) != 0) {\r | |
4cda7726 | 142 | Snp->Cdb.OpFlags |= PXE_OPFLAGS_RECEIVE_FILTER_UNICAST;\r |
28db6da4 | 143 | }\r |
144 | \r | |
145 | if ((DisableFlags & EFI_SIMPLE_NETWORK_RECEIVE_BROADCAST) != 0) {\r | |
4cda7726 | 146 | Snp->Cdb.OpFlags |= PXE_OPFLAGS_RECEIVE_FILTER_BROADCAST;\r |
28db6da4 | 147 | }\r |
148 | \r | |
149 | if ((DisableFlags & EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS) != 0) {\r | |
4cda7726 | 150 | Snp->Cdb.OpFlags |= PXE_OPFLAGS_RECEIVE_FILTER_PROMISCUOUS;\r |
28db6da4 | 151 | }\r |
152 | \r | |
153 | if ((DisableFlags & EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST) != 0) {\r | |
4cda7726 | 154 | Snp->Cdb.OpFlags |= PXE_OPFLAGS_RECEIVE_FILTER_ALL_MULTICAST;\r |
28db6da4 | 155 | }\r |
156 | \r | |
157 | if ((DisableFlags & EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST) != 0) {\r | |
4cda7726 | 158 | Snp->Cdb.OpFlags |= PXE_OPFLAGS_RECEIVE_FILTER_FILTERED_MULTICAST;\r |
28db6da4 | 159 | }\r |
d1050b9d | 160 | \r |
28db6da4 | 161 | //\r |
162 | // Issue UNDI command and check result.\r | |
163 | //\r | |
c49ca4a2 | 164 | DEBUG ((DEBUG_NET, "\nsnp->undi.receive_filters() "));\r |
28db6da4 | 165 | \r |
d1050b9d | 166 | (*Snp->IssueUndi32Command)((UINT64)(UINTN)&Snp->Cdb);\r |
28db6da4 | 167 | \r |
3af347b3 | 168 | if (Snp->Cdb.StatCode != PXE_STATCODE_SUCCESS) {\r |
28db6da4 | 169 | //\r |
170 | // UNDI command failed. Return UNDI status to caller.\r | |
171 | //\r | |
172 | DEBUG (\r | |
c49ca4a2 | 173 | (DEBUG_ERROR,\r |
d1050b9d MK |
174 | "\nsnp->undi.receive_filters() %xh:%xh\n",\r |
175 | Snp->Cdb.StatFlags,\r | |
176 | Snp->Cdb.StatCode)\r | |
28db6da4 | 177 | );\r |
178 | \r | |
179 | return EFI_DEVICE_ERROR;\r | |
180 | }\r | |
181 | \r | |
182 | return EFI_SUCCESS;\r | |
183 | }\r | |
184 | \r | |
185 | /**\r | |
f3816027 | 186 | Call undi to read the receive filters.\r |
28db6da4 | 187 | \r |
f3816027 | 188 | @param Snp Pointer to snp driver structure.\r |
28db6da4 | 189 | \r |
f3816027 | 190 | @retval EFI_SUCCESS The receive filter was read.\r |
d1102dba LG |
191 | @retval EFI_DEVICE_ERROR Fail to execute UNDI command.\r |
192 | \r | |
28db6da4 | 193 | **/\r |
28db6da4 | 194 | EFI_STATUS\r |
4cda7726 | 195 | PxeRecvFilterRead (\r |
d1050b9d | 196 | SNP_DRIVER *Snp\r |
28db6da4 | 197 | )\r |
198 | {\r | |
d1050b9d MK |
199 | Snp->Cdb.OpCode = PXE_OPCODE_RECEIVE_FILTERS;\r |
200 | Snp->Cdb.OpFlags = PXE_OPFLAGS_RECEIVE_FILTER_READ;\r | |
201 | Snp->Cdb.CPBsize = PXE_CPBSIZE_NOT_USED;\r | |
202 | Snp->Cdb.DBsize = (UINT16)(Snp->Mode.MaxMCastFilterCount * sizeof (EFI_MAC_ADDRESS));\r | |
203 | Snp->Cdb.CPBaddr = PXE_CPBADDR_NOT_USED;\r | |
4cda7726 | 204 | if (Snp->Cdb.DBsize == 0) {\r |
d1050b9d | 205 | Snp->Cdb.DBaddr = (UINT64)(UINTN)NULL;\r |
28db6da4 | 206 | } else {\r |
d1050b9d | 207 | Snp->Cdb.DBaddr = (UINT64)(UINTN)Snp->Db;\r |
4cda7726 | 208 | ZeroMem (Snp->Db, Snp->Cdb.DBsize);\r |
28db6da4 | 209 | }\r |
210 | \r | |
d1050b9d MK |
211 | Snp->Cdb.StatCode = PXE_STATCODE_INITIALIZE;\r |
212 | Snp->Cdb.StatFlags = PXE_STATFLAGS_INITIALIZE;\r | |
213 | Snp->Cdb.IFnum = Snp->IfNum;\r | |
214 | Snp->Cdb.Control = PXE_CONTROL_LAST_CDB_IN_LIST;\r | |
28db6da4 | 215 | \r |
c49ca4a2 | 216 | DEBUG ((DEBUG_NET, "\nsnp->undi.receive_filters() "));\r |
28db6da4 | 217 | \r |
d1050b9d | 218 | (*Snp->IssueUndi32Command)((UINT64)(UINTN)&Snp->Cdb);\r |
28db6da4 | 219 | \r |
3af347b3 | 220 | if (Snp->Cdb.StatCode != PXE_STATCODE_SUCCESS) {\r |
28db6da4 | 221 | //\r |
222 | // UNDI command failed. Return UNDI status to caller.\r | |
223 | //\r | |
224 | DEBUG (\r | |
c49ca4a2 | 225 | (DEBUG_ERROR,\r |
d1050b9d MK |
226 | "\nsnp->undi.receive_filters() %xh:%xh\n",\r |
227 | Snp->Cdb.StatFlags,\r | |
228 | Snp->Cdb.StatCode)\r | |
28db6da4 | 229 | );\r |
230 | \r | |
231 | return EFI_DEVICE_ERROR;\r | |
232 | }\r | |
d1050b9d | 233 | \r |
28db6da4 | 234 | //\r |
235 | // Convert UNDI32 StatFlags to EFI SNP filter flags.\r | |
236 | //\r | |
4cda7726 | 237 | Snp->Mode.ReceiveFilterSetting = 0;\r |
28db6da4 | 238 | \r |
4cda7726 | 239 | if ((Snp->Cdb.StatFlags & PXE_STATFLAGS_RECEIVE_FILTER_UNICAST) != 0) {\r |
240 | Snp->Mode.ReceiveFilterSetting |= EFI_SIMPLE_NETWORK_RECEIVE_UNICAST;\r | |
28db6da4 | 241 | }\r |
242 | \r | |
4cda7726 | 243 | if ((Snp->Cdb.StatFlags & PXE_STATFLAGS_RECEIVE_FILTER_BROADCAST) != 0) {\r |
244 | Snp->Mode.ReceiveFilterSetting |= EFI_SIMPLE_NETWORK_RECEIVE_BROADCAST;\r | |
28db6da4 | 245 | }\r |
246 | \r | |
4cda7726 | 247 | if ((Snp->Cdb.StatFlags & PXE_STATFLAGS_RECEIVE_FILTER_PROMISCUOUS) != 0) {\r |
248 | Snp->Mode.ReceiveFilterSetting |= EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS;\r | |
28db6da4 | 249 | }\r |
250 | \r | |
4cda7726 | 251 | if ((Snp->Cdb.StatFlags & PXE_STATFLAGS_RECEIVE_FILTER_ALL_MULTICAST) != 0) {\r |
252 | Snp->Mode.ReceiveFilterSetting |= EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST;\r | |
28db6da4 | 253 | }\r |
254 | \r | |
4cda7726 | 255 | if ((Snp->Cdb.StatFlags & PXE_STATFLAGS_RECEIVE_FILTER_FILTERED_MULTICAST) != 0) {\r |
256 | Snp->Mode.ReceiveFilterSetting |= EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST;\r | |
28db6da4 | 257 | }\r |
258 | \r | |
4cda7726 | 259 | CopyMem (Snp->Mode.MCastFilter, Snp->Db, Snp->Cdb.DBsize);\r |
28db6da4 | 260 | \r |
261 | //\r | |
262 | // Count number of active entries in multicast filter list.\r | |
263 | //\r | |
264 | {\r | |
d1050b9d | 265 | EFI_MAC_ADDRESS ZeroMacAddr;\r |
28db6da4 | 266 | \r |
267 | SetMem (&ZeroMacAddr, sizeof ZeroMacAddr, 0);\r | |
268 | \r | |
4cda7726 | 269 | for (Snp->Mode.MCastFilterCount = 0;\r |
270 | Snp->Mode.MCastFilterCount < Snp->Mode.MaxMCastFilterCount;\r | |
271 | Snp->Mode.MCastFilterCount++\r | |
d1050b9d MK |
272 | )\r |
273 | {\r | |
28db6da4 | 274 | if (CompareMem (\r |
4cda7726 | 275 | &Snp->Mode.MCastFilter[Snp->Mode.MCastFilterCount],\r |
28db6da4 | 276 | &ZeroMacAddr,\r |
277 | sizeof ZeroMacAddr\r | |
d1050b9d MK |
278 | ) == 0)\r |
279 | {\r | |
28db6da4 | 280 | break;\r |
281 | }\r | |
282 | }\r | |
283 | }\r | |
284 | \r | |
285 | return EFI_SUCCESS;\r | |
286 | }\r | |
287 | \r | |
28db6da4 | 288 | /**\r |
4cda7726 | 289 | Manages the multicast receive filters of a network interface.\r |
d1102dba LG |
290 | \r |
291 | This function is used enable and disable the hardware and software receive\r | |
4cda7726 | 292 | filters for the underlying network device.\r |
d1102dba LG |
293 | The receive filter change is broken down into three steps:\r |
294 | * The filter mask bits that are set (ON) in the Enable parameter are added to\r | |
295 | the current receive filter settings.\r | |
4cda7726 | 296 | * The filter mask bits that are set (ON) in the Disable parameter are subtracted\r |
297 | from the updated receive filter settings.\r | |
298 | * If the resulting receive filter setting is not supported by the hardware a\r | |
299 | more liberal setting is selected.\r | |
d1102dba | 300 | If the same bits are set in the Enable and Disable parameters, then the bits\r |
4cda7726 | 301 | in the Disable parameter takes precedence.\r |
d1102dba LG |
302 | If the ResetMCastFilter parameter is TRUE, then the multicast address list\r |
303 | filter is disabled (irregardless of what other multicast bits are set in the\r | |
304 | Enable and Disable parameters). The SNP->Mode->MCastFilterCount field is set\r | |
4cda7726 | 305 | to zero. The Snp->Mode->MCastFilter contents are undefined.\r |
d1102dba LG |
306 | After enabling or disabling receive filter settings, software should verify\r |
307 | the new settings by checking the Snp->Mode->ReceiveFilterSettings,\r | |
4cda7726 | 308 | Snp->Mode->MCastFilterCount and Snp->Mode->MCastFilter fields.\r |
d1102dba | 309 | Note: Some network drivers and/or devices will automatically promote receive\r |
4cda7726 | 310 | filter settings if the requested setting can not be honored. For example, if\r |
d1102dba LG |
311 | a request for four multicast addresses is made and the underlying hardware\r |
312 | only supports two multicast addresses the driver might set the promiscuous\r | |
4cda7726 | 313 | or promiscuous multicast receive filters instead. The receiving software is\r |
d1102dba | 314 | responsible for discarding any extra packets that get through the hardware\r |
4cda7726 | 315 | receive filters.\r |
d1102dba | 316 | Note: Note: To disable all receive filter hardware, the network driver must\r |
4cda7726 | 317 | be Shutdown() and Stopped(). Calling ReceiveFilters() with Disable set to\r |
d1102dba LG |
318 | Snp->Mode->ReceiveFilterSettings will make it so no more packets are\r |
319 | returned by the Receive() function, but the receive hardware may still be\r | |
4cda7726 | 320 | moving packets into system memory before inspecting and discarding them.\r |
d1102dba | 321 | Unexpected system errors, reboots and hangs can occur if an OS is loaded\r |
4cda7726 | 322 | and the network devices are not Shutdown() and Stopped().\r |
d1102dba | 323 | If ResetMCastFilter is TRUE, then the multicast receive filter list on the\r |
4cda7726 | 324 | network interface will be reset to the default multicast receive filter list.\r |
d1102dba LG |
325 | If ResetMCastFilter is FALSE, and this network interface allows the multicast\r |
326 | receive filter list to be modified, then the MCastFilterCnt and MCastFilter\r | |
327 | are used to update the current multicast receive filter list. The modified\r | |
328 | receive filter list settings can be found in the MCastFilter field of\r | |
4cda7726 | 329 | EFI_SIMPLE_NETWORK_MODE. If the network interface does not allow the multicast\r |
330 | receive filter list to be modified, then EFI_INVALID_PARAMETER will be returned.\r | |
331 | If the driver has not been initialized, EFI_DEVICE_ERROR will be returned.\r | |
d1102dba | 332 | If the receive filter mask and multicast receive filter list have been\r |
4cda7726 | 333 | successfully updated on the network interface, EFI_SUCCESS will be returned.\r |
334 | \r | |
335 | @param This A pointer to the EFI_SIMPLE_NETWORK_PROTOCOL instance.\r | |
336 | @param Enable A bit mask of receive filters to enable on the network\r | |
337 | interface.\r | |
338 | @param Disable A bit mask of receive filters to disable on the network\r | |
d1102dba | 339 | interface. For backward compatibility with EFI 1.1\r |
4cda7726 | 340 | platforms, the EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST bit\r |
341 | must be set when the ResetMCastFilter parameter is TRUE.\r | |
d1102dba LG |
342 | @param ResetMCastFilter Set to TRUE to reset the contents of the multicast\r |
343 | receive filters on the network interface to their\r | |
344 | default values.\r | |
4cda7726 | 345 | @param MCastFilterCnt Number of multicast HW MAC addresses in the new MCastFilter\r |
d1102dba LG |
346 | list. This value must be less than or equal to the\r |
347 | MCastFilterCnt field of EFI_SIMPLE_NETWORK_MODE.\r | |
4cda7726 | 348 | This field is optional if ResetMCastFilter is TRUE.\r |
349 | @param MCastFilter A pointer to a list of new multicast receive filter HW\r | |
d1102dba LG |
350 | MAC addresses. This list will replace any existing\r |
351 | multicast HW MAC address list. This field is optional\r | |
4cda7726 | 352 | if ResetMCastFilter is TRUE.\r |
d1102dba | 353 | \r |
4cda7726 | 354 | @retval EFI_SUCCESS The multicast receive filter list was updated.\r |
355 | @retval EFI_NOT_STARTED The network interface has not been started.\r | |
356 | @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:\r | |
357 | * This is NULL\r | |
358 | * There are bits set in Enable that are not set\r | |
359 | in Snp->Mode->ReceiveFilterMask\r | |
360 | * There are bits set in Disable that are not set\r | |
361 | in Snp->Mode->ReceiveFilterMask\r | |
d1102dba LG |
362 | * Multicast is being enabled (the\r |
363 | EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST bit is\r | |
364 | set in Enable, it is not set in Disable, and\r | |
4cda7726 | 365 | ResetMCastFilter is FALSE) and MCastFilterCount\r |
366 | is zero\r | |
367 | * Multicast is being enabled and MCastFilterCount\r | |
368 | is greater than Snp->Mode->MaxMCastFilterCount\r | |
369 | * Multicast is being enabled and MCastFilter is NULL\r | |
370 | * Multicast is being enabled and one or more of\r | |
371 | the addresses in the MCastFilter list are not\r | |
372 | valid multicast MAC addresses\r | |
373 | @retval EFI_DEVICE_ERROR One or more of the following conditions is TRUE:\r | |
374 | * The network interface has been started but has\r | |
375 | not been initialized\r | |
d1102dba | 376 | * An unexpected error was returned by the\r |
4cda7726 | 377 | underlying network driver or device\r |
378 | @retval EFI_UNSUPPORTED This function is not supported by the network\r | |
379 | interface.\r | |
28db6da4 | 380 | \r |
381 | **/\r | |
382 | EFI_STATUS\r | |
383 | EFIAPI\r | |
4cda7726 | 384 | SnpUndi32ReceiveFilters (\r |
d1050b9d MK |
385 | IN EFI_SIMPLE_NETWORK_PROTOCOL *This,\r |
386 | IN UINT32 Enable,\r | |
387 | IN UINT32 Disable,\r | |
388 | IN BOOLEAN ResetMCastFilter,\r | |
389 | IN UINTN MCastFilterCnt OPTIONAL,\r | |
390 | IN EFI_MAC_ADDRESS *MCastFilter OPTIONAL\r | |
28db6da4 | 391 | )\r |
392 | {\r | |
4cda7726 | 393 | SNP_DRIVER *Snp;\r |
28db6da4 | 394 | EFI_STATUS Status;\r |
395 | EFI_TPL OldTpl;\r | |
396 | \r | |
4cda7726 | 397 | if (This == NULL) {\r |
28db6da4 | 398 | return EFI_INVALID_PARAMETER;\r |
399 | }\r | |
400 | \r | |
4cda7726 | 401 | Snp = EFI_SIMPLE_NETWORK_DEV_FROM_THIS (This);\r |
28db6da4 | 402 | \r |
403 | OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r | |
404 | \r | |
4cda7726 | 405 | switch (Snp->Mode.State) {\r |
d1050b9d MK |
406 | case EfiSimpleNetworkInitialized:\r |
407 | break;\r | |
28db6da4 | 408 | \r |
d1050b9d MK |
409 | case EfiSimpleNetworkStopped:\r |
410 | Status = EFI_NOT_STARTED;\r | |
411 | goto ON_EXIT;\r | |
28db6da4 | 412 | \r |
d1050b9d MK |
413 | default:\r |
414 | Status = EFI_DEVICE_ERROR;\r | |
415 | goto ON_EXIT;\r | |
28db6da4 | 416 | }\r |
d1050b9d | 417 | \r |
28db6da4 | 418 | //\r |
419 | // check if we are asked to enable or disable something that the UNDI\r | |
420 | // does not even support!\r | |
421 | //\r | |
4cda7726 | 422 | if (((Enable &~Snp->Mode.ReceiveFilterMask) != 0) ||\r |
d1050b9d MK |
423 | ((Disable &~Snp->Mode.ReceiveFilterMask) != 0))\r |
424 | {\r | |
28db6da4 | 425 | Status = EFI_INVALID_PARAMETER;\r |
426 | goto ON_EXIT;\r | |
427 | }\r | |
428 | \r | |
4cda7726 | 429 | if (ResetMCastFilter) {\r |
d1050b9d | 430 | Disable |= EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST & Snp->Mode.ReceiveFilterMask;\r |
4cda7726 | 431 | MCastFilterCnt = 0;\r |
432 | MCastFilter = NULL;\r | |
28db6da4 | 433 | } else {\r |
4cda7726 | 434 | if (MCastFilterCnt != 0) {\r |
435 | if ((MCastFilterCnt > Snp->Mode.MaxMCastFilterCount) ||\r | |
d1050b9d MK |
436 | (MCastFilter == NULL))\r |
437 | {\r | |
28db6da4 | 438 | Status = EFI_INVALID_PARAMETER;\r |
439 | goto ON_EXIT;\r | |
440 | }\r | |
441 | }\r | |
442 | }\r | |
443 | \r | |
d1050b9d | 444 | if ((Enable == 0) && (Disable == 0) && !ResetMCastFilter && (MCastFilterCnt == 0)) {\r |
28db6da4 | 445 | Status = EFI_SUCCESS;\r |
446 | goto ON_EXIT;\r | |
447 | }\r | |
448 | \r | |
d1050b9d | 449 | if (((Enable & EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST) != 0) && (MCastFilterCnt == 0)) {\r |
28db6da4 | 450 | Status = EFI_INVALID_PARAMETER;\r |
451 | goto ON_EXIT;\r | |
452 | }\r | |
453 | \r | |
4cda7726 | 454 | if ((Enable != 0) || (MCastFilterCnt != 0)) {\r |
455 | Status = PxeRecvFilterEnable (\r | |
456 | Snp,\r | |
457 | Enable,\r | |
458 | MCastFilterCnt,\r | |
459 | MCastFilter\r | |
460 | );\r | |
28db6da4 | 461 | \r |
462 | if (EFI_ERROR (Status)) {\r | |
463 | goto ON_EXIT;\r | |
464 | }\r | |
465 | }\r | |
466 | \r | |
4cda7726 | 467 | if ((Disable != 0) || ResetMCastFilter) {\r |
468 | Status = PxeRecvFilterDisable (Snp, Disable, ResetMCastFilter);\r | |
28db6da4 | 469 | \r |
470 | if (EFI_ERROR (Status)) {\r | |
471 | goto ON_EXIT;\r | |
472 | }\r | |
473 | }\r | |
474 | \r | |
4cda7726 | 475 | Status = PxeRecvFilterRead (Snp);\r |
28db6da4 | 476 | \r |
477 | ON_EXIT:\r | |
478 | gBS->RestoreTPL (OldTpl);\r | |
479 | \r | |
480 | return Status;\r | |
481 | }\r |