dev.dpdk.org archive mirror
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] net/ice: clear the HW tables when close device
@ 2019-11-07  9:59 Qi Zhang
  2019-11-08  6:17 ` Ye Xiaolong
  2019-11-08  7:10 ` Ye Xiaolong
  0 siblings, 2 replies; 7+ messages in thread
From: Qi Zhang @ 2019-11-07  9:59 UTC (permalink / raw)
  To: qiming.yang; +Cc: dev, xiaolong.ye, Qi Zhang

Clear the HW tables during dev_close. Otherwise HW tables will not
be initialized correctly after device reset.

Fixes: a4c8c48fe3f4 ("net/ice: load OS default package")

Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
---
 drivers/net/ice/base/ice_flex_pipe.c | 55 ++++++++++++++++++++++++++++++++++++
 drivers/net/ice/base/ice_flex_pipe.h |  1 +
 drivers/net/ice/ice_ethdev.c         |  1 +
 3 files changed, 57 insertions(+)

diff --git a/drivers/net/ice/base/ice_flex_pipe.c b/drivers/net/ice/base/ice_flex_pipe.c
index dd098f529..b816ca67f 100644
--- a/drivers/net/ice/base/ice_flex_pipe.c
+++ b/drivers/net/ice/base/ice_flex_pipe.c
@@ -3618,6 +3618,61 @@ static void ice_init_flow_profs(struct ice_hw *hw, u8 blk_idx)
 }
 
 /**
+ * ice_clear_hw_tbls - clear HW tables and flow profiles
+ * @hw: pointer to the hardware structure
+ */
+void ice_clear_hw_tbls(struct ice_hw *hw)
+{
+	u8 i;
+
+	for (i = 0; i < ICE_BLK_COUNT; i++) {
+		struct ice_prof_redir *prof_redir = &hw->blk[i].prof_redir;
+		struct ice_prof_tcam *prof = &hw->blk[i].prof;
+		struct ice_xlt1 *xlt1 = &hw->blk[i].xlt1;
+		struct ice_xlt2 *xlt2 = &hw->blk[i].xlt2;
+		struct ice_es *es = &hw->blk[i].es;
+
+		if (hw->blk[i].is_list_init) {
+			ice_free_prof_map(hw, i);
+			ice_free_flow_profs(hw, i);
+		}
+
+		ice_free_vsig_tbl(hw, (enum ice_block)i);
+
+		ice_memset(xlt1->ptypes, 0, xlt1->count * sizeof(*xlt1->ptypes),
+			   ICE_NONDMA_MEM);
+		ice_memset(xlt1->ptg_tbl, 0,
+			   ICE_MAX_PTGS * sizeof(*xlt1->ptg_tbl),
+			   ICE_NONDMA_MEM);
+		ice_memset(xlt1->t, 0, xlt1->count * sizeof(*xlt1->t),
+			   ICE_NONDMA_MEM);
+
+		ice_memset(xlt2->vsis, 0, xlt2->count * sizeof(*xlt2->vsis),
+			   ICE_NONDMA_MEM);
+		ice_memset(xlt2->vsig_tbl, 0,
+			   xlt2->count * sizeof(*xlt2->vsig_tbl),
+			   ICE_NONDMA_MEM);
+		ice_memset(xlt2->t, 0, xlt2->count * sizeof(*xlt2->t),
+			   ICE_NONDMA_MEM);
+
+		ice_memset(prof->t, 0, prof->count * sizeof(*prof->t),
+			   ICE_NONDMA_MEM);
+		ice_memset(prof_redir->t, 0,
+			   prof_redir->count * sizeof(*prof_redir->t),
+			   ICE_NONDMA_MEM);
+
+		ice_memset(es->t, 0, es->count * sizeof(*es->t),
+			   ICE_NONDMA_MEM);
+		ice_memset(es->ref_count, 0, es->count * sizeof(*es->ref_count),
+			   ICE_NONDMA_MEM);
+		ice_memset(es->written, 0, es->count * sizeof(*es->written),
+			   ICE_NONDMA_MEM);
+		ice_memset(es->mask_ena, 0, es->count * sizeof(*es->mask_ena),
+			   ICE_NONDMA_MEM);
+	}
+}
+
+/**
  * ice_init_hw_tbls - init hardware table memory
  * @hw: pointer to the hardware structure
  */
diff --git a/drivers/net/ice/base/ice_flex_pipe.h b/drivers/net/ice/base/ice_flex_pipe.h
index ee606af15..fa72e386d 100644
--- a/drivers/net/ice/base/ice_flex_pipe.h
+++ b/drivers/net/ice/base/ice_flex_pipe.h
@@ -71,6 +71,7 @@ ice_copy_and_init_pkg(struct ice_hw *hw, const u8 *buf, u32 len);
 enum ice_status ice_init_hw_tbls(struct ice_hw *hw);
 void ice_free_seg(struct ice_hw *hw);
 void ice_fill_blk_tbls(struct ice_hw *hw);
+void ice_clear_hw_tbls(struct ice_hw *hw);
 void ice_free_hw_tbls(struct ice_hw *hw);
 enum ice_status
 ice_rem_prof(struct ice_hw *hw, enum ice_block blk, u64 id);
diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c
index d81eb5eeb..0b439cc0b 100644
--- a/drivers/net/ice/ice_ethdev.c
+++ b/drivers/net/ice/ice_ethdev.c
@@ -2322,6 +2322,7 @@ ice_dev_close(struct rte_eth_dev *dev)
 	rte_free(hw->port_info);
 	hw->port_info = NULL;
 	ice_shutdown_all_ctrlq(hw);
+	ice_clear_hw_tbls(hw);
 	rte_free(pf->proto_xtr);
 	pf->proto_xtr = NULL;
 
-- 
2.13.6


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

* Re: [dpdk-dev] [PATCH] net/ice: clear the HW tables when close device
  2019-11-07  9:59 [dpdk-dev] [PATCH] net/ice: clear the HW tables when close device Qi Zhang
