All of lore.kernel.org
 help / color / mirror / Atom feed
* [Intel-wired-lan] [PATCH net-next v3 0/6] Enable Intel VF RSS
@ 2021-04-13  0:48 Haiyue Wang
  2021-04-13  0:48 ` [Intel-wired-lan] [PATCH net-next v3 1/6] ice: Enable RSS configure for AVF Haiyue Wang
                   ` (5 more replies)
  0 siblings, 6 replies; 13+ messages in thread
From: Haiyue Wang @ 2021-04-13  0:48 UTC (permalink / raw)
  To: intel-wired-lan

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

-- 
2.31.1


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Intel-wired-lan] [PATCH net-next v3 1/6] ice: Enable RSS configure for AVF
  2021-04-13  0:48 [Intel-wired-lan] [PATCH net-next v3 0/6] Enable Intel VF RSS Haiyue Wang
@ 2021-04-13  0:48 ` Haiyue Wang
  2021-04-14  1:47   ` Chen, BoX C
  2021-04-13  0:48 ` [Intel-wired-lan] [PATCH net-next v3 2/6] ice: Support RSS configure removal " Haiyue Wang
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 13+ messages in thread
From: Haiyue Wang @ 2021-04-13  0:48 UTC (permalink / raw)
  To: intel-wired-lan

From: Qi Zhang <qi.z.zhang@intel.com>

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.

Signed-off-by: Jia Guo <jia.guo@intel.com>
Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
Signed-off-by: Haiyue Wang <haiyue.wang@intel.com>
---
 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(-)

diff --git a/drivers/net/ethernet/intel/ice/ice_flow.h b/drivers/net/ethernet/intel/ice/ice_flow.h
index eec9def8ffca..2f68b59ace7e 100644
--- a/drivers/net/ethernet/intel/ice/ice_flow.h
+++ b/drivers/net/ethernet/intel/ice/ice_flow.h
@@ -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))
diff --git a/drivers/net/ethernet/intel/ice/ice_virtchnl_allowlist.c b/drivers/net/ethernet/intel/ice/ice_virtchnl_allowlist.c
index 58d395db4219..35811862336e 100644
--- a/drivers/net/ethernet/intel/ice/ice_virtchnl_allowlist.c
+++ b/drivers/net/ethernet/intel/ice/ice_virtchnl_allowlist.c
@@ -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),
 };
 
diff --git a/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c b/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c
index 96a2b319bf21..f104326037fb 100644
--- a/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c
+++ b/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c
@@ -5,8 +5,248 @@
 #include "ice_base.h"
 #include "ice_lib.h"
 #include "ice_fltr.h"
+#include "ice_flow.h"
 #include "ice_virtchnl_allowlist.h"
 
+#define FIELD_SELECTOR(proto_hdr_field) \
+		BIT((proto_hdr_field) & PROTO_HDR_FIELD_MASK)
+
+struct ice_vc_hdr_match_type {
+	u32 vc_hdr;	/* virtchnl headers (VIRTCHNL_PROTO_HDR_XXX) */
+	u32 ice_hdr;	/* ice headers (ICE_FLOW_SEG_HDR_XXX) */
+};
+
+static const struct ice_vc_hdr_match_type ice_vc_hdr_list_os[] = {
+	{VIRTCHNL_PROTO_HDR_NONE,	ICE_FLOW_SEG_HDR_NONE},
+	{VIRTCHNL_PROTO_HDR_IPV4,	ICE_FLOW_SEG_HDR_IPV4 |
+					ICE_FLOW_SEG_HDR_IPV_OTHER},
+	{VIRTCHNL_PROTO_HDR_IPV6,	ICE_FLOW_SEG_HDR_IPV6 |
+					ICE_FLOW_SEG_HDR_IPV_OTHER},
+	{VIRTCHNL_PROTO_HDR_TCP,	ICE_FLOW_SEG_HDR_TCP},
+	{VIRTCHNL_PROTO_HDR_UDP,	ICE_FLOW_SEG_HDR_UDP},
+	{VIRTCHNL_PROTO_HDR_SCTP,	ICE_FLOW_SEG_HDR_SCTP},
+};
+
+static const struct ice_vc_hdr_match_type ice_vc_hdr_list_comms[] = {
+	{VIRTCHNL_PROTO_HDR_NONE,	ICE_FLOW_SEG_HDR_NONE},
+	{VIRTCHNL_PROTO_HDR_ETH,	ICE_FLOW_SEG_HDR_ETH},
+	{VIRTCHNL_PROTO_HDR_S_VLAN,	ICE_FLOW_SEG_HDR_VLAN},
+	{VIRTCHNL_PROTO_HDR_C_VLAN,	ICE_FLOW_SEG_HDR_VLAN},
+	{VIRTCHNL_PROTO_HDR_IPV4,	ICE_FLOW_SEG_HDR_IPV4 |
+					ICE_FLOW_SEG_HDR_IPV_OTHER},
+	{VIRTCHNL_PROTO_HDR_IPV6,	ICE_FLOW_SEG_HDR_IPV6 |
+					ICE_FLOW_SEG_HDR_IPV_OTHER},
+	{VIRTCHNL_PROTO_HDR_TCP,	ICE_FLOW_SEG_HDR_TCP},
+	{VIRTCHNL_PROTO_HDR_UDP,	ICE_FLOW_SEG_HDR_UDP},
+	{VIRTCHNL_PROTO_HDR_SCTP,	ICE_FLOW_SEG_HDR_SCTP},
+	{VIRTCHNL_PROTO_HDR_PPPOE,	ICE_FLOW_SEG_HDR_PPPOE},
+	{VIRTCHNL_PROTO_HDR_GTPU_IP,	ICE_FLOW_SEG_HDR_GTPU_IP},
+	{VIRTCHNL_PROTO_HDR_GTPU_EH,	ICE_FLOW_SEG_HDR_GTPU_EH},
+	{VIRTCHNL_PROTO_HDR_GTPU_EH_PDU_DWN,
+					ICE_FLOW_SEG_HDR_GTPU_DWN},
+	{VIRTCHNL_PROTO_HDR_GTPU_EH_PDU_UP,
+					ICE_FLOW_SEG_HDR_GTPU_UP},
+	{VIRTCHNL_PROTO_HDR_L2TPV3,	ICE_FLOW_SEG_HDR_L2TPV3},
+	{VIRTCHNL_PROTO_HDR_ESP,	ICE_FLOW_SEG_HDR_ESP},
+	{VIRTCHNL_PROTO_HDR_AH,		ICE_FLOW_SEG_HDR_AH},
+	{VIRTCHNL_PROTO_HDR_PFCP,	ICE_FLOW_SEG_HDR_PFCP_SESSION},
+};
+
+struct ice_vc_hash_field_match_type {
+	u32 vc_hdr;		/* virtchnl headers
+				 * (VIRTCHNL_PROTO_HDR_XXX)
+				 */
+	u32 vc_hash_field;	/* virtchnl hash fields selector
+				 * FIELD_SELECTOR((VIRTCHNL_PROTO_HDR_ETH_XXX))
+				 */
+	u64 ice_hash_field;	/* ice hash fields
+				 * (BIT_ULL(ICE_FLOW_FIELD_IDX_XXX))
+				 */
+};
+
+static const struct
+ice_vc_hash_field_match_type ice_vc_hash_field_list_os[] = {
+	{VIRTCHNL_PROTO_HDR_IPV4, FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_IPV4_SRC),
+		BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_SA)},
+	{VIRTCHNL_PROTO_HDR_IPV4, FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_IPV4_DST),
+		BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_DA)},
+	{VIRTCHNL_PROTO_HDR_IPV4, FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_IPV4_SRC) |
+		FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_IPV4_DST),
+		ICE_FLOW_HASH_IPV4},
+	{VIRTCHNL_PROTO_HDR_IPV4, FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_IPV4_SRC) |
+		FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_IPV4_PROT),
+		BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_SA) |
+		BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_PROT)},
+	{VIRTCHNL_PROTO_HDR_IPV4, FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_IPV4_DST) |
+		FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_IPV4_PROT),
+		BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_DA) |
+		BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_PROT)},
+	{VIRTCHNL_PROTO_HDR_IPV4, FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_IPV4_SRC) |
+		FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_IPV4_DST) |
+		FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_IPV4_PROT),
+		ICE_FLOW_HASH_IPV4 | BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_PROT)},
+	{VIRTCHNL_PROTO_HDR_IPV4, FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_IPV4_PROT),
+		BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_PROT)},
+	{VIRTCHNL_PROTO_HDR_IPV6, FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_IPV6_SRC),
+		BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_SA)},
+	{VIRTCHNL_PROTO_HDR_IPV6, FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_IPV6_DST),
+		BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_DA)},
+	{VIRTCHNL_PROTO_HDR_IPV6, FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_IPV6_SRC) |
+		FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_IPV6_DST),
+		ICE_FLOW_HASH_IPV6},
+	{VIRTCHNL_PROTO_HDR_IPV6, FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_IPV6_SRC) |
+		FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_IPV6_PROT),
+		BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_SA) |
+		BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_PROT)},
+	{VIRTCHNL_PROTO_HDR_IPV6, FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_IPV6_DST) |
+		FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_IPV6_PROT),
+		BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_DA) |
+		BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_PROT)},
+	{VIRTCHNL_PROTO_HDR_IPV6, FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_IPV6_SRC) |
+		FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_IPV6_DST) |
+		FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_IPV6_PROT),
+		ICE_FLOW_HASH_IPV6 | BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_PROT)},
+	{VIRTCHNL_PROTO_HDR_IPV6, FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_IPV6_PROT),
+		BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_PROT)},
+	{VIRTCHNL_PROTO_HDR_TCP,
+		FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_TCP_SRC_PORT),
+		BIT_ULL(ICE_FLOW_FIELD_IDX_TCP_SRC_PORT)},
+	{VIRTCHNL_PROTO_HDR_TCP,
+		FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_TCP_DST_PORT),
+		BIT_ULL(ICE_FLOW_FIELD_IDX_TCP_DST_PORT)},
+	{VIRTCHNL_PROTO_HDR_TCP,
+		FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_TCP_SRC_PORT) |
+		FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_TCP_DST_PORT),
+		ICE_FLOW_HASH_TCP_PORT},
+	{VIRTCHNL_PROTO_HDR_UDP,
+		FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_UDP_SRC_PORT),
+		BIT_ULL(ICE_FLOW_FIELD_IDX_UDP_SRC_PORT)},
+	{VIRTCHNL_PROTO_HDR_UDP,
+		FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_UDP_DST_PORT),
+		BIT_ULL(ICE_FLOW_FIELD_IDX_UDP_DST_PORT)},
+	{VIRTCHNL_PROTO_HDR_UDP,
+		FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_UDP_SRC_PORT) |
+		FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_UDP_DST_PORT),
+		ICE_FLOW_HASH_UDP_PORT},
+	{VIRTCHNL_PROTO_HDR_SCTP,
+		FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_SCTP_SRC_PORT),
+		BIT_ULL(ICE_FLOW_FIELD_IDX_SCTP_SRC_PORT)},
+	{VIRTCHNL_PROTO_HDR_SCTP,
+		FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_SCTP_DST_PORT),
+		BIT_ULL(ICE_FLOW_FIELD_IDX_SCTP_DST_PORT)},
+	{VIRTCHNL_PROTO_HDR_SCTP,
+		FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_SCTP_SRC_PORT) |
+		FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_SCTP_DST_PORT),
+		ICE_FLOW_HASH_SCTP_PORT},
+};
+
+static const struct
+ice_vc_hash_field_match_type ice_vc_hash_field_list_comms[] = {
+	{VIRTCHNL_PROTO_HDR_ETH, FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_ETH_SRC),
+		BIT_ULL(ICE_FLOW_FIELD_IDX_ETH_SA)},
+	{VIRTCHNL_PROTO_HDR_ETH, FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_ETH_DST),
+		BIT_ULL(ICE_FLOW_FIELD_IDX_ETH_DA)},
+	{VIRTCHNL_PROTO_HDR_ETH, FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_ETH_SRC) |
+		FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_ETH_DST),
+		ICE_FLOW_HASH_ETH},
+	{VIRTCHNL_PROTO_HDR_ETH,
+		FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_ETH_ETHERTYPE),
+		BIT_ULL(ICE_FLOW_FIELD_IDX_ETH_TYPE)},
+	{VIRTCHNL_PROTO_HDR_S_VLAN,
+		FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_S_VLAN_ID),
+		BIT_ULL(ICE_FLOW_FIELD_IDX_S_VLAN)},
+	{VIRTCHNL_PROTO_HDR_C_VLAN,
+		FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_C_VLAN_ID),
+		BIT_ULL(ICE_FLOW_FIELD_IDX_C_VLAN)},
+	{VIRTCHNL_PROTO_HDR_IPV4, FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_IPV4_SRC),
+		BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_SA)},
+	{VIRTCHNL_PROTO_HDR_IPV4, FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_IPV4_DST),
+		BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_DA)},
+	{VIRTCHNL_PROTO_HDR_IPV4, FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_IPV4_SRC) |
+		FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_IPV4_DST),
+		ICE_FLOW_HASH_IPV4},
+	{VIRTCHNL_PROTO_HDR_IPV4, FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_IPV4_SRC) |
+		FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_IPV4_PROT),
+		BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_SA) |
+		BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_PROT)},
+	{VIRTCHNL_PROTO_HDR_IPV4, FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_IPV4_DST) |
+		FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_IPV4_PROT),
+		BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_DA) |
+		BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_PROT)},
+	{VIRTCHNL_PROTO_HDR_IPV4, FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_IPV4_SRC) |
+		FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_IPV4_DST) |
+		FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_IPV4_PROT),
+		ICE_FLOW_HASH_IPV4 | BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_PROT)},
+	{VIRTCHNL_PROTO_HDR_IPV4, FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_IPV4_PROT),
+		BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_PROT)},
+	{VIRTCHNL_PROTO_HDR_IPV6, FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_IPV6_SRC),
+		BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_SA)},
+	{VIRTCHNL_PROTO_HDR_IPV6, FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_IPV6_DST),
+		BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_DA)},
+	{VIRTCHNL_PROTO_HDR_IPV6, FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_IPV6_SRC) |
+		FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_IPV6_DST),
+		ICE_FLOW_HASH_IPV6},
+	{VIRTCHNL_PROTO_HDR_IPV6, FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_IPV6_SRC) |
+		FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_IPV6_PROT),
+		BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_SA) |
+		BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_PROT)},
+	{VIRTCHNL_PROTO_HDR_IPV6, FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_IPV6_DST) |
+		FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_IPV6_PROT),
+		BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_DA) |
+		BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_PROT)},
+	{VIRTCHNL_PROTO_HDR_IPV6, FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_IPV6_SRC) |
+		FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_IPV6_DST) |
+		FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_IPV6_PROT),
+		ICE_FLOW_HASH_IPV6 | BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_PROT)},
+	{VIRTCHNL_PROTO_HDR_IPV6, FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_IPV6_PROT),
+		BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_PROT)},
+	{VIRTCHNL_PROTO_HDR_TCP,
+		FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_TCP_SRC_PORT),
+		BIT_ULL(ICE_FLOW_FIELD_IDX_TCP_SRC_PORT)},
+	{VIRTCHNL_PROTO_HDR_TCP,
+		FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_TCP_DST_PORT),
+		BIT_ULL(ICE_FLOW_FIELD_IDX_TCP_DST_PORT)},
+	{VIRTCHNL_PROTO_HDR_TCP,
+		FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_TCP_SRC_PORT) |
+		FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_TCP_DST_PORT),
+		ICE_FLOW_HASH_TCP_PORT},
+	{VIRTCHNL_PROTO_HDR_UDP,
+		FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_UDP_SRC_PORT),
+		BIT_ULL(ICE_FLOW_FIELD_IDX_UDP_SRC_PORT)},
+	{VIRTCHNL_PROTO_HDR_UDP,
+		FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_UDP_DST_PORT),
+		BIT_ULL(ICE_FLOW_FIELD_IDX_UDP_DST_PORT)},
+	{VIRTCHNL_PROTO_HDR_UDP,
+		FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_UDP_SRC_PORT) |
+		FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_UDP_DST_PORT),
+		ICE_FLOW_HASH_UDP_PORT},
+	{VIRTCHNL_PROTO_HDR_SCTP,
+		FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_SCTP_SRC_PORT),
+		BIT_ULL(ICE_FLOW_FIELD_IDX_SCTP_SRC_PORT)},
+	{VIRTCHNL_PROTO_HDR_SCTP,
+		FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_SCTP_DST_PORT),
+		BIT_ULL(ICE_FLOW_FIELD_IDX_SCTP_DST_PORT)},
+	{VIRTCHNL_PROTO_HDR_SCTP,
+		FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_SCTP_SRC_PORT) |
+		FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_SCTP_DST_PORT),
+		ICE_FLOW_HASH_SCTP_PORT},
+	{VIRTCHNL_PROTO_HDR_PPPOE,
+		FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_PPPOE_SESS_ID),
+		BIT_ULL(ICE_FLOW_FIELD_IDX_PPPOE_SESS_ID)},
+	{VIRTCHNL_PROTO_HDR_GTPU_IP,
+		FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_GTPU_IP_TEID),
+		BIT_ULL(ICE_FLOW_FIELD_IDX_GTPU_IP_TEID)},
+	{VIRTCHNL_PROTO_HDR_L2TPV3,
+		FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_L2TPV3_SESS_ID),
+		BIT_ULL(ICE_FLOW_FIELD_IDX_L2TPV3_SESS_ID)},
+	{VIRTCHNL_PROTO_HDR_ESP, FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_ESP_SPI),
+		BIT_ULL(ICE_FLOW_FIELD_IDX_ESP_SPI)},
+	{VIRTCHNL_PROTO_HDR_AH, FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_AH_SPI),
+		BIT_ULL(ICE_FLOW_FIELD_IDX_AH_SPI)},
+	{VIRTCHNL_PROTO_HDR_PFCP, FIELD_SELECTOR(VIRTCHNL_PROTO_HDR_PFCP_SEID),
+		BIT_ULL(ICE_FLOW_FIELD_IDX_PFCP_SEID)},
+};
+
 /**
  * ice_get_vf_vsi - get VF's VSI based on the stored index
  * @vf: VF used to get VSI
@@ -2100,6 +2340,9 @@ static int ice_vc_get_vf_res_msg(struct ice_vf *vf, u8 *msg)
 	if (vf->driver_caps & VIRTCHNL_VF_CAP_ADV_LINK_SPEED)
 		vfres->vf_cap_flags |= VIRTCHNL_VF_CAP_ADV_LINK_SPEED;
 
+	if (vf->driver_caps & VIRTCHNL_VF_OFFLOAD_ADV_RSS_PF)
+		vfres->vf_cap_flags |= VIRTCHNL_VF_OFFLOAD_ADV_RSS_PF;
+
 	if (vf->driver_caps & VIRTCHNL_VF_OFFLOAD_USO)
 		vfres->vf_cap_flags |= VIRTCHNL_VF_OFFLOAD_USO;
 
@@ -2213,6 +2456,210 @@ static bool ice_vc_isvalid_ring_len(u16 ring_len)
 		!(ring_len % ICE_REQ_DESC_MULTIPLE));
 }
 
+/**
+ * ice_vc_parse_rss_cfg - parses hash fields and headers from
+ * a specific virtchnl RSS cfg
+ * @hw: pointer to the hardware
+ * @rss_cfg: pointer to the virtchnl RSS cfg
+ * @addl_hdrs: pointer to the protocol header fields (ICE_FLOW_SEG_HDR_*)
+ * to configure
+ * @hash_flds: pointer to the hash bit fields (ICE_FLOW_HASH_*) to configure
+ *
+ * Return true if all the protocol header and hash fields in the RSS cfg could
+ * be parsed, else return false
+ *
+ * This function parses the virtchnl RSS cfg to be the intended
+ * hash fields and the intended header for RSS configuration
+ */
+static bool
+ice_vc_parse_rss_cfg(struct ice_hw *hw, struct virtchnl_rss_cfg *rss_cfg,
+		     u32 *addl_hdrs, u64 *hash_flds)
+{
+	const struct ice_vc_hash_field_match_type *hf_list;
+	const struct ice_vc_hdr_match_type *hdr_list;
+	int i, hf_list_len, hdr_list_len;
+
+	if (!strncmp(hw->active_pkg_name, "ICE COMMS Package",
+		     sizeof(hw->active_pkg_name))) {
+		hf_list = ice_vc_hash_field_list_comms;
+		hf_list_len = ARRAY_SIZE(ice_vc_hash_field_list_comms);
+		hdr_list = ice_vc_hdr_list_comms;
+		hdr_list_len = ARRAY_SIZE(ice_vc_hdr_list_comms);
+	} else {
+		hf_list = ice_vc_hash_field_list_os;
+		hf_list_len = ARRAY_SIZE(ice_vc_hash_field_list_os);
+		hdr_list = ice_vc_hdr_list_os;
+		hdr_list_len = ARRAY_SIZE(ice_vc_hdr_list_os);
+	}
+
+	for (i = 0; i < rss_cfg->proto_hdrs.count; i++) {
+		struct virtchnl_proto_hdr *proto_hdr =
+					&rss_cfg->proto_hdrs.proto_hdr[i];
+		bool hdr_found = false;
+		int j;
+
+		/* Find matched ice headers according to virtchnl headers. */
+		for (j = 0; j < hdr_list_len; j++) {
+			struct ice_vc_hdr_match_type hdr_map = hdr_list[j];
+
+			if (proto_hdr->type == hdr_map.vc_hdr) {
+				*addl_hdrs |= hdr_map.ice_hdr;
+				hdr_found = true;
+			}
+		}
+
+		if (!hdr_found)
+			return false;
+
+		/* Find matched ice hash fields according to
+		 * virtchnl hash fields.
+		 */
+		for (j = 0; j < hf_list_len; j++) {
+			struct ice_vc_hash_field_match_type hf_map = hf_list[j];
+
+			if (proto_hdr->type == hf_map.vc_hdr &&
+			    proto_hdr->field_selector == hf_map.vc_hash_field) {
+				*hash_flds |= hf_map.ice_hash_field;
+				break;
+			}
+		}
+	}
+
+	return true;
+}
+
+/**
+ * ice_vf_adv_rss_offload_ena - determine if capabilities support advanced
+ * RSS offloads
+ * @caps: VF driver negotiated capabilities
+ *
+ * Return true if VIRTCHNL_VF_OFFLOAD_ADV_RSS_PF capability is set,
+ * else return false
+ */
+static bool ice_vf_adv_rss_offload_ena(u32 caps)
+{
+	return !!(caps & VIRTCHNL_VF_OFFLOAD_ADV_RSS_PF);
+}
+
+/**
+ * ice_vc_handle_rss_cfg
+ * @vf: pointer to the VF info
+ * @msg: pointer to the message buffer
+ * @add: add a RSS config if true, otherwise delete a RSS config
+ *
+ * This function adds/deletes a RSS config
+ */
+static int ice_vc_handle_rss_cfg(struct ice_vf *vf, u8 *msg, bool add)
+{
+	u32 v_opcode = add ? VIRTCHNL_OP_ADD_RSS_CFG : VIRTCHNL_OP_DEL_RSS_CFG;
+	struct virtchnl_rss_cfg *rss_cfg = (struct virtchnl_rss_cfg *)msg;
+	enum virtchnl_status_code v_ret = VIRTCHNL_STATUS_SUCCESS;
+	struct device *dev = ice_pf_to_dev(vf->pf);
+	struct ice_hw *hw = &vf->pf->hw;
+	struct ice_vsi *vsi;
+
+	if (!test_bit(ICE_FLAG_RSS_ENA, vf->pf->flags)) {
+		dev_dbg(dev, "VF %d attempting to configure RSS, but RSS is not supported by the PF\n",
+			vf->vf_id);
+		v_ret = VIRTCHNL_STATUS_ERR_NOT_SUPPORTED;
+		goto error_param;
+	}
+
+	if (!ice_vf_adv_rss_offload_ena(vf->driver_caps)) {
+		dev_dbg(dev, "VF %d attempting to configure RSS, but Advanced RSS offload is not supported\n",
+			vf->vf_id);
+		v_ret = VIRTCHNL_STATUS_ERR_PARAM;
+		goto error_param;
+	}
+
+	if (!test_bit(ICE_VF_STATE_ACTIVE, vf->vf_states)) {
+		v_ret = VIRTCHNL_STATUS_ERR_PARAM;
+		goto error_param;
+	}
+
+	if (rss_cfg->proto_hdrs.count > VIRTCHNL_MAX_NUM_PROTO_HDRS ||
+	    rss_cfg->rss_algorithm < VIRTCHNL_RSS_ALG_TOEPLITZ_ASYMMETRIC ||
+	    rss_cfg->rss_algorithm > VIRTCHNL_RSS_ALG_XOR_SYMMETRIC) {
+		dev_dbg(dev, "VF %d attempting to configure RSS, but RSS configuration is not valid\n",
+			vf->vf_id);
+		v_ret = VIRTCHNL_STATUS_ERR_PARAM;
+		goto error_param;
+	}
+
+	vsi = vf->pf->vsi[vf->lan_vsi_idx];
+	if (!vsi) {
+		v_ret = VIRTCHNL_STATUS_ERR_PARAM;
+		goto error_param;
+	}
+
+	if (rss_cfg->rss_algorithm == VIRTCHNL_RSS_ALG_R_ASYMMETRIC) {
+		struct ice_vsi_ctx *ctx;
+		enum ice_status status;
+		u8 lut_type, hash_type;
+
+		lut_type = ICE_AQ_VSI_Q_OPT_RSS_LUT_VSI;
+		hash_type = add ? ICE_AQ_VSI_Q_OPT_RSS_XOR :
+				ICE_AQ_VSI_Q_OPT_RSS_TPLZ;
+
+		ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
+		if (!ctx) {
+			v_ret = VIRTCHNL_STATUS_ERR_NO_MEMORY;
+			goto error_param;
+		}
+
+		ctx->info.q_opt_rss = ((lut_type <<
+					ICE_AQ_VSI_Q_OPT_RSS_LUT_S) &
+				       ICE_AQ_VSI_Q_OPT_RSS_LUT_M) |
+				       (hash_type &
+					ICE_AQ_VSI_Q_OPT_RSS_HASH_M);
+
+		/* Preserve existing queueing option setting */
+		ctx->info.q_opt_rss |= (vsi->info.q_opt_rss &
+					  ICE_AQ_VSI_Q_OPT_RSS_GBL_LUT_M);
+		ctx->info.q_opt_tc = vsi->info.q_opt_tc;
+		ctx->info.q_opt_flags = vsi->info.q_opt_rss;
+
+		ctx->info.valid_sections =
+				cpu_to_le16(ICE_AQ_VSI_PROP_Q_OPT_VALID);
+
+		status = ice_update_vsi(hw, vsi->idx, ctx, NULL);
+		if (status) {
+			dev_err(dev, "update VSI for RSS failed, err %s aq_err %s\n",
+				ice_stat_str(status),
+				ice_aq_str(hw->adminq.sq_last_status));
+			v_ret = VIRTCHNL_STATUS_ERR_PARAM;
+		} else {
+			vsi->info.q_opt_rss = ctx->info.q_opt_rss;
+		}
+
+		kfree(ctx);
+	} else {
+		u32 addl_hdrs = ICE_FLOW_SEG_HDR_NONE;
+		u64 hash_flds = ICE_HASH_INVALID;
+
+		if (!ice_vc_parse_rss_cfg(hw, rss_cfg, &addl_hdrs,
+					  &hash_flds)) {
+			v_ret = VIRTCHNL_STATUS_ERR_PARAM;
+			goto error_param;
+		}
+
+		if (add) {
+			if (ice_add_rss_cfg(hw, vsi->idx, hash_flds,
+					    addl_hdrs)) {
+				v_ret = VIRTCHNL_STATUS_ERR_PARAM;
+				dev_err(dev, "ice_add_rss_cfg failed for vsi = %d, v_ret = %d\n",
+					vsi->vsi_num, v_ret);
+			}
+		} else {
+			v_ret = VIRTCHNL_STATUS_ERR_NOT_SUPPORTED;
+			dev_err(dev, "RSS removal not supported\n");
+		}
+	}
+
+error_param:
+	return ice_vc_send_msg_to_vf(vf, v_opcode, v_ret, NULL, 0);
+}
+
 /**
  * ice_vc_config_rss_key
  * @vf: pointer to the VF info
@@ -4029,6 +4476,12 @@ void ice_vc_process_vf_msg(struct ice_pf *pf, struct ice_rq_event_info *event)
 	case VIRTCHNL_OP_DEL_FDIR_FILTER:
 		err = ice_vc_del_fdir_fltr(vf, msg);
 		break;
+	case VIRTCHNL_OP_ADD_RSS_CFG:
+		err = ice_vc_handle_rss_cfg(vf, msg, true);
+		break;
+	case VIRTCHNL_OP_DEL_RSS_CFG:
+		err = ice_vc_handle_rss_cfg(vf, msg, false);
+		break;
 	case VIRTCHNL_OP_UNKNOWN:
 	default:
 		dev_err(dev, "Unsupported opcode %d from VF %d\n", v_opcode,
diff --git a/include/linux/avf/virtchnl.h b/include/linux/avf/virtchnl.h
index ddcff6219b61..bd94d2467e01 100644
--- a/include/linux/avf/virtchnl.h
+++ b/include/linux/avf/virtchnl.h
@@ -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;
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [Intel-wired-lan] [PATCH net-next v3 2/6] ice: Support RSS configure removal for AVF
  2021-04-13  0:48 [Intel-wired-lan] [PATCH net-next v3 0/6] Enable Intel VF RSS Haiyue Wang
  2021-04-13  0:48 ` [Intel-wired-lan] [PATCH net-next v3 1/6] ice: Enable RSS configure for AVF Haiyue Wang
