From patchwork Fri Jul 15 14:59:19 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 72113 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp669250qga; Fri, 15 Jul 2016 07:59:37 -0700 (PDT) X-Received: by 10.107.192.134 with SMTP id q128mr21673372iof.5.1468594777364; Fri, 15 Jul 2016 07:59:37 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id j1si2906983ioo.191.2016.07.15.07.59.36; Fri, 15 Jul 2016 07:59: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=pass (p=NONE dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 8F34468707; Fri, 15 Jul 2016 14:59: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=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 66FD0686D2; Fri, 15 Jul 2016 14:59:29 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id A47A1686D3; Fri, 15 Jul 2016 14:59:26 +0000 (UTC) Received: from mail-lf0-f53.google.com (mail-lf0-f53.google.com [209.85.215.53]) by lists.linaro.org (Postfix) with ESMTPS id 1A5C6686D1 for ; Fri, 15 Jul 2016 14:59:25 +0000 (UTC) Received: by mail-lf0-f53.google.com with SMTP id y184so790495lfd.3 for ; Fri, 15 Jul 2016 07:59:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=bP9AieDQqu7hjrnptTC5g7UwezdQCKDNk/ulrD7VJM4=; b=YpdNzPMs5CLOkOqVB00KaJ4nECPt6ihQfBDO5a/mfBIXuUeHauebVE6Pr/pMcFOSu5 oycfeKXYAXkASRbMmMvJH0BqYuN/lbGVxDhYkV+NInBjP2j8zxeUJ0n306Wd4D0vBhPX ZLvu8LUVav05i3gKzt8IQs4vDw1E9kAjVYJGyQmcVdlMVr41F7/cw4/VxwFOsGJNyhhS yK4QWhTfZs2VOMtV0jdGnWk1/adp4o5l0+MSRuZtbwo+AVONa+9d0usdYzcoPdt0rQpJ 9R/FbhAaNUrndxlFfaSwYY+s/BT+aW+zqqhZi7rkq8v1L90i8FoCYSu7XAGWITmcdn6t N5yg== X-Gm-Message-State: ALyK8tIhzgmX07odYDFCslIae1y75TE3Wik7B52FHVAf7H+azNyBhlZ2BPd8AxxWkI9NtZeagX4= X-Received: by 10.25.153.203 with SMTP id b194mr1582617lfe.185.1468594763661; Fri, 15 Jul 2016 07:59:23 -0700 (PDT) Received: from maxim-Aspire-VN7-791.d-systems.local ([185.75.190.112]) by smtp.gmail.com with ESMTPSA id q36sm2011113lfi.26.2016.07.15.07.59.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 15 Jul 2016 07:59:22 -0700 (PDT) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Fri, 15 Jul 2016 17:59:19 +0300 Message-Id: <1468594759-25108-1-git-send-email-maxim.uvarov@linaro.org> X-Mailer: git-send-email 2.7.1.250.gff4ea60 X-Topics: patch Subject: [lng-odp] [PATCHv3] example: remove reference from linux-generic internal envs 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" Make print for example more platform independent and move prints about pktio states in platform initialization code. Signed-off-by: Maxim Uvarov Reviewed-by: Bill Fischofer --- v3: typo did not append changes in print netmap to v2. (mmsg in netmap print has to be netmap). tested all available pktios (dpdk, netmap, socket, pcap with make check). example/generator/odp_generator.c | 4 ---- example/ipsec/odp_ipsec.c | 6 +----- example/packet/odp_pktio.c | 4 ---- example/switch/odp_switch.c | 5 ----- platform/linux-generic/pktio/dpdk.c | 20 +++++++++++++++----- platform/linux-generic/pktio/ipc.c | 1 + platform/linux-generic/pktio/loop.c | 8 +++++++- platform/linux-generic/pktio/netmap.c | 20 ++++++++++++++++++-- platform/linux-generic/pktio/pcap.c | 8 +++++++- platform/linux-generic/pktio/socket.c | 19 +++++++++++++++++-- platform/linux-generic/pktio/socket_mmap.c | 19 +++++++++++++++++-- test/performance/odp_l2fwd.c | 4 ---- 12 files changed, 83 insertions(+), 35 deletions(-) -- 2.7.1.250.gff4ea60 diff --git a/example/generator/odp_generator.c b/example/generator/odp_generator.c index 3fea112..b0053b9 100644 --- a/example/generator/odp_generator.c +++ b/example/generator/odp_generator.c @@ -1157,10 +1157,6 @@ static void usage(char *progname) "\n" "Optional OPTIONS\n" " -h, --help Display help and exit.\n" - " environment variables: ODP_PKTIO_DISABLE_NETMAP\n" - " ODP_PKTIO_DISABLE_SOCKET_MMAP\n" - " ODP_PKTIO_DISABLE_SOCKET_MMSG\n" - " can be used to advanced pkt I/O selection for odp-linux\n" " -p, --packetsize payload length of the packets\n" " -t, --timeout only for ping mode, wait ICMP reply timeout seconds\n" " -i, --interval wait interval ms between sending each packet\n" diff --git a/example/ipsec/odp_ipsec.c b/example/ipsec/odp_ipsec.c index d8ca791..6a9a9fe 100644 --- a/example/ipsec/odp_ipsec.c +++ b/example/ipsec/odp_ipsec.c @@ -1587,11 +1587,7 @@ static void usage(char *progname) "Optional OPTIONS\n" " -c, --count CPU count.\n" " -h, --help Display help and exit.\n" - " environment variables: ODP_PKTIO_DISABLE_NETMAP\n" - " ODP_PKTIO_DISABLE_SOCKET_MMAP\n" - " ODP_PKTIO_DISABLE_SOCKET_MMSG\n" - " can be used to advanced pkt I/O selection for odp-linux\n" - " ODP_IPSEC_USE_POLL_QUEUES\n" + " environment variables: ODP_IPSEC_USE_POLL_QUEUES\n" " to enable use of poll queues instead of scheduled (default)\n" " ODP_IPSEC_STREAM_VERIFY_MDEQ\n" " to enable use of multiple dequeue for queue draining during\n" diff --git a/example/packet/odp_pktio.c b/example/packet/odp_pktio.c index 6e14abb..d1135cb 100644 --- a/example/packet/odp_pktio.c +++ b/example/packet/odp_pktio.c @@ -732,10 +732,6 @@ static void usage(char *progname) " 1: Receive and send via queues.\n" " 2: Receive via scheduler, send via queues.\n" " -h, --help Display help and exit.\n" - " environment variables: ODP_PKTIO_DISABLE_NETMAP\n" - " ODP_PKTIO_DISABLE_SOCKET_MMAP\n" - " ODP_PKTIO_DISABLE_SOCKET_MMSG\n" - " can be used to advanced pkt I/O selection for odp-linux\n" "\n", NO_PATH(progname), NO_PATH(progname) ); } diff --git a/example/switch/odp_switch.c b/example/switch/odp_switch.c index 5ce71a9..c48a202 100644 --- a/example/switch/odp_switch.c +++ b/example/switch/odp_switch.c @@ -727,11 +727,6 @@ static void usage(char *progname) " -a, --accuracy Statistics print interval in seconds\n" " (default is 10 second).\n" " -h, --help Display help and exit.\n\n" - " environment variables: ODP_PKTIO_DISABLE_DPDK\n" - " ODP_PKTIO_DISABLE_NETMAP\n" - " ODP_PKTIO_DISABLE_SOCKET_MMAP\n" - " ODP_PKTIO_DISABLE_SOCKET_MMSG\n" - " can be used to advanced pkt I/O selection for odp-linux\n" "\n", NO_PATH(progname), NO_PATH(progname), MAX_PKTIOS ); } diff --git a/platform/linux-generic/pktio/dpdk.c b/platform/linux-generic/pktio/dpdk.c index c21c703..a5934a5 100644 --- a/platform/linux-generic/pktio/dpdk.c +++ b/platform/linux-generic/pktio/dpdk.c @@ -26,6 +26,8 @@ #include #include +static int disable_pktio; /** !0 this pktio disabled, 0 enabled */ + /* Has dpdk_pktio_init() been called */ static odp_bool_t dpdk_initialized; @@ -453,12 +455,20 @@ static int dpdk_pktio_init(void) } /* Placeholder for DPDK global init */ -static int odp_dpdk_pktio_init_global(void) +static int dpdk_pktio_init_global(void) { + if (getenv("ODP_PKTIO_DISABLE_DPDK")) { + ODP_PRINT("PKTIO: dpdk pktio skipped," + " enabled export ODP_PKTIO_DISABLE_DPDK=1.\n"); + disable_pktio = 1; + } else { + ODP_PRINT("PKTIO: initialized dpdk pktio," + " use export ODP_PKTIO_DISABLE_DPDK=1 to disable.\n"); + } return 0; } -static int odp_dpdk_pktio_init_local(void) +static int dpdk_pktio_init_local(void) { int cpu; @@ -546,7 +556,7 @@ static int dpdk_open(odp_pktio_t id ODP_UNUSED, uint32_t mtu; int i; - if (getenv("ODP_PKTIO_DISABLE_DPDK")) + if (disable_pktio) return -1; if (pool == ODP_POOL_INVALID) @@ -993,8 +1003,8 @@ static int dpdk_stats_reset(pktio_entry_t *pktio_entry) const pktio_if_ops_t dpdk_pktio_ops = { .name = "dpdk", - .init_global = odp_dpdk_pktio_init_global, - .init_local = odp_dpdk_pktio_init_local, + .init_global = dpdk_pktio_init_global, + .init_local = dpdk_pktio_init_local, .term = NULL, .open = dpdk_open, .close = dpdk_close, diff --git a/platform/linux-generic/pktio/ipc.c b/platform/linux-generic/pktio/ipc.c index e0d4ab9..f9e7a00 100644 --- a/platform/linux-generic/pktio/ipc.c +++ b/platform/linux-generic/pktio/ipc.c @@ -775,6 +775,7 @@ static int ipc_close(pktio_entry_t *pktio_entry) static int ipc_pktio_init_global(void) { _ring_tailq_init(); + ODP_PRINT("PKTIO: initialized ipc interface.\n"); return 0; } diff --git a/platform/linux-generic/pktio/loop.c b/platform/linux-generic/pktio/loop.c index ac16c41..21d7542 100644 --- a/platform/linux-generic/pktio/loop.c +++ b/platform/linux-generic/pktio/loop.c @@ -243,10 +243,16 @@ static int loopback_stats_reset(pktio_entry_t *pktio_entry ODP_UNUSED) return 0; } +static int loop_init_global(void) +{ + ODP_PRINT("PKTIO: initialized loop interface.\n"); + return 0; +} + const pktio_if_ops_t loopback_pktio_ops = { .name = "loop", .print = NULL, - .init_global = NULL, + .init_global = loop_init_global, .init_local = NULL, .term = NULL, .open = loopback_open, diff --git a/platform/linux-generic/pktio/netmap.c b/platform/linux-generic/pktio/netmap.c index d69df6b..3017e40 100644 --- a/platform/linux-generic/pktio/netmap.c +++ b/platform/linux-generic/pktio/netmap.c @@ -37,6 +37,7 @@ #define NM_WAIT_TIMEOUT 10 /* netmap_wait_for_link() timeout in seconds */ #define NM_INJECT_RETRIES 10 +static int disable_pktio; /** !0 this pktio disabled, 0 enabled */ static int netmap_stats_reset(pktio_entry_t *pktio_entry); static int netmap_do_ioctl(pktio_entry_t *pktio_entry, unsigned long cmd, @@ -332,7 +333,7 @@ static int netmap_open(odp_pktio_t id ODP_UNUSED, pktio_entry_t *pktio_entry, odp_pktin_hash_proto_t hash_proto; odp_pktio_stats_t cur_stats; - if (getenv("ODP_PKTIO_DISABLE_NETMAP")) + if (disable_pktio) return -1; if (pool == ODP_POOL_INVALID) @@ -891,10 +892,25 @@ static void netmap_print(pktio_entry_t *pktio_entry) rss_conf_print(&hash_proto); } +static int netmap_init_global(void) +{ + if (getenv("ODP_PKTIO_DISABLE_NETMAP")) { + ODP_PRINT("PKTIO: netmap pktio skipped," + " enabled export ODP_PKTIO_DISABLE_NETMAP=1.\n"); + disable_pktio = 1; + } else { + ODP_PRINT("PKTIO: initialized netmap pktio," + " use export ODP_PKTIO_DISABLE_NETMAP=1 to disable.\n" + " Netmap prefixes are netmap:eth0 or vale:eth0. Refer to" + " Netmap documentation for usage information.\n"); + } + return 0; +} + const pktio_if_ops_t netmap_pktio_ops = { .name = "netmap", .print = netmap_print, - .init_global = NULL, + .init_global = netmap_init_global, .init_local = NULL, .term = NULL, .open = netmap_open, diff --git a/platform/linux-generic/pktio/pcap.c b/platform/linux-generic/pktio/pcap.c index be9049a..e501858 100644 --- a/platform/linux-generic/pktio/pcap.c +++ b/platform/linux-generic/pktio/pcap.c @@ -430,10 +430,16 @@ static int pcapif_stats(pktio_entry_t *pktio_entry, return 0; } +static int pcapif_init_global(void) +{ + ODP_PRINT("PKTIO: initialized pcap interface.\n"); + return 0; +} + const pktio_if_ops_t pcap_pktio_ops = { .name = "pcap", .print = NULL, - .init_global = NULL, + .init_global = pcapif_init_global, .init_local = NULL, .open = pcapif_init, .close = pcapif_close, diff --git a/platform/linux-generic/pktio/socket.c b/platform/linux-generic/pktio/socket.c index 5d85ef5..0309b0d 100644 --- a/platform/linux-generic/pktio/socket.c +++ b/platform/linux-generic/pktio/socket.c @@ -46,6 +46,8 @@ #include #include +static int disable_pktio; /** !0 this pktio disabled, 0 enabled */ + static int sock_stats_reset(pktio_entry_t *pktio_entry); /** Provide a sendmmsg wrapper for systems with no libc or kernel support. @@ -571,7 +573,7 @@ static int sock_mmsg_open(odp_pktio_t id ODP_UNUSED, pktio_entry_t *pktio_entry, const char *devname, odp_pool_t pool) { - if (getenv("ODP_PKTIO_DISABLE_SOCKET_MMSG")) + if (disable_pktio) return -1; return sock_setup_pkt(pktio_entry, devname, pool); } @@ -894,10 +896,23 @@ static int sock_stats_reset(pktio_entry_t *pktio_entry) pktio_entry->s.pkt_sock.sockfd); } +static int sock_init_global(void) +{ + if (getenv("ODP_PKTIO_DISABLE_SOCKET_MMSG")) { + ODP_PRINT("PKTIO: socket mmsg skipped," + " enabled export ODP_PKTIO_DISABLE_SOCKET_MMSG=1.\n"); + disable_pktio = 1; + } else { + ODP_PRINT("PKTIO: initialized socket mmsg," + "use export ODP_PKTIO_DISABLE_SOCKET_MMSG=1 to disable.\n"); + } + return 0; +} + const pktio_if_ops_t sock_mmsg_pktio_ops = { .name = "socket", .print = NULL, - .init_global = NULL, + .init_global = sock_init_global, .init_local = NULL, .term = NULL, .open = sock_mmsg_open, diff --git a/platform/linux-generic/pktio/socket_mmap.c b/platform/linux-generic/pktio/socket_mmap.c index 11bb7d6..b6be81a 100644 --- a/platform/linux-generic/pktio/socket_mmap.c +++ b/platform/linux-generic/pktio/socket_mmap.c @@ -35,6 +35,8 @@ #include #include +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) { @@ -503,7 +505,7 @@ static int sock_mmap_open(odp_pktio_t id ODP_UNUSED, int ret = 0; odp_pktio_stats_t cur_stats; - if (getenv("ODP_PKTIO_DISABLE_SOCKET_MMAP")) + if (disable_pktio) return -1; pkt_sock_mmap_t *const pkt_sock = &pktio_entry->s.pkt_sock_mmap; @@ -688,10 +690,23 @@ static int sock_mmap_stats_reset(pktio_entry_t *pktio_entry) pktio_entry->s.pkt_sock_mmap.sockfd); } +static int sock_mmap_init_global(void) +{ + if (getenv("ODP_PKTIO_DISABLE_SOCKET_MMAP")) { + ODP_PRINT("PKTIO: socket mmap skipped," + " enabled export ODP_PKTIO_DISABLE_SOCKET_MMAP=1.\n"); + disable_pktio = 1; + } else { + ODP_PRINT("PKTIO: initialized socket mmap," + " use export ODP_PKTIO_DISABLE_SOCKET_MMAP=1 to disable.\n"); + } + return 0; +} + const pktio_if_ops_t sock_mmap_pktio_ops = { .name = "socket_mmap", .print = NULL, - .init_global = NULL, + .init_global = sock_mmap_init_global, .init_local = NULL, .term = NULL, .open = sock_mmap_open, diff --git a/test/performance/odp_l2fwd.c b/test/performance/odp_l2fwd.c index e296b94..f4947ca 100644 --- a/test/performance/odp_l2fwd.c +++ b/test/performance/odp_l2fwd.c @@ -1032,10 +1032,6 @@ static void usage(char *progname) " -e, --error_check 0: Don't check packet errors (default)\n" " 1: Check packet errors\n" " -h, --help Display help and exit.\n\n" - " environment variables: ODP_PKTIO_DISABLE_NETMAP\n" - " ODP_PKTIO_DISABLE_SOCKET_MMAP\n" - " ODP_PKTIO_DISABLE_SOCKET_MMSG\n" - " can be used to advanced pkt I/O selection for odp-linux\n" "\n", NO_PATH(progname), NO_PATH(progname), MAX_PKTIOS ); }