From: Igor Romanov Date: Tue, 2 Apr 2019 09:28:36 +0000 (+0100) Subject: net/sfc: support Tx preparation in EFX datapath X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=07685524c94af5068953c2e9e2356b00939ca343;p=dpdk.git net/sfc: support Tx preparation in EFX datapath Implement generic checks in Tx prepare function and update Tx burst function accordingly. Signed-off-by: Igor Romanov Signed-off-by: Andrew Rybchenko --- diff --git a/doc/guides/rel_notes/release_19_05.rst b/doc/guides/rel_notes/release_19_05.rst index 487928bedb..1a81fbc6c5 100644 --- a/doc/guides/rel_notes/release_19_05.rst +++ b/doc/guides/rel_notes/release_19_05.rst @@ -87,6 +87,7 @@ New Features * Added support for RSS RETA and hash configuration get API in a secondary process. * Added support for Rx packet types list in a secondary process. + * Added Tx prepare to do Tx offloads checks. * **Updated Mellanox drivers.** diff --git a/drivers/net/sfc/sfc_dp_tx.h b/drivers/net/sfc/sfc_dp_tx.h index 9cb2198e21..885094b676 100644 --- a/drivers/net/sfc/sfc_dp_tx.h +++ b/drivers/net/sfc/sfc_dp_tx.h @@ -13,6 +13,7 @@ #include #include "sfc_dp.h" +#include "sfc_debug.h" #ifdef __cplusplus extern "C" { @@ -170,6 +171,7 @@ struct sfc_dp_tx { sfc_dp_tx_qtx_ev_t *qtx_ev; sfc_dp_tx_qreap_t *qreap; sfc_dp_tx_qdesc_status_t *qdesc_status; + eth_tx_prep_t pkt_prepare; eth_tx_burst_t pkt_burst; }; @@ -192,6 +194,28 @@ sfc_dp_find_tx_by_caps(struct sfc_dp_list *head, unsigned int avail_caps) /** Get Tx datapath ops by the datapath TxQ handle */ const struct sfc_dp_tx *sfc_dp_tx_by_dp_txq(const struct sfc_dp_txq *dp_txq); +static inline int +sfc_dp_tx_prepare_pkt(struct rte_mbuf *m) +{ +#ifdef RTE_LIBRTE_SFC_EFX_DEBUG + int ret; + + ret = rte_validate_tx_offload(m); + if (ret != 0) { + /* + * Negative error code is returned by rte_validate_tx_offload(), + * but positive are used inside net/sfc PMD. + */ + SFC_ASSERT(ret < 0); + return -ret; + } +#else + RTE_SET_USED(m); +#endif + + return 0; +} + extern struct sfc_dp_tx sfc_efx_tx; extern struct sfc_dp_tx sfc_ef10_tx; extern struct sfc_dp_tx sfc_ef10_simple_tx; diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c index 2675d4a8cd..6c33601e73 100644 --- a/drivers/net/sfc/sfc_ethdev.c +++ b/drivers/net/sfc/sfc_ethdev.c @@ -1854,6 +1854,7 @@ sfc_eth_dev_set_ops(struct rte_eth_dev *dev) sa->priv.dp_tx = dp_tx; dev->rx_pkt_burst = dp_rx->pkt_burst; + dev->tx_pkt_prepare = dp_tx->pkt_prepare; dev->tx_pkt_burst = dp_tx->pkt_burst; dev->dev_ops = &sfc_eth_dev_ops; @@ -1881,6 +1882,7 @@ sfc_eth_dev_clear_ops(struct rte_eth_dev *dev) struct sfc_adapter_shared *sas = sfc_adapter_shared_by_eth_dev(dev); dev->dev_ops = NULL; + dev->tx_pkt_prepare = NULL; dev->rx_pkt_burst = NULL; dev->tx_pkt_burst = NULL; @@ -1961,6 +1963,7 @@ sfc_eth_dev_secondary_init(struct rte_eth_dev *dev, uint32_t logtype_main) dev->process_private = sap; dev->rx_pkt_burst = dp_rx->pkt_burst; + dev->tx_pkt_prepare = dp_tx->pkt_prepare; dev->tx_pkt_burst = dp_tx->pkt_burst; dev->dev_ops = &sfc_eth_dev_secondary_ops; @@ -1982,6 +1985,7 @@ sfc_eth_dev_secondary_clear_ops(struct rte_eth_dev *dev) free(dev->process_private); dev->process_private = NULL; dev->dev_ops = NULL; + dev->tx_pkt_prepare = NULL; dev->tx_pkt_burst = NULL; dev->rx_pkt_burst = NULL; } diff --git a/drivers/net/sfc/sfc_tso.c b/drivers/net/sfc/sfc_tso.c index 1ce787f3ca..2c03c08375 100644 --- a/drivers/net/sfc/sfc_tso.c +++ b/drivers/net/sfc/sfc_tso.c @@ -97,7 +97,7 @@ sfc_efx_tso_do(struct sfc_efx_txq *txq, unsigned int idx, uint8_t *tsoh; const struct tcp_hdr *th; efsys_dma_addr_t header_paddr; - uint16_t packet_id; + uint16_t packet_id = 0; uint32_t sent_seq; struct rte_mbuf *m = *in_seg; size_t nh_off = m->l2_len; /* IP header offset */ @@ -147,17 +147,18 @@ sfc_efx_tso_do(struct sfc_efx_txq *txq, unsigned int idx, tsoh = rte_pktmbuf_mtod(m, uint8_t *); } - /* Handle IP header */ + /* + * Handle IP header. Tx prepare has debug-only checks that offload flags + * are correctly filled in in TSO mbuf. Use zero IPID if there is no + * IPv4 flag. If the packet is still IPv4, HW will simply start from + * zero IPID. + */ if (m->ol_flags & PKT_TX_IPV4) { const struct ipv4_hdr *iphe4; iphe4 = (const struct ipv4_hdr *)(tsoh + nh_off); rte_memcpy(&packet_id, &iphe4->packet_id, sizeof(uint16_t)); packet_id = rte_be_to_cpu_16(packet_id); - } else if (m->ol_flags & PKT_TX_IPV6) { - packet_id = 0; - } else { - return EINVAL; } /* Handle TCP header */ diff --git a/drivers/net/sfc/sfc_tx.c b/drivers/net/sfc/sfc_tx.c index 4b1f94ce8d..16fd220bfb 100644 --- a/drivers/net/sfc/sfc_tx.c +++ b/drivers/net/sfc/sfc_tx.c @@ -697,6 +697,25 @@ sfc_efx_tx_maybe_insert_tag(struct sfc_efx_txq *txq, struct rte_mbuf *m, return 1; } +static uint16_t +sfc_efx_prepare_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts, + uint16_t nb_pkts) +{ + uint16_t i; + + for (i = 0; i < nb_pkts; i++) { + int ret; + + ret = sfc_dp_tx_prepare_pkt(tx_pkts[i]); + if (unlikely(ret != 0)) { + rte_errno = ret; + break; + } + } + + return i; +} + static uint16_t sfc_efx_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) { @@ -1122,5 +1141,6 @@ struct sfc_dp_tx sfc_efx_tx = { .qstop = sfc_efx_tx_qstop, .qreap = sfc_efx_tx_qreap, .qdesc_status = sfc_efx_tx_qdesc_status, + .pkt_prepare = sfc_efx_prepare_pkts, .pkt_burst = sfc_efx_xmit_pkts, };