@ 2021-04-13  0:48 ` Haiyue Wang
  2021-04-14  1:49   ` Chen, BoX C
  2021-04-13  0:48 ` [Intel-wired-lan] [PATCH net-next v3 3/6] iavf: Add framework to enable ethtool RSS config Haiyue Wang
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 13+ messages in thread
From: Haiyue Wang @ 2021-04-13  0:48 UTC (permalink / raw)
  To: intel-wired-lan

From: Qi Zhang <qi.z.zhang@intel.com>

Add the handler for virtchnl message VIRTCHNL_OP_DEL_RSS_CFG to remove
an existing RSS configuration with matching hashed fields.

Signed-off-by: Vignesh Sridhar <vignesh.sridhar@intel.com>
Co-developed-by: Jia Guo <jia.guo@intel.com>
Signed-off-by: Jia Guo <jia.guo@intel.com>
Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
Signed-off-by: Haiyue Wang <haiyue.wang@intel.com>
---
 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(-)

diff --git a/drivers/net/ethernet/intel/ice/ice_flow.c b/drivers/net/ethernet/intel/ice/ice_flow.c
index 4d59eb96383b..f160672448a0 100644
--- a/drivers/net/ethernet/intel/ice/ice_flow.c
+++ b/drivers/net/ethernet/intel/ice/ice_flow.c
@@ -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.
diff --git a/drivers/net/ethernet/intel/ice/ice_flow.h b/drivers/net/ethernet/intel/ice/ice_flow.h
index 2f68b59ace7e..2a2d8c1536cb 100644
--- a/drivers/net/ethernet/intel/ice/ice_flow.h
+++ b/drivers/net/ethernet/intel/ice/ice_flow.h
@@ -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_ */
diff --git a/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c b/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c
index f104326037fb..3bacd9d76347 100644
--- a/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c
+++ b/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c
@@ -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));
+			}
 		}
 	}
 
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [Intel-wired-lan] [PATCH net-next v3 3/6] iavf: Add framework to enable ethtool RSS config
  2021-04-13  0:48 [Intel-wired-lan] [PATCH net-next v3 0/6] Enable Intel VF RSS Haiyue Wang
  2021-04-13  0:48 ` [Intel-wired-lan] [PATCH net-next v3 1/6] ice: Enable RSS configure for AVF Haiyue Wang
  2021-04-13  0:48 ` [Intel-wired-lan] [PATCH net-next v3 2/6] ice: Support RSS configure removal " Haiyue Wang
@ 2021-04-13  0:48 ` Haiyue Wang
  2021-04-21 19:23   ` Jankowski, Konrad0
  2021-04-13  0:48 ` [Intel-wired-lan] [PATCH net-next v3 4/6] iavf: Support for modifying TCP RSS flow hashing Haiyue Wang
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 13+ messages in thread
From: Haiyue Wang @ 2021-04-13  0:48 UTC (permalink / raw)
  To: intel-wired-lan

