Commit 4c6ce450 authored by Sai Krishna's avatar Sai Krishna Committed by David S. Miller
Browse files

octeontx2-pf: Reset MAC stats during probe



Reset CGX/RPM MAC HW statistics at the time of driver probe()

Signed-off-by: default avatarHariprasad Kelam <hkelam@marvell.com>
Signed-off-by: default avatarSai Krishna <saikrishnag@marvell.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 9748dbc9
Loading
Loading
Loading
Loading
+27 −0
Original line number Diff line number Diff line
@@ -24,6 +24,8 @@
#define DRV_NAME	"Marvell-CGX/RPM"
#define DRV_STRING      "Marvell CGX/RPM Driver"

#define CGX_RX_STAT_GLOBAL_INDEX	9

static LIST_HEAD(cgx_list);

/* Convert firmware speed encoding to user format(Mbps) */
@@ -701,6 +703,30 @@ u64 cgx_features_get(void *cgxd)
	return ((struct cgx *)cgxd)->hw_features;
}

int cgx_stats_reset(void *cgxd, int lmac_id)
{
	struct cgx *cgx = cgxd;
	int stat_id;

	if (!is_lmac_valid(cgx, lmac_id))
		return -ENODEV;

	for (stat_id = 0 ; stat_id < CGX_RX_STATS_COUNT; stat_id++) {
		if (stat_id >= CGX_RX_STAT_GLOBAL_INDEX)
		/* pass lmac as 0 for CGX_CMR_RX_STAT9-12 */
			cgx_write(cgx, 0,
				  (CGXX_CMRX_RX_STAT0 + (stat_id * 8)), 0);
		else
			cgx_write(cgx, lmac_id,
				  (CGXX_CMRX_RX_STAT0 + (stat_id * 8)), 0);
	}

	for (stat_id = 0 ; stat_id < CGX_TX_STATS_COUNT; stat_id++)
		cgx_write(cgx, lmac_id, CGXX_CMRX_TX_STAT0 + (stat_id * 8), 0);

	return 0;
}

static int cgx_set_fec_stats_count(struct cgx_link_user_info *linfo)
{
	if (!linfo->fec)
@@ -1788,6 +1814,7 @@ 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,
};

static int cgx_probe(struct pci_dev *pdev, const struct pci_device_id *id)
+1 −0
Original line number Diff line number Diff line
@@ -141,6 +141,7 @@ int cgx_lmac_evh_register(struct cgx_event_cb *cb, void *cgxd, int lmac_id);
int cgx_lmac_evh_unregister(void *cgxd, int lmac_id);
int cgx_get_tx_stats(void *cgxd, int lmac_id, int idx, u64 *tx_stat);
int cgx_get_rx_stats(void *cgxd, int lmac_id, int idx, u64 *rx_stat);
int cgx_stats_reset(void *cgxd, int lmac_id);
int cgx_lmac_rx_tx_enable(void *cgxd, int lmac_id, bool enable);
int cgx_lmac_tx_enable(void *cgxd, int lmac_id, bool enable);
int cgx_lmac_addr_set(u8 cgx_id, u8 lmac_id, u8 *mac_addr);
+1 −0
Original line number Diff line number Diff line
@@ -132,6 +132,7 @@ struct mac_ops {
	/* FEC stats */
	int			(*get_fec_stats)(void *cgxd, int lmac_id,
						 struct cgx_fec_stats_rsp *rsp);
	int			(*mac_stats_reset)(void *cgxd, int lmac_id);
};

struct cgx {
+1 −0
Original line number Diff line number Diff line
@@ -174,6 +174,7 @@ M(CGX_FEC_STATS, 0x217, cgx_fec_stats, msg_req, cgx_fec_stats_rsp) \
M(CGX_SET_LINK_MODE,	0x218, cgx_set_link_mode, cgx_set_link_mode_req,\
			       cgx_set_link_mode_rsp)	\
M(CGX_GET_PHY_FEC_STATS, 0x219, cgx_get_phy_fec_stats, msg_req, msg_rsp) \
M(CGX_STATS_RST,	0x21A, cgx_stats_rst, msg_req, msg_rsp)		\
M(CGX_FEATURES_GET,	0x21B, cgx_features_get, msg_req,		\
			       cgx_features_info_msg)			\
M(RPM_STATS,		0x21C, rpm_stats, msg_req, rpm_stats_rsp)	\
+17 −0
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ static struct mac_ops rpm_mac_ops = {
	.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,
};

static struct mac_ops		rpm2_mac_ops   = {
@@ -70,6 +71,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,
	.mac_stats_reset	    =	rpm_stats_reset,
};

bool is_dev_rpm2(void *rpmd)
@@ -443,6 +445,21 @@ int rpm_get_tx_stats(void *rpmd, int lmac_id, int idx, u64 *tx_stat)
	return 0;
}

int rpm_stats_reset(void *rpmd, int lmac_id)
{
	rpm_t *rpm = rpmd;
	u64 cfg;

	if (!is_lmac_valid(rpm, lmac_id))
		return -ENODEV;

	cfg = rpm_read(rpm, 0, RPMX_MTI_STAT_STATN_CONTROL);
	cfg |= RPMX_CMD_CLEAR_TX | RPMX_CMD_CLEAR_RX | BIT_ULL(lmac_id);
	rpm_write(rpm, 0, RPMX_MTI_STAT_STATN_CONTROL, cfg);

	return 0;
}

u8 rpm_get_lmac_type(void *rpmd, int lmac_id)
{
	rpm_t *rpm = rpmd;
Loading