Skip to content

Commit bd74d4e

Browse files
Felix Manlunasdavem330
authored andcommitted
octeontx2-af: Add new CGX_CMD to get PHY FEC statistics
This patch adds support to fetch fec stats from PHY. The stats are put in the shared data struct fwdata. A PHY driver indicates that it has FEC stats by setting the flag fwdata.phy.misc.has_fec_stats Besides CGX_CMD_GET_PHY_FEC_STATS, also add CGX_CMD_PRBS and CGX_CMD_DISPLAY_EYE to enum cgx_cmd_id so that Linux's enum list is in sync with firmware's enum list. Signed-off-by: Felix Manlunas <[email protected]> Signed-off-by: Christina Jacob <[email protected]> Signed-off-by: Sunil Goutham <[email protected]> Signed-off-by: Hariprasad Kelam <[email protected]> Reviewed-by: Jesse Brandeburg <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 84c4f9c commit bd74d4e

File tree

6 files changed

+97
-0
lines changed

6 files changed

+97
-0
lines changed

drivers/net/ethernet/marvell/octeontx2/af/cgx.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -861,6 +861,18 @@ int cgx_set_fec(u64 fec, int cgx_id, int lmac_id)
861861
return cgx->lmac_idmap[lmac_id]->link_info.fec;
862862
}
863863

