[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 33d121f..61c2da4 100644 (file)
@@ -2,22 +2,52 @@
 #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
+NTSTATUS\r
+EvtDeviceProcessQueryInterfaceRequest(\r
+       IN WDFDEVICE  Device,\r
+       IN LPGUID  InterfaceType,\r
+       IN OUT PINTERFACE  ExposedInterface,\r
+       IN OUT PVOID  ExposedInterfaceSpecificData\r
+       )\r
+{\r
+       PPDO_DEVICE_DATA p_pdo = PdoGetData(Device);\r
+       PFDO_DEVICE_DATA p_fdo  = p_pdo->p_fdo;\r
+       PMLX4_BUS_IB_INTERFACE p_ib_ifc = (PMLX4_BUS_IB_INTERFACE)ExposedInterface;\r
+\r
+       UNUSED_PARAM(InterfaceType);\r
+       UNUSED_PARAM(ExposedInterfaceSpecificData);\r
+\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
+}\r
+\r
 NTSTATUS\r
 create_pdo(\r
        __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
@@ -42,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
@@ -123,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
@@ -157,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
@@ -184,11 +218,11 @@ Return Value:
 \r
        WdfDeviceSetPowerCapabilities(hChild, &powerCaps);\r
 \r
-       p_fdo->bus_ib_ifc.port_id = SerialNo;\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.pVipBusIfc->ulAllocatePortObjSize = MAX_PORT_SIZE;\r
-       p_fdo->bus_ib_ifc.register_interface = mlx4_register_interface;\r
-       p_fdo->bus_ib_ifc.unregister_interface = mlx4_unregister_interface;\r
        p_fdo->bus_ib_ifc.mlx4_interface.mlx4_pd_alloc = mlx4_pd_alloc;\r
        p_fdo->bus_ib_ifc.mlx4_interface.mlx4_pd_free = mlx4_pd_free;\r
        p_fdo->bus_ib_ifc.mlx4_interface.mlx4_uar_alloc = mlx4_uar_alloc;\r
@@ -226,7 +260,15 @@ Return Value:
 \r
        p_fdo->bus_ib_ifc.mlx4_interface.mlx4_INIT_PORT = mlx4_INIT_PORT;\r
        p_fdo->bus_ib_ifc.mlx4_interface.mlx4_CLOSE_PORT = mlx4_CLOSE_PORT;\r
-\r
+       p_fdo->bus_ib_ifc.mlx4_interface.mlx4_add_eq = mlx4_add_eq;\r
+       p_fdo->bus_ib_ifc.mlx4_interface.mlx4_remove_eq = mlx4_remove_eq;\r
+       p_fdo->bus_ib_ifc.mlx4_interface.mlx4_register_ev_cb = mlx4_reset_cb_register;\r
+       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
@@ -236,7 +278,7 @@ Return Value:
 \r
        WDF_QUERY_INTERFACE_CONFIG_INIT( &p_pdo->qiMlx4Bus,\r
                (PINTERFACE) &p_fdo->bus_ib_ifc,\r
-               &MLX4_BUS_IB_INTERFACE_GUID, NULL);\r
+               &MLX4_BUS_IB_INTERFACE_GUID, EvtDeviceProcessQueryInterfaceRequest);\r
 \r
        status = WdfDeviceAddQueryInterface( hChild, &p_pdo->qiMlx4Bus );\r
        if (!NT_SUCCESS(status))\r
@@ -249,6 +291,8 @@ Return Value:
                (PINTERFACE) &p_fdo->pci_dev.bus_pci_ifc,\r
                &GUID_BUS_INTERFACE_STANDARD, NULL);\r
 \r
+       // TODO: Soft Reset - how tobar getting interface during RESET_IN_PROGRESS\r
+       // maybe - using EvtDeviceProcessQueryInterfaceRequest\r
        status = WdfDeviceAddQueryInterface( hChild, &p_pdo->qiPciBus );\r
        if (!NT_SUCCESS(status))\r
                goto Cleanup;\r