1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2019 Intel Corporation
5 #ifndef _IPN3KE_FLOW_H_
6 #define _IPN3KE_FLOW_H_
9 * Expand the length to DWORD alignment with 'Unused' field.
12 * | Unused |Ruler id (id) | Key1 Key2 … (data) |
13 * |--------+---------------+--------------------|
14 * | 17bits | 3 bits | Total 108 bits |
17 * Note: And the MSb of key data is filled to 0 when it is less
20 #define IPN3KE_FLOW_KEY_UNUSED_BITS 17
21 #define IPN3KE_FLOW_KEY_ID_BITS 3
22 #define IPN3KE_FLOW_KEY_DATA_BITS 108
24 #define IPN3KE_FLOW_KEY_TOTAL_BITS \
25 (IPN3KE_FLOW_KEY_UNUSED_BITS + \
26 IPN3KE_FLOW_KEY_ID_BITS + \
27 IPN3KE_FLOW_KEY_DATA_BITS)
29 #define IPN3KE_FLOW_KEY_ID_OFFSET \
30 (IPN3KE_FLOW_KEY_UNUSED_BITS)
32 #define IPN3KE_FLOW_KEY_DATA_OFFSET \
33 (IPN3KE_FLOW_KEY_ID_OFFSET + IPN3KE_FLOW_KEY_ID_BITS)
36 * Expand the length to DWORD alignment with 'Unused' field.
39 * | Unused | enable (acl) | uid |
40 * |---------+--------------+--------------|
41 * | 15 bits | 1 bit | 16 bits |
45 #define IPN3KE_FLOW_RESULT_UNUSED_BITS 15
46 #define IPN3KE_FLOW_RESULT_ACL_BITS 1
47 #define IPN3KE_FLOW_RESULT_UID_BITS 16
49 #define IPN3KE_FLOW_RESULT_TOTAL_BITS \
50 (IPN3KE_FLOW_RESULT_UNUSED_BITS + \
51 IPN3KE_FLOW_RESULT_ACL_BITS + \
52 IPN3KE_FLOW_RESULT_UID_BITS)
54 #define IPN3KE_FLOW_RESULT_ACL_OFFSET \
55 (IPN3KE_FLOW_RESULT_UNUSED_BITS)
57 #define IPN3KE_FLOW_RESULT_UID_OFFSET \
58 (IPN3KE_FLOW_RESULT_ACL_OFFSET + IPN3KE_FLOW_RESULT_ACL_BITS)
60 #define IPN3KE_FLOW_RESULT_UID_MAX \
61 ((1UL << IPN3KE_FLOW_RESULT_UID_BITS) - 1)
64 #define BITS_PER_BYTE 8
66 #define BITS_TO_BYTES(bits) \
67 (((bits) + BITS_PER_BYTE - 1) / BITS_PER_BYTE)
69 struct ipn3ke_flow_rule {
70 uint8_t key[BITS_TO_BYTES(IPN3KE_FLOW_KEY_TOTAL_BITS)];
71 uint8_t result[BITS_TO_BYTES(IPN3KE_FLOW_RESULT_TOTAL_BITS)];
75 TAILQ_ENTRY(rte_flow) next; /**< Pointer to the next flow structure. */
77 struct ipn3ke_flow_rule rule;
80 TAILQ_HEAD(ipn3ke_flow_list, rte_flow);
82 static inline uint16_t ipn3ke_swap16(uint16_t x)
84 return ((x & 0xff) << 8) | ((x >> 8) & 0xff);
87 static inline uint32_t ipn3ke_swap32(uint32_t x)
92 high = (x >> 16) & 0xffff;
94 high1 = ipn3ke_swap16(low);
96 low1 = ipn3ke_swap16(high);
102 extern const struct rte_flow_ops ipn3ke_flow_ops;
104 int ipn3ke_flow_init(void *dev);
106 #endif /* _IPN3KE_FLOW_H_ */