4 * Copyright(c) Broadcom Limited.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
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
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.
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.
39 #include <sys/queue.h>
41 #include <rte_ethdev.h>
42 #include <rte_memory.h>
43 #include <rte_lcore.h>
44 #include <rte_spinlock.h>
48 #define BNXT_MAX_MTU 9500
49 #define VLAN_TAG_SIZE 4
51 enum bnxt_hw_context {
53 HW_CONTEXT_IS_RSS = 1,
54 HW_CONTEXT_IS_COS = 2,
58 struct bnxt_vlan_table_entry {
61 } __attribute__((packed));
63 struct bnxt_child_vf_info {
65 struct bnxt_vlan_table_entry *vlan_table;
66 STAILQ_HEAD(, bnxt_filter_info) filter;
67 uint32_t func_cfg_flags;
75 #define BNXT_FIRST_PF_FID 1
76 #define BNXT_MAX_VFS(bp) (bp->pf.max_vfs)
77 #define BNXT_FIRST_VF_FID 128
78 #define BNXT_PF_RINGS_USED(bp) bnxt_get_num_queues(bp)
79 #define BNXT_PF_RINGS_AVAIL(bp) (bp->pf.max_cp_rings - BNXT_PF_RINGS_USED(bp))
84 uint32_t func_cfg_flags;
86 phys_addr_t vf_req_buf_dma_addr;
87 uint32_t vf_req_fwd[8];
89 struct bnxt_child_vf_info *vf_info;
90 #define BNXT_EVB_MODE_NONE 0
91 #define BNXT_EVB_MODE_VEB 1
92 #define BNXT_EVB_MODE_VEPA 2
96 /* Max wait time is 10 * 100ms = 1s */
97 #define BNXT_LINK_WAIT_CNT 10
98 #define BNXT_LINK_WAIT_INTERVAL 100
99 struct bnxt_link_info {
102 uint8_t phy_link_status;
110 #define PHY_VER_LEN 3
111 uint8_t phy_ver[PHY_VER_LEN];
113 uint16_t support_speeds;
114 uint16_t auto_link_speed;
115 uint16_t auto_link_speed_mask;
116 uint32_t preemphasis;
119 #define BNXT_COS_QUEUE_COUNT 8
120 struct bnxt_cos_queue_info {
128 struct rte_eth_dev *eth_dev;
129 struct rte_pci_device *pdev;
132 #define BNXT_FLAG_REGISTERED (1 << 0)
133 #define BNXT_FLAG_VF (1 << 1)
134 #define BNXT_FLAG_PORT_STATS (1 << 2)
135 #define BNXT_FLAG_JUMBO (1 << 3)
136 #define BNXT_PF(bp) (!((bp)->flags & BNXT_FLAG_VF))
137 #define BNXT_VF(bp) ((bp)->flags & BNXT_FLAG_VF)
138 #define BNXT_NPAR_ENABLED(bp) ((bp)->port_partition_type)
139 #define BNXT_NPAR_PF(bp) (BNXT_PF(bp) && BNXT_NPAR_ENABLED(bp))
141 unsigned int rx_nr_rings;
142 unsigned int rx_cp_nr_rings;
143 struct bnxt_rx_queue **rx_queues;
144 const void *rx_mem_zone;
145 struct rx_port_stats *hw_rx_port_stats;
146 phys_addr_t hw_rx_port_stats_map;
148 unsigned int tx_nr_rings;
149 unsigned int tx_cp_nr_rings;
150 struct bnxt_tx_queue **tx_queues;
151 const void *tx_mem_zone;
152 struct tx_port_stats *hw_tx_port_stats;
153 phys_addr_t hw_tx_port_stats_map;
155 /* Default completion ring */
156 struct bnxt_cp_ring_info *def_cp_ring;
157 uint32_t max_ring_grps;
158 struct bnxt_ring_grp_info *grp_info;
160 unsigned int nr_vnics;
162 struct bnxt_vnic_info *vnic_info;
163 STAILQ_HEAD(, bnxt_vnic_info) free_vnic_list;
165 struct bnxt_filter_info *filter_info;
166 STAILQ_HEAD(, bnxt_filter_info) free_filter_list;
168 /* VNIC pointer for flow filter (VMDq) pools */
169 #define MAX_FF_POOLS ETH_64_POOLS
170 STAILQ_HEAD(, bnxt_vnic_info) ff_pool[MAX_FF_POOLS];
172 struct bnxt_irq *irq_tbl;
174 #define MAX_NUM_MAC_ADDR 32
175 uint8_t mac_addr[ETHER_ADDR_LEN];
177 uint16_t hwrm_cmd_seq;
178 void *hwrm_cmd_resp_addr;
179 phys_addr_t hwrm_cmd_resp_dma_addr;
180 rte_spinlock_t hwrm_lock;
181 uint16_t max_req_len;
182 uint16_t max_resp_len;
184 struct bnxt_link_info link_info;
185 struct bnxt_cos_queue_info cos_queue[BNXT_COS_QUEUE_COUNT];
188 uint8_t dflt_mac_addr[ETHER_ADDR_LEN];
189 uint16_t max_rsscos_ctx;
190 uint16_t max_cp_rings;
191 uint16_t max_tx_rings;
192 uint16_t max_rx_rings;
195 uint16_t max_stat_ctx;
197 struct bnxt_pf_info pf;
198 uint8_t port_partition_type;
200 uint8_t vxlan_port_cnt;
201 uint8_t geneve_port_cnt;
203 uint16_t geneve_port;
204 uint16_t vxlan_fw_dst_port_id;
205 uint16_t geneve_fw_dst_port_id;
207 rte_atomic64_t rx_mbuf_alloc_fail;
211 * Response sent back to the caller after callback
213 enum rte_pmd_bnxt_mb_event_rsp {
214 RTE_PMD_BNXT_MB_EVENT_NOOP_ACK, /**< skip mbox request and ACK */
215 RTE_PMD_BNXT_MB_EVENT_NOOP_NACK, /**< skip mbox request and NACK */
216 RTE_PMD_BNXT_MB_EVENT_PROCEED, /**< proceed with mbox request */
217 RTE_PMD_BNXT_MB_EVENT_MAX /**< max value of this enum */
220 /* mailbox message types */
221 #define BNXT_VF_RESET 0x01 /* VF requests reset */
222 #define BNXT_VF_SET_MAC_ADDR 0x02 /* VF requests PF to set MAC addr */
223 #define BNXT_VF_SET_VLAN 0x03 /* VF requests PF to set VLAN */
224 #define BNXT_VF_SET_MTU 0x04 /* VF requests PF to set MTU */
225 #define BNXT_VF_SET_MRU 0x05 /* VF requests PF to set MRU */
228 * Data sent to the caller when the callback is executed.
230 struct rte_pmd_bnxt_mb_event_param {
231 uint16_t vf_id; /* Virtual Function number */
232 int retval; /* return value */
233 void *msg; /* pointer to message */
236 int bnxt_link_update_op(struct rte_eth_dev *eth_dev, int wait_to_complete);
237 int bnxt_rcv_msg_from_vf(struct bnxt *bp, uint16_t vf_id, void *msg);
239 #define RX_PROD_AGG_BD_TYPE_RX_PROD_AGG 0x6