Re: re(4) feature flags additions and changes

2014-09-05 Thread Jonathan Gray
On Tue, Sep 02, 2014 at 07:20:30AM -0400, Brad Smith wrote:
 On Tue, Sep 02, 2014 at 06:28:48AM -0400, Brad Smith wrote:
  Add some feature flags and store in the softc the various max Jumbo frame 
  sizes
  for the different generations of chips. No behavioral change.
  
  Tested with..
  
  re0 at pci2 dev 0 function 0 Realtek 8168 rev 0x03: RTL8168D/8111D 
  (0x2800)
  re0 at pci2 dev 0 function 0 Realtek 8168 rev 0x0c: RTL8168G/8111G 
  (0x4c00)
  
  OK?
 
 Fix a typo with RL_FLAG_HWIM.

Why not leave the assignment of sc_hwrev in re.c and stash the product
as sc_product or some such?

   case RL_HWREV_8168C:
   case RL_HWREV_8168CP:
 - case RL_HWREV_8168DP:
 - sc-rl_flags |= RL_FLAG_INVMAR | RL_FLAG_PHYWAKE |
 - RL_FLAG_PAR | RL_FLAG_DESCV2 | RL_FLAG_MACSTAT |
 - RL_FLAG_HWIM | RL_FLAG_CMDSTOP | RL_FLAG_AUTOPAD;
 - /*
 -  * These controllers support jumbo frame but it seems
 -  * that enabling it requires touching additional magic
 -  * registers. Depending on MAC revisions some
 -  * controllers need to disable checksum offload. So
 -  * disable jumbo frame until I have better idea what
 -  * it really requires to make it support.
 -  * RTL8168C/CP : supports up to 6KB jumbo frame.
 -  * RTL8111C/CP : supports up to 9KB jumbo frame.
 -  */
 - sc-rl_flags |= RL_FLAG_NOJUMBO;
 + sc-rl_flags |= RL_FLAG_PHYWAKE | RL_FLAG_PAR |
 + RL_FLAG_DESCV2 | RL_FLAG_MACSTAT | RL_FLAG_CMDSTOP |
 + RL_FLAG_AUTOPAD | RL_FLAG_JUMBOV2 | RL_FLAG_WOL_MANLINK;
 + sc-rl_max_mtu = RL_JUMBO_MTU_6K;
   break;

Assuming the goal is the sync these flags with the FreeBSD driver this
misses:

case RL_HWREV_8168C:
if (sc-rl_macrev == 0x0020)
sc-rl_flags |= RL_FLAG_MACSLEEP;
/* FALLTHROUGH */
case RL_HWREV_8168CP:

macrev is not sc_hwrev but is read from the same RL_TXCFG register
with a different mask (0x0070).

