From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from dpdk.org (dpdk.org [92.243.14.124])
	by inbox.dpdk.org (Postfix) with ESMTP id A6108A0577;
	Mon, 13 Apr 2020 04:05:21 +0200 (CEST)
Received: from [92.243.14.124] (localhost [127.0.0.1])
	by dpdk.org (Postfix) with ESMTP id AFB8F2B86;
	Mon, 13 Apr 2020 04:05:20 +0200 (CEST)
Received: from mga05.intel.com (mga05.intel.com [192.55.52.43])
 by dpdk.org (Postfix) with ESMTP id 90E2FFFA
 for <dev@dpdk.org>; Mon, 13 Apr 2020 04:05:18 +0200 (CEST)
IronPort-SDR: OaRgXQKq0iEpkpu5vLzagRr4gu4hrm6Zo4q1T1wqX/xhy42MTto0iGkht4IrGtVmD2Y1kuHu7T
 ins/wy4MrHWQ==
X-Amp-Result: SKIPPED(no attachment in message)
X-Amp-File-Uploaded: False
Received: from fmsmga005.fm.intel.com ([10.253.24.32])
 by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;
 12 Apr 2020 19:05:15 -0700
IronPort-SDR: C3v7ZTsRPynxYzf7EExrGLnsALmTViYJkYyfp8Jnyax7239hIXX8sOzcbSlHQbg3mqaFdVC5bP
 ZAIaLWxEa4iA==
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.72,377,1580803200"; d="scan'208";a="453009253"
Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203])
 by fmsmga005.fm.intel.com with ESMTP; 12 Apr 2020 19:05:15 -0700
Received: from fmsmsx603.amr.corp.intel.com (10.18.126.83) by
 FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS)
 id 14.3.439.0; Sun, 12 Apr 2020 19:05:14 -0700
Received: from fmsmsx603.amr.corp.intel.com (10.18.126.83) by
 fmsmsx603.amr.corp.intel.com (10.18.126.83) with Microsoft SMTP Server
 (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id
 15.1.1713.5; Sun, 12 Apr 2020 19:05:14 -0700
Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by
 fmsmsx603.amr.corp.intel.com (10.18.126.83) with Microsoft SMTP Server
 (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1713.5
 via Frontend Transport; Sun, 12 Apr 2020 19:05:14 -0700
Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.146]) by
 SHSMSX101.ccr.corp.intel.com ([169.254.1.129]) with mapi id 14.03.0439.000;
 Mon, 13 Apr 2020 10:02:26 +0800
From: "Zhang, Qi Z" <qi.z.zhang@intel.com>
To: "Guo, Jia" <jia.guo@intel.com>, "Ye, Xiaolong" <xiaolong.ye@intel.com>
CC: "dev@dpdk.org" <dev@dpdk.org>, "Wu, Jingjing" <jingjing.wu@intel.com>,
 "Cao, Yahui" <yahui.cao@intel.com>, "Su, Simei" <simei.su@intel.com>
Thread-Topic: [dpdk-dev v3 2/4] net/iavf: add RSS configuration for VFs
Thread-Index: AQHWD0qidXitfEBsrUejVGtXamy4Sqh2OmyA
Date: Mon, 13 Apr 2020 02:02:25 +0000
Message-ID: <039ED4275CED7440929022BC67E70611547F7C92@SHSMSX103.ccr.corp.intel.com>
References: <20200318170401.7938-5-jia.guo@intel.com>
 <20200411000945.15311-1-jia.guo@intel.com>
 <20200411000945.15311-3-jia.guo@intel.com>
In-Reply-To: <20200411000945.15311-3-jia.guo@intel.com>
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach: 
X-MS-TNEF-Correlator: 
dlp-product: dlpe-windows
dlp-version: 11.2.0.6
dlp-reaction: no-action
x-originating-ip: [10.239.127.40]
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
Subject: Re: [dpdk-dev] [dpdk-dev v3 2/4] net/iavf: add RSS configuration
	for VFs
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org
Sender: "dev" <dev-bounces@dpdk.org>

Hi Jeff:

