mac80211: backport latest patches except for NVRAM support
[openwrt/openwrt.git] / package / kernel / mac80211 / patches / 314-brcmfmac-add-debugfs-entry-for-msgbuf-statistics.patch
1 From: Franky Lin <frankyl@broadcom.com>
2 Date: Thu, 20 Aug 2015 22:06:04 +0200
3 Subject: [PATCH] brcmfmac: add debugfs entry for msgbuf statistics
4
5 Expose ring buffer read/write pointers and other useful statistics
6 through debugfs.
7
8 Reviewed-by: Arend Van Spriel <arend@broadcom.com>
9 Reviewed-by: Hante Meuleman <meuleman@broadcom.com>
10 Reviewed-by: Pieter-Paul Giesberts <pieterpg@broadcom.com>
11 Signed-off-by: Franky Lin <frankyl@broadcom.com>
12 Signed-off-by: Arend van Spriel <arend@broadcom.com>
13 Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
14 ---
15
16 --- a/drivers/net/wireless/brcm80211/brcmfmac/msgbuf.c
17 +++ b/drivers/net/wireless/brcm80211/brcmfmac/msgbuf.c
18 @@ -1360,6 +1360,60 @@ void brcmf_msgbuf_delete_flowring(struct
19 }
20 }
21
22 +#ifdef DEBUG
23 +static int brcmf_msgbuf_stats_read(struct seq_file *seq, void *data)
24 +{
25 + struct brcmf_bus *bus_if = dev_get_drvdata(seq->private);
26 + struct brcmf_pub *drvr = bus_if->drvr;
27 + struct brcmf_msgbuf *msgbuf = (struct brcmf_msgbuf *)drvr->proto->pd;
28 + struct brcmf_commonring *commonring;
29 + u16 i;
30 + struct brcmf_flowring_ring *ring;
31 + struct brcmf_flowring_hash *hash;
32 +
33 + commonring = msgbuf->commonrings[BRCMF_H2D_MSGRING_CONTROL_SUBMIT];
34 + seq_printf(seq, "h2d_ctl_submit: rp %4u, wp %4u, depth %4u\n",
35 + commonring->r_ptr, commonring->w_ptr, commonring->depth);
36 + commonring = msgbuf->commonrings[BRCMF_H2D_MSGRING_RXPOST_SUBMIT];
37 + seq_printf(seq, "h2d_rx_submit: rp %4u, wp %4u, depth %4u\n",
38 + commonring->r_ptr, commonring->w_ptr, commonring->depth);
39 + commonring = msgbuf->commonrings[BRCMF_D2H_MSGRING_CONTROL_COMPLETE];
40 + seq_printf(seq, "d2h_ctl_cmplt: rp %4u, wp %4u, depth %4u\n",
41 + commonring->r_ptr, commonring->w_ptr, commonring->depth);
42 + commonring = msgbuf->commonrings[BRCMF_D2H_MSGRING_TX_COMPLETE];
43 + seq_printf(seq, "d2h_tx_cmplt: rp %4u, wp %4u, depth %4u\n",
44 + commonring->r_ptr, commonring->w_ptr, commonring->depth);
45 + commonring = msgbuf->commonrings[BRCMF_D2H_MSGRING_RX_COMPLETE];
46 + seq_printf(seq, "d2h_rx_cmplt: rp %4u, wp %4u, depth %4u\n",
47 + commonring->r_ptr, commonring->w_ptr, commonring->depth);
48 +
49 + seq_printf(seq, "\nh2d_flowrings: depth %u\n",
50 + BRCMF_H2D_TXFLOWRING_MAX_ITEM);
51 + seq_puts(seq, "Active flowrings:\n");
52 + hash = msgbuf->flow->hash;
53 + for (i = 0; i < msgbuf->flow->nrofrings; i++) {
54 + if (!msgbuf->flow->rings[i])
55 + continue;
56 + ring = msgbuf->flow->rings[i];
57 + if (ring->status != RING_OPEN)
58 + continue;
59 + commonring = msgbuf->flowrings[i];
60 + hash = &msgbuf->flow->hash[ring->hash_id];
61 + seq_printf(seq, "id %3u: rp %4u, wp %4u, qlen %4u, blocked %u\n"
62 + " ifidx %u, fifo %u, da %pM\n",
63 + i, commonring->r_ptr, commonring->w_ptr,
64 + skb_queue_len(&ring->skblist), ring->blocked,
65 + hash->ifidx, hash->fifo, hash->mac);
66 + }
67 +
68 + return 0;
69 +}
70 +#else
71 +static int brcmf_msgbuf_stats_read(struct seq_file *seq, void *data)
72 +{
73 + return 0;
74 +}
75 +#endif
76
77 int brcmf_proto_msgbuf_attach(struct brcmf_pub *drvr)
78 {
79 @@ -1460,6 +1514,8 @@ int brcmf_proto_msgbuf_attach(struct brc
80 spin_lock_init(&msgbuf->flowring_work_lock);
81 INIT_LIST_HEAD(&msgbuf->work_queue);
82
83 + brcmf_debugfs_add_entry(drvr, "msgbuf_stats", brcmf_msgbuf_stats_read);
84 +
85 return 0;
86
87 fail: