4 * Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
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 Intel 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.
38 * 32 bits tx flags, high 16 bits for L2TAG1 (VLAN),
39 * low 16 bits for others.
41 #define I40E_TX_FLAG_L2TAG1_SHIFT 16
42 #define I40E_TX_FLAG_L2TAG1_MASK 0xffff0000
43 #define I40E_TX_FLAG_CSUM ((uint32_t)(1 << 0))
44 #define I40E_TX_FLAG_INSERT_VLAN ((uint32_t)(1 << 1))
45 #define I40E_TX_FLAG_TSYN ((uint32_t)(1 << 2))
47 #ifdef RTE_LIBRTE_I40E_RX_ALLOW_BULK_ALLOC
48 #define RTE_PMD_I40E_RX_MAX_BURST 32
51 #define I40E_RXBUF_SZ_1024 1024
52 #define I40E_RXBUF_SZ_2048 2048
54 enum i40e_header_split_mode {
55 i40e_header_split_none = 0,
56 i40e_header_split_enabled = 1,
57 i40e_header_split_always = 2,
58 i40e_header_split_reserved
61 #define I40E_HEADER_SPLIT_NONE ((uint8_t)0)
62 #define I40E_HEADER_SPLIT_L2 ((uint8_t)(1 << 0))
63 #define I40E_HEADER_SPLIT_IP ((uint8_t)(1 << 1))
64 #define I40E_HEADER_SPLIT_UDP_TCP ((uint8_t)(1 << 2))
65 #define I40E_HEADER_SPLIT_SCTP ((uint8_t)(1 << 3))
66 #define I40E_HEADER_SPLIT_ALL (I40E_HEADER_SPLIT_L2 | \
67 I40E_HEADER_SPLIT_IP | \
68 I40E_HEADER_SPLIT_UDP_TCP | \
69 I40E_HEADER_SPLIT_SCTP)
71 /* HW desc structure, both 16-byte and 32-byte types are supported */
72 #ifdef RTE_LIBRTE_I40E_16BYTE_RX_DESC
73 #define i40e_rx_desc i40e_16byte_rx_desc
75 #define i40e_rx_desc i40e_32byte_rx_desc
78 struct i40e_rx_entry {
79 struct rte_mbuf *mbuf;
83 * Structure associated with each RX queue.
85 struct i40e_rx_queue {
86 struct rte_mempool *mp; /**< mbuf pool to populate RX ring */
87 volatile union i40e_rx_desc *rx_ring;/**< RX ring virtual address */
88 uint64_t rx_ring_phys_addr; /**< RX ring DMA address */
89 struct i40e_rx_entry *sw_ring; /**< address of RX soft ring */
90 uint16_t nb_rx_desc; /**< number of RX descriptors */
91 uint16_t rx_free_thresh; /**< max free RX desc to hold */
92 uint16_t rx_tail; /**< current value of tail */
93 uint16_t nb_rx_hold; /**< number of held free RX desc */
94 struct rte_mbuf *pkt_first_seg; /**< first segment of current packet */
95 struct rte_mbuf *pkt_last_seg; /**< last segment of current packet */
96 #ifdef RTE_LIBRTE_I40E_RX_ALLOW_BULK_ALLOC
97 uint16_t rx_nb_avail; /**< number of staged packets ready */
98 uint16_t rx_next_avail; /**< index of next staged packets */
99 uint16_t rx_free_trigger; /**< triggers rx buffer allocation */
100 struct rte_mbuf fake_mbuf; /**< dummy mbuf */
101 struct rte_mbuf *rx_stage[RTE_PMD_I40E_RX_MAX_BURST * 2];
103 uint8_t port_id; /**< device port ID */
104 uint8_t crc_len; /**< 0 if CRC stripped, 4 otherwise */
105 uint16_t queue_id; /**< RX queue index */
106 uint16_t reg_idx; /**< RX queue register index */
107 uint8_t drop_en; /**< if not 0, set register bit */
108 volatile uint8_t *qrx_tail; /**< register address of tail */
109 struct i40e_vsi *vsi; /**< the VSI this queue belongs to */
110 uint16_t rx_buf_len; /* The packet buffer size */
111 uint16_t rx_hdr_len; /* The header buffer size */
112 uint16_t max_pkt_len; /* Maximum packet length */
113 uint8_t hs_mode; /* Header Split mode */
114 bool q_set; /**< indicate if rx queue has been configured */
115 bool rx_deferred_start; /**< don't start this queue in dev start */
118 struct i40e_tx_entry {
119 struct rte_mbuf *mbuf;
125 * Structure associated with each TX queue.
127 struct i40e_tx_queue {
128 uint16_t nb_tx_desc; /**< number of TX descriptors */
129 uint64_t tx_ring_phys_addr; /**< TX ring DMA address */
130 volatile struct i40e_tx_desc *tx_ring; /**< TX ring virtual address */
131 struct i40e_tx_entry *sw_ring; /**< virtual address of SW ring */
132 uint16_t tx_tail; /**< current value of tail register */
133 volatile uint8_t *qtx_tail; /**< register address of tail */
134 uint16_t nb_tx_used; /**< number of TX desc used since RS bit set */
135 /**< index to last TX descriptor to have been cleaned */
136 uint16_t last_desc_cleaned;
137 /**< Total number of TX descriptors ready to be allocated. */
139 /**< Start freeing TX buffers if there are less free descriptors than
141 uint16_t tx_free_thresh;
142 /** Number of TX descriptors to use before RS bit is set. */
143 uint16_t tx_rs_thresh;
144 uint8_t pthresh; /**< Prefetch threshold register. */
145 uint8_t hthresh; /**< Host threshold register. */
146 uint8_t wthresh; /**< Write-back threshold reg. */
147 uint8_t port_id; /**< Device port identifier. */
148 uint16_t queue_id; /**< TX queue index. */
151 struct i40e_vsi *vsi; /**< the VSI this queue belongs to */
154 bool q_set; /**< indicate if tx queue has been configured */
155 bool tx_deferred_start; /**< don't start this queue in dev start */
158 /** Offload features */
159 union i40e_tx_offload {
162 uint64_t l2_len:7; /**< L2 (MAC) Header Length. */
163 uint64_t l3_len:9; /**< L3 (IP) Header Length. */
164 uint64_t l4_len:8; /**< L4 Header Length. */
165 uint64_t tso_segsz:16; /**< TCP TSO segment size */
166 uint64_t outer_l2_len:8; /**< outer L2 Header Length */
167 uint64_t outer_l3_len:16; /**< outer L3 Header Length */
171 int i40e_dev_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id);
172 int i40e_dev_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id);
173 int i40e_dev_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id);
174 int i40e_dev_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id);
175 int i40e_dev_rx_queue_setup(struct rte_eth_dev *dev,
178 unsigned int socket_id,
179 const struct rte_eth_rxconf *rx_conf,
180 struct rte_mempool *mp);
181 int i40e_dev_tx_queue_setup(struct rte_eth_dev *dev,
184 unsigned int socket_id,
185 const struct rte_eth_txconf *tx_conf);
186 void i40e_dev_rx_queue_release(void *rxq);
187 void i40e_dev_tx_queue_release(void *txq);
188 uint16_t i40e_recv_pkts(void *rx_queue,
189 struct rte_mbuf **rx_pkts,
191 uint16_t i40e_recv_scattered_pkts(void *rx_queue,
192 struct rte_mbuf **rx_pkts,
194 uint16_t i40e_xmit_pkts(void *tx_queue,
195 struct rte_mbuf **tx_pkts,
197 int i40e_tx_queue_init(struct i40e_tx_queue *txq);
198 int i40e_rx_queue_init(struct i40e_rx_queue *rxq);
199 void i40e_free_tx_resources(struct i40e_tx_queue *txq);
200 void i40e_free_rx_resources(struct i40e_rx_queue *rxq);
201 void i40e_dev_clear_queues(struct rte_eth_dev *dev);
202 void i40e_dev_free_queues(struct rte_eth_dev *dev);
203 void i40e_reset_rx_queue(struct i40e_rx_queue *rxq);
204 void i40e_reset_tx_queue(struct i40e_tx_queue *txq);
205 void i40e_tx_queue_release_mbufs(struct i40e_tx_queue *txq);
206 int i40e_alloc_rx_queue_mbufs(struct i40e_rx_queue *rxq);
207 void i40e_rx_queue_release_mbufs(struct i40e_rx_queue *rxq);
209 uint32_t i40e_dev_rx_queue_count(struct rte_eth_dev *dev,
210 uint16_t rx_queue_id);
211 int i40e_dev_rx_descriptor_done(void *rx_queue, uint16_t offset);
213 #endif /* _I40E_RXTX_H_ */