i40e: use the safe hash table iterator when deleting mac filters
Subsystems (2)
PATCH 1/11 i40e: use the safe hash table iterator when deleting mac filters
From: Lihong Yang <[email protected]>
This patch replaces hash_for_each function with hash_for_each_safe when calling __i40e_del_filter. The hash_for_each_safe function is the right one to use when iterating over a hash table to safely remove a hash entry. Otherwise, incorrect values may be read from freed memory.
Detected by CoverityScan, CID 1402048 Read from pointer after free
--- drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c +2 -1
@@ -2880,6 +2880,7 @@ int i40e_ndo_set_vf_mac(struct net_device *netdev, int vf_id, u8 *mac)struct i40e_mac_filter *f;struct i40e_vf *vf;int ret =0 ; +struct hlist_node *h;int bkt;/* validate the request */
@@ -2918,7 +2919,7 @@ int i40e_ndo_set_vf_mac(struct net_device *netdev, int vf_id, u8 *mac)/* Delete all the filters for this VSI - we're going to kill it * anyway. */ -hash_for_each (vsi->mac_filter_hash, bkt, f, hlist) +hash_for_each_safe (vsi->mac_filter_hash, bkt, h, f, hlist)__i40e_del_filter (vsi, f);spin_unlock_bh (&vsi->mac_filter_hash_lock);
Signature · 1 line
2.9.4
PATCH 2/11 i40evf: fix mac filter removal timing issue
From: Alan Brady <[email protected]>
Due to the asynchronous nature in which mac filters are added and deleted, there exists a bug in which filters are erroneously removed if removed then added again quickly.
The events are as such:
- filter marked for removal
- same filter is re-added before watchdog that cleans up filters
- we skip re-adding the filter because we have it already in the
list
- watchdog filter cleanup kicks off and filter is removed
So when we were re-adding the same filter, it didn't actually get added because it already existed in the list, but was marked for removal and had yet to actually be removed.
This patch fixes the issue by making sure that when adding a filter, if we find it already existing in our list, make sure it is not marked to be removed.
--- drivers/net/ethernet/intel/i40evf/i40evf_main.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/ethernet/intel/i40evf/i40evf_main.c +2 -0
@@ -880,6 +880,8 @@ i40evf_mac_filter *i40evf_add_filter(struct i40evf_adapter *adapter,list_add_tail (&f->list, &adapter->mac_filter_list); f->add = true; adapter->aq_required |=I40EVF_FLAG_AQ_ADD_MAC_FILTER ; + }else { + f->remove = false; }clear_bit (__I40EVF_IN_CRITICAL_TASK, &adapter->crit_section);
Signature · 1 line
2.9.4
Bowers
PATCH 2/11 i40evf: fix mac filter removal timing issue
Quoted 25 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On Behalf Of Alice Michael
Sent: Thursday, September 7, 2017 5:06 AM
To: Michael, Alice <[email protected]>; intel-wired-
lan at lists.osuosl.org
Subject: [Intel-wired-lan] [next PATCH S80-V3 02/11] i40evf: fix mac filter removal timing issueFrom: Alan Brady <[email protected]>
Due to the asynchronous nature in which mac filters are added and deleted, there exists a bug in which filters are erroneously removed if removed then added again quickly.
The events are as such:
- filter marked for removal
- same filter is re-added before watchdog that cleans up filters
- we skip re-adding the filter because we have it already in the list
- watchdog filter cleanup kicks off and filter is removedSo when we were re-adding the same filter, it didn't actually get added because it already existed in the list, but was marked for removal and had yet to actually be removed.
Quoted 7 lines
This patch fixes the issue by making sure that when adding a filter, if we find it already existing in our list, make sure it is not marked to be removed.
Signed-off-by Alan Brady <[email protected]>--- drivers/net/ethernet/intel/i40evf/i40evf_main.c | 2 ++ 1 file changed, 2 insertions(+)
PATCH 3/11 i40e/i40evf: fix incorrect default ITR values on driver load
In reply to Alice MichaelFrom: Jacob Keller <[email protected]>
The ITR register expects to be programmed in units of 2 microseconds. Because of this, all of the drivers I40E_ITR_* constants are in terms of this 2 microsecond register.
Unfortunately, the rx_itr_default value is expected to be programmed in microseconds.
Effectively the driver defaults to an ITR value of half the expected value (in terms of minimum microseconds between interrupts).
Fix this by changing the default values to be calculated using ITR_REG_TO_USEC macro which indicates that we're converting from the register units into microseconds.
--- drivers/net/ethernet/intel/i40e/i40e_main.c | 4 ++-- drivers/net/ethernet/intel/i40e/i40e_txrx.h | 6 ++++-- drivers/net/ethernet/intel/i40evf/i40e_txrx.h | 6 ++++-- drivers/net/ethernet/intel/i40evf/i40evf_main.c | 4 ++-- 4 files changed, 12 insertions(+), 8 deletions(-)
drivers/net/ethernet/intel/i40e/i40e_main.c +2 -2
@@ -8983,8 +8983,8 @@ static int i40e_sw_init(struct i40e_pf *pf)I40E_FLAG_MSIX_ENABLED ;/* Set default ITR */ - pf->rx_itr_default =I40E_ITR_DYNAMIC |I40E_ITR_RX_DEF ; - pf->tx_itr_default =I40E_ITR_DYNAMIC |I40E_ITR_TX_DEF ; + pf->rx_itr_default =I40E_ITR_RX_DEF ; + pf->tx_itr_default =I40E_ITR_TX_DEF ;/* Depending on PF configurations, it is possible that the RSS * maximum might end up larger than the available queues
drivers/net/ethernet/intel/i40e/i40e_txrx.h +4 -2
@@ -38,8 +38,10 @@#define I40E_ITR_8K 0x003E#define I40E_ITR_4K 0x007A#define I40E_MAX_INTRL 0x3B/* reg uses 4 usec resolution */ -#define I40E_ITR_RX_DEF I40E_ITR_20K -#define I40E_ITR_TX_DEF I40E_ITR_20K +#define I40E_ITR_RX_DEF (ITR_REG_TO_USEC(I40E_ITR_20K) | \ + I40E_ITR_DYNAMIC) +#define I40E_ITR_TX_DEF (ITR_REG_TO_USEC(I40E_ITR_20K) | \ + I40E_ITR_DYNAMIC)#define I40E_ITR_DYNAMIC 0x8000/* use top bit as a flag */ #define I40E_MIN_INT_RATE 250/* ~= 1000000 / (I40E_MAX_ITR * 2) */ #define I40E_MAX_INT_RATE 500000/* == 1000000 / (I40E_MIN_ITR * 2) */
drivers/net/ethernet/intel/i40evf/i40e_txrx.h +4 -2
@@ -38,8 +38,10 @@#define I40E_ITR_8K 0x003E#define I40E_ITR_4K 0x007A#define I40E_MAX_INTRL 0x3B/* reg uses 4 usec resolution */ -#define I40E_ITR_RX_DEF I40E_ITR_20K -#define I40E_ITR_TX_DEF I40E_ITR_20K +#define I40E_ITR_RX_DEF (ITR_REG_TO_USEC(I40E_ITR_20K) | \ + I40E_ITR_DYNAMIC) +#define I40E_ITR_TX_DEF (ITR_REG_TO_USEC(I40E_ITR_20K) | \ + I40E_ITR_DYNAMIC)#define I40E_ITR_DYNAMIC 0x8000/* use top bit as a flag */ #define I40E_MIN_INT_RATE 250/* ~= 1000000 / (I40E_MAX_ITR * 2) */ #define I40E_MAX_INT_RATE 500000/* == 1000000 / (I40E_MIN_ITR * 2) */
drivers/net/ethernet/intel/i40evf/i40evf_main.c +2 -2
@@ -1223,7 +1223,7 @@ static int i40evf_alloc_queues(struct i40evf_adapter *adapter) tx_ring->netdev = adapter->netdev; tx_ring->dev = &adapter->pdev->dev; tx_ring->count = adapter->tx_desc_count; - tx_ring->tx_itr_setting = (I40E_ITR_DYNAMIC |I40E_ITR_TX_DEF ); + tx_ring->tx_itr_setting =I40E_ITR_TX_DEF ;if (adapter->flags &I40EVF_FLAG_WB_ON_ITR_CAPABLE ) tx_ring->flags |=I40E_TXR_FLAGS_WB_ON_ITR ;
@@ -1232,7 +1232,7 @@ static int i40evf_alloc_queues(struct i40evf_adapter *adapter) rx_ring->netdev = adapter->netdev; rx_ring->dev = &adapter->pdev->dev; rx_ring->count = adapter->rx_desc_count; - rx_ring->rx_itr_setting = (I40E_ITR_DYNAMIC |I40E_ITR_RX_DEF ); + rx_ring->rx_itr_setting =I40E_ITR_RX_DEF ; } adapter->num_active_queues = num_active_queues;
Signature · 1 line
2.9.4
Bowers
PATCH 3/11 i40e/i40evf: fix incorrect default ITR values on driver load
Quoted 25 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On Behalf Of Alice Michael
Sent: Thursday, September 7, 2017 5:06 AM
To: Michael, Alice <[email protected]>; intel-wired- lan at lists.osuosl.org
Subject: [Intel-wired-lan] [next PATCH S80-V3 03/11] i40e/i40evf: fix incorrect default ITR values on driver loadFrom: Jacob Keller <[email protected]>
The ITR register expects to be programmed in units of 2 microseconds. Because of this, all of the drivers I40E_ITR_* constants are in terms of this 2 microsecond register.
Unfortunately, the
rx_itr_defaultvalue is expected to be programmed in microseconds.Effectively the driver defaults to an ITR value of half the expected value (in terms of minimum microseconds between interrupts).
Fix this by changing the default values to be calculated using
ITR_REG_TO_USECmacro which indicates that we're converting from the register units into microseconds.
Quoted 7 lines
Signed-off-by Jacob Keller <[email protected]>--- drivers/net/ethernet/intel/i40e/i40e_main.c | 4 ++-- drivers/net/ethernet/intel/i40e/i40e_txrx.h | 6 ++++-- drivers/net/ethernet/intel/i40evf/i40e_txrx.h | 6 ++++-- drivers/net/ethernet/intel/i40evf/i40evf_main.c | 4 ++-- 4 files changed, 12 insertions(+), 8 deletions(-)
PATCH 4/11 i40e/i40evf: always set the CLEARPBA flag when re-enabling interrupts
In reply to Alice MichaelFrom: Jacob Keller <[email protected]>
In the past we changed driver behavior to not clear the PBA when re-enabling interrupts. This change was motivated by the flawed belief that clearing the PBA would cause a lost interrupt if a receive interrupt occurred while interrupts were disabled.
According to empirical testing this isn't the case. Additionally, the data sheet specifically says that we should set the CLEARPBA bit when re-enabling interrupts in a polling setup.
This reverts commit 40d72a509862 ("i40e/i40evf: don't lose interrupts")
--- drivers/net/ethernet/intel/i40e/i40e.h | 5 +---- drivers/net/ethernet/intel/i40e/i40e_main.c | 11 +++++------ drivers/net/ethernet/intel/i40e/i40e_txrx.c | 6 ++---- drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c | 2 +- drivers/net/ethernet/intel/i40evf/i40e_txrx.c | 4 +--- 5 files changed, 10 insertions(+), 18 deletions(-)
drivers/net/ethernet/intel/i40e/i40e.h +1 -4
@@ -949,9 +949,6 @@ static inline void i40e_irq_dynamic_enable(struct i40e_vsi *vsi, int vector)struct i40e_hw *hw = &pf->hw;u32 val; -/* definitely clear the PBA here, as this function is meant to -* clean out all previous interrupts AND enable the interrupt -*/ val =I40E_PFINT_DYN_CTLN_INTENA_MASK |I40E_PFINT_DYN_CTLN_CLEARPBA_MASK | (I40E_ITR_NONE <<I40E_PFINT_DYN_CTLN_ITR_INDX_SHIFT );
@@ -960,7 +957,7 @@ static inline void i40e_irq_dynamic_enable(struct i40e_vsi *vsi, int vector) }void i40e_irq_dynamic_disable_icr0 (struct i40e_pf *pf); -void i40e_irq_dynamic_enable_icr0 (struct i40e_pf *pf,bool clearpba); +void i40e_irq_dynamic_enable_icr0 (struct i40e_pf *pf);int i40e_ioctl (struct net_device *netdev,struct ifreq *ifr,int cmd);int i40e_open (struct net_device *netdev);int i40e_close (struct net_device *netdev);
drivers/net/ethernet/intel/i40e/i40e_main.c +5 -6
@@ -3403,15 +3403,14 @@ void i40e_irq_dynamic_disable_icr0(struct i40e_pf *pf)/** * i40e_irq_dynamic_enable_icr0 - Enable default interrupt generation for icr0 * @pf: board private structure -* @clearpba: true when all pending interrupt events should be cleared **/ -void i40e_irq_dynamic_enable_icr0 (struct i40e_pf *pf,bool clearpba) +void i40e_irq_dynamic_enable_icr0 (struct i40e_pf *pf) {struct i40e_hw *hw = &pf->hw;u32 val; val =I40E_PFINT_DYN_CTL0_INTENA_MASK | - (clearpba ?I40E_PFINT_DYN_CTL0_CLEARPBA_MASK :0 ) | +I40E_PFINT_DYN_CTL0_CLEARPBA_MASK | (I40E_ITR_NONE <<I40E_PFINT_DYN_CTL0_ITR_INDX_SHIFT );wr32 (hw,I40E_PFINT_DYN_CTL0 , val);
@@ -3597,7 +3596,7 @@ static int i40e_vsi_enable_irq(struct i40e_vsi *vsi)for (i =0 ; i < vsi->num_q_vectors; i++)i40e_irq_dynamic_enable (vsi, i); }else { -i40e_irq_dynamic_enable_icr0 (pf, true); +i40e_irq_dynamic_enable_icr0 (pf); }i40e_flush (&pf->hw);
@@ -3746,7 +3745,7 @@ static irqreturn_t i40e_intr(int irq, void *data)wr32 (hw,I40E_PFINT_ICR0_ENA , ena_mask);if (!test_bit (__I40E_DOWN, pf->state)) {i40e_service_event_schedule (pf); -i40e_irq_dynamic_enable_icr0 (pf, false); +i40e_irq_dynamic_enable_icr0 (pf); }return ret;
@@ -8455,7 +8454,7 @@ static int i40e_setup_misc_vector(struct i40e_pf *pf)i40e_flush (hw); -i40e_irq_dynamic_enable_icr0 (pf, true); +i40e_irq_dynamic_enable_icr0 (pf);return err; }
drivers/net/ethernet/intel/i40e/i40e_txrx.c +2 -4
@@ -2201,9 +2201,7 @@ static u32 i40e_buildreg_itr(const int type, const u16 itr)u32 val; val =I40E_PFINT_DYN_CTLN_INTENA_MASK | -/* Don't clear PBA because that can cause lost interrupts that -* came in while we were cleaning/polling -*/ +I40E_PFINT_DYN_CTLN_CLEARPBA_MASK | (type <<I40E_PFINT_DYN_CTLN_ITR_INDX_SHIFT ) | (itr <<I40E_PFINT_DYN_CTLN_INTERVAL_SHIFT );
@@ -2240,7 +2238,7 @@ static inline void i40e_update_enable_itr(struct i40e_vsi *vsi,/* If we don't have MSIX, then we only need to re-enable icr0 */ if (!(vsi->back->flags &I40E_FLAG_MSIX_ENABLED )) { -i40e_irq_dynamic_enable_icr0 (vsi->back, false); +i40e_irq_dynamic_enable_icr0 (vsi->back);return ; }
drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c +1 -1
@@ -1355,7 +1355,7 @@ int i40e_alloc_vfs(struct i40e_pf *pf, u16 num_alloc_vfs)i40e_free_vfs (pf); err_iov:/* Re-enable interrupt 0. */ -i40e_irq_dynamic_enable_icr0 (pf, false); +i40e_irq_dynamic_enable_icr0 (pf);return ret; }
drivers/net/ethernet/intel/i40evf/i40e_txrx.c +1 -3
@@ -1409,9 +1409,7 @@ static u32 i40e_buildreg_itr(const int type, const u16 itr)u32 val; val =I40E_VFINT_DYN_CTLN1_INTENA_MASK | -/* Don't clear PBA because that can cause lost interrupts that -* came in while we were cleaning/polling -*/ +I40E_VFINT_DYN_CTLN1_CLEARPBA_MASK | (type <<I40E_VFINT_DYN_CTLN1_ITR_INDX_SHIFT ) | (itr <<I40E_VFINT_DYN_CTLN1_INTERVAL_SHIFT );
Signature · 1 line
2.9.4
Bowers
PATCH 4/11 i40e/i40evf: always set the CLEARPBA flag when re-enabling interrupts
Quoted 22 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On Behalf Of Alice Michael
Sent: Thursday, September 7, 2017 5:06 AM
To: Michael, Alice <[email protected]>; intel-wired-
lan at lists.osuosl.org
Subject: [Intel-wired-lan] [next PATCH S80-V3 04/11] i40e/i40evf: always set the CLEARPBA flag when re-enabling interruptsFrom: Jacob Keller <[email protected]>
In the past we changed driver behavior to not clear the PBA when re- enabling interrupts. This change was motivated by the flawed belief that clearing the PBA would cause a lost interrupt if a receive interrupt occurred while interrupts were disabled.
According to empirical testing this isn't the case. Additionally, the data sheet specifically says that we should set the CLEARPBA bit when re-enabling interrupts in a polling setup.
This reverts commit
40d72a509862("i40e/i40evf: don't lose interrupts")
Quoted 8 lines
Signed-off-by Jacob Keller <[email protected]>--- drivers/net/ethernet/intel/i40e/i40e.h | 5 +---- drivers/net/ethernet/intel/i40e/i40e_main.c | 11 +++++------ drivers/net/ethernet/intel/i40e/i40e_txrx.c | 6 ++---- drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c | 2 +- drivers/net/ethernet/intel/i40evf/i40e_txrx.c | 4 +--- 5 files changed, 10 insertions(+), 18 deletions(-)
Duyck
PATCH 4/11 i40e/i40evf: always set the CLEARPBA flag when re-enabling interrupts
Quoted 31 lines · AndrewX
Quoted 22 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On Behalf Of Alice Michael
Sent: Thursday, September 7, 2017 5:06 AM
To: Michael, Alice <[email protected]>; intel-wired-
lan at lists.osuosl.org
Subject: [Intel-wired-lan] [next PATCH S80-V3 04/11] i40e/i40evf: always set the CLEARPBA flag when re-enabling interruptsFrom: Jacob Keller <[email protected]>
In the past we changed driver behavior to not clear the PBA when re- enabling interrupts. This change was motivated by the flawed belief that clearing the PBA would cause a lost interrupt if a receive interrupt occurred while interrupts were disabled.
According to empirical testing this isn't the case. Additionally, the data sheet specifically says that we should set the CLEARPBA bit when re-enabling interrupts in a polling setup.
This reverts commit
40d72a509862("i40e/i40evf: don't lose interrupts")Quoted 8 lines
Signed-off-by Jacob Keller <[email protected]>--- drivers/net/ethernet/intel/i40e/i40e.h | 5 +---- drivers/net/ethernet/intel/i40e/i40e_main.c | 11 +++++------ drivers/net/ethernet/intel/i40e/i40e_txrx.c | 6 ++---- drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c | 2 +- drivers/net/ethernet/intel/i40evf/i40e_txrx.c | 4 +--- 5 files changed, 10 insertions(+), 18 deletions(-)
Quoted 2 lines
Tested-by Andrew Bowers <[email protected]>
This patch just got pointed out to me in a hallway conversation.
I am pretty sure this _will_ cause you to lose interrupts. Specifically you shouldn't be clearing the PBA bit at the end of the polling routine unless you know you are going to poll again.
The PBA bit should only be cleared if:
1. You are at the start of your clean-up routine and want to clear it in case any additional work has come in since the original vector fired. (currently handled via an auto-clear function for MSI-X)
2. You are at the end of your polling routine and you know you are going to be polling again.
The original patch was more aggressive than it needed to be. For example you could probably go ahead and clear the PBA in the i40e_intr()q interrupt routine itself since all it is doing is scheduling the polling routine which will run after the interrupt routine has completed. You shouldn't be clearing the PBA at the end of NAPI poll unless you know you are not going to be exiting polling.
I hope this helps to clarify things.
- Alex
Keller
PATCH 4/11 i40e/i40evf: always set the CLEARPBA flag when re-enabling interrupts
Quoted 66 lines
-----Original Message-----
From: Duyck, Alexander H
Sent: Thursday, October 05, 2017 11:32 AM
To: Keller, Jacob E <[email protected]>
Cc: Bowers, AndrewX <[email protected]>; intel-wired-
lan at lists.osuosl.org
Subject: Re: [Intel-wired-lan] [next PATCH S80-V3 04/11] i40e/i40evf: always set the CLEARPBA flag when re-enabling interruptsQuoted 31 lines · AndrewX
Quoted 22 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On Behalf Of Alice Michael
Sent: Thursday, September 7, 2017 5:06 AM
To: Michael, Alice <[email protected]>; intel-wired-
lan at lists.osuosl.org
Subject: [Intel-wired-lan] [next PATCH S80-V3 04/11] i40e/i40evf: always set the CLEARPBA flag when re-enabling interruptsFrom: Jacob Keller <[email protected]>
In the past we changed driver behavior to not clear the PBA when re- enabling interrupts. This change was motivated by the flawed belief that clearing the PBA would cause a lost interrupt if a receive interrupt occurred while interrupts were disabled.
According to empirical testing this isn't the case. Additionally, the data sheet specifically says that we should set the CLEARPBA bit when re-enabling interrupts in a polling setup.
This reverts commit
40d72a509862("i40e/i40evf: don't lose interrupts")Quoted 8 lines
Signed-off-by Jacob Keller <[email protected]>--- drivers/net/ethernet/intel/i40e/i40e.h | 5 +---- drivers/net/ethernet/intel/i40e/i40e_main.c | 11 +++++------ drivers/net/ethernet/intel/i40e/i40e_txrx.c | 6 ++---- drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c | 2 +- drivers/net/ethernet/intel/i40evf/i40e_txrx.c | 4 +--- 5 files changed, 10 insertions(+), 18 deletions(-)Quoted 2 lines
Tested-by Andrew Bowers <[email protected]>This patch just got pointed out to me in a hallway conversation.
I am pretty sure this _will_ cause you to lose interrupts. Specifically you shouldn't be clearing the PBA bit at the end of the polling routine unless you know you are going to poll again.
The PBA bit should only be cleared if:
1. You are at the start of your clean-up routine and want to clear it in case any additional work has come in since the original vector fired. (currently handled via an auto-clear function for MSI-X)
2. You are at the end of your polling routine and you know you are going to be polling again.The original patch was more aggressive than it needed to be. For example you could probably go ahead and clear the PBA in the i40e_intr()q interrupt routine itself since all it is doing is scheduling the polling routine which will run after the interrupt routine has completed. You shouldn't be clearing the PBA at the end of NAPI poll unless you know you are not going to be exiting polling.
Quoted 3 lines
I hope this helps to clarify things.
- Alex
Ok so only clear it if we're continuing to poll. I'll cook up a patch for that.
Thanks,
Jake
PATCH 4/11 i40e/i40evf: always set the CLEARPBA flag when re-enabling interrupts
Quoted 7 lines · Jacob E
Quoted 7 lines
The original patch was more aggressive than it needed to be. For example you could probably go ahead and clear the PBA in the i40e_intr()q interrupt routine itself since all it is doing is scheduling the polling routine which will run after the interrupt routine has completed. You shouldn't be clearing the PBA at the end of NAPI poll unless you know you are not going to be exiting polling.
Quoted 5 lines
Quoted 3 lines
I hope this helps to clarify things.
- Alex
Ok so only clear it if we're continuing to poll. I'll cook up a patch for that.
Hi Jake, we may just need to cook up a better test for this instead of generating further patches. I believe based on updated understanding of the hardware functionality that this patch is correct, but it is difficult to prove and we should probably spend more time doing the actual proof.
At least this patch follow the actual directions in the hardware manual, so I think we should stick with it.
Jesse
Keller
PATCH 4/11 i40e/i40evf: always set the CLEARPBA flag when re-enabling interrupts
Quoted 31 lines
-----Original Message-----
From: Brandeburg, Jesse
Sent: Thursday, October 05, 2017 4:01 PM
To: Keller, Jacob E <[email protected]>
Cc: Duyck, Alexander H <[email protected]>; intel-wired- lan at lists.osuosl.org; Brandeburg, Jesse <[email protected]>
Subject: Re: [Intel-wired-lan] [next PATCH S80-V3 04/11] i40e/i40evf: always set the CLEARPBA flag when re-enabling interruptsQuoted 7 lines · Jacob E
Quoted 7 lines
The original patch was more aggressive than it needed to be. For example you could probably go ahead and clear the PBA in the i40e_intr()q interrupt routine itself since all it is doing is scheduling the polling routine which will run after the interrupt routine has completed. You shouldn't be clearing the PBA at the end of NAPI poll unless you know you are not going to be exiting polling.
Quoted 5 lines
Quoted 3 lines
I hope this helps to clarify things.
- Alex
Ok so only clear it if we're continuing to poll. I'll cook up a patch for that.
Hi Jake, we may just need to cook up a better test for this instead of generating further patches. I believe based on updated understanding of the hardware functionality that this patch is correct, but it is difficult to prove and we should probably spend more time doing the actual proof.
Quoted 4 lines
At least this patch follow the actual directions in the hardware manual, so I think we should stick with it.
Jesse
Ok. Lets continue the discussion in person to make sure everyone's on the same page and understanding.
I think I agree that we should keep this patch as is since it's based on the directions in our hardware manual.
Regards,
Jake
PATCH 5/11 i40e: reduce lrxqthresh from 2 to 1
In reply to Alice MichaelFrom: Jacob Keller <[email protected]>
The lrxq thresh value tells hardware to immediately interrupt when there are fewer than N*64 packets left in the ring.
Counter intuitively, empirical testing has shown that decreasing this value from 2 to 1, and thus changing from an immediate interrupt at fewer than 128 descriptors down to 64 descriptors causes a small increase in the maximum total packets per second we can receive. This increase occurs even when we're polling with interrupts masked, as the hardware must still handle interrupts internally even if we've disabled them in software.
Also reduce the value for any VFs we allocate.
--- drivers/net/ethernet/intel/i40e/i40e_main.c | 2 +- drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/i40e/i40e_main.c +1 -1
@@ -3030,7 +3030,7 @@ static int i40e_configure_rx_ring(struct i40e_ring *ring)if (hw->revision_id ==0 ) rx_ctx.lrxqthresh =0 ;else - rx_ctx.lrxqthresh =2 ; + rx_ctx.lrxqthresh =1 ; rx_ctx.crcstrip =1 ; rx_ctx.l2tsel =1 ;/* this controls whether VLAN is stripped from inner headers */
drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c +1 -1
@@ -636,7 +636,7 @@ static int i40e_config_vsi_rx_queue(struct i40e_vf *vf, u16 vsi_id, rx_ctx.dsize =1 ;/* default values */ - rx_ctx.lrxqthresh =2 ; + rx_ctx.lrxqthresh =1 ; rx_ctx.crcstrip =1 ; rx_ctx.prefena =1 ; rx_ctx.l2tsel =1 ;
Signature · 1 line
2.9.4
Bowers
PATCH 5/11 i40e: reduce lrxqthresh from 2 to 1
Quoted 21 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On Behalf Of Alice Michael
Sent: Thursday, September 7, 2017 5:06 AM
To: Michael, Alice <[email protected]>; intel-wired-
lan at lists.osuosl.org
Subject: [Intel-wired-lan] [next PATCH S80-V3 05/11] i40e: reduce lrxqthresh from 2 to 1From: Jacob Keller <[email protected]>
The lrxq thresh value tells hardware to immediately interrupt when there are fewer than N*64 packets left in the ring.
Counter intuitively, empirical testing has shown that decreasing this value from 2 to 1, and thus changing from an immediate interrupt at fewer than 128 descriptors down to 64 descriptors causes a small increase in the maximum total packets per second we can receive. This increase occurs even when we're polling with interrupts masked, as the hardware must still handle interrupts internally even if we've disabled them in software.
Quoted 7 lines
Also reduce the value for any VFs we allocate.
Signed-off-by Jacob Keller <[email protected]>--- drivers/net/ethernet/intel/i40e/i40e_main.c | 2 +- drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
PATCH 6/11 i40e/i40evf: bump tail only in multiples of 8
In reply to Alice MichaelFrom: Jacob Keller <[email protected]>
Hardware only fetches descriptors on cachelines of 8, essentially ignoring the lower 3 bits of the tail register. Thus, it is pointless to bump tail by an unaligned access as the hardware will ignore some of the new descriptors we allocated. Thus, it's ideal if we can ensure tail writes are always aligned to 8.
At first, it seems like we'd already do this, since we allocate descriptors in batches which are a multiple of 8. Since we'd always increment by a multiple of 8, it seems like the value should always be aligned.
However, this ignores allocation failures. If we fail to allocate a buffer, our tail register will become unaligned. Once it has become unaligned it will essentially be stuck unaligned until a buffer allocation happens to fail at the exact amount necessary to re-align it.
We can do better, by simply rounding down the number of buffers we're about to allocate (cleaned_count) such that "next_to_clean
+ cleaned_count" is rounded to the nearest multiple of 8.
We do this by calculating how far off that value is and subtracting it from the cleaned_count. This essentially defers allocation of buffers if they're going to be ignored by hardware anyways, and re-aligns our next_to_use and tail values after a failure to allocate a descriptor.
This calculation ensures that we always align the tail writes in a way the hardware expects and don't unnecessarily allocate buffers which won't be fetched immediately.
--- drivers/net/ethernet/intel/i40e/i40e_txrx.c | 9 +++++++++ drivers/net/ethernet/intel/i40evf/i40e_txrx.c | 9 +++++++++ 2 files changed, 18 insertions(+)
drivers/net/ethernet/intel/i40e/i40e_txrx.c +9 -0
@@ -1372,6 +1372,15 @@ bool i40e_alloc_rx_buffers(struct i40e_ring *rx_ring, u16 cleaned_count)union i40e_rx_desc *rx_desc;struct i40e_rx_buffer *bi; +/* Hardware only fetches new descriptors in cache lines of 8, +* essentially ignoring the lower 3 bits of the tail register. We want +* to ensure our tail writes are aligned to avoid unnecessary work. We +* can't simply round down the cleaned count, since we might fail to +* allocate some buffers. What we really want is to ensure that +* next_to_used + cleaned_count produces an aligned value. +*/ + cleaned_count -= (ntu + cleaned_count) &0x7 ; +/* do nothing if no valid netdev defined */ if (!rx_ring->netdev || !cleaned_count)return false;
drivers/net/ethernet/intel/i40evf/i40e_txrx.c +9 -0
@@ -711,6 +711,15 @@ bool i40evf_alloc_rx_buffers(struct i40e_ring *rx_ring, u16 cleaned_count)union i40e_rx_desc *rx_desc;struct i40e_rx_buffer *bi; +/* Hardware only fetches new descriptors in cache lines of 8, +* essentially ignoring the lower 3 bits of the tail register. We want +* to ensure our tail writes are aligned to avoid unnecessary work. We +* can't simply round down the cleaned count, since we might fail to +* allocate some buffers. What we really want is to ensure that +* next_to_used + cleaned_count produces an aligned value. +*/ + cleaned_count -= (ntu + cleaned_count) &0x7 ; +/* do nothing if no valid netdev defined */ if (!rx_ring->netdev || !cleaned_count)return false;
Signature · 1 line
2.9.4
Bowers
PATCH 6/11 i40e/i40evf: bump tail only in multiples of 8
Quoted 38 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On Behalf Of Alice Michael
Sent: Thursday, September 7, 2017 5:06 AM
To: Michael, Alice <[email protected]>; intel-wired-
lan at lists.osuosl.org
Subject: [Intel-wired-lan] [next PATCH S80-V3 06/11] i40e/i40evf: bump tail only in multiples of 8From: Jacob Keller <[email protected]>
Hardware only fetches descriptors on cachelines of 8, essentially ignoring the lower 3 bits of the tail register. Thus, it is pointless to bump tail by an unaligned access as the hardware will ignore some of the new descriptors we allocated. Thus, it's ideal if we can ensure tail writes are always aligned to 8.
At first, it seems like we'd already do this, since we allocate descriptors in batches which are a multiple of 8. Since we'd always increment by a multiple of 8, it seems like the value should always be aligned.
However, this ignores allocation failures. If we fail to allocate a buffer, our tail register will become unaligned. Once it has become unaligned it will essentially be stuck unaligned until a buffer allocation happens to fail at the exact amount necessary to re-align it.
We can do better, by simply rounding down the number of buffers we're about to allocate (
cleaned_count) such that "next_to_clean
+cleaned_count" is rounded to the nearest multiple of 8.We do this by calculating how far off that value is and subtracting it from the
cleaned_count. This essentially defers allocation of buffers if they're going to be ignored by hardware anyways, and re-aligns ournext_to_useand tail values after a failure to allocate a descriptor.This calculation ensures that we always align the tail writes in a way the hardware expects and don't unnecessarily allocate buffers which won't be fetched immediately.
Quoted 5 lines
Signed-off-by Jacob Keller <[email protected]>--- drivers/net/ethernet/intel/i40e/i40e_txrx.c | 9 +++++++++ drivers/net/ethernet/intel/i40evf/i40e_txrx.c | 9 +++++++++ 2 files changed, 18 insertions(+)
PATCH 7/11 i40e/i40evf: bundle more descriptors when allocating buffers
In reply to Alice MichaelFrom: Jacob Keller <[email protected]>
Double the number of descriptors we'll bundle into one tail bump when receiving. Empirical testing has shown that we reduce CPU utilization and don't appear to reduce throughput or packet rate. 32 seems to be the sweet spot, as it's half the default polling budget, so we'd essentially reduce from 4 tail writes when polling down to 2. Increasing this up to 64 appears to have negative impacts as it may become possible that we don't bump the tail each time we get polled, which could cause a long delay between returning descriptors to the hardware.
--- drivers/net/ethernet/intel/i40e/i40e_txrx.h | 2 +- drivers/net/ethernet/intel/i40evf/i40e_txrx.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/i40e/i40e_txrx.h +1 -1
@@ -208,7 +208,7 @@ static inline bool i40e_test_staterr(union i40e_rx_desc *rx_desc, }/* How many Rx Buffers do we bundle into one write to the hardware ? */ -#define I40E_RX_BUFFER_WRITE 16/* Must be power of 2 */ +#define I40E_RX_BUFFER_WRITE 32/* Must be power of 2 */ #define I40E_RX_INCREMENT (r, i) \ do { \ (i)++; \
drivers/net/ethernet/intel/i40evf/i40e_txrx.h +1 -1
@@ -191,7 +191,7 @@ static inline bool i40e_test_staterr(union i40e_rx_desc *rx_desc, }/* How many Rx Buffers do we bundle into one write to the hardware ? */ -#define I40E_RX_BUFFER_WRITE 16/* Must be power of 2 */ +#define I40E_RX_BUFFER_WRITE 32/* Must be power of 2 */ #define I40E_RX_INCREMENT (r, i) \ do { \ (i)++; \
Signature · 1 line
2.9.4
Bowers
PATCH 7/11 i40e/i40evf: bundle more descriptors when allocating buffers
Quoted 20 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On Behalf Of Alice Michael
Sent: Thursday, September 7, 2017 5:06 AM
To: Michael, Alice <[email protected]>; intel-wired- lan at lists.osuosl.org
Subject: [Intel-wired-lan] [next PATCH S80-V3 07/11] i40e/i40evf: bundle more descriptors when allocating buffersFrom: Jacob Keller <[email protected]>
Double the number of descriptors we'll bundle into one tail bump when receiving. Empirical testing has shown that we reduce CPU utilization and don't appear to reduce throughput or packet rate. 32 seems to be the sweet spot, as it's half the default polling budget, so we'd essentially reduce from 4 tail writes when polling down to 2. Increasing this up to
64 appears to have negative impacts as it may become possible that we don't bump the tail each time we get polled, which could cause a long delay between returning descriptors to the hardware.
Quoted 5 lines
Signed-off-by Jacob Keller <[email protected]>--- drivers/net/ethernet/intel/i40e/i40e_txrx.h | 2 +- drivers/net/ethernet/intel/i40evf/i40e_txrx.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
PATCH 8/11 i40e: allow XPS with QoS enabled
In reply to Alice MichaelFrom: Jacob Keller <[email protected]>
Recently, the kernel gained support for enabling XPS and QoS at the same time. Thus, we no longer need to worry about the number of traffic classes when enabling XPS.
--- drivers/net/ethernet/intel/i40e/i40e_main.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-)
drivers/net/ethernet/intel/i40e/i40e_main.c +6 -11
@@ -2879,23 +2879,18 @@ static void i40e_vsi_free_rx_resources(struct i40e_vsi *vsi)**/ static void i40e_config_xps_tx_ring (struct i40e_ring *ring) { -struct i40e_vsi *vsi = ring->vsi;int cpu;if (!ring->q_vector || !ring->netdev)return ; -if ((vsi->tc_config.numtc <=1 ) && - !test_and_set_bit (__I40E_TX_XPS_INIT_DONE, ring->state)) { - cpu =cpumask_local_spread (ring->q_vector->v_idx,-1 ); -netif_set_xps_queue (ring->netdev,get_cpu_mask (cpu), - ring->queue_index); - } +/* We only initialize XPS once, so as not to overwrite user settings */ +if (test_and_set_bit (__I40E_TX_XPS_INIT_DONE, ring->state)) +return ; -/* schedule our worker thread which will take care of -* applying the new filter changes -*/ -i40e_service_event_schedule (vsi->back); + cpu =cpumask_local_spread (ring->q_vector->v_idx,-1 ); +netif_set_xps_queue (ring->netdev,get_cpu_mask (cpu), + ring->queue_index); }/**
Signature · 1 line
2.9.4
Bowers
PATCH 8/11 i40e: allow XPS with QoS enabled
Quoted 11 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On Behalf Of Alice Michael
Sent: Thursday, September 7, 2017 5:06 AM
To: Michael, Alice <[email protected]>; intel-wired- lan at lists.osuosl.org
Subject: [Intel-wired-lan] [next PATCH S80-V3 08/11] i40e: allow XPS with QoS enabledFrom: Jacob Keller <[email protected]>
Quoted 8 lines
Recently, the kernel gained support for enabling XPS and QoS at the same time. Thus, we no longer need to worry about the number of traffic classes when enabling XPS.
Signed-off-by Jacob Keller <[email protected]>--- drivers/net/ethernet/intel/i40e/i40e_main.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-)
PATCH 9/11 i40e: add check for return from find_first_bit call
In reply to Alice MichaelFrom: Lihong Yang <[email protected]>
The find_first_bit function will return the size passed to search if the first set bit is not found. This patch adds the check in case that happens as the return value would be used as the index in an array and that would have caused the out-of-bounds access.
Detected by CoverityScan, CID 1295969 Out-of-bounds access
--- drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c +4 -0
@@ -306,6 +306,10 @@ static void i40e_config_irq_link_list(struct i40e_vf *vf, u16 vsi_id, next_q =find_first_bit (&linklistmap, (I40E_MAX_VSI_QP *I40E_VIRTCHNL_SUPPORTED_QTYPES )); +if (unlikely (next_q == (I40E_MAX_VSI_QP * +I40E_VIRTCHNL_SUPPORTED_QTYPES ))) + goto irq_list_done; + vsi_queue_id = next_q /I40E_VIRTCHNL_SUPPORTED_QTYPES ; qtype = next_q %I40E_VIRTCHNL_SUPPORTED_QTYPES ; pf_queue_id =i40e_vc_get_pf_queue_id (vf, vsi_id, vsi_queue_id);
Signature · 1 line
2.9.4
Bowers
PATCH 9/11 i40e: add check for return from find_first_bit call
Quoted 16 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On Behalf Of Alice Michael
Sent: Thursday, September 7, 2017 5:06 AM
To: Michael, Alice <[email protected]>; intel-wired- lan at lists.osuosl.org
Subject: [Intel-wired-lan] [next PATCH S80-V3 09/11] i40e: add check for return fromfind_first_bitcallFrom: Lihong Yang <[email protected]>
The
find_first_bitfunction will return the size passed to search if the first set bit is not found. This patch adds the check in case that happens as the return value would be used as the index in an array and that would have caused the out-of-bounds access.
Quoted 6 lines
Detected by CoverityScan, CID 1295969 Out-of-bounds access
Signed-off-by Lihong Yang <[email protected]>--- drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c | 4 ++++ 1 file changed, 4 insertions(+)
PATCH 10/11 i40e: Retry AQC GetPhyAbilities to overcome I2CRead hangs
In reply to Alice MichaelFrom: Jayaprakash Shanmugam <[email protected]>
- When the I2C is busy, the PHY reads are delayed. The firmware will return EGAIN in these cases with an expectation that the SW will trigger the reads again
- This patch retries the operation for a maximum period of 500ms
--- drivers/net/ethernet/intel/i40e/i40e_common.c | 42 ++++++++++++++++++--------- drivers/net/ethernet/intel/i40e/i40e_type.h | 3 ++ drivers/net/ethernet/intel/i40evf/i40e_type.h | 3 ++ 3 files changed, 35 insertions(+), 13 deletions(-)
drivers/net/ethernet/intel/i40e/i40e_common.c +29 -13
@@ -1567,30 +1567,46 @@ i40e_status i40e_aq_get_phy_capabilities(struct i40e_hw *hw,struct i40e_aq_desc desc;i40e_status status;u16 abilities_size =sizeof (struct i40e_aq_get_phy_abilities_resp ); +u16 max_delay =I40E_MAX_PHY_TIMEOUT , total_delay =0 ;if (!abilities)return I40E_ERR_PARAM ; -i40e_fill_default_direct_cmd_desc (&desc, - i40e_aqc_opc_get_phy_abilities); +do { +i40e_fill_default_direct_cmd_desc (&desc, + i40e_aqc_opc_get_phy_abilities); - desc.flags |=cpu_to_le16 ((u16 )I40E_AQ_FLAG_BUF ); -if (abilities_size >I40E_AQ_LARGE_BUF ) - desc.flags |=cpu_to_le16 ((u16 )I40E_AQ_FLAG_LB ); + desc.flags |=cpu_to_le16 ((u16 )I40E_AQ_FLAG_BUF ); +if (abilities_size >I40E_AQ_LARGE_BUF ) + desc.flags |=cpu_to_le16 ((u16 )I40E_AQ_FLAG_LB ); -if (qualified_modules) - desc.params.external.param0 |= +if (qualified_modules) + desc.params.external.param0 |=cpu_to_le32 (I40E_AQ_PHY_REPORT_QUALIFIED_MODULES ); -if (report_init) - desc.params.external.param0 |= +if (report_init) + desc.params.external.param0 |=cpu_to_le32 (I40E_AQ_PHY_REPORT_INITIAL_VALUES ); - status =i40e_asq_send_command (hw, &desc, abilities, abilities_size, - cmd_details); + status =i40e_asq_send_command (hw, &desc, abilities, + abilities_size, cmd_details); -if (hw->aq.asq_last_status ==I40E_AQ_RC_EIO ) - status =I40E_ERR_UNKNOWN_PHY ; +if (status) +break ; + +if (hw->aq.asq_last_status ==I40E_AQ_RC_EIO ) { + status =I40E_ERR_UNKNOWN_PHY ; +break ; + }else if (hw->aq.asq_last_status ==I40E_AQ_RC_EAGAIN ) { +usleep_range (1000 ,2000 ); + total_delay++; + status =I40E_ERR_TIMEOUT ; + } + }while ((hw->aq.asq_last_status !=I40E_AQ_RC_OK ) && + (total_delay < max_delay)); + +if (status) +return status;if (report_init) { if (hw->mac.type == I40E_MAC_XL710 &&
drivers/net/ethernet/intel/i40e/i40e_type.h +3 -0
@@ -46,6 +46,9 @@/* Max default timeout in ms, */ #define I40E_MAX_NVM_TIMEOUT 18000 +/* Max timeout in ms for the phy to respond */ +#define I40E_MAX_PHY_TIMEOUT 500 +/* Switch from ms to the 1usec global time (this is the GTIME resolution) */ #define I40E_MS_TO_GTIME (time) ((time) * 1000)
drivers/net/ethernet/intel/i40evf/i40e_type.h +3 -0
@@ -46,6 +46,9 @@/* Max default timeout in ms, */ #define I40E_MAX_NVM_TIMEOUT 18000 +/* Max timeout in ms for the phy to respond */ +#define I40E_MAX_PHY_TIMEOUT 500 +/* Switch from ms to the 1usec global time (this is the GTIME resolution) */ #define I40E_MS_TO_GTIME (time) ((time) * 1000)
Signature · 1 line
2.9.4
Bowers
PATCH 10/11 i40e: Retry AQC GetPhyAbilities to overcome I2CRead hangs
Quoted 16 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On Behalf Of Alice Michael
Sent: Thursday, September 7, 2017 5:06 AM
To: Michael, Alice <[email protected]>; intel-wired- lan at lists.osuosl.org
Subject: [Intel-wired-lan] [next PATCH S80-V3 10/11] i40e: Retry AQC GetPhyAbilities to overcome I2CRead hangsFrom: Jayaprakash Shanmugam <[email protected]>
- When the I2C is busy, the PHY reads are delayed. The firmware will return EGAIN in these cases with an expectation that the SW will trigger the reads again
- This patch retries the operation for a maximum period of 500ms
Quoted 8 lines
Signed-off-by: Jayaprakash Shanmugam
<[email protected]>--- drivers/net/ethernet/intel/i40e/i40e_common.c | 42 ++++++++++++++++++--------- drivers/net/ethernet/intel/i40e/i40e_type.h | 3 ++ drivers/net/ethernet/intel/i40evf/i40e_type.h | 3 ++ 3 files changed, 35 insertions(+), 13 deletions(-)
PATCH 11/11 i40e: use a local variable instead of calculating multiple times
In reply to Alice MichaelFrom: Lihong Yang <[email protected]>
The computed result of I40E_MAX_VSI_QP * I40E_VIRTCHNL_SUPPORTED_QTYPES is used more than three times in function i40e_config_irq_link_list. Simply declare a local variable to store it to improve readability.
--- drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-)
drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c +7 -13
@@ -273,7 +273,7 @@ static void i40e_config_irq_link_list(struct i40e_vf *vf, u16 vsi_id,struct i40e_hw *hw = &pf->hw;u16 vsi_queue_id, pf_queue_id;enum i40e_queue_type qtype; -u16 next_q, vector_id; +u16 next_q, vector_id, size;u32 reg, reg_idx;u16 itr_idx =0 ;
@@ -303,11 +303,9 @@ static void i40e_config_irq_link_list(struct i40e_vf *vf, u16 vsi_id, vsi_queue_id + 1)); } - next_q =find_first_bit (&linklistmap, - (I40E_MAX_VSI_QP * -I40E_VIRTCHNL_SUPPORTED_QTYPES )); -if (unlikely (next_q == (I40E_MAX_VSI_QP * -I40E_VIRTCHNL_SUPPORTED_QTYPES ))) + size =I40E_MAX_VSI_QP *I40E_VIRTCHNL_SUPPORTED_QTYPES ; + next_q =find_first_bit (&linklistmap, size); +if (unlikely (next_q == size)) goto irq_list_done; vsi_queue_id = next_q /I40E_VIRTCHNL_SUPPORTED_QTYPES ;
@@ -317,7 +315,7 @@ static void i40e_config_irq_link_list(struct i40e_vf *vf, u16 vsi_id,wr32 (hw, reg_idx, reg); -while (next_q < (I40E_MAX_VSI_QP *I40E_VIRTCHNL_SUPPORTED_QTYPES )) { +while (next_q < size) {switch (qtype) {case I40E_QUEUE_TYPE_RX : reg_idx =I40E_QINT_RQCTL (pf_queue_id);
@@ -331,12 +329,8 @@ static void i40e_config_irq_link_list(struct i40e_vf *vf, u16 vsi_id,break ; } - next_q =find_next_bit (&linklistmap, - (I40E_MAX_VSI_QP * -I40E_VIRTCHNL_SUPPORTED_QTYPES ), - next_q +1 ); -if (next_q < - (I40E_MAX_VSI_QP *I40E_VIRTCHNL_SUPPORTED_QTYPES )) { + next_q =find_next_bit (&linklistmap, size, next_q +1 ); +if (next_q < size) { vsi_queue_id = next_q /I40E_VIRTCHNL_SUPPORTED_QTYPES ; qtype = next_q %I40E_VIRTCHNL_SUPPORTED_QTYPES ; pf_queue_id = i40e_vc_get_pf_queue_id(vf, vsi_id,
Signature · 1 line
2.9.4
Bowers
PATCH 11/11 i40e: use a local variable instead of calculating multiple times
Quoted 16 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On Behalf Of Alice Michael
Sent: Thursday, September 7, 2017 5:06 AM
To: Michael, Alice <[email protected]>; intel-wired-
lan at lists.osuosl.org
Subject: [Intel-wired-lan] [next PATCH S80-V3 11/11] i40e: use a local variable instead of calculating multiple timesFrom: Lihong Yang <[email protected]>
The computed result of
I40E_MAX_VSI_QP*I40E_VIRTCHNL_SUPPORTED_QTYPESis used more than three times in functioni40e_config_irq_link_list.
Simply declare a local variable to store it to improve readability.
Quoted 4 lines
Signed-off-by Lihong Yang <[email protected]>--- drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-)
Bowers
PATCH 1/11 i40e: use the safe hash table iterator when deleting mac filters
In reply to Alice MichaelQuoted 16 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On Behalf Of Alice Michael
Sent: Thursday, September 7, 2017 5:06 AM
To: Michael, Alice <[email protected]>; intel-wired-
lan at lists.osuosl.org
Subject: [Intel-wired-lan] [next PATCH S80-V3 01/11] i40e: use the safe hash table iterator when deleting mac filtersFrom: Lihong Yang <[email protected]>
This patch replaces
hash_for_eachfunction withhash_for_each_safewhen calling__i40e_del_filter. Thehash_for_each_safefunction is the right one to use when iterating over a hash table to safely remove a hash entry. Otherwise, incorrect values may be read from freed memory.
Quoted 6 lines
Detected by CoverityScan, CID 1402048 Read from pointer after free
Signed-off-by Lihong Yang <[email protected]>--- drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)