[openib-general] [PATCH]: GSI Eliminate static limit on HCAs and ports
Hal Rosenstock
halr at voltaire.com
Wed Aug 11 04:36:32 PDT 2004
Eliminate static limit on HCAs and ports in GSI
Index: access/TODO
===================================================================
--- access/TODO (revision 624)
+++ access/TODO (working copy)
@@ -1,8 +1,7 @@
-8/10/04
+8/11/04
Remove #if 0/1 with suitable preprocessor symbols
Replace ib_reg_mr with ib_reg_phys_mr
-Eliminate static limit on numbers of ports/HCAs
Makefile needs to use standard kbuild
Migrate from /proc to /sysfs
Obtain proper SGID index for GRH support (low priority)
Index: access/gsi_main.c
===================================================================
--- access/gsi_main.c (revision 627)
+++ access/gsi_main.c (working copy)
@@ -147,13 +147,6 @@
static struct timer_list gsi_sent_dtgrm_timer;
static atomic_t gsi_sent_dtgrm_timer_running = ATOMIC_INIT(1);
-#if 1 /* GSI_CREATE_PORTS_IN_INSMOD */
-/* support max 10 ports !!! */
-# define GSI_MAX_SUPPORTED_PORTS 10
-static struct gsi_hca_info_st *gsi_hca_h_array[GSI_MAX_SUPPORTED_PORTS];
-static int gsi_hca_h_array_num_ports = 0;
-#endif
-
/* Current client ID (Manager in IB MI terms) */
static u32 gsi_curr_client_id = GSI_SERVER_ID + 1;
static u32 gsi_curr_tid_cnt = 0;
@@ -623,16 +616,26 @@
* and remove the HCA info structure.
*/
static int
-gsi_hca_close(struct gsi_hca_info_st *hca)
+gsi_hca_close(struct ib_device *device, int gsi_port)
{
+ struct gsi_hca_info_st *hca = NULL, *head =
+ (struct gsi_hca_info_st *) &gsi_hca_list, *entry;
GSI_HCA_LIST_LOCK_VAR;
+ GSI_HCA_LIST_LOCK();
+ list_for_each(entry, head) {
+ if (entry->handle == device && entry->port == gsi_port) {
+ hca = entry;
+ break;
+ }
+ }
+
if (hca == NULL) {
printk(KERN_ERR "hca == NULL\n");
+ GSI_HCA_LIST_UNLOCK();
return -ENODEV;
}
- GSI_HCA_LIST_LOCK();
if (--hca->ref_cnt > 0) {
printk(KERN_DEBUG "cnt - %d\n", hca->ref_cnt);
GSI_HCA_LIST_UNLOCK();
@@ -656,8 +659,8 @@
* Open the HCA device, create the QP and CQ if needed
*/
static int
-gsi_hca_open(struct ib_device *device,
- struct gsi_hca_info_st **hca_info, int gsi_port)
+gsi_hca_open(struct ib_device *device, int gsi_port,
+ struct gsi_hca_info_st **hca_info)
{
struct gsi_hca_info_st *hca = NULL, *head =
(struct gsi_hca_info_st *) &gsi_hca_list, *entry;
@@ -700,14 +703,11 @@
printk(KERN_ERR "Memory allocation error\n");
return -ENOMEM;
}
-
- memset(hca, 0, sizeof (*hca));
*hca_info = hca;
+ memset(hca, 0, sizeof (*hca));
hca->port = gsi_port;
-
hca->ref_cnt = 1;
-
hca->handle = device;
cq_size = GSI_QP_SND_SIZE + GSI_QP_RCV_SIZE + 20;
@@ -816,7 +816,7 @@
return -EPERM;
}
- if ((ret = gsi_hca_open(device, &hca, port))) {
+ if ((ret = gsi_hca_open(device, port, &hca))) {
printk(KERN_ERR "Cannot open HCA\n");
goto error1;
}
@@ -931,7 +931,7 @@
kfree(newinfo);
#endif
error2:
- gsi_hca_close(hca);
+ gsi_hca_close(device, port);
error1:
return ret;
}
@@ -976,7 +976,7 @@
gsi_class_return_posted_snd_dtgrms(class_info);
gsi_class_clean_redirect_class_port_info_list(class_info);
- gsi_hca_close(class_info->hca);
+ gsi_hca_close(class_info->hca->handle, class_info->hca->port);
kfree(class_info);
return 0;
@@ -2719,43 +2719,32 @@
int ret;
struct ib_device_cap hca_attrib;
int i = 0;
+ struct gsi_hca_info_st *hca = NULL;
if ((ret = ib_query_device(device, &hca_attrib))) {
printk(KERN_ERR "Could not query HCA\n");
goto error_hca_query;
}
- if (hca_attrib.phys_port_cnt > GSI_MAX_SUPPORTED_PORTS) {
- printk(KERN_ERR "Too many ports - %d (support up to %d)\n",
- hca_attrib.phys_port_cnt, GSI_MAX_SUPPORTED_PORTS);
- ret = -EMFILE;
- goto error_too_many_ports;
- }
-
for (i = 0; i < hca_attrib.phys_port_cnt; i++) {
- if ((ret = gsi_hca_open(device,
- &(gsi_hca_h_array[i]), (i + 1)))) {
+ if ((ret = gsi_hca_open(device, i + 1, &hca))) {
printk(KERN_ERR "Cannot open HCA\n");
goto error_gsi_hca_open;
}
- gsi_hca_h_array_num_ports++;
}
return 0;
error_gsi_hca_open:
while (i > 0) {
- if ((ret = gsi_hca_close((gsi_hca_h_array[i - 1])))) {
+ if ((ret = gsi_hca_close(device, i - 1))) {
printk(KERN_ERR \
"Cannot close gsi HCA (ret: %d), ix: %d\n",
ret, i - 1);
}
- gsi_hca_h_array_num_ports--;
- gsi_hca_h_array[i - 1] = NULL;
i--;
}
-error_too_many_ports:
error_hca_query:
return ret;
}
@@ -2763,7 +2752,7 @@
static int
gsi_delete_ports(struct ib_device *device)
{
- int ret;
+ int ret = 0;
struct ib_device_cap hca_attrib;
int i = 0;
@@ -2772,34 +2761,14 @@
goto error_hca_query;
}
- if (hca_attrib.phys_port_cnt > GSI_MAX_SUPPORTED_PORTS) {
- printk(KERN_ERR "Too many ports - %d (support up to %d)\n",
- hca_attrib.phys_port_cnt, GSI_MAX_SUPPORTED_PORTS);
- ret = -EMFILE;
- goto error_too_many_ports;
- }
-
for (i = 0; i < hca_attrib.phys_port_cnt; i++) {
- if (gsi_hca_h_array[i] != NULL) {
- if ((ret = gsi_hca_close((gsi_hca_h_array[i])))) {
- printk(KERN_ERR \
- "Cannot close gsi HCA (ret: %d), ix: %d\n",
- ret, i);
- }
- gsi_hca_h_array_num_ports--;
- } else {
- printk(KERN_ERR "gsi_hca_h_array[%d] == NULL\n", i);
+ if ((ret = gsi_hca_close(device, i))) {
+ printk(KERN_ERR \
+ "Cannot close gsi HCA (ret: %d), ix: %d\n",
+ ret, i);
}
}
- if (gsi_hca_h_array_num_ports != 0) {
- printk(KERN_ERR "gsi_hca_h_array_num_ports: %d != 0\n",
- gsi_hca_h_array_num_ports);
- }
-
- return 0;
-
-error_too_many_ports:
error_hca_query:
return ret;
}
Index: access/gsi_priv.h
===================================================================
--- access/gsi_priv.h (revision 624)
+++ access/gsi_priv.h (working copy)
@@ -187,7 +187,7 @@
spinlock_t rcv_list_lock;
struct list_head rcv_posted_dtgrm_list;
- u8 port; /* #### Set this field? */
+ u8 port;
struct ib_qp *qp; /* QP */
struct ib_cq *cq; /* Complete queue */
Index: access/class_port_info.h
===================================================================
--- access/class_port_info.h (revision 561)
+++ access/class_port_info.h (working copy)
@@ -133,7 +133,7 @@
#if defined(__LITTLE_ENDIAN)
static inline void
-class_port_ntoh(char *dest, char *src, u8 size)
+gid_ntoh(char *dest, char *src, u8 size)
{
u8 i;
char temp;
@@ -151,7 +151,7 @@
}
}
#else
-#define class_port_ntoh(a,b,c) if(a != b)memcpy(a,b,c)
+#define gid_ntoh(a,b,c) if(a != b)memcpy(a,b,c)
#endif
static inline void
@@ -159,7 +159,7 @@
{
info->capability_mask = htons(info->capability_mask);
info->reserved1 = htonl(info->reserved1) >> 5;
- class_port_ntoh((char *) &info->redirect_gid,
+ gid_ntoh((char *) &info->redirect_gid,
(char *) &info->redirect_gid,
sizeof (info->redirect_gid));
info->redirect_fl = htonl(info->redirect_fl) >> 12;
@@ -167,8 +167,8 @@
info->redirect_p_key = htons(info->redirect_p_key);
info->redirect_qp = (htonl(info->redirect_qp)) >> 8;
info->redirect_q_key = htonl(info->redirect_q_key);
- class_port_ntoh((char *) &info->trap_gid, (char *) &info->trap_gid,
- sizeof (info->trap_gid));
+ gid_ntoh((char *) &info->trap_gid, (char *) &info->trap_gid,
+ sizeof (info->trap_gid));
info->trapfl = htonl(info->trapfl) >> 12;
info->trap_lid = htons(info->trap_lid);
info->trap_p_key = htons(info->trap_p_key);
More information about the general
mailing list