From patchwork Thu Sep 14 03: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: 112496 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp265652qgf; Wed, 13 Sep 2017 20:03:04 -0700 (PDT) X-Google-Smtp-Source: AOwi7QBsLw0IbQWf/3OgYu7XsoX7lP7cTyzJ4GpSmgdpyE//Y7Yl5UJW/OeN43Rr9/Do+MJEolDp X-Received: by 10.200.43.79 with SMTP id 15mr29152902qtv.126.1505358184070; Wed, 13 Sep 2017 20:03:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505358184; cv=none; d=google.com; s=arc-20160816; b=NkWRDJvJuHdPbqvfeFGRZW1CyAjxXkQERxShDp9Vs/Lv1ugSw2tLPgY3pK7xTZIa2p ck8/xvy4LVQZQSStHDjtdQP9Y921knFuj8VmVl29kCqO3VdurxrULEP7oewl0N0bYDPy +BmFRCBxyHmBYE97K5PvyWhoFZM7Jg35AbSCX8cW/gOrZEojHJTzM+sWRHWPWzOHKMVQ dd5VsENNoXY6e9lsXOSqHG44pp5fyTJR/kBY81E+yLM6Uf7x9gKgauyG9Llsr5catPlD tLfGpEtOcqZhNIDHV/L3CW/ynECahlAwafak5ITNuqUPaw1vwBlGoeAmgElM3nhqkbhH z+pA== 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=GvfQqNPmUtzREL4PxGYqJ7nRARZDtiUdZSJapk55iB0=; b=b+kaAYr+zetrBHLkc7i2phiv/wIu6/vg9dIx7/Ft1iYEjeb+DgP7k+TrPoHH3Jlhhw fn1rwK5hPrTyaomuQoh5b3vFInOmyY38YF6FJHorfec/j9YEqkhFRfUPyakQuemAncCi AaZ4sJqLLnQJu3gZRb9OqC3WAsLLtcU6RfkfNEcp/DQIAJj/YllJw0tHy6MW5FwO5GK1 KT3zMPCJ2dCHIChKUCnRiWzPNlYuemZBWzT4JlbGX2sG3B/hVQoNWtOf7OsTsjw6xnJU VRo0BkyCFdSf6zr9y8f4kKfYUa3tZ7sIc/VdU3cNLPc8vR1QsC9u8XsVWkxEKRv2NJIv eRiA== 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 q64si878919qkb.271.2017.09.13.20.03.03; Wed, 13 Sep 2017 20:03:04 -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 B5A8864455; Thu, 14 Sep 2017 03:03:03 +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 E206F60D3D; Thu, 14 Sep 2017 03:00:50 +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 65B2960C1E; Thu, 14 Sep 2017 03:00:36 +0000 (UTC) Received: from forward102p.mail.yandex.net (forward102p.mail.yandex.net [77.88.28.102]) by lists.linaro.org (Postfix) with ESMTPS id F192D609B2 for ; Thu, 14 Sep 2017 03:00:29 +0000 (UTC) Received: from mxback4o.mail.yandex.net (mxback4o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::1e]) by forward102p.mail.yandex.net (Yandex) with ESMTP id 74C964305C4F for ; Thu, 14 Sep 2017 06:00:28 +0300 (MSK) Received: from smtp4o.mail.yandex.net (smtp4o.mail.yandex.net [2a02:6b8:0:1a2d::28]) by mxback4o.mail.yandex.net (nwsmtp/Yandex) with ESMTP id sLOKhntzTD-0SVKfK34; Thu, 14 Sep 2017 06:00:28 +0300 Received: by smtp4o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id zmNnunofyZ-0ROeENVf; Thu, 14 Sep 2017 06:00:27 +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, 14 Sep 2017 06:00:08 +0300 Message-Id: <1505358015-27878-5-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1505358015-27878-1-git-send-email-odpbot@yandex.ru> References: <1505358015-27878-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 139 Subject: [lng-odp] [PATCH CLOUD-DEV v3 4/11] linux-gen: pktio: loopback: minor code refactory 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: Yi He Rename the source as loopback.c, move implementation specific data structure into dedicated header file. Signed-off-by: Yi He Signed-off-by: Balakrishna Garapati Reviewed-by: Brian Brooks Reviewed-by: Honnappa Nagarahalli Reviewed-by: Bill Fischofer --- /** Email created from pull request 139 (heyi-linaro:modular-pktio-ops) ** https://github.com/Linaro/odp/pull/139 ** Patch: https://github.com/Linaro/odp/pull/139.patch ** Base sha: a1f50ad720e11a54b13c4786cad4687cb5c4ec2a ** Merge commit sha: a25c44f448c9f01c48cfb51f6350d317baab8700 **/ platform/linux-dpdk/Makefile.am | 3 ++- platform/linux-dpdk/include/odp_packet_io_internal.h | 7 +------ platform/linux-generic/Makefile.am | 3 ++- platform/linux-generic/include/odp_packet_io_internal.h | 7 +------ platform/linux-generic/include/odp_pktio_ops_loopback.h | 17 +++++++++++++++++ .../linux-generic/include/odp_pktio_ops_subsystem.h | 13 +++++++++++++ platform/linux-generic/pktio/{loop.c => loopback.c} | 14 +++++++------- 7 files changed, 43 insertions(+), 21 deletions(-) create mode 100644 platform/linux-generic/include/odp_pktio_ops_loopback.h rename platform/linux-generic/pktio/{loop.c => loopback.c} (94%) diff --git a/platform/linux-dpdk/Makefile.am b/platform/linux-dpdk/Makefile.am index 83931d27..4d5dff5d 100644 --- a/platform/linux-dpdk/Makefile.am +++ b/platform/linux-dpdk/Makefile.am @@ -190,6 +190,7 @@ noinst_HEADERS = \ ${srcdir}/include/odp_packet_dpdk.h \ ${srcdir}/include/odp_packet_internal.h \ ${top_srcdir}/platform/linux-generic/include/odp_pktio_ops_subsystem.h \ + ${top_srcdir}/platform/linux-generic/include/odp_pktio_ops_loopback.h \ ${top_srcdir}/platform/linux-generic/include/odp_name_table_internal.h \ ${srcdir}/include/odp_packet_io_internal.h \ ${srcdir}/include/odp_errno_define.h \ @@ -246,7 +247,7 @@ __LIB__libodp_dpdk_la_SOURCES = \ pktio/subsystem.c \ odp_packet_flags.c \ ../linux-generic/odp_packet_io.c \ - ../linux-generic/pktio/loop.c \ + ../linux-generic/pktio/loopback.c \ ../linux-generic/odp_pkt_queue.c \ pool/dpdk.c \ ../linux-generic/odp_queue.c \ diff --git a/platform/linux-dpdk/include/odp_packet_io_internal.h b/platform/linux-dpdk/include/odp_packet_io_internal.h index fde172fc..ba388c9c 100644 --- a/platform/linux-dpdk/include/odp_packet_io_internal.h +++ b/platform/linux-dpdk/include/odp_packet_io_internal.h @@ -43,11 +43,6 @@ typedef union pktio_entry_u pktio_entry_t; /* Forward declaration */ struct pkt_dpdk_t; -typedef struct { - odp_queue_t loopq; /**< loopback queue for "loop" device */ - odp_bool_t promisc; /**< promiscuous mode state */ -} pkt_loop_t; - /** Packet socket using dpdk mmaped rings for both Rx and Tx */ typedef struct { odp_pktio_capability_t capa; /**< interface capabilities */ @@ -67,13 +62,13 @@ typedef struct { struct pktio_entry { const pktio_ops_module_t *ops; /**< Implementation specific methods */ + pktio_ops_data_t ops_data; /* These two locks together lock the whole pktio device */ odp_ticketlock_t rxl; /**< RX ticketlock */ odp_ticketlock_t txl; /**< TX ticketlock */ int cls_enabled; /**< is classifier enabled */ odp_pktio_t handle; /**< pktio handle */ union { - pkt_loop_t pkt_loop; /**< Using loopback for IO */ pkt_dpdk_t pkt_dpdk; /**< using DPDK API for IO */ }; enum { diff --git a/platform/linux-generic/Makefile.am b/platform/linux-generic/Makefile.am index ff08a6ef..1aaea84f 100644 --- a/platform/linux-generic/Makefile.am +++ b/platform/linux-generic/Makefile.am @@ -191,6 +191,7 @@ noinst_HEADERS = \ ${srcdir}/include/odp_packet_dpdk.h \ ${srcdir}/include/odp_packet_socket.h \ ${srcdir}/include/odp_packet_tap.h \ + ${srcdir}/include/odp_pktio_ops_loopback.h \ ${srcdir}/include/odp_pktio_ops_subsystem.h \ ${srcdir}/include/odp_pkt_queue_internal.h \ ${srcdir}/include/odp_pool_internal.h \ @@ -266,7 +267,7 @@ __LIB__libodp_linux_la_SOURCES = \ pktio/subsystem.c \ pktio/ipc.c \ pktio/pktio_common.c \ - pktio/loop.c \ + pktio/loopback.c \ pktio/netmap.c \ pktio/dpdk.c \ pktio/socket.c \ diff --git a/platform/linux-generic/include/odp_packet_io_internal.h b/platform/linux-generic/include/odp_packet_io_internal.h index 58914840..893fa114 100644 --- a/platform/linux-generic/include/odp_packet_io_internal.h +++ b/platform/linux-generic/include/odp_packet_io_internal.h @@ -51,11 +51,6 @@ typedef union pktio_entry_u pktio_entry_t; * requested number of packets were not handled. */ #define SOCK_ERR_REPORT(e) (e != EAGAIN && e != EWOULDBLOCK && e != EINTR) -typedef struct { - odp_queue_t loopq; /**< loopback queue for "loop" device */ - odp_bool_t promisc; /**< promiscuous mode state */ -} pkt_loop_t; - #ifdef HAVE_PCAP typedef struct { char *fname_rx; /**< name of pcap file for rx */ @@ -111,13 +106,13 @@ typedef struct { struct pktio_entry { const pktio_ops_module_t *ops; /**< Implementation specific methods */ + pktio_ops_data_t ops_data; /**< 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 */ int cls_enabled; /**< is classifier enabled */ odp_pktio_t handle; /**< pktio handle */ union { - pkt_loop_t pkt_loop; /**< Using loopback for IO */ pkt_sock_t pkt_sock; /**< using socket API for IO */ pkt_sock_mmap_t pkt_sock_mmap; /**< using socket mmap * API for IO */ diff --git a/platform/linux-generic/include/odp_pktio_ops_loopback.h b/platform/linux-generic/include/odp_pktio_ops_loopback.h new file mode 100644 index 00000000..93245947 --- /dev/null +++ b/platform/linux-generic/include/odp_pktio_ops_loopback.h @@ -0,0 +1,17 @@ +/* Copyright (c) 2017, ARM Limited. All rights reserved. + * + * Copyright (c) 2017, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef ODP_PKTIO_OPS_LOOPBACK_H_ +#define ODP_PKTIO_OPS_LOOPBACK_H_ + +typedef struct { + odp_queue_t loopq; /**< loopback queue for "loop" device */ + odp_bool_t promisc; /**< promiscuous mode state */ +} pktio_ops_loopback_data_t; + +#endif diff --git a/platform/linux-generic/include/odp_pktio_ops_subsystem.h b/platform/linux-generic/include/odp_pktio_ops_subsystem.h index ff497a2a..7b90ed3d 100644 --- a/platform/linux-generic/include/odp_pktio_ops_subsystem.h +++ b/platform/linux-generic/include/odp_pktio_ops_subsystem.h @@ -78,4 +78,17 @@ 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 { + pktio_ops_loopback_data_t loopback; +} pktio_ops_data_t; + +/* Extract pktio ops data from pktio entry structure */ +#define ops_data(mod) s.ops_data.mod + #endif diff --git a/platform/linux-generic/pktio/loop.c b/platform/linux-generic/pktio/loopback.c similarity index 94% rename from platform/linux-generic/pktio/loop.c rename to platform/linux-generic/pktio/loopback.c index 39718a89..0c572338 100644 --- a/platform/linux-generic/pktio/loop.c +++ b/platform/linux-generic/pktio/loopback.c @@ -35,10 +35,10 @@ 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->s.pkt_loop.loopq = + pktio_entry->ops_data(loopback).loopq = odp_queue_create(loopq_name, NULL); - if (pktio_entry->s.pkt_loop.loopq == ODP_QUEUE_INVALID) + if (pktio_entry->ops_data(loopback).loopq == ODP_QUEUE_INVALID) return -1; loopback_stats_reset(pktio_entry); @@ -48,7 +48,7 @@ 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->s.pkt_loop.loopq); + return odp_queue_destroy(pktio_entry->ops_data(loopback).loopq); } static int loopback_recv(pktio_entry_t *pktio_entry, int index ODP_UNUSED, @@ -70,7 +70,7 @@ static int loopback_recv(pktio_entry_t *pktio_entry, int index ODP_UNUSED, odp_ticketlock_lock(&pktio_entry->s.rxl); - queue = queue_fn->from_ext(pktio_entry->s.pkt_loop.loopq); + queue = queue_fn->from_ext(pktio_entry->ops_data(loopback).loopq); nbr = queue_fn->deq_multi(queue, hdr_tbl, len); if (pktio_entry->s.config.pktin.bit.ts_all || @@ -170,7 +170,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->s.pkt_loop.loopq); + queue = queue_fn->from_ext(pktio_entry->ops_data(loopback).loopq); ret = queue_fn->enq_multi(queue, hdr_tbl, len); if (ret > 0) { @@ -223,13 +223,13 @@ 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->s.pkt_loop.promisc = enable; + pktio_entry->ops_data(loopback).promisc = enable; return 0; } static int loopback_promisc_mode_get(pktio_entry_t *pktio_entry) { - return pktio_entry->s.pkt_loop.promisc ? 1 : 0; + return pktio_entry->ops_data(loopback).promisc ? 1 : 0; } static int loopback_stats(pktio_entry_t *pktio_entry,