From patchwork Tue Jan 23 01:05:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "John Daley (johndale)" X-Patchwork-Id: 34284 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 3E71C1B00B; Tue, 23 Jan 2018 02:05:43 +0100 (CET) Received: from alln-iport-6.cisco.com (alln-iport-6.cisco.com [173.37.142.93]) by dpdk.org (Postfix) with ESMTP id 6441112009 for ; Tue, 23 Jan 2018 02:05:37 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=3403; q=dns/txt; s=iport; t=1516669537; x=1517879137; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=bLalG+5gNsL+w+Nen9JT5t2BG4hqIWUmR2rtNUou6mw=; b=Xi7nGsGsuRlFtXCjCR1tPEoXlsEJVuwxRREtEbOAY9QHMCcCb82Pvp/6 ad5aeoWEfPe3ykNEEbDoucEwrY8LVvM7WSoYf47DvqtBRS2Yap/tLeeI2 5kVF8o49meU0JtN2kqov7BNXe7Ua+gbTlZEAks0CdT9/Zd/LB6Vkd9Ntg A=; X-IronPort-AV: E=Sophos;i="5.46,398,1511827200"; d="scan'208";a="59658541" Received: from alln-core-10.cisco.com ([173.36.13.132]) by alln-iport-6.cisco.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Jan 2018 01:05:36 +0000 Received: from cisco.com (savbu-usnic-a.cisco.com [10.193.184.48]) by alln-core-10.cisco.com (8.14.5/8.14.5) with ESMTP id w0N15a6f004174; Tue, 23 Jan 2018 01:05:36 GMT Received: by cisco.com (Postfix, from userid 392789) id EF69120F2003; Mon, 22 Jan 2018 17:05:35 -0800 (PST) From: John Daley To: ferruh.yigit@intel.com Cc: dev@dpdk.org, Hyong Youb Kim Date: Mon, 22 Jan 2018 17:05:29 -0800 Message-Id: <20180123010529.17748-3-johndale@cisco.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20180123010529.17748-1-johndale@cisco.com> References: <20180123010529.17748-1-johndale@cisco.com> Subject: [dpdk-dev] [PATCH] net/enic: add a Tx prepare handler 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: Hyong Youb Kim Like most NICs, this hardware (Cisco VIC) also requires partial checksum in the packet for checksum offload and TSO. So, add the tx_pkt_prepare handler like other PMDs do. Technically, VIC has an offload mode that does not require partial checksum for non-TSO packets. But, it has no such mode for TSO packets, making tx_pkt_prepare unavoidable. Signed-off-by: Hyong Youb Kim Reviewed-by: John Daley --- drivers/net/enic/enic.h | 2 ++ drivers/net/enic/enic_ethdev.c | 1 + drivers/net/enic/enic_rxtx.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+) diff --git a/drivers/net/enic/enic.h b/drivers/net/enic/enic.h index c76a8f0af..c083985ee 100644 --- a/drivers/net/enic/enic.h +++ b/drivers/net/enic/enic.h @@ -268,6 +268,8 @@ uint16_t enic_dummy_recv_pkts(void *rx_queue, uint16_t nb_pkts); uint16_t enic_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts); +uint16_t enic_prep_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, + uint16_t nb_pkts); int enic_set_mtu(struct enic *enic, uint16_t new_mtu); int enic_link_update(struct enic *enic); void enic_fdir_info(struct enic *enic); diff --git a/drivers/net/enic/enic_ethdev.c b/drivers/net/enic/enic_ethdev.c index 2c356dc27..c46d592ed 100644 --- a/drivers/net/enic/enic_ethdev.c +++ b/drivers/net/enic/enic_ethdev.c @@ -641,6 +641,7 @@ static int eth_enicpmd_dev_init(struct rte_eth_dev *eth_dev) eth_dev->dev_ops = &enicpmd_eth_dev_ops; eth_dev->rx_pkt_burst = &enic_recv_pkts; eth_dev->tx_pkt_burst = &enic_xmit_pkts; + eth_dev->tx_pkt_prepare = &enic_prep_pkts; pdev = RTE_ETH_DEV_TO_PCI(eth_dev); rte_eth_copy_pci_info(eth_dev, pdev); diff --git a/drivers/net/enic/enic_rxtx.c b/drivers/net/enic/enic_rxtx.c index 8157697a0..2fe5a3fa3 100644 --- a/drivers/net/enic/enic_rxtx.c +++ b/drivers/net/enic/enic_rxtx.c @@ -5,6 +5,7 @@ #include #include +#include #include #include "enic_compat.h" @@ -14,6 +15,15 @@ #include #include +#define ENIC_TX_OFFLOAD_MASK ( \ + PKT_TX_VLAN_PKT | \ + PKT_TX_IP_CKSUM | \ + PKT_TX_L4_MASK | \ + PKT_TX_TCP_SEG) + +#define ENIC_TX_OFFLOAD_NOTSUP_MASK \ + (PKT_TX_OFFLOAD_MASK ^ ENIC_TX_OFFLOAD_MASK) + #define RTE_PMD_USE_PREFETCH #ifdef RTE_PMD_USE_PREFETCH @@ -433,6 +443,38 @@ unsigned int enic_cleanup_wq(__rte_unused struct enic *enic, struct vnic_wq *wq) return 0; } +uint16_t enic_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts, + uint16_t nb_pkts) +{ + int32_t ret; + uint16_t i; + uint64_t ol_flags; + struct rte_mbuf *m; + + for (i = 0; i != nb_pkts; i++) { + m = tx_pkts[i]; + ol_flags = m->ol_flags; + if (ol_flags & ENIC_TX_OFFLOAD_NOTSUP_MASK) { + rte_errno = -ENOTSUP; + return i; + } +#ifdef RTE_LIBRTE_ETHDEV_DEBUG + ret = rte_validate_tx_offload(m); + if (ret != 0) { + rte_errno = ret; + return i; + } +#endif + ret = rte_net_intel_cksum_prepare(m); + if (ret != 0) { + rte_errno = ret; + return i; + } + } + + return i; +} + uint16_t enic_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) {