Skip to content

Commit ce1b75d

Browse files
plinga1anguy11
authored andcommitted
idpf: add ptypes and MAC filter support
Add the virtchnl support to request the packet types. Parse the responses received from CP and based on the protocol headers, populate the packet type structure with necessary information. Initialize the MAC address and add the virtchnl support to add and del MAC address. Co-developed-by: Alan Brady <[email protected]> Signed-off-by: Alan Brady <[email protected]> Co-developed-by: Joshua Hay <[email protected]> Signed-off-by: Joshua Hay <[email protected]> Co-developed-by: Madhu Chittim <[email protected]> Signed-off-by: Madhu Chittim <[email protected]> Co-developed-by: Phani Burra <[email protected]> Signed-off-by: Phani Burra <[email protected]> Co-developed-by: Shailendra Bhatnagar <[email protected]> Signed-off-by: Shailendra Bhatnagar <[email protected]> Reviewed-by: Sridhar Samudrala <[email protected]> Reviewed-by: Willem de Bruijn <[email protected]> Signed-off-by: Pavan Kumar Linga <[email protected]> Signed-off-by: Tony Nguyen <[email protected]>
1 parent 0fe4546 commit ce1b75d

File tree

4 files changed

+837
-1
lines changed

4 files changed

+837
-1
lines changed

drivers/net/ethernet/intel/idpf/idpf.h

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ struct idpf_vport_max_q;
2121
#define IDPF_NO_FREE_SLOT 0xffff
2222

2323
/* Default Mailbox settings */
24+
#define IDPF_NUM_FILTERS_PER_MSG 20
2425
#define IDPF_NUM_DFLT_MBX_Q 2 /* includes both TX and RX */
2526
#define IDPF_DFLT_MBX_Q_LEN 64
2627
#define IDPF_DFLT_MBX_ID -1
@@ -37,6 +38,20 @@ struct idpf_vport_max_q;
3738
#define IDPF_VIRTCHNL_VERSION_MAJOR VIRTCHNL2_VERSION_MAJOR_2
3839
#define IDPF_VIRTCHNL_VERSION_MINOR VIRTCHNL2_VERSION_MINOR_0
3940

41+
/**
42+
* struct idpf_mac_filter
43+
* @list: list member field
44+
* @macaddr: MAC address
45+
* @remove: filter should be removed (virtchnl)
46+
* @add: filter should be added (virtchnl)
47+
*/
48+
struct idpf_mac_filter {
49+
struct list_head list;
50+
u8 macaddr[ETH_ALEN];
51+
bool remove;
52+
bool add;
53+
};
54+
4055
/**
4156
* enum idpf_state - State machine to handle bring up
4257
* @__IDPF_STARTUP: Start the state machine
@@ -115,11 +130,17 @@ enum idpf_vport_state {
115130

116131
/**
117132
* struct idpf_netdev_priv - Struct to store vport back pointer
133+
* @adapter: Adapter back pointer
118134
* @vport: Vport back pointer
135+
* @vport_id: Vport identifier
136+
* @vport_idx: Relative vport index
119137
* @state: See enum idpf_vport_state
120138
*/
121139
struct idpf_netdev_priv {
140+
struct idpf_adapter *adapter;
122141
struct idpf_vport *vport;
142+
u32 vport_id;
143+
u16 vport_idx;
123144
enum idpf_vport_state state;
124145
};
125146

