1 /*-
2 * Broadcom NetXtreme-C/E network driver.
3 *
4 * Copyright (c) 2016 Broadcom, All Rights Reserved.
5 * The term Broadcom refers to Broadcom Limited and/or its subsidiaries
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS'
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
26 * THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29 #include <sys/types.h>
30 #include <sys/sysctl.h>
31 #include <sys/ctype.h>
32 #include <linux/delay.h>
33
34 #include "bnxt.h"
35 #include "bnxt_hwrm.h"
36 #include "bnxt_sysctl.h"
37
38 DEFINE_MUTEX(tmp_mutex); /* mutex lock for driver */
39 extern void bnxt_fw_reset(struct bnxt_softc *bp);
40 extern void bnxt_queue_sp_work(struct bnxt_softc *bp);
41 extern void
42 process_nq(struct bnxt_softc *softc, uint16_t nqid);
43 /*
44 * We want to create:
45 * dev.bnxt.0.hwstats.txq0
46 * dev.bnxt.0.hwstats.txq0.txmbufs
47 * dev.bnxt.0.hwstats.rxq0
48 * dev.bnxt.0.hwstats.txq0.rxmbufs
49 * so the hwstats ctx list needs to be created in attach_post and populated
50 * during init.
51 *
52 * Then, it needs to be cleaned up in stop.
53 */
54
55 int
bnxt_init_sysctl_ctx(struct bnxt_softc * softc)56 bnxt_init_sysctl_ctx(struct bnxt_softc *softc)
57 {
58 struct sysctl_ctx_list *ctx;
59
60 sysctl_ctx_init(&softc->hw_stats);
61 ctx = device_get_sysctl_ctx(softc->dev);
62 softc->hw_stats_oid = SYSCTL_ADD_NODE(ctx,
63 SYSCTL_CHILDREN(device_get_sysctl_tree(softc->dev)), OID_AUTO,
64 "hwstats", CTLFLAG_RD | CTLFLAG_MPSAFE, 0, "hardware statistics");
65 if (!softc->hw_stats_oid) {
66 sysctl_ctx_free(&softc->hw_stats);
67 return ENOMEM;
68 }
69
70 sysctl_ctx_init(&softc->ver_info->ver_ctx);
71 ctx = device_get_sysctl_ctx(softc->dev);
72 softc->ver_info->ver_oid = SYSCTL_ADD_NODE(ctx,
73 SYSCTL_CHILDREN(device_get_sysctl_tree(softc->dev)), OID_AUTO,
74 "ver", CTLFLAG_RD | CTLFLAG_MPSAFE, 0,
75 "hardware/firmware version information");
76 if (!softc->ver_info->ver_oid) {
77 sysctl_ctx_free(&softc->ver_info->ver_ctx);
78 return ENOMEM;
79 }
80
81 if (BNXT_PF(softc)) {
82 sysctl_ctx_init(&softc->nvm_info->nvm_ctx);
83 ctx = device_get_sysctl_ctx(softc->dev);
84 softc->nvm_info->nvm_oid = SYSCTL_ADD_NODE(ctx,
85 SYSCTL_CHILDREN(device_get_sysctl_tree(softc->dev)), OID_AUTO,
86 "nvram", CTLFLAG_RD | CTLFLAG_MPSAFE, 0,
87 "nvram information");
88 if (!softc->nvm_info->nvm_oid) {
89 sysctl_ctx_free(&softc->nvm_info->nvm_ctx);
90 return ENOMEM;
91 }
92 }
93
94 sysctl_ctx_init(&softc->hw_lro_ctx);
95 ctx = device_get_sysctl_ctx(softc->dev);
96 softc->hw_lro_oid = SYSCTL_ADD_NODE(ctx,
97 SYSCTL_CHILDREN(device_get_sysctl_tree(softc->dev)), OID_AUTO,
98 "hw_lro", CTLFLAG_RD | CTLFLAG_MPSAFE, 0, "hardware lro");
99 if (!softc->hw_lro_oid) {
100 sysctl_ctx_free(&softc->hw_lro_ctx);
101 return ENOMEM;
102 }
103
104 sysctl_ctx_init(&softc->flow_ctrl_ctx);
105 ctx = device_get_sysctl_ctx(softc->dev);
106 softc->flow_ctrl_oid = SYSCTL_ADD_NODE(ctx,
107 SYSCTL_CHILDREN(device_get_sysctl_tree(softc->dev)), OID_AUTO,
108 "fc", CTLFLAG_RD | CTLFLAG_MPSAFE, 0, "flow ctrl");
109 if (!softc->flow_ctrl_oid) {
110 sysctl_ctx_free(&softc->flow_ctrl_ctx);
111 return ENOMEM;
112 }
113
114 sysctl_ctx_init(&softc->dcb_ctx);
115 ctx = device_get_sysctl_ctx(softc->dev);
116 softc->dcb_oid = SYSCTL_ADD_NODE(ctx,
117 SYSCTL_CHILDREN(device_get_sysctl_tree(softc->dev)), OID_AUTO,
118 "dcb", CTLFLAG_RD | CTLFLAG_MPSAFE, 0, "dcb");
119 if (!softc->dcb_oid) {
120 sysctl_ctx_free(&softc->dcb_ctx);
121 return ENOMEM;
122 }
123
124 return 0;
125 }
126
127 int
bnxt_free_sysctl_ctx(struct bnxt_softc * softc)128 bnxt_free_sysctl_ctx(struct bnxt_softc *softc)
129 {
130 int orc;
131 int rc = 0;
132
133 if (softc->hw_stats_oid != NULL) {
134 orc = sysctl_ctx_free(&softc->hw_stats);
135 if (orc)
136 rc = orc;
137 else
138 softc->hw_stats_oid = NULL;
139 }
140 if (softc->ver_info->ver_oid != NULL) {
141 orc = sysctl_ctx_free(&softc->ver_info->ver_ctx);
142 if (orc)
143 rc = orc;
144 else
145 softc->ver_info->ver_oid = NULL;
146 }
147 if (BNXT_PF(softc) && softc->nvm_info->nvm_oid != NULL) {
148 orc = sysctl_ctx_free(&softc->nvm_info->nvm_ctx);
149 if (orc)
150 rc = orc;
151 else
152 softc->nvm_info->nvm_oid = NULL;
153 }
154 if (softc->hw_lro_oid != NULL) {
155 orc = sysctl_ctx_free(&softc->hw_lro_ctx);
156 if (orc)
157 rc = orc;
158 else
159 softc->hw_lro_oid = NULL;
160 }
161
162 if (softc->flow_ctrl_oid != NULL) {
163 orc = sysctl_ctx_free(&softc->flow_ctrl_ctx);
164 if (orc)
165 rc = orc;
166 else
167 softc->flow_ctrl_oid = NULL;
168 }
169
170 if (softc->dcb_oid != NULL) {
171 orc = sysctl_ctx_free(&softc->dcb_ctx);
172 if (orc)
173 rc = orc;
174 else
175 softc->dcb_oid = NULL;
176 }
177
178 return rc;
179 }
180
181 int
bnxt_create_tx_sysctls(struct bnxt_softc * softc,int txr)182 bnxt_create_tx_sysctls(struct bnxt_softc *softc, int txr)
183 {
184 struct sysctl_oid *oid;
185 struct ctx_hw_stats *tx_stats = (void *)softc->tx_stats[txr].idi_vaddr;
186 char name[32];
187 char desc[64];
188
189 sprintf(name, "txq%d", txr);
190 sprintf(desc, "transmit queue %d", txr);
191 oid = SYSCTL_ADD_NODE(&softc->hw_stats,
192 SYSCTL_CHILDREN(softc->hw_stats_oid), OID_AUTO, name,
193 CTLFLAG_RD | CTLFLAG_MPSAFE, 0, desc);
194 if (!oid)
195 return ENOMEM;
196
197 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
198 "ucast_pkts", CTLFLAG_RD, &tx_stats->tx_ucast_pkts,
199 "unicast packets sent");
200 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
201 "mcast_pkts", CTLFLAG_RD, &tx_stats->tx_mcast_pkts,
202 "multicast packets sent");
203 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
204 "bcast_pkts", CTLFLAG_RD, &tx_stats->tx_bcast_pkts,
205 "broadcast packets sent");
206 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
207 "discard_pkts", CTLFLAG_RD,
208 &tx_stats->tx_discard_pkts, "discarded transmit packets");
209 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
210 "error_pkts", CTLFLAG_RD, &tx_stats->tx_error_pkts,
211 "Error transmit packets");
212 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
213 "ucast_bytes", CTLFLAG_RD, &tx_stats->tx_ucast_bytes,
214 "unicast bytes sent");
215 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
216 "mcast_bytes", CTLFLAG_RD, &tx_stats->tx_mcast_bytes,
217 "multicast bytes sent");
218 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
219 "bcast_bytes", CTLFLAG_RD, &tx_stats->tx_bcast_bytes,
220 "broadcast bytes sent");
221
222 return 0;
223 }
224
225 int
bnxt_create_port_stats_sysctls(struct bnxt_softc * softc)226 bnxt_create_port_stats_sysctls(struct bnxt_softc *softc)
227 {
228 struct sysctl_oid *oid;
229 char name[32];
230 char desc[64];
231
232 sprintf(name, "port_stats");
233 sprintf(desc, "Port Stats");
234 oid = SYSCTL_ADD_NODE(&softc->hw_stats,
235 SYSCTL_CHILDREN(softc->hw_stats_oid), OID_AUTO, name,
236 CTLFLAG_RD | CTLFLAG_MPSAFE, 0, desc);
237 if (!oid)
238 return ENOMEM;
239
240 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
241 "tx_64b_frames", CTLFLAG_RD,
242 &softc->tx_port_stats->tx_64b_frames, "Transmitted 64b frames");
243 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
244 "tx_65b_127b_frames", CTLFLAG_RD,
245 &softc->tx_port_stats->tx_65b_127b_frames,
246 "Transmitted 65b 127b frames");
247 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
248 "tx_128b_255b_frames", CTLFLAG_RD,
249 &softc->tx_port_stats->tx_128b_255b_frames,
250 "Transmitted 128b 255b frames");
251 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
252 "tx_256b_511b_frames", CTLFLAG_RD,
253 &softc->tx_port_stats->tx_256b_511b_frames,
254 "Transmitted 256b 511b frames");
255 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
256 "tx_512b_1023b_frames", CTLFLAG_RD,
257 &softc->tx_port_stats->tx_512b_1023b_frames,
258 "Transmitted 512b 1023b frames");
259 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
260 "tx_1024b_1518b_frames", CTLFLAG_RD,
261 &softc->tx_port_stats->tx_1024b_1518b_frames,
262 "Transmitted 1024b 1518b frames");
263 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
264 "tx_good_vlan_frames", CTLFLAG_RD,
265 &softc->tx_port_stats->tx_good_vlan_frames,
266 "Transmitted good vlan frames");
267 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
268 "tx_1519b_2047b_frames", CTLFLAG_RD,
269 &softc->tx_port_stats->tx_1519b_2047b_frames,
270 "Transmitted 1519b 2047b frames");
271 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
272 "tx_2048b_4095b_frames", CTLFLAG_RD,
273 &softc->tx_port_stats->tx_2048b_4095b_frames,
274 "Transmitted 2048b 4095b frames");
275 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
276 "tx_4096b_9216b_frames", CTLFLAG_RD,
277 &softc->tx_port_stats->tx_4096b_9216b_frames,
278 "Transmitted 4096b 9216b frames");
279 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
280 "tx_9217b_16383b_frames", CTLFLAG_RD,
281 &softc->tx_port_stats->tx_9217b_16383b_frames,
282 "Transmitted 9217b 16383b frames");
283 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
284 "tx_good_frames", CTLFLAG_RD,
285 &softc->tx_port_stats->tx_good_frames, "Transmitted good frames");
286 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
287 "tx_total_frames", CTLFLAG_RD,
288 &softc->tx_port_stats->tx_total_frames, "Transmitted total frames");
289 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
290 "tx_ucast_frames", CTLFLAG_RD,
291 &softc->tx_port_stats->tx_ucast_frames, "Transmitted ucast frames");
292 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
293 "tx_mcast_frames", CTLFLAG_RD,
294 &softc->tx_port_stats->tx_mcast_frames, "Transmitted mcast frames");
295 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
296 "tx_bcast_frames", CTLFLAG_RD,
297 &softc->tx_port_stats->tx_bcast_frames, "Transmitted bcast frames");
298 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
299 "tx_pause_frames", CTLFLAG_RD,
300 &softc->tx_port_stats->tx_pause_frames, "Transmitted pause frames");
301 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
302 "tx_pfc_frames", CTLFLAG_RD,
303 &softc->tx_port_stats->tx_pfc_frames, "Transmitted pfc frames");
304 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
305 "tx_jabber_frames", CTLFLAG_RD,
306 &softc->tx_port_stats->tx_jabber_frames, "Transmitted jabber frames");
307 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
308 "tx_fcs_err_frames", CTLFLAG_RD,
309 &softc->tx_port_stats->tx_fcs_err_frames,
310 "Transmitted fcs err frames");
311 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
312 "tx_err", CTLFLAG_RD,
313 &softc->tx_port_stats->tx_err, "Transmitted err");
314 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
315 "tx_fifo_underruns", CTLFLAG_RD,
316 &softc->tx_port_stats->tx_fifo_underruns,
317 "Transmitted fifo underruns");
318 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
319 "tx_pfc_ena_frames_pri0", CTLFLAG_RD,
320 &softc->tx_port_stats->tx_pfc_ena_frames_pri0,
321 "Transmitted pfc ena frames pri0");
322 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
323 "tx_pfc_ena_frames_pri1", CTLFLAG_RD,
324 &softc->tx_port_stats->tx_pfc_ena_frames_pri1,
325 "Transmitted pfc ena frames pri1");
326 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
327 "tx_pfc_ena_frames_pri2", CTLFLAG_RD,
328 &softc->tx_port_stats->tx_pfc_ena_frames_pri2,
329 "Transmitted pfc ena frames pri2");
330 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
331 "tx_pfc_ena_frames_pri3", CTLFLAG_RD,
332 &softc->tx_port_stats->tx_pfc_ena_frames_pri3,
333 "Transmitted pfc ena frames pri3");
334 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
335 "tx_pfc_ena_frames_pri4", CTLFLAG_RD,
336 &softc->tx_port_stats->tx_pfc_ena_frames_pri4,
337 "Transmitted pfc ena frames pri4");
338 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
339 "tx_pfc_ena_frames_pri5", CTLFLAG_RD,
340 &softc->tx_port_stats->tx_pfc_ena_frames_pri5,
341 "Transmitted pfc ena frames pri5");
342 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
343 "tx_pfc_ena_frames_pri6", CTLFLAG_RD,
344 &softc->tx_port_stats->tx_pfc_ena_frames_pri6,
345 "Transmitted pfc ena frames pri6");
346 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
347 "tx_pfc_ena_frames_pri7", CTLFLAG_RD,
348 &softc->tx_port_stats->tx_pfc_ena_frames_pri7,
349 "Transmitted pfc ena frames pri7");
350 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
351 "tx_eee_lpi_events", CTLFLAG_RD,
352 &softc->tx_port_stats->tx_eee_lpi_events,
353 "Transmitted eee lpi events");
354 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
355 "tx_eee_lpi_duration", CTLFLAG_RD,
356 &softc->tx_port_stats->tx_eee_lpi_duration,
357 "Transmitted eee lpi duration");
358 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
359 "tx_llfc_logical_msgs", CTLFLAG_RD,
360 &softc->tx_port_stats->tx_llfc_logical_msgs,
361 "Transmitted llfc logical msgs");
362 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
363 "tx_hcfc_msgs", CTLFLAG_RD,
364 &softc->tx_port_stats->tx_hcfc_msgs, "Transmitted hcfc msgs");
365 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
366 "tx_total_collisions", CTLFLAG_RD,
367 &softc->tx_port_stats->tx_total_collisions,
368 "Transmitted total collisions");
369 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
370 "tx_bytes", CTLFLAG_RD,
371 &softc->tx_port_stats->tx_bytes, "Transmitted bytes");
372 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
373 "tx_xthol_frames", CTLFLAG_RD,
374 &softc->tx_port_stats->tx_xthol_frames, "Transmitted xthol frames");
375 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
376 "tx_stat_discard", CTLFLAG_RD,
377 &softc->tx_port_stats->tx_stat_discard, "Transmitted stat discard");
378 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
379 "tx_stat_error", CTLFLAG_RD,
380 &softc->tx_port_stats->tx_stat_error, "Transmitted stat error");
381 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
382 "rx_64b_frames", CTLFLAG_RD,
383 &softc->rx_port_stats->rx_64b_frames, "Received 64b frames");
384 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
385 "rx_65b_127b_frames", CTLFLAG_RD,
386 &softc->rx_port_stats->rx_65b_127b_frames, "Received 65b 127b frames");
387 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
388 "rx_128b_255b_frames", CTLFLAG_RD,
389 &softc->rx_port_stats->rx_128b_255b_frames,
390 "Received 128b 255b frames");
391 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
392 "rx_256b_511b_frames", CTLFLAG_RD,
393 &softc->rx_port_stats->rx_256b_511b_frames,
394 "Received 256b 511b frames");
395 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
396 "rx_512b_1023b_frames", CTLFLAG_RD,
397 &softc->rx_port_stats->rx_512b_1023b_frames,
398 "Received 512b 1023b frames");
399 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
400 "rx_1024b_1518b_frames", CTLFLAG_RD,
401 &softc->rx_port_stats->rx_1024b_1518b_frames,
402 "Received 1024b 1518 frames");
403 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
404 "rx_good_vlan_frames", CTLFLAG_RD,
405 &softc->rx_port_stats->rx_good_vlan_frames,
406 "Received good vlan frames");
407 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
408 "rx_1519b_2047b_frames", CTLFLAG_RD,
409 &softc->rx_port_stats->rx_1519b_2047b_frames,
410 "Received 1519b 2047b frames");
411 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
412 "rx_2048b_4095b_frames", CTLFLAG_RD,
413 &softc->rx_port_stats->rx_2048b_4095b_frames,
414 "Received 2048b 4095b frames");
415 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
416 "rx_4096b_9216b_frames", CTLFLAG_RD,
417 &softc->rx_port_stats->rx_4096b_9216b_frames,
418 "Received 4096b 9216b frames");
419 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
420 "rx_9217b_16383b_frames", CTLFLAG_RD,
421 &softc->rx_port_stats->rx_9217b_16383b_frames,
422 "Received 9217b 16383b frames");
423 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
424 "rx_total_frames", CTLFLAG_RD,
425 &softc->rx_port_stats->rx_total_frames, "Received total frames");
426 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
427 "rx_ucast_frames", CTLFLAG_RD,
428 &softc->rx_port_stats->rx_ucast_frames, "Received ucast frames");
429 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
430 "rx_mcast_frames", CTLFLAG_RD,
431 &softc->rx_port_stats->rx_mcast_frames, "Received mcast frames");
432 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
433 "rx_bcast_frames", CTLFLAG_RD,
434 &softc->rx_port_stats->rx_bcast_frames, "Received bcast frames");
435 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
436 "rx_fcs_err_frames", CTLFLAG_RD,
437 &softc->rx_port_stats->rx_fcs_err_frames, "Received fcs err frames");
438 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
439 "rx_ctrl_frames", CTLFLAG_RD,
440 &softc->rx_port_stats->rx_ctrl_frames, "Received ctrl frames");
441 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
442 "rx_pause_frames", CTLFLAG_RD,
443 &softc->rx_port_stats->rx_pause_frames, "Received pause frames");
444 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
445 "rx_pfc_frames", CTLFLAG_RD,
446 &softc->rx_port_stats->rx_pfc_frames, "Received pfc frames");
447 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
448 "rx_align_err_frames", CTLFLAG_RD,
449 &softc->rx_port_stats->rx_align_err_frames,
450 "Received align err frames");
451 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
452 "rx_ovrsz_frames", CTLFLAG_RD,
453 &softc->rx_port_stats->rx_ovrsz_frames,
454 "Received ovrsz frames");
455 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
456 "rx_jbr_frames", CTLFLAG_RD,
457 &softc->rx_port_stats->rx_jbr_frames,
458 "Received jbr frames");
459 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
460 "rx_mtu_err_frames", CTLFLAG_RD,
461 &softc->rx_port_stats->rx_mtu_err_frames,
462 "Received mtu err frames");
463 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
464 "rx_tagged_frames", CTLFLAG_RD,
465 &softc->rx_port_stats->rx_tagged_frames,
466 "Received tagged frames");
467 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
468 "rx_double_tagged_frames", CTLFLAG_RD,
469 &softc->rx_port_stats->rx_double_tagged_frames,
470 "Received double tagged frames");
471 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
472 "rx_good_frames", CTLFLAG_RD,
473 &softc->rx_port_stats->rx_good_frames,
474 "Received good frames");
475 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
476 "rx_pfc_ena_frames_pri0", CTLFLAG_RD,
477 &softc->rx_port_stats->rx_pfc_ena_frames_pri0,
478 "Received pfc ena frames pri0");
479 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
480 "rx_pfc_ena_frames_pri1", CTLFLAG_RD,
481 &softc->rx_port_stats->rx_pfc_ena_frames_pri1,
482 "Received pfc ena frames pri1");
483 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
484 "rx_pfc_ena_frames_pri2", CTLFLAG_RD,
485 &softc->rx_port_stats->rx_pfc_ena_frames_pri2,
486 "Received pfc ena frames pri2");
487 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
488 "rx_pfc_ena_frames_pri3", CTLFLAG_RD,
489 &softc->rx_port_stats->rx_pfc_ena_frames_pri3,
490 "Received pfc ena frames pri3");
491 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
492 "rx_pfc_ena_frames_pri4", CTLFLAG_RD,
493 &softc->rx_port_stats->rx_pfc_ena_frames_pri4,
494 "Received pfc ena frames pri4");
495 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
496 "rx_pfc_ena_frames_pri5", CTLFLAG_RD,
497 &softc->rx_port_stats->rx_pfc_ena_frames_pri5,
498 "Received pfc ena frames pri5");
499 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
500 "rx_pfc_ena_frames_pri6", CTLFLAG_RD,
501 &softc->rx_port_stats->rx_pfc_ena_frames_pri6,
502 "Received pfc ena frames pri6");
503 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
504 "rx_pfc_ena_frames_pri7", CTLFLAG_RD,
505 &softc->rx_port_stats->rx_pfc_ena_frames_pri7,
506 "Received pfc ena frames pri7");
507 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
508 "rx_sch_crc_err_frames", CTLFLAG_RD,
509 &softc->rx_port_stats->rx_sch_crc_err_frames,
510 "Received sch crc err frames");
511 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
512 "rx_undrsz_frames", CTLFLAG_RD,
513 &softc->rx_port_stats->rx_undrsz_frames, "Received undrsz frames");
514 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
515 "rx_eee_lpi_events", CTLFLAG_RD,
516 &softc->rx_port_stats->rx_eee_lpi_events, "Received eee lpi events");
517 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
518 "rx_eee_lpi_duration", CTLFLAG_RD,
519 &softc->rx_port_stats->rx_eee_lpi_duration,
520 "Received eee lpi duration");
521 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
522 "rx_llfc_physical_msgs", CTLFLAG_RD,
523 &softc->rx_port_stats->rx_llfc_physical_msgs,
524 "Received llfc physical msgs");
525 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
526 "rx_llfc_logical_msgs", CTLFLAG_RD,
527 &softc->rx_port_stats->rx_llfc_logical_msgs,
528 "Received llfc logical msgs");
529 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
530 "rx_llfc_msgs_with_crc_err", CTLFLAG_RD,
531 &softc->rx_port_stats->rx_llfc_msgs_with_crc_err,
532 "Received llfc msgs with crc err");
533 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
534 "rx_hcfc_msgs", CTLFLAG_RD,
535 &softc->rx_port_stats->rx_hcfc_msgs, "Received hcfc msgs");
536 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
537 "rx_hcfc_msgs_with_crc_err", CTLFLAG_RD,
538 &softc->rx_port_stats->rx_hcfc_msgs_with_crc_err,
539 "Received hcfc msgs with crc err");
540 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
541 "rx_bytes", CTLFLAG_RD,
542 &softc->rx_port_stats->rx_bytes, "Received bytes");
543 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
544 "rx_runt_bytes", CTLFLAG_RD,
545 &softc->rx_port_stats->rx_runt_bytes, "Received runt bytes");
546 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
547 "rx_runt_frames", CTLFLAG_RD,
548 &softc->rx_port_stats->rx_runt_frames, "Received runt frames");
549 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
550 "rx_stat_discard", CTLFLAG_RD,
551 &softc->rx_port_stats->rx_stat_discard, "Received stat discard");
552 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
553 "rx_stat_err", CTLFLAG_RD,
554 &softc->rx_port_stats->rx_stat_err, "Received stat err");
555
556 if (BNXT_CHIP_P5(softc) &&
557 (softc->flags & BNXT_FLAG_FW_CAP_EXT_STATS)) {
558 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
559 "tx_bytes_cos0", CTLFLAG_RD,
560 &softc->tx_port_stats_ext->tx_bytes_cos0, "Transmitted bytes count cos0");
561 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
562 "tx_packets_cos0", CTLFLAG_RD,
563 &softc->tx_port_stats_ext->tx_packets_cos0, "Transmitted packets count cos0");
564 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
565 "tx_bytes_cos1", CTLFLAG_RD,
566 &softc->tx_port_stats_ext->tx_bytes_cos1, "Transmitted bytes count cos1");
567 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
568 "tx_packets_cos1", CTLFLAG_RD,
569 &softc->tx_port_stats_ext->tx_packets_cos1, "Transmitted packets count cos1");
570 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
571 "tx_bytes_cos2", CTLFLAG_RD,
572 &softc->tx_port_stats_ext->tx_bytes_cos2, "Transmitted bytes count cos2");
573 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
574 "tx_packets_cos2", CTLFLAG_RD,
575 &softc->tx_port_stats_ext->tx_packets_cos2, "Transmitted packets count cos2");
576 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
577 "tx_bytes_cos3", CTLFLAG_RD,
578 &softc->tx_port_stats_ext->tx_bytes_cos3, "Transmitted bytes count cos3");
579 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
580 "tx_packets_cos3", CTLFLAG_RD,
581 &softc->tx_port_stats_ext->tx_packets_cos3, "Transmitted packets count cos3");
582 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
583 "tx_bytes_cos4", CTLFLAG_RD,
584 &softc->tx_port_stats_ext->tx_bytes_cos4, "Transmitted bytes count cos4");
585 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
586 "tx_packets_cos4", CTLFLAG_RD,
587 &softc->tx_port_stats_ext->tx_packets_cos4, "Transmitted packets count cos4");
588 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
589 "tx_bytes_cos5", CTLFLAG_RD,
590 &softc->tx_port_stats_ext->tx_bytes_cos5, "Transmitted bytes count cos5");
591 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
592 "tx_packets_cos5", CTLFLAG_RD,
593 &softc->tx_port_stats_ext->tx_packets_cos5, "Transmitted packets count cos5");
594 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
595 "tx_bytes_cos6", CTLFLAG_RD,
596 &softc->tx_port_stats_ext->tx_bytes_cos6, "Transmitted bytes count cos6");
597 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
598 "tx_packets_cos6", CTLFLAG_RD,
599 &softc->tx_port_stats_ext->tx_packets_cos6, "Transmitted packets count cos6");
600 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
601 "tx_bytes_cos7", CTLFLAG_RD,
602 &softc->tx_port_stats_ext->tx_bytes_cos7, "Transmitted bytes count cos7");
603 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
604 "tx_packets_cos7", CTLFLAG_RD,
605 &softc->tx_port_stats_ext->tx_packets_cos7, "Transmitted packets count cos7");
606
607 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
608 "tx_bytes_pri0", CTLFLAG_RD,
609 &softc->tx_bytes_pri[0], "Transmitted bytes count pri0");
610 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
611 "tx_packets_pri0", CTLFLAG_RD,
612 &softc->tx_packets_pri[0], "Transmitted packets count pri0");
613 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
614 "tx_bytes_pri1", CTLFLAG_RD,
615 &softc->tx_bytes_pri[1], "Transmitted bytes count pri1");
616 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
617 "tx_packets_pri1", CTLFLAG_RD,
618 &softc->tx_packets_pri[1], "Transmitted packets count pri1");
619 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
620 "tx_bytes_pri2", CTLFLAG_RD,
621 &softc->tx_bytes_pri[2], "Transmitted bytes count pri2");
622 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
623 "tx_packets_pri2", CTLFLAG_RD,
624 &softc->tx_packets_pri[2], "Transmitted packets count pri2");
625 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
626 "tx_bytes_pri3", CTLFLAG_RD,
627 &softc->tx_bytes_pri[3], "Transmitted bytes count pri3");
628 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
629 "tx_packets_pri3", CTLFLAG_RD,
630 &softc->tx_packets_pri[3], "Transmitted packets count pri3");
631 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
632 "tx_bytes_pri4", CTLFLAG_RD,
633 &softc->tx_bytes_pri[4], "Transmitted bytes count pri4");
634 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
635 "tx_packets_pri4", CTLFLAG_RD,
636 &softc->tx_packets_pri[4], "Transmitted packets count pri4");
637 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
638 "tx_bytes_pri5", CTLFLAG_RD,
639 &softc->tx_bytes_pri[5], "Transmitted bytes count pri5");
640 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
641 "tx_packets_pri5", CTLFLAG_RD,
642 &softc->tx_packets_pri[5], "Transmitted packets count pri5");
643 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
644 "tx_bytes_pri6", CTLFLAG_RD,
645 &softc->tx_bytes_pri[6], "Transmitted bytes count pri6");
646 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
647 "tx_packets_pri6", CTLFLAG_RD,
648 &softc->tx_packets_pri[6], "Transmitted packets count pri6");
649 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
650 "tx_bytes_pri7", CTLFLAG_RD,
651 &softc->tx_bytes_pri[7], "Transmitted bytes count pri7");
652 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
653 "tx_packets_pri7", CTLFLAG_RD,
654 &softc->tx_packets_pri[7], "Transmitted packets count pri7");
655
656 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
657 "pfc_pri0_tx_duration_us", CTLFLAG_RD,
658 &softc->tx_port_stats_ext->pfc_pri0_tx_duration_us, "Time duration between"
659 "XON to XOFF and XOFF to XON for pri0");
660 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
661 "pfc_pri0_tx_transitions", CTLFLAG_RD,
662 &softc->tx_port_stats_ext->pfc_pri0_tx_transitions, "Num times transition"
663 "between XON to XOFF and XOFF to XON for pri0");
664 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
665 "pfc_pri1_tx_duration_us", CTLFLAG_RD,
666 &softc->tx_port_stats_ext->pfc_pri1_tx_duration_us, "Time duration between"
667 "XON to XOFF and XOFF to XON for pri1");
668 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
669 "pfc_pri1_tx_transitions", CTLFLAG_RD,
670 &softc->tx_port_stats_ext->pfc_pri1_tx_transitions, "Num times transition"
671 "between XON to XOFF and XOFF to XON for pri1");
672 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
673 "pfc_pri2_tx_duration_us", CTLFLAG_RD,
674 &softc->tx_port_stats_ext->pfc_pri2_tx_duration_us, "Time duration between"
675 "XON to XOFF and XOFF to XON for pri2");
676 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
677 "pfc_pri2_tx_transitions", CTLFLAG_RD,
678 &softc->tx_port_stats_ext->pfc_pri2_tx_transitions, "Num times transition"
679 "between XON to XOFF and XOFF to XON for pri2");
680 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
681 "pfc_pri3_tx_duration_us", CTLFLAG_RD,
682 &softc->tx_port_stats_ext->pfc_pri3_tx_duration_us, "Time duration between"
683 "XON to XOFF and XOFF to XON for pri3");
684 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
685 "pfc_pri3_tx_transitions", CTLFLAG_RD,
686 &softc->tx_port_stats_ext->pfc_pri3_tx_transitions, "Num times transition"
687 "between XON to XOFF and XOFF to XON for pri3");
688 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
689 "pfc_pri4_tx_duration_us", CTLFLAG_RD,
690 &softc->tx_port_stats_ext->pfc_pri4_tx_duration_us, "Time duration between"
691 "XON to XOFF and XOFF to XON for pri4");
692 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
693 "pfc_pri4_tx_transitions", CTLFLAG_RD,
694 &softc->tx_port_stats_ext->pfc_pri4_tx_transitions, "Num times transition"
695 "between XON to XOFF and XOFF to XON for pri4");
696 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
697 "pfc_pri5_tx_duration_us", CTLFLAG_RD,
698 &softc->tx_port_stats_ext->pfc_pri5_tx_duration_us, "Time duration between"
699 "XON to XOFF and XOFF to XON for pri5");
700 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
701 "pfc_pri5_tx_transitions", CTLFLAG_RD,
702 &softc->tx_port_stats_ext->pfc_pri5_tx_transitions, "Num times transition"
703 "between XON to XOFF and XOFF to XON for pri5");
704 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
705 "pfc_pri6_tx_duration_us", CTLFLAG_RD,
706 &softc->tx_port_stats_ext->pfc_pri6_tx_duration_us, "Time duration between"
707 "XON to XOFF and XOFF to XON for pri6");
708 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
709 "pfc_pri6_tx_transitions", CTLFLAG_RD,
710 &softc->tx_port_stats_ext->pfc_pri6_tx_transitions, "Num times transition"
711 "between XON to XOFF and XOFF to XON for pri6");
712 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
713 "pfc_pri7_tx_duration_us", CTLFLAG_RD,
714 &softc->tx_port_stats_ext->pfc_pri7_tx_duration_us, "Time duration between"
715 "XON to XOFF and XOFF to XON for pri7");
716 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
717 "pfc_pri7_tx_transitions", CTLFLAG_RD,
718 &softc->tx_port_stats_ext->pfc_pri7_tx_transitions, "Num times transition"
719 "between XON to XOFF and XOFF to XON for pri7");
720
721 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
722 "link_down_events", CTLFLAG_RD,
723 &softc->rx_port_stats_ext->link_down_events, "Num times link states down");
724 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
725 "continuous_pause_events", CTLFLAG_RD,
726 &softc->rx_port_stats_ext->continuous_pause_events, "Num times pause events");
727 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
728 "resume_pause_events", CTLFLAG_RD,
729 &softc->rx_port_stats_ext->resume_pause_events, "Num times pause events"
730 "resumes");
731 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
732 "continuous_roce_pause_events", CTLFLAG_RD,
733 &softc->rx_port_stats_ext->continuous_roce_pause_events, "Num times roce"
734 "pause events");
735 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
736 "resume_roce_pause_events", CTLFLAG_RD,
737 &softc->rx_port_stats_ext->resume_roce_pause_events, "Num times roce pause"
738 "events resumes");
739
740 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
741 "rx_bytes_cos0", CTLFLAG_RD,
742 &softc->rx_port_stats_ext->rx_bytes_cos0, "Received bytes count cos0");
743 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
744 "rx_packets_cos0", CTLFLAG_RD,
745 &softc->rx_port_stats_ext->rx_packets_cos0, "Received packets count cos0");
746 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
747 "rx_bytes_cos1", CTLFLAG_RD,
748 &softc->rx_port_stats_ext->rx_bytes_cos1, "Received bytes count cos1");
749 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
750 "rx_packets_cos1", CTLFLAG_RD,
751 &softc->rx_port_stats_ext->rx_packets_cos1, "Received packets count cos1");
752 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
753 "rx_bytes_cos2", CTLFLAG_RD,
754 &softc->rx_port_stats_ext->rx_bytes_cos2, "Received bytes count cos2");
755 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
756 "rx_packets_cos2", CTLFLAG_RD,
757 &softc->rx_port_stats_ext->rx_packets_cos2, "Received packets count cos2");
758 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
759 "rx_bytes_cos3", CTLFLAG_RD,
760 &softc->rx_port_stats_ext->rx_bytes_cos3, "Received bytes count cos3");
761 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
762 "rx_packets_cos3", CTLFLAG_RD,
763 &softc->rx_port_stats_ext->rx_packets_cos3, "Received packets count cos3");
764 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
765 "rx_bytes_cos4", CTLFLAG_RD,
766 &softc->rx_port_stats_ext->rx_bytes_cos4, "Received bytes count cos4");
767 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
768 "rx_packets_cos4", CTLFLAG_RD,
769 &softc->rx_port_stats_ext->rx_packets_cos4, "Received packets count cos4");
770 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
771 "rx_bytes_cos5", CTLFLAG_RD,
772 &softc->rx_port_stats_ext->rx_bytes_cos5, "Received bytes count cos5");
773 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
774 "rx_packets_cos5", CTLFLAG_RD,
775 &softc->rx_port_stats_ext->rx_packets_cos5, "Received packets count cos5");
776 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
777 "rx_bytes_cos6", CTLFLAG_RD,
778 &softc->rx_port_stats_ext->rx_bytes_cos6, "Received bytes count cos6");
779 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
780 "rx_packets_cos6", CTLFLAG_RD,
781 &softc->rx_port_stats_ext->rx_packets_cos6, "Received packets count cos6");
782 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
783 "rx_bytes_cos7", CTLFLAG_RD,
784 &softc->rx_port_stats_ext->rx_bytes_cos7, "Received bytes count cos7");
785 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
786 "rx_packets_cos7", CTLFLAG_RD,
787 &softc->rx_port_stats_ext->rx_packets_cos7, "Received packets count cos7");
788
789 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
790 "rx_bytes_pri0", CTLFLAG_RD,
791 &softc->rx_bytes_pri[0], "Received bytes count pri0");
792 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
793 "rx_packets_pri0", CTLFLAG_RD,
794 &softc->rx_packets_pri[0], "Received packets count pri0");
795 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
796 "rx_bytes_pri1", CTLFLAG_RD,
797 &softc->rx_bytes_pri[1], "Received bytes count pri1");
798 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
799 "rx_packets_pri1", CTLFLAG_RD,
800 &softc->rx_packets_pri[1], "Received packets count pri1");
801 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
802 "rx_bytes_pri2", CTLFLAG_RD,
803 &softc->rx_bytes_pri[2], "Received bytes count pri2");
804 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
805 "rx_packets_pri2", CTLFLAG_RD,
806 &softc->rx_packets_pri[2], "Received packets count pri2");
807 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
808 "rx_bytes_pri3", CTLFLAG_RD,
809 &softc->rx_bytes_pri[3], "Received bytes count pri3");
810 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
811 "rx_packets_pri3", CTLFLAG_RD,
812 &softc->rx_packets_pri[3], "Received packets count pri3");
813 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
814 "rx_bytes_pri4", CTLFLAG_RD,
815 &softc->rx_bytes_pri[4], "Received bytes count pri4");
816 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
817 "rx_packets_pri4", CTLFLAG_RD,
818 &softc->rx_packets_pri[4], "Received packets count pri4");
819 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
820 "rx_bytes_pri5", CTLFLAG_RD,
821 &softc->rx_bytes_pri[5], "Received bytes count pri5");
822 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
823 "rx_packets_pri5", CTLFLAG_RD,
824 &softc->rx_packets_pri[5], "Received packets count pri5");
825 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
826 "rx_bytes_pri6", CTLFLAG_RD,
827 &softc->rx_bytes_pri[6], "Received bytes count pri6");
828 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
829 "rx_packets_pri6", CTLFLAG_RD,
830 &softc->rx_packets_pri[6], "Received packets count pri6");
831 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
832 "rx_bytes_pri7", CTLFLAG_RD,
833 &softc->rx_bytes_pri[7], "Received bytes count pri7");
834 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
835 "rx_packets_pri7", CTLFLAG_RD,
836 &softc->rx_packets_pri[7], "Received packets count pri7");
837
838 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
839 "pfc_pri0_rx_duration_us", CTLFLAG_RD,
840 &softc->rx_port_stats_ext->pfc_pri0_rx_duration_us, "Time duration in receiving"
841 "between XON to XOFF and XOFF to XON for pri0");
842 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
843 "pfc_pri0_rx_transitions", CTLFLAG_RD,
844 &softc->rx_port_stats_ext->pfc_pri0_rx_transitions, "Num times rx transition"
845 "between XON to XOFF and XOFF to XON for pri0");
846 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
847 "pfc_pri1_rx_duration_us", CTLFLAG_RD,
848 &softc->rx_port_stats_ext->pfc_pri1_rx_duration_us, "Time duration in receiving"
849 "between XON to XOFF and XOFF to XON for pri1");
850 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
851 "pfc_pri1_rx_transitions", CTLFLAG_RD,
852 &softc->rx_port_stats_ext->pfc_pri1_rx_transitions, "Num times rx transition"
853 "between XON to XOFF and XOFF to XON for pri1");
854 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
855 "pfc_pri2_rx_duration_us", CTLFLAG_RD,
856 &softc->rx_port_stats_ext->pfc_pri2_rx_duration_us, "Time duration in receiving"
857 "between XON to XOFF and XOFF to XON for pri2");
858 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
859 "pfc_pri2_rx_transitions", CTLFLAG_RD,
860 &softc->rx_port_stats_ext->pfc_pri2_rx_transitions, "Num times rx transition"
861 "between XON to XOFF and XOFF to XON for pri2");
862 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
863 "pfc_pri3_rx_duration_us", CTLFLAG_RD,
864 &softc->rx_port_stats_ext->pfc_pri3_rx_duration_us, "Time duration in receiving"
865 "between XON to XOFF and XOFF to XON for pri3");
866 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
867 "pfc_pri3_rx_transitions", CTLFLAG_RD,
868 &softc->rx_port_stats_ext->pfc_pri3_rx_transitions, "Num times rx transition"
869 "between XON to XOFF and XOFF to XON for pri3");
870 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
871 "pfc_pri4_rx_duration_us", CTLFLAG_RD,
872 &softc->rx_port_stats_ext->pfc_pri4_rx_duration_us, "Time duration in receiving"
873 "between XON to XOFF and XOFF to XON for pri4");
874 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
875 "pfc_pri4_rx_transitions", CTLFLAG_RD,
876 &softc->rx_port_stats_ext->pfc_pri4_rx_transitions, "Num times rx transition"
877 "between XON to XOFF and XOFF to XON for pri4");
878 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
879 "pfc_pri5_rx_duration_us", CTLFLAG_RD,
880 &softc->rx_port_stats_ext->pfc_pri5_rx_duration_us, "Time duration in receiving"
881 "between XON to XOFF and XOFF to XON for pri5");
882 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
883 "pfc_pri5_rx_transitions", CTLFLAG_RD,
884 &softc->rx_port_stats_ext->pfc_pri5_rx_transitions, "Num times rx transition"
885 "between XON to XOFF and XOFF to XON for pri5");
886 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
887 "pfc_pri6_rx_duration_us", CTLFLAG_RD,
888 &softc->rx_port_stats_ext->pfc_pri6_rx_duration_us, "Time duration in receiving"
889 "between XON to XOFF and XOFF to XON for pri6");
890 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
891 "pfc_pri6_rx_transitions", CTLFLAG_RD,
892 &softc->rx_port_stats_ext->pfc_pri6_rx_transitions, "Num times rx transition"
893 "between XON to XOFF and XOFF to XON for pri6");
894 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
895 "pfc_pri7_rx_duration_us", CTLFLAG_RD,
896 &softc->rx_port_stats_ext->pfc_pri7_rx_duration_us, "Time duration in receiving"
897 "between XON to XOFF and XOFF to XON for pri7");
898 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
899 "pfc_pri7_rx_transitions", CTLFLAG_RD,
900 &softc->rx_port_stats_ext->pfc_pri7_rx_transitions, "Num times rx transition"
901 "between XON to XOFF and XOFF to XON for pri7");
902
903 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
904 "rx_bits", CTLFLAG_RD,
905 &softc->rx_port_stats_ext->rx_bits, "total number of received bits");
906 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
907 "rx_buffer_passed_threshold", CTLFLAG_RD,
908 &softc->rx_port_stats_ext->rx_buffer_passed_threshold, "num of events port"
909 "buffer"
910 "was over 85%");
911 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
912 "rx_pcs_symbol_err", CTLFLAG_RD,
913 &softc->rx_port_stats_ext->rx_pcs_symbol_err, "num of symbol errors wasn't"
914 "corrected by FEC");
915 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
916 "rx_corrected_bits", CTLFLAG_RD,
917 &softc->rx_port_stats_ext->rx_corrected_bits, "num of bits corrected by FEC");
918
919 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
920 "rx_discard_bytes_cos0", CTLFLAG_RD,
921 &softc->rx_port_stats_ext->rx_discard_bytes_cos0, "num of rx discard bytes"
922 "count on cos0");
923 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
924 "rx_discard_packets_cos0", CTLFLAG_RD,
925 &softc->rx_port_stats_ext->rx_discard_packets_cos0, "num of rx discard packets"
926 "count on cos0");
927 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
928 "rx_discard_bytes_cos1", CTLFLAG_RD,
929 &softc->rx_port_stats_ext->rx_discard_bytes_cos1, "num of rx discard bytes"
930 "count on cos1");
931 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
932 "rx_discard_packets_cos1", CTLFLAG_RD,
933 &softc->rx_port_stats_ext->rx_discard_packets_cos1, "num of rx discard packets"
934 "count on cos1");
935 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
936 "rx_discard_bytes_cos2", CTLFLAG_RD,
937 &softc->rx_port_stats_ext->rx_discard_bytes_cos2, "num of rx discard bytes"
938 "count on cos2");
939 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
940 "rx_discard_packets_cos2", CTLFLAG_RD,
941 &softc->rx_port_stats_ext->rx_discard_packets_cos2, "num of rx discard packets"
942 "count on cos2");
943 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
944 "rx_discard_bytes_cos3", CTLFLAG_RD,
945 &softc->rx_port_stats_ext->rx_discard_bytes_cos3, "num of rx discard bytes"
946 "count on cos3");
947 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
948 "rx_discard_packets_cos3", CTLFLAG_RD,
949 &softc->rx_port_stats_ext->rx_discard_packets_cos3, "num of rx discard packets"
950 "count on cos3");
951 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
952 "rx_discard_bytes_cos4", CTLFLAG_RD,
953 &softc->rx_port_stats_ext->rx_discard_bytes_cos4, "num of rx discard bytes"
954 "count on cos4");
955 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
956 "rx_discard_packets_cos4", CTLFLAG_RD,
957 &softc->rx_port_stats_ext->rx_discard_packets_cos4, "num of rx discard packets"
958 "count on cos4");
959 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
960 "rx_discard_bytes_cos5", CTLFLAG_RD,
961 &softc->rx_port_stats_ext->rx_discard_bytes_cos5, "num of rx discard bytes"
962 "count on cos5");
963 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
964 "rx_discard_packets_cos5", CTLFLAG_RD,
965 &softc->rx_port_stats_ext->rx_discard_packets_cos5, "num of rx discard packets"
966 "count on cos5");
967 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
968 "rx_discard_bytes_cos6", CTLFLAG_RD,
969 &softc->rx_port_stats_ext->rx_discard_bytes_cos6, "num of rx discard bytes"
970 "count on cos6");
971 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
972 "rx_discard_packets_cos6", CTLFLAG_RD,
973 &softc->rx_port_stats_ext->rx_discard_packets_cos6, "num of rx discard packets"
974 "count on cos6");
975 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
976 "rx_discard_bytes_cos7", CTLFLAG_RD,
977 &softc->rx_port_stats_ext->rx_discard_bytes_cos7, "num of rx discard bytes"
978 "count on cos7");
979 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
980 "rx_discard_packets_cos7", CTLFLAG_RD,
981 &softc->rx_port_stats_ext->rx_discard_packets_cos7, "num of rx discard packets"
982 "count on cos7");
983 }
984
985
986 return 0;
987 }
988
989 int
bnxt_create_rx_sysctls(struct bnxt_softc * softc,int rxr)990 bnxt_create_rx_sysctls(struct bnxt_softc *softc, int rxr)
991 {
992 struct sysctl_oid *oid;
993 struct ctx_hw_stats *rx_stats = (void *)softc->rx_stats[rxr].idi_vaddr;
994 char name[32];
995 char desc[64];
996
997 sprintf(name, "rxq%d", rxr);
998 sprintf(desc, "receive queue %d", rxr);
999 oid = SYSCTL_ADD_NODE(&softc->hw_stats,
1000 SYSCTL_CHILDREN(softc->hw_stats_oid), OID_AUTO, name,
1001 CTLFLAG_RD | CTLFLAG_MPSAFE, 0, desc);
1002 if (!oid)
1003 return ENOMEM;
1004
1005 if (BNXT_CHIP_P5(softc))
1006 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
1007 "nq_num_ints", CTLFLAG_RD, &softc->nq_rings[rxr].int_count,
1008 "Num Interrupts");
1009 else
1010 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
1011 "rq_num_ints", CTLFLAG_RD, &softc->rx_cp_rings[rxr].int_count,
1012 "Num Interrupts");
1013 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
1014 "ucast_pkts", CTLFLAG_RD, &rx_stats->rx_ucast_pkts,
1015 "unicast packets received");
1016 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
1017 "mcast_pkts", CTLFLAG_RD, &rx_stats->rx_mcast_pkts,
1018 "multicast packets received");
1019 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
1020 "bcast_pkts", CTLFLAG_RD, &rx_stats->rx_bcast_pkts,
1021 "broadcast packets received");
1022 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
1023 "discard_pkts", CTLFLAG_RD,
1024 &rx_stats->rx_discard_pkts, "discarded receive packets");
1025 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
1026 "error_pkts", CTLFLAG_RD, &rx_stats->rx_error_pkts,
1027 "Error receive packets");
1028 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
1029 "ucast_bytes", CTLFLAG_RD, &rx_stats->rx_ucast_bytes,
1030 "unicast bytes received");
1031 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
1032 "mcast_bytes", CTLFLAG_RD, &rx_stats->rx_mcast_bytes,
1033 "multicast bytes received");
1034 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
1035 "bcast_bytes", CTLFLAG_RD, &rx_stats->rx_bcast_bytes,
1036 "broadcast bytes received");
1037
1038 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
1039 "tpa_pkts", CTLFLAG_RD, &rx_stats->tpa_pkts,
1040 "TPA packets");
1041 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
1042 "tpa_bytes", CTLFLAG_RD, &rx_stats->tpa_bytes,
1043 "TPA bytes");
1044 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
1045 "tpa_events", CTLFLAG_RD, &rx_stats->tpa_events,
1046 "TPA events");
1047 SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
1048 "tpa_aborts", CTLFLAG_RD, &rx_stats->tpa_aborts,
1049 "TPA aborts");
1050
1051 return 0;
1052 }
1053
1054 static char *bnxt_chip_type[] = {
1055 "ASIC",
1056 "FPGA",
1057 "Palladium",
1058 "Unknown"
1059 };
1060 #define MAX_CHIP_TYPE 3
1061
bnxt_parse_pkglog(int desired_field,uint8_t * data,size_t datalen)1062 static char *bnxt_parse_pkglog(int desired_field, uint8_t *data, size_t datalen)
1063 {
1064 char *retval = NULL;
1065 char *p;
1066 char *value;
1067 int field = 0;
1068
1069 if (datalen < 1)
1070 return NULL;
1071 /* null-terminate the log data (removing last '\n'): */
1072 data[datalen - 1] = 0;
1073 for (p = data; *p != 0; p++) {
1074 field = 0;
1075 retval = NULL;
1076 while (*p != 0 && *p != '\n') {
1077 value = p;
1078 while (*p != 0 && *p != '\t' && *p != '\n')
1079 p++;
1080 if (field == desired_field)
1081 retval = value;
1082 if (*p != '\t')
1083 break;
1084 *p = 0;
1085 field++;
1086 p++;
1087 }
1088 if (*p == 0)
1089 break;
1090 *p = 0;
1091 }
1092 return retval;
1093 }
1094
1095 static int
bnxt_package_ver_sysctl(SYSCTL_HANDLER_ARGS)1096 bnxt_package_ver_sysctl(SYSCTL_HANDLER_ARGS)
1097 {
1098 struct bnxt_softc *softc = arg1;
1099 struct iflib_dma_info dma_data;
1100 char *pkglog = NULL;
1101 char *p;
1102 char unk[] = "<unknown>";
1103 char *buf = unk;
1104 int rc;
1105 uint16_t ordinal = BNX_DIR_ORDINAL_FIRST;
1106 uint16_t index;
1107 uint32_t data_len;
1108
1109 rc = bnxt_hwrm_nvm_find_dir_entry(softc, BNX_DIR_TYPE_PKG_LOG,
1110 &ordinal, BNX_DIR_EXT_NONE, &index, false,
1111 HWRM_NVM_FIND_DIR_ENTRY_INPUT_OPT_ORDINAL_EQ,
1112 &data_len, NULL, NULL);
1113 dma_data.idi_vaddr = NULL;
1114 if (rc == 0 && data_len) {
1115 rc = iflib_dma_alloc(softc->ctx, data_len, &dma_data,
1116 BUS_DMA_NOWAIT);
1117 if (rc == 0) {
1118 rc = bnxt_hwrm_nvm_read(softc, index, 0, data_len,
1119 &dma_data);
1120 if (rc == 0) {
1121 pkglog = dma_data.idi_vaddr;
1122 p = bnxt_parse_pkglog(BNX_PKG_LOG_FIELD_IDX_PKG_VERSION, pkglog, data_len);
1123 if (p && *p != 0 && isdigit(*p))
1124 buf = p;
1125 }
1126 } else
1127 dma_data.idi_vaddr = NULL;
1128 }
1129
1130 rc = sysctl_handle_string(oidp, buf, 0, req);
1131 if (dma_data.idi_vaddr)
1132 iflib_dma_free(&dma_data);
1133 return rc;
1134 }
1135
1136 static int
bnxt_hwrm_min_ver_sysctl(SYSCTL_HANDLER_ARGS)1137 bnxt_hwrm_min_ver_sysctl(SYSCTL_HANDLER_ARGS)
1138 {
1139 struct bnxt_softc *softc = arg1;
1140 char buf[16];
1141 uint8_t newver[3];
1142 int rc;
1143
1144 sprintf(buf, "%hhu.%hhu.%hhu", softc->ver_info->hwrm_min_major,
1145 softc->ver_info->hwrm_min_minor, softc->ver_info->hwrm_min_update);
1146
1147 rc = sysctl_handle_string(oidp, buf, sizeof(buf), req);
1148 if (rc || req->newptr == NULL)
1149 return rc;
1150 if (sscanf(buf, "%hhu.%hhu.%hhu%*c", &newver[0], &newver[1],
1151 &newver[2]) != 3)
1152 return EINVAL;
1153 softc->ver_info->hwrm_min_major = newver[0];
1154 softc->ver_info->hwrm_min_minor = newver[1];
1155 softc->ver_info->hwrm_min_update = newver[2];
1156 bnxt_check_hwrm_version(softc);
1157
1158 return rc;
1159 }
1160
1161 int
bnxt_create_ver_sysctls(struct bnxt_softc * softc)1162 bnxt_create_ver_sysctls(struct bnxt_softc *softc)
1163 {
1164 struct bnxt_ver_info *vi = softc->ver_info;
1165 struct sysctl_oid *oid = vi->ver_oid;
1166
1167 if (!oid)
1168 return ENOMEM;
1169
1170 SYSCTL_ADD_STRING(&vi->ver_ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
1171 "hwrm_if", CTLFLAG_RD, vi->hwrm_if_ver, 0,
1172 "HWRM interface version");
1173 SYSCTL_ADD_STRING(&vi->ver_ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
1174 "driver_hwrm_if", CTLFLAG_RD, vi->driver_hwrm_if_ver, 0,
1175 "HWRM firmware version");
1176 SYSCTL_ADD_STRING(&vi->ver_ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
1177 "mgmt_fw", CTLFLAG_RD, vi->mgmt_fw_ver, 0,
1178 "management firmware version");
1179 SYSCTL_ADD_STRING(&vi->ver_ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
1180 "netctrl_fw", CTLFLAG_RD, vi->netctrl_fw_ver, 0,
1181 "network control firmware version");
1182 SYSCTL_ADD_STRING(&vi->ver_ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
1183 "roce_fw", CTLFLAG_RD, vi->roce_fw_ver, 0,
1184 "RoCE firmware version");
1185 SYSCTL_ADD_STRING(&vi->ver_ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
1186 "fw_ver", CTLFLAG_RD, vi->fw_ver_str, 0,
1187 "Firmware version");
1188 SYSCTL_ADD_STRING(&vi->ver_ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
1189 "phy", CTLFLAG_RD, vi->phy_ver, 0,
1190 "PHY version");
1191 SYSCTL_ADD_STRING(&vi->ver_ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
1192 "hwrm_fw_name", CTLFLAG_RD, vi->hwrm_fw_name, 0,
1193 "HWRM firmware name");
1194 SYSCTL_ADD_STRING(&vi->ver_ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
1195 "mgmt_fw_name", CTLFLAG_RD, vi->mgmt_fw_name, 0,
1196 "management firmware name");
1197 SYSCTL_ADD_STRING(&vi->ver_ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
1198 "netctrl_fw_name", CTLFLAG_RD, vi->netctrl_fw_name, 0,
1199 "network control firmware name");
1200 SYSCTL_ADD_STRING(&vi->ver_ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
1201 "roce_fw_name", CTLFLAG_RD, vi->roce_fw_name, 0,
1202 "RoCE firmware name");
1203 SYSCTL_ADD_STRING(&vi->ver_ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
1204 "phy_vendor", CTLFLAG_RD, vi->phy_vendor, 0,
1205 "PHY vendor name");
1206 SYSCTL_ADD_STRING(&vi->ver_ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
1207 "phy_partnumber", CTLFLAG_RD, vi->phy_partnumber, 0,
1208 "PHY vendor part number");
1209 SYSCTL_ADD_U16(&vi->ver_ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
1210 "chip_num", CTLFLAG_RD, &vi->chip_num, 0, "chip number");
1211 SYSCTL_ADD_U8(&vi->ver_ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
1212 "chip_rev", CTLFLAG_RD, &vi->chip_rev, 0, "chip revision");
1213 SYSCTL_ADD_U8(&vi->ver_ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
1214 "chip_metal", CTLFLAG_RD, &vi->chip_metal, 0, "chip metal number");
1215 SYSCTL_ADD_U8(&vi->ver_ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
1216 "chip_bond_id", CTLFLAG_RD, &vi->chip_bond_id, 0,
1217 "chip bond id");
1218 SYSCTL_ADD_STRING(&vi->ver_ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
1219 "chip_type", CTLFLAG_RD, vi->chip_type > MAX_CHIP_TYPE ?
1220 bnxt_chip_type[MAX_CHIP_TYPE] : bnxt_chip_type[vi->chip_type], 0,
1221 "RoCE firmware name");
1222 SYSCTL_ADD_PROC(&vi->ver_ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
1223 "package_ver", CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE,
1224 softc, 0, bnxt_package_ver_sysctl, "A",
1225 "currently installed package version");
1226 SYSCTL_ADD_PROC(&vi->ver_ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
1227 "hwrm_min_ver", CTLTYPE_STRING | CTLFLAG_RWTUN | CTLFLAG_MPSAFE,
1228 softc, 0, bnxt_hwrm_min_ver_sysctl, "A",
1229 "minimum hwrm API vesion to support");
1230
1231 return 0;
1232 }
1233
1234 int
bnxt_create_nvram_sysctls(struct bnxt_nvram_info * ni)1235 bnxt_create_nvram_sysctls(struct bnxt_nvram_info *ni)
1236 {
1237 struct sysctl_oid *oid = ni->nvm_oid;
1238
1239 if (!oid)
1240 return ENOMEM;
1241
1242 SYSCTL_ADD_U16(&ni->nvm_ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
1243 "mfg_id", CTLFLAG_RD, &ni->mfg_id, 0, "manufacturer id");
1244 SYSCTL_ADD_U16(&ni->nvm_ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
1245 "device_id", CTLFLAG_RD, &ni->device_id, 0, "device id");
1246 SYSCTL_ADD_U32(&ni->nvm_ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
1247 "sector_size", CTLFLAG_RD, &ni->sector_size, 0, "sector size");
1248 SYSCTL_ADD_U32(&ni->nvm_ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
1249 "size", CTLFLAG_RD, &ni->size, 0, "nvram total size");
1250 SYSCTL_ADD_U32(&ni->nvm_ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
1251 "reserved_size", CTLFLAG_RD, &ni->reserved_size, 0,
1252 "total reserved space");
1253 SYSCTL_ADD_U32(&ni->nvm_ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
1254 "available_size", CTLFLAG_RD, &ni->available_size, 0,
1255 "total available space");
1256
1257 return 0;
1258 }
1259
1260 static int
bnxt_rss_key_sysctl(SYSCTL_HANDLER_ARGS)1261 bnxt_rss_key_sysctl(SYSCTL_HANDLER_ARGS)
1262 {
1263 struct bnxt_softc *softc = arg1;
1264 char buf[HW_HASH_KEY_SIZE*2+1] = {0};
1265 char *p;
1266 int i;
1267 int rc;
1268
1269 for (p = buf, i=0; i<HW_HASH_KEY_SIZE; i++)
1270 p += sprintf(p, "%02x", softc->vnic_info.rss_hash_key[i]);
1271
1272 rc = sysctl_handle_string(oidp, buf, sizeof(buf), req);
1273 if (rc || req->newptr == NULL)
1274 return rc;
1275
1276 if (strspn(buf, "0123456789abcdefABCDEF") != (HW_HASH_KEY_SIZE * 2))
1277 return EINVAL;
1278
1279 for (p = buf, i=0; i<HW_HASH_KEY_SIZE; i++) {
1280 if (sscanf(p, "%02hhx", &softc->vnic_info.rss_hash_key[i]) != 1)
1281 return EINVAL;
1282 p += 2;
1283 }
1284
1285 if (if_getdrvflags(iflib_get_ifp(softc->ctx)) & IFF_DRV_RUNNING)
1286 bnxt_hwrm_rss_cfg(softc, &softc->vnic_info,
1287 softc->vnic_info.rss_hash_type);
1288
1289 return rc;
1290 }
1291
1292 static const char *bnxt_hash_types[] = {"ipv4", "tcp_ipv4", "udp_ipv4", "ipv6",
1293 "tcp_ipv6", "udp_ipv6", NULL};
1294
bnxt_get_rss_type_str_bit(char * str)1295 static int bnxt_get_rss_type_str_bit(char *str)
1296 {
1297 int i;
1298
1299 for (i=0; bnxt_hash_types[i]; i++)
1300 if (strcmp(bnxt_hash_types[i], str) == 0)
1301 return i;
1302
1303 return -1;
1304 }
1305
1306 static int
bnxt_rss_type_sysctl(SYSCTL_HANDLER_ARGS)1307 bnxt_rss_type_sysctl(SYSCTL_HANDLER_ARGS)
1308 {
1309 struct bnxt_softc *softc = arg1;
1310 char buf[256] = {0};
1311 char *p;
1312 char *next;
1313 int rc;
1314 int type;
1315 int bit;
1316
1317 for (type = softc->vnic_info.rss_hash_type; type;
1318 type &= ~(1<<bit)) {
1319 bit = ffs(type) - 1;
1320 if (bit >= sizeof(bnxt_hash_types) / sizeof(const char *))
1321 continue;
1322 if (type != softc->vnic_info.rss_hash_type)
1323 strcat(buf, ",");
1324 strcat(buf, bnxt_hash_types[bit]);
1325 }
1326
1327 rc = sysctl_handle_string(oidp, buf, sizeof(buf), req);
1328 if (rc || req->newptr == NULL)
1329 return rc;
1330
1331 for (type = 0, next = buf, p = strsep(&next, " ,"); p;
1332 p = strsep(&next, " ,")) {
1333 bit = bnxt_get_rss_type_str_bit(p);
1334 if (bit == -1)
1335 return EINVAL;
1336 type |= 1<<bit;
1337 }
1338 if (type != softc->vnic_info.rss_hash_type) {
1339 softc->vnic_info.rss_hash_type = type;
1340 if (if_getdrvflags(iflib_get_ifp(softc->ctx)) & IFF_DRV_RUNNING)
1341 bnxt_hwrm_rss_cfg(softc, &softc->vnic_info,
1342 softc->vnic_info.rss_hash_type);
1343 }
1344
1345 return rc;
1346 }
1347
1348 static int
bnxt_rx_stall_sysctl(SYSCTL_HANDLER_ARGS)1349 bnxt_rx_stall_sysctl(SYSCTL_HANDLER_ARGS) {
1350 struct bnxt_softc *softc = arg1;
1351 int rc;
1352 int val;
1353
1354 if (softc == NULL)
1355 return EBUSY;
1356
1357 val = (bool)(softc->vnic_info.flags & BNXT_VNIC_FLAG_BD_STALL);
1358 rc = sysctl_handle_int(oidp, &val, 0, req);
1359 if (rc || !req->newptr)
1360 return rc;
1361
1362 if (val)
1363 softc->vnic_info.flags |= BNXT_VNIC_FLAG_BD_STALL;
1364 else
1365 softc->vnic_info.flags &= ~BNXT_VNIC_FLAG_BD_STALL;
1366
1367 if (if_getdrvflags(iflib_get_ifp(softc->ctx)) & IFF_DRV_RUNNING)
1368 rc = bnxt_hwrm_vnic_cfg(softc, &softc->vnic_info);
1369
1370 return rc;
1371 }
1372
1373 static int
bnxt_vlan_strip_sysctl(SYSCTL_HANDLER_ARGS)1374 bnxt_vlan_strip_sysctl(SYSCTL_HANDLER_ARGS) {
1375 struct bnxt_softc *softc = arg1;
1376 int rc;
1377 int val;
1378
1379 if (softc == NULL)
1380 return EBUSY;
1381
1382 val = (bool)(softc->vnic_info.flags & BNXT_VNIC_FLAG_VLAN_STRIP);
1383 rc = sysctl_handle_int(oidp, &val, 0, req);
1384 if (rc || !req->newptr)
1385 return rc;
1386
1387 if (val)
1388 softc->vnic_info.flags |= BNXT_VNIC_FLAG_VLAN_STRIP;
1389 else
1390 softc->vnic_info.flags &= ~BNXT_VNIC_FLAG_VLAN_STRIP;
1391
1392 if (if_getdrvflags(iflib_get_ifp(softc->ctx)) & IFF_DRV_RUNNING)
1393 rc = bnxt_hwrm_vnic_cfg(softc, &softc->vnic_info);
1394
1395 return rc;
1396 }
1397
1398 static int
bnxt_set_coal_rx_usecs(SYSCTL_HANDLER_ARGS)1399 bnxt_set_coal_rx_usecs(SYSCTL_HANDLER_ARGS) {
1400 struct bnxt_softc *softc = arg1;
1401 int rc;
1402 int val;
1403
1404 if (softc == NULL)
1405 return EBUSY;
1406
1407 val = softc->rx_coal_usecs;
1408 rc = sysctl_handle_int(oidp, &val, 0, req);
1409 if (rc || !req->newptr)
1410 return rc;
1411
1412 softc->rx_coal_usecs = val;
1413 rc = bnxt_hwrm_set_coal(softc);
1414
1415 return rc;
1416 }
1417
1418 static int
bnxt_set_coal_rx_frames(SYSCTL_HANDLER_ARGS)1419 bnxt_set_coal_rx_frames(SYSCTL_HANDLER_ARGS) {
1420 struct bnxt_softc *softc = arg1;
1421 int rc;
1422 int val;
1423
1424 if (softc == NULL)
1425 return EBUSY;
1426
1427 val = softc->rx_coal_frames;
1428 rc = sysctl_handle_int(oidp, &val, 0, req);
1429 if (rc || !req->newptr)
1430 return rc;
1431
1432 softc->rx_coal_frames = val;
1433 rc = bnxt_hwrm_set_coal(softc);
1434
1435 return rc;
1436 }
1437
1438 static int
bnxt_set_coal_rx_usecs_irq(SYSCTL_HANDLER_ARGS)1439 bnxt_set_coal_rx_usecs_irq(SYSCTL_HANDLER_ARGS) {
1440 struct bnxt_softc *softc = arg1;
1441 int rc;
1442 int val;
1443
1444 if (softc == NULL)
1445 return EBUSY;
1446
1447 val = softc->rx_coal_usecs_irq;
1448 rc = sysctl_handle_int(oidp, &val, 0, req);
1449 if (rc || !req->newptr)
1450 return rc;
1451
1452 softc->rx_coal_usecs_irq = val;
1453 rc = bnxt_hwrm_set_coal(softc);
1454
1455 return rc;
1456 }
1457
1458 static int
bnxt_set_coal_rx_frames_irq(SYSCTL_HANDLER_ARGS)1459 bnxt_set_coal_rx_frames_irq(SYSCTL_HANDLER_ARGS) {
1460 struct bnxt_softc *softc = arg1;
1461 int rc;
1462 int val;
1463
1464 if (softc == NULL)
1465 return EBUSY;
1466
1467 val = softc->rx_coal_frames_irq;
1468 rc = sysctl_handle_int(oidp, &val, 0, req);
1469 if (rc || !req->newptr)
1470 return rc;
1471
1472 softc->rx_coal_frames_irq = val;
1473 rc = bnxt_hwrm_set_coal(softc);
1474
1475 return rc;
1476 }
1477
1478 static int
bnxt_set_coal_tx_usecs(SYSCTL_HANDLER_ARGS)1479 bnxt_set_coal_tx_usecs(SYSCTL_HANDLER_ARGS) {
1480 struct bnxt_softc *softc = arg1;
1481 int rc;
1482 int val;
1483
1484 if (softc == NULL)
1485 return EBUSY;
1486
1487 val = softc->tx_coal_usecs;
1488 rc = sysctl_handle_int(oidp, &val, 0, req);
1489 if (rc || !req->newptr)
1490 return rc;
1491
1492 softc->tx_coal_usecs = val;
1493 rc = bnxt_hwrm_set_coal(softc);
1494
1495 return rc;
1496 }
1497
1498 static int
bnxt_set_coal_tx_frames(SYSCTL_HANDLER_ARGS)1499 bnxt_set_coal_tx_frames(SYSCTL_HANDLER_ARGS) {
1500 struct bnxt_softc *softc = arg1;
1501 int rc;
1502 int val;
1503
1504 if (softc == NULL)
1505 return EBUSY;
1506
1507 val = softc->tx_coal_frames;
1508 rc = sysctl_handle_int(oidp, &val, 0, req);
1509 if (rc || !req->newptr)
1510 return rc;
1511
1512 softc->tx_coal_frames = val;
1513 rc = bnxt_hwrm_set_coal(softc);
1514
1515 return rc;
1516 }
1517
1518 static int
bnxt_set_coal_tx_usecs_irq(SYSCTL_HANDLER_ARGS)1519 bnxt_set_coal_tx_usecs_irq(SYSCTL_HANDLER_ARGS) {
1520 struct bnxt_softc *softc = arg1;
1521 int rc;
1522 int val;
1523
1524 if (softc == NULL)
1525 return EBUSY;
1526
1527 val = softc->tx_coal_usecs_irq;
1528 rc = sysctl_handle_int(oidp, &val, 0, req);
1529 if (rc || !req->newptr)
1530 return rc;
1531
1532 softc->tx_coal_usecs_irq = val;
1533 rc = bnxt_hwrm_set_coal(softc);
1534
1535 return rc;
1536 }
1537
1538 static int
bnxt_set_coal_tx_frames_irq(SYSCTL_HANDLER_ARGS)1539 bnxt_set_coal_tx_frames_irq(SYSCTL_HANDLER_ARGS) {
1540 struct bnxt_softc *softc = arg1;
1541 int rc;
1542 int val;
1543
1544 if (softc == NULL)
1545 return EBUSY;
1546
1547 val = softc->tx_coal_frames_irq;
1548 rc = sysctl_handle_int(oidp, &val, 0, req);
1549 if (rc || !req->newptr)
1550 return rc;
1551
1552 softc->tx_coal_frames_irq = val;
1553 rc = bnxt_hwrm_set_coal(softc);
1554
1555 return rc;
1556 }
1557
1558 static
simulate_reset(struct bnxt_softc * bp,char * fwcli_string)1559 void simulate_reset(struct bnxt_softc *bp, char *fwcli_string)
1560 {
1561 struct hwrm_dbg_fw_cli_input req = {0};
1562 int rc = 0;
1563
1564 bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_DBG_FW_CLI);
1565 req.cmpl_ring = -1;
1566 req.target_id = -1;
1567 req.cli_cmd_len = strlen(fwcli_string);
1568 req.host_buf_len = 64 * 1024;
1569 strcpy((char *)req.cli_cmd, fwcli_string);
1570
1571 BNXT_HWRM_LOCK(bp);
1572 rc = _hwrm_send_message(bp, &req, sizeof(req));
1573 if (rc) {
1574 device_printf(bp->dev, " Manual FW fault failed, rc:%x\n", rc);
1575 }
1576 BNXT_HWRM_UNLOCK(bp);
1577 }
1578
1579 static int
bnxt_reset_ctrl(SYSCTL_HANDLER_ARGS)1580 bnxt_reset_ctrl(SYSCTL_HANDLER_ARGS) {
1581 struct bnxt_softc *softc = arg1;
1582 int rc = 0;
1583 char buf[50] = {0};
1584
1585 if (softc == NULL)
1586 return EBUSY;
1587
1588 rc = sysctl_handle_string(oidp, buf, sizeof(buf), req);
1589 if (rc || req->newptr == NULL)
1590 return rc;
1591
1592 if (BNXT_CHIP_P5(softc))
1593 simulate_reset(softc, buf);
1594
1595 return rc;
1596 }
1597
1598 int
bnxt_create_config_sysctls_pre(struct bnxt_softc * softc)1599 bnxt_create_config_sysctls_pre(struct bnxt_softc *softc)
1600 {
1601 struct sysctl_ctx_list *ctx = device_get_sysctl_ctx(softc->dev);
1602 struct sysctl_oid_list *children;
1603
1604 children = SYSCTL_CHILDREN(device_get_sysctl_tree(softc->dev));
1605
1606 SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "rss_key",
1607 CTLTYPE_STRING | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, softc, 0,
1608 bnxt_rss_key_sysctl, "A", "RSS key");
1609 SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "rss_type",
1610 CTLTYPE_STRING | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, softc, 0,
1611 bnxt_rss_type_sysctl, "A", "RSS type bits");
1612 SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "rx_stall",
1613 CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, softc, 0,
1614 bnxt_rx_stall_sysctl, "I",
1615 "buffer rx packets in hardware until the host posts new buffers");
1616 SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "vlan_strip",
1617 CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, softc, 0,
1618 bnxt_vlan_strip_sysctl, "I", "strip VLAN tag in the RX path");
1619 SYSCTL_ADD_CONST_STRING(ctx, children, OID_AUTO, "if_name", CTLFLAG_RD,
1620 if_name(iflib_get_ifp(softc->ctx)), "interface name");
1621
1622 SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "intr_coal_rx_usecs",
1623 CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, softc, 0,
1624 bnxt_set_coal_rx_usecs, "I", "interrupt coalescing Rx Usecs");
1625 SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "intr_coal_rx_frames",
1626 CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, softc, 0,
1627 bnxt_set_coal_rx_frames, "I", "interrupt coalescing Rx Frames");
1628 SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "intr_coal_rx_usecs_irq",
1629 CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, softc, 0,
1630 bnxt_set_coal_rx_usecs_irq, "I",
1631 "interrupt coalescing Rx Usecs IRQ");
1632 SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "intr_coal_rx_frames_irq",
1633 CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, softc, 0,
1634 bnxt_set_coal_rx_frames_irq, "I",
1635 "interrupt coalescing Rx Frames IRQ");
1636 SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "intr_coal_tx_usecs",
1637 CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, softc, 0,
1638 bnxt_set_coal_tx_usecs, "I", "interrupt coalescing Tx Usces");
1639 SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "intr_coal_tx_frames",
1640 CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, softc, 0,
1641 bnxt_set_coal_tx_frames, "I", "interrupt coalescing Tx Frames");
1642 SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "intr_coal_tx_usecs_irq",
1643 CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, softc, 0,
1644 bnxt_set_coal_tx_usecs_irq, "I",
1645 "interrupt coalescing Tx Usecs IRQ");
1646 SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "intr_coal_tx_frames_irq",
1647 CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, softc, 0,
1648 bnxt_set_coal_tx_frames_irq, "I",
1649 "interrupt coalescing Tx Frames IRQ");
1650 SYSCTL_ADD_U32(ctx, children, OID_AUTO, "flags", CTLFLAG_RD,
1651 &softc->flags, 0, "flags");
1652 SYSCTL_ADD_U64(ctx, children, OID_AUTO, "fw_cap", CTLFLAG_RD,
1653 &softc->fw_cap, 0, "FW caps");
1654
1655 SYSCTL_ADD_PROC(ctx, children, OID_AUTO,
1656 "reset_ctrl", CTLTYPE_STRING | CTLFLAG_RWTUN, softc,
1657 0, bnxt_reset_ctrl, "A",
1658 "Issue controller reset: 0 / 1");
1659 return 0;
1660 }
1661
1662 #define BNXT_HW_LRO_FN(fn_name, arg) \
1663 static int \
1664 fn_name(SYSCTL_HANDLER_ARGS) { \
1665 struct bnxt_softc *softc = arg1; \
1666 int rc; \
1667 int val; \
1668 \
1669 if (softc == NULL) \
1670 return EBUSY; \
1671 \
1672 val = softc->hw_lro.arg; \
1673 rc = sysctl_handle_int(oidp, &val, 0, req); \
1674 if (rc || !req->newptr) \
1675 return rc; \
1676 \
1677 if ((if_getdrvflags(iflib_get_ifp(softc->ctx)) & IFF_DRV_RUNNING)) \
1678 return EBUSY; \
1679 \
1680 if (!(softc->flags & BNXT_FLAG_TPA)) \
1681 return EINVAL; \
1682 \
1683 softc->hw_lro.arg = val; \
1684 bnxt_validate_hw_lro_settings(softc); \
1685 rc = bnxt_hwrm_vnic_tpa_cfg(softc); \
1686 \
1687 return rc; \
1688 }
1689
BNXT_HW_LRO_FN(bnxt_hw_lro_enable_disable,enable)1690 BNXT_HW_LRO_FN(bnxt_hw_lro_enable_disable, enable)
1691 BNXT_HW_LRO_FN(bnxt_hw_lro_set_mode, is_mode_gro)
1692 BNXT_HW_LRO_FN(bnxt_hw_lro_set_max_agg_segs, max_agg_segs)
1693 BNXT_HW_LRO_FN(bnxt_hw_lro_set_max_aggs, max_aggs)
1694 BNXT_HW_LRO_FN(bnxt_hw_lro_set_min_agg_len, min_agg_len)
1695
1696 #define BNXT_FLOW_CTRL_FN(fn_name, arg) \
1697 static int \
1698 fn_name(SYSCTL_HANDLER_ARGS) { \
1699 struct bnxt_softc *softc = arg1; \
1700 int rc; \
1701 int val; \
1702 \
1703 if (softc == NULL) \
1704 return EBUSY; \
1705 \
1706 val = softc->link_info.flow_ctrl.arg; \
1707 rc = sysctl_handle_int(oidp, &val, 0, req); \
1708 if (rc || !req->newptr) \
1709 return rc; \
1710 \
1711 if (val) \
1712 val = 1; \
1713 \
1714 if (softc->link_info.flow_ctrl.arg != val) { \
1715 softc->link_info.flow_ctrl.arg = val; \
1716 rc = bnxt_hwrm_set_link_setting(softc, true, false, false);\
1717 rc = bnxt_hwrm_port_phy_qcfg(softc); \
1718 } \
1719 \
1720 return rc; \
1721 }
1722
1723 BNXT_FLOW_CTRL_FN(bnxt_flow_ctrl_tx, tx)
1724 BNXT_FLOW_CTRL_FN(bnxt_flow_ctrl_rx, rx)
1725 BNXT_FLOW_CTRL_FN(bnxt_flow_ctrl_autoneg, autoneg)
1726 int
1727 bnxt_create_pause_fc_sysctls(struct bnxt_softc *softc)
1728 {
1729 struct sysctl_oid *oid = softc->flow_ctrl_oid;
1730
1731 if (!oid)
1732 return ENOMEM;
1733
1734 SYSCTL_ADD_PROC(&softc->flow_ctrl_ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
1735 "tx", CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, softc, 0,
1736 bnxt_flow_ctrl_tx, "A", "Enable or Disable Tx Flow Ctrl: 0 / 1");
1737
1738 SYSCTL_ADD_PROC(&softc->flow_ctrl_ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
1739 "rx", CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, softc, 0,
1740 bnxt_flow_ctrl_rx, "A", "Enable or Disable Tx Flow Ctrl: 0 / 1");
1741
1742 SYSCTL_ADD_PROC(&softc->flow_ctrl_ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
1743 "autoneg", CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, softc,
1744 0, bnxt_flow_ctrl_autoneg, "A",
1745 "Enable or Disable Autoneg Flow Ctrl: 0 / 1");
1746
1747 return 0;
1748 }
1749
1750 int
bnxt_create_hw_lro_sysctls(struct bnxt_softc * softc)1751 bnxt_create_hw_lro_sysctls(struct bnxt_softc *softc)
1752 {
1753 struct sysctl_oid *oid = softc->hw_lro_oid;
1754
1755 if (!oid)
1756 return ENOMEM;
1757
1758 SYSCTL_ADD_PROC(&softc->hw_lro_ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
1759 "enable", CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, softc,
1760 0, bnxt_hw_lro_enable_disable, "A",
1761 "Enable or Disable HW LRO: 0 / 1");
1762
1763 SYSCTL_ADD_PROC(&softc->hw_lro_ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
1764 "gro_mode", CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, softc,
1765 0, bnxt_hw_lro_set_mode, "A",
1766 "Set mode: 1 = GRO mode, 0 = RSC mode");
1767
1768 SYSCTL_ADD_PROC(&softc->hw_lro_ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
1769 "max_agg_segs", CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_MPSAFE,
1770 softc, 0, bnxt_hw_lro_set_max_agg_segs, "A",
1771 "Set Max Agg Seg Value (unit is Log2): "
1772 "0 (= 1 seg) / 1 (= 2 segs) / ... / 31 (= 2^31 segs)");
1773
1774 SYSCTL_ADD_PROC(&softc->hw_lro_ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
1775 "max_aggs", CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_MPSAFE,
1776 softc, 0, bnxt_hw_lro_set_max_aggs, "A",
1777 "Set Max Aggs Value (unit is Log2): "
1778 "0 (= 1 agg) / 1 (= 2 aggs) / ... / 7 (= 2^7 segs)");
1779
1780 SYSCTL_ADD_PROC(&softc->hw_lro_ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
1781 "min_agg_len", CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_MPSAFE,
1782 softc, 0, bnxt_hw_lro_set_min_agg_len, "A",
1783 "Min Agg Len: 1 to 9000");
1784
1785 return 0;
1786 }
1787
1788 static int
bnxt_dcb_dcbx_cap(SYSCTL_HANDLER_ARGS)1789 bnxt_dcb_dcbx_cap(SYSCTL_HANDLER_ARGS)
1790 {
1791 struct bnxt_softc *softc = arg1;
1792 int val;
1793 int rc;
1794
1795 if (softc == NULL)
1796 return EBUSY;
1797
1798 val = bnxt_dcb_getdcbx(softc);
1799 rc = sysctl_handle_int(oidp, &val, 0, req);
1800 if (rc || !req->newptr)
1801 return rc;
1802
1803 bnxt_dcb_setdcbx(softc, val);
1804
1805 return rc;
1806 }
1807
1808 static char
bnxt_ets_tsa_to_str(struct bnxt_softc * softc,uint32_t tc)1809 bnxt_ets_tsa_to_str(struct bnxt_softc *softc, uint32_t tc)
1810 {
1811 switch (softc->ieee_ets->tc_tsa[tc]) {
1812 case BNXT_IEEE_8021QAZ_TSA_STRICT:
1813 return 's';
1814 case BNXT_IEEE_8021QAZ_TSA_ETS:
1815 return 'e';
1816 default:
1817 return 'X';
1818
1819 }
1820 }
1821
1822 static uint32_t
bnxt_ets_str_to_tsa(char tsa_str)1823 bnxt_ets_str_to_tsa(char tsa_str)
1824 {
1825 switch (tsa_str) {
1826 case 's':
1827 return BNXT_IEEE_8021QAZ_TSA_STRICT;
1828 case 'e':
1829 return BNXT_IEEE_8021QAZ_TSA_ETS;
1830 default:
1831 return -1;
1832 }
1833 }
1834
1835 static int
bnxt_ets_get_val(struct bnxt_softc * softc,uint32_t type,uint32_t tc)1836 bnxt_ets_get_val(struct bnxt_softc *softc, uint32_t type, uint32_t tc)
1837 {
1838 switch (type) {
1839 case BNXT_TYPE_ETS_TSA:
1840 if (softc->ieee_ets)
1841 return softc->ieee_ets->tc_tsa[tc];
1842 break;
1843 case BNXT_TYPE_ETS_PRI2TC:
1844 if (softc->ieee_ets)
1845 return softc->ieee_ets->prio_tc[tc];
1846 break;
1847 case BNXT_TYPE_ETS_TCBW:
1848 if (softc->ieee_ets)
1849 return softc->ieee_ets->tc_tx_bw[tc];
1850 break;
1851 default:
1852 break;
1853 }
1854
1855 return -1;
1856 }
1857
1858 static void
bnxt_pfc_get_string(struct bnxt_softc * softc,char * buf,struct bnxt_ieee_pfc * pfc)1859 bnxt_pfc_get_string(struct bnxt_softc *softc, char *buf, struct bnxt_ieee_pfc *pfc)
1860 {
1861 uint32_t i;
1862 bool found = false;
1863
1864 for (i = 0; i < BNXT_IEEE_8021QAZ_MAX_TCS; i++) {
1865 if (pfc->pfc_en & (1 << i)) {
1866 if (found)
1867 buf += sprintf(buf, ", ");
1868 buf += sprintf(buf, "%d", i);
1869 found = true;
1870 }
1871 }
1872
1873 if (!found)
1874 buf += sprintf(buf, "none");
1875 }
1876
bnxt_get_tlv_selector_str(uint8_t selector)1877 static char *bnxt_get_tlv_selector_str(uint8_t selector)
1878 {
1879 switch (selector) {
1880 case BNXT_IEEE_8021QAZ_APP_SEL_ETHERTYPE:
1881 return "Ethertype";
1882 case BNXT_IEEE_8021QAZ_APP_SEL_DGRAM:
1883 return "UDP or DCCP";
1884 case BNXT_IEEE_8021QAZ_APP_SEL_DSCP:
1885 return "DSCP";
1886 default:
1887 return "Unknown";
1888 }
1889 }
1890
1891 static void
bnxt_app_tlv_get_string(struct bnxt_softc * softc,char * buf,struct bnxt_dcb_app * app,int num)1892 bnxt_app_tlv_get_string(struct bnxt_softc *softc, char *buf,
1893 struct bnxt_dcb_app *app, int num)
1894 {
1895 uint32_t i;
1896
1897 if (!num) {
1898 buf += sprintf(buf, " None");
1899 return;
1900 }
1901
1902 buf += sprintf(buf, "\n");
1903 for (i = 0; i < num; i++) {
1904 buf += sprintf(buf, "\tAPP#%0d:\tpri: %d,\tSel: %d,\t%s: %d\n",
1905 i,
1906 app[i].priority,
1907 app[i].selector,
1908 bnxt_get_tlv_selector_str(app[i].selector),
1909 app[i].protocol);
1910 }
1911 }
1912
1913 static void
bnxt_ets_get_string(struct bnxt_softc * softc,char * buf)1914 bnxt_ets_get_string(struct bnxt_softc *softc, char *buf)
1915 {
1916 uint32_t type, i;
1917
1918 type = BNXT_TYPE_ETS_TSA;
1919 for (type = 0; type < BNXT_TYPE_ETS_MAX; type++) {
1920 for (i = 0; i < BNXT_IEEE_8021QAZ_MAX_TCS; i++) {
1921 if (i == 0)
1922 buf += sprintf(buf, "%s:", BNXT_ETS_TYPE_STR[type]);
1923
1924 if (!softc->ieee_ets)
1925 buf += sprintf(buf, "x");
1926 else if (type == BNXT_TYPE_ETS_TSA)
1927 buf += sprintf(buf, "%c", bnxt_ets_tsa_to_str(softc, i));
1928 else
1929 buf += sprintf(buf, "%d", bnxt_ets_get_val(softc, type, i));
1930
1931 if (i != BNXT_IEEE_8021QAZ_MAX_TCS - 1)
1932 buf += sprintf(buf, ",");
1933 }
1934 if (type != BNXT_TYPE_ETS_MAX - 1)
1935 buf += sprintf(buf, "#");
1936 }
1937 }
1938
1939 static int
bnxt_dcb_list_app(SYSCTL_HANDLER_ARGS)1940 bnxt_dcb_list_app(SYSCTL_HANDLER_ARGS)
1941 {
1942 struct bnxt_dcb_app app[128] = {0};
1943 struct bnxt_softc *softc = arg1;
1944 int rc, num_inputs = 0;
1945 char *buf;
1946
1947 if (softc == NULL)
1948 return EBUSY;
1949
1950 #define BNXT_APP_TLV_STR_LEN 4096
1951 buf = malloc(BNXT_APP_TLV_STR_LEN, M_DEVBUF, M_NOWAIT | M_ZERO);
1952 if (!buf)
1953 return ENOMEM;
1954
1955 bnxt_dcb_ieee_listapp(softc, app, &num_inputs);
1956 bnxt_app_tlv_get_string(softc, buf, app, num_inputs);
1957
1958 rc = sysctl_handle_string(oidp, buf, BNXT_APP_TLV_STR_LEN, req);
1959 if (rc || req->newptr == NULL)
1960 goto end;
1961
1962 end:
1963 free(buf, M_DEVBUF);
1964 return rc;
1965 }
1966
1967 static int
bnxt_dcb_del_app(SYSCTL_HANDLER_ARGS)1968 bnxt_dcb_del_app(SYSCTL_HANDLER_ARGS)
1969 {
1970 struct bnxt_softc *softc = arg1;
1971 struct bnxt_dcb_app app = {0};
1972 char buf[256] = {0};
1973 int rc, num_inputs;
1974
1975 if (softc == NULL)
1976 return EBUSY;
1977
1978 rc = sysctl_handle_string(oidp, buf, sizeof(buf), req);
1979 if (rc || req->newptr == NULL)
1980 return rc;
1981
1982 num_inputs = sscanf(buf, "%hhu,%hhu,%hd", &app.priority, &app.selector, &app.protocol);
1983
1984 if (num_inputs != 3) {
1985 device_printf(softc->dev,
1986 "Invalid app tlv syntax, inputs = %d\n", num_inputs);
1987 return EINVAL;
1988 }
1989
1990 bnxt_dcb_ieee_delapp(softc, &app);
1991
1992 return rc;
1993 }
1994 static int
bnxt_dcb_set_app(SYSCTL_HANDLER_ARGS)1995 bnxt_dcb_set_app(SYSCTL_HANDLER_ARGS)
1996 {
1997 struct bnxt_softc *softc = arg1;
1998 struct bnxt_dcb_app app = {0};
1999 char buf[256] = {0};
2000 int rc, num_inputs;
2001
2002 if (softc == NULL)
2003 return EBUSY;
2004
2005 rc = sysctl_handle_string(oidp, buf, sizeof(buf), req);
2006 if (rc || req->newptr == NULL)
2007 return rc;
2008
2009 num_inputs = sscanf(buf, "%hhu,%hhu,%hd", &app.priority, &app.selector, &app.protocol);
2010
2011 if (num_inputs != 3) {
2012 device_printf(softc->dev,
2013 "Invalid app tlv syntax, inputs = %d\n", num_inputs);
2014 return EINVAL;
2015 }
2016
2017 bnxt_dcb_ieee_setapp(softc, &app);
2018
2019 return rc;
2020 }
2021
2022 static int
bnxt_dcb_pfc(SYSCTL_HANDLER_ARGS)2023 bnxt_dcb_pfc(SYSCTL_HANDLER_ARGS)
2024 {
2025 struct bnxt_softc *softc = arg1;
2026 struct bnxt_ieee_pfc pfc = {0};
2027 int rc, i, num_inputs;
2028 char buf[256] = {0};
2029 int pri_mask = 0;
2030 char pri[8];
2031
2032 if (softc == NULL)
2033 return EBUSY;
2034
2035 rc = bnxt_dcb_ieee_getpfc(softc, &pfc);
2036 if (!rc)
2037 bnxt_pfc_get_string(softc, buf, &pfc);
2038 else
2039 sprintf(buf, "## getpfc failed with error %d ##", rc);
2040
2041 rc = sysctl_handle_string(oidp, buf, sizeof(buf), req);
2042 if (rc || req->newptr == NULL)
2043 return rc;
2044
2045 /* Check for 'none' string first */
2046 if (sscanf(buf, "%s", buf) == 1) {
2047 if (strncmp(buf, "none", 8) == 0) {
2048 goto configure;
2049 }
2050 }
2051 num_inputs = sscanf(buf, "%hhu,%hhu,%hhu,%hhu,%hhu,%hhu,%hhu,%hhu",
2052 &pri[0], &pri[1], &pri[2], &pri[3], &pri[4],
2053 &pri[5], &pri[6], &pri[7]);
2054
2055 if (num_inputs < 1 || num_inputs > 8) {
2056 device_printf(softc->dev,
2057 "Invalid pfc syntax, inputs = %d\n", num_inputs);
2058 return EINVAL;
2059 }
2060
2061 for (i = 0; i < num_inputs; i++) {
2062 if (pri[i] > 7 || pri[i] < 0) {
2063 device_printf(softc->dev,
2064 "Invalid priority %d. Valid priorties are "
2065 "from 0 to 7 and string \"none\".\n", pri[i]);
2066 return EINVAL;
2067 }
2068
2069 pri_mask |= (1 << pri[i]) & 0xFF;
2070 }
2071
2072 configure:
2073 pfc.pfc_en = pri_mask;
2074 rc = bnxt_dcb_ieee_setpfc(softc, &pfc);
2075 if (rc)
2076 device_printf(softc->dev,
2077 "setpfc failed with status %d\n", rc);
2078 return rc;
2079 }
2080
2081 static int
bnxt_dcb_ets(SYSCTL_HANDLER_ARGS)2082 bnxt_dcb_ets(SYSCTL_HANDLER_ARGS)
2083 {
2084 struct bnxt_softc *softc = arg1;
2085 struct bnxt_ieee_ets ets = {0};
2086 int rc = 0, i, num_inputs;
2087 char buf[256] = {0};
2088 char tsa[8];
2089
2090 if (softc == NULL)
2091 return EBUSY;
2092
2093 rc = bnxt_dcb_ieee_getets(softc, &ets);
2094 if (!rc)
2095 bnxt_ets_get_string(softc, buf);
2096 else
2097 sprintf(buf, "## getets failed with error %d ##", rc);
2098
2099 rc = sysctl_handle_string(oidp, buf, sizeof(buf), req);
2100 if (rc || req->newptr == NULL)
2101 return rc;
2102
2103 num_inputs = sscanf(buf, "tsa:%c,%c,%c,%c,%c,%c,%c,%c#"
2104 "pri2tc:%hhu,%hhu,%hhu,%hhu,%hhu,%hhu,%hhu,%hhu#"
2105 "tcbw:%hhu,%hhu,%hhu,%hhu,%hhu,%hhu,%hhu,%hhu",
2106 &tsa[0], &tsa[1], &tsa[2], &tsa[3], &tsa[4], &tsa[5], &tsa[6], &tsa[7],
2107 &ets.prio_tc[0], &ets.prio_tc[1], &ets.prio_tc[2], &ets.prio_tc[3],
2108 &ets.prio_tc[4], &ets.prio_tc[5], &ets.prio_tc[6], &ets.prio_tc[7],
2109 &ets.tc_tx_bw[0], &ets.tc_tx_bw[1], &ets.tc_tx_bw[2], &ets.tc_tx_bw[3],
2110 &ets.tc_tx_bw[4], &ets.tc_tx_bw[5], &ets.tc_tx_bw[6], &ets.tc_tx_bw[7]);
2111
2112 if (num_inputs != 24)
2113 return EINVAL;
2114
2115 for ( i= 0; i < 8; i++)
2116 ets.tc_tsa[i] = bnxt_ets_str_to_tsa(tsa[i]);
2117
2118 rc = bnxt_dcb_ieee_setets(softc, &ets);
2119
2120 return rc;
2121 }
2122
2123 int
bnxt_create_dcb_sysctls(struct bnxt_softc * softc)2124 bnxt_create_dcb_sysctls(struct bnxt_softc *softc)
2125 {
2126 struct sysctl_oid *oid = softc->dcb_oid;
2127
2128 if (!oid)
2129 return ENOMEM;
2130
2131 SYSCTL_ADD_PROC(&softc->dcb_ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
2132 "dcbx_cap", CTLTYPE_INT | CTLFLAG_RWTUN, softc,
2133 0, bnxt_dcb_dcbx_cap, "A",
2134 "Enable or Disable LRO: 0 / 1");
2135
2136 SYSCTL_ADD_PROC(&softc->dcb_ctx, SYSCTL_CHILDREN(oid), OID_AUTO, "ets",
2137 CTLTYPE_STRING | CTLFLAG_RWTUN, softc, 0,
2138 bnxt_dcb_ets, "A", "Enhanced Transmission Selection (ETS)");
2139
2140 SYSCTL_ADD_PROC(&softc->dcb_ctx, SYSCTL_CHILDREN(oid), OID_AUTO, "pfc",
2141 CTLTYPE_STRING | CTLFLAG_RWTUN, softc, 0,
2142 bnxt_dcb_pfc, "A", "Enhanced Transmission Selection (ETS)");
2143
2144 SYSCTL_ADD_PROC(&softc->dcb_ctx, SYSCTL_CHILDREN(oid), OID_AUTO, "set_apptlv",
2145 CTLTYPE_STRING | CTLFLAG_WR, softc, 0,
2146 bnxt_dcb_set_app, "A", "Set App TLV");
2147
2148 SYSCTL_ADD_PROC(&softc->dcb_ctx, SYSCTL_CHILDREN(oid), OID_AUTO, "del_apptlv",
2149 CTLTYPE_STRING | CTLFLAG_WR, softc, 0,
2150 bnxt_dcb_del_app, "A", "Delete App TLV");
2151
2152 SYSCTL_ADD_PROC(&softc->dcb_ctx, SYSCTL_CHILDREN(oid), OID_AUTO, "list_apptlv",
2153 CTLTYPE_STRING | CTLFLAG_RD, softc, 0,
2154 bnxt_dcb_list_app, "A", "List all App TLVs");
2155
2156 return 0;
2157 }
2158
2159 int
bnxt_create_config_sysctls_post(struct bnxt_softc * softc)2160 bnxt_create_config_sysctls_post(struct bnxt_softc *softc)
2161 {
2162 /* Nothing for now, meant for future expansion */
2163 return 0;
2164 }
2165