Add 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 <haiyue.wang@intel.com>
---
 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

diff --git a/drivers/net/ethernet/intel/iavf/iavf.h b/drivers/net/ethernet/intel/iavf/iavf.h
index 09e5b9cf5719..1e996d9c1351 100644
--- a/drivers/net/ethernet/intel/iavf/iavf.h
+++ b/drivers/net/ethernet/intel/iavf/iavf.h
@@ -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_ */
diff --git a/drivers/net/ethernet/intel/iavf/iavf_adv_rss.h b/drivers/net/ethernet/intel/iavf/iavf_adv_rss.h
new file mode 100644
index 000000000000..66262090e697
--- /dev/null
+++ b/drivers/net/ethernet/intel/iavf/iavf_adv_rss.h
@@ -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_ */
diff --git a/drivers/net/ethernet/intel/iavf/iavf_main.c b/drivers/net/ethernet/intel/iavf/iavf_main.c
index 357e66e866b7..1323778f461d 100644
--- a/drivers/net/ethernet/intel/iavf/iavf_main.c
+++ b/drivers/net/ethernet/intel/iavf/iavf_main.c
@@ -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);
diff --git a/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c b/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c
index 9aaade0aae4c..54d2efe1732d 100644
--- a/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c
+++ b/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c
@@ -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 @@ void iavf_del_fdir_filter(struct iavf_adapter *adapter)
 	iavf_send_pf_msg(adapter, VIRTCHNL_OP_DEL_FDIR_FILTER, (u8 *)&f, len);
 }
 
