Skip to content

Commit 1f7ea1c

Browse files
qzhan16anguy11
authored andcommitted
ice: Enable FDIR Configure for AVF
The virtual channel is going to be extended to support FDIR and RSS configure from AVF. New data structures and OP codes will be added, the patch enable the FDIR part. To support above advanced AVF feature, we need to figure out what kind of data structure should be passed from VF to PF to describe an FDIR rule or RSS config rule. The common part of the requirement is we need a data structure to represent the input set selection of a rule's hash key. An input set selection is a group of fields be selected from one or more network protocol layers that could be identified as a specific flow. For example, select dst IP address from an IPv4 header combined with dst port from the TCP header as the input set for an IPv4/TCP flow. The patch adds a new data structure virtchnl_proto_hdrs to abstract a network protocol headers group which is composed of layers of network protocol header(virtchnl_proto_hdr). A protocol header contains a 32 bits mask (field_selector) to describe which fields are selected as input sets, as well as a header type (enum virtchnl_proto_hdr_type). Each bit is mapped to a field in enum virtchnl_proto_hdr_field guided by its header type. +------------+-----------+------------------------------+ | | Proto Hdr | Header Type A | | | +------------------------------+ | | | BIT 31 | ... | BIT 1 | BIT 0 | | |-----------+------------------------------+ |Proto Hdrs | Proto Hdr | Header Type B | | | +------------------------------+ | | | BIT 31 | ... | BIT 1 | BIT 0 | | |-----------+------------------------------+ | | Proto Hdr | Header Type C | | | +------------------------------+ | | | BIT 31 | ... | BIT 1 | BIT 0 | | |-----------+------------------------------+ | | .... | +-------------------------------------------------------+ All fields in enum virtchnl_proto_hdr_fields are grouped with header type and the value of the first field of a header type is always 32 aligned. enum proto_hdr_type { header_type_A = 0; header_type_B = 1; .... } enum proto_hdr_field { /* header type A */ header_A_field_0 = 0, header_A_field_1 = 1, header_A_field_2 = 2, header_A_field_3 = 3, /* header type B */ header_B_field_0 = 32, // = header_type_B << 5 header_B_field_0 = 33, header_B_field_0 = 34 header_B_field_0 = 35, .... }; So we have: proto_hdr_type = proto_hdr_field / 32 bit offset = proto_hdr_field % 32 To simply the protocol header's operations, couple help macros are added. For example, to select src IP and dst port as input set for an IPv4/UDP flow. we have: struct virtchnl_proto_hdr hdr[2]; VIRTCHNL_SET_PROTO_HDR_TYPE(&hdr[0], IPV4) VIRTCHNL_ADD_PROTO_HDR_FIELD(&hdr[0], IPV4, SRC) VIRTCHNL_SET_PROTO_HDR_TYPE(&hdr[1], UDP) VIRTCHNL_ADD_PROTO_HDR_FIELD(&hdr[1], UDP, DST) The byte array is used to store the protocol header of a training package. The byte array must be network order. The patch added virtual channel support for iAVF FDIR add/validate/delete filter. iAVF FDIR is Flow Director for Intel Adaptive Virtual Function which can direct Ethernet packets to the queues of the Network Interface Card. Add/delete command is adding or deleting one rule for each virtual channel message, while validate command is just verifying if this rule is valid without any other operations. To add or delete one rule, driver needs to config TCAM and Profile, build training packets which contains the input set value, and send the training packets through FDIR Tx queue. In addition, driver needs to manage the software context to avoid adding duplicated rules, deleting non-existent rule, input set conflicts and other invalid cases. NOTE: Supported pattern/actions and their parse functions are not be included in this patch, they will be added in a separate one. Signed-off-by: Jeff Guo <jia.guo@intel.com> Signed-off-by: Yahui Cao <yahui.cao@intel.com> Signed-off-by: Simei Su <simei.su@intel.com> Signed-off-by: Beilei Xing <beilei.xing@intel.com> Signed-off-by: Qi Zhang <qi.z.zhang@intel.com> Tested-by: Chen Bo <BoX.C.Chen@intel.com> Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
1 parent da62c5f commit 1f7ea1c

10 files changed

Lines changed: 1372 additions & 6 deletions

File tree

‎drivers/net/ethernet/intel/ice/Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ ice-y := ice_main.o \
2626
ice_fw_update.o \
2727
ice_lag.o \
2828
ice_ethtool.o
29-
ice-$(CONFIG_PCI_IOV) += ice_virtchnl_pf.o ice_sriov.o
29+
ice-$(CONFIG_PCI_IOV) += ice_virtchnl_pf.o ice_sriov.o ice_virtchnl_fdir.o
3030
ice-$(CONFIG_DCB) += ice_dcb.o ice_dcb_nl.o ice_dcb_lib.o
3131
ice-$(CONFIG_RFS_ACCEL) += ice_arfs.o
3232
ice-$(CONFIG_XDP_SOCKETS) += ice_xsk.o

