Commit e08466a7 authored by Linus Torvalds's avatar Linus Torvalds
Browse files
Pull rdma updates from Jason Gunthorpe:
 "Not a big list of changes this cycle, mostly small things. The new
  MANA rdma driver should come next cycle along with a bunch of work on
  rxe.

  Summary:

   - Small bug fixes in mlx5, efa, rxe, hns, irdma, erdma, siw

   - rts tracing improvements

   - Code improvements: strlscpy conversion, unused parameter, spelling
     mistakes, unused variables, flex arrays

   - restrack device details report for hns

   - Simplify struct device initialization in SRP

   - Eliminate the never-used service_mask support in IB CM

   - Make rxe not print to the console for some kinds of network packets

   - Asymetric paths and router support in the CM through netlink
     messages

   - DMABUF importer support for mlx5devx umem's"

* tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma: (84 commits)
  RDMA/rxe: Remove error/warning messages from packet receiver path
  RDMA/usnic: fix set-but-not-unused variable 'flags' warning
  IB/hfi1: Use skb_put_data() instead of skb_put/memcpy pair
  RDMA/hns: Unified Log Printing Style
  RDMA/hns: Replacing magic number with macros in apply_func_caps()
  RDMA/hns: Repacing 'dseg_len' by macros in fill_ext_sge_inl_data()
  RDMA/hns: Remove redundant 'max_srq_desc_sz' in caps
  RDMA/hns: Remove redundant 'num_mtt_segs' and 'max_extend_sg'
  RDMA/hns: Remove redundant 'phy_addr' in hns_roce_hem_list_find_mtt()
  RDMA/hns: Remove redundant 'use_lowmem' argument from hns_roce_init_hem_table()
  RDMA/hns: Remove redundant 'bt_level' for hem_list_alloc_item()
  RDMA/hns: Remove redundant 'attr_mask' in modify_qp_init_to_init()
  RDMA/hns: Remove unnecessary brackets when getting point
  RDMA/hns: Remove unnecessary braces for single statement blocks
  RDMA/hns: Cleanup for a spelling error of Asynchronous
  IB/rdmavt: Add __init/__exit annotations to module init/exit funcs
  RDMA/rxe: Remove redundant num_sge fields
  RDMA/mlx5: Enable ATS support for MRs and umems
  RDMA/mlx5: Add support for dmabuf to devx umem
  RDMA/core: Add UVERBS_ATTR_RAW_FD
  ...
parents 1227db9e 33331a72
Loading
Loading
Loading
Loading
+5 −6
Original line number Diff line number Diff line
@@ -360,10 +360,9 @@ static int process_msg_sess_info(struct rnbd_srv_session *srv_sess,
				 const void *msg, size_t len,
				 void *data, size_t datalen);

static int rnbd_srv_rdma_ev(void *priv,
			    struct rtrs_srv_op *id, int dir,
			    void *data, size_t datalen, const void *usr,
			    size_t usrlen)
static int rnbd_srv_rdma_ev(void *priv, struct rtrs_srv_op *id,
			    void *data, size_t datalen,
			    const void *usr, size_t usrlen)
{
	struct rnbd_srv_session *srv_sess = priv;
	const struct rnbd_msg_hdr *hdr = usr;
@@ -389,8 +388,8 @@ static int rnbd_srv_rdma_ev(void *priv,
					    datalen);
		break;
	default:
		pr_warn("Received unexpected message type %d with dir %d from session %s\n",
			type, dir, srv_sess->sessname);
		pr_warn("Received unexpected message type %d from session %s\n",
			type, srv_sess->sessname);
		return -EINVAL;
	}

