[OFW][patch] partition - amended

Slava Strebkov slavas at voltaire.com
Sun Apr 13 03:44:12 PDT 2008


Hi,

Attached patch is an implementation of partitions. It's a working
solution.

Default installation creates two IPoIB adapters with default pkeys.

New pkey (and IPoIB adapter instance) may be created by using [Device
Manager] IPoIB [Advanced properties], Partition Key. 

A value in hex format will define a new pkey for adapter.

 

 

 

Index: core/bus/kernel/bus_driver.c

===================================================================

--- core/bus/kernel/bus_driver.c  (revision 1049)

+++ core/bus/kernel/bus_driver.c           (working copy)

@@ -42,8 +42,8 @@

 #include "al_dev.h"

 #include "al_debug.h"

 #include <complib/cl_init.h>

+#include "iba/ipoib_ifc.h"

 

-

 #if defined(EVENT_TRACING)

 #ifdef offsetof

 #undef offsetof

@@ -419,7 +419,75 @@

            return status;

 }

 

+static NTSTATUS

+bus_drv_int_ctl(

+          IN                                             DEVICE_OBJECT
*p_dev_obj,

+          IN                                             IRP
*p_irp )

+{

+          NTSTATUS                    status;

+          bus_fdo_ext_t    *p_ext;

+          pkey_array_t     *pkey_msg;

+          PIO_STACK_LOCATION pstack;

 

+          BUS_ENTER( BUS_DBG_DRV );

+

+          /* Get the extension. */

+          p_ext = p_dev_obj->DeviceExtension;

+    pstack = IoGetCurrentIrpStackLocation(p_irp);

+

+          if(pstack->Parameters.DeviceIoControl.IoControlCode !=
IOCTL_CREATE_PDO)

+          {

+                      status = STATUS_INVALID_DEVICE_REQUEST;

+                      p_irp->IoStatus.Status = status;

+                      p_irp->IoStatus.Information = 0;

+                      IoCompleteRequest( p_irp, IO_NO_INCREMENT );

+                      BUS_EXIT( BUS_DBG_DRV );

+                      return status;

+          }

+          

+          pkey_msg = (pkey_array_t*)p_irp->AssociatedIrp.SystemBuffer;

+

+          CL_ASSERT(pkey_msg);

+
CL_ASSERT(pstack->Parameters.DeviceIoControl.InputBufferLength ==
sizeof(pkey_array_t));

+

+          /* Acquire the stop lock. */

+          status = IoAcquireRemoveLock( &p_ext->cl_ext.stop_lock, p_irp
);

+          if( !NT_SUCCESS( status ) )

+          {

+                      p_irp->IoStatus.Status = status;

+                      p_irp->IoStatus.Information = 0;

+                      IoCompleteRequest( p_irp, IO_NO_INCREMENT );

+                      BUS_EXIT( BUS_DBG_DRV );

+                      return status;

+          }

+

+          /* Acquire the remove lock. */

+          status = IoAcquireRemoveLock( &p_ext->cl_ext.remove_lock,
p_irp );

+          if( !NT_SUCCESS( status ) )

+          {

+                      IoReleaseRemoveLock( &p_ext->cl_ext.stop_lock,
p_irp );

+                      p_irp->IoStatus.Status = status;

+                      p_irp->IoStatus.Information = 0;

+                      IoCompleteRequest( p_irp, IO_NO_INCREMENT );

+                      BUS_EXIT( BUS_DBG_DRV );

+                      return status;

+          }

+          /* create additional pdo(s) */

+          status = port_mgr_pkey_add(pkey_msg->p_def_pkey_pdo,
(uint16_t*)pkey_msg->pkey_array, pkey_msg->pkey_num);

+

+          /* Release the remove and stop locks. */

+          IoReleaseRemoveLock( &p_ext->cl_ext.remove_lock, p_irp );

+          IoReleaseRemoveLock( &p_ext->cl_ext.stop_lock, p_irp );

+

+          p_irp->IoStatus.Status = status;

+          p_irp->IoStatus.Information = 0;

+          IoCompleteRequest( p_irp, IO_NO_INCREMENT );

+

+          BUS_EXIT( BUS_DBG_DRV );

+

+          return status;

+}

+

 static NTSTATUS

 bus_drv_sysctl(

            IN                                             DEVICE_OBJECT
*p_dev_obj,

@@ -516,6 +584,7 @@

            p_driver_obj->MajorFunction[IRP_MJ_POWER] = cl_power;

            p_driver_obj->MajorFunction[IRP_MJ_DEVICE_CONTROL] =
bus_drv_ioctl;

            p_driver_obj->MajorFunction[IRP_MJ_SYSTEM_CONTROL] =
bus_drv_sysctl;

+          p_driver_obj->MajorFunction[IRP_MJ_INTERNAL_DEVICE_CONTROL] =
bus_drv_int_ctl;

            p_driver_obj->DriverUnload = bus_drv_unload;

            p_driver_obj->DriverExtension->AddDevice = bus_add_device;

 

Index: core/bus/kernel/bus_pnp.h

===================================================================

--- core/bus/kernel/bus_pnp.h     (revision 1049)

+++ core/bus/kernel/bus_pnp.h  (working copy)

@@ -86,4 +86,5 @@

            IN                     const    net64_t
ca_guid,

            IN                                             IRP* const
p_irp );

 

+NTSTATUS port_mgr_pkey_add(DEVICE_OBJECT *p_default_pdo, const uint16_t
*pkey_array, uint16_t pkey_count);

 #endif  // !defined _BUS_DRV_PNP_H_

Index: core/bus/kernel/bus_port_mgr.c

===================================================================

--- core/bus/kernel/bus_port_mgr.c         (revision 1049)

+++ core/bus/kernel/bus_port_mgr.c       (working copy)

