@@ -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
1659
* @adapter: pointer to adapter struct
1660
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,
1668
- * sendslope, hicredit, locredit arguments are ignored. Returns 0 if
1669
- * success. Negative otherwise .
1662
+ * Configure CBS for a given hardware queue. Parameters are retrieved
1663
+ * from the correct Tx ring, so igb_save_cbs_params() should be used
1664
+ * for setting those correctly prior to this function being called .
1670
1665
**/
1671
- static void igb_configure_cbs (struct igb_adapter * adapter , int queue ,
1672
- bool enable , int idleslope , int sendslope ,
1673
- int hicredit , int locredit )
1666
+ static void igb_config_tx_modes (struct igb_adapter * adapter , int queue )
1674
1667
{
1668
+ struct igb_ring * ring = adapter -> tx_ring [queue ];
1675
1669
struct net_device * netdev = adapter -> netdev ;
1676
1670
struct e1000_hw * hw = & adapter -> hw ;
1677
1671
u32 tqavcc ;
@@ -1680,7 +1674,7 @@ static void igb_configure_cbs(struct igb_adapter *adapter, int queue,
1680
1674
WARN_ON (hw -> mac .type != e1000_i210 );
1681
1675
WARN_ON (queue < 0 || queue > 1 );
1682
1676
1683
- if (enable || queue == 0 ) {
1677
+ if (ring -> cbs_enable || queue == 0 ) {
1684
1678
/* i210 does not allow the queue 0 to be in the Strict
1685
1679
* Priority mode while the Qav mode is enabled, so,
1686
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
1684
* Queue0 QueueMode must be set to 1b when
1691
1685
* TransmitMode is set to Qav."
1692
1686
*/
1693
- if (queue == 0 && !enable ) {
1687
+ if (queue == 0 && !ring -> cbs_enable ) {
1694
1688
/* max "linkspeed" idleslope in kbps */
1695
- idleslope = 1000000 ;
1696
- hicredit = ETH_FRAME_LEN ;
1689
+ ring -> idleslope = 1000000 ;
1690
+ ring -> hicredit = ETH_FRAME_LEN ;
1697
1691
}
1698
1692
1699
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
1750
* calculated value, so the resulting bandwidth might
1757
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
1755
tqavcc = rd32 (E1000_I210_TQAVCC (queue ));
1762
1756
tqavcc &= ~E1000_TQAVCC_IDLESLOPE_MASK ;
1763
1757
tqavcc |= value ;
1764
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
1762
} else {
1768
1763
set_tx_desc_fetch_prio (hw , queue , TX_QUEUE_PRIO_LOW );
1769
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
1780
netdev_dbg (netdev , "CBS %s: queue %d idleslope %d sendslope %d hiCredit %d locredit %d\n" ,
1786
- (enable ) ? "enabled" : "disabled" , queue ,
1787
- idleslope , sendslope , hicredit , locredit );
1781
+ (ring -> cbs_enable ) ? "enabled" : "disabled" , queue ,
1782
+ ring -> idleslope , ring -> sendslope , ring -> hicredit ,
1783
+ ring -> locredit );
1788
1784
}
1789
1785
1790
1786
static 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
1810
1806
static bool is_any_cbs_enabled (struct igb_adapter * adapter )
1811
1807
{
1812
- struct igb_ring * ring ;
1813
1808
int i ;
1814
1809
1815
1810
for (i = 0 ; i < adapter -> num_tx_queues ; i ++ ) {
1816
- ring = adapter -> tx_ring [i ];
1817
-
1818
- if (ring -> cbs_enable )
1811
+ if (adapter -> tx_ring [i ]-> cbs_enable )
1819
1812
return true;
1820
1813
}
1821
1814
1822
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
+ **/
1825
1827
static void igb_setup_tx_mode (struct igb_adapter * adapter )
1826
1828
{
1827
1829
struct net_device * netdev = adapter -> netdev ;
@@ -1881,11 +1883,7 @@ static void igb_setup_tx_mode(struct igb_adapter *adapter)
1881
1883
adapter -> num_tx_queues : I210_SR_QUEUES_NUM ;
1882
1884
1883
1885
for (i = 0 ; i < max_queue ; i ++ ) {
1884
- struct igb_ring * ring = adapter -> tx_ring [i ];
1885
-
1886
- igb_configure_cbs (adapter , i , ring -> cbs_enable ,
1887
- ring -> idleslope , ring -> sendslope ,
1888
- ring -> hicredit , ring -> locredit );
1886
+ igb_config_tx_modes (adapter , i );
1889
1887
}
1890
1888
} else {
1891
1889
wr32 (E1000_RXPBS , I210_RXPBSIZE_DEFAULT );
@@ -2480,9 +2478,7 @@ static int igb_offload_cbs(struct igb_adapter *adapter,
2480
2478
return err ;
2481
2479
2482
2480
if (is_fqtss_enabled (adapter )) {
2483
- igb_configure_cbs (adapter , qopt -> queue , qopt -> enable ,
2484
- qopt -> idleslope , qopt -> sendslope ,
2485
- qopt -> hicredit , qopt -> locredit );
2481
+ igb_config_tx_modes (adapter , qopt -> queue );
2486
2482
2487
2483
if (!is_any_cbs_enabled (adapter ))
2488
2484
enable_fqtss (adapter , false);
0 commit comments