1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Copyright (C) 2018-2020, Intel Corporation. */
3 
4 #ifndef _ICE_ARFS_H_
5 #define _ICE_ARFS_H_
6 enum ice_arfs_fltr_state {
7 	ICE_ARFS_INACTIVE,
8 	ICE_ARFS_ACTIVE,
9 	ICE_ARFS_TODEL,
10 };
11 
12 struct ice_arfs_entry {
13 	struct ice_fdir_fltr fltr_info;
14 	struct hlist_node list_entry;
15 	u64 time_activated;	/* only valid for UDP flows */
16 	u32 flow_id;
17 	/* fltr_state = 0 - ICE_ARFS_INACTIVE:
18 	 *	filter needs to be updated or programmed in HW.
19 	 * fltr_state = 1 - ICE_ARFS_ACTIVE:
20 	 *	filter is active and programmed in HW.
21 	 * fltr_state = 2 - ICE_ARFS_TODEL:
22 	 *	filter has been deleted from HW and needs to be removed from
23 	 *	the aRFS hash table.
24 	 */
25 	u8 fltr_state;
26 };
27 
28 struct ice_arfs_entry_ptr {
29 	struct ice_arfs_entry *arfs_entry;
30 	struct hlist_node list_entry;
31 };
32 
33 struct ice_arfs_active_fltr_cntrs {
34 	atomic_t active_tcpv4_cnt;
35 	atomic_t active_tcpv6_cnt;
36 	atomic_t active_udpv4_cnt;
37 	atomic_t active_udpv6_cnt;
38 };
39 
40 #ifdef CONFIG_RFS_ACCEL
41 int
42 ice_rx_flow_steer(struct net_device *netdev, const struct sk_buff *skb,
43 		  u16 rxq_idx, u32 flow_id);
44 void ice_clear_arfs(struct ice_vsi *vsi);
45 void ice_free_cpu_rx_rmap(struct ice_vsi *vsi);
46 void ice_init_arfs(struct ice_vsi *vsi);
47 void ice_sync_arfs_fltrs(struct ice_pf *pf);
48 int ice_set_cpu_rx_rmap(struct ice_vsi *vsi);
49 void ice_remove_arfs(struct ice_pf *pf);
50 void ice_rebuild_arfs(struct ice_pf *pf);
51 bool
52 ice_is_arfs_using_perfect_flow(struct ice_hw *hw,
53 			       enum ice_fltr_ptype flow_type);
54 #else
55 static inline void ice_clear_arfs(struct ice_vsi *vsi) { }
56 static inline void ice_free_cpu_rx_rmap(struct ice_vsi *vsi) { }
57 static inline void ice_init_arfs(struct ice_vsi *vsi) { }
58 static inline void ice_sync_arfs_fltrs(struct ice_pf *pf) { }
59 static inline void ice_remove_arfs(struct ice_pf *pf) { }
60 static inline void ice_rebuild_arfs(struct ice_pf *pf) { }
61 
62 static inline int ice_set_cpu_rx_rmap(struct ice_vsi __always_unused *vsi)
63 {
64 	return 0;
65 }
66 
67 static inline int
68 ice_rx_flow_steer(struct net_device __always_unused *netdev,
69 		  const struct sk_buff __always_unused *skb,
70 		  u16 __always_unused rxq_idx, u32 __always_unused flow_id)
71 {
72 	return -EOPNOTSUPP;
73 }
74 
75 static inline bool
76 ice_is_arfs_using_perfect_flow(struct ice_hw __always_unused *hw,
77 			       enum ice_fltr_ptype __always_unused flow_type)
78 {
79 	return false;
80 }
81 #endif /* CONFIG_RFS_ACCEL */
82 #endif /* _ICE_ARFS_H_ */
83