From patchwork Thu Jul 14 19:10:32 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 72049 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp231911qga; Thu, 14 Jul 2016 12:10:54 -0700 (PDT) X-Received: by 10.36.137.3 with SMTP id s3mr29614674itd.93.1468523453730; Thu, 14 Jul 2016 12:10:53 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id q14si17174930itb.21.2016.07.14.12.10.53; Thu, 14 Jul 2016 12:10:53 -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 4013461763; Thu, 14 Jul 2016 19:10:53 +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 DDF0061772; Thu, 14 Jul 2016 19:10:45 +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 1539B61875; Thu, 14 Jul 2016 19:10:43 +0000 (UTC) Received: from mail-lf0-f42.google.com (mail-lf0-f42.google.com [209.85.215.42]) by lists.linaro.org (Postfix) with ESMTPS id 534FF61763 for ; Thu, 14 Jul 2016 19:10:41 +0000 (UTC) Received: by mail-lf0-f42.google.com with SMTP id f93so71608908lfi.2 for ; Thu, 14 Jul 2016 12:10:41 -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=36WEfdcCN4lsbTX/aNVnb65qaSOxuHfOjTyoAsUy/Rg=; b=DRsY9ilpOyvkD4Nc4YvApR1DTdjPFTKQNUXCZB/eZkUMrorDDSWkabp8fbqODGQZb6 EJxi4YqHcIrfIbm2VGcFz7fJpvW45yH5G4mjXiILcD5Wig9eSo8nKb+Z9VAPtPT0D1Gs LTQOD8CN0/T78L2abHndm3WJRpewZNQKQtV0asTruk615RP9YAftrEhK+eYLX07nzA7o 1MDMQA4ZfZq2/OwzTeylPuS7GPDWFVvzQLuRMMJDrdsKMLfI21kOkIEKfpvSSymt1cAr HkQPtKA4gj4t0jIecnBNYb1nvDDrYjaUKCjc14fVufSo407hOVP572CwfUWqk6AUfUDD t4WA== X-Gm-Message-State: ALyK8tK6X4zFkdZpj6MKqPwDg0UlU82tjvTMCCunHhAYYwmtbHBdPRAvZK4eqXTdfNpf9Bd6L+s= X-Received: by 10.25.17.70 with SMTP id g67mr7644181lfi.145.1468523439782; Thu, 14 Jul 2016 12:10:39 -0700 (PDT) Received: from localhost.localdomain ([83.220.236.107]) by smtp.gmail.com with ESMTPSA id 4sm1112405ljf.9.2016.07.14.12.10.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 14 Jul 2016 12:10:38 -0700 (PDT) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Thu, 14 Jul 2016 22:10:32 +0300 Message-Id: <1468523432-21150-1-git-send-email-maxim.uvarov@linaro.org> X-Mailer: git-send-email 2.7.1.250.gff4ea60 X-Topics: patch Subject: [lng-odp] [PATCHv2] 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 --- v2: - for netmap did not add pktio_init_global to functions struct; (retested, netmap works fine.) - corrected dpdk prints (were messsages about packet mmap). Needed to test this patch with dpdk pktio. 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..351790e 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: socket mmap skipped," + " enabled export ODP_PKTIO_DISABLE_NETMAP=1.\n"); + disable_pktio = 1; + } else { + ODP_PRINT("PKTIO: initialized socket mmap," + " use export ODP_PKTIO_DISABLE_NETMAP=1 to disable.\n" + " Netmap refixes 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 ); }