diff options
author | Mohammad Abdul Awal <mohammad.abdul.awal@intel.com> | 2016-06-15 09:21:55 +0100 |
---|---|---|
committer | Mohammad Abdul Awal <mohammad.abdul.awal@intel.com> | 2016-09-06 13:16:52 +0100 |
commit | 8ae38dfb285ab9843312964b3081b2c52ba857dc (patch) | |
tree | 87dd74f1ca5668df4b859fdb7633ac7f83bbf75e /examples/udpfwd/parse.c | |
parent | 58a3674671da166ff3e3ec4dd552eb60adf3652b (diff) |
Initial working version of RSS
The patch enables RSS support for TLDK udpfwd application.
The number of rx queues and tx queues are equal to the number of lcore
enabled for backend operation. NICs calculate the RSS hash based on the
UDP dest port only. The RSS hash key is calculated at runtime based on
the number of queues enebaled.
Change-Id: I06006a4606f8faad8f16241348b2ce19b70335e5
Signed-off-by: Mohammad Abdul Awal <mohammad.abdul.awal@intel.com>
Diffstat (limited to 'examples/udpfwd/parse.c')
-rw-r--r-- | examples/udpfwd/parse.c | 55 |
1 files changed, 49 insertions, 6 deletions
diff --git a/examples/udpfwd/parse.c b/examples/udpfwd/parse.c index 78df01b..cc8c0b2 100644 --- a/examples/udpfwd/parse.c +++ b/examples/udpfwd/parse.c @@ -13,6 +13,7 @@ * limitations under the License. */ +#include <sched.h> #include "netbe.h" #include "parse.h" @@ -61,7 +62,6 @@ parse_ip_val(__rte_unused const char *key, const char *val, void *prm) return 0; } - #define PARSE_UINT8x16(s, v, l) \ do { \ char *end; \ @@ -110,6 +110,41 @@ parse_feop_val(__rte_unused const char *key, const char *val, void *prm) } static int +parse_lcore_list_val(__rte_unused const char *key, const char *val, void *prm) +{ + union parse_val *rv; + unsigned long a, b; + uint32_t i; + char *end; + + rv = prm; + errno = 0; + a = strtoul(val, &end, 0); + if (errno != 0 || (end[0] != 0 && end[0] != '-') || a > UINT32_MAX) + return -EINVAL; + + if (end[0] == '-') { + val = end + 1; + errno = 0; + b = strtoul(val, &end, 0); + if (errno != 0 || end[0] != 0 || b > UINT32_MAX) + return -EINVAL; + } else + b = a; + + if (a <= b) { + for (i = a; i <= b; i++) + CPU_SET(i, &rv->cpuset); + } else { + RTE_LOG(ERR, USER1, + "%s: lcores not in ascending order\n", __func__); + return -EINVAL; + } + + return 0; +} + +static int parse_kvargs(const char *arg, const char *keys_man[], uint32_t nb_man, const char *keys_opt[], uint32_t nb_opt, const arg_handler_t hndl[], union parse_val val[]) @@ -139,7 +174,7 @@ parse_kvargs(const char *arg, const char *keys_man[], uint32_t nb_man, if (rte_kvargs_process(kvl, keys_man[j], hndl[j], val + j) != 0) { RTE_LOG(ERR, USER1, - "%s: %s invalid value for key: %s\n", + "%s: %s invalid value for man key: %s\n", __func__, arg, keys_man[j]); rte_kvargs_free(kvl); return -EINVAL; @@ -151,7 +186,7 @@ parse_kvargs(const char *arg, const char *keys_man[], uint32_t nb_man, if (rte_kvargs_process(kvl, keys_opt[j], hndl[k], val + k) != 0) { RTE_LOG(ERR, USER1, - "%s: %s invalid value for key: %s\n", + "%s: %s invalid value for opt key: %s\n", __func__, arg, keys_opt[j]); rte_kvargs_free(kvl); return -EINVAL; @@ -166,6 +201,7 @@ int parse_netbe_arg(struct netbe_port *prt, const char *arg) { int32_t rc; + uint32_t i, j; static const char *keys_man[] = { "port", @@ -182,7 +218,7 @@ parse_netbe_arg(struct netbe_port *prt, const char *arg) static const arg_handler_t hndl[] = { parse_uint_val, - parse_uint_val, + parse_lcore_list_val, parse_uint_val, parse_uint_val, parse_uint_val, @@ -201,7 +237,10 @@ parse_netbe_arg(struct netbe_port *prt, const char *arg) return rc; prt->id = val[0].u64; - prt->lcore = val[1].u64; + for (i = 0, j = 0; i < RTE_MAX_LCORE; i++) + if (CPU_ISSET(i, &val[1].cpuset)) + prt->lcore[j++] = i; + prt->nb_lcore = j; prt->mtu = val[2].u64; prt->rx_offload = val[3].u64; prt->tx_offload = val[4].u64; @@ -210,6 +249,7 @@ parse_netbe_arg(struct netbe_port *prt, const char *arg) return 0; } + static int check_netbe_dest(const struct netbe_dest *dst) { @@ -390,6 +430,7 @@ parse_netfe_arg(struct netfe_stream_prm *sp, const char *arg) "fwlport", "fwraddr", "fwrport", + "belcore", }; static const arg_handler_t hndl[] = { @@ -404,16 +445,17 @@ parse_netfe_arg(struct netfe_stream_prm *sp, const char *arg) parse_uint_val, parse_ip_val, parse_uint_val, + parse_uint_val, }; union parse_val val[RTE_DIM(hndl)]; memset(val, 0, sizeof(val)); + val[11].u64 = LCORE_ID_ANY; rc = parse_kvargs(arg, keys_man, RTE_DIM(keys_man), keys_opt, RTE_DIM(keys_opt), hndl, val); if (rc != 0) return rc; - sp->lcore = val[0].u64; sp->op = val[1].u64; pv2saddr(&sp->sprm.prm.local_addr, val + 2, val + 3); @@ -421,6 +463,7 @@ parse_netfe_arg(struct netfe_stream_prm *sp, const char *arg) sp->txlen = val[6].u64; pv2saddr(&sp->fprm.prm.local_addr, val + 7, val + 8); pv2saddr(&sp->fprm.prm.remote_addr, val + 9, val + 10); + sp->be_lcore = val[11].u64; return 0; } |