1 /* SPDX-License-Identifier: BSD-3-Clause 2 * 3 * Copyright (c) 2023 Advanced Micro Devices, Inc. 4 */ 5 6 #ifndef _SFC_MAE_CONNTRACK_H 7 #define _SFC_MAE_CONNTRACK_H 8 9 #include <stdbool.h> 10 11 #include <rte_ip.h> 12 13 #include "efx.h" 14 15 #include "sfc_tbls.h" 16 17 #ifdef __cplusplus 18 extern "C" { 19 #endif 20 21 typedef struct sfc_mae_conntrack_key_s { 22 uint8_t ip_proto; 23 uint16_t ether_type_le; 24 25 uint16_t src_port_le; 26 uint16_t dst_port_le; 27 28 uint8_t src_addr_le[RTE_SIZEOF_FIELD(struct rte_ipv6_hdr, src_addr)]; 29 uint8_t dst_addr_le[RTE_SIZEOF_FIELD(struct rte_ipv6_hdr, dst_addr)]; 30 } sfc_mae_conntrack_key_t; 31 32 typedef struct sfc_mae_conntrack_nat_s { 33 uint32_t ip_le; 34 uint16_t port_le; 35 bool dir_is_dst; 36 } sfc_mae_conntrack_nat_t; 37 38 typedef struct sfc_mae_conntrack_response_s { 39 uint32_t ct_mark; 40 sfc_mae_conntrack_nat_t nat; 41 uint32_t counter_id; 42 } sfc_mae_conntrack_response_t; 43 44 struct sfc_adapter; 45 46 static inline bool sfc_mae_conntrack_is_supported(struct sfc_adapter * sa)47sfc_mae_conntrack_is_supported(struct sfc_adapter *sa) 48 { 49 return sfc_tbls_id_is_supported(sa, EFX_TABLE_ID_CONNTRACK); 50 } 51 52 static inline const struct sfc_tbl_meta * sfc_mae_conntrack_meta_lookup(struct sfc_adapter * sa)53sfc_mae_conntrack_meta_lookup(struct sfc_adapter *sa) 54 { 55 return sfc_tbl_meta_lookup(sa, EFX_TABLE_ID_CONNTRACK); 56 } 57 58 int sfc_mae_conntrack_insert(struct sfc_adapter *sa, 59 const sfc_mae_conntrack_key_t *key, 60 const sfc_mae_conntrack_response_t *response); 61 62 int sfc_mae_conntrack_delete(struct sfc_adapter *sa, 63 const sfc_mae_conntrack_key_t *key); 64 65 #ifdef __cplusplus 66 } 67 #endif 68 #endif /* _SFC_MAE_CONNTRACK_H */ 69