common/cnxk: support reading BPHY CGX/RPM FEC
authorTomasz Duszynski <tduszynski@marvell.com>
Thu, 15 Jul 2021 13:53:27 +0000 (08:53 -0500)
committerThomas Monjalon <thomas@monjalon.net>
Thu, 22 Jul 2021 20:08:44 +0000 (22:08 +0200)
Before setting FEC for specific LMAC one needs to know which type is
actually supported because it generally differs between modes
LMAC operates in (SGMII, SFI, etc.).

Signed-off-by: Tomasz Duszynski <tduszynski@marvell.com>
drivers/common/cnxk/roc_bphy_cgx.c
drivers/common/cnxk/roc_bphy_cgx.h
drivers/common/cnxk/roc_bphy_cgx_priv.h
drivers/common/cnxk/version.map

index 056a3db..467b676 100644 (file)
@@ -395,3 +395,28 @@ roc_bphy_cgx_ptp_rx_disable(struct roc_bphy_cgx *roc_cgx, unsigned int lmac)
 {
        return roc_bphy_cgx_ptp_rx_ena_dis(roc_cgx, lmac, false);
 }
+
+int
+roc_bphy_cgx_fec_supported_get(struct roc_bphy_cgx *roc_cgx, unsigned int lmac,
+                              enum roc_bphy_cgx_eth_link_fec *fec)
+{
+       uint64_t scr1, scr0;
+       int ret;
+
+       if (!roc_cgx || !fec)
+               return -EINVAL;
+
+       if (!roc_bphy_cgx_lmac_exists(roc_cgx, lmac))
+               return -EINVAL;
+
+       scr1 = FIELD_PREP(SCR1_ETH_CMD_ID, ETH_CMD_GET_SUPPORTED_FEC);
+
+       ret = roc_bphy_cgx_intf_req(roc_cgx, lmac, scr1, &scr0);
+       if (ret)
+               return ret;
+
+       scr0 = FIELD_GET(SCR0_ETH_FEC_TYPES_S_FEC, scr0);
+       *fec = (enum roc_bphy_cgx_eth_link_fec)scr0;
+
+       return 0;
+}
index 49c35a1..9439f88 100644 (file)
@@ -115,6 +115,9 @@ __roc_api int roc_bphy_cgx_ptp_rx_enable(struct roc_bphy_cgx *roc_cgx,
                                         unsigned int lmac);
 __roc_api int roc_bphy_cgx_ptp_rx_disable(struct roc_bphy_cgx *roc_cgx,
                                          unsigned int lmac);
+__roc_api int roc_bphy_cgx_fec_supported_get(struct roc_bphy_cgx *roc_cgx,
+                                            unsigned int lmac,
+                                            enum roc_bphy_cgx_eth_link_fec *fec);
 
 
 #endif /* _ROC_BPHY_CGX_H_ */
index 71a277f..93aa43e 100644 (file)
@@ -66,6 +66,7 @@ enum eth_cmd_id {
        ETH_CMD_INTERNAL_LBK = 7,
        ETH_CMD_MODE_CHANGE = 11, /* hot plug support */
        ETH_CMD_INTF_SHUTDOWN = 12,
+       ETH_CMD_GET_SUPPORTED_FEC = 18,
        ETH_CMD_SET_PTP_MODE = 34,
 };
 
@@ -109,6 +110,9 @@ enum eth_cmd_own {
 #define SCR0_ETH_LNK_STS_S_LMAC_TYPE   GENMASK_ULL(35, 28)
 #define SCR0_ETH_LNK_STS_S_MODE               GENMASK_ULL(43, 36)
 
+/* struct eth_fec_types_s */
+#define SCR0_ETH_FEC_TYPES_S_FEC GENMASK_ULL(10, 9)
+
 /* scratchx(1) CSR used for non-secure SW->ATF communication
  * This CSR acts as a command register
  */
index 2a28087..6923116 100644 (file)
@@ -24,6 +24,7 @@ INTERNAL {
        roc_ae_fpm_put;
        roc_bphy_cgx_dev_fini;
        roc_bphy_cgx_dev_init;
+       roc_bphy_cgx_fec_supported_get;
        roc_bphy_cgx_get_linkinfo;
        roc_bphy_cgx_intlbk_disable;
        roc_bphy_cgx_intlbk_enable;