diff options
author | Brett Creeley <brett.creeley@intel.com> | 2019-02-28 18:25:59 -0500 |
---|---|---|
committer | Jeff Kirsher <jeffrey.t.kirsher@intel.com> | 2019-05-02 04:21:56 -0400 |
commit | b07833a00d70fb731bb3aba8876a56e37b549f3e (patch) | |
tree | ef5376b786a7c5f972578c025dea53248b9e2d04 /drivers/net/ethernet/intel/ice/ice_lib.c | |
parent | 8d7189d266ccec6dce1a4c2dd2bde6e0d632a24c (diff) |
ice: Add reg_idx variable in ice_q_vector structure
Every time we want to re-enable interrupts and/or write to a register
that requires an interrupt vector's hardware index we do the following:
vsi->hw_base_vector + q_vector->v_idx
This is a wasteful operation, especially in the hot path. Fix this by
adding a u16 reg_idx member to the ice_q_vector structure and make the
necessary changes to make this work.
Signed-off-by: Brett Creeley <brett.creeley@intel.com>
Signed-off-by: Anirudh Venkataramanan <anirudh.venkataramanan@intel.com>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Diffstat (limited to 'drivers/net/ethernet/intel/ice/ice_lib.c')
-rw-r--r-- | drivers/net/ethernet/intel/ice/ice_lib.c | 84 |
1 files changed, 67 insertions, 17 deletions
diff --git a/drivers/net/ethernet/intel/ice/ice_lib.c b/drivers/net/ethernet/intel/ice/ice_lib.c index 6d9571c8826d..399905396134 100644 --- a/drivers/net/ethernet/intel/ice/ice_lib.c +++ b/drivers/net/ethernet/intel/ice/ice_lib.c | |||
@@ -1805,13 +1805,12 @@ static void ice_cfg_itr_gran(struct ice_hw *hw) | |||
1805 | * ice_cfg_itr - configure the initial interrupt throttle values | 1805 | * ice_cfg_itr - configure the initial interrupt throttle values |
1806 | * @hw: pointer to the HW structure | 1806 | * @hw: pointer to the HW structure |
1807 | * @q_vector: interrupt vector that's being configured | 1807 | * @q_vector: interrupt vector that's being configured |
1808 | * @vector: HW vector index to apply the interrupt throttling to | ||
1809 | * | 1808 | * |
1810 | * Configure interrupt throttling values for the ring containers that are | 1809 | * Configure interrupt throttling values for the ring containers that are |
1811 | * associated with the interrupt vector passed in. | 1810 | * associated with the interrupt vector passed in. |
1812 | */ | 1811 | */ |
1813 | static void | 1812 | static void |
1814 | ice_cfg_itr(struct ice_hw *hw, struct ice_q_vector *q_vector, u16 vector) | 1813 | ice_cfg_itr(struct ice_hw *hw, struct ice_q_vector *q_vector) |
1815 | { | 1814 | { |
1816 | ice_cfg_itr_gran(hw); | 1815 | ice_cfg_itr_gran(hw); |
1817 | 1816 | ||
@@ -1825,7 +1824,7 @@ ice_cfg_itr(struct ice_hw *hw, struct ice_q_vector *q_vector, u16 vector) | |||
1825 | rc->target_itr = ITR_TO_REG(rc->itr_setting); | 1824 | rc->target_itr = ITR_TO_REG(rc->itr_setting); |
1826 | rc->next_update = jiffies + 1; | 1825 | rc->next_update = jiffies + 1; |
1827 | rc->current_itr = rc->target_itr; | 1826 | rc->current_itr = rc->target_itr; |
1828 | wr32(hw, GLINT_ITR(rc->itr_idx, vector), | 1827 | wr32(hw, GLINT_ITR(rc->itr_idx, q_vector->reg_idx), |
1829 | ITR_REG_ALIGN(rc->current_itr) >> ICE_ITR_GRAN_S); | 1828 | ITR_REG_ALIGN(rc->current_itr) >> ICE_ITR_GRAN_S); |
1830 | } | 1829 | } |
1831 | 1830 | ||
@@ -1839,7 +1838,7 @@ ice_cfg_itr(struct ice_hw *hw, struct ice_q_vector *q_vector, u16 vector) | |||
1839 | rc->target_itr = ITR_TO_REG(rc->itr_setting); | 1838 | rc->target_itr = ITR_TO_REG(rc->itr_setting); |
1840 | rc->next_update = jiffies + 1; | 1839 | rc->next_update = jiffies + 1; |
1841 | rc->current_itr = rc->target_itr; | 1840 | rc->current_itr = rc->target_itr; |
1842 | wr32(hw, GLINT_ITR(rc->itr_idx, vector), | 1841 | wr32(hw, GLINT_ITR(rc->itr_idx, q_vector->reg_idx), |
1843 | ITR_REG_ALIGN(rc->current_itr) >> ICE_ITR_GRAN_S); | 1842 | ITR_REG_ALIGN(rc->current_itr) >> ICE_ITR_GRAN_S); |
1844 | } | 1843 | } |
1845 | } | 1844 | } |
@@ -1851,17 +1850,17 @@ ice_cfg_itr(struct ice_hw *hw, struct ice_q_vector *q_vector, u16 vector) | |||
1851 | void ice_vsi_cfg_msix(struct ice_vsi *vsi) | 1850 | void ice_vsi_cfg_msix(struct ice_vsi *vsi) |
1852 | { | 1851 | { |
1853 | struct ice_pf *pf = vsi->back; | 1852 | struct ice_pf *pf = vsi->back; |
1854 | u16 vector = vsi->hw_base_vector; | ||
1855 | struct ice_hw *hw = &pf->hw; | 1853 | struct ice_hw *hw = &pf->hw; |
1856 | u32 txq = 0, rxq = 0; | 1854 | u32 txq = 0, rxq = 0; |
1857 | int i, q; | 1855 | int i, q; |
1858 | 1856 | ||
1859 | for (i = 0; i < vsi->num_q_vectors; i++, vector++) { | 1857 | for (i = 0; i < vsi->num_q_vectors; i++) { |
1860 | struct ice_q_vector *q_vector = vsi->q_vectors[i]; | 1858 | struct ice_q_vector *q_vector = vsi->q_vectors[i]; |
1859 | u16 reg_idx = q_vector->reg_idx; | ||
1861 | 1860 | ||
1862 | ice_cfg_itr(hw, q_vector, vector); | 1861 | ice_cfg_itr(hw, q_vector); |
1863 | 1862 | ||
1864 | wr32(hw, GLINT_RATE(vector), | 1863 | wr32(hw, GLINT_RATE(reg_idx), |
1865 | ice_intrl_usec_to_reg(q_vector->intrl, hw->intrl_gran)); | 1864 | ice_intrl_usec_to_reg(q_vector->intrl, hw->intrl_gran)); |
1866 | 1865 | ||
1867 | /* Both Transmit Queue Interrupt Cause Control register | 1866 | /* Both Transmit Queue Interrupt Cause Control register |
@@ -1886,7 +1885,7 @@ void ice_vsi_cfg_msix(struct ice_vsi *vsi) | |||
1886 | else | 1885 | else |
1887 | val = QINT_TQCTL_CAUSE_ENA_M | | 1886 | val = QINT_TQCTL_CAUSE_ENA_M | |
1888 | (itr_idx << QINT_TQCTL_ITR_INDX_S) | | 1887 | (itr_idx << QINT_TQCTL_ITR_INDX_S) | |
1889 | (vector << QINT_TQCTL_MSIX_INDX_S); | 1888 | (reg_idx << QINT_TQCTL_MSIX_INDX_S); |
1890 | wr32(hw, QINT_TQCTL(vsi->txq_map[txq]), val); | 1889 | wr32(hw, QINT_TQCTL(vsi->txq_map[txq]), val); |
1891 | txq++; | 1890 | txq++; |
1892 | } | 1891 | } |
@@ -1902,7 +1901,7 @@ void ice_vsi_cfg_msix(struct ice_vsi *vsi) | |||
1902 | else | 1901 | else |
1903 | val = QINT_RQCTL_CAUSE_ENA_M | | 1902 | val = QINT_RQCTL_CAUSE_ENA_M | |
1904 | (itr_idx << QINT_RQCTL_ITR_INDX_S) | | 1903 | (itr_idx << QINT_RQCTL_ITR_INDX_S) | |
1905 | (vector << QINT_RQCTL_MSIX_INDX_S); | 1904 | (reg_idx << QINT_RQCTL_MSIX_INDX_S); |
1906 | wr32(hw, QINT_RQCTL(vsi->rxq_map[rxq]), val); | 1905 | wr32(hw, QINT_RQCTL(vsi->rxq_map[rxq]), val); |
1907 | rxq++; | 1906 | rxq++; |
1908 | } | 1907 | } |
@@ -2065,8 +2064,6 @@ ice_vsi_stop_tx_rings(struct ice_vsi *vsi, enum ice_disq_rst_src rst_src, | |||
2065 | break; | 2064 | break; |
2066 | 2065 | ||
2067 | for (i = 0; i < vsi->tc_cfg.tc_info[tc].qcount_tx; i++) { | 2066 | for (i = 0; i < vsi->tc_cfg.tc_info[tc].qcount_tx; i++) { |
2068 | u16 v_idx; | ||
2069 | |||
2070 | if (!rings || !rings[q_idx] || | 2067 | if (!rings || !rings[q_idx] || |
2071 | !rings[q_idx]->q_vector) { | 2068 | !rings[q_idx]->q_vector) { |
2072 | err = -EINVAL; | 2069 | err = -EINVAL; |
@@ -2088,8 +2085,7 @@ ice_vsi_stop_tx_rings(struct ice_vsi *vsi, enum ice_disq_rst_src rst_src, | |||
2088 | /* trigger a software interrupt for the vector | 2085 | /* trigger a software interrupt for the vector |
2089 | * associated to the queue to schedule NAPI handler | 2086 | * associated to the queue to schedule NAPI handler |
2090 | */ | 2087 | */ |
2091 | v_idx = rings[i]->q_vector->v_idx; | 2088 | wr32(hw, GLINT_DYN_CTL(rings[i]->q_vector->reg_idx), |
2092 | wr32(hw, GLINT_DYN_CTL(vsi->hw_base_vector + v_idx), | ||
2093 | GLINT_DYN_CTL_SWINT_TRIG_M | | 2089 | GLINT_DYN_CTL_SWINT_TRIG_M | |
2094 | GLINT_DYN_CTL_INTENA_MSK_M); | 2090 | GLINT_DYN_CTL_INTENA_MSK_M); |
2095 | q_idx++; | 2091 | q_idx++; |
@@ -2209,6 +2205,44 @@ static void ice_vsi_set_tc_cfg(struct ice_vsi *vsi) | |||
2209 | } | 2205 | } |
2210 | 2206 | ||
2211 | /** | 2207 | /** |
2208 | * ice_vsi_set_q_vectors_reg_idx - set the HW register index for all q_vectors | ||
2209 | * @vsi: VSI to set the q_vectors register index on | ||
2210 | */ | ||
2211 | static int | ||
2212 | ice_vsi_set_q_vectors_reg_idx(struct ice_vsi *vsi) | ||
2213 | { | ||
2214 | u16 i; | ||
2215 | |||
2216 | if (!vsi || !vsi->q_vectors) | ||
2217 | return -EINVAL; | ||
2218 | |||
2219 | ice_for_each_q_vector(vsi, i) { | ||
2220 | struct ice_q_vector *q_vector = vsi->q_vectors[i]; | ||
2221 | |||
2222 | if (!q_vector) { | ||
2223 | dev_err(&vsi->back->pdev->dev, | ||
2224 | "Failed to set reg_idx on q_vector %d VSI %d\n", | ||
2225 | i, vsi->vsi_num); | ||
2226 | goto clear_reg_idx; | ||
2227 | } | ||
2228 | |||
2229 | q_vector->reg_idx = q_vector->v_idx + vsi->hw_base_vector; | ||
2230 | } | ||
2231 | |||
2232 | return 0; | ||
2233 | |||
2234 | clear_reg_idx: | ||
2235 | ice_for_each_q_vector(vsi, i) { | ||
2236 | struct ice_q_vector *q_vector = vsi->q_vectors[i]; | ||
2237 | |||
2238 | if (q_vector) | ||
2239 | q_vector->reg_idx = 0; | ||
2240 | } | ||
2241 | |||
2242 | return -EINVAL; | ||
2243 | } | ||
2244 | |||
2245 | /** | ||
2212 | * ice_vsi_setup - Set up a VSI by a given type | 2246 | * ice_vsi_setup - Set up a VSI by a given type |
2213 | * @pf: board private structure | 2247 | * @pf: board private structure |
2214 | * @pi: pointer to the port_info instance | 2248 | * @pi: pointer to the port_info instance |
@@ -2273,6 +2307,10 @@ ice_vsi_setup(struct ice_pf *pf, struct ice_port_info *pi, | |||
2273 | if (ret) | 2307 | if (ret) |
2274 | goto unroll_alloc_q_vector; | 2308 | goto unroll_alloc_q_vector; |
2275 | 2309 | ||
2310 | ret = ice_vsi_set_q_vectors_reg_idx(vsi); | ||
2311 | if (ret) | ||
2312 | goto unroll_vector_base; | ||
2313 | |||
2276 | ret = ice_vsi_alloc_rings(vsi); | 2314 | ret = ice_vsi_alloc_rings(vsi); |
2277 | if (ret) | 2315 | if (ret) |
2278 | goto unroll_vector_base; | 2316 | goto unroll_vector_base; |
@@ -2311,6 +2349,10 @@ ice_vsi_setup(struct ice_pf *pf, struct ice_port_info *pi, | |||
2311 | } else { | 2349 | } else { |
2312 | vsi->hw_base_vector = pf->vf[vf_id].first_vector_idx; | 2350 | vsi->hw_base_vector = pf->vf[vf_id].first_vector_idx; |
2313 | } | 2351 | } |
2352 | ret = ice_vsi_set_q_vectors_reg_idx(vsi); | ||
2353 | if (ret) | ||
2354 | goto unroll_vector_base; | ||
2355 | |||
2314 | pf->q_left_tx -= vsi->alloc_txq; | 2356 | pf->q_left_tx -= vsi->alloc_txq; |
2315 | pf->q_left_rx -= vsi->alloc_rxq; | 2357 | pf->q_left_rx -= vsi->alloc_rxq; |
2316 | break; | 2358 | break; |
@@ -2623,11 +2665,11 @@ void ice_vsi_dis_irq(struct ice_vsi *vsi) | |||
2623 | 2665 | ||
2624 | /* disable each interrupt */ | 2666 | /* disable each interrupt */ |
2625 | if (test_bit(ICE_FLAG_MSIX_ENA, pf->flags)) { | 2667 | if (test_bit(ICE_FLAG_MSIX_ENA, pf->flags)) { |
2626 | for (i = vsi->hw_base_vector; | 2668 | ice_for_each_q_vector(vsi, i) |
2627 | i < (vsi->num_q_vectors + vsi->hw_base_vector); i++) | 2669 | wr32(hw, GLINT_DYN_CTL(vsi->q_vectors[i]->reg_idx), 0); |
2628 | wr32(hw, GLINT_DYN_CTL(i), 0); | ||
2629 | 2670 | ||
2630 | ice_flush(hw); | 2671 | ice_flush(hw); |
2672 | |||
2631 | ice_for_each_q_vector(vsi, i) | 2673 | ice_for_each_q_vector(vsi, i) |
2632 | synchronize_irq(pf->msix_entries[i + base].vector); | 2674 | synchronize_irq(pf->msix_entries[i + base].vector); |
2633 | } | 2675 | } |
@@ -2780,6 +2822,10 @@ int ice_vsi_rebuild(struct ice_vsi *vsi) | |||
2780 | if (ret) | 2822 | if (ret) |
2781 | goto err_vectors; | 2823 | goto err_vectors; |
2782 | 2824 | ||
2825 | ret = ice_vsi_set_q_vectors_reg_idx(vsi); | ||
2826 | if (ret) | ||
2827 | goto err_vectors; | ||
2828 | |||
2783 | ret = ice_vsi_alloc_rings(vsi); | 2829 | ret = ice_vsi_alloc_rings(vsi); |
2784 | if (ret) | 2830 | if (ret) |
2785 | goto err_vectors; | 2831 | goto err_vectors; |
@@ -2801,6 +2847,10 @@ int ice_vsi_rebuild(struct ice_vsi *vsi) | |||
2801 | if (ret) | 2847 | if (ret) |
2802 | goto err_vectors; | 2848 | goto err_vectors; |
2803 | 2849 | ||
2850 | ret = ice_vsi_set_q_vectors_reg_idx(vsi); | ||
2851 | if (ret) | ||
2852 | goto err_vectors; | ||
2853 | |||
2804 | ret = ice_vsi_alloc_rings(vsi); | 2854 | ret = ice_vsi_alloc_rings(vsi); |
2805 | if (ret) | 2855 | if (ret) |
2806 | goto err_vectors; | 2856 | goto err_vectors; |