@@ -62,7 +62,7 @@

 {

            bus_pdo_ext_t                           pdo;

 

-           net64_t
port_guid;

+          port_guid_pkey                          port_guid;

            uint32_t                                     n_port;

 

            /* Number of references on the upper interface. */

@@ -512,8 +512,7 @@

                        p_pdo_ext = PARENT_STRUCT( p_list_item,
bus_pdo_ext_t, list_item );

                        p_port_ext = (bus_port_ext_t*)p_pdo_ext;

            

-                       if( p_pdo_ext->b_present &&
p_pdo_ext->b_hibernating &&

-                                   (p_port_ext->port_guid ==
p_pnp_rec->p_port_attr->port_guid) )

+                      if( p_pdo_ext->b_present &&
p_pdo_ext->b_hibernating && (p_port_ext->port_guid.guid ==
p_pnp_rec->p_port_attr->port_guid))

                        {

                                    n_devs++;

                                    break;

@@ -523,7 +522,7 @@

                                    ("Skipped PDO for %s: PDO %p, ext
%p, present %d, missing %d, hibernating %d, port_guid %I64x.\n",

 
p_pdo_ext->cl_ext.vfptr_pnp_po->identity, p_pdo_ext->cl_ext.p_self_do, 

                                    p_pdo_ext, p_pdo_ext->b_present,
p_pdo_ext->b_reported_missing, 

-                                   p_pdo_ext->b_hibernating,
p_port_ext->port_guid ) );

+                                  p_pdo_ext->b_hibernating,
p_port_ext->port_guid.guid  ) );

            }

 

            if (n_devs)

@@ -546,7 +545,7 @@

                                                ("Found PDO for %s: PDO
%p, ext %p, present %d, missing %d, hibernating %d, port_guid %I64x.\n",

 
p_pdo_ext->cl_ext.vfptr_pnp_po->identity, p_pdo_ext->cl_ext.p_self_do, 

                                                p_pdo_ext,
p_pdo_ext->b_present, p_pdo_ext->b_reported_missing, 

-
p_pdo_ext->b_hibernating, p_port_ext->port_guid ) );

+                                              p_pdo_ext->b_hibernating,
p_port_ext->port_guid.guid ) );

                        }

            }

            else 

@@ -630,9 +629,9 @@

                        BUS_TRACE_EXIT( BUS_DBG_ERROR, ("acquire_ca
failed to find CA.\n") );

                        return IB_INVALID_GUID;

            }

-           p_port_ext->port_guid = p_pnp_rec->p_port_attr->port_guid;

+          p_port_ext->port_guid.guid =
p_pnp_rec->p_port_attr->port_guid;

            p_port_ext->n_port = p_pnp_rec->p_port_attr->port_num;

-

+          p_port_ext->port_guid.pkey = IB_DEFAULT_PKEY;

            /* Store the device extension in the port vector for future
queries. */

            cl_mutex_acquire( &gp_port_mgr->pdo_mutex );

            cl_qlist_insert_tail( &gp_port_mgr->port_list,

@@ -657,7 +656,85 @@

            return IB_SUCCESS;

 }

 

+/**********************************************************************
**************

+* name            :           port_mgr_pkey_add

+*           creates pdo for each pkey value in pkey_array 

+* input :           p_pdo, pkey_array , pkey_count

+* output:          none

+* return:          NTSTATUS

+***********************************************************************
**************/

+NTSTATUS port_mgr_pkey_add(DEVICE_OBJECT *p_default_pdo , const
uint16_t *pkey_array, uint16_t pkey_count)

+{

+          NTSTATUS                    status;

+          uint16_t i;

+          DEVICE_OBJECT *p_pdo[MAX_NUM_PKEY];

+          bus_port_ext_t   *p_port_ext, *default_port_ext;

+          CL_ASSERT(pkey_array);

+          CL_ASSERT(pkey_count <= MAX_NUM_PKEY);

 

+          BUS_ENTER( BUS_DBG_PNP );

+

+          default_port_ext =
(bus_port_ext_t*)p_default_pdo->DeviceExtension;

+

+          for(i = 0; i < pkey_count; i++)

+          {

+                      /* Create the PDO for the new port device. */

+                                  status = IoCreateDevice(
bus_globals.p_driver_obj, sizeof(bus_port_ext_t),

+                                              NULL,
FILE_DEVICE_CONTROLLER,

+                                              FILE_DEVICE_SECURE_OPEN |
FILE_AUTOGENERATED_DEVICE_NAME ,

+                                              FALSE, &p_pdo[i] );

+          

+                      if( !NT_SUCCESS( status ) )

+                      {

+                                  BUS_TRACE_EXIT( BUS_DBG_ERROR,

+                                              ("IoCreateDevice returned
%08x. for Pkey = %04X\n", status,pkey_array[i]) );

+                                  return status;

+                      }

+          

+                      /* Initialize the device extension. */

+                      cl_init_pnp_po_ext( p_pdo[i], NULL, p_pdo[i],
bus_globals.dbg_lvl,

+                                  &vfptr_port_pnp,
&vfptr_port_query_txt );

+          

+                      /* Set the DO_BUS_ENUMERATED_DEVICE flag to mark
it as a PDO. */

+                      p_pdo[i]->Flags |= DO_BUS_ENUMERATED_DEVICE;

+          

+                      p_port_ext = p_pdo[i]->DeviceExtension;

+                      p_port_ext->pdo.dev_po_state.DeviceState =
PowerDeviceD0;

+                      p_port_ext->pdo.p_parent_ext =
bus_globals.p_bus_ext;

+                      p_port_ext->pdo.b_present = TRUE;

+                      p_port_ext->pdo.b_reported_missing = FALSE;

+                      p_port_ext->pdo.b_hibernating = FALSE;

+                      p_port_ext->pdo.p_po_work_item = NULL;

+          

+                      BUS_TRACE( BUS_DBG_PNP, ("Created device for %s:
PDO %p,ext %p, present %d, missing %d .\n",

+
p_port_ext->pdo.cl_ext.vfptr_pnp_po->identity, p_pdo[i], p_port_ext,
p_port_ext->pdo.b_present, 

+                                  p_port_ext->pdo.b_reported_missing )
);

+

+                      p_port_ext->pdo.ca_guid =
default_port_ext->pdo.ca_guid;

+                      p_port_ext->pdo.h_ca =
default_port_ext->pdo.h_ca;

+

+                      p_port_ext->port_guid.guid =
default_port_ext->port_guid.guid;

+                      p_port_ext->port_guid.pkey = pkey_array[i];

+                      p_port_ext->n_port = default_port_ext->n_port;

+

+                      /* Store the device extension in the port vector
for future queries. */

+                      cl_mutex_acquire( &gp_port_mgr->pdo_mutex );

+                      cl_qlist_insert_tail( &gp_port_mgr->port_list,

+                                  &p_port_ext->pdo.list_item );

+                      cl_mutex_release( &gp_port_mgr->pdo_mutex );

+

+                      /* 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 );

+

+                      /* Invalidate removal relations for the bus
driver. */

+                      IoInvalidateDeviceRelations(

+                                  bus_globals.p_bus_ext->cl_ext.p_pdo,
RemovalRelations );

+          }

+                      BUS_EXIT( BUS_DBG_PNP );

+                      return STATUS_SUCCESS;

+}

+

 void

 port_mgr_port_remove(

            IN
ib_pnp_port_rec_t*                                p_pnp_rec )

@@ -1063,16 +1140,16 @@

            }

 

            /* The instance ID is the port GUID. */

-           p_string = ExAllocatePoolWithTag( PagedPool, sizeof(WCHAR) *
17, 'iuqp' );

+          p_string = ExAllocatePoolWithTag( PagedPool, sizeof(WCHAR) *
21, 'iuqp' );

            if( !p_string )

            {

                        BUS_TRACE_EXIT( BUS_DBG_ERROR,

                                    ("Failed to allocate instance ID
buffer (%d bytes).\n",

-                                   sizeof(WCHAR) * 17) );

+                                  sizeof(WCHAR) * 21) );

                        return STATUS_NO_MEMORY;

            }

 

