1
0
Fork 0
mirror of https://github.com/Ysurac/openmptcprouter.git synced 2025-02-14 20:31:54 +00:00
openmptcprouter/6.12/package/kernel/qca-nss-dp/patches/0014-nss-dp-update-EEE-support-for-6.12.patch
2025-01-10 18:11:03 +01:00

155 lines
5.9 KiB
Diff

From cdfdb0fd6407bb3a3a3c7bf9602d40928d950641 Mon Sep 17 00:00:00 2001
From: Mantas Pucka <mantas@8devices.com>
Date: Tue, 10 Dec 2024 13:32:04 +0200
Subject: [PATCH 18/18] nss-dp: update EEE support for 6.12
Linux 6.12 changed API for EEE link modes
Signed-off-by: Mantas Pucka <mantas@8devices.com>
---
nss_dp_ethtools.c | 8 ++++++--
2 files changed, 10 insertions(+), 8 deletions(-)
--- a/nss_dp_ethtools.c
+++ b/nss_dp_ethtools.c
@@ -206,6 +206,7 @@ static int32_t nss_dp_set_pauseparam(str
* nss_dp_fal_to_ethtool_linkmode_xlate()
* Translate linkmode from FAL type to ethtool type.
*/
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 12, 0))
static inline void nss_dp_fal_to_ethtool_linkmode_xlate(uint32_t *xlate_to, uint32_t *xlate_from)
{
uint32_t pos;
@@ -243,12 +244,26 @@ static inline void nss_dp_fal_to_ethtool
*xlate_from &= (~(1 << (pos - 1)));
}
}
+#else
+static inline void nss_dp_fal_to_ethtool_linkmode_xlate(unsigned long *to, uint32_t from)
+{
+ linkmode_mod_bit(ETHTOOL_LINK_MODE_10baseT_Full_BIT, to, from & FAL_PHY_EEE_10BASE_T);
+ linkmode_mod_bit(ETHTOOL_LINK_MODE_100baseT_Full_BIT, to, from & FAL_PHY_EEE_100BASE_T);
+ linkmode_mod_bit(ETHTOOL_LINK_MODE_1000baseT_Full_BIT, to, from & FAL_PHY_EEE_1000BASE_T);
+ linkmode_mod_bit(ETHTOOL_LINK_MODE_2500baseX_Full_BIT, to, from & FAL_PHY_EEE_2500BASE_T);
+ linkmode_mod_bit(ETHTOOL_LINK_MODE_10000baseT_Full_BIT, to, from & FAL_PHY_EEE_10000BASE_T);
+}
+#endif
/*
* nss_dp_get_eee()
* Get EEE settings.
*/
-static int32_t nss_dp_get_eee(struct net_device *netdev, struct ethtool_eee *eee)
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 12, 0))
+static int nss_dp_get_eee(struct net_device *netdev, struct ethtool_eee *eee)
+#else
+static int nss_dp_get_eee(struct net_device *netdev, struct ethtool_keee *eee)
+#endif
{
struct nss_dp_dev *dp_priv = (struct nss_dp_dev *)netdev_priv(netdev);
fal_port_eee_cfg_t port_eee_cfg;
@@ -266,9 +281,15 @@ static int32_t nss_dp_get_eee(struct net
/*
* Translate the FAL linkmode types to ethtool linkmode types.
*/
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 12, 0))
nss_dp_fal_to_ethtool_linkmode_xlate(&eee->supported, &port_eee_cfg.capability);
nss_dp_fal_to_ethtool_linkmode_xlate(&eee->advertised, &port_eee_cfg.advertisement);
nss_dp_fal_to_ethtool_linkmode_xlate(&eee->lp_advertised, &port_eee_cfg.link_partner_advertisement);
+#else
+ nss_dp_fal_to_ethtool_linkmode_xlate(eee->supported, port_eee_cfg.capability);
+ nss_dp_fal_to_ethtool_linkmode_xlate(eee->advertised, port_eee_cfg.advertisement);
+ nss_dp_fal_to_ethtool_linkmode_xlate(eee->lp_advertised, port_eee_cfg.link_partner_advertisement);
+#endif
eee->eee_enabled = port_eee_cfg.enable;
eee->eee_active = port_eee_cfg.eee_status;
eee->tx_lpi_enabled = port_eee_cfg.lpi_tx_enable;
@@ -281,11 +302,15 @@ static int32_t nss_dp_get_eee(struct net
* nss_dp_set_eee()
* Set EEE settings.
*/
-static int32_t nss_dp_set_eee(struct net_device *netdev, struct ethtool_eee *eee)
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 12, 0))
+static int nss_dp_set_eee(struct net_device *netdev, struct ethtool_eee *eee)
+#else
+static int nss_dp_set_eee(struct net_device *netdev, struct ethtool_keee *eee)
+#endif
{
struct nss_dp_dev *dp_priv = (struct nss_dp_dev *)netdev_priv(netdev);
fal_port_eee_cfg_t port_eee_cfg, port_eee_cur_cfg;
- uint32_t port_id, pos;
+ uint32_t port_id;
sw_error_t ret;
memset(&port_eee_cfg, 0, sizeof(fal_port_eee_cfg_t));
@@ -306,8 +331,9 @@ static int32_t nss_dp_set_eee(struct net
/*
* Translate the ethtool speed types to FAL speed types.
*/
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 12, 0))
while (eee->advertised) {
- pos = ffs(eee->advertised);
+ uint32_t pos = ffs(eee->advertised);
switch (1 << (pos - 1)) {
case ADVERTISED_10baseT_Full:
if (port_eee_cur_cfg.capability & FAL_PHY_EEE_10BASE_T) {
@@ -361,6 +387,48 @@ static int32_t nss_dp_set_eee(struct net
eee->advertised &= (~(1 << (pos - 1)));
}
+#else
+ if (linkmode_test_bit(ETHTOOL_LINK_MODE_10baseT_Full_BIT, eee->advertised)) {
+ if (port_eee_cur_cfg.capability & FAL_PHY_EEE_10BASE_T) {
+ port_eee_cfg.advertisement |= FAL_PHY_EEE_10BASE_T;
+ } else {
+ netdev_dbg(netdev, "Advertised value 10baseT_Full is not supported\n");
+ return -EIO;
+ }
+ }
+ if (linkmode_test_bit(ETHTOOL_LINK_MODE_100baseT_Full_BIT, eee->advertised)) {
+ if (port_eee_cur_cfg.capability & FAL_PHY_EEE_100BASE_T) {
+ port_eee_cfg.advertisement |= FAL_PHY_EEE_100BASE_T;
+ } else {
+ netdev_dbg(netdev, "Advertised value 100baseT_Full is not supported\n");
+ return -EIO;
+ }
+ }
+ if (linkmode_test_bit(ETHTOOL_LINK_MODE_1000baseT_Full_BIT, eee->advertised)) {
+ if (port_eee_cur_cfg.capability & FAL_PHY_EEE_1000BASE_T) {
+ port_eee_cfg.advertisement |= FAL_PHY_EEE_1000BASE_T;
+ } else {
+ netdev_dbg(netdev, "Advertised value 1000baseT_Full is not supported\n");
+ return -EIO;
+ }
+ }
+ if (linkmode_test_bit(ETHTOOL_LINK_MODE_2500baseX_Full_BIT, eee->advertised)) {
+ if (port_eee_cur_cfg.capability & FAL_PHY_EEE_2500BASE_T) {
+ port_eee_cfg.advertisement |= FAL_PHY_EEE_2500BASE_T;
+ } else {
+ netdev_dbg(netdev, "Advertised value 2500baseX_Full is not supported\n");
+ return -EIO;
+ }
+ }
+ if (linkmode_test_bit(ETHTOOL_LINK_MODE_10000baseT_Full_BIT, eee->advertised)) {
+ if (port_eee_cur_cfg.capability & FAL_PHY_EEE_10000BASE_T) {
+ port_eee_cfg.advertisement |= FAL_PHY_EEE_10000BASE_T;
+ } else {
+ netdev_dbg(netdev, "Advertised value 1000baseT_Full is not supported\n");
+ return -EIO;
+ }
+ }
+#endif
port_eee_cfg.lpi_tx_enable = eee->tx_lpi_enabled;
port_eee_cfg.lpi_sleep_timer = eee->tx_lpi_timer;
@@ -482,8 +550,10 @@ struct ethtool_ops nss_dp_ethtool_ops =
#endif
.get_pauseparam = &nss_dp_get_pauseparam,
.set_pauseparam = &nss_dp_set_pauseparam,
+
.get_eee = &nss_dp_get_eee,
.set_eee = &nss_dp_set_eee,
+
.get_priv_flags = nss_dp_get_priv_flags,
.set_priv_flags = nss_dp_set_priv_flags,
};