58 Status =
gBS->OpenProtocol (
60 &gEfiDevicePathProtocolGuid,
61 (VOID **)&ParentDevicePath,
64 EFI_OPEN_PROTOCOL_GET_PROTOCOL
66 if (EFI_ERROR (Status)) {
79 if (VlanDevicePath ==
NULL) {
87 Status =
gBS->InstallMultipleProtocolInterfaces (
89 &gEfiDevicePathProtocolGuid,
93 if (EFI_ERROR (Status)) {
98 if (Devicepath !=
NULL) {
99 *Devicepath = VlanDevicePath;
124 UINTN ProtocolOffset;
128 ProtocolOffset = MnpDeviceData->Snp->Mode->HwAddressSize * 2;
134 ASSERT (Packet !=
NULL);
140 ProtocolType = NTOHS (*(UINT16 *)(Packet + ProtocolOffset));
141 if (ProtocolType != ETHER_TYPE_VLAN) {
148 VlanTag.Uint16 = NTOHS (*(UINT16 *)(Packet + ProtocolOffset +
sizeof (ProtocolType)));
149 *VlanId = VlanTag.Bits.Vid;
154 CopyMem (Packet + NET_VLAN_TAG_LEN, Packet, ProtocolOffset);
159 NetbufTrim (Nbuf, NET_VLAN_TAG_LEN, NET_BUF_HEAD);
180 OUT UINT16 *ProtocolType,
181 IN OUT UINT8 **Packet,
182 IN OUT UINT32 *Length
191 MnpDeviceData = MnpServiceData->MnpDeviceData;
192 SnpMode = MnpDeviceData->Snp->
Mode;
194 *ProtocolType = ETHER_TYPE_VLAN;
195 *Length = *Length + NET_VLAN_TAG_LEN;
196 *Packet = *Packet - NET_VLAN_TAG_LEN;
198 Tpid = (UINT16 *)(*Packet + SnpMode->
MediaHeaderSize - sizeof (*ProtocolType));
200 if (TxData->HeaderLength != 0) {
206 *Packet + NET_VLAN_TAG_LEN,
209 *Tpid = HTONS (ETHER_TYPE_VLAN);
214 EtherType = (UINT16 *)(
UINTN)(VlanTci + 1);
215 *EtherType = HTONS (TxData->ProtocolType);
218 VlanTci->Bits.Vid = MnpServiceData->VlanId;
219 VlanTci->Bits.Cfi = VLAN_TCI_CFI_CANONICAL_MAC;
220 VlanTci->Bits.Priority = MnpServiceData->Priority;
221 VlanTci->Uint16 = HTONS (VlanTci->Uint16);
247 BOOLEAN FoundDuplicateItem;
251 FoundDuplicateItem =
FALSE;
254 for (Index = 0; Index < NumberOfVlan; Index++) {
255 for (Index2 = Index + 1; Index2 < NumberOfVlan; Index2++) {
256 if (Buffer[Index].Bits.Vid == Buffer[Index2].Bits.Vid) {
257 FoundDuplicateItem =
TRUE;
263 if (FoundDuplicateItem) {
264 for (Index2 = Index +1; Index2 < NumberOfVlan; Index++, Index2++) {
269 FoundDuplicateItem =
FALSE;
272 *NewNumberOfVlan = NumberOfVlan - Count;
304 UINTN NewNumberOfVlan;
311 Status =
gRT->GetVariable (
312 MnpDeviceData->MacString,
313 &gEfiVlanConfigProtocolGuid,
318 if (Status != EFI_BUFFER_TOO_SMALL) {
319 return EFI_NOT_FOUND;
326 if (Buffer ==
NULL) {
327 return EFI_OUT_OF_RESOURCES;
330 Status =
gRT->GetVariable (
331 MnpDeviceData->MacString,
332 &gEfiVlanConfigProtocolGuid,
337 if (EFI_ERROR (Status)) {
343 if (!EFI_ERROR (Status)) {
344 *NumberOfVlan = NewNumberOfVlan;
345 *VlanVariable = Buffer;
369 return gRT->SetVariable (
370 MnpDeviceData->MacString,
371 &gEfiVlanConfigProtocolGuid,
427 if ((This ==
NULL) || (VlanId > 4094) || (Priority > 7)) {
428 return EFI_INVALID_PARAMETER;
432 MnpDeviceData = MNP_DEVICE_DATA_FROM_THIS (This);
433 if (MnpDeviceData->NumberOfVlan == 0) {
439 MnpServiceData = MNP_SERVICE_DATA_FROM_LINK (Entry);
446 if (EFI_ERROR (Status)) {
451 if (EFI_ERROR (Status)) {
459 if (MnpServiceData ==
NULL) {
460 return EFI_OUT_OF_RESOURCES;
468 if (MnpServiceData ==
NULL) {
474 if (MnpServiceData ==
NULL) {
475 return EFI_OUT_OF_RESOURCES;
480 MnpServiceData->VlanId = VlanId;
481 MnpServiceData->Priority = Priority;
483 MnpDeviceData->NumberOfVlan++;
499 if (NewVariable ==
NULL) {
500 Status = EFI_OUT_OF_RESOURCES;
504 if (OldVariable !=
NULL) {
508 Index = NumberOfVlan++;
513 for (Index = 0; Index < NumberOfVlan; Index++) {
514 if (OldVariable[Index].Bits.Vid == VlanId) {
519 ASSERT (Index < NumberOfVlan);
521 NewVariable = OldVariable;
525 NewVariable[Index].Bits.Vid = VlanId;
526 NewVariable[Index].Bits.Priority = Priority;
532 if (OldVariable !=
NULL) {
562 IN UINT16 *VlanId OPTIONAL,
563 OUT UINT16 *NumberOfVlan,
572 if ((This ==
NULL) || ((VlanId !=
NULL) && (*VlanId > 4094)) || (NumberOfVlan ==
NULL) || (Entries ==
NULL)) {
573 return EFI_INVALID_PARAMETER;
579 MnpDeviceData = MNP_DEVICE_DATA_FROM_THIS (This);
580 if (MnpDeviceData->NumberOfVlan == 0) {
581 return EFI_NOT_FOUND;
584 if (VlanId ==
NULL) {
588 *NumberOfVlan = (UINT16)MnpDeviceData->NumberOfVlan;
590 if (VlanData ==
NULL) {
591 return EFI_OUT_OF_RESOURCES;
595 NET_LIST_FOR_EACH (Entry, &MnpDeviceData->ServiceList) {
596 MnpServiceData = MNP_SERVICE_DATA_FROM_LINK (Entry);
598 VlanData->
VlanId = MnpServiceData->VlanId;
599 VlanData->
Priority = MnpServiceData->Priority;
610 if (MnpServiceData ==
NULL) {
611 return EFI_NOT_FOUND;
615 if (VlanData ==
NULL) {
616 return EFI_OUT_OF_RESOURCES;
619 VlanData->
VlanId = MnpServiceData->VlanId;
620 VlanData->
Priority = MnpServiceData->Priority;
659 if ((This ==
NULL) || (VlanId > 4094)) {
660 return EFI_INVALID_PARAMETER;
663 MnpDeviceData = MNP_DEVICE_DATA_FROM_THIS (This);
664 if (MnpDeviceData->NumberOfVlan == 0) {
665 return EFI_NOT_FOUND;
672 if (MnpServiceData ==
NULL) {
673 return EFI_NOT_FOUND;
676 MnpDeviceData->NumberOfVlan--;
678 if ((VlanId != 0) || (MnpDeviceData->NumberOfVlan != 0)) {
684 if (EFI_ERROR (Status)) {
689 if (EFI_ERROR (Status)) {
694 if ((VlanId != 0) && (MnpDeviceData->NumberOfVlan == 0)) {
699 if (MnpServiceData ==
NULL) {
700 return EFI_OUT_OF_RESOURCES;
708 if (MnpDeviceData->NumberOfVlan != 0) {
710 if (VlanVariable ==
NULL) {
711 return EFI_OUT_OF_RESOURCES;
714 VlanData = VlanVariable;
715 NET_LIST_FOR_EACH (Entry, &MnpDeviceData->ServiceList) {
716 MnpServiceData = MNP_SERVICE_DATA_FROM_LINK (Entry);
718 VlanData->Bits.Vid = MnpServiceData->VlanId;
719 VlanData->Bits.Priority = MnpServiceData->Priority;
724 Status =
MnpSetVlanVariable (MnpDeviceData, MnpDeviceData->NumberOfVlan, VlanVariable);
726 if (VlanVariable !=
NULL) {
LIST_ENTRY *EFIAPI GetFirstNode(IN CONST LIST_ENTRY *List)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
#define MESSAGING_DEVICE_PATH
EFI_DEVICE_PATH_PROTOCOL *EFIAPI AppendDevicePathNode(IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath OPTIONAL, IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathNode OPTIONAL)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
EFI_RUNTIME_SERVICES * gRT
MNP_SERVICE_DATA * MnpFindServiceData(IN MNP_DEVICE_DATA *MnpDeviceData, IN UINT16 VlanId)
EFI_STATUS MnpDestroyServiceChild(IN OUT MNP_SERVICE_DATA *MnpServiceData)
EFI_STATUS MnpDestroyServiceData(IN OUT MNP_SERVICE_DATA *MnpServiceData)
MNP_SERVICE_DATA * MnpCreateServiceData(IN MNP_DEVICE_DATA *MnpDeviceData, IN UINT16 VlanId, IN UINT8 Priority OPTIONAL)
EFI_STATUS MnpCheckVlanVariable(IN MNP_DEVICE_DATA *MnpDeviceData, IN VLAN_TCI *Buffer, IN UINTN NumberOfVlan, OUT UINTN *NewNumberOfVlan)
BOOLEAN MnpRemoveVlanTag(IN OUT MNP_DEVICE_DATA *MnpDeviceData, IN OUT NET_BUF *Nbuf, OUT UINT16 *VlanId)
EFI_STATUS EFIAPI VlanConfigSet(IN EFI_VLAN_CONFIG_PROTOCOL *This, IN UINT16 VlanId, IN UINT8 Priority)
EFI_STATUS EFIAPI VlanConfigFind(IN EFI_VLAN_CONFIG_PROTOCOL *This, IN UINT16 *VlanId OPTIONAL, OUT UINT16 *NumberOfVlan, OUT EFI_VLAN_FIND_DATA **Entries)
EFI_HANDLE MnpCreateVlanChild(IN EFI_HANDLE ImageHandle, IN EFI_HANDLE ControllerHandle, IN UINT16 VlanId, OUT EFI_DEVICE_PATH_PROTOCOL **Devicepath OPTIONAL)
EFI_STATUS EFIAPI VlanConfigRemove(IN EFI_VLAN_CONFIG_PROTOCOL *This, IN UINT16 VlanId)
EFI_STATUS MnpGetVlanVariable(IN MNP_DEVICE_DATA *MnpDeviceData, OUT UINTN *NumberOfVlan, OUT VLAN_TCI **VlanVariable)
EFI_STATUS MnpSetVlanVariable(IN MNP_DEVICE_DATA *MnpDeviceData, IN UINTN NumberOfVlan, IN VLAN_TCI *VlanVariable)
VOID MnpInsertVlanTag(IN MNP_SERVICE_DATA *MnpServiceData, IN EFI_MANAGED_NETWORK_TRANSMIT_DATA *TxData, OUT UINT16 *ProtocolType, IN OUT UINT8 **Packet, IN OUT UINT32 *Length)
UINT32 EFIAPI NetbufTrim(IN OUT NET_BUF *Nbuf, IN UINT32 Len, IN BOOLEAN FromHead)
UINT8 *EFIAPI NetbufGetByte(IN NET_BUF *Nbuf, IN UINT32 Offset, OUT UINT32 *Index OPTIONAL)
VOID *EFIAPI AllocatePool(IN UINTN AllocationSize)
VOID EFIAPI Exit(IN EFI_STATUS Status)
#define EFI_VARIABLE_NON_VOLATILE
EFI_SIMPLE_NETWORK_MODE * Mode
UINT8 Priority
Priority of this VLAN.
UINT16 VlanId
Vlan Identifier.