2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
4 * Copyright (c) 2013-2014 Qlogic Corporation
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 * POSSIBILITY OF SUCH DAMAGE.
34 * Author : David C Somayajulu, Qlogic Corporation, Aliso Viejo, CA 92656.
41 * structure encapsulating a DMA buffer
49 bus_dma_tag_t dma_tag;
51 typedef struct qla_dma qla_dma_t;
54 * structure encapsulating interrupt vectors
63 typedef struct qla_ivec qla_ivec_t;
66 * Transmit Related Definitions
69 #define MAX_TX_RINGS 1
70 #define NUM_TX_DESCRIPTORS 1024
72 #define QLA_MAX_SEGMENTS 64 /* maximum # of segs in a sg list */
73 #define QLA_OAL_BLK_SIZE (sizeof (q81_txb_desc_t) * QLA_MAX_SEGMENTS)
75 #define QLA_TX_OALB_TOTAL_SIZE (NUM_TX_DESCRIPTORS * QLA_OAL_BLK_SIZE)
77 #define QLA_TX_PRIVATE_BSIZE ((QLA_TX_OALB_TOTAL_SIZE + \
79 (PAGE_SIZE - 1)) & ~(PAGE_SIZE - 1))
81 #define QLA_MAX_MTU 9000
82 #define QLA_STD_FRAME_SIZE 1514
83 #define QLA_MAX_TSO_FRAME_SIZE ((64 * 1024 - 1) + 22)
85 #define QL_FRAME_HDR_SIZE (ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN +\
86 sizeof (struct ip6_hdr) + sizeof (struct tcphdr) + 16)
92 /* The number of entries in the OAL is determined by QLA_MAX_SEGMENTS */
96 typedef struct qla_tx_buf qla_tx_buf_t;
107 qla_tx_buf_t tx_buf[NUM_TX_DESCRIPTORS];
110 struct resource *wq_db_addr;
111 uint32_t wq_db_offset;
113 q81_tx_cmd_t *wq_vaddr;
117 bus_addr_t wq_icb_paddr;
119 uint32_t *txr_cons_vaddr;
120 bus_addr_t txr_cons_paddr;
122 volatile uint32_t txr_free; /* # of free entries in tx ring */
123 volatile uint32_t txr_next; /* # next available tx ring entry */
124 volatile uint32_t txr_done;
127 uint64_t tx_tso_frames;
128 uint64_t tx_vlan_frames;
130 typedef struct qla_tx_ring qla_tx_ring_t;
133 * Receive Related Definitions
136 #define MAX_RX_RINGS MAX_TX_RINGS
138 #define NUM_RX_DESCRIPTORS 1024
139 #define NUM_CQ_ENTRIES NUM_RX_DESCRIPTORS
141 #define QLA_LGB_SIZE (12 * 1024)
142 #define QLA_NUM_LGB_ENTRIES 32
144 #define QLA_LBQ_SIZE (QLA_NUM_LGB_ENTRIES * sizeof(q81_bq_addr_e_t))
146 #define QLA_LGBQ_AND_TABLE_SIZE \
147 ((QLA_LBQ_SIZE + PAGE_SIZE + (PAGE_SIZE - 1)) & ~(PAGE_SIZE - 1))
149 /* Please note that Small Buffer size is determined by max mtu size */
150 #define QLA_NUM_SMB_ENTRIES NUM_RX_DESCRIPTORS
152 #define QLA_SBQ_SIZE (QLA_NUM_SMB_ENTRIES * sizeof(q81_bq_addr_e_t))
154 #define QLA_SMBQ_AND_TABLE_SIZE \
155 ((QLA_SBQ_SIZE + PAGE_SIZE + (PAGE_SIZE - 1)) & ~(PAGE_SIZE - 1))
163 typedef struct qla_rx_buf qla_rx_buf_t;
180 qla_rx_buf_t rx_buf[NUM_RX_DESCRIPTORS];
181 qla_rx_buf_t *rxb_free;
185 uint32_t cq_db_offset;
188 bus_addr_t cq_icb_paddr;
191 bus_addr_t cqi_paddr;
194 bus_addr_t cq_base_paddr;
195 uint32_t cq_next; /* next cq entry to process */
197 void *lbq_addr_tbl_vaddr;
198 bus_addr_t lbq_addr_tbl_paddr;
201 bus_addr_t lbq_paddr;
202 uint32_t lbq_next; /* next entry in LBQ to process */
203 uint32_t lbq_free;/* # of entries in LBQ to arm */
204 uint32_t lbq_in; /* next entry in LBQ to arm */
209 void *sbq_addr_tbl_vaddr;
210 bus_addr_t sbq_addr_tbl_paddr;
213 bus_addr_t sbq_paddr;
214 uint32_t sbq_next; /* next entry in SBQ to process */
215 uint32_t sbq_free;/* # of entries in SBQ to arm */
216 uint32_t sbq_in; /* next entry in SBQ to arm */
221 typedef struct qla_rx_ring qla_rx_ring_t;
223 #define QLA_WATCHDOG_CALLOUT_TICKS 1
226 * Multicast Definitions
228 typedef struct _qla_mcast {
231 } __packed qla_mcast_t;
236 #define QLA_PAGE_SIZE 4096
239 * Adapter structure contains the hardware independent information of the
249 qla_watchdog_active :1,
250 qla_watchdog_exit :1,
251 qla_watchdog_pause :1,
257 volatile uint32_t hw_init;
259 volatile uint32_t qla_watchdog_exited;
260 volatile uint32_t qla_watchdog_paused;
261 volatile uint32_t qla_initiate_recovery;
266 uint16_t watchdog_ticks;
270 struct cdev *ioctl_dev;
272 /* register mapping */
273 struct resource *pci_reg;
276 struct resource *pci_reg1;
280 qla_ivec_t irq_vec[MAX_RX_RINGS];
283 bus_dma_tag_t parent_tag;
285 /* interface to o.s */
288 struct ifmedia media;
289 uint16_t max_frame_size;
294 /* hardware access lock */
296 volatile uint32_t hw_lock_held;
299 /* transmit related */
300 uint32_t num_tx_rings;
301 qla_tx_ring_t tx_ring[MAX_TX_RINGS];
303 bus_dma_tag_t tx_tag;
305 struct taskqueue *tx_tq;
306 struct callout tx_callout;
309 /* receive related */
310 uint32_t num_rx_rings;
311 qla_rx_ring_t rx_ring[MAX_RX_RINGS];
312 bus_dma_tag_t rx_tag;
315 uint32_t err_m_getcl;
316 uint32_t err_m_getjcl;
317 uint32_t err_tx_dmamap_create;
318 uint32_t err_tx_dmamap_load;
319 uint32_t err_tx_defrag;
321 /* mac address related */
322 uint8_t mac_rcv_mode;
323 uint8_t mac_addr[ETHER_ADDR_LEN];
325 qla_mcast_t mcast[Q8_MAX_NUM_MULTICAST_ADDRS];
329 uint32_t link_status;
330 uint32_t link_down_info;
331 uint32_t link_hw_info;
332 uint32_t link_dcbx_counters;
333 uint32_t link_change_counters;
339 volatile const char *qla_lock;
340 volatile const char *qla_unlock;
342 /* Error Recovery Related */
344 struct task err_task;
345 struct taskqueue *err_tq;
350 /* mailbox completions */
351 uint32_t aen[Q81_NUM_AEN_REGISTERS];
352 uint32_t mbox[Q81_NUM_MBX_REGISTERS];
353 volatile uint32_t mbx_done;
355 /* mpi dump related */
360 typedef struct qla_host qla_host_t;
362 /* note that align has to be a power of 2 */
363 #define QL_ALIGN(size, align) (((size) + ((align) - 1)) & (~((align) - 1)))
364 #define QL_MIN(x, y) ((x < y) ? x : y)
366 #define QL_RUNNING(ifp) \
367 ((ifp->if_drv_flags & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) == \
370 /* Return 0, if identical, else 1 */
372 #define QL_MAC_CMP(mac1, mac2) \
373 ((((*(uint32_t *) mac1) == (*(uint32_t *) mac2) && \
374 (*(uint16_t *)(mac1 + 4)) == (*(uint16_t *)(mac2 + 4)))) ? 0 : 1)
376 #endif /* #ifndef _QLS_DEF_H_ */