@ 2019-11-08  6:17 ` Ye Xiaolong
  2019-11-08  6:39   ` Ye Xiaolong
  2019-11-08  6:51   ` Zhang, Qi Z
  2019-11-08  7:10 ` Ye Xiaolong
  1 sibling, 2 replies; 7+ messages in thread
From: Ye Xiaolong @ 2019-11-08  6:17 UTC (permalink / raw)
  To: Qi Zhang; +Cc: qiming.yang, dev

Hi, Qi

On 11/07, Qi Zhang wrote:
>Clear the HW tables during dev_close. Otherwise HW tables will not
>be initialized correctly after device reset.
>
>Fixes: a4c8c48fe3f4 ("net/ice: load OS default package")
>
>Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
>---
> drivers/net/ice/base/ice_flex_pipe.c | 55 ++++++++++++++++++++++++++++++++++++
> drivers/net/ice/base/ice_flex_pipe.h |  1 +
> drivers/net/ice/ice_ethdev.c         |  1 +
> 3 files changed, 57 insertions(+)
>
>diff --git a/drivers/net/ice/base/ice_flex_pipe.c b/drivers/net/ice/base/ice_flex_pipe.c
>index dd098f529..b816ca67f 100644
>--- a/drivers/net/ice/base/ice_flex_pipe.c
>+++ b/drivers/net/ice/base/ice_flex_pipe.c
>@@ -3618,6 +3618,61 @@ static void ice_init_flow_profs(struct ice_hw *hw, u8 blk_idx)
> }
> 
> /**
>+ * ice_clear_hw_tbls - clear HW tables and flow profiles
>+ * @hw: pointer to the hardware structure
>+ */
>+void ice_clear_hw_tbls(struct ice_hw *hw)

What is the difference between this one and existing ice_free_hw_tbls, can
we use ice_free_hw_tbls directly?

Thanks,
Xiaolong

>+{
>+	u8 i;
>+
>+	for (i = 0; i < ICE_BLK_COUNT; i++) {
>+		struct ice_prof_redir *prof_redir = &hw->blk[i].prof_redir;
>+		struct ice_prof_tcam *prof = &hw->blk[i].prof;
>+		struct ice_xlt1 *xlt1 = &hw->blk[i].xlt1;
>+		struct ice_xlt2 *xlt2 = &hw->blk[i].xlt2;
>+		struct ice_es *es = &hw->blk[i].es;
>+
>+		if (hw->blk[i].is_list_init) {
>+			ice_free_prof_map(hw, i);
>+			ice_free_flow_profs(hw, i);
>+		}
>+
>+		ice_free_vsig_tbl(hw, (enum ice_block)i);
>+
>+		ice_memset(xlt1->ptypes, 0, xlt1->count * sizeof(*xlt1->ptypes),
>+			   ICE_NONDMA_MEM);
>+		ice_memset(xlt1->ptg_tbl, 0,
>+			   ICE_MAX_PTGS * sizeof(*xlt1->ptg_tbl),
>+			   ICE_NONDMA_MEM);
>+		ice_memset(xlt1->t, 0, xlt1->count * sizeof(*xlt1->t),
>+			   ICE_NONDMA_MEM);
>+
>+		ice_memset(xlt2->vsis, 0, xlt2->count * sizeof(*xlt2->vsis),
>+			   ICE_NONDMA_MEM);
>+		ice_memset(xlt2->vsig_tbl, 0,
>+			   xlt2->count * sizeof(*xlt2->vsig_tbl),
>+			   ICE_NONDMA_MEM);
>+		ice_memset(xlt2->t, 0, xlt2->count * sizeof(*xlt2->t),
>+			   ICE_NONDMA_MEM);
>+
>+		ice_memset(prof->t, 0, prof->count * sizeof(*prof->t),
>+			   ICE_NONDMA_MEM);
>+		ice_memset(prof_redir->t, 0,
>+			   prof_redir->count * sizeof(*prof_redir->t),
>+			   ICE_NONDMA_MEM);
>+
>+		ice_memset(es->t, 0, es->count * sizeof(*es->t),
>+			   ICE_NONDMA_MEM);
>+		ice_memset(es->ref_count, 0, es->count * sizeof(*es->ref_count),
>+			   ICE_NONDMA_MEM);
>+		ice_memset(es->written, 0, es->count * sizeof(*es->written),
>+			   ICE_NONDMA_MEM);
>+		ice_memset(es->mask_ena, 0, es->count * sizeof(*es->mask_ena),
>+			   ICE_NONDMA_MEM);
>+	}
>+}
>+
>+/**
>  * ice_init_hw_tbls - init hardware table memory
>  * @hw: pointer to the hardware structure
>  */
>diff --git a/drivers/net/ice/base/ice_flex_pipe.h b/drivers/net/ice/base/ice_flex_pipe.h
>index ee606af15..fa72e386d 100644
>--- a/drivers/net/ice/base/ice_flex_pipe.h
>+++ b/drivers/net/ice/base/ice_flex_pipe.h
>@@ -71,6 +71,7 @@ ice_copy_and_init_pkg(struct ice_hw *hw, const u8 *buf, u32 len);
> enum ice_status ice_init_hw_tbls(struct ice_hw *hw);
> void ice_free_seg(struct ice_hw *hw);
> void ice_fill_blk_tbls(struct ice_hw *hw);
>+void ice_clear_hw_tbls(struct ice_hw *hw);
> void ice_free_hw_tbls(struct ice_hw *hw);
> enum ice_status
> ice_rem_prof(struct ice_hw *hw, enum ice_block blk, u64 id);
>diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c
>index d81eb5eeb..0b439cc0b 100644
>--- a/drivers/net/ice/ice_ethdev.c
>+++ b/drivers/net/ice/ice_ethdev.c
>@@ -2322,6 +2322,7 @@ ice_dev_close(struct rte_eth_dev *dev)
> 	rte_free(hw->port_info);
> 	hw->port_info = NULL;
> 	ice_shutdown_all_ctrlq(hw);
>+	ice_clear_hw_tbls(hw);
> 	rte_free(pf->proto_xtr);
> 	pf->proto_xtr = NULL;
> 
>-- 
>2.13.6
>

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