+/**
+ * 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 RSS configuration, command %d pending\n",
+			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;
+	}
+
+	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 RSS configuration, command %d pending\n",
+			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;
+	}
+
+	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->adv_rss_list_head,
+					    list) {
+				if (rss->state == IAVF_ADV_RSS_DEL_PENDING) {
+					rss->state = IAVF_ADV_RSS_ACTIVE;
+					dev_err(&adapter->pdev->dev, "Failed to delete RSS configuration, error %s\n",
+						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 VLAN Stripping is not allowed when Port VLAN is configured\n");
@@ -1683,6 +1811,30 @@ 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;
+
+		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->current_op))
 			dev_warn(&adapter->pdev->dev, "Expected response %d from PF, received %d\n",
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [Intel-wired-lan] [PATCH net-next v3 4/6] iavf: Support for modifying TCP RSS flow hashing
  2021-04-13  0:48 [Intel-wired-lan] [PATCH net-next v3 0/6] Enable Intel VF RSS Haiyue Wang
                   ` (2 preceding siblings ...)
  2021-04-13  0:48 ` [Intel-wired-lan] [PATCH net-next v3 3/6] iavf: Add framework to enable ethtool RSS config Haiyue Wang
@ 2021-04-13  0:48 ` Haiyue Wang
  2021-04-21 19:22   ` Jankowski, Konrad0
  2021-04-13  0:48 ` [Intel-wired-lan] [PATCH net-next v3 5/6] iavf: Support for modifying UDP " Haiyue Wang
  2021-04-13  0:48 ` [Intel-wired-lan] [PATCH net-next v3 6/6] iavf: Support for modifying SCTP " Haiyue Wang
  5 siblings, 1 reply; 13+ messages in thread
From: Haiyue Wang @ 2021-04-13  0:48 UTC (permalink / raw)
  To: intel-wired-lan

Provides 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 <haiyue.wang@intel.com>
---
 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

diff --git a/drivers/net/ethernet/intel/iavf/Makefile b/drivers/net/ethernet/intel/iavf/Makefile
index 121e194ee734..9c3e45c54d01 100644
--- a/drivers/net/ethernet/intel/iavf/Makefile
+++ b/drivers/net/ethernet/intel/iavf/Makefile
@@ -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.c b/drivers/net/ethernet/intel/iavf/iavf_adv_rss.c
new file mode 100644
index 000000000000..4c5771cdc445
--- /dev/null
+++ b/drivers/net/ethernet/intel/iavf/iavf_adv_rss.c
@@ -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);
+
+	if (hash_flds & IAVF_ADV_RSS_HASH_FLD_TCP_DST_PORT)
+		VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT(hdr, TCP, 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
+ * @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;
+
+	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,
+		       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);
+}
diff --git a/drivers/net/ethernet/intel/iavf/iavf_adv_rss.h b/drivers/net/ethernet/intel/iavf/iavf_adv_rss.h
index 66262090e697..339ecb42938b 100644
--- a/drivers/net/ethernet/intel/iavf/iavf_adv_rss.h
+++ b/drivers/net/ethernet/intel/iavf/iavf_adv_rss.h
@@ -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_ */
diff --git a/drivers/net/ethernet/intel/iavf/iavf_ethtool.c b/drivers/net/ethernet/intel/iavf/iavf_ethtool.c
index 935145ab2b77..b5ec8e723b61 100644
--- a/drivers/net/ethernet/intel/iavf/iavf_ethtool.c
+++ b/drivers/net/ethernet/intel/iavf/iavf_ethtool.c
@@ -1418,6 +1418,214 @@ static int iavf_del_fdir_ethtool(struct iavf_adapter *adapter, struct ethtool_rx
 	return 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;
+			if (cmd->data & RXH_L4_B_2_3)
+				hfld |= IAVF_ADV_RSS_HASH_FLD_TCP_DST_PORT;
+			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)) {
+		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;
+		} 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;
+	}
+	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)
 	case 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:
 		break;
