From 9346a9090e03c0bcd9a6091d01d99d6f0c11fe7b Mon Sep 17 00:00:00 2001 From: Justin Viiret Date: Thu, 7 Jul 2016 12:53:09 +1000 Subject: [PATCH] fdr: remove groups from struct FDR_Runtime_Args --- src/fdr/fdr.c | 15 ++++++----- src/fdr/fdr_internal.h | 1 - src/fdr/teddy.c | 32 +++++++++++------------ src/fdr/teddy.h | 59 ++++++++++++++++++++++++++++-------------- src/fdr/teddy_avx2.c | 40 ++++++++++++++-------------- 5 files changed, 84 insertions(+), 63 deletions(-) diff --git a/src/fdr/fdr.c b/src/fdr/fdr.c index f973f639..4230c2b1 100644 --- a/src/fdr/fdr.c +++ b/src/fdr/fdr.c @@ -702,8 +702,8 @@ size_t prepareZones(const u8 *buf, size_t len, const u8 *hend, static never_inline hwlm_error_t fdr_engine_exec(const struct FDR *fdr, - const struct FDR_Runtime_Args *a) { - hwlmcb_rv_t control = *a->groups; + const struct FDR_Runtime_Args *a, + hwlm_group_t control) { u32 floodBackoff = FLOOD_BACKOFF_START; u32 last_match_id = INVALID_MATCH_ID; u64a domain_mask_adjusted = fdr->domainMask << 1; @@ -768,7 +768,10 @@ hwlm_error_t fdr_engine_exec(const struct FDR *fdr, #define ONLY_AVX2(func) NULL #endif -typedef hwlm_error_t (*FDRFUNCTYPE)(const struct FDR *fdr, const struct FDR_Runtime_Args *a); +typedef hwlm_error_t (*FDRFUNCTYPE)(const struct FDR *fdr, + const struct FDR_Runtime_Args *a, + hwlm_group_t control); + static const FDRFUNCTYPE funcs[] = { fdr_engine_exec, ONLY_AVX2(fdr_exec_teddy_avx2_msks1_fast), @@ -811,7 +814,6 @@ hwlm_error_t fdrExec(const struct FDR *fdr, const u8 *buf, size_t len, start, cb, ctxt, - &groups, nextFloodDetect(buf, len, FLOOD_BACKOFF_START), 0 }; @@ -819,7 +821,7 @@ hwlm_error_t fdrExec(const struct FDR *fdr, const u8 *buf, size_t len, return HWLM_SUCCESS; } else { assert(funcs[fdr->engineID]); - return funcs[fdr->engineID](fdr, &a); + return funcs[fdr->engineID](fdr, &a, groups); } } @@ -837,7 +839,6 @@ hwlm_error_t fdrExecStreaming(const struct FDR *fdr, const u8 *hbuf, start, cb, ctxt, - &groups, nextFloodDetect(buf, len, FLOOD_BACKOFF_START), /* we are guaranteed to always have 16 initialised bytes at the end of * the history buffer (they may be garbage). */ @@ -850,7 +851,7 @@ hwlm_error_t fdrExecStreaming(const struct FDR *fdr, const u8 *hbuf, ret = HWLM_SUCCESS; } else { assert(funcs[fdr->engineID]); - ret = funcs[fdr->engineID](fdr, &a); + ret = funcs[fdr->engineID](fdr, &a, groups); } fdrPackState(fdr, &a, stream_state); diff --git a/src/fdr/fdr_internal.h b/src/fdr/fdr_internal.h index cde13f6c..6272b69e 100644 --- a/src/fdr/fdr_internal.h +++ b/src/fdr/fdr_internal.h @@ -105,7 +105,6 @@ struct FDR_Runtime_Args { size_t start_offset; HWLMCallback cb; void *ctxt; - hwlm_group_t *groups; const u8 *firstFloodDetect; const u64a histBytes; }; diff --git a/src/fdr/teddy.c b/src/fdr/teddy.c index 462b57df..9f8b5104 100644 --- a/src/fdr/teddy.c +++ b/src/fdr/teddy.c @@ -179,10 +179,10 @@ m128 prep_conf_teddy_m4(const m128 *maskBase, m128 *old_1, m128 *old_2, } hwlm_error_t fdr_exec_teddy_msks1(const struct FDR *fdr, - const struct FDR_Runtime_Args *a) { + const struct FDR_Runtime_Args *a, + hwlm_group_t control) { const u8 *buf_end = a->buf + a->len; const u8 *ptr = a->buf + a->start_offset; - hwlmcb_rv_t control = *a->groups; u32 floodBackoff = FLOOD_BACKOFF_START; const u8 *tryFloodDetect = a->firstFloodDetect; u32 last_match = (u32)-1; @@ -233,10 +233,10 @@ hwlm_error_t fdr_exec_teddy_msks1(const struct FDR *fdr, } hwlm_error_t fdr_exec_teddy_msks1_pck(const struct FDR *fdr, - const struct FDR_Runtime_Args *a) { + const struct FDR_Runtime_Args *a, + hwlm_group_t control) { const u8 *buf_end = a->buf + a->len; const u8 *ptr = a->buf + a->start_offset; - hwlmcb_rv_t control = *a->groups; u32 floodBackoff = FLOOD_BACKOFF_START; const u8 *tryFloodDetect = a->firstFloodDetect; u32 last_match = (u32)-1; @@ -287,10 +287,10 @@ hwlm_error_t fdr_exec_teddy_msks1_pck(const struct FDR *fdr, } hwlm_error_t fdr_exec_teddy_msks2(const struct FDR *fdr, - const struct FDR_Runtime_Args *a) { + const struct FDR_Runtime_Args *a, + hwlm_group_t control) { const u8 *buf_end = a->buf + a->len; const u8 *ptr = a->buf + a->start_offset; - hwlmcb_rv_t control = *a->groups; u32 floodBackoff = FLOOD_BACKOFF_START; const u8 *tryFloodDetect = a->firstFloodDetect; u32 last_match = (u32)-1; @@ -345,10 +345,10 @@ hwlm_error_t fdr_exec_teddy_msks2(const struct FDR *fdr, } hwlm_error_t fdr_exec_teddy_msks2_pck(const struct FDR *fdr, - const struct FDR_Runtime_Args *a) { + const struct FDR_Runtime_Args *a, + hwlm_group_t control) { const u8 *buf_end = a->buf + a->len; const u8 *ptr = a->buf + a->start_offset; - hwlmcb_rv_t control = *a->groups; u32 floodBackoff = FLOOD_BACKOFF_START; const u8 *tryFloodDetect = a->firstFloodDetect; u32 last_match = (u32)-1; @@ -403,10 +403,10 @@ hwlm_error_t fdr_exec_teddy_msks2_pck(const struct FDR *fdr, } hwlm_error_t fdr_exec_teddy_msks3(const struct FDR *fdr, - const struct FDR_Runtime_Args *a) { + const struct FDR_Runtime_Args *a, + hwlm_group_t control) { const u8 *buf_end = a->buf + a->len; const u8 *ptr = a->buf + a->start_offset; - hwlmcb_rv_t control = *a->groups; u32 floodBackoff = FLOOD_BACKOFF_START; const u8 *tryFloodDetect = a->firstFloodDetect; u32 last_match = (u32)-1; @@ -464,10 +464,10 @@ hwlm_error_t fdr_exec_teddy_msks3(const struct FDR *fdr, } hwlm_error_t fdr_exec_teddy_msks3_pck(const struct FDR *fdr, - const struct FDR_Runtime_Args *a) { + const struct FDR_Runtime_Args *a, + hwlm_group_t control) { const u8 *buf_end = a->buf + a->len; const u8 *ptr = a->buf + a->start_offset; - hwlmcb_rv_t control = *a->groups; u32 floodBackoff = FLOOD_BACKOFF_START; const u8 *tryFloodDetect = a->firstFloodDetect; u32 last_match = (u32)-1; @@ -525,10 +525,10 @@ hwlm_error_t fdr_exec_teddy_msks3_pck(const struct FDR *fdr, } hwlm_error_t fdr_exec_teddy_msks4(const struct FDR *fdr, - const struct FDR_Runtime_Args *a) { + const struct FDR_Runtime_Args *a, + hwlm_group_t control) { const u8 *buf_end = a->buf + a->len; const u8 *ptr = a->buf + a->start_offset; - hwlmcb_rv_t control = *a->groups; u32 floodBackoff = FLOOD_BACKOFF_START; const u8 *tryFloodDetect = a->firstFloodDetect; u32 last_match = (u32)-1; @@ -587,10 +587,10 @@ hwlm_error_t fdr_exec_teddy_msks4(const struct FDR *fdr, } hwlm_error_t fdr_exec_teddy_msks4_pck(const struct FDR *fdr, - const struct FDR_Runtime_Args *a) { + const struct FDR_Runtime_Args *a, + hwlm_group_t control) { const u8 *buf_end = a->buf + a->len; const u8 *ptr = a->buf + a->start_offset; - hwlmcb_rv_t control = *a->groups; u32 floodBackoff = FLOOD_BACKOFF_START; const u8 *tryFloodDetect = a->firstFloodDetect; u32 last_match = (u32)-1; diff --git a/src/fdr/teddy.h b/src/fdr/teddy.h index f3902723..e2936723 100644 --- a/src/fdr/teddy.h +++ b/src/fdr/teddy.h @@ -33,64 +33,85 @@ #ifndef TEDDY_H_ #define TEDDY_H_ +#include "hwlm/hwlm.h" // for hwlm_group_t + struct FDR; // forward declaration from fdr_internal.h struct FDR_Runtime_Args; hwlm_error_t fdr_exec_teddy_msks1(const struct FDR *fdr, - const struct FDR_Runtime_Args *a); + const struct FDR_Runtime_Args *a, + hwlm_group_t control); hwlm_error_t fdr_exec_teddy_msks1_pck(const struct FDR *fdr, - const struct FDR_Runtime_Args *a); + const struct FDR_Runtime_Args *a, + hwlm_group_t control); hwlm_error_t fdr_exec_teddy_msks2(const struct FDR *fdr, - const struct FDR_Runtime_Args *a); + const struct FDR_Runtime_Args *a, + hwlm_group_t control); hwlm_error_t fdr_exec_teddy_msks2_pck(const struct FDR *fdr, - const struct FDR_Runtime_Args *a); + const struct FDR_Runtime_Args *a, + hwlm_group_t control); hwlm_error_t fdr_exec_teddy_msks3(const struct FDR *fdr, - const struct FDR_Runtime_Args *a); + const struct FDR_Runtime_Args *a, + hwlm_group_t control); hwlm_error_t fdr_exec_teddy_msks3_pck(const struct FDR *fdr, - const struct FDR_Runtime_Args *a); + const struct FDR_Runtime_Args *a, + hwlm_group_t control); hwlm_error_t fdr_exec_teddy_msks4(const struct FDR *fdr, - const struct FDR_Runtime_Args *a); + const struct FDR_Runtime_Args *a, + hwlm_group_t control); hwlm_error_t fdr_exec_teddy_msks4_pck(const struct FDR *fdr, - const struct FDR_Runtime_Args *a); + const struct FDR_Runtime_Args *a, + hwlm_group_t control); #if defined(__AVX2__) hwlm_error_t fdr_exec_teddy_avx2_msks1_fat(const struct FDR *fdr, - const struct FDR_Runtime_Args *a); + const struct FDR_Runtime_Args *a, + hwlm_group_t control); hwlm_error_t fdr_exec_teddy_avx2_msks1_pck_fat(const struct FDR *fdr, - const struct FDR_Runtime_Args *a); + const struct FDR_Runtime_Args *a, + hwlm_group_t control); hwlm_error_t fdr_exec_teddy_avx2_msks2_fat(const struct FDR *fdr, - const struct FDR_Runtime_Args *a); + const struct FDR_Runtime_Args *a, + hwlm_group_t control); hwlm_error_t fdr_exec_teddy_avx2_msks2_pck_fat(const struct FDR *fdr, - const struct FDR_Runtime_Args *a); + const struct FDR_Runtime_Args *a, + hwlm_group_t control); hwlm_error_t fdr_exec_teddy_avx2_msks3_fat(const struct FDR *fdr, - const struct FDR_Runtime_Args *a); + const struct FDR_Runtime_Args *a, + hwlm_group_t control); hwlm_error_t fdr_exec_teddy_avx2_msks3_pck_fat(const struct FDR *fdr, - const struct FDR_Runtime_Args *a); + const struct FDR_Runtime_Args *a, + hwlm_group_t control); hwlm_error_t fdr_exec_teddy_avx2_msks4_fat(const struct FDR *fdr, - const struct FDR_Runtime_Args *a); + const struct FDR_Runtime_Args *a, + hwlm_group_t control); hwlm_error_t fdr_exec_teddy_avx2_msks4_pck_fat(const struct FDR *fdr, - const struct FDR_Runtime_Args *a); + const struct FDR_Runtime_Args *a, + hwlm_group_t control); hwlm_error_t fdr_exec_teddy_avx2_msks1_fast(const struct FDR *fdr, - const struct FDR_Runtime_Args *a); + const struct FDR_Runtime_Args *a, + hwlm_group_t control); -hwlm_error_t fdr_exec_teddy_avx2_msks1_pck_fast(const struct FDR *fdr, - const struct FDR_Runtime_Args *a); +hwlm_error_t +fdr_exec_teddy_avx2_msks1_pck_fast(const struct FDR *fdr, + const struct FDR_Runtime_Args *a, + hwlm_group_t control); #endif /* __AVX2__ */ diff --git a/src/fdr/teddy_avx2.c b/src/fdr/teddy_avx2.c index 52e75cb4..428c9446 100644 --- a/src/fdr/teddy_avx2.c +++ b/src/fdr/teddy_avx2.c @@ -481,10 +481,10 @@ const u32 * getConfBase_avx2(const struct Teddy *teddy, u8 numMask) { } hwlm_error_t fdr_exec_teddy_avx2_msks1_fat(const struct FDR *fdr, - const struct FDR_Runtime_Args *a) { + const struct FDR_Runtime_Args *a, + hwlm_group_t control) { const u8 *buf_end = a->buf + a->len; const u8 *ptr = a->buf + a->start_offset; - hwlmcb_rv_t control = *a->groups; u32 floodBackoff = FLOOD_BACKOFF_START; const u8 *tryFloodDetect = a->firstFloodDetect; u32 last_match = (u32)-1; @@ -536,10 +536,10 @@ hwlm_error_t fdr_exec_teddy_avx2_msks1_fat(const struct FDR *fdr, } hwlm_error_t fdr_exec_teddy_avx2_msks1_pck_fat(const struct FDR *fdr, - const struct FDR_Runtime_Args *a) { + const struct FDR_Runtime_Args *a, + hwlm_group_t control) { const u8 *buf_end = a->buf + a->len; const u8 *ptr = a->buf + a->start_offset; - hwlmcb_rv_t control = *a->groups; u32 floodBackoff = FLOOD_BACKOFF_START; const u8 *tryFloodDetect = a->firstFloodDetect; u32 last_match = (u32)-1; @@ -591,10 +591,10 @@ hwlm_error_t fdr_exec_teddy_avx2_msks1_pck_fat(const struct FDR *fdr, } hwlm_error_t fdr_exec_teddy_avx2_msks2_fat(const struct FDR *fdr, - const struct FDR_Runtime_Args *a) { + const struct FDR_Runtime_Args *a, + hwlm_group_t control) { const u8 *buf_end = a->buf + a->len; const u8 *ptr = a->buf + a->start_offset; - hwlmcb_rv_t control = *a->groups; u32 floodBackoff = FLOOD_BACKOFF_START; const u8 *tryFloodDetect = a->firstFloodDetect; u32 last_match = (u32)-1; @@ -649,10 +649,10 @@ hwlm_error_t fdr_exec_teddy_avx2_msks2_fat(const struct FDR *fdr, } hwlm_error_t fdr_exec_teddy_avx2_msks2_pck_fat(const struct FDR *fdr, - const struct FDR_Runtime_Args *a) { + const struct FDR_Runtime_Args *a, + hwlm_group_t control) { const u8 *buf_end = a->buf + a->len; const u8 *ptr = a->buf + a->start_offset; - hwlmcb_rv_t control = *a->groups; u32 floodBackoff = FLOOD_BACKOFF_START; const u8 *tryFloodDetect = a->firstFloodDetect; u32 last_match = (u32)-1; @@ -707,10 +707,10 @@ hwlm_error_t fdr_exec_teddy_avx2_msks2_pck_fat(const struct FDR *fdr, } hwlm_error_t fdr_exec_teddy_avx2_msks3_fat(const struct FDR *fdr, - const struct FDR_Runtime_Args *a) { + const struct FDR_Runtime_Args *a, + hwlm_group_t control) { const u8 *buf_end = a->buf + a->len; const u8 *ptr = a->buf + a->start_offset; - hwlmcb_rv_t control = *a->groups; u32 floodBackoff = FLOOD_BACKOFF_START; const u8 *tryFloodDetect = a->firstFloodDetect; u32 last_match = (u32)-1; @@ -768,10 +768,10 @@ hwlm_error_t fdr_exec_teddy_avx2_msks3_fat(const struct FDR *fdr, } hwlm_error_t fdr_exec_teddy_avx2_msks3_pck_fat(const struct FDR *fdr, - const struct FDR_Runtime_Args *a) { + const struct FDR_Runtime_Args *a, + hwlm_group_t control) { const u8 *buf_end = a->buf + a->len; const u8 *ptr = a->buf + a->start_offset; - hwlmcb_rv_t control = *a->groups; u32 floodBackoff = FLOOD_BACKOFF_START; const u8 *tryFloodDetect = a->firstFloodDetect; u32 last_match = (u32)-1; @@ -829,10 +829,10 @@ hwlm_error_t fdr_exec_teddy_avx2_msks3_pck_fat(const struct FDR *fdr, } hwlm_error_t fdr_exec_teddy_avx2_msks4_fat(const struct FDR *fdr, - const struct FDR_Runtime_Args *a) { + const struct FDR_Runtime_Args *a, + hwlm_group_t control) { const u8 *buf_end = a->buf + a->len; const u8 *ptr = a->buf + a->start_offset; - hwlmcb_rv_t control = *a->groups; u32 floodBackoff = FLOOD_BACKOFF_START; const u8 *tryFloodDetect = a->firstFloodDetect; u32 last_match = (u32)-1; @@ -894,10 +894,10 @@ hwlm_error_t fdr_exec_teddy_avx2_msks4_fat(const struct FDR *fdr, } hwlm_error_t fdr_exec_teddy_avx2_msks4_pck_fat(const struct FDR *fdr, - const struct FDR_Runtime_Args *a) { + const struct FDR_Runtime_Args *a, + hwlm_group_t control) { const u8 *buf_end = a->buf + a->len; const u8 *ptr = a->buf + a->start_offset; - hwlmcb_rv_t control = *a->groups; u32 floodBackoff = FLOOD_BACKOFF_START; const u8 *tryFloodDetect = a->firstFloodDetect; u32 last_match = (u32)-1; @@ -959,10 +959,10 @@ hwlm_error_t fdr_exec_teddy_avx2_msks4_pck_fat(const struct FDR *fdr, } hwlm_error_t fdr_exec_teddy_avx2_msks1_fast(const struct FDR *fdr, - const struct FDR_Runtime_Args *a) { + const struct FDR_Runtime_Args *a, + hwlm_group_t control) { const u8 *buf_end = a->buf + a->len; const u8 *ptr = a->buf + a->start_offset; - hwlmcb_rv_t control = *a->groups; u32 floodBackoff = FLOOD_BACKOFF_START; const u8 *tryFloodDetect = a->firstFloodDetect; u32 last_match = (u32)-1; @@ -1028,10 +1028,10 @@ hwlm_error_t fdr_exec_teddy_avx2_msks1_fast(const struct FDR *fdr, } hwlm_error_t fdr_exec_teddy_avx2_msks1_pck_fast(const struct FDR *fdr, - const struct FDR_Runtime_Args *a) { + const struct FDR_Runtime_Args *a, + hwlm_group_t control) { const u8 *buf_end = a->buf + a->len; const u8 *ptr = a->buf + a->start_offset; - hwlmcb_rv_t control = *a->groups; u32 floodBackoff = FLOOD_BACKOFF_START; const u8 *tryFloodDetect = a->firstFloodDetect; u32 last_match = (u32)-1;