[dpdk-dev] [PATCH v2 6/7] net/mlx5: probe all port representors

Shahaf Shuler shahafs at mellanox.com
Sun Jun 17 12:15:07 CEST 2018


Hi Adrien,

Saturday, June 16, 2018 11:58 AM, Xueming(Steven) Li:
> Subject: RE: [dpdk-dev] [PATCH v2 6/7] net/mlx5: probe all port representors
> 
> > -----Original Message-----
> > From: dev <dev-bounces at dpdk.org> On Behalf Of Adrien Mazarguil
> > Sent: Thursday, June 14, 2018 4:35 PM
> > To: Shahaf Shuler <shahafs at mellanox.com>
> > Cc: dev at dpdk.org
> > Subject: [dpdk-dev] [PATCH v2 6/7] net/mlx5: probe all port
> > representors
> >
> > Probe existing port representors in addition to their master device and
> associate them automatically.
> >
> > To avoid name collision between Ethernet devices, their names use the
> > same convention as ixgbe and i40e PMDs, that is, instead of only a PCI
> address in DBDF notation:
> >
> > - "net_{DBDF}_0" for master/switch devices.

This is breaking compatibility for application using the device names in order to attach them to the application (e.g. OVS-DPDK). 
Before this patch the naming scheme for non-representor port is "{DBDF}". 

Can we preserve the compatibility and add appropriate suffix for the representor case? 

