Small fix and code refactoring for mlx5
Subsystems (4)
cover Small fix and code refactoring for mlx5
Hi Doug,
These two patches are intended for rdna-next and related to mlx5 only.
Despite the fact that these patches were tested and found that no merge conflict is expected between IB and net parts of mlx5 driver, we would like to ask you to take into your tree this refactored code.
Such move will give us enough time to respond in case other developers (non-Mellanox) will send patches in that area and will cause to merge conflicts during Linus's merge window.
Thanks
Artemy Kovalyov (2):
IB/mlx5: Fix MODIFY_QP command input structure
{net, IB}/mlx5: Refactor internal SRQ API
drivers/infiniband/hw/mlx5/srq.c | 102 ++++------ drivers/net/ethernet/mellanox/mlx5/core/srq.c | 265 ++++++++++++++------------ include/linux/mlx5/driver.h | 6 +- include/linux/mlx5/qp.h | 5 +- include/linux/mlx5/srq.h | 25 +++ 5 files changed, 218 insertions(+), 185 deletions(-)
Signature · 6 lines
2.1.4 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 1466166812-730-1-git-send-email-leon-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org
PATCH 1/2 IB/mlx5: Fix MODIFY_QP command input structure
From: Artemy Kovalyov <artemyko-VPRAkNaXOzVWk0Htik3J/[email protected]>
Make MODIFY_QP command input structure compliant to specification
--- include/linux/mlx5/qp.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
include/linux/mlx5/qp.h +3 -2
@@ -556,10 +556,11 @@ struct mlx5_destroy_qp_mbox_out {struct mlx5_modify_qp_mbox_in {struct mlx5_inbox_hdr hdr;__be32 qpn; -u8 rsvd1[4 ]; -__be32 optparam;u8 rsvd0[4 ]; +__be32 optparam; +u8 rsvd1[4 ];struct mlx5_qp_context ctx; +u8 rsvd2[16 ]; };struct mlx5_modify_qp_mbox_out {
Signature · 6 lines
2.1.4 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 2/2 {net, IB}/mlx5: Refactor internal SRQ API
In reply to a message not in the archiveFrom: Artemy Kovalyov <artemyko-VPRAkNaXOzVWk0Htik3J/[email protected]>
Currently, the SRQ API uses the obsolete mlx5_*_srq_mbox_{in,out} structs which limit the ability to pass the SRQ attributes between net and IB parts of the driver.
This patch changes the SRQ API so as to use auto-generated structs and provides a better way to pass attributes which will be in use by coming features.
--- drivers/infiniband/hw/mlx5/srq.c | 102 ++++------ drivers/net/ethernet/mellanox/mlx5/core/srq.c | 265 ++++++++++++++------------ include/linux/mlx5/driver.h | 6 +- include/linux/mlx5/srq.h | 25 +++ 4 files changed, 215 insertions(+), 183 deletions(-)
drivers/infiniband/hw/mlx5/srq.c +40 -62
@@ -74,14 +74,12 @@ static void mlx5_ib_srq_event(struct mlx5_core_srq *srq, enum mlx5_event type) }static int create_srq_user (struct ib_pd *pd,struct mlx5_ib_srq *srq, -struct mlx5_create_srq_mbox_in **in, -struct ib_udata *udata,int buf_size,int *inlen, -int is_xrc) +struct mlx5_srq_attr *in, +struct ib_udata *udata,int buf_size) {struct mlx5_ib_dev *dev =to_mdev (pd->device);struct mlx5_ib_create_srq ucmd = {};size_t ucmdlen; -void *xsrqc;int err;int npages;int page_shift;
@@ -104,7 +102,7 @@ static int create_srq_user(struct ib_pd *pd, struct mlx5_ib_srq *srq, udata->inlen - sizeof(ucmd)))return -EINVAL ; -if (is_xrc) { +if (in->type ==IB_SRQT_XRC ) { err =get_srq_user_index (to_mucontext (pd->uobject->context), &ucmd, udata->inlen, &uidx);if (err)
@@ -130,14 +128,13 @@ static int create_srq_user(struct ib_pd *pd, struct mlx5_ib_srq *srq, goto err_umem; } - *inlen =sizeof (**in) +sizeof (*(*in)->pas) * ncont; - *in =mlx5_vzalloc (*inlen); -if (!(*in)) { + in->pas =mlx5_vzalloc (sizeof (*in->pas) * ncont); +if (!in->pas) { err = -ENOMEM ; goto err_umem; } -mlx5_ib_populate_pas (dev, srq->umem, page_shift, (*in)->pas,0 ); +mlx5_ib_populate_pas (dev, srq->umem, page_shift, in->pas,0 ); err =mlx5_ib_db_map_user (to_mucontext (pd->uobject->context), ucmd.db_addr, &srq->db);
@@ -146,20 +143,16 @@ static int create_srq_user(struct ib_pd *pd, struct mlx5_ib_srq *srq, goto err_in; } - (*in)->ctx.log_pg_sz = page_shift -MLX5_ADAPTER_PAGE_SHIFT ; - (*in)->ctx.pgoff_cqn =cpu_to_be32 (offset <<26 ); - -if ((MLX5_CAP_GEN (dev->mdev, cqe_version) ==MLX5_CQE_VERSION_V1 ) && - is_xrc){ - xsrqc =MLX5_ADDR_OF (create_xrc_srq_in, *in, - xrc_srq_context_entry); -MLX5_SET (xrc_srqc, xsrqc, user_index, uidx); - } + in->log_page_size = page_shift -MLX5_ADAPTER_PAGE_SHIFT ; + in->page_offset = offset; +if (MLX5_CAP_GEN (dev->mdev, cqe_version) ==MLX5_CQE_VERSION_V1 && + in->type ==IB_SRQT_XRC ) + in->user_index = uidx;return 0 ; err_in: -kvfree (*in); +kvfree (in->pas); err_umem:ib_umem_release (srq->umem);
@@ -168,15 +161,13 @@ err_umem: }static int create_srq_kernel (struct mlx5_ib_dev *dev,struct mlx5_ib_srq *srq, -struct mlx5_create_srq_mbox_in **in,int buf_size, -int *inlen,int is_xrc) +struct mlx5_srq_attr *in,int buf_size) {int err;int i;struct mlx5_wqe_srq_next_seg *next;int page_shift;int npages; -void *xsrqc; err =mlx5_db_alloc (dev->mdev, &srq->db);if (err) {
@@ -204,13 +195,12 @@ static int create_srq_kernel(struct mlx5_ib_dev *dev, struct mlx5_ib_srq *srq, npages =DIV_ROUND_UP (srq->buf.npages,1 << (page_shift -PAGE_SHIFT ));mlx5_ib_dbg (dev,"buf_size %d, page_shift %d, npages %d, calc npages %d\n" , buf_size, page_shift, srq->buf.npages, npages); - *inlen =sizeof (**in) +sizeof (*(*in)->pas) * npages; - *in =mlx5_vzalloc (*inlen); -if (!*in) { + in->pas =mlx5_vzalloc (sizeof (*in->pas) * npages); +if (!in->pas) { err = -ENOMEM ; goto err_buf; } -mlx5_fill_page_array (&srq->buf, (*in)->pas); +mlx5_fill_page_array (&srq->buf, in->pas); srq->wrid =kmalloc (srq->msrq.max *sizeof (u64),GFP_KERNEL );if (!srq->wrid) {
@@ -221,20 +211,15 @@ static int create_srq_kernel(struct mlx5_ib_dev *dev, struct mlx5_ib_srq *srq, } srq->wq_sig = !!srq_signature; - (*in)->ctx.log_pg_sz = page_shift -MLX5_ADAPTER_PAGE_SHIFT ; - -if ((MLX5_CAP_GEN (dev->mdev, cqe_version) ==MLX5_CQE_VERSION_V1 ) && - is_xrc){ - xsrqc =MLX5_ADDR_OF (create_xrc_srq_in, *in, - xrc_srq_context_entry); -/* 0xffffff means we ask to work with cqe version 0 */ -MLX5_SET (xrc_srqc, xsrqc, user_index,MLX5_IB_DEFAULT_UIDX ); - } + in->log_page_size = page_shift -MLX5_ADAPTER_PAGE_SHIFT ; +if (MLX5_CAP_GEN (dev->mdev, cqe_version) ==MLX5_CQE_VERSION_V1 && + in->type ==IB_SRQT_XRC ) + in->user_index =MLX5_IB_DEFAULT_UIDX ;return 0 ; err_in: -kvfree (*in); +kvfree (in->pas); err_buf:mlx5_buf_free (dev->mdev, &srq->buf);
@@ -267,10 +252,7 @@ struct ib_srq *mlx5_ib_create_srq(struct ib_pd *pd,int desc_size;int buf_size;int err; -struct mlx5_create_srq_mbox_in *uninitialized_var (in ); -int uninitialized_var (inlen ); -int is_xrc; -u32 flgs, xrcdn; +struct mlx5_srq_attr in = {0 };__u32 max_srq_wqes =1 <<MLX5_CAP_GEN (dev->mdev, log_max_srq_sz);/* Sanity check SRQ size before proceeding */
@@ -302,14 +284,10 @@ struct ib_srq *mlx5_ib_create_srq(struct ib_pd *pd, desc_size, init_attr->attr.max_wr, srq->msrq.max, srq->msrq.max_gs, srq->msrq.max_avail_gather); - is_xrc = (init_attr->srq_type ==IB_SRQT_XRC ); -if (pd->uobject) - err =create_srq_user (pd, srq, &in, udata, buf_size, &inlen, - is_xrc); + err =create_srq_user (pd, srq, &in, udata, buf_size);else - err =create_srq_kernel (dev, srq, &in, buf_size, &inlen, - is_xrc); + err =create_srq_kernel (dev, srq, &in, buf_size);if (err) { mlx5_ib_warn(dev, "create srq %s failed, err %d\n",
@@ -317,23 +295,23 @@ struct ib_srq *mlx5_ib_create_srq(struct ib_pd *pd, goto err_srq; } - in->ctx.state_log_sz =ilog2 (srq->msrq.max); - flgs = ((srq->msrq.wqe_shift -4 ) | (is_xrc <<5 ) | (srq->wq_sig <<7 )) <<24 ; - xrcdn =0 ; -if (is_xrc) { - xrcdn =to_mxrcd (init_attr->ext.xrc.xrcd)->xrcdn; - in->ctx.pgoff_cqn |=cpu_to_be32 (to_mcq (init_attr->ext.xrc.cq)->mcq.cqn); + in.type = init_attr->srq_type; + in.log_size =ilog2 (srq->msrq.max); + in.wqe_shift = srq->msrq.wqe_shift -4 ; +if (srq->wq_sig) + in.flags |=MLX5_SRQ_FLAG_WQ_SIG ; +if (init_attr->srq_type ==IB_SRQT_XRC ) { + in.xrcd =to_mxrcd (init_attr->ext.xrc.xrcd)->xrcdn; + in.cqn =to_mcq (init_attr->ext.xrc.cq)->mcq.cqn; }else if (init_attr->srq_type ==IB_SRQT_BASIC ) { - xrcdn =to_mxrcd (dev->devr.x0)->xrcdn; - in->ctx.pgoff_cqn |=cpu_to_be32 (to_mcq (dev->devr.c0)->mcq.cqn); + in.xrcd =to_mxrcd (dev->devr.x0)->xrcdn; + in.cqn =to_mcq (dev->devr.c0)->mcq.cqn; } - in->ctx.flags_xrcd =cpu_to_be32 ((flgs &0xFF000000 ) | (xrcdn &0xFFFFFF )); - - in->ctx.pd =cpu_to_be32 (to_mpd (pd)->pdn); - in->ctx.db_record =cpu_to_be64 (srq->db.dma); - err =mlx5_core_create_srq (dev->mdev, &srq->msrq, in, inlen, is_xrc); -kvfree (in); + in.pd =to_mpd (pd)->pdn; + in.db_record = srq->db.dma; + err =mlx5_core_create_srq (dev->mdev, &srq->msrq, &in); +kvfree (in.pas);if (err) {mlx5_ib_dbg (dev,"create SRQ failed, err %d\n" , err); goto err_usr_kern_srq;
@@ -401,7 +379,7 @@ int mlx5_ib_query_srq(struct ib_srq *ibsrq, struct ib_srq_attr *srq_attr)struct mlx5_ib_dev *dev =to_mdev (ibsrq->device);struct mlx5_ib_srq *srq =to_msrq (ibsrq);int ret; -struct mlx5_query_srq_mbox_out *out; +struct mlx5_srq_attr *out; out =kzalloc (sizeof (*out),GFP_KERNEL );if (!out)
@@ -411,7 +389,7 @@ int mlx5_ib_query_srq(struct ib_srq *ibsrq, struct ib_srq_attr *srq_attr)if (ret) goto out_box; - srq_attr->srq_limit =be16_to_cpu (out->ctx.lwm); + srq_attr->srq_limit = out->lwm; srq_attr->max_wr = srq->msrq.max -1 ; srq_attr->max_sge = srq->msrq.max_gs;
drivers/net/ethernet/mellanox/mlx5/core/srq.c +147 -118
411 lines not on this page · raw message
include/linux/mlx5/driver.h +3 -3
@@ -46,6 +46,7 @@#include <linux/mlx5/device.h> #include <linux/mlx5/doorbell.h> +#include <linux/mlx5/srq.h> enum {MLX5_RQ_BITMASK_VSD =1 <<1 ,
@@ -772,11 +773,10 @@ struct mlx5_cmd_mailbox *mlx5_alloc_cmd_mailbox_chain(struct mlx5_core_dev *dev,void mlx5_free_cmd_mailbox_chain (struct mlx5_core_dev *dev,struct mlx5_cmd_mailbox *head);int mlx5_core_create_srq (struct mlx5_core_dev *dev,struct mlx5_core_srq *srq, -struct mlx5_create_srq_mbox_in *in,int inlen, -int is_xrc); +struct mlx5_srq_attr *in);int mlx5_core_destroy_srq (struct mlx5_core_dev *dev,struct mlx5_core_srq *srq);int mlx5_core_query_srq (struct mlx5_core_dev *dev,struct mlx5_core_srq *srq, -struct mlx5_query_srq_mbox_out *out); +struct mlx5_srq_attr *out);int mlx5_core_arm_srq (struct mlx5_core_dev *dev,struct mlx5_core_srq *srq,u16 lwm,int is_srq);void mlx5_init_mkey_table (struct mlx5_core_dev *dev);
include/linux/mlx5/srq.h +25 -0
@@ -35,6 +35,31 @@#include <linux/mlx5/driver.h> +enum { +MLX5_SRQ_FLAG_ERR = (1 <<0 ), +MLX5_SRQ_FLAG_WQ_SIG = (1 <<1 ), +}; + +struct mlx5_srq_attr { +u32 type; +u32 flags; +u32 log_size; +u32 wqe_shift; +u32 log_page_size; +u32 wqe_cnt; +u32 srqn; +u32 xrcd; +u32 page_offset; +u32 cqn; +u32 pd; +u32 lwm; +u32 user_index; +u64 db_record; +u64 *pas; +}; + +struct mlx5_core_dev ; +void mlx5_init_srq_table (struct mlx5_core_dev *dev);void mlx5_cleanup_srq_table (struct mlx5_core_dev *dev);
Signature · 6 lines
2.1.4 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 20 lines · Leon Romanovsky
Hi Doug,
These two patches are intended for rdna-next and related to mlx5 only.
Despite the fact that these patches were tested and found that no merge conflict is expected between IB and net parts of mlx5 driver, we would like to ask you to take into your tree this refactored code.
Such move will give us enough time to respond in case other developers (non-Mellanox) will send patches in that area and will cause to merge conflicts during Linus's merge window.
Thanks
Artemy Kovalyov (2):
IB/mlx5: FixMODIFY_QPcommand input structure {net, IB}/mlx5: Refactor internal SRQ API
Quoted 7 lines
drivers/infiniband/hw/mlx5/srq.c | 102 ++++------ drivers/net/ethernet/mellanox/mlx5/core/srq.c | 265 ++++++++++++++------------ include/linux/mlx5/driver.h | 6 +- include/linux/mlx5/qp.h | 5 +- include/linux/mlx5/srq.h | 25 +++ 5 files changed, 218 insertions(+), 185 deletions(-)
I had to fix up the fist patch to apply, but the second worked fine. Series applied for 4.8, thanks.
Signature · 2 lines
Doug Ledford <[email protected]> GPG KeyID: 0E572FDD