Skip to content

Commit 2368957

Browse files
committed
Merge branch 'cxgb4-move-stats-fetched-from-firmware-to-debugfs'
Rahul Lakkireddy says: ==================== cxgb4: move stats fetched from firmware to debugfs Some stats are fetched via slow firmware mailbox, which can cause packet drops under heavy load. So, this series removes these stats from ethtool -S and expose them via debugfs. Patch 1 removes stats fetched via firmware from ethtool -S. Patch 2 exposes stats removed in Patch 1 via debugfs. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents b32b088 + 31e5f5c commit 2368957

File tree

2 files changed

+164
-133
lines changed

2 files changed

+164
-133
lines changed

drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c

Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2962,6 +2962,169 @@ static const struct file_operations chcr_stats_debugfs_fops = {
29622962
.llseek = seq_lseek,
29632963
.release = single_release,
29642964
};
2965+
2966+
#define PRINT_ADAP_STATS(string, value) \
2967+
seq_printf(seq, "%-25s %-20llu\n", (string), \
2968+
(unsigned long long)(value))
2969+
2970+
#define PRINT_CH_STATS(string, value) \
2971+
do { \
2972+
seq_printf(seq, "%-25s ", (string)); \
2973+
for (i = 0; i < adap->params.arch.nchan; i++) \
2974+
seq_printf(seq, "%-20llu ", \
2975+
(unsigned long long)stats.value[i]); \
2976+
seq_printf(seq, "\n"); \
2977+
} while (0)
2978+
2979+
#define PRINT_CH_STATS2(string, value) \
2980+
do { \
2981+
seq_printf(seq, "%-25s ", (string)); \
2982+
for (i = 0; i < adap->params.arch.nchan; i++) \
2983+
seq_printf(seq, "%-20llu ", \
2984+
(unsigned long long)stats[i].value); \
2985+
seq_printf(seq, "\n"); \
2986+
} while (0)
2987+
2988+
static void show_tcp_stats(struct seq_file *seq)
2989+
{
2990+
struct adapter *adap = seq->private;
2991+
struct tp_tcp_stats v4, v6;
2992+
2993+
spin_lock(&adap->stats_lock);
2994+
t4_tp_get_tcp_stats(adap, &v4, &v6, false);
2995+
spin_unlock(&adap->stats_lock);
2996+
2997+
PRINT_ADAP_STATS("tcp_ipv4_out_rsts:", v4.tcp_out_rsts);
2998+
PRINT_ADAP_STATS("tcp_ipv4_in_segs:", v4.tcp_in_segs);
2999+
PRINT_ADAP_STATS("tcp_ipv4_out_segs:", v4.tcp_out_segs);
3000+
PRINT_ADAP_STATS("tcp_ipv4_retrans_segs:", v4.tcp_retrans_segs);
3001+
PRINT_ADAP_STATS("tcp_ipv6_out_rsts:", v6.tcp_out_rsts);
3002+
PRINT_ADAP_STATS("tcp_ipv6_in_segs:", v6.tcp_in_segs);
3003+
PRINT_ADAP_STATS("tcp_ipv6_out_segs:", v6.tcp_out_segs);
3004+
PRINT_ADAP_STATS("tcp_ipv6_retrans_segs:", v6.tcp_retrans_segs);
3005+
}
3006+
3007+
static void show_ddp_stats(struct seq_file *seq)
3008+
{
3009+
struct adapter *adap = seq->private;
3010+
struct tp_usm_stats stats;
3011+
3012+
spin_lock(&adap->stats_lock);
3013+
t4_get_usm_stats(adap, &stats, false);
3014+
spin_unlock(&adap->stats_lock);
3015+
3016+
PRINT_ADAP_STATS("usm_ddp_frames:", stats.frames);
3017+
PRINT_ADAP_STATS("usm_ddp_octets:", stats.octets);
3018+
PRINT_ADAP_STATS("usm_ddp_drops:", stats.drops);
3019+
}
3020+
3021+
static void show_rdma_stats(struct seq_file *seq)
3022+
{
3023+
struct adapter *adap = seq->private;
3024+
struct tp_rdma_stats stats;
3025+
3026+
spin_lock(&adap->stats_lock);
3027+
t4_tp_get_rdma_stats(adap, &stats, false);
3028+
spin_unlock(&adap->stats_lock);
3029+
3030+
PRINT_ADAP_STATS("rdma_no_rqe_mod_defer:", stats.rqe_dfr_mod);
3031+
PRINT_ADAP_STATS("rdma_no_rqe_pkt_defer:", stats.rqe_dfr_pkt);
3032+
}
3033+
3034+
static void show_tp_err_adapter_stats(struct seq_file *seq)
3035+
{
3036+
struct adapter *adap = seq->private;
3037+
struct tp_err_stats stats;
3038+
3039+
spin_lock(&adap->stats_lock);
3040+
t4_tp_get_err_stats(adap, &stats, false);
3041+
spin_unlock(&adap->stats_lock);
3042+
3043+
PRINT_ADAP_STATS("tp_err_ofld_no_neigh:", stats.ofld_no_neigh);
3044+
PRINT_ADAP_STATS("tp_err_ofld_cong_defer:", stats.ofld_cong_defer);
3045+
}
3046+
3047+
static void show_cpl_stats(struct seq_file *seq)
3048+
{
3049+
struct adapter *adap = seq->private;
3050+
struct tp_cpl_stats stats;
3051+
u8 i;
3052+
3053+
spin_lock(&adap->stats_lock);
3054+
t4_tp_get_cpl_stats(adap, &stats, false);
3055+
spin_unlock(&adap->stats_lock);
3056+
3057+
PRINT_CH_STATS("tp_cpl_requests:", req);
3058+
PRINT_CH_STATS("tp_cpl_responses:", rsp);
3059+
}
3060+
3061+
static void show_tp_err_channel_stats(struct seq_file *seq)
3062+
{
3063+
struct adapter *adap = seq->private;
3064+
struct tp_err_stats stats;
3065+
u8 i;
3066+
3067+
spin_lock(&adap->stats_lock);
3068+
t4_tp_get_err_stats(adap, &stats, false);
3069+
spin_unlock(&adap->stats_lock);
3070+
3071+
PRINT_CH_STATS("tp_mac_in_errs:", mac_in_errs);
3072+
PRINT_CH_STATS("tp_hdr_in_errs:", hdr_in_errs);
3073+
PRINT_CH_STATS("tp_tcp_in_errs:", tcp_in_errs);
3074+
PRINT_CH_STATS("tp_tcp6_in_errs:", tcp6_in_errs);
3075+
PRINT_CH_STATS("tp_tnl_cong_drops:", tnl_cong_drops);
3076+
PRINT_CH_STATS("tp_tnl_tx_drops:", tnl_tx_drops);
3077+
PRINT_CH_STATS("tp_ofld_vlan_drops:", ofld_vlan_drops);
3078+
PRINT_CH_STATS("tp_ofld_chan_drops:", ofld_chan_drops);
3079+
}
3080+
3081+
static void show_fcoe_stats(struct seq_file *seq)
3082+
{
3083+
struct adapter *adap = seq->private;
3084+
struct tp_fcoe_stats stats[NCHAN];
3085+
u8 i;
3086+
3087+
spin_lock(&adap->stats_lock);
3088+
for (i = 0; i < adap->params.arch.nchan; i++)
3089+
t4_get_fcoe_stats(adap, i, &stats[i], false);
3090+
spin_unlock(&adap->stats_lock);
3091+
3092+
PRINT_CH_STATS2("fcoe_octets_ddp", octets_ddp);
3093+
PRINT_CH_STATS2("fcoe_frames_ddp", frames_ddp);
3094+
PRINT_CH_STATS2("fcoe_frames_drop", frames_drop);
3095+
}
3096+
3097+
#undef PRINT_CH_STATS2
3098+
#undef PRINT_CH_STATS
3099+
#undef PRINT_ADAP_STATS
3100+
3101+
static int tp_stats_show(struct seq_file *seq, void *v)
3102+
{
3103+
struct adapter *adap = seq->private;
3104+
3105+
seq_puts(seq, "\n--------Adapter Stats--------\n");
3106+
show_tcp_stats(seq);
3107+
show_ddp_stats(seq);
3108+
show_rdma_stats(seq);
3109+
show_tp_err_adapter_stats(seq);
3110+
3111+
seq_puts(seq, "\n-------- Channel Stats --------\n");
3112+
if (adap->params.arch.nchan == NCHAN)
3113+
seq_printf(seq, "%-25s %-20s %-20s %-20s %-20s\n",
3114+
" ", "channel 0", "channel 1",
3115+
"channel 2", "channel 3");
3116+
else
3117+
seq_printf(seq, "%-25s %-20s %-20s\n",
3118+
" ", "channel 0", "channel 1");
3119+
show_cpl_stats(seq);
3120+
show_tp_err_channel_stats(seq);
3121+
show_fcoe_stats(seq);
3122+
3123+
return 0;
3124+
}
3125+
3126+
DEFINE_SIMPLE_DEBUGFS_FILE(tp_stats);
3127+
29653128
/* Add an array of Debug FS files.
29663129
*/
29673130
void add_debugfs_files(struct adapter *adap,
@@ -3038,6 +3201,7 @@ int t4_setup_debugfs(struct adapter *adap)
30383201
{ "blocked_fl", &blocked_fl_fops, 0600, 0 },
30393202
{ "meminfo", &meminfo_fops, 0400, 0 },
30403203
{ "crypto", &chcr_stats_debugfs_fops, 0400, 0 },
3204+
{ "tp_stats", &tp_stats_debugfs_fops, 0400, 0 },
30413205
};
30423206

