Commit 1222d15a authored by Jiri Pirko's avatar Jiri Pirko Committed by David S. Miller

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: default avatarJiri Pirko <jiri@mellanox.com>
Signed-off-by: default avatarIdo Schimmel <idosch@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent ac13d6d8
...@@ -3365,6 +3365,7 @@ MLXSW_ITEM32(reg, ppcnt, pnat, 0x00, 14, 2); ...@@ -3365,6 +3365,7 @@ MLXSW_ITEM32(reg, ppcnt, pnat, 0x00, 14, 2);
enum mlxsw_reg_ppcnt_grp { enum mlxsw_reg_ppcnt_grp {
MLXSW_REG_PPCNT_IEEE_8023_CNT = 0x0, MLXSW_REG_PPCNT_IEEE_8023_CNT = 0x0,
MLXSW_REG_PPCNT_RFC_2819_CNT = 0x2,
MLXSW_REG_PPCNT_EXT_CNT = 0x5, MLXSW_REG_PPCNT_EXT_CNT = 0x5,
MLXSW_REG_PPCNT_PRIO_CNT = 0x10, MLXSW_REG_PPCNT_PRIO_CNT = 0x10,
MLXSW_REG_PPCNT_TC_CNT = 0x11, MLXSW_REG_PPCNT_TC_CNT = 0x11,
...@@ -3523,6 +3524,68 @@ MLXSW_ITEM64(reg, ppcnt, a_pause_mac_ctrl_frames_received, ...@@ -3523,6 +3524,68 @@ MLXSW_ITEM64(reg, ppcnt, a_pause_mac_ctrl_frames_received,
MLXSW_ITEM64(reg, ppcnt, a_pause_mac_ctrl_frames_transmitted, MLXSW_ITEM64(reg, ppcnt, a_pause_mac_ctrl_frames_transmitted,
MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x90, 0, 64); MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x90, 0, 64);
/* Ethernet RFC 2819 Counter Group */
/* reg_ppcnt_ether_stats_pkts64octets
* Access: RO
*/
MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts64octets,
MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x58, 0, 64);
/* reg_ppcnt_ether_stats_pkts65to127octets
* Access: RO
*/
MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts65to127octets,
MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x60, 0, 64);
/* reg_ppcnt_ether_stats_pkts128to255octets
* Access: RO
*/
MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts128to255octets,
MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x68, 0, 64);
/* reg_ppcnt_ether_stats_pkts256to511octets
* Access: RO
*/
MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts256to511octets,
MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x70, 0, 64);
/* reg_ppcnt_ether_stats_pkts512to1023octets
* Access: RO
*/
MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts512to1023octets,
MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x78, 0, 64);
/* reg_ppcnt_ether_stats_pkts1024to1518octets
* Access: RO
*/
MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts1024to1518octets,
MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x80, 0, 64);
/* reg_ppcnt_ether_stats_pkts1519to2047octets
* Access: RO
*/
MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts1519to2047octets,
MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x88, 0, 64);
/* reg_ppcnt_ether_stats_pkts2048to4095octets
* Access: RO
*/
MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts2048to4095octets,
MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x90, 0, 64);
/* reg_ppcnt_ether_stats_pkts4096to8191octets
* Access: RO
*/
MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts4096to8191octets,
MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x98, 0, 64);
/* reg_ppcnt_ether_stats_pkts8192to10239octets
* Access: RO
*/
MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts8192to10239octets,
MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0xA0, 0, 64);
/* Ethernet Extended Counter Group Counters */ /* Ethernet Extended Counter Group Counters */
/* reg_ppcnt_ecn_marked /* reg_ppcnt_ecn_marked
......
...@@ -1888,6 +1888,52 @@ static struct mlxsw_sp_port_hw_stats mlxsw_sp_port_hw_stats[] = { ...@@ -1888,6 +1888,52 @@ static struct mlxsw_sp_port_hw_stats mlxsw_sp_port_hw_stats[] = {
#define MLXSW_SP_PORT_HW_STATS_LEN ARRAY_SIZE(mlxsw_sp_port_hw_stats) #define MLXSW_SP_PORT_HW_STATS_LEN ARRAY_SIZE(mlxsw_sp_port_hw_stats)
static struct mlxsw_sp_port_hw_stats mlxsw_sp_port_hw_rfc_2819_stats[] = {
{
.str = "ether_pkts64octets",
.getter = mlxsw_reg_ppcnt_ether_stats_pkts64octets_get,
},
{
.str = "ether_pkts65to127octets",
.getter = mlxsw_reg_ppcnt_ether_stats_pkts65to127octets_get,
},
{
.str = "ether_pkts128to255octets",
.getter = mlxsw_reg_ppcnt_ether_stats_pkts128to255octets_get,
},
{
.str = "ether_pkts256to511octets",
.getter = mlxsw_reg_ppcnt_ether_stats_pkts256to511octets_get,
},
{
.str = "ether_pkts512to1023octets",
.getter = mlxsw_reg_ppcnt_ether_stats_pkts512to1023octets_get,
},
{
.str = "ether_pkts1024to1518octets",
.getter = mlxsw_reg_ppcnt_ether_stats_pkts1024to1518octets_get,
},
{
.str = "ether_pkts1519to2047octets",
.getter = mlxsw_reg_ppcnt_ether_stats_pkts1519to2047octets_get,
},
{
.str = "ether_pkts2048to4095octets",
.getter = mlxsw_reg_ppcnt_ether_stats_pkts2048to4095octets_get,
},
{
.str = "ether_pkts4096to8191octets",
.getter = mlxsw_reg_ppcnt_ether_stats_pkts4096to8191octets_get,
},
{
.str = "ether_pkts8192to10239octets",
.getter = mlxsw_reg_ppcnt_ether_stats_pkts8192to10239octets_get,
},
};
#define MLXSW_SP_PORT_HW_RFC_2819_STATS_LEN \
ARRAY_SIZE(mlxsw_sp_port_hw_rfc_2819_stats)
static struct mlxsw_sp_port_hw_stats mlxsw_sp_port_hw_prio_stats[] = { static struct mlxsw_sp_port_hw_stats mlxsw_sp_port_hw_prio_stats[] = {
{ {
.str = "rx_octets_prio", .str = "rx_octets_prio",
...@@ -1979,6 +2025,11 @@ static void mlxsw_sp_port_get_strings(struct net_device *dev, ...@@ -1979,6 +2025,11 @@ static void mlxsw_sp_port_get_strings(struct net_device *dev,
ETH_GSTRING_LEN); ETH_GSTRING_LEN);
p += ETH_GSTRING_LEN; p += ETH_GSTRING_LEN;
} }
for (i = 0; i < MLXSW_SP_PORT_HW_RFC_2819_STATS_LEN; i++) {
memcpy(p, mlxsw_sp_port_hw_rfc_2819_stats[i].str,
ETH_GSTRING_LEN);
p += ETH_GSTRING_LEN;
}
for (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++) for (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++)
mlxsw_sp_port_get_prio_strings(&p, i); 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, ...@@ -2018,10 +2069,14 @@ mlxsw_sp_get_hw_stats_by_group(struct mlxsw_sp_port_hw_stats **p_hw_stats,
int *p_len, enum mlxsw_reg_ppcnt_grp grp) int *p_len, enum mlxsw_reg_ppcnt_grp grp)
{ {
switch (grp) { switch (grp) {
case MLXSW_REG_PPCNT_IEEE_8023_CNT: case MLXSW_REG_PPCNT_IEEE_8023_CNT:
*p_hw_stats = mlxsw_sp_port_hw_stats; *p_hw_stats = mlxsw_sp_port_hw_stats;
*p_len = MLXSW_SP_PORT_HW_STATS_LEN; *p_len = MLXSW_SP_PORT_HW_STATS_LEN;
break; break;
case MLXSW_REG_PPCNT_RFC_2819_CNT:
*p_hw_stats = mlxsw_sp_port_hw_rfc_2819_stats;
*p_len = MLXSW_SP_PORT_HW_RFC_2819_STATS_LEN;
break;
case MLXSW_REG_PPCNT_PRIO_CNT: case MLXSW_REG_PPCNT_PRIO_CNT:
*p_hw_stats = mlxsw_sp_port_hw_prio_stats; *p_hw_stats = mlxsw_sp_port_hw_prio_stats;
*p_len = MLXSW_SP_PORT_HW_PRIO_STATS_LEN; *p_len = MLXSW_SP_PORT_HW_PRIO_STATS_LEN;
...@@ -2071,6 +2126,11 @@ static void mlxsw_sp_port_get_stats(struct net_device *dev, ...@@ -2071,6 +2126,11 @@ static void mlxsw_sp_port_get_stats(struct net_device *dev,
data, data_index); data, data_index);
data_index = MLXSW_SP_PORT_HW_STATS_LEN; data_index = MLXSW_SP_PORT_HW_STATS_LEN;
/* RFC 2819 Counters */
__mlxsw_sp_port_get_stats(dev, MLXSW_REG_PPCNT_RFC_2819_CNT, 0,
data, data_index);
data_index += MLXSW_SP_PORT_HW_RFC_2819_STATS_LEN;
/* Per-Priority Counters */ /* Per-Priority Counters */
for (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++) { for (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++) {
__mlxsw_sp_port_get_stats(dev, MLXSW_REG_PPCNT_PRIO_CNT, i, __mlxsw_sp_port_get_stats(dev, MLXSW_REG_PPCNT_PRIO_CNT, i,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment