0001
0002
0003
0004 #ifndef __NFP_FLOWER_CONNTRACK_H__
0005 #define __NFP_FLOWER_CONNTRACK_H__ 1
0006
0007 #include <net/netfilter/nf_flow_table.h>
0008 #include "main.h"
0009
0010 #define NFP_FL_CT_NO_TUN 0xff
0011
0012 #define COMPARE_UNMASKED_FIELDS(__match1, __match2, __out) \
0013 do { \
0014 typeof(__match1) _match1 = (__match1); \
0015 typeof(__match2) _match2 = (__match2); \
0016 bool *_out = (__out); \
0017 int i, size = sizeof(*(_match1).key); \
0018 char *k1, *m1, *k2, *m2; \
0019 *_out = false; \
0020 k1 = (char *)_match1.key; \
0021 m1 = (char *)_match1.mask; \
0022 k2 = (char *)_match2.key; \
0023 m2 = (char *)_match2.mask; \
0024 for (i = 0; i < size; i++) \
0025 if ((k1[i] & m1[i] & m2[i]) ^ \
0026 (k2[i] & m1[i] & m2[i])) { \
0027 *_out = true; \
0028 break; \
0029 } \
0030 } while (0) \
0031
0032 extern const struct rhashtable_params nfp_zone_table_params;
0033 extern const struct rhashtable_params nfp_ct_map_params;
0034 extern const struct rhashtable_params nfp_tc_ct_merge_params;
0035 extern const struct rhashtable_params nfp_nft_ct_merge_params;
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059 struct nfp_fl_ct_zone_entry {
0060 u16 zone;
0061 struct rhash_head hash_node;
0062
0063 struct nfp_flower_priv *priv;
0064 struct nf_flowtable *nft;
0065
0066 struct list_head pre_ct_list;
0067 unsigned int pre_ct_count;
0068
0069 struct list_head post_ct_list;
0070 unsigned int post_ct_count;
0071
0072 struct rhashtable tc_merge_tb;
0073 unsigned int tc_merge_count;
0074
0075 struct list_head nft_flows_list;
0076 unsigned int nft_flows_count;
0077
0078 struct rhashtable nft_merge_tb;
0079 unsigned int nft_merge_count;
0080 };
0081
0082 enum ct_entry_type {
0083 CT_TYPE_PRE_CT,
0084 CT_TYPE_NFT,
0085 CT_TYPE_POST_CT,
0086 _CT_TYPE_MAX,
0087 };
0088
0089 enum nfp_nfp_layer_name {
0090 FLOW_PAY_META_TCI = 0,
0091 FLOW_PAY_INPORT,
0092 FLOW_PAY_EXT_META,
0093 FLOW_PAY_MAC_MPLS,
0094 FLOW_PAY_L4,
0095 FLOW_PAY_IPV4,
0096 FLOW_PAY_IPV6,
0097 FLOW_PAY_CT,
0098 FLOW_PAY_GRE,
0099 FLOW_PAY_QINQ,
0100 FLOW_PAY_UDP_TUN,
0101 FLOW_PAY_GENEVE_OPT,
0102
0103 _FLOW_PAY_LAYERS_MAX
0104 };
0105
0106
0107
0108
0109
0110
0111
0112
0113
0114
0115
0116
0117
0118
0119 struct nfp_fl_ct_flow_entry {
0120 unsigned long cookie;
0121 struct list_head list_node;
0122 u32 chain_index;
0123 enum ct_entry_type type;
0124 struct net_device *netdev;
0125 struct nfp_fl_ct_zone_entry *zt;
0126 struct list_head children;
0127 struct flow_rule *rule;
0128 struct flow_stats stats;
0129 u8 tun_offset;
0130 };
0131
0132
0133
0134
0135
0136
0137
0138
0139
0140
0141
0142
0143 struct nfp_fl_ct_tc_merge {
0144 unsigned long cookie[2];
0145 struct rhash_head hash_node;
0146 struct list_head pre_ct_list;
0147 struct list_head post_ct_list;
0148 struct nfp_fl_ct_zone_entry *zt;
0149 struct nfp_fl_ct_flow_entry *pre_ct_parent;
0150 struct nfp_fl_ct_flow_entry *post_ct_parent;
0151 struct list_head children;
0152 };
0153
0154
0155
0156
0157
0158
0159
0160
0161
0162
0163
0164
0165
0166
0167 struct nfp_fl_nft_tc_merge {
0168 struct net_device *netdev;
0169 unsigned long cookie[3];
0170 struct rhash_head hash_node;
0171 struct nfp_fl_ct_zone_entry *zt;
0172 struct list_head nft_flow_list;
0173 struct list_head tc_merge_list;
0174 struct nfp_fl_ct_tc_merge *tc_m_parent;
0175 struct nfp_fl_ct_flow_entry *nft_parent;
0176 unsigned long tc_flower_cookie;
0177 struct nfp_fl_payload *flow_pay;
0178 };
0179
0180
0181
0182
0183
0184
0185
0186 struct nfp_fl_ct_map_entry {
0187 unsigned long cookie;
0188 struct rhash_head hash_node;
0189 struct nfp_fl_ct_flow_entry *ct_entry;
0190 };
0191
0192 bool is_pre_ct_flow(struct flow_cls_offload *flow);
0193 bool is_post_ct_flow(struct flow_cls_offload *flow);
0194
0195
0196
0197
0198
0199
0200
0201
0202
0203
0204
0205
0206
0207 int nfp_fl_ct_handle_pre_ct(struct nfp_flower_priv *priv,
0208 struct net_device *netdev,
0209 struct flow_cls_offload *flow,
0210 struct netlink_ext_ack *extack);
0211
0212
0213
0214
0215
0216
0217
0218
0219
0220
0221
0222
0223 int nfp_fl_ct_handle_post_ct(struct nfp_flower_priv *priv,
0224 struct net_device *netdev,
0225 struct flow_cls_offload *flow,
0226 struct netlink_ext_ack *extack);
0227
0228
0229
0230
0231
0232 void nfp_fl_ct_clean_flow_entry(struct nfp_fl_ct_flow_entry *entry);
0233
0234
0235
0236
0237
0238 int nfp_fl_ct_del_flow(struct nfp_fl_ct_map_entry *ct_map_ent);
0239
0240
0241
0242
0243
0244
0245
0246
0247 int nfp_fl_ct_handle_nft_flow(enum tc_setup_type type, void *type_data,
0248 void *cb_priv);
0249
0250
0251
0252
0253
0254
0255 int nfp_fl_ct_stats(struct flow_cls_offload *flow,
0256 struct nfp_fl_ct_map_entry *ct_map_ent);
0257 #endif