Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright(c) 2020 Intel Corporation
3 : : */
4 : :
5 : : #include <rte_config.h>
6 : : #include <rte_flow.h>
7 : : #include <rte_malloc.h>
8 : : #include <ethdev_driver.h>
9 : : #include <rte_net.h>
10 : :
11 : : #include "e1000_logs.h"
12 : : #include "igc_txrx.h"
13 : :
14 : : #ifdef RTE_PMD_USE_PREFETCH
15 : : #define rte_igc_prefetch(p) rte_prefetch0(p)
16 : : #else
17 : : #define rte_igc_prefetch(p) do {} while (0)
18 : : #endif
19 : :
20 : : #ifdef RTE_PMD_PACKET_PREFETCH
21 : : #define rte_packet_prefetch(p) rte_prefetch1(p)
22 : : #else
23 : : #define rte_packet_prefetch(p) do {} while (0)
24 : : #endif
25 : :
26 : : /* Multicast / Unicast table offset mask. */
27 : : #define E1000_RCTL_MO_MSK (3u << E1000_RCTL_MO_SHIFT)
28 : :
29 : : /* Loopback mode. */
30 : : #define E1000_RCTL_LBM_SHIFT 6
31 : : #define E1000_RCTL_LBM_MSK (3u << E1000_RCTL_LBM_SHIFT)
32 : :
33 : : /* Hash select for MTA */
34 : : #define E1000_RCTL_HSEL_SHIFT 8
35 : : #define E1000_RCTL_HSEL_MSK (3u << E1000_RCTL_HSEL_SHIFT)
36 : : #define E1000_RCTL_PSP (1u << 21)
37 : :
38 : : /* Receive buffer size for header buffer */
39 : : #define IGC_SRRCTL_BSIZEHEADER_SHIFT 8
40 : :
41 : : /* RX descriptor status and error flags */
42 : : #define IGC_RXD_STAT_L4CS (1u << 5)
43 : : #define IGC_RXD_STAT_VEXT (1u << 9)
44 : : #define IGC_RXD_STAT_LLINT (1u << 11)
45 : : #define IGC_RXD_STAT_SCRC (1u << 12)
46 : : #define IGC_RXD_STAT_SMDT_MASK (3u << 13)
47 : : #define IGC_RXD_STAT_MC (1u << 19)
48 : : #define IGC_RXD_EXT_ERR_L4E (1u << 29)
49 : : #define IGC_RXD_EXT_ERR_IPE (1u << 30)
50 : : #define IGC_RXD_EXT_ERR_RXE (1u << 31)
51 : : #define IGC_RXD_RSS_TYPE_MASK 0xfu
52 : : #define IGC_RXD_PCTYPE_MASK (0x7fu << 4)
53 : : #define IGC_RXD_ETQF_SHIFT 12
54 : : #define IGC_RXD_ETQF_MSK (0xfu << IGC_RXD_ETQF_SHIFT)
55 : : #define IGC_RXD_VPKT (1u << 16)
56 : :
57 : : /* TXD control bits */
58 : : #define IGC_TXDCTL_PTHRESH_SHIFT 0
59 : : #define IGC_TXDCTL_HTHRESH_SHIFT 8
60 : : #define IGC_TXDCTL_WTHRESH_SHIFT 16
61 : : #define IGC_TXDCTL_PTHRESH_MSK (0x1fu << IGC_TXDCTL_PTHRESH_SHIFT)
62 : : #define IGC_TXDCTL_HTHRESH_MSK (0x1fu << IGC_TXDCTL_HTHRESH_SHIFT)
63 : : #define IGC_TXDCTL_WTHRESH_MSK (0x1fu << IGC_TXDCTL_WTHRESH_SHIFT)
64 : :
65 : : /* RXD control bits */
66 : : #define IGC_RXDCTL_PTHRESH_SHIFT 0
67 : : #define IGC_RXDCTL_HTHRESH_SHIFT 8
68 : : #define IGC_RXDCTL_WTHRESH_SHIFT 16
69 : : #define IGC_RXDCTL_PTHRESH_MSK (0x1fu << IGC_RXDCTL_PTHRESH_SHIFT)
70 : : #define IGC_RXDCTL_HTHRESH_MSK (0x1fu << IGC_RXDCTL_HTHRESH_SHIFT)
71 : : #define IGC_RXDCTL_WTHRESH_MSK (0x1fu << IGC_RXDCTL_WTHRESH_SHIFT)
72 : :
73 : : #define IGC_TSO_MAX_HDRLEN 512
74 : : #define IGC_TSO_MAX_MSS 9216
75 : :
76 : : /* Bit Mask to indicate what bits required for building TX context */
77 : : #define IGC_TX_OFFLOAD_MASK (RTE_MBUF_F_TX_OUTER_IPV4 | \
78 : : RTE_MBUF_F_TX_IPV6 | \
79 : : RTE_MBUF_F_TX_IPV4 | \
80 : : RTE_MBUF_F_TX_VLAN | \
81 : : RTE_MBUF_F_TX_IP_CKSUM | \
82 : : RTE_MBUF_F_TX_L4_MASK | \
83 : : RTE_MBUF_F_TX_TCP_SEG | \
84 : : RTE_MBUF_F_TX_UDP_SEG | \
85 : : RTE_MBUF_F_TX_IEEE1588_TMST)
86 : :
87 : : #define IGC_TX_OFFLOAD_SEG (RTE_MBUF_F_TX_TCP_SEG | RTE_MBUF_F_TX_UDP_SEG)
88 : :
89 : : #define IGC_ADVTXD_POPTS_TXSM 0x00000200 /* L4 Checksum offload request */
90 : : #define IGC_ADVTXD_POPTS_IXSM 0x00000100 /* IP Checksum offload request */
91 : :
92 : : /* L4 Packet TYPE of Reserved */
93 : : #define IGC_ADVTXD_TUCMD_L4T_RSV 0x00001800
94 : :
95 : : #define IGC_TX_OFFLOAD_NOTSUP_MASK (RTE_MBUF_F_TX_OFFLOAD_MASK ^ IGC_TX_OFFLOAD_MASK)
96 : :
97 : : #define IGC_TS_HDR_LEN 16
98 : :
99 : : static inline uint64_t
100 : 0 : rx_desc_statuserr_to_pkt_flags(uint32_t statuserr)
101 : : {
102 : : static uint64_t l4_chksum_flags[] = {0, 0,
103 : : RTE_MBUF_F_RX_L4_CKSUM_GOOD,
104 : : RTE_MBUF_F_RX_L4_CKSUM_BAD};
105 : :
106 : : static uint64_t l3_chksum_flags[] = {0, 0,
107 : : RTE_MBUF_F_RX_IP_CKSUM_GOOD,
108 : : RTE_MBUF_F_RX_IP_CKSUM_BAD};
109 : : uint64_t pkt_flags = 0;
110 : : uint32_t tmp;
111 : :
112 [ # # ]: 0 : if (statuserr & E1000_RXD_STAT_VP)
113 : : pkt_flags |= RTE_MBUF_F_RX_VLAN_STRIPPED;
114 : :
115 : 0 : tmp = !!(statuserr & (IGC_RXD_STAT_L4CS | E1000_RXD_STAT_UDPCS));
116 : 0 : tmp = (tmp << 1) | (uint32_t)!!(statuserr & IGC_RXD_EXT_ERR_L4E);
117 : 0 : pkt_flags |= l4_chksum_flags[tmp];
118 : :
119 : 0 : tmp = !!(statuserr & E1000_RXD_STAT_IPCS);
120 : 0 : tmp = (tmp << 1) | (uint32_t)!!(statuserr & IGC_RXD_EXT_ERR_IPE);
121 : 0 : pkt_flags |= l3_chksum_flags[tmp];
122 : :
123 : 0 : return pkt_flags;
124 : : }
125 : :
126 : : #define IGC_PACKET_TYPE_IPV4 0X01
127 : : #define IGC_PACKET_TYPE_IPV4_TCP 0X11
128 : : #define IGC_PACKET_TYPE_IPV4_UDP 0X21
129 : : #define IGC_PACKET_TYPE_IPV4_SCTP 0X41
130 : : #define IGC_PACKET_TYPE_IPV4_EXT 0X03
131 : : #define IGC_PACKET_TYPE_IPV4_EXT_SCTP 0X43
132 : : #define IGC_PACKET_TYPE_IPV6 0X04
133 : : #define IGC_PACKET_TYPE_IPV6_TCP 0X14
134 : : #define IGC_PACKET_TYPE_IPV6_UDP 0X24
135 : : #define IGC_PACKET_TYPE_IPV6_EXT 0X0C
136 : : #define IGC_PACKET_TYPE_IPV6_EXT_TCP 0X1C
137 : : #define IGC_PACKET_TYPE_IPV6_EXT_UDP 0X2C
138 : : #define IGC_PACKET_TYPE_IPV4_IPV6 0X05
139 : : #define IGC_PACKET_TYPE_IPV4_IPV6_TCP 0X15
140 : : #define IGC_PACKET_TYPE_IPV4_IPV6_UDP 0X25
141 : : #define IGC_PACKET_TYPE_IPV4_IPV6_EXT 0X0D
142 : : #define IGC_PACKET_TYPE_IPV4_IPV6_EXT_TCP 0X1D
143 : : #define IGC_PACKET_TYPE_IPV4_IPV6_EXT_UDP 0X2D
144 : : #define IGC_PACKET_TYPE_MAX 0X80
145 : : #define IGC_PACKET_TYPE_MASK 0X7F
146 : : #define IGC_PACKET_TYPE_SHIFT 0X04
147 : :
148 : : static inline uint32_t
149 : : rx_desc_pkt_info_to_pkt_type(uint32_t pkt_info)
150 : : {
151 : : static const alignas(RTE_CACHE_LINE_SIZE) uint32_t
152 : : ptype_table[IGC_PACKET_TYPE_MAX] = {
153 : : [IGC_PACKET_TYPE_IPV4] = RTE_PTYPE_L2_ETHER |
154 : : RTE_PTYPE_L3_IPV4,
155 : : [IGC_PACKET_TYPE_IPV4_EXT] = RTE_PTYPE_L2_ETHER |
156 : : RTE_PTYPE_L3_IPV4_EXT,
157 : : [IGC_PACKET_TYPE_IPV6] = RTE_PTYPE_L2_ETHER |
158 : : RTE_PTYPE_L3_IPV6,
159 : : [IGC_PACKET_TYPE_IPV4_IPV6] = RTE_PTYPE_L2_ETHER |
160 : : RTE_PTYPE_L3_IPV4 | RTE_PTYPE_TUNNEL_IP |
161 : : RTE_PTYPE_INNER_L3_IPV6,
162 : : [IGC_PACKET_TYPE_IPV6_EXT] = RTE_PTYPE_L2_ETHER |
163 : : RTE_PTYPE_L3_IPV6_EXT,
164 : : [IGC_PACKET_TYPE_IPV4_IPV6_EXT] = RTE_PTYPE_L2_ETHER |
165 : : RTE_PTYPE_L3_IPV4 | RTE_PTYPE_TUNNEL_IP |
166 : : RTE_PTYPE_INNER_L3_IPV6_EXT,
167 : : [IGC_PACKET_TYPE_IPV4_TCP] = RTE_PTYPE_L2_ETHER |
168 : : RTE_PTYPE_L3_IPV4 | RTE_PTYPE_L4_TCP,
169 : : [IGC_PACKET_TYPE_IPV6_TCP] = RTE_PTYPE_L2_ETHER |
170 : : RTE_PTYPE_L3_IPV6 | RTE_PTYPE_L4_TCP,
171 : : [IGC_PACKET_TYPE_IPV4_IPV6_TCP] = RTE_PTYPE_L2_ETHER |
172 : : RTE_PTYPE_L3_IPV4 | RTE_PTYPE_TUNNEL_IP |
173 : : RTE_PTYPE_INNER_L3_IPV6 | RTE_PTYPE_INNER_L4_TCP,
174 : : [IGC_PACKET_TYPE_IPV6_EXT_TCP] = RTE_PTYPE_L2_ETHER |
175 : : RTE_PTYPE_L3_IPV6_EXT | RTE_PTYPE_L4_TCP,
176 : : [IGC_PACKET_TYPE_IPV4_IPV6_EXT_TCP] = RTE_PTYPE_L2_ETHER |
177 : : RTE_PTYPE_L3_IPV4 | RTE_PTYPE_TUNNEL_IP |
178 : : RTE_PTYPE_INNER_L3_IPV6_EXT | RTE_PTYPE_INNER_L4_TCP,
179 : : [IGC_PACKET_TYPE_IPV4_UDP] = RTE_PTYPE_L2_ETHER |
180 : : RTE_PTYPE_L3_IPV4 | RTE_PTYPE_L4_UDP,
181 : : [IGC_PACKET_TYPE_IPV6_UDP] = RTE_PTYPE_L2_ETHER |
182 : : RTE_PTYPE_L3_IPV6 | RTE_PTYPE_L4_UDP,
183 : : [IGC_PACKET_TYPE_IPV4_IPV6_UDP] = RTE_PTYPE_L2_ETHER |
184 : : RTE_PTYPE_L3_IPV4 | RTE_PTYPE_TUNNEL_IP |
185 : : RTE_PTYPE_INNER_L3_IPV6 | RTE_PTYPE_INNER_L4_UDP,
186 : : [IGC_PACKET_TYPE_IPV6_EXT_UDP] = RTE_PTYPE_L2_ETHER |
187 : : RTE_PTYPE_L3_IPV6_EXT | RTE_PTYPE_L4_UDP,
188 : : [IGC_PACKET_TYPE_IPV4_IPV6_EXT_UDP] = RTE_PTYPE_L2_ETHER |
189 : : RTE_PTYPE_L3_IPV4 | RTE_PTYPE_TUNNEL_IP |
190 : : RTE_PTYPE_INNER_L3_IPV6_EXT | RTE_PTYPE_INNER_L4_UDP,
191 : : [IGC_PACKET_TYPE_IPV4_SCTP] = RTE_PTYPE_L2_ETHER |
192 : : RTE_PTYPE_L3_IPV4 | RTE_PTYPE_L4_SCTP,
193 : : [IGC_PACKET_TYPE_IPV4_EXT_SCTP] = RTE_PTYPE_L2_ETHER |
194 : : RTE_PTYPE_L3_IPV4_EXT | RTE_PTYPE_L4_SCTP,
195 : : };
196 : 0 : if (unlikely(pkt_info & E1000_RXDADV_PKTTYPE_ETQF))
197 : : return RTE_PTYPE_UNKNOWN;
198 : :
199 : 0 : pkt_info = (pkt_info >> IGC_PACKET_TYPE_SHIFT) & IGC_PACKET_TYPE_MASK;
200 : :
201 : 0 : return ptype_table[pkt_info];
202 : : }
203 : :
204 : : static inline void
205 : 0 : rx_desc_get_pkt_info(struct igc_rx_queue *rxq, struct rte_mbuf *rxm,
206 : : union e1000_adv_rx_desc *rxd, uint32_t staterr)
207 : : {
208 : : uint64_t pkt_flags;
209 : : uint32_t hlen_type_rss;
210 : : uint16_t pkt_info;
211 : :
212 : : /* Prefetch data of first segment, if configured to do so. */
213 : 0 : rte_packet_prefetch((char *)rxm->buf_addr + rxm->data_off);
214 : :
215 : 0 : rxm->port = rxq->port_id;
216 : 0 : hlen_type_rss = rte_le_to_cpu_32(rxd->wb.lower.lo_dword.data);
217 : 0 : rxm->hash.rss = rte_le_to_cpu_32(rxd->wb.lower.hi_dword.rss);
218 : 0 : rxm->vlan_tci = rte_le_to_cpu_16(rxd->wb.upper.vlan);
219 : :
220 : 0 : pkt_flags = (hlen_type_rss & IGC_RXD_RSS_TYPE_MASK) ?
221 [ # # ]: 0 : RTE_MBUF_F_RX_RSS_HASH : 0;
222 : :
223 [ # # ]: 0 : if (hlen_type_rss & IGC_RXD_VPKT)
224 : 0 : pkt_flags |= RTE_MBUF_F_RX_VLAN;
225 : :
226 : 0 : pkt_flags |= rx_desc_statuserr_to_pkt_flags(staterr);
227 : :
228 [ # # ]: 0 : if (rxq->offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP)
229 : 0 : pkt_flags |= RTE_MBUF_F_RX_IEEE1588_PTP;
230 : :
231 : 0 : rxm->ol_flags = pkt_flags;
232 : 0 : pkt_info = rte_le_to_cpu_16(rxd->wb.lower.lo_dword.hs_rss.pkt_info);
233 [ # # ]: 0 : rxm->packet_type = rx_desc_pkt_info_to_pkt_type(pkt_info);
234 : 0 : }
235 : :
236 : : uint16_t
237 : 0 : igc_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
238 : : {
239 : : struct igc_rx_queue * const rxq = rx_queue;
240 : 0 : volatile union e1000_adv_rx_desc * const rx_ring = rxq->rx_ring;
241 : 0 : struct igc_rx_entry * const sw_ring = rxq->sw_ring;
242 : 0 : uint16_t rx_id = rxq->rx_tail;
243 : : uint16_t nb_rx = 0;
244 : : uint16_t nb_hold = 0;
245 : :
246 [ # # ]: 0 : while (nb_rx < nb_pkts) {
247 : : volatile union e1000_adv_rx_desc *rxdp;
248 : : struct igc_rx_entry *rxe;
249 : : struct rte_mbuf *rxm;
250 : : struct rte_mbuf *nmb;
251 : : union e1000_adv_rx_desc rxd;
252 : : uint32_t staterr;
253 : : uint16_t data_len;
254 : :
255 : : /*
256 : : * The order of operations here is important as the DD status
257 : : * bit must not be read after any other descriptor fields.
258 : : * rx_ring and rxdp are pointing to volatile data so the order
259 : : * of accesses cannot be reordered by the compiler. If they were
260 : : * not volatile, they could be reordered which could lead to
261 : : * using invalid descriptor fields when read from rxd.
262 : : */
263 : 0 : rxdp = &rx_ring[rx_id];
264 : 0 : staterr = rte_cpu_to_le_32(rxdp->wb.upper.status_error);
265 [ # # ]: 0 : if (!(staterr & E1000_RXD_STAT_DD))
266 : : break;
267 : 0 : rxd = *rxdp;
268 : :
269 : : /*
270 : : * End of packet.
271 : : *
272 : : * If the E1000_RXD_STAT_EOP flag is not set, the RX packet is
273 : : * likely to be invalid and to be dropped by the various
274 : : * validation checks performed by the network stack.
275 : : *
276 : : * Allocate a new mbuf to replenish the RX ring descriptor.
277 : : * If the allocation fails:
278 : : * - arrange for that RX descriptor to be the first one
279 : : * being parsed the next time the receive function is
280 : : * invoked [on the same queue].
281 : : *
282 : : * - Stop parsing the RX ring and return immediately.
283 : : *
284 : : * This policy does not drop the packet received in the RX
285 : : * descriptor for which the allocation of a new mbuf failed.
286 : : * Thus, it allows that packet to be later retrieved if
287 : : * mbuf have been freed in the mean time.
288 : : * As a side effect, holding RX descriptors instead of
289 : : * systematically giving them back to the NIC may lead to
290 : : * RX ring exhaustion situations.
291 : : * However, the NIC can gracefully prevent such situations
292 : : * to happen by sending specific "back-pressure" flow control
293 : : * frames to its peer(s).
294 : : */
295 : : PMD_RX_LOG(DEBUG,
296 : : "port_id=%u queue_id=%u rx_id=%u staterr=0x%x data_len=%u",
297 : : rxq->port_id, rxq->queue_id, rx_id, staterr,
298 : : rte_le_to_cpu_16(rxd.wb.upper.length));
299 : :
300 : 0 : nmb = rte_mbuf_raw_alloc(rxq->mb_pool);
301 [ # # ]: 0 : if (nmb == NULL) {
302 : : unsigned int id;
303 : : PMD_RX_LOG(DEBUG,
304 : : "RX mbuf alloc failed, port_id=%u queue_id=%u",
305 : : rxq->port_id, rxq->queue_id);
306 : 0 : id = rxq->port_id;
307 : 0 : rte_eth_devices[id].data->rx_mbuf_alloc_failed++;
308 : 0 : break;
309 : : }
310 : :
311 : 0 : nb_hold++;
312 : 0 : rxe = &sw_ring[rx_id];
313 : 0 : rx_id++;
314 [ # # ]: 0 : if (rx_id >= rxq->nb_rx_desc)
315 : : rx_id = 0;
316 : :
317 : : /* Prefetch next mbuf while processing current one. */
318 : : rte_igc_prefetch(sw_ring[rx_id].mbuf);
319 : :
320 : : /*
321 : : * When next RX descriptor is on a cache-line boundary,
322 : : * prefetch the next 4 RX descriptors and the next 8 pointers
323 : : * to mbufs.
324 : : */
325 : : if ((rx_id & 0x3) == 0) {
326 : : rte_igc_prefetch(&rx_ring[rx_id]);
327 : : rte_igc_prefetch(&sw_ring[rx_id]);
328 : : }
329 : :
330 : : /*
331 : : * Update RX descriptor with the physical address of the new
332 : : * data buffer of the new allocated mbuf.
333 : : */
334 : 0 : rxm = rxe->mbuf;
335 : 0 : rxe->mbuf = nmb;
336 : 0 : rxdp->read.hdr_addr = 0;
337 : :
338 [ # # ]: 0 : if (rxq->offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP)
339 : 0 : rxdp->read.pkt_addr =
340 : 0 : rte_cpu_to_le_64(rte_mbuf_data_iova_default(nmb)) -
341 : : IGC_TS_HDR_LEN;
342 : : else
343 : 0 : rxdp->read.pkt_addr =
344 : : rte_cpu_to_le_64(rte_mbuf_data_iova_default(nmb));
345 : :
346 : 0 : rxm->next = NULL;
347 : :
348 : 0 : rxm->data_off = RTE_PKTMBUF_HEADROOM;
349 : 0 : data_len = rte_le_to_cpu_16(rxd.wb.upper.length) - rxq->crc_len;
350 : : /*
351 : : * When the RTE_ETH_RX_OFFLOAD_TIMESTAMP offload is enabled the
352 : : * length in the descriptor still accounts for the timestamp so
353 : : * it must be subtracted.
354 : : */
355 [ # # ]: 0 : if (rxq->offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP)
356 : 0 : data_len -= IGC_TS_HDR_LEN;
357 : 0 : rxm->data_len = data_len;
358 : 0 : rxm->pkt_len = data_len;
359 : 0 : rxm->nb_segs = 1;
360 : :
361 : 0 : rx_desc_get_pkt_info(rxq, rxm, &rxd, staterr);
362 : :
363 [ # # ]: 0 : if (rxq->offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP) {
364 : 0 : uint32_t *ts = rte_pktmbuf_mtod_offset(rxm,
365 : : uint32_t *, -IGC_TS_HDR_LEN);
366 : 0 : rxq->rx_timestamp = (uint64_t)ts[3] * NSEC_PER_SEC +
367 : 0 : ts[2];
368 : 0 : rxm->timesync = rxq->queue_id;
369 : : }
370 : :
371 : : /*
372 : : * Store the mbuf address into the next entry of the array
373 : : * of returned packets.
374 : : */
375 : 0 : rx_pkts[nb_rx++] = rxm;
376 : : }
377 : 0 : rxq->rx_tail = rx_id;
378 : :
379 : : /*
380 : : * If the number of free RX descriptors is greater than the RX free
381 : : * threshold of the queue, advance the Receive Descriptor Tail (RDT)
382 : : * register.
383 : : * Update the RDT with the value of the last processed RX descriptor
384 : : * minus 1, to guarantee that the RDT register is never equal to the
385 : : * RDH register, which creates a "full" ring situation from the
386 : : * hardware point of view...
387 : : */
388 : 0 : nb_hold = nb_hold + rxq->nb_rx_hold;
389 [ # # ]: 0 : if (nb_hold > rxq->rx_free_thresh) {
390 : : PMD_RX_LOG(DEBUG,
391 : : "port_id=%u queue_id=%u rx_tail=%u nb_hold=%u nb_rx=%u",
392 : : rxq->port_id, rxq->queue_id, rx_id, nb_hold, nb_rx);
393 [ # # ]: 0 : rx_id = (rx_id == 0) ? (rxq->nb_rx_desc - 1) : (rx_id - 1);
394 : 0 : E1000_PCI_REG_WRITE(rxq->rdt_reg_addr, rx_id);
395 : : nb_hold = 0;
396 : : }
397 : 0 : rxq->nb_rx_hold = nb_hold;
398 : 0 : return nb_rx;
399 : : }
400 : :
401 : : uint16_t
402 : 0 : igc_recv_scattered_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
403 : : uint16_t nb_pkts)
404 : : {
405 : : struct igc_rx_queue * const rxq = rx_queue;
406 : 0 : volatile union e1000_adv_rx_desc * const rx_ring = rxq->rx_ring;
407 : 0 : struct igc_rx_entry * const sw_ring = rxq->sw_ring;
408 : 0 : struct rte_mbuf *first_seg = rxq->pkt_first_seg;
409 : 0 : struct rte_mbuf *last_seg = rxq->pkt_last_seg;
410 : :
411 : 0 : uint16_t rx_id = rxq->rx_tail;
412 : : uint16_t nb_rx = 0;
413 : : uint16_t nb_hold = 0;
414 : :
415 [ # # ]: 0 : while (nb_rx < nb_pkts) {
416 : : volatile union e1000_adv_rx_desc *rxdp;
417 : : struct igc_rx_entry *rxe;
418 : : struct rte_mbuf *rxm;
419 : : struct rte_mbuf *nmb;
420 : : union e1000_adv_rx_desc rxd;
421 : : uint32_t staterr;
422 : : uint16_t data_len;
423 : :
424 : 0 : next_desc:
425 : : /*
426 : : * The order of operations here is important as the DD status
427 : : * bit must not be read after any other descriptor fields.
428 : : * rx_ring and rxdp are pointing to volatile data so the order
429 : : * of accesses cannot be reordered by the compiler. If they were
430 : : * not volatile, they could be reordered which could lead to
431 : : * using invalid descriptor fields when read from rxd.
432 : : */
433 : 0 : rxdp = &rx_ring[rx_id];
434 : 0 : staterr = rte_cpu_to_le_32(rxdp->wb.upper.status_error);
435 [ # # ]: 0 : if (!(staterr & E1000_RXD_STAT_DD))
436 : : break;
437 : 0 : rxd = *rxdp;
438 : :
439 : : /*
440 : : * Descriptor done.
441 : : *
442 : : * Allocate a new mbuf to replenish the RX ring descriptor.
443 : : * If the allocation fails:
444 : : * - arrange for that RX descriptor to be the first one
445 : : * being parsed the next time the receive function is
446 : : * invoked [on the same queue].
447 : : *
448 : : * - Stop parsing the RX ring and return immediately.
449 : : *
450 : : * This policy does not drop the packet received in the RX
451 : : * descriptor for which the allocation of a new mbuf failed.
452 : : * Thus, it allows that packet to be later retrieved if
453 : : * mbuf have been freed in the mean time.
454 : : * As a side effect, holding RX descriptors instead of
455 : : * systematically giving them back to the NIC may lead to
456 : : * RX ring exhaustion situations.
457 : : * However, the NIC can gracefully prevent such situations
458 : : * to happen by sending specific "back-pressure" flow control
459 : : * frames to its peer(s).
460 : : */
461 : : PMD_RX_LOG(DEBUG,
462 : : "port_id=%u queue_id=%u rx_id=%u staterr=0x%x data_len=%u",
463 : : rxq->port_id, rxq->queue_id, rx_id, staterr,
464 : : rte_le_to_cpu_16(rxd.wb.upper.length));
465 : :
466 : 0 : nmb = rte_mbuf_raw_alloc(rxq->mb_pool);
467 [ # # ]: 0 : if (nmb == NULL) {
468 : : unsigned int id;
469 : : PMD_RX_LOG(DEBUG,
470 : : "RX mbuf alloc failed, port_id=%u queue_id=%u",
471 : : rxq->port_id, rxq->queue_id);
472 : 0 : id = rxq->port_id;
473 : 0 : rte_eth_devices[id].data->rx_mbuf_alloc_failed++;
474 : 0 : break;
475 : : }
476 : :
477 : 0 : nb_hold++;
478 : 0 : rxe = &sw_ring[rx_id];
479 : 0 : rx_id++;
480 [ # # ]: 0 : if (rx_id >= rxq->nb_rx_desc)
481 : : rx_id = 0;
482 : :
483 : : /* Prefetch next mbuf while processing current one. */
484 : : rte_igc_prefetch(sw_ring[rx_id].mbuf);
485 : :
486 : : /*
487 : : * When next RX descriptor is on a cache-line boundary,
488 : : * prefetch the next 4 RX descriptors and the next 8 pointers
489 : : * to mbufs.
490 : : */
491 : : if ((rx_id & 0x3) == 0) {
492 : : rte_igc_prefetch(&rx_ring[rx_id]);
493 : : rte_igc_prefetch(&sw_ring[rx_id]);
494 : : }
495 : :
496 : : /*
497 : : * Update RX descriptor with the physical address of the new
498 : : * data buffer of the new allocated mbuf.
499 : : */
500 : 0 : rxm = rxe->mbuf;
501 : 0 : rxe->mbuf = nmb;
502 : 0 : rxdp->read.hdr_addr = 0;
503 : :
504 [ # # ]: 0 : if (rxq->offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP)
505 : 0 : rxdp->read.pkt_addr =
506 : 0 : rte_cpu_to_le_64(rte_mbuf_data_iova_default(nmb)) -
507 : : IGC_TS_HDR_LEN;
508 : : else
509 : 0 : rxdp->read.pkt_addr =
510 : : rte_cpu_to_le_64(rte_mbuf_data_iova_default(nmb));
511 : :
512 : 0 : rxm->next = NULL;
513 : :
514 : : /*
515 : : * Set data length & data buffer address of mbuf.
516 : : */
517 : 0 : rxm->data_off = RTE_PKTMBUF_HEADROOM;
518 : 0 : data_len = rte_le_to_cpu_16(rxd.wb.upper.length);
519 [ # # ]: 0 : if (rxq->offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP) {
520 : : /*
521 : : * When the RTE_ETH_RX_OFFLOAD_TIMESTAMP offload is enabled
522 : : * the pkt_addr of all software ring entries is moved forward
523 : : * by IGC_TS_HDR_LEN (see igc_alloc_rx_queue_mbufs()) so that
524 : : * when the hardware writes the packet with a prepended
525 : : * timestamp the actual packet data still starts at the
526 : : * normal data offset. The length in the descriptor still
527 : : * accounts for the timestamp so it needs to be subtracted.
528 : : * Follow-up mbufs do not have the timestamp so the data
529 : : * offset must be adjusted to point to the start of the packet
530 : : * data.
531 : : */
532 [ # # ]: 0 : if (first_seg == NULL)
533 : 0 : data_len -= IGC_TS_HDR_LEN;
534 : : else
535 : 0 : rxm->data_off -= IGC_TS_HDR_LEN;
536 : : }
537 : 0 : rxm->data_len = data_len;
538 : :
539 : : /*
540 : : * If this is the first buffer of the received packet,
541 : : * set the pointer to the first mbuf of the packet and
542 : : * initialize its context.
543 : : * Otherwise, update the total length and the number of segments
544 : : * of the current scattered packet, and update the pointer to
545 : : * the last mbuf of the current packet.
546 : : */
547 [ # # ]: 0 : if (first_seg == NULL) {
548 : : first_seg = rxm;
549 : 0 : first_seg->pkt_len = data_len;
550 : 0 : first_seg->nb_segs = 1;
551 : : } else {
552 : 0 : first_seg->pkt_len += data_len;
553 : 0 : first_seg->nb_segs++;
554 : 0 : last_seg->next = rxm;
555 : : }
556 : :
557 : : /*
558 : : * If this is not the last buffer of the received packet,
559 : : * update the pointer to the last mbuf of the current scattered
560 : : * packet and continue to parse the RX ring.
561 : : */
562 [ # # ]: 0 : if (!(staterr & E1000_RXD_STAT_EOP)) {
563 : : last_seg = rxm;
564 : 0 : goto next_desc;
565 : : }
566 : :
567 : : /*
568 : : * This is the last buffer of the received packet.
569 : : * If the CRC is not stripped by the hardware:
570 : : * - Subtract the CRC length from the total packet length.
571 : : * - If the last buffer only contains the whole CRC or a part
572 : : * of it, free the mbuf associated to the last buffer.
573 : : * If part of the CRC is also contained in the previous
574 : : * mbuf, subtract the length of that CRC part from the
575 : : * data length of the previous mbuf.
576 : : */
577 [ # # ]: 0 : if (unlikely(rxq->crc_len > 0)) {
578 : 0 : first_seg->pkt_len -= RTE_ETHER_CRC_LEN;
579 [ # # ]: 0 : if (data_len <= RTE_ETHER_CRC_LEN) {
580 : : rte_pktmbuf_free_seg(rxm);
581 : 0 : first_seg->nb_segs--;
582 : 0 : last_seg->data_len = last_seg->data_len -
583 : : (RTE_ETHER_CRC_LEN - data_len);
584 : 0 : last_seg->next = NULL;
585 : : rxm = last_seg;
586 : : } else {
587 : 0 : rxm->data_len = (uint16_t)
588 : : (data_len - RTE_ETHER_CRC_LEN);
589 : : }
590 : : }
591 : :
592 : 0 : rx_desc_get_pkt_info(rxq, first_seg, &rxd, staterr);
593 : :
594 [ # # ]: 0 : if (rxq->offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP) {
595 : 0 : uint32_t *ts = rte_pktmbuf_mtod_offset(first_seg,
596 : : uint32_t *, -IGC_TS_HDR_LEN);
597 : 0 : rxq->rx_timestamp = (uint64_t)ts[3] * NSEC_PER_SEC +
598 : 0 : ts[2];
599 : 0 : rxm->timesync = rxq->queue_id;
600 : : }
601 : :
602 : : /*
603 : : * Store the mbuf address into the next entry of the array
604 : : * of returned packets.
605 : : */
606 : 0 : rx_pkts[nb_rx++] = first_seg;
607 : :
608 : : /* Setup receipt context for a new packet. */
609 : : first_seg = NULL;
610 : : }
611 : 0 : rxq->rx_tail = rx_id;
612 : :
613 : : /*
614 : : * Save receive context.
615 : : */
616 : 0 : rxq->pkt_first_seg = first_seg;
617 : 0 : rxq->pkt_last_seg = last_seg;
618 : :
619 : : /*
620 : : * If the number of free RX descriptors is greater than the RX free
621 : : * threshold of the queue, advance the Receive Descriptor Tail (RDT)
622 : : * register.
623 : : * Update the RDT with the value of the last processed RX descriptor
624 : : * minus 1, to guarantee that the RDT register is never equal to the
625 : : * RDH register, which creates a "full" ring situation from the
626 : : * hardware point of view...
627 : : */
628 : 0 : nb_hold = nb_hold + rxq->nb_rx_hold;
629 [ # # ]: 0 : if (nb_hold > rxq->rx_free_thresh) {
630 : : PMD_RX_LOG(DEBUG,
631 : : "port_id=%u queue_id=%u rx_tail=%u nb_hold=%u nb_rx=%u",
632 : : rxq->port_id, rxq->queue_id, rx_id, nb_hold, nb_rx);
633 [ # # ]: 0 : rx_id = (rx_id == 0) ? (rxq->nb_rx_desc - 1) : (rx_id - 1);
634 : 0 : E1000_PCI_REG_WRITE(rxq->rdt_reg_addr, rx_id);
635 : : nb_hold = 0;
636 : : }
637 : 0 : rxq->nb_rx_hold = nb_hold;
638 : 0 : return nb_rx;
639 : : }
640 : :
641 : : static void
642 : 0 : igc_rx_queue_release_mbufs(struct igc_rx_queue *rxq)
643 : : {
644 : : unsigned int i;
645 : :
646 [ # # ]: 0 : if (rxq->sw_ring != NULL) {
647 [ # # ]: 0 : for (i = 0; i < rxq->nb_rx_desc; i++) {
648 [ # # ]: 0 : if (rxq->sw_ring[i].mbuf != NULL) {
649 : : rte_pktmbuf_free_seg(rxq->sw_ring[i].mbuf);
650 : 0 : rxq->sw_ring[i].mbuf = NULL;
651 : : }
652 : : }
653 : : }
654 : 0 : }
655 : :
656 : : static void
657 : 0 : igc_rx_queue_release(struct igc_rx_queue *rxq)
658 : : {
659 : 0 : igc_rx_queue_release_mbufs(rxq);
660 : 0 : rte_free(rxq->sw_ring);
661 : 0 : rte_free(rxq);
662 : 0 : }
663 : :
664 : 0 : void eth_igc_rx_queue_release(struct rte_eth_dev *dev, uint16_t qid)
665 : : {
666 [ # # ]: 0 : if (dev->data->rx_queues[qid])
667 : 0 : igc_rx_queue_release(dev->data->rx_queues[qid]);
668 : 0 : }
669 : :
670 : 0 : uint32_t eth_igc_rx_queue_count(void *rx_queue)
671 : : {
672 : : /**
673 : : * Check the DD bit of a rx descriptor of each 4 in a group,
674 : : * to avoid checking too frequently and downgrading performance
675 : : * too much.
676 : : */
677 : : #define IGC_RXQ_SCAN_INTERVAL 4
678 : :
679 : : volatile union e1000_adv_rx_desc *rxdp;
680 : : struct igc_rx_queue *rxq;
681 : : uint16_t desc = 0;
682 : :
683 : : rxq = rx_queue;
684 : 0 : rxdp = &rxq->rx_ring[rxq->rx_tail];
685 : :
686 [ # # ]: 0 : while (desc < rxq->nb_rx_desc - rxq->rx_tail) {
687 [ # # ]: 0 : if (unlikely(!(rxdp->wb.upper.status_error &
688 : : E1000_RXD_STAT_DD)))
689 : 0 : return desc;
690 : 0 : desc += IGC_RXQ_SCAN_INTERVAL;
691 : 0 : rxdp += IGC_RXQ_SCAN_INTERVAL;
692 : : }
693 : 0 : rxdp = &rxq->rx_ring[rxq->rx_tail + desc - rxq->nb_rx_desc];
694 : :
695 [ # # ]: 0 : while (desc < rxq->nb_rx_desc &&
696 [ # # ]: 0 : (rxdp->wb.upper.status_error & E1000_RXD_STAT_DD)) {
697 : 0 : desc += IGC_RXQ_SCAN_INTERVAL;
698 : 0 : rxdp += IGC_RXQ_SCAN_INTERVAL;
699 : : }
700 : :
701 : 0 : return desc;
702 : : }
703 : :
704 : 0 : int eth_igc_rx_descriptor_status(void *rx_queue, uint16_t offset)
705 : : {
706 : : struct igc_rx_queue *rxq = rx_queue;
707 : : volatile uint32_t *status;
708 : : uint32_t desc;
709 : :
710 [ # # # # ]: 0 : if (unlikely(!rxq || offset >= rxq->nb_rx_desc))
711 : : return -EINVAL;
712 : :
713 [ # # ]: 0 : if (offset >= rxq->nb_rx_desc - rxq->nb_rx_hold)
714 : : return RTE_ETH_RX_DESC_UNAVAIL;
715 : :
716 : 0 : desc = rxq->rx_tail + offset;
717 [ # # ]: 0 : if (desc >= rxq->nb_rx_desc)
718 : 0 : desc -= rxq->nb_rx_desc;
719 : :
720 : 0 : status = &rxq->rx_ring[desc].wb.upper.status_error;
721 [ # # ]: 0 : if (*status & rte_cpu_to_le_32(E1000_RXD_STAT_DD))
722 : 0 : return RTE_ETH_RX_DESC_DONE;
723 : :
724 : : return RTE_ETH_RX_DESC_AVAIL;
725 : : }
726 : :
727 : : static int
728 : 0 : igc_alloc_rx_queue_mbufs(struct igc_rx_queue *rxq)
729 : : {
730 : 0 : struct igc_rx_entry *rxe = rxq->sw_ring;
731 : : uint64_t dma_addr;
732 : : unsigned int i;
733 : :
734 : : /* Initialize software ring entries. */
735 [ # # ]: 0 : for (i = 0; i < rxq->nb_rx_desc; i++) {
736 : : volatile union e1000_adv_rx_desc *rxd;
737 : 0 : struct rte_mbuf *mbuf = rte_mbuf_raw_alloc(rxq->mb_pool);
738 : :
739 [ # # ]: 0 : if (mbuf == NULL) {
740 : 0 : PMD_DRV_LOG(ERR, "RX mbuf alloc failed, queue_id=%hu",
741 : : rxq->queue_id);
742 : 0 : return -ENOMEM;
743 : : }
744 : : dma_addr = rte_cpu_to_le_64(rte_mbuf_data_iova_default(mbuf));
745 : 0 : rxd = &rxq->rx_ring[i];
746 : 0 : rxd->read.hdr_addr = 0;
747 [ # # ]: 0 : if (rxq->offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP)
748 : 0 : rxd->read.pkt_addr = dma_addr - IGC_TS_HDR_LEN;
749 : : else
750 : 0 : rxd->read.pkt_addr = dma_addr;
751 : 0 : rxe[i].mbuf = mbuf;
752 : : }
753 : :
754 : : return 0;
755 : : }
756 : :
757 : : /*
758 : : * RSS random key supplied in section 7.1.2.9.3 of the Intel I225 datasheet.
759 : : * Used as the default key.
760 : : */
761 : : static uint8_t default_rss_key[40] = {
762 : : 0x6D, 0x5A, 0x56, 0xDA, 0x25, 0x5B, 0x0E, 0xC2,
763 : : 0x41, 0x67, 0x25, 0x3D, 0x43, 0xA3, 0x8F, 0xB0,
764 : : 0xD0, 0xCA, 0x2B, 0xCB, 0xAE, 0x7B, 0x30, 0xB4,
765 : : 0x77, 0xCB, 0x2D, 0xA3, 0x80, 0x30, 0xF2, 0x0C,
766 : : 0x6A, 0x42, 0xB7, 0x3B, 0xBE, 0xAC, 0x01, 0xFA,
767 : : };
768 : :
769 : : void
770 : 0 : igc_rss_disable(struct rte_eth_dev *dev)
771 : : {
772 : 0 : struct e1000_hw *hw = IGC_DEV_PRIVATE_HW(dev);
773 : : uint32_t mrqc;
774 : :
775 : 0 : mrqc = E1000_READ_REG(hw, E1000_MRQC);
776 : 0 : mrqc &= ~E1000_MRQC_ENABLE_MASK;
777 : 0 : E1000_WRITE_REG(hw, E1000_MRQC, mrqc);
778 : 0 : }
779 : :
780 : : void
781 : 0 : igc_hw_rss_hash_set(struct e1000_hw *hw, struct rte_eth_rss_conf *rss_conf)
782 : : {
783 : 0 : uint32_t *hash_key = (uint32_t *)rss_conf->rss_key;
784 : : uint32_t mrqc;
785 : : uint64_t rss_hf;
786 : :
787 [ # # ]: 0 : if (hash_key != NULL) {
788 : : uint8_t i;
789 : :
790 : : /* Fill in RSS hash key */
791 [ # # ]: 0 : for (i = 0; i < IGC_HKEY_MAX_INDEX; i++)
792 : 0 : E1000_WRITE_REG_LE_VALUE(hw, E1000_RSSRK(i), hash_key[i]);
793 : : }
794 : :
795 : : /* Set configured hashing protocols in MRQC register */
796 : 0 : rss_hf = rss_conf->rss_hf;
797 : : mrqc = E1000_MRQC_ENABLE_RSS_4Q; /* RSS enabled. */
798 [ # # ]: 0 : if (rss_hf & RTE_ETH_RSS_IPV4)
799 : : mrqc |= E1000_MRQC_RSS_FIELD_IPV4;
800 [ # # ]: 0 : if (rss_hf & RTE_ETH_RSS_NONFRAG_IPV4_TCP)
801 : 0 : mrqc |= E1000_MRQC_RSS_FIELD_IPV4_TCP;
802 [ # # ]: 0 : if (rss_hf & RTE_ETH_RSS_IPV6)
803 : 0 : mrqc |= E1000_MRQC_RSS_FIELD_IPV6;
804 [ # # ]: 0 : if (rss_hf & RTE_ETH_RSS_IPV6_EX)
805 : 0 : mrqc |= E1000_MRQC_RSS_FIELD_IPV6_EX;
806 [ # # ]: 0 : if (rss_hf & RTE_ETH_RSS_NONFRAG_IPV6_TCP)
807 : 0 : mrqc |= E1000_MRQC_RSS_FIELD_IPV6_TCP;
808 [ # # ]: 0 : if (rss_hf & RTE_ETH_RSS_IPV6_TCP_EX)
809 : 0 : mrqc |= E1000_MRQC_RSS_FIELD_IPV6_TCP_EX;
810 [ # # ]: 0 : if (rss_hf & RTE_ETH_RSS_NONFRAG_IPV4_UDP)
811 : 0 : mrqc |= E1000_MRQC_RSS_FIELD_IPV4_UDP;
812 [ # # ]: 0 : if (rss_hf & RTE_ETH_RSS_NONFRAG_IPV6_UDP)
813 : 0 : mrqc |= E1000_MRQC_RSS_FIELD_IPV6_UDP;
814 [ # # ]: 0 : if (rss_hf & RTE_ETH_RSS_IPV6_UDP_EX)
815 : 0 : mrqc |= E1000_MRQC_RSS_FIELD_IPV6_UDP_EX;
816 : 0 : E1000_WRITE_REG(hw, E1000_MRQC, mrqc);
817 : 0 : }
818 : :
819 : : static void
820 : 0 : igc_rss_configure(struct rte_eth_dev *dev)
821 : : {
822 : : struct rte_eth_rss_conf rss_conf;
823 : 0 : struct e1000_hw *hw = IGC_DEV_PRIVATE_HW(dev);
824 : : uint16_t i;
825 : :
826 : : /* Fill in redirection table. */
827 [ # # ]: 0 : for (i = 0; i < IGC_RSS_RDT_SIZD; i++) {
828 : : union igc_rss_reta_reg reta;
829 : : uint16_t q_idx, reta_idx;
830 : :
831 [ # # ]: 0 : q_idx = (uint8_t)((dev->data->nb_rx_queues > 1) ?
832 : : i % dev->data->nb_rx_queues : 0);
833 : 0 : reta_idx = i % sizeof(reta);
834 : 0 : reta.bytes[reta_idx] = q_idx;
835 [ # # ]: 0 : if (reta_idx == sizeof(reta) - 1)
836 : 0 : E1000_WRITE_REG_LE_VALUE(hw,
837 : : E1000_RETA(i / sizeof(reta)), reta.dword);
838 : : }
839 : :
840 : : /*
841 : : * Configure the RSS key and the RSS protocols used to compute
842 : : * the RSS hash of input packets.
843 : : */
844 : 0 : rss_conf = dev->data->dev_conf.rx_adv_conf.rss_conf;
845 [ # # ]: 0 : if (rss_conf.rss_key == NULL)
846 : 0 : rss_conf.rss_key = default_rss_key;
847 : 0 : igc_hw_rss_hash_set(hw, &rss_conf);
848 : 0 : }
849 : :
850 : : int
851 : 0 : igc_del_rss_filter(struct rte_eth_dev *dev)
852 : : {
853 : 0 : struct igc_rss_filter *rss_filter = IGC_DEV_PRIVATE_RSS_FILTER(dev);
854 : :
855 [ # # ]: 0 : if (rss_filter->enable) {
856 : : /* recover default RSS configuration */
857 : 0 : igc_rss_configure(dev);
858 : :
859 : : /* disable RSS logic and clear filter data */
860 : 0 : igc_rss_disable(dev);
861 : : memset(rss_filter, 0, sizeof(*rss_filter));
862 : 0 : return 0;
863 : : }
864 : 0 : PMD_DRV_LOG(ERR, "filter not exist!");
865 : 0 : return -ENOENT;
866 : : }
867 : :
868 : : /* Initiate the filter structure by the structure of rte_flow_action_rss */
869 : : void
870 : 0 : igc_rss_conf_set(struct igc_rss_filter *out,
871 : : const struct rte_flow_action_rss *rss)
872 : : {
873 : 0 : out->conf.func = rss->func;
874 : 0 : out->conf.level = rss->level;
875 : 0 : out->conf.types = rss->types;
876 : :
877 [ # # ]: 0 : if (rss->key_len == sizeof(out->key)) {
878 : 0 : memcpy(out->key, rss->key, rss->key_len);
879 : 0 : out->conf.key = out->key;
880 : 0 : out->conf.key_len = rss->key_len;
881 : : } else {
882 : 0 : out->conf.key = NULL;
883 : 0 : out->conf.key_len = 0;
884 : : }
885 : :
886 [ # # ]: 0 : if (rss->queue_num <= IGC_RSS_RDT_SIZD) {
887 : 0 : memcpy(out->queue, rss->queue,
888 : 0 : sizeof(*out->queue) * rss->queue_num);
889 : 0 : out->conf.queue = out->queue;
890 : 0 : out->conf.queue_num = rss->queue_num;
891 : : } else {
892 : 0 : out->conf.queue = NULL;
893 : 0 : out->conf.queue_num = 0;
894 : : }
895 : 0 : }
896 : :
897 : : int
898 : 0 : igc_add_rss_filter(struct rte_eth_dev *dev, struct igc_rss_filter *rss)
899 : : {
900 : 0 : struct rte_eth_rss_conf rss_conf = {
901 : 0 : .rss_key = rss->conf.key_len ?
902 [ # # ]: 0 : (void *)(uintptr_t)rss->conf.key : NULL,
903 : : .rss_key_len = rss->conf.key_len,
904 : 0 : .rss_hf = rss->conf.types,
905 : : };
906 : 0 : struct e1000_hw *hw = IGC_DEV_PRIVATE_HW(dev);
907 : 0 : struct igc_rss_filter *rss_filter = IGC_DEV_PRIVATE_RSS_FILTER(dev);
908 : : uint32_t i, j;
909 : :
910 : : /* check RSS type is valid */
911 [ # # ]: 0 : if ((rss_conf.rss_hf & IGC_RSS_OFFLOAD_ALL) == 0) {
912 : 0 : PMD_DRV_LOG(ERR,
913 : : "RSS type(0x%" PRIx64 ") error!, only 0x%" PRIx64
914 : : " been supported", rss_conf.rss_hf,
915 : : (uint64_t)IGC_RSS_OFFLOAD_ALL);
916 : 0 : return -EINVAL;
917 : : }
918 : :
919 : : /* check queue count is not zero */
920 [ # # ]: 0 : if (!rss->conf.queue_num) {
921 : 0 : PMD_DRV_LOG(ERR, "Queue number should not be 0!");
922 : 0 : return -EINVAL;
923 : : }
924 : :
925 : : /* check queue id is valid */
926 [ # # ]: 0 : for (i = 0; i < rss->conf.queue_num; i++)
927 [ # # ]: 0 : if (rss->conf.queue[i] >= dev->data->nb_rx_queues) {
928 : 0 : PMD_DRV_LOG(ERR, "Queue id %u is invalid!",
929 : : rss->conf.queue[i]);
930 : 0 : return -EINVAL;
931 : : }
932 : :
933 : : /* only support one filter */
934 [ # # ]: 0 : if (rss_filter->enable) {
935 : 0 : PMD_DRV_LOG(ERR, "Only support one RSS filter!");
936 : 0 : return -ENOTSUP;
937 : : }
938 : 0 : rss_filter->enable = 1;
939 : :
940 : 0 : igc_rss_conf_set(rss_filter, &rss->conf);
941 : :
942 : : /* Fill in redirection table. */
943 [ # # ]: 0 : for (i = 0, j = 0; i < IGC_RSS_RDT_SIZD; i++, j++) {
944 : : union igc_rss_reta_reg reta;
945 : : uint16_t q_idx, reta_idx;
946 : :
947 [ # # ]: 0 : if (j == rss->conf.queue_num)
948 : : j = 0;
949 : 0 : q_idx = rss->conf.queue[j];
950 : 0 : reta_idx = i % sizeof(reta);
951 : 0 : reta.bytes[reta_idx] = q_idx;
952 [ # # ]: 0 : if (reta_idx == sizeof(reta) - 1)
953 : 0 : E1000_WRITE_REG_LE_VALUE(hw,
954 : : E1000_RETA(i / sizeof(reta)), reta.dword);
955 : : }
956 : :
957 [ # # ]: 0 : if (rss_conf.rss_key == NULL)
958 : 0 : rss_conf.rss_key = default_rss_key;
959 : 0 : igc_hw_rss_hash_set(hw, &rss_conf);
960 : 0 : return 0;
961 : : }
962 : :
963 : : void
964 : 0 : igc_clear_rss_filter(struct rte_eth_dev *dev)
965 : : {
966 : 0 : struct igc_rss_filter *rss_filter = IGC_DEV_PRIVATE_RSS_FILTER(dev);
967 : :
968 [ # # ]: 0 : if (!rss_filter->enable)
969 : : return;
970 : :
971 : : /* recover default RSS configuration */
972 : 0 : igc_rss_configure(dev);
973 : :
974 : : /* disable RSS logic and clear filter data */
975 : 0 : igc_rss_disable(dev);
976 : : memset(rss_filter, 0, sizeof(*rss_filter));
977 : : }
978 : :
979 : : static int
980 : 0 : igc_dev_mq_rx_configure(struct rte_eth_dev *dev)
981 : : {
982 [ # # ]: 0 : if (RTE_ETH_DEV_SRIOV(dev).active) {
983 : 0 : PMD_DRV_LOG(ERR, "SRIOV unsupported!");
984 : 0 : return -EINVAL;
985 : : }
986 : :
987 [ # # # ]: 0 : switch (dev->data->dev_conf.rxmode.mq_mode) {
988 : 0 : case RTE_ETH_MQ_RX_RSS:
989 : 0 : igc_rss_configure(dev);
990 : 0 : break;
991 : 0 : case RTE_ETH_MQ_RX_NONE:
992 : : /*
993 : : * configure RSS register for following,
994 : : * then disable the RSS logic
995 : : */
996 : 0 : igc_rss_configure(dev);
997 : 0 : igc_rss_disable(dev);
998 : 0 : break;
999 : 0 : default:
1000 : 0 : PMD_DRV_LOG(ERR, "rx mode(%d) not supported!",
1001 : : dev->data->dev_conf.rxmode.mq_mode);
1002 : 0 : return -EINVAL;
1003 : : }
1004 : : return 0;
1005 : : }
1006 : :
1007 : : int
1008 : 0 : igc_rx_init(struct rte_eth_dev *dev)
1009 : : {
1010 : : struct igc_rx_queue *rxq;
1011 : 0 : struct e1000_hw *hw = IGC_DEV_PRIVATE_HW(dev);
1012 : 0 : uint64_t offloads = dev->data->dev_conf.rxmode.offloads;
1013 : : uint32_t max_rx_pktlen;
1014 : : uint32_t rctl;
1015 : : uint32_t rxcsum;
1016 : : uint16_t buf_size;
1017 : : uint16_t rctl_bsize;
1018 : : uint16_t i;
1019 : : int ret;
1020 : :
1021 : 0 : dev->rx_pkt_burst = igc_recv_pkts;
1022 : :
1023 : : /*
1024 : : * Make sure receives are disabled while setting
1025 : : * up the descriptor ring.
1026 : : */
1027 : 0 : rctl = E1000_READ_REG(hw, E1000_RCTL);
1028 : 0 : E1000_WRITE_REG(hw, E1000_RCTL, rctl & ~E1000_RCTL_EN);
1029 : :
1030 : : /* Configure support of jumbo frames, if any. */
1031 [ # # ]: 0 : if (dev->data->mtu > RTE_ETHER_MTU)
1032 : 0 : rctl |= E1000_RCTL_LPE;
1033 : : else
1034 : 0 : rctl &= ~E1000_RCTL_LPE;
1035 : :
1036 : 0 : max_rx_pktlen = dev->data->mtu + IGC_ETH_OVERHEAD;
1037 : : /*
1038 : : * Set maximum packet length by default, and might be updated
1039 : : * together with enabling/disabling dual VLAN.
1040 : : */
1041 : 0 : E1000_WRITE_REG(hw, E1000_RLPML, max_rx_pktlen);
1042 : :
1043 : : /* Configure and enable each RX queue. */
1044 : : rctl_bsize = 0;
1045 [ # # ]: 0 : for (i = 0; i < dev->data->nb_rx_queues; i++) {
1046 : : uint64_t bus_addr;
1047 : : uint32_t rxdctl;
1048 : : uint32_t srrctl;
1049 : :
1050 : 0 : rxq = dev->data->rx_queues[i];
1051 : 0 : rxq->flags = 0;
1052 : :
1053 [ # # ]: 0 : if (offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP)
1054 : 0 : rxq->offloads |= RTE_ETH_RX_OFFLOAD_TIMESTAMP;
1055 : :
1056 : : /* Allocate buffers for descriptor rings and set up queue */
1057 : 0 : ret = igc_alloc_rx_queue_mbufs(rxq);
1058 [ # # ]: 0 : if (ret)
1059 : 0 : return ret;
1060 : :
1061 : : /*
1062 : : * Reset crc_len in case it was changed after queue setup by a
1063 : : * call to configure
1064 : : */
1065 : 0 : rxq->crc_len = (offloads & RTE_ETH_RX_OFFLOAD_KEEP_CRC) ?
1066 : 0 : RTE_ETHER_CRC_LEN : 0;
1067 : :
1068 : 0 : bus_addr = rxq->rx_ring_phys_addr;
1069 [ # # ]: 0 : E1000_WRITE_REG(hw, E1000_RDLEN(rxq->reg_idx),
1070 : : rxq->nb_rx_desc *
1071 : : sizeof(union e1000_adv_rx_desc));
1072 [ # # ]: 0 : E1000_WRITE_REG(hw, E1000_RDBAH(rxq->reg_idx),
1073 : : (uint32_t)(bus_addr >> 32));
1074 [ # # ]: 0 : E1000_WRITE_REG(hw, E1000_RDBAL(rxq->reg_idx),
1075 : : (uint32_t)bus_addr);
1076 : :
1077 : : /* set descriptor configuration */
1078 : : srrctl = E1000_SRRCTL_DESCTYPE_ADV_ONEBUF;
1079 : :
1080 : : srrctl |= (uint32_t)(RTE_PKTMBUF_HEADROOM / 64) <<
1081 : : IGC_SRRCTL_BSIZEHEADER_SHIFT;
1082 : : /*
1083 : : * Configure RX buffer size.
1084 : : */
1085 [ # # ]: 0 : buf_size = (uint16_t)(rte_pktmbuf_data_room_size(rxq->mb_pool) -
1086 : : RTE_PKTMBUF_HEADROOM);
1087 [ # # ]: 0 : if (buf_size >= 1024) {
1088 : : /*
1089 : : * Configure the BSIZEPACKET field of the SRRCTL
1090 : : * register of the queue.
1091 : : * Value is in 1 KB resolution, from 1 KB to 16 KB.
1092 : : * If this field is equal to 0b, then RCTL.BSIZE
1093 : : * determines the RX packet buffer size.
1094 : : */
1095 : :
1096 : 0 : srrctl |= ((buf_size >> E1000_SRRCTL_BSIZEPKT_SHIFT) &
1097 : : E1000_SRRCTL_BSIZEPKT_MASK);
1098 : 0 : buf_size = (uint16_t)((srrctl &
1099 : : E1000_SRRCTL_BSIZEPKT_MASK) <<
1100 : : E1000_SRRCTL_BSIZEPKT_SHIFT);
1101 : :
1102 : : /* It adds dual VLAN length for supporting dual VLAN */
1103 [ # # ]: 0 : if (max_rx_pktlen > buf_size)
1104 : 0 : dev->data->scattered_rx = 1;
1105 : : } else {
1106 : : /*
1107 : : * Use BSIZE field of the device RCTL register.
1108 : : */
1109 [ # # ]: 0 : if (rctl_bsize == 0 || rctl_bsize > buf_size)
1110 : : rctl_bsize = buf_size;
1111 : 0 : dev->data->scattered_rx = 1;
1112 : : }
1113 : :
1114 : : /* Set if packets are dropped when no descriptors available */
1115 [ # # ]: 0 : if (rxq->drop_en)
1116 : 0 : srrctl |= E1000_SRRCTL_DROP_EN;
1117 : :
1118 [ # # ]: 0 : E1000_WRITE_REG(hw, E1000_SRRCTL(rxq->reg_idx), srrctl);
1119 : :
1120 : : /* Enable this RX queue. */
1121 : : rxdctl = E1000_RXDCTL_QUEUE_ENABLE;
1122 : 0 : rxdctl |= ((uint32_t)rxq->pthresh << IGC_RXDCTL_PTHRESH_SHIFT) &
1123 : : IGC_RXDCTL_PTHRESH_MSK;
1124 : 0 : rxdctl |= ((uint32_t)rxq->hthresh << IGC_RXDCTL_HTHRESH_SHIFT) &
1125 : : IGC_RXDCTL_HTHRESH_MSK;
1126 : 0 : rxdctl |= ((uint32_t)rxq->wthresh << IGC_RXDCTL_WTHRESH_SHIFT) &
1127 : : IGC_RXDCTL_WTHRESH_MSK;
1128 [ # # ]: 0 : E1000_WRITE_REG(hw, E1000_RXDCTL(rxq->reg_idx), rxdctl);
1129 : : }
1130 : :
1131 [ # # ]: 0 : if (offloads & RTE_ETH_RX_OFFLOAD_SCATTER)
1132 : 0 : dev->data->scattered_rx = 1;
1133 : :
1134 [ # # ]: 0 : if (dev->data->scattered_rx) {
1135 : 0 : PMD_DRV_LOG(DEBUG, "forcing scatter mode");
1136 : 0 : dev->rx_pkt_burst = igc_recv_scattered_pkts;
1137 : : }
1138 : : /*
1139 : : * Setup BSIZE field of RCTL register, if needed.
1140 : : * Buffer sizes >= 1024 are not [supposed to be] setup in the RCTL
1141 : : * register, since the code above configures the SRRCTL register of
1142 : : * the RX queue in such a case.
1143 : : * All configurable sizes are:
1144 : : * 16384: rctl |= (E1000_RCTL_SZ_16384 | E1000_RCTL_BSEX);
1145 : : * 8192: rctl |= (E1000_RCTL_SZ_8192 | E1000_RCTL_BSEX);
1146 : : * 4096: rctl |= (E1000_RCTL_SZ_4096 | E1000_RCTL_BSEX);
1147 : : * 2048: rctl |= E1000_RCTL_SZ_2048;
1148 : : * 1024: rctl |= E1000_RCTL_SZ_1024;
1149 : : * 512: rctl |= E1000_RCTL_SZ_512;
1150 : : * 256: rctl |= E1000_RCTL_SZ_256;
1151 : : */
1152 [ # # ]: 0 : if (rctl_bsize > 0) {
1153 [ # # ]: 0 : if (rctl_bsize >= 512) /* 512 <= buf_size < 1024 - use 512 */
1154 : 0 : rctl |= E1000_RCTL_SZ_512;
1155 : : else /* 256 <= buf_size < 512 - use 256 */
1156 : 0 : rctl |= E1000_RCTL_SZ_256;
1157 : : }
1158 : :
1159 : : /*
1160 : : * Configure RSS if device configured with multiple RX queues.
1161 : : */
1162 : 0 : igc_dev_mq_rx_configure(dev);
1163 : :
1164 : : /* Update the rctl since igc_dev_mq_rx_configure may change its value */
1165 : 0 : rctl |= E1000_READ_REG(hw, E1000_RCTL);
1166 : :
1167 : : /*
1168 : : * Setup the Checksum Register.
1169 : : * Receive Full-Packet Checksum Offload is mutually exclusive with RSS.
1170 : : */
1171 : 0 : rxcsum = E1000_READ_REG(hw, E1000_RXCSUM);
1172 : : rxcsum |= E1000_RXCSUM_PCSD;
1173 : :
1174 : : /* Enable both L3/L4 rx checksum offload */
1175 [ # # ]: 0 : if (offloads & RTE_ETH_RX_OFFLOAD_IPV4_CKSUM)
1176 : 0 : rxcsum |= E1000_RXCSUM_IPOFL;
1177 : : else
1178 : 0 : rxcsum &= ~E1000_RXCSUM_IPOFL;
1179 : :
1180 [ # # ]: 0 : if (offloads &
1181 : : (RTE_ETH_RX_OFFLOAD_TCP_CKSUM | RTE_ETH_RX_OFFLOAD_UDP_CKSUM)) {
1182 : 0 : rxcsum |= E1000_RXCSUM_TUOFL;
1183 : 0 : offloads |= RTE_ETH_RX_OFFLOAD_SCTP_CKSUM;
1184 : : } else {
1185 : 0 : rxcsum &= ~E1000_RXCSUM_TUOFL;
1186 : : }
1187 : :
1188 [ # # ]: 0 : if (offloads & RTE_ETH_RX_OFFLOAD_SCTP_CKSUM)
1189 : 0 : rxcsum |= E1000_RXCSUM_CRCOFL;
1190 : : else
1191 : 0 : rxcsum &= ~E1000_RXCSUM_CRCOFL;
1192 : :
1193 : 0 : E1000_WRITE_REG(hw, E1000_RXCSUM, rxcsum);
1194 : :
1195 : : /* Setup the Receive Control Register. */
1196 [ # # ]: 0 : if (offloads & RTE_ETH_RX_OFFLOAD_KEEP_CRC)
1197 : 0 : rctl &= ~E1000_RCTL_SECRC; /* Do not Strip Ethernet CRC. */
1198 : : else
1199 : 0 : rctl |= E1000_RCTL_SECRC; /* Strip Ethernet CRC. */
1200 : :
1201 : : rctl &= ~E1000_RCTL_MO_MSK;
1202 : 0 : rctl &= ~E1000_RCTL_LBM_MSK;
1203 : 0 : rctl |= E1000_RCTL_EN | E1000_RCTL_BAM | E1000_RCTL_LBM_NO |
1204 : : E1000_RCTL_DPF |
1205 : 0 : (hw->mac.mc_filter_type << E1000_RCTL_MO_SHIFT);
1206 : :
1207 [ # # ]: 0 : if (dev->data->dev_conf.lpbk_mode == 1)
1208 : 0 : rctl |= E1000_RCTL_LBM_MAC;
1209 : :
1210 : : rctl &= ~(E1000_RCTL_HSEL_MSK | E1000_RCTL_CFIEN | E1000_RCTL_CFI |
1211 : : E1000_RCTL_PSP | E1000_RCTL_PMCF);
1212 : :
1213 : : /* Make sure VLAN Filters are off. */
1214 : : rctl &= ~E1000_RCTL_VFE;
1215 : : /* Don't store bad packets. */
1216 : 0 : rctl &= ~E1000_RCTL_SBP;
1217 : :
1218 : : /* Enable Receives. */
1219 : 0 : E1000_WRITE_REG(hw, E1000_RCTL, rctl);
1220 : :
1221 : : /*
1222 : : * Setup the HW Rx Head and Tail Descriptor Pointers.
1223 : : * This needs to be done after enable.
1224 : : */
1225 [ # # ]: 0 : for (i = 0; i < dev->data->nb_rx_queues; i++) {
1226 : : uint32_t dvmolr;
1227 : :
1228 : 0 : rxq = dev->data->rx_queues[i];
1229 [ # # ]: 0 : E1000_WRITE_REG(hw, E1000_RDH(rxq->reg_idx), 0);
1230 [ # # ]: 0 : E1000_WRITE_REG(hw, E1000_RDT(rxq->reg_idx), rxq->nb_rx_desc - 1);
1231 : :
1232 : 0 : dvmolr = E1000_READ_REG(hw, E1000_DVMOLR(rxq->reg_idx));
1233 [ # # ]: 0 : if (rxq->offloads & RTE_ETH_RX_OFFLOAD_VLAN_STRIP)
1234 : 0 : dvmolr |= E1000_DVMOLR_STRVLAN;
1235 : : else
1236 : 0 : dvmolr &= ~E1000_DVMOLR_STRVLAN;
1237 : :
1238 [ # # ]: 0 : if (offloads & RTE_ETH_RX_OFFLOAD_KEEP_CRC)
1239 : 0 : dvmolr &= ~E1000_DVMOLR_STRCRC;
1240 : : else
1241 : 0 : dvmolr |= E1000_DVMOLR_STRCRC;
1242 : :
1243 : 0 : E1000_WRITE_REG(hw, E1000_DVMOLR(rxq->reg_idx), dvmolr);
1244 : 0 : dev->data->rx_queue_state[i] = RTE_ETH_QUEUE_STATE_STARTED;
1245 : : }
1246 : :
1247 : : return 0;
1248 : : }
1249 : :
1250 : : static void
1251 : : igc_reset_rx_queue(struct igc_rx_queue *rxq)
1252 : : {
1253 : : static const union e1000_adv_rx_desc zeroed_desc = { {0} };
1254 : : unsigned int i;
1255 : :
1256 : : /* Zero out HW ring memory */
1257 [ # # # # ]: 0 : for (i = 0; i < rxq->nb_rx_desc; i++)
1258 : 0 : rxq->rx_ring[i] = zeroed_desc;
1259 : :
1260 : 0 : rxq->rx_tail = 0;
1261 : 0 : rxq->pkt_first_seg = NULL;
1262 : 0 : rxq->pkt_last_seg = NULL;
1263 : : }
1264 : :
1265 : : int
1266 : 0 : eth_igc_rx_queue_setup(struct rte_eth_dev *dev,
1267 : : uint16_t queue_idx,
1268 : : uint16_t nb_desc,
1269 : : unsigned int socket_id,
1270 : : const struct rte_eth_rxconf *rx_conf,
1271 : : struct rte_mempool *mp)
1272 : : {
1273 : 0 : struct e1000_hw *hw = IGC_DEV_PRIVATE_HW(dev);
1274 : : const struct rte_memzone *rz;
1275 : : struct igc_rx_queue *rxq;
1276 : : unsigned int size;
1277 : :
1278 : : /*
1279 : : * Validate number of receive descriptors.
1280 : : * It must not exceed hardware maximum, and must be multiple
1281 : : * of IGC_RX_DESCRIPTOR_MULTIPLE.
1282 : : */
1283 [ # # ]: 0 : if (nb_desc % IGC_RX_DESCRIPTOR_MULTIPLE != 0 ||
1284 [ # # ]: 0 : nb_desc > IGC_MAX_RXD || nb_desc < IGC_MIN_RXD) {
1285 : 0 : PMD_DRV_LOG(ERR,
1286 : : "RX descriptor must be multiple of %u(cur: %u) and between %u and %u",
1287 : : IGC_RX_DESCRIPTOR_MULTIPLE, nb_desc,
1288 : : IGC_MIN_RXD, IGC_MAX_RXD);
1289 : 0 : return -EINVAL;
1290 : : }
1291 : :
1292 : : /* Free memory prior to re-allocation if needed */
1293 [ # # ]: 0 : if (dev->data->rx_queues[queue_idx] != NULL) {
1294 : 0 : igc_rx_queue_release(dev->data->rx_queues[queue_idx]);
1295 : 0 : dev->data->rx_queues[queue_idx] = NULL;
1296 : : }
1297 : :
1298 : : /* First allocate the RX queue data structure. */
1299 : 0 : rxq = rte_zmalloc("ethdev RX queue", sizeof(struct igc_rx_queue),
1300 : : RTE_CACHE_LINE_SIZE);
1301 [ # # ]: 0 : if (rxq == NULL)
1302 : : return -ENOMEM;
1303 : 0 : rxq->offloads = rx_conf->offloads;
1304 : 0 : rxq->mb_pool = mp;
1305 : 0 : rxq->nb_rx_desc = nb_desc;
1306 : 0 : rxq->pthresh = rx_conf->rx_thresh.pthresh;
1307 : 0 : rxq->hthresh = rx_conf->rx_thresh.hthresh;
1308 : 0 : rxq->wthresh = rx_conf->rx_thresh.wthresh;
1309 : 0 : rxq->drop_en = rx_conf->rx_drop_en;
1310 : 0 : rxq->rx_free_thresh = rx_conf->rx_free_thresh;
1311 : 0 : rxq->queue_id = queue_idx;
1312 : 0 : rxq->reg_idx = queue_idx;
1313 : 0 : rxq->port_id = dev->data->port_id;
1314 : :
1315 : : /*
1316 : : * Allocate RX ring hardware descriptors. A memzone large enough to
1317 : : * handle the maximum ring size is allocated in order to allow for
1318 : : * resizing in later calls to the queue setup function.
1319 : : */
1320 : : size = sizeof(union e1000_adv_rx_desc) * IGC_MAX_RXD;
1321 : 0 : rz = rte_eth_dma_zone_reserve(dev, "rx_ring", queue_idx, size,
1322 : : IGC_ALIGN, socket_id);
1323 [ # # ]: 0 : if (rz == NULL) {
1324 : 0 : igc_rx_queue_release(rxq);
1325 : 0 : return -ENOMEM;
1326 : : }
1327 [ # # ]: 0 : rxq->rdt_reg_addr = E1000_PCI_REG_ADDR(hw, E1000_RDT(rxq->reg_idx));
1328 [ # # ]: 0 : rxq->rdh_reg_addr = E1000_PCI_REG_ADDR(hw, E1000_RDH(rxq->reg_idx));
1329 : 0 : rxq->rx_ring_phys_addr = rz->iova;
1330 : 0 : rxq->rx_ring = (union e1000_adv_rx_desc *)rz->addr;
1331 : :
1332 : : /* Allocate software ring. */
1333 : 0 : rxq->sw_ring = rte_zmalloc("rxq->sw_ring",
1334 : : sizeof(struct igc_rx_entry) * nb_desc,
1335 : : RTE_CACHE_LINE_SIZE);
1336 [ # # ]: 0 : if (rxq->sw_ring == NULL) {
1337 : 0 : igc_rx_queue_release(rxq);
1338 : 0 : return -ENOMEM;
1339 : : }
1340 : :
1341 : 0 : PMD_DRV_LOG(DEBUG, "sw_ring=%p hw_ring=%p dma_addr=0x%" PRIx64,
1342 : : rxq->sw_ring, rxq->rx_ring, rxq->rx_ring_phys_addr);
1343 : :
1344 : 0 : dev->data->rx_queues[queue_idx] = rxq;
1345 : : igc_reset_rx_queue(rxq);
1346 : :
1347 : 0 : return 0;
1348 : : }
1349 : :
1350 : : /* prepare packets for transmit */
1351 : : uint16_t
1352 : 0 : eth_igc_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts,
1353 : : uint16_t nb_pkts)
1354 : : {
1355 : : int i, ret;
1356 : : struct rte_mbuf *m;
1357 : :
1358 [ # # ]: 0 : for (i = 0; i < nb_pkts; i++) {
1359 : 0 : m = tx_pkts[i];
1360 : :
1361 : : /* Check some limitations for TSO in hardware */
1362 [ # # ]: 0 : if (m->ol_flags & IGC_TX_OFFLOAD_SEG)
1363 [ # # ]: 0 : if (m->tso_segsz > IGC_TSO_MAX_MSS ||
1364 [ # # ]: 0 : m->l2_len + m->l3_len + m->l4_len >
1365 : : IGC_TSO_MAX_HDRLEN) {
1366 : 0 : rte_errno = EINVAL;
1367 : 0 : return i;
1368 : : }
1369 : :
1370 [ # # ]: 0 : if (m->ol_flags & IGC_TX_OFFLOAD_NOTSUP_MASK) {
1371 : 0 : rte_errno = ENOTSUP;
1372 : 0 : return i;
1373 : : }
1374 : :
1375 : : #ifdef RTE_ETHDEV_DEBUG_TX
1376 : : ret = rte_validate_tx_offload(m);
1377 : : if (ret != 0) {
1378 : : rte_errno = -ret;
1379 : : return i;
1380 : : }
1381 : : #endif
1382 : : ret = rte_net_intel_cksum_prepare(m);
1383 [ # # ]: 0 : if (ret != 0) {
1384 : 0 : rte_errno = -ret;
1385 : 0 : return i;
1386 : : }
1387 : : }
1388 : :
1389 : 0 : return i;
1390 : : }
1391 : :
1392 : : /*
1393 : : *There're some limitations in hardware for TCP segmentation offload. We
1394 : : *should check whether the parameters are valid.
1395 : : */
1396 : : static inline uint64_t
1397 : : check_tso_para(uint64_t ol_req, union igc_tx_offload ol_para)
1398 : : {
1399 : 0 : if (!(ol_req & IGC_TX_OFFLOAD_SEG))
1400 : : return ol_req;
1401 [ # # ]: 0 : if (ol_para.tso_segsz > IGC_TSO_MAX_MSS || ol_para.l2_len +
1402 [ # # ]: 0 : ol_para.l3_len + ol_para.l4_len > IGC_TSO_MAX_HDRLEN) {
1403 : 0 : ol_req &= ~IGC_TX_OFFLOAD_SEG;
1404 : 0 : ol_req |= RTE_MBUF_F_TX_TCP_CKSUM;
1405 : : }
1406 : : return ol_req;
1407 : : }
1408 : :
1409 : : /*
1410 : : * Check which hardware context can be used. Use the existing match
1411 : : * or create a new context descriptor.
1412 : : */
1413 : : static inline uint32_t
1414 : 0 : what_advctx_update(struct igc_tx_queue *txq, uint64_t flags,
1415 : : union igc_tx_offload tx_offload)
1416 : : {
1417 : 0 : uint32_t curr = txq->ctx_curr;
1418 : :
1419 : : /* If match with the current context */
1420 [ # # # # ]: 0 : if (likely(txq->ctx_cache[curr].flags == flags &&
1421 : : txq->ctx_cache[curr].tx_offload.data ==
1422 : : (txq->ctx_cache[curr].tx_offload_mask.data &
1423 : : tx_offload.data))) {
1424 : : return curr;
1425 : : }
1426 : :
1427 : : /* Total two context, if match with the second context */
1428 : 0 : curr ^= 1;
1429 [ # # # # ]: 0 : if (likely(txq->ctx_cache[curr].flags == flags &&
1430 : : txq->ctx_cache[curr].tx_offload.data ==
1431 : : (txq->ctx_cache[curr].tx_offload_mask.data &
1432 : : tx_offload.data))) {
1433 : 0 : txq->ctx_curr = curr;
1434 : 0 : return curr;
1435 : : }
1436 : :
1437 : : /* Mismatch, create new one */
1438 : : return IGC_CTX_NUM;
1439 : : }
1440 : :
1441 : : static uint32_t igc_tx_launchtime(uint64_t txtime, uint16_t port_id)
1442 : : {
1443 : : struct rte_eth_dev *dev = &rte_eth_devices[port_id];
1444 : 0 : struct igc_adapter *adapter = IGC_DEV_PRIVATE(dev);
1445 : 0 : uint64_t base_time = adapter->base_time;
1446 : 0 : uint64_t cycle_time = adapter->cycle_time;
1447 : : uint32_t launchtime;
1448 : :
1449 : 0 : launchtime = (txtime - base_time) % cycle_time;
1450 : :
1451 : : return rte_cpu_to_le_32(launchtime);
1452 : : }
1453 : :
1454 : : /*
1455 : : * This is a separate function, looking for optimization opportunity here
1456 : : * Rework required to go with the pre-defined values.
1457 : : */
1458 : : static inline void
1459 : 0 : igc_set_xmit_ctx(struct igc_tx_queue *txq,
1460 : : volatile struct e1000_adv_tx_context_desc *ctx_txd,
1461 : : uint64_t ol_flags, union igc_tx_offload tx_offload,
1462 : : uint64_t txtime)
1463 : : {
1464 : : uint32_t type_tucmd_mlhl;
1465 : : uint32_t mss_l4len_idx;
1466 : : uint32_t ctx_curr;
1467 : : uint32_t vlan_macip_lens;
1468 : : union igc_tx_offload tx_offload_mask;
1469 : :
1470 : : /* Use the previous context */
1471 : 0 : txq->ctx_curr ^= 1;
1472 : 0 : ctx_curr = txq->ctx_curr;
1473 : :
1474 : 0 : tx_offload_mask.data = 0;
1475 : : type_tucmd_mlhl = 0;
1476 : :
1477 : : /* Specify which HW CTX to upload. */
1478 : 0 : mss_l4len_idx = (ctx_curr << E1000_ADVTXD_IDX_SHIFT);
1479 : :
1480 [ # # ]: 0 : if (ol_flags & RTE_MBUF_F_TX_VLAN)
1481 : 0 : tx_offload_mask.vlan_tci = 0xffff;
1482 : :
1483 : : /* check if TCP segmentation required for this packet */
1484 [ # # ]: 0 : if (ol_flags & IGC_TX_OFFLOAD_SEG) {
1485 : : /* implies IP cksum in IPv4 */
1486 [ # # ]: 0 : if (ol_flags & RTE_MBUF_F_TX_IP_CKSUM)
1487 : : type_tucmd_mlhl = E1000_ADVTXD_TUCMD_IPV4 |
1488 : : E1000_ADVTXD_DTYP_CTXT | E1000_ADVTXD_DCMD_DEXT;
1489 : : else
1490 : : type_tucmd_mlhl = E1000_ADVTXD_TUCMD_IPV6 |
1491 : : E1000_ADVTXD_DTYP_CTXT | E1000_ADVTXD_DCMD_DEXT;
1492 : :
1493 [ # # ]: 0 : if (ol_flags & RTE_MBUF_F_TX_TCP_SEG)
1494 : 0 : type_tucmd_mlhl |= E1000_ADVTXD_TUCMD_L4T_TCP;
1495 : : else
1496 : : type_tucmd_mlhl |= E1000_ADVTXD_TUCMD_L4T_UDP;
1497 : :
1498 : 0 : tx_offload_mask.data |= TX_TSO_CMP_MASK;
1499 : 0 : mss_l4len_idx |= (uint32_t)tx_offload.tso_segsz <<
1500 : : E1000_ADVTXD_MSS_SHIFT;
1501 : 0 : mss_l4len_idx |= (uint32_t)tx_offload.l4_len <<
1502 : : E1000_ADVTXD_L4LEN_SHIFT;
1503 : : } else { /* no TSO, check if hardware checksum is needed */
1504 [ # # ]: 0 : if (ol_flags & (RTE_MBUF_F_TX_IP_CKSUM | RTE_MBUF_F_TX_L4_MASK))
1505 : 0 : tx_offload_mask.data |= TX_MACIP_LEN_CMP_MASK;
1506 : :
1507 [ # # ]: 0 : if (ol_flags & RTE_MBUF_F_TX_IP_CKSUM)
1508 : : type_tucmd_mlhl = E1000_ADVTXD_TUCMD_IPV4;
1509 : :
1510 [ # # # # ]: 0 : switch (ol_flags & RTE_MBUF_F_TX_L4_MASK) {
1511 : 0 : case RTE_MBUF_F_TX_TCP_CKSUM:
1512 : 0 : type_tucmd_mlhl |= E1000_ADVTXD_TUCMD_L4T_TCP |
1513 : : E1000_ADVTXD_DTYP_CTXT | E1000_ADVTXD_DCMD_DEXT;
1514 : 0 : mss_l4len_idx |= (uint32_t)sizeof(struct rte_tcp_hdr)
1515 : : << E1000_ADVTXD_L4LEN_SHIFT;
1516 : 0 : break;
1517 : 0 : case RTE_MBUF_F_TX_UDP_CKSUM:
1518 : 0 : type_tucmd_mlhl |= E1000_ADVTXD_TUCMD_L4T_UDP |
1519 : : E1000_ADVTXD_DTYP_CTXT | E1000_ADVTXD_DCMD_DEXT;
1520 : 0 : mss_l4len_idx |= (uint32_t)sizeof(struct rte_udp_hdr)
1521 : : << E1000_ADVTXD_L4LEN_SHIFT;
1522 : 0 : break;
1523 : 0 : case RTE_MBUF_F_TX_SCTP_CKSUM:
1524 : 0 : type_tucmd_mlhl |= E1000_ADVTXD_TUCMD_L4T_SCTP |
1525 : : E1000_ADVTXD_DTYP_CTXT | E1000_ADVTXD_DCMD_DEXT;
1526 : 0 : mss_l4len_idx |= (uint32_t)sizeof(struct rte_sctp_hdr)
1527 : : << E1000_ADVTXD_L4LEN_SHIFT;
1528 : 0 : break;
1529 : 0 : default:
1530 : 0 : type_tucmd_mlhl |= IGC_ADVTXD_TUCMD_L4T_RSV |
1531 : : E1000_ADVTXD_DTYP_CTXT | E1000_ADVTXD_DCMD_DEXT;
1532 : 0 : break;
1533 : : }
1534 : : }
1535 : :
1536 [ # # ]: 0 : if (!txtime) {
1537 : 0 : txq->ctx_cache[ctx_curr].flags = ol_flags;
1538 : 0 : txq->ctx_cache[ctx_curr].tx_offload.data =
1539 : 0 : tx_offload_mask.data & tx_offload.data;
1540 : 0 : txq->ctx_cache[ctx_curr].tx_offload_mask = tx_offload_mask;
1541 : : }
1542 : :
1543 : 0 : ctx_txd->type_tucmd_mlhl = rte_cpu_to_le_32(type_tucmd_mlhl);
1544 : 0 : vlan_macip_lens = (uint32_t)tx_offload.data;
1545 : 0 : ctx_txd->vlan_macip_lens = rte_cpu_to_le_32(vlan_macip_lens);
1546 : 0 : ctx_txd->mss_l4len_idx = rte_cpu_to_le_32(mss_l4len_idx);
1547 : :
1548 [ # # ]: 0 : if (txtime)
1549 : 0 : ctx_txd->u.launch_time = igc_tx_launchtime(txtime,
1550 : 0 : txq->port_id);
1551 : : else
1552 : 0 : ctx_txd->u.launch_time = 0;
1553 : 0 : }
1554 : :
1555 : : static inline uint32_t
1556 : : tx_desc_vlan_flags_to_cmdtype(uint64_t ol_flags)
1557 : : {
1558 : : uint32_t cmdtype;
1559 : : static uint32_t vlan_cmd[2] = {0, E1000_ADVTXD_DCMD_VLE};
1560 : : static uint32_t tso_cmd[2] = {0, E1000_ADVTXD_DCMD_TSE};
1561 : 0 : cmdtype = vlan_cmd[(ol_flags & RTE_MBUF_F_TX_VLAN) != 0];
1562 : 0 : cmdtype |= tso_cmd[(ol_flags & IGC_TX_OFFLOAD_SEG) != 0];
1563 : : return cmdtype;
1564 : : }
1565 : :
1566 : : static inline uint32_t
1567 : : tx_desc_cksum_flags_to_olinfo(uint64_t ol_flags)
1568 : : {
1569 : : static const uint32_t l4_olinfo[2] = {0, IGC_ADVTXD_POPTS_TXSM};
1570 : : static const uint32_t l3_olinfo[2] = {0, IGC_ADVTXD_POPTS_IXSM};
1571 : : uint32_t tmp;
1572 : :
1573 : 0 : tmp = l4_olinfo[(ol_flags & RTE_MBUF_F_TX_L4_MASK) != RTE_MBUF_F_TX_L4_NO_CKSUM];
1574 : 0 : tmp |= l3_olinfo[(ol_flags & RTE_MBUF_F_TX_IP_CKSUM) != 0];
1575 : 0 : tmp |= l4_olinfo[(ol_flags & IGC_TX_OFFLOAD_SEG) != 0];
1576 : : return tmp;
1577 : : }
1578 : :
1579 : : uint16_t
1580 : 0 : igc_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
1581 : : {
1582 : : struct igc_tx_queue * const txq = tx_queue;
1583 : 0 : struct igc_tx_entry * const sw_ring = txq->sw_ring;
1584 : : struct igc_tx_entry *txe, *txn;
1585 : 0 : volatile union e1000_adv_tx_desc * const txr = txq->tx_ring;
1586 : : volatile union e1000_adv_tx_desc *txd;
1587 : : struct rte_mbuf *tx_pkt;
1588 : : struct rte_mbuf *m_seg;
1589 : : uint64_t buf_dma_addr;
1590 : : uint32_t olinfo_status;
1591 : : uint32_t cmd_type_len;
1592 : : uint32_t pkt_len;
1593 : : uint16_t slen;
1594 : : uint64_t ol_flags;
1595 : : uint16_t tx_end;
1596 : : uint16_t tx_id;
1597 : : uint16_t tx_last;
1598 : : uint16_t nb_tx;
1599 : : uint64_t tx_ol_req;
1600 : : uint32_t new_ctx = 0;
1601 : 0 : union igc_tx_offload tx_offload = {0};
1602 : : uint64_t ts;
1603 : :
1604 : 0 : tx_id = txq->tx_tail;
1605 : 0 : txe = &sw_ring[tx_id];
1606 : :
1607 [ # # ]: 0 : for (nb_tx = 0; nb_tx < nb_pkts; nb_tx++) {
1608 : 0 : tx_pkt = *tx_pkts++;
1609 : 0 : pkt_len = tx_pkt->pkt_len;
1610 : :
1611 [ # # ]: 0 : RTE_MBUF_PREFETCH_TO_FREE(txe->mbuf);
1612 : :
1613 : : /*
1614 : : * The number of descriptors that must be allocated for a
1615 : : * packet is the number of segments of that packet, plus 1
1616 : : * Context Descriptor for the VLAN Tag Identifier, if any.
1617 : : * Determine the last TX descriptor to allocate in the TX ring
1618 : : * for the packet, starting from the current position (tx_id)
1619 : : * in the ring.
1620 : : */
1621 : 0 : tx_last = (uint16_t)(tx_id + tx_pkt->nb_segs - 1);
1622 : :
1623 : 0 : ol_flags = tx_pkt->ol_flags;
1624 : 0 : tx_ol_req = ol_flags & IGC_TX_OFFLOAD_MASK;
1625 : :
1626 : : /* If a Context Descriptor need be built . */
1627 [ # # ]: 0 : if (tx_ol_req) {
1628 : 0 : tx_offload.l2_len = tx_pkt->l2_len;
1629 : 0 : tx_offload.l3_len = tx_pkt->l3_len;
1630 : 0 : tx_offload.l4_len = tx_pkt->l4_len;
1631 : 0 : tx_offload.vlan_tci = tx_pkt->vlan_tci;
1632 [ # # ]: 0 : tx_offload.tso_segsz = tx_pkt->tso_segsz;
1633 : : tx_ol_req = check_tso_para(tx_ol_req, tx_offload);
1634 : :
1635 : 0 : new_ctx = what_advctx_update(txq, tx_ol_req,
1636 : : tx_offload);
1637 : : /* Only allocate context descriptor if required*/
1638 : 0 : new_ctx = (new_ctx >= IGC_CTX_NUM);
1639 : 0 : tx_last = (uint16_t)(tx_last + new_ctx);
1640 : : }
1641 [ # # ]: 0 : if (tx_last >= txq->nb_tx_desc)
1642 : 0 : tx_last = (uint16_t)(tx_last - txq->nb_tx_desc);
1643 : :
1644 : : PMD_TX_LOG(DEBUG,
1645 : : "port_id=%u queue_id=%u pktlen=%u tx_first=%u tx_last=%u",
1646 : : txq->port_id, txq->queue_id, pkt_len, tx_id, tx_last);
1647 : :
1648 : : /*
1649 : : * Check if there are enough free descriptors in the TX ring
1650 : : * to transmit the next packet.
1651 : : * This operation is based on the two following rules:
1652 : : *
1653 : : * 1- Only check that the last needed TX descriptor can be
1654 : : * allocated (by construction, if that descriptor is free,
1655 : : * all intermediate ones are also free).
1656 : : *
1657 : : * For this purpose, the index of the last TX descriptor
1658 : : * used for a packet (the "last descriptor" of a packet)
1659 : : * is recorded in the TX entries (the last one included)
1660 : : * that are associated with all TX descriptors allocated
1661 : : * for that packet.
1662 : : *
1663 : : * 2- Avoid to allocate the last free TX descriptor of the
1664 : : * ring, in order to never set the TDT register with the
1665 : : * same value stored in parallel by the NIC in the TDH
1666 : : * register, which makes the TX engine of the NIC enter
1667 : : * in a deadlock situation.
1668 : : *
1669 : : * By extension, avoid to allocate a free descriptor that
1670 : : * belongs to the last set of free descriptors allocated
1671 : : * to the same packet previously transmitted.
1672 : : */
1673 : :
1674 : : /*
1675 : : * The "last descriptor" of the previously sent packet, if any,
1676 : : * which used the last descriptor to allocate.
1677 : : */
1678 : 0 : tx_end = sw_ring[tx_last].last_id;
1679 : :
1680 : : /*
1681 : : * The next descriptor following that "last descriptor" in the
1682 : : * ring.
1683 : : */
1684 : 0 : tx_end = sw_ring[tx_end].next_id;
1685 : :
1686 : : /*
1687 : : * The "last descriptor" associated with that next descriptor.
1688 : : */
1689 : 0 : tx_end = sw_ring[tx_end].last_id;
1690 : :
1691 : : /*
1692 : : * Check that this descriptor is free.
1693 : : */
1694 [ # # ]: 0 : if (!(txr[tx_end].wb.status & E1000_TXD_STAT_DD)) {
1695 [ # # ]: 0 : if (nb_tx == 0)
1696 : : return 0;
1697 : 0 : goto end_of_tx;
1698 : : }
1699 : :
1700 : : /*
1701 : : * Set common flags of all TX Data Descriptors.
1702 : : *
1703 : : * The following bits must be set in all Data Descriptors:
1704 : : * - E1000_ADVTXD_DTYP_DATA
1705 : : * - E1000_ADVTXD_DCMD_DEXT
1706 : : *
1707 : : * The following bits must be set in the first Data Descriptor
1708 : : * and are ignored in the other ones:
1709 : : * - E1000_ADVTXD_DCMD_IFCS
1710 : : * - E1000_ADVTXD_MAC_1588
1711 : : * - E1000_ADVTXD_DCMD_VLE
1712 : : *
1713 : : * The following bits must only be set in the last Data
1714 : : * Descriptor:
1715 : : * - E1000_TXD_CMD_EOP
1716 : : *
1717 : : * The following bits can be set in any Data Descriptor, but
1718 : : * are only set in the last Data Descriptor:
1719 : : * - E1000_TXD_CMD_RS
1720 : : */
1721 : 0 : cmd_type_len = txq->txd_type |
1722 : : E1000_ADVTXD_DCMD_IFCS | E1000_ADVTXD_DCMD_DEXT;
1723 [ # # ]: 0 : if (tx_ol_req & IGC_TX_OFFLOAD_SEG)
1724 : 0 : pkt_len -= (tx_pkt->l2_len + tx_pkt->l3_len +
1725 : 0 : tx_pkt->l4_len);
1726 : 0 : olinfo_status = (pkt_len << E1000_ADVTXD_PAYLEN_SHIFT);
1727 : :
1728 : : /*
1729 : : * Timer 0 should be used to for packet timestamping,
1730 : : * sample the packet timestamp to reg 0
1731 : : */
1732 [ # # ]: 0 : if (ol_flags & RTE_MBUF_F_TX_IEEE1588_TMST)
1733 : 0 : cmd_type_len |= E1000_ADVTXD_MAC_TSTAMP;
1734 : :
1735 [ # # ]: 0 : if (tx_ol_req) {
1736 : : /* Setup TX Advanced context descriptor if required */
1737 [ # # ]: 0 : if (new_ctx) {
1738 : : volatile struct e1000_adv_tx_context_desc *
1739 : 0 : ctx_txd = (volatile struct
1740 : 0 : e1000_adv_tx_context_desc *)&txr[tx_id];
1741 : :
1742 : 0 : txn = &sw_ring[txe->next_id];
1743 [ # # ]: 0 : RTE_MBUF_PREFETCH_TO_FREE(txn->mbuf);
1744 : :
1745 [ # # ]: 0 : if (txe->mbuf != NULL) {
1746 : : rte_pktmbuf_free_seg(txe->mbuf);
1747 : 0 : txe->mbuf = NULL;
1748 : : }
1749 : :
1750 [ # # ]: 0 : if (igc_tx_timestamp_dynflag > 0) {
1751 : 0 : ts = *RTE_MBUF_DYNFIELD(tx_pkt,
1752 : : igc_tx_timestamp_dynfield_offset,
1753 : : uint64_t *);
1754 : 0 : igc_set_xmit_ctx(txq, ctx_txd,
1755 : : tx_ol_req, tx_offload, ts);
1756 : : } else {
1757 : 0 : igc_set_xmit_ctx(txq, ctx_txd,
1758 : : tx_ol_req, tx_offload, 0);
1759 : : }
1760 : :
1761 : 0 : txe->last_id = tx_last;
1762 : 0 : tx_id = txe->next_id;
1763 : : txe = txn;
1764 : : }
1765 : :
1766 : : /* Setup the TX Advanced Data Descriptor */
1767 : 0 : cmd_type_len |=
1768 : : tx_desc_vlan_flags_to_cmdtype(tx_ol_req);
1769 : 0 : olinfo_status |=
1770 : : tx_desc_cksum_flags_to_olinfo(tx_ol_req);
1771 : 0 : olinfo_status |= (uint32_t)txq->ctx_curr <<
1772 : : E1000_ADVTXD_IDX_SHIFT;
1773 : : }
1774 : :
1775 : : m_seg = tx_pkt;
1776 : : do {
1777 : 0 : txn = &sw_ring[txe->next_id];
1778 [ # # ]: 0 : RTE_MBUF_PREFETCH_TO_FREE(txn->mbuf);
1779 : :
1780 : 0 : txd = &txr[tx_id];
1781 : :
1782 [ # # ]: 0 : if (txe->mbuf != NULL)
1783 : : rte_pktmbuf_free_seg(txe->mbuf);
1784 : 0 : txe->mbuf = m_seg;
1785 : :
1786 : : /* Set up transmit descriptor */
1787 [ # # ]: 0 : slen = (uint16_t)m_seg->data_len;
1788 : : buf_dma_addr = rte_mbuf_data_iova(m_seg);
1789 : 0 : txd->read.buffer_addr =
1790 : : rte_cpu_to_le_64(buf_dma_addr);
1791 : 0 : txd->read.cmd_type_len =
1792 : 0 : rte_cpu_to_le_32(cmd_type_len | slen);
1793 : 0 : txd->read.olinfo_status =
1794 : : rte_cpu_to_le_32(olinfo_status);
1795 : 0 : txe->last_id = tx_last;
1796 : 0 : tx_id = txe->next_id;
1797 : : txe = txn;
1798 : 0 : m_seg = m_seg->next;
1799 [ # # ]: 0 : } while (m_seg != NULL);
1800 : :
1801 : : /*
1802 : : * The last packet data descriptor needs End Of Packet (EOP)
1803 : : * and Report Status (RS).
1804 : : */
1805 : 0 : txd->read.cmd_type_len |=
1806 : : rte_cpu_to_le_32(E1000_TXD_CMD_EOP | E1000_TXD_CMD_RS);
1807 : : }
1808 : 0 : end_of_tx:
1809 : : rte_wmb();
1810 : :
1811 : : /*
1812 : : * Set the Transmit Descriptor Tail (TDT).
1813 : : */
1814 : 0 : E1000_PCI_REG_WRITE_RELAXED(txq->tdt_reg_addr, tx_id);
1815 : : PMD_TX_LOG(DEBUG, "port_id=%u queue_id=%u tx_tail=%u nb_tx=%u",
1816 : : txq->port_id, txq->queue_id, tx_id, nb_tx);
1817 : 0 : txq->tx_tail = tx_id;
1818 : :
1819 : 0 : return nb_tx;
1820 : : }
1821 : :
1822 : 0 : int eth_igc_tx_descriptor_status(void *tx_queue, uint16_t offset)
1823 : : {
1824 : : struct igc_tx_queue *txq = tx_queue;
1825 : : volatile uint32_t *status;
1826 : : uint32_t desc;
1827 : :
1828 [ # # # # ]: 0 : if (unlikely(!txq || offset >= txq->nb_tx_desc))
1829 : : return -EINVAL;
1830 : :
1831 : 0 : desc = txq->tx_tail + offset;
1832 [ # # ]: 0 : if (desc >= txq->nb_tx_desc)
1833 : 0 : desc -= txq->nb_tx_desc;
1834 : :
1835 : 0 : status = &txq->tx_ring[desc].wb.status;
1836 [ # # ]: 0 : if (*status & rte_cpu_to_le_32(E1000_TXD_STAT_DD))
1837 : 0 : return RTE_ETH_TX_DESC_DONE;
1838 : :
1839 : : return RTE_ETH_TX_DESC_FULL;
1840 : : }
1841 : :
1842 : : static void
1843 : 0 : igc_tx_queue_release_mbufs(struct igc_tx_queue *txq)
1844 : : {
1845 : : unsigned int i;
1846 : :
1847 [ # # ]: 0 : if (txq->sw_ring != NULL) {
1848 [ # # ]: 0 : for (i = 0; i < txq->nb_tx_desc; i++) {
1849 [ # # ]: 0 : if (txq->sw_ring[i].mbuf != NULL) {
1850 : : rte_pktmbuf_free_seg(txq->sw_ring[i].mbuf);
1851 : 0 : txq->sw_ring[i].mbuf = NULL;
1852 : : }
1853 : : }
1854 : : }
1855 : 0 : }
1856 : :
1857 : : static void
1858 : 0 : igc_tx_queue_release(struct igc_tx_queue *txq)
1859 : : {
1860 : 0 : igc_tx_queue_release_mbufs(txq);
1861 : 0 : rte_free(txq->sw_ring);
1862 : 0 : rte_free(txq);
1863 : 0 : }
1864 : :
1865 : 0 : void eth_igc_tx_queue_release(struct rte_eth_dev *dev, uint16_t qid)
1866 : : {
1867 [ # # ]: 0 : if (dev->data->tx_queues[qid])
1868 : 0 : igc_tx_queue_release(dev->data->tx_queues[qid]);
1869 : 0 : }
1870 : :
1871 : : static void
1872 : : igc_reset_tx_queue_stat(struct igc_tx_queue *txq)
1873 : : {
1874 : 0 : txq->tx_head = 0;
1875 : 0 : txq->tx_tail = 0;
1876 : 0 : txq->ctx_curr = 0;
1877 : 0 : memset((void *)&txq->ctx_cache, 0,
1878 : : IGC_CTX_NUM * sizeof(struct igc_advctx_info));
1879 : : }
1880 : :
1881 : : static void
1882 : 0 : igc_reset_tx_queue(struct igc_tx_queue *txq)
1883 : : {
1884 : 0 : struct igc_tx_entry *txe = txq->sw_ring;
1885 : : uint16_t i, prev;
1886 : :
1887 : : /* Initialize ring entries */
1888 : 0 : prev = (uint16_t)(txq->nb_tx_desc - 1);
1889 [ # # ]: 0 : for (i = 0; i < txq->nb_tx_desc; i++) {
1890 : 0 : volatile union e1000_adv_tx_desc *txd = &txq->tx_ring[i];
1891 : :
1892 : 0 : txd->wb.status = E1000_TXD_STAT_DD;
1893 : 0 : txe[i].mbuf = NULL;
1894 : 0 : txe[i].last_id = i;
1895 : 0 : txe[prev].next_id = i;
1896 : : prev = i;
1897 : : }
1898 : :
1899 : 0 : txq->txd_type = E1000_ADVTXD_DTYP_DATA;
1900 : : igc_reset_tx_queue_stat(txq);
1901 : 0 : }
1902 : :
1903 : : /*
1904 : : * clear all rx/tx queue
1905 : : */
1906 : : void
1907 : 0 : igc_dev_clear_queues(struct rte_eth_dev *dev)
1908 : : {
1909 : : uint16_t i;
1910 : : struct igc_tx_queue *txq;
1911 : : struct igc_rx_queue *rxq;
1912 : :
1913 [ # # ]: 0 : for (i = 0; i < dev->data->nb_tx_queues; i++) {
1914 : 0 : txq = dev->data->tx_queues[i];
1915 [ # # ]: 0 : if (txq != NULL) {
1916 : 0 : igc_tx_queue_release_mbufs(txq);
1917 : 0 : igc_reset_tx_queue(txq);
1918 : 0 : dev->data->tx_queue_state[i] = RTE_ETH_QUEUE_STATE_STOPPED;
1919 : : }
1920 : : }
1921 : :
1922 [ # # ]: 0 : for (i = 0; i < dev->data->nb_rx_queues; i++) {
1923 : 0 : rxq = dev->data->rx_queues[i];
1924 [ # # ]: 0 : if (rxq != NULL) {
1925 : 0 : igc_rx_queue_release_mbufs(rxq);
1926 : : igc_reset_rx_queue(rxq);
1927 : 0 : dev->data->rx_queue_state[i] = RTE_ETH_QUEUE_STATE_STOPPED;
1928 : : }
1929 : : }
1930 : 0 : }
1931 : :
1932 : 0 : int eth_igc_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
1933 : : uint16_t nb_desc, unsigned int socket_id,
1934 : : const struct rte_eth_txconf *tx_conf)
1935 : : {
1936 : : const struct rte_memzone *tz;
1937 : : struct igc_tx_queue *txq;
1938 : : struct e1000_hw *hw;
1939 : : uint32_t size;
1940 : :
1941 [ # # ]: 0 : if (nb_desc % IGC_TX_DESCRIPTOR_MULTIPLE != 0 ||
1942 [ # # ]: 0 : nb_desc > IGC_MAX_TXD || nb_desc < IGC_MIN_TXD) {
1943 : 0 : PMD_DRV_LOG(ERR,
1944 : : "TX-descriptor must be a multiple of %u and between %u and %u, cur: %u",
1945 : : IGC_TX_DESCRIPTOR_MULTIPLE,
1946 : : IGC_MAX_TXD, IGC_MIN_TXD, nb_desc);
1947 : 0 : return -EINVAL;
1948 : : }
1949 : :
1950 : 0 : hw = IGC_DEV_PRIVATE_HW(dev);
1951 : :
1952 : : /*
1953 : : * The tx_free_thresh and tx_rs_thresh values are not used in the 2.5G
1954 : : * driver.
1955 : : */
1956 [ # # ]: 0 : if (tx_conf->tx_free_thresh != 0)
1957 : 0 : PMD_DRV_LOG(INFO,
1958 : : "The tx_free_thresh parameter is not used for the 2.5G driver");
1959 [ # # ]: 0 : if (tx_conf->tx_rs_thresh != 0)
1960 : 0 : PMD_DRV_LOG(INFO,
1961 : : "The tx_rs_thresh parameter is not used for the 2.5G driver");
1962 [ # # ]: 0 : if (tx_conf->tx_thresh.wthresh == 0)
1963 : 0 : PMD_DRV_LOG(INFO,
1964 : : "To improve 2.5G driver performance, consider setting the TX WTHRESH value to 4, 8, or 16.");
1965 : :
1966 : : /* Free memory prior to re-allocation if needed */
1967 [ # # ]: 0 : if (dev->data->tx_queues[queue_idx] != NULL) {
1968 : 0 : igc_tx_queue_release(dev->data->tx_queues[queue_idx]);
1969 : 0 : dev->data->tx_queues[queue_idx] = NULL;
1970 : : }
1971 : :
1972 : : /* First allocate the tx queue data structure */
1973 : 0 : txq = rte_zmalloc("ethdev TX queue", sizeof(struct igc_tx_queue),
1974 : : RTE_CACHE_LINE_SIZE);
1975 [ # # ]: 0 : if (txq == NULL)
1976 : : return -ENOMEM;
1977 : :
1978 : : /*
1979 : : * Allocate TX ring hardware descriptors. A memzone large enough to
1980 : : * handle the maximum ring size is allocated in order to allow for
1981 : : * resizing in later calls to the queue setup function.
1982 : : */
1983 : : size = sizeof(union e1000_adv_tx_desc) * IGC_MAX_TXD;
1984 : 0 : tz = rte_eth_dma_zone_reserve(dev, "tx_ring", queue_idx, size,
1985 : : IGC_ALIGN, socket_id);
1986 [ # # ]: 0 : if (tz == NULL) {
1987 : 0 : igc_tx_queue_release(txq);
1988 : 0 : return -ENOMEM;
1989 : : }
1990 : :
1991 : 0 : txq->nb_tx_desc = nb_desc;
1992 : 0 : txq->pthresh = tx_conf->tx_thresh.pthresh;
1993 : 0 : txq->hthresh = tx_conf->tx_thresh.hthresh;
1994 : 0 : txq->wthresh = tx_conf->tx_thresh.wthresh;
1995 : :
1996 : 0 : txq->queue_id = queue_idx;
1997 : 0 : txq->reg_idx = queue_idx;
1998 : 0 : txq->port_id = dev->data->port_id;
1999 : :
2000 [ # # ]: 0 : txq->tdt_reg_addr = E1000_PCI_REG_ADDR(hw, E1000_TDT(txq->reg_idx));
2001 : 0 : txq->tx_ring_phys_addr = tz->iova;
2002 : :
2003 : 0 : txq->tx_ring = (union e1000_adv_tx_desc *)tz->addr;
2004 : : /* Allocate software ring */
2005 : 0 : txq->sw_ring = rte_zmalloc("txq->sw_ring",
2006 : : sizeof(struct igc_tx_entry) * nb_desc,
2007 : : RTE_CACHE_LINE_SIZE);
2008 [ # # ]: 0 : if (txq->sw_ring == NULL) {
2009 : 0 : igc_tx_queue_release(txq);
2010 : 0 : return -ENOMEM;
2011 : : }
2012 : 0 : PMD_DRV_LOG(DEBUG, "sw_ring=%p hw_ring=%p dma_addr=0x%" PRIx64,
2013 : : txq->sw_ring, txq->tx_ring, txq->tx_ring_phys_addr);
2014 : :
2015 : 0 : igc_reset_tx_queue(txq);
2016 : 0 : dev->tx_pkt_burst = igc_xmit_pkts;
2017 : 0 : dev->tx_pkt_prepare = ð_igc_prep_pkts;
2018 : 0 : dev->data->tx_queues[queue_idx] = txq;
2019 : 0 : txq->offloads = tx_conf->offloads;
2020 : :
2021 : 0 : return 0;
2022 : : }
2023 : :
2024 : : int
2025 : 0 : eth_igc_tx_done_cleanup(void *txqueue, uint32_t free_cnt)
2026 : : {
2027 : : struct igc_tx_queue *txq = txqueue;
2028 : : struct igc_tx_entry *sw_ring;
2029 : : volatile union e1000_adv_tx_desc *txr;
2030 : : uint16_t tx_first; /* First segment analyzed. */
2031 : : uint16_t tx_id; /* Current segment being processed. */
2032 : : uint16_t tx_last; /* Last segment in the current packet. */
2033 : : uint16_t tx_next; /* First segment of the next packet. */
2034 : : uint32_t count;
2035 : :
2036 [ # # ]: 0 : if (txq == NULL)
2037 : : return -ENODEV;
2038 : :
2039 : : count = 0;
2040 : 0 : sw_ring = txq->sw_ring;
2041 : 0 : txr = txq->tx_ring;
2042 : :
2043 : : /*
2044 : : * tx_tail is the last sent packet on the sw_ring. Goto the end
2045 : : * of that packet (the last segment in the packet chain) and
2046 : : * then the next segment will be the start of the oldest segment
2047 : : * in the sw_ring. This is the first packet that will be
2048 : : * attempted to be freed.
2049 : : */
2050 : :
2051 : : /* Get last segment in most recently added packet. */
2052 : 0 : tx_first = sw_ring[txq->tx_tail].last_id;
2053 : :
2054 : : /* Get the next segment, which is the oldest segment in ring. */
2055 : 0 : tx_first = sw_ring[tx_first].next_id;
2056 : :
2057 : : /* Set the current index to the first. */
2058 : : tx_id = tx_first;
2059 : :
2060 : : /*
2061 : : * Loop through each packet. For each packet, verify that an
2062 : : * mbuf exists and that the last segment is free. If so, free
2063 : : * it and move on.
2064 : : */
2065 : : while (1) {
2066 : 0 : tx_last = sw_ring[tx_id].last_id;
2067 : :
2068 [ # # ]: 0 : if (sw_ring[tx_last].mbuf) {
2069 [ # # ]: 0 : if (!(txr[tx_last].wb.status &
2070 : : rte_cpu_to_le_32(E1000_TXD_STAT_DD)))
2071 : : break;
2072 : :
2073 : : /* Get the start of the next packet. */
2074 : 0 : tx_next = sw_ring[tx_last].next_id;
2075 : :
2076 : : /*
2077 : : * Loop through all segments in a
2078 : : * packet.
2079 : : */
2080 : : do {
2081 [ # # ]: 0 : rte_pktmbuf_free_seg(sw_ring[tx_id].mbuf);
2082 : 0 : sw_ring[tx_id].mbuf = NULL;
2083 : 0 : sw_ring[tx_id].last_id = tx_id;
2084 : :
2085 : : /* Move to next segment. */
2086 : 0 : tx_id = sw_ring[tx_id].next_id;
2087 [ # # ]: 0 : } while (tx_id != tx_next);
2088 : :
2089 : : /*
2090 : : * Increment the number of packets
2091 : : * freed.
2092 : : */
2093 : 0 : count++;
2094 [ # # ]: 0 : if (unlikely(count == free_cnt))
2095 : : break;
2096 : : } else {
2097 : : /*
2098 : : * There are multiple reasons to be here:
2099 : : * 1) All the packets on the ring have been
2100 : : * freed - tx_id is equal to tx_first
2101 : : * and some packets have been freed.
2102 : : * - Done, exit
2103 : : * 2) Interfaces has not sent a rings worth of
2104 : : * packets yet, so the segment after tail is
2105 : : * still empty. Or a previous call to this
2106 : : * function freed some of the segments but
2107 : : * not all so there is a hole in the list.
2108 : : * Hopefully this is a rare case.
2109 : : * - Walk the list and find the next mbuf. If
2110 : : * there isn't one, then done.
2111 : : */
2112 [ # # ]: 0 : if (likely(tx_id == tx_first && count != 0))
2113 : : break;
2114 : :
2115 : : /*
2116 : : * Walk the list and find the next mbuf, if any.
2117 : : */
2118 : : do {
2119 : : /* Move to next segment. */
2120 : 0 : tx_id = sw_ring[tx_id].next_id;
2121 : :
2122 [ # # ]: 0 : if (sw_ring[tx_id].mbuf)
2123 : : break;
2124 : :
2125 [ # # ]: 0 : } while (tx_id != tx_first);
2126 : :
2127 : : /*
2128 : : * Determine why previous loop bailed. If there
2129 : : * is not an mbuf, done.
2130 : : */
2131 [ # # ]: 0 : if (sw_ring[tx_id].mbuf == NULL)
2132 : : break;
2133 : : }
2134 : : }
2135 : :
2136 : 0 : return count;
2137 : : }
2138 : :
2139 : : void
2140 : 0 : igc_tx_init(struct rte_eth_dev *dev)
2141 : : {
2142 : 0 : struct e1000_hw *hw = IGC_DEV_PRIVATE_HW(dev);
2143 : 0 : uint64_t offloads = dev->data->dev_conf.txmode.offloads;
2144 : : uint32_t tctl;
2145 : : uint32_t txdctl;
2146 : : uint16_t i;
2147 : : int err;
2148 : :
2149 : : /* Setup the Base and Length of the Tx Descriptor Rings. */
2150 [ # # ]: 0 : for (i = 0; i < dev->data->nb_tx_queues; i++) {
2151 : 0 : struct igc_tx_queue *txq = dev->data->tx_queues[i];
2152 : 0 : uint64_t bus_addr = txq->tx_ring_phys_addr;
2153 : :
2154 [ # # ]: 0 : E1000_WRITE_REG(hw, E1000_TDLEN(txq->reg_idx),
2155 : : txq->nb_tx_desc *
2156 : : sizeof(union e1000_adv_tx_desc));
2157 [ # # ]: 0 : E1000_WRITE_REG(hw, E1000_TDBAH(txq->reg_idx),
2158 : : (uint32_t)(bus_addr >> 32));
2159 [ # # ]: 0 : E1000_WRITE_REG(hw, E1000_TDBAL(txq->reg_idx),
2160 : : (uint32_t)bus_addr);
2161 : :
2162 : : /* Setup the HW Tx Head and Tail descriptor pointers. */
2163 [ # # ]: 0 : E1000_WRITE_REG(hw, E1000_TDT(txq->reg_idx), 0);
2164 [ # # ]: 0 : E1000_WRITE_REG(hw, E1000_TDH(txq->reg_idx), 0);
2165 : :
2166 : : /* Setup Transmit threshold registers. */
2167 : 0 : txdctl = ((uint32_t)txq->pthresh << IGC_TXDCTL_PTHRESH_SHIFT) &
2168 : : IGC_TXDCTL_PTHRESH_MSK;
2169 : 0 : txdctl |= ((uint32_t)txq->hthresh << IGC_TXDCTL_HTHRESH_SHIFT) &
2170 : : IGC_TXDCTL_HTHRESH_MSK;
2171 : 0 : txdctl |= ((uint32_t)txq->wthresh << IGC_TXDCTL_WTHRESH_SHIFT) &
2172 : : IGC_TXDCTL_WTHRESH_MSK;
2173 : 0 : txdctl |= E1000_TXDCTL_QUEUE_ENABLE;
2174 [ # # ]: 0 : E1000_WRITE_REG(hw, E1000_TXDCTL(txq->reg_idx), txdctl);
2175 : 0 : dev->data->tx_queue_state[i] = RTE_ETH_QUEUE_STATE_STARTED;
2176 : : }
2177 : :
2178 [ # # ]: 0 : if (offloads & RTE_ETH_TX_OFFLOAD_SEND_ON_TIMESTAMP) {
2179 : 0 : err = rte_mbuf_dyn_tx_timestamp_register
2180 : : (&igc_tx_timestamp_dynfield_offset,
2181 : : &igc_tx_timestamp_dynflag);
2182 [ # # ]: 0 : if (err) {
2183 : 0 : PMD_DRV_LOG(ERR,
2184 : : "Cannot register mbuf field/flag for timestamp");
2185 : : }
2186 : : }
2187 : :
2188 : 0 : e1000_config_collision_dist(hw);
2189 : :
2190 : : /* Program the Transmit Control Register. */
2191 : 0 : tctl = E1000_READ_REG(hw, E1000_TCTL);
2192 : 0 : tctl &= ~E1000_TCTL_CT;
2193 : 0 : tctl |= (E1000_TCTL_PSP | E1000_TCTL_RTLC | E1000_TCTL_EN |
2194 : : ((uint32_t)E1000_COLLISION_THRESHOLD << E1000_CT_SHIFT));
2195 : :
2196 : : /* This write will effectively turn on the transmit unit. */
2197 : 0 : E1000_WRITE_REG(hw, E1000_TCTL, tctl);
2198 : 0 : }
2199 : :
2200 : : void
2201 : 0 : eth_igc_rxq_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
2202 : : struct rte_eth_rxq_info *qinfo)
2203 : : {
2204 : : struct igc_rx_queue *rxq;
2205 : :
2206 : 0 : rxq = dev->data->rx_queues[queue_id];
2207 : :
2208 : 0 : qinfo->mp = rxq->mb_pool;
2209 : 0 : qinfo->scattered_rx = dev->data->scattered_rx;
2210 : 0 : qinfo->nb_desc = rxq->nb_rx_desc;
2211 : :
2212 : 0 : qinfo->conf.rx_free_thresh = rxq->rx_free_thresh;
2213 : 0 : qinfo->conf.rx_drop_en = rxq->drop_en;
2214 : 0 : qinfo->conf.offloads = rxq->offloads;
2215 : 0 : qinfo->conf.rx_thresh.hthresh = rxq->hthresh;
2216 : 0 : qinfo->conf.rx_thresh.pthresh = rxq->pthresh;
2217 : 0 : qinfo->conf.rx_thresh.wthresh = rxq->wthresh;
2218 : 0 : }
2219 : :
2220 : : void
2221 : 0 : eth_igc_txq_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
2222 : : struct rte_eth_txq_info *qinfo)
2223 : : {
2224 : : struct igc_tx_queue *txq;
2225 : :
2226 : 0 : txq = dev->data->tx_queues[queue_id];
2227 : :
2228 : 0 : qinfo->nb_desc = txq->nb_tx_desc;
2229 : :
2230 : 0 : qinfo->conf.tx_thresh.pthresh = txq->pthresh;
2231 : 0 : qinfo->conf.tx_thresh.hthresh = txq->hthresh;
2232 : 0 : qinfo->conf.tx_thresh.wthresh = txq->wthresh;
2233 : 0 : qinfo->conf.offloads = txq->offloads;
2234 : 0 : }
2235 : :
2236 : : void
2237 : 0 : eth_igc_vlan_strip_queue_set(struct rte_eth_dev *dev,
2238 : : uint16_t rx_queue_id, int on)
2239 : : {
2240 : 0 : struct e1000_hw *hw = IGC_DEV_PRIVATE_HW(dev);
2241 : 0 : struct igc_rx_queue *rxq = dev->data->rx_queues[rx_queue_id];
2242 : : uint32_t reg_val;
2243 : :
2244 [ # # ]: 0 : if (rx_queue_id >= IGC_QUEUE_PAIRS_NUM) {
2245 : 0 : PMD_DRV_LOG(ERR, "Queue index(%u) illegal, max is %u",
2246 : : rx_queue_id, IGC_QUEUE_PAIRS_NUM - 1);
2247 : 0 : return;
2248 : : }
2249 : :
2250 : 0 : reg_val = E1000_READ_REG(hw, E1000_DVMOLR(rx_queue_id));
2251 [ # # ]: 0 : if (on) {
2252 : 0 : reg_val |= E1000_DVMOLR_STRVLAN;
2253 : 0 : rxq->offloads |= RTE_ETH_RX_OFFLOAD_VLAN_STRIP;
2254 : : } else {
2255 : 0 : reg_val &= ~(E1000_DVMOLR_STRVLAN | E1000_DVMOLR_HIDVLAN);
2256 : 0 : rxq->offloads &= ~RTE_ETH_RX_OFFLOAD_VLAN_STRIP;
2257 : : }
2258 : :
2259 : 0 : E1000_WRITE_REG(hw, E1000_DVMOLR(rx_queue_id), reg_val);
2260 : : }
|