From patchwork Wed Dec 17 23:16:25 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Fischofer X-Patchwork-Id: 42400 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f72.google.com (mail-ee0-f72.google.com [74.125.83.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id E664626C76 for ; Wed, 17 Dec 2014 23:16:52 +0000 (UTC) Received: by mail-ee0-f72.google.com with SMTP id e53sf145309eek.11 for ; Wed, 17 Dec 2014 15:16:52 -0800 (PST) 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:subject :precedence:list-id:list-unsubscribe:list-archive:list-post :list-help:list-subscribe:mime-version:content-type :content-transfer-encoding:errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=jqrYPAskTI5aH4SxEitjzlEFgYlcjVbq/cH3IXB7/r8=; b=VEzyQKjG60XrYhgnMxqFn3IoGd83vkmWuq0wVFbQIKfIAYuQNgh52Du4qTAzgGntds gp2HVUaxk+slMzMb+nBcVrlteUmISuCewOr/UvghilqNHwPeiYCONUJqjkeZW63k1uCz WJJ6qNJRcBThPpjuc7TFahcfnPYgrMDy6+UN346DpFrp9SmNv9ammn6M3Edoh5ZyFfXm Nkr1pBnYNAYaYxN+BzqZSMbQUslRGPU49uSE36nuhOs/6Y6BGjAhuO7+bMr2OnzNkBl8 3NqVMO45XjLqw6i5PzqPTfHJ0/1/vO6vtp9LecF1EqYg2oLo0JSHSH/kxoWURosdkTC1 h/YA== X-Gm-Message-State: ALoCoQkfO9LRSthYhJ8MW0XG/ZUcx8MyyOFa9EvsamA2/wiq6ggphIiUREu+RSxb03GxmkvP8KAs X-Received: by 10.194.173.97 with SMTP id bj1mr6851797wjc.2.1418858212085; Wed, 17 Dec 2014 15:16:52 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.198.235 with SMTP id jf11ls1105537lac.74.gmail; Wed, 17 Dec 2014 15:16:51 -0800 (PST) X-Received: by 10.152.7.229 with SMTP id m5mr44004483laa.80.1418858211916; Wed, 17 Dec 2014 15:16:51 -0800 (PST) Received: from mail-lb0-f172.google.com (mail-lb0-f172.google.com. [209.85.217.172]) by mx.google.com with ESMTPS id xz9si5127173lbb.126.2014.12.17.15.16.51 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 17 Dec 2014 15:16:51 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.172 as permitted sender) client-ip=209.85.217.172; Received: by mail-lb0-f172.google.com with SMTP id u10so68273lbd.3 for ; Wed, 17 Dec 2014 15:16:51 -0800 (PST) X-Received: by 10.152.37.7 with SMTP id u7mr19920558laj.74.1418858211447; Wed, 17 Dec 2014 15:16:51 -0800 (PST) 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.112.142.69 with SMTP id ru5csp1521402lbb; Wed, 17 Dec 2014 15:16:50 -0800 (PST) X-Received: by 10.224.114.133 with SMTP id e5mr78236141qaq.48.1418858209876; Wed, 17 Dec 2014 15:16:49 -0800 (PST) Received: from ip-10-35-177-41.ec2.internal (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTPS id y3si6260027qai.115.2014.12.17.15.16.48 (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 17 Dec 2014 15:16:49 -0800 (PST) Received-SPF: none (google.com: lng-odp-bounces@lists.linaro.org does not designate permitted sender hosts) client-ip=54.225.227.206; Received: from localhost ([127.0.0.1] helo=ip-10-35-177-41.ec2.internal) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1Y1Npl-0003Sk-W0; Wed, 17 Dec 2014 23:16:46 +0000 Received: from mail-ob0-f174.google.com ([209.85.214.174]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1Y1Npe-0003NN-CS for lng-odp@lists.linaro.org; Wed, 17 Dec 2014 23:16:38 +0000 Received: by mail-ob0-f174.google.com with SMTP id nt9so7620852obb.5 for ; Wed, 17 Dec 2014 15:16:33 -0800 (PST) X-Received: by 10.202.59.137 with SMTP id i131mr25771246oia.114.1418858193015; Wed, 17 Dec 2014 15:16:33 -0800 (PST) Received: from localhost.localdomain (cpe-24-28-70-239.austin.res.rr.com. [24.28.70.239]) by mx.google.com with ESMTPSA id v73sm2394860oie.19.2014.12.17.15.16.32 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 17 Dec 2014 15:16:32 -0800 (PST) From: Bill Fischofer To: lng-odp@lists.linaro.org Date: Wed, 17 Dec 2014 17:16:25 -0600 Message-Id: <1418858186-25251-1-git-send-email-bill.fischofer@linaro.org> X-Mailer: git-send-email 1.8.3.2 X-Topics: patch Subject: [lng-odp] [PATCH 1/2] linux-generic: packets: enable segmented packet support 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: bill.fischofer@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.172 as permitted sender) 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 Add segmented packet I/O support via sockets. RAW sockets limited to single segment. Signed-off-by: Bill Fischofer --- platform/linux-generic/odp_packet_socket.c | 33 +++++++++++++++++------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/platform/linux-generic/odp_packet_socket.c b/platform/linux-generic/odp_packet_socket.c index 2849065..340da88 100644 --- a/platform/linux-generic/odp_packet_socket.c +++ b/platform/linux-generic/odp_packet_socket.c @@ -321,7 +321,8 @@ int recv_pkt_sock_basic(pkt_sock_t *const pkt_sock, for (i = 0; i < len; i++) { if (odp_likely(pkt == ODP_PACKET_INVALID)) { - pkt = _odp_packet_alloc(pkt_sock->pool); + pkt = odp_packet_alloc(pkt_sock->pool, + pkt_sock->max_frame_len); if (odp_unlikely(pkt == ODP_PACKET_INVALID)) break; } @@ -339,7 +340,7 @@ int recv_pkt_sock_basic(pkt_sock_t *const pkt_sock, continue; /* Parse and set packet header data */ - packet_set_len(pkt, recv_bytes); + odp_packet_pull_tail(pkt, pkt_sock->max_frame_len - recv_bytes); _odp_packet_parse(pkt); pkt_table[nb_rx] = pkt; @@ -418,7 +419,8 @@ int recv_pkt_sock_mmsg(pkt_sock_t *const pkt_sock, memset(msgvec, 0, sizeof(msgvec)); for (i = 0; i < (int)len; i++) { - pkt_table[i] = _odp_packet_alloc(pkt_sock->pool); + pkt_table[i] = odp_packet_alloc(pkt_sock->pool, + pkt_sock->max_frame_len); if (odp_unlikely(pkt_table[i] == ODP_PACKET_INVALID)) break; @@ -445,7 +447,9 @@ int recv_pkt_sock_mmsg(pkt_sock_t *const pkt_sock, } /* Parse and set packet header data */ - packet_set_len(pkt_table[i], msgvec[i].msg_len); + odp_packet_pull_tail(pkt_table[i], + pkt_sock->max_frame_len - + msgvec[i].msg_len); _odp_packet_parse(pkt_table[i]); pkt_table[nb_rx] = pkt_table[i]; @@ -566,7 +570,6 @@ static inline unsigned pkt_mmap_v2_rx(int sock, struct ring *ring, uint8_t *pkt_buf; int pkt_len; struct ethhdr *eth_hdr; - uint8_t *l2_hdr; unsigned i = 0; (void)sock; @@ -591,13 +594,15 @@ static inline unsigned pkt_mmap_v2_rx(int sock, struct ring *ring, continue; } - pkt_table[i] = _odp_packet_alloc(pool); + pkt_table[i] = odp_packet_alloc(pool, pkt_len); if (odp_unlikely(pkt_table[i] == ODP_PACKET_INVALID)) break; - packet_set_len(pkt_table[i], pkt_len); - l2_hdr = odp_packet_data(pkt_table[i]); - memcpy(l2_hdr, pkt_buf, pkt_len); + if (odp_packet_copydata_in(pkt_table[i], 0, + pkt_len, pkt_buf) != 0) { + odp_packet_free(pkt_table[i]); + break; + } mmap_rx_user_ready(ppd.raw); @@ -620,7 +625,6 @@ static inline unsigned pkt_mmap_v2_tx(int sock, struct ring *ring, odp_packet_t pkt_table[], unsigned len) { union frame_map ppd; - uint8_t *pkt_buf; uint32_t pkt_len; unsigned frame_num, next_frame_num; int ret; @@ -634,13 +638,14 @@ static inline unsigned pkt_mmap_v2_tx(int sock, struct ring *ring, next_frame_num = (frame_num + 1) % ring->rd_num; - pkt_buf = odp_packet_l2_ptr(pkt_table[i], &pkt_len); - + pkt_len = odp_packet_len(pkt_table[i]); ppd.v2->tp_h.tp_snaplen = pkt_len; ppd.v2->tp_h.tp_len = pkt_len; - memcpy((uint8_t *)ppd.raw + TPACKET2_HDRLEN - - sizeof(struct sockaddr_ll), pkt_buf, pkt_len); + odp_packet_copydata_out(pkt_table[i], 0, pkt_len, + (uint8_t *)ppd.raw + + TPACKET2_HDRLEN - + sizeof(struct sockaddr_ll)); mmap_tx_user_ready(ppd.raw);