> > - "net_{DBDF}_representor_{rep}" with "rep" starting from 0 for port
> >   representors.
> >
> > Both optionally suffixed with "_port_{num}" instead of " port {num}"
> > for devices that expose several Verbs ports (note this is never the case on
> mlx5, but kept for historical reasons for the time being).
> >
> > (Patch based on prior work from Yuanhan Liu)
> >
> > Signed-off-by: Adrien Mazarguil <adrien.mazarguil at 6wind.com>
> > --
> > v2 changes:
> >
> > - Added representor information to dev_infos_get(). DPDK port ID of
> master
> >   device is now stored in the private structure to retrieve it
> >   conveniently.
> > - Master device is assigned dummy representor ID value -1 to better
> >   distinguish from the the first actual representor reported by
> >   dev_infos_get() as those are indexed from 0.
> > - Added RTE_ETH_DEV_REPRESENTOR device flag.
> > ---
> >  drivers/net/mlx5/mlx5.c        | 138 ++++++++++++++++++++++++--------
> >  drivers/net/mlx5/mlx5.h        |   9 ++-
> >  drivers/net/mlx5/mlx5_ethdev.c | 151
> ++++++++++++++++++++++++++++++++----
> >  drivers/net/mlx5/mlx5_mac.c    |   2 +-
> >  drivers/net/mlx5/mlx5_stats.c  |   6 +-
> >  5 files changed, 252 insertions(+), 54 deletions(-)
> >
> > diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index
> > 498f80c89..716c9d9a5 100644
> > --- a/drivers/net/mlx5/mlx5.c
> > +++ b/drivers/net/mlx5/mlx5.c
> > @@ -304,6 +304,9 @@ mlx5_dev_close(struct rte_eth_dev *dev)
> >  	if (ret)
> >  		DRV_LOG(WARNING, "port %u some flows still remain",
> >  			dev->data->port_id);
> > +	if (!priv->representor &&
> > +	    priv->domain_id != RTE_ETH_DEV_SWITCH_DOMAIN_ID_INVALID)
> > +		claim_zero(rte_eth_switch_domain_free(priv->domain_id));
> >  	memset(priv, 0, sizeof(*priv));
> >  }
> >
> > @@ -648,6 +651,10 @@ mlx5_uar_init_secondary(struct rte_eth_dev
> *dev)
> >   *   Verbs device attributes.
> >   * @param port
> >   *   Verbs port to use (indexed from 1).
> > + * @param master
> > + *   Master device in case @p ibv_dev is a port representor.
> > + * @param rep_id
> > + *   Representor identifier when @p master is non-NULL.
> >   *
> >   * @return
> >   *   A valid Ethernet device object on success, NULL otherwise and
> rte_errno
> > @@ -658,7 +665,9 @@ mlx5_dev_spawn_one(struct rte_device
> *dpdk_dev,
> >  		   struct ibv_device *ibv_dev,
> >  		   int vf,
> >  		   const struct ibv_device_attr_ex *attr,
> > -		   unsigned int port)
> > +		   unsigned int port,
> > +		   struct rte_eth_dev *master,
> > +		   unsigned int rep_id)
> >  {
> >  	struct ibv_context *ctx;
> >  	struct ibv_port_attr port_attr;
> > @@ -802,11 +811,14 @@ mlx5_dev_spawn_one(struct rte_device
> *dpdk_dev,
> >  		" old OFED/rdma-core version or firmware configuration");
> #endif
> >  	config.mpls_en = mpls_en;
> > -	if (attr->orig_attr.phys_port_cnt > 1)
> > -		snprintf(name, sizeof(name), "%s port %u",
> > -			 dpdk_dev->name, port);
> > +	if (!master)
> > +		snprintf(name, sizeof(name), "net_%s_0", dpdk_dev-
> >name);
> >  	else
> > -		snprintf(name, sizeof(name), "%s", dpdk_dev->name);
> > +		snprintf(name, sizeof(name), "net_%s_representor_%u",
> > +			 dpdk_dev->name, rep_id);
> > +	if (attr->orig_attr.phys_port_cnt > 1)
> > +		snprintf(name, sizeof(name), "%s_port_%u", name, port);
> > +	DRV_LOG(DEBUG, "naming Ethernet device \"%s\"", name);
> >  	if (rte_eal_process_type() == RTE_PROC_SECONDARY) {
> >  		eth_dev = rte_eth_dev_attach_secondary(name);
> >  		if (eth_dev == NULL) {
> > @@ -883,6 +895,30 @@ mlx5_dev_spawn_one(struct rte_device
> *dpdk_dev,
> >  	priv->port = port;
> >  	priv->pd = pd;
> >  	priv->mtu = ETHER_MTU;
> > +	/*
> > +	 * Allocate a switch domain for master devices and share it with
> > +	 * port representors.
> > +	 */
> > +	if (!master) {
> > +		priv->representor = 0;
> > +		priv->master_id = -1; /* Updated once known. */
> > +		priv->domain_id =
> RTE_ETH_DEV_SWITCH_DOMAIN_ID_INVALID;
> 
> Domain_id will override below.
> 
> > +		priv->rep_id = -1; /* Dummy unique value. */
> > +		err = rte_eth_switch_domain_alloc(&priv->domain_id);
> > +		if (err) {
> > +			err = rte_errno;
> > +			DRV_LOG(ERR, "unable to allocate switch domain:
> %s",
> > +				strerror(rte_errno));
> > +			goto error;
> > +		}
> > +	} else {
> > +		priv->representor = 1;
> > +		priv->master_id =
> > +			((struct priv *)master->data->dev_private)-
> >master_id;
> > +		priv->domain_id =
> > +			((struct priv *)master->data->dev_private)-
> >domain_id;
> > +		priv->rep_id = rep_id;
> > +	}
> 
> Do you think such information should be set as well in secondary process?
> 
> >  	err = mlx5_args(&config, dpdk_dev->devargs);
> >  	if (err) {
> >  		err = rte_errno;
> > @@ -964,6 +1000,18 @@ mlx5_dev_spawn_one(struct rte_device
> *dpdk_dev,
> >  		err = ENOMEM;
> >  		goto error;
> >  	}
> > +	/*
> > +	 * Now that eth_dev is allocated and its port ID is known, make
> > +	 * non-representor ports target their own port ID as master for
> > +	 * convenience.
> > +	 *
> > +	 * Master port ID is already set for actual representors. Those only
> > +	 * need the right device flag.
> > +	 */
> > +	if (!master)
> > +		priv->master_id = eth_dev->data->port_id;
> > +	else
> > +		eth_dev->data->dev_flags |= RTE_ETH_DEV_REPRESENTOR;
> >  	eth_dev->data->dev_private = priv;
> >  	priv->dev_data = eth_dev->data;
> >  	eth_dev->data->mac_addrs = priv->mac; @@ -1083,8 +1131,12 @@
> > mlx5_dev_spawn_one(struct rte_device *dpdk_dev,
> >  	rte_rwlock_write_unlock(&mlx5_shared_data-
> >mem_event_rwlock);
> >  	return eth_dev;
> >  error:
> > -	if (priv)
> > +	if (priv) {
> > +		if (!priv->representor &&
> > +		    priv->domain_id !=
> RTE_ETH_DEV_SWITCH_DOMAIN_ID_INVALID)
> > +			claim_zero(rte_eth_switch_domain_free(priv-
> >domain_id));
> >  		rte_free(priv);
> > +	}
> >  	if (pd)
> >  		claim_zero(mlx5_glue->dealloc_pd(pd));
> >  	if (eth_dev)
> > @@ -1097,12 +1149,14 @@ mlx5_dev_spawn_one(struct rte_device
> > *dpdk_dev,  }
> >
> >  /**
> > - * Spawn Ethernet devices from Verbs information, one per detected
> port.
> > + * Spawn Ethernet devices from Verbs information, one per detected
> > + port and
> > + * port representor.
> >   *
> >   * @param dpdk_dev
> >   *   Backing DPDK device.
> >   * @param ibv_dev
> > - *   Verbs device.
> > + *   NULL-terminated list of Verbs devices. First entry is the master device
> > + *   (mandatory), followed by optional representors.
> >   * @param vf
> >   *   If nonzero, enable VF-specific features.
> >   *
> > @@ -1113,17 +1167,21 @@ mlx5_dev_spawn_one(struct rte_device
> *dpdk_dev,
> >   */
> >  static struct rte_eth_dev **
> >  mlx5_dev_spawn(struct rte_device *dpdk_dev,
> > -	       struct ibv_device *ibv_dev,
> > +	       struct ibv_device **ibv_dev,
> >  	       int vf)
> >  {
> >  	struct rte_eth_dev **eth_list = NULL;
> >  	struct ibv_context *ctx;
> >  	struct ibv_device_attr_ex attr;
> > +	void *tmp;
> >  	unsigned int i;
> > +	unsigned int j = 0;
> > +	unsigned int n = 0;
> >  	int ret;
> >
> > +next:
> >  	errno = 0;
> > -	ctx = mlx5_glue->open_device(ibv_dev);
> > +	ctx = mlx5_glue->open_device(ibv_dev[j]);
> >  	if (!ctx) {
> >  		rte_errno = errno ? errno : ENODEV;
> >  		if (rte_errno == ENODEV)
> > @@ -1132,7 +1190,7 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,
> >  		else
> >  			DRV_LOG(ERR,
> >  				"cannot use device, are drivers up to date?");
> > -		return NULL;
> > +		goto error;
> >  	}
> >  	ret = mlx5_glue->query_device_ex(ctx, NULL, &attr);
> >  	mlx5_glue->close_device(ctx);
> > @@ -1140,34 +1198,42 @@ mlx5_dev_spawn(struct rte_device
> *dpdk_dev,
> >  		rte_errno = ret;
> >  		DRV_LOG(ERR, "unable to query device information: %s",
> >  			strerror(rte_errno));
> > -		return NULL;
> > +		goto error;
> >  	}
> > -	DRV_LOG(INFO, "%u port(s) detected",
> attr.orig_attr.phys_port_cnt);
> > -	eth_list = malloc(sizeof(*eth_list) *
> > -			  (attr.orig_attr.phys_port_cnt + 1));
> > -	if (!eth_list) {
> > +	DRV_LOG(INFO, "%u port(s) detected on \"%s\"",
> > +		attr.orig_attr.phys_port_cnt, ibv_dev[j]->name);
> > +	tmp = realloc(eth_list, sizeof(*eth_list) *
> > +		      (n + attr.orig_attr.phys_port_cnt + 1));
> > +	if (!tmp) {
> >  		rte_errno = errno;
> > -		return NULL;
> > +		goto error;
> >  	}
> > +	eth_list = tmp;
> >  	for (i = 0; i < attr.orig_attr.phys_port_cnt; ++i) {
> > -		eth_list[i] = mlx5_dev_spawn_one(dpdk_dev, ibv_dev, vf,
> > -						 &attr, i + 1);
> > -		if (eth_list[i])
> > -			continue;
> > -		/* Save rte_errno and roll back in case of failure. */
> > -		ret = rte_errno;
> > -		while (i--) {
> > -			mlx5_dev_close(eth_list[i]);
> > -			if (rte_eal_process_type() == RTE_PROC_PRIMARY)
> > -				rte_free(eth_list[i]->data->dev_private);
> > -			claim_zero(rte_eth_dev_release_port(eth_list[i]));
> > -		}
> > -		free(eth_list);
> > -		rte_errno = ret;
> > -		return NULL;
> > +		eth_list[n] = mlx5_dev_spawn_one(dpdk_dev, ibv_dev[j],
> vf,
> > +						 &attr, i + 1,
> > +						 j ? eth_list[0] : NULL,
> > +						 j - 1);

The representor id is according to the sort made by qsort (based on device names).
A better way may be to set it according to the sysfs information, like you do in the mlx5_get_ifname function.
What do you think? 

> > +		if (!eth_list[n])
> > +			goto error;
> > +		++n;
> >  	}
> > -	eth_list[i] = NULL;
> > +	if (ibv_dev[++j])
> > +		goto next;
> > +	eth_list[n] = NULL;
> >  	return eth_list;
> > +error:
> > +	/* Save rte_errno and roll back in case of failure. */
> > +	ret = rte_errno;
> > +	while (n--) {
> > +		mlx5_dev_close(eth_list[n]);
> > +		if (rte_eal_process_type() == RTE_PROC_PRIMARY)
> > +			rte_free(eth_list[n]->data->dev_private);
> > +		claim_zero(rte_eth_dev_release_port(eth_list[n]));
> > +	}
> > +	free(eth_list);
> > +	rte_errno = ret;
> > +	return NULL;
> >  }
> >
> >  /**
> > @@ -1282,7 +1348,7 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv
> __rte_unused,
> >  				ibv_match[ret]->name, ret - 1);
> >  	}
> >  	if (n)
> > -		eth_list = mlx5_dev_spawn(&pci_dev->device,
> ibv_match[0], vf);
> > +		eth_list = mlx5_dev_spawn(&pci_dev->device, ibv_match,
> vf);
> >  	mlx5_glue->free_device_list(ibv_list);
> >  	if (!n) {
> >  		DRV_LOG(WARNING,
> > @@ -1302,7 +1368,11 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv
> __rte_unused,
> >  		ret = -rte_errno;
> >  	} else {
> >  		for (ret = 0; eth_list[ret]; ++ret) {
> > +			uint32_t restore = eth_list[ret]->data->dev_flags;
> > +
> >  			rte_eth_copy_pci_info(eth_list[ret], pci_dev);
> > +			/* Restore non-PCI flags cleared by the above call. */
> > +			eth_list[ret]->data->dev_flags |= restore;
> >  			rte_eth_dev_probing_finish(eth_list[ret]);
> >  		}
> >  		ret = 0;
> > diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index
> > 997b04a33..0fe467140 100644
> > --- a/drivers/net/mlx5/mlx5.h
> > +++ b/drivers/net/mlx5/mlx5.h
> > @@ -161,6 +161,10 @@ struct priv {
> >  	uint16_t mtu; /* Configured MTU. */
> >  	uint8_t port; /* Physical port number. */
> >  	unsigned int isolated:1; /* Whether isolated mode is enabled. */
> > +	unsigned int representor:1; /* Device is a port representor. */

Why we need above flag? Why can't we use RTE_ETH_DEV_REPRESENTOR from eth_dev->data->dev_flags. 

> > +	uint16_t master_id; /* DPDK port ID of switch domain master. */
> > +	uint16_t domain_id; /* Switch domain identifier. */
> > +	unsigned int rep_id; /* Port representor identifier. */
> >  	/* RX/TX queues. */
> >  	unsigned int rxqs_n; /* RX queues array size. */
> >  	unsigned int txqs_n; /* TX queues array size. */ @@ -209,9 +213,12
> > @@ int mlx5_getenv_int(const char *);
> >
> >  /* mlx5_ethdev.c */
> >
> > +int mlx5_get_master_ifname(const struct rte_eth_dev *dev,
> > +			   char (*ifname)[IF_NAMESIZE]);
> >  int mlx5_get_ifname(const struct rte_eth_dev *dev, char
> > (*ifname)[IF_NAMESIZE]);  int mlx5_ifindex(const struct rte_eth_dev
> > *dev); -int mlx5_ifreq(const struct rte_eth_dev *dev, int req, struct
> > ifreq *ifr);
> > +int mlx5_ifreq(const struct rte_eth_dev *dev, int req, struct ifreq *ifr,
> > +	       int master);
> >  int mlx5_get_mtu(struct rte_eth_dev *dev, uint16_t *mtu);  int
> > mlx5_set_flags(struct rte_eth_dev *dev, unsigned int keep,
> >  		   unsigned int flags);
> > diff --git a/drivers/net/mlx5/mlx5_ethdev.c
> > b/drivers/net/mlx5/mlx5_ethdev.c index 90488af33..9d579659e 100644
> > --- a/drivers/net/mlx5/mlx5_ethdev.c
> > +++ b/drivers/net/mlx5/mlx5_ethdev.c
> > @@ -93,7 +93,7 @@ struct ethtool_link_settings {  #endif
> >
> >  /**
> > - * Get interface name from private structure.
> > + * Get master interface name from private structure.
> >   *
> >   * @param[in] dev
> >   *   Pointer to Ethernet device.
> > @@ -104,7 +104,8 @@ struct ethtool_link_settings {
> >   *   0 on success, a negative errno value otherwise and rte_errno is set.
> >   */
> >  int
> > -mlx5_get_ifname(const struct rte_eth_dev *dev, char
> > (*ifname)[IF_NAMESIZE])
> > +mlx5_get_master_ifname(const struct rte_eth_dev *dev,
> > +		       char (*ifname)[IF_NAMESIZE])
> >  {
> >  	struct priv *priv = dev->data->dev_private;
> >  	DIR *dir;
> > @@ -179,6 +180,113 @@ mlx5_get_ifname(const struct rte_eth_dev *dev,
> > char (*ifname)[IF_NAMESIZE])  }
> >
> >  /**
> > + * Get interface name from private structure.
> > + *
> > + * This is a port representor-aware version of mlx5_get_master_ifname().
> > + *
> > + * @param[in] dev
> > + *   Pointer to Ethernet device.
> > + * @param[out] ifname
> > + *   Interface name output buffer.
> > + *
> > + * @return
> > + *   0 on success, a negative errno value otherwise and rte_errno is set.
> > + */
> > +int
> > +mlx5_get_ifname(const struct rte_eth_dev *dev, char
> > +(*ifname)[IF_NAMESIZE]) {
> > +	struct priv *priv = dev->data->dev_private;
> > +	int ret;
> > +	char master[IF_NAMESIZE];
> > +	FILE *file;
> > +	DIR *dir;
> > +	uint64_t phys_switch_id;
> > +
> > +	if (!priv->representor)
> > +		return mlx5_get_master_ifname(dev, ifname);
> > +	ret = mlx5_get_master_ifname(dev, &master);
> > +	if (ret)
> > +		return ret;
> > +	{
> > +		MKSTR(path, "%s/device/net/%s/phys_switch_id",
> > +		      priv->ibdev_path, master);
> > +
> > +		file = fopen(path, "rb");
> > +	}
> > +	if (!file) {
> > +		rte_errno = errno;
> > +		return -rte_errno;
> > +	}
> > +	ret = fscanf(file, "%" SCNx64, &phys_switch_id);
> > +	fclose(file);
> > +	if (ret != 1) {
> > +		rte_errno = EINVAL;
> > +		return -rte_errno;
> > +	}
> > +	{
> > +		MKSTR(path, "%s/device/net/%s/subsystem",
> > +		      priv->ibdev_path, master);
> > +
> > +		dir = opendir(path);
> > +	}
> > +	if (!dir) {
> > +		rte_errno = errno;
> > +		return -rte_errno;
> > +	}
> > +	/*
> > +	 * Scan network interfaces to find one with matching phys_switch_id
> > +	 * and phys_switch_name.
> > +	 */
> > +	do {
> > +		struct dirent *dent;
> > +		uint64_t phys_switch_id_rep;
> > +		int rep_id;
> > +
> > +		ret = -ENOENT;
> > +		dent = readdir(dir);
> > +		if (!dent)
> > +			break;
> > +		{
> > +			MKSTR(path,
> > +
> "%s/device/net/%s/subsystem/%s/phys_switch_id",
> > +			      priv->ibdev_path, master, dent->d_name);
> > +
> > +			file = fopen(path, "rb");
> > +		}
> > +		if (!file)
> > +			continue;
> > +		ret = fscanf(file, "%" SCNx64, &phys_switch_id_rep);
> > +		fclose(file);
> > +		if (ret != 1)
> > +			continue;
> > +		if (phys_switch_id_rep != phys_switch_id)
> > +			continue;
> > +		{
> > +			MKSTR(path,
> > +
> "%s/device/net/%s/subsystem/%s/phys_port_name",
> > +			      priv->ibdev_path, master, dent->d_name);
> > +
> > +			file = fopen(path, "rb");
> > +		}
> > +		if (!file)
> > +			continue;
> > +		ret = fscanf(file, "%d", &rep_id);
> > +		fclose(file);
> > +		if (ret != 1)
> > +			continue;
> > +		if (rep_id < 0 || (unsigned int)rep_id != priv->rep_id)
> > +			continue;
> > +		strlcpy(*ifname, dent->d_name, sizeof(*ifname));
> > +		ret = 0;
> > +		break;
> > +	} while (1);
> > +	closedir(dir);
> > +	if (ret)
> > +		rte_errno = -ret;
> > +	return ret;
> > +}
> > +
> > +/**
> >   * Get the interface index from device name.
> >   *
> >   * @param[in] dev
> > @@ -214,12 +322,16 @@ mlx5_ifindex(const struct rte_eth_dev *dev)
> >   *   Request number to pass to ioctl().
> >   * @param[out] ifr
> >   *   Interface request structure output buffer.
> > + * @param master
> > + *   When device is a port representor, perform request on master device
> > + *   instead.
> >   *
> >   * @return
> >   *   0 on success, a negative errno value otherwise and rte_errno is set.
> >   */
> >  int
> > -mlx5_ifreq(const struct rte_eth_dev *dev, int req, struct ifreq *ifr)
> > +mlx5_ifreq(const struct rte_eth_dev *dev, int req, struct ifreq *ifr,
> > +	   int master)
> >  {
> >  	int sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_IP);
> >  	int ret = 0;
> > @@ -228,7 +340,10 @@ mlx5_ifreq(const struct rte_eth_dev *dev, int req,
> struct ifreq *ifr)
> >  		rte_errno = errno;
> >  		return -rte_errno;
> >  	}
> > -	ret = mlx5_get_ifname(dev, &ifr->ifr_name);
> > +	if (master)
> > +		ret = mlx5_get_master_ifname(dev, &ifr->ifr_name);
> > +	else
> > +		ret = mlx5_get_ifname(dev, &ifr->ifr_name);
> >  	if (ret)
> >  		goto error;
> >  	ret = ioctl(sock, req, ifr);
> > @@ -258,7 +373,7 @@ int
> >  mlx5_get_mtu(struct rte_eth_dev *dev, uint16_t *mtu)  {
> >  	struct ifreq request;
> > -	int ret = mlx5_ifreq(dev, SIOCGIFMTU, &request);
> > +	int ret = mlx5_ifreq(dev, SIOCGIFMTU, &request, 0);
> >
> >  	if (ret)
> >  		return ret;
> > @@ -282,7 +397,7 @@ mlx5_set_mtu(struct rte_eth_dev *dev, uint16_t
> mtu)  {
> >  	struct ifreq request = { .ifr_mtu = mtu, };
> >
> > -	return mlx5_ifreq(dev, SIOCSIFMTU, &request);
> > +	return mlx5_ifreq(dev, SIOCSIFMTU, &request, 0);
> >  }
> >
> >  /**
> > @@ -302,13 +417,13 @@ int
> >  mlx5_set_flags(struct rte_eth_dev *dev, unsigned int keep, unsigned int
> flags)  {
> >  	struct ifreq request;
> > -	int ret = mlx5_ifreq(dev, SIOCGIFFLAGS, &request);
> > +	int ret = mlx5_ifreq(dev, SIOCGIFFLAGS, &request, 0);
> >
> >  	if (ret)
> >  		return ret;
> >  	request.ifr_flags &= keep;
> >  	request.ifr_flags |= flags & ~keep;
> > -	return mlx5_ifreq(dev, SIOCSIFFLAGS, &request);
> > +	return mlx5_ifreq(dev, SIOCSIFFLAGS, &request, 0);
> >  }
> >
> >  /**
> > @@ -477,6 +592,12 @@ mlx5_dev_infos_get(struct rte_eth_dev *dev,
> struct rte_eth_dev_info *info)
> >  	info->speed_capa = priv->link_speed_capa;
> >  	info->flow_type_rss_offloads = ~MLX5_RSS_HF_MASK;
> >  	mlx5_set_default_params(dev, info);
> > +	if (rte_eth_dev_is_valid_port(priv->master_id)) {
> > +		info->switch_info.name =
> > +			rte_eth_devices[priv->master_id].data->name;
> > +		info->switch_info.domain_id = priv->domain_id;
> > +		info->switch_info.port_id = priv->rep_id;
> > +	}
> >  }
> >
> >  /**
> > @@ -540,7 +661,7 @@ mlx5_link_update_unlocked_gset(struct
> rte_eth_dev *dev,
> >  	int link_speed = 0;
> >  	int ret;
> >
> > -	ret = mlx5_ifreq(dev, SIOCGIFFLAGS, &ifr);
> > +	ret = mlx5_ifreq(dev, SIOCGIFFLAGS, &ifr, 1);
> >  	if (ret) {
> >  		DRV_LOG(WARNING, "port %u ioctl(SIOCGIFFLAGS) failed:
> %s",
> >  			dev->data->port_id, strerror(rte_errno)); @@ -550,7
> +671,7 @@
> > mlx5_link_update_unlocked_gset(struct rte_eth_dev *dev,
> >  	dev_link.link_status = ((ifr.ifr_flags & IFF_UP) &&
> >  				(ifr.ifr_flags & IFF_RUNNING));
> >  	ifr.ifr_data = (void *)&edata;
> > -	ret = mlx5_ifreq(dev, SIOCETHTOOL, &ifr);
> > +	ret = mlx5_ifreq(dev, SIOCETHTOOL, &ifr, 1);
> >  	if (ret) {
> >  		DRV_LOG(WARNING,
> >  			"port %u ioctl(SIOCETHTOOL, ETHTOOL_GSET) failed:
> %s", @@ -611,7
> > +732,7 @@ mlx5_link_update_unlocked_gs(struct rte_eth_dev *dev,
> >  	uint64_t sc;
> >  	int ret;
> >
> > -	ret = mlx5_ifreq(dev, SIOCGIFFLAGS, &ifr);
> > +	ret = mlx5_ifreq(dev, SIOCGIFFLAGS, &ifr, 1);
> >  	if (ret) {
> >  		DRV_LOG(WARNING, "port %u ioctl(SIOCGIFFLAGS) failed:
> %s",
> >  			dev->data->port_id, strerror(rte_errno)); @@ -621,7
> +742,7 @@
> > mlx5_link_update_unlocked_gs(struct rte_eth_dev *dev,
> >  	dev_link.link_status = ((ifr.ifr_flags & IFF_UP) &&
> >  				(ifr.ifr_flags & IFF_RUNNING));
> >  	ifr.ifr_data = (void *)&gcmd;
> > -	ret = mlx5_ifreq(dev, SIOCETHTOOL, &ifr);
> > +	ret = mlx5_ifreq(dev, SIOCETHTOOL, &ifr, 1);
> >  	if (ret) {
> >  		DRV_LOG(DEBUG,
> >  			"port %u ioctl(SIOCETHTOOL,
> ETHTOOL_GLINKSETTINGS)"
> > @@ -638,7 +759,7 @@ mlx5_link_update_unlocked_gs(struct rte_eth_dev
> > *dev,
> >
> >  	*ecmd = gcmd;
> >  	ifr.ifr_data = (void *)ecmd;
> > -	ret = mlx5_ifreq(dev, SIOCETHTOOL, &ifr);
> > +	ret = mlx5_ifreq(dev, SIOCETHTOOL, &ifr, 1);
> >  	if (ret) {
> >  		DRV_LOG(DEBUG,
> >  			"port %u ioctl(SIOCETHTOOL,
> ETHTOOL_GLINKSETTINGS)"
> > @@ -801,7 +922,7 @@ mlx5_dev_get_flow_ctrl(struct rte_eth_dev *dev,
> struct rte_eth_fc_conf *fc_conf)
> >  	int ret;
> >
> >  	ifr.ifr_data = (void *)ðpause;
> > -	ret = mlx5_ifreq(dev, SIOCETHTOOL, &ifr);
> > +	ret = mlx5_ifreq(dev, SIOCETHTOOL, &ifr, 1);
> >  	if (ret) {
> >  		DRV_LOG(WARNING,
> >  			"port %u ioctl(SIOCETHTOOL,
> ETHTOOL_GPAUSEPARAM) failed:"
> > @@ -854,7 +975,7 @@ mlx5_dev_set_flow_ctrl(struct rte_eth_dev *dev,
> struct rte_eth_fc_conf *fc_conf)
> >  		ethpause.tx_pause = 1;
> >  	else
> >  		ethpause.tx_pause = 0;
> > -	ret = mlx5_ifreq(dev, SIOCETHTOOL, &ifr);
> > +	ret = mlx5_ifreq(dev, SIOCETHTOOL, &ifr, 0);
> >  	if (ret) {
> >  		DRV_LOG(WARNING,
> >  			"port %u ioctl(SIOCETHTOOL,
> ETHTOOL_SPAUSEPARAM)"
> > diff --git a/drivers/net/mlx5/mlx5_mac.c b/drivers/net/mlx5/mlx5_mac.c
> > index 672a47619..12ee37f55
> > 100644
> > --- a/drivers/net/mlx5/mlx5_mac.c
> > +++ b/drivers/net/mlx5/mlx5_mac.c
> > @@ -49,7 +49,7 @@ mlx5_get_mac(struct rte_eth_dev *dev, uint8_t
> (*mac)[ETHER_ADDR_LEN])
> >  	struct ifreq request;
> >  	int ret;
> >
> > -	ret = mlx5_ifreq(dev, SIOCGIFHWADDR, &request);
> > +	ret = mlx5_ifreq(dev, SIOCGIFHWADDR, &request, 0);
> >  	if (ret)
> >  		return ret;
> >  	memcpy(mac, request.ifr_hwaddr.sa_data, ETHER_ADDR_LEN); diff -
> -git
> > a/drivers/net/mlx5/mlx5_stats.c b/drivers/net/mlx5/mlx5_stats.c index
> > 875dd1027..91f3d474a 100644
> > --- a/drivers/net/mlx5/mlx5_stats.c
> > +++ b/drivers/net/mlx5/mlx5_stats.c
> > @@ -146,7 +146,7 @@ mlx5_read_dev_counters(struct rte_eth_dev *dev,
> uint64_t *stats)
> >  	et_stats->cmd = ETHTOOL_GSTATS;
> >  	et_stats->n_stats = xstats_ctrl->stats_n;
> >  	ifr.ifr_data = (caddr_t)et_stats;
> > -	ret = mlx5_ifreq(dev, SIOCETHTOOL, &ifr);
> > +	ret = mlx5_ifreq(dev, SIOCETHTOOL, &ifr, 1);
> >  	if (ret) {
> >  		DRV_LOG(WARNING,
> >  			"port %u unable to read statistic values from device",
> @@ -194,7
> > +194,7 @@ mlx5_ethtool_get_stats_n(struct rte_eth_dev *dev) {
> >
> >  	drvinfo.cmd = ETHTOOL_GDRVINFO;
> >  	ifr.ifr_data = (caddr_t)&drvinfo;
> > -	ret = mlx5_ifreq(dev, SIOCETHTOOL, &ifr);
> > +	ret = mlx5_ifreq(dev, SIOCETHTOOL, &ifr, 1);
> >  	if (ret) {
> >  		DRV_LOG(WARNING, "port %u unable to query number of
> statistics",
> >  			dev->data->port_id);
> > @@ -244,7 +244,7 @@ mlx5_xstats_init(struct rte_eth_dev *dev)
> >  	strings->string_set = ETH_SS_STATS;
> >  	strings->len = dev_stats_n;
> >  	ifr.ifr_data = (caddr_t)strings;
> > -	ret = mlx5_ifreq(dev, SIOCETHTOOL, &ifr);
> > +	ret = mlx5_ifreq(dev, SIOCETHTOOL, &ifr, 1);
> >  	if (ret) {
> >  		DRV_LOG(WARNING, "port %u unable to get statistic
> names",
> >  			dev->data->port_id);
> > --
> > 2.11.0


More information about the dev mailing list