i40e/i40evf: Use ring pointers to clean up _set_itr_per_queue
authorAlexander Duyck <alexander.h.duyck@intel.com>
Wed, 27 Dec 2017 13:15:51 +0000 (08:15 -0500)
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>
Fri, 26 Jan 2018 21:23:07 +0000 (13:23 -0800)
This change cleans up the i40e/i40evf_set_itr_per_queue function by
dropping all the unneeded pointer chases. Instead we can just pull out the
pointers for the Tx and Rx rings and use them throughout the function.

Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
drivers/net/ethernet/intel/i40e/i40e_ethtool.c
drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c

index 2cbd564e437ac03cf3ccd073d08be157aa470b34..dd6996e6539645074646d7deb71e4d25f1275016 100644 (file)
@@ -2305,6 +2305,8 @@ static void i40e_set_itr_per_queue(struct i40e_vsi *vsi,
                                   struct ethtool_coalesce *ec,
                                   int queue)
 {
+       struct i40e_ring *rx_ring = vsi->rx_rings[queue];
+       struct i40e_ring *tx_ring = vsi->tx_rings[queue];
        struct i40e_pf *pf = vsi->back;
        struct i40e_hw *hw = &pf->hw;
        struct i40e_q_vector *q_vector;
@@ -2312,26 +2314,26 @@ static void i40e_set_itr_per_queue(struct i40e_vsi *vsi,
 
        intrl = i40e_intrl_usec_to_reg(vsi->int_rate_limit);
 
-       vsi->rx_rings[queue]->rx_itr_setting = ec->rx_coalesce_usecs;
-       vsi->tx_rings[queue]->tx_itr_setting = ec->tx_coalesce_usecs;
+       rx_ring->rx_itr_setting = ec->rx_coalesce_usecs;
+       tx_ring->tx_itr_setting = ec->tx_coalesce_usecs;
 
        if (ec->use_adaptive_rx_coalesce)
-               vsi->rx_rings[queue]->rx_itr_setting |= I40E_ITR_DYNAMIC;
+               rx_ring->rx_itr_setting |= I40E_ITR_DYNAMIC;
        else
-               vsi->rx_rings[queue]->rx_itr_setting &= ~I40E_ITR_DYNAMIC;
+               rx_ring->rx_itr_setting &= ~I40E_ITR_DYNAMIC;
 
        if (ec->use_adaptive_tx_coalesce)
-               vsi->tx_rings[queue]->tx_itr_setting |= I40E_ITR_DYNAMIC;
+               tx_ring->tx_itr_setting |= I40E_ITR_DYNAMIC;
        else
-               vsi->tx_rings[queue]->tx_itr_setting &= ~I40E_ITR_DYNAMIC;
+               tx_ring->tx_itr_setting &= ~I40E_ITR_DYNAMIC;
 
-       q_vector = vsi->rx_rings[queue]->q_vector;
-       q_vector->rx.itr = ITR_TO_REG(vsi->rx_rings[queue]->rx_itr_setting);
+       q_vector = rx_ring->q_vector;
+       q_vector->rx.itr = ITR_TO_REG(rx_ring->rx_itr_setting);
        vector = vsi->base_vector + q_vector->v_idx;
        wr32(hw, I40E_PFINT_ITRN(I40E_RX_ITR, vector - 1), q_vector->rx.itr);
 
-       q_vector = vsi->tx_rings[queue]->q_vector;
-       q_vector->tx.itr = ITR_TO_REG(vsi->tx_rings[queue]->tx_itr_setting);
+       q_vector = tx_ring->q_vector;
+       q_vector->tx.itr = ITR_TO_REG(tx_ring->tx_itr_setting);
        vector = vsi->base_vector + q_vector->v_idx;
        wr32(hw, I40E_PFINT_ITRN(I40E_TX_ITR, vector - 1), q_vector->tx.itr);
 
index da006fa3fec1c80790249f50f3d74ddbc613a91c..e2d8aa19d205f4fc4bcc5e42c002c50bc65ef64f 100644 (file)
@@ -512,31 +512,31 @@ static void i40evf_set_itr_per_queue(struct i40evf_adapter *adapter,
                                     struct ethtool_coalesce *ec,
                                     int queue)
 {
+       struct i40e_ring *rx_ring = &adapter->rx_rings[queue];
+       struct i40e_ring *tx_ring = &adapter->tx_rings[queue];
        struct i40e_vsi *vsi = &adapter->vsi;
        struct i40e_hw *hw = &adapter->hw;
        struct i40e_q_vector *q_vector;
        u16 vector;
 
-       adapter->rx_rings[queue].rx_itr_setting = ec->rx_coalesce_usecs;
-       adapter->tx_rings[queue].tx_itr_setting = ec->tx_coalesce_usecs;
+       rx_ring->rx_itr_setting = ec->rx_coalesce_usecs;
+       tx_ring->tx_itr_setting = ec->tx_coalesce_usecs;
 
-       if (ec->use_adaptive_rx_coalesce)
-               adapter->rx_rings[queue].rx_itr_setting |= I40E_ITR_DYNAMIC;
-       else
-               adapter->rx_rings[queue].rx_itr_setting &= ~I40E_ITR_DYNAMIC;
+       rx_ring->rx_itr_setting |= I40E_ITR_DYNAMIC;
+       if (!ec->use_adaptive_rx_coalesce)
+               rx_ring->rx_itr_setting ^= I40E_ITR_DYNAMIC;
 
-       if (ec->use_adaptive_tx_coalesce)
-               adapter->tx_rings[queue].tx_itr_setting |= I40E_ITR_DYNAMIC;
-       else
-               adapter->tx_rings[queue].tx_itr_setting &= ~I40E_ITR_DYNAMIC;
+       tx_ring->tx_itr_setting |= I40E_ITR_DYNAMIC;
+       if (!ec->use_adaptive_tx_coalesce)
+               tx_ring->tx_itr_setting ^= I40E_ITR_DYNAMIC;
 
-       q_vector = adapter->rx_rings[queue].q_vector;
-       q_vector->rx.itr = ITR_TO_REG(adapter->rx_rings[queue].rx_itr_setting);
+       q_vector = rx_ring->q_vector;
+       q_vector->rx.itr = ITR_TO_REG(rx_ring->rx_itr_setting);
        vector = vsi->base_vector + q_vector->v_idx;
        wr32(hw, I40E_VFINT_ITRN1(I40E_RX_ITR, vector - 1), q_vector->rx.itr);
 
-       q_vector = adapter->tx_rings[queue].q_vector;
-       q_vector->tx.itr = ITR_TO_REG(adapter->tx_rings[queue].tx_itr_setting);
+       q_vector = tx_ring->q_vector;
+       q_vector->tx.itr = ITR_TO_REG(tx_ring->tx_itr_setting);
        vector = vsi->base_vector + q_vector->v_idx;
        wr32(hw, I40E_VFINT_ITRN1(I40E_TX_ITR, vector - 1), q_vector->tx.itr);