+52 −52
Original line number Diff line number Diff line
@@ -175,6 +175,7 @@ struct cm_device {
struct cm_av {
	struct cm_port *port;
	struct rdma_ah_attr ah_attr;
	u16 dlid_datapath;
	u16 pkey_index;
	u8 timeout;
};
@@ -617,7 +618,6 @@ static struct cm_id_private *cm_insert_listen(struct cm_id_private *cm_id_priv,
	struct rb_node *parent = NULL;
	struct cm_id_private *cur_cm_id_priv;
	__be64 service_id = cm_id_priv->id.service_id;
	__be64 service_mask = cm_id_priv->id.service_mask;
	unsigned long flags;

	spin_lock_irqsave(&cm.lock, flags);
@@ -625,9 +625,16 @@ static struct cm_id_private *cm_insert_listen(struct cm_id_private *cm_id_priv,
		parent = *link;
		cur_cm_id_priv = rb_entry(parent, struct cm_id_private,
					  service_node);
		if ((cur_cm_id_priv->id.service_mask & service_id) ==
		    (service_mask & cur_cm_id_priv->id.service_id) &&
		    (cm_id_priv->id.device == cur_cm_id_priv->id.device)) {

		if (cm_id_priv->id.device < cur_cm_id_priv->id.device)
			link = &(*link)->rb_left;
		else if (cm_id_priv->id.device > cur_cm_id_priv->id.device)
			link = &(*link)->rb_right;
		else if (be64_lt(service_id, cur_cm_id_priv->id.service_id))
			link = &(*link)->rb_left;
		else if (be64_gt(service_id, cur_cm_id_priv->id.service_id))
			link = &(*link)->rb_right;
		else {
			/*
			 * Sharing an ib_cm_id with different handlers is not
			 * supported
@@ -643,17 +650,6 @@ static struct cm_id_private *cm_insert_listen(struct cm_id_private *cm_id_priv,
			spin_unlock_irqrestore(&cm.lock, flags);
			return cur_cm_id_priv;
		}

		if (cm_id_priv->id.device < cur_cm_id_priv->id.device)
			link = &(*link)->rb_left;
		else if (cm_id_priv->id.device > cur_cm_id_priv->id.device)
			link = &(*link)->rb_right;
		else if (be64_lt(service_id, cur_cm_id_priv->id.service_id))
			link = &(*link)->rb_left;
		else if (be64_gt(service_id, cur_cm_id_priv->id.service_id))
			link = &(*link)->rb_right;
		else
			link = &(*link)->rb_right;
	}
	cm_id_priv->listen_sharecount++;
	rb_link_node(&cm_id_priv->service_node, parent, link);
@@ -670,12 +666,7 @@ static struct cm_id_private *cm_find_listen(struct ib_device *device,

	while (node) {
		cm_id_priv = rb_entry(node, struct cm_id_private, service_node);
		if ((cm_id_priv->id.service_mask & service_id) ==
		     cm_id_priv->id.service_id &&
		    (cm_id_priv->id.device == device)) {
			refcount_inc(&cm_id_priv->refcount);
			return cm_id_priv;
		}

		if (device < cm_id_priv->id.device)
			node = node->rb_left;
		else if (device > cm_id_priv->id.device)
@@ -684,8 +675,10 @@ static struct cm_id_private *cm_find_listen(struct ib_device *device,
			node = node->rb_left;
		else if (be64_gt(service_id, cm_id_priv->id.service_id))
			node = node->rb_right;
		else
			node = node->rb_right;
		else {
			refcount_inc(&cm_id_priv->refcount);
			return cm_id_priv;
		}
	}
	return NULL;
}
@@ -1158,22 +1151,17 @@ void ib_destroy_cm_id(struct ib_cm_id *cm_id)
}
EXPORT_SYMBOL(ib_destroy_cm_id);

static int cm_init_listen(struct cm_id_private *cm_id_priv, __be64 service_id,
			  __be64 service_mask)
static int cm_init_listen(struct cm_id_private *cm_id_priv, __be64 service_id)
{
	service_mask = service_mask ? service_mask : ~cpu_to_be64(0);
	service_id &= service_mask;
	if ((service_id & IB_SERVICE_ID_AGN_MASK) == IB_CM_ASSIGN_SERVICE_ID &&
	    (service_id != IB_CM_ASSIGN_SERVICE_ID))
		return -EINVAL;

	if (service_id == IB_CM_ASSIGN_SERVICE_ID) {
	if (service_id == IB_CM_ASSIGN_SERVICE_ID)
		cm_id_priv->id.service_id = cpu_to_be64(cm.listen_service_id++);
		cm_id_priv->id.service_mask = ~cpu_to_be64(0);
	} else {
	else
		cm_id_priv->id.service_id = service_id;
		cm_id_priv->id.service_mask = service_mask;
	}

	return 0;
}

@@ -1185,12 +1173,8 @@ static int cm_init_listen(struct cm_id_private *cm_id_priv, __be64 service_id,
 *   and service ID resolution requests.  The service ID should be specified
 *   network-byte order.  If set to IB_CM_ASSIGN_SERVICE_ID, the CM will
 *   assign a service ID to the caller.
 * @service_mask: Mask applied to service ID used to listen across a
 *   range of service IDs.  If set to 0, the service ID is matched
 *   exactly.  This parameter is ignored if %service_id is set to
 *   IB_CM_ASSIGN_SERVICE_ID.
 */
int ib_cm_listen(struct ib_cm_id *cm_id, __be64 service_id, __be64 service_mask)
int ib_cm_listen(struct ib_cm_id *cm_id, __be64 service_id)
{
	struct cm_id_private *cm_id_priv =
		container_of(cm_id, struct cm_id_private, id);
@@ -1203,7 +1187,7 @@ int ib_cm_listen(struct ib_cm_id *cm_id, __be64 service_id, __be64 service_mask)
		goto out;
	}

	ret = cm_init_listen(cm_id_priv, service_id, service_mask);
	ret = cm_init_listen(cm_id_priv, service_id);
	if (ret)
		goto out;

@@ -1251,7 +1235,7 @@ struct ib_cm_id *ib_cm_insert_listen(struct ib_device *device,
	if (IS_ERR(cm_id_priv))
		return ERR_CAST(cm_id_priv);

	err = cm_init_listen(cm_id_priv, service_id, 0);
	err = cm_init_listen(cm_id_priv, service_id);
	if (err) {
		ib_destroy_cm_id(&cm_id_priv->id);
		return ERR_PTR(err);
@@ -1321,6 +1305,7 @@ static void cm_format_req(struct cm_req_msg *req_msg,
	struct sa_path_rec *pri_path = param->primary_path;
	struct sa_path_rec *alt_path = param->alternate_path;
	bool pri_ext = false;
	__be16 lid;

	if (pri_path->rec_type == SA_PATH_REC_TYPE_OPA)
		pri_ext = opa_is_extended_lid(pri_path->opa.dlid,
@@ -1380,9 +1365,16 @@ static void cm_format_req(struct cm_req_msg *req_msg,
					      htons(ntohl(sa_path_get_dlid(
						      pri_path)))));
	} else {
		/* Work-around until there's a way to obtain remote LID info */

		if (param->primary_path_inbound) {
			lid = param->primary_path_inbound->ib.dlid;
			IBA_SET(CM_REQ_PRIMARY_LOCAL_PORT_LID, req_msg,
				be16_to_cpu(lid));
		} else
			IBA_SET(CM_REQ_PRIMARY_LOCAL_PORT_LID, req_msg,
				be16_to_cpu(IB_LID_PERMISSIVE));

		/* Work-around until there's a way to obtain remote LID info */
		IBA_SET(CM_REQ_PRIMARY_REMOTE_PORT_LID, req_msg,
			be16_to_cpu(IB_LID_PERMISSIVE));
	}
@@ -1522,7 +1514,6 @@ int ib_send_cm_req(struct ib_cm_id *cm_id,
		}
	}
	cm_id->service_id = param->service_id;
	cm_id->service_mask = ~cpu_to_be64(0);
	cm_id_priv->timeout_ms = cm_convert_to_ms(
				    param->primary_path->packet_life_time) * 2 +
				 cm_convert_to_ms(
@@ -1538,6 +1529,10 @@ int ib_send_cm_req(struct ib_cm_id *cm_id,
	spin_lock_irqsave(&cm_id_priv->lock, flags);

	cm_move_av_from_path(&cm_id_priv->av, &av);
	if (param->primary_path_outbound)
		cm_id_priv->av.dlid_datapath =
			be16_to_cpu(param->primary_path_outbound->ib.dlid);

	if (param->alternate_path)
		cm_move_av_from_path(&cm_id_priv->alt_av, &alt_av);

@@ -1632,14 +1627,13 @@ static void cm_path_set_rec_type(struct ib_device *ib_device, u32 port_num,

static void cm_format_path_lid_from_req(struct cm_req_msg *req_msg,
					struct sa_path_rec *primary_path,
					struct sa_path_rec *alt_path)
					struct sa_path_rec *alt_path,
					struct ib_wc *wc)
{
	u32 lid;

	if (primary_path->rec_type != SA_PATH_REC_TYPE_OPA) {
		sa_path_set_dlid(primary_path,
				 IBA_GET(CM_REQ_PRIMARY_LOCAL_PORT_LID,
					 req_msg));
		sa_path_set_dlid(primary_path, wc->slid);
		sa_path_set_slid(primary_path,
				 IBA_GET(CM_REQ_PRIMARY_REMOTE_PORT_LID,
					 req_msg));
@@ -1676,7 +1670,8 @@ static void cm_format_path_lid_from_req(struct cm_req_msg *req_msg,

static void cm_format_paths_from_req(struct cm_req_msg *req_msg,
				     struct sa_path_rec *primary_path,
				     struct sa_path_rec *alt_path)
				     struct sa_path_rec *alt_path,
				     struct ib_wc *wc)
{
	primary_path->dgid =
		*IBA_GET_MEM_PTR(CM_REQ_PRIMARY_LOCAL_PORT_GID, req_msg);
@@ -1734,7 +1729,7 @@ static void cm_format_paths_from_req(struct cm_req_msg *req_msg,
		if (sa_path_is_roce(alt_path))
			alt_path->roce.route_resolved = false;
	}
	cm_format_path_lid_from_req(req_msg, primary_path, alt_path);
	cm_format_path_lid_from_req(req_msg, primary_path, alt_path, wc);
}

static u16 cm_get_bth_pkey(struct cm_work *work)
@@ -2079,7 +2074,6 @@ static int cm_req_handler(struct cm_work *work)
		cpu_to_be32(IBA_GET(CM_REQ_LOCAL_COMM_ID, req_msg));
	cm_id_priv->id.service_id =
		cpu_to_be64(IBA_GET(CM_REQ_SERVICE_ID, req_msg));
	cm_id_priv->id.service_mask = ~cpu_to_be64(0);
	cm_id_priv->tid = req_msg->hdr.tid;
	cm_id_priv->timeout_ms = cm_convert_to_ms(
		IBA_GET(CM_REQ_LOCAL_CM_RESPONSE_TIMEOUT, req_msg));
@@ -2148,7 +2142,7 @@ static int cm_req_handler(struct cm_work *work)
	if (cm_req_has_alt_path(req_msg))
		work->path[1].rec_type = work->path[0].rec_type;
	cm_format_paths_from_req(req_msg, &work->path[0],
				 &work->path[1]);
				 &work->path[1], work->mad_recv_wc->wc);
	if (cm_id_priv->av.ah_attr.type == RDMA_AH_ATTR_TYPE_ROCE)
		sa_path_set_dmac(&work->path[0],
				 cm_id_priv->av.ah_attr.roce.dmac);
@@ -2173,6 +2167,10 @@ static int cm_req_handler(struct cm_work *work)
				       NULL, 0);
		goto rejected;
	}
	if (cm_id_priv->av.ah_attr.type == RDMA_AH_ATTR_TYPE_IB)
		cm_id_priv->av.dlid_datapath =
			IBA_GET(CM_REQ_PRIMARY_LOCAL_PORT_LID, req_msg);

	if (cm_req_has_alt_path(req_msg)) {
		ret = cm_init_av_by_path(&work->path[1], NULL,
					 &cm_id_priv->alt_av);
@@ -3486,7 +3484,6 @@ int ib_send_cm_sidr_req(struct ib_cm_id *cm_id,
	spin_lock_irqsave(&cm_id_priv->lock, flags);
	cm_move_av_from_path(&cm_id_priv->av, &av);
	cm_id->service_id = param->service_id;
	cm_id->service_mask = ~cpu_to_be64(0);
	cm_id_priv->timeout_ms = param->timeout_ms;
	cm_id_priv->max_cm_retries = param->max_cm_retries;
	if (cm_id->state != IB_CM_IDLE) {
@@ -3561,7 +3558,6 @@ static int cm_sidr_req_handler(struct cm_work *work)
		cpu_to_be32(IBA_GET(CM_SIDR_REQ_REQUESTID, sidr_req_msg));
	cm_id_priv->id.service_id =
		cpu_to_be64(IBA_GET(CM_SIDR_REQ_SERVICEID, sidr_req_msg));
	cm_id_priv->id.service_mask = ~cpu_to_be64(0);
	cm_id_priv->tid = sidr_req_msg->hdr.tid;

	wc = work->mad_recv_wc->wc;
@@ -4134,6 +4130,10 @@ static int cm_init_qp_rtr_attr(struct cm_id_private *cm_id_priv,
		*qp_attr_mask = IB_QP_STATE | IB_QP_AV | IB_QP_PATH_MTU |
				IB_QP_DEST_QPN | IB_QP_RQ_PSN;
		qp_attr->ah_attr = cm_id_priv->av.ah_attr;
		if ((qp_attr->ah_attr.type == RDMA_AH_ATTR_TYPE_IB) &&
		    cm_id_priv->av.dlid_datapath &&
		    (cm_id_priv->av.dlid_datapath != 0xffff))
			qp_attr->ah_attr.ib.dlid = cm_id_priv->av.dlid_datapath;
		qp_attr->path_mtu = cm_id_priv->path_mtu;
		qp_attr->dest_qp_num = be32_to_cpu(cm_id_priv->remote_qpn);
		qp_attr->rq_psn = be32_to_cpu(cm_id_priv->rq_psn);
+69 −19
Original line number Diff line number Diff line
@@ -2026,6 +2026,8 @@ static void _destroy_id(struct rdma_id_private *id_priv,
		cma_id_put(id_priv->id.context);

	kfree(id_priv->id.route.path_rec);
	kfree(id_priv->id.route.path_rec_inbound);
	kfree(id_priv->id.route.path_rec_outbound);

	put_net(id_priv->id.route.addr.dev_addr.net);
	kfree(id_priv);
@@ -2241,14 +2243,14 @@ cma_ib_new_conn_id(const struct rdma_cm_id *listen_id,
		goto err;

	rt = &id->route;
	rt->num_paths = ib_event->param.req_rcvd.alternate_path ? 2 : 1;
	rt->path_rec = kmalloc_array(rt->num_paths, sizeof(*rt->path_rec),
				     GFP_KERNEL);
	rt->num_pri_alt_paths = ib_event->param.req_rcvd.alternate_path ? 2 : 1;
	rt->path_rec = kmalloc_array(rt->num_pri_alt_paths,
				     sizeof(*rt->path_rec), GFP_KERNEL);
	if (!rt->path_rec)
		goto err;

	rt->path_rec[0] = *path;
	if (rt->num_paths == 2)
	if (rt->num_pri_alt_paths == 2)
		rt->path_rec[1] = *ib_event->param.req_rcvd.alternate_path;

	if (net_dev) {
@@ -2817,26 +2819,72 @@ int rdma_set_min_rnr_timer(struct rdma_cm_id *id, u8 min_rnr_timer)
}
EXPORT_SYMBOL(rdma_set_min_rnr_timer);

static void route_set_path_rec_inbound(struct cma_work *work,
				       struct sa_path_rec *path_rec)
{
	struct rdma_route *route = &work->id->id.route;

	if (!route->path_rec_inbound) {
		route->path_rec_inbound =
			kzalloc(sizeof(*route->path_rec_inbound), GFP_KERNEL);
		if (!route->path_rec_inbound)
			return;
	}

	*route->path_rec_inbound = *path_rec;
}

static void route_set_path_rec_outbound(struct cma_work *work,
					struct sa_path_rec *path_rec)
{
	struct rdma_route *route = &work->id->id.route;

	if (!route->path_rec_outbound) {
		route->path_rec_outbound =
			kzalloc(sizeof(*route->path_rec_outbound), GFP_KERNEL);
		if (!route->path_rec_outbound)
			return;
	}

	*route->path_rec_outbound = *path_rec;
}

static void cma_query_handler(int status, struct sa_path_rec *path_rec,
			      void *context)
			      int num_prs, void *context)
{
	struct cma_work *work = context;
	struct rdma_route *route;
	int i;

	route = &work->id->id.route;

	if (!status) {
		route->num_paths = 1;
		*route->path_rec = *path_rec;
	} else {
	if (status)
		goto fail;

	for (i = 0; i < num_prs; i++) {
		if (!path_rec[i].flags || (path_rec[i].flags & IB_PATH_GMP))
			*route->path_rec = path_rec[i];
		else if (path_rec[i].flags & IB_PATH_INBOUND)
			route_set_path_rec_inbound(work, &path_rec[i]);
		else if (path_rec[i].flags & IB_PATH_OUTBOUND)
			route_set_path_rec_outbound(work, &path_rec[i]);
	}
	if (!route->path_rec) {
		status = -EINVAL;
		goto fail;
	}

	route->num_pri_alt_paths = 1;
	queue_work(cma_wq, &work->work);
	return;

fail:
	work->old_state = RDMA_CM_ROUTE_QUERY;
	work->new_state = RDMA_CM_ADDR_RESOLVED;
	work->event.event = RDMA_CM_EVENT_ROUTE_ERROR;
	work->event.status = status;
	pr_debug_ratelimited("RDMA CM: ROUTE_ERROR: failed to query path. status %d\n",
			     status);
	}

	queue_work(cma_wq, &work->work);
}

@@ -3081,7 +3129,7 @@ int rdma_set_ib_path(struct rdma_cm_id *id,
		dev_put(ndev);
	}

	id->route.num_paths = 1;
	id->route.num_pri_alt_paths = 1;
	return 0;

err_free:
@@ -3214,7 +3262,7 @@ static int cma_resolve_iboe_route(struct rdma_id_private *id_priv)
		goto err1;
	}

	route->num_paths = 1;
	route->num_pri_alt_paths = 1;

	ndev = cma_iboe_set_path_rec_l2_fields(id_priv);
	if (!ndev) {
@@ -3274,7 +3322,7 @@ static int cma_resolve_iboe_route(struct rdma_id_private *id_priv)
err2:
	kfree(route->path_rec);
	route->path_rec = NULL;
	route->num_paths = 0;
	route->num_pri_alt_paths = 0;
err1:
	kfree(work);
	return ret;
@@ -4265,7 +4313,9 @@ static int cma_connect_ib(struct rdma_id_private *id_priv,
	}

	req.primary_path = &route->path_rec[0];
	if (route->num_paths == 2)
	req.primary_path_inbound = route->path_rec_inbound;
	req.primary_path_outbound = route->path_rec_outbound;
	if (route->num_pri_alt_paths == 2)
		req.alternate_path = &route->path_rec[1];

	req.ppath_sgid_attr = id_priv->id.route.addr.dev_addr.sgid_attr;
+1 −1
Original line number Diff line number Diff line
@@ -292,7 +292,7 @@ static struct config_group *make_cma_dev(struct config_group *group,
		goto fail;
	}

	strlcpy(cma_dev_group->name, name, sizeof(cma_dev_group->name));
	strscpy(cma_dev_group->name, name, sizeof(cma_dev_group->name));

	config_group_init_type_name(&cma_dev_group->ports_group, "ports",
				    &cma_ports_group_type);
+2 −2
Original line number Diff line number Diff line
@@ -422,7 +422,7 @@ int ib_device_rename(struct ib_device *ibdev, const char *name)
		return ret;
	}

	strlcpy(ibdev->name, name, IB_DEVICE_NAME_MAX);
	strscpy(ibdev->name, name, IB_DEVICE_NAME_MAX);
	ret = rename_compat_devs(ibdev);

	downgrade_write(&devices_rwsem);
@@ -1217,7 +1217,7 @@ static int assign_name(struct ib_device *device, const char *name)
		ret = -ENFILE;
		goto out;
	}
	strlcpy(device->name, dev_name(&device->dev), IB_DEVICE_NAME_MAX);
	strscpy(device->name, dev_name(&device->dev), IB_DEVICE_NAME_MAX);

	ret = xa_alloc_cyclic(&devices, &device->index, device, xa_limit_31b,
			&last_id, GFP_KERNEL);
Loading