Skip to content

Commit 0075fa0

Browse files
hramamu1Jeff Kirsher
authored andcommitted
i40evf: Add support to apply cloud filters
This patch enables a tc filter to be applied as a cloud filter for the VF. This patch adds functions which parse the tc filter, extract the necessary fields needed to configure the filter and package them in a virtchnl message to be sent to the PF to apply them. Signed-off-by: Harshitha Ramamurthy <[email protected]> Tested-by: Andrew Bowers <[email protected]> Signed-off-by: Jeff Kirsher <[email protected]>
1 parent 3872c8d commit 0075fa0

File tree

3 files changed

+810
-5
lines changed

3 files changed

+810
-5
lines changed

drivers/net/ethernet/intel/i40evf/i40evf.h

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@
5454
#include <net/ip6_checksum.h>
5555
#include <net/pkt_cls.h>
5656
#include <net/udp.h>
57+
#include <net/tc_act/tc_gact.h>
58+
#include <net/tc_act/tc_mirred.h>
5759

5860
#include "i40e_type.h"
5961
#include <linux/avf/virtchnl.h>
@@ -184,6 +186,14 @@ struct i40evf_channel_config {
184186
u8 total_qps;
185187
};
186188

189+
/* State of cloud filter */
190+
enum i40evf_cloud_filter_state_t {
191+
__I40EVF_CF_INVALID, /* cloud filter not added */
192+
__I40EVF_CF_ADD_PENDING, /* cloud filter pending add by the PF */
193+
__I40EVF_CF_DEL_PENDING, /* cloud filter pending del by the PF */
194+
__I40EVF_CF_ACTIVE, /* cloud filter is active */
195+
};
196+
187197
/* Driver state. The order of these is important! */
188198
enum i40evf_state_t {
189199
__I40EVF_STARTUP, /* driver loaded, probe complete */
@@ -205,6 +215,36 @@ enum i40evf_critical_section_t {
205215
__I40EVF_IN_REMOVE_TASK, /* device being removed */
206216
};
207217

218+
#define I40EVF_CLOUD_FIELD_OMAC 0x01
219+
#define I40EVF_CLOUD_FIELD_IMAC 0x02
220+
#define I40EVF_CLOUD_FIELD_IVLAN 0x04
221+
#define I40EVF_CLOUD_FIELD_TEN_ID 0x08
222+
#define I40EVF_CLOUD_FIELD_IIP 0x10
223+
224+
#define I40EVF_CF_FLAGS_OMAC I40EVF_CLOUD_FIELD_OMAC
225+
#define I40EVF_CF_FLAGS_IMAC I40EVF_CLOUD_FIELD_IMAC
226+
#define I40EVF_CF_FLAGS_IMAC_IVLAN (I40EVF_CLOUD_FIELD_IMAC |\
227+
I40EVF_CLOUD_FIELD_IVLAN)
228+
#define I40EVF_CF_FLAGS_IMAC_TEN_ID (I40EVF_CLOUD_FIELD_IMAC |\
229+
I40EVF_CLOUD_FIELD_TEN_ID)
230+
#define I40EVF_CF_FLAGS_OMAC_TEN_ID_IMAC (I40EVF_CLOUD_FIELD_OMAC |\
231+
I40EVF_CLOUD_FIELD_IMAC |\
232+
I40EVF_CLOUD_FIELD_TEN_ID)
233+
#define I40EVF_CF_FLAGS_IMAC_IVLAN_TEN_ID (I40EVF_CLOUD_FIELD_IMAC |\
234+
I40EVF_CLOUD_FIELD_IVLAN |\
235+
I40EVF_CLOUD_FIELD_TEN_ID)
236+
#define I40EVF_CF_FLAGS_IIP I40E_CLOUD_FIELD_IIP
237+
238+
/* bookkeeping of cloud filters */
239+
struct i40evf_cloud_filter {
240+
enum i40evf_cloud_filter_state_t state;
241+
struct list_head list;
242+
struct virtchnl_filter f;
243+
unsigned long cookie;
244+
bool del; /* filter needs to be deleted */
245+
bool add; /* filter needs to be added */
246+
};
247+
208248
/* board specific private data structure */
209249
struct i40evf_adapter {
210250
struct timer_list watchdog_timer;
@@ -287,6 +327,8 @@ struct i40evf_adapter {
287327
#define I40EVF_FLAG_AQ_DISABLE_VLAN_STRIPPING BIT(20)
288328
#define I40EVF_FLAG_AQ_ENABLE_CHANNELS BIT(21)
289329
#define I40EVF_FLAG_AQ_DISABLE_CHANNELS BIT(22)
330+
#define I40EVF_FLAG_AQ_ADD_CLOUD_FILTER BIT(23)
331+
#define I40EVF_FLAG_AQ_DEL_CLOUD_FILTER BIT(24)
290332

291333
/* OS defined structs */
292334
struct net_device *netdev;
@@ -335,6 +377,10 @@ struct i40evf_adapter {
335377
/* ADQ related members */
336378
struct i40evf_channel_config ch_config;
337379
u8 num_tc;
380+
struct list_head cloud_filter_list;
381+
/* lock to protest access to the cloud filter list */
382+
spinlock_t cloud_filter_list_lock;
383+
u16 num_cloud_filters;
338384
};
339385

340386

@@ -403,4 +449,6 @@ void i40evf_notify_client_open(struct i40e_vsi *vsi);
403449
void i40evf_notify_client_close(struct i40e_vsi *vsi, bool reset);
404450
void i40evf_enable_channels(struct i40evf_adapter *adapter);
405451
void i40evf_disable_channels(struct i40evf_adapter *adapter);
452+
void i40evf_add_cloud_filter(struct i40evf_adapter *adapter);
453+
void i40evf_del_cloud_filter(struct i40evf_adapter *adapter);
406454
#endif /* _I40EVF_H_ */

0 commit comments

Comments
 (0)