From patchwork Tue Oct 10 12:00:07 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: 115391 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp3667944qgn; Tue, 10 Oct 2017 05:04:05 -0700 (PDT) X-Google-Smtp-Source: AOwi7QBtnAbt5r1O3IUzM3mB3UUEhZYgRrHkht28r4tXZrdt2Jd1GDy5MrgOo3pkNjAFcP+nfooK X-Received: by 10.36.43.13 with SMTP id h13mr9598083ita.8.1507637045725; Tue, 10 Oct 2017 05:04:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507637045; cv=none; d=google.com; s=arc-20160816; b=QzRBIHWAIiTNv+ZnF7nTkT1GISGg0KeSO9ACQvYzdSjCRgUKV9+E4MkNv5uQNE83ci Q3oPDIdSD7H7N/MxnNEUNy4tlAy3vI8Zo9Sq3eCW28Ln5tFJQwGcrzFUmH4DJZUG7d6H WqWyuA6K9Tja66qfxQ9ELyemkWz1tCmPqOehaw2z93IhOG4ZhWqh2F6hOy08gYYHKq42 pB28iyE7tTSfJiEEMnHBKO4XDHBQhX4edmbzosEu/YBLnoH1mSuHAHAbhsXQfcCvyQ63 G5ge9wHDLVNPCPHUGu0b7waM4NmPnrTzxQEplLvIynBNF4Wn1hZuZKLxihbJbikFHEhb ivGQ== 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=8uYEpkGZgdMY8ytbQTFUxbQdHerNDsNoL61bUDDQzqI=; b=uD/Hsu1G9mD6KJsjFhic9OC9o3FdJrXAcCQOc+8PgdGdgAYnvPkHnSGuobtzdw8YDO ZeYwzNoRDV8doNg3mTthO/B4c29dRGy9fwjheQK8UbjCgD/GUycGLeSvlabGNytSkBp9 h2BxAlUF3ukRvKjHiQrvcklSET/j0I4vlBfG6ywcCEI7HJGU1eRSaFIGcC9suqoTpI8d rYnSob11wk43ZFJLl3Gg/kN2kHfwQ8aI0Mj7Akbn19pgdPLV4Wh1kvscvrors8RkA3zA tGGzJPGex4JvfzUFOYsveNXbCY44WwVcOvBavc/MPqvnkJFcdutfHM5z/WzkuDYKf8Aw +1Rg== 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 r38si8405372ioi.299.2017.10.10.05.04.04; Tue, 10 Oct 2017 05:04:05 -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 1AAC460C42; Tue, 10 Oct 2017 12:04:04 +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=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, 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 24E5D60C63; Tue, 10 Oct 2017 12:02:36 +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 0AC1A609FB; Tue, 10 Oct 2017 12:02:17 +0000 (UTC) Received: from forward103j.mail.yandex.net (forward103j.mail.yandex.net [5.45.198.246]) by lists.linaro.org (Postfix) with ESMTPS id 00BD660C8B for ; Tue, 10 Oct 2017 12:00:52 +0000 (UTC) Received: from mxback16j.mail.yandex.net (mxback16j.mail.yandex.net [IPv6:2a02:6b8:0:1619::92]) by forward103j.mail.yandex.net (Yandex) with ESMTP id 3B71934C3989 for ; Tue, 10 Oct 2017 15:00:50 +0300 (MSK) Received: from smtp4o.mail.yandex.net (smtp4o.mail.yandex.net [2a02:6b8:0:1a2d::28]) by mxback16j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id H8hpVN5WGE-0n9GO9ng; Tue, 10 Oct 2017 15:00:49 +0300 Received: by smtp4o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id NWf2cc9w7t-0mem9tUj; Tue, 10 Oct 2017 15:00:48 +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: Tue, 10 Oct 2017 15:00:07 +0300 Message-Id: <1507636815-18816-2-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1507636815-18816-1-git-send-email-odpbot@yandex.ru> References: <1507636815-18816-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 196 Subject: [lng-odp] [PATCH CLOUD-DEV v3 1/9] linux-gen: pktio: introduce 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 196 (bogdanPricope:cloud_dev_pktio_ops_data_pr) ** https://github.com/Linaro/odp/pull/196 ** Patch: https://github.com/Linaro/odp/pull/196.patch ** Base sha: 3d3c8f71f39ff139695d6f4b8e5ea17502c5f7cf ** Merge commit sha: 2bae88983ff377d83fcf9c99bf5c380275454327 **/ platform/linux-dpdk/include/odp_packet_io_internal.h | 5 ++++- platform/linux-generic/include/odp_packet_io_internal.h | 5 ++++- platform/linux-generic/include/odp_pktio_ops_subsystem.h | 7 +++++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/platform/linux-dpdk/include/odp_packet_io_internal.h b/platform/linux-dpdk/include/odp_packet_io_internal.h index 10760ca47..d31c449e2 100644 --- a/platform/linux-dpdk/include/odp_packet_io_internal.h +++ b/platform/linux-dpdk/include/odp_packet_io_internal.h @@ -42,7 +42,10 @@ typedef union pktio_entry_u pktio_entry_t; struct pktio_entry { const pktio_ops_module_t *ops; /**< Implementation specific methods */ - pktio_ops_data_t ops_data; + union { + pktio_ops_data_t ops_data; + uint8_t _ops_data[ODP_PKTIO_ODPS_DATA_MAX_SIZE]; + }; /* These two locks together lock the whole pktio device */ odp_ticketlock_t rxl; /**< RX ticketlock */ odp_ticketlock_t txl; /**< TX ticketlock */ diff --git a/platform/linux-generic/include/odp_packet_io_internal.h b/platform/linux-generic/include/odp_packet_io_internal.h index dacea47c9..79f5b1082 100644 --- a/platform/linux-generic/include/odp_packet_io_internal.h +++ b/platform/linux-generic/include/odp_packet_io_internal.h @@ -50,7 +50,10 @@ typedef union pktio_entry_u pktio_entry_t; struct pktio_entry { const pktio_ops_module_t *ops; /**< Implementation specific methods */ - pktio_ops_data_t ops_data; /**< IO operation specific data */ + union { + pktio_ops_data_t ops_data; /**< IO operation specific data */ + uint8_t _ops_data[ODP_PKTIO_ODPS_DATA_MAX_SIZE]; + }; /* These two locks together lock the whole pktio device */ odp_ticketlock_t rxl; /**< RX ticketlock */ odp_ticketlock_t txl; /**< TX ticketlock */ diff --git a/platform/linux-generic/include/odp_pktio_ops_subsystem.h b/platform/linux-generic/include/odp_pktio_ops_subsystem.h index 7a915b82c..a8da6197b 100644 --- a/platform/linux-generic/include/odp_pktio_ops_subsystem.h +++ b/platform/linux-generic/include/odp_pktio_ops_subsystem.h @@ -103,4 +103,11 @@ typedef union { /* Extract pktio ops data from pktio entry structure */ #define ops_data(mod) s.ops_data.mod +/* Maximum size of pktio specific ops data.*/ +#define ODP_PKTIO_ODPS_DATA_MAX_SIZE 80000 + +/* Extract pktio ops data from pktio entry structure */ +#define odp_ops_data(_p, _mod) \ + ((pktio_ops_ ## _mod ## _data_t *)(uintptr_t)_p->s._ops_data) + #endif From patchwork Tue Oct 10 12:00:08 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: 115392 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp3668910qgn; Tue, 10 Oct 2017 05:04:54 -0700 (PDT) X-Google-Smtp-Source: AOwi7QDi3/RtHhHjfTfXhpQpxGjrndQMNZAGGo2uH7f0s4fNErhnrVDsdLXvz4WbsfOQnkXXxkFg X-Received: by 10.36.129.197 with SMTP id q188mr17106722itd.72.1507637094560; Tue, 10 Oct 2017 05:04:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507637094; cv=none; d=google.com; s=arc-20160816; b=qb9V/ZlXPuD/iJo0SnqFWR7DVthv2Z+pxFi7NJyx8LRbRM/x+1W6l1iHN4Zkx+i37x PlMx6b32+TZVXQEaVENEDeQQoXPmwkxc7SHhfgFVxi5MsHTm2uZ5NUvDlxcIVid7cHUb FsVXclIQPr6b6d9MH4QSkvCirWbAc4cdFAUctL1WVFzbpEU/eD8JD/L9kNRDVFwDqaCa XYAVoEM5u6oUocWdneMZV2dAfi8Cc3lwtLEFLRSnp673PrDYSzF7gXGCI3yyqhzZlg6X zfMaJxi56p7J39z4DpTsl3SqmD4Pk/t8tB30bZ3ls+QrToGLUx8M90P5b+4UZiCeGdcD DIvw== 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=lVd9PJAjto5G2vAikrLFR1nzrg+9nXW+ihey6Wk7HfI=; b=0zfrDMPOguPqyeASwZvi3/COpuDcEIBCN9mYajnxmYe++5ICo95LIbf+eETe1sEz8r 6zWyjLJrESrDCpVJOIGO3WJkJASSC60+iJ47ngPS75LMmJdN+x8iHwrOhNevxIkQzr6a gC+eJZAfVTs/7cs1bi6mopnwG43zHPQqPhiLiZf7HUfOvDi0708T0icd6lamC3ewjSna d/hj9ABq+GJSK6SYhIHdMGjOrVC69bctWXQ+zjQs+xe556Cta4W1j4QSI82xCqwyfdMh xfYbQf24Ftj9aMDhAhzOFehWB96hGw7wfT+jv5aX393EPJCg2V5N3tN6T5LaA+/8UOqv qaSw== 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 h187si3239176ith.204.2017.10.10.05.04.52; Tue, 10 Oct 2017 05:04:54 -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 D1E7F60DB8; Tue, 10 Oct 2017 12:04:52 +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=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, 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 6BDFC60CA1; Tue, 10 Oct 2017 12:02:46 +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 F145560A4D; Tue, 10 Oct 2017 12:02:21 +0000 (UTC) Received: from forward100j.mail.yandex.net (forward100j.mail.yandex.net [5.45.198.240]) by lists.linaro.org (Postfix) with ESMTPS id D8CF860BFE for ; Tue, 10 Oct 2017 12:00:58 +0000 (UTC) Received: from mxback15g.mail.yandex.net (mxback15g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:94]) by forward100j.mail.yandex.net (Yandex) with ESMTP id 7470E5D8457E for ; Tue, 10 Oct 2017 15:00:57 +0300 (MSK) Received: from smtp4o.mail.yandex.net (smtp4o.mail.yandex.net [2a02:6b8:0:1a2d::28]) by mxback15g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id 4oYNq7m4fv-0pn8IPMR; Tue, 10 Oct 2017 15:00:51 +0300 Received: by smtp4o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id NWf2cc9w7t-0oeOrOd9; Tue, 10 Oct 2017 15:00:50 +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: Tue, 10 Oct 2017 15:00:08 +0300 Message-Id: <1507636815-18816-3-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1507636815-18816-1-git-send-email-odpbot@yandex.ru> References: <1507636815-18816-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 196 Subject: [lng-odp] [PATCH CLOUD-DEV v3 2/9] linux-gen: pktio: loopback: 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 196 (bogdanPricope:cloud_dev_pktio_ops_data_pr) ** https://github.com/Linaro/odp/pull/196 ** Patch: https://github.com/Linaro/odp/pull/196.patch ** Base sha: 3d3c8f71f39ff139695d6f4b8e5ea17502c5f7cf ** Merge commit sha: 2bae88983ff377d83fcf9c99bf5c380275454327 **/ .../include/odp_pktio_ops_subsystem.h | 2 -- platform/linux-generic/pktio/loopback.c | 33 ++++++++++++++++------ 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/platform/linux-generic/include/odp_pktio_ops_subsystem.h b/platform/linux-generic/include/odp_pktio_ops_subsystem.h index a8da6197b..415b8365f 100644 --- a/platform/linux-generic/include/odp_pktio_ops_subsystem.h +++ b/platform/linux-generic/include/odp_pktio_ops_subsystem.h @@ -80,7 +80,6 @@ typedef ODP_MODULE_CLASS(pktio_ops) { /* All implementations of this subsystem */ #include -#include #include #include #include @@ -92,7 +91,6 @@ typedef ODP_MODULE_CLASS(pktio_ops) { typedef union { void *dpdk; pktio_ops_ipc_data_t ipc; - pktio_ops_loopback_data_t loopback; pktio_ops_netmap_data_t netmap; pktio_ops_pcap_data_t pcap; pktio_ops_socket_data_t socket; diff --git a/platform/linux-generic/pktio/loopback.c b/platform/linux-generic/pktio/loopback.c index a3edc9d2a..e55f1cfe9 100644 --- a/platform/linux-generic/pktio/loopback.c +++ b/platform/linux-generic/pktio/loopback.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include @@ -21,6 +22,7 @@ #include #include #include +#include /* MAC address for the "loop" interface */ static const char pktio_loop_mac[] = {0x02, 0xe9, 0x34, 0x80, 0x73, 0x01}; @@ -30,6 +32,9 @@ static int loopback_stats_reset(pktio_entry_t *pktio_entry); static int loopback_open(odp_pktio_t id, pktio_entry_t *pktio_entry, const char *devname, odp_pool_t pool ODP_UNUSED) { + pktio_ops_loopback_data_t *pkt_lbk = + odp_ops_data(pktio_entry, loopback); + if (strcmp(devname, "loop")) return -1; @@ -37,10 +42,9 @@ static int loopback_open(odp_pktio_t id, pktio_entry_t *pktio_entry, snprintf(loopq_name, sizeof(loopq_name), "%" PRIu64 "-pktio_loopq", odp_pktio_to_u64(id)); - pktio_entry->ops_data(loopback).loopq = - odp_queue_create(loopq_name, NULL); + pkt_lbk->loopq = odp_queue_create(loopq_name, NULL); - if (pktio_entry->ops_data(loopback).loopq == ODP_QUEUE_INVALID) + if (pkt_lbk->loopq == ODP_QUEUE_INVALID) return -1; loopback_stats_reset(pktio_entry); @@ -50,7 +54,10 @@ static int loopback_open(odp_pktio_t id, pktio_entry_t *pktio_entry, static int loopback_close(pktio_entry_t *pktio_entry) { - return odp_queue_destroy(pktio_entry->ops_data(loopback).loopq); + pktio_ops_loopback_data_t *pkt_lbk = + odp_ops_data(pktio_entry, loopback); + + return odp_queue_destroy(pkt_lbk->loopq); } static int loopback_recv(pktio_entry_t *pktio_entry, int index ODP_UNUSED, @@ -65,13 +72,15 @@ static int loopback_recv(pktio_entry_t *pktio_entry, int index ODP_UNUSED, odp_time_t *ts = NULL; int num_rx = 0; int failed = 0; + pktio_ops_loopback_data_t *pkt_lbk = + odp_ops_data(pktio_entry, loopback); if (odp_unlikely(len > QUEUE_MULTI_MAX)) len = QUEUE_MULTI_MAX; odp_ticketlock_lock(&pktio_entry->s.rxl); - queue = queue_fn->from_ext(pktio_entry->ops_data(loopback).loopq); + queue = queue_fn->from_ext(pkt_lbk->loopq); nbr = queue_fn->deq_multi(queue, hdr_tbl, len); if (pktio_entry->s.config.pktin.bit.ts_all || @@ -155,6 +164,8 @@ static int loopback_send(pktio_entry_t *pktio_entry, int index ODP_UNUSED, int i; int ret; uint32_t bytes = 0; + pktio_ops_loopback_data_t *pkt_lbk = + odp_ops_data(pktio_entry, loopback); if (odp_unlikely(len > QUEUE_MULTI_MAX)) len = QUEUE_MULTI_MAX; @@ -166,7 +177,7 @@ static int loopback_send(pktio_entry_t *pktio_entry, int index ODP_UNUSED, odp_ticketlock_lock(&pktio_entry->s.txl); - queue = queue_fn->from_ext(pktio_entry->ops_data(loopback).loopq); + queue = queue_fn->from_ext(pkt_lbk->loopq); ret = queue_fn->enq_multi(queue, hdr_tbl, len); if (ret > 0) { @@ -219,13 +230,19 @@ static int loopback_capability(pktio_entry_t *pktio_entry ODP_UNUSED, static int loopback_promisc_mode_set(pktio_entry_t *pktio_entry, odp_bool_t enable) { - pktio_entry->ops_data(loopback).promisc = enable; + pktio_ops_loopback_data_t *pkt_lbk = + odp_ops_data(pktio_entry, loopback); + + pkt_lbk->promisc = enable; return 0; } static int loopback_promisc_mode_get(pktio_entry_t *pktio_entry) { - return pktio_entry->ops_data(loopback).promisc ? 1 : 0; + pktio_ops_loopback_data_t *pkt_lbk = + odp_ops_data(pktio_entry, loopback); + + return pkt_lbk->promisc ? 1 : 0; } static int loopback_stats(pktio_entry_t *pktio_entry, From patchwork Tue Oct 10 12:00:09 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: 115394 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp3671568qgn; Tue, 10 Oct 2017 05:07:07 -0700 (PDT) X-Google-Smtp-Source: AOwi7QC4BpPeI8LgCA8bb6z8O+05HYpW9sivrgAPk/jjG02SnOF5P9uEDyN+6u8FM5RANGnC6cVI X-Received: by 10.36.189.130 with SMTP id x124mr11234120ite.27.1507637227163; Tue, 10 Oct 2017 05:07:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507637227; cv=none; d=google.com; s=arc-20160816; b=M4XtAO0J8fjjTLsa276PF0JLnmK+Fx/8uY6O3q8u3jiaZzmSMzCoDAGgNire4NQ63A HMlVJs7wfWnE7w5JLUs7USosWMkxvUAK3Dgu7gqGigpmyC+RyhzTaij9f6p2K0aTO5XQ /nQkJnEa4fnN5Q1dGJyub1q0xoAdRTFbdW5+VDKhRHZeJtkhH9nTYG0R7ERdmno/3160 ntVZCxi2lHo1Jx2zDKg606II1KHvGYr5z7GBgSqIwuA2yqb6YdoUi9OGNDCHRNSO571W VBIhouwJbh6vLC18iEwSnsR3F+sZ3Jq/Gl/xizNdgijEyj4k0+PU5wKKCKZSkVg4BPXV pRKA== 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=+5bcrdMdl9h3iblx26j3sGNdibkbbcHonwTAT39uKYc=; b=ls2D73Rz4KsZLeayrFXwOMdKNn9/K+LDCopsRBEwztV6zQDibE4fIvLeC9quh0XKbR yovr4LG5sw7niqJiFdbpXwy6Jekg3+yw07RJGlXvyJHl/meQ2m0oqtnLoXgmAsM/ik3u MbnzJQ89wmzWYd/qLBoH/Vtg8fFb0ihqMEs/9AVpyDw2dLR0EWwVBaPBrY2hWlPMPF60 L2Htm/GYU9o21y2Naj7ZPJ4d42/Z9uvuLborsvA531rz1JyV9O9sBkmm/o9uzhA0mE+J 73SthXCVxlzcFIa4ppH8XkxPLp/KN8sD1IGY81QIEYOp4KiJbAUGEmU3gvBZz59SFuGa uQmg== 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 r65si8541481ith.105.2017.10.10.05.07.05; Tue, 10 Oct 2017 05:07:07 -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 5AD52607A9; Tue, 10 Oct 2017 12:07:05 +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,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,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 EA5BA60C35; Tue, 10 Oct 2017 12:03:05 +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 91D4460C1F; Tue, 10 Oct 2017 12:02:28 +0000 (UTC) Received: from forward104p.mail.yandex.net (forward104p.mail.yandex.net [77.88.28.107]) by lists.linaro.org (Postfix) with ESMTPS id 2270F60CA9 for ; Tue, 10 Oct 2017 12:01:00 +0000 (UTC) Received: from mxback8o.mail.yandex.net (mxback8o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::22]) by forward104p.mail.yandex.net (Yandex) with ESMTP id A7CAA182C72 for ; Tue, 10 Oct 2017 15:00:58 +0300 (MSK) Received: from smtp4o.mail.yandex.net (smtp4o.mail.yandex.net [2a02:6b8:0:1a2d::28]) by mxback8o.mail.yandex.net (nwsmtp/Yandex) with ESMTP id 7kasdswoD6-0wQSwUjA; Tue, 10 Oct 2017 15:00:58 +0300 Received: by smtp4o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id NWf2cc9w7t-0vea5lGR; Tue, 10 Oct 2017 15:00:57 +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: Tue, 10 Oct 2017 15:00:09 +0300 Message-Id: <1507636815-18816-4-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1507636815-18816-1-git-send-email-odpbot@yandex.ru> References: <1507636815-18816-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 196 Subject: [lng-odp] [PATCH CLOUD-DEV v3 3/9] linux-gen: pktio: socket: move common code away from socket pktios 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 196 (bogdanPricope:cloud_dev_pktio_ops_data_pr) ** https://github.com/Linaro/odp/pull/196 ** Patch: https://github.com/Linaro/odp/pull/196.patch ** Base sha: 3d3c8f71f39ff139695d6f4b8e5ea17502c5f7cf ** Merge commit sha: 2bae88983ff377d83fcf9c99bf5c380275454327 **/ platform/linux-generic/Makefile.am | 2 + .../linux-generic/include/odp_pktio_ops_socket.h | 76 ----- platform/linux-generic/pktio/common.c | 367 +++++++++++++++++++++ platform/linux-generic/pktio/common.h | 81 +++++ platform/linux-generic/pktio/dpdk.c | 1 + platform/linux-generic/pktio/ethtool.c | 1 + platform/linux-generic/pktio/ethtool.h | 15 + platform/linux-generic/pktio/netmap.c | 2 + platform/linux-generic/pktio/socket.c | 354 +------------------- platform/linux-generic/pktio/socket_mmap.c | 2 + platform/linux-generic/pktio/tap.c | 1 + 11 files changed, 474 insertions(+), 428 deletions(-) create mode 100644 platform/linux-generic/pktio/common.h create mode 100644 platform/linux-generic/pktio/ethtool.h diff --git a/platform/linux-generic/Makefile.am b/platform/linux-generic/Makefile.am index 539342dfb..6a1e0256d 100644 --- a/platform/linux-generic/Makefile.am +++ b/platform/linux-generic/Makefile.am @@ -186,6 +186,8 @@ noinst_HEADERS = \ ${srcdir}/include/odp_packet_internal.h \ ${srcdir}/include/odp_packet_io_internal.h \ ${srcdir}/include/odp_packet_io_ring_internal.h \ + ${srcdir}/pktio/ethtool.h \ + ${srcdir}/pktio/common.h \ ${srcdir}/pktio/dpdk.h \ ${srcdir}/include/odp_pktio_ops_ipc.h \ ${srcdir}/include/odp_pktio_ops_loopback.h \ diff --git a/platform/linux-generic/include/odp_pktio_ops_socket.h b/platform/linux-generic/include/odp_pktio_ops_socket.h index 32c49c08e..5ed444df7 100644 --- a/platform/linux-generic/include/odp_pktio_ops_socket.h +++ b/platform/linux-generic/include/odp_pktio_ops_socket.h @@ -93,80 +93,4 @@ ethaddrs_equal(unsigned char mac_a[], unsigned char mac_b[]) return !memcmp(mac_a, mac_b, ETH_ALEN); } -/** - * Read the MAC address from a packet socket - */ -int mac_addr_get_fd(int fd, const char *name, unsigned char mac_dst[]); - -/** - * Read the MTU from a packet socket - */ -uint32_t mtu_get_fd(int fd, const char *name); - -/** - * Enable/Disable promisc mode for a packet socket - */ -int promisc_mode_set_fd(int fd, const char *name, int enable); - -/** - * Return promisc mode of a packet socket - */ -int promisc_mode_get_fd(int fd, const char *name); - -/** - * Return link status of a packet socket (up/down) - */ -int link_status_fd(int fd, const char *name); - -/** - * Get enabled RSS hash protocols of a packet socket - * - * @param fd Socket file descriptor - * @param name Interface name - * @param hash_proto[out] Hash protocols - * - * @returns Number enabled hash protocols - */ -int rss_conf_get_fd(int fd, const char *name, - odp_pktin_hash_proto_t *hash_proto); - -/** - * Get supported RSS hash protocols of a packet socket - * - * Can be both read and modified. - * - * @param fd Socket file descriptor - * @param name Interface name - * @param hash_proto[out] Hash protocols - * - * @returns Number of supported hash protocols - */ -int rss_conf_get_supported_fd(int fd, const char *name, - odp_pktin_hash_proto_t *hash_proto); - -/** - * Set RSS hash protocols of a packet socket - * - * @param fd Socket file descriptor - * @param name Interface name - * @param hash_proto Hash protocols - * - * @retval 0 on success - * @retval <0 on failure - */ -int rss_conf_set_fd(int fd, const char *name, - const odp_pktin_hash_proto_t *proto); - -/** - * Print enabled RSS hash protocols - * - * @param hash_proto Hash protocols - */ -void rss_conf_print(const odp_pktin_hash_proto_t *hash_proto); - -/** - * Get ethtool statistics of a packet socket - */ -int ethtool_stats_get_fd(int fd, const char *name, odp_pktio_stats_t *stats); - #endif diff --git a/platform/linux-generic/pktio/common.c b/platform/linux-generic/pktio/common.c index 94add0615..4c952e467 100644 --- a/platform/linux-generic/pktio/common.c +++ b/platform/linux-generic/pktio/common.c @@ -9,7 +9,17 @@ #include #include +#include +#include #include +#include +#include +#include +#include +#include +#include +#include +#include int sock_stats_reset_fd(pktio_entry_t *pktio_entry, int fd) { @@ -82,3 +92,360 @@ int sock_stats_fd(pktio_entry_t *pktio_entry, return ret; } + +/* + * ODP_PACKET_SOCKET_MMSG: + * ODP_PACKET_SOCKET_MMAP: + * ODP_PACKET_NETMAP: + */ +uint32_t mtu_get_fd(int fd, const char *name) +{ + struct ifreq ifr; + int ret; + + snprintf(ifr.ifr_name, IF_NAMESIZE, "%s", name); + ret = ioctl(fd, SIOCGIFMTU, &ifr); + if (ret < 0) { + __odp_errno = errno; + ODP_DBG("ioctl(SIOCGIFMTU): %s: \"%s\".\n", strerror(errno), + ifr.ifr_name); + return 0; + } + return ifr.ifr_mtu; +} + +/** + * ODP_PACKET_SOCKET_MMSG: + * ODP_PACKET_SOCKET_MMAP: + * ODP_PACKET_NETMAP: + */ +int mac_addr_get_fd(int fd, const char *name, unsigned char mac_dst[]) +{ + struct ifreq ethreq; + int ret; + + memset(ðreq, 0, sizeof(ethreq)); + snprintf(ethreq.ifr_name, IF_NAMESIZE, "%s", name); + ret = ioctl(fd, SIOCGIFHWADDR, ðreq); + if (ret != 0) { + __odp_errno = errno; + ODP_ERR("ioctl(SIOCGIFHWADDR): %s: \"%s\".\n", strerror(errno), + ethreq.ifr_name); + return -1; + } + + memcpy(mac_dst, (unsigned char *)ethreq.ifr_ifru.ifru_hwaddr.sa_data, + ETH_ALEN); + return 0; +} + +/* + * ODP_PACKET_SOCKET_MMSG: + * ODP_PACKET_SOCKET_MMAP: + * ODP_PACKET_NETMAP: + */ +int promisc_mode_set_fd(int fd, const char *name, int enable) +{ + struct ifreq ifr; + int ret; + + snprintf(ifr.ifr_name, IF_NAMESIZE, "%s", name); + ret = ioctl(fd, SIOCGIFFLAGS, &ifr); + if (ret < 0) { + __odp_errno = errno; + ODP_DBG("ioctl(SIOCGIFFLAGS): %s: \"%s\".\n", strerror(errno), + ifr.ifr_name); + return -1; + } + + if (enable) + ifr.ifr_flags |= IFF_PROMISC; + else + ifr.ifr_flags &= ~(IFF_PROMISC); + + ret = ioctl(fd, SIOCSIFFLAGS, &ifr); + if (ret < 0) { + __odp_errno = errno; + ODP_DBG("ioctl(SIOCSIFFLAGS): %s: \"%s\".\n", strerror(errno), + ifr.ifr_name); + return -1; + } + return 0; +} + +/* + * ODP_PACKET_SOCKET_MMSG: + * ODP_PACKET_SOCKET_MMAP: + * ODP_PACKET_NETMAP: + */ +int promisc_mode_get_fd(int fd, const char *name) +{ + struct ifreq ifr; + int ret; + + snprintf(ifr.ifr_name, IF_NAMESIZE, "%s", name); + ret = ioctl(fd, SIOCGIFFLAGS, &ifr); + if (ret < 0) { + __odp_errno = errno; + ODP_DBG("ioctl(SIOCGIFFLAGS): %s: \"%s\".\n", strerror(errno), + ifr.ifr_name); + return -1; + } + + return !!(ifr.ifr_flags & IFF_PROMISC); +} + +/* + * ODP_PACKET_SOCKET_MMSG: + * ODP_PACKET_SOCKET_MMAP: + * ODP_PACKET_NETMAP: + */ +int link_status_fd(int fd, const char *name) +{ + struct ifreq ifr; + int ret; + + snprintf(ifr.ifr_name, IF_NAMESIZE, "%s", name); + ret = ioctl(fd, SIOCGIFFLAGS, &ifr); + if (ret < 0) { + __odp_errno = errno; + ODP_DBG("ioctl(SIOCGIFFLAGS): %s: \"%s\".\n", strerror(errno), + ifr.ifr_name); + return -1; + } + + return !!(ifr.ifr_flags & IFF_RUNNING); +} + +/** + * Get enabled hash options of a packet socket + * + * @param fd Socket file descriptor + * @param name Interface name + * @param flow_type Packet flow type + * @param options[out] Enabled hash options + * + * @retval 0 on success + * @retval <0 on failure + */ +static inline int get_rss_hash_options(int fd, const char *name, + uint32_t flow_type, uint64_t *options) +{ + struct ifreq ifr; + struct ethtool_rxnfc rsscmd; + + memset(&ifr, 0, sizeof(ifr)); + memset(&rsscmd, 0, sizeof(rsscmd)); + *options = 0; + + snprintf(ifr.ifr_name, IF_NAMESIZE, "%s", name); + + rsscmd.cmd = ETHTOOL_GRXFH; + rsscmd.flow_type = flow_type; + + ifr.ifr_data = (void *)&rsscmd; + + if (ioctl(fd, SIOCETHTOOL, &ifr) < 0) + return -1; + + *options = rsscmd.data; + return 0; +} + +int rss_conf_get_fd(int fd, const char *name, + odp_pktin_hash_proto_t *hash_proto) +{ + uint64_t options; + int rss_enabled = 0; + + memset(hash_proto, 0, sizeof(odp_pktin_hash_proto_t)); + + get_rss_hash_options(fd, name, IPV4_FLOW, &options); + if ((options & RXH_IP_SRC) && (options & RXH_IP_DST)) { + hash_proto->proto.ipv4 = 1; + rss_enabled++; + } + get_rss_hash_options(fd, name, TCP_V4_FLOW, &options); + if ((options & RXH_IP_SRC) && (options & RXH_IP_DST) && + (options & RXH_L4_B_0_1) && (options & RXH_L4_B_2_3)) { + hash_proto->proto.ipv4_tcp = 1; + rss_enabled++; + } + get_rss_hash_options(fd, name, UDP_V4_FLOW, &options); + if ((options & RXH_IP_SRC) && (options & RXH_IP_DST) && + (options & RXH_L4_B_0_1) && (options & RXH_L4_B_2_3)) { + hash_proto->proto.ipv4_udp = 1; + rss_enabled++; + } + get_rss_hash_options(fd, name, IPV6_FLOW, &options); + if ((options & RXH_IP_SRC) && (options & RXH_IP_DST)) { + hash_proto->proto.ipv6 = 1; + rss_enabled++; + } + get_rss_hash_options(fd, name, TCP_V6_FLOW, &options); + if ((options & RXH_IP_SRC) && (options & RXH_IP_DST) && + (options & RXH_L4_B_0_1) && (options & RXH_L4_B_2_3)) { + hash_proto->proto.ipv6_tcp = 1; + rss_enabled++; + } + get_rss_hash_options(fd, name, UDP_V6_FLOW, &options); + if ((options & RXH_IP_SRC) && (options & RXH_IP_DST) && + (options & RXH_L4_B_0_1) && (options & RXH_L4_B_2_3)) { + hash_proto->proto.ipv6_udp = 1; + rss_enabled++; + } + return rss_enabled; +} + +/** + * Set hash options of a packet socket + * + * @param fd Socket file descriptor + * @param name Interface name + * @param flow_type Packet flow type + * @param options Hash options + * + * @retval 0 on success + * @retval <0 on failure + */ +static inline int set_rss_hash(int fd, const char *name, + uint32_t flow_type, uint64_t options) +{ + struct ifreq ifr; + struct ethtool_rxnfc rsscmd; + + memset(&rsscmd, 0, sizeof(rsscmd)); + + snprintf(ifr.ifr_name, IF_NAMESIZE, "%s", name); + + rsscmd.cmd = ETHTOOL_SRXFH; + rsscmd.flow_type = flow_type; + rsscmd.data = options; + + ifr.ifr_data = (void *)&rsscmd; + + if (ioctl(fd, SIOCETHTOOL, &ifr) < 0) + return -1; + + return 0; +} + +int rss_conf_set_fd(int fd, const char *name, + const odp_pktin_hash_proto_t *hash_proto) +{ + uint64_t options; + odp_pktin_hash_proto_t cur_hash; + + /* Compare to currently set hash protocols */ + rss_conf_get_fd(fd, name, &cur_hash); + + if (hash_proto->proto.ipv4_udp && !cur_hash.proto.ipv4_udp) { + options = RXH_IP_SRC | RXH_IP_DST | RXH_L4_B_0_1 | RXH_L4_B_2_3; + if (set_rss_hash(fd, name, UDP_V4_FLOW, options)) + return -1; + } + if (hash_proto->proto.ipv4_tcp && !cur_hash.proto.ipv4_tcp) { + options = RXH_IP_SRC | RXH_IP_DST | RXH_L4_B_0_1 | RXH_L4_B_2_3; + if (set_rss_hash(fd, name, TCP_V4_FLOW, options)) + return -1; + } + if (hash_proto->proto.ipv6_udp && !cur_hash.proto.ipv6_udp) { + options = RXH_IP_SRC | RXH_IP_DST | RXH_L4_B_0_1 | RXH_L4_B_2_3; + if (set_rss_hash(fd, name, UDP_V6_FLOW, options)) + return -1; + } + if (hash_proto->proto.ipv6_tcp && !cur_hash.proto.ipv6_tcp) { + options = RXH_IP_SRC | RXH_IP_DST | RXH_L4_B_0_1 | RXH_L4_B_2_3; + if (set_rss_hash(fd, name, TCP_V6_FLOW, options)) + return -1; + } + if (hash_proto->proto.ipv4 && !cur_hash.proto.ipv4) { + options = RXH_IP_SRC | RXH_IP_DST; + if (set_rss_hash(fd, name, IPV4_FLOW, options)) + return -1; + } + if (hash_proto->proto.ipv6 && !cur_hash.proto.ipv6) { + options = RXH_IP_SRC | RXH_IP_DST; + if (set_rss_hash(fd, name, IPV6_FLOW, options)) + return -1; + } + return 0; +} + +int rss_conf_get_supported_fd(int fd, const char *name, + odp_pktin_hash_proto_t *hash_proto) +{ + uint64_t options; + int rss_supported = 0; + + memset(hash_proto, 0, sizeof(odp_pktin_hash_proto_t)); + + if (!get_rss_hash_options(fd, name, IPV4_FLOW, &options)) { + if (!set_rss_hash(fd, name, IPV4_FLOW, options)) { + hash_proto->proto.ipv4 = 1; + rss_supported++; + } + } + if (!get_rss_hash_options(fd, name, TCP_V4_FLOW, &options)) { + if (!set_rss_hash(fd, name, TCP_V4_FLOW, options)) { + hash_proto->proto.ipv4_tcp = 1; + rss_supported++; + } + } + if (!get_rss_hash_options(fd, name, UDP_V4_FLOW, &options)) { + if (!set_rss_hash(fd, name, UDP_V4_FLOW, options)) { + hash_proto->proto.ipv4_udp = 1; + rss_supported++; + } + } + if (!get_rss_hash_options(fd, name, IPV6_FLOW, &options)) { + if (!set_rss_hash(fd, name, IPV6_FLOW, options)) { + hash_proto->proto.ipv6 = 1; + rss_supported++; + } + } + if (!get_rss_hash_options(fd, name, TCP_V6_FLOW, &options)) { + if (!set_rss_hash(fd, name, TCP_V6_FLOW, options)) { + hash_proto->proto.ipv6_tcp = 1; + rss_supported++; + } + } + if (!get_rss_hash_options(fd, name, UDP_V6_FLOW, &options)) { + if (!set_rss_hash(fd, name, UDP_V6_FLOW, options)) { + hash_proto->proto.ipv6_udp = 1; + rss_supported++; + } + } + return rss_supported; +} + +void rss_conf_print(const odp_pktin_hash_proto_t *hash_proto) +{ int max_len = 512; + char str[max_len]; + int len = 0; + int n = max_len - 1; + + len += snprintf(&str[len], n - len, " rss conf\n"); + + if (hash_proto->proto.ipv4) + len += snprintf(&str[len], n - len, + " IPV4\n"); + if (hash_proto->proto.ipv4_tcp) + len += snprintf(&str[len], n - len, + " IPV4 TCP\n"); + if (hash_proto->proto.ipv4_udp) + len += snprintf(&str[len], n - len, + " IPV4 UDP\n"); + if (hash_proto->proto.ipv6) + len += snprintf(&str[len], n - len, + " IPV6\n"); + if (hash_proto->proto.ipv6_tcp) + len += snprintf(&str[len], n - len, + " IPV6 TCP\n"); + if (hash_proto->proto.ipv6_udp) + len += snprintf(&str[len], n - len, + " IPV6 UDP\n"); + str[len] = '\0'; + + ODP_PRINT("%s\n", str); +} diff --git a/platform/linux-generic/pktio/common.h b/platform/linux-generic/pktio/common.h new file mode 100644 index 000000000..2940af143 --- /dev/null +++ b/platform/linux-generic/pktio/common.h @@ -0,0 +1,81 @@ +/* Copyright (c) 2016, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef ODP_PKTIO_COMMON_H_ +#define ODP_PKTIO_COMMON_H_ + +/** + * Read the MTU from a packet socket + */ +uint32_t mtu_get_fd(int fd, const char *name); + +/** + * Read the MAC address from a packet socket + */ +int mac_addr_get_fd(int fd, const char *name, unsigned char mac_dst[]); + +/** + * Enable/Disable promisc mode for a packet socket + */ +int promisc_mode_set_fd(int fd, const char *name, int enable); + +/** + * Return promisc mode of a packet socket + */ +int promisc_mode_get_fd(int fd, const char *name); + +/** + * Return link status of a packet socket (up/down) + */ +int link_status_fd(int fd, const char *name); + +/** + * Get enabled RSS hash protocols of a packet socket + * + * @param fd Socket file descriptor + * @param name Interface name + * @param hash_proto[out] Hash protocols + * + * @returns Number enabled hash protocols + */ +int rss_conf_get_fd(int fd, const char *name, + odp_pktin_hash_proto_t *hash_proto); + +/** + * Get supported RSS hash protocols of a packet socket + * + * Can be both read and modified. + * + * @param fd Socket file descriptor + * @param name Interface name + * @param hash_proto[out] Hash protocols + * + * @returns Number of supported hash protocols + */ +int rss_conf_get_supported_fd(int fd, const char *name, + odp_pktin_hash_proto_t *hash_proto); + +/** + * Set RSS hash protocols of a packet socket + * + * @param fd Socket file descriptor + * @param name Interface name + * @param hash_proto Hash protocols + * + * @retval 0 on success + * @retval <0 on failure + */ +int rss_conf_set_fd(int fd, const char *name, + const odp_pktin_hash_proto_t *proto); + +/** + * Print enabled RSS hash protocols + * + * @param hash_proto Hash protocols + */ +void rss_conf_print(const odp_pktin_hash_proto_t *hash_proto); + +#endif /*ODP_PKTIO_COMMON_H_*/ diff --git a/platform/linux-generic/pktio/dpdk.c b/platform/linux-generic/pktio/dpdk.c index bbe8ddda4..484af82c5 100644 --- a/platform/linux-generic/pktio/dpdk.c +++ b/platform/linux-generic/pktio/dpdk.c @@ -24,6 +24,7 @@ #include #include +#include #include #include diff --git a/platform/linux-generic/pktio/ethtool.c b/platform/linux-generic/pktio/ethtool.c index b41ce4440..b71666a32 100644 --- a/platform/linux-generic/pktio/ethtool.c +++ b/platform/linux-generic/pktio/ethtool.c @@ -19,6 +19,7 @@ #include #include #include +#include static struct ethtool_gstrings *get_stringset(int fd, struct ifreq *ifr) { diff --git a/platform/linux-generic/pktio/ethtool.h b/platform/linux-generic/pktio/ethtool.h new file mode 100644 index 000000000..c5a811238 --- /dev/null +++ b/platform/linux-generic/pktio/ethtool.h @@ -0,0 +1,15 @@ +/* Copyright (c) 2016, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef ODP_PKTIO_ETHTOOL_H_ +#define ODP_PKTIO_ETHTOOL_H_ + +/** + * Get ethtool statistics of a packet socket + */ +int ethtool_stats_get_fd(int fd, const char *name, odp_pktio_stats_t *stats); + +#endif /*ODP_PKTIO_ETHTOOL_H_*/ diff --git a/platform/linux-generic/pktio/netmap.c b/platform/linux-generic/pktio/netmap.c index e2d4baa54..49d38f7f2 100644 --- a/platform/linux-generic/pktio/netmap.c +++ b/platform/linux-generic/pktio/netmap.c @@ -24,6 +24,8 @@ #include #include #include +#include +#include #include diff --git a/platform/linux-generic/pktio/socket.c b/platform/linux-generic/pktio/socket.c index 55d2e27cd..145f56014 100644 --- a/platform/linux-generic/pktio/socket.c +++ b/platform/linux-generic/pktio/socket.c @@ -43,6 +43,8 @@ #include #include #include +#include +#include #include #include @@ -99,358 +101,6 @@ int sendmmsg(int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags) #define ETHBUF_ALIGN(buf_ptr) ((uint8_t *)ODP_ALIGN_ROUNDUP_PTR((buf_ptr), \ sizeof(uint32_t)) + ETHBUF_OFFSET) -/** - * ODP_PACKET_SOCKET_MMSG: - * ODP_PACKET_SOCKET_MMAP: - * ODP_PACKET_NETMAP: - */ -int mac_addr_get_fd(int fd, const char *name, unsigned char mac_dst[]) -{ - struct ifreq ethreq; - int ret; - - memset(ðreq, 0, sizeof(ethreq)); - snprintf(ethreq.ifr_name, IF_NAMESIZE, "%s", name); - ret = ioctl(fd, SIOCGIFHWADDR, ðreq); - if (ret != 0) { - __odp_errno = errno; - ODP_ERR("ioctl(SIOCGIFHWADDR): %s: \"%s\".\n", strerror(errno), - ethreq.ifr_name); - return -1; - } - - memcpy(mac_dst, (unsigned char *)ethreq.ifr_ifru.ifru_hwaddr.sa_data, - ETH_ALEN); - return 0; -} - -/* - * ODP_PACKET_SOCKET_MMSG: - * ODP_PACKET_SOCKET_MMAP: - * ODP_PACKET_NETMAP: - */ -uint32_t mtu_get_fd(int fd, const char *name) -{ - struct ifreq ifr; - int ret; - - snprintf(ifr.ifr_name, IF_NAMESIZE, "%s", name); - ret = ioctl(fd, SIOCGIFMTU, &ifr); - if (ret < 0) { - __odp_errno = errno; - ODP_DBG("ioctl(SIOCGIFMTU): %s: \"%s\".\n", strerror(errno), - ifr.ifr_name); - return 0; - } - return ifr.ifr_mtu; -} - -/* - * ODP_PACKET_SOCKET_MMSG: - * ODP_PACKET_SOCKET_MMAP: - * ODP_PACKET_NETMAP: - */ -int promisc_mode_set_fd(int fd, const char *name, int enable) -{ - struct ifreq ifr; - int ret; - - snprintf(ifr.ifr_name, IF_NAMESIZE, "%s", name); - ret = ioctl(fd, SIOCGIFFLAGS, &ifr); - if (ret < 0) { - __odp_errno = errno; - ODP_DBG("ioctl(SIOCGIFFLAGS): %s: \"%s\".\n", strerror(errno), - ifr.ifr_name); - return -1; - } - - if (enable) - ifr.ifr_flags |= IFF_PROMISC; - else - ifr.ifr_flags &= ~(IFF_PROMISC); - - ret = ioctl(fd, SIOCSIFFLAGS, &ifr); - if (ret < 0) { - __odp_errno = errno; - ODP_DBG("ioctl(SIOCSIFFLAGS): %s: \"%s\".\n", strerror(errno), - ifr.ifr_name); - return -1; - } - return 0; -} - -/* - * ODP_PACKET_SOCKET_MMSG: - * ODP_PACKET_SOCKET_MMAP: - * ODP_PACKET_NETMAP: - */ -int promisc_mode_get_fd(int fd, const char *name) -{ - struct ifreq ifr; - int ret; - - snprintf(ifr.ifr_name, IF_NAMESIZE, "%s", name); - ret = ioctl(fd, SIOCGIFFLAGS, &ifr); - if (ret < 0) { - __odp_errno = errno; - ODP_DBG("ioctl(SIOCGIFFLAGS): %s: \"%s\".\n", strerror(errno), - ifr.ifr_name); - return -1; - } - - return !!(ifr.ifr_flags & IFF_PROMISC); -} - -int link_status_fd(int fd, const char *name) -{ - struct ifreq ifr; - int ret; - - snprintf(ifr.ifr_name, IF_NAMESIZE, "%s", name); - ret = ioctl(fd, SIOCGIFFLAGS, &ifr); - if (ret < 0) { - __odp_errno = errno; - ODP_DBG("ioctl(SIOCGIFFLAGS): %s: \"%s\".\n", strerror(errno), - ifr.ifr_name); - return -1; - } - - return !!(ifr.ifr_flags & IFF_RUNNING); -} - -/** - * Get enabled hash options of a packet socket - * - * @param fd Socket file descriptor - * @param name Interface name - * @param flow_type Packet flow type - * @param options[out] Enabled hash options - * - * @retval 0 on success - * @retval <0 on failure - */ -static inline int get_rss_hash_options(int fd, const char *name, - uint32_t flow_type, uint64_t *options) -{ - struct ifreq ifr; - struct ethtool_rxnfc rsscmd; - - memset(&ifr, 0, sizeof(ifr)); - memset(&rsscmd, 0, sizeof(rsscmd)); - *options = 0; - - snprintf(ifr.ifr_name, IF_NAMESIZE, "%s", name); - - rsscmd.cmd = ETHTOOL_GRXFH; - rsscmd.flow_type = flow_type; - - ifr.ifr_data = (caddr_t)&rsscmd; - - if (ioctl(fd, SIOCETHTOOL, &ifr) < 0) - return -1; - - *options = rsscmd.data; - return 0; -} - -int rss_conf_get_fd(int fd, const char *name, - odp_pktin_hash_proto_t *hash_proto) -{ - uint64_t options; - int rss_enabled = 0; - - memset(hash_proto, 0, sizeof(odp_pktin_hash_proto_t)); - - get_rss_hash_options(fd, name, IPV4_FLOW, &options); - if ((options & RXH_IP_SRC) && (options & RXH_IP_DST)) { - hash_proto->proto.ipv4 = 1; - rss_enabled++; - } - get_rss_hash_options(fd, name, TCP_V4_FLOW, &options); - if ((options & RXH_IP_SRC) && (options & RXH_IP_DST) && - (options & RXH_L4_B_0_1) && (options & RXH_L4_B_2_3)) { - hash_proto->proto.ipv4_tcp = 1; - rss_enabled++; - } - get_rss_hash_options(fd, name, UDP_V4_FLOW, &options); - if ((options & RXH_IP_SRC) && (options & RXH_IP_DST) && - (options & RXH_L4_B_0_1) && (options & RXH_L4_B_2_3)) { - hash_proto->proto.ipv4_udp = 1; - rss_enabled++; - } - get_rss_hash_options(fd, name, IPV6_FLOW, &options); - if ((options & RXH_IP_SRC) && (options & RXH_IP_DST)) { - hash_proto->proto.ipv6 = 1; - rss_enabled++; - } - get_rss_hash_options(fd, name, TCP_V6_FLOW, &options); - if ((options & RXH_IP_SRC) && (options & RXH_IP_DST) && - (options & RXH_L4_B_0_1) && (options & RXH_L4_B_2_3)) { - hash_proto->proto.ipv6_tcp = 1; - rss_enabled++; - } - get_rss_hash_options(fd, name, UDP_V6_FLOW, &options); - if ((options & RXH_IP_SRC) && (options & RXH_IP_DST) && - (options & RXH_L4_B_0_1) && (options & RXH_L4_B_2_3)) { - hash_proto->proto.ipv6_udp = 1; - rss_enabled++; - } - return rss_enabled; -} - -/** - * Set hash options of a packet socket - * - * @param fd Socket file descriptor - * @param name Interface name - * @param flow_type Packet flow type - * @param options Hash options - * - * @retval 0 on success - * @retval <0 on failure - */ -static inline int set_rss_hash(int fd, const char *name, - uint32_t flow_type, uint64_t options) -{ - struct ifreq ifr; - struct ethtool_rxnfc rsscmd; - - memset(&rsscmd, 0, sizeof(rsscmd)); - - snprintf(ifr.ifr_name, IF_NAMESIZE, "%s", name); - - rsscmd.cmd = ETHTOOL_SRXFH; - rsscmd.flow_type = flow_type; - rsscmd.data = options; - - ifr.ifr_data = (caddr_t)&rsscmd; - - if (ioctl(fd, SIOCETHTOOL, &ifr) < 0) - return -1; - - return 0; -} - -int rss_conf_set_fd(int fd, const char *name, - const odp_pktin_hash_proto_t *hash_proto) -{ - uint64_t options; - odp_pktin_hash_proto_t cur_hash; - - /* Compare to currently set hash protocols */ - rss_conf_get_fd(fd, name, &cur_hash); - - if (hash_proto->proto.ipv4_udp && !cur_hash.proto.ipv4_udp) { - options = RXH_IP_SRC | RXH_IP_DST | RXH_L4_B_0_1 | RXH_L4_B_2_3; - if (set_rss_hash(fd, name, UDP_V4_FLOW, options)) - return -1; - } - if (hash_proto->proto.ipv4_tcp && !cur_hash.proto.ipv4_tcp) { - options = RXH_IP_SRC | RXH_IP_DST | RXH_L4_B_0_1 | RXH_L4_B_2_3; - if (set_rss_hash(fd, name, TCP_V4_FLOW, options)) - return -1; - } - if (hash_proto->proto.ipv6_udp && !cur_hash.proto.ipv6_udp) { - options = RXH_IP_SRC | RXH_IP_DST | RXH_L4_B_0_1 | RXH_L4_B_2_3; - if (set_rss_hash(fd, name, UDP_V6_FLOW, options)) - return -1; - } - if (hash_proto->proto.ipv6_tcp && !cur_hash.proto.ipv6_tcp) { - options = RXH_IP_SRC | RXH_IP_DST | RXH_L4_B_0_1 | RXH_L4_B_2_3; - if (set_rss_hash(fd, name, TCP_V6_FLOW, options)) - return -1; - } - if (hash_proto->proto.ipv4 && !cur_hash.proto.ipv4) { - options = RXH_IP_SRC | RXH_IP_DST; - if (set_rss_hash(fd, name, IPV4_FLOW, options)) - return -1; - } - if (hash_proto->proto.ipv6 && !cur_hash.proto.ipv6) { - options = RXH_IP_SRC | RXH_IP_DST; - if (set_rss_hash(fd, name, IPV6_FLOW, options)) - return -1; - } - return 0; -} - -int rss_conf_get_supported_fd(int fd, const char *name, - odp_pktin_hash_proto_t *hash_proto) -{ - uint64_t options; - int rss_supported = 0; - - memset(hash_proto, 0, sizeof(odp_pktin_hash_proto_t)); - - if (!get_rss_hash_options(fd, name, IPV4_FLOW, &options)) { - if (!set_rss_hash(fd, name, IPV4_FLOW, options)) { - hash_proto->proto.ipv4 = 1; - rss_supported++; - } - } - if (!get_rss_hash_options(fd, name, TCP_V4_FLOW, &options)) { - if (!set_rss_hash(fd, name, TCP_V4_FLOW, options)) { - hash_proto->proto.ipv4_tcp = 1; - rss_supported++; - } - } - if (!get_rss_hash_options(fd, name, UDP_V4_FLOW, &options)) { - if (!set_rss_hash(fd, name, UDP_V4_FLOW, options)) { - hash_proto->proto.ipv4_udp = 1; - rss_supported++; - } - } - if (!get_rss_hash_options(fd, name, IPV6_FLOW, &options)) { - if (!set_rss_hash(fd, name, IPV6_FLOW, options)) { - hash_proto->proto.ipv6 = 1; - rss_supported++; - } - } - if (!get_rss_hash_options(fd, name, TCP_V6_FLOW, &options)) { - if (!set_rss_hash(fd, name, TCP_V6_FLOW, options)) { - hash_proto->proto.ipv6_tcp = 1; - rss_supported++; - } - } - if (!get_rss_hash_options(fd, name, UDP_V6_FLOW, &options)) { - if (!set_rss_hash(fd, name, UDP_V6_FLOW, options)) { - hash_proto->proto.ipv6_udp = 1; - rss_supported++; - } - } - return rss_supported; -} - -void rss_conf_print(const odp_pktin_hash_proto_t *hash_proto) -{ int max_len = 512; - char str[max_len]; - int len = 0; - int n = max_len - 1; - - len += snprintf(&str[len], n - len, " rss conf\n"); - - if (hash_proto->proto.ipv4) - len += snprintf(&str[len], n - len, - " IPV4\n"); - if (hash_proto->proto.ipv4_tcp) - len += snprintf(&str[len], n - len, - " IPV4 TCP\n"); - if (hash_proto->proto.ipv4_udp) - len += snprintf(&str[len], n - len, - " IPV4 UDP\n"); - if (hash_proto->proto.ipv6) - len += snprintf(&str[len], n - len, - " IPV6\n"); - if (hash_proto->proto.ipv6_tcp) - len += snprintf(&str[len], n - len, - " IPV6 TCP\n"); - if (hash_proto->proto.ipv6_udp) - len += snprintf(&str[len], n - len, - " IPV6 UDP\n"); - str[len] = '\0'; - - ODP_PRINT("%s\n", str); -} - /* * ODP_PACKET_SOCKET_MMSG: */ diff --git a/platform/linux-generic/pktio/socket_mmap.c b/platform/linux-generic/pktio/socket_mmap.c index 09ad8137e..c413b1a22 100644 --- a/platform/linux-generic/pktio/socket_mmap.c +++ b/platform/linux-generic/pktio/socket_mmap.c @@ -32,6 +32,8 @@ #include #include #include +#include +#include #include #include diff --git a/platform/linux-generic/pktio/tap.c b/platform/linux-generic/pktio/tap.c index 80a13d236..177066ebe 100644 --- a/platform/linux-generic/pktio/tap.c +++ b/platform/linux-generic/pktio/tap.c @@ -45,6 +45,7 @@ #include #include #include +#include #define BUF_SIZE 65536 From patchwork Tue Oct 10 12:00:10 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: 115395 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp3674079qgn; Tue, 10 Oct 2017 05:09:17 -0700 (PDT) X-Google-Smtp-Source: AOwi7QD/vucJlYkozU+xhmqv7DNFNuWgfdOmGFvC6LBvGZ+8n+Tpf9f6RONoRBPu+X78MPRKG/9I X-Received: by 10.107.182.139 with SMTP id g133mr17352638iof.10.1507637357285; Tue, 10 Oct 2017 05:09:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507637357; cv=none; d=google.com; s=arc-20160816; b=KexXYkIiOii2QTg2aLCNCZVUVfy1xDbHcjdDZi6fT82xvtskXb6hvKDf+7eKlGWL4D ZGEZRP/HczfiamIbpbFDoACslTRq+l5Pm2xlz1CXfPaBywxlcHoEOJ+gTSuqebezOZFm 7nIkmwbSNWQSh44NKw5RZb20fJD5OBOB+ZZJYKnT04KBy9LoVZaacPN+zZ3kT+QMt14+ J9vs3ysH0EDr/0s91bLJHdm0iN9IyxF6ONMSq+ZfLeIuW35tamLxqB0wOSWp8SpjlwJy h0QeeYVQiCyOgVBXM96rNn3RhNsFXcCQ8AxL3j6BIGofNrFn/oOBqE4NFJLFpThCz8oO Sd7g== 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=Q2LdM69trYZoesL9R0n5RX8Vf/uTA0/WAAaYb057yZg=; b=RG77oYQRMy8I00BIVBArcxgzYuMRtB+EpNVEB0mk8Ad0X9wQpDnRnhaxdZNgKIgUNz vMUi7GWaZFGK50keSpbRW+LcHg5T6FJkRQFJUlRV9+3tfeXn4C1pvz0Sqs6Xzo//sJkr Pk/rmiL1Qln3HqAXEs85Mdl4e2pJ/PS68sVNhWokY+BKEsvmie/NcAKdRsgxgQ06kd83 YLeWL5M8OpVBFfVYc1NoOGu+4KOR1CcyrRZdVc/LMRqR/gcMDqoBhr6PgGe9SibJnnPb yOP+jVEiSxINoGnHernZj3867YTwiEqSdrcWDUtR3w0xelsNXRpHht3PNZYyKlF47fX8 0jew== 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 v191si8839239ith.135.2017.10.10.05.09.15; Tue, 10 Oct 2017 05:09:17 -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 753BC62DF6; Tue, 10 Oct 2017 12:09:15 +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=-5.4 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, 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 4BC4560CC6; Tue, 10 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 8423160C1F; Tue, 10 Oct 2017 12:02:29 +0000 (UTC) Received: from forward103o.mail.yandex.net (forward103o.mail.yandex.net [37.140.190.177]) by lists.linaro.org (Postfix) with ESMTPS id 8E31160C01 for ; Tue, 10 Oct 2017 12:01:01 +0000 (UTC) Received: from mxback14j.mail.yandex.net (mxback14j.mail.yandex.net [IPv6:2a02:6b8:0:1619::90]) by forward103o.mail.yandex.net (Yandex) with ESMTP id DB1F9588437E for ; Tue, 10 Oct 2017 15:00:59 +0300 (MSK) Received: from smtp4o.mail.yandex.net (smtp4o.mail.yandex.net [2a02:6b8:0:1a2d::28]) by mxback14j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id nTxkdwtIMF-0xoKQRvs; Tue, 10 Oct 2017 15:00:59 +0300 Received: by smtp4o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id NWf2cc9w7t-0weOhLmx; Tue, 10 Oct 2017 15:00:58 +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: Tue, 10 Oct 2017 15:00:10 +0300 Message-Id: <1507636815-18816-5-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1507636815-18816-1-git-send-email-odpbot@yandex.ru> References: <1507636815-18816-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 196 Subject: [lng-odp] [PATCH CLOUD-DEV v3 4/9] linux-gen: pktio: socket: 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 196 (bogdanPricope:cloud_dev_pktio_ops_data_pr) ** https://github.com/Linaro/odp/pull/196 ** Patch: https://github.com/Linaro/odp/pull/196.patch ** Base sha: 3d3c8f71f39ff139695d6f4b8e5ea17502c5f7cf ** Merge commit sha: 2bae88983ff377d83fcf9c99bf5c380275454327 **/ .../include/odp_pktio_ops_subsystem.h | 3 -- platform/linux-generic/pktio/socket.c | 47 ++++++++++++++------- platform/linux-generic/pktio/socket_mmap.c | 48 +++++++++++++++------- 3 files changed, 66 insertions(+), 32 deletions(-) diff --git a/platform/linux-generic/include/odp_pktio_ops_subsystem.h b/platform/linux-generic/include/odp_pktio_ops_subsystem.h index 415b8365f..369d722f0 100644 --- a/platform/linux-generic/include/odp_pktio_ops_subsystem.h +++ b/platform/linux-generic/include/odp_pktio_ops_subsystem.h @@ -82,7 +82,6 @@ typedef ODP_MODULE_CLASS(pktio_ops) { #include #include #include -#include #include /* Per implementation private data @@ -93,8 +92,6 @@ typedef union { pktio_ops_ipc_data_t ipc; pktio_ops_netmap_data_t netmap; pktio_ops_pcap_data_t pcap; - pktio_ops_socket_data_t socket; - pktio_ops_socket_mmap_data_t mmap; pktio_ops_tap_data_t tap; } pktio_ops_data_t; diff --git a/platform/linux-generic/pktio/socket.c b/platform/linux-generic/pktio/socket.c index 145f56014..4602dda0c 100644 --- a/platform/linux-generic/pktio/socket.c +++ b/platform/linux-generic/pktio/socket.c @@ -43,6 +43,7 @@ #include #include #include +#include #include #include @@ -107,7 +108,7 @@ int sendmmsg(int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags) static int sock_close(pktio_entry_t *pktio_entry) { pktio_ops_socket_data_t *pkt_sock = - &pktio_entry->ops_data(socket); + odp_ops_data(pktio_entry, socket); if (pkt_sock->sockfd != -1 && close(pkt_sock->sockfd) != 0) { __odp_errno = errno; @@ -131,7 +132,7 @@ static int sock_setup_pkt(pktio_entry_t *pktio_entry, const char *netdev, struct sockaddr_ll sa_ll; char shm_name[ODP_SHM_NAME_LEN]; pktio_ops_socket_data_t *pkt_sock = - &pktio_entry->ops_data(socket); + odp_ops_data(pktio_entry, socket); odp_pktio_stats_t cur_stats; /* Init pktio entry */ @@ -256,7 +257,7 @@ static int sock_mmsg_recv(pktio_entry_t *pktio_entry, int index ODP_UNUSED, odp_packet_t pkt_table[], int len) { pktio_ops_socket_data_t *pkt_sock = - &pktio_entry->ops_data(socket); + odp_ops_data(pktio_entry, socket); odp_pool_t pool = pkt_sock->pool; odp_time_t ts_val; odp_time_t *ts = NULL; @@ -372,7 +373,7 @@ static int sock_mmsg_send(pktio_entry_t *pktio_entry, int index ODP_UNUSED, const odp_packet_t pkt_table[], int len) { pktio_ops_socket_data_t *pkt_sock = - &pktio_entry->ops_data(socket); + odp_ops_data(pktio_entry, socket); struct mmsghdr msgvec[len]; struct iovec iovecs[len][MAX_SEGS]; int ret; @@ -418,7 +419,10 @@ static int sock_mmsg_send(pktio_entry_t *pktio_entry, int index ODP_UNUSED, */ static uint32_t sock_mtu_get(pktio_entry_t *pktio_entry) { - return pktio_entry->ops_data(socket).mtu; + pktio_ops_socket_data_t *pkt_sock = + odp_ops_data(pktio_entry, socket); + + return pkt_sock->mtu; } /* @@ -427,7 +431,10 @@ static uint32_t sock_mtu_get(pktio_entry_t *pktio_entry) static int sock_mac_addr_get(pktio_entry_t *pktio_entry, void *mac_addr) { - memcpy(mac_addr, pktio_entry->ops_data(socket).if_mac, ETH_ALEN); + pktio_ops_socket_data_t *pkt_sock = + odp_ops_data(pktio_entry, socket); + + memcpy(mac_addr, pkt_sock->if_mac, ETH_ALEN); return ETH_ALEN; } @@ -437,7 +444,10 @@ static int sock_mac_addr_get(pktio_entry_t *pktio_entry, static int sock_promisc_mode_set(pktio_entry_t *pktio_entry, odp_bool_t enable) { - return promisc_mode_set_fd(pktio_entry->ops_data(socket).sockfd, + pktio_ops_socket_data_t *pkt_sock = + odp_ops_data(pktio_entry, socket); + + return promisc_mode_set_fd(pkt_sock->sockfd, pktio_entry->s.name, enable); } @@ -446,13 +456,19 @@ static int sock_promisc_mode_set(pktio_entry_t *pktio_entry, */ static int sock_promisc_mode_get(pktio_entry_t *pktio_entry) { - return promisc_mode_get_fd(pktio_entry->ops_data(socket).sockfd, + pktio_ops_socket_data_t *pkt_sock = + odp_ops_data(pktio_entry, socket); + + return promisc_mode_get_fd(pkt_sock->sockfd, pktio_entry->s.name); } static int sock_link_status(pktio_entry_t *pktio_entry) { - return link_status_fd(pktio_entry->ops_data(socket).sockfd, + pktio_ops_socket_data_t *pkt_sock = + odp_ops_data(pktio_entry, socket); + + return link_status_fd(pkt_sock->sockfd, pktio_entry->s.name); } @@ -474,26 +490,29 @@ static int sock_capability(pktio_entry_t *pktio_entry ODP_UNUSED, static int sock_stats(pktio_entry_t *pktio_entry, odp_pktio_stats_t *stats) { + pktio_ops_socket_data_t *pkt_sock = + odp_ops_data(pktio_entry, socket); + if (pktio_entry->s.stats_type == STATS_UNSUPPORTED) { memset(stats, 0, sizeof(*stats)); return 0; } - return sock_stats_fd(pktio_entry, - stats, - pktio_entry->ops_data(socket).sockfd); + return sock_stats_fd(pktio_entry, stats, pkt_sock->sockfd); } static int sock_stats_reset(pktio_entry_t *pktio_entry) { + pktio_ops_socket_data_t *pkt_sock = + odp_ops_data(pktio_entry, socket); + if (pktio_entry->s.stats_type == STATS_UNSUPPORTED) { memset(&pktio_entry->s.stats, 0, sizeof(odp_pktio_stats_t)); return 0; } - return sock_stats_reset_fd(pktio_entry, - pktio_entry->ops_data(socket).sockfd); + return sock_stats_reset_fd(pktio_entry, pkt_sock->sockfd); } static int sock_init_global(void) diff --git a/platform/linux-generic/pktio/socket_mmap.c b/platform/linux-generic/pktio/socket_mmap.c index c413b1a22..af23f368e 100644 --- a/platform/linux-generic/pktio/socket_mmap.c +++ b/platform/linux-generic/pktio/socket_mmap.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include @@ -491,7 +492,7 @@ static int mmap_bind_sock(pktio_ops_socket_mmap_data_t *pkt_sock, static int sock_mmap_close(pktio_entry_t *entry) { pktio_ops_socket_mmap_data_t - *const pkt_sock = &entry->ops_data(mmap); + *const pkt_sock = odp_ops_data(entry, socket_mmap); int ret; ret = mmap_unmap_sock(pkt_sock); @@ -521,7 +522,7 @@ static int sock_mmap_open(odp_pktio_t id ODP_UNUSED, return -1; pktio_ops_socket_mmap_data_t - *const pkt_sock = &pktio_entry->ops_data(mmap); + *const pkt_sock = odp_ops_data(pktio_entry, socket_mmap); int fanout = 1; /* Init pktio entry */ @@ -607,7 +608,7 @@ static int sock_mmap_recv(pktio_entry_t *pktio_entry, int index ODP_UNUSED, odp_packet_t pkt_table[], int len) { pktio_ops_socket_mmap_data_t - *const pkt_sock = &pktio_entry->ops_data(mmap); + *const pkt_sock = odp_ops_data(pktio_entry, socket_mmap); int ret; odp_ticketlock_lock(&pktio_entry->s.rxl); @@ -623,7 +624,7 @@ static int sock_mmap_send(pktio_entry_t *pktio_entry, int index ODP_UNUSED, { int ret; pktio_ops_socket_mmap_data_t - *const pkt_sock = &pktio_entry->ops_data(mmap); + *const pkt_sock = odp_ops_data(pktio_entry, socket_mmap); odp_ticketlock_lock(&pktio_entry->s.txl); ret = pkt_mmap_v2_tx(pkt_sock->tx_ring.sock, &pkt_sock->tx_ring, @@ -635,33 +636,46 @@ static int sock_mmap_send(pktio_entry_t *pktio_entry, int index ODP_UNUSED, static uint32_t sock_mmap_mtu_get(pktio_entry_t *pktio_entry) { - return mtu_get_fd(pktio_entry->ops_data(mmap).sockfd, - pktio_entry->s.name); + pktio_ops_socket_mmap_data_t + *const pkt_sock = odp_ops_data(pktio_entry, socket_mmap); + + return mtu_get_fd(pkt_sock->sockfd, pktio_entry->s.name); } static int sock_mmap_mac_addr_get(pktio_entry_t *pktio_entry, void *mac_addr) { - memcpy(mac_addr, pktio_entry->ops_data(mmap).if_mac, ETH_ALEN); + pktio_ops_socket_mmap_data_t + *const pkt_sock = odp_ops_data(pktio_entry, socket_mmap); + + memcpy(mac_addr, pkt_sock->if_mac, ETH_ALEN); return ETH_ALEN; } static int sock_mmap_promisc_mode_set(pktio_entry_t *pktio_entry, odp_bool_t enable) { - return promisc_mode_set_fd(pktio_entry->ops_data(mmap).sockfd, + pktio_ops_socket_mmap_data_t + *const pkt_sock = odp_ops_data(pktio_entry, socket_mmap); + + return promisc_mode_set_fd(pkt_sock->sockfd, pktio_entry->s.name, enable); } static int sock_mmap_promisc_mode_get(pktio_entry_t *pktio_entry) { - return promisc_mode_get_fd(pktio_entry->ops_data(mmap).sockfd, + pktio_ops_socket_mmap_data_t + *const pkt_sock = odp_ops_data(pktio_entry, socket_mmap); + + return promisc_mode_get_fd(pkt_sock->sockfd, pktio_entry->s.name); } static int sock_mmap_link_status(pktio_entry_t *pktio_entry) { - return link_status_fd(pktio_entry->ops_data(mmap).sockfd, - pktio_entry->s.name); + pktio_ops_socket_mmap_data_t + *const pkt_sock = odp_ops_data(pktio_entry, socket_mmap); + + return link_status_fd(pkt_sock->sockfd, pktio_entry->s.name); } static int sock_mmap_capability(pktio_entry_t *pktio_entry ODP_UNUSED, @@ -682,26 +696,30 @@ static int sock_mmap_capability(pktio_entry_t *pktio_entry ODP_UNUSED, static int sock_mmap_stats(pktio_entry_t *pktio_entry, odp_pktio_stats_t *stats) { + pktio_ops_socket_mmap_data_t + *const pkt_sock = odp_ops_data(pktio_entry, socket_mmap); + if (pktio_entry->s.stats_type == STATS_UNSUPPORTED) { memset(stats, 0, sizeof(*stats)); return 0; } return sock_stats_fd(pktio_entry, - stats, - pktio_entry->ops_data(mmap).sockfd); + stats, pkt_sock->sockfd); } static int sock_mmap_stats_reset(pktio_entry_t *pktio_entry) { + pktio_ops_socket_mmap_data_t + *const pkt_sock = odp_ops_data(pktio_entry, socket_mmap); + if (pktio_entry->s.stats_type == STATS_UNSUPPORTED) { memset(&pktio_entry->s.stats, 0, sizeof(odp_pktio_stats_t)); return 0; } - return sock_stats_reset_fd(pktio_entry, - pktio_entry->ops_data(mmap).sockfd); + return sock_stats_reset_fd(pktio_entry, pkt_sock->sockfd); } static int sock_mmap_init_global(void) From patchwork Tue Oct 10 12:00:11 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: 115393 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp3670275qgn; Tue, 10 Oct 2017 05:06:00 -0700 (PDT) X-Google-Smtp-Source: AOwi7QDtlueB78OZb/BSk51xVilEDWFzinD1vIBkXOr3eKgvlop81C80aGwMpdh6LrFda4isy3ps X-Received: by 10.36.164.75 with SMTP id v11mr19409097iti.33.1507637160616; Tue, 10 Oct 2017 05:06:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507637160; cv=none; d=google.com; s=arc-20160816; b=fm9e1JvudDWTMTA6tSYx8OLz7U2zAnqRBR4vb/H6m/wBLbhdo5QJmSyZEoInlvwzVC YmvBtdB+bY9kgeXIftvUGw9SN8fNxYsUTUYzcxaiM6jZJHQmn88fnZAVBPDPt6KKyTrf nQ29Bq+Gtd3HEKAGfJX6F5f4V0Pyu4KB/DMOt2cJldJh8m/foWMiFh2VODxhnuD30ebK APereGEQYgRshx8til9i6tVHTTAWyNmrhRwbqYxOfqXV+5bjJFfBZB6pRj7fUo1nnNxG Zn65hXnUW/PbMTYzygtEEsqdWMuEtg/9b2bDV9Kt/PltD5G22VHGuiII0OZm2A5NFIV6 UGiQ== 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=1aKItY62ByBxUhxe5EErb8QtPSoktadm6gBwaU1ua7w=; b=huV9KksNM/qUTBNteM8n3YpDcF8rup1K89wsKIu+IfnaAVR8HkAz+aOncDkuBplEqf hj0MU9fHpVAW9/mEqprUwIqQ8aREsgsemGxYZuoOR3vLdKXDxYE7cgy/QmliZU38AkJW JIYm17y9WBJpxsU0JmdEbtD/XN+1P6VJ6e9vxomFmcYzxXf62mGIRrwr5SXBpe7eug5h ZCUBBJaMdrrb9XViC9cv8L3we3CIi5pcs8RShqjQo+t1KhPBMYvRzB55qKoP6xXQRIcn B0T+LROlzjAlHsoxVeeoYyfzc0F2TZHO12OQO8nd/NocYnUefvtdFOaItzjYbg1uyoI2 uDpQ== 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 d184si8627417itg.168.2017.10.10.05.05.58; Tue, 10 Oct 2017 05:06:00 -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 B834B62AE7; Tue, 10 Oct 2017 12:05:58 +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=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, 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 8FA8860BF6; Tue, 10 Oct 2017 12:02:56 +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 99D9660BF1; Tue, 10 Oct 2017 12:02:24 +0000 (UTC) Received: from forward104j.mail.yandex.net (forward104j.mail.yandex.net [5.45.198.247]) by lists.linaro.org (Postfix) with ESMTPS id 35A6B60CB2 for ; Tue, 10 Oct 2017 12:01:02 +0000 (UTC) Received: from mxback7j.mail.yandex.net (mxback7j.mail.yandex.net [IPv6:2a02:6b8:0:1619::110]) by forward104j.mail.yandex.net (Yandex) with ESMTP id C42A24250B for ; Tue, 10 Oct 2017 15:01:00 +0300 (MSK) Received: from smtp4o.mail.yandex.net (smtp4o.mail.yandex.net [2a02:6b8:0:1a2d::28]) by mxback7j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id dIetgHO7i8-10FOCUlF; Tue, 10 Oct 2017 15:01:00 +0300 Received: by smtp4o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id NWf2cc9w7t-10eaCPca; Tue, 10 Oct 2017 15:01:00 +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: Tue, 10 Oct 2017 15:00:11 +0300 Message-Id: <1507636815-18816-6-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1507636815-18816-1-git-send-email-odpbot@yandex.ru> References: <1507636815-18816-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 196 Subject: [lng-odp] [PATCH CLOUD-DEV v3 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 196 (bogdanPricope:cloud_dev_pktio_ops_data_pr) ** https://github.com/Linaro/odp/pull/196 ** Patch: https://github.com/Linaro/odp/pull/196.patch ** Base sha: 3d3c8f71f39ff139695d6f4b8e5ea17502c5f7cf ** Merge commit sha: 2bae88983ff377d83fcf9c99bf5c380275454327 **/ .../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 369d722f0..526280a10 100644 --- a/platform/linux-generic/include/odp_pktio_ops_subsystem.h +++ b/platform/linux-generic/include/odp_pktio_ops_subsystem.h @@ -82,7 +82,6 @@ typedef ODP_MODULE_CLASS(pktio_ops) { #include #include #include -#include /* Per implementation private data * TODO: refactory each implementation to hide it internally @@ -92,7 +91,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 177066ebe..c617fa6fd 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; } From patchwork Tue Oct 10 12:00:12 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: 115397 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp3676795qgn; Tue, 10 Oct 2017 05:11:38 -0700 (PDT) X-Google-Smtp-Source: AOwi7QDM3iyzjAsbWc3e/Iwku2pfiI5Qt+qObstS40uSJG15vOLFfRFMEOi44XptngsrLU6Efo50 X-Received: by 10.36.50.150 with SMTP id j144mr17839633ita.52.1507637498053; Tue, 10 Oct 2017 05:11:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507637498; cv=none; d=google.com; s=arc-20160816; b=tiOVGnWNWzl+NymeYMUx81rGKx7ZWA8oC764nlzd1kypCmpXMMu+tVGqKkm+Tt2zEW 63WSRC9dfw9btkTWGRxWplXed1V9iNWYK0TabLZeWr6FSD6b5iY5pX5ESB5CZLpkJxmF A0Y2rjzwH3MihEJArr4ai6b+5G7NW7BOgcGYsN+9YXeX8feDdpiz2ttIDNxHrn9wGyWW Kt4lnRffqUGaywe7hB8KT+bk/PGNdrTAJdf1FExtWtAVaouza2MvGr3rT1NcwsCun7Xp oMwvyH/7qjffnagt1/D/EGusVjEWLKQ+GNyJdPV+hs+oAox8PiXpyq/fsOqRMdeQsei4 4Skg== 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=Bd0BbnQCZOAU5zAeqHpL6C9t7G3+BllXjyGWAan6Qj4=; b=wKC6ybmrB4gZvLmvM/bPNqsQi8mmXYIbCbFkOnJpMNXffYy5DYuXlJ5cg3mqgxWEO1 uLxGntnRb5RN/gMeGo8ImDLSrjLPcoWQS6ZjxkX0w4u3VY/wfirwp9c8f/q+cdLY9WRY DV+pnPK/9B7kRGi+0zuIqKKePf9/Mc1LoYgewMjhhKb4CkZ8QPeTY63LDiyhovr94GHW i7i6GKvyE+g4+J2QQzf/9PdlXMCcYWNCv+dF+ITptIxN5N3UhbbxxnkwrO4tdc7GSw4S Gx68wKnPnpSUr/J7NEcNy/dNOfMHF+L4Iei+h8WgSLcfiGd4acDr5IpkT115E5c9Kl5A lrNg== 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 j129si8351354ioe.226.2017.10.10.05.11.36; Tue, 10 Oct 2017 05:11:37 -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 D5CF6634BD; Tue, 10 Oct 2017 12:11:35 +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,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,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 F0F6160D3D; Tue, 10 Oct 2017 12:03:21 +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 5CE2460C35; Tue, 10 Oct 2017 12:02:32 +0000 (UTC) Received: from forward104o.mail.yandex.net (forward104o.mail.yandex.net [37.140.190.179]) by lists.linaro.org (Postfix) with ESMTPS id 5C3A260CBD for ; Tue, 10 Oct 2017 12:01:03 +0000 (UTC) Received: from mxback8j.mail.yandex.net (mxback8j.mail.yandex.net [IPv6:2a02:6b8:0:1619::111]) by forward104o.mail.yandex.net (Yandex) with ESMTP id B4D9B702585 for ; Tue, 10 Oct 2017 15:01:01 +0300 (MSK) Received: from smtp4o.mail.yandex.net (smtp4o.mail.yandex.net [2a02:6b8:0:1a2d::28]) by mxback8j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id I14eh42bLA-11bu0PDJ; Tue, 10 Oct 2017 15:01:01 +0300 Received: by smtp4o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id NWf2cc9w7t-10eGUcTT; Tue, 10 Oct 2017 15:01:00 +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: Tue, 10 Oct 2017 15:00:12 +0300 Message-Id: <1507636815-18816-7-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1507636815-18816-1-git-send-email-odpbot@yandex.ru> References: <1507636815-18816-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 196 Subject: [lng-odp] [PATCH CLOUD-DEV v3 6/9] linux-gen: pktio: ipc: 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 196 (bogdanPricope:cloud_dev_pktio_ops_data_pr) ** https://github.com/Linaro/odp/pull/196 ** Patch: https://github.com/Linaro/odp/pull/196.patch ** Base sha: 3d3c8f71f39ff139695d6f4b8e5ea17502c5f7cf ** Merge commit sha: 2bae88983ff377d83fcf9c99bf5c380275454327 **/ .../include/odp_pktio_ops_subsystem.h | 2 - platform/linux-generic/pktio/ipc.c | 201 +++++++++++---------- 2 files changed, 103 insertions(+), 100 deletions(-) diff --git a/platform/linux-generic/include/odp_pktio_ops_subsystem.h b/platform/linux-generic/include/odp_pktio_ops_subsystem.h index 526280a10..6bb31516a 100644 --- a/platform/linux-generic/include/odp_pktio_ops_subsystem.h +++ b/platform/linux-generic/include/odp_pktio_ops_subsystem.h @@ -79,7 +79,6 @@ typedef ODP_MODULE_CLASS(pktio_ops) { } pktio_ops_module_t; /* All implementations of this subsystem */ -#include #include #include @@ -88,7 +87,6 @@ typedef ODP_MODULE_CLASS(pktio_ops) { */ typedef union { void *dpdk; - pktio_ops_ipc_data_t ipc; pktio_ops_netmap_data_t netmap; pktio_ops_pcap_data_t pcap; } pktio_ops_data_t; diff --git a/platform/linux-generic/pktio/ipc.c b/platform/linux-generic/pktio/ipc.c index 5211d1e5f..a9bd64640 100644 --- a/platform/linux-generic/pktio/ipc.c +++ b/platform/linux-generic/pktio/ipc.c @@ -11,10 +11,12 @@ #include #include #include <_ishm_internal.h> +#include #include #include #include +#include #define IPC_ODP_DEBUG_PRINT 0 @@ -45,7 +47,8 @@ static const char *_ipc_odp_buffer_pool_shm_name(odp_pool_t pool_hdl) static int _ipc_master_start(pktio_entry_t *pktio_entry) { - struct pktio_info *pinfo = pktio_entry->ops_data(ipc).pinfo; + pktio_ops_ipc_data_t *pkt_ipc = odp_ops_data(pktio_entry, ipc); + struct pktio_info *pinfo = pkt_ipc->pinfo; odp_shm_t shm; if (pinfo->slave.init_done == 0) @@ -59,11 +62,11 @@ static int _ipc_master_start(pktio_entry_t *pktio_entry) return -1; } - pktio_entry->ops_data(ipc).remote_pool_shm = shm; - pktio_entry->ops_data(ipc).pool_base = odp_shm_addr(shm); - pktio_entry->ops_data(ipc).pool_mdata_base = (char *)odp_shm_addr(shm); + pkt_ipc->remote_pool_shm = shm; + pkt_ipc->pool_base = odp_shm_addr(shm); + pkt_ipc->pool_mdata_base = (char *)odp_shm_addr(shm); - odp_atomic_store_u32(&pktio_entry->ops_data(ipc).ready, 1); + odp_atomic_store_u32(&pkt_ipc->ready, 1); IPC_ODP_DBG("%s started.\n", pktio_entry->s.name); return 0; @@ -73,6 +76,7 @@ static int _ipc_init_master(pktio_entry_t *pktio_entry, const char *dev, odp_pool_t pool_hdl) { + pktio_ops_ipc_data_t *pkt_ipc = odp_ops_data(pktio_entry, ipc); char ipc_shm_name[ODP_POOL_NAME_LEN + sizeof("_m_prod")]; pool_t *pool; struct pktio_info *pinfo; @@ -90,62 +94,62 @@ static int _ipc_init_master(pktio_entry_t *pktio_entry, * to be processed packets ring. */ snprintf(ipc_shm_name, sizeof(ipc_shm_name), "%s_m_prod", dev); - pktio_entry->ops_data(ipc).tx.send = _ring_create(ipc_shm_name, + pkt_ipc->tx.send = _ring_create(ipc_shm_name, PKTIO_IPC_ENTRIES, _RING_SHM_PROC | _RING_NO_LIST); - if (!pktio_entry->ops_data(ipc).tx.send) { + if (!pkt_ipc->tx.send) { ODP_ERR("pid %d unable to create ipc ring %s name\n", getpid(), ipc_shm_name); return -1; } ODP_DBG("Created IPC ring: %s, count %d, free %d\n", - ipc_shm_name, _ring_count(pktio_entry->ops_data(ipc).tx.send), - _ring_free_count(pktio_entry->ops_data(ipc).tx.send)); + ipc_shm_name, _ring_count(pkt_ipc->tx.send), + _ring_free_count(pkt_ipc->tx.send)); /* generate name in shm like ipc_pktio_p for * already processed packets */ snprintf(ipc_shm_name, sizeof(ipc_shm_name), "%s_m_cons", dev); - pktio_entry->ops_data(ipc).tx.free = _ring_create(ipc_shm_name, + pkt_ipc->tx.free = _ring_create(ipc_shm_name, PKTIO_IPC_ENTRIES, _RING_SHM_PROC | _RING_NO_LIST); - if (!pktio_entry->ops_data(ipc).tx.free) { + if (!pkt_ipc->tx.free) { ODP_ERR("pid %d unable to create ipc ring %s name\n", getpid(), ipc_shm_name); goto free_m_prod; } ODP_DBG("Created IPC ring: %s, count %d, free %d\n", - ipc_shm_name, _ring_count(pktio_entry->ops_data(ipc).tx.free), - _ring_free_count(pktio_entry->ops_data(ipc).tx.free)); + ipc_shm_name, _ring_count(pkt_ipc->tx.free), + _ring_free_count(pkt_ipc->tx.free)); snprintf(ipc_shm_name, sizeof(ipc_shm_name), "%s_s_prod", dev); - pktio_entry->ops_data(ipc).rx.recv = _ring_create(ipc_shm_name, + pkt_ipc->rx.recv = _ring_create(ipc_shm_name, PKTIO_IPC_ENTRIES, _RING_SHM_PROC | _RING_NO_LIST); - if (!pktio_entry->ops_data(ipc).rx.recv) { + if (!pkt_ipc->rx.recv) { ODP_ERR("pid %d unable to create ipc ring %s name\n", getpid(), ipc_shm_name); goto free_m_cons; } ODP_DBG("Created IPC ring: %s, count %d, free %d\n", - ipc_shm_name, _ring_count(pktio_entry->ops_data(ipc).rx.recv), - _ring_free_count(pktio_entry->ops_data(ipc).rx.recv)); + ipc_shm_name, _ring_count(pkt_ipc->rx.recv), + _ring_free_count(pkt_ipc->rx.recv)); snprintf(ipc_shm_name, sizeof(ipc_shm_name), "%s_s_cons", dev); - pktio_entry->ops_data(ipc).rx.free = _ring_create(ipc_shm_name, + pkt_ipc->rx.free = _ring_create(ipc_shm_name, PKTIO_IPC_ENTRIES, _RING_SHM_PROC | _RING_NO_LIST); - if (!pktio_entry->ops_data(ipc).rx.free) { + if (!pkt_ipc->rx.free) { ODP_ERR("pid %d unable to create ipc ring %s name\n", getpid(), ipc_shm_name); goto free_s_prod; } ODP_DBG("Created IPC ring: %s, count %d, free %d\n", - ipc_shm_name, _ring_count(pktio_entry->ops_data(ipc).rx.free), - _ring_free_count(pktio_entry->ops_data(ipc).rx.free)); + ipc_shm_name, _ring_count(pkt_ipc->rx.free), + _ring_free_count(pkt_ipc->rx.free)); /* Set up pool name for remote info */ - pinfo = pktio_entry->ops_data(ipc).pinfo; + pinfo = pkt_ipc->pinfo; pool_name = _ipc_odp_buffer_pool_shm_name(pool_hdl); if (strlen(pool_name) > ODP_POOL_NAME_LEN) { ODP_ERR("pid %d ipc pool name %s is too big %d\n", @@ -158,7 +162,7 @@ static int _ipc_init_master(pktio_entry_t *pktio_entry, pinfo->slave.pid = 0; pinfo->slave.init_done = 0; - pktio_entry->ops_data(ipc).pool = pool_hdl; + pkt_ipc->pool = pool_hdl; ODP_DBG("Pre init... DONE.\n"); pinfo->master.init_done = 1; @@ -224,15 +228,18 @@ static int _ipc_init_slave(const char *dev, pktio_entry_t *pktio_entry, odp_pool_t pool) { + pktio_ops_ipc_data_t *pkt_ipc = odp_ops_data(pktio_entry, ipc); + if (strlen(dev) > (ODP_POOL_NAME_LEN - sizeof("_slave_r"))) ODP_ABORT("too big ipc name\n"); - pktio_entry->ops_data(ipc).pool = pool; + pkt_ipc->pool = pool; return 0; } static int _ipc_slave_start(pktio_entry_t *pktio_entry) { + pktio_ops_ipc_data_t *pkt_ipc = odp_ops_data(pktio_entry, ipc); char ipc_shm_name[ODP_POOL_NAME_LEN + sizeof("_slave_r")]; struct pktio_info *pinfo; odp_shm_t shm; @@ -248,61 +255,61 @@ static int _ipc_slave_start(pktio_entry_t *pktio_entry) sprintf(dev, "ipc:%s", tail); snprintf(ipc_shm_name, sizeof(ipc_shm_name), "%s_m_prod", dev); - pktio_entry->ops_data(ipc).rx.recv = _ipc_shm_map(ipc_shm_name, pid); - if (!pktio_entry->ops_data(ipc).rx.recv) { + pkt_ipc->rx.recv = _ipc_shm_map(ipc_shm_name, pid); + if (!pkt_ipc->rx.recv) { ODP_DBG("pid %d unable to find ipc ring %s name\n", getpid(), dev); sleep(1); return -1; } ODP_DBG("Connected IPC ring: %s, count %d, free %d\n", - ipc_shm_name, _ring_count(pktio_entry->ops_data(ipc).rx.recv), - _ring_free_count(pktio_entry->ops_data(ipc).rx.recv)); + ipc_shm_name, _ring_count(pkt_ipc->rx.recv), + _ring_free_count(pkt_ipc->rx.recv)); snprintf(ipc_shm_name, sizeof(ipc_shm_name), "%s_m_cons", dev); - pktio_entry->ops_data(ipc).rx.free = _ipc_shm_map(ipc_shm_name, pid); - if (!pktio_entry->ops_data(ipc).rx.free) { + pkt_ipc->rx.free = _ipc_shm_map(ipc_shm_name, pid); + if (!pkt_ipc->rx.free) { ODP_ERR("pid %d unable to find ipc ring %s name\n", getpid(), dev); goto free_m_prod; } ODP_DBG("Connected IPC ring: %s, count %d, free %d\n", - ipc_shm_name, _ring_count(pktio_entry->ops_data(ipc).rx.free), - _ring_free_count(pktio_entry->ops_data(ipc).rx.free)); + ipc_shm_name, _ring_count(pkt_ipc->rx.free), + _ring_free_count(pkt_ipc->rx.free)); snprintf(ipc_shm_name, sizeof(ipc_shm_name), "%s_s_prod", dev); - pktio_entry->ops_data(ipc).tx.send = _ipc_shm_map(ipc_shm_name, pid); - if (!pktio_entry->ops_data(ipc).tx.send) { + pkt_ipc->tx.send = _ipc_shm_map(ipc_shm_name, pid); + if (!pkt_ipc->tx.send) { ODP_ERR("pid %d unable to find ipc ring %s name\n", getpid(), dev); goto free_m_cons; } ODP_DBG("Connected IPC ring: %s, count %d, free %d\n", - ipc_shm_name, _ring_count(pktio_entry->ops_data(ipc).tx.send), - _ring_free_count(pktio_entry->ops_data(ipc).tx.send)); + ipc_shm_name, _ring_count(pkt_ipc->tx.send), + _ring_free_count(pkt_ipc->tx.send)); snprintf(ipc_shm_name, sizeof(ipc_shm_name), "%s_s_cons", dev); - pktio_entry->ops_data(ipc).tx.free = _ipc_shm_map(ipc_shm_name, pid); - if (!pktio_entry->ops_data(ipc).tx.free) { + pkt_ipc->tx.free = _ipc_shm_map(ipc_shm_name, pid); + if (!pkt_ipc->tx.free) { ODP_ERR("pid %d unable to find ipc ring %s name\n", getpid(), dev); goto free_s_prod; } ODP_DBG("Connected IPC ring: %s, count %d, free %d\n", - ipc_shm_name, _ring_count(pktio_entry->ops_data(ipc).tx.free), - _ring_free_count(pktio_entry->ops_data(ipc).tx.free)); + ipc_shm_name, _ring_count(pkt_ipc->tx.free), + _ring_free_count(pkt_ipc->tx.free)); /* Get info about remote pool */ - pinfo = pktio_entry->ops_data(ipc).pinfo; + pinfo = pkt_ipc->pinfo; shm = _ipc_map_remote_pool(pinfo->master.pool_name, pid); - pktio_entry->ops_data(ipc).remote_pool_shm = shm; - pktio_entry->ops_data(ipc).pool_mdata_base = (char *)odp_shm_addr(shm); - pktio_entry->ops_data(ipc).pkt_size = pinfo->master.block_size; + pkt_ipc->remote_pool_shm = shm; + pkt_ipc->pool_mdata_base = (char *)odp_shm_addr(shm); + pkt_ipc->pkt_size = pinfo->master.block_size; - _ipc_export_pool(pinfo, pktio_entry->ops_data(ipc).pool); + _ipc_export_pool(pinfo, pkt_ipc->pool); - odp_atomic_store_u32(&pktio_entry->ops_data(ipc).ready, 1); + odp_atomic_store_u32(&pkt_ipc->ready, 1); pinfo->slave.init_done = 1; ODP_DBG("%s started.\n", pktio_entry->s.name); @@ -334,6 +341,7 @@ static int ipc_pktio_open(odp_pktio_t id ODP_UNUSED, char name[ODP_POOL_NAME_LEN + sizeof("_info")]; char tail[ODP_POOL_NAME_LEN]; odp_shm_t shm; + pktio_ops_ipc_data_t *pkt_ipc = odp_ops_data(pktio_entry, ipc); ODP_STATIC_ASSERT(ODP_POOL_NAME_LEN == _RING_NAMESIZE, "mismatch pool and ring name arrays"); @@ -341,15 +349,15 @@ static int ipc_pktio_open(odp_pktio_t id ODP_UNUSED, if (strncmp(dev, "ipc", 3)) return -1; - odp_atomic_init_u32(&pktio_entry->ops_data(ipc).ready, 0); + odp_atomic_init_u32(&pkt_ipc->ready, 0); - pktio_entry->ops_data(ipc).rx.cache = _ring_create("ipc_rx_cache", + pkt_ipc->rx.cache = _ring_create("ipc_rx_cache", PKTIO_IPC_ENTRIES, _RING_NO_LIST); /* Shared info about remote pktio */ if (sscanf(dev, "ipc:%d:%s", &pid, tail) == 2) { - pktio_entry->ops_data(ipc).type = PKTIO_TYPE_IPC_SLAVE; + pkt_ipc->type = PKTIO_TYPE_IPC_SLAVE; snprintf(name, sizeof(name), "ipc:%s_info", tail); IPC_ODP_DBG("lookup for name %s for pid %d\n", name, pid); @@ -362,12 +370,12 @@ static int ipc_pktio_open(odp_pktio_t id ODP_UNUSED, odp_shm_free(shm); return -1; } - pktio_entry->ops_data(ipc).pinfo = pinfo; - pktio_entry->ops_data(ipc).pinfo_shm = shm; + pkt_ipc->pinfo = pinfo; + pkt_ipc->pinfo_shm = shm; ODP_DBG("process %d is slave\n", getpid()); ret = _ipc_init_slave(name, pktio_entry, pool); } else { - pktio_entry->ops_data(ipc).type = PKTIO_TYPE_IPC_MASTER; + pkt_ipc->type = PKTIO_TYPE_IPC_MASTER; snprintf(name, sizeof(name), "%s_info", dev); shm = odp_shm_reserve(name, sizeof(struct pktio_info), ODP_CACHE_LINE_SIZE, @@ -380,8 +388,8 @@ static int ipc_pktio_open(odp_pktio_t id ODP_UNUSED, pinfo = odp_shm_addr(shm); pinfo->master.init_done = 0; pinfo->master.pool_name[0] = 0; - pktio_entry->ops_data(ipc).pinfo = pinfo; - pktio_entry->ops_data(ipc).pinfo_shm = shm; + pkt_ipc->pinfo = pinfo; + pkt_ipc->pinfo_shm = shm; ODP_DBG("process %d is master\n", getpid()); ret = _ipc_init_master(pktio_entry, dev, pool); } @@ -391,6 +399,7 @@ static int ipc_pktio_open(odp_pktio_t id ODP_UNUSED, static void _ipc_free_ring_packets(pktio_entry_t *pktio_entry, _ring_t *r) { + pktio_ops_ipc_data_t *pkt_ipc = odp_ops_data(pktio_entry, ipc); uintptr_t offsets[PKTIO_IPC_ENTRIES]; int ret; void **rbuf_p; @@ -401,7 +410,7 @@ static void _ipc_free_ring_packets(pktio_entry_t *pktio_entry, _ring_t *r) if (!r) return; - pool = pool_entry_from_hdl(pktio_entry->ops_data(ipc).pool); + pool = pool_entry_from_hdl(pkt_ipc->pool); addr = odp_shm_addr(pool->shm); rbuf_p = (void *)&offsets; @@ -426,6 +435,7 @@ static void _ipc_free_ring_packets(pktio_entry_t *pktio_entry, _ring_t *r) static int ipc_pktio_recv_lockless(pktio_entry_t *pktio_entry, odp_packet_t pkt_table[], int len) { + pktio_ops_ipc_data_t *pkt_ipc = odp_ops_data(pktio_entry, ipc); int pkts = 0; int i; _ring_t *r; @@ -435,16 +445,16 @@ static int ipc_pktio_recv_lockless(pktio_entry_t *pktio_entry, uint32_t ready; int pkts_ring; - ready = odp_atomic_load_u32(&pktio_entry->ops_data(ipc).ready); + ready = odp_atomic_load_u32(&pkt_ipc->ready); if (odp_unlikely(!ready)) { IPC_ODP_DBG("start pktio is missing before usage?\n"); return 0; } - _ipc_free_ring_packets(pktio_entry, pktio_entry->ops_data(ipc).tx.free); + _ipc_free_ring_packets(pktio_entry, pkt_ipc->tx.free); /* rx from cache */ - r = pktio_entry->ops_data(ipc).rx.cache; + r = pkt_ipc->rx.cache; pkts = _ring_mc_dequeue_burst(r, ipcbufs_p, len); if (odp_unlikely(pkts < 0)) ODP_ABORT("internal error dequeue\n"); @@ -452,7 +462,7 @@ static int ipc_pktio_recv_lockless(pktio_entry_t *pktio_entry, /* rx from other app */ if (pkts == 0) { ipcbufs_p = (void *)&offsets[0]; - r = pktio_entry->ops_data(ipc).rx.recv; + r = pkt_ipc->rx.recv; pkts = _ring_mc_dequeue_burst(r, ipcbufs_p, len); if (odp_unlikely(pkts < 0)) ODP_ABORT("internal error dequeue\n"); @@ -470,10 +480,10 @@ static int ipc_pktio_recv_lockless(pktio_entry_t *pktio_entry, uint64_t data_pool_off; void *rmt_data_ptr; - phdr = (void *)((uint8_t *)pktio_entry-> - ops_data(ipc).pool_mdata_base + offsets[i]); + phdr = (void *)((uint8_t *)pkt_ipc->pool_mdata_base + + offsets[i]); - pool = pktio_entry->ops_data(ipc).pool; + pool = pkt_ipc->pool; if (odp_unlikely(pool == ODP_POOL_INVALID)) ODP_ABORT("invalid pool"); @@ -497,12 +507,11 @@ static int ipc_pktio_recv_lockless(pktio_entry_t *pktio_entry, pkt_data = odp_packet_data(pkt); if (odp_unlikely(!pkt_data)) ODP_ABORT("unable to map pkt_data ipc_slave %d\n", - (PKTIO_TYPE_IPC_SLAVE == - pktio_entry->ops_data(ipc).type)); + (PKTIO_TYPE_IPC_SLAVE == pkt_ipc->type)); /* Copy packet data from shared pool to local pool. */ - rmt_data_ptr = (uint8_t *)pktio_entry-> - ops_data(ipc).pool_mdata_base + data_pool_off; + rmt_data_ptr = (uint8_t *)pkt_ipc->pool_mdata_base + + data_pool_off; memcpy(pkt_data, rmt_data_ptr, phdr->frame_len); /* Copy packets L2, L3 parsed offsets and size */ @@ -521,7 +530,7 @@ static int ipc_pktio_recv_lockless(pktio_entry_t *pktio_entry, /* put back to rx ring dequed but not processed packets*/ if (pkts != i) { ipcbufs_p = (void *)&offsets[i]; - r_p = pktio_entry->ops_data(ipc).rx.cache; + r_p = pkt_ipc->rx.cache; pkts_ring = _ring_mp_enqueue_burst(r_p, ipcbufs_p, pkts - i); if (pkts_ring != (pkts - i)) @@ -529,14 +538,13 @@ static int ipc_pktio_recv_lockless(pktio_entry_t *pktio_entry, if (i == 0) return 0; - } /*num of actually received packets*/ pkts = i; /* Now tell other process that we no longer need that buffers.*/ - r_p = pktio_entry->ops_data(ipc).rx.free; + r_p = pkt_ipc->rx.free; repeat: @@ -580,11 +588,12 @@ static int ipc_pktio_recv(pktio_entry_t *pktio_entry, int index ODP_UNUSED, static int ipc_pktio_send_lockless(pktio_entry_t *pktio_entry, const odp_packet_t pkt_table[], int len) { + pktio_ops_ipc_data_t *pkt_ipc = odp_ops_data(pktio_entry, ipc); _ring_t *r; void **rbuf_p; int ret; int i; - uint32_t ready = odp_atomic_load_u32(&pktio_entry->ops_data(ipc).ready); + uint32_t ready = odp_atomic_load_u32(&pkt_ipc->ready); odp_packet_t pkt_table_mapped[len]; /**< Ready to send packet has to be * in memory mapped pool. */ uintptr_t offsets[len]; @@ -592,7 +601,7 @@ static int ipc_pktio_send_lockless(pktio_entry_t *pktio_entry, if (odp_unlikely(!ready)) return 0; - _ipc_free_ring_packets(pktio_entry, pktio_entry->ops_data(ipc).tx.free); + _ipc_free_ring_packets(pktio_entry, pkt_ipc->tx.free); /* Copy packets to shm shared pool if they are in different * pool, or if they are references (we can't share across IPC). @@ -600,7 +609,7 @@ static int ipc_pktio_send_lockless(pktio_entry_t *pktio_entry, for (i = 0; i < len; i++) { odp_packet_t pkt = pkt_table[i]; pool_t *ipc_pool = pool_entry_from_hdl( - pktio_entry->ops_data(ipc).pool); + pkt_ipc->pool); odp_packet_hdr_t *pkt_hdr; pool_t *pool; @@ -611,8 +620,7 @@ static int ipc_pktio_send_lockless(pktio_entry_t *pktio_entry, odp_packet_has_ref(pkt)) { odp_packet_t newpkt; - newpkt = odp_packet_copy( - pkt, pktio_entry->ops_data(ipc).pool); + newpkt = odp_packet_copy(pkt, pkt_ipc->pool); if (newpkt == ODP_PACKET_INVALID) ODP_ABORT("Unable to copy packet\n"); @@ -644,20 +652,17 @@ static int ipc_pktio_send_lockless(pktio_entry_t *pktio_entry, odp_packet_to_u64(pkt), odp_pool_to_u64(pool_hdl), pkt_hdr, pkt_hdr->buf_hdr.ipc_data_offset, offsets[i], odp_shm_addr(pool->shm), - odp_shm_addr(pool_entry_from_hdl(pktio_entry-> - ops_data(ipc).pool)->shm)); + odp_shm_addr(pool_entry_from_hdl( + pkt_ipc->pool)->shm)); } /* Put packets to ring to be processed by other process. */ rbuf_p = (void *)&offsets[0]; - r = pktio_entry->ops_data(ipc).tx.send; + r = pkt_ipc->tx.send; ret = _ring_mp_enqueue_burst(r, rbuf_p, len); if (odp_unlikely(ret < 0)) { ODP_ERR("pid %d odp_ring_mp_enqueue_bulk fail, ipc_slave %d, ret %d\n", - getpid(), - (PKTIO_TYPE_IPC_SLAVE == - pktio_entry->ops_data(ipc).type), - ret); + getpid(), (PKTIO_TYPE_IPC_SLAVE == pkt_ipc->type), ret); ODP_ERR("odp_ring_full: %d, odp_ring_count %d, _ring_free_count %d\n", _ring_full(r), _ring_count(r), _ring_free_count(r)); @@ -696,15 +701,15 @@ static int ipc_mac_addr_get(pktio_entry_t *pktio_entry ODP_UNUSED, static int ipc_start(pktio_entry_t *pktio_entry) { - uint32_t ready = odp_atomic_load_u32( - &pktio_entry->ops_data(ipc).ready); + pktio_ops_ipc_data_t *pkt_ipc = odp_ops_data(pktio_entry, ipc); + uint32_t ready = odp_atomic_load_u32(&pkt_ipc->ready); if (ready) { ODP_ABORT("%s Already started\n", pktio_entry->s.name); return -1; } - if (pktio_entry->ops_data(ipc).type == PKTIO_TYPE_IPC_MASTER) + if (pkt_ipc->type == PKTIO_TYPE_IPC_MASTER) return _ipc_master_start(pktio_entry); else return _ipc_slave_start(pktio_entry); @@ -712,24 +717,23 @@ static int ipc_start(pktio_entry_t *pktio_entry) static int ipc_stop(pktio_entry_t *pktio_entry) { + pktio_ops_ipc_data_t *pkt_ipc = odp_ops_data(pktio_entry, ipc); unsigned tx_send = 0, tx_free = 0; - odp_atomic_store_u32(&pktio_entry->ops_data(ipc).ready, 0); + odp_atomic_store_u32(&pkt_ipc->ready, 0); - if (pktio_entry->ops_data(ipc).tx.send) - _ipc_free_ring_packets(pktio_entry, - pktio_entry->ops_data(ipc).tx.send); + if (pkt_ipc->tx.send) + _ipc_free_ring_packets(pktio_entry, pkt_ipc->tx.send); /* other process can transfer packets from one ring to * other, use delay here to free that packets. */ sleep(1); - if (pktio_entry->ops_data(ipc).tx.free) - _ipc_free_ring_packets(pktio_entry, - pktio_entry->ops_data(ipc).tx.free); - - if (pktio_entry->ops_data(ipc).tx.send) - tx_send = _ring_count(pktio_entry->ops_data(ipc).tx.send); - if (pktio_entry->ops_data(ipc).tx.free) - tx_free = _ring_count(pktio_entry->ops_data(ipc).tx.free); + if (pkt_ipc->tx.free) + _ipc_free_ring_packets(pktio_entry, pkt_ipc->tx.free); + + if (pkt_ipc->tx.send) + tx_send = _ring_count(pkt_ipc->tx.send); + if (pkt_ipc->tx.free) + tx_free = _ring_count(pkt_ipc->tx.free); if (tx_send | tx_free) { ODP_DBG("IPC rings: tx send %d tx free %d\n", tx_send, tx_free); @@ -740,6 +744,7 @@ static int ipc_stop(pktio_entry_t *pktio_entry) static int ipc_close(pktio_entry_t *pktio_entry) { + pktio_ops_ipc_data_t *pkt_ipc = odp_ops_data(pktio_entry, ipc); char ipc_shm_name[ODP_POOL_NAME_LEN + sizeof("_m_prod")]; char *dev = pktio_entry->s.name; char name[ODP_POOL_NAME_LEN]; @@ -748,7 +753,7 @@ static int ipc_close(pktio_entry_t *pktio_entry) ipc_stop(pktio_entry); - odp_shm_free(pktio_entry->ops_data(ipc).remote_pool_shm); + odp_shm_free(pkt_ipc->remote_pool_shm); if (sscanf(dev, "ipc:%d:%s", &pid, tail) == 2) snprintf(name, sizeof(name), "ipc:%s", tail); @@ -756,7 +761,7 @@ static int ipc_close(pktio_entry_t *pktio_entry) snprintf(name, sizeof(name), "%s", dev); /* unlink this pktio info for both master and slave */ - odp_shm_free(pktio_entry->ops_data(ipc).pinfo_shm); + odp_shm_free(pkt_ipc->pinfo_shm); /* destroy rings */ snprintf(ipc_shm_name, sizeof(ipc_shm_name), "%s_s_cons", name); From patchwork Tue Oct 10 12:00:13 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: 115396 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp3675489qgn; Tue, 10 Oct 2017 05:10:29 -0700 (PDT) X-Google-Smtp-Source: AOwi7QCgS+1O9uhAt5BDrVZUqvh/67qSCmRlYCPkvWOIr57BsfefqTqkQMDha2lZExLTiSEIDgeq X-Received: by 10.107.10.157 with SMTP id 29mr16910615iok.285.1507637429458; Tue, 10 Oct 2017 05:10:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507637429; cv=none; d=google.com; s=arc-20160816; b=go14uUru3svjgoHjc6y8GxcW0QOrznCdeXXYzkoP53GGb3IxPy2fz4i5nnLHAhUy9+ Fki/Xtjd9o3F4sNephLweg53i62tr7IejpKo/3/XuTwT0J2sH0jgIdx0HdZZGRm99T0E Pqg1sBjZ1QfI8HySHENGgKlD70ELpk3nBdvr+8VYOx5wE7rKZ9+jlE+gAeL85glIoJQP xS+aV5cUyHqLpz+gPFydS5pZwhFAxbk9teT57qrNf6/QiaPN9sTRm33F3blEqhXGI6Wk gQ44uBX/qTQQPzmqQ0ez2ekqxqP5J1k+R3I4tNnLkfWWMOMr/ycsBw190Di4brzIZ07G dBuw== 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=3AYoBlZMRQbG/3vVb4u2FqCrJAqTP7CSVSHKi0LzPus=; b=xP4f8coaK3JV61fjy4udX+ZsVAmsjTm9IjCVhOh60fV6f308zmmVHB7JvrqKw1ZhJx GscFXAI7SPdjfU7AlxInxbOFep5xuBzmW/i0gCpZCoElzyqDcFwxX5lri5uV2kIQ50TS Fnngh05US5VylIks8HrysUyGAQBYqU+dj/ZhDNGHShRom7sovTtjztvsz5AnNCRa9KO7 mk+Klw0oijBHdwiheM1bzR+k9WbvAbbidoKPqPE8MTnWLrjOpzbndlxxqHaHfbYA8xNh ApOOO5lZmKIWOqaqQf4toyvibYnvK77vpB+HSrqtWSceYQoTPtxuVn0KKjjgKgXlss9+ sqiw== 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 i66si312745iti.130.2017.10.10.05.10.28; Tue, 10 Oct 2017 05:10:29 -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 E1DDA62FC7; Tue, 10 Oct 2017 12:10:27 +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=-5.4 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, 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 AAB7C60D2C; Tue, 10 Oct 2017 12:03:16 +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 30AAE60C29; Tue, 10 Oct 2017 12:02:31 +0000 (UTC) Received: from forward103o.mail.yandex.net (forward103o.mail.yandex.net [37.140.190.177]) by lists.linaro.org (Postfix) with ESMTPS id 757C360CC1 for ; Tue, 10 Oct 2017 12:01:03 +0000 (UTC) Received: from mxback4j.mail.yandex.net (mxback4j.mail.yandex.net [IPv6:2a02:6b8:0:1619::10d]) by forward103o.mail.yandex.net (Yandex) with ESMTP id 6EFF55882169 for ; Tue, 10 Oct 2017 15:01:02 +0300 (MSK) Received: from smtp4o.mail.yandex.net (smtp4o.mail.yandex.net [2a02:6b8:0:1a2d::28]) by mxback4j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id FNqcUc3QLi-12vKm4RH; Tue, 10 Oct 2017 15:01:02 +0300 Received: by smtp4o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id NWf2cc9w7t-11eGAq1m; Tue, 10 Oct 2017 15:01:01 +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: Tue, 10 Oct 2017 15:00:13 +0300 Message-Id: <1507636815-18816-8-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1507636815-18816-1-git-send-email-odpbot@yandex.ru> References: <1507636815-18816-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 196 Subject: [lng-odp] [PATCH CLOUD-DEV v3 7/9] linux-gen: pktio: netmap: 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 196 (bogdanPricope:cloud_dev_pktio_ops_data_pr) ** https://github.com/Linaro/odp/pull/196 ** Patch: https://github.com/Linaro/odp/pull/196.patch ** Base sha: 3d3c8f71f39ff139695d6f4b8e5ea17502c5f7cf ** Merge commit sha: 2bae88983ff377d83fcf9c99bf5c380275454327 **/ .../include/odp_pktio_ops_subsystem.h | 2 - platform/linux-generic/odp_packet_io.c | 1 + platform/linux-generic/pktio/netmap.c | 96 +++++++++++++--------- 3 files changed, 60 insertions(+), 39 deletions(-) diff --git a/platform/linux-generic/include/odp_pktio_ops_subsystem.h b/platform/linux-generic/include/odp_pktio_ops_subsystem.h index 6bb31516a..ece4d46e0 100644 --- a/platform/linux-generic/include/odp_pktio_ops_subsystem.h +++ b/platform/linux-generic/include/odp_pktio_ops_subsystem.h @@ -79,7 +79,6 @@ typedef ODP_MODULE_CLASS(pktio_ops) { } pktio_ops_module_t; /* All implementations of this subsystem */ -#include #include /* Per implementation private data @@ -87,7 +86,6 @@ typedef ODP_MODULE_CLASS(pktio_ops) { */ typedef union { void *dpdk; - pktio_ops_netmap_data_t netmap; pktio_ops_pcap_data_t pcap; } pktio_ops_data_t; diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c index 9269f33da..3ed1c5d0d 100644 --- a/platform/linux-generic/odp_packet_io.c +++ b/platform/linux-generic/odp_packet_io.c @@ -29,6 +29,7 @@ #include #include #include +#include /* Sleep this many nanoseconds between pktin receive calls */ #define SLEEP_NSEC 1000 diff --git a/platform/linux-generic/pktio/netmap.c b/platform/linux-generic/pktio/netmap.c index 49d38f7f2..b21c90fd0 100644 --- a/platform/linux-generic/pktio/netmap.c +++ b/platform/linux-generic/pktio/netmap.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -49,7 +50,7 @@ static int netmap_do_ioctl(pktio_entry_t *pktio_entry, unsigned long cmd, int subcmd) { pktio_ops_netmap_data_t *pkt_nm = - &pktio_entry->ops_data(netmap); + odp_ops_data(pktio_entry, netmap); struct ethtool_value eval; struct ifreq ifr; int err; @@ -137,7 +138,7 @@ static int netmap_input_queues_config(pktio_entry_t *pktio_entry, const odp_pktin_queue_param_t *p) { pktio_ops_netmap_data_t *pkt_nm = - &pktio_entry->ops_data(netmap); + odp_ops_data(pktio_entry, netmap); odp_pktin_mode_t mode = pktio_entry->s.param.in_mode; unsigned num_queues = p->num_queues; odp_bool_t lockless; @@ -166,7 +167,7 @@ static int netmap_output_queues_config(pktio_entry_t *pktio_entry, const odp_pktout_queue_param_t *p) { pktio_ops_netmap_data_t *pkt_nm = - &pktio_entry->ops_data(netmap); + odp_ops_data(pktio_entry, netmap); pkt_nm->lockless_tx = (p->op_mode == ODP_PKTIO_OP_MT_UNSAFE); @@ -184,7 +185,7 @@ static inline void netmap_close_descriptors(pktio_entry_t *pktio_entry) { int i, j; pktio_ops_netmap_data_t *pkt_nm = - &pktio_entry->ops_data(netmap); + odp_ops_data(pktio_entry, netmap); for (i = 0; i < PKTIO_MAX_QUEUES; i++) { for (j = 0; j < NM_MAX_DESC; j++) { @@ -208,7 +209,7 @@ static inline void netmap_close_descriptors(pktio_entry_t *pktio_entry) static int netmap_close(pktio_entry_t *pktio_entry) { pktio_ops_netmap_data_t *pkt_nm = - &pktio_entry->ops_data(netmap); + odp_ops_data(pktio_entry, netmap); netmap_close_descriptors(pktio_entry); @@ -222,11 +223,13 @@ static int netmap_close(pktio_entry_t *pktio_entry) static int netmap_link_status(pktio_entry_t *pktio_entry) { - if (pktio_entry->ops_data(netmap).is_virtual) + pktio_ops_netmap_data_t *pkt_nm = + odp_ops_data(pktio_entry, netmap); + + if (pkt_nm->is_virtual) return 1; - return link_status_fd(pktio_entry->ops_data(netmap).sockfd, - pktio_entry->ops_data(netmap).if_name); + return link_status_fd(pkt_nm->sockfd, pkt_nm->if_name); } /** @@ -242,6 +245,8 @@ static inline int netmap_wait_for_link(pktio_entry_t *pktio_entry) { int i; int ret; + pktio_ops_netmap_data_t *pkt_nm = + odp_ops_data(pktio_entry, netmap); /* Wait for the link to come up */ for (i = 0; i <= NM_WAIT_TIMEOUT; i++) { @@ -253,12 +258,12 @@ static inline int netmap_wait_for_link(pktio_entry_t *pktio_entry) * until the opposing end's interface comes back up again. In * this case without the additional sleep pktio validation * tests fail. */ - if (!pktio_entry->ops_data(netmap).is_virtual) + if (!pkt_nm->is_virtual) sleep(1); if (ret == 1) return 1; } - ODP_DBG("%s link is down\n", pktio_entry->ops_data(netmap).if_name); + ODP_DBG("%s link is down\n", pkt_nm->if_name); return 0; } @@ -270,7 +275,7 @@ static inline int netmap_wait_for_link(pktio_entry_t *pktio_entry) static void netmap_init_capability(pktio_entry_t *pktio_entry) { pktio_ops_netmap_data_t *pkt_nm = - &pktio_entry->ops_data(netmap); + odp_ops_data(pktio_entry, netmap); odp_pktio_capability_t *capa = &pkt_nm->capa; memset(&pkt_nm->capa, 0, sizeof(odp_pktio_capability_t)); @@ -338,7 +343,7 @@ static int netmap_open(odp_pktio_t id ODP_UNUSED, pktio_entry_t *pktio_entry, uint32_t mtu; uint32_t buf_size; pktio_ops_netmap_data_t *pkt_nm = - &pktio_entry->ops_data(netmap); + odp_ops_data(pktio_entry, netmap); struct nm_desc *desc; struct netmap_ring *ring; odp_pktin_hash_proto_t hash_proto; @@ -462,7 +467,7 @@ static int netmap_open(odp_pktio_t id ODP_UNUSED, pktio_entry_t *pktio_entry, static int netmap_start(pktio_entry_t *pktio_entry) { pktio_ops_netmap_data_t *pkt_nm = - &pktio_entry->ops_data(netmap); + odp_ops_data(pktio_entry, netmap); netmap_ring_t *desc_ring; struct nm_desc *desc_ptr; unsigned i; @@ -618,8 +623,10 @@ static inline int netmap_pkt_to_odp(pktio_entry_t *pktio_entry, netmap_slot_t slot_tbl[], int16_t slot_num, odp_time_t *ts) { + pktio_ops_netmap_data_t *pkt_nm = + odp_ops_data(pktio_entry, netmap); odp_packet_t pkt; - odp_pool_t pool = pktio_entry->ops_data(netmap).pool; + odp_pool_t pool = pkt_nm->pool; odp_packet_hdr_t *pkt_hdr; odp_packet_hdr_t parsed_hdr; int i; @@ -627,7 +634,7 @@ static inline int netmap_pkt_to_odp(pktio_entry_t *pktio_entry, int alloc_len; /* Allocate maximum sized packets */ - alloc_len = pktio_entry->ops_data(netmap).mtu; + alloc_len = pkt_nm->mtu; num = packet_alloc_multi(pool, alloc_len, pkt_tbl, slot_num); @@ -640,10 +647,9 @@ static inline int netmap_pkt_to_odp(pktio_entry_t *pktio_entry, odp_prefetch(slot.buf); - if (odp_unlikely(len > pktio_entry-> - ops_data(netmap).max_frame_len)) { + if (odp_unlikely(len > pkt_nm->max_frame_len)) { ODP_ERR("RX: frame too big %" PRIu16 " %zu!\n", len, - pktio_entry->ops_data(netmap).max_frame_len); + pkt_nm->max_frame_len); goto fail; } @@ -740,7 +746,7 @@ static int netmap_recv(pktio_entry_t *pktio_entry, int index, { struct nm_desc *desc; pktio_ops_netmap_data_t *pkt_nm = - &pktio_entry->ops_data(netmap); + odp_ops_data(pktio_entry, netmap); unsigned first_desc_id = pkt_nm->rx_desc_ring[index].s.first; unsigned last_desc_id = pkt_nm->rx_desc_ring[index].s.last; unsigned desc_id; @@ -794,7 +800,7 @@ static int netmap_send(pktio_entry_t *pktio_entry, int index, const odp_packet_t pkt_table[], int num) { pktio_ops_netmap_data_t *pkt_nm = - &pktio_entry->ops_data(netmap); + odp_ops_data(pktio_entry, netmap); struct pollfd polld; struct nm_desc *desc; struct netmap_ring *ring; @@ -869,76 +875,92 @@ static int netmap_send(pktio_entry_t *pktio_entry, int index, static int netmap_mac_addr_get(pktio_entry_t *pktio_entry, void *mac_addr) { - memcpy(mac_addr, pktio_entry->ops_data(netmap).if_mac, ETH_ALEN); + pktio_ops_netmap_data_t *pkt_nm = + odp_ops_data(pktio_entry, netmap); + + memcpy(mac_addr, pkt_nm->if_mac, ETH_ALEN); return ETH_ALEN; } static uint32_t netmap_mtu_get(pktio_entry_t *pktio_entry) { - return pktio_entry->ops_data(netmap).mtu; + pktio_ops_netmap_data_t *pkt_nm = + odp_ops_data(pktio_entry, netmap); + + return pkt_nm->mtu; } static int netmap_promisc_mode_set(pktio_entry_t *pktio_entry, odp_bool_t enable) { - if (pktio_entry->ops_data(netmap).is_virtual) { + pktio_ops_netmap_data_t *pkt_nm = + odp_ops_data(pktio_entry, netmap); + + if (pkt_nm->is_virtual) { __odp_errno = ENOTSUP; return -1; } - return promisc_mode_set_fd( - pktio_entry->ops_data(netmap).sockfd, - pktio_entry->ops_data(netmap).if_name, enable); + return promisc_mode_set_fd(pkt_nm->sockfd, pkt_nm->if_name, enable); } static int netmap_promisc_mode_get(pktio_entry_t *pktio_entry) { - if (pktio_entry->ops_data(netmap).is_virtual) + pktio_ops_netmap_data_t *pkt_nm = + odp_ops_data(pktio_entry, netmap); + + if (pkt_nm->is_virtual) return 0; - return promisc_mode_get_fd( - pktio_entry->ops_data(netmap).sockfd, - pktio_entry->ops_data(netmap).if_name); + return promisc_mode_get_fd(pkt_nm->sockfd, pkt_nm->if_name); } static int netmap_capability(pktio_entry_t *pktio_entry, odp_pktio_capability_t *capa) { - *capa = pktio_entry->ops_data(netmap).capa; + pktio_ops_netmap_data_t *pkt_nm = + odp_ops_data(pktio_entry, netmap); + + *capa = pkt_nm->capa; return 0; } static int netmap_stats(pktio_entry_t *pktio_entry, odp_pktio_stats_t *stats) { + pktio_ops_netmap_data_t *pkt_nm = + odp_ops_data(pktio_entry, netmap); + if (pktio_entry->s.stats_type == STATS_UNSUPPORTED) { memset(stats, 0, sizeof(*stats)); return 0; } return sock_stats_fd(pktio_entry, - stats, - pktio_entry->ops_data(netmap).sockfd); + stats, pkt_nm->sockfd); } static int netmap_stats_reset(pktio_entry_t *pktio_entry) { + pktio_ops_netmap_data_t *pkt_nm = + odp_ops_data(pktio_entry, netmap); + if (pktio_entry->s.stats_type == STATS_UNSUPPORTED) { memset(&pktio_entry->s.stats, 0, sizeof(odp_pktio_stats_t)); return 0; } - return sock_stats_reset_fd(pktio_entry, - pktio_entry->ops_data(netmap).sockfd); + return sock_stats_reset_fd(pktio_entry, pkt_nm->sockfd); } static void netmap_print(pktio_entry_t *pktio_entry) { odp_pktin_hash_proto_t hash_proto; + pktio_ops_netmap_data_t *pkt_nm = + odp_ops_data(pktio_entry, netmap); - if (rss_conf_get_fd(pktio_entry->ops_data(netmap).sockfd, - pktio_entry->ops_data(netmap).if_name, &hash_proto)) + if (rss_conf_get_fd(pkt_nm->sockfd, pkt_nm->if_name, &hash_proto)) rss_conf_print(&hash_proto); } From patchwork Tue Oct 10 12:00:14 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: 115398 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp3678642qgn; Tue, 10 Oct 2017 05:13:18 -0700 (PDT) X-Google-Smtp-Source: AOwi7QBNHu67SQ4DER/6gAabslV1L2Ok4DEJZ//OwoTi4vTt4NKUfWslriNpT+w3InPVwXJF3Nry X-Received: by 10.36.6.1 with SMTP id 1mr18872754itv.91.1507637598464; Tue, 10 Oct 2017 05:13:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507637598; cv=none; d=google.com; s=arc-20160816; b=xKGIVn06TSVc0ov9rkUv8dpPooDxrk2KfvdQjB6aYorN5/vzVQjAiBtAxGVP3A1Eq7 PRXtu2t/CeotU8l9pWz/+9Rh93uFJcnHwa1wT98/RE3dnod+sA03Y0t8aaB4RP9va73M cLaachnRbRQu+upgUjQNwpuJbQKJeRE19G2c9y7nt8ubV0lzovmjtBuVqfB7jNV2dIvg KB9MfOH8uhYp84nVD324cX9soeKNzvpQJ+aaI2P7AjgSUXyPcIJ00QkXjZQW2La73HuT Y9/8/e4OcufMIJT5PBJ9uBVEcQT/kIj/LKr2bc34FsGia1iZX1I90mRl/WOFZdfdSFRw 9Oqw== 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=yl5/nt67IVsUyr/EYvgUSkUlygBwnICdyuiyLKZQ7Eg=; b=CU/MKWSGPXphvcFIWuFa45KrcbVAR0nIbUx/JFlAePzC0zomCaZX60bdc1oNvtk76m zKwnpHh3/UBmcJHQP2KHNFhl9jXQkxKdf9SsOQHdUws73Bl/nqmp6DGUrq6cznS5OcJW mWIKiKv6tii5bKHo3qIBWyRYxpUWpVZtDvS+s4rSyW8vo1r7yTNqN4McDVYlNjGOakSc 1It50b+fOCjjzLM9yrLrH16gyxXy4JtTN5iTMygEy3AvkvyfuVGJkGIOD8i/6hvew9OC xpOJQ04T6fTEPeEKdfUGEHZMoiNbSM1rxNSsuw0TEUHbVThclbnMg//JtR+XrCTxYVHh yJ1w== 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 x21si8385751iod.123.2017.10.10.05.13.16; Tue, 10 Oct 2017 05:13:18 -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 9601160DC9; Tue, 10 Oct 2017 12:13:16 +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=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, 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 2484360D50; Tue, 10 Oct 2017 12:03:27 +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 9FB5160C9A; Tue, 10 Oct 2017 12:02:33 +0000 (UTC) Received: from forward106j.mail.yandex.net (forward106j.mail.yandex.net [5.45.198.249]) by lists.linaro.org (Postfix) with ESMTPS id CBB9460C63 for ; Tue, 10 Oct 2017 12:01:05 +0000 (UTC) Received: from mxback6g.mail.yandex.net (mxback6g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:167]) by forward106j.mail.yandex.net (Yandex) with ESMTP id 9588018037D8 for ; Tue, 10 Oct 2017 15:01:04 +0300 (MSK) Received: from smtp4o.mail.yandex.net (smtp4o.mail.yandex.net [2a02:6b8:0:1a2d::28]) by mxback6g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id eKrlTjqdsH-14i4AuY9; Tue, 10 Oct 2017 15:01:04 +0300 Received: by smtp4o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id NWf2cc9w7t-14eCSKN8; Tue, 10 Oct 2017 15:01:04 +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: Tue, 10 Oct 2017 15:00:14 +0300 Message-Id: <1507636815-18816-9-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1507636815-18816-1-git-send-email-odpbot@yandex.ru> References: <1507636815-18816-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 196 Subject: [lng-odp] [PATCH CLOUD-DEV v3 8/9] linux-gen: pktio: pcap: 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 196 (bogdanPricope:cloud_dev_pktio_ops_data_pr) ** https://github.com/Linaro/odp/pull/196 ** Patch: https://github.com/Linaro/odp/pull/196.patch ** Base sha: 3d3c8f71f39ff139695d6f4b8e5ea17502c5f7cf ** Merge commit sha: 2bae88983ff377d83fcf9c99bf5c380275454327 **/ .../linux-generic/include/odp_pktio_ops_subsystem.h | 4 ---- platform/linux-generic/pktio/pcap.c | 19 +++++++++---------- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/platform/linux-generic/include/odp_pktio_ops_subsystem.h b/platform/linux-generic/include/odp_pktio_ops_subsystem.h index ece4d46e0..5449eccbd 100644 --- a/platform/linux-generic/include/odp_pktio_ops_subsystem.h +++ b/platform/linux-generic/include/odp_pktio_ops_subsystem.h @@ -78,15 +78,11 @@ typedef ODP_MODULE_CLASS(pktio_ops) { odp_api_proto(pktio_ops, print) print; } pktio_ops_module_t; -/* All implementations of this subsystem */ -#include - /* Per implementation private data * TODO: refactory each implementation to hide it internally */ typedef union { void *dpdk; - pktio_ops_pcap_data_t pcap; } pktio_ops_data_t; /* Extract pktio ops data from pktio entry structure */ diff --git a/platform/linux-generic/pktio/pcap.c b/platform/linux-generic/pktio/pcap.c index 7808242f5..acadbd87d 100644 --- a/platform/linux-generic/pktio/pcap.c +++ b/platform/linux-generic/pktio/pcap.c @@ -41,6 +41,7 @@ #include #include #include +#include #include @@ -139,8 +140,7 @@ static int _pcapif_init_tx(pktio_ops_pcap_data_t *pcap) static int pcapif_init(odp_pktio_t id ODP_UNUSED, pktio_entry_t *pktio_entry, const char *devname, odp_pool_t pool) { - pktio_ops_pcap_data_t *pcap = - &pktio_entry->ops_data(pcap); + pktio_ops_pcap_data_t *pcap = odp_ops_data(pktio_entry, pcap); int ret; memset(pcap, 0, sizeof(pktio_ops_pcap_data_t)); @@ -167,7 +167,7 @@ static int pcapif_init(odp_pktio_t id ODP_UNUSED, pktio_entry_t *pktio_entry, static int pcapif_close(pktio_entry_t *pktio_entry) { - pktio_ops_pcap_data_t *pcap = &pktio_entry->ops_data(pcap); + pktio_ops_pcap_data_t *pcap = odp_ops_data(pktio_entry, pcap); if (pcap->tx_dump) pcap_dump_close(pcap->tx_dump); @@ -214,8 +214,7 @@ static int pcapif_recv_pkt(pktio_entry_t *pktio_entry, int index ODP_UNUSED, odp_packet_t pkt; odp_packet_hdr_t *pkt_hdr; uint32_t pkt_len; - pktio_ops_pcap_data_t *pcap = - &pktio_entry->ops_data(pcap); + pktio_ops_pcap_data_t *pcap = odp_ops_data(pktio_entry, pcap); odp_time_t ts_val; odp_time_t *ts = NULL; @@ -298,8 +297,7 @@ static int _pcapif_dump_pkt(pktio_ops_pcap_data_t *pcap, odp_packet_t pkt) static int pcapif_send_pkt(pktio_entry_t *pktio_entry, int index ODP_UNUSED, const odp_packet_t pkts[], int len) { - pktio_ops_pcap_data_t *pcap = - &pktio_entry->ops_data(pcap); + pktio_ops_pcap_data_t *pcap = odp_ops_data(pktio_entry, pcap); int i; odp_ticketlock_lock(&pktio_entry->s.txl); @@ -367,8 +365,7 @@ static int pcapif_promisc_mode_set(pktio_entry_t *pktio_entry, { char filter_exp[64] = {0}; struct bpf_program bpf; - pktio_ops_pcap_data_t *pcap = - &pktio_entry->ops_data(pcap); + pktio_ops_pcap_data_t *pcap = odp_ops_data(pktio_entry, pcap); if (!pcap->rx) { pcap->promisc = enable; @@ -408,7 +405,9 @@ static int pcapif_promisc_mode_set(pktio_entry_t *pktio_entry, static int pcapif_promisc_mode_get(pktio_entry_t *pktio_entry) { - return pktio_entry->ops_data(pcap).promisc; + pktio_ops_pcap_data_t *pcap = odp_ops_data(pktio_entry, pcap); + + return pcap->promisc; } static int pcapif_stats_reset(pktio_entry_t *pktio_entry) From patchwork Tue Oct 10 12:00:15 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: 115399 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp3679583qgn; Tue, 10 Oct 2017 05:14:13 -0700 (PDT) X-Google-Smtp-Source: AOwi7QBOq2clPXQgJ+FmAK7/Pw40ixLhvbo62KvmOA53pPEU5fP8+YnkNnW4K6tiPsCPiAMbkIQA X-Received: by 10.107.82.6 with SMTP id g6mr11569749iob.253.1507637653326; Tue, 10 Oct 2017 05:14:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507637653; cv=none; d=google.com; s=arc-20160816; b=rPhxfoTjBMXWmvvnv24EgLkch+Zd8BZBcYdrz8C5kho7fAZZzw3X/H11qDrb8prMRU 5kYwU9+X+SzWmBYPHX1mA/+4AdHsK3Af/DWyuCoeHkNcA1jptaWVcOuFkWLFR1syfHte S4JNwnlXFkPTvdPEdfY+vh0UrUAbDRcLdXvDzv7qxCUyIEcG4l3VOrRL8ZjQpIqGjCad kAMaGpiKk+Pao9EJLr5dCgBExduJgbsIcaAo8T52btCbma6wQuCytUX09M/DyQkiZQ5x YaDYU4HXbVHwTVCgbx9yduM83zdnaZavqqpFk23ewyD9AflNY5kG8OUPfRKKMoQSkdGw 9dTQ== 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=d3Q7HxEnZVkhI4oOoPUHGEDEiLq+BFXOWEYg+NFcdCU=; b=PUK8LojUT/bVTzynHhk1XNjnM6PlmQpIX54nWToojaBrFH/mUy2IhlMD/RDaZbF4pc wlypApjtTSI2/MRs/i5WS9GeYhX86TWhEw+KijpxlF/0rXtal9GMIf2onXqTP3J8iYDo 6UVndZ4PzTeoxUQeKtD6Uiv14v2k6E3HUHluJ1FGQzK7ycOUdyK3DvEO6KF44/FDEHhN 2mg13advxcDLi1LX2aadNdNXvFUwhXwSdtQQPiwnfMje5JWBtIhzHwpD5B8RoEqDMgXI 20U5ahqAcRBijNa6SkrdbV+QKByt4+XY/IB5O6EKLn7z+n4PNwcUmAzrgAQnLJb45Dhe OdYQ== 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 k14si9156368ita.104.2017.10.10.05.14.11; Tue, 10 Oct 2017 05:14:13 -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 89CE662874; Tue, 10 Oct 2017 12:14:11 +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,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,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 6A4C260D72; Tue, 10 Oct 2017 12:03:35 +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 077AE60CA9; Tue, 10 Oct 2017 12:02:40 +0000 (UTC) Received: from forward104p.mail.yandex.net (forward104p.mail.yandex.net [77.88.28.107]) by lists.linaro.org (Postfix) with ESMTPS id 8927F60CC6 for ; Tue, 10 Oct 2017 12:01:06 +0000 (UTC) Received: from mxback4g.mail.yandex.net (mxback4g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:165]) by forward104p.mail.yandex.net (Yandex) with ESMTP id 8809F180E3C for ; Tue, 10 Oct 2017 15:01:05 +0300 (MSK) Received: from smtp4o.mail.yandex.net (smtp4o.mail.yandex.net [2a02:6b8:0:1a2d::28]) by mxback4g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id qodU3qDyyH-153uLBYU; Tue, 10 Oct 2017 15:01:05 +0300 Received: by smtp4o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id NWf2cc9w7t-14eeQiwH; Tue, 10 Oct 2017 15:01:04 +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: Tue, 10 Oct 2017 15:00:15 +0300 Message-Id: <1507636815-18816-10-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1507636815-18816-1-git-send-email-odpbot@yandex.ru> References: <1507636815-18816-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 196 Subject: [lng-odp] [PATCH CLOUD-DEV v3 9/9] linux-gen: pktio: dpdk: 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 196 (bogdanPricope:cloud_dev_pktio_ops_data_pr) ** https://github.com/Linaro/odp/pull/196 ** Patch: https://github.com/Linaro/odp/pull/196.patch ** Base sha: 3d3c8f71f39ff139695d6f4b8e5ea17502c5f7cf ** Merge commit sha: 2bae88983ff377d83fcf9c99bf5c380275454327 **/ .../linux-dpdk/include/odp_packet_io_internal.h | 7 +- platform/linux-dpdk/pktio/dpdk.c | 57 +++++------- .../linux-generic/include/odp_packet_io_internal.h | 6 +- .../include/odp_pktio_ops_subsystem.h | 12 +-- platform/linux-generic/pktio/dpdk.c | 100 +++++++++++---------- 5 files changed, 82 insertions(+), 100 deletions(-) diff --git a/platform/linux-dpdk/include/odp_packet_io_internal.h b/platform/linux-dpdk/include/odp_packet_io_internal.h index d31c449e2..089ad38c5 100644 --- a/platform/linux-dpdk/include/odp_packet_io_internal.h +++ b/platform/linux-dpdk/include/odp_packet_io_internal.h @@ -29,7 +29,6 @@ extern "C" { #define PKTIO_MAX_QUEUES 64 #include -#include /* Forward declaration */ typedef union pktio_entry_u pktio_entry_t; @@ -42,10 +41,8 @@ typedef union pktio_entry_u pktio_entry_t; struct pktio_entry { const pktio_ops_module_t *ops; /**< Implementation specific methods */ - union { - pktio_ops_data_t ops_data; - uint8_t _ops_data[ODP_PKTIO_ODPS_DATA_MAX_SIZE]; - }; + uint8_t ops_data[ODP_PKTIO_ODPS_DATA_MAX_SIZE]; /**< IO operation + specific data */ /* These two locks together lock the whole pktio device */ odp_ticketlock_t rxl; /**< RX ticketlock */ odp_ticketlock_t txl; /**< TX ticketlock */ diff --git a/platform/linux-dpdk/pktio/dpdk.c b/platform/linux-dpdk/pktio/dpdk.c index d7a90197a..b54f06b8b 100644 --- a/platform/linux-dpdk/pktio/dpdk.c +++ b/platform/linux-dpdk/pktio/dpdk.c @@ -4,6 +4,8 @@ * SPDX-License-Identifier: BSD-3-Clause */ +#include + #include #include #include @@ -39,18 +41,6 @@ static pktio_ops_module_t dpdk_pktio_ops; static uint32_t mtu_get_pkt_dpdk(pktio_entry_t *pktio_entry); -static inline pktio_ops_dpdk_data_t * - __retrieve_op_data(pktio_entry_t *pktio) -{ - return (pktio_ops_dpdk_data_t *)(pktio->ops_data(dpdk)); -} - -static inline void __release_op_data(pktio_entry_t *pktio) -{ - free(pktio->ops_data(dpdk)); - pktio->ops_data(dpdk) = NULL; -} - /* Test if s has only digits or not. Dpdk pktio uses only digits.*/ static int _dpdk_netdev_is_valid(const char *s) { @@ -108,7 +98,7 @@ static int input_queues_config_pkt_dpdk(pktio_entry_t *pktio_entry, const odp_pktin_queue_param_t *p) { pktio_ops_dpdk_data_t *pkt_dpdk = - __retrieve_op_data(pktio_entry); + odp_ops_data(pktio_entry, dpdk); odp_pktin_mode_t mode = pktio_entry->s.param.in_mode; /** @@ -138,7 +128,7 @@ static int output_queues_config_pkt_dpdk(pktio_entry_t *pktio_entry, const odp_pktout_queue_param_t *p) { pktio_ops_dpdk_data_t *pkt_dpdk = - __retrieve_op_data(pktio_entry); + odp_ops_data(pktio_entry, dpdk); if (p->op_mode == ODP_PKTIO_OP_MT_UNSAFE) pkt_dpdk->lockless_tx = 1; @@ -155,7 +145,8 @@ static int setup_pkt_dpdk(odp_pktio_t pktio ODP_UNUSED, { uint8_t portid = 0; struct rte_eth_dev_info dev_info; - pktio_ops_dpdk_data_t *pkt_dpdk = NULL; + pktio_ops_dpdk_data_t *pkt_dpdk = + odp_ops_data(pktio_entry, dpdk); int i; if (!_dpdk_netdev_is_valid(netdev)) { @@ -164,9 +155,6 @@ static int setup_pkt_dpdk(odp_pktio_t pktio ODP_UNUSED, return -1; } - pktio_entry->ops_data(dpdk) = malloc(sizeof(pktio_ops_dpdk_data_t)); - pkt_dpdk = __retrieve_op_data(pktio_entry); - if (odp_unlikely(pkt_dpdk == NULL)) { ODP_ERR("Failed to allocate pktio_ops_dpdk_data_t struct"); return -1; @@ -202,12 +190,11 @@ static int setup_pkt_dpdk(odp_pktio_t pktio ODP_UNUSED, static int close_pkt_dpdk(pktio_entry_t *pktio_entry) { const pktio_ops_dpdk_data_t *pkt_dpdk = - __retrieve_op_data(pktio_entry); + odp_ops_data(pktio_entry, dpdk); if (pktio_entry->s.state == PKTIO_STATE_STOPPED) rte_eth_dev_close(pkt_dpdk->portid); - __release_op_data(pktio_entry); return 0; } @@ -215,7 +202,7 @@ static int start_pkt_dpdk(pktio_entry_t *pktio_entry) { int ret, i; pktio_ops_dpdk_data_t *pkt_dpdk = - __retrieve_op_data(pktio_entry); + odp_ops_data(pktio_entry, dpdk); uint8_t portid = pkt_dpdk->portid; int sid = rte_eth_dev_socket_id(pkt_dpdk->portid); int socket_id = sid < 0 ? 0 : sid; @@ -324,7 +311,8 @@ static int start_pkt_dpdk(pktio_entry_t *pktio_entry) static int stop_pkt_dpdk(pktio_entry_t *pktio_entry) { pktio_ops_dpdk_data_t *pkt_dpdk = - __retrieve_op_data(pktio_entry); + odp_ops_data(pktio_entry, dpdk); + rte_eth_dev_stop(pkt_dpdk->portid); return 0; } @@ -373,7 +361,7 @@ static int recv_pkt_dpdk(pktio_entry_t *pktio_entry, int index, { uint16_t nb_rx, i; pktio_ops_dpdk_data_t *pkt_dpdk = - __retrieve_op_data(pktio_entry); + odp_ops_data(pktio_entry, dpdk); odp_packet_t *saved_pkt_table; uint8_t min = pkt_dpdk->min_rx_burst; odp_time_t ts_val; @@ -490,7 +478,7 @@ static int send_pkt_dpdk(pktio_entry_t *pktio_entry, int index, { int pkts; pktio_ops_dpdk_data_t *pkt_dpdk = - __retrieve_op_data(pktio_entry); + odp_ops_data(pktio_entry, dpdk); if (!pkt_dpdk->lockless_tx) odp_ticketlock_lock(&pkt_dpdk->tx_lock[index]); @@ -543,7 +531,7 @@ static uint32_t _dpdk_vdev_mtu(uint8_t port_id) static uint32_t mtu_get_pkt_dpdk(pktio_entry_t *pktio_entry) { pktio_ops_dpdk_data_t *pkt_dpdk = - __retrieve_op_data(pktio_entry); + odp_ops_data(pktio_entry, dpdk); uint16_t mtu = 0; int ret; @@ -604,7 +592,7 @@ static int _dpdk_vdev_promisc_mode_set(uint8_t port_id, int enable) static int promisc_mode_set_pkt_dpdk(pktio_entry_t *pktio_entry, int enable) { const pktio_ops_dpdk_data_t *pkt_dpdk = - __retrieve_op_data(pktio_entry); + odp_ops_data(pktio_entry, dpdk); uint8_t portid = pkt_dpdk->portid; if (enable) @@ -648,7 +636,7 @@ static int _dpdk_vdev_promisc_mode(uint8_t port_id) static int promisc_mode_get_pkt_dpdk(pktio_entry_t *pktio_entry) { const pktio_ops_dpdk_data_t *pkt_dpdk = - __retrieve_op_data(pktio_entry); + odp_ops_data(pktio_entry, dpdk); uint8_t portid = pkt_dpdk->portid; if (pkt_dpdk->vdev_sysc_promisc) @@ -660,25 +648,27 @@ static int promisc_mode_get_pkt_dpdk(pktio_entry_t *pktio_entry) static int mac_get_pkt_dpdk(pktio_entry_t *pktio_entry, void *mac_addr) { const pktio_ops_dpdk_data_t *pkt_dpdk = - __retrieve_op_data(pktio_entry); + odp_ops_data(pktio_entry, dpdk); + rte_eth_macaddr_get(pkt_dpdk->portid, (struct ether_addr *)mac_addr); return ETH_ALEN; } - static int capability_pkt_dpdk(pktio_entry_t *pktio_entry, odp_pktio_capability_t *capa) { const pktio_ops_dpdk_data_t *pkt_dpdk = - __retrieve_op_data(pktio_entry); + odp_ops_data(pktio_entry, dpdk); + *capa = pkt_dpdk->capa; return 0; } + static int link_status_pkt_dpdk(pktio_entry_t *pktio_entry) { const pktio_ops_dpdk_data_t *pkt_dpdk = - __retrieve_op_data(pktio_entry); + odp_ops_data(pktio_entry, dpdk); struct rte_eth_link link; rte_eth_link_get(pkt_dpdk->portid, &link); @@ -702,7 +692,7 @@ static void stats_convert(struct rte_eth_stats *rte_stats, static int stats_pkt_dpdk(pktio_entry_t *pktio_entry, odp_pktio_stats_t *stats) { const pktio_ops_dpdk_data_t *pkt_dpdk = - __retrieve_op_data(pktio_entry); + odp_ops_data(pktio_entry, dpdk); int ret; struct rte_eth_stats rte_stats; @@ -721,7 +711,8 @@ static int stats_pkt_dpdk(pktio_entry_t *pktio_entry, odp_pktio_stats_t *stats) static int stats_reset_pkt_dpdk(pktio_entry_t *pktio_entry) { const pktio_ops_dpdk_data_t *pkt_dpdk = - __retrieve_op_data(pktio_entry); + odp_ops_data(pktio_entry, dpdk); + rte_eth_stats_reset(pkt_dpdk->portid); return 0; } diff --git a/platform/linux-generic/include/odp_packet_io_internal.h b/platform/linux-generic/include/odp_packet_io_internal.h index 79f5b1082..b26a35d25 100644 --- a/platform/linux-generic/include/odp_packet_io_internal.h +++ b/platform/linux-generic/include/odp_packet_io_internal.h @@ -50,10 +50,8 @@ typedef union pktio_entry_u pktio_entry_t; struct pktio_entry { const pktio_ops_module_t *ops; /**< Implementation specific methods */ - union { - pktio_ops_data_t ops_data; /**< IO operation specific data */ - uint8_t _ops_data[ODP_PKTIO_ODPS_DATA_MAX_SIZE]; - }; + uint8_t ops_data[ODP_PKTIO_ODPS_DATA_MAX_SIZE]; /**< IO operation + specific data */ /* These two locks together lock the whole pktio device */ odp_ticketlock_t rxl; /**< RX ticketlock */ odp_ticketlock_t txl; /**< TX ticketlock */ diff --git a/platform/linux-generic/include/odp_pktio_ops_subsystem.h b/platform/linux-generic/include/odp_pktio_ops_subsystem.h index 5449eccbd..f1ff48832 100644 --- a/platform/linux-generic/include/odp_pktio_ops_subsystem.h +++ b/platform/linux-generic/include/odp_pktio_ops_subsystem.h @@ -78,21 +78,11 @@ typedef ODP_MODULE_CLASS(pktio_ops) { odp_api_proto(pktio_ops, print) print; } pktio_ops_module_t; -/* Per implementation private data - * TODO: refactory each implementation to hide it internally - */ -typedef union { - void *dpdk; -} pktio_ops_data_t; - -/* Extract pktio ops data from pktio entry structure */ -#define ops_data(mod) s.ops_data.mod - /* Maximum size of pktio specific ops data.*/ #define ODP_PKTIO_ODPS_DATA_MAX_SIZE 80000 /* Extract pktio ops data from pktio entry structure */ #define odp_ops_data(_p, _mod) \ - ((pktio_ops_ ## _mod ## _data_t *)(uintptr_t)_p->s._ops_data) + ((pktio_ops_ ## _mod ## _data_t *)(uintptr_t)_p->s.ops_data) #endif diff --git a/platform/linux-generic/pktio/dpdk.c b/platform/linux-generic/pktio/dpdk.c index 484af82c5..990e1a57a 100644 --- a/platform/linux-generic/pktio/dpdk.c +++ b/platform/linux-generic/pktio/dpdk.c @@ -14,6 +14,7 @@ #include #include #include +#include #include @@ -39,18 +40,6 @@ #include #include -static inline pktio_ops_dpdk_data_t * - __retrieve_op_data(pktio_entry_t *pktio) -{ - return (pktio_ops_dpdk_data_t *)(pktio->ops_data(dpdk)); -} - -static inline void __release_op_data(pktio_entry_t *pktio) -{ - free(pktio->ops_data(dpdk)); - pktio->ops_data(dpdk) = NULL; -} - #if ODP_DPDK_ZERO_COPY ODP_STATIC_ASSERT(CONFIG_PACKET_HEADROOM == RTE_PKTMBUF_HEADROOM, "ODP and DPDK headroom sizes not matching!"); @@ -363,6 +352,7 @@ static inline int mbuf_to_pkt(pktio_entry_t *pktio_entry, struct rte_mbuf *mbuf_table[], uint16_t mbuf_num, odp_time_t *ts) { + pktio_ops_dpdk_data_t *pkt_dpdk = odp_ops_data(pktio_entry, dpdk); odp_packet_t pkt; odp_packet_hdr_t *pkt_hdr; uint16_t pkt_len; @@ -371,11 +361,11 @@ static inline int mbuf_to_pkt(pktio_entry_t *pktio_entry, int i, j; int nb_pkts = 0; int alloc_len, num; - odp_pool_t pool = __retrieve_op_data(pktio_entry)->pool; odp_pktin_config_opt_t *pktin_cfg = &pktio_entry->s.config.pktin; + odp_pool_t pool = pkt_dpdk->pool; /* Allocate maximum sized packets */ - alloc_len = __retrieve_op_data(pktio_entry)->data_room; + alloc_len = pkt_dpdk->data_room; num = packet_alloc_multi(pool, alloc_len, pkt_table, mbuf_num); if (num != mbuf_num) { @@ -545,7 +535,7 @@ static inline int pkt_to_mbuf(pktio_entry_t *pktio_entry, const odp_packet_t pkt_table[], uint16_t num) { pktio_ops_dpdk_data_t *pkt_dpdk = - __retrieve_op_data(pktio_entry); + odp_ops_data(pktio_entry, dpdk); int i, j; char *data; uint16_t pkt_len; @@ -589,6 +579,8 @@ static inline int mbuf_to_pkt_zero(pktio_entry_t *pktio_entry, struct rte_mbuf *mbuf_table[], uint16_t mbuf_num, odp_time_t *ts) { + pktio_ops_dpdk_data_t *pkt_dpdk = + odp_ops_data(pktio_entry, dpdk); odp_packet_t pkt; odp_packet_hdr_t *pkt_hdr; uint16_t pkt_len; @@ -596,8 +588,8 @@ static inline int mbuf_to_pkt_zero(pktio_entry_t *pktio_entry, void *data; int i; int nb_pkts = 0; - odp_pool_t pool = __retrieve_op_data(pktio_entry)->pool; odp_pktin_config_opt_t *pktin_cfg = &pktio_entry->s.config.pktin; + odp_pool_t pool = pkt_dpdk->pool; for (i = 0; i < mbuf_num; i++) { odp_packet_hdr_t parsed_hdr; @@ -662,7 +654,7 @@ static inline int pkt_to_mbuf_zero(pktio_entry_t *pktio_entry, uint16_t *copy_count) { pktio_ops_dpdk_data_t *pkt_dpdk = - __retrieve_op_data(pktio_entry); + odp_ops_data(pktio_entry, dpdk); odp_pktout_config_opt_t *pktout_cfg = &pktio_entry->s.config.pktout; int i; *copy_count = 0; @@ -752,7 +744,7 @@ static uint32_t dpdk_vdev_mtu_get(uint8_t port_id) static uint32_t dpdk_mtu_get(pktio_entry_t *pktio_entry) { pktio_ops_dpdk_data_t *pkt_dpdk = - __retrieve_op_data(pktio_entry); + odp_ops_data(pktio_entry, dpdk); uint32_t mtu = 0; if (rte_eth_dev_get_mtu(pkt_dpdk->port_id, (uint16_t *)&mtu)) @@ -846,7 +838,7 @@ static int dpdk_setup_port(pktio_entry_t *pktio_entry) { int ret; pktio_ops_dpdk_data_t *pkt_dpdk = - __retrieve_op_data(pktio_entry); + odp_ops_data(pktio_entry, dpdk); struct rte_eth_rss_conf rss_conf; uint16_t hw_ip_checksum = 0; @@ -895,7 +887,7 @@ static int dpdk_setup_port(pktio_entry_t *pktio_entry) static int dpdk_close(pktio_entry_t *pktio_entry) { pktio_ops_dpdk_data_t *pkt_dpdk = - __retrieve_op_data(pktio_entry); + odp_ops_data(pktio_entry, dpdk); unsigned idx; unsigned i, j; @@ -913,7 +905,6 @@ static int dpdk_close(pktio_entry_t *pktio_entry) if (!ODP_DPDK_ZERO_COPY) rte_mempool_free(pkt_dpdk->pkt_pool); - __release_op_data(pktio_entry); return 0; } @@ -1046,6 +1037,8 @@ static int dpdk_pktio_init_local(void) static int dpdk_input_queues_config(pktio_entry_t *pktio_entry, const odp_pktin_queue_param_t *p) { + pktio_ops_dpdk_data_t *pkt_dpdk = + odp_ops_data(pktio_entry, dpdk); odp_pktin_mode_t mode = pktio_entry->s.param.in_mode; odp_bool_t lockless; @@ -1059,9 +1052,9 @@ static int dpdk_input_queues_config(pktio_entry_t *pktio_entry, lockless = 0; if (p->hash_enable && p->num_queues > 1) - __retrieve_op_data(pktio_entry)->hash = p->hash_proto; + pkt_dpdk->hash = p->hash_proto; - __retrieve_op_data(pktio_entry)->lockless_rx = lockless; + pkt_dpdk->lockless_rx = lockless; return 0; } @@ -1070,7 +1063,7 @@ static int dpdk_output_queues_config(pktio_entry_t *pktio_entry, const odp_pktout_queue_param_t *p) { pktio_ops_dpdk_data_t *pkt_dpdk = - __retrieve_op_data(pktio_entry); + odp_ops_data(pktio_entry, dpdk); odp_bool_t lockless; if (p->op_mode == ODP_PKTIO_OP_MT_UNSAFE) @@ -1087,7 +1080,7 @@ static void dpdk_init_capability(pktio_entry_t *pktio_entry, struct rte_eth_dev_info *dev_info) { pktio_ops_dpdk_data_t *pkt_dpdk = - __retrieve_op_data(pktio_entry); + odp_ops_data(pktio_entry, dpdk); odp_pktio_capability_t *capa = &pkt_dpdk->capa; int ptype_cnt; int ptype_l3_ipv4 = 0; @@ -1164,7 +1157,8 @@ static int dpdk_open(odp_pktio_t id ODP_UNUSED, const char *netdev, odp_pool_t pool) { - pktio_ops_dpdk_data_t *pkt_dpdk = NULL; + pktio_ops_dpdk_data_t *pkt_dpdk = + odp_ops_data(pktio_entry, dpdk); struct rte_eth_dev_info dev_info; struct rte_mempool *pkt_pool; char pool_name[RTE_MEMPOOL_NAMESIZE]; @@ -1192,9 +1186,6 @@ static int dpdk_open(odp_pktio_t id ODP_UNUSED, dpdk_initialized = 1; } - pktio_entry->ops_data(dpdk) = malloc(sizeof(pktio_ops_dpdk_data_t)); - pkt_dpdk = __retrieve_op_data(pktio_entry); - if (odp_unlikely(pkt_dpdk == NULL)) { ODP_ERR("Failed to allocate pktio_ops_dpdk_data_t struct"); return -1; @@ -1208,7 +1199,6 @@ static int dpdk_open(odp_pktio_t id ODP_UNUSED, if (rte_eth_dev_count() == 0) { ODP_ERR("No DPDK ports found\n"); - __release_op_data(pktio_entry); return -1; } @@ -1217,7 +1207,6 @@ static int dpdk_open(odp_pktio_t id ODP_UNUSED, mtu = dpdk_mtu_get(pktio_entry); if (mtu == 0) { ODP_ERR("Failed to read interface MTU\n"); - __release_op_data(pktio_entry); return -1; } pkt_dpdk->mtu = mtu + _ODP_ETHHDR_LEN; @@ -1254,7 +1243,6 @@ static int dpdk_open(odp_pktio_t id ODP_UNUSED, } if (pkt_pool == NULL) { ODP_ERR("Cannot init mbuf packet pool\n"); - __release_op_data(pktio_entry); return -1; } @@ -1280,7 +1268,7 @@ static int dpdk_open(odp_pktio_t id ODP_UNUSED, static int dpdk_start(pktio_entry_t *pktio_entry) { pktio_ops_dpdk_data_t *pkt_dpdk = - __retrieve_op_data(pktio_entry); + odp_ops_data(pktio_entry, dpdk); uint8_t port_id = pkt_dpdk->port_id; int ret; unsigned i; @@ -1331,7 +1319,10 @@ static int dpdk_start(pktio_entry_t *pktio_entry) static int dpdk_stop(pktio_entry_t *pktio_entry) { - rte_eth_dev_stop(__retrieve_op_data(pktio_entry)->port_id); + pktio_ops_dpdk_data_t *pkt_dpdk = + odp_ops_data(pktio_entry, dpdk); + + rte_eth_dev_stop(pkt_dpdk->port_id); return 0; } @@ -1340,7 +1331,7 @@ static int dpdk_recv(pktio_entry_t *pktio_entry, int index, odp_packet_t pkt_table[], int num) { pktio_ops_dpdk_data_t *pkt_dpdk = - __retrieve_op_data(pktio_entry); + odp_ops_data(pktio_entry, dpdk); pkt_cache_t *rx_cache = &pkt_dpdk->rx_cache[index]; odp_time_t ts_val; odp_time_t *ts = NULL; @@ -1416,7 +1407,7 @@ static int dpdk_send(pktio_entry_t *pktio_entry, int index, { struct rte_mbuf *tx_mbufs[num]; pktio_ops_dpdk_data_t *pkt_dpdk = - __retrieve_op_data(pktio_entry); + odp_ops_data(pktio_entry, dpdk); uint16_t copy_count = 0; int tx_pkts; int i; @@ -1479,16 +1470,21 @@ static int dpdk_send(pktio_entry_t *pktio_entry, int index, static int dpdk_mac_addr_get(pktio_entry_t *pktio_entry, void *mac_addr) { - rte_eth_macaddr_get(__retrieve_op_data(pktio_entry)->port_id, + pktio_ops_dpdk_data_t *pkt_dpdk = + odp_ops_data(pktio_entry, dpdk); + + rte_eth_macaddr_get(pkt_dpdk->port_id, (struct ether_addr *)mac_addr); return ETH_ALEN; } static int dpdk_promisc_mode_set(pktio_entry_t *pktio_entry, odp_bool_t enable) { - uint8_t port_id = __retrieve_op_data(pktio_entry)->port_id; + pktio_ops_dpdk_data_t *pkt_dpdk = + odp_ops_data(pktio_entry, dpdk); + uint8_t port_id = pkt_dpdk->port_id; - if (__retrieve_op_data(pktio_entry)->vdev_sysc_promisc) + if (pkt_dpdk->vdev_sysc_promisc) return dpdk_vdev_promisc_mode_set(port_id, enable); if (enable) @@ -1501,9 +1497,11 @@ static int dpdk_promisc_mode_set(pktio_entry_t *pktio_entry, odp_bool_t enable) static int dpdk_promisc_mode_get(pktio_entry_t *pktio_entry) { - uint8_t port_id = __retrieve_op_data(pktio_entry)->port_id; + pktio_ops_dpdk_data_t *pkt_dpdk = + odp_ops_data(pktio_entry, dpdk); + uint8_t port_id = pkt_dpdk->port_id; - if (__retrieve_op_data(pktio_entry)->vdev_sysc_promisc) + if (pkt_dpdk->vdev_sysc_promisc) return dpdk_vdev_promisc_mode_get(port_id); else return rte_eth_promiscuous_get(port_id); @@ -1512,18 +1510,22 @@ static int dpdk_promisc_mode_get(pktio_entry_t *pktio_entry) static int dpdk_capability(pktio_entry_t *pktio_entry, odp_pktio_capability_t *capa) { - *capa = __retrieve_op_data(pktio_entry)->capa; + pktio_ops_dpdk_data_t *pkt_dpdk = + odp_ops_data(pktio_entry, dpdk); + + *capa = pkt_dpdk->capa; return 0; } static int dpdk_link_status(pktio_entry_t *pktio_entry) { + pktio_ops_dpdk_data_t *pkt_dpdk = + odp_ops_data(pktio_entry, dpdk); struct rte_eth_link link; memset(&link, 0, sizeof(struct rte_eth_link)); - rte_eth_link_get_nowait( - __retrieve_op_data(pktio_entry)->port_id, &link); + rte_eth_link_get_nowait(pkt_dpdk->port_id, &link); return link.link_status; } @@ -1542,11 +1544,12 @@ static void stats_convert(const struct rte_eth_stats *rte_stats, static int dpdk_stats(pktio_entry_t *pktio_entry, odp_pktio_stats_t *stats) { + pktio_ops_dpdk_data_t *pkt_dpdk = + odp_ops_data(pktio_entry, dpdk); int ret; struct rte_eth_stats rte_stats; - ret = rte_eth_stats_get( - __retrieve_op_data(pktio_entry)->port_id, &rte_stats); + ret = rte_eth_stats_get(pkt_dpdk->port_id, &rte_stats); if (ret == 0) { stats_convert(&rte_stats, stats); @@ -1557,7 +1560,10 @@ static int dpdk_stats(pktio_entry_t *pktio_entry, odp_pktio_stats_t *stats) static int dpdk_stats_reset(pktio_entry_t *pktio_entry) { - rte_eth_stats_reset(__retrieve_op_data(pktio_entry)->port_id); + pktio_ops_dpdk_data_t *pkt_dpdk = + odp_ops_data(pktio_entry, dpdk); + + rte_eth_stats_reset(pkt_dpdk->port_id); return 0; }