Message ID | 20230831142225.588762-1-kheib@redhat.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | [for-next] RDMA/nldev: Add support for reporting ipoib netdev | expand |
On Thu, Aug 31, 2023 at 10:22:25AM -0400, Kamal Heib wrote: > This patch adds support for reporting the ipoib net device for a given > RDMA device by calling ib_get_net_dev_by_params() when filling the > port's info. > > $ rdma link show mlx5_0/1 > link mlx5_0/1 subnet_prefix fe80:0000:0000:0000 lid 66 sm_lid 3 lmc 0 > state ACTIVE physical_state LINK_UP netdev ibp196s0f0 > > Signed-off-by: Kamal Heib <kheib@redhat.com> > --- > drivers/infiniband/core/nldev.c | 19 +++++++++++++++++++ > 1 file changed, 19 insertions(+) Are we sure we want to do this? How does it work with namespaces? > @@ -340,6 +341,21 @@ static int fill_port_info(struct sk_buff *msg, > return -EMSGSIZE; > if (nla_put_u8(msg, RDMA_NLDEV_ATTR_LMC, attr.lmc)) > return -EMSGSIZE; > + ipoib_netdev = ib_get_net_dev_by_params(device, port, > + IB_DEFAULT_PKEY_FULL, > + NULL, NULL); And it doesn't work at all for non-default ipoib interfaces? Jason
On 2023-08-31 20:02, Jason Gunthorpe wrote: > On Thu, Aug 31, 2023 at 10:22:25AM -0400, Kamal Heib wrote: >> This patch adds support for reporting the ipoib net device for a given >> RDMA device by calling ib_get_net_dev_by_params() when filling the >> port's info. >> >> $ rdma link show mlx5_0/1 >> link mlx5_0/1 subnet_prefix fe80:0000:0000:0000 lid 66 sm_lid 3 lmc 0 >> state ACTIVE physical_state LINK_UP netdev ibp196s0f0 >> >> Signed-off-by: Kamal Heib <kheib@redhat.com> >> --- >> drivers/infiniband/core/nldev.c | 19 +++++++++++++++++++ >> 1 file changed, 19 insertions(+) > > Are we sure we want to do this? How does it work with namespaces? You are right, I'll fix it. > >> @@ -340,6 +341,21 @@ static int fill_port_info(struct sk_buff *msg, >> return -EMSGSIZE; >> if (nla_put_u8(msg, RDMA_NLDEV_ATTR_LMC, attr.lmc)) >> return -EMSGSIZE; >> + ipoib_netdev = ib_get_net_dev_by_params(device, port, >> + IB_DEFAULT_PKEY_FULL, >> + NULL, NULL); > > And it doesn't work at all for non-default ipoib interfaces? > I'll fix it. Thanks, Kamal > Jason >
diff --git a/drivers/infiniband/core/nldev.c b/drivers/infiniband/core/nldev.c index d5d3e4f0de77..fc4ad62dc5c3 100644 --- a/drivers/infiniband/core/nldev.c +++ b/drivers/infiniband/core/nldev.c @@ -308,6 +308,7 @@ static int fill_port_info(struct sk_buff *msg, struct ib_device *device, u32 port, const struct net *net) { + struct net_device *ipoib_netdev = NULL; struct net_device *netdev = NULL; struct ib_port_attr attr; int ret; @@ -340,6 +341,21 @@ static int fill_port_info(struct sk_buff *msg, return -EMSGSIZE; if (nla_put_u8(msg, RDMA_NLDEV_ATTR_LMC, attr.lmc)) return -EMSGSIZE; + ipoib_netdev = ib_get_net_dev_by_params(device, port, + IB_DEFAULT_PKEY_FULL, + NULL, NULL); + if (ipoib_netdev) { + ret = nla_put_u32(msg, + RDMA_NLDEV_ATTR_NDEV_INDEX, + ipoib_netdev->ifindex); + if (ret) + goto out; + ret = nla_put_string(msg, + RDMA_NLDEV_ATTR_NDEV_NAME, + ipoib_netdev->name); + if (ret) + goto out; + } } if (nla_put_u8(msg, RDMA_NLDEV_ATTR_PORT_STATE, attr.state)) return -EMSGSIZE; @@ -357,6 +373,9 @@ static int fill_port_info(struct sk_buff *msg, } out: + if (ipoib_netdev) + dev_put(ipoib_netdev); + if (netdev) dev_put(netdev); return ret;
This patch adds support for reporting the ipoib net device for a given RDMA device by calling ib_get_net_dev_by_params() when filling the port's info. $ rdma link show mlx5_0/1 link mlx5_0/1 subnet_prefix fe80:0000:0000:0000 lid 66 sm_lid 3 lmc 0 state ACTIVE physical_state LINK_UP netdev ibp196s0f0 Signed-off-by: Kamal Heib <kheib@redhat.com> --- drivers/infiniband/core/nldev.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)