> -----Original Message-----
> From: Guo, Jia <jia.guo@intel.com>
> Sent: Saturday, April 11, 2020 8:10 AM
> To: Ye, Xiaolong <xiaolong.ye@intel.com>; Zhang, Qi Z <qi.z.zhang@intel.c=
om>
> Cc: dev@dpdk.org; Wu, Jingjing <jingjing.wu@intel.com>; Cao, Yahui
> <yahui.cao@intel.com>; Su, Simei <simei.su@intel.com>; Guo, Jia
> <jia.guo@intel.com>
> Subject: [dpdk-dev v3 2/4] net/iavf: add RSS configuration for VFs
>=20
> The VF must be capable of configuring RSS. Add a virtchnl handler to pars=
e a
> specific RSS configuration, and process the configuration for VFs, such a=
s add
> or delete a RSS rule.
>=20
> Signed-off-by: Jeff Guo <jia.guo@intel.com>
> ---
> v3->v2:
> 1.add doc in release note
> 2.refine some naming base on virtchnl definition.
> ---
>  doc/guides/rel_notes/release_20_05.rst |    2 +
>  drivers/net/iavf/Makefile              |    1 +
>  drivers/net/iavf/iavf.h                |    2 +
>  drivers/net/iavf/iavf_hash.c           | 1108
> ++++++++++++++++++++++++
>  drivers/net/iavf/iavf_vchnl.c          |   33 +-
>  drivers/net/iavf/meson.build           |    1 +
>  6 files changed, 1142 insertions(+), 5 deletions(-)  create mode 100644
> drivers/net/iavf/iavf_hash.c
>=20
> diff --git a/doc/guides/rel_notes/release_20_05.rst
> b/doc/guides/rel_notes/release_20_05.rst
> index 4b81893ff..b5962d8e4 100644
> --- a/doc/guides/rel_notes/release_20_05.rst
> +++ b/doc/guides/rel_notes/release_20_05.rst
> @@ -98,6 +98,8 @@ New Features
>    Update the Intel iavf driver with new features and improvements,
> including:
>=20
>    * Added generic filter support.
> +  * Added advanced RSS configuration for VFs.
> +
>=20
>  Removed Items
>  -------------
> diff --git a/drivers/net/iavf/Makefile b/drivers/net/iavf/Makefile index
> 1bf0f26b5..7b0093a3e 100644
> --- a/drivers/net/iavf/Makefile
> +++ b/drivers/net/iavf/Makefile
> @@ -24,6 +24,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_IAVF_PMD) +=3D
> iavf_ethdev.c
>  SRCS-$(CONFIG_RTE_LIBRTE_IAVF_PMD) +=3D iavf_vchnl.c
>  SRCS-$(CONFIG_RTE_LIBRTE_IAVF_PMD) +=3D iavf_rxtx.c
>  SRCS-$(CONFIG_RTE_LIBRTE_IAVF_PMD) +=3D iavf_generic_flow.c
> +SRCS-$(CONFIG_RTE_LIBRTE_IAVF_PMD) +=3D iavf_hash.c
>  ifeq ($(CONFIG_RTE_ARCH_X86), y)
>  SRCS-$(CONFIG_RTE_LIBRTE_IAVF_PMD) +=3D iavf_rxtx_vec_sse.c  endif diff
> --git a/drivers/net/iavf/iavf.h b/drivers/net/iavf/iavf.h index
> 78bdaff20..d813296d3 100644
> --- a/drivers/net/iavf/iavf.h
> +++ b/drivers/net/iavf/iavf.h
> @@ -252,4 +252,6 @@ int iavf_config_promisc(struct iavf_adapter
> *adapter, bool enable_unicast,  int iavf_add_del_eth_addr(struct
> iavf_adapter *adapter,
>  			 struct rte_ether_addr *addr, bool add);  int
> iavf_add_del_vlan(struct iavf_adapter *adapter, uint16_t vlanid, bool add=
);
> +int iavf_add_del_rss_cfg(struct iavf_adapter *adapter,
> +			 struct virtchnl_rss_cfg *rss_cfg, bool add);
>  #endif /* _IAVF_ETHDEV_H_ */
> diff --git a/drivers/net/iavf/iavf_hash.c b/drivers/net/iavf/iavf_hash.c =
new
> file mode 100644 index 000000000..f831738cc
> --- /dev/null
> +++ b/drivers/net/iavf/iavf_hash.c
> @@ -0,0 +1,1108 @@
> +/* SPDX-License-Identifier: BSD-3-Clause
> + * Copyright(c) 2020 Intel Corporation
> + */
> +
> +
> +static uint64_t
> +iavf_rss_hf_refine(uint64_t rss_hf, const struct rte_flow_item pattern[]=
,
> +		   const struct rte_flow_action *action,
> +		   struct rte_flow_error *error)
> +{
> +	const struct rte_flow_item *item;
> +
> +	for (item =3D pattern; item->type !=3D RTE_FLOW_ITEM_TYPE_END; item++)
> {
> +		if (item->type =3D=3D RTE_FLOW_ITEM_TYPE_GTP_PSC) {
> +			const struct rte_flow_action_rss *rss =3D action->conf;
> +			const struct rte_flow_item_gtp_psc *psc =3D item->spec;
> +
> +			if (psc && ((psc->pdu_type =3D=3D GTP_EH_PDU_LINK_UP &&
> +				     (rss->types & ETH_RSS_L3_SRC_ONLY)) ||

Why we need to check SRC_ONLY here, the purpose of the function is to refin=
e the rss_hf,
Should we'd better input set check to the stage " Find matched proto hdrs a=
ccording to hash type" later

> +				    (!psc->pdu_type &&

Better use GTP_EH_PDU_LINK_DOWN

> +				     (rss->types & ETH_RSS_L3_DST_ONLY)))) {
> +				rss_hf |=3D ETH_RSS_GTPU;
> +			} else {
> +				rte_flow_error_set(error, EINVAL,
> +						   RTE_FLOW_ERROR_TYPE_ITEM_SPEC,
> +						   pattern,
> +						   "Invalid input set");
> +				return -rte_errno;
> +			}
> +		}
> +	}
> +
> +	return rss_hf;
> +}
> +
> +static int
> +iavf_hash_parse_action(struct iavf_pattern_match_item
> *pattern_match_item,
> +		       const struct rte_flow_item pattern[],
> +		       const struct rte_flow_action actions[],
> +		       void **meta, struct rte_flow_error *error) {
> +	struct iavf_rss_meta *rss_meta =3D (struct iavf_rss_meta *)*meta;
> +	struct rss_type_match_hdr *m =3D (struct rss_type_match_hdr *)
> +				(pattern_match_item->meta);
> +	uint32_t type_list_len =3D RTE_DIM(iavf_hash_type_list);
> +	struct iavf_hash_match_type *type_match_item;
> +	enum rte_flow_action_type action_type;
> +	const struct rte_flow_action_rss *rss;
> +	const struct rte_flow_action *action;
> +	uint64_t rss_hf;
> +	uint16_t i;
> +	bool item_found =3D false;
> +
> +	/* Supported action is RSS. */
> +	for (action =3D actions; action->type !=3D
> +		RTE_FLOW_ACTION_TYPE_END; action++) {
> +		action_type =3D action->type;
> +		switch (action_type) {
> +		case RTE_FLOW_ACTION_TYPE_RSS:
> +			rss =3D action->conf;
> +			rss_hf =3D rss->types;
> +
> +			/**
> +			 * Check simultaneous use of SRC_ONLY and DST_ONLY
> +			 * of the same level.
> +			 */
> +			rss_hf =3D rte_eth_rss_hf_refine(rss_hf);
> +
> +			/**
> +			 * Check the item spec with the rss action and
> +			 * refine rss hash field.
> +			 */
> +			rss_hf =3D iavf_rss_hf_refine(rss_hf, pattern, action,
> +						    error);
> +
> +			/* Check if pattern is empty. */
> +			if (pattern_match_item->pattern_list !=3D
> +				iavf_pattern_empty && rss->func =3D=3D
> +				RTE_ETH_HASH_FUNCTION_SIMPLE_XOR)
> +				return rte_flow_error_set(error, ENOTSUP,
> +					RTE_FLOW_ERROR_TYPE_ACTION, action,
> +					"Not supported flow");
> +
> +			/* Check if rss types match pattern. */
> +			if (rss->func !=3D RTE_ETH_HASH_FUNCTION_SIMPLE_XOR) {
> +				if (((rss_hf & ETH_RSS_IPV4) !=3D
> +					m->eth_rss_hint) &&
> +				    ((rss_hf & ETH_RSS_NONFRAG_IPV4_UDP) !=3D
> +					m->eth_rss_hint) &&
> +				    ((rss_hf & ETH_RSS_NONFRAG_IPV4_TCP) !=3D
> +					m->eth_rss_hint) &&
> +				    ((rss_hf & ETH_RSS_NONFRAG_IPV4_SCTP) !=3D
> +					m->eth_rss_hint) &&
> +				    ((rss_hf & ETH_RSS_IPV6) !=3D
> +					m->eth_rss_hint) &&
> +				    ((rss_hf & ETH_RSS_NONFRAG_IPV6_UDP) !=3D
> +					m->eth_rss_hint) &&
> +				    ((rss_hf & ETH_RSS_NONFRAG_IPV6_TCP) !=3D
> +					m->eth_rss_hint) &&
> +				    ((rss_hf & ETH_RSS_NONFRAG_IPV6_SCTP) !=3D
> +					m->eth_rss_hint))
> +					return rte_flow_error_set(error,
> +					ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION,
> +					action, "Not supported RSS types");
> +			}

Why we need above check ? what happens if the input set does not include an=
y IP layer for example session id of PFCP?

......

> +static int
> +iavf_hash_create(__rte_unused struct iavf_adapter *ad,
> +		 __rte_unused struct rte_flow *flow, void *meta,
> +		 __rte_unused struct rte_flow_error *error) {
> +	struct iavf_rss_meta *rss_meta =3D (struct iavf_rss_meta *)meta;
> +	struct virtchnl_rss_cfg *rss_cfg;
> +	int ret =3D 0;
> +
> +	rss_cfg =3D rte_zmalloc("iavf rss rule",
> +			      sizeof(struct virtchnl_rss_cfg), 0);
> +	if (!rss_cfg) {
> +		rte_flow_error_set(error, EINVAL,
> +				   RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
> +				   "No memory for rss rule");
> +		return -ENOMEM;
> +	}
> +
> +	rss_cfg->proto_hdrs =3D *rss_meta->proto_hdrs;
> +	rss_cfg->rss_algorithm =3D rss_meta->hash_function;
> +
> +	ret =3D iavf_add_del_rss_cfg(ad, rss_cfg, true);
> +	if (!ret) {
> +		flow->rule =3D rss_cfg;
> +	} else {
> +		PMD_DRV_LOG(ERR, "fail to add RSS configure");
> +		rte_free(rss_cfg);
> +	}

The "meta" be created by iavf_hash_parse_pattern_action is assumed to be fr=
eed here,=20