linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vadim Lomovtsev <Vadim.Lomovtsev@caviumnetworks.com>
To: sgoutham@cavium.com, sunil.kovvuri@gmail.com, rric@kernel.org,
	linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, davem@davemloft.net
Cc: dnelson@redhat.com, ynorov@caviumnetworks.com,
	Vadim Lomovtsev <Vadim.Lomovtsev@cavium.com>
Subject: [PATCH v2 2/7] net: thunderx: add MAC address filter tracking for LMAC
Date: Fri, 30 Mar 2018 04:59:48 -0700	[thread overview]
Message-ID: <20180330115953.17154-3-Vadim.Lomovtsev@caviumnetworks.com> (raw)
In-Reply-To: <20180330115953.17154-1-Vadim.Lomovtsev@caviumnetworks.com>

From: Vadim Lomovtsev <Vadim.Lomovtsev@cavium.com>

The ThunderX NIC has two Ethernet Interfaces (BGX) each of them could has
up to four Logical MACs configured. Each of BGX has 32 filters to be
configured for filtering ingress packets. The number of filters available
to particular LMAC is from 8 (if we have four LMACs configured per BGX)
up to 32 (in case of only one LMAC is configured per BGX).

At the same time the NIC could present up to 128 VFs to OS as network
interfaces, each of them kernel will configure with set of MAC addresses
for filtering. So to prevent dupes in BGX filter registers from different
network interfaces it is required to cache and track all filter
configuration requests prior to applying them onto BGX filter registers.

This commit is to update LMAC structures with control fields to
allocate/releasing filters tracking list along with implementing
dmac array allocate/release per LMAC.

Signed-off-by: Vadim Lomovtsev <Vadim.Lomovtsev@cavium.com>
---
 drivers/net/ethernet/cavium/thunder/thunder_bgx.c | 44 +++++++++++++++--------
 1 file changed, 30 insertions(+), 14 deletions(-)

diff --git a/drivers/net/ethernet/cavium/thunder/thunder_bgx.c b/drivers/net/ethernet/cavium/thunder/thunder_bgx.c
index 0dd211605eb1..de90e6aa5a4f 100644
--- a/drivers/net/ethernet/cavium/thunder/thunder_bgx.c
+++ b/drivers/net/ethernet/cavium/thunder/thunder_bgx.c
@@ -37,9 +37,18 @@ enum MCAST_MODE {
 #define MCAST_MODE_MASK   0x3
 #define BGX_MCAST_MODE(x) (x << 1)
 
+struct dmac_map {
+	u64                     vf_map;
+	u64                     dmac;
+};
+
 struct lmac {
 	struct bgx		*bgx;
-	int			dmac;
+	/* actual number of DMACs configured */
+	u8			dmacs_cfg;
+	/* overal number of possible DMACs could be configured per LMAC */
+	u8                      dmacs_count;
+	struct dmac_map         *dmacs; /* DMAC:VFs tracking filter array */
 	u8			mac[ETH_ALEN];
 	u8                      lmac_type;
 	u8                      lane_to_sds;
@@ -236,6 +245,19 @@ void bgx_set_lmac_mac(int node, int bgx_idx, int lmacid, const u8 *mac)
 }
 EXPORT_SYMBOL(bgx_set_lmac_mac);
 
+static void bgx_flush_dmac_cam_filter(struct bgx *bgx, int lmacid)
+{
+	struct lmac *lmac = NULL;
+	u8  idx = 0;
+
+	lmac = &bgx->lmac[lmacid];
+	/* reset CAM filters */
+	for (idx = 0; idx < lmac->dmacs_count; idx++)
+		bgx_reg_write(bgx, 0, BGX_CMR_RX_DMACX_CAM +
+			      ((lmacid * lmac->dmacs_count) + idx) *
+			      sizeof(u64), 0);
+}
+
 void bgx_lmac_rx_tx_enable(int node, int bgx_idx, int lmacid, bool enable)
 {
 	struct bgx *bgx = get_bgx(node, bgx_idx);
@@ -481,18 +503,6 @@ u64 bgx_get_tx_stats(int node, int bgx_idx, int lmac, int idx)
 }
 EXPORT_SYMBOL(bgx_get_tx_stats);
 
-static void bgx_flush_dmac_addrs(struct bgx *bgx, int lmac)
-{
-	u64 offset;
-
-	while (bgx->lmac[lmac].dmac > 0) {
-		offset = ((bgx->lmac[lmac].dmac - 1) * sizeof(u64)) +
-			(lmac * MAX_DMAC_PER_LMAC * sizeof(u64));
-		bgx_reg_write(bgx, 0, BGX_CMR_RX_DMACX_CAM + offset, 0);
-		bgx->lmac[lmac].dmac--;
-	}
-}
-
 /* Configure BGX LMAC in internal loopback mode */
 void bgx_lmac_internal_loopback(int node, int bgx_idx,
 				int lmac_idx, bool enable)
@@ -925,6 +935,11 @@ static int bgx_lmac_enable(struct bgx *bgx, u8 lmacid)
 		bgx_reg_write(bgx, lmacid, BGX_SMUX_TX_MIN_PKT, 60 + 4);
 	}
 
+	/* actual number of filters available to exact LMAC */
+	lmac->dmacs_count = (RX_DMAC_COUNT / bgx->lmac_count);
+	lmac->dmacs = kcalloc(lmac->dmacs_count, sizeof(*lmac->dmacs),
+			      GFP_KERNEL);
+
 	/* Enable lmac */
 	bgx_reg_modify(bgx, lmacid, BGX_CMRX_CFG, CMR_EN);
 
