RE: [PATCH v3 rdma-next 04/10] RDMA/nldev: provide detailed CM_ID information

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> 
> On Mon, Feb 26, 2018 at 03:22:25PM -0800, Steve Wise wrote:
> > +static int fill_res_cm_id_entry(struct sk_buff *msg,
> > +				struct netlink_callback *cb,
> > +				struct rdma_restrack_entry *res, uint32_t
> port)
> > +{
> > +	struct rdma_id_private *id_priv =
> > +				container_of(res, struct rdma_id_private,
> res);
> > +	struct rdma_cm_id *cm_id = &id_priv->id;
> > +	struct nlattr *entry_attr;
> > +
> > +	if (port && port != cm_id->port_num)
> > +		return 0;
> > +
> > +	entry_attr = nla_nest_start(msg,
> RDMA_NLDEV_ATTR_RES_CM_ID_ENTRY);
> > +	if (!entry_attr)
> > +		goto out;
> > +
> > +	if (cm_id->port_num &&
> > +	    nla_put_u32(msg, RDMA_NLDEV_ATTR_PORT_INDEX, cm_id-
> >port_num))
> > +		goto err;
> > +
> > +	if (id_priv->qp_num &&
> > +	    nla_put_u32(msg, RDMA_NLDEV_ATTR_RES_LQPN, id_priv-
> >qp_num))
> > +		goto err;
> > +
> > +	if (nla_put_u32(msg, RDMA_NLDEV_ATTR_RES_PS, cm_id->ps))
> > +		goto err;
> > +
> > +	if (nla_put_u8(msg, RDMA_NLDEV_ATTR_RES_TYPE, cm_id-
> >qp_type))
> > +		goto err;
> > +	if (nla_put_u8(msg, RDMA_NLDEV_ATTR_RES_STATE, id_priv->state))
> > +		goto err;
> > +
> > +	if (nla_put(msg, RDMA_NLDEV_ATTR_RES_SRC_ADDR,
> > +			    sizeof(cm_id->route.addr.src_addr),
> > +			    &cm_id->route.addr.src_addr))
> > +		goto err;
> > +	if (nla_put(msg, RDMA_NLDEV_ATTR_RES_DST_ADDR,
> > +			    sizeof(cm_id->route.addr.dst_addr),
> > +			    &cm_id->route.addr.dst_addr))
> > +		goto err;
> > +
> > +	if (id_priv->caller) {
> > +		if (nla_put_string(msg,
> RDMA_NLDEV_ATTR_RES_KERN_NAME,
> > +				   id_priv->caller))
> > +			goto err;
> > +	} else {
> > +		/* CMA keeps the owning pid. */
> > +		if (nla_put_u32(msg, RDMA_NLDEV_ATTR_RES_PID, id_priv-
> >owner))
> > +			goto err;
> > +	}
> > +
> > +	nla_nest_end(msg, entry_attr);
> > +	return 0;
> > +
> > +err:
> > +	nla_nest_cancel(msg, entry_attr);
> > +out:
> > +	return -EMSGSIZE;
> > +}
> 
> That is alot nicer with the helper..
> 
> >  static int nldev_get_doit(struct sk_buff *skb, struct nlmsghdr *nlh,
> >  			  struct netlink_ext_ack *extack)
> >  {
> > @@ -583,7 +653,7 @@ static int res_get_common_dumpit(struct sk_buff
> *skb,
> >  	err = nlmsg_parse(cb->nlh, 0, tb, RDMA_NLDEV_ATTR_MAX - 1,
> >  			  nldev_policy, NULL);
> >  	/*
> > -	 * Right now, we are expecting the device index to get QP
> information,
> > +	 * Right now, we are expecting the device index to get res
> information,
> >  	 * but it is possible to extend this code to return all devices in
> 
> This hunk looks like it should be in another patch

Oops.  Yea.

Steve.

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux