Changeset 99404 in vbox for trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/MnpDxe/MnpVlan.c
- Timestamp:
- Apr 14, 2023 3:17:44 PM (22 months ago)
- Location:
- trunk/src/VBox/Devices/EFI/FirmwareNew
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/EFI/FirmwareNew
-
Property svn:mergeinfo
changed from (toggle deleted branches)
to (toggle deleted branches)/vendor/edk2/current 103735-103757,103769-103776,129194-145445 /vendor/edk2/current 103735-103757,103769-103776,129194-156846
-
Property svn:mergeinfo
changed from (toggle deleted branches)
-
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/MnpDxe/MnpVlan.c
r80721 r99404 10 10 #include "MnpVlan.h" 11 11 12 VLAN_DEVICE_PATH 12 VLAN_DEVICE_PATH mVlanDevicePathTemplate = { 13 13 { 14 14 MESSAGING_DEVICE_PATH, 15 15 MSG_VLAN_DP, 16 16 { 17 (UINT8) 18 (UINT8) 17 (UINT8)(sizeof (VLAN_DEVICE_PATH)), 18 (UINT8)((sizeof (VLAN_DEVICE_PATH)) >> 8) 19 19 } 20 20 }, … … 28 28 }; 29 29 30 31 30 /** 32 31 Create a child handle for the VLAN ID. … … 42 41 EFI_HANDLE 43 42 MnpCreateVlanChild ( 44 IN EFI_HANDLE 45 IN EFI_HANDLE 46 IN UINT16 47 OUT EFI_DEVICE_PATH_PROTOCOL**Devicepath OPTIONAL43 IN EFI_HANDLE ImageHandle, 44 IN EFI_HANDLE ControllerHandle, 45 IN UINT16 VlanId, 46 OUT EFI_DEVICE_PATH_PROTOCOL **Devicepath OPTIONAL 48 47 ) 49 48 { … … 60 59 ControllerHandle, 61 60 &gEfiDevicePathProtocolGuid, 62 (VOID **) 61 (VOID **)&ParentDevicePath, 63 62 ImageHandle, 64 63 ControllerHandle, … … 74 73 CopyMem (&VlanNode, &mVlanDevicePathTemplate, sizeof (VLAN_DEVICE_PATH)); 75 74 VlanNode.VlanId = VlanId; 76 VlanDevicePath = AppendDevicePathNode (77 ParentDevicePath,78 (EFI_DEVICE_PATH_PROTOCOL *)&VlanNode79 );75 VlanDevicePath = AppendDevicePathNode ( 76 ParentDevicePath, 77 (EFI_DEVICE_PATH_PROTOCOL *)&VlanNode 78 ); 80 79 if (VlanDevicePath == NULL) { 81 80 return NULL; … … 86 85 // 87 86 ChildHandle = NULL; 88 Status = gBS->InstallMultipleProtocolInterfaces (89 &ChildHandle,90 &gEfiDevicePathProtocolGuid,91 VlanDevicePath,92 NULL93 );87 Status = gBS->InstallMultipleProtocolInterfaces ( 88 &ChildHandle, 89 &gEfiDevicePathProtocolGuid, 90 VlanDevicePath, 91 NULL 92 ); 94 93 if (EFI_ERROR (Status)) { 95 94 FreePool (VlanDevicePath); … … 117 116 BOOLEAN 118 117 MnpRemoveVlanTag ( 119 IN OUT MNP_DEVICE_DATA 120 IN OUT NET_BUF 121 OUT UINT16*VlanId118 IN OUT MNP_DEVICE_DATA *MnpDeviceData, 119 IN OUT NET_BUF *Nbuf, 120 OUT UINT16 *VlanId 122 121 ) 123 122 { … … 139 138 // 140 139 *VlanId = 0; 141 ProtocolType = NTOHS (*(UINT16 *) 140 ProtocolType = NTOHS (*(UINT16 *)(Packet + ProtocolOffset)); 142 141 if (ProtocolType != ETHER_TYPE_VLAN) { 143 142 // … … 147 146 } 148 147 149 VlanTag.Uint16 = NTOHS (*(UINT16 *) 150 *VlanId = VlanTag.Bits.Vid;148 VlanTag.Uint16 = NTOHS (*(UINT16 *)(Packet + ProtocolOffset + sizeof (ProtocolType))); 149 *VlanId = VlanTag.Bits.Vid; 151 150 152 151 // … … 162 161 return TRUE; 163 162 } 164 165 163 166 164 /** … … 178 176 VOID 179 177 MnpInsertVlanTag ( 180 IN MNP_SERVICE_DATA 181 IN EFI_MANAGED_NETWORK_TRANSMIT_DATA 182 OUT UINT16*ProtocolType,183 IN OUT UINT8 184 IN OUT UINT32 185 ) 186 { 187 VLAN_TCI *VlanTci;188 UINT16 *Tpid;189 UINT16 *EtherType;190 MNP_DEVICE_DATA *MnpDeviceData;191 EFI_SIMPLE_NETWORK_MODE *SnpMode;178 IN MNP_SERVICE_DATA *MnpServiceData, 179 IN EFI_MANAGED_NETWORK_TRANSMIT_DATA *TxData, 180 OUT UINT16 *ProtocolType, 181 IN OUT UINT8 **Packet, 182 IN OUT UINT32 *Length 183 ) 184 { 185 VLAN_TCI *VlanTci; 186 UINT16 *Tpid; 187 UINT16 *EtherType; 188 MNP_DEVICE_DATA *MnpDeviceData; 189 EFI_SIMPLE_NETWORK_MODE *SnpMode; 192 190 193 191 MnpDeviceData = MnpServiceData->MnpDeviceData; … … 195 193 196 194 *ProtocolType = ETHER_TYPE_VLAN; 197 *Length = *Length + NET_VLAN_TAG_LEN;198 *Packet = *Packet - NET_VLAN_TAG_LEN;199 200 Tpid = (UINT16 *) 201 VlanTci = (VLAN_TCI *) (UINTN)(Tpid + 1);195 *Length = *Length + NET_VLAN_TAG_LEN; 196 *Packet = *Packet - NET_VLAN_TAG_LEN; 197 198 Tpid = (UINT16 *)(*Packet + SnpMode->MediaHeaderSize - sizeof (*ProtocolType)); 199 VlanTci = (VLAN_TCI *)(UINTN)(Tpid + 1); 202 200 if (TxData->HeaderLength != 0) { 203 201 // … … 214 212 // Media header not in packet, VLAN TCI and original protocol type becomes payload 215 213 // 216 EtherType = (UINT16 *) (UINTN)(VlanTci + 1);214 EtherType = (UINT16 *)(UINTN)(VlanTci + 1); 217 215 *EtherType = HTONS (TxData->ProtocolType); 218 216 } … … 238 236 EFI_STATUS 239 237 MnpCheckVlanVariable ( 240 IN MNP_DEVICE_DATA 241 IN VLAN_TCI 242 IN UINTN 243 OUT UINTN*NewNumberOfVlan244 ) 245 { 246 UINTN 247 UINTN 248 UINTN 249 BOOLEAN 250 EFI_STATUS 251 252 Count = 0;253 FoundDuplicateItem 254 Status = EFI_SUCCESS;238 IN MNP_DEVICE_DATA *MnpDeviceData, 239 IN VLAN_TCI *Buffer, 240 IN UINTN NumberOfVlan, 241 OUT UINTN *NewNumberOfVlan 242 ) 243 { 244 UINTN Index; 245 UINTN Index2; 246 UINTN Count; 247 BOOLEAN FoundDuplicateItem; 248 EFI_STATUS Status; 249 250 Count = 0; 251 FoundDuplicateItem = FALSE; 252 Status = EFI_SUCCESS; 255 253 256 254 for (Index = 0; Index < NumberOfVlan; Index++) { 257 for (Index2 = Index + 1; Index2 < NumberOfVlan; Index2++) { 258 if (Buffer[Index].Bits.Vid == Buffer[Index2].Bits.Vid) { 259 FoundDuplicateItem = TRUE; 260 Count++; 261 break; 262 } 263 } 264 if (FoundDuplicateItem) { 265 for (Index2 = Index +1; Index2 < NumberOfVlan; Index++, Index2++) { 266 CopyMem (Buffer + Index, Buffer + Index2, sizeof (VLAN_TCI)); 267 } 268 } 269 FoundDuplicateItem = FALSE; 255 for (Index2 = Index + 1; Index2 < NumberOfVlan; Index2++) { 256 if (Buffer[Index].Bits.Vid == Buffer[Index2].Bits.Vid) { 257 FoundDuplicateItem = TRUE; 258 Count++; 259 break; 260 } 261 } 262 263 if (FoundDuplicateItem) { 264 for (Index2 = Index +1; Index2 < NumberOfVlan; Index++, Index2++) { 265 CopyMem (Buffer + Index, Buffer + Index2, sizeof (VLAN_TCI)); 266 } 267 } 268 269 FoundDuplicateItem = FALSE; 270 270 } 271 271 … … 294 294 EFI_STATUS 295 295 MnpGetVlanVariable ( 296 IN MNP_DEVICE_DATA 297 OUT UINTN*NumberOfVlan,298 OUT VLAN_TCI**VlanVariable296 IN MNP_DEVICE_DATA *MnpDeviceData, 297 OUT UINTN *NumberOfVlan, 298 OUT VLAN_TCI **VlanVariable 299 299 ) 300 300 { … … 307 307 // Get VLAN configuration from EFI Variable 308 308 // 309 Buffer = NULL;309 Buffer = NULL; 310 310 BufferSize = 0; 311 Status = gRT->GetVariable (312 MnpDeviceData->MacString,313 &gEfiVlanConfigProtocolGuid,314 NULL,315 &BufferSize,316 NULL317 );311 Status = gRT->GetVariable ( 312 MnpDeviceData->MacString, 313 &gEfiVlanConfigProtocolGuid, 314 NULL, 315 &BufferSize, 316 NULL 317 ); 318 318 if (Status != EFI_BUFFER_TOO_SMALL) { 319 319 return EFI_NOT_FOUND; … … 362 362 EFI_STATUS 363 363 MnpSetVlanVariable ( 364 IN MNP_DEVICE_DATA 365 IN UINTN 366 IN VLAN_TCI 364 IN MNP_DEVICE_DATA *MnpDeviceData, 365 IN UINTN NumberOfVlan, 366 IN VLAN_TCI *VlanVariable 367 367 ) 368 368 { … … 376 376 } 377 377 378 379 378 /** 380 379 Create a VLAN device or modify the configuration parameter of an … … 411 410 EFIAPI 412 411 VlanConfigSet ( 413 IN EFI_VLAN_CONFIG_PROTOCOL 414 IN UINT16 415 IN UINT8 412 IN EFI_VLAN_CONFIG_PROTOCOL *This, 413 IN UINT16 VlanId, 414 IN UINT8 Priority 416 415 ) 417 416 { … … 430 429 } 431 430 432 IsAdd = FALSE;431 IsAdd = FALSE; 433 432 MnpDeviceData = MNP_DEVICE_DATA_FROM_THIS (This); 434 433 if (MnpDeviceData->NumberOfVlan == 0) { … … 436 435 // No existing VLAN, this is the first VLAN to add 437 436 // 438 IsAdd = TRUE;439 Entry = GetFirstNode (&MnpDeviceData->ServiceList);437 IsAdd = TRUE; 438 Entry = GetFirstNode (&MnpDeviceData->ServiceList); 440 439 MnpServiceData = MNP_SERVICE_DATA_FROM_LINK (Entry); 441 440 … … 471 470 // VlanId not found, create a new MNP service data 472 471 // 473 IsAdd = TRUE;472 IsAdd = TRUE; 474 473 MnpServiceData = MnpCreateServiceData (MnpDeviceData, VlanId, Priority); 475 474 if (MnpServiceData == NULL) { … … 479 478 } 480 479 481 MnpServiceData->VlanId = VlanId;480 MnpServiceData->VlanId = VlanId; 482 481 MnpServiceData->Priority = Priority; 483 482 if (IsAdd) { … … 517 516 } 518 517 } 518 519 519 ASSERT (Index < NumberOfVlan); 520 520 … … 536 536 return Status; 537 537 } 538 539 538 540 539 /** … … 560 559 EFIAPI 561 560 VlanConfigFind ( 562 IN EFI_VLAN_CONFIG_PROTOCOL 563 IN UINT16 564 OUT UINT16*NumberOfVlan,565 OUT EFI_VLAN_FIND_DATA**Entries561 IN EFI_VLAN_CONFIG_PROTOCOL *This, 562 IN UINT16 *VlanId OPTIONAL, 563 OUT UINT16 *NumberOfVlan, 564 OUT EFI_VLAN_FIND_DATA **Entries 566 565 ) 567 566 { … … 571 570 EFI_VLAN_FIND_DATA *VlanData; 572 571 573 if ((This == NULL) || ( VlanId != NULL && *VlanId > 4094) || (NumberOfVlan == NULL) || (Entries == NULL)) {572 if ((This == NULL) || ((VlanId != NULL) && (*VlanId > 4094)) || (NumberOfVlan == NULL) || (Entries == NULL)) { 574 573 return EFI_INVALID_PARAMETER; 575 574 } … … 587 586 // Return all current VLAN configuration 588 587 // 589 *NumberOfVlan = (UINT16) 590 VlanData = AllocateZeroPool (*NumberOfVlan * sizeof (EFI_VLAN_FIND_DATA));588 *NumberOfVlan = (UINT16)MnpDeviceData->NumberOfVlan; 589 VlanData = AllocateZeroPool (*NumberOfVlan * sizeof (EFI_VLAN_FIND_DATA)); 591 590 if (VlanData == NULL) { 592 591 return EFI_OUT_OF_RESOURCES; … … 597 596 MnpServiceData = MNP_SERVICE_DATA_FROM_LINK (Entry); 598 597 599 VlanData->VlanId = MnpServiceData->VlanId;598 VlanData->VlanId = MnpServiceData->VlanId; 600 599 VlanData->Priority = MnpServiceData->Priority; 601 600 VlanData++; … … 617 616 return EFI_OUT_OF_RESOURCES; 618 617 } 619 VlanData->VlanId = MnpServiceData->VlanId; 618 619 VlanData->VlanId = MnpServiceData->VlanId; 620 620 VlanData->Priority = MnpServiceData->Priority; 621 621 622 622 *NumberOfVlan = 1; 623 *Entries = VlanData;623 *Entries = VlanData; 624 624 625 625 return EFI_SUCCESS; 626 626 } 627 628 627 629 628 /** … … 647 646 EFIAPI 648 647 VlanConfigRemove ( 649 IN EFI_VLAN_CONFIG_PROTOCOL 650 IN UINT16 648 IN EFI_VLAN_CONFIG_PROTOCOL *This, 649 IN UINT16 VlanId 651 650 ) 652 651 {
Note:
See TracChangeset
for help on using the changeset viewer.