77
88#include <net/mana/mana.h>
99
10- static const struct {
10+ struct mana_stats_desc {
1111 char name [ETH_GSTRING_LEN ];
1212 u16 offset ;
13- } mana_eth_stats [] = {
13+ };
14+
15+ static const struct mana_stats_desc mana_eth_stats [] = {
1416 {"stop_queue" , offsetof(struct mana_ethtool_stats , stop_queue )},
1517 {"wake_queue" , offsetof(struct mana_ethtool_stats , wake_queue )},
1618 {"hc_rx_discards_no_wqe" , offsetof(struct mana_ethtool_stats ,
@@ -75,6 +77,59 @@ static const struct {
7577 rx_cqe_unknown_type )},
7678};
7779
80+ static const struct mana_stats_desc mana_phy_stats [] = {
81+ { "hc_rx_pkt_drop_phy" , offsetof(struct mana_ethtool_phy_stats , rx_pkt_drop_phy ) },
82+ { "hc_tx_pkt_drop_phy" , offsetof(struct mana_ethtool_phy_stats , tx_pkt_drop_phy ) },
83+ { "hc_tc0_rx_pkt_phy" , offsetof(struct mana_ethtool_phy_stats , rx_pkt_tc0_phy ) },
84+ { "hc_tc0_rx_byte_phy" , offsetof(struct mana_ethtool_phy_stats , rx_byte_tc0_phy ) },
85+ { "hc_tc0_tx_pkt_phy" , offsetof(struct mana_ethtool_phy_stats , tx_pkt_tc0_phy ) },
86+ { "hc_tc0_tx_byte_phy" , offsetof(struct mana_ethtool_phy_stats , tx_byte_tc0_phy ) },
87+ { "hc_tc1_rx_pkt_phy" , offsetof(struct mana_ethtool_phy_stats , rx_pkt_tc1_phy ) },
88+ { "hc_tc1_rx_byte_phy" , offsetof(struct mana_ethtool_phy_stats , rx_byte_tc1_phy ) },
89+ { "hc_tc1_tx_pkt_phy" , offsetof(struct mana_ethtool_phy_stats , tx_pkt_tc1_phy ) },
90+ { "hc_tc1_tx_byte_phy" , offsetof(struct mana_ethtool_phy_stats , tx_byte_tc1_phy ) },
91+ { "hc_tc2_rx_pkt_phy" , offsetof(struct mana_ethtool_phy_stats , rx_pkt_tc2_phy ) },
92+ { "hc_tc2_rx_byte_phy" , offsetof(struct mana_ethtool_phy_stats , rx_byte_tc2_phy ) },
93+ { "hc_tc2_tx_pkt_phy" , offsetof(struct mana_ethtool_phy_stats , tx_pkt_tc2_phy ) },
94+ { "hc_tc2_tx_byte_phy" , offsetof(struct mana_ethtool_phy_stats , tx_byte_tc2_phy ) },
95+ { "hc_tc3_rx_pkt_phy" , offsetof(struct mana_ethtool_phy_stats , rx_pkt_tc3_phy ) },
96+ { "hc_tc3_rx_byte_phy" , offsetof(struct mana_ethtool_phy_stats , rx_byte_tc3_phy ) },
97+ { "hc_tc3_tx_pkt_phy" , offsetof(struct mana_ethtool_phy_stats , tx_pkt_tc3_phy ) },
98+ { "hc_tc3_tx_byte_phy" , offsetof(struct mana_ethtool_phy_stats , tx_byte_tc3_phy ) },
99+ { "hc_tc4_rx_pkt_phy" , offsetof(struct mana_ethtool_phy_stats , rx_pkt_tc4_phy ) },
100+ { "hc_tc4_rx_byte_phy" , offsetof(struct mana_ethtool_phy_stats , rx_byte_tc4_phy ) },
101+ { "hc_tc4_tx_pkt_phy" , offsetof(struct mana_ethtool_phy_stats , tx_pkt_tc4_phy ) },
102+ { "hc_tc4_tx_byte_phy" , offsetof(struct mana_ethtool_phy_stats , tx_byte_tc4_phy ) },
103+ { "hc_tc5_rx_pkt_phy" , offsetof(struct mana_ethtool_phy_stats , rx_pkt_tc5_phy ) },
104+ { "hc_tc5_rx_byte_phy" , offsetof(struct mana_ethtool_phy_stats , rx_byte_tc5_phy ) },
105+ { "hc_tc5_tx_pkt_phy" , offsetof(struct mana_ethtool_phy_stats , tx_pkt_tc5_phy ) },
106+ { "hc_tc5_tx_byte_phy" , offsetof(struct mana_ethtool_phy_stats , tx_byte_tc5_phy ) },
107+ { "hc_tc6_rx_pkt_phy" , offsetof(struct mana_ethtool_phy_stats , rx_pkt_tc6_phy ) },
108+ { "hc_tc6_rx_byte_phy" , offsetof(struct mana_ethtool_phy_stats , rx_byte_tc6_phy ) },
109+ { "hc_tc6_tx_pkt_phy" , offsetof(struct mana_ethtool_phy_stats , tx_pkt_tc6_phy ) },
110+ { "hc_tc6_tx_byte_phy" , offsetof(struct mana_ethtool_phy_stats , tx_byte_tc6_phy ) },
111+ { "hc_tc7_rx_pkt_phy" , offsetof(struct mana_ethtool_phy_stats , rx_pkt_tc7_phy ) },
112+ { "hc_tc7_rx_byte_phy" , offsetof(struct mana_ethtool_phy_stats , rx_byte_tc7_phy ) },
113+ { "hc_tc7_tx_pkt_phy" , offsetof(struct mana_ethtool_phy_stats , tx_pkt_tc7_phy ) },
114+ { "hc_tc7_tx_byte_phy" , offsetof(struct mana_ethtool_phy_stats , tx_byte_tc7_phy ) },
115+ { "hc_tc0_rx_pause_phy" , offsetof(struct mana_ethtool_phy_stats , rx_pause_tc0_phy ) },
116+ { "hc_tc0_tx_pause_phy" , offsetof(struct mana_ethtool_phy_stats , tx_pause_tc0_phy ) },
117+ { "hc_tc1_rx_pause_phy" , offsetof(struct mana_ethtool_phy_stats , rx_pause_tc1_phy ) },
118+ { "hc_tc1_tx_pause_phy" , offsetof(struct mana_ethtool_phy_stats , tx_pause_tc1_phy ) },
119+ { "hc_tc2_rx_pause_phy" , offsetof(struct mana_ethtool_phy_stats , rx_pause_tc2_phy ) },
120+ { "hc_tc2_tx_pause_phy" , offsetof(struct mana_ethtool_phy_stats , tx_pause_tc2_phy ) },
121+ { "hc_tc3_rx_pause_phy" , offsetof(struct mana_ethtool_phy_stats , rx_pause_tc3_phy ) },
122+ { "hc_tc3_tx_pause_phy" , offsetof(struct mana_ethtool_phy_stats , tx_pause_tc3_phy ) },
123+ { "hc_tc4_rx_pause_phy" , offsetof(struct mana_ethtool_phy_stats , rx_pause_tc4_phy ) },
124+ { "hc_tc4_tx_pause_phy" , offsetof(struct mana_ethtool_phy_stats , tx_pause_tc4_phy ) },
125+ { "hc_tc5_rx_pause_phy" , offsetof(struct mana_ethtool_phy_stats , rx_pause_tc5_phy ) },
126+ { "hc_tc5_tx_pause_phy" , offsetof(struct mana_ethtool_phy_stats , tx_pause_tc5_phy ) },
127+ { "hc_tc6_rx_pause_phy" , offsetof(struct mana_ethtool_phy_stats , rx_pause_tc6_phy ) },
128+ { "hc_tc6_tx_pause_phy" , offsetof(struct mana_ethtool_phy_stats , tx_pause_tc6_phy ) },
129+ { "hc_tc7_rx_pause_phy" , offsetof(struct mana_ethtool_phy_stats , rx_pause_tc7_phy ) },
130+ { "hc_tc7_tx_pause_phy" , offsetof(struct mana_ethtool_phy_stats , tx_pause_tc7_phy ) },
131+ };
132+
78133static int mana_get_sset_count (struct net_device * ndev , int stringset )
79134{
80135 struct mana_port_context * apc = netdev_priv (ndev );
@@ -83,8 +138,8 @@ static int mana_get_sset_count(struct net_device *ndev, int stringset)
83138 if (stringset != ETH_SS_STATS )
84139 return - EINVAL ;
85140
86- return ARRAY_SIZE (mana_eth_stats ) + num_queues *
87- (MANA_STATS_RX_COUNT + MANA_STATS_TX_COUNT );
141+ return ARRAY_SIZE (mana_eth_stats ) + ARRAY_SIZE ( mana_phy_stats ) +
142+ num_queues * (MANA_STATS_RX_COUNT + MANA_STATS_TX_COUNT );
88143}
89144
90145static void mana_get_strings (struct net_device * ndev , u32 stringset , u8 * data )
@@ -99,6 +154,9 @@ static void mana_get_strings(struct net_device *ndev, u32 stringset, u8 *data)
99154 for (i = 0 ; i < ARRAY_SIZE (mana_eth_stats ); i ++ )
100155 ethtool_puts (& data , mana_eth_stats [i ].name );
101156
157+ for (i = 0 ; i < ARRAY_SIZE (mana_phy_stats ); i ++ )
158+ ethtool_puts (& data , mana_phy_stats [i ].name );
159+
102160 for (i = 0 ; i < num_queues ; i ++ ) {
103161 ethtool_sprintf (& data , "rx_%d_packets" , i );
104162 ethtool_sprintf (& data , "rx_%d_bytes" , i );
@@ -128,6 +186,7 @@ static void mana_get_ethtool_stats(struct net_device *ndev,
128186 struct mana_port_context * apc = netdev_priv (ndev );
129187 unsigned int num_queues = apc -> num_queues ;
130188 void * eth_stats = & apc -> eth_stats ;
189+ void * phy_stats = & apc -> phy_stats ;
131190 struct mana_stats_rx * rx_stats ;
132191 struct mana_stats_tx * tx_stats ;
133192 unsigned int start ;
@@ -151,9 +210,18 @@ static void mana_get_ethtool_stats(struct net_device *ndev,
151210 /* we call mana function to update stats from GDMA */
152211 mana_query_gf_stats (apc );
153212
213+ /* We call this mana function to get the phy stats from GDMA and includes
214+ * aggregate tx/rx drop counters, Per-TC(Traffic Channel) tx/rx and pause
215+ * counters.
216+ */
217+ mana_query_phy_stats (apc );
218+
154219 for (q = 0 ; q < ARRAY_SIZE (mana_eth_stats ); q ++ )
155220 data [i ++ ] = * (u64 * )(eth_stats + mana_eth_stats [q ].offset );
156221
222+ for (q = 0 ; q < ARRAY_SIZE (mana_phy_stats ); q ++ )
223+ data [i ++ ] = * (u64 * )(phy_stats + mana_phy_stats [q ].offset );
224+
157225 for (q = 0 ; q < num_queues ; q ++ ) {
158226 rx_stats = & apc -> rxqs [q ]-> stats ;
159227
0 commit comments