Skip to contentSkip to conversation

ixgbe: add a callback to set the maximum transmit bitrate

PATCH New Rostislav Pehlivanov 2 participants 2 messages Jan 27, 2016 – Mar 1, 2016

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 drivers/net/ethernet/intel/ixgbe/ixgbe_main.c  | 31 ++++++++++++++++++++++++++
 drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c |  2 +-
 drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.h |  1 +
 3 files changed, 33 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +31 -0
index c4003a8..d05455c 100644
@@ -1084,6 +1084,36 @@ static void ixgbe_tx_timeout_reset(struct ixgbe_adapter *adapter)
 }
 
 /**
+ * ixgbe_tx_maxrate - callback to set the maximum per-queue bitrate
+ **/
+static int ixgbe_tx_maxrate(struct net_device *netdev,
+			    int queue_index, u32 maxrate)
+{
+	struct ixgbe_adapter *adapter = netdev_priv(netdev);
+	struct ixgbe_hw *hw = &adapter->hw;
+	u32 bcnrc_val = ixgbe_link_mbps(adapter);
+
+	if (!maxrate)
+		return 0;
+
+	/* Calculate the rate factor values to set */
+	bcnrc_val <<= IXGBE_RTTBCNRC_RF_INT_SHIFT;
+	bcnrc_val /= maxrate;
+
+	/* clear everything but the rate factor */
+	bcnrc_val &= IXGBE_RTTBCNRC_RF_INT_MASK |
+	IXGBE_RTTBCNRC_RF_DEC_MASK;
+
+	/* enable the rate scheduler */
+	bcnrc_val |= IXGBE_RTTBCNRC_RS_ENA;
+
+	IXGBE_WRITE_REG(hw, IXGBE_RTTDQSEL, queue_index);
+	IXGBE_WRITE_REG(hw, IXGBE_RTTBCNRC, bcnrc_val);
+
+	return 0;
+}
+
+/**
  * ixgbe_clean_tx_irq - Reclaim resources after transmit completes
  * @q_vector: structure containing interrupt and ring information
  * @tx_ring: tx ring to clean
@@ -8646,6 +8676,7 @@ static const struct net_device_ops ixgbe_netdev_ops = {
 	.ndo_set_mac_address	= ixgbe_set_mac,
 	.ndo_change_mtu		= ixgbe_change_mtu,
 	.ndo_tx_timeout		= ixgbe_tx_timeout,
+	.ndo_set_tx_maxrate	= ixgbe_tx_maxrate,
 	.ndo_vlan_rx_add_vid	= ixgbe_vlan_rx_add_vid,
 	.ndo_vlan_rx_kill_vid	= ixgbe_vlan_rx_kill_vid,
 	.ndo_do_ioctl		= ixgbe_ioctl,
drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c +1 -1
index 8025a3f..f9ca7d5 100644
@@ -1395,7 +1395,7 @@ out:
 	return err;
 }
 
-static int ixgbe_link_mbps(struct ixgbe_adapter *adapter)
+int ixgbe_link_mbps(struct ixgbe_adapter *adapter)
 {
 	switch (adapter->link_speed) {
 	case IXGBE_LINK_SPEED_100_FULL:
drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.h +1 -0
index dad9257..47e65e2 100644
@@ -44,6 +44,7 @@ void ixgbe_ping_all_vfs(struct ixgbe_adapter *adapter);
 int ixgbe_ndo_set_vf_mac(struct net_device *netdev, int queue, u8 *mac);
 int ixgbe_ndo_set_vf_vlan(struct net_device *netdev, int queue, u16 vlan,
 			   u8 qos);
+int ixgbe_link_mbps(struct ixgbe_adapter *adapter);
 int ixgbe_ndo_set_vf_bw(struct net_device *netdev, int vf, int min_tx_rate,
 			int max_tx_rate);
 int ixgbe_ndo_set_vf_spoofchk(struct net_device *netdev, int vf, bool setting);
Signature · 1 line
2.7.0
#1 lore raw

PATCH 1/1 ixgbe: add a callback to set the maximum transmit bitrate

Quoted 20 lines

-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at lists.osuosl.org] On Behalf Of Rostislav Pehlivanov
Sent: Wednesday, January 27, 2016 10:34 AM
To: intel-wired-lan at lists.osuosl.org; netdev at vger.kernel.org; linux- kernel at vger.kernel.org; Kirsher, Jeffrey T <[email protected]>; Brandeburg, Jesse <[email protected]>; Nelson, Shannon <[email protected]>
Cc: Rostislav Pehlivanov <[email protected]>
Subject: [Intel-wired-lan] [PATCH] 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.

Quoted 7 lines
---
 drivers/net/ethernet/intel/ixgbe/ixgbe_main.c  | 31
++++++++++++++++++++++++++
drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c |  2 +-
drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.h |  1 +
 3 files changed, 33 insertions(+), 1 deletion(-)

Traffic rate smooth as expected