Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit dd984e87 authored by Jinesh K. Jayakumar's avatar Jinesh K. Jayakumar
Browse files

msm: ipa: Enable support for bandwidth voting



Enable support for bandwidth voting in IPA offload sub-system based on
link speed of managed ethernet devices.

CRs-Fixed: 2369661
Change-Id: Ibd2d8dc8d002e87a6a8ac51ef547c4d75c1b1600
Signed-off-by: default avatarJinesh K. Jayakumar <jineshk@codeaurora.org>
parent 005f8763
Loading
Loading
Loading
Loading
+29 −1
Original line number Diff line number Diff line
@@ -10,9 +10,12 @@
 * GNU General Public License for more details.
 */

#include <linux/ethtool.h>

#include "ipa_eth_i.h"

#define IPA_ETH_MIN_BW_MBPS 1
#define IPA_ETH_MAX_BW_MBPS 100000

static void ipa_eth_pm_callback(void *arg, enum ipa_pm_cb_event event)
{
@@ -92,10 +95,35 @@ int ipa_eth_pm_deactivate(struct ipa_eth_device *eth_dev)
	return ipa_pm_deactivate_sync(eth_dev->pm_handle);
}

static u32 __fetch_ethtool_link_speed(struct ipa_eth_device *eth_dev)
{
	int rc;
	struct ethtool_link_ksettings link_ksettings;

	rc = __ethtool_get_link_ksettings(eth_dev->net_dev, &link_ksettings);
	if (rc) {
		ipa_eth_dev_err(eth_dev,
			"Failed to obtain link settings via ethtool");
		return 0;
	}

	return link_ksettings.base.speed;
}

int ipa_eth_pm_vote_bw(struct ipa_eth_device *eth_dev)
{
	u32 link_speed;
	int throughput;

	if (!ipa_pm_is_used())
		return 0;

	return ipa_pm_set_throughput(eth_dev->pm_handle, IPA_ETH_MIN_BW_MBPS);
	link_speed = __fetch_ethtool_link_speed(eth_dev);
	throughput = clamp_val(link_speed,
				IPA_ETH_MIN_BW_MBPS, IPA_ETH_MAX_BW_MBPS);

	ipa_eth_dev_log(eth_dev, "Link speed is %u, setting throughput as %d",
			link_speed, throughput);

	return ipa_pm_set_throughput(eth_dev->pm_handle, throughput);
}