RDMA/bnxt_re: Remove pkey table
Subsystems (2)
PATCH 1/1 RDMA/bnxt_re: Remove pkey table
The RoCE spec requires RoCE devices to support only the default pkey. However the bnxt_re driver maintains 0xFFFF entries pkey table and uses only the first entry. Remove the pkey table and hard code a table of length one hard wired with the default pkey.
--- drivers/infiniband/hw/bnxt_re/ib_verbs.c | 9 +-- drivers/infiniband/hw/bnxt_re/qplib_fp.c | 11 ++- drivers/infiniband/hw/bnxt_re/qplib_res.c | 50 ------------ drivers/infiniband/hw/bnxt_re/qplib_res.h | 7 -- drivers/infiniband/hw/bnxt_re/qplib_sp.c | 99 +---------------------- drivers/infiniband/hw/bnxt_re/qplib_sp.h | 9 --- 6 files changed, 10 insertions(+), 175 deletions(-)
drivers/infiniband/hw/bnxt_re/ib_verbs.c +4 -5
@@ -262,13 +262,12 @@ void bnxt_re_query_fw_str(struct ib_device *ibdev, char *str)int bnxt_re_query_pkey (struct ib_device *ibdev,u32 port_num,u16 index,u16 *pkey) { -struct bnxt_re_dev *rdev =to_bnxt_re_dev (ibdev, ibdev); +if (index >0 ) +return -EINVAL ; -/* Ignore port_num */ + *pkey =IB_DEFAULT_PKEY_FULL ; -memset (pkey,0 ,sizeof (*pkey)); -return bnxt_qplib_get_pkey (&rdev->qplib_res, - &rdev->qplib_res.pkey_tbl, index, pkey); +return 0 ; } int bnxt_re_query_gid(struct ib_device *ibdev, u32 port_num,
drivers/infiniband/hw/bnxt_re/qplib_fp.c +5 -6
@@ -46,6 +46,7 @@#include <linux/delay.h> #include <linux/prefetch.h> #include <linux/if_ether.h> +#include <rdma/ib_mad.h> #include "roce_hsi.h"
@@ -1232,7 +1233,7 @@ int bnxt_qplib_modify_qp(struct bnxt_qplib_res *res, struct bnxt_qplib_qp *qp)struct bnxt_qplib_rcfw *rcfw = res->rcfw;struct cmdq_modify_qp req;struct creq_modify_qp_resp resp; -u16 cmd_flags =0 , pkey; +u16 cmd_flags =0 ;u32 temp32[4 ];u32 bmask;int rc;
@@ -1255,11 +1256,9 @@ int bnxt_qplib_modify_qp(struct bnxt_qplib_res *res, struct bnxt_qplib_qp *qp)if (bmask &CMDQ_MODIFY_QP_MODIFY_MASK_ACCESS ) req.access = qp->access; -if (bmask &CMDQ_MODIFY_QP_MODIFY_MASK_PKEY ) { -if (!bnxt_qplib_get_pkey (res, &res->pkey_tbl, - qp->pkey_index, &pkey)) - req.pkey =cpu_to_le16 (pkey); - } +if (bmask &CMDQ_MODIFY_QP_MODIFY_MASK_PKEY ) + req.pkey =IB_DEFAULT_PKEY_FULL ; +if (bmask &CMDQ_MODIFY_QP_MODIFY_MASK_QKEY ) req.qkey =cpu_to_le32 (qp->qkey);
drivers/infiniband/hw/bnxt_re/qplib_res.c +0 -50
86 lines not on this page · raw message
drivers/infiniband/hw/bnxt_re/qplib_res.h +0 -7
@@ -185,12 +185,6 @@ struct bnxt_qplib_sgid_tbl {u8 *vlan; }; -struct bnxt_qplib_pkey_tbl { -u16 *tbl; -u16 max; -u16 active; -}; -struct bnxt_qplib_dpi {u32 dpi;void __iomem *dbr;
@@ -258,7 +252,6 @@ struct bnxt_qplib_res {struct bnxt_qplib_rcfw *rcfw;struct bnxt_qplib_pd_tbl pd_tbl;struct bnxt_qplib_sgid_tbl sgid_tbl; -struct bnxt_qplib_pkey_tbl pkey_tbl;struct bnxt_qplib_dpi_tbl dpi_tbl;bool prio;bool is_vf;
drivers/infiniband/hw/bnxt_re/qplib_sp.c +1 -98
111 lines not on this page · raw message
drivers/infiniband/hw/bnxt_re/qplib_sp.h +0 -9
@@ -255,15 +255,6 @@ int bnxt_qplib_add_sgid(struct bnxt_qplib_sgid_tbl *sgid_tbl,int bnxt_qplib_update_sgid (struct bnxt_qplib_sgid_tbl *sgid_tbl,struct bnxt_qplib_gid *gid,u16 gid_idx,const u8 *smac); -int bnxt_qplib_get_pkey (struct bnxt_qplib_res *res, -struct bnxt_qplib_pkey_tbl *pkey_tbl,u16 index, -u16 *pkey); -int bnxt_qplib_del_pkey (struct bnxt_qplib_res *res, -struct bnxt_qplib_pkey_tbl *pkey_tbl,u16 *pkey, -bool update); -int bnxt_qplib_add_pkey (struct bnxt_qplib_res *res, -struct bnxt_qplib_pkey_tbl *pkey_tbl,u16 *pkey, -bool update);int bnxt_qplib_get_dev_attr (struct bnxt_qplib_rcfw *rcfw,struct bnxt_qplib_dev_attr *attr,bool vf); int bnxt_qplib_set_func_resources(struct bnxt_qplib_res *res,
Signature · 1 line
2.31.1
Quoted 343 lines
-----Original Message-----
From: Kamal Heib <[email protected]>
Sent: Thursday, November 25, 2021 9:06 AM
To: [email protected]
Cc: Selvin Xavier <[email protected]>; Jason Gunthorpe <[email protected]>; Kamal Heib <[email protected]>
Subject: [PATCH for-next] RDMA/bnxt_re: Remove pkey tableThe RoCE spec requires RoCE devices to support only the default pkey. However the
bnxt_redriver maintains0xFFFFentries pkey table and uses only the first entry. Remove the pkey table and hard code a table of length one hard wired with the default pkey.Signed-off-by Kamal Heib <[email protected]>--- drivers/infiniband/hw/bnxt_re/ib_verbs.c | 9 +-- drivers/infiniband/hw/bnxt_re/qplib_fp.c | 11 ++- drivers/infiniband/hw/bnxt_re/qplib_res.c | 50 ------------ drivers/infiniband/hw/bnxt_re/qplib_res.h | 7 -- drivers/infiniband/hw/bnxt_re/qplib_sp.c | 99 +---------------------- drivers/infiniband/hw/bnxt_re/qplib_sp.h | 9 --- 6 files changed, 10 insertions(+), 175 deletions(-)drivers/infiniband/hw/bnxt_re/ib_verbs.c +4
-5@@ -262,13 +262,12 @@ void bnxt_re_query_fw_str(struct ib_device *ibdev, char *str) int bnxt_re_query_pkey(struct ib_device *ibdev, u32 port_num,u16 index,u16 *pkey) { -struct bnxt_re_dev *rdev =to_bnxt_re_dev (ibdev, ibdev); +if (index >0 ) +return -EINVAL ; -/* Ignore port_num */ + *pkey =IB_DEFAULT_PKEY_FULL ; -memset (pkey,0 ,sizeof (*pkey)); -return bnxt_qplib_get_pkey (&rdev->qplib_res, - &rdev->qplib_res.pkey_tbl, index, pkey); +return 0 ; }int bnxt_re_query_gid(struct
ib_device*ibdev, u32port_num, diff --gita/drivers/infiniband/hw/bnxt_re/qplib_fp.cb/drivers/infiniband/hw/bnxt_re/qplib_fp.c
indexca88849559bf..f6472cca9ec7100644drivers/infiniband/hw/bnxt_re/qplib_fp.c +2
-1@@ -46,6 +46,7 @@#include <linux/delay.h> #include <linux/prefetch.h> #include <linux/if_ether.h> +#include <rdma/ib_mad.h> #include "roce_hsi.h" @@ -1232,7 +1233,7 @@ int bnxt_qplib_modify_qp(struct bnxt_qplib_res *res, struct bnxt_qplib_qp *qp)struct bnxt_qplib_rcfw *rcfw = res->rcfw;struct cmdq_modify_qp req;struct creq_modify_qp_resp resp; -u16 cmd_flags =0 , pkey; +u16 cmd_flags =0 ;u32 temp32[4 ];u32 bmask;drivers/infiniband/hw/bnxt_re/qplib_fp.c +3
-5int rc;@@ -1255,11 +1256,9 @@ int bnxt_qplib_modify_qp(struct bnxt_qplib_res *res, struct bnxt_qplib_qp *qp)if (bmask &CMDQ_MODIFY_QP_MODIFY_MASK_ACCESS ) req.access = qp->access; -if (bmask &CMDQ_MODIFY_QP_MODIFY_MASK_PKEY ) { -if (!bnxt_qplib_get_pkey (res, &res->pkey_tbl, - qp->pkey_index, &pkey)) - req.pkey =cpu_to_le16 (pkey); - } +if (bmask &CMDQ_MODIFY_QP_MODIFY_MASK_PKEY ) + req.pkey =IB_DEFAULT_PKEY_FULL ; +if (bmask &CMDQ_MODIFY_QP_MODIFY_MASK_QKEY ) req.qkey =cpu_to_le32 (qp->qkey);drivers/infiniband/hw/bnxt_re/qplib_res.c +0
-42@@ -649,31 +649,6 @@ static void bnxt_qplib_init_sgid_tbl(struct bnxt_qplib_sgid_tbl *sgid_tbl,memset (sgid_tbl->hw_id,-1 ,sizeof (u16) * sgid_tbl->max); } -static void bnxt_qplib_free_pkey_tbl (struct bnxt_qplib_res *res, -struct bnxt_qplib_pkey_tbl *pkey_tbl) -{ -if (!pkey_tbl->tbl) -dev_dbg (&res->pdev->dev,"PKEY tbl not present\n" ); -else -kfree (pkey_tbl->tbl); - - pkey_tbl->tbl =NULL ; - pkey_tbl->max =0 ; - pkey_tbl->active =0 ; -} - -static int bnxt_qplib_alloc_pkey_tbl (struct bnxt_qplib_res *res, -struct bnxt_qplib_pkey_tbl *pkey_tbl, -u16 max) -{ - pkey_tbl->tbl =kcalloc (max,sizeof (u16),GFP_KERNEL ); -if (!pkey_tbl->tbl) -return -ENOMEM ; - - pkey_tbl->max = max; -return 0 ; -}; -/* PDs */ int bnxt_qplib_alloc_pd (struct bnxt_qplib_pd_tbl *pdt,struct bnxt_qplib_pd *pd) {@@ -843,24 +818,6 @@ static int bnxt_qplib_alloc_dpi_tbl(struct bnxt_qplib_res *res, return -ENOMEM ; } -/* PKEYs */ -static void bnxt_qplib_cleanup_pkey_tbl (struct bnxt_qplib_pkey_tbl *pkey_tbl) -{ -memset (pkey_tbl->tbl,0 ,sizeof (u16) * pkey_tbl->max); - pkey_tbl->active =0 ; -} - -static void bnxt_qplib_init_pkey_tbl (struct bnxt_qplib_res *res, -struct bnxt_qplib_pkey_tbl *pkey_tbl) -{ -u16 pkey =0xFFFF ; - -memset (pkey_tbl->tbl,0 ,sizeof (u16) * pkey_tbl->max); - -/* pkey default = 0xFFFF */ -bnxt_qplib_add_pkey (res, pkey_tbl, &pkey, false); -} -/* Stats */ static void bnxt_qplib_free_stats_ctx (struct pci_dev *pdev, struct bnxt_qplib_stats *stats) @@ -891,21 +848,18 @@ static int bnxt_qplib_alloc_stats_ctx(struct
pci_dev*pdev,void
bnxt_qplib_cleanup_res(struct bnxt_qplib_res *res){drivers/infiniband/hw/bnxt_re/qplib_res.c +0
-3-bnxt_qplib_cleanup_pkey_tbl (&res->pkey_tbl);bnxt_qplib_cleanup_sgid_tbl (res, &res->sgid_tbl); }int bnxt_qplib_init_res (struct bnxt_qplib_res *res) {bnxt_qplib_init_sgid_tbl (&res->sgid_tbl, res->netdev); -bnxt_qplib_init_pkey_tbl (res, &res->pkey_tbl);return 0 ; }void bnxt_qplib_free_res (struct bnxt_qplib_res *res) { -bnxt_qplib_free_pkey_tbl (res, &res->pkey_tbl);bnxt_qplib_free_sgid_tbl (res, &res->sgid_tbl);bnxt_qplib_free_pd_tbl (&res->pd_tbl); bnxt_qplib_free_dpi_tbl(res, &res->dpi_tbl); @@ -924,10 +878,6@@ int bnxt_qplib_alloc_res(struct
bnxt_qplib_res*res, structpci_dev*pdev,drivers/infiniband/hw/bnxt_re/qplib_res.c +0
-1if (rc) goto fail; - rc = bnxt_qplib_alloc_pkey_tbl(res, &res->pkey_tbl, dev_attr-Quoted 1 line
max_pkey);drivers/infiniband/hw/bnxt_re/qplib_res.c +0
-3-if (rc) - goto fail; - rc =bnxt_qplib_alloc_pd_tbl (res, &res->pd_tbl, dev_attr->max_pd);if (rc) goto fail;drivers/infiniband/hw/bnxt_re/qplib_res.h +0
-7@@ -185,12 +185,6 @@ struct bnxt_qplib_sgid_tbl {u8 *vlan; }; -struct bnxt_qplib_pkey_tbl { -u16 *tbl; -u16 max; -u16 active; -}; -struct bnxt_qplib_dpi {u32 dpi;void __iomem *dbr;@@ -258,7 +252,6 @@ struct bnxt_qplib_res {struct bnxt_qplib_rcfw *rcfw;struct bnxt_qplib_pd_tbl pd_tbl;struct bnxt_qplib_sgid_tbl sgid_tbl; -struct bnxt_qplib_pkey_tbl pkey_tbl;struct bnxt_qplib_dpi_tbl dpi_tbl;bool prio;bool is_vf;drivers/infiniband/hw/bnxt_re/qplib_sp.c +1
-11@@ -146,17 +146,7 @@ int bnxt_qplib_get_dev_attr(struct bnxt_qplib_rcfw *rcfw, attr->max_srq =le16_to_cpu (sb->max_srq); attr->max_srq_wqes =le32_to_cpu (sb->max_srq_wr) -1 ; attr->max_srq_sges = sb->max_srq_sge; - attr->max_pkey =le32_to_cpu (sb->max_pkeys); -/* -* Some versions of FW reports more than 0xFFFF. -* Restrict it for now to 0xFFFF to avoid -* reporting trucated value -*/ -if (attr->max_pkey >0xFFFF ) { -/* ib_port_attr::pkey_tbl_len is u16 */ - attr->max_pkey =0xFFFF ; - } - + attr->max_pkey =1 ; attr->max_inline_data =le32_to_cpu (sb->max_inline_data); attr->l2_db_size = (sb->l2_db_space_size + 1) *(
0x01<<RCFW_DBR_BASE_PAGE_SHIFT); @@ -
414,93 +404,6 @@ int bnxt_qplib_update_sgid(structbnxt_qplib_sgid_tbl*sgid_tbl,drivers/infiniband/hw/bnxt_re/qplib_sp.c +0
-33return rc; } -/* pkeys */ -int bnxt_qplib_get_pkey (struct bnxt_qplib_res *res, -struct bnxt_qplib_pkey_tbl *pkey_tbl,u16 index, -u16 *pkey) -{ -if (index ==0xFFFF ) { - *pkey =0xFFFF ; -return 0 ; - } -if (index >= pkey_tbl->max) { -dev_err (&res->pdev->dev, -"Index %d exceeded PKEY table max (%d)\n" , - index, pkey_tbl->max); -return -EINVAL ; - } -memcpy (pkey, &pkey_tbl->tbl[index],sizeof (*pkey)); -return 0 ; -} - -int bnxt_qplib_del_pkey (struct bnxt_qplib_res *res, -struct bnxt_qplib_pkey_tbl *pkey_tbl,u16 *pkey, -bool update) -{ -int i, rc =0 ; - -if (!pkey_tbl) { -dev_err (&res->pdev->dev,"PKEY table not allocated\n" ); -return -EINVAL ; - } - -/* Do we need a pkey_lock here? */ -if (!pkey_tbl->active) { - dev_err(&res->pdev->dev, "PKEY table has no activeentries\n");
drivers/infiniband/hw/bnxt_re/qplib_sp.c +0
-9-return -ENOMEM ; - } -for (i =0 ; i < pkey_tbl->max; i++) { -if (!memcmp (&pkey_tbl->tbl[i], pkey,sizeof (*pkey))) -break ; - } -if (i == pkey_tbl->max) { - dev_err(&res->pdev->dev, - "PKEY 0x%04x not found in the pkey table\n",*pkey);
drivers/infiniband/hw/bnxt_re/qplib_sp.c +0
-45-return -ENOMEM ; - } -memset (&pkey_tbl->tbl[i],0 ,sizeof (*pkey)); - pkey_tbl->active--; - -/* unlock */ -return rc; -} - -int bnxt_qplib_add_pkey (struct bnxt_qplib_res *res, -struct bnxt_qplib_pkey_tbl *pkey_tbl,u16 *pkey, -bool update) -{ -int i, free_idx, rc =0 ; - -if (!pkey_tbl) { -dev_err (&res->pdev->dev,"PKEY table not allocated\n" ); -return -EINVAL ; - } - -/* Do we need a pkey_lock here? */ -if (pkey_tbl->active == pkey_tbl->max) { -dev_err (&res->pdev->dev,"PKEY table is full\n" ); -return -ENOMEM ; - } - free_idx = pkey_tbl->max; -for (i =0 ; i < pkey_tbl->max; i++) { -if (!memcmp (&pkey_tbl->tbl[i], pkey,sizeof (*pkey))) -return -EALREADY ; -else if (!pkey_tbl->tbl[i] && free_idx == pkey_tbl->max) - free_idx = i; - } -if (free_idx == pkey_tbl->max) { -dev_err (&res->pdev->dev, -"PKEY table is FULL but count is not MAX??\n" ); -return -ENOMEM ; - } -/* Add PKEY to the pkey_tbl */ -memcpy (&pkey_tbl->tbl[free_idx], pkey,sizeof (*pkey)); - pkey_tbl->active++; - -/* unlock */ -return rc; -} -/* AH */ int bnxt_qplib_create_ah(struct bnxt_qplib_res *res, struct bnxt_qplib_ah*ah,
drivers/infiniband/hw/bnxt_re/qplib_sp.c +0
-0bool block)drivers/infiniband/hw/bnxt_re/qplib_sp.h +0
-2@@ -255,15 +255,6 @@ int bnxt_qplib_add_sgid(struct bnxt_qplib_sgid_tbl *sgid_tbl, int bnxt_qplib_update_sgid(struct bnxt_qplib_sgid_tbl *sgid_tbl,struct bnxt_qplib_gid *gid,u16 gid_idx,const u8 *smac); -int bnxt_qplib_get_pkey(struct bnxt_qplib_res *res, - struct bnxt_qplib_pkey_tbl *pkey_tbl, u16 index,
drivers/infiniband/hw/bnxt_re/qplib_sp.h int bnxt_qplib_add_sgid(struct bnxt_qplib_sgid_tbl · line 260
Quoted 10 lines
drivers/infiniband/hw/bnxt_re/qplib_sp.h +0
-7- u16 *pkey); -int bnxt_qplib_del_pkey (struct bnxt_qplib_res *res, -struct bnxt_qplib_pkey_tbl *pkey_tbl,u16 *pkey, -bool update); -int bnxt_qplib_add_pkey (struct bnxt_qplib_res *res, -struct bnxt_qplib_pkey_tbl *pkey_tbl,u16 *pkey, -bool update);int bnxt_qplib_get_dev_attr (struct bnxt_qplib_rcfw *rcfw, struct bnxt_qplib_dev_attr *attr, bool vf); int bnxt_qplib_set_func_resources(struct bnxt_qplib_res *res,
Looks good to me.
Quoted 2 lines
--
2.31.1
Quoted 7 lines · Kamal Heib
The RoCE spec requires RoCE devices to support only the default pkey. However the
bnxt_redriver maintains0xFFFFentries pkey table and uses only the first entry. Remove the pkey table and hard code a table of length one hard wired with the default pkey.Signed-off-by Kamal Heib <[email protected]>Reviewed-by Devesh Sharma <[email protected]>
Quoted 8 lines
--- drivers/infiniband/hw/bnxt_re/ib_verbs.c | 9 +-- drivers/infiniband/hw/bnxt_re/qplib_fp.c | 11 ++- drivers/infiniband/hw/bnxt_re/qplib_res.c | 50 ------------ drivers/infiniband/hw/bnxt_re/qplib_res.h | 7 -- drivers/infiniband/hw/bnxt_re/qplib_sp.c | 99 +---------------------- drivers/infiniband/hw/bnxt_re/qplib_sp.h | 9 --- 6 files changed, 10 insertions(+), 175 deletions(-)
Applied to for-next, thanks
Jason