From patchwork Fri Oct 21 14:46:17 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Kulasek X-Patchwork-Id: 16745 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 7D38E58D4; Fri, 21 Oct 2016 16:46:47 +0200 (CEST) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id 759C75699 for ; Fri, 21 Oct 2016 16:46:44 +0200 (CEST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga105.fm.intel.com with ESMTP; 21 Oct 2016 07:46:44 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.31,377,1473145200"; d="scan'208"; a="1048043671" Received: from unknown (HELO Sent) ([10.103.102.234]) by orsmga001.jf.intel.com with SMTP; 21 Oct 2016 07:46:41 -0700 Received: by Sent (sSMTP sendmail emulation); Fri, 21 Oct 2016 16:46:41 +0200 From: Tomasz Kulasek To: dev@dpdk.org Cc: konstantin.ananyev@intel.com, olivier.matz@6wind.com Date: Fri, 21 Oct 2016 16:46:17 +0200 Message-Id: <1477061177-15828-7-git-send-email-tomaszx.kulasek@intel.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1477061177-15828-1-git-send-email-tomaszx.kulasek@intel.com> References: <1477057376-16224-1-git-send-email-tomaszx.kulasek@intel.com> <1477061177-15828-1-git-send-email-tomaszx.kulasek@intel.com> Subject: [dpdk-dev] [PATCH v8 6/6] testpmd: use Tx preparation in csum engine X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Removed pseudo header calculation for udp/tcp/tso packets from application and used Tx preparation API for packet preparation and verification. Adding aditional step to the csum engine costs about 3-4% of performance drop, on my setup with ixgbe driver. It's caused mostly by the need of reaccessing and modification of packet data. Signed-off-by: Tomasz Kulasek --- app/test-pmd/csumonly.c | 36 +++++++++++++----------------------- 1 file changed, 13 insertions(+), 23 deletions(-) diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c index 57e6ae2..6f33ae9 100644 --- a/app/test-pmd/csumonly.c +++ b/app/test-pmd/csumonly.c @@ -112,15 +112,6 @@ struct simple_gre_hdr { } __attribute__((__packed__)); static uint16_t -get_psd_sum(void *l3_hdr, uint16_t ethertype, uint64_t ol_flags) -{ - if (ethertype == _htons(ETHER_TYPE_IPv4)) - return rte_ipv4_phdr_cksum(l3_hdr, ol_flags); - else /* assume ethertype == ETHER_TYPE_IPv6 */ - return rte_ipv6_phdr_cksum(l3_hdr, ol_flags); -} - -static uint16_t get_udptcp_checksum(void *l3_hdr, void *l4_hdr, uint16_t ethertype) { if (ethertype == _htons(ETHER_TYPE_IPv4)) @@ -370,32 +361,24 @@ process_inner_cksums(void *l3_hdr, const struct testpmd_offload_info *info, /* do not recalculate udp cksum if it was 0 */ if (udp_hdr->dgram_cksum != 0) { udp_hdr->dgram_cksum = 0; - if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) { + if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) ol_flags |= PKT_TX_UDP_CKSUM; - udp_hdr->dgram_cksum = get_psd_sum(l3_hdr, - info->ethertype, ol_flags); - } else { + else udp_hdr->dgram_cksum = get_udptcp_checksum(l3_hdr, udp_hdr, info->ethertype); - } } } else if (info->l4_proto == IPPROTO_TCP) { tcp_hdr = (struct tcp_hdr *)((char *)l3_hdr + info->l3_len); tcp_hdr->cksum = 0; - if (tso_segsz) { + if (tso_segsz) ol_flags |= PKT_TX_TCP_SEG; - tcp_hdr->cksum = get_psd_sum(l3_hdr, info->ethertype, - ol_flags); - } else if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) { + else if (testpmd_ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ol_flags |= PKT_TX_TCP_CKSUM; - tcp_hdr->cksum = get_psd_sum(l3_hdr, info->ethertype, - ol_flags); - } else { + else tcp_hdr->cksum = get_udptcp_checksum(l3_hdr, tcp_hdr, info->ethertype); - } } else if (info->l4_proto == IPPROTO_SCTP) { sctp_hdr = (struct sctp_hdr *)((char *)l3_hdr + info->l3_len); sctp_hdr->cksum = 0; @@ -648,6 +631,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) void *l3_hdr = NULL, *outer_l3_hdr = NULL; /* can be IPv4 or IPv6 */ uint16_t nb_rx; uint16_t nb_tx; + uint16_t nb_prep; uint16_t i; uint64_t rx_ol_flags, tx_ol_flags; uint16_t testpmd_ol_flags; @@ -857,7 +841,13 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) printf("\n"); } } - nb_tx = rte_eth_tx_burst(fs->tx_port, fs->tx_queue, pkts_burst, nb_rx); + nb_prep = rte_eth_tx_prep(fs->tx_port, fs->tx_queue, pkts_burst, + nb_rx); + if (nb_prep != nb_rx) + printf("Preparing packet burst to transmit failed: %s\n", + rte_strerror(rte_errno)); + + nb_tx = rte_eth_tx_burst(fs->tx_port, fs->tx_queue, pkts_burst, nb_prep); /* * Retry if necessary */