‎drivers/net/ethernet/intel/ice/ice_ethtool_fdir.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1679,6 +1679,10 @@ int ice_add_fdir_ethtool(struct ice_vsi *vsi, struct ethtool_rxnfc *cmd)
16791679
input->flex_offset = userdata.flex_offset;
16801680
}
16811681

1682+
input->cnt_ena = ICE_FXD_FLTR_QW0_STAT_ENA_PKTS;
1683+
input->fdid_prio = ICE_FXD_FLTR_QW1_FDID_PRI_THREE;
1684+
input->comp_report = ICE_FXD_FLTR_QW0_COMP_REPORT_SW_FAIL;
1685+
16821686
/* input struct is added to the HW filter list */
16831687
ice_fdir_update_list_entry(pf, input, fsp->location);
16841688

‎drivers/net/ethernet/intel/ice/ice_fdir.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ ice_fdir_get_prgm_desc(struct ice_hw *hw, struct ice_fdir_fltr *input,
378378
fdir_fltr_ctx.drop = ICE_FXD_FLTR_QW0_DROP_NO;
379379
fdir_fltr_ctx.qindex = input->q_index;
380380
}
381-
fdir_fltr_ctx.cnt_ena = ICE_FXD_FLTR_QW0_STAT_ENA_PKTS;
381+
fdir_fltr_ctx.cnt_ena = input->cnt_ena;
382382
fdir_fltr_ctx.cnt_index = input->cnt_index;
383383
fdir_fltr_ctx.fd_vsi = ice_get_hw_vsi_num(hw, input->dest_vsi);
384384
fdir_fltr_ctx.evict_ena = ICE_FXD_FLTR_QW0_EVICT_ENA_FALSE;
@@ -387,8 +387,8 @@ ice_fdir_get_prgm_desc(struct ice_hw *hw, struct ice_fdir_fltr *input,
387387
ICE_FXD_FLTR_QW1_PCMD_REMOVE;
388388
fdir_fltr_ctx.swap = ICE_FXD_FLTR_QW1_SWAP_NOT_SET;
389389
fdir_fltr_ctx.comp_q = ICE_FXD_FLTR_QW0_COMP_Q_ZERO;
390-
fdir_fltr_ctx.comp_report = ICE_FXD_FLTR_QW0_COMP_REPORT_SW_FAIL;
391-
fdir_fltr_ctx.fdid_prio = 3;
390+
fdir_fltr_ctx.comp_report = input->comp_report;
391+
fdir_fltr_ctx.fdid_prio = input->fdid_prio;
392392
fdir_fltr_ctx.desc_prof = 1;
393393
fdir_fltr_ctx.desc_prof_prio = 3;
394394
ice_set_fd_desc_val(&fdir_fltr_ctx, fdesc);

‎drivers/net/ethernet/intel/ice/ice_fdir.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
#define ICE_IPV6_HLIM_OFFSET 21
3232
#define ICE_IPV6_PROTO_OFFSET 20
3333

34+
#define ICE_FDIR_MAX_FLTRS 16384
35+
3436
/* IP v4 has 2 flag bits that enable fragment processing: DF and MF. DF
3537
* requests that the packet not be fragmented. MF indicates that a packet has
3638
* been fragmented.
@@ -138,9 +140,12 @@ struct ice_fdir_fltr {
138140
u16 q_index;
139141
u16 dest_vsi;
140142
u8 dest_ctl;
143+
u8 cnt_ena;
141144
u8 fltr_status;
142145
u16 cnt_index;
143146
u32 fltr_id;
147+
u8 fdid_prio;
148+
u8 comp_report;
144149
};
145150

146151
/* Dummy packet filter definition structure */

‎drivers/net/ethernet/intel/ice/ice_lan_tx_rx.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ struct ice_fltr_desc {
5555
#define ICE_FXD_FLTR_QW0_COMP_REPORT_M \
5656
(0x3ULL << ICE_FXD_FLTR_QW0_COMP_REPORT_S)
5757
#define ICE_FXD_FLTR_QW0_COMP_REPORT_SW_FAIL 0x1ULL
58+
#define ICE_FXD_FLTR_QW0_COMP_REPORT_SW 0x2ULL
5859

5960
#define ICE_FXD_FLTR_QW0_FD_SPACE_S 14
6061
#define ICE_FXD_FLTR_QW0_FD_SPACE_M (0x3ULL << ICE_FXD_FLTR_QW0_FD_SPACE_S)
@@ -128,6 +129,7 @@ struct ice_fltr_desc {
128129
#define ICE_FXD_FLTR_QW1_FDID_PRI_S 25
129130
#define ICE_FXD_FLTR_QW1_FDID_PRI_M (0x7ULL << ICE_FXD_FLTR_QW1_FDID_PRI_S)
130131
#define ICE_FXD_FLTR_QW1_FDID_PRI_ONE 0x1ULL
132+
#define ICE_FXD_FLTR_QW1_FDID_PRI_THREE 0x3ULL
131133

132134
#define ICE_FXD_FLTR_QW1_FDID_MDID_S 28
133135
#define ICE_FXD_FLTR_QW1_FDID_MDID_M (0xFULL << ICE_FXD_FLTR_QW1_FDID_MDID_S)

0 commit comments

Comments
 (0)