From patchwork Tue Apr 1 10:39:55 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ciprian Barbu X-Patchwork-Id: 27528 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f69.google.com (mail-la0-f69.google.com [209.85.215.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 0EC1320553 for ; Tue, 1 Apr 2014 10:40:04 +0000 (UTC) Received: by mail-la0-f69.google.com with SMTP id pn19sf7548581lab.0 for ; Tue, 01 Apr 2014 03:40:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:from:to:cc:subject:date:message-id :x-original-sender:x-original-authentication-results:precedence :mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe:content-type; bh=r+kIv+Di+sGjRNW5dlb55u70lk+3q15nPAIHeD35238=; b=Kyk0E4Bcn4a1DRkzipFZVDcg6Xv43IdzZJKd+WTVxEH2JiEjBjFiaNwKiwmfDMuOuS BmJ0YfpAjaqSLUERUelKUkap2fYSn9zJ1aw7YBkF4El4erwfuel3X1XkUUjMuWgRbq/G PsiGm9HkDEMCOvBtG00ghk/36yozY+rg19ZNJg2FuCpDFxFFe65qKJYsaDhSlEMX/+Da 3xod1vl90lAs6TgQ7GhgdyRwUubRz3Yk/bzd2B2UoJXLOz+M2SrHYc/5v/F6SKBJxx0V UkRUdwUng1mzemCqNnbGghkmiW8bwwF7mhxo2p2zYvXFkPyZZr3LjFkTOTla7xNYze+O ueeQ== X-Gm-Message-State: ALoCoQnUK1uPCTdpRyYGhtae5PIEOeXIGfG428M4Td0HUs/ByvLXCUHSMyfbVKAcOn4SGYJBptgf X-Received: by 10.112.50.50 with SMTP id z18mr13681861lbn.7.1396348802729; Tue, 01 Apr 2014 03:40:02 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: lng-odp@linaro.org Received: by 10.152.4.193 with SMTP id m1ls413247lam.39.gmail; Tue, 01 Apr 2014 03:40:02 -0700 (PDT) X-Received: by 10.152.3.72 with SMTP id a8mr1233424laa.33.1396348802497; Tue, 01 Apr 2014 03:40:02 -0700 (PDT) Received: from mail-la0-f41.google.com (mail-la0-f41.google.com [209.85.215.41]) by mx.google.com with ESMTPS id o6si10548872laj.162.2014.04.01.03.40.02 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 01 Apr 2014 03:40:02 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.215.41 is neither permitted nor denied by best guess record for domain of ciprian.barbu@linaro.org) client-ip=209.85.215.41; Received: by mail-la0-f41.google.com with SMTP id gl10so6983454lab.28 for ; Tue, 01 Apr 2014 03:40:02 -0700 (PDT) X-Received: by 10.112.47.3 with SMTP id z3mr1189725lbm.34.1396348802399; Tue, 01 Apr 2014 03:40:02 -0700 (PDT) Received: from sestofb10.enea.se (sestofw01.enea.se. [192.36.1.252]) by mx.google.com with ESMTPSA id bm3sm11856490lbb.12.2014.04.01.03.40.01 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 01 Apr 2014 03:40:01 -0700 (PDT) From: Ciprian Barbu To: lng-odp@linaro.org Cc: ciprian.barbu@linaro.org Subject: [lng-odp][PATCH v4] packet parsing modifications Date: Tue, 1 Apr 2014 12:39:55 +0200 Message-Id: <1396348796-43137-1-git-send-email-ciprian.barbu@linaro.org> X-Mailer: git-send-email 1.7.10.4 X-Original-Sender: ciprian.barbu@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.215.41 is neither permitted nor denied by best guess record for domain of ciprian.barbu@linaro.org) smtp.mail=ciprian.barbu@linaro.org Precedence: list Mailing-list: list lng-odp@linaro.org; contact lng-odp+owners@linaro.org List-ID: X-Google-Group-Id: 474323889996 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , This patch sets the minimum eth frame len for packets arrived from netmap. Additionally, if the packet was not received from the SW ring a debug message is printed. Signed-off-by: Ciprian Barbu --- platform/linux-generic/include/odp_packet_netmap.h | 5 +---- platform/linux-generic/source/odp_packet_netmap.c | 10 ++++++++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/platform/linux-generic/include/odp_packet_netmap.h b/platform/linux-generic/include/odp_packet_netmap.h index 960ccbf..9d5fb88 100644 --- a/platform/linux-generic/include/odp_packet_netmap.h +++ b/platform/linux-generic/include/odp_packet_netmap.h @@ -34,12 +34,9 @@ typedef struct { struct nm_desc_t *nm_desc; struct netmap_ring *rxring; struct netmap_ring *txring; - - /********************************/ odp_queue_t tx_access; /* Used for exclusive access to send packets */ uint32_t if_flags; - uint32_t if_reqcap; - uint32_t if_curcap; + int netmap_mode; char ifname[32]; } pkt_netmap_t; diff --git a/platform/linux-generic/source/odp_packet_netmap.c b/platform/linux-generic/source/odp_packet_netmap.c index 1cbd84c..2d459b9 100644 --- a/platform/linux-generic/source/odp_packet_netmap.c +++ b/platform/linux-generic/source/odp_packet_netmap.c @@ -131,6 +131,7 @@ int setup_pkt_netmap(pkt_netmap_t * const pkt_nm, char *netdev, pkt_nm->buf_size = odp_buffer_size(buf); /* max frame len taking into account the l2-offset */ pkt_nm->max_frame_len = pkt_nm->buf_size - pkt_nm->l2_offset; + pkt_nm->netmap_mode = nm_params->netmap_mode; odp_buffer_free(buf); @@ -293,10 +294,15 @@ int recv_pkt_netmap(pkt_netmap_t * const pkt_nm, odp_packet_t pkt_table[], rxring->head = nm_ring_next(rxring, cur); rxring->cur = nm_ring_next(rxring, cur); - if (payload_len > pkt_nm->max_frame_len) { + if (odp_unlikely(payload_len > pkt_nm->max_frame_len)) { ODP_ERR("Data partially lost %u %lu!\n", payload_len, pkt_nm->max_frame_len); payload_len = pkt_nm->max_frame_len; + } else if (odp_unlikely(payload_len < ODP_ETH_LEN_MIN)) { + if (odp_unlikely(pkt_nm->netmap_mode != ODP_NETMAP_MODE_SW)) + ODP_DBG("Frame appears to be truncated: %u\n", + (unsigned)payload_len); + payload_len = ODP_ETH_LEN_MIN; } pkt_buf = odp_packet_buf_addr(pkt); @@ -361,7 +367,7 @@ int send_pkt_netmap(pkt_netmap_t * const pkt_nm, odp_packet_t pkt_table[], txbuf = NETMAP_BUF(txring, slot->buf_idx); pkt = pkt_table[i]; - frame = odp_packet_l2(pkt); + frame = odp_packet_start(pkt); frame_len = odp_packet_get_len(pkt); memcpy(txbuf, frame, frame_len);