net/ice: fix RSS advanced rule invalid issue
diff mbox series

Message ID 20200319074825.16035-1-junyux.jiang@intel.com
State Superseded, archived
Delegated to: xiaolong ye
Headers show
Series
  • net/ice: fix RSS advanced rule invalid issue
Related show

Checks

Context Check Description
ci/Intel-compilation success Compilation OK
ci/iol-testing success Testing PASS
ci/travis-robot success Travis build: passed
ci/iol-mellanox-Performance success Performance Testing PASS
ci/checkpatch success coding style OK

Commit Message

Junyu Jiang March 19, 2020, 7:48 a.m. UTC
This patch added a restore function of RSS advanced rule to fix
the rule invalid when after running port stop and port start.

Fixes: 5ad3db8d4bdd ("net/ice: enable advanced RSS")
Cc: stable@dpdk.org

Signed-off-by: Junyu Jiang <junyux.jiang@intel.com>
---
 drivers/net/ice/ice_ethdev.c | 47 ++++++++++++++++++++++++++++++++++++
 1 file changed, 47 insertions(+)

Comments

Yang, Qiming March 26, 2020, 2 a.m. UTC | #1
Hi, Junyu
Comments inline.
And I have a proposal, why we don't put ice_rss_init into ice_dev_init, so the rss rule will not recovery.

Qiming

> -----Original Message-----
> From: Jiang, JunyuX <junyux.jiang@intel.com>
> Sent: Thursday, March 19, 2020 15:48
> To: dev@dpdk.org
> Cc: Yang, Qiming <qiming.yang@intel.com>; Zhang, Qi Z
> <qi.z.zhang@intel.com>; Jiang, JunyuX <junyux.jiang@intel.com>;
> stable@dpdk.org
> Subject: [PATCH] net/ice: fix RSS advanced rule invalid issue
> 
> This patch added a restore function of RSS advanced rule to fix the rule

I think it should be 'for RSS advanced rule'

> invalid when after running port stop and port start.

Delete 'when'

> 
> Fixes: 5ad3db8d4bdd ("net/ice: enable advanced RSS")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Junyu Jiang <junyux.jiang@intel.com>
> ---
>  drivers/net/ice/ice_ethdev.c | 47
> ++++++++++++++++++++++++++++++++++++
>  1 file changed, 47 insertions(+)
> 
> diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c
> index 85ef83e92..2dd8120f1 100644
> --- a/drivers/net/ice/ice_ethdev.c
> +++ b/drivers/net/ice/ice_ethdev.c
> @@ -47,6 +47,11 @@ struct proto_xtr_ol_flag {
>  	bool required;
>  };
> 
> +struct ice_hash_flow_cfg {
> +	bool simple_xor;

Why not an enum for the algorithm?

> +	struct ice_rss_cfg rss_cfg;
> +};
> +
>  static struct proto_xtr_ol_flag ice_proto_xtr_ol_flag_params[] = {
>  	[PROTO_XTR_VLAN] = {
>  		.param = { .name = "ice_dynflag_proto_xtr_vlan" }, @@ -
> 2464,6 +2469,45 @@ ice_dev_configure(struct rte_eth_dev *dev)
>  	return 0;
>  }
> 
> +static int
> +ice_rss_restore(struct rte_eth_dev *dev) {
> +	struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data-
> >dev_private);
> +	struct ice_hw *hw = ICE_PF_TO_HW(pf);

Please use the same function as PF, like DEV_TO_PF

> +	struct ice_vsi *vsi = pf->main_vsi;
> +	struct rte_flow *p_flow;
> +	struct ice_hash_flow_cfg *filter_ptr;

What's the ptr means?

> +	struct ice_flow_engine *engine;
> +	uint32_t reg;
> +	int ret;
> +
> +	TAILQ_FOREACH(p_flow, &pf->flow_list, node) {
> +		engine = p_flow->engine;
> +		if (engine->type == ICE_FLOW_ENGINE_HASH) {
> +			filter_ptr = (struct ice_hash_flow_cfg *)p_flow->rule;
> +			/* Enable registers for simple_xor hash function. */
> +			if (filter_ptr->simple_xor == 1) {
> +				reg = ICE_READ_REG(hw,
> +					VSIQF_HASH_CTL(vsi->vsi_id));
> +				reg = (reg &
> (~VSIQF_HASH_CTL_HASH_SCHEME_M)) |
> +					(2 <<
> VSIQF_HASH_CTL_HASH_SCHEME_S);
> +				ICE_WRITE_REG(hw,
> +					VSIQF_HASH_CTL(vsi->vsi_id), reg);
> +			} else {
> +				ret = ice_add_rss_cfg(hw, vsi->idx,
> +					filter_ptr->rss_cfg.hashed_flds,
> +					filter_ptr->rss_cfg.packet_hdr,
> +					filter_ptr->rss_cfg.symm);
> +				if (ret)
> +					PMD_DRV_LOG(ERR,
> +						"%s restore rss fail %d",
> +						__func__, ret);
> +			}
> +		}
> +	}
> +	return 0;
> +}
> +
>  static int ice_init_rss(struct ice_pf *pf)  {
>  	struct ice_hw *hw = ICE_PF_TO_HW(pf);
> @@ -2591,6 +2635,9 @@ static int ice_init_rss(struct ice_pf *pf)
>  		PMD_DRV_LOG(ERR, "%s PPPoE/PPPoD_SessionID rss flow
> fail %d",
>  				__func__, ret);
> 
> +	/* restore RSS configuration */
> +	ice_rss_restore(dev);
> +
>  	return 0;
>  }
> 
> --
> 2.17.1

