RDMA: Remove query_pkey from iwarp providers
Subsystems (4)
cover RDMA: Remove query_pkey from iwarp providers
This patch set does the following:
1- Avoid exposing the pkeys sysfs entries for iwarp providers. 2- Avoid allocating the pkey cache for iwarp providers.
3- Remove the requirement by RDMA core to implement query_pkey
by all providers.
4- Remove the implementation of query_pkey callback from iwarp providers.
v1: Patch #1: Move the free of the pkey_group to the right place.
Kamal Heib (7):
RDMA/core: Expose pkeys sysfs files only if pkey_tbl_len is set RDMA/core: Allocate the pkey cache only if the pkey_tbl_len is set RDMA/core: Remove query_pkey from the mandatory ops RDMA/siw: Remove the query_pkey callback
RDMA/cxgb4: Remove the query_pkey callback
RDMA/i40iw: Remove the query_pkey callback
RDMA/qedr: Remove the query_pkey callback
drivers/infiniband/core/cache.c | 45 ++++++++++------ drivers/infiniband/core/device.c | 4 +- drivers/infiniband/core/sysfs.c | 64 ++++++++++++++++------- drivers/infiniband/hw/cxgb4/provider.c | 11 ---- drivers/infiniband/hw/i40iw/i40iw_verbs.c | 19 ------- drivers/infiniband/hw/qedr/main.c | 3 +- drivers/infiniband/hw/qedr/verbs.c | 1 - drivers/infiniband/sw/siw/siw_main.c | 1 - drivers/infiniband/sw/siw/siw_verbs.c | 9 ---- drivers/infiniband/sw/siw/siw_verbs.h | 1 - 10 files changed, 77 insertions(+), 81 deletions(-)
Signature · 1 line
2.25.4
PATCH 1/7 RDMA/core: Expose pkeys sysfs files only if pkey_tbl_len is set
Expose the pkeys sysfs files only if the pkey_tbl_len is set by the providers.
--- drivers/infiniband/core/sysfs.c | 64 ++++++++++++++++++++++----------- 1 file changed, 44 insertions(+), 20 deletions(-)
drivers/infiniband/core/sysfs.c +44 -20
@@ -58,7 +58,7 @@ struct ib_port {struct ib_device *ibdev;struct gid_attr_group *gid_attr_group;struct attribute_group gid_group; -struct attribute_group pkey_group; +struct attribute_group *pkey_group;struct attribute_group *pma_table;struct attribute_group *hw_stats_ag;struct rdma_hw_stats *hw_stats;
@@ -681,11 +681,16 @@ static void ib_port_release(struct kobject *kobj)kfree (p->gid_group.attrs); } -if (p->pkey_group.attrs) { -for (i =0 ; (a = p->pkey_group.attrs[i]); ++i) -kfree (a); +if (p->pkey_group) { +if (p->pkey_group->attrs) { +for (i =0 ; (a = p->pkey_group->attrs[i]); ++i) +kfree (a); + +kfree (p->pkey_group->attrs); + } -kfree (p->pkey_group.attrs); +kfree (p->pkey_group); + p->pkey_group =NULL ; }kfree (p);
@@ -1118,17 +1123,26 @@ static int add_port(struct ib_core_device *coredev, int port_num)if (ret) goto err_free_gid_type; - p->pkey_group.name ="pkeys" ; - p->pkey_group.attrs =alloc_group_attrs (show_port_pkey, - attr.pkey_tbl_len); -if (!p->pkey_group.attrs) { - ret = -ENOMEM ; - goto err_remove_gid_type; +if (attr.pkey_tbl_len) { + p->pkey_group =kzalloc (sizeof (*p->pkey_group),GFP_KERNEL ); +if (!p->pkey_group) { + ret = -ENOMEM ; + goto err_remove_gid_type; + } + + p->pkey_group->name ="pkeys" ; + p->pkey_group->attrs =alloc_group_attrs (show_port_pkey, + attr.pkey_tbl_len); +if (!p->pkey_group->attrs) { + ret = -ENOMEM ; + goto err_free_pkey_group; + } + + ret =sysfs_create_group (&p->kobj, p->pkey_group); +if (ret) + goto err_free_pkey; } - ret =sysfs_create_group (&p->kobj, &p->pkey_group); -if (ret) - goto err_free_pkey;if (device->ops.init_port && is_full_dev) { ret = device->ops.init_port (device, port_num, &p->kobj);
@@ -1150,14 +1164,23 @@ static int add_port(struct ib_core_device *coredev, int port_num)return 0 ; err_remove_pkey: -sysfs_remove_group (&p->kobj, &p->pkey_group); +if (p->pkey_group) +sysfs_remove_group (&p->kobj, p->pkey_group); err_free_pkey: -for (i =0 ; i < attr.pkey_tbl_len; ++i) -kfree (p->pkey_group.attrs[i]); +if (p->pkey_group) { +for (i =0 ; i < attr.pkey_tbl_len; ++i) +kfree (p->pkey_group->attrs[i]); -kfree (p->pkey_group.attrs); - p->pkey_group.attrs =NULL ; +kfree (p->pkey_group->attrs); + p->pkey_group->attrs =NULL ; + } + +err_free_pkey_group: +if (p->pkey_group) { +kfree (p->pkey_group); + p->pkey_group =NULL ; + } err_remove_gid_type: sysfs_remove_group(&p->gid_attr_group->kobj,
@@ -1317,7 +1340,8 @@ void ib_free_port_attrs(struct ib_core_device *coredev)if (port->pma_table)sysfs_remove_group (p, port->pma_table); -sysfs_remove_group (p, &port->pkey_group); +if (port->pkey_group) +sysfs_remove_group (p, port->pkey_group);sysfs_remove_group (p, &port->gid_group);sysfs_remove_group (&port->gid_attr_group->kobj, &port->gid_attr_group->ndev);
Signature · 1 line
2.25.4
PATCH 2/7 RDMA/core: Allocate the pkey cache only if the pkey_tbl_len is set
In reply to Kamal HeibAllocate the pkey cache only if the pkey_tbl_len is set by the provider, also add checks to avoid accessing the pkey cache when it not initialized.
--- drivers/infiniband/core/cache.c | 45 +++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 16 deletions(-)
drivers/infiniband/core/cache.c +29 -16
@@ -1054,7 +1054,7 @@ int ib_get_cached_pkey(struct ib_device *device, cache = device->port_data[port_num].cache.pkey; -if (index <0 || index >= cache->table_len) +if (!cache || index <0 || index >= cache->table_len) ret = -EINVAL ;else *pkey = cache->table[index];
@@ -1099,6 +1099,10 @@ int ib_find_cached_pkey(struct ib_device *device,read_lock_irqsave (&device->cache_lock, flags); cache = device->port_data[port_num].cache.pkey; +if (!cache) { + ret = -EINVAL ; + goto err; + } *index =-1 ;
@@ -1117,6 +1121,7 @@ int ib_find_cached_pkey(struct ib_device *device, ret =0 ; } +err:read_unlock_irqrestore (&device->cache_lock, flags);return ret;
@@ -1139,6 +1144,10 @@ int ib_find_exact_cached_pkey(struct ib_device *device,read_lock_irqsave (&device->cache_lock, flags); cache = device->port_data[port_num].cache.pkey; +if (!cache) { + ret = -EINVAL ; + goto err; + } *index =-1 ;
@@ -1149,6 +1158,7 @@ int ib_find_exact_cached_pkey(struct ib_device *device,break ; } +err:read_unlock_irqrestore (&device->cache_lock, flags);return ret;
@@ -1425,23 +1435,26 @@ ib_cache_update(struct ib_device *device, u8 port, bool enforce_security) goto err; } - pkey_cache =kmalloc (struct_size (pkey_cache, table, - tprops->pkey_tbl_len), -GFP_KERNEL ); -if (!pkey_cache) { - ret = -ENOMEM ; - goto err; - } +if (tprops->pkey_tbl_len) { + pkey_cache =kmalloc (struct_size (pkey_cache, table, + tprops->pkey_tbl_len), +GFP_KERNEL ); +if (!pkey_cache) { + ret = -ENOMEM ; + goto err; + } - pkey_cache->table_len = tprops->pkey_tbl_len; + pkey_cache->table_len = tprops->pkey_tbl_len; -for (i =0 ; i < pkey_cache->table_len; ++i) { - ret =ib_query_pkey (device, port, i, pkey_cache->table + i); -if (ret) { -dev_warn (&device->dev, -"ib_query_pkey failed (%d) for index %d\n" , - ret, i); - goto err; +for (i =0 ; i < pkey_cache->table_len; ++i) { + ret =ib_query_pkey (device, port, i, + pkey_cache->table + i); +if (ret) { +dev_warn (&device->dev, +"ib_query_pkey failed (%d) for index %d\n" , + ret, i); + goto err; + } } }
Signature · 1 line
2.25.4
PATCH 3/7 RDMA/core: Remove query_pkey from the mandatory ops
In reply to Kamal HeibThe query_pkey() isn't mandatory for the iwarp providers, so remove this requirement from the RDMA core.
--- drivers/infiniband/core/device.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/infiniband/core/device.c +3 -1
@@ -272,7 +272,6 @@ static void 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 (alloc_pd),IB_MANDATORY_FUNC (dealloc_pd), IB_MANDATORY_FUNC(create_qp),
@@ -2362,6 +2361,9 @@ int ib_query_pkey(struct ib_device *device,if (!rdma_is_port_valid (device, port_num))return -EINVAL ; +if (!device->ops.query_pkey) +return -EOPNOTSUPP ; +return device->ops.query_pkey (device, port_num, index, pkey); }EXPORT_SYMBOL (ib_query_pkey);
Signature · 1 line
2.25.4
PATCH 4/7 RDMA/siw: Remove the query_pkey callback
In reply to Kamal HeibNow that the query_pkey() isn't mandatory by the RDMA core for iwarp providers, this callback can be removed.
--- drivers/infiniband/sw/siw/siw_main.c | 1 - drivers/infiniband/sw/siw/siw_verbs.c | 9 --------- drivers/infiniband/sw/siw/siw_verbs.h | 1 - 3 files changed, 11 deletions(-)
drivers/infiniband/sw/siw/siw_main.c +0 -1
@@ -288,7 +288,6 @@ static const struct ib_device_ops siw_device_ops = { .post_srq_recv = siw_post_srq_recv, .query_device = siw_query_device, .query_gid = siw_query_gid, - .query_pkey = siw_query_pkey, .query_port = siw_query_port, .query_qp = siw_query_qp, .query_srq = siw_query_srq,
drivers/infiniband/sw/siw/siw_verbs.c +0 -9
@@ -176,7 +176,6 @@ int siw_query_port(struct ib_device *base_dev, u8 port, attr->active_mtu =ib_mtu_int_to_enum (sdev->netdev->mtu); attr->phys_state = sdev->state ==IB_PORT_ACTIVE ?IB_PORT_PHYS_STATE_LINK_UP :IB_PORT_PHYS_STATE_DISABLED ; - attr->pkey_tbl_len =1 ; attr->port_cap_flags =IB_PORT_CM_SUP |IB_PORT_DEVICE_MGMT_SUP ; attr->state = sdev->state;/*
@@ -204,20 +203,12 @@ int siw_get_port_immutable(struct ib_device *base_dev, u8 port,if (rv)return rv; - port_immutable->pkey_tbl_len = attr.pkey_tbl_len; port_immutable->gid_tbl_len = attr.gid_tbl_len; port_immutable->core_cap_flags =RDMA_CORE_PORT_IWARP ;return 0 ; } -int siw_query_pkey (struct ib_device *base_dev,u8 port,u16 idx,u16 *pkey) -{ -/* Report the default pkey */ - *pkey =0xffff ; -return 0 ; -} -int siw_query_gid (struct ib_device *base_dev,u8 port,int idx,union ib_gid *gid) {
drivers/infiniband/sw/siw/siw_verbs.h +0 -1
@@ -46,7 +46,6 @@ int siw_create_cq(struct ib_cq *base_cq, const struct ib_cq_init_attr *attr, struct ib_udata *udata);int siw_query_port (struct ib_device *base_dev,u8 port,struct ib_port_attr *attr); -int siw_query_pkey (struct ib_device *base_dev,u8 port,u16 idx,u16 *pkey);int siw_query_gid (struct ib_device *base_dev,u8 port,int idx,union ib_gid *gid);int siw_alloc_pd (struct ib_pd *base_pd,struct ib_udata *udata);
Signature · 1 line
2.25.4
Re: [PATCH for-next v1 4/7] RDMA/siw: Remove the query_pkey callback
-----"Kamal Heib" <[email protected]> wrote: -----
Quoted 86 lines
To: [email protected]
From: "Kamal Heib" <[email protected]>
Date: 07/14/2020 08:34PM
Cc: "Doug Ledford" <[email protected]>, "Jason Gunthorpe" <[email protected]>, "Michal Kalderon" <[email protected]>, "Potnuri Bharat Teja" <[email protected]>, "Shiraz Saleem" <[email protected]>, "Bernard Metzler" <[email protected]>, "Kamal Heib" <[email protected]>
Subject: [EXTERNAL] [PATCH for-next v1 4/7] RDMA/siw: Remove thequery_pkeycallbackNow that the
query_pkey()isn't mandatory by the RDMA core for iwarp providers, this callback can be removed.Signed-off-by Kamal Heib <[email protected]>---
drivers/infiniband/sw/siw/siw_main.c | 1 - drivers/infiniband/sw/siw/siw_verbs.c | 9 --------- drivers/infiniband/sw/siw/siw_verbs.h | 1 - 3 files changed, 11 deletions(-)drivers/infiniband/sw/siw/siw_main.c +0
-1@@ -288,7 +288,6 @@ static const struct ib_device_ops siw_device_ops = { .post_srq_recv = siw_post_srq_recv, .query_device = siw_query_device, .query_gid = siw_query_gid, - .query_pkey = siw_query_pkey, .query_port = siw_query_port, .query_qp = siw_query_qp,.query_srq =
siw_query_srq,drivers/infiniband/sw/siw/siw_verbs.c +0
-1@@ -176,7 +176,6 @@ int siw_query_port(struct ib_device *base_dev, u8 port, attr->active_mtu =ib_mtu_int_to_enum (sdev->netdev->mtu); attr->phys_state = sdev->state ==IB_PORT_ACTIVE ?IB_PORT_PHYS_STATE_LINK_UP :IB_PORT_PHYS_STATE_DISABLED ; - attr->pkey_tbl_len =1 ; attr->port_cap_flags =IB_PORT_CM_SUP |IB_PORT_DEVICE_MGMT_SUP ; attr->state = sdev->state;/*drivers/infiniband/sw/siw/siw_verbs.c +0
-8@@ -204,20 +203,12 @@ int siw_get_port_immutable(struct ib_device *base_dev, u8 port, if (rv)return rv; - port_immutable->pkey_tbl_len = attr.pkey_tbl_len; port_immutable->gid_tbl_len = attr.gid_tbl_len; port_immutable->core_cap_flags =RDMA_CORE_PORT_IWARP ;return 0 ; } -int siw_query_pkey (struct ib_device *base_dev,u8 port,u16 idx,u16 *pkey) -{ -/* Report the default pkey */ - *pkey =0xffff ; -return 0 ; -} - int siw_query_gid(struct ib_device *base_dev, u8 port, int idx,union
ib_gid*gid)
{drivers/infiniband/sw/siw/siw_verbs.h +0
-1@@ -46,7 +46,6 @@ int siw_create_cq(struct ib_cq *base_cq, conststruct ib_cq_init_attr *attr, struct ib_udata *udata);int siw_query_port (struct ib_device *base_dev,u8 port,struct ib_port_attr *attr); -int siw_query_pkey (struct ib_device *base_dev,u8 port,u16 idx,u16 *pkey); int siw_query_gid(struct ib_device *base_dev, u8 port, int idx,union ib_gid *gid);
Quoted 5 lines
int
siw_alloc_pd(struct ib_pd *base_pd, struct ib_udata *udata);Signature · 1 line
2.25.4
Thanks, Kamal!
PATCH 5/7 RDMA/cxgb4: Remove the query_pkey callback
In reply to Kamal HeibNow that the query_pkey() isn't mandatory by the RDMA core for iwarp providers, this callback can be removed.
--- drivers/infiniband/hw/cxgb4/provider.c | 11 ----------- 1 file changed, 11 deletions(-)
drivers/infiniband/hw/cxgb4/provider.c +0 -11
@@ -236,14 +236,6 @@ static int c4iw_allocate_pd(struct ib_pd *pd, struct ib_udata *udata)return 0 ; } -static int c4iw_query_pkey (struct ib_device *ibdev,u8 port,u16 index, -u16 *pkey) -{ -pr_debug ("ibdev %p\n" , ibdev); - *pkey =0 ; -return 0 ; -} -static int c4iw_query_gid (struct ib_device *ibdev,u8 port,int index,union ib_gid *gid) {
@@ -317,7 +309,6 @@ static int c4iw_query_port(struct ib_device *ibdev, u8 port,IB_PORT_DEVICE_MGMT_SUP |IB_PORT_VENDOR_CLASS_SUP |IB_PORT_BOOT_MGMT_SUP ; props->gid_tbl_len =1 ; - props->pkey_tbl_len =1 ; props->max_msg_sz =-1 ;return ret;
@@ -439,7 +430,6 @@ static int c4iw_port_immutable(struct ib_device *ibdev, u8 port_num,if (err)return err; - immutable->pkey_tbl_len = attr.pkey_tbl_len; immutable->gid_tbl_len = attr.gid_tbl_len;return 0 ;
@@ -503,7 +493,6 @@ static const struct ib_device_ops c4iw_dev_ops = { .post_srq_recv = c4iw_post_srq_recv, .query_device = c4iw_query_device, .query_gid = c4iw_query_gid, - .query_pkey = c4iw_query_pkey, .query_port = c4iw_query_port, .query_qp = c4iw_ib_query_qp, .reg_user_mr = c4iw_reg_user_mr,
Signature · 1 line
2.25.4
PATCH 6/7 RDMA/i40iw: Remove the query_pkey callback
In reply to Kamal HeibNow that the query_pkey() isn't mandatory by the RDMA core for iwarp providers, this callback can be removed.
--- drivers/infiniband/hw/i40iw/i40iw_verbs.c | 19 ------------------- 1 file changed, 19 deletions(-)
drivers/infiniband/hw/i40iw/i40iw_verbs.c +0 -19
@@ -101,7 +101,6 @@ static int i40iw_query_port(struct ib_device *ibdev, props->port_cap_flags =IB_PORT_CM_SUP |IB_PORT_REINIT_SUP |IB_PORT_VENDOR_CLASS_SUP |IB_PORT_BOOT_MGMT_SUP ; props->gid_tbl_len =1 ; - props->pkey_tbl_len =1 ; props->active_width =IB_WIDTH_4X ; props->active_speed =1 ; props->max_msg_sz =I40IW_MAX_OUTBOUND_MESSAGE_SIZE ;
@@ -2459,7 +2458,6 @@ static int i40iw_port_immutable(struct ib_device *ibdev, u8 port_num,if (err)return err; - immutable->pkey_tbl_len = attr.pkey_tbl_len; immutable->gid_tbl_len = attr.gid_tbl_len;return 0 ;
@@ -2615,22 +2613,6 @@ static int i40iw_query_gid(struct ib_device *ibdev,return 0 ; } -/** -* i40iw_query_pkey - Query partition key -* @ibdev: device pointer from stack -* @port: port number -* @index: index of pkey -* @pkey: pointer to store the pkey -*/ -static int i40iw_query_pkey (struct ib_device *ibdev, -u8 port, -u16 index, -u16 *pkey) -{ - *pkey =0 ; -return 0 ; -} -static const struct ib_device_ops i40iw_dev_ops = { .owner =THIS_MODULE , .driver_id =RDMA_DRIVER_I40IW ,
@@ -2670,7 +2652,6 @@ static const struct ib_device_ops i40iw_dev_ops = { .post_send = i40iw_post_send, .query_device = i40iw_query_device, .query_gid = i40iw_query_gid, - .query_pkey = i40iw_query_pkey, .query_port = i40iw_query_port, .query_qp = i40iw_query_qp, .reg_user_mr = i40iw_reg_user_mr,
Signature · 1 line
2.25.4
PATCH 7/7 RDMA/qedr: Remove the query_pkey callback
In reply to Kamal HeibNow that the query_pkey() isn't mandatory by the RDMA core for iwarp providers, this callback can be removed from the common ops and moved to the RoCE only ops within the qedr driver.
--- drivers/infiniband/hw/qedr/main.c | 3 +-- drivers/infiniband/hw/qedr/verbs.c | 1 - 2 files changed, 1 insertion(+), 3 deletions(-)
drivers/infiniband/hw/qedr/main.c +1 -2
@@ -110,7 +110,6 @@ static int qedr_iw_port_immutable(struct ib_device *ibdev, u8 port_num,if (err)return err; - immutable->pkey_tbl_len =1 ; immutable->gid_tbl_len =1 ; immutable->core_cap_flags =RDMA_CORE_PORT_IWARP ; immutable->max_mad_size =0 ;
@@ -179,6 +178,7 @@ static int qedr_iw_register_device(struct qedr_dev *dev)static const struct ib_device_ops qedr_roce_dev_ops = { .get_port_immutable = qedr_roce_port_immutable, + .query_pkey = qedr_query_pkey, };static void qedr_roce_register_device (struct qedr_dev *dev)
@@ -221,7 +221,6 @@ static const struct ib_device_ops qedr_dev_ops = { .post_srq_recv = qedr_post_srq_recv, .process_mad = qedr_process_mad, .query_device = qedr_query_device, - .query_pkey = qedr_query_pkey, .query_port = qedr_query_port, .query_qp = qedr_query_qp, .query_srq = qedr_query_srq,
drivers/infiniband/hw/qedr/verbs.c +0 -1
@@ -239,7 +239,6 @@ int qedr_query_port(struct ib_device *ibdev, u8 port, struct ib_port_attr *attr) attr->ip_gids = true;if (rdma_protocol_iwarp (&dev->ibdev,1 )) { attr->gid_tbl_len =1 ; - attr->pkey_tbl_len =1 ; }else { attr->gid_tbl_len =QEDR_MAX_SGID ; attr->pkey_tbl_len =QEDR_ROCE_PKEY_TABLE_LEN ;
Signature · 1 line
2.25.4
Quoted 12 lines
Subject: [PATCH for-next v1 0/7] RDMA: Remove
query_pkeyfrom iwarp providersThis patch set does the following:
1- Avoid exposing the pkeys sysfs entries for iwarp providers. 2- Avoid allocating the pkey cache for iwarp providers.
3- Remove the requirement by RDMA core to implementquery_pkey
by all providers.
4- Remove the implementation ofquery_pkeycallback from iwarp providers.v1: Patch #1: Move the free of the
pkey_groupto the right place.
[...]
Quoted 1 line
RDMA/i40iw: Remove the
query_pkeycallback
i40iw bits look ok. Thanks!
Quoted 9 lines · Kamal Heib
This patch set does the following:
1- Avoid exposing the pkeys sysfs entries for iwarp providers. 2- Avoid allocating the pkey cache for iwarp providers.
3- Remove the requirement by RDMA core to implementquery_pkey
by all providers.
4- Remove the implementation ofquery_pkeycallback from iwarp providers.v1: Patch #1: Move the free of the
pkey_groupto the right place.
Quoted 8 lines
Kamal Heib (7):
RDMA/core: Expose pkeys sysfs files only ifpkey_tbl_lenis set RDMA/core: Allocate the pkey cache only if thepkey_tbl_lenis set RDMA/core: Removequery_pkeyfrom the mandatory ops RDMA/siw: Remove thequery_pkeycallback
RDMA/cxgb4: Remove thequery_pkeycallback
RDMA/i40iw: Remove thequery_pkeycallback
RDMA/qedr: Remove thequery_pkeycallback
Applied to for-next, thanks
Jason