2 * Copyright (c) 2001-2013, Intel Corporation
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the Intel Corporation nor the names of its
16 * contributors may be used to endorse or promote products derived from
17 * this software without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
40 #define IX_MAX_MSIX 64
41 #define IX_MAX_MSIX_82598 16
46 #define IX_MAX_RXRING 16
47 #define IX_MIN_RXRING_RSS 2
52 #define IX_MAX_TXRING_82598 32
53 #define IX_MAX_TXRING_82599 64
54 #define IX_MAX_TXRING_X540 64
57 * Default number of segments received before writing to RX related registers
59 #define IX_DEF_RXWREG_NSEGS 32
62 * Default number of segments sent before writing to TX related registers
64 #define IX_DEF_TXWREG_NSEGS 8
67 * TxDescriptors Valid Range: 64-4096 Default Value: 256 This value is the
68 * number of transmit descriptors allocated by the driver. Increasing this
69 * value allows the driver to queue more transmits. Each descriptor is 16
70 * bytes. Performance tests have show the 2K value to be optimal for top
73 #define IX_DEF_TXD 1024
74 #define IX_PERF_TXD 2048
75 #define IX_MAX_TXD 4096
79 * RxDescriptors Valid Range: 64-4096 Default Value: 256 This value is the
80 * number of receive descriptors allocated for each RX queue. Increasing this
81 * value allows the driver to buffer more incoming packets. Each descriptor
82 * is 16 bytes. A receive buffer is also allocated for each descriptor.
84 * Note: with 8 rings and a dual port card, it is possible to bump up
85 * against the system mbuf pool limit, you can tune nmbclusters
88 #define IX_DEF_RXD 1024
89 #define IX_PERF_RXD 2048
90 #define IX_MAX_RXD 4096
93 /* Alignment for rings */
94 #define IX_DBA_ALIGN 128
96 #define IX_MAX_FRAME_SIZE 9728
97 #define IX_MTU_HDR (ETHER_HDR_LEN + ETHER_CRC_LEN + EVL_ENCAPLEN)
98 #define IX_MAX_MTU (IX_MAX_FRAME_SIZE - IX_MTU_HDR)
101 /* Flow control constants */
102 #define IX_FC_PAUSE 0xFFFF
103 #define IX_FC_HI 0x20000
104 #define IX_FC_LO 0x10000
107 * RSS related registers
110 #define IX_RSSRK_SIZE 4
111 #define IX_RSSRK_VAL(key, i) (key[(i) * IX_RSSRK_SIZE] | \
112 key[(i) * IX_RSSRK_SIZE + 1] << 8 | \
113 key[(i) * IX_RSSRK_SIZE + 2] << 16 | \
114 key[(i) * IX_RSSRK_SIZE + 3] << 24)
116 #define IX_NRETA_X550 128
117 #define IX_RETA_SIZE 4
122 #define IX_EITR_INTVL_MASK_82598 0xffff
123 #define IX_EITR_INTVL_MASK 0x0fff
124 #define IX_EITR_INTVL_RSVD_MASK 0x0007
125 #define IX_EITR_INTVL_MIN IXGBE_MIN_EITR
126 #define IX_EITR_INTVL_MAX IXGBE_MAX_EITR
129 * Used for optimizing small rx mbufs. Effort is made to keep the copy
130 * small and aligned for the CPU L1 cache.
132 * MHLEN is typically 168 bytes, giving us 8-byte alignment. Getting
133 * 32 byte alignment needed for the fast bcopy results in 8 bytes being
134 * wasted. Getting 64 byte alignment, which _should_ be ideal for
135 * modern Intel CPUs, results in 40 bytes wasted and a significant drop
136 * in observed efficiency of the optimization, 97.9% -> 81.8%.
138 #define IX_RX_COPY_LEN 160
139 #define IX_RX_COPY_ALIGN (MHLEN - IX_RX_COPY_LEN)
141 #define IX_MAX_MCASTADDR 128
143 #define IX_MSIX_BAR_82598 3
144 #define IX_MSIX_BAR_82599 4
146 #define IX_TSO_SIZE (IP_MAXPACKET + \
147 sizeof(struct ether_vlan_header))
150 * MUST be less than 38. Though 82598 does not have this limit,
151 * we don't want long TX chain. 33 should be large enough even
152 * for 64K TSO (32 x 2K mbuf cluster and 1 x mbuf header).
155 * - 82599 datasheet 7.2.1.1
156 * - X540 datasheet 7.2.1.1
158 #define IX_MAX_SCATTER 33
159 #define IX_TX_RESERVED 3 /* 1 for TX ctx, 2 reserved */
161 /* MSI and legacy interrupt */
162 #define IX_TX_INTR_VEC 0
163 #define IX_TX_INTR_MASK (1 << IX_TX_INTR_VEC)
164 #define IX_RX0_INTR_VEC 1
165 #define IX_RX0_INTR_MASK (1 << IX_RX0_INTR_VEC)
166 #define IX_RX1_INTR_VEC 2
167 #define IX_RX1_INTR_MASK (1 << IX_RX1_INTR_VEC)
169 #define IX_INTR_RATE 8000
170 #define IX_MSIX_RX_RATE 8000
171 #define IX_MSIX_TX_RATE 6000
173 /* IOCTL define to gather SFP+ Diagnostic data */
174 #define SIOCGI2C SIOCGIFGENERIC
176 /* TX checksum offload */
177 #define CSUM_OFFLOAD (CSUM_IP|CSUM_TCP|CSUM_UDP)
179 #define IX_EICR_STATUS (IXGBE_EICR_LSC | IXGBE_EICR_ECC | \
180 IXGBE_EICR_GPI_SDP1 | IXGBE_EICR_GPI_SDP2 | \
183 /* This is used to get SFP+ module data */
203 #define IX_RX_COPY 0x1
209 struct lwkt_serialize tx_serialize
;
210 struct ifaltq_subque
*tx_ifsq
;
211 struct ix_softc
*tx_sc
;
212 volatile uint32_t *tx_hdr
;
213 union ixgbe_adv_tx_desc
*tx_base
;
214 struct ix_tx_buf
*tx_buf
;
215 bus_dma_tag_t tx_tag
;
217 #define IX_TXFLAG_ENABLED 0x1
221 uint16_t tx_next_avail
;
222 uint16_t tx_next_clean
;
224 uint16_t tx_wreg_nsegs
;
225 uint16_t tx_intr_nsegs
;
230 uint32_t tx_eims_val
;
231 struct ifsubq_watchdog tx_watchdog
;
233 bus_dma_tag_t tx_base_dtag
;
234 bus_dmamap_t tx_base_map
;
235 bus_addr_t tx_base_paddr
;
237 bus_dma_tag_t tx_hdr_dtag
;
238 bus_dmamap_t tx_hdr_map
;
239 bus_addr_t tx_hdr_paddr
;
243 struct lwkt_serialize rx_serialize
;
244 struct ix_softc
*rx_sc
;
245 union ixgbe_adv_rx_desc
*rx_base
;
246 struct ix_rx_buf
*rx_buf
;
247 bus_dma_tag_t rx_tag
;
248 bus_dmamap_t rx_sparemap
;
251 #define IX_RXRING_FLAG_LRO 0x01
252 #define IX_RXRING_FLAG_DISC 0x02
253 uint16_t rx_next_check
;
256 uint16_t rx_wreg_nsegs
;
259 uint32_t rx_eims_val
;
260 struct ix_tx_ring
*rx_txr
; /* piggybacked TX ring */
266 bus_dma_tag_t rx_base_dtag
;
267 bus_dmamap_t rx_base_map
;
268 bus_addr_t rx_base_paddr
;
271 struct ix_intr_data
{
272 struct lwkt_serialize
*intr_serialize
;
273 driver_intr_t
*intr_func
;
275 struct resource
*intr_res
;
281 #define IX_INTR_USE_RXTX 0
282 #define IX_INTR_USE_STATUS 1
283 #define IX_INTR_USE_RX 2
284 #define IX_INTR_USE_TX 3
285 const char *intr_desc
;
290 struct arpcom arpcom
;
293 struct ixgbe_osdep osdep
;
295 struct lwkt_serialize main_serialize
;
298 boolean_t link_active
;
303 struct ix_rx_ring
*rx_rings
;
304 struct ix_tx_ring
*tx_rings
;
306 struct callout timer
;
309 int ifm_media
; /* IFM_ */
312 boolean_t sfp_probe
; /* plyggable optics */
314 struct ixgbe_hw_stats stats
;
324 struct ix_intr_data
*intr_data
;
327 bus_dma_tag_t parent_tag
;
328 struct ifmedia media
;
330 struct resource
*mem_res
;
333 struct resource
*msix_mem_res
;
337 struct lwkt_serialize
**serializes
;
339 uint8_t *mta
; /* Multicast array memory */
342 int advspeed
; /* advertised link speeds */
343 uint32_t wufc
; /* power management */
344 uint16_t dmac
; /* DMA coalescing */
345 uint16_t max_frame_size
;
346 int16_t sts_msix_vec
; /* status MSI-X vector */
356 #define IX_ENABLE_HWRSS(sc) ((sc)->rx_ring_cnt > 1)
357 #define IX_ENABLE_HWTSS(sc) ((sc)->tx_ring_cnt > 1)
359 #endif /* _IF_IX_H_ */