Patch
diff mbox series

diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c
index 85ef83e92..2dd8120f1 100644
--- a/drivers/net/ice/ice_ethdev.c
+++ b/drivers/net/ice/ice_ethdev.c
@@ -47,6 +47,11 @@  struct proto_xtr_ol_flag {
 	bool required;
 };
 
+struct ice_hash_flow_cfg {
+	bool simple_xor;
+	struct ice_rss_cfg rss_cfg;
+};
+
 static struct proto_xtr_ol_flag ice_proto_xtr_ol_flag_params[] = {
 	[PROTO_XTR_VLAN] = {
 		.param = { .name = "ice_dynflag_proto_xtr_vlan" },
@@ -2464,6 +2469,45 @@  ice_dev_configure(struct rte_eth_dev *dev)
 	return 0;
 }
 
+static int
+ice_rss_restore(struct rte_eth_dev *dev)
+{
+	struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
+	struct ice_hw *hw = ICE_PF_TO_HW(pf);
+	struct ice_vsi *vsi = pf->main_vsi;
+	struct rte_flow *p_flow;
+	struct ice_hash_flow_cfg *filter_ptr;
+	struct ice_flow_engine *engine;
+	uint32_t reg;
+	int ret;
+
+	TAILQ_FOREACH(p_flow, &pf->flow_list, node) {
+		engine = p_flow->engine;
+		if (engine->type == ICE_FLOW_ENGINE_HASH) {
+			filter_ptr = (struct ice_hash_flow_cfg *)p_flow->rule;
+			/* Enable registers for simple_xor hash function. */
+			if (filter_ptr->simple_xor == 1) {
+				reg = ICE_READ_REG(hw,
+					VSIQF_HASH_CTL(vsi->vsi_id));
+				reg = (reg & (~VSIQF_HASH_CTL_HASH_SCHEME_M)) |
+					(2 << VSIQF_HASH_CTL_HASH_SCHEME_S);
+				ICE_WRITE_REG(hw,
+					VSIQF_HASH_CTL(vsi->vsi_id), reg);
+			} else {
+				ret = ice_add_rss_cfg(hw, vsi->idx,
+					filter_ptr->rss_cfg.hashed_flds,
+					filter_ptr->rss_cfg.packet_hdr,
+					filter_ptr->rss_cfg.symm);
+				if (ret)
+					PMD_DRV_LOG(ERR,
+						"%s restore rss fail %d",
+						__func__, ret);
+			}
+		}
+	}
+	return 0;
+}
+
 static int ice_init_rss(struct ice_pf *pf)
 {
 	struct ice_hw *hw = ICE_PF_TO_HW(pf);
@@ -2591,6 +2635,9 @@  static int ice_init_rss(struct ice_pf *pf)
 		PMD_DRV_LOG(ERR, "%s PPPoE/PPPoD_SessionID rss flow fail %d",
 				__func__, ret);
 
+	/* restore RSS configuration */
+	ice_rss_restore(dev);
+
 	return 0;
 }