Linux Audio

Check our new training course

Open-source upstreaming

Need help get the support for your hardware in upstream Linux?
Loading...
v6.9.4
  1/* SPDX-License-Identifier: GPL-2.0 */
  2/* Copyright (c) 2021, Intel Corporation. */
  3
  4#ifndef _IAVF_FDIR_H_
  5#define _IAVF_FDIR_H_
  6
  7struct iavf_adapter;
  8
  9/* State of Flow Director filter
 10 *
 11 * *_REQUEST states are used to mark filter to be sent to PF driver to perform
 12 * an action (either add or delete filter). *_PENDING states are an indication
 13 * that request was sent to PF and the driver is waiting for response.
 14 *
 15 * Both DELETE and DISABLE states are being used to delete a filter in PF.
 16 * The difference is that after a successful response filter in DEL_PENDING
 17 * state is being deleted from VF driver as well and filter in DIS_PENDING state
 18 * is being changed to INACTIVE state.
 19 */
 20enum iavf_fdir_fltr_state_t {
 21	IAVF_FDIR_FLTR_ADD_REQUEST,	/* User requests to add filter */
 22	IAVF_FDIR_FLTR_ADD_PENDING,	/* Filter pending add by the PF */
 23	IAVF_FDIR_FLTR_DEL_REQUEST,	/* User requests to delete filter */
 24	IAVF_FDIR_FLTR_DEL_PENDING,	/* Filter pending delete by the PF */
 25	IAVF_FDIR_FLTR_DIS_REQUEST,	/* Filter scheduled to be disabled */
 26	IAVF_FDIR_FLTR_DIS_PENDING,	/* Filter pending disable by the PF */
 27	IAVF_FDIR_FLTR_INACTIVE,	/* Filter inactive on link down */
 28	IAVF_FDIR_FLTR_ACTIVE,		/* Filter is active */
 29};
 30
 31enum iavf_fdir_flow_type {
 32	/* NONE - used for undef/error */
 33	IAVF_FDIR_FLOW_NONE = 0,
 34	IAVF_FDIR_FLOW_IPV4_TCP,
 35	IAVF_FDIR_FLOW_IPV4_UDP,
 36	IAVF_FDIR_FLOW_IPV4_SCTP,
 37	IAVF_FDIR_FLOW_IPV4_AH,
 38	IAVF_FDIR_FLOW_IPV4_ESP,
 39	IAVF_FDIR_FLOW_IPV4_OTHER,
 40	IAVF_FDIR_FLOW_IPV6_TCP,
 41	IAVF_FDIR_FLOW_IPV6_UDP,
 42	IAVF_FDIR_FLOW_IPV6_SCTP,
 43	IAVF_FDIR_FLOW_IPV6_AH,
 44	IAVF_FDIR_FLOW_IPV6_ESP,
 45	IAVF_FDIR_FLOW_IPV6_OTHER,
 46	IAVF_FDIR_FLOW_NON_IP_L2,
 47	/* MAX - this must be last and add anything new just above it */
 48	IAVF_FDIR_FLOW_PTYPE_MAX,
 49};
 50
 51/* Must not exceed the array element number of '__be32 data[2]' in the ethtool
 52 * 'struct ethtool_rx_flow_spec.m_ext.data[2]' to express the flex-byte (word).
 53 */
 54#define IAVF_FLEX_WORD_NUM	2
 55
 56struct iavf_flex_word {
 57	u16 offset;
 58	u16 word;
 59};
 60
 61struct iavf_ipv4_addrs {
 62	__be32 src_ip;
 63	__be32 dst_ip;
 64};
 65
 66struct iavf_ipv6_addrs {
 67	struct in6_addr src_ip;
 68	struct in6_addr dst_ip;
 69};
 70
 71struct iavf_fdir_eth {
 72	__be16 etype;
 73};
 74
 75struct iavf_fdir_ip {
 76	union {
 77		struct iavf_ipv4_addrs v4_addrs;
 78		struct iavf_ipv6_addrs v6_addrs;
 79	};
 80	__be16 src_port;
 81	__be16 dst_port;
 82	__be32 l4_header;	/* first 4 bytes of the layer 4 header */
 83	__be32 spi;		/* security parameter index for AH/ESP */
 84	union {
 85		u8 tos;
 86		u8 tclass;
 87	};
 88	u8 proto;
 89};
 90
 91struct iavf_fdir_extra {
 92	u32 usr_def[IAVF_FLEX_WORD_NUM];
 93};
 94
 95/* bookkeeping of Flow Director filters */
 96struct iavf_fdir_fltr {
 97	enum iavf_fdir_fltr_state_t state;
 98	struct list_head list;
 99
100	enum iavf_fdir_flow_type flow_type;
101
102	struct iavf_fdir_eth eth_data;
103	struct iavf_fdir_eth eth_mask;
104
105	struct iavf_fdir_ip ip_data;
106	struct iavf_fdir_ip ip_mask;
107
108	struct iavf_fdir_extra ext_data;
109	struct iavf_fdir_extra ext_mask;
110
111	enum virtchnl_action action;
112
113	/* flex byte filter data */
114	u8 ip_ver; /* used to adjust the flex offset, 4 : IPv4, 6 : IPv6 */
115	u8 flex_cnt;
116	struct iavf_flex_word flex_words[IAVF_FLEX_WORD_NUM];
117
118	u32 flow_id;
119
120	u32 loc;	/* Rule location inside the flow table */
121	u32 q_index;
122
123	struct virtchnl_fdir_add vc_add_msg;
124};
125
126int iavf_validate_fdir_fltr_masks(struct iavf_adapter *adapter,
127				  struct iavf_fdir_fltr *fltr);
128int iavf_fill_fdir_add_msg(struct iavf_adapter *adapter, struct iavf_fdir_fltr *fltr);
129void iavf_print_fdir_fltr(struct iavf_adapter *adapter, struct iavf_fdir_fltr *fltr);
130bool iavf_fdir_is_dup_fltr(struct iavf_adapter *adapter, struct iavf_fdir_fltr *fltr);
131void iavf_fdir_list_add_fltr(struct iavf_adapter *adapter, struct iavf_fdir_fltr *fltr);
132struct iavf_fdir_fltr *iavf_find_fdir_fltr_by_loc(struct iavf_adapter *adapter, u32 loc);
133#endif /* _IAVF_FDIR_H_ */
v6.2
  1/* SPDX-License-Identifier: GPL-2.0 */
  2/* Copyright (c) 2021, Intel Corporation. */
  3
  4#ifndef _IAVF_FDIR_H_
  5#define _IAVF_FDIR_H_
  6
  7struct iavf_adapter;
  8
  9/* State of Flow Director filter */
 
 
 
 
 
 
 
 
 
 
 10enum iavf_fdir_fltr_state_t {
 11	IAVF_FDIR_FLTR_ADD_REQUEST,	/* User requests to add filter */
 12	IAVF_FDIR_FLTR_ADD_PENDING,	/* Filter pending add by the PF */
 13	IAVF_FDIR_FLTR_DEL_REQUEST,	/* User requests to delete filter */
 14	IAVF_FDIR_FLTR_DEL_PENDING,	/* Filter pending delete by the PF */
 
 
 
 15	IAVF_FDIR_FLTR_ACTIVE,		/* Filter is active */
 16};
 17
 18enum iavf_fdir_flow_type {
 19	/* NONE - used for undef/error */
 20	IAVF_FDIR_FLOW_NONE = 0,
 21	IAVF_FDIR_FLOW_IPV4_TCP,
 22	IAVF_FDIR_FLOW_IPV4_UDP,
 23	IAVF_FDIR_FLOW_IPV4_SCTP,
 24	IAVF_FDIR_FLOW_IPV4_AH,
 25	IAVF_FDIR_FLOW_IPV4_ESP,
 26	IAVF_FDIR_FLOW_IPV4_OTHER,
 27	IAVF_FDIR_FLOW_IPV6_TCP,
 28	IAVF_FDIR_FLOW_IPV6_UDP,
 29	IAVF_FDIR_FLOW_IPV6_SCTP,
 30	IAVF_FDIR_FLOW_IPV6_AH,
 31	IAVF_FDIR_FLOW_IPV6_ESP,
 32	IAVF_FDIR_FLOW_IPV6_OTHER,
 33	IAVF_FDIR_FLOW_NON_IP_L2,
 34	/* MAX - this must be last and add anything new just above it */
 35	IAVF_FDIR_FLOW_PTYPE_MAX,
 36};
 37
 38/* Must not exceed the array element number of '__be32 data[2]' in the ethtool
 39 * 'struct ethtool_rx_flow_spec.m_ext.data[2]' to express the flex-byte (word).
 40 */
 41#define IAVF_FLEX_WORD_NUM	2
 42
 43struct iavf_flex_word {
 44	u16 offset;
 45	u16 word;
 46};
 47
 48struct iavf_ipv4_addrs {
 49	__be32 src_ip;
 50	__be32 dst_ip;
 51};
 52
 53struct iavf_ipv6_addrs {
 54	struct in6_addr src_ip;
 55	struct in6_addr dst_ip;
 56};
 57
 58struct iavf_fdir_eth {
 59	__be16 etype;
 60};
 61
 62struct iavf_fdir_ip {
 63	union {
 64		struct iavf_ipv4_addrs v4_addrs;
 65		struct iavf_ipv6_addrs v6_addrs;
 66	};
 67	__be16 src_port;
 68	__be16 dst_port;
 69	__be32 l4_header;	/* first 4 bytes of the layer 4 header */
 70	__be32 spi;		/* security parameter index for AH/ESP */
 71	union {
 72		u8 tos;
 73		u8 tclass;
 74	};
 75	u8 proto;
 76};
 77
 78struct iavf_fdir_extra {
 79	u32 usr_def[IAVF_FLEX_WORD_NUM];
 80};
 81
 82/* bookkeeping of Flow Director filters */
 83struct iavf_fdir_fltr {
 84	enum iavf_fdir_fltr_state_t state;
 85	struct list_head list;
 86
 87	enum iavf_fdir_flow_type flow_type;
 88
 89	struct iavf_fdir_eth eth_data;
 90	struct iavf_fdir_eth eth_mask;
 91
 92	struct iavf_fdir_ip ip_data;
 93	struct iavf_fdir_ip ip_mask;
 94
 95	struct iavf_fdir_extra ext_data;
 96	struct iavf_fdir_extra ext_mask;
 97
 98	enum virtchnl_action action;
 99
100	/* flex byte filter data */
101	u8 ip_ver; /* used to adjust the flex offset, 4 : IPv4, 6 : IPv6 */
102	u8 flex_cnt;
103	struct iavf_flex_word flex_words[IAVF_FLEX_WORD_NUM];
104
105	u32 flow_id;
106
107	u32 loc;	/* Rule location inside the flow table */
108	u32 q_index;
109
110	struct virtchnl_fdir_add vc_add_msg;
111};
112
 
 
113int iavf_fill_fdir_add_msg(struct iavf_adapter *adapter, struct iavf_fdir_fltr *fltr);
114void iavf_print_fdir_fltr(struct iavf_adapter *adapter, struct iavf_fdir_fltr *fltr);
115bool iavf_fdir_is_dup_fltr(struct iavf_adapter *adapter, struct iavf_fdir_fltr *fltr);
116void iavf_fdir_list_add_fltr(struct iavf_adapter *adapter, struct iavf_fdir_fltr *fltr);
117struct iavf_fdir_fltr *iavf_find_fdir_fltr_by_loc(struct iavf_adapter *adapter, u32 loc);
118#endif /* _IAVF_FDIR_H_ */