]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
octeontx2-af: Add FEC stats for RPM/RPM_USX block
authorHariprasad Kelam <hkelam@marvell.com>
Mon, 5 Dec 2022 07:05:21 +0000 (12:35 +0530)
committerPaolo Abeni <pabeni@redhat.com>
Wed, 7 Dec 2022 11:24:29 +0000 (12:24 +0100)
CN10K silicon MAC block RPM and CN10KB silicon MAC block RPM_USX
both support BASER and RSFEC modes.

Also MAC (CGX) on OcteonTx2 silicon variants and MAC (RPM) on
OcteonTx3 CN10K are different and FEC stats need to be read
differently. CN10KB MAC block (RPM_USX) fec csr offsets are same
as CN10K MAC block (RPM) mac_ops points to same fn(). Upper layer
interface between  RVU AF and PF netdev is  kept same. Based on
silicon variant appropriate fn() pointer is called to  read FEC stats

Signed-off-by: Hariprasad Kelam <hkelam@marvell.com>
Signed-off-by: Sunil Kovvuri Goutham <sgoutham@marvell.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
drivers/net/ethernet/marvell/octeontx2/af/cgx.c
drivers/net/ethernet/marvell/octeontx2/af/lmac_common.h
drivers/net/ethernet/marvell/octeontx2/af/rpm.c
drivers/net/ethernet/marvell/octeontx2/af/rpm.h
drivers/net/ethernet/marvell/octeontx2/af/rvu_cgx.c

index 242c5b0eb15d6be7bffd1d33626d399be9f48522..b2b71fe80d61c2239e2231729f1f64a2fe8d285d 100644 (file)
@@ -742,6 +742,10 @@ int cgx_get_fec_stats(void *cgxd, int lmac_id, struct cgx_fec_stats_rsp *rsp)
 
        if (!cgx || lmac_id >= cgx->lmac_count)
                return -ENODEV;
