Optimize RoCE address handle creation for userspace
Subsystems (9)
cover Optimize RoCE address handle creation for userspace
Hi Doug,
Please find below the patchset from Moni.
--------------------------------------------------------------------------
Creating a UD address handler (user or kernel) when link layer is Ethernet requires resolving the remote L3 address (GID) to a L2 address (MAC/VLAN).
Doing it in kernel is easy with an interface in that the module ib_addr provides. In userspace such an interface does not exist and kernel help is required.
Until now the way to resolve GID (which is the remote IP or a function of it) to a MAC was with an interface supplied by libnl. The implementation of this interface is heavy and fails on large load of requests to create an address handle.
This series of patches is an infrastructure for user drivers that care for it to optimize the resolution of L3 to L2 addresses with uverbs interface.
------------------------------------------------------------------------
The patch #3 was originally posted by Knut Omang and Moni extended it to support all available drivers along with enhanced commit message. We are sending the same patch as it exists in our review system, but feel free to change authorship to Knut if it is matter.
Thanks
Available in the "topic/create_ah" topic branch of this git repo:git://git.kernel.org/pub/scm/linux/kernel/git/leon/linux-rdma.git
Or for browsing:
https://git.kernel.org/cgit/linux/kernel/git/leon/linux-rdma.git/log/?h=topic/create_ah
Moni Shoua (5):
IB/core: Enhance ib_resolve_eth_dmac to be usable for creating AH IB/mlx5: Report that device supports user data response in create_ah IB/core: Let the verb create_ah return extended response to user IB/mlx5: Use kernel driver to help userspace create address handle IB/mlx5: Make create/destroy address handle available to userspace
drivers/infiniband/core/core_priv.h | 3 - drivers/infiniband/core/uverbs_cmd.c | 19 ++++-- drivers/infiniband/core/verbs.c | 86 ++++++++++++++-------------- drivers/infiniband/hw/cxgb3/iwch_provider.c | 3 +- drivers/infiniband/hw/cxgb4/provider.c | 4 +- drivers/infiniband/hw/hns/hns_roce_ah.c | 3 +- drivers/infiniband/hw/hns/hns_roce_device.h | 3 +- drivers/infiniband/hw/i40iw/i40iw_verbs.c | 4 +- drivers/infiniband/hw/mlx4/ah.c | 4 +- drivers/infiniband/hw/mlx4/mlx4_ib.h | 3 +- drivers/infiniband/hw/mlx5/ah.c | 25 +++++++- drivers/infiniband/hw/mlx5/main.c | 5 +- drivers/infiniband/hw/mlx5/mlx5_ib.h | 3 +- drivers/infiniband/hw/mthca/mthca_provider.c | 4 +- drivers/infiniband/hw/nes/nes_verbs.c | 3 +- drivers/infiniband/hw/ocrdma/ocrdma_ah.c | 3 +- drivers/infiniband/hw/ocrdma/ocrdma_ah.h | 4 +- drivers/infiniband/hw/qedr/verbs.c | 3 +- drivers/infiniband/hw/qedr/verbs.h | 3 +- drivers/infiniband/hw/usnic/usnic_ib_verbs.c | 4 +- drivers/infiniband/hw/usnic/usnic_ib_verbs.h | 4 +- drivers/infiniband/sw/rxe/rxe_verbs.c | 4 +- include/rdma/ib_verbs.h | 6 +- include/uapi/rdma/mlx5-abi.h | 7 +++ 24 files changed, 140 insertions(+), 70 deletions(-)
--
2.7.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 1/5 IB/core: Enhance ib_resolve_eth_dmac to be usable for creating AH
In reply to a message not in the archiveFrom: Moni Shoua <monis-VPRAkNaXOzVWk0Htik3J/[email protected]>
The function ib_resolve_eth_dmac() requires struct qp_attr * and qp_attr_mask as parameters while the function might be useful to resolve dmac for address handles. This patch changes the signature of the function so it can be used in the flow of creating an address handle.
--- drivers/infiniband/core/core_priv.h | 3 -- drivers/infiniband/core/uverbs_cmd.c | 8 ++-- drivers/infiniband/core/verbs.c | 84 ++++++++++++++++++------------------ include/rdma/ib_verbs.h | 3 ++ 4 files changed, 50 insertions(+), 48 deletions(-)
drivers/infiniband/core/core_priv.h +0 -3
@@ -72,9 +72,6 @@ void ib_device_unregister_sysfs(struct ib_device *device);void ib_cache_setup (void );void ib_cache_cleanup (void ); -int ib_resolve_eth_dmac (struct ib_qp *qp, -struct ib_qp_attr *qp_attr,int *qp_attr_mask); -typedef void (*roce_netdev_callback )(struct ib_device *device,u8 port,struct net_device *idev,void *cookie);
drivers/infiniband/core/uverbs_cmd.c +5 -3
@@ -2402,9 +2402,11 @@ ssize_t ib_uverbs_modify_qp(struct ib_uverbs_file *file, attr->alt_ah_attr.port_num = cmd.alt_dest.port_num;if (qp->real_qp == qp) { - ret =ib_resolve_eth_dmac (qp, attr, &cmd.attr_mask); -if (ret) - goto release_qp; +if (cmd.attr_mask &IB_QP_AV ) { + ret =ib_resolve_eth_dmac (qp->device, &attr->ah_attr); +if (ret) + goto release_qp; + } ret = qp->device->modify_qp (qp, attr,modify_qp_mask (qp->qp_type, cmd.attr_mask), &udata); }else {
drivers/infiniband/core/verbs.c +42 -42
108 lines not on this page · raw message
include/rdma/ib_verbs.h +3 -0
@@ -3357,4 +3357,7 @@ int ib_sg_to_pages(struct ib_mr *mr, struct scatterlist *sgl, int sg_nents,void ib_drain_rq (struct ib_qp *qp);void ib_drain_sq (struct ib_qp *qp);void ib_drain_qp (struct ib_qp *qp); + +int ib_resolve_eth_dmac (struct ib_device *device, +struct ib_ah_attr *ah_attr);#endif /* IB_VERBS_H */
Signature · 6 lines
2.7.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/5 IB/mlx5: Report that device supports user data response in create_ah
In reply to a message not in the archiveFrom: Moni Shoua <monis-VPRAkNaXOzVWk0Htik3J/[email protected]>
To make mlx5 user driver aware of whether kernel driver returns dmac in user data response add a new flag that will be returned back to user-space through alloc_ucontext.
--- drivers/infiniband/hw/mlx5/main.c | 3 ++- include/uapi/rdma/mlx5-abi.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-)
drivers/infiniband/hw/mlx5/main.c +2 -1
@@ -1093,7 +1093,8 @@ static struct ib_ucontext *mlx5_ib_alloc_ucontext(struct ib_device *ibdev, resp.response_length +=sizeof (resp.cqe_version);if (field_avail (typeof (resp), cmds_supp_uhw, udata->outlen)) { - resp.cmds_supp_uhw |=MLX5_USER_CMDS_SUPP_UHW_QUERY_DEVICE ; + resp.cmds_supp_uhw |=MLX5_USER_CMDS_SUPP_UHW_QUERY_DEVICE | +MLX5_USER_CMDS_SUPP_UHW_CREATE_AH ; resp.response_length +=sizeof (resp.cmds_supp_uhw); }
include/uapi/rdma/mlx5-abi.h +1 -0
@@ -82,6 +82,7 @@ enum mlx5_ib_alloc_ucontext_resp_mask {enum mlx5_user_cmds_supp_uhw {MLX5_USER_CMDS_SUPP_UHW_QUERY_DEVICE =1 <<0 , +MLX5_USER_CMDS_SUPP_UHW_CREATE_AH =1 <<1 , };struct mlx5_ib_alloc_ucontext_resp {
Signature · 6 lines
2.7.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 3/5 IB/core: Let the verb create_ah return extended response to user
In reply to a message not in the archiveFrom: Moni Shoua <monis-VPRAkNaXOzVWk0Htik3J/[email protected]>
Add struct ib_udata to the signature of create_ah callback that is implemented by IB device drivers. This allows HW drivers to return extra data to the userspace library.
This patch prepares the ground for mlx5 driver to resolve destination mac address for a given GID and return it to userspace.
This patch was previously submitted by Knut Omang as a part of the patch set to support Oracle's Infiniband HCA (SIF).
--- drivers/infiniband/core/uverbs_cmd.c | 11 ++++++++++- drivers/infiniband/core/verbs.c | 2 +- drivers/infiniband/hw/cxgb3/iwch_provider.c | 3 ++- drivers/infiniband/hw/cxgb4/provider.c | 4 +++- drivers/infiniband/hw/hns/hns_roce_ah.c | 3 ++- drivers/infiniband/hw/hns/hns_roce_device.h | 3 ++- drivers/infiniband/hw/i40iw/i40iw_verbs.c | 4 +++- drivers/infiniband/hw/mlx4/ah.c | 4 +++- drivers/infiniband/hw/mlx4/mlx4_ib.h | 3 ++- drivers/infiniband/hw/mlx5/ah.c | 4 +++- drivers/infiniband/hw/mlx5/mlx5_ib.h | 3 ++- drivers/infiniband/hw/mthca/mthca_provider.c | 4 +++- drivers/infiniband/hw/nes/nes_verbs.c | 3 ++- drivers/infiniband/hw/ocrdma/ocrdma_ah.c | 3 ++- drivers/infiniband/hw/ocrdma/ocrdma_ah.h | 4 +++- drivers/infiniband/hw/qedr/verbs.c | 3 ++- drivers/infiniband/hw/qedr/verbs.h | 3 ++- drivers/infiniband/hw/usnic/usnic_ib_verbs.c | 4 +++- drivers/infiniband/hw/usnic/usnic_ib_verbs.h | 4 +++- drivers/infiniband/sw/rxe/rxe_verbs.c | 4 +++- include/rdma/ib_verbs.h | 3 ++- 21 files changed, 58 insertions(+), 21 deletions(-)
drivers/infiniband/core/uverbs_cmd.c +10 -1
@@ -2877,6 +2877,7 @@ ssize_t ib_uverbs_create_ah(struct ib_uverbs_file *file,struct ib_ah *ah;struct ib_ah_attr attr;int ret; +struct ib_udata udata;if (out_len <sizeof resp)return -ENOSPC ;
@@ -2884,6 +2885,10 @@ ssize_t ib_uverbs_create_ah(struct ib_uverbs_file *file,if (copy_from_user (&cmd, buf,sizeof cmd))return -EFAULT ; +INIT_UDATA (&udata, buf +sizeof (cmd), + (unsigned long )cmd.response +sizeof (resp), + in_len -sizeof (cmd), out_len -sizeof (resp)); + uobj =kmalloc (sizeof *uobj,GFP_KERNEL );if (!uobj)return -ENOMEM ;
@@ -2910,12 +2915,16 @@ ssize_t ib_uverbs_create_ah(struct ib_uverbs_file *file,memset (&attr.dmac,0 ,sizeof (attr.dmac));memcpy (attr.grh.dgid.raw, cmd.attr.grh.dgid,16 ); - ah =ib_create_ah (pd, &attr); + ah = pd->device->create_ah (pd, &attr, &udata); +if (IS_ERR (ah)) { ret =PTR_ERR (ah); goto err_put; } + ah->device = pd->device; + ah->pd = pd; +atomic_inc (&pd->usecnt); ah->uobject = uobj; uobj->object = ah;
drivers/infiniband/core/verbs.c +1 -1
@@ -315,7 +315,7 @@ struct ib_ah *ib_create_ah(struct ib_pd *pd, struct ib_ah_attr *ah_attr) {struct ib_ah *ah; - ah = pd->device->create_ah (pd, ah_attr); + ah = pd->device->create_ah (pd, ah_attr,NULL );if (!IS_ERR (ah)) { ah->device = pd->device;
drivers/infiniband/hw/cxgb3/iwch_provider.c +2 -1
@@ -62,7 +62,8 @@#include "common.h" static struct ib_ah *iwch_ah_create (struct ib_pd *pd, -struct ib_ah_attr *ah_attr) +struct ib_ah_attr *ah_attr, +struct ib_udata *udata) {return ERR_PTR (-ENOSYS ); }
drivers/infiniband/hw/cxgb4/provider.c +3 -1
@@ -59,7 +59,9 @@ module_param(fastreg_support, int, 0644);MODULE_PARM_DESC (fastreg_support,"Advertise fastreg support (default=1)" );static struct ib_ah *c4iw_ah_create (struct ib_pd *pd, -struct ib_ah_attr *ah_attr) +struct ib_ah_attr *ah_attr, +struct ib_udata *udata) + {return ERR_PTR (-ENOSYS ); }
drivers/infiniband/hw/hns/hns_roce_ah.c +2 -1
@@ -39,7 +39,8 @@#define HNS_ROCE_VLAN_SL_BIT_MASK 7#define HNS_ROCE_VLAN_SL_SHIFT 13 -struct ib_ah *hns_roce_create_ah (struct ib_pd *ibpd,struct ib_ah_attr *ah_attr) +struct ib_ah *hns_roce_create_ah (struct ib_pd *ibpd,struct ib_ah_attr *ah_attr, +struct ib_udata *udata) {struct hns_roce_dev *hr_dev =to_hr_dev (ibpd->device);struct device *dev = &hr_dev->pdev->dev;
drivers/infiniband/hw/hns/hns_roce_device.h +2 -1
@@ -667,7 +667,8 @@ int hns_roce_bitmap_alloc_range(struct hns_roce_bitmap *bitmap, int cnt,void hns_roce_bitmap_free_range (struct hns_roce_bitmap *bitmap,unsigned long obj,int cnt); -struct ib_ah *hns_roce_create_ah (struct ib_pd *pd,struct ib_ah_attr *ah_attr); +struct ib_ah *hns_roce_create_ah (struct ib_pd *pd,struct ib_ah_attr *ah_attr, +struct ib_udata *udata);int hns_roce_query_ah (struct ib_ah *ibah,struct ib_ah_attr *ah_attr);int hns_roce_destroy_ah (struct ib_ah *ah);
drivers/infiniband/hw/i40iw/i40iw_verbs.c +3 -1
@@ -2562,7 +2562,9 @@ static int i40iw_query_pkey(struct ib_device *ibdev,* @ah_attr: address handle attributes */ static struct ib_ah *i40iw_create_ah (struct ib_pd *ibpd, -struct ib_ah_attr *attr) +struct ib_ah_attr *attr, +struct ib_udata *udata) + {return ERR_PTR (-ENOSYS ); }
drivers/infiniband/hw/mlx4/ah.c +3 -1
@@ -124,7 +124,9 @@ static struct ib_ah *create_iboe_ah(struct ib_pd *pd, struct ib_ah_attr *ah_attrreturn &ah->ibah; } -struct ib_ah *mlx4_ib_create_ah (struct ib_pd *pd,struct ib_ah_attr *ah_attr) +struct ib_ah *mlx4_ib_create_ah (struct ib_pd *pd,struct ib_ah_attr *ah_attr, +struct ib_udata *udata) + {struct mlx4_ib_ah *ah;struct ib_ah *ret;
drivers/infiniband/hw/mlx4/mlx4_ib.h +2 -1
@@ -742,7 +742,8 @@ int mlx4_ib_arm_cq(struct ib_cq *cq, enum ib_cq_notify_flags flags);void __mlx4_ib_cq_clean (struct mlx4_ib_cq *cq,u32 qpn,struct mlx4_ib_srq *srq);void mlx4_ib_cq_clean (struct mlx4_ib_cq *cq,u32 qpn,struct mlx4_ib_srq *srq); -struct ib_ah *mlx4_ib_create_ah (struct ib_pd *pd,struct ib_ah_attr *ah_attr); +struct ib_ah *mlx4_ib_create_ah (struct ib_pd *pd,struct ib_ah_attr *ah_attr, +struct ib_udata *udata);int mlx4_ib_query_ah (struct ib_ah *ibah,struct ib_ah_attr *ah_attr);int mlx4_ib_destroy_ah (struct ib_ah *ah);
drivers/infiniband/hw/mlx5/ah.c +3 -1
@@ -64,7 +64,9 @@ static struct ib_ah *create_ib_ah(struct mlx5_ib_dev *dev,return &ah->ibah; } -struct ib_ah *mlx5_ib_create_ah (struct ib_pd *pd,struct ib_ah_attr *ah_attr) +struct ib_ah *mlx5_ib_create_ah (struct ib_pd *pd,struct ib_ah_attr *ah_attr, +struct ib_udata *udata) + {struct mlx5_ib_ah *ah;struct mlx5_ib_dev *dev =to_mdev (pd->device);
drivers/infiniband/hw/mlx5/mlx5_ib.h +2 -1
@@ -737,7 +737,8 @@ void mlx5_ib_free_srq_wqe(struct mlx5_ib_srq *srq, int wqe_index);int mlx5_MAD_IFC (struct mlx5_ib_dev *dev,int ignore_mkey,int ignore_bkey,u8 port,const struct ib_wc *in_wc,const struct ib_grh *in_grh,const void *in_mad,void *response_mad); -struct ib_ah *mlx5_ib_create_ah (struct ib_pd *pd,struct ib_ah_attr *ah_attr); +struct ib_ah *mlx5_ib_create_ah (struct ib_pd *pd,struct ib_ah_attr *ah_attr, +struct ib_udata *udata);int mlx5_ib_query_ah (struct ib_ah *ibah,struct ib_ah_attr *ah_attr);int mlx5_ib_destroy_ah (struct ib_ah *ah); struct ib_srq *mlx5_ib_create_srq(struct ib_pd *pd,
drivers/infiniband/hw/mthca/mthca_provider.c +3 -1
@@ -410,7 +410,9 @@ static int mthca_dealloc_pd(struct ib_pd *pd) }static struct ib_ah *mthca_ah_create (struct ib_pd *pd, -struct ib_ah_attr *ah_attr) +struct ib_ah_attr *ah_attr, +struct ib_udata *udata) + {int err;struct mthca_ah *ah;
drivers/infiniband/hw/nes/nes_verbs.c +2 -1
@@ -771,7 +771,8 @@ static int nes_dealloc_pd(struct ib_pd *ibpd)/** * nes_create_ah */ -static struct ib_ah *nes_create_ah (struct ib_pd *pd,struct ib_ah_attr *ah_attr) +static struct ib_ah *nes_create_ah (struct ib_pd *pd,struct ib_ah_attr *ah_attr, +struct ib_udata *udata) {return ERR_PTR (-ENOSYS ); }
drivers/infiniband/hw/ocrdma/ocrdma_ah.c +2 -1
@@ -154,7 +154,8 @@ static inline int set_av_attr(struct ocrdma_dev *dev, struct ocrdma_ah *ah,return status; } -struct ib_ah *ocrdma_create_ah (struct ib_pd *ibpd,struct ib_ah_attr *attr) +struct ib_ah *ocrdma_create_ah (struct ib_pd *ibpd,struct ib_ah_attr *attr, +struct ib_udata *udata) {u32 *ahid_addr;int status;
drivers/infiniband/hw/ocrdma/ocrdma_ah.h +3 -1
@@ -50,7 +50,9 @@ enum {OCRDMA_AH_L3_TYPE_MASK =0x03 , OCRDMA_AH_L3_TYPE_SHIFT = 0x1D /* 29 bits */ }; -struct ib_ah *ocrdma_create_ah (struct ib_pd *,struct ib_ah_attr *); + +struct ib_ah *ocrdma_create_ah (struct ib_pd *,struct ib_ah_attr *, +struct ib_udata *);int ocrdma_destroy_ah (struct ib_ah *);int ocrdma_query_ah (struct ib_ah *,struct ib_ah_attr *);int ocrdma_modify_ah (struct ib_ah *,struct ib_ah_attr *);
drivers/infiniband/hw/qedr/verbs.c +2 -1
@@ -2094,7 +2094,8 @@ int qedr_destroy_qp(struct ib_qp *ibqp)return rc; } -struct ib_ah *qedr_create_ah (struct ib_pd *ibpd,struct ib_ah_attr *attr) +struct ib_ah *qedr_create_ah (struct ib_pd *ibpd,struct ib_ah_attr *attr, +struct ib_udata *udata) {struct qedr_ah *ah;
drivers/infiniband/hw/qedr/verbs.h +2 -1
@@ -70,7 +70,8 @@ int qedr_query_qp(struct ib_qp *, struct ib_qp_attr *qp_attr, int qp_attr_mask, struct ib_qp_init_attr *);int qedr_destroy_qp (struct ib_qp *ibqp); -struct ib_ah *qedr_create_ah (struct ib_pd *ibpd,struct ib_ah_attr *attr); +struct ib_ah *qedr_create_ah (struct ib_pd *ibpd,struct ib_ah_attr *attr, +struct ib_udata *udata);int qedr_destroy_ah (struct ib_ah *ibah);int qedr_dereg_mr (struct ib_mr *);
drivers/infiniband/hw/usnic/usnic_ib_verbs.c +3 -1
@@ -738,7 +738,9 @@ int usnic_ib_mmap(struct ib_ucontext *context,/* In ib callbacks section - Start of stub funcs */ struct ib_ah *usnic_ib_create_ah (struct ib_pd *pd, -struct ib_ah_attr *ah_attr) +struct ib_ah_attr *ah_attr, +struct ib_udata *udata) + {usnic_dbg ("\n" );return ERR_PTR (-EPERM );
drivers/infiniband/hw/usnic/usnic_ib_verbs.h +3 -1
@@ -75,7 +75,9 @@ int usnic_ib_dealloc_ucontext(struct ib_ucontext *ibcontext);int usnic_ib_mmap (struct ib_ucontext *context,struct vm_area_struct *vma);struct ib_ah *usnic_ib_create_ah (struct ib_pd *pd, -struct ib_ah_attr *ah_attr); +struct ib_ah_attr *ah_attr, +struct ib_udata *udata); +int usnic_ib_destroy_ah (struct ib_ah *ah);int usnic_ib_post_send (struct ib_qp *ibqp,struct ib_send_wr *wr,struct ib_send_wr **bad_wr);
drivers/infiniband/sw/rxe/rxe_verbs.c +3 -1
@@ -316,7 +316,9 @@ static int rxe_init_av(struct rxe_dev *rxe, struct ib_ah_attr *attr,return err; } -static struct ib_ah *rxe_create_ah (struct ib_pd *ibpd,struct ib_ah_attr *attr) +static struct ib_ah *rxe_create_ah (struct ib_pd *ibpd,struct ib_ah_attr *attr, +struct ib_udata *udata) + {int err;struct rxe_dev *rxe =to_rdev (ibpd->device);
include/rdma/ib_verbs.h +2 -1
@@ -1933,7 +1933,8 @@ struct ib_device { struct ib_udata *udata);int (*dealloc_pd)(struct ib_pd *pd);struct ib_ah * (*create_ah)(struct ib_pd *pd, -struct ib_ah_attr *ah_attr); +struct ib_ah_attr *ah_attr, +struct ib_udata *udata);int (*modify_ah)(struct ib_ah *ah,struct ib_ah_attr *ah_attr); int (*query_ah)(struct ib_ah *ah,
Signature · 6 lines
2.7.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 4/5 IB/mlx5: Use kernel driver to help userspace create address handle
In reply to a message not in the archiveFrom: Moni Shoua <monis-VPRAkNaXOzVWk0Htik3J/[email protected]>
Resolving a MAC address for a given IP address in userspace is inefficient. This patch lets mlx5 user driver using the kernel driver to resolve the mac and get the answer in the private section of the response.
--- drivers/infiniband/hw/mlx5/ah.c | 21 +++++++++++++++++++++ include/uapi/rdma/mlx5-abi.h | 6 ++++++ 2 files changed, 27 insertions(+)
drivers/infiniband/hw/mlx5/ah.c +21 -0
@@ -77,6 +77,27 @@ struct ib_ah *mlx5_ib_create_ah(struct ib_pd *pd, struct ib_ah_attr *ah_attr,if (ll ==IB_LINK_LAYER_ETHERNET && !(ah_attr->ah_flags &IB_AH_GRH ))return ERR_PTR (-EINVAL ); +if (ll ==IB_LINK_LAYER_ETHERNET && udata) { +int err; +struct mlx5_ib_create_ah_resp resp = {}; +u32 min_resp_len = offsetof(typeof (resp ), dmac) + +sizeof (resp.dmac); + +if (udata->outlen < min_resp_len) +return ERR_PTR (-EINVAL ); + + resp.response_length = min_resp_len; + + err =ib_resolve_eth_dmac (pd->device, ah_attr); +if (err) +return ERR_PTR (err); + +memcpy (resp.dmac, ah_attr->dmac,ETH_ALEN ); + err =ib_copy_to_udata (udata, &resp, resp.response_length); +if (err) +return ERR_PTR (err); + } + ah =kzalloc (sizeof (*ah),GFP_ATOMIC );if (!ah)return ERR_PTR (-ENOMEM );
include/uapi/rdma/mlx5-abi.h +6 -0
@@ -233,6 +233,12 @@ struct mlx5_ib_create_wq {__u32 reserved; }; +struct mlx5_ib_create_ah_resp { +__u32 response_length; +__u8 dmac[ETH_ALEN ]; +__u8 reserved[6 ]; +}; +struct mlx5_ib_create_wq_resp {__u32 response_length;__u32 reserved;
Signature · 6 lines
2.7.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 5/5 IB/mlx5: Make create/destroy address handle available to userspace
In reply to a message not in the archiveFrom: Moni Shoua <monis-VPRAkNaXOzVWk0Htik3J/[email protected]>
Advertise that create_ah and destroy_ah verbs are accessible from uverbs interface.
--- drivers/infiniband/hw/mlx5/main.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/infiniband/hw/mlx5/main.c +2 -0
@@ -2993,6 +2993,8 @@ static void *mlx5_ib_add(struct mlx5_core_dev *mdev) (1ull <<IB_USER_VERBS_CMD_QUERY_PORT ) | (1ull <<IB_USER_VERBS_CMD_ALLOC_PD ) | (1ull <<IB_USER_VERBS_CMD_DEALLOC_PD ) | + (1ull <<IB_USER_VERBS_CMD_CREATE_AH ) | + (1ull <<IB_USER_VERBS_CMD_DESTROY_AH ) | (1ull <<IB_USER_VERBS_CMD_REG_MR ) | (1ull <<IB_USER_VERBS_CMD_REREG_MR ) | (1ull << IB_USER_VERBS_CMD_DEREG_MR) |
Signature · 6 lines
2.7.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 67 lines · Leon Romanovsky
Hi Doug,
Please find below the patchset from Moni.
--------------------------------------------------------------------------
Creating a UD address handler (user or kernel) when link layer is Ethernet requires resolving the remote L3 address (GID) to a L2 address (MAC/VLAN).Doing it in kernel is easy with an interface in that the module
ib_addrprovides. In userspace such an interface does not exist and kernel help is required.Until now the way to resolve GID (which is the remote IP or a function of it) to a MAC was with an interface supplied by libnl. The implementation of this interface is heavy and fails on large load of requests to create an address handle.
This series of patches is an infrastructure for user drivers that care for it to optimize the resolution of L3 to L2 addresses with uverbs interface.
------------------------------------------------------------------------The patch #3 was originally posted by Knut Omang and Moni extended it to support all available drivers along with enhanced commit message. We are sending the same patch as it exists in our review system, but feel free to change authorship to Knut if it is matter.
Thanks
Available in the "topic/create_ah" topic branch of this git repo:
git://git.kernel.org/pub/scm/linux/kernel/git/leon/linux-rdma.git
Or for browsing:
https://git.kernel.org/cgit/linux/kernel/git/leon/linux-rdma.git/log/?h=topic/create_ahMoni Shoua (5):
IB/core: Enhanceib_resolve_eth_dmacto be usable for creating AH IB/mlx5: Report that device supports user data response increate_ahIB/core: Let the verbcreate_ahreturn extended response to user IB/mlx5: Use kernel driver to help userspace create address handle IB/mlx5: Make create/destroy address handle available to userspacedrivers/infiniband/core/core_priv.h | 3 - drivers/infiniband/core/uverbs_cmd.c | 19 ++++-- drivers/infiniband/core/verbs.c | 86 ++++++++++++++-------------- drivers/infiniband/hw/cxgb3/iwch_provider.c | 3 +- drivers/infiniband/hw/cxgb4/provider.c | 4 +- drivers/infiniband/hw/hns/hns_roce_ah.c | 3 +- drivers/infiniband/hw/hns/hns_roce_device.h | 3 +- drivers/infiniband/hw/i40iw/i40iw_verbs.c | 4 +- drivers/infiniband/hw/mlx4/ah.c | 4 +- drivers/infiniband/hw/mlx4/mlx4_ib.h | 3 +- drivers/infiniband/hw/mlx5/ah.c | 25 +++++++- drivers/infiniband/hw/mlx5/main.c | 5 +- drivers/infiniband/hw/mlx5/mlx5_ib.h | 3 +- drivers/infiniband/hw/mthca/mthca_provider.c | 4 +- drivers/infiniband/hw/nes/nes_verbs.c | 3 +- drivers/infiniband/hw/ocrdma/ocrdma_ah.c | 3 +- drivers/infiniband/hw/ocrdma/ocrdma_ah.h | 4 +- drivers/infiniband/hw/qedr/verbs.c | 3 +- drivers/infiniband/hw/qedr/verbs.h | 3 +- drivers/infiniband/hw/usnic/usnic_ib_verbs.c | 4 +- drivers/infiniband/hw/usnic/usnic_ib_verbs.h | 4 +- drivers/infiniband/sw/rxe/rxe_verbs.c | 4 +- include/rdma/ib_verbs.h | 6 +- include/uapi/rdma/mlx5-abi.h | 7 +++ 24 files changed, 140 insertions(+), 70 deletions(-)
Quoted 3 lines
--
2.7.4
Series applied, thanks.
Signature · 2 lines
Doug Ledford <[email protected]> GPG Key ID: 0E572FDD