DPDK patches and discussions
 help / color / mirror / Atom feed
From: Tomasz Duszynski <tdu@semihalf.com>
To: dev@dpdk.org
Cc: mw@semihalf.com, dima@marvell.com, nsamsono@marvell.com,
	Jianbo.liu@linaro.org, Tomasz Duszynski <tdu@semihalf.com>,
	Jacek Siuda <jck@semihalf.com>
Subject: [dpdk-dev] [PATCH v4 09/16] net/mrvl: add support for mac filtering
Date: Mon,  9 Oct 2017 17:00:37 +0200	[thread overview]
Message-ID: <1507561244-20115-10-git-send-email-tdu@semihalf.com> (raw)
In-Reply-To: <1507561244-20115-1-git-send-email-tdu@semihalf.com>

Add support for unicast and multicast mac filters.

Signed-off-by: Jacek Siuda <jck@semihalf.com>
Signed-off-by: Tomasz Duszynski <tdu@semihalf.com>
---
 doc/guides/nics/features/mrvl.ini |  2 +
 drivers/net/mrvl/mrvl_ethdev.c    | 95 ++++++++++++++++++++++++++++++++++++++-
 drivers/net/mrvl/mrvl_ethdev.h    |  1 +
 3 files changed, 97 insertions(+), 1 deletion(-)

diff --git a/doc/guides/nics/features/mrvl.ini b/doc/guides/nics/features/mrvl.ini
index c2df525..2243749 100644
--- a/doc/guides/nics/features/mrvl.ini
+++ b/doc/guides/nics/features/mrvl.ini
@@ -10,3 +10,5 @@ MTU update           = Y
 Jumbo frame          = Y
 Promiscuous mode     = Y
 Allmulticast mode    = Y
+Unicast MAC filter   = Y
+Multicast MAC filter = Y
diff --git a/drivers/net/mrvl/mrvl_ethdev.c b/drivers/net/mrvl/mrvl_ethdev.c
index 519aa19..daa2229 100644
--- a/drivers/net/mrvl/mrvl_ethdev.c
+++ b/drivers/net/mrvl/mrvl_ethdev.c
@@ -69,10 +69,11 @@
 /* maximum number of available hifs */
 #define MRVL_MUSDK_HIFS_MAX 9
 
-#define MRVL_MAC_ADDRS_MAX 1
 /* prefetch shift */
 #define MRVL_MUSDK_PREFETCH_SHIFT 2
 
+/* TCAM has 25 entries reserved for uc/mc filter entries */
+#define MRVL_MAC_ADDRS_MAX 25
 #define MRVL_MATCH_LEN 16
 #define MRVL_PKT_EFFEC_OFFS (MRVL_PKT_OFFS + MV_MH_SIZE)
 /* Maximum allowable packet size */
@@ -372,6 +373,22 @@ mrvl_dev_start(struct rte_eth_dev *dev)
 	if (ret)
 		return ret;
 
