[ofw][patch][CORE,HW] remove PDO from the upper HCA interface

Leonid Keller leonid at mellanox.co.il
Wed Mar 25 08:55:06 PDT 2009


This patch removes p_hca_dev field of the upper CA interface
(ci_interface_t), which contains PDO of HCA device.
IBBUS, now sitting over HCA, gets this PDO in add_device function and
stores it (in this patch) in new p_hca_dev field in IBAL CA object.
All the usages of ci_interface_t.p_hca_dev  field is replaced by usage
of p_hca_dev in IBAL CA object.
 
p_hca_obj field, added in 2019 patch in RDMA_INTERFACE_VERBS, removed
and placed instead of p_hca_dev in ci_interface_t.
 
Removing of PDO filed from the interface required changing of
ib_register_ca prototype (for technical reasons).
It is - an interface function, so the interface version number was
increased (IB_CI_INTERFACE_VERSION=5).
 
Index: core/al/al_ca.h
===================================================================
--- core/al/al_ca.h (revision 2055)
+++ core/al/al_ca.h (working copy)
@@ -50,6 +50,7 @@
  cl_list_item_t   list_item;
 #if defined(CL_KERNEL)
  ib_ca_handle_t   h_um_ca;
+ PDEVICE_OBJECT   p_hca_dev;
 #endif
 
 } ib_ca_t;
Index: core/al/al_ci_ca.h
===================================================================
--- core/al/al_ci_ca.h (revision 2055)
+++ core/al/al_ci_ca.h (working copy)
@@ -56,7 +56,9 @@
 ib_api_status_t
 create_ci_ca(
  IN    al_obj_t     *p_parent_obj,
- IN  const ci_interface_t*    p_ci );
+ IN  const ci_interface_t*    p_ci,
+ IN  const PDEVICE_OBJECT    p_hca_dev
+ );
 
 DEVICE_OBJECT*
 get_ca_dev(
Index: core/al/kernel/al_ci_ca.c
===================================================================
--- core/al/kernel/al_ci_ca.c (revision 2055)
+++ core/al/kernel/al_ci_ca.c (working copy)
@@ -84,7 +84,9 @@
 ib_api_status_t
 create_ci_ca(
  IN    al_obj_t     *p_parent_obj,
- IN  const ci_interface_t*    p_ci )
+ IN  const ci_interface_t*    p_ci,
+ IN  const PDEVICE_OBJECT    p_hca_dev
+ )
 {
  ib_api_status_t   status;
  cl_status_t    cl_status;
@@ -185,6 +187,9 @@
   return status;
  }
 
+ /* store HCA device object into CA object */
+ p_ci_ca->h_ca->p_hca_dev = p_hca_dev;
+ 
  /* Get a list of the port GUIDs on this CI CA. */
  status = get_port_info( p_ci_ca );
  if( status != IB_SUCCESS )
@@ -516,6 +521,6 @@
 {
  ASSERT( h_ca );
 
- ObReferenceObject( h_ca->obj.p_ci_ca->verbs.p_hca_dev );
- return h_ca->obj.p_ci_ca->verbs.p_hca_dev;
-}
\ No newline at end of file
+ ObReferenceObject( h_ca->p_hca_dev );
+ return h_ca->p_hca_dev;
+}
Index: core/al/kernel/al_mgr.c
===================================================================
--- core/al/kernel/al_mgr.c (revision 2055)
+++ core/al/kernel/al_mgr.c (working copy)
@@ -256,7 +256,9 @@
  */
 ib_api_status_t
 ib_register_ca(
- IN  const ci_interface_t*    p_ci )
+ IN  const ci_interface_t*    p_ci,
+ IN  const PDEVICE_OBJECT    p_hca_dev
+ )
 {
  ib_api_status_t  status;
 
@@ -283,7 +285,7 @@
  }
 
  /* Construct and initialize the CA structure. */
