1 /* SPDX-License-Identifier: GPL-2.0-only */ 2 /**************************************************************************** 3 * Driver for Solarflare network controllers and boards 4 * Copyright 2023, Advanced Micro Devices, Inc. 5 * 6 * This program is free software; you can redistribute it and/or modify it 7 * under the terms of the GNU General Public License version 2 as published 8 * by the Free Software Foundation, incorporated herein by reference. 9 */ 10 11 #ifndef EFX_TC_CONNTRACK_H 12 #define EFX_TC_CONNTRACK_H 13 #include "net_driver.h" 14 15 #if IS_ENABLED(CONFIG_SFC_SRIOV) 16 #include <linux/refcount.h> 17 #include <net/netfilter/nf_flow_table.h> 18 19 struct efx_tc_ct_zone { 20 u16 zone; 21 struct rhash_head linkage; 22 refcount_t ref; 23 struct nf_flowtable *nf_ft; 24 struct efx_nic *efx; 25 struct mutex mutex; /* protects cts list */ 26 struct list_head cts; /* list of efx_tc_ct_entry in this zone */ 27 }; 28 29 /* create/uncreate/teardown hashtables */ 30 int efx_tc_init_conntrack(struct efx_nic *efx); 31 void efx_tc_destroy_conntrack(struct efx_nic *efx); 32 void efx_tc_fini_conntrack(struct efx_nic *efx); 33 34 struct efx_tc_ct_zone *efx_tc_ct_register_zone(struct efx_nic *efx, u16 zone, 35 struct nf_flowtable *ct_ft); 36 void efx_tc_ct_unregister_zone(struct efx_nic *efx, 37 struct efx_tc_ct_zone *ct_zone); 38 39 struct efx_tc_ct_entry { 40 unsigned long cookie; 41 struct rhash_head linkage; 42 __be16 eth_proto; 43 u8 ip_proto; 44 bool dnat; 45 __be32 src_ip, dst_ip, nat_ip; 46 struct in6_addr src_ip6, dst_ip6; 47 __be16 l4_sport, l4_dport, l4_natport; /* Ports (UDP, TCP) */ 48 struct efx_tc_ct_zone *zone; 49 u32 mark; 50 struct efx_tc_counter *cnt; 51 struct list_head list; /* entry on zone->cts */ 52 }; 53 54 #endif /* CONFIG_SFC_SRIOV */ 55 #endif /* EFX_TC_CONNTRACK_H */ 56