DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] net/octeontx: fix user supplied index in MAC address add
@ 2020-01-24  6:35 Sunil Kumar Kori
  2020-01-29  6:42 ` [dpdk-dev] [PATCH v2 1/1] " Sunil Kumar Kori
  0 siblings, 1 reply; 4+ messages in thread
From: Sunil Kumar Kori @ 2020-01-24  6:35 UTC (permalink / raw)
  To: Harman Kalra; +Cc: dev, Sunil Kumar Kori

Earlier after a successful mac_addr_add operation, index was returned
by underlying layer which was unused but same as provided by DPDK API.

So API is enhanced to use application provided index location to add
MAC address entry.

Fixes: e4373bf1b3f5 ("net/octeontx: add unicast MAC filter")

Signed-off-by: Sunil Kumar Kori <skori@marvell.com>
---
 drivers/net/octeontx/base/octeontx_bgx.c | 13 ++++++-------
 drivers/net/octeontx/base/octeontx_bgx.h |  7 ++++++-
 drivers/net/octeontx/octeontx_ethdev.c   | 18 ++++++++++++++----
 3 files changed, 26 insertions(+), 12 deletions(-)

diff --git a/drivers/net/octeontx/base/octeontx_bgx.c b/drivers/net/octeontx/base/octeontx_bgx.c
index e70255b11..a2d615fb2 100644
--- a/drivers/net/octeontx/base/octeontx_bgx.c
+++ b/drivers/net/octeontx/base/octeontx_bgx.c
@@ -245,22 +245,21 @@ octeontx_bgx_port_mac_set(int port, uint8_t *mac_addr)
 }
 
 int
-octeontx_bgx_port_mac_add(int port, uint8_t *mac_addr)
+octeontx_bgx_port_mac_add(int port, uint8_t *mac_addr, int index)
 {
+	struct octeontx_mbox_bgx_port_mac_filter filter;
 	struct octeontx_mbox_hdr hdr;
-	int resp = 0;
 	int len = 6;
-	int res = 0;
 
 	hdr.coproc = OCTEONTX_BGX_COPROC;
 	hdr.msg = MBOX_BGX_PORT_ADD_MACADDR;
 	hdr.vfid = port;
 
-	res = octeontx_mbox_send(&hdr, mac_addr, len, &resp, sizeof(int));
-	if (res < 0)
-		return -EACCES;
+	memcpy(filter.mac_addr, mac_addr, len);
+	filter.index = index;
+	len = sizeof(struct octeontx_mbox_bgx_port_mac_filter);
 
-	return res;
+	return octeontx_mbox_send(&hdr, &filter, len, NULL, 0);
 }
 
 int
diff --git a/drivers/net/octeontx/base/octeontx_bgx.h b/drivers/net/octeontx/base/octeontx_bgx.h
index caaff179c..11c25db67 100644
--- a/drivers/net/octeontx/base/octeontx_bgx.h
+++ b/drivers/net/octeontx/base/octeontx_bgx.h
@@ -112,6 +112,11 @@ typedef struct octeontx_mbox_bgx_port_stats {
 	uint64_t rx_jabber_errors;
 } octeontx_mbox_bgx_port_stats_t;
 
+struct octeontx_mbox_bgx_port_mac_filter {
+	uint8_t mac_addr[6];
+	int index;
+};
+
 int octeontx_bgx_port_open(int port, octeontx_mbox_bgx_port_conf_t *conf);
 int octeontx_bgx_port_close(int port);
 int octeontx_bgx_port_start(int port);
@@ -123,7 +128,7 @@ int octeontx_bgx_port_stats_clr(int port);
 int octeontx_bgx_port_link_status(int port);
 int octeontx_bgx_port_promisc_set(int port, int en);
 int octeontx_bgx_port_mac_set(int port, uint8_t *mac_addr);
-int octeontx_bgx_port_mac_add(int port, uint8_t *mac_addr);
+int octeontx_bgx_port_mac_add(int port, uint8_t *mac_addr, int index);
 int octeontx_bgx_port_mac_del(int port, uint32_t index);
 int octeontx_bgx_port_mac_entries_get(int port);
 
diff --git a/drivers/net/octeontx/octeontx_ethdev.c b/drivers/net/octeontx/octeontx_ethdev.c
index e23162d8a..e34f7cef3 100644
--- a/drivers/net/octeontx/octeontx_ethdev.c
+++ b/drivers/net/octeontx/octeontx_ethdev.c
@@ -573,13 +573,14 @@ octeontx_dev_mac_addr_del(struct rte_eth_dev *dev, uint32_t index)
 static int
 octeontx_dev_mac_addr_add(struct rte_eth_dev *dev,
 			  struct rte_ether_addr *mac_addr,
-			  __rte_unused uint32_t index,
+			  uint32_t index,
 			  __rte_unused uint32_t vmdq)
 {
 	struct octeontx_nic *nic = octeontx_pmd_priv(dev);
 	int ret;
 
-	ret = octeontx_bgx_port_mac_add(nic->port_id, mac_addr->addr_bytes);
+	ret = octeontx_bgx_port_mac_add(nic->port_id, mac_addr->addr_bytes,
+					index);
 	if (ret < 0) {
 		octeontx_log_err("failed to add MAC address filter on port %d",
 				 nic->port_id);
@@ -597,9 +598,15 @@ octeontx_dev_default_mac_addr_set(struct rte_eth_dev *dev,
 	int ret;
 
 	ret = octeontx_bgx_port_mac_set(nic->port_id, addr->addr_bytes);
-	if (ret != 0)
+	if (ret == 0) {
+		/* Update same mac address to BGX CAM table */
+		ret = octeontx_bgx_port_mac_add(nic->port_id, addr->addr_bytes,
+						0);
+	}
+	if (ret < 0) {
 		octeontx_log_err("failed to set MAC address on port %d",
-				nic->port_id);
+				 nic->port_id);
+	}
 
 	return ret;
 }
@@ -1149,6 +1156,9 @@ octeontx_create(struct rte_vdev_device *dev, int port, uint8_t evdev,
 	/* Update port_id mac to eth_dev */
 	memcpy(data->mac_addrs, nic->mac_addr, RTE_ETHER_ADDR_LEN);
 
+	/* Update same mac address to BGX CAM table at index 0 */
+	octeontx_bgx_port_mac_add(nic->port_id, nic->mac_addr, 0);
+
 	PMD_INIT_LOG(DEBUG, "ethdev info: ");
 	PMD_INIT_LOG(DEBUG, "port %d, port_ena %d ochan %d num_ochan %d tx_q %d",
 				nic->port_id, nic->port_ena,
-- 
2.17.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [dpdk-dev] [PATCH v2 1/1] net/octeontx: fix user supplied index in MAC address add
  2020-01-24  6:35 [dpdk-dev] [PATCH] net/octeontx: fix user supplied index in MAC address add Sunil Kumar Kori
@ 2020-01-29  6:42 ` Sunil Kumar Kori
  2020-01-29 12:26   ` Harman Kalra
  0 siblings, 1 reply; 4+ messages in thread
From: Sunil Kumar Kori @ 2020-01-29  6:42 UTC (permalink / raw)
  To: Harman Kalra; +Cc: dev, Sunil Kumar Kori

Earlier after a successful mac_addr_add operation, index was returned
by underlying layer which was unused but same as provided by DPDK API.

So API is enhanced to use application provided index location to add
MAC address entry.

Fixes: e4373bf1b3f5 ("net/octeontx: add unicast MAC filter")

Signed-off-by: Sunil Kumar Kori <skori@marvell.com>
---
v2:
 - Disable promiscuous mode flag when default MAC address is set.

 drivers/net/octeontx/base/octeontx_bgx.c | 13 ++++++-------
 drivers/net/octeontx/base/octeontx_bgx.h |  7 ++++++-
 drivers/net/octeontx/octeontx_ethdev.c   | 21 +++++++++++++++++----
 3 files changed, 29 insertions(+), 12 deletions(-)

diff --git a/drivers/net/octeontx/base/octeontx_bgx.c b/drivers/net/octeontx/base/octeontx_bgx.c
index e70255b11..a2d615fb2 100644
--- a/drivers/net/octeontx/base/octeontx_bgx.c
+++ b/drivers/net/octeontx/base/octeontx_bgx.c
@@ -245,22 +245,21 @@ octeontx_bgx_port_mac_set(int port, uint8_t *mac_addr)
 }
 
 int
-octeontx_bgx_port_mac_add(int port, uint8_t *mac_addr)
+octeontx_bgx_port_mac_add(int port, uint8_t *mac_addr, int index)
 {
+	struct octeontx_mbox_bgx_port_mac_filter filter;
 	struct octeontx_mbox_hdr hdr;
-	int resp = 0;
 	int len = 6;
-	int res = 0;
 
 	hdr.coproc = OCTEONTX_BGX_COPROC;
 	hdr.msg = MBOX_BGX_PORT_ADD_MACADDR;
 	hdr.vfid = port;
 
-	res = octeontx_mbox_send(&hdr, mac_addr, len, &resp, sizeof(int));
-	if (res < 0)
-		return -EACCES;
+	memcpy(filter.mac_addr, mac_addr, len);
+	filter.index = index;
+	len = sizeof(struct octeontx_mbox_bgx_port_mac_filter);
 
-	return res;
+	return octeontx_mbox_send(&hdr, &filter, len, NULL, 0);
 }
 
 int
diff --git a/drivers/net/octeontx/base/octeontx_bgx.h b/drivers/net/octeontx/base/octeontx_bgx.h
index caaff179c..11c25db67 100644
--- a/drivers/net/octeontx/base/octeontx_bgx.h
+++ b/drivers/net/octeontx/base/octeontx_bgx.h
@@ -112,6 +112,11 @@ typedef struct octeontx_mbox_bgx_port_stats {
 	uint64_t rx_jabber_errors;
 } octeontx_mbox_bgx_port_stats_t;
 
+struct octeontx_mbox_bgx_port_mac_filter {
+	uint8_t mac_addr[6];
+	int index;
+};
+
 int octeontx_bgx_port_open(int port, octeontx_mbox_bgx_port_conf_t *conf);
 int octeontx_bgx_port_close(int port);
 int octeontx_bgx_port_start(int port);
@@ -123,7 +128,7 @@ int octeontx_bgx_port_stats_clr(int port);
 int octeontx_bgx_port_link_status(int port);
 int octeontx_bgx_port_promisc_set(int port, int en);
 int octeontx_bgx_port_mac_set(int port, uint8_t *mac_addr);
-int octeontx_bgx_port_mac_add(int port, uint8_t *mac_addr);
+int octeontx_bgx_port_mac_add(int port, uint8_t *mac_addr, int index);
 int octeontx_bgx_port_mac_del(int port, uint32_t index);
 int octeontx_bgx_port_mac_entries_get(int port);
 
diff --git a/drivers/net/octeontx/octeontx_ethdev.c b/drivers/net/octeontx/octeontx_ethdev.c
index e23162d8a..f965b946e 100644
--- a/drivers/net/octeontx/octeontx_ethdev.c
+++ b/drivers/net/octeontx/octeontx_ethdev.c
@@ -573,13 +573,14 @@ octeontx_dev_mac_addr_del(struct rte_eth_dev *dev, uint32_t index)
 static int
 octeontx_dev_mac_addr_add(struct rte_eth_dev *dev,
 			  struct rte_ether_addr *mac_addr,
-			  __rte_unused uint32_t index,
+			  uint32_t index,
 			  __rte_unused uint32_t vmdq)
 {
 	struct octeontx_nic *nic = octeontx_pmd_priv(dev);
 	int ret;
 
-	ret = octeontx_bgx_port_mac_add(nic->port_id, mac_addr->addr_bytes);
+	ret = octeontx_bgx_port_mac_add(nic->port_id, mac_addr->addr_bytes,
+					index);
 	if (ret < 0) {
 		octeontx_log_err("failed to add MAC address filter on port %d",
 				 nic->port_id);
@@ -594,12 +595,21 @@ octeontx_dev_default_mac_addr_set(struct rte_eth_dev *dev,
 					struct rte_ether_addr *addr)
 {
 	struct octeontx_nic *nic = octeontx_pmd_priv(dev);
+	uint8_t prom_mode = dev->data->promiscuous;
 	int ret;
 
+	dev->data->promiscuous = 0;
 	ret = octeontx_bgx_port_mac_set(nic->port_id, addr->addr_bytes);
-	if (ret != 0)
+	if (ret == 0) {
+		/* Update same mac address to BGX CAM table */
+		ret = octeontx_bgx_port_mac_add(nic->port_id, addr->addr_bytes,
+						0);
+	}
+	if (ret < 0) {
+		dev->data->promiscuous = prom_mode;
 		octeontx_log_err("failed to set MAC address on port %d",
-				nic->port_id);
+				 nic->port_id);
+	}
 
 	return ret;
 }
@@ -1149,6 +1159,9 @@ octeontx_create(struct rte_vdev_device *dev, int port, uint8_t evdev,
 	/* Update port_id mac to eth_dev */
 	memcpy(data->mac_addrs, nic->mac_addr, RTE_ETHER_ADDR_LEN);
 
+	/* Update same mac address to BGX CAM table at index 0 */
+	octeontx_bgx_port_mac_add(nic->port_id, nic->mac_addr, 0);
+
 	PMD_INIT_LOG(DEBUG, "ethdev info: ");
 	PMD_INIT_LOG(DEBUG, "port %d, port_ena %d ochan %d num_ochan %d tx_q %d",
 				nic->port_id, nic->port_ena,
-- 
2.17.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [dpdk-dev] [PATCH v2 1/1] net/octeontx: fix user supplied index in MAC address add
  2020-01-29  6:42 ` [dpdk-dev] [PATCH v2 1/1] " Sunil Kumar Kori