* Re: [dpdk-dev] [PATCH] net/ice: clear the HW tables when close device
  2019-11-08  6:17 ` Ye Xiaolong
@ 2019-11-08  6:39   ` Ye Xiaolong
  2019-11-08  6:51   ` Zhang, Qi Z
  1 sibling, 0 replies; 7+ messages in thread
From: Ye Xiaolong @ 2019-11-08  6:39 UTC (permalink / raw)
  To: Qi Zhang; +Cc: qiming.yang, dev

On 11/08, Ye Xiaolong wrote:
>Hi, Qi
>
>On 11/07, Qi Zhang wrote:
>>Clear the HW tables during dev_close. Otherwise HW tables will not
>>be initialized correctly after device reset.
>>
>>Fixes: a4c8c48fe3f4 ("net/ice: load OS default package")
>>
>>Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
>>---
>> drivers/net/ice/base/ice_flex_pipe.c | 55 ++++++++++++++++++++++++++++++++++++
>> drivers/net/ice/base/ice_flex_pipe.h |  1 +
>> drivers/net/ice/ice_ethdev.c         |  1 +
>> 3 files changed, 57 insertions(+)
>>
>>diff --git a/drivers/net/ice/base/ice_flex_pipe.c b/drivers/net/ice/base/ice_flex_pipe.c
>>index dd098f529..b816ca67f 100644
>>--- a/drivers/net/ice/base/ice_flex_pipe.c
>>+++ b/drivers/net/ice/base/ice_flex_pipe.c
>>@@ -3618,6 +3618,61 @@ static void ice_init_flow_profs(struct ice_hw *hw, u8 blk_idx)
>> }
>> 
>> /**
>>+ * ice_clear_hw_tbls - clear HW tables and flow profiles
>>+ * @hw: pointer to the hardware structure
>>+ */
>>+void ice_clear_hw_tbls(struct ice_hw *hw)
>
>What is the difference between this one and existing ice_free_hw_tbls, can
>we use ice_free_hw_tbls directly?

Other thing I notice is that we've called ice_init_hw in ice_dev_init, but 
missed ice_deinit_hw (which will unroll initialization operations done by ice_init_hw)
in ice_dev_uninit, is it done intentionally?

Thanks,
Xiaolong

>
>Thanks,
>Xiaolong
>
>>+{
>>+	u8 i;
>>+
>>+	for (i = 0; i < ICE_BLK_COUNT; i++) {
>>+		struct ice_prof_redir *prof_redir = &hw->blk[i].prof_redir;
>>+		struct ice_prof_tcam *prof = &hw->blk[i].prof;
>>+		struct ice_xlt1 *xlt1 = &hw->blk[i].xlt1;
>>+		struct ice_xlt2 *xlt2 = &hw->blk[i].xlt2;
>>+		struct ice_es *es = &hw->blk[i].es;
>>+
>>+		if (hw->blk[i].is_list_init) {
>>+			ice_free_prof_map(hw, i);
>>+			ice_free_flow_profs(hw, i);
>>+		}
>>+
>>+		ice_free_vsig_tbl(hw, (enum ice_block)i);
>>+
>>+		ice_memset(xlt1->ptypes, 0, xlt1->count * sizeof(*xlt1->ptypes),
>>+			   ICE_NONDMA_MEM);
>>+		ice_memset(xlt1->ptg_tbl, 0,
>>+			   ICE_MAX_PTGS * sizeof(*xlt1->ptg_tbl),
>>+			   ICE_NONDMA_MEM);
>>+		ice_memset(xlt1->t, 0, xlt1->count * sizeof(*xlt1->t),
>>+			   ICE_NONDMA_MEM);
>>+
>>+		ice_memset(xlt2->vsis, 0, xlt2->count * sizeof(*xlt2->vsis),
>>+			   ICE_NONDMA_MEM);
>>+		ice_memset(xlt2->vsig_tbl, 0,
>>+			   xlt2->count * sizeof(*xlt2->vsig_tbl),
>>+			   ICE_NONDMA_MEM);
>>+		ice_memset(xlt2->t, 0, xlt2->count * sizeof(*xlt2->t),
>>+			   ICE_NONDMA_MEM);
>>+
>>+		ice_memset(prof->t, 0, prof->count * sizeof(*prof->t),
>>+			   ICE_NONDMA_MEM);
>>+		ice_memset(prof_redir->t, 0,
>>+			   prof_redir->count * sizeof(*prof_redir->t),
>>+			   ICE_NONDMA_MEM);
>>+
>>+		ice_memset(es->t, 0, es->count * sizeof(*es->t),
>>+			   ICE_NONDMA_MEM);
>>+		ice_memset(es->ref_count, 0, es->count * sizeof(*es->ref_count),
>>+			   ICE_NONDMA_MEM);
>>+		ice_memset(es->written, 0, es->count * sizeof(*es->written),
>>+			   ICE_NONDMA_MEM);
>>+		ice_memset(es->mask_ena, 0, es->count * sizeof(*es->mask_ena),
>>+			   ICE_NONDMA_MEM);
>>+	}
>>+}
>>+
>>+/**
>>  * ice_init_hw_tbls - init hardware table memory
>>  * @hw: pointer to the hardware structure
>>  */
>>diff --git a/drivers/net/ice/base/ice_flex_pipe.h b/drivers/net/ice/base/ice_flex_pipe.h
>>index ee606af15..fa72e386d 100644
>>--- a/drivers/net/ice/base/ice_flex_pipe.h
>>+++ b/drivers/net/ice/base/ice_flex_pipe.h
>>@@ -71,6 +71,7 @@ ice_copy_and_init_pkg(struct ice_hw *hw, const u8 *buf, u32 len);
>> enum ice_status ice_init_hw_tbls(struct ice_hw *hw);
>> void ice_free_seg(struct ice_hw *hw);
>> void ice_fill_blk_tbls(struct ice_hw *hw);
>>+void ice_clear_hw_tbls(struct ice_hw *hw);
>> void ice_free_hw_tbls(struct ice_hw *hw);
>> enum ice_status
>> ice_rem_prof(struct ice_hw *hw, enum ice_block blk, u64 id);
>>diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c
>>index d81eb5eeb..0b439cc0b 100644
>>--- a/drivers/net/ice/ice_ethdev.c
>>+++ b/drivers/net/ice/ice_ethdev.c
>>@@ -2322,6 +2322,7 @@ ice_dev_close(struct rte_eth_dev *dev)
>> 	rte_free(hw->port_info);
>> 	hw->port_info = NULL;
>> 	ice_shutdown_all_ctrlq(hw);
>>+	ice_clear_hw_tbls(hw);
>> 	rte_free(pf->proto_xtr);
>> 	pf->proto_xtr = NULL;
>> 
>>-- 
>>2.13.6
>>

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

* Re: [dpdk-dev] [PATCH] net/ice: clear the HW tables when close device
  2019-11-08  6:17 ` Ye Xiaolong
  2019-11-08  6:39   ` Ye Xiaolong
@ 2019-11-08  6:51   ` Zhang, Qi Z
  2019-11-08  9:24     ` Zhang, Qi Z
  1 sibling, 1 reply; 7+ messages in thread
From: Zhang, Qi Z @ 2019-11-08  6:51 UTC (permalink / raw)
  To: Ye, Xiaolong; +Cc: Yang, Qiming, dev



> -----Original Message-----
> From: Ye, Xiaolong <xiaolong.ye@intel.com>
> Sent: Friday, November 8, 2019 2:18 PM
> To: Zhang, Qi Z <qi.z.zhang@intel.com>
> Cc: Yang, Qiming <qiming.yang@intel.com>; dev@dpdk.org
> Subject: Re: [PATCH] net/ice: clear the HW tables when close device
> 
> Hi, Qi
> 
> On 11/07, Qi Zhang wrote:
> >Clear the HW tables during dev_close. Otherwise HW tables will not be
> >initialized correctly after device reset.
> >
> >Fixes: a4c8c48fe3f4 ("net/ice: load OS default package")
> >
> >Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
> >---
> > drivers/net/ice/base/ice_flex_pipe.c | 55
> >++++++++++++++++++++++++++++++++++++
> > drivers/net/ice/base/ice_flex_pipe.h |  1 +
> > drivers/net/ice/ice_ethdev.c         |  1 +
> > 3 files changed, 57 insertions(+)
> >
> >diff --git a/drivers/net/ice/base/ice_flex_pipe.c
> >b/drivers/net/ice/base/ice_flex_pipe.c
> >index dd098f529..b816ca67f 100644
> >--- a/drivers/net/ice/base/ice_flex_pipe.c
> >+++ b/drivers/net/ice/base/ice_flex_pipe.c
> >@@ -3618,6 +3618,61 @@ static void ice_init_flow_profs(struct ice_hw
> >*hw, u8 blk_idx)  }
> >
> > /**
> >+ * ice_clear_hw_tbls - clear HW tables and flow profiles
> >+ * @hw: pointer to the hardware structure  */ void
> >+ice_clear_hw_tbls(struct ice_hw *hw)
> 
> What is the difference between this one and existing ice_free_hw_tbls, can we
> use ice_free_hw_tbls directly?

The ice_clear_hw_tbls is designed for device reset scenario, it reset all the table, but not do free, so during next ice_init_hw_tbls, all the allocation steps can be skipped.
Though, I guess ice_free_hw_tbls may also works, but Kernel driver use ice_clear_hw_tbls during reset, DPDK would better just follow the same implementation to avoid unnecessary evaluation effort.

Regards
Qi


> 
> Thanks,
> Xiaolong
> 
> >+{
> >+	u8 i;
> >+
> >+	for (i = 0; i < ICE_BLK_COUNT; i++) {
> >+		struct ice_prof_redir *prof_redir = &hw->blk[i].prof_redir;
> >+		struct ice_prof_tcam *prof = &hw->blk[i].prof;
> >+		struct ice_xlt1 *xlt1 = &hw->blk[i].xlt1;
> >+		struct ice_xlt2 *xlt2 = &hw->blk[i].xlt2;
> >+		struct ice_es *es = &hw->blk[i].es;
> >+
> >+		if (hw->blk[i].is_list_init) {
> >+			ice_free_prof_map(hw, i);
> >+			ice_free_flow_profs(hw, i);
> >+		}
> >+
> >+		ice_free_vsig_tbl(hw, (enum ice_block)i);
> >+
> >+		ice_memset(xlt1->ptypes, 0, xlt1->count * sizeof(*xlt1->ptypes),
> >+			   ICE_NONDMA_MEM);
> >+		ice_memset(xlt1->ptg_tbl, 0,
> >+			   ICE_MAX_PTGS * sizeof(*xlt1->ptg_tbl),
> >+			   ICE_NONDMA_MEM);
> >+		ice_memset(xlt1->t, 0, xlt1->count * sizeof(*xlt1->t),
> >+			   ICE_NONDMA_MEM);
> >+
> >+		ice_memset(xlt2->vsis, 0, xlt2->count * sizeof(*xlt2->vsis),
> >+			   ICE_NONDMA_MEM);
> >+		ice_memset(xlt2->vsig_tbl, 0,
> >+			   xlt2->count * sizeof(*xlt2->vsig_tbl),
> >+			   ICE_NONDMA_MEM);
> >+		ice_memset(xlt2->t, 0, xlt2->count * sizeof(*xlt2->t),
> >+			   ICE_NONDMA_MEM);
> >+
> >+		ice_memset(prof->t, 0, prof->count * sizeof(*prof->t),
> >+			   ICE_NONDMA_MEM);
> >+		ice_memset(prof_redir->t, 0,
> >+			   prof_redir->count * sizeof(*prof_redir->t),
> >+			   ICE_NONDMA_MEM);
> >+
> >+		ice_memset(es->t, 0, es->count * sizeof(*es->t),
> >+			   ICE_NONDMA_MEM);
> >+		ice_memset(es->ref_count, 0, es->count * sizeof(*es->ref_count),
> >+			   ICE_NONDMA_MEM);
> >+		ice_memset(es->written, 0, es->count * sizeof(*es->written),
> >+			   ICE_NONDMA_MEM);
> >+		ice_memset(es->mask_ena, 0, es->count * sizeof(*es->mask_ena),
> >+			   ICE_NONDMA_MEM);
> >+	}
> >+}
> >+
> >+/**
> >  * ice_init_hw_tbls - init hardware table memory
> >  * @hw: pointer to the hardware structure
> >  */
> >diff --git a/drivers/net/ice/base/ice_flex_pipe.h
> >b/drivers/net/ice/base/ice_flex_pipe.h
> >index ee606af15..fa72e386d 100644
> >--- a/drivers/net/ice/base/ice_flex_pipe.h
> >+++ b/drivers/net/ice/base/ice_flex_pipe.h
> >@@ -71,6 +71,7 @@ ice_copy_and_init_pkg(struct ice_hw *hw, const u8
> >*buf, u32 len);  enum ice_status ice_init_hw_tbls(struct ice_hw *hw);
> >void ice_free_seg(struct ice_hw *hw);  void ice_fill_blk_tbls(struct
> >ice_hw *hw);
> >+void ice_clear_hw_tbls(struct ice_hw *hw);
> > void ice_free_hw_tbls(struct ice_hw *hw);  enum ice_status
> >ice_rem_prof(struct ice_hw *hw, enum ice_block blk, u64 id); diff --git
> >a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c index
> >d81eb5eeb..0b439cc0b 100644
> >--- a/drivers/net/ice/ice_ethdev.c
> >+++ b/drivers/net/ice/ice_ethdev.c
> >@@ -2322,6 +2322,7 @@ ice_dev_close(struct rte_eth_dev *dev)
> > 	rte_free(hw->port_info);
> > 	hw->port_info = NULL;
> > 	ice_shutdown_all_ctrlq(hw);
> >+	ice_clear_hw_tbls(hw);
> > 	rte_free(pf->proto_xtr);
> > 	pf->proto_xtr = NULL;
> >
> >--
> >2.13.6
> >

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

* Re: [dpdk-dev] [PATCH] net/ice: clear the HW tables when close device
  2019-11-07  9:59 [dpdk-dev] [PATCH] net/ice: clear the HW tables when close device Qi Zhang
  2019-11-08  6:17 ` Ye Xiaolong
