From b21a0c747006ca954067ee6d06795f9ad3fa6331 Mon Sep 17 00:00:00 2001 From: leonidk Date: Tue, 18 Apr 2006 08:27:07 +0000 Subject: [PATCH] [MTHCA] improve the time of handling events like port state change git-svn-id: svn://openib.tc.cornell.edu/gen1/trunk@312 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86 --- hw/mthca/kernel/ib_verbs.h | 16 ++++++++-------- hw/mthca/kernel/mt_cache.c | 20 ++++++++++++++------ hw/mthca/kernel/mt_device.c | 28 ++++++++++++++-------------- hw/mthca/kernel/mthca_provider.c | 31 ++++++++++++++++++++++--------- hw/mthca/kernel/mthca_provider.h | 8 ++++---- 5 files changed, 62 insertions(+), 41 deletions(-) diff --git a/hw/mthca/kernel/ib_verbs.h b/hw/mthca/kernel/ib_verbs.h index 24b093dd..8e269304 100644 --- a/hw/mthca/kernel/ib_verbs.h +++ b/hw/mthca/kernel/ib_verbs.h @@ -700,11 +700,11 @@ struct ib_device { int (*query_port)(struct ib_device *device, u8 port_num, struct ib_port_attr *port_attr); - int (*query_gid)(struct ib_device *device, + int (*query_gid_chunk)(struct ib_device *device, u8 port_num, int index, - union ib_gid *gid); - int (*query_pkey)(struct ib_device *device, - u8 port_num, u16 index, u16 *pkey); + union ib_gid gid[8]); + int (*query_pkey_chunk)(struct ib_device *device, + u8 port_num, u16 index, u16 pkey[32]); int (*modify_device)(struct ib_device *device, int device_modify_mask, struct ib_device_modify *device_modify); @@ -855,11 +855,11 @@ int ib_query_device(struct ib_device *device, int ib_query_port(struct ib_device *device, u8 port_num, struct ib_port_attr *port_attr); -int ib_query_gid(struct ib_device *device, - u8 port_num, int index, union ib_gid *gid); +int ib_query_gid_chunk(struct ib_device *device, + u8 port_num, int index, union ib_gid gid[8]); -int ib_query_pkey(struct ib_device *device, - u8 port_num, u16 index, u16 *pkey); +int ib_query_pkey_chunk(struct ib_device *device, + u8 port_num, u16 index, u16 pkey[32]); int ib_modify_device(struct ib_device *device, int device_modify_mask, diff --git a/hw/mthca/kernel/mt_cache.c b/hw/mthca/kernel/mt_cache.c index a05b601a..daff9345 100644 --- a/hw/mthca/kernel/mt_cache.c +++ b/hw/mthca/kernel/mt_cache.c @@ -230,22 +230,30 @@ static void ib_cache_update(struct ib_device *device, gid_cache->table_len = tprops->gid_tbl_len; - for (i = 0; i < pkey_cache->table_len; ++i) { - ret = ib_query_pkey(device, port, (u16)i, pkey_cache->table + i); + for (i = 0; i < pkey_cache->table_len; i+=32) { + u16 pkey_chunk[32]; + int size; + ret = ib_query_pkey_chunk(device, port, (u16)i, pkey_chunk); if (ret) { - HCA_PRINT(TRACE_LEVEL_WARNING ,HCA_DBG_LOW,("ib_query_pkey failed (%d) for %s (index %d)\n", + HCA_PRINT(TRACE_LEVEL_WARNING ,HCA_DBG_LOW,("ib_query_pkey_chunk failed (%d) for %s (index %d)\n", ret, device->name, i)); goto err; } + size = min(32, pkey_cache->table_len - i); + RtlCopyMemory(pkey_cache->table + i, pkey_chunk, size*sizeof(u16)); } - for (i = 0; i < gid_cache->table_len; ++i) { - ret = ib_query_gid(device, port, i, gid_cache->table + i); + for (i = 0; i < gid_cache->table_len; i+=8) { + union ib_gid gid_chunk[8]; + int size; + ret = ib_query_gid_chunk(device, port, i, gid_chunk); if (ret) { - HCA_PRINT(TRACE_LEVEL_WARNING ,HCA_DBG_LOW,("ib_query_gid failed (%d) for %s (index %d)\n", + HCA_PRINT(TRACE_LEVEL_WARNING ,HCA_DBG_LOW,("ib_query_gid_chunk failed (%d) for %s (index %d)\n", ret, device->name, i)); goto err; } + size = min(8, gid_cache->table_len - i); + RtlCopyMemory(gid_cache->table + i, gid_chunk, size*sizeof(union ib_gid)); } write_lock_irq(&device->cache.lock, &lh); diff --git a/hw/mthca/kernel/mt_device.c b/hw/mthca/kernel/mt_device.c index a8d4d0c9..6e520bc4 100644 --- a/hw/mthca/kernel/mt_device.c +++ b/hw/mthca/kernel/mt_device.c @@ -70,8 +70,8 @@ static int ib_device_check_mandatory(struct ib_device *device) } mandatory_table[] = { IB_MANDATORY_FUNC(query_device), IB_MANDATORY_FUNC(query_port), - IB_MANDATORY_FUNC(query_pkey), - IB_MANDATORY_FUNC(query_gid), + IB_MANDATORY_FUNC(query_pkey_chunk), + IB_MANDATORY_FUNC(query_gid_chunk), IB_MANDATORY_FUNC(alloc_pd), IB_MANDATORY_FUNC(dealloc_pd), IB_MANDATORY_FUNC(create_ah), @@ -472,34 +472,34 @@ int ib_query_port(struct ib_device *device, /** - * ib_query_gid - Get GID table entry + * ib_query_gid_chunk - Get a chunk of GID table entries * @device:Device to query * @port_num:Port number to query * @index:GID table index to query - * @gid:Returned GID + * @gid:Returned GIDs chunk * - * ib_query_gid() fetches the specified GID table entry. + * ib_query_gid_chunk() fetches the specified GID table enties chunk. */ -int ib_query_gid(struct ib_device *device, - u8 port_num, int index, union ib_gid *gid) +int ib_query_gid_chunk(struct ib_device *device, + u8 port_num, int index, union ib_gid gid[8]) { - return device->query_gid(device, port_num, index, gid); + return device->query_gid_chunk(device, port_num, index, gid); } /** - * ib_query_pkey - Get P_Key table entry + * ib_query_pkey_chunk - Get a chunk of P_Key table entries * @device:Device to query * @port_num:Port number to query * @index:P_Key table index to query - * @pkey:Returned P_Key + * @pkey:Returned P_Keys chunk * - * ib_query_pkey() fetches the specified P_Key table entry. + * ib_query_pkey_chunk() fetches the specified P_Key table entries chunk. */ -int ib_query_pkey(struct ib_device *device, - u8 port_num, u16 index, u16 *pkey) +int ib_query_pkey_chunk(struct ib_device *device, + u8 port_num, u16 index, u16 pkey[32]) { - return device->query_pkey(device, port_num, index, pkey); + return device->query_pkey_chunk(device, port_num, index, pkey); } diff --git a/hw/mthca/kernel/mthca_provider.c b/hw/mthca/kernel/mthca_provider.c index c5ed497b..2d204626 100644 --- a/hw/mthca/kernel/mthca_provider.c +++ b/hw/mthca/kernel/mthca_provider.c @@ -216,8 +216,8 @@ out: return err; } -int mthca_query_pkey(struct ib_device *ibdev, - u8 port, u16 index, u16 *pkey) +int mthca_query_pkey_chunk(struct ib_device *ibdev, + u8 port, u16 index, u16 pkey[32]) { struct ib_smp *in_mad = NULL; struct ib_smp *out_mad = NULL; @@ -243,7 +243,12 @@ int mthca_query_pkey(struct ib_device *ibdev, goto out; } - *pkey = cl_ntoh16(((__be16 *) out_mad->data)[index % 32]); + { // copy the results + int i; + __be16 *pkey_chunk = (__be16 *)out_mad->data; + for (i=0; i<32; ++i) + pkey[i] = cl_ntoh16(pkey_chunk[i]); + } out: kfree(in_mad); @@ -251,13 +256,14 @@ int mthca_query_pkey(struct ib_device *ibdev, return err; } -int mthca_query_gid(struct ib_device *ibdev, u8 port, - int index, union ib_gid *gid) +int mthca_query_gid_chunk(struct ib_device *ibdev, u8 port, + int index, union ib_gid gid[8]) { struct ib_smp *in_mad = NULL; struct ib_smp *out_mad = NULL; int err = -ENOMEM; u8 status; + __be64 subnet_prefix; in_mad = kzalloc(sizeof *in_mad, GFP_KERNEL); out_mad = kmalloc(sizeof *out_mad, GFP_KERNEL); @@ -278,7 +284,7 @@ int mthca_query_gid(struct ib_device *ibdev, u8 port, goto out; } - memcpy(gid->raw, out_mad->data + 8, 8); + memcpy(&subnet_prefix, out_mad->data + 8, 8); init_query_mad(in_mad); in_mad->attr_id = IB_SMP_ATTR_GUID_INFO; @@ -294,7 +300,14 @@ int mthca_query_gid(struct ib_device *ibdev, u8 port, goto out; } - memcpy(gid->raw + 8, out_mad->data + (index % 8) * 16, 8); + { // copy the results + int i; + __be64 *guid = (__be64 *)out_mad->data; + for (i=0; i<8; ++i) { + gid[i].global.subnet_prefix = subnet_prefix; + gid[i].global.interface_id = guid[i]; + } + } out: kfree(in_mad); @@ -1169,8 +1182,8 @@ int mthca_register_device(struct mthca_dev *dev) dev->ib_dev.query_device = mthca_query_device; dev->ib_dev.query_port = mthca_query_port; dev->ib_dev.modify_port = mthca_modify_port; - dev->ib_dev.query_pkey = mthca_query_pkey; - dev->ib_dev.query_gid = mthca_query_gid; + dev->ib_dev.query_pkey_chunk = mthca_query_pkey_chunk; + dev->ib_dev.query_gid_chunk = mthca_query_gid_chunk; dev->ib_dev.alloc_ucontext = mthca_alloc_ucontext; dev->ib_dev.dealloc_ucontext = mthca_dealloc_ucontext; dev->ib_dev.alloc_pd = mthca_alloc_pd; diff --git a/hw/mthca/kernel/mthca_provider.h b/hw/mthca/kernel/mthca_provider.h index 2e71579e..9cf5a777 100644 --- a/hw/mthca/kernel/mthca_provider.h +++ b/hw/mthca/kernel/mthca_provider.h @@ -372,11 +372,11 @@ int mthca_modify_port(struct ib_device *ibdev, u8 port, int port_modify_mask, struct ib_port_modify *props); -int mthca_query_pkey(struct ib_device *ibdev, - u8 port, u16 index, u16 *pkey); +int mthca_query_pkey_chunk(struct ib_device *ibdev, + u8 port, u16 index, u16 pkey[32]); -int mthca_query_gid(struct ib_device *ibdev, u8 port, - int index, union ib_gid *gid); +int mthca_query_gid_chunk(struct ib_device *ibdev, u8 port, + int index, union ib_gid gid[8]); struct ib_ucontext *mthca_alloc_ucontext(struct ib_device *ibdev, ci_umv_buf_t* const p_umv_buf); -- 2.17.1