From patchwork Thu Oct 19 12:00:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 116386 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp415547qgn; Thu, 19 Oct 2017 05:08:10 -0700 (PDT) X-Google-Smtp-Source: ABhQp+SZGBrvZ4eb+hlO6U+iLsvEAi20ItCBVhqXPgSgfYtQEhwjryigz2sECm/RWkd+rWiUvLmQ X-Received: by 10.36.73.164 with SMTP id e36mr1820713itd.129.1508414890811; Thu, 19 Oct 2017 05:08:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508414890; cv=none; d=google.com; s=arc-20160816; b=dTAr+zs/c3vibdSUc3HGnpqqCICWMrjG1Z/GqHdmfy05hMpyU1UbPjaILZwUYcLQio biB7u7xwJZQZ90mRgWgu3aWZ6z5UG1bK8bItexw7Nves0C/LZIw9bAk65bTd8BMVJnv6 BGQiRLjQOashWr2yWRey/wp9WjNvU2S2VRjCjHRx5szsLq4kG834V3e+QX8PMSI6TDKB LExgixEoW8oimtMIFDjKZnYAaMEYNlA2vS5Q5Wzogp/FOaoZcAy9uWNrEP3fou9zNLBD 9iu2ak7BqGSxfcAC0cn5DoewtB1Hw378JekeGuEVPU7GvagVrDtMCJbu3u2ogkdqex6f 4C8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=2+NpCMt0ANao8yN/oxfeRNpBYOayHs+8T4HY8J0z4QA=; b=zdRtYipMRRH2pdS2uUVW6u6nI6mR6z4nX+EdF4s9YIMrypGZhBzn0GTH4pYy3omu7r DQwnDXBwxY8zemkd479tdhbjGVGQgC+3pzi6jpbS6OOcE0Wf49mXWz+/RY+XGkco+797 Q2ZgP6D7UWWDhWSXK3NVSM/zkq5CqZaCc8OET9tfXGX4K80MbaPO3otQ81q+ePG+NtFB QYTQz0qbhr3gYuMqeVn7LsT+opLasuOK4z+8pvC9IKZSV7WPEsOVos2E6JF4rvUN10L9 /cO10lFdL8md/usxJnYKzzZ9hdbtjjga5Nsv4wyLMJJT6t+m6Yq+p2imSbwT5vXQpsv+ bOfg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (ec2-54-197-127-237.compute-1.amazonaws.com. [54.197.127.237]) by mx.google.com with ESMTP id 6si1153759itv.66.2017.10.19.05.08.10; Thu, 19 Oct 2017 05:08:10 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) client-ip=54.197.127.237; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id 4A15462E4A; Thu, 19 Oct 2017 12:08:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW,URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 51FF962C64; Thu, 19 Oct 2017 12:03:09 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 0B84C62A88; Thu, 19 Oct 2017 12:03:02 +0000 (UTC) Received: from forward106p.mail.yandex.net (forward106p.mail.yandex.net [77.88.28.109]) by lists.linaro.org (Postfix) with ESMTPS id 3D5D562ABF for ; Thu, 19 Oct 2017 12:00:25 +0000 (UTC) Received: from mxback7g.mail.yandex.net (mxback7g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:168]) by forward106p.mail.yandex.net (Yandex) with ESMTP id 063232D8524C for ; Thu, 19 Oct 2017 15:00:24 +0300 (MSK) Received: from smtp2o.mail.yandex.net (smtp2o.mail.yandex.net [2a02:6b8:0:1a2d::26]) by mxback7g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id FBQ83Ecopb-0Hk85IeK; Thu, 19 Oct 2017 15:00:17 +0300 Received: by smtp2o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id lZE2bfHgVf-0HIe9NHw; Thu, 19 Oct 2017 15:00:17 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Github ODP bot To: lng-odp@lists.linaro.org Date: Thu, 19 Oct 2017 15:00:04 +0300 Message-Id: <1508414408-10456-6-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1508414408-10456-1-git-send-email-odpbot@yandex.ru> References: <1508414408-10456-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 241 Subject: [lng-odp] [PATCH v1 5/9] linux-gen: pktio: tap: use generic pktio_ops data storage X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" From: Bogdan Pricope Signed-off-by: Bogdan Pricope --- /** Email created from pull request 241 (bogdanPricope:2_0_pktio_ops_pr) ** https://github.com/Linaro/odp/pull/241 ** Patch: https://github.com/Linaro/odp/pull/241.patch ** Base sha: 76f82972ecb51aa64215c97cb3d7f94e5de980f9 ** Merge commit sha: 24c411a2875cbcd686833666d481a0197cc82e90 **/ .../include/odp_pktio_ops_subsystem.h | 2 -- platform/linux-generic/include/odp_pktio_ops_tap.h | 1 + platform/linux-generic/pktio/tap.c | 34 +++++++++++++--------- 3 files changed, 21 insertions(+), 16 deletions(-) diff --git a/platform/linux-generic/include/odp_pktio_ops_subsystem.h b/platform/linux-generic/include/odp_pktio_ops_subsystem.h index d945a5cc1..56b7a5fcd 100644 --- a/platform/linux-generic/include/odp_pktio_ops_subsystem.h +++ b/platform/linux-generic/include/odp_pktio_ops_subsystem.h @@ -84,7 +84,6 @@ typedef ODP_MODULE_CLASS(pktio_ops) { #include #include #include -#include /* Per implementation private data * TODO: refactory each implementation to hide it internally @@ -94,7 +93,6 @@ typedef union { pktio_ops_ipc_data_t ipc; pktio_ops_netmap_data_t netmap; pktio_ops_pcap_data_t pcap; - pktio_ops_tap_data_t tap; } pktio_ops_data_t; /* Extract pktio ops data from pktio entry structure */ diff --git a/platform/linux-generic/include/odp_pktio_ops_tap.h b/platform/linux-generic/include/odp_pktio_ops_tap.h index e8e2e270e..d9ce8e71d 100644 --- a/platform/linux-generic/include/odp_pktio_ops_tap.h +++ b/platform/linux-generic/include/odp_pktio_ops_tap.h @@ -7,6 +7,7 @@ #ifndef ODP_PACKET_OPS_TAP_H_ #define ODP_PACKET_OPS_TAP_H_ +#include #include typedef struct { diff --git a/platform/linux-generic/pktio/tap.c b/platform/linux-generic/pktio/tap.c index 6cef64f18..e256eec3e 100644 --- a/platform/linux-generic/pktio/tap.c +++ b/platform/linux-generic/pktio/tap.c @@ -45,6 +45,7 @@ #include #include #include +#include #include #define BUF_SIZE 65536 @@ -66,7 +67,7 @@ static int tap_pktio_open(odp_pktio_t id ODP_UNUSED, int fd, skfd, flags; uint32_t mtu; struct ifreq ifr; - pktio_ops_tap_data_t *tap = &pktio_entry->ops_data(tap); + pktio_ops_tap_data_t *tap = odp_ops_data(pktio_entry, tap); if (strncmp(devname, "tap:", 4) != 0) return -1; @@ -166,7 +167,7 @@ static int tap_pktio_open(odp_pktio_t id ODP_UNUSED, static int tap_pktio_close(pktio_entry_t *pktio_entry) { int ret = 0; - pktio_ops_tap_data_t *tap = &pktio_entry->ops_data(tap); + pktio_ops_tap_data_t *tap = odp_ops_data(pktio_entry, tap); if (tap->fd != -1 && close(tap->fd) != 0) { __odp_errno = errno; @@ -186,6 +187,7 @@ static int tap_pktio_close(pktio_entry_t *pktio_entry) static odp_packet_t pack_odp_pkt(pktio_entry_t *pktio_entry, const void *data, unsigned int len, odp_time_t *ts) { + pktio_ops_tap_data_t *tap = odp_ops_data(pktio_entry, tap); odp_packet_t pkt; odp_packet_hdr_t *pkt_hdr; odp_packet_hdr_t parsed_hdr; @@ -193,13 +195,12 @@ static odp_packet_t pack_odp_pkt(pktio_entry_t *pktio_entry, const void *data, if (pktio_cls_enabled(pktio_entry)) { if (cls_classify_packet(pktio_entry, data, len, len, - &pktio_entry->ops_data(tap).pool, - &parsed_hdr)) { + &tap->pool, &parsed_hdr)) { return ODP_PACKET_INVALID; } } - num = packet_alloc_multi(pktio_entry->ops_data(tap).pool, len, &pkt, 1); + num = packet_alloc_multi(tap->pool, len, &pkt, 1); if (num != 1) return ODP_PACKET_INVALID; @@ -230,7 +231,7 @@ static int tap_pktio_recv(pktio_entry_t *pktio_entry, int index ODP_UNUSED, ssize_t retval; int i; uint8_t buf[BUF_SIZE]; - pktio_ops_tap_data_t *tap = &pktio_entry->ops_data(tap); + pktio_ops_tap_data_t *tap = odp_ops_data(pktio_entry, tap); odp_time_t ts_val; odp_time_t *ts = NULL; @@ -270,7 +271,7 @@ static int tap_pktio_send_lockless(pktio_entry_t *pktio_entry, int i, n; uint32_t pkt_len; uint8_t buf[BUF_SIZE]; - pktio_ops_tap_data_t *tap = &pktio_entry->ops_data(tap); + pktio_ops_tap_data_t *tap = odp_ops_data(pktio_entry, tap); for (i = 0; i < len; i++) { pkt_len = odp_packet_len(pkts[i]); @@ -332,11 +333,11 @@ static int tap_pktio_send(pktio_entry_t *pktio_entry, int index ODP_UNUSED, static uint32_t tap_mtu_get(pktio_entry_t *pktio_entry) { uint32_t ret; + pktio_ops_tap_data_t *tap = odp_ops_data(pktio_entry, tap); - ret = mtu_get_fd(pktio_entry->ops_data(tap).skfd, - pktio_entry->s.name + 4); + ret = mtu_get_fd(tap->skfd, pktio_entry->s.name + 4); if (ret > 0) - pktio_entry->ops_data(tap).mtu = ret; + tap->mtu = ret; return ret; } @@ -344,19 +345,24 @@ static uint32_t tap_mtu_get(pktio_entry_t *pktio_entry) static int tap_promisc_mode_set(pktio_entry_t *pktio_entry, odp_bool_t enable) { - return promisc_mode_set_fd(pktio_entry->ops_data(tap).skfd, + pktio_ops_tap_data_t *tap = odp_ops_data(pktio_entry, tap); + + return promisc_mode_set_fd(tap->skfd, pktio_entry->s.name + 4, enable); } static int tap_promisc_mode_get(pktio_entry_t *pktio_entry) { - return promisc_mode_get_fd(pktio_entry->ops_data(tap).skfd, - pktio_entry->s.name + 4); + pktio_ops_tap_data_t *tap = odp_ops_data(pktio_entry, tap); + + return promisc_mode_get_fd(tap->skfd, pktio_entry->s.name + 4); } static int tap_mac_addr_get(pktio_entry_t *pktio_entry, void *mac_addr) { - memcpy(mac_addr, pktio_entry->ops_data(tap).if_mac, ETH_ALEN); + pktio_ops_tap_data_t *tap = odp_ops_data(pktio_entry, tap); + + memcpy(mac_addr, tap->if_mac, ETH_ALEN); return ETH_ALEN; }