Enable Intel VF RSS
Subsystems (3)
v3 cover Enable Intel VF RSS
The current Intel VF (iAVF) doesn't support changing its RSS input set by ethool. Add support in virtchnl, iavf, and ice to enable RSS input set changes on the VF via ethtool.
v3: fix the SCTP dest port set wrong.
v2: rewrite the commit message, and some code clean up.
Haiyue Wang (4):
iavf: Add framework to enable ethtool RSS config
iavf: Support for modifying TCP RSS flow hashing
iavf: Support for modifying UDP RSS flow hashing
iavf: Support for modifying SCTP RSS flow hashing
Qi Zhang (2):
ice: Enable RSS configure for AVF
ice: Support RSS configure removal for AVF
drivers/net/ethernet/intel/iavf/Makefile | 1 + drivers/net/ethernet/intel/iavf/iavf.h | 10 + .../net/ethernet/intel/iavf/iavf_adv_rss.c | 218 ++++++++ .../net/ethernet/intel/iavf/iavf_adv_rss.h | 95 ++++ .../net/ethernet/intel/iavf/iavf_ethtool.c | 252 +++++++++- drivers/net/ethernet/intel/iavf/iavf_main.c | 27 + .../net/ethernet/intel/iavf/iavf_virtchnl.c | 163 ++++++ drivers/net/ethernet/intel/ice/ice_flow.c | 88 ++++ drivers/net/ethernet/intel/ice/ice_flow.h | 6 + .../intel/ice/ice_virtchnl_allowlist.c | 6 + .../net/ethernet/intel/ice/ice_virtchnl_pf.c | 465 ++++++++++++++++++ include/linux/avf/virtchnl.h | 25 +- 12 files changed, 1353 insertions(+), 3 deletions(-) create mode 100644 drivers/net/ethernet/intel/iavf/iavf_adv_rss.c create mode 100644 drivers/net/ethernet/intel/iavf/iavf_adv_rss.h
Signature · 1 line
2.31.1
PATCH v3 1/6 ice: Enable RSS configure for AVF
From: Qi Zhang <[email protected]>
Currently, RSS hash input is not available to AVF by ethtool, it is set by the PF directly.
Add the RSS configure support for AVF through new virtchnl message, and define the capability flag VIRTCHNL_VF_OFFLOAD_ADV_RSS_PF to query this new RSS offload support.
--- drivers/net/ethernet/intel/ice/ice_flow.h | 3 + .../intel/ice/ice_virtchnl_allowlist.c | 6 + .../net/ethernet/intel/ice/ice_virtchnl_pf.c | 453 ++++++++++++++++++ include/linux/avf/virtchnl.h | 25 +- 4 files changed, 486 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/ice/ice_flow.h +3 -0
@@ -8,6 +8,9 @@#define ICE_FLOW_FLD_OFF_INVAL 0xffff/* Generate flow hash field from flow field type(s) */ +#define ICE_FLOW_HASH_ETH \ + (BIT_ULL(ICE_FLOW_FIELD_IDX_ETH_DA) | \ + BIT_ULL(ICE_FLOW_FIELD_IDX_ETH_SA))#define ICE_FLOW_HASH_IPV4 \ (BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_SA) | \ BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_DA))
drivers/net/ethernet/intel/ice/ice_virtchnl_allowlist.c +6 -0
@@ -61,6 +61,11 @@ static const u32 rss_pf_allowlist_opcodes[] = { VIRTCHNL_OP_GET_RSS_HENA_CAPS, VIRTCHNL_OP_SET_RSS_HENA, }; +/* VIRTCHNL_VF_OFFLOAD_ADV_RSS_PF */ +static const u32 adv_rss_pf_allowlist_opcodes[] = { +VIRTCHNL_OP_ADD_RSS_CFG ,VIRTCHNL_OP_DEL_RSS_CFG , +}; +/* VIRTCHNL_VF_OFFLOAD_FDIR_PF */ static const u32 fdir_pf_allowlist_opcodes[] = {VIRTCHNL_OP_ADD_FDIR_FILTER ,VIRTCHNL_OP_DEL_FDIR_FILTER ,
@@ -82,6 +87,7 @@ static const struct allowlist_opcode_info allowlist_opcodes[] = {ALLOW_ITEM (VIRTCHNL_VF_OFFLOAD_REQ_QUEUES , req_queues_allowlist_opcodes),ALLOW_ITEM (VIRTCHNL_VF_OFFLOAD_VLAN , vlan_allowlist_opcodes),ALLOW_ITEM (VIRTCHNL_VF_OFFLOAD_RSS_PF , rss_pf_allowlist_opcodes), +ALLOW_ITEM (VIRTCHNL_VF_OFFLOAD_ADV_RSS_PF , adv_rss_pf_allowlist_opcodes), ALLOW_ITEM(VIRTCHNL_VF_OFFLOAD_FDIR_PF, fdir_pf_allowlist_opcodes), };
drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c +453 -0
479 lines not on this page · raw message
include/linux/avf/virtchnl.h +24 -1
@@ -136,7 +136,9 @@ enum virtchnl_ops {VIRTCHNL_OP_DISABLE_CHANNELS =31 ,VIRTCHNL_OP_ADD_CLOUD_FILTER =32 ,VIRTCHNL_OP_DEL_CLOUD_FILTER =33 , -/* opcode 34 - 46 are reserved */ +/* opcode 34 - 44 are reserved */ +VIRTCHNL_OP_ADD_RSS_CFG =45 , +VIRTCHNL_OP_DEL_RSS_CFG =46 ,VIRTCHNL_OP_ADD_FDIR_FILTER =47 ,VIRTCHNL_OP_DEL_FDIR_FILTER =48 , VIRTCHNL_OP_MAX,
@@ -251,6 +253,7 @@ VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_vsi_resource);#define VIRTCHNL_VF_OFFLOAD_ENCAP_CSUM 0X00200000#define VIRTCHNL_VF_OFFLOAD_RX_ENCAP_CSUM 0X00400000#define VIRTCHNL_VF_OFFLOAD_ADQ 0X00800000 +#define VIRTCHNL_VF_OFFLOAD_ADV_RSS_PF 0X08000000#define VIRTCHNL_VF_OFFLOAD_FDIR_PF 0X10000000#define VIRTCHNL_VF_OFFLOAD_USO 0X02000000
@@ -704,6 +707,14 @@ enum virtchnl_vfr_states { VIRTCHNL_VFR_VFACTIVE, }; +/* Type of RSS algorithm */ +enum virtchnl_rss_algorithm { +VIRTCHNL_RSS_ALG_TOEPLITZ_ASYMMETRIC =0 , +VIRTCHNL_RSS_ALG_R_ASYMMETRIC =1 , +VIRTCHNL_RSS_ALG_TOEPLITZ_SYMMETRIC =2 , +VIRTCHNL_RSS_ALG_XOR_SYMMETRIC =3 , +}; +#define VIRTCHNL_MAX_NUM_PROTO_HDRS 32#define PROTO_HDR_SHIFT 5#define PROTO_HDR_FIELD_START (proto_hdr_type) ((proto_hdr_type) << PROTO_HDR_SHIFT)
@@ -859,6 +870,14 @@ struct virtchnl_proto_hdrs {VIRTCHNL_CHECK_STRUCT_LEN (2312 , virtchnl_proto_hdrs); +struct virtchnl_rss_cfg { +struct virtchnl_proto_hdrs proto_hdrs;/* protocol headers */ +enum virtchnl_rss_algorithm rss_algorithm;/* RSS algorithm type */ +u8 reserved[128 ];/* reserve for future */ +}; + +VIRTCHNL_CHECK_STRUCT_LEN (2444 , virtchnl_rss_cfg); +/* action configuration for FDIR */ struct virtchnl_filter_action {enum virtchnl_action type;
@@ -1127,6 +1146,10 @@ virtchnl_vc_validate_vf_msg(struct virtchnl_version_info *ver, u32 v_opcode,case VIRTCHNL_OP_DEL_CLOUD_FILTER : valid_len =sizeof (struct virtchnl_filter );break ; +case VIRTCHNL_OP_ADD_RSS_CFG : +case VIRTCHNL_OP_DEL_RSS_CFG : + valid_len =sizeof (struct virtchnl_rss_cfg ); +break ;case VIRTCHNL_OP_ADD_FDIR_FILTER : valid_len =sizeof (struct virtchnl_fdir_add );break ;
Signature · 1 line
2.31.1
Chen
PATCH v3 1/6 ice: Enable RSS configure for AVF
Quoted 21 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Haiyue Wang
Sent: April 13, 2021 8:49
To: intel-wired-lan at lists.osuosl.org
Cc: Guo, Jia <[email protected]>; Zhang, Qi Z <[email protected]>
Subject: [Intel-wired-lan] [PATCH net-next v3 1/6] ice: Enable RSS configure for AVFFrom: Qi Zhang <[email protected]>
Currently, RSS hash input is not available to AVF by ethtool, it is set by the PF directly.
Add the RSS configure support for AVF through new virtchnl message, and define the capability flag
VIRTCHNL_VF_OFFLOAD_ADV_RSS_PFto query this new RSS offload support.Signed-off-by Jia Guo <[email protected]>Signed-off-by Qi Zhang <[email protected]>Signed-off-by Haiyue Wang <[email protected]>
Quoted 7 lines
--- drivers/net/ethernet/intel/ice/ice_flow.h | 3 + .../intel/ice/ice_virtchnl_allowlist.c | 6 + .../net/ethernet/intel/ice/ice_virtchnl_pf.c | 453 ++++++++++++++++++ include/linux/avf/virtchnl.h | 25 +- 4 files changed, 486 insertions(+), 1 deletion(-)
Regards,
Chen Bo
______________________________________________
Intel-wired-lan mailing list
Intel-wired-lan at osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
PATCH v3 2/6 ice: Support RSS configure removal for AVF
In reply to Haiyue WangFrom: Qi Zhang <[email protected]>
Add the handler for virtchnl message VIRTCHNL_OP_DEL_RSS_CFG to remove an existing RSS configuration with matching hashed fields.
--- drivers/net/ethernet/intel/ice/ice_flow.c | 88 +++++++++++++++++++ drivers/net/ethernet/intel/ice/ice_flow.h | 3 + .../net/ethernet/intel/ice/ice_virtchnl_pf.c | 16 +++- 3 files changed, 105 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/ice/ice_flow.c +88 -0
@@ -2149,6 +2149,94 @@ ice_add_rss_cfg(struct ice_hw *hw, u16 vsi_handle, u64 hashed_flds,return status; } +/** +* ice_rem_rss_cfg_sync - remove an existing RSS configuration +* @hw: pointer to the hardware structure +* @vsi_handle: software VSI handle +* @hashed_flds: Packet hash types (ICE_FLOW_HASH_*) to remove +* @addl_hdrs: Protocol header fields within a packet segment +* @segs_cnt: packet segment count +* +* Assumption: lock has already been acquired for RSS list +*/ +static enum ice_status +ice_rem_rss_cfg_sync (struct ice_hw *hw,u16 vsi_handle,u64 hashed_flds, +u32 addl_hdrs,u8 segs_cnt) +{ +const enum ice_block blk =ICE_BLK_RSS ; +struct ice_flow_seg_info *segs; +struct ice_flow_prof *prof; +enum ice_status status; + + segs =kcalloc (segs_cnt,sizeof (*segs),GFP_KERNEL ); +if (!segs) +return ICE_ERR_NO_MEMORY ; + +/* Construct the packet segment info from the hashed fields */ + status =ice_flow_set_rss_seg_info (&segs[segs_cnt -1 ], hashed_flds, + addl_hdrs); +if (status) + goto out; + + prof =ice_flow_find_prof_conds (hw, blk,ICE_FLOW_RX , segs, segs_cnt, + vsi_handle, +ICE_FLOW_FIND_PROF_CHK_FLDS ); +if (!prof) { + status =ICE_ERR_DOES_NOT_EXIST ; + goto out; + } + + status =ice_flow_disassoc_prof (hw, blk, prof, vsi_handle); +if (status) + goto out; + +/* Remove RSS configuration from VSI context before deleting +* the flow profile. +*/ +ice_rem_rss_list (hw, vsi_handle, prof); + +if (bitmap_empty (prof->vsis,ICE_MAX_VSI )) + status =ice_flow_rem_prof (hw, blk, prof->id); + +out: +kfree (segs); +return status; +} + +/** +* ice_rem_rss_cfg - remove an existing RSS config with matching hashed fields +* @hw: pointer to the hardware structure +* @vsi_handle: software VSI handle +* @hashed_flds: Packet hash types (ICE_FLOW_HASH_*) to remove +* @addl_hdrs: Protocol header fields within a packet segment +* +* This function will lookup the flow profile based on the input +* hash field bitmap, iterate through the profile entry list of +* that profile and find entry associated with input VSI to be +* removed. Calls are made to underlying flow s which will APIs +* turn build or update buffers for RSS XLT1 section. +*/ +enum ice_status __maybe_unused +ice_rem_rss_cfg (struct ice_hw *hw,u16 vsi_handle,u64 hashed_flds, +u32 addl_hdrs) +{ +enum ice_status status; + +if (hashed_flds ==ICE_HASH_INVALID || + !ice_is_vsi_valid (hw, vsi_handle)) +return ICE_ERR_PARAM ; + +mutex_lock (&hw->rss_locks); + status =ice_rem_rss_cfg_sync (hw, vsi_handle, hashed_flds, addl_hdrs, +ICE_RSS_OUTER_HEADERS ); +if (!status) + status =ice_rem_rss_cfg_sync (hw, vsi_handle, hashed_flds, + addl_hdrs,ICE_RSS_INNER_HEADERS ); +mutex_unlock (&hw->rss_locks); + +return status; +} +/* Mapping of AVF hash bit fields to an L3-L4 hash combination. * As the ice_flow_avf_hdr_field represent individual bit shifts in a hash, * convert its values to their appropriate flow L3, L4 values.
drivers/net/ethernet/intel/ice/ice_flow.h +3 -0
@@ -409,5 +409,8 @@ enum ice_status ice_rem_vsi_rss_cfg(struct ice_hw *hw, u16 vsi_handle);enum ice_status ice_add_rss_cfg (struct ice_hw *hw,u16 vsi_handle,u64 hashed_flds,u32 addl_hdrs); +enum ice_status +ice_rem_rss_cfg (struct ice_hw *hw,u16 vsi_handle,u64 hashed_flds, +u32 addl_hdrs);u64 ice_get_rss_cfg (struct ice_hw *hw,u16 vsi_handle,u32 hdrs);#endif /* _ICE_FLOW_H_ */
drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c +14 -2
@@ -2651,8 +2651,20 @@ static int ice_vc_handle_rss_cfg(struct ice_vf *vf, u8 *msg, bool add) vsi->vsi_num, v_ret); } }else { - v_ret =VIRTCHNL_STATUS_ERR_NOT_SUPPORTED ; -dev_err (dev,"RSS removal not supported\n" ); +enum ice_status status; + + status =ice_rem_rss_cfg (hw, vsi->idx, hash_flds, + addl_hdrs); +/* We just ignore ICE_ERR_DOES_NOT_EXIST, because +* if two configurations share the same profile remove +* one of them actually removes both, since the +* profile is deleted. +*/ +if (status && status !=ICE_ERR_DOES_NOT_EXIST ) { + v_ret =VIRTCHNL_STATUS_ERR_PARAM ; +dev_err (dev,"ice_rem_rss_cfg failed for VF ID:%d, error:%s\n" , + vf->vf_id,ice_stat_str (status)); + } } }
Signature · 1 line
2.31.1
Chen
PATCH v3 2/6 ice: Support RSS configure removal for AVF
Quoted 20 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Haiyue Wang
Sent: April 13, 2021 8:49
To: intel-wired-lan at lists.osuosl.org
Cc: Guo, Jia <[email protected]>; Sridhar, Vignesh <[email protected]>; Zhang, Qi Z <[email protected]>
Subject: [Intel-wired-lan] [PATCH net-next v3 2/6] ice: Support RSS configure removal for AVFFrom: Qi Zhang <[email protected]>
Add the handler for virtchnl message
VIRTCHNL_OP_DEL_RSS_CFGto remove an existing RSS configuration with matching hashed fields.Signed-off-by Vignesh Sridhar <[email protected]>Co-developed-by Jia Guo <[email protected]>Signed-off-by Jia Guo <[email protected]>Signed-off-by Qi Zhang <[email protected]>Signed-off-by Haiyue Wang <[email protected]>
Quoted 6 lines
--- drivers/net/ethernet/intel/ice/ice_flow.c | 88 +++++++++++++++++++ drivers/net/ethernet/intel/ice/ice_flow.h | 3 + .../net/ethernet/intel/ice/ice_virtchnl_pf.c | 16 +++- 3 files changed, 105 insertions(+), 2 deletions(-)
Regards,
Chen Bo
_______________________________________________
Intel-wired-lan mailing list
Intel-wired-lan at osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
PATCH v3 3/6 iavf: Add framework to enable ethtool RSS config
In reply to Haiyue WangAdd the virtchnl message interface to VF, so that VF can request RSS input set(s) based on PF's capability.
This framework allows ethtool RSS config support on the VF driver.
--- drivers/net/ethernet/intel/iavf/iavf.h | 10 ++ .../net/ethernet/intel/iavf/iavf_adv_rss.h | 25 +++ drivers/net/ethernet/intel/iavf/iavf_main.c | 27 ++++ .../net/ethernet/intel/iavf/iavf_virtchnl.c | 152 ++++++++++++++++++ 4 files changed, 214 insertions(+) create mode 100644 drivers/net/ethernet/intel/iavf/iavf_adv_rss.h
drivers/net/ethernet/intel/iavf/iavf.h +10 -0
@@ -38,6 +38,7 @@#include <linux/avf/virtchnl.h> #include "iavf_txrx.h" #include "iavf_fdir.h" +#include "iavf_adv_rss.h" #define DEFAULT_DEBUG_LEVEL_SHIFT 3#define PFX "iavf: "
@@ -304,6 +305,8 @@ struct iavf_adapter {#define IAVF_FLAG_AQ_DEL_CLOUD_FILTER BIT(24)#define IAVF_FLAG_AQ_ADD_FDIR_FILTER BIT(25)#define IAVF_FLAG_AQ_DEL_FDIR_FILTER BIT(26) +#define IAVF_FLAG_AQ_ADD_ADV_RSS_CFG BIT(27) +#define IAVF_FLAG_AQ_DEL_ADV_RSS_CFG BIT(28)/* OS defined structs */ struct net_device *netdev;
@@ -346,6 +349,8 @@ struct iavf_adapter { VIRTCHNL_VF_CAP_ADV_LINK_SPEED)#define FDIR_FLTR_SUPPORT (_a) ((_a)->vf_res->vf_cap_flags & \ VIRTCHNL_VF_OFFLOAD_FDIR_PF) +#define ADV_RSS_SUPPORT (_a) ((_a)->vf_res->vf_cap_flags & \ + VIRTCHNL_VF_OFFLOAD_ADV_RSS_PF)struct virtchnl_vf_resource *vf_res;/* incl. all VSIs */ struct virtchnl_vsi_resource *vsi_res;/* our LAN VSI */ struct virtchnl_version_info pf_version;
@@ -373,6 +378,9 @@ struct iavf_adapter {u16 fdir_active_fltr;struct list_head fdir_list_head;spinlock_t fdir_fltr_lock;/* protect the Flow Director filter list */ + +struct list_head adv_rss_list_head; +spinlock_t adv_rss_lock;/* protect the RSS management list */ };
@@ -445,6 +453,8 @@ void iavf_add_cloud_filter(struct iavf_adapter *adapter);void iavf_del_cloud_filter (struct iavf_adapter *adapter);void iavf_add_fdir_filter (struct iavf_adapter *adapter);void iavf_del_fdir_filter (struct iavf_adapter *adapter); +void iavf_add_adv_rss_cfg (struct iavf_adapter *adapter); +void iavf_del_adv_rss_cfg (struct iavf_adapter *adapter);struct iavf_mac_filter *iavf_add_filter (struct iavf_adapter *adapter,const u8 *macaddr);#endif /* _IAVF_H_ */
drivers/net/ethernet/intel/iavf/iavf_adv_rss.h new file +25 -0
@@ -0,0 +1,25 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Copyright (c) 2021, Intel Corporation. */ + +#ifndef _IAVF_ADV_RSS_H_ +#define _IAVF_ADV_RSS_H_ + +struct iavf_adapter ; + +/* State of advanced RSS configuration */ +enum iavf_adv_rss_state_t { +IAVF_ADV_RSS_ADD_REQUEST ,/* User requests to add RSS */ +IAVF_ADV_RSS_ADD_PENDING ,/* RSS pending add by the PF */ +IAVF_ADV_RSS_DEL_REQUEST ,/* Driver requests to delete RSS */ +IAVF_ADV_RSS_DEL_PENDING ,/* RSS pending delete by the PF */ +IAVF_ADV_RSS_ACTIVE ,/* RSS configuration is active */ +}; + +/* bookkeeping of advanced RSS configuration */ +struct iavf_adv_rss { +enum iavf_adv_rss_state_t state; +struct list_head list; + +struct virtchnl_rss_cfg cfg_msg; +}; +#endif /* _IAVF_ADV_RSS_H_ */
drivers/net/ethernet/intel/iavf/iavf_main.c +27 -0
@@ -962,6 +962,7 @@ void iavf_down(struct iavf_adapter *adapter)struct iavf_cloud_filter *cf;struct iavf_fdir_fltr *fdir;struct iavf_mac_filter *f; +struct iavf_adv_rss *rss;if (adapter->state <= __IAVF_DOWN_PENDING)return ;
@@ -1004,6 +1005,12 @@ void iavf_down(struct iavf_adapter *adapter) }spin_unlock_bh (&adapter->fdir_fltr_lock); +/* remove all advance RSS configuration */ +spin_lock_bh (&adapter->adv_rss_lock); +list_for_each_entry (rss, &adapter->adv_rss_list_head, list) + rss->state =IAVF_ADV_RSS_DEL_REQUEST ; +spin_unlock_bh (&adapter->adv_rss_lock); +if (!(adapter->flags &IAVF_FLAG_PF_COMMS_FAILED ) && adapter->state != __IAVF_RESETTING) {/* cancel any current operation */
@@ -1016,6 +1023,7 @@ void iavf_down(struct iavf_adapter *adapter) adapter->aq_required |=IAVF_FLAG_AQ_DEL_VLAN_FILTER ; adapter->aq_required |=IAVF_FLAG_AQ_DEL_CLOUD_FILTER ; adapter->aq_required |=IAVF_FLAG_AQ_DEL_FDIR_FILTER ; + adapter->aq_required |=IAVF_FLAG_AQ_DEL_ADV_RSS_CFG ; adapter->aq_required |=IAVF_FLAG_AQ_DISABLE_QUEUES ; }
@@ -1646,6 +1654,14 @@ static int iavf_process_aq_command(struct iavf_adapter *adapter)iavf_del_fdir_filter (adapter);return IAVF_SUCCESS ; } +if (adapter->aq_required &IAVF_FLAG_AQ_ADD_ADV_RSS_CFG ) { +iavf_add_adv_rss_cfg (adapter); +return 0 ; + } +if (adapter->aq_required &IAVF_FLAG_AQ_DEL_ADV_RSS_CFG ) { +iavf_del_adv_rss_cfg (adapter); +return 0 ; + }return -EAGAIN ; }
@@ -3776,11 +3792,13 @@ static int iavf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)spin_lock_init (&adapter->mac_vlan_list_lock);spin_lock_init (&adapter->cloud_filter_list_lock);spin_lock_init (&adapter->fdir_fltr_lock); +spin_lock_init (&adapter->adv_rss_lock);INIT_LIST_HEAD (&adapter->mac_filter_list);INIT_LIST_HEAD (&adapter->vlan_filter_list);INIT_LIST_HEAD (&adapter->cloud_filter_list);INIT_LIST_HEAD (&adapter->fdir_list_head); +INIT_LIST_HEAD (&adapter->adv_rss_list_head);INIT_WORK (&adapter->reset_task, iavf_reset_task);INIT_WORK (&adapter->adminq_task, iavf_adminq_task);
@@ -3886,6 +3904,7 @@ static void iavf_remove(struct pci_dev *pdev)struct iavf_adapter *adapter =netdev_priv (netdev);struct iavf_fdir_fltr *fdir, *fdirtmp;struct iavf_vlan_filter *vlf, *vlftmp; +struct iavf_adv_rss *rss, *rsstmp;struct iavf_mac_filter *f, *ftmp;struct iavf_cloud_filter *cf, *cftmp;struct iavf_hw *hw = &adapter->hw;
@@ -3969,6 +3988,14 @@ static void iavf_remove(struct pci_dev *pdev) }spin_unlock_bh (&adapter->fdir_fltr_lock); +spin_lock_bh (&adapter->adv_rss_lock); +list_for_each_entry_safe (rss, rsstmp, &adapter->adv_rss_list_head, + list) { +list_del (&rss->list); +kfree (rss); + } +spin_unlock_bh (&adapter->adv_rss_lock); +free_netdev (netdev);pci_disable_pcie_error_reporting (pdev);
drivers/net/ethernet/intel/iavf/iavf_virtchnl.c +152 -0
176 lines not on this page · raw message
Signature · 1 line
2.31.1
Jankowski
PATCH v3 3/6 iavf: Add framework to enable ethtool RSS config
Quoted 399 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Haiyue Wang
Sent: wtorek, 13 kwietnia 2021 02:49
To: intel-wired-lan at lists.osuosl.org
Cc: Zhang, Qi Z <[email protected]>
Subject: [Intel-wired-lan] [PATCH net-next v3 3/6] iavf: Add framework to enable ethtool RSS configAdd the virtchnl message interface to VF, so that VF can request RSS input set(s) based on PF's capability.
This framework allows ethtool RSS config support on the VF driver.
Signed-off-by Haiyue Wang <[email protected]>--- drivers/net/ethernet/intel/iavf/iavf.h | 10 ++ .../net/ethernet/intel/iavf/iavf_adv_rss.h | 25 +++ drivers/net/ethernet/intel/iavf/iavf_main.c | 27 ++++ .../net/ethernet/intel/iavf/iavf_virtchnl.c | 152 ++++++++++++++++++ 4 files changed, 214 insertions(+) create mode 100644 drivers/net/ethernet/intel/iavf/iavf_adv_rss.hdrivers/net/ethernet/intel/iavf/iavf.h +5
-0@@ -38,6 +38,7 @@#include <linux/avf/virtchnl.h> #include "iavf_txrx.h" #include "iavf_fdir.h" +#include "iavf_adv_rss.h" #define DEFAULT_DEBUG_LEVEL_SHIFT 3#define PFX "iavf: "@@ -304,6 +305,8 @@ struct iavf_adapter {#define IAVF_FLAG_AQ_DEL_CLOUD_FILTER BIT(24)#define IAVF_FLAG_AQ_ADD_FDIR_FILTER BIT(25)#define IAVF_FLAG_AQ_DEL_FDIR_FILTER BIT(26) +#define IAVF_FLAG_AQ_ADD_ADV_RSS_CFG BIT(27) +#define IAVF_FLAG_AQ_DEL_ADV_RSS_CFG BIT(28)/* OS defined structs */ struct net_device *netdev;@@ -346,6 +349,8 @@ struct iavf_adapter { VIRTCHNL_VF_CAP_ADV_LINK_SPEED) #defineFDIR_FLTR_SUPPORT (_a) ((_a)->vf_res->vf_cap_flags & \ VIRTCHNL_VF_OFFLOAD_FDIR_PF) +#define ADV_RSS_SUPPORT (_a) ((_a)->vf_res->vf_cap_flags & \ + VIRTCHNL_VF_OFFLOAD_ADV_RSS_PF)struct virtchnl_vf_resource *vf_res;/* incl. all VSIs */ struct virtchnl_vsi_resource *vsi_res;/* our LAN VSI */ struct virtchnl_version_info pf_version; @@ -373,6 +378,9 @@ struct
iavf_adapter{drivers/net/ethernet/intel/iavf/iavf.h +0
-0u16 fdir_active_fltr;struct list_head fdir_list_head;spinlock_t fdir_fltr_lock;/* protect the Flow Director filter list */
drivers/net/ethernet/intel/iavf/iavf.h +3
-0+ +struct list_head adv_rss_list_head; +spinlock_t adv_rss_lock;/* protect the RSS management list */
};drivers/net/ethernet/intel/iavf/iavf.h +0
-0@@ -445,6 +453,8 @@ void iavf_add_cloud_filter(struct iavf_adapter *adapter); void iavf_del_cloud_filter(struct iavf_adapter *adapter); void
iavf_add_fdir_filter(struct iavf_adapter *adapter); voidiavf_del_fdir_filter(struct iavf_adapter *adapter);drivers/net/ethernet/intel/iavf/iavf.h +2
-0+void iavf_add_adv_rss_cfg (struct iavf_adapter *adapter);void +iavf_del_adv_rss_cfg (struct iavf_adapter *adapter);struct iavf_mac_filter *iavf_add_filter (struct iavf_adapter *adapter,const u8 *macaddr);#endif /* _IAVF_H_ */ drivers/net/ethernet/intel/iavf/iavf_adv_rss.h new file +10
-0@@ -0,0 +1,25 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Copyright (c) 2021, Intel Corporation. */ + +#ifndef _IAVF_ADV_RSS_H_ +#define _IAVF_ADV_RSS_H_ + +struct iavf_adapter ; + +/* State of advanced RSS configuration */ enum iavf_adv_rss_state_t { +IAVF_ADV_RSS_ADD_REQUEST ,/* User requests to add RSS */
drivers/net/ethernet/intel/iavf/iavf_adv_rss.h new file +1
-0+ IAVF_ADV_RSS_ADD_PENDING, /* RSS pending add by the PF*/
drivers/net/ethernet/intel/iavf/iavf_adv_rss.h new file +1
-0+ IAVF_ADV_RSS_DEL_REQUEST, /* Driver requests to deleteRSS */
drivers/net/ethernet/intel/iavf/iavf_adv_rss.h new file +1
-0+ IAVF_ADV_RSS_DEL_PENDING, /* RSS pending delete by thePF */
drivers/net/ethernet/intel/iavf/iavf_adv_rss.h new file +1
-0+ IAVF_ADV_RSS_ACTIVE, /* RSS configuration is active*/
drivers/net/ethernet/intel/iavf/iavf_adv_rss.h new file +9
-0+}; + +/* bookkeeping of advanced RSS configuration */ struct iavf_adv_rss { +enum iavf_adv_rss_state_t state; +struct list_head list; + +struct virtchnl_rss_cfg cfg_msg; +}; +#endif /* _IAVF_ADV_RSS_H_ */ drivers/net/ethernet/intel/iavf/iavf_main.c +8
-0@@ -962,6 +962,7 @@ void iavf_down(struct iavf_adapter *adapter)struct iavf_cloud_filter *cf;struct iavf_fdir_fltr *fdir;struct iavf_mac_filter *f; +struct iavf_adv_rss *rss;if (adapter->state <= __IAVF_DOWN_PENDING)return ;@@ -1004,6 +1005,12 @@ void iavf_down(struct iavf_adapter *adapter) }spin_unlock_bh (&adapter->fdir_fltr_lock); +/* remove all advance RSS configuration */ +spin_lock_bh (&adapter->adv_rss_lock); +list_for_each_entry (rss, &adapter->adv_rss_list_head, list) + rss->state =IAVF_ADV_RSS_DEL_REQUEST ; +spin_unlock_bh (&adapter->adv_rss_lock); +if (!(adapter->flags &IAVF_FLAG_PF_COMMS_FAILED ) && adapter->state != __IAVF_RESETTING) {/* cancel any current operation */ @@ -1016,6 +1023,7 @@ void iavf_down(struct iavf_adapter *adapter) adapter->aq_required |=IAVF_FLAG_AQ_DEL_VLAN_FILTER ; adapter->aq_required |=IAVF_FLAG_AQ_DEL_CLOUD_FILTER ; adapter->aq_required |=IAVF_FLAG_AQ_DEL_FDIR_FILTER ; + adapter->aq_required |=IAVF_FLAG_AQ_DEL_ADV_RSS_CFG ;
adapter->aq_required|=IAVF_FLAG_AQ_DISABLE_QUEUES;drivers/net/ethernet/intel/iavf/iavf_main.c +10
-0}@@ -1646,6 +1654,14 @@ static int iavf_process_aq_command(struct iavf_adapter *adapter)iavf_del_fdir_filter (adapter );return IAVF_SUCCESS ; } +if (adapter->aq_required &IAVF_FLAG_AQ_ADD_ADV_RSS_CFG ) { +iavf_add_adv_rss_cfg (adapter); +return 0 ; + } +if (adapter->aq_required &IAVF_FLAG_AQ_DEL_ADV_RSS_CFG ) { +iavf_del_adv_rss_cfg (adapter); +return 0 ; + }return -EAGAIN ; }@@ -3776,11 +3792,13 @@ static int iavf_probe(struct pci_dev *pdev, const struct pci_device_id *ent) spin_lock_init(&adapter->mac_vlan_list_lock);spin_lock_init (&adapter->cloud_filter_list_lock);spin_lock_init (&adapter->fdir_fltr_lock); +spin_lock_init (&adapter->adv_rss_lock);INIT_LIST_HEAD (&adapter->mac_filter_list);INIT_LIST_HEAD (&adapter->vlan_filter_list);INIT_LIST_HEAD (&adapter->cloud_filter_list);INIT_LIST_HEAD (&adapter->fdir_list_head); +INIT_LIST_HEAD (&adapter->adv_rss_list_head);INIT_WORK (&adapter->reset_task, iavf_reset_task);
INIT_WORK(&adapter->adminq_task, iavf_adminq_task); @@ -
3886,6 +3904,7 @@ static voidiavf_remove(struct pci_dev *pdev)drivers/net/ethernet/intel/iavf/iavf_main.c +9
-0struct iavf_adapter *adapter =netdev_priv (netdev);struct iavf_fdir_fltr *fdir, *fdirtmp;struct iavf_vlan_filter *vlf, *vlftmp; +struct iavf_adv_rss *rss, *rsstmp;struct iavf_mac_filter *f, *ftmp;struct iavf_cloud_filter *cf, *cftmp;struct iavf_hw *hw = &adapter->hw;@@ -3969,6 +3988,14 @@ static void iavf_remove(struct pci_dev *pdev) }spin_unlock_bh (&adapter->fdir_fltr_lock); +spin_lock_bh (&adapter->adv_rss_lock); +list_for_each_entry_safe (rss, rsstmp, &adapter->adv_rss_list_head, + list) { +list_del (&rss->list); +kfree (rss); + } +spin_unlock_bh (&adapter->adv_rss_lock); +free_netdev (netdev);pci_disable_pcie_error_reporting (pdev);drivers/net/ethernet/intel/iavf/iavf_virtchnl.c +1
-0@@ -142,6 +142,7 @@ int iavf_send_vf_config_msg(struct iavf_adapter *adapter)VIRTCHNL_VF_OFFLOAD_ADQ |VIRTCHNL_VF_OFFLOAD_USO |VIRTCHNL_VF_OFFLOAD_FDIR_PF | +VIRTCHNL_VF_OFFLOAD_ADV_RSS_PF |VIRTCHNL_VF_CAP_ADV_LINK_SPEED ;
adapter->current_op=VIRTCHNL_OP_GET_VF_RESOURCES; @@ -
1294,6 +1295,102 @@ voidiavf_del_fdir_filter(struct iavf_adapter *adapter)
iavf_send_pf_msg(adapter,VIRTCHNL_OP_DEL_FDIR_FILTER, (u8
*)&f, len); }drivers/net/ethernet/intel/iavf/iavf_virtchnl.c +16
-0+/** +* iavf_add_adv_rss_cfg +* @adapter: the VF adapter structure +* +* Request that the PF add RSS configuration as specified +* by the user via ethtool. +**/ +void iavf_add_adv_rss_cfg (struct iavf_adapter *adapter) { +struct virtchnl_rss_cfg *rss_cfg; +struct iavf_adv_rss *rss; +bool process_rss = false; +int len; + +if (adapter->current_op !=VIRTCHNL_OP_UNKNOWN ) { +/* bail because we already have a command pending */ + dev_err(&adapter->pdev->dev, "Cannot add RSSconfiguration, command %d pending\n",
drivers/net/ethernet/intel/iavf/iavf_virtchnl.c +26
-0+ adapter->current_op); +return ; + } + + len =sizeof (struct virtchnl_rss_cfg ); + rss_cfg =kzalloc (len,GFP_KERNEL ); +if (!rss_cfg) +return ; + +spin_lock_bh (&adapter->adv_rss_lock); +list_for_each_entry (rss, &adapter->adv_rss_list_head, list) { +if (rss->state ==IAVF_ADV_RSS_ADD_REQUEST ) { + process_rss = true; + rss->state =IAVF_ADV_RSS_ADD_PENDING ; +memcpy (rss_cfg, &rss->cfg_msg, len); +break ; + } + } +spin_unlock_bh (&adapter->adv_rss_lock); + +if (process_rss) { + adapter->current_op =VIRTCHNL_OP_ADD_RSS_CFG ; +iavf_send_pf_msg (adapter,VIRTCHNL_OP_ADD_RSS_CFG , + (u8 *)rss_cfg, len); + }else { + adapter->aq_required &=~IAVF_FLAG_AQ_ADD_ADV_RSS_CFG;
drivers/net/ethernet/intel/iavf/iavf_virtchnl.c +21
-0+ } + +kfree (rss_cfg); +} + +/** +* iavf_del_adv_rss_cfg +* @adapter: the VF adapter structure +* +* Request that the PF delete RSS configuration as specified +* by the user via ethtool. +**/ +void iavf_del_adv_rss_cfg (struct iavf_adapter *adapter) { +struct virtchnl_rss_cfg *rss_cfg; +struct iavf_adv_rss *rss; +bool process_rss = false; +int len; + +if (adapter->current_op !=VIRTCHNL_OP_UNKNOWN ) { +/* bail because we already have a command pending */ + dev_err(&adapter->pdev->dev, "Cannot remove RSSconfiguration, command %d pending\n",
drivers/net/ethernet/intel/iavf/iavf_virtchnl.c +26
-0+ adapter->current_op); +return ; + } + + len =sizeof (struct virtchnl_rss_cfg ); + rss_cfg =kzalloc (len,GFP_KERNEL ); +if (!rss_cfg) +return ; + +spin_lock_bh (&adapter->adv_rss_lock); +list_for_each_entry (rss, &adapter->adv_rss_list_head, list) { +if (rss->state ==IAVF_ADV_RSS_DEL_REQUEST ) { + process_rss = true; + rss->state =IAVF_ADV_RSS_DEL_PENDING ; +memcpy (rss_cfg, &rss->cfg_msg, len); +break ; + } + } +spin_unlock_bh (&adapter->adv_rss_lock); + +if (process_rss) { + adapter->current_op =VIRTCHNL_OP_DEL_RSS_CFG ; +iavf_send_pf_msg (adapter,VIRTCHNL_OP_DEL_RSS_CFG , + (u8 *)rss_cfg, len); + }else { + adapter->aq_required &=~IAVF_FLAG_AQ_DEL_ADV_RSS_CFG;
drivers/net/ethernet/intel/iavf/iavf_virtchnl.c +25
-0+ } + +kfree (rss_cfg); +} +/** * iavf_request_reset * @adapter: adapter structure @@ -1494,6 +1591,37 @@ void iavf_virtchnl_completion(struct iavf_adapter *adapter,spin_unlock_bh (&adapter->fdir_fltr_lock); }break ; +case VIRTCHNL_OP_ADD_RSS_CFG : { +struct iavf_adv_rss *rss, *rss_tmp; + +spin_lock_bh (&adapter->adv_rss_lock); +list_for_each_entry_safe (rss, rss_tmp, + &adapter- >adv_rss_list_head, + list) { +if (rss->state ==IAVF_ADV_RSS_ADD_PENDING ) { +list_del (&rss->list); +kfree (rss); + } + } +spin_unlock_bh (&adapter->adv_rss_lock); + } +break ; +case VIRTCHNL_OP_DEL_RSS_CFG : { +struct iavf_adv_rss *rss; + +spin_lock_bh (&adapter->adv_rss_lock); + list_for_each_entry(rss, &adapter-Quoted 1 line
adv_rss_list_head,drivers/net/ethernet/intel/iavf/iavf_virtchnl.c +2
-0+ list) { + if (rss->state ==
IAVF_ADV_RSS_DEL_PENDING) {drivers/net/ethernet/intel/iavf/iavf_virtchnl.c +2
-0+ rss->state =IAVF_ADV_RSS_ACTIVE ; + dev_err(&adapter->pdev->dev,"Failed to delete RSS configuration, error %s\n",
drivers/net/ethernet/intel/iavf/iavf_virtchnl.c +7
-0+iavf_stat_str (&adapter->hw, + v_retval)); + } + } +spin_unlock_bh (&adapter->adv_rss_lock); + } +break ;case VIRTCHNL_OP_ENABLE_VLAN_STRIPPING :case VIRTCHNL_OP_DISABLE_VLAN_STRIPPING : dev_warn(&adapter->pdev->dev, "Changing VLANStripping is not allowed when Port VLAN is configured\n"); @@ -1683,6 +1811,30 @@ void iavf_virtchnl_completion(struct
iavf_adapter*adapter,drivers/net/ethernet/intel/iavf/iavf_virtchnl.c +24
-0spin_unlock_bh (&adapter->fdir_fltr_lock); }break ; +case VIRTCHNL_OP_ADD_RSS_CFG : { +struct iavf_adv_rss *rss; + +spin_lock_bh (&adapter->adv_rss_lock); +list_for_each_entry (rss, &adapter->adv_rss_list_head, list) +if (rss->state ==IAVF_ADV_RSS_ADD_PENDING ) + rss->state =IAVF_ADV_RSS_ACTIVE ; +spin_unlock_bh (&adapter->adv_rss_lock); + } +break ; +case VIRTCHNL_OP_DEL_RSS_CFG : { +struct iavf_adv_rss *rss, *rss_tmp; + +spin_lock_bh (&adapter->adv_rss_lock); +list_for_each_entry_safe (rss, rss_tmp, + &adapter->adv_rss_list_head, list) { +if (rss->state ==IAVF_ADV_RSS_DEL_PENDING ) { +list_del (&rss->list); +kfree (rss); + } + } +spin_unlock_bh (&adapter->adv_rss_lock); + } +break ;default : if (adapter->current_op && (v_opcode != adapter-Quoted 1 line
current_op))
Quoted 2 lines
dev_warn(&adapter->pdev->dev, "Expected
response %d from PF, received %d\n",
PATCH v3 4/6 iavf: Support for modifying TCP RSS flow hashing
In reply to Haiyue WangProvides the ability to enable TCP RSS hashing by ethtool.
It gives users option of generating RSS hash based on the TCP source and destination ports numbers, IPv4 or IPv6 source and destination addresses.
--- drivers/net/ethernet/intel/iavf/Makefile | 1 + .../net/ethernet/intel/iavf/iavf_adv_rss.c | 170 ++++++++++++++ .../net/ethernet/intel/iavf/iavf_adv_rss.h | 54 +++++ .../net/ethernet/intel/iavf/iavf_ethtool.c | 214 +++++++++++++++++- .../net/ethernet/intel/iavf/iavf_virtchnl.c | 15 +- 5 files changed, 450 insertions(+), 4 deletions(-) create mode 100644 drivers/net/ethernet/intel/iavf/iavf_adv_rss.c
drivers/net/ethernet/intel/iavf/Makefile +1 -0
@@ -12,4 +12,5 @@ subdir-ccflags-y += -I$(src) obj-$(CONFIG_IAVF) += iavf.o iavf-objs := iavf_main.o iavf_ethtool.o iavf_virtchnl.o iavf_fdir.o \ + iavf_adv_rss.o \ iavf_txrx.o iavf_common.o iavf_adminq.o iavf_client.o
drivers/net/ethernet/intel/iavf/iavf_adv_rss.c new file +170 -0
170 lines not on this page · raw message
drivers/net/ethernet/intel/iavf/iavf_adv_rss.h +54 -0
65 lines not on this page · raw message
drivers/net/ethernet/intel/iavf/iavf_ethtool.c +212 -2
232 lines not on this page · raw message
drivers/net/ethernet/intel/iavf/iavf_virtchnl.c +13 -2
@@ -1327,6 +1327,9 @@ void iavf_add_adv_rss_cfg(struct iavf_adapter *adapter) process_rss = true; rss->state =IAVF_ADV_RSS_ADD_PENDING ;memcpy (rss_cfg, &rss->cfg_msg, len); +iavf_print_adv_rss_cfg (adapter, rss, +"Input set change for" , +"is pending" );break ; } }
@@ -1599,6 +1602,9 @@ void iavf_virtchnl_completion(struct iavf_adapter *adapter, &adapter->adv_rss_list_head, list) {if (rss->state ==IAVF_ADV_RSS_ADD_PENDING ) { +iavf_print_adv_rss_cfg (adapter, rss, +"Failed to change the input set for" , +NULL );list_del (&rss->list);kfree (rss); }
@@ -1815,9 +1821,14 @@ void iavf_virtchnl_completion(struct iavf_adapter *adapter,struct iavf_adv_rss *rss;spin_lock_bh (&adapter->adv_rss_lock); -list_for_each_entry (rss, &adapter->adv_rss_list_head, list) -if (rss->state ==IAVF_ADV_RSS_ADD_PENDING ) +list_for_each_entry (rss, &adapter->adv_rss_list_head, list) { +if (rss->state ==IAVF_ADV_RSS_ADD_PENDING ) { +iavf_print_adv_rss_cfg (adapter, rss, +"Input set change for" , +"successful" ); rss->state =IAVF_ADV_RSS_ACTIVE ; + } + }spin_unlock_bh (&adapter->adv_rss_lock); }break ;
Signature · 1 line
2.31.1
Jankowski
PATCH v3 4/6 iavf: Support for modifying TCP RSS flow hashing
Quoted 576 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Haiyue Wang
Sent: wtorek, 13 kwietnia 2021 02:49
To: intel-wired-lan at lists.osuosl.org
Cc: Zhang, Qi Z <[email protected]>
Subject: [Intel-wired-lan] [PATCH net-next v3 4/6] iavf: Support for modifying TCP RSS flow hashingProvides the ability to enable TCP RSS hashing by ethtool.
It gives users option of generating RSS hash based on the TCP source and destination ports numbers, IPv4 or IPv6 source and destination addresses.
Signed-off-by Haiyue Wang <[email protected]>--- drivers/net/ethernet/intel/iavf/Makefile | 1 + .../net/ethernet/intel/iavf/iavf_adv_rss.c | 170 ++++++++++++++ .../net/ethernet/intel/iavf/iavf_adv_rss.h | 54 +++++ .../net/ethernet/intel/iavf/iavf_ethtool.c | 214 +++++++++++++++++- .../net/ethernet/intel/iavf/iavf_virtchnl.c | 15 +- 5 files changed, 450 insertions(+), 4 deletions(-) create mode 100644
drivers/net/ethernet/intel/iavf/iavf_adv_rss.cdrivers/net/ethernet/intel/iavf/Makefile +1
-0@@ -12,4 +12,5 @@ subdir-ccflags-y += -I$(src) obj-$(CONFIG_IAVF) += iavf.o iavf-objs := iavf_main.o iavf_ethtool.o iavf_virtchnl.o iavf_fdir.o \ + iavf_adv_rss.o \ iavf_txrx.o iavf_common.o iavf_adminq.o iavf_client.o diff --git
a/drivers/net/ethernet/intel/iavf/iavf_adv_rss.cb/drivers/net/ethernet/intel/iavf/iavf_adv_rss.c
new file mode 100644
index 000000000000..4c5771cdc445drivers/net/ethernet/intel/iavf/iavf_adv_rss.c new file +45
-0@@ -0,0 +1,170 @@ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright (c) 2021, Intel Corporation. */ + +/* advanced RSS configuration ethtool support for iavf */ + +#include "iavf.h" + +/** +* iavf_fill_adv_rss_ip4_hdr - fill the IPv4 RSS protocol header +* @hdr: the virtchnl message protocol header data structure +* @hash_flds: the RSS configuration protocol hash fields */ static +void iavf_fill_adv_rss_ip4_hdr (struct virtchnl_proto_hdr *hdr,u64 +hash_flds) { +VIRTCHNL_SET_PROTO_HDR_TYPE (hdr,IPV4 ); + +if (hash_flds &IAVF_ADV_RSS_HASH_FLD_IPV4_SA ) +VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT (hdr,IPV4 ,SRC ); + +if (hash_flds &IAVF_ADV_RSS_HASH_FLD_IPV4_DA ) +VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT (hdr,IPV4 ,DST ); } + +/** +* iavf_fill_adv_rss_ip6_hdr - fill the IPv6 RSS protocol header +* @hdr: the virtchnl message protocol header data structure +* @hash_flds: the RSS configuration protocol hash fields */ static +void iavf_fill_adv_rss_ip6_hdr (struct virtchnl_proto_hdr *hdr,u64 +hash_flds) { +VIRTCHNL_SET_PROTO_HDR_TYPE (hdr,IPV6 ); + +if (hash_flds &IAVF_ADV_RSS_HASH_FLD_IPV6_SA ) +VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT (hdr,IPV6 ,SRC ); + +if (hash_flds &IAVF_ADV_RSS_HASH_FLD_IPV6_DA ) +VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT (hdr,IPV6 ,DST ); } + +/** +* iavf_fill_adv_rss_tcp_hdr - fill the TCP RSS protocol header +* @hdr: the virtchnl message protocol header data structure +* @hash_flds: the RSS configuration protocol hash fields */ static +void iavf_fill_adv_rss_tcp_hdr (struct virtchnl_proto_hdr *hdr,u64 +hash_flds) { +VIRTCHNL_SET_PROTO_HDR_TYPE (hdr,TCP ); + +if (hash_flds &IAVF_ADV_RSS_HASH_FLD_TCP_SRC_PORT ) + VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT(hdr, TCP,
SRC_PORT);drivers/net/ethernet/intel/iavf/iavf_adv_rss.c new file +3
-0+ +if (hash_flds &IAVF_ADV_RSS_HASH_FLD_TCP_DST_PORT ) + VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT(hdr, TCP,
DST_PORT); }drivers/net/ethernet/intel/iavf/iavf_adv_rss.c new file +18
-0+ +/** +* iavf_fill_adv_rss_cfg_msg - fill the RSS configuration into virtchnl +message +* @rss_cfg: the virtchnl message to be filled with RSS configuration +setting +* @packet_hdrs: the RSS configuration protocol header types +* @hash_flds: the RSS configuration protocol hash fields +* +* Returns 0 if the RSS configuration virtchnl message is filled +successfully */ int iavf_fill_adv_rss_cfg_msg (struct virtchnl_rss_cfg +*rss_cfg, +u32 packet_hdrs,u64 hash_flds) +{ +struct virtchnl_proto_hdrs *proto_hdrs = &rss_cfg->proto_hdrs; +struct virtchnl_proto_hdr *hdr; + + rss_cfg->rss_algorithm =
VIRTCHNL_RSS_ALG_TOEPLITZ_ASYMMETRIC;drivers/net/ethernet/intel/iavf/iavf_adv_rss.c new file +56
-0+ + proto_hdrs->tunnel_level =0 ;/* always outer layer */ + + hdr = &proto_hdrs->proto_hdr[proto_hdrs->count++]; +switch (packet_hdrs &IAVF_ADV_RSS_FLOW_SEG_HDR_L3 ) { +case IAVF_ADV_RSS_FLOW_SEG_HDR_IPV4 : +iavf_fill_adv_rss_ip4_hdr (hdr, hash_flds); +break ; +case IAVF_ADV_RSS_FLOW_SEG_HDR_IPV6 : +iavf_fill_adv_rss_ip6_hdr (hdr, hash_flds); +break ; +default : +return -EINVAL ; + } + + hdr = &proto_hdrs->proto_hdr[proto_hdrs->count++]; +switch (packet_hdrs &IAVF_ADV_RSS_FLOW_SEG_HDR_L4 ) { +case IAVF_ADV_RSS_FLOW_SEG_HDR_TCP : +iavf_fill_adv_rss_tcp_hdr (hdr, hash_flds); +break ; +default : +return -EINVAL ; + } + +return 0 ; +} + +/** +* iavf_find_adv_rss_cfg_by_hdrs - find RSS configuration with header +type +* @adapter: pointer to the VF adapter structure +* @packet_hdrs: protocol header type to find. +* +* Returns pointer to advance RSS configuration if found or null */ +struct iavf_adv_rss *iavf_find_adv_rss_cfg_by_hdrs (struct iavf_adapter +*adapter,u32 packet_hdrs) { +struct iavf_adv_rss *rss; + +list_for_each_entry (rss, &adapter->adv_rss_list_head, list) +if (rss->packet_hdrs == packet_hdrs) +return rss; + +return NULL ; +} + +/** +* iavf_print_adv_rss_cfg +* @adapter: pointer to the VF adapter structure +* @rss: pointer to the advance RSS configuration to print +* @action: the string description about how to handle the RSS +* @result: the string description about the virtchnl result +* +* Print the advance RSS configuration +**/ +void +iavf_print_adv_rss_cfg(struct iavf_adapter *adapter, struct iavf_adv_rss*rss,
drivers/net/ethernet/intel/iavf/iavf_adv_rss.c new file +37
-0+ const char *action, const char *result) { + u32 packet_hdrs = rss->packet_hdrs; +u64 hash_flds = rss->hash_flds; +static char hash_opt[300 ]; +const char *proto; + +if (packet_hdrs &IAVF_ADV_RSS_FLOW_SEG_HDR_TCP ) + proto ="TCP" ; +else +return ; + +memset (hash_opt,0 ,sizeof (hash_opt)); + +strcat (hash_opt, proto); +if (packet_hdrs &IAVF_ADV_RSS_FLOW_SEG_HDR_IPV4 ) +strcat (hash_opt,"v4 " ); +else +strcat (hash_opt,"v6 " ); + +if (hash_flds & (IAVF_ADV_RSS_HASH_FLD_IPV4_SA | +IAVF_ADV_RSS_HASH_FLD_IPV6_SA )) +strcat (hash_opt,"IP SA," ); +if (hash_flds & (IAVF_ADV_RSS_HASH_FLD_IPV4_DA | +IAVF_ADV_RSS_HASH_FLD_IPV6_DA )) +strcat (hash_opt,"IP DA," ); +if (hash_flds &IAVF_ADV_RSS_HASH_FLD_TCP_SRC_PORT ) +strcat (hash_opt,"src port," ); +if (hash_flds &IAVF_ADV_RSS_HASH_FLD_TCP_DST_PORT ) +strcat (hash_opt,"dst port," ); + +if (!action) + action ="" ; + +if (!result) + result ="" ; + + dev_info(&adapter->pdev->dev, "%s %s %s\n", action, hash_opt,result);
drivers/net/ethernet/intel/iavf/iavf_adv_rss.c new file +1
-0+}drivers/net/ethernet/intel/iavf/iavf_adv_rss.h +54
-0@@ -15,11 +15,65 @@ enum iavf_adv_rss_state_t { IAVF_ADV_RSS_ACTIVE, /* RSS configuration is active */ }; +enum iavf_adv_rss_flow_seg_hdr { +IAVF_ADV_RSS_FLOW_SEG_HDR_NONE =0x00000000 , +IAVF_ADV_RSS_FLOW_SEG_HDR_IPV4 =0x00000001 , +IAVF_ADV_RSS_FLOW_SEG_HDR_IPV6 =0x00000002 , +IAVF_ADV_RSS_FLOW_SEG_HDR_TCP =0x00000004 , +}; + +#define IAVF_ADV_RSS_FLOW_SEG_HDR_L3 \ + (IAVF_ADV_RSS_FLOW_SEG_HDR_IPV4 | \ + IAVF_ADV_RSS_FLOW_SEG_HDR_IPV6) + +#define IAVF_ADV_RSS_FLOW_SEG_HDR_L4 \ + (IAVF_ADV_RSS_FLOW_SEG_HDR_TCP) + +enum iavf_adv_rss_flow_field { +/* L3 */ +IAVF_ADV_RSS_FLOW_FIELD_IDX_IPV4_SA , +IAVF_ADV_RSS_FLOW_FIELD_IDX_IPV4_DA , +IAVF_ADV_RSS_FLOW_FIELD_IDX_IPV6_SA , +IAVF_ADV_RSS_FLOW_FIELD_IDX_IPV6_DA , +/* L4 */ +IAVF_ADV_RSS_FLOW_FIELD_IDX_TCP_SRC_PORT , +IAVF_ADV_RSS_FLOW_FIELD_IDX_TCP_DST_PORT , + +/* The total number of enums must not exceed 64 */ +IAVF_ADV_RSS_FLOW_FIELD_IDX_MAX +}; + +#define IAVF_ADV_RSS_HASH_INVALID 0 +#define IAVF_ADV_RSS_HASH_FLD_IPV4_SA \ + BIT_ULL(IAVF_ADV_RSS_FLOW_FIELD_IDX_IPV4_SA) +#define IAVF_ADV_RSS_HASH_FLD_IPV6_SA \ + BIT_ULL(IAVF_ADV_RSS_FLOW_FIELD_IDX_IPV6_SA) +#define IAVF_ADV_RSS_HASH_FLD_IPV4_DA \ + BIT_ULL(IAVF_ADV_RSS_FLOW_FIELD_IDX_IPV4_DA) +#define IAVF_ADV_RSS_HASH_FLD_IPV6_DA \ + BIT_ULL(IAVF_ADV_RSS_FLOW_FIELD_IDX_IPV6_DA) +#define IAVF_ADV_RSS_HASH_FLD_TCP_SRC_PORT \ + BIT_ULL(IAVF_ADV_RSS_FLOW_FIELD_IDX_TCP_SRC_PORT) +#define IAVF_ADV_RSS_HASH_FLD_TCP_DST_PORT \ + BIT_ULL(IAVF_ADV_RSS_FLOW_FIELD_IDX_TCP_DST_PORT) +/* bookkeeping of advanced RSS configuration */ struct iavf_adv_rss {enum iavf_adv_rss_state_t state;struct list_head list; +u32 packet_hdrs; +u64 hash_flds; +struct virtchnl_rss_cfg cfg_msg; }; + +int +iavf_fill_adv_rss_cfg_msg (struct virtchnl_rss_cfg *rss_cfg, +u32 packet_hdrs,u64 hash_flds); +struct iavf_adv_rss * +iavf_find_adv_rss_cfg_by_hdrs (struct iavf_adapter *adapter,u32 +packet_hdrs);void iavf_print_adv_rss_cfg (struct iavf_adapter *adapter, +struct iavf_adv_rss *rss, +const char *action,const char *result);#endif /* _IAVF_ADV_RSS_H_ */ drivers/net/ethernet/intel/iavf/iavf_ethtool.c +0
-0@@ -1418,6 +1418,214 @@ static int iavf_del_fdir_ethtool(struct
iavf_adapter*adapter, structethtool_rxdrivers/net/ethernet/intel/iavf/iavf_ethtool.c +63
-0return err; } +/** +* iavf_adv_rss_parse_hdrs - parses headers from RSS hash input +* @cmd: ethtool rxnfc command +* +* This function parses the rxnfc command and returns intended +* header types for RSS configuration +*/ +static u32 iavf_adv_rss_parse_hdrs (struct ethtool_rxnfc *cmd) { +u32 hdrs =IAVF_ADV_RSS_FLOW_SEG_HDR_NONE ; + +switch (cmd->flow_type) { +case TCP_V4_FLOW : + hdrs |=IAVF_ADV_RSS_FLOW_SEG_HDR_TCP | +IAVF_ADV_RSS_FLOW_SEG_HDR_IPV4 ; +break ; +case TCP_V6_FLOW : + hdrs |=IAVF_ADV_RSS_FLOW_SEG_HDR_TCP | +IAVF_ADV_RSS_FLOW_SEG_HDR_IPV6 ; +break ; +default : +break ; + } + +return hdrs; +} + +/** +* iavf_adv_rss_parse_hash_flds - parses hash fields from RSS hash +input +* @cmd: ethtool rxnfc command +* +* This function parses the rxnfc command and returns intended hash +fields for +* RSS configuration +*/ +static u64 iavf_adv_rss_parse_hash_flds (struct ethtool_rxnfc *cmd) { +u64 hfld =IAVF_ADV_RSS_HASH_INVALID ; + +if (cmd->data &RXH_IP_SRC || cmd->data &RXH_IP_DST ) { +switch (cmd->flow_type) { +case TCP_V4_FLOW : +if (cmd->data &RXH_IP_SRC ) + hfld |=IAVF_ADV_RSS_HASH_FLD_IPV4_SA ; +if (cmd->data &RXH_IP_DST ) + hfld |=IAVF_ADV_RSS_HASH_FLD_IPV4_DA ; +break ; +case TCP_V6_FLOW : +if (cmd->data &RXH_IP_SRC ) + hfld |=IAVF_ADV_RSS_HASH_FLD_IPV6_SA ; +if (cmd->data &RXH_IP_DST ) + hfld |=IAVF_ADV_RSS_HASH_FLD_IPV6_DA ; +break ; +default : +break ; + } + } + +if (cmd->data &RXH_L4_B_0_1 || cmd->data &RXH_L4_B_2_3 ) { +switch (cmd->flow_type) { +case TCP_V4_FLOW : +case TCP_V6_FLOW : +if (cmd->data &RXH_L4_B_0_1 ) + hfld |=
IAVF_ADV_RSS_HASH_FLD_TCP_SRC_PORT;drivers/net/ethernet/intel/iavf/iavf_ethtool.c +2
-0+if (cmd->data &RXH_L4_B_2_3 ) + hfld |=
IAVF_ADV_RSS_HASH_FLD_TCP_DST_PORT;drivers/net/ethernet/intel/iavf/iavf_ethtool.c +42
-0+break ; +default : +break ; + } + } + +return hfld; +} + +/** +* iavf_set_adv_rss_hash_opt - Enable/Disable flow types for RSS hash +* @adapter: pointer to the VF adapter structure +* @cmd: ethtool rxnfc command +* +* Returns Success if the flow input set is supported. +*/ +static int +iavf_set_adv_rss_hash_opt (struct iavf_adapter *adapter, +struct ethtool_rxnfc *cmd) +{ +struct iavf_adv_rss *rss_old, *rss_new; +bool rss_new_add = false; +int count =50 , err =0 ; +u64 hash_flds; +u32 hdrs; + +if (!ADV_RSS_SUPPORT (adapter)) +return -EOPNOTSUPP ; + + hdrs =iavf_adv_rss_parse_hdrs (cmd); +if (hdrs ==IAVF_ADV_RSS_FLOW_SEG_HDR_NONE ) +return -EINVAL ; + + hash_flds =iavf_adv_rss_parse_hash_flds (cmd); +if (hash_flds ==IAVF_ADV_RSS_HASH_INVALID ) +return -EINVAL ; + + rss_new =kzalloc (sizeof (*rss_new),GFP_KERNEL ); +if (!rss_new) +return -ENOMEM ; + +if (iavf_fill_adv_rss_cfg_msg (&rss_new->cfg_msg, hdrs, hash_flds)){
drivers/net/ethernet/intel/iavf/iavf_ethtool.c +25
-0+kfree (rss_new); +return -EINVAL ; + } + +while (test_and_set_bit (__IAVF_IN_CRITICAL_TASK, + &adapter->crit_section)) { +if (--count ==0 ) { +kfree (rss_new); +return -EINVAL ; + } + +udelay (1 ); + } + +spin_lock_bh (&adapter->adv_rss_lock); + rss_old =iavf_find_adv_rss_cfg_by_hdrs (adapter, hdrs); +if (rss_old) { +if (rss_old->state !=IAVF_ADV_RSS_ACTIVE ) { + err = -EBUSY ; + }else if (rss_old->hash_flds != hash_flds) { + rss_old->state =IAVF_ADV_RSS_ADD_REQUEST ; + rss_old->hash_flds = hash_flds; +memcpy (&rss_old->cfg_msg, &rss_new->cfg_msg, +sizeof (rss_new->cfg_msg)); + adapter->aq_required |=
IAVF_FLAG_AQ_ADD_ADV_RSS_CFG;drivers/net/ethernet/intel/iavf/iavf_ethtool.c +10
-0+ }else { + err = -EEXIST ; + } + }else { + rss_new_add = true; + rss_new->state =IAVF_ADV_RSS_ADD_REQUEST ; + rss_new->packet_hdrs = hdrs; + rss_new->hash_flds = hash_flds; +list_add_tail (&rss_new->list, &adapter->adv_rss_list_head); + adapter->aq_required |=
IAVF_FLAG_AQ_ADD_ADV_RSS_CFG;drivers/net/ethernet/intel/iavf/iavf_ethtool.c +67
-0+ } +spin_unlock_bh (&adapter->adv_rss_lock); + +if (!err) +mod_delayed_work (iavf_wq, &adapter->watchdog_task,0 ); + +clear_bit (__IAVF_IN_CRITICAL_TASK, &adapter->crit_section); + +if (!rss_new_add) +kfree (rss_new); + +return err; +} + +/** +* iavf_get_adv_rss_hash_opt - Retrieve hash fields for a given +flow-type +* @adapter: pointer to the VF adapter structure +* @cmd: ethtool rxnfc command +* +* Returns Success if the flow input set is supported. +*/ +static int +iavf_get_adv_rss_hash_opt (struct iavf_adapter *adapter, +struct ethtool_rxnfc *cmd) +{ +struct iavf_adv_rss *rss; +u64 hash_flds; +u32 hdrs; + +if (!ADV_RSS_SUPPORT (adapter)) +return -EOPNOTSUPP ; + + cmd->data =0 ; + + hdrs =iavf_adv_rss_parse_hdrs (cmd); +if (hdrs ==IAVF_ADV_RSS_FLOW_SEG_HDR_NONE ) +return -EINVAL ; + +spin_lock_bh (&adapter->adv_rss_lock); + rss =iavf_find_adv_rss_cfg_by_hdrs (adapter, hdrs); +if (rss) + hash_flds = rss->hash_flds; +else + hash_flds =IAVF_ADV_RSS_HASH_INVALID ; +spin_unlock_bh (&adapter->adv_rss_lock); + +if (hash_flds ==IAVF_ADV_RSS_HASH_INVALID ) +return -EINVAL ; + +if (hash_flds & (IAVF_ADV_RSS_HASH_FLD_IPV4_SA | +IAVF_ADV_RSS_HASH_FLD_IPV6_SA )) + cmd->data |= (u64 )RXH_IP_SRC ; + +if (hash_flds & (IAVF_ADV_RSS_HASH_FLD_IPV4_DA | +IAVF_ADV_RSS_HASH_FLD_IPV6_DA )) + cmd->data |= (u64 )RXH_IP_DST ; + +if (hash_flds &IAVF_ADV_RSS_HASH_FLD_TCP_SRC_PORT ) + cmd->data |= (u64 )RXH_L4_B_0_1 ; + +if (hash_flds &IAVF_ADV_RSS_HASH_FLD_TCP_DST_PORT ) + cmd->data |= (u64 )RXH_L4_B_2_3 ; + +return 0 ; +} +/** * iavf_set_rxnfc - command to set Rx flow rules. * @netdev: network interface device structure @@ -1437,6 +1645,9 @@ static int
iavf_set_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *cmd)drivers/net/ethernet/intel/iavf/iavf_ethtool.c +4
-2case ETHTOOL_SRXCLSRLDEL : ret =iavf_del_fdir_ethtool (adapter, cmd);break ; +case ETHTOOL_SRXFH : + ret =iavf_set_adv_rss_hash_opt (adapter, cmd); +break ;default :break ; }@@ -1477,8 +1688,7 @@ static int iavf_get_rxnfc(struct net_device *netdev,struct ethtool_rxnfc *cmd, ret =iavf_get_fdir_fltr_ids (adapter, cmd, (u32 *)rule_locs);break ;case ETHTOOL_GRXFH : -netdev_info (netdev, -"RSS hash info is not available to vf, use pf.\n" ); + ret =iavf_get_adv_rss_hash_opt (adapter, cmd);break ;default :drivers/net/ethernet/intel/iavf/iavf_ethtool.c +0
-0break ;drivers/net/ethernet/intel/iavf/iavf_virtchnl.c +3
-0@@ -1327,6 +1327,9 @@ void iavf_add_adv_rss_cfg(struct iavf_adapter *adapter) process_rss = true; rss->state =IAVF_ADV_RSS_ADD_PENDING ;memcpy (rss_cfg, &rss->cfg_msg, len); +iavf_print_adv_rss_cfg (adapter, rss, +"Input set change for" , +"is pending" );break ; }drivers/net/ethernet/intel/iavf/iavf_virtchnl.c +2
-0}@@ -1599,6 +1602,9 @@ void iavf_virtchnl_completion(struct iavf_adapter *adapter, &adapter- >adv_rss_list_head, list) {if (rss->state ==IAVF_ADV_RSS_ADD_PENDING ) { + iavf_print_adv_rss_cfg(adapter, rss, + "Failed to changethe input set for",
drivers/net/ethernet/intel/iavf/iavf_virtchnl.c +8
-2+ NULL);list_del (&rss->list);kfree (rss); }@@ -1815,9 +1821,14 @@ void iavf_virtchnl_completion(struct iavf_adapter *adapter, struct iavf_adv_rss *rss;spin_lock_bh (&adapter->adv_rss_lock); -list_for_each_entry (rss, &adapter->adv_rss_list_head, list) -if (rss->state ==IAVF_ADV_RSS_ADD_PENDING ) +list_for_each_entry (rss, &adapter->adv_rss_list_head, list) { +if (rss->state ==IAVF_ADV_RSS_ADD_PENDING ) { +iavf_print_adv_rss_cfg (adapter, rss, +"Input set change for" , +"successful" ); rss->state =IAVF_ADV_RSS_ACTIVE ; + } + }spin_unlock_bh (&adapter->adv_rss_lock); }
Quoted 1 line
break;
PATCH v3 5/6 iavf: Support for modifying UDP RSS flow hashing
In reply to Haiyue WangProvides the ability to enable UDP RSS hashing by ethtool.
It gives users option of generating RSS hash based on the UDP source and destination ports numbers, IPv4 or IPv6 source and destination addresses.
--- .../net/ethernet/intel/iavf/iavf_adv_rss.c | 28 +++++++++++++++++-- .../net/ethernet/intel/iavf/iavf_adv_rss.h | 10 ++++++- .../net/ethernet/intel/iavf/iavf_ethtool.c | 23 +++++++++++++-- 3 files changed, 56 insertions(+), 5 deletions(-)
drivers/net/ethernet/intel/iavf/iavf_adv_rss.c +26 -2
@@ -56,6 +56,23 @@ iavf_fill_adv_rss_tcp_hdr(struct virtchnl_proto_hdr *hdr, u64 hash_flds)VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT (hdr,TCP ,DST_PORT ); } +/** +* iavf_fill_adv_rss_udp_hdr - fill the UDP RSS protocol header +* @hdr: the virtchnl message protocol header data structure +* @hash_flds: the RSS configuration protocol hash fields +*/ +static void +iavf_fill_adv_rss_udp_hdr (struct virtchnl_proto_hdr *hdr,u64 hash_flds) +{ +VIRTCHNL_SET_PROTO_HDR_TYPE (hdr,UDP ); + +if (hash_flds &IAVF_ADV_RSS_HASH_FLD_UDP_SRC_PORT ) +VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT (hdr,UDP ,SRC_PORT ); + +if (hash_flds &IAVF_ADV_RSS_HASH_FLD_UDP_DST_PORT ) +VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT (hdr,UDP ,DST_PORT ); +} +/** * iavf_fill_adv_rss_cfg_msg - fill the RSS configuration into virtchnl message * @rss_cfg: the virtchnl message to be filled with RSS configuration setting
@@ -92,6 +109,9 @@ iavf_fill_adv_rss_cfg_msg(struct virtchnl_rss_cfg *rss_cfg,case IAVF_ADV_RSS_FLOW_SEG_HDR_TCP :iavf_fill_adv_rss_tcp_hdr (hdr, hash_flds);break ; +case IAVF_ADV_RSS_FLOW_SEG_HDR_UDP : +iavf_fill_adv_rss_udp_hdr (hdr, hash_flds); +break ;default :return -EINVAL ; }
@@ -138,6 +158,8 @@ iavf_print_adv_rss_cfg(struct iavf_adapter *adapter, struct iavf_adv_rss *rss,if (packet_hdrs &IAVF_ADV_RSS_FLOW_SEG_HDR_TCP ) proto ="TCP" ; +else if (packet_hdrs &IAVF_ADV_RSS_FLOW_SEG_HDR_UDP ) + proto ="UDP" ;else return ;
@@ -155,9 +177,11 @@ iavf_print_adv_rss_cfg(struct iavf_adapter *adapter, struct iavf_adv_rss *rss,if (hash_flds & (IAVF_ADV_RSS_HASH_FLD_IPV4_DA |IAVF_ADV_RSS_HASH_FLD_IPV6_DA ))strcat (hash_opt,"IP DA," ); -if (hash_flds &IAVF_ADV_RSS_HASH_FLD_TCP_SRC_PORT ) +if (hash_flds & (IAVF_ADV_RSS_HASH_FLD_TCP_SRC_PORT | +IAVF_ADV_RSS_HASH_FLD_UDP_SRC_PORT ))strcat (hash_opt,"src port," ); -if (hash_flds &IAVF_ADV_RSS_HASH_FLD_TCP_DST_PORT ) +if (hash_flds & (IAVF_ADV_RSS_HASH_FLD_TCP_DST_PORT | +IAVF_ADV_RSS_HASH_FLD_UDP_DST_PORT ))strcat (hash_opt,"dst port," );if (!action)
drivers/net/ethernet/intel/iavf/iavf_adv_rss.h +9 -1
@@ -20,6 +20,7 @@ enum iavf_adv_rss_flow_seg_hdr {IAVF_ADV_RSS_FLOW_SEG_HDR_IPV4 =0x00000001 ,IAVF_ADV_RSS_FLOW_SEG_HDR_IPV6 =0x00000002 ,IAVF_ADV_RSS_FLOW_SEG_HDR_TCP =0x00000004 , + IAVF_ADV_RSS_FLOW_SEG_HDR_UDP = 0x00000008, };#define IAVF_ADV_RSS_FLOW_SEG_HDR_L3 \
@@ -27,7 +28,8 @@ enum iavf_adv_rss_flow_seg_hdr { IAVF_ADV_RSS_FLOW_SEG_HDR_IPV6)#define IAVF_ADV_RSS_FLOW_SEG_HDR_L4 \ - (IAVF_ADV_RSS_FLOW_SEG_HDR_TCP) + (IAVF_ADV_RSS_FLOW_SEG_HDR_TCP | \ + IAVF_ADV_RSS_FLOW_SEG_HDR_UDP)enum iavf_adv_rss_flow_field {/* L3 */
@@ -38,6 +40,8 @@ enum iavf_adv_rss_flow_field {/* L4 */ IAVF_ADV_RSS_FLOW_FIELD_IDX_TCP_SRC_PORT ,IAVF_ADV_RSS_FLOW_FIELD_IDX_TCP_DST_PORT , +IAVF_ADV_RSS_FLOW_FIELD_IDX_UDP_SRC_PORT , +IAVF_ADV_RSS_FLOW_FIELD_IDX_UDP_DST_PORT ,/* The total number of enums must not exceed 64 */ IAVF_ADV_RSS_FLOW_FIELD_IDX_MAX
@@ -56,6 +60,10 @@ enum iavf_adv_rss_flow_field { BIT_ULL(IAVF_ADV_RSS_FLOW_FIELD_IDX_TCP_SRC_PORT)#define IAVF_ADV_RSS_HASH_FLD_TCP_DST_PORT \ BIT_ULL(IAVF_ADV_RSS_FLOW_FIELD_IDX_TCP_DST_PORT) +#define IAVF_ADV_RSS_HASH_FLD_UDP_SRC_PORT \ + BIT_ULL(IAVF_ADV_RSS_FLOW_FIELD_IDX_UDP_SRC_PORT) +#define IAVF_ADV_RSS_HASH_FLD_UDP_DST_PORT \ + BIT_ULL(IAVF_ADV_RSS_FLOW_FIELD_IDX_UDP_DST_PORT)/* bookkeeping of advanced RSS configuration */ struct iavf_adv_rss {
drivers/net/ethernet/intel/iavf/iavf_ethtool.c +21 -2
@@ -1434,10 +1434,18 @@ static u32 iavf_adv_rss_parse_hdrs(struct ethtool_rxnfc *cmd) hdrs |=IAVF_ADV_RSS_FLOW_SEG_HDR_TCP |IAVF_ADV_RSS_FLOW_SEG_HDR_IPV4 ;break ; +case UDP_V4_FLOW : + hdrs |=IAVF_ADV_RSS_FLOW_SEG_HDR_UDP | +IAVF_ADV_RSS_FLOW_SEG_HDR_IPV4 ; +break ;case TCP_V6_FLOW : hdrs |=IAVF_ADV_RSS_FLOW_SEG_HDR_TCP |IAVF_ADV_RSS_FLOW_SEG_HDR_IPV6 ;break ; +case UDP_V6_FLOW : + hdrs |=IAVF_ADV_RSS_FLOW_SEG_HDR_UDP | +IAVF_ADV_RSS_FLOW_SEG_HDR_IPV6 ; +break ;default :break ; }
@@ -1459,12 +1467,14 @@ static u64 iavf_adv_rss_parse_hash_flds(struct ethtool_rxnfc *cmd)if (cmd->data &RXH_IP_SRC || cmd->data &RXH_IP_DST ) {switch (cmd->flow_type) {case TCP_V4_FLOW : +case UDP_V4_FLOW :if (cmd->data &RXH_IP_SRC ) hfld |=IAVF_ADV_RSS_HASH_FLD_IPV4_SA ;if (cmd->data &RXH_IP_DST ) hfld |=IAVF_ADV_RSS_HASH_FLD_IPV4_DA ;break ;case TCP_V6_FLOW : +case UDP_V6_FLOW :if (cmd->data &RXH_IP_SRC ) hfld |=IAVF_ADV_RSS_HASH_FLD_IPV6_SA ;if (cmd->data &RXH_IP_DST )
@@ -1484,6 +1494,13 @@ static u64 iavf_adv_rss_parse_hash_flds(struct ethtool_rxnfc *cmd)if (cmd->data &RXH_L4_B_2_3 ) hfld |=IAVF_ADV_RSS_HASH_FLD_TCP_DST_PORT ;break ; +case UDP_V4_FLOW : +case UDP_V6_FLOW : +if (cmd->data &RXH_L4_B_0_1 ) + hfld |=IAVF_ADV_RSS_HASH_FLD_UDP_SRC_PORT ; +if (cmd->data &RXH_L4_B_2_3 ) + hfld |=IAVF_ADV_RSS_HASH_FLD_UDP_DST_PORT ; +break ;default :break ; }
@@ -1617,10 +1634,12 @@ iavf_get_adv_rss_hash_opt(struct iavf_adapter *adapter, IAVF_ADV_RSS_HASH_FLD_IPV6_DA)) cmd->data |= (u64)RXH_IP_DST; - if (hash_flds & IAVF_ADV_RSS_HASH_FLD_TCP_SRC_PORT) + if (hash_flds & (IAVF_ADV_RSS_HASH_FLD_TCP_SRC_PORT | + IAVF_ADV_RSS_HASH_FLD_UDP_SRC_PORT)) cmd->data |= (u64)RXH_L4_B_0_1; - if (hash_flds & IAVF_ADV_RSS_HASH_FLD_TCP_DST_PORT) + if (hash_flds & (IAVF_ADV_RSS_HASH_FLD_TCP_DST_PORT | + IAVF_ADV_RSS_HASH_FLD_UDP_DST_PORT)) cmd->data |= (u64)RXH_L4_B_2_3;return 0 ;
Signature · 1 line
2.31.1
Jankowski
PATCH v3 5/6 iavf: Support for modifying UDP RSS flow hashing
Quoted 204 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Haiyue Wang
Sent: wtorek, 13 kwietnia 2021 02:49
To: intel-wired-lan at lists.osuosl.org
Cc: Zhang, Qi Z <[email protected]>
Subject: [Intel-wired-lan] [PATCH net-next v3 5/6] iavf: Support for modifying UDP RSS flow hashingProvides the ability to enable UDP RSS hashing by ethtool.
It gives users option of generating RSS hash based on the UDP source and destination ports numbers, IPv4 or IPv6 source and destination addresses.
Signed-off-by Haiyue Wang <[email protected]>--- .../net/ethernet/intel/iavf/iavf_adv_rss.c | 28 +++++++++++++++++-- .../net/ethernet/intel/iavf/iavf_adv_rss.h | 10 ++++++- .../net/ethernet/intel/iavf/iavf_ethtool.c | 23 +++++++++++++-- 3 files changed, 56 insertions(+), 5 deletions(-)drivers/net/ethernet/intel/iavf/iavf_adv_rss.c +17
-0@@ -56,6 +56,23 @@ iavf_fill_adv_rss_tcp_hdr(struct virtchnl_proto_hdr *hdr, u64 hash_flds)VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT (hdr,TCP ,DST_PORT ); } +/** +* iavf_fill_adv_rss_udp_hdr - fill the UDP RSS protocol header +* @hdr: the virtchnl message protocol header data structure +* @hash_flds: the RSS configuration protocol hash fields */ static +void iavf_fill_adv_rss_udp_hdr (struct virtchnl_proto_hdr *hdr,u64 +hash_flds) { +VIRTCHNL_SET_PROTO_HDR_TYPE (hdr,UDP ); + +if (hash_flds &IAVF_ADV_RSS_HASH_FLD_UDP_SRC_PORT ) +VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT (hdr,UDP ,SRC_PORT ); + +if (hash_flds &IAVF_ADV_RSS_HASH_FLD_UDP_DST_PORT ) +VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT (hdr,UDP ,DST_PORT ); } +/** * iavf_fill_adv_rss_cfg_msg - fill the RSS configuration into virtchnl message * @rss_cfg: the virtchnl message to be filled with RSS configuration setting @@ -92,6 +109,9 @@ iavf_fill_adv_rss_cfg_msg(struct virtchnl_rss_cfg *rss_cfg, case IAVF_ADV_RSS_FLOW_SEG_HDR_TCP:iavf_fill_adv_rss_tcp_hdr (hdr, hash_flds);break ; +case IAVF_ADV_RSS_FLOW_SEG_HDR_UDP : +iavf_fill_adv_rss_udp_hdr (hdr, hash_flds); +break ;default :return -EINVAL ;drivers/net/ethernet/intel/iavf/iavf_adv_rss.c +6
-2}@@ -138,6 +158,8 @@ iavf_print_adv_rss_cfg(struct iavf_adapter *adapter,struct iavf_adv_rss *rss, if (packet_hdrs & IAVF_ADV_RSS_FLOW_SEG_HDR_TCP) proto ="TCP" ; + else if (packet_hdrs & IAVF_ADV_RSS_FLOW_SEG_HDR_UDP) + proto ="UDP" ; else return;@@ -155,9 +177,11 @@ iavf_print_adv_rss_cfg(struct iavf_adapter *adapter, struct iavf_adv_rss *rss, if (hash_flds & (IAVF_ADV_RSS_HASH_FLD_IPV4_DA | IAVF_ADV_RSS_HASH_FLD_IPV6_DA))strcat (hash_opt,"IP DA," ); -if (hash_flds &IAVF_ADV_RSS_HASH_FLD_TCP_SRC_PORT ) +if (hash_flds & (IAVF_ADV_RSS_HASH_FLD_TCP_SRC_PORT | +IAVF_ADV_RSS_HASH_FLD_UDP_SRC_PORT ))strcat (hash_opt,"src port," ); -if (hash_flds &IAVF_ADV_RSS_HASH_FLD_TCP_DST_PORT ) +if (hash_flds & (IAVF_ADV_RSS_HASH_FLD_TCP_DST_PORT | +IAVF_ADV_RSS_HASH_FLD_UDP_DST_PORT ))strcat (hash_opt,"dst port," );drivers/net/ethernet/intel/iavf/iavf_adv_rss.c +0
-0if (!action)drivers/net/ethernet/intel/iavf/iavf_adv_rss.h +9
-1@@ -20,6 +20,7 @@ enum iavf_adv_rss_flow_seg_hdr {IAVF_ADV_RSS_FLOW_SEG_HDR_IPV4 =0x00000001 ,IAVF_ADV_RSS_FLOW_SEG_HDR_IPV6 =0x00000002 ,IAVF_ADV_RSS_FLOW_SEG_HDR_TCP =0x00000004 , + IAVF_ADV_RSS_FLOW_SEG_HDR_UDP = 0x00000008, };#define IAVF_ADV_RSS_FLOW_SEG_HDR_L3 \@@ -27,7 +28,8 @@ enum iavf_adv_rss_flow_seg_hdr { IAVF_ADV_RSS_FLOW_SEG_HDR_IPV6)#define IAVF_ADV_RSS_FLOW_SEG_HDR_L4 \ - (IAVF_ADV_RSS_FLOW_SEG_HDR_TCP) + (IAVF_ADV_RSS_FLOW_SEG_HDR_TCP | \ + IAVF_ADV_RSS_FLOW_SEG_HDR_UDP)enum iavf_adv_rss_flow_field {/* L3 */ @@ -38,6 +40,8 @@ enum iavf_adv_rss_flow_field {/* L4 */ IAVF_ADV_RSS_FLOW_FIELD_IDX_TCP_SRC_PORT ,IAVF_ADV_RSS_FLOW_FIELD_IDX_TCP_DST_PORT , +IAVF_ADV_RSS_FLOW_FIELD_IDX_UDP_SRC_PORT , +IAVF_ADV_RSS_FLOW_FIELD_IDX_UDP_DST_PORT ,/* The total number of enums must not exceed 64 */ IAVF_ADV_RSS_FLOW_FIELD_IDX_MAX @@ -56,6 +60,10 @@ enum iavf_adv_rss_flow_field { BIT_ULL(IAVF_ADV_RSS_FLOW_FIELD_IDX_TCP_SRC_PORT)#define IAVF_ADV_RSS_HASH_FLD_TCP_DST_PORT \ BIT_ULL(IAVF_ADV_RSS_FLOW_FIELD_IDX_TCP_DST_PORT) +#define IAVF_ADV_RSS_HASH_FLD_UDP_SRC_PORT \ + BIT_ULL(IAVF_ADV_RSS_FLOW_FIELD_IDX_UDP_SRC_PORT) +#define IAVF_ADV_RSS_HASH_FLD_UDP_DST_PORT \ + BIT_ULL(IAVF_ADV_RSS_FLOW_FIELD_IDX_UDP_DST_PORT) /* bookkeeping of advanced RSS configuration */ struct iavf_adv_rss { diff --git
a/drivers/net/ethernet/intel/iavf/iavf_ethtool.cb/drivers/net/ethernet/intel/iavf/iavf_ethtool.cindexb5ec8e723b61..8a396cba944b100644drivers/net/ethernet/intel/iavf/iavf_ethtool.c +8
-0@@ -1434,10 +1434,18 @@ static u32 iavf_adv_rss_parse_hdrs(struct ethtool_rxnfc *cmd) hdrs |= IAVF_ADV_RSS_FLOW_SEG_HDR_TCP |IAVF_ADV_RSS_FLOW_SEG_HDR_IPV4 ;break ; +case UDP_V4_FLOW : + hdrs |=IAVF_ADV_RSS_FLOW_SEG_HDR_UDP | +IAVF_ADV_RSS_FLOW_SEG_HDR_IPV4 ; +break ;case TCP_V6_FLOW : hdrs |=IAVF_ADV_RSS_FLOW_SEG_HDR_TCP |IAVF_ADV_RSS_FLOW_SEG_HDR_IPV6 ;break ; +case UDP_V6_FLOW : + hdrs |=IAVF_ADV_RSS_FLOW_SEG_HDR_UDP | +IAVF_ADV_RSS_FLOW_SEG_HDR_IPV6 ; +break ;default :break ;drivers/net/ethernet/intel/iavf/iavf_ethtool.c +2
-0}@@ -1459,12 +1467,14 @@ static u64 iavf_adv_rss_parse_hash_flds(struct ethtool_rxnfc *cmd)if (cmd->data &RXH_IP_SRC || cmd->data &RXH_IP_DST ) {switch (cmd->flow_type) {case TCP_V4_FLOW : +case UDP_V4_FLOW :if (cmd->data &RXH_IP_SRC ) hfld |=IAVF_ADV_RSS_HASH_FLD_IPV4_SA ;if (cmd->data &RXH_IP_DST ) hfld |=IAVF_ADV_RSS_HASH_FLD_IPV4_DA ;break ;case TCP_V6_FLOW : +case UDP_V6_FLOW :if (cmd->data &RXH_IP_SRC ) hfld |=IAVF_ADV_RSS_HASH_FLD_IPV6_SA ;drivers/net/ethernet/intel/iavf/iavf_ethtool.c +6
-0if (cmd->data &RXH_IP_DST )@@ -1484,6 +1494,13 @@ static u64 iavf_adv_rss_parse_hash_flds(struct ethtool_rxnfc *cmd)if (cmd->data &RXH_L4_B_2_3 ) hfld |=IAVF_ADV_RSS_HASH_FLD_TCP_DST_PORT ;break ; +case UDP_V4_FLOW : +case UDP_V6_FLOW : +if (cmd->data &RXH_L4_B_0_1 ) + hfld |=IAVF_ADV_RSS_HASH_FLD_UDP_SRC_PORT ; +if (cmd->data &RXH_L4_B_2_3 ) + hfld |=
IAVF_ADV_RSS_HASH_FLD_UDP_DST_PORT;drivers/net/ethernet/intel/iavf/iavf_ethtool.c +5
-2+break ;default :break ; }@@ -1617,10 +1634,12 @@ iavf_get_adv_rss_hash_opt(struct iavf_adapter *adapter, IAVF_ADV_RSS_HASH_FLD_IPV6_DA)) cmd->data |= (u64 )RXH_IP_DST ; -if (hash_flds &IAVF_ADV_RSS_HASH_FLD_TCP_SRC_PORT ) +if (hash_flds & (IAVF_ADV_RSS_HASH_FLD_TCP_SRC_PORT | +IAVF_ADV_RSS_HASH_FLD_UDP_SRC_PORT )) cmd->data |= (u64 )RXH_L4_B_0_1 ; -if (hash_flds &IAVF_ADV_RSS_HASH_FLD_TCP_DST_PORT ) +if (hash_flds & (IAVF_ADV_RSS_HASH_FLD_TCP_DST_PORT | +IAVF_ADV_RSS_HASH_FLD_UDP_DST_PORT )) cmd->data |= (u64 )RXH_L4_B_2_3 ;
Quoted 1 line
return 0;
PATCH v3 6/6 iavf: Support for modifying SCTP RSS flow hashing
In reply to Haiyue WangProvide the ability to enable SCTP RSS hashing by ethtool.
It gives users option of generating RSS hash based on the SCTP source and destination ports numbers, IPv4 or IPv6 source and destination addresses.
--- .../net/ethernet/intel/iavf/iavf_adv_rss.c | 28 +++++++++++++++++-- .../net/ethernet/intel/iavf/iavf_adv_rss.h | 10 ++++++- .../net/ethernet/intel/iavf/iavf_ethtool.c | 23 +++++++++++++-- 3 files changed, 56 insertions(+), 5 deletions(-)
drivers/net/ethernet/intel/iavf/iavf_adv_rss.c +26 -2
@@ -73,6 +73,23 @@ iavf_fill_adv_rss_udp_hdr(struct virtchnl_proto_hdr *hdr, u64 hash_flds)VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT (hdr,UDP ,DST_PORT ); } +/** +* iavf_fill_adv_rss_sctp_hdr - fill the SCTP RSS protocol header +* @hdr: the virtchnl message protocol header data structure +* @hash_flds: the RSS configuration protocol hash fields +*/ +static void +iavf_fill_adv_rss_sctp_hdr (struct virtchnl_proto_hdr *hdr,u64 hash_flds) +{ +VIRTCHNL_SET_PROTO_HDR_TYPE (hdr,SCTP ); + +if (hash_flds &IAVF_ADV_RSS_HASH_FLD_SCTP_SRC_PORT ) +VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT (hdr,SCTP ,SRC_PORT ); + +if (hash_flds &IAVF_ADV_RSS_HASH_FLD_SCTP_DST_PORT ) +VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT (hdr,SCTP ,DST_PORT ); +} +/** * iavf_fill_adv_rss_cfg_msg - fill the RSS configuration into virtchnl message * @rss_cfg: the virtchnl message to be filled with RSS configuration setting
@@ -112,6 +129,9 @@ iavf_fill_adv_rss_cfg_msg(struct virtchnl_rss_cfg *rss_cfg,case IAVF_ADV_RSS_FLOW_SEG_HDR_UDP :iavf_fill_adv_rss_udp_hdr (hdr, hash_flds);break ; +case IAVF_ADV_RSS_FLOW_SEG_HDR_SCTP : +iavf_fill_adv_rss_sctp_hdr (hdr, hash_flds); +break ;default :return -EINVAL ; }
@@ -160,6 +180,8 @@ iavf_print_adv_rss_cfg(struct iavf_adapter *adapter, struct iavf_adv_rss *rss, proto ="TCP" ; else if (packet_hdrs & IAVF_ADV_RSS_FLOW_SEG_HDR_UDP) proto ="UDP" ; + else if (packet_hdrs & IAVF_ADV_RSS_FLOW_SEG_HDR_SCTP) + proto ="SCTP" ; else return;
@@ -178,10 +200,12 @@ iavf_print_adv_rss_cfg(struct iavf_adapter *adapter, struct iavf_adv_rss *rss, IAVF_ADV_RSS_HASH_FLD_IPV6_DA)) strcat(hash_opt, "IP DA,");if (hash_flds & (IAVF_ADV_RSS_HASH_FLD_TCP_SRC_PORT | -IAVF_ADV_RSS_HASH_FLD_UDP_SRC_PORT )) +IAVF_ADV_RSS_HASH_FLD_UDP_SRC_PORT | +IAVF_ADV_RSS_HASH_FLD_SCTP_SRC_PORT ))strcat (hash_opt,"src port," );if (hash_flds & (IAVF_ADV_RSS_HASH_FLD_TCP_DST_PORT | -IAVF_ADV_RSS_HASH_FLD_UDP_DST_PORT )) +IAVF_ADV_RSS_HASH_FLD_UDP_DST_PORT | +IAVF_ADV_RSS_HASH_FLD_SCTP_DST_PORT ))strcat (hash_opt,"dst port," );if (!action)
drivers/net/ethernet/intel/iavf/iavf_adv_rss.h +9 -1
@@ -21,6 +21,7 @@ enum iavf_adv_rss_flow_seg_hdr {IAVF_ADV_RSS_FLOW_SEG_HDR_IPV6 =0x00000002 ,IAVF_ADV_RSS_FLOW_SEG_HDR_TCP =0x00000004 ,IAVF_ADV_RSS_FLOW_SEG_HDR_UDP =0x00000008 , + IAVF_ADV_RSS_FLOW_SEG_HDR_SCTP = 0x00000010, };#define IAVF_ADV_RSS_FLOW_SEG_HDR_L3 \
@@ -29,7 +30,8 @@ enum iavf_adv_rss_flow_seg_hdr {#define IAVF_ADV_RSS_FLOW_SEG_HDR_L4 \ (IAVF_ADV_RSS_FLOW_SEG_HDR_TCP | \ - IAVF_ADV_RSS_FLOW_SEG_HDR_UDP) + IAVF_ADV_RSS_FLOW_SEG_HDR_UDP | \ + IAVF_ADV_RSS_FLOW_SEG_HDR_SCTP)enum iavf_adv_rss_flow_field {/* L3 */
@@ -42,6 +44,8 @@ enum iavf_adv_rss_flow_field {IAVF_ADV_RSS_FLOW_FIELD_IDX_TCP_DST_PORT ,IAVF_ADV_RSS_FLOW_FIELD_IDX_UDP_SRC_PORT ,IAVF_ADV_RSS_FLOW_FIELD_IDX_UDP_DST_PORT , +IAVF_ADV_RSS_FLOW_FIELD_IDX_SCTP_SRC_PORT , +IAVF_ADV_RSS_FLOW_FIELD_IDX_SCTP_DST_PORT ,/* The total number of enums must not exceed 64 */ IAVF_ADV_RSS_FLOW_FIELD_IDX_MAX
@@ -64,6 +68,10 @@ enum iavf_adv_rss_flow_field { BIT_ULL(IAVF_ADV_RSS_FLOW_FIELD_IDX_UDP_SRC_PORT)#define IAVF_ADV_RSS_HASH_FLD_UDP_DST_PORT \ BIT_ULL(IAVF_ADV_RSS_FLOW_FIELD_IDX_UDP_DST_PORT) +#define IAVF_ADV_RSS_HASH_FLD_SCTP_SRC_PORT \ + BIT_ULL(IAVF_ADV_RSS_FLOW_FIELD_IDX_SCTP_SRC_PORT) +#define IAVF_ADV_RSS_HASH_FLD_SCTP_DST_PORT \ + BIT_ULL(IAVF_ADV_RSS_FLOW_FIELD_IDX_SCTP_DST_PORT)/* bookkeeping of advanced RSS configuration */ struct iavf_adv_rss {
drivers/net/ethernet/intel/iavf/iavf_ethtool.c +21 -2
@@ -1438,6 +1438,10 @@ static u32 iavf_adv_rss_parse_hdrs(struct ethtool_rxnfc *cmd) hdrs |=IAVF_ADV_RSS_FLOW_SEG_HDR_UDP |IAVF_ADV_RSS_FLOW_SEG_HDR_IPV4 ;break ; +case SCTP_V4_FLOW : + hdrs |=IAVF_ADV_RSS_FLOW_SEG_HDR_SCTP | +IAVF_ADV_RSS_FLOW_SEG_HDR_IPV4 ; +break ;case TCP_V6_FLOW : hdrs |=IAVF_ADV_RSS_FLOW_SEG_HDR_TCP |IAVF_ADV_RSS_FLOW_SEG_HDR_IPV6 ;
@@ -1446,6 +1450,10 @@ static u32 iavf_adv_rss_parse_hdrs(struct ethtool_rxnfc *cmd) hdrs |=IAVF_ADV_RSS_FLOW_SEG_HDR_UDP |IAVF_ADV_RSS_FLOW_SEG_HDR_IPV6 ;break ; +case SCTP_V6_FLOW : + hdrs |=IAVF_ADV_RSS_FLOW_SEG_HDR_SCTP | +IAVF_ADV_RSS_FLOW_SEG_HDR_IPV6 ; +break ;default :break ; }
@@ -1468,6 +1476,7 @@ static u64 iavf_adv_rss_parse_hash_flds(struct ethtool_rxnfc *cmd)switch (cmd->flow_type) {case TCP_V4_FLOW :case UDP_V4_FLOW : +case SCTP_V4_FLOW :if (cmd->data &RXH_IP_SRC ) hfld |=IAVF_ADV_RSS_HASH_FLD_IPV4_SA ;if (cmd->data &RXH_IP_DST )
@@ -1475,6 +1484,7 @@ static u64 iavf_adv_rss_parse_hash_flds(struct ethtool_rxnfc *cmd)break ;case TCP_V6_FLOW :case UDP_V6_FLOW : +case SCTP_V6_FLOW :if (cmd->data &RXH_IP_SRC ) hfld |=IAVF_ADV_RSS_HASH_FLD_IPV6_SA ;if (cmd->data &RXH_IP_DST )
@@ -1501,6 +1511,13 @@ static u64 iavf_adv_rss_parse_hash_flds(struct ethtool_rxnfc *cmd)if (cmd->data &RXH_L4_B_2_3 ) hfld |=IAVF_ADV_RSS_HASH_FLD_UDP_DST_PORT ;break ; +case SCTP_V4_FLOW : +case SCTP_V6_FLOW : +if (cmd->data &RXH_L4_B_0_1 ) + hfld |=IAVF_ADV_RSS_HASH_FLD_SCTP_SRC_PORT ; +if (cmd->data &RXH_L4_B_2_3 ) + hfld |=IAVF_ADV_RSS_HASH_FLD_SCTP_DST_PORT ; +break ;default :break ; }
@@ -1635,11 +1652,13 @@ iavf_get_adv_rss_hash_opt(struct iavf_adapter *adapter, cmd->data |= (u64 )RXH_IP_DST ;if (hash_flds & (IAVF_ADV_RSS_HASH_FLD_TCP_SRC_PORT | -IAVF_ADV_RSS_HASH_FLD_UDP_SRC_PORT )) +IAVF_ADV_RSS_HASH_FLD_UDP_SRC_PORT | +IAVF_ADV_RSS_HASH_FLD_SCTP_SRC_PORT )) cmd->data |= (u64 )RXH_L4_B_0_1 ;if (hash_flds & (IAVF_ADV_RSS_HASH_FLD_TCP_DST_PORT | -IAVF_ADV_RSS_HASH_FLD_UDP_DST_PORT )) +IAVF_ADV_RSS_HASH_FLD_UDP_DST_PORT | +IAVF_ADV_RSS_HASH_FLD_SCTP_DST_PORT )) cmd->data |= (u64 )RXH_L4_B_2_3 ;return 0 ;
Signature · 1 line
2.31.1
Jankowski
PATCH v3 6/6 iavf: Support for modifying SCTP RSS flow hashing
Quoted 212 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Haiyue Wang
Sent: wtorek, 13 kwietnia 2021 02:49
To: intel-wired-lan at lists.osuosl.org
Cc: Zhang, Qi Z <[email protected]>
Subject: [Intel-wired-lan] [PATCH net-next v3 6/6] iavf: Support for modifying SCTP RSS flow hashingProvide the ability to enable SCTP RSS hashing by ethtool.
It gives users option of generating RSS hash based on the SCTP source and destination ports numbers, IPv4 or IPv6 source and destination addresses.
Signed-off-by Haiyue Wang <[email protected]>--- .../net/ethernet/intel/iavf/iavf_adv_rss.c | 28 +++++++++++++++++-- .../net/ethernet/intel/iavf/iavf_adv_rss.h | 10 ++++++- .../net/ethernet/intel/iavf/iavf_ethtool.c | 23 +++++++++++++-- 3 files changed, 56 insertions(+), 5 deletions(-)drivers/net/ethernet/intel/iavf/iavf_adv_rss.c +17
-0@@ -73,6 +73,23 @@ iavf_fill_adv_rss_udp_hdr(struct virtchnl_proto_hdr *hdr, u64 hash_flds)VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT (hdr,UDP ,DST_PORT ); } +/** +* iavf_fill_adv_rss_sctp_hdr - fill the SCTP RSS protocol header +* @hdr: the virtchnl message protocol header data structure +* @hash_flds: the RSS configuration protocol hash fields */ static +void iavf_fill_adv_rss_sctp_hdr (struct virtchnl_proto_hdr *hdr,u64 +hash_flds) { +VIRTCHNL_SET_PROTO_HDR_TYPE (hdr,SCTP ); + +if (hash_flds &IAVF_ADV_RSS_HASH_FLD_SCTP_SRC_PORT ) +VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT (hdr,SCTP ,SRC_PORT ); + +if (hash_flds &IAVF_ADV_RSS_HASH_FLD_SCTP_DST_PORT ) +VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT (hdr,SCTP ,DST_PORT ); } +/** * iavf_fill_adv_rss_cfg_msg - fill the RSS configuration into virtchnl message * @rss_cfg: the virtchnl message to be filled with RSS configuration setting @@ -112,6 +129,9 @@ iavf_fill_adv_rss_cfg_msg(struct virtchnl_rss_cfg *rss_cfg, case IAVF_ADV_RSS_FLOW_SEG_HDR_UDP:iavf_fill_adv_rss_udp_hdr (hdr, hash_flds);break ; +case IAVF_ADV_RSS_FLOW_SEG_HDR_SCTP : +iavf_fill_adv_rss_sctp_hdr (hdr, hash_flds); +break ;default :return -EINVAL ;drivers/net/ethernet/intel/iavf/iavf_adv_rss.c +6
-2}@@ -160,6 +180,8 @@ iavf_print_adv_rss_cfg(struct iavf_adapter *adapter,struct iavf_adv_rss *rss, proto ="TCP" ; else if (packet_hdrs & IAVF_ADV_RSS_FLOW_SEG_HDR_UDP) proto ="UDP" ; + else if (packet_hdrs & IAVF_ADV_RSS_FLOW_SEG_HDR_SCTP) + proto ="SCTP" ; else return;@@ -178,10 +200,12 @@ iavf_print_adv_rss_cfg(struct iavf_adapter *adapter, struct iavf_adv_rss *rss, IAVF_ADV_RSS_HASH_FLD_IPV6_DA))strcat (hash_opt,"IP DA," );if (hash_flds & (IAVF_ADV_RSS_HASH_FLD_TCP_SRC_PORT | -IAVF_ADV_RSS_HASH_FLD_UDP_SRC_PORT )) +IAVF_ADV_RSS_HASH_FLD_UDP_SRC_PORT | +IAVF_ADV_RSS_HASH_FLD_SCTP_SRC_PORT ))strcat (hash_opt,"src port," );if (hash_flds & (IAVF_ADV_RSS_HASH_FLD_TCP_DST_PORT | -IAVF_ADV_RSS_HASH_FLD_UDP_DST_PORT )) +IAVF_ADV_RSS_HASH_FLD_UDP_DST_PORT | +IAVF_ADV_RSS_HASH_FLD_SCTP_DST_PORT ))strcat (hash_opt,"dst port," );drivers/net/ethernet/intel/iavf/iavf_adv_rss.c +0
-0if (!action)drivers/net/ethernet/intel/iavf/iavf_adv_rss.h +9
-1@@ -21,6 +21,7 @@ enum iavf_adv_rss_flow_seg_hdr {IAVF_ADV_RSS_FLOW_SEG_HDR_IPV6 =0x00000002 ,IAVF_ADV_RSS_FLOW_SEG_HDR_TCP =0x00000004 ,IAVF_ADV_RSS_FLOW_SEG_HDR_UDP =0x00000008 , + IAVF_ADV_RSS_FLOW_SEG_HDR_SCTP = 0x00000010, };#define IAVF_ADV_RSS_FLOW_SEG_HDR_L3 \@@ -29,7 +30,8 @@ enum iavf_adv_rss_flow_seg_hdr {#define IAVF_ADV_RSS_FLOW_SEG_HDR_L4 \ (IAVF_ADV_RSS_FLOW_SEG_HDR_TCP | \ - IAVF_ADV_RSS_FLOW_SEG_HDR_UDP) + IAVF_ADV_RSS_FLOW_SEG_HDR_UDP | \ + IAVF_ADV_RSS_FLOW_SEG_HDR_SCTP)enum iavf_adv_rss_flow_field {/* L3 */ @@ -42,6 +44,8 @@ enum iavf_adv_rss_flow_field {IAVF_ADV_RSS_FLOW_FIELD_IDX_TCP_DST_PORT ,IAVF_ADV_RSS_FLOW_FIELD_IDX_UDP_SRC_PORT ,IAVF_ADV_RSS_FLOW_FIELD_IDX_UDP_DST_PORT , +IAVF_ADV_RSS_FLOW_FIELD_IDX_SCTP_SRC_PORT , +IAVF_ADV_RSS_FLOW_FIELD_IDX_SCTP_DST_PORT ,/* The total number of enums must not exceed 64 */ IAVF_ADV_RSS_FLOW_FIELD_IDX_MAX @@ -64,6 +68,10 @@ enum iavf_adv_rss_flow_field { BIT_ULL(IAVF_ADV_RSS_FLOW_FIELD_IDX_UDP_SRC_PORT)#define IAVF_ADV_RSS_HASH_FLD_UDP_DST_PORT \ BIT_ULL(IAVF_ADV_RSS_FLOW_FIELD_IDX_UDP_DST_PORT) +#define IAVF_ADV_RSS_HASH_FLD_SCTP_SRC_PORT \ + BIT_ULL(IAVF_ADV_RSS_FLOW_FIELD_IDX_SCTP_SRC_PORT) +#define IAVF_ADV_RSS_HASH_FLD_SCTP_DST_PORT \ + BIT_ULL(IAVF_ADV_RSS_FLOW_FIELD_IDX_SCTP_DST_PORT) /* bookkeeping of advanced RSS configuration */ struct iavf_adv_rss { diff --git
a/drivers/net/ethernet/intel/iavf/iavf_ethtool.cb/drivers/net/ethernet/intel/iavf/iavf_ethtool.cindex8a396cba944b..0d22a5275218100644drivers/net/ethernet/intel/iavf/iavf_ethtool.c +4
-0@@ -1438,6 +1438,10 @@ static u32 iavf_adv_rss_parse_hdrs(struct ethtool_rxnfc *cmd) hdrs |= IAVF_ADV_RSS_FLOW_SEG_HDR_UDP |IAVF_ADV_RSS_FLOW_SEG_HDR_IPV4 ;break ; +case SCTP_V4_FLOW : + hdrs |=IAVF_ADV_RSS_FLOW_SEG_HDR_SCTP | +IAVF_ADV_RSS_FLOW_SEG_HDR_IPV4 ; +break ;case TCP_V6_FLOW : hdrs |= IAVF_ADV_RSS_FLOW_SEG_HDR_TCP |drivers/net/ethernet/intel/iavf/iavf_ethtool.c +4
-0IAVF_ADV_RSS_FLOW_SEG_HDR_IPV6 ;@@ -1446,6 +1450,10 @@ static u32 iavf_adv_rss_parse_hdrs(struct ethtool_rxnfc *cmd) hdrs |= IAVF_ADV_RSS_FLOW_SEG_HDR_UDP |IAVF_ADV_RSS_FLOW_SEG_HDR_IPV6 ;break ; +case SCTP_V6_FLOW : + hdrs |=IAVF_ADV_RSS_FLOW_SEG_HDR_SCTP | +IAVF_ADV_RSS_FLOW_SEG_HDR_IPV6 ; +break ;default :break ;drivers/net/ethernet/intel/iavf/iavf_ethtool.c +1
-0}@@ -1468,6 +1476,7 @@ static u64 iavf_adv_rss_parse_hash_flds(struct ethtool_rxnfc *cmd)switch (cmd->flow_type) {case TCP_V4_FLOW :case UDP_V4_FLOW : +case SCTP_V4_FLOW :if (cmd->data &RXH_IP_SRC ) hfld |=IAVF_ADV_RSS_HASH_FLD_IPV4_SA ;drivers/net/ethernet/intel/iavf/iavf_ethtool.c +1
-0if (cmd->data &RXH_IP_DST )@@ -1475,6 +1484,7 @@ static u64 iavf_adv_rss_parse_hash_flds(struct ethtool_rxnfc *cmd) break;case TCP_V6_FLOW :case UDP_V6_FLOW : +case SCTP_V6_FLOW :if (cmd->data &RXH_IP_SRC ) hfld |=IAVF_ADV_RSS_HASH_FLD_IPV6_SA ;drivers/net/ethernet/intel/iavf/iavf_ethtool.c +6
-0if (cmd->data &RXH_IP_DST )@@ -1501,6 +1511,13 @@ static u64 iavf_adv_rss_parse_hash_flds(struct ethtool_rxnfc *cmd)if (cmd->data &RXH_L4_B_2_3 ) hfld |=IAVF_ADV_RSS_HASH_FLD_UDP_DST_PORT ;break ; +case SCTP_V4_FLOW : +case SCTP_V6_FLOW : +if (cmd->data &RXH_L4_B_0_1 ) + hfld |=IAVF_ADV_RSS_HASH_FLD_SCTP_SRC_PORT ; +if (cmd->data &RXH_L4_B_2_3 ) + hfld |=
IAVF_ADV_RSS_HASH_FLD_SCTP_DST_PORT;drivers/net/ethernet/intel/iavf/iavf_ethtool.c +5
-2+break ;default :break ; }@@ -1635,11 +1652,13 @@ iavf_get_adv_rss_hash_opt(struct iavf_adapter *adapter, cmd->data |= (u64 )RXH_IP_DST ;if (hash_flds & (IAVF_ADV_RSS_HASH_FLD_TCP_SRC_PORT | -IAVF_ADV_RSS_HASH_FLD_UDP_SRC_PORT )) +IAVF_ADV_RSS_HASH_FLD_UDP_SRC_PORT | +IAVF_ADV_RSS_HASH_FLD_SCTP_SRC_PORT )) cmd->data |= (u64 )RXH_L4_B_0_1 ;if (hash_flds & (IAVF_ADV_RSS_HASH_FLD_TCP_DST_PORT | -IAVF_ADV_RSS_HASH_FLD_UDP_DST_PORT )) +IAVF_ADV_RSS_HASH_FLD_UDP_DST_PORT | +IAVF_ADV_RSS_HASH_FLD_SCTP_DST_PORT )) cmd->data |= (u64 )RXH_L4_B_2_3 ;
Quoted 1 line
return 0;