@@ -1011,7 +1026,8 @@ static void bgx_lmac_disable(struct bgx *bgx, u8 lmacid)
 	cfg &= ~CMR_EN;
 	bgx_reg_write(bgx, lmacid, BGX_CMRX_CFG, cfg);
 
-	bgx_flush_dmac_addrs(bgx, lmacid);
+	bgx_flush_dmac_cam_filter(bgx, lmacid);
+	kfree(lmac->dmacs);
 
 	if ((lmac->lmac_type != BGX_MODE_XFI) &&
 	    (lmac->lmac_type != BGX_MODE_XLAUI) &&
-- 
2.14.3

  parent reply	other threads:[~2018-03-30 12:02 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-27 15:07 [PATCH 0/7] net: thunderx: implement DMAC filtering support Vadim Lomovtsev
2018-03-27 15:07 ` [PATCH 1/7] net: thunderx: move filter register related macro into proper place Vadim Lomovtsev
2018-03-27 15:07 ` [PATCH 2/7] net: thunderx: add MAC address filter tracking for LMAC Vadim Lomovtsev
2018-03-27 15:07 ` [PATCH 3/7] net: thunderx: add multicast filter management support Vadim Lomovtsev
2018-03-28 12:29   ` kbuild test robot
2018-03-27 15:07 ` [PATCH 4/7] net: thunderx: add new messages for handle ndo_set_rx_mode callback Vadim Lomovtsev
2018-03-27 15:07 ` [PATCH 5/7] net: thunderx: add XCAST messages handlers for PF Vadim Lomovtsev
2018-03-27 15:07 ` [PATCH 6/7] net: thunderx: add workqueue control structures for handle ndo_set_rx_mode request Vadim Lomovtsev
2018-03-27 15:07 ` [PATCH 7/7] net: thunderx: add ndo_set_rx_mode callback implementation for VF Vadim Lomovtsev
2018-03-27 17:28 ` [PATCH 0/7] net: thunderx: implement DMAC filtering support David Miller
2018-03-28  8:47   ` Vadim Lomovtsev
2018-03-30 11:59 ` [PATCH v2 " Vadim Lomovtsev
2018-03-30 11:59   ` [PATCH v2 1/7] net: thunderx: move filter register related macro into proper place Vadim Lomovtsev
2018-03-30 11:59   ` Vadim Lomovtsev [this message]
2018-03-30 11:59   ` [PATCH v2 3/7] net: thunderx: add multicast filter management support Vadim Lomovtsev
2018-03-30 11:59   ` [PATCH v2 4/7] net: thunderx: add new messages for handle ndo_set_rx_mode callback Vadim Lomovtsev
2018-03-30 11:59   ` [PATCH v2 5/7] net: thunderx: add XCAST messages handlers for PF Vadim Lomovtsev
2018-03-30 11:59   ` [PATCH v2 6/7] net: thunderx: add workqueue control structures for handle ndo_set_rx_mode request Vadim Lomovtsev
2018-03-30 11:59   ` [PATCH v2 7/7] net: thunderx: add ndo_set_rx_mode callback implementation for VF Vadim Lomovtsev
2018-04-01  2:07   ` [PATCH v2 0/7] net: thunderx: implement DMAC filtering support David Miller
2018-04-02 10:40     ` Vadim Lomovtsev
2019-02-20 11:02 ` [PATCH v3 0/8] nic: thunderx: fix communication races between VF & PF Vadim Lomovtsev
2019-02-20 11:02   ` [PATCH v3 1/8] net: thunderx: correct typo in macro name Vadim Lomovtsev
2019-02-20 11:02   ` [PATCH v3 2/8] net: thunderx: replace global nicvf_rx_mode_wq work queue for all VFs to private for each of them Vadim Lomovtsev
2019-02-20 11:02   ` [PATCH v3 3/8] net: thunderx: make CFG_DONE message to run through generic send-ack sequence Vadim Lomovtsev
2019-02-20 11:02   ` [PATCH v3 5/8] net: thunderx: rework xcast message structure to make it fit into 64 bit Vadim Lomovtsev
2019-02-20 11:02   ` [PATCH v3 6/8] net: thunderx: add mutex to protect mailbox from concurrent calls for same VF Vadim Lomovtsev
2019-02-20 11:02   ` [PATCH v3 4/8] net: thunderx: add nicvf_send_msg_to_pf result check for set_rx_mode_task Vadim Lomovtsev
2019-02-20 11:02   ` [PATCH v3 7/8] net: thunderx: move link state polling function to VF Vadim Lomovtsev
2019-02-20 11:02   ` [PATCH v3 8/8] net: thunderx: remove link change polling code and info from nicpf Vadim Lomovtsev
2019-02-20 11:19   ` [PATCH v3 0/8] nic: thunderx: fix communication races between VF & PF Vadim Lomovtsev
2019-02-22 19:44   ` David Miller

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=20180330115953.17154-3-Vadim.Lomovtsev@caviumnetworks.com \
    --to=vadim.lomovtsev@caviumnetworks.com \
    --cc=Vadim.Lomovtsev@cavium.com \
    --cc=davem@davemloft.net \
    --cc=dnelson@redhat.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=rric@kernel.org \
    --cc=sgoutham@cavium.com \
    --cc=sunil.kovvuri@gmail.com \
    --cc=ynorov@caviumnetworks.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).