@@ -184,6 +205,12 @@ struct idpf_dev_ops {
184205
STATE(IDPF_VC_ALLOC_VECTORS_ERR) \
185206
STATE(IDPF_VC_DEALLOC_VECTORS) \
186207
STATE(IDPF_VC_DEALLOC_VECTORS_ERR) \
208+
STATE(IDPF_VC_ADD_MAC_ADDR) \
209+
STATE(IDPF_VC_ADD_MAC_ADDR_ERR) \
210+
STATE(IDPF_VC_DEL_MAC_ADDR) \
211+
STATE(IDPF_VC_DEL_MAC_ADDR_ERR) \
212+
STATE(IDPF_VC_GET_PTYPE_INFO) \
213+
STATE(IDPF_VC_GET_PTYPE_INFO_ERR) \
187214
STATE(IDPF_VC_NBITS)
188215

189216
#define IDPF_GEN_ENUM(ENUM) ENUM,
@@ -213,13 +240,15 @@ extern const char * const idpf_vport_vc_state_str[];
213240
* @bufq_size: Size of buffers in ring (e.g. 2K, 4K, etc)
214241
* @num_rxq_grp: Number of RX queues in a group
215242
* @rxq_model: Splitq queue or single queue queuing model
243+
* @rx_ptype_lkup: Lookup table for ptypes on RX
216244
* @adapter: back pointer to associated adapter
217245
* @netdev: Associated net_device. Each vport should have one and only one
218246
* associated netdev.
219247
* @vport_type: Default SRIOV, SIOV, etc.
220248
* @vport_id: Device given vport identifier
221249
* @idx: Software index in adapter vports struct
222250
* @default_vport: Use this vport if one isn't specified
251+
* @base_rxd: True if the driver should use base descriptors instead of flex
223252
* @max_mtu: device given max possible MTU
224253
* @default_mac_addr: device will give a default MAC to use
225254
* @vc_msg: Virtchnl message buffer
@@ -242,13 +271,15 @@ struct idpf_vport {
242271
u32 bufq_size[IDPF_MAX_BUFQS_PER_RXQ_GRP];
243272
u16 num_rxq_grp;
244273
u32 rxq_model;
274+
struct idpf_rx_ptype_decoded rx_ptype_lkup[IDPF_RX_MAX_PTYPE];
245275

246276
struct idpf_adapter *adapter;
247277
struct net_device *netdev;
248278
u16 vport_type;
249279
u32 vport_id;
250280
u16 idx;
251281
bool default_vport;
282+
bool base_rxd;
252283

253284
u16 max_mtu;
254285
u8 default_mac_addr[ETH_ALEN];
@@ -269,6 +300,7 @@ struct idpf_vport {
269300
* ethtool
270301
* @num_req_rxq_desc: Number of user requested RX queue descriptors through
271302
* ethtool
303+
* @mac_filter_list: List of MAC filters
272304
*
273305
* Used to restore configuration after a reset as the vport will get wiped.
274306
*/
@@ -277,17 +309,22 @@ struct idpf_vport_user_config_data {
277309
u16 num_req_rx_qs;
278310
u32 num_req_txq_desc;
279311
u32 num_req_rxq_desc;
312+
struct list_head mac_filter_list;
280313
};
281314

282315
/**
283316
* enum idpf_vport_config_flags - Vport config flags
284317
* @IDPF_VPORT_REG_NETDEV: Register netdev
285318
* @IDPF_VPORT_UP_REQUESTED: Set if interface up is requested on core reset
319+
* @IDPF_VPORT_ADD_MAC_REQ: Asynchronous add ether address in flight
320+
* @IDPF_VPORT_DEL_MAC_REQ: Asynchronous delete ether address in flight
286321
* @IDPF_VPORT_CONFIG_FLAGS_NBITS: Must be last
287322
*/
288323
enum idpf_vport_config_flags {
289324
IDPF_VPORT_REG_NETDEV,
290325
IDPF_VPORT_UP_REQUESTED,
326+
IDPF_VPORT_ADD_MAC_REQ,
327+
IDPF_VPORT_DEL_MAC_REQ,
291328
IDPF_VPORT_CONFIG_FLAGS_NBITS,
292329
};
293330

@@ -335,11 +372,13 @@ struct idpf_vector_lifo {
335372
* struct idpf_vport_config - Vport configuration data
336373
* @user_config: see struct idpf_vport_user_config_data
337374
* @max_q: Maximum possible queues
375+
* @mac_filter_list_lock: Lock to protect mac filters
338376
* @flags: See enum idpf_vport_config_flags
339377
*/
340378
struct idpf_vport_config {
341379
struct idpf_vport_user_config_data user_config;
342380
struct idpf_vport_max_q max_q;
381+
spinlock_t mac_filter_list_lock;
343382
DECLARE_BITMAP(flags, IDPF_VPORT_CONFIG_FLAGS_NBITS);
344383
};
345384

@@ -592,6 +631,7 @@ void idpf_vc_core_deinit(struct idpf_adapter *adapter);
592631
int idpf_intr_req(struct idpf_adapter *adapter);
593632
void idpf_intr_rel(struct idpf_adapter *adapter);
594633
int idpf_send_destroy_vport_msg(struct idpf_vport *vport);
634+
int idpf_send_get_rx_ptype_msg(struct idpf_vport *vport);
595635
int idpf_send_dealloc_vectors_msg(struct idpf_adapter *adapter);
596636
int idpf_send_alloc_vectors_msg(struct idpf_adapter *adapter, u16 num_vectors);
597637
void idpf_deinit_task(struct idpf_adapter *adapter);
@@ -606,9 +646,13 @@ int idpf_vport_alloc_max_qs(struct idpf_adapter *adapter,
606646
struct idpf_vport_max_q *max_q);
607647
void idpf_vport_dealloc_max_qs(struct idpf_adapter *adapter,
608648
struct idpf_vport_max_q *max_q);
649+
int idpf_add_del_mac_filters(struct idpf_vport *vport,
650+
struct idpf_netdev_priv *np,
651+
bool add, bool async);
609652
void idpf_vport_init(struct idpf_vport *vport, struct idpf_vport_max_q *max_q);
610653
u32 idpf_get_vport_id(struct idpf_vport *vport);
611654
int idpf_send_create_vport_msg(struct idpf_adapter *adapter,
612655
struct idpf_vport_max_q *max_q);
656+
int idpf_check_supported_desc_ids(struct idpf_vport *vport);
613657

614658
#endif /* !_IDPF_H_ */

0 commit comments

Comments
 (0)