On 2016/04/19 18:14, Stuart Henderson wrote: > On 2016/04/19 18:57, Christian Weisgerber wrote: > > Stuart Henderson: > > > > > Looking at unique "RTL8168E/8111E (0x2c00)" entries from dmesglog > > > back to Feb 2013, there are 7 APUs (=21 NICs), and 20 non-APUs. > > > Do we care if we change led state for those others too? We could > > > check the MAC vendor for 00:0d:b9, but I think this is unnecessary > > > complexity (and who knows, maybe it's an improvement for some of > > > those too). > > > > Checking the MAC address is brittle since it can be changed (ifconfig > > lladdr). Instead, I suggest checking hw_vendor and hw_prod; see > > for instance what skgpio(4) does. I don't think blindly reprogramming > > the LED state for all chips of this type is acceptable. > > Ah that's not a bad idea, I'll take a look. I'll need a tester for > that as the board I was using is in production now.
Done in diff below. I switched to one led for link, one flashing on for activity as I think the majority of people who commented preferred that over having indication of gig link. Whether or not this goes in, I'll be using some variant of this for remote boxes using this board, there's too much risk of people thinking the box is broken and trying to power-cycle to "fix" it otherwise. text data bss dec hex 19112 32 0 19144 4ac8 re.o 19287 32 0 19319 4b77 re.o (obviously it's larger with the strcmp). Index: re.c =================================================================== RCS file: /cvs/src/sys/dev/ic/re.c,v retrieving revision 1.191 diff -u -p -r1.191 re.c --- re.c 13 Apr 2016 10:49:26 -0000 1.191 +++ re.c 19 Apr 2016 20:22:03 -0000 @@ -198,6 +198,8 @@ struct cfdriver re_cd = { 0, "re", DV_IFNET }; +extern char *hw_vendor, *hw_prod; + #define EE_SET(x) \ CSR_WRITE_1(sc, RL_EECMD, \ CSR_READ_1(sc, RL_EECMD) | x) @@ -1940,6 +1942,21 @@ re_init(struct ifnet *ifp) htole32(*(u_int32_t *)(&eaddr.eaddr[4]))); CSR_WRITE_4(sc, RL_IDR0, htole32(*(u_int32_t *)(&eaddr.eaddr[0]))); + /* + * Default on PC Engines APU1 is to have all LEDs off unless + * there is network activity. Override to provide a link status + * LED. + */ + if (sc->sc_hwrev == RL_HWREV_8168E && + hw_vendor != NULL && hw_prod != NULL && + strcmp(hw_vendor, "PC Engines") == 0 && + strcmp(hw_prod, "APU") == 0) { + CSR_SETBIT_1(sc, RL_CFG4, RL_CFG4_CUSTOM_LED); + CSR_WRITE_1(sc, RL_LEDSEL, RL_LED_LINK | RL_LED_ACT << 4); + } + /* + * Protect config register again + */ CSR_WRITE_1(sc, RL_EECMD, RL_EEMODE_OFF); if ((sc->rl_flags & RL_FLAG_JUMBOV2) != 0) Index: rtl81x9reg.h =================================================================== RCS file: /cvs/src/sys/dev/ic/rtl81x9reg.h,v retrieving revision 1.97 diff -u -p -r1.97 rtl81x9reg.h --- rtl81x9reg.h 28 Dec 2015 05:49:15 -0000 1.97 +++ rtl81x9reg.h 19 Apr 2016 20:22:03 -0000 @@ -153,6 +153,13 @@ #define RL_MISC 0x00F0 /* + * Register used on RTL8111E + */ +#define RL_LEDSEL 0x0018 +#define RL_LED_LINK 0x7 /* link at any speed */ +#define RL_LED_ACT 0x8 + +/* * TX config register bits */ #define RL_TXCFG_CLRABRT 0x00000001 /* retransmit aborted pkt */ @@ -449,6 +456,7 @@ /* * Config 4 register */ +#define RL_CFG4_CUSTOM_LED 0x40 #define RL_CFG4_LWPTN 0x04 #define RL_CFG4_LWPME 0x10 #define RL_CFG4_JUMBO_EN1 0x02