- status = create_ci_ca( &gp_al_mgr->obj, p_ci );
+ status = create_ci_ca( &gp_al_mgr->obj, p_ci, p_hca_dev );
  if( status != IB_SUCCESS )
  {
   AL_PRINT( TRACE_LEVEL_ERROR, AL_DBG_ERROR,
Index: core/bus/kernel/bus_iou_mgr.c
===================================================================
--- core/bus/kernel/bus_iou_mgr.c (revision 2055)
+++ core/bus/kernel/bus_iou_mgr.c (working copy)
@@ -417,7 +417,7 @@
   {
    /* Invalidate bus relations for the HCA. */
    IoInvalidateDeviceRelations(
-    p_ext->h_ca->obj.p_ci_ca->verbs.p_hca_dev, BusRelations );
+    p_ext->h_ca->p_hca_dev, BusRelations );
 
    /* Release the reference on the CA object. */
    deref_al_obj( &p_ext->h_ca->obj );
@@ -787,7 +787,7 @@
 
  /* Tell the PnP Manager to rescan for the HCA's bus relations. */
  IoInvalidateDeviceRelations(
-   p_iou_ext->pdo.h_ca->obj.p_ci_ca->verbs.p_hca_dev, BusRelations );
+   p_iou_ext->pdo.h_ca->p_hca_dev, BusRelations );
 
  /* Invalidate removal relations for the bus driver. */
  IoInvalidateDeviceRelations(
@@ -885,7 +885,7 @@
 
  /* Invalidate bus relations for the HCA. */
  IoInvalidateDeviceRelations(
-  p_ext->h_ca->obj.p_ci_ca->verbs.p_hca_dev, BusRelations );
+  p_ext->h_ca->p_hca_dev, BusRelations );
 
  /* free PNP context */
  cl_free( p_ctx );
@@ -1561,7 +1561,7 @@
   p_ext = p_dev_obj->DeviceExtension;
   if( !p_ext->h_ca ||
    !p_ext->b_present ||
-   !p_ext->h_ca->obj.p_ci_ca->verbs.p_hca_dev ||
+   !p_ext->h_ca->p_hca_dev ||
    p_ext->b_reported_missing )
   {
    return STATUS_NO_SUCH_DEVICE;
@@ -1569,7 +1569,7 @@
 
 
   status = cl_fwd_query_ifc(
-   p_ext->h_ca->obj.p_ci_ca->verbs.p_hca_dev, p_io_stack );
+   p_ext->h_ca->p_hca_dev, p_io_stack );
  }
  else
  {
Index: core/bus/kernel/bus_pnp.c
===================================================================
--- core/bus/kernel/bus_pnp.c (revision 2055)
+++ core/bus/kernel/bus_pnp.c (working copy)
@@ -47,6 +47,7 @@
 #include "iba/ib_ci_ifc.h"
 #include "iba/ib_cm_ifc.h"
 #include "al_cm_cep.h"
+#include "al_mgr.h"
 
 
 /* Interface names are generated by IoRegisterDeviceInterface. */
@@ -460,8 +461,11 @@
  }
  p_ext->hca_ifc_taken = TRUE;
 
+ /* bind BFI to HCA by CA GUID. Have to be before ib_register_ca */
+ p_bfi->ca_guid = p_ext->hca_ifc.Verbs.guid;
+
  /* register HCA */
- ib_status = ib_register_ca( &p_ext->hca_ifc.Verbs );
+ ib_status = ib_register_ca( &p_ext->hca_ifc.Verbs, p_ext->cl_ext.p_pdo
);
  if( ib_status != IB_SUCCESS )
  {
   BUS_TRACE_EXIT( BUS_DBG_ERROR, ("ib_register_ca returned %s.\n",
@@ -469,9 +473,6 @@
   return STATUS_UNSUCCESSFUL;
  }
 
- /* bind BFI to HCA by CA GUID */
- p_bfi->ca_guid = p_ext->hca_ifc.Verbs.guid;
-
  BUS_TRACE_EXIT(BUS_DBG_PNP, ("%s bound to CA guid %I64x\n",
          p_bfi->whoami,p_bfi->ca_guid));
  return status;
Index: core/bus/kernel/bus_port_mgr.c
===================================================================
--- core/bus/kernel/bus_port_mgr.c (revision 2055)
+++ core/bus/kernel/bus_port_mgr.c (working copy)
@@ -415,7 +415,7 @@
   {
    /* Invalidate bus relations for the HCA. */
    IoInvalidateDeviceRelations(
-    p_ext->h_ca->obj.p_ci_ca->verbs.p_hca_dev, BusRelations );
+    p_ext->h_ca->p_hca_dev, BusRelations );
 
    /* Release the reference on the CA object. */
    deref_al_obj( &p_ext->h_ca->obj );
@@ -925,7 +925,7 @@
 
   /* Tell the PnP Manager to rescan for the HCA's bus relations. */
   IoInvalidateDeviceRelations(
-   p_port_ext->pdo.h_ca->obj.p_ci_ca->verbs.p_hca_dev, BusRelations );
+   p_port_ext->pdo.h_ca->p_hca_dev, BusRelations );
  }
 
  /* Invalidate removal relations for the bus driver. */
@@ -985,7 +985,7 @@
 
  /* Tell the PnP Manager to rescan for the HCA's bus relations. */
  IoInvalidateDeviceRelations(
-  p_port_ext->pdo.h_ca->obj.p_ci_ca->verbs.p_hca_dev, BusRelations );
+  p_port_ext->pdo.h_ca->p_hca_dev, BusRelations );
 
  BUS_EXIT( BUS_DBG_PNP );
  return CL_SUCCESS;
