net/bnxt: get device infos
[dpdk.git] / drivers / net / bnxt / bnxt.h
1 /*-
2  *   BSD LICENSE
3  *
4  *   Copyright(c) Broadcom Limited.
5  *   All rights reserved.
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  *
11  *     * Redistributions of source code must retain the above copyright
12  *       notice, this list of conditions and the following disclaimer.
13  *     * Redistributions in binary form must reproduce the above copyright
14  *       notice, this list of conditions and the following disclaimer in
15  *       the documentation and/or other materials provided with the
16  *       distribution.
17  *     * Neither the name of Broadcom Corporation nor the names of its
18  *       contributors may be used to endorse or promote products derived
19  *       from this software without specific prior written permission.
20  *
21  *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24  *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25  *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26  *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27  *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28  *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29  *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30  *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  */
33
34 #ifndef _BNXT_H_
35 #define _BNXT_H_
36
37 #include <inttypes.h>
38 #include <sys/queue.h>
39
40 #include <rte_ethdev.h>
41 #include <rte_memory.h>
42 #include <rte_lcore.h>
43 #include <rte_spinlock.h>
44
45 #define BNXT_MAX_MTU            9000
46 #define VLAN_TAG_SIZE           4
47
48 struct bnxt_vf_info {
49         uint16_t                fw_fid;
50         uint8_t                 mac_addr[ETHER_ADDR_LEN];
51         uint16_t                max_rsscos_ctx;
52         uint16_t                max_cp_rings;
53         uint16_t                max_tx_rings;
54         uint16_t                max_rx_rings;
55         uint16_t                max_l2_ctx;
56         uint16_t                max_vnics;
57         struct bnxt_pf_info     *pf;
58 };
59
60 struct bnxt_pf_info {
61 #define BNXT_FIRST_PF_FID       1
62 #define BNXT_MAX_VFS(bp)        (bp->pf.max_vfs)
63 #define BNXT_FIRST_VF_FID       128
64 #define BNXT_PF_RINGS_USED(bp)  bnxt_get_num_queues(bp)
65 #define BNXT_PF_RINGS_AVAIL(bp) (bp->pf.max_cp_rings - BNXT_PF_RINGS_USED(bp))
66         uint32_t                fw_fid;
67         uint8_t                 port_id;
68         uint8_t                 mac_addr[ETHER_ADDR_LEN];
69         uint16_t                max_rsscos_ctx;
70         uint16_t                max_cp_rings;
71         uint16_t                max_tx_rings;
72         uint16_t                max_rx_rings;
73         uint16_t                max_l2_ctx;
74         uint16_t                max_vnics;
75         uint16_t                first_vf_id;
76         uint16_t                active_vfs;
77         uint16_t                max_vfs;
78         void                    *vf_req_buf;
79         phys_addr_t             vf_req_buf_dma_addr;
80         uint32_t                vf_req_fwd[8];
81         struct bnxt_vf_info     *vf;
82 };
83
84 #define BNXT_COS_QUEUE_COUNT    8
85 struct bnxt_cos_queue_info {
86         uint8_t id;
87         uint8_t profile;
88 };
89
90 struct bnxt {
91         void                            *bar0;
92
93         struct rte_eth_dev              *eth_dev;
94         struct rte_pci_device           *pdev;
95
96         uint32_t                flags;
97 #define BNXT_FLAG_REGISTERED    (1 << 0)
98 #define BNXT_FLAG_VF            (1 << 1)
99 #define BNXT_PF(bp)             (!((bp)->flags & BNXT_FLAG_VF))
100 #define BNXT_VF(bp)             ((bp)->flags & BNXT_FLAG_VF)
101
102 #define MAX_NUM_MAC_ADDR        32
103         uint8_t                 mac_addr[ETHER_ADDR_LEN];
104
105         uint16_t                        hwrm_cmd_seq;
106         void                            *hwrm_cmd_resp_addr;
107         phys_addr_t                     hwrm_cmd_resp_dma_addr;
108         rte_spinlock_t                  hwrm_lock;
109         uint16_t                        max_req_len;
110         uint16_t                        max_resp_len;
111
112         struct bnxt_cos_queue_info      cos_queue[BNXT_COS_QUEUE_COUNT];
113
114         struct bnxt_pf_info             pf;
115         struct bnxt_vf_info             vf;
116 };
117
118 #endif