[v1,34/72] net/mlx5/windows: implement mlx5 mac addr add

Message ID 20201027232335.31427-35-ophirmu@nvidia.com (mailing list archive)
State Superseded, archived
Delegated to: Raslan Darawsheh
Headers
Series mlx5 Windows support - part #5 |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Ophir Munk Oct. 27, 2020, 11:22 p.m. UTC
  From: Tal Shnaiderman <talshn@nvidia.com>

Get the list of MAC addresses and verify if the input mac parameter
already exists. If not - return -ENOTSUP (as Windows does not support
adding new MAC addresses). If the MAC address exists (EEXIST) return 0
(the equivalent of Linux implementation of this API).

Signed-off-by: Tal Shnaiderman <talshn@nvidia.com>
---
 drivers/net/mlx5/windows/mlx5_os.c | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)
  

Comments

Narcisa Ana Maria Vasile Nov. 11, 2020, 12:08 a.m. UTC | #1
On Tue, Oct 27, 2020 at 11:22:57PM +0000, Ophir Munk wrote:
> From: Tal Shnaiderman <talshn@nvidia.com>
> 
> Get the list of MAC addresses and verify if the input mac parameter
> already exists. If not - return -ENOTSUP (as Windows does not support
> adding new MAC addresses). If the MAC address exists (EEXIST) return 0
> (the equivalent of Linux implementation of this API).
> 
> Signed-off-by: Tal Shnaiderman <talshn@nvidia.com>
> ---
>  drivers/net/mlx5/windows/mlx5_os.c | 36 ++++++++++++++++++++++++++++++++++++
>  1 file changed, 36 insertions(+)
> 
> diff --git a/drivers/net/mlx5/windows/mlx5_os.c b/drivers/net/mlx5/windows/mlx5_os.c
> index b0cc9f3..6e27474 100644
> --- a/drivers/net/mlx5/windows/mlx5_os.c
> +++ b/drivers/net/mlx5/windows/mlx5_os.c
> @@ -183,6 +183,42 @@ mlx5_os_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index)
>  }
>  
> + *
> + * @return
> + *   0 on success, a negative errno value otherwise
> + */
> +int
> +mlx5_os_mac_addr_add(struct rte_eth_dev *dev, struct rte_ether_addr *mac,
> +		     uint32_t index)
> +{
> +	(void)index;
> +	struct rte_ether_addr lmac;
> +
> +	if (mlx5_get_mac(dev, &lmac.addr_bytes)) {
> +		DRV_LOG(ERR,
> +			"port %u cannot get MAC address, is mlx5_en"
> +			" loaded? (errno: %s)",
> +			dev->data->port_id, strerror(rte_errno));
> +		return rte_errno;

Should it be "return -rte_errno" here?

> +	}
> +	if (memcmp(&lmac, mac, sizeof(struct rte_ether_addr))) {
> +		DRV_LOG(ERR,
> +			"adding new mac address to device is unsupported");
> +		return -ENOTSUP;
> +	}
> +	return 0;
> +}
> +
> +/**
>   * Modify a VF MAC address
>   * Currently it has no support under Windows.
>   *
> -- 
> 2.8.4
  
Tal Shnaiderman Nov. 14, 2020, 9:49 p.m. UTC | #2
> Subject: Re: [dpdk-dev] [PATCH v1 34/72] net/mlx5/windows: implement
> mlx5 mac addr add
> 
> On Tue, Oct 27, 2020 at 11:22:57PM +0000, Ophir Munk wrote:
> > From: Tal Shnaiderman <talshn@nvidia.com>
> >
> > Get the list of MAC addresses and verify if the input mac parameter
> > already exists. If not - return -ENOTSUP (as Windows does not support
> > adding new MAC addresses). If the MAC address exists (EEXIST) return 0
> > (the equivalent of Linux implementation of this API).
> >
> > Signed-off-by: Tal Shnaiderman <talshn@nvidia.com>
> > ---
> >  drivers/net/mlx5/windows/mlx5_os.c | 36
> > ++++++++++++++++++++++++++++++++++++
> >  1 file changed, 36 insertions(+)
> >
> > diff --git a/drivers/net/mlx5/windows/mlx5_os.c
> > b/drivers/net/mlx5/windows/mlx5_os.c
> > index b0cc9f3..6e27474 100644
> > --- a/drivers/net/mlx5/windows/mlx5_os.c
> > +++ b/drivers/net/mlx5/windows/mlx5_os.c
> > @@ -183,6 +183,42 @@ mlx5_os_mac_addr_remove(struct rte_eth_dev
> *dev,
> > uint32_t index)  }
> >
> > + *
> > + * @return
> > + *   0 on success, a negative errno value otherwise
> > + */
> > +int
> > +mlx5_os_mac_addr_add(struct rte_eth_dev *dev, struct rte_ether_addr
> *mac,
> > +		     uint32_t index)
> > +{
> > +	(void)index;
> > +	struct rte_ether_addr lmac;
> > +
> > +	if (mlx5_get_mac(dev, &lmac.addr_bytes)) {
> > +		DRV_LOG(ERR,
> > +			"port %u cannot get MAC address, is mlx5_en"
> > +			" loaded? (errno: %s)",
> > +			dev->data->port_id, strerror(rte_errno));
> > +		return rte_errno;
> 
> Should it be "return -rte_errno" here?

Actually, mlx5_get_mac return a negative value in rte_errno in case of failure.

> 
> > +	}
> > +	if (memcmp(&lmac, mac, sizeof(struct rte_ether_addr))) {
> > +		DRV_LOG(ERR,
> > +			"adding new mac address to device is unsupported");
> > +		return -ENOTSUP;
> > +	}
> > +	return 0;
> > +}
> > +
> > +/**
> >   * Modify a VF MAC address
> >   * Currently it has no support under Windows.
> >   *
> > --
> > 2.8.4
  

Patch

diff --git a/drivers/net/mlx5/windows/mlx5_os.c b/drivers/net/mlx5/windows/mlx5_os.c
index b0cc9f3..6e27474 100644
--- a/drivers/net/mlx5/windows/mlx5_os.c
+++ b/drivers/net/mlx5/windows/mlx5_os.c
@@ -183,6 +183,42 @@  mlx5_os_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index)
 }
 
 /**
+ * Adds a MAC address to the device
+ * Currently it has no support under Windows.
+ *
+ * @param dev
+ *   Pointer to Ethernet device structure.
+ * @param mac_addr
+ *   MAC address to register.
+ * @param index
+ *   MAC address index.
+ *
+ * @return
+ *   0 on success, a negative errno value otherwise
+ */
+int
+mlx5_os_mac_addr_add(struct rte_eth_dev *dev, struct rte_ether_addr *mac,
+		     uint32_t index)
+{
+	(void)index;
+	struct rte_ether_addr lmac;
+
+	if (mlx5_get_mac(dev, &lmac.addr_bytes)) {
+		DRV_LOG(ERR,
+			"port %u cannot get MAC address, is mlx5_en"
+			" loaded? (errno: %s)",
+			dev->data->port_id, strerror(rte_errno));
+		return rte_errno;
+	}
+	if (memcmp(&lmac, mac, sizeof(struct rte_ether_addr))) {
+		DRV_LOG(ERR,
+			"adding new mac address to device is unsupported");
+		return -ENOTSUP;
+	}
+	return 0;
+}
+
+/**
  * Modify a VF MAC address
  * Currently it has no support under Windows.
  *