From patchwork Wed Aug 23 05:59:58 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: 110712 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp3670237qge; Tue, 22 Aug 2017 23:00:45 -0700 (PDT) X-Received: by 10.200.35.124 with SMTP id b57mr2167575qtb.253.1503468045318; Tue, 22 Aug 2017 23:00:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503468045; cv=none; d=google.com; s=arc-20160816; b=qJaxLWjaeBWa6r1FgrZC5+JJyzqadsPMQ9P+C7ttfpm0ShUADjr0AAvWD1p98nx9H8 5Z+p0dFjdID83TaIErzGqbfKdnTp8PSjvwrNxTt0K8aBTfzt7yJr+emFEeScmtqd74ra idLRULQ90ZNKFr7h2OSYvxrnNcxdXVk1CPbzrWfNRgZo1CBcw6cdIICAxQdAyRbn+S3h UlWkM9SkmB1BlwzkGsM1tq/UpuhuF08ubWzhpgJuMhIwEJonkynDVKobHPTiX1cpfzNx 0xSqYA1lSYdOMPJL8yKyIxYGQRtYcx7jq45ceAVtaYXvYRx4FhahTgcaPZVkezeFTwsl W7FA== 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=1DbcmQa7dm5zVebuypMc+NEGRlwxqK5v8gpACIKRxb8=; b=fsMEu58W5WaBeSXciNc/w47DLwLgldM48k+LhnHbxDA4099hW74CvEFGjBNBRVznkM wfrPO/TFSZlC3xyJYONsKbLiMZR8pWHGVWhd7XXjv3pbQZDcm+np1AYhvrgT2BRoKu/Z gxfRx6igSpeTn8QN3BZIb5IljEOB+SZs01Sh19aPecZpdKpZRE6d5mD5iXdQngGknHdq PgHIE1DM4qtsO94QJpThp0PVznzfkt8BvByy6Tzp8eML3GINE1sqmWIJ8zaH8xaNDeEy DKL9DHm/diFHCDCqenpEl4/BqFP/Sq+r48GYQFPW9zS9qugmaud0EXjA3HfgW/TmkUs4 B2rw== 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 c32si778094qtd.218.2017.08.22.23.00.44; Tue, 22 Aug 2017 23:00:45 -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 5194E644C3; Wed, 23 Aug 2017 06:00:44 +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, 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 DEFA26449C; Wed, 23 Aug 2017 06:00:26 +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 4DD3264494; Wed, 23 Aug 2017 06:00:23 +0000 (UTC) Received: from forward106o.mail.yandex.net (forward106o.mail.yandex.net [37.140.190.187]) by lists.linaro.org (Postfix) with ESMTPS id 6B07F6446B for ; Wed, 23 Aug 2017 06:00:19 +0000 (UTC) Received: from mxback4o.mail.yandex.net (mxback4o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::1e]) by forward106o.mail.yandex.net (Yandex) with ESMTP id 99906782C54 for ; Wed, 23 Aug 2017 09:00:17 +0300 (MSK) Received: from smtp3o.mail.yandex.net (smtp3o.mail.yandex.net [2a02:6b8:0:1a2d::27]) by mxback4o.mail.yandex.net (nwsmtp/Yandex) with ESMTP id lVIXQLqwox-0HAWZkrE; Wed, 23 Aug 2017 09:00:17 +0300 Received: by smtp3o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id QeRkbDFm9Y-0HLmZQ1S; Wed, 23 Aug 2017 09:00:17 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Github ODP bot To: lng-odp@lists.linaro.org Date: Wed, 23 Aug 2017 08:59:58 +0300 Message-Id: <1503468007-12911-2-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1503468007-12911-1-git-send-email-odpbot@yandex.ru> References: <1503468007-12911-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 139 Subject: [lng-odp] [PATCH CLOUD-DEV v1 1/10] framework: modular: extern SUBSYSTEM_FOREACH_TEMPLATE 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 Static SUBSYSTEM_FOREACH_TEMPLATE constraints the functions to be instantiated in the source files which invoke them, this causes code scatter shoots. Signed-off-by: Yi He --- /** 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: 3cdc8a07993b93b145dc3b4a373b5ebc33bae882 ** Merge commit sha: a87822f157888ef3269a7b8b3f38c63ecc111669 **/ frameworks/modular/odp_module.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frameworks/modular/odp_module.h b/frameworks/modular/odp_module.h index 1a9e178c..59f67c8d 100644 --- a/frameworks/modular/odp_module.h +++ b/frameworks/modular/odp_module.h @@ -206,7 +206,7 @@ struct odp_module_base { * subsystem and invoke init_global method for each. */ #define ODP_SUBSYSTEM_FOREACH_TEMPLATE(subs, method, print) \ -static int odp_ ## subs ##_## method(bool continue_on_errors) \ +int odp_ ## subs ##_## method(bool continue_on_errors) \ { \ int result = 0; \ ODP_MODULE_CLASS(subs) * mod = NULL; \ From patchwork Wed Aug 23 05:59:59 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: 110713 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp3671669qge; Tue, 22 Aug 2017 23:02:02 -0700 (PDT) X-Received: by 10.55.175.67 with SMTP id y64mr2058479qke.130.1503468122676; Tue, 22 Aug 2017 23:02:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503468122; cv=none; d=google.com; s=arc-20160816; b=vISAtv67FxN2MB7qyVsuAQeWyLu1EBhCVtpuXHDvxUo5dOlmoB5W3sXpYhxduPJjuR GGxeLzyfx0Tr3Jd3JimXHmfvcLTmcVzlIm2WCqK9cVpJzBWW0yiHG8iXVcDrjDcHS4SP Mi1ml1yw4ZUTRmi2dL743Gb2r8qqjtYlxCoq8QUSLZZZMCSHOsLOxtCtMV2I5zqinCCy BozydH/piDsOUJTwo5U4Lp3zmc24bAPdaVH293QhUfgFEejwQp7+px/IJs3f9z8YSwGm wVQLZtZDi5zJBGeGDKWg0J3J4CDMVTATsv2WKYmMc3uLRFZeAG0mGKqsj3hiMk8n55di kJtw== 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=4qyVz7p394aBbT5MdXh082B9uVq5HwkrLYbpzBoLhmI=; b=GcIMbxhjy3h3BQ9/vI+gC4kphhnJQLxwqIuymCIqhsJP0D/sq8PPCZx/HwJ8s2j2fj 3aq7M0otc4ZQHj1K8LHQ8DmpE016WWxDLHJ+6QOfoGnzi0lNwlECQ+CDjvGXX0yitVkt tZcpJbcj3fSzXor9TClT0uK6KSQ43VWSRhQLSBzhvCdL2p9nGBAZmOkj5opOrszYX0aE jCnMm8FAP3msHSAPKQkUwv7erLXcrQvpnU3KDOvjRqwf50nZP3124P0WUr5MqYYQlSaN abedHjblQs4pj0Jl4TdVkolD6/koDfCoFR5/q8L0iCjhnByWOoDC1Ji2raB8UzOX6s6I gAig== 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 b45si763831qte.223.2017.08.22.23.02.02; Tue, 22 Aug 2017 23:02:02 -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 44E306448C; Wed, 23 Aug 2017 06:02:02 +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 97B57644AF; Wed, 23 Aug 2017 06:00:33 +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 D1A2B644A0; Wed, 23 Aug 2017 06:00:25 +0000 (UTC) Received: from forward102j.mail.yandex.net (forward102j.mail.yandex.net [5.45.198.243]) by lists.linaro.org (Postfix) with ESMTPS id B09666447C for ; Wed, 23 Aug 2017 06:00:19 +0000 (UTC) Received: from mxback15g.mail.yandex.net (mxback15g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:94]) by forward102j.mail.yandex.net (Yandex) with ESMTP id 2522D5603A5C for ; Wed, 23 Aug 2017 09:00:18 +0300 (MSK) Received: from smtp3o.mail.yandex.net (smtp3o.mail.yandex.net [2a02:6b8:0:1a2d::27]) by mxback15g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id xlslMER7Ge-0IaCe6hP; Wed, 23 Aug 2017 09:00:18 +0300 Received: by smtp3o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id QeRkbDFm9Y-0HLOdTY8; Wed, 23 Aug 2017 09:00:17 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Github ODP bot To: lng-odp@lists.linaro.org Date: Wed, 23 Aug 2017 08:59:59 +0300 Message-Id: <1503468007-12911-3-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1503468007-12911-1-git-send-email-odpbot@yandex.ru> References: <1503468007-12911-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 139 Subject: [lng-odp] [PATCH CLOUD-DEV v1 2/10] example: l2fwd_simple: disable 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: Yi He l2fwd_simple_run.sh waits 1 second to allow test application to forward more than 10 packets. It works in case pktios are listed statically and pcap takes precedence over socket pktios. But with dynamically registered pktios the order was not guaranteed and socket pktios may take precedence over pcap pktio, which spent more time in open operation and caused this test failed. Disable the socket pktios since they mistakenly take too long time in open operation, future code refactory should solve the problem thoroughly. Signed-off-by: Yi He --- /** 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: 3cdc8a07993b93b145dc3b4a373b5ebc33bae882 ** Merge commit sha: a87822f157888ef3269a7b8b3f38c63ecc111669 **/ example/l2fwd_simple/l2fwd_simple_run.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/example/l2fwd_simple/l2fwd_simple_run.sh b/example/l2fwd_simple/l2fwd_simple_run.sh index 130a3a84..0c464f70 100755 --- a/example/l2fwd_simple/l2fwd_simple_run.sh +++ b/example/l2fwd_simple/l2fwd_simple_run.sh @@ -6,6 +6,11 @@ # SPDX-License-Identifier: BSD-3-Clause # +# Disable socket pktios since their open operations +# mistakenly take too long time +export ODP_PKTIO_DISABLE_SOCKET_MMSG=1 +export ODP_PKTIO_DISABLE_SOCKET_MMAP=1 + PCAP_IN=`find . ${TEST_DIR} $(dirname $0) -name udp64.pcap -print -quit` echo "using PCAP_IN = ${PCAP_IN}" From patchwork Wed Aug 23 06:00:00 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: 110715 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp3674290qge; Tue, 22 Aug 2017 23:04:36 -0700 (PDT) X-Received: by 10.237.48.4 with SMTP id 4mr2059580qte.176.1503468276011; Tue, 22 Aug 2017 23:04:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503468276; cv=none; d=google.com; s=arc-20160816; b=yfvGq8M25nO1u5c8SaTWHCKGr3YcHgpYn/QloDFjuna6IaeNGsbeFhhH664B8/DX4v 9l3BqnSvIa6vpNFJ67/iujsBLQ2gDYbLYv1FVeeoF2e/SCsGBLYtJj3TW9g/evyMYR9D Ecjz+kSzoR4zF5wPky6u4gr/01aZK5+auswxTt6MbwhwvPqDkrgkwgQ0+lbxZkbZvnfO UdHwqackoq6QmlKvdWRe8Lu8LWTtLXyZpGjwjwirTOdHGW54IJCA6oLaF6HCwHoZjbcR 8oD7XODRAk7jUZ5nzqkAp7TGFObadK1mZvKZRj1pEKXai5b9JDoAZAtv6rxMGqhR66zK uUlg== 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=l2x/AZ7DXXK1vbS05zUT8RSpTXfsKnj6N4jz4C7iH0M=; b=Dfvu01hzCY56FS1vbYuEISXUDhtbwm3dVqRSOgyH8xHN54a9RdY2G62+6NYILsp4Zj Tsakf6wrEOXX3YVE95jnmRQuZ054e4RR2ajbTtZK22UrPDvZXxei3f+n1jIxLBb+PaH4 HjTMrWyfNVQJ+NauxKHPWS8aP7bm+eQTAM/Z5ksN0soivXfkIR1epVOOV9O5hyONjd2K 1JtYdj1K++ICqIKcOknU1RrEyGt49F7EeOU9twj7pye75IfM2SB+IRZBY1tPzYfor2AC K2YnJuavZ8Vk57Udw6WKqOHEJX4j/sg6nSbaIhW+4BHGfps5D6DQ2NqhnaW1q6TzAHBK hV4w== 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 24si733653qtp.137.2017.08.22.23.04.35; Tue, 22 Aug 2017 23:04: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 9247B644B3; Wed, 23 Aug 2017 06:04: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=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, 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 B610F644C5; Wed, 23 Aug 2017 06:00:46 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 20C2D644B7; Wed, 23 Aug 2017 06:00:34 +0000 (UTC) Received: from forward104j.mail.yandex.net (forward104j.mail.yandex.net [5.45.198.247]) by lists.linaro.org (Postfix) with ESMTPS id ED1476447F for ; Wed, 23 Aug 2017 06:00:20 +0000 (UTC) Received: from mxback3o.mail.yandex.net (mxback3o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::1d]) by forward104j.mail.yandex.net (Yandex) with ESMTP id 92B14435D8 for ; Wed, 23 Aug 2017 09:00:19 +0300 (MSK) Received: from smtp3o.mail.yandex.net (smtp3o.mail.yandex.net [2a02:6b8:0:1a2d::27]) by mxback3o.mail.yandex.net (nwsmtp/Yandex) with ESMTP id oFQBZYsePC-0J7epHl2; Wed, 23 Aug 2017 09:00:19 +0300 Received: by smtp3o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id QeRkbDFm9Y-0ILmZik1; Wed, 23 Aug 2017 09:00:18 +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: Wed, 23 Aug 2017 09:00:00 +0300 Message-Id: <1503468007-12911-4-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1503468007-12911-1-git-send-email-odpbot@yandex.ru> References: <1503468007-12911-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 139 Subject: [lng-odp] [PATCH CLOUD-DEV v1 3/10] linux-gen: pktio: apply modular framework 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 Apply modular framework to the pktio ops registration, convert the static array for impls registration into a dynamic and extensible modularization manner. Signed-off-by: Yi He --- /** 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: 3cdc8a07993b93b145dc3b4a373b5ebc33bae882 ** Merge commit sha: a87822f157888ef3269a7b8b3f38c63ecc111669 **/ platform/linux-generic/Makefile.am | 3 +- .../linux-generic/include/odp_packet_io_internal.h | 59 ++-------------- .../include/odp_pktio_ops_subsystem.h | 81 ++++++++++++++++++++++ platform/linux-generic/odp_packet_io.c | 57 ++++----------- platform/linux-generic/pktio/dpdk.c | 34 ++++++--- platform/linux-generic/pktio/io_ops.c | 31 --------- platform/linux-generic/pktio/ipc.c | 43 +++++++++--- platform/linux-generic/pktio/loop.c | 31 ++++++--- platform/linux-generic/pktio/netmap.c | 37 +++++++--- platform/linux-generic/pktio/pcap.c | 33 +++++++-- platform/linux-generic/pktio/socket.c | 31 ++++++--- platform/linux-generic/pktio/socket_mmap.c | 31 ++++++--- platform/linux-generic/pktio/subsystem.c | 58 ++++++++++++++++ platform/linux-generic/pktio/tap.c | 38 +++++++--- 14 files changed, 369 insertions(+), 198 deletions(-) create mode 100644 platform/linux-generic/include/odp_pktio_ops_subsystem.h delete mode 100644 platform/linux-generic/pktio/io_ops.c create mode 100644 platform/linux-generic/pktio/subsystem.c diff --git a/platform/linux-generic/Makefile.am b/platform/linux-generic/Makefile.am index 36d9290c..3ca43871 100644 --- a/platform/linux-generic/Makefile.am +++ b/platform/linux-generic/Makefile.am @@ -190,6 +190,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_subsystem.h \ ${srcdir}/include/odp_pkt_queue_internal.h \ ${srcdir}/include/odp_pool_internal.h \ ${srcdir}/include/odp_pool_subsystem.h \ @@ -259,7 +260,7 @@ __LIB__libodp_linux_la_SOURCES = \ odp_packet_flags.c \ odp_packet_io.c \ pktio/ethtool.c \ - pktio/io_ops.c \ + pktio/subsystem.c \ pktio/ipc.c \ pktio/pktio_common.c \ pktio/loop.c \ diff --git a/platform/linux-generic/include/odp_packet_io_internal.h b/platform/linux-generic/include/odp_packet_io_internal.h index 1a4e345f..4054ad4a 100644 --- a/platform/linux-generic/include/odp_packet_io_internal.h +++ b/platform/linux-generic/include/odp_packet_io_internal.h @@ -36,6 +36,10 @@ extern "C" { #include #include +/* Forward declaration */ +typedef union pktio_entry_u pktio_entry_t; +#include + #define PKTIO_NAME_LEN 256 #define PKTIN_INVALID ((odp_pktin_queue_t) {ODP_PKTIO_INVALID, 0}) @@ -47,9 +51,6 @@ extern "C" { * requested number of packets were not handled. */ #define SOCK_ERR_REPORT(e) (e != EAGAIN && e != EWOULDBLOCK && e != EINTR) -/* Forward declaration */ -struct pktio_if_ops; - typedef struct { odp_queue_t loopq; /**< loopback queue for "loop" device */ odp_bool_t promisc; /**< promiscuous mode state */ @@ -109,7 +110,7 @@ typedef struct { } _ipc_pktio_t; struct pktio_entry { - const struct pktio_if_ops *ops; /**< Implementation specific methods */ + const pktio_ops_module_t *ops; /**< Implementation specific methods */ /* These two locks together lock the whole pktio device */ odp_ticketlock_t rxl; /**< RX ticketlock */ odp_ticketlock_t txl; /**< TX ticketlock */ @@ -177,50 +178,16 @@ struct pktio_entry { } out_queue[PKTIO_MAX_QUEUES]; }; -typedef union { +union pktio_entry_u { struct pktio_entry s; uint8_t pad[ROUNDUP_CACHE_LINE(sizeof(struct pktio_entry))]; -} pktio_entry_t; +}; typedef struct { odp_spinlock_t lock; pktio_entry_t entries[ODP_CONFIG_PKTIO_ENTRIES]; } pktio_table_t; -typedef struct pktio_if_ops { - const char *name; - void (*print)(pktio_entry_t *pktio_entry); - int (*init_global)(void); - int (*init_local)(void); - int (*term)(void); - int (*open)(odp_pktio_t pktio, pktio_entry_t *pktio_entry, - const char *devname, odp_pool_t pool); - int (*close)(pktio_entry_t *pktio_entry); - int (*start)(pktio_entry_t *pktio_entry); - int (*stop)(pktio_entry_t *pktio_entry); - int (*stats)(pktio_entry_t *pktio_entry, odp_pktio_stats_t *stats); - int (*stats_reset)(pktio_entry_t *pktio_entry); - uint64_t (*pktin_ts_res)(pktio_entry_t *pktio_entry); - odp_time_t (*pktin_ts_from_ns)(pktio_entry_t *pktio_entry, uint64_t ns); - int (*recv)(pktio_entry_t *entry, int index, odp_packet_t packets[], - int num); - int (*send)(pktio_entry_t *entry, int index, - const odp_packet_t packets[], int num); - uint32_t (*mtu_get)(pktio_entry_t *pktio_entry); - int (*promisc_mode_set)(pktio_entry_t *pktio_entry, int enable); - int (*promisc_mode_get)(pktio_entry_t *pktio_entry); - int (*mac_get)(pktio_entry_t *pktio_entry, void *mac_addr); - int (*link_status)(pktio_entry_t *pktio_entry); - int (*capability)(pktio_entry_t *pktio_entry, - odp_pktio_capability_t *capa); - int (*config)(pktio_entry_t *pktio_entry, - const odp_pktio_config_t *config); - int (*input_queues_config)(pktio_entry_t *pktio_entry, - const odp_pktin_queue_param_t *param); - int (*output_queues_config)(pktio_entry_t *pktio_entry, - const odp_pktout_queue_param_t *p); -} pktio_if_ops_t; - extern void *pktio_entry_ptr[]; static inline int pktio_to_id(odp_pktio_t pktio) @@ -252,18 +219,6 @@ static inline void pktio_cls_enabled_set(pktio_entry_t *entry, int ena) entry->s.cls_enabled = ena; } -extern const pktio_if_ops_t netmap_pktio_ops; -extern const pktio_if_ops_t dpdk_pktio_ops; -extern const pktio_if_ops_t sock_mmsg_pktio_ops; -extern const pktio_if_ops_t sock_mmap_pktio_ops; -extern const pktio_if_ops_t loopback_pktio_ops; -#ifdef HAVE_PCAP -extern const pktio_if_ops_t pcap_pktio_ops; -#endif -extern const pktio_if_ops_t tap_pktio_ops; -extern const pktio_if_ops_t ipc_pktio_ops; -extern const pktio_if_ops_t * const pktio_if_ops[]; - int sysfs_stats(pktio_entry_t *pktio_entry, odp_pktio_stats_t *stats); int sock_stats_fd(pktio_entry_t *pktio_entry, diff --git a/platform/linux-generic/include/odp_pktio_ops_subsystem.h b/platform/linux-generic/include/odp_pktio_ops_subsystem.h new file mode 100644 index 00000000..ff497a2a --- /dev/null +++ b/platform/linux-generic/include/odp_pktio_ops_subsystem.h @@ -0,0 +1,81 @@ +/* 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_SUBSYSTEM_H_ +#define ODP_PKTIO_OPS_SUBSYSTEM_H_ + +#include +#include + +/* ODP packet IO operations subsystem declaration */ +ODP_SUBSYSTEM_DECLARE(pktio_ops); + +/* Subsystem APIs declarations */ +ODP_SUBSYSTEM_API(pktio_ops, int, open, odp_pktio_t, + pktio_entry_t *, const char *, odp_pool_t); +ODP_SUBSYSTEM_API(pktio_ops, int, close, pktio_entry_t *); +ODP_SUBSYSTEM_API(pktio_ops, int, start, pktio_entry_t *); +ODP_SUBSYSTEM_API(pktio_ops, int, stop, pktio_entry_t *); +ODP_SUBSYSTEM_API(pktio_ops, int, stats, pktio_entry_t *, + odp_pktio_stats_t *stats); +ODP_SUBSYSTEM_API(pktio_ops, int, stats_reset, pktio_entry_t *); +ODP_SUBSYSTEM_API(pktio_ops, uint64_t, pktin_ts_res, pktio_entry_t *); +ODP_SUBSYSTEM_API(pktio_ops, odp_time_t, pktin_ts_from_ns, + pktio_entry_t *, uint64_t ns); +ODP_SUBSYSTEM_API(pktio_ops, int, recv, pktio_entry_t *, + int index, odp_packet_t packets[], int count); +ODP_SUBSYSTEM_API(pktio_ops, int, send, pktio_entry_t *, + int index, const odp_packet_t packets[], int count); +ODP_SUBSYSTEM_API(pktio_ops, uint32_t, mtu_get, pktio_entry_t *); +ODP_SUBSYSTEM_API(pktio_ops, int, promisc_mode_set, + pktio_entry_t *, int enable); +ODP_SUBSYSTEM_API(pktio_ops, int, promisc_mode_get, pktio_entry_t *); +ODP_SUBSYSTEM_API(pktio_ops, int, mac_get, pktio_entry_t *, void *); +ODP_SUBSYSTEM_API(pktio_ops, int, link_status, pktio_entry_t *); +ODP_SUBSYSTEM_API(pktio_ops, int, capability, pktio_entry_t *, + odp_pktio_capability_t *); +ODP_SUBSYSTEM_API(pktio_ops, int, config, pktio_entry_t *, + const odp_pktio_config_t *); +ODP_SUBSYSTEM_API(pktio_ops, int, input_queues_config, + pktio_entry_t *, const odp_pktin_queue_param_t *); +ODP_SUBSYSTEM_API(pktio_ops, int, output_queues_config, + pktio_entry_t *, const odp_pktout_queue_param_t *); +ODP_SUBSYSTEM_API(pktio_ops, void, print, pktio_entry_t *); + +/* Declare subsystem init and term routines */ +ODP_SUBSYSTEM_API(pktio_ops, int, init_global, bool); +ODP_SUBSYSTEM_API(pktio_ops, int, init_local, bool); +ODP_SUBSYSTEM_API(pktio_ops, int, term_global, bool); +ODP_SUBSYSTEM_API(pktio_ops, int, term_local, bool); + +typedef ODP_MODULE_CLASS(pktio_ops) { + odp_module_base_t base; + + odp_api_proto(pktio_ops, open) open; + odp_api_proto(pktio_ops, close) close; + odp_api_proto(pktio_ops, start) start; + odp_api_proto(pktio_ops, stop) stop; + odp_api_proto(pktio_ops, stats) stats; + odp_api_proto(pktio_ops, stats_reset) stats_reset; + odp_api_proto(pktio_ops, pktin_ts_res) pktin_ts_res; + odp_api_proto(pktio_ops, pktin_ts_from_ns) pktin_ts_from_ns; + odp_api_proto(pktio_ops, recv) recv; + odp_api_proto(pktio_ops, send) send; + odp_api_proto(pktio_ops, mtu_get) mtu_get; + odp_api_proto(pktio_ops, promisc_mode_set) promisc_mode_set; + odp_api_proto(pktio_ops, promisc_mode_get) promisc_mode_get; + odp_api_proto(pktio_ops, mac_get) mac_get; + odp_api_proto(pktio_ops, link_status) link_status; + odp_api_proto(pktio_ops, capability) capability; + odp_api_proto(pktio_ops, config) config; + odp_api_proto(pktio_ops, input_queues_config) input_queues_config; + odp_api_proto(pktio_ops, output_queues_config) output_queues_config; + odp_api_proto(pktio_ops, print) print; +} pktio_ops_module_t; + +#endif diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c index 066f89dc..3e47aac9 100644 --- a/platform/linux-generic/odp_packet_io.c +++ b/platform/linux-generic/odp_packet_io.c @@ -51,7 +51,6 @@ int odp_pktio_init_global(void) pktio_entry_t *pktio_entry; int i; odp_shm_t shm; - int pktio_if; shm = odp_shm_reserve("odp_pktio_entries", sizeof(pktio_table_t), @@ -76,32 +75,12 @@ int odp_pktio_init_global(void) pktio_entry_ptr[i] = pktio_entry; } - for (pktio_if = 0; pktio_if_ops[pktio_if]; ++pktio_if) { - if (pktio_if_ops[pktio_if]->init_global) - if (pktio_if_ops[pktio_if]->init_global()) { - ODP_ERR("failed to initialized pktio type %d", - pktio_if); - return -1; - } - } - - return 0; + return odp_pktio_ops_init_global(true); } int odp_pktio_init_local(void) { - int pktio_if; - - for (pktio_if = 0; pktio_if_ops[pktio_if]; ++pktio_if) { - if (pktio_if_ops[pktio_if]->init_local) - if (pktio_if_ops[pktio_if]->init_local()) { - ODP_ERR("failed to initialized pktio type %d", - pktio_if); - return -1; - } - } - - return 0; + return odp_pktio_ops_init_local(true); } static inline int is_free(pktio_entry_t *entry) @@ -181,8 +160,7 @@ static odp_pktio_t setup_pktio_entry(const char *name, odp_pool_t pool, { odp_pktio_t hdl; pktio_entry_t *pktio_entry; - int ret = -1; - int pktio_if; + pktio_ops_module_t *mod; if (strlen(name) >= PKTIO_NAME_LEN - 1) { /* ioctl names limitation */ @@ -202,25 +180,24 @@ static odp_pktio_t setup_pktio_entry(const char *name, odp_pool_t pool, if (!pktio_entry) return ODP_PKTIO_INVALID; + pktio_entry->s.ops = NULL; /* Reset stale ops */ pktio_entry->s.pool = pool; memcpy(&pktio_entry->s.param, param, sizeof(odp_pktio_param_t)); pktio_entry->s.handle = hdl; odp_pktio_config_init(&pktio_entry->s.config); - for (pktio_if = 0; pktio_if_ops[pktio_if]; ++pktio_if) { - ret = pktio_if_ops[pktio_if]->open(hdl, pktio_entry, name, - pool); - - if (!ret) { - pktio_entry->s.ops = pktio_if_ops[pktio_if]; - ODP_DBG("%s uses %s\n", - name, pktio_if_ops[pktio_if]->name); + odp_subsystem_lock(read, pktio_ops); + odp_subsystem_foreach_module(pktio_ops, mod) { + if (0 == mod->open(hdl, pktio_entry, name, pool)) { + pktio_entry->s.ops = mod; + ODP_DBG("%s uses %s\n", name, mod->base.name); break; } } + odp_subsystem_unlock(read, pktio_ops); - if (ret != 0) { + if (pktio_entry->s.ops == NULL) { pktio_entry->s.state = PKTIO_STATE_FREE; hdl = ODP_PKTIO_INVALID; ODP_ERR("Unable to init any I/O type.\n"); @@ -913,7 +890,7 @@ int odp_pktio_info(odp_pktio_t hdl, odp_pktio_info_t *info) memset(info, 0, sizeof(odp_pktio_info_t)); info->name = entry->s.name; - info->drv_name = entry->s.ops->name; + info->drv_name = entry->s.ops->base.name; info->pool = entry->s.pool; memcpy(&info->param, &entry->s.param, sizeof(odp_pktio_param_t)); @@ -988,7 +965,7 @@ void odp_pktio_print(odp_pktio_t hdl) len += snprintf(&str[len], n - len, " name %s\n", entry->s.name); len += snprintf(&str[len], n - len, - " type %s\n", entry->s.ops->name); + " type %s\n", entry->s.ops->base.name); len += snprintf(&str[len], n - len, " state %s\n", entry->s.state == PKTIO_STATE_STARTED ? "start" : @@ -1030,7 +1007,6 @@ int odp_pktio_term_global(void) { int ret = 0; int i; - int pktio_if; for (i = 0; i < ODP_CONFIG_PKTIO_ENTRIES; ++i) { pktio_entry_t *pktio_entry; @@ -1056,12 +1032,7 @@ int odp_pktio_term_global(void) unlock_entry(pktio_entry); } - for (pktio_if = 0; pktio_if_ops[pktio_if]; ++pktio_if) { - if (pktio_if_ops[pktio_if]->term) - if (pktio_if_ops[pktio_if]->term()) - ODP_ABORT("failed to terminate pktio type %d", - pktio_if); - } + ret = odp_pktio_ops_term_global(false); ret = odp_shm_free(odp_shm_lookup("odp_pktio_entries")); if (ret != 0) diff --git a/platform/linux-generic/pktio/dpdk.c b/platform/linux-generic/pktio/dpdk.c index 9e3e583d..e72a7637 100644 --- a/platform/linux-generic/pktio/dpdk.c +++ b/platform/linux-generic/pktio/dpdk.c @@ -1290,30 +1290,46 @@ static int dpdk_stats_reset(pktio_entry_t *pktio_entry) return 0; } -const pktio_if_ops_t dpdk_pktio_ops = { - .name = "dpdk", - .init_global = dpdk_pktio_init_global, - .init_local = dpdk_pktio_init_local, - .term = NULL, +static pktio_ops_module_t dpdk_pktio_ops = { + .base = { + .name = "dpdk", + .init_local = dpdk_pktio_init_local, + .init_global = dpdk_pktio_init_global, + .term_local = NULL, + .term_global = NULL, + }, .open = dpdk_open, .close = dpdk_close, .start = dpdk_start, .stop = dpdk_stop, .stats = dpdk_stats, .stats_reset = dpdk_stats_reset, + .pktin_ts_res = NULL, + .pktin_ts_from_ns = NULL, .recv = dpdk_recv, .send = dpdk_send, - .link_status = dpdk_link_status, .mtu_get = dpdk_mtu_get, .promisc_mode_set = dpdk_promisc_mode_set, .promisc_mode_get = dpdk_promisc_mode_get, .mac_get = dpdk_mac_addr_get, + .link_status = dpdk_link_status, .capability = dpdk_capability, - .pktin_ts_res = NULL, - .pktin_ts_from_ns = NULL, .config = NULL, .input_queues_config = dpdk_input_queues_config, - .output_queues_config = dpdk_output_queues_config + .output_queues_config = dpdk_output_queues_config, + .print = NULL, }; +ODP_MODULE_CONSTRUCTOR(dpdk_pktio_ops) +{ + odp_module_constructor(&dpdk_pktio_ops); + + odp_subsystem_register_module(pktio_ops, &dpdk_pktio_ops); +} + +/* Temporary variable to enable link this module, + * will remove in Makefile scheme changes. + */ +int enable_link_dpdk_pktio_ops = 0; + #endif /* ODP_PKTIO_DPDK */ diff --git a/platform/linux-generic/pktio/io_ops.c b/platform/linux-generic/pktio/io_ops.c deleted file mode 100644 index fbf30ca7..00000000 --- a/platform/linux-generic/pktio/io_ops.c +++ /dev/null @@ -1,31 +0,0 @@ -/* Copyright (c) 2013, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#include - -/* Ops for all implementation of pktio. - * Order matters. The first implementation to setup successfully - * will be picked. - * Array must be NULL terminated */ -const pktio_if_ops_t * const pktio_if_ops[] = { - &loopback_pktio_ops, -#ifdef ODP_PKTIO_DPDK - &dpdk_pktio_ops, -#endif -#ifdef ODP_NETMAP - &netmap_pktio_ops, -#endif -#ifdef HAVE_PCAP - &pcap_pktio_ops, -#endif -#ifdef _ODP_PKTIO_IPC - &ipc_pktio_ops, -#endif - &tap_pktio_ops, - &sock_mmap_pktio_ops, - &sock_mmsg_pktio_ops, - NULL -}; diff --git a/platform/linux-generic/pktio/ipc.c b/platform/linux-generic/pktio/ipc.c index 8c7db84e..984f0ab4 100644 --- a/platform/linux-generic/pktio/ipc.c +++ b/platform/linux-generic/pktio/ipc.c @@ -771,23 +771,44 @@ static int ipc_pktio_init_global(void) return 0; } -const pktio_if_ops_t ipc_pktio_ops = { - .name = "ipc", - .print = NULL, - .init_global = ipc_pktio_init_global, - .init_local = NULL, - .term = NULL, +static pktio_ops_module_t ipc_pktio_ops = { + .base = { + .name = "ipc", + .init_local = NULL, + .term_local = NULL, + .init_global = ipc_pktio_init_global, + .term_global = NULL, + }, .open = ipc_pktio_open, .close = ipc_close, - .recv = ipc_pktio_recv, - .send = ipc_pktio_send, .start = ipc_start, .stop = ipc_stop, + .stats = NULL, + .stats_reset = NULL, + .pktin_ts_res = NULL, + .pktin_ts_from_ns = NULL, + .recv = ipc_pktio_recv, + .send = ipc_pktio_send, .mtu_get = ipc_mtu_get, .promisc_mode_set = NULL, .promisc_mode_get = NULL, .mac_get = ipc_mac_addr_get, - .pktin_ts_res = NULL, - .pktin_ts_from_ns = NULL, - .config = NULL + .link_status = NULL, + .capability = NULL, + .config = NULL, + .input_queues_config = NULL, + .output_queues_config = NULL, + .print = NULL, }; + +ODP_MODULE_CONSTRUCTOR(ipc_pktio_ops) +{ + odp_module_constructor(&ipc_pktio_ops); + + odp_subsystem_register_module(pktio_ops, &ipc_pktio_ops); +} + +/* Temporary variable to enable link this module, + * will remove in Makefile scheme changes. + */ +int enable_link_ipc_pktio_ops = 0; diff --git a/platform/linux-generic/pktio/loop.c b/platform/linux-generic/pktio/loop.c index c825393a..39718a89 100644 --- a/platform/linux-generic/pktio/loop.c +++ b/platform/linux-generic/pktio/loop.c @@ -251,18 +251,22 @@ static int loop_init_global(void) return 0; } -const pktio_if_ops_t loopback_pktio_ops = { - .name = "loop", - .print = NULL, - .init_global = loop_init_global, - .init_local = NULL, - .term = NULL, +static pktio_ops_module_t loopback_pktio_ops = { + .base = { + .name = "loopback", + .init_local = NULL, + .term_local = NULL, + .init_global = loop_init_global, + .term_global = NULL, + }, .open = loopback_open, .close = loopback_close, .start = NULL, .stop = NULL, .stats = loopback_stats, .stats_reset = loopback_stats_reset, + .pktin_ts_res = NULL, + .pktin_ts_from_ns = NULL, .recv = loopback_recv, .send = loopback_send, .mtu_get = loopback_mtu_get, @@ -271,9 +275,20 @@ const pktio_if_ops_t loopback_pktio_ops = { .mac_get = loopback_mac_addr_get, .link_status = loopback_link_status, .capability = loopback_capability, - .pktin_ts_res = NULL, - .pktin_ts_from_ns = NULL, .config = NULL, .input_queues_config = NULL, .output_queues_config = NULL, + .print = NULL, }; + +ODP_MODULE_CONSTRUCTOR(loopback_pktio_ops) +{ + odp_module_constructor(&loopback_pktio_ops); + + odp_subsystem_register_module(pktio_ops, &loopback_pktio_ops); +} + +/* Temporary variable to enable link this module, + * will remove in Makefile scheme changes. + */ +int enable_link_loopback_pktio_ops = 0; diff --git a/platform/linux-generic/pktio/netmap.c b/platform/linux-generic/pktio/netmap.c index 928bb00a..c75f8be9 100644 --- a/platform/linux-generic/pktio/netmap.c +++ b/platform/linux-generic/pktio/netmap.c @@ -943,31 +943,46 @@ static int netmap_init_global(void) return 0; } -const pktio_if_ops_t netmap_pktio_ops = { - .name = "netmap", - .print = netmap_print, - .init_global = netmap_init_global, - .init_local = NULL, - .term = NULL, +static pktio_ops_module_t netmap_pktio_ops = { + .base = { + .name = "netmap", + .init_local = NULL, + .term_local = NULL, + .init_global = netmap_init_global, + .term_global = NULL, + }, .open = netmap_open, .close = netmap_close, .start = netmap_start, .stop = netmap_stop, - .link_status = netmap_link_status, .stats = netmap_stats, .stats_reset = netmap_stats_reset, + .pktin_ts_res = NULL, + .pktin_ts_from_ns = NULL, + .recv = netmap_recv, + .send = netmap_send, .mtu_get = netmap_mtu_get, .promisc_mode_set = netmap_promisc_mode_set, .promisc_mode_get = netmap_promisc_mode_get, .mac_get = netmap_mac_addr_get, + .link_status = netmap_link_status, .capability = netmap_capability, - .pktin_ts_res = NULL, - .pktin_ts_from_ns = NULL, .config = NULL, .input_queues_config = netmap_input_queues_config, .output_queues_config = netmap_output_queues_config, - .recv = netmap_recv, - .send = netmap_send + .print = netmap_print, }; +ODP_MODULE_CONSTRUCTOR(netmap_pktio_ops) +{ + odp_module_constructor(&netmap_pktio_ops); + + odp_subsystem_register_module(pktio_ops, &netmap_pktio_ops); +} + +/* Temporary variable to enable link this module, + * will remove in Makefile scheme changes. + */ +int enable_link_netmap_pktio_ops = 0; + #endif /* ODP_NETMAP */ diff --git a/platform/linux-generic/pktio/pcap.c b/platform/linux-generic/pktio/pcap.c index a467b640..98f81089 100644 --- a/platform/linux-generic/pktio/pcap.c +++ b/platform/linux-generic/pktio/pcap.c @@ -423,25 +423,44 @@ static int pcapif_init_global(void) return 0; } -const pktio_if_ops_t pcap_pktio_ops = { - .name = "pcap", - .print = NULL, - .init_global = pcapif_init_global, - .init_local = NULL, +static pktio_ops_module_t pcap_pktio_ops = { + .base = { + .name = "pcap", + .init_local = NULL, + .term_local = NULL, + .init_global = pcapif_init_global, + .term_global = NULL, + }, .open = pcapif_init, .close = pcapif_close, + .start = NULL, + .stop = NULL, .stats = pcapif_stats, .stats_reset = pcapif_stats_reset, + .pktin_ts_res = NULL, + .pktin_ts_from_ns = NULL, .recv = pcapif_recv_pkt, .send = pcapif_send_pkt, .mtu_get = pcapif_mtu_get, .promisc_mode_set = pcapif_promisc_mode_set, .promisc_mode_get = pcapif_promisc_mode_get, .mac_get = pcapif_mac_addr_get, + .link_status = NULL, .capability = pcapif_capability, - .pktin_ts_res = NULL, - .pktin_ts_from_ns = NULL, .config = NULL, .input_queues_config = NULL, .output_queues_config = NULL, + .print = NULL, }; + +ODP_MODULE_CONSTRUCTOR(pcap_pktio_ops) +{ + odp_module_constructor(&pcap_pktio_ops); + + odp_subsystem_register_module(pktio_ops, &pcap_pktio_ops); +} + +/* Temporary variable to enable link this module, + * will remove in Makefile scheme changes. + */ +int enable_link_pcap_pktio_ops = 0; diff --git a/platform/linux-generic/pktio/socket.c b/platform/linux-generic/pktio/socket.c index a383adc6..8b8ccf03 100644 --- a/platform/linux-generic/pktio/socket.c +++ b/platform/linux-generic/pktio/socket.c @@ -853,18 +853,22 @@ static int sock_init_global(void) return 0; } -const pktio_if_ops_t sock_mmsg_pktio_ops = { - .name = "socket", - .print = NULL, - .init_global = sock_init_global, - .init_local = NULL, - .term = NULL, +static pktio_ops_module_t socket_pktio_ops = { + .base = { + .name = "socket", + .init_local = NULL, + .term_local = NULL, + .init_global = sock_init_global, + .term_global = NULL, + }, .open = sock_mmsg_open, .close = sock_close, .start = NULL, .stop = NULL, .stats = sock_stats, .stats_reset = sock_stats_reset, + .pktin_ts_res = NULL, + .pktin_ts_from_ns = NULL, .recv = sock_mmsg_recv, .send = sock_mmsg_send, .mtu_get = sock_mtu_get, @@ -873,9 +877,20 @@ const pktio_if_ops_t sock_mmsg_pktio_ops = { .mac_get = sock_mac_addr_get, .link_status = sock_link_status, .capability = sock_capability, - .pktin_ts_res = NULL, - .pktin_ts_from_ns = NULL, .config = NULL, .input_queues_config = NULL, .output_queues_config = NULL, + .print = NULL, }; + +ODP_MODULE_CONSTRUCTOR(socket_pktio_ops) +{ + odp_module_constructor(&socket_pktio_ops); + + odp_subsystem_register_module(pktio_ops, &socket_pktio_ops); +} + +/* Temporary variable to enable link this module, + * will remove in Makefile scheme changes. + */ +int enable_link_socket_pktio_ops = 0; diff --git a/platform/linux-generic/pktio/socket_mmap.c b/platform/linux-generic/pktio/socket_mmap.c index 6fc4b4cc..0a27316f 100644 --- a/platform/linux-generic/pktio/socket_mmap.c +++ b/platform/linux-generic/pktio/socket_mmap.c @@ -710,18 +710,22 @@ static int sock_mmap_init_global(void) return 0; } -const pktio_if_ops_t sock_mmap_pktio_ops = { - .name = "socket_mmap", - .print = NULL, - .init_global = sock_mmap_init_global, - .init_local = NULL, - .term = NULL, +static pktio_ops_module_t socket_mmap_pktio_ops = { + .base = { + .name = "socket mmap", + .init_local = NULL, + .term_local = NULL, + .init_global = sock_mmap_init_global, + .term_global = NULL, + }, .open = sock_mmap_open, .close = sock_mmap_close, .start = NULL, .stop = NULL, .stats = sock_mmap_stats, .stats_reset = sock_mmap_stats_reset, + .pktin_ts_res = NULL, + .pktin_ts_from_ns = NULL, .recv = sock_mmap_recv, .send = sock_mmap_send, .mtu_get = sock_mmap_mtu_get, @@ -730,9 +734,20 @@ const pktio_if_ops_t sock_mmap_pktio_ops = { .mac_get = sock_mmap_mac_addr_get, .link_status = sock_mmap_link_status, .capability = sock_mmap_capability, - .pktin_ts_res = NULL, - .pktin_ts_from_ns = NULL, .config = NULL, .input_queues_config = NULL, .output_queues_config = NULL, + .print = NULL, }; + +ODP_MODULE_CONSTRUCTOR(socket_mmap_pktio_ops) +{ + odp_module_constructor(&socket_mmap_pktio_ops); + + odp_subsystem_register_module(pktio_ops, &socket_mmap_pktio_ops); +} + +/* Temporary variable to enable link this module, + * will remove in Makefile scheme changes. + */ +int enable_link_socket_mmap_pktio_ops = 0; diff --git a/platform/linux-generic/pktio/subsystem.c b/platform/linux-generic/pktio/subsystem.c new file mode 100644 index 00000000..fbcf22d7 --- /dev/null +++ b/platform/linux-generic/pktio/subsystem.c @@ -0,0 +1,58 @@ +/* Copyright (c) 2017, ARM Limited. All rights reserved. + * + * Copyright (c) 2017, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include +#include + +#define SUBSYSTEM_VERSION 0x00010000UL +ODP_SUBSYSTEM_DEFINE(pktio_ops, "packet IO operations", SUBSYSTEM_VERSION); + +/* Instantiate init and term functions */ +ODP_SUBSYSTEM_FOREACH_TEMPLATE(pktio_ops, init_global, ODP_ERR) +ODP_SUBSYSTEM_FOREACH_TEMPLATE(pktio_ops, init_local, ODP_ERR) +ODP_SUBSYSTEM_FOREACH_TEMPLATE(pktio_ops, term_global, ODP_ABORT) + +/* Temporary variable to enable link modules, + * will remove in Makefile scheme changes. + */ +#ifdef ODP_PKTIO_DPDK +extern int enable_link_dpdk_pktio_ops; +#endif +extern int enable_link_ipc_pktio_ops; +extern int enable_link_loopback_pktio_ops; +#ifdef ODP_NETMAP +extern int enable_link_netmap_pktio_ops; +#endif +#ifdef HAVE_PCAP +extern int enable_link_pcap_pktio_ops; +#endif +extern int enable_link_socket_pktio_ops; +extern int enable_link_socket_mmap_pktio_ops; +extern int enable_link_tap_pktio_ops; + +ODP_SUBSYSTEM_CONSTRUCTOR(pktio_ops) +{ + odp_subsystem_constructor(pktio_ops); + + /* Further initialization per subsystem */ + +#ifdef ODP_PKTIO_DPDK + enable_link_dpdk_pktio_ops = 1; +#endif + enable_link_ipc_pktio_ops = 1; + enable_link_loopback_pktio_ops = 1; +#ifdef ODP_NETMAP + enable_link_netmap_pktio_ops = 1; +#endif +#ifdef HAVE_PCAP + enable_link_pcap_pktio_ops = 1; +#endif + enable_link_socket_pktio_ops = 1; + enable_link_socket_mmap_pktio_ops = 1; + enable_link_tap_pktio_ops = 1; +} diff --git a/platform/linux-generic/pktio/tap.c b/platform/linux-generic/pktio/tap.c index 650c12a7..bfe41239 100644 --- a/platform/linux-generic/pktio/tap.c +++ b/platform/linux-generic/pktio/tap.c @@ -373,24 +373,44 @@ static int tap_capability(pktio_entry_t *pktio_entry ODP_UNUSED, return 0; } -const pktio_if_ops_t tap_pktio_ops = { - .name = "tap", - .print = NULL, - .init_global = NULL, - .init_local = NULL, - .term = NULL, +static pktio_ops_module_t tap_pktio_ops = { + .base = { + .name = "tap", + .init_local = NULL, + .term_local = NULL, + .init_global = NULL, + .term_global = NULL, + }, .open = tap_pktio_open, .close = tap_pktio_close, .start = NULL, .stop = NULL, + .stats = NULL, + .stats_reset = NULL, + .pktin_ts_res = NULL, + .pktin_ts_from_ns = NULL, .recv = tap_pktio_recv, .send = tap_pktio_send, .mtu_get = tap_mtu_get, .promisc_mode_set = tap_promisc_mode_set, .promisc_mode_get = tap_promisc_mode_get, .mac_get = tap_mac_addr_get, + .link_status = NULL, .capability = tap_capability, - .pktin_ts_res = NULL, - .pktin_ts_from_ns = NULL, - .config = NULL + .config = NULL, + .input_queues_config = NULL, + .output_queues_config = NULL, + .print = NULL, }; + +ODP_MODULE_CONSTRUCTOR(tap_pktio_ops) +{ + odp_module_constructor(&tap_pktio_ops); + + odp_subsystem_register_module(pktio_ops, &tap_pktio_ops); +} + +/* Temporary variable to enable link this module, + * will remove in Makefile scheme changes. + */ +int enable_link_tap_pktio_ops = 0; From patchwork Wed Aug 23 06: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: 110714 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp3672423qge; Tue, 22 Aug 2017 23:02:45 -0700 (PDT) X-Received: by 10.200.44.209 with SMTP id 17mr2326153qtx.265.1503468165432; Tue, 22 Aug 2017 23:02:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503468165; cv=none; d=google.com; s=arc-20160816; b=GUXy3hMlvf/OnteX7wT883DtRnJrPRWfq47ZgqKOkpa1ITpbWPCygGGxkzk3PsNSNr OASmhSlpwZQSgheXOkMICydNorgc8UI6GyVnN+XFYD2BKQSWCq2YsBfiziyWDTm/tA5d YJx5T2sw3tsWG0u3OJor9qbgovJX/csYhmmfDVye8ofGU/1CIDPfXnyjsrFWrmnfq2B5 bTm4d29d4oSFYlnsoe1GaOr6eq0jruN6vZsDnMIKdU4o8t1jQELqxMQqN0RivpJDheMA XIi9blZDUBVWRHfnXqleodcjEfo5HU7RT9X03xmiqj5y69SyGsqSfGivmkXPaniqzCHf wztg== 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=sZOmAwi3HLbGijxN2n/Nhtl1uZ3CxuiGO9EU/7QEDxk=; b=gn9kBXCwKl9jhtW8c/kSRla+eNAzXDFQud/c0QVReWVEJrfWyJ4RFxw2mfLELlitYo mPEhNzcM1SelZNn+n0KFdHidyiYP4GKeviQZRXGacycjbliy89lc6nXZPeieuAgBPkkZ lhCyZn+c7oqum/BBX3qhEK/9iQAkJVIWlDu8ZQBZR8RGAzXTN+fA7WGD6vxn48HdlNw4 LiMG/hxiqM8YK+wjoJyfWLPbsO8qwtxeN5hgVqfyr+/VTAS0zZBWumj1n8Bzyf9Hb3FL 0QOIsnUoqcOpVZQaX0Z2XNIY7ltPwxYJAuFOlKlOxM94if8eIS0F3G/8jGIT2uOngbD6 Up3g== 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 g52si746649qtg.287.2017.08.22.23.02.45; Tue, 22 Aug 2017 23:02:45 -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 E9C4D64495; Wed, 23 Aug 2017 06:02:44 +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 0060664494; Wed, 23 Aug 2017 06:00:37 +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 75537644A8; Wed, 23 Aug 2017 06:00:28 +0000 (UTC) Received: from forward100p.mail.yandex.net (forward100p.mail.yandex.net [77.88.28.100]) by lists.linaro.org (Postfix) with ESMTPS id 1914564484 for ; Wed, 23 Aug 2017 06:00:22 +0000 (UTC) Received: from mxback6o.mail.yandex.net (mxback6o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::20]) by forward100p.mail.yandex.net (Yandex) with ESMTP id 9AB7951049B3 for ; Wed, 23 Aug 2017 09:00:20 +0300 (MSK) Received: from smtp3o.mail.yandex.net (smtp3o.mail.yandex.net [2a02:6b8:0:1a2d::27]) by mxback6o.mail.yandex.net (nwsmtp/Yandex) with ESMTP id 1OWylkBGT3-0K3iPmMT; Wed, 23 Aug 2017 09:00:20 +0300 Received: by smtp3o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id QeRkbDFm9Y-0JLaENFu; Wed, 23 Aug 2017 09:00:19 +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: Wed, 23 Aug 2017 09:00:01 +0300 Message-Id: <1503468007-12911-5-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1503468007-12911-1-git-send-email-odpbot@yandex.ru> References: <1503468007-12911-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 139 Subject: [lng-odp] [PATCH CLOUD-DEV v1 4/10] 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 --- /** 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: 3cdc8a07993b93b145dc3b4a373b5ebc33bae882 ** Merge commit sha: a87822f157888ef3269a7b8b3f38c63ecc111669 **/ 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 +++++++------- 5 files changed, 40 insertions(+), 14 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-generic/Makefile.am b/platform/linux-generic/Makefile.am index 3ca43871..7dfbfed2 100644 --- a/platform/linux-generic/Makefile.am +++ b/platform/linux-generic/Makefile.am @@ -190,6 +190,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 \ @@ -263,7 +264,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 4054ad4a..7ad3ab9c 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, From patchwork Wed Aug 23 06:00:02 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: 110716 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp3676616qge; Tue, 22 Aug 2017 23:06:45 -0700 (PDT) X-Received: by 10.237.35.67 with SMTP id i3mr2251441qtc.212.1503468405691; Tue, 22 Aug 2017 23:06:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503468405; cv=none; d=google.com; s=arc-20160816; b=WMYXSi3HAyajFZ8q0y/Cr0/Z8fFCuGblUrqJb3nMNUg04ck9UqziLOoZRDSyNFDA8T IRKIcjpLB++cFxMLh/ft1enBFhyYZwqBcRMvvfqPjTxtU3DL8b4Dw5QGn6zyVFHC540v YrouIKgKv1Wik51l7D33p2uDkyHfS00iY16yJ5QIkdU3nrolS+s+Yr4rc/12Gy01tVHD TnW+d+Lwbqwo8cQ3XiRkNFSkovf0xYm0YL31ZKYaXOpZd7RAhBb4PXNm7WWhscSiqJDI e7hvvNtJ2RtT2pAIt9E0F11lHurzmLOj2EyyZmIpodFF2Yg88v6+p/7nVi2mv0G3UptC XmqA== 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=PmINkd8PWYHsctB72bFeihuW9R6fdqoR9Et35BRUnJA=; b=EORIXTKEMwzkdAj2vmdtj528nrjDEizcUYhbo4HoImPx7CtxL7n73MJQ1SgivFoKPH c82O4Ldi4pVafd6LrqzGsuAPGYtg/XTrgsgtjk/Hzwsk3T77upB/8r+xqgrW7/eks1xV kQjf1U7WU7s9aUklaby25CtzO92sw8Ot7ezWVbt6fkr8g+d2ZZp6x57/6xbWYU4+JXtU 4/N+wfo27qwy8IA7o6Qv000Y7BDCrE5/ktSSZAxmqDEhpg9GCuTL1UsQsJWZlLk51zsa /4ZS7ZuSQ5ntoIa51Y+ZyiahLMi2qbGkw8CgFfYbynrjZ2Lg6lzzLoxOQ8oduTLtTqyw Unvw== 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 v11si757471qti.550.2017.08.22.23.06.45; Tue, 22 Aug 2017 23:06:45 -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 32D4C644C9; Wed, 23 Aug 2017 06:06:45 +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 1C96860743; Wed, 23 Aug 2017 06:00:57 +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 55772644B5; Wed, 23 Aug 2017 06:00:35 +0000 (UTC) Received: from forward101j.mail.yandex.net (forward101j.mail.yandex.net [5.45.198.241]) by lists.linaro.org (Postfix) with ESMTPS id A583A6446B for ; Wed, 23 Aug 2017 06:00:23 +0000 (UTC) Received: from mxback10o.mail.yandex.net (mxback10o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::24]) by forward101j.mail.yandex.net (Yandex) with ESMTP id B446712418AE for ; Wed, 23 Aug 2017 09:00:21 +0300 (MSK) Received: from smtp3o.mail.yandex.net (smtp3o.mail.yandex.net [2a02:6b8:0:1a2d::27]) by mxback10o.mail.yandex.net (nwsmtp/Yandex) with ESMTP id jbBFC98BBc-0L2an9I0; Wed, 23 Aug 2017 09:00:21 +0300 Received: by smtp3o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id QeRkbDFm9Y-0KLKQDGc; Wed, 23 Aug 2017 09:00:20 +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: Wed, 23 Aug 2017 09:00:02 +0300 Message-Id: <1503468007-12911-6-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1503468007-12911-1-git-send-email-odpbot@yandex.ru> References: <1503468007-12911-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 139 Subject: [lng-odp] [PATCH CLOUD-DEV v1 5/10] linux-gen: pktio: ipc: 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 Move implementation specific data structure into dedicated header file. Signed-off-by: Yi He --- /** 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: 3cdc8a07993b93b145dc3b4a373b5ebc33bae882 ** Merge commit sha: a87822f157888ef3269a7b8b3f38c63ecc111669 **/ platform/linux-generic/Makefile.am | 2 +- .../linux-generic/include/odp_packet_io_internal.h | 39 ----- .../include/odp_packet_io_ipc_internal.h | 48 ------ platform/linux-generic/include/odp_pktio_ops_ipc.h | 91 ++++++++++ .../include/odp_pktio_ops_subsystem.h | 2 + platform/linux-generic/odp_packet_io.c | 1 - platform/linux-generic/pktio/ipc.c | 185 +++++++++++---------- 7 files changed, 189 insertions(+), 179 deletions(-) delete mode 100644 platform/linux-generic/include/odp_packet_io_ipc_internal.h create mode 100644 platform/linux-generic/include/odp_pktio_ops_ipc.h diff --git a/platform/linux-generic/Makefile.am b/platform/linux-generic/Makefile.am index 7dfbfed2..3e2b8756 100644 --- a/platform/linux-generic/Makefile.am +++ b/platform/linux-generic/Makefile.am @@ -184,12 +184,12 @@ noinst_HEADERS = \ ${srcdir}/include/odp_name_table_internal.h \ ${srcdir}/include/odp_packet_internal.h \ ${srcdir}/include/odp_packet_io_internal.h \ - ${srcdir}/include/odp_packet_io_ipc_internal.h \ ${srcdir}/include/odp_packet_io_ring_internal.h \ ${srcdir}/include/odp_packet_netmap.h \ ${srcdir}/include/odp_packet_dpdk.h \ ${srcdir}/include/odp_packet_socket.h \ ${srcdir}/include/odp_packet_tap.h \ + ${srcdir}/include/odp_pktio_ops_ipc.h \ ${srcdir}/include/odp_pktio_ops_loopback.h \ ${srcdir}/include/odp_pktio_ops_subsystem.h \ ${srcdir}/include/odp_pkt_queue_internal.h \ diff --git a/platform/linux-generic/include/odp_packet_io_internal.h b/platform/linux-generic/include/odp_packet_io_internal.h index 7ad3ab9c..3646dbac 100644 --- a/platform/linux-generic/include/odp_packet_io_internal.h +++ b/platform/linux-generic/include/odp_packet_io_internal.h @@ -66,44 +66,6 @@ typedef struct { } pkt_pcap_t; #endif -typedef struct { - /* TX */ - struct { - _ring_t *send; /**< ODP ring for IPC msg packets - indexes transmitted to shared - memory */ - _ring_t *free; /**< ODP ring for IPC msg packets - indexes already processed by remote - process */ - } tx; - /* RX */ - struct { - _ring_t *recv; /**< ODP ring for IPC msg packets - indexes received from shared - memory (from remote process) */ - _ring_t *free; /**< odp ring for ipc msg packets - indexes already processed by - current process */ - _ring_t *cache; /**< local cache to keep packet order right */ - } rx; /* slave */ - void *pool_base; /**< Remote pool base addr */ - void *pool_mdata_base; /**< Remote pool mdata base addr */ - uint64_t pkt_size; /**< Packet size in remote pool */ - odp_pool_t pool; /**< Pool of main process */ - enum { - PKTIO_TYPE_IPC_MASTER = 0, /**< Master is the process which - creates shm */ - PKTIO_TYPE_IPC_SLAVE /**< Slave is the process which - connects to shm */ - } type; /**< define if it's master or slave process */ - odp_atomic_u32_t ready; /**< 1 - pktio is ready and can recv/send - packet, 0 - not yet ready */ - void *pinfo; - odp_shm_t pinfo_shm; - odp_shm_t remote_pool_shm; /**< shm of remote pool get with - _ipc_map_remote_pool() */ -} _ipc_pktio_t; - struct pktio_entry { const pktio_ops_module_t *ops; /**< Implementation specific methods */ pktio_ops_data_t ops_data; /**< IO operation specific data */ @@ -122,7 +84,6 @@ struct pktio_entry { pkt_pcap_t pkt_pcap; /**< Using pcap for IO */ #endif pkt_tap_t pkt_tap; /**< using TAP for IO */ - _ipc_pktio_t ipc; /**< IPC pktio data */ }; enum { /* Not allocated */ diff --git a/platform/linux-generic/include/odp_packet_io_ipc_internal.h b/platform/linux-generic/include/odp_packet_io_ipc_internal.h deleted file mode 100644 index 9d8943a6..00000000 --- a/platform/linux-generic/include/odp_packet_io_ipc_internal.h +++ /dev/null @@ -1,48 +0,0 @@ -/* Copyright (c) 2015, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -/* IPC packet I/O over shared memory ring */ -#include - -/* number of odp buffers in odp ring queue */ -#define PKTIO_IPC_ENTRIES 4096 - -/* that struct is exported to shared memory, so that processes can find - * each other. - */ -struct pktio_info { - struct { - /* number of buffer*/ - int num; - /* size of packet/segment in remote pool */ - uint32_t block_size; - char pool_name[ODP_POOL_NAME_LEN]; - /* 1 if master finished creation of all shared objects */ - int init_done; - } master; - struct { - void *base_addr; - uint32_t block_size; - char pool_name[ODP_POOL_NAME_LEN]; - /* pid of the slave process written to shm and - * used by master to look up memory created by - * slave - */ - int pid; - int init_done; - } slave; -} ODP_PACKED; diff --git a/platform/linux-generic/include/odp_pktio_ops_ipc.h b/platform/linux-generic/include/odp_pktio_ops_ipc.h new file mode 100644 index 00000000..5903ef9b --- /dev/null +++ b/platform/linux-generic/include/odp_pktio_ops_ipc.h @@ -0,0 +1,91 @@ +/* Copyright (c) 2015, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef ODP_PKTIO_OPS_IPC_H_ +#define ODP_PKTIO_OPS_IPC_H_ + +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +/* IPC packet I/O over shared memory ring */ +#include + +/* number of odp buffers in odp ring queue */ +#define PKTIO_IPC_ENTRIES 4096 + +/* that struct is exported to shared memory, so that processes can find + * each other. + */ +struct pktio_info { + struct { + /* number of buffer*/ + int num; + /* size of packet/segment in remote pool */ + uint32_t block_size; + char pool_name[ODP_POOL_NAME_LEN]; + /* 1 if master finished creation of all shared objects */ + int init_done; + } master; + struct { + void *base_addr; + uint32_t block_size; + char pool_name[ODP_POOL_NAME_LEN]; + /* pid of the slave process written to shm and + * used by master to look up memory created by + * slave + */ + int pid; + int init_done; + } slave; +} ODP_PACKED; + +typedef struct { + /* TX */ + struct { + _ring_t *send; /**< ODP ring for IPC msg packets + indexes transmitted to shared + memory */ + _ring_t *free; /**< ODP ring for IPC msg packets + indexes already processed by remote + process */ + } tx; + /* RX */ + struct { + _ring_t *recv; /**< ODP ring for IPC msg packets + indexes received from shared + memory (from remote process) */ + _ring_t *free; /**< odp ring for ipc msg packets + indexes already processed by + current process */ + _ring_t *cache; /**< local cache to keep packet order right */ + } rx; /* slave */ + void *pool_base; /**< Remote pool base addr */ + void *pool_mdata_base; /**< Remote pool mdata base addr */ + uint64_t pkt_size; /**< Packet size in remote pool */ + odp_pool_t pool; /**< Pool of main process */ + enum { + PKTIO_TYPE_IPC_MASTER = 0, /**< Master is the process which + creates shm */ + PKTIO_TYPE_IPC_SLAVE /**< Slave is the process which + connects to shm */ + } type; /**< define if it's master or slave process */ + odp_atomic_u32_t ready; /**< 1 - pktio is ready and can recv/send + packet, 0 - not yet ready */ + void *pinfo; + odp_shm_t pinfo_shm; + odp_shm_t remote_pool_shm; /**< shm of remote pool get with + _ipc_map_remote_pool() */ +} pktio_ops_ipc_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 7b90ed3d..650b3664 100644 --- a/platform/linux-generic/include/odp_pktio_ops_subsystem.h +++ b/platform/linux-generic/include/odp_pktio_ops_subsystem.h @@ -79,12 +79,14 @@ typedef ODP_MODULE_CLASS(pktio_ops) { } pktio_ops_module_t; /* All implementations of this subsystem */ +#include #include /* Per implementation private data * TODO: refactory each implementation to hide it internally */ typedef union { + pktio_ops_ipc_data_t ipc; pktio_ops_loopback_data_t loopback; } pktio_ops_data_t; diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c index 3e47aac9..bdcf524c 100644 --- a/platform/linux-generic/odp_packet_io.c +++ b/platform/linux-generic/odp_packet_io.c @@ -19,7 +19,6 @@ #include #include #include -#include #include #include diff --git a/platform/linux-generic/pktio/ipc.c b/platform/linux-generic/pktio/ipc.c index 984f0ab4..14cd86eb 100644 --- a/platform/linux-generic/pktio/ipc.c +++ b/platform/linux-generic/pktio/ipc.c @@ -3,7 +3,6 @@ * * SPDX-License-Identifier: BSD-3-Clause */ -#include #include #include #include @@ -43,7 +42,7 @@ 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->s.ipc.pinfo; + struct pktio_info *pinfo = pktio_entry->ops_data(ipc).pinfo; odp_shm_t shm; if (pinfo->slave.init_done == 0) @@ -57,11 +56,11 @@ static int _ipc_master_start(pktio_entry_t *pktio_entry) return -1; } - pktio_entry->s.ipc.remote_pool_shm = shm; - pktio_entry->s.ipc.pool_base = odp_shm_addr(shm); - pktio_entry->s.ipc.pool_mdata_base = (char *)odp_shm_addr(shm); + 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); - odp_atomic_store_u32(&pktio_entry->s.ipc.ready, 1); + odp_atomic_store_u32(&pktio_entry->ops_data(ipc).ready, 1); IPC_ODP_DBG("%s started.\n", pktio_entry->s.name); return 0; @@ -88,62 +87,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->s.ipc.tx.send = _ring_create(ipc_shm_name, + pktio_entry->ops_data(ipc).tx.send = _ring_create(ipc_shm_name, PKTIO_IPC_ENTRIES, _RING_SHM_PROC | _RING_NO_LIST); - if (!pktio_entry->s.ipc.tx.send) { + if (!pktio_entry->ops_data(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->s.ipc.tx.send), - _ring_free_count(pktio_entry->s.ipc.tx.send)); + ipc_shm_name, _ring_count(pktio_entry->ops_data(ipc).tx.send), + _ring_free_count(pktio_entry->ops_data(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->s.ipc.tx.free = _ring_create(ipc_shm_name, + pktio_entry->ops_data(ipc).tx.free = _ring_create(ipc_shm_name, PKTIO_IPC_ENTRIES, _RING_SHM_PROC | _RING_NO_LIST); - if (!pktio_entry->s.ipc.tx.free) { + if (!pktio_entry->ops_data(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->s.ipc.tx.free), - _ring_free_count(pktio_entry->s.ipc.tx.free)); + ipc_shm_name, _ring_count(pktio_entry->ops_data(ipc).tx.free), + _ring_free_count(pktio_entry->ops_data(ipc).tx.free)); snprintf(ipc_shm_name, sizeof(ipc_shm_name), "%s_s_prod", dev); - pktio_entry->s.ipc.rx.recv = _ring_create(ipc_shm_name, + pktio_entry->ops_data(ipc).rx.recv = _ring_create(ipc_shm_name, PKTIO_IPC_ENTRIES, _RING_SHM_PROC | _RING_NO_LIST); - if (!pktio_entry->s.ipc.rx.recv) { + if (!pktio_entry->ops_data(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->s.ipc.rx.recv), - _ring_free_count(pktio_entry->s.ipc.rx.recv)); + ipc_shm_name, _ring_count(pktio_entry->ops_data(ipc).rx.recv), + _ring_free_count(pktio_entry->ops_data(ipc).rx.recv)); snprintf(ipc_shm_name, sizeof(ipc_shm_name), "%s_s_cons", dev); - pktio_entry->s.ipc.rx.free = _ring_create(ipc_shm_name, + pktio_entry->ops_data(ipc).rx.free = _ring_create(ipc_shm_name, PKTIO_IPC_ENTRIES, _RING_SHM_PROC | _RING_NO_LIST); - if (!pktio_entry->s.ipc.rx.free) { + if (!pktio_entry->ops_data(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->s.ipc.rx.free), - _ring_free_count(pktio_entry->s.ipc.rx.free)); + ipc_shm_name, _ring_count(pktio_entry->ops_data(ipc).rx.free), + _ring_free_count(pktio_entry->ops_data(ipc).rx.free)); /* Set up pool name for remote info */ - pinfo = pktio_entry->s.ipc.pinfo; + pinfo = pktio_entry->ops_data(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", @@ -156,7 +155,7 @@ static int _ipc_init_master(pktio_entry_t *pktio_entry, pinfo->slave.pid = 0; pinfo->slave.init_done = 0; - pktio_entry->s.ipc.pool = pool_hdl; + pktio_entry->ops_data(ipc).pool = pool_hdl; ODP_DBG("Pre init... DONE.\n"); pinfo->master.init_done = 1; @@ -225,7 +224,7 @@ static int _ipc_init_slave(const char *dev, if (strlen(dev) > (ODP_POOL_NAME_LEN - sizeof("_slave_r"))) ODP_ABORT("too big ipc name\n"); - pktio_entry->s.ipc.pool = pool; + pktio_entry->ops_data(ipc).pool = pool; return 0; } @@ -246,61 +245,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->s.ipc.rx.recv = _ipc_shm_map(ipc_shm_name, pid); - if (!pktio_entry->s.ipc.rx.recv) { + pktio_entry->ops_data(ipc).rx.recv = _ipc_shm_map(ipc_shm_name, pid); + if (!pktio_entry->ops_data(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->s.ipc.rx.recv), - _ring_free_count(pktio_entry->s.ipc.rx.recv)); + ipc_shm_name, _ring_count(pktio_entry->ops_data(ipc).rx.recv), + _ring_free_count(pktio_entry->ops_data(ipc).rx.recv)); snprintf(ipc_shm_name, sizeof(ipc_shm_name), "%s_m_cons", dev); - pktio_entry->s.ipc.rx.free = _ipc_shm_map(ipc_shm_name, pid); - if (!pktio_entry->s.ipc.rx.free) { + pktio_entry->ops_data(ipc).rx.free = _ipc_shm_map(ipc_shm_name, pid); + if (!pktio_entry->ops_data(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->s.ipc.rx.free), - _ring_free_count(pktio_entry->s.ipc.rx.free)); + ipc_shm_name, _ring_count(pktio_entry->ops_data(ipc).rx.free), + _ring_free_count(pktio_entry->ops_data(ipc).rx.free)); snprintf(ipc_shm_name, sizeof(ipc_shm_name), "%s_s_prod", dev); - pktio_entry->s.ipc.tx.send = _ipc_shm_map(ipc_shm_name, pid); - if (!pktio_entry->s.ipc.tx.send) { + pktio_entry->ops_data(ipc).tx.send = _ipc_shm_map(ipc_shm_name, pid); + if (!pktio_entry->ops_data(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->s.ipc.tx.send), - _ring_free_count(pktio_entry->s.ipc.tx.send)); + ipc_shm_name, _ring_count(pktio_entry->ops_data(ipc).tx.send), + _ring_free_count(pktio_entry->ops_data(ipc).tx.send)); snprintf(ipc_shm_name, sizeof(ipc_shm_name), "%s_s_cons", dev); - pktio_entry->s.ipc.tx.free = _ipc_shm_map(ipc_shm_name, pid); - if (!pktio_entry->s.ipc.tx.free) { + pktio_entry->ops_data(ipc).tx.free = _ipc_shm_map(ipc_shm_name, pid); + if (!pktio_entry->ops_data(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->s.ipc.tx.free), - _ring_free_count(pktio_entry->s.ipc.tx.free)); + ipc_shm_name, _ring_count(pktio_entry->ops_data(ipc).tx.free), + _ring_free_count(pktio_entry->ops_data(ipc).tx.free)); /* Get info about remote pool */ - pinfo = pktio_entry->s.ipc.pinfo; + pinfo = pktio_entry->ops_data(ipc).pinfo; shm = _ipc_map_remote_pool(pinfo->master.pool_name, pid); - pktio_entry->s.ipc.remote_pool_shm = shm; - pktio_entry->s.ipc.pool_mdata_base = (char *)odp_shm_addr(shm); - pktio_entry->s.ipc.pkt_size = pinfo->master.block_size; + 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; - _ipc_export_pool(pinfo, pktio_entry->s.ipc.pool); + _ipc_export_pool(pinfo, pktio_entry->ops_data(ipc).pool); - odp_atomic_store_u32(&pktio_entry->s.ipc.ready, 1); + odp_atomic_store_u32(&pktio_entry->ops_data(ipc).ready, 1); pinfo->slave.init_done = 1; ODP_DBG("%s started.\n", pktio_entry->s.name); @@ -339,15 +338,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->s.ipc.ready, 0); + odp_atomic_init_u32(&pktio_entry->ops_data(ipc).ready, 0); - pktio_entry->s.ipc.rx.cache = _ring_create("ipc_rx_cache", + pktio_entry->ops_data(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->s.ipc.type = PKTIO_TYPE_IPC_SLAVE; + pktio_entry->ops_data(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); @@ -360,12 +359,12 @@ static int ipc_pktio_open(odp_pktio_t id ODP_UNUSED, odp_shm_free(shm); return -1; } - pktio_entry->s.ipc.pinfo = pinfo; - pktio_entry->s.ipc.pinfo_shm = shm; + pktio_entry->ops_data(ipc).pinfo = pinfo; + pktio_entry->ops_data(ipc).pinfo_shm = shm; ODP_DBG("process %d is slave\n", getpid()); ret = _ipc_init_slave(name, pktio_entry, pool); } else { - pktio_entry->s.ipc.type = PKTIO_TYPE_IPC_MASTER; + pktio_entry->ops_data(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, @@ -378,8 +377,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->s.ipc.pinfo = pinfo; - pktio_entry->s.ipc.pinfo_shm = shm; + pktio_entry->ops_data(ipc).pinfo = pinfo; + pktio_entry->ops_data(ipc).pinfo_shm = shm; ODP_DBG("process %d is master\n", getpid()); ret = _ipc_init_master(pktio_entry, dev, pool); } @@ -399,7 +398,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->s.ipc.pool); + pool = pool_entry_from_hdl(pktio_entry->ops_data(ipc).pool); addr = odp_shm_addr(pool->shm); rbuf_p = (void *)&offsets; @@ -433,16 +432,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->s.ipc.ready); + ready = odp_atomic_load_u32(&pktio_entry->ops_data(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->s.ipc.tx.free); + _ipc_free_ring_packets(pktio_entry, pktio_entry->ops_data(ipc).tx.free); /* rx from cache */ - r = pktio_entry->s.ipc.rx.cache; + r = pktio_entry->ops_data(ipc).rx.cache; pkts = _ring_mc_dequeue_burst(r, ipcbufs_p, len); if (odp_unlikely(pkts < 0)) ODP_ABORT("internal error dequeue\n"); @@ -450,7 +449,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->s.ipc.rx.recv; + r = pktio_entry->ops_data(ipc).rx.recv; pkts = _ring_mc_dequeue_burst(r, ipcbufs_p, len); if (odp_unlikely(pkts < 0)) ODP_ABORT("internal error dequeue\n"); @@ -468,10 +467,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->s.ipc.pool_mdata_base + - offsets[i]); + phdr = (void *)((uint8_t *)pktio_entry-> + ops_data(ipc).pool_mdata_base + offsets[i]); - pool = pktio_entry->s.ipc.pool; + pool = pktio_entry->ops_data(ipc).pool; if (odp_unlikely(pool == ODP_POOL_INVALID)) ODP_ABORT("invalid pool"); @@ -496,11 +495,11 @@ static int ipc_pktio_recv_lockless(pktio_entry_t *pktio_entry, if (odp_unlikely(!pkt_data)) ODP_ABORT("unable to map pkt_data ipc_slave %d\n", (PKTIO_TYPE_IPC_SLAVE == - pktio_entry->s.ipc.type)); + pktio_entry->ops_data(ipc).type)); /* Copy packet data from shared pool to local pool. */ - rmt_data_ptr = (uint8_t *)pktio_entry->s.ipc.pool_mdata_base + - data_pool_off; + rmt_data_ptr = (uint8_t *)pktio_entry-> + ops_data(ipc).pool_mdata_base + data_pool_off; memcpy(pkt_data, rmt_data_ptr, phdr->frame_len); /* Copy packets L2, L3 parsed offsets and size */ @@ -519,7 +518,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->s.ipc.rx.cache; + r_p = pktio_entry->ops_data(ipc).rx.cache; pkts_ring = _ring_mp_enqueue_burst(r_p, ipcbufs_p, pkts - i); if (pkts_ring != (pkts - i)) @@ -534,7 +533,7 @@ static int ipc_pktio_recv_lockless(pktio_entry_t *pktio_entry, pkts = i; /* Now tell other process that we no longer need that buffers.*/ - r_p = pktio_entry->s.ipc.rx.free; + r_p = pktio_entry->ops_data(ipc).rx.free; repeat: @@ -582,7 +581,7 @@ static int ipc_pktio_send_lockless(pktio_entry_t *pktio_entry, void **rbuf_p; int ret; int i; - uint32_t ready = odp_atomic_load_u32(&pktio_entry->s.ipc.ready); + uint32_t ready = odp_atomic_load_u32(&pktio_entry->ops_data(ipc).ready); odp_packet_t pkt_table_mapped[len]; /**< Ready to send packet has to be * in memory mapped pool. */ uintptr_t offsets[len]; @@ -590,14 +589,15 @@ 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->s.ipc.tx.free); + _ipc_free_ring_packets(pktio_entry, pktio_entry->ops_data(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). */ for (i = 0; i < len; i++) { odp_packet_t pkt = pkt_table[i]; - pool_t *ipc_pool = pool_entry_from_hdl(pktio_entry->s.ipc.pool); + pool_t *ipc_pool = pool_entry_from_hdl( + pktio_entry->ops_data(ipc).pool); odp_packet_hdr_t *pkt_hdr; pool_t *pool; @@ -608,7 +608,8 @@ 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->s.ipc.pool); + newpkt = odp_packet_copy( + pkt, pktio_entry->ops_data(ipc).pool); if (newpkt == ODP_PACKET_INVALID) ODP_ABORT("Unable to copy packet\n"); @@ -640,18 +641,19 @@ 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->s.ipc.pool)->shm)); + odp_shm_addr(pool_entry_from_hdl(pktio_entry-> + ops_data(ipc).pool)->shm)); } /* Put packets to ring to be processed by other process. */ rbuf_p = (void *)&offsets[0]; - r = pktio_entry->s.ipc.tx.send; + r = pktio_entry->ops_data(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->s.ipc.type), + (PKTIO_TYPE_IPC_SLAVE == + pktio_entry->ops_data(ipc).type), ret); ODP_ERR("odp_ring_full: %d, odp_ring_count %d, _ring_free_count %d\n", _ring_full(r), _ring_count(r), @@ -691,14 +693,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->s.ipc.ready); + uint32_t ready = odp_atomic_load_u32( + &pktio_entry->ops_data(ipc).ready); if (ready) { ODP_ABORT("%s Already started\n", pktio_entry->s.name); return -1; } - if (pktio_entry->s.ipc.type == PKTIO_TYPE_IPC_MASTER) + if (pktio_entry->ops_data(ipc).type == PKTIO_TYPE_IPC_MASTER) return _ipc_master_start(pktio_entry); else return _ipc_slave_start(pktio_entry); @@ -708,20 +711,22 @@ static int ipc_stop(pktio_entry_t *pktio_entry) { unsigned tx_send = 0, tx_free = 0; - odp_atomic_store_u32(&pktio_entry->s.ipc.ready, 0); + odp_atomic_store_u32(&pktio_entry->ops_data(ipc).ready, 0); - if (pktio_entry->s.ipc.tx.send) - _ipc_free_ring_packets(pktio_entry, pktio_entry->s.ipc.tx.send); + if (pktio_entry->ops_data(ipc).tx.send) + _ipc_free_ring_packets(pktio_entry, + pktio_entry->ops_data(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->s.ipc.tx.free) - _ipc_free_ring_packets(pktio_entry, pktio_entry->s.ipc.tx.free); - - if (pktio_entry->s.ipc.tx.send) - tx_send = _ring_count(pktio_entry->s.ipc.tx.send); - if (pktio_entry->s.ipc.tx.free) - tx_free = _ring_count(pktio_entry->s.ipc.tx.free); + 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 (tx_send | tx_free) { ODP_DBG("IPC rings: tx send %d tx free %d\n", tx_send, tx_free); @@ -740,7 +745,7 @@ static int ipc_close(pktio_entry_t *pktio_entry) ipc_stop(pktio_entry); - odp_shm_free(pktio_entry->s.ipc.remote_pool_shm); + odp_shm_free(pktio_entry->ops_data(ipc).remote_pool_shm); if (sscanf(dev, "ipc:%d:%s", &pid, tail) == 2) snprintf(name, sizeof(name), "ipc:%s", tail); @@ -748,7 +753,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->s.ipc.pinfo_shm); + odp_shm_free(pktio_entry->ops_data(ipc).pinfo_shm); /* destroy rings */ snprintf(ipc_shm_name, sizeof(ipc_shm_name), "%s_s_cons", name); From patchwork Wed Aug 23 06:00:03 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: 110718 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp3679852qge; Tue, 22 Aug 2017 23:09:38 -0700 (PDT) X-Received: by 10.55.115.66 with SMTP id o63mr2162892qkc.41.1503468578054; Tue, 22 Aug 2017 23:09:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503468578; cv=none; d=google.com; s=arc-20160816; b=yXSlZFLPb+ZRfZoHdIJhbzxLjYpv2nT0aV2fsAmslLRb5JYkRKTHFl+phQ+5qT+3gV byks1Vb8pPgsGaQxaXnuE3WtcRMFRCIuMwUrKL1/sSiB7LXr2m9nWOTmo8/OQPCBYtkg Zn7SPYuUOcAc8MTchBuj8l77yUDhOq5n6C+0f3gxQnOnfTYjF0y0c0Mk+WAvTjNFDX8s Iyd6FdgOzYTLrOMsZwbgW2lUHodXzBXa8tkVc9EfyOqZ9bVEqH6G2BakPWqS3CSiV/hw mSC2NWoY8SOzQpEeHg13NBx733Xc+Xngb947cDFBVWlifVrSZSawstTlJAwmjAPGGWf2 Z4Xw== 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=eRLRFBCN5f6E/t9wdHSpEMUQpW8fh1Jx/west8kKb+A=; b=ZT/qnJxWdmhrxQihfs4LzYH6nc0WkS6BGIxthD4DfU0uWbTRDA0Kz3cxof2gzA7Oc+ 0AjUn/PI0XQN1yZ8wwd2hccm/44CHmcO7FCQBz722qJbpTwomiW0y9fKkio8eFK+ULVz jsZ79cDCQEdDbMUL/9WTB1UBSipU9il97Gp+d83Bh6UNcumCO2zdp+5/RnmHwh94Ow2T Vh8348TMPtka8RqXY1ezD0EUiNRddpD3EdhpQYveTwknD+NlS7sRYJjf+caZFVnM0JkS iGPvBdNDMNf6438fnmI/zTUXLhC3LklpV+Usk2siNpU5c+UEr39ZZKy5PRgml6nu6nL1 gDOw== 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 z5si757080qke.484.2017.08.22.23.09.37; Tue, 22 Aug 2017 23:09:38 -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 A3E2D64497; Wed, 23 Aug 2017 06:09:37 +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, 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 DF2276087C; Wed, 23 Aug 2017 06:01:05 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id DDF72644B8; Wed, 23 Aug 2017 06:00:37 +0000 (UTC) Received: from forward104o.mail.yandex.net (forward104o.mail.yandex.net [37.140.190.179]) by lists.linaro.org (Postfix) with ESMTPS id F25826448C for ; Wed, 23 Aug 2017 06:00:23 +0000 (UTC) Received: from mxback15j.mail.yandex.net (mxback15j.mail.yandex.net [IPv6:2a02:6b8:0:1619::91]) by forward104o.mail.yandex.net (Yandex) with ESMTP id 7C3DF2C84447 for ; Wed, 23 Aug 2017 09:00:22 +0300 (MSK) Received: from smtp3o.mail.yandex.net (smtp3o.mail.yandex.net [2a02:6b8:0:1a2d::27]) by mxback15j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id z6tybjVW5S-0M9KVUkR; Wed, 23 Aug 2017 09:00:22 +0300 Received: by smtp3o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id QeRkbDFm9Y-0LLWxLku; Wed, 23 Aug 2017 09:00:21 +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: Wed, 23 Aug 2017 09:00:03 +0300 Message-Id: <1503468007-12911-7-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1503468007-12911-1-git-send-email-odpbot@yandex.ru> References: <1503468007-12911-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 139 Subject: [lng-odp] [PATCH CLOUD-DEV v1 6/10] linux-gen: pktio: netmap: 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 Move implementation specific data structure into dedicated header file. Signed-off-by: Yi He --- /** 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: 3cdc8a07993b93b145dc3b4a373b5ebc33bae882 ** Merge commit sha: a87822f157888ef3269a7b8b3f38c63ecc111669 **/ platform/linux-generic/Makefile.am | 2 +- .../linux-generic/include/odp_packet_io_internal.h | 2 - ...{odp_packet_netmap.h => odp_pktio_ops_netmap.h} | 6 +- .../include/odp_pktio_ops_subsystem.h | 2 + platform/linux-generic/pktio/netmap.c | 89 ++++++++++++---------- 5 files changed, 56 insertions(+), 45 deletions(-) rename platform/linux-generic/include/{odp_packet_netmap.h => odp_pktio_ops_netmap.h} (96%) diff --git a/platform/linux-generic/Makefile.am b/platform/linux-generic/Makefile.am index 3e2b8756..1db9bbc4 100644 --- a/platform/linux-generic/Makefile.am +++ b/platform/linux-generic/Makefile.am @@ -185,12 +185,12 @@ noinst_HEADERS = \ ${srcdir}/include/odp_packet_internal.h \ ${srcdir}/include/odp_packet_io_internal.h \ ${srcdir}/include/odp_packet_io_ring_internal.h \ - ${srcdir}/include/odp_packet_netmap.h \ ${srcdir}/include/odp_packet_dpdk.h \ ${srcdir}/include/odp_packet_socket.h \ ${srcdir}/include/odp_packet_tap.h \ ${srcdir}/include/odp_pktio_ops_ipc.h \ ${srcdir}/include/odp_pktio_ops_loopback.h \ + ${srcdir}/include/odp_pktio_ops_netmap.h \ ${srcdir}/include/odp_pktio_ops_subsystem.h \ ${srcdir}/include/odp_pkt_queue_internal.h \ ${srcdir}/include/odp_pool_internal.h \ diff --git a/platform/linux-generic/include/odp_packet_io_internal.h b/platform/linux-generic/include/odp_packet_io_internal.h index 3646dbac..f974abb6 100644 --- a/platform/linux-generic/include/odp_packet_io_internal.h +++ b/platform/linux-generic/include/odp_packet_io_internal.h @@ -32,7 +32,6 @@ extern "C" { #define PKTIO_MAX_QUEUES 64 #include -#include #include #include @@ -78,7 +77,6 @@ struct pktio_entry { pkt_sock_t pkt_sock; /**< using socket API for IO */ pkt_sock_mmap_t pkt_sock_mmap; /**< using socket mmap * API for IO */ - pkt_netmap_t pkt_nm; /**< using netmap API for IO */ pkt_dpdk_t pkt_dpdk; /**< using DPDK for IO */ #ifdef HAVE_PCAP pkt_pcap_t pkt_pcap; /**< Using pcap for IO */ diff --git a/platform/linux-generic/include/odp_packet_netmap.h b/platform/linux-generic/include/odp_pktio_ops_netmap.h similarity index 96% rename from platform/linux-generic/include/odp_packet_netmap.h rename to platform/linux-generic/include/odp_pktio_ops_netmap.h index a6f68d56..35592d85 100644 --- a/platform/linux-generic/include/odp_packet_netmap.h +++ b/platform/linux-generic/include/odp_pktio_ops_netmap.h @@ -4,8 +4,8 @@ * SPDX-License-Identifier: BSD-3-Clause */ -#ifndef ODP_PACKET_NETMAP_H -#define ODP_PACKET_NETMAP_H +#ifndef ODP_PKTIO_OPS_NETMAP_H_ +#define ODP_PKTIO_OPS_NETMAP_H_ #include #include @@ -63,6 +63,6 @@ typedef struct { netmap_ring_t rx_desc_ring[PKTIO_MAX_QUEUES]; /** mapping of pktout queues to netmap tx descriptors */ netmap_ring_t tx_desc_ring[PKTIO_MAX_QUEUES]; -} pkt_netmap_t; +} pktio_ops_netmap_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 650b3664..b1b735ce 100644 --- a/platform/linux-generic/include/odp_pktio_ops_subsystem.h +++ b/platform/linux-generic/include/odp_pktio_ops_subsystem.h @@ -81,6 +81,7 @@ typedef ODP_MODULE_CLASS(pktio_ops) { /* All implementations of this subsystem */ #include #include +#include /* Per implementation private data * TODO: refactory each implementation to hide it internally @@ -88,6 +89,7 @@ typedef ODP_MODULE_CLASS(pktio_ops) { typedef union { pktio_ops_ipc_data_t ipc; pktio_ops_loopback_data_t loopback; + pktio_ops_netmap_data_t netmap; } pktio_ops_data_t; /* Extract pktio ops data from pktio entry structure */ diff --git a/platform/linux-generic/pktio/netmap.c b/platform/linux-generic/pktio/netmap.c index c75f8be9..accac61c 100644 --- a/platform/linux-generic/pktio/netmap.c +++ b/platform/linux-generic/pktio/netmap.c @@ -12,7 +12,6 @@ #include #include -#include #include #include #include @@ -46,15 +45,16 @@ static int netmap_stats_reset(pktio_entry_t *pktio_entry); static int netmap_do_ioctl(pktio_entry_t *pktio_entry, unsigned long cmd, int subcmd) { - pkt_netmap_t *pkt_nm = &pktio_entry->s.pkt_nm; + pktio_ops_netmap_data_t *pkt_nm = + &pktio_entry->ops_data(netmap); struct ethtool_value eval; struct ifreq ifr; int err; int fd = pkt_nm->sockfd; memset(&ifr, 0, sizeof(ifr)); - snprintf(ifr.ifr_name, sizeof(ifr.ifr_name), "%s", - pktio_entry->s.pkt_nm.if_name); + snprintf(ifr.ifr_name, sizeof(ifr.ifr_name), + "%s", pkt_nm->if_name); switch (cmd) { case SIOCSIFFLAGS: @@ -133,7 +133,8 @@ static inline void map_netmap_rings(netmap_ring_t *rings, static int netmap_input_queues_config(pktio_entry_t *pktio_entry, const odp_pktin_queue_param_t *p) { - pkt_netmap_t *pkt_nm = &pktio_entry->s.pkt_nm; + pktio_ops_netmap_data_t *pkt_nm = + &pktio_entry->ops_data(netmap); odp_pktin_mode_t mode = pktio_entry->s.param.in_mode; unsigned num_queues = p->num_queues; odp_bool_t lockless; @@ -146,8 +147,7 @@ static int netmap_input_queues_config(pktio_entry_t *pktio_entry, lockless = (p->op_mode == ODP_PKTIO_OP_MT_UNSAFE); if (p->hash_enable && num_queues > 1) { - if (rss_conf_set_fd(pktio_entry->s.pkt_nm.sockfd, - pktio_entry->s.pkt_nm.if_name, + if (rss_conf_set_fd(pkt_nm->sockfd, pkt_nm->if_name, &p->hash_proto)) { ODP_ERR("Failed to configure input hash\n"); return -1; @@ -162,7 +162,8 @@ static int netmap_input_queues_config(pktio_entry_t *pktio_entry, static int netmap_output_queues_config(pktio_entry_t *pktio_entry, const odp_pktout_queue_param_t *p) { - pkt_netmap_t *pkt_nm = &pktio_entry->s.pkt_nm; + pktio_ops_netmap_data_t *pkt_nm = + &pktio_entry->ops_data(netmap); pkt_nm->lockless_tx = (p->op_mode == ODP_PKTIO_OP_MT_UNSAFE); @@ -179,7 +180,8 @@ static int netmap_output_queues_config(pktio_entry_t *pktio_entry, static inline void netmap_close_descriptors(pktio_entry_t *pktio_entry) { int i, j; - pkt_netmap_t *pkt_nm = &pktio_entry->s.pkt_nm; + pktio_ops_netmap_data_t *pkt_nm = + &pktio_entry->ops_data(netmap); for (i = 0; i < PKTIO_MAX_QUEUES; i++) { for (j = 0; j < NM_MAX_DESC; j++) { @@ -202,7 +204,8 @@ static inline void netmap_close_descriptors(pktio_entry_t *pktio_entry) static int netmap_close(pktio_entry_t *pktio_entry) { - pkt_netmap_t *pkt_nm = &pktio_entry->s.pkt_nm; + pktio_ops_netmap_data_t *pkt_nm = + &pktio_entry->ops_data(netmap); netmap_close_descriptors(pktio_entry); @@ -216,11 +219,11 @@ static int netmap_close(pktio_entry_t *pktio_entry) static int netmap_link_status(pktio_entry_t *pktio_entry) { - if (pktio_entry->s.pkt_nm.is_virtual) + if (pktio_entry->ops_data(netmap).is_virtual) return 1; - return link_status_fd(pktio_entry->s.pkt_nm.sockfd, - pktio_entry->s.pkt_nm.if_name); + return link_status_fd(pktio_entry->ops_data(netmap).sockfd, + pktio_entry->ops_data(netmap).if_name); } /** @@ -247,12 +250,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->s.pkt_nm.is_virtual) + if (!pktio_entry->ops_data(netmap).is_virtual) sleep(1); if (ret == 1) return 1; } - ODP_DBG("%s link is down\n", pktio_entry->s.pkt_nm.if_name); + ODP_DBG("%s link is down\n", pktio_entry->ops_data(netmap).if_name); return 0; } @@ -263,7 +266,8 @@ static inline int netmap_wait_for_link(pktio_entry_t *pktio_entry) */ static void netmap_init_capability(pktio_entry_t *pktio_entry) { - pkt_netmap_t *pkt_nm = &pktio_entry->s.pkt_nm; + pktio_ops_netmap_data_t *pkt_nm = + &pktio_entry->ops_data(netmap); odp_pktio_capability_t *capa = &pkt_nm->capa; memset(&pkt_nm->capa, 0, sizeof(odp_pktio_capability_t)); @@ -330,7 +334,8 @@ static int netmap_open(odp_pktio_t id ODP_UNUSED, pktio_entry_t *pktio_entry, const char *prefix; uint32_t mtu; uint32_t buf_size; - pkt_netmap_t *pkt_nm = &pktio_entry->s.pkt_nm; + pktio_ops_netmap_data_t *pkt_nm = + &pktio_entry->ops_data(netmap); struct nm_desc *desc; struct netmap_ring *ring; odp_pktin_hash_proto_t hash_proto; @@ -407,7 +412,7 @@ static int netmap_open(odp_pktio_t id ODP_UNUSED, pktio_entry_t *pktio_entry, /* Use either interface MTU (+ ethernet header length) or netmap buffer * size as MTU, whichever is smaller. */ - mtu = mtu_get_fd(pktio_entry->s.pkt_nm.sockfd, pkt_nm->if_name); + mtu = mtu_get_fd(pkt_nm->sockfd, pkt_nm->if_name); if (mtu == 0) { ODP_ERR("Unable to read interface MTU\n"); goto error; @@ -432,7 +437,7 @@ static int netmap_open(odp_pktio_t id ODP_UNUSED, pktio_entry_t *pktio_entry, goto error; /* netmap uses only ethtool to get statistics counters */ - err = ethtool_stats_get_fd(pktio_entry->s.pkt_nm.sockfd, + err = ethtool_stats_get_fd(pkt_nm->sockfd, pkt_nm->if_name, &cur_stats); if (err) { ODP_ERR("netmap pktio %s does not support statistics counters\n", @@ -453,7 +458,8 @@ static int netmap_open(odp_pktio_t id ODP_UNUSED, pktio_entry_t *pktio_entry, static int netmap_start(pktio_entry_t *pktio_entry) { - pkt_netmap_t *pkt_nm = &pktio_entry->s.pkt_nm; + pktio_ops_netmap_data_t *pkt_nm = + &pktio_entry->ops_data(netmap); netmap_ring_t *desc_ring; struct nm_desc *desc_ptr; unsigned i; @@ -610,7 +616,7 @@ static inline int netmap_pkt_to_odp(pktio_entry_t *pktio_entry, odp_time_t *ts) { odp_packet_t pkt; - odp_pool_t pool = pktio_entry->s.pkt_nm.pool; + odp_pool_t pool = pktio_entry->ops_data(netmap).pool; odp_packet_hdr_t *pkt_hdr; odp_packet_hdr_t parsed_hdr; int i; @@ -618,7 +624,7 @@ static inline int netmap_pkt_to_odp(pktio_entry_t *pktio_entry, int alloc_len; /* Allocate maximum sized packets */ - alloc_len = pktio_entry->s.pkt_nm.mtu; + alloc_len = pktio_entry->ops_data(netmap).mtu; num = packet_alloc_multi(pool, alloc_len, pkt_tbl, slot_num); @@ -631,9 +637,10 @@ static inline int netmap_pkt_to_odp(pktio_entry_t *pktio_entry, odp_prefetch(slot.buf); - if (odp_unlikely(len > pktio_entry->s.pkt_nm.max_frame_len)) { + if (odp_unlikely(len > pktio_entry-> + ops_data(netmap).max_frame_len)) { ODP_ERR("RX: frame too big %" PRIu16 " %zu!\n", len, - pktio_entry->s.pkt_nm.max_frame_len); + pktio_entry->ops_data(netmap).max_frame_len); goto fail; } @@ -729,7 +736,8 @@ static int netmap_recv(pktio_entry_t *pktio_entry, int index, odp_packet_t pkt_table[], int num) { struct nm_desc *desc; - pkt_netmap_t *pkt_nm = &pktio_entry->s.pkt_nm; + pktio_ops_netmap_data_t *pkt_nm = + &pktio_entry->ops_data(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; @@ -782,7 +790,8 @@ static int netmap_recv(pktio_entry_t *pktio_entry, int index, static int netmap_send(pktio_entry_t *pktio_entry, int index, const odp_packet_t pkt_table[], int num) { - pkt_netmap_t *pkt_nm = &pktio_entry->s.pkt_nm; + pktio_ops_netmap_data_t *pkt_nm = + &pktio_entry->ops_data(netmap); struct pollfd polld; struct nm_desc *desc; struct netmap_ring *ring; @@ -857,40 +866,42 @@ 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->s.pkt_nm.if_mac, ETH_ALEN); + memcpy(mac_addr, pktio_entry->ops_data(netmap).if_mac, ETH_ALEN); return ETH_ALEN; } static uint32_t netmap_mtu_get(pktio_entry_t *pktio_entry) { - return pktio_entry->s.pkt_nm.mtu; + return pktio_entry->ops_data(netmap).mtu; } static int netmap_promisc_mode_set(pktio_entry_t *pktio_entry, odp_bool_t enable) { - if (pktio_entry->s.pkt_nm.is_virtual) { + if (pktio_entry->ops_data(netmap).is_virtual) { __odp_errno = ENOTSUP; return -1; } - return promisc_mode_set_fd(pktio_entry->s.pkt_nm.sockfd, - pktio_entry->s.pkt_nm.if_name, enable); + return promisc_mode_set_fd( + pktio_entry->ops_data(netmap).sockfd, + pktio_entry->ops_data(netmap).if_name, enable); } static int netmap_promisc_mode_get(pktio_entry_t *pktio_entry) { - if (pktio_entry->s.pkt_nm.is_virtual) + if (pktio_entry->ops_data(netmap).is_virtual) return 0; - return promisc_mode_get_fd(pktio_entry->s.pkt_nm.sockfd, - pktio_entry->s.pkt_nm.if_name); + return promisc_mode_get_fd( + pktio_entry->ops_data(netmap).sockfd, + pktio_entry->ops_data(netmap).if_name); } static int netmap_capability(pktio_entry_t *pktio_entry, odp_pktio_capability_t *capa) { - *capa = pktio_entry->s.pkt_nm.capa; + *capa = pktio_entry->ops_data(netmap).capa; return 0; } @@ -904,7 +915,7 @@ static int netmap_stats(pktio_entry_t *pktio_entry, return sock_stats_fd(pktio_entry, stats, - pktio_entry->s.pkt_nm.sockfd); + pktio_entry->ops_data(netmap).sockfd); } static int netmap_stats_reset(pktio_entry_t *pktio_entry) @@ -916,15 +927,15 @@ static int netmap_stats_reset(pktio_entry_t *pktio_entry) } return sock_stats_reset_fd(pktio_entry, - pktio_entry->s.pkt_nm.sockfd); + pktio_entry->ops_data(netmap).sockfd); } static void netmap_print(pktio_entry_t *pktio_entry) { odp_pktin_hash_proto_t hash_proto; - if (rss_conf_get_fd(pktio_entry->s.pkt_nm.sockfd, - pktio_entry->s.pkt_nm.if_name, &hash_proto)) + if (rss_conf_get_fd(pktio_entry->ops_data(netmap).sockfd, + pktio_entry->ops_data(netmap).if_name, &hash_proto)) rss_conf_print(&hash_proto); } From patchwork Wed Aug 23 06:00:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 110717 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp3678723qge; Tue, 22 Aug 2017 23:08:39 -0700 (PDT) X-Received: by 10.55.177.133 with SMTP id a127mr1941577qkf.303.1503468519473; Tue, 22 Aug 2017 23:08:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503468519; cv=none; d=google.com; s=arc-20160816; b=DJj3xXMN5IfFlRwQTsMpZfXEdGENRNnVsA4nHyeStxAgsGmre4szHAsmlO+pFB+Xvl /L6U+g2K0z+ajtDtK2uqZiLE69z9oYz+YRYOYbR+w8ayQ3allgezHWDWwL06zEfV7oq8 cp49fDNySnhx7vBVGjrZHVF7vdLf6SqwIAxvGcMhQeqw1YwLWE0D2VzLE1t5xLIIrsJF NPc8acw/P3QuSnLC9w5lAf46FOHwa9Ny8rDwEK9gQt8q5n8PL76xx4iM2x2CCIXytUtB b8c7kZv3Rd3ntNIAQDyaxOIiaIuX70qMLbrrt4wpZeIkHgrOZg7/eOHQW/MLBDXD2uo0 jFLQ== 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=EJmvPNdKkvCk9PSG4x5ppQ9Ma1340YGNeMNY8tClqos=; b=X8iQNMs8GY3jAa9lAKng070ZOmTJdmj+hXd/uAWUrnSEbX+QmME0J1UJixFka1VFR6 sI5Ln/ehWp3MyfbblCGvgEAMkqdhLg5K367sJgB4XVKPudg9YAT1ODgJkH5Jt42r2Ywc GRmMPk5N3xxX+paYo6WSNowx3j9QMkZIcUV2y/9hR+q+beOye+wG2aYINR4RLic5d6pK FQjTF+pigMh2w0ZuDqizLPTzVx/tKUffvzACPq75AJO/M66HhpSnORBlpJ9CkZ+FEbkE UvVcN+LHjNRipNxeBbtRylmSPJUc9o7J9KciiO4b1RbFOGlFLkCTSxWM4zti0Lab/Upc KJjA== 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 a23si775981qkc.407.2017.08.22.23.08.39; Tue, 22 Aug 2017 23:08:39 -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 0E75D6447F; Wed, 23 Aug 2017 06:08:39 +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 99FF76088F; Wed, 23 Aug 2017 06:01:01 +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 DBBBF6447F; Wed, 23 Aug 2017 06:00:36 +0000 (UTC) Received: from forward101o.mail.yandex.net (forward101o.mail.yandex.net [37.140.190.181]) by lists.linaro.org (Postfix) with ESMTPS id 8484164494 for ; Wed, 23 Aug 2017 06:00:24 +0000 (UTC) Received: from mxback9g.mail.yandex.net (mxback9g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:170]) by forward101o.mail.yandex.net (Yandex) with ESMTP id 40A4F13427CD for ; Wed, 23 Aug 2017 09:00:23 +0300 (MSK) Received: from smtp3o.mail.yandex.net (smtp3o.mail.yandex.net [2a02:6b8:0:1a2d::27]) by mxback9g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id jOib8VVVxK-0Nb8WIs3; Wed, 23 Aug 2017 09:00:23 +0300 Received: by smtp3o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id QeRkbDFm9Y-0MLWo96e; Wed, 23 Aug 2017 09:00:22 +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: Wed, 23 Aug 2017 09:00:04 +0300 Message-Id: <1503468007-12911-8-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1503468007-12911-1-git-send-email-odpbot@yandex.ru> References: <1503468007-12911-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 139 Subject: [lng-odp] [PATCH CLOUD-DEV v1 7/10] linux-gen: pktio: pcap: 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 Move implementation specific data structure into dedicated header file. Signed-off-by: Yi He --- /** 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: 3cdc8a07993b93b145dc3b4a373b5ebc33bae882 ** Merge commit sha: a87822f157888ef3269a7b8b3f38c63ecc111669 **/ platform/linux-generic/Makefile.am | 1 + .../linux-generic/include/odp_packet_io_internal.h | 18 ------------- .../linux-generic/include/odp_pktio_ops_pcap.h | 25 ++++++++++++++++++ .../include/odp_pktio_ops_subsystem.h | 2 ++ platform/linux-generic/pktio/pcap.c | 30 +++++++++++++--------- 5 files changed, 46 insertions(+), 30 deletions(-) create mode 100644 platform/linux-generic/include/odp_pktio_ops_pcap.h diff --git a/platform/linux-generic/Makefile.am b/platform/linux-generic/Makefile.am index 1db9bbc4..0243be53 100644 --- a/platform/linux-generic/Makefile.am +++ b/platform/linux-generic/Makefile.am @@ -191,6 +191,7 @@ noinst_HEADERS = \ ${srcdir}/include/odp_pktio_ops_ipc.h \ ${srcdir}/include/odp_pktio_ops_loopback.h \ ${srcdir}/include/odp_pktio_ops_netmap.h \ + ${srcdir}/include/odp_pktio_ops_pcap.h \ ${srcdir}/include/odp_pktio_ops_subsystem.h \ ${srcdir}/include/odp_pkt_queue_internal.h \ ${srcdir}/include/odp_pool_internal.h \ diff --git a/platform/linux-generic/include/odp_packet_io_internal.h b/platform/linux-generic/include/odp_packet_io_internal.h index f974abb6..f68c8a84 100644 --- a/platform/linux-generic/include/odp_packet_io_internal.h +++ b/platform/linux-generic/include/odp_packet_io_internal.h @@ -50,21 +50,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) -#ifdef HAVE_PCAP -typedef struct { - char *fname_rx; /**< name of pcap file for rx */ - char *fname_tx; /**< name of pcap file for tx */ - void *rx; /**< rx pcap handle */ - void *tx; /**< tx pcap handle */ - void *tx_dump; /**< tx pcap dumper handle */ - odp_pool_t pool; /**< rx pool */ - unsigned char *buf; /**< per-pktio temp buffer */ - int loops; /**< number of times to loop rx pcap */ - int loop_cnt; /**< number of loops completed */ - odp_bool_t promisc; /**< promiscuous mode state */ -} pkt_pcap_t; -#endif - struct pktio_entry { const pktio_ops_module_t *ops; /**< Implementation specific methods */ pktio_ops_data_t ops_data; /**< IO operation specific data */ @@ -78,9 +63,6 @@ struct pktio_entry { pkt_sock_mmap_t pkt_sock_mmap; /**< using socket mmap * API for IO */ pkt_dpdk_t pkt_dpdk; /**< using DPDK for IO */ -#ifdef HAVE_PCAP - pkt_pcap_t pkt_pcap; /**< Using pcap for IO */ -#endif pkt_tap_t pkt_tap; /**< using TAP for IO */ }; enum { diff --git a/platform/linux-generic/include/odp_pktio_ops_pcap.h b/platform/linux-generic/include/odp_pktio_ops_pcap.h new file mode 100644 index 00000000..6911710c --- /dev/null +++ b/platform/linux-generic/include/odp_pktio_ops_pcap.h @@ -0,0 +1,25 @@ +/* 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_PCAP_H_ +#define ODP_PKTIO_OPS_PCAP_H_ + +typedef struct { + char *fname_rx; /**< name of pcap file for rx */ + char *fname_tx; /**< name of pcap file for tx */ + void *rx; /**< rx pcap handle */ + void *tx; /**< tx pcap handle */ + void *tx_dump; /**< tx pcap dumper handle */ + odp_pool_t pool; /**< rx pool */ + unsigned char *buf; /**< per-pktio temp buffer */ + int loops; /**< number of times to loop rx pcap */ + int loop_cnt; /**< number of loops completed */ + odp_bool_t promisc; /**< promiscuous mode state */ +} pktio_ops_pcap_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 b1b735ce..fc461be7 100644 --- a/platform/linux-generic/include/odp_pktio_ops_subsystem.h +++ b/platform/linux-generic/include/odp_pktio_ops_subsystem.h @@ -82,6 +82,7 @@ typedef ODP_MODULE_CLASS(pktio_ops) { #include #include #include +#include /* Per implementation private data * TODO: refactory each implementation to hide it internally @@ -90,6 +91,7 @@ typedef union { 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_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 98f81089..b54501ed 100644 --- a/platform/linux-generic/pktio/pcap.c +++ b/platform/linux-generic/pktio/pcap.c @@ -51,7 +51,8 @@ static const char pcap_mac[] = {0x02, 0xe9, 0x34, 0x80, 0x73, 0x04}; static int pcapif_stats_reset(pktio_entry_t *pktio_entry); -static int _pcapif_parse_devname(pkt_pcap_t *pcap, const char *devname) +static int _pcapif_parse_devname( + pktio_ops_pcap_data_t *pcap, const char *devname) { char *tok; char in[PKTIO_NAME_LEN]; @@ -80,7 +81,7 @@ static int _pcapif_parse_devname(pkt_pcap_t *pcap, const char *devname) return 0; } -static int _pcapif_init_rx(pkt_pcap_t *pcap) +static int _pcapif_init_rx(pktio_ops_pcap_data_t *pcap) { char errbuf[PCAP_ERRBUF_SIZE]; int linktype; @@ -101,7 +102,7 @@ static int _pcapif_init_rx(pkt_pcap_t *pcap) return 0; } -static int _pcapif_init_tx(pkt_pcap_t *pcap) +static int _pcapif_init_tx(pktio_ops_pcap_data_t *pcap) { pcap_t *tx = pcap->rx; @@ -136,10 +137,11 @@ static int _pcapif_init_tx(pkt_pcap_t *pcap) static int pcapif_init(odp_pktio_t id ODP_UNUSED, pktio_entry_t *pktio_entry, const char *devname, odp_pool_t pool) { - pkt_pcap_t *pcap = &pktio_entry->s.pkt_pcap; + pktio_ops_pcap_data_t *pcap = + &pktio_entry->ops_data(pcap); int ret; - memset(pcap, 0, sizeof(pkt_pcap_t)); + memset(pcap, 0, sizeof(pktio_ops_pcap_data_t)); pcap->loop_cnt = 1; pcap->loops = 1; pcap->pool = pool; @@ -163,7 +165,8 @@ static int pcapif_init(odp_pktio_t id ODP_UNUSED, pktio_entry_t *pktio_entry, static int pcapif_close(pktio_entry_t *pktio_entry) { - pkt_pcap_t *pcap = &pktio_entry->s.pkt_pcap; + pktio_ops_pcap_data_t *pcap = + &pktio_entry->ops_data(pcap); if (pcap->tx_dump) pcap_dump_close(pcap->tx_dump); @@ -181,7 +184,7 @@ static int pcapif_close(pktio_entry_t *pktio_entry) return 0; } -static int _pcapif_reopen(pkt_pcap_t *pcap) +static int _pcapif_reopen(pktio_ops_pcap_data_t *pcap) { char errbuf[PCAP_ERRBUF_SIZE]; @@ -210,7 +213,8 @@ 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; - pkt_pcap_t *pcap = &pktio_entry->s.pkt_pcap; + pktio_ops_pcap_data_t *pcap = + &pktio_entry->ops_data(pcap); odp_time_t ts_val; odp_time_t *ts = NULL; @@ -270,7 +274,7 @@ static int pcapif_recv_pkt(pktio_entry_t *pktio_entry, int index ODP_UNUSED, return i; } -static int _pcapif_dump_pkt(pkt_pcap_t *pcap, odp_packet_t pkt) +static int _pcapif_dump_pkt(pktio_ops_pcap_data_t *pcap, odp_packet_t pkt) { struct pcap_pkthdr hdr; @@ -293,7 +297,8 @@ static int _pcapif_dump_pkt(pkt_pcap_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) { - pkt_pcap_t *pcap = &pktio_entry->s.pkt_pcap; + pktio_ops_pcap_data_t *pcap = + &pktio_entry->ops_data(pcap); int i; odp_ticketlock_lock(&pktio_entry->s.txl); @@ -361,7 +366,8 @@ static int pcapif_promisc_mode_set(pktio_entry_t *pktio_entry, { char filter_exp[64] = {0}; struct bpf_program bpf; - pkt_pcap_t *pcap = &pktio_entry->s.pkt_pcap; + pktio_ops_pcap_data_t *pcap = + &pktio_entry->ops_data(pcap); if (!pcap->rx) { pcap->promisc = enable; @@ -401,7 +407,7 @@ 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->s.pkt_pcap.promisc; + return pktio_entry->ops_data(pcap).promisc; } static int pcapif_stats_reset(pktio_entry_t *pktio_entry) From patchwork Wed Aug 23 06:00:05 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: 110720 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp3681037qge; Tue, 22 Aug 2017 23:10:51 -0700 (PDT) X-Received: by 10.55.160.15 with SMTP id j15mr2270590qke.324.1503468651092; Tue, 22 Aug 2017 23:10:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503468651; cv=none; d=google.com; s=arc-20160816; b=ak1818aXvH1zol17dfuY5/vsrXOxCE0bEeN424SLMSdfV7BqDL/CERH7d3g00ZvqmP j09cLF6Wl5gkLuX/OqL5YDVP0c2U/E/9u/5616pEPS8fleb5eCimj0ksiQgkrZ/UtjMN 5CWK5UdnxTM4FoWfCvpR1JKAaf6YPGxy86bJW25kPwob2+xokyfb9hAZb1X3aJUxUSvg UmeB9do6hnsIOOnX/odEWzlzYDbj+zNK1emRKnx+GTWvLFafUV5gxwRXBiM8zboRyVlI LiUVbcHtKwTXC/Lo45aKvVBK9GhZs159eXCVT8xcaf1/I7JASd9nl9OxAytdOvZIc7W9 cT3Q== 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=0OJwAfVHW/Gf47TzPoFw1sGQMM6NDTvl5QP4g4VwN1A=; b=r/WJun818XPnPBTbKYFBOtuISS9L53nCQKk9nokEhxStBpKKNl4rWxCaKnOWjiCM+P ybQ+2tNKCivUs+c19XgoGKEmdDGS0F6uF3c/URpLwcjkAB96q2rOORjYn1Hx0ynvh5s+ kB5v4M77v711wt8+VMAPxNiGWouwdCklR7uw0LZYwlCfDxzfZplhj0aX9uGtz75j6DyH ZvTpGXUseZCGZoPRueIqv2Oye4Ph+caeWiXM4CxCaNlp0DObZXNInSG21xEJkqp3QnQa EZFYktmXo/lt0dXlhPef0u/LTXtrAoV1RMb3YGDp2hcKhT8ASC02FZlMU/mntB8FFlum 6Hyg== 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 g13si780850qtb.139.2017.08.22.23.10.50; Tue, 22 Aug 2017 23:10: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 A3D2564497; Wed, 23 Aug 2017 06:10: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 3CBD4644CE; Wed, 23 Aug 2017 06:01: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 B61D8644C5; Wed, 23 Aug 2017 06:00:41 +0000 (UTC) Received: from forward103j.mail.yandex.net (forward103j.mail.yandex.net [5.45.198.246]) by lists.linaro.org (Postfix) with ESMTPS id 3FB8A64495 for ; Wed, 23 Aug 2017 06:00:25 +0000 (UTC) Received: from mxback8o.mail.yandex.net (mxback8o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::22]) by forward103j.mail.yandex.net (Yandex) with ESMTP id DA3E234C3F9C for ; Wed, 23 Aug 2017 09:00:23 +0300 (MSK) Received: from smtp3o.mail.yandex.net (smtp3o.mail.yandex.net [2a02:6b8:0:1a2d::27]) by mxback8o.mail.yandex.net (nwsmtp/Yandex) with ESMTP id RfxVUooWb6-0NVmAsZ2; Wed, 23 Aug 2017 09:00:23 +0300 Received: by smtp3o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id QeRkbDFm9Y-0NLODV9W; Wed, 23 Aug 2017 09:00:23 +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: Wed, 23 Aug 2017 09:00:05 +0300 Message-Id: <1503468007-12911-9-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1503468007-12911-1-git-send-email-odpbot@yandex.ru> References: <1503468007-12911-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 139 Subject: [lng-odp] [PATCH CLOUD-DEV v1 8/10] linux-gen: pktio: socket: 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 implementation specific data structure and its dedicated header file to accommodate uniformed name scheme. Signed-off-by: Yi He --- /** 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: 3cdc8a07993b93b145dc3b4a373b5ebc33bae882 ** Merge commit sha: a87822f157888ef3269a7b8b3f38c63ecc111669 **/ platform/linux-generic/Makefile.am | 2 +- .../linux-generic/include/odp_packet_io_internal.h | 4 -- ...{odp_packet_socket.h => odp_pktio_ops_socket.h} | 8 ++-- .../include/odp_pktio_ops_subsystem.h | 3 ++ platform/linux-generic/odp_packet_io.c | 1 - platform/linux-generic/pktio/ethtool.c | 2 +- platform/linux-generic/pktio/netmap.c | 1 - platform/linux-generic/pktio/socket.c | 30 ++++++++------- platform/linux-generic/pktio/socket_mmap.c | 45 ++++++++++++---------- platform/linux-generic/pktio/tap.c | 1 - 10 files changed, 50 insertions(+), 47 deletions(-) rename platform/linux-generic/include/{odp_packet_socket.h => odp_pktio_ops_socket.h} (96%) diff --git a/platform/linux-generic/Makefile.am b/platform/linux-generic/Makefile.am index 0243be53..c8e20ec6 100644 --- a/platform/linux-generic/Makefile.am +++ b/platform/linux-generic/Makefile.am @@ -186,12 +186,12 @@ noinst_HEADERS = \ ${srcdir}/include/odp_packet_io_internal.h \ ${srcdir}/include/odp_packet_io_ring_internal.h \ ${srcdir}/include/odp_packet_dpdk.h \ - ${srcdir}/include/odp_packet_socket.h \ ${srcdir}/include/odp_packet_tap.h \ ${srcdir}/include/odp_pktio_ops_ipc.h \ ${srcdir}/include/odp_pktio_ops_loopback.h \ ${srcdir}/include/odp_pktio_ops_netmap.h \ ${srcdir}/include/odp_pktio_ops_pcap.h \ + ${srcdir}/include/odp_pktio_ops_socket.h \ ${srcdir}/include/odp_pktio_ops_subsystem.h \ ${srcdir}/include/odp_pkt_queue_internal.h \ ${srcdir}/include/odp_pool_internal.h \ diff --git a/platform/linux-generic/include/odp_packet_io_internal.h b/platform/linux-generic/include/odp_packet_io_internal.h index f68c8a84..91100f9e 100644 --- a/platform/linux-generic/include/odp_packet_io_internal.h +++ b/platform/linux-generic/include/odp_packet_io_internal.h @@ -31,7 +31,6 @@ extern "C" { #include #define PKTIO_MAX_QUEUES 64 -#include #include #include @@ -59,9 +58,6 @@ struct pktio_entry { int cls_enabled; /**< is classifier enabled */ odp_pktio_t handle; /**< pktio handle */ union { - pkt_sock_t pkt_sock; /**< using socket API for IO */ - pkt_sock_mmap_t pkt_sock_mmap; /**< using socket mmap - * API for IO */ pkt_dpdk_t pkt_dpdk; /**< using DPDK for IO */ pkt_tap_t pkt_tap; /**< using TAP for IO */ }; diff --git a/platform/linux-generic/include/odp_packet_socket.h b/platform/linux-generic/include/odp_pktio_ops_socket.h similarity index 96% rename from platform/linux-generic/include/odp_packet_socket.h rename to platform/linux-generic/include/odp_pktio_ops_socket.h index 0e61f6f0..32c49c08 100644 --- a/platform/linux-generic/include/odp_packet_socket.h +++ b/platform/linux-generic/include/odp_pktio_ops_socket.h @@ -5,8 +5,8 @@ * SPDX-License-Identifier: BSD-3-Clause */ -#ifndef ODP_PACKET_SOCKET_H -#define ODP_PACKET_SOCKET_H +#ifndef ODP_PKTIO_OPS_SOCKET_H_ +#define ODP_PKTIO_OPS_SOCKET_H_ #include #include @@ -42,7 +42,7 @@ typedef struct { odp_pool_t pool; /**< pool to alloc packets from */ uint32_t mtu; /**< maximum transmission unit */ unsigned char if_mac[ETH_ALEN]; /**< IF eth mac addr */ -} pkt_sock_t; +} pktio_ops_socket_data_t; /** packet mmap ring */ struct ring { @@ -79,7 +79,7 @@ typedef struct { unsigned char if_mac[ETH_ALEN]; struct sockaddr_ll ll; int fanout; -} pkt_sock_mmap_t; +} pktio_ops_socket_mmap_data_t; static inline void ethaddr_copy(unsigned char mac_dst[], unsigned char mac_src[]) diff --git a/platform/linux-generic/include/odp_pktio_ops_subsystem.h b/platform/linux-generic/include/odp_pktio_ops_subsystem.h index fc461be7..952d9be5 100644 --- a/platform/linux-generic/include/odp_pktio_ops_subsystem.h +++ b/platform/linux-generic/include/odp_pktio_ops_subsystem.h @@ -83,6 +83,7 @@ typedef ODP_MODULE_CLASS(pktio_ops) { #include #include #include +#include /* Per implementation private data * TODO: refactory each implementation to hide it internally @@ -92,6 +93,8 @@ typedef union { pktio_ops_loopback_data_t loopback; 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_data_t; /* Extract pktio ops data from pktio entry structure */ diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c index bdcf524c..aa6187d6 100644 --- a/platform/linux-generic/odp_packet_io.c +++ b/platform/linux-generic/odp_packet_io.c @@ -13,7 +13,6 @@ #include #include #include -#include #include #include #include diff --git a/platform/linux-generic/pktio/ethtool.c b/platform/linux-generic/pktio/ethtool.c index d8f9e12c..ed2875c5 100644 --- a/platform/linux-generic/pktio/ethtool.c +++ b/platform/linux-generic/pktio/ethtool.c @@ -13,8 +13,8 @@ #include #include -#include #include +#include static struct ethtool_gstrings *get_stringset(int fd, struct ifreq *ifr) { diff --git a/platform/linux-generic/pktio/netmap.c b/platform/linux-generic/pktio/netmap.c index accac61c..07d6d9e9 100644 --- a/platform/linux-generic/pktio/netmap.c +++ b/platform/linux-generic/pktio/netmap.c @@ -12,7 +12,6 @@ #include #include -#include #include #include diff --git a/platform/linux-generic/pktio/socket.c b/platform/linux-generic/pktio/socket.c index 8b8ccf03..c7c3c5a8 100644 --- a/platform/linux-generic/pktio/socket.c +++ b/platform/linux-generic/pktio/socket.c @@ -33,7 +33,6 @@ #include #include -#include #include #include #include @@ -455,7 +454,9 @@ void rss_conf_print(const odp_pktin_hash_proto_t *hash_proto) */ static int sock_close(pktio_entry_t *pktio_entry) { - pkt_sock_t *pkt_sock = &pktio_entry->s.pkt_sock; + pktio_ops_socket_data_t *pkt_sock = + &pktio_entry->ops_data(socket); + if (pkt_sock->sockfd != -1 && close(pkt_sock->sockfd) != 0) { __odp_errno = errno; ODP_ERR("close(sockfd): %s\n", strerror(errno)); @@ -477,7 +478,8 @@ static int sock_setup_pkt(pktio_entry_t *pktio_entry, const char *netdev, struct ifreq ethreq; struct sockaddr_ll sa_ll; char shm_name[ODP_SHM_NAME_LEN]; - pkt_sock_t *pkt_sock = &pktio_entry->s.pkt_sock; + pktio_ops_socket_data_t *pkt_sock = + &pktio_entry->ops_data(socket); odp_pktio_stats_t cur_stats; /* Init pktio entry */ @@ -530,7 +532,7 @@ static int sock_setup_pkt(pktio_entry_t *pktio_entry, const char *netdev, goto error; } - err = ethtool_stats_get_fd(pktio_entry->s.pkt_sock.sockfd, + err = ethtool_stats_get_fd(pkt_sock->sockfd, pktio_entry->s.name, &cur_stats); if (err != 0) { @@ -601,7 +603,8 @@ static uint32_t _rx_pkt_to_iovec(odp_packet_t pkt, static int sock_mmsg_recv(pktio_entry_t *pktio_entry, int index ODP_UNUSED, odp_packet_t pkt_table[], int len) { - pkt_sock_t *pkt_sock = &pktio_entry->s.pkt_sock; + pktio_ops_socket_data_t *pkt_sock = + &pktio_entry->ops_data(socket); odp_pool_t pool = pkt_sock->pool; odp_time_t ts_val; odp_time_t *ts = NULL; @@ -716,7 +719,8 @@ static uint32_t _tx_pkt_to_iovec(odp_packet_t pkt, static int sock_mmsg_send(pktio_entry_t *pktio_entry, int index ODP_UNUSED, const odp_packet_t pkt_table[], int len) { - pkt_sock_t *pkt_sock = &pktio_entry->s.pkt_sock; + pktio_ops_socket_data_t *pkt_sock = + &pktio_entry->ops_data(socket); struct mmsghdr msgvec[len]; struct iovec iovecs[len][MAX_SEGS]; int ret; @@ -762,7 +766,7 @@ 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->s.pkt_sock.mtu; + return pktio_entry->ops_data(socket).mtu; } /* @@ -771,7 +775,7 @@ 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->s.pkt_sock.if_mac, ETH_ALEN); + memcpy(mac_addr, pktio_entry->ops_data(socket).if_mac, ETH_ALEN); return ETH_ALEN; } @@ -781,7 +785,7 @@ 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->s.pkt_sock.sockfd, + return promisc_mode_set_fd(pktio_entry->ops_data(socket).sockfd, pktio_entry->s.name, enable); } @@ -790,13 +794,13 @@ 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->s.pkt_sock.sockfd, + return promisc_mode_get_fd(pktio_entry->ops_data(socket).sockfd, pktio_entry->s.name); } static int sock_link_status(pktio_entry_t *pktio_entry) { - return link_status_fd(pktio_entry->s.pkt_sock.sockfd, + return link_status_fd(pktio_entry->ops_data(socket).sockfd, pktio_entry->s.name); } @@ -825,7 +829,7 @@ static int sock_stats(pktio_entry_t *pktio_entry, return sock_stats_fd(pktio_entry, stats, - pktio_entry->s.pkt_sock.sockfd); + pktio_entry->ops_data(socket).sockfd); } static int sock_stats_reset(pktio_entry_t *pktio_entry) @@ -837,7 +841,7 @@ static int sock_stats_reset(pktio_entry_t *pktio_entry) } return sock_stats_reset_fd(pktio_entry, - pktio_entry->s.pkt_sock.sockfd); + pktio_entry->ops_data(socket).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 0a27316f..9054a835 100644 --- a/platform/linux-generic/pktio/socket_mmap.c +++ b/platform/linux-generic/pktio/socket_mmap.c @@ -23,7 +23,6 @@ #include #include -#include #include #include #include @@ -37,8 +36,8 @@ static int disable_pktio; /** !0 this pktio disabled, 0 enabled */ -static int set_pkt_sock_fanout_mmap(pkt_sock_mmap_t *const pkt_sock, - int sock_group_idx) +static int set_pkt_sock_fanout_mmap( + pktio_ops_socket_mmap_data_t *const pkt_sock, int sock_group_idx) { int sockfd = pkt_sock->sockfd; int val; @@ -144,7 +143,7 @@ static uint8_t *pkt_mmap_vlan_insert(uint8_t *l2_hdr_ptr, } static inline unsigned pkt_mmap_v2_rx(pktio_entry_t *pktio_entry, - pkt_sock_mmap_t *pkt_sock, + pktio_ops_socket_mmap_data_t *pkt_sock, odp_packet_t pkt_table[], unsigned len, unsigned char if_mac[]) { @@ -411,7 +410,7 @@ static int mmap_setup_ring(int sock, struct ring *ring, int type, return 0; } -static int mmap_sock(pkt_sock_mmap_t *pkt_sock) +static int mmap_sock(pktio_ops_socket_mmap_data_t *pkt_sock) { int i; int sock = pkt_sock->sockfd; @@ -455,14 +454,15 @@ static int mmap_sock(pkt_sock_mmap_t *pkt_sock) return 0; } -static int mmap_unmap_sock(pkt_sock_mmap_t *pkt_sock) +static int mmap_unmap_sock(pktio_ops_socket_mmap_data_t *pkt_sock) { free(pkt_sock->rx_ring.rd); free(pkt_sock->tx_ring.rd); return munmap(pkt_sock->mmap_base, pkt_sock->mmap_len); } -static int mmap_bind_sock(pkt_sock_mmap_t *pkt_sock, const char *netdev) +static int mmap_bind_sock(pktio_ops_socket_mmap_data_t *pkt_sock, + const char *netdev) { int ret; @@ -486,7 +486,8 @@ static int mmap_bind_sock(pkt_sock_mmap_t *pkt_sock, const char *netdev) static int sock_mmap_close(pktio_entry_t *entry) { - pkt_sock_mmap_t *const pkt_sock = &entry->s.pkt_sock_mmap; + pktio_ops_socket_mmap_data_t + *const pkt_sock = &entry->ops_data(mmap); int ret; ret = mmap_unmap_sock(pkt_sock); @@ -515,7 +516,8 @@ static int sock_mmap_open(odp_pktio_t id ODP_UNUSED, if (disable_pktio) return -1; - pkt_sock_mmap_t *const pkt_sock = &pktio_entry->s.pkt_sock_mmap; + pktio_ops_socket_mmap_data_t + *const pkt_sock = &pktio_entry->ops_data(mmap); int fanout = 1; /* Init pktio entry */ @@ -570,7 +572,7 @@ static int sock_mmap_open(odp_pktio_t id ODP_UNUSED, goto error; } - ret = ethtool_stats_get_fd(pktio_entry->s.pkt_sock_mmap.sockfd, + ret = ethtool_stats_get_fd(pkt_sock->sockfd, pktio_entry->s.name, &cur_stats); if (ret != 0) { @@ -586,8 +588,7 @@ static int sock_mmap_open(odp_pktio_t id ODP_UNUSED, pktio_entry->s.stats_type = STATS_ETHTOOL; } - ret = sock_stats_reset_fd(pktio_entry, - pktio_entry->s.pkt_sock_mmap.sockfd); + ret = sock_stats_reset_fd(pktio_entry, pkt_sock->sockfd); if (ret != 0) goto error; @@ -601,7 +602,8 @@ static int sock_mmap_open(odp_pktio_t id ODP_UNUSED, static int sock_mmap_recv(pktio_entry_t *pktio_entry, int index ODP_UNUSED, odp_packet_t pkt_table[], int len) { - pkt_sock_mmap_t *const pkt_sock = &pktio_entry->s.pkt_sock_mmap; + pktio_ops_socket_mmap_data_t + *const pkt_sock = &pktio_entry->ops_data(mmap); int ret; odp_ticketlock_lock(&pktio_entry->s.rxl); @@ -616,7 +618,8 @@ static int sock_mmap_send(pktio_entry_t *pktio_entry, int index ODP_UNUSED, const odp_packet_t pkt_table[], int len) { int ret; - pkt_sock_mmap_t *const pkt_sock = &pktio_entry->s.pkt_sock_mmap; + pktio_ops_socket_mmap_data_t + *const pkt_sock = &pktio_entry->ops_data(mmap); odp_ticketlock_lock(&pktio_entry->s.txl); ret = pkt_mmap_v2_tx(pkt_sock->tx_ring.sock, &pkt_sock->tx_ring, @@ -628,32 +631,32 @@ 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->s.pkt_sock_mmap.sockfd, + return mtu_get_fd(pktio_entry->ops_data(mmap).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->s.pkt_sock_mmap.if_mac, ETH_ALEN); + memcpy(mac_addr, pktio_entry->ops_data(mmap).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->s.pkt_sock_mmap.sockfd, + return promisc_mode_set_fd(pktio_entry->ops_data(mmap).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->s.pkt_sock_mmap.sockfd, + return promisc_mode_get_fd(pktio_entry->ops_data(mmap).sockfd, pktio_entry->s.name); } static int sock_mmap_link_status(pktio_entry_t *pktio_entry) { - return link_status_fd(pktio_entry->s.pkt_sock_mmap.sockfd, + return link_status_fd(pktio_entry->ops_data(mmap).sockfd, pktio_entry->s.name); } @@ -682,7 +685,7 @@ static int sock_mmap_stats(pktio_entry_t *pktio_entry, return sock_stats_fd(pktio_entry, stats, - pktio_entry->s.pkt_sock_mmap.sockfd); + pktio_entry->ops_data(mmap).sockfd); } static int sock_mmap_stats_reset(pktio_entry_t *pktio_entry) @@ -694,7 +697,7 @@ static int sock_mmap_stats_reset(pktio_entry_t *pktio_entry) } return sock_stats_reset_fd(pktio_entry, - pktio_entry->s.pkt_sock_mmap.sockfd); + pktio_entry->ops_data(mmap).sockfd); } static int sock_mmap_init_global(void) diff --git a/platform/linux-generic/pktio/tap.c b/platform/linux-generic/pktio/tap.c index bfe41239..a5c15e11 100644 --- a/platform/linux-generic/pktio/tap.c +++ b/platform/linux-generic/pktio/tap.c @@ -40,7 +40,6 @@ #include #include -#include #include #include #include From patchwork Wed Aug 23 06: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: 110721 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp3682182qge; Tue, 22 Aug 2017 23:12:05 -0700 (PDT) X-Received: by 10.200.24.139 with SMTP id s11mr2051351qtj.122.1503468725543; Tue, 22 Aug 2017 23:12:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503468725; cv=none; d=google.com; s=arc-20160816; b=PQ5GUYThiSrgJnXrVl9Z+riMm/7u+vuZkCCc0XI8Ba0uMrRvg9H7T5PjIrInJC0ukn eFaBHW0dVMdjR/IfffuU4xYHFpT0tGdFkUnAiUNcA7Ppzb8GFuNGudXsl1P0ykp3YXri dBb62Vqu//HFuvuo+q7hQxfjzG1gKI1+6kRg7o+gW4A8GAlOY/oZu4kr5e2paktoM5B6 OfQE0ervuL8i1ZHp5F5ZMtkDRJAXfsmIWVgRC/tCp1ZMOKUlqIjP7ZQlfvcTsENh61Xe NHQxpanHaH3yUiF9qTYIc/89ltjbqdPPTogajSXb03YFjl+qkmzgXUve1+AEIk0agdbJ vN7A== 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=UAIcaFri2zb+rc1kWBFhQr14cKkNidypBMhqDQA+JYY=; b=iWSzNWLRNMyf4baJvr/Za0adeeevay9onXgt9R96RlTc4j7ftg3B4qw4iMwztOxwmL IXaYEOe/W9vZb1x+KtzG0xSJlOEhSxL+PMe7Fn/asr0+yIeS7S81mLoj38qPGymbZqSu YYThcDUNsqmSr+qXU9VZpoLIGEYdud389RXMlmURU7tK2TY9dp4tOllkCKWEwFrJ0oMB xjsrAdAUVihPAnYjk52QiPe/c1/ZeEM42A8bUWm7tzB3QVckILyMRIWEhOEwZk0tDgbF nk0mvJa6YV0LGG4ycdxI0BaOlZ6C8Y3lfxkbgxsGtbT2pJ8/XIKEq1hUSBj3lVtWrcOL NRrg== 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 v6si760785qka.416.2017.08.22.23.12.05; Tue, 22 Aug 2017 23:12:05 -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 284EC6080D; Wed, 23 Aug 2017 06:12:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, 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 80A20644D8; Wed, 23 Aug 2017 06:01:12 +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 3303F644C7; Wed, 23 Aug 2017 06:00:47 +0000 (UTC) Received: from forward106o.mail.yandex.net (forward106o.mail.yandex.net [37.140.190.187]) by lists.linaro.org (Postfix) with ESMTPS id 89E5764497 for ; Wed, 23 Aug 2017 06:00:25 +0000 (UTC) Received: from mxback12j.mail.yandex.net (mxback12j.mail.yandex.net [IPv6:2a02:6b8:0:1619::87]) by forward106o.mail.yandex.net (Yandex) with ESMTP id 7AAB5782C54 for ; Wed, 23 Aug 2017 09:00:24 +0300 (MSK) Received: from smtp3o.mail.yandex.net (smtp3o.mail.yandex.net [2a02:6b8:0:1a2d::27]) by mxback12j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id dKrq9EttfE-0OVG6QJ3; Wed, 23 Aug 2017 09:00:24 +0300 Received: by smtp3o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id QeRkbDFm9Y-0NLaWxwb; Wed, 23 Aug 2017 09:00:23 +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: Wed, 23 Aug 2017 09:00:06 +0300 Message-Id: <1503468007-12911-10-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1503468007-12911-1-git-send-email-odpbot@yandex.ru> References: <1503468007-12911-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 139 Subject: [lng-odp] [PATCH CLOUD-DEV v1 9/10] linux-gen: pktio: tap: 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 implementation specific data structure and its dedicated header file to accommodate uniformed name scheme. Signed-off-by: Yi He --- /** 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: 3cdc8a07993b93b145dc3b4a373b5ebc33bae882 ** Merge commit sha: a87822f157888ef3269a7b8b3f38c63ecc111669 **/ platform/linux-generic/Makefile.am | 2 +- .../linux-generic/include/odp_packet_io_internal.h | 2 -- .../include/odp_pktio_ops_subsystem.h | 2 ++ .../{odp_packet_tap.h => odp_pktio_ops_tap.h} | 6 +++--- platform/linux-generic/pktio/tap.c | 22 +++++++++++----------- 5 files changed, 17 insertions(+), 17 deletions(-) rename platform/linux-generic/include/{odp_packet_tap.h => odp_pktio_ops_tap.h} (85%) diff --git a/platform/linux-generic/Makefile.am b/platform/linux-generic/Makefile.am index c8e20ec6..ab85716f 100644 --- a/platform/linux-generic/Makefile.am +++ b/platform/linux-generic/Makefile.am @@ -186,12 +186,12 @@ noinst_HEADERS = \ ${srcdir}/include/odp_packet_io_internal.h \ ${srcdir}/include/odp_packet_io_ring_internal.h \ ${srcdir}/include/odp_packet_dpdk.h \ - ${srcdir}/include/odp_packet_tap.h \ ${srcdir}/include/odp_pktio_ops_ipc.h \ ${srcdir}/include/odp_pktio_ops_loopback.h \ ${srcdir}/include/odp_pktio_ops_netmap.h \ ${srcdir}/include/odp_pktio_ops_pcap.h \ ${srcdir}/include/odp_pktio_ops_socket.h \ + ${srcdir}/include/odp_pktio_ops_tap.h \ ${srcdir}/include/odp_pktio_ops_subsystem.h \ ${srcdir}/include/odp_pkt_queue_internal.h \ ${srcdir}/include/odp_pool_internal.h \ diff --git a/platform/linux-generic/include/odp_packet_io_internal.h b/platform/linux-generic/include/odp_packet_io_internal.h index 91100f9e..9fe210be 100644 --- a/platform/linux-generic/include/odp_packet_io_internal.h +++ b/platform/linux-generic/include/odp_packet_io_internal.h @@ -31,7 +31,6 @@ extern "C" { #include #define PKTIO_MAX_QUEUES 64 -#include #include /* Forward declaration */ @@ -59,7 +58,6 @@ struct pktio_entry { odp_pktio_t handle; /**< pktio handle */ union { pkt_dpdk_t pkt_dpdk; /**< using DPDK for IO */ - pkt_tap_t pkt_tap; /**< using TAP for IO */ }; enum { /* Not allocated */ diff --git a/platform/linux-generic/include/odp_pktio_ops_subsystem.h b/platform/linux-generic/include/odp_pktio_ops_subsystem.h index 952d9be5..5c01e34f 100644 --- a/platform/linux-generic/include/odp_pktio_ops_subsystem.h +++ b/platform/linux-generic/include/odp_pktio_ops_subsystem.h @@ -84,6 +84,7 @@ typedef ODP_MODULE_CLASS(pktio_ops) { #include #include #include +#include /* Per implementation private data * TODO: refactory each implementation to hide it internally @@ -95,6 +96,7 @@ typedef union { 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; /* Extract pktio ops data from pktio entry structure */ diff --git a/platform/linux-generic/include/odp_packet_tap.h b/platform/linux-generic/include/odp_pktio_ops_tap.h similarity index 85% rename from platform/linux-generic/include/odp_packet_tap.h rename to platform/linux-generic/include/odp_pktio_ops_tap.h index a90bfbce..e8e2e270 100644 --- a/platform/linux-generic/include/odp_packet_tap.h +++ b/platform/linux-generic/include/odp_pktio_ops_tap.h @@ -4,8 +4,8 @@ * SPDX-License-Identifier: BSD-3-Clause */ -#ifndef ODP_PACKET_TAP_H_ -#define ODP_PACKET_TAP_H_ +#ifndef ODP_PACKET_OPS_TAP_H_ +#define ODP_PACKET_OPS_TAP_H_ #include @@ -16,6 +16,6 @@ typedef struct { unsigned char if_mac[ETH_ALEN]; /**< MAC address of pktio side (not a MAC address of kernel interface)*/ odp_pool_t pool; /**< pool to alloc packets from */ -} pkt_tap_t; +} pktio_ops_tap_data_t; #endif diff --git a/platform/linux-generic/pktio/tap.c b/platform/linux-generic/pktio/tap.c index a5c15e11..090e51b6 100644 --- a/platform/linux-generic/pktio/tap.c +++ b/platform/linux-generic/pktio/tap.c @@ -63,7 +63,7 @@ static int tap_pktio_open(odp_pktio_t id ODP_UNUSED, int fd, skfd, flags; uint32_t mtu; struct ifreq ifr; - pkt_tap_t *tap = &pktio_entry->s.pkt_tap; + pktio_ops_tap_data_t *tap = &pktio_entry->ops_data(tap); if (strncmp(devname, "tap:", 4) != 0) return -1; @@ -163,7 +163,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; - pkt_tap_t *tap = &pktio_entry->s.pkt_tap; + pktio_ops_tap_data_t *tap = &pktio_entry->ops_data(tap); if (tap->fd != -1 && close(tap->fd) != 0) { __odp_errno = errno; @@ -190,13 +190,13 @@ 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->s.pkt_tap.pool, + &pktio_entry->ops_data(tap).pool, &parsed_hdr)) { return ODP_PACKET_INVALID; } } - num = packet_alloc_multi(pktio_entry->s.pkt_tap.pool, len, &pkt, 1); + num = packet_alloc_multi(pktio_entry->ops_data(tap).pool, len, &pkt, 1); if (num != 1) return ODP_PACKET_INVALID; @@ -227,7 +227,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]; - pkt_tap_t *tap = &pktio_entry->s.pkt_tap; + pktio_ops_tap_data_t *tap = &pktio_entry->ops_data(tap); odp_time_t ts_val; odp_time_t *ts = NULL; @@ -267,7 +267,7 @@ static int tap_pktio_send_lockless(pktio_entry_t *pktio_entry, int i, n; uint32_t pkt_len; uint8_t buf[BUF_SIZE]; - pkt_tap_t *tap = &pktio_entry->s.pkt_tap; + pktio_ops_tap_data_t *tap = &pktio_entry->ops_data(tap); for (i = 0; i < len; i++) { pkt_len = odp_packet_len(pkts[i]); @@ -330,10 +330,10 @@ static uint32_t tap_mtu_get(pktio_entry_t *pktio_entry) { uint32_t ret; - ret = mtu_get_fd(pktio_entry->s.pkt_tap.skfd, + ret = mtu_get_fd(pktio_entry->ops_data(tap).skfd, pktio_entry->s.name + 4); if (ret > 0) - pktio_entry->s.pkt_tap.mtu = ret; + pktio_entry->ops_data(tap).mtu = ret; return ret; } @@ -341,19 +341,19 @@ 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->s.pkt_tap.skfd, + return promisc_mode_set_fd(pktio_entry->ops_data(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->s.pkt_tap.skfd, + return promisc_mode_get_fd(pktio_entry->ops_data(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->s.pkt_tap.if_mac, ETH_ALEN); + memcpy(mac_addr, pktio_entry->ops_data(tap).if_mac, ETH_ALEN); return ETH_ALEN; } From patchwork Wed Aug 23 06: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: 110722 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp3683613qge; Tue, 22 Aug 2017 23:13:37 -0700 (PDT) X-Received: by 10.200.28.82 with SMTP id j18mr322962qtk.300.1503468817300; Tue, 22 Aug 2017 23:13:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503468817; cv=none; d=google.com; s=arc-20160816; b=rHNRc2KMZkygMTz0bx4xWfyyOR0h6HA28pTxEwJqZBxA/82HRXaLWEdRnR2JLpaUf/ 9tYgoYfbb91jYIiwP0ftBCdz94y6xXH6uET41PFpPaDKZIqzpy0uVXUyJvktfht9oByI yn1xeq9dIUyGtAphvwdKMozgGUiX0dQwMFNDCQjVvwLFgbtct4daO+rSdKp6aoiDF8zs 0L3kO19704D9QOPpQ/LLHPLihByiHOT/Ky2yyyItpugrNP8SqmNwowsJbgn4mr2MRcH6 NgzWluay5mmYHuhuPyWGfOhdisurWXac2J5HW6jj8kBffmOUkplamt0KuOfhMH6Jp2MN iBOw== 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=B0GaZDVVTlnSRq1u4Jpae2479rjEUpvBMRpoeDJj9tM=; b=FrHDh4H/YK2N3MTdbws3aZdExRv+tY/9MY1sS8029DEiEKhc1KunlEqF//Lo3nGy0K p4T/3+P/a3LeDdi/LJL2F0OTUJSWDN/NZx3OByvqkiHEiJNdw+Q4dDl0vvCsAj4gxvTf SS4d8Y9qNHBC1cUkouPZLwa+/B6pEQZcqoITXE54hxG8O2FH3HMTZrpCsMYGq7qipUkg NTqqIUGcXYqhpGtBWivSt7HmZKpc2/rtFhQHYwsUgdVpAqRjH8SQDTTwqBO7Ktj5Y4k/ h8KLUNxh2Tj4pNNEjjq0t4rxz/NCrQMy7qW3dZDoQwJTexcLs/3yyZ1ALqh6I9kowvOq KaEA== 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 l32si763764qte.461.2017.08.22.23.13.36; Tue, 22 Aug 2017 23:13:37 -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 A4F34644E7; Wed, 23 Aug 2017 06:13:36 +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, 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 F26B6644E3; Wed, 23 Aug 2017 06: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 49081644D3; Wed, 23 Aug 2017 06:00:51 +0000 (UTC) Received: from forward106p.mail.yandex.net (forward106p.mail.yandex.net [77.88.28.109]) by lists.linaro.org (Postfix) with ESMTPS id DB22D6449A for ; Wed, 23 Aug 2017 06:00:26 +0000 (UTC) Received: from mxback14g.mail.yandex.net (mxback14g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:93]) by forward106p.mail.yandex.net (Yandex) with ESMTP id 5F2442D82012 for ; Wed, 23 Aug 2017 09:00:25 +0300 (MSK) Received: from smtp3o.mail.yandex.net (smtp3o.mail.yandex.net [2a02:6b8:0:1a2d::27]) by mxback14g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id d78xKIaPxt-0PBqOvbj; Wed, 23 Aug 2017 09:00:25 +0300 Received: by smtp3o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id QeRkbDFm9Y-0OLKnR6x; Wed, 23 Aug 2017 09:00:24 +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: Wed, 23 Aug 2017 09:00:07 +0300 Message-Id: <1503468007-12911-11-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1503468007-12911-1-git-send-email-odpbot@yandex.ru> References: <1503468007-12911-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 139 Subject: [lng-odp] [PATCH CLOUD-DEV v1 10/10] linux-gen: pktio: dpdk: 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 implementation specific data structure and move its dedicated header file to impl local, decouple it from pktio_entry_t data structure. Signed-off-by: Yi He Signed-off-by: Balakrishna Garapati --- /** 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: 3cdc8a07993b93b145dc3b4a373b5ebc33bae882 ** Merge commit sha: a87822f157888ef3269a7b8b3f38c63ecc111669 **/ platform/linux-generic/Makefile.am | 4 +- .../linux-generic/include/odp_packet_io_internal.h | 5 -- .../include/odp_pktio_ops_subsystem.h | 1 + .../pktio/{pktio_common.c => common.c} | 0 platform/linux-generic/pktio/dpdk.c | 94 +++++++++++++++------- .../{include/odp_packet_dpdk.h => pktio/dpdk.h} | 6 +- 6 files changed, 71 insertions(+), 39 deletions(-) rename platform/linux-generic/pktio/{pktio_common.c => common.c} (100%) rename platform/linux-generic/{include/odp_packet_dpdk.h => pktio/dpdk.h} (96%) diff --git a/platform/linux-generic/Makefile.am b/platform/linux-generic/Makefile.am index ab85716f..a2223805 100644 --- a/platform/linux-generic/Makefile.am +++ b/platform/linux-generic/Makefile.am @@ -185,7 +185,7 @@ noinst_HEADERS = \ ${srcdir}/include/odp_packet_internal.h \ ${srcdir}/include/odp_packet_io_internal.h \ ${srcdir}/include/odp_packet_io_ring_internal.h \ - ${srcdir}/include/odp_packet_dpdk.h \ + ${srcdir}/pktio/dpdk.h \ ${srcdir}/include/odp_pktio_ops_ipc.h \ ${srcdir}/include/odp_pktio_ops_loopback.h \ ${srcdir}/include/odp_pktio_ops_netmap.h \ @@ -264,7 +264,7 @@ __LIB__libodp_linux_la_SOURCES = \ pktio/ethtool.c \ pktio/subsystem.c \ pktio/ipc.c \ - pktio/pktio_common.c \ + pktio/common.c \ pktio/loopback.c \ pktio/netmap.c \ pktio/dpdk.c \ diff --git a/platform/linux-generic/include/odp_packet_io_internal.h b/platform/linux-generic/include/odp_packet_io_internal.h index 9fe210be..7359b586 100644 --- a/platform/linux-generic/include/odp_packet_io_internal.h +++ b/platform/linux-generic/include/odp_packet_io_internal.h @@ -31,8 +31,6 @@ extern "C" { #include #define PKTIO_MAX_QUEUES 64 -#include - /* Forward declaration */ typedef union pktio_entry_u pktio_entry_t; #include @@ -56,9 +54,6 @@ struct pktio_entry { odp_ticketlock_t txl; /**< TX ticketlock */ int cls_enabled; /**< is classifier enabled */ odp_pktio_t handle; /**< pktio handle */ - union { - pkt_dpdk_t pkt_dpdk; /**< using DPDK for IO */ - }; enum { /* Not allocated */ PKTIO_STATE_FREE = 0, diff --git a/platform/linux-generic/include/odp_pktio_ops_subsystem.h b/platform/linux-generic/include/odp_pktio_ops_subsystem.h index 5c01e34f..7a915b82 100644 --- a/platform/linux-generic/include/odp_pktio_ops_subsystem.h +++ b/platform/linux-generic/include/odp_pktio_ops_subsystem.h @@ -90,6 +90,7 @@ typedef ODP_MODULE_CLASS(pktio_ops) { * TODO: refactory each implementation to hide it internally */ typedef union { + void *dpdk; pktio_ops_ipc_data_t ipc; pktio_ops_loopback_data_t loopback; pktio_ops_netmap_data_t netmap; diff --git a/platform/linux-generic/pktio/pktio_common.c b/platform/linux-generic/pktio/common.c similarity index 100% rename from platform/linux-generic/pktio/pktio_common.c rename to platform/linux-generic/pktio/common.c diff --git a/platform/linux-generic/pktio/dpdk.c b/platform/linux-generic/pktio/dpdk.c index e72a7637..511c7778 100644 --- a/platform/linux-generic/pktio/dpdk.c +++ b/platform/linux-generic/pktio/dpdk.c @@ -20,9 +20,9 @@ #include #include -#include #include +#include #include #include @@ -32,6 +32,18 @@ #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!"); @@ -310,10 +322,10 @@ 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 = pktio_entry->s.pkt_dpdk.pool; + odp_pool_t pool = __retrieve_op_data(pktio_entry)->pool; /* Allocate maximum sized packets */ - alloc_len = pktio_entry->s.pkt_dpdk.data_room; + alloc_len = __retrieve_op_data(pktio_entry)->data_room; num = packet_alloc_multi(pool, alloc_len, pkt_table, mbuf_num); if (num != mbuf_num) { @@ -385,7 +397,8 @@ static inline int pkt_to_mbuf(pktio_entry_t *pktio_entry, struct rte_mbuf *mbuf_table[], const odp_packet_t pkt_table[], uint16_t num) { - pkt_dpdk_t *pkt_dpdk = &pktio_entry->s.pkt_dpdk; + pktio_ops_dpdk_data_t *pkt_dpdk = + __retrieve_op_data(pktio_entry); int i, j; char *data; uint16_t pkt_len; @@ -430,7 +443,7 @@ static inline int mbuf_to_pkt_zero(pktio_entry_t *pktio_entry, void *data; int i; int nb_pkts = 0; - odp_pool_t pool = pktio_entry->s.pkt_dpdk.pool; + odp_pool_t pool = __retrieve_op_data(pktio_entry)->pool; for (i = 0; i < mbuf_num; i++) { odp_packet_hdr_t parsed_hdr; @@ -487,7 +500,8 @@ static inline int pkt_to_mbuf_zero(pktio_entry_t *pktio_entry, const odp_packet_t pkt_table[], uint16_t num, uint16_t *seg_count) { - pkt_dpdk_t *pkt_dpdk = &pktio_entry->s.pkt_dpdk; + pktio_ops_dpdk_data_t *pkt_dpdk = + __retrieve_op_data(pktio_entry); int i; *seg_count = 0; @@ -562,7 +576,8 @@ static uint32_t dpdk_vdev_mtu_get(uint8_t port_id) static uint32_t dpdk_mtu_get(pktio_entry_t *pktio_entry) { - pkt_dpdk_t *pkt_dpdk = &pktio_entry->s.pkt_dpdk; + pktio_ops_dpdk_data_t *pkt_dpdk = + __retrieve_op_data(pktio_entry); uint32_t mtu = 0; if (rte_eth_dev_get_mtu(pkt_dpdk->port_id, (uint16_t *)&mtu)) @@ -655,7 +670,8 @@ static void rss_conf_to_hash_proto(struct rte_eth_rss_conf *rss_conf, static int dpdk_setup_port(pktio_entry_t *pktio_entry) { int ret; - pkt_dpdk_t *pkt_dpdk = &pktio_entry->s.pkt_dpdk; + pktio_ops_dpdk_data_t *pkt_dpdk = + __retrieve_op_data(pktio_entry); struct rte_eth_rss_conf rss_conf; /* Always set some hash functions to enable DPDK RSS hash calculation */ @@ -697,7 +713,8 @@ static int dpdk_setup_port(pktio_entry_t *pktio_entry) static int dpdk_close(pktio_entry_t *pktio_entry) { - pkt_dpdk_t *pkt_dpdk = &pktio_entry->s.pkt_dpdk; + pktio_ops_dpdk_data_t *pkt_dpdk = + __retrieve_op_data(pktio_entry); unsigned idx; unsigned i, j; @@ -715,6 +732,7 @@ 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; } @@ -860,9 +878,9 @@ static int dpdk_input_queues_config(pktio_entry_t *pktio_entry, lockless = 0; if (p->hash_enable && p->num_queues > 1) - pktio_entry->s.pkt_dpdk.hash = p->hash_proto; + __retrieve_op_data(pktio_entry)->hash = p->hash_proto; - pktio_entry->s.pkt_dpdk.lockless_rx = lockless; + __retrieve_op_data(pktio_entry)->lockless_rx = lockless; return 0; } @@ -870,7 +888,8 @@ static int dpdk_input_queues_config(pktio_entry_t *pktio_entry, static int dpdk_output_queues_config(pktio_entry_t *pktio_entry, const odp_pktout_queue_param_t *p) { - pkt_dpdk_t *pkt_dpdk = &pktio_entry->s.pkt_dpdk; + pktio_ops_dpdk_data_t *pkt_dpdk = + __retrieve_op_data(pktio_entry); odp_bool_t lockless; if (p->op_mode == ODP_PKTIO_OP_MT_UNSAFE) @@ -886,7 +905,8 @@ static int dpdk_output_queues_config(pktio_entry_t *pktio_entry, static void dpdk_init_capability(pktio_entry_t *pktio_entry, struct rte_eth_dev_info *dev_info) { - pkt_dpdk_t *pkt_dpdk = &pktio_entry->s.pkt_dpdk; + pktio_ops_dpdk_data_t *pkt_dpdk = + __retrieve_op_data(pktio_entry); odp_pktio_capability_t *capa = &pkt_dpdk->capa; memset(dev_info, 0, sizeof(struct rte_eth_dev_info)); @@ -909,7 +929,7 @@ static int dpdk_open(odp_pktio_t id ODP_UNUSED, const char *netdev, odp_pool_t pool) { - pkt_dpdk_t *pkt_dpdk = &pktio_entry->s.pkt_dpdk; + pktio_ops_dpdk_data_t *pkt_dpdk = NULL; struct rte_eth_dev_info dev_info; struct rte_mempool *pkt_pool; char pool_name[RTE_MEMPOOL_NAMESIZE]; @@ -937,6 +957,14 @@ 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; + } + /* Init pktio entry */ memset(pkt_dpdk, 0, sizeof(*pkt_dpdk)); @@ -945,6 +973,7 @@ 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; } @@ -953,6 +982,7 @@ 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; @@ -989,6 +1019,7 @@ 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; } @@ -1013,7 +1044,8 @@ static int dpdk_open(odp_pktio_t id ODP_UNUSED, static int dpdk_start(pktio_entry_t *pktio_entry) { - pkt_dpdk_t *pkt_dpdk = &pktio_entry->s.pkt_dpdk; + pktio_ops_dpdk_data_t *pkt_dpdk = + __retrieve_op_data(pktio_entry); uint8_t port_id = pkt_dpdk->port_id; int ret; unsigned i; @@ -1064,7 +1096,7 @@ static int dpdk_start(pktio_entry_t *pktio_entry) static int dpdk_stop(pktio_entry_t *pktio_entry) { - rte_eth_dev_stop(pktio_entry->s.pkt_dpdk.port_id); + rte_eth_dev_stop(__retrieve_op_data(pktio_entry)->port_id); return 0; } @@ -1072,7 +1104,8 @@ static int dpdk_stop(pktio_entry_t *pktio_entry) static int dpdk_recv(pktio_entry_t *pktio_entry, int index, odp_packet_t pkt_table[], int num) { - pkt_dpdk_t *pkt_dpdk = &pktio_entry->s.pkt_dpdk; + pktio_ops_dpdk_data_t *pkt_dpdk = + __retrieve_op_data(pktio_entry); pkt_cache_t *rx_cache = &pkt_dpdk->rx_cache[index]; odp_time_t ts_val; odp_time_t *ts = NULL; @@ -1104,7 +1137,7 @@ static int dpdk_recv(pktio_entry_t *pktio_entry, int index, } else if ((unsigned)num < pkt_dpdk->min_rx_burst) { struct rte_mbuf *new_mbufs[pkt_dpdk->min_rx_burst]; - nb_rx = rte_eth_rx_burst(pktio_entry->s.pkt_dpdk.port_id, index, + nb_rx = rte_eth_rx_burst(pkt_dpdk->port_id, index, new_mbufs, pkt_dpdk->min_rx_burst); rx_cache->s.idx = 0; for (i = 0; i < nb_rx; i++) { @@ -1119,7 +1152,7 @@ static int dpdk_recv(pktio_entry_t *pktio_entry, int index, nb_rx = RTE_MIN(num, nb_rx); } else { - nb_rx = rte_eth_rx_burst(pktio_entry->s.pkt_dpdk.port_id, index, + nb_rx = rte_eth_rx_burst(pkt_dpdk->port_id, index, rx_mbufs, num); } @@ -1147,7 +1180,8 @@ static int dpdk_send(pktio_entry_t *pktio_entry, int index, const odp_packet_t pkt_table[], int num) { struct rte_mbuf *tx_mbufs[num]; - pkt_dpdk_t *pkt_dpdk = &pktio_entry->s.pkt_dpdk; + pktio_ops_dpdk_data_t *pkt_dpdk = + __retrieve_op_data(pktio_entry); uint16_t seg_count = 0; int tx_pkts; int i; @@ -1210,16 +1244,16 @@ 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(pktio_entry->s.pkt_dpdk.port_id, + rte_eth_macaddr_get(__retrieve_op_data(pktio_entry)->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 = pktio_entry->s.pkt_dpdk.port_id; + uint8_t port_id = __retrieve_op_data(pktio_entry)->port_id; - if (pktio_entry->s.pkt_dpdk.vdev_sysc_promisc) + if (__retrieve_op_data(pktio_entry)->vdev_sysc_promisc) return dpdk_vdev_promisc_mode_set(port_id, enable); if (enable) @@ -1232,9 +1266,9 @@ 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 = pktio_entry->s.pkt_dpdk.port_id; + uint8_t port_id = __retrieve_op_data(pktio_entry)->port_id; - if (pktio_entry->s.pkt_dpdk.vdev_sysc_promisc) + if (__retrieve_op_data(pktio_entry)->vdev_sysc_promisc) return dpdk_vdev_promisc_mode_get(port_id); else return rte_eth_promiscuous_get(port_id); @@ -1243,7 +1277,7 @@ 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 = pktio_entry->s.pkt_dpdk.capa; + *capa = __retrieve_op_data(pktio_entry)->capa; return 0; } @@ -1253,7 +1287,8 @@ static int dpdk_link_status(pktio_entry_t *pktio_entry) memset(&link, 0, sizeof(struct rte_eth_link)); - rte_eth_link_get_nowait(pktio_entry->s.pkt_dpdk.port_id, &link); + rte_eth_link_get_nowait( + __retrieve_op_data(pktio_entry)->port_id, &link); return link.link_status; } @@ -1275,7 +1310,8 @@ static int dpdk_stats(pktio_entry_t *pktio_entry, odp_pktio_stats_t *stats) int ret; struct rte_eth_stats rte_stats; - ret = rte_eth_stats_get(pktio_entry->s.pkt_dpdk.port_id, &rte_stats); + ret = rte_eth_stats_get( + __retrieve_op_data(pktio_entry)->port_id, &rte_stats); if (ret == 0) { stats_convert(&rte_stats, stats); @@ -1286,7 +1322,7 @@ 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(pktio_entry->s.pkt_dpdk.port_id); + rte_eth_stats_reset(__retrieve_op_data(pktio_entry)->port_id); return 0; } diff --git a/platform/linux-generic/include/odp_packet_dpdk.h b/platform/linux-generic/pktio/dpdk.h similarity index 96% rename from platform/linux-generic/include/odp_packet_dpdk.h rename to platform/linux-generic/pktio/dpdk.h index 5d80d84a..7495b596 100644 --- a/platform/linux-generic/include/odp_packet_dpdk.h +++ b/platform/linux-generic/pktio/dpdk.h @@ -4,8 +4,8 @@ * SPDX-License-Identifier: BSD-3-Clause */ -#ifndef ODP_PACKET_DPDK_H -#define ODP_PACKET_DPDK_H +#ifndef ODP_PKTIO_OPS_DPDK_H_ +#define ODP_PKTIO_OPS_DPDK_H_ #include #include @@ -63,6 +63,6 @@ typedef struct { odp_ticketlock_t tx_lock[PKTIO_MAX_QUEUES]; /**< TX queue locks */ /** cache for storing extra RX packets */ pkt_cache_t rx_cache[PKTIO_MAX_QUEUES]; -} pkt_dpdk_t; +} pktio_ops_dpdk_data_t; #endif