src/dpdk/drivers/common/mlx5/linux/mlx5_nl.c
int
mlx5_nl_switch_info(int nl, unsigned int ifindex,
		    struct mlx5_switch_info *info)
{
	struct {
		struct nlmsghdr nh;
		struct ifinfomsg info;
		struct rtattr rta;
		uint32_t extmask;
	} req = {
		.nh = {
			.nlmsg_len = NLMSG_LENGTH
					(sizeof(req.info) +
					 RTA_LENGTH(sizeof(uint32_t))),
			.nlmsg_type = RTM_GETLINK,
			.nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK,
		},
		.info = {
			.ifi_family = AF_UNSPEC,
			.ifi_index = ifindex,
		},
		.rta = {
			.rta_type = IFLA_EXT_MASK,
			.rta_len = RTA_LENGTH(sizeof(int32_t)),
		},
		.extmask = RTE_LE32(1),
	};
	uint32_t sn = MLX5_NL_SN_GENERATE;
	int ret;

	ret = mlx5_nl_send(nl, &req.nh, sn);
	if (ret >= 0)
		ret = mlx5_nl_recv(nl, sn, mlx5_nl_switch_info_cb, info);
	if (info->master && info->representor) {
		DRV_LOG(ERR, "ifindex %u device is recognized as master"
			     " and as representor", ifindex);
		rte_errno = ENODEV;
		ret = -rte_errno;
	}
	return ret;
}
/**
 * Get switch information associated with network interface.
 *
 * @param nl
 *   Netlink socket of the ROUTE kind (NETLINK_ROUTE).
 * @param ifindex
 *   Network interface index.
 * @param[out] info
 *   Switch information object, populated in case of success.
 *
 * @return
 *   0 on success, a negative errno value otherwise and rte_errno is set.
 */
Get switch information associated with network interface.
@param nl
Netlink socket of the ROUTE kind (NETLINK_ROUTE).
@param ifindex
Network interface index.
@param[out] info
Switch information object, populated in case of success.

@return
0 on success, a negative errno value otherwise and rte_errno is set.
Get switch information associated with network interface . @param nl Netlink socket of the ROUTE kind ( NETLINK_ROUTE ) . @param ifindex Network interface index . @param [ out ] info Switch information object populated in case of success . @return 0 on success a negative errno value otherwise and rte_errno is set .
int
mlx5_nl_switch_info(int nl, unsigned int ifindex,
		    struct mlx5_switch_info *info)
{
	struct {
		struct nlmsghdr nh;
		struct ifinfomsg info;
		struct rtattr rta;
		uint32_t extmask;
	} req = {
		.nh = {
			.nlmsg_len = NLMSG_LENGTH
					(sizeof(req.info) +
					 RTA_LENGTH(sizeof(uint32_t))),
			.nlmsg_type = RTM_GETLINK,
			.nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK,
		},
		.info = {
			.ifi_family = AF_UNSPEC,
			.ifi_index = ifindex,
		},
		.rta = {
			.rta_type = IFLA_EXT_MASK,
			.rta_len = RTA_LENGTH(sizeof(int32_t)),
		},
		.extmask = RTE_LE32(1),
	};
	uint32_t sn = MLX5_NL_SN_GENERATE;
	int ret;
	ret = mlx5_nl_send(nl, &req.nh, sn);
	if (ret >= 0)
		ret = mlx5_nl_recv(nl, sn, mlx5_nl_switch_info_cb, info);
	if (info->master && info->representor) {
		DRV_LOG(ERR, "ifindex %u device is recognized as master"
			     " and as representor", ifindex);
		rte_errno = ENODEV;
		ret = -rte_errno;
	}
	return ret;
}
int mlx5_nl_switch_info ( int nl , unsigned int ifindex , struct mlx5_switch_info * info ) { struct { struct nlmsghdr nh ; struct ifinfomsg info ; struct rtattr rta ; uint32_t extmask ; } req = { . nh = { . nlmsg_len = NLMSG_LENGTH ( sizeof ( req . info ) + RTA_LENGTH ( sizeof ( uint32_t ) ) ) , . nlmsg_type = RTM_GETLINK , . nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK , } , . info = { . ifi_family = AF_UNSPEC , . ifi_index = ifindex , } , . rta = { . rta_type = IFLA_EXT_MASK , . rta_len = RTA_LENGTH ( sizeof ( int32_t ) ) , } , . extmask = RTE_LE32 ( 1 ) , } ; uint32_t sn = MLX5_NL_SN_GENERATE ; int ret ; ret = mlx5_nl_send ( nl , & req . nh , sn ) ; if ( ret >= 0 ) ret = mlx5_nl_recv ( nl , sn , mlx5_nl_switch_info_cb , info ) ; if ( info -> master && info -> representor ) { DRV_LOG ( ERR , " " " " , ifindex ) ; rte_errno = ENODEV ; ret = - rte_errno ; } return ret ; }
Get switch information associated with network interface.
Get switch information associated with network interface .