net/mlx5: add getting IB ports number for multiport IB
There is the routine mlx5_nl_portnum() added to get the number of ports of multiport Infiniband device. It is assumed the Uplink/VF representors are attached on these ports. Signed-off-by: Viacheslav Ovsiienko <viacheslavo@mellanox.com> Acked-by: Shahaf Shuler <shahafs@mellanox.com>
This commit is contained in:
parent
e505508a38
commit
bbfad6427b
@ -422,6 +422,7 @@ void mlx5_nl_mac_addr_sync(struct rte_eth_dev *dev);
|
||||
void mlx5_nl_mac_addr_flush(struct rte_eth_dev *dev);
|
||||
int mlx5_nl_promisc(struct rte_eth_dev *dev, int enable);
|
||||
int mlx5_nl_allmulti(struct rte_eth_dev *dev, int enable);
|
||||
unsigned int mlx5_nl_portnum(int nl, const char *name);
|
||||
unsigned int mlx5_nl_ifindex(int nl, const char *name, uint32_t pindex);
|
||||
int mlx5_nl_switch_info(int nl, unsigned int ifindex,
|
||||
struct mlx5_switch_info *info);
|
||||
|
@ -825,6 +825,51 @@ mlx5_nl_ifindex(int nl, const char *name, uint32_t pindex)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number of physical ports of given IB device.
|
||||
*
|
||||
* @param nl
|
||||
* Netlink socket of the RDMA kind (NETLINK_RDMA).
|
||||
* @param[in] name
|
||||
* IB device name.
|
||||
*
|
||||
* @return
|
||||
* A valid (nonzero) number of ports on success, 0 otherwise
|
||||
* and rte_errno is set.
|
||||
*/
|
||||
unsigned int
|
||||
mlx5_nl_portnum(int nl, const char *name)
|
||||
{
|
||||
uint32_t seq = random();
|
||||
struct mlx5_nl_ifindex_data data = {
|
||||
.name = name,
|
||||
.ibindex = 0,
|
||||
.ifindex = 0,
|
||||
.portnum = 0,
|
||||
};
|
||||
struct nlmsghdr req = {
|
||||
.nlmsg_len = NLMSG_LENGTH(0),
|
||||
.nlmsg_type = RDMA_NL_GET_TYPE(RDMA_NL_NLDEV,
|
||||
RDMA_NLDEV_CMD_GET),
|
||||
.nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK | NLM_F_DUMP,
|
||||
};
|
||||
int ret;
|
||||
|
||||
ret = mlx5_nl_send(nl, &req, seq);
|
||||
if (ret < 0)
|
||||
return 0;
|
||||
ret = mlx5_nl_recv(nl, seq, mlx5_nl_cmdget_cb, &data);
|
||||
if (ret < 0)
|
||||
return 0;
|
||||
if (!data.ibindex) {
|
||||
rte_errno = ENODEV;
|
||||
return 0;
|
||||
}
|
||||
if (!data.portnum)
|
||||
rte_errno = EINVAL;
|
||||
return data.portnum;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process switch information from Netlink message.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user