diff --git a/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c b/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c
index 54d2efe1732d..0eab3c43bdc5 100644
--- a/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c
+++ b/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c
@@ -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;
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [Intel-wired-lan] [PATCH net-next v3 5/6] iavf: Support for modifying UDP RSS flow hashing
  2021-04-13  0:48 [Intel-wired-lan] [PATCH net-next v3 0/6] Enable Intel VF RSS Haiyue Wang
                   ` (3 preceding siblings ...)
  2021-04-13  0:48 ` [Intel-wired-lan] [PATCH net-next v3 4/6] iavf: Support for modifying TCP RSS flow hashing Haiyue Wang
@ 2021-04-13  0:48 ` Haiyue Wang
  2021-04-21 19:22   ` Jankowski, Konrad0
  2021-04-13  0:48 ` [Intel-wired-lan] [PATCH net-next v3 6/6] iavf: Support for modifying SCTP " Haiyue Wang
  5 siblings, 1 reply; 13+ messages in thread
From: Haiyue Wang @ 2021-04-13  0:48 UTC (permalink / raw)
  To: intel-wired-lan

Provides 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 <haiyue.wang@intel.com>
---
 .../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(-)

diff --git a/drivers/net/ethernet/intel/iavf/iavf_adv_rss.c b/drivers/net/ethernet/intel/iavf/iavf_adv_rss.c
index 4c5771cdc445..a8e03aaccc6b 100644
--- a/drivers/net/ethernet/intel/iavf/iavf_adv_rss.c
+++ b/drivers/net/ethernet/intel/iavf/iavf_adv_rss.c
@@ -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)
diff --git a/drivers/net/ethernet/intel/iavf/iavf_adv_rss.h b/drivers/net/ethernet/intel/iavf/iavf_adv_rss.h
index 339ecb42938b..4681f5e8321d 100644
--- a/drivers/net/ethernet/intel/iavf/iavf_adv_rss.h
+++ b/drivers/net/ethernet/intel/iavf/iavf_adv_rss.h
@@ -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.c b/drivers/net/ethernet/intel/iavf/iavf_ethtool.c
index b5ec8e723b61..8a396cba944b 100644
--- a/drivers/net/ethernet/intel/iavf/iavf_ethtool.c
+++ b/drivers/net/ethernet/intel/iavf/iavf_ethtool.c
@@ -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;
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [Intel-wired-lan] [PATCH net-next v3 6/6] iavf: Support for modifying SCTP RSS flow hashing
  2021-04-13  0:48 [Intel-wired-lan] [PATCH net-next v3 0/6] Enable Intel VF RSS Haiyue Wang
                   ` (4 preceding siblings ...)
  2021-04-13  0:48 ` [Intel-wired-lan] [PATCH net-next v3 5/6] iavf: Support for modifying UDP " Haiyue Wang
@ 2021-04-13  0:48 ` Haiyue Wang
  2021-04-21 19:20   ` Jankowski, Konrad0
  5 siblings, 1 reply; 13+ messages in thread
From: Haiyue Wang @ 2021-04-13  0:48 UTC (permalink / raw)
  To: intel-wired-lan

Provide 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 <haiyue.wang@intel.com>
---
 .../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(-)

diff --git a/drivers/net/ethernet/intel/iavf/iavf_adv_rss.c b/drivers/net/ethernet/intel/iavf/iavf_adv_rss.c
index a8e03aaccc6b..6edbf134b73f 100644
--- a/drivers/net/ethernet/intel/iavf/iavf_adv_rss.c
+++ b/drivers/net/ethernet/intel/iavf/iavf_adv_rss.c
@@ -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)
diff --git a/drivers/net/ethernet/intel/iavf/iavf_adv_rss.h b/drivers/net/ethernet/intel/iavf/iavf_adv_rss.h
index 4681f5e8321d..4d3be11af7aa 100644
--- a/drivers/net/ethernet/intel/iavf/iavf_adv_rss.h
+++ b/drivers/net/ethernet/intel/iavf/iavf_adv_rss.h
@@ -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.c b/drivers/net/ethernet/intel/iavf/iavf_ethtool.c
index 8a396cba944b..0d22a5275218 100644
--- a/drivers/net/ethernet/intel/iavf/iavf_ethtool.c
+++ b/drivers/net/ethernet/intel/iavf/iavf_ethtool.c
@@ -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;
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [Intel-wired-lan] [PATCH net-next v3 1/6] ice: Enable RSS configure for AVF
  2021-04-13  0:48 ` [Intel-wired-lan] [PATCH net-next v3 1/6] ice: Enable RSS configure for AVF Haiyue Wang