The other flags and jumbo values all seem to match FreeBSD
from a quick comparison.

 @@ -957,8 +981,8 @@ re_attach(struct rl_softc *sc, const cha
   ifp-if_ioctl = re_ioctl;
   ifp-if_start = re_start;
   ifp-if_watchdog = re_watchdog;
 - if ((sc-rl_flags  RL_FLAG_NOJUMBO) == 0)
 - ifp-if_hardmtu = RL_JUMBO_MTU;
 + if ((sc-rl_flags  RL_FLAG_JUMBOV2) == 0)
 + ifp-if_hardmtu = sc-rl_max_mtu;
   IFQ_SET_MAXLEN(ifp-if_snd, RL_TX_QLEN);
   IFQ_SET_READY(ifp-if_snd);
  

Anything with RL_FLAG_JUMBOV2 won't do jumbos, because
the relevant code for this isn't there at the moment?



Re: re(4) feature flags additions and changes

2014-09-05 Thread Brad Smith

On 05/09/14 2:24 AM, Jonathan Gray wrote:

On Tue, Sep 02, 2014 at 07:20:30AM -0400, Brad Smith wrote:

On Tue, Sep 02, 2014 at 06:28:48AM -0400, Brad Smith wrote:

Add some feature flags and store in the softc the various max Jumbo frame sizes
for the different generations of chips. No behavioral change.

Tested with..

re0 at pci2 dev 0 function 0 Realtek 8168 rev 0x03: RTL8168D/8111D (0x2800)
re0 at pci2 dev 0 function 0 Realtek 8168 rev 0x0c: RTL8168G/8111G (0x4c00)

OK?


Fix a typo with RL_FLAG_HWIM.


Why not leave the assignment of sc_hwrev in re.c and stash the product
as sc_product or some such?


I had been considering that as well. I'll do that as what I had
was bugging me.


case RL_HWREV_8168C:
case RL_HWREV_8168CP:
-   case RL_HWREV_8168DP:
-   sc-rl_flags |= RL_FLAG_INVMAR | RL_FLAG_PHYWAKE |
-   RL_FLAG_PAR | RL_FLAG_DESCV2 | RL_FLAG_MACSTAT |
-   RL_FLAG_HWIM | RL_FLAG_CMDSTOP | RL_FLAG_AUTOPAD;
-   /*
-* These controllers support jumbo frame but it seems
-* that enabling it requires touching additional magic
-* registers. Depending on MAC revisions some
-* controllers need to disable checksum offload. So
-* disable jumbo frame until I have better idea what
-* it really requires to make it support.
-* RTL8168C/CP : supports up to 6KB jumbo frame.
-* RTL8111C/CP : supports up to 9KB jumbo frame.
-*/
-   sc-rl_flags |= RL_FLAG_NOJUMBO;
+   sc-rl_flags |= RL_FLAG_PHYWAKE | RL_FLAG_PAR |
+   RL_FLAG_DESCV2 | RL_FLAG_MACSTAT | RL_FLAG_CMDSTOP |
+   RL_FLAG_AUTOPAD | RL_FLAG_JUMBOV2 | RL_FLAG_WOL_MANLINK;
+   sc-rl_max_mtu = RL_JUMBO_MTU_6K;
break;


Assuming the goal is the sync these flags with the FreeBSD driver this
misses:


It's to get as close as possible more or less.


case RL_HWREV_8168C:
if (sc-rl_macrev == 0x0020)
sc-rl_flags |= RL_FLAG_MACSLEEP;
/* FALLTHROUGH */
case RL_HWREV_8168CP:

macrev is not sc_hwrev but is read from the same RL_TXCFG register
with a different mask (0x0070).


I'll see about adding that in later. I haven't seen anyone mentioning
any issues with re(4) that might be attributed to the lack of code to
kick the controller out of deep sleep mode so it isn't a priority.


The other flags and jumbo values all seem to match FreeBSD
from a quick comparison.


@@ -957,8 +981,8 @@ re_attach(struct rl_softc *sc, const cha
ifp-if_ioctl = re_ioctl;
ifp-if_start = re_start;
ifp-if_watchdog = re_watchdog;
-   if ((sc-rl_flags  RL_FLAG_NOJUMBO) == 0)
-   ifp-if_hardmtu = RL_JUMBO_MTU;
+   if ((sc-rl_flags  RL_FLAG_JUMBOV2) == 0)
+   ifp-if_hardmtu = sc-rl_max_mtu;
IFQ_SET_MAXLEN(ifp-if_snd, RL_TX_QLEN);
IFQ_SET_READY(ifp-if_snd);



Anything with RL_FLAG_JUMBOV2 won't do jumbos, because
the relevant code for this isn't there at the moment?


Basically, yes.

--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.



Re: re(4) feature flags additions and changes

2014-09-05 Thread Brad Smith
On Tue, Sep 02, 2014 at 07:20:30AM -0400, Brad Smith wrote:
 On Tue, Sep 02, 2014 at 06:28:48AM -0400, Brad Smith wrote:
  Add some feature flags and store in the softc the various max Jumbo frame 
  sizes
  for the different generations of chips. No behavioral change.
  
  Tested with..
  
  re0 at pci2 dev 0 function 0 Realtek 8168 rev 0x03: RTL8168D/8111D 
  (0x2800)
  re0 at pci2 dev 0 function 0 Realtek 8168 rev 0x0c: RTL8168G/8111G 
  (0x4c00)
  
  OK?
 
 Fix a typo with RL_FLAG_HWIM.

So store the PCI id in the sc_product field instead. The CardBus bit is not
strictly necessary but I'd rather be consistent for both bus frontends for
now especially if I happen to use this field for anything else in the future.

 
Index: pci/if_re_pci.c
===
RCS file: /home/cvs/src/sys/dev/pci/if_re_pci.c,v
retrieving revision 1.41
diff -u -p -u -p -r1.41 if_re_pci.c
--- pci/if_re_pci.c 22 Jul 2014 13:12:11 -  1.41
+++ pci/if_re_pci.c 5 Sep 2014 18:20:49 -
@@ -197,6 +197,8 @@ re_pci_attach(struct device *parent, str
CSR_WRITE_1(sc, RL_EECMD, RL_EEMODE_OFF);
}
 
+   sc-sc_product = PCI_PRODUCT(pa-pa_id);
+
/* Call bus-independent attach routine */
if (re_attach(sc, intrstr)) {
pci_intr_disestablish(pc, psc-sc_ih);
Index: cardbus/if_re_cardbus.c
===
RCS file: /home/cvs/src/sys/dev/cardbus/if_re_cardbus.c,v
retrieving revision 1.24
diff -u -p -u -p -r1.24 if_re_cardbus.c
--- cardbus/if_re_cardbus.c 11 Aug 2014 12:45:45 -  1.24
+++ cardbus/if_re_cardbus.c 5 Sep 2014 18:19:48 -
@@ -152,6 +152,8 @@ re_cardbus_attach(struct device *parent,
}
snprintf(intrstr, sizeof(intrstr), irq %d, ca-ca_intrline);
 
+   sc-sc_product = PCI_PRODUCT(ca-ca_id);
+
/* Call bus-independent (common) attach routine */
if (re_attach(sc, intrstr)) {
cardbus_intr_disestablish(ct-ct_cc, ct-ct_cf, csc-sc_ih);
Index: ic/re.c
===
RCS file: /home/cvs/src/sys/dev/ic/re.c,v
retrieving revision 1.155
diff -u -p -u -p -r1.155 re.c
--- ic/re.c 22 Jul 2014 13:12:12 -  1.155
+++ ic/re.c 5 Sep 2014 18:26:19 -
@@ -144,6 +144,7 @@
 
 #include dev/pci/pcireg.h
 #include dev/pci/pcivar.h
+#include dev/pci/pcidevs.h
 
 #include dev/ic/rtl81x9reg.h
 #include dev/ic/revar.h
@@ -578,7 +579,7 @@ re_iff(struct rl_softc *sc)
 * parts. This means we have to write the hash pattern in reverse
 * order for those devices.
 */
-   if (sc-rl_flags  RL_FLAG_INVMAR) {
+   if (sc-rl_flags  RL_FLAG_PCIE) {
CSR_WRITE_4(sc, RL_MAR0, swap32(hashes[1]));
CSR_WRITE_4(sc, RL_MAR4, swap32(hashes[0]));
} else {
@@ -604,7 +605,7 @@ re_reset(struct rl_softc *sc)
if (i == RL_TIMEOUT)
printf(%s: reset never completed!\n, sc-sc_dev.dv_xname);
 
-   if (sc-rl_flags  RL_FLAG_MACLDPS)
+   if (sc-rl_flags  RL_FLAG_MACRESET)
CSR_WRITE_1(sc, RL_LDPS, 1);
 }
 
@@ -639,13 +640,14 @@ re_attach(struct rl_softc *sc, const cha
 
switch (sc-sc_hwrev) {
case RL_HWREV_8139CPLUS:
-   sc-rl_flags |= RL_FLAG_NOJUMBO | RL_FLAG_AUTOPAD;
+   sc-rl_flags |= RL_FLAG_FASTETHER | RL_FLAG_AUTOPAD;
+   sc-rl_max_mtu = RL_MTU;
break;
case RL_HWREV_8100E:
case RL_HWREV_8100E_SPIN2:
case RL_HWREV_8101E:
-   sc-rl_flags |= RL_FLAG_NOJUMBO | RL_FLAG_INVMAR |
-   RL_FLAG_PHYWAKE;
+   sc-rl_flags |= RL_FLAG_PHYWAKE | RL_FLAG_FASTETHER;
+   sc-rl_max_mtu = RL_MTU;
break;
case RL_HWREV_8103E:
sc-rl_flags |= RL_FLAG_MACSLEEP;
@@ -653,70 +655,103 @@ re_attach(struct rl_softc *sc, const cha
case RL_HWREV_8102E:
case RL_HWREV_8102EL:
case RL_HWREV_8102EL_SPIN1:
-   sc-rl_flags |= RL_FLAG_NOJUMBO | RL_FLAG_INVMAR |
-   RL_FLAG_PHYWAKE | RL_FLAG_PAR | RL_FLAG_DESCV2 |
-   RL_FLAG_MACSTAT | RL_FLAG_CMDSTOP | RL_FLAG_AUTOPAD;
+   sc-rl_flags |= RL_FLAG_PHYWAKE | RL_FLAG_PAR |
+   RL_FLAG_DESCV2 | RL_FLAG_MACSTAT | RL_FLAG_FASTETHER |
+   RL_FLAG_CMDSTOP | RL_FLAG_AUTOPAD;
+   sc-rl_max_mtu = RL_MTU;
break;
case RL_HWREV_8401E:
-   case RL_HWREV_8402:
case RL_HWREV_8105E:
case RL_HWREV_8105E_SPIN1:
case RL_HWREV_8106E:
-   sc-rl_flags |= RL_FLAG_INVMAR | RL_FLAG_PHYWAKE |
-   RL_FLAG_PHYWAKE_PM | RL_FLAG_PAR | RL_FLAG_DESCV2 |
-   RL_FLAG_MACSTAT | RL_FLAG_CMDSTOP | RL_FLAG_AUTOPAD |
-   RL_FLAG_NOJUMBO;
+   sc-rl_flags |= RL_FLAG_PHYWAKE | 

Re: re(4) feature flags additions and changes

2014-09-05 Thread Jonathan Gray
On Fri, Sep 05, 2014 at 03:10:01PM -0400, Brad Smith wrote:
 On Tue, Sep 02, 2014 at 07:20:30AM -0400, Brad Smith wrote:
  On Tue, Sep 02, 2014 at 06:28:48AM -0400, Brad Smith wrote:
   Add some feature flags and store in the softc the various max Jumbo frame 
   sizes
   for the different generations of chips. No behavioral change.
   
   Tested with..
   
   re0 at pci2 dev 0 function 0 Realtek 8168 rev 0x03: RTL8168D/8111D 
   (0x2800)
   re0 at pci2 dev 0 function 0 Realtek 8168 rev 0x0c: RTL8168G/8111G 
   (0x4c00)
   
   OK?
  
  Fix a typo with RL_FLAG_HWIM.
 
 So store the PCI id in the sc_product field instead. The CardBus bit is not
 strictly necessary but I'd rather be consistent for both bus frontends for
 now especially if I happen to use this field for anything else in the future.
 

 + pci_vendor_id_t sc_product;

OK, but this should be uint16_t as re.c should really have

Index: re.c
===
RCS file: /cvs/src/sys/dev/ic/re.c,v
retrieving revision 1.155
diff -u -p -r1.155 re.c
--- re.c22 Jul 2014 13:12:12 -  1.155
+++ re.c6 Sep 2014 03:53:02 -
@@ -121,6 +121,8 @@
 #include sys/timeout.h
 #include sys/socket.h
 
+#include machine/bus.h
+
 #include net/if.h
 #include net/if_dl.h
 #include net/if_media.h
@@ -141,9 +143,6 @@
 
 #include dev/mii/mii.h
 #include dev/mii/miivar.h
-
-#include dev/pci/pcireg.h
-#include dev/pci/pcivar.h
 
 #include dev/ic/rtl81x9reg.h
 #include dev/ic/revar.h



re(4) feature flags additions and changes

2014-09-02 Thread Brad Smith
Add some feature flags and store in the softc the various max Jumbo frame sizes
for the different generations of chips. No behavioral change.

Tested with..

re0 at pci2 dev 0 function 0 Realtek 8168 rev 0x03: RTL8168D/8111D (0x2800)
re0 at pci2 dev 0 function 0 Realtek 8168 rev 0x0c: RTL8168G/8111G (0x4c00)

OK?


Index: pci/if_re_pci.c
===
RCS file: /home/cvs/src/sys/dev/pci/if_re_pci.c,v
retrieving revision 1.41
diff -u -p -u -p -r1.41 if_re_pci.c
--- pci/if_re_pci.c 22 Jul 2014 13:12:11 -  1.41
+++ pci/if_re_pci.c 20 Aug 2014 02:06:34 -
@@ -197,6 +197,23 @@ re_pci_attach(struct device *parent, str
CSR_WRITE_1(sc, RL_EECMD, RL_EEMODE_OFF);
}
 
+   sc-sc_hwrev = CSR_READ_4(sc, RL_TXCFG)  RL_TXCFG_HWREV;
+
+   switch (sc-sc_hwrev) {
+   case RL_HWREV_8168GU:
+   if (PCI_PRODUCT(pa-pa_id) == PCI_PRODUCT_REALTEK_RT8101E) {
+   /* RTL8106EUS */
+   sc-rl_flags |= RL_FLAG_FASTETHER;
+   sc-rl_max_mtu = RL_MTU;
+   } else {
+   sc-rl_flags |= RL_FLAG_JUMBOV2 | RL_FLAG_WOL_MANLINK;
+   sc-rl_max_mtu = RL_JUMBO_MTU_9K;
+   }
+   break;
+   default:
+   break;
+   }
+
/* Call bus-independent attach routine */
if (re_attach(sc, intrstr)) {
pci_intr_disestablish(pc, psc-sc_ih);
Index: cardbus/if_re_cardbus.c
===
RCS file: /home/cvs/src/sys/dev/cardbus/if_re_cardbus.c,v
retrieving revision 1.24
diff -u -p -u -p -r1.24 if_re_cardbus.c
--- cardbus/if_re_cardbus.c 11 Aug 2014 12:45:45 -  1.24
+++ cardbus/if_re_cardbus.c 24 Aug 2014 23:09:04 -
@@ -152,6 +152,8 @@ re_cardbus_attach(struct device *parent,
}
snprintf(intrstr, sizeof(intrstr), irq %d, ca-ca_intrline);
 
+   sc-sc_hwrev = CSR_READ_4(sc, RL_TXCFG)  RL_TXCFG_HWREV;
+
/* Call bus-independent (common) attach routine */
if (re_attach(sc, intrstr)) {
cardbus_intr_disestablish(ct-ct_cc, ct-ct_cf, csc-sc_ih);
Index: ic/re.c
===
RCS file: /home/cvs/src/sys/dev/ic/re.c,v
retrieving revision 1.155
diff -u -p -u -p -r1.155 re.c
--- ic/re.c 22 Jul 2014 13:12:12 -  1.155
+++ ic/re.c 24 Aug 2014 23:09:05 -
@@ -578,7 +578,7 @@ re_iff(struct rl_softc *sc)
 * parts. This means we have to write the hash pattern in reverse
 * order for those devices.
 */
-   if (sc-rl_flags  RL_FLAG_INVMAR) {
+   if (sc-rl_flags  RL_FLAG_PCIE) {
CSR_WRITE_4(sc, RL_MAR0, swap32(hashes[1]));
CSR_WRITE_4(sc, RL_MAR4, swap32(hashes[0]));
} else {
@@ -604,7 +604,7 @@ re_reset(struct rl_softc *sc)
if (i == RL_TIMEOUT)
printf(%s: reset never completed!\n, sc-sc_dev.dv_xname);
 
-   if (sc-rl_flags  RL_FLAG_MACLDPS)
+   if (sc-rl_flags  RL_FLAG_MACRESET)
CSR_WRITE_1(sc, RL_LDPS, 1);
 }
 
@@ -635,17 +635,16 @@ re_attach(struct rl_softc *sc, const cha
const struct re_revision *rr;
const char  *re_name = NULL;
 
-   sc-sc_hwrev = CSR_READ_4(sc, RL_TXCFG)  RL_TXCFG_HWREV;
-
switch (sc-sc_hwrev) {
case RL_HWREV_8139CPLUS:
-   sc-rl_flags |= RL_FLAG_NOJUMBO | RL_FLAG_AUTOPAD;
+   sc-rl_flags |= RL_FLAG_FASTETHER | RL_FLAG_AUTOPAD;
+   sc-rl_max_mtu = RL_MTU;
break;
case RL_HWREV_8100E:
case RL_HWREV_8100E_SPIN2:
case RL_HWREV_8101E:
-   sc-rl_flags |= RL_FLAG_NOJUMBO | RL_FLAG_INVMAR |
-   RL_FLAG_PHYWAKE;
+   sc-rl_flags |= RL_FLAG_PHYWAKE | RL_FLAG_FASTETHER;
+   sc-rl_max_mtu = RL_MTU;
break;
case RL_HWREV_8103E:
sc-rl_flags |= RL_FLAG_MACSLEEP;
@@ -653,70 +652,94 @@ re_attach(struct rl_softc *sc, const cha
case RL_HWREV_8102E:
case RL_HWREV_8102EL:
case RL_HWREV_8102EL_SPIN1:
-   sc-rl_flags |= RL_FLAG_NOJUMBO | RL_FLAG_INVMAR |
-   RL_FLAG_PHYWAKE | RL_FLAG_PAR | RL_FLAG_DESCV2 |
-   RL_FLAG_MACSTAT | RL_FLAG_CMDSTOP | RL_FLAG_AUTOPAD;
+   sc-rl_flags |= RL_FLAG_PHYWAKE | RL_FLAG_PAR |
+   RL_FLAG_DESCV2 | RL_FLAG_MACSTAT | RL_FLAG_FASTETHER |
+   RL_FLAG_CMDSTOP | RL_FLAG_AUTOPAD;
+   sc-rl_max_mtu = RL_MTU;
break;
case RL_HWREV_8401E:
-   case RL_HWREV_8402:
case RL_HWREV_8105E:
case RL_HWREV_8105E_SPIN1:
case RL_HWREV_8106E:
-   sc-rl_flags |= RL_FLAG_INVMAR | RL_FLAG_PHYWAKE |
-   RL_FLAG_PHYWAKE_PM | RL_FLAG_PAR | RL_FLAG_DESCV2 |
-   

Re: re(4) feature flags additions and changes

2014-09-02 Thread Jonathan Gray
On Tue, Sep 02, 2014 at 06:28:48AM -0400, Brad Smith wrote:
 Add some feature flags and store in the softc the various max Jumbo frame 
 sizes
 for the different generations of chips. No behavioral change.
 
 Tested with..
 
 re0 at pci2 dev 0 function 0 Realtek 8168 rev 0x03: RTL8168D/8111D (0x2800)
 re0 at pci2 dev 0 function 0 Realtek 8168 rev 0x0c: RTL8168G/8111G (0x4c00)
 
 OK?

This would be a much easier diff to read if you didn't change
the names of a whole bunch of flags.

 +#define  RL_FLAG_HWIM0x00800
 +#define  RL_FLAG_MACSLEEP0x0800

This is obviously wrong.



Re: re(4) feature flags additions and changes

2014-09-02 Thread Brad Smith
On Tue, Sep 02, 2014 at 06:28:48AM -0400, Brad Smith wrote:
 Add some feature flags and store in the softc the various max Jumbo frame 
 sizes
 for the different generations of chips. No behavioral change.
 
 Tested with..
 
 re0 at pci2 dev 0 function 0 Realtek 8168 rev 0x03: RTL8168D/8111D (0x2800)
 re0 at pci2 dev 0 function 0 Realtek 8168 rev 0x0c: RTL8168G/8111G (0x4c00)
 
 OK?

Fix a typo with RL_FLAG_HWIM.


Index: pci/if_re_pci.c
===
RCS file: /home/cvs/src/sys/dev/pci/if_re_pci.c,v
retrieving revision 1.41
diff -u -p -u -p -r1.41 if_re_pci.c
--- pci/if_re_pci.c 22 Jul 2014 13:12:11 -  1.41
+++ pci/if_re_pci.c 20 Aug 2014 02:06:34 -
@@ -197,6 +197,23 @@ re_pci_attach(struct device *parent, str
CSR_WRITE_1(sc, RL_EECMD, RL_EEMODE_OFF);
}
 
+   sc-sc_hwrev = CSR_READ_4(sc, RL_TXCFG)  RL_TXCFG_HWREV;
+
+   switch (sc-sc_hwrev) {
+   case RL_HWREV_8168GU:
+   if (PCI_PRODUCT(pa-pa_id) == PCI_PRODUCT_REALTEK_RT8101E) {
+   /* RTL8106EUS */
+   sc-rl_flags |= RL_FLAG_FASTETHER;
+   sc-rl_max_mtu = RL_MTU;
+   } else {
+   sc-rl_flags |= RL_FLAG_JUMBOV2 | RL_FLAG_WOL_MANLINK;
+   sc-rl_max_mtu = RL_JUMBO_MTU_9K;
+   }
+   break;
+   default:
+   break;
+   }
+
/* Call bus-independent attach routine */
if (re_attach(sc, intrstr)) {
pci_intr_disestablish(pc, psc-sc_ih);
Index: cardbus/if_re_cardbus.c
===
RCS file: /home/cvs/src/sys/dev/cardbus/if_re_cardbus.c,v
retrieving revision 1.24
diff -u -p -u -p -r1.24 if_re_cardbus.c
--- cardbus/if_re_cardbus.c 11 Aug 2014 12:45:45 -  1.24
+++ cardbus/if_re_cardbus.c 24 Aug 2014 23:09:04 -
@@ -152,6 +152,8 @@ re_cardbus_attach(struct device *parent,
}
snprintf(intrstr, sizeof(intrstr), irq %d, ca-ca_intrline);
 
+   sc-sc_hwrev = CSR_READ_4(sc, RL_TXCFG)  RL_TXCFG_HWREV;
+
/* Call bus-independent (common) attach routine */
if (re_attach(sc, intrstr)) {
cardbus_intr_disestablish(ct-ct_cc, ct-ct_cf, csc-sc_ih);
Index: ic/re.c
===
RCS file: /home/cvs/src/sys/dev/ic/re.c,v
retrieving revision 1.155
diff -u -p -u -p -r1.155 re.c
--- ic/re.c 22 Jul 2014 13:12:12 -  1.155
+++ ic/re.c 24 Aug 2014 23:09:05 -
@@ -578,7 +578,7 @@ re_iff(struct rl_softc *sc)
 * parts. This means we have to write the hash pattern in reverse
 * order for those devices.
 */
-   if (sc-rl_flags  RL_FLAG_INVMAR) {
+   if (sc-rl_flags  RL_FLAG_PCIE) {
CSR_WRITE_4(sc, RL_MAR0, swap32(hashes[1]));
CSR_WRITE_4(sc, RL_MAR4, swap32(hashes[0]));
} else {
@@ -604,7 +604,7 @@ re_reset(struct rl_softc *sc)
if (i == RL_TIMEOUT)
printf(%s: reset never completed!\n, sc-sc_dev.dv_xname);
 
-   if (sc-rl_flags  RL_FLAG_MACLDPS)
+   if (sc-rl_flags  RL_FLAG_MACRESET)
CSR_WRITE_1(sc, RL_LDPS, 1);
 }
 
@@ -635,17 +635,16 @@ re_attach(struct rl_softc *sc, const cha
const struct re_revision *rr;
const char  *re_name = NULL;
 
-   sc-sc_hwrev = CSR_READ_4(sc, RL_TXCFG)  RL_TXCFG_HWREV;
-
switch (sc-sc_hwrev) {
case RL_HWREV_8139CPLUS:
-   sc-rl_flags |= RL_FLAG_NOJUMBO | RL_FLAG_AUTOPAD;
+   sc-rl_flags |= RL_FLAG_FASTETHER | RL_FLAG_AUTOPAD;
+   sc-rl_max_mtu = RL_MTU;
break;
case RL_HWREV_8100E:
case RL_HWREV_8100E_SPIN2:
case RL_HWREV_8101E:
-   sc-rl_flags |= RL_FLAG_NOJUMBO | RL_FLAG_INVMAR |
-   RL_FLAG_PHYWAKE;
+   sc-rl_flags |= RL_FLAG_PHYWAKE | RL_FLAG_FASTETHER;
+   sc-rl_max_mtu = RL_MTU;
break;
case RL_HWREV_8103E:
sc-rl_flags |= RL_FLAG_MACSLEEP;
@@ -653,70 +652,94 @@ re_attach(struct rl_softc *sc, const cha
case RL_HWREV_8102E:
case RL_HWREV_8102EL:
case RL_HWREV_8102EL_SPIN1:
-   sc-rl_flags |= RL_FLAG_NOJUMBO | RL_FLAG_INVMAR |
-   RL_FLAG_PHYWAKE | RL_FLAG_PAR | RL_FLAG_DESCV2 |
-   RL_FLAG_MACSTAT | RL_FLAG_CMDSTOP | RL_FLAG_AUTOPAD;
+   sc-rl_flags |= RL_FLAG_PHYWAKE | RL_FLAG_PAR |
+   RL_FLAG_DESCV2 | RL_FLAG_MACSTAT | RL_FLAG_FASTETHER |
+   RL_FLAG_CMDSTOP | RL_FLAG_AUTOPAD;
+   sc-rl_max_mtu = RL_MTU;
break;
case RL_HWREV_8401E:
-   case RL_HWREV_8402:
case RL_HWREV_8105E:
case RL_HWREV_8105E_SPIN1:
case RL_HWREV_8106E:
-   sc-rl_flags |= RL_FLAG_INVMAR | 

Re: re(4) feature flags additions and changes

2014-09-02 Thread Brad Smith
On Tue, Sep 02, 2014 at 09:03:34PM +1000, Jonathan Gray wrote:
 On Tue, Sep 02, 2014 at 06:28:48AM -0400, Brad Smith wrote:
  Add some feature flags and store in the softc the various max Jumbo frame 
  sizes
  for the different generations of chips. No behavioral change.
  
  Tested with..
  
  re0 at pci2 dev 0 function 0 Realtek 8168 rev 0x03: RTL8168D/8111D 
  (0x2800)
  re0 at pci2 dev 0 function 0 Realtek 8168 rev 0x0c: RTL8168G/8111G 
  (0x4c00)
  
  OK?
 
 This would be a much easier diff to read if you didn't change
 the names of a whole bunch of flags.

Changed.. RL_FLAG_MACLDPS - RL_FLAG_MACRESET.
Removed.. RL_FLAG_INVMAR, RL_FLAG_NOJUMBO.
Added.. RL_FLAG_FASTETHER, RL_FLAG_CMDSTOP_WAIT_TXQ, RL_FLAG_JUMBOV2, 
RL_FLAG_WOL_MANLINK,
RL_FLAG_WAIT_TXPOLL, RL_FLAG_WOLRXENB.

  +#defineRL_FLAG_HWIM0x00800
  +#defineRL_FLAG_MACSLEEP0x0800
 
 This is obviously wrong.

A typo. Fixed. Thanks.

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.