DPDK patches and discussions
 help / color / Atom feed
* [dpdk-dev] [PATCH] net/octeontx: add unicast MAC filter
@ 2020-01-13  6:16 Sunil Kumar Kori
  2020-01-14  7:43 ` Harman Kalra
  0 siblings, 1 reply; 3+ messages in thread
From: Sunil Kumar Kori @ 2020-01-13  6:16 UTC (permalink / raw)
  To: Jerin Jacob, John McNamara, Marko Kovacevic; +Cc: dev, Sunil Kumar Kori

At BGX, DMAC filter table can be enabled to allow defined hosts.
Patch implements 'mac_addr_add' and 'mac_addr_remove' ops to
add/remove MAC filters which uses BGX DMAC filter table.

Signed-off-by: Sunil Kumar Kori <skori@marvell.com>
---
 doc/guides/nics/features/octeontx.ini    |  2 +-
 drivers/net/octeontx/base/octeontx_bgx.c | 55 ++++++++++++++++++++++++
 drivers/net/octeontx/base/octeontx_bgx.h |  6 +++
 drivers/net/octeontx/octeontx_ethdev.c   | 50 +++++++++++++++++++--
 4 files changed, 109 insertions(+), 4 deletions(-)

diff --git a/doc/guides/nics/features/octeontx.ini b/doc/guides/nics/features/octeontx.ini
index c92d5aa07..323befe59 100644
--- a/doc/guides/nics/features/octeontx.ini
+++ b/doc/guides/nics/features/octeontx.ini
@@ -10,7 +10,7 @@ Lock-free Tx queue   = Y
 Queue start/stop     = P
 Jumbo frame          = Y
 Promiscuous mode     = Y
-Unicast MAC filter   = P
+Unicast MAC filter   = Y
 CRC offload          = Y
 Packet type parsing  = Y
 Basic stats          = Y
diff --git a/drivers/net/octeontx/base/octeontx_bgx.c b/drivers/net/octeontx/base/octeontx_bgx.c
index 0e2388264..e70255b11 100644
--- a/drivers/net/octeontx/base/octeontx_bgx.c
+++ b/drivers/net/octeontx/base/octeontx_bgx.c
@@ -243,3 +243,58 @@ octeontx_bgx_port_mac_set(int port, uint8_t *mac_addr)
 
 	return res;
 }
+
+int
+octeontx_bgx_port_mac_add(int port, uint8_t *mac_addr)
+{
+	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;
+
+	return res;
+}
+
+int
+octeontx_bgx_port_mac_del(int port, uint32_t index)
+{
+	struct octeontx_mbox_hdr hdr;
+	int len = sizeof(uint32_t);
+	int res = 0;
+
+	hdr.coproc = OCTEONTX_BGX_COPROC;
+	hdr.msg = MBOX_BGX_PORT_DEL_MACADDR;
+	hdr.vfid = port;
+
+	res = octeontx_mbox_send(&hdr, &index, len, NULL, 0);
+	if (res < 0)
+		return -EACCES;
+
+	return res;
+}
+
+int
+octeontx_bgx_port_mac_entries_get(int port)
+{
+	struct octeontx_mbox_hdr hdr;
+	int resp = 6;
+	int res = 0;
+
+	hdr.coproc = OCTEONTX_BGX_COPROC;
+	hdr.msg = MBOX_BGX_PORT_GET_MACADDR_ENTRIES;
+	hdr.vfid = port;
+
+	res = octeontx_mbox_send(&hdr, NULL, 0, &resp, sizeof(int));
+	if (res < 0)
+		return -EACCES;
+
+	return resp;
+}
diff --git a/drivers/net/octeontx/base/octeontx_bgx.h b/drivers/net/octeontx/base/octeontx_bgx.h
index a9bbaf2c3..caaff179c 100644
--- a/drivers/net/octeontx/base/octeontx_bgx.h
+++ b/drivers/net/octeontx/base/octeontx_bgx.h
@@ -28,6 +28,9 @@
 #define MBOX_BGX_PORT_SET_BCAST         12
 #define MBOX_BGX_PORT_SET_MCAST         13
 #define MBOX_BGX_PORT_SET_MTU		14
+#define MBOX_BGX_PORT_ADD_MACADDR	15
+#define MBOX_BGX_PORT_DEL_MACADDR	16
+#define MBOX_BGX_PORT_GET_MACADDR_ENTRIES 17
 
 /* BGX port configuration parameters: */
 typedef struct octeontx_mbox_bgx_port_conf {
@@ -120,6 +123,9 @@ 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_del(int port, uint32_t index);
+int octeontx_bgx_port_mac_entries_get(int port);
 
 #endif	/* __OCTEONTX_BGX_H__ */
 
diff --git a/drivers/net/octeontx/octeontx_ethdev.c b/drivers/net/octeontx/octeontx_ethdev.c
index 679803dd4..e23162d8a 100644
--- a/drivers/net/octeontx/octeontx_ethdev.c
+++ b/drivers/net/octeontx/octeontx_ethdev.c
@@ -558,6 +558,37 @@ octeontx_dev_stats_reset(struct rte_eth_dev *dev)
 	return octeontx_port_stats_clr(nic);
 }
 
+static void
+octeontx_dev_mac_addr_del(struct rte_eth_dev *dev, uint32_t index)
+{
+	struct octeontx_nic *nic = octeontx_pmd_priv(dev);
+	int ret;
+
+	ret = octeontx_bgx_port_mac_del(nic->port_id, index);
+	if (ret != 0)
+		octeontx_log_err("failed to del MAC address filter on port %d",
+				 nic->port_id);
+}
+
+static int
+octeontx_dev_mac_addr_add(struct rte_eth_dev *dev,
+			  struct rte_ether_addr *mac_addr,
+			  __rte_unused 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);
+	if (ret < 0) {
+		octeontx_log_err("failed to add MAC address filter on port %d",
+				 nic->port_id);
+		return ret;
+	}
+
+	return 0;
+}
+
 static int
 octeontx_dev_default_mac_addr_set(struct rte_eth_dev *dev,
 					struct rte_ether_addr *addr)
@@ -577,7 +608,7 @@ static int
 octeontx_dev_info(struct rte_eth_dev *dev,
 		struct rte_eth_dev_info *dev_info)
 {
-	RTE_SET_USED(dev);
+	struct octeontx_nic *nic = octeontx_pmd_priv(dev);
 
 	/* Autonegotiation may be disabled */
 	dev_info->speed_capa = ETH_LINK_SPEED_FIXED;
@@ -585,7 +616,8 @@ octeontx_dev_info(struct rte_eth_dev *dev,
 			ETH_LINK_SPEED_1G | ETH_LINK_SPEED_10G |
 			ETH_LINK_SPEED_40G;
 
-	dev_info->max_mac_addrs = 1;
+	dev_info->max_mac_addrs =
+				octeontx_bgx_port_mac_entries_get(nic->port_id);
 	dev_info->max_rx_pktlen = PKI_MAX_PKTLEN;
 	dev_info->max_rx_queues = 1;
 	dev_info->max_tx_queues = PKO_MAX_NUM_DQ;
@@ -986,6 +1018,8 @@ static const struct eth_dev_ops octeontx_dev_ops = {
 	.link_update		 = octeontx_dev_link_update,
 	.stats_get		 = octeontx_dev_stats_get,
 	.stats_reset		 = octeontx_dev_stats_reset,
+	.mac_addr_remove	 = octeontx_dev_mac_addr_del,
+	.mac_addr_add		 = octeontx_dev_mac_addr_add,
 	.mac_addr_set		 = octeontx_dev_default_mac_addr_set,
 	.tx_queue_start		 = octeontx_dev_tx_queue_start,
 	.tx_queue_stop		 = octeontx_dev_tx_queue_stop,
@@ -1009,6 +1043,7 @@ octeontx_create(struct rte_vdev_device *dev, int port, uint8_t evdev,
 	struct rte_eth_dev *eth_dev = NULL;
 	struct rte_eth_dev_data *data;
 	const char *name = rte_vdev_device_name(dev);
+	int max_entries;
 
 	PMD_INIT_FUNC_TRACE();
 
@@ -1082,7 +1117,16 @@ octeontx_create(struct rte_vdev_device *dev, int port, uint8_t evdev,
 	data->all_multicast = 0;
 	data->scattered_rx = 0;
 
-	data->mac_addrs = rte_zmalloc_socket(octtx_name, RTE_ETHER_ADDR_LEN, 0,
+	/* Get maximum number of supported MAC entries */
+	max_entries = octeontx_bgx_port_mac_entries_get(nic->port_id);
+	if (max_entries < 0) {
+		octeontx_log_err("Failed to get max entries for mac addr");
+		res = -ENOTSUP;
+		goto err;
+	}
+
+	data->mac_addrs = rte_zmalloc_socket(octtx_name, max_entries *
+					     RTE_ETHER_ADDR_LEN, 0,
 							socket_id);
 	if (data->mac_addrs == NULL) {
 		octeontx_log_err("failed to allocate memory for mac_addrs");
-- 
2.17.1


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

* Re: [dpdk-dev] [PATCH] net/octeontx: add unicast MAC filter
  2020-01-13  6:16 [dpdk-dev] [PATCH] net/octeontx: add unicast MAC filter Sunil Kumar Kori
@ 2020-01-14  7:43 ` Harman Kalra
  2020-01-14  7:45   ` Jerin Jacob
  0 siblings, 1 reply; 3+ messages in thread
From: Harman Kalra @ 2020-01-14  7:43 UTC (permalink / raw)
  To: Sunil Kumar Kori
  Cc: Jerin Jacob Kollanukkaran, John McNamara, Marko Kovacevic, dev

On Mon, Jan 13, 2020 at 11:46:44AM +0530, Sunil Kumar Kori wrote:
> At BGX, DMAC filter table can be enabled to allow defined hosts.
> Patch implements 'mac_addr_add' and 'mac_addr_remove' ops to
> add/remove MAC filters which uses BGX DMAC filter table.
> 
> Signed-off-by: Sunil Kumar Kori <skori@marvell.com>

Acked-by: Harman Kalra <hkalra@marvell.com>
> ---
>  doc/guides/nics/features/octeontx.ini    |  2 +-
>  drivers/net/octeontx/base/octeontx_bgx.c | 55 ++++++++++++++++++++++++
>  drivers/net/octeontx/base/octeontx_bgx.h |  6 +++
>  drivers/net/octeontx/octeontx_ethdev.c   | 50 +++++++++++++++++++--
>  4 files changed, 109 insertions(+), 4 deletions(-)
> 
> diff --git a/doc/guides/nics/features/octeontx.ini b/doc/guides/nics/features/octeontx.ini
> index c92d5aa07..323befe59 100644
> --- a/doc/guides/nics/features/octeontx.ini
> +++ b/doc/guides/nics/features/octeontx.ini
> @@ -10,7 +10,7 @@ Lock-free Tx queue   = Y
>  Queue start/stop     = P
>  Jumbo frame          = Y
>  Promiscuous mode     = Y
> -Unicast MAC filter   = P
> +Unicast MAC filter   = Y
>  CRC offload          = Y
>  Packet type parsing  = Y
>  Basic stats          = Y
> diff --git a/drivers/net/octeontx/base/octeontx_bgx.c b/drivers/net/octeontx/base/octeontx_bgx.c
> index 0e2388264..e70255b11 100644
> --- a/drivers/net/octeontx/base/octeontx_bgx.c
> +++ b/drivers/net/octeontx/base/octeontx_bgx.c
> @@ -243,3 +243,58 @@ octeontx_bgx_port_mac_set(int port, uint8_t *mac_addr)
>  
>  	return res;
>  }
> +
> +int
> +octeontx_bgx_port_mac_add(int port, uint8_t *mac_addr)
> +{
> +	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;
> +
> +	return res;
> +}
> +
> +int
> +octeontx_bgx_port_mac_del(int port, uint32_t index)
> +{
> +	struct octeontx_mbox_hdr hdr;
> +	int len = sizeof(uint32_t);
> +	int res = 0;
> +
> +	hdr.coproc = OCTEONTX_BGX_COPROC;
> +	hdr.msg = MBOX_BGX_PORT_DEL_MACADDR;
> +	hdr.vfid = port;
> +
> +	res = octeontx_mbox_send(&hdr, &index, len, NULL, 0);
> +	if (res < 0)
> +		return -EACCES;
> +
> +	return res;
> +}
> +
> +int
> +octeontx_bgx_port_mac_entries_get(int port)
> +{
> +	struct octeontx_mbox_hdr hdr;
> +	int resp = 6;
> +	int res = 0;
> +
> +	hdr.coproc = OCTEONTX_BGX_COPROC;
> +	hdr.msg = MBOX_BGX_PORT_GET_MACADDR_ENTRIES;
> +	hdr.vfid = port;
> +
> +	res = octeontx_mbox_send(&hdr, NULL, 0, &resp, sizeof(int));
> +	if (res < 0)
> +		return -EACCES;
> +
> +	return resp;
> +}
> diff --git a/drivers/net/octeontx/base/octeontx_bgx.h b/drivers/net/octeontx/base/octeontx_bgx.h
> index a9bbaf2c3..caaff179c 100644
> --- a/drivers/net/octeontx/base/octeontx_bgx.h
> +++ b/drivers/net/octeontx/base/octeontx_bgx.h
> @@ -28,6 +28,9 @@
>  #define MBOX_BGX_PORT_SET_BCAST         12
>  #define MBOX_BGX_PORT_SET_MCAST         13
>  #define MBOX_BGX_PORT_SET_MTU		14
> +#define MBOX_BGX_PORT_ADD_MACADDR	15
> +#define MBOX_BGX_PORT_DEL_MACADDR	16
> +#define MBOX_BGX_PORT_GET_MACADDR_ENTRIES 17
>  
>  /* BGX port configuration parameters: */
>  typedef struct octeontx_mbox_bgx_port_conf {
> @@ -120,6 +123,9 @@ 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_del(int port, uint32_t index);
> +int octeontx_bgx_port_mac_entries_get(int port);
>  
>  #endif	/* __OCTEONTX_BGX_H__ */
>  
> diff --git a/drivers/net/octeontx/octeontx_ethdev.c b/drivers/net/octeontx/octeontx_ethdev.c
> index 679803dd4..e23162d8a 100644
> --- a/drivers/net/octeontx/octeontx_ethdev.c
> +++ b/drivers/net/octeontx/octeontx_ethdev.c
> @@ -558,6 +558,37 @@ octeontx_dev_stats_reset(struct rte_eth_dev *dev)
>  	return octeontx_port_stats_clr(nic);
>  }
>  
> +static void
> +octeontx_dev_mac_addr_del(struct rte_eth_dev *dev, uint32_t index)
> +{
> +	struct octeontx_nic *nic = octeontx_pmd_priv(dev);
> +	int ret;
> +
> +	ret = octeontx_bgx_port_mac_del(nic->port_id, index);
> +	if (ret != 0)
> +		octeontx_log_err("failed to del MAC address filter on port %d",
> +				 nic->port_id);
> +}
> +
> +static int
> +octeontx_dev_mac_addr_add(struct rte_eth_dev *dev,
> +			  struct rte_ether_addr *mac_addr,
> +			  __rte_unused 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);
> +	if (ret < 0) {
> +		octeontx_log_err("failed to add MAC address filter on port %d",
> +				 nic->port_id);
> +		return ret;
> +	}
> +
> +	return 0;
> +}
> +
>  static int
>  octeontx_dev_default_mac_addr_set(struct rte_eth_dev *dev,
>  					struct rte_ether_addr *addr)
> @@ -577,7 +608,7 @@ static int
>  octeontx_dev_info(struct rte_eth_dev *dev,
>  		struct rte_eth_dev_info *dev_info)
>  {
> -	RTE_SET_USED(dev);
> +	struct octeontx_nic *nic = octeontx_pmd_priv(dev);
>  
>  	/* Autonegotiation may be disabled */
>  	dev_info->speed_capa = ETH_LINK_SPEED_FIXED;
> @@ -585,7 +616,8 @@ octeontx_dev_info(struct rte_eth_dev *dev,
>  			ETH_LINK_SPEED_1G | ETH_LINK_SPEED_10G |
>  			ETH_LINK_SPEED_40G;
>  
> -	dev_info->max_mac_addrs = 1;
> +	dev_info->max_mac_addrs =
> +				octeontx_bgx_port_mac_entries_get(nic->port_id);
>  	dev_info->max_rx_pktlen = PKI_MAX_PKTLEN;
>  	dev_info->max_rx_queues = 1;
>  	dev_info->max_tx_queues = PKO_MAX_NUM_DQ;
> @@ -986,6 +1018,8 @@ static const struct eth_dev_ops octeontx_dev_ops = {
>  	.link_update		 = octeontx_dev_link_update,
>  	.stats_get		 = octeontx_dev_stats_get,
>  	.stats_reset		 = octeontx_dev_stats_reset,
> +	.mac_addr_remove	 = octeontx_dev_mac_addr_del,
> +	.mac_addr_add		 = octeontx_dev_mac_addr_add,
>  	.mac_addr_set		 = octeontx_dev_default_mac_addr_set,
>  	.tx_queue_start		 = octeontx_dev_tx_queue_start,
>  	.tx_queue_stop		 = octeontx_dev_tx_queue_stop,
> @@ -1009,6 +1043,7 @@ octeontx_create(struct rte_vdev_device *dev, int port, uint8_t evdev,
>  	struct rte_eth_dev *eth_dev = NULL;
>  	struct rte_eth_dev_data *data;
>  	const char *name = rte_vdev_device_name(dev);
> +	int max_entries;
>  
>  	PMD_INIT_FUNC_TRACE();
>  
> @@ -1082,7 +1117,16 @@ octeontx_create(struct rte_vdev_device *dev, int port, uint8_t evdev,
>  	data->all_multicast = 0;
>  	data->scattered_rx = 0;
>  
> -	data->mac_addrs = rte_zmalloc_socket(octtx_name, RTE_ETHER_ADDR_LEN, 0,
> +	/* Get maximum number of supported MAC entries */
> +	max_entries = octeontx_bgx_port_mac_entries_get(nic->port_id);
> +	if (max_entries < 0) {
> +		octeontx_log_err("Failed to get max entries for mac addr");
> +		res = -ENOTSUP;
> +		goto err;
> +	}
> +
> +	data->mac_addrs = rte_zmalloc_socket(octtx_name, max_entries *
> +					     RTE_ETHER_ADDR_LEN, 0,
>  							socket_id);
>  	if (data->mac_addrs == NULL) {
>  		octeontx_log_err("failed to allocate memory for mac_addrs");
> -- 
> 2.17.1
> 

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

* Re: [dpdk-dev] [PATCH] net/octeontx: add unicast MAC filter
  2020-01-14  7:43 ` Harman Kalra
