@@ -1655,23 +1655,17 @@ static void set_queue_mode(struct e1000_hw *hw, int queue, enum queue_mode mode)
16551655}
16561656
16571657/**
1658- * igb_configure_cbs - Configure Credit-Based Shaper (CBS)
1658+ * igb_config_tx_modes - Configure "Qav Tx mode" features on igb
16591659 * @adapter: pointer to adapter struct
16601660 * @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
16661661 *
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 .
16701665 **/
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 )
16741667{
1668+ struct igb_ring * ring = adapter -> tx_ring [queue ];
16751669 struct net_device * netdev = adapter -> netdev ;
16761670 struct e1000_hw * hw = & adapter -> hw ;
16771671 u32 tqavcc ;
@@ -1680,7 +1674,7 @@ static void igb_configure_cbs(struct igb_adapter *adapter, int queue,
16801674 WARN_ON (hw -> mac .type != e1000_i210 );
16811675 WARN_ON (queue < 0 || queue > 1 );
16821676
1683- if (enable || queue == 0 ) {
1677+ if (ring -> cbs_enable || queue == 0 ) {
16841678 /* i210 does not allow the queue 0 to be in the Strict
16851679 * Priority mode while the Qav mode is enabled, so,
16861680 * instead of disabling strict priority mode, we give
@@ -1690,10 +1684,10 @@ static void igb_configure_cbs(struct igb_adapter *adapter, int queue,
16901684 * Queue0 QueueMode must be set to 1b when
16911685 * TransmitMode is set to Qav."
16921686 */
1693- if (queue == 0 && !enable ) {
1687+ if (queue == 0 && !ring -> cbs_enable ) {
16941688 /* max "linkspeed" idleslope in kbps */
1695- idleslope = 1000000 ;
1696- hicredit = ETH_FRAME_LEN ;
1689+ ring -> idleslope = 1000000 ;
1690+ ring -> hicredit = ETH_FRAME_LEN ;
16971691 }
16981692
16991693 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,
17561750 * calculated value, so the resulting bandwidth might
17571751 * be slightly higher for some configurations.
17581752 */
1759- value = DIV_ROUND_UP_ULL (idleslope * 61034ULL , 1000000 );
1753+ value = DIV_ROUND_UP_ULL (ring -> idleslope * 61034ULL , 1000000 );
17601754
17611755 tqavcc = rd32 (E1000_I210_TQAVCC (queue ));
17621756 tqavcc &= ~E1000_TQAVCC_IDLESLOPE_MASK ;
17631757 tqavcc |= value ;
17641758 wr32 (E1000_I210_TQAVCC (queue ), tqavcc );
17651759
1766- wr32 (E1000_I210_TQAVHC (queue ), 0x80000000 + hicredit * 0x7735 );
1760+ wr32 (E1000_I210_TQAVHC (queue ),
1761+ 0x80000000 + ring -> hicredit * 0x7735 );
17671762 } else {
17681763 set_tx_desc_fetch_prio (hw , queue , TX_QUEUE_PRIO_LOW );
17691764 set_queue_mode (hw , queue , QUEUE_MODE_STRICT_PRIORITY );
@@ -1783,8 +1778,9 @@ static void igb_configure_cbs(struct igb_adapter *adapter, int queue,
17831778 */
17841779
17851780 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 );
17881784}
17891785
17901786static 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,
18091805
18101806static bool is_any_cbs_enabled (struct igb_adapter * adapter )
18111807{
1812- struct igb_ring * ring ;
18131808 int i ;
18141809
18151810 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 )
18191812 return true;
18201813 }
18211814
18221815 return false;
18231816}
18241817
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+ **/
18251827static void igb_setup_tx_mode (struct igb_adapter * adapter )
18261828{
18271829 struct net_device * netdev = adapter -> netdev ;
@@ -1881,11 +1883,7 @@ static void igb_setup_tx_mode(struct igb_adapter *adapter)
18811883 adapter -> num_tx_queues : I210_SR_QUEUES_NUM ;
18821884
18831885 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 );
18891887 }
18901888 } else {
18911889 wr32 (E1000_RXPBS , I210_RXPBSIZE_DEFAULT );
@@ -2480,9 +2478,7 @@ static int igb_offload_cbs(struct igb_adapter *adapter,
24802478 return err ;
24812479
24822480 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 );
24862482
24872483 if (!is_any_cbs_enabled (adapter ))
24882484 enable_fqtss (adapter , false);
0 commit comments