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
50 #define BNXT_MAX_LED 4
52 struct bnxt_led_info {
57 uint16_t led_state_caps;
58 #define BNXT_LED_ALT_BLINK_CAP(x) ((x) & \
59 rte_cpu_to_le_16(HWRM_PORT_LED_QCFG_OUTPUT_LED0_STATE_BLINKALT))
61 uint16_t led_color_caps;
69 uint16_t led_blink_on;
70 uint16_t led_blink_off;
75 #define BNXT_LED_DFLT_ENA \
76 (HWRM_PORT_LED_CFG_INPUT_ENABLES_LED0_ID | \
77 HWRM_PORT_LED_CFG_INPUT_ENABLES_LED0_STATE | \
78 HWRM_PORT_LED_CFG_INPUT_ENABLES_LED0_BLINK_ON | \
79 HWRM_PORT_LED_CFG_INPUT_ENABLES_LED0_BLINK_OFF | \
80 HWRM_PORT_LED_CFG_INPUT_ENABLES_LED0_GROUP_ID)
82 #define BNXT_LED_DFLT_ENA_SHIFT 6
84 #define BNXT_LED_DFLT_ENABLES(x) \
85 rte_cpu_to_le_32(BNXT_LED_DFLT_ENA << (BNXT_LED_DFLT_ENA_SHIFT * (x)))
87 enum bnxt_hw_context {
89 HW_CONTEXT_IS_RSS = 1,
90 HW_CONTEXT_IS_COS = 2,
94 struct bnxt_vlan_table_entry {
97 } __attribute__((packed));
99 struct bnxt_child_vf_info {
101 struct bnxt_vlan_table_entry *vlan_table;
102 STAILQ_HEAD(, bnxt_filter_info) filter;
103 uint32_t func_cfg_flags;
110 struct bnxt_pf_info {
111 #define BNXT_FIRST_PF_FID 1
112 #define BNXT_MAX_VFS(bp) (bp->pf.max_vfs)
113 #define BNXT_FIRST_VF_FID 128
114 #define BNXT_PF_RINGS_USED(bp) bnxt_get_num_queues(bp)
115 #define BNXT_PF_RINGS_AVAIL(bp) (bp->pf.max_cp_rings - BNXT_PF_RINGS_USED(bp))
117 uint16_t first_vf_id;
120 uint32_t func_cfg_flags;
122 phys_addr_t vf_req_buf_dma_addr;
123 uint32_t vf_req_fwd[8];
124 uint16_t total_vnics;
125 struct bnxt_child_vf_info *vf_info;
126 #define BNXT_EVB_MODE_NONE 0
127 #define BNXT_EVB_MODE_VEB 1
128 #define BNXT_EVB_MODE_VEPA 2
132 /* Max wait time is 10 * 100ms = 1s */
133 #define BNXT_LINK_WAIT_CNT 10
134 #define BNXT_LINK_WAIT_INTERVAL 100
135 struct bnxt_link_info {
138 uint8_t phy_link_status;
146 #define PHY_VER_LEN 3
147 uint8_t phy_ver[PHY_VER_LEN];
149 uint16_t support_speeds;
150 uint16_t auto_link_speed;
151 uint16_t auto_link_speed_mask;
152 uint32_t preemphasis;
155 #define BNXT_COS_QUEUE_COUNT 8
156 struct bnxt_cos_queue_info {
164 struct rte_eth_dev *eth_dev;
165 struct rte_pci_device *pdev;
168 #define BNXT_FLAG_REGISTERED (1 << 0)
169 #define BNXT_FLAG_VF (1 << 1)
170 #define BNXT_FLAG_PORT_STATS (1 << 2)
171 #define BNXT_FLAG_JUMBO (1 << 3)
172 #define BNXT_PF(bp) (!((bp)->flags & BNXT_FLAG_VF))
173 #define BNXT_VF(bp) ((bp)->flags & BNXT_FLAG_VF)
174 #define BNXT_NPAR_ENABLED(bp) ((bp)->port_partition_type)
175 #define BNXT_NPAR_PF(bp) (BNXT_PF(bp) && BNXT_NPAR_ENABLED(bp))
177 unsigned int rx_nr_rings;
178 unsigned int rx_cp_nr_rings;
179 struct bnxt_rx_queue **rx_queues;
180 const void *rx_mem_zone;
181 struct rx_port_stats *hw_rx_port_stats;
182 phys_addr_t hw_rx_port_stats_map;
184 unsigned int tx_nr_rings;
185 unsigned int tx_cp_nr_rings;
186 struct bnxt_tx_queue **tx_queues;
187 const void *tx_mem_zone;
188 struct tx_port_stats *hw_tx_port_stats;
189 phys_addr_t hw_tx_port_stats_map;
191 /* Default completion ring */
192 struct bnxt_cp_ring_info *def_cp_ring;
193 uint32_t max_ring_grps;
194 struct bnxt_ring_grp_info *grp_info;
196 unsigned int nr_vnics;
198 struct bnxt_vnic_info *vnic_info;
199 STAILQ_HEAD(, bnxt_vnic_info) free_vnic_list;
201 struct bnxt_filter_info *filter_info;
202 STAILQ_HEAD(, bnxt_filter_info) free_filter_list;
204 /* VNIC pointer for flow filter (VMDq) pools */
205 #define MAX_FF_POOLS ETH_64_POOLS
206 STAILQ_HEAD(, bnxt_vnic_info) ff_pool[MAX_FF_POOLS];
208 struct bnxt_irq *irq_tbl;
210 #define MAX_NUM_MAC_ADDR 32
211 uint8_t mac_addr[ETHER_ADDR_LEN];
213 uint16_t hwrm_cmd_seq;
214 void *hwrm_cmd_resp_addr;
215 phys_addr_t hwrm_cmd_resp_dma_addr;
216 rte_spinlock_t hwrm_lock;
217 uint16_t max_req_len;
218 uint16_t max_resp_len;
220 struct bnxt_link_info link_info;
221 struct bnxt_cos_queue_info cos_queue[BNXT_COS_QUEUE_COUNT];
224 uint8_t dflt_mac_addr[ETHER_ADDR_LEN];
225 uint16_t max_rsscos_ctx;
226 uint16_t max_cp_rings;
227 uint16_t max_tx_rings;
228 uint16_t max_rx_rings;
231 uint16_t max_stat_ctx;
233 struct bnxt_pf_info pf;
234 uint8_t port_partition_type;
236 uint8_t vxlan_port_cnt;
237 uint8_t geneve_port_cnt;
239 uint16_t geneve_port;
240 uint16_t vxlan_fw_dst_port_id;
241 uint16_t geneve_fw_dst_port_id;
243 rte_atomic64_t rx_mbuf_alloc_fail;
245 struct bnxt_led_info leds[BNXT_MAX_LED];
250 * Response sent back to the caller after callback
252 enum rte_pmd_bnxt_mb_event_rsp {
253 RTE_PMD_BNXT_MB_EVENT_NOOP_ACK, /**< skip mbox request and ACK */
254 RTE_PMD_BNXT_MB_EVENT_NOOP_NACK, /**< skip mbox request and NACK */
255 RTE_PMD_BNXT_MB_EVENT_PROCEED, /**< proceed with mbox request */
256 RTE_PMD_BNXT_MB_EVENT_MAX /**< max value of this enum */
259 /* mailbox message types */
260 #define BNXT_VF_RESET 0x01 /* VF requests reset */
261 #define BNXT_VF_SET_MAC_ADDR 0x02 /* VF requests PF to set MAC addr */
262 #define BNXT_VF_SET_VLAN 0x03 /* VF requests PF to set VLAN */
263 #define BNXT_VF_SET_MTU 0x04 /* VF requests PF to set MTU */
264 #define BNXT_VF_SET_MRU 0x05 /* VF requests PF to set MRU */
267 * Data sent to the caller when the callback is executed.
269 struct rte_pmd_bnxt_mb_event_param {
270 uint16_t vf_id; /* Virtual Function number */
271 int retval; /* return value */
272 void *msg; /* pointer to message */
275 int bnxt_link_update_op(struct rte_eth_dev *eth_dev, int wait_to_complete);
276 int bnxt_rcv_msg_from_vf(struct bnxt *bp, uint16_t vf_id, void *msg);
278 #define RX_PROD_AGG_BD_TYPE_RX_PROD_AGG 0x6