@ 2020-01-14  7:45   ` Jerin Jacob
  0 siblings, 0 replies; 3+ messages in thread
From: Jerin Jacob @ 2020-01-14  7:45 UTC (permalink / raw)
  To: Harman Kalra
  Cc: Sunil Kumar Kori, Jerin Jacob Kollanukkaran, John McNamara,
	Marko Kovacevic, dev

On Tue, Jan 14, 2020 at 1:13 PM Harman Kalra <hkalra@marvell.com> wrote:
>
> On Mon, Jan 13, 2020 at 11:46:44AM +0530, Sunil Kumar Kori wrote:
> > At BGX, DMAC filter table can be enabled to allow defined hosts.
> > Patch implements 'mac_addr_add' and 'mac_addr_remove' ops to
> > add/remove MAC filters which uses BGX DMAC filter table.
> >
> > Signed-off-by: Sunil Kumar Kori <skori@marvell.com>
>
> Acked-by: Harman Kalra <hkalra@marvell.com>

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



> > ---
> >  doc/guides/nics/features/octeontx.ini    |  2 +-
> >  drivers/net/octeontx/base/octeontx_bgx.c | 55 ++++++++++++++++++++++++
> >  drivers/net/octeontx/base/octeontx_bgx.h |  6 +++
> >  drivers/net/octeontx/octeontx_ethdev.c   | 50 +++++++++++++++++++--
> >  4 files changed, 109 insertions(+), 4 deletions(-)
> >
> > diff --git a/doc/guides/nics/features/octeontx.ini b/doc/guides/nics/features/octeontx.ini
> > index c92d5aa07..323befe59 100644
> > --- a/doc/guides/nics/features/octeontx.ini
> > +++ b/doc/guides/nics/features/octeontx.ini
> > @@ -10,7 +10,7 @@ Lock-free Tx queue   = Y
> >  Queue start/stop     = P
> >  Jumbo frame          = Y
> >  Promiscuous mode     = Y
> > -Unicast MAC filter   = P
> > +Unicast MAC filter   = Y
> >  CRC offload          = Y
> >  Packet type parsing  = Y
> >  Basic stats          = Y
> > diff --git a/drivers/net/octeontx/base/octeontx_bgx.c b/drivers/net/octeontx/base/octeontx_bgx.c
> > index 0e2388264..e70255b11 100644
> > --- a/drivers/net/octeontx/base/octeontx_bgx.c
> > +++ b/drivers/net/octeontx/base/octeontx_bgx.c
> > @@ -243,3 +243,58 @@ octeontx_bgx_port_mac_set(int port, uint8_t *mac_addr)
> >
> >       return res;
> >  }
> > +
> > +int
> > +octeontx_bgx_port_mac_add(int port, uint8_t *mac_addr)
> > +{
> > +     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;
> > +
> > +     return res;
> > +}
> > +
> > +int
> > +octeontx_bgx_port_mac_del(int port, uint32_t index)
> > +{
> > +     struct octeontx_mbox_hdr hdr;
> > +     int len = sizeof(uint32_t);
> > +     int res = 0;
> > +
> > +     hdr.coproc = OCTEONTX_BGX_COPROC;
> > +     hdr.msg = MBOX_BGX_PORT_DEL_MACADDR;
> > +     hdr.vfid = port;
> > +
> > +     res = octeontx_mbox_send(&hdr, &index, len, NULL, 0);
> > +     if (res < 0)
> > +             return -EACCES;
> > +
> > +     return res;
> > +}
> > +
> > +int
> > +octeontx_bgx_port_mac_entries_get(int port)
> > +{
> > +     struct octeontx_mbox_hdr hdr;
> > +     int resp = 6;
> > +     int res = 0;
> > +
> > +     hdr.coproc = OCTEONTX_BGX_COPROC;
> > +     hdr.msg = MBOX_BGX_PORT_GET_MACADDR_ENTRIES;
> > +     hdr.vfid = port;
> > +
> > +     res = octeontx_mbox_send(&hdr, NULL, 0, &resp, sizeof(int));
> > +     if (res < 0)
> > +             return -EACCES;
> > +
> > +     return resp;
> > +}
> > diff --git a/drivers/net/octeontx/base/octeontx_bgx.h b/drivers/net/octeontx/base/octeontx_bgx.h
> > index a9bbaf2c3..caaff179c 100644
> > --- a/drivers/net/octeontx/base/octeontx_bgx.h
> > +++ b/drivers/net/octeontx/base/octeontx_bgx.h
> > @@ -28,6 +28,9 @@
> >  #define MBOX_BGX_PORT_SET_BCAST         12
> >  #define MBOX_BGX_PORT_SET_MCAST         13
> >  #define MBOX_BGX_PORT_SET_MTU                14
> > +#define MBOX_BGX_PORT_ADD_MACADDR    15
> > +#define MBOX_BGX_PORT_DEL_MACADDR    16
> > +#define MBOX_BGX_PORT_GET_MACADDR_ENTRIES 17
> >
> >  /* BGX port configuration parameters: */
> >  typedef struct octeontx_mbox_bgx_port_conf {
> > @@ -120,6 +123,9 @@ 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_del(int port, uint32_t index);
> > +int octeontx_bgx_port_mac_entries_get(int port);
> >
> >  #endif       /* __OCTEONTX_BGX_H__ */
> >
> > diff --git a/drivers/net/octeontx/octeontx_ethdev.c b/drivers/net/octeontx/octeontx_ethdev.c
> > index 679803dd4..e23162d8a 100644
> > --- a/drivers/net/octeontx/octeontx_ethdev.c
> > +++ b/drivers/net/octeontx/octeontx_ethdev.c
> > @@ -558,6 +558,37 @@ octeontx_dev_stats_reset(struct rte_eth_dev *dev)
> >       return octeontx_port_stats_clr(nic);
> >  }
> >
> > +static void
> > +octeontx_dev_mac_addr_del(struct rte_eth_dev *dev, uint32_t index)
> > +{
> > +     struct octeontx_nic *nic = octeontx_pmd_priv(dev);
> > +     int ret;
> > +
> > +     ret = octeontx_bgx_port_mac_del(nic->port_id, index);
> > +     if (ret != 0)
> > +             octeontx_log_err("failed to del MAC address filter on port %d",
> > +                              nic->port_id);
> > +}
> > +
> > +static int
> > +octeontx_dev_mac_addr_add(struct rte_eth_dev *dev,
> > +                       struct rte_ether_addr *mac_addr,
> > +                       __rte_unused 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);
> > +     if (ret < 0) {
> > +             octeontx_log_err("failed to add MAC address filter on port %d",
> > +                              nic->port_id);
> > +             return ret;
> > +     }
> > +
> > +     return 0;
> > +}
> > +
> >  static int
> >  octeontx_dev_default_mac_addr_set(struct rte_eth_dev *dev,
> >                                       struct rte_ether_addr *addr)
> > @@ -577,7 +608,7 @@ static int
> >  octeontx_dev_info(struct rte_eth_dev *dev,
> >               struct rte_eth_dev_info *dev_info)
> >  {
> > -     RTE_SET_USED(dev);
> > +     struct octeontx_nic *nic = octeontx_pmd_priv(dev);
> >
> >       /* Autonegotiation may be disabled */
> >       dev_info->speed_capa = ETH_LINK_SPEED_FIXED;
> > @@ -585,7 +616,8 @@ octeontx_dev_info(struct rte_eth_dev *dev,
> >                       ETH_LINK_SPEED_1G | ETH_LINK_SPEED_10G |
> >                       ETH_LINK_SPEED_40G;
> >
> > -     dev_info->max_mac_addrs = 1;
> > +     dev_info->max_mac_addrs =
> > +                             octeontx_bgx_port_mac_entries_get(nic->port_id);
> >       dev_info->max_rx_pktlen = PKI_MAX_PKTLEN;
> >       dev_info->max_rx_queues = 1;
> >       dev_info->max_tx_queues = PKO_MAX_NUM_DQ;
> > @@ -986,6 +1018,8 @@ static const struct eth_dev_ops octeontx_dev_ops = {
> >       .link_update             = octeontx_dev_link_update,
> >       .stats_get               = octeontx_dev_stats_get,
> >       .stats_reset             = octeontx_dev_stats_reset,
> > +     .mac_addr_remove         = octeontx_dev_mac_addr_del,
> > +     .mac_addr_add            = octeontx_dev_mac_addr_add,
> >       .mac_addr_set            = octeontx_dev_default_mac_addr_set,
> >       .tx_queue_start          = octeontx_dev_tx_queue_start,
> >       .tx_queue_stop           = octeontx_dev_tx_queue_stop,
> > @@ -1009,6 +1043,7 @@ octeontx_create(struct rte_vdev_device *dev, int port, uint8_t evdev,
> >       struct rte_eth_dev *eth_dev = NULL;
> >       struct rte_eth_dev_data *data;
> >       const char *name = rte_vdev_device_name(dev);
> > +     int max_entries;
> >
> >       PMD_INIT_FUNC_TRACE();
> >
> > @@ -1082,7 +1117,16 @@ octeontx_create(struct rte_vdev_device *dev, int port, uint8_t evdev,
> >       data->all_multicast = 0;
> >       data->scattered_rx = 0;
> >
> > -     data->mac_addrs = rte_zmalloc_socket(octtx_name, RTE_ETHER_ADDR_LEN, 0,
> > +     /* Get maximum number of supported MAC entries */
> > +     max_entries = octeontx_bgx_port_mac_entries_get(nic->port_id);
> > +     if (max_entries < 0) {
> > +             octeontx_log_err("Failed to get max entries for mac addr");
> > +             res = -ENOTSUP;
> > +             goto err;
> > +     }
> > +
> > +     data->mac_addrs = rte_zmalloc_socket(octtx_name, max_entries *
> > +                                          RTE_ETHER_ADDR_LEN, 0,
> >                                                       socket_id);
> >       if (data->mac_addrs == NULL) {
> >               octeontx_log_err("failed to allocate memory for mac_addrs");
> > --
> > 2.17.1
> >

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

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-13  6:16 [dpdk-dev] [PATCH] net/octeontx: add unicast MAC filter Sunil Kumar Kori
2020-01-14  7:43 ` Harman Kalra
2020-01-14  7:45   ` Jerin Jacob

DPDK patches and discussions

Archives are clonable:
	git clone --mirror http://inbox.dpdk.org/dev/0 dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dev dev/ http://inbox.dpdk.org/dev \
		dev@dpdk.org
	public-inbox-index dev


Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.dev


AGPL code for this site: git clone https://public-inbox.org/ public-inbox