@ 2020-01-29 12:26   ` Harman Kalra
  2020-02-03 10:34     ` Jerin Jacob
  0 siblings, 1 reply; 4+ messages in thread
From: Harman Kalra @ 2020-01-29 12:26 UTC (permalink / raw)
  To: Sunil Kumar Kori; +Cc: dev

On Wed, Jan 29, 2020 at 12:12:42PM +0530, Sunil Kumar Kori wrote:
> Earlier after a successful mac_addr_add operation, index was returned
> by underlying layer which was unused but same as provided by DPDK API.
> 
> So API is enhanced to use application provided index location to add
> MAC address entry.
> 
> Fixes: e4373bf1b3f5 ("net/octeontx: add unicast MAC filter")
> 
> Signed-off-by: Sunil Kumar Kori <skori@marvell.com>

Acked-by: Harman Kalra <hkalra@marvell.com>

> ---
> v2:
>  - Disable promiscuous mode flag when default MAC address is set.
> 
>  drivers/net/octeontx/base/octeontx_bgx.c | 13 ++++++-------
>  drivers/net/octeontx/base/octeontx_bgx.h |  7 ++++++-
>  drivers/net/octeontx/octeontx_ethdev.c   | 21 +++++++++++++++++----
>  3 files changed, 29 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/net/octeontx/base/octeontx_bgx.c b/drivers/net/octeontx/base/octeontx_bgx.c
> index e70255b11..a2d615fb2 100644
> --- a/drivers/net/octeontx/base/octeontx_bgx.c
> +++ b/drivers/net/octeontx/base/octeontx_bgx.c
> @@ -245,22 +245,21 @@ octeontx_bgx_port_mac_set(int port, uint8_t *mac_addr)
>  }
>  
>  int
> -octeontx_bgx_port_mac_add(int port, uint8_t *mac_addr)
> +octeontx_bgx_port_mac_add(int port, uint8_t *mac_addr, int index)
>  {
> +	struct octeontx_mbox_bgx_port_mac_filter filter;
>  	struct octeontx_mbox_hdr hdr;
> -	int resp = 0;
>  	int len = 6;
> -	int res = 0;
>  
>  	hdr.coproc = OCTEONTX_BGX_COPROC;
>  	hdr.msg = MBOX_BGX_PORT_ADD_MACADDR;
>  	hdr.vfid = port;
>  
> -	res = octeontx_mbox_send(&hdr, mac_addr, len, &resp, sizeof(int));
> -	if (res < 0)
> -		return -EACCES;
> +	memcpy(filter.mac_addr, mac_addr, len);
> +	filter.index = index;
> +	len = sizeof(struct octeontx_mbox_bgx_port_mac_filter);
>  
> -	return res;
> +	return octeontx_mbox_send(&hdr, &filter, len, NULL, 0);
>  }
>  
>  int
> diff --git a/drivers/net/octeontx/base/octeontx_bgx.h b/drivers/net/octeontx/base/octeontx_bgx.h
> index caaff179c..11c25db67 100644
> --- a/drivers/net/octeontx/base/octeontx_bgx.h
> +++ b/drivers/net/octeontx/base/octeontx_bgx.h
> @@ -112,6 +112,11 @@ typedef struct octeontx_mbox_bgx_port_stats {
>  	uint64_t rx_jabber_errors;
>  } octeontx_mbox_bgx_port_stats_t;
>  
> +struct octeontx_mbox_bgx_port_mac_filter {
> +	uint8_t mac_addr[6];
> +	int index;
> +};
> +
>  int octeontx_bgx_port_open(int port, octeontx_mbox_bgx_port_conf_t *conf);
>  int octeontx_bgx_port_close(int port);
>  int octeontx_bgx_port_start(int port);
> @@ -123,7 +128,7 @@ int octeontx_bgx_port_stats_clr(int port);
>  int octeontx_bgx_port_link_status(int port);
>  int octeontx_bgx_port_promisc_set(int port, int en);
>  int octeontx_bgx_port_mac_set(int port, uint8_t *mac_addr);
> -int octeontx_bgx_port_mac_add(int port, uint8_t *mac_addr);
> +int octeontx_bgx_port_mac_add(int port, uint8_t *mac_addr, int index);
>  int octeontx_bgx_port_mac_del(int port, uint32_t index);
>  int octeontx_bgx_port_mac_entries_get(int port);
>  
> diff --git a/drivers/net/octeontx/octeontx_ethdev.c b/drivers/net/octeontx/octeontx_ethdev.c
> index e23162d8a..f965b946e 100644
> --- a/drivers/net/octeontx/octeontx_ethdev.c
> +++ b/drivers/net/octeontx/octeontx_ethdev.c
> @@ -573,13 +573,14 @@ octeontx_dev_mac_addr_del(struct rte_eth_dev *dev, uint32_t index)
>  static int
>  octeontx_dev_mac_addr_add(struct rte_eth_dev *dev,
>  			  struct rte_ether_addr *mac_addr,
> -			  __rte_unused uint32_t index,
> +			  uint32_t index,
>  			  __rte_unused uint32_t vmdq)
>  {
>  	struct octeontx_nic *nic = octeontx_pmd_priv(dev);
>  	int ret;
>  
> -	ret = octeontx_bgx_port_mac_add(nic->port_id, mac_addr->addr_bytes);
> +	ret = octeontx_bgx_port_mac_add(nic->port_id, mac_addr->addr_bytes,
> +					index);
>  	if (ret < 0) {
>  		octeontx_log_err("failed to add MAC address filter on port %d",
>  				 nic->port_id);
> @@ -594,12 +595,21 @@ octeontx_dev_default_mac_addr_set(struct rte_eth_dev *dev,
>  					struct rte_ether_addr *addr)
>  {
>  	struct octeontx_nic *nic = octeontx_pmd_priv(dev);
> +	uint8_t prom_mode = dev->data->promiscuous;
>  	int ret;
>  
> +	dev->data->promiscuous = 0;
>  	ret = octeontx_bgx_port_mac_set(nic->port_id, addr->addr_bytes);
> -	if (ret != 0)
> +	if (ret == 0) {
> +		/* Update same mac address to BGX CAM table */
> +		ret = octeontx_bgx_port_mac_add(nic->port_id, addr->addr_bytes,
> +						0);
> +	}
> +	if (ret < 0) {
> +		dev->data->promiscuous = prom_mode;
>  		octeontx_log_err("failed to set MAC address on port %d",
> -				nic->port_id);
> +				 nic->port_id);
> +	}
>  
>  	return ret;
>  }
> @@ -1149,6 +1159,9 @@ octeontx_create(struct rte_vdev_device *dev, int port, uint8_t evdev,
>  	/* Update port_id mac to eth_dev */
>  	memcpy(data->mac_addrs, nic->mac_addr, RTE_ETHER_ADDR_LEN);
>  
> +	/* Update same mac address to BGX CAM table at index 0 */
> +	octeontx_bgx_port_mac_add(nic->port_id, nic->mac_addr, 0);
> +
>  	PMD_INIT_LOG(DEBUG, "ethdev info: ");
>  	PMD_INIT_LOG(DEBUG, "port %d, port_ena %d ochan %d num_ochan %d tx_q %d",
>  				nic->port_id, nic->port_ena,
> -- 
> 2.17.1
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [dpdk-dev] [PATCH v2 1/1] net/octeontx: fix user supplied index in MAC address add
  2020-01-29 12:26   ` Harman Kalra
@ 2020-02-03 10:34     ` Jerin Jacob
  0 siblings, 0 replies; 4+ messages in thread
From: Jerin Jacob @ 2020-02-03 10:34 UTC (permalink / raw)
  To: Harman Kalra, Ferruh Yigit; +Cc: Sunil Kumar Kori, dev

On Wed, Jan 29, 2020 at 5:56 PM Harman Kalra <hkalra@marvell.com> wrote:
>
> On Wed, Jan 29, 2020 at 12:12:42PM +0530, Sunil Kumar Kori wrote:
> > Earlier after a successful mac_addr_add operation, index was returned
> > by underlying layer which was unused but same as provided by DPDK API.
> >
> > So API is enhanced to use application provided index location to add
> > MAC address entry.
> >
> > Fixes: e4373bf1b3f5 ("net/octeontx: add unicast MAC filter")
> >
> > Signed-off-by: Sunil Kumar Kori <skori@marvell.com>
>
> Acked-by: Harman Kalra <hkalra@marvell.com>
>

Applied to dpdk-next-net-mrvl/master. Thanks

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-02-03 10:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-24  6:35 [dpdk-dev] [PATCH] net/octeontx: fix user supplied index in MAC address add Sunil Kumar Kori
2020-01-29  6:42 ` [dpdk-dev] [PATCH v2 1/1] " Sunil Kumar Kori
2020-01-29 12:26   ` Harman Kalra
2020-02-03 10:34     ` Jerin Jacob

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).