From patchwork Thu Oct 19 12:00:01 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: 116384 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp411803qgn; Thu, 19 Oct 2017 05:04:55 -0700 (PDT) X-Google-Smtp-Source: ABhQp+TpEmyxfC2W+xGcViE2KNxuEprXBrDeIh3gOFl00ciiKcjcpVcgVnEMQUU+0qKJ4QLNNwc9 X-Received: by 10.36.73.14 with SMTP id z14mr2018838ita.60.1508414695386; Thu, 19 Oct 2017 05:04:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508414695; cv=none; d=google.com; s=arc-20160816; b=CUVEMYdbY7jQntXWJgARsqXeaWJ5H4+Ia/Ka1CxrE3bjWfEL2XSdxABIv3uQ1t0eoF 9FCQZfdQdFxYk2JslNd/THQfABNicARCNZLd4/kdkbOvjvV3b6UMm9r19TZsbpKdGRYz 5w52X0yqDKp8qf0mlS/ZOIx/zhMIOk507MrTb+Ylc/PyTKXKuX2esDwpYBsQNLw27Bzm 8CKzEDI/IoqMqmHYeB4z5DlELTGFNMAwM1uKtG3SiqFpHCixfawDoc3o0+Z9g93pkbOy r/mNxT5YE58v3frksRt9D3v8IFzWywP9TzXyIFCetPnL09tcBjMRR17809JqCov/xSEE 9j1g== 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=ItPuy41aZ2/TVWdNRbgkumcZpEsLd/FLZArL8J/g96w=; b=J7ppyO7PyagvqIQn2DfJ9sL4Sjlh8wOT5KrhzZ9W8JDtMNhjt1A0h0sb/fxvEmFJHj +eVjnmDz84tCL9zZ7Et923WvNrUx66wMU4vQ8RYsKEQWTgxQ9bz6URhta7fzxVri99U+ JHgvyijVJbFK5Aa/vEYPtS0mg+DOg7dLcPH38v5KCvNnd9gCPun5VHv74MatqvLaVz6h X3YHoAWPD9cNv+FOCFeR8Z1DGxWWVpO0ucFwvupsdGLIx9cTLAUIZmtEg1/7e1S0nkDv Pme8q3y6epevdCHAs2vCbB67r4HPdJY6jmkNJBSc5pCUTxNqgBoHDW02ZV38ef5aGHYY IGLw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (ec2-54-197-127-237.compute-1.amazonaws.com. [54.197.127.237]) by mx.google.com with ESMTP id z126si1213866itg.60.2017.10.19.05.04.55; Thu, 19 Oct 2017 05:04:55 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) client-ip=54.197.127.237; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id E13F260C1D; Thu, 19 Oct 2017 12:04:54 +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 A297262A9E; Thu, 19 Oct 2017 12:02:41 +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 1054B62B34; Thu, 19 Oct 2017 12:02:27 +0000 (UTC) Received: from forward100o.mail.yandex.net (forward100o.mail.yandex.net [37.140.190.180]) by lists.linaro.org (Postfix) with ESMTPS id 187CF61D4C for ; Thu, 19 Oct 2017 12:00:17 +0000 (UTC) Received: from mxback17j.mail.yandex.net (mxback17j.mail.yandex.net [IPv6:2a02:6b8:0:1619::93]) by forward100o.mail.yandex.net (Yandex) with ESMTP id E8E532A22193 for ; Thu, 19 Oct 2017 15:00:14 +0300 (MSK) Received: from smtp2o.mail.yandex.net (smtp2o.mail.yandex.net [2a02:6b8:0:1a2d::26]) by mxback17j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id yH6ge1nmZM-0EZWVHgY; Thu, 19 Oct 2017 15:00:14 +0300 Received: by smtp2o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id lZE2bfHgVf-0DIWN7Pd; Thu, 19 Oct 2017 15:00:13 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Github ODP bot To: lng-odp@lists.linaro.org Date: Thu, 19 Oct 2017 15:00:01 +0300 Message-Id: <1508414408-10456-3-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1508414408-10456-1-git-send-email-odpbot@yandex.ru> References: <1508414408-10456-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 241 Subject: [lng-odp] [PATCH v1 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 241 (bogdanPricope:2_0_pktio_ops_pr) ** https://github.com/Linaro/odp/pull/241 ** Patch: https://github.com/Linaro/odp/pull/241.patch ** Base sha: 76f82972ecb51aa64215c97cb3d7f94e5de980f9 ** Merge commit sha: 24c411a2875cbcd686833666d481a0197cc82e90 **/ .../include/odp_pktio_ops_subsystem.h | 2 -- platform/linux-generic/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 07c5dbee7..241ce4673 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) { /* All implementations of this subsystem */ #include -#include #include #include #include @@ -94,7 +93,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 b17868a39..01bbc8bc6 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,