i40e/i40evf: Use usec value instead of reg value for ITR defines
Subsystems (2)
PATCH 11/14 i40e/i40evf: Use usec value instead of reg value for ITR defines
From: Alexander Duyck <[email protected]>
Instead of using the register value for the defines when setting up the ring ITR we can just use the actual values and avoid the use of shifts and macros to translate between the values we have and the values we want.
This helps to make the code more readable as we can quickly translate from one value to the other.
--- drivers/net/ethernet/intel/i40e/i40e_ethtool.c | 12 +++--- drivers/net/ethernet/intel/i40e/i40e_txrx.c | 11 +++++- drivers/net/ethernet/intel/i40e/i40e_txrx.h | 45 ++++++++++++---------- drivers/net/ethernet/intel/i40evf/i40e_txrx.c | 11 +++++- drivers/net/ethernet/intel/i40evf/i40e_txrx.h | 44 +++++++++++---------- drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c | 12 +++--- 6 files changed, 79 insertions(+), 56 deletions(-)
drivers/net/ethernet/intel/i40e/i40e_ethtool.c +6 -6
@@ -2315,8 +2315,8 @@ static void i40e_set_itr_per_queue(struct i40e_vsi *vsi, intrl =i40e_intrl_usec_to_reg (vsi->int_rate_limit); - rx_ring->itr_setting = ec->rx_coalesce_usecs; - tx_ring->itr_setting = ec->tx_coalesce_usecs; + rx_ring->itr_setting =ITR_REG_ALIGN (ec->rx_coalesce_usecs); + tx_ring->itr_setting =ITR_REG_ALIGN (ec->tx_coalesce_usecs);if (ec->use_adaptive_rx_coalesce) rx_ring->itr_setting |=I40E_ITR_DYNAMIC ;
@@ -2396,7 +2396,7 @@ static int __i40e_set_coalesce(struct net_device *netdev,return -EINVAL ; } -if (ec->rx_coalesce_usecs > (I40E_MAX_ITR <<1 )) { +if (ec->rx_coalesce_usecs >I40E_MAX_ITR ) {netif_info (pf, drv, netdev,"Invalid value, rx-usecs range is 0-8160\n" );return -EINVAL ; }
@@ -2407,16 +2407,16 @@ static int __i40e_set_coalesce(struct net_device *netdev,return -EINVAL ; } -if (ec->tx_coalesce_usecs > (I40E_MAX_ITR <<1 )) { +if (ec->tx_coalesce_usecs >I40E_MAX_ITR ) {netif_info (pf, drv, netdev,"Invalid value, tx-usecs range is 0-8160\n" );return -EINVAL ; }if (ec->use_adaptive_rx_coalesce && !cur_rx_itr) - ec->rx_coalesce_usecs =I40E_MIN_ITR <<1 ; + ec->rx_coalesce_usecs =I40E_MIN_ITR ;if (ec->use_adaptive_tx_coalesce && !cur_tx_itr) - ec->tx_coalesce_usecs =I40E_MIN_ITR <<1 ; + ec->tx_coalesce_usecs =I40E_MIN_ITR ; intrl_reg =i40e_intrl_usec_to_reg (ec->rx_coalesce_usecs_high); vsi->int_rate_limit =INTRL_REG_TO_USEC (intrl_reg);
drivers/net/ethernet/intel/i40e/i40e_txrx.c +9 -2
@@ -2263,7 +2263,7 @@ static int i40e_clean_rx_irq(struct i40e_ring *rx_ring, int budget)return failure ? budget : (int )total_rx_packets; } -static u32 i40e_buildreg_itr (const int type,const u16 itr) +static inline u32 i40e_buildreg_itr (const int type,u16 itr) {u32 val;
@@ -2276,10 +2276,17 @@ static u32 i40e_buildreg_itr(const int type, const u16 itr)* xxINT_DYN_CTLx CSR with INTENA_MSK (bit 31) set to 0 will clear * an event in the PBA anyway so we need to rely on the automask * to hold pending events for us until the interrupt is re-enabled +* +* The itr value is reported in microseconds, and the register +* value is recorded in 2 microsecond units. For this reason we +* only need to shift by the interval shift - 1 instead of the +* full value. */ + itr &=I40E_ITR_MASK ; + val =I40E_PFINT_DYN_CTLN_INTENA_MASK | (type <<I40E_PFINT_DYN_CTLN_ITR_INDX_SHIFT ) | - (itr <<I40E_PFINT_DYN_CTLN_INTERVAL_SHIFT ); + (itr << (I40E_PFINT_DYN_CTLN_INTERVAL_SHIFT -1 ));return val; }
drivers/net/ethernet/intel/i40e/i40e_txrx.h +25 -20
57 lines not on this page · raw message
drivers/net/ethernet/intel/i40evf/i40e_txrx.c +9 -2
@@ -1460,7 +1460,7 @@ static int i40e_clean_rx_irq(struct i40e_ring *rx_ring, int budget)return failure ? budget : (int )total_rx_packets; } -static u32 i40e_buildreg_itr (const int type,const u16 itr) +static inline u32 i40e_buildreg_itr (const int type,u16 itr) {u32 val;
@@ -1473,10 +1473,17 @@ static u32 i40e_buildreg_itr(const int type, const u16 itr)* xxINT_DYN_CTLx CSR with INTENA_MSK (bit 31) set to 0 will clear * an event in the PBA anyway so we need to rely on the automask * to hold pending events for us until the interrupt is re-enabled +* +* The itr value is reported in microseconds, and the register +* value is recorded in 2 microsecond units. For this reason we +* only need to shift by the interval shift - 1 instead of the +* full value. */ + itr &=I40E_ITR_MASK ; + val =I40E_VFINT_DYN_CTLN1_INTENA_MASK | (type <<I40E_VFINT_DYN_CTLN1_ITR_INDX_SHIFT ) | - (itr <<I40E_VFINT_DYN_CTLN1_INTERVAL_SHIFT ); + (itr << (I40E_VFINT_DYN_CTLN1_INTERVAL_SHIFT -1 ));return val; }
drivers/net/ethernet/intel/i40evf/i40e_txrx.h +24 -20
55 lines not on this page · raw message
drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c +6 -6
@@ -517,8 +517,8 @@ static void i40evf_set_itr_per_queue(struct i40evf_adapter *adapter,struct i40e_hw *hw = &adapter->hw;struct i40e_q_vector *q_vector; - rx_ring->itr_setting = ec->rx_coalesce_usecs; - tx_ring->itr_setting = ec->tx_coalesce_usecs; + rx_ring->itr_setting =ITR_REG_ALIGN (ec->rx_coalesce_usecs); + tx_ring->itr_setting =ITR_REG_ALIGN (ec->tx_coalesce_usecs); rx_ring->itr_setting |=I40E_ITR_DYNAMIC ;if (!ec->use_adaptive_rx_coalesce)
@@ -563,8 +563,8 @@ static int __i40evf_set_coalesce(struct net_device *netdev,if (ec->rx_coalesce_usecs ==0 ) {if (ec->use_adaptive_rx_coalesce)netif_info (adapter, drv, netdev,"rx-usecs=0, need to disable adaptive-rx for a complete disable\n" ); - }else if ((ec->rx_coalesce_usecs < (I40E_MIN_ITR <<1 )) || - (ec->rx_coalesce_usecs > (I40E_MAX_ITR <<1 ))) { + }else if ((ec->rx_coalesce_usecs <I40E_MIN_ITR ) || + (ec->rx_coalesce_usecs >I40E_MAX_ITR )) {netif_info (adapter, drv, netdev,"Invalid value, rx-usecs range is 0-8160\n" );return -EINVAL ; }
@@ -573,8 +573,8 @@ static int __i40evf_set_coalesce(struct net_device *netdev,if (ec->tx_coalesce_usecs ==0 ) {if (ec->use_adaptive_tx_coalesce)netif_info (adapter, drv, netdev,"tx-usecs=0, need to disable adaptive-tx for a complete disable\n" ); - }else if ((ec->tx_coalesce_usecs < (I40E_MIN_ITR <<1 )) || - (ec->tx_coalesce_usecs > (I40E_MAX_ITR <<1 ))) { + }else if ((ec->tx_coalesce_usecs <I40E_MIN_ITR ) || + (ec->tx_coalesce_usecs >I40E_MAX_ITR )) {netif_info (adapter, drv, netdev,"Invalid value, tx-usecs range is 0-8160\n" );return -EINVAL ; }
Signature · 1 line
2.9.5
Bowers
PATCH 11/14 i40e/i40evf: Use usec value instead of reg value for ITR defines
Quoted 19 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On Behalf Of Alice Michael
Sent: Friday, December 29, 2017 5:51 AM
To: Michael, Alice <[email protected]>; intel-wired-
lan at lists.osuosl.org
Subject: [Intel-wired-lan] [next PATCH S85-V1 11/14] i40e/i40evf: Use usec value instead of reg value for ITR definesFrom: Alexander Duyck <[email protected]>
Instead of using the register value for the defines when setting up the ring ITR we can just use the actual values and avoid the use of shifts and macros to translate between the values we have and the values we want.
This helps to make the code more readable as we can quickly translate from one value to the other.
Signed-off-by Alexander Duyck <[email protected]>
Quoted 8 lines
--- drivers/net/ethernet/intel/i40e/i40e_ethtool.c | 12 +++--- drivers/net/ethernet/intel/i40e/i40e_txrx.c | 11 +++++- drivers/net/ethernet/intel/i40e/i40e_txrx.h | 45 ++++++++++++---------- drivers/net/ethernet/intel/i40evf/i40e_txrx.c | 11 +++++- drivers/net/ethernet/intel/i40evf/i40e_txrx.h | 44 +++++++++++---------- drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c | 12 +++--- 6 files changed, 79 insertions(+), 56 deletions(-)