@@ -1125,7 +1125,7 @@
 
  /* Tell the PnP Manager to rescan for the HCA's bus relations. */
  IoInvalidateDeviceRelations(
-  pmatched_guid_ext->pdo.h_ca->obj.p_ci_ca->verbs.p_hca_dev,
BusRelations );
+  pmatched_guid_ext->pdo.h_ca->p_hca_dev, BusRelations );
 
  /* Invalidate removal relations for the bus driver. */
  IoInvalidateDeviceRelations(
@@ -1267,7 +1267,7 @@
 
  /* Invalidate bus relations for the HCA. */
  IoInvalidateDeviceRelations(
-  p_ext->h_ca->obj.p_ci_ca->verbs.p_hca_dev, BusRelations );
+  p_ext->h_ca->p_hca_dev, BusRelations );
 
  /* Free PNP context memory */
  cl_free( p_ctx );
@@ -1796,7 +1796,7 @@
   return STATUS_NO_SUCH_DEVICE;
  }
 
- p_hca_dev = p_ext->pdo.h_ca->obj.p_ci_ca->verbs.p_hca_dev;
+ p_hca_dev = p_ext->pdo.h_ca->p_hca_dev;
 
  /* Get the length of the HCA's location. */
  status = IoGetDeviceProperty( p_hca_dev,
@@ -2017,14 +2017,14 @@
   p_ext = p_dev_obj->DeviceExtension;
   if( !p_ext->h_ca ||
    !p_ext->b_present ||
-   !p_ext->h_ca->obj.p_ci_ca->verbs.p_hca_dev ||
+   !p_ext->h_ca->p_hca_dev ||
    p_ext->b_reported_missing )
   {
    return STATUS_NO_SUCH_DEVICE;
   }
 
   status = cl_fwd_query_ifc(
-   p_ext->h_ca->obj.p_ci_ca->verbs.p_hca_dev, p_io_stack );
+   p_ext->h_ca->p_hca_dev, p_io_stack );
  }
  else
  {
Index: core/winmad/kernel/wm_driver.c
===================================================================
--- core/winmad/kernel/wm_driver.c (revision 2055)
+++ core/winmad/kernel/wm_driver.c (working copy)
@@ -233,7 +233,7 @@
 
  size = 0;
  ib_status = pDevice->VerbsInterface.Verbs.
-    query_ca(pDevice->VerbsInterface.p_hca_obj, NULL, &size, NULL);
+    query_ca(pDevice->VerbsInterface.Verbs.p_hca_obj, NULL, &size,
NULL);
  if (ib_status != IB_INSUFFICIENT_MEMORY) {
   attr = NULL;
   goto out;
@@ -245,7 +245,7 @@
  }
 
  ib_status = pDevice->VerbsInterface.Verbs.
-    query_ca(pDevice->VerbsInterface.p_hca_obj, attr, &size, NULL);
+    query_ca(pDevice->VerbsInterface.Verbs.p_hca_obj, attr, &size,
NULL);
  if (ib_status != IB_SUCCESS) {
   ExFreePool(attr);
   attr = NULL;
Index: core/winverbs/kernel/wv_driver.c
===================================================================
--- core/winverbs/kernel/wv_driver.c (revision 2055)
+++ core/winverbs/kernel/wv_driver.c (working copy)
@@ -477,7 +477,7 @@
  if (!NT_SUCCESS(status)) {
   return status;
  }
- dev->hDevice = dev->Interface.p_hca_obj;
+ dev->hDevice = dev->Interface.Verbs.p_hca_obj;
 
  KeAcquireGuardedMutex(&Lock);
  create = IsListEmpty(&DevList);
Index: hw/mlx4/kernel/hca/drv.c
===================================================================
--- hw/mlx4/kernel/hca/drv.c (revision 2055)
+++ hw/mlx4/kernel/hca/drv.c (working copy)
@@ -282,8 +102,7 @@
 
  setup_ci_interface( p_fdo->hca.guid, !!hca_is_livefish(p_fdo), pIfc );
 
- pIfc->p_hca_dev = WdfDeviceWdmGetPhysicalDevice(p_fdo->FdoDevice);
- ASSERT(pIfc->p_hca_dev);
+ pIfc->p_hca_obj = &p_fdo->hca;
  pIfc->vend_id = (uint32_t)p_fdo->bus_ib_ifc.pdev->ven_id;
  pIfc->dev_id = (uint16_t)p_fdo->bus_ib_ifc.pdev->dev_id;
  pIfc->dev_revision = (uint16_t)p_fdo->hca.hw_ver;
@@ -1215,8 +868,7 @@
 
  setup_ci_interface( p_fdo->hca.guid, !!hca_is_livefish(p_fdo), pIfc );
 
- pIfc->p_hca_dev = p_fdo->cl_ext.p_pdo;
- ASSERT(pIfc->p_hca_dev);    
+ pIfc->p_hca_obj = &p_fdo->hca;
  pIfc->vend_id = (uint32_t)p_fdo->bus_ib_ifc.pdev->ven_id;
  pIfc->dev_id = (uint16_t)p_fdo->bus_ib_ifc.pdev->dev_id;
  pIfc->dev_revision = (uint16_t)p_fdo->hca.hw_ver;
@@ -1641,7 +1293,6 @@
  p_ifc->InterfaceHeader.InterfaceReference = __ref_ifc;
  p_ifc->InterfaceHeader.InterfaceDereference = __deref_ifc;
  p_ifc->Verbs = *p_hca_ifc;
- p_ifc->p_hca_obj = &p_fdo->hca;
 
  /* take the reference before returning. */
  __ref_ifc( p_dev_obj );
Index: hw/mthca/kernel/hca_pnp.c
===================================================================
--- hw/mthca/kernel/hca_pnp.c (revision 2055)
+++ hw/mthca/kernel/hca_pnp.c (working copy)
@@ -242,7 +242,7 @@
   !!mthca_is_livefish(p_ext->hca.mdev),
   pIfc );
 
- pIfc->p_hca_dev = p_ext->cl_ext.p_pdo;
+ pIfc->p_hca_obj = &p_ext->hca.hob;
  pIfc->vend_id = (uint32_t)p_ext->hcaConfig.VendorID;
  pIfc->dev_id = (uint16_t)p_ext->hcaConfig.DeviceID;
  pIfc->dev_revision = (uint16_t)p_ext->hca.hw_ver;
@@ -877,7 +877,6 @@
  p_ifc->InterfaceHeader.InterfaceReference = __ref_ifc;
  p_ifc->InterfaceHeader.InterfaceDereference = __deref_ifc;
  p_ifc->Verbs = *p_hca_ifc;
- p_ifc->p_hca_obj = &p_ext->hca.hob;
 
  /* take the reference before returning. */
  __ref_ifc( p_dev_obj );
Index: inc/iba/ib_ci.h
===================================================================
--- inc/iba/ib_ci.h (revision 2055)
+++ inc/iba/ib_ci.h (working copy)
@@ -2793,10 +2793,10 @@
  net64_t    guid;
 
  /*
-  * Device object of the HCA.  In Windows, this is a pointer to the PDO
-  * for the HCA device.
+  * Handle, returned by open_ca function of HCA upper interface
(ci_interface_t)
+  * It has ib_ca_handle_t type
   */
- void    *p_hca_dev;
+ void    *p_hca_obj;
 
  /*
   * Vendor ID, Device ID, Device Revision of the HCA
@@ -2936,7 +2936,9 @@
 */
 AL_EXPORT ib_api_status_t
 ib_register_ca (
- IN  const ci_interface_t    *p_ci );
+ IN  const ci_interface_t*    p_ci,
+ IN  const PDEVICE_OBJECT    p_hca_dev
+ );
 /*
 * DESCRIPTION
 * This routine is called by a HCA kernel mode driver to inform the
@@ -2950,6 +2952,8 @@
 * p_ci
 *  [in] Pointer to the ci_interface_t structure that has the function
 *  vector to support verbs functionality.
+* p_hca_dev
+*  PDO of HCA device
 *
 * RETURN VALUE
 * IB_SUCCESS
Index: inc/kernel/iba/ib_ci_ifc.h
===================================================================
--- inc/kernel/iba/ib_ci_ifc.h (revision 2055)
+++ inc/kernel/iba/ib_ci_ifc.h (working copy)
@@ -49,13 +49,15 @@
 *********/
 
 
-#define IB_CI_INTERFACE_VERSION  (4)
+#define IB_CI_INTERFACE_VERSION  (5)
 
 
 /* Function type for ib_register_ca.  Match the definition in ib_ci.h
*/
 typedef ib_api_status_t
 (*ib_pfn_register_ca_t)(
- IN  const ci_interface_t* const  p_ci );
+ IN  const ci_interface_t* const  p_ci,
+ IN  const PDEVICE_OBJECT    p_hca_dev
+ );
 
 
 /* Function type for ib_deregister_ca.  Matches the definition in
ib_ci.h */
Index: inc/kernel/rdma/verbs.h
===================================================================
--- inc/kernel/rdma/verbs.h (revision 2055)
+++ inc/kernel/rdma/verbs.h (working copy)
@@ -57,7 +57,6 @@
 {
  INTERFACE  InterfaceHeader;
  ci_interface_t Verbs;
- void *   p_hca_obj;
 
 } RDMA_INTERFACE_VERBS;
 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openfabrics.org/pipermail/ofw/attachments/20090325/ef9f7ec9/attachment.html>


More information about the ofw mailing list