aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/intel/igb/igb_main.c
diff options
context:
space:
mode:
authorJesus Sanchez-Palencia <jesus.sanchez-palencia@intel.com>2018-07-03 18:42:55 -0400
committerDavid S. Miller <davem@davemloft.net>2018-07-04 09:30:27 -0400
commit91db364236c8ae1af976d9794e5fec98e859dae7 (patch)
treeba5d01471ae7e6d43a800267047b4de80f7be3ac /drivers/net/ethernet/intel/igb/igb_main.c
parent88cab77162e86e0f6a2b7e4f859c1435c4e24feb (diff)
igb: Refactor igb_configure_cbs()
Make this function retrieve what it needs from the Tx ring being addressed since it already relies on what had been saved on it before. Also, since this function will be used by the upcoming Launchtime patches rename it to better reflect its intention. Note that Launchtime is not part of what 802.1Qav specifies, but the i210 datasheet refers to this set of functionality as "Qav Transmission Mode". Here we also perform a tiny refactor at is_any_cbs_enabled(), and add further documentation to igb_setup_tx_mode(). Signed-off-by: Jesus Sanchez-Palencia <jesus.sanchez-palencia@intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/intel/igb/igb_main.c')
-rw-r--r--drivers/net/ethernet/intel/igb/igb_main.c60
1 files changed, 28 insertions, 32 deletions
diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
index f1e3397bd405..15f6b9c57ccf 100644
--- a/drivers/net/ethernet/intel/igb/igb_main.c
+++ b/drivers/net/ethernet/intel/igb/igb_main.c
@@ -1655,23 +1655,17 @@ static void set_queue_mode(struct e1000_hw *hw, int queue, enum queue_mode mode)
1655} 1655}
1656 1656
1657/** 1657/**
1658 * igb_configure_cbs - Configure Credit-Based Shaper (CBS) 1658 * igb_config_tx_modes - Configure "Qav Tx mode" features on igb
1659 * @adapter: pointer to adapter struct 1659 * @adapter: pointer to adapter struct
1660 * @queue: queue number 1660 * @queue: queue number
1661 * @enable: true = enable CBS, false = disable CBS
1662 * @idleslope: idleSlope in kbps
1663 * @sendslope: sendSlope in kbps
1664 * @hicredit: hiCredit in bytes
1665 * @locredit: loCredit in bytes
1666 * 1661 *
1667 * Configure CBS for a given hardware queue. When disabling, idleslope, 1662 * Configure CBS for a given hardware queue. Parameters are retrieved
1668 * sendslope, hicredit, locredit arguments are ignored. Returns 0 if 1663 * from the correct Tx ring, so igb_save_cbs_params() should be used
1669 * success. Negative otherwise. 1664 * for setting those correctly prior to this function being called.
1670 **/ 1665 **/
1671static void igb_configure_cbs(struct igb_adapter *adapter, int queue, 1666static void igb_config_tx_modes(struct igb_adapter *adapter, int queue)
1672 bool enable, int idleslope, int sendslope,
1673 int hicredit, int locredit)
1674{ 1667{
1668 struct igb_ring *ring = adapter->tx_ring[queue];
1675 struct net_device *netdev = adapter->netdev; 1669 struct net_device *netdev = adapter->netdev;
1676 struct e1000_hw *hw = &adapter->hw; 1670 struct e1000_hw *hw = &adapter->hw;
1677 u32 tqavcc; 1671 u32 tqavcc;
@@ -1680,7 +1674,7 @@ static void igb_configure_cbs(struct igb_adapter *adapter, int queue,
1680 WARN_ON(hw->mac.type != e1000_i210); 1674 WARN_ON(hw->mac.type != e1000_i210);
1681 WARN_ON(queue < 0 || queue > 1); 1675 WARN_ON(queue < 0 || queue > 1);
1682 1676
1683 if (enable || queue == 0) { 1677 if (ring->cbs_enable || queue == 0) {
1684 /* i210 does not allow the queue 0 to be in the Strict 1678 /* i210 does not allow the queue 0 to be in the Strict
1685 * Priority mode while the Qav mode is enabled, so, 1679 * Priority mode while the Qav mode is enabled, so,
1686 * instead of disabling strict priority mode, we give 1680 * instead of disabling strict priority mode, we give
@@ -1690,10 +1684,10 @@ static void igb_configure_cbs(struct igb_adapter *adapter, int queue,
1690 * Queue0 QueueMode must be set to 1b when 1684 * Queue0 QueueMode must be set to 1b when
1691 * TransmitMode is set to Qav." 1685 * TransmitMode is set to Qav."
1692 */ 1686 */
1693 if (queue == 0 && !enable) { 1687 if (queue == 0 && !ring->cbs_enable) {
1694 /* max "linkspeed" idleslope in kbps */ 1688 /* max "linkspeed" idleslope in kbps */
1695 idleslope = 1000000; 1689 ring->idleslope = 1000000;
1696 hicredit = ETH_FRAME_LEN; 1690 ring->hicredit = ETH_FRAME_LEN;
1697 } 1691 }
1698 1692
1699 set_tx_desc_fetch_prio(hw, queue, TX_QUEUE_PRIO_HIGH); 1693 set_tx_desc_fetch_prio(hw, queue, TX_QUEUE_PRIO_HIGH);
@@ -1756,14 +1750,15 @@ static void igb_configure_cbs(struct igb_adapter *adapter, int queue,
1756 * calculated value, so the resulting bandwidth might 1750 * calculated value, so the resulting bandwidth might
1757 * be slightly higher for some configurations. 1751 * be slightly higher for some configurations.
1758 */ 1752 */
1759 value = DIV_ROUND_UP_ULL(idleslope * 61034ULL, 1000000); 1753 value = DIV_ROUND_UP_ULL(ring->idleslope * 61034ULL, 1000000);
1760 1754
1761 tqavcc = rd32(E1000_I210_TQAVCC(queue)); 1755 tqavcc = rd32(E1000_I210_TQAVCC(queue));
1762 tqavcc &= ~E1000_TQAVCC_IDLESLOPE_MASK; 1756 tqavcc &= ~E1000_TQAVCC_IDLESLOPE_MASK;
1763 tqavcc |= value; 1757 tqavcc |= value;
1764 wr32(E1000_I210_TQAVCC(queue), tqavcc); 1758 wr32(E1000_I210_TQAVCC(queue), tqavcc);
1765 1759
1766 wr32(E1000_I210_TQAVHC(queue), 0x80000000 + hicredit * 0x7735); 1760 wr32(E1000_I210_TQAVHC(queue),
1761 0x80000000 + ring->hicredit * 0x7735);
1767 } else { 1762 } else {
1768 set_tx_desc_fetch_prio(hw, queue, TX_QUEUE_PRIO_LOW); 1763 set_tx_desc_fetch_prio(hw, queue, TX_QUEUE_PRIO_LOW);
1769 set_queue_mode(hw, queue, QUEUE_MODE_STRICT_PRIORITY); 1764 set_queue_mode(hw, queue, QUEUE_MODE_STRICT_PRIORITY);
@@ -1783,8 +1778,9 @@ static void igb_configure_cbs(struct igb_adapter *adapter, int queue,
1783 */ 1778 */
1784 1779
1785 netdev_dbg(netdev, "CBS %s: queue %d idleslope %d sendslope %d hiCredit %d locredit %d\n", 1780 netdev_dbg(netdev, "CBS %s: queue %d idleslope %d sendslope %d hiCredit %d locredit %d\n",
1786 (enable) ? "enabled" : "disabled", queue, 1781 (ring->cbs_enable) ? "enabled" : "disabled", queue,
1787 idleslope, sendslope, hicredit, locredit); 1782 ring->idleslope, ring->sendslope, ring->hicredit,
1783 ring->locredit);
1788} 1784}
1789 1785
1790static int igb_save_cbs_params(struct igb_adapter *adapter, int queue, 1786static int igb_save_cbs_params(struct igb_adapter *adapter, int queue,
@@ -1809,19 +1805,25 @@ static int igb_save_cbs_params(struct igb_adapter *adapter, int queue,
1809 1805
1810static bool is_any_cbs_enabled(struct igb_adapter *adapter) 1806static bool is_any_cbs_enabled(struct igb_adapter *adapter)
1811{ 1807{
1812 struct igb_ring *ring;
1813 int i; 1808 int i;
1814 1809
1815 for (i = 0; i < adapter->num_tx_queues; i++) { 1810 for (i = 0; i < adapter->num_tx_queues; i++) {
1816 ring = adapter->tx_ring[i]; 1811 if (adapter->tx_ring[i]->cbs_enable)
1817
1818 if (ring->cbs_enable)
1819 return true; 1812 return true;
1820 } 1813 }
1821 1814
1822 return false; 1815 return false;
1823} 1816}
1824 1817
1818/**
1819 * igb_setup_tx_mode - Switch to/from Qav Tx mode when applicable
1820 * @adapter: pointer to adapter struct
1821 *
1822 * Configure TQAVCTRL register switching the controller's Tx mode
1823 * if FQTSS mode is enabled or disabled. Additionally, will issue
1824 * a call to igb_config_tx_modes() per queue so any previously saved
1825 * Tx parameters are applied.
1826 **/
1825static void igb_setup_tx_mode(struct igb_adapter *adapter) 1827static void igb_setup_tx_mode(struct igb_adapter *adapter)
1826{ 1828{
1827 struct net_device *netdev = adapter->netdev; 1829 struct net_device *netdev = adapter->netdev;
@@ -1881,11 +1883,7 @@ static void igb_setup_tx_mode(struct igb_adapter *adapter)
1881 adapter->num_tx_queues : I210_SR_QUEUES_NUM; 1883 adapter->num_tx_queues : I210_SR_QUEUES_NUM;
1882 1884
1883 for (i = 0; i < max_queue; i++) { 1885 for (i = 0; i < max_queue; i++) {
1884 struct igb_ring *ring = adapter->tx_ring[i]; 1886 igb_config_tx_modes(adapter, i);
1885
1886 igb_configure_cbs(adapter, i, ring->cbs_enable,
1887 ring->idleslope, ring->sendslope,
1888 ring->hicredit, ring->locredit);
1889 } 1887 }
1890 } else { 1888 } else {
1891 wr32(E1000_RXPBS, I210_RXPBSIZE_DEFAULT); 1889 wr32(E1000_RXPBS, I210_RXPBSIZE_DEFAULT);
@@ -2480,9 +2478,7 @@ static int igb_offload_cbs(struct igb_adapter *adapter,
2480 return err; 2478 return err;
2481 2479
2482 if (is_fqtss_enabled(adapter)) { 2480 if (is_fqtss_enabled(adapter)) {
2483 igb_configure_cbs(adapter, qopt->queue, qopt->enable, 2481 igb_config_tx_modes(adapter, qopt->queue);
2484 qopt->idleslope, qopt->sendslope,
2485 qopt->hicredit, qopt->locredit);
2486 2482
2487 if (!is_any_cbs_enabled(adapter)) 2483 if (!is_any_cbs_enabled(adapter))
2488 enable_fqtss(adapter, false); 2484 enable_fqtss(adapter, false);