\r
typedef struct _pkey_array\r
{\r
+ ib_net64_t port_guid;\r
ib_net16_t pkey_num;\r
ib_net16_t pkey_array[MAX_NUM_PKEY];\r
}pkey_array_t;\r
cl_status_t\r
bus_add_pkey(\r
IN cl_ioctl_handle_t h_ioctl );\r
+cl_status_t\r
+bus_rem_pkey(\r
+ IN cl_ioctl_handle_t h_ioctl );\r
\r
/* Define data structures for user-mode proxy */\r
#else /* CL_KERNEL */\r
ual_bind_cq,\r
ual_bind_destroy,\r
ual_bind_nd,\r
- ual_req_create_pdo,\r
al_proxy_maxops\r
\r
} al_proxy_ops_t;\r
#define UAL_BIND_CQ IOCTL_CODE(ALDEV_KEY, ual_bind_cq)\r
#define UAL_BIND_DESTROY IOCTL_CODE(ALDEV_KEY, ual_bind_destroy)\r
#define UAL_BIND_ND IOCTL_CODE(ALDEV_KEY, ual_bind_nd)\r
-#define UAL_REQ_CREATE_PDO IOCTL_CODE(ALDEV_KEY, ual_req_create_pdo)\r
\r
#define AL_PROXY_OPS_START IOCTL_CODE(ALDEV_KEY, al_proxy_ops_start)\r
#define AL_PROXY_MAXOPS IOCTL_CODE(ALDEV_KEY, al_proxy_maxops)\r
ual_reject_ioc_cmd,\r
ual_add_svc_entry_cmd,\r
ual_remove_svc_entry_cmd,\r
-\r
- al_ioc_maxops\r
+ ual_req_create_pdo,\r
+ ual_req_remove_pdo,\r
+ al_ioc_maxops,\r
\r
} al_ioc_ops_t;\r
\r
\r
\r
#define UAL_GET_CA_ATTR_INFO IOCTL_CODE(ALDEV_KEY, ual_get_ca_attr)\r
+#define UAL_REQ_CREATE_PDO IOCTL_CODE(ALDEV_KEY, ual_req_create_pdo)\r
+#define UAL_REQ_REMOVE_PDO IOCTL_CODE(ALDEV_KEY, ual_req_remove_pdo)\r
\r
/* PnP related ioctl commands. */\r
#define UAL_REG_PNP IOCTL_CODE(ALDEV_KEY, ual_reg_pnp_cmd)\r
\r
CL_ASSERT( p_port_attr_1->port_guid == p_port_attr_2->port_guid );\r
\r
- if( cl_memcmp( p_port_attr_1, p_port_attr_2,\r
- offsetof( ib_port_attr_t, p_gid_table ) ) != 0 )\r
+ if( (cl_memcmp( p_port_attr_1, p_port_attr_2,\r
+ offsetof( ib_port_attr_t, p_gid_table ) ) != 0 ) ||\r
+ (cl_memcmp(p_port_attr_1->p_gid_table,p_port_attr_2->p_gid_table,\r
+ p_port_attr_1->num_gids*sizeof(p_port_attr_1->p_gid_table[0]))) ||\r
+ (cl_memcmp(p_port_attr_1->p_pkey_table,p_port_attr_2->p_pkey_table,\r
+ p_port_attr_1->num_pkeys*sizeof(p_port_attr_1->p_pkey_table[0]))) \r
+ )\r
+\r
{\r
return FALSE;\r
}\r
case UAL_BIND_ND:\r
cl_status = proxy_bind_file( h_ioctl, AL_OBJ_TYPE_NDI );\r
break;\r
- case UAL_REQ_CREATE_PDO:\r
- cl_status = bus_add_pkey( h_ioctl);\r
- break;\r
default:\r
cl_status = CL_INVALID_PARAMETER;\r
break;\r
#include <iba/ib_al.h>\r
#include <iba/ib_al_ioctl.h>\r
#include "al_debug.h"\r
+#include "al.h"\r
#include "al_dev.h"\r
#include "al_proxy.h"\r
-\r
+#include "ib_common.h"\r
\r
cl_status_t\r
ioc_ioctl(\r
\r
switch( cl_ioctl_ctl_code( h_ioctl ) )\r
{\r
+ case UAL_REQ_CREATE_PDO:\r
+ {\r
+ cl_status = bus_add_pkey(h_ioctl);\r
+ break;\r
+ }\r
+\r
+ case UAL_REQ_REMOVE_PDO:\r
+ {\r
+ cl_status = bus_rem_pkey(h_ioctl);\r
+ break;\r
+ }\r
default:\r
cl_status = CL_INVALID_PARAMETER;\r
break;\r
#else\r
#define DEFAULT_NODE_DESC "OpenIB Windows® Host"\r
#endif\r
-/* pkey array to be read */\r
-pkey_array_t g_pkeys;\r
+\r
+\r
\r
char node_desc[IB_NODE_DESCRIPTION_SIZE];\r
\r
BUS_DBG_ERROR,\r
TRUE,\r
NULL,\r
- NULL\r
+ NULL,\r
+ NULL,\r
};\r
\r
static void\r
RtlStringCbCopyNA( node_desc, sizeof(node_desc),\r
DEFAULT_NODE_DESC, sizeof(DEFAULT_NODE_DESC) );\r
}\r
+ BUS_EXIT( BUS_DBG_DRV );\r
}\r
/************************************************************************************\r
* name : __prepare_pKey_array\r
* output: pkey_array\r
* return: uint16_t number of pkey(s) found\r
*************************************************************************************/\r
-static uint16_t __prepare_pKey_array(IN const UNICODE_STRING *str, OUT uint16_t *pkey_array)\r
+static void __prepare_pKey_array(IN const char *str, size_t str_len,OUT pkey_array_t *cur_pkey)\r
{\r
- uint16_t i, num_pKeys, cur_pkey_length;\r
NTSTATUS status;\r
- ANSI_STRING ansi_str;\r
- static const uint16_t PATTERN_LENGTH = 6;\r
+ size_t i;\r
+ uint8_t j;\r
+ char pkey_str[7];\r
+ ULONG tmp_val;\r
BUS_ENTER( BUS_DBG_DRV );\r
\r
- CL_ASSERT(pkey_array);\r
+ CL_ASSERT(cur_pkey);\r
CL_ASSERT(str);\r
\r
- num_pKeys = 0;\r
- cur_pkey_length = 0;\r
+ cur_pkey->pkey_num = 0;\r
+ j = 0;\r
\r
- status = RtlUnicodeStringToAnsiString(&ansi_str,str,TRUE);\r
- if(! NT_SUCCESS(status))\r
- {\r
- BUS_TRACE(BUS_DBG_ERROR ,\r
- ("RtlUnicodeStringToAnsiString returned 0x%.8x\n", status) );\r
- return 0;\r
- }\r
- \r
- for (i = 0; (i < ansi_str.MaximumLength) && (num_pKeys < MAX_NUM_PKEY) ; i++)\r
+ for (i = 0; (i < str_len) && (cur_pkey->pkey_num < MAX_NUM_PKEY) ; i++)\r
{\r
- switch(ansi_str.Buffer[i])\r
+ if(str[i] == ' ')\r
+ continue;\r
+\r
+ if( (str[i] != ',') && (str[i] != '\0'))\r
{\r
- case '0':\r
- cur_pkey_length++;\r
- if (((i+1) < ansi_str.Length) && ( ( ansi_str.Buffer[i+1] == 'x') || ( ansi_str.Buffer[i+1] == 'X')))\r
- break;\r
- else\r
+ if(j >= 7)\r
{\r
- pkey_array[num_pKeys] = \\r
- (pkey_array[num_pKeys] << 4)| 0;\r
+ BUS_TRACE(BUS_DBG_ERROR ,\r
+ ("Incorrect format of pkey value\n") );\r
break;\r
}\r
-\r
- case 'x':\r
- case 'X':\r
- cur_pkey_length++;\r
- break;\r
-\r
- case ',':\r
- if(cur_pkey_length == PATTERN_LENGTH)\r
+ pkey_str[j] = str[i];\r
+ j++;\r
+ }\r
+ else\r
+ {\r
+ pkey_str[j] = '\0';\r
+ status = RtlCharToInteger(&pkey_str[2],16,&tmp_val);\r
+ if(! NT_SUCCESS(status))\r
{\r
- cur_pkey_length = 0;\r
- num_pKeys++;\r
+ BUS_TRACE(BUS_DBG_ERROR ,\r
+ ("Failed to convert, status = 0x%08X\n",status) );\r
+ break; \r
}\r
- break;\r
-\r
- case 'A':\r
- case 'a':\r
- pkey_array[num_pKeys] = \\r
- (pkey_array[num_pKeys] << 4)| 0xA;\r
- cur_pkey_length++;\r
- break;\r
-\r
- case 'B':\r
- case 'b':\r
- pkey_array[num_pKeys] = \\r
- (pkey_array[num_pKeys] << 4)| 0xB;\r
- cur_pkey_length++;\r
- break;\r
-\r
- case 'C':\r
- case 'c':\r
- pkey_array[num_pKeys] = \\r
- (pkey_array[num_pKeys] << 4)| 0xC;\r
- cur_pkey_length++;\r
- break;\r
-\r
- case 'D':\r
- case 'd':\r
- pkey_array[num_pKeys] = \\r
- (pkey_array[num_pKeys] << 4)| 0xD;\r
- cur_pkey_length++;\r
- break;\r
-\r
- case 'E':\r
- case 'e':\r
- pkey_array[num_pKeys] = \\r
- (pkey_array[num_pKeys] << 4)| 0xE;\r
- cur_pkey_length++;\r
- break;\r
-\r
- case 'F':\r
- case 'f':\r
- pkey_array[num_pKeys] = \\r
- (pkey_array[num_pKeys] << 4)| 0xF;\r
- cur_pkey_length++;\r
- break;\r
-\r
- case '1':\r
- case '2':\r
- case '3':\r
- case '4':\r
- case '5':\r
- case '6':\r
- case '7':\r
- case '8':\r
- case '9':\r
- pkey_array[num_pKeys] = \\r
- (pkey_array[num_pKeys] << 4)| (ansi_str.Buffer[i] - '0');\r
- cur_pkey_length++;\r
- break;\r
- \r
- case '\0':\r
- if(cur_pkey_length == PATTERN_LENGTH)\r
+ cur_pkey->pkey_array[cur_pkey->pkey_num++] = (uint16_t)tmp_val;\r
+ j = 0;\r
+ }\r
+ }\r
+ BUS_EXIT( BUS_DBG_DRV );\r
+}\r
+\r
+static pkey_conf_t*\r
+create_pkey_conf(pkey_conf_t **pp_cur_conf, char *guid_str, uint32_t guid_str_len)\r
+{\r
+ NTSTATUS status;\r
+ char tmp_char;\r
+ uint32_t tmp_val;\r
+\r
+ if (! *pp_cur_conf)\r
+ pp_cur_conf = &bus_globals.p_pkey_conf;\r
+ else\r
+ pp_cur_conf = &((*pp_cur_conf)->next_conf);\r
+\r
+ *pp_cur_conf = cl_zalloc( sizeof( pkey_conf_t ) );\r
+ if (!(*pp_cur_conf) )\r
+ {\r
+ BUS_TRACE(BUS_DBG_ERROR ,\r
+ ("Failed to allocate pkey configuration\n") );\r
+ return NULL; \r
+ }\r
+\r
+ tmp_char = guid_str[1 + guid_str_len/2];\r
+ guid_str[1 + guid_str_len/2] = '\0';\r
+ status = RtlCharToInteger(&guid_str[2],16,(PULONG)&tmp_val);\r
+ if(! NT_SUCCESS(status))\r
+ {\r
+ cl_free((*pp_cur_conf));\r
+ (*pp_cur_conf) = NULL;\r
+ BUS_TRACE(BUS_DBG_ERROR ,\r
+ ("Failed to convert, status = 0x%08X\n",status) );\r
+ return NULL; \r
+ }\r
+ guid_str[1 + guid_str_len/2] = tmp_char;\r
+ (*pp_cur_conf)->pkeys_per_port.port_guid = tmp_val;\r
+\r
+ status = RtlCharToInteger(&guid_str[1 + guid_str_len/2],16,(PULONG)&tmp_val);\r
+ if(! NT_SUCCESS(status))\r
+ {\r
+ cl_free((*pp_cur_conf));\r
+ (*pp_cur_conf) = NULL;\r
+ BUS_TRACE(BUS_DBG_ERROR ,\r
+ ("Failed to convert, status = 0x%08X\n",status) );\r
+ return NULL; \r
+ }\r
+ (*pp_cur_conf)->pkeys_per_port.port_guid = ((*pp_cur_conf)->pkeys_per_port.port_guid << 32) | tmp_val;\r
+ return (*pp_cur_conf);\r
+}\r
+\r
+/************************************************************************\r
+* name: __build_pkeys_per_port\r
+* extracts pkeys and port guids from registry string.\r
+* builds pkey array per port\r
+* input: UNICODE_STRING *str\r
+* return: NTSTATUS\r
+************************************************************************/\r
+static NTSTATUS\r
+__build_pkeys_per_port(IN const UNICODE_STRING *str)\r
+{\r
+ NTSTATUS status;\r
+ ANSI_STRING ansi_str;\r
+ uint32_t i,j;\r
+ char *p_end, *p_start;\r
+ boolean_t port_guid_found;\r
+ pkey_conf_t *cur_pkey_conf = NULL;\r
+ char tmp_guid[32] = {'\0'};\r
+ p_start = NULL;\r
+\r
+ status = RtlUnicodeStringToAnsiString(&ansi_str,str,TRUE);\r
+ if(! NT_SUCCESS(status))\r
+ {\r
+ BUS_TRACE(BUS_DBG_ERROR ,\r
+ ("RtlUnicodeStringToAnsiString returned 0x%.8x\n", status) );\r
+ return status;\r
+ }\r
+\r
+ port_guid_found = FALSE;\r
+ j = 0;\r
+ for ( i = 0; i < ansi_str.MaximumLength; i++)\r
+ {\r
+ if(! port_guid_found)\r
+ {\r
+ if(ansi_str.Buffer[i] == ':')\r
{\r
- cur_pkey_length = 0;\r
- num_pKeys++;\r
+ port_guid_found = TRUE;\r
+ tmp_guid[j] = '\0';\r
+ cur_pkey_conf = create_pkey_conf(&cur_pkey_conf,(char*)tmp_guid,j);\r
+ if(! cur_pkey_conf)\r
+ {\r
+ RtlFreeAnsiString(&ansi_str);\r
+ BUS_TRACE(BUS_DBG_ERROR ,\r
+ ("Failed to create pkey configuration\n"));\r
+ return STATUS_INVALID_PARAMETER;\r
+ }\r
+ RtlZeroMemory(tmp_guid,sizeof(tmp_guid));\r
+ j = 0;\r
+ p_start = NULL;\r
}\r
else\r
{\r
- RtlFreeAnsiString(&ansi_str);\r
- return num_pKeys;\r
+ tmp_guid[j] = ansi_str.Buffer[i]; \r
+ j++;\r
+ continue;\r
}\r
- break;\r
+ }\r
+ else\r
+ {\r
+ if(!p_start)\r
+ p_start = &ansi_str.Buffer[i]; \r
\r
- default:\r
- break;\r
+ if(ansi_str.Buffer[i] == ';')\r
+ {\r
+ p_end = &ansi_str.Buffer[i];\r
+ ansi_str.Buffer[i] = '\0';\r
+ __prepare_pKey_array(p_start,(size_t)(p_end - p_start) + 1,&cur_pkey_conf->pkeys_per_port);\r
\r
+ ansi_str.Buffer[i] = ';';\r
+ p_start = NULL;\r
+ port_guid_found = FALSE;\r
+ }\r
}\r
}\r
-\r
RtlFreeAnsiString(&ansi_str);\r
- BUS_EXIT( BUS_DBG_DRV );\r
- return num_pKeys;\r
+ return STATUS_SUCCESS;\r
}\r
static NTSTATUS\r
__read_registry(\r
{\r
NTSTATUS status;\r
/* Remember the terminating entry in the table below. */\r
- RTL_QUERY_REGISTRY_TABLE table[10];\r
+ RTL_QUERY_REGISTRY_TABLE table[12];\r
UNICODE_STRING param_path;\r
UNICODE_STRING pkeyString;\r
UNICODE_STRING empty_string;\r
return STATUS_INSUFFICIENT_RESOURCES;\r
}\r
\r
- cl_memclr(&g_pkeys,sizeof(pkey_array_t));\r
-\r
/*\r
* Clear the table. This clears all the query callback pointers,\r
* and sets up the terminating table entry.\r
table[8].DefaultType = REG_SZ;\r
table[8].DefaultData = &empty_string;\r
table[8].DefaultLength = 0;\r
+\r
/* Have at it! */\r
status = RtlQueryRegistryValues( RTL_REGISTRY_ABSOLUTE, \r
param_path.Buffer, table, NULL, NULL );\r
if (NT_SUCCESS(status))\r
- g_pkeys.pkey_num = __prepare_pKey_array(&pkeyString, (uint16_t*)g_pkeys.pkey_array);\r
+ {\r
+ if( !NT_SUCCESS(__build_pkeys_per_port(&pkeyString)))\r
+ BUS_TRACE(BUS_DBG_ERROR ,\r
+ ("Failed to build pkey configuration\n"));\r
+ }\r
#if DBG\r
if( g_al_dbg_flags & AL_DBG_ERR )\r
g_al_dbg_flags |= CL_DBG_ERROR;\r
return status;\r
}\r
\r
+cl_status_t\r
+bus_rem_pkey(cl_ioctl_handle_t h_ioctl)\r
+{\r
+ cl_status_t status;\r
+ pkey_array_t *pkeys;\r
+ PIO_STACK_LOCATION pIoStack;\r
+\r
+ BUS_ENTER( BUS_DBG_DRV );\r
+\r
+ pIoStack = IoGetCurrentIrpStackLocation(h_ioctl);\r
+ if ( (! h_ioctl->AssociatedIrp.SystemBuffer) || \r
+ pIoStack->Parameters.DeviceIoControl.InputBufferLength < sizeof (pkey_array_t))\r
+ {\r
+ BUS_TRACE_EXIT( BUS_DBG_ERROR, \r
+ ("Invalid parameters.\n") );\r
+ return CL_INVALID_PARAMETER;\r
+ }\r
+\r
+ pkeys = (pkey_array_t*)h_ioctl->AssociatedIrp.SystemBuffer;\r
+\r
+ /* removes pdo */\r
+ status = port_mgr_pkey_rem(pkeys);\r
+ if (! NT_SUCCESS(status))\r
+ {\r
+ BUS_TRACE_EXIT( BUS_DBG_ERROR, \r
+ ("port_mgr_pkey_rem returned %08x.\n", status) );\r
+ }\r
+\r
+ BUS_EXIT( BUS_DBG_DRV );\r
+ return status;\r
+}\r
static NTSTATUS\r
bus_drv_sysctl(\r
IN DEVICE_OBJECT *p_dev_obj,\r
bus_drv_unload(\r
IN DRIVER_OBJECT *p_driver_obj )\r
{\r
+ pkey_conf_t *cur_conf,*tmp;\r
UNICODE_STRING dos_name;\r
- UNUSED_PARAM( p_driver_obj );\r
\r
BUS_ENTER( BUS_DBG_DRV );\r
\r
RtlInitUnicodeString( &dos_name, L"\\DosDevices\\Global\\ibal" );\r
+ UNUSED_PARAM( p_driver_obj );\r
IoDeleteSymbolicLink( &dos_name );\r
-\r
+ cur_conf = bus_globals.p_pkey_conf;\r
+ while(cur_conf)\r
+ {\r
+ tmp = cur_conf;\r
+ cur_conf = cur_conf->next_conf;\r
+ cl_free(tmp);\r
+ }\r
CL_DEINIT;\r
\r
#if defined(EVENT_TRACING)\r
#include "iba/ib_al.h"\r
#include "bus_port_mgr.h"\r
#include "bus_iou_mgr.h"\r
-\r
+#include "al_dev.h"\r
/* Safe string functions. */\r
#if WINVER == 0x500\r
/*\r
\r
/* work item for handling Power Management request */\r
PIO_WORKITEM p_po_work_item;\r
- \r
+ boolean_t is_partition_pdo;\r
} bus_pdo_ext_t;\r
\r
+/* pkey configuration */\r
+typedef struct _pkey_conf_t\r
+{\r
+ pkey_array_t pkeys_per_port;\r
+ struct _pkey_conf_t *next_conf;\r
+}pkey_conf_t;\r
\r
/*\r
* Global Driver parameters.\r
/* Pointer to the one and only bus root. */\r
bus_fdo_ext_t *p_bus_ext;\r
\r
+ /* pkey array to be read */\r
+ pkey_conf_t *p_pkey_conf;\r
} bus_globals_t;\r
\r
\r
IN IRP* const p_irp );\r
\r
NTSTATUS port_mgr_pkey_add();\r
+NTSTATUS port_mgr_pkey_rem();\r
#endif // !defined _BUS_DRV_PNP_H_\r
#include "iba/ipoib_ifc.h"\r
#include "al_dev.h"\r
\r
+#define IPOIB_PART_DEVICE_ID L"IBA\\IPoIBP"\r
#define IPOIB_DEVICE_ID L"IBA\\IPoIB"\r
#define IPOIB_COMPAT_ID L"IBA\\SID_1000066a00020000\0\0"\r
/* Hardware ID is a MULTI_SZ, so is terminated with a double NULL. */\r
#define IPOIB_HARDWARE_ID IPOIB_DEVICE_ID L"\0"\r
+#define IPOIB_PART_HARDWARE_ID IPOIB_PART_DEVICE_ID L"\0"\r
#define IPOIB_DESCRIPTION L"OpenIB IPoIB Adapter"\r
\r
/* {5A9649F4-0101-4a7c-8337-796C48082DA2} */\r
{\r
bus_pdo_ext_t pdo;\r
\r
- port_guid_pkey port_guid;\r
+ port_guid_pkey_t port_guid;\r
uint32_t n_port;\r
\r
/* Number of references on the upper interface. */\r
\r
port_mgr_t* gp_port_mgr = NULL;\r
\r
-extern pkey_array_t g_pkeys;\r
-\r
-static boolean_t pkeys_enumerated = FALSE;\r
/*\r
* Function prototypes.\r
*/\r
p_ext->cl_ext.vfptr_pnp_po->identity, p_ext->cl_ext.p_self_do, p_ext, p_ext->b_present, p_ext->b_reported_missing ) );\r
continue;\r
}\r
- if( p_ext->h_ca )\r
+ if( p_ext->h_ca && (!p_ext->is_partition_pdo))\r
{\r
/* Invalidate bus relations for the HCA. */\r
IoInvalidateDeviceRelations(\r
return status;\r
}\r
\r
+\r
ib_api_status_t\r
port_mgr_port_add(\r
IN ib_pnp_port_rec_t* p_pnp_rec )\r
uint8_t num_pdo;\r
bus_port_ext_t *p_port_ext;\r
ib_net16_t pdo_cnt;\r
+ pkey_conf_t *cur_conf; \r
+ pkey_array_t *cur_pkeys = NULL;\r
BUS_ENTER( BUS_DBG_PNP );\r
\r
if( !bus_globals.b_report_port_nic )\r
return status;\r
}\r
\r
+ cur_conf = bus_globals.p_pkey_conf;\r
+ while(cur_conf)\r
+ {\r
+ if(p_pnp_rec->p_port_attr->port_guid == cur_conf->pkeys_per_port.port_guid)\r
+ {\r
+ cur_pkeys = &cur_conf->pkeys_per_port;\r
+ break;\r
+ }\r
+ cur_conf = cur_conf->next_conf;\r
+ }\r
p_port_ext = NULL;\r
\r
- if( pkeys_enumerated)\r
+ if( !cur_pkeys)\r
pdo_cnt = 1;\r
else\r
- pdo_cnt = g_pkeys.pkey_num + 1;\r
+ pdo_cnt = cur_conf->pkeys_per_port.pkey_num + 1;\r
\r
for (num_pdo = 0; num_pdo < pdo_cnt; num_pdo++)\r
{\r
if(num_pdo > 0)\r
{\r
p_port_ext->pdo.h_ca = ((bus_port_ext_t*)p_pdo[0]->DeviceExtension)->pdo.h_ca;\r
+ p_port_ext->pdo.is_partition_pdo = TRUE;\r
}\r
else\r
p_port_ext->pdo.h_ca = acquire_ca( p_pnp_rec->p_ca_attr->ca_guid );\r
p_port_ext->port_guid.pkey = IB_DEFAULT_PKEY;\r
\r
if(num_pdo > 0)\r
- {\r
- p_port_ext->port_guid.pkey = g_pkeys.pkey_array[num_pdo -1];\r
- }\r
+ p_port_ext->port_guid.pkey = cur_pkeys->pkey_array[num_pdo -1];\r
+\r
/* Store the device extension in the port vector for future queries. */\r
cl_mutex_acquire( &gp_port_mgr->pdo_mutex );\r
cl_qlist_insert_tail( &gp_port_mgr->port_list,\r
if(num_pdo == 0)\r
p_pnp_rec->pnp_rec.context = p_port_ext;\r
}\r
- pkeys_enumerated = TRUE;\r
\r
/* Tell the PnP Manager to rescan for the HCA's bus relations. */\r
IoInvalidateDeviceRelations(\r
return IB_SUCCESS;\r
}\r
\r
+/************************************************************************************\r
+* name : port_mgr_pkey_rem\r
+* removes pdo for each pkey value in pkey_array \r
+* input : g_pkeys\r
+* output: none\r
+* return: cl_status\r
+*************************************************************************************/\r
+cl_status_t port_mgr_pkey_rem(pkey_array_t *pkeys)\r
+{\r
+\r
+ uint16_t cnt;\r
+ cl_list_item_t *p_list_item;\r
+ bus_port_ext_t *p_port_ext;\r
+ bus_pdo_ext_t *p_pdo_ext = NULL;\r
+ cl_qlist_t* p_pdo_list = &gp_port_mgr->port_list;\r
+\r
+ BUS_ENTER( BUS_DBG_PNP );\r
+\r
+ p_port_ext = NULL;\r
+ cl_mutex_acquire( &gp_port_mgr->pdo_mutex );\r
+ \r
+ /* Count the number of child devices. */\r
+ for( p_list_item = cl_qlist_head( p_pdo_list );\r
+ p_list_item != cl_qlist_end( p_pdo_list );\r
+ p_list_item = cl_qlist_next( p_list_item ) )\r
+ {\r
+ p_pdo_ext = PARENT_STRUCT( p_list_item, bus_pdo_ext_t, list_item );\r
+ p_port_ext = (bus_port_ext_t*)p_pdo_ext;\r
+\r
+ if(p_port_ext->port_guid.guid == pkeys->port_guid)\r
+ {\r
+ for(cnt = 0; cnt < pkeys->pkey_num; cnt++)\r
+ {\r
+ if( (p_port_ext->port_guid.pkey == pkeys->pkey_array[cnt]) &&\r
+ (p_port_ext->port_guid.pkey != IB_DEFAULT_PKEY))\r
+ {\r
+ p_port_ext->pdo.b_present = FALSE;\r
+ break;\r
+ }\r
+ }\r
+ }\r
+ }\r
+ cl_mutex_release( &gp_port_mgr->pdo_mutex );\r
+\r
+ /* Tell the PnP Manager to rescan for the HCA's bus relations. */\r
+ IoInvalidateDeviceRelations(\r
+ p_port_ext->pdo.h_ca->obj.p_ci_ca->verbs.p_hca_dev, BusRelations );\r
+\r
+ /* Invalidate removal relations for the bus driver. */\r
+ IoInvalidateDeviceRelations(\r
+ bus_globals.p_bus_ext->cl_ext.p_pdo, RemovalRelations );\r
+\r
+ BUS_EXIT( BUS_DBG_PNP );\r
+ return CL_SUCCESS;\r
+}\r
/************************************************************************************\r
* name : port_mgr_pkey_add\r
* creates pdo for each pkey value in pkey_array \r
* output: none\r
* return: cl_status\r
*************************************************************************************/\r
-cl_status_t port_mgr_pkey_add(pkey_array_t *pkeys)\r
+cl_status_t port_mgr_pkey_add(pkey_array_t *req_pkeys)\r
{\r
uint16_t cnt;\r
NTSTATUS status;\r
cl_list_item_t *p_list_item;\r
- bus_port_ext_t *p_port_ext, *pkey_port_ext;\r
+ bus_port_ext_t *p_port_ext, *pkey_port_ext, *pmatched_guid_ext;\r
DEVICE_OBJECT *p_pdo[MAX_NUM_PKEY];\r
- bus_pdo_ext_t *p_pdo_ext = NULL;\r
cl_qlist_t* p_pdo_list = &gp_port_mgr->port_list;\r
\r
BUS_ENTER( BUS_DBG_PNP );\r
\r
+ pmatched_guid_ext = NULL;\r
p_port_ext = NULL;\r
cl_mutex_acquire( &gp_port_mgr->pdo_mutex );\r
\r
p_list_item != cl_qlist_end( p_pdo_list );\r
p_list_item = cl_qlist_next( p_list_item ) )\r
{\r
- p_pdo_ext = PARENT_STRUCT( p_list_item, bus_pdo_ext_t, list_item );\r
- p_port_ext = (bus_port_ext_t*)p_pdo_ext;\r
+ p_port_ext = (bus_port_ext_t*)PARENT_STRUCT( p_list_item, bus_pdo_ext_t, list_item );\r
\r
- if(p_port_ext->port_guid.pkey != IB_DEFAULT_PKEY)\r
- break;\r
+ if(p_port_ext->port_guid.guid == req_pkeys->port_guid)\r
+ {\r
+ uint16_t i;\r
+ for(i = 0; i < req_pkeys->pkey_num; i++)\r
+ {\r
+ if(p_port_ext->port_guid.pkey == req_pkeys->pkey_array[i])\r
+ {\r
+ /* was removed previously */\r
+ p_port_ext->pdo.b_present = TRUE;\r
+ p_port_ext->pdo.b_reported_missing = FALSE;\r
+ req_pkeys->pkey_array[i] = 0; \r
+ }\r
+ }\r
+ if(!pmatched_guid_ext)\r
+ pmatched_guid_ext = p_port_ext;\r
+ }\r
}\r
cl_mutex_release( &gp_port_mgr->pdo_mutex );\r
\r
- if (!p_port_ext)\r
+ if (!pmatched_guid_ext)\r
{\r
BUS_TRACE_EXIT( BUS_DBG_ERROR,\r
("No existed pdo found.\n") );\r
- return CL_ERROR;\r
+ return CL_NOT_FOUND;\r
}\r
\r
- for (cnt = 0; cnt < pkeys->pkey_num; cnt++)\r
+ for (cnt = 0; cnt < req_pkeys->pkey_num; cnt++)\r
{\r
+ if(! (cl_hton16(req_pkeys->pkey_array[cnt]) & IB_PKEY_BASE_MASK) )\r
+ continue;\r
\r
/* Create the PDO for the new port device. */\r
status = IoCreateDevice( bus_globals.p_driver_obj, sizeof(bus_port_ext_t),\r
pkey_port_ext->pdo.b_reported_missing ) );\r
\r
/* Cache the CA GUID. */\r
- pkey_port_ext->pdo.ca_guid = p_port_ext->pdo.ca_guid;\r
- pkey_port_ext->pdo.h_ca = p_port_ext->pdo.h_ca;\r
- pkey_port_ext->port_guid.guid = p_port_ext->port_guid.guid;\r
- pkey_port_ext->n_port = p_port_ext->n_port;\r
- pkey_port_ext->port_guid.pkey = pkeys->pkey_array[cnt];\r
-\r
+ pkey_port_ext->pdo.ca_guid = pmatched_guid_ext->pdo.ca_guid;\r
+ pkey_port_ext->pdo.h_ca = pmatched_guid_ext->pdo.h_ca;\r
+ pkey_port_ext->port_guid.guid = pmatched_guid_ext->port_guid.guid;\r
+ pkey_port_ext->n_port = pmatched_guid_ext->n_port;\r
+ pkey_port_ext->port_guid.pkey = req_pkeys->pkey_array[cnt];\r
+ pkey_port_ext->pdo.is_partition_pdo = TRUE;\r
/* Store the device extension in the port vector for future queries. */\r
cl_mutex_acquire( &gp_port_mgr->pdo_mutex );\r
cl_qlist_insert_tail( &gp_port_mgr->port_list,\r
\r
/* Tell the PnP Manager to rescan for the HCA's bus relations. */\r
IoInvalidateDeviceRelations(\r
- p_port_ext->pdo.h_ca->obj.p_ci_ca->verbs.p_hca_dev, BusRelations );\r
+ pmatched_guid_ext->pdo.h_ca->obj.p_ci_ca->verbs.p_hca_dev, BusRelations );\r
\r
/* Invalidate removal relations for the bus driver. */\r
IoInvalidateDeviceRelations(\r
{\r
WCHAR *p_string;\r
bus_port_ext_t *p_ext;\r
+ size_t dev_id_size;\r
\r
BUS_ENTER( BUS_DBG_PNP );\r
\r
BUS_TRACE_EXIT( BUS_DBG_ERROR, ("Device not present.\n") );\r
return STATUS_NO_SUCH_DEVICE;\r
}\r
-\r
+ if(p_ext->port_guid.pkey == IB_DEFAULT_PKEY)\r
+ dev_id_size = sizeof(IPOIB_DEVICE_ID);\r
+ else\r
+ dev_id_size = sizeof(IPOIB_PART_DEVICE_ID );\r
/* Device ID is "IBA\SID_<sid> where <sid> is the IPoIB Service ID. */\r
- p_string = ExAllocatePoolWithTag( PagedPool, sizeof(IPOIB_DEVICE_ID), 'vedq' );\r
+ p_string = ExAllocatePoolWithTag( PagedPool, dev_id_size, 'vedq' );\r
if( !p_string )\r
{\r
BUS_TRACE_EXIT( BUS_DBG_ERROR,\r
("Failed to allocate device ID buffer (%d bytes).\n",\r
- sizeof(IPOIB_DEVICE_ID)) );\r
+ dev_id_size) );\r
return STATUS_INSUFFICIENT_RESOURCES;\r
}\r
- cl_memcpy( p_string, IPOIB_DEVICE_ID, sizeof(IPOIB_DEVICE_ID) );\r
+\r
+ if(p_ext->port_guid.pkey == IB_DEFAULT_PKEY)\r
+ cl_memcpy( p_string, IPOIB_DEVICE_ID, sizeof(IPOIB_DEVICE_ID) );\r
+ else\r
+ cl_memcpy( p_string, IPOIB_PART_DEVICE_ID, sizeof(IPOIB_PART_DEVICE_ID) );\r
p_irp->IoStatus.Information = (ULONG_PTR)p_string;\r
\r
BUS_EXIT( BUS_DBG_PNP );\r
{\r
WCHAR *p_string;\r
bus_port_ext_t *p_ext;\r
+ size_t dev_id_size;\r
\r
BUS_ENTER( BUS_DBG_PNP );\r
\r
\r
p_ext = (bus_port_ext_t*)p_dev_obj->DeviceExtension;\r
- if( !p_ext->pdo.b_present )\r
- {\r
- BUS_TRACE_EXIT( BUS_DBG_ERROR, ("Device not present.\n") );\r
- return STATUS_NO_SUCH_DEVICE;\r
- }\r
\r
- p_string = ExAllocatePoolWithTag( PagedPool, sizeof(IPOIB_HARDWARE_ID), 'ihqp' );\r
+ if(p_ext->port_guid.pkey == IB_DEFAULT_PKEY)\r
+ dev_id_size = sizeof(IPOIB_HARDWARE_ID);\r
+ else\r
+ dev_id_size = sizeof(IPOIB_PART_HARDWARE_ID );\r
+\r
+ p_string = ExAllocatePoolWithTag( PagedPool, dev_id_size, 'ihqp' );\r
if( !p_string )\r
{\r
BUS_TRACE_EXIT( BUS_DBG_ERROR,\r
("Failed to allocate hardware ID buffer (%d bytes).\n",\r
- sizeof(IPOIB_HARDWARE_ID)) );\r
+ dev_id_size) );\r
return STATUS_INSUFFICIENT_RESOURCES;\r
}\r
- cl_memcpy( p_string, IPOIB_HARDWARE_ID, sizeof(IPOIB_HARDWARE_ID) );\r
+ if(p_ext->port_guid.pkey == IB_DEFAULT_PKEY)\r
+ cl_memcpy( p_string, IPOIB_HARDWARE_ID, sizeof(IPOIB_HARDWARE_ID) );\r
+ else\r
+ cl_memcpy( p_string, IPOIB_PART_HARDWARE_ID, sizeof(IPOIB_PART_HARDWARE_ID) );\r
p_irp->IoStatus.Information = (ULONG_PTR)p_string;\r
\r
BUS_EXIT( BUS_DBG_PNP );\r
// allocate work item
work->work_item = IoAllocateWorkItem(pdo);
if (work->work_item == NULL) {
- //TODO: at least - print error. Need to return code, but the function is void
+ HCA_PRINT(TRACE_LEVEL_ERROR ,HCA_DBG_LOW,("Failed to allocate workitem for cache update.\n"));
}
else { // schedule the work
IoQueueWorkItem(
}
}
+ else
+ {
+ HCA_PRINT(TRACE_LEVEL_ERROR ,HCA_DBG_MEMORY,("Failed to memory for workitem.\n"));
+ }
}
}
{\r
net64_t guid;\r
ib_net16_t pkey;\r
-} port_guid_pkey;\r
+} port_guid_pkey_t;\r
\r
\r
/*\r
typedef struct _ipoib_ifc_data\r
{\r
net64_t ca_guid;\r
- port_guid_pkey port_guid;\r
+ port_guid_pkey_t port_guid;\r
uint8_t port_num;\r
\r
} ipoib_ifc_data_t;\r
+\r
#include "stdio.h"\r
#include "string.h"\r
#include "stdlib.h"\r
#include <windows.h>\r
-\r
#include <iba/ib_types.h>\r
#include <iba/ib_al.h>\r
#include "al_dev.h"\r
\r
+\r
typedef enum\r
{\r
pkey_show = 0,\r
{\r
struct\r
{\r
+ net64_t port_guid;\r
unsigned short pkey_num;\r
unsigned __int16 pkeys[MAX_NUM_PKEY];\r
Pkey_action action;\r
\r
void show_help()\r
{\r
- printf("Usage : part_man.exe <show|add|rem> <pkey1 pkey2 ...>\n");\r
+ printf("Usage : part_man.exe <show|add|rem> <port_guid> <pkey1, pkey2, ...>\n");\r
}\r
\r
/********************************************************************\r
return retval;\r
}\r
\r
-static boolean_t reg_ibbus_print_pkey()\r
+static int reg_ibbus_print_pkey()\r
{\r
int result;\r
char pkeyBuf[DEFAULT_BUFER_SIZE];\r
if (result < 4)\r
{\r
printf("No configured pkey found\n");\r
- return FALSE;\r
+ return 1;\r
}\r
- return TRUE;\r
+ return 0;\r
}\r
\r
-static int reg_ibbus_pkey_add(const uint16_t *pkeys, uint16_t pkey_num,OUT pkey_array_t *pkey)\r
+static int reg_ibbus_pkey_add(const uint16_t *pkeys, uint16_t pkey_num,OUT pkey_array_t *pkey, OUT char **final_reg_string, OUT DWORD *reg_length)\r
{\r
- char partKey[DEFAULT_BUFER_SIZE];\r
- char tmp[10];\r
+ static char partKey[DEFAULT_BUFER_SIZE];\r
+ char tmp[20];\r
+ char *guid_string, *p;\r
HKEY reg_handle;\r
LONG ret;\r
+ char *tmpbuff = NULL;\r
int cnt;\r
int retval = 0;\r
uint16_t i = 0;\r
DWORD read_length;\r
\r
+ *final_reg_string = NULL;\r
read_length = reg_ibbus_pkey_show(FALSE,(char*)partKey,®_handle);\r
-\r
+ p = NULL;\r
+ guid_string = NULL;\r
if (read_length < 4)\r
{\r
/* empty string read, simply write to registry */\r
- cnt = sprintf(partKey,"0x%04X",pkeys[0]);\r
- pkey->pkey_array[pkey->pkey_num] = pkeys[0];\r
- pkey->pkey_num++;\r
- i = 1;\r
+ cnt = sprintf(partKey,"0x%I64X:",pkey->port_guid);\r
}\r
else\r
{\r
/* update the existed registry list */\r
- cnt = (int)strlen(partKey);\r
- i = 0;\r
+ sprintf(tmp,"0x%I64X",pkey->port_guid);\r
+ guid_string = strstr(partKey,tmp);\r
+ if(guid_string)\r
+ {\r
+ p = strstr(guid_string,";");\r
+ tmpbuff = (char*)malloc(strlen(p) + 1);\r
+ if(!tmpbuff)\r
+ {\r
+ printf("Failed memory allocation\n");\r
+ return 1;\r
+ }\r
+ /* save the rest of the string */\r
+ strcpy(tmpbuff,p);\r
+ cnt = (int)(p - partKey);\r
+ }\r
+ else\r
+ {\r
+ cnt = strlen(partKey) + sprintf(partKey + strlen(partKey),"%s:",tmp);\r
+ }\r
} \r
\r
- for ( ;i < pkey_num; i++)\r
+ for (i = 0 ;i < pkey_num; i++)\r
{\r
+ char *same_pkey;\r
sprintf(tmp,"0x%04X",pkeys[i]);\r
- if (strstr(partKey,tmp))\r
+ if ( guid_string )\r
{\r
- continue;\r
+ same_pkey = strstr(guid_string,tmp);\r
+ if( same_pkey && (same_pkey < p) )\r
+ continue;\r
}\r
pkey->pkey_array[pkey->pkey_num] = pkeys[i];\r
pkey->pkey_num++;\r
- cnt += sprintf(partKey + cnt,",0x%04X",pkeys[i]);\r
+ if( (i == 0) && (!guid_string))\r
+ cnt += sprintf(partKey + cnt,"0x%04X",pkeys[i]);\r
+ else\r
+ cnt += sprintf(partKey + cnt,",0x%04X",pkeys[i]);\r
}\r
- cnt += sprintf(partKey + cnt,"\0");\r
+ if(tmpbuff)\r
+ {\r
+ cnt += sprintf(partKey + cnt,"%s",tmpbuff);\r
+ free(tmpbuff);\r
+ }\r
+ else\r
+ cnt += sprintf(partKey + cnt,";\0");\r
\r
if(pkey->pkey_num)\r
- {\r
- ret = RegSetValueEx(reg_handle,"PartitionKey",0,REG_SZ,(BYTE*)partKey, (DWORD)cnt);\r
- if (ERROR_SUCCESS != ret)\r
- {\r
- printf("reg_ibbus_pkey_add RegSetValueEx error = %d\n",GetLastError());\r
- retval = 1;\r
- }\r
+ { \r
+ *final_reg_string = partKey;\r
+ *reg_length = (DWORD)cnt;\r
}\r
else\r
+ {\r
printf("No pkey to add\n");\r
+ retval = 1;\r
+ }\r
RegCloseKey( reg_handle );\r
return retval;\r
}\r
\r
static int reg_ibbus_pkey_rem(const unsigned __int16 *pkeys, unsigned short pkey_num,OUT pkey_array_t *pkey)\r
{\r
- char partKey[DEFAULT_BUFER_SIZE];\r
- char newKey[DEFAULT_BUFER_SIZE] = {'\0'};\r
+ static char partKey[DEFAULT_BUFER_SIZE];\r
+ static char newKey[DEFAULT_BUFER_SIZE] = {'\0'};\r
\r
HKEY reg_handle;\r
LONG ret;\r
unsigned __int16 cur_pkey;\r
int retval = 0;\r
unsigned short i = 0;\r
- char seps[] = ",";\r
+ char pkey_sep[] = ",";\r
+ char *pfrom, *pto;\r
+ char *guid_string;\r
+ char tmp[20];\r
char *token;\r
+ char *pafter = NULL;\r
boolean_t found2remove;\r
+ boolean_t pkey_not_written = TRUE;\r
\r
read_length = reg_ibbus_pkey_show(FALSE,(char*)partKey,®_handle);\r
do\r
break;\r
}\r
\r
- token = strtok(partKey,seps);\r
- cnt = 0;\r
+ sprintf(tmp,"0x%I64X\0",pkey->port_guid);\r
+ guid_string = strstr(partKey,tmp);\r
+ if (! guid_string)\r
+ {\r
+ printf("No guid configured - nothing to remove\n");\r
+ retval = 1;\r
+ break;\r
+ }\r
+ pfrom = strstr(guid_string,":");\r
+ pto = strstr(guid_string,";");\r
+ if ( (!pfrom) || (!pto))\r
+ {\r
+ printf("Error configuration\n");\r
+ retval = 1;\r
+ break;\r
+ }\r
+\r
+ pfrom++;\r
+ pafter = (char*)malloc(strlen(pto) + 1);\r
+\r
+ if(!pafter)\r
+ {\r
+ printf("Allocation failed\n");\r
+ retval = 1;\r
+ break;\r
+ }\r
+ _snprintf(newKey,(int)(pfrom - partKey),"%s",partKey);\r
+ cnt = (int)(pfrom - partKey);\r
+ strcpy(pafter,pto);\r
+ pto[0] = '\0';\r
+ strcpy(partKey,pfrom);\r
+ token = strtok(partKey,pkey_sep);\r
while(token)\r
{\r
found2remove = FALSE;\r
converted = sscanf(token,"0x%X",&cur_pkey);\r
- if(! converted || (converted == EOF))\r
+ if(!converted || (converted == EOF))\r
{\r
printf("invalid registry format\n");\r
retval = 1;\r
break;\r
}\r
+\r
for (i = 0; i < pkey_num; i++)\r
{\r
found2remove = (boolean_t)(cur_pkey == pkeys[i]);\r
if(found2remove)\r
+ {\r
+ pkey->pkey_array[pkey->pkey_num] = pkeys[i];\r
break;\r
+ }\r
}\r
\r
if(found2remove)\r
}\r
else\r
{\r
- if(!cnt)\r
+ if(pkey_not_written)\r
+ {\r
cnt += sprintf(newKey + cnt,"0x%04X",cur_pkey);\r
+ pkey_not_written = FALSE;\r
+ }\r
else\r
cnt += sprintf(newKey + cnt,",0x%04X",cur_pkey);\r
}\r
- token = strtok(NULL,seps);\r
+ token = strtok(NULL,pkey_sep);\r
}\r
\r
if(! pkey->pkey_num)\r
break;\r
}\r
\r
+ if(pkey_not_written)\r
+ cnt -= (2 + strlen(tmp));\r
+ \r
+ strcpy(newKey + cnt,pafter);\r
ret = RegSetValueEx(reg_handle,"PartitionKey",0,REG_SZ,(BYTE*)newKey, (DWORD)strlen(newKey));\r
if (ERROR_SUCCESS != ret)\r
{\r
}\r
}\r
while(FALSE);\r
+ if(pafter)\r
+ free(pafter);\r
\r
RegCloseKey( reg_handle );\r
return retval;\r
}\r
\r
-int send_create_pdo_req(pkey_array_t *pkeys)\r
+static int send_pdo_req(pkey_array_t *pkeys,DWORD iocode)\r
{\r
HANDLE hKernelLib;\r
DWORD bytesReturned;\r
}\r
\r
if (! DeviceIoControl(hKernelLib,\r
- UAL_REQ_CREATE_PDO,\r
+ iocode,\r
pkeys,sizeof(pkey_array_t),\r
NULL,0,\r
&bytesReturned,\r
NULL))\r
{\r
- printf("send_create_pdo_req failed error %d\n",GetLastError());\r
+ DWORD err = GetLastError();\r
+ if (err == 1168)\r
+ printf("No matched port guid (0x%I64X) found\n",pkeys->port_guid);\r
+ else if (err == 1117)\r
+ printf("operation failed - internal driver error\n");\r
+ else if(err == 87)\r
+ printf("operation failed - invalid input to driver\n");\r
+ else\r
+ printf("operation failed with error %d\n",err);\r
+\r
CloseHandle(hKernelLib);\r
return 1;\r
}\r
return 0;\r
}\r
\r
+\r
boolean_t reg_pkey_operation(const REQUEST_IN *input)\r
{\r
pkey_array_t pkeys;\r
+ HKEY reg_handle;\r
+ char *p_reg_string;\r
+ DWORD reg_length = 0;\r
int result;\r
int i;\r
+ LONG ret;\r
if(!input)\r
{\r
printf("create_ipoib_pdo : invalid input parameter\n");\r
}\r
\r
RtlZeroMemory(&pkeys,sizeof(pkeys));\r
+ pkeys.port_guid = input->u.guid_pkey.port_guid;\r
+\r
if(input->u.guid_pkey.action == pkey_add)\r
- result = reg_ibbus_pkey_add((unsigned __int16*)input->u.guid_pkey.pkeys, input->u.guid_pkey.pkey_num, &pkeys);\r
+ result = reg_ibbus_pkey_add((unsigned __int16*)input->u.guid_pkey.pkeys, input->u.guid_pkey.pkey_num, &pkeys,&p_reg_string,®_length);\r
else if(input->u.guid_pkey.action == pkey_rem)\r
- {\r
result = reg_ibbus_pkey_rem((unsigned __int16*)input->u.guid_pkey.pkeys, input->u.guid_pkey.pkey_num, &pkeys);\r
- return (boolean_t)(result == 0);\r
- }\r
else if(input->u.guid_pkey.action == pkey_show)\r
- return reg_ibbus_print_pkey();\r
+ result = reg_ibbus_print_pkey();\r
+ else\r
+ printf("Invalid command to part_man.exe\n");\r
\r
- if(0 == result)\r
+ if( 0 != result)\r
+ return FALSE;\r
+\r
+ if(pkeys.pkey_num)\r
{\r
- if(pkeys.pkey_num)\r
- return (boolean_t)( 0 == send_create_pdo_req(&pkeys));\r
+ if(input->u.guid_pkey.action == pkey_add)\r
+ {\r
+ if( 0 == send_pdo_req(&pkeys,UAL_REQ_CREATE_PDO))\r
+ {\r
+ ret = RegOpenKeyEx(HKEY_LOCAL_MACHINE,IBBUS_SERV_KEY,0,KEY_SET_VALUE | KEY_QUERY_VALUE ,®_handle);\r
+\r
+ ret = RegSetValueEx(reg_handle,"PartitionKey",0,REG_SZ,(BYTE*)p_reg_string,reg_length);\r
+ RegCloseKey( reg_handle );\r
+ if (ERROR_SUCCESS == ret)\r
+ {\r
+ return TRUE;\r
+ }\r
+ else\r
+ {\r
+ printf("reg_ibbus_pkey_add RegSetValueEx error = %d\n",GetLastError());\r
+ }\r
+ }\r
+ }\r
+ else if(input->u.guid_pkey.action == pkey_rem)\r
+ {\r
+ return (boolean_t)( 0 == send_pdo_req(&pkeys,UAL_REQ_REMOVE_PDO));\r
+ }\r
}\r
return FALSE;\r
}\r
return 0;\r
}\r
\r
- if(num < 3)\r
+ if(num < 4)\r
{\r
printf("invalid command %s\n",cmd[1]);\r
return 0;\r
}\r
- for( i = 2; i < num; i++)\r
+\r
+ /* vstat output format 0008:f104:0397:7ccc \r
+ For port guid add 1 for each port \r
+ */\r
+ if (strstr(cmd[2],":"))\r
{\r
- if (strstr(cmd[i],"0x"))\r
+ int i;\r
+ unsigned short *guid_vstat;\r
+ guid_vstat = (unsigned short*)&input->u.guid_pkey.port_guid;\r
+ sscanf(cmd[2],"%x:%x:%x:%x",&guid_vstat[0],&guid_vstat[1],&guid_vstat[2],&guid_vstat[3]);\r
+ for( i = 0; i < 4; i++)\r
+ guid_vstat[i] = (guid_vstat[i] << 8) | (guid_vstat[i] >> 8);\r
+ }\r
+ else\r
+ {\r
+ printf("port guid %s - illegal string format\n",cmd[2]);\r
+ return 0;\r
+ }\r
+ \r
+ for( i = 3; i < num; i++)\r
+ {\r
+ if((strstr(cmd[i],"ffff")) || (strstr(cmd[i],"FFFF")))\r
+ continue;\r
+ if (strstr(cmd[i],"0x") || strstr(cmd[i],"0X"))\r
sscanf(cmd[i],"0x%x",&input->u.guid_pkey.pkeys[input->u.guid_pkey.pkey_num]);\r
else\r
sscanf(cmd[i],"%x",&input->u.guid_pkey.pkeys[input->u.guid_pkey.pkey_num]);\r
-\r
input->u.guid_pkey.pkey_num++;\r
}\r
return 1;\r
}\r
\r
\r
+static ib_api_status_t\r
+ipoib_query_pkey_index(ipoib_adapter_t *p_adapter)\r
+{\r
+ ib_api_status_t status;\r
+ ib_ca_attr_t *ca_attr;\r
+ uint32_t ca_size;\r
+ uint16_t index = 0;\r
+\r
+ /* Query the CA for Pkey table */\r
+ status = p_adapter->p_ifc->query_ca(p_adapter->p_port->ib_mgr.h_ca, NULL, &ca_size);\r
+ if(status != IB_INSUFFICIENT_MEMORY)\r
+ {\r
+ IPOIB_PRINT_EXIT( TRACE_LEVEL_ERROR, IPOIB_DBG_ERROR,\r
+ ("ib_query_ca failed\n"));\r
+ return status;\r
+ }\r
+\r
+ ca_attr = (ib_ca_attr_t*)cl_zalloc(ca_size);\r
+ if (!ca_attr)\r
+ {\r
+ IPOIB_PRINT_EXIT( TRACE_LEVEL_ERROR, IPOIB_DBG_ERROR,\r
+ ("cl_zalloc can't allocate %d\n",ca_size));\r
+ return IB_INSUFFICIENT_MEMORY;\r
+ }\r
+\r
+ status = p_adapter->p_ifc->query_ca(p_adapter->p_port->ib_mgr.h_ca, ca_attr,&ca_size); \r
+ if( status != IB_SUCCESS )\r
+ {\r
+ IPOIB_PRINT_EXIT( TRACE_LEVEL_ERROR, IPOIB_DBG_ERROR,\r
+ ("ib_query_ca returned %s\n", \r
+ p_adapter->p_ifc->get_err_str( status )) );\r
+ goto pkey_end;\r
+ }\r
+\r
+ CL_ASSERT(ca_attr->p_port_attr->p_pkey_table[0] == IB_DEFAULT_PKEY);\r
+ for(index = 0; index < ca_attr->p_port_attr->num_pkeys; index++)\r
+ {\r
+ if(cl_hton16(p_adapter->guids.port_guid.pkey) == ca_attr->p_port_attr->p_pkey_table[index])\r
+ break;\r
+ }\r
+ if(index >= ca_attr->p_port_attr->num_pkeys)\r
+ {\r
+ IPOIB_PRINT_EXIT( TRACE_LEVEL_ERROR, IPOIB_DBG_ERROR,\r
+ ("Pkey table is invalid, index not found\n"));\r
+ NdisWriteErrorLogEntry( p_adapter->h_adapter,\r
+ EVENT_IPOIB_PARTITION_ERR, 1, p_adapter->guids.port_guid.pkey );\r
+ p_adapter->p_port->pkey_index = PKEY_INVALID_INDEX;\r
+ goto pkey_end;\r
+ }\r
+\r
+ p_adapter->p_port->pkey_index = index;\r
+ IPOIB_PRINT_EXIT( TRACE_LEVEL_INFORMATION, IPOIB_DBG_IB,\r
+ ("for PKEY = 0x%04X got index = %d\n",p_adapter->guids.port_guid.pkey,index));\r
+\r
+pkey_end:\r
+ if(ca_attr)\r
+ cl_free(ca_attr);\r
+ return status;\r
+}\r
+\r
static ib_api_status_t\r
__ipoib_pnp_cb(\r
IN ib_pnp_rec_t *p_pnp_rec )\r
{\r
- ib_api_status_t status;\r
ipoib_adapter_t *p_adapter;\r
ipoib_port_t *p_port;\r
ib_pnp_event_t old_state;\r
ib_pnp_port_rec_t *p_port_rec;\r
+ ib_api_status_t status = IB_SUCCESS;\r
\r
IPOIB_ENTER( IPOIB_DBG_PNP );\r
\r
("IPOIB: Received unhandled PnP event 0x%x (%s)\n",\r
p_pnp_rec->pnp_event, ib_get_pnp_event_str( p_pnp_rec->pnp_event )) );\r
/* Fall through. */\r
- case IB_PNP_PKEY_CHANGE:\r
- case IB_PNP_SM_CHANGE:\r
- case IB_PNP_GID_CHANGE:\r
- case IB_PNP_LID_CHANGE:\r
+\r
status = IB_SUCCESS;\r
\r
- /* We ignore this event if the link is not active. */\r
+ /* We ignore events below if the link is not active. */\r
if( p_port_rec->p_port_attr->link_state != IB_LINK_ACTIVE )\r
- break;\r
+ break;\r
+\r
+ case IB_PNP_PKEY_CHANGE:\r
+ if(p_pnp_rec->pnp_event == IB_PNP_PKEY_CHANGE && \r
+ p_adapter->guids.port_guid.pkey != IB_DEFAULT_PKEY)\r
+ {\r
+ status = ipoib_query_pkey_index(p_adapter);\r
+ if(status != IB_SUCCESS)\r
+ break;\r
+ }\r
+\r
+ case IB_PNP_SM_CHANGE:\r
+ case IB_PNP_GID_CHANGE:\r
+ case IB_PNP_LID_CHANGE:\r
\r
cl_obj_lock( &p_adapter->obj );\r
old_state = p_adapter->state;\r
break;\r
\r
default:\r
+ if (p_adapter->guids.port_guid.pkey != IB_DEFAULT_PKEY)\r
+ ipoib_query_pkey_index(p_adapter);\r
+\r
/* Join all programmed multicast groups. */\r
for( i = 0; i < p_adapter->mcast_array_size; i++ )\r
{\r
Language=English\r
%2: Incorrect value or non-existing registry for the optional IPoIB parameter %3, overriding it by default value: %4\r
.\r
+\r
+MessageId=0x005B\r
+Facility=IPoIB\r
+Severity=Error\r
+SymbolicName=EVENT_IPOIB_PARTITION_ERR\r
+Language=English\r
+%2: Pkey index not found for partition , change switch pkey configuration.\r
+.\r
+\r
uint64_t vaddr;\r
net32_t rkey;\r
ib_qp_attr_t qp_attr;\r
- ib_ca_attr_t *ca_attr;\r
- uint32_t ca_size;\r
\r
IPOIB_ENTER( IPOIB_DBG_INIT );\r
\r
return status;\r
}\r
\r
- /* Query the CA for Pkey table */\r
- status = p_port->p_adapter->p_ifc->query_ca(p_port->ib_mgr.h_ca, NULL, &ca_size);\r
- if(status != IB_INSUFFICIENT_MEMORY)\r
- {\r
- IPOIB_PRINT_EXIT( TRACE_LEVEL_ERROR, IPOIB_DBG_ERROR,\r
- ("ib_query_ca failed\n"));\r
- return status;\r
- }\r
-\r
- ca_attr = (ib_ca_attr_t*)cl_zalloc(ca_size);\r
- if (!ca_attr)\r
- {\r
- IPOIB_PRINT_EXIT( TRACE_LEVEL_ERROR, IPOIB_DBG_ERROR,\r
- ("cl_zalloc can't allocate %d\n",ca_size));\r
- return IB_INSUFFICIENT_RESOURCES;\r
- }\r
-\r
- status = p_port->p_adapter->p_ifc->query_ca(p_port->ib_mgr.h_ca, ca_attr,&ca_size); \r
- if( status != IB_SUCCESS )\r
- {\r
- cl_free(ca_attr);\r
- IPOIB_PRINT_EXIT( TRACE_LEVEL_ERROR, IPOIB_DBG_ERROR,\r
- ("ib_query_ca returned %s\n", \r
- p_port->p_adapter->p_ifc->get_err_str( status )) );\r
- return status;\r
- }\r
- if( ca_attr->p_port_attr->link_state == IB_LINK_ACTIVE)\r
- {\r
- uint16_t index;\r
- CL_ASSERT(ca_attr->p_port_attr->p_pkey_table[0] == IB_DEFAULT_PKEY);\r
- for(index = 0; index < ca_attr->p_port_attr->num_pkeys; index++)\r
- {\r
- if(p_port->p_adapter->guids.port_guid.pkey == ca_attr->p_port_attr->p_pkey_table[index])\r
- break;\r
- }\r
- if(index >= ca_attr->p_port_attr->num_pkeys)\r
- {\r
- IPOIB_PRINT_EXIT( TRACE_LEVEL_ERROR, IPOIB_DBG_ERROR,\r
- ("Pkey table is invalid, index not found\n"));\r
- return IB_NOT_FOUND;\r
- }\r
- p_port->pkey_index = index;\r
- IPOIB_PRINT_EXIT( TRACE_LEVEL_INFORMATION, IPOIB_DBG_IB,\r
- ("for PKEY = 0x%04X got index = %d\n",p_port->p_adapter->guids.port_guid.pkey,index));\r
- }\r
- cl_free(ca_attr);\r
/* Allocate the PD. */\r
status = p_port->p_adapter->p_ifc->alloc_pd(\r
p_port->ib_mgr.h_ca, IB_PDT_UD, p_port, &p_port->ib_mgr.h_pd );\r
\r
member_rec.mgid.raw[4] = (uint8_t) (p_port->p_adapter->guids.port_guid.pkey >> 8) ;\r
member_rec.mgid.raw[5] = (uint8_t) p_port->p_adapter->guids.port_guid.pkey;\r
- member_rec.pkey = p_port->p_adapter->guids.port_guid.pkey;\r
+ member_rec.pkey = cl_hton16(p_port->p_adapter->guids.port_guid.pkey);\r
cl_memclr( &query, sizeof(ib_query_req_t) );\r
query.query_type = IB_QUERY_USER_DEFINED;\r
query.p_query_input = &info;\r
mcast_req.member_rec.mtu =\r
(IB_PATH_SELECTOR_EXACTLY << 6) | IB_MTU_LEN_2048;\r
\r
- mcast_req.member_rec.pkey = p_port->p_adapter->guids.port_guid.pkey;\r
+ mcast_req.member_rec.pkey = cl_hton16(p_port->p_adapter->guids.port_guid.pkey);\r
\r
mcast_req.member_rec.sl_flow_hop = ib_member_set_sl_flow_hop( 0, 0, 0 );\r
mcast_req.member_rec.scope_state =\r
mcast_req.retry_cnt = p_port->p_adapter->params.sa_retry_cnt;\r
mcast_req.port_guid = p_port->p_adapter->guids.port_guid.guid;\r
mcast_req.pkey_index = p_port->pkey_index;\r
- mcast_req.member_rec.pkey = p_port->p_adapter->guids.port_guid.pkey;\r
+ mcast_req.member_rec.pkey = cl_hton16(p_port->p_adapter->guids.port_guid.pkey);\r
/*\r
* Create the endpoint and insert it in the port. Since we don't wait for\r
* the mcast SA operations to complete before returning from the multicast\r
#define MAX_SEND_SGE 8\r
\r
\r
+/* \r
+ * Invalid pkey index\r
+ */\r
+#define PKEY_INVALID_INDEX 0xFFFF\r
+\r
/*\r
* Define to control how transfers are done. When defined as 1, causes\r
* packets to be sent using NDIS DMA facilities (getting the SGL from the\r
\r
[OPENIB.ntx86]\r
%IpoibDesc% = Ipoib.DDInstall, IBA\IPoIB ; Internet Protocol over InfiniBand Adapter\r
+%IpoibDescP% = Ipoib.DDInstall, IBA\IPoIBP ; Internet Protocol over InfiniBand Adapter with partition key\r
\r
[OPENIB.ntamd64]\r
%IpoibDesc% = Ipoib.DDInstall, IBA\IPoIB ; Internet Protocol over InfiniBand Adapter\r
+%IpoibDescP% = Ipoib.DDInstall, IBA\IPoIBP ; Internet Protocol over InfiniBand Adapter with partition key\r
\r
[OPENIB.ntia64]\r
%IpoibDesc% = Ipoib.DDInstall, IBA\IPoIB ; Internet Protocol over InfiniBand Adapter\r
+%IpoibDescP% = Ipoib.DDInstall, IBA\IPoIBP ; Internet Protocol over InfiniBand Adapter with partition key\r
\r
[Ipoib.DDInstall.ntx86]\r
Characteristics = 0x81 ; NCF_HAS_UI | NCF_VIRTUAL\r
HKR, Ndi\Params\PayloadMtu, Min, 0, "60"\r
HKR, Ndi\Params\PayloadMtu, Max, 0, "4092"\r
\r
+\r
HKR, Ndi\Params\MCLeaveRescan, ParamDesc, 0, "MC leave rescan (sec)"\r
HKR, Ndi\Params\MCLeaveRescan, Type, 0, "dword"\r
HKR, Ndi\Params\MCLeaveRescan, Default, 0, "260"\r
HKR, Ndi\Params\MCLeaveRescan, Optional, 0, "0"\r
HKR, Ndi\Params\MCLeaveRescan, Min, 0, "1"\r
HKR, Ndi\Params\MCLeaveRescan, Max, 0, "3600"\r
+\r
+\r
[IpoibService]\r
DisplayName = %IpoibServiceDispName%\r
ServiceType = 1 ;%SERVICE_KERNEL_DRIVER%\r
[Strings]\r
OPENIB = "OpenIB Alliance"\r
IpoibDesc = "OpenIB IPoIB Adapter"\r
+IpoibDescP = "OpenIB IPoIB Adapter Partition"\r
IpoibServiceDispName = "IPoIB"\r
IcsDisk1 = "OpenIB IPoIB Disk #1"\r
DIRID_SYSTEM = 11\r