Skip to content

Commit c04f90e

Browse files
Rostislav PehlivanovJeff Kirsher
authored andcommitted
ixgbe: add a callback to set the maximum transmit bitrate
This commit adds a callback which allows to adjust the maximum transmit bitrate the card can output. This makes it possible to get a smooth traffic instead of the default burst-y behaviour when trying to output e.g. a video stream. Much of the logic needed to get a correct bcnrc_val was taken from the ixgbe_set_vf_rate_limit() function. Signed-off-by: Rostislav Pehlivanov <[email protected]> Tested-by: Andrew Bowers <[email protected]> Signed-off-by: Jeff Kirsher <[email protected]>
1 parent afdc71e commit c04f90e

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed

drivers/net/ethernet/intel/ixgbe/ixgbe_main.c

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,6 +1077,36 @@ static void ixgbe_tx_timeout_reset(struct ixgbe_adapter *adapter)
10771077
}
10781078
}
10791079

1080+
/**
1081+
* ixgbe_tx_maxrate - callback to set the maximum per-queue bitrate
1082+
**/
1083+
static int ixgbe_tx_maxrate(struct net_device *netdev,
1084+
int queue_index, u32 maxrate)
1085+
{
1086+
struct ixgbe_adapter *adapter = netdev_priv(netdev);
1087+
struct ixgbe_hw *hw = &adapter->hw;
1088+
u32 bcnrc_val = ixgbe_link_mbps(adapter);
1089+
1090+
if (!maxrate)
1091+
return 0;
1092+
1093+
/* Calculate the rate factor values to set */
1094+
bcnrc_val <<= IXGBE_RTTBCNRC_RF_INT_SHIFT;
1095+
bcnrc_val /= maxrate;
1096+
1097+
/* clear everything but the rate factor */
1098+
bcnrc_val &= IXGBE_RTTBCNRC_RF_INT_MASK |
1099+
IXGBE_RTTBCNRC_RF_DEC_MASK;
1100+
1101+
/* enable the rate scheduler */
1102+
bcnrc_val |= IXGBE_RTTBCNRC_RS_ENA;
1103+
1104+
IXGBE_WRITE_REG(hw, IXGBE_RTTDQSEL, queue_index);
1105+
IXGBE_WRITE_REG(hw, IXGBE_RTTBCNRC, bcnrc_val);
1106+
1107+
return 0;
1108+
}
1109+
10801110
/**
10811111
* ixgbe_clean_tx_irq - Reclaim resources after transmit completes
10821112
* @q_vector: structure containing interrupt and ring information
@@ -8807,6 +8837,7 @@ static const struct net_device_ops ixgbe_netdev_ops = {
88078837
.ndo_set_mac_address = ixgbe_set_mac,
88088838
.ndo_change_mtu = ixgbe_change_mtu,
88098839
.ndo_tx_timeout = ixgbe_tx_timeout,
8840+
.ndo_set_tx_maxrate = ixgbe_tx_maxrate,
88108841
.ndo_vlan_rx_add_vid = ixgbe_vlan_rx_add_vid,
88118842
.ndo_vlan_rx_kill_vid = ixgbe_vlan_rx_kill_vid,
88128843
.ndo_do_ioctl = ixgbe_ioctl,

drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1398,7 +1398,7 @@ int ixgbe_ndo_set_vf_vlan(struct net_device *netdev, int vf, u16 vlan, u8 qos)
13981398
return err;
13991399
}
14001400

1401-
static int ixgbe_link_mbps(struct ixgbe_adapter *adapter)
1401+
int ixgbe_link_mbps(struct ixgbe_adapter *adapter)
14021402
{
14031403
switch (adapter->link_speed) {
14041404
case IXGBE_LINK_SPEED_100_FULL:

drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ void ixgbe_ping_all_vfs(struct ixgbe_adapter *adapter);
4444
int ixgbe_ndo_set_vf_mac(struct net_device *netdev, int queue, u8 *mac);
4545
int ixgbe_ndo_set_vf_vlan(struct net_device *netdev, int queue, u16 vlan,
4646
u8 qos);
47+
int ixgbe_link_mbps(struct ixgbe_adapter *adapter);
4748
int ixgbe_ndo_set_vf_bw(struct net_device *netdev, int vf, int min_tx_rate,
4849
int max_tx_rate);
4950
int ixgbe_ndo_set_vf_spoofchk(struct net_device *netdev, int vf, bool setting);

0 commit comments

Comments
 (0)