+
+       if (cgx->lmac_idmap[lmac_id]->link_info.fec == OTX2_FEC_NONE)
+               return 0;
+
        fec_stats_count =
                cgx_set_fec_stats_count(&cgx->lmac_idmap[lmac_id]->link_info);
        if (cgx->lmac_idmap[lmac_id]->link_info.fec == OTX2_FEC_BASER) {
@@ -1749,6 +1753,7 @@ static struct mac_ops     cgx_mac_ops    = {
        .mac_lmac_intl_lbk =    cgx_lmac_internal_loopback,
        .mac_get_rx_stats  =    cgx_get_rx_stats,
        .mac_get_tx_stats  =    cgx_get_tx_stats,
+       .get_fec_stats     =    cgx_get_fec_stats,
        .mac_enadis_rx_pause_fwding =   cgx_lmac_enadis_rx_pause_fwding,
        .mac_get_pause_frm_status =     cgx_lmac_get_pause_frm_status,
        .mac_enadis_pause_frm =         cgx_lmac_enadis_pause_frm,
index 386fb73ad366dead02bff5c81a741acac841b3e0..39aaf0e4467dcffddc77f359e59987eb2fefe0b6 100644 (file)
@@ -126,6 +126,9 @@ struct mac_ops {
        int                     (*mac_get_pfc_frm_cfg)(void *cgxd, int lmac_id,
                                                       u8 *tx_pause, u8 *rx_pause);
 
+       /* FEC stats */
+       int                     (*get_fec_stats)(void *cgxd, int lmac_id,
+                                                struct cgx_fec_stats_rsp *rsp);
 };
 
 struct cgx {
index a15a59d5dff8cbb53846a29f02a68548f1241d6a..de0d88dd10d65c74803e44e330a4cbf78e2eb00d 100644 (file)
@@ -27,6 +27,7 @@ static struct mac_ops         rpm_mac_ops   = {
        .mac_lmac_intl_lbk =    rpm_lmac_internal_loopback,
        .mac_get_rx_stats  =    rpm_get_rx_stats,
        .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,
@@ -57,6 +58,7 @@ static struct mac_ops         rpm2_mac_ops   = {
        .mac_lmac_intl_lbk =    rpm_lmac_internal_loopback,
        .mac_get_rx_stats  =    rpm_get_rx_stats,
        .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,
@@ -655,3 +657,59 @@ int  rpm_lmac_get_pfc_frm_cfg(void *rpmd, int lmac_id, u8 *tx_pause, u8 *rx_paus
 
        return 0;
 }
+
+int rpm_get_fec_stats(void *rpmd, int lmac_id, struct cgx_fec_stats_rsp *rsp)
+{
+       u64 val_lo, val_hi;
+       rpm_t *rpm = rpmd;
+       u64 cfg;
+
+       if (!is_lmac_valid(rpm, lmac_id))
+               return -ENODEV;
+
+       if (rpm->lmac_idmap[lmac_id]->link_info.fec == OTX2_FEC_NONE)
+               return 0;
+
+       if (rpm->lmac_idmap[lmac_id]->link_info.fec == OTX2_FEC_BASER) {
+               val_lo = rpm_read(rpm, lmac_id, RPMX_MTI_FCFECX_VL0_CCW_LO);
+               val_hi = rpm_read(rpm, lmac_id, RPMX_MTI_FCFECX_CW_HI);
+               rsp->fec_corr_blks = (val_hi << 16 | val_lo);
+
+               val_lo = rpm_read(rpm, lmac_id, RPMX_MTI_FCFECX_VL0_NCCW_LO);
+               val_hi = rpm_read(rpm, lmac_id, RPMX_MTI_FCFECX_CW_HI);
+               rsp->fec_uncorr_blks = (val_hi << 16 | val_lo);
+
+               /* 50G uses 2 Physical serdes lines */
+               if (rpm->lmac_idmap[lmac_id]->link_info.lmac_type_id ==
+                   LMAC_MODE_50G_R) {
+                       val_lo = rpm_read(rpm, lmac_id,
+                                         RPMX_MTI_FCFECX_VL1_CCW_LO);
+                       val_hi = rpm_read(rpm, lmac_id,
+                                         RPMX_MTI_FCFECX_CW_HI);
+                       rsp->fec_corr_blks += (val_hi << 16 | val_lo);
+
+                       val_lo = rpm_read(rpm, lmac_id,
+                                         RPMX_MTI_FCFECX_VL1_NCCW_LO);
+                       val_hi = rpm_read(rpm, lmac_id,
+                                         RPMX_MTI_FCFECX_CW_HI);
+                       rsp->fec_uncorr_blks += (val_hi << 16 | val_lo);
+               }
+       } else {
+               /* enable RS-FEC capture */
+               cfg = rpm_read(rpm, 0, RPMX_MTI_STAT_STATN_CONTROL);
+               cfg |= RPMX_RSFEC_RX_CAPTURE | BIT(lmac_id);
+               rpm_write(rpm, 0, RPMX_MTI_STAT_STATN_CONTROL, cfg);
+
+               val_lo = rpm_read(rpm, 0,
+                                 RPMX_MTI_RSFEC_STAT_COUNTER_CAPTURE_2);
+               val_hi = rpm_read(rpm, 0, RPMX_MTI_STAT_DATA_HI_CDC);
+               rsp->fec_corr_blks = (val_hi << 32 | val_lo);
+
+               val_lo = rpm_read(rpm, 0,
+                                 RPMX_MTI_RSFEC_STAT_COUNTER_CAPTURE_3);
+               val_hi = rpm_read(rpm, 0, RPMX_MTI_STAT_DATA_HI_CDC);
+               rsp->fec_uncorr_blks = (val_hi << 32 | val_lo);
+       }
+
+       return 0;
+}
index fc20a35bd8f91a5a9d12ec6caa9e95c36136709a..22147b4c21370720559837d8f5c1e9b784e883e1 100644 (file)
@@ -25,7 +25,6 @@
 #define RPMX_CMRX_SW_INT_ENA_W1S        0x198
 #define RPMX_CMRX_LINK_CFG             0x1070
 #define RPMX_MTI_PCS100X_CONTROL1       0x20000
-#define RPMX_MTI_LPCSX_CONTROL1         0x30000
 #define RPMX_MTI_PCS_LBK                BIT_ULL(14)
 #define RPMX_MTI_LPCSX_CONTROL(id)     (0x30000 | ((id) * 0x100))
 
 #define RPMX_TS_BINARY_MODE                            BIT_ULL(11)
 #define RPMX_CONST1                                    0x2008
 
+/* FEC stats */
+#define RPMX_MTI_STAT_STATN_CONTROL                    0x10018
+#define RPMX_MTI_STAT_DATA_HI_CDC                      0x10038
+#define RPMX_RSFEC_RX_CAPTURE                          BIT_ULL(27)
+#define RPMX_MTI_RSFEC_STAT_COUNTER_CAPTURE_2          0x40050
+#define RPMX_MTI_RSFEC_STAT_COUNTER_CAPTURE_3          0x40058
+#define RPMX_MTI_FCFECX_VL0_CCW_LO                     0x38618
+#define RPMX_MTI_FCFECX_VL0_NCCW_LO                    0x38620
+#define RPMX_MTI_FCFECX_VL1_CCW_LO                     0x38628
+#define RPMX_MTI_FCFECX_VL1_NCCW_LO                    0x38630
+#define RPMX_MTI_FCFECX_CW_HI                          0x38638
+
 /* CN10KB CSR Declaration */
 #define  RPM2_CMRX_SW_INT                              0x1b0
 #define  RPM2_CMRX_SW_INT_ENA_W1S                      0x1b8
@@ -119,4 +130,5 @@ int rpm_lmac_get_pfc_frm_cfg(void *rpmd, int lmac_id, u8 *tx_pause,
                             u8 *rx_pause);
 int rpm2_get_nr_lmacs(void *rpmd);
 bool is_dev_rpm2(void *rpmd);
+int rpm_get_fec_stats(void *cgxd, int lmac_id, struct cgx_fec_stats_rsp *rsp);
 #endif /* RPM_H */
index 53580e0381c91816f4531c3f5829c47a691128b6..438b212fb54a7e2318c998811c21f501ec5262b4 100644 (file)
@@ -579,6 +579,7 @@ int rvu_mbox_handler_cgx_fec_stats(struct rvu *rvu,
                                   struct cgx_fec_stats_rsp *rsp)
 {
        int pf = rvu_get_pf(req->hdr.pcifunc);
+       struct mac_ops *mac_ops;
        u8 cgx_idx, lmac;
        void *cgxd;
 
@@ -587,7 +588,8 @@ int rvu_mbox_handler_cgx_fec_stats(struct rvu *rvu,
        rvu_get_cgx_lmac_id(rvu->pf2cgxlmac_map[pf], &cgx_idx, &lmac);
 
        cgxd = rvu_cgx_pdata(cgx_idx, rvu);
-       return cgx_get_fec_stats(cgxd, lmac, rsp);
+       mac_ops = get_mac_ops(cgxd);
+       return  mac_ops->get_fec_stats(cgxd, lmac, rsp);
 }
 
 int rvu_mbox_handler_cgx_mac_addr_set(struct rvu *rvu,