aboutsummaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/l4fwd/README5
-rw-r--r--examples/l4fwd/lcore.h7
-rw-r--r--examples/l4fwd/main.c3
-rw-r--r--examples/l4fwd/parse.c51
-rw-r--r--examples/l4fwd/port.h2
-rw-r--r--examples/l4fwd/tcp.h6
6 files changed, 65 insertions, 9 deletions
diff --git a/examples/l4fwd/README b/examples/l4fwd/README
index 658fe3a..a232537 100644
--- a/examples/l4fwd/README
+++ b/examples/l4fwd/README
@@ -130,6 +130,11 @@
-L | --listen /* open TCP streams in server mode (listen). */ \
-a | --enable-arp /* enable arp responses (request not supported) */ \
-v | --verbose /* different level of verbose mode */ \
+ -H | --hash <string> /* hash algorithm i.e. siphash or jhash to be */ \
+ /* used to generate the sequence number. */ \
+ -K | --seckey <string> /* 16 character long secret key used by */ \
+ /* hash algorithms to generate the */ \
+ /* sequence number. */ \
<port0_params> <port1_params> ... <portN_params>
Note that: options -U and -T cannot be used together.
diff --git a/examples/l4fwd/lcore.h b/examples/l4fwd/lcore.h
index d88e434..11cc239 100644
--- a/examples/l4fwd/lcore.h
+++ b/examples/l4fwd/lcore.h
@@ -16,6 +16,8 @@
#ifndef LCORE_H_
#define LCORE_H_
+#include <rte_random.h>
+
#include "dpdk_legacy.h"
/*
@@ -64,6 +66,11 @@ create_context(struct netbe_lcore *lc, const struct tle_ctx_param *ctx_prm)
cprm.lookup4_data = lc;
cprm.lookup6 = lpm6_dst_lookup;
cprm.lookup6_data = lc;
+ if (cprm.secret_key.u64[0] == 0 &&
+ cprm.secret_key.u64[1] == 0) {
+ cprm.secret_key.u64[0] = rte_rand();
+ cprm.secret_key.u64[1] = rte_rand();
+ }
frag_cycles = (rte_get_tsc_hz() + MS_PER_S - 1) /
MS_PER_S * FRAG_TTL;
diff --git a/examples/l4fwd/main.c b/examples/l4fwd/main.c
index 37bd03e..7613a95 100644
--- a/examples/l4fwd/main.c
+++ b/examples/l4fwd/main.c
@@ -68,9 +68,8 @@ static char proto_name[3][10] = {"udp", "tcp", ""};
static const struct rte_eth_conf port_conf_default = {
.rxmode = {
- .max_rx_pkt_len = ETHER_MAX_VLAN_FRAME_LEN,
.hw_vlan_strip = 1,
- .jumbo_frame = 1,
+ .jumbo_frame = 0,
},
};
diff --git a/examples/l4fwd/parse.c b/examples/l4fwd/parse.c
index 6593221..4850312 100644
--- a/examples/l4fwd/parse.c
+++ b/examples/l4fwd/parse.c
@@ -13,6 +13,9 @@
* limitations under the License.
*/
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
#include "netbe.h"
#include "parse.h"
@@ -61,6 +64,12 @@ static const struct {
#define OPT_SHORT_LISTEN 'L'
#define OPT_LONG_LISTEN "listen"
+#define OPT_SHORT_HASH 'H'
+#define OPT_LONG_HASH "hash"
+
+#define OPT_SHORT_SEC_KEY 'K'
+#define OPT_LONG_SEC_KEY "seckey"
+
#define OPT_SHORT_VERBOSE 'v'
#define OPT_LONG_VERBOSE "verbose"
@@ -75,6 +84,8 @@ static const struct option long_opt[] = {
{OPT_LONG_STREAMS, 1, 0, OPT_SHORT_STREAMS},
{OPT_LONG_UDP, 0, 0, OPT_SHORT_UDP},
{OPT_LONG_TCP, 0, 0, OPT_SHORT_TCP},
+ {OPT_LONG_HASH, 1, 0, OPT_SHORT_HASH},
+ {OPT_LONG_SEC_KEY, 1, 0, OPT_SHORT_SEC_KEY},
{OPT_LONG_LISTEN, 0, 0, OPT_SHORT_LISTEN},
{OPT_LONG_VERBOSE, 1, 0, OPT_SHORT_VERBOSE},
{NULL, 0, 0, 0}
@@ -298,7 +309,7 @@ parse_netbe_arg(struct netbe_port *prt, const char *arg, rte_cpuset_t *pcpu)
union parse_val val[RTE_DIM(hndl)];
memset(val, 0, sizeof(val));
- val[2].u64 = ETHER_MAX_VLAN_FRAME_LEN - ETHER_CRC_LEN;
+ val[2].u64 = ETHER_MAX_LEN - ETHER_CRC_LEN;
rc = parse_kvargs(arg, keys_man, RTE_DIM(keys_man),
keys_opt, RTE_DIM(keys_opt), hndl, val);
@@ -709,6 +720,17 @@ netfe_parse_cfg(const char *fname, struct netfe_lcore_prm *lp)
return rc;
}
+static uint32_t
+parse_hash_alg(const char *val)
+{
+ if (strcmp(val, "jhash") == 0)
+ return TLE_JHASH;
+ else if (strcmp(val, "siphash") == 0)
+ return TLE_SIPHASH;
+ else
+ return TLE_HASH_NUM;
+}
+
int
parse_app_options(int argc, char **argv, struct netbe_cfg *cfg,
struct tle_ctx_param *ctx_prm,
@@ -722,8 +744,8 @@ parse_app_options(int argc, char **argv, struct netbe_cfg *cfg,
optind = 0;
optarg = NULL;
- while ((opt = getopt_long(argc, argv, "aB:LPR:S:TUb:f:s:v:", long_opt,
- &opt_idx)) != EOF) {
+ while ((opt = getopt_long(argc, argv, "aB:LPR:S:TUb:f:s:v:H:K:",
+ long_opt, &opt_idx)) != EOF) {
if (opt == OPT_SHORT_ARP) {
cfg->arp = 1;
} else if (opt == OPT_SHORT_SBULK) {
@@ -778,7 +800,28 @@ parse_app_options(int argc, char **argv, struct netbe_cfg *cfg,
} else if (opt == OPT_SHORT_LISTEN) {
listen = 1;
cfg->server = 1;
- } else {
+ } else if (opt == OPT_SHORT_HASH) {
+ ctx_prm->hash_alg = parse_hash_alg(optarg);
+ if (ctx_prm->hash_alg >= TLE_HASH_NUM) {
+ rte_exit(EXIT_FAILURE,
+ "%s: invalid hash algorithm %s "
+ "for option: \'%c\'\n",
+ __func__, optarg, opt);
+ }
+ } else if (opt == OPT_SHORT_SEC_KEY) {
+ n = strlen(optarg);
+ if (n != sizeof(ctx_prm->secret_key)) {
+ rte_exit(EXIT_FAILURE,
+ "%s: invalid length %s "
+ "for option \'%c\' "
+ "must be 16 characters long\n",
+ __func__, optarg, opt);
+ }
+ memcpy(&ctx_prm->secret_key, optarg,
+ sizeof(ctx_prm->secret_key));
+ }
+
+ else {
rte_exit(EXIT_FAILURE,
"%s: unknown option: \'%c\'\n",
__func__, opt);
diff --git a/examples/l4fwd/port.h b/examples/l4fwd/port.h
index bc13dca..04f3ec2 100644
--- a/examples/l4fwd/port.h
+++ b/examples/l4fwd/port.h
@@ -181,6 +181,8 @@ port_init(struct netbe_port *uprt, uint32_t proto)
port_conf.rxmode.hw_ip_checksum = 1;
}
port_conf.rxmode.max_rx_pkt_len = uprt->mtu + ETHER_CRC_LEN;
+ if (port_conf.rxmode.max_rx_pkt_len > ETHER_MAX_LEN)
+ port_conf.rxmode.jumbo_frame = 1;
rc = update_rss_conf(uprt, &dev_info, &port_conf, proto);
if (rc != 0)
diff --git a/examples/l4fwd/tcp.h b/examples/l4fwd/tcp.h
index f6ca3a5..e4aadb5 100644
--- a/examples/l4fwd/tcp.h
+++ b/examples/l4fwd/tcp.h
@@ -279,9 +279,9 @@ netfe_fwd_tcp(uint32_t lcore, struct netfe_stream *fes)
__func__, lcore, proto_name[fes->proto],
fed->s, n, k);
- fed->stat.txp += k;
- fed->stat.drops += n - k;
- fes->stat.fwp += k;
+ fed->stat.txp += k;
+ fed->stat.drops += n - k;
+ fes->stat.fwp += k;
} else {
NETFE_TRACE("%s(%u, %p): no fwd stream for %u pkts;\n",