1 /* SPDX-License-Identifier: BSD-3-Clause
3 * Copyright (c) 2016-2018 Solarflare Communications Inc.
6 * This software was jointly developed between OKTET Labs (under contract
7 * for Solarflare) and Solarflare Communications, Inc.
10 #include <rte_mempool.h>
15 #include "sfc_debug.h"
19 #include "sfc_kvargs.h"
20 #include "sfc_tweak.h"
23 * Maximum number of Rx queue flush attempt in the case of failure or
26 #define SFC_RX_QFLUSH_ATTEMPTS (3)
29 * Time to wait between event queue polling attempts when waiting for Rx
30 * queue flush done or failed events.
32 #define SFC_RX_QFLUSH_POLL_WAIT_MS (1)
35 * Maximum number of event queue polling attempts when waiting for Rx queue
36 * flush done or failed events. It defines Rx queue flush attempt timeout
37 * together with SFC_RX_QFLUSH_POLL_WAIT_MS.
39 #define SFC_RX_QFLUSH_POLL_ATTEMPTS (2000)
42 sfc_rx_qflush_done(struct sfc_rxq *rxq)
44 rxq->state |= SFC_RXQ_FLUSHED;
45 rxq->state &= ~SFC_RXQ_FLUSHING;
49 sfc_rx_qflush_failed(struct sfc_rxq *rxq)
51 rxq->state |= SFC_RXQ_FLUSH_FAILED;
52 rxq->state &= ~SFC_RXQ_FLUSHING;
56 sfc_efx_rx_qrefill(struct sfc_efx_rxq *rxq)
58 unsigned int free_space;
60 void *objs[SFC_RX_REFILL_BULK];
61 efsys_dma_addr_t addr[RTE_DIM(objs)];
62 unsigned int added = rxq->added;
65 struct sfc_efx_rx_sw_desc *rxd;
67 uint16_t port_id = rxq->dp.dpq.port_id;
69 free_space = rxq->max_fill_level - (added - rxq->completed);
71 if (free_space < rxq->refill_threshold)
74 bulks = free_space / RTE_DIM(objs);
75 /* refill_threshold guarantees that bulks is positive */
76 SFC_ASSERT(bulks > 0);
78 id = added & rxq->ptr_mask;
80 if (unlikely(rte_mempool_get_bulk(rxq->refill_mb_pool, objs,
81 RTE_DIM(objs)) < 0)) {
83 * It is hardly a safe way to increment counter
84 * from different contexts, but all PMDs do it.
86 rxq->evq->sa->eth_dev->data->rx_mbuf_alloc_failed +=
88 /* Return if we have posted nothing yet */
89 if (added == rxq->added)
95 for (i = 0; i < RTE_DIM(objs);
96 ++i, id = (id + 1) & rxq->ptr_mask) {
99 rxd = &rxq->sw_desc[id];
102 SFC_ASSERT(rte_mbuf_refcnt_read(m) == 1);
103 m->data_off = RTE_PKTMBUF_HEADROOM;
104 SFC_ASSERT(m->next == NULL);
105 SFC_ASSERT(m->nb_segs == 1);
108 addr[i] = rte_pktmbuf_iova(m);
111 efx_rx_qpost(rxq->common, addr, rxq->buf_size,
112 RTE_DIM(objs), rxq->completed, added);
113 added += RTE_DIM(objs);
114 } while (--bulks > 0);
116 SFC_ASSERT(added != rxq->added);
118 efx_rx_qpush(rxq->common, added, &rxq->pushed);
122 sfc_efx_rx_desc_flags_to_offload_flags(const unsigned int desc_flags)
124 uint64_t mbuf_flags = 0;
126 switch (desc_flags & (EFX_PKT_IPV4 | EFX_CKSUM_IPV4)) {
127 case (EFX_PKT_IPV4 | EFX_CKSUM_IPV4):
128 mbuf_flags |= PKT_RX_IP_CKSUM_GOOD;
131 mbuf_flags |= PKT_RX_IP_CKSUM_BAD;
134 RTE_BUILD_BUG_ON(PKT_RX_IP_CKSUM_UNKNOWN != 0);
135 SFC_ASSERT((mbuf_flags & PKT_RX_IP_CKSUM_MASK) ==
136 PKT_RX_IP_CKSUM_UNKNOWN);
140 switch ((desc_flags &
141 (EFX_PKT_TCP | EFX_PKT_UDP | EFX_CKSUM_TCPUDP))) {
142 case (EFX_PKT_TCP | EFX_CKSUM_TCPUDP):
143 case (EFX_PKT_UDP | EFX_CKSUM_TCPUDP):
144 mbuf_flags |= PKT_RX_L4_CKSUM_GOOD;
148 mbuf_flags |= PKT_RX_L4_CKSUM_BAD;
151 RTE_BUILD_BUG_ON(PKT_RX_L4_CKSUM_UNKNOWN != 0);
152 SFC_ASSERT((mbuf_flags & PKT_RX_L4_CKSUM_MASK) ==
153 PKT_RX_L4_CKSUM_UNKNOWN);
161 sfc_efx_rx_desc_flags_to_packet_type(const unsigned int desc_flags)
163 return RTE_PTYPE_L2_ETHER |
164 ((desc_flags & EFX_PKT_IPV4) ?
165 RTE_PTYPE_L3_IPV4_EXT_UNKNOWN : 0) |
166 ((desc_flags & EFX_PKT_IPV6) ?
167 RTE_PTYPE_L3_IPV6_EXT_UNKNOWN : 0) |
168 ((desc_flags & EFX_PKT_TCP) ? RTE_PTYPE_L4_TCP : 0) |
169 ((desc_flags & EFX_PKT_UDP) ? RTE_PTYPE_L4_UDP : 0);
172 static const uint32_t *
173 sfc_efx_supported_ptypes_get(__rte_unused uint32_t tunnel_encaps)
175 static const uint32_t ptypes[] = {
177 RTE_PTYPE_L3_IPV4_EXT_UNKNOWN,
178 RTE_PTYPE_L3_IPV6_EXT_UNKNOWN,
188 sfc_efx_rx_set_rss_hash(struct sfc_efx_rxq *rxq, unsigned int flags,
194 if ((rxq->flags & SFC_EFX_RXQ_FLAG_RSS_HASH) == 0)
197 mbuf_data = rte_pktmbuf_mtod(m, uint8_t *);
199 if (flags & (EFX_PKT_IPV4 | EFX_PKT_IPV6)) {
200 m->hash.rss = efx_pseudo_hdr_hash_get(rxq->common,
201 EFX_RX_HASHALG_TOEPLITZ,
204 m->ol_flags |= PKT_RX_RSS_HASH;
209 sfc_efx_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
211 struct sfc_dp_rxq *dp_rxq = rx_queue;
212 struct sfc_efx_rxq *rxq = sfc_efx_rxq_by_dp_rxq(dp_rxq);
213 unsigned int completed;
214 unsigned int prefix_size = rxq->prefix_size;
215 unsigned int done_pkts = 0;
216 boolean_t discard_next = B_FALSE;
217 struct rte_mbuf *scatter_pkt = NULL;
219 if (unlikely((rxq->flags & SFC_EFX_RXQ_FLAG_RUNNING) == 0))
222 sfc_ev_qpoll(rxq->evq);
224 completed = rxq->completed;
225 while (completed != rxq->pending && done_pkts < nb_pkts) {
227 struct sfc_efx_rx_sw_desc *rxd;
229 unsigned int seg_len;
230 unsigned int desc_flags;
232 id = completed++ & rxq->ptr_mask;
233 rxd = &rxq->sw_desc[id];
235 desc_flags = rxd->flags;
240 if (desc_flags & (EFX_ADDR_MISMATCH | EFX_DISCARD))
243 if (desc_flags & EFX_PKT_PREFIX_LEN) {
247 rc = efx_pseudo_hdr_pkt_length_get(rxq->common,
248 rte_pktmbuf_mtod(m, uint8_t *), &tmp_size);
252 seg_len = rxd->size - prefix_size;
255 rte_pktmbuf_data_len(m) = seg_len;
256 rte_pktmbuf_pkt_len(m) = seg_len;
258 if (scatter_pkt != NULL) {
259 if (rte_pktmbuf_chain(scatter_pkt, m) != 0) {
260 rte_pktmbuf_free(scatter_pkt);
263 /* The packet to deliver */
267 if (desc_flags & EFX_PKT_CONT) {
268 /* The packet is scattered, more fragments to come */
270 /* Further fragments have no prefix */
275 /* Scattered packet is done */
277 /* The first fragment of the packet has prefix */
278 prefix_size = rxq->prefix_size;
281 sfc_efx_rx_desc_flags_to_offload_flags(desc_flags);
283 sfc_efx_rx_desc_flags_to_packet_type(desc_flags);
286 * Extract RSS hash from the packet prefix and
287 * set the corresponding field (if needed and possible)
289 sfc_efx_rx_set_rss_hash(rxq, desc_flags, m);
291 m->data_off += prefix_size;
298 discard_next = ((desc_flags & EFX_PKT_CONT) != 0);
299 rte_mempool_put(rxq->refill_mb_pool, m);
303 /* pending is only moved when entire packet is received */
304 SFC_ASSERT(scatter_pkt == NULL);
306 rxq->completed = completed;
308 sfc_efx_rx_qrefill(rxq);
313 static sfc_dp_rx_qdesc_npending_t sfc_efx_rx_qdesc_npending;
315 sfc_efx_rx_qdesc_npending(struct sfc_dp_rxq *dp_rxq)
317 struct sfc_efx_rxq *rxq = sfc_efx_rxq_by_dp_rxq(dp_rxq);
319 if ((rxq->flags & SFC_EFX_RXQ_FLAG_RUNNING) == 0)
322 sfc_ev_qpoll(rxq->evq);
324 return rxq->pending - rxq->completed;
327 static sfc_dp_rx_qdesc_status_t sfc_efx_rx_qdesc_status;
329 sfc_efx_rx_qdesc_status(struct sfc_dp_rxq *dp_rxq, uint16_t offset)
331 struct sfc_efx_rxq *rxq = sfc_efx_rxq_by_dp_rxq(dp_rxq);
333 if (unlikely(offset > rxq->ptr_mask))
337 * Poll EvQ to derive up-to-date 'rxq->pending' figure;
338 * it is required for the queue to be running, but the
339 * check is omitted because API design assumes that it
340 * is the duty of the caller to satisfy all conditions
342 SFC_ASSERT((rxq->flags & SFC_EFX_RXQ_FLAG_RUNNING) ==
343 SFC_EFX_RXQ_FLAG_RUNNING);
344 sfc_ev_qpoll(rxq->evq);
347 * There is a handful of reserved entries in the ring,
348 * but an explicit check whether the offset points to
349 * a reserved entry is neglected since the two checks
350 * below rely on the figures which take the HW limits
351 * into account and thus if an entry is reserved, the
352 * checks will fail and UNAVAIL code will be returned
355 if (offset < (rxq->pending - rxq->completed))
356 return RTE_ETH_RX_DESC_DONE;
358 if (offset < (rxq->added - rxq->completed))
359 return RTE_ETH_RX_DESC_AVAIL;
361 return RTE_ETH_RX_DESC_UNAVAIL;
365 sfc_rxq_by_dp_rxq(const struct sfc_dp_rxq *dp_rxq)
367 const struct sfc_dp_queue *dpq = &dp_rxq->dpq;
368 struct rte_eth_dev *eth_dev;
369 struct sfc_adapter *sa;
372 SFC_ASSERT(rte_eth_dev_is_valid_port(dpq->port_id));
373 eth_dev = &rte_eth_devices[dpq->port_id];
375 sa = eth_dev->data->dev_private;
377 SFC_ASSERT(dpq->queue_id < sa->rxq_count);
378 rxq = sa->rxq_info[dpq->queue_id].rxq;
380 SFC_ASSERT(rxq != NULL);
384 static sfc_dp_rx_qsize_up_rings_t sfc_efx_rx_qsize_up_rings;
386 sfc_efx_rx_qsize_up_rings(uint16_t nb_rx_desc,
387 __rte_unused struct rte_mempool *mb_pool,
388 unsigned int *rxq_entries,
389 unsigned int *evq_entries,
390 unsigned int *rxq_max_fill_level)
392 *rxq_entries = nb_rx_desc;
393 *evq_entries = nb_rx_desc;
394 *rxq_max_fill_level = EFX_RXQ_LIMIT(*rxq_entries);
398 static sfc_dp_rx_qcreate_t sfc_efx_rx_qcreate;
400 sfc_efx_rx_qcreate(uint16_t port_id, uint16_t queue_id,
401 const struct rte_pci_addr *pci_addr, int socket_id,
402 const struct sfc_dp_rx_qcreate_info *info,
403 struct sfc_dp_rxq **dp_rxqp)
405 struct sfc_efx_rxq *rxq;
409 rxq = rte_zmalloc_socket("sfc-efx-rxq", sizeof(*rxq),
410 RTE_CACHE_LINE_SIZE, socket_id);
414 sfc_dp_queue_init(&rxq->dp.dpq, port_id, queue_id, pci_addr);
417 rxq->sw_desc = rte_calloc_socket("sfc-efx-rxq-sw_desc",
419 sizeof(*rxq->sw_desc),
420 RTE_CACHE_LINE_SIZE, socket_id);
421 if (rxq->sw_desc == NULL)
422 goto fail_desc_alloc;
424 /* efx datapath is bound to efx control path */
425 rxq->evq = sfc_rxq_by_dp_rxq(&rxq->dp)->evq;
426 if (info->flags & SFC_RXQ_FLAG_RSS_HASH)
427 rxq->flags |= SFC_EFX_RXQ_FLAG_RSS_HASH;
428 rxq->ptr_mask = info->rxq_entries - 1;
429 rxq->batch_max = info->batch_max;
430 rxq->prefix_size = info->prefix_size;
431 rxq->max_fill_level = info->max_fill_level;
432 rxq->refill_threshold = info->refill_threshold;
433 rxq->buf_size = info->buf_size;
434 rxq->refill_mb_pool = info->refill_mb_pool;
446 static sfc_dp_rx_qdestroy_t sfc_efx_rx_qdestroy;
448 sfc_efx_rx_qdestroy(struct sfc_dp_rxq *dp_rxq)
450 struct sfc_efx_rxq *rxq = sfc_efx_rxq_by_dp_rxq(dp_rxq);
452 rte_free(rxq->sw_desc);
456 static sfc_dp_rx_qstart_t sfc_efx_rx_qstart;
458 sfc_efx_rx_qstart(struct sfc_dp_rxq *dp_rxq,
459 __rte_unused unsigned int evq_read_ptr)
461 /* libefx-based datapath is specific to libefx-based PMD */
462 struct sfc_efx_rxq *rxq = sfc_efx_rxq_by_dp_rxq(dp_rxq);
463 struct sfc_rxq *crxq = sfc_rxq_by_dp_rxq(dp_rxq);
465 rxq->common = crxq->common;
467 rxq->pending = rxq->completed = rxq->added = rxq->pushed = 0;
469 sfc_efx_rx_qrefill(rxq);
471 rxq->flags |= (SFC_EFX_RXQ_FLAG_STARTED | SFC_EFX_RXQ_FLAG_RUNNING);
476 static sfc_dp_rx_qstop_t sfc_efx_rx_qstop;
478 sfc_efx_rx_qstop(struct sfc_dp_rxq *dp_rxq,
479 __rte_unused unsigned int *evq_read_ptr)
481 struct sfc_efx_rxq *rxq = sfc_efx_rxq_by_dp_rxq(dp_rxq);
483 rxq->flags &= ~SFC_EFX_RXQ_FLAG_RUNNING;
485 /* libefx-based datapath is bound to libefx-based PMD and uses
486 * event queue structure directly. So, there is no necessity to
487 * return EvQ read pointer.
491 static sfc_dp_rx_qpurge_t sfc_efx_rx_qpurge;
493 sfc_efx_rx_qpurge(struct sfc_dp_rxq *dp_rxq)
495 struct sfc_efx_rxq *rxq = sfc_efx_rxq_by_dp_rxq(dp_rxq);
497 struct sfc_efx_rx_sw_desc *rxd;
499 for (i = rxq->completed; i != rxq->added; ++i) {
500 rxd = &rxq->sw_desc[i & rxq->ptr_mask];
501 rte_mempool_put(rxq->refill_mb_pool, rxd->mbuf);
503 /* Packed stream relies on 0 in inactive SW desc.
504 * Rx queue stop is not performance critical, so
505 * there is no harm to do it always.
511 rxq->flags &= ~SFC_EFX_RXQ_FLAG_STARTED;
514 struct sfc_dp_rx sfc_efx_rx = {
516 .name = SFC_KVARG_DATAPATH_EFX,
520 .features = SFC_DP_RX_FEAT_SCATTER |
521 SFC_DP_RX_FEAT_CHECKSUM,
522 .qsize_up_rings = sfc_efx_rx_qsize_up_rings,
523 .qcreate = sfc_efx_rx_qcreate,
524 .qdestroy = sfc_efx_rx_qdestroy,
525 .qstart = sfc_efx_rx_qstart,
526 .qstop = sfc_efx_rx_qstop,
527 .qpurge = sfc_efx_rx_qpurge,
528 .supported_ptypes_get = sfc_efx_supported_ptypes_get,
529 .qdesc_npending = sfc_efx_rx_qdesc_npending,
530 .qdesc_status = sfc_efx_rx_qdesc_status,
531 .pkt_burst = sfc_efx_recv_pkts,
535 sfc_rx_qdesc_npending(struct sfc_adapter *sa, unsigned int sw_index)
539 SFC_ASSERT(sw_index < sa->rxq_count);
540 rxq = sa->rxq_info[sw_index].rxq;
542 if (rxq == NULL || (rxq->state & SFC_RXQ_STARTED) == 0)
545 return sa->dp_rx->qdesc_npending(rxq->dp);
549 sfc_rx_qdesc_done(struct sfc_dp_rxq *dp_rxq, unsigned int offset)
551 struct sfc_rxq *rxq = sfc_rxq_by_dp_rxq(dp_rxq);
553 return offset < rxq->evq->sa->dp_rx->qdesc_npending(dp_rxq);
557 sfc_rx_qflush(struct sfc_adapter *sa, unsigned int sw_index)
560 unsigned int retry_count;
561 unsigned int wait_count;
564 rxq = sa->rxq_info[sw_index].rxq;
565 SFC_ASSERT(rxq->state & SFC_RXQ_STARTED);
568 * Retry Rx queue flushing in the case of flush failed or
569 * timeout. In the worst case it can delay for 6 seconds.
571 for (retry_count = 0;
572 ((rxq->state & SFC_RXQ_FLUSHED) == 0) &&
573 (retry_count < SFC_RX_QFLUSH_ATTEMPTS);
575 rc = efx_rx_qflush(rxq->common);
577 rxq->state |= (rc == EALREADY) ?
578 SFC_RXQ_FLUSHED : SFC_RXQ_FLUSH_FAILED;
581 rxq->state &= ~SFC_RXQ_FLUSH_FAILED;
582 rxq->state |= SFC_RXQ_FLUSHING;
585 * Wait for Rx queue flush done or failed event at least
586 * SFC_RX_QFLUSH_POLL_WAIT_MS milliseconds and not more
587 * than 2 seconds (SFC_RX_QFLUSH_POLL_WAIT_MS multiplied
588 * by SFC_RX_QFLUSH_POLL_ATTEMPTS).
592 rte_delay_ms(SFC_RX_QFLUSH_POLL_WAIT_MS);
593 sfc_ev_qpoll(rxq->evq);
594 } while ((rxq->state & SFC_RXQ_FLUSHING) &&
595 (wait_count++ < SFC_RX_QFLUSH_POLL_ATTEMPTS));
597 if (rxq->state & SFC_RXQ_FLUSHING)
598 sfc_err(sa, "RxQ %u flush timed out", sw_index);
600 if (rxq->state & SFC_RXQ_FLUSH_FAILED)
601 sfc_err(sa, "RxQ %u flush failed", sw_index);
603 if (rxq->state & SFC_RXQ_FLUSHED)
604 sfc_notice(sa, "RxQ %u flushed", sw_index);
607 sa->dp_rx->qpurge(rxq->dp);
611 sfc_rx_default_rxq_set_filter(struct sfc_adapter *sa, struct sfc_rxq *rxq)
613 struct sfc_rss *rss = &sa->rss;
614 boolean_t need_rss = (rss->channels > 0) ? B_TRUE : B_FALSE;
615 struct sfc_port *port = &sa->port;
619 * If promiscuous or all-multicast mode has been requested, setting
620 * filter for the default Rx queue might fail, in particular, while
621 * running over PCI function which is not a member of corresponding
622 * privilege groups; if this occurs, few iterations will be made to
623 * repeat this step without promiscuous and all-multicast flags set
626 rc = efx_mac_filter_default_rxq_set(sa->nic, rxq->common, need_rss);
629 else if (rc != EOPNOTSUPP)
633 sfc_warn(sa, "promiscuous mode has been requested, "
634 "but the HW rejects it");
635 sfc_warn(sa, "promiscuous mode will be disabled");
637 port->promisc = B_FALSE;
638 rc = sfc_set_rx_mode(sa);
645 if (port->allmulti) {
646 sfc_warn(sa, "all-multicast mode has been requested, "
647 "but the HW rejects it");
648 sfc_warn(sa, "all-multicast mode will be disabled");
650 port->allmulti = B_FALSE;
651 rc = sfc_set_rx_mode(sa);
662 sfc_rx_qstart(struct sfc_adapter *sa, unsigned int sw_index)
664 struct sfc_port *port = &sa->port;
665 struct sfc_rxq_info *rxq_info;
670 sfc_log_init(sa, "sw_index=%u", sw_index);
672 SFC_ASSERT(sw_index < sa->rxq_count);
674 rxq_info = &sa->rxq_info[sw_index];
676 SFC_ASSERT(rxq != NULL);
677 SFC_ASSERT(rxq->state == SFC_RXQ_INITIALIZED);
681 rc = sfc_ev_qstart(evq, sfc_evq_index_by_rxq_sw_index(sa, sw_index));
685 switch (rxq_info->type) {
686 case EFX_RXQ_TYPE_DEFAULT:
687 rc = efx_rx_qcreate(sa->nic, rxq->hw_index, 0, rxq_info->type,
688 &rxq->mem, rxq_info->entries, 0 /* not used on EF10 */,
689 rxq_info->type_flags, evq->common, &rxq->common);
691 case EFX_RXQ_TYPE_ES_SUPER_BUFFER: {
692 struct rte_mempool *mp = rxq->refill_mb_pool;
693 struct rte_mempool_info mp_info;
695 rc = rte_mempool_ops_get_info(mp, &mp_info);
697 /* Positive errno is used in the driver */
699 goto fail_mp_get_info;
701 if (mp_info.contig_block_size <= 0) {
703 goto fail_bad_contig_block_size;
705 rc = efx_rx_qcreate_es_super_buffer(sa->nic, rxq->hw_index, 0,
706 mp_info.contig_block_size, rxq->buf_size,
707 mp->header_size + mp->elt_size + mp->trailer_size,
708 sa->rxd_wait_timeout_ns,
709 &rxq->mem, rxq_info->entries, rxq_info->type_flags,
710 evq->common, &rxq->common);
717 goto fail_rx_qcreate;
719 efx_rx_qenable(rxq->common);
721 rc = sa->dp_rx->qstart(rxq->dp, evq->read_ptr);
725 rxq->state |= SFC_RXQ_STARTED;
727 if ((sw_index == 0) && !port->isolated) {
728 rc = sfc_rx_default_rxq_set_filter(sa, rxq);
730 goto fail_mac_filter_default_rxq_set;
733 /* It seems to be used by DPDK for debug purposes only ('rte_ether') */
734 sa->eth_dev->data->rx_queue_state[sw_index] =
735 RTE_ETH_QUEUE_STATE_STARTED;
739 fail_mac_filter_default_rxq_set:
740 sa->dp_rx->qstop(rxq->dp, &rxq->evq->read_ptr);
743 sfc_rx_qflush(sa, sw_index);
746 fail_bad_contig_block_size:
755 sfc_rx_qstop(struct sfc_adapter *sa, unsigned int sw_index)
757 struct sfc_rxq_info *rxq_info;
760 sfc_log_init(sa, "sw_index=%u", sw_index);
762 SFC_ASSERT(sw_index < sa->rxq_count);
764 rxq_info = &sa->rxq_info[sw_index];
767 if (rxq == NULL || rxq->state == SFC_RXQ_INITIALIZED)
769 SFC_ASSERT(rxq->state & SFC_RXQ_STARTED);
771 /* It seems to be used by DPDK for debug purposes only ('rte_ether') */
772 sa->eth_dev->data->rx_queue_state[sw_index] =
773 RTE_ETH_QUEUE_STATE_STOPPED;
775 sa->dp_rx->qstop(rxq->dp, &rxq->evq->read_ptr);
778 efx_mac_filter_default_rxq_clear(sa->nic);
780 sfc_rx_qflush(sa, sw_index);
782 rxq->state = SFC_RXQ_INITIALIZED;
784 efx_rx_qdestroy(rxq->common);
786 sfc_ev_qstop(rxq->evq);
790 sfc_rx_get_dev_offload_caps(struct sfc_adapter *sa)
792 const efx_nic_cfg_t *encp = efx_nic_cfg_get(sa->nic);
795 caps |= DEV_RX_OFFLOAD_JUMBO_FRAME;
797 if (sa->dp_rx->features & SFC_DP_RX_FEAT_CHECKSUM) {
798 caps |= DEV_RX_OFFLOAD_IPV4_CKSUM;
799 caps |= DEV_RX_OFFLOAD_UDP_CKSUM;
800 caps |= DEV_RX_OFFLOAD_TCP_CKSUM;
803 if (encp->enc_tunnel_encapsulations_supported &&
804 (sa->dp_rx->features & SFC_DP_RX_FEAT_TUNNELS))
805 caps |= DEV_RX_OFFLOAD_OUTER_IPV4_CKSUM;
811 sfc_rx_get_queue_offload_caps(struct sfc_adapter *sa)
815 if (sa->dp_rx->features & SFC_DP_RX_FEAT_SCATTER)
816 caps |= DEV_RX_OFFLOAD_SCATTER;
822 sfc_rx_qcheck_conf(struct sfc_adapter *sa, unsigned int rxq_max_fill_level,
823 const struct rte_eth_rxconf *rx_conf,
824 __rte_unused uint64_t offloads)
828 if (rx_conf->rx_thresh.pthresh != 0 ||
829 rx_conf->rx_thresh.hthresh != 0 ||
830 rx_conf->rx_thresh.wthresh != 0) {
832 "RxQ prefetch/host/writeback thresholds are not supported");
835 if (rx_conf->rx_free_thresh > rxq_max_fill_level) {
837 "RxQ free threshold too large: %u vs maximum %u",
838 rx_conf->rx_free_thresh, rxq_max_fill_level);
842 if (rx_conf->rx_drop_en == 0) {
843 sfc_err(sa, "RxQ drop disable is not supported");
851 sfc_rx_mbuf_data_alignment(struct rte_mempool *mb_pool)
856 /* The mbuf object itself is always cache line aligned */
857 order = rte_bsf32(RTE_CACHE_LINE_SIZE);
859 /* Data offset from mbuf object start */
860 data_off = sizeof(struct rte_mbuf) + rte_pktmbuf_priv_size(mb_pool) +
861 RTE_PKTMBUF_HEADROOM;
863 order = MIN(order, rte_bsf32(data_off));
869 sfc_rx_mb_pool_buf_size(struct sfc_adapter *sa, struct rte_mempool *mb_pool)
871 const efx_nic_cfg_t *encp = efx_nic_cfg_get(sa->nic);
872 const uint32_t nic_align_start = MAX(1, encp->enc_rx_buf_align_start);
873 const uint32_t nic_align_end = MAX(1, encp->enc_rx_buf_align_end);
875 unsigned int buf_aligned;
876 unsigned int start_alignment;
877 unsigned int end_padding_alignment;
879 /* Below it is assumed that both alignments are power of 2 */
880 SFC_ASSERT(rte_is_power_of_2(nic_align_start));
881 SFC_ASSERT(rte_is_power_of_2(nic_align_end));
884 * mbuf is always cache line aligned, double-check
885 * that it meets rx buffer start alignment requirements.
888 /* Start from mbuf pool data room size */
889 buf_size = rte_pktmbuf_data_room_size(mb_pool);
891 /* Remove headroom */
892 if (buf_size <= RTE_PKTMBUF_HEADROOM) {
894 "RxQ mbuf pool %s object data room size %u is smaller than headroom %u",
895 mb_pool->name, buf_size, RTE_PKTMBUF_HEADROOM);
898 buf_size -= RTE_PKTMBUF_HEADROOM;
900 /* Calculate guaranteed data start alignment */
901 buf_aligned = sfc_rx_mbuf_data_alignment(mb_pool);
903 /* Reserve space for start alignment */
904 if (buf_aligned < nic_align_start) {
905 start_alignment = nic_align_start - buf_aligned;
906 if (buf_size <= start_alignment) {
908 "RxQ mbuf pool %s object data room size %u is insufficient for headroom %u and buffer start alignment %u required by NIC",
910 rte_pktmbuf_data_room_size(mb_pool),
911 RTE_PKTMBUF_HEADROOM, start_alignment);
914 buf_aligned = nic_align_start;
915 buf_size -= start_alignment;
920 /* Make sure that end padding does not write beyond the buffer */
921 if (buf_aligned < nic_align_end) {
923 * Estimate space which can be lost. If guarnteed buffer
924 * size is odd, lost space is (nic_align_end - 1). More
925 * accurate formula is below.
927 end_padding_alignment = nic_align_end -
928 MIN(buf_aligned, 1u << (rte_bsf32(buf_size) - 1));
929 if (buf_size <= end_padding_alignment) {
931 "RxQ mbuf pool %s object data room size %u is insufficient for headroom %u, buffer start alignment %u and end padding alignment %u required by NIC",
933 rte_pktmbuf_data_room_size(mb_pool),
934 RTE_PKTMBUF_HEADROOM, start_alignment,
935 end_padding_alignment);
938 buf_size -= end_padding_alignment;
941 * Start is aligned the same or better than end,
944 buf_size = P2ALIGN(buf_size, nic_align_end);
951 sfc_rx_qinit(struct sfc_adapter *sa, unsigned int sw_index,
952 uint16_t nb_rx_desc, unsigned int socket_id,
953 const struct rte_eth_rxconf *rx_conf,
954 struct rte_mempool *mb_pool)
956 const efx_nic_cfg_t *encp = efx_nic_cfg_get(sa->nic);
957 struct sfc_rss *rss = &sa->rss;
959 unsigned int rxq_entries;
960 unsigned int evq_entries;
961 unsigned int rxq_max_fill_level;
964 struct sfc_rxq_info *rxq_info;
967 struct sfc_dp_rx_qcreate_info info;
969 rc = sa->dp_rx->qsize_up_rings(nb_rx_desc, mb_pool, &rxq_entries,
970 &evq_entries, &rxq_max_fill_level);
972 goto fail_size_up_rings;
973 SFC_ASSERT(rxq_entries >= EFX_RXQ_MINNDESCS);
974 SFC_ASSERT(rxq_entries <= EFX_RXQ_MAXNDESCS);
975 SFC_ASSERT(rxq_max_fill_level <= nb_rx_desc);
977 offloads = rx_conf->offloads |
978 sa->eth_dev->data->dev_conf.rxmode.offloads;
979 rc = sfc_rx_qcheck_conf(sa, rxq_max_fill_level, rx_conf, offloads);
983 buf_size = sfc_rx_mb_pool_buf_size(sa, mb_pool);
985 sfc_err(sa, "RxQ %u mbuf pool object size is too small",
991 if ((buf_size < sa->port.pdu + encp->enc_rx_prefix_size) &&
992 (~offloads & DEV_RX_OFFLOAD_SCATTER)) {
993 sfc_err(sa, "Rx scatter is disabled and RxQ %u mbuf pool "
994 "object size is too small", sw_index);
995 sfc_err(sa, "RxQ %u calculated Rx buffer size is %u vs "
996 "PDU size %u plus Rx prefix %u bytes",
997 sw_index, buf_size, (unsigned int)sa->port.pdu,
998 encp->enc_rx_prefix_size);
1003 SFC_ASSERT(sw_index < sa->rxq_count);
1004 rxq_info = &sa->rxq_info[sw_index];
1006 SFC_ASSERT(rxq_entries <= rxq_info->max_entries);
1007 rxq_info->entries = rxq_entries;
1009 if (sa->dp_rx->dp.hw_fw_caps & SFC_DP_HW_FW_CAP_RX_ES_SUPER_BUFFER)
1010 rxq_info->type = EFX_RXQ_TYPE_ES_SUPER_BUFFER;
1012 rxq_info->type = EFX_RXQ_TYPE_DEFAULT;
1014 rxq_info->type_flags =
1015 (offloads & DEV_RX_OFFLOAD_SCATTER) ?
1016 EFX_RXQ_FLAG_SCATTER : EFX_RXQ_FLAG_NONE;
1018 if ((encp->enc_tunnel_encapsulations_supported != 0) &&
1019 (sa->dp_rx->features & SFC_DP_RX_FEAT_TUNNELS))
1020 rxq_info->type_flags |= EFX_RXQ_FLAG_INNER_CLASSES;
1022 rc = sfc_ev_qinit(sa, SFC_EVQ_TYPE_RX, sw_index,
1023 evq_entries, socket_id, &evq);
1028 rxq = rte_zmalloc_socket("sfc-rxq", sizeof(*rxq), RTE_CACHE_LINE_SIZE,
1031 goto fail_rxq_alloc;
1033 rxq_info->rxq = rxq;
1036 rxq->hw_index = sw_index;
1037 rxq->refill_threshold =
1038 RTE_MAX(rx_conf->rx_free_thresh, SFC_RX_REFILL_BULK);
1039 rxq->refill_mb_pool = mb_pool;
1040 rxq->buf_size = buf_size;
1042 rc = sfc_dma_alloc(sa, "rxq", sw_index, EFX_RXQ_SIZE(rxq_info->entries),
1043 socket_id, &rxq->mem);
1045 goto fail_dma_alloc;
1047 memset(&info, 0, sizeof(info));
1048 info.refill_mb_pool = rxq->refill_mb_pool;
1049 info.max_fill_level = rxq_max_fill_level;
1050 info.refill_threshold = rxq->refill_threshold;
1051 info.buf_size = buf_size;
1052 info.batch_max = encp->enc_rx_batch_max;
1053 info.prefix_size = encp->enc_rx_prefix_size;
1055 if (rss->hash_support == EFX_RX_HASH_AVAILABLE && rss->channels > 0)
1056 info.flags |= SFC_RXQ_FLAG_RSS_HASH;
1058 info.rxq_entries = rxq_info->entries;
1059 info.rxq_hw_ring = rxq->mem.esm_base;
1060 info.evq_entries = evq_entries;
1061 info.evq_hw_ring = evq->mem.esm_base;
1062 info.hw_index = rxq->hw_index;
1063 info.mem_bar = sa->mem_bar.esb_base;
1064 info.vi_window_shift = encp->enc_vi_window_shift;
1066 rc = sa->dp_rx->qcreate(sa->eth_dev->data->port_id, sw_index,
1067 &RTE_ETH_DEV_TO_PCI(sa->eth_dev)->addr,
1068 socket_id, &info, &rxq->dp);
1070 goto fail_dp_rx_qcreate;
1072 evq->dp_rxq = rxq->dp;
1074 rxq->state = SFC_RXQ_INITIALIZED;
1076 rxq_info->deferred_start = (rx_conf->rx_deferred_start != 0);
1081 sfc_dma_free(sa, &rxq->mem);
1084 rxq_info->rxq = NULL;
1091 rxq_info->entries = 0;
1095 sfc_log_init(sa, "failed %d", rc);
1100 sfc_rx_qfini(struct sfc_adapter *sa, unsigned int sw_index)
1102 struct sfc_rxq_info *rxq_info;
1103 struct sfc_rxq *rxq;
1105 SFC_ASSERT(sw_index < sa->rxq_count);
1107 rxq_info = &sa->rxq_info[sw_index];
1109 rxq = rxq_info->rxq;
1110 SFC_ASSERT(rxq->state == SFC_RXQ_INITIALIZED);
1112 sa->dp_rx->qdestroy(rxq->dp);
1115 rxq_info->rxq = NULL;
1116 rxq_info->entries = 0;
1118 sfc_dma_free(sa, &rxq->mem);
1120 sfc_ev_qfini(rxq->evq);
1127 * Mapping between RTE RSS hash functions and their EFX counterparts.
1129 struct sfc_rss_hf_rte_to_efx sfc_rss_hf_map[] = {
1130 { ETH_RSS_NONFRAG_IPV4_TCP,
1131 EFX_RX_HASH(IPV4_TCP, 4TUPLE) },
1132 { ETH_RSS_NONFRAG_IPV4_UDP,
1133 EFX_RX_HASH(IPV4_UDP, 4TUPLE) },
1134 { ETH_RSS_NONFRAG_IPV6_TCP | ETH_RSS_IPV6_TCP_EX,
1135 EFX_RX_HASH(IPV6_TCP, 4TUPLE) },
1136 { ETH_RSS_NONFRAG_IPV6_UDP | ETH_RSS_IPV6_UDP_EX,
1137 EFX_RX_HASH(IPV6_UDP, 4TUPLE) },
1138 { ETH_RSS_IPV4 | ETH_RSS_FRAG_IPV4 | ETH_RSS_NONFRAG_IPV4_OTHER,
1139 EFX_RX_HASH(IPV4_TCP, 2TUPLE) | EFX_RX_HASH(IPV4_UDP, 2TUPLE) |
1140 EFX_RX_HASH(IPV4, 2TUPLE) },
1141 { ETH_RSS_IPV6 | ETH_RSS_FRAG_IPV6 | ETH_RSS_NONFRAG_IPV6_OTHER |
1143 EFX_RX_HASH(IPV6_TCP, 2TUPLE) | EFX_RX_HASH(IPV6_UDP, 2TUPLE) |
1144 EFX_RX_HASH(IPV6, 2TUPLE) }
1147 static efx_rx_hash_type_t
1148 sfc_rx_hash_types_mask_supp(efx_rx_hash_type_t hash_type,
1149 unsigned int *hash_type_flags_supported,
1150 unsigned int nb_hash_type_flags_supported)
1152 efx_rx_hash_type_t hash_type_masked = 0;
1155 for (i = 0; i < nb_hash_type_flags_supported; ++i) {
1156 unsigned int class_tuple_lbn[] = {
1157 EFX_RX_CLASS_IPV4_TCP_LBN,
1158 EFX_RX_CLASS_IPV4_UDP_LBN,
1159 EFX_RX_CLASS_IPV4_LBN,
1160 EFX_RX_CLASS_IPV6_TCP_LBN,
1161 EFX_RX_CLASS_IPV6_UDP_LBN,
1162 EFX_RX_CLASS_IPV6_LBN
1165 for (j = 0; j < RTE_DIM(class_tuple_lbn); ++j) {
1166 unsigned int tuple_mask = EFX_RX_CLASS_HASH_4TUPLE;
1169 tuple_mask <<= class_tuple_lbn[j];
1170 flag = hash_type & tuple_mask;
1172 if (flag == hash_type_flags_supported[i])
1173 hash_type_masked |= flag;
1177 return hash_type_masked;
1181 sfc_rx_hash_init(struct sfc_adapter *sa)
1183 struct sfc_rss *rss = &sa->rss;
1184 const efx_nic_cfg_t *encp = efx_nic_cfg_get(sa->nic);
1185 uint32_t alg_mask = encp->enc_rx_scale_hash_alg_mask;
1186 efx_rx_hash_alg_t alg;
1187 unsigned int flags_supp[EFX_RX_HASH_NFLAGS];
1188 unsigned int nb_flags_supp;
1189 struct sfc_rss_hf_rte_to_efx *hf_map;
1190 struct sfc_rss_hf_rte_to_efx *entry;
1191 efx_rx_hash_type_t efx_hash_types;
1195 if (alg_mask & (1U << EFX_RX_HASHALG_TOEPLITZ))
1196 alg = EFX_RX_HASHALG_TOEPLITZ;
1197 else if (alg_mask & (1U << EFX_RX_HASHALG_PACKED_STREAM))
1198 alg = EFX_RX_HASHALG_PACKED_STREAM;
1202 rc = efx_rx_scale_hash_flags_get(sa->nic, alg, flags_supp,
1207 hf_map = rte_calloc_socket("sfc-rss-hf-map",
1208 RTE_DIM(sfc_rss_hf_map),
1209 sizeof(*hf_map), 0, sa->socket_id);
1215 for (i = 0; i < RTE_DIM(sfc_rss_hf_map); ++i) {
1216 efx_rx_hash_type_t ht;
1218 ht = sfc_rx_hash_types_mask_supp(sfc_rss_hf_map[i].efx,
1219 flags_supp, nb_flags_supp);
1221 entry->rte = sfc_rss_hf_map[i].rte;
1223 efx_hash_types |= ht;
1228 rss->hash_alg = alg;
1229 rss->hf_map_nb_entries = (unsigned int)(entry - hf_map);
1230 rss->hf_map = hf_map;
1231 rss->hash_types = efx_hash_types;
1237 sfc_rx_hash_fini(struct sfc_adapter *sa)
1239 struct sfc_rss *rss = &sa->rss;
1241 rte_free(rss->hf_map);
1245 sfc_rx_hf_rte_to_efx(struct sfc_adapter *sa, uint64_t rte,
1246 efx_rx_hash_type_t *efx)
1248 struct sfc_rss *rss = &sa->rss;
1249 efx_rx_hash_type_t hash_types = 0;
1252 for (i = 0; i < rss->hf_map_nb_entries; ++i) {
1253 uint64_t rte_mask = rss->hf_map[i].rte;
1255 if ((rte & rte_mask) != 0) {
1257 hash_types |= rss->hf_map[i].efx;
1262 sfc_err(sa, "unsupported hash functions requested");
1272 sfc_rx_hf_efx_to_rte(struct sfc_adapter *sa, efx_rx_hash_type_t efx)
1274 struct sfc_rss *rss = &sa->rss;
1278 for (i = 0; i < rss->hf_map_nb_entries; ++i) {
1279 efx_rx_hash_type_t hash_type = rss->hf_map[i].efx;
1281 if ((efx & hash_type) == hash_type)
1282 rte |= rss->hf_map[i].rte;
1289 sfc_rx_process_adv_conf_rss(struct sfc_adapter *sa,
1290 struct rte_eth_rss_conf *conf)
1292 struct sfc_rss *rss = &sa->rss;
1293 efx_rx_hash_type_t efx_hash_types = rss->hash_types;
1294 uint64_t rss_hf = sfc_rx_hf_efx_to_rte(sa, efx_hash_types);
1297 if (rss->context_type != EFX_RX_SCALE_EXCLUSIVE) {
1298 if ((conf->rss_hf != 0 && conf->rss_hf != rss_hf) ||
1299 conf->rss_key != NULL)
1303 if (conf->rss_hf != 0) {
1304 rc = sfc_rx_hf_rte_to_efx(sa, conf->rss_hf, &efx_hash_types);
1309 if (conf->rss_key != NULL) {
1310 if (conf->rss_key_len != sizeof(rss->key)) {
1311 sfc_err(sa, "RSS key size is wrong (should be %lu)",
1315 rte_memcpy(rss->key, conf->rss_key, sizeof(rss->key));
1318 rss->hash_types = efx_hash_types;
1324 sfc_rx_rss_config(struct sfc_adapter *sa)
1326 struct sfc_rss *rss = &sa->rss;
1329 if (rss->channels > 0) {
1330 rc = efx_rx_scale_mode_set(sa->nic, EFX_RSS_CONTEXT_DEFAULT,
1331 rss->hash_alg, rss->hash_types,
1336 rc = efx_rx_scale_key_set(sa->nic, EFX_RSS_CONTEXT_DEFAULT,
1337 rss->key, sizeof(rss->key));
1341 rc = efx_rx_scale_tbl_set(sa->nic, EFX_RSS_CONTEXT_DEFAULT,
1342 rss->tbl, RTE_DIM(rss->tbl));
1350 sfc_rx_start(struct sfc_adapter *sa)
1352 unsigned int sw_index;
1355 sfc_log_init(sa, "rxq_count=%u", sa->rxq_count);
1357 rc = efx_rx_init(sa->nic);
1361 rc = sfc_rx_rss_config(sa);
1363 goto fail_rss_config;
1365 for (sw_index = 0; sw_index < sa->rxq_count; ++sw_index) {
1366 if (sa->rxq_info[sw_index].rxq != NULL &&
1367 (!sa->rxq_info[sw_index].deferred_start ||
1368 sa->rxq_info[sw_index].deferred_started)) {
1369 rc = sfc_rx_qstart(sa, sw_index);
1371 goto fail_rx_qstart;
1378 while (sw_index-- > 0)
1379 sfc_rx_qstop(sa, sw_index);
1382 efx_rx_fini(sa->nic);
1385 sfc_log_init(sa, "failed %d", rc);
1390 sfc_rx_stop(struct sfc_adapter *sa)
1392 unsigned int sw_index;
1394 sfc_log_init(sa, "rxq_count=%u", sa->rxq_count);
1396 sw_index = sa->rxq_count;
1397 while (sw_index-- > 0) {
1398 if (sa->rxq_info[sw_index].rxq != NULL)
1399 sfc_rx_qstop(sa, sw_index);
1402 efx_rx_fini(sa->nic);
1406 sfc_rx_qinit_info(struct sfc_adapter *sa, unsigned int sw_index)
1408 struct sfc_rxq_info *rxq_info = &sa->rxq_info[sw_index];
1409 unsigned int max_entries;
1411 max_entries = EFX_RXQ_MAXNDESCS;
1412 SFC_ASSERT(rte_is_power_of_2(max_entries));
1414 rxq_info->max_entries = max_entries;
1420 sfc_rx_check_mode(struct sfc_adapter *sa, struct rte_eth_rxmode *rxmode)
1422 uint64_t offloads_supported = sfc_rx_get_dev_offload_caps(sa) |
1423 sfc_rx_get_queue_offload_caps(sa);
1424 struct sfc_rss *rss = &sa->rss;
1427 switch (rxmode->mq_mode) {
1428 case ETH_MQ_RX_NONE:
1429 /* No special checks are required */
1432 if (rss->context_type == EFX_RX_SCALE_UNAVAILABLE) {
1433 sfc_err(sa, "RSS is not available");
1438 sfc_err(sa, "Rx multi-queue mode %u not supported",
1444 * Requested offloads are validated against supported by ethdev,
1445 * so unsupported offloads cannot be added as the result of
1448 if ((rxmode->offloads & DEV_RX_OFFLOAD_CHECKSUM) !=
1449 (offloads_supported & DEV_RX_OFFLOAD_CHECKSUM)) {
1450 sfc_warn(sa, "Rx checksum offloads cannot be disabled - always on (IPv4/TCP/UDP)");
1451 rxmode->offloads |= DEV_RX_OFFLOAD_CHECKSUM;
1454 if ((offloads_supported & DEV_RX_OFFLOAD_OUTER_IPV4_CKSUM) &&
1455 (~rxmode->offloads & DEV_RX_OFFLOAD_OUTER_IPV4_CKSUM)) {
1456 sfc_warn(sa, "Rx outer IPv4 checksum offload cannot be disabled - always on");
1457 rxmode->offloads |= DEV_RX_OFFLOAD_OUTER_IPV4_CKSUM;
1464 * Destroy excess queues that are no longer needed after reconfiguration
1465 * or complete close.
1468 sfc_rx_fini_queues(struct sfc_adapter *sa, unsigned int nb_rx_queues)
1472 SFC_ASSERT(nb_rx_queues <= sa->rxq_count);
1474 sw_index = sa->rxq_count;
1475 while (--sw_index >= (int)nb_rx_queues) {
1476 if (sa->rxq_info[sw_index].rxq != NULL)
1477 sfc_rx_qfini(sa, sw_index);
1480 sa->rxq_count = nb_rx_queues;
1484 * Initialize Rx subsystem.
1486 * Called at device (re)configuration stage when number of receive queues is
1487 * specified together with other device level receive configuration.
1489 * It should be used to allocate NUMA-unaware resources.
1492 sfc_rx_configure(struct sfc_adapter *sa)
1494 struct sfc_rss *rss = &sa->rss;
1495 struct rte_eth_conf *dev_conf = &sa->eth_dev->data->dev_conf;
1496 const unsigned int nb_rx_queues = sa->eth_dev->data->nb_rx_queues;
1499 sfc_log_init(sa, "nb_rx_queues=%u (old %u)",
1500 nb_rx_queues, sa->rxq_count);
1502 rc = sfc_rx_check_mode(sa, &dev_conf->rxmode);
1504 goto fail_check_mode;
1506 if (nb_rx_queues == sa->rxq_count)
1509 if (sa->rxq_info == NULL) {
1511 sa->rxq_info = rte_calloc_socket("sfc-rxqs", nb_rx_queues,
1512 sizeof(sa->rxq_info[0]), 0,
1514 if (sa->rxq_info == NULL)
1515 goto fail_rxqs_alloc;
1517 struct sfc_rxq_info *new_rxq_info;
1519 if (nb_rx_queues < sa->rxq_count)
1520 sfc_rx_fini_queues(sa, nb_rx_queues);
1524 rte_realloc(sa->rxq_info,
1525 nb_rx_queues * sizeof(sa->rxq_info[0]), 0);
1526 if (new_rxq_info == NULL && nb_rx_queues > 0)
1527 goto fail_rxqs_realloc;
1529 sa->rxq_info = new_rxq_info;
1530 if (nb_rx_queues > sa->rxq_count)
1531 memset(&sa->rxq_info[sa->rxq_count], 0,
1532 (nb_rx_queues - sa->rxq_count) *
1533 sizeof(sa->rxq_info[0]));
1536 while (sa->rxq_count < nb_rx_queues) {
1537 rc = sfc_rx_qinit_info(sa, sa->rxq_count);
1539 goto fail_rx_qinit_info;
1544 rss->channels = (dev_conf->rxmode.mq_mode == ETH_MQ_RX_RSS) ?
1545 MIN(sa->rxq_count, EFX_MAXRSS) : 0;
1547 if (rss->channels > 0) {
1548 struct rte_eth_rss_conf *adv_conf_rss;
1549 unsigned int sw_index;
1551 for (sw_index = 0; sw_index < EFX_RSS_TBL_SIZE; ++sw_index)
1552 rss->tbl[sw_index] = sw_index % rss->channels;
1554 adv_conf_rss = &dev_conf->rx_adv_conf.rss_conf;
1555 rc = sfc_rx_process_adv_conf_rss(sa, adv_conf_rss);
1557 goto fail_rx_process_adv_conf_rss;
1563 fail_rx_process_adv_conf_rss:
1570 sfc_log_init(sa, "failed %d", rc);
1575 * Shutdown Rx subsystem.
1577 * Called at device close stage, for example, before device shutdown.
1580 sfc_rx_close(struct sfc_adapter *sa)
1582 struct sfc_rss *rss = &sa->rss;
1584 sfc_rx_fini_queues(sa, 0);
1588 rte_free(sa->rxq_info);
1589 sa->rxq_info = NULL;