Message ID | 1468594759-25108-1-git-send-email-maxim.uvarov@linaro.org |
---|---|
State | Accepted |
Commit | 22721beb44a03491c6df66f8c218ed2d66692fa1 |
Headers | show |
merged, Maxim. On 07/15/16 17:59, Maxim Uvarov wrote: > Make print for example more platform independent and move > prints about pktio states in platform initialization code. > > Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org> > Reviewed-by: Bill Fischofer <bill.fischofer@linaro.org> > --- > 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(-) > > 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 <number> 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 <number> 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 <rte_ethdev.h> > #include <rte_string_fns.h> > > +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 <protocols/eth.h> > #include <protocols/ip.h> > > +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 <protocols/eth.h> > #include <protocols/ip.h> > > +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 > ); > }
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 <number> 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 <number> 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 <rte_ethdev.h> #include <rte_string_fns.h> +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 <protocols/eth.h> #include <protocols/ip.h> +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 <protocols/eth.h> #include <protocols/ip.h> +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 ); }