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