123205e6dSChristina Jacob // SPDX-License-Identifier: GPL-2.0
2c7cd6c5aSSunil Goutham /* Marvell RVU Admin Function driver
323205e6dSChristina Jacob *
4c7cd6c5aSSunil Goutham * Copyright (C) 2019 Marvell.
523205e6dSChristina Jacob *
623205e6dSChristina Jacob */
723205e6dSChristina Jacob
823205e6dSChristina Jacob #ifdef CONFIG_DEBUG_FS
923205e6dSChristina Jacob
1023205e6dSChristina Jacob #include <linux/fs.h>
1123205e6dSChristina Jacob #include <linux/debugfs.h>
1223205e6dSChristina Jacob #include <linux/module.h>
1323205e6dSChristina Jacob #include <linux/pci.h>
1423205e6dSChristina Jacob
1523205e6dSChristina Jacob #include "rvu_struct.h"
1623205e6dSChristina Jacob #include "rvu_reg.h"
1723205e6dSChristina Jacob #include "rvu.h"
18c57211b5SPrakash Brahmajyosyula #include "cgx.h"
1991c6945eSHariprasad Kelam #include "lmac_common.h"
20e07fb507SSunil Goutham #include "npc.h"
2187e4ea29SRatheesh Kannoth #include "rvu_npc_hash.h"
22d06c2abaSGeetha sowjanya #include "mcs.h"
2323205e6dSChristina Jacob
2423205e6dSChristina Jacob #define DEBUGFS_DIR_NAME "octeontx2"
2523205e6dSChristina Jacob
26c57211b5SPrakash Brahmajyosyula enum {
27c57211b5SPrakash Brahmajyosyula CGX_STAT0,
28c57211b5SPrakash Brahmajyosyula CGX_STAT1,
29c57211b5SPrakash Brahmajyosyula CGX_STAT2,
30c57211b5SPrakash Brahmajyosyula CGX_STAT3,
31c57211b5SPrakash Brahmajyosyula CGX_STAT4,
32c57211b5SPrakash Brahmajyosyula CGX_STAT5,
33c57211b5SPrakash Brahmajyosyula CGX_STAT6,
34c57211b5SPrakash Brahmajyosyula CGX_STAT7,
35c57211b5SPrakash Brahmajyosyula CGX_STAT8,
36c57211b5SPrakash Brahmajyosyula CGX_STAT9,
37c57211b5SPrakash Brahmajyosyula CGX_STAT10,
38c57211b5SPrakash Brahmajyosyula CGX_STAT11,
39c57211b5SPrakash Brahmajyosyula CGX_STAT12,
40c57211b5SPrakash Brahmajyosyula CGX_STAT13,
41c57211b5SPrakash Brahmajyosyula CGX_STAT14,
42c57211b5SPrakash Brahmajyosyula CGX_STAT15,
43c57211b5SPrakash Brahmajyosyula CGX_STAT16,
44c57211b5SPrakash Brahmajyosyula CGX_STAT17,
45c57211b5SPrakash Brahmajyosyula CGX_STAT18,
46c57211b5SPrakash Brahmajyosyula };
47c57211b5SPrakash Brahmajyosyula
48f967488dSLinu Cherian /* NIX TX stats */
49f967488dSLinu Cherian enum nix_stat_lf_tx {
50f967488dSLinu Cherian TX_UCAST = 0x0,
51f967488dSLinu Cherian TX_BCAST = 0x1,
52f967488dSLinu Cherian TX_MCAST = 0x2,
53f967488dSLinu Cherian TX_DROP = 0x3,
54f967488dSLinu Cherian TX_OCTS = 0x4,
55f967488dSLinu Cherian TX_STATS_ENUM_LAST,
56f967488dSLinu Cherian };
57f967488dSLinu Cherian
58f967488dSLinu Cherian /* NIX RX stats */
59f967488dSLinu Cherian enum nix_stat_lf_rx {
60f967488dSLinu Cherian RX_OCTS = 0x0,
61f967488dSLinu Cherian RX_UCAST = 0x1,
62f967488dSLinu Cherian RX_BCAST = 0x2,
63f967488dSLinu Cherian RX_MCAST = 0x3,
64f967488dSLinu Cherian RX_DROP = 0x4,
65f967488dSLinu Cherian RX_DROP_OCTS = 0x5,
66f967488dSLinu Cherian RX_FCS = 0x6,
67f967488dSLinu Cherian RX_ERR = 0x7,
68f967488dSLinu Cherian RX_DRP_BCAST = 0x8,
69f967488dSLinu Cherian RX_DRP_MCAST = 0x9,
70f967488dSLinu Cherian RX_DRP_L3BCAST = 0xa,
71f967488dSLinu Cherian RX_DRP_L3MCAST = 0xb,
72f967488dSLinu Cherian RX_STATS_ENUM_LAST,
73f967488dSLinu Cherian };
74f967488dSLinu Cherian
75c57211b5SPrakash Brahmajyosyula static char *cgx_rx_stats_fields[] = {
76c57211b5SPrakash Brahmajyosyula [CGX_STAT0] = "Received packets",
77c57211b5SPrakash Brahmajyosyula [CGX_STAT1] = "Octets of received packets",
78c57211b5SPrakash Brahmajyosyula [CGX_STAT2] = "Received PAUSE packets",
79c57211b5SPrakash Brahmajyosyula [CGX_STAT3] = "Received PAUSE and control packets",
80c57211b5SPrakash Brahmajyosyula [CGX_STAT4] = "Filtered DMAC0 (NIX-bound) packets",
81c57211b5SPrakash Brahmajyosyula [CGX_STAT5] = "Filtered DMAC0 (NIX-bound) octets",
82c57211b5SPrakash Brahmajyosyula [CGX_STAT6] = "Packets dropped due to RX FIFO full",
83c57211b5SPrakash Brahmajyosyula [CGX_STAT7] = "Octets dropped due to RX FIFO full",
84c57211b5SPrakash Brahmajyosyula [CGX_STAT8] = "Error packets",
85c57211b5SPrakash Brahmajyosyula [CGX_STAT9] = "Filtered DMAC1 (NCSI-bound) packets",
86c57211b5SPrakash Brahmajyosyula [CGX_STAT10] = "Filtered DMAC1 (NCSI-bound) octets",
87c57211b5SPrakash Brahmajyosyula [CGX_STAT11] = "NCSI-bound packets dropped",
88c57211b5SPrakash Brahmajyosyula [CGX_STAT12] = "NCSI-bound octets dropped",
89c57211b5SPrakash Brahmajyosyula };
90c57211b5SPrakash Brahmajyosyula
91c57211b5SPrakash Brahmajyosyula static char *cgx_tx_stats_fields[] = {
92c57211b5SPrakash Brahmajyosyula [CGX_STAT0] = "Packets dropped due to excessive collisions",
93c57211b5SPrakash Brahmajyosyula [CGX_STAT1] = "Packets dropped due to excessive deferral",
94c57211b5SPrakash Brahmajyosyula [CGX_STAT2] = "Multiple collisions before successful transmission",
95c57211b5SPrakash Brahmajyosyula [CGX_STAT3] = "Single collisions before successful transmission",
96c57211b5SPrakash Brahmajyosyula [CGX_STAT4] = "Total octets sent on the interface",
97c57211b5SPrakash Brahmajyosyula [CGX_STAT5] = "Total frames sent on the interface",
98c57211b5SPrakash Brahmajyosyula [CGX_STAT6] = "Packets sent with an octet count < 64",
99c57211b5SPrakash Brahmajyosyula [CGX_STAT7] = "Packets sent with an octet count == 64",
1001910ccf0SRakesh Babu Saladi [CGX_STAT8] = "Packets sent with an octet count of 65-127",
101c57211b5SPrakash Brahmajyosyula [CGX_STAT9] = "Packets sent with an octet count of 128-255",
102c57211b5SPrakash Brahmajyosyula [CGX_STAT10] = "Packets sent with an octet count of 256-511",
103c57211b5SPrakash Brahmajyosyula [CGX_STAT11] = "Packets sent with an octet count of 512-1023",
104c57211b5SPrakash Brahmajyosyula [CGX_STAT12] = "Packets sent with an octet count of 1024-1518",
105c57211b5SPrakash Brahmajyosyula [CGX_STAT13] = "Packets sent with an octet count of > 1518",
106c57211b5SPrakash Brahmajyosyula [CGX_STAT14] = "Packets sent to a broadcast DMAC",
107c57211b5SPrakash Brahmajyosyula [CGX_STAT15] = "Packets sent to the multicast DMAC",
108c57211b5SPrakash Brahmajyosyula [CGX_STAT16] = "Transmit underflow and were truncated",
109c57211b5SPrakash Brahmajyosyula [CGX_STAT17] = "Control/PAUSE packets sent",
110c57211b5SPrakash Brahmajyosyula };
111c57211b5SPrakash Brahmajyosyula
112ce7a6c31SHariprasad Kelam static char *rpm_rx_stats_fields[] = {
113ce7a6c31SHariprasad Kelam "Octets of received packets",
114ce7a6c31SHariprasad Kelam "Octets of received packets with out error",
115ce7a6c31SHariprasad Kelam "Received packets with alignment errors",
116ce7a6c31SHariprasad Kelam "Control/PAUSE packets received",
117ce7a6c31SHariprasad Kelam "Packets received with Frame too long Errors",
118ce7a6c31SHariprasad Kelam "Packets received with a1nrange length Errors",
119ce7a6c31SHariprasad Kelam "Received packets",
120ce7a6c31SHariprasad Kelam "Packets received with FrameCheckSequenceErrors",
121ce7a6c31SHariprasad Kelam "Packets received with VLAN header",
122ce7a6c31SHariprasad Kelam "Error packets",
123a6e0ee35SColin Ian King "Packets received with unicast DMAC",
124ce7a6c31SHariprasad Kelam "Packets received with multicast DMAC",
125ce7a6c31SHariprasad Kelam "Packets received with broadcast DMAC",
126ce7a6c31SHariprasad Kelam "Dropped packets",
127ce7a6c31SHariprasad Kelam "Total frames received on interface",
128ce7a6c31SHariprasad Kelam "Packets received with an octet count < 64",
129ce7a6c31SHariprasad Kelam "Packets received with an octet count == 64",
1301910ccf0SRakesh Babu Saladi "Packets received with an octet count of 65-127",
131ce7a6c31SHariprasad Kelam "Packets received with an octet count of 128-255",
132ce7a6c31SHariprasad Kelam "Packets received with an octet count of 256-511",
133ce7a6c31SHariprasad Kelam "Packets received with an octet count of 512-1023",
134ce7a6c31SHariprasad Kelam "Packets received with an octet count of 1024-1518",
135ce7a6c31SHariprasad Kelam "Packets received with an octet count of > 1518",
136ce7a6c31SHariprasad Kelam "Oversized Packets",
137ce7a6c31SHariprasad Kelam "Jabber Packets",
138ce7a6c31SHariprasad Kelam "Fragmented Packets",
139ce7a6c31SHariprasad Kelam "CBFC(class based flow control) pause frames received for class 0",
140ce7a6c31SHariprasad Kelam "CBFC pause frames received for class 1",
141ce7a6c31SHariprasad Kelam "CBFC pause frames received for class 2",
142ce7a6c31SHariprasad Kelam "CBFC pause frames received for class 3",
143ce7a6c31SHariprasad Kelam "CBFC pause frames received for class 4",
144ce7a6c31SHariprasad Kelam "CBFC pause frames received for class 5",
145ce7a6c31SHariprasad Kelam "CBFC pause frames received for class 6",
146ce7a6c31SHariprasad Kelam "CBFC pause frames received for class 7",
147ce7a6c31SHariprasad Kelam "CBFC pause frames received for class 8",
148ce7a6c31SHariprasad Kelam "CBFC pause frames received for class 9",
149ce7a6c31SHariprasad Kelam "CBFC pause frames received for class 10",
150ce7a6c31SHariprasad Kelam "CBFC pause frames received for class 11",
151ce7a6c31SHariprasad Kelam "CBFC pause frames received for class 12",
152ce7a6c31SHariprasad Kelam "CBFC pause frames received for class 13",
153ce7a6c31SHariprasad Kelam "CBFC pause frames received for class 14",
154ce7a6c31SHariprasad Kelam "CBFC pause frames received for class 15",
155ce7a6c31SHariprasad Kelam "MAC control packets received",
156ce7a6c31SHariprasad Kelam };
157ce7a6c31SHariprasad Kelam
158ce7a6c31SHariprasad Kelam static char *rpm_tx_stats_fields[] = {
159ce7a6c31SHariprasad Kelam "Total octets sent on the interface",
160ce7a6c31SHariprasad Kelam "Total octets transmitted OK",
161ce7a6c31SHariprasad Kelam "Control/Pause frames sent",
162ce7a6c31SHariprasad Kelam "Total frames transmitted OK",
163ce7a6c31SHariprasad Kelam "Total frames sent with VLAN header",
164ce7a6c31SHariprasad Kelam "Error Packets",
165ce7a6c31SHariprasad Kelam "Packets sent to unicast DMAC",
166ce7a6c31SHariprasad Kelam "Packets sent to the multicast DMAC",
167ce7a6c31SHariprasad Kelam "Packets sent to a broadcast DMAC",
168ce7a6c31SHariprasad Kelam "Packets sent with an octet count == 64",
1691910ccf0SRakesh Babu Saladi "Packets sent with an octet count of 65-127",
170ce7a6c31SHariprasad Kelam "Packets sent with an octet count of 128-255",
171ce7a6c31SHariprasad Kelam "Packets sent with an octet count of 256-511",
172ce7a6c31SHariprasad Kelam "Packets sent with an octet count of 512-1023",
173ce7a6c31SHariprasad Kelam "Packets sent with an octet count of 1024-1518",
174ce7a6c31SHariprasad Kelam "Packets sent with an octet count of > 1518",
175ce7a6c31SHariprasad Kelam "CBFC(class based flow control) pause frames transmitted for class 0",
176ce7a6c31SHariprasad Kelam "CBFC pause frames transmitted for class 1",
177ce7a6c31SHariprasad Kelam "CBFC pause frames transmitted for class 2",
178ce7a6c31SHariprasad Kelam "CBFC pause frames transmitted for class 3",
179ce7a6c31SHariprasad Kelam "CBFC pause frames transmitted for class 4",
180ce7a6c31SHariprasad Kelam "CBFC pause frames transmitted for class 5",
181ce7a6c31SHariprasad Kelam "CBFC pause frames transmitted for class 6",
182ce7a6c31SHariprasad Kelam "CBFC pause frames transmitted for class 7",
183ce7a6c31SHariprasad Kelam "CBFC pause frames transmitted for class 8",
184ce7a6c31SHariprasad Kelam "CBFC pause frames transmitted for class 9",
185ce7a6c31SHariprasad Kelam "CBFC pause frames transmitted for class 10",
186ce7a6c31SHariprasad Kelam "CBFC pause frames transmitted for class 11",
187ce7a6c31SHariprasad Kelam "CBFC pause frames transmitted for class 12",
188ce7a6c31SHariprasad Kelam "CBFC pause frames transmitted for class 13",
189ce7a6c31SHariprasad Kelam "CBFC pause frames transmitted for class 14",
190ce7a6c31SHariprasad Kelam "CBFC pause frames transmitted for class 15",
191ce7a6c31SHariprasad Kelam "MAC control packets sent",
192ce7a6c31SHariprasad Kelam "Total frames sent on the interface"
193ce7a6c31SHariprasad Kelam };
194ce7a6c31SHariprasad Kelam
19576638a2eSSrujana Challa enum cpt_eng_type {
19676638a2eSSrujana Challa CPT_AE_TYPE = 1,
19776638a2eSSrujana Challa CPT_SE_TYPE = 2,
19876638a2eSSrujana Challa CPT_IE_TYPE = 3,
19976638a2eSSrujana Challa };
20076638a2eSSrujana Challa
20123205e6dSChristina Jacob #define rvu_dbg_NULL NULL
2028756828aSChristina Jacob #define rvu_dbg_open_NULL NULL
2038756828aSChristina Jacob
2048756828aSChristina Jacob #define RVU_DEBUG_SEQ_FOPS(name, read_op, write_op) \
2058756828aSChristina Jacob static int rvu_dbg_open_##name(struct inode *inode, struct file *file) \
2068756828aSChristina Jacob { \
2078756828aSChristina Jacob return single_open(file, rvu_dbg_##read_op, inode->i_private); \
2088756828aSChristina Jacob } \
2098756828aSChristina Jacob static const struct file_operations rvu_dbg_##name##_fops = { \
2108756828aSChristina Jacob .owner = THIS_MODULE, \
2118756828aSChristina Jacob .open = rvu_dbg_open_##name, \
2128756828aSChristina Jacob .read = seq_read, \
2138756828aSChristina Jacob .write = rvu_dbg_##write_op, \
2148756828aSChristina Jacob .llseek = seq_lseek, \
2158756828aSChristina Jacob .release = single_release, \
2168756828aSChristina Jacob }
21723205e6dSChristina Jacob
21823205e6dSChristina Jacob #define RVU_DEBUG_FOPS(name, read_op, write_op) \
21923205e6dSChristina Jacob static const struct file_operations rvu_dbg_##name##_fops = { \
22023205e6dSChristina Jacob .owner = THIS_MODULE, \
22123205e6dSChristina Jacob .open = simple_open, \
22223205e6dSChristina Jacob .read = rvu_dbg_##read_op, \
22323205e6dSChristina Jacob .write = rvu_dbg_##write_op \
22423205e6dSChristina Jacob }
22523205e6dSChristina Jacob
22602e202c3SPrakash Brahmajyosyula static void print_nix_qsize(struct seq_file *filp, struct rvu_pfvf *pfvf);
22702e202c3SPrakash Brahmajyosyula
rvu_dbg_mcs_port_stats_display(struct seq_file * filp,void * unused,int dir)228d06c2abaSGeetha sowjanya static int rvu_dbg_mcs_port_stats_display(struct seq_file *filp, void *unused, int dir)
229d06c2abaSGeetha sowjanya {
230d06c2abaSGeetha sowjanya struct mcs *mcs = filp->private;
231d06c2abaSGeetha sowjanya struct mcs_port_stats stats;
232d06c2abaSGeetha sowjanya int lmac;
233d06c2abaSGeetha sowjanya
234d06c2abaSGeetha sowjanya seq_puts(filp, "\n port stats\n");
235d06c2abaSGeetha sowjanya mutex_lock(&mcs->stats_lock);
236d06c2abaSGeetha sowjanya for_each_set_bit(lmac, &mcs->hw->lmac_bmap, mcs->hw->lmac_cnt) {
237d06c2abaSGeetha sowjanya mcs_get_port_stats(mcs, &stats, lmac, dir);
238d06c2abaSGeetha sowjanya seq_printf(filp, "port%d: Tcam Miss: %lld\n", lmac, stats.tcam_miss_cnt);
239d06c2abaSGeetha sowjanya seq_printf(filp, "port%d: Parser errors: %lld\n", lmac, stats.parser_err_cnt);
240d06c2abaSGeetha sowjanya
241d06c2abaSGeetha sowjanya if (dir == MCS_RX && mcs->hw->mcs_blks > 1)
242d06c2abaSGeetha sowjanya seq_printf(filp, "port%d: Preempt error: %lld\n", lmac,
243d06c2abaSGeetha sowjanya stats.preempt_err_cnt);
244d06c2abaSGeetha sowjanya if (dir == MCS_TX)
245d06c2abaSGeetha sowjanya seq_printf(filp, "port%d: Sectag insert error: %lld\n", lmac,
246d06c2abaSGeetha sowjanya stats.sectag_insert_err_cnt);
247d06c2abaSGeetha sowjanya }
248d06c2abaSGeetha sowjanya mutex_unlock(&mcs->stats_lock);
249d06c2abaSGeetha sowjanya return 0;
250d06c2abaSGeetha sowjanya }
251d06c2abaSGeetha sowjanya
rvu_dbg_mcs_rx_port_stats_display(struct seq_file * filp,void * unused)252d06c2abaSGeetha sowjanya static int rvu_dbg_mcs_rx_port_stats_display(struct seq_file *filp, void *unused)
253d06c2abaSGeetha sowjanya {
254d06c2abaSGeetha sowjanya return rvu_dbg_mcs_port_stats_display(filp, unused, MCS_RX);
255d06c2abaSGeetha sowjanya }
256d06c2abaSGeetha sowjanya
257d06c2abaSGeetha sowjanya RVU_DEBUG_SEQ_FOPS(mcs_rx_port_stats, mcs_rx_port_stats_display, NULL);
258d06c2abaSGeetha sowjanya
rvu_dbg_mcs_tx_port_stats_display(struct seq_file * filp,void * unused)259d06c2abaSGeetha sowjanya static int rvu_dbg_mcs_tx_port_stats_display(struct seq_file *filp, void *unused)
260d06c2abaSGeetha sowjanya {
261d06c2abaSGeetha sowjanya return rvu_dbg_mcs_port_stats_display(filp, unused, MCS_TX);
262d06c2abaSGeetha sowjanya }
263d06c2abaSGeetha sowjanya
264d06c2abaSGeetha sowjanya RVU_DEBUG_SEQ_FOPS(mcs_tx_port_stats, mcs_tx_port_stats_display, NULL);
265d06c2abaSGeetha sowjanya
rvu_dbg_mcs_sa_stats_display(struct seq_file * filp,void * unused,int dir)266d06c2abaSGeetha sowjanya static int rvu_dbg_mcs_sa_stats_display(struct seq_file *filp, void *unused, int dir)
267d06c2abaSGeetha sowjanya {
268d06c2abaSGeetha sowjanya struct mcs *mcs = filp->private;
269d06c2abaSGeetha sowjanya struct mcs_sa_stats stats;
270d06c2abaSGeetha sowjanya struct rsrc_bmap *map;
271d06c2abaSGeetha sowjanya int sa_id;
272d06c2abaSGeetha sowjanya
273d06c2abaSGeetha sowjanya if (dir == MCS_TX) {
274d06c2abaSGeetha sowjanya map = &mcs->tx.sa;
275d06c2abaSGeetha sowjanya mutex_lock(&mcs->stats_lock);
276d06c2abaSGeetha sowjanya for_each_set_bit(sa_id, map->bmap, mcs->hw->sa_entries) {
277d06c2abaSGeetha sowjanya seq_puts(filp, "\n TX SA stats\n");
278d06c2abaSGeetha sowjanya mcs_get_sa_stats(mcs, &stats, sa_id, MCS_TX);
279d06c2abaSGeetha sowjanya seq_printf(filp, "sa%d: Pkts encrypted: %lld\n", sa_id,
280d06c2abaSGeetha sowjanya stats.pkt_encrypt_cnt);
281d06c2abaSGeetha sowjanya
282d06c2abaSGeetha sowjanya seq_printf(filp, "sa%d: Pkts protected: %lld\n", sa_id,
283d06c2abaSGeetha sowjanya stats.pkt_protected_cnt);
284d06c2abaSGeetha sowjanya }
285d06c2abaSGeetha sowjanya mutex_unlock(&mcs->stats_lock);
286d06c2abaSGeetha sowjanya return 0;
287d06c2abaSGeetha sowjanya }
288d06c2abaSGeetha sowjanya
289d06c2abaSGeetha sowjanya /* RX stats */
290d06c2abaSGeetha sowjanya map = &mcs->rx.sa;
291d06c2abaSGeetha sowjanya mutex_lock(&mcs->stats_lock);
292d06c2abaSGeetha sowjanya for_each_set_bit(sa_id, map->bmap, mcs->hw->sa_entries) {
293d06c2abaSGeetha sowjanya seq_puts(filp, "\n RX SA stats\n");
294d06c2abaSGeetha sowjanya mcs_get_sa_stats(mcs, &stats, sa_id, MCS_RX);
295d06c2abaSGeetha sowjanya seq_printf(filp, "sa%d: Invalid pkts: %lld\n", sa_id, stats.pkt_invalid_cnt);
296d06c2abaSGeetha sowjanya seq_printf(filp, "sa%d: Pkts no sa error: %lld\n", sa_id, stats.pkt_nosaerror_cnt);
297d06c2abaSGeetha sowjanya seq_printf(filp, "sa%d: Pkts not valid: %lld\n", sa_id, stats.pkt_notvalid_cnt);
298d06c2abaSGeetha sowjanya seq_printf(filp, "sa%d: Pkts ok: %lld\n", sa_id, stats.pkt_ok_cnt);
299d06c2abaSGeetha sowjanya seq_printf(filp, "sa%d: Pkts no sa: %lld\n", sa_id, stats.pkt_nosa_cnt);
300d06c2abaSGeetha sowjanya }
301d06c2abaSGeetha sowjanya mutex_unlock(&mcs->stats_lock);
302d06c2abaSGeetha sowjanya return 0;
303d06c2abaSGeetha sowjanya }
304d06c2abaSGeetha sowjanya
rvu_dbg_mcs_rx_sa_stats_display(struct seq_file * filp,void * unused)305d06c2abaSGeetha sowjanya static int rvu_dbg_mcs_rx_sa_stats_display(struct seq_file *filp, void *unused)
306d06c2abaSGeetha sowjanya {
307d06c2abaSGeetha sowjanya return rvu_dbg_mcs_sa_stats_display(filp, unused, MCS_RX);
308d06c2abaSGeetha sowjanya }
309d06c2abaSGeetha sowjanya
310d06c2abaSGeetha sowjanya RVU_DEBUG_SEQ_FOPS(mcs_rx_sa_stats, mcs_rx_sa_stats_display, NULL);
311d06c2abaSGeetha sowjanya
rvu_dbg_mcs_tx_sa_stats_display(struct seq_file * filp,void * unused)312d06c2abaSGeetha sowjanya static int rvu_dbg_mcs_tx_sa_stats_display(struct seq_file *filp, void *unused)
313d06c2abaSGeetha sowjanya {
314d06c2abaSGeetha sowjanya return rvu_dbg_mcs_sa_stats_display(filp, unused, MCS_TX);
315d06c2abaSGeetha sowjanya }
316d06c2abaSGeetha sowjanya
317d06c2abaSGeetha sowjanya RVU_DEBUG_SEQ_FOPS(mcs_tx_sa_stats, mcs_tx_sa_stats_display, NULL);
318d06c2abaSGeetha sowjanya
rvu_dbg_mcs_tx_sc_stats_display(struct seq_file * filp,void * unused)319d06c2abaSGeetha sowjanya static int rvu_dbg_mcs_tx_sc_stats_display(struct seq_file *filp, void *unused)
320d06c2abaSGeetha sowjanya {
321d06c2abaSGeetha sowjanya struct mcs *mcs = filp->private;
322d06c2abaSGeetha sowjanya struct mcs_sc_stats stats;
323d06c2abaSGeetha sowjanya struct rsrc_bmap *map;
324d06c2abaSGeetha sowjanya int sc_id;
325d06c2abaSGeetha sowjanya
326d06c2abaSGeetha sowjanya map = &mcs->tx.sc;
327d06c2abaSGeetha sowjanya seq_puts(filp, "\n SC stats\n");
328d06c2abaSGeetha sowjanya
329d06c2abaSGeetha sowjanya mutex_lock(&mcs->stats_lock);
330d06c2abaSGeetha sowjanya for_each_set_bit(sc_id, map->bmap, mcs->hw->sc_entries) {
331d06c2abaSGeetha sowjanya mcs_get_sc_stats(mcs, &stats, sc_id, MCS_TX);
332d06c2abaSGeetha sowjanya seq_printf(filp, "\n=======sc%d======\n\n", sc_id);
333d06c2abaSGeetha sowjanya seq_printf(filp, "sc%d: Pkts encrypted: %lld\n", sc_id, stats.pkt_encrypt_cnt);
334d06c2abaSGeetha sowjanya seq_printf(filp, "sc%d: Pkts protected: %lld\n", sc_id, stats.pkt_protected_cnt);
335d06c2abaSGeetha sowjanya
336d06c2abaSGeetha sowjanya if (mcs->hw->mcs_blks == 1) {
337d06c2abaSGeetha sowjanya seq_printf(filp, "sc%d: Octets encrypted: %lld\n", sc_id,
338d06c2abaSGeetha sowjanya stats.octet_encrypt_cnt);
339d06c2abaSGeetha sowjanya seq_printf(filp, "sc%d: Octets protected: %lld\n", sc_id,
340d06c2abaSGeetha sowjanya stats.octet_protected_cnt);
341d06c2abaSGeetha sowjanya }
342d06c2abaSGeetha sowjanya }
343d06c2abaSGeetha sowjanya mutex_unlock(&mcs->stats_lock);
344d06c2abaSGeetha sowjanya return 0;
345d06c2abaSGeetha sowjanya }
346d06c2abaSGeetha sowjanya
347d06c2abaSGeetha sowjanya RVU_DEBUG_SEQ_FOPS(mcs_tx_sc_stats, mcs_tx_sc_stats_display, NULL);
348d06c2abaSGeetha sowjanya
rvu_dbg_mcs_rx_sc_stats_display(struct seq_file * filp,void * unused)349d06c2abaSGeetha sowjanya static int rvu_dbg_mcs_rx_sc_stats_display(struct seq_file *filp, void *unused)
350d06c2abaSGeetha sowjanya {
351d06c2abaSGeetha sowjanya struct mcs *mcs = filp->private;
352d06c2abaSGeetha sowjanya struct mcs_sc_stats stats;
353d06c2abaSGeetha sowjanya struct rsrc_bmap *map;
354d06c2abaSGeetha sowjanya int sc_id;
355d06c2abaSGeetha sowjanya
356d06c2abaSGeetha sowjanya map = &mcs->rx.sc;
357d06c2abaSGeetha sowjanya seq_puts(filp, "\n SC stats\n");
358d06c2abaSGeetha sowjanya
359d06c2abaSGeetha sowjanya mutex_lock(&mcs->stats_lock);
360d06c2abaSGeetha sowjanya for_each_set_bit(sc_id, map->bmap, mcs->hw->sc_entries) {
361d06c2abaSGeetha sowjanya mcs_get_sc_stats(mcs, &stats, sc_id, MCS_RX);
362d06c2abaSGeetha sowjanya seq_printf(filp, "\n=======sc%d======\n\n", sc_id);
363d06c2abaSGeetha sowjanya seq_printf(filp, "sc%d: Cam hits: %lld\n", sc_id, stats.hit_cnt);
364d06c2abaSGeetha sowjanya seq_printf(filp, "sc%d: Invalid pkts: %lld\n", sc_id, stats.pkt_invalid_cnt);
365d06c2abaSGeetha sowjanya seq_printf(filp, "sc%d: Late pkts: %lld\n", sc_id, stats.pkt_late_cnt);
366d06c2abaSGeetha sowjanya seq_printf(filp, "sc%d: Notvalid pkts: %lld\n", sc_id, stats.pkt_notvalid_cnt);
367d06c2abaSGeetha sowjanya seq_printf(filp, "sc%d: Unchecked pkts: %lld\n", sc_id, stats.pkt_unchecked_cnt);
368d06c2abaSGeetha sowjanya
369d06c2abaSGeetha sowjanya if (mcs->hw->mcs_blks > 1) {
370d06c2abaSGeetha sowjanya seq_printf(filp, "sc%d: Delay pkts: %lld\n", sc_id, stats.pkt_delay_cnt);
371d06c2abaSGeetha sowjanya seq_printf(filp, "sc%d: Pkts ok: %lld\n", sc_id, stats.pkt_ok_cnt);
372d06c2abaSGeetha sowjanya }
373d06c2abaSGeetha sowjanya if (mcs->hw->mcs_blks == 1) {
374d06c2abaSGeetha sowjanya seq_printf(filp, "sc%d: Octets decrypted: %lld\n", sc_id,
375d06c2abaSGeetha sowjanya stats.octet_decrypt_cnt);
376d06c2abaSGeetha sowjanya seq_printf(filp, "sc%d: Octets validated: %lld\n", sc_id,
377d06c2abaSGeetha sowjanya stats.octet_validate_cnt);
378d06c2abaSGeetha sowjanya }
379d06c2abaSGeetha sowjanya }
380d06c2abaSGeetha sowjanya mutex_unlock(&mcs->stats_lock);
381d06c2abaSGeetha sowjanya return 0;
382d06c2abaSGeetha sowjanya }
383d06c2abaSGeetha sowjanya
384d06c2abaSGeetha sowjanya RVU_DEBUG_SEQ_FOPS(mcs_rx_sc_stats, mcs_rx_sc_stats_display, NULL);
385d06c2abaSGeetha sowjanya
rvu_dbg_mcs_flowid_stats_display(struct seq_file * filp,void * unused,int dir)386d06c2abaSGeetha sowjanya static int rvu_dbg_mcs_flowid_stats_display(struct seq_file *filp, void *unused, int dir)
387d06c2abaSGeetha sowjanya {
388d06c2abaSGeetha sowjanya struct mcs *mcs = filp->private;
389d06c2abaSGeetha sowjanya struct mcs_flowid_stats stats;
390d06c2abaSGeetha sowjanya struct rsrc_bmap *map;
391d06c2abaSGeetha sowjanya int flow_id;
392d06c2abaSGeetha sowjanya
393d06c2abaSGeetha sowjanya seq_puts(filp, "\n Flowid stats\n");
394d06c2abaSGeetha sowjanya
395d06c2abaSGeetha sowjanya if (dir == MCS_RX)
396d06c2abaSGeetha sowjanya map = &mcs->rx.flow_ids;
397d06c2abaSGeetha sowjanya else
398d06c2abaSGeetha sowjanya map = &mcs->tx.flow_ids;
399d06c2abaSGeetha sowjanya
400d06c2abaSGeetha sowjanya mutex_lock(&mcs->stats_lock);
401d06c2abaSGeetha sowjanya for_each_set_bit(flow_id, map->bmap, mcs->hw->tcam_entries) {
402d06c2abaSGeetha sowjanya mcs_get_flowid_stats(mcs, &stats, flow_id, dir);
403d06c2abaSGeetha sowjanya seq_printf(filp, "Flowid%d: Hit:%lld\n", flow_id, stats.tcam_hit_cnt);
404d06c2abaSGeetha sowjanya }
405d06c2abaSGeetha sowjanya mutex_unlock(&mcs->stats_lock);
406d06c2abaSGeetha sowjanya return 0;
407d06c2abaSGeetha sowjanya }
408d06c2abaSGeetha sowjanya
rvu_dbg_mcs_tx_flowid_stats_display(struct seq_file * filp,void * unused)409d06c2abaSGeetha sowjanya static int rvu_dbg_mcs_tx_flowid_stats_display(struct seq_file *filp, void *unused)
410d06c2abaSGeetha sowjanya {
411d06c2abaSGeetha sowjanya return rvu_dbg_mcs_flowid_stats_display(filp, unused, MCS_TX);
412d06c2abaSGeetha sowjanya }
413d06c2abaSGeetha sowjanya
414d06c2abaSGeetha sowjanya RVU_DEBUG_SEQ_FOPS(mcs_tx_flowid_stats, mcs_tx_flowid_stats_display, NULL);
415d06c2abaSGeetha sowjanya
rvu_dbg_mcs_rx_flowid_stats_display(struct seq_file * filp,void * unused)416d06c2abaSGeetha sowjanya static int rvu_dbg_mcs_rx_flowid_stats_display(struct seq_file *filp, void *unused)
417d06c2abaSGeetha sowjanya {
418d06c2abaSGeetha sowjanya return rvu_dbg_mcs_flowid_stats_display(filp, unused, MCS_RX);
419d06c2abaSGeetha sowjanya }
420d06c2abaSGeetha sowjanya
421d06c2abaSGeetha sowjanya RVU_DEBUG_SEQ_FOPS(mcs_rx_flowid_stats, mcs_rx_flowid_stats_display, NULL);
422d06c2abaSGeetha sowjanya
rvu_dbg_mcs_tx_secy_stats_display(struct seq_file * filp,void * unused)423d06c2abaSGeetha sowjanya static int rvu_dbg_mcs_tx_secy_stats_display(struct seq_file *filp, void *unused)
424d06c2abaSGeetha sowjanya {
425d06c2abaSGeetha sowjanya struct mcs *mcs = filp->private;
426d06c2abaSGeetha sowjanya struct mcs_secy_stats stats;
427d06c2abaSGeetha sowjanya struct rsrc_bmap *map;
428d06c2abaSGeetha sowjanya int secy_id;
429d06c2abaSGeetha sowjanya
430d06c2abaSGeetha sowjanya map = &mcs->tx.secy;
431d06c2abaSGeetha sowjanya seq_puts(filp, "\n MCS TX secy stats\n");
432d06c2abaSGeetha sowjanya
433d06c2abaSGeetha sowjanya mutex_lock(&mcs->stats_lock);
434d06c2abaSGeetha sowjanya for_each_set_bit(secy_id, map->bmap, mcs->hw->secy_entries) {
435d06c2abaSGeetha sowjanya mcs_get_tx_secy_stats(mcs, &stats, secy_id);
436d06c2abaSGeetha sowjanya seq_printf(filp, "\n=======Secy%d======\n\n", secy_id);
437d06c2abaSGeetha sowjanya seq_printf(filp, "secy%d: Ctrl bcast pkts: %lld\n", secy_id,
438d06c2abaSGeetha sowjanya stats.ctl_pkt_bcast_cnt);
439d06c2abaSGeetha sowjanya seq_printf(filp, "secy%d: Ctrl Mcast pkts: %lld\n", secy_id,
440d06c2abaSGeetha sowjanya stats.ctl_pkt_mcast_cnt);
441d06c2abaSGeetha sowjanya seq_printf(filp, "secy%d: Ctrl ucast pkts: %lld\n", secy_id,
442d06c2abaSGeetha sowjanya stats.ctl_pkt_ucast_cnt);
443d06c2abaSGeetha sowjanya seq_printf(filp, "secy%d: Ctrl octets: %lld\n", secy_id, stats.ctl_octet_cnt);
444d06c2abaSGeetha sowjanya seq_printf(filp, "secy%d: Unctrl bcast cnt: %lld\n", secy_id,
445d06c2abaSGeetha sowjanya stats.unctl_pkt_bcast_cnt);
446d06c2abaSGeetha sowjanya seq_printf(filp, "secy%d: Unctrl mcast pkts: %lld\n", secy_id,
447d06c2abaSGeetha sowjanya stats.unctl_pkt_mcast_cnt);
448d06c2abaSGeetha sowjanya seq_printf(filp, "secy%d: Unctrl ucast pkts: %lld\n", secy_id,
449d06c2abaSGeetha sowjanya stats.unctl_pkt_ucast_cnt);
450d06c2abaSGeetha sowjanya seq_printf(filp, "secy%d: Unctrl octets: %lld\n", secy_id, stats.unctl_octet_cnt);
451d06c2abaSGeetha sowjanya seq_printf(filp, "secy%d: Octet encrypted: %lld\n", secy_id,
452d06c2abaSGeetha sowjanya stats.octet_encrypted_cnt);
453d06c2abaSGeetha sowjanya seq_printf(filp, "secy%d: octet protected: %lld\n", secy_id,
454d06c2abaSGeetha sowjanya stats.octet_protected_cnt);
455d06c2abaSGeetha sowjanya seq_printf(filp, "secy%d: Pkts on active sa: %lld\n", secy_id,
456d06c2abaSGeetha sowjanya stats.pkt_noactivesa_cnt);
457d06c2abaSGeetha sowjanya seq_printf(filp, "secy%d: Pkts too long: %lld\n", secy_id, stats.pkt_toolong_cnt);
458d06c2abaSGeetha sowjanya seq_printf(filp, "secy%d: Pkts untagged: %lld\n", secy_id, stats.pkt_untagged_cnt);
459d06c2abaSGeetha sowjanya }
460d06c2abaSGeetha sowjanya mutex_unlock(&mcs->stats_lock);
461d06c2abaSGeetha sowjanya return 0;
462d06c2abaSGeetha sowjanya }
463d06c2abaSGeetha sowjanya
464d06c2abaSGeetha sowjanya RVU_DEBUG_SEQ_FOPS(mcs_tx_secy_stats, mcs_tx_secy_stats_display, NULL);
465d06c2abaSGeetha sowjanya
rvu_dbg_mcs_rx_secy_stats_display(struct seq_file * filp,void * unused)466d06c2abaSGeetha sowjanya static int rvu_dbg_mcs_rx_secy_stats_display(struct seq_file *filp, void *unused)
467d06c2abaSGeetha sowjanya {
468d06c2abaSGeetha sowjanya struct mcs *mcs = filp->private;
469d06c2abaSGeetha sowjanya struct mcs_secy_stats stats;
470d06c2abaSGeetha sowjanya struct rsrc_bmap *map;
471d06c2abaSGeetha sowjanya int secy_id;
472d06c2abaSGeetha sowjanya
473d06c2abaSGeetha sowjanya map = &mcs->rx.secy;
474d06c2abaSGeetha sowjanya seq_puts(filp, "\n MCS secy stats\n");
475d06c2abaSGeetha sowjanya
476d06c2abaSGeetha sowjanya mutex_lock(&mcs->stats_lock);
477d06c2abaSGeetha sowjanya for_each_set_bit(secy_id, map->bmap, mcs->hw->secy_entries) {
478d06c2abaSGeetha sowjanya mcs_get_rx_secy_stats(mcs, &stats, secy_id);
479d06c2abaSGeetha sowjanya seq_printf(filp, "\n=======Secy%d======\n\n", secy_id);
480d06c2abaSGeetha sowjanya seq_printf(filp, "secy%d: Ctrl bcast pkts: %lld\n", secy_id,
481d06c2abaSGeetha sowjanya stats.ctl_pkt_bcast_cnt);
482d06c2abaSGeetha sowjanya seq_printf(filp, "secy%d: Ctrl Mcast pkts: %lld\n", secy_id,
483d06c2abaSGeetha sowjanya stats.ctl_pkt_mcast_cnt);
484d06c2abaSGeetha sowjanya seq_printf(filp, "secy%d: Ctrl ucast pkts: %lld\n", secy_id,
485d06c2abaSGeetha sowjanya stats.ctl_pkt_ucast_cnt);
486d06c2abaSGeetha sowjanya seq_printf(filp, "secy%d: Ctrl octets: %lld\n", secy_id, stats.ctl_octet_cnt);
487d06c2abaSGeetha sowjanya seq_printf(filp, "secy%d: Unctrl bcast cnt: %lld\n", secy_id,
488d06c2abaSGeetha sowjanya stats.unctl_pkt_bcast_cnt);
489d06c2abaSGeetha sowjanya seq_printf(filp, "secy%d: Unctrl mcast pkts: %lld\n", secy_id,
490d06c2abaSGeetha sowjanya stats.unctl_pkt_mcast_cnt);
491d06c2abaSGeetha sowjanya seq_printf(filp, "secy%d: Unctrl ucast pkts: %lld\n", secy_id,
492d06c2abaSGeetha sowjanya stats.unctl_pkt_ucast_cnt);
493d06c2abaSGeetha sowjanya seq_printf(filp, "secy%d: Unctrl octets: %lld\n", secy_id, stats.unctl_octet_cnt);
494d06c2abaSGeetha sowjanya seq_printf(filp, "secy%d: Octet decrypted: %lld\n", secy_id,
495d06c2abaSGeetha sowjanya stats.octet_decrypted_cnt);
496d06c2abaSGeetha sowjanya seq_printf(filp, "secy%d: octet validated: %lld\n", secy_id,
497d06c2abaSGeetha sowjanya stats.octet_validated_cnt);
498d06c2abaSGeetha sowjanya seq_printf(filp, "secy%d: Pkts on disable port: %lld\n", secy_id,
499d06c2abaSGeetha sowjanya stats.pkt_port_disabled_cnt);
500c222b292SGeetha sowjanya seq_printf(filp, "secy%d: Pkts with badtag: %lld\n", secy_id, stats.pkt_badtag_cnt);
501c222b292SGeetha sowjanya seq_printf(filp, "secy%d: Pkts with no SA(sectag.tci.c=0): %lld\n", secy_id,
502c222b292SGeetha sowjanya stats.pkt_nosa_cnt);
503d06c2abaSGeetha sowjanya seq_printf(filp, "secy%d: Pkts with nosaerror: %lld\n", secy_id,
504d06c2abaSGeetha sowjanya stats.pkt_nosaerror_cnt);
505d06c2abaSGeetha sowjanya seq_printf(filp, "secy%d: Tagged ctrl pkts: %lld\n", secy_id,
506d06c2abaSGeetha sowjanya stats.pkt_tagged_ctl_cnt);
507d06c2abaSGeetha sowjanya seq_printf(filp, "secy%d: Untaged pkts: %lld\n", secy_id, stats.pkt_untaged_cnt);
508d06c2abaSGeetha sowjanya seq_printf(filp, "secy%d: Ctrl pkts: %lld\n", secy_id, stats.pkt_ctl_cnt);
509d06c2abaSGeetha sowjanya if (mcs->hw->mcs_blks > 1)
510d06c2abaSGeetha sowjanya seq_printf(filp, "secy%d: pkts notag: %lld\n", secy_id,
511d06c2abaSGeetha sowjanya stats.pkt_notag_cnt);
512d06c2abaSGeetha sowjanya }
513d06c2abaSGeetha sowjanya mutex_unlock(&mcs->stats_lock);
514d06c2abaSGeetha sowjanya return 0;
515d06c2abaSGeetha sowjanya }
516d06c2abaSGeetha sowjanya
517d06c2abaSGeetha sowjanya RVU_DEBUG_SEQ_FOPS(mcs_rx_secy_stats, mcs_rx_secy_stats_display, NULL);
518d06c2abaSGeetha sowjanya
rvu_dbg_mcs_init(struct rvu * rvu)519d06c2abaSGeetha sowjanya static void rvu_dbg_mcs_init(struct rvu *rvu)
520d06c2abaSGeetha sowjanya {
521d06c2abaSGeetha sowjanya struct mcs *mcs;
522d06c2abaSGeetha sowjanya char dname[10];
523d06c2abaSGeetha sowjanya int i;
524d06c2abaSGeetha sowjanya
525d06c2abaSGeetha sowjanya if (!rvu->mcs_blk_cnt)
526d06c2abaSGeetha sowjanya return;
527d06c2abaSGeetha sowjanya
528d06c2abaSGeetha sowjanya rvu->rvu_dbg.mcs_root = debugfs_create_dir("mcs", rvu->rvu_dbg.root);
529d06c2abaSGeetha sowjanya
530d06c2abaSGeetha sowjanya for (i = 0; i < rvu->mcs_blk_cnt; i++) {
531d06c2abaSGeetha sowjanya mcs = mcs_get_pdata(i);
532d06c2abaSGeetha sowjanya
533d06c2abaSGeetha sowjanya sprintf(dname, "mcs%d", i);
534d06c2abaSGeetha sowjanya rvu->rvu_dbg.mcs = debugfs_create_dir(dname,
535d06c2abaSGeetha sowjanya rvu->rvu_dbg.mcs_root);
536d06c2abaSGeetha sowjanya
537d06c2abaSGeetha sowjanya rvu->rvu_dbg.mcs_rx = debugfs_create_dir("rx_stats", rvu->rvu_dbg.mcs);
538d06c2abaSGeetha sowjanya
539d06c2abaSGeetha sowjanya debugfs_create_file("flowid", 0600, rvu->rvu_dbg.mcs_rx, mcs,
540d06c2abaSGeetha sowjanya &rvu_dbg_mcs_rx_flowid_stats_fops);
541d06c2abaSGeetha sowjanya
542d06c2abaSGeetha sowjanya debugfs_create_file("secy", 0600, rvu->rvu_dbg.mcs_rx, mcs,
543d06c2abaSGeetha sowjanya &rvu_dbg_mcs_rx_secy_stats_fops);
544d06c2abaSGeetha sowjanya
545d06c2abaSGeetha sowjanya debugfs_create_file("sc", 0600, rvu->rvu_dbg.mcs_rx, mcs,
546d06c2abaSGeetha sowjanya &rvu_dbg_mcs_rx_sc_stats_fops);
547d06c2abaSGeetha sowjanya
548d06c2abaSGeetha sowjanya debugfs_create_file("sa", 0600, rvu->rvu_dbg.mcs_rx, mcs,
549d06c2abaSGeetha sowjanya &rvu_dbg_mcs_rx_sa_stats_fops);
550d06c2abaSGeetha sowjanya
551d06c2abaSGeetha sowjanya debugfs_create_file("port", 0600, rvu->rvu_dbg.mcs_rx, mcs,
552d06c2abaSGeetha sowjanya &rvu_dbg_mcs_rx_port_stats_fops);
553d06c2abaSGeetha sowjanya
554d06c2abaSGeetha sowjanya rvu->rvu_dbg.mcs_tx = debugfs_create_dir("tx_stats", rvu->rvu_dbg.mcs);
555d06c2abaSGeetha sowjanya
556d06c2abaSGeetha sowjanya debugfs_create_file("flowid", 0600, rvu->rvu_dbg.mcs_tx, mcs,
557d06c2abaSGeetha sowjanya &rvu_dbg_mcs_tx_flowid_stats_fops);
558d06c2abaSGeetha sowjanya
559d06c2abaSGeetha sowjanya debugfs_create_file("secy", 0600, rvu->rvu_dbg.mcs_tx, mcs,
560d06c2abaSGeetha sowjanya &rvu_dbg_mcs_tx_secy_stats_fops);
561d06c2abaSGeetha sowjanya
562d06c2abaSGeetha sowjanya debugfs_create_file("sc", 0600, rvu->rvu_dbg.mcs_tx, mcs,
563d06c2abaSGeetha sowjanya &rvu_dbg_mcs_tx_sc_stats_fops);
564d06c2abaSGeetha sowjanya
565d06c2abaSGeetha sowjanya debugfs_create_file("sa", 0600, rvu->rvu_dbg.mcs_tx, mcs,
566d06c2abaSGeetha sowjanya &rvu_dbg_mcs_tx_sa_stats_fops);
567d06c2abaSGeetha sowjanya
568d06c2abaSGeetha sowjanya debugfs_create_file("port", 0600, rvu->rvu_dbg.mcs_tx, mcs,
569d06c2abaSGeetha sowjanya &rvu_dbg_mcs_tx_port_stats_fops);
570d06c2abaSGeetha sowjanya }
571d06c2abaSGeetha sowjanya }
572d06c2abaSGeetha sowjanya
5730daa55d0SHarman Kalra #define LMT_MAPTBL_ENTRY_SIZE 16
5740daa55d0SHarman Kalra /* Dump LMTST map table */
rvu_dbg_lmtst_map_table_display(struct file * filp,char __user * buffer,size_t count,loff_t * ppos)5750daa55d0SHarman Kalra static ssize_t rvu_dbg_lmtst_map_table_display(struct file *filp,
5760daa55d0SHarman Kalra char __user *buffer,
5770daa55d0SHarman Kalra size_t count, loff_t *ppos)
5780daa55d0SHarman Kalra {
5790daa55d0SHarman Kalra struct rvu *rvu = filp->private_data;
5800daa55d0SHarman Kalra u64 lmt_addr, val, tbl_base;
5810daa55d0SHarman Kalra int pf, vf, num_vfs, hw_vfs;
5820daa55d0SHarman Kalra void __iomem *lmt_map_base;
5830daa55d0SHarman Kalra int buf_size = 10240;
584a280ef90SDan Carpenter size_t off = 0;
585a280ef90SDan Carpenter int index = 0;
5860daa55d0SHarman Kalra char *buf;
587a280ef90SDan Carpenter int ret;
5880daa55d0SHarman Kalra
5890daa55d0SHarman Kalra /* don't allow partial reads */
5900daa55d0SHarman Kalra if (*ppos != 0)
5910daa55d0SHarman Kalra return 0;
5920daa55d0SHarman Kalra
5930daa55d0SHarman Kalra buf = kzalloc(buf_size, GFP_KERNEL);
5940daa55d0SHarman Kalra if (!buf)
5950b9f1b26SNiels Dossche return -ENOMEM;
5960daa55d0SHarman Kalra
5970daa55d0SHarman Kalra tbl_base = rvu_read64(rvu, BLKADDR_APR, APR_AF_LMT_MAP_BASE);
5980daa55d0SHarman Kalra
5990daa55d0SHarman Kalra lmt_map_base = ioremap_wc(tbl_base, 128 * 1024);
6000daa55d0SHarman Kalra if (!lmt_map_base) {
6010daa55d0SHarman Kalra dev_err(rvu->dev, "Failed to setup lmt map table mapping!!\n");
6020daa55d0SHarman Kalra kfree(buf);
6030daa55d0SHarman Kalra return false;
6040daa55d0SHarman Kalra }
6050daa55d0SHarman Kalra
6060daa55d0SHarman Kalra off += scnprintf(&buf[off], buf_size - 1 - off,
6070daa55d0SHarman Kalra "\n\t\t\t\t\tLmtst Map Table Entries");
6080daa55d0SHarman Kalra off += scnprintf(&buf[off], buf_size - 1 - off,
6090daa55d0SHarman Kalra "\n\t\t\t\t\t=======================");
6100daa55d0SHarman Kalra off += scnprintf(&buf[off], buf_size - 1 - off, "\nPcifunc\t\t\t");
6110daa55d0SHarman Kalra off += scnprintf(&buf[off], buf_size - 1 - off, "Table Index\t\t");
6120daa55d0SHarman Kalra off += scnprintf(&buf[off], buf_size - 1 - off,
6130daa55d0SHarman Kalra "Lmtline Base (word 0)\t\t");
6140daa55d0SHarman Kalra off += scnprintf(&buf[off], buf_size - 1 - off,
6150daa55d0SHarman Kalra "Lmt Map Entry (word 1)");
6160daa55d0SHarman Kalra off += scnprintf(&buf[off], buf_size - 1 - off, "\n");
6170daa55d0SHarman Kalra for (pf = 0; pf < rvu->hw->total_pfs; pf++) {
6180daa55d0SHarman Kalra off += scnprintf(&buf[off], buf_size - 1 - off, "PF%d \t\t\t",
6190daa55d0SHarman Kalra pf);
6200daa55d0SHarman Kalra
6210daa55d0SHarman Kalra index = pf * rvu->hw->total_vfs * LMT_MAPTBL_ENTRY_SIZE;
6220daa55d0SHarman Kalra off += scnprintf(&buf[off], buf_size - 1 - off, " 0x%llx\t\t",
6230daa55d0SHarman Kalra (tbl_base + index));
6240daa55d0SHarman Kalra lmt_addr = readq(lmt_map_base + index);
6250daa55d0SHarman Kalra off += scnprintf(&buf[off], buf_size - 1 - off,
6260daa55d0SHarman Kalra " 0x%016llx\t\t", lmt_addr);
6270daa55d0SHarman Kalra index += 8;
6280daa55d0SHarman Kalra val = readq(lmt_map_base + index);
6290daa55d0SHarman Kalra off += scnprintf(&buf[off], buf_size - 1 - off, " 0x%016llx\n",
6300daa55d0SHarman Kalra val);
6310daa55d0SHarman Kalra /* Reading num of VFs per PF */
6320daa55d0SHarman Kalra rvu_get_pf_numvfs(rvu, pf, &num_vfs, &hw_vfs);
6330daa55d0SHarman Kalra for (vf = 0; vf < num_vfs; vf++) {
6340daa55d0SHarman Kalra index = (pf * rvu->hw->total_vfs * 16) +
6350daa55d0SHarman Kalra ((vf + 1) * LMT_MAPTBL_ENTRY_SIZE);
6360daa55d0SHarman Kalra off += scnprintf(&buf[off], buf_size - 1 - off,
6370daa55d0SHarman Kalra "PF%d:VF%d \t\t", pf, vf);
6380daa55d0SHarman Kalra off += scnprintf(&buf[off], buf_size - 1 - off,
6390daa55d0SHarman Kalra " 0x%llx\t\t", (tbl_base + index));
6400daa55d0SHarman Kalra lmt_addr = readq(lmt_map_base + index);
6410daa55d0SHarman Kalra off += scnprintf(&buf[off], buf_size - 1 - off,
6420daa55d0SHarman Kalra " 0x%016llx\t\t", lmt_addr);
6430daa55d0SHarman Kalra index += 8;
6440daa55d0SHarman Kalra val = readq(lmt_map_base + index);
6450daa55d0SHarman Kalra off += scnprintf(&buf[off], buf_size - 1 - off,
6460daa55d0SHarman Kalra " 0x%016llx\n", val);
6470daa55d0SHarman Kalra }
6480daa55d0SHarman Kalra }
6490daa55d0SHarman Kalra off += scnprintf(&buf[off], buf_size - 1 - off, "\n");
6500daa55d0SHarman Kalra
651a280ef90SDan Carpenter ret = min(off, count);
652a280ef90SDan Carpenter if (copy_to_user(buffer, buf, ret))
653a280ef90SDan Carpenter ret = -EFAULT;
6540daa55d0SHarman Kalra kfree(buf);
6550daa55d0SHarman Kalra
6560daa55d0SHarman Kalra iounmap(lmt_map_base);
657a280ef90SDan Carpenter if (ret < 0)
658a280ef90SDan Carpenter return ret;
6590daa55d0SHarman Kalra
660a280ef90SDan Carpenter *ppos = ret;
661a280ef90SDan Carpenter return ret;
6620daa55d0SHarman Kalra }
6630daa55d0SHarman Kalra
6640daa55d0SHarman Kalra RVU_DEBUG_FOPS(lmtst_map_table, lmtst_map_table_display, NULL);
6650daa55d0SHarman Kalra
get_lf_str_list(struct rvu_block block,int pcifunc,char * lfs)666e77bcdd1SRakesh Babu static void get_lf_str_list(struct rvu_block block, int pcifunc,
667e77bcdd1SRakesh Babu char *lfs)
668e77bcdd1SRakesh Babu {
669e77bcdd1SRakesh Babu int lf = 0, seq = 0, len = 0, prev_lf = block.lf.max;
670e77bcdd1SRakesh Babu
671e77bcdd1SRakesh Babu for_each_set_bit(lf, block.lf.bmap, block.lf.max) {
672e77bcdd1SRakesh Babu if (lf >= block.lf.max)
673e77bcdd1SRakesh Babu break;
674e77bcdd1SRakesh Babu
675e77bcdd1SRakesh Babu if (block.fn_map[lf] != pcifunc)
676e77bcdd1SRakesh Babu continue;
677e77bcdd1SRakesh Babu
678e77bcdd1SRakesh Babu if (lf == prev_lf + 1) {
679e77bcdd1SRakesh Babu prev_lf = lf;
680e77bcdd1SRakesh Babu seq = 1;
681e77bcdd1SRakesh Babu continue;
682e77bcdd1SRakesh Babu }
683e77bcdd1SRakesh Babu
684e77bcdd1SRakesh Babu if (seq)
685e77bcdd1SRakesh Babu len += sprintf(lfs + len, "-%d,%d", prev_lf, lf);
686e77bcdd1SRakesh Babu else
687e77bcdd1SRakesh Babu len += (len ? sprintf(lfs + len, ",%d", lf) :
688e77bcdd1SRakesh Babu sprintf(lfs + len, "%d", lf));
689e77bcdd1SRakesh Babu
690e77bcdd1SRakesh Babu prev_lf = lf;
691e77bcdd1SRakesh Babu seq = 0;
692e77bcdd1SRakesh Babu }
693e77bcdd1SRakesh Babu
694e77bcdd1SRakesh Babu if (seq)
695e77bcdd1SRakesh Babu len += sprintf(lfs + len, "-%d", prev_lf);
696e77bcdd1SRakesh Babu
697e77bcdd1SRakesh Babu lfs[len] = '\0';
698e77bcdd1SRakesh Babu }
699e77bcdd1SRakesh Babu
get_max_column_width(struct rvu * rvu)700e77bcdd1SRakesh Babu static int get_max_column_width(struct rvu *rvu)
701e77bcdd1SRakesh Babu {
702e77bcdd1SRakesh Babu int index, pf, vf, lf_str_size = 12, buf_size = 256;
703e77bcdd1SRakesh Babu struct rvu_block block;
704e77bcdd1SRakesh Babu u16 pcifunc;
705e77bcdd1SRakesh Babu char *buf;
706e77bcdd1SRakesh Babu
707e77bcdd1SRakesh Babu buf = kzalloc(buf_size, GFP_KERNEL);
708e77bcdd1SRakesh Babu if (!buf)
709e77bcdd1SRakesh Babu return -ENOMEM;
710e77bcdd1SRakesh Babu
711e77bcdd1SRakesh Babu for (pf = 0; pf < rvu->hw->total_pfs; pf++) {
712e77bcdd1SRakesh Babu for (vf = 0; vf <= rvu->hw->total_vfs; vf++) {
713e77bcdd1SRakesh Babu pcifunc = pf << 10 | vf;
714e77bcdd1SRakesh Babu if (!pcifunc)
715e77bcdd1SRakesh Babu continue;
716e77bcdd1SRakesh Babu
717e77bcdd1SRakesh Babu for (index = 0; index < BLK_COUNT; index++) {
718e77bcdd1SRakesh Babu block = rvu->hw->block[index];
719e77bcdd1SRakesh Babu if (!strlen(block.name))
720e77bcdd1SRakesh Babu continue;
721e77bcdd1SRakesh Babu
722e77bcdd1SRakesh Babu get_lf_str_list(block, pcifunc, buf);
723e77bcdd1SRakesh Babu if (lf_str_size <= strlen(buf))
724e77bcdd1SRakesh Babu lf_str_size = strlen(buf) + 1;
725e77bcdd1SRakesh Babu }
726e77bcdd1SRakesh Babu }
727e77bcdd1SRakesh Babu }
728e77bcdd1SRakesh Babu
729e77bcdd1SRakesh Babu kfree(buf);
730e77bcdd1SRakesh Babu return lf_str_size;
731e77bcdd1SRakesh Babu }
732e77bcdd1SRakesh Babu
73323205e6dSChristina Jacob /* Dumps current provisioning status of all RVU block LFs */
rvu_dbg_rsrc_attach_status(struct file * filp,char __user * buffer,size_t count,loff_t * ppos)73423205e6dSChristina Jacob static ssize_t rvu_dbg_rsrc_attach_status(struct file *filp,
73523205e6dSChristina Jacob char __user *buffer,
73623205e6dSChristina Jacob size_t count, loff_t *ppos)
73723205e6dSChristina Jacob {
738e77bcdd1SRakesh Babu int index, off = 0, flag = 0, len = 0, i = 0;
73923205e6dSChristina Jacob struct rvu *rvu = filp->private_data;
740e77bcdd1SRakesh Babu int bytes_not_copied = 0;
74123205e6dSChristina Jacob struct rvu_block block;
742e77bcdd1SRakesh Babu int pf, vf, pcifunc;
74323205e6dSChristina Jacob int buf_size = 2048;
744e77bcdd1SRakesh Babu int lf_str_size;
745f7884097SRakesh Babu char *lfs;
74623205e6dSChristina Jacob char *buf;
74723205e6dSChristina Jacob
74823205e6dSChristina Jacob /* don't allow partial reads */
74923205e6dSChristina Jacob if (*ppos != 0)
75023205e6dSChristina Jacob return 0;
75123205e6dSChristina Jacob
75223205e6dSChristina Jacob buf = kzalloc(buf_size, GFP_KERNEL);
75323205e6dSChristina Jacob if (!buf)
7540b9f1b26SNiels Dossche return -ENOMEM;
755f7884097SRakesh Babu
756e77bcdd1SRakesh Babu /* Get the maximum width of a column */
757e77bcdd1SRakesh Babu lf_str_size = get_max_column_width(rvu);
758e77bcdd1SRakesh Babu
759f7884097SRakesh Babu lfs = kzalloc(lf_str_size, GFP_KERNEL);
7609e0a537dSColin Ian King if (!lfs) {
7619e0a537dSColin Ian King kfree(buf);
762f7884097SRakesh Babu return -ENOMEM;
7639e0a537dSColin Ian King }
764f7884097SRakesh Babu off += scnprintf(&buf[off], buf_size - 1 - off, "%-*s", lf_str_size,
765f7884097SRakesh Babu "pcifunc");
76623205e6dSChristina Jacob for (index = 0; index < BLK_COUNT; index++)
767f7884097SRakesh Babu if (strlen(rvu->hw->block[index].name)) {
76823205e6dSChristina Jacob off += scnprintf(&buf[off], buf_size - 1 - off,
769f7884097SRakesh Babu "%-*s", lf_str_size,
77023205e6dSChristina Jacob rvu->hw->block[index].name);
771f7884097SRakesh Babu }
772e77bcdd1SRakesh Babu
77323205e6dSChristina Jacob off += scnprintf(&buf[off], buf_size - 1 - off, "\n");
774e77bcdd1SRakesh Babu bytes_not_copied = copy_to_user(buffer + (i * off), buf, off);
775e77bcdd1SRakesh Babu if (bytes_not_copied)
776e77bcdd1SRakesh Babu goto out;
777e77bcdd1SRakesh Babu
778e77bcdd1SRakesh Babu i++;
779e77bcdd1SRakesh Babu *ppos += off;
78023205e6dSChristina Jacob for (pf = 0; pf < rvu->hw->total_pfs; pf++) {
78123205e6dSChristina Jacob for (vf = 0; vf <= rvu->hw->total_vfs; vf++) {
782e77bcdd1SRakesh Babu off = 0;
783e77bcdd1SRakesh Babu flag = 0;
78423205e6dSChristina Jacob pcifunc = pf << 10 | vf;
78523205e6dSChristina Jacob if (!pcifunc)
78623205e6dSChristina Jacob continue;
78723205e6dSChristina Jacob
78823205e6dSChristina Jacob if (vf) {
789f7884097SRakesh Babu sprintf(lfs, "PF%d:VF%d", pf, vf - 1);
790e77bcdd1SRakesh Babu off = scnprintf(&buf[off],
79123205e6dSChristina Jacob buf_size - 1 - off,
792f7884097SRakesh Babu "%-*s", lf_str_size, lfs);
79323205e6dSChristina Jacob } else {
794f7884097SRakesh Babu sprintf(lfs, "PF%d", pf);
795e77bcdd1SRakesh Babu off = scnprintf(&buf[off],
79623205e6dSChristina Jacob buf_size - 1 - off,
797f7884097SRakesh Babu "%-*s", lf_str_size, lfs);
79823205e6dSChristina Jacob }
79923205e6dSChristina Jacob
800e77bcdd1SRakesh Babu for (index = 0; index < BLK_COUNT; index++) {
80123205e6dSChristina Jacob block = rvu->hw->block[index];
80223205e6dSChristina Jacob if (!strlen(block.name))
80323205e6dSChristina Jacob continue;
804f7884097SRakesh Babu len = 0;
805f7884097SRakesh Babu lfs[len] = '\0';
806e77bcdd1SRakesh Babu get_lf_str_list(block, pcifunc, lfs);
807e77bcdd1SRakesh Babu if (strlen(lfs))
80823205e6dSChristina Jacob flag = 1;
809f7884097SRakesh Babu
81023205e6dSChristina Jacob off += scnprintf(&buf[off], buf_size - 1 - off,
811f7884097SRakesh Babu "%-*s", lf_str_size, lfs);
81223205e6dSChristina Jacob }
813e77bcdd1SRakesh Babu if (flag) {
814e77bcdd1SRakesh Babu off += scnprintf(&buf[off],
815e77bcdd1SRakesh Babu buf_size - 1 - off, "\n");
816e77bcdd1SRakesh Babu bytes_not_copied = copy_to_user(buffer +
817e77bcdd1SRakesh Babu (i * off),
818e77bcdd1SRakesh Babu buf, off);
819e77bcdd1SRakesh Babu if (bytes_not_copied)
820e77bcdd1SRakesh Babu goto out;
821e77bcdd1SRakesh Babu
822e77bcdd1SRakesh Babu i++;
823e77bcdd1SRakesh Babu *ppos += off;
824e77bcdd1SRakesh Babu }
82523205e6dSChristina Jacob }
82623205e6dSChristina Jacob }
82723205e6dSChristina Jacob
828e77bcdd1SRakesh Babu out:
829f7884097SRakesh Babu kfree(lfs);
83023205e6dSChristina Jacob kfree(buf);
83123205e6dSChristina Jacob if (bytes_not_copied)
83223205e6dSChristina Jacob return -EFAULT;
83323205e6dSChristina Jacob
834e77bcdd1SRakesh Babu return *ppos;
83523205e6dSChristina Jacob }
83623205e6dSChristina Jacob
83723205e6dSChristina Jacob RVU_DEBUG_FOPS(rsrc_status, rsrc_attach_status, NULL);
83823205e6dSChristina Jacob
rvu_dbg_rvu_pf_cgx_map_display(struct seq_file * filp,void * unused)839e2fb3730SRakesh Babu static int rvu_dbg_rvu_pf_cgx_map_display(struct seq_file *filp, void *unused)
840e2fb3730SRakesh Babu {
841e2fb3730SRakesh Babu struct rvu *rvu = filp->private;
842e2fb3730SRakesh Babu struct pci_dev *pdev = NULL;
84391c6945eSHariprasad Kelam struct mac_ops *mac_ops;
844e2fb3730SRakesh Babu char cgx[10], lmac[10];
845e2fb3730SRakesh Babu struct rvu_pfvf *pfvf;
846e2fb3730SRakesh Babu int pf, domain, blkid;
847e2fb3730SRakesh Babu u8 cgx_id, lmac_id;
848e2fb3730SRakesh Babu u16 pcifunc;
849e2fb3730SRakesh Babu
850e2fb3730SRakesh Babu domain = 2;
85129788787SSubbaraya Sundeep mac_ops = get_mac_ops(rvu_first_cgx_pdata(rvu));
85229788787SSubbaraya Sundeep /* There can be no CGX devices at all */
85329788787SSubbaraya Sundeep if (!mac_ops)
85429788787SSubbaraya Sundeep return 0;
85591c6945eSHariprasad Kelam seq_printf(filp, "PCI dev\t\tRVU PF Func\tNIX block\t%s\tLMAC\n",
85691c6945eSHariprasad Kelam mac_ops->name);
857e2fb3730SRakesh Babu for (pf = 0; pf < rvu->hw->total_pfs; pf++) {
858e2fb3730SRakesh Babu if (!is_pf_cgxmapped(rvu, pf))
859e2fb3730SRakesh Babu continue;
860e2fb3730SRakesh Babu
861e2fb3730SRakesh Babu pdev = pci_get_domain_bus_and_slot(domain, pf + 1, 0);
862e2fb3730SRakesh Babu if (!pdev)
863e2fb3730SRakesh Babu continue;
864e2fb3730SRakesh Babu
865e2fb3730SRakesh Babu cgx[0] = 0;
866e2fb3730SRakesh Babu lmac[0] = 0;
867e2fb3730SRakesh Babu pcifunc = pf << 10;
868e2fb3730SRakesh Babu pfvf = rvu_get_pfvf(rvu, pcifunc);
869e2fb3730SRakesh Babu
870e2fb3730SRakesh Babu if (pfvf->nix_blkaddr == BLKADDR_NIX0)
871e2fb3730SRakesh Babu blkid = 0;
872e2fb3730SRakesh Babu else
873e2fb3730SRakesh Babu blkid = 1;
874e2fb3730SRakesh Babu
875e2fb3730SRakesh Babu rvu_get_cgx_lmac_id(rvu->pf2cgxlmac_map[pf], &cgx_id,
876e2fb3730SRakesh Babu &lmac_id);
87791c6945eSHariprasad Kelam sprintf(cgx, "%s%d", mac_ops->name, cgx_id);
878e2fb3730SRakesh Babu sprintf(lmac, "LMAC%d", lmac_id);
879e2fb3730SRakesh Babu seq_printf(filp, "%s\t0x%x\t\tNIX%d\t\t%s\t%s\n",
880e2fb3730SRakesh Babu dev_name(&pdev->dev), pcifunc, blkid, cgx, lmac);
881d6660880SYang Yingliang
882d6660880SYang Yingliang pci_dev_put(pdev);
883e2fb3730SRakesh Babu }
884e2fb3730SRakesh Babu return 0;
885e2fb3730SRakesh Babu }
886e2fb3730SRakesh Babu
887e2fb3730SRakesh Babu RVU_DEBUG_SEQ_FOPS(rvu_pf_cgx_map, rvu_pf_cgx_map_display, NULL);
888e2fb3730SRakesh Babu
rvu_dbg_is_valid_lf(struct rvu * rvu,int blkaddr,int lf,u16 * pcifunc)8890f3ce484SRakesh Babu static bool rvu_dbg_is_valid_lf(struct rvu *rvu, int blkaddr, int lf,
8908756828aSChristina Jacob u16 *pcifunc)
8918756828aSChristina Jacob {
8928756828aSChristina Jacob struct rvu_block *block;
8938756828aSChristina Jacob struct rvu_hwinfo *hw;
8948756828aSChristina Jacob
8958756828aSChristina Jacob hw = rvu->hw;
8968756828aSChristina Jacob block = &hw->block[blkaddr];
8978756828aSChristina Jacob
8988756828aSChristina Jacob if (lf < 0 || lf >= block->lf.max) {
8998756828aSChristina Jacob dev_warn(rvu->dev, "Invalid LF: valid range: 0-%d\n",
9008756828aSChristina Jacob block->lf.max - 1);
9018756828aSChristina Jacob return false;
9028756828aSChristina Jacob }
9038756828aSChristina Jacob
9048756828aSChristina Jacob *pcifunc = block->fn_map[lf];
9058756828aSChristina Jacob if (!*pcifunc) {
9068756828aSChristina Jacob dev_warn(rvu->dev,
9078756828aSChristina Jacob "This LF is not attached to any RVU PFFUNC\n");
9088756828aSChristina Jacob return false;
9098756828aSChristina Jacob }
9108756828aSChristina Jacob return true;
9118756828aSChristina Jacob }
9128756828aSChristina Jacob
print_npa_qsize(struct seq_file * m,struct rvu_pfvf * pfvf)9138756828aSChristina Jacob static void print_npa_qsize(struct seq_file *m, struct rvu_pfvf *pfvf)
9148756828aSChristina Jacob {
9158756828aSChristina Jacob char *buf;
9168756828aSChristina Jacob
9178756828aSChristina Jacob buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
9188756828aSChristina Jacob if (!buf)
9198756828aSChristina Jacob return;
9208756828aSChristina Jacob
9218756828aSChristina Jacob if (!pfvf->aura_ctx) {
9228756828aSChristina Jacob seq_puts(m, "Aura context is not initialized\n");
9238756828aSChristina Jacob } else {
9248756828aSChristina Jacob bitmap_print_to_pagebuf(false, buf, pfvf->aura_bmap,
9258756828aSChristina Jacob pfvf->aura_ctx->qsize);
9268756828aSChristina Jacob seq_printf(m, "Aura count : %d\n", pfvf->aura_ctx->qsize);
9278756828aSChristina Jacob seq_printf(m, "Aura context ena/dis bitmap : %s\n", buf);
9288756828aSChristina Jacob }
9298756828aSChristina Jacob
9308756828aSChristina Jacob if (!pfvf->pool_ctx) {
9318756828aSChristina Jacob seq_puts(m, "Pool context is not initialized\n");
9328756828aSChristina Jacob } else {
9338756828aSChristina Jacob bitmap_print_to_pagebuf(false, buf, pfvf->pool_bmap,
9348756828aSChristina Jacob pfvf->pool_ctx->qsize);
9358756828aSChristina Jacob seq_printf(m, "Pool count : %d\n", pfvf->pool_ctx->qsize);
9368756828aSChristina Jacob seq_printf(m, "Pool context ena/dis bitmap : %s\n", buf);
9378756828aSChristina Jacob }
9388756828aSChristina Jacob kfree(buf);
9398756828aSChristina Jacob }
9408756828aSChristina Jacob
9418756828aSChristina Jacob /* The 'qsize' entry dumps current Aura/Pool context Qsize
9428756828aSChristina Jacob * and each context's current enable/disable status in a bitmap.
9438756828aSChristina Jacob */
rvu_dbg_qsize_display(struct seq_file * filp,void * unsused,int blktype)9448756828aSChristina Jacob static int rvu_dbg_qsize_display(struct seq_file *filp, void *unsused,
9458756828aSChristina Jacob int blktype)
9468756828aSChristina Jacob {
9478756828aSChristina Jacob void (*print_qsize)(struct seq_file *filp,
9488756828aSChristina Jacob struct rvu_pfvf *pfvf) = NULL;
9490f3ce484SRakesh Babu struct dentry *current_dir;
9508756828aSChristina Jacob struct rvu_pfvf *pfvf;
9518756828aSChristina Jacob struct rvu *rvu;
9528756828aSChristina Jacob int qsize_id;
9538756828aSChristina Jacob u16 pcifunc;
9540f3ce484SRakesh Babu int blkaddr;
9558756828aSChristina Jacob
9568756828aSChristina Jacob rvu = filp->private;
9578756828aSChristina Jacob switch (blktype) {
9588756828aSChristina Jacob case BLKTYPE_NPA:
9598756828aSChristina Jacob qsize_id = rvu->rvu_dbg.npa_qsize_id;
9608756828aSChristina Jacob print_qsize = print_npa_qsize;
9618756828aSChristina Jacob break;
96202e202c3SPrakash Brahmajyosyula
96302e202c3SPrakash Brahmajyosyula case BLKTYPE_NIX:
96402e202c3SPrakash Brahmajyosyula qsize_id = rvu->rvu_dbg.nix_qsize_id;
96502e202c3SPrakash Brahmajyosyula print_qsize = print_nix_qsize;
96602e202c3SPrakash Brahmajyosyula break;
96702e202c3SPrakash Brahmajyosyula
9688756828aSChristina Jacob default:
9698756828aSChristina Jacob return -EINVAL;
9708756828aSChristina Jacob }
9718756828aSChristina Jacob
9720f3ce484SRakesh Babu if (blktype == BLKTYPE_NPA) {
9730f3ce484SRakesh Babu blkaddr = BLKADDR_NPA;
9740f3ce484SRakesh Babu } else {
9750f3ce484SRakesh Babu current_dir = filp->file->f_path.dentry->d_parent;
9760f3ce484SRakesh Babu blkaddr = (!strcmp(current_dir->d_name.name, "nix1") ?
9770f3ce484SRakesh Babu BLKADDR_NIX1 : BLKADDR_NIX0);
9780f3ce484SRakesh Babu }
9790f3ce484SRakesh Babu
9800f3ce484SRakesh Babu if (!rvu_dbg_is_valid_lf(rvu, blkaddr, qsize_id, &pcifunc))
9818756828aSChristina Jacob return -EINVAL;
9828756828aSChristina Jacob
9838756828aSChristina Jacob pfvf = rvu_get_pfvf(rvu, pcifunc);
9848756828aSChristina Jacob print_qsize(filp, pfvf);
9858756828aSChristina Jacob
9868756828aSChristina Jacob return 0;
9878756828aSChristina Jacob }
9888756828aSChristina Jacob
rvu_dbg_qsize_write(struct file * filp,const char __user * buffer,size_t count,loff_t * ppos,int blktype)9898756828aSChristina Jacob static ssize_t rvu_dbg_qsize_write(struct file *filp,
9908756828aSChristina Jacob const char __user *buffer, size_t count,
9918756828aSChristina Jacob loff_t *ppos, int blktype)
9928756828aSChristina Jacob {
9938756828aSChristina Jacob char *blk_string = (blktype == BLKTYPE_NPA) ? "npa" : "nix";
9948756828aSChristina Jacob struct seq_file *seqfile = filp->private_data;
9958756828aSChristina Jacob char *cmd_buf, *cmd_buf_tmp, *subtoken;
9968756828aSChristina Jacob struct rvu *rvu = seqfile->private;
9970f3ce484SRakesh Babu struct dentry *current_dir;
9980f3ce484SRakesh Babu int blkaddr;
9998756828aSChristina Jacob u16 pcifunc;
10008756828aSChristina Jacob int ret, lf;
10018756828aSChristina Jacob
1002*0a0285ceSBui Quang Minh cmd_buf = memdup_user_nul(buffer, count);
10038756828aSChristina Jacob if (IS_ERR(cmd_buf))
10048756828aSChristina Jacob return -ENOMEM;
10058756828aSChristina Jacob
10068756828aSChristina Jacob cmd_buf_tmp = strchr(cmd_buf, '\n');
10078756828aSChristina Jacob if (cmd_buf_tmp) {
10088756828aSChristina Jacob *cmd_buf_tmp = '\0';
10098756828aSChristina Jacob count = cmd_buf_tmp - cmd_buf + 1;
10108756828aSChristina Jacob }
10118756828aSChristina Jacob
10128756828aSChristina Jacob cmd_buf_tmp = cmd_buf;
10138756828aSChristina Jacob subtoken = strsep(&cmd_buf, " ");
10148756828aSChristina Jacob ret = subtoken ? kstrtoint(subtoken, 10, &lf) : -EINVAL;
10158756828aSChristina Jacob if (cmd_buf)
10168756828aSChristina Jacob ret = -EINVAL;
10178756828aSChristina Jacob
1018c2d4c543SRakesh Babu Saladi if (ret < 0 || !strncmp(subtoken, "help", 4)) {
10198756828aSChristina Jacob dev_info(rvu->dev, "Use echo <%s-lf > qsize\n", blk_string);
10208756828aSChristina Jacob goto qsize_write_done;
10218756828aSChristina Jacob }
10228756828aSChristina Jacob
10230f3ce484SRakesh Babu if (blktype == BLKTYPE_NPA) {
10240f3ce484SRakesh Babu blkaddr = BLKADDR_NPA;
10250f3ce484SRakesh Babu } else {
10260f3ce484SRakesh Babu current_dir = filp->f_path.dentry->d_parent;
10270f3ce484SRakesh Babu blkaddr = (!strcmp(current_dir->d_name.name, "nix1") ?
10280f3ce484SRakesh Babu BLKADDR_NIX1 : BLKADDR_NIX0);
10290f3ce484SRakesh Babu }
10300f3ce484SRakesh Babu
10310f3ce484SRakesh Babu if (!rvu_dbg_is_valid_lf(rvu, blkaddr, lf, &pcifunc)) {
10328756828aSChristina Jacob ret = -EINVAL;
10338756828aSChristina Jacob goto qsize_write_done;
10348756828aSChristina Jacob }
10358756828aSChristina Jacob if (blktype == BLKTYPE_NPA)
10368756828aSChristina Jacob rvu->rvu_dbg.npa_qsize_id = lf;
103702e202c3SPrakash Brahmajyosyula else
103802e202c3SPrakash Brahmajyosyula rvu->rvu_dbg.nix_qsize_id = lf;
10398756828aSChristina Jacob
10408756828aSChristina Jacob qsize_write_done:
10418756828aSChristina Jacob kfree(cmd_buf_tmp);
10428756828aSChristina Jacob return ret ? ret : count;
10438756828aSChristina Jacob }
10448756828aSChristina Jacob
rvu_dbg_npa_qsize_write(struct file * filp,const char __user * buffer,size_t count,loff_t * ppos)10458756828aSChristina Jacob static ssize_t rvu_dbg_npa_qsize_write(struct file *filp,
10468756828aSChristina Jacob const char __user *buffer,
10478756828aSChristina Jacob size_t count, loff_t *ppos)
10488756828aSChristina Jacob {
10498756828aSChristina Jacob return rvu_dbg_qsize_write(filp, buffer, count, ppos,
10508756828aSChristina Jacob BLKTYPE_NPA);
10518756828aSChristina Jacob }
10528756828aSChristina Jacob
rvu_dbg_npa_qsize_display(struct seq_file * filp,void * unused)10538756828aSChristina Jacob static int rvu_dbg_npa_qsize_display(struct seq_file *filp, void *unused)
10548756828aSChristina Jacob {
10558756828aSChristina Jacob return rvu_dbg_qsize_display(filp, unused, BLKTYPE_NPA);
10568756828aSChristina Jacob }
10578756828aSChristina Jacob
10588756828aSChristina Jacob RVU_DEBUG_SEQ_FOPS(npa_qsize, npa_qsize_display, npa_qsize_write);
10598756828aSChristina Jacob
10608756828aSChristina Jacob /* Dumps given NPA Aura's context */
print_npa_aura_ctx(struct seq_file * m,struct npa_aq_enq_rsp * rsp)10618756828aSChristina Jacob static void print_npa_aura_ctx(struct seq_file *m, struct npa_aq_enq_rsp *rsp)
10628756828aSChristina Jacob {
10638756828aSChristina Jacob struct npa_aura_s *aura = &rsp->aura;
10643feac505SGeetha sowjanya struct rvu *rvu = m->private;
10658756828aSChristina Jacob
10668756828aSChristina Jacob seq_printf(m, "W0: Pool addr\t\t%llx\n", aura->pool_addr);
10678756828aSChristina Jacob
10688756828aSChristina Jacob seq_printf(m, "W1: ena\t\t\t%d\nW1: pool caching\t%d\n",
10698756828aSChristina Jacob aura->ena, aura->pool_caching);
10708756828aSChristina Jacob seq_printf(m, "W1: pool way mask\t%d\nW1: avg con\t\t%d\n",
10718756828aSChristina Jacob aura->pool_way_mask, aura->avg_con);
10728756828aSChristina Jacob seq_printf(m, "W1: pool drop ena\t%d\nW1: aura drop ena\t%d\n",
10738756828aSChristina Jacob aura->pool_drop_ena, aura->aura_drop_ena);
10748756828aSChristina Jacob seq_printf(m, "W1: bp_ena\t\t%d\nW1: aura drop\t\t%d\n",
10758756828aSChristina Jacob aura->bp_ena, aura->aura_drop);
10768756828aSChristina Jacob seq_printf(m, "W1: aura shift\t\t%d\nW1: avg_level\t\t%d\n",
10778756828aSChristina Jacob aura->shift, aura->avg_level);
10788756828aSChristina Jacob
10798756828aSChristina Jacob seq_printf(m, "W2: count\t\t%llu\nW2: nix0_bpid\t\t%d\nW2: nix1_bpid\t\t%d\n",
10808756828aSChristina Jacob (u64)aura->count, aura->nix0_bpid, aura->nix1_bpid);
10818756828aSChristina Jacob
10828756828aSChristina Jacob seq_printf(m, "W3: limit\t\t%llu\nW3: bp\t\t\t%d\nW3: fc_ena\t\t%d\n",
10838756828aSChristina Jacob (u64)aura->limit, aura->bp, aura->fc_ena);
10843feac505SGeetha sowjanya
10853feac505SGeetha sowjanya if (!is_rvu_otx2(rvu))
10863feac505SGeetha sowjanya seq_printf(m, "W3: fc_be\t\t%d\n", aura->fc_be);
10878756828aSChristina Jacob seq_printf(m, "W3: fc_up_crossing\t%d\nW3: fc_stype\t\t%d\n",
10888756828aSChristina Jacob aura->fc_up_crossing, aura->fc_stype);
10898756828aSChristina Jacob seq_printf(m, "W3: fc_hyst_bits\t%d\n", aura->fc_hyst_bits);
10908756828aSChristina Jacob
10918756828aSChristina Jacob seq_printf(m, "W4: fc_addr\t\t%llx\n", aura->fc_addr);
10928756828aSChristina Jacob
10938756828aSChristina Jacob seq_printf(m, "W5: pool_drop\t\t%d\nW5: update_time\t\t%d\n",
10948756828aSChristina Jacob aura->pool_drop, aura->update_time);
10958756828aSChristina Jacob seq_printf(m, "W5: err_int \t\t%d\nW5: err_int_ena\t\t%d\n",
10968756828aSChristina Jacob aura->err_int, aura->err_int_ena);
10978756828aSChristina Jacob seq_printf(m, "W5: thresh_int\t\t%d\nW5: thresh_int_ena \t%d\n",
10988756828aSChristina Jacob aura->thresh_int, aura->thresh_int_ena);
10998756828aSChristina Jacob seq_printf(m, "W5: thresh_up\t\t%d\nW5: thresh_qint_idx\t%d\n",
11008756828aSChristina Jacob aura->thresh_up, aura->thresh_qint_idx);
11018756828aSChristina Jacob seq_printf(m, "W5: err_qint_idx \t%d\n", aura->err_qint_idx);
11028756828aSChristina Jacob
11038756828aSChristina Jacob seq_printf(m, "W6: thresh\t\t%llu\n", (u64)aura->thresh);
11043feac505SGeetha sowjanya if (!is_rvu_otx2(rvu))
11053feac505SGeetha sowjanya seq_printf(m, "W6: fc_msh_dst\t\t%d\n", aura->fc_msh_dst);
11068756828aSChristina Jacob }
11078756828aSChristina Jacob
11088756828aSChristina Jacob /* Dumps given NPA Pool's context */
print_npa_pool_ctx(struct seq_file * m,struct npa_aq_enq_rsp * rsp)11098756828aSChristina Jacob static void print_npa_pool_ctx(struct seq_file *m, struct npa_aq_enq_rsp *rsp)
11108756828aSChristina Jacob {
11118756828aSChristina Jacob struct npa_pool_s *pool = &rsp->pool;
11123feac505SGeetha sowjanya struct rvu *rvu = m->private;
11138756828aSChristina Jacob
11148756828aSChristina Jacob seq_printf(m, "W0: Stack base\t\t%llx\n", pool->stack_base);
11158756828aSChristina Jacob
11168756828aSChristina Jacob seq_printf(m, "W1: ena \t\t%d\nW1: nat_align \t\t%d\n",
11178756828aSChristina Jacob pool->ena, pool->nat_align);
11188756828aSChristina Jacob seq_printf(m, "W1: stack_caching\t%d\nW1: stack_way_mask\t%d\n",
11198756828aSChristina Jacob pool->stack_caching, pool->stack_way_mask);
11208756828aSChristina Jacob seq_printf(m, "W1: buf_offset\t\t%d\nW1: buf_size\t\t%d\n",
11218756828aSChristina Jacob pool->buf_offset, pool->buf_size);
11228756828aSChristina Jacob
11238756828aSChristina Jacob seq_printf(m, "W2: stack_max_pages \t%d\nW2: stack_pages\t\t%d\n",
11248756828aSChristina Jacob pool->stack_max_pages, pool->stack_pages);
11258756828aSChristina Jacob
11268756828aSChristina Jacob seq_printf(m, "W3: op_pc \t\t%llu\n", (u64)pool->op_pc);
11278756828aSChristina Jacob
11288756828aSChristina Jacob seq_printf(m, "W4: stack_offset\t%d\nW4: shift\t\t%d\nW4: avg_level\t\t%d\n",
11298756828aSChristina Jacob pool->stack_offset, pool->shift, pool->avg_level);
11308756828aSChristina Jacob seq_printf(m, "W4: avg_con \t\t%d\nW4: fc_ena\t\t%d\nW4: fc_stype\t\t%d\n",
11318756828aSChristina Jacob pool->avg_con, pool->fc_ena, pool->fc_stype);
11328756828aSChristina Jacob seq_printf(m, "W4: fc_hyst_bits\t%d\nW4: fc_up_crossing\t%d\n",
11338756828aSChristina Jacob pool->fc_hyst_bits, pool->fc_up_crossing);
11343feac505SGeetha sowjanya if (!is_rvu_otx2(rvu))
11353feac505SGeetha sowjanya seq_printf(m, "W4: fc_be\t\t%d\n", pool->fc_be);
11368756828aSChristina Jacob seq_printf(m, "W4: update_time\t\t%d\n", pool->update_time);
11378756828aSChristina Jacob
11388756828aSChristina Jacob seq_printf(m, "W5: fc_addr\t\t%llx\n", pool->fc_addr);
11398756828aSChristina Jacob
11408756828aSChristina Jacob seq_printf(m, "W6: ptr_start\t\t%llx\n", pool->ptr_start);
11418756828aSChristina Jacob
11428756828aSChristina Jacob seq_printf(m, "W7: ptr_end\t\t%llx\n", pool->ptr_end);
11438756828aSChristina Jacob
11448756828aSChristina Jacob seq_printf(m, "W8: err_int\t\t%d\nW8: err_int_ena\t\t%d\n",
11458756828aSChristina Jacob pool->err_int, pool->err_int_ena);
11468756828aSChristina Jacob seq_printf(m, "W8: thresh_int\t\t%d\n", pool->thresh_int);
11478756828aSChristina Jacob seq_printf(m, "W8: thresh_int_ena\t%d\nW8: thresh_up\t\t%d\n",
11488756828aSChristina Jacob pool->thresh_int_ena, pool->thresh_up);
11493feac505SGeetha sowjanya seq_printf(m, "W8: thresh_qint_idx\t%d\nW8: err_qint_idx\t%d\n",
11508756828aSChristina Jacob pool->thresh_qint_idx, pool->err_qint_idx);
11513feac505SGeetha sowjanya if (!is_rvu_otx2(rvu))
11523feac505SGeetha sowjanya seq_printf(m, "W8: fc_msh_dst\t\t%d\n", pool->fc_msh_dst);
11538756828aSChristina Jacob }
11548756828aSChristina Jacob
11558756828aSChristina Jacob /* Reads aura/pool's ctx from admin queue */
rvu_dbg_npa_ctx_display(struct seq_file * m,void * unused,int ctype)11568756828aSChristina Jacob static int rvu_dbg_npa_ctx_display(struct seq_file *m, void *unused, int ctype)
11578756828aSChristina Jacob {
11588756828aSChristina Jacob void (*print_npa_ctx)(struct seq_file *m, struct npa_aq_enq_rsp *rsp);
11598756828aSChristina Jacob struct npa_aq_enq_req aq_req;
11608756828aSChristina Jacob struct npa_aq_enq_rsp rsp;
11618756828aSChristina Jacob struct rvu_pfvf *pfvf;
11628756828aSChristina Jacob int aura, rc, max_id;
11638756828aSChristina Jacob int npalf, id, all;
11648756828aSChristina Jacob struct rvu *rvu;
11658756828aSChristina Jacob u16 pcifunc;
11668756828aSChristina Jacob
11678756828aSChristina Jacob rvu = m->private;
11688756828aSChristina Jacob
11698756828aSChristina Jacob switch (ctype) {
11708756828aSChristina Jacob case NPA_AQ_CTYPE_AURA:
11718756828aSChristina Jacob npalf = rvu->rvu_dbg.npa_aura_ctx.lf;
11728756828aSChristina Jacob id = rvu->rvu_dbg.npa_aura_ctx.id;
11738756828aSChristina Jacob all = rvu->rvu_dbg.npa_aura_ctx.all;
11748756828aSChristina Jacob break;
11758756828aSChristina Jacob
11768756828aSChristina Jacob case NPA_AQ_CTYPE_POOL:
11778756828aSChristina Jacob npalf = rvu->rvu_dbg.npa_pool_ctx.lf;
11788756828aSChristina Jacob id = rvu->rvu_dbg.npa_pool_ctx.id;
11798756828aSChristina Jacob all = rvu->rvu_dbg.npa_pool_ctx.all;
11808756828aSChristina Jacob break;
11818756828aSChristina Jacob default:
11828756828aSChristina Jacob return -EINVAL;
11838756828aSChristina Jacob }
11848756828aSChristina Jacob
11850f3ce484SRakesh Babu if (!rvu_dbg_is_valid_lf(rvu, BLKADDR_NPA, npalf, &pcifunc))
11868756828aSChristina Jacob return -EINVAL;
11878756828aSChristina Jacob
11888756828aSChristina Jacob pfvf = rvu_get_pfvf(rvu, pcifunc);
11898756828aSChristina Jacob if (ctype == NPA_AQ_CTYPE_AURA && !pfvf->aura_ctx) {
11908756828aSChristina Jacob seq_puts(m, "Aura context is not initialized\n");
11918756828aSChristina Jacob return -EINVAL;
11928756828aSChristina Jacob } else if (ctype == NPA_AQ_CTYPE_POOL && !pfvf->pool_ctx) {
11938756828aSChristina Jacob seq_puts(m, "Pool context is not initialized\n");
11948756828aSChristina Jacob return -EINVAL;
11958756828aSChristina Jacob }
11968756828aSChristina Jacob
11978756828aSChristina Jacob memset(&aq_req, 0, sizeof(struct npa_aq_enq_req));
11988756828aSChristina Jacob aq_req.hdr.pcifunc = pcifunc;
11998756828aSChristina Jacob aq_req.ctype = ctype;
12008756828aSChristina Jacob aq_req.op = NPA_AQ_INSTOP_READ;
12018756828aSChristina Jacob if (ctype == NPA_AQ_CTYPE_AURA) {
12028756828aSChristina Jacob max_id = pfvf->aura_ctx->qsize;
12038756828aSChristina Jacob print_npa_ctx = print_npa_aura_ctx;
12048756828aSChristina Jacob } else {
12058756828aSChristina Jacob max_id = pfvf->pool_ctx->qsize;
12068756828aSChristina Jacob print_npa_ctx = print_npa_pool_ctx;
12078756828aSChristina Jacob }
12088756828aSChristina Jacob
12098756828aSChristina Jacob if (id < 0 || id >= max_id) {
12108756828aSChristina Jacob seq_printf(m, "Invalid %s, valid range is 0-%d\n",
12118756828aSChristina Jacob (ctype == NPA_AQ_CTYPE_AURA) ? "aura" : "pool",
12128756828aSChristina Jacob max_id - 1);
12138756828aSChristina Jacob return -EINVAL;
12148756828aSChristina Jacob }
12158756828aSChristina Jacob
12168756828aSChristina Jacob if (all)
12178756828aSChristina Jacob id = 0;
12188756828aSChristina Jacob else
12198756828aSChristina Jacob max_id = id + 1;
12208756828aSChristina Jacob
12218756828aSChristina Jacob for (aura = id; aura < max_id; aura++) {
12228756828aSChristina Jacob aq_req.aura_id = aura;
1223ab6dddd2SSubbaraya Sundeep
1224ab6dddd2SSubbaraya Sundeep /* Skip if queue is uninitialized */
1225ab6dddd2SSubbaraya Sundeep if (ctype == NPA_AQ_CTYPE_POOL && !test_bit(aura, pfvf->pool_bmap))
1226ab6dddd2SSubbaraya Sundeep continue;
1227ab6dddd2SSubbaraya Sundeep
12288756828aSChristina Jacob seq_printf(m, "======%s : %d=======\n",
12298756828aSChristina Jacob (ctype == NPA_AQ_CTYPE_AURA) ? "AURA" : "POOL",
12308756828aSChristina Jacob aq_req.aura_id);
12318756828aSChristina Jacob rc = rvu_npa_aq_enq_inst(rvu, &aq_req, &rsp);
12328756828aSChristina Jacob if (rc) {
12338756828aSChristina Jacob seq_puts(m, "Failed to read context\n");
12348756828aSChristina Jacob return -EINVAL;
12358756828aSChristina Jacob }
12368756828aSChristina Jacob print_npa_ctx(m, &rsp);
12378756828aSChristina Jacob }
12388756828aSChristina Jacob return 0;
12398756828aSChristina Jacob }
12408756828aSChristina Jacob
write_npa_ctx(struct rvu * rvu,bool all,int npalf,int id,int ctype)12418756828aSChristina Jacob static int write_npa_ctx(struct rvu *rvu, bool all,
12428756828aSChristina Jacob int npalf, int id, int ctype)
12438756828aSChristina Jacob {
12448756828aSChristina Jacob struct rvu_pfvf *pfvf;
12458756828aSChristina Jacob int max_id = 0;
12468756828aSChristina Jacob u16 pcifunc;
12478756828aSChristina Jacob
12480f3ce484SRakesh Babu if (!rvu_dbg_is_valid_lf(rvu, BLKADDR_NPA, npalf, &pcifunc))
12498756828aSChristina Jacob return -EINVAL;
12508756828aSChristina Jacob
12518756828aSChristina Jacob pfvf = rvu_get_pfvf(rvu, pcifunc);
12528756828aSChristina Jacob
12538756828aSChristina Jacob if (ctype == NPA_AQ_CTYPE_AURA) {
12548756828aSChristina Jacob if (!pfvf->aura_ctx) {
12558756828aSChristina Jacob dev_warn(rvu->dev, "Aura context is not initialized\n");
12568756828aSChristina Jacob return -EINVAL;
12578756828aSChristina Jacob }
12588756828aSChristina Jacob max_id = pfvf->aura_ctx->qsize;
12598756828aSChristina Jacob } else if (ctype == NPA_AQ_CTYPE_POOL) {
12608756828aSChristina Jacob if (!pfvf->pool_ctx) {
12618756828aSChristina Jacob dev_warn(rvu->dev, "Pool context is not initialized\n");
12628756828aSChristina Jacob return -EINVAL;
12638756828aSChristina Jacob }
12648756828aSChristina Jacob max_id = pfvf->pool_ctx->qsize;
12658756828aSChristina Jacob }
12668756828aSChristina Jacob
12678756828aSChristina Jacob if (id < 0 || id >= max_id) {
12688756828aSChristina Jacob dev_warn(rvu->dev, "Invalid %s, valid range is 0-%d\n",
12698756828aSChristina Jacob (ctype == NPA_AQ_CTYPE_AURA) ? "aura" : "pool",
12708756828aSChristina Jacob max_id - 1);
12718756828aSChristina Jacob return -EINVAL;
12728756828aSChristina Jacob }
12738756828aSChristina Jacob
12748756828aSChristina Jacob switch (ctype) {
12758756828aSChristina Jacob case NPA_AQ_CTYPE_AURA:
12768756828aSChristina Jacob rvu->rvu_dbg.npa_aura_ctx.lf = npalf;
12778756828aSChristina Jacob rvu->rvu_dbg.npa_aura_ctx.id = id;
12788756828aSChristina Jacob rvu->rvu_dbg.npa_aura_ctx.all = all;
12798756828aSChristina Jacob break;
12808756828aSChristina Jacob
12818756828aSChristina Jacob case NPA_AQ_CTYPE_POOL:
12828756828aSChristina Jacob rvu->rvu_dbg.npa_pool_ctx.lf = npalf;
12838756828aSChristina Jacob rvu->rvu_dbg.npa_pool_ctx.id = id;
12848756828aSChristina Jacob rvu->rvu_dbg.npa_pool_ctx.all = all;
12858756828aSChristina Jacob break;
12868756828aSChristina Jacob default:
12878756828aSChristina Jacob return -EINVAL;
12888756828aSChristina Jacob }
12898756828aSChristina Jacob return 0;
12908756828aSChristina Jacob }
12918756828aSChristina Jacob
parse_cmd_buffer_ctx(char * cmd_buf,size_t * count,const char __user * buffer,int * npalf,int * id,bool * all)12928756828aSChristina Jacob static int parse_cmd_buffer_ctx(char *cmd_buf, size_t *count,
12938756828aSChristina Jacob const char __user *buffer, int *npalf,
12948756828aSChristina Jacob int *id, bool *all)
12958756828aSChristina Jacob {
12968756828aSChristina Jacob int bytes_not_copied;
12978756828aSChristina Jacob char *cmd_buf_tmp;
12988756828aSChristina Jacob char *subtoken;
12998756828aSChristina Jacob int ret;
13008756828aSChristina Jacob
13018756828aSChristina Jacob bytes_not_copied = copy_from_user(cmd_buf, buffer, *count);
13028756828aSChristina Jacob if (bytes_not_copied)
13038756828aSChristina Jacob return -EFAULT;
13048756828aSChristina Jacob
13058756828aSChristina Jacob cmd_buf[*count] = '\0';
13068756828aSChristina Jacob cmd_buf_tmp = strchr(cmd_buf, '\n');
13078756828aSChristina Jacob
13088756828aSChristina Jacob if (cmd_buf_tmp) {
13098756828aSChristina Jacob *cmd_buf_tmp = '\0';
13108756828aSChristina Jacob *count = cmd_buf_tmp - cmd_buf + 1;
13118756828aSChristina Jacob }
13128756828aSChristina Jacob
13138756828aSChristina Jacob subtoken = strsep(&cmd_buf, " ");
13148756828aSChristina Jacob ret = subtoken ? kstrtoint(subtoken, 10, npalf) : -EINVAL;
13158756828aSChristina Jacob if (ret < 0)
13168756828aSChristina Jacob return ret;
13178756828aSChristina Jacob subtoken = strsep(&cmd_buf, " ");
13188756828aSChristina Jacob if (subtoken && strcmp(subtoken, "all") == 0) {
13198756828aSChristina Jacob *all = true;
13208756828aSChristina Jacob } else {
13218756828aSChristina Jacob ret = subtoken ? kstrtoint(subtoken, 10, id) : -EINVAL;
13228756828aSChristina Jacob if (ret < 0)
13238756828aSChristina Jacob return ret;
13248756828aSChristina Jacob }
13258756828aSChristina Jacob if (cmd_buf)
13268756828aSChristina Jacob return -EINVAL;
13278756828aSChristina Jacob return ret;
13288756828aSChristina Jacob }
13298756828aSChristina Jacob
rvu_dbg_npa_ctx_write(struct file * filp,const char __user * buffer,size_t count,loff_t * ppos,int ctype)13308756828aSChristina Jacob static ssize_t rvu_dbg_npa_ctx_write(struct file *filp,
13318756828aSChristina Jacob const char __user *buffer,
13328756828aSChristina Jacob size_t count, loff_t *ppos, int ctype)
13338756828aSChristina Jacob {
13348756828aSChristina Jacob char *cmd_buf, *ctype_string = (ctype == NPA_AQ_CTYPE_AURA) ?
13358756828aSChristina Jacob "aura" : "pool";
13368756828aSChristina Jacob struct seq_file *seqfp = filp->private_data;
13378756828aSChristina Jacob struct rvu *rvu = seqfp->private;
13388756828aSChristina Jacob int npalf, id = 0, ret;
13398756828aSChristina Jacob bool all = false;
13408756828aSChristina Jacob
13418756828aSChristina Jacob if ((*ppos != 0) || !count)
13428756828aSChristina Jacob return -EINVAL;
13438756828aSChristina Jacob
13448756828aSChristina Jacob cmd_buf = kzalloc(count + 1, GFP_KERNEL);
13458756828aSChristina Jacob if (!cmd_buf)
13468756828aSChristina Jacob return count;
13478756828aSChristina Jacob ret = parse_cmd_buffer_ctx(cmd_buf, &count, buffer,
13488756828aSChristina Jacob &npalf, &id, &all);
13498756828aSChristina Jacob if (ret < 0) {
13508756828aSChristina Jacob dev_info(rvu->dev,
13518756828aSChristina Jacob "Usage: echo <npalf> [%s number/all] > %s_ctx\n",
13528756828aSChristina Jacob ctype_string, ctype_string);
13538756828aSChristina Jacob goto done;
13548756828aSChristina Jacob } else {
13558756828aSChristina Jacob ret = write_npa_ctx(rvu, all, npalf, id, ctype);
13568756828aSChristina Jacob }
13578756828aSChristina Jacob done:
13588756828aSChristina Jacob kfree(cmd_buf);
13598756828aSChristina Jacob return ret ? ret : count;
13608756828aSChristina Jacob }
13618756828aSChristina Jacob
rvu_dbg_npa_aura_ctx_write(struct file * filp,const char __user * buffer,size_t count,loff_t * ppos)13628756828aSChristina Jacob static ssize_t rvu_dbg_npa_aura_ctx_write(struct file *filp,
13638756828aSChristina Jacob const char __user *buffer,
13648756828aSChristina Jacob size_t count, loff_t *ppos)
13658756828aSChristina Jacob {
13668756828aSChristina Jacob return rvu_dbg_npa_ctx_write(filp, buffer, count, ppos,
13678756828aSChristina Jacob NPA_AQ_CTYPE_AURA);
13688756828aSChristina Jacob }
13698756828aSChristina Jacob
rvu_dbg_npa_aura_ctx_display(struct seq_file * filp,void * unused)13708756828aSChristina Jacob static int rvu_dbg_npa_aura_ctx_display(struct seq_file *filp, void *unused)
13718756828aSChristina Jacob {
13728756828aSChristina Jacob return rvu_dbg_npa_ctx_display(filp, unused, NPA_AQ_CTYPE_AURA);
13738756828aSChristina Jacob }
13748756828aSChristina Jacob
13758756828aSChristina Jacob RVU_DEBUG_SEQ_FOPS(npa_aura_ctx, npa_aura_ctx_display, npa_aura_ctx_write);
13768756828aSChristina Jacob
rvu_dbg_npa_pool_ctx_write(struct file * filp,const char __user * buffer,size_t count,loff_t * ppos)13778756828aSChristina Jacob static ssize_t rvu_dbg_npa_pool_ctx_write(struct file *filp,
13788756828aSChristina Jacob const char __user *buffer,
13798756828aSChristina Jacob size_t count, loff_t *ppos)
13808756828aSChristina Jacob {
13818756828aSChristina Jacob return rvu_dbg_npa_ctx_write(filp, buffer, count, ppos,
13828756828aSChristina Jacob NPA_AQ_CTYPE_POOL);
13838756828aSChristina Jacob }
13848756828aSChristina Jacob
rvu_dbg_npa_pool_ctx_display(struct seq_file * filp,void * unused)13858756828aSChristina Jacob static int rvu_dbg_npa_pool_ctx_display(struct seq_file *filp, void *unused)
13868756828aSChristina Jacob {
13878756828aSChristina Jacob return rvu_dbg_npa_ctx_display(filp, unused, NPA_AQ_CTYPE_POOL);
13888756828aSChristina Jacob }
13898756828aSChristina Jacob
13908756828aSChristina Jacob RVU_DEBUG_SEQ_FOPS(npa_pool_ctx, npa_pool_ctx_display, npa_pool_ctx_write);
13918756828aSChristina Jacob
ndc_cache_stats(struct seq_file * s,int blk_addr,int ctype,int transaction)1392c5a797e0SPrakash Brahmajyosyula static void ndc_cache_stats(struct seq_file *s, int blk_addr,
1393c5a797e0SPrakash Brahmajyosyula int ctype, int transaction)
1394c5a797e0SPrakash Brahmajyosyula {
1395c5a797e0SPrakash Brahmajyosyula u64 req, out_req, lat, cant_alloc;
13960f3ce484SRakesh Babu struct nix_hw *nix_hw;
13970f3ce484SRakesh Babu struct rvu *rvu;
1398c5a797e0SPrakash Brahmajyosyula int port;
1399c5a797e0SPrakash Brahmajyosyula
14000f3ce484SRakesh Babu if (blk_addr == BLKADDR_NDC_NPA0) {
14010f3ce484SRakesh Babu rvu = s->private;
14020f3ce484SRakesh Babu } else {
14030f3ce484SRakesh Babu nix_hw = s->private;
14040f3ce484SRakesh Babu rvu = nix_hw->rvu;
14050f3ce484SRakesh Babu }
14060f3ce484SRakesh Babu
1407c5a797e0SPrakash Brahmajyosyula for (port = 0; port < NDC_MAX_PORT; port++) {
1408c5a797e0SPrakash Brahmajyosyula req = rvu_read64(rvu, blk_addr, NDC_AF_PORTX_RTX_RWX_REQ_PC
1409c5a797e0SPrakash Brahmajyosyula (port, ctype, transaction));
1410c5a797e0SPrakash Brahmajyosyula lat = rvu_read64(rvu, blk_addr, NDC_AF_PORTX_RTX_RWX_LAT_PC
1411c5a797e0SPrakash Brahmajyosyula (port, ctype, transaction));
1412c5a797e0SPrakash Brahmajyosyula out_req = rvu_read64(rvu, blk_addr,
1413c5a797e0SPrakash Brahmajyosyula NDC_AF_PORTX_RTX_RWX_OSTDN_PC
1414c5a797e0SPrakash Brahmajyosyula (port, ctype, transaction));
1415c5a797e0SPrakash Brahmajyosyula cant_alloc = rvu_read64(rvu, blk_addr,
1416c5a797e0SPrakash Brahmajyosyula NDC_AF_PORTX_RTX_CANT_ALLOC_PC
1417c5a797e0SPrakash Brahmajyosyula (port, transaction));
1418c5a797e0SPrakash Brahmajyosyula seq_printf(s, "\nPort:%d\n", port);
1419c5a797e0SPrakash Brahmajyosyula seq_printf(s, "\tTotal Requests:\t\t%lld\n", req);
1420c5a797e0SPrakash Brahmajyosyula seq_printf(s, "\tTotal Time Taken:\t%lld cycles\n", lat);
1421c5a797e0SPrakash Brahmajyosyula seq_printf(s, "\tAvg Latency:\t\t%lld cycles\n", lat / req);
1422c5a797e0SPrakash Brahmajyosyula seq_printf(s, "\tOutstanding Requests:\t%lld\n", out_req);
1423c5a797e0SPrakash Brahmajyosyula seq_printf(s, "\tCant Alloc Requests:\t%lld\n", cant_alloc);
1424c5a797e0SPrakash Brahmajyosyula }
1425c5a797e0SPrakash Brahmajyosyula }
1426c5a797e0SPrakash Brahmajyosyula
ndc_blk_cache_stats(struct seq_file * s,int idx,int blk_addr)1427c5a797e0SPrakash Brahmajyosyula static int ndc_blk_cache_stats(struct seq_file *s, int idx, int blk_addr)
1428c5a797e0SPrakash Brahmajyosyula {
1429c5a797e0SPrakash Brahmajyosyula seq_puts(s, "\n***** CACHE mode read stats *****\n");
1430c5a797e0SPrakash Brahmajyosyula ndc_cache_stats(s, blk_addr, CACHING, NDC_READ_TRANS);
1431c5a797e0SPrakash Brahmajyosyula seq_puts(s, "\n***** CACHE mode write stats *****\n");
1432c5a797e0SPrakash Brahmajyosyula ndc_cache_stats(s, blk_addr, CACHING, NDC_WRITE_TRANS);
1433c5a797e0SPrakash Brahmajyosyula seq_puts(s, "\n***** BY-PASS mode read stats *****\n");
1434c5a797e0SPrakash Brahmajyosyula ndc_cache_stats(s, blk_addr, BYPASS, NDC_READ_TRANS);
1435c5a797e0SPrakash Brahmajyosyula seq_puts(s, "\n***** BY-PASS mode write stats *****\n");
1436c5a797e0SPrakash Brahmajyosyula ndc_cache_stats(s, blk_addr, BYPASS, NDC_WRITE_TRANS);
1437c5a797e0SPrakash Brahmajyosyula return 0;
1438c5a797e0SPrakash Brahmajyosyula }
1439c5a797e0SPrakash Brahmajyosyula
rvu_dbg_npa_ndc_cache_display(struct seq_file * filp,void * unused)1440c5a797e0SPrakash Brahmajyosyula static int rvu_dbg_npa_ndc_cache_display(struct seq_file *filp, void *unused)
1441c5a797e0SPrakash Brahmajyosyula {
1442c5a797e0SPrakash Brahmajyosyula return ndc_blk_cache_stats(filp, NPA0_U, BLKADDR_NDC_NPA0);
1443c5a797e0SPrakash Brahmajyosyula }
1444c5a797e0SPrakash Brahmajyosyula
1445c5a797e0SPrakash Brahmajyosyula RVU_DEBUG_SEQ_FOPS(npa_ndc_cache, npa_ndc_cache_display, NULL);
1446c5a797e0SPrakash Brahmajyosyula
ndc_blk_hits_miss_stats(struct seq_file * s,int idx,int blk_addr)1447c5a797e0SPrakash Brahmajyosyula static int ndc_blk_hits_miss_stats(struct seq_file *s, int idx, int blk_addr)
1448c5a797e0SPrakash Brahmajyosyula {
14490f3ce484SRakesh Babu struct nix_hw *nix_hw;
14500f3ce484SRakesh Babu struct rvu *rvu;
1451c5a797e0SPrakash Brahmajyosyula int bank, max_bank;
1452ea9dd2e5SSuman Ghosh u64 ndc_af_const;
1453c5a797e0SPrakash Brahmajyosyula
14540f3ce484SRakesh Babu if (blk_addr == BLKADDR_NDC_NPA0) {
14550f3ce484SRakesh Babu rvu = s->private;
14560f3ce484SRakesh Babu } else {
14570f3ce484SRakesh Babu nix_hw = s->private;
14580f3ce484SRakesh Babu rvu = nix_hw->rvu;
14590f3ce484SRakesh Babu }
14600f3ce484SRakesh Babu
1461ea9dd2e5SSuman Ghosh ndc_af_const = rvu_read64(rvu, blk_addr, NDC_AF_CONST);
1462ea9dd2e5SSuman Ghosh max_bank = FIELD_GET(NDC_AF_BANK_MASK, ndc_af_const);
1463c5a797e0SPrakash Brahmajyosyula for (bank = 0; bank < max_bank; bank++) {
1464c5a797e0SPrakash Brahmajyosyula seq_printf(s, "BANK:%d\n", bank);
1465c5a797e0SPrakash Brahmajyosyula seq_printf(s, "\tHits:\t%lld\n",
1466c5a797e0SPrakash Brahmajyosyula (u64)rvu_read64(rvu, blk_addr,
1467c5a797e0SPrakash Brahmajyosyula NDC_AF_BANKX_HIT_PC(bank)));
1468c5a797e0SPrakash Brahmajyosyula seq_printf(s, "\tMiss:\t%lld\n",
1469c5a797e0SPrakash Brahmajyosyula (u64)rvu_read64(rvu, blk_addr,
1470c5a797e0SPrakash Brahmajyosyula NDC_AF_BANKX_MISS_PC(bank)));
1471c5a797e0SPrakash Brahmajyosyula }
1472c5a797e0SPrakash Brahmajyosyula return 0;
1473c5a797e0SPrakash Brahmajyosyula }
1474c5a797e0SPrakash Brahmajyosyula
rvu_dbg_nix_ndc_rx_cache_display(struct seq_file * filp,void * unused)1475c5a797e0SPrakash Brahmajyosyula static int rvu_dbg_nix_ndc_rx_cache_display(struct seq_file *filp, void *unused)
1476c5a797e0SPrakash Brahmajyosyula {
14770f3ce484SRakesh Babu struct nix_hw *nix_hw = filp->private;
14780f3ce484SRakesh Babu int blkaddr = 0;
14790f3ce484SRakesh Babu int ndc_idx = 0;
14800f3ce484SRakesh Babu
14810f3ce484SRakesh Babu blkaddr = (nix_hw->blkaddr == BLKADDR_NIX1 ?
14820f3ce484SRakesh Babu BLKADDR_NDC_NIX1_RX : BLKADDR_NDC_NIX0_RX);
14830f3ce484SRakesh Babu ndc_idx = (nix_hw->blkaddr == BLKADDR_NIX1 ? NIX1_RX : NIX0_RX);
14840f3ce484SRakesh Babu
14850f3ce484SRakesh Babu return ndc_blk_cache_stats(filp, ndc_idx, blkaddr);
1486c5a797e0SPrakash Brahmajyosyula }
1487c5a797e0SPrakash Brahmajyosyula
1488c5a797e0SPrakash Brahmajyosyula RVU_DEBUG_SEQ_FOPS(nix_ndc_rx_cache, nix_ndc_rx_cache_display, NULL);
1489c5a797e0SPrakash Brahmajyosyula
rvu_dbg_nix_ndc_tx_cache_display(struct seq_file * filp,void * unused)1490c5a797e0SPrakash Brahmajyosyula static int rvu_dbg_nix_ndc_tx_cache_display(struct seq_file *filp, void *unused)
1491c5a797e0SPrakash Brahmajyosyula {
14920f3ce484SRakesh Babu struct nix_hw *nix_hw = filp->private;
14930f3ce484SRakesh Babu int blkaddr = 0;
14940f3ce484SRakesh Babu int ndc_idx = 0;
14950f3ce484SRakesh Babu
14960f3ce484SRakesh Babu blkaddr = (nix_hw->blkaddr == BLKADDR_NIX1 ?
14970f3ce484SRakesh Babu BLKADDR_NDC_NIX1_TX : BLKADDR_NDC_NIX0_TX);
14980f3ce484SRakesh Babu ndc_idx = (nix_hw->blkaddr == BLKADDR_NIX1 ? NIX1_TX : NIX0_TX);
14990f3ce484SRakesh Babu
15000f3ce484SRakesh Babu return ndc_blk_cache_stats(filp, ndc_idx, blkaddr);
1501c5a797e0SPrakash Brahmajyosyula }
1502c5a797e0SPrakash Brahmajyosyula
1503c5a797e0SPrakash Brahmajyosyula RVU_DEBUG_SEQ_FOPS(nix_ndc_tx_cache, nix_ndc_tx_cache_display, NULL);
1504c5a797e0SPrakash Brahmajyosyula
rvu_dbg_npa_ndc_hits_miss_display(struct seq_file * filp,void * unused)1505c5a797e0SPrakash Brahmajyosyula static int rvu_dbg_npa_ndc_hits_miss_display(struct seq_file *filp,
1506c5a797e0SPrakash Brahmajyosyula void *unused)
1507c5a797e0SPrakash Brahmajyosyula {
1508c5a797e0SPrakash Brahmajyosyula return ndc_blk_hits_miss_stats(filp, NPA0_U, BLKADDR_NDC_NPA0);
1509c5a797e0SPrakash Brahmajyosyula }
1510c5a797e0SPrakash Brahmajyosyula
1511c5a797e0SPrakash Brahmajyosyula RVU_DEBUG_SEQ_FOPS(npa_ndc_hits_miss, npa_ndc_hits_miss_display, NULL);
1512c5a797e0SPrakash Brahmajyosyula
rvu_dbg_nix_ndc_rx_hits_miss_display(struct seq_file * filp,void * unused)1513c5a797e0SPrakash Brahmajyosyula static int rvu_dbg_nix_ndc_rx_hits_miss_display(struct seq_file *filp,
1514c5a797e0SPrakash Brahmajyosyula void *unused)
1515c5a797e0SPrakash Brahmajyosyula {
15160f3ce484SRakesh Babu struct nix_hw *nix_hw = filp->private;
15170f3ce484SRakesh Babu int ndc_idx = NPA0_U;
15180f3ce484SRakesh Babu int blkaddr = 0;
15190f3ce484SRakesh Babu
15200f3ce484SRakesh Babu blkaddr = (nix_hw->blkaddr == BLKADDR_NIX1 ?
15210f3ce484SRakesh Babu BLKADDR_NDC_NIX1_RX : BLKADDR_NDC_NIX0_RX);
15220f3ce484SRakesh Babu
15230f3ce484SRakesh Babu return ndc_blk_hits_miss_stats(filp, ndc_idx, blkaddr);
1524c5a797e0SPrakash Brahmajyosyula }
1525c5a797e0SPrakash Brahmajyosyula
1526c5a797e0SPrakash Brahmajyosyula RVU_DEBUG_SEQ_FOPS(nix_ndc_rx_hits_miss, nix_ndc_rx_hits_miss_display, NULL);
1527c5a797e0SPrakash Brahmajyosyula
rvu_dbg_nix_ndc_tx_hits_miss_display(struct seq_file * filp,void * unused)1528c5a797e0SPrakash Brahmajyosyula static int rvu_dbg_nix_ndc_tx_hits_miss_display(struct seq_file *filp,
1529c5a797e0SPrakash Brahmajyosyula void *unused)
1530c5a797e0SPrakash Brahmajyosyula {
15310f3ce484SRakesh Babu struct nix_hw *nix_hw = filp->private;
15320f3ce484SRakesh Babu int ndc_idx = NPA0_U;
15330f3ce484SRakesh Babu int blkaddr = 0;
15340f3ce484SRakesh Babu
15350f3ce484SRakesh Babu blkaddr = (nix_hw->blkaddr == BLKADDR_NIX1 ?
15360f3ce484SRakesh Babu BLKADDR_NDC_NIX1_TX : BLKADDR_NDC_NIX0_TX);
15370f3ce484SRakesh Babu
15380f3ce484SRakesh Babu return ndc_blk_hits_miss_stats(filp, ndc_idx, blkaddr);
1539c5a797e0SPrakash Brahmajyosyula }
1540c5a797e0SPrakash Brahmajyosyula
1541c5a797e0SPrakash Brahmajyosyula RVU_DEBUG_SEQ_FOPS(nix_ndc_tx_hits_miss, nix_ndc_tx_hits_miss_display, NULL);
1542c5a797e0SPrakash Brahmajyosyula
print_nix_cn10k_sq_ctx(struct seq_file * m,struct nix_cn10k_sq_ctx_s * sq_ctx)15433feac505SGeetha sowjanya static void print_nix_cn10k_sq_ctx(struct seq_file *m,
15443feac505SGeetha sowjanya struct nix_cn10k_sq_ctx_s *sq_ctx)
15453feac505SGeetha sowjanya {
15463feac505SGeetha sowjanya seq_printf(m, "W0: ena \t\t\t%d\nW0: qint_idx \t\t\t%d\n",
15473feac505SGeetha sowjanya sq_ctx->ena, sq_ctx->qint_idx);
15483feac505SGeetha sowjanya seq_printf(m, "W0: substream \t\t\t0x%03x\nW0: sdp_mcast \t\t\t%d\n",
15493feac505SGeetha sowjanya sq_ctx->substream, sq_ctx->sdp_mcast);
15503feac505SGeetha sowjanya seq_printf(m, "W0: cq \t\t\t\t%d\nW0: sqe_way_mask \t\t%d\n\n",
15513feac505SGeetha sowjanya sq_ctx->cq, sq_ctx->sqe_way_mask);
15523feac505SGeetha sowjanya
15533feac505SGeetha sowjanya seq_printf(m, "W1: smq \t\t\t%d\nW1: cq_ena \t\t\t%d\nW1: xoff\t\t\t%d\n",
15543feac505SGeetha sowjanya sq_ctx->smq, sq_ctx->cq_ena, sq_ctx->xoff);
15553feac505SGeetha sowjanya seq_printf(m, "W1: sso_ena \t\t\t%d\nW1: smq_rr_weight\t\t%d\n",
15563feac505SGeetha sowjanya sq_ctx->sso_ena, sq_ctx->smq_rr_weight);
15573feac505SGeetha sowjanya seq_printf(m, "W1: default_chan\t\t%d\nW1: sqb_count\t\t\t%d\n\n",
15583feac505SGeetha sowjanya sq_ctx->default_chan, sq_ctx->sqb_count);
15593feac505SGeetha sowjanya
15603feac505SGeetha sowjanya seq_printf(m, "W2: smq_rr_count_lb \t\t%d\n", sq_ctx->smq_rr_count_lb);
15613feac505SGeetha sowjanya seq_printf(m, "W2: smq_rr_count_ub \t\t%d\n", sq_ctx->smq_rr_count_ub);
15623feac505SGeetha sowjanya seq_printf(m, "W2: sqb_aura \t\t\t%d\nW2: sq_int \t\t\t%d\n",
15633feac505SGeetha sowjanya sq_ctx->sqb_aura, sq_ctx->sq_int);
15643feac505SGeetha sowjanya seq_printf(m, "W2: sq_int_ena \t\t\t%d\nW2: sqe_stype \t\t\t%d\n",
15653feac505SGeetha sowjanya sq_ctx->sq_int_ena, sq_ctx->sqe_stype);
15663feac505SGeetha sowjanya
15673feac505SGeetha sowjanya seq_printf(m, "W3: max_sqe_size\t\t%d\nW3: cq_limit\t\t\t%d\n",
15683feac505SGeetha sowjanya sq_ctx->max_sqe_size, sq_ctx->cq_limit);
15693feac505SGeetha sowjanya seq_printf(m, "W3: lmt_dis \t\t\t%d\nW3: mnq_dis \t\t\t%d\n",
15703feac505SGeetha sowjanya sq_ctx->mnq_dis, sq_ctx->lmt_dis);
15713feac505SGeetha sowjanya seq_printf(m, "W3: smq_next_sq\t\t\t%d\nW3: smq_lso_segnum\t\t%d\n",
15723feac505SGeetha sowjanya sq_ctx->smq_next_sq, sq_ctx->smq_lso_segnum);
15733feac505SGeetha sowjanya seq_printf(m, "W3: tail_offset \t\t%d\nW3: smenq_offset\t\t%d\n",
15743feac505SGeetha sowjanya sq_ctx->tail_offset, sq_ctx->smenq_offset);
15753feac505SGeetha sowjanya seq_printf(m, "W3: head_offset\t\t\t%d\nW3: smenq_next_sqb_vld\t\t%d\n\n",
15763feac505SGeetha sowjanya sq_ctx->head_offset, sq_ctx->smenq_next_sqb_vld);
15773feac505SGeetha sowjanya
1578c5d731c5SGeetha sowjanya seq_printf(m, "W3: smq_next_sq_vld\t\t%d\nW3: smq_pend\t\t\t%d\n",
1579c5d731c5SGeetha sowjanya sq_ctx->smq_next_sq_vld, sq_ctx->smq_pend);
15803feac505SGeetha sowjanya seq_printf(m, "W4: next_sqb \t\t\t%llx\n\n", sq_ctx->next_sqb);
15813feac505SGeetha sowjanya seq_printf(m, "W5: tail_sqb \t\t\t%llx\n\n", sq_ctx->tail_sqb);
15823feac505SGeetha sowjanya seq_printf(m, "W6: smenq_sqb \t\t\t%llx\n\n", sq_ctx->smenq_sqb);
15833feac505SGeetha sowjanya seq_printf(m, "W7: smenq_next_sqb \t\t%llx\n\n",
15843feac505SGeetha sowjanya sq_ctx->smenq_next_sqb);
15853feac505SGeetha sowjanya
15863feac505SGeetha sowjanya seq_printf(m, "W8: head_sqb\t\t\t%llx\n\n", sq_ctx->head_sqb);
15873feac505SGeetha sowjanya
15883feac505SGeetha sowjanya seq_printf(m, "W9: vfi_lso_total\t\t%d\n", sq_ctx->vfi_lso_total);
15893feac505SGeetha sowjanya seq_printf(m, "W9: vfi_lso_sizem1\t\t%d\nW9: vfi_lso_sb\t\t\t%d\n",
15903feac505SGeetha sowjanya sq_ctx->vfi_lso_sizem1, sq_ctx->vfi_lso_sb);
15913feac505SGeetha sowjanya seq_printf(m, "W9: vfi_lso_mps\t\t\t%d\nW9: vfi_lso_vlan0_ins_ena\t%d\n",
15923feac505SGeetha sowjanya sq_ctx->vfi_lso_mps, sq_ctx->vfi_lso_vlan0_ins_ena);
15933feac505SGeetha sowjanya seq_printf(m, "W9: vfi_lso_vlan1_ins_ena\t%d\nW9: vfi_lso_vld \t\t%d\n\n",
15943feac505SGeetha sowjanya sq_ctx->vfi_lso_vld, sq_ctx->vfi_lso_vlan1_ins_ena);
15953feac505SGeetha sowjanya
15963feac505SGeetha sowjanya seq_printf(m, "W10: scm_lso_rem \t\t%llu\n\n",
15973feac505SGeetha sowjanya (u64)sq_ctx->scm_lso_rem);
15983feac505SGeetha sowjanya seq_printf(m, "W11: octs \t\t\t%llu\n\n", (u64)sq_ctx->octs);
15993feac505SGeetha sowjanya seq_printf(m, "W12: pkts \t\t\t%llu\n\n", (u64)sq_ctx->pkts);
16003feac505SGeetha sowjanya seq_printf(m, "W14: dropped_octs \t\t%llu\n\n",
16013feac505SGeetha sowjanya (u64)sq_ctx->dropped_octs);
16023feac505SGeetha sowjanya seq_printf(m, "W15: dropped_pkts \t\t%llu\n\n",
16033feac505SGeetha sowjanya (u64)sq_ctx->dropped_pkts);
16043feac505SGeetha sowjanya }
16053feac505SGeetha sowjanya
160602e202c3SPrakash Brahmajyosyula /* Dumps given nix_sq's context */
print_nix_sq_ctx(struct seq_file * m,struct nix_aq_enq_rsp * rsp)160702e202c3SPrakash Brahmajyosyula static void print_nix_sq_ctx(struct seq_file *m, struct nix_aq_enq_rsp *rsp)
160802e202c3SPrakash Brahmajyosyula {
160902e202c3SPrakash Brahmajyosyula struct nix_sq_ctx_s *sq_ctx = &rsp->sq;
16103feac505SGeetha sowjanya struct nix_hw *nix_hw = m->private;
16113feac505SGeetha sowjanya struct rvu *rvu = nix_hw->rvu;
161202e202c3SPrakash Brahmajyosyula
16133feac505SGeetha sowjanya if (!is_rvu_otx2(rvu)) {
16143feac505SGeetha sowjanya print_nix_cn10k_sq_ctx(m, (struct nix_cn10k_sq_ctx_s *)sq_ctx);
16153feac505SGeetha sowjanya return;
16163feac505SGeetha sowjanya }
161702e202c3SPrakash Brahmajyosyula seq_printf(m, "W0: sqe_way_mask \t\t%d\nW0: cq \t\t\t\t%d\n",
161802e202c3SPrakash Brahmajyosyula sq_ctx->sqe_way_mask, sq_ctx->cq);
161902e202c3SPrakash Brahmajyosyula seq_printf(m, "W0: sdp_mcast \t\t\t%d\nW0: substream \t\t\t0x%03x\n",
162002e202c3SPrakash Brahmajyosyula sq_ctx->sdp_mcast, sq_ctx->substream);
162102e202c3SPrakash Brahmajyosyula seq_printf(m, "W0: qint_idx \t\t\t%d\nW0: ena \t\t\t%d\n\n",
162202e202c3SPrakash Brahmajyosyula sq_ctx->qint_idx, sq_ctx->ena);
162302e202c3SPrakash Brahmajyosyula
162402e202c3SPrakash Brahmajyosyula seq_printf(m, "W1: sqb_count \t\t\t%d\nW1: default_chan \t\t%d\n",
162502e202c3SPrakash Brahmajyosyula sq_ctx->sqb_count, sq_ctx->default_chan);
162602e202c3SPrakash Brahmajyosyula seq_printf(m, "W1: smq_rr_quantum \t\t%d\nW1: sso_ena \t\t\t%d\n",
162702e202c3SPrakash Brahmajyosyula sq_ctx->smq_rr_quantum, sq_ctx->sso_ena);
162802e202c3SPrakash Brahmajyosyula seq_printf(m, "W1: xoff \t\t\t%d\nW1: cq_ena \t\t\t%d\nW1: smq\t\t\t\t%d\n\n",
162902e202c3SPrakash Brahmajyosyula sq_ctx->xoff, sq_ctx->cq_ena, sq_ctx->smq);
163002e202c3SPrakash Brahmajyosyula
163102e202c3SPrakash Brahmajyosyula seq_printf(m, "W2: sqe_stype \t\t\t%d\nW2: sq_int_ena \t\t\t%d\n",
163202e202c3SPrakash Brahmajyosyula sq_ctx->sqe_stype, sq_ctx->sq_int_ena);
163302e202c3SPrakash Brahmajyosyula seq_printf(m, "W2: sq_int \t\t\t%d\nW2: sqb_aura \t\t\t%d\n",
163402e202c3SPrakash Brahmajyosyula sq_ctx->sq_int, sq_ctx->sqb_aura);
163502e202c3SPrakash Brahmajyosyula seq_printf(m, "W2: smq_rr_count \t\t%d\n\n", sq_ctx->smq_rr_count);
163602e202c3SPrakash Brahmajyosyula
163702e202c3SPrakash Brahmajyosyula seq_printf(m, "W3: smq_next_sq_vld\t\t%d\nW3: smq_pend\t\t\t%d\n",
163802e202c3SPrakash Brahmajyosyula sq_ctx->smq_next_sq_vld, sq_ctx->smq_pend);
163902e202c3SPrakash Brahmajyosyula seq_printf(m, "W3: smenq_next_sqb_vld \t\t%d\nW3: head_offset\t\t\t%d\n",
164002e202c3SPrakash Brahmajyosyula sq_ctx->smenq_next_sqb_vld, sq_ctx->head_offset);
164102e202c3SPrakash Brahmajyosyula seq_printf(m, "W3: smenq_offset\t\t%d\nW3: tail_offset\t\t\t%d\n",
164202e202c3SPrakash Brahmajyosyula sq_ctx->smenq_offset, sq_ctx->tail_offset);
164302e202c3SPrakash Brahmajyosyula seq_printf(m, "W3: smq_lso_segnum \t\t%d\nW3: smq_next_sq\t\t\t%d\n",
164402e202c3SPrakash Brahmajyosyula sq_ctx->smq_lso_segnum, sq_ctx->smq_next_sq);
164502e202c3SPrakash Brahmajyosyula seq_printf(m, "W3: mnq_dis \t\t\t%d\nW3: lmt_dis \t\t\t%d\n",
164602e202c3SPrakash Brahmajyosyula sq_ctx->mnq_dis, sq_ctx->lmt_dis);
164702e202c3SPrakash Brahmajyosyula seq_printf(m, "W3: cq_limit\t\t\t%d\nW3: max_sqe_size\t\t%d\n\n",
164802e202c3SPrakash Brahmajyosyula sq_ctx->cq_limit, sq_ctx->max_sqe_size);
164902e202c3SPrakash Brahmajyosyula
165002e202c3SPrakash Brahmajyosyula seq_printf(m, "W4: next_sqb \t\t\t%llx\n\n", sq_ctx->next_sqb);
165102e202c3SPrakash Brahmajyosyula seq_printf(m, "W5: tail_sqb \t\t\t%llx\n\n", sq_ctx->tail_sqb);
165202e202c3SPrakash Brahmajyosyula seq_printf(m, "W6: smenq_sqb \t\t\t%llx\n\n", sq_ctx->smenq_sqb);
165302e202c3SPrakash Brahmajyosyula seq_printf(m, "W7: smenq_next_sqb \t\t%llx\n\n",
165402e202c3SPrakash Brahmajyosyula sq_ctx->smenq_next_sqb);
165502e202c3SPrakash Brahmajyosyula
165602e202c3SPrakash Brahmajyosyula seq_printf(m, "W8: head_sqb\t\t\t%llx\n\n", sq_ctx->head_sqb);
165702e202c3SPrakash Brahmajyosyula
165802e202c3SPrakash Brahmajyosyula seq_printf(m, "W9: vfi_lso_vld\t\t\t%d\nW9: vfi_lso_vlan1_ins_ena\t%d\n",
165902e202c3SPrakash Brahmajyosyula sq_ctx->vfi_lso_vld, sq_ctx->vfi_lso_vlan1_ins_ena);
166002e202c3SPrakash Brahmajyosyula seq_printf(m, "W9: vfi_lso_vlan0_ins_ena\t%d\nW9: vfi_lso_mps\t\t\t%d\n",
166102e202c3SPrakash Brahmajyosyula sq_ctx->vfi_lso_vlan0_ins_ena, sq_ctx->vfi_lso_mps);
166202e202c3SPrakash Brahmajyosyula seq_printf(m, "W9: vfi_lso_sb\t\t\t%d\nW9: vfi_lso_sizem1\t\t%d\n",
166302e202c3SPrakash Brahmajyosyula sq_ctx->vfi_lso_sb, sq_ctx->vfi_lso_sizem1);
166402e202c3SPrakash Brahmajyosyula seq_printf(m, "W9: vfi_lso_total\t\t%d\n\n", sq_ctx->vfi_lso_total);
166502e202c3SPrakash Brahmajyosyula
166602e202c3SPrakash Brahmajyosyula seq_printf(m, "W10: scm_lso_rem \t\t%llu\n\n",
166702e202c3SPrakash Brahmajyosyula (u64)sq_ctx->scm_lso_rem);
166802e202c3SPrakash Brahmajyosyula seq_printf(m, "W11: octs \t\t\t%llu\n\n", (u64)sq_ctx->octs);
166902e202c3SPrakash Brahmajyosyula seq_printf(m, "W12: pkts \t\t\t%llu\n\n", (u64)sq_ctx->pkts);
167002e202c3SPrakash Brahmajyosyula seq_printf(m, "W14: dropped_octs \t\t%llu\n\n",
167102e202c3SPrakash Brahmajyosyula (u64)sq_ctx->dropped_octs);
167202e202c3SPrakash Brahmajyosyula seq_printf(m, "W15: dropped_pkts \t\t%llu\n\n",
167302e202c3SPrakash Brahmajyosyula (u64)sq_ctx->dropped_pkts);
167402e202c3SPrakash Brahmajyosyula }
167502e202c3SPrakash Brahmajyosyula
print_nix_cn10k_rq_ctx(struct seq_file * m,struct nix_cn10k_rq_ctx_s * rq_ctx)16763feac505SGeetha sowjanya static void print_nix_cn10k_rq_ctx(struct seq_file *m,
16773feac505SGeetha sowjanya struct nix_cn10k_rq_ctx_s *rq_ctx)
16783feac505SGeetha sowjanya {
16793feac505SGeetha sowjanya seq_printf(m, "W0: ena \t\t\t%d\nW0: sso_ena \t\t\t%d\n",
16803feac505SGeetha sowjanya rq_ctx->ena, rq_ctx->sso_ena);
16813feac505SGeetha sowjanya seq_printf(m, "W0: ipsech_ena \t\t\t%d\nW0: ena_wqwd \t\t\t%d\n",
16823feac505SGeetha sowjanya rq_ctx->ipsech_ena, rq_ctx->ena_wqwd);
16833feac505SGeetha sowjanya seq_printf(m, "W0: cq \t\t\t\t%d\nW0: lenerr_dis \t\t\t%d\n",
16843feac505SGeetha sowjanya rq_ctx->cq, rq_ctx->lenerr_dis);
16853feac505SGeetha sowjanya seq_printf(m, "W0: csum_il4_dis \t\t%d\nW0: csum_ol4_dis \t\t%d\n",
16863feac505SGeetha sowjanya rq_ctx->csum_il4_dis, rq_ctx->csum_ol4_dis);
16873feac505SGeetha sowjanya seq_printf(m, "W0: len_il4_dis \t\t%d\nW0: len_il3_dis \t\t%d\n",
16883feac505SGeetha sowjanya rq_ctx->len_il4_dis, rq_ctx->len_il3_dis);
16893feac505SGeetha sowjanya seq_printf(m, "W0: len_ol4_dis \t\t%d\nW0: len_ol3_dis \t\t%d\n",
16903feac505SGeetha sowjanya rq_ctx->len_ol4_dis, rq_ctx->len_ol3_dis);
16913feac505SGeetha sowjanya seq_printf(m, "W0: wqe_aura \t\t\t%d\n\n", rq_ctx->wqe_aura);
16923feac505SGeetha sowjanya
16933feac505SGeetha sowjanya seq_printf(m, "W1: spb_aura \t\t\t%d\nW1: lpb_aura \t\t\t%d\n",
16943feac505SGeetha sowjanya rq_ctx->spb_aura, rq_ctx->lpb_aura);
16953feac505SGeetha sowjanya seq_printf(m, "W1: spb_aura \t\t\t%d\n", rq_ctx->spb_aura);
16963feac505SGeetha sowjanya seq_printf(m, "W1: sso_grp \t\t\t%d\nW1: sso_tt \t\t\t%d\n",
16973feac505SGeetha sowjanya rq_ctx->sso_grp, rq_ctx->sso_tt);
16983feac505SGeetha sowjanya seq_printf(m, "W1: pb_caching \t\t\t%d\nW1: wqe_caching \t\t%d\n",
16993feac505SGeetha sowjanya rq_ctx->pb_caching, rq_ctx->wqe_caching);
17003feac505SGeetha sowjanya seq_printf(m, "W1: xqe_drop_ena \t\t%d\nW1: spb_drop_ena \t\t%d\n",
17013feac505SGeetha sowjanya rq_ctx->xqe_drop_ena, rq_ctx->spb_drop_ena);
17023feac505SGeetha sowjanya seq_printf(m, "W1: lpb_drop_ena \t\t%d\nW1: pb_stashing \t\t%d\n",
17033feac505SGeetha sowjanya rq_ctx->lpb_drop_ena, rq_ctx->pb_stashing);
17043feac505SGeetha sowjanya seq_printf(m, "W1: ipsecd_drop_ena \t\t%d\nW1: chi_ena \t\t\t%d\n\n",
17053feac505SGeetha sowjanya rq_ctx->ipsecd_drop_ena, rq_ctx->chi_ena);
17063feac505SGeetha sowjanya
17073feac505SGeetha sowjanya seq_printf(m, "W2: band_prof_id \t\t%d\n", rq_ctx->band_prof_id);
17083feac505SGeetha sowjanya seq_printf(m, "W2: policer_ena \t\t%d\n", rq_ctx->policer_ena);
17093feac505SGeetha sowjanya seq_printf(m, "W2: spb_sizem1 \t\t\t%d\n", rq_ctx->spb_sizem1);
17103feac505SGeetha sowjanya seq_printf(m, "W2: wqe_skip \t\t\t%d\nW2: sqb_ena \t\t\t%d\n",
17113feac505SGeetha sowjanya rq_ctx->wqe_skip, rq_ctx->spb_ena);
17123feac505SGeetha sowjanya seq_printf(m, "W2: lpb_size1 \t\t\t%d\nW2: first_skip \t\t\t%d\n",
17133feac505SGeetha sowjanya rq_ctx->lpb_sizem1, rq_ctx->first_skip);
17143feac505SGeetha sowjanya seq_printf(m, "W2: later_skip\t\t\t%d\nW2: xqe_imm_size\t\t%d\n",
17153feac505SGeetha sowjanya rq_ctx->later_skip, rq_ctx->xqe_imm_size);
17163feac505SGeetha sowjanya seq_printf(m, "W2: xqe_imm_copy \t\t%d\nW2: xqe_hdr_split \t\t%d\n\n",
17173feac505SGeetha sowjanya rq_ctx->xqe_imm_copy, rq_ctx->xqe_hdr_split);
17183feac505SGeetha sowjanya
17193feac505SGeetha sowjanya seq_printf(m, "W3: xqe_drop \t\t\t%d\nW3: xqe_pass \t\t\t%d\n",
17203feac505SGeetha sowjanya rq_ctx->xqe_drop, rq_ctx->xqe_pass);
17213feac505SGeetha sowjanya seq_printf(m, "W3: wqe_pool_drop \t\t%d\nW3: wqe_pool_pass \t\t%d\n",
17223feac505SGeetha sowjanya rq_ctx->wqe_pool_drop, rq_ctx->wqe_pool_pass);
17233feac505SGeetha sowjanya seq_printf(m, "W3: spb_pool_drop \t\t%d\nW3: spb_pool_pass \t\t%d\n",
17243feac505SGeetha sowjanya rq_ctx->spb_pool_drop, rq_ctx->spb_pool_pass);
17253feac505SGeetha sowjanya seq_printf(m, "W3: spb_aura_drop \t\t%d\nW3: spb_aura_pass \t\t%d\n\n",
17263feac505SGeetha sowjanya rq_ctx->spb_aura_pass, rq_ctx->spb_aura_drop);
17273feac505SGeetha sowjanya
17283feac505SGeetha sowjanya seq_printf(m, "W4: lpb_aura_drop \t\t%d\nW3: lpb_aura_pass \t\t%d\n",
17293feac505SGeetha sowjanya rq_ctx->lpb_aura_pass, rq_ctx->lpb_aura_drop);
17303feac505SGeetha sowjanya seq_printf(m, "W4: lpb_pool_drop \t\t%d\nW3: lpb_pool_pass \t\t%d\n",
17313feac505SGeetha sowjanya rq_ctx->lpb_pool_drop, rq_ctx->lpb_pool_pass);
17323feac505SGeetha sowjanya seq_printf(m, "W4: rq_int \t\t\t%d\nW4: rq_int_ena\t\t\t%d\n",
17333feac505SGeetha sowjanya rq_ctx->rq_int, rq_ctx->rq_int_ena);
17343feac505SGeetha sowjanya seq_printf(m, "W4: qint_idx \t\t\t%d\n\n", rq_ctx->qint_idx);
17353feac505SGeetha sowjanya
17363feac505SGeetha sowjanya seq_printf(m, "W5: ltag \t\t\t%d\nW5: good_utag \t\t\t%d\n",
17373feac505SGeetha sowjanya rq_ctx->ltag, rq_ctx->good_utag);
17383feac505SGeetha sowjanya seq_printf(m, "W5: bad_utag \t\t\t%d\nW5: flow_tagw \t\t\t%d\n",
17393feac505SGeetha sowjanya rq_ctx->bad_utag, rq_ctx->flow_tagw);
17403feac505SGeetha sowjanya seq_printf(m, "W5: ipsec_vwqe \t\t\t%d\nW5: vwqe_ena \t\t\t%d\n",
17413feac505SGeetha sowjanya rq_ctx->ipsec_vwqe, rq_ctx->vwqe_ena);
17423feac505SGeetha sowjanya seq_printf(m, "W5: vwqe_wait \t\t\t%d\nW5: max_vsize_exp\t\t%d\n",
17433feac505SGeetha sowjanya rq_ctx->vwqe_wait, rq_ctx->max_vsize_exp);
17443feac505SGeetha sowjanya seq_printf(m, "W5: vwqe_skip \t\t\t%d\n\n", rq_ctx->vwqe_skip);
17453feac505SGeetha sowjanya
17463feac505SGeetha sowjanya seq_printf(m, "W6: octs \t\t\t%llu\n\n", (u64)rq_ctx->octs);
17473feac505SGeetha sowjanya seq_printf(m, "W7: pkts \t\t\t%llu\n\n", (u64)rq_ctx->pkts);
17483feac505SGeetha sowjanya seq_printf(m, "W8: drop_octs \t\t\t%llu\n\n", (u64)rq_ctx->drop_octs);
17493feac505SGeetha sowjanya seq_printf(m, "W9: drop_pkts \t\t\t%llu\n\n", (u64)rq_ctx->drop_pkts);
17503feac505SGeetha sowjanya seq_printf(m, "W10: re_pkts \t\t\t%llu\n", (u64)rq_ctx->re_pkts);
17513feac505SGeetha sowjanya }
17523feac505SGeetha sowjanya
175302e202c3SPrakash Brahmajyosyula /* Dumps given nix_rq's context */
print_nix_rq_ctx(struct seq_file * m,struct nix_aq_enq_rsp * rsp)175402e202c3SPrakash Brahmajyosyula static void print_nix_rq_ctx(struct seq_file *m, struct nix_aq_enq_rsp *rsp)
175502e202c3SPrakash Brahmajyosyula {
175602e202c3SPrakash Brahmajyosyula struct nix_rq_ctx_s *rq_ctx = &rsp->rq;
17573feac505SGeetha sowjanya struct nix_hw *nix_hw = m->private;
17583feac505SGeetha sowjanya struct rvu *rvu = nix_hw->rvu;
17593feac505SGeetha sowjanya
17603feac505SGeetha sowjanya if (!is_rvu_otx2(rvu)) {
17613feac505SGeetha sowjanya print_nix_cn10k_rq_ctx(m, (struct nix_cn10k_rq_ctx_s *)rq_ctx);
17623feac505SGeetha sowjanya return;
17633feac505SGeetha sowjanya }
176402e202c3SPrakash Brahmajyosyula
176502e202c3SPrakash Brahmajyosyula seq_printf(m, "W0: wqe_aura \t\t\t%d\nW0: substream \t\t\t0x%03x\n",
176602e202c3SPrakash Brahmajyosyula rq_ctx->wqe_aura, rq_ctx->substream);
176702e202c3SPrakash Brahmajyosyula seq_printf(m, "W0: cq \t\t\t\t%d\nW0: ena_wqwd \t\t\t%d\n",
176802e202c3SPrakash Brahmajyosyula rq_ctx->cq, rq_ctx->ena_wqwd);
176902e202c3SPrakash Brahmajyosyula seq_printf(m, "W0: ipsech_ena \t\t\t%d\nW0: sso_ena \t\t\t%d\n",
177002e202c3SPrakash Brahmajyosyula rq_ctx->ipsech_ena, rq_ctx->sso_ena);
177102e202c3SPrakash Brahmajyosyula seq_printf(m, "W0: ena \t\t\t%d\n\n", rq_ctx->ena);
177202e202c3SPrakash Brahmajyosyula
177302e202c3SPrakash Brahmajyosyula seq_printf(m, "W1: lpb_drop_ena \t\t%d\nW1: spb_drop_ena \t\t%d\n",
177402e202c3SPrakash Brahmajyosyula rq_ctx->lpb_drop_ena, rq_ctx->spb_drop_ena);
177502e202c3SPrakash Brahmajyosyula seq_printf(m, "W1: xqe_drop_ena \t\t%d\nW1: wqe_caching \t\t%d\n",
177602e202c3SPrakash Brahmajyosyula rq_ctx->xqe_drop_ena, rq_ctx->wqe_caching);
177702e202c3SPrakash Brahmajyosyula seq_printf(m, "W1: pb_caching \t\t\t%d\nW1: sso_tt \t\t\t%d\n",
177802e202c3SPrakash Brahmajyosyula rq_ctx->pb_caching, rq_ctx->sso_tt);
177902e202c3SPrakash Brahmajyosyula seq_printf(m, "W1: sso_grp \t\t\t%d\nW1: lpb_aura \t\t\t%d\n",
178002e202c3SPrakash Brahmajyosyula rq_ctx->sso_grp, rq_ctx->lpb_aura);
178102e202c3SPrakash Brahmajyosyula seq_printf(m, "W1: spb_aura \t\t\t%d\n\n", rq_ctx->spb_aura);
178202e202c3SPrakash Brahmajyosyula
178302e202c3SPrakash Brahmajyosyula seq_printf(m, "W2: xqe_hdr_split \t\t%d\nW2: xqe_imm_copy \t\t%d\n",
178402e202c3SPrakash Brahmajyosyula rq_ctx->xqe_hdr_split, rq_ctx->xqe_imm_copy);
178502e202c3SPrakash Brahmajyosyula seq_printf(m, "W2: xqe_imm_size \t\t%d\nW2: later_skip \t\t\t%d\n",
178602e202c3SPrakash Brahmajyosyula rq_ctx->xqe_imm_size, rq_ctx->later_skip);
178702e202c3SPrakash Brahmajyosyula seq_printf(m, "W2: first_skip \t\t\t%d\nW2: lpb_sizem1 \t\t\t%d\n",
178802e202c3SPrakash Brahmajyosyula rq_ctx->first_skip, rq_ctx->lpb_sizem1);
178902e202c3SPrakash Brahmajyosyula seq_printf(m, "W2: spb_ena \t\t\t%d\nW2: wqe_skip \t\t\t%d\n",
179002e202c3SPrakash Brahmajyosyula rq_ctx->spb_ena, rq_ctx->wqe_skip);
179102e202c3SPrakash Brahmajyosyula seq_printf(m, "W2: spb_sizem1 \t\t\t%d\n\n", rq_ctx->spb_sizem1);
179202e202c3SPrakash Brahmajyosyula
179302e202c3SPrakash Brahmajyosyula seq_printf(m, "W3: spb_pool_pass \t\t%d\nW3: spb_pool_drop \t\t%d\n",
179402e202c3SPrakash Brahmajyosyula rq_ctx->spb_pool_pass, rq_ctx->spb_pool_drop);
179502e202c3SPrakash Brahmajyosyula seq_printf(m, "W3: spb_aura_pass \t\t%d\nW3: spb_aura_drop \t\t%d\n",
179602e202c3SPrakash Brahmajyosyula rq_ctx->spb_aura_pass, rq_ctx->spb_aura_drop);
179702e202c3SPrakash Brahmajyosyula seq_printf(m, "W3: wqe_pool_pass \t\t%d\nW3: wqe_pool_drop \t\t%d\n",
179802e202c3SPrakash Brahmajyosyula rq_ctx->wqe_pool_pass, rq_ctx->wqe_pool_drop);
179902e202c3SPrakash Brahmajyosyula seq_printf(m, "W3: xqe_pass \t\t\t%d\nW3: xqe_drop \t\t\t%d\n\n",
180002e202c3SPrakash Brahmajyosyula rq_ctx->xqe_pass, rq_ctx->xqe_drop);
180102e202c3SPrakash Brahmajyosyula
180202e202c3SPrakash Brahmajyosyula seq_printf(m, "W4: qint_idx \t\t\t%d\nW4: rq_int_ena \t\t\t%d\n",
180302e202c3SPrakash Brahmajyosyula rq_ctx->qint_idx, rq_ctx->rq_int_ena);
180402e202c3SPrakash Brahmajyosyula seq_printf(m, "W4: rq_int \t\t\t%d\nW4: lpb_pool_pass \t\t%d\n",
180502e202c3SPrakash Brahmajyosyula rq_ctx->rq_int, rq_ctx->lpb_pool_pass);
180602e202c3SPrakash Brahmajyosyula seq_printf(m, "W4: lpb_pool_drop \t\t%d\nW4: lpb_aura_pass \t\t%d\n",
180702e202c3SPrakash Brahmajyosyula rq_ctx->lpb_pool_drop, rq_ctx->lpb_aura_pass);
180802e202c3SPrakash Brahmajyosyula seq_printf(m, "W4: lpb_aura_drop \t\t%d\n\n", rq_ctx->lpb_aura_drop);
180902e202c3SPrakash Brahmajyosyula
181002e202c3SPrakash Brahmajyosyula seq_printf(m, "W5: flow_tagw \t\t\t%d\nW5: bad_utag \t\t\t%d\n",
181102e202c3SPrakash Brahmajyosyula rq_ctx->flow_tagw, rq_ctx->bad_utag);
181202e202c3SPrakash Brahmajyosyula seq_printf(m, "W5: good_utag \t\t\t%d\nW5: ltag \t\t\t%d\n\n",
181302e202c3SPrakash Brahmajyosyula rq_ctx->good_utag, rq_ctx->ltag);
181402e202c3SPrakash Brahmajyosyula
181502e202c3SPrakash Brahmajyosyula seq_printf(m, "W6: octs \t\t\t%llu\n\n", (u64)rq_ctx->octs);
181602e202c3SPrakash Brahmajyosyula seq_printf(m, "W7: pkts \t\t\t%llu\n\n", (u64)rq_ctx->pkts);
181702e202c3SPrakash Brahmajyosyula seq_printf(m, "W8: drop_octs \t\t\t%llu\n\n", (u64)rq_ctx->drop_octs);
181802e202c3SPrakash Brahmajyosyula seq_printf(m, "W9: drop_pkts \t\t\t%llu\n\n", (u64)rq_ctx->drop_pkts);
181902e202c3SPrakash Brahmajyosyula seq_printf(m, "W10: re_pkts \t\t\t%llu\n", (u64)rq_ctx->re_pkts);
182002e202c3SPrakash Brahmajyosyula }
182102e202c3SPrakash Brahmajyosyula
182202e202c3SPrakash Brahmajyosyula /* Dumps given nix_cq's context */
print_nix_cq_ctx(struct seq_file * m,struct nix_aq_enq_rsp * rsp)182302e202c3SPrakash Brahmajyosyula static void print_nix_cq_ctx(struct seq_file *m, struct nix_aq_enq_rsp *rsp)
182402e202c3SPrakash Brahmajyosyula {
182502e202c3SPrakash Brahmajyosyula struct nix_cq_ctx_s *cq_ctx = &rsp->cq;
182602e202c3SPrakash Brahmajyosyula
182702e202c3SPrakash Brahmajyosyula seq_printf(m, "W0: base \t\t\t%llx\n\n", cq_ctx->base);
182802e202c3SPrakash Brahmajyosyula
182902e202c3SPrakash Brahmajyosyula seq_printf(m, "W1: wrptr \t\t\t%llx\n", (u64)cq_ctx->wrptr);
183002e202c3SPrakash Brahmajyosyula seq_printf(m, "W1: avg_con \t\t\t%d\nW1: cint_idx \t\t\t%d\n",
183102e202c3SPrakash Brahmajyosyula cq_ctx->avg_con, cq_ctx->cint_idx);
183202e202c3SPrakash Brahmajyosyula seq_printf(m, "W1: cq_err \t\t\t%d\nW1: qint_idx \t\t\t%d\n",
183302e202c3SPrakash Brahmajyosyula cq_ctx->cq_err, cq_ctx->qint_idx);
183402e202c3SPrakash Brahmajyosyula seq_printf(m, "W1: bpid \t\t\t%d\nW1: bp_ena \t\t\t%d\n\n",
183502e202c3SPrakash Brahmajyosyula cq_ctx->bpid, cq_ctx->bp_ena);
183602e202c3SPrakash Brahmajyosyula
183702e202c3SPrakash Brahmajyosyula seq_printf(m, "W2: update_time \t\t%d\nW2:avg_level \t\t\t%d\n",
183802e202c3SPrakash Brahmajyosyula cq_ctx->update_time, cq_ctx->avg_level);
183902e202c3SPrakash Brahmajyosyula seq_printf(m, "W2: head \t\t\t%d\nW2:tail \t\t\t%d\n\n",
184002e202c3SPrakash Brahmajyosyula cq_ctx->head, cq_ctx->tail);
184102e202c3SPrakash Brahmajyosyula
184202e202c3SPrakash Brahmajyosyula seq_printf(m, "W3: cq_err_int_ena \t\t%d\nW3:cq_err_int \t\t\t%d\n",
184302e202c3SPrakash Brahmajyosyula cq_ctx->cq_err_int_ena, cq_ctx->cq_err_int);
184402e202c3SPrakash Brahmajyosyula seq_printf(m, "W3: qsize \t\t\t%d\nW3:caching \t\t\t%d\n",
184502e202c3SPrakash Brahmajyosyula cq_ctx->qsize, cq_ctx->caching);
184602e202c3SPrakash Brahmajyosyula seq_printf(m, "W3: substream \t\t\t0x%03x\nW3: ena \t\t\t%d\n",
184702e202c3SPrakash Brahmajyosyula cq_ctx->substream, cq_ctx->ena);
184802e202c3SPrakash Brahmajyosyula seq_printf(m, "W3: drop_ena \t\t\t%d\nW3: drop \t\t\t%d\n",
184902e202c3SPrakash Brahmajyosyula cq_ctx->drop_ena, cq_ctx->drop);
185002e202c3SPrakash Brahmajyosyula seq_printf(m, "W3: bp \t\t\t\t%d\n\n", cq_ctx->bp);
185102e202c3SPrakash Brahmajyosyula }
185202e202c3SPrakash Brahmajyosyula
rvu_dbg_nix_queue_ctx_display(struct seq_file * filp,void * unused,int ctype)185302e202c3SPrakash Brahmajyosyula static int rvu_dbg_nix_queue_ctx_display(struct seq_file *filp,
185402e202c3SPrakash Brahmajyosyula void *unused, int ctype)
185502e202c3SPrakash Brahmajyosyula {
185602e202c3SPrakash Brahmajyosyula void (*print_nix_ctx)(struct seq_file *filp,
185702e202c3SPrakash Brahmajyosyula struct nix_aq_enq_rsp *rsp) = NULL;
18580f3ce484SRakesh Babu struct nix_hw *nix_hw = filp->private;
18590f3ce484SRakesh Babu struct rvu *rvu = nix_hw->rvu;
186002e202c3SPrakash Brahmajyosyula struct nix_aq_enq_req aq_req;
186102e202c3SPrakash Brahmajyosyula struct nix_aq_enq_rsp rsp;
186202e202c3SPrakash Brahmajyosyula char *ctype_string = NULL;
186302e202c3SPrakash Brahmajyosyula int qidx, rc, max_id = 0;
186402e202c3SPrakash Brahmajyosyula struct rvu_pfvf *pfvf;
186502e202c3SPrakash Brahmajyosyula int nixlf, id, all;
186602e202c3SPrakash Brahmajyosyula u16 pcifunc;
186702e202c3SPrakash Brahmajyosyula
186802e202c3SPrakash Brahmajyosyula switch (ctype) {
186902e202c3SPrakash Brahmajyosyula case NIX_AQ_CTYPE_CQ:
187002e202c3SPrakash Brahmajyosyula nixlf = rvu->rvu_dbg.nix_cq_ctx.lf;
187102e202c3SPrakash Brahmajyosyula id = rvu->rvu_dbg.nix_cq_ctx.id;
187202e202c3SPrakash Brahmajyosyula all = rvu->rvu_dbg.nix_cq_ctx.all;
187302e202c3SPrakash Brahmajyosyula break;
187402e202c3SPrakash Brahmajyosyula
187502e202c3SPrakash Brahmajyosyula case NIX_AQ_CTYPE_SQ:
187602e202c3SPrakash Brahmajyosyula nixlf = rvu->rvu_dbg.nix_sq_ctx.lf;
187702e202c3SPrakash Brahmajyosyula id = rvu->rvu_dbg.nix_sq_ctx.id;
187802e202c3SPrakash Brahmajyosyula all = rvu->rvu_dbg.nix_sq_ctx.all;
187902e202c3SPrakash Brahmajyosyula break;
188002e202c3SPrakash Brahmajyosyula
188102e202c3SPrakash Brahmajyosyula case NIX_AQ_CTYPE_RQ:
188202e202c3SPrakash Brahmajyosyula nixlf = rvu->rvu_dbg.nix_rq_ctx.lf;
188302e202c3SPrakash Brahmajyosyula id = rvu->rvu_dbg.nix_rq_ctx.id;
188402e202c3SPrakash Brahmajyosyula all = rvu->rvu_dbg.nix_rq_ctx.all;
188502e202c3SPrakash Brahmajyosyula break;
188602e202c3SPrakash Brahmajyosyula
188702e202c3SPrakash Brahmajyosyula default:
188802e202c3SPrakash Brahmajyosyula return -EINVAL;
188902e202c3SPrakash Brahmajyosyula }
189002e202c3SPrakash Brahmajyosyula
18910f3ce484SRakesh Babu if (!rvu_dbg_is_valid_lf(rvu, nix_hw->blkaddr, nixlf, &pcifunc))
189202e202c3SPrakash Brahmajyosyula return -EINVAL;
189302e202c3SPrakash Brahmajyosyula
189402e202c3SPrakash Brahmajyosyula pfvf = rvu_get_pfvf(rvu, pcifunc);
189502e202c3SPrakash Brahmajyosyula if (ctype == NIX_AQ_CTYPE_SQ && !pfvf->sq_ctx) {
189602e202c3SPrakash Brahmajyosyula seq_puts(filp, "SQ context is not initialized\n");
189702e202c3SPrakash Brahmajyosyula return -EINVAL;
189802e202c3SPrakash Brahmajyosyula } else if (ctype == NIX_AQ_CTYPE_RQ && !pfvf->rq_ctx) {
189902e202c3SPrakash Brahmajyosyula seq_puts(filp, "RQ context is not initialized\n");
190002e202c3SPrakash Brahmajyosyula return -EINVAL;
190102e202c3SPrakash Brahmajyosyula } else if (ctype == NIX_AQ_CTYPE_CQ && !pfvf->cq_ctx) {
190202e202c3SPrakash Brahmajyosyula seq_puts(filp, "CQ context is not initialized\n");
190302e202c3SPrakash Brahmajyosyula return -EINVAL;
190402e202c3SPrakash Brahmajyosyula }
190502e202c3SPrakash Brahmajyosyula
190602e202c3SPrakash Brahmajyosyula if (ctype == NIX_AQ_CTYPE_SQ) {
190702e202c3SPrakash Brahmajyosyula max_id = pfvf->sq_ctx->qsize;
190802e202c3SPrakash Brahmajyosyula ctype_string = "sq";
190902e202c3SPrakash Brahmajyosyula print_nix_ctx = print_nix_sq_ctx;
191002e202c3SPrakash Brahmajyosyula } else if (ctype == NIX_AQ_CTYPE_RQ) {
191102e202c3SPrakash Brahmajyosyula max_id = pfvf->rq_ctx->qsize;
191202e202c3SPrakash Brahmajyosyula ctype_string = "rq";
191302e202c3SPrakash Brahmajyosyula print_nix_ctx = print_nix_rq_ctx;
191402e202c3SPrakash Brahmajyosyula } else if (ctype == NIX_AQ_CTYPE_CQ) {
191502e202c3SPrakash Brahmajyosyula max_id = pfvf->cq_ctx->qsize;
191602e202c3SPrakash Brahmajyosyula ctype_string = "cq";
191702e202c3SPrakash Brahmajyosyula print_nix_ctx = print_nix_cq_ctx;
191802e202c3SPrakash Brahmajyosyula }
191902e202c3SPrakash Brahmajyosyula
192002e202c3SPrakash Brahmajyosyula memset(&aq_req, 0, sizeof(struct nix_aq_enq_req));
192102e202c3SPrakash Brahmajyosyula aq_req.hdr.pcifunc = pcifunc;
192202e202c3SPrakash Brahmajyosyula aq_req.ctype = ctype;
192302e202c3SPrakash Brahmajyosyula aq_req.op = NIX_AQ_INSTOP_READ;
192402e202c3SPrakash Brahmajyosyula if (all)
192502e202c3SPrakash Brahmajyosyula id = 0;
192602e202c3SPrakash Brahmajyosyula else
192702e202c3SPrakash Brahmajyosyula max_id = id + 1;
192802e202c3SPrakash Brahmajyosyula for (qidx = id; qidx < max_id; qidx++) {
192902e202c3SPrakash Brahmajyosyula aq_req.qidx = qidx;
193002e202c3SPrakash Brahmajyosyula seq_printf(filp, "=====%s_ctx for nixlf:%d and qidx:%d is=====\n",
193102e202c3SPrakash Brahmajyosyula ctype_string, nixlf, aq_req.qidx);
193202e202c3SPrakash Brahmajyosyula rc = rvu_mbox_handler_nix_aq_enq(rvu, &aq_req, &rsp);
193302e202c3SPrakash Brahmajyosyula if (rc) {
193402e202c3SPrakash Brahmajyosyula seq_puts(filp, "Failed to read the context\n");
193502e202c3SPrakash Brahmajyosyula return -EINVAL;
193602e202c3SPrakash Brahmajyosyula }
193702e202c3SPrakash Brahmajyosyula print_nix_ctx(filp, &rsp);
193802e202c3SPrakash Brahmajyosyula }
193902e202c3SPrakash Brahmajyosyula return 0;
194002e202c3SPrakash Brahmajyosyula }
194102e202c3SPrakash Brahmajyosyula
write_nix_queue_ctx(struct rvu * rvu,bool all,int nixlf,int id,int ctype,char * ctype_string,struct seq_file * m)194202e202c3SPrakash Brahmajyosyula static int write_nix_queue_ctx(struct rvu *rvu, bool all, int nixlf,
19430f3ce484SRakesh Babu int id, int ctype, char *ctype_string,
19440f3ce484SRakesh Babu struct seq_file *m)
194502e202c3SPrakash Brahmajyosyula {
19460f3ce484SRakesh Babu struct nix_hw *nix_hw = m->private;
194702e202c3SPrakash Brahmajyosyula struct rvu_pfvf *pfvf;
194802e202c3SPrakash Brahmajyosyula int max_id = 0;
194902e202c3SPrakash Brahmajyosyula u16 pcifunc;
195002e202c3SPrakash Brahmajyosyula
19510f3ce484SRakesh Babu if (!rvu_dbg_is_valid_lf(rvu, nix_hw->blkaddr, nixlf, &pcifunc))
195202e202c3SPrakash Brahmajyosyula return -EINVAL;
195302e202c3SPrakash Brahmajyosyula
195402e202c3SPrakash Brahmajyosyula pfvf = rvu_get_pfvf(rvu, pcifunc);
195502e202c3SPrakash Brahmajyosyula
195602e202c3SPrakash Brahmajyosyula if (ctype == NIX_AQ_CTYPE_SQ) {
195702e202c3SPrakash Brahmajyosyula if (!pfvf->sq_ctx) {
195802e202c3SPrakash Brahmajyosyula dev_warn(rvu->dev, "SQ context is not initialized\n");
195902e202c3SPrakash Brahmajyosyula return -EINVAL;
196002e202c3SPrakash Brahmajyosyula }
196102e202c3SPrakash Brahmajyosyula max_id = pfvf->sq_ctx->qsize;
196202e202c3SPrakash Brahmajyosyula } else if (ctype == NIX_AQ_CTYPE_RQ) {
196302e202c3SPrakash Brahmajyosyula if (!pfvf->rq_ctx) {
196402e202c3SPrakash Brahmajyosyula dev_warn(rvu->dev, "RQ context is not initialized\n");
196502e202c3SPrakash Brahmajyosyula return -EINVAL;
196602e202c3SPrakash Brahmajyosyula }
196702e202c3SPrakash Brahmajyosyula max_id = pfvf->rq_ctx->qsize;
196802e202c3SPrakash Brahmajyosyula } else if (ctype == NIX_AQ_CTYPE_CQ) {
196902e202c3SPrakash Brahmajyosyula if (!pfvf->cq_ctx) {
197002e202c3SPrakash Brahmajyosyula dev_warn(rvu->dev, "CQ context is not initialized\n");
197102e202c3SPrakash Brahmajyosyula return -EINVAL;
197202e202c3SPrakash Brahmajyosyula }
197302e202c3SPrakash Brahmajyosyula max_id = pfvf->cq_ctx->qsize;
197402e202c3SPrakash Brahmajyosyula }
197502e202c3SPrakash Brahmajyosyula
197602e202c3SPrakash Brahmajyosyula if (id < 0 || id >= max_id) {
197702e202c3SPrakash Brahmajyosyula dev_warn(rvu->dev, "Invalid %s_ctx valid range 0-%d\n",
197802e202c3SPrakash Brahmajyosyula ctype_string, max_id - 1);
197902e202c3SPrakash Brahmajyosyula return -EINVAL;
198002e202c3SPrakash Brahmajyosyula }
198102e202c3SPrakash Brahmajyosyula switch (ctype) {
198202e202c3SPrakash Brahmajyosyula case NIX_AQ_CTYPE_CQ:
198302e202c3SPrakash Brahmajyosyula rvu->rvu_dbg.nix_cq_ctx.lf = nixlf;
198402e202c3SPrakash Brahmajyosyula rvu->rvu_dbg.nix_cq_ctx.id = id;
198502e202c3SPrakash Brahmajyosyula rvu->rvu_dbg.nix_cq_ctx.all = all;
198602e202c3SPrakash Brahmajyosyula break;
198702e202c3SPrakash Brahmajyosyula
198802e202c3SPrakash Brahmajyosyula case NIX_AQ_CTYPE_SQ:
198902e202c3SPrakash Brahmajyosyula rvu->rvu_dbg.nix_sq_ctx.lf = nixlf;
199002e202c3SPrakash Brahmajyosyula rvu->rvu_dbg.nix_sq_ctx.id = id;
199102e202c3SPrakash Brahmajyosyula rvu->rvu_dbg.nix_sq_ctx.all = all;
199202e202c3SPrakash Brahmajyosyula break;
199302e202c3SPrakash Brahmajyosyula
199402e202c3SPrakash Brahmajyosyula case NIX_AQ_CTYPE_RQ:
199502e202c3SPrakash Brahmajyosyula rvu->rvu_dbg.nix_rq_ctx.lf = nixlf;
199602e202c3SPrakash Brahmajyosyula rvu->rvu_dbg.nix_rq_ctx.id = id;
199702e202c3SPrakash Brahmajyosyula rvu->rvu_dbg.nix_rq_ctx.all = all;
199802e202c3SPrakash Brahmajyosyula break;
199902e202c3SPrakash Brahmajyosyula default:
200002e202c3SPrakash Brahmajyosyula return -EINVAL;
200102e202c3SPrakash Brahmajyosyula }
200202e202c3SPrakash Brahmajyosyula return 0;
200302e202c3SPrakash Brahmajyosyula }
200402e202c3SPrakash Brahmajyosyula
rvu_dbg_nix_queue_ctx_write(struct file * filp,const char __user * buffer,size_t count,loff_t * ppos,int ctype)200502e202c3SPrakash Brahmajyosyula static ssize_t rvu_dbg_nix_queue_ctx_write(struct file *filp,
200602e202c3SPrakash Brahmajyosyula const char __user *buffer,
200702e202c3SPrakash Brahmajyosyula size_t count, loff_t *ppos,
200802e202c3SPrakash Brahmajyosyula int ctype)
200902e202c3SPrakash Brahmajyosyula {
201002e202c3SPrakash Brahmajyosyula struct seq_file *m = filp->private_data;
20110f3ce484SRakesh Babu struct nix_hw *nix_hw = m->private;
20120f3ce484SRakesh Babu struct rvu *rvu = nix_hw->rvu;
201302e202c3SPrakash Brahmajyosyula char *cmd_buf, *ctype_string;
201402e202c3SPrakash Brahmajyosyula int nixlf, id = 0, ret;
201502e202c3SPrakash Brahmajyosyula bool all = false;
201602e202c3SPrakash Brahmajyosyula
201702e202c3SPrakash Brahmajyosyula if ((*ppos != 0) || !count)
201802e202c3SPrakash Brahmajyosyula return -EINVAL;
201902e202c3SPrakash Brahmajyosyula
202002e202c3SPrakash Brahmajyosyula switch (ctype) {
202102e202c3SPrakash Brahmajyosyula case NIX_AQ_CTYPE_SQ:
202202e202c3SPrakash Brahmajyosyula ctype_string = "sq";
202302e202c3SPrakash Brahmajyosyula break;
202402e202c3SPrakash Brahmajyosyula case NIX_AQ_CTYPE_RQ:
202502e202c3SPrakash Brahmajyosyula ctype_string = "rq";
202602e202c3SPrakash Brahmajyosyula break;
202702e202c3SPrakash Brahmajyosyula case NIX_AQ_CTYPE_CQ:
202802e202c3SPrakash Brahmajyosyula ctype_string = "cq";
202902e202c3SPrakash Brahmajyosyula break;
203002e202c3SPrakash Brahmajyosyula default:
203102e202c3SPrakash Brahmajyosyula return -EINVAL;
203202e202c3SPrakash Brahmajyosyula }
203302e202c3SPrakash Brahmajyosyula
203402e202c3SPrakash Brahmajyosyula cmd_buf = kzalloc(count + 1, GFP_KERNEL);
203502e202c3SPrakash Brahmajyosyula
203602e202c3SPrakash Brahmajyosyula if (!cmd_buf)
203702e202c3SPrakash Brahmajyosyula return count;
203802e202c3SPrakash Brahmajyosyula
203902e202c3SPrakash Brahmajyosyula ret = parse_cmd_buffer_ctx(cmd_buf, &count, buffer,
204002e202c3SPrakash Brahmajyosyula &nixlf, &id, &all);
204102e202c3SPrakash Brahmajyosyula if (ret < 0) {
204202e202c3SPrakash Brahmajyosyula dev_info(rvu->dev,
204302e202c3SPrakash Brahmajyosyula "Usage: echo <nixlf> [%s number/all] > %s_ctx\n",
204402e202c3SPrakash Brahmajyosyula ctype_string, ctype_string);
204502e202c3SPrakash Brahmajyosyula goto done;
204602e202c3SPrakash Brahmajyosyula } else {
204702e202c3SPrakash Brahmajyosyula ret = write_nix_queue_ctx(rvu, all, nixlf, id, ctype,
20480f3ce484SRakesh Babu ctype_string, m);
204902e202c3SPrakash Brahmajyosyula }
205002e202c3SPrakash Brahmajyosyula done:
205102e202c3SPrakash Brahmajyosyula kfree(cmd_buf);
205202e202c3SPrakash Brahmajyosyula return ret ? ret : count;
205302e202c3SPrakash Brahmajyosyula }
205402e202c3SPrakash Brahmajyosyula
rvu_dbg_nix_sq_ctx_write(struct file * filp,const char __user * buffer,size_t count,loff_t * ppos)205502e202c3SPrakash Brahmajyosyula static ssize_t rvu_dbg_nix_sq_ctx_write(struct file *filp,
205602e202c3SPrakash Brahmajyosyula const char __user *buffer,
205702e202c3SPrakash Brahmajyosyula size_t count, loff_t *ppos)
205802e202c3SPrakash Brahmajyosyula {
205902e202c3SPrakash Brahmajyosyula return rvu_dbg_nix_queue_ctx_write(filp, buffer, count, ppos,
206002e202c3SPrakash Brahmajyosyula NIX_AQ_CTYPE_SQ);
206102e202c3SPrakash Brahmajyosyula }
206202e202c3SPrakash Brahmajyosyula
rvu_dbg_nix_sq_ctx_display(struct seq_file * filp,void * unused)206302e202c3SPrakash Brahmajyosyula static int rvu_dbg_nix_sq_ctx_display(struct seq_file *filp, void *unused)
206402e202c3SPrakash Brahmajyosyula {
206502e202c3SPrakash Brahmajyosyula return rvu_dbg_nix_queue_ctx_display(filp, unused, NIX_AQ_CTYPE_SQ);
206602e202c3SPrakash Brahmajyosyula }
206702e202c3SPrakash Brahmajyosyula
206802e202c3SPrakash Brahmajyosyula RVU_DEBUG_SEQ_FOPS(nix_sq_ctx, nix_sq_ctx_display, nix_sq_ctx_write);
206902e202c3SPrakash Brahmajyosyula
rvu_dbg_nix_rq_ctx_write(struct file * filp,const char __user * buffer,size_t count,loff_t * ppos)207002e202c3SPrakash Brahmajyosyula static ssize_t rvu_dbg_nix_rq_ctx_write(struct file *filp,
207102e202c3SPrakash Brahmajyosyula const char __user *buffer,
207202e202c3SPrakash Brahmajyosyula size_t count, loff_t *ppos)
207302e202c3SPrakash Brahmajyosyula {
207402e202c3SPrakash Brahmajyosyula return rvu_dbg_nix_queue_ctx_write(filp, buffer, count, ppos,
207502e202c3SPrakash Brahmajyosyula NIX_AQ_CTYPE_RQ);
207602e202c3SPrakash Brahmajyosyula }
207702e202c3SPrakash Brahmajyosyula
rvu_dbg_nix_rq_ctx_display(struct seq_file * filp,void * unused)207802e202c3SPrakash Brahmajyosyula static int rvu_dbg_nix_rq_ctx_display(struct seq_file *filp, void *unused)
207902e202c3SPrakash Brahmajyosyula {
208002e202c3SPrakash Brahmajyosyula return rvu_dbg_nix_queue_ctx_display(filp, unused, NIX_AQ_CTYPE_RQ);
208102e202c3SPrakash Brahmajyosyula }
208202e202c3SPrakash Brahmajyosyula
208302e202c3SPrakash Brahmajyosyula RVU_DEBUG_SEQ_FOPS(nix_rq_ctx, nix_rq_ctx_display, nix_rq_ctx_write);
208402e202c3SPrakash Brahmajyosyula
rvu_dbg_nix_cq_ctx_write(struct file * filp,const char __user * buffer,size_t count,loff_t * ppos)208502e202c3SPrakash Brahmajyosyula static ssize_t rvu_dbg_nix_cq_ctx_write(struct file *filp,
208602e202c3SPrakash Brahmajyosyula const char __user *buffer,
208702e202c3SPrakash Brahmajyosyula size_t count, loff_t *ppos)
208802e202c3SPrakash Brahmajyosyula {
208902e202c3SPrakash Brahmajyosyula return rvu_dbg_nix_queue_ctx_write(filp, buffer, count, ppos,
209002e202c3SPrakash Brahmajyosyula NIX_AQ_CTYPE_CQ);
209102e202c3SPrakash Brahmajyosyula }
209202e202c3SPrakash Brahmajyosyula
rvu_dbg_nix_cq_ctx_display(struct seq_file * filp,void * unused)209302e202c3SPrakash Brahmajyosyula static int rvu_dbg_nix_cq_ctx_display(struct seq_file *filp, void *unused)
209402e202c3SPrakash Brahmajyosyula {
209502e202c3SPrakash Brahmajyosyula return rvu_dbg_nix_queue_ctx_display(filp, unused, NIX_AQ_CTYPE_CQ);
209602e202c3SPrakash Brahmajyosyula }
209702e202c3SPrakash Brahmajyosyula
209802e202c3SPrakash Brahmajyosyula RVU_DEBUG_SEQ_FOPS(nix_cq_ctx, nix_cq_ctx_display, nix_cq_ctx_write);
209902e202c3SPrakash Brahmajyosyula
print_nix_qctx_qsize(struct seq_file * filp,int qsize,unsigned long * bmap,char * qtype)210002e202c3SPrakash Brahmajyosyula static void print_nix_qctx_qsize(struct seq_file *filp, int qsize,
210102e202c3SPrakash Brahmajyosyula unsigned long *bmap, char *qtype)
210202e202c3SPrakash Brahmajyosyula {
210302e202c3SPrakash Brahmajyosyula char *buf;
210402e202c3SPrakash Brahmajyosyula
210502e202c3SPrakash Brahmajyosyula buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
210602e202c3SPrakash Brahmajyosyula if (!buf)
210702e202c3SPrakash Brahmajyosyula return;
210802e202c3SPrakash Brahmajyosyula
210902e202c3SPrakash Brahmajyosyula bitmap_print_to_pagebuf(false, buf, bmap, qsize);
211002e202c3SPrakash Brahmajyosyula seq_printf(filp, "%s context count : %d\n", qtype, qsize);
211102e202c3SPrakash Brahmajyosyula seq_printf(filp, "%s context ena/dis bitmap : %s\n",
211202e202c3SPrakash Brahmajyosyula qtype, buf);
211302e202c3SPrakash Brahmajyosyula kfree(buf);
211402e202c3SPrakash Brahmajyosyula }
211502e202c3SPrakash Brahmajyosyula
print_nix_qsize(struct seq_file * filp,struct rvu_pfvf * pfvf)211602e202c3SPrakash Brahmajyosyula static void print_nix_qsize(struct seq_file *filp, struct rvu_pfvf *pfvf)
211702e202c3SPrakash Brahmajyosyula {
211802e202c3SPrakash Brahmajyosyula if (!pfvf->cq_ctx)
211902e202c3SPrakash Brahmajyosyula seq_puts(filp, "cq context is not initialized\n");
212002e202c3SPrakash Brahmajyosyula else
212102e202c3SPrakash Brahmajyosyula print_nix_qctx_qsize(filp, pfvf->cq_ctx->qsize, pfvf->cq_bmap,
212202e202c3SPrakash Brahmajyosyula "cq");
212302e202c3SPrakash Brahmajyosyula
212402e202c3SPrakash Brahmajyosyula if (!pfvf->rq_ctx)
212502e202c3SPrakash Brahmajyosyula seq_puts(filp, "rq context is not initialized\n");
212602e202c3SPrakash Brahmajyosyula else
212702e202c3SPrakash Brahmajyosyula print_nix_qctx_qsize(filp, pfvf->rq_ctx->qsize, pfvf->rq_bmap,
212802e202c3SPrakash Brahmajyosyula "rq");
212902e202c3SPrakash Brahmajyosyula
213002e202c3SPrakash Brahmajyosyula if (!pfvf->sq_ctx)
213102e202c3SPrakash Brahmajyosyula seq_puts(filp, "sq context is not initialized\n");
213202e202c3SPrakash Brahmajyosyula else
213302e202c3SPrakash Brahmajyosyula print_nix_qctx_qsize(filp, pfvf->sq_ctx->qsize, pfvf->sq_bmap,
213402e202c3SPrakash Brahmajyosyula "sq");
213502e202c3SPrakash Brahmajyosyula }
213602e202c3SPrakash Brahmajyosyula
rvu_dbg_nix_qsize_write(struct file * filp,const char __user * buffer,size_t count,loff_t * ppos)213702e202c3SPrakash Brahmajyosyula static ssize_t rvu_dbg_nix_qsize_write(struct file *filp,
213802e202c3SPrakash Brahmajyosyula const char __user *buffer,
213902e202c3SPrakash Brahmajyosyula size_t count, loff_t *ppos)
214002e202c3SPrakash Brahmajyosyula {
214102e202c3SPrakash Brahmajyosyula return rvu_dbg_qsize_write(filp, buffer, count, ppos,
214202e202c3SPrakash Brahmajyosyula BLKTYPE_NIX);
214302e202c3SPrakash Brahmajyosyula }
214402e202c3SPrakash Brahmajyosyula
rvu_dbg_nix_qsize_display(struct seq_file * filp,void * unused)214502e202c3SPrakash Brahmajyosyula static int rvu_dbg_nix_qsize_display(struct seq_file *filp, void *unused)
214602e202c3SPrakash Brahmajyosyula {
214702e202c3SPrakash Brahmajyosyula return rvu_dbg_qsize_display(filp, unused, BLKTYPE_NIX);
214802e202c3SPrakash Brahmajyosyula }
214902e202c3SPrakash Brahmajyosyula
215002e202c3SPrakash Brahmajyosyula RVU_DEBUG_SEQ_FOPS(nix_qsize, nix_qsize_display, nix_qsize_write);
215102e202c3SPrakash Brahmajyosyula
print_band_prof_ctx(struct seq_file * m,struct nix_bandprof_s * prof)2152e7d89717SSunil Goutham static void print_band_prof_ctx(struct seq_file *m,
2153e7d89717SSunil Goutham struct nix_bandprof_s *prof)
2154e7d89717SSunil Goutham {
2155e7d89717SSunil Goutham char *str;
2156e7d89717SSunil Goutham
2157e7d89717SSunil Goutham switch (prof->pc_mode) {
2158e7d89717SSunil Goutham case NIX_RX_PC_MODE_VLAN:
2159e7d89717SSunil Goutham str = "VLAN";
2160e7d89717SSunil Goutham break;
2161e7d89717SSunil Goutham case NIX_RX_PC_MODE_DSCP:
2162e7d89717SSunil Goutham str = "DSCP";
2163e7d89717SSunil Goutham break;
2164e7d89717SSunil Goutham case NIX_RX_PC_MODE_GEN:
2165e7d89717SSunil Goutham str = "Generic";
2166e7d89717SSunil Goutham break;
2167e7d89717SSunil Goutham case NIX_RX_PC_MODE_RSVD:
2168e7d89717SSunil Goutham str = "Reserved";
2169e7d89717SSunil Goutham break;
2170e7d89717SSunil Goutham }
2171e7d89717SSunil Goutham seq_printf(m, "W0: pc_mode\t\t%s\n", str);
2172e7d89717SSunil Goutham str = (prof->icolor == 3) ? "Color blind" :
2173e7d89717SSunil Goutham (prof->icolor == 0) ? "Green" :
2174e7d89717SSunil Goutham (prof->icolor == 1) ? "Yellow" : "Red";
2175e7d89717SSunil Goutham seq_printf(m, "W0: icolor\t\t%s\n", str);
2176e7d89717SSunil Goutham seq_printf(m, "W0: tnl_ena\t\t%d\n", prof->tnl_ena);
2177e7d89717SSunil Goutham seq_printf(m, "W0: peir_exponent\t%d\n", prof->peir_exponent);
2178e7d89717SSunil Goutham seq_printf(m, "W0: pebs_exponent\t%d\n", prof->pebs_exponent);
2179e7d89717SSunil Goutham seq_printf(m, "W0: cir_exponent\t%d\n", prof->cir_exponent);
2180e7d89717SSunil Goutham seq_printf(m, "W0: cbs_exponent\t%d\n", prof->cbs_exponent);
2181e7d89717SSunil Goutham seq_printf(m, "W0: peir_mantissa\t%d\n", prof->peir_mantissa);
2182e7d89717SSunil Goutham seq_printf(m, "W0: pebs_mantissa\t%d\n", prof->pebs_mantissa);
2183e7d89717SSunil Goutham seq_printf(m, "W0: cir_mantissa\t%d\n", prof->cir_mantissa);
2184e7d89717SSunil Goutham
2185e7d89717SSunil Goutham seq_printf(m, "W1: cbs_mantissa\t%d\n", prof->cbs_mantissa);
2186e7d89717SSunil Goutham str = (prof->lmode == 0) ? "byte" : "packet";
2187e7d89717SSunil Goutham seq_printf(m, "W1: lmode\t\t%s\n", str);
2188e7d89717SSunil Goutham seq_printf(m, "W1: l_select\t\t%d\n", prof->l_sellect);
2189e7d89717SSunil Goutham seq_printf(m, "W1: rdiv\t\t%d\n", prof->rdiv);
2190e7d89717SSunil Goutham seq_printf(m, "W1: adjust_exponent\t%d\n", prof->adjust_exponent);
2191e7d89717SSunil Goutham seq_printf(m, "W1: adjust_mantissa\t%d\n", prof->adjust_mantissa);
2192e7d89717SSunil Goutham str = (prof->gc_action == 0) ? "PASS" :
2193e7d89717SSunil Goutham (prof->gc_action == 1) ? "DROP" : "RED";
2194e7d89717SSunil Goutham seq_printf(m, "W1: gc_action\t\t%s\n", str);
2195e7d89717SSunil Goutham str = (prof->yc_action == 0) ? "PASS" :
2196e7d89717SSunil Goutham (prof->yc_action == 1) ? "DROP" : "RED";
2197e7d89717SSunil Goutham seq_printf(m, "W1: yc_action\t\t%s\n", str);
2198e7d89717SSunil Goutham str = (prof->rc_action == 0) ? "PASS" :
2199e7d89717SSunil Goutham (prof->rc_action == 1) ? "DROP" : "RED";
2200e7d89717SSunil Goutham seq_printf(m, "W1: rc_action\t\t%s\n", str);
2201e7d89717SSunil Goutham seq_printf(m, "W1: meter_algo\t\t%d\n", prof->meter_algo);
2202e7d89717SSunil Goutham seq_printf(m, "W1: band_prof_id\t%d\n", prof->band_prof_id);
2203e7d89717SSunil Goutham seq_printf(m, "W1: hl_en\t\t%d\n", prof->hl_en);
2204e7d89717SSunil Goutham
2205e7d89717SSunil Goutham seq_printf(m, "W2: ts\t\t\t%lld\n", (u64)prof->ts);
2206e7d89717SSunil Goutham seq_printf(m, "W3: pe_accum\t\t%d\n", prof->pe_accum);
2207e7d89717SSunil Goutham seq_printf(m, "W3: c_accum\t\t%d\n", prof->c_accum);
2208e7d89717SSunil Goutham seq_printf(m, "W4: green_pkt_pass\t%lld\n",
2209e7d89717SSunil Goutham (u64)prof->green_pkt_pass);
2210e7d89717SSunil Goutham seq_printf(m, "W5: yellow_pkt_pass\t%lld\n",
2211e7d89717SSunil Goutham (u64)prof->yellow_pkt_pass);
2212e7d89717SSunil Goutham seq_printf(m, "W6: red_pkt_pass\t%lld\n", (u64)prof->red_pkt_pass);
2213e7d89717SSunil Goutham seq_printf(m, "W7: green_octs_pass\t%lld\n",
2214e7d89717SSunil Goutham (u64)prof->green_octs_pass);
2215e7d89717SSunil Goutham seq_printf(m, "W8: yellow_octs_pass\t%lld\n",
2216e7d89717SSunil Goutham (u64)prof->yellow_octs_pass);
2217e7d89717SSunil Goutham seq_printf(m, "W9: red_octs_pass\t%lld\n", (u64)prof->red_octs_pass);
2218e7d89717SSunil Goutham seq_printf(m, "W10: green_pkt_drop\t%lld\n",
2219e7d89717SSunil Goutham (u64)prof->green_pkt_drop);
2220e7d89717SSunil Goutham seq_printf(m, "W11: yellow_pkt_drop\t%lld\n",
2221e7d89717SSunil Goutham (u64)prof->yellow_pkt_drop);
2222e7d89717SSunil Goutham seq_printf(m, "W12: red_pkt_drop\t%lld\n", (u64)prof->red_pkt_drop);
2223e7d89717SSunil Goutham seq_printf(m, "W13: green_octs_drop\t%lld\n",
2224e7d89717SSunil Goutham (u64)prof->green_octs_drop);
2225e7d89717SSunil Goutham seq_printf(m, "W14: yellow_octs_drop\t%lld\n",
2226e7d89717SSunil Goutham (u64)prof->yellow_octs_drop);
2227e7d89717SSunil Goutham seq_printf(m, "W15: red_octs_drop\t%lld\n", (u64)prof->red_octs_drop);
2228e7d89717SSunil Goutham seq_puts(m, "==============================\n");
2229e7d89717SSunil Goutham }
2230e7d89717SSunil Goutham
rvu_dbg_nix_band_prof_ctx_display(struct seq_file * m,void * unused)2231e7d89717SSunil Goutham static int rvu_dbg_nix_band_prof_ctx_display(struct seq_file *m, void *unused)
2232e7d89717SSunil Goutham {
2233e7d89717SSunil Goutham struct nix_hw *nix_hw = m->private;
2234e7d89717SSunil Goutham struct nix_cn10k_aq_enq_req aq_req;
2235e7d89717SSunil Goutham struct nix_cn10k_aq_enq_rsp aq_rsp;
2236e7d89717SSunil Goutham struct rvu *rvu = nix_hw->rvu;
2237e7d89717SSunil Goutham struct nix_ipolicer *ipolicer;
2238e7d89717SSunil Goutham int layer, prof_idx, idx, rc;
2239e7d89717SSunil Goutham u16 pcifunc;
2240e7d89717SSunil Goutham char *str;
2241e7d89717SSunil Goutham
2242cc45b96eSSubbaraya Sundeep /* Ingress policers do not exist on all platforms */
2243cc45b96eSSubbaraya Sundeep if (!nix_hw->ipolicer)
2244cc45b96eSSubbaraya Sundeep return 0;
2245cc45b96eSSubbaraya Sundeep
2246e7d89717SSunil Goutham for (layer = 0; layer < BAND_PROF_NUM_LAYERS; layer++) {
2247e7d89717SSunil Goutham if (layer == BAND_PROF_INVAL_LAYER)
2248e7d89717SSunil Goutham continue;
2249e7d89717SSunil Goutham str = (layer == BAND_PROF_LEAF_LAYER) ? "Leaf" :
2250e7d89717SSunil Goutham (layer == BAND_PROF_MID_LAYER) ? "Mid" : "Top";
2251e7d89717SSunil Goutham
2252e7d89717SSunil Goutham seq_printf(m, "\n%s bandwidth profiles\n", str);
2253e7d89717SSunil Goutham seq_puts(m, "=======================\n");
2254e7d89717SSunil Goutham
2255e7d89717SSunil Goutham ipolicer = &nix_hw->ipolicer[layer];
2256e7d89717SSunil Goutham
2257e7d89717SSunil Goutham for (idx = 0; idx < ipolicer->band_prof.max; idx++) {
2258e7d89717SSunil Goutham if (is_rsrc_free(&ipolicer->band_prof, idx))
2259e7d89717SSunil Goutham continue;
2260e7d89717SSunil Goutham
2261e7d89717SSunil Goutham prof_idx = (idx & 0x3FFF) | (layer << 14);
2262e7d89717SSunil Goutham rc = nix_aq_context_read(rvu, nix_hw, &aq_req, &aq_rsp,
2263e7d89717SSunil Goutham 0x00, NIX_AQ_CTYPE_BANDPROF,
2264e7d89717SSunil Goutham prof_idx);
2265e7d89717SSunil Goutham if (rc) {
2266e7d89717SSunil Goutham dev_err(rvu->dev,
2267e7d89717SSunil Goutham "%s: Failed to fetch context of %s profile %d, err %d\n",
2268e7d89717SSunil Goutham __func__, str, idx, rc);
2269e7d89717SSunil Goutham return 0;
2270e7d89717SSunil Goutham }
2271e7d89717SSunil Goutham seq_printf(m, "\n%s bandwidth profile:: %d\n", str, idx);
2272e7d89717SSunil Goutham pcifunc = ipolicer->pfvf_map[idx];
2273e7d89717SSunil Goutham if (!(pcifunc & RVU_PFVF_FUNC_MASK))
2274e7d89717SSunil Goutham seq_printf(m, "Allocated to :: PF %d\n",
2275e7d89717SSunil Goutham rvu_get_pf(pcifunc));
2276e7d89717SSunil Goutham else
2277e7d89717SSunil Goutham seq_printf(m, "Allocated to :: PF %d VF %d\n",
2278e7d89717SSunil Goutham rvu_get_pf(pcifunc),
2279e7d89717SSunil Goutham (pcifunc & RVU_PFVF_FUNC_MASK) - 1);
2280e7d89717SSunil Goutham print_band_prof_ctx(m, &aq_rsp.prof);
2281e7d89717SSunil Goutham }
2282e7d89717SSunil Goutham }
2283e7d89717SSunil Goutham return 0;
2284e7d89717SSunil Goutham }
2285e7d89717SSunil Goutham
2286e7d89717SSunil Goutham RVU_DEBUG_SEQ_FOPS(nix_band_prof_ctx, nix_band_prof_ctx_display, NULL);
2287e7d89717SSunil Goutham
rvu_dbg_nix_band_prof_rsrc_display(struct seq_file * m,void * unused)2288e7d89717SSunil Goutham static int rvu_dbg_nix_band_prof_rsrc_display(struct seq_file *m, void *unused)
2289e7d89717SSunil Goutham {
2290e7d89717SSunil Goutham struct nix_hw *nix_hw = m->private;
2291e7d89717SSunil Goutham struct nix_ipolicer *ipolicer;
2292e7d89717SSunil Goutham int layer;
2293e7d89717SSunil Goutham char *str;
2294e7d89717SSunil Goutham
2295cc45b96eSSubbaraya Sundeep /* Ingress policers do not exist on all platforms */
2296cc45b96eSSubbaraya Sundeep if (!nix_hw->ipolicer)
2297cc45b96eSSubbaraya Sundeep return 0;
2298cc45b96eSSubbaraya Sundeep
2299e7d89717SSunil Goutham seq_puts(m, "\nBandwidth profile resource free count\n");
2300e7d89717SSunil Goutham seq_puts(m, "=====================================\n");
2301e7d89717SSunil Goutham for (layer = 0; layer < BAND_PROF_NUM_LAYERS; layer++) {
2302e7d89717SSunil Goutham if (layer == BAND_PROF_INVAL_LAYER)
2303e7d89717SSunil Goutham continue;
2304e7d89717SSunil Goutham str = (layer == BAND_PROF_LEAF_LAYER) ? "Leaf" :
2305e7d89717SSunil Goutham (layer == BAND_PROF_MID_LAYER) ? "Mid " : "Top ";
2306e7d89717SSunil Goutham
2307e7d89717SSunil Goutham ipolicer = &nix_hw->ipolicer[layer];
2308e7d89717SSunil Goutham seq_printf(m, "%s :: Max: %4d Free: %4d\n", str,
2309e7d89717SSunil Goutham ipolicer->band_prof.max,
2310e7d89717SSunil Goutham rvu_rsrc_free_count(&ipolicer->band_prof));
2311e7d89717SSunil Goutham }
2312e7d89717SSunil Goutham seq_puts(m, "=====================================\n");
2313e7d89717SSunil Goutham
2314e7d89717SSunil Goutham return 0;
2315e7d89717SSunil Goutham }
2316e7d89717SSunil Goutham
2317e7d89717SSunil Goutham RVU_DEBUG_SEQ_FOPS(nix_band_prof_rsrc, nix_band_prof_rsrc_display, NULL);
2318e7d89717SSunil Goutham
rvu_dbg_nix_init(struct rvu * rvu,int blkaddr)23190f3ce484SRakesh Babu static void rvu_dbg_nix_init(struct rvu *rvu, int blkaddr)
232002e202c3SPrakash Brahmajyosyula {
23210f3ce484SRakesh Babu struct nix_hw *nix_hw;
232202e202c3SPrakash Brahmajyosyula
23230f3ce484SRakesh Babu if (!is_block_implemented(rvu->hw, blkaddr))
23240f3ce484SRakesh Babu return;
23250f3ce484SRakesh Babu
23260f3ce484SRakesh Babu if (blkaddr == BLKADDR_NIX0) {
232702e202c3SPrakash Brahmajyosyula rvu->rvu_dbg.nix = debugfs_create_dir("nix", rvu->rvu_dbg.root);
23280f3ce484SRakesh Babu nix_hw = &rvu->hw->nix[0];
23290f3ce484SRakesh Babu } else {
23300f3ce484SRakesh Babu rvu->rvu_dbg.nix = debugfs_create_dir("nix1",
23310f3ce484SRakesh Babu rvu->rvu_dbg.root);
23320f3ce484SRakesh Babu nix_hw = &rvu->hw->nix[1];
23330f3ce484SRakesh Babu }
233402e202c3SPrakash Brahmajyosyula
23352ce5a307SDan Carpenter debugfs_create_file("sq_ctx", 0600, rvu->rvu_dbg.nix, nix_hw,
233602e202c3SPrakash Brahmajyosyula &rvu_dbg_nix_sq_ctx_fops);
23372ce5a307SDan Carpenter debugfs_create_file("rq_ctx", 0600, rvu->rvu_dbg.nix, nix_hw,
233802e202c3SPrakash Brahmajyosyula &rvu_dbg_nix_rq_ctx_fops);
23392ce5a307SDan Carpenter debugfs_create_file("cq_ctx", 0600, rvu->rvu_dbg.nix, nix_hw,
234002e202c3SPrakash Brahmajyosyula &rvu_dbg_nix_cq_ctx_fops);
23412ce5a307SDan Carpenter debugfs_create_file("ndc_tx_cache", 0600, rvu->rvu_dbg.nix, nix_hw,
23422ce5a307SDan Carpenter &rvu_dbg_nix_ndc_tx_cache_fops);
23432ce5a307SDan Carpenter debugfs_create_file("ndc_rx_cache", 0600, rvu->rvu_dbg.nix, nix_hw,
23442ce5a307SDan Carpenter &rvu_dbg_nix_ndc_rx_cache_fops);
23452ce5a307SDan Carpenter debugfs_create_file("ndc_tx_hits_miss", 0600, rvu->rvu_dbg.nix, nix_hw,
23460f3ce484SRakesh Babu &rvu_dbg_nix_ndc_tx_hits_miss_fops);
23472ce5a307SDan Carpenter debugfs_create_file("ndc_rx_hits_miss", 0600, rvu->rvu_dbg.nix, nix_hw,
23480f3ce484SRakesh Babu &rvu_dbg_nix_ndc_rx_hits_miss_fops);
23492ce5a307SDan Carpenter debugfs_create_file("qsize", 0600, rvu->rvu_dbg.nix, rvu,
235002e202c3SPrakash Brahmajyosyula &rvu_dbg_nix_qsize_fops);
2351e7d89717SSunil Goutham debugfs_create_file("ingress_policer_ctx", 0600, rvu->rvu_dbg.nix, nix_hw,
2352e7d89717SSunil Goutham &rvu_dbg_nix_band_prof_ctx_fops);
2353e7d89717SSunil Goutham debugfs_create_file("ingress_policer_rsrc", 0600, rvu->rvu_dbg.nix, nix_hw,
2354e7d89717SSunil Goutham &rvu_dbg_nix_band_prof_rsrc_fops);
235502e202c3SPrakash Brahmajyosyula }
235602e202c3SPrakash Brahmajyosyula
rvu_dbg_npa_init(struct rvu * rvu)23578756828aSChristina Jacob static void rvu_dbg_npa_init(struct rvu *rvu)
23588756828aSChristina Jacob {
23598756828aSChristina Jacob rvu->rvu_dbg.npa = debugfs_create_dir("npa", rvu->rvu_dbg.root);
23608756828aSChristina Jacob
23612ce5a307SDan Carpenter debugfs_create_file("qsize", 0600, rvu->rvu_dbg.npa, rvu,
23628756828aSChristina Jacob &rvu_dbg_npa_qsize_fops);
23632ce5a307SDan Carpenter debugfs_create_file("aura_ctx", 0600, rvu->rvu_dbg.npa, rvu,
23648756828aSChristina Jacob &rvu_dbg_npa_aura_ctx_fops);
23652ce5a307SDan Carpenter debugfs_create_file("pool_ctx", 0600, rvu->rvu_dbg.npa, rvu,
23668756828aSChristina Jacob &rvu_dbg_npa_pool_ctx_fops);
23672ce5a307SDan Carpenter debugfs_create_file("ndc_cache", 0600, rvu->rvu_dbg.npa, rvu,
2368c5a797e0SPrakash Brahmajyosyula &rvu_dbg_npa_ndc_cache_fops);
23692ce5a307SDan Carpenter debugfs_create_file("ndc_hits_miss", 0600, rvu->rvu_dbg.npa, rvu,
23702ce5a307SDan Carpenter &rvu_dbg_npa_ndc_hits_miss_fops);
23718756828aSChristina Jacob }
23728756828aSChristina Jacob
2373f967488dSLinu Cherian #define PRINT_CGX_CUML_NIXRX_STATUS(idx, name) \
2374f967488dSLinu Cherian ({ \
2375f967488dSLinu Cherian u64 cnt; \
2376f967488dSLinu Cherian err = rvu_cgx_nix_cuml_stats(rvu, cgxd, lmac_id, (idx), \
2377f967488dSLinu Cherian NIX_STATS_RX, &(cnt)); \
2378f967488dSLinu Cherian if (!err) \
2379f967488dSLinu Cherian seq_printf(s, "%s: %llu\n", name, cnt); \
2380f967488dSLinu Cherian cnt; \
2381f967488dSLinu Cherian })
2382f967488dSLinu Cherian
2383f967488dSLinu Cherian #define PRINT_CGX_CUML_NIXTX_STATUS(idx, name) \
2384f967488dSLinu Cherian ({ \
2385f967488dSLinu Cherian u64 cnt; \
2386f967488dSLinu Cherian err = rvu_cgx_nix_cuml_stats(rvu, cgxd, lmac_id, (idx), \
2387f967488dSLinu Cherian NIX_STATS_TX, &(cnt)); \
2388f967488dSLinu Cherian if (!err) \
2389f967488dSLinu Cherian seq_printf(s, "%s: %llu\n", name, cnt); \
2390f967488dSLinu Cherian cnt; \
2391f967488dSLinu Cherian })
2392f967488dSLinu Cherian
cgx_print_stats(struct seq_file * s,int lmac_id)2393c57211b5SPrakash Brahmajyosyula static int cgx_print_stats(struct seq_file *s, int lmac_id)
2394c57211b5SPrakash Brahmajyosyula {
2395c57211b5SPrakash Brahmajyosyula struct cgx_link_user_info linfo;
239691c6945eSHariprasad Kelam struct mac_ops *mac_ops;
2397c57211b5SPrakash Brahmajyosyula void *cgxd = s->private;
2398f967488dSLinu Cherian u64 ucast, mcast, bcast;
2399c57211b5SPrakash Brahmajyosyula int stat = 0, err = 0;
2400c57211b5SPrakash Brahmajyosyula u64 tx_stat, rx_stat;
2401f967488dSLinu Cherian struct rvu *rvu;
2402f967488dSLinu Cherian
2403f967488dSLinu Cherian rvu = pci_get_drvdata(pci_get_device(PCI_VENDOR_ID_CAVIUM,
2404f967488dSLinu Cherian PCI_DEVID_OCTEONTX2_RVU_AF, NULL));
2405f967488dSLinu Cherian if (!rvu)
2406f967488dSLinu Cherian return -ENODEV;
2407c57211b5SPrakash Brahmajyosyula
240891c6945eSHariprasad Kelam mac_ops = get_mac_ops(cgxd);
24091910ccf0SRakesh Babu Saladi /* There can be no CGX devices at all */
241091c6945eSHariprasad Kelam if (!mac_ops)
241191c6945eSHariprasad Kelam return 0;
241291c6945eSHariprasad Kelam
2413c57211b5SPrakash Brahmajyosyula /* Link status */
2414c57211b5SPrakash Brahmajyosyula seq_puts(s, "\n=======Link Status======\n\n");
2415c57211b5SPrakash Brahmajyosyula err = cgx_get_link_info(cgxd, lmac_id, &linfo);
2416c57211b5SPrakash Brahmajyosyula if (err)
2417c57211b5SPrakash Brahmajyosyula seq_puts(s, "Failed to read link status\n");
2418c57211b5SPrakash Brahmajyosyula seq_printf(s, "\nLink is %s %d Mbps\n\n",
2419c57211b5SPrakash Brahmajyosyula linfo.link_up ? "UP" : "DOWN", linfo.speed);
2420c57211b5SPrakash Brahmajyosyula
2421c57211b5SPrakash Brahmajyosyula /* Rx stats */
242291c6945eSHariprasad Kelam seq_printf(s, "\n=======NIX RX_STATS(%s port level)======\n\n",
242391c6945eSHariprasad Kelam mac_ops->name);
2424f967488dSLinu Cherian ucast = PRINT_CGX_CUML_NIXRX_STATUS(RX_UCAST, "rx_ucast_frames");
2425f967488dSLinu Cherian if (err)
2426f967488dSLinu Cherian return err;
2427f967488dSLinu Cherian mcast = PRINT_CGX_CUML_NIXRX_STATUS(RX_MCAST, "rx_mcast_frames");
2428f967488dSLinu Cherian if (err)
2429f967488dSLinu Cherian return err;
2430f967488dSLinu Cherian bcast = PRINT_CGX_CUML_NIXRX_STATUS(RX_BCAST, "rx_bcast_frames");
2431f967488dSLinu Cherian if (err)
2432f967488dSLinu Cherian return err;
2433f967488dSLinu Cherian seq_printf(s, "rx_frames: %llu\n", ucast + mcast + bcast);
2434f967488dSLinu Cherian PRINT_CGX_CUML_NIXRX_STATUS(RX_OCTS, "rx_bytes");
2435f967488dSLinu Cherian if (err)
2436f967488dSLinu Cherian return err;
2437f967488dSLinu Cherian PRINT_CGX_CUML_NIXRX_STATUS(RX_DROP, "rx_drops");
2438f967488dSLinu Cherian if (err)
2439f967488dSLinu Cherian return err;
2440f967488dSLinu Cherian PRINT_CGX_CUML_NIXRX_STATUS(RX_ERR, "rx_errors");
2441f967488dSLinu Cherian if (err)
2442f967488dSLinu Cherian return err;
2443f967488dSLinu Cherian
2444f967488dSLinu Cherian /* Tx stats */
244591c6945eSHariprasad Kelam seq_printf(s, "\n=======NIX TX_STATS(%s port level)======\n\n",
244691c6945eSHariprasad Kelam mac_ops->name);
2447f967488dSLinu Cherian ucast = PRINT_CGX_CUML_NIXTX_STATUS(TX_UCAST, "tx_ucast_frames");
2448f967488dSLinu Cherian if (err)
2449f967488dSLinu Cherian return err;
2450f967488dSLinu Cherian mcast = PRINT_CGX_CUML_NIXTX_STATUS(TX_MCAST, "tx_mcast_frames");
2451f967488dSLinu Cherian if (err)
2452f967488dSLinu Cherian return err;
2453f967488dSLinu Cherian bcast = PRINT_CGX_CUML_NIXTX_STATUS(TX_BCAST, "tx_bcast_frames");
2454f967488dSLinu Cherian if (err)
2455f967488dSLinu Cherian return err;
2456f967488dSLinu Cherian seq_printf(s, "tx_frames: %llu\n", ucast + mcast + bcast);
2457f967488dSLinu Cherian PRINT_CGX_CUML_NIXTX_STATUS(TX_OCTS, "tx_bytes");
2458f967488dSLinu Cherian if (err)
2459f967488dSLinu Cherian return err;
2460f967488dSLinu Cherian PRINT_CGX_CUML_NIXTX_STATUS(TX_DROP, "tx_drops");
2461f967488dSLinu Cherian if (err)
2462f967488dSLinu Cherian return err;
2463f967488dSLinu Cherian
2464f967488dSLinu Cherian /* Rx stats */
246591c6945eSHariprasad Kelam seq_printf(s, "\n=======%s RX_STATS======\n\n", mac_ops->name);
2466ce7a6c31SHariprasad Kelam while (stat < mac_ops->rx_stats_cnt) {
2467ce7a6c31SHariprasad Kelam err = mac_ops->mac_get_rx_stats(cgxd, lmac_id, stat, &rx_stat);
2468c57211b5SPrakash Brahmajyosyula if (err)
2469c57211b5SPrakash Brahmajyosyula return err;
2470ce7a6c31SHariprasad Kelam if (is_rvu_otx2(rvu))
2471ce7a6c31SHariprasad Kelam seq_printf(s, "%s: %llu\n", cgx_rx_stats_fields[stat],
2472ce7a6c31SHariprasad Kelam rx_stat);
2473ce7a6c31SHariprasad Kelam else
2474ce7a6c31SHariprasad Kelam seq_printf(s, "%s: %llu\n", rpm_rx_stats_fields[stat],
2475ce7a6c31SHariprasad Kelam rx_stat);
2476c57211b5SPrakash Brahmajyosyula stat++;
2477c57211b5SPrakash Brahmajyosyula }
2478c57211b5SPrakash Brahmajyosyula
2479c57211b5SPrakash Brahmajyosyula /* Tx stats */
2480c57211b5SPrakash Brahmajyosyula stat = 0;
248191c6945eSHariprasad Kelam seq_printf(s, "\n=======%s TX_STATS======\n\n", mac_ops->name);
2482ce7a6c31SHariprasad Kelam while (stat < mac_ops->tx_stats_cnt) {
2483ce7a6c31SHariprasad Kelam err = mac_ops->mac_get_tx_stats(cgxd, lmac_id, stat, &tx_stat);
2484c57211b5SPrakash Brahmajyosyula if (err)
2485c57211b5SPrakash Brahmajyosyula return err;
2486ce7a6c31SHariprasad Kelam
2487ce7a6c31SHariprasad Kelam if (is_rvu_otx2(rvu))
2488ce7a6c31SHariprasad Kelam seq_printf(s, "%s: %llu\n", cgx_tx_stats_fields[stat],
2489ce7a6c31SHariprasad Kelam tx_stat);
2490ce7a6c31SHariprasad Kelam else
2491ce7a6c31SHariprasad Kelam seq_printf(s, "%s: %llu\n", rpm_tx_stats_fields[stat],
2492ce7a6c31SHariprasad Kelam tx_stat);
2493c57211b5SPrakash Brahmajyosyula stat++;
2494c57211b5SPrakash Brahmajyosyula }
2495c57211b5SPrakash Brahmajyosyula
2496c57211b5SPrakash Brahmajyosyula return err;
2497c57211b5SPrakash Brahmajyosyula }
2498c57211b5SPrakash Brahmajyosyula
rvu_dbg_derive_lmacid(struct seq_file * filp,int * lmac_id)2499dbc52debSHariprasad Kelam static int rvu_dbg_derive_lmacid(struct seq_file *filp, int *lmac_id)
2500c57211b5SPrakash Brahmajyosyula {
2501c57211b5SPrakash Brahmajyosyula struct dentry *current_dir;
2502c57211b5SPrakash Brahmajyosyula char *buf;
2503c57211b5SPrakash Brahmajyosyula
2504c57211b5SPrakash Brahmajyosyula current_dir = filp->file->f_path.dentry->d_parent;
2505c57211b5SPrakash Brahmajyosyula buf = strrchr(current_dir->d_name.name, 'c');
2506c57211b5SPrakash Brahmajyosyula if (!buf)
2507c57211b5SPrakash Brahmajyosyula return -EINVAL;
2508c57211b5SPrakash Brahmajyosyula
2509dbc52debSHariprasad Kelam return kstrtoint(buf + 1, 10, lmac_id);
2510c57211b5SPrakash Brahmajyosyula }
2511dbc52debSHariprasad Kelam
rvu_dbg_cgx_stat_display(struct seq_file * filp,void * unused)2512dbc52debSHariprasad Kelam static int rvu_dbg_cgx_stat_display(struct seq_file *filp, void *unused)
2513dbc52debSHariprasad Kelam {
2514dbc52debSHariprasad Kelam int lmac_id, err;
2515dbc52debSHariprasad Kelam
2516dbc52debSHariprasad Kelam err = rvu_dbg_derive_lmacid(filp, &lmac_id);
2517dbc52debSHariprasad Kelam if (!err)
2518dbc52debSHariprasad Kelam return cgx_print_stats(filp, lmac_id);
2519dbc52debSHariprasad Kelam
2520c57211b5SPrakash Brahmajyosyula return err;
2521c57211b5SPrakash Brahmajyosyula }
2522c57211b5SPrakash Brahmajyosyula
2523c57211b5SPrakash Brahmajyosyula RVU_DEBUG_SEQ_FOPS(cgx_stat, cgx_stat_display, NULL);
2524c57211b5SPrakash Brahmajyosyula
cgx_print_dmac_flt(struct seq_file * s,int lmac_id)2525dbc52debSHariprasad Kelam static int cgx_print_dmac_flt(struct seq_file *s, int lmac_id)
2526dbc52debSHariprasad Kelam {
2527dbc52debSHariprasad Kelam struct pci_dev *pdev = NULL;
2528dbc52debSHariprasad Kelam void *cgxd = s->private;
2529dbc52debSHariprasad Kelam char *bcast, *mcast;
2530dbc52debSHariprasad Kelam u16 index, domain;
2531dbc52debSHariprasad Kelam u8 dmac[ETH_ALEN];
2532dbc52debSHariprasad Kelam struct rvu *rvu;
2533dbc52debSHariprasad Kelam u64 cfg, mac;
2534dbc52debSHariprasad Kelam int pf;
2535dbc52debSHariprasad Kelam
2536dbc52debSHariprasad Kelam rvu = pci_get_drvdata(pci_get_device(PCI_VENDOR_ID_CAVIUM,
2537dbc52debSHariprasad Kelam PCI_DEVID_OCTEONTX2_RVU_AF, NULL));
2538dbc52debSHariprasad Kelam if (!rvu)
2539dbc52debSHariprasad Kelam return -ENODEV;
2540dbc52debSHariprasad Kelam
2541dbc52debSHariprasad Kelam pf = cgxlmac_to_pf(rvu, cgx_get_cgxid(cgxd), lmac_id);
2542dbc52debSHariprasad Kelam domain = 2;
2543dbc52debSHariprasad Kelam
2544dbc52debSHariprasad Kelam pdev = pci_get_domain_bus_and_slot(domain, pf + 1, 0);
2545dbc52debSHariprasad Kelam if (!pdev)
2546dbc52debSHariprasad Kelam return 0;
2547dbc52debSHariprasad Kelam
2548dbc52debSHariprasad Kelam cfg = cgx_read_dmac_ctrl(cgxd, lmac_id);
2549dbc52debSHariprasad Kelam bcast = cfg & CGX_DMAC_BCAST_MODE ? "ACCEPT" : "REJECT";
2550dbc52debSHariprasad Kelam mcast = cfg & CGX_DMAC_MCAST_MODE ? "ACCEPT" : "REJECT";
2551dbc52debSHariprasad Kelam
2552dbc52debSHariprasad Kelam seq_puts(s,
2553dbc52debSHariprasad Kelam "PCI dev RVUPF BROADCAST MULTICAST FILTER-MODE\n");
2554dbc52debSHariprasad Kelam seq_printf(s, "%s PF%d %9s %9s",
2555dbc52debSHariprasad Kelam dev_name(&pdev->dev), pf, bcast, mcast);
2556dbc52debSHariprasad Kelam if (cfg & CGX_DMAC_CAM_ACCEPT)
2557dbc52debSHariprasad Kelam seq_printf(s, "%12s\n\n", "UNICAST");
2558dbc52debSHariprasad Kelam else
2559dbc52debSHariprasad Kelam seq_printf(s, "%16s\n\n", "PROMISCUOUS");
2560dbc52debSHariprasad Kelam
2561dbc52debSHariprasad Kelam seq_puts(s, "\nDMAC-INDEX ADDRESS\n");
2562dbc52debSHariprasad Kelam
2563dbc52debSHariprasad Kelam for (index = 0 ; index < 32 ; index++) {
2564dbc52debSHariprasad Kelam cfg = cgx_read_dmac_entry(cgxd, index);
2565dbc52debSHariprasad Kelam /* Display enabled dmac entries associated with current lmac */
2566dbc52debSHariprasad Kelam if (lmac_id == FIELD_GET(CGX_DMAC_CAM_ENTRY_LMACID, cfg) &&
2567dbc52debSHariprasad Kelam FIELD_GET(CGX_DMAC_CAM_ADDR_ENABLE, cfg)) {
2568dbc52debSHariprasad Kelam mac = FIELD_GET(CGX_RX_DMAC_ADR_MASK, cfg);
2569dbc52debSHariprasad Kelam u64_to_ether_addr(mac, dmac);
2570dbc52debSHariprasad Kelam seq_printf(s, "%7d %pM\n", index, dmac);
2571dbc52debSHariprasad Kelam }
2572dbc52debSHariprasad Kelam }
2573dbc52debSHariprasad Kelam
2574d6660880SYang Yingliang pci_dev_put(pdev);
2575dbc52debSHariprasad Kelam return 0;
2576dbc52debSHariprasad Kelam }
2577dbc52debSHariprasad Kelam
rvu_dbg_cgx_dmac_flt_display(struct seq_file * filp,void * unused)2578dbc52debSHariprasad Kelam static int rvu_dbg_cgx_dmac_flt_display(struct seq_file *filp, void *unused)
2579dbc52debSHariprasad Kelam {
2580dbc52debSHariprasad Kelam int err, lmac_id;
2581dbc52debSHariprasad Kelam
2582dbc52debSHariprasad Kelam err = rvu_dbg_derive_lmacid(filp, &lmac_id);
2583dbc52debSHariprasad Kelam if (!err)
2584dbc52debSHariprasad Kelam return cgx_print_dmac_flt(filp, lmac_id);
2585dbc52debSHariprasad Kelam
2586dbc52debSHariprasad Kelam return err;
2587dbc52debSHariprasad Kelam }
2588dbc52debSHariprasad Kelam
2589dbc52debSHariprasad Kelam RVU_DEBUG_SEQ_FOPS(cgx_dmac_flt, cgx_dmac_flt_display, NULL);
2590dbc52debSHariprasad Kelam
rvu_dbg_cgx_init(struct rvu * rvu)2591c57211b5SPrakash Brahmajyosyula static void rvu_dbg_cgx_init(struct rvu *rvu)
2592c57211b5SPrakash Brahmajyosyula {
259391c6945eSHariprasad Kelam struct mac_ops *mac_ops;
259491c6945eSHariprasad Kelam unsigned long lmac_bmap;
2595c57211b5SPrakash Brahmajyosyula int i, lmac_id;
2596c57211b5SPrakash Brahmajyosyula char dname[20];
2597c57211b5SPrakash Brahmajyosyula void *cgx;
2598c57211b5SPrakash Brahmajyosyula
25993feac505SGeetha sowjanya if (!cgx_get_cgxcnt_max())
26003feac505SGeetha sowjanya return;
26013feac505SGeetha sowjanya
260229788787SSubbaraya Sundeep mac_ops = get_mac_ops(rvu_first_cgx_pdata(rvu));
260391c6945eSHariprasad Kelam if (!mac_ops)
260491c6945eSHariprasad Kelam return;
260591c6945eSHariprasad Kelam
260691c6945eSHariprasad Kelam rvu->rvu_dbg.cgx_root = debugfs_create_dir(mac_ops->name,
260791c6945eSHariprasad Kelam rvu->rvu_dbg.root);
2608c57211b5SPrakash Brahmajyosyula
2609c57211b5SPrakash Brahmajyosyula for (i = 0; i < cgx_get_cgxcnt_max(); i++) {
2610c57211b5SPrakash Brahmajyosyula cgx = rvu_cgx_pdata(i, rvu);
2611c57211b5SPrakash Brahmajyosyula if (!cgx)
2612c57211b5SPrakash Brahmajyosyula continue;
261391c6945eSHariprasad Kelam lmac_bmap = cgx_get_lmac_bmap(cgx);
2614c57211b5SPrakash Brahmajyosyula /* cgx debugfs dir */
261591c6945eSHariprasad Kelam sprintf(dname, "%s%d", mac_ops->name, i);
2616c57211b5SPrakash Brahmajyosyula rvu->rvu_dbg.cgx = debugfs_create_dir(dname,
2617c57211b5SPrakash Brahmajyosyula rvu->rvu_dbg.cgx_root);
261891c6945eSHariprasad Kelam
2619f2e664adSRakesh Babu Saladi for_each_set_bit(lmac_id, &lmac_bmap, rvu->hw->lmac_per_cgx) {
2620c57211b5SPrakash Brahmajyosyula /* lmac debugfs dir */
2621c57211b5SPrakash Brahmajyosyula sprintf(dname, "lmac%d", lmac_id);
2622c57211b5SPrakash Brahmajyosyula rvu->rvu_dbg.lmac =
2623c57211b5SPrakash Brahmajyosyula debugfs_create_dir(dname, rvu->rvu_dbg.cgx);
2624c57211b5SPrakash Brahmajyosyula
26252ce5a307SDan Carpenter debugfs_create_file("stats", 0600, rvu->rvu_dbg.lmac,
26262ce5a307SDan Carpenter cgx, &rvu_dbg_cgx_stat_fops);
2627dbc52debSHariprasad Kelam debugfs_create_file("mac_filter", 0600,
2628dbc52debSHariprasad Kelam rvu->rvu_dbg.lmac, cgx,
2629dbc52debSHariprasad Kelam &rvu_dbg_cgx_dmac_flt_fops);
2630c57211b5SPrakash Brahmajyosyula }
2631c57211b5SPrakash Brahmajyosyula }
2632c57211b5SPrakash Brahmajyosyula }
2633c57211b5SPrakash Brahmajyosyula
2634e07fb507SSunil Goutham /* NPC debugfs APIs */
rvu_print_npc_mcam_info(struct seq_file * s,u16 pcifunc,int blkaddr)2635e07fb507SSunil Goutham static void rvu_print_npc_mcam_info(struct seq_file *s,
2636e07fb507SSunil Goutham u16 pcifunc, int blkaddr)
2637e07fb507SSunil Goutham {
2638e07fb507SSunil Goutham struct rvu *rvu = s->private;
2639e07fb507SSunil Goutham int entry_acnt, entry_ecnt;
2640e07fb507SSunil Goutham int cntr_acnt, cntr_ecnt;
2641e07fb507SSunil Goutham
2642e07fb507SSunil Goutham rvu_npc_get_mcam_entry_alloc_info(rvu, pcifunc, blkaddr,
2643e07fb507SSunil Goutham &entry_acnt, &entry_ecnt);
2644e07fb507SSunil Goutham rvu_npc_get_mcam_counter_alloc_info(rvu, pcifunc, blkaddr,
2645e07fb507SSunil Goutham &cntr_acnt, &cntr_ecnt);
2646e07fb507SSunil Goutham if (!entry_acnt && !cntr_acnt)
2647e07fb507SSunil Goutham return;
2648e07fb507SSunil Goutham
2649e07fb507SSunil Goutham if (!(pcifunc & RVU_PFVF_FUNC_MASK))
2650e07fb507SSunil Goutham seq_printf(s, "\n\t\t Device \t\t: PF%d\n",
2651e07fb507SSunil Goutham rvu_get_pf(pcifunc));
2652e07fb507SSunil Goutham else
2653e07fb507SSunil Goutham seq_printf(s, "\n\t\t Device \t\t: PF%d VF%d\n",
2654e07fb507SSunil Goutham rvu_get_pf(pcifunc),
2655e07fb507SSunil Goutham (pcifunc & RVU_PFVF_FUNC_MASK) - 1);
2656e07fb507SSunil Goutham
2657e07fb507SSunil Goutham if (entry_acnt) {
2658e07fb507SSunil Goutham seq_printf(s, "\t\t Entries allocated \t: %d\n", entry_acnt);
2659e07fb507SSunil Goutham seq_printf(s, "\t\t Entries enabled \t: %d\n", entry_ecnt);
2660e07fb507SSunil Goutham }
2661e07fb507SSunil Goutham if (cntr_acnt) {
2662e07fb507SSunil Goutham seq_printf(s, "\t\t Counters allocated \t: %d\n", cntr_acnt);
2663e07fb507SSunil Goutham seq_printf(s, "\t\t Counters enabled \t: %d\n", cntr_ecnt);
2664e07fb507SSunil Goutham }
2665e07fb507SSunil Goutham }
2666e07fb507SSunil Goutham
rvu_dbg_npc_mcam_info_display(struct seq_file * filp,void * unsued)2667e07fb507SSunil Goutham static int rvu_dbg_npc_mcam_info_display(struct seq_file *filp, void *unsued)
2668e07fb507SSunil Goutham {
2669e07fb507SSunil Goutham struct rvu *rvu = filp->private;
2670e07fb507SSunil Goutham int pf, vf, numvfs, blkaddr;
2671e07fb507SSunil Goutham struct npc_mcam *mcam;
26721c1935c9SSubbaraya Sundeep u16 pcifunc, counters;
2673e07fb507SSunil Goutham u64 cfg;
2674e07fb507SSunil Goutham
2675e07fb507SSunil Goutham blkaddr = rvu_get_blkaddr(rvu, BLKTYPE_NPC, 0);
2676e07fb507SSunil Goutham if (blkaddr < 0)
2677e07fb507SSunil Goutham return -ENODEV;
2678e07fb507SSunil Goutham
2679e07fb507SSunil Goutham mcam = &rvu->hw->mcam;
26801c1935c9SSubbaraya Sundeep counters = rvu->hw->npc_counters;
2681e07fb507SSunil Goutham
2682e07fb507SSunil Goutham seq_puts(filp, "\nNPC MCAM info:\n");
2683e07fb507SSunil Goutham /* MCAM keywidth on receive and transmit sides */
2684e07fb507SSunil Goutham cfg = rvu_read64(rvu, blkaddr, NPC_AF_INTFX_KEX_CFG(NIX_INTF_RX));
2685e07fb507SSunil Goutham cfg = (cfg >> 32) & 0x07;
2686e07fb507SSunil Goutham seq_printf(filp, "\t\t RX keywidth \t: %s\n", (cfg == NPC_MCAM_KEY_X1) ?
2687e07fb507SSunil Goutham "112bits" : ((cfg == NPC_MCAM_KEY_X2) ?
2688e07fb507SSunil Goutham "224bits" : "448bits"));
2689e07fb507SSunil Goutham cfg = rvu_read64(rvu, blkaddr, NPC_AF_INTFX_KEX_CFG(NIX_INTF_TX));
2690e07fb507SSunil Goutham cfg = (cfg >> 32) & 0x07;
2691e07fb507SSunil Goutham seq_printf(filp, "\t\t TX keywidth \t: %s\n", (cfg == NPC_MCAM_KEY_X1) ?
2692e07fb507SSunil Goutham "112bits" : ((cfg == NPC_MCAM_KEY_X2) ?
2693e07fb507SSunil Goutham "224bits" : "448bits"));
2694e07fb507SSunil Goutham
2695e07fb507SSunil Goutham mutex_lock(&mcam->lock);
2696e07fb507SSunil Goutham /* MCAM entries */
2697e07fb507SSunil Goutham seq_printf(filp, "\n\t\t MCAM entries \t: %d\n", mcam->total_entries);
2698e07fb507SSunil Goutham seq_printf(filp, "\t\t Reserved \t: %d\n",
2699e07fb507SSunil Goutham mcam->total_entries - mcam->bmap_entries);
2700e07fb507SSunil Goutham seq_printf(filp, "\t\t Available \t: %d\n", mcam->bmap_fcnt);
2701e07fb507SSunil Goutham
2702e07fb507SSunil Goutham /* MCAM counters */
27031c1935c9SSubbaraya Sundeep seq_printf(filp, "\n\t\t MCAM counters \t: %d\n", counters);
27041c1935c9SSubbaraya Sundeep seq_printf(filp, "\t\t Reserved \t: %d\n",
27051c1935c9SSubbaraya Sundeep counters - mcam->counters.max);
2706e07fb507SSunil Goutham seq_printf(filp, "\t\t Available \t: %d\n",
2707e07fb507SSunil Goutham rvu_rsrc_free_count(&mcam->counters));
2708e07fb507SSunil Goutham
2709e07fb507SSunil Goutham if (mcam->bmap_entries == mcam->bmap_fcnt) {
2710e07fb507SSunil Goutham mutex_unlock(&mcam->lock);
2711e07fb507SSunil Goutham return 0;
2712e07fb507SSunil Goutham }
2713e07fb507SSunil Goutham
2714e07fb507SSunil Goutham seq_puts(filp, "\n\t\t Current allocation\n");
2715e07fb507SSunil Goutham seq_puts(filp, "\t\t====================\n");
2716e07fb507SSunil Goutham for (pf = 0; pf < rvu->hw->total_pfs; pf++) {
2717e07fb507SSunil Goutham pcifunc = (pf << RVU_PFVF_PF_SHIFT);
2718e07fb507SSunil Goutham rvu_print_npc_mcam_info(filp, pcifunc, blkaddr);
2719e07fb507SSunil Goutham
2720e07fb507SSunil Goutham cfg = rvu_read64(rvu, BLKADDR_RVUM, RVU_PRIV_PFX_CFG(pf));
2721e07fb507SSunil Goutham numvfs = (cfg >> 12) & 0xFF;
2722e07fb507SSunil Goutham for (vf = 0; vf < numvfs; vf++) {
2723e07fb507SSunil Goutham pcifunc = (pf << RVU_PFVF_PF_SHIFT) | (vf + 1);
2724e07fb507SSunil Goutham rvu_print_npc_mcam_info(filp, pcifunc, blkaddr);
2725e07fb507SSunil Goutham }
2726e07fb507SSunil Goutham }
2727e07fb507SSunil Goutham
2728e07fb507SSunil Goutham mutex_unlock(&mcam->lock);
2729e07fb507SSunil Goutham return 0;
2730e07fb507SSunil Goutham }
2731e07fb507SSunil Goutham
2732e07fb507SSunil Goutham RVU_DEBUG_SEQ_FOPS(npc_mcam_info, npc_mcam_info_display, NULL);
2733e07fb507SSunil Goutham
rvu_dbg_npc_rx_miss_stats_display(struct seq_file * filp,void * unused)2734e07fb507SSunil Goutham static int rvu_dbg_npc_rx_miss_stats_display(struct seq_file *filp,
2735e07fb507SSunil Goutham void *unused)
2736e07fb507SSunil Goutham {
2737e07fb507SSunil Goutham struct rvu *rvu = filp->private;
2738e07fb507SSunil Goutham struct npc_mcam *mcam;
2739e07fb507SSunil Goutham int blkaddr;
2740e07fb507SSunil Goutham
2741e07fb507SSunil Goutham blkaddr = rvu_get_blkaddr(rvu, BLKTYPE_NPC, 0);
2742e07fb507SSunil Goutham if (blkaddr < 0)
2743e07fb507SSunil Goutham return -ENODEV;
2744e07fb507SSunil Goutham
2745e07fb507SSunil Goutham mcam = &rvu->hw->mcam;
2746e07fb507SSunil Goutham
2747e07fb507SSunil Goutham seq_puts(filp, "\nNPC MCAM RX miss action stats\n");
2748e07fb507SSunil Goutham seq_printf(filp, "\t\tStat %d: \t%lld\n", mcam->rx_miss_act_cntr,
2749e07fb507SSunil Goutham rvu_read64(rvu, blkaddr,
2750e07fb507SSunil Goutham NPC_AF_MATCH_STATX(mcam->rx_miss_act_cntr)));
2751e07fb507SSunil Goutham
2752e07fb507SSunil Goutham return 0;
2753e07fb507SSunil Goutham }
2754e07fb507SSunil Goutham
2755e07fb507SSunil Goutham RVU_DEBUG_SEQ_FOPS(npc_rx_miss_act, npc_rx_miss_stats_display, NULL);
2756e07fb507SSunil Goutham
rvu_dbg_npc_mcam_show_flows(struct seq_file * s,struct rvu_npc_mcam_rule * rule)27574d6beb9cSSubbaraya Sundeep static void rvu_dbg_npc_mcam_show_flows(struct seq_file *s,
27584d6beb9cSSubbaraya Sundeep struct rvu_npc_mcam_rule *rule)
27594d6beb9cSSubbaraya Sundeep {
27604d6beb9cSSubbaraya Sundeep u8 bit;
27614d6beb9cSSubbaraya Sundeep
27624d6beb9cSSubbaraya Sundeep for_each_set_bit(bit, (unsigned long *)&rule->features, 64) {
27634d6beb9cSSubbaraya Sundeep seq_printf(s, "\t%s ", npc_get_field_name(bit));
27644d6beb9cSSubbaraya Sundeep switch (bit) {
27652cee6401SSuman Ghosh case NPC_LXMB:
27662cee6401SSuman Ghosh if (rule->lxmb == 1)
27672cee6401SSuman Ghosh seq_puts(s, "\tL2M nibble is set\n");
27682cee6401SSuman Ghosh else
27692cee6401SSuman Ghosh seq_puts(s, "\tL2B nibble is set\n");
27702cee6401SSuman Ghosh break;
27714d6beb9cSSubbaraya Sundeep case NPC_DMAC:
27724d6beb9cSSubbaraya Sundeep seq_printf(s, "%pM ", rule->packet.dmac);
27734d6beb9cSSubbaraya Sundeep seq_printf(s, "mask %pM\n", rule->mask.dmac);
27744d6beb9cSSubbaraya Sundeep break;
27754d6beb9cSSubbaraya Sundeep case NPC_SMAC:
27764d6beb9cSSubbaraya Sundeep seq_printf(s, "%pM ", rule->packet.smac);
27774d6beb9cSSubbaraya Sundeep seq_printf(s, "mask %pM\n", rule->mask.smac);
27784d6beb9cSSubbaraya Sundeep break;
27794d6beb9cSSubbaraya Sundeep case NPC_ETYPE:
27804d6beb9cSSubbaraya Sundeep seq_printf(s, "0x%x ", ntohs(rule->packet.etype));
27814d6beb9cSSubbaraya Sundeep seq_printf(s, "mask 0x%x\n", ntohs(rule->mask.etype));
27824d6beb9cSSubbaraya Sundeep break;
27834d6beb9cSSubbaraya Sundeep case NPC_OUTER_VID:
27841d4d9e42SNaveen Mamindlapalli seq_printf(s, "0x%x ", ntohs(rule->packet.vlan_tci));
27854d6beb9cSSubbaraya Sundeep seq_printf(s, "mask 0x%x\n",
27864d6beb9cSSubbaraya Sundeep ntohs(rule->mask.vlan_tci));
27874d6beb9cSSubbaraya Sundeep break;
278821e74835SSuman Ghosh case NPC_INNER_VID:
278921e74835SSuman Ghosh seq_printf(s, "0x%x ", ntohs(rule->packet.vlan_itci));
279021e74835SSuman Ghosh seq_printf(s, "mask 0x%x\n",
279121e74835SSuman Ghosh ntohs(rule->mask.vlan_itci));
279221e74835SSuman Ghosh break;
27934d6beb9cSSubbaraya Sundeep case NPC_TOS:
27944d6beb9cSSubbaraya Sundeep seq_printf(s, "%d ", rule->packet.tos);
27954d6beb9cSSubbaraya Sundeep seq_printf(s, "mask 0x%x\n", rule->mask.tos);
27964d6beb9cSSubbaraya Sundeep break;
27974d6beb9cSSubbaraya Sundeep case NPC_SIP_IPV4:
27984d6beb9cSSubbaraya Sundeep seq_printf(s, "%pI4 ", &rule->packet.ip4src);
27994d6beb9cSSubbaraya Sundeep seq_printf(s, "mask %pI4\n", &rule->mask.ip4src);
28004d6beb9cSSubbaraya Sundeep break;
28014d6beb9cSSubbaraya Sundeep case NPC_DIP_IPV4:
28024d6beb9cSSubbaraya Sundeep seq_printf(s, "%pI4 ", &rule->packet.ip4dst);
28034d6beb9cSSubbaraya Sundeep seq_printf(s, "mask %pI4\n", &rule->mask.ip4dst);
28044d6beb9cSSubbaraya Sundeep break;
28054d6beb9cSSubbaraya Sundeep case NPC_SIP_IPV6:
28064d6beb9cSSubbaraya Sundeep seq_printf(s, "%pI6 ", rule->packet.ip6src);
28074d6beb9cSSubbaraya Sundeep seq_printf(s, "mask %pI6\n", rule->mask.ip6src);
28084d6beb9cSSubbaraya Sundeep break;
28094d6beb9cSSubbaraya Sundeep case NPC_DIP_IPV6:
28104d6beb9cSSubbaraya Sundeep seq_printf(s, "%pI6 ", rule->packet.ip6dst);
28114d6beb9cSSubbaraya Sundeep seq_printf(s, "mask %pI6\n", rule->mask.ip6dst);
28124d6beb9cSSubbaraya Sundeep break;
2813c672e372SSuman Ghosh case NPC_IPFRAG_IPV6:
2814c672e372SSuman Ghosh seq_printf(s, "0x%x ", rule->packet.next_header);
2815c672e372SSuman Ghosh seq_printf(s, "mask 0x%x\n", rule->mask.next_header);
2816c672e372SSuman Ghosh break;
2817c672e372SSuman Ghosh case NPC_IPFRAG_IPV4:
2818c672e372SSuman Ghosh seq_printf(s, "0x%x ", rule->packet.ip_flag);
2819c672e372SSuman Ghosh seq_printf(s, "mask 0x%x\n", rule->mask.ip_flag);
2820c672e372SSuman Ghosh break;
28214d6beb9cSSubbaraya Sundeep case NPC_SPORT_TCP:
28224d6beb9cSSubbaraya Sundeep case NPC_SPORT_UDP:
28234d6beb9cSSubbaraya Sundeep case NPC_SPORT_SCTP:
28244d6beb9cSSubbaraya Sundeep seq_printf(s, "%d ", ntohs(rule->packet.sport));
28254d6beb9cSSubbaraya Sundeep seq_printf(s, "mask 0x%x\n", ntohs(rule->mask.sport));
28264d6beb9cSSubbaraya Sundeep break;
28274d6beb9cSSubbaraya Sundeep case NPC_DPORT_TCP:
28284d6beb9cSSubbaraya Sundeep case NPC_DPORT_UDP:
28294d6beb9cSSubbaraya Sundeep case NPC_DPORT_SCTP:
28304d6beb9cSSubbaraya Sundeep seq_printf(s, "%d ", ntohs(rule->packet.dport));
28314d6beb9cSSubbaraya Sundeep seq_printf(s, "mask 0x%x\n", ntohs(rule->mask.dport));
28324d6beb9cSSubbaraya Sundeep break;
283373b4c04eSRatheesh Kannoth case NPC_IPSEC_SPI:
283473b4c04eSRatheesh Kannoth seq_printf(s, "0x%x ", ntohl(rule->packet.spi));
283573b4c04eSRatheesh Kannoth seq_printf(s, "mask 0x%x\n", ntohl(rule->mask.spi));
283673b4c04eSRatheesh Kannoth break;
28374d6beb9cSSubbaraya Sundeep default:
2838b7cf9661SNaveen Mamindlapalli seq_puts(s, "\n");
28394d6beb9cSSubbaraya Sundeep break;
28404d6beb9cSSubbaraya Sundeep }
28414d6beb9cSSubbaraya Sundeep }
28424d6beb9cSSubbaraya Sundeep }
28434d6beb9cSSubbaraya Sundeep
rvu_dbg_npc_mcam_show_action(struct seq_file * s,struct rvu_npc_mcam_rule * rule)28444d6beb9cSSubbaraya Sundeep static void rvu_dbg_npc_mcam_show_action(struct seq_file *s,
28454d6beb9cSSubbaraya Sundeep struct rvu_npc_mcam_rule *rule)
28464d6beb9cSSubbaraya Sundeep {
2847cb7a6b3bSSubbaraya Sundeep if (is_npc_intf_tx(rule->intf)) {
28484d6beb9cSSubbaraya Sundeep switch (rule->tx_action.op) {
28494d6beb9cSSubbaraya Sundeep case NIX_TX_ACTIONOP_DROP:
28504d6beb9cSSubbaraya Sundeep seq_puts(s, "\taction: Drop\n");
28514d6beb9cSSubbaraya Sundeep break;
28524d6beb9cSSubbaraya Sundeep case NIX_TX_ACTIONOP_UCAST_DEFAULT:
28534d6beb9cSSubbaraya Sundeep seq_puts(s, "\taction: Unicast to default channel\n");
28544d6beb9cSSubbaraya Sundeep break;
28554d6beb9cSSubbaraya Sundeep case NIX_TX_ACTIONOP_UCAST_CHAN:
28564d6beb9cSSubbaraya Sundeep seq_printf(s, "\taction: Unicast to channel %d\n",
28574d6beb9cSSubbaraya Sundeep rule->tx_action.index);
28584d6beb9cSSubbaraya Sundeep break;
28594d6beb9cSSubbaraya Sundeep case NIX_TX_ACTIONOP_MCAST:
28604d6beb9cSSubbaraya Sundeep seq_puts(s, "\taction: Multicast\n");
28614d6beb9cSSubbaraya Sundeep break;
28624d6beb9cSSubbaraya Sundeep case NIX_TX_ACTIONOP_DROP_VIOL:
28634d6beb9cSSubbaraya Sundeep seq_puts(s, "\taction: Lockdown Violation Drop\n");
28644d6beb9cSSubbaraya Sundeep break;
28654d6beb9cSSubbaraya Sundeep default:
28664d6beb9cSSubbaraya Sundeep break;
2867fc6f89ddSXu Wang }
28684d6beb9cSSubbaraya Sundeep } else {
28694d6beb9cSSubbaraya Sundeep switch (rule->rx_action.op) {
28704d6beb9cSSubbaraya Sundeep case NIX_RX_ACTIONOP_DROP:
28714d6beb9cSSubbaraya Sundeep seq_puts(s, "\taction: Drop\n");
28724d6beb9cSSubbaraya Sundeep break;
28734d6beb9cSSubbaraya Sundeep case NIX_RX_ACTIONOP_UCAST:
28744d6beb9cSSubbaraya Sundeep seq_printf(s, "\taction: Direct to queue %d\n",
28754d6beb9cSSubbaraya Sundeep rule->rx_action.index);
28764d6beb9cSSubbaraya Sundeep break;
28774d6beb9cSSubbaraya Sundeep case NIX_RX_ACTIONOP_RSS:
28784d6beb9cSSubbaraya Sundeep seq_puts(s, "\taction: RSS\n");
28794d6beb9cSSubbaraya Sundeep break;
28804d6beb9cSSubbaraya Sundeep case NIX_RX_ACTIONOP_UCAST_IPSEC:
28814d6beb9cSSubbaraya Sundeep seq_puts(s, "\taction: Unicast ipsec\n");
28824d6beb9cSSubbaraya Sundeep break;
28834d6beb9cSSubbaraya Sundeep case NIX_RX_ACTIONOP_MCAST:
28844d6beb9cSSubbaraya Sundeep seq_puts(s, "\taction: Multicast\n");
28854d6beb9cSSubbaraya Sundeep break;
28864d6beb9cSSubbaraya Sundeep default:
28874d6beb9cSSubbaraya Sundeep break;
2888fc6f89ddSXu Wang }
28894d6beb9cSSubbaraya Sundeep }
28904d6beb9cSSubbaraya Sundeep }
28914d6beb9cSSubbaraya Sundeep
rvu_dbg_get_intf_name(int intf)28924d6beb9cSSubbaraya Sundeep static const char *rvu_dbg_get_intf_name(int intf)
28934d6beb9cSSubbaraya Sundeep {
28944d6beb9cSSubbaraya Sundeep switch (intf) {
28954d6beb9cSSubbaraya Sundeep case NIX_INTFX_RX(0):
28964d6beb9cSSubbaraya Sundeep return "NIX0_RX";
28974d6beb9cSSubbaraya Sundeep case NIX_INTFX_RX(1):
28984d6beb9cSSubbaraya Sundeep return "NIX1_RX";
28994d6beb9cSSubbaraya Sundeep case NIX_INTFX_TX(0):
29004d6beb9cSSubbaraya Sundeep return "NIX0_TX";
29014d6beb9cSSubbaraya Sundeep case NIX_INTFX_TX(1):
29024d6beb9cSSubbaraya Sundeep return "NIX1_TX";
29034d6beb9cSSubbaraya Sundeep default:
29044d6beb9cSSubbaraya Sundeep break;
29054d6beb9cSSubbaraya Sundeep }
29064d6beb9cSSubbaraya Sundeep
29074d6beb9cSSubbaraya Sundeep return "unknown";
29084d6beb9cSSubbaraya Sundeep }
29094d6beb9cSSubbaraya Sundeep
rvu_dbg_npc_mcam_show_rules(struct seq_file * s,void * unused)29104d6beb9cSSubbaraya Sundeep static int rvu_dbg_npc_mcam_show_rules(struct seq_file *s, void *unused)
29114d6beb9cSSubbaraya Sundeep {
29124d6beb9cSSubbaraya Sundeep struct rvu_npc_mcam_rule *iter;
29134d6beb9cSSubbaraya Sundeep struct rvu *rvu = s->private;
29144d6beb9cSSubbaraya Sundeep struct npc_mcam *mcam;
29154d6beb9cSSubbaraya Sundeep int pf, vf = -1;
2916967db352SNaveen Mamindlapalli bool enabled;
29174d6beb9cSSubbaraya Sundeep int blkaddr;
29184d6beb9cSSubbaraya Sundeep u16 target;
29194d6beb9cSSubbaraya Sundeep u64 hits;
29204d6beb9cSSubbaraya Sundeep
29214d6beb9cSSubbaraya Sundeep blkaddr = rvu_get_blkaddr(rvu, BLKTYPE_NPC, 0);
29224d6beb9cSSubbaraya Sundeep if (blkaddr < 0)
29234d6beb9cSSubbaraya Sundeep return 0;
29244d6beb9cSSubbaraya Sundeep
29254d6beb9cSSubbaraya Sundeep mcam = &rvu->hw->mcam;
29264d6beb9cSSubbaraya Sundeep
29274d6beb9cSSubbaraya Sundeep mutex_lock(&mcam->lock);
29284d6beb9cSSubbaraya Sundeep list_for_each_entry(iter, &mcam->mcam_rules, list) {
29294d6beb9cSSubbaraya Sundeep pf = (iter->owner >> RVU_PFVF_PF_SHIFT) & RVU_PFVF_PF_MASK;
29304d6beb9cSSubbaraya Sundeep seq_printf(s, "\n\tInstalled by: PF%d ", pf);
29314d6beb9cSSubbaraya Sundeep
29324d6beb9cSSubbaraya Sundeep if (iter->owner & RVU_PFVF_FUNC_MASK) {
29334d6beb9cSSubbaraya Sundeep vf = (iter->owner & RVU_PFVF_FUNC_MASK) - 1;
29344d6beb9cSSubbaraya Sundeep seq_printf(s, "VF%d", vf);
29354d6beb9cSSubbaraya Sundeep }
29364d6beb9cSSubbaraya Sundeep seq_puts(s, "\n");
29374d6beb9cSSubbaraya Sundeep
29384d6beb9cSSubbaraya Sundeep seq_printf(s, "\tdirection: %s\n", is_npc_intf_rx(iter->intf) ?
29394d6beb9cSSubbaraya Sundeep "RX" : "TX");
29404d6beb9cSSubbaraya Sundeep seq_printf(s, "\tinterface: %s\n",
29414d6beb9cSSubbaraya Sundeep rvu_dbg_get_intf_name(iter->intf));
29424d6beb9cSSubbaraya Sundeep seq_printf(s, "\tmcam entry: %d\n", iter->entry);
29434d6beb9cSSubbaraya Sundeep
29444d6beb9cSSubbaraya Sundeep rvu_dbg_npc_mcam_show_flows(s, iter);
294563f925dcSNaveen Mamindlapalli if (is_npc_intf_rx(iter->intf)) {
29464d6beb9cSSubbaraya Sundeep target = iter->rx_action.pf_func;
29474d6beb9cSSubbaraya Sundeep pf = (target >> RVU_PFVF_PF_SHIFT) & RVU_PFVF_PF_MASK;
29484d6beb9cSSubbaraya Sundeep seq_printf(s, "\tForward to: PF%d ", pf);
29494d6beb9cSSubbaraya Sundeep
29504d6beb9cSSubbaraya Sundeep if (target & RVU_PFVF_FUNC_MASK) {
29514d6beb9cSSubbaraya Sundeep vf = (target & RVU_PFVF_FUNC_MASK) - 1;
29524d6beb9cSSubbaraya Sundeep seq_printf(s, "VF%d", vf);
29534d6beb9cSSubbaraya Sundeep }
29544d6beb9cSSubbaraya Sundeep seq_puts(s, "\n");
29559716a40aSRakesh Babu seq_printf(s, "\tchannel: 0x%x\n", iter->chan);
29569716a40aSRakesh Babu seq_printf(s, "\tchannel_mask: 0x%x\n", iter->chan_mask);
29574d6beb9cSSubbaraya Sundeep }
29584d6beb9cSSubbaraya Sundeep
29594d6beb9cSSubbaraya Sundeep rvu_dbg_npc_mcam_show_action(s, iter);
2960967db352SNaveen Mamindlapalli
2961967db352SNaveen Mamindlapalli enabled = is_mcam_entry_enabled(rvu, mcam, blkaddr, iter->entry);
2962967db352SNaveen Mamindlapalli seq_printf(s, "\tenabled: %s\n", enabled ? "yes" : "no");
29634d6beb9cSSubbaraya Sundeep
29644d6beb9cSSubbaraya Sundeep if (!iter->has_cntr)
29654d6beb9cSSubbaraya Sundeep continue;
29664d6beb9cSSubbaraya Sundeep seq_printf(s, "\tcounter: %d\n", iter->cntr);
29674d6beb9cSSubbaraya Sundeep
29684d6beb9cSSubbaraya Sundeep hits = rvu_read64(rvu, blkaddr, NPC_AF_MATCH_STATX(iter->cntr));
29694d6beb9cSSubbaraya Sundeep seq_printf(s, "\thits: %lld\n", hits);
29704d6beb9cSSubbaraya Sundeep }
29714d6beb9cSSubbaraya Sundeep mutex_unlock(&mcam->lock);
29724d6beb9cSSubbaraya Sundeep
29734d6beb9cSSubbaraya Sundeep return 0;
29744d6beb9cSSubbaraya Sundeep }
29754d6beb9cSSubbaraya Sundeep
29764d6beb9cSSubbaraya Sundeep RVU_DEBUG_SEQ_FOPS(npc_mcam_rules, npc_mcam_show_rules, NULL);
29774d6beb9cSSubbaraya Sundeep
rvu_dbg_npc_exact_show_entries(struct seq_file * s,void * unused)297887e4ea29SRatheesh Kannoth static int rvu_dbg_npc_exact_show_entries(struct seq_file *s, void *unused)
297987e4ea29SRatheesh Kannoth {
298087e4ea29SRatheesh Kannoth struct npc_exact_table_entry *mem_entry[NPC_EXACT_TBL_MAX_WAYS] = { 0 };
298187e4ea29SRatheesh Kannoth struct npc_exact_table_entry *cam_entry;
298287e4ea29SRatheesh Kannoth struct npc_exact_table *table;
298387e4ea29SRatheesh Kannoth struct rvu *rvu = s->private;
298487e4ea29SRatheesh Kannoth int i, j;
298587e4ea29SRatheesh Kannoth
298687e4ea29SRatheesh Kannoth u8 bitmap = 0;
298787e4ea29SRatheesh Kannoth
298887e4ea29SRatheesh Kannoth table = rvu->hw->table;
298987e4ea29SRatheesh Kannoth
299087e4ea29SRatheesh Kannoth mutex_lock(&table->lock);
299187e4ea29SRatheesh Kannoth
299287e4ea29SRatheesh Kannoth /* Check if there is at least one entry in mem table */
299387e4ea29SRatheesh Kannoth if (!table->mem_tbl_entry_cnt)
299487e4ea29SRatheesh Kannoth goto dump_cam_table;
299587e4ea29SRatheesh Kannoth
299687e4ea29SRatheesh Kannoth /* Print table headers */
299787e4ea29SRatheesh Kannoth seq_puts(s, "\n\tExact Match MEM Table\n");
299887e4ea29SRatheesh Kannoth seq_puts(s, "Index\t");
299987e4ea29SRatheesh Kannoth
300087e4ea29SRatheesh Kannoth for (i = 0; i < table->mem_table.ways; i++) {
300187e4ea29SRatheesh Kannoth mem_entry[i] = list_first_entry_or_null(&table->lhead_mem_tbl_entry[i],
300287e4ea29SRatheesh Kannoth struct npc_exact_table_entry, list);
300387e4ea29SRatheesh Kannoth
300487e4ea29SRatheesh Kannoth seq_printf(s, "Way-%d\t\t\t\t\t", i);
300587e4ea29SRatheesh Kannoth }
300687e4ea29SRatheesh Kannoth
300787e4ea29SRatheesh Kannoth seq_puts(s, "\n");
300887e4ea29SRatheesh Kannoth for (i = 0; i < table->mem_table.ways; i++)
300987e4ea29SRatheesh Kannoth seq_puts(s, "\tChan MAC \t");
301087e4ea29SRatheesh Kannoth
301187e4ea29SRatheesh Kannoth seq_puts(s, "\n\n");
301287e4ea29SRatheesh Kannoth
301387e4ea29SRatheesh Kannoth /* Print mem table entries */
301487e4ea29SRatheesh Kannoth for (i = 0; i < table->mem_table.depth; i++) {
301587e4ea29SRatheesh Kannoth bitmap = 0;
301687e4ea29SRatheesh Kannoth for (j = 0; j < table->mem_table.ways; j++) {
301787e4ea29SRatheesh Kannoth if (!mem_entry[j])
301887e4ea29SRatheesh Kannoth continue;
301987e4ea29SRatheesh Kannoth
302087e4ea29SRatheesh Kannoth if (mem_entry[j]->index != i)
302187e4ea29SRatheesh Kannoth continue;
302287e4ea29SRatheesh Kannoth
302387e4ea29SRatheesh Kannoth bitmap |= BIT(j);
302487e4ea29SRatheesh Kannoth }
302587e4ea29SRatheesh Kannoth
302687e4ea29SRatheesh Kannoth /* No valid entries */
302787e4ea29SRatheesh Kannoth if (!bitmap)
302887e4ea29SRatheesh Kannoth continue;
302987e4ea29SRatheesh Kannoth
303087e4ea29SRatheesh Kannoth seq_printf(s, "%d\t", i);
303187e4ea29SRatheesh Kannoth for (j = 0; j < table->mem_table.ways; j++) {
303287e4ea29SRatheesh Kannoth if (!(bitmap & BIT(j))) {
303387e4ea29SRatheesh Kannoth seq_puts(s, "nil\t\t\t\t\t");
303487e4ea29SRatheesh Kannoth continue;
303587e4ea29SRatheesh Kannoth }
303687e4ea29SRatheesh Kannoth
303787e4ea29SRatheesh Kannoth seq_printf(s, "0x%x %pM\t\t\t", mem_entry[j]->chan,
303887e4ea29SRatheesh Kannoth mem_entry[j]->mac);
303987e4ea29SRatheesh Kannoth mem_entry[j] = list_next_entry(mem_entry[j], list);
304087e4ea29SRatheesh Kannoth }
304187e4ea29SRatheesh Kannoth seq_puts(s, "\n");
304287e4ea29SRatheesh Kannoth }
304387e4ea29SRatheesh Kannoth
304487e4ea29SRatheesh Kannoth dump_cam_table:
304587e4ea29SRatheesh Kannoth
304687e4ea29SRatheesh Kannoth if (!table->cam_tbl_entry_cnt)
304787e4ea29SRatheesh Kannoth goto done;
304887e4ea29SRatheesh Kannoth
304987e4ea29SRatheesh Kannoth seq_puts(s, "\n\tExact Match CAM Table\n");
305087e4ea29SRatheesh Kannoth seq_puts(s, "index\tchan\tMAC\n");
305187e4ea29SRatheesh Kannoth
305287e4ea29SRatheesh Kannoth /* Traverse cam table entries */
305387e4ea29SRatheesh Kannoth list_for_each_entry(cam_entry, &table->lhead_cam_tbl_entry, list) {
305487e4ea29SRatheesh Kannoth seq_printf(s, "%d\t0x%x\t%pM\n", cam_entry->index, cam_entry->chan,
305587e4ea29SRatheesh Kannoth cam_entry->mac);
305687e4ea29SRatheesh Kannoth }
305787e4ea29SRatheesh Kannoth
305887e4ea29SRatheesh Kannoth done:
305987e4ea29SRatheesh Kannoth mutex_unlock(&table->lock);
306087e4ea29SRatheesh Kannoth return 0;
306187e4ea29SRatheesh Kannoth }
306287e4ea29SRatheesh Kannoth
306387e4ea29SRatheesh Kannoth RVU_DEBUG_SEQ_FOPS(npc_exact_entries, npc_exact_show_entries, NULL);
306487e4ea29SRatheesh Kannoth
rvu_dbg_npc_exact_show_info(struct seq_file * s,void * unused)306587e4ea29SRatheesh Kannoth static int rvu_dbg_npc_exact_show_info(struct seq_file *s, void *unused)
306687e4ea29SRatheesh Kannoth {
306787e4ea29SRatheesh Kannoth struct npc_exact_table *table;
306887e4ea29SRatheesh Kannoth struct rvu *rvu = s->private;
306987e4ea29SRatheesh Kannoth int i;
307087e4ea29SRatheesh Kannoth
307187e4ea29SRatheesh Kannoth table = rvu->hw->table;
307287e4ea29SRatheesh Kannoth
307387e4ea29SRatheesh Kannoth seq_puts(s, "\n\tExact Table Info\n");
307487e4ea29SRatheesh Kannoth seq_printf(s, "Exact Match Feature : %s\n",
307587e4ea29SRatheesh Kannoth rvu->hw->cap.npc_exact_match_enabled ? "enabled" : "disable");
307687e4ea29SRatheesh Kannoth if (!rvu->hw->cap.npc_exact_match_enabled)
307787e4ea29SRatheesh Kannoth return 0;
307887e4ea29SRatheesh Kannoth
307987e4ea29SRatheesh Kannoth seq_puts(s, "\nMCAM Index\tMAC Filter Rules Count\n");
308087e4ea29SRatheesh Kannoth for (i = 0; i < table->num_drop_rules; i++)
308187e4ea29SRatheesh Kannoth seq_printf(s, "%d\t\t%d\n", i, table->cnt_cmd_rules[i]);
308287e4ea29SRatheesh Kannoth
308387e4ea29SRatheesh Kannoth seq_puts(s, "\nMcam Index\tPromisc Mode Status\n");
308487e4ea29SRatheesh Kannoth for (i = 0; i < table->num_drop_rules; i++)
308587e4ea29SRatheesh Kannoth seq_printf(s, "%d\t\t%s\n", i, table->promisc_mode[i] ? "on" : "off");
308687e4ea29SRatheesh Kannoth
308787e4ea29SRatheesh Kannoth seq_puts(s, "\n\tMEM Table Info\n");
308887e4ea29SRatheesh Kannoth seq_printf(s, "Ways : %d\n", table->mem_table.ways);
308987e4ea29SRatheesh Kannoth seq_printf(s, "Depth : %d\n", table->mem_table.depth);
309087e4ea29SRatheesh Kannoth seq_printf(s, "Mask : 0x%llx\n", table->mem_table.mask);
309187e4ea29SRatheesh Kannoth seq_printf(s, "Hash Mask : 0x%x\n", table->mem_table.hash_mask);
309287e4ea29SRatheesh Kannoth seq_printf(s, "Hash Offset : 0x%x\n", table->mem_table.hash_offset);
309387e4ea29SRatheesh Kannoth
309487e4ea29SRatheesh Kannoth seq_puts(s, "\n\tCAM Table Info\n");
309587e4ea29SRatheesh Kannoth seq_printf(s, "Depth : %d\n", table->cam_table.depth);
309687e4ea29SRatheesh Kannoth
309787e4ea29SRatheesh Kannoth return 0;
309887e4ea29SRatheesh Kannoth }
309987e4ea29SRatheesh Kannoth
310087e4ea29SRatheesh Kannoth RVU_DEBUG_SEQ_FOPS(npc_exact_info, npc_exact_show_info, NULL);
310187e4ea29SRatheesh Kannoth
rvu_dbg_npc_exact_drop_cnt(struct seq_file * s,void * unused)310287e4ea29SRatheesh Kannoth static int rvu_dbg_npc_exact_drop_cnt(struct seq_file *s, void *unused)
310387e4ea29SRatheesh Kannoth {
310487e4ea29SRatheesh Kannoth struct npc_exact_table *table;
310587e4ea29SRatheesh Kannoth struct rvu *rvu = s->private;
310687e4ea29SRatheesh Kannoth struct npc_key_field *field;
310787e4ea29SRatheesh Kannoth u16 chan, pcifunc;
310887e4ea29SRatheesh Kannoth int blkaddr, i;
310987e4ea29SRatheesh Kannoth u64 cfg, cam1;
311087e4ea29SRatheesh Kannoth char *str;
311187e4ea29SRatheesh Kannoth
311287e4ea29SRatheesh Kannoth blkaddr = rvu_get_blkaddr(rvu, BLKTYPE_NPC, 0);
311387e4ea29SRatheesh Kannoth table = rvu->hw->table;
311487e4ea29SRatheesh Kannoth
311587e4ea29SRatheesh Kannoth field = &rvu->hw->mcam.rx_key_fields[NPC_CHAN];
311687e4ea29SRatheesh Kannoth
311787e4ea29SRatheesh Kannoth seq_puts(s, "\n\t Exact Hit on drop status\n");
311887e4ea29SRatheesh Kannoth seq_puts(s, "\npcifunc\tmcam_idx\tHits\tchan\tstatus\n");
311987e4ea29SRatheesh Kannoth
312087e4ea29SRatheesh Kannoth for (i = 0; i < table->num_drop_rules; i++) {
312187e4ea29SRatheesh Kannoth pcifunc = rvu_npc_exact_drop_rule_to_pcifunc(rvu, i);
312287e4ea29SRatheesh Kannoth cfg = rvu_read64(rvu, blkaddr, NPC_AF_MCAMEX_BANKX_CFG(i, 0));
312387e4ea29SRatheesh Kannoth
312487e4ea29SRatheesh Kannoth /* channel will be always in keyword 0 */
312587e4ea29SRatheesh Kannoth cam1 = rvu_read64(rvu, blkaddr,
312687e4ea29SRatheesh Kannoth NPC_AF_MCAMEX_BANKX_CAMX_W0(i, 0, 1));
312787e4ea29SRatheesh Kannoth chan = field->kw_mask[0] & cam1;
312887e4ea29SRatheesh Kannoth
312987e4ea29SRatheesh Kannoth str = (cfg & 1) ? "enabled" : "disabled";
313087e4ea29SRatheesh Kannoth
313187e4ea29SRatheesh Kannoth seq_printf(s, "0x%x\t%d\t\t%llu\t0x%x\t%s\n", pcifunc, i,
313287e4ea29SRatheesh Kannoth rvu_read64(rvu, blkaddr,
313387e4ea29SRatheesh Kannoth NPC_AF_MATCH_STATX(table->counter_idx[i])),
313487e4ea29SRatheesh Kannoth chan, str);
313587e4ea29SRatheesh Kannoth }
313687e4ea29SRatheesh Kannoth
313787e4ea29SRatheesh Kannoth return 0;
313887e4ea29SRatheesh Kannoth }
313987e4ea29SRatheesh Kannoth
314087e4ea29SRatheesh Kannoth RVU_DEBUG_SEQ_FOPS(npc_exact_drop_cnt, npc_exact_drop_cnt, NULL);
314187e4ea29SRatheesh Kannoth
rvu_dbg_npc_init(struct rvu * rvu)3142e07fb507SSunil Goutham static void rvu_dbg_npc_init(struct rvu *rvu)
3143e07fb507SSunil Goutham {
3144e07fb507SSunil Goutham rvu->rvu_dbg.npc = debugfs_create_dir("npc", rvu->rvu_dbg.root);
3145e07fb507SSunil Goutham
31462ce5a307SDan Carpenter debugfs_create_file("mcam_info", 0444, rvu->rvu_dbg.npc, rvu,
31472ce5a307SDan Carpenter &rvu_dbg_npc_mcam_info_fops);
31482ce5a307SDan Carpenter debugfs_create_file("mcam_rules", 0444, rvu->rvu_dbg.npc, rvu,
31492ce5a307SDan Carpenter &rvu_dbg_npc_mcam_rules_fops);
315087e4ea29SRatheesh Kannoth
31512ce5a307SDan Carpenter debugfs_create_file("rx_miss_act_stats", 0444, rvu->rvu_dbg.npc, rvu,
31522ce5a307SDan Carpenter &rvu_dbg_npc_rx_miss_act_fops);
315387e4ea29SRatheesh Kannoth
315487e4ea29SRatheesh Kannoth if (!rvu->hw->cap.npc_exact_match_enabled)
315587e4ea29SRatheesh Kannoth return;
315687e4ea29SRatheesh Kannoth
315787e4ea29SRatheesh Kannoth debugfs_create_file("exact_entries", 0444, rvu->rvu_dbg.npc, rvu,
315887e4ea29SRatheesh Kannoth &rvu_dbg_npc_exact_entries_fops);
315987e4ea29SRatheesh Kannoth
316087e4ea29SRatheesh Kannoth debugfs_create_file("exact_info", 0444, rvu->rvu_dbg.npc, rvu,
316187e4ea29SRatheesh Kannoth &rvu_dbg_npc_exact_info_fops);
316287e4ea29SRatheesh Kannoth
316387e4ea29SRatheesh Kannoth debugfs_create_file("exact_drop_cnt", 0444, rvu->rvu_dbg.npc, rvu,
316487e4ea29SRatheesh Kannoth &rvu_dbg_npc_exact_drop_cnt_fops);
316587e4ea29SRatheesh Kannoth
3166e07fb507SSunil Goutham }
3167e07fb507SSunil Goutham
cpt_eng_sts_display(struct seq_file * filp,u8 eng_type)316876638a2eSSrujana Challa static int cpt_eng_sts_display(struct seq_file *filp, u8 eng_type)
316976638a2eSSrujana Challa {
3170b0f60fabSSrujana Challa struct cpt_ctx *ctx = filp->private;
317176638a2eSSrujana Challa u64 busy_sts = 0, free_sts = 0;
317276638a2eSSrujana Challa u32 e_min = 0, e_max = 0, e, i;
317376638a2eSSrujana Challa u16 max_ses, max_ies, max_aes;
3174b0f60fabSSrujana Challa struct rvu *rvu = ctx->rvu;
3175b0f60fabSSrujana Challa int blkaddr = ctx->blkaddr;
317676638a2eSSrujana Challa u64 reg;
317776638a2eSSrujana Challa
317876638a2eSSrujana Challa reg = rvu_read64(rvu, blkaddr, CPT_AF_CONSTANTS1);
317976638a2eSSrujana Challa max_ses = reg & 0xffff;
318076638a2eSSrujana Challa max_ies = (reg >> 16) & 0xffff;
318176638a2eSSrujana Challa max_aes = (reg >> 32) & 0xffff;
318276638a2eSSrujana Challa
318376638a2eSSrujana Challa switch (eng_type) {
318476638a2eSSrujana Challa case CPT_AE_TYPE:
318576638a2eSSrujana Challa e_min = max_ses + max_ies;
318676638a2eSSrujana Challa e_max = max_ses + max_ies + max_aes;
318776638a2eSSrujana Challa break;
318876638a2eSSrujana Challa case CPT_SE_TYPE:
318976638a2eSSrujana Challa e_min = 0;
319076638a2eSSrujana Challa e_max = max_ses;
319176638a2eSSrujana Challa break;
319276638a2eSSrujana Challa case CPT_IE_TYPE:
319376638a2eSSrujana Challa e_min = max_ses;
319476638a2eSSrujana Challa e_max = max_ses + max_ies;
319576638a2eSSrujana Challa break;
319676638a2eSSrujana Challa default:
319776638a2eSSrujana Challa return -EINVAL;
319876638a2eSSrujana Challa }
319976638a2eSSrujana Challa
320076638a2eSSrujana Challa for (e = e_min, i = 0; e < e_max; e++, i++) {
320176638a2eSSrujana Challa reg = rvu_read64(rvu, blkaddr, CPT_AF_EXEX_STS(e));
320276638a2eSSrujana Challa if (reg & 0x1)
320376638a2eSSrujana Challa busy_sts |= 1ULL << i;
320476638a2eSSrujana Challa
320576638a2eSSrujana Challa if (reg & 0x2)
320676638a2eSSrujana Challa free_sts |= 1ULL << i;
320776638a2eSSrujana Challa }
320876638a2eSSrujana Challa seq_printf(filp, "FREE STS : 0x%016llx\n", free_sts);
320976638a2eSSrujana Challa seq_printf(filp, "BUSY STS : 0x%016llx\n", busy_sts);
321076638a2eSSrujana Challa
321176638a2eSSrujana Challa return 0;
321276638a2eSSrujana Challa }
321376638a2eSSrujana Challa
rvu_dbg_cpt_ae_sts_display(struct seq_file * filp,void * unused)321476638a2eSSrujana Challa static int rvu_dbg_cpt_ae_sts_display(struct seq_file *filp, void *unused)
321576638a2eSSrujana Challa {
321676638a2eSSrujana Challa return cpt_eng_sts_display(filp, CPT_AE_TYPE);
321776638a2eSSrujana Challa }
321876638a2eSSrujana Challa
321976638a2eSSrujana Challa RVU_DEBUG_SEQ_FOPS(cpt_ae_sts, cpt_ae_sts_display, NULL);
322076638a2eSSrujana Challa
rvu_dbg_cpt_se_sts_display(struct seq_file * filp,void * unused)322176638a2eSSrujana Challa static int rvu_dbg_cpt_se_sts_display(struct seq_file *filp, void *unused)
322276638a2eSSrujana Challa {
322376638a2eSSrujana Challa return cpt_eng_sts_display(filp, CPT_SE_TYPE);
322476638a2eSSrujana Challa }
322576638a2eSSrujana Challa
322676638a2eSSrujana Challa RVU_DEBUG_SEQ_FOPS(cpt_se_sts, cpt_se_sts_display, NULL);
322776638a2eSSrujana Challa
rvu_dbg_cpt_ie_sts_display(struct seq_file * filp,void * unused)322876638a2eSSrujana Challa static int rvu_dbg_cpt_ie_sts_display(struct seq_file *filp, void *unused)
322976638a2eSSrujana Challa {
323076638a2eSSrujana Challa return cpt_eng_sts_display(filp, CPT_IE_TYPE);
323176638a2eSSrujana Challa }
323276638a2eSSrujana Challa
323376638a2eSSrujana Challa RVU_DEBUG_SEQ_FOPS(cpt_ie_sts, cpt_ie_sts_display, NULL);
323476638a2eSSrujana Challa
rvu_dbg_cpt_engines_info_display(struct seq_file * filp,void * unused)323576638a2eSSrujana Challa static int rvu_dbg_cpt_engines_info_display(struct seq_file *filp, void *unused)
323676638a2eSSrujana Challa {
3237b0f60fabSSrujana Challa struct cpt_ctx *ctx = filp->private;
323876638a2eSSrujana Challa u16 max_ses, max_ies, max_aes;
3239b0f60fabSSrujana Challa struct rvu *rvu = ctx->rvu;
3240b0f60fabSSrujana Challa int blkaddr = ctx->blkaddr;
324176638a2eSSrujana Challa u32 e_max, e;
324276638a2eSSrujana Challa u64 reg;
324376638a2eSSrujana Challa
324476638a2eSSrujana Challa reg = rvu_read64(rvu, blkaddr, CPT_AF_CONSTANTS1);
324576638a2eSSrujana Challa max_ses = reg & 0xffff;
324676638a2eSSrujana Challa max_ies = (reg >> 16) & 0xffff;
324776638a2eSSrujana Challa max_aes = (reg >> 32) & 0xffff;
324876638a2eSSrujana Challa
324976638a2eSSrujana Challa e_max = max_ses + max_ies + max_aes;
325076638a2eSSrujana Challa
325176638a2eSSrujana Challa seq_puts(filp, "===========================================\n");
325276638a2eSSrujana Challa for (e = 0; e < e_max; e++) {
325376638a2eSSrujana Challa reg = rvu_read64(rvu, blkaddr, CPT_AF_EXEX_CTL2(e));
325476638a2eSSrujana Challa seq_printf(filp, "CPT Engine[%u] Group Enable 0x%02llx\n", e,
325576638a2eSSrujana Challa reg & 0xff);
325676638a2eSSrujana Challa reg = rvu_read64(rvu, blkaddr, CPT_AF_EXEX_ACTIVE(e));
325776638a2eSSrujana Challa seq_printf(filp, "CPT Engine[%u] Active Info 0x%llx\n", e,
325876638a2eSSrujana Challa reg);
325976638a2eSSrujana Challa reg = rvu_read64(rvu, blkaddr, CPT_AF_EXEX_CTL(e));
326076638a2eSSrujana Challa seq_printf(filp, "CPT Engine[%u] Control 0x%llx\n", e,
326176638a2eSSrujana Challa reg);
326276638a2eSSrujana Challa seq_puts(filp, "===========================================\n");
326376638a2eSSrujana Challa }
326476638a2eSSrujana Challa return 0;
326576638a2eSSrujana Challa }
326676638a2eSSrujana Challa
326776638a2eSSrujana Challa RVU_DEBUG_SEQ_FOPS(cpt_engines_info, cpt_engines_info_display, NULL);
326876638a2eSSrujana Challa
rvu_dbg_cpt_lfs_info_display(struct seq_file * filp,void * unused)326976638a2eSSrujana Challa static int rvu_dbg_cpt_lfs_info_display(struct seq_file *filp, void *unused)
327076638a2eSSrujana Challa {
3271b0f60fabSSrujana Challa struct cpt_ctx *ctx = filp->private;
3272b0f60fabSSrujana Challa int blkaddr = ctx->blkaddr;
3273b0f60fabSSrujana Challa struct rvu *rvu = ctx->rvu;
327476638a2eSSrujana Challa struct rvu_block *block;
3275b0f60fabSSrujana Challa struct rvu_hwinfo *hw;
327676638a2eSSrujana Challa u64 reg;
327776638a2eSSrujana Challa u32 lf;
327876638a2eSSrujana Challa
3279b0f60fabSSrujana Challa hw = rvu->hw;
328076638a2eSSrujana Challa block = &hw->block[blkaddr];
328176638a2eSSrujana Challa if (!block->lf.bmap)
328276638a2eSSrujana Challa return -ENODEV;
328376638a2eSSrujana Challa
328476638a2eSSrujana Challa seq_puts(filp, "===========================================\n");
328576638a2eSSrujana Challa for (lf = 0; lf < block->lf.max; lf++) {
328676638a2eSSrujana Challa reg = rvu_read64(rvu, blkaddr, CPT_AF_LFX_CTL(lf));
328776638a2eSSrujana Challa seq_printf(filp, "CPT Lf[%u] CTL 0x%llx\n", lf, reg);
328876638a2eSSrujana Challa reg = rvu_read64(rvu, blkaddr, CPT_AF_LFX_CTL2(lf));
328976638a2eSSrujana Challa seq_printf(filp, "CPT Lf[%u] CTL2 0x%llx\n", lf, reg);
329076638a2eSSrujana Challa reg = rvu_read64(rvu, blkaddr, CPT_AF_LFX_PTR_CTL(lf));
329176638a2eSSrujana Challa seq_printf(filp, "CPT Lf[%u] PTR_CTL 0x%llx\n", lf, reg);
329276638a2eSSrujana Challa reg = rvu_read64(rvu, blkaddr, block->lfcfg_reg |
329376638a2eSSrujana Challa (lf << block->lfshift));
329476638a2eSSrujana Challa seq_printf(filp, "CPT Lf[%u] CFG 0x%llx\n", lf, reg);
329576638a2eSSrujana Challa seq_puts(filp, "===========================================\n");
329676638a2eSSrujana Challa }
329776638a2eSSrujana Challa return 0;
329876638a2eSSrujana Challa }
329976638a2eSSrujana Challa
330076638a2eSSrujana Challa RVU_DEBUG_SEQ_FOPS(cpt_lfs_info, cpt_lfs_info_display, NULL);
330176638a2eSSrujana Challa
rvu_dbg_cpt_err_info_display(struct seq_file * filp,void * unused)330276638a2eSSrujana Challa static int rvu_dbg_cpt_err_info_display(struct seq_file *filp, void *unused)
330376638a2eSSrujana Challa {
3304b0f60fabSSrujana Challa struct cpt_ctx *ctx = filp->private;
3305b0f60fabSSrujana Challa struct rvu *rvu = ctx->rvu;
3306b0f60fabSSrujana Challa int blkaddr = ctx->blkaddr;
330776638a2eSSrujana Challa u64 reg0, reg1;
330876638a2eSSrujana Challa
330976638a2eSSrujana Challa reg0 = rvu_read64(rvu, blkaddr, CPT_AF_FLTX_INT(0));
331076638a2eSSrujana Challa reg1 = rvu_read64(rvu, blkaddr, CPT_AF_FLTX_INT(1));
331176638a2eSSrujana Challa seq_printf(filp, "CPT_AF_FLTX_INT: 0x%llx 0x%llx\n", reg0, reg1);
331276638a2eSSrujana Challa reg0 = rvu_read64(rvu, blkaddr, CPT_AF_PSNX_EXE(0));
331376638a2eSSrujana Challa reg1 = rvu_read64(rvu, blkaddr, CPT_AF_PSNX_EXE(1));
331476638a2eSSrujana Challa seq_printf(filp, "CPT_AF_PSNX_EXE: 0x%llx 0x%llx\n", reg0, reg1);
331576638a2eSSrujana Challa reg0 = rvu_read64(rvu, blkaddr, CPT_AF_PSNX_LF(0));
331676638a2eSSrujana Challa seq_printf(filp, "CPT_AF_PSNX_LF: 0x%llx\n", reg0);
331776638a2eSSrujana Challa reg0 = rvu_read64(rvu, blkaddr, CPT_AF_RVU_INT);
331876638a2eSSrujana Challa seq_printf(filp, "CPT_AF_RVU_INT: 0x%llx\n", reg0);
331976638a2eSSrujana Challa reg0 = rvu_read64(rvu, blkaddr, CPT_AF_RAS_INT);
332076638a2eSSrujana Challa seq_printf(filp, "CPT_AF_RAS_INT: 0x%llx\n", reg0);
332176638a2eSSrujana Challa reg0 = rvu_read64(rvu, blkaddr, CPT_AF_EXE_ERR_INFO);
332276638a2eSSrujana Challa seq_printf(filp, "CPT_AF_EXE_ERR_INFO: 0x%llx\n", reg0);
332376638a2eSSrujana Challa
332476638a2eSSrujana Challa return 0;
332576638a2eSSrujana Challa }
332676638a2eSSrujana Challa
332776638a2eSSrujana Challa RVU_DEBUG_SEQ_FOPS(cpt_err_info, cpt_err_info_display, NULL);
332876638a2eSSrujana Challa
rvu_dbg_cpt_pc_display(struct seq_file * filp,void * unused)332976638a2eSSrujana Challa static int rvu_dbg_cpt_pc_display(struct seq_file *filp, void *unused)
333076638a2eSSrujana Challa {
3331b0f60fabSSrujana Challa struct cpt_ctx *ctx = filp->private;
3332b0f60fabSSrujana Challa struct rvu *rvu = ctx->rvu;
3333b0f60fabSSrujana Challa int blkaddr = ctx->blkaddr;
333476638a2eSSrujana Challa u64 reg;
333576638a2eSSrujana Challa
333676638a2eSSrujana Challa reg = rvu_read64(rvu, blkaddr, CPT_AF_INST_REQ_PC);
333776638a2eSSrujana Challa seq_printf(filp, "CPT instruction requests %llu\n", reg);
333876638a2eSSrujana Challa reg = rvu_read64(rvu, blkaddr, CPT_AF_INST_LATENCY_PC);
333976638a2eSSrujana Challa seq_printf(filp, "CPT instruction latency %llu\n", reg);
334076638a2eSSrujana Challa reg = rvu_read64(rvu, blkaddr, CPT_AF_RD_REQ_PC);
334176638a2eSSrujana Challa seq_printf(filp, "CPT NCB read requests %llu\n", reg);
334276638a2eSSrujana Challa reg = rvu_read64(rvu, blkaddr, CPT_AF_RD_LATENCY_PC);
334376638a2eSSrujana Challa seq_printf(filp, "CPT NCB read latency %llu\n", reg);
334476638a2eSSrujana Challa reg = rvu_read64(rvu, blkaddr, CPT_AF_RD_UC_PC);
334576638a2eSSrujana Challa seq_printf(filp, "CPT read requests caused by UC fills %llu\n", reg);
334676638a2eSSrujana Challa reg = rvu_read64(rvu, blkaddr, CPT_AF_ACTIVE_CYCLES_PC);
334776638a2eSSrujana Challa seq_printf(filp, "CPT active cycles pc %llu\n", reg);
334876638a2eSSrujana Challa reg = rvu_read64(rvu, blkaddr, CPT_AF_CPTCLK_CNT);
334976638a2eSSrujana Challa seq_printf(filp, "CPT clock count pc %llu\n", reg);
335076638a2eSSrujana Challa
335176638a2eSSrujana Challa return 0;
335276638a2eSSrujana Challa }
335376638a2eSSrujana Challa
335476638a2eSSrujana Challa RVU_DEBUG_SEQ_FOPS(cpt_pc, cpt_pc_display, NULL);
335576638a2eSSrujana Challa
rvu_dbg_cpt_init(struct rvu * rvu,int blkaddr)3356b0f60fabSSrujana Challa static void rvu_dbg_cpt_init(struct rvu *rvu, int blkaddr)
335776638a2eSSrujana Challa {
3358b0f60fabSSrujana Challa struct cpt_ctx *ctx;
3359b0f60fabSSrujana Challa
3360b0f60fabSSrujana Challa if (!is_block_implemented(rvu->hw, blkaddr))
336176638a2eSSrujana Challa return;
336276638a2eSSrujana Challa
3363b0f60fabSSrujana Challa if (blkaddr == BLKADDR_CPT0) {
336476638a2eSSrujana Challa rvu->rvu_dbg.cpt = debugfs_create_dir("cpt", rvu->rvu_dbg.root);
3365b0f60fabSSrujana Challa ctx = &rvu->rvu_dbg.cpt_ctx[0];
3366b0f60fabSSrujana Challa ctx->blkaddr = BLKADDR_CPT0;
3367b0f60fabSSrujana Challa ctx->rvu = rvu;
3368b0f60fabSSrujana Challa } else {
3369b0f60fabSSrujana Challa rvu->rvu_dbg.cpt = debugfs_create_dir("cpt1",
3370b0f60fabSSrujana Challa rvu->rvu_dbg.root);
3371b0f60fabSSrujana Challa ctx = &rvu->rvu_dbg.cpt_ctx[1];
3372b0f60fabSSrujana Challa ctx->blkaddr = BLKADDR_CPT1;
3373b0f60fabSSrujana Challa ctx->rvu = rvu;
3374b0f60fabSSrujana Challa }
337576638a2eSSrujana Challa
3376b0f60fabSSrujana Challa debugfs_create_file("cpt_pc", 0600, rvu->rvu_dbg.cpt, ctx,
337776638a2eSSrujana Challa &rvu_dbg_cpt_pc_fops);
3378b0f60fabSSrujana Challa debugfs_create_file("cpt_ae_sts", 0600, rvu->rvu_dbg.cpt, ctx,
337976638a2eSSrujana Challa &rvu_dbg_cpt_ae_sts_fops);
3380b0f60fabSSrujana Challa debugfs_create_file("cpt_se_sts", 0600, rvu->rvu_dbg.cpt, ctx,
338176638a2eSSrujana Challa &rvu_dbg_cpt_se_sts_fops);
3382b0f60fabSSrujana Challa debugfs_create_file("cpt_ie_sts", 0600, rvu->rvu_dbg.cpt, ctx,
338376638a2eSSrujana Challa &rvu_dbg_cpt_ie_sts_fops);
3384b0f60fabSSrujana Challa debugfs_create_file("cpt_engines_info", 0600, rvu->rvu_dbg.cpt, ctx,
338576638a2eSSrujana Challa &rvu_dbg_cpt_engines_info_fops);
3386b0f60fabSSrujana Challa debugfs_create_file("cpt_lfs_info", 0600, rvu->rvu_dbg.cpt, ctx,
338776638a2eSSrujana Challa &rvu_dbg_cpt_lfs_info_fops);
3388b0f60fabSSrujana Challa debugfs_create_file("cpt_err_info", 0600, rvu->rvu_dbg.cpt, ctx,
338976638a2eSSrujana Challa &rvu_dbg_cpt_err_info_fops);
339076638a2eSSrujana Challa }
339176638a2eSSrujana Challa
rvu_get_dbg_dir_name(struct rvu * rvu)33923feac505SGeetha sowjanya static const char *rvu_get_dbg_dir_name(struct rvu *rvu)
33933feac505SGeetha sowjanya {
33943feac505SGeetha sowjanya if (!is_rvu_otx2(rvu))
33953feac505SGeetha sowjanya return "cn10k";
33963feac505SGeetha sowjanya else
33973feac505SGeetha sowjanya return "octeontx2";
33983feac505SGeetha sowjanya }
33993feac505SGeetha sowjanya
rvu_dbg_init(struct rvu * rvu)340023205e6dSChristina Jacob void rvu_dbg_init(struct rvu *rvu)
340123205e6dSChristina Jacob {
34023feac505SGeetha sowjanya rvu->rvu_dbg.root = debugfs_create_dir(rvu_get_dbg_dir_name(rvu), NULL);
340323205e6dSChristina Jacob
34042ce5a307SDan Carpenter debugfs_create_file("rsrc_alloc", 0444, rvu->rvu_dbg.root, rvu,
34052ce5a307SDan Carpenter &rvu_dbg_rsrc_status_fops);
3406e2fb3730SRakesh Babu
34070daa55d0SHarman Kalra if (!is_rvu_otx2(rvu))
34080daa55d0SHarman Kalra debugfs_create_file("lmtst_map_table", 0444, rvu->rvu_dbg.root,
34090daa55d0SHarman Kalra rvu, &rvu_dbg_lmtst_map_table_fops);
34100daa55d0SHarman Kalra
341191c6945eSHariprasad Kelam if (!cgx_get_cgxcnt_max())
341291c6945eSHariprasad Kelam goto create;
341391c6945eSHariprasad Kelam
341491c6945eSHariprasad Kelam if (is_rvu_otx2(rvu))
341591c6945eSHariprasad Kelam debugfs_create_file("rvu_pf_cgx_map", 0444, rvu->rvu_dbg.root,
341691c6945eSHariprasad Kelam rvu, &rvu_dbg_rvu_pf_cgx_map_fops);
341791c6945eSHariprasad Kelam else
3418786621d2SGeetha sowjanya debugfs_create_file("rvu_pf_rpm_map", 0444, rvu->rvu_dbg.root,
341991c6945eSHariprasad Kelam rvu, &rvu_dbg_rvu_pf_cgx_map_fops);
342091c6945eSHariprasad Kelam
342191c6945eSHariprasad Kelam create:
34228756828aSChristina Jacob rvu_dbg_npa_init(rvu);
34230f3ce484SRakesh Babu rvu_dbg_nix_init(rvu, BLKADDR_NIX0);
34240f3ce484SRakesh Babu
34250f3ce484SRakesh Babu rvu_dbg_nix_init(rvu, BLKADDR_NIX1);
3426c57211b5SPrakash Brahmajyosyula rvu_dbg_cgx_init(rvu);
3427e07fb507SSunil Goutham rvu_dbg_npc_init(rvu);
3428b0f60fabSSrujana Challa rvu_dbg_cpt_init(rvu, BLKADDR_CPT0);
3429b0f60fabSSrujana Challa rvu_dbg_cpt_init(rvu, BLKADDR_CPT1);
3430d06c2abaSGeetha sowjanya rvu_dbg_mcs_init(rvu);
343123205e6dSChristina Jacob }
343223205e6dSChristina Jacob
rvu_dbg_exit(struct rvu * rvu)343323205e6dSChristina Jacob void rvu_dbg_exit(struct rvu *rvu)
343423205e6dSChristina Jacob {
343523205e6dSChristina Jacob debugfs_remove_recursive(rvu->rvu_dbg.root);
343623205e6dSChristina Jacob }
343723205e6dSChristina Jacob
343823205e6dSChristina Jacob #endif /* CONFIG_DEBUG_FS */
3439