Skip to content

Commit 1222d15

Browse files
jpirkodavem330
authored andcommitted
mlxsw: spectrum: Expose counters for various packet sizes
Expose counters ASIC has in the group of RFC 2819 counters that count number of packets within specific size range. Signed-off-by: Jiri Pirko <[email protected]> Signed-off-by: Ido Schimmel <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent ac13d6d commit 1222d15

File tree

2 files changed

+124
-1
lines changed

2 files changed

+124
-1
lines changed

drivers/net/ethernet/mellanox/mlxsw/reg.h

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3365,6 +3365,7 @@ MLXSW_ITEM32(reg, ppcnt, pnat, 0x00, 14, 2);
33653365

33663366
enum mlxsw_reg_ppcnt_grp {
33673367
MLXSW_REG_PPCNT_IEEE_8023_CNT = 0x0,
3368+
MLXSW_REG_PPCNT_RFC_2819_CNT = 0x2,
33683369
MLXSW_REG_PPCNT_EXT_CNT = 0x5,
33693370
MLXSW_REG_PPCNT_PRIO_CNT = 0x10,
33703371
MLXSW_REG_PPCNT_TC_CNT = 0x11,
@@ -3523,6 +3524,68 @@ MLXSW_ITEM64(reg, ppcnt, a_pause_mac_ctrl_frames_received,
35233524
MLXSW_ITEM64(reg, ppcnt, a_pause_mac_ctrl_frames_transmitted,
35243525
MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x90, 0, 64);
35253526

3527+
/* Ethernet RFC 2819 Counter Group */
3528+
3529+
/* reg_ppcnt_ether_stats_pkts64octets
3530+
* Access: RO
3531+
*/
3532+
MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts64octets,
3533+
MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x58, 0, 64);
3534+
3535+
/* reg_ppcnt_ether_stats_pkts65to127octets
3536+
* Access: RO
3537+
*/
3538+
MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts65to127octets,
3539+
MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x60, 0, 64);
3540+
3541+
/* reg_ppcnt_ether_stats_pkts128to255octets
3542+
* Access: RO
3543+
*/
3544+
MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts128to255octets,
3545+
MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x68, 0, 64);
3546+
3547+
/* reg_ppcnt_ether_stats_pkts256to511octets
3548+
* Access: RO
3549+
*/
3550+
MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts256to511octets,
3551+
MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x70, 0, 64);
3552+
3553+
/* reg_ppcnt_ether_stats_pkts512to1023octets
3554+
* Access: RO
3555+
*/
3556+
MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts512to1023octets,
3557+
MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x78, 0, 64);
3558+
3559+
/* reg_ppcnt_ether_stats_pkts1024to1518octets
3560+
* Access: RO
3561+
*/
3562+
MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts1024to1518octets,
3563+
MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x80, 0, 64);
3564+
3565+
/* reg_ppcnt_ether_stats_pkts1519to2047octets
3566+
* Access: RO
3567+
*/
3568+
MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts1519to2047octets,
3569+
MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x88, 0, 64);
3570+
3571+
/* reg_ppcnt_ether_stats_pkts2048to4095octets
3572+
* Access: RO
3573+
*/
3574+
MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts2048to4095octets,
3575+
MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x90, 0, 64);
3576+
3577+
/* reg_ppcnt_ether_stats_pkts4096to8191octets
3578+
* Access: RO
3579+
*/
3580+
MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts4096to8191octets,
3581+
MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x98, 0, 64);
3582+
3583+
/* reg_ppcnt_ether_stats_pkts8192to10239octets
3584+
* Access: RO
3585+
*/
3586+
MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts8192to10239octets,
3587+
MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0xA0, 0, 64);
3588+
35263589
/* Ethernet Extended Counter Group Counters */
35273590

