4 * Copyright (c) 2016-2017 Solarflare Communications Inc.
7 * This software was jointly developed between OKTET Labs (under contract
8 * for Solarflare) and Solarflare Communications, Inc.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions are met:
13 * 1. Redistributions of source code must retain the above copyright notice,
14 * this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright notice,
16 * this list of conditions and the following disclaimer in the documentation
17 * and/or other materials provided with the distribution.
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
21 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
26 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
27 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
28 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
29 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 #include "sfc_debug.h"
37 #include "sfc_tweak.h"
38 #include "sfc_kvargs.h"
41 * Maximum number of TX queue flush attempts in case of
42 * failure or flush timeout
44 #define SFC_TX_QFLUSH_ATTEMPTS (3)
47 * Time to wait between event queue polling attempts when waiting for TX
48 * queue flush done or flush failed events
50 #define SFC_TX_QFLUSH_POLL_WAIT_MS (1)
53 * Maximum number of event queue polling attempts when waiting for TX queue
54 * flush done or flush failed events; it defines TX queue flush attempt timeout
55 * together with SFC_TX_QFLUSH_POLL_WAIT_MS
57 #define SFC_TX_QFLUSH_POLL_ATTEMPTS (2000)
60 sfc_tx_qcheck_conf(struct sfc_adapter *sa, uint16_t nb_tx_desc,
61 const struct rte_eth_txconf *tx_conf)
63 unsigned int flags = tx_conf->txq_flags;
64 const efx_nic_cfg_t *encp = efx_nic_cfg_get(sa->nic);
67 if (tx_conf->tx_rs_thresh != 0) {
68 sfc_err(sa, "RS bit in transmit descriptor is not supported");
72 if (tx_conf->tx_free_thresh > EFX_TXQ_LIMIT(nb_tx_desc)) {
74 "TxQ free threshold too large: %u vs maximum %u",
75 tx_conf->tx_free_thresh, EFX_TXQ_LIMIT(nb_tx_desc));
79 if (tx_conf->tx_thresh.pthresh != 0 ||
80 tx_conf->tx_thresh.hthresh != 0 ||
81 tx_conf->tx_thresh.wthresh != 0) {
83 "prefetch/host/writeback thresholds are not supported");
87 if ((flags & ETH_TXQ_FLAGS_NOVLANOFFL) == 0) {
88 if (!encp->enc_hw_tx_insert_vlan_enabled) {
89 sfc_err(sa, "VLAN offload is not supported");
91 } else if (~sa->dp_tx->features & SFC_DP_TX_FEAT_VLAN_INSERT) {
93 "VLAN offload is not supported by %s datapath",
99 if ((flags & ETH_TXQ_FLAGS_NOXSUMSCTP) == 0) {
100 sfc_err(sa, "SCTP offload is not supported");
104 /* We either perform both TCP and UDP offload, or no offload at all */
105 if (((flags & ETH_TXQ_FLAGS_NOXSUMTCP) == 0) !=
106 ((flags & ETH_TXQ_FLAGS_NOXSUMUDP) == 0)) {
107 sfc_err(sa, "TCP and UDP offloads can't be set independently");
115 sfc_tx_qflush_done(struct sfc_txq *txq)
117 txq->state |= SFC_TXQ_FLUSHED;
118 txq->state &= ~SFC_TXQ_FLUSHING;
122 sfc_tx_qinit(struct sfc_adapter *sa, unsigned int sw_index,
123 uint16_t nb_tx_desc, unsigned int socket_id,
124 const struct rte_eth_txconf *tx_conf)
126 const efx_nic_cfg_t *encp = efx_nic_cfg_get(sa->nic);
127 struct sfc_txq_info *txq_info;
130 unsigned int evq_index = sfc_evq_index_by_txq_sw_index(sa, sw_index);
132 struct sfc_dp_tx_qcreate_info info;
134 sfc_log_init(sa, "TxQ = %u", sw_index);
136 rc = sfc_tx_qcheck_conf(sa, nb_tx_desc, tx_conf);
140 SFC_ASSERT(sw_index < sa->txq_count);
141 txq_info = &sa->txq_info[sw_index];
143 SFC_ASSERT(nb_tx_desc <= sa->txq_max_entries);
144 txq_info->entries = nb_tx_desc;
146 rc = sfc_ev_qinit(sa, evq_index, txq_info->entries, socket_id);
150 evq = sa->evq_info[evq_index].evq;
153 txq = rte_zmalloc_socket("sfc-txq", sizeof(*txq), 0, socket_id);
159 txq->hw_index = sw_index;
162 (tx_conf->tx_free_thresh) ? tx_conf->tx_free_thresh :
163 SFC_TX_DEFAULT_FREE_THRESH;
164 txq->flags = tx_conf->txq_flags;
166 rc = sfc_dma_alloc(sa, "txq", sw_index, EFX_TXQ_SIZE(txq_info->entries),
167 socket_id, &txq->mem);
171 memset(&info, 0, sizeof(info));
172 info.free_thresh = txq->free_thresh;
173 info.flags = tx_conf->txq_flags;
174 info.txq_entries = txq_info->entries;
175 info.dma_desc_size_max = encp->enc_tx_dma_desc_size_max;
177 rc = sa->dp_tx->qcreate(sa->eth_dev->data->port_id, sw_index,
178 &SFC_DEV_TO_PCI(sa->eth_dev)->addr,
179 socket_id, &info, &txq->dp);
181 goto fail_dp_tx_qinit;
183 evq->dp_txq = txq->dp;
185 txq->state = SFC_TXQ_INITIALIZED;
187 txq_info->deferred_start = (tx_conf->tx_deferred_start != 0);
192 sfc_dma_free(sa, &txq->mem);
195 txq_info->txq = NULL;
199 sfc_ev_qfini(sa, evq_index);
202 txq_info->entries = 0;
205 sfc_log_init(sa, "failed (TxQ = %u, rc = %d)", sw_index, rc);
210 sfc_tx_qfini(struct sfc_adapter *sa, unsigned int sw_index)
212 struct sfc_txq_info *txq_info;
215 sfc_log_init(sa, "TxQ = %u", sw_index);
217 SFC_ASSERT(sw_index < sa->txq_count);
218 txq_info = &sa->txq_info[sw_index];
221 SFC_ASSERT(txq != NULL);
222 SFC_ASSERT(txq->state == SFC_TXQ_INITIALIZED);
224 sa->dp_tx->qdestroy(txq->dp);
227 txq_info->txq = NULL;
228 txq_info->entries = 0;
230 sfc_dma_free(sa, &txq->mem);
235 sfc_tx_qinit_info(struct sfc_adapter *sa, unsigned int sw_index)
237 sfc_log_init(sa, "TxQ = %u", sw_index);
243 sfc_tx_check_mode(struct sfc_adapter *sa, const struct rte_eth_txmode *txmode)
247 switch (txmode->mq_mode) {
251 sfc_err(sa, "Tx multi-queue mode %u not supported",
257 * These features are claimed to be i40e-specific,
258 * but it does make sense to double-check their absence
260 if (txmode->hw_vlan_reject_tagged) {
261 sfc_err(sa, "Rejecting tagged packets not supported");
265 if (txmode->hw_vlan_reject_untagged) {
266 sfc_err(sa, "Rejecting untagged packets not supported");
270 if (txmode->hw_vlan_insert_pvid) {
271 sfc_err(sa, "Port-based VLAN insertion not supported");
279 sfc_tx_init(struct sfc_adapter *sa)
281 const efx_nic_cfg_t *encp = efx_nic_cfg_get(sa->nic);
282 const struct rte_eth_conf *dev_conf = &sa->eth_dev->data->dev_conf;
283 unsigned int sw_index;
287 * The datapath implementation assumes absence of boundary
288 * limits on Tx DMA descriptors. Addition of these checks on
289 * datapath would simply make the datapath slower.
291 if (encp->enc_tx_dma_desc_boundary != 0) {
293 goto fail_tx_dma_desc_boundary;
296 rc = sfc_tx_check_mode(sa, &dev_conf->txmode);
298 goto fail_check_mode;
300 sa->txq_count = sa->eth_dev->data->nb_tx_queues;
302 sa->txq_info = rte_calloc_socket("sfc-txqs", sa->txq_count,
303 sizeof(sa->txq_info[0]), 0,
305 if (sa->txq_info == NULL)
306 goto fail_txqs_alloc;
308 for (sw_index = 0; sw_index < sa->txq_count; ++sw_index) {
309 rc = sfc_tx_qinit_info(sa, sw_index);
311 goto fail_tx_qinit_info;
317 rte_free(sa->txq_info);
324 fail_tx_dma_desc_boundary:
325 sfc_log_init(sa, "failed (rc = %d)", rc);
330 sfc_tx_fini(struct sfc_adapter *sa)
334 sw_index = sa->txq_count;
335 while (--sw_index >= 0) {
336 if (sa->txq_info[sw_index].txq != NULL)
337 sfc_tx_qfini(sa, sw_index);
340 rte_free(sa->txq_info);
346 sfc_tx_qstart(struct sfc_adapter *sa, unsigned int sw_index)
348 struct rte_eth_dev_data *dev_data;
349 struct sfc_txq_info *txq_info;
353 unsigned int desc_index;
356 sfc_log_init(sa, "TxQ = %u", sw_index);
358 SFC_ASSERT(sw_index < sa->txq_count);
359 txq_info = &sa->txq_info[sw_index];
363 SFC_ASSERT(txq->state == SFC_TXQ_INITIALIZED);
367 rc = sfc_ev_qstart(sa, evq->evq_index);
372 * It seems that DPDK has no controls regarding IPv4 offloads,
373 * hence, we always enable it here
375 if ((txq->flags & ETH_TXQ_FLAGS_NOXSUMTCP) ||
376 (txq->flags & ETH_TXQ_FLAGS_NOXSUMUDP)) {
377 flags = EFX_TXQ_CKSUM_IPV4;
379 flags = EFX_TXQ_CKSUM_IPV4 | EFX_TXQ_CKSUM_TCPUDP;
382 flags |= EFX_TXQ_FATSOV2;
385 rc = efx_tx_qcreate(sa->nic, sw_index, 0, &txq->mem,
386 txq_info->entries, 0 /* not used on EF10 */,
388 &txq->common, &desc_index);
390 if (sa->tso && (rc == ENOSPC))
391 sfc_err(sa, "ran out of TSO contexts");
393 goto fail_tx_qcreate;
396 efx_tx_qenable(txq->common);
398 txq->state |= SFC_TXQ_STARTED;
400 rc = sa->dp_tx->qstart(txq->dp, evq->read_ptr, desc_index);
405 * It seems to be used by DPDK for debug purposes only ('rte_ether')
407 dev_data = sa->eth_dev->data;
408 dev_data->tx_queue_state[sw_index] = RTE_ETH_QUEUE_STATE_STARTED;
413 txq->state = SFC_TXQ_INITIALIZED;
414 efx_tx_qdestroy(txq->common);
417 sfc_ev_qstop(sa, evq->evq_index);
424 sfc_tx_qstop(struct sfc_adapter *sa, unsigned int sw_index)
426 struct rte_eth_dev_data *dev_data;
427 struct sfc_txq_info *txq_info;
429 unsigned int retry_count;
430 unsigned int wait_count;
432 sfc_log_init(sa, "TxQ = %u", sw_index);
434 SFC_ASSERT(sw_index < sa->txq_count);
435 txq_info = &sa->txq_info[sw_index];
439 if (txq->state == SFC_TXQ_INITIALIZED)
442 SFC_ASSERT(txq->state & SFC_TXQ_STARTED);
444 sa->dp_tx->qstop(txq->dp, &txq->evq->read_ptr);
447 * Retry TX queue flushing in case of flush failed or
448 * timeout; in the worst case it can delay for 6 seconds
450 for (retry_count = 0;
451 ((txq->state & SFC_TXQ_FLUSHED) == 0) &&
452 (retry_count < SFC_TX_QFLUSH_ATTEMPTS);
454 if (efx_tx_qflush(txq->common) != 0) {
455 txq->state |= SFC_TXQ_FLUSHING;
460 * Wait for TX queue flush done or flush failed event at least
461 * SFC_TX_QFLUSH_POLL_WAIT_MS milliseconds and not more
462 * than 2 seconds (SFC_TX_QFLUSH_POLL_WAIT_MS multiplied
463 * by SFC_TX_QFLUSH_POLL_ATTEMPTS)
467 rte_delay_ms(SFC_TX_QFLUSH_POLL_WAIT_MS);
468 sfc_ev_qpoll(txq->evq);
469 } while ((txq->state & SFC_TXQ_FLUSHING) &&
470 wait_count++ < SFC_TX_QFLUSH_POLL_ATTEMPTS);
472 if (txq->state & SFC_TXQ_FLUSHING)
473 sfc_err(sa, "TxQ %u flush timed out", sw_index);
475 if (txq->state & SFC_TXQ_FLUSHED)
476 sfc_info(sa, "TxQ %u flushed", sw_index);
479 sa->dp_tx->qreap(txq->dp);
481 txq->state = SFC_TXQ_INITIALIZED;
483 efx_tx_qdestroy(txq->common);
485 sfc_ev_qstop(sa, txq->evq->evq_index);
488 * It seems to be used by DPDK for debug purposes only ('rte_ether')
490 dev_data = sa->eth_dev->data;
491 dev_data->tx_queue_state[sw_index] = RTE_ETH_QUEUE_STATE_STOPPED;
495 sfc_tx_start(struct sfc_adapter *sa)
497 unsigned int sw_index;
500 sfc_log_init(sa, "txq_count = %u", sa->txq_count);
503 if (!efx_nic_cfg_get(sa->nic)->enc_fw_assisted_tso_v2_enabled) {
504 sfc_warn(sa, "TSO support was unable to be restored");
509 rc = efx_tx_init(sa->nic);
511 goto fail_efx_tx_init;
513 for (sw_index = 0; sw_index < sa->txq_count; ++sw_index) {
514 if (!(sa->txq_info[sw_index].deferred_start) ||
515 sa->txq_info[sw_index].deferred_started) {
516 rc = sfc_tx_qstart(sa, sw_index);
525 while (sw_index-- > 0)
526 sfc_tx_qstop(sa, sw_index);
528 efx_tx_fini(sa->nic);
531 sfc_log_init(sa, "failed (rc = %d)", rc);
536 sfc_tx_stop(struct sfc_adapter *sa)
538 unsigned int sw_index;
540 sfc_log_init(sa, "txq_count = %u", sa->txq_count);
542 sw_index = sa->txq_count;
543 while (sw_index-- > 0) {
544 if (sa->txq_info[sw_index].txq != NULL)
545 sfc_tx_qstop(sa, sw_index);
548 efx_tx_fini(sa->nic);
552 sfc_efx_tx_reap(struct sfc_efx_txq *txq)
554 unsigned int completed;
556 sfc_ev_qpoll(txq->evq);
558 for (completed = txq->completed;
559 completed != txq->pending; completed++) {
560 struct sfc_efx_tx_sw_desc *txd;
562 txd = &txq->sw_ring[completed & txq->ptr_mask];
564 if (txd->mbuf != NULL) {
565 rte_pktmbuf_free(txd->mbuf);
570 txq->completed = completed;
574 * The function is used to insert or update VLAN tag;
575 * the firmware has state of the firmware tag to insert per TxQ
576 * (controlled by option descriptors), hence, if the tag of the
577 * packet to be sent is different from one remembered by the firmware,
578 * the function will update it
581 sfc_efx_tx_maybe_insert_tag(struct sfc_efx_txq *txq, struct rte_mbuf *m,
584 uint16_t this_tag = ((m->ol_flags & PKT_TX_VLAN_PKT) ?
587 if (this_tag == txq->hw_vlan_tci)
591 * The expression inside SFC_ASSERT() is not desired to be checked in
592 * a non-debug build because it might be too expensive on the data path
594 SFC_ASSERT(efx_nic_cfg_get(txq->evq->sa->nic)->enc_hw_tx_insert_vlan_enabled);
596 efx_tx_qdesc_vlantci_create(txq->common, rte_cpu_to_be_16(this_tag),
599 txq->hw_vlan_tci = this_tag;
605 sfc_efx_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
607 struct sfc_dp_txq *dp_txq = (struct sfc_dp_txq *)tx_queue;
608 struct sfc_efx_txq *txq = sfc_efx_txq_by_dp_txq(dp_txq);
609 unsigned int added = txq->added;
610 unsigned int pushed = added;
611 unsigned int pkts_sent = 0;
612 efx_desc_t *pend = &txq->pend_desc[0];
613 const unsigned int hard_max_fill = EFX_TXQ_LIMIT(txq->ptr_mask + 1);
614 const unsigned int soft_max_fill = hard_max_fill - txq->free_thresh;
615 unsigned int fill_level = added - txq->completed;
618 struct rte_mbuf **pktp;
620 if (unlikely((txq->flags & SFC_EFX_TXQ_FLAG_RUNNING) == 0))
624 * If insufficient space for a single packet is present,
625 * we should reap; otherwise, we shouldn't do that all the time
626 * to avoid latency increase
628 reap_done = (fill_level > soft_max_fill);
631 sfc_efx_tx_reap(txq);
633 * Recalculate fill level since 'txq->completed'
634 * might have changed on reap
636 fill_level = added - txq->completed;
639 for (pkts_sent = 0, pktp = &tx_pkts[0];
640 (pkts_sent < nb_pkts) && (fill_level <= soft_max_fill);
641 pkts_sent++, pktp++) {
642 struct rte_mbuf *m_seg = *pktp;
643 size_t pkt_len = m_seg->pkt_len;
644 unsigned int pkt_descs = 0;
648 * Here VLAN TCI is expected to be zero in case if no
649 * DEV_TX_VLAN_OFFLOAD capability is advertised;
650 * if the calling app ignores the absence of
651 * DEV_TX_VLAN_OFFLOAD and pushes VLAN TCI, then
652 * TX_ERROR will occur
654 pkt_descs += sfc_efx_tx_maybe_insert_tag(txq, m_seg, &pend);
656 if (m_seg->ol_flags & PKT_TX_TCP_SEG) {
658 * We expect correct 'pkt->l[2, 3, 4]_len' values
659 * to be set correctly by the caller
661 if (sfc_efx_tso_do(txq, added, &m_seg, &in_off, &pend,
662 &pkt_descs, &pkt_len) != 0) {
663 /* We may have reached this place for
664 * one of the following reasons:
666 * 1) Packet header length is greater
667 * than SFC_TSOH_STD_LEN
668 * 2) TCP header starts at more then
669 * 208 bytes into the frame
671 * We will deceive RTE saying that we have sent
672 * the packet, but we will actually drop it.
673 * Hence, we should revert 'pend' to the
674 * previous state (in case we have added
675 * VLAN descriptor) and start processing
676 * another one packet. But the original
677 * mbuf shouldn't be orphaned
681 rte_pktmbuf_free(*pktp);
687 * We've only added 2 FATSOv2 option descriptors
688 * and 1 descriptor for the linearized packet header.
689 * The outstanding work will be done in the same manner
690 * as for the usual non-TSO path
694 for (; m_seg != NULL; m_seg = m_seg->next) {
695 efsys_dma_addr_t next_frag;
698 seg_len = m_seg->data_len;
699 next_frag = rte_mbuf_data_dma_addr(m_seg);
702 * If we've started TSO transaction few steps earlier,
703 * we'll skip packet header using an offset in the
704 * current segment (which has been set to the
705 * first one containing payload)
712 efsys_dma_addr_t frag_addr = next_frag;
716 * It is assumed here that there is no
717 * limitation on address boundary
718 * crossing by DMA descriptor.
720 frag_len = MIN(seg_len, txq->dma_desc_size_max);
721 next_frag += frag_len;
725 efx_tx_qdesc_dma_create(txq->common,
731 } while (seg_len != 0);
736 fill_level += pkt_descs;
737 if (unlikely(fill_level > hard_max_fill)) {
739 * Our estimation for maximum number of descriptors
740 * required to send a packet seems to be wrong.
741 * Try to reap (if we haven't yet).
744 sfc_efx_tx_reap(txq);
746 fill_level = added - txq->completed;
747 if (fill_level > hard_max_fill) {
757 /* Assign mbuf to the last used desc */
758 txq->sw_ring[(added - 1) & txq->ptr_mask].mbuf = *pktp;
761 if (likely(pkts_sent > 0)) {
762 rc = efx_tx_qdesc_post(txq->common, txq->pend_desc,
763 pend - &txq->pend_desc[0],
764 txq->completed, &txq->added);
767 if (likely(pushed != txq->added))
768 efx_tx_qpush(txq->common, txq->added, pushed);
771 #if SFC_TX_XMIT_PKTS_REAP_AT_LEAST_ONCE
773 sfc_efx_tx_reap(txq);
781 sfc_txq_by_dp_txq(const struct sfc_dp_txq *dp_txq)
783 const struct sfc_dp_queue *dpq = &dp_txq->dpq;
784 struct rte_eth_dev *eth_dev;
785 struct sfc_adapter *sa;
788 SFC_ASSERT(rte_eth_dev_is_valid_port(dpq->port_id));
789 eth_dev = &rte_eth_devices[dpq->port_id];
791 sa = eth_dev->data->dev_private;
793 SFC_ASSERT(dpq->queue_id < sa->txq_count);
794 txq = sa->txq_info[dpq->queue_id].txq;
796 SFC_ASSERT(txq != NULL);
800 static sfc_dp_tx_qcreate_t sfc_efx_tx_qcreate;
802 sfc_efx_tx_qcreate(uint16_t port_id, uint16_t queue_id,
803 const struct rte_pci_addr *pci_addr,
805 const struct sfc_dp_tx_qcreate_info *info,
806 struct sfc_dp_txq **dp_txqp)
808 struct sfc_efx_txq *txq;
809 struct sfc_txq *ctrl_txq;
813 txq = rte_zmalloc_socket("sfc-efx-txq", sizeof(*txq),
814 RTE_CACHE_LINE_SIZE, socket_id);
818 sfc_dp_queue_init(&txq->dp.dpq, port_id, queue_id, pci_addr);
821 txq->pend_desc = rte_calloc_socket("sfc-efx-txq-pend-desc",
822 EFX_TXQ_LIMIT(info->txq_entries),
823 sizeof(*txq->pend_desc), 0,
825 if (txq->pend_desc == NULL)
826 goto fail_pend_desc_alloc;
829 txq->sw_ring = rte_calloc_socket("sfc-efx-txq-sw_ring",
831 sizeof(*txq->sw_ring),
832 RTE_CACHE_LINE_SIZE, socket_id);
833 if (txq->sw_ring == NULL)
834 goto fail_sw_ring_alloc;
836 ctrl_txq = sfc_txq_by_dp_txq(&txq->dp);
837 if (ctrl_txq->evq->sa->tso) {
838 rc = sfc_efx_tso_alloc_tsoh_objs(txq->sw_ring,
839 info->txq_entries, socket_id);
841 goto fail_alloc_tsoh_objs;
844 txq->evq = ctrl_txq->evq;
845 txq->ptr_mask = info->txq_entries - 1;
846 txq->free_thresh = info->free_thresh;
847 txq->dma_desc_size_max = info->dma_desc_size_max;
852 fail_alloc_tsoh_objs:
853 rte_free(txq->sw_ring);
856 rte_free(txq->pend_desc);
858 fail_pend_desc_alloc:
865 static sfc_dp_tx_qdestroy_t sfc_efx_tx_qdestroy;
867 sfc_efx_tx_qdestroy(struct sfc_dp_txq *dp_txq)
869 struct sfc_efx_txq *txq = sfc_efx_txq_by_dp_txq(dp_txq);
871 sfc_efx_tso_free_tsoh_objs(txq->sw_ring, txq->ptr_mask + 1);
872 rte_free(txq->sw_ring);
873 rte_free(txq->pend_desc);
877 static sfc_dp_tx_qstart_t sfc_efx_tx_qstart;
879 sfc_efx_tx_qstart(struct sfc_dp_txq *dp_txq,
880 __rte_unused unsigned int evq_read_ptr,
881 unsigned int txq_desc_index)
883 /* libefx-based datapath is specific to libefx-based PMD */
884 struct sfc_efx_txq *txq = sfc_efx_txq_by_dp_txq(dp_txq);
885 struct sfc_txq *ctrl_txq = sfc_txq_by_dp_txq(dp_txq);
887 txq->common = ctrl_txq->common;
889 txq->pending = txq->completed = txq->added = txq_desc_index;
890 txq->hw_vlan_tci = 0;
892 txq->flags |= (SFC_EFX_TXQ_FLAG_STARTED | SFC_EFX_TXQ_FLAG_RUNNING);
897 static sfc_dp_tx_qstop_t sfc_efx_tx_qstop;
899 sfc_efx_tx_qstop(struct sfc_dp_txq *dp_txq,
900 __rte_unused unsigned int *evq_read_ptr)
902 struct sfc_efx_txq *txq = sfc_efx_txq_by_dp_txq(dp_txq);
904 txq->flags &= ~SFC_EFX_TXQ_FLAG_RUNNING;
907 static sfc_dp_tx_qreap_t sfc_efx_tx_qreap;
909 sfc_efx_tx_qreap(struct sfc_dp_txq *dp_txq)
911 struct sfc_efx_txq *txq = sfc_efx_txq_by_dp_txq(dp_txq);
914 sfc_efx_tx_reap(txq);
916 for (txds = 0; txds <= txq->ptr_mask; txds++) {
917 if (txq->sw_ring[txds].mbuf != NULL) {
918 rte_pktmbuf_free(txq->sw_ring[txds].mbuf);
919 txq->sw_ring[txds].mbuf = NULL;
923 txq->flags &= ~SFC_EFX_TXQ_FLAG_STARTED;
926 struct sfc_dp_tx sfc_efx_tx = {
928 .name = SFC_KVARG_DATAPATH_EFX,
932 .features = SFC_DP_TX_FEAT_VLAN_INSERT,
933 .qcreate = sfc_efx_tx_qcreate,
934 .qdestroy = sfc_efx_tx_qdestroy,
935 .qstart = sfc_efx_tx_qstart,
936 .qstop = sfc_efx_tx_qstop,
937 .qreap = sfc_efx_tx_qreap,
938 .pkt_burst = sfc_efx_xmit_pkts,