CNDP 22.08.0
Loading...
Searching...
No Matches
acl_vect.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright (c) 2010-2022 Intel Corporation
3 */
4
5#ifndef _CNE_ACL_VECT_H_
6#define _CNE_ACL_VECT_H_
7
13
14#ifdef __cplusplus
15extern "C" {
16#endif
17
18/*
19 * Takes 2 SIMD registers containing N transitions each (tr0, tr1).
20 * Shuffles it into different representation:
21 * lo - contains low 32 bits of given N transitions.
22 * hi - contains high 32 bits of given N transitions.
23 */
24#define ACL_TR_HILO(P, TC, tr0, tr1, lo, hi) \
25 do { \
26 lo = (typeof(lo))_##P##_shuffle_ps((TC)(tr0), (TC)(tr1), 0x88); \
27 hi = (typeof(hi))_##P##_shuffle_ps((TC)(tr0), (TC)(tr1), 0xdd); \
28 } while (0)
29
30/*
31 * Calculate the address of the next transition for
32 * all types of nodes. Note that only DFA nodes and range
33 * nodes actually transition to another node. Match
34 * nodes not supposed to be encountered here.
35 * For quad range nodes:
36 * Calculate number of range boundaries that are less than the
37 * input value. Range boundaries for each node are in signed 8 bit,
38 * ordered from -128 to 127.
39 * This is effectively a popcnt of bytes that are greater than the
40 * input byte.
41 * Single nodes are processed in the same ways as quad range nodes.
42 */
43#define ACL_TR_CALC_ADDR(P, S, addr, index_mask, next_input, shuffle_input, ones_16, range_base, \
44 tr_lo, tr_hi) \
45 do { \
46 \
47 typeof(addr) in, node_type, r, t; \
48 typeof(addr) dfa_msk, dfa_ofs, quad_ofs; \
49 \
50 t = _##P##_xor_si##S(index_mask, index_mask); \
51 in = _##P##_shuffle_epi8(next_input, shuffle_input); \
52 \
53 /* Calc node type and node addr */ \
54 node_type = _##P##_andnot_si##S(index_mask, tr_lo); \
55 addr = _##P##_and_si##S(index_mask, tr_lo); \
56 \
57 /* mask for DFA type(0) nodes */ \
58 dfa_msk = _##P##_cmpeq_epi32(node_type, t); \
59 \
60 /* DFA calculations. */ \
61 r = _##P##_srli_epi32(in, 30); \
62 r = _##P##_add_epi8(r, range_base); \
63 t = _##P##_srli_epi32(in, 24); \
64 r = _##P##_shuffle_epi8(tr_hi, r); \
65 \
66 dfa_ofs = _##P##_sub_epi32(t, r); \
67 \
68 /* QUAD/SINGLE calculations. */ \
69 t = _##P##_cmpgt_epi8(in, tr_hi); \
70 t = _##P##_sign_epi8(t, t); \
71 t = _##P##_maddubs_epi16(t, t); \
72 quad_ofs = _##P##_madd_epi16(t, ones_16); \
73 \
74 /* blend DFA and QUAD/SINGLE. */ \
75 t = _##P##_blendv_epi8(quad_ofs, dfa_ofs, dfa_msk); \
76 \
77 /* calculate address for next transitions. */ \
78 addr = _##P##_add_epi32(addr, t); \
79 } while (0)
80
81#ifdef __cplusplus
82}
83#endif
84
85#endif /* _CNE_ACL_VECT_H_ */