There is the routine mlx5_nl_ifindex() returning the
network interface index associated with Infiniband device.
We are going to support multiport IB devices, now function
takes the IB port as argument and returns ifindex associated
with tuple <IB device, IB port>
Signed-off-by: Viacheslav Ovsiienko <viacheslavo@mellanox.com>
Acked-by: Shahaf Shuler <shahafs@mellanox.com>
list[i].ifindex = 0;
else
list[i].ifindex = mlx5_nl_ifindex
list[i].ifindex = 0;
else
list[i].ifindex = mlx5_nl_ifindex
- (nl_rdma, list[i].ibv_dev->name);
+ (nl_rdma, list[i].ibv_dev->name, 1);
if (nl_route < 0 ||
!list[i].ifindex ||
mlx5_nl_switch_info(nl_route, list[i].ifindex,
if (nl_route < 0 ||
!list[i].ifindex ||
mlx5_nl_switch_info(nl_route, list[i].ifindex,
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);
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_ifindex(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);
int mlx5_nl_switch_info(int nl, unsigned int ifindex,
struct mlx5_switch_info *info);
struct mlx5_priv *priv = dev->data->dev_private;
unsigned int ifindex =
priv->nl_socket_rdma >= 0 ?
struct mlx5_priv *priv = dev->data->dev_private;
unsigned int ifindex =
priv->nl_socket_rdma >= 0 ?
- mlx5_nl_ifindex(priv->nl_socket_rdma, priv->ibdev_name) : 0;
+ mlx5_nl_ifindex(priv->nl_socket_rdma, priv->ibdev_name, 1) : 0;
if (!ifindex) {
if (!priv->representor)
if (!ifindex) {
if (!priv->representor)
int mac_n; /**< Number of addresses in the array. */
};
int mac_n; /**< Number of addresses in the array. */
};
-/** Data structure used by mlx5_nl_ifindex_cb(). */
+/** Data structure used by mlx5_nl_cmdget_cb(). */
struct mlx5_nl_ifindex_data {
const char *name; /**< IB device name (in). */
uint32_t ibindex; /**< IB device index (out). */
uint32_t ifindex; /**< Network interface index (out). */
struct mlx5_nl_ifindex_data {
const char *name; /**< IB device name (in). */
uint32_t ibindex; /**< IB device index (out). */
uint32_t ifindex; /**< Network interface index (out). */
+ uint32_t portnum; /**< IB device max port number. */
* 0 on success, a negative errno value otherwise and rte_errno is set.
*/
static int
* 0 on success, a negative errno value otherwise and rte_errno is set.
*/
static int
-mlx5_nl_ifindex_cb(struct nlmsghdr *nh, void *arg)
+mlx5_nl_cmdget_cb(struct nlmsghdr *nh, void *arg)
{
struct mlx5_nl_ifindex_data *data = arg;
size_t off = NLMSG_HDRLEN;
uint32_t ibindex = 0;
uint32_t ifindex = 0;
{
struct mlx5_nl_ifindex_data *data = arg;
size_t off = NLMSG_HDRLEN;
uint32_t ibindex = 0;
uint32_t ifindex = 0;
int found = 0;
if (nh->nlmsg_type !=
int found = 0;
if (nh->nlmsg_type !=
case RDMA_NLDEV_ATTR_NDEV_INDEX:
ifindex = *(uint32_t *)payload;
break;
case RDMA_NLDEV_ATTR_NDEV_INDEX:
ifindex = *(uint32_t *)payload;
break;
+ case RDMA_NLDEV_ATTR_PORT_INDEX:
+ portnum = *(uint32_t *)payload;
+ break;
if (found) {
data->ibindex = ibindex;
data->ifindex = ifindex;
if (found) {
data->ibindex = ibindex;
data->ifindex = ifindex;
+ data->portnum = portnum;
* Netlink socket of the RDMA kind (NETLINK_RDMA).
* @param[in] name
* IB device name.
* Netlink socket of the RDMA kind (NETLINK_RDMA).
* @param[in] name
* IB device name.
+ * @param[in] pindex
+ * IB device port index, starting from 1
* @return
* A valid (nonzero) interface index on success, 0 otherwise and rte_errno
* is set.
*/
unsigned int
* @return
* A valid (nonzero) interface index on success, 0 otherwise and rte_errno
* is set.
*/
unsigned int
-mlx5_nl_ifindex(int nl, const char *name)
+mlx5_nl_ifindex(int nl, const char *name, uint32_t pindex)
- static const uint32_t pindex = 1;
uint32_t seq = random();
struct mlx5_nl_ifindex_data data = {
.name = name,
uint32_t seq = random();
struct mlx5_nl_ifindex_data data = {
.name = name,
ret = mlx5_nl_send(nl, &req.nh, seq);
if (ret < 0)
return 0;
ret = mlx5_nl_send(nl, &req.nh, seq);
if (ret < 0)
return 0;
- ret = mlx5_nl_recv(nl, seq, mlx5_nl_ifindex_cb, &data);
+ ret = mlx5_nl_recv(nl, seq, mlx5_nl_cmdget_cb, &data);
if (ret < 0)
return 0;
if (!data.ibindex)
if (ret < 0)
return 0;
if (!data.ibindex)
ret = mlx5_nl_send(nl, &req.nh, seq);
if (ret < 0)
return 0;
ret = mlx5_nl_send(nl, &req.nh, seq);
if (ret < 0)
return 0;
- ret = mlx5_nl_recv(nl, seq, mlx5_nl_ifindex_cb, &data);
+ ret = mlx5_nl_recv(nl, seq, mlx5_nl_cmdget_cb, &data);
if (ret < 0)
return 0;
if (!data.ifindex)
if (ret < 0)
return 0;
if (!data.ifindex)