@ 2021-04-14  1:47   ` Chen, BoX C
  0 siblings, 0 replies; 13+ messages in thread
From: Chen, BoX C @ 2021-04-14  1:47 UTC (permalink / raw)
  To: intel-wired-lan

> -----Original Message-----
> From: Intel-wired-lan <intel-wired-lan-bounces@osuosl.org> On Behalf Of
> Haiyue Wang
> Sent: April 13, 2021 8:49
> To: intel-wired-lan at lists.osuosl.org
> Cc: Guo, Jia <jia.guo@intel.com>; Zhang, Qi Z <qi.z.zhang@intel.com>
> Subject: [Intel-wired-lan] [PATCH net-next v3 1/6] ice: Enable RSS configure
> for AVF
> 
> From: Qi Zhang <qi.z.zhang@intel.com>
> 
> 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.
> 
> Signed-off-by: Jia Guo <jia.guo@intel.com>
> Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
> Signed-off-by: Haiyue Wang <haiyue.wang@intel.com>
> ---
>  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(-)
> 

Tested-by: Bo Chen <BoX.C.Chen@intel.com>

Regards,
Chen Bo
______________________________________________
Intel-wired-lan mailing list
Intel-wired-lan at osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Intel-wired-lan] [PATCH net-next v3 2/6] ice: Support RSS configure removal for AVF
  2021-04-13  0:48 ` [Intel-wired-lan] [PATCH net-next v3 2/6] ice: Support RSS configure removal " Haiyue Wang
