]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/dev/bnxt/bnxt_sysctl.c
bnxt: Choose better HW LRO defaults for performance
[FreeBSD/FreeBSD.git] / sys / dev / bnxt / bnxt_sysctl.c
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/cdefs.h>
30 __FBSDID("$FreeBSD$");
31
32 #include <sys/types.h>
33 #include <sys/sysctl.h>
34
35 #include "bnxt.h"
36 #include "bnxt_hwrm.h"
37 #include "bnxt_sysctl.h"
38
39 static int bnxt_vlan_only_sysctl(SYSCTL_HANDLER_ARGS);
40 /*
41  * We want to create:
42  * dev.bnxt.0.hwstats.txq0
43  * dev.bnxt.0.hwstats.txq0.txmbufs
44  * dev.bnxt.0.hwstats.rxq0
45  * dev.bnxt.0.hwstats.txq0.rxmbufs
46  * so the hwstats ctx list needs to be created in attach_post and populated
47  * during init.
48  *
49  * Then, it needs to be cleaned up in stop.
50  */
51
52 int
53 bnxt_init_sysctl_ctx(struct bnxt_softc *softc)
54 {
55         struct sysctl_ctx_list *ctx;
56
57         sysctl_ctx_init(&softc->hw_stats);
58         ctx = device_get_sysctl_ctx(softc->dev);
59         softc->hw_stats_oid = SYSCTL_ADD_NODE(ctx,
60             SYSCTL_CHILDREN(device_get_sysctl_tree(softc->dev)), OID_AUTO,
61             "hwstats", CTLFLAG_RD, 0, "hardware statistics");
62         if (!softc->hw_stats_oid) {
63                 sysctl_ctx_free(&softc->hw_stats);
64                 return ENOMEM;
65         }
66
67         sysctl_ctx_init(&softc->ver_info->ver_ctx);
68         ctx = device_get_sysctl_ctx(softc->dev);
69         softc->ver_info->ver_oid = SYSCTL_ADD_NODE(ctx,
70             SYSCTL_CHILDREN(device_get_sysctl_tree(softc->dev)), OID_AUTO,
71             "ver", CTLFLAG_RD, 0, "hardware/firmware version information");
72         if (!softc->ver_info->ver_oid) {
73                 sysctl_ctx_free(&softc->ver_info->ver_ctx);
74                 return ENOMEM;
75         }
76
77         sysctl_ctx_init(&softc->nvm_info->nvm_ctx);
78         ctx = device_get_sysctl_ctx(softc->dev);
79         softc->nvm_info->nvm_oid = SYSCTL_ADD_NODE(ctx,
80             SYSCTL_CHILDREN(device_get_sysctl_tree(softc->dev)), OID_AUTO,
81             "nvram", CTLFLAG_RD, 0, "nvram information");
82         if (!softc->nvm_info->nvm_oid) {
83                 sysctl_ctx_free(&softc->nvm_info->nvm_ctx);
84                 return ENOMEM;
85         }
86
87         sysctl_ctx_init(&softc->hw_lro_ctx);
88         ctx = device_get_sysctl_ctx(softc->dev);
89         softc->hw_lro_oid = SYSCTL_ADD_NODE(ctx,
90             SYSCTL_CHILDREN(device_get_sysctl_tree(softc->dev)), OID_AUTO,
91             "hw_lro", CTLFLAG_RD, 0, "hardware lro");
92         if (!softc->hw_lro_oid) {
93                 sysctl_ctx_free(&softc->hw_lro_ctx);
94                 return ENOMEM;
95         }
96
97         return 0;
98 }
99
100 int
101 bnxt_free_sysctl_ctx(struct bnxt_softc *softc)
102 {
103         int orc;
104         int rc = 0;
105
106         if (softc->hw_stats_oid != NULL) {
107                 orc = sysctl_ctx_free(&softc->hw_stats);
108                 if (orc)
109                         rc = orc;
110                 else
111                         softc->hw_stats_oid = NULL;
112         }
113         if (softc->ver_info->ver_oid != NULL) {
114                 orc = sysctl_ctx_free(&softc->ver_info->ver_ctx);
115                 if (orc)
116                         rc = orc;
117                 else
118                         softc->ver_info->ver_oid = NULL;
119         }
120         if (softc->nvm_info->nvm_oid != NULL) {
121                 orc = sysctl_ctx_free(&softc->nvm_info->nvm_ctx);
122                 if (orc)
123                         rc = orc;
124                 else
125                         softc->nvm_info->nvm_oid = NULL;
126         }
127         if (softc->hw_lro_oid != NULL) {
128                 orc = sysctl_ctx_free(&softc->hw_lro_ctx);
129                 if (orc)
130                         rc = orc;
131                 else
132                         softc->hw_lro_oid = NULL;
133         }
134
135         return rc;
136 }
137
138 int
139 bnxt_create_tx_sysctls(struct bnxt_softc *softc, int txr)
140 {
141         struct sysctl_oid *oid;
142         struct ctx_hw_stats *tx_stats = (void *)softc->tx_stats.idi_vaddr;
143         char    name[32];
144         char    desc[64];
145
146         sprintf(name, "txq%d", txr);
147         sprintf(desc, "transmit queue %d", txr);
148         oid = SYSCTL_ADD_NODE(&softc->hw_stats,
149             SYSCTL_CHILDREN(softc->hw_stats_oid), OID_AUTO, name, CTLFLAG_RD, 0,
150             desc);
151         if (!oid)
152                 return ENOMEM;
153
154
155         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
156             "ucast_pkts", CTLFLAG_RD, &tx_stats[txr].tx_ucast_pkts,
157             "unicast packets sent");
158         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
159             "mcast_pkts", CTLFLAG_RD, &tx_stats[txr].tx_mcast_pkts,
160             "multicast packets sent");
161         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
162             "bcast_pkts", CTLFLAG_RD, &tx_stats[txr].tx_bcast_pkts,
163             "broadcast packets sent");
164         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
165             "discard_pkts", CTLFLAG_RD,
166             &tx_stats[txr].tx_discard_pkts, "discarded transmit packets");
167         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
168             "drop_pkts", CTLFLAG_RD, &tx_stats[txr].tx_drop_pkts,
169             "dropped transmit packets");
170         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
171             "ucast_bytes", CTLFLAG_RD, &tx_stats[txr].tx_ucast_bytes,
172             "unicast bytes sent");
173         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
174             "mcast_bytes", CTLFLAG_RD, &tx_stats[txr].tx_mcast_bytes,
175             "multicast bytes sent");
176         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
177             "bcast_bytes", CTLFLAG_RD, &tx_stats[txr].tx_bcast_bytes,
178             "broadcast bytes sent");
179
180         return 0;
181 }
182
183 int
184 bnxt_create_port_stats_sysctls(struct bnxt_softc *softc)
185 {
186         struct sysctl_oid *oid;
187         char    name[32];
188         char    desc[64];
189
190         sprintf(name, "port_stats");
191         sprintf(desc, "Port Stats");
192         oid = SYSCTL_ADD_NODE(&softc->hw_stats,
193                         SYSCTL_CHILDREN(softc->hw_stats_oid), OID_AUTO, name, CTLFLAG_RD, 0,
194                         desc);
195         if (!oid)
196                 return ENOMEM;
197
198         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
199             "tx_64b_frames", CTLFLAG_RD,
200             &softc->tx_port_stats->tx_64b_frames, "Transmitted 64b frames");
201         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
202             "tx_65b_127b_frames", CTLFLAG_RD,
203             &softc->tx_port_stats->tx_65b_127b_frames, 
204             "Transmitted 65b 127b frames");
205         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
206             "tx_128b_255b_frames", CTLFLAG_RD,
207             &softc->tx_port_stats->tx_128b_255b_frames, 
208             "Transmitted 128b 255b frames");
209         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
210             "tx_256b_511b_frames", CTLFLAG_RD,
211             &softc->tx_port_stats->tx_256b_511b_frames, 
212             "Transmitted 256b 511b frames");
213         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
214             "tx_512b_1023b_frames", CTLFLAG_RD,
215             &softc->tx_port_stats->tx_512b_1023b_frames, 
216             "Transmitted 512b 1023b frames");
217         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
218             "tx_1024b_1518_frames", CTLFLAG_RD,
219             &softc->tx_port_stats->tx_1024b_1518_frames, 
220             "Transmitted 1024b 1518 frames");
221         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
222             "tx_good_vlan_frames", CTLFLAG_RD,
223             &softc->tx_port_stats->tx_good_vlan_frames, 
224             "Transmitted good vlan frames");
225         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
226             "tx_1519b_2047_frames", CTLFLAG_RD,
227             &softc->tx_port_stats->tx_1519b_2047_frames, 
228             "Transmitted 1519b 2047 frames");
229         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
230             "tx_2048b_4095b_frames", CTLFLAG_RD,
231             &softc->tx_port_stats->tx_2048b_4095b_frames, 
232             "Transmitted 2048b 4095b frames");
233         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
234             "tx_4096b_9216b_frames", CTLFLAG_RD,
235             &softc->tx_port_stats->tx_4096b_9216b_frames, 
236             "Transmitted 4096b 9216b frames");
237         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
238             "tx_9217b_16383b_frames", CTLFLAG_RD, 
239             &softc->tx_port_stats->tx_9217b_16383b_frames, 
240             "Transmitted 9217b 16383b frames");
241         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
242             "tx_good_frames", CTLFLAG_RD,
243             &softc->tx_port_stats->tx_good_frames, "Transmitted good frames");
244         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
245             "tx_total_frames", CTLFLAG_RD,
246             &softc->tx_port_stats->tx_total_frames, "Transmitted total frames");
247         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
248             "tx_ucast_frames", CTLFLAG_RD,
249             &softc->tx_port_stats->tx_ucast_frames, "Transmitted ucast frames");
250         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
251             "tx_mcast_frames", CTLFLAG_RD,
252             &softc->tx_port_stats->tx_mcast_frames, "Transmitted mcast frames");
253         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
254             "tx_bcast_frames", CTLFLAG_RD,
255             &softc->tx_port_stats->tx_bcast_frames, "Transmitted bcast frames");
256         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
257             "tx_pause_frames", CTLFLAG_RD,
258             &softc->tx_port_stats->tx_pause_frames, "Transmitted pause frames");
259         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
260             "tx_pfc_frames", CTLFLAG_RD,
261             &softc->tx_port_stats->tx_pfc_frames, "Transmitted pfc frames");
262         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
263             "tx_jabber_frames", CTLFLAG_RD,
264             &softc->tx_port_stats->tx_jabber_frames, "Transmitted jabber frames");
265         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
266             "tx_fcs_err_frames", CTLFLAG_RD,
267             &softc->tx_port_stats->tx_fcs_err_frames, 
268             "Transmitted fcs err frames");
269         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
270             "tx_control_frames", CTLFLAG_RD,
271             &softc->tx_port_stats->tx_control_frames, 
272             "Transmitted control frames");
273         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
274             "tx_oversz_frames", CTLFLAG_RD,
275             &softc->tx_port_stats->tx_oversz_frames, "Transmitted oversz frames");
276         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
277             "tx_single_dfrl_frames", CTLFLAG_RD,
278             &softc->tx_port_stats->tx_single_dfrl_frames, 
279             "Transmitted single dfrl frames");
280         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
281             "tx_multi_dfrl_frames", CTLFLAG_RD,
282             &softc->tx_port_stats->tx_multi_dfrl_frames, 
283             "Transmitted multi dfrl frames");
284         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
285             "tx_single_coll_frames", CTLFLAG_RD,
286             &softc->tx_port_stats->tx_single_coll_frames, 
287             "Transmitted single coll frames");
288         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
289             "tx_multi_coll_frames", CTLFLAG_RD,
290             &softc->tx_port_stats->tx_multi_coll_frames, 
291             "Transmitted multi coll frames");
292         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
293             "tx_late_coll_frames", CTLFLAG_RD,
294             &softc->tx_port_stats->tx_late_coll_frames, 
295             "Transmitted late coll frames");
296         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
297             "tx_excessive_coll_frames", CTLFLAG_RD,
298             &softc->tx_port_stats->tx_excessive_coll_frames, 
299             "Transmitted excessive coll frames");
300         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
301             "tx_frag_frames", CTLFLAG_RD,
302             &softc->tx_port_stats->tx_frag_frames, "Transmitted frag frames");
303         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
304             "tx_err", CTLFLAG_RD,
305             &softc->tx_port_stats->tx_err, "Transmitted err");
306         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
307             "tx_tagged_frames", CTLFLAG_RD,
308             &softc->tx_port_stats->tx_tagged_frames, "Transmitted tagged frames");
309         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
310             "tx_dbl_tagged_frames", CTLFLAG_RD,
311             &softc->tx_port_stats->tx_dbl_tagged_frames, 
312             "Transmitted dbl tagged frames");
313         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
314             "tx_runt_frames", CTLFLAG_RD,
315             &softc->tx_port_stats->tx_runt_frames, "Transmitted runt frames");
316         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
317             "tx_fifo_underruns", CTLFLAG_RD,
318             &softc->tx_port_stats->tx_fifo_underruns, 
319             "Transmitted fifo underruns");
320         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
321             "tx_pfc_ena_frames_pri0", CTLFLAG_RD,
322             &softc->tx_port_stats->tx_pfc_ena_frames_pri0, 
323             "Transmitted pfc ena frames pri0");
324         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
325             "tx_pfc_ena_frames_pri1", CTLFLAG_RD,
326             &softc->tx_port_stats->tx_pfc_ena_frames_pri1, 
327             "Transmitted pfc ena frames pri1");
328         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
329             "tx_pfc_ena_frames_pri2", CTLFLAG_RD,
330             &softc->tx_port_stats->tx_pfc_ena_frames_pri2, 
331             "Transmitted pfc ena frames pri2");
332         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
333             "tx_pfc_ena_frames_pri3", CTLFLAG_RD,
334             &softc->tx_port_stats->tx_pfc_ena_frames_pri3, 
335             "Transmitted pfc ena frames pri3");
336         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
337             "tx_pfc_ena_frames_pri4", CTLFLAG_RD,
338             &softc->tx_port_stats->tx_pfc_ena_frames_pri4, 
339             "Transmitted pfc ena frames pri4");
340         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
341             "tx_pfc_ena_frames_pri5", CTLFLAG_RD,
342             &softc->tx_port_stats->tx_pfc_ena_frames_pri5, 
343             "Transmitted pfc ena frames pri5");
344         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
345             "tx_pfc_ena_frames_pri6", CTLFLAG_RD,
346             &softc->tx_port_stats->tx_pfc_ena_frames_pri6, 
347             "Transmitted pfc ena frames pri6");
348         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
349             "tx_pfc_ena_frames_pri7", CTLFLAG_RD,
350             &softc->tx_port_stats->tx_pfc_ena_frames_pri7, 
351             "Transmitted pfc ena frames pri7");
352         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
353             "tx_eee_lpi_events", CTLFLAG_RD,
354             &softc->tx_port_stats->tx_eee_lpi_events, 
355             "Transmitted eee lpi events");
356         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
357             "tx_eee_lpi_duration", CTLFLAG_RD,
358             &softc->tx_port_stats->tx_eee_lpi_duration, 
359             "Transmitted eee lpi duration");
360         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
361             "tx_llfc_logical_msgs", CTLFLAG_RD,
362             &softc->tx_port_stats->tx_llfc_logical_msgs, 
363             "Transmitted llfc logical msgs");
364         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
365             "tx_hcfc_msgs", CTLFLAG_RD,
366             &softc->tx_port_stats->tx_hcfc_msgs, "Transmitted hcfc msgs");
367         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
368             "tx_total_collisions", CTLFLAG_RD,
369             &softc->tx_port_stats->tx_total_collisions, 
370             "Transmitted total collisions");
371         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
372             "tx_bytes", CTLFLAG_RD,
373             &softc->tx_port_stats->tx_bytes, "Transmitted bytes");
374         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
375             "tx_xthol_frames", CTLFLAG_RD,
376             &softc->tx_port_stats->tx_xthol_frames, "Transmitted xthol frames");
377         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
378             "tx_stat_discard", CTLFLAG_RD,
379             &softc->tx_port_stats->tx_stat_discard, "Transmitted stat discard");
380         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
381             "tx_stat_error", CTLFLAG_RD,
382             &softc->tx_port_stats->tx_stat_error, "Transmitted stat error");
383         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
384             "rx_64b_frames", CTLFLAG_RD,
385             &softc->rx_port_stats->rx_64b_frames, "Received 64b frames");
386         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
387             "rx_65b_127b_frames", CTLFLAG_RD,
388             &softc->rx_port_stats->rx_65b_127b_frames, "Received 65b 127b frames");
389         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
390             "rx_128b_255b_frames", CTLFLAG_RD,
391             &softc->rx_port_stats->rx_128b_255b_frames, 
392             "Received 128b 255b frames");
393         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
394             "rx_256b_511b_frames", CTLFLAG_RD,
395             &softc->rx_port_stats->rx_256b_511b_frames, 
396             "Received 256b 511b frames");
397         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
398             "rx_512b_1023b_frames", CTLFLAG_RD,
399             &softc->rx_port_stats->rx_512b_1023b_frames, 
400             "Received 512b 1023b frames");
401         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
402             "rx_1024b_1518_frames", CTLFLAG_RD,
403             &softc->rx_port_stats->rx_1024b_1518_frames, 
404             "Received 1024b 1518 frames");
405         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
406             "rx_good_vlan_frames", CTLFLAG_RD,
407             &softc->rx_port_stats->rx_good_vlan_frames, 
408             "Received good vlan frames");
409         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
410             "rx_1519b_2047b_frames", CTLFLAG_RD,
411             &softc->rx_port_stats->rx_1519b_2047b_frames, 
412             "Received 1519b 2047b frames");
413         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
414             "rx_2048b_4095b_frames", CTLFLAG_RD,
415             &softc->rx_port_stats->rx_2048b_4095b_frames, 
416             "Received 2048b 4095b frames");
417         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
418             "rx_4096b_9216b_frames", CTLFLAG_RD,
419             &softc->rx_port_stats->rx_4096b_9216b_frames, 
420             "Received 4096b 9216b frames");
421         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
422             "rx_9217b_16383b_frames", CTLFLAG_RD,
423             &softc->rx_port_stats->rx_9217b_16383b_frames, 
424             "Received 9217b 16383b frames");
425         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
426             "rx_total_frames", CTLFLAG_RD,
427             &softc->rx_port_stats->rx_total_frames, "Received total frames");
428         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
429             "rx_ucast_frames", CTLFLAG_RD,
430             &softc->rx_port_stats->rx_ucast_frames, "Received ucast frames");
431         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
432             "rx_mcast_frames", CTLFLAG_RD,
433             &softc->rx_port_stats->rx_mcast_frames, "Received mcast frames");
434         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
435             "rx_bcast_frames", CTLFLAG_RD,
436             &softc->rx_port_stats->rx_bcast_frames, "Received bcast frames");
437         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
438             "rx_fcs_err_frames", CTLFLAG_RD,
439             &softc->rx_port_stats->rx_fcs_err_frames, "Received fcs err frames");
440         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
441             "rx_ctrl_frames", CTLFLAG_RD,
442             &softc->rx_port_stats->rx_ctrl_frames, "Received ctrl frames");
443         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
444             "rx_pause_frames", CTLFLAG_RD,
445             &softc->rx_port_stats->rx_pause_frames, "Received pause frames");
446         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
447             "rx_pfc_frames", CTLFLAG_RD,
448             &softc->rx_port_stats->rx_pfc_frames, "Received pfc frames");
449         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
450             "rx_unsupported_opcode_frames", CTLFLAG_RD,
451             &softc->rx_port_stats->rx_unsupported_opcode_frames, 
452             "Received unsupported opcode frames");
453         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
454             "rx_unsupported_da_pausepfc_frames", CTLFLAG_RD,
455             &softc->rx_port_stats->rx_unsupported_da_pausepfc_frames, 
456             "Received unsupported da pausepfc frames");
457         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
458             "rx_wrong_sa_frames", CTLFLAG_RD,
459             &softc->rx_port_stats->rx_wrong_sa_frames, 
460             "Received wrong sa frames");
461         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
462             "rx_align_err_frames", CTLFLAG_RD,
463             &softc->rx_port_stats->rx_align_err_frames, 
464             "Received align err frames");
465         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
466             "rx_oor_len_frames", CTLFLAG_RD,
467             &softc->rx_port_stats->rx_oor_len_frames, 
468             "Received oor len frames");
469         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
470             "rx_code_err_frames", CTLFLAG_RD,
471             &softc->rx_port_stats->rx_code_err_frames, 
472             "Received code err frames");
473         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
474             "rx_false_carrier_frames", CTLFLAG_RD,
475             &softc->rx_port_stats->rx_false_carrier_frames, 
476             "Received false carrier frames");
477         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
478             "rx_ovrsz_frames", CTLFLAG_RD,
479             &softc->rx_port_stats->rx_ovrsz_frames, 
480             "Received ovrsz frames");
481         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
482             "rx_jbr_frames", CTLFLAG_RD,
483             &softc->rx_port_stats->rx_jbr_frames, 
484             "Received jbr frames");
485         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
486             "rx_mtu_err_frames", CTLFLAG_RD,
487             &softc->rx_port_stats->rx_mtu_err_frames, 
488             "Received mtu err frames");
489         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
490             "rx_match_crc_frames", CTLFLAG_RD,
491             &softc->rx_port_stats->rx_match_crc_frames, 
492             "Received match crc frames");
493         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
494             "rx_promiscuous_frames", CTLFLAG_RD,
495             &softc->rx_port_stats->rx_promiscuous_frames, 
496             "Received promiscuous frames");
497         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
498             "rx_tagged_frames", CTLFLAG_RD,
499             &softc->rx_port_stats->rx_tagged_frames, 
500             "Received tagged frames");
501         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
502             "rx_double_tagged_frames", CTLFLAG_RD,
503             &softc->rx_port_stats->rx_double_tagged_frames, 
504             "Received double tagged frames");
505         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
506             "rx_trunc_frames", CTLFLAG_RD,
507             &softc->rx_port_stats->rx_trunc_frames, 
508             "Received trunc frames");
509         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
510             "rx_good_frames", CTLFLAG_RD,
511             &softc->rx_port_stats->rx_good_frames, 
512             "Received good frames");
513         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
514             "rx_pfc_xon2xoff_frames_pri0", CTLFLAG_RD,
515             &softc->rx_port_stats->rx_pfc_xon2xoff_frames_pri0, 
516             "Received pfc xon2xoff frames pri0");
517         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
518             "rx_pfc_xon2xoff_frames_pri1", CTLFLAG_RD,
519             &softc->rx_port_stats->rx_pfc_xon2xoff_frames_pri1, 
520             "Received pfc xon2xoff frames pri1");
521         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
522             "rx_pfc_xon2xoff_frames_pri2", CTLFLAG_RD,
523             &softc->rx_port_stats->rx_pfc_xon2xoff_frames_pri2, 
524             "Received pfc xon2xoff frames pri2");
525         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
526             "rx_pfc_xon2xoff_frames_pri3", CTLFLAG_RD,
527             &softc->rx_port_stats->rx_pfc_xon2xoff_frames_pri3, 
528             "Received pfc xon2xoff frames pri3");
529         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
530             "rx_pfc_xon2xoff_frames_pri4", CTLFLAG_RD,
531             &softc->rx_port_stats->rx_pfc_xon2xoff_frames_pri4, 
532             "Received pfc xon2xoff frames pri4");
533         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
534             "rx_pfc_xon2xoff_frames_pri5", CTLFLAG_RD,
535             &softc->rx_port_stats->rx_pfc_xon2xoff_frames_pri5, 
536             "Received pfc xon2xoff frames pri5");
537         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
538             "rx_pfc_xon2xoff_frames_pri6", CTLFLAG_RD,
539             &softc->rx_port_stats->rx_pfc_xon2xoff_frames_pri6, 
540             "Received pfc xon2xoff frames pri6");
541         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
542             "rx_pfc_xon2xoff_frames_pri7", CTLFLAG_RD,
543             &softc->rx_port_stats->rx_pfc_xon2xoff_frames_pri7, 
544             "Received pfc xon2xoff frames pri7");
545         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
546             "rx_pfc_ena_frames_pri0", CTLFLAG_RD,
547             &softc->rx_port_stats->rx_pfc_ena_frames_pri0, 
548             "Received pfc ena frames pri0");
549         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
550             "rx_pfc_ena_frames_pri1", CTLFLAG_RD,
551             &softc->rx_port_stats->rx_pfc_ena_frames_pri1, 
552             "Received pfc ena frames pri1");
553         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
554             "rx_pfc_ena_frames_pri2", CTLFLAG_RD,
555             &softc->rx_port_stats->rx_pfc_ena_frames_pri2, 
556             "Received pfc ena frames pri2");
557         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
558             "rx_pfc_ena_frames_pri3", CTLFLAG_RD,
559             &softc->rx_port_stats->rx_pfc_ena_frames_pri3, 
560             "Received pfc ena frames pri3");
561         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
562             "rx_pfc_ena_frames_pri4", CTLFLAG_RD,
563             &softc->rx_port_stats->rx_pfc_ena_frames_pri4, 
564             "Received pfc ena frames pri4");
565         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
566             "rx_pfc_ena_frames_pri5", CTLFLAG_RD,
567             &softc->rx_port_stats->rx_pfc_ena_frames_pri5, 
568             "Received pfc ena frames pri5");
569         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
570             "rx_pfc_ena_frames_pri6", CTLFLAG_RD,
571             &softc->rx_port_stats->rx_pfc_ena_frames_pri6, 
572             "Received pfc ena frames pri6");
573         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
574             "rx_pfc_ena_frames_pri7", CTLFLAG_RD,
575             &softc->rx_port_stats->rx_pfc_ena_frames_pri7, 
576             "Received pfc ena frames pri7");
577         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
578             "rx_sch_crc_err_frames", CTLFLAG_RD,
579             &softc->rx_port_stats->rx_sch_crc_err_frames, 
580             "Received sch crc err frames");
581         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
582             "rx_undrsz_frames", CTLFLAG_RD,
583             &softc->rx_port_stats->rx_undrsz_frames, "Received undrsz frames");
584         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
585             "rx_frag_frames", CTLFLAG_RD,
586             &softc->rx_port_stats->rx_frag_frames, "Received frag frames");
587         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
588             "rx_eee_lpi_events", CTLFLAG_RD,
589             &softc->rx_port_stats->rx_eee_lpi_events, "Received eee lpi events");
590         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
591             "rx_eee_lpi_duration", CTLFLAG_RD,
592             &softc->rx_port_stats->rx_eee_lpi_duration, 
593             "Received eee lpi duration");
594         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
595             "rx_llfc_physical_msgs", CTLFLAG_RD,
596             &softc->rx_port_stats->rx_llfc_physical_msgs, 
597             "Received llfc physical msgs");
598         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
599             "rx_llfc_logical_msgs", CTLFLAG_RD,
600             &softc->rx_port_stats->rx_llfc_logical_msgs, 
601             "Received llfc logical msgs");
602         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
603             "rx_llfc_msgs_with_crc_err", CTLFLAG_RD,
604             &softc->rx_port_stats->rx_llfc_msgs_with_crc_err, 
605             "Received llfc msgs with crc err");
606         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
607             "rx_hcfc_msgs", CTLFLAG_RD,
608             &softc->rx_port_stats->rx_hcfc_msgs, "Received hcfc msgs");
609         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
610             "rx_hcfc_msgs_with_crc_err", CTLFLAG_RD,
611             &softc->rx_port_stats->rx_hcfc_msgs_with_crc_err, 
612             "Received hcfc msgs with crc err");
613         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
614             "rx_bytes", CTLFLAG_RD,
615             &softc->rx_port_stats->rx_bytes, "Received bytes");
616         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
617             "rx_runt_bytes", CTLFLAG_RD,
618             &softc->rx_port_stats->rx_runt_bytes, "Received runt bytes");
619         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
620             "rx_runt_frames", CTLFLAG_RD,
621             &softc->rx_port_stats->rx_runt_frames, "Received runt frames");
622         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
623             "rx_stat_discard", CTLFLAG_RD,
624             &softc->rx_port_stats->rx_stat_discard, "Received stat discard");
625         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
626             "rx_stat_err", CTLFLAG_RD,
627             &softc->rx_port_stats->rx_stat_err, "Received stat err");
628
629         return 0;
630 }
631
632
633 int
634 bnxt_create_rx_sysctls(struct bnxt_softc *softc, int rxr)
635 {
636         struct sysctl_oid *oid;
637         struct ctx_hw_stats *rx_stats = (void *)softc->rx_stats.idi_vaddr;
638         char    name[32];
639         char    desc[64];
640
641         sprintf(name, "rxq%d", rxr);
642         sprintf(desc, "receive queue %d", rxr);
643         oid = SYSCTL_ADD_NODE(&softc->hw_stats,
644             SYSCTL_CHILDREN(softc->hw_stats_oid), OID_AUTO, name, CTLFLAG_RD, 0,
645             desc);
646         if (!oid)
647                 return ENOMEM;
648
649         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
650             "ucast_pkts", CTLFLAG_RD, &rx_stats[rxr].rx_ucast_pkts,
651             "unicast packets received");
652         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
653             "mcast_pkts", CTLFLAG_RD, &rx_stats[rxr].rx_mcast_pkts,
654             "multicast packets received");
655         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
656             "bcast_pkts", CTLFLAG_RD, &rx_stats[rxr].rx_bcast_pkts,
657             "broadcast packets received");
658         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
659             "discard_pkts", CTLFLAG_RD,
660             &rx_stats[rxr].rx_discard_pkts, "discarded receive packets");
661         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
662             "drop_pkts", CTLFLAG_RD, &rx_stats[rxr].rx_drop_pkts,
663             "dropped receive packets");
664         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
665             "ucast_bytes", CTLFLAG_RD, &rx_stats[rxr].rx_ucast_bytes,
666             "unicast bytes received");
667         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
668             "mcast_bytes", CTLFLAG_RD, &rx_stats[rxr].rx_mcast_bytes,
669             "multicast bytes received");
670         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
671             "bcast_bytes", CTLFLAG_RD, &rx_stats[rxr].rx_bcast_bytes,
672             "broadcast bytes received");
673
674         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
675             "tpa_pkts", CTLFLAG_RD, &rx_stats[rxr].tpa_pkts,
676             "TPA packets");
677         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
678             "tpa_bytes", CTLFLAG_RD, &rx_stats[rxr].tpa_bytes,
679             "TPA bytes");
680         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
681             "tpa_events", CTLFLAG_RD, &rx_stats[rxr].tpa_events,
682             "TPA events");
683         SYSCTL_ADD_QUAD(&softc->hw_stats, SYSCTL_CHILDREN(oid), OID_AUTO,
684             "tpa_aborts", CTLFLAG_RD, &rx_stats[rxr].tpa_aborts,
685             "TPA aborts");
686
687         return 0;
688 }
689
690 static char *bnxt_chip_type[] = {
691         "ASIC",
692         "FPGA",
693         "Palladium",
694         "Unknown"
695 };
696 #define MAX_CHIP_TYPE 3
697
698 static int
699 bnxt_package_ver_sysctl(SYSCTL_HANDLER_ARGS)
700 {
701         struct bnxt_softc *softc = arg1;
702         struct iflib_dma_info dma_data;
703         char *pkglog = NULL;
704         char *p;
705         char *next;
706         char unk[] = "<unknown>";
707         char *buf = unk;
708         int rc;
709         int field;
710         uint16_t ordinal = BNX_DIR_ORDINAL_FIRST;
711         uint16_t index;
712         uint32_t data_len;
713
714         rc = bnxt_hwrm_nvm_find_dir_entry(softc, BNX_DIR_TYPE_PKG_LOG,
715             &ordinal, BNX_DIR_EXT_NONE, &index, false,
716             HWRM_NVM_FIND_DIR_ENTRY_INPUT_OPT_ORDINAL_EQ,
717             &data_len, NULL, NULL);
718         dma_data.idi_vaddr = NULL;
719         if (rc == 0 && data_len) {
720                 rc = iflib_dma_alloc(softc->ctx, data_len, &dma_data,
721                     BUS_DMA_NOWAIT);
722                 if (rc == 0) {
723                         rc = bnxt_hwrm_nvm_read(softc, index, 0, data_len,
724                             &dma_data);
725                         if (rc == 0) {
726                                 pkglog = dma_data.idi_vaddr;
727                                 /* NULL terminate (removes last \n) */
728                                 pkglog[data_len-1] = 0;
729
730                                 /* Set p = start of last line */
731                                 p = strrchr(pkglog, '\n');
732                                 if (p == NULL)
733                                         p = pkglog;
734
735                                 /* Now find the correct tab delimited field */
736                                 for (field = 0, next = p,
737                                     p = strsep(&next, "\t");
738                                     field <
739                                     BNX_PKG_LOG_FIELD_IDX_PKG_VERSION && p;
740                                     p = strsep(&next, "\t")) {
741                                         field++;
742                                 }
743                                 if (field == BNX_PKG_LOG_FIELD_IDX_PKG_VERSION)
744                                         buf = p;
745                         }
746                 }
747                 else
748                         dma_data.idi_vaddr = NULL;
749         }
750
751         rc = sysctl_handle_string(oidp, buf, 0, req);
752         if (dma_data.idi_vaddr)
753                 iflib_dma_free(&dma_data);
754         return rc;
755 }
756
757 static int
758 bnxt_hwrm_min_ver_sysctl(SYSCTL_HANDLER_ARGS)
759 {
760         struct bnxt_softc *softc = arg1;
761         char buf[16];
762         uint8_t newver[3];
763         int rc;
764
765         sprintf(buf, "%hhu.%hhu.%hhu", softc->ver_info->hwrm_min_major,
766             softc->ver_info->hwrm_min_minor, softc->ver_info->hwrm_min_update);
767
768         rc = sysctl_handle_string(oidp, buf, sizeof(buf), req);
769         if (rc || req->newptr == NULL)
770                 return rc;
771         if (sscanf(buf, "%hhu.%hhu.%hhu%*c", &newver[0], &newver[1],
772             &newver[2]) != 3)
773                 return EINVAL;
774         softc->ver_info->hwrm_min_major = newver[0];
775         softc->ver_info->hwrm_min_minor = newver[1];
776         softc->ver_info->hwrm_min_update = newver[2];
777         bnxt_check_hwrm_version(softc);
778
779         return rc;
780 }
781
782 int
783 bnxt_create_ver_sysctls(struct bnxt_softc *softc)
784 {
785         struct bnxt_ver_info *vi = softc->ver_info;
786         struct sysctl_oid *oid = vi->ver_oid;
787
788         if (!oid)
789                 return ENOMEM;
790
791         SYSCTL_ADD_STRING(&vi->ver_ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
792             "hwrm_if", CTLFLAG_RD, vi->hwrm_if_ver, 0,
793             "HWRM interface version");
794         SYSCTL_ADD_STRING(&vi->ver_ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
795             "driver_hwrm_if", CTLFLAG_RD, vi->driver_hwrm_if_ver, 0,
796             "HWRM firmware version");
797         SYSCTL_ADD_STRING(&vi->ver_ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
798             "hwrm_fw", CTLFLAG_RD, vi->hwrm_fw_ver, 0,
799             "HWRM firmware version");
800         SYSCTL_ADD_STRING(&vi->ver_ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
801             "mgmt_fw", CTLFLAG_RD, vi->mgmt_fw_ver, 0,
802             "management firmware version");
803         SYSCTL_ADD_STRING(&vi->ver_ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
804             "netctrl_fw", CTLFLAG_RD, vi->netctrl_fw_ver, 0,
805             "network control firmware version");
806         SYSCTL_ADD_STRING(&vi->ver_ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
807             "roce_fw", CTLFLAG_RD, vi->roce_fw_ver, 0,
808             "RoCE firmware version");
809         SYSCTL_ADD_STRING(&vi->ver_ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
810             "phy", CTLFLAG_RD, vi->phy_ver, 0,
811             "PHY version");
812         SYSCTL_ADD_STRING(&vi->ver_ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
813             "hwrm_fw_name", CTLFLAG_RD, vi->hwrm_fw_name, 0,
814             "HWRM firmware name");
815         SYSCTL_ADD_STRING(&vi->ver_ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
816             "mgmt_fw_name", CTLFLAG_RD, vi->mgmt_fw_name, 0,
817             "management firmware name");
818         SYSCTL_ADD_STRING(&vi->ver_ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
819             "netctrl_fw_name", CTLFLAG_RD, vi->netctrl_fw_name, 0,
820             "network control firmware name");
821         SYSCTL_ADD_STRING(&vi->ver_ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
822             "roce_fw_name", CTLFLAG_RD, vi->roce_fw_name, 0,
823             "RoCE firmware name");
824         SYSCTL_ADD_STRING(&vi->ver_ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
825             "phy_vendor", CTLFLAG_RD, vi->phy_vendor, 0,
826             "PHY vendor name");
827         SYSCTL_ADD_STRING(&vi->ver_ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
828             "phy_partnumber", CTLFLAG_RD, vi->phy_partnumber, 0,
829             "PHY vendor part number");
830         SYSCTL_ADD_U16(&vi->ver_ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
831             "chip_num", CTLFLAG_RD, &vi->chip_num, 0, "chip number");
832         SYSCTL_ADD_U8(&vi->ver_ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
833             "chip_rev", CTLFLAG_RD, &vi->chip_rev, 0, "chip revision");
834         SYSCTL_ADD_U8(&vi->ver_ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
835             "chip_metal", CTLFLAG_RD, &vi->chip_metal, 0, "chip metal number");
836         SYSCTL_ADD_U8(&vi->ver_ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
837             "chip_bond_id", CTLFLAG_RD, &vi->chip_bond_id, 0,
838             "chip bond id");
839         SYSCTL_ADD_STRING(&vi->ver_ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
840             "chip_type", CTLFLAG_RD, vi->chip_type > MAX_CHIP_TYPE ?
841             bnxt_chip_type[MAX_CHIP_TYPE] : bnxt_chip_type[vi->chip_type], 0,
842             "RoCE firmware name");
843         SYSCTL_ADD_PROC(&vi->ver_ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
844             "package_ver", CTLTYPE_STRING|CTLFLAG_RD, softc, 0,
845             bnxt_package_ver_sysctl, "A",
846             "currently installed package version");
847         SYSCTL_ADD_PROC(&vi->ver_ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
848             "hwrm_min_ver", CTLTYPE_STRING|CTLFLAG_RWTUN, softc, 0,
849             bnxt_hwrm_min_ver_sysctl, "A",
850             "minimum hwrm API vesion to support");
851
852         return 0;
853 }
854
855 int
856 bnxt_create_nvram_sysctls(struct bnxt_nvram_info *ni)
857 {
858         struct sysctl_oid *oid = ni->nvm_oid;
859
860         if (!oid)
861                 return ENOMEM;
862
863         SYSCTL_ADD_U16(&ni->nvm_ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
864             "mfg_id", CTLFLAG_RD, &ni->mfg_id, 0, "manufacturer id");
865         SYSCTL_ADD_U16(&ni->nvm_ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
866             "device_id", CTLFLAG_RD, &ni->device_id, 0, "device id");
867         SYSCTL_ADD_U32(&ni->nvm_ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
868             "sector_size", CTLFLAG_RD, &ni->sector_size, 0, "sector size");
869         SYSCTL_ADD_U32(&ni->nvm_ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
870             "size", CTLFLAG_RD, &ni->size, 0, "nvram total size");
871         SYSCTL_ADD_U32(&ni->nvm_ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
872             "reserved_size", CTLFLAG_RD, &ni->reserved_size, 0,
873             "total reserved space");
874         SYSCTL_ADD_U32(&ni->nvm_ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
875             "available_size", CTLFLAG_RD, &ni->available_size, 0,
876             "total available space");
877
878         return 0;
879 }
880
881 static int
882 bnxt_rss_key_sysctl(SYSCTL_HANDLER_ARGS)
883 {
884         struct bnxt_softc *softc = arg1;
885         char buf[HW_HASH_KEY_SIZE*2+1] = {0};
886         char *p;
887         int i;
888         int rc;
889
890         for (p = buf, i=0; i<HW_HASH_KEY_SIZE; i++)
891                 p += sprintf(p, "%02x", softc->vnic_info.rss_hash_key[i]);
892
893         rc = sysctl_handle_string(oidp, buf, sizeof(buf), req);
894         if (rc || req->newptr == NULL)
895                 return rc;
896
897         if (strspn(buf, "0123456789abcdefABCDEF") != (HW_HASH_KEY_SIZE * 2))
898                 return EINVAL;
899
900         for (p = buf, i=0; i<HW_HASH_KEY_SIZE; i++) {
901                 if (sscanf(p, "%02hhx", &softc->vnic_info.rss_hash_key[i]) != 1)
902                         return EINVAL;
903                 p += 2;
904         }
905
906         if (if_getdrvflags(iflib_get_ifp(softc->ctx)) & IFF_DRV_RUNNING)
907                 bnxt_hwrm_rss_cfg(softc, &softc->vnic_info,
908                     softc->vnic_info.rss_hash_type);
909
910         return rc;
911 }
912
913 static const char *bnxt_hash_types[] = {"ipv4", "tcp_ipv4", "udp_ipv4", "ipv6",
914     "tcp_ipv6", "udp_ipv6", NULL};
915
916 static int bnxt_get_rss_type_str_bit(char *str)
917 {
918         int i;
919
920         for (i=0; bnxt_hash_types[i]; i++)
921                 if (strcmp(bnxt_hash_types[i], str) == 0)
922                         return i;
923
924         return -1;
925 }
926
927 static int
928 bnxt_rss_type_sysctl(SYSCTL_HANDLER_ARGS)
929 {
930         struct bnxt_softc *softc = arg1;
931         char buf[256] = {0};
932         char *p;
933         char *next;
934         int rc;
935         int type;
936         int bit;
937
938         for (type = softc->vnic_info.rss_hash_type; type;
939             type &= ~(1<<bit)) {
940                 bit = ffs(type) - 1;
941                 if (bit >= sizeof(bnxt_hash_types) / sizeof(const char *))
942                         continue;
943                 if (type != softc->vnic_info.rss_hash_type)
944                         strcat(buf, ",");
945                 strcat(buf, bnxt_hash_types[bit]);
946         }
947
948         rc = sysctl_handle_string(oidp, buf, sizeof(buf), req);
949         if (rc || req->newptr == NULL)
950                 return rc;
951
952         for (type = 0, next = buf, p = strsep(&next, " ,"); p;
953             p = strsep(&next, " ,")) {
954                 bit = bnxt_get_rss_type_str_bit(p);
955                 if (bit == -1)
956                         return EINVAL;
957                 type |= 1<<bit;
958         }
959         if (type != softc->vnic_info.rss_hash_type) {
960                 softc->vnic_info.rss_hash_type = type;
961                 if (if_getdrvflags(iflib_get_ifp(softc->ctx)) & IFF_DRV_RUNNING)
962                         bnxt_hwrm_rss_cfg(softc, &softc->vnic_info,
963                             softc->vnic_info.rss_hash_type);
964         }
965
966         return rc;
967 }
968
969 static int
970 bnxt_rx_stall_sysctl(SYSCTL_HANDLER_ARGS) {
971         struct bnxt_softc *softc = arg1;
972         int rc;
973         int val;
974
975         if (softc == NULL)
976                 return EBUSY;
977
978         val = (bool)(softc->vnic_info.flags & BNXT_VNIC_FLAG_BD_STALL);
979         rc = sysctl_handle_int(oidp, &val, 0, req);
980         if (rc || !req->newptr)
981                 return rc;
982
983         if (val)
984                 softc->vnic_info.flags |= BNXT_VNIC_FLAG_BD_STALL;
985         else
986                 softc->vnic_info.flags &= ~BNXT_VNIC_FLAG_BD_STALL;
987
988         if (if_getdrvflags(iflib_get_ifp(softc->ctx)) & IFF_DRV_RUNNING)
989                 rc = bnxt_hwrm_vnic_cfg(softc, &softc->vnic_info);
990
991         return rc;
992 }
993
994 static int
995 bnxt_vlan_strip_sysctl(SYSCTL_HANDLER_ARGS) {
996         struct bnxt_softc *softc = arg1;
997         int rc;
998         int val;
999
1000         if (softc == NULL)
1001                 return EBUSY;
1002
1003         val = (bool)(softc->vnic_info.flags & BNXT_VNIC_FLAG_VLAN_STRIP);
1004         rc = sysctl_handle_int(oidp, &val, 0, req);
1005         if (rc || !req->newptr)
1006                 return rc;
1007
1008         if (val)
1009                 softc->vnic_info.flags |= BNXT_VNIC_FLAG_VLAN_STRIP;
1010         else
1011                 softc->vnic_info.flags &= ~BNXT_VNIC_FLAG_VLAN_STRIP;
1012
1013         if (if_getdrvflags(iflib_get_ifp(softc->ctx)) & IFF_DRV_RUNNING)
1014                 rc = bnxt_hwrm_vnic_cfg(softc, &softc->vnic_info);
1015
1016         return rc;
1017 }
1018
1019 static int
1020 bnxt_set_coal_rx_usecs(SYSCTL_HANDLER_ARGS) {
1021         struct bnxt_softc *softc = arg1;
1022         int rc;
1023         int val;
1024
1025         if (softc == NULL)
1026                 return EBUSY;
1027
1028         val = softc->rx_coal_usecs;
1029         rc = sysctl_handle_int(oidp, &val, 0, req);
1030         if (rc || !req->newptr)
1031                 return rc;
1032
1033         softc->rx_coal_usecs = val;
1034         rc = bnxt_hwrm_set_coal(softc);
1035
1036         return rc;
1037 }
1038
1039 static int
1040 bnxt_set_coal_rx_frames(SYSCTL_HANDLER_ARGS) {
1041         struct bnxt_softc *softc = arg1;
1042         int rc;
1043         int val;
1044
1045         if (softc == NULL)
1046                 return EBUSY;
1047
1048         val = softc->rx_coal_frames;
1049         rc = sysctl_handle_int(oidp, &val, 0, req);
1050         if (rc || !req->newptr)
1051                 return rc;
1052
1053         softc->rx_coal_frames = val;
1054         rc = bnxt_hwrm_set_coal(softc);
1055
1056         return rc;
1057 }
1058
1059 static int
1060 bnxt_set_coal_rx_usecs_irq(SYSCTL_HANDLER_ARGS) {
1061         struct bnxt_softc *softc = arg1;
1062         int rc;
1063         int val;
1064
1065         if (softc == NULL)
1066                 return EBUSY;
1067
1068         val = softc->rx_coal_usecs_irq;
1069         rc = sysctl_handle_int(oidp, &val, 0, req);
1070         if (rc || !req->newptr)
1071                 return rc;
1072
1073         softc->rx_coal_usecs_irq = val;
1074         rc = bnxt_hwrm_set_coal(softc);
1075
1076         return rc;
1077 }
1078
1079 static int
1080 bnxt_set_coal_rx_frames_irq(SYSCTL_HANDLER_ARGS) {
1081         struct bnxt_softc *softc = arg1;
1082         int rc;
1083         int val;
1084
1085         if (softc == NULL)
1086                 return EBUSY;
1087
1088         val = softc->rx_coal_frames_irq;
1089         rc = sysctl_handle_int(oidp, &val, 0, req);
1090         if (rc || !req->newptr)
1091                 return rc;
1092
1093         softc->rx_coal_frames_irq = val;
1094         rc = bnxt_hwrm_set_coal(softc);
1095
1096         return rc;
1097 }
1098
1099 static int
1100 bnxt_set_coal_tx_usecs(SYSCTL_HANDLER_ARGS) {
1101         struct bnxt_softc *softc = arg1;
1102         int rc;
1103         int val;
1104
1105         if (softc == NULL)
1106                 return EBUSY;
1107
1108         val = softc->tx_coal_usecs;
1109         rc = sysctl_handle_int(oidp, &val, 0, req);
1110         if (rc || !req->newptr)
1111                 return rc;
1112
1113         softc->tx_coal_usecs = val;
1114         rc = bnxt_hwrm_set_coal(softc);
1115
1116         return rc;
1117 }
1118
1119 static int
1120 bnxt_set_coal_tx_frames(SYSCTL_HANDLER_ARGS) {
1121         struct bnxt_softc *softc = arg1;
1122         int rc;
1123         int val;
1124
1125         if (softc == NULL)
1126                 return EBUSY;
1127
1128         val = softc->tx_coal_frames;
1129         rc = sysctl_handle_int(oidp, &val, 0, req);
1130         if (rc || !req->newptr)
1131                 return rc;
1132
1133         softc->tx_coal_frames = val;
1134         rc = bnxt_hwrm_set_coal(softc);
1135
1136         return rc;
1137 }
1138
1139 static int
1140 bnxt_set_coal_tx_usecs_irq(SYSCTL_HANDLER_ARGS) {
1141         struct bnxt_softc *softc = arg1;
1142         int rc;
1143         int val;
1144
1145         if (softc == NULL)
1146                 return EBUSY;
1147
1148         val = softc->tx_coal_usecs_irq;
1149         rc = sysctl_handle_int(oidp, &val, 0, req);
1150         if (rc || !req->newptr)
1151                 return rc;
1152
1153         softc->tx_coal_usecs_irq = val;
1154         rc = bnxt_hwrm_set_coal(softc);
1155
1156         return rc;
1157 }
1158
1159 static int
1160 bnxt_set_coal_tx_frames_irq(SYSCTL_HANDLER_ARGS) {
1161         struct bnxt_softc *softc = arg1;
1162         int rc;
1163         int val;
1164
1165         if (softc == NULL)
1166                 return EBUSY;
1167
1168         val = softc->tx_coal_frames_irq;
1169         rc = sysctl_handle_int(oidp, &val, 0, req);
1170         if (rc || !req->newptr)
1171                 return rc;
1172
1173         softc->tx_coal_frames_irq = val;
1174         rc = bnxt_hwrm_set_coal(softc);
1175
1176         return rc;
1177 }
1178
1179 int
1180 bnxt_create_config_sysctls_pre(struct bnxt_softc *softc)
1181 {
1182         struct sysctl_ctx_list *ctx = device_get_sysctl_ctx(softc->dev);
1183         struct sysctl_oid_list *children;
1184
1185         children = SYSCTL_CHILDREN(device_get_sysctl_tree(softc->dev));;
1186
1187         SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "rss_key",
1188             CTLTYPE_STRING|CTLFLAG_RWTUN, softc, 0, bnxt_rss_key_sysctl, "A",
1189             "RSS key");
1190         SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "rss_type",
1191             CTLTYPE_STRING|CTLFLAG_RWTUN, softc, 0, bnxt_rss_type_sysctl, "A",
1192             "RSS type bits");
1193         SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "rx_stall",
1194             CTLTYPE_INT|CTLFLAG_RWTUN, softc, 0, bnxt_rx_stall_sysctl, "I",
1195             "buffer rx packets in hardware until the host posts new buffers");
1196         SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "vlan_strip",
1197             CTLTYPE_INT|CTLFLAG_RWTUN, softc, 0, bnxt_vlan_strip_sysctl, "I",
1198             "strip VLAN tag in the RX path");
1199         SYSCTL_ADD_STRING(ctx, children, OID_AUTO, "if_name", CTLFLAG_RD,
1200                 iflib_get_ifp(softc->ctx)->if_xname, 0, "interface name");
1201
1202         SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "intr_coal_rx_usecs",
1203                         CTLTYPE_INT|CTLFLAG_RWTUN, softc, 0, bnxt_set_coal_rx_usecs,
1204                         "I", "interrupt coalescing Rx Usecs");
1205         SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "intr_coal_rx_frames",
1206                         CTLTYPE_INT|CTLFLAG_RWTUN, softc, 0, bnxt_set_coal_rx_frames,
1207                         "I", "interrupt coalescing Rx Frames");
1208         SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "intr_coal_rx_usecs_irq",
1209                         CTLTYPE_INT|CTLFLAG_RWTUN, softc, 0, bnxt_set_coal_rx_usecs_irq,
1210                         "I", "interrupt coalescing Rx Usecs IRQ");
1211         SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "intr_coal_rx_frames_irq",
1212                         CTLTYPE_INT|CTLFLAG_RWTUN, softc, 0, bnxt_set_coal_rx_frames_irq,
1213                         "I", "interrupt coalescing Rx Frames IRQ");
1214         SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "intr_coal_tx_usecs",
1215                         CTLTYPE_INT|CTLFLAG_RWTUN, softc, 0, bnxt_set_coal_tx_usecs,
1216                         "I", "interrupt coalescing Tx Usces");
1217         SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "intr_coal_tx_frames",
1218                         CTLTYPE_INT|CTLFLAG_RWTUN, softc, 0, bnxt_set_coal_tx_frames,
1219                         "I", "interrupt coalescing Tx Frames"); 
1220         SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "intr_coal_tx_usecs_irq",
1221                         CTLTYPE_INT|CTLFLAG_RWTUN, softc, 0, bnxt_set_coal_tx_usecs_irq,
1222                         "I", "interrupt coalescing Tx Usecs IRQ"); 
1223         SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "intr_coal_tx_frames_irq",
1224                         CTLTYPE_INT|CTLFLAG_RWTUN, softc, 0, bnxt_set_coal_tx_frames_irq,
1225                         "I", "interrupt coalescing Tx Frames IRQ");
1226
1227         return 0;
1228 }
1229
1230 #define BNXT_HW_LRO_FN(fn_name, arg)                                       \
1231 static int                                                                 \
1232 fn_name(SYSCTL_HANDLER_ARGS) {                                             \
1233         struct bnxt_softc *softc = arg1;                                   \
1234         int rc;                                                            \
1235         int val;                                                           \
1236                                                                            \
1237         if (softc == NULL)                                                 \
1238                 return EBUSY;                                              \
1239                                                                            \
1240         val = softc->hw_lro.arg;                                           \
1241         rc = sysctl_handle_int(oidp, &val, 0, req);                        \
1242         if (rc || !req->newptr)                                            \
1243                 return rc;                                                 \
1244                                                                            \
1245         if ((if_getdrvflags(iflib_get_ifp(softc->ctx)) & IFF_DRV_RUNNING)) \
1246                 return EBUSY;                                              \
1247                                                                            \
1248         softc->hw_lro.arg = val;                                           \
1249         bnxt_validate_hw_lro_settings(softc);                              \
1250         rc = bnxt_hwrm_vnic_tpa_cfg(softc);                                \
1251                                                                            \
1252         return rc;                                                         \
1253 }
1254
1255 BNXT_HW_LRO_FN(bnxt_hw_lro_enable_disable, enable)
1256 BNXT_HW_LRO_FN(bnxt_hw_lro_set_mode, is_mode_gro)
1257 BNXT_HW_LRO_FN(bnxt_hw_lro_set_max_agg_segs, max_agg_segs)
1258 BNXT_HW_LRO_FN(bnxt_hw_lro_set_max_aggs, max_aggs)
1259 BNXT_HW_LRO_FN(bnxt_hw_lro_set_min_agg_len, min_agg_len)
1260
1261 int
1262 bnxt_create_hw_lro_sysctls(struct bnxt_softc *softc)
1263 {
1264         struct sysctl_oid *oid = softc->hw_lro_oid;
1265
1266         if (!oid)
1267                 return ENOMEM;
1268
1269         SYSCTL_ADD_PROC(&softc->hw_lro_ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
1270                         "enable", CTLTYPE_INT|CTLFLAG_RWTUN, softc, 0,
1271                         bnxt_hw_lro_enable_disable, "A",
1272                         "Enable or Disable HW LRO: 0 / 1");
1273
1274         SYSCTL_ADD_PROC(&softc->hw_lro_ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
1275                         "gro_mode", CTLTYPE_INT|CTLFLAG_RWTUN, softc, 0,
1276                         bnxt_hw_lro_set_mode, "A",
1277                         "Set mode: 1 = GRO mode, 0 = RSC mode");
1278
1279         SYSCTL_ADD_PROC(&softc->hw_lro_ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
1280                         "max_agg_segs", CTLTYPE_INT|CTLFLAG_RWTUN, softc, 0,
1281                         bnxt_hw_lro_set_max_agg_segs, "A",
1282                         "Set Max Agg Seg Value (unit is Log2): "
1283                         "0 (= 1 seg) / 1 (= 2 segs) /  ... / 31 (= 2^31 segs)");
1284         
1285         SYSCTL_ADD_PROC(&softc->hw_lro_ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
1286                         "max_aggs", CTLTYPE_INT|CTLFLAG_RWTUN, softc, 0,
1287                         bnxt_hw_lro_set_max_aggs, "A",
1288                         "Set Max Aggs Value (unit is Log2): "
1289                         "0 (= 1 agg) / 1 (= 2 aggs) /  ... / 7 (= 2^7 segs)"); 
1290
1291         SYSCTL_ADD_PROC(&softc->hw_lro_ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
1292                         "min_agg_len", CTLTYPE_INT|CTLFLAG_RWTUN, softc, 0,
1293                         bnxt_hw_lro_set_min_agg_len, "A",
1294                         "Min Agg Len: 1 to 9000");
1295
1296         return 0;
1297 }
1298 static int
1299 bnxt_vlan_only_sysctl(SYSCTL_HANDLER_ARGS) {
1300         struct bnxt_softc *softc = arg1;
1301         int rc;
1302         int val;
1303
1304         if (softc == NULL)
1305                 return EBUSY;
1306
1307         val = softc->vnic_info.vlan_only;
1308         rc = sysctl_handle_int(oidp, &val, 0, req);
1309         if (rc || !req->newptr)
1310                 return rc;
1311
1312         if (val)
1313                 val = 1;
1314
1315         if (val != softc->vnic_info.vlan_only) {
1316                 softc->vnic_info.vlan_only = val;
1317                 if (if_getdrvflags(iflib_get_ifp(softc->ctx)) & IFF_DRV_RUNNING)
1318                         rc = bnxt_hwrm_cfa_l2_set_rx_mask(softc,
1319                             &softc->vnic_info);
1320         }
1321
1322         return rc;
1323 }
1324
1325 int
1326 bnxt_create_config_sysctls_post(struct bnxt_softc *softc)
1327 {
1328         struct sysctl_ctx_list *ctx = device_get_sysctl_ctx(softc->dev);
1329         struct sysctl_oid_list *children;
1330
1331         children = SYSCTL_CHILDREN(device_get_sysctl_tree(softc->dev));;
1332
1333         SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "vlan_only",
1334             CTLTYPE_INT|CTLFLAG_RWTUN, softc, 0, bnxt_vlan_only_sysctl, "I",
1335             "require vlan tag on received packets when vlan is enabled");
1336
1337         return 0;
1338 }