Commit bae4e109 authored by Shalom Toledo's avatar Shalom Toledo Committed by David S. Miller

mlxsw: spectrum: Expose discard counters via ethtool

Expose packets discard counters via ethtool to help with debugging.
Signed-off-by: default avatarShalom Toledo <shalomt@mellanox.com>
Reviewed-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 aa6daaca
...@@ -4235,8 +4235,11 @@ MLXSW_ITEM32(reg, ppcnt, pnat, 0x00, 14, 2); ...@@ -4235,8 +4235,11 @@ 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_2863_CNT = 0x1,
MLXSW_REG_PPCNT_RFC_2819_CNT = 0x2, MLXSW_REG_PPCNT_RFC_2819_CNT = 0x2,
MLXSW_REG_PPCNT_RFC_3635_CNT = 0x3,
MLXSW_REG_PPCNT_EXT_CNT = 0x5, MLXSW_REG_PPCNT_EXT_CNT = 0x5,
MLXSW_REG_PPCNT_DISCARD_CNT = 0x6,
MLXSW_REG_PPCNT_PRIO_CNT = 0x10, MLXSW_REG_PPCNT_PRIO_CNT = 0x10,
MLXSW_REG_PPCNT_TC_CNT = 0x11, MLXSW_REG_PPCNT_TC_CNT = 0x11,
MLXSW_REG_PPCNT_TC_CONG_TC = 0x13, MLXSW_REG_PPCNT_TC_CONG_TC = 0x13,
...@@ -4251,6 +4254,7 @@ enum mlxsw_reg_ppcnt_grp { ...@@ -4251,6 +4254,7 @@ enum mlxsw_reg_ppcnt_grp {
* 0x2: RFC 2819 Counters * 0x2: RFC 2819 Counters
* 0x3: RFC 3635 Counters * 0x3: RFC 3635 Counters
* 0x5: Ethernet Extended Counters * 0x5: Ethernet Extended Counters
* 0x6: Ethernet Discard Counters
* 0x8: Link Level Retransmission Counters * 0x8: Link Level Retransmission Counters
* 0x10: Per Priority Counters * 0x10: Per Priority Counters
* 0x11: Per Traffic Class Counters * 0x11: Per Traffic Class Counters
...@@ -4394,8 +4398,46 @@ MLXSW_ITEM64(reg, ppcnt, a_pause_mac_ctrl_frames_received, ...@@ -4394,8 +4398,46 @@ 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 2863 Counter Group */
/* reg_ppcnt_if_in_discards
* Access: RO
*/
MLXSW_ITEM64(reg, ppcnt, if_in_discards,
MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x10, 0, 64);
/* reg_ppcnt_if_out_discards
* Access: RO
*/
MLXSW_ITEM64(reg, ppcnt, if_out_discards,
MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x38, 0, 64);
/* reg_ppcnt_if_out_errors
* Access: RO
*/
MLXSW_ITEM64(reg, ppcnt, if_out_errors,
MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x40, 0, 64);
/* Ethernet RFC 2819 Counter Group */ /* Ethernet RFC 2819 Counter Group */
/* reg_ppcnt_ether_stats_undersize_pkts
* Access: RO
*/
MLXSW_ITEM64(reg, ppcnt, ether_stats_undersize_pkts,
MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x30, 0, 64);
/* reg_ppcnt_ether_stats_oversize_pkts
* Access: RO
*/
MLXSW_ITEM64(reg, ppcnt, ether_stats_oversize_pkts,
MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x38, 0, 64);
/* reg_ppcnt_ether_stats_fragments
* Access: RO
*/
MLXSW_ITEM64(reg, ppcnt, ether_stats_fragments,
MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x40, 0, 64);
/* reg_ppcnt_ether_stats_pkts64octets /* reg_ppcnt_ether_stats_pkts64octets
* Access: RO * Access: RO
*/ */
...@@ -4456,6 +4498,32 @@ MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts4096to8191octets, ...@@ -4456,6 +4498,32 @@ MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts4096to8191octets,
MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts8192to10239octets, MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts8192to10239octets,
MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0xA0, 0, 64); MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0xA0, 0, 64);
/* Ethernet RFC 3635 Counter Group */
/* reg_ppcnt_dot3stats_fcs_errors
* Access: RO
*/
MLXSW_ITEM64(reg, ppcnt, dot3stats_fcs_errors,
MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x08, 0, 64);
/* reg_ppcnt_dot3stats_symbol_errors
* Access: RO
*/
MLXSW_ITEM64(reg, ppcnt, dot3stats_symbol_errors,
MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x60, 0, 64);
/* reg_ppcnt_dot3control_in_unknown_opcodes
* Access: RO
*/
MLXSW_ITEM64(reg, ppcnt, dot3control_in_unknown_opcodes,
MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x68, 0, 64);
/* reg_ppcnt_dot3in_pause_frames
* Access: RO
*/
MLXSW_ITEM64(reg, ppcnt, dot3in_pause_frames,
MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x70, 0, 64);
/* Ethernet Extended Counter Group Counters */ /* Ethernet Extended Counter Group Counters */
/* reg_ppcnt_ecn_marked /* reg_ppcnt_ecn_marked
...@@ -4464,6 +4532,80 @@ MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts8192to10239octets, ...@@ -4464,6 +4532,80 @@ MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts8192to10239octets,
MLXSW_ITEM64(reg, ppcnt, ecn_marked, MLXSW_ITEM64(reg, ppcnt, ecn_marked,
MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x08, 0, 64); MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x08, 0, 64);
/* Ethernet Discard Counter Group Counters */
/* reg_ppcnt_ingress_general
* Access: RO
*/
MLXSW_ITEM64(reg, ppcnt, ingress_general,
MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x00, 0, 64);
/* reg_ppcnt_ingress_policy_engine
* Access: RO
*/
MLXSW_ITEM64(reg, ppcnt, ingress_policy_engine,
MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x08, 0, 64);
/* reg_ppcnt_ingress_vlan_membership
* Access: RO
*/
MLXSW_ITEM64(reg, ppcnt, ingress_vlan_membership,
MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x10, 0, 64);
/* reg_ppcnt_ingress_tag_frame_type
* Access: RO
*/
MLXSW_ITEM64(reg, ppcnt, ingress_tag_frame_type,
MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x18, 0, 64);
/* reg_ppcnt_egress_vlan_membership
* Access: RO
*/
MLXSW_ITEM64(reg, ppcnt, egress_vlan_membership,
MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x20, 0, 64);
/* reg_ppcnt_loopback_filter
* Access: RO
*/
MLXSW_ITEM64(reg, ppcnt, loopback_filter,
MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x28, 0, 64);
/* reg_ppcnt_egress_general
* Access: RO
*/
MLXSW_ITEM64(reg, ppcnt, egress_general,
MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x30, 0, 64);
/* reg_ppcnt_egress_hoq
* Access: RO
*/
MLXSW_ITEM64(reg, ppcnt, egress_hoq,
MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x40, 0, 64);
/* reg_ppcnt_egress_policy_engine
* Access: RO
*/
MLXSW_ITEM64(reg, ppcnt, egress_policy_engine,
MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x50, 0, 64);
/* reg_ppcnt_ingress_tx_link_down
* Access: RO
*/
MLXSW_ITEM64(reg, ppcnt, ingress_tx_link_down,
MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x58, 0, 64);
/* reg_ppcnt_egress_stp_filter
* Access: RO
*/
MLXSW_ITEM64(reg, ppcnt, egress_stp_filter,
MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x60, 0, 64);
/* reg_ppcnt_egress_sll
* Access: RO
*/
MLXSW_ITEM64(reg, ppcnt, egress_sll,
MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x70, 0, 64);
/* Ethernet Per Priority Group Counters */ /* Ethernet Per Priority Group Counters */
/* reg_ppcnt_rx_octets /* reg_ppcnt_rx_octets
......
...@@ -1876,7 +1876,37 @@ static struct mlxsw_sp_port_hw_stats mlxsw_sp_port_hw_stats[] = { ...@@ -1876,7 +1876,37 @@ 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_2863_stats[] = {
{
.str = "if_in_discards",
.getter = mlxsw_reg_ppcnt_if_in_discards_get,
},
{
.str = "if_out_discards",
.getter = mlxsw_reg_ppcnt_if_out_discards_get,
},
{
.str = "if_out_errors",
.getter = mlxsw_reg_ppcnt_if_out_errors_get,
},
};
#define MLXSW_SP_PORT_HW_RFC_2863_STATS_LEN \
ARRAY_SIZE(mlxsw_sp_port_hw_rfc_2863_stats)
static struct mlxsw_sp_port_hw_stats mlxsw_sp_port_hw_rfc_2819_stats[] = { static struct mlxsw_sp_port_hw_stats mlxsw_sp_port_hw_rfc_2819_stats[] = {
{
.str = "ether_stats_undersize_pkts",
.getter = mlxsw_reg_ppcnt_ether_stats_undersize_pkts_get,
},
{
.str = "ether_stats_oversize_pkts",
.getter = mlxsw_reg_ppcnt_ether_stats_oversize_pkts_get,
},
{
.str = "ether_stats_fragments",
.getter = mlxsw_reg_ppcnt_ether_stats_fragments_get,
},
{ {
.str = "ether_pkts64octets", .str = "ether_pkts64octets",
.getter = mlxsw_reg_ppcnt_ether_stats_pkts64octets_get, .getter = mlxsw_reg_ppcnt_ether_stats_pkts64octets_get,
...@@ -1922,6 +1952,82 @@ static struct mlxsw_sp_port_hw_stats mlxsw_sp_port_hw_rfc_2819_stats[] = { ...@@ -1922,6 +1952,82 @@ static struct mlxsw_sp_port_hw_stats mlxsw_sp_port_hw_rfc_2819_stats[] = {
#define MLXSW_SP_PORT_HW_RFC_2819_STATS_LEN \ #define MLXSW_SP_PORT_HW_RFC_2819_STATS_LEN \
ARRAY_SIZE(mlxsw_sp_port_hw_rfc_2819_stats) ARRAY_SIZE(mlxsw_sp_port_hw_rfc_2819_stats)
static struct mlxsw_sp_port_hw_stats mlxsw_sp_port_hw_rfc_3635_stats[] = {
{
.str = "dot3stats_fcs_errors",
.getter = mlxsw_reg_ppcnt_dot3stats_fcs_errors_get,
},
{
.str = "dot3stats_symbol_errors",
.getter = mlxsw_reg_ppcnt_dot3stats_symbol_errors_get,
},
{
.str = "dot3control_in_unknown_opcodes",
.getter = mlxsw_reg_ppcnt_dot3control_in_unknown_opcodes_get,
},
{
.str = "dot3in_pause_frames",
.getter = mlxsw_reg_ppcnt_dot3in_pause_frames_get,
},
};
#define MLXSW_SP_PORT_HW_RFC_3635_STATS_LEN \
ARRAY_SIZE(mlxsw_sp_port_hw_rfc_3635_stats)
static struct mlxsw_sp_port_hw_stats mlxsw_sp_port_hw_discard_stats[] = {
{
.str = "discard_ingress_general",
.getter = mlxsw_reg_ppcnt_ingress_general_get,
},
{
.str = "discard_ingress_policy_engine",
.getter = mlxsw_reg_ppcnt_ingress_policy_engine_get,
},
{
.str = "discard_ingress_vlan_membership",
.getter = mlxsw_reg_ppcnt_ingress_vlan_membership_get,
},
{
.str = "discard_ingress_tag_frame_type",
.getter = mlxsw_reg_ppcnt_ingress_tag_frame_type_get,
},
{
.str = "discard_egress_vlan_membership",
.getter = mlxsw_reg_ppcnt_egress_vlan_membership_get,
},
{
.str = "discard_loopback_filter",
.getter = mlxsw_reg_ppcnt_loopback_filter_get,
},
{
.str = "discard_egress_general",
.getter = mlxsw_reg_ppcnt_egress_general_get,
},
{
.str = "discard_egress_hoq",
.getter = mlxsw_reg_ppcnt_egress_hoq_get,
},
{
.str = "discard_egress_policy_engine",
.getter = mlxsw_reg_ppcnt_egress_policy_engine_get,
},
{
.str = "discard_ingress_tx_link_down",
.getter = mlxsw_reg_ppcnt_ingress_tx_link_down_get,
},
{
.str = "discard_egress_stp_filter",
.getter = mlxsw_reg_ppcnt_egress_stp_filter_get,
},
{
.str = "discard_egress_sll",
.getter = mlxsw_reg_ppcnt_egress_sll_get,
},
};
#define MLXSW_SP_PORT_HW_DISCARD_STATS_LEN \
ARRAY_SIZE(mlxsw_sp_port_hw_discard_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",
...@@ -1974,7 +2080,10 @@ static struct mlxsw_sp_port_hw_stats mlxsw_sp_port_hw_tc_stats[] = { ...@@ -1974,7 +2080,10 @@ static struct mlxsw_sp_port_hw_stats mlxsw_sp_port_hw_tc_stats[] = {
#define MLXSW_SP_PORT_HW_TC_STATS_LEN ARRAY_SIZE(mlxsw_sp_port_hw_tc_stats) #define MLXSW_SP_PORT_HW_TC_STATS_LEN ARRAY_SIZE(mlxsw_sp_port_hw_tc_stats)
#define MLXSW_SP_PORT_ETHTOOL_STATS_LEN (MLXSW_SP_PORT_HW_STATS_LEN + \ #define MLXSW_SP_PORT_ETHTOOL_STATS_LEN (MLXSW_SP_PORT_HW_STATS_LEN + \
MLXSW_SP_PORT_HW_RFC_2863_STATS_LEN + \
MLXSW_SP_PORT_HW_RFC_2819_STATS_LEN + \ MLXSW_SP_PORT_HW_RFC_2819_STATS_LEN + \
MLXSW_SP_PORT_HW_RFC_3635_STATS_LEN + \
MLXSW_SP_PORT_HW_DISCARD_STATS_LEN + \
(MLXSW_SP_PORT_HW_PRIO_STATS_LEN * \ (MLXSW_SP_PORT_HW_PRIO_STATS_LEN * \
IEEE_8021QAZ_MAX_TCS) + \ IEEE_8021QAZ_MAX_TCS) + \
(MLXSW_SP_PORT_HW_TC_STATS_LEN * \ (MLXSW_SP_PORT_HW_TC_STATS_LEN * \
...@@ -2015,12 +2124,31 @@ static void mlxsw_sp_port_get_strings(struct net_device *dev, ...@@ -2015,12 +2124,31 @@ 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_2863_STATS_LEN; i++) {
memcpy(p, mlxsw_sp_port_hw_rfc_2863_stats[i].str,
ETH_GSTRING_LEN);
p += ETH_GSTRING_LEN;
}
for (i = 0; i < MLXSW_SP_PORT_HW_RFC_2819_STATS_LEN; i++) { for (i = 0; i < MLXSW_SP_PORT_HW_RFC_2819_STATS_LEN; i++) {
memcpy(p, mlxsw_sp_port_hw_rfc_2819_stats[i].str, memcpy(p, mlxsw_sp_port_hw_rfc_2819_stats[i].str,
ETH_GSTRING_LEN); ETH_GSTRING_LEN);
p += ETH_GSTRING_LEN; p += ETH_GSTRING_LEN;
} }
for (i = 0; i < MLXSW_SP_PORT_HW_RFC_3635_STATS_LEN; i++) {
memcpy(p, mlxsw_sp_port_hw_rfc_3635_stats[i].str,
ETH_GSTRING_LEN);
p += ETH_GSTRING_LEN;
}
for (i = 0; i < MLXSW_SP_PORT_HW_DISCARD_STATS_LEN; i++) {
memcpy(p, mlxsw_sp_port_hw_discard_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);
...@@ -2063,10 +2191,22 @@ mlxsw_sp_get_hw_stats_by_group(struct mlxsw_sp_port_hw_stats **p_hw_stats, ...@@ -2063,10 +2191,22 @@ mlxsw_sp_get_hw_stats_by_group(struct mlxsw_sp_port_hw_stats **p_hw_stats,
*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_2863_CNT:
*p_hw_stats = mlxsw_sp_port_hw_rfc_2863_stats;
*p_len = MLXSW_SP_PORT_HW_RFC_2863_STATS_LEN;
break;
case MLXSW_REG_PPCNT_RFC_2819_CNT: case MLXSW_REG_PPCNT_RFC_2819_CNT:
*p_hw_stats = mlxsw_sp_port_hw_rfc_2819_stats; *p_hw_stats = mlxsw_sp_port_hw_rfc_2819_stats;
*p_len = MLXSW_SP_PORT_HW_RFC_2819_STATS_LEN; *p_len = MLXSW_SP_PORT_HW_RFC_2819_STATS_LEN;
break; break;
case MLXSW_REG_PPCNT_RFC_3635_CNT:
*p_hw_stats = mlxsw_sp_port_hw_rfc_3635_stats;
*p_len = MLXSW_SP_PORT_HW_RFC_3635_STATS_LEN;
break;
case MLXSW_REG_PPCNT_DISCARD_CNT:
*p_hw_stats = mlxsw_sp_port_hw_discard_stats;
*p_len = MLXSW_SP_PORT_HW_DISCARD_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;
...@@ -2116,11 +2256,26 @@ static void mlxsw_sp_port_get_stats(struct net_device *dev, ...@@ -2116,11 +2256,26 @@ 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 2863 Counters */
__mlxsw_sp_port_get_stats(dev, MLXSW_REG_PPCNT_RFC_2863_CNT, 0,
data, data_index);
data_index += MLXSW_SP_PORT_HW_RFC_2863_STATS_LEN;
/* RFC 2819 Counters */ /* RFC 2819 Counters */
__mlxsw_sp_port_get_stats(dev, MLXSW_REG_PPCNT_RFC_2819_CNT, 0, __mlxsw_sp_port_get_stats(dev, MLXSW_REG_PPCNT_RFC_2819_CNT, 0,
data, data_index); data, data_index);
data_index += MLXSW_SP_PORT_HW_RFC_2819_STATS_LEN; data_index += MLXSW_SP_PORT_HW_RFC_2819_STATS_LEN;
/* RFC 3635 Counters */
__mlxsw_sp_port_get_stats(dev, MLXSW_REG_PPCNT_RFC_3635_CNT, 0,
data, data_index);
data_index += MLXSW_SP_PORT_HW_RFC_3635_STATS_LEN;
/* Discard Counters */
__mlxsw_sp_port_get_stats(dev, MLXSW_REG_PPCNT_DISCARD_CNT, 0,
data, data_index);
data_index += MLXSW_SP_PORT_HW_DISCARD_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