35283591
/* reg_ppcnt_ecn_marked

drivers/net/ethernet/mellanox/mlxsw/spectrum.c

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1888,6 +1888,52 @@ static struct mlxsw_sp_port_hw_stats mlxsw_sp_port_hw_stats[] = {
18881888

18891889
#define MLXSW_SP_PORT_HW_STATS_LEN ARRAY_SIZE(mlxsw_sp_port_hw_stats)
18901890

1891+
static struct mlxsw_sp_port_hw_stats mlxsw_sp_port_hw_rfc_2819_stats[] = {
1892+
{
1893+
.str = "ether_pkts64octets",
1894+
.getter = mlxsw_reg_ppcnt_ether_stats_pkts64octets_get,
1895+
},
1896+
{
1897+
.str = "ether_pkts65to127octets",
1898+
.getter = mlxsw_reg_ppcnt_ether_stats_pkts65to127octets_get,
1899+
},
1900+
{
1901+
.str = "ether_pkts128to255octets",
1902+
.getter = mlxsw_reg_ppcnt_ether_stats_pkts128to255octets_get,
1903+
},
1904+
{
1905+
.str = "ether_pkts256to511octets",
1906+
.getter = mlxsw_reg_ppcnt_ether_stats_pkts256to511octets_get,
1907+
},
1908+
{
1909+
.str = "ether_pkts512to1023octets",
1910+
.getter = mlxsw_reg_ppcnt_ether_stats_pkts512to1023octets_get,
1911+
},
1912+
{
1913+
.str = "ether_pkts1024to1518octets",
1914+
.getter = mlxsw_reg_ppcnt_ether_stats_pkts1024to1518octets_get,
1915+
},
1916+
{
1917+
.str = "ether_pkts1519to2047octets",
1918+
.getter = mlxsw_reg_ppcnt_ether_stats_pkts1519to2047octets_get,
1919+
},
1920+
{
1921+
.str = "ether_pkts2048to4095octets",
1922+
.getter = mlxsw_reg_ppcnt_ether_stats_pkts2048to4095octets_get,
1923+
},
1924+
{
1925+
.str = "ether_pkts4096to8191octets",
1926+
.getter = mlxsw_reg_ppcnt_ether_stats_pkts4096to8191octets_get,
1927+
},
1928+
{
1929+
.str = "ether_pkts8192to10239octets",
1930+
.getter = mlxsw_reg_ppcnt_ether_stats_pkts8192to10239octets_get,
1931+
},
1932+
};
1933+
1934+
#define MLXSW_SP_PORT_HW_RFC_2819_STATS_LEN \
1935+
ARRAY_SIZE(mlxsw_sp_port_hw_rfc_2819_stats)
1936+
18911937
static struct mlxsw_sp_port_hw_stats mlxsw_sp_port_hw_prio_stats[] = {
18921938
{
18931939
.str = "rx_octets_prio",
@@ -1979,6 +2025,11 @@ static void mlxsw_sp_port_get_strings(struct net_device *dev,
19792025
ETH_GSTRING_LEN);
19802026
p += ETH_GSTRING_LEN;
19812027
}
2028+
for (i = 0; i < MLXSW_SP_PORT_HW_RFC_2819_STATS_LEN; i++) {
2029+
memcpy(p, mlxsw_sp_port_hw_rfc_2819_stats[i].str,
2030+
ETH_GSTRING_LEN);
2031+
p += ETH_GSTRING_LEN;
2032+
}
19822033

19832034
for (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++)
19842035
mlxsw_sp_port_get_prio_strings(&p, i);
@@ -2018,10 +2069,14 @@ mlxsw_sp_get_hw_stats_by_group(struct mlxsw_sp_port_hw_stats **p_hw_stats,
20182069
int *p_len, enum mlxsw_reg_ppcnt_grp grp)
20192070
{
20202071
switch (grp) {
2021-
case MLXSW_REG_PPCNT_IEEE_8023_CNT:
2072+
case MLXSW_REG_PPCNT_IEEE_8023_CNT:
20222073
*p_hw_stats = mlxsw_sp_port_hw_stats;
20232074
*p_len = MLXSW_SP_PORT_HW_STATS_LEN;
20242075
break;
2076+
case MLXSW_REG_PPCNT_RFC_2819_CNT:
2077+
*p_hw_stats = mlxsw_sp_port_hw_rfc_2819_stats;
2078+
*p_len = MLXSW_SP_PORT_HW_RFC_2819_STATS_LEN;
2079+
break;
20252080
case MLXSW_REG_PPCNT_PRIO_CNT:
20262081
*p_hw_stats = mlxsw_sp_port_hw_prio_stats;
20272082
*p_len = MLXSW_SP_PORT_HW_PRIO_STATS_LEN;
@@ -2071,6 +2126,11 @@ static void mlxsw_sp_port_get_stats(struct net_device *dev,
20712126
data, data_index);
20722127
data_index = MLXSW_SP_PORT_HW_STATS_LEN;
20732128

2129+
/* RFC 2819 Counters */
2130+
__mlxsw_sp_port_get_stats(dev, MLXSW_REG_PPCNT_RFC_2819_CNT, 0,
2131+
data, data_index);
2132+
data_index += MLXSW_SP_PORT_HW_RFC_2819_STATS_LEN;
2133+
20742134
/* Per-Priority Counters */
20752135
for (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++) {
20762136
__mlxsw_sp_port_get_stats(dev, MLXSW_REG_PPCNT_PRIO_CNT, i,

0 commit comments

Comments
 (0)