[RFC,v3,3/3] examples: add lcore topology API calls
Checks
Commit Message
Enhance example code to allow topology based lcores API, while
retaining default behaviour.
- helloworld: allow lcoes to send hello to lcores in selected topology.
- l2fwd: allow use of IO lcores topology.
- skeleton: choose the lcore from IO topology which has more ports.
v3 changes:
- fix typo from SE_NO_TOPOLOGY to USE_NO_TOPOLOGY
Signed-off-by: Vipin Varghese <vipin.varghese@amd.com>
---
examples/helloworld/main.c | 142 ++++++++++++++++++++++++++++++++++-
examples/l2fwd/main.c | 56 ++++++++++++--
examples/skeleton/basicfwd.c | 22 ++++++
3 files changed, 210 insertions(+), 10 deletions(-)
Comments
> Enhance example code to allow topology based lcores API, while
> retaining default behaviour.
>
> - helloworld: allow lcoes to send hello to lcores in selected topology.
> - l2fwd: allow use of IO lcores topology.
> - skeleton: choose the lcore from IO topology which has more ports.
>
> v3 changes:
> - fix typo from SE_NO_TOPOLOGY to USE_NO_TOPOLOGY
>
> Signed-off-by: Vipin Varghese <vipin.varghese@amd.com>
> ---
I see compilation failure on ARM platforms due to missing header include.
../examples/helloworld/main.c: In function 'parse_topology':
../examples/helloworld/main.c:83:13: error: implicit declaration of function 'strtoul'; did you mean 'strtok'? [-Wimplicit-function-declaration]
83 | n = strtoul(q_arg, &end, 10);
| ^~~~~~~
| strtok
../examples/helloworld/main.c:83:13: warning: nested extern declaration of 'strtoul' [-Wnested-externs]
../examples/helloworld/main.c: In function 'helloworld_parse_args':
../examples/helloworld/main.c:115:42: error: 'EXIT_FAILURE' undeclared (first use in this function)
115 | rte_exit(EXIT_FAILURE, "Invalid Topology selection\n");
| ^~~~~~~~~~~~
../examples/helloworld/main.c:13:1: note: 'EXIT_FAILURE' is defined in header '<stdlib.h>'; this is probably fixable by adding '#include <stdlib.h>'
12 | #include <rte_memory.h>
+++ |+#include <stdlib.h>
13 | #include <rte_launch.h>
../examples/helloworld/main.c:115:42: note: each undeclared identifier is reported only once for each function it appears in
115 | rte_exit(EXIT_FAILURE, "Invalid Topology selection\n");
| ^~~~~~~~~~~~
../examples/helloworld/main.c: In function 'main':
../examples/helloworld/main.c:153:26: error: 'EXIT_FAILURE' undeclared (first use in this function)
153 | rte_exit(EXIT_FAILURE, "Invalid arguments\n");
| ^~~~~~~~~~~~
../examples/helloworld/main.c:153:26: note: 'EXIT_FAILURE' is defined in header '<stdlib.h>'; thi
Below header include should fix it.
diff --git a/examples/helloworld/main.c b/examples/helloworld/main.c
index 9845c3775c3a..f49bd0108f74 100644
--- a/examples/helloworld/main.c
+++ b/examples/helloworld/main.c
@@ -3,6 +3,7 @@
*/
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <errno.h>
Hi Pavan,
Snipped
>
> I see compilation failure on ARM platforms due to missing header include.
>
> ../examples/helloworld/main.c: In function 'parse_topology':
> ../examples/helloworld/main.c:83:13: error: implicit declaration of function 'strtoul';
> did you mean 'strtok'? [-Wimplicit-function-declaration]
> 83 | n = strtoul(q_arg, &end, 10);
> | ^~~~~~~
> | strtok
> ../examples/helloworld/main.c:83:13: warning: nested extern declaration of 'strtoul' [-
> Wnested-externs]
> ../examples/helloworld/main.c: In function 'helloworld_parse_args':
> ../examples/helloworld/main.c:115:42: error: 'EXIT_FAILURE' undeclared (first use
> in this function)
> 115 | rte_exit(EXIT_FAILURE, "Invalid Topology selection\n");
> | ^~~~~~~~~~~~
> ../examples/helloworld/main.c:13:1: note: 'EXIT_FAILURE' is defined in header
> '<stdlib.h>'; this is probably fixable by adding '#include <stdlib.h>'
> 12 | #include <rte_memory.h>
> +++ |+#include <stdlib.h>
> 13 | #include <rte_launch.h>
> ../examples/helloworld/main.c:115:42: note: each undeclared identifier is reported
> only once for each function it appears in
> 115 | rte_exit(EXIT_FAILURE, "Invalid Topology selection\n");
> | ^~~~~~~~~~~~
> ../examples/helloworld/main.c: In function 'main':
> ../examples/helloworld/main.c:153:26: error: 'EXIT_FAILURE' undeclared (first use
> in this function)
> 153 | rte_exit(EXIT_FAILURE, "Invalid arguments\n");
> | ^~~~~~~~~~~~
> ../examples/helloworld/main.c:153:26: note: 'EXIT_FAILURE' is defined in header
> '<stdlib.h>'; thi
>
> Below header include should fix it.
>
> diff --git a/examples/helloworld/main.c b/examples/helloworld/main.c index
> 9845c3775c3a..f49bd0108f74 100644
> --- a/examples/helloworld/main.c
> +++ b/examples/helloworld/main.c
> @@ -3,6 +3,7 @@
> */
>
> #include <stdio.h>
> +#include <stdlib.h>
> #include <string.h>
> #include <stdint.h>
> #include <errno.h>
Thank you for helping me here, I did run with `check_includes & developer_mode`, it did not throw this error.
Before patch submission I tried `devtools/test-meson-builds.sh` too. I think internally this is not using ` check_includes & developer_mode `.
Let me recheck and fix this in version 4.
> Hi Pavan,
>
> Snipped
>
> >
> > I see compilation failure on ARM platforms due to missing header include.
> >
> > ../examples/helloworld/main.c: In function 'parse_topology':
> > ../examples/helloworld/main.c:83:13: error: implicit declaration of
> > function 'strtoul'; did you mean 'strtok'? [-Wimplicit-function-declaration]
> > 83 | n = strtoul(q_arg, &end, 10);
> > | ^~~~~~~
> > | strtok
> > ../examples/helloworld/main.c:83:13: warning: nested extern
> > declaration of 'strtoul' [- Wnested-externs]
> > ../examples/helloworld/main.c: In function 'helloworld_parse_args':
> > ../examples/helloworld/main.c:115:42: error: 'EXIT_FAILURE' undeclared
> > (first use in this function)
> > 115 | rte_exit(EXIT_FAILURE, "Invalid Topology
> selection\n");
> > | ^~~~~~~~~~~~
> > ../examples/helloworld/main.c:13:1: note: 'EXIT_FAILURE' is defined in
> > header '<stdlib.h>'; this is probably fixable by adding '#include <stdlib.h>'
> > 12 | #include <rte_memory.h>
> > +++ |+#include <stdlib.h>
> > 13 | #include <rte_launch.h>
> > ../examples/helloworld/main.c:115:42: note: each undeclared identifier
> > is reported only once for each function it appears in
> > 115 | rte_exit(EXIT_FAILURE, "Invalid Topology
> selection\n");
> > | ^~~~~~~~~~~~
> > ../examples/helloworld/main.c: In function 'main':
> > ../examples/helloworld/main.c:153:26: error: 'EXIT_FAILURE' undeclared
> > (first use in this function)
> > 153 | rte_exit(EXIT_FAILURE, "Invalid arguments\n");
> > | ^~~~~~~~~~~~
> > ../examples/helloworld/main.c:153:26: note: 'EXIT_FAILURE' is defined
> > in header '<stdlib.h>'; thi
> >
> > Below header include should fix it.
> >
> > diff --git a/examples/helloworld/main.c b/examples/helloworld/main.c
> > index
> > 9845c3775c3a..f49bd0108f74 100644
> > --- a/examples/helloworld/main.c
> > +++ b/examples/helloworld/main.c
> > @@ -3,6 +3,7 @@
> > */
> >
> > #include <stdio.h>
> > +#include <stdlib.h>
> > #include <string.h>
> > #include <stdint.h>
> > #include <errno.h>
>
> Thank you for helping me here, I did run with `check_includes & developer_mode`,
> it did not throw this error.
> Before patch submission I tried `devtools/test-meson-builds.sh` too. I think internally
> this is not using ` check_includes & developer_mode `.
> Let me recheck and fix this in version 4.
Thank you, I found the reason for my miss on this.
When build using cross compiler manually, no issues with the steps
```
meson arm64-build --cross-file config/arm/arm64_armv8_linux_gcc
ninja -C arm64-build
cd example/helloworld
make
```
But building using cross compiler with examples manually, no issues with the steps
```
meson arm64-build --cross-file config/arm/arm64_armv8_linux_gcc -Dexamples=helloworld
ninja -C arm64-build
```
We get the logs as
```
../examples/helloworld/main.c: In function 'parse_topology':
../examples/helloworld/main.c:83:13: warning: implicit declaration of function 'strtoul'; did you mean 'strtok'? [-Wimplicit-function-declaration]
83 | n = strtoul(q_arg, &end, 10);
| ^~~~~~~
| strtok
../examples/helloworld/main.c:83:13: warning: nested extern declaration of 'strtoul' [-Wnested-externs]
../examples/helloworld/main.c: In function 'helloworld_parse_args':
../examples/helloworld/main.c:115:42: error: 'EXIT_FAILURE' undeclared (first use in this function)
115 | rte_exit(EXIT_FAILURE, "Invalid Topology selection\n");
| ^~~~~~~~~~~~
../examples/helloworld/main.c:13:1: note: 'EXIT_FAILURE' is defined in header '<stdlib.h>'; did you forget to '#include <stdlib.h>'?
12 | #include <rte_memory.h>
+++ |+#include <stdlib.h>
13 | #include <rte_launch.h>
../examples/helloworld/main.c:115:42: note: each undeclared identifier is reported only once for each function it appears in
115 | rte_exit(EXIT_FAILURE, "Invalid Topology selection\n");
| ^~~~~~~~~~~~
../examples/helloworld/main.c: In function 'main':
../examples/helloworld/main.c:153:26: error: 'EXIT_FAILURE' undeclared (first use in this function)
153 | rte_exit(EXIT_FAILURE, "Invalid arguments\n");
| ^~~~~~~~~~~~
../examples/helloworld/main.c:153:26: note: 'EXIT_FAILURE' is defined in header '<stdlib.h>'; did you forget to '#include <stdlib.h>'?
[2963/4590] Compiling C object drivers/libtmp_rte_event_cnxk.a.p/event_cnxk_tx_cn10k_tx_112_127_seg.c.o
ninja: build stopped: subcommand failed.
```
> > Hi Pavan,
> >
> > Snipped
> >
> > >
> > > I see compilation failure on ARM platforms due to missing header include.
> > >
> > > ../examples/helloworld/main.c: In function 'parse_topology':
> > > ../examples/helloworld/main.c:83:13: error: implicit declaration of
> > > function 'strtoul'; did you mean 'strtok'? [-Wimplicit-function-declaration]
> > > 83 | n = strtoul(q_arg, &end, 10);
> > > | ^~~~~~~
> > > | strtok
> > > ../examples/helloworld/main.c:83:13: warning: nested extern
> > > declaration of 'strtoul' [- Wnested-externs]
> > > ../examples/helloworld/main.c: In function 'helloworld_parse_args':
> > > ../examples/helloworld/main.c:115:42: error: 'EXIT_FAILURE' undeclared
> > > (first use in this function)
> > > 115 | rte_exit(EXIT_FAILURE, "Invalid Topology
> > selection\n");
> > > | ^~~~~~~~~~~~
> > > ../examples/helloworld/main.c:13:1: note: 'EXIT_FAILURE' is defined in
> > > header '<stdlib.h>'; this is probably fixable by adding '#include <stdlib.h>'
> > > 12 | #include <rte_memory.h>
> > > +++ |+#include <stdlib.h>
> > > 13 | #include <rte_launch.h>
> > > ../examples/helloworld/main.c:115:42: note: each undeclared identifier
> > > is reported only once for each function it appears in
> > > 115 | rte_exit(EXIT_FAILURE, "Invalid Topology
> > selection\n");
> > > | ^~~~~~~~~~~~
> > > ../examples/helloworld/main.c: In function 'main':
> > > ../examples/helloworld/main.c:153:26: error: 'EXIT_FAILURE' undeclared
> > > (first use in this function)
> > > 153 | rte_exit(EXIT_FAILURE, "Invalid arguments\n");
> > > | ^~~~~~~~~~~~
> > > ../examples/helloworld/main.c:153:26: note: 'EXIT_FAILURE' is defined
> > > in header '<stdlib.h>'; thi
> > >
> > > Below header include should fix it.
> > >
> > > diff --git a/examples/helloworld/main.c b/examples/helloworld/main.c
> > > index
> > > 9845c3775c3a..f49bd0108f74 100644
> > > --- a/examples/helloworld/main.c
> > > +++ b/examples/helloworld/main.c
> > > @@ -3,6 +3,7 @@
> > > */
> > >
> > > #include <stdio.h>
> > > +#include <stdlib.h>
> > > #include <string.h>
> > > #include <stdint.h>
> > > #include <errno.h>
> >
> > Thank you for helping me here, I did run with `check_includes &
> developer_mode`,
> > it did not throw this error.
> > Before patch submission I tried `devtools/test-meson-builds.sh` too. I think
> internally
> > this is not using ` check_includes & developer_mode `.
> > Let me recheck and fix this in version 4.
>
> Thank you, I found the reason for my miss on this.
>
> When build using cross compiler manually, no issues with the steps
> ```
> meson arm64-build --cross-file config/arm/arm64_armv8_linux_gcc
> ninja -C arm64-build
> cd example/helloworld
> make
> ```
>
> But building using cross compiler with examples manually, no issues with the
> steps
> ```
> meson arm64-build --cross-file config/arm/arm64_armv8_linux_gcc -
> Dexamples=helloworld
> ninja -C arm64-build
> ```
>
I generally run ./devtools/test-meson-builds.sh as a catch all 😊
@@ -7,6 +7,7 @@
#include <stdint.h>
#include <errno.h>
#include <sys/queue.h>
+#include <getopt.h>
#include <rte_memory.h>
#include <rte_launch.h>
@@ -14,6 +15,14 @@
#include <rte_per_lcore.h>
#include <rte_lcore.h>
#include <rte_debug.h>
+#include <rte_log.h>
+
+#define RTE_LOGTYPE_HELLOWORLD RTE_LOGTYPE_USER1
+#define USE_NO_TOPOLOGY 0xffff
+
+static uint16_t topo_sel = USE_NO_TOPOLOGY;
+/* lcore selector based on Topology */
+static const char short_options[] = "T:";
/* Launch a function on lcore. 8< */
static int
@@ -21,11 +30,109 @@ lcore_hello(__rte_unused void *arg)
{
unsigned lcore_id;
lcore_id = rte_lcore_id();
+
printf("hello from core %u\n", lcore_id);
return 0;
}
+
+static int
+send_lcore_hello(__rte_unused void *arg)
+{
+ unsigned int lcore_id;
+ uint16_t send_lcore_id;
+ uint16_t send_count = 0;
+
+ lcore_id = rte_lcore_id();
+
+ send_lcore_id = rte_get_next_lcore_from_domain(lcore_id, false, true, topo_sel);
+
+ while ((send_lcore_id != RTE_MAX_LCORE) && (lcore_id != send_lcore_id)) {
+ printf("hello from core %u to core %u\n", lcore_id, send_lcore_id);
+ send_lcore_id = rte_get_next_lcore_from_domain(send_lcore_id,
+ false, true, topo_sel);
+ send_count += 1;
+ }
+
+ if (send_count == 0)
+ RTE_LOG(INFO, HELLOWORLD, "for lcoe %u; no lcores in same domain!!!\n", lcore_id);
+
+ return 0;
+}
/* >8 End of launching function on lcore. */
+/* display usage. 8< */
+static void
+helloworld_usage(const char *prgname)
+{
+ printf("%s [EAL options] -- [-T TOPO]\n"
+ " -T TOPO: choose topology to send hello to\n"
+ " - 0: send cores sharing L1 (SMT)\n"
+ " - 1: send cores sharing L2\n"
+ " - 2: send cores sharing L3\n"
+ " - 3: send cores sharing IO\n\n",
+ prgname);
+}
+
+static unsigned int
+parse_topology(const char *q_arg)
+{
+ char *end = NULL;
+ unsigned long n;
+
+ /* parse the topology option */
+ n = strtoul(q_arg, &end, 10);
+
+ if ((q_arg[0] == '\0') || (end == NULL) || (*end != '\0'))
+ return 0;
+
+ if (n > 3)
+ return USE_NO_TOPOLOGY;
+
+ n = (n == 0) ? RTE_LCORE_DOMAIN_L1 :
+ (n == 1) ? RTE_LCORE_DOMAIN_L2 :
+ (n == 2) ? RTE_LCORE_DOMAIN_L3 :
+ RTE_LCORE_DOMAIN_IO;
+
+ return n;
+}
+
+/* Parse the argument given in the command line of the application */
+static int
+helloworld_parse_args(int argc, char **argv)
+{
+ int opt, ret;
+ char **argvopt = argv;
+ int option_index;
+ char *prgname = argv[0];
+ while ((opt = getopt_long(argc, argvopt, short_options,
+ NULL, &option_index)) != EOF) {
+ switch (opt) {
+ /* Topology selection */
+ case 'T':
+ topo_sel = parse_topology(optarg);
+ if (topo_sel == USE_NO_TOPOLOGY) {
+ helloworld_usage(prgname);
+ rte_exit(EXIT_FAILURE, "Invalid Topology selection\n");
+ }
+
+ RTE_LOG(DEBUG, HELLOWORLD, "USR selects (%s) domain cores!\n",
+ (topo_sel == RTE_LCORE_DOMAIN_L1) ? "L1" :
+ (topo_sel == RTE_LCORE_DOMAIN_L2) ? "L2" :
+ (topo_sel == RTE_LCORE_DOMAIN_L3) ? "L3" : "IO");
+ ret = 0;
+ break;
+ default:
+ helloworld_usage(prgname);
+ return -1;
+ }
+ }
+ if (optind >= 0)
+ argv[optind-1] = prgname;
+ ret = optind-1;
+ optind = 1; /* reset getopt lib */
+ return ret;
+}
+
/* Initialization of Environment Abstraction Layer (EAL). 8< */
int
main(int argc, char **argv)
@@ -38,15 +145,46 @@ main(int argc, char **argv)
rte_panic("Cannot init EAL\n");
/* >8 End of initialization of Environment Abstraction Layer */
+ argc -= ret;
+ argv += ret;
+
+ ret = helloworld_parse_args(argc, argv);
+ if (ret < 0)
+ rte_exit(EXIT_FAILURE, "Invalid arguments\n");
+
+ if (topo_sel != USE_NO_TOPOLOGY) {
+ uint16_t domain_count = rte_get_domain_count(topo_sel);
+ RTE_LOG(DEBUG, HELLOWORLD, "selected Domain (%s)\n",
+ (topo_sel == RTE_LCORE_DOMAIN_L1) ? "L1" :
+ (topo_sel == RTE_LCORE_DOMAIN_L2) ? "L2" :
+ (topo_sel == RTE_LCORE_DOMAIN_L3) ? "L3" : "IO");
+
+ for (int i = 0; i < domain_count; i++) {
+ uint16_t domain_lcore_count = rte_lcore_count_from_domain(topo_sel, i);
+ uint16_t domain_lcore = rte_get_lcore_in_domain(topo_sel, i, 0);
+
+ if (domain_lcore_count)
+ RTE_LOG(DEBUG, HELLOWORLD, "at index (%u), %u cores, lcore (%u) at index 0\n",
+ i,
+ domain_lcore_count,
+ domain_lcore);
+ }
+ }
+
/* Launches the function on each lcore. 8< */
RTE_LCORE_FOREACH_WORKER(lcore_id) {
/* Simpler equivalent. 8< */
- rte_eal_remote_launch(lcore_hello, NULL, lcore_id);
+ rte_eal_remote_launch((topo_sel == USE_NO_TOPOLOGY) ?
+ lcore_hello : send_lcore_hello, NULL, lcore_id);
/* >8 End of simpler equivalent. */
}
/* call it on main lcore too */
- lcore_hello(NULL);
+ if (topo_sel == USE_NO_TOPOLOGY)
+ lcore_hello(NULL);
+ else
+ send_lcore_hello(NULL);
+
/* >8 End of launching the function on each lcore. */
rte_eal_mp_wait_lcore();
@@ -46,6 +46,9 @@ static int mac_updating = 1;
/* Ports set in promiscuous mode off by default. */
static int promiscuous_on;
+/* select lcores based on ports numa (RTE_LCORE_DOMAIN_IO). */
+static bool select_port_from_io_domain;
+
#define RTE_LOGTYPE_L2FWD RTE_LOGTYPE_USER1
#define MAX_PKT_BURST 32
@@ -314,6 +317,7 @@ l2fwd_usage(const char *prgname)
" -P : Enable promiscuous mode\n"
" -q NQ: number of queue (=ports) per lcore (default is 1)\n"
" -T PERIOD: statistics will be refreshed each PERIOD seconds (0 to disable, 10 default, 86400 maximum)\n"
+ " -t : Enable IO domain lcores mapping to Ports\n"
" --no-mac-updating: Disable MAC addresses updating (enabled by default)\n"
" When enabled:\n"
" - The source MAC address is replaced by the TX port MAC address\n"
@@ -431,6 +435,7 @@ static const char short_options[] =
"P" /* promiscuous */
"q:" /* number of queues */
"T:" /* timer period */
+ "t" /* lcore from port io numa */
;
#define CMD_LINE_OPT_NO_MAC_UPDATING "no-mac-updating"
@@ -502,6 +507,11 @@ l2fwd_parse_args(int argc, char **argv)
timer_period = timer_secs;
break;
+ /* lcores from port io numa */
+ case 't':
+ select_port_from_io_domain = true;
+ break;
+
/* long options */
case CMD_LINE_OPT_PORTMAP_NUM:
ret = l2fwd_parse_port_pair_config(optarg);
@@ -654,7 +664,7 @@ main(int argc, char **argv)
uint16_t nb_ports;
uint16_t nb_ports_available = 0;
uint16_t portid, last_port;
- unsigned lcore_id, rx_lcore_id;
+ uint16_t lcore_id, rx_lcore_id;
unsigned nb_ports_in_mask = 0;
unsigned int nb_lcores = 0;
unsigned int nb_mbufs;
@@ -738,18 +748,48 @@ main(int argc, char **argv)
qconf = NULL;
/* Initialize the port/queue configuration of each logical core */
+ if (rte_get_domain_count(RTE_LCORE_DOMAIN_IO) == 0)
+ rte_exit(EXIT_FAILURE, "we do not have enough cores in IO numa!\n");
+
+ uint16_t coreindx_io_domain[RTE_MAX_ETHPORTS] = {0};
+ uint16_t lcore_io_domain[RTE_MAX_ETHPORTS] = {RTE_MAX_LCORE};
+ uint16_t l3_domain_count = rte_get_domain_count(RTE_LCORE_DOMAIN_IO);
+
+ for (int i = 0; i < l3_domain_count; i++)
+ lcore_io_domain[i] = rte_get_lcore_in_domain(RTE_LCORE_DOMAIN_IO, i, 0);
+
RTE_ETH_FOREACH_DEV(portid) {
/* skip ports that are not enabled */
if ((l2fwd_enabled_port_mask & (1 << portid)) == 0)
continue;
- /* get the lcore_id for this port */
- while (rte_lcore_is_enabled(rx_lcore_id) == 0 ||
- lcore_queue_conf[rx_lcore_id].n_rx_port ==
- l2fwd_rx_queue_per_lcore) {
- rx_lcore_id++;
- if (rx_lcore_id >= RTE_MAX_LCORE)
- rte_exit(EXIT_FAILURE, "Not enough cores\n");
+ /* get IO NUMA for the port */
+ int port_socket = rte_eth_dev_socket_id(portid);
+
+ if (select_port_from_io_domain == false) {
+ /* get the lcore_id for this port */
+ while ((rte_lcore_is_enabled(rx_lcore_id) == 0) ||
+ (lcore_queue_conf[rx_lcore_id].n_rx_port ==
+ l2fwd_rx_queue_per_lcore)) {
+ rx_lcore_id++;
+ if (rx_lcore_id >= RTE_MAX_LCORE)
+ rte_exit(EXIT_FAILURE, "Not enough cores\n");
+ }
+ } else {
+ /* get lcore from IO numa for this port */
+ rx_lcore_id = lcore_io_domain[port_socket];
+
+ if (lcore_queue_conf[rx_lcore_id].n_rx_port == l2fwd_rx_queue_per_lcore) {
+ coreindx_io_domain[port_socket] += 1;
+ rx_lcore_id = rte_get_lcore_in_domain(RTE_LCORE_DOMAIN_IO,
+ port_socket, coreindx_io_domain[port_socket]);
+ }
+
+ if (rx_lcore_id == RTE_MAX_LCORE)
+ rte_exit(EXIT_FAILURE, "unable find IO (%u) numa lcore for port (%u)\n",
+ port_socket, portid);
+
+ lcore_io_domain[port_socket] = rx_lcore_id;
}
if (qconf != &lcore_queue_conf[rx_lcore_id]) {
@@ -176,6 +176,11 @@ main(int argc, char *argv[])
unsigned nb_ports;
uint16_t portid;
+ uint16_t ports_socket_domain[RTE_MAX_ETHPORTS] = {0};
+ uint16_t sel_io_socket = 0;
+ uint16_t sel_io_indx = 0;
+ uint16_t core_count_from_io = 0;
+
/* Initializion the Environment Abstraction Layer (EAL). 8< */
int ret = rte_eal_init(argc, argv);
if (ret < 0)
@@ -190,6 +195,20 @@ main(int argc, char *argv[])
if (nb_ports < 2 || (nb_ports & 1))
rte_exit(EXIT_FAILURE, "Error: number of ports must be even\n");
+ /* get the socekt of each port */
+ RTE_ETH_FOREACH_DEV(portid) {
+ ports_socket_domain[rte_eth_dev_socket_id(portid)] += 1;
+
+ if (ports_socket_domain[rte_eth_dev_socket_id(portid)] > sel_io_socket) {
+ sel_io_socket = ports_socket_domain[rte_eth_dev_socket_id(portid)];
+ sel_io_indx = rte_eth_dev_socket_id(portid);
+ }
+ }
+
+ core_count_from_io = rte_lcore_count_from_domain(RTE_LCORE_DOMAIN_IO, sel_io_indx);
+ if (core_count_from_io == 0)
+ printf("\nWARNING: select main_lcore from IO domain (%u)\n", sel_io_indx);
+
/* Creates a new mempool in memory to hold the mbufs. */
/* Allocates mempool to hold the mbufs. 8< */
@@ -210,6 +229,9 @@ main(int argc, char *argv[])
if (rte_lcore_count() > 1)
printf("\nWARNING: Too many lcores enabled. Only 1 used.\n");
+ if (rte_lcore_to_socket_id(rte_lcore_id()) != sel_io_indx)
+ printf("\nWARNING: please use lcore from IO domain %u.\n", sel_io_indx);
+
/* Call lcore_main on the main core only. Called on single lcore. 8< */
lcore_main();
/* >8 End of called on single lcore. */