diff options
author | Govindarajulu Varadarajan <_govind@gmx.com> | 2014-07-21 07:52:17 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-07-21 23:22:46 -0400 |
commit | e3e5af33e6d64a36bce1dfd9f599649f539801de (patch) | |
tree | 7c3c462982a83816159bc50007b8a5c803bde135 /drivers | |
parent | 1042cab8627a2d11491e8b0dd40c4dda3180285a (diff) |
enic: remove #ifdef CONFIG_RFS_ACCEL around filter structures
This patch removes the #ifdef CONFIG_RFS_ACCEL around the classifier filter
structures. This makes the filter structures available when CONFIG_RFS_ACCEL = n.
Introduce enic_rfs_timer_start() & enic_rfs_timer_stop() to start/stop the
timer. These two functions are nop when CONFIG_RFS_ACCEL = n.
Signed-off-by: Govindarajulu Varadarajan <_govind@gmx.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/ethernet/cisco/enic/enic.h | 5 | ||||
-rw-r--r-- | drivers/net/ethernet/cisco/enic/enic_clsf.c | 69 | ||||
-rw-r--r-- | drivers/net/ethernet/cisco/enic/enic_clsf.h | 22 |
3 files changed, 51 insertions, 45 deletions
diff --git a/drivers/net/ethernet/cisco/enic/enic.h b/drivers/net/ethernet/cisco/enic/enic.h index 4ecbbb3c024a..962510f391df 100644 --- a/drivers/net/ethernet/cisco/enic/enic.h +++ b/drivers/net/ethernet/cisco/enic/enic.h | |||
@@ -99,7 +99,6 @@ struct enic_port_profile { | |||
99 | u8 mac_addr[ETH_ALEN]; | 99 | u8 mac_addr[ETH_ALEN]; |
100 | }; | 100 | }; |
101 | 101 | ||
102 | #ifdef CONFIG_RFS_ACCEL | ||
103 | /* enic_rfs_fltr_node - rfs filter node in hash table | 102 | /* enic_rfs_fltr_node - rfs filter node in hash table |
104 | * @@keys: IPv4 5 tuple | 103 | * @@keys: IPv4 5 tuple |
105 | * @flow_id: flow_id of clsf filter provided by kernel | 104 | * @flow_id: flow_id of clsf filter provided by kernel |
@@ -135,8 +134,6 @@ struct enic_rfs_flw_tbl { | |||
135 | struct timer_list rfs_may_expire; | 134 | struct timer_list rfs_may_expire; |
136 | }; | 135 | }; |
137 | 136 | ||
138 | #endif /* CONFIG_RFS_ACCEL */ | ||
139 | |||
140 | /* Per-instance private data structure */ | 137 | /* Per-instance private data structure */ |
141 | struct enic { | 138 | struct enic { |
142 | struct net_device *netdev; | 139 | struct net_device *netdev; |
@@ -188,9 +185,7 @@ struct enic { | |||
188 | /* completion queue cache line section */ | 185 | /* completion queue cache line section */ |
189 | ____cacheline_aligned struct vnic_cq cq[ENIC_CQ_MAX]; | 186 | ____cacheline_aligned struct vnic_cq cq[ENIC_CQ_MAX]; |
190 | unsigned int cq_count; | 187 | unsigned int cq_count; |
191 | #ifdef CONFIG_RFS_ACCEL | ||
192 | struct enic_rfs_flw_tbl rfs_h; | 188 | struct enic_rfs_flw_tbl rfs_h; |
193 | #endif | ||
194 | }; | 189 | }; |
195 | 190 | ||
196 | static inline struct device *enic_get_dev(struct enic *enic) | 191 | static inline struct device *enic_get_dev(struct enic *enic) |
diff --git a/drivers/net/ethernet/cisco/enic/enic_clsf.c b/drivers/net/ethernet/cisco/enic/enic_clsf.c index bc451baac4cd..ee6acbf02ef0 100644 --- a/drivers/net/ethernet/cisco/enic/enic_clsf.c +++ b/drivers/net/ethernet/cisco/enic/enic_clsf.c | |||
@@ -65,37 +65,6 @@ int enic_delfltr(struct enic *enic, u16 filter_id) | |||
65 | return ret; | 65 | return ret; |
66 | } | 66 | } |
67 | 67 | ||
68 | #ifdef CONFIG_RFS_ACCEL | ||
69 | void enic_flow_may_expire(unsigned long data) | ||
70 | { | ||
71 | struct enic *enic = (struct enic *)data; | ||
72 | bool res; | ||
73 | int j; | ||
74 | |||
75 | spin_lock(&enic->rfs_h.lock); | ||
76 | for (j = 0; j < ENIC_CLSF_EXPIRE_COUNT; j++) { | ||
77 | struct hlist_head *hhead; | ||
78 | struct hlist_node *tmp; | ||
79 | struct enic_rfs_fltr_node *n; | ||
80 | |||
81 | hhead = &enic->rfs_h.ht_head[enic->rfs_h.toclean++]; | ||
82 | hlist_for_each_entry_safe(n, tmp, hhead, node) { | ||
83 | res = rps_may_expire_flow(enic->netdev, n->rq_id, | ||
84 | n->flow_id, n->fltr_id); | ||
85 | if (res) { | ||
86 | res = enic_delfltr(enic, n->fltr_id); | ||
87 | if (unlikely(res)) | ||
88 | continue; | ||
89 | hlist_del(&n->node); | ||
90 | kfree(n); | ||
91 | enic->rfs_h.free++; | ||
92 | } | ||
93 | } | ||
94 | } | ||
95 | spin_unlock(&enic->rfs_h.lock); | ||
96 | mod_timer(&enic->rfs_h.rfs_may_expire, jiffies + HZ/4); | ||
97 | } | ||
98 | |||
99 | /* enic_rfs_flw_tbl_init - initialize enic->rfs_h members | 68 | /* enic_rfs_flw_tbl_init - initialize enic->rfs_h members |
100 | * @enic: enic data | 69 | * @enic: enic data |
101 | */ | 70 | */ |
@@ -109,17 +78,14 @@ void enic_rfs_flw_tbl_init(struct enic *enic) | |||
109 | enic->rfs_h.max = enic->config.num_arfs; | 78 | enic->rfs_h.max = enic->config.num_arfs; |
110 | enic->rfs_h.free = enic->rfs_h.max; | 79 | enic->rfs_h.free = enic->rfs_h.max; |
111 | enic->rfs_h.toclean = 0; | 80 | enic->rfs_h.toclean = 0; |
112 | init_timer(&enic->rfs_h.rfs_may_expire); | 81 | enic_rfs_timer_start(enic); |
113 | enic->rfs_h.rfs_may_expire.function = enic_flow_may_expire; | ||
114 | enic->rfs_h.rfs_may_expire.data = (unsigned long)enic; | ||
115 | mod_timer(&enic->rfs_h.rfs_may_expire, jiffies + HZ/4); | ||
116 | } | 82 | } |
117 | 83 | ||
118 | void enic_rfs_flw_tbl_free(struct enic *enic) | 84 | void enic_rfs_flw_tbl_free(struct enic *enic) |
119 | { | 85 | { |
120 | int i; | 86 | int i; |
121 | 87 | ||
122 | del_timer_sync(&enic->rfs_h.rfs_may_expire); | 88 | enic_rfs_timer_stop(enic); |
123 | spin_lock(&enic->rfs_h.lock); | 89 | spin_lock(&enic->rfs_h.lock); |
124 | enic->rfs_h.free = 0; | 90 | enic->rfs_h.free = 0; |
125 | for (i = 0; i < (1 << ENIC_RFS_FLW_BITSHIFT); i++) { | 91 | for (i = 0; i < (1 << ENIC_RFS_FLW_BITSHIFT); i++) { |
@@ -137,6 +103,37 @@ void enic_rfs_flw_tbl_free(struct enic *enic) | |||
137 | spin_unlock(&enic->rfs_h.lock); | 103 | spin_unlock(&enic->rfs_h.lock); |
138 | } | 104 | } |
139 | 105 | ||
106 | #ifdef CONFIG_RFS_ACCEL | ||
107 | void enic_flow_may_expire(unsigned long data) | ||
108 | { | ||
109 | struct enic *enic = (struct enic *)data; | ||
110 | bool res; | ||
111 | int j; | ||
112 | |||
113 | spin_lock(&enic->rfs_h.lock); | ||
114 | for (j = 0; j < ENIC_CLSF_EXPIRE_COUNT; j++) { | ||
115 | struct hlist_head *hhead; | ||
116 | struct hlist_node *tmp; | ||
117 | struct enic_rfs_fltr_node *n; | ||
118 | |||
119 | hhead = &enic->rfs_h.ht_head[enic->rfs_h.toclean++]; | ||
120 | hlist_for_each_entry_safe(n, tmp, hhead, node) { | ||
121 | res = rps_may_expire_flow(enic->netdev, n->rq_id, | ||
122 | n->flow_id, n->fltr_id); | ||
123 | if (res) { | ||
124 | res = enic_delfltr(enic, n->fltr_id); | ||
125 | if (unlikely(res)) | ||
126 | continue; | ||
127 | hlist_del(&n->node); | ||
128 | kfree(n); | ||
129 | enic->rfs_h.free++; | ||
130 | } | ||
131 | } | ||
132 | } | ||
133 | spin_unlock(&enic->rfs_h.lock); | ||
134 | mod_timer(&enic->rfs_h.rfs_may_expire, jiffies + HZ/4); | ||
135 | } | ||
136 | |||
140 | static struct enic_rfs_fltr_node *htbl_key_search(struct hlist_head *h, | 137 | static struct enic_rfs_fltr_node *htbl_key_search(struct hlist_head *h, |
141 | struct flow_keys *k) | 138 | struct flow_keys *k) |
142 | { | 139 | { |
diff --git a/drivers/net/ethernet/cisco/enic/enic_clsf.h b/drivers/net/ethernet/cisco/enic/enic_clsf.h index d572704cd117..221f364cd811 100644 --- a/drivers/net/ethernet/cisco/enic/enic_clsf.h +++ b/drivers/net/ethernet/cisco/enic/enic_clsf.h | |||
@@ -8,15 +8,29 @@ | |||
8 | 8 | ||
9 | int enic_addfltr_5t(struct enic *enic, struct flow_keys *keys, u16 rq); | 9 | int enic_addfltr_5t(struct enic *enic, struct flow_keys *keys, u16 rq); |
10 | int enic_delfltr(struct enic *enic, u16 filter_id); | 10 | int enic_delfltr(struct enic *enic, u16 filter_id); |
11 | |||
12 | #ifdef CONFIG_RFS_ACCEL | ||
13 | void enic_rfs_flw_tbl_init(struct enic *enic); | 11 | void enic_rfs_flw_tbl_init(struct enic *enic); |
14 | void enic_rfs_flw_tbl_free(struct enic *enic); | 12 | void enic_rfs_flw_tbl_free(struct enic *enic); |
13 | |||
14 | #ifdef CONFIG_RFS_ACCEL | ||
15 | int enic_rx_flow_steer(struct net_device *dev, const struct sk_buff *skb, | 15 | int enic_rx_flow_steer(struct net_device *dev, const struct sk_buff *skb, |
16 | u16 rxq_index, u32 flow_id); | 16 | u16 rxq_index, u32 flow_id); |
17 | void enic_flow_may_expire(unsigned long data); | ||
18 | |||
19 | static inline void enic_rfs_timer_start(struct enic *enic) | ||
20 | { | ||
21 | init_timer(&enic->rfs_h.rfs_may_expire); | ||
22 | enic->rfs_h.rfs_may_expire.function = enic_flow_may_expire; | ||
23 | enic->rfs_h.rfs_may_expire.data = (unsigned long)enic; | ||
24 | mod_timer(&enic->rfs_h.rfs_may_expire, jiffies + HZ/4); | ||
25 | } | ||
26 | |||
27 | static inline void enic_rfs_timer_stop(struct enic *enic) | ||
28 | { | ||
29 | del_timer_sync(&enic->rfs_h.rfs_may_expire); | ||
30 | } | ||
17 | #else | 31 | #else |
18 | static inline void enic_rfs_flw_tbl_init(struct enic *enic) {} | 32 | static inline void enic_rfs_timer_start(struct enic *enic) {} |
19 | static inline void enic_rfs_flw_tbl_free(struct enic *enic) {} | 33 | static inline void enic_rfs_timer_stop(struct enic *enic) {} |
20 | #endif /* CONFIG_RFS_ACCEL */ | 34 | #endif /* CONFIG_RFS_ACCEL */ |
21 | 35 | ||
22 | #endif /* _ENIC_CLSF_H_ */ | 36 | #endif /* _ENIC_CLSF_H_ */ |