net/ixgbe: fix fdirctrl register setting
PATCH 1/1 net/ixgbe: fix fdirctrl register setting
From: YU DAPENG <[email protected]>
The function ixgbe_fdir_set_flexbytes_offset is used when create FDir rule for flexbytes. It set a register: FDIRCTRL.FLEX_OFFSET, which cause that even if the FDir flexbytes rule is destroyed, the rule still direct the packet and transfer it to the wrong place. It is because Setting FDIRCTRL shall only be permitted on Flow Director initialization flow or Clearing the Flow Director table, otherwise unexpected happens. In order to evade the limit, add code to make setting FDIRCTRL work without unexpected effects.
--- drivers/net/ixgbe/ixgbe_fdir.c | 23 +++++++++++++++++++++++ drivers/net/ixgbe/ixgbe_flow.c | 7 +++---- 2 files changed, 26 insertions(+), 4 deletions(-)
drivers/net/ixgbe/ixgbe_fdir.c +23 -0
@@ -503,9 +503,32 @@ ixgbe_fdir_set_flexbytes_offset(struct rte_eth_dev *dev, uint16_t offset) {struct ixgbe_hw *hw =IXGBE_DEV_PRIVATE_TO_HW (dev->data->dev_private); +struct ixgbe_hw_fdir_info *fdir_info = +IXGBE_DEV_PRIVATE_TO_FDIR_INFO (dev->data->dev_private);uint32_t fdirctrl;int i; +if (fdir_info->flex_bytes_offset == offset) +return 0 ; + + fdir_info->flex_bytes_offset = offset; + +/* +* 82599 adapters flow director init flow cannot be restarted, +* Workaround 82599 silicon errata by performing the following steps +* before re-writing the FDIRCTRL control register with the same value. +* - write 1 to bit 8 of FDIRCMD register & +* - write 0 to bit 8 of FDIRCMD register +*/ +IXGBE_WRITE_REG (hw,IXGBE_FDIRCMD , + (IXGBE_READ_REG (hw,IXGBE_FDIRCMD ) | +IXGBE_FDIRCMD_CLEARHT )); +IXGBE_WRITE_FLUSH (hw); +IXGBE_WRITE_REG (hw,IXGBE_FDIRCMD , + (IXGBE_READ_REG (hw,IXGBE_FDIRCMD ) & + ~IXGBE_FDIRCMD_CLEARHT )); +IXGBE_WRITE_FLUSH (hw); + fdirctrl =IXGBE_READ_REG (hw,IXGBE_FDIRCTRL ); fdirctrl &= ~IXGBE_FDIRCTRL_FLEX_MASK ;
drivers/net/ixgbe/ixgbe_flow.c +3 -4
@@ -3137,8 +3137,6 @@ ixgbe_flow_create(struct rte_eth_dev *dev,rte_memcpy (&fdir_info->mask, &fdir_rule.mask,sizeof (struct ixgbe_hw_fdir_mask )); - fdir_info->flex_bytes_offset = - fdir_rule.flex_bytes_offset;if (fdir_rule.mask.flex_bytes_mask) ixgbe_fdir_set_flexbytes_offset(dev,
@@ -3161,8 +3159,9 @@ ixgbe_flow_create(struct rte_eth_dev *dev,if (ret) goto out; -if (fdir_info->flex_bytes_offset != - fdir_rule.flex_bytes_offset) +if (fdir_rule.mask.flex_bytes_mask && + (fdir_info->flex_bytes_offset != + fdir_rule.flex_bytes_offset)) goto out; } }
Signature · 1 line
2.26.2.windows.1
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of [email protected]
Sent: Friday, December 11, 2020 9:35 AM
To: Guo, Jia <[email protected]>
Cc: [email protected]; Yu, DapengX <[email protected]>; Zhang, Qi Z <[email protected]>
Subject: [dpdk-dev] [PATCH] net/ixgbe: fix fdirctrl register setting
From: YU DAPENG <[email protected]>
The function ixgbe_fdir_set_flexbytes_offset is used when create FDir rule for flexbytes. It set a register: FDIRCTRL.FLEX_OFFSET, which cause that even if the FDir flexbytes rule is destroyed, the rule still direct the packet and transfer it to the wrong place. It is because Setting FDIRCTRL shall only be permitted on Flow Director initialization flow or Clearing the Flow Director table, otherwise unexpected happens. In order to evade the limit, add code to make setting FDIRCTRL work without unexpected effects.
--- drivers/net/ixgbe/ixgbe_fdir.c | 23 +++++++++++++++++++++++ drivers/net/ixgbe/ixgbe_flow.c | 7 +++---- 2 files changed, 26 insertions(+), 4 deletions(-)
drivers/net/ixgbe/ixgbe_fdir.c +23 -0
@@ -503,9 +503,32 @@ ixgbe_fdir_set_flexbytes_offset(struct rte_eth_dev *dev, uint16_t offset) {struct ixgbe_hw *hw =IXGBE_DEV_PRIVATE_TO_HW (dev->data->dev_private); +struct ixgbe_hw_fdir_info *fdir_info = +IXGBE_DEV_PRIVATE_TO_FDIR_INFO (dev->data->dev_private);uint32_t fdirctrl;int i; +if (fdir_info->flex_bytes_offset == offset) +return 0 ; + + fdir_info->flex_bytes_offset = offset; + +/* +* 82599 adapters flow director init flow cannot be restarted, +* Workaround 82599 silicon errata by performing the following steps +* before re-writing the FDIRCTRL control register with the same value. +* - write 1 to bit 8 of FDIRCMD register & +* - write 0 to bit 8 of FDIRCMD register +*/ +IXGBE_WRITE_REG (hw,IXGBE_FDIRCMD , + (IXGBE_READ_REG (hw,IXGBE_FDIRCMD ) | +IXGBE_FDIRCMD_CLEARHT )); +IXGBE_WRITE_FLUSH (hw); +IXGBE_WRITE_REG (hw,IXGBE_FDIRCMD , + (IXGBE_READ_REG (hw,IXGBE_FDIRCMD ) & + ~IXGBE_FDIRCMD_CLEARHT )); +IXGBE_WRITE_FLUSH (hw); + fdirctrl =IXGBE_READ_REG (hw,IXGBE_FDIRCTRL ); fdirctrl &= ~IXGBE_FDIRCTRL_FLEX_MASK; diff --git a/drivers/net/ixgbe/ixgbe_flow.c b/drivers/net/ixgbe/ixgbe_flow.c index 39f6ed73f..b37541d9b 100644
drivers/net/ixgbe/ixgbe_flow.c +3 -4
@@ -3137,8 +3137,6 @@ ixgbe_flow_create(struct rte_eth_dev *dev,rte_memcpy (&fdir_info->mask, &fdir_rule.mask,sizeof (struct ixgbe_hw_fdir_mask )); - fdir_info->flex_bytes_offset = - fdir_rule.flex_bytes_offset;if (fdir_rule.mask.flex_bytes_mask) ixgbe_fdir_set_flexbytes_offset(dev,
@@ -3161,8 +3159,9 @@ ixgbe_flow_create(struct rte_eth_dev *dev,if (ret) goto out; -if (fdir_info->flex_bytes_offset != - fdir_rule.flex_bytes_offset) +if (fdir_rule.mask.flex_bytes_mask && + (fdir_info->flex_bytes_offset != + fdir_rule.flex_bytes_offset)) goto out; } }
--
2.26.2.windows.1
Hi, dapeng
Quoted 37 lines
-----Original Message-----
From: [email protected] <[email protected]>
Sent: Friday, December 11, 2020 9:35 AM
To: Guo, Jia <[email protected]>
Cc: [email protected]; Yu, DapengX <[email protected]>; Zhang, Qi Z <[email protected]>
Subject: [PATCH] net/ixgbe: fix fdirctrl register settingFrom: YU DAPENG <[email protected]>
The function
ixgbe_fdir_set_flexbytes_offsetis used when create FDir rule for flexbytes. It set a register: FDIRCTRL.FLEX_OFFSET, which cause that even if the FDir flexbytes rule is destroyed, the rule still direct the packet and transfer it to the wrong place. It is because Setting FDIRCTRL shall only be permitted on Flow Director initialization flow or Clearing the Flow Director table, otherwise unexpected happens. In order to evade the limit, add code to make setting FDIRCTRL work without unexpected effects.Fixes f35fec63dde1 ("net/ixgbe: enable flex bytes for generic flow API")Signed-off-by YU DAPENG <[email protected]>--- drivers/net/ixgbe/ixgbe_fdir.c | 23 +++++++++++++++++++++++ drivers/net/ixgbe/ixgbe_flow.c | 7 +++---- 2 files changed, 26 insertions(+), 4 deletions(-)drivers/net/ixgbe/ixgbe_fdir.c +0
-0@@ -503,9 +503,32 @@ ixgbe_fdir_set_flexbytes_offset(struct rte_eth_dev *dev, uint16_t offset) {struct ixgbe_hw *hw =IXGBE_DEV_PRIVATE_TO_HW (dev->data- >dev_private);
drivers/net/ixgbe/ixgbe_fdir.c ixgbe_fdir_set_flexbytes_offset(struct rte_eth_dev · line 517
Quoted 10 lines
drivers/net/ixgbe/ixgbe_fdir.c +6
-0+struct ixgbe_hw_fdir_info *fdir_info = +IXGBE_DEV_PRIVATE_TO_FDIR_INFO (dev->data- >dev_private);uint32_t fdirctrl;int i; +if (fdir_info->flex_bytes_offset == offset) +return 0 ; + + fdir_info->flex_bytes_offset = offset;
Should this value assign at the end of the polling checking?
And could you kindly help to check is the timeout checking (i >= IXGBE_FDIR_INIT_DONE_POLL) also need in the "ixgbe_fdir_set_flexbytes_offset"?
drivers/net/ixgbe/ixgbe_fdir.c ixgbe_fdir_set_flexbytes_offset(struct rte_eth_dev · line 519
Quoted 2 lines
drivers/net/ixgbe/ixgbe_fdir.c +2
-0+ +/*
/* -> /**
Quoted 6 lines
drivers/net/ixgbe/ixgbe_fdir.c +3
-0+* 82599 adapters flow director init flow cannot be restarted, +* Workaround 82599 silicon errata by performing the following steps +* before re-writing the FDIRCTRL control register with the same value.
drivers/net/ixgbe/ixgbe_fdir.c +2
-0+* - write 1 to bit 8 of FDIRCMD register & +* - write 0 to bit 8 of FDIRCMD register
drivers/net/ixgbe/ixgbe_fdir.c ixgbe_fdir_set_flexbytes_offset(struct rte_eth_dev *dev, · line 531
Quoted 10 lines
drivers/net/ixgbe/ixgbe_fdir.c +10
-0+*/ +IXGBE_WRITE_REG (hw,IXGBE_FDIRCMD , + (IXGBE_READ_REG (hw,IXGBE_FDIRCMD ) | +IXGBE_FDIRCMD_CLEARHT )); +IXGBE_WRITE_FLUSH (hw); +IXGBE_WRITE_REG (hw,IXGBE_FDIRCMD , + (IXGBE_READ_REG (hw,IXGBE_FDIRCMD ) & + ~IXGBE_FDIRCMD_CLEARHT )); +IXGBE_WRITE_FLUSH (hw); +
So you mean the above steps should be done before re-writing the FDIRCTRL, just like the Flow Director initialization flow or Clearing the Flow Director, right?
If so, please refine your commit log and make it more clear, since Setting FDIRCTRL shall is not only be permitted on Flow Director initialization flow or Clearing the Flow Director table.
Quoted 17 lines
drivers/net/ixgbe/ixgbe_fdir.c +0
-0fdirctrl =IXGBE_READ_REG (hw,IXGBE_FDIRCTRL ); fdirctrl &= ~IXGBE_FDIRCTRL_FLEX_MASK; diff --git
a/drivers/net/ixgbe/ixgbe_flow.cb/drivers/net/ixgbe/ixgbe_flow.cindex39f6ed73f..b37541d9b100644drivers/net/ixgbe/ixgbe_flow.c +0
-2@@ -3137,8 +3137,6 @@ ixgbe_flow_create(struct rte_eth_dev *dev,rte_memcpy (&fdir_info->mask, &fdir_rule.mask,sizeof (struct ixgbe_hw_fdir_mask )); - fdir_info->flex_bytes_offset = - fdir_rule.flex_bytes_offset;if (fdir_rule.mask.flex_bytes_mask) ixgbe_fdir_set_flexbytes_offset(dev,
drivers/net/ixgbe/ixgbe_flow.c ixgbe_flow_create(struct rte_eth_dev *dev, · line 3163
Quoted 7 lines
drivers/net/ixgbe/ixgbe_flow.c +2
-2@@ -3161,8 +3159,9 @@ ixgbe_flow_create(struct rte_eth_dev *dev,if (ret) goto out; -if (fdir_info->flex_bytes_offset != - fdir_rule.flex_bytes_offset) + if (fdir_rule.mask.flex_bytes_mask && + (fdir_info->flex_bytes_offset !=
Suggest you check the line align.
drivers/net/ixgbe/ixgbe_flow.c ixgbe_flow_create(struct rte_eth_dev *dev, · line 3164
Quoted 1 line
drivers/net/ixgbe/ixgbe_flow.c +1
-0+ fdir_rule.flex_bytes_offset))
This line is the same as above.
Quoted 5 lines
drivers/net/ixgbe/ixgbe_flow.c +0
-1goto out; } } --2.26.2.windows.1
PATCH v2 1/1 net/ixgbe: fix fdirctrl register setting
In reply to [email protected]From: YU DAPENG <[email protected]>
The function ixgbe_fdir_set_flexbytes_offset is used when create FDir rule for flexbytes. It set a register: FDIRCTRL.FLEX_OFFSET, which cause that even if the FDir flexbytes rule is destroyed, the rule still direct the packet and transfer it to the wrong place. It is because setting FDIRCTRL shall only be permitted on Flow Director initialization flow or clearing the Flow Director table according to intel datasheet, otherwise unexpected happens. In order to evade the limit, add code to set FDIRCMD.CLEARHT to 1b and then clear it back to 0b to make the setting act like the Flow Director initialization flow or clearing the Flow Director table.
--- drivers/net/ixgbe/ixgbe_fdir.c | 29 +++++++++++++++++++++++++++++ drivers/net/ixgbe/ixgbe_flow.c | 15 ++++++++------- 2 files changed, 37 insertions(+), 7 deletions(-)
drivers/net/ixgbe/ixgbe_fdir.c +29 -0
@@ -503,9 +503,30 @@ ixgbe_fdir_set_flexbytes_offset(struct rte_eth_dev *dev, uint16_t offset) {struct ixgbe_hw *hw =IXGBE_DEV_PRIVATE_TO_HW (dev->data->dev_private); +struct ixgbe_hw_fdir_info *fdir_info = +IXGBE_DEV_PRIVATE_TO_FDIR_INFO (dev->data->dev_private);uint32_t fdirctrl;int i; +if (fdir_info->flex_bytes_offset == offset) +return 0 ; + +/** +* 82599 adapters flow director init flow cannot be restarted, +* Workaround 82599 silicon errata by performing the following steps +* before re-writing the FDIRCTRL control register with the same value. +* - write 1 to bit 8 of FDIRCMD register & +* - write 0 to bit 8 of FDIRCMD register +*/ +IXGBE_WRITE_REG (hw,IXGBE_FDIRCMD , + (IXGBE_READ_REG (hw,IXGBE_FDIRCMD ) | +IXGBE_FDIRCMD_CLEARHT )); +IXGBE_WRITE_FLUSH (hw); +IXGBE_WRITE_REG (hw,IXGBE_FDIRCMD , + (IXGBE_READ_REG (hw,IXGBE_FDIRCMD ) & + ~IXGBE_FDIRCMD_CLEARHT )); +IXGBE_WRITE_FLUSH (hw); + fdirctrl =IXGBE_READ_REG (hw,IXGBE_FDIRCTRL ); fdirctrl &= ~IXGBE_FDIRCTRL_FLEX_MASK ;
@@ -520,6 +541,14 @@ ixgbe_fdir_set_flexbytes_offset(struct rte_eth_dev *dev,break ;msec_delay (1 ); } + +if (i >=IXGBE_FDIR_INIT_DONE_POLL ) { +PMD_DRV_LOG (ERR ,"Flow Director poll time exceeded!" ); +return -ETIMEDOUT ; + } + + fdir_info->flex_bytes_offset = offset; +return 0 ; }
drivers/net/ixgbe/ixgbe_flow.c +8 -7
@@ -3137,13 +3137,13 @@ ixgbe_flow_create(struct rte_eth_dev *dev,rte_memcpy (&fdir_info->mask, &fdir_rule.mask,sizeof (struct ixgbe_hw_fdir_mask )); - fdir_info->flex_bytes_offset = - fdir_rule.flex_bytes_offset; -if (fdir_rule.mask.flex_bytes_mask) -ixgbe_fdir_set_flexbytes_offset (dev, +if (fdir_rule.mask.flex_bytes_mask) { + ret =ixgbe_fdir_set_flexbytes_offset (dev, fdir_rule.flex_bytes_offset); - +if (ret) + goto out; + } ret =ixgbe_fdir_set_input_mask (dev);if (ret) goto out;
@@ -3161,8 +3161,9 @@ ixgbe_flow_create(struct rte_eth_dev *dev,if (ret) goto out; -if (fdir_info->flex_bytes_offset != - fdir_rule.flex_bytes_offset) +if (fdir_rule.mask.flex_bytes_mask && + fdir_info->flex_bytes_offset != + fdir_rule.flex_bytes_offset) goto out; } }
Signature · 1 line
2.26.2.windows.1
Hi Jia,
Thanks for your comments!
Patch v2 has been sent, all your comments have specified answer in patch v2.
-----Original Message-----
From: Guo, Jia
Sent: Tuesday, December 15, 2020 12:37 PM
To: Yu, DapengX <[email protected]>
Cc: [email protected]; Yu, DapengX <[email protected]>; Zhang, Qi Z <[email protected]>
Subject: RE: [PATCH] net/ixgbe: fix fdirctrl register setting
Hi, dapeng
Quoted 38 lines
-----Original Message-----
From: [email protected] <[email protected]>
Sent: Friday, December 11, 2020 9:35 AM
To: Guo, Jia <[email protected]>
Cc: [email protected]; Yu, DapengX <[email protected]>; Zhang, Qi Z <[email protected]>
Subject: [PATCH] net/ixgbe: fix fdirctrl register settingFrom: YU DAPENG <[email protected]>
The function
ixgbe_fdir_set_flexbytes_offsetis used when create FDir
rule for flexbytes. It set a register: FDIRCTRL.FLEX_OFFSET, which
cause that even if the FDir flexbytes rule is destroyed, the rule
still direct the packet and transfer it to the wrong place. It is
because Setting FDIRCTRL shall only be permitted on Flow Director
initialization flow or Clearing the Flow Director table, otherwise
unexpected happens. In order to evade the limit, add code to make setting FDIRCTRL work without unexpected effects.Fixes f35fec63dde1 ("net/ixgbe: enable flex bytes for generic flowAPI")
Cc: [email protected]Signed-off-by YU DAPENG <[email protected]>--- drivers/net/ixgbe/ixgbe_fdir.c | 23 +++++++++++++++++++++++ drivers/net/ixgbe/ixgbe_flow.c | 7 +++---- 2 files changed, 26 insertions(+), 4 deletions(-)(quoted diff) +0
-0
b/drivers/net/ixgbe/ixgbe_fdir.cindexa0fab5070..56dddd56b100644drivers/net/ixgbe/ixgbe_fdir.c +0
-0@@ -503,9 +503,32 @@ ixgbe_fdir_set_flexbytes_offset(struct rte_eth_dev *dev, uint16_t offset) {struct ixgbe_hw *hw =IXGBE_DEV_PRIVATE_TO_HW (dev->data- >dev_private);
drivers/net/ixgbe/ixgbe_fdir.c ixgbe_fdir_set_flexbytes_offset(struct · line 517
Quoted 10 lines
drivers/net/ixgbe/ixgbe_fdir.c +6
-0+struct ixgbe_hw_fdir_info *fdir_info = +IXGBE_DEV_PRIVATE_TO_FDIR_INFO (dev->data- >dev_private);uint32_t fdirctrl;int i; +if (fdir_info->flex_bytes_offset == offset) +return 0 ; + + fdir_info->flex_bytes_offset = offset;
Should this value assign at the end of the polling checking?
And could you kindly help to check is the timeout checking (i >= IXGBE_FDIR_INIT_DONE_POLL) also need in the "ixgbe_fdir_set_flexbytes_offset"?
drivers/net/ixgbe/ixgbe_fdir.c ixgbe_fdir_set_flexbytes_offset(struct · line 519
Quoted 2 lines
drivers/net/ixgbe/ixgbe_fdir.c +2
-0+ +/*
/* -> /**
Quoted 6 lines
drivers/net/ixgbe/ixgbe_fdir.c +3
-0+* 82599 adapters flow director init flow cannot be restarted, +* Workaround 82599 silicon errata by performing the following steps +* before re-writing the FDIRCTRL control register with the same value.
drivers/net/ixgbe/ixgbe_fdir.c +2
-0+* - write 1 to bit 8 of FDIRCMD register & +* - write 0 to bit 8 of FDIRCMD register
drivers/net/ixgbe/ixgbe_fdir.c ixgbe_fdir_set_flexbytes_offset(struct rte_eth_dev *dev, · line 531
Quoted 10 lines
drivers/net/ixgbe/ixgbe_fdir.c +10
-0+*/ +IXGBE_WRITE_REG (hw,IXGBE_FDIRCMD , + (IXGBE_READ_REG (hw,IXGBE_FDIRCMD ) | +IXGBE_FDIRCMD_CLEARHT )); +IXGBE_WRITE_FLUSH (hw); +IXGBE_WRITE_REG (hw,IXGBE_FDIRCMD , + (IXGBE_READ_REG (hw,IXGBE_FDIRCMD ) & + ~IXGBE_FDIRCMD_CLEARHT )); +IXGBE_WRITE_FLUSH (hw); +
So you mean the above steps should be done before re-writing the FDIRCTRL, just like the Flow Director initialization flow or Clearing the Flow Director, right? If so, please refine your commit log and make it more clear, since Setting FDIRCTRL shall is not only be permitted on Flow Director initialization flow or Clearing the Flow Director table.
Quoted 17 lines
drivers/net/ixgbe/ixgbe_fdir.c +0
-0fdirctrl =IXGBE_READ_REG (hw,IXGBE_FDIRCTRL ); fdirctrl &= ~IXGBE_FDIRCTRL_FLEX_MASK; diff --git
a/drivers/net/ixgbe/ixgbe_flow.cb/drivers/net/ixgbe/ixgbe_flow.cindex39f6ed73f..b37541d9b100644drivers/net/ixgbe/ixgbe_flow.c +0
-2@@ -3137,8 +3137,6 @@ ixgbe_flow_create(struct rte_eth_dev *dev,rte_memcpy (&fdir_info->mask, &fdir_rule.mask,sizeof (struct ixgbe_hw_fdir_mask )); - fdir_info->flex_bytes_offset = - fdir_rule.flex_bytes_offset;if (fdir_rule.mask.flex_bytes_mask) ixgbe_fdir_set_flexbytes_offset(dev,
drivers/net/ixgbe/ixgbe_flow.c ixgbe_flow_create(struct rte_eth_dev *dev, · line 3163
Quoted 7 lines
drivers/net/ixgbe/ixgbe_flow.c +2
-2@@ -3161,8 +3159,9 @@ ixgbe_flow_create(struct rte_eth_dev *dev,if (ret) goto out; -if (fdir_info->flex_bytes_offset != - fdir_rule.flex_bytes_offset) + if (fdir_rule.mask.flex_bytes_mask && + (fdir_info->flex_bytes_offset !=
Suggest you check the line align.
drivers/net/ixgbe/ixgbe_flow.c ixgbe_flow_create(struct rte_eth_dev *dev, · line 3164
Quoted 1 line
drivers/net/ixgbe/ixgbe_flow.c +1
-0+ fdir_rule.flex_bytes_offset))
This line is the same as above.
Quoted 5 lines
drivers/net/ixgbe/ixgbe_flow.c +0
-1goto out; } } --2.26.2.windows.1
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of [email protected]
Sent: Tuesday, December 15, 2020 6:11 PM
To: Guo, Jia <[email protected]>
Cc: [email protected]; Yu, DapengX <[email protected]>; [email protected]
Subject: [dpdk-dev] [PATCH v2] net/ixgbe: fix fdirctrl register setting
From: YU DAPENG <[email protected]>
The function ixgbe_fdir_set_flexbytes_offset is used when create FDir rule for flexbytes. It set a register: FDIRCTRL.FLEX_OFFSET, which cause that even if the FDir flexbytes rule is destroyed, the rule still direct the packet and transfer it to the wrong place. It is because setting FDIRCTRL shall only be permitted on Flow Director initialization flow or clearing the Flow Director table according to intel datasheet, otherwise unexpected happens. In order to evade the limit, add code to set FDIRCMD.CLEARHT to 1b and then clear it back to 0b to make the setting act like the Flow Director initialization flow or clearing the Flow Director table.
--- drivers/net/ixgbe/ixgbe_fdir.c | 29 +++++++++++++++++++++++++++++ drivers/net/ixgbe/ixgbe_flow.c | 15 ++++++++------- 2 files changed, 37 insertions(+), 7 deletions(-)
drivers/net/ixgbe/ixgbe_fdir.c +21 -0
@@ -503,9 +503,30 @@ ixgbe_fdir_set_flexbytes_offset(struct rte_eth_dev *dev, uint16_t offset) {struct ixgbe_hw *hw =IXGBE_DEV_PRIVATE_TO_HW (dev->data->dev_private); +struct ixgbe_hw_fdir_info *fdir_info = +IXGBE_DEV_PRIVATE_TO_FDIR_INFO (dev->data->dev_private);uint32_t fdirctrl;int i; +if (fdir_info->flex_bytes_offset == offset) +return 0 ; + +/** +* 82599 adapters flow director init flow cannot be restarted, +* Workaround 82599 silicon errata by performing the following steps +* before re-writing the FDIRCTRL control register with the same value. +* - write 1 to bit 8 of FDIRCMD register & +* - write 0 to bit 8 of FDIRCMD register +*/ +IXGBE_WRITE_REG (hw,IXGBE_FDIRCMD , + (IXGBE_READ_REG (hw,IXGBE_FDIRCMD ) | +IXGBE_FDIRCMD_CLEARHT )); +IXGBE_WRITE_FLUSH (hw); +IXGBE_WRITE_REG (hw,IXGBE_FDIRCMD , + (IXGBE_READ_REG (hw,IXGBE_FDIRCMD ) & + ~IXGBE_FDIRCMD_CLEARHT )); +IXGBE_WRITE_FLUSH (hw); + fdirctrl =IXGBE_READ_REG (hw,IXGBE_FDIRCTRL ); fdirctrl &= ~IXGBE_FDIRCTRL_FLEX_MASK; @@ -520,6 +541,14 @@ ixgbe_fdir_set_flexbytes_offset(struct rte_eth_dev *dev,
break;
msec_delay(1);
}
+
+ if (i >= IXGBE_FDIR_INIT_DONE_POLL) {
+ PMD_DRV_LOG(ERR, "Flow Director poll time exceeded!");
+ return -ETIMEDOUT;
+ }
+
+ fdir_info->flex_bytes_offset = offset;
+
return 0;
}
drivers/net/ixgbe/ixgbe_flow.c +8 -7
@@ -3137,13 +3137,13 @@ ixgbe_flow_create(struct rte_eth_dev *dev,rte_memcpy (&fdir_info->mask, &fdir_rule.mask,sizeof (struct ixgbe_hw_fdir_mask )); - fdir_info->flex_bytes_offset = - fdir_rule.flex_bytes_offset; -if (fdir_rule.mask.flex_bytes_mask) -ixgbe_fdir_set_flexbytes_offset (dev, +if (fdir_rule.mask.flex_bytes_mask) { + ret =ixgbe_fdir_set_flexbytes_offset (dev, fdir_rule.flex_bytes_offset); - +if (ret) + goto out; + } ret =ixgbe_fdir_set_input_mask (dev);if (ret) goto out;
@@ -3161,8 +3161,9 @@ ixgbe_flow_create(struct rte_eth_dev *dev,if (ret) goto out; -if (fdir_info->flex_bytes_offset != - fdir_rule.flex_bytes_offset) +if (fdir_rule.mask.flex_bytes_mask && + fdir_info->flex_bytes_offset != + fdir_rule.flex_bytes_offset) goto out; } }
--
2.26.2.windows.1
Guo, Jia
Acked-byQuoted 130 lines
-----Original Message-----
From: Zhou, JunX W <[email protected]>
Sent: Tuesday, December 22, 2020 2:51 PM
To: Yu, DapengX <[email protected]>; Guo, Jia <[email protected]>
Cc: [email protected]; Yu, DapengX <[email protected]>; [email protected]
Subject: RE: [dpdk-dev] [PATCH v2] net/ixgbe: fix fdirctrl register settingTested-by Zhou, Jun <[email protected]>-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of [email protected]
Sent: Tuesday, December 15, 2020 6:11 PM
To: Guo, Jia <[email protected]>
Cc: [email protected]; Yu, DapengX <[email protected]>; [email protected]
Subject: [dpdk-dev] [PATCH v2] net/ixgbe: fix fdirctrl register settingFrom: YU DAPENG <[email protected]>
The function
ixgbe_fdir_set_flexbytes_offsetis used when create FDir rule for flexbytes. It set a register: FDIRCTRL.FLEX_OFFSET, which cause that even if the FDir flexbytes rule is destroyed, the rule still direct the packet and transfer it to the wrong place. It is because setting FDIRCTRL shall only be permitted on Flow Director initialization flow or clearing the Flow Director table according to intel datasheet, otherwise unexpected happens. In order to evade the limit, add code to set FDIRCMD.CLEARHT to 1b and then clear it back to 0b to make the setting act like the Flow Director initialization flow or clearing the Flow Director table.Fixes f35fec63dde1 ("net/ixgbe: enable flex bytes for generic flow API")Signed-off-by YU DAPENG <[email protected]>--- drivers/net/ixgbe/ixgbe_fdir.c | 29 +++++++++++++++++++++++++++++ drivers/net/ixgbe/ixgbe_flow.c | 15 ++++++++------- 2 files changed, 37 insertions(+), 7 deletions(-)drivers/net/ixgbe/ixgbe_fdir.c +9
-0@@ -503,9 +503,30 @@ ixgbe_fdir_set_flexbytes_offset(struct rte_eth_dev *dev, uint16_t offset) {struct ixgbe_hw *hw =IXGBE_DEV_PRIVATE_TO_HW (dev->data- >dev_private); +struct ixgbe_hw_fdir_info *fdir_info = +IXGBE_DEV_PRIVATE_TO_FDIR_INFO (dev->data- >dev_private);uint32_t fdirctrl;int i; +if (fdir_info->flex_bytes_offset == offset) +return 0 ; + +/** +* 82599 adapters flow director init flow cannot be restarted, +* Workaround 82599 silicon errata by performing the following steps +* before re-writing the FDIRCTRL control register with the same value.
drivers/net/ixgbe/ixgbe_fdir.c +12
-0+* - write 1 to bit 8 of FDIRCMD register & +* - write 0 to bit 8 of FDIRCMD register +*/ +IXGBE_WRITE_REG (hw,IXGBE_FDIRCMD , + (IXGBE_READ_REG (hw,IXGBE_FDIRCMD ) | +IXGBE_FDIRCMD_CLEARHT )); +IXGBE_WRITE_FLUSH (hw); +IXGBE_WRITE_REG (hw,IXGBE_FDIRCMD , + (IXGBE_READ_REG (hw,IXGBE_FDIRCMD ) & + ~IXGBE_FDIRCMD_CLEARHT )); +IXGBE_WRITE_FLUSH (hw); + fdirctrl =IXGBE_READ_REG (hw,IXGBE_FDIRCTRL ); fdirctrl &= ~IXGBE_FDIRCTRL_FLEX_MASK; @@ -520,6 +541,14 @@ixgbe_fdir_set_flexbytes_offset(struct
rte_eth_dev*dev,drivers/net/ixgbe/ixgbe_fdir.c +8
-0break ;msec_delay (1 ); } + +if (i >=IXGBE_FDIR_INIT_DONE_POLL ) { +PMD_DRV_LOG (ERR ,"Flow Director poll time exceeded!" ); +return -ETIMEDOUT ; + } + + fdir_info->flex_bytes_offset = offset; +return 0 ; }drivers/net/ixgbe/ixgbe_flow.c +5
-5@@ -3137,13 +3137,13 @@ ixgbe_flow_create(struct rte_eth_dev *dev,rte_memcpy (&fdir_info->mask, &fdir_rule.mask,sizeof (struct ixgbe_hw_fdir_mask )); - fdir_info->flex_bytes_offset = - fdir_rule.flex_bytes_offset; -if (fdir_rule.mask.flex_bytes_mask) -ixgbe_fdir_set_flexbytes_offset (dev, +if (fdir_rule.mask.flex_bytes_mask) { + ret =ixgbe_fdir_set_flexbytes_offset (dev, fdir_rule.flex_bytes_offset); - +if (ret) + goto out; + } ret =ixgbe_fdir_set_input_mask (dev);if (ret)drivers/net/ixgbe/ixgbe_flow.c +3
-3goto out;@@ -3161,8 +3161,9 @@ ixgbe_flow_create(struct rte_eth_dev *dev,if (ret) goto out; -if (fdir_info->flex_bytes_offset != - fdir_rule.flex_bytes_offset) +if (fdir_rule.mask.flex_bytes_mask && + fdir_info->flex_bytes_offset != + fdir_rule.flex_bytes_offset) goto out; } } --2.26.2.windows.1
Quoted 35 lines · Jia
Acked-by Jeff Guo <[email protected]>Quoted 33 lines
-----Original Message-----
From: Zhou, JunX W <[email protected]>
Sent: Tuesday, December 22, 2020 2:51 PM
To: Yu, DapengX <[email protected]>; Guo, Jia <[email protected]>
Cc: [email protected]; Yu, DapengX <[email protected]>; [email protected]
Subject: RE: [dpdk-dev] [PATCH v2] net/ixgbe: fix fdirctrl register settingTested-by Zhou, Jun <[email protected]>-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of [email protected]
Sent: Tuesday, December 15, 2020 6:11 PM
To: Guo, Jia <[email protected]>
Cc: [email protected]; Yu, DapengX <[email protected]>; [email protected]
Subject: [dpdk-dev] [PATCH v2] net/ixgbe: fix fdirctrl register settingFrom: YU DAPENG <[email protected]>
The function
ixgbe_fdir_set_flexbytes_offsetis used when create FDir rule for flexbytes. It set a register: FDIRCTRL.FLEX_OFFSET, which cause that even if the FDir flexbytes rule is destroyed, the rule still direct the packet and transfer it to the wrong place. It is because setting FDIRCTRL shall only be permitted on Flow Director initialization flow or clearing the Flow Director table according to intel datasheet, otherwise unexpected happens. In order to evade the limit, add code to set FDIRCMD.CLEARHT to 1b and then clear it back to 0b to make the setting act like the Flow Director initialization flow or clearing the Flow Director table.Fixes f35fec63dde1 ("net/ixgbe: enable flex bytes for generic flow API")Signed-off-by YU DAPENG <[email protected]>
Updating the commit log as following:
net/ixgbe: fix flexbytes flow director rule
When a flexbytes flow director rule is created, the FDIRCTRL.FLEX_OFFSET register is set, and it keeps its affect even after the flow director flexbytes rule is destroyed, causing packets to be transferred to the wrong place.
It is because setting FDIRCTRL shall only be permitted on Flow Director initialization flow or clearing the Flow Director table according to the datasheet, otherwise device may behave unexpectedly.
In order to evade this limitation, simulate the Flow Director initialization flow or clearing the Flow Director table by setting FDIRCMD.CLEARHT to 0x1B and then clear it back to 0x0B.
Please prefer the "Dapeng Yu <[email protected]>" signature to be consistent.