aboutsummaryrefslogtreecommitdiffstats
path: root/lib/libtle_l4p/ctx.c
diff options
context:
space:
mode:
authorReshma Pattan <reshma.pattan@intel.com>2017-04-07 16:51:27 +0100
committerReshma Pattan <reshma.pattan@intel.com>2017-04-14 10:30:57 +0100
commit9fa82a63e47e4ee274c54af366e6fce055a0cbab (patch)
tree6479ef920d62a7d772e029766da113eb1e7b3228 /lib/libtle_l4p/ctx.c
parent4e3cb26150547b8b4105c795e282a1564e7f6e86 (diff)
* Add siphash file for calculating the sequence number.
* l4fwd app changed to include new command line parameters hash and secret key for hash calculation. * Changed l4fwd library to integrate siphash support for calculating the sequence number. Change-Id: I29c60836c8b17a118d76b619fd79398fac200f67 Signed-off-by: Reshma Pattan <reshma.pattan@intel.com>
Diffstat (limited to 'lib/libtle_l4p/ctx.c')
-rw-r--r--lib/libtle_l4p/ctx.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/libtle_l4p/ctx.c b/lib/libtle_l4p/ctx.c
index 7ebef9d..6eb33eb 100644
--- a/lib/libtle_l4p/ctx.c
+++ b/lib/libtle_l4p/ctx.c
@@ -21,6 +21,7 @@
#include "stream.h"
#include "misc.h"
+#include <halfsiphash.h>
#define LPORT_START 0x8000
#define LPORT_END MAX_PORT_NUM
@@ -66,6 +67,8 @@ check_ctx_prm(const struct tle_ctx_param *prm)
{
if (prm->proto >= TLE_PROTO_NUM)
return -EINVAL;
+ if (prm->hash_alg >= TLE_HASH_NUM)
+ return -EINVAL;
return 0;
}
@@ -108,6 +111,13 @@ tle_ctx_create(const struct tle_ctx_param *ctx_prm)
tle_pbm_init(ctx->use + i, LPORT_START_BLK);
ctx->streams.nb_free = ctx->prm.max_streams;
+
+ /* Initialization of siphash state is done here to speed up the
+ * fastpath processing.
+ */
+ if (ctx->prm.hash_alg == TLE_SIPHASH)
+ siphash_initialization(&ctx->prm.secret_key,
+ &ctx->prm.secret_key);
return ctx;
}