Re: alc(4) current for NetBSD 6.1.5, patch included

2015-01-25 Thread Emile `iMil' Heitor

On Sun, 25 Jan 2015, Leonardo Taccari wrote:


If someone has succesfully tested alc(4) on 813x/815x chipsets too can
we request a pull up for netbsd-7? It seems that the 816x chipsets are
common on various motherboards and laptopts.

What do you think?


Definitely a good idea as those chips are widely spread for a very long time
now. Also, I believe backporting it to 7.0 should be pretty straightforward.


Emile `iMil' Heitor * 
  _
| http://imil.net| ASCII ribbon campaign ( )
| http://www.NetBSD.org  |  - against HTML email  X
| http://gcu.info|  & vCards / \



Re: alc(4) current for NetBSD 6.1.5, patch included

2015-01-25 Thread Leonardo Taccari
Hello iMil and the entire NetBSD community,

"Emile `iMil' Heitor" writes:
> Using Leonardo Taccari's work on alc(4) for NetBSD current, I've enabled my
> AR8171 Gbe NIC on NetBSD 6.1.5 by porting the driver.
> Anyone interested, just apply the enclosed patch in src/sys/dev/pci then:
> 
> make -f Makefile.pcidevs in src/sys/dev/pci
> 
> and rebuild your kernel as usual.
If someone has succesfully tested alc(4) on 813x/815x chipsets too can
we request a pull up for netbsd-7? It seems that the 816x chipsets are
common on various motherboards and laptopts.

What do you think?


Thank you in advance for your attention!
Ciao,
L.


alc(4) current for NetBSD 6.1.5, patch included

2015-01-24 Thread Emile `iMil' Heitor


Hi,

Using Leonardo Taccari's work on alc(4) for NetBSD current, I've enabled my
AR8171 Gbe NIC on NetBSD 6.1.5 by porting the driver.
Anyone interested, just apply the enclosed patch in src/sys/dev/pci then:

make -f Makefile.pcidevs in src/sys/dev/pci

and rebuild your kernel as usual.

HTH


Emile `iMil' Heitor * 
  _
| http://imil.net| ASCII ribbon campaign ( )
| http://www.NetBSD.org  |  - against HTML email  X
| http://gcu.info|  & vCards / \Index: if_alc.c
===
RCS file: /cvsroot/src/sys/dev/pci/if_alc.c,v
retrieving revision 1.5
diff -u -r1.5 if_alc.c
--- if_alc.c29 Aug 2011 14:47:08 -  1.5
+++ if_alc.c24 Jan 2015 21:47:00 -
@@ -95,6 +95,16 @@
"Atheros AR8152 v1.1 PCIe Fast Ethernet" },
{ PCI_VENDOR_ATTANSIC, PCI_PRODUCT_ATTANSIC_AR8152_B2, 6 * 1024,
"Atheros AR8152 v2.0 PCIe Fast Ethernet" },
+   { PCI_VENDOR_ATTANSIC, PCI_PRODUCT_ATTANSIC_AR8161, 9 * 1024,
+   "Atheros AR8161 PCIe Gigabit Ethernet" },
+   { PCI_VENDOR_ATTANSIC, PCI_PRODUCT_ATTANSIC_AR8162, 9 * 1024,
+   "Atheros AR8162 PCIe Fast Ethernet" },
+   { PCI_VENDOR_ATTANSIC, PCI_PRODUCT_ATTANSIC_AR8171, 9 * 1024,
+   "Atheros AR8171 PCIe Gigabit Ethernet" },
+   { PCI_VENDOR_ATTANSIC, PCI_PRODUCT_ATTANSIC_AR8172, 9 * 1024,
+   "Atheros AR8172 PCIe Fast Ethernet" },
+   { PCI_VENDOR_ATTANSIC, PCI_PRODUCT_ATTANSIC_E2200, 9 * 1024,
+   "Killer E2200 Gigabit Ethernet" },
{ 0, 0, 0, NULL },
 };
 
@@ -103,33 +113,50 @@
 static int alc_detach(device_t, int);
 
 static int alc_init(struct ifnet *);
+static int alc_init_backend(struct ifnet *, bool);
 static voidalc_start(struct ifnet *);
 static int alc_ioctl(struct ifnet *, u_long, void *);
 static voidalc_watchdog(struct ifnet *);
 static int alc_mediachange(struct ifnet *);
 static voidalc_mediastatus(struct ifnet *, struct ifmediareq *);
 
-static voidalc_aspm(struct alc_softc *, int);
+static voidalc_aspm(struct alc_softc *, int, int);
+static voidalc_aspm_813x(struct alc_softc *, int);
+static voidalc_aspm_816x(struct alc_softc *, int);
 static voidalc_disable_l0s_l1(struct alc_softc *);
 static int alc_dma_alloc(struct alc_softc *);
 static voidalc_dma_free(struct alc_softc *);
+static voidalc_dsp_fixup(struct alc_softc *, int);
 static int alc_encap(struct alc_softc *, struct mbuf **);
 static struct alc_ident *
alc_find_ident(struct pci_attach_args *);
 static voidalc_get_macaddr(struct alc_softc *);
+static voidalc_get_macaddr_813x(struct alc_softc *);
+static voidalc_get_macaddr_816x(struct alc_softc *);
+static voidalc_get_macaddr_par(struct alc_softc *);
 static voidalc_init_cmb(struct alc_softc *);
 static voidalc_init_rr_ring(struct alc_softc *);
-static int alc_init_rx_ring(struct alc_softc *);
+static int alc_init_rx_ring(struct alc_softc *, bool);
 static voidalc_init_smb(struct alc_softc *);
 static voidalc_init_tx_ring(struct alc_softc *);
 static int alc_intr(void *);
 static voidalc_mac_config(struct alc_softc *);
+static uint32_talc_mii_readreg_813x(struct alc_softc *, int, int);
+static uint32_talc_mii_readreg_816x(struct alc_softc *, int, int);
+static voidalc_mii_writereg_813x(struct alc_softc *, int, int, int);
+static voidalc_mii_writereg_816x(struct alc_softc *, int, int, int);
 static int alc_miibus_readreg(device_t, int, int);
 static voidalc_miibus_statchg(device_t);
 static voidalc_miibus_writereg(device_t, int, int, int);
-static int alc_newbuf(struct alc_softc *, struct alc_rxdesc *, int);
+static uint32_talc_miidbg_readreg(struct alc_softc *, int);
+static voidalc_miidbg_writereg(struct alc_softc *, int, int);
+static uint32_talc_miiext_readreg(struct alc_softc *, int, int);
+static uint32_talc_miiext_writereg(struct alc_softc *, int, int, int);
+static int alc_newbuf(struct alc_softc *, struct alc_rxdesc *, bool);
 static voidalc_phy_down(struct alc_softc *);
 static voidalc_phy_reset(struct alc_softc *);
+static voidalc_phy_reset_813x(struct alc_softc *);
+static voidalc_phy_reset_816x(struct alc_softc *);
 static voidalc_reset(struct alc_softc *);
 static voidalc_rxeof(struct alc_softc *, struct rx_rdesc *);
 static int alc_rxintr(struct alc_softc *);
@@ -159,12 +186,34 @@
 alc_miibus_readreg(device_t dev, int phy, int reg)
 {
struct alc_softc *sc = device_private(dev);
+   int v;
+
+   if ((sc->alc_flags & ALC_FLAG_AR816X_FAMILY) != 0)
+   v = alc_mii_readreg_816x(sc, phy, reg);
+   else
+