From patchwork Wed Apr 9 09:03:37 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ciprian Barbu X-Patchwork-Id: 28069 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ob0-f198.google.com (mail-ob0-f198.google.com [209.85.214.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id B26942145A for ; Wed, 9 Apr 2014 09:04:46 +0000 (UTC) Received: by mail-ob0-f198.google.com with SMTP id wn1sf9453095obc.1 for ; Wed, 09 Apr 2014 02:04:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:subject:precedence:list-id:list-unsubscribe:list-archive :list-post:list-help:list-subscribe:mime-version:errors-to:sender :x-original-sender:x-original-authentication-results:mailing-list :content-type:content-transfer-encoding; bh=1ZUKkwTDo+w5FfJG4RvN8/nvFcOOZeBEFwe7nRDeQNs=; b=mQGcYD5/xH6jCHFLegnrs29OFTWis4z5yIuNAoaufcO2CaEiv4qxxQN1LsqDWF9MMt VuMdOb3obL4pvAGh/Pkw4eQiJRZSSDbv9e+BKGpENifb630DUM1v+BJ54CFnrznY1+y6 lDxPG/x4mvhjYngBcGJByKnlEy0A6YqZFb5IQDj2dWe4vyot21Wnrec4Pefxach7UIgj zCW3CUhmrfMITPy8ppD8aY/vLVu3wEpbNeJKifyWWQQmkfMUWpcLiHMm1U/SZlH6eAKA GcupskSzSfkn71yPfQt2wbJYn1QVzwBGaCPN6REGAhZZ4s7g9oHXOaGMcNpssSh0s5gU sBmg== X-Gm-Message-State: ALoCoQlj1Y/bePu+OuvDeMb8jXv9FGvcGkqqjME/HedSt20m9Ua8DkS6TnyDXWU8+rymr5eKRUfm X-Received: by 10.182.33.98 with SMTP id q2mr4322283obi.43.1397034286204; Wed, 09 Apr 2014 02:04:46 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.46.33 with SMTP id j30ls552182qga.67.gmail; Wed, 09 Apr 2014 02:04:46 -0700 (PDT) X-Received: by 10.221.29.137 with SMTP id ry9mr7830022vcb.6.1397034286081; Wed, 09 Apr 2014 02:04:46 -0700 (PDT) Received: from mail-ve0-f172.google.com (mail-ve0-f172.google.com [209.85.128.172]) by mx.google.com with ESMTPS id cb3si48793vdc.41.2014.04.09.02.04.46 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 09 Apr 2014 02:04:46 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.172 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.172; Received: by mail-ve0-f172.google.com with SMTP id jx11so1868115veb.3 for ; Wed, 09 Apr 2014 02:04:46 -0700 (PDT) X-Received: by 10.58.219.233 with SMTP id pr9mr8003173vec.10.1397034285981; Wed, 09 Apr 2014 02:04:45 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.12.8 with SMTP id v8csp312804vcv; Wed, 9 Apr 2014 02:04:45 -0700 (PDT) X-Received: by 10.140.44.2 with SMTP id f2mr10158152qga.73.1397034285638; Wed, 09 Apr 2014 02:04:45 -0700 (PDT) Received: from ip-10-141-164-156.ec2.internal (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTPS id v10si126699qat.116.2014.04.09.02.04.45 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 09 Apr 2014 02:04:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Received: from localhost ([127.0.0.1] helo=ip-10-141-164-156.ec2.internal) by ip-10-141-164-156.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1WXoOh-0002Kt-31; Wed, 09 Apr 2014 09:02:19 +0000 Received: from mail-la0-f41.google.com ([209.85.215.41]) by ip-10-141-164-156.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1WXoNz-000132-JS for lng-odp@lists.linaro.org; Wed, 09 Apr 2014 09:01:35 +0000 Received: by mail-la0-f41.google.com with SMTP id gl10so930012lab.28 for ; Wed, 09 Apr 2014 02:03:55 -0700 (PDT) X-Received: by 10.112.24.9 with SMTP id q9mr6304761lbf.23.1397034234978; Wed, 09 Apr 2014 02:03:54 -0700 (PDT) Received: from sestofb10.enea.se (sestofw01.enea.se. [192.36.1.252]) by mx.google.com with ESMTPSA id x5sm334267lbk.5.2014.04.09.02.03.54 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 09 Apr 2014 02:03:54 -0700 (PDT) From: Ciprian Barbu To: lng-odp@lists.linaro.org Date: Wed, 9 Apr 2014 11:03:37 +0200 Message-Id: <1397034218-2971-5-git-send-email-ciprian.barbu@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1397034218-2971-1-git-send-email-ciprian.barbu@linaro.org> References: <1397034218-2971-1-git-send-email-ciprian.barbu@linaro.org> Subject: [lng-odp] [PATCH 4/5] Accept short frames from netmap software rings X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: lng-odp-bounces@lists.linaro.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ciprian.barbu@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.172 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Since packets from the network stack are mostly valid, we decided to pad them to a minimum of OD_ETH_LEN_MIN. The odp_packet_parse function is intended to be used for parsing frames for physical wired ethernet devices which are supposed to conform to IEEE 802.3 minimum frame length. Padding frames from the network stack (SW ring) is the prefered choice at the moment. Signed-off-by: Ciprian Barbu --- platform/linux-generic/source/odp_packet_netmap.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/platform/linux-generic/source/odp_packet_netmap.c b/platform/linux-generic/source/odp_packet_netmap.c index f5cc500..e54964b 100644 --- a/platform/linux-generic/source/odp_packet_netmap.c +++ b/platform/linux-generic/source/odp_packet_netmap.c @@ -292,14 +292,26 @@ int recv_pkt_netmap(pkt_netmap_t * const pkt_nm, odp_packet_t pkt_table[], rxring->head = nm_ring_next(rxring, cur); rxring->cur = rxring->head; + pkt_buf = odp_packet_buf_addr(pkt); + l2_hdr = pkt_buf + pkt_nm->frame_offset; + if (frame_len > pkt_nm->max_frame_len) { - ODP_ERR("Data partially lost %u %lu!\n", + ODP_ERR("RX: frame too big %u %lu!\n", frame_len, pkt_nm->max_frame_len); - frame_len = pkt_nm->max_frame_len; + /* drop the frame, reuse pkt next interation */ + continue; + } + if (odp_unlikely(frame_len < ODP_ETH_LEN_MIN)) { + if (odp_unlikely(pkt_nm->netmap_mode != + ODP_NETMAP_MODE_SW)) { + ODP_ERR("RX: Frame truncated: %u\n", + (unsigned)frame_len); + continue; + } + memset(l2_hdr + frame_len, 0, + ODP_ETH_LEN_MIN - frame_len); + frame_len = ODP_ETH_LEN_MIN; } - - pkt_buf = odp_packet_buf_addr(pkt); - l2_hdr = pkt_buf + pkt_nm->frame_offset; /* For now copy the data in the mbuf, worry about zero-copy later */