shithub: riscv

Download patch

ref: 682e47137a819304420cf6153b1ee827ce1531a8
parent: 3ff88ede016fe49fd4d3f222e85db0cf70c39e17
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Mon Jan 6 19:45:41 EST 2025

ether2114x: fix automatic media detection

We used to reject media info if FD was not specified
in plan9.ini. Instead, initialize fd override to -1
which makes us use it if the infoblock tells us to
and provide a "HD" option to force half-duplex mode.

This makes the media detection work on hyper-v.

--- a/sys/src/9/pc/ether2114x.c
+++ b/sys/src/9/pc/ether2114x.c
@@ -1623,7 +1623,7 @@
 		}
 	}
 
-	ctlr->fd = 0;
+	ctlr->fd = -1;
 	ctlr->medium = -1;
 
 	return 0;
@@ -1776,13 +1776,15 @@
 	 * (no MII) or the autonegotiation fails.
 	 */
 	for(i = 0; i < ether->nopt; i++){
+		if(cistrcmp(ether->opt[i], "HD") == 0){
+			ctlr->fd = 0;
+			continue;
+		}
 		if(cistrcmp(ether->opt[i], "FD") == 0){
 			ctlr->fd = 1;
 			continue;
 		}
 		for(x = 0; x < nelem(mediatable); x++){
-			debug("compare <%s> <%s>\n", mediatable[x],
-				ether->opt[i]);
 			if(cistrcmp(mediatable[x], ether->opt[i]))
 				continue;
 			ctlr->medium = x;
@@ -1803,6 +1805,7 @@
 	}
 
 	ether->mbps = media(ether, 1);
+	ether->link = ether->mbps != 0;
 
 	/*
 	 * Initialise descriptor rings, ethernet address.
--