Corrected the code for dual MAC controllers. The YUKON_DRIVER driver's structure includes a controller port number. The SNP interface functions passing a msk_if_softc object (corresponding to the controller interface) to the if_msk interface functions. Multi-controller and multi-MAC support: use a linked list to store the association between EFI controller handle and the interface data structure.
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Daniil Egranov daniil.egranov@arm.com --- Drivers/Net/MarvellYukonDxe/DriverBinding.c | 451 +++++++++++++++++++--------- Drivers/Net/MarvellYukonDxe/MarvellYukon.h | 71 +++++ Drivers/Net/MarvellYukonDxe/Snp.c | 64 +++- 3 files changed, 437 insertions(+), 149 deletions(-)
diff --git a/Drivers/Net/MarvellYukonDxe/DriverBinding.c b/Drivers/Net/MarvellYukonDxe/DriverBinding.c index 95068fa..5269e7a 100644 --- a/Drivers/Net/MarvellYukonDxe/DriverBinding.c +++ b/Drivers/Net/MarvellYukonDxe/DriverBinding.c @@ -19,6 +19,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include "MarvellYukon.h" #include "if_msk.h"
+STATIC LIST_ENTRY MarvellYukonDrvDataHead; + /** Test to see if this driver supports ControllerHandle. This service is called by the EFI boot service ConnectController(). In @@ -110,27 +112,14 @@ MarvellYukonDriverStart ( MAC_ADDR_DEVICE_PATH MacDeviceNode; VOID *ChildPciIo; YUKON_DRIVER *YukonDriver; - - Status = gBS->AllocatePool (EfiBootServicesData, - sizeof (YUKON_DRIVER), - (VOID**) &YukonDriver); - if (EFI_ERROR (Status)) { - DEBUG ((EFI_D_ERROR, "Marvell Yukon: AllocatePool() failed with Status = %r\n", EFI_OUT_OF_RESOURCES)); - return Status; - } - - gBS->SetMem (YukonDriver, sizeof (YUKON_DRIVER), 0); - EfiInitializeLock (&YukonDriver->Lock, TPL_NOTIFY); - - // - // Set the structure signature - // - YukonDriver->Signature = YUKON_DRIVER_SIGNATURE; + struct msk_softc *ScData; + EFI_PCI_IO_PROTOCOL *PciIo; + UINTN Port;
Status = gBS->OpenProtocol ( Controller, &gEfiPciIoProtocolGuid, - (VOID **) &YukonDriver->PciIo, + (VOID **) &PciIo, pThis->DriverBindingHandle, Controller, EFI_OPEN_PROTOCOL_BY_DRIVER @@ -143,131 +132,133 @@ MarvellYukonDriverStart ( }
// - // Initialize the simple network protocol + // Initialize Marvell Yukon controller + // Get number of ports and MAC address for each port // - Status = InitializeSNPProtocol (YukonDriver); - - if (EFI_ERROR(Status)){ - DEBUG ((EFI_D_ERROR, "Marvell Yukon: InitializeSNPProtocol: ERROR Status = %r\n", Status)); - gBS->CloseProtocol ( - Controller, - &gEfiPciIoProtocolGuid, - pThis->DriverBindingHandle, - Controller - ); + Status = mskc_attach (PciIo, &ScData); + if (EFI_ERROR (Status)) { + return Status; }
- // - // Set Device Path - // - Status = gBS->OpenProtocol ( - Controller, - &gEfiDevicePathProtocolGuid, - (VOID **) &ParentDevicePath, - pThis->DriverBindingHandle, - Controller, - EFI_OPEN_PROTOCOL_GET_PROTOCOL - ); + Status = MarvellYukonAddControllerData (Controller, ScData); + if (EFI_ERROR (Status)) { + return Status; + }
- if (EFI_ERROR(Status)) { - DEBUG ((EFI_D_ERROR, "Marvell Yukon: OpenProtocol:EFI_DEVICE_PATH_PROTOCOL error. Status = %r\n", Status)); + for (Port = 0; Port < ScData->msk_num_port; Port++) {
- gBS->CloseProtocol ( - Controller, - &gEfiPciIoProtocolGuid, - pThis->DriverBindingHandle, - Controller - ); + Status = gBS->AllocatePool (EfiBootServicesData, + sizeof (YUKON_DRIVER), + (VOID**) &YukonDriver); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "Marvell Yukon: AllocatePool() failed with Status = %r\n", Status)); + return Status; + }
- gBS->FreePool (YukonDriver); - return Status; - } + if(ScData->msk_if[Port] == NULL) { + DEBUG ((DEBUG_ERROR, "Marvell Yukon: AllocatePool() failed with Status = %r\n", EFI_BAD_BUFFER_SIZE)); + return EFI_BAD_BUFFER_SIZE; + }
- gBS->SetMem (&MacDeviceNode, sizeof (MAC_ADDR_DEVICE_PATH), 0); - MacDeviceNode.Header.Type = MESSAGING_DEVICE_PATH; - MacDeviceNode.Header.SubType = MSG_MAC_ADDR_DP; + gBS->SetMem (YukonDriver, sizeof (YUKON_DRIVER), 0); + EfiInitializeLock (&YukonDriver->Lock, TPL_NOTIFY);
- SetDevicePathNodeLength (&MacDeviceNode, sizeof (MacDeviceNode)); + // + // Set the structure signature + // + YukonDriver->Signature = YUKON_DRIVER_SIGNATURE;
- // - // Initialize Yukon card so we can get the MAC address - // - Status = mskc_attach (YukonDriver->PciIo, &YukonDriver->SnpMode.PermanentAddress); + // + // Set MAC address + // + gBS->CopyMem (&YukonDriver->SnpMode.PermanentAddress, &(ScData->msk_if[Port])->MacAddress, sizeof (EFI_MAC_ADDRESS));
- if (EFI_ERROR (Status)) { - gBS->FreePool (YukonDriver); - return Status; - } + // + // Set Port number + // + YukonDriver->Port = Port;
- mskc_detach(); + // + // Initialize the simple network protocol + // + Status = InitializeSNPProtocol (YukonDriver);
- // - // Assign fields for device path - // - gBS->CopyMem (&YukonDriver->SnpMode.CurrentAddress, &YukonDriver->SnpMode.PermanentAddress, sizeof (EFI_MAC_ADDRESS)); - gBS->CopyMem (&MacDeviceNode.MacAddress, &YukonDriver->SnpMode.CurrentAddress, sizeof (EFI_MAC_ADDRESS)); + if (EFI_ERROR(Status)){ + DEBUG ((DEBUG_ERROR, "Marvell Yukon: InitializeSNPProtocol: ERROR Status = %r\n", Status)); + gBS->CloseProtocol ( + Controller, + &gEfiPciIoProtocolGuid, + pThis->DriverBindingHandle, + Controller + ); + }
- MacDeviceNode.IfType = YukonDriver->SnpMode.IfType; - YukonDriver->DevicePath = AppendDevicePathNode (ParentDevicePath, &MacDeviceNode.Header); - if (YukonDriver->DevicePath == NULL) { - DEBUG ((EFI_D_ERROR, "Marvell Yukon: AppendDevicePathNode: ERROR Status = %r\n", EFI_OUT_OF_RESOURCES)); - gBS->CloseProtocol ( + // + // Set Device Path + // + Status = gBS->OpenProtocol ( Controller, - &gEfiPciIoProtocolGuid, + &gEfiDevicePathProtocolGuid, + (VOID **) &ParentDevicePath, pThis->DriverBindingHandle, - Controller + Controller, + EFI_OPEN_PROTOCOL_GET_PROTOCOL ); - gBS->FreePool (YukonDriver); - return EFI_OUT_OF_RESOURCES; - }
- // - // Install both the simple network and device path protocols. - // - Status = gBS->InstallMultipleProtocolInterfaces ( - &YukonDriver->Controller, - &gEfiSimpleNetworkProtocolGuid, - &YukonDriver->Snp, - &gEfiDevicePathProtocolGuid, - YukonDriver->DevicePath, - NULL - ); + if (EFI_ERROR(Status)) { + DEBUG ((DEBUG_ERROR, "Marvell Yukon: OpenProtocol:EFI_DEVICE_PATH_PROTOCOL error. Status = %r\n", Status));
- if (EFI_ERROR(Status)){ - DEBUG ((EFI_D_ERROR, "Marvell Yukon: InstallMultipleProtocolInterfaces error. Status = %r\n", Status)); + gBS->CloseProtocol ( + Controller, + &gEfiPciIoProtocolGuid, + pThis->DriverBindingHandle, + Controller + );
- gBS->CloseProtocol ( - Controller, - &gEfiPciIoProtocolGuid, - pThis->DriverBindingHandle, - Controller - ); + gBS->FreePool (YukonDriver); + return Status; + }
- gBS->FreePool (YukonDriver->DevicePath); - gBS->FreePool (YukonDriver); - return Status; - } else { + gBS->SetMem (&MacDeviceNode, sizeof (MAC_ADDR_DEVICE_PATH), 0); + MacDeviceNode.Header.Type = MESSAGING_DEVICE_PATH; + MacDeviceNode.Header.SubType = MSG_MAC_ADDR_DP; + + SetDevicePathNodeLength (&MacDeviceNode, sizeof (MacDeviceNode));
// - // Hook as a child device + // Assign fields for device path // - Status = gBS->OpenProtocol (Controller, - &gEfiPciIoProtocolGuid, - &ChildPciIo, - pThis->DriverBindingHandle, - YukonDriver->Controller, - EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER); - if (EFI_ERROR(Status)){ - DEBUG ((EFI_D_ERROR, "Marvell Yukon: OpenProtocol: child controller error. Status = %r\n", Status)); + gBS->CopyMem (&YukonDriver->SnpMode.CurrentAddress, &YukonDriver->SnpMode.PermanentAddress, sizeof (EFI_MAC_ADDRESS)); + gBS->CopyMem (&MacDeviceNode.MacAddress, &YukonDriver->SnpMode.CurrentAddress, sizeof (EFI_MAC_ADDRESS));
- gBS->UninstallMultipleProtocolInterfaces ( + MacDeviceNode.IfType = YukonDriver->SnpMode.IfType; + YukonDriver->DevicePath = AppendDevicePathNode (ParentDevicePath, &MacDeviceNode.Header); + if (YukonDriver->DevicePath == NULL) { + DEBUG ((DEBUG_ERROR, "Marvell Yukon: AppendDevicePathNode: ERROR Status = %r\n", EFI_OUT_OF_RESOURCES)); + gBS->CloseProtocol ( Controller, - &gEfiSimpleNetworkProtocolGuid, - &YukonDriver->Snp, - &gEfiDevicePathProtocolGuid, - YukonDriver->DevicePath, - NULL + &gEfiPciIoProtocolGuid, + pThis->DriverBindingHandle, + Controller ); + gBS->FreePool (YukonDriver); + return EFI_OUT_OF_RESOURCES; + } + + // + // Install both the simple network and device path protocols. + // + Status = gBS->InstallMultipleProtocolInterfaces ( + &YukonDriver->Controller, + &gEfiSimpleNetworkProtocolGuid, + &YukonDriver->Snp, + &gEfiDevicePathProtocolGuid, + YukonDriver->DevicePath, + NULL + ); + + if (EFI_ERROR(Status)){ + DEBUG ((DEBUG_ERROR, "Marvell Yukon: InstallMultipleProtocolInterfaces error. Status = %r\n", Status));
gBS->CloseProtocol ( Controller, @@ -280,13 +271,53 @@ MarvellYukonDriverStart ( gBS->FreePool (YukonDriver); return Status; } else { - DEBUG ((EFI_D_NET, "Marvell Yukon: MarvellYukonDriverSupported: New Controller Handle = %p\n", YukonDriver->Controller)); + + // + // Hook as a child device + // + Status = gBS->OpenProtocol (Controller, + &gEfiPciIoProtocolGuid, + &ChildPciIo, + pThis->DriverBindingHandle, + YukonDriver->Controller, + EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER); + if (EFI_ERROR(Status)){ + DEBUG ((DEBUG_ERROR, "Marvell Yukon: OpenProtocol: child controller error. Status = %r\n", Status)); + + gBS->UninstallMultipleProtocolInterfaces ( + Controller, + &gEfiSimpleNetworkProtocolGuid, + &YukonDriver->Snp, + &gEfiDevicePathProtocolGuid, + YukonDriver->DevicePath, + NULL + ); + + gBS->CloseProtocol ( + Controller, + &gEfiPciIoProtocolGuid, + pThis->DriverBindingHandle, + Controller + ); + + gBS->FreePool (YukonDriver->DevicePath); + gBS->FreePool (YukonDriver); + return Status; + } else { + DEBUG ((DEBUG_NET, "Marvell Yukon: MarvellYukonDriverSupported: New Controller Handle = %p\n", YukonDriver->Controller)); + } + + Status = MarvellYukonAddControllerData (YukonDriver->Controller, ScData); + if (EFI_ERROR(Status)){ + DEBUG ((DEBUG_ERROR, "Marvell Yukon: Failed to register port %d with controller handle %p\n", Port, YukonDriver->Controller)); + } + } - }
- if (!EFI_ERROR(Status)) { - Status = gBS->CreateEvent (EVT_SIGNAL_EXIT_BOOT_SERVICES, TPL_CALLBACK, - &MarvellYukonNotifyExitBoot, YukonDriver, &YukonDriver->ExitBootEvent); + if (!EFI_ERROR(Status)) { + Status = gBS->CreateEvent (EVT_SIGNAL_EXIT_BOOT_SERVICES, TPL_CALLBACK, + &MarvellYukonNotifyExitBoot, YukonDriver, &YukonDriver->ExitBootEvent); + } }
return Status; @@ -319,6 +350,8 @@ MarvellYukonDriverStop ( EFI_STATUS Status; YUKON_DRIVER *YukonDriver; EFI_TPL OldTpl; + UINTN ChildController; + struct msk_softc *ScData;
if (pThis == NULL) { DEBUG ((EFI_D_ERROR, "Marvell Yukon: MarvellYukonDriverStop() failed with Status = %r\n", EFI_INVALID_PARAMETER)); @@ -330,15 +363,10 @@ MarvellYukonDriverStop ( return EFI_INVALID_PARAMETER; }
- if (NumberOfChildren > 0) { - - // - // Currently support only one network port - // - ASSERT (NumberOfChildren == 1); + for (ChildController = 0; ChildController < NumberOfChildren; ChildController ++) {
Status = gBS->OpenProtocol ( - ChildHandleBuffer[0], + ChildHandleBuffer[ChildController], &gEfiSimpleNetworkProtocolGuid, (VOID **) &SimpleNetwork, pThis->DriverBindingHandle, @@ -349,10 +377,16 @@ MarvellYukonDriverStop ( if (!EFI_ERROR(Status)) {
YukonDriver = YUKON_DEV_FROM_THIS_SNP (SimpleNetwork); + + Status = MarvellYukonGetControllerData(YukonDriver->Controller, &ScData); + if (EFI_ERROR(Status)) { + continue; + } + OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
- ASSERT (YukonDriver->Controller == ChildHandleBuffer[0]); - if (YukonDriver->SnpMode.State != EfiSimpleNetworkStopped) { + ASSERT (YukonDriver->Controller == ChildHandleBuffer[ChildController]); + if (YukonDriver->SnpMode.State != EfiSimpleNetworkStopped) {
// // Device in use, cannot stop driver instance @@ -364,11 +398,15 @@ MarvellYukonDriverStop ( // // Unhook the child controller // - gBS->CloseProtocol (Controller, + Status = gBS->CloseProtocol (Controller, &gEfiPciIoProtocolGuid, pThis->DriverBindingHandle, YukonDriver->Controller);
+ if (EFI_ERROR(Status)){ + DEBUG ((DEBUG_ERROR, "Marvell Yukon: MarvellYukonDriverStop:Close Child EfiPciIoProtocol error. Status %r\n", Status)); + } + Status = gBS->UninstallMultipleProtocolInterfaces ( YukonDriver->Controller, &gEfiSimpleNetworkProtocolGuid, @@ -382,25 +420,36 @@ MarvellYukonDriverStop ( DEBUG ((EFI_D_ERROR, "Marvell Yukon: MarvellYukonDriverStop:UninstallMultipleProtocolInterfaces error. Status %r\n", Status)); }
+ MarvellYukonDelControllerData(YukonDriver->Controller); + gBS->CloseEvent (YukonDriver->ExitBootEvent); gBS->FreePool (YukonDriver->DevicePath); gBS->FreePool (YukonDriver); } gBS->RestoreTPL (OldTpl); } - } else { - Status = gBS->CloseProtocol ( - Controller, - &gEfiPciIoProtocolGuid, - pThis->DriverBindingHandle, - Controller - ); + }
- if (EFI_ERROR(Status)){ - DEBUG ((EFI_D_ERROR, "Marvell Yukon: MarvellYukonDriverStop:Close EfiPciIoProtocol error. Status %r\n", Status)); - } + Status = gBS->CloseProtocol ( + Controller, + &gEfiPciIoProtocolGuid, + pThis->DriverBindingHandle, + Controller + ); + + if (EFI_ERROR(Status)){ + DEBUG ((DEBUG_ERROR, "Marvell Yukon: MarvellYukonDriverStop:Close EfiPciIoProtocol error. Status %r\n", Status)); + } + + Status = MarvellYukonGetControllerData(Controller, &ScData); + if (EFI_ERROR(Status)) { + return Status; }
+ mskc_detach (ScData); + gBS->FreePool(ScData); + Status = MarvellYukonDelControllerData(Controller); + return Status; }
@@ -436,6 +485,123 @@ MarvellYukonNotifyExitBoot ( } }
+/** + Get driver's data structure associated with controller + + @param [in] Controller Controller Id. + @param [out] Data Driver's data. + +**/ +EFI_STATUS +EFIAPI +MarvellYukonGetControllerData( + IN EFI_HANDLE Controller, + OUT struct msk_softc **Data + ) +{ + MSK_LINKED_DRV_BUF *DrvNode; + EFI_STATUS Status; + + Status = MarvellYukonFindControllerNode (Controller, &DrvNode); + if (!EFI_ERROR(Status)) { + *Data = DrvNode->Data; + } + return Status; +} + +/** + Add driver's data structure associated with controller + + @param [in] Controller Controller Id. + @param [in] Data Driver's data. + +**/ +EFI_STATUS +EFIAPI +MarvellYukonAddControllerData ( + IN EFI_HANDLE Controller, + IN struct msk_softc *Data + ) +{ + MSK_LINKED_DRV_BUF *DrvNode; + EFI_STATUS Status; + + Status = MarvellYukonFindControllerNode (Controller, &DrvNode); + if (EFI_ERROR(Status)) { + Status = gBS->AllocatePool (EfiBootServicesData, + sizeof (MSK_LINKED_DRV_BUF), + (VOID**) &DrvNode); + if (!EFI_ERROR (Status)) { + DrvNode->Signature = MSK_DRV_SIGNATURE; + DrvNode->Controller = Controller; + DrvNode->Data = Data; + InsertTailList (&MarvellYukonDrvDataHead, &DrvNode->Link); + } + } else { + Status = EFI_ALREADY_STARTED; + } + + return Status; +} + +/** + Delete driver's data structure associated with controller + + @param [in] Controller Controller Id. + +**/ +EFI_STATUS +EFIAPI +MarvellYukonDelControllerData ( + IN EFI_HANDLE Controller + ) +{ + MSK_LINKED_DRV_BUF *DrvNode; + EFI_STATUS Status; + + Status = MarvellYukonFindControllerNode (Controller, &DrvNode); + if (!EFI_ERROR(Status)) { + RemoveEntryList (&DrvNode->Link); + gBS->FreePool (DrvNode); + } + + return Status; +} + +/** + Find node associated with controller + + @param [in] Controller Controller Id. + @param [out] DrvLinkedBuff Controller's node. + +**/ +EFI_STATUS +EFIAPI +MarvellYukonFindControllerNode ( + IN EFI_HANDLE Controller, + OUT MSK_LINKED_DRV_BUF **DrvLinkedBuff + ) +{ + MSK_LINKED_DRV_BUF *DrvBuffNode; + EFI_STATUS Status; + LIST_ENTRY *Node; + + Status = EFI_NOT_FOUND; + + Node = GetFirstNode (&MarvellYukonDrvDataHead); + while (!IsNull (&MarvellYukonDrvDataHead, Node)) { + DrvBuffNode = MSK_DRV_INFO_FROM_THIS (Node); + if (DrvBuffNode->Controller == Controller) { + *DrvLinkedBuff = DrvBuffNode; + Status = EFI_SUCCESS; + break; + } + Node = GetNextNode (&MarvellYukonDrvDataHead, Node); + } + + return Status; +} + // // Simple Network Protocol Driver Global Variables // @@ -487,7 +653,10 @@ InitializeMarvellYukonDriver (
if (EFI_ERROR (Status)) { DEBUG ((EFI_D_ERROR, "Marvell Yukon: InitializeMarvellYukonDriver(): Driver binding failed\n")); + return Status; }
+ InitializeListHead (&MarvellYukonDrvDataHead); + return Status; } diff --git a/Drivers/Net/MarvellYukonDxe/MarvellYukon.h b/Drivers/Net/MarvellYukonDxe/MarvellYukon.h index e6110cb..07f5389 100644 --- a/Drivers/Net/MarvellYukonDxe/MarvellYukon.h +++ b/Drivers/Net/MarvellYukonDxe/MarvellYukon.h @@ -43,6 +43,7 @@ typedef struct { EFI_LOCK Lock;
EFI_HANDLE Controller; + UINTN Port; EFI_EVENT ExitBootEvent;
EFI_SIMPLE_NETWORK_PROTOCOL Snp; @@ -58,6 +59,22 @@ typedef struct {
#define SNP_MEM_PAGES(x) (((x) - 1) / 4096 + 1)
+typedef struct { + UINT32 Signature; + LIST_ENTRY Link; + EFI_HANDLE Controller; + struct msk_softc *Data; +} MSK_LINKED_DRV_BUF; + +#define MSK_DRV_SIGNATURE SIGNATURE_32 ('m', 's', 'k', 'c') + +#define MSK_DRV_INFO_FROM_THIS(a) \ + CR (a, \ + MSK_LINKED_DRV_BUF, \ + Link, \ + MSK_DRV_SIGNATURE \ + ); + // // Global Variables // @@ -708,4 +725,58 @@ MarvellYukonNotifyExitBoot ( IN VOID *Context );
+/** + Get driver's data structure associated with controller + + @param [in] Controller Controller Id. + @param [out] Data Driver's data. + +**/ +EFI_STATUS +EFIAPI +MarvellYukonGetControllerData( + IN EFI_HANDLE Controller, + OUT struct msk_softc **Data + ); + +/** + Add driver's data structure associated with controller + + @param [in] Controller Controller Id. + @param [in] Data Driver's data. + +**/ +EFI_STATUS +EFIAPI +MarvellYukonAddControllerData ( + IN EFI_HANDLE Controller, + IN struct msk_softc * + ); + +/** + Delete driver's data structure associated with controller + + @param [in] Controller Controller Id. + +**/ +EFI_STATUS +EFIAPI +MarvellYukonDelControllerData ( + IN EFI_HANDLE Controller + ); + +/** + Find node associated with controller + + @param [in] Controller Controller Id. + @param [out] DrvLinkedBuff Controller's node. + +**/ +EFI_STATUS +EFIAPI +MarvellYukonFindControllerNode ( + IN EFI_HANDLE Controller, + OUT MSK_LINKED_DRV_BUF **DrvLinkedBuff + ); + /* _SNP_H_ */ diff --git a/Drivers/Net/MarvellYukonDxe/Snp.c b/Drivers/Net/MarvellYukonDxe/Snp.c index 3d84f84..9662322 100644 --- a/Drivers/Net/MarvellYukonDxe/Snp.c +++ b/Drivers/Net/MarvellYukonDxe/Snp.c @@ -123,6 +123,7 @@ SnpGetStatus ( EFI_STATUS Status; YUKON_DRIVER *Snp; EFI_TPL OldTpl; + struct msk_softc *ScData;
if (This == NULL) { return EFI_INVALID_PARAMETER; @@ -133,6 +134,11 @@ SnpGetStatus ( return EFI_INVALID_PARAMETER; }
+ Status = MarvellYukonGetControllerData(Snp->Controller, &ScData); + if (EFI_ERROR(Status)) { + return Status; + } + OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
switch (Snp->SnpMode.State) { @@ -148,7 +154,7 @@ SnpGetStatus ( goto ON_EXIT; }
- mskc_getstatus (InterruptStatus, TxBuf); + mskc_getstatus (ScData->msk_if[Snp->Port], InterruptStatus, TxBuf); Status = EFI_SUCCESS;
ON_EXIT: @@ -201,6 +207,7 @@ SnpInitialize ( EFI_STATUS Status; YUKON_DRIVER *YukonDriver; EFI_TPL OldTpl; + struct msk_softc *ScData;
DEBUG ((EFI_D_NET, "Marvell Yukon: SnpInitialize()\n")); if (This == NULL) { @@ -210,6 +217,11 @@ SnpInitialize (
YukonDriver = YUKON_DEV_FROM_THIS_SNP (This);
+ Status = MarvellYukonGetControllerData(YukonDriver->Controller, &ScData); + if (EFI_ERROR(Status)) { + return Status; + } + OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
switch (YukonDriver->SnpMode.State) { @@ -230,7 +242,7 @@ SnpInitialize ( gBS->SetMem (YukonDriver->SnpMode.MCastFilter, sizeof YukonDriver->SnpMode.MCastFilter, 0); gBS->CopyMem (&YukonDriver->SnpMode.CurrentAddress, &YukonDriver->SnpMode.PermanentAddress, sizeof (EFI_MAC_ADDRESS));
- Status = mskc_init (); + Status = mskc_init (ScData->msk_if[YukonDriver->Port]);
if (EFI_ERROR (Status)) { goto ON_ERROR_RESTORE_TPL; @@ -511,6 +523,7 @@ SnpReceive ( EFI_STATUS Status; YUKON_DRIVER *Snp; EFI_TPL OldTpl; + struct msk_softc *ScData;
if (This == NULL) { return EFI_INVALID_PARAMETER; @@ -518,6 +531,11 @@ SnpReceive (
Snp = YUKON_DEV_FROM_THIS_SNP (This);
+ Status = MarvellYukonGetControllerData(Snp->Controller, &ScData); + if (EFI_ERROR(Status)) { + return Status; + } + OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
switch (Snp->SnpMode.State) { @@ -538,7 +556,7 @@ SnpReceive ( goto ON_EXIT; }
- Status = mskc_receive (BufferSize, Buffer); + Status = mskc_receive (ScData->msk_if[Snp->Port], BufferSize, Buffer); if (EFI_ERROR (Status)) { if (Status == EFI_NOT_READY) { goto ON_EXIT_NO_DEBUG; @@ -681,6 +699,7 @@ SnpReceiveFilters ( YUKON_DRIVER *YukonDriver; EFI_TPL OldTpl; UINT32 newReceiveFilter; + struct msk_softc *ScData;
DEBUG ((EFI_D_NET, "Marvell Yukon: SnpReceiveFilters()\n")); if (This == NULL) { @@ -690,6 +709,11 @@ SnpReceiveFilters (
YukonDriver = YUKON_DEV_FROM_THIS_SNP (This);
+ Status = MarvellYukonGetControllerData(YukonDriver->Controller, &ScData); + if (EFI_ERROR(Status)) { + return Status; + } + OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
switch (YukonDriver->SnpMode.State) { @@ -743,7 +767,7 @@ SnpReceiveFilters ( }
YukonDriver->SnpMode.ReceiveFilterSetting = newReceiveFilter; - mskc_rxfilter (YukonDriver->SnpMode.ReceiveFilterSetting, MCastFilterCnt, MCastFilter); + mskc_rxfilter (ScData->msk_if[YukonDriver->Port], YukonDriver->SnpMode.ReceiveFilterSetting, MCastFilterCnt, MCastFilter);
Status = EFI_SUCCESS; goto ON_EXIT; @@ -860,6 +884,7 @@ SnpShutdown ( EFI_STATUS Status; YUKON_DRIVER *YukonDriver; EFI_TPL OldTpl; + struct msk_softc *ScData;
DEBUG ((EFI_D_NET, "Marvell Yukon: SnpShutdown()\n")); // @@ -872,6 +897,11 @@ SnpShutdown (
YukonDriver = YUKON_DEV_FROM_THIS_SNP (This);
+ Status = MarvellYukonGetControllerData(YukonDriver->Controller, &ScData); + if (EFI_ERROR(Status)) { + return Status; + } + OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
// @@ -890,7 +920,7 @@ SnpShutdown ( goto ON_ERROR_RESTORE_TPL; }
- mskc_shutdown (); + mskc_stop_if (ScData->msk_if[YukonDriver->Port]); YukonDriver->SnpMode.State = EfiSimpleNetworkStarted; Status = EFI_SUCCESS;
@@ -941,6 +971,7 @@ SnpStart ( YUKON_DRIVER *YukonDriver; EFI_TPL OldTpl; EFI_STATUS Status; + struct msk_softc *ScData;
DEBUG ((EFI_D_NET, "Marvell Yukon: SnpStart()\n")); if (This == NULL) { @@ -950,6 +981,11 @@ SnpStart (
YukonDriver = YUKON_DEV_FROM_THIS_SNP (This);
+ Status = MarvellYukonGetControllerData(YukonDriver->Controller, &ScData); + if (EFI_ERROR(Status)) { + return Status; + } + OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
switch (YukonDriver->SnpMode.State) { @@ -966,7 +1002,7 @@ SnpStart ( goto ON_ERROR_RESTORE_TPL; }
- Status = mskc_attach (YukonDriver->PciIo, &YukonDriver->SnpMode.PermanentAddress); + Status = mskc_attach_if (ScData->msk_if[YukonDriver->Port], YukonDriver->Port);
if (EFI_ERROR (Status)) { goto ON_ERROR_RESTORE_TPL; @@ -1244,6 +1280,7 @@ SnpStop ( EFI_STATUS Status; YUKON_DRIVER *YukonDriver; EFI_TPL OldTpl; + struct msk_softc *ScData;
DEBUG ((EFI_D_NET, "Marvell Yukon: SnpStop()\n")); if (This == NULL) { @@ -1253,6 +1290,11 @@ SnpStop (
YukonDriver = YUKON_DEV_FROM_THIS_SNP (This);
+ Status = MarvellYukonGetControllerData(YukonDriver->Controller, &ScData); + if (EFI_ERROR(Status)) { + return Status; + } + OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
switch (YukonDriver->SnpMode.State) { @@ -1269,7 +1311,7 @@ SnpStop ( goto ON_ERROR_RESTORE_TPL; }
- mskc_detach (); + mskc_detach_if (ScData->msk_if[YukonDriver->Port]); YukonDriver->SnpMode.State = EfiSimpleNetworkStopped; gBS->SetMem (&YukonDriver->SnpMode.CurrentAddress, sizeof (EFI_MAC_ADDRESS), 0); Status = EFI_SUCCESS; @@ -1354,6 +1396,7 @@ SnpTransmit ( EFI_TPL OldTpl; ETHER_HEAD *Frame; UINT16 ProtocolNet; + struct msk_softc *ScData;
DEBUG ((EFI_D_NET, "Marvell Yukon: SnpTransmit()\n")); if (This == NULL) { @@ -1366,6 +1409,11 @@ SnpTransmit ( return EFI_DEVICE_ERROR; }
+ Status = MarvellYukonGetControllerData(YukonDriver->Controller, &ScData); + if (EFI_ERROR(Status)) { + return Status; + } + OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
switch (YukonDriver->SnpMode.State) { @@ -1407,7 +1455,7 @@ SnpTransmit ( gBS->CopyMem (&Frame->EtherType, &ProtocolNet, sizeof (UINT16)); }
- Status = mskc_transmit (BufferSize, Buffer); + Status = mskc_transmit (ScData->msk_if[YukonDriver->Port], BufferSize, Buffer);
ON_EXIT: gBS->RestoreTPL (OldTpl);