DPDK patches and discussions
 help / color / mirror / Atom feed
From: Matej Vido <vido@cesnet.cz>
To: dev@dpdk.org
Cc: pus@cesnet.cz, viktorin@rehivetech.com
Subject: [dpdk-dev] [PATCH 3/4] szedata2: add functions for enabling/disabling promiscuous, allmulticast modes
Date: Thu, 28 Jan 2016 23:23:48 +0100	[thread overview]
Message-ID: <1454019829-5908-3-git-send-email-vido@cesnet.cz> (raw)
In-Reply-To: <1454019829-5908-1-git-send-email-vido@cesnet.cz>

Signed-off-by: Matej Vido <vido@cesnet.cz>
---
 drivers/net/szedata2/rte_eth_szedata2.c |   45 +++++++++++++++++++++++++++++++
 drivers/net/szedata2/rte_eth_szedata2.h |   39 ++++++++++++++++++++++++++
 2 files changed, 84 insertions(+), 0 deletions(-)

diff --git a/drivers/net/szedata2/rte_eth_szedata2.c b/drivers/net/szedata2/rte_eth_szedata2.c
index d8c260b..81c806e 100644
--- a/drivers/net/szedata2/rte_eth_szedata2.c
+++ b/drivers/net/szedata2/rte_eth_szedata2.c
@@ -1281,6 +1281,42 @@ eth_mac_addr_set(struct rte_eth_dev *dev __rte_unused,
 {
 }
 
+static void
+eth_promiscuous_enable(struct rte_eth_dev *dev)
+{
+	volatile struct szedata2_cgmii_ibuf *ibuf = SZEDATA2_PCI_RESOURCE_PTR(
+			dev, SZEDATA2_CGMII_IBUF_BASE_OFF,
+			volatile struct szedata2_cgmii_ibuf *);
+	cgmii_ibuf_mac_mode_write(ibuf, SZEDATA2_MAC_CHMODE_PROMISC);
+}
+
+static void
+eth_promiscuous_disable(struct rte_eth_dev *dev)
+{
+	volatile struct szedata2_cgmii_ibuf *ibuf = SZEDATA2_PCI_RESOURCE_PTR(
+			dev, SZEDATA2_CGMII_IBUF_BASE_OFF,
+			volatile struct szedata2_cgmii_ibuf *);
+	cgmii_ibuf_mac_mode_write(ibuf, SZEDATA2_MAC_CHMODE_ONLY_VALID);
+}
+
+static void
+eth_allmulticast_enable(struct rte_eth_dev *dev)
+{
+	volatile struct szedata2_cgmii_ibuf *ibuf = SZEDATA2_PCI_RESOURCE_PTR(
+			dev, SZEDATA2_CGMII_IBUF_BASE_OFF,
+			volatile struct szedata2_cgmii_ibuf *);
+	cgmii_ibuf_mac_mode_write(ibuf, SZEDATA2_MAC_CHMODE_ALL_MULTICAST);
+}
+
+static void
+eth_allmulticast_disable(struct rte_eth_dev *dev)
+{
+	volatile struct szedata2_cgmii_ibuf *ibuf = SZEDATA2_PCI_RESOURCE_PTR(
+			dev, SZEDATA2_CGMII_IBUF_BASE_OFF,
+			volatile struct szedata2_cgmii_ibuf *);
+	cgmii_ibuf_mac_mode_write(ibuf, SZEDATA2_MAC_CHMODE_ONLY_VALID);
+}
+
 static struct eth_dev_ops ops = {
 		.dev_start          = eth_dev_start,
 		.dev_stop           = eth_dev_stop,
@@ -1289,6 +1325,10 @@ static struct eth_dev_ops ops = {
 		.dev_close          = eth_dev_close,
 		.dev_configure      = eth_dev_configure,
 		.dev_infos_get      = eth_dev_info,
+		.promiscuous_enable   = eth_promiscuous_enable,
+		.promiscuous_disable  = eth_promiscuous_disable,
+		.allmulticast_enable  = eth_allmulticast_enable,
+		.allmulticast_disable = eth_allmulticast_disable,
 		.rx_queue_start     = eth_rx_queue_start,
 		.rx_queue_stop      = eth_rx_queue_stop,
 		.tx_queue_start     = eth_tx_queue_start,
@@ -1471,8 +1511,10 @@ rte_szedata2_eth_dev_init(struct rte_eth_dev *dev)
 			(unsigned long long)pci_rsc->len,
 			(unsigned long long)pci_rsc->addr);
 
+	/* Get link state */
 	eth_link_update(dev, 0);
 
+	/* Allocate space for one mac address */
 	data->mac_addrs = rte_zmalloc(data->name, sizeof(struct ether_addr),
 			RTE_CACHE_LINE_SIZE);
 	if (data->mac_addrs == NULL) {
@@ -1484,6 +1526,9 @@ rte_szedata2_eth_dev_init(struct rte_eth_dev *dev)
 
 	ether_addr_copy(&eth_addr, data->mac_addrs);
 
+	/* At initial state COMBO card is in promiscuous mode so disable it */
+	eth_promiscuous_disable(dev);
+
 	RTE_LOG(INFO, PMD, "szedata2 device ("
 			PCI_PRI_FMT ") successfully initialized\n",
 			pci_addr->domain, pci_addr->bus, pci_addr->devid,
diff --git a/drivers/net/szedata2/rte_eth_szedata2.h b/drivers/net/szedata2/rte_eth_szedata2.h
index 39d1c48..522cf47 100644
--- a/drivers/net/szedata2/rte_eth_szedata2.h
+++ b/drivers/net/szedata2/rte_eth_szedata2.h
@@ -213,6 +213,13 @@ enum szedata2_link_speed {
 	SZEDATA2_LINK_SPEED_100G,
 };
 
+enum szedata2_mac_check_mode {
+	SZEDATA2_MAC_CHMODE_PROMISC       = 0x0,
+	SZEDATA2_MAC_CHMODE_ONLY_VALID    = 0x1,
+	SZEDATA2_MAC_CHMODE_ALL_BROADCAST = 0x2,
+	SZEDATA2_MAC_CHMODE_ALL_MULTICAST = 0x3,
+};
+
 /*
  * Structure describes CGMII IBUF address space
  */
@@ -299,6 +306,38 @@ cgmii_ibuf_is_link_up(volatile struct szedata2_cgmii_ibuf *ibuf)
 }
 
 /*
+ * @return
+ *     MAC address check mode
+ */
+static inline enum szedata2_mac_check_mode
+cgmii_ibuf_mac_mode_read(volatile struct szedata2_cgmii_ibuf *ibuf)
+{
+	switch (rte_le_to_cpu_32(ibuf->mac_chmode) & 0x3) {
+	case 0x0:
+		return SZEDATA2_MAC_CHMODE_PROMISC;
+	case 0x1:
+		return SZEDATA2_MAC_CHMODE_ONLY_VALID;
+	case 0x2:
+		return SZEDATA2_MAC_CHMODE_ALL_BROADCAST;
+	case 0x3:
+		return SZEDATA2_MAC_CHMODE_ALL_MULTICAST;
+	default:
+		return SZEDATA2_MAC_CHMODE_PROMISC;
+	}
+}
+
+/*
+ * Writes "mode" in MAC address check mode register.
+ */
+static inline void
+cgmii_ibuf_mac_mode_write(volatile struct szedata2_cgmii_ibuf *ibuf,
+		enum szedata2_mac_check_mode mode)
+{
+	ibuf->mac_chmode = rte_cpu_to_le_32(
+			(rte_le_to_cpu_32(ibuf->mac_chmode) & ~0x3) | mode);
+}
+
+/*
  * Structure describes CGMII OBUF address space
  */
 struct szedata2_cgmii_obuf {
-- 
1.7.1

  parent reply	other threads:[~2016-01-28 22:24 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-28 22:23 [dpdk-dev] [PATCH 1/4] szedata2: rewrite PMD from virtual PMD_VDEV type to PMD_PDEV type Matej Vido
2016-01-28 22:23 ` [dpdk-dev] [PATCH 2/4] szedata2: add functions for setting link up/down and updating link info Matej Vido
2016-01-28 22:23 ` Matej Vido [this message]
2016-01-28 22:23 ` [dpdk-dev] [PATCH 4/4] szedata2: update documentation and release notes Matej Vido
2016-02-17 11:32 ` [dpdk-dev] [PATCH 1/4] szedata2: rewrite PMD from virtual PMD_VDEV type to PMD_PDEV type Bruce Richardson

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=1454019829-5908-3-git-send-email-vido@cesnet.cz \
    --to=vido@cesnet.cz \
    --cc=dev@dpdk.org \
    --cc=pus@cesnet.cz \
    --cc=viktorin@rehivetech.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).