@ 2019-11-08  7:10 ` Ye Xiaolong
  2019-11-08 15:16   ` Ye Xiaolong
  1 sibling, 1 reply; 7+ messages in thread
From: Ye Xiaolong @ 2019-11-08  7:10 UTC (permalink / raw)
  To: Qi Zhang; +Cc: qiming.yang, dev

On 11/07, Qi Zhang wrote:
>Clear the HW tables during dev_close. Otherwise HW tables will not
>be initialized correctly after device reset.
>
>Fixes: a4c8c48fe3f4 ("net/ice: load OS default package")
>
>Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
>---
> drivers/net/ice/base/ice_flex_pipe.c | 55 ++++++++++++++++++++++++++++++++++++
> drivers/net/ice/base/ice_flex_pipe.h |  1 +
> drivers/net/ice/ice_ethdev.c         |  1 +
> 3 files changed, 57 insertions(+)
>
>diff --git a/drivers/net/ice/base/ice_flex_pipe.c b/drivers/net/ice/base/ice_flex_pipe.c
>index dd098f529..b816ca67f 100644
>--- a/drivers/net/ice/base/ice_flex_pipe.c
>+++ b/drivers/net/ice/base/ice_flex_pipe.c
>@@ -3618,6 +3618,61 @@ static void ice_init_flow_profs(struct ice_hw *hw, u8 blk_idx)
> }
> 
> /**
>+ * ice_clear_hw_tbls - clear HW tables and flow profiles
>+ * @hw: pointer to the hardware structure
>+ */
>+void ice_clear_hw_tbls(struct ice_hw *hw)
>+{
>+	u8 i;
>+
>+	for (i = 0; i < ICE_BLK_COUNT; i++) {
>+		struct ice_prof_redir *prof_redir = &hw->blk[i].prof_redir;
>+		struct ice_prof_tcam *prof = &hw->blk[i].prof;
>+		struct ice_xlt1 *xlt1 = &hw->blk[i].xlt1;
>+		struct ice_xlt2 *xlt2 = &hw->blk[i].xlt2;
>+		struct ice_es *es = &hw->blk[i].es;
>+
>+		if (hw->blk[i].is_list_init) {
>+			ice_free_prof_map(hw, i);
>+			ice_free_flow_profs(hw, i);
>+		}
>+
>+		ice_free_vsig_tbl(hw, (enum ice_block)i);
>+
>+		ice_memset(xlt1->ptypes, 0, xlt1->count * sizeof(*xlt1->ptypes),
>+			   ICE_NONDMA_MEM);
>+		ice_memset(xlt1->ptg_tbl, 0,
>+			   ICE_MAX_PTGS * sizeof(*xlt1->ptg_tbl),
>+			   ICE_NONDMA_MEM);
>+		ice_memset(xlt1->t, 0, xlt1->count * sizeof(*xlt1->t),
>+			   ICE_NONDMA_MEM);
>+
>+		ice_memset(xlt2->vsis, 0, xlt2->count * sizeof(*xlt2->vsis),
>+			   ICE_NONDMA_MEM);
>+		ice_memset(xlt2->vsig_tbl, 0,
>+			   xlt2->count * sizeof(*xlt2->vsig_tbl),
>+			   ICE_NONDMA_MEM);
>+		ice_memset(xlt2->t, 0, xlt2->count * sizeof(*xlt2->t),
>+			   ICE_NONDMA_MEM);
>+
>+		ice_memset(prof->t, 0, prof->count * sizeof(*prof->t),
>+			   ICE_NONDMA_MEM);
>+		ice_memset(prof_redir->t, 0,
>+			   prof_redir->count * sizeof(*prof_redir->t),
>+			   ICE_NONDMA_MEM);
>+
>+		ice_memset(es->t, 0, es->count * sizeof(*es->t),
>+			   ICE_NONDMA_MEM);
>+		ice_memset(es->ref_count, 0, es->count * sizeof(*es->ref_count),
>+			   ICE_NONDMA_MEM);
>+		ice_memset(es->written, 0, es->count * sizeof(*es->written),
>+			   ICE_NONDMA_MEM);
>+		ice_memset(es->mask_ena, 0, es->count * sizeof(*es->mask_ena),
>+			   ICE_NONDMA_MEM);
>+	}
>+}
>+
>+/**
>  * ice_init_hw_tbls - init hardware table memory
>  * @hw: pointer to the hardware structure
>  */
>diff --git a/drivers/net/ice/base/ice_flex_pipe.h b/drivers/net/ice/base/ice_flex_pipe.h
>index ee606af15..fa72e386d 100644
>--- a/drivers/net/ice/base/ice_flex_pipe.h
>+++ b/drivers/net/ice/base/ice_flex_pipe.h
>@@ -71,6 +71,7 @@ ice_copy_and_init_pkg(struct ice_hw *hw, const u8 *buf, u32 len);
> enum ice_status ice_init_hw_tbls(struct ice_hw *hw);
> void ice_free_seg(struct ice_hw *hw);
> void ice_fill_blk_tbls(struct ice_hw *hw);
>+void ice_clear_hw_tbls(struct ice_hw *hw);
> void ice_free_hw_tbls(struct ice_hw *hw);
> enum ice_status
> ice_rem_prof(struct ice_hw *hw, enum ice_block blk, u64 id);
>diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c
>index d81eb5eeb..0b439cc0b 100644
>--- a/drivers/net/ice/ice_ethdev.c
>+++ b/drivers/net/ice/ice_ethdev.c
>@@ -2322,6 +2322,7 @@ ice_dev_close(struct rte_eth_dev *dev)
> 	rte_free(hw->port_info);
> 	hw->port_info = NULL;
> 	ice_shutdown_all_ctrlq(hw);
>+	ice_clear_hw_tbls(hw);
> 	rte_free(pf->proto_xtr);
> 	pf->proto_xtr = NULL;
> 
>-- 
>2.13.6
>

