From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 19585A0096 for ; Mon, 3 Jun 2019 20:21:00 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 171061B9BE; Mon, 3 Jun 2019 20:21:00 +0200 (CEST) Received: from dispatch1-us1.ppe-hosted.com (dispatch1-us1.ppe-hosted.com [148.163.129.52]) by dpdk.org (Postfix) with ESMTP id 774E31B9B3; Mon, 3 Jun 2019 20:20:58 +0200 (CEST) X-Virus-Scanned: Proofpoint Essentials engine Received: from webmail.solarflare.com (webmail.solarflare.com [12.187.104.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mx1-us3.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTPS id A4500480098; Mon, 3 Jun 2019 18:20:56 +0000 (UTC) Received: from ocex03.SolarFlarecom.com (10.20.40.36) by ocex03.SolarFlarecom.com (10.20.40.36) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Mon, 3 Jun 2019 11:20:54 -0700 Received: from opal.uk.solarflarecom.com (10.17.10.1) by ocex03.SolarFlarecom.com (10.20.40.36) with Microsoft SMTP Server (TLS) id 15.0.1395.4 via Frontend Transport; Mon, 3 Jun 2019 11:20:52 -0700 Received: from ukv-loginhost.uk.solarflarecom.com (ukv-loginhost.uk.solarflarecom.com [10.17.10.39]) by opal.uk.solarflarecom.com (8.13.8/8.13.8) with ESMTP id x53IKpZK009616; Mon, 3 Jun 2019 19:20:51 +0100 Received: from ukv-loginhost.uk.solarflarecom.com (localhost [127.0.0.1]) by ukv-loginhost.uk.solarflarecom.com (Postfix) with ESMTP id 39EBF1616E0; Mon, 3 Jun 2019 19:20:51 +0100 (BST) From: Andrew Rybchenko To: , <"Coquelin , "Tiwei Bie" , Zhihong Wang CC: , Dilshod Urazov , Date: Mon, 3 Jun 2019 19:20:38 +0100 Message-ID: <1559586038-16181-1-git-send-email-arybchenko@solarflare.com> X-Mailer: git-send-email 1.8.3.1 MIME-Version: 1.0 Content-Type: text/plain X-TM-AS-Product-Ver: SMEX-12.5.0.1300-8.5.1010-24654.005 X-TM-AS-Result: No-6.271000-4.000000-10 X-TMASE-MatchedRID: L6x78Rxx066jJwaIeQ4C0EdAWPMBu8kQNU8z+tFJHR2sBbMjHUED8LER MpuIU2oe4XHxYgeGSGV1F2UJ40Hu5gVQ1xLwjqxoHcQQBuf4ZFsmKH/Kj46+VZGhAvBSa2i/yJN a6DYLgM0003R2T+VvjtL8EByfWwBiLGmmJTL2jhwD2WXLXdz+Adi5W7Rf+s6QQW6eCaGxKwL4v0 Dh0LIwCVfFMkCZ6qI1hIWqdquaJsofOjKSU0pCEeI0ZCCJp19Dndls9F9zmi02/UwdvFG5IgW2Y 47KAviO4vM1YF6AJbbCCfuIMF6xLSAHAopEd76vw9uJ01Rr7T2A8cv/djaokjPgCVFmnGjLR+8P fpLspwmVxZ0w+81wHw== X-TM-AS-User-Approved-Sender: No X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--6.271000-4.000000 X-TMASE-Version: SMEX-12.5.0.1300-8.5.1010-24654.005 X-MDID: 1559586056-40Wu_7lmfHMU Subject: [dpdk-dev] [PATCH] net/virtio: add Tx preparation X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Dilshod Urazov Virtio requires pseudo-header checksum in TCP/UDP checksum to do offload, but it was lost when Tx prepare is introduced. Also rte_validate_tx_offload() should be used to validate Tx offloads. Also it is incorrect to do virtio_tso_fix_cksum() after prepend to mbuf without taking prepended size into account, since layer 2/3/4 lengths provide incorrect offsets after prepend. Fixes: 4fb7e803eb1a ("ethdev: add Tx preparation") Cc: stable@dpdk.org Signed-off-by: Dilshod Urazov Signed-off-by: Andrew Rybchenko --- drivers/net/virtio/virtio_ethdev.c | 1 + drivers/net/virtio/virtio_ethdev.h | 3 +++ drivers/net/virtio/virtio_rxtx.c | 32 +++++++++++++++++++++++++++++++- 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c index c4570bb..97d3c29 100644 --- a/drivers/net/virtio/virtio_ethdev.c +++ b/drivers/net/virtio/virtio_ethdev.c @@ -1473,6 +1473,7 @@ static int virtio_dev_xstats_get_names(struct rte_eth_dev *dev, { struct virtio_hw *hw = eth_dev->data->dev_private; + eth_dev->tx_pkt_prepare = virtio_xmit_pkts_prepare; if (vtpci_packed_queue(hw)) { PMD_INIT_LOG(INFO, "virtio: using packed ring %s Tx path on port %u", diff --git a/drivers/net/virtio/virtio_ethdev.h b/drivers/net/virtio/virtio_ethdev.h index 45e96f3..20d3317 100644 --- a/drivers/net/virtio/virtio_ethdev.h +++ b/drivers/net/virtio/virtio_ethdev.h @@ -89,6 +89,9 @@ uint16_t virtio_recv_mergeable_pkts_packed(void *rx_queue, uint16_t virtio_recv_pkts_inorder(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts); +uint16_t virtio_xmit_pkts_prepare(void *tx_queue, struct rte_mbuf **tx_pkts, + uint16_t nb_pkts); + uint16_t virtio_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts); uint16_t virtio_xmit_pkts_packed(void *tx_queue, struct rte_mbuf **tx_pkts, diff --git a/drivers/net/virtio/virtio_rxtx.c b/drivers/net/virtio/virtio_rxtx.c index 1de2854..f2ca085 100644 --- a/drivers/net/virtio/virtio_rxtx.c +++ b/drivers/net/virtio/virtio_rxtx.c @@ -559,7 +559,6 @@ /* TCP Segmentation Offload */ if (cookie->ol_flags & PKT_TX_TCP_SEG) { - virtio_tso_fix_cksum(cookie); hdr->gso_type = (cookie->ol_flags & PKT_TX_IPV6) ? VIRTIO_NET_HDR_GSO_TCPV6 : VIRTIO_NET_HDR_GSO_TCPV4; @@ -1970,6 +1969,37 @@ } uint16_t +virtio_xmit_pkts_prepare(void *tx_queue __rte_unused, struct rte_mbuf **tx_pkts, + uint16_t nb_pkts) +{ + uint16_t nb_tx; + int error; + + for (nb_tx = 0; nb_tx < nb_pkts; nb_tx++) { + struct rte_mbuf *m = tx_pkts[nb_tx]; + +#ifdef RTE_LIBRTE_ETHDEV_DEBUG + error = rte_validate_tx_offload(m); + if (unlikely(error)) { + rte_errno = -error; + break; + } +#endif + + error = rte_net_intel_cksum_prepare(m); + if (unlikely(error)) { + rte_errno = -error; + break; + } + + if (m->ol_flags & PKT_TX_TCP_SEG) + virtio_tso_fix_cksum(m); + } + + return nb_tx; +} + +uint16_t virtio_xmit_pkts_packed(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) { -- 1.8.3.1