Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

RDMA: Group create AH arguments in struct

Following patch adds additional argument to the create AH function, so it
make sense to group ah_attr and flags arguments in struct.

Link: https://lore.kernel.org/r/20200430192146.12863-13-maorg@mellanox.com
Signed-off-by: Maor Gottlieb <maorg@mellanox.com>
Acked-by: Devesh Sharma <devesh.sharma@broadcom.com>
Acked-by: Gal Pressman <galpress@amazon.com>
Acked-by: Weihang Li <liweihang@huawei.com>
Reviewed-by: Jason Gunthorpe <jgg@mellanox.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>

authored by

Maor Gottlieb and committed by
Jason Gunthorpe
fa5d010c 451c9fc7

+66 -47
+4 -1
drivers/infiniband/core/verbs.c
··· 502 502 u32 flags, 503 503 struct ib_udata *udata) 504 504 { 505 + struct rdma_ah_init_attr init_attr = {}; 505 506 struct ib_device *device = pd->device; 506 507 struct ib_ah *ah; 507 508 int ret; ··· 522 521 ah->pd = pd; 523 522 ah->type = ah_attr->type; 524 523 ah->sgid_attr = rdma_update_sgid_attr(ah_attr, NULL); 524 + init_attr.ah_attr = ah_attr; 525 + init_attr.flags = flags; 525 526 526 - ret = device->ops.create_ah(ah, ah_attr, flags, udata); 527 + ret = device->ops.create_ah(ah, &init_attr, udata); 527 528 if (ret) { 528 529 kfree(ah); 529 530 return ERR_PTR(ret);
+5 -3
drivers/infiniband/hw/bnxt_re/ib_verbs.c
··· 631 631 return nw_type; 632 632 } 633 633 634 - int bnxt_re_create_ah(struct ib_ah *ib_ah, struct rdma_ah_attr *ah_attr, 635 - u32 flags, struct ib_udata *udata) 634 + int bnxt_re_create_ah(struct ib_ah *ib_ah, struct rdma_ah_init_attr *init_attr, 635 + struct ib_udata *udata) 636 636 { 637 637 struct ib_pd *ib_pd = ib_ah->pd; 638 638 struct bnxt_re_pd *pd = container_of(ib_pd, struct bnxt_re_pd, ib_pd); 639 + struct rdma_ah_attr *ah_attr = init_attr->ah_attr; 639 640 const struct ib_global_route *grh = rdma_ah_read_grh(ah_attr); 640 641 struct bnxt_re_dev *rdev = pd->rdev; 641 642 const struct ib_gid_attr *sgid_attr; ··· 674 673 675 674 memcpy(ah->qplib_ah.dmac, ah_attr->roce.dmac, ETH_ALEN); 676 675 rc = bnxt_qplib_create_ah(&rdev->qplib_res, &ah->qplib_ah, 677 - !(flags & RDMA_CREATE_AH_SLEEPABLE)); 676 + !(init_attr->flags & 677 + RDMA_CREATE_AH_SLEEPABLE)); 678 678 if (rc) { 679 679 ibdev_err(&rdev->ibdev, "Failed to allocate HW AH"); 680 680 return rc;
+1 -1
drivers/infiniband/hw/bnxt_re/ib_verbs.h
··· 170 170 u8 port_num); 171 171 int bnxt_re_alloc_pd(struct ib_pd *pd, struct ib_udata *udata); 172 172 void bnxt_re_dealloc_pd(struct ib_pd *pd, struct ib_udata *udata); 173 - int bnxt_re_create_ah(struct ib_ah *ah, struct rdma_ah_attr *ah_attr, u32 flags, 173 + int bnxt_re_create_ah(struct ib_ah *ah, struct rdma_ah_init_attr *init_attr, 174 174 struct ib_udata *udata); 175 175 int bnxt_re_modify_ah(struct ib_ah *ah, struct rdma_ah_attr *ah_attr); 176 176 int bnxt_re_query_ah(struct ib_ah *ah, struct rdma_ah_attr *ah_attr);
+1 -2
drivers/infiniband/hw/efa/efa.h
··· 153 153 struct vm_area_struct *vma); 154 154 void efa_mmap_free(struct rdma_user_mmap_entry *rdma_entry); 155 155 int efa_create_ah(struct ib_ah *ibah, 156 - struct rdma_ah_attr *ah_attr, 157 - u32 flags, 156 + struct rdma_ah_init_attr *init_attr, 158 157 struct ib_udata *udata); 159 158 void efa_destroy_ah(struct ib_ah *ibah, u32 flags); 160 159 int efa_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *qp_attr,
+3 -3
drivers/infiniband/hw/efa/efa_verbs.c
··· 1639 1639 } 1640 1640 1641 1641 int efa_create_ah(struct ib_ah *ibah, 1642 - struct rdma_ah_attr *ah_attr, 1643 - u32 flags, 1642 + struct rdma_ah_init_attr *init_attr, 1644 1643 struct ib_udata *udata) 1645 1644 { 1645 + struct rdma_ah_attr *ah_attr = init_attr->ah_attr; 1646 1646 struct efa_dev *dev = to_edev(ibah->device); 1647 1647 struct efa_com_create_ah_params params = {}; 1648 1648 struct efa_ibv_create_ah_resp resp = {}; ··· 1650 1650 struct efa_ah *ah = to_eah(ibah); 1651 1651 int err; 1652 1652 1653 - if (!(flags & RDMA_CREATE_AH_SLEEPABLE)) { 1653 + if (!(init_attr->flags & RDMA_CREATE_AH_SLEEPABLE)) { 1654 1654 ibdev_dbg(&dev->ibdev, 1655 1655 "Create address handle is not supported in atomic context\n"); 1656 1656 err = -EOPNOTSUPP;
+3 -2
drivers/infiniband/hw/hns/hns_roce_ah.c
··· 39 39 #define HNS_ROCE_VLAN_SL_BIT_MASK 7 40 40 #define HNS_ROCE_VLAN_SL_SHIFT 13 41 41 42 - int hns_roce_create_ah(struct ib_ah *ibah, struct rdma_ah_attr *ah_attr, 43 - u32 flags, struct ib_udata *udata) 42 + int hns_roce_create_ah(struct ib_ah *ibah, struct rdma_ah_init_attr *init_attr, 43 + struct ib_udata *udata) 44 44 { 45 45 struct hns_roce_dev *hr_dev = to_hr_dev(ibah->device); 46 46 const struct ib_gid_attr *gid_attr; 47 47 struct device *dev = hr_dev->dev; 48 48 struct hns_roce_ah *ah = to_hr_ah(ibah); 49 + struct rdma_ah_attr *ah_attr = init_attr->ah_attr; 49 50 const struct ib_global_route *grh = rdma_ah_read_grh(ah_attr); 50 51 u16 vlan_id = 0xffff; 51 52 bool vlan_en = false;
+2 -2
drivers/infiniband/hw/hns/hns_roce_device.h
··· 1208 1208 unsigned long obj, int cnt, 1209 1209 int rr); 1210 1210 1211 - int hns_roce_create_ah(struct ib_ah *ah, struct rdma_ah_attr *ah_attr, 1212 - u32 flags, struct ib_udata *udata); 1211 + int hns_roce_create_ah(struct ib_ah *ah, struct rdma_ah_init_attr *init_attr, 1212 + struct ib_udata *udata); 1213 1213 int hns_roce_query_ah(struct ib_ah *ibah, struct rdma_ah_attr *ah_attr); 1214 1214 void hns_roce_destroy_ah(struct ib_ah *ah, u32 flags); 1215 1215
+7 -4
drivers/infiniband/hw/mlx4/ah.c
··· 141 141 return 0; 142 142 } 143 143 144 - int mlx4_ib_create_ah(struct ib_ah *ib_ah, struct rdma_ah_attr *ah_attr, 145 - u32 flags, struct ib_udata *udata) 146 - 144 + int mlx4_ib_create_ah(struct ib_ah *ib_ah, struct rdma_ah_init_attr *init_attr, 145 + struct ib_udata *udata) 147 146 { 147 + struct rdma_ah_attr *ah_attr = init_attr->ah_attr; 148 + 148 149 if (ah_attr->type == RDMA_AH_ATTR_TYPE_ROCE) { 149 150 if (!(rdma_ah_get_ah_flags(ah_attr) & IB_AH_GRH)) 150 151 return -EINVAL; ··· 168 167 int slave_sgid_index, u8 *s_mac, u16 vlan_tag) 169 168 { 170 169 struct rdma_ah_attr slave_attr = *ah_attr; 170 + struct rdma_ah_init_attr init_attr = {}; 171 171 struct mlx4_ib_ah *mah = to_mah(ah); 172 172 int ret; 173 173 174 174 slave_attr.grh.sgid_attr = NULL; 175 175 slave_attr.grh.sgid_index = slave_sgid_index; 176 - ret = mlx4_ib_create_ah(ah, &slave_attr, 0, NULL); 176 + init_attr.ah_attr = &slave_attr; 177 + ret = mlx4_ib_create_ah(ah, &init_attr, NULL); 177 178 if (ret) 178 179 return ret; 179 180
+1 -1
drivers/infiniband/hw/mlx4/mlx4_ib.h
··· 752 752 void __mlx4_ib_cq_clean(struct mlx4_ib_cq *cq, u32 qpn, struct mlx4_ib_srq *srq); 753 753 void mlx4_ib_cq_clean(struct mlx4_ib_cq *cq, u32 qpn, struct mlx4_ib_srq *srq); 754 754 755 - int mlx4_ib_create_ah(struct ib_ah *ah, struct rdma_ah_attr *ah_attr, u32 flags, 755 + int mlx4_ib_create_ah(struct ib_ah *ah, struct rdma_ah_init_attr *init_attr, 756 756 struct ib_udata *udata); 757 757 int mlx4_ib_create_ah_slave(struct ib_ah *ah, struct rdma_ah_attr *ah_attr, 758 758 int slave_sgid_index, u8 *s_mac, u16 vlan_tag);
+3 -2
drivers/infiniband/hw/mlx5/ah.c
··· 68 68 } 69 69 } 70 70 71 - int mlx5_ib_create_ah(struct ib_ah *ibah, struct rdma_ah_attr *ah_attr, 72 - u32 flags, struct ib_udata *udata) 71 + int mlx5_ib_create_ah(struct ib_ah *ibah, struct rdma_ah_init_attr *init_attr, 72 + struct ib_udata *udata) 73 73 74 74 { 75 + struct rdma_ah_attr *ah_attr = init_attr->ah_attr; 75 76 struct mlx5_ib_ah *ah = to_mah(ibah); 76 77 struct mlx5_ib_dev *dev = to_mdev(ibah->device); 77 78 enum rdma_ah_attr_type ah_type = ah_attr->type;
+1 -1
drivers/infiniband/hw/mlx5/mlx5_ib.h
··· 1153 1153 void __mlx5_ib_cq_clean(struct mlx5_ib_cq *cq, u32 qpn, struct mlx5_ib_srq *srq); 1154 1154 void mlx5_ib_cq_clean(struct mlx5_ib_cq *cq, u32 qpn, struct mlx5_ib_srq *srq); 1155 1155 void mlx5_ib_free_srq_wqe(struct mlx5_ib_srq *srq, int wqe_index); 1156 - int mlx5_ib_create_ah(struct ib_ah *ah, struct rdma_ah_attr *ah_attr, u32 flags, 1156 + int mlx5_ib_create_ah(struct ib_ah *ah, struct rdma_ah_init_attr *init_attr, 1157 1157 struct ib_udata *udata); 1158 1158 int mlx5_ib_query_ah(struct ib_ah *ibah, struct rdma_ah_attr *ah_attr); 1159 1159 void mlx5_ib_destroy_ah(struct ib_ah *ah, u32 flags);
+5 -4
drivers/infiniband/hw/mthca/mthca_provider.c
··· 388 388 mthca_pd_free(to_mdev(pd->device), to_mpd(pd)); 389 389 } 390 390 391 - static int mthca_ah_create(struct ib_ah *ibah, struct rdma_ah_attr *ah_attr, 392 - u32 flags, struct ib_udata *udata) 391 + static int mthca_ah_create(struct ib_ah *ibah, 392 + struct rdma_ah_init_attr *init_attr, 393 + struct ib_udata *udata) 393 394 394 395 { 395 396 struct mthca_ah *ah = to_mah(ibah); 396 397 397 - return mthca_create_ah(to_mdev(ibah->device), to_mpd(ibah->pd), ah_attr, 398 - ah); 398 + return mthca_create_ah(to_mdev(ibah->device), to_mpd(ibah->pd), 399 + init_attr->ah_attr, ah); 399 400 } 400 401 401 402 static void mthca_ah_destroy(struct ib_ah *ah, u32 flags)
+2 -1
drivers/infiniband/hw/ocrdma/ocrdma_ah.c
··· 155 155 return status; 156 156 } 157 157 158 - int ocrdma_create_ah(struct ib_ah *ibah, struct rdma_ah_attr *attr, u32 flags, 158 + int ocrdma_create_ah(struct ib_ah *ibah, struct rdma_ah_init_attr *init_attr, 159 159 struct ib_udata *udata) 160 160 { 161 161 u32 *ahid_addr; ··· 165 165 u16 vlan_tag = 0xffff; 166 166 const struct ib_gid_attr *sgid_attr; 167 167 struct ocrdma_pd *pd = get_ocrdma_pd(ibah->pd); 168 + struct rdma_ah_attr *attr = init_attr->ah_attr; 168 169 struct ocrdma_dev *dev = get_ocrdma_dev(ibah->device); 169 170 170 171 if ((attr->type != RDMA_AH_ATTR_TYPE_ROCE) ||
+1 -1
drivers/infiniband/hw/ocrdma/ocrdma_ah.h
··· 51 51 OCRDMA_AH_L3_TYPE_SHIFT = 0x1D /* 29 bits */ 52 52 }; 53 53 54 - int ocrdma_create_ah(struct ib_ah *ah, struct rdma_ah_attr *ah_attr, u32 flags, 54 + int ocrdma_create_ah(struct ib_ah *ah, struct rdma_ah_init_attr *init_attr, 55 55 struct ib_udata *udata); 56 56 void ocrdma_destroy_ah(struct ib_ah *ah, u32 flags); 57 57 int ocrdma_query_ah(struct ib_ah *ah, struct rdma_ah_attr *ah_attr);
+2 -2
drivers/infiniband/hw/qedr/verbs.c
··· 2750 2750 return 0; 2751 2751 } 2752 2752 2753 - int qedr_create_ah(struct ib_ah *ibah, struct rdma_ah_attr *attr, u32 flags, 2753 + int qedr_create_ah(struct ib_ah *ibah, struct rdma_ah_init_attr *init_attr, 2754 2754 struct ib_udata *udata) 2755 2755 { 2756 2756 struct qedr_ah *ah = get_qedr_ah(ibah); 2757 2757 2758 - rdma_copy_ah_attr(&ah->attr, attr); 2758 + rdma_copy_ah_attr(&ah->attr, init_attr->ah_attr); 2759 2759 2760 2760 return 0; 2761 2761 }
+1 -1
drivers/infiniband/hw/qedr/verbs.h
··· 70 70 void qedr_destroy_srq(struct ib_srq *ibsrq, struct ib_udata *udata); 71 71 int qedr_post_srq_recv(struct ib_srq *ibsrq, const struct ib_recv_wr *wr, 72 72 const struct ib_recv_wr **bad_recv_wr); 73 - int qedr_create_ah(struct ib_ah *ibah, struct rdma_ah_attr *attr, u32 flags, 73 + int qedr_create_ah(struct ib_ah *ibah, struct rdma_ah_init_attr *init_attr, 74 74 struct ib_udata *udata); 75 75 void qedr_destroy_ah(struct ib_ah *ibah, u32 flags); 76 76
+3 -2
drivers/infiniband/hw/vmw_pvrdma/pvrdma_verbs.c
··· 509 509 * 510 510 * @return: 0 on success, otherwise errno. 511 511 */ 512 - int pvrdma_create_ah(struct ib_ah *ibah, struct rdma_ah_attr *ah_attr, 513 - u32 flags, struct ib_udata *udata) 512 + int pvrdma_create_ah(struct ib_ah *ibah, struct rdma_ah_init_attr *init_attr, 513 + struct ib_udata *udata) 514 514 { 515 + struct rdma_ah_attr *ah_attr = init_attr->ah_attr; 515 516 struct pvrdma_dev *dev = to_vdev(ibah->device); 516 517 struct pvrdma_ah *ah = to_vah(ibah); 517 518 const struct ib_global_route *grh;
+1 -1
drivers/infiniband/hw/vmw_pvrdma/pvrdma_verbs.h
··· 414 414 void pvrdma_destroy_cq(struct ib_cq *cq, struct ib_udata *udata); 415 415 int pvrdma_poll_cq(struct ib_cq *ibcq, int num_entries, struct ib_wc *wc); 416 416 int pvrdma_req_notify_cq(struct ib_cq *cq, enum ib_cq_notify_flags flags); 417 - int pvrdma_create_ah(struct ib_ah *ah, struct rdma_ah_attr *ah_attr, u32 flags, 417 + int pvrdma_create_ah(struct ib_ah *ah, struct rdma_ah_init_attr *init_attr, 418 418 struct ib_udata *udata); 419 419 void pvrdma_destroy_ah(struct ib_ah *ah, u32 flags); 420 420
+6 -5
drivers/infiniband/sw/rdmavt/ah.c
··· 98 98 * 99 99 * Return: 0 on success 100 100 */ 101 - int rvt_create_ah(struct ib_ah *ibah, struct rdma_ah_attr *ah_attr, 102 - u32 create_flags, struct ib_udata *udata) 101 + int rvt_create_ah(struct ib_ah *ibah, struct rdma_ah_init_attr *init_attr, 102 + struct ib_udata *udata) 103 103 { 104 104 struct rvt_ah *ah = ibah_to_rvtah(ibah); 105 105 struct rvt_dev_info *dev = ib_to_rvt(ibah->device); 106 106 unsigned long flags; 107 107 108 - if (rvt_check_ah(ibah->device, ah_attr)) 108 + if (rvt_check_ah(ibah->device, init_attr->ah_attr)) 109 109 return -EINVAL; 110 110 111 111 spin_lock_irqsave(&dev->n_ahs_lock, flags); ··· 117 117 dev->n_ahs_allocated++; 118 118 spin_unlock_irqrestore(&dev->n_ahs_lock, flags); 119 119 120 - rdma_copy_ah_attr(&ah->attr, ah_attr); 120 + rdma_copy_ah_attr(&ah->attr, init_attr->ah_attr); 121 121 122 122 if (dev->driver_f.notify_new_ah) 123 - dev->driver_f.notify_new_ah(ibah->device, ah_attr, ah); 123 + dev->driver_f.notify_new_ah(ibah->device, 124 + init_attr->ah_attr, ah); 124 125 125 126 return 0; 126 127 }
+2 -2
drivers/infiniband/sw/rdmavt/ah.h
··· 50 50 51 51 #include <rdma/rdma_vt.h> 52 52 53 - int rvt_create_ah(struct ib_ah *ah, struct rdma_ah_attr *ah_attr, 54 - u32 create_flags, struct ib_udata *udata); 53 + int rvt_create_ah(struct ib_ah *ah, struct rdma_ah_init_attr *init_attr, 54 + struct ib_udata *udata); 55 55 void rvt_destroy_ah(struct ib_ah *ibah, u32 destroy_flags); 56 56 int rvt_modify_ah(struct ib_ah *ibah, struct rdma_ah_attr *ah_attr); 57 57 int rvt_query_ah(struct ib_ah *ibah, struct rdma_ah_attr *ah_attr);
+5 -4
drivers/infiniband/sw/rxe/rxe_verbs.c
··· 195 195 rxe_drop_ref(pd); 196 196 } 197 197 198 - static int rxe_create_ah(struct ib_ah *ibah, struct rdma_ah_attr *attr, 199 - u32 flags, struct ib_udata *udata) 198 + static int rxe_create_ah(struct ib_ah *ibah, 199 + struct rdma_ah_init_attr *init_attr, 200 + struct ib_udata *udata) 200 201 201 202 { 202 203 int err; 203 204 struct rxe_dev *rxe = to_rdev(ibah->device); 204 205 struct rxe_ah *ah = to_rah(ibah); 205 206 206 - err = rxe_av_chk_attr(rxe, attr); 207 + err = rxe_av_chk_attr(rxe, init_attr->ah_attr); 207 208 if (err) 208 209 return err; 209 210 ··· 212 211 if (err) 213 212 return err; 214 213 215 - rxe_init_av(attr, &ah->av); 214 + rxe_init_av(init_attr->ah_attr, &ah->av); 216 215 return 0; 217 216 } 218 217
+7 -2
include/rdma/ib_verbs.h
··· 880 880 */ 881 881 __attribute_const__ enum ib_rate mult_to_ib_rate(int mult); 882 882 883 + struct rdma_ah_init_attr { 884 + struct rdma_ah_attr *ah_attr; 885 + u32 flags; 886 + }; 887 + 883 888 enum rdma_ah_attr_type { 884 889 RDMA_AH_ATTR_TYPE_UNDEFINED, 885 890 RDMA_AH_ATTR_TYPE_IB, ··· 2408 2403 void (*disassociate_ucontext)(struct ib_ucontext *ibcontext); 2409 2404 int (*alloc_pd)(struct ib_pd *pd, struct ib_udata *udata); 2410 2405 void (*dealloc_pd)(struct ib_pd *pd, struct ib_udata *udata); 2411 - int (*create_ah)(struct ib_ah *ah, struct rdma_ah_attr *ah_attr, 2412 - u32 flags, struct ib_udata *udata); 2406 + int (*create_ah)(struct ib_ah *ah, struct rdma_ah_init_attr *attr, 2407 + struct ib_udata *udata); 2413 2408 int (*modify_ah)(struct ib_ah *ah, struct rdma_ah_attr *ah_attr); 2414 2409 int (*query_ah)(struct ib_ah *ah, struct rdma_ah_attr *ah_attr); 2415 2410 void (*destroy_ah)(struct ib_ah *ah, u32 flags);