octeontx2-af: Show DMAC filter drop count
PATCH 1/1 octeontx2-af: Show DMAC filter drop count
From: Hariprasad Kelam <[email protected]>
Show the number of packets dropped by DMAC filters in the CGX/RPM debugfs mac_filter entry.
CGX uses RX_STAT4 for this counter, while RPM/RPM2 use RX_STAT2.
--- .../net/ethernet/marvell/octeontx2/af/cgx.c | 13 +++++- .../net/ethernet/marvell/octeontx2/af/cgx.h | 2 + .../marvell/octeontx2/af/lmac_common.h | 2 + .../net/ethernet/marvell/octeontx2/af/rpm.c | 40 +++++++++++++------ .../net/ethernet/marvell/octeontx2/af/rpm.h | 2 + .../net/ethernet/marvell/octeontx2/af/rvu.h | 1 + .../ethernet/marvell/octeontx2/af/rvu_cgx.c | 12 ++++++ .../marvell/octeontx2/af/rvu_debugfs.c | 8 ++++ 8 files changed, 67 insertions(+), 13 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/cgx.c +12 -1
@@ -752,6 +752,16 @@ u64 cgx_features_get(void *cgxd)return ((struct cgx *)cgxd)->hw_features; } +u64 cgx_get_dmacflt_dropped_pktcnt (void *cgxd,int lmac_id) +{ +struct cgx *cgx = cgxd; + +if (!is_lmac_valid (cgx, lmac_id)) +return 0 ; + +return cgx_read (cgx, lmac_id,CGXX_CMRX_RX_STAT4 ); +} +int cgx_stats_reset (void *cgxd,int lmac_id) {struct cgx *cgx = cgxd;
@@ -1943,7 +1953,8 @@ static struct mac_ops cgx_mac_ops = { .pfc_config = cgx_lmac_pfc_config, .mac_get_pfc_frm_cfg = cgx_lmac_get_pfc_frm_cfg, .mac_reset = cgx_lmac_reset, - .mac_stats_reset = cgx_stats_reset, + .get_dmacflt_dropped_pktcnt = cgx_get_dmacflt_dropped_pktcnt, + .mac_stats_reset = cgx_stats_reset, .mac_x2p_reset = cgx_x2p_reset, .mac_enadis_rx = cgx_enadis_rx, };
drivers/net/ethernet/marvell/octeontx2/af/cgx.h +2 -0
@@ -39,6 +39,7 @@#define CGXX_CMRX_INT_ENA_W1S 0x058#define CGXX_CMRX_RX_ID_MAP 0x060#define CGXX_CMRX_RX_STAT0 0x070 +#define CGXX_CMRX_RX_STAT4 0x090#define CGXX_CMRX_RX_LOGL_XON 0x100#define CGXX_CMRX_RX_LMACS 0x128#define CGXX_CMRX_RX_DMAC_CTL0 (0x1F8 + mac_ops->csr_offset)
@@ -187,5 +188,6 @@ int cgx_lmac_get_pfc_frm_cfg(void *cgxd, int lmac_id, u8 *tx_pause,int verify_lmac_fc_cfg (void *cgxd,int lmac_id,u8 tx_pause,u8 rx_pause,int pfvf_idx);int cgx_lmac_reset (void *cgxd,int lmac_id,u8 pf_req_flr); +u64 cgx_get_dmacflt_dropped_pktcnt (void *cgx,int lmac_id);u32 cgx_get_fifo_len (void *cgxd);#endif /* CGX_H */
drivers/net/ethernet/marvell/octeontx2/af/lmac_common.h +2 -0
@@ -128,6 +128,8 @@ struct mac_ops { u8 *tx_pause, u8 *rx_pause);int (*mac_reset)(void *cgxd,int lmac_id,u8 pf_req_flr); +u64 (*get_dmacflt_dropped_pktcnt)(void *cgxd,int lmac_id); +/* FEC stats */ int (*get_fec_stats)(void *cgxd,int lmac_id,struct cgx_fec_stats_rsp *rsp);
drivers/net/ethernet/marvell/octeontx2/af/rpm.c +28 -12
@@ -29,18 +29,19 @@ static struct mac_ops rpm_mac_ops = { .mac_get_tx_stats = rpm_get_tx_stats, .get_fec_stats = rpm_get_fec_stats, .mac_enadis_rx_pause_fwding = rpm_lmac_enadis_rx_pause_fwding, - .mac_get_pause_frm_status = rpm_lmac_get_pause_frm_status, - .mac_enadis_pause_frm = rpm_lmac_enadis_pause_frm, - .mac_pause_frm_config = rpm_lmac_pause_frm_config, - .mac_enadis_ptp_config = rpm_lmac_ptp_config, - .mac_rx_tx_enable = rpm_lmac_rx_tx_enable, - .mac_tx_enable = rpm_lmac_tx_enable, - .pfc_config = rpm_lmac_pfc_config, - .mac_get_pfc_frm_cfg = rpm_lmac_get_pfc_frm_cfg, - .mac_reset = rpm_lmac_reset, - .mac_stats_reset = rpm_stats_reset, - .mac_x2p_reset = rpm_x2p_reset, - .mac_enadis_rx = rpm_enadis_rx, + .mac_get_pause_frm_status = rpm_lmac_get_pause_frm_status, + .mac_enadis_pause_frm = rpm_lmac_enadis_pause_frm, + .mac_pause_frm_config = rpm_lmac_pause_frm_config, + .mac_enadis_ptp_config = rpm_lmac_ptp_config, + .mac_rx_tx_enable = rpm_lmac_rx_tx_enable, + .mac_tx_enable = rpm_lmac_tx_enable, + .pfc_config = rpm_lmac_pfc_config, + .mac_get_pfc_frm_cfg = rpm_lmac_get_pfc_frm_cfg, + .mac_reset = rpm_lmac_reset, + .get_dmacflt_dropped_pktcnt = rpm_get_dmacflt_dropped_pktcnt, + .mac_stats_reset = rpm_stats_reset, + .mac_x2p_reset = rpm_x2p_reset, + .mac_enadis_rx = rpm_enadis_rx, };static struct mac_ops rpm2_mac_ops = {
@@ -73,6 +74,7 @@ static struct mac_ops rpm2_mac_ops = { .pfc_config = rpm_lmac_pfc_config, .mac_get_pfc_frm_cfg = rpm_lmac_get_pfc_frm_cfg, .mac_reset = rpm_lmac_reset, + .get_dmacflt_dropped_pktcnt = rpm_get_dmacflt_dropped_pktcnt, .mac_stats_reset = rpm_stats_reset, .mac_x2p_reset = rpm_x2p_reset, .mac_enadis_rx = rpm_enadis_rx,
@@ -449,6 +451,20 @@ int rpm_get_tx_stats(void *rpmd, int lmac_id, int idx, u64 *tx_stat)return 0 ; } +u64 rpm_get_dmacflt_dropped_pktcnt (void *rpmd,int lmac_id) +{ +rpm_t *rpm = rpmd; +u64 dmac_flt_stat; + +if (!is_lmac_valid (rpm, lmac_id)) +return 0 ; + + dmac_flt_stat =is_dev_rpm2 (rpm) ?RPM2_CMRX_RX_STAT2 : +RPMX_CMRX_RX_STAT2 ; + +return rpm_read (rpm, lmac_id, dmac_flt_stat); +} +int rpm_stats_reset (void *rpmd,int lmac_id) {rpm_t *rpm = rpmd;
drivers/net/ethernet/marvell/octeontx2/af/rpm.h +2 -0
@@ -60,6 +60,7 @@#define RPMX_MTI_STAT_RX_STAT_PAGES_COUNTERX 0x12000#define RPMX_MTI_STAT_TX_STAT_PAGES_COUNTERX 0x13000#define RPMX_MTI_STAT_DATA_HI_CDC 0x10038 +#define RPMX_CMRX_RX_STAT2 0x4010#define RPM_LMAC_FWI 0xa#define RPM_TX_EN BIT_ULL(0)
@@ -129,6 +130,7 @@ int rpm_lmac_enadis_pause_frm(void *rpmd, int lmac_id, u8 tx_pause, u8 rx_pause);int rpm_get_tx_stats (void *rpmd,int lmac_id,int idx,u64 *tx_stat);int rpm_get_rx_stats (void *rpmd,int lmac_id,int idx,u64 *rx_stat); +u64 rpm_get_dmacflt_dropped_pktcnt (void *rpmd,int lmac_id);void rpm_lmac_ptp_config (void *rpmd,int lmac_id,bool enable);int rpm_lmac_rx_tx_enable (void *rpmd,int lmac_id,bool enable);int rpm_lmac_tx_enable (void *rpmd,int lmac_id,bool enable);
drivers/net/ethernet/marvell/octeontx2/af/rvu.h +1 -0
@@ -1127,6 +1127,7 @@ int rvu_cgx_prio_flow_ctrl_cfg(struct rvu *rvu, u16 pcifunc, u8 tx_pause, u8 rx_ u16 pfc_en);int rvu_cgx_cfg_pause_frm (struct rvu *rvu,u16 pcifunc,u8 tx_pause,u8 rx_pause);void rvu_mac_reset (struct rvu *rvu,u16 pcifunc); +u64 rvu_cgx_get_dmacflt_dropped_pktcnt (void *cgxd,int lmac_id);u32 rvu_cgx_get_lmac_fifolen (struct rvu *rvu,int cgx,int lmac);void cgx_start_linkup (struct rvu *rvu); int npc_get_nixlf_mcam_index(struct npc_mcam *mcam,
drivers/net/ethernet/marvell/octeontx2/af/rvu_cgx.c +12 -0
@@ -1356,6 +1356,18 @@ void rvu_mac_reset(struct rvu *rvu, u16 pcifunc)dev_err (rvu->dev,"Failed to reset MAC\n" ); } +u64 rvu_cgx_get_dmacflt_dropped_pktcnt (void *cgxd,int lmac_id) +{ +struct mac_ops *mac_ops; + + mac_ops =get_mac_ops (cgxd); + +if (!mac_ops || !mac_ops->get_dmacflt_dropped_pktcnt) +return 0 ; + +return mac_ops->get_dmacflt_dropped_pktcnt (cgxd, lmac_id); +} +/* Do not allow CGX-mapped VFs to overwrite PKIND when special parse kinds * (HiGig, EDSA, etc.) are in use on the shared LMAC. VFs must not program * NPC_TX_DEF_PKIND on NIX_AF_LFX_TX_PARSE_CFG in that case: the PF owns
drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c +8 -0
@@ -2957,8 +2957,10 @@ static int cgx_print_dmac_flt(struct seq_file *s, int lmac_id)struct rvu_cgx_lmac_dbgfs_ctx *dctx = s->private;struct rvu *rvu = dctx->rvu;struct pci_dev *pdev =NULL ; +struct mac_ops *mac_ops;void *cgxd = dctx->cgxd;char *bcast, *mcast; +u64 drop_cnt;u16 index, domain;u8 dmac[ETH_ALEN ];u64 cfg, mac;
@@ -2997,6 +2999,12 @@ static int cgx_print_dmac_flt(struct seq_file *s, int lmac_id) } } + mac_ops =get_mac_ops (cgxd); +if (mac_ops && mac_ops->get_dmacflt_dropped_pktcnt) { + drop_cnt =rvu_cgx_get_dmacflt_dropped_pktcnt (cgxd, lmac_id); +seq_printf (s,"\nDMAC filter drop count: %llu\n" , drop_cnt); + } +pci_dev_put (pdev);return 0 ; }
Signature · 1 line
2.48.1
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Critical: 0 · High: 0 · Medium: 1 · Low: 0
- [Medium] New debugfs label contradicts the driver's own name for the same CGX register.
--
octeontx2-af: Show DMAC filter drop count
This adds a new mac_ops callback, get_dmacflt_dropped_pktcnt, implemented for CGX (reading CGXX_CMRX_RX_STAT4) and RPM/RPM2 (reading RX_STAT2), and prints the value in the mac_filter debugfs entry.
Quoted 8 lines
drivers/net/ethernet/marvell/octeontx2/af/cgx.c +0
-0@@ -752,6 +752,16 @@ u64 cgx_features_get(void *cgxd)return ((struct cgx *)cgxd)->hw_features; }
drivers/net/ethernet/marvell/octeontx2/af/cgx.c u64 cgx_features_get(void *cgxd) · line 764
Quoted 10 lines
drivers/net/ethernet/marvell/octeontx2/af/cgx.c +10
-0+u64 cgx_get_dmacflt_dropped_pktcnt (void *cgxd,int lmac_id) +{ +struct cgx *cgx = cgxd; + +if (!is_lmac_valid (cgx, lmac_id)) +return 0 ; + +return cgx_read (cgx, lmac_id,CGXX_CMRX_RX_STAT4 ); +} +
[Severity: Medium]
Is CGXX_CMRX_RX_STAT4 really the DMAC filter drop counter? This driver already exposes that same register under a different name.
cgx_get_rx_stats() reads:
*rx_stat = cgx_read(cgx, lmac_id, CGXX_CMRX_RX_STAT0 + (idx * 8));
For idx == 4 that is 0x070 + 32 == 0x090, i.e. the newly added CGXX_CMRX_RX_STAT4. The name printed for it in the cgx_stat debugfs file is:
drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c:
[CGX_STAT4] = "Filtered DMAC0 (NIX-bound) packets", [CGX_STAT5] = "Filtered DMAC0 (NIX-bound) octets", [CGX_STAT6] = "Packets dropped due to RX FIFO full", [CGX_STAT7] = "Octets dropped due to RX FIFO full", ... [CGX_STAT11] = "NCSI-bound packets dropped",
That table uses "dropped" wording for STAT6/7 and STAT11/12, and the "Filtered DMAC<n> (<channel>-bound)" wording for STAT4/5 and STAT9/10, which reads as packets that passed the DMAC filter towards NIX rather than packets discarded by it.
Quoted 10 lines
drivers/net/ethernet/marvell/octeontx2/af/cgx.h +1
-0@@ -39,6 +39,7 @@#define CGXX_CMRX_INT_ENA_W1S 0x058#define CGXX_CMRX_RX_ID_MAP 0x060#define CGXX_CMRX_RX_STAT0 0x070 +#define CGXX_CMRX_RX_STAT4 0x090#define CGXX_CMRX_RX_LOGL_XON 0x100
[ ... ]
Quoted 5 lines
drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c +0
-0
drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c static int cgx_print_dmac_flt(struct seq_file *s, int lmac_id) · line 3013
Quoted 9 lines
drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c +6
-0@@ -3003,6 +3005,12 @@ static int cgx_print_dmac_flt(struct seq_file *s, int lmac_id) } } + mac_ops =get_mac_ops (cgxd); +if (mac_ops && mac_ops->get_dmacflt_dropped_pktcnt) { + drop_cnt =rvu_cgx_get_dmacflt_dropped_pktcnt (cgxd, lmac_id); +seq_printf (s,"\nDMAC filter drop count: %llu\n" , drop_cnt); + } +
[Severity: Medium]
After this change, the same CGX register is presented to users with two opposite meanings in two debugfs files of the same driver:cgx_print_stats() prints it via cgx_rx_stats_fields[CGX_STAT4] as "Filtered DMAC0 (NIX-bound) packets", while cgx_print_dmac_flt() prints it as "DMAC filter drop count".
One of the two descriptions has to be wrong. If the existing table is the correct one, then any interface passing traffic will show a large and continuously growing "DMAC filter drop count" that is really the accepted packet count.
Could the two labels be reconciled, i.e. either correct cgx_rx_stats_fields[CGX_STAT4] or use a different register for the drop count here?
The commit message says:
CGX uses RX_STAT4 for this counter, while RPM/RPM2 use RX_STAT2.
Can a reference to the CGX/RPM register descriptions be added so it is clear which of the two in-tree descriptions of RX_STAT4 matches the hardware?
[ ... ]
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260901042503.1182121-1-nshettyj%40marvell.com
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 8 lines · On Tue, 1 Sep 2026 09:55:02 +0530 you wrote:
From: Hariprasad Kelam <[email protected]>
Show the number of packets dropped by DMAC filters in the CGX/RPM debugfs
mac_filterentry.CGX uses
RX_STAT4for this counter, while RPM/RPM2 useRX_STAT2.[...]
Here is the summary with links:
- [net-next] octeontx2-af: Show DMAC filter drop count
https://git.kernel.org/netdev/net-next/c/5cce5d29273c
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html