From patchwork Thu Oct 27 06:15:22 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Qiu X-Patchwork-Id: 687462 X-Patchwork-Delegate: diproiettod@vmware.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from archives.nicira.com (archives.nicira.com [96.126.127.54]) by ozlabs.org (Postfix) with ESMTP id 3t4Gyq5ZZHz9t2b for ; Thu, 27 Oct 2016 17:22:43 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=OcQbxtE4; dkim-atps=neutral Received: from archives.nicira.com (localhost [127.0.0.1]) by archives.nicira.com (Postfix) with ESMTP id 098C6101ED; Wed, 26 Oct 2016 23:22:43 -0700 (PDT) X-Original-To: dev@openvswitch.org Delivered-To: dev@openvswitch.org Received: from mx3v3.cudamail.com (mx3.cudamail.com [64.34.241.5]) by archives.nicira.com (Postfix) with ESMTPS id D153C101EE for ; Wed, 26 Oct 2016 23:22:41 -0700 (PDT) Received: from bar6.cudamail.com (localhost [127.0.0.1]) by mx3v3.cudamail.com (Postfix) with ESMTPS id 671D6162D96 for ; Thu, 27 Oct 2016 00:22:41 -0600 (MDT) X-ASG-Debug-ID: 1477549360-0b323724ec2168a0001-byXFYA Received: from mx1-pf1.cudamail.com ([192.168.24.1]) by bar6.cudamail.com with ESMTP id TrEhLmPzgnod0Xus (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Thu, 27 Oct 2016 00:22:40 -0600 (MDT) X-Barracuda-Envelope-From: qdy220091330@gmail.com X-Barracuda-RBL-Trusted-Forwarder: 192.168.24.1 Received: from unknown (HELO mail-pf0-f193.google.com) (209.85.192.193) by mx1-pf1.cudamail.com with ESMTPS (AES128-SHA encrypted); 27 Oct 2016 06:22:40 -0000 Received-SPF: pass (mx1-pf1.cudamail.com: SPF record at _netblocks.google.com designates 209.85.192.193 as permitted sender) X-Barracuda-Apparent-Source-IP: 209.85.192.193 X-Barracuda-RBL-IP: 209.85.192.193 Received: by mail-pf0-f193.google.com with SMTP id i85so1659211pfa.0 for ; Wed, 26 Oct 2016 23:22:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=vDz2wZvB8ybEvZJ9N8MDNK6mdNFPnFiAn9QHSD5Ka5s=; b=OcQbxtE4P4TGBaAMzlpRZEEyCgEy0F9xlgzHNjoWINR0shdgshOjDI/kerZjx+SPkT LBdGWdLtJrkx2R0LNkKcsUQzZNhOKbn6qVmiZFeIJzqIAssPenwhgcLkXuwrd4zTmMdU 6AQWvFzDbSbDx8G6JTVkd2UtA/Xrd+4e4TdDOo3R7zXF9okbU9MoYdTtDkN0KF5AB5N0 jsYCEaRLYW849cZmhKcNUDEeUmqYLqyqS3+DKKfagROF1jDDKHHNtWfivlMl58rQt+zm d2VFDBK6iOK4xXpeIaF6gPueiHSALKu5DRJpgx6mS/ott3ff+MjhbwzgxXOQFCCaD+IZ iSeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=vDz2wZvB8ybEvZJ9N8MDNK6mdNFPnFiAn9QHSD5Ka5s=; b=JNYdLN5C4GGJ72TjaeT+gWdFr2lLr7LrxGY8rhkrnSOkMM/RXmmXRbfwlMIw5lgRxF VjpvmnrtJcqq4iNsb+V8O/GA5+v8QVJr7OTIDzaqOttP7nKyuVsQEkAOd+BtbQimN/DK 0CheA2STEtKc2cl4qPlgWidIAiMqiCnF4QpeFWBeNzKuzputX1aDy2h9qlM9zWSWeNKj Vc1pLErX9oXa+8Ol9GnVbbQqM3/mGIzuFF+DyS0DumA1ctoydKQGhFOdpiKPc2G/074+ rjb8psvEtO9sAQ75kxIfYzZWjb+xf79io6EpV1CpGlgWNMMd23a5QPfR2XJZnl2C88uG 7NIQ== X-Gm-Message-State: ABUngvec9SJRz25mwaGoIbqiSgqgOraSJrNJVNdt3jLbG7eZnHw468ozOkZnCmzCQRn3Sw== X-Received: by 10.98.51.134 with SMTP id z128mr11418779pfz.163.1477549359785; Wed, 26 Oct 2016 23:22:39 -0700 (PDT) Received: from localhost.localdomain ([67.229.141.125]) by smtp.gmail.com with ESMTPSA id 141sm8410079pfw.63.2016.10.26.23.22.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 26 Oct 2016 23:22:39 -0700 (PDT) X-CudaMail-Envelope-Sender: qdy220091330@gmail.com From: Michael Qiu X-Google-Original-From: Michael Qiu To: dev@openvswitch.org X-CudaMail-MID: CM-E1-1026000325 X-CudaMail-DTE: 102716 X-CudaMail-Originating-IP: 209.85.192.193 Date: Thu, 27 Oct 2016 14:15:22 +0800 X-ASG-Orig-Subj: [##CM-E1-1026000325##][PATCH 3/5] lib/dp-packet: Fix data_len issue with multi-segments Message-Id: <1477548924-26376-4-git-send-email-qiudayu@chinac.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1477548924-26376-1-git-send-email-qiudayu@chinac.com> References: <1477548924-26376-1-git-send-email-qiudayu@chinac.com> X-Barracuda-Connect: UNKNOWN[192.168.24.1] X-Barracuda-Start-Time: 1477549360 X-Barracuda-Encrypted: ECDHE-RSA-AES256-GCM-SHA384 X-Barracuda-URL: https://web.cudamail.com:443/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at cudamail.com X-Barracuda-BRTS-Status: 1 X-Barracuda-Spam-Score: 0.60 X-Barracuda-Spam-Status: No, SCORE=0.60 using global scores of TAG_LEVEL=3.5 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=4.0 tests=BSF_SC5_MJ1963, DKIM_SIGNED, RDNS_NONE X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.34084 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- 0.00 DKIM_SIGNED Domain Keys Identified Mail: message has a signature 0.10 RDNS_NONE Delivered to trusted network by a host with no rDNS 0.50 BSF_SC5_MJ1963 Custom Rule MJ1963 Cc: Przemyslaw Lal , Marcin Ksiadz , Michael Qiu , kevin.traynor@intel.com Subject: [ovs-dev] [PATCH 3/5] lib/dp-packet: Fix data_len issue with multi-segments X-BeenThere: dev@openvswitch.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dev-bounces@openvswitch.org Sender: "dev" When a packet is from DPDK source, and it contains multipule segments, data_len is not equal to the packet size. This patch fix this issue. Signed-off-by: Michael Qiu Signed-off-by: Marcin Ksiadz Signed-off-by: Mark Kavanagh Signed-off-by: Przemyslaw Lal Signed-off-by: Yuanhan Liu --- lib/dp-packet.h | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/lib/dp-packet.h b/lib/dp-packet.h index 7c1e637..b5a55bb 100644 --- a/lib/dp-packet.h +++ b/lib/dp-packet.h @@ -24,6 +24,10 @@ #include "util.h" #include "netdev-dpdk.h" +#ifdef DPDK_NETDEV +#include "rte_ether.h" +#endif + #ifdef __cplusplus extern "C" { #endif @@ -409,17 +413,20 @@ dp_packet_size(const struct dp_packet *b) static inline void dp_packet_set_size(struct dp_packet *b, uint32_t v) { - /* netdev-dpdk does not currently support segmentation; consequently, for - * all intents and purposes, 'data_len' (16 bit) and 'pkt_len' (32 bit) may - * be used interchangably. - * - * On the datapath, it is expected that the size of packets - * (and thus 'v') will always be <= UINT16_MAX; this means that there is no - * loss of accuracy in assigning 'v' to 'data_len'. + /* + * Assign current segment length. If total length is greater than + * max data length in a segment, additional calculation is needed */ - b->mbuf.data_len = (uint16_t)v; /* Current seg length. */ - b->mbuf.pkt_len = v; /* Total length of all segments linked to - * this segment. */ + if (v > (b->mbuf.buf_len - b->mbuf.data_off)) { + b->mbuf.data_len = + (uint16_t)(b->mbuf.buf_len - b->mbuf.data_off); + } else { + b->mbuf.data_len = (uint16_t)v; + } + + /* Total length of all segments linked to + * this segment. */ + b->mbuf.pkt_len = v; } static inline uint16_t