Thread (6 messages) 6 messages, 4 authors, 2021-04-13

Re: [PATCH rdma-next v2] RDMA/mlx5: Expose private query port

From: Mark Bloch <mbloch@nvidia.com>
Date: 2021-04-13 20:25:59
Also in: linux-rdma


On 4/13/2021 23:03, Jason Gunthorpe wrote:
On Thu, Apr 01, 2021 at 11:50:04AM +0300, Leon Romanovsky wrote:
quoted
+static int UVERBS_HANDLER(MLX5_IB_METHOD_QUERY_PORT)(
+	struct uverbs_attr_bundle *attrs)
+{
+	struct mlx5_ib_uapi_query_port *info;
+	struct mlx5_ib_ucontext *c;
+	struct mlx5_ib_dev *dev;
+	u32 port_num;
+	int ret;
+
+	if (uverbs_copy_from(&port_num, attrs,
+			     MLX5_IB_ATTR_QUERY_PORT_PORT_NUM))
+		return -EFAULT;
+
+	c = to_mucontext(ib_uverbs_get_ucontext(attrs));
+	if (IS_ERR(c))
+		return PTR_ERR(c);
+	dev = to_mdev(c->ibucontext.device);
+
+	if (!rdma_is_port_valid(&dev->ib_dev, port_num))
+		return -EINVAL;
+
+	info = uverbs_zalloc(attrs, sizeof(*info));
+	if (IS_ERR(info))
+		return PTR_ERR(info);
This allocation is not needed, info is small enough to be on the stack
quoted
+
+	if (mlx5_eswitch_mode(dev->mdev) == MLX5_ESWITCH_OFFLOADS) {
+		ret = fill_switchdev_info(dev, port_num, info);
+		if (ret)
+			return ret;
+	}
+
+	return uverbs_copy_to(attrs, MLX5_IB_ATTR_QUERY_PORT, info,
+			      sizeof(*info));
This should be 

uverbs_copy_to_struct_or_zero()
Will address both comments in the v3. thanks.

Mark
Jason
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help