@ 2021-04-14  1:49   ` Chen, BoX C
  0 siblings, 0 replies; 13+ messages in thread
From: Chen, BoX C @ 2021-04-14  1:49 UTC (permalink / raw)
  To: intel-wired-lan

> -----Original Message-----
> From: Intel-wired-lan <intel-wired-lan-bounces@osuosl.org> On Behalf Of
> Haiyue Wang
> Sent: April 13, 2021 8:49
> To: intel-wired-lan at lists.osuosl.org
> Cc: Guo, Jia <jia.guo@intel.com>; Sridhar, Vignesh
> <vignesh.sridhar@intel.com>; Zhang, Qi Z <qi.z.zhang@intel.com>
> Subject: [Intel-wired-lan] [PATCH net-next v3 2/6] ice: Support RSS configure
> removal for AVF
> 
> From: Qi Zhang <qi.z.zhang@intel.com>
> 
> Add the handler for virtchnl message VIRTCHNL_OP_DEL_RSS_CFG to
> remove an existing RSS configuration with matching hashed fields.
> 
> Signed-off-by: Vignesh Sridhar <vignesh.sridhar@intel.com>
> Co-developed-by: Jia Guo <jia.guo@intel.com>
> Signed-off-by: Jia Guo <jia.guo@intel.com>
> Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
> Signed-off-by: Haiyue Wang <haiyue.wang@intel.com>
> ---
>  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(-)
> 

Tested-by: Bo Chen <BoX.C.Chen@intel.com>

Regards,
Chen Bo
_______________________________________________
Intel-wired-lan mailing list
Intel-wired-lan at osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Intel-wired-lan] [PATCH net-next v3 6/6] iavf: Support for modifying SCTP RSS flow hashing
  2021-04-13  0:48 ` [Intel-wired-lan] [PATCH net-next v3 6/6] iavf: Support for modifying SCTP " Haiyue Wang
@ 2021-04-21 19:20   ` Jankowski, Konrad0
  0 siblings, 0 replies; 13+ messages in thread
From: Jankowski, Konrad0 @ 2021-04-21 19:20 UTC (permalink / raw)
  To: intel-wired-lan



> -----Original Message-----
> From: Intel-wired-lan <intel-wired-lan-bounces@osuosl.org> On Behalf Of
> Haiyue Wang
> Sent: wtorek, 13 kwietnia 2021 02:49
> To: intel-wired-lan at lists.osuosl.org
> Cc: Zhang, Qi Z <qi.z.zhang@intel.com>
> Subject: [Intel-wired-lan] [PATCH net-next v3 6/6] iavf: Support for
> modifying SCTP RSS flow hashing
> 
> Provide 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 <haiyue.wang@intel.com>
> ---
>  .../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(-)
> 
> diff --git a/drivers/net/ethernet/intel/iavf/iavf_adv_rss.c
> b/drivers/net/ethernet/intel/iavf/iavf_adv_rss.c
> index a8e03aaccc6b..6edbf134b73f 100644
> --- a/drivers/net/ethernet/intel/iavf/iavf_adv_rss.c
> +++ b/drivers/net/ethernet/intel/iavf/iavf_adv_rss.c
> @@ -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)
> diff --git a/drivers/net/ethernet/intel/iavf/iavf_adv_rss.h
> b/drivers/net/ethernet/intel/iavf/iavf_adv_rss.h
> index 4681f5e8321d..4d3be11af7aa 100644
> --- a/drivers/net/ethernet/intel/iavf/iavf_adv_rss.h
> +++ b/drivers/net/ethernet/intel/iavf/iavf_adv_rss.h
> @@ -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.c
> b/drivers/net/ethernet/intel/iavf/iavf_ethtool.c
> index 8a396cba944b..0d22a5275218 100644
> --- a/drivers/net/ethernet/intel/iavf/iavf_ethtool.c
> +++ b/drivers/net/ethernet/intel/iavf/iavf_ethtool.c
> @@ -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;

Tested-by: Konrad Jankowski <konrad0.jankowski@intel.com>

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Intel-wired-lan] [PATCH net-next v3 5/6] iavf: Support for modifying UDP RSS flow hashing
  2021-04-13  0:48 ` [Intel-wired-lan] [PATCH net-next v3 5/6] iavf: Support for modifying UDP " Haiyue Wang
@ 2021-04-21 19:22   ` Jankowski, Konrad0
  0 siblings, 0 replies; 13+ messages in thread
From: Jankowski, Konrad0 @ 2021-04-21 19:22 UTC (permalink / raw)
  To: intel-wired-lan



> -----Original Message-----
> From: Intel-wired-lan <intel-wired-lan-bounces@osuosl.org> On Behalf Of
> Haiyue Wang
> Sent: wtorek, 13 kwietnia 2021 02:49
> To: intel-wired-lan at lists.osuosl.org
> Cc: Zhang, Qi Z <qi.z.zhang@intel.com>
> Subject: [Intel-wired-lan] [PATCH net-next v3 5/6] iavf: Support for
> modifying UDP RSS flow hashing
> 
> Provides 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 <haiyue.wang@intel.com>
> ---
>  .../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(-)
> 
> diff --git a/drivers/net/ethernet/intel/iavf/iavf_adv_rss.c
> b/drivers/net/ethernet/intel/iavf/iavf_adv_rss.c
> index 4c5771cdc445..a8e03aaccc6b 100644
> --- a/drivers/net/ethernet/intel/iavf/iavf_adv_rss.c
> +++ b/drivers/net/ethernet/intel/iavf/iavf_adv_rss.c
> @@ -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)
> diff --git a/drivers/net/ethernet/intel/iavf/iavf_adv_rss.h
> b/drivers/net/ethernet/intel/iavf/iavf_adv_rss.h
> index 339ecb42938b..4681f5e8321d 100644
> --- a/drivers/net/ethernet/intel/iavf/iavf_adv_rss.h
> +++ b/drivers/net/ethernet/intel/iavf/iavf_adv_rss.h
> @@ -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.c
> b/drivers/net/ethernet/intel/iavf/iavf_ethtool.c
> index b5ec8e723b61..8a396cba944b 100644
> --- a/drivers/net/ethernet/intel/iavf/iavf_ethtool.c
> +++ b/drivers/net/ethernet/intel/iavf/iavf_ethtool.c
> @@ -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;

Tested-by: Konrad Jankowski <konrad0.jankowski@intel.com>

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Intel-wired-lan] [PATCH net-next v3 4/6] iavf: Support for modifying TCP RSS flow hashing
  2021-04-13  0:48 ` [Intel-wired-lan] [PATCH net-next v3 4/6] iavf: Support for modifying TCP RSS flow hashing Haiyue Wang
