Skip to content

Commit 3a34ecf

Browse files
Vadim Lomovtsevdavem330
authored andcommitted
net: thunderx: add MAC address filter tracking for LMAC
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 <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent f8ad1f3 commit 3a34ecf

File tree

1 file changed

+30
-14
lines changed

1 file changed

+30
-14
lines changed

drivers/net/ethernet/cavium/thunder/thunder_bgx.c

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,18 @@ enum MCAST_MODE {
3737
#define MCAST_MODE_MASK 0x3
3838
#define BGX_MCAST_MODE(x) (x << 1)
3939

40+
struct dmac_map {
41+
u64 vf_map;
42+
u64 dmac;
43+
};
44+
4045
struct lmac {
4146
struct bgx *bgx;
42-
int dmac;
47+
/* actual number of DMACs configured */
48+
u8 dmacs_cfg;
49+
/* overal number of possible DMACs could be configured per LMAC */
50+
u8 dmacs_count;
51+
struct dmac_map *dmacs; /* DMAC:VFs tracking filter array */
4352
u8 mac[ETH_ALEN];
4453
u8 lmac_type;
4554
u8 lane_to_sds;
@@ -236,6 +245,19 @@ void bgx_set_lmac_mac(int node, int bgx_idx, int lmacid, const u8 *mac)
236245
}
237246
EXPORT_SYMBOL(bgx_set_lmac_mac);
238247

248+
static void bgx_flush_dmac_cam_filter(struct bgx *bgx, int lmacid)
249+
{
250+
struct lmac *lmac = NULL;
251+
u8 idx = 0;
252+
253+
lmac = &bgx->lmac[lmacid];
254+
/* reset CAM filters */
255+
for (idx = 0; idx < lmac->dmacs_count; idx++)
256+
bgx_reg_write(bgx, 0, BGX_CMR_RX_DMACX_CAM +
257+
((lmacid * lmac->dmacs_count) + idx) *
258+
sizeof(u64), 0);
259+
}
260+
239261
void bgx_lmac_rx_tx_enable(int node, int bgx_idx, int lmacid, bool enable)
240262
{
241263
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)
481503
}
482504
EXPORT_SYMBOL(bgx_get_tx_stats);
483505

484-
static void bgx_flush_dmac_addrs(struct bgx *bgx, int lmac)
485-
{
486-
u64 offset;
487-
488-
while (bgx->lmac[lmac].dmac > 0) {
489-
offset = ((bgx->lmac[lmac].dmac - 1) * sizeof(u64)) +
490-
(lmac * MAX_DMAC_PER_LMAC * sizeof(u64));
491-
bgx_reg_write(bgx, 0, BGX_CMR_RX_DMACX_CAM + offset, 0);
492-
bgx->lmac[lmac].dmac--;
493-
}
494-
}
495-
496506
/* Configure BGX LMAC in internal loopback mode */
497507
void bgx_lmac_internal_loopback(int node, int bgx_idx,
498508
int lmac_idx, bool enable)
@@ -925,6 +935,11 @@ static int bgx_lmac_enable(struct bgx *bgx, u8 lmacid)
925935
bgx_reg_write(bgx, lmacid, BGX_SMUX_TX_MIN_PKT, 60 + 4);
926936
}
927937

938+
/* actual number of filters available to exact LMAC */
939+
lmac->dmacs_count = (RX_DMAC_COUNT / bgx->lmac_count);
940+
lmac->dmacs = kcalloc(lmac->dmacs_count, sizeof(*lmac->dmacs),
941+
GFP_KERNEL);
942+
928943
/* Enable lmac */
929944
bgx_reg_modify(bgx, lmacid, BGX_CMRX_CFG, CMR_EN);
930945

@@ -1011,7 +1026,8 @@ static void bgx_lmac_disable(struct bgx *bgx, u8 lmacid)
10111026
cfg &= ~CMR_EN;
10121027
bgx_reg_write(bgx, lmacid, BGX_CMRX_CFG, cfg);
10131028

1014-
bgx_flush_dmac_addrs(bgx, lmacid);
1029+
bgx_flush_dmac_cam_filter(bgx, lmacid);
1030+
kfree(lmac->dmacs);
10151031

10161032
if ((lmac->lmac_type != BGX_MODE_XFI) &&
10171033
(lmac->lmac_type != BGX_MODE_XLAUI) &&

0 commit comments

Comments
 (0)