[edk2-devel] [edk2-platforms PATCH 2/8] Marvell/Drivers: Pp2Dxe: Fix Pp2SnpReceiveFilters

Marcin Wojtas mw at semihalf.com
Mon Mar 14 15:38:31 UTC 2022


Until now the Pp2SnpReceiveFilters callback unconditionally
returned EFI_SUCCESS. Allow proper handling of the input
values on the protocol level. Keep the HW registers intact.

Signed-off-by: Marcin Wojtas <mw at semihalf.com>
---
 Silicon/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.c | 62 +++++++++++++++++++-
 1 file changed, 61 insertions(+), 1 deletion(-)

diff --git a/Silicon/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.c b/Silicon/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.c
index 30e091f807..3e09fafc4c 100644
--- a/Silicon/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.c
+++ b/Silicon/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.c
@@ -725,7 +725,67 @@ Pp2SnpReceiveFilters (
   IN EFI_MAC_ADDRESS             *MCastFilter OPTIONAL
   )
 {
-  return EFI_SUCCESS;
+  PP2DXE_CONTEXT *Pp2Context;
+  EFI_TPL SavedTpl;
+  UINTN Count;
+
+  /* Check Snp Instance. */
+  if (This == NULL) {
+    return EFI_INVALID_PARAMETER;
+  }
+
+  SavedTpl = gBS->RaiseTPL (TPL_CALLBACK);
+
+  Pp2Context = INSTANCE_FROM_SNP(This);
+
+  /* Check whether the driver was started and initialized. */
+  if (This->Mode->State != EfiSimpleNetworkInitialized) {
+    switch (This->Mode->State) {
+    case EfiSimpleNetworkStopped:
+      DEBUG ((DEBUG_WARN, "Pp2Dxe%d: not started\n", Pp2Context->Instance));
+      ReturnUnlock (SavedTpl, EFI_NOT_STARTED);
+    case EfiSimpleNetworkStarted:
+      DEBUG ((DEBUG_WARN, "Pp2Dxe%d: not initialized\n", Pp2Context->Instance));
+      ReturnUnlock (SavedTpl, EFI_DEVICE_ERROR);
+    default:
+      DEBUG ((DEBUG_WARN,
+        "Pp2Dxe%d: wrong state: %u\n",
+        Pp2Context->Instance,
+        This->Mode->State));
+      ReturnUnlock (SavedTpl, EFI_DEVICE_ERROR);
+    }
+  }
+
+  if (((Enable | Disable) & ~This->Mode->ReceiveFilterMask) != 0) {
+    ReturnUnlock (SavedTpl, EFI_INVALID_PARAMETER);
+  }
+
+  if (!ResetMCastFilter &&
+      (Disable & EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST) == 0 &&
+      (Enable & EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST) != 0) {
+    if (MCastFilterCnt == 0 ||
+        MCastFilterCnt > This->Mode->MaxMCastFilterCount ||
+        MCastFilter == NULL) {
+      ReturnUnlock (SavedTpl, EFI_INVALID_PARAMETER);
+    }
+
+    for (Count = 0; Count < MCastFilterCnt; Count++) {
+      if ((MCastFilter[Count].Addr[0] & 1) == 0) {
+        ReturnUnlock (SavedTpl, EFI_INVALID_PARAMETER);
+      }
+      CopyMem (&This->Mode->MCastFilter[Count],
+        &MCastFilter[Count],
+        sizeof (EFI_MAC_ADDRESS));
+    }
+    This->Mode->MCastFilterCount = MCastFilterCnt;
+  } else if (ResetMCastFilter) {
+    This->Mode->MCastFilterCount = 0;
+  }
+
+  This->Mode->ReceiveFilterSetting |= Enable;
+  This->Mode->ReceiveFilterSetting &= ~Disable;
+
+  ReturnUnlock (SavedTpl, EFI_SUCCESS);
 }
 
 EFI_STATUS
-- 
2.29.0



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#87541): https://edk2.groups.io/g/devel/message/87541
Mute This Topic: https://groups.io/mt/89776251/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-




More information about the edk2-devel-archive mailing list