30433207
/* Debug FS nodes common to all T5 and later adapters.

drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c

Lines changed: 0 additions & 133 deletions
Original file line numberDiff line numberDiff line change
@@ -115,42 +115,10 @@ static char adapter_stats_strings[][ETH_GSTRING_LEN] = {
115115
"db_drop ",
116116
"db_full ",
117117
"db_empty ",
118-
"tcp_ipv4_out_rsts ",
119-
"tcp_ipv4_in_segs ",
120-
"tcp_ipv4_out_segs ",
121-
"tcp_ipv4_retrans_segs ",
122-
"tcp_ipv6_out_rsts ",
123-
"tcp_ipv6_in_segs ",
124-
"tcp_ipv6_out_segs ",
125-
"tcp_ipv6_retrans_segs ",
126-
"usm_ddp_frames ",
127-
"usm_ddp_octets ",
128-
"usm_ddp_drops ",
129-
"rdma_no_rqe_mod_defer ",
130-
"rdma_no_rqe_pkt_defer ",
131-
"tp_err_ofld_no_neigh ",
132-
"tp_err_ofld_cong_defer ",
133118
"write_coal_success ",
134119
"write_coal_fail ",
135120
};
136121

137-
static char channel_stats_strings[][ETH_GSTRING_LEN] = {
138-
"--------Channel--------- ",
139-
"tp_cpl_requests ",
140-
"tp_cpl_responses ",
141-
"tp_mac_in_errs ",
142-
"tp_hdr_in_errs ",
143-
"tp_tcp_in_errs ",
144-
"tp_tcp6_in_errs ",
145-
"tp_tnl_cong_drops ",
146-
"tp_tnl_tx_drops ",
147-
"tp_ofld_vlan_drops ",
148-
"tp_ofld_chan_drops ",
149-
"fcoe_octets_ddp ",
150-
"fcoe_frames_ddp ",
151-
"fcoe_frames_drop ",
152-
};
153-
154122
static char loopback_stats_strings[][ETH_GSTRING_LEN] = {
155123
"-------Loopback----------- ",
156124
"octets_ok ",
@@ -187,7 +155,6 @@ static int get_sset_count(struct net_device *dev, int sset)
187155
case ETH_SS_STATS:
188156
return ARRAY_SIZE(stats_strings) +
189157
ARRAY_SIZE(adapter_stats_strings) +
190-
ARRAY_SIZE(channel_stats_strings) +
191158
ARRAY_SIZE(loopback_stats_strings);
192159
case ETH_SS_PRIV_FLAGS:
193160
return ARRAY_SIZE(cxgb4_priv_flags_strings);
@@ -252,9 +219,6 @@ static void get_strings(struct net_device *dev, u32 stringset, u8 *data)
252219
memcpy(data, adapter_stats_strings,
253220
sizeof(adapter_stats_strings));
254221
data += sizeof(adapter_stats_strings);
255-
memcpy(data, channel_stats_strings,
256-
sizeof(channel_stats_strings));
257-
data += sizeof(channel_stats_strings);
258222
memcpy(data, loopback_stats_strings,
259223
sizeof(loopback_stats_strings));
260224
} else if (stringset == ETH_SS_PRIV_FLAGS) {
@@ -280,41 +244,10 @@ struct adapter_stats {
280244
u64 db_drop;
281245
u64 db_full;
282246
u64 db_empty;
283-
u64 tcp_v4_out_rsts;
284-
u64 tcp_v4_in_segs;
285-
u64 tcp_v4_out_segs;
286-
u64 tcp_v4_retrans_segs;
287-
u64 tcp_v6_out_rsts;
288-
u64 tcp_v6_in_segs;
289-
u64 tcp_v6_out_segs;
290-
u64 tcp_v6_retrans_segs;
291-
u64 frames;
292-
u64 octets;
293-
u64 drops;
294-
u64 rqe_dfr_mod;
295-
u64 rqe_dfr_pkt;
296-
u64 ofld_no_neigh;
297-
u64 ofld_cong_defer;
298247
u64 wc_success;
299248
u64 wc_fail;
300249
};
301250

302-
struct channel_stats {
303-
u64 cpl_req;
304-
u64 cpl_rsp;
305-
u64 mac_in_errs;
306-
u64 hdr_in_errs;
307-
u64 tcp_in_errs;
308-
u64 tcp6_in_errs;
309-
u64 tnl_cong_drops;
310-
u64 tnl_tx_drops;
311-
u64 ofld_vlan_drops;
312-
u64 ofld_chan_drops;
313-
u64 octets_ddp;
314-
u64 frames_ddp;
315-
u64 frames_drop;
316-
};
317-
318251
static void collect_sge_port_stats(const struct adapter *adap,
319252
const struct port_info *p,
320253
struct queue_port_stats *s)
@@ -337,45 +270,14 @@ static void collect_sge_port_stats(const struct adapter *adap,
337270

338271
static void collect_adapter_stats(struct adapter *adap, struct adapter_stats *s)
339272
{
340-
struct tp_tcp_stats v4, v6;
341-
struct tp_rdma_stats rdma_stats;
342-
struct tp_err_stats err_stats;
343-
struct tp_usm_stats usm_stats;
344273
u64 val1, val2;
345274

346275
memset(s, 0, sizeof(*s));
347276

348-
spin_lock(&adap->stats_lock);
349-
t4_tp_get_tcp_stats(adap, &v4, &v6, false);
350-
t4_tp_get_rdma_stats(adap, &rdma_stats, false);
351-
t4_get_usm_stats(adap, &usm_stats, false);
352-
t4_tp_get_err_stats(adap, &err_stats, false);
353-
spin_unlock(&adap->stats_lock);
354-
355277
s->db_drop = adap->db_stats.db_drop;
356278
s->db_full = adap->db_stats.db_full;
357279
s->db_empty = adap->db_stats.db_empty;
358280

359-
s->tcp_v4_out_rsts = v4.tcp_out_rsts;
360-
s->tcp_v4_in_segs = v4.tcp_in_segs;
361-
s->tcp_v4_out_segs = v4.tcp_out_segs;
362-
s->tcp_v4_retrans_segs = v4.tcp_retrans_segs;
363-
s->tcp_v6_out_rsts = v6.tcp_out_rsts;
364-
s->tcp_v6_in_segs = v6.tcp_in_segs;
365-
s->tcp_v6_out_segs = v6.tcp_out_segs;
366-
s->tcp_v6_retrans_segs = v6.tcp_retrans_segs;
367-
368-
if (is_offload(adap)) {
369-
s->frames = usm_stats.frames;
370-
s->octets = usm_stats.octets;
371-
s->drops = usm_stats.drops;
372-
s->rqe_dfr_mod = rdma_stats.rqe_dfr_mod;
373-
s->rqe_dfr_pkt = rdma_stats.rqe_dfr_pkt;
374-
}
375-
376-
s->ofld_no_neigh = err_stats.ofld_no_neigh;
377-
s->ofld_cong_defer = err_stats.ofld_cong_defer;
378-
379281
if (!is_t4(adap->params.chip)) {
380282
int v;
381283

@@ -389,36 +291,6 @@ static void collect_adapter_stats(struct adapter *adap, struct adapter_stats *s)
389291
}
390292
}
391293

392-
static void collect_channel_stats(struct adapter *adap, struct channel_stats *s,
393-
u8 i)
394-
{
395-
struct tp_cpl_stats cpl_stats;
396-
struct tp_err_stats err_stats;
397-
struct tp_fcoe_stats fcoe_stats;
398-
399-
memset(s, 0, sizeof(*s));
400-
401-
spin_lock(&adap->stats_lock);
402-
t4_tp_get_cpl_stats(adap, &cpl_stats, false);
403-
t4_tp_get_err_stats(adap, &err_stats, false);
404-
t4_get_fcoe_stats(adap, i, &fcoe_stats, false);
405-
spin_unlock(&adap->stats_lock);
406-
407-
s->cpl_req = cpl_stats.req[i];
408-
s->cpl_rsp = cpl_stats.rsp[i];
409-
s->mac_in_errs = err_stats.mac_in_errs[i];
410-
s->hdr_in_errs = err_stats.hdr_in_errs[i];
411-
s->tcp_in_errs = err_stats.tcp_in_errs[i];
412-
s->tcp6_in_errs = err_stats.tcp6_in_errs[i];
413-
s->tnl_cong_drops = err_stats.tnl_cong_drops[i];
414-
s->tnl_tx_drops = err_stats.tnl_tx_drops[i];
415-
s->ofld_vlan_drops = err_stats.ofld_vlan_drops[i];
416-
s->ofld_chan_drops = err_stats.ofld_chan_drops[i];
417-
s->octets_ddp = fcoe_stats.octets_ddp;
418-
s->frames_ddp = fcoe_stats.frames_ddp;
419-
s->frames_drop = fcoe_stats.frames_drop;
420-
}
421-
422294
static void get_stats(struct net_device *dev, struct ethtool_stats *stats,
423295
u64 *data)
424296
{
@@ -438,11 +310,6 @@ static void get_stats(struct net_device *dev, struct ethtool_stats *stats,
438310
collect_adapter_stats(adapter, (struct adapter_stats *)data);
439311
data += sizeof(struct adapter_stats) / sizeof(u64);
440312

441-
*data++ = (u64)pi->port_id;
442-
collect_channel_stats(adapter, (struct channel_stats *)data,
443-
pi->port_id);
444-
data += sizeof(struct channel_stats) / sizeof(u64);
445-
446313
*data++ = (u64)pi->port_id;
447314
memset(&s, 0, sizeof(s));
448315
t4_get_lb_stats(adapter, pi->port_id, &s);

0 commit comments

Comments
 (0)