Acked-by: Xiaolong Ye <xiaolong.ye@intel.com>

Applied to dpdk-next-net-intel. Thanks.

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

* Re: [dpdk-dev] [PATCH] net/ice: clear the HW tables when close device
  2019-11-08  6:51   ` Zhang, Qi Z
@ 2019-11-08  9:24     ` Zhang, Qi Z
  0 siblings, 0 replies; 7+ messages in thread
From: Zhang, Qi Z @ 2019-11-08  9:24 UTC (permalink / raw)
  To: Ye, Xiaolong; +Cc: Yang, Qiming, 'dev@dpdk.org'



> -----Original Message-----
> From: Zhang, Qi Z
> Sent: Friday, November 8, 2019 2:51 PM
> To: Ye, Xiaolong <xiaolong.ye@intel.com>
> Cc: Yang, Qiming <qiming.yang@intel.com>; dev@dpdk.org
> Subject: RE: [PATCH] net/ice: clear the HW tables when close device
> 
> 
> 
> > -----Original Message-----
> > From: Ye, Xiaolong <xiaolong.ye@intel.com>
> > Sent: Friday, November 8, 2019 2:18 PM
> > To: Zhang, Qi Z <qi.z.zhang@intel.com>
> > Cc: Yang, Qiming <qiming.yang@intel.com>; dev@dpdk.org
> > Subject: Re: [PATCH] net/ice: clear the HW tables when close device
> >
> > Hi, Qi
> >
> > On 11/07, Qi Zhang wrote:
> > >Clear the HW tables during dev_close. Otherwise HW tables will not be
> > >initialized correctly after device reset.
> > >
> > >Fixes: a4c8c48fe3f4 ("net/ice: load OS default package")
> > >
> > >Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
> > >---
> > > drivers/net/ice/base/ice_flex_pipe.c | 55
> > >++++++++++++++++++++++++++++++++++++
> > > drivers/net/ice/base/ice_flex_pipe.h |  1 +
> > > drivers/net/ice/ice_ethdev.c         |  1 +
> > > 3 files changed, 57 insertions(+)
> > >
> > >diff --git a/drivers/net/ice/base/ice_flex_pipe.c
> > >b/drivers/net/ice/base/ice_flex_pipe.c
> > >index dd098f529..b816ca67f 100644
> > >--- a/drivers/net/ice/base/ice_flex_pipe.c
> > >+++ b/drivers/net/ice/base/ice_flex_pipe.c
> > >@@ -3618,6 +3618,61 @@ static void ice_init_flow_profs(struct ice_hw
> > >*hw, u8 blk_idx)  }
> > >
> > > /**
> > >+ * ice_clear_hw_tbls - clear HW tables and flow profiles
> > >+ * @hw: pointer to the hardware structure  */ void
> > >+ice_clear_hw_tbls(struct ice_hw *hw)
> >
> > What is the difference between this one and existing ice_free_hw_tbls,
> > can we use ice_free_hw_tbls directly?
> 
> The ice_clear_hw_tbls is designed for device reset scenario, it reset all the
> table, but not do free, so during next ice_init_hw_tbls, all the allocation steps
> can be skipped.
> Though, I guess ice_free_hw_tbls may also works, but Kernel driver use
> ice_clear_hw_tbls during reset, DPDK would better just follow the same
> implementation to avoid unnecessary evaluation effort.

