diff mbox

shrink struct ib_send_wr V3

Message ID 55E33CBC.3090000@dev.mellanox.co.il (mailing list archive)
State Not Applicable
Headers show

Commit Message

Sagi Grimberg Aug. 30, 2015, 5:26 p.m. UTC
On 8/30/2015 6:31 PM, Sagi Grimberg wrote:
>>   - patch 2 now explicitly replaces the weird overloading in the mlx5
>>     driver with an explicit embedding of struct ib_send_wr, similar
>>     to what we do for all other MRs.
>
> That's nice,
>
> There is one non-trivial spot that was missed in mlx5_ib_post_send
> though:
>
> diff --git a/drivers/infiniband/hw/mlx5/qp.c
> b/drivers/infiniband/hw/mlx5/qp.c
> index 7ddfb74..35a18d6 100644
> --- a/drivers/infiniband/hw/mlx5/qp.c
> +++ b/drivers/infiniband/hw/mlx5/qp.c
> @@ -2802,7 +2802,7 @@ int mlx5_ib_post_send(struct ib_qp *ibqp, struct
> ib_send_wr *wr,
>                                  goto out;
>                          }
>                          qp->sq.wr_data[idx] = MLX5_IB_WR_UMR;
> -                       ctrl->imm = cpu_to_be32(fast_reg_wr(wr)->rkey);
> +                       ctrl->imm = cpu_to_be32(umr_wr(wr)->mkey);
>                          set_reg_umr_segment(seg, wr);
>                          seg += sizeof(struct mlx5_wqe_umr_ctrl_seg);
>                          size += sizeof(struct mlx5_wqe_umr_ctrl_seg) / 16;
>
> Care to fold this in?
>

There is another problem I'm seeing in this patch. in reg_umr the
local variable is a type ib_send_wr which is passed to
prep_umr_reg_wqe() which casts it to mlx5_umr_wr (container_of). It
should have probably been mlx5_umr_wr to begin with...

I think this needs to be folded in as well:
         int size;
@@ -798,14 +799,14 @@ static struct mlx5_ib_mr *reg_umr(struct ib_pd 
*pd, struct ib_umem *umem,
                 goto free_pas;
         }

-       memset(&wr, 0, sizeof(wr));
-       wr.wr_id = (u64)(unsigned long)&umr_context;
-       prep_umr_reg_wqe(pd, &wr, &sg, dma, npages, mr->mmr.key, page_shift,
-                        virt_addr, len, access_flags);
+       memset(&umrwr, 0, sizeof(umrwr));
+       umrwr.wr.wr_id = (u64)(unsigned long)&umr_context;
+       prep_umr_reg_wqe(pd, &umrwr.wr, &sg, dma, npages, mr->mmr.key,
+                        page_shift, virt_addr, len, access_flags);

         mlx5_ib_init_umr_context(&umr_context);
         down(&umrc->sem);
-       err = ib_post_send(umrc->qp, &wr, &bad);
+       err = ib_post_send(umrc->qp, &umrwr.wr, &bad);
         if (err) {
                 mlx5_ib_warn(dev, "post send failed, err %d\n", err);
                 goto unmap_dma;
@@ -1134,16 +1135,17 @@ static int unreg_umr(struct mlx5_ib_dev *dev, 
struct mlx5_ib_mr *mr)
  {
         struct umr_common *umrc = &dev->umrc;
         struct mlx5_ib_umr_context umr_context;
-       struct ib_send_wr wr, *bad;
+       struct mlx5_umr_wr umrwr;
+       struct ib_send_wr *bad;
         int err;

-       memset(&wr, 0, sizeof(wr));
-       wr.wr_id = (u64)(unsigned long)&umr_context;
-       prep_umr_unreg_wqe(dev, &wr, mr->mmr.key);
+       memset(&umrwr, 0, sizeof(umrwr));
+       umrwr.wr.wr_id = (u64)(unsigned long)&umr_context;
+       prep_umr_unreg_wqe(dev, &umrwr.wr, mr->mmr.key);

         mlx5_ib_init_umr_context(&umr_context);
         down(&umrc->sem);
-       err = ib_post_send(umrc->qp, &wr, &bad);
+       err = ib_post_send(umrc->qp, &umrwr.wr, &bad);
         if (err) {
                 up(&umrc->sem);
                 mlx5_ib_dbg(dev, "err %d\n", err);
--
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/infiniband/hw/mlx5/mr.c 
b/drivers/infiniband/hw/mlx5/mr.c
index 9fac2c1..6f8f3d8 100644
--- a/drivers/infiniband/hw/mlx5/mr.c
+++ b/drivers/infiniband/hw/mlx5/mr.c
@@ -752,7 +752,8 @@  static struct mlx5_ib_mr *reg_umr(struct ib_pd *pd, 
struct ib_umem *umem,
         struct device *ddev = dev->ib_dev.dma_device;
         struct umr_common *umrc = &dev->umrc;
         struct mlx5_ib_umr_context umr_context;
-       struct ib_send_wr wr, *bad;
+       struct mlx5_umr_wr umrwr;
+       struct ib_send_wr *bad;
         struct mlx5_ib_mr *mr;
         struct ib_sge sg;