diff mbox series

[v2,09/11,RFC] net: phylink: Add support for CRS-based rate adaptation

Message ID 20220719235002.1944800-10-sean.anderson@seco.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series net: phy: Add support for rate adaptation | expand

Checks

Context Check Description
netdev/tree_selection success Guessed tree name to be net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix warning Target tree name not specified in the subject
netdev/cover_letter success Series has a cover letter
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit fail Errors and warnings before: 4 this patch: 4
netdev/cc_maintainers success CCed 8 of 8 maintainers
netdev/build_clang fail Errors and warnings before: 4 this patch: 4
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn fail Errors and warnings before: 4 this patch: 4
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 20 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Sean Anderson July 19, 2022, 11:49 p.m. UTC
This adds support for CRS-based rate adaptation, such as the type used
for 10PASS-TS and 2BASE-TL. As these link modes are not supported by any
in-tree phy, this patch is marked as RFC. It serves chiefly to
illustrate the approach to adding support for another rate adaptation
type.

Signed-off-by: Sean Anderson <sean.anderson@seco.com>
---

(no changes since v1)

 drivers/net/phy/phylink.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
index f61040c93f3c..75b4994d68c8 100644
--- a/drivers/net/phy/phylink.c
+++ b/drivers/net/phy/phylink.c
@@ -553,9 +553,18 @@  unsigned long phylink_get_capabilities(phy_interface_t interface,
 		adapted_caps &= ~(MAC_1000HD | MAC_100HD | MAC_10HD);
 		break;
 	}
-	case RATE_ADAPT_CRS:
-		/* TODO */
+	case RATE_ADAPT_CRS: {
+		/* The MAC must support half duplex at the interface speed */
+		if (state.speed == SPEED_1000) {
+			if (mac_capabilities & MAC_1000HD)
+				adapted_caps = MAC_100 | MAC_10;
+		} else if (state.speed == SPEED_1000) {
+			if (mac_capabilities & MAC_100HD)
+				adapted_caps = MAC_10;
+		}
+		adapted_caps &= mac_capabilities;
 		break;
+	}
 	case RATE_ADAPT_OPEN_LOOP:
 		/* TODO */
 		break;