After second thought, I think we should free the memory in dev_unit.to prevent memory leak.
So ice_free_hw_tbls should be the right fix,  ice_clear_hw_tbls should be used in the case when we try to optimize the dev_reset scenario which does not simply call dev_uninit/dev_init.
I will send a v2 for this.

Thanks
Qi
> 
> Regards
> Qi
> 
> 
> >
> > Thanks,
> > Xiaolong
> >
> > >+{
> > >+	u8 i;
> > >+
> > >+	for (i = 0; i < ICE_BLK_COUNT; i++) {
> > >+		struct ice_prof_redir *prof_redir = &hw->blk[i].prof_redir;
> > >+		struct ice_prof_tcam *prof = &hw->blk[i].prof;
> > >+		struct ice_xlt1 *xlt1 = &hw->blk[i].xlt1;
> > >+		struct ice_xlt2 *xlt2 = &hw->blk[i].xlt2;
> > >+		struct ice_es *es = &hw->blk[i].es;
> > >+
> > >+		if (hw->blk[i].is_list_init) {
> > >+			ice_free_prof_map(hw, i);
> > >+			ice_free_flow_profs(hw, i);
> > >+		}
> > >+
> > >+		ice_free_vsig_tbl(hw, (enum ice_block)i);
> > >+
> > >+		ice_memset(xlt1->ptypes, 0, xlt1->count * sizeof(*xlt1->ptypes),
> > >+			   ICE_NONDMA_MEM);
> > >+		ice_memset(xlt1->ptg_tbl, 0,
> > >+			   ICE_MAX_PTGS * sizeof(*xlt1->ptg_tbl),
> > >+			   ICE_NONDMA_MEM);
> > >+		ice_memset(xlt1->t, 0, xlt1->count * sizeof(*xlt1->t),
> > >+			   ICE_NONDMA_MEM);
> > >+
> > >+		ice_memset(xlt2->vsis, 0, xlt2->count * sizeof(*xlt2->vsis),
> > >+			   ICE_NONDMA_MEM);
> > >+		ice_memset(xlt2->vsig_tbl, 0,
> > >+			   xlt2->count * sizeof(*xlt2->vsig_tbl),
> > >+			   ICE_NONDMA_MEM);
> > >+		ice_memset(xlt2->t, 0, xlt2->count * sizeof(*xlt2->t),
> > >+			   ICE_NONDMA_MEM);
> > >+
> > >+		ice_memset(prof->t, 0, prof->count * sizeof(*prof->t),
> > >+			   ICE_NONDMA_MEM);
> > >+		ice_memset(prof_redir->t, 0,
> > >+			   prof_redir->count * sizeof(*prof_redir->t),
> > >+			   ICE_NONDMA_MEM);
> > >+
> > >+		ice_memset(es->t, 0, es->count * sizeof(*es->t),
> > >+			   ICE_NONDMA_MEM);
> > >+		ice_memset(es->ref_count, 0, es->count * sizeof(*es->ref_count),
> > >+			   ICE_NONDMA_MEM);
> > >+		ice_memset(es->written, 0, es->count * sizeof(*es->written),
> > >+			   ICE_NONDMA_MEM);
> > >+		ice_memset(es->mask_ena, 0, es->count * sizeof(*es->mask_ena),
> > >+			   ICE_NONDMA_MEM);
> > >+	}
> > >+}
> > >+
> > >+/**
> > >  * ice_init_hw_tbls - init hardware table memory
> > >  * @hw: pointer to the hardware structure
> > >  */
> > >diff --git a/drivers/net/ice/base/ice_flex_pipe.h
> > >b/drivers/net/ice/base/ice_flex_pipe.h
> > >index ee606af15..fa72e386d 100644
> > >--- a/drivers/net/ice/base/ice_flex_pipe.h
> > >+++ b/drivers/net/ice/base/ice_flex_pipe.h
> > >@@ -71,6 +71,7 @@ ice_copy_and_init_pkg(struct ice_hw *hw, const u8
> > >*buf, u32 len);  enum ice_status ice_init_hw_tbls(struct ice_hw *hw);
> > >void ice_free_seg(struct ice_hw *hw);  void ice_fill_blk_tbls(struct
> > >ice_hw *hw);
> > >+void ice_clear_hw_tbls(struct ice_hw *hw);
> > > void ice_free_hw_tbls(struct ice_hw *hw);  enum ice_status
> > >ice_rem_prof(struct ice_hw *hw, enum ice_block blk, u64 id); diff
> > >--git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c
> > >index d81eb5eeb..0b439cc0b 100644
> > >--- a/drivers/net/ice/ice_ethdev.c
> > >+++ b/drivers/net/ice/ice_ethdev.c
> > >@@ -2322,6 +2322,7 @@ ice_dev_close(struct rte_eth_dev *dev)
> > > 	rte_free(hw->port_info);
> > > 	hw->port_info = NULL;
> > > 	ice_shutdown_all_ctrlq(hw);
> > >+	ice_clear_hw_tbls(hw);
> > > 	rte_free(pf->proto_xtr);
> > > 	pf->proto_xtr = NULL;
> > >
> > >--
> > >2.13.6
> > >

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

