]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/dev/bnxt/bnxt.h
Revert r323516 (iflib rollup)
[FreeBSD/FreeBSD.git] / sys / dev / bnxt / bnxt.h
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 #ifndef _BNXT_H
33 #define _BNXT_H
34
35 #include <sys/param.h>
36 #include <sys/socket.h>
37 #include <sys/sysctl.h>
38 #include <sys/taskqueue.h>
39
40 #include <machine/bus.h>
41
42 #include <net/ethernet.h>
43 #include <net/if.h>
44 #include <net/if_var.h>
45 #include <net/iflib.h>
46
47 #include "hsi_struct_def.h"
48
49 /* PCI IDs */
50 #define BROADCOM_VENDOR_ID      0x14E4
51
52 #define BCM57301        0x16c8
53 #define BCM57302        0x16c9
54 #define BCM57304        0x16ca
55 #define BCM57311        0x16ce
56 #define BCM57312        0x16cf
57 #define BCM57314        0x16df
58 #define BCM57402        0x16d0
59 #define BCM57402_NPAR   0x16d4
60 #define BCM57404        0x16d1
61 #define BCM57404_NPAR   0x16e7
62 #define BCM57406        0x16d2
63 #define BCM57406_NPAR   0x16e8
64 #define BCM57407        0x16d5
65 #define BCM57407_NPAR   0x16ea
66 #define BCM57407_SFP    0x16e9
67 #define BCM57412        0x16d6
68 #define BCM57412_NPAR1  0x16de
69 #define BCM57412_NPAR2  0x16eb
70 #define BCM57414        0x16d7
71 #define BCM57414_NPAR1  0x16ec
72 #define BCM57414_NPAR2  0x16ed
73 #define BCM57416        0x16d8
74 #define BCM57416_NPAR1  0x16ee
75 #define BCM57416_NPAR2  0x16ef
76 #define BCM57416_SFP    0x16e3
77 #define BCM57417        0x16d9
78 #define BCM57417_NPAR1  0x16c0
79 #define BCM57417_NPAR2  0x16cc
80 #define BCM57417_SFP    0x16e2
81 #define BCM57454        0x1614
82 #define BCM58700        0x16cd
83 #define NETXTREME_C_VF1 0x16cb
84 #define NETXTREME_C_VF2 0x16e1
85 #define NETXTREME_C_VF3 0x16e5
86 #define NETXTREME_E_VF1 0x16c1
87 #define NETXTREME_E_VF2 0x16d3
88 #define NETXTREME_E_VF3 0x16dc
89
90 #define CSUM_OFFLOAD            (CSUM_IP_TSO|CSUM_IP6_TSO|CSUM_IP| \
91                                  CSUM_IP_UDP|CSUM_IP_TCP|CSUM_IP_SCTP| \
92                                  CSUM_IP6_UDP|CSUM_IP6_TCP|CSUM_IP6_SCTP)
93
94 #define BNXT_MAX_MTU    9000
95
96 #define BNXT_RSS_HASH_TYPE_TCPV4        0
97 #define BNXT_RSS_HASH_TYPE_UDPV4        1
98 #define BNXT_RSS_HASH_TYPE_IPV4         2
99 #define BNXT_RSS_HASH_TYPE_TCPV6        3
100 #define BNXT_RSS_HASH_TYPE_UDPV6        4
101 #define BNXT_RSS_HASH_TYPE_IPV6         5
102 #define BNXT_GET_RSS_PROFILE_ID(rss_hash_type) ((rss_hash_type >> 1) & 0x1F)
103
104 #define BNXT_NO_MORE_WOL_FILTERS        0xFFFF
105 #define bnxt_wol_supported(softc)       ((softc)->flags & BNXT_FLAG_WOL_CAP)
106
107 /* Completion related defines */
108 #define CMP_VALID(cmp, v_bit) \
109         ((!!(((struct cmpl_base *)(cmp))->info3_v & htole32(CMPL_BASE_V))) == !!(v_bit) )
110
111 #define NEXT_CP_CONS_V(ring, cons, v_bit) do {                              \
112         if (__predict_false(++(cons) == (ring)->ring_size))                 \
113                 ((cons) = 0, (v_bit) = !v_bit);                             \
114 } while (0)
115
116 #define RING_NEXT(ring, idx) (__predict_false(idx + 1 == (ring)->ring_size) ? \
117                                                                 0 : idx + 1)
118
119 #define CMPL_PREFETCH_NEXT(cpr, idx)                                        \
120         __builtin_prefetch(&((struct cmpl_base *)(cpr)->ring.vaddr)[((idx) +\
121             (CACHE_LINE_SIZE / sizeof(struct cmpl_base))) &                 \
122             ((cpr)->ring.ring_size - 1)])
123
124 /*
125  * If we update the index, a write barrier is needed after the write to ensure
126  * the completion ring has space before the RX/TX ring does.  Since we can't
127  * make the RX and AG doorbells covered by the same barrier without remapping
128  * MSI-X vectors, we create the barrier over the enture doorbell bar.
129  * TODO: Remap the MSI-X vectors to allow a barrier to only cover the doorbells
130  *       for a single ring group.
131  *
132  * A barrier of just the size of the write is used to ensure the ordering
133  * remains correct and no writes are lost.
134  */
135 #define BNXT_CP_DISABLE_DB(ring) do {                                       \
136         bus_space_barrier((ring)->softc->doorbell_bar.tag,                  \
137             (ring)->softc->doorbell_bar.handle, (ring)->doorbell, 4,        \
138             BUS_SPACE_BARRIER_WRITE);                                       \
139         bus_space_barrier((ring)->softc->doorbell_bar.tag,                  \
140             (ring)->softc->doorbell_bar.handle, 0,                          \
141             (ring)->softc->doorbell_bar.size, BUS_SPACE_BARRIER_WRITE);     \
142         bus_space_write_4((ring)->softc->doorbell_bar.tag,                  \
143             (ring)->softc->doorbell_bar.handle, (ring)->doorbell,           \
144             htole32(CMPL_DOORBELL_KEY_CMPL | CMPL_DOORBELL_MASK));          \
145 } while (0)
146
147 #define BNXT_CP_ENABLE_DB(ring) do {                                        \
148         bus_space_barrier((ring)->softc->doorbell_bar.tag,                  \
149             (ring)->softc->doorbell_bar.handle, (ring)->doorbell, 4,        \
150             BUS_SPACE_BARRIER_WRITE);                                       \
151         bus_space_barrier((ring)->softc->doorbell_bar.tag,                  \
152             (ring)->softc->doorbell_bar.handle, 0,                          \
153             (ring)->softc->doorbell_bar.size, BUS_SPACE_BARRIER_WRITE);     \
154         bus_space_write_4((ring)->softc->doorbell_bar.tag,                  \
155             (ring)->softc->doorbell_bar.handle, (ring)->doorbell,           \
156             htole32(CMPL_DOORBELL_KEY_CMPL));                               \
157 } while (0)
158
159 #define BNXT_CP_IDX_ENABLE_DB(ring, cons) do {                              \
160         bus_space_barrier((ring)->softc->doorbell_bar.tag,                  \
161             (ring)->softc->doorbell_bar.handle, (ring)->doorbell, 4,        \
162             BUS_SPACE_BARRIER_WRITE);                                       \
163         bus_space_write_4((ring)->softc->doorbell_bar.tag,                  \
164             (ring)->softc->doorbell_bar.handle, (ring)->doorbell,           \
165             htole32(CMPL_DOORBELL_KEY_CMPL | CMPL_DOORBELL_IDX_VALID |      \
166             (cons)));                                                       \
167         bus_space_barrier((ring)->softc->doorbell_bar.tag,                  \
168             (ring)->softc->doorbell_bar.handle, 0,                          \
169             (ring)->softc->doorbell_bar.size, BUS_SPACE_BARRIER_WRITE);     \
170 } while (0)
171
172 #define BNXT_CP_IDX_DISABLE_DB(ring, cons) do {                             \
173         bus_space_barrier((ring)->softc->doorbell_bar.tag,                  \
174             (ring)->softc->doorbell_bar.handle, (ring)->doorbell, 4,        \
175             BUS_SPACE_BARRIER_WRITE);                                       \
176         bus_space_write_4((ring)->softc->doorbell_bar.tag,                  \
177             (ring)->softc->doorbell_bar.handle, (ring)->doorbell,           \
178             htole32(CMPL_DOORBELL_KEY_CMPL | CMPL_DOORBELL_IDX_VALID |      \
179             CMPL_DOORBELL_MASK | (cons)));                                  \
180         bus_space_barrier((ring)->softc->doorbell_bar.tag,                  \
181             (ring)->softc->doorbell_bar.handle, 0,                          \
182             (ring)->softc->doorbell_bar.size, BUS_SPACE_BARRIER_WRITE);     \
183 } while (0)
184
185 #define BNXT_TX_DB(ring, idx) do {                                          \
186         bus_space_barrier((ring)->softc->doorbell_bar.tag,                  \
187             (ring)->softc->doorbell_bar.handle, (ring)->doorbell, 4,        \
188             BUS_SPACE_BARRIER_WRITE);                                       \
189         bus_space_write_4(                                                  \
190             (ring)->softc->doorbell_bar.tag,                                \
191             (ring)->softc->doorbell_bar.handle,                             \
192             (ring)->doorbell, htole32(TX_DOORBELL_KEY_TX | (idx)));         \
193 } while (0)
194
195 #define BNXT_RX_DB(ring, idx) do {                                          \
196         bus_space_barrier((ring)->softc->doorbell_bar.tag,                  \
197             (ring)->softc->doorbell_bar.handle, (ring)->doorbell, 4,        \
198             BUS_SPACE_BARRIER_WRITE);                                       \
199         bus_space_write_4(                                                  \
200             (ring)->softc->doorbell_bar.tag,                                \
201             (ring)->softc->doorbell_bar.handle,                             \
202             (ring)->doorbell, htole32(RX_DOORBELL_KEY_RX | (idx)));         \
203 } while (0)
204
205 /* Lock macros */
206 #define BNXT_HWRM_LOCK_INIT(_softc, _name) \
207     mtx_init(&(_softc)->hwrm_lock, _name, "BNXT HWRM Lock", MTX_DEF)
208 #define BNXT_HWRM_LOCK(_softc)          mtx_lock(&(_softc)->hwrm_lock)
209 #define BNXT_HWRM_UNLOCK(_softc)        mtx_unlock(&(_softc)->hwrm_lock)
210 #define BNXT_HWRM_LOCK_DESTROY(_softc)  mtx_destroy(&(_softc)->hwrm_lock)
211 #define BNXT_HWRM_LOCK_ASSERT(_softc)   mtx_assert(&(_softc)->hwrm_lock,    \
212     MA_OWNED)
213
214 /* Chip info */
215 #define BNXT_TSO_SIZE   UINT16_MAX
216
217 #define min_t(type, x, y) ({                    \
218         type __min1 = (x);                      \
219         type __min2 = (y);                      \
220         __min1 < __min2 ? __min1 : __min2; })
221
222 #define max_t(type, x, y) ({                    \
223         type __max1 = (x);                      \
224         type __max2 = (y);                      \
225         __max1 > __max2 ? __max1 : __max2; })
226
227 #define clamp_t(type, _x, min, max)     min_t(type, max_t(type, _x, min), max)
228
229 /* NVRAM access */
230 enum bnxt_nvm_directory_type {
231         BNX_DIR_TYPE_UNUSED = 0,
232         BNX_DIR_TYPE_PKG_LOG = 1,
233         BNX_DIR_TYPE_UPDATE = 2,
234         BNX_DIR_TYPE_CHIMP_PATCH = 3,
235         BNX_DIR_TYPE_BOOTCODE = 4,
236         BNX_DIR_TYPE_VPD = 5,
237         BNX_DIR_TYPE_EXP_ROM_MBA = 6,
238         BNX_DIR_TYPE_AVS = 7,
239         BNX_DIR_TYPE_PCIE = 8,
240         BNX_DIR_TYPE_PORT_MACRO = 9,
241         BNX_DIR_TYPE_APE_FW = 10,
242         BNX_DIR_TYPE_APE_PATCH = 11,
243         BNX_DIR_TYPE_KONG_FW = 12,
244         BNX_DIR_TYPE_KONG_PATCH = 13,
245         BNX_DIR_TYPE_BONO_FW = 14,
246         BNX_DIR_TYPE_BONO_PATCH = 15,
247         BNX_DIR_TYPE_TANG_FW = 16,
248         BNX_DIR_TYPE_TANG_PATCH = 17,
249         BNX_DIR_TYPE_BOOTCODE_2 = 18,
250         BNX_DIR_TYPE_CCM = 19,
251         BNX_DIR_TYPE_PCI_CFG = 20,
252         BNX_DIR_TYPE_TSCF_UCODE = 21,
253         BNX_DIR_TYPE_ISCSI_BOOT = 22,
254         BNX_DIR_TYPE_ISCSI_BOOT_IPV6 = 24,
255         BNX_DIR_TYPE_ISCSI_BOOT_IPV4N6 = 25,
256         BNX_DIR_TYPE_ISCSI_BOOT_CFG6 = 26,
257         BNX_DIR_TYPE_EXT_PHY = 27,
258         BNX_DIR_TYPE_SHARED_CFG = 40,
259         BNX_DIR_TYPE_PORT_CFG = 41,
260         BNX_DIR_TYPE_FUNC_CFG = 42,
261         BNX_DIR_TYPE_MGMT_CFG = 48,
262         BNX_DIR_TYPE_MGMT_DATA = 49,
263         BNX_DIR_TYPE_MGMT_WEB_DATA = 50,
264         BNX_DIR_TYPE_MGMT_WEB_META = 51,
265         BNX_DIR_TYPE_MGMT_EVENT_LOG = 52,
266         BNX_DIR_TYPE_MGMT_AUDIT_LOG = 53
267 };
268
269 enum bnxnvm_pkglog_field_index {
270         BNX_PKG_LOG_FIELD_IDX_INSTALLED_TIMESTAMP       = 0,
271         BNX_PKG_LOG_FIELD_IDX_PKG_DESCRIPTION           = 1,
272         BNX_PKG_LOG_FIELD_IDX_PKG_VERSION               = 2,
273         BNX_PKG_LOG_FIELD_IDX_PKG_TIMESTAMP             = 3,
274         BNX_PKG_LOG_FIELD_IDX_PKG_CHECKSUM              = 4,
275         BNX_PKG_LOG_FIELD_IDX_INSTALLED_ITEMS           = 5,
276         BNX_PKG_LOG_FIELD_IDX_INSTALLED_MASK            = 6
277 };
278
279 #define BNX_DIR_ORDINAL_FIRST           0
280 #define BNX_DIR_EXT_NONE                0
281
282 struct bnxt_bar_info {
283         struct resource         *res;
284         bus_space_tag_t         tag;
285         bus_space_handle_t      handle;
286         bus_size_t              size;
287         int                     rid;
288 };
289
290 struct bnxt_link_info {
291         uint8_t         media_type;
292         uint8_t         transceiver;
293         uint8_t         phy_addr;
294         uint8_t         phy_link_status;
295         uint8_t         wire_speed;
296         uint8_t         loop_back;
297         uint8_t         link_up;
298         uint8_t         last_link_up;
299         uint8_t         duplex;
300         uint8_t         last_duplex;
301         uint8_t         pause;
302         uint8_t         last_pause;
303         uint8_t         auto_pause;
304         uint8_t         force_pause;
305         uint8_t         duplex_setting;
306         uint8_t         auto_mode;
307 #define PHY_VER_LEN             3
308         uint8_t         phy_ver[PHY_VER_LEN];
309         uint8_t         phy_type;
310         uint16_t        link_speed;
311         uint16_t        support_speeds;
312         uint16_t        auto_link_speeds;
313         uint16_t        auto_link_speed;
314         uint16_t        force_link_speed;
315         uint32_t        preemphasis;
316
317         /* copy of requested setting */
318         uint8_t         autoneg;
319 #define BNXT_AUTONEG_SPEED      1
320 #define BNXT_AUTONEG_FLOW_CTRL  2
321         uint8_t         req_duplex;
322         uint8_t         req_flow_ctrl;
323         uint16_t        req_link_speed;
324 };
325
326 enum bnxt_cp_type {
327         BNXT_DEFAULT,
328         BNXT_TX,
329         BNXT_RX,
330         BNXT_SHARED
331 };
332
333 struct bnxt_cos_queue {
334         uint8_t id;
335         uint8_t profile;
336 };
337
338 struct bnxt_func_info {
339         uint32_t        fw_fid;
340         uint8_t         mac_addr[ETHER_ADDR_LEN];
341         uint16_t        max_rsscos_ctxs;
342         uint16_t        max_cp_rings;
343         uint16_t        max_tx_rings;
344         uint16_t        max_rx_rings;
345         uint16_t        max_hw_ring_grps;
346         uint16_t        max_irqs;
347         uint16_t        max_l2_ctxs;
348         uint16_t        max_vnics;
349         uint16_t        max_stat_ctxs;
350 };
351
352 struct bnxt_pf_info {
353 #define BNXT_FIRST_PF_FID       1
354 #define BNXT_FIRST_VF_FID       128
355         uint8_t         port_id;
356         uint32_t        first_vf_id;
357         uint16_t        active_vfs;
358         uint16_t        max_vfs;
359         uint32_t        max_encap_records;
360         uint32_t        max_decap_records;
361         uint32_t        max_tx_em_flows;
362         uint32_t        max_tx_wm_flows;
363         uint32_t        max_rx_em_flows;
364         uint32_t        max_rx_wm_flows;
365         unsigned long   *vf_event_bmap;
366         uint16_t        hwrm_cmd_req_pages;
367         void            *hwrm_cmd_req_addr[4];
368         bus_addr_t      hwrm_cmd_req_dma_addr[4];
369 };
370
371 struct bnxt_vf_info {
372         uint16_t        fw_fid;
373         uint8_t         mac_addr[ETHER_ADDR_LEN];
374         uint16_t        max_rsscos_ctxs;
375         uint16_t        max_cp_rings;
376         uint16_t        max_tx_rings;
377         uint16_t        max_rx_rings;
378         uint16_t        max_hw_ring_grps;
379         uint16_t        max_l2_ctxs;
380         uint16_t        max_irqs;
381         uint16_t        max_vnics;
382         uint16_t        max_stat_ctxs;
383         uint32_t        vlan;
384 #define BNXT_VF_QOS             0x1
385 #define BNXT_VF_SPOOFCHK        0x2
386 #define BNXT_VF_LINK_FORCED     0x4
387 #define BNXT_VF_LINK_UP         0x8
388         uint32_t        flags;
389         uint32_t        func_flags; /* func cfg flags */
390         uint32_t        min_tx_rate;
391         uint32_t        max_tx_rate;
392         void            *hwrm_cmd_req_addr;
393         bus_addr_t      hwrm_cmd_req_dma_addr;
394 };
395
396 #define BNXT_FLAG_VF            (1<<1)
397
398 #define BNXT_PF(softc)          (!((softc)->flags & BNXT_FLAG_VF))
399 #define BNXT_VF(softc)          ((softc)->flags & BNXT_FLAG_VF)
400
401 struct bnxt_vlan_tag {
402         SLIST_ENTRY(bnxt_vlan_tag) next;
403         uint16_t        tpid;
404         uint16_t        tag;
405 };
406
407 struct bnxt_vnic_info {
408         uint16_t        id;
409         uint16_t        def_ring_grp;
410         uint16_t        cos_rule;
411         uint16_t        lb_rule;
412         uint16_t        mru;
413
414         uint32_t        rx_mask;
415         bool            vlan_only;
416         struct iflib_dma_info mc_list;
417         int             mc_list_count;
418 #define BNXT_MAX_MC_ADDRS               16
419
420         uint32_t        flags;
421 #define BNXT_VNIC_FLAG_DEFAULT          0x01
422 #define BNXT_VNIC_FLAG_BD_STALL         0x02
423 #define BNXT_VNIC_FLAG_VLAN_STRIP       0x04
424
425         uint64_t        filter_id;
426         uint32_t        flow_id;
427
428         uint16_t        rss_id;
429         uint32_t        rss_hash_type;
430         uint8_t         rss_hash_key[HW_HASH_KEY_SIZE];
431         struct iflib_dma_info rss_hash_key_tbl;
432         struct iflib_dma_info   rss_grp_tbl;
433         SLIST_HEAD(vlan_head, bnxt_vlan_tag) vlan_tags;
434         struct iflib_dma_info vlan_tag_list;
435 };
436
437 struct bnxt_grp_info {
438         uint16_t        stats_ctx;
439         uint16_t        grp_id;
440         uint16_t        rx_ring_id;
441         uint16_t        cp_ring_id;
442         uint16_t        ag_ring_id;
443 };
444
445 struct bnxt_ring {
446         uint64_t                paddr;
447         vm_offset_t             doorbell;
448         caddr_t                 vaddr;
449         struct bnxt_softc       *softc;
450         uint32_t                ring_size;      /* Must be a power of two */
451         uint16_t                id;             /* Logical ID */
452         uint16_t                phys_id;
453         struct bnxt_full_tpa_start *tpa_start;
454 };
455
456 struct bnxt_cp_ring {
457         struct bnxt_ring        ring;
458         struct if_irq           irq;
459         uint32_t                cons;
460         bool                    v_bit;          /* Value of valid bit */
461         struct ctx_hw_stats     *stats;
462         uint32_t                stats_ctx_id;
463         uint32_t                last_idx;       /* Used by RX rings only
464                                                  * set to the last read pidx
465                                                  */
466 };
467
468 struct bnxt_full_tpa_start {
469         struct rx_tpa_start_cmpl low;
470         struct rx_tpa_start_cmpl_hi high;
471 };
472
473 /* All the version information for the part */
474 #define BNXT_VERSTR_SIZE        (3*3+2+1)       /* ie: "255.255.255\0" */
475 #define BNXT_NAME_SIZE          17
476 struct bnxt_ver_info {
477         uint8_t         hwrm_if_major;
478         uint8_t         hwrm_if_minor;
479         uint8_t         hwrm_if_update;
480         char            hwrm_if_ver[BNXT_VERSTR_SIZE];
481         char            driver_hwrm_if_ver[BNXT_VERSTR_SIZE];
482         char            hwrm_fw_ver[BNXT_VERSTR_SIZE];
483         char            mgmt_fw_ver[BNXT_VERSTR_SIZE];
484         char            netctrl_fw_ver[BNXT_VERSTR_SIZE];
485         char            roce_fw_ver[BNXT_VERSTR_SIZE];
486         char            phy_ver[BNXT_VERSTR_SIZE];
487         char            pkg_ver[64];
488
489         char            hwrm_fw_name[BNXT_NAME_SIZE];
490         char            mgmt_fw_name[BNXT_NAME_SIZE];
491         char            netctrl_fw_name[BNXT_NAME_SIZE];
492         char            roce_fw_name[BNXT_NAME_SIZE];
493         char            phy_vendor[BNXT_NAME_SIZE];
494         char            phy_partnumber[BNXT_NAME_SIZE];
495
496         uint16_t        chip_num;
497         uint8_t         chip_rev;
498         uint8_t         chip_metal;
499         uint8_t         chip_bond_id;
500         uint8_t         chip_type;
501
502         uint8_t         hwrm_min_major;
503         uint8_t         hwrm_min_minor;
504         uint8_t         hwrm_min_update;
505
506         struct sysctl_ctx_list  ver_ctx;
507         struct sysctl_oid       *ver_oid;
508 };
509
510 struct bnxt_nvram_info {
511         uint16_t        mfg_id;
512         uint16_t        device_id;
513         uint32_t        sector_size;
514         uint32_t        size;
515         uint32_t        reserved_size;
516         uint32_t        available_size;
517
518         struct sysctl_ctx_list  nvm_ctx;
519         struct sysctl_oid       *nvm_oid;
520 };
521
522 struct bnxt_func_qcfg {
523         uint16_t alloc_completion_rings;
524         uint16_t alloc_tx_rings;
525         uint16_t alloc_rx_rings;
526         uint16_t alloc_vnics;
527 };
528
529 struct bnxt_softc {
530         device_t        dev;
531         if_ctx_t        ctx;
532         if_softc_ctx_t  scctx;
533         if_shared_ctx_t sctx;
534         struct ifmedia  *media;
535
536         struct bnxt_bar_info    hwrm_bar;
537         struct bnxt_bar_info    doorbell_bar;
538         struct bnxt_link_info   link_info;
539 #define BNXT_FLAG_NPAR          0x1
540 #define BNXT_FLAG_WOL_CAP       0x2
541         uint32_t                flags;
542         uint32_t                total_msix;
543
544         struct bnxt_func_info   func;
545         struct bnxt_func_qcfg   fn_qcfg;
546         struct bnxt_pf_info     pf;
547         struct bnxt_vf_info     vf;
548
549         uint16_t                hwrm_cmd_seq;
550         uint32_t                hwrm_cmd_timeo; /* milliseconds */
551         struct iflib_dma_info   hwrm_cmd_resp;
552         /* Interrupt info for HWRM */
553         struct if_irq           irq;
554         struct mtx              hwrm_lock;
555         uint16_t                hwrm_max_req_len;
556
557 #define BNXT_MAX_QUEUE          8
558         uint8_t                 max_tc;
559         struct bnxt_cos_queue   q_info[BNXT_MAX_QUEUE];
560
561         uint64_t                admin_ticks;
562         struct iflib_dma_info   hw_rx_port_stats;
563         struct iflib_dma_info   hw_tx_port_stats;
564         struct rx_port_stats    *rx_port_stats;
565         struct tx_port_stats    *tx_port_stats;
566
567         int                     num_cp_rings;
568
569         struct bnxt_ring        *tx_rings;
570         struct bnxt_cp_ring     *tx_cp_rings;
571         struct iflib_dma_info   tx_stats;
572         int                     ntxqsets;
573
574         struct bnxt_vnic_info   vnic_info;
575         struct bnxt_ring        *ag_rings;
576         struct bnxt_ring        *rx_rings;
577         struct bnxt_cp_ring     *rx_cp_rings;
578         struct bnxt_grp_info    *grp_info;
579         struct iflib_dma_info   rx_stats;
580         int                     nrxqsets;
581
582         struct bnxt_cp_ring     def_cp_ring;
583         struct iflib_dma_info   def_cp_ring_mem;
584         struct grouptask        def_cp_task;
585
586         struct sysctl_ctx_list  hw_stats;
587         struct sysctl_oid       *hw_stats_oid;
588
589         struct bnxt_ver_info    *ver_info;
590         struct bnxt_nvram_info  *nvm_info;
591         bool wol;
592         uint8_t wol_filter_id;
593         uint16_t                rx_coal_usecs;
594         uint16_t                rx_coal_usecs_irq;
595         uint16_t                rx_coal_frames;
596         uint16_t                rx_coal_frames_irq;
597         uint16_t                tx_coal_usecs;
598         uint16_t                tx_coal_usecs_irq;
599         uint16_t                tx_coal_frames;
600         uint16_t                tx_coal_frames_irq;
601
602 #define BNXT_USEC_TO_COAL_TIMER(x)      ((x) * 25 / 2)
603 #define BNXT_DEF_STATS_COAL_TICKS        1000000
604 #define BNXT_MIN_STATS_COAL_TICKS         250000
605 #define BNXT_MAX_STATS_COAL_TICKS        1000000
606
607 };
608
609 struct bnxt_filter_info {
610         STAILQ_ENTRY(bnxt_filter_info) next;
611         uint64_t        fw_l2_filter_id;
612 #define INVALID_MAC_INDEX ((uint16_t)-1)
613         uint16_t        mac_index;
614
615         /* Filter Characteristics */
616         uint32_t        flags;
617         uint32_t        enables;
618         uint8_t         l2_addr[ETHER_ADDR_LEN];
619         uint8_t         l2_addr_mask[ETHER_ADDR_LEN];
620         uint16_t        l2_ovlan;
621         uint16_t        l2_ovlan_mask;
622         uint16_t        l2_ivlan;
623         uint16_t        l2_ivlan_mask;
624         uint8_t         t_l2_addr[ETHER_ADDR_LEN];
625         uint8_t         t_l2_addr_mask[ETHER_ADDR_LEN];
626         uint16_t        t_l2_ovlan;
627         uint16_t        t_l2_ovlan_mask;
628         uint16_t        t_l2_ivlan;
629         uint16_t        t_l2_ivlan_mask;
630         uint8_t         tunnel_type;
631         uint16_t        mirror_vnic_id;
632         uint32_t        vni;
633         uint8_t         pri_hint;
634         uint64_t        l2_filter_id_hint;
635 };
636
637 /* Function declarations */
638 void bnxt_report_link(struct bnxt_softc *softc);
639 bool bnxt_check_hwrm_version(struct bnxt_softc *softc);
640
641 #endif /* _BNXT_H */