864+
int cgx_get_phy_fec_stats(void *cgxd, int lmac_id)
865+
{
866+
struct cgx *cgx = cgxd;
867+
u64 req = 0, resp;
868+
869+
if (!cgx)
870+
return -ENODEV;
871+
872+
req = FIELD_SET(CMDREG_ID, CGX_CMD_GET_PHY_FEC_STATS, req);
873+
return cgx_fwi_cmd_generic(req, &resp, cgx, lmac_id);
874+
}
875+
864876
static int cgx_fwi_link_change(struct cgx *cgx, int lmac_id, bool enable)
865877
{
866878
u64 req = 0;

drivers/net/ethernet/marvell/octeontx2/af/cgx.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,5 +154,6 @@ void cgx_lmac_ptp_config(void *cgxd, int lmac_id, bool enable);
154154
u8 cgx_lmac_get_p2x(int cgx_id, int lmac_id);
155155
int cgx_set_fec(u64 fec, int cgx_id, int lmac_id);
156156
int cgx_get_fec_stats(void *cgxd, int lmac_id, struct cgx_fec_stats_rsp *rsp);
157+
int cgx_get_phy_fec_stats(void *cgxd, int lmac_id);
157158

158159
#endif /* CGX_H */

drivers/net/ethernet/marvell/octeontx2/af/cgx_fw_if.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@ enum cgx_cmd_id {
8989
CGX_CMD_SET_AN,
9090
CGX_CMD_GET_ADV_LINK_MODES,
9191
CGX_CMD_GET_ADV_FEC,
92+
CGX_CMD_GET_PHY_MOD_TYPE, /* line-side modulation type: NRZ or PAM4 */
93+
CGX_CMD_SET_PHY_MOD_TYPE,
94+
CGX_CMD_PRBS,
95+
CGX_CMD_DISPLAY_EYE,
96+
CGX_CMD_GET_PHY_FEC_STATS,
9297
};
9398

9499
/* async event ids */

drivers/net/ethernet/marvell/octeontx2/af/mbox.h

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,8 @@ M(CGX_CFG_PAUSE_FRM, 0x20E, cgx_cfg_pause_frm, cgx_pause_frm_cfg, \
151151
cgx_pause_frm_cfg) \
152152
M(CGX_FEC_SET, 0x210, cgx_set_fec_param, fec_mode, fec_mode) \
153153
M(CGX_FEC_STATS, 0x211, cgx_fec_stats, msg_req, cgx_fec_stats_rsp) \
154+
M(CGX_GET_PHY_FEC_STATS, 0x212, cgx_get_phy_fec_stats, msg_req, msg_rsp) \
155+
M(CGX_FW_DATA_GET, 0x213, cgx_get_aux_link_info, msg_req, cgx_fw_data) \
154156
/* NPA mbox IDs (range 0x400 - 0x5FF) */ \
155157
/* NPA mbox IDs (range 0x400 - 0x5FF) */ \
156158
M(NPA_LF_ALLOC, 0x400, npa_lf_alloc, \
@@ -413,6 +415,47 @@ struct fec_mode {
413415
int fec;
414416
};
415417

418+
struct sfp_eeprom_s {
419+
#define SFP_EEPROM_SIZE 256
420+
u16 sff_id;
421+
u8 buf[SFP_EEPROM_SIZE];
422+
u64 reserved;
423+
};
424+
425+
struct phy_s {
426+
struct {
427+
u64 can_change_mod_type:1;
428+
u64 mod_type:1;
429+
u64 has_fec_stats:1;
430+
} misc;
431+
struct fec_stats_s {
432+
u32 rsfec_corr_cws;
433+
u32 rsfec_uncorr_cws;
434+
u32 brfec_corr_blks;
435+
u32 brfec_uncorr_blks;
436+
} fec_stats;
437+
};
438+
439+
struct cgx_lmac_fwdata_s {
440+
u16 rw_valid;
441+
u64 supported_fec;
442+
u64 supported_an;
443+
u64 supported_link_modes;
444+
/* only applicable if AN is supported */
445+
u64 advertised_fec;
446+
u64 advertised_link_modes;
447+
/* Only applicable if SFP/QSFP slot is present */
448+
struct sfp_eeprom_s sfp_eeprom;
449+
struct phy_s phy;
450+
#define LMAC_FWDATA_RESERVED_MEM 1021
451+
u64 reserved[LMAC_FWDATA_RESERVED_MEM];
452+
};
453+
454+
struct cgx_fw_data {
455+
struct mbox_msghdr hdr;
456+
struct cgx_lmac_fwdata_s fwdata;
457+
};
458+
416459
/* NPA mbox message formats */
417460

418461
/* NPA mailbox error codes

drivers/net/ethernet/marvell/octeontx2/af/rvu.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,10 @@ struct rvu_fwdata {
357357
u64 msixtr_base;
358358
#define FWDATA_RESERVED_MEM 1023
359359
u64 reserved[FWDATA_RESERVED_MEM];
360+
#define CGX_MAX 5
361+
#define CGX_LMACS_MAX 4
362+
struct cgx_lmac_fwdata_s cgx_fw_data[CGX_MAX][CGX_LMACS_MAX];
363+
/* Do not add new fields below this line */
360364
};
361365

362366
struct ptp;

drivers/net/ethernet/marvell/octeontx2/af/rvu_cgx.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -692,6 +692,19 @@ int rvu_mbox_handler_cgx_cfg_pause_frm(struct rvu *rvu,
692692
return 0;
693693
}
694694

695+
int rvu_mbox_handler_cgx_get_phy_fec_stats(struct rvu *rvu, struct msg_req *req,
696+
struct msg_rsp *rsp)
697+
{
698+
int pf = rvu_get_pf(req->hdr.pcifunc);
699+
u8 cgx_id, lmac_id;
700+
701+
if (!is_pf_cgxmapped(rvu, pf))
702+
return -EPERM;
703+
704+
rvu_get_cgx_lmac_id(rvu->pf2cgxlmac_map[pf], &cgx_id, &lmac_id);
705+
return cgx_get_phy_fec_stats(rvu_cgx_pdata(cgx_id, rvu), lmac_id);
706+
}
707+
695708
/* Finds cumulative status of NIX rx/tx counters from LF of a PF and those
696709
* from its VFs as well. ie. NIX rx/tx counters at the CGX port level
697710
*/
@@ -800,3 +813,22 @@ int rvu_mbox_handler_cgx_set_fec_param(struct rvu *rvu,
800813
rsp->fec = cgx_set_fec(req->fec, cgx_id, lmac_id);
801814
return 0;
802815
}
816+
817+
int rvu_mbox_handler_cgx_get_aux_link_info(struct rvu *rvu, struct msg_req *req,
818+
struct cgx_fw_data *rsp)
819+
{
820+
int pf = rvu_get_pf(req->hdr.pcifunc);
821+
u8 cgx_id, lmac_id;
822+
823+
if (!rvu->fwdata)
824+
return -ENXIO;
825+
826+
if (!is_pf_cgxmapped(rvu, pf))
827+
return -EPERM;
828+
829+
rvu_get_cgx_lmac_id(rvu->pf2cgxlmac_map[pf], &cgx_id, &lmac_id);
830+
831+
memcpy(&rsp->fwdata, &rvu->fwdata->cgx_fw_data[cgx_id][lmac_id],
832+
sizeof(struct cgx_lmac_fwdata_s));
833+
return 0;
834+
}

0 commit comments

Comments
 (0)