* Re: [dpdk-dev] [PATCH] net/ice: clear the HW tables when close device
  2019-11-08  7:10 ` Ye Xiaolong
@ 2019-11-08 15:16   ` Ye Xiaolong
  0 siblings, 0 replies; 7+ messages in thread
From: Ye Xiaolong @ 2019-11-08 15:16 UTC (permalink / raw)
  To: Qi Zhang; +Cc: qiming.yang, dev

Drop this patch from next-net-intel since it is superseded by "nett/ice: free the HW tables when close device"

Thanks,
Xiaolong

On 11/08, Ye Xiaolong wrote:
>On 11/07, Qi Zhang wrote:
>>Clear the HW tables during dev_close. Otherwise HW tables will not
>>be initialized correctly after device reset.
>>
>>Fixes: a4c8c48fe3f4 ("net/ice: load OS default package")
>>
>>Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
>>---
>> drivers/net/ice/base/ice_flex_pipe.c | 55 ++++++++++++++++++++++++++++++++++++
>> drivers/net/ice/base/ice_flex_pipe.h |  1 +
>> drivers/net/ice/ice_ethdev.c         |  1 +
>> 3 files changed, 57 insertions(+)
>>
>>diff --git a/drivers/net/ice/base/ice_flex_pipe.c b/drivers/net/ice/base/ice_flex_pipe.c
>>index dd098f529..b816ca67f 100644
>>--- a/drivers/net/ice/base/ice_flex_pipe.c
>>+++ b/drivers/net/ice/base/ice_flex_pipe.c
>>@@ -3618,6 +3618,61 @@ static void ice_init_flow_profs(struct ice_hw *hw, u8 blk_idx)
>> }
>> 
>> /**
>>+ * ice_clear_hw_tbls - clear HW tables and flow profiles
>>+ * @hw: pointer to the hardware structure
>>+ */
>>+void ice_clear_hw_tbls(struct ice_hw *hw)
>>+{
>>+	u8 i;
>>+
>>+	for (i = 0; i < ICE_BLK_COUNT; i++) {
>>+		struct ice_prof_redir *prof_redir = &hw->blk[i].prof_redir;
>>+		struct ice_prof_tcam *prof = &hw->blk[i].prof;
>>+		struct ice_xlt1 *xlt1 = &hw->blk[i].xlt1;
>>+		struct ice_xlt2 *xlt2 = &hw->blk[i].xlt2;
>>+		struct ice_es *es = &hw->blk[i].es;
>>+
>>+		if (hw->blk[i].is_list_init) {
>>+			ice_free_prof_map(hw, i);
>>+			ice_free_flow_profs(hw, i);
>>+		}
>>+
>>+		ice_free_vsig_tbl(hw, (enum ice_block)i);
>>+
>>+		ice_memset(xlt1->ptypes, 0, xlt1->count * sizeof(*xlt1->ptypes),
>>+			   ICE_NONDMA_MEM);
>>+		ice_memset(xlt1->ptg_tbl, 0,
>>+			   ICE_MAX_PTGS * sizeof(*xlt1->ptg_tbl),
>>+			   ICE_NONDMA_MEM);
>>+		ice_memset(xlt1->t, 0, xlt1->count * sizeof(*xlt1->t),
>>+			   ICE_NONDMA_MEM);
>>+
>>+		ice_memset(xlt2->vsis, 0, xlt2->count * sizeof(*xlt2->vsis),
>>+			   ICE_NONDMA_MEM);
>>+		ice_memset(xlt2->vsig_tbl, 0,
>>+			   xlt2->count * sizeof(*xlt2->vsig_tbl),
>>+			   ICE_NONDMA_MEM);
>>+		ice_memset(xlt2->t, 0, xlt2->count * sizeof(*xlt2->t),
>>+			   ICE_NONDMA_MEM);
>>+
>>+		ice_memset(prof->t, 0, prof->count * sizeof(*prof->t),
>>+			   ICE_NONDMA_MEM);
>>+		ice_memset(prof_redir->t, 0,
>>+			   prof_redir->count * sizeof(*prof_redir->t),
>>+			   ICE_NONDMA_MEM);
>>+
>>+		ice_memset(es->t, 0, es->count * sizeof(*es->t),
>>+			   ICE_NONDMA_MEM);
>>+		ice_memset(es->ref_count, 0, es->count * sizeof(*es->ref_count),
>>+			   ICE_NONDMA_MEM);
>>+		ice_memset(es->written, 0, es->count * sizeof(*es->written),
>>+			   ICE_NONDMA_MEM);
>>+		ice_memset(es->mask_ena, 0, es->count * sizeof(*es->mask_ena),
>>+			   ICE_NONDMA_MEM);
>>+	}
>>+}
>>+
>>+/**
>>  * ice_init_hw_tbls - init hardware table memory
>>  * @hw: pointer to the hardware structure
>>  */
>>diff --git a/drivers/net/ice/base/ice_flex_pipe.h b/drivers/net/ice/base/ice_flex_pipe.h
>>index ee606af15..fa72e386d 100644
>>--- a/drivers/net/ice/base/ice_flex_pipe.h
>>+++ b/drivers/net/ice/base/ice_flex_pipe.h
>>@@ -71,6 +71,7 @@ ice_copy_and_init_pkg(struct ice_hw *hw, const u8 *buf, u32 len);
>> enum ice_status ice_init_hw_tbls(struct ice_hw *hw);
>> void ice_free_seg(struct ice_hw *hw);
>> void ice_fill_blk_tbls(struct ice_hw *hw);
>>+void ice_clear_hw_tbls(struct ice_hw *hw);
>> void ice_free_hw_tbls(struct ice_hw *hw);
>> enum ice_status
>> ice_rem_prof(struct ice_hw *hw, enum ice_block blk, u64 id);
>>diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c
>>index d81eb5eeb..0b439cc0b 100644
>>--- a/drivers/net/ice/ice_ethdev.c
>>+++ b/drivers/net/ice/ice_ethdev.c
>>@@ -2322,6 +2322,7 @@ ice_dev_close(struct rte_eth_dev *dev)
>> 	rte_free(hw->port_info);
>> 	hw->port_info = NULL;
>> 	ice_shutdown_all_ctrlq(hw);
>>+	ice_clear_hw_tbls(hw);
>> 	rte_free(pf->proto_xtr);
>> 	pf->proto_xtr = NULL;
>> 
>>-- 
>>2.13.6
>>
>
>Acked-by: Xiaolong Ye <xiaolong.ye@intel.com>
>
>Applied to dpdk-next-net-intel. Thanks.

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

end of thread, other threads:[~2019-11-08 15:20 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-07  9:59 [dpdk-dev] [PATCH] net/ice: clear the HW tables when close device Qi Zhang
2019-11-08  6:17 ` Ye Xiaolong
2019-11-08  6:39   ` Ye Xiaolong
2019-11-08  6:51   ` Zhang, Qi Z
2019-11-08  9:24     ` Zhang, Qi Z
2019-11-08  7:10 ` Ye Xiaolong
2019-11-08 15:16   ` Ye Xiaolong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).