From patchwork Tue Aug 19 17:22:17 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robbie King X-Patchwork-Id: 35647 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yh0-f69.google.com (mail-yh0-f69.google.com [209.85.213.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 6E9DC2034C for ; Tue, 19 Aug 2014 17:22:33 +0000 (UTC) Received: by mail-yh0-f69.google.com with SMTP id v1sf23161628yhn.0 for ; Tue, 19 Aug 2014 10:22:33 -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:date:from:message-id:to: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=glpRfymq5cdzMp/T1e3hIIbVJQ56poVWJzP649muEF4=; b=NLgN9izsKuMvh0pGBxKR10QwZejaU06YSOprD++sdZhi/1Qr2EU6nVa798n++xnwZC 117KujArzlSa1gQOaPLbiElGdTxyesOyARGbWg3BwXHElRVwScAQsFAHoWQkknTcP9/Q WYFT+HyarlnCDiJCPgkBROz/s3pfP9ap1KfVBBgGC4u9hm4QinTFVt/KpgPVouyOnApK 5lM817sV/y8tqh8HWgvdsIx5/pUb6YZLlBdc16L73H6Mb7abT2puYRK+fnogzV2z7x4P C5yRT3xFq8oXREMPa3Hk8HIx5BMPRa81uFm0WuWyg+QmYCJqQvDEFnaL+AmGbPmCYSQV +Ang== X-Gm-Message-State: ALoCoQmAUb1h2TLiR1fAk0+NMCDXPUp6ptsFrGnVFLvwb2uhJZ8+Z2QNNYoi82y93SiF+VGKKapx X-Received: by 10.236.4.41 with SMTP id 29mr18948860yhi.25.1408468953275; Tue, 19 Aug 2014 10:22:33 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.104.130 with SMTP id a2ls2831996qgf.90.gmail; Tue, 19 Aug 2014 10:22:33 -0700 (PDT) X-Received: by 10.220.97.5 with SMTP id j5mr31636230vcn.16.1408468953156; Tue, 19 Aug 2014 10:22:33 -0700 (PDT) Received: from mail-vc0-x234.google.com (mail-vc0-x234.google.com [2607:f8b0:400c:c03::234]) by mx.google.com with ESMTPS id f7si9212841vcs.34.2014.08.19.10.22.33 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 19 Aug 2014 10:22:33 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2607:f8b0:400c:c03::234 as permitted sender) client-ip=2607:f8b0:400c:c03::234; Received: by mail-vc0-f180.google.com with SMTP id ij19so7853091vcb.11 for ; Tue, 19 Aug 2014 10:22:33 -0700 (PDT) X-Received: by 10.52.119.229 with SMTP id kx5mr2436653vdb.40.1408468953086; Tue, 19 Aug 2014 10:22:33 -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.221.37.5 with SMTP id tc5csp256956vcb; Tue, 19 Aug 2014 10:22:31 -0700 (PDT) X-Received: by 10.140.30.180 with SMTP id d49mr64436653qgd.63.1408468951189; Tue, 19 Aug 2014 10:22:31 -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 s4si24783198qan.121.2014.08.19.10.22.30 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 19 Aug 2014 10:22:31 -0700 (PDT) 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-141-164-156.ec2.internal) by ip-10-141-164-156.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1XJn78-00022e-1F; Tue, 19 Aug 2014 17:22:30 +0000 Received: from alln-iport-8.cisco.com ([173.37.142.95]) by ip-10-141-164-156.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1XJn71-0001zG-P0 for lng-odp@lists.linaro.org; Tue, 19 Aug 2014 17:22:23 +0000 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ak0HAK6G81OtJA2I/2dsb2JhbABZgw20EQGeQIQoFneEMYEONIkjnQOkCBePaYMZgR0FsUWDeSGCfgEBAQ X-IronPort-AV: E=Sophos;i="5.01,896,1400025600"; d="scan'208";a="70580563" Received: from alln-core-3.cisco.com ([173.36.13.136]) by alln-iport-8.cisco.com with ESMTP; 19 Aug 2014 17:22:19 +0000 Received: from cpp-rtpbld-55.cisco.com (cpp-rtpbld-55.cisco.com [172.18.5.199]) by alln-core-3.cisco.com (8.14.5/8.14.5) with ESMTP id s7JHMHW4001436 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Tue, 19 Aug 2014 17:22:18 GMT Received: from cpp-rtpbld-55.cisco.com (localhost.localdomain [127.0.0.1]) by cpp-rtpbld-55.cisco.com (8.13.8/8.13.8) with ESMTP id s7JHMHcI014423 for ; Tue, 19 Aug 2014 13:22:17 -0400 Received: (from robking@localhost) by cpp-rtpbld-55.cisco.com (8.13.8/8.13.8/Submit) id s7JHMHED014422 for lng-odp@lists.linaro.org; Tue, 19 Aug 2014 13:22:17 -0400 Date: Tue, 19 Aug 2014 13:22:17 -0400 From: robking@cisco.com Message-Id: <201408191722.s7JHMHED014422@cpp-rtpbld-55.cisco.com> To: lng-odp@lists.linaro.org Subject: [lng-odp] ODP packet headroom example diff 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-Original-Sender: robking@cisco.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2607:f8b0:400c:c03::234 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org; dkim=fail header.i=@cisco.com Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Here is the diff I mentioned that I'm using to make progress on Cisco DP. diff --git a/platform/linux-generic/include/api/odp_pktio_socket.h b/platform/linux-generic/include/api/odp_pktio_socket.h index deeeeed..99f5904 100644 --- a/platform/linux-generic/include/api/odp_pktio_socket.h +++ b/platform/linux-generic/include/api/odp_pktio_socket.h @@ -16,6 +16,7 @@ extern "C" { typedef struct { odp_pktio_type_t type; int fanout; + int headroom; } socket_params_t; #ifdef __cplusplus diff --git a/platform/linux-generic/include/odp_packet_socket.h b/platform/linux-generic/include/odp_packet_socket.h index f991806..cc965a3 100644 --- a/platform/linux-generic/include/odp_packet_socket.h +++ b/platform/linux-generic/include/odp_packet_socket.h @@ -80,7 +80,7 @@ int setup_pkt_sock(pkt_sock_t * const pkt_sock, const char *netdev, odp_buffer_pool_t pool); int setup_pkt_sock_mmap(pkt_sock_mmap_t * const pkt_sock, const char *netdev, - odp_buffer_pool_t pool, int fanout); + odp_buffer_pool_t pool, socket_params_t *sock_params); /** * Close a packet socket diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c index 33ade10..3682c78 100644 --- a/platform/linux-generic/odp_packet_io.c +++ b/platform/linux-generic/odp_packet_io.c @@ -220,7 +220,7 @@ odp_pktio_t odp_pktio_open(const char *dev, odp_buffer_pool_t pool, break; case ODP_PKTIO_TYPE_SOCKET_MMAP: res = setup_pkt_sock_mmap(&pktio_entry->s.pkt_sock_mmap, dev, - pool, params->sock_params.fanout); + pool, ¶ms->sock_params); if (res == -1) { close_pkt_sock_mmap(&pktio_entry->s.pkt_sock_mmap); free_pktio_entry(id); diff --git a/platform/linux-generic/odp_packet_socket.c b/platform/linux-generic/odp_packet_socket.c index d44c333..49652a0 100644 --- a/platform/linux-generic/odp_packet_socket.c +++ b/platform/linux-generic/odp_packet_socket.c @@ -34,8 +34,8 @@ #include #include -#include #include +#include #include #include @@ -760,7 +760,7 @@ static int mmap_store_hw_addr(pkt_sock_mmap_t * const pkt_sock, * ODP_PACKET_SOCKET_MMAP: */ int setup_pkt_sock_mmap(pkt_sock_mmap_t * const pkt_sock, const char *netdev, - odp_buffer_pool_t pool, int fanout) + odp_buffer_pool_t pool, socket_params_t *sock_params) { odp_packet_t pkt; uint8_t *pkt_buf; @@ -781,6 +781,7 @@ int setup_pkt_sock_mmap(pkt_sock_mmap_t * const pkt_sock, const char *netdev, l2_hdr = ETHBUF_ALIGN(pkt_buf); /* Store eth buffer offset for pkt buffers from this pool */ pkt_sock->frame_offset = (uintptr_t)l2_hdr - (uintptr_t)pkt_buf; + pkt_sock->frame_offset += sock_params->headroom; odp_packet_free(pkt); @@ -815,7 +816,7 @@ int setup_pkt_sock_mmap(pkt_sock_mmap_t * const pkt_sock, const char *netdev, return -1; } - if (fanout) { + if (sock_params->fanout) { ret = set_pkt_sock_fanout_mmap(pkt_sock, if_idx); if (ret != 0) return -1;