-           status = RtlStringCchPrintfW( p_string, 17, L"%016I64x",
p_ext->port_guid );

+          status = RtlStringCchPrintfW( p_string, 21,
L"%016I64x%04x",p_ext->port_guid.guid,p_ext->port_guid.pkey );

            if( !NT_SUCCESS( status ) )

            {

                        CL_ASSERT( NT_SUCCESS( status ) );

Index: inc/kernel/iba/ipoib_ifc.h

===================================================================

--- inc/kernel/iba/ipoib_ifc.h        (revision 1049)

+++ inc/kernel/iba/ipoib_ifc.h     (working copy)

@@ -62,6 +62,30 @@

 * DESCRIPTION

 *          IPoIB interface datat.

 *

+*         The port guid combined from guid + PKEY 

+*/

+typedef struct _port_guid_pkey

+{

+          net64_t             guid;

+          ib_net16_t         pkey;

+} port_guid_pkey;

+

+#define           MAX_NUM_PKEY          16

+

+typedef struct _pkey_array

+{

+          DEVICE_OBJECT *p_def_pkey_pdo;

+          ib_net16_t           pkey_num;

+          ib_net16_t    pkey_array[MAX_NUM_PKEY];

+}pkey_array_t;

+

+/* Internal dev ctl code */

+#define IOCTL_CREATE_PDO\

+   CTL_CODE(ALDEV_KEY, 0x005, METHOD_BUFFERED,\

+         FILE_READ_DATA | FILE_WRITE_DATA )

+

+

+/*

 *          The ipoib_ifc_data_t structure 

 *

 * SYNOPSIS

@@ -69,7 +93,7 @@

 typedef struct _ipoib_ifc_data

 {

            net64_t
ca_guid;

-           net64_t
port_guid;

+          port_guid_pkey
port_guid;

            uint8_t
port_num;

 

 }          ipoib_ifc_data_t;

Index: ulp/ipoib/kernel/ipoib_adapter.c

===================================================================

--- ulp/ipoib/kernel/ipoib_adapter.c          (revision 1049)

+++ ulp/ipoib/kernel/ipoib_adapter.c       (working copy)

@@ -171,7 +171,7 @@

 

            IPOIB_PRINT( TRACE_LEVEL_INFORMATION, IPOIB_DBG_INIT,

                                    ("Port %016I64x (CA %016I64x port
%d) initializing\n",

-                                   p_adapter->guids.port_guid,
p_adapter->guids.ca_guid,

+                                  p_adapter->guids.port_guid.guid,
p_adapter->guids.ca_guid,

                                    p_adapter->guids.port_num) );

 

            cl_status = cl_obj_init( &p_adapter->obj, CL_DESTROY_SYNC,

@@ -343,7 +343,7 @@

 

            /* Validate the port GUID and generate the MAC address. */

            status =

-                       ipoib_mac_from_guid( p_adapter->guids.port_guid,
&p_adapter->mac );

+                      ipoib_mac_from_guid(
p_adapter->guids.port_guid.guid, &p_adapter->mac );

            if( status != IB_SUCCESS )

            {

                        IPOIB_PRINT_EXIT( TRACE_LEVEL_ERROR,
IPOIB_DBG_ERROR,

@@ -530,7 +530,7 @@

            case IB_PNP_PORT_ADD:

                        CL_ASSERT( !p_pnp_rec->context );

                        /* Only process our port GUID. */

-                       if( p_pnp_rec->guid !=
p_adapter->guids.port_guid )

+                      if( p_pnp_rec->guid !=
p_adapter->guids.port_guid.guid )

                        {

                                    status = IB_NOT_DONE;

                                    break;

Index: ulp/ipoib/kernel/ipoib_driver.c

===================================================================

--- ulp/ipoib/kernel/ipoib_driver.c (revision 1049)

+++ ulp/ipoib/kernel/ipoib_driver.c          (working copy)

@@ -48,6 +48,7 @@

 #include <initguid.h>

 #include <iba/ipoib_ifc.h>

 

+#include "al_dev.h"

 

 #if defined(NDIS50_MINIPORT)

 #define MAJOR_NDIS_VERSION 5

@@ -225,6 +226,8 @@

 __ipoib_read_registry(

            IN
UNICODE_STRING* const                     p_registry_path );

 

+static NDIS_STATUS

+ipoib_send_pkey_req(ipoib_adapter_t *p_adapter, pkey_array_t
*pkey_arr);

 

 //! Standard Windows Device Driver Entry Point

 /*! DriverEntry is the first routine called after a driver is loaded,
and

@@ -397,6 +400,121 @@

 }

 

 

+/**********************************************************************
**************

+* name            :           __prepare_pKey_array

+*           parses registry string and exrtacts pkey value(s) from it.

+* input :           UNICODE_STRING *str

+* output:          pkey_array

+* return:          uint16_t number of pkey(s) found

+***********************************************************************
**************/

+static uint16_t __prepare_pKey_array(IN const UNICODE_STRING *str, OUT
uint16_t *pkey_array)

+{

+          uint16_t i, num_pKeys;

+          NTSTATUS status;

+          ANSI_STRING ansi_str;

+

+          IPOIB_ENTER( IPOIB_DBG_INIT );

+

+          CL_ASSERT(pkey_array);

+          CL_ASSERT(str);

+

+          num_pKeys = 0;

+

+          status = RtlUnicodeStringToAnsiString(&ansi_str,str,TRUE);

+          if(! NT_SUCCESS(status))

+          {

+                      IPOIB_PRINT_EXIT( TRACE_LEVEL_ERROR,
IPOIB_DBG_ERROR,

+                                  ("RtlUnicodeStringToAnsiString
returned 0x%.8x\n", status) );

+                      return 0;

+          }

+

+          for (i = 0; (i < ansi_str.MaximumLength) && (num_pKeys <
MAX_NUM_PKEY) ; i++)

+    {

+                      switch(ansi_str.Buffer[i])

+                      {

+                      case '0':

+                                  if (((i+1) < ansi_str.Length) && ( (
ansi_str.Buffer[i+1] == 'x') || ( ansi_str.Buffer[i+1] == 'X')))

+                                              break;

+                                  else

+                                  {

+                                              pkey_array[num_pKeys] = \

+                                              (pkey_array[num_pKeys] <<
4)| 0;

+                                              break;

+                                  }

+

+                      case 'x':

+                      case 'X':

+                                  break;

+

+                      case ',':

+                                  if(i > 3)

+                                              num_pKeys++;

+                                  break;

+

+                      case 'A':

+                      case 'a':

+                                  pkey_array[num_pKeys] = \

+                                  (pkey_array[num_pKeys] << 4)| 0xA;

+                                  break;

+

+                      case 'B':

+                      case 'b':

+                                  pkey_array[num_pKeys] = \

+                                  (pkey_array[num_pKeys] << 4)| 0xB;

+                                  break;

+

+                      case 'C':

+                      case 'c':

+                                  pkey_array[num_pKeys] = \

+                                  (pkey_array[num_pKeys] << 4)| 0xC;

+                                  break;

+

+                      case 'D':

+                      case 'd':

+                                  pkey_array[num_pKeys] = \

+                                  (pkey_array[num_pKeys] << 4)| 0xD;

+                                  break;

+

+                      case 'E':

+                      case 'e':

+                                  pkey_array[num_pKeys] = \

+                                  (pkey_array[num_pKeys] << 4)| 0xE;

+                                  break;

+

+                      case 'F':

+                      case 'f':

+                                  pkey_array[num_pKeys] = \

+                                  (pkey_array[num_pKeys] << 4)| 0xF;

+                                  break;

+

+                      case '1':

+                      case '2':

+                      case '3':

+                      case '4':

+                      case '5':

+                      case '6':

+                      case '7':

+                      case '8':

+                      case '9':

+                                  pkey_array[num_pKeys] = \

+                                  (pkey_array[num_pKeys] << 4)|
(ansi_str.Buffer[i] - '0');

+                                  break;

+                                  

+                      case '\0':

+                                  if(i > 3)

+                                              num_pKeys++;

+                                  break;

+

+                      default:

+                                  break;

+

+                      }

+          }

+

+    RtlFreeAnsiString(&ansi_str);

+          IPOIB_EXIT( IPOIB_DBG_INIT );

+          return num_pKeys;

+}

 NDIS_STATUS

 ipoib_get_adapter_params(

            IN                                             NDIS_HANDLE*
const                           wrapper_config_context,

@@ -408,6 +526,7 @@

            NDIS_STRING
keyword;

            PUCHAR
mac;

            UINT
len;

+          pkey_array_t
pkey_arr;

 

            IPOIB_ENTER( IPOIB_DBG_INIT );

 

@@ -559,13 +678,91 @@

                        }

            }

 

+          /* Optional: Partition Key values to be used with this port.
*/

+          RtlZeroMemory(&pkey_arr,sizeof(pkey_arr));

+          RtlInitUnicodeString( &keyword, L"PartitionKey" );

+          NdisReadConfiguration(

+                      &status, &p_param, h_config, &keyword,
NdisParameterString );

+          if( status != NDIS_STATUS_SUCCESS )

+          {

+                      IPOIB_PRINT( TRACE_LEVEL_ERROR, IPOIB_DBG_INIT,

+                                  ("port %04X Failed to read Pkey
values configuration\n",p_adapter->guids.port_guid.pkey));

+          }

+          else

+                      pkey_arr.pkey_num =
__prepare_pKey_array(&p_param->ParameterData.StringData,(uint16_t*)pkey_
arr.pkey_array);

+

+          if( pkey_arr.pkey_num)

+                      ipoib_send_pkey_req(p_adapter, &pkey_arr);

            NdisCloseConfiguration( h_config );

 

            IPOIB_EXIT( IPOIB_DBG_INIT );

            return NDIS_STATUS_SUCCESS;

 }

 

+/**********************************************************************
****

+* name            :           ipoib_send_pkey_req

+*                                 creates pdo(s) for non-default
pkey(s)

+* input :           p_adapter, pkey_arr

+* output:          none

+* return:          NDIS_STATUS

+***********************************************************************
***/

+NDIS_STATUS

+ipoib_send_pkey_req(ipoib_adapter_t *p_adapter, pkey_array_t *pkey_arr)

+{

+          NTSTATUS                                status;

+          DEVICE_OBJECT                     *p_pdo;

+          IRP
*p_irp;

+          KEVENT                                               event;

+          IO_STATUS_BLOCK                  io_status;

+          NDIS_STRING                           dev_name;

+          PFILE_OBJECT                        fobject;

 

+          IPOIB_ENTER( IPOIB_DBG_INIT );

+

+          if(p_adapter->guids.port_guid.pkey != IB_DEFAULT_PKEY)

+          {

+                      IPOIB_PRINT( TRACE_LEVEL_ERROR, IPOIB_DBG_INIT,

+                                  ("Only device with default pkey can
create partition VLAN\n"));

+                      return STATUS_INVALID_PARAMETER;

+          }

+

+          RtlInitUnicodeString( &dev_name, AL_DEVICE_NAME );

+

+    status = IoGetDeviceObjectPointer(& dev_name,

+                                        FILE_GENERIC_READ,

+                                      & fobject,

+                                      & p_pdo);

+          if(! NT_SUCCESS(status))

+          {

+                      IPOIB_PRINT_EXIT( TRACE_LEVEL_ERROR,
IPOIB_DBG_ERROR,

+                                  ("IoGetDeviceObjectPointer returned
%08X\n",status) );

+                      return status;

+          }

+

+          NdisMGetDeviceProperty( p_adapter->h_adapter,
&pkey_arr->p_def_pkey_pdo, NULL, NULL, NULL, NULL );

+          KeInitializeEvent( &event, NotificationEvent, FALSE );

+

+          p_irp = IoBuildDeviceIoControlRequest( IOCTL_CREATE_PDO,
p_pdo,

+                      pkey_arr, sizeof(pkey_array_t), NULL,0,TRUE,
&event, &io_status );

+

+          if( !p_irp )

+          {

+                      IPOIB_PRINT_EXIT( TRACE_LEVEL_ERROR,
IPOIB_DBG_ERROR,

+                                  ("Failed to allocate IoControlRequest
IRP.\n") );

+                      return STATUS_INSUFFICIENT_RESOURCES;

+          }

+

+          status = IoCallDriver(p_pdo, p_irp);

+          if (status == STATUS_PENDING)

+          {

+                      KeWaitForSingleObject( &event, Executive,
KernelMode,

+                                  FALSE, NULL );

+                      status = io_status.Status;

+          }

+          IPOIB_EXIT( IPOIB_DBG_INIT );

+          return status;

+}

+

 NDIS_STATUS

 ipoib_get_adapter_guids(

            IN                                             NDIS_HANDLE*
const                           h_adapter,

@@ -767,7 +964,7 @@

 

            IPOIB_PRINT( TRACE_LEVEL_INFORMATION, IPOIB_DBG_INIT,

                                    ("Port %016I64x (CA %016I64x port
%d) halting\n",

-                                   p_adapter->guids.port_guid,
p_adapter->guids.ca_guid,

+                                  p_adapter->guids.port_guid.guid,
p_adapter->guids.ca_guid,

                                    p_adapter->guids.port_num) );

 

            ipoib_destroy_adapter( p_adapter );

@@ -2336,10 +2533,10 @@

            cl_memset( &ib_service, 0, sizeof(ib_service) );

 

            /* BUGBUG Only register local subnet GID prefix for now */

-           ib_gid_set_default( &port_gid, p_adapter->guids.port_guid );

+          ib_gid_set_default( &port_gid,
p_adapter->guids.port_guid.guid );

            ib_service.svc_rec.service_gid               = port_gid;

 

-           ib_service.svc_rec.service_pkey             =
IB_DEFAULT_PKEY;

+          ib_service.svc_rec.service_pkey             =
p_adapter->guids.port_guid.pkey;

            ib_service.svc_rec.service_lease            =
IB_INFINITE_SERVICE_LEASE;

 

            /* Must cast here because the service name is an array of
unsigned chars but

@@ -2347,7 +2544,7 @@

            strcpy( (char *)ib_service.svc_rec.service_name, ATS_NAME );

 

            /* IP Address in question will be put in below */

-           ib_service.port_guid                   =
p_adapter->guids.port_guid;

+          ib_service.port_guid                   =
p_adapter->guids.port_guid.guid;

            ib_service.timeout_ms                =
p_adapter->params.sa_timeout;

            ib_service.retry_cnt                   =
p_adapter->params.sa_retry_cnt;

 

Index: ulp/ipoib/kernel/ipoib_endpoint.c

===================================================================

--- ulp/ipoib/kernel/ipoib_endpoint.c        (revision 1049)

+++ ulp/ipoib/kernel/ipoib_endpoint.c      (working copy)

@@ -312,13 +312,13 @@

 

            cl_memclr( &path, sizeof(ib_path_rec_t) );

            path.dgid = p_endpt->dgid;

-           ib_gid_set_default( &path.sgid,
p_port->p_adapter->guids.port_guid );

+          ib_gid_set_default( &path.sgid,
p_port->p_adapter->guids.port_guid.guid );

            path.num_path = 0x1;

 

            cl_memclr( &query, sizeof(ib_query_req_t) );

            query.query_type = IB_QUERY_USER_DEFINED;

            query.p_query_input = &info;

-           query.port_guid = p_port->p_adapter->guids.port_guid;

+          query.port_guid = p_port->p_adapter->guids.port_guid.guid;

            query.timeout_ms = p_port->p_adapter->params.sa_timeout;

            query.retry_cnt = p_port->p_adapter->params.sa_retry_cnt;

 

Index: ulp/ipoib/kernel/ipoib_ibat.c

===================================================================

--- ulp/ipoib/kernel/ipoib_ibat.c    (revision 1049)

+++ ulp/ipoib/kernel/ipoib_ibat.c (working copy)

@@ -140,7 +140,7 @@

            {

                        pAdapter = CONTAINING_RECORD( pItem,
ipoib_adapter_t, entry );

                        pOut->Ports[pOut->NumPorts].CaGuid =
pAdapter->guids.ca_guid;

-                       pOut->Ports[pOut->NumPorts].PortGuid =
pAdapter->guids.port_guid;

+                      pOut->Ports[pOut->NumPorts].PortGuid =
pAdapter->guids.port_guid.guid;

                        pOut->Ports[pOut->NumPorts].PortNum =
pAdapter->guids.port_num;

                        pOut->NumPorts++;

 

@@ -210,7 +210,7 @@

                        pItem = cl_qlist_next( pItem ) )

            {

                        pAdapter = CONTAINING_RECORD( pItem,
ipoib_adapter_t, entry );

-                       if( PortGuid && pAdapter->guids.port_guid !=
PortGuid )

+                      if( PortGuid && pAdapter->guids.port_guid.guid !=
PortGuid )

                                    continue;

 

                        cl_obj_lock( &pAdapter->obj );

@@ -300,7 +300,7 @@

                        pItem = cl_qlist_next( pItem ) )

            {

                        pAdapter = CONTAINING_RECORD( pItem,
ipoib_adapter_t, entry );

-                       if( pIn->PortGuid != pAdapter->guids.port_guid )

+                      if( pIn->PortGuid !=
pAdapter->guids.port_guid.guid )

                                    continue;

 

                        /* Found the port - lookup the MAC. */

@@ -394,7 +394,7 @@

                                    if (!memcmp(
&pIn->Address.Address[12], pAddr->address.as_bytes, IPV4_ADDR_SIZE))

                                    {

                                                pOut->Port.CaGuid =
pAdapter->guids.ca_guid;

-                                               pOut->Port.PortGuid =
pAdapter->guids.port_guid;

+                                              pOut->Port.PortGuid =
pAdapter->guids.port_guid.guid;

                                                pOut->Port.PortNum =
pAdapter->guids.port_num;

 
pIrp->IoStatus.Information = sizeof(IOCTL_IBAT_IP_TO_PORT_OUT);

                                                status = STATUS_SUCCESS;

Index: ulp/ipoib/kernel/ipoib_port.c

===================================================================

--- ulp/ipoib/kernel/ipoib_port.c   (revision 1049)

+++ ulp/ipoib/kernel/ipoib_port.c (working copy)

@@ -793,6 +793,8 @@

            uint64_t                         vaddr;

            net32_t                                     rkey;

            ib_qp_attr_t                   qp_attr;

+          ib_ca_attr_t                   *ca_attr;

+          uint32_t                         ca_size;

 

            IPOIB_ENTER( IPOIB_DBG_INIT );

 

@@ -810,6 +812,49 @@

                        return status;

            }

 

+          /* Query the CA for Pkey table */

+          status =
p_port->p_adapter->p_ifc->query_ca(p_port->ib_mgr.h_ca, NULL, &ca_size);

+          if(status != IB_INSUFFICIENT_MEMORY)

+          {

+                      IPOIB_PRINT_EXIT( TRACE_LEVEL_ERROR,
IPOIB_DBG_ERROR,

+                                  ("ib_query_ca failed\n"));

+                                  return status;

+          }

+

+          ca_attr = (ib_ca_attr_t*)cl_zalloc(ca_size);

+          if          (!ca_attr)

+          {

+                      IPOIB_PRINT_EXIT( TRACE_LEVEL_ERROR,
IPOIB_DBG_ERROR,

+                                  ("cl_zalloc can't allocate
%d\n",ca_size));

+                      return IB_INSUFFICIENT_RESOURCES;

+          }

+

+          status =
p_port->p_adapter->p_ifc->query_ca(p_port->ib_mgr.h_ca,
ca_attr,&ca_size);     

+          if( status != IB_SUCCESS )

+          {

+                      IPOIB_PRINT_EXIT( TRACE_LEVEL_ERROR,
IPOIB_DBG_ERROR,

+                                  ("ib_query_ca returned %s\n", 

+
p_port->p_adapter->p_ifc->get_err_str( status )) );

+                      return status;

+          }

+          if( ca_attr->p_port_attr->link_state == IB_LINK_ACTIVE)

+          {

+                      uint16_t index;

+                      CL_ASSERT(ca_attr->p_port_attr->p_pkey_table[0]
== IB_DEFAULT_PKEY);

+                      for(index = 0; index <
ca_attr->p_port_attr->num_pkeys; index++)

+                      {

+
if(p_port->p_adapter->guids.port_guid.pkey ==
ca_attr->p_port_attr->p_pkey_table[index])

+                                              break;

+                      }

+                      if(index >= ca_attr->p_port_attr->num_pkeys)

+                      {

+                                  IPOIB_PRINT_EXIT( TRACE_LEVEL_ERROR,
IPOIB_DBG_ERROR,

+                                  ("Pkey table is invalid, index not
found\n"));

+                          return IB_NOT_FOUND;

+                      }

+                      p_port->pkey_index = index;

+          }

+          cl_free(ca_attr);

            /* Allocate the PD. */

            status = p_port->p_adapter->p_ifc->alloc_pd(

                        p_port->ib_mgr.h_ca, IB_PDT_UD, p_port,
&p_port->ib_mgr.h_pd );

@@ -3309,7 +3354,7 @@

 

                        CL_ASSERT( p_cid[1] == 21 );

                        p_cid[23]= DHCP_OPT_END;

-                       ib_gid_set_default( &gid,
p_port->p_adapter->guids.port_guid );

+                      ib_gid_set_default( &gid,
p_port->p_adapter->guids.port_guid.guid );

                        cl_memcpy( &p_cid[7], &gid, sizeof(ib_gid_t) );

                        cl_memcpy( &p_cid[3], &p_port->ib_mgr.qpn,
sizeof(p_port->ib_mgr.qpn) );                     

                        p_ib_dhcp->htype = DHCP_HW_TYPE_IB;

@@ -3409,7 +3454,7 @@

            p_ib_arp->op = p_arp->op;

            p_ib_arp->src_hw.flags_qpn = p_port->ib_mgr.qpn;

            ib_gid_set_default( &p_ib_arp->src_hw.gid,

-                       p_port->p_adapter->guids.port_guid );

+                      p_port->p_adapter->guids.port_guid.guid );

            p_ib_arp->src_ip = p_arp->src_ip;

            if( cl_memcmp( &p_arp->dst_hw, &null_hw, sizeof(mac_addr_t)
) )

            {

@@ -3584,7 +3629,7 @@

            p_desc->wr.dgrm.ud.remote_qp = p_desc->p_endpt->qpn;

            p_desc->wr.dgrm.ud.remote_qkey =
p_port->ib_mgr.bcast_rec.qkey;

            p_desc->wr.dgrm.ud.h_av = p_desc->p_endpt->h_av;

-           p_desc->wr.dgrm.ud.pkey_index = 0;

+          p_desc->wr.dgrm.ud.pkey_index = p_port->pkey_index;

            p_desc->wr.dgrm.ud.rsvd = NULL;

 

            /* Store context in our reserved area of the packet. */

@@ -4683,7 +4728,7 @@

            cl_memclr( &query, sizeof(ib_query_req_t) );

            query.query_type = IB_QUERY_USER_DEFINED;

            query.p_query_input = &info;

-           query.port_guid = p_port->p_adapter->guids.port_guid;

+          query.port_guid = p_port->p_adapter->guids.port_guid.guid;

            query.timeout_ms = p_port->p_adapter->params.sa_timeout;

            query.retry_cnt = p_port->p_adapter->params.sa_retry_cnt;

            query.query_context = p_port;

@@ -4721,7 +4766,7 @@

 

            IPOIB_ENTER( IPOIB_DBG_INIT );

 

-           ib_gid_set_default( &gid, p_port->p_adapter->guids.port_guid
);

+          ib_gid_set_default( &gid,
p_port->p_adapter->guids.port_guid.guid );

            p_endpt = ipoib_endpt_create(

                        &gid, p_port_info->base_lid, p_port->ib_mgr.qpn
);

            if( !p_endpt )

@@ -4894,10 +4939,13 @@

            cl_memclr( &member_rec, sizeof(ib_member_rec_t) );

            member_rec.mgid = bcast_mgid_template;

 

+    member_rec.mgid.raw[4] =
(uint8_t)(p_port->p_adapter->guids.port_guid.pkey >> 8);

+          member_rec.mgid.raw[5] = (uint8_t)
p_port->p_adapter->guids.port_guid.pkey;

+          member_rec.pkey = p_port->p_adapter->guids.port_guid.pkey;

            cl_memclr( &query, sizeof(ib_query_req_t) );

            query.query_type = IB_QUERY_USER_DEFINED;

            query.p_query_input = &info;

-           query.port_guid = p_port->p_adapter->guids.port_guid;

+          query.port_guid = p_port->p_adapter->guids.port_guid.guid;

            query.timeout_ms = p_port->p_adapter->params.sa_timeout;

            query.retry_cnt = p_port->p_adapter->params.sa_retry_cnt;

            query.query_context = p_port;

@@ -5031,14 +5079,14 @@

            /* We specify our port GID for the join operation. */

            mcast_req.member_rec.port_gid.unicast.prefix =
IB_DEFAULT_SUBNET_PREFIX;

            mcast_req.member_rec.port_gid.unicast.interface_id =

-                       p_port->p_adapter->guids.port_guid;

+                      p_port->p_adapter->guids.port_guid.guid;

 

            mcast_req.mcast_context = p_port;

            mcast_req.pfn_mcast_cb = __bcast_cb;

            mcast_req.timeout_ms = p_port->p_adapter->params.sa_timeout;

            mcast_req.retry_cnt =
p_port->p_adapter->params.sa_retry_cnt;

-           mcast_req.port_guid = p_port->p_adapter->guids.port_guid;

-           mcast_req.pkey_index = 0;

+          mcast_req.port_guid =
p_port->p_adapter->guids.port_guid.guid;

+          mcast_req.pkey_index = p_port->pkey_index;

 

            if( ib_member_get_state( mcast_req.member_rec.scope_state )
!=

                        IB_MC_REC_STATE_FULL_MEMBER )

@@ -5086,7 +5134,10 @@

             */

            mcast_req.member_rec.mgid = bcast_mgid_template;

            ib_gid_set_default( &mcast_req.member_rec.port_gid,

-                       p_port->p_adapter->guids.port_guid );

+                      p_port->p_adapter->guids.port_guid.guid );

+

+          mcast_req.member_rec.mgid.raw[4] = (uint8_t)
(p_port->p_adapter->guids.port_guid.pkey >> 8);

+          mcast_req.member_rec.mgid.raw[5] = (uint8_t)
p_port->p_adapter->guids.port_guid.pkey;

            /*

             * IPOIB spec requires that the QKEY have the MSb set so
that the QKEY

             * from the QP is used rather than the QKEY in the send WR.

@@ -5096,7 +5147,7 @@

            mcast_req.member_rec.mtu =

                        (IB_PATH_SELECTOR_EXACTLY << 6) |
IB_MTU_LEN_2048;

 

-           mcast_req.member_rec.pkey = IB_DEFAULT_PKEY;

+          mcast_req.member_rec.pkey =
p_port->p_adapter->guids.port_guid.pkey;

 

            mcast_req.member_rec.sl_flow_hop =
ib_member_set_sl_flow_hop( 0, 0, 0 );

            mcast_req.member_rec.scope_state =

@@ -5106,8 +5157,8 @@

            mcast_req.pfn_mcast_cb = __bcast_cb;

            mcast_req.timeout_ms = p_port->p_adapter->params.sa_timeout;

            mcast_req.retry_cnt =
p_port->p_adapter->params.sa_retry_cnt;

-           mcast_req.port_guid = p_port->p_adapter->guids.port_guid;

-           mcast_req.pkey_index = 0;

+          mcast_req.port_guid =
p_port->p_adapter->guids.port_guid.guid;

+          mcast_req.pkey_index = p_port->pkey_index;

 

            /* reference the object for the multicast join request. */

            ipoib_port_ref( p_port, ref_join_bcast );

@@ -5362,9 +5413,9 @@

            }

 

            /* Move the QP to RTS. */

-           dgrm_info.port_guid = p_port->p_adapter->guids.port_guid;

+          dgrm_info.port_guid =
p_port->p_adapter->guids.port_guid.guid;

            dgrm_info.qkey = p_port->ib_mgr.bcast_rec.qkey;

-           dgrm_info.pkey_index = 0;

+          dgrm_info.pkey_index = p_port->pkey_index;

            status = p_port->p_adapter->p_ifc->init_dgrm_svc(
p_port->ib_mgr.h_qp, &dgrm_info );

            if( status != IB_SUCCESS )

            {

@@ -5464,9 +5515,9 @@

            mcast_req.pfn_mcast_cb = __mcast_cb;

            mcast_req.timeout_ms = p_port->p_adapter->params.sa_timeout;

            mcast_req.retry_cnt =
p_port->p_adapter->params.sa_retry_cnt;

-           mcast_req.port_guid = p_port->p_adapter->guids.port_guid;

-           mcast_req.pkey_index = 0;

-

+          mcast_req.port_guid =
p_port->p_adapter->guids.port_guid.guid;

+          mcast_req.pkey_index = p_port->pkey_index;

+          mcast_req.member_rec.pkey =
p_port->p_adapter->guids.port_guid.pkey;

            /*

             * Create the endpoint and insert it in the port.  Since we
don't wait for

             * the mcast SA operations to complete before returning from
the multicast

Index: ulp/ipoib/kernel/ipoib_port.h

===================================================================

--- ulp/ipoib/kernel/ipoib_port.h   (revision 1049)

+++ ulp/ipoib/kernel/ipoib_port.h (working copy)

@@ -506,6 +506,7 @@

            atomic32_t
endpt_rdr;

 

            atomic32_t
hdr_idx;

+          uint16_t                                     pkey_index;

            ipoib_hdr_t
hdr[1];  /* Must be last! */

 

 }          ipoib_port_t;

Index: ulp/ipoib/kernel/netipoib.inf

===================================================================

--- ulp/ipoib/kernel/netipoib.inf    (revision 1049)

+++ ulp/ipoib/kernel/netipoib.inf  (working copy)

@@ -126,6 +126,12 @@

 HKR, Ndi\Params\PayloadMtu,              Min,                  0, "60"

 HKR, Ndi\Params\PayloadMtu,              Max,                 0, "2044"

 

+HKR, Ndi\Params\PartitionKey,             ParamDesc,      0, "Partition
Key (hex)"

+HKR, Ndi\Params\PartitionKey,                         Type,
0, "edit"

+HKR, Ndi\Params\PartitionKey,                         LimitText,
0, "7"

+HKR, Ndi\Params\PartitionKey,                         UpperCase,
0, "1"

+HKR, Ndi\Params\PartitionKey,                         Default,
0, "0"

+HKR, Ndi\Params\PartitionKey,                         Optional,
0, "1"

 [IpoibService]

 DisplayName     = %IpoibServiceDispName%

 ServiceType     = 1 ;%SERVICE_KERNEL_DRIVER%

Index: ulp/ipoib/kernel/SOURCES

===================================================================

--- ulp/ipoib/kernel/SOURCES     (revision 1049)

+++ ulp/ipoib/kernel/SOURCES  (working copy)

@@ -18,7 +18,7 @@

                        ipoib_port.c \

                        ipoib_ibat.c

 

-INCLUDES=..;..\..\..\inc;..\..\..\inc\kernel;

+INCLUDES=..;..\..\..\inc;..\..\..\inc\kernel;..\..\..\core\al;

 

 C_DEFINES=$(C_DEFINES) -DNDIS_MINIPORT_DRIVER -DNDIS_WDM=1 \

            -DDEPRECATE_DDK_FUNCTIONS -DNDIS51_MINIPORT -DNEED_CL_OBJ
-DBINARY_COMPATIBLE=0

 

Slava Strebkov

SW Engineer

Voltaire

099718750

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openfabrics.org/pipermail/ofw/attachments/20080413/64d0831e/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: partitions.diff
Type: application/octet-stream
Size: 31525 bytes
Desc: partitions.diff
URL: <http://lists.openfabrics.org/pipermail/ofw/attachments/20080413/64d0831e/attachment.obj>


More information about the ofw mailing list