+	/*
+	 * In case there are some some stale uc/mc mac addresses flush them
+	 * here. It cannot be done during mrvl_dev_close() as port information
+	 * is already gone at that point (due to pp2_ppio_deinit() in
+	 * mrvl_dev_stop()).
+	 */
+	if (!priv->uc_mc_flushed) {
+		ret = pp2_ppio_flush_mac_addrs(priv->ppio, 1, 1);
+		if (ret) {
+			RTE_LOG(ERR, PMD,
+				"Failed to flush uc/mc filter list\n");
+			goto out;
+		}
+		priv->uc_mc_flushed = 1;
+	}
+
 	/* For default QoS config, don't start classifier. */
 	if (mrvl_qos_cfg) {
 		ret = mrvl_start_qos_mapping(priv);
@@ -657,6 +674,80 @@ mrvl_allmulticast_disable(struct rte_eth_dev *dev)
 }
 
 /**
+ * DPDK callback to remove a MAC address.
+ *
+ * @param dev
+ *   Pointer to Ethernet device structure.
+ * @param index
+ *   MAC address index.
+ */
+static void
+mrvl_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index)
+{
+	struct mrvl_priv *priv = dev->data->dev_private;
+	char buf[ETHER_ADDR_FMT_SIZE];
+	int ret;
+
+	ret = pp2_ppio_remove_mac_addr(priv->ppio,
+				       dev->data->mac_addrs[index].addr_bytes);
+	if (ret) {
+		ether_format_addr(buf, sizeof(buf),
+				  &dev->data->mac_addrs[index]);
+		RTE_LOG(ERR, PMD, "Failed to remove mac %s\n", buf);
+	}
+}
+
+/**
+ * DPDK callback to add a MAC address.
+ *
+ * @param dev
+ *   Pointer to Ethernet device structure.
+ * @param mac_addr
+ *   MAC address to register.
+ * @param index
+ *   MAC address index.
+ * @param vmdq
+ *   VMDq pool index to associate address with (unused).
+ *
+ * @return
+ *   0 on success, negative error value otherwise.
+ */
+static int
+mrvl_mac_addr_add(struct rte_eth_dev *dev, struct ether_addr *mac_addr,
+		  uint32_t index, uint32_t vmdq __rte_unused)
+{
+	struct mrvl_priv *priv = dev->data->dev_private;
+	char buf[ETHER_ADDR_FMT_SIZE];
+	int ret;
+
+	if (index == 0)
+		/* For setting index 0, mrvl_mac_addr_set() should be used.*/
+		return -1;
+
+	/*
+	 * Maximum number of uc addresses can be tuned via kernel module mvpp2x
+	 * parameter uc_filter_max. Maximum number of mc addresses is then
+	 * MRVL_MAC_ADDRS_MAX - uc_filter_max. Currently it defaults to 4 and
+	 * 21 respectively.
+	 *
+	 * If more than uc_filter_max uc addresses were added to filter list
+	 * then NIC will switch to promiscuous mode automatically.
+	 *
+	 * If more than MRVL_MAC_ADDRS_MAX - uc_filter_max number mc addresses
+	 * were added to filter list then NIC will switch to all-multicast mode
+	 * automatically.
+	 */
+	ret = pp2_ppio_add_mac_addr(priv->ppio, mac_addr->addr_bytes);
+	if (ret) {
+		ether_format_addr(buf, sizeof(buf), mac_addr);
+		RTE_LOG(ERR, PMD, "Failed to add mac %s\n", buf);
+		return -1;
+	}
+
+	return 0;
+}
+
+/**
  * DPDK callback to set the primary MAC address.
  *
  * @param dev
@@ -1006,6 +1097,8 @@ static const struct eth_dev_ops mrvl_ops = {
 	.allmulticast_enable = mrvl_allmulticast_enable,
 	.promiscuous_disable = mrvl_promiscuous_disable,
 	.allmulticast_disable = mrvl_allmulticast_disable,
+	.mac_addr_remove = mrvl_mac_addr_remove,
+	.mac_addr_add = mrvl_mac_addr_add,
 	.mac_addr_set = mrvl_mac_addr_set,
 	.mtu_set = mrvl_mtu_set,
 	.dev_infos_get = mrvl_dev_infos_get,
diff --git a/drivers/net/mrvl/mrvl_ethdev.h b/drivers/net/mrvl/mrvl_ethdev.h
index da33d05..f43f426 100644
--- a/drivers/net/mrvl/mrvl_ethdev.h
+++ b/drivers/net/mrvl/mrvl_ethdev.h
@@ -98,6 +98,7 @@ struct mrvl_priv {
 	uint8_t pp_id;
 	uint8_t ppio_id;
 	uint8_t bpool_bit;
+	uint8_t uc_mc_flushed;
 
 	struct pp2_ppio_params ppio_params;
 	struct pp2_cls_qos_tbl_params qos_tbl_params;
-- 
2.7.4

  parent reply	other threads:[~2017-10-09 15:01 UTC|newest]

Thread overview: 110+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-26  9:39 [dpdk-dev] [PATCH 0/8] add net/crypto mrvl pmd drivers Tomasz Duszynski
2017-09-26  9:39 ` [dpdk-dev] [PATCH 1/8] app: link the whole rte_cfgfile library Tomasz Duszynski
2017-09-26 14:31   ` Bruce Richardson
2017-09-27  7:36     ` Tomasz Duszynski
2017-09-27 12:01       ` Bruce Richardson
2017-09-26  9:39 ` [dpdk-dev] [PATCH 2/8] net/mrvl: add mrvl net pmd driver Tomasz Duszynski
2017-09-26  9:40 ` [dpdk-dev] [PATCH 3/8] doc: add mrvl net pmd documentation Tomasz Duszynski
2017-09-26  9:40 ` [dpdk-dev] [PATCH 4/8] maintainers: add maintainers for the mrvl net pmd Tomasz Duszynski
2017-09-26  9:40 ` [dpdk-dev] [PATCH 5/8] crypto/mrvl: add mrvl crypto pmd driver Tomasz Duszynski
2017-09-26  9:40 ` [dpdk-dev] [PATCH 6/8] doc: add mrvl crypto pmd documentation Tomasz Duszynski
2017-09-26  9:40 ` [dpdk-dev] [PATCH 7/8] maintainers: add maintainers for the mrvl crypto pmd Tomasz Duszynski
2017-09-26  9:40 ` [dpdk-dev] [PATCH 8/8] test: add mrvl crypto pmd unit tests Tomasz Duszynski
2017-09-27  9:40 ` [dpdk-dev] [PATCH 0/8] add net/crypto mrvl pmd drivers De Lara Guarch, Pablo
2017-09-27 10:59   ` Tomasz Duszynski
2017-09-28 10:22 ` [dpdk-dev] [PATCH v2 0/4] add net mrvl pmd driver Tomasz Duszynski
2017-09-28 10:22   ` [dpdk-dev] [PATCH v2 1/4] app: link the whole rte_cfgfile library Tomasz Duszynski
2017-10-03 11:51     ` [dpdk-dev] [PATCH v3 0/4] add net mrvl pmd driver Tomasz Duszynski
2017-10-03 11:51       ` [dpdk-dev] [PATCH v3 1/4] app: link the whole rte_cfgfile library Tomasz Duszynski
2017-10-03 11:51       ` [dpdk-dev] [PATCH v3 2/4] net/mrvl: add mrvl net pmd driver Tomasz Duszynski
2017-10-04  0:24         ` Ferruh Yigit
2017-10-04  8:59           ` Tomasz Duszynski
2017-10-04 16:59             ` Ferruh Yigit
2017-10-05  8:43               ` Tomasz Duszynski
2017-10-05 17:29                 ` Ferruh Yigit
2017-10-06  6:41                   ` Tomasz Duszynski
2017-10-10 21:25                 ` Thomas Monjalon
2017-10-04  0:28         ` Ferruh Yigit
2017-10-04 13:19           ` Tomasz Duszynski
2017-10-05 17:37             ` Ferruh Yigit
2017-10-03 11:51       ` [dpdk-dev] [PATCH v3 3/4] doc: add mrvl net pmd documentation Tomasz Duszynski
2017-10-04  0:29         ` Ferruh Yigit
2017-10-04  7:53           ` Tomasz Duszynski
2017-10-03 11:51       ` [dpdk-dev] [PATCH v3 4/4] maintainers: add maintainers for the mrvl net pmd Tomasz Duszynski
2017-10-09 15:00       ` [dpdk-dev] [PATCH v4 00/16] add net mrvl pmd driver Tomasz Duszynski
2017-10-09 15:00         ` [dpdk-dev] [PATCH v4 01/16] app: link the whole rte_cfgfile library Tomasz Duszynski
2017-10-09 15:00         ` [dpdk-dev] [PATCH v4 02/16] net/mrvl: add mrvl net pmd driver skeleton Tomasz Duszynski
2017-10-11 13:38           ` Thomas Monjalon
2017-10-12  6:51             ` Tomasz Duszynski
2017-10-12  7:59               ` Vincent JARDIN
2017-10-12 12:14                 ` Jacek Siuda
2017-10-12 13:57                   ` Vincent JARDIN
2017-10-09 15:00         ` [dpdk-dev] [PATCH v4 03/16] net/mrvl: add rx/tx support Tomasz Duszynski
2017-10-09 15:00         ` [dpdk-dev] [PATCH v4 04/16] net/mrvl: add link update Tomasz Duszynski
2017-10-09 15:00         ` [dpdk-dev] [PATCH v4 05/16] net/mrvl: add link speed capabilities Tomasz Duszynski
2017-10-09 15:00         ` [dpdk-dev] [PATCH v4 06/16] net/mrvl: add support for updating mtu Tomasz Duszynski
2017-10-09 15:00         ` [dpdk-dev] [PATCH v4 07/16] net/mrvl: add jumbo frame support Tomasz Duszynski
2017-10-09 15:00         ` [dpdk-dev] [PATCH v4 08/16] net/mrvl: add support for promiscuous and allmulticast modes Tomasz Duszynski
2017-10-09 15:00         ` Tomasz Duszynski [this message]
2017-10-09 15:00         ` [dpdk-dev] [PATCH v4 10/16] net/mrvl: add rss hashing support Tomasz Duszynski
2017-10-09 15:00         ` [dpdk-dev] [PATCH v4 11/16] net/mrvl: add support for vlan filtering Tomasz Duszynski
2017-10-09 15:00         ` [dpdk-dev] [PATCH v4 12/16] net/mrvl: add crc, l3 and l4 offloads support Tomasz Duszynski
2017-10-09 15:00         ` [dpdk-dev] [PATCH v4 13/16] net/mrvl: add packet type parsing support Tomasz Duszynski
2017-10-09 15:00         ` [dpdk-dev] [PATCH v4 14/16] net/mrvl: add basic stats support Tomasz Duszynski
2017-10-09 15:00         ` [dpdk-dev] [PATCH v4 15/16] maintainers: add maintainers for the mrvl net pmd Tomasz Duszynski
2017-10-09 19:02           ` Ferruh Yigit
2017-10-09 19:09             ` Marcin Wojtas
2017-10-09 19:12               ` Ferruh Yigit
2017-10-10  5:47             ` Tomasz Duszynski
2017-10-10  3:20           ` Jianbo Liu
2017-10-10  4:38             ` Ferruh Yigit
2017-10-09 15:00         ` [dpdk-dev] [PATCH v4 16/16] doc: add mrvl net pmd documentation Tomasz Duszynski
2017-10-09 20:54           ` Ferruh Yigit
2017-10-10  5:51             ` Tomasz Duszynski
2017-10-11 14:27           ` Thomas Monjalon
2017-10-12  2:01             ` Thomas Monjalon
2017-10-09 20:59         ` [dpdk-dev] [PATCH v4 00/16] add net mrvl pmd driver Ferruh Yigit
2017-10-10  0:25           ` Ferruh Yigit
2017-10-10  7:07             ` Tomasz Duszynski
2017-10-10  5:55           ` Tomasz Duszynski
2017-10-12  1:51           ` Ferruh Yigit
2017-10-12  2:37             ` [dpdk-dev] [PATCH] doc: add build steps to mrvl NIC guide Thomas Monjalon
2017-10-12  6:28               ` Tomasz Duszynski
2017-10-12  8:02                 ` Thomas Monjalon
2017-10-12  6:07             ` [dpdk-dev] [PATCH v4 00/16] add net mrvl pmd driver Tomasz Duszynski
2017-09-28 10:22   ` [dpdk-dev] [PATCH v2 2/4] net/mrvl: add mrvl net " Tomasz Duszynski
2017-09-29 15:38     ` Stephen Hemminger
2017-10-02 11:08       ` Bruce Richardson
2017-10-03  6:33         ` Tomasz Duszynski
2017-10-03  6:23       ` Tomasz Duszynski
2017-09-28 10:22   ` [dpdk-dev] [PATCH v2 3/4] doc: add mrvl net pmd documentation Tomasz Duszynski
2017-09-28 10:22   ` [dpdk-dev] [PATCH v2 4/4] maintainers: add maintainers for the mrvl net pmd Tomasz Duszynski
2017-09-28 11:06   ` [dpdk-dev] [PATCH v2 0/4] add net mrvl pmd driver Ferruh Yigit
2017-09-28 11:40     ` Amit Tomer
2017-09-28 12:01       ` Marcin Wojtas
2017-09-28 10:23 ` [dpdk-dev] [PATCH v2 0/4] add crypto " Tomasz Duszynski
2017-09-28 10:23   ` [dpdk-dev] [PATCH v2 1/4] crypto/mrvl: add mrvl crypto " Tomasz Duszynski
2017-10-05 15:01     ` De Lara Guarch, Pablo
2017-10-06  7:24       ` Tomasz Duszynski
2017-10-05 15:47     ` Bruce Richardson
2017-10-06  7:05       ` Tomasz Duszynski
2017-09-28 10:23   ` [dpdk-dev] [PATCH v2 2/4] doc: add mrvl crypto pmd documentation Tomasz Duszynski
2017-10-05 14:45     ` De Lara Guarch, Pablo
2017-10-06  8:06       ` Tomasz Duszynski
2017-09-28 10:23   ` [dpdk-dev] [PATCH v2 3/4] maintainers: add maintainers for the mrvl crypto pmd Tomasz Duszynski
2017-09-28 10:23   ` [dpdk-dev] [PATCH v2 4/4] test: add mrvl crypto pmd unit tests Tomasz Duszynski
2017-10-07 20:28   ` [dpdk-dev] [PATCH v3 0/4] add crypto mrvl pmd driver Tomasz Duszynski
2017-10-07 20:28     ` [dpdk-dev] [PATCH v3 1/4] crypto/mrvl: add mrvl crypto " Tomasz Duszynski
2017-10-10 10:16       ` De Lara Guarch, Pablo
2017-10-10 10:25         ` Tomasz Duszynski
2017-10-07 20:28     ` [dpdk-dev] [PATCH v3 2/4] doc: add mrvl crypto pmd documentation Tomasz Duszynski
2017-10-07 20:28     ` [dpdk-dev] [PATCH v3 3/4] maintainers: add maintainers for the mrvl crypto pmd Tomasz Duszynski
2017-10-07 20:28     ` [dpdk-dev] [PATCH v3 4/4] test: add mrvl crypto pmd unit tests Tomasz Duszynski
2017-10-10 10:44       ` De Lara Guarch, Pablo
2017-10-10 10:57         ` Tomasz Duszynski
2017-10-10 12:17     ` [dpdk-dev] [PATCH v4 0/4] add crypto mrvl pmd driver Tomasz Duszynski
2017-10-10 12:17       ` [dpdk-dev] [PATCH v4 1/4] crypto/mrvl: add mrvl crypto " Tomasz Duszynski
2017-10-10 12:17       ` [dpdk-dev] [PATCH v4 2/4] doc: add mrvl crypto pmd documentation Tomasz Duszynski
2017-10-10 12:17       ` [dpdk-dev] [PATCH v4 3/4] maintainers: add maintainers for the mrvl crypto pmd Tomasz Duszynski
2017-10-10 12:17       ` [dpdk-dev] [PATCH v4 4/4] test: add mrvl crypto pmd unit tests Tomasz Duszynski
2017-10-12 12:11       ` [dpdk-dev] [PATCH v4 0/4] add crypto mrvl pmd driver De Lara Guarch, Pablo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1507561244-20115-10-git-send-email-tdu@semihalf.com \
    --to=tdu@semihalf.com \
    --cc=Jianbo.liu@linaro.org \
    --cc=dev@dpdk.org \
    --cc=dima@marvell.com \
    --cc=jck@semihalf.com \
    --cc=mw@semihalf.com \
    --cc=nsamsono@marvell.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).