From patchwork Tue Oct 10 10:00:06 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: 115373 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp3561270qgn; Tue, 10 Oct 2017 03:03:23 -0700 (PDT) X-Google-Smtp-Source: AOwi7QBeUz2V69OM/n8uYA5zZlcDAMgNVl8lXQLgjkKaXK+YI6TIzjY6ipoKjHpF2Od6Cd5zKzx4 X-Received: by 10.36.20.81 with SMTP id 78mr16566714itg.127.1507629803729; Tue, 10 Oct 2017 03:03:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507629803; cv=none; d=google.com; s=arc-20160816; b=vOtwR9GpZfA0XeVveAHJflMsOjRUjjRec/PP7OD9/VxyO6tkeb7c0MOBm+oVGunTJu HwOuCCKeOGiYHbvArHp/IpzSIV53HFKAn7n1d0bbBByqmuNA21BD1mQcWD4e9V1EjeOo scXgOfBF3drS7YgOhwYYx2w0Rcy7Cc/tV7FWVlJwWdTX0AyUIYWpHkpfbgnj+4EFHhcB jcvFHm4c7P/1CPZGWNjH/9NX2RIRPitoHD6rv2JxYAO2hen/Z7JBXCtltSw1imU6uVI0 knC1xh51XofVDmTMZhYaFU+2uIBXDGJEqbWheK2X1EvaY8BaXKa0ZiWJvAQ50URKD+gW 0GFw== 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=U/8Z1Sq5PyoIiEzjWXmaP5VKACf34Ou0+wWRl2FlC7o=; b=Ga8PJ60BQIIr1f4EjVBTyowt5XnIN1xR4Sp8gfr6oyXDMDqIXz7M6F6O+BRc1KzcpW jNN1lYOirnKUAUOl35hhdXlLBD6dfB8c1RMF52Rk+FQlte7uCYCJD8Dcrj8gPIOEwJT+ F3YVl6CxWBXwqUnjyqRcoujTXNjLRMNhUZM9fEdEVuxc/PhTN2TnKompcImuu4r5+OqR HHnaupRMPgk5PL+CoxFxAes6ShmjkMdFB/U6dV7Kprl2MJxLHRlu+jUhce6wQ8sSlcub k9gQqTtYnD/r9n9N8+1KN+T4UOMO9hWUlrrTCbDLia2DRljhVS/plZSssTN2AskVz3f+ 1N5Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 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 (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id t62si8153832iof.169.2017.10.10.03.03.23; Tue, 10 Oct 2017 03:03:23 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 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 4B7B460BFE; Tue, 10 Oct 2017 10:03:23 +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 5C64260C42; Tue, 10 Oct 2017 10:01: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 3D88360BFB; Tue, 10 Oct 2017 10:01:00 +0000 (UTC) Received: from forward106o.mail.yandex.net (forward106o.mail.yandex.net [37.140.190.187]) by lists.linaro.org (Postfix) with ESMTPS id 5AE9F60765 for ; Tue, 10 Oct 2017 10:00:50 +0000 (UTC) Received: from mxback15g.mail.yandex.net (mxback15g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:94]) by forward106o.mail.yandex.net (Yandex) with ESMTP id BE7BE7819BA for ; Tue, 10 Oct 2017 13:00:48 +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 4aKuY7Dv6i-0gnuCh0a; Tue, 10 Oct 2017 13:00:42 +0300 Received: by smtp4o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id hbf1r0CSIp-0gea6VAk; Tue, 10 Oct 2017 13:00:42 +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 13:00:06 +0300 Message-Id: <1507629614-17356-2-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1507629614-17356-1-git-send-email-odpbot@yandex.ru> References: <1507629614-17356-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 196 Subject: [lng-odp] [PATCH CLOUD-DEV v2 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: 396a3d25a5aaadda96c34eb8a6801599f7afac84 **/ 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 10: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: 115372 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp3560305qgn; Tue, 10 Oct 2017 03:02:23 -0700 (PDT) X-Google-Smtp-Source: AOwi7QBzkMQVyTpv9UUfGFcnTGrk47pYtsn6JioOJQ2qtTXcKrVYcNDU1K5lXmTSEBxkW2FMMTBu X-Received: by 10.36.103.194 with SMTP id u185mr18669308itc.57.1507629743772; Tue, 10 Oct 2017 03:02:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507629743; cv=none; d=google.com; s=arc-20160816; b=es1FVK3WJWDwCfAYYYUflBd3zg6cuKVZu0A4wU3CduEoTLZ3BpBl+6jXy7o6xLhfbz EjWS5Kfuyrw8jtx60tjl3mBOhH6XziGpg0fvln5vVb4tdEysEA+lWjw/XcjkPIOBTbpC oOvrj/A+gj6NGRPG8hEg2py04LqlCUF7RGy2f4vkItYDp6WAha82p6Max1sWJ/sNsDsB OIyMqh9dcWCgtqRRlb0qXxF32MICC1DSzR+T9QNCN2ptpelpTI3F4pMQJPvWxIOtihNP bIVhqb3k+GXAo5cUeydFdkzhCoY6acG6fqWdhVwrR06IxK/sEM6KWZhXT7J6Wj9GSwpj efIA== 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=XJIT2AXLggOOQk6+G8dhAku2HCfJ+RL6Qh3jk0524PE=; b=QLkWtdAAopYHhW/TEDqxlqoc2kOGP9a/YRsnHFaSmwWoT4m8Mv/bR5dnsalzyiWQCD ObxbOPmRIWPFHqikKN66BeDwp1CeyOO7UbO/K+1d/ypXVydq3C4kix5bJmPixAAhKPW7 JOk6edR42Fner7oL6XHGtrxUFWjGGSh2MIhkv4JstOVr3S4IoaUQFuA5WbZx9dGpn9Si UUNomi/pG2lEuOOK6hw69f30wy916iBFAnp9uUpmrTmXhcCSqAe+7txUKZg+3mNER6uh 3AZ6D7DnTFG1cGjWj1XFQuP/C+FOlWfJT8giQHDDzqL0a4R5hjcCEfnywKT2t/eG+ZOZ LJ1Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 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 (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id d19si5093013ioj.319.2017.10.10.03.02.23; Tue, 10 Oct 2017 03:02:23 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 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 49FD060D6E; Tue, 10 Oct 2017 10:02:23 +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,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 F043860BD8; Tue, 10 Oct 2017 10:01: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 6599360BFE; Tue, 10 Oct 2017 10:00:57 +0000 (UTC) Received: from forward101j.mail.yandex.net (forward101j.mail.yandex.net [5.45.198.241]) by lists.linaro.org (Postfix) with ESMTPS id 11EB2609B5 for ; Tue, 10 Oct 2017 10:00:51 +0000 (UTC) Received: from mxback19j.mail.yandex.net (mxback19j.mail.yandex.net [IPv6:2a02:6b8:0:1619::95]) by forward101j.mail.yandex.net (Yandex) with ESMTP id 7F6A7124329F for ; Tue, 10 Oct 2017 13:00:49 +0300 (MSK) Received: from smtp4o.mail.yandex.net (smtp4o.mail.yandex.net [2a02:6b8:0:1a2d::28]) by mxback19j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id AZInZcE6Zy-0nZ0gU5P; Tue, 10 Oct 2017 13:00:49 +0300 Received: by smtp4o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id hbf1r0CSIp-0meCUbdg; Tue, 10 Oct 2017 13: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 13:00:07 +0300 Message-Id: <1507629614-17356-3-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1507629614-17356-1-git-send-email-odpbot@yandex.ru> References: <1507629614-17356-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 196 Subject: [lng-odp] [PATCH CLOUD-DEV v2 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: 396a3d25a5aaadda96c34eb8a6801599f7afac84 **/ .../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 10: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: 115374 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp3562244qgn; Tue, 10 Oct 2017 03:04:29 -0700 (PDT) X-Google-Smtp-Source: AOwi7QBqFpF7W2ouyLSI1R3tEE4rPlAThxDQy7yQwlU2vscU0Vtnf+oSJPc1yxo3mmAsnDvct6/9 X-Received: by 10.36.137.69 with SMTP id s66mr14277117itd.22.1507629869097; Tue, 10 Oct 2017 03:04:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507629869; cv=none; d=google.com; s=arc-20160816; b=q9dJWx195IlTbl9L9LiFU2XPByeYfFHUtSmi7b65j0NLAAj5UQlbTcBnz+ZfTUKAxt D45E0qvH3MJeEh1Y8MFeAYRtj0mORKFKSlGZ+cOJMWlqigOGQHxwN6vKrsiXKHM3qxE9 Xoha5t6yvZ4AzYZfEGYs8Jz09iW0aWFopoBGzMdxo61FqwcRJ8fXXaUaMJ3WDD+B4SoY 3b/SoNSLvXe+ETIJjPFXUedw9i9otccqXabbsUcLMmumqnOlk+CZdKz9xRKIKuEP0He3 ZW8ido09ZXtyu6NmhWNNxdLmBHAEZXdAgPxBNluQyvCUkYpuYwu2Sc0K6cr9p5YbYeqd U4Pg== 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=gly8y00wn8LR28owlJfnLb3eBX1KG1cWLZ428WuZeBc=; b=J/nkIOcfeoOLv/Xtg+PiY9P6V3lICBBYIGd2euIq8urQQm4Nm5JwMtdXO/Kuv/WKdH Yicxd93OesbtGO66b+wXEOu9Y7ynupu/Mnasf7MOOrB5Bk4IRqfF0HYKzmUOtpgUrjww l6H58G/bSPwWckw6CjZ/8rX7dsQQRzBIPXlh/sYk0xxO6mOXmjNWinT0s84I5qW5ZqkV t5TL8FmR3Ju0rgy6PO41Fj7P+r0Bio2tXGki9zT5ume3SzEE6R8wrQeR+0PmuLGb5GjO YZWJCd1ciweKwzYGmnZfNjD0E7x2+NOWG2K3M/Gua1eiiWtSwRHfOaDadDzT2obvXzwS cLvg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 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 (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id a28si7894443ioj.257.2017.10.10.03.04.28; Tue, 10 Oct 2017 03:04:29 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 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 88C6860C48; Tue, 10 Oct 2017 10:04:28 +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 A77A860C35; Tue, 10 Oct 2017 10:01:29 +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 A20A960C29; Tue, 10 Oct 2017 10:01:04 +0000 (UTC) Received: from forward100j.mail.yandex.net (forward100j.mail.yandex.net [5.45.198.240]) by lists.linaro.org (Postfix) with ESMTPS id F16D560A4D for ; Tue, 10 Oct 2017 10:00:51 +0000 (UTC) Received: from mxback5j.mail.yandex.net (mxback5j.mail.yandex.net [IPv6:2a02:6b8:0:1619::10e]) by forward100j.mail.yandex.net (Yandex) with ESMTP id 8C60B5D8418B for ; Tue, 10 Oct 2017 13:00:50 +0300 (MSK) Received: from smtp4o.mail.yandex.net (smtp4o.mail.yandex.net [2a02:6b8:0:1a2d::28]) by mxback5j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id 5x4WSPatrV-0og0DbKq; Tue, 10 Oct 2017 13:00:50 +0300 Received: by smtp4o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id hbf1r0CSIp-0neC6Ksk; Tue, 10 Oct 2017 13:00:49 +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 13:00:08 +0300 Message-Id: <1507629614-17356-4-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1507629614-17356-1-git-send-email-odpbot@yandex.ru> References: <1507629614-17356-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 196 Subject: [lng-odp] [PATCH CLOUD-DEV v2 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: 396a3d25a5aaadda96c34eb8a6801599f7afac84 **/ 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 10: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: 115378 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp3568168qgn; Tue, 10 Oct 2017 03:11:07 -0700 (PDT) X-Google-Smtp-Source: AOwi7QCBZQCkok8pHwTxK0rATBw6zQ5Eit63dTEKDWjqLm7mf+LBYNK5UcFPoBT9otzsa7bUVXTB X-Received: by 10.107.52.200 with SMTP id b191mr4838621ioa.298.1507630266925; Tue, 10 Oct 2017 03:11:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507630266; cv=none; d=google.com; s=arc-20160816; b=QHt30y3u6umBnoGz7X+u3L9fvn/ztXyfnlRgKd3gXBioGOCTSuhOb2vFV4Ph8z5gQO Kw87CH65YeY/MEOKtSUWFqae1+aKJwEyDdEJq1QQSPjQcpkI6Cjf411KDug70NyXCn0Z yJc0srRzXFagIEYva5/T20UEBpyTlNrB74ZrubUd04kJmWJ3wlWhWVcg+B+1N68KbqWt 2/m4fsPIw02uei33MfvIZt7S5NUImqi/oh48MIa7OqJbDyBdBBGvToNwrEtruYtvgYEF wjG1Ud4nCOaeA3vP9Wkmn0OvUeebpOheeGCS5ODzYxFKRmTSX552JvGXAync/n5YXtJV nX7Q== 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=XrifzUjnUDrjkHvSw/oiqlxoh35MS5v37EOWT/ty6/g=; b=q82M6/3gd98hxYgY+R+3pncUAoym/E2OYRMLQNWpBfUwQLivedYR13pF3atUTLpQov DP0ebeTuwN4cfP01Y5ZrdawPWe87Iu6SxhVTAQZj+4SkglYVh4dFwaoUdE5lQ9WjSD58 61AnRx7qX59dDBKHNuSLI1+JGZ8xfcTK/ae8h7XQ3uXSCLqPUG3vmiPlhJdfWky2Qdsf GqvzeMWHyUdeMz0IHaavkFoHTASD2NHy84zVCoZcoUJPiFKM/lM0KRqQHCi3VIfCRk+/ kiXK2A/imwvWqimgCuclFsTLx4VJ1pGazpuj58FJdEEp3z/24Fs6VnbGZ3pR42Rg0nWO kAkA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 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 (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id m186si8621818ith.109.2017.10.10.03.11.06; Tue, 10 Oct 2017 03:11:06 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 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 72F9460E53; Tue, 10 Oct 2017 10:11:06 +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 6E61A60D3A; Tue, 10 Oct 2017 10:02:03 +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 EE24C609B5; Tue, 10 Oct 2017 10:01:08 +0000 (UTC) Received: from forward100p.mail.yandex.net (forward100p.mail.yandex.net [77.88.28.100]) by lists.linaro.org (Postfix) with ESMTPS id 9E19960B4B for ; Tue, 10 Oct 2017 10:00:52 +0000 (UTC) Received: from mxback9g.mail.yandex.net (mxback9g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:170]) by forward100p.mail.yandex.net (Yandex) with ESMTP id 44AB95101334 for ; Tue, 10 Oct 2017 13:00:51 +0300 (MSK) Received: from smtp4o.mail.yandex.net (smtp4o.mail.yandex.net [2a02:6b8:0:1a2d::28]) by mxback9g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id GlFNqJM2ve-0pD8oCGk; Tue, 10 Oct 2017 13:00:51 +0300 Received: by smtp4o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id hbf1r0CSIp-0oeCbdOm; Tue, 10 Oct 2017 13: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 13:00:09 +0300 Message-Id: <1507629614-17356-5-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1507629614-17356-1-git-send-email-odpbot@yandex.ru> References: <1507629614-17356-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 196 Subject: [lng-odp] [PATCH CLOUD-DEV v2 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: 396a3d25a5aaadda96c34eb8a6801599f7afac84 **/ .../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 10: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: 115375 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp3564361qgn; Tue, 10 Oct 2017 03:06:40 -0700 (PDT) X-Google-Smtp-Source: AOwi7QCQIxHbL5EaNNoD3Xi0bsfCie8h6+0fHT7ByCu0r/Hh1BFZOsXec8qJArDvNkPSOr9TbN+A X-Received: by 10.107.135.8 with SMTP id j8mr13338403iod.116.1507630000576; Tue, 10 Oct 2017 03:06:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507630000; cv=none; d=google.com; s=arc-20160816; b=tz2h/RLPH4FoeQLKwLJsSKPZNMoZybkeui9crj+HrZBheTgHmyV/xICmrgDSUBCDM5 HTX7rWURIm2rcyx/NJY2QNCquA52cEDwQuJaAejCv5QeBkqCWfnVRd/bS55Qw44jcjLW n0LzvICQxwW+Sy5vUtvD0OyxU/5mQwlih0RiVYJMtktZ3OLEov1miQRahOr2udQABWo3 /Tmiq/AibGx4R4aV8pNwB8c7YjYZXhuivGpeAL42MWB68GT8wSUS1rIB4+JcWOaFhuuS Mv6U6o9W64pJIjN96KFoBEiGZTTBG9/q5tAQF13VPdLrehxDljm5Mc55uuVnDYUOPTSb QkZw== 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=bCatcrs2/u98UnKk12uCuHSUunp0mPkLnYHzBSWje74=; b=PjyzWr95UwfjoCHkP/PUiJcm0nvPLRlhN9zOXWehyX0kahjDaKAzR8JtO2HkF3kR1T rQpqzXMZ2cTfF9zo/VxyuO4TeSM1niQFX0VkZv429mARThJu/2w3CX14lGamaDP2kgX7 DhQTzombIbofVuZcg3fSF5k+oDBXKEtWJDL5C/TjaH2CuY+NXkjgtlmTcQPNEI81MzKP eAEnWI6ug6sc8DTQW790kZ2P+vITqdJaisNMn6zG+Do98g2W4CIIKwbRUliKt8SujZeh YRoRutO0hW3dYyGmXWwyyWwuaigJYm0ykfGE/2VAHPyIKtqgwo+xM6LYVVsXj7Rphs+j tYeQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 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 (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id p2si7990253iof.273.2017.10.10.03.06.40; Tue, 10 Oct 2017 03:06:40 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 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 13ACE60DB8; Tue, 10 Oct 2017 10:06:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW,URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id F291F60CBD; Tue, 10 Oct 2017 10:01:39 +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 368D960BD8; Tue, 10 Oct 2017 10:01:05 +0000 (UTC) Received: from forward103p.mail.yandex.net (forward103p.mail.yandex.net [77.88.28.106]) by lists.linaro.org (Postfix) with ESMTPS id 7C4DB60BD8 for ; Tue, 10 Oct 2017 10:00:53 +0000 (UTC) Received: from mxback7g.mail.yandex.net (mxback7g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:168]) by forward103p.mail.yandex.net (Yandex) with ESMTP id D80022184115 for ; Tue, 10 Oct 2017 13:00:51 +0300 (MSK) Received: from smtp4o.mail.yandex.net (smtp4o.mail.yandex.net [2a02:6b8:0:1a2d::28]) by mxback7g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id i7ow4m1trw-0pk4YYfH; Tue, 10 Oct 2017 13:00:51 +0300 Received: by smtp4o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id hbf1r0CSIp-0peGGCYl; Tue, 10 Oct 2017 13:00:51 +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 13:00:10 +0300 Message-Id: <1507629614-17356-6-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1507629614-17356-1-git-send-email-odpbot@yandex.ru> References: <1507629614-17356-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 196 Subject: [lng-odp] [PATCH CLOUD-DEV v2 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: 396a3d25a5aaadda96c34eb8a6801599f7afac84 **/ .../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 10: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: 115377 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp3566802qgn; Tue, 10 Oct 2017 03:09:35 -0700 (PDT) X-Google-Smtp-Source: AOwi7QBNyS2LA9aY/8W3DhDazzONfNqkhJhEmChtATuXuPBAiG0e3FWH4mxFd08cZN+KvpHUDKHi X-Received: by 10.107.162.67 with SMTP id l64mr4332198ioe.278.1507630175876; Tue, 10 Oct 2017 03:09:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507630175; cv=none; d=google.com; s=arc-20160816; b=PPc7HdqyeZyQcysTtC3TresIpTgb3De1acI8cOzLxsg1Cd6fLWer3tjjHTNiNyvlmI /gJA/s+PKTXM3lZgxkY6T2lQCKgH88oonzhVLQoBPyF/IzRtN+HXQXwP5aZ5dxMo1s46 KA5m+a0LJRZiz6r9OIMl2N0j7buxSCMKNbDmRBppyCvOwYoN0D/GofpEwDlHAImQB4Kw oRrJOixUceFGXbye/p0h8UprefoZQYuWhGnJFnL2Uvq8hcikF+g0R2EMXvNQwXE2mAPJ kicWlzWdz1maSBO2Z/B++Jp3caomM9CgITTHN0neFo21tFpHkXYbNtZb1E++T8NY5IC+ u2qg== 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=vqZ7se8TYz604rIdMFkjsadKXpRVc9COJLh7u+booiQ=; b=fH+So/dRJftEEjfbj9UAn1yn7b2Sz71ilG5Ox6Cj5nuEonfZhmM9+GHOgbBi2PikfP 9ez97j/i7MwjRB/2bbutbQOSxd23kTUEhJnkLWaYVUtlsofBtmhJZbY7383F7q7oVI3j ptfGBxAApseTw60ds0SILt57FcR/o0NWG7Bp1zA98Yw8IHefp/Tn7Rx2G874jaVXW5b4 hDlyC22vG9VehxLEs4JDkJiQFTQsAtjSSQUj/aIEJZsfO6gNJwNw3Y6iB7uWDLkAxAMm IdVngjcpVCbNZaRXiF32wBIhyOjhkDnDmQtd1+25VRbEvz6Zl6a2fTpRNPWGRCfVfSw/ qrbA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 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 (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id 11si7495347ioi.360.2017.10.10.03.09.35; Tue, 10 Oct 2017 03:09:35 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 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 3576360D79; Tue, 10 Oct 2017 10:09: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 2807660D2D; Tue, 10 Oct 2017 10:01:58 +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 BAC3160765; Tue, 10 Oct 2017 10:01:07 +0000 (UTC) Received: from forward104o.mail.yandex.net (forward104o.mail.yandex.net [37.140.190.179]) by lists.linaro.org (Postfix) with ESMTPS id 2966B60BF6 for ; Tue, 10 Oct 2017 10:00:54 +0000 (UTC) Received: from mxback6o.mail.yandex.net (mxback6o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::20]) by forward104o.mail.yandex.net (Yandex) with ESMTP id B08427037ED for ; Tue, 10 Oct 2017 13:00:52 +0300 (MSK) Received: from smtp4o.mail.yandex.net (smtp4o.mail.yandex.net [2a02:6b8:0:1a2d::28]) by mxback6o.mail.yandex.net (nwsmtp/Yandex) with ESMTP id nZl8H7TilA-0qO0RcwH; Tue, 10 Oct 2017 13:00:52 +0300 Received: by smtp4o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id hbf1r0CSIp-0peasYwO; Tue, 10 Oct 2017 13:00:51 +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 13:00:11 +0300 Message-Id: <1507629614-17356-7-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1507629614-17356-1-git-send-email-odpbot@yandex.ru> References: <1507629614-17356-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 196 Subject: [lng-odp] [PATCH CLOUD-DEV v2 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: 396a3d25a5aaadda96c34eb8a6801599f7afac84 **/ .../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 10: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: 115380 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp3571562qgn; Tue, 10 Oct 2017 03:15:19 -0700 (PDT) X-Google-Smtp-Source: AOwi7QBYXyq11SNy6dN42qlwyGrNCRe2fLK5k3PQ7KXUySLaT9232ICX3Jb71mCVgzWWUwSmbpfm X-Received: by 10.36.203.3 with SMTP id u3mr16127108itg.136.1507630519357; Tue, 10 Oct 2017 03:15:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507630519; cv=none; d=google.com; s=arc-20160816; b=PZ9N/0BdmtdQu3Dy1dQo18aa653uXvKnnu0JIVdTpNePtne91ct2npoC6IAHoBrPE5 Z8WyrGQvus075Phs+Be2ve/WLJW5g1ie2A+s9GqT6SQABP3erIfjRo47SxDf2Ng4V9Uj LrWz0UKkeUI1aK66j2Op4SNz4mUGWKXb96tsl+en1yJGUdaTZ9Jn3VcO0zLtZ/z/HPg2 t1ViEZxAzX1m/ERrCNXSzCqUWm5KLDh8n+ApbdMn6708u8oJ2bNPvfpmsInh6Nk0J3ua fCn1BdF7l+M/Vl3P2ZDriSx75i0oiIxzfT4tcZHO6eIQaAEiPTn9W4xQ9jOj2vpAh6pj 2ycQ== 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=GYpGdPtxbqBhxMQIFEbBUN+4EfHu1A+6qlkI8yYmEKo=; b=Y+ILjgtqkxvicrEUFsGJx6dF83HgNYx1mey3vpBc9PKwE/h1ermEHGqx4Y/BO2tP+y IghBSZYog7KKIqCJNpcPm2bWdUXF7/LJzotEj3wFIYzrNci13aHzyJcbxn+Ctjz0sUVm d5V/A5uhFDxq8XEvy8m+fvUmbtnUaK6RCEQPOE/e+WZu7alOaFDHxTLRj3qDHAeaGwFH 32ehSb0dbBgglBhgMAkOdPWIckek+Dn6sfeaff9Rx5Nj/HWOwP7OvYpXbHzgV8WLxb+M J8ZkuIrtGSs060JbLrstaZHfw8b1ugCw8HEdk7ikvrAEAILazwxrhH23XZWjwDbMX2Kk 5XfQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 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 (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id p9si3774845iop.130.2017.10.10.03.15.19; Tue, 10 Oct 2017 03:15:19 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 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 DFC7A60ECC; Tue, 10 Oct 2017 10:15:18 +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 C000260D45; Tue, 10 Oct 2017 10:02:31 +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 6275360D6E; Tue, 10 Oct 2017 10:02:21 +0000 (UTC) Received: from forward106j.mail.yandex.net (forward106j.mail.yandex.net [5.45.198.249]) by lists.linaro.org (Postfix) with ESMTPS id EA7DD60A4D for ; Tue, 10 Oct 2017 10:01:04 +0000 (UTC) Received: from mxback1j.mail.yandex.net (mxback1j.mail.yandex.net [IPv6:2a02:6b8:0:1619::10a]) by forward106j.mail.yandex.net (Yandex) with ESMTP id 5C6F21800F3F for ; Tue, 10 Oct 2017 13:00:59 +0300 (MSK) Received: from smtp4o.mail.yandex.net (smtp4o.mail.yandex.net [2a02:6b8:0:1a2d::28]) by mxback1j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id 4aP5Hs9YiM-0rxWCcq1; Tue, 10 Oct 2017 13:00:53 +0300 Received: by smtp4o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id hbf1r0CSIp-0qemuOC1; Tue, 10 Oct 2017 13:00:52 +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 13:00:12 +0300 Message-Id: <1507629614-17356-8-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1507629614-17356-1-git-send-email-odpbot@yandex.ru> References: <1507629614-17356-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 196 Subject: [lng-odp] [PATCH CLOUD-DEV v2 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: 396a3d25a5aaadda96c34eb8a6801599f7afac84 **/ .../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 10: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: 115376 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp3566184qgn; Tue, 10 Oct 2017 03:08:51 -0700 (PDT) X-Google-Smtp-Source: AOwi7QDLjSQwgz2gE47HRbjlJAOQ/y/jqW8Gul9njmiYXKHDQ6vQG62ODJ+ZeRX/28SUZ6JsC+P4 X-Received: by 10.107.48.76 with SMTP id w73mr7062460iow.301.1507630131188; Tue, 10 Oct 2017 03:08:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507630131; cv=none; d=google.com; s=arc-20160816; b=iKc4AlrRkFPJST+51U9U5X0mYGjcJHijH6ojR5eK6WwNrSftz2FGiVTx85jARox4nd iiscQvEMUF7tyFIPeCIwY8p9nFZ1esPGEpQjv7iMbPhRDZXPU4GqlQLFCnyy4209f7Gn IdHX4trOZDTvBOgVapwtbJGgqgdMBF3wQCJX2l/fX8iXZ1T5o3tEZSkQfTG3j1P5Yu88 zCJSrHsvgfp+OiMDqQoKlLX6puhr64qgQBe7Ippqa1kBlKOsHDJEQy9ECec7GtlMDdbA v7T0TV9RhCiDmhZQ0DYhIO/r9FhMlnIjPBjuBr4YTkcIhwvpPTZx8mvo3l+ycyoXwjyG zRPA== 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=naIiD1sKc1e9tH5tPaC8bJmVe0o3kqnGyBNIYtC178g=; b=gfRBClCaGDN3Fy5Vp2OsyMZZ5pomy78Z69Ir+TRcYpoJG8wIhqSBd4eNrccMwNVgwY sDr+aT06NDbiarauCC0sqkjR5JBOY//qbUlC8Krn14+AXUtuxBPHwHX2AvuPWa9c8Br0 GH1UC/vgrnfiaMi6S8DpS4vzCjwcYi/rnJqxgICMaHWgndpOIqV+lBxqJ+b1gCnOc6VF q1g2Yh8lhn2sUpbMU6aNQuyImjLDq7UigCycSLGKA/sQr6VifwDpx4ZPIIgDZpMa7K9b MAtNEH18n+ik56SPudDCtyIxQLLRrMycP2SG36fHn1SyR7xua7sAh4YQ6xvhTl0xan9C GJ6w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 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 (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id u67si8886817itf.100.2017.10.10.03.08.50; Tue, 10 Oct 2017 03:08:51 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 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 A675B60DB2; Tue, 10 Oct 2017 10:08:50 +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,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 CC92C60D1F; Tue, 10 Oct 2017 10:01:48 +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 B899A60BD8; Tue, 10 Oct 2017 10:01:07 +0000 (UTC) Received: from forward102j.mail.yandex.net (forward102j.mail.yandex.net [5.45.198.243]) by lists.linaro.org (Postfix) with ESMTPS id 33933609B5 for ; Tue, 10 Oct 2017 10:01:01 +0000 (UTC) Received: from mxback9j.mail.yandex.net (mxback9j.mail.yandex.net [IPv6:2a02:6b8:0:1619::112]) by forward102j.mail.yandex.net (Yandex) with ESMTP id D7E055602F5E for ; Tue, 10 Oct 2017 13:00:59 +0300 (MSK) Received: from smtp4o.mail.yandex.net (smtp4o.mail.yandex.net [2a02:6b8:0:1a2d::28]) by mxback9j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id S0KVGoQLqo-0xHOicxT; Tue, 10 Oct 2017 13:00:59 +0300 Received: by smtp4o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id hbf1r0CSIp-0xeGPnU9; Tue, 10 Oct 2017 13:00:59 +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 13:00:13 +0300 Message-Id: <1507629614-17356-9-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1507629614-17356-1-git-send-email-odpbot@yandex.ru> References: <1507629614-17356-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 196 Subject: [lng-odp] [PATCH CLOUD-DEV v2 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: 396a3d25a5aaadda96c34eb8a6801599f7afac84 **/ .../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 10: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: 115379 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp3569085qgn; Tue, 10 Oct 2017 03:12:15 -0700 (PDT) X-Google-Smtp-Source: AOwi7QAURHO60iVtWcFmPvvUy5TWhIEHxz4+GtKe48ZrK+1vchHZIs9aN65ljMSL7UzcrBw/psPT X-Received: by 10.36.93.82 with SMTP id w79mr17050595ita.119.1507630335868; Tue, 10 Oct 2017 03:12:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507630335; cv=none; d=google.com; s=arc-20160816; b=ex45OK1gEe4IWvqvqRcspcO8EfVQcwcwr93txk2ujtnFSVYgKEuptv6LGSKuzOqCfW ht5TODvB/de2OC2GsxYnqqWn94kWD9wFznRQDKFVzGSCGp0sloZ57Zr2AaTRJ6+wy47H DQbCA1EHUpUJaJ419rtxaKse26paR81XvhVyPtMVpSKFFpqdLQOzbH8mm+WvzYmniEug KWEGpqN7UPmdM2itIKmAOWGPmySsXCngowi0JEYiH7FLZ8YrNdMzo/KCVRjciNP2ZNDl AdxGF8SJHywjj4UT1k20NluqwtcP+2aCidHrS8jK3QziFGSJENaCR6rSTfSke3W2iRIZ m8Ig== 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=2JUL0yqzkjjFcPNJC0H3E4OWnWMrTqya93k1LgbZ1eE=; b=sfuTle4xehNXMJQqI75dQhr7xsnzhe3LObTehmZYPWSjLu6FkJs1UQ6sxaMVLKUCs0 eAi0x4741qgq/rZi2bjS1CWb08trSdLpgFVgnN3lq/TMhNi3nRBgHpiIG2Wf4he11zDI mNq2vVWzKaTOxoSAxFs53CGjZq/K2qxUXmmT6YZ+Fj0JTZwWTP6ZzuBxqttJ8Hw0wF+Z 0/SXZv1qe0wzXnYB0vOnSJJ4ZSbFiyy4qK7qF7C+y4+8+TArbz786VR9MSDdrR1beL0f fStX7WrtKvMVtYzSYCr3bf/OhL5VQyuzYKeIVV6rWB0rqkbdIp87KJFt8c6UrO6PmLFU +Gqg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 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 (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id x137si9452539ite.52.2017.10.10.03.12.15; Tue, 10 Oct 2017 03:12:15 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 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 6847B60D3E; Tue, 10 Oct 2017 10:12: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=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,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 D124C60D48; Tue, 10 Oct 2017 10:02:10 +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 B066260C42; Tue, 10 Oct 2017 10:01:12 +0000 (UTC) Received: from forward102j.mail.yandex.net (forward102j.mail.yandex.net [5.45.198.243]) by lists.linaro.org (Postfix) with ESMTPS id C0BE160BFB for ; Tue, 10 Oct 2017 10:01:01 +0000 (UTC) Received: from mxback8j.mail.yandex.net (mxback8j.mail.yandex.net [IPv6:2a02:6b8:0:1619::111]) by forward102j.mail.yandex.net (Yandex) with ESMTP id BFE445602FB5 for ; Tue, 10 Oct 2017 13:01:00 +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 0BZWSy755k-10be5OS3; Tue, 10 Oct 2017 13:01:00 +0300 Received: by smtp4o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id hbf1r0CSIp-0xemdYVA; Tue, 10 Oct 2017 13:00:59 +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 13:00:14 +0300 Message-Id: <1507629614-17356-10-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1507629614-17356-1-git-send-email-odpbot@yandex.ru> References: <1507629614-17356-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 196 Subject: [lng-odp] [PATCH CLOUD-DEV v2 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: 396a3d25a5aaadda96c34eb8a6801599f7afac84 **/ .../linux-dpdk/include/odp_packet_io_internal.h | 7 +- platform/linux-dpdk/pktio/dpdk.c | 55 +++++------- .../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, 80 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..30ccc456e 100644 --- a/platform/linux-dpdk/pktio/dpdk.c +++ b/platform/linux-dpdk/pktio/dpdk.c @@ -39,18 +39,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 +96,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 +126,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 +143,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 +153,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 +188,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 +200,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 +309,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 +359,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 +476,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 +529,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 +590,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 +634,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 +646,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 +690,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 +709,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; }