[MLX4] add 2 new functions to Eth interface: mlx4_register_vlan/mlx4_unregister_vlan...
[mirror/winof/.git] / hw / mlx4 / kernel / bus / drv / pdo.c
index 920cd47..61c2da4 100644 (file)
@@ -2,13 +2,12 @@
 #include <initguid.h>\r
 #include <wdmguid.h>\r
 \r
-#if defined(EVENT_TRACING)\r
-#include "pdo.tmh"\r
-#endif\r
-\r
-#ifdef ALLOC_PRAGMA\r
-#pragma alloc_text(PAGE, create_pdo)\r
+#if defined (EVENT_TRACING)\r
+#ifdef offsetof\r
+#undef offsetof\r
 #endif\r
+#include "pdo.tmh"\r
+#endif \r
 \r
 #define MAX_ID_LEN 80\r
 \r
@@ -27,11 +26,19 @@ EvtDeviceProcessQueryInterfaceRequest(
        UNUSED_PARAM(InterfaceType);\r
        UNUSED_PARAM(ExposedInterfaceSpecificData);\r
 \r
-       p_ib_ifc->p_ibdev = p_fdo->bus_ib_ifc.p_ibdev;\r
-       p_ib_ifc->pmlx4_dev = p_fdo->bus_ib_ifc.pmlx4_dev;\r
-       p_ib_ifc->is_livefish = p_fdo->bus_ib_ifc.is_livefish;\r
+       if (p_fdo->pci_dev.dev) {\r
+               p_ib_ifc->p_ibdev = p_fdo->bus_ib_ifc.p_ibdev;\r
+               p_ib_ifc->pmlx4_dev = p_fdo->bus_ib_ifc.pmlx4_dev;\r
+               p_ib_ifc->is_livefish = p_fdo->bus_ib_ifc.is_livefish;\r
+               return STATUS_SUCCESS;\r
+       }\r
+       else {\r
+               p_ib_ifc->p_ibdev = NULL;\r
+               p_ib_ifc->pmlx4_dev = NULL;\r
+               p_ib_ifc->is_livefish = FALSE;\r
+               return STATUS_UNSUCCESSFUL;\r
+       }\r
 \r
-       return STATUS_SUCCESS;\r
 }\r
 \r
 NTSTATUS\r
@@ -39,7 +46,8 @@ create_pdo(
        __in WDFDEVICE  Device,\r
        __in PWCHAR     HardwareIds,\r
        __in PWCHAR     DeviceDescription,\r
-       __in ULONG      SerialNo\r
+       __in ULONG      SerialNo,\r
+       __in PWCHAR     Location\r
 )\r
 /*++\r
 \r
@@ -64,9 +72,9 @@ Return Value:
        WDF_DEVICE_PNP_CAPABILITIES pnpCaps;\r
        WDF_DEVICE_POWER_CAPABILITIES powerCaps;\r
        UNICODE_STRING compatId;\r
-       DECLARE_CONST_UNICODE_STRING(deviceLocation, L"MLX4 Bus 0");\r
        UNICODE_STRING deviceId;\r
        DECLARE_UNICODE_STRING_SIZE(buffer, MAX_ID_LEN);\r
+       DECLARE_UNICODE_STRING_SIZE(deviceLocation, MAX_ID_LEN);\r
 \r
        MLX4_PRINT(TRACE_LEVEL_INFORMATION, MLX4_DBG_DRV, ("Entered CreatePdo\n"));\r
 \r
@@ -145,6 +153,11 @@ Return Value:
        // The driver can specify the driver's default locale by calling\r
        // WdfPdoInitSetDefaultLocale.\r
        //\r
+       status =  RtlUnicodeStringPrintf(&deviceLocation, L"MLX4 %s", Location+4);\r
+       if (!NT_SUCCESS(status)) {\r
+               goto Cleanup;\r
+       }\r
+\r
        status = WdfPdoInitAddDeviceText(pDeviceInit,\r
                &buffer, &deviceLocation, 0x409);\r
        if (!NT_SUCCESS(status)) {\r
@@ -179,18 +192,17 @@ Return Value:
        p_pdo->PdoDevice = hChild;\r
 \r
        //\r
-       // Set some properties for the child device.\r
+       // Set PnP properties for the child device.\r
        //\r
        WDF_DEVICE_PNP_CAPABILITIES_INIT(&pnpCaps);\r
-       pnpCaps.Removable         = WdfTrue;\r
-       pnpCaps.EjectSupported    = WdfTrue;\r
-       pnpCaps.SurpriseRemovalOK = WdfTrue;\r
-\r
        pnpCaps.Address  = SerialNo;\r
        pnpCaps.UINumber = SerialNo;\r
 \r
        WdfDeviceSetPnpCapabilities(hChild, &pnpCaps);\r
 \r
+       //\r
+       // Set Power properties for the child device\r
+       //\r
        WDF_DEVICE_POWER_CAPABILITIES_INIT(&powerCaps);\r
 \r
        powerCaps.DeviceD1 = WdfTrue;\r
@@ -206,6 +218,9 @@ Return Value:
 \r
        WdfDeviceSetPowerCapabilities(hChild, &powerCaps);\r
 \r
+       //\r
+       // Set bus IB interface\r
+       //\r
        p_fdo->bus_ib_ifc.port_id = (u8) SerialNo;\r
        p_fdo->bus_ib_ifc.pVipBusIfc = &p_fdo->mtnic_Ifc;\r
        p_fdo->bus_ib_ifc.mlx4_interface.mlx4_pd_alloc = mlx4_pd_alloc;\r
@@ -251,6 +266,9 @@ Return Value:
        p_fdo->bus_ib_ifc.mlx4_interface.mlx4_unregister_ev_cb = mlx4_reset_cb_unregister;\r
        p_fdo->bus_ib_ifc.mlx4_interface.mlx4_reset_request = mlx4_reset_request;\r
        p_fdo->bus_ib_ifc.mlx4_interface.mlx4_reset_execute = mlx4_reset_execute;\r
+       p_fdo->bus_ib_ifc.mlx4_interface.mlx4_reset_ready = mlx4_reset_ready;\r
+       p_fdo->bus_ib_ifc.mlx4_interface.mlx4_register_vlan = mlx4_register_vlan;\r
+       p_fdo->bus_ib_ifc.mlx4_interface.mlx4_unregister_vlan = mlx4_unregister_vlan;\r
        \r
        //\r
        // Create a custom interface so that other drivers can\r