@ 2021-04-21 19:22   ` Jankowski, Konrad0
  0 siblings, 0 replies; 13+ messages in thread
From: Jankowski, Konrad0 @ 2021-04-21 19:22 UTC (permalink / raw)
  To: intel-wired-lan



> -----Original Message-----
> From: Intel-wired-lan <intel-wired-lan-bounces@osuosl.org> On Behalf Of
> Haiyue Wang
> Sent: wtorek, 13 kwietnia 2021 02:49
> To: intel-wired-lan at lists.osuosl.org
> Cc: Zhang, Qi Z <qi.z.zhang@intel.com>
> Subject: [Intel-wired-lan] [PATCH net-next v3 4/6] iavf: Support for
> modifying TCP RSS flow hashing
> 
> Provides 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 <haiyue.wang@intel.com>
> ---
>  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
> 
> diff --git a/drivers/net/ethernet/intel/iavf/Makefile
> b/drivers/net/ethernet/intel/iavf/Makefile
> index 121e194ee734..9c3e45c54d01 100644
> --- a/drivers/net/ethernet/intel/iavf/Makefile
> +++ b/drivers/net/ethernet/intel/iavf/Makefile
> @@ -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.c
> b/drivers/net/ethernet/intel/iavf/iavf_adv_rss.c
> new file mode 100644
> index 000000000000..4c5771cdc445
> --- /dev/null
> +++ b/drivers/net/ethernet/intel/iavf/iavf_adv_rss.c
> @@ -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);
> +
> +	if (hash_flds & IAVF_ADV_RSS_HASH_FLD_TCP_DST_PORT)
> +		VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT(hdr, TCP,
> 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
> + * @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;
> +
> +	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,
> +		       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);
> +}
> diff --git a/drivers/net/ethernet/intel/iavf/iavf_adv_rss.h
> b/drivers/net/ethernet/intel/iavf/iavf_adv_rss.h
> index 66262090e697..339ecb42938b 100644
> --- a/drivers/net/ethernet/intel/iavf/iavf_adv_rss.h
> +++ b/drivers/net/ethernet/intel/iavf/iavf_adv_rss.h
> @@ -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_ */
> diff --git a/drivers/net/ethernet/intel/iavf/iavf_ethtool.c
> b/drivers/net/ethernet/intel/iavf/iavf_ethtool.c
> index 935145ab2b77..b5ec8e723b61 100644
> --- a/drivers/net/ethernet/intel/iavf/iavf_ethtool.c
> +++ b/drivers/net/ethernet/intel/iavf/iavf_ethtool.c
> @@ -1418,6 +1418,214 @@ static int iavf_del_fdir_ethtool(struct
> iavf_adapter *adapter, struct ethtool_rx
>  	return 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;
> +			if (cmd->data & RXH_L4_B_2_3)
> +				hfld |=
> IAVF_ADV_RSS_HASH_FLD_TCP_DST_PORT;
> +			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))
> {
> +		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;
> +		} 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;
> +	}
> +	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)
>  	case 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:
>  		break;
> diff --git a/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c
> b/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c
> index 54d2efe1732d..0eab3c43bdc5 100644
> --- a/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c
> +++ b/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c
> @@ -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;

Tested-by: Konrad Jankowski <konrad0.jankowski@intel.com>

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Intel-wired-lan] [PATCH net-next v3 3/6] iavf: Add framework to enable ethtool RSS config
  2021-04-13  0:48 ` [Intel-wired-lan] [PATCH net-next v3 3/6] iavf: Add framework to enable ethtool RSS config Haiyue Wang
@ 2021-04-21 19:23   ` Jankowski, Konrad0
  0 siblings, 0 replies; 13+ messages in thread
From: Jankowski, Konrad0 @ 2021-04-21 19:23 UTC (permalink / raw)
  To: intel-wired-lan



> -----Original Message-----
> From: Intel-wired-lan <intel-wired-lan-bounces@osuosl.org> On Behalf Of
> Haiyue Wang
> Sent: wtorek, 13 kwietnia 2021 02:49
> To: intel-wired-lan at lists.osuosl.org
> Cc: Zhang, Qi Z <qi.z.zhang@intel.com>
> Subject: [Intel-wired-lan] [PATCH net-next v3 3/6] iavf: Add framework to
> enable ethtool RSS config
> 
> Add 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 <haiyue.wang@intel.com>
> ---
>  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
> 
> diff --git a/drivers/net/ethernet/intel/iavf/iavf.h
> b/drivers/net/ethernet/intel/iavf/iavf.h
> index 09e5b9cf5719..1e996d9c1351 100644
> --- a/drivers/net/ethernet/intel/iavf/iavf.h
> +++ b/drivers/net/ethernet/intel/iavf/iavf.h
> @@ -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_ */
> diff --git a/drivers/net/ethernet/intel/iavf/iavf_adv_rss.h
> b/drivers/net/ethernet/intel/iavf/iavf_adv_rss.h
> new file mode 100644
> index 000000000000..66262090e697
> --- /dev/null
> +++ b/drivers/net/ethernet/intel/iavf/iavf_adv_rss.h
> @@ -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_ */
> diff --git a/drivers/net/ethernet/intel/iavf/iavf_main.c
> b/drivers/net/ethernet/intel/iavf/iavf_main.c
> index 357e66e866b7..1323778f461d 100644
> --- a/drivers/net/ethernet/intel/iavf/iavf_main.c
> +++ b/drivers/net/ethernet/intel/iavf/iavf_main.c
> @@ -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);
> diff --git a/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c
> b/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c
> index 9aaade0aae4c..54d2efe1732d 100644
> --- a/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c
> +++ b/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c
> @@ -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 @@ void iavf_del_fdir_filter(struct iavf_adapter *adapter)
>  	iavf_send_pf_msg(adapter, VIRTCHNL_OP_DEL_FDIR_FILTER, (u8
> *)&f, len);  }
> 
> +/**
> + * 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 RSS
> configuration, command %d pending\n",
> +			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;
> +	}
> +
> +	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 RSS
> configuration, command %d pending\n",
> +			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;
> +	}
> +
> +	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-
> >adv_rss_list_head,
> +					    list) {
> +				if (rss->state ==
> IAVF_ADV_RSS_DEL_PENDING) {
> +					rss->state = IAVF_ADV_RSS_ACTIVE;
> +					dev_err(&adapter->pdev->dev,
> "Failed to delete RSS configuration, error %s\n",
> +						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 VLAN
> Stripping is not allowed when Port VLAN is configured\n"); @@ -1683,6
> +1811,30 @@ 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;
> +
> +		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-
> >current_op))
>  			dev_warn(&adapter->pdev->dev, "Expected
> response %d from PF, received %d\n",

Tested-by: Konrad Jankowski <konrad0.jankowski@intel.com>

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2021-04-21 19:23 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-13  0:48 [Intel-wired-lan] [PATCH net-next v3 0/6] Enable Intel VF RSS Haiyue Wang
2021-04-13  0:48 ` [Intel-wired-lan] [PATCH net-next v3 1/6] ice: Enable RSS configure for AVF Haiyue Wang
2021-04-14  1:47   ` Chen, BoX C
2021-04-13  0:48 ` [Intel-wired-lan] [PATCH net-next v3 2/6] ice: Support RSS configure removal " Haiyue Wang
2021-04-14  1:49   ` Chen, BoX C
2021-04-13  0:48 ` [Intel-wired-lan] [PATCH net-next v3 3/6] iavf: Add framework to enable ethtool RSS config Haiyue Wang
2021-04-21 19:23   ` Jankowski, Konrad0
2021-04-13  0:48 ` [Intel-wired-lan] [PATCH net-next v3 4/6] iavf: Support for modifying TCP RSS flow hashing Haiyue Wang
2021-04-21 19:22   ` Jankowski, Konrad0
2021-04-13  0:48 ` [Intel-wired-lan] [PATCH net-next v3 5/6] iavf: Support for modifying UDP " Haiyue Wang
2021-04-21 19:22   ` Jankowski, Konrad0
2021-04-13  0:48 ` [Intel-wired-lan] [PATCH net-next v3 6/6] iavf: Support for modifying SCTP " Haiyue Wang
2021-04-21 19:20   ` Jankowski, Konrad0

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.