svn commit: r316821 - head/sys/dev/age

2017-04-14 Thread Pyun YongHyeon
Author: yongari
Date: Fri Apr 14 08:27:42 2017
New Revision: 316821
URL: https://svnweb.freebsd.org/changeset/base/316821

Log:
  Remove dead code.

Modified:
  head/sys/dev/age/if_age.c

Modified: head/sys/dev/age/if_age.c
==
--- head/sys/dev/age/if_age.c   Fri Apr 14 08:11:50 2017(r316820)
+++ head/sys/dev/age/if_age.c   Fri Apr 14 08:27:42 2017(r316821)
@@ -2161,11 +2161,6 @@ age_int_task(void *arg, int pending)
sc->age_cdata.age_cmb_block_map,
BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
 
-#if 0
-   printf("INTR: 0x%08x\n", status);
-   status &= ~INTR_DIS_DMA;
-   CSR_WRITE_4(sc, AGE_INTR_STATUS, status | INTR_DIS_INT);
-#endif
ifp = sc->age_ifp;
if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0) {
if ((status & INTR_CMB_RX) != 0)
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r316820 - head/sys/dev/jme

2017-04-14 Thread Pyun YongHyeon
Author: yongari
Date: Fri Apr 14 08:11:50 2017
New Revision: 316820
URL: https://svnweb.freebsd.org/changeset/base/316820

Log:
  Don't overwrite mapped bits.
  
  Found by: PVS-Studio

Modified:
  head/sys/dev/jme/if_jme.c

Modified: head/sys/dev/jme/if_jme.c
==
--- head/sys/dev/jme/if_jme.c   Fri Apr 14 07:27:23 2017(r316819)
+++ head/sys/dev/jme/if_jme.c   Fri Apr 14 08:11:50 2017(r316820)
@@ -557,7 +557,7 @@ jme_map_intr_vector(struct jme_softc *sc
bzero(map, sizeof(map));
 
/* Map Tx interrupts source to MSI/MSIX vector 2. */
-   map[MSINUM_REG_INDEX(N_INTR_TXQ0_COMP)] =
+   map[MSINUM_REG_INDEX(N_INTR_TXQ0_COMP)] |=
MSINUM_INTR_SOURCE(2, N_INTR_TXQ0_COMP);
map[MSINUM_REG_INDEX(N_INTR_TXQ1_COMP)] |=
MSINUM_INTR_SOURCE(2, N_INTR_TXQ1_COMP);
@@ -579,37 +579,37 @@ jme_map_intr_vector(struct jme_softc *sc
MSINUM_INTR_SOURCE(2, N_INTR_TXQ_COAL_TO);
 
/* Map Rx interrupts source to MSI/MSIX vector 1. */
-   map[MSINUM_REG_INDEX(N_INTR_RXQ0_COMP)] =
+   map[MSINUM_REG_INDEX(N_INTR_RXQ0_COMP)] |=
MSINUM_INTR_SOURCE(1, N_INTR_RXQ0_COMP);
-   map[MSINUM_REG_INDEX(N_INTR_RXQ1_COMP)] =
+   map[MSINUM_REG_INDEX(N_INTR_RXQ1_COMP)] |=
MSINUM_INTR_SOURCE(1, N_INTR_RXQ1_COMP);
-   map[MSINUM_REG_INDEX(N_INTR_RXQ2_COMP)] =
+   map[MSINUM_REG_INDEX(N_INTR_RXQ2_COMP)] |=
MSINUM_INTR_SOURCE(1, N_INTR_RXQ2_COMP);
-   map[MSINUM_REG_INDEX(N_INTR_RXQ3_COMP)] =
+   map[MSINUM_REG_INDEX(N_INTR_RXQ3_COMP)] |=
MSINUM_INTR_SOURCE(1, N_INTR_RXQ3_COMP);
-   map[MSINUM_REG_INDEX(N_INTR_RXQ0_DESC_EMPTY)] =
+   map[MSINUM_REG_INDEX(N_INTR_RXQ0_DESC_EMPTY)] |=
MSINUM_INTR_SOURCE(1, N_INTR_RXQ0_DESC_EMPTY);
-   map[MSINUM_REG_INDEX(N_INTR_RXQ1_DESC_EMPTY)] =
+   map[MSINUM_REG_INDEX(N_INTR_RXQ1_DESC_EMPTY)] |=
MSINUM_INTR_SOURCE(1, N_INTR_RXQ1_DESC_EMPTY);
-   map[MSINUM_REG_INDEX(N_INTR_RXQ2_DESC_EMPTY)] =
+   map[MSINUM_REG_INDEX(N_INTR_RXQ2_DESC_EMPTY)] |=
MSINUM_INTR_SOURCE(1, N_INTR_RXQ2_DESC_EMPTY);
-   map[MSINUM_REG_INDEX(N_INTR_RXQ3_DESC_EMPTY)] =
+   map[MSINUM_REG_INDEX(N_INTR_RXQ3_DESC_EMPTY)] |=
MSINUM_INTR_SOURCE(1, N_INTR_RXQ3_DESC_EMPTY);
-   map[MSINUM_REG_INDEX(N_INTR_RXQ0_COAL)] =
+   map[MSINUM_REG_INDEX(N_INTR_RXQ0_COAL)] |=
MSINUM_INTR_SOURCE(1, N_INTR_RXQ0_COAL);
-   map[MSINUM_REG_INDEX(N_INTR_RXQ1_COAL)] =
+   map[MSINUM_REG_INDEX(N_INTR_RXQ1_COAL)] |=
MSINUM_INTR_SOURCE(1, N_INTR_RXQ1_COAL);
-   map[MSINUM_REG_INDEX(N_INTR_RXQ2_COAL)] =
+   map[MSINUM_REG_INDEX(N_INTR_RXQ2_COAL)] |=
MSINUM_INTR_SOURCE(1, N_INTR_RXQ2_COAL);
-   map[MSINUM_REG_INDEX(N_INTR_RXQ3_COAL)] =
+   map[MSINUM_REG_INDEX(N_INTR_RXQ3_COAL)] |=
MSINUM_INTR_SOURCE(1, N_INTR_RXQ3_COAL);
-   map[MSINUM_REG_INDEX(N_INTR_RXQ0_COAL_TO)] =
+   map[MSINUM_REG_INDEX(N_INTR_RXQ0_COAL_TO)] |=
MSINUM_INTR_SOURCE(1, N_INTR_RXQ0_COAL_TO);
-   map[MSINUM_REG_INDEX(N_INTR_RXQ1_COAL_TO)] =
+   map[MSINUM_REG_INDEX(N_INTR_RXQ1_COAL_TO)] |=
MSINUM_INTR_SOURCE(1, N_INTR_RXQ1_COAL_TO);
-   map[MSINUM_REG_INDEX(N_INTR_RXQ2_COAL_TO)] =
+   map[MSINUM_REG_INDEX(N_INTR_RXQ2_COAL_TO)] |=
MSINUM_INTR_SOURCE(1, N_INTR_RXQ2_COAL_TO);
-   map[MSINUM_REG_INDEX(N_INTR_RXQ3_COAL_TO)] =
+   map[MSINUM_REG_INDEX(N_INTR_RXQ3_COAL_TO)] |=
MSINUM_INTR_SOURCE(1, N_INTR_RXQ3_COAL_TO);
 
/* Map all other interrupts source to MSI/MSIX vector 0. */
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r316819 - head/sys/dev/msk

2017-04-14 Thread Pyun YongHyeon
Author: yongari
Date: Fri Apr 14 07:27:23 2017
New Revision: 316819
URL: https://svnweb.freebsd.org/changeset/base/316819

Log:
  Remove unnecessary assignment.
  
  Found by: PVS-Studio

Modified:
  head/sys/dev/msk/if_msk.c

Modified: head/sys/dev/msk/if_msk.c
==
--- head/sys/dev/msk/if_msk.c   Fri Apr 14 06:42:46 2017(r316818)
+++ head/sys/dev/msk/if_msk.c   Fri Apr 14 07:27:23 2017(r316819)
@@ -4493,7 +4493,7 @@ msk_sysctl_node(struct msk_if_softc *sc_
 
tree = SYSCTL_ADD_NODE(ctx, child, OID_AUTO, "stats", CTLFLAG_RD,
NULL, "MSK Statistics");
-   schild = child = SYSCTL_CHILDREN(tree);
+   schild = SYSCTL_CHILDREN(tree);
tree = SYSCTL_ADD_NODE(ctx, schild, OID_AUTO, "rx", CTLFLAG_RD,
NULL, "MSK RX Statistics");
child = SYSCTL_CHILDREN(tree);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r316808 - head/sys/dev/txp

2017-04-13 Thread Pyun YongHyeon
Author: yongari
Date: Fri Apr 14 03:23:03 2017
New Revision: 316808
URL: https://svnweb.freebsd.org/changeset/base/316808

Log:
  Remove unnecessary check aginst NULL.  txp_ext_command() with
  TXP_CMD_WAIT argument allocates a response buffer.  If the allocation
  fails, txp_ext_command() returns an error and it's handed in caller.
  
  Found by: PVS-Studio

Modified:
  head/sys/dev/txp/if_txp.c

Modified: head/sys/dev/txp/if_txp.c
==
--- head/sys/dev/txp/if_txp.c   Fri Apr 14 03:20:34 2017(r316807)
+++ head/sys/dev/txp/if_txp.c   Fri Apr 14 03:23:03 2017(r316808)
@@ -400,8 +400,7 @@ txp_attach(device_t dev)
"Unknown Typhoon sleep image version: %u:0x%08x\n",
rsp->rsp_numdesc, p2);
}
-   if (rsp != NULL)
-   free(rsp, M_DEVBUF);
+   free(rsp, M_DEVBUF);
 
sc->sc_xcvr = TXP_XCVR_AUTO;
txp_command(sc, TXP_CMD_XCVR_SELECT, TXP_XCVR_AUTO, 0, 0,
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r316806 - head/sys/dev/fxp

2017-04-13 Thread Pyun YongHyeon
Author: yongari
Date: Fri Apr 14 02:33:26 2017
New Revision: 316806
URL: https://svnweb.freebsd.org/changeset/base/316806

Log:
  Remove unnecessary comparison.
  
  Found by: PVS-Studio

Modified:
  head/sys/dev/fxp/if_fxp.c

Modified: head/sys/dev/fxp/if_fxp.c
==
--- head/sys/dev/fxp/if_fxp.c   Fri Apr 14 02:24:02 2017(r316805)
+++ head/sys/dev/fxp/if_fxp.c   Fri Apr 14 02:33:26 2017(r316806)
@@ -2212,18 +2212,15 @@ fxp_stop(struct fxp_softc *sc)
 * Release any xmit buffers.
 */
txp = sc->fxp_desc.tx_list;
-   if (txp != NULL) {
-   for (i = 0; i < FXP_NTXCB; i++) {
-   if (txp[i].tx_mbuf != NULL) {
-   bus_dmamap_sync(sc->fxp_txmtag, txp[i].tx_map,
-   BUS_DMASYNC_POSTWRITE);
-   bus_dmamap_unload(sc->fxp_txmtag,
-   txp[i].tx_map);
-   m_freem(txp[i].tx_mbuf);
-   txp[i].tx_mbuf = NULL;
-   /* clear this to reset csum offload bits */
-   txp[i].tx_cb->tbd[0].tb_addr = 0;
-   }
+   for (i = 0; i < FXP_NTXCB; i++) {
+   if (txp[i].tx_mbuf != NULL) {
+   bus_dmamap_sync(sc->fxp_txmtag, txp[i].tx_map,
+   BUS_DMASYNC_POSTWRITE);
+   bus_dmamap_unload(sc->fxp_txmtag, txp[i].tx_map);
+   m_freem(txp[i].tx_mbuf);
+   txp[i].tx_mbuf = NULL;
+   /* clear this to reset csum offload bits */
+   txp[i].tx_cb->tbd[0].tb_addr = 0;
}
}
bus_dmamap_sync(sc->cbl_tag, sc->cbl_map,
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r316805 - head/sys/dev/ae

2017-04-13 Thread Pyun YongHyeon
Author: yongari
Date: Fri Apr 14 02:24:02 2017
New Revision: 316805
URL: https://svnweb.freebsd.org/changeset/base/316805

Log:
  Fix a potentially forever loop.
  
  Found by: PVS-Studio

Modified:
  head/sys/dev/ae/if_ae.c

Modified: head/sys/dev/ae/if_ae.c
==
--- head/sys/dev/ae/if_ae.c Fri Apr 14 01:56:15 2017(r316804)
+++ head/sys/dev/ae/if_ae.c Fri Apr 14 02:24:02 2017(r316805)
@@ -1696,7 +1696,7 @@ ae_stop_txmac(ae_softc_t *sc)
/*
 * Wait for IDLE state.
 */
-   for (i = 0; i < AE_IDLE_TIMEOUT; i--) {
+   for (i = 0; i < AE_IDLE_TIMEOUT; i++) {
val = AE_READ_4(sc, AE_IDLE_REG);
if ((val & (AE_IDLE_TXMAC | AE_IDLE_DMAREAD)) == 0)
break;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r309528 - head/sys/dev/sound/pci/hda

2016-12-03 Thread Pyun YongHyeon
Author: yongari
Date: Sun Dec  4 05:55:18 2016
New Revision: 309528
URL: https://svnweb.freebsd.org/changeset/base/309528

Log:
  Fix too low volume on MSI H170 GAMING M3 board by poking vendor
  specific COEF.

Modified:
  head/sys/dev/sound/pci/hda/hdaa_patches.c

Modified: head/sys/dev/sound/pci/hda/hdaa_patches.c
==
--- head/sys/dev/sound/pci/hda/hdaa_patches.c   Sun Dec  4 05:46:30 2016
(r309527)
+++ head/sys/dev/sound/pci/hda/hdaa_patches.c   Sun Dec  4 05:55:18 2016
(r309528)
@@ -739,6 +739,12 @@ hdaa_patch_direct(struct hdaa_devinfo *d
hda_command(dev, HDA_CMD_12BIT(0, devinfo->nid,
0xf88, 0xc0));
break;
+   case HDA_CODEC_ALC1150:
+   if (subid == 0xd9781462) {
+   /* Too low volume on MSI H170 GAMING M3. */
+   hdaa_write_coef(dev, 0x20, 0x07, 0x7cb);
+   }
+   break;
}
if (subid == APPLE_INTEL_MAC)
hda_command(dev, HDA_CMD_12BIT(0, devinfo->nid,
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r309527 - head/sys/dev/sound/pci/hda

2016-12-03 Thread Pyun YongHyeon
Author: yongari
Date: Sun Dec  4 05:46:30 2016
New Revision: 309527
URL: https://svnweb.freebsd.org/changeset/base/309527

Log:
  Recognize RealTek ALC1150 7.1 channel HD audio codec.

Modified:
  head/sys/dev/sound/pci/hda/hdac.h
  head/sys/dev/sound/pci/hda/hdacc.c

Modified: head/sys/dev/sound/pci/hda/hdac.h
==
--- head/sys/dev/sound/pci/hda/hdac.h   Sun Dec  4 04:04:57 2016
(r309526)
+++ head/sys/dev/sound/pci/hda/hdac.h   Sun Dec  4 05:46:30 2016
(r309527)
@@ -368,6 +368,7 @@
 #define HDA_CODEC_ALC889   HDA_CODEC_CONSTRUCT(REALTEK, 0x0889)
 #define HDA_CODEC_ALC892   HDA_CODEC_CONSTRUCT(REALTEK, 0x0892)
 #define HDA_CODEC_ALC899   HDA_CODEC_CONSTRUCT(REALTEK, 0x0899)
+#define HDA_CODEC_ALC1150  HDA_CODEC_CONSTRUCT(REALTEK, 0x0900)
 #define HDA_CODEC_ALC  HDA_CODEC_CONSTRUCT(REALTEK, 0x)
 
 /* Motorola */

Modified: head/sys/dev/sound/pci/hda/hdacc.c
==
--- head/sys/dev/sound/pci/hda/hdacc.c  Sun Dec  4 04:04:57 2016
(r309526)
+++ head/sys/dev/sound/pci/hda/hdacc.c  Sun Dec  4 05:46:30 2016
(r309527)
@@ -111,6 +111,7 @@ static const struct {
{ HDA_CODEC_ALC889, 0,  "Realtek ALC889" },
{ HDA_CODEC_ALC892, 0,  "Realtek ALC892" },
{ HDA_CODEC_ALC899, 0,  "Realtek ALC899" },
+   { HDA_CODEC_ALC1150, 0, "Realtek ALC1150" },
{ HDA_CODEC_AD1882, 0,  "Analog Devices AD1882" },
{ HDA_CODEC_AD1882A, 0, "Analog Devices AD1882A" },
{ HDA_CODEC_AD1883, 0,  "Analog Devices AD1883" },
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r304584 - head/sys/dev/alc

2016-08-21 Thread Pyun YongHyeon
Author: yongari
Date: Mon Aug 22 03:28:06 2016
New Revision: 304584
URL: https://svnweb.freebsd.org/changeset/base/304584

Log:
  Add a missing change in r304575.
  
  Noticed by:   jhb

Modified:
  head/sys/dev/alc/if_alcvar.h

Modified: head/sys/dev/alc/if_alcvar.h
==
--- head/sys/dev/alc/if_alcvar.hMon Aug 22 03:23:28 2016
(r304583)
+++ head/sys/dev/alc/if_alcvar.hMon Aug 22 03:28:06 2016
(r304584)
@@ -235,7 +235,8 @@ struct alc_softc {
 #defineALC_FLAG_APS0x1000
 #defineALC_FLAG_AR816X_FAMILY  0x2000
 #defineALC_FLAG_LINK_WAR   0x4000
-#defineALC_FLAG_LINK   0x8000
+#defineALC_FLAG_E2X00  0x8000
+#defineALC_FLAG_LINK   0x1
 
struct callout  alc_tick_ch;
struct alc_hw_stats alc_stats;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r304576 - head/share/man/man4

2016-08-21 Thread Pyun YongHyeon
Author: yongari
Date: Mon Aug 22 01:28:02 2016
New Revision: 304576
URL: https://svnweb.freebsd.org/changeset/base/304576

Log:
  Add Killer E2400 to the supported hardware list.

Modified:
  head/share/man/man4/alc.4

Modified: head/share/man/man4/alc.4
==
--- head/share/man/man4/alc.4   Mon Aug 22 01:19:05 2016(r304575)
+++ head/share/man/man4/alc.4   Mon Aug 22 01:28:02 2016(r304576)
@@ -24,7 +24,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd October 8, 2014
+.Dd August 22, 2016
 .Dt ALC 4
 .Os
 .Sh NAME
@@ -122,6 +122,8 @@ Atheros AR8171 PCI Express Gigabit Ether
 Atheros AR8172 PCI Express Fast Ethernet controller
 .It
 Killer E2200 Gigabit Ethernet controller
+.It
+Killer E2400 Gigabit Ethernet controller
 .El
 .Sh LOADER TUNABLES
 Tunables can be set at the
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r304575 - in head/sys/dev: alc pci

2016-08-21 Thread Pyun YongHyeon
Author: yongari
Date: Mon Aug 22 01:19:05 2016
New Revision: 304575
URL: https://svnweb.freebsd.org/changeset/base/304575

Log:
  Add Killer E2400 Gigabit Ethernet support.
  It seems Killer E2200/E2400 has a BIOS misconfiguration or silicon
  bug which triggers DMA write errors when driver uses advertised
  maximum payload size.  Force the maximum payload size to 128 bytes
  in DMA configuration.
  This change should fix occasional DMA write errors reported on
  Killer E2200.
  
  Tested by:

Modified:
  head/sys/dev/alc/if_alc.c
  head/sys/dev/alc/if_alcreg.h
  head/sys/dev/pci/pci.c

Modified: head/sys/dev/alc/if_alc.c
==
--- head/sys/dev/alc/if_alc.c   Mon Aug 22 01:06:54 2016(r304574)
+++ head/sys/dev/alc/if_alc.c   Mon Aug 22 01:19:05 2016(r304575)
@@ -121,6 +121,8 @@ static struct alc_ident alc_ident_table[
"Atheros AR8172 PCIe Fast Ethernet" },
{ VENDORID_ATHEROS, DEVICEID_ATHEROS_E2200, 9 * 1024,
"Killer E2200 Gigabit Ethernet" },
+   { VENDORID_ATHEROS, DEVICEID_ATHEROS_E2400, 9 * 1024,
+   "Killer E2400 Gigabit Ethernet" },
{ 0, 0, 0, NULL}
 };
 
@@ -1080,6 +1082,7 @@ alc_phy_down(struct alc_softc *sc)
switch (sc->alc_ident->deviceid) {
case DEVICEID_ATHEROS_AR8161:
case DEVICEID_ATHEROS_E2200:
+   case DEVICEID_ATHEROS_E2400:
case DEVICEID_ATHEROS_AR8162:
case DEVICEID_ATHEROS_AR8171:
case DEVICEID_ATHEROS_AR8172:
@@ -1397,12 +1400,15 @@ alc_attach(device_t dev)
 * shows the same PHY model/revision number of AR8131.
 */
switch (sc->alc_ident->deviceid) {
+   case DEVICEID_ATHEROS_E2200:
+   case DEVICEID_ATHEROS_E2400:
+   sc->alc_flags |= ALC_FLAG_E2X00;
+   /* FALLTHROUGH */
case DEVICEID_ATHEROS_AR8161:
if (pci_get_subvendor(dev) == VENDORID_ATHEROS &&
pci_get_subdevice(dev) == 0x0091 && sc->alc_rev == 0)
sc->alc_flags |= ALC_FLAG_LINK_WAR;
/* FALLTHROUGH */
-   case DEVICEID_ATHEROS_E2200:
case DEVICEID_ATHEROS_AR8171:
sc->alc_flags |= ALC_FLAG_AR816X_FAMILY;
break;
@@ -1473,6 +1479,12 @@ alc_attach(device_t dev)
sc->alc_dma_rd_burst = 3;
if (alc_dma_burst[sc->alc_dma_wr_burst] > 1024)
sc->alc_dma_wr_burst = 3;
+   /*
+* Force maximum payload size to 128 bytes for E2200/E2400.
+* Otherwise it triggers DMA write error.
+*/
+   if ((sc->alc_flags & ALC_FLAG_E2X00) != 0)
+   sc->alc_dma_wr_burst = 0;
alc_init_pcie(sc);
}
 

Modified: head/sys/dev/alc/if_alcreg.h
==
--- head/sys/dev/alc/if_alcreg.hMon Aug 22 01:06:54 2016
(r304574)
+++ head/sys/dev/alc/if_alcreg.hMon Aug 22 01:19:05 2016
(r304575)
@@ -45,10 +45,11 @@
 #defineDEVICEID_ATHEROS_AR8152_B   0x2060  /* L2C V1.1 */
 #defineDEVICEID_ATHEROS_AR8152_B2  0x2062  /* L2C V2.0 */
 #defineDEVICEID_ATHEROS_AR8161 0x1091
-#defineDEVICEID_ATHEROS_E2200  0xE091
 #defineDEVICEID_ATHEROS_AR8162 0x1090
 #defineDEVICEID_ATHEROS_AR8171 0x10A1
 #defineDEVICEID_ATHEROS_AR8172 0x10A0
+#defineDEVICEID_ATHEROS_E2200  0xE091
+#defineDEVICEID_ATHEROS_E2400  0xE0A1
 
 #defineATHEROS_AR8152_B_V100xC0
 #defineATHEROS_AR8152_B_V110xC1

Modified: head/sys/dev/pci/pci.c
==
--- head/sys/dev/pci/pci.c  Mon Aug 22 01:06:54 2016(r304574)
+++ head/sys/dev/pci/pci.c  Mon Aug 22 01:19:05 2016(r304575)
@@ -281,12 +281,13 @@ static const struct pci_quirk pci_quirks
{ 0x43851002, PCI_QUIRK_UNMAP_REG,  0x14,   0 },
 
/*
-* Atheros AR8161/AR8162/E2200 Ethernet controllers have a bug that
-* MSI interrupt does not assert if PCIM_CMD_INTxDIS bit of the
-* command register is set.
+* Atheros AR8161/AR8162/E2200/E2400 Ethernet controllers have a
+* bug that MSI interrupt does not assert if PCIM_CMD_INTxDIS bit
+* of the command register is set.
 */
{ 0x10911969, PCI_QUIRK_MSI_INTX_BUG,   0,  0 },
{ 0xE0911969, PCI_QUIRK_MSI_INTX_BUG,   0,  0 },
+   { 0xE0A11969, PCI_QUIRK_MSI_INTX_BUG,   0,  0 },
{ 0x10901969, PCI_QUIRK_MSI_INTX_BUG,   0,  0 },
 
/*
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To 

svn commit: r304574 - head/sys/dev/alc

2016-08-21 Thread Pyun YongHyeon
Author: yongari
Date: Mon Aug 22 01:06:54 2016
New Revision: 304574
URL: https://svnweb.freebsd.org/changeset/base/304574

Log:
  Correct DMA channel number selection on AR816x family of
  controllers. For Gigabit Ethernet version of AR816x, AR813x/AR815x
  except L1D controller, use vendor recommended ASPM parameters.
  While here, increase alc_dma_burst array size.  Broken H/W can
  return bogus value in theory.

Modified:
  head/sys/dev/alc/if_alc.c

Modified: head/sys/dev/alc/if_alc.c
==
--- head/sys/dev/alc/if_alc.c   Mon Aug 22 00:40:45 2016(r304573)
+++ head/sys/dev/alc/if_alc.c   Mon Aug 22 01:06:54 2016(r304574)
@@ -255,7 +255,7 @@ static struct resource_spec alc_irq_spec
{ -1,   0,  0 }
 };
 
-static uint32_t alc_dma_burst[] = { 128, 256, 512, 1024, 2048, 4096, 0 };
+static uint32_t alc_dma_burst[] = { 128, 256, 512, 1024, 2048, 4096, 0, 0 };
 
 static int
 alc_miibus_readreg(device_t dev, int phy, int reg)
@@ -4184,13 +4184,17 @@ alc_init_locked(struct alc_softc *sc)
reg = (RXQ_CFG_RD_BURST_DEFAULT << RXQ_CFG_RD_BURST_SHIFT) &
RXQ_CFG_RD_BURST_MASK;
reg |= RXQ_CFG_RSS_MODE_DIS;
-   if ((sc->alc_flags & ALC_FLAG_AR816X_FAMILY) != 0)
+   if ((sc->alc_flags & ALC_FLAG_AR816X_FAMILY) != 0) {
reg |= (RXQ_CFG_816X_IDT_TBL_SIZE_DEFAULT <<
RXQ_CFG_816X_IDT_TBL_SIZE_SHIFT) &
RXQ_CFG_816X_IDT_TBL_SIZE_MASK;
-   if ((sc->alc_flags & ALC_FLAG_FASTETHER) == 0 &&
-   sc->alc_ident->deviceid != DEVICEID_ATHEROS_AR8151_V2)
-   reg |= RXQ_CFG_ASPM_THROUGHPUT_LIMIT_1M;
+   if ((sc->alc_flags & ALC_FLAG_FASTETHER) == 0)
+   reg |= RXQ_CFG_ASPM_THROUGHPUT_LIMIT_100M;
+   } else {
+   if ((sc->alc_flags & ALC_FLAG_FASTETHER) == 0 &&
+   sc->alc_ident->deviceid != DEVICEID_ATHEROS_AR8151_V2)
+   reg |= RXQ_CFG_ASPM_THROUGHPUT_LIMIT_100M;
+   }
CSR_WRITE_4(sc, ALC_RXQ_CFG, reg);
 
/* Configure DMA parameters. */
@@ -4214,12 +4218,12 @@ alc_init_locked(struct alc_softc *sc)
switch (AR816X_REV(sc->alc_rev)) {
case AR816X_REV_A0:
case AR816X_REV_A1:
-   reg |= DMA_CFG_RD_CHNL_SEL_1;
+   reg |= DMA_CFG_RD_CHNL_SEL_2;
break;
case AR816X_REV_B0:
/* FALLTHROUGH */
default:
-   reg |= DMA_CFG_RD_CHNL_SEL_3;
+   reg |= DMA_CFG_RD_CHNL_SEL_4;
break;
}
}
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r304458 - head/sys/dev/usb/net

2016-08-19 Thread Pyun YongHyeon
Author: yongari
Date: Fri Aug 19 10:51:30 2016
New Revision: 304458
URL: https://svnweb.freebsd.org/changeset/base/304458

Log:
  Host controller is byte oriented.  Fix wrong assumption on big-endian
  systems.
  
  Pointed out by:   hselasky

Modified:
  head/sys/dev/usb/net/if_axgereg.h

Modified: head/sys/dev/usb/net/if_axgereg.h
==
--- head/sys/dev/usb/net/if_axgereg.h   Fri Aug 19 09:11:50 2016
(r304457)
+++ head/sys/dev/usb/net/if_axgereg.h   Fri Aug 19 10:51:30 2016
(r304458)
@@ -154,21 +154,15 @@ enum {
 #defineAXGE_N_FRAMES   16
 
 struct axge_frame_txhdr {
-#if BYTE_ORDER == LITTLE_ENDIAN
uint32_tlen;
-   uint32_tmss;
-#else
-   uint32_tmss;
-   uint32_tlen;
-#endif
-} __packed;
-
 #defineAXGE_TXLEN_MASK 0x0001
 #defineAXGE_VLAN_INSERT0x2000
 #defineAXGE_CSUM_DISABLE   0x8000
+   uint32_tmss;
 #defineAXGE_MSS_MASK   0x3FFF
 #defineAXGE_PADDING0x80008000
 #defineAXGE_VLAN_TAG_MASK  0x
+} __packed;
 
 #defineAXGE_TXBYTES(x) ((x) & AXGE_TXLEN_MASK)
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r304439 - head/sys/dev/usb/net

2016-08-18 Thread Pyun YongHyeon
Author: yongari
Date: Fri Aug 19 00:50:32 2016
New Revision: 304439
URL: https://svnweb.freebsd.org/changeset/base/304439

Log:
  Fix build on big-endian systems.
  
  Reported by:  bz

Modified:
  head/sys/dev/usb/net/if_axgereg.h

Modified: head/sys/dev/usb/net/if_axgereg.h
==
--- head/sys/dev/usb/net/if_axgereg.h   Fri Aug 19 00:03:41 2016
(r304438)
+++ head/sys/dev/usb/net/if_axgereg.h   Fri Aug 19 00:50:32 2016
(r304439)
@@ -156,19 +156,20 @@ enum {
 struct axge_frame_txhdr {
 #if BYTE_ORDER == LITTLE_ENDIAN
uint32_tlen;
-#defineAXGE_TXLEN_MASK 0x0001
-#defineAXGE_VLAN_INSERT0x2000
-#defineAXGE_CSUM_DISABLE   0x8000
uint32_tmss;
-#defineAXGE_MSS_MASK   0x3FFF
-#defineAXGE_PADDING0x80008000
-#defineAXGE_VLAN_TAG_MASK  0x
 #else
uint32_tmss;
uint32_tlen;
 #endif
 } __packed;
 
+#defineAXGE_TXLEN_MASK 0x0001
+#defineAXGE_VLAN_INSERT0x2000
+#defineAXGE_CSUM_DISABLE   0x8000
+#defineAXGE_MSS_MASK   0x3FFF
+#defineAXGE_PADDING0x80008000
+#defineAXGE_VLAN_TAG_MASK  0x
+
 #defineAXGE_TXBYTES(x) ((x) & AXGE_TXLEN_MASK)
 
 #defineAXGE_PHY_ADDR   3
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r304336 - head/sys/dev/usb/net

2016-08-18 Thread Pyun YongHyeon
Author: yongari
Date: Thu Aug 18 07:11:31 2016
New Revision: 304336
URL: https://svnweb.freebsd.org/changeset/base/304336

Log:
  When device is detached make sure to stop the controller and make
  it return zero-length USB packet.

Modified:
  head/sys/dev/usb/net/if_axge.c

Modified: head/sys/dev/usb/net/if_axge.c
==
--- head/sys/dev/usb/net/if_axge.c  Thu Aug 18 06:46:14 2016
(r304335)
+++ head/sys/dev/usb/net/if_axge.c  Thu Aug 18 07:11:31 2016
(r304336)
@@ -580,9 +580,27 @@ axge_detach(device_t dev)
 {
struct axge_softc *sc;
struct usb_ether *ue;
+   uint16_t val;
 
sc = device_get_softc(dev);
ue = >sc_ue;
+   if (device_is_attached(dev)) {
+   AXGE_LOCK(sc);
+   /*
+* XXX
+* ether_ifdetach(9) should be called first.
+*/
+   axge_stop(ue);
+   /* Force bulk-in to return a zero-length USB packet. */
+   val = axge_read_cmd_2(sc, AXGE_ACCESS_MAC, 2, AXGE_EPPRCR);
+   val |= EPPRCR_BZ | EPPRCR_IPRL;
+   axge_write_cmd_2(sc, AXGE_ACCESS_MAC, 2, AXGE_EPPRCR, val);
+   /* Change clock. */
+   axge_write_cmd_1(sc, AXGE_ACCESS_MAC, AXGE_CLK_SELECT, 0);
+   /* Disable MAC. */
+   axge_write_cmd_2(sc, AXGE_ACCESS_MAC, 2, AXGE_RCR, 0);
+   AXGE_UNLOCK(sc);
+   }
usbd_transfer_unsetup(sc->sc_xfer, AXGE_N_TRANSFER);
uether_ifdetach(ue);
mtx_destroy(>sc_mtx);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r304335 - head/sys/dev/usb/net

2016-08-18 Thread Pyun YongHyeon
Author: yongari
Date: Thu Aug 18 06:46:14 2016
New Revision: 304335
URL: https://svnweb.freebsd.org/changeset/base/304335

Log:
  In axge_stop(), clear medium receive enable bit which will stop RX
  MAC operation.

Modified:
  head/sys/dev/usb/net/if_axge.c

Modified: head/sys/dev/usb/net/if_axge.c
==
--- head/sys/dev/usb/net/if_axge.c  Thu Aug 18 06:39:09 2016
(r304334)
+++ head/sys/dev/usb/net/if_axge.c  Thu Aug 18 06:46:14 2016
(r304335)
@@ -847,12 +847,17 @@ axge_stop(struct usb_ether *ue)
 {
struct axge_softc *sc;
struct ifnet *ifp;
+   uint16_t val;
 
sc = uether_getsc(ue);
ifp = uether_getifp(ue);
 
AXGE_LOCK_ASSERT(sc, MA_OWNED);
 
+   val = axge_read_cmd_2(sc, AXGE_ACCESS_MAC, 2, AXGE_MSR);
+   val &= ~MSR_RE;
+   axge_write_cmd_2(sc, AXGE_ACCESS_MAC, 2, AXGE_MSR, val);
+
ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE);
sc->sc_flags &= ~AXGE_FLAG_LINK;
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r304333 - head/sys/dev/usb/net

2016-08-18 Thread Pyun YongHyeon
Author: yongari
Date: Thu Aug 18 06:35:09 2016
New Revision: 304333
URL: https://svnweb.freebsd.org/changeset/base/304333

Log:
  When usbd_transfer_setup() fails, don't call
  usbd_transfer_unsetup().

Modified:
  head/sys/dev/usb/net/if_axge.c

Modified: head/sys/dev/usb/net/if_axge.c
==
--- head/sys/dev/usb/net/if_axge.c  Thu Aug 18 06:29:07 2016
(r304332)
+++ head/sys/dev/usb/net/if_axge.c  Thu Aug 18 06:35:09 2016
(r304333)
@@ -553,7 +553,8 @@ axge_attach(device_t dev)
sc->sc_xfer, axge_config, AXGE_N_TRANSFER, sc, >sc_mtx);
if (error) {
device_printf(dev, "allocating USB transfers failed\n");
-   goto detach;
+   mtx_destroy(>sc_mtx);
+   return (ENXIO);
}
 
ue->ue_sc = sc;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r304332 - head/sys/dev/usb/net

2016-08-18 Thread Pyun YongHyeon
Author: yongari
Date: Thu Aug 18 06:29:07 2016
New Revision: 304332
URL: https://svnweb.freebsd.org/changeset/base/304332

Log:
  Introduce axge_rxfilter() which configures RX filtering and replace
  axge_setmulti()/axge_setpromisc() with axge_rxfilter().
  Multicast filter programming and promiscuous mode requires
  access to a common RX configuration register so there is no need to
  use separate functions with added complexity.  axge_rxfilter() does
  not read back AXGE_RCR register since accessing a register in USB
  is too slow and we already have all knowledge of required
  configuration.  Rebuilding RX filter configuration is simpler and
  faster than manipulating every bits after reading back the
  register.
  
  Note, axge_rxfilter() does not set RCR_IPE(IP header alignment on
  32bit boundary) to disable extra padding bytes insertion.  The
  extra padding wastes ethernet to USB host bandwidth as well as
  complicating RX handling logic.  Current USB framework requires
  copying RX frames to mbufs so there is no need to worry about
  alignment.  Previously axge_rx_frame() performed wrong bound check
  due to the extra padding and it was broken when RX checksum
  offloading is disabled.  See added comment in axge_rx_frame () for
  actual RX packet layout.
  
  In axge_init(), disable WOL.  It's meaningless to enable WOL in
  normal operation.
  
  In axge_rxeof(), use properly sized mbuf rather than blindly
  allocating a mbuf cluster.
  
  Use RX H/W checksum offloading only when administrator requested RX
  checksum offloading. Previously it always used RX H/W checksum
  offloading result regardless of RX checksum offloading state.
  
  Separate L4 checksum offloading validation from L3 one and properly
  set required offloading bits for each layer. This is to fix setting
  L4 checksum offloading bits for L3 packets.
  
  There are still lots of RX errors(probably RX FIFO overflows) under
  moderate load.  Users are strongly recommended to enable ethernet
  flow control.
  
  Reviewed by:  kevlo (initial version), hselasky

Modified:
  head/sys/dev/usb/net/if_axge.c
  head/sys/dev/usb/net/if_axgereg.h

Modified: head/sys/dev/usb/net/if_axge.c
==
--- head/sys/dev/usb/net/if_axge.c  Thu Aug 18 06:03:55 2016
(r304331)
+++ head/sys/dev/usb/net/if_axge.c  Thu Aug 18 06:29:07 2016
(r304332)
@@ -104,8 +104,7 @@ static uether_fn_t axge_init;
 static uether_fn_t axge_stop;
 static uether_fn_t axge_start;
 static uether_fn_t axge_tick;
-static uether_fn_t axge_setmulti;
-static uether_fn_t axge_setpromisc;
+static uether_fn_t axge_rxfilter;
 
 static int axge_read_mem(struct axge_softc *, uint8_t, uint16_t,
uint16_t, void *, int);
@@ -200,8 +199,8 @@ static const struct usb_ether_methods ax
.ue_init = axge_init,
.ue_stop = axge_stop,
.ue_tick = axge_tick,
-   .ue_setmulti = axge_setmulti,
-   .ue_setpromisc = axge_setpromisc,
+   .ue_setmulti = axge_rxfilter,
+   .ue_setpromisc = axge_rxfilter,
.ue_mii_upd = axge_ifmedia_upd,
.ue_mii_sts = axge_ifmedia_sts,
 };
@@ -727,7 +726,7 @@ axge_tick(struct usb_ether *ue)
 }
 
 static void
-axge_setmulti(struct usb_ether *ue)
+axge_rxfilter(struct usb_ether *ue)
 {
struct axge_softc *sc;
struct ifnet *ifp;
@@ -741,14 +740,26 @@ axge_setmulti(struct usb_ether *ue)
h = 0;
AXGE_LOCK_ASSERT(sc, MA_OWNED);
 
-   rxmode = axge_read_cmd_2(sc, AXGE_ACCESS_MAC, 2, AXGE_RCR);
+   /*
+* Configure RX settings.
+* Don't set RCR_IPE(IP header alignment on 32bit boundary) to disable
+* inserting extra padding bytes.  This wastes ethernet to USB host
+* bandwidth as well as complicating RX handling logic.  Current USB
+* framework requires copying RX frames to mbufs so there is no need
+* to worry about alignment.
+*/
+   rxmode = RCR_DROP_CRCERR | RCR_START;
+   if (ifp->if_flags & IFF_BROADCAST)
+   rxmode |= RCR_ACPT_BCAST;
if (ifp->if_flags & (IFF_ALLMULTI | IFF_PROMISC)) {
+   if (ifp->if_flags & IFF_PROMISC)
+   rxmode |= RCR_PROMISC;
rxmode |= RCR_ACPT_ALL_MCAST;
axge_write_cmd_2(sc, AXGE_ACCESS_MAC, 2, AXGE_RCR, rxmode);
return;
}
-   rxmode &= ~RCR_ACPT_ALL_MCAST;
 
+   rxmode |= RCR_ACPT_MCAST;
if_maddr_rlock(ifp);
TAILQ_FOREACH(ifma, >if_multiaddrs, ifma_link) {
if (ifma->ifma_addr->sa_family != AF_LINK)
@@ -764,26 +775,6 @@ axge_setmulti(struct usb_ether *ue)
 }
 
 static void
-axge_setpromisc(struct usb_ether *ue)
-{
-   struct axge_softc *sc;
-   struct ifnet *ifp;
-   uint16_t rxmode;
-
-   sc = uether_getsc(ue);
-   ifp = uether_getifp(ue);
-   rxmode = axge_read_cmd_2(sc, AXGE_ACCESS_MAC, 2, AXGE_RCR);
-
-   if 

svn commit: r304326 - head/sys/dev/usb/net

2016-08-17 Thread Pyun YongHyeon
Author: yongari
Date: Thu Aug 18 05:07:02 2016
New Revision: 304326
URL: https://svnweb.freebsd.org/changeset/base/304326

Log:
  Switch to TX header format rather than directly manipulating header
  structures.  This simplifies mbuf copy operation to USB buffers as
  well as improving readability.  The controller supports Microsoft
  LSOv1(aka TSO) but this change set does not include the support due
  to copying overhead to USB buffers and large amount of memory waste.
  
  Remove useless ZLP padding which seems to come from Linux.  Required
  bits the code tried to set was not copied into USB buffer so it had
  no effect.  Unlike Linux, FreeBSD USB stack automatically generates
  ZLP so no explicit padding is required in driver.[1]
  
  Micro-optimize updating IFCOUNTER_OPACKETS counter by moving it out
  of TX loop since updating counter is not cheap operation as it did
  long time ago and we already know how many number of packets were
  queued after exiting the loop.
  
  While here, fix a checksum offloading bug which will happen when
  upper stack computes checksum while H/W checksum offloading is
  active.  The controller should be notified to not recompute the
  checksum in this case.
  
  Reviewed by:  kevlo (initial version), hselasky
  Pointed out by:   hselasky [1]

Modified:
  head/sys/dev/usb/net/if_axge.c
  head/sys/dev/usb/net/if_axgereg.h

Modified: head/sys/dev/usb/net/if_axge.c
==
--- head/sys/dev/usb/net/if_axge.c  Thu Aug 18 04:25:17 2016
(r304325)
+++ head/sys/dev/usb/net/if_axge.c  Thu Aug 18 05:07:02 2016
(r304326)
@@ -35,6 +35,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -144,8 +145,8 @@ static const struct usb_config axge_conf
.type = UE_BULK,
.endpoint = UE_ADDR_ANY,
.direction = UE_DIR_OUT,
-   .frames = 16,
-   .bufsize = 16 * MCLBYTES,
+   .frames = AXGE_N_FRAMES,
+   .bufsize = AXGE_N_FRAMES * MCLBYTES,
.flags = {.pipe_bof = 1,.force_short_xfer = 1,},
.callback = axge_bulk_write_callback,
.timeout = 1,   /* 10 seconds */
@@ -630,7 +631,7 @@ axge_bulk_write_callback(struct usb_xfer
struct ifnet *ifp;
struct usb_page_cache *pc;
struct mbuf *m;
-   uint32_t txhdr;
+   struct axge_frame_txhdr txhdr;
int nframes, pos;
 
sc = usbd_xfer_softc(xfer);
@@ -651,36 +652,25 @@ tr_setup:
return;
}
 
-   for (nframes = 0; nframes < 16 &&
+   for (nframes = 0; nframes < AXGE_N_FRAMES &&
!IFQ_DRV_IS_EMPTY(>if_snd); nframes++) {
IFQ_DRV_DEQUEUE(>if_snd, m);
if (m == NULL)
break;
usbd_xfer_set_frame_offset(xfer, nframes * MCLBYTES,
-   nframes);
-   pos = 0;
+   nframes);
pc = usbd_xfer_get_frame(xfer, nframes);
-   txhdr = htole32(m->m_pkthdr.len);
-   usbd_copy_in(pc, 0, , sizeof(txhdr));
-   txhdr = 0;
-   txhdr = htole32(txhdr);
-   usbd_copy_in(pc, 4, , sizeof(txhdr));
-   pos += 8;
+   txhdr.mss = 0;
+   txhdr.len = htole32(AXGE_TXBYTES(m->m_pkthdr.len));
+   if ((ifp->if_capenable & IFCAP_TXCSUM) != 0 &&
+   (m->m_pkthdr.csum_flags & AXGE_CSUM_FEATURES) == 0)
+   txhdr.len |= htole32(AXGE_CSUM_DISABLE);
+
+   pos = 0;
+   usbd_copy_in(pc, pos, , sizeof(txhdr));
+   pos += sizeof(txhdr);
usbd_m_copy_in(pc, pos, m, 0, m->m_pkthdr.len);
pos += m->m_pkthdr.len;
-   if ((pos % usbd_xfer_max_framelen(xfer)) == 0)
-   txhdr |= 0x80008000;
-
-   /*
-* XXX
-* Update TX packet counter here. This is not
-* correct way but it seems that there is no way
-* to know how many packets are sent at the end
-* of transfer because controller combines
-* multiple writes into single one if there is
-* room in TX buffer of controller.
-*/
-   if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1);
 
/*
 * if there's a BPF listener, bounce a copy
@@ -694,6 +684,16 @@ tr_setup:

svn commit: r304325 - head/sys/dev/usb/net

2016-08-17 Thread Pyun YongHyeon
Author: yongari
Date: Thu Aug 18 04:25:17 2016
New Revision: 304325
URL: https://svnweb.freebsd.org/changeset/base/304325

Log:
  Rename cryptic RX filter constants with more readable ones.
  No functional change.

Modified:
  head/sys/dev/usb/net/if_axge.c
  head/sys/dev/usb/net/if_axgereg.h

Modified: head/sys/dev/usb/net/if_axge.c
==
--- head/sys/dev/usb/net/if_axge.c  Thu Aug 18 02:14:39 2016
(r304324)
+++ head/sys/dev/usb/net/if_axge.c  Thu Aug 18 04:25:17 2016
(r304325)
@@ -743,11 +743,11 @@ axge_setmulti(struct usb_ether *ue)
 
rxmode = axge_read_cmd_2(sc, AXGE_ACCESS_MAC, 2, AXGE_RCR);
if (ifp->if_flags & (IFF_ALLMULTI | IFF_PROMISC)) {
-   rxmode |= RCR_AMALL;
+   rxmode |= RCR_ACPT_ALL_MCAST;
axge_write_cmd_2(sc, AXGE_ACCESS_MAC, 2, AXGE_RCR, rxmode);
return;
}
-   rxmode &= ~RCR_AMALL;
+   rxmode &= ~RCR_ACPT_ALL_MCAST;
 
if_maddr_rlock(ifp);
TAILQ_FOREACH(ifma, >if_multiaddrs, ifma_link) {
@@ -775,9 +775,9 @@ axge_setpromisc(struct usb_ether *ue)
rxmode = axge_read_cmd_2(sc, AXGE_ACCESS_MAC, 2, AXGE_RCR);
 
if (ifp->if_flags & IFF_PROMISC)
-   rxmode |= RCR_PRO;
+   rxmode |= RCR_PROMISC;
else
-   rxmode &= ~RCR_PRO;
+   rxmode &= ~RCR_PROMISC;
 
axge_write_cmd_2(sc, AXGE_ACCESS_MAC, 2, AXGE_RCR, rxmode);
axge_setmulti(ue);
@@ -828,16 +828,16 @@ axge_init(struct usb_ether *ue)
axge_csum_cfg(ue);
 
/* Configure RX settings. */
-   rxmode = (RCR_AM | RCR_SO | RCR_DROP_CRCE);
+   rxmode = (RCR_ACPT_MCAST | RCR_START | RCR_DROP_CRCERR);
if ((ifp->if_capenable & IFCAP_RXCSUM) != 0)
rxmode |= RCR_IPE;
 
/* If we want promiscuous mode, set the allframes bit. */
if (ifp->if_flags & IFF_PROMISC)
-   rxmode |= RCR_PRO;
+   rxmode |= RCR_PROMISC;
 
if (ifp->if_flags & IFF_BROADCAST)
-   rxmode |= RCR_AB;
+   rxmode |= RCR_ACPT_BCAST;
 
axge_write_cmd_2(sc, AXGE_ACCESS_MAC, 2, AXGE_RCR, rxmode);
 

Modified: head/sys/dev/usb/net/if_axgereg.h
==
--- head/sys/dev/usb/net/if_axgereg.h   Thu Aug 18 02:14:39 2016
(r304324)
+++ head/sys/dev/usb/net/if_axgereg.h   Thu Aug 18 04:25:17 2016
(r304325)
@@ -57,13 +57,14 @@
 /* Rx control register */
 #defineAXGE_RCR0x0b
 #defineRCR_STOP0x
-#defineRCR_PRO 0x0001
-#defineRCR_AMALL   0x0002
-#defineRCR_AB  0x0008
-#defineRCR_AM  0x0010
-#defineRCR_AP  0x0020
-#defineRCR_SO  0x0080
-#defineRCR_DROP_CRCE   0x0100
+#defineRCR_PROMISC 0x0001
+#defineRCR_ACPT_ALL_MCAST  0x0002
+#defineRCR_AUTOPAD_BNDRY   0x0004
+#defineRCR_ACPT_BCAST  0x0008
+#defineRCR_ACPT_MCAST  0x0010
+#defineRCR_ACPT_PHY_MCAST  0x0020
+#defineRCR_START   0x0080
+#defineRCR_DROP_CRCERR 0x0100
 #defineRCR_IPE 0x0200
 #defineRCR_TX_CRC_PAD  0x0400
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r304324 - head/sys/dev/usb/net

2016-08-17 Thread Pyun YongHyeon
Author: yongari
Date: Thu Aug 18 02:14:39 2016
New Revision: 304324
URL: https://svnweb.freebsd.org/changeset/base/304324

Log:
  Don't explicitly call MIIBUS_STATCHG() method handler.  Link state
  change should be handled by PHY driver.  Some broken PHY H/Ws may
  need that workaround but it seems axge(4) don't use such PHYs.

Modified:
  head/sys/dev/usb/net/if_axge.c

Modified: head/sys/dev/usb/net/if_axge.c
==
--- head/sys/dev/usb/net/if_axge.c  Thu Aug 18 01:48:58 2016
(r304323)
+++ head/sys/dev/usb/net/if_axge.c  Thu Aug 18 02:14:39 2016
(r304324)
@@ -724,11 +724,6 @@ axge_tick(struct usb_ether *ue)
AXGE_LOCK_ASSERT(sc, MA_OWNED);
 
mii_tick(mii);
-   if ((sc->sc_flags & AXGE_FLAG_LINK) == 0) {
-   axge_miibus_statchg(ue->ue_dev);
-   if ((sc->sc_flags & AXGE_FLAG_LINK) != 0)
-   axge_start(ue);
-   }
 }
 
 static void
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r304323 - head/sys/dev/usb/net

2016-08-17 Thread Pyun YongHyeon
Author: yongari
Date: Thu Aug 18 01:48:58 2016
New Revision: 304323
URL: https://svnweb.freebsd.org/changeset/base/304323

Log:
  Pass PHY location information and remove PHY access hack.

Modified:
  head/sys/dev/usb/net/if_axge.c
  head/sys/dev/usb/net/if_axgereg.h

Modified: head/sys/dev/usb/net/if_axge.c
==
--- head/sys/dev/usb/net/if_axge.c  Thu Aug 18 01:25:12 2016
(r304322)
+++ head/sys/dev/usb/net/if_axge.c  Thu Aug 18 01:48:58 2016
(r304323)
@@ -303,8 +303,6 @@ axge_miibus_writereg(device_t dev, int p
int locked;
 
sc = device_get_softc(dev);
-   if (sc->sc_phyno != phy)
-   return (0);
locked = mtx_owned(>sc_mtx);
if (!locked)
AXGE_LOCK(sc);
@@ -434,7 +432,6 @@ axge_attach_post(struct usb_ether *ue)
struct axge_softc *sc;
 
sc = uether_getsc(ue);
-   sc->sc_phyno = 3;
 
/* Initialize controller and get station address. */
axge_chip_init(sc);
@@ -466,7 +463,7 @@ axge_attach_post_sub(struct usb_ether *u
mtx_lock();
error = mii_attach(ue->ue_dev, >ue_miibus, ifp,
uether_ifmedia_upd, ue->ue_methods->ue_mii_sts,
-   BMSR_DEFCAPMASK, sc->sc_phyno, MII_OFFSET_ANY, MIIF_DOPAUSE);
+   BMSR_DEFCAPMASK, AXGE_PHY_ADDR, MII_OFFSET_ANY, MIIF_DOPAUSE);
mtx_unlock();
 
return (error);

Modified: head/sys/dev/usb/net/if_axgereg.h
==
--- head/sys/dev/usb/net/if_axgereg.h   Thu Aug 18 01:25:12 2016
(r304322)
+++ head/sys/dev/usb/net/if_axgereg.h   Thu Aug 18 01:48:58 2016
(r304323)
@@ -158,11 +158,12 @@ enum {
AXGE_N_TRANSFER,
 };
 
+#defineAXGE_PHY_ADDR   3
+
 struct axge_softc {
struct usb_ethersc_ue;
struct mtx  sc_mtx;
struct usb_xfer *sc_xfer[AXGE_N_TRANSFER];
-   int sc_phyno;
 
int sc_flags;
 #defineAXGE_FLAG_LINK  0x0001  /* got a link */
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r302548 - head/share/man/man9

2016-07-11 Thread Pyun YongHyeon
Author: yongari
Date: Mon Jul 11 06:49:56 2016
New Revision: 302548
URL: https://svnweb.freebsd.org/changeset/base/302548

Log:
  Belatedly remove CSUM_IP_FRAGS and CSUM_FRAGMENT offloading
  capabilities.  It was removed in r243624 and r254804/r271006
  respectively.
  This file and mbuf(9) needs updates for other offloading
  capabilities(i.e. CSUM_SCTP and CSUM_TSO).

Modified:
  head/share/man/man9/ifnet.9

Modified: head/share/man/man9/ifnet.9
==
--- head/share/man/man9/ifnet.9 Mon Jul 11 06:37:04 2016(r302547)
+++ head/share/man/man9/ifnet.9 Mon Jul 11 06:49:56 2016(r302548)
@@ -28,7 +28,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd July 29, 2014
+.Dd July 11, 2016
 .Dt IFNET 9
 .Os
 .Sh NAME
@@ -787,18 +787,6 @@ The interface will compute IP checksums.
 The interface will compute TCP checksums.
 .It Dv CSUM_UDP
 The interface will compute UDP checksums.
-.It Dv CSUM_IP_FRAGS
-The interface can compute a TCP or UDP checksum for a packet
-fragmented by the host CPU.
-Makes sense only along with
-.Dv CSUM_TCP
-or
-.Dv CSUM_UDP .
-.It Dv CSUM_FRAGMENT
-The interface will do the fragmentation of IP packets if necessary.
-The host CPU does not need to care about MTU on this interface
-as long as a packet to transmit through it is an IP one and it
-does not exceed the size of the hardware buffer.
 .El
 .Pp
 An interface notifies the TCP/IP module about the tasks
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r295873 - in head/sys/dev: msk sk

2016-02-21 Thread Pyun YongHyeon
Author: yongari
Date: Mon Feb 22 00:58:04 2016
New Revision: 295873
URL: https://svnweb.freebsd.org/changeset/base/295873

Log:
  ifnet lock was changed to use sx(9) long time ago.
  Don't hold a driver lock for if_free(9).

Modified:
  head/sys/dev/msk/if_msk.c
  head/sys/dev/sk/if_sk.c

Modified: head/sys/dev/msk/if_msk.c
==
--- head/sys/dev/msk/if_msk.c   Mon Feb 22 00:49:35 2016(r295872)
+++ head/sys/dev/msk/if_msk.c   Mon Feb 22 00:58:04 2016(r295873)
@@ -2059,11 +2059,11 @@ msk_detach(device_t dev)
msk_txrx_dma_free(sc_if);
bus_generic_detach(dev);
 
-   if (ifp)
-   if_free(ifp);
sc = sc_if->msk_softc;
sc->msk_if[sc_if->msk_port] = NULL;
MSK_IF_UNLOCK(sc_if);
+   if (ifp)
+   if_free(ifp);
 
return (0);
 }

Modified: head/sys/dev/sk/if_sk.c
==
--- head/sys/dev/sk/if_sk.c Mon Feb 22 00:49:35 2016(r295872)
+++ head/sys/dev/sk/if_sk.c Mon Feb 22 00:58:04 2016(r295873)
@@ -1833,8 +1833,6 @@ sk_detach(dev)
ether_ifdetach(ifp);
SK_IF_LOCK(sc_if);
}
-   if (ifp)
-   if_free(ifp);
/*
 * We're generally called from skc_detach() which is using
 * device_delete_child() to get to here. It's already trashed
@@ -1848,6 +1846,8 @@ sk_detach(dev)
sk_dma_jumbo_free(sc_if);
sk_dma_free(sc_if);
SK_IF_UNLOCK(sc_if);
+   if (ifp)
+   if_free(ifp);
 
return(0);
 }
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r295738 - head/sys/dev/rl

2016-02-17 Thread Pyun YongHyeon
Author: yongari
Date: Thu Feb 18 03:05:08 2016
New Revision: 295738
URL: https://svnweb.freebsd.org/changeset/base/295738

Log:
  Fix a bug introduced in r295736
  TX descriptor address should be updated for valid chain.
  
  Pointed out by:   jmallett

Modified:
  head/sys/dev/rl/if_rl.c

Modified: head/sys/dev/rl/if_rl.c
==
--- head/sys/dev/rl/if_rl.c Thu Feb 18 01:58:26 2016(r295737)
+++ head/sys/dev/rl/if_rl.c Thu Feb 18 03:05:08 2016(r295738)
@@ -1945,8 +1945,9 @@ rl_stop(struct rl_softc *sc)
sc->rl_cdata.rl_tx_dmamap[i]);
m_freem(sc->rl_cdata.rl_tx_chain[i]);
sc->rl_cdata.rl_tx_chain[i] = NULL;
+   CSR_WRITE_4(sc, RL_TXADDR0 + (i * sizeof(uint32_t)),
+   0x000);
}
-   CSR_WRITE_4(sc, RL_TXADDR0 + (i * sizeof(uint32_t)), 0x000);
}
 }
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r295736 - head/sys/dev/rl

2016-02-17 Thread Pyun YongHyeon
Author: yongari
Date: Thu Feb 18 01:30:49 2016
New Revision: 295736
URL: https://svnweb.freebsd.org/changeset/base/295736

Log:
  Remove duplicated check.
  
  Found by: PVS-Studio

Modified:
  head/sys/dev/rl/if_rl.c

Modified: head/sys/dev/rl/if_rl.c
==
--- head/sys/dev/rl/if_rl.c Thu Feb 18 01:24:10 2016(r295735)
+++ head/sys/dev/rl/if_rl.c Thu Feb 18 01:30:49 2016(r295736)
@@ -1938,18 +1938,15 @@ rl_stop(struct rl_softc *sc)
 */
for (i = 0; i < RL_TX_LIST_CNT; i++) {
if (sc->rl_cdata.rl_tx_chain[i] != NULL) {
-   if (sc->rl_cdata.rl_tx_chain[i] != NULL) {
-   bus_dmamap_sync(sc->rl_cdata.rl_tx_tag,
-   sc->rl_cdata.rl_tx_dmamap[i],
-   BUS_DMASYNC_POSTWRITE);
-   bus_dmamap_unload(sc->rl_cdata.rl_tx_tag,
-   sc->rl_cdata.rl_tx_dmamap[i]);
-   m_freem(sc->rl_cdata.rl_tx_chain[i]);
-   sc->rl_cdata.rl_tx_chain[i] = NULL;
-   }
-   CSR_WRITE_4(sc, RL_TXADDR0 + (i * sizeof(uint32_t)),
-   0x000);
+   bus_dmamap_sync(sc->rl_cdata.rl_tx_tag,
+   sc->rl_cdata.rl_tx_dmamap[i],
+   BUS_DMASYNC_POSTWRITE);
+   bus_dmamap_unload(sc->rl_cdata.rl_tx_tag,
+   sc->rl_cdata.rl_tx_dmamap[i]);
+   m_freem(sc->rl_cdata.rl_tx_chain[i]);
+   sc->rl_cdata.rl_tx_chain[i] = NULL;
}
+   CSR_WRITE_4(sc, RL_TXADDR0 + (i * sizeof(uint32_t)), 0x000);
}
 }
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r295735 - in head/sys/dev: age alc ale jme msk stge vte

2016-02-17 Thread Pyun YongHyeon
Author: yongari
Date: Thu Feb 18 01:24:10 2016
New Revision: 295735
URL: https://svnweb.freebsd.org/changeset/base/295735

Log:
  Fix variable assignment.
  
  Found by: PVS-Studio

Modified:
  head/sys/dev/age/if_age.c
  head/sys/dev/alc/if_alc.c
  head/sys/dev/ale/if_ale.c
  head/sys/dev/jme/if_jme.c
  head/sys/dev/msk/if_msk.c
  head/sys/dev/stge/if_stge.c
  head/sys/dev/vte/if_vte.c

Modified: head/sys/dev/age/if_age.c
==
--- head/sys/dev/age/if_age.c   Thu Feb 18 00:37:58 2016(r295734)
+++ head/sys/dev/age/if_age.c   Thu Feb 18 01:24:10 2016(r295735)
@@ -588,7 +588,7 @@ age_attach(device_t dev)
/* Create device sysctl node. */
age_sysctl_node(sc);
 
-   if ((error = age_dma_alloc(sc) != 0))
+   if ((error = age_dma_alloc(sc)) != 0)
goto fail;
 
/* Load station address. */

Modified: head/sys/dev/alc/if_alc.c
==
--- head/sys/dev/alc/if_alc.c   Thu Feb 18 00:37:58 2016(r295734)
+++ head/sys/dev/alc/if_alc.c   Thu Feb 18 01:24:10 2016(r295735)
@@ -1532,7 +1532,7 @@ alc_attach(device_t dev)
/* Create device sysctl node. */
alc_sysctl_node(sc);
 
-   if ((error = alc_dma_alloc(sc) != 0))
+   if ((error = alc_dma_alloc(sc)) != 0)
goto fail;
 
/* Load station address. */

Modified: head/sys/dev/ale/if_ale.c
==
--- head/sys/dev/ale/if_ale.c   Thu Feb 18 00:37:58 2016(r295734)
+++ head/sys/dev/ale/if_ale.c   Thu Feb 18 01:24:10 2016(r295735)
@@ -603,7 +603,7 @@ ale_attach(device_t dev)
/* Create device sysctl node. */
ale_sysctl_node(sc);
 
-   if ((error = ale_dma_alloc(sc) != 0))
+   if ((error = ale_dma_alloc(sc)) != 0)
goto fail;
 
/* Load station address. */

Modified: head/sys/dev/jme/if_jme.c
==
--- head/sys/dev/jme/if_jme.c   Thu Feb 18 00:37:58 2016(r295734)
+++ head/sys/dev/jme/if_jme.c   Thu Feb 18 01:24:10 2016(r295735)
@@ -804,7 +804,7 @@ jme_attach(device_t dev)
}
/* Create coalescing sysctl node. */
jme_sysctl_node(sc);
-   if ((error = jme_dma_alloc(sc) != 0))
+   if ((error = jme_dma_alloc(sc)) != 0)
goto fail;
 
ifp = sc->jme_ifp = if_alloc(IFT_ETHER);

Modified: head/sys/dev/msk/if_msk.c
==
--- head/sys/dev/msk/if_msk.c   Thu Feb 18 00:37:58 2016(r295734)
+++ head/sys/dev/msk/if_msk.c   Thu Feb 18 01:24:10 2016(r295735)
@@ -1623,7 +1623,7 @@ msk_attach(device_t dev)
callout_init_mtx(_if->msk_tick_ch, _if->msk_softc->msk_mtx, 0);
msk_sysctl_node(sc_if);
 
-   if ((error = msk_txrx_dma_alloc(sc_if) != 0))
+   if ((error = msk_txrx_dma_alloc(sc_if)) != 0)
goto fail;
msk_rx_dma_jalloc(sc_if);
 

Modified: head/sys/dev/stge/if_stge.c
==
--- head/sys/dev/stge/if_stge.c Thu Feb 18 00:37:58 2016(r295734)
+++ head/sys/dev/stge/if_stge.c Thu Feb 18 01:24:10 2016(r295735)
@@ -508,7 +508,7 @@ stge_attach(device_t dev)
}
}
 
-   if ((error = stge_dma_alloc(sc) != 0))
+   if ((error = stge_dma_alloc(sc)) != 0)
goto fail;
 
/*

Modified: head/sys/dev/vte/if_vte.c
==
--- head/sys/dev/vte/if_vte.c   Thu Feb 18 00:37:58 2016(r295734)
+++ head/sys/dev/vte/if_vte.c   Thu Feb 18 01:24:10 2016(r295735)
@@ -428,7 +428,7 @@ vte_attach(device_t dev)
/* Reset the ethernet controller. */
vte_reset(sc);
 
-   if ((error = vte_dma_alloc(sc) != 0))
+   if ((error = vte_dma_alloc(sc)) != 0)
goto fail;
 
/* Create device sysctl node. */
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r291676 - head/sys/dev/mii

2015-12-02 Thread Pyun YongHyeon
Author: yongari
Date: Thu Dec  3 05:27:39 2015
New Revision: 291676
URL: https://svnweb.freebsd.org/changeset/base/291676

Log:
  Disable EEE(Energy Efficient Ethernet) for RTL8211F PHY.
  It seems the EEE made RX MAC enter LPI(Low Power Idle) mode such
  that dwc(4) was not able to receive packets.  Ideally dwc(4) should
  be able to use EEE to save power during periods of low link
  utilization(i.e. gating off clock).  Due to lack of dwc(4)
  datasheet it's not easy to take required steps for EEE on LPI
  enter/exit events.  Disabling EEE in PHY seems to be easy
  workaround until dwc(4) supports EEE.
  
  Updating EEE advertisement register on RTL8211F seems to have no
  effect until reprogramming MII_ANAR, MII_100T2CR and MII_BMCR
  with auto-negotiation. It's not clear whether it's related with
  mii_phy_reset()'s BMCR_ISO handling for RTL8211F though.
  It seems rgephy_reset() needs careful investigation for newer
  RealTek PHYs.
  
  Ganbold submitted working version based on NetBSD change and
  tested lots of changes I made. Thanks a lot!
  
  Submitted by: ganbold (initial version)
  In collaboration with:ganbold

Modified:
  head/sys/dev/mii/rgephy.c
  head/sys/dev/mii/rgephyreg.h

Modified: head/sys/dev/mii/rgephy.c
==
--- head/sys/dev/mii/rgephy.c   Thu Dec  3 04:35:44 2015(r291675)
+++ head/sys/dev/mii/rgephy.c   Thu Dec  3 05:27:39 2015(r291676)
@@ -90,6 +90,7 @@ static void   rgephy_reset(struct mii_soft
 static int rgephy_linkup(struct mii_softc *);
 static voidrgephy_loop(struct mii_softc *);
 static voidrgephy_load_dspcode(struct mii_softc *);
+static voidrgephy_disable_eee(struct mii_softc *);
 
 static const struct mii_phydesc rgephys[] = {
MII_PHY_DESC(REALTEK, RTL8169S),
@@ -517,10 +518,9 @@ rgephy_reset(struct mii_softc *sc)
switch (sc->mii_mpd_rev) {
case RGEPHY_8211F:
pcr = PHY_READ(sc, RGEPHY_F_MII_PCR1);
-   if ((pcr & RGEPHY_F_PCR1_MDI_MM) != 0) {
-   pcr &= ~RGEPHY_F_PCR1_MDI_MM;
-   PHY_WRITE(sc, RGEPHY_F_MII_PCR1, pcr);
-   }
+   pcr &= ~(RGEPHY_F_PCR1_MDI_MM | RGEPHY_F_PCR1_ALDPS_EN);
+   PHY_WRITE(sc, RGEPHY_F_MII_PCR1, pcr);
+   rgephy_disable_eee(sc);
break;
case RGEPHY_8211C:
if ((sc->mii_flags & MIIF_PHYPRIV0) == 0) {
@@ -548,3 +548,29 @@ rgephy_reset(struct mii_softc *sc)
DELAY(1000);
rgephy_load_dspcode(sc);
 }
+
+static void
+rgephy_disable_eee(struct mii_softc *sc)
+{
+   uint16_t anar;
+
+   PHY_WRITE(sc, RGEPHY_F_EPAGSR, 0x);
+   PHY_WRITE(sc, MII_MMDACR, MMDACR_FN_ADDRESS |
+   (MMDACR_DADDRMASK & RGEPHY_F_MMD_DEV_7));
+   PHY_WRITE(sc, MII_MMDAADR, RGEPHY_F_MMD_EEEAR);
+   PHY_WRITE(sc, MII_MMDACR, MMDACR_FN_DATANPI |
+   (MMDACR_DADDRMASK & RGEPHY_F_MMD_DEV_7));
+   PHY_WRITE(sc, MII_MMDAADR, 0x);
+   PHY_WRITE(sc, MII_MMDACR, 0x);
+   /*
+* XXX
+* Restart auto-negotiation to take changes effect.
+* This may result in link establishment.
+*/
+   anar = BMSR_MEDIA_TO_ANAR(sc->mii_capabilities) | ANAR_CSMA;
+   PHY_WRITE(sc, RGEPHY_MII_ANAR, anar);
+   PHY_WRITE(sc, RGEPHY_MII_1000CTL, RGEPHY_1000CTL_AHD |
+   RGEPHY_1000CTL_AFD);
+   PHY_WRITE(sc, RGEPHY_MII_BMCR, RGEPHY_BMCR_RESET |
+   RGEPHY_BMCR_AUTOEN | RGEPHY_BMCR_STARTNEG);
+}

Modified: head/sys/dev/mii/rgephyreg.h
==
--- head/sys/dev/mii/rgephyreg.hThu Dec  3 04:35:44 2015
(r291675)
+++ head/sys/dev/mii/rgephyreg.hThu Dec  3 05:27:39 2015
(r291676)
@@ -183,4 +183,20 @@
 #defineRGEPHY_F_SSR_MDI0x0002  /* MDI/MDIX */
 #defineRGEPHY_F_SSR_JABBER 0x0001  /* Jabber */
 
+/* RTL8211F */
+#defineRGEPHY_F_EPAGSR 0x1F/* Extension page select 
register */
+
+/* RTL8211F */
+#defineRGEPHY_F_MMD_DEV_7  0x07
+
+/* RTL8211F MMD device 7 */
+#defineRGEPHY_F_MMD_EEEAR  0x3C/* EEE advertisement */
+#defineEEEAR_1000T 0x0004  /* adv. 1000baseT EEE */
+#defineEEEAR_100TX 0x0002  /* adv. 100baseTX EEE */
+
+/* RTL8211F MMD device 7 */
+#defineRGEPHY_F_MMD_EEELPAR0x3D/* EEE link partner abilities */
+#defineEEELPAR_1000T   0x0004  /* link partner 1000baseT EEE 
capable */
+#defineEEELPAR_100TX   0x0002  /* link partner 100baseTX EEE 
capable */
+
 #endif /* _DEV_RGEPHY_MIIREG_H_ */
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r287238 - head/sys/dev/msk

2015-08-27 Thread Pyun YongHyeon
Author: yongari
Date: Fri Aug 28 01:32:42 2015
New Revision: 287238
URL: https://svnweb.freebsd.org/changeset/base/287238

Log:
  Set DMA alignment constraint of status, TX and RX LEs(List Elements
  in Marvell terms) to 32768.  32768 looks overkill but it will
  ensure correct DMAed update.  This change addresses occasional
  watchdog timeouts reported on 10.2-RELEASE.
  
  Tested by:Johann Hugo jh...@meraka.csir.co.za
  MFC after:2 weeks

Modified:
  head/sys/dev/msk/if_mskreg.h

Modified: head/sys/dev/msk/if_mskreg.h
==
--- head/sys/dev/msk/if_mskreg.hFri Aug 28 00:49:30 2015
(r287237)
+++ head/sys/dev/msk/if_mskreg.hFri Aug 28 01:32:42 2015
(r287238)
@@ -2175,13 +2175,8 @@
 #define MSK_ADDR_LO(x) ((uint64_t) (x)  0xUL)
 #define MSK_ADDR_HI(x) ((uint64_t) (x)  32)
 
-/*
- * At first I guessed 8 bytes, the size of a single descriptor, would be
- * required alignment constraints. But, it seems that Yukon II have 4096
- * bytes boundary alignment constraints.
- */
-#define MSK_RING_ALIGN 4096
-#defineMSK_STAT_ALIGN  4096
+#defineMSK_RING_ALIGN  32768
+#defineMSK_STAT_ALIGN  32768
 
 /* Rx descriptor data structure */
 struct msk_rx_desc {
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r281877 - head/sys/dev/mii

2015-04-22 Thread Pyun YongHyeon
Author: yongari
Date: Thu Apr 23 01:39:28 2015
New Revision: 281877
URL: https://svnweb.freebsd.org/changeset/base/281877

Log:
  Add another variant of BCM5708S controller to IBM HS21 workaround
  list.
  
  PR:   118238
  MFC after:2 weeks

Modified:
  head/sys/dev/mii/brgphy.c

Modified: head/sys/dev/mii/brgphy.c
==
--- head/sys/dev/mii/brgphy.c   Thu Apr 23 01:04:14 2015(r281876)
+++ head/sys/dev/mii/brgphy.c   Thu Apr 23 01:39:28 2015(r281877)
@@ -160,25 +160,33 @@ static const struct mii_phy_funcs brgphy
brgphy_reset
 };
 
-#define HS21_PRODUCT_IDIBM eServer BladeCenter HS21
-#define HS21_BCM_CHIPID0x57081021
+static const struct hs21_type {
+   const uint32_t id;
+   const char *prod;
+} hs21_type_lists[] = {
+   { 0x57081021, IBM eServer BladeCenter HS21 },
+   { 0x57081011, IBM eServer BladeCenter HS21 -[8853PAU]- },
+};
 
 static int
 detect_hs21(struct bce_softc *bce_sc)
 {
char *sysenv;
-   int found;
+   int found, i;
 
found = 0;
-   if (bce_sc-bce_chipid == HS21_BCM_CHIPID) {
-   sysenv = kern_getenv(smbios.system.product);
-   if (sysenv != NULL) {
-   if (strncmp(sysenv, HS21_PRODUCT_ID,
-   strlen(HS21_PRODUCT_ID)) == 0)
-   found = 1;
-   freeenv(sysenv);
+   sysenv = kern_getenv(smbios.system.product);
+   if (sysenv == NULL)
+   return (found);
+   for (i = 0; i  nitems(hs21_type_lists); i++) {
+   if (bce_sc-bce_chipid == hs21_type_lists[i].id 
+   strncmp(sysenv, hs21_type_lists[i].prod,
+   strlen(hs21_type_lists[i].prod)) == 0) {
+   found++;
+   break;
}
}
+   freeenv(sysenv);
return (found);
 }
 
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r279941 - head/sys/dev/mii

2015-03-12 Thread Pyun YongHyeon
Author: yongari
Date: Fri Mar 13 01:16:14 2015
New Revision: 279941
URL: https://svnweb.freebsd.org/changeset/base/279941

Log:
  Restore auto MDIX for RTL8211B and newer revision PHYs which was
  broken in r279903.
  
  Reported by:  john  feith . com

Modified:
  head/sys/dev/mii/rgephy.c

Modified: head/sys/dev/mii/rgephy.c
==
--- head/sys/dev/mii/rgephy.c   Fri Mar 13 00:08:58 2015(r279940)
+++ head/sys/dev/mii/rgephy.c   Fri Mar 13 01:16:14 2015(r279941)
@@ -531,7 +531,7 @@ rgephy_reset(struct mii_softc *sc)
PHY_WRITE(sc, RGEPHY_MII_SSR, ssr);
}
}
-   break;
+   /* FALLTHROUGH */
default:
if (sc-mii_mpd_rev = RGEPHY_8211B) {
pcr = PHY_READ(sc, RGEPHY_MII_PCR);
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r279903 - head/sys/dev/mii

2015-03-12 Thread Pyun YongHyeon
Author: yongari
Date: Thu Mar 12 07:05:28 2015
New Revision: 279903
URL: https://svnweb.freebsd.org/changeset/base/279903

Log:
  Add RTL8211F gigabit PHY support.
  
  PR:   197265
  MFC after:2 weeks

Modified:
  head/sys/dev/mii/rgephy.c
  head/sys/dev/mii/rgephyreg.h

Modified: head/sys/dev/mii/rgephy.c
==
--- head/sys/dev/mii/rgephy.c   Thu Mar 12 06:43:58 2015(r279902)
+++ head/sys/dev/mii/rgephy.c   Thu Mar 12 07:05:28 2015(r279903)
@@ -87,6 +87,7 @@ static intrgephy_service(struct mii_sof
 static voidrgephy_status(struct mii_softc *);
 static int rgephy_mii_phy_auto(struct mii_softc *, int);
 static voidrgephy_reset(struct mii_softc *);
+static int rgephy_linkup(struct mii_softc *);
 static voidrgephy_loop(struct mii_softc *);
 static voidrgephy_load_dspcode(struct mii_softc *);
 
@@ -147,7 +148,7 @@ static int
 rgephy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
 {
struct ifmedia_entry *ife = mii-mii_media.ifm_cur;
-   int reg, speed, gig, anar;
+   int speed, gig, anar;
 
switch (cmd) {
case MII_POLLSTAT:
@@ -237,20 +238,9 @@ setit:
 * Check to see if we have link.  If we do, we don't
 * need to restart the autonegotiation process.
 */
-   if ((sc-mii_flags  MIIF_PHYPRIV0) == 0 
-   sc-mii_mpd_rev = 2) {
-   /* RTL8211B(L) */
-   reg = PHY_READ(sc, RGEPHY_MII_SSR);
-   if (reg  RGEPHY_SSR_LINK) {
-   sc-mii_ticks = 0;
-   break;
-   }
-   } else {
-   reg = PHY_READ(sc, RL_GMEDIASTAT);
-   if (reg  RL_GMEDIASTAT_LINK) {
-   sc-mii_ticks = 0;
-   break;
-   }
+   if (rgephy_linkup(sc) != 0) {
+   sc-mii_ticks = 0;
+   break;
}
 
/* Announce link loss right after it happens. */
@@ -283,6 +273,33 @@ setit:
return (0);
 }
 
+static int
+rgephy_linkup(struct mii_softc *sc)
+{
+   int linkup;
+   uint16_t reg;
+
+   linkup = 0;
+   if ((sc-mii_flags  MIIF_PHYPRIV0) == 0 
+   sc-mii_mpd_rev = RGEPHY_8211B) {
+   if (sc-mii_mpd_rev == RGEPHY_8211F) {
+   reg = PHY_READ(sc, RGEPHY_F_MII_SSR);
+   if (reg  RGEPHY_F_SSR_LINK)
+   linkup++;
+   } else {
+   reg = PHY_READ(sc, RGEPHY_MII_SSR);
+   if (reg  RGEPHY_SSR_LINK)
+   linkup++;
+   }
+   } else {
+   reg = PHY_READ(sc, RL_GMEDIASTAT);
+   if (reg  RL_GMEDIASTAT_LINK)
+   linkup++;
+   }
+
+   return (linkup);
+}
+
 static void
 rgephy_status(struct mii_softc *sc)
 {
@@ -293,18 +310,10 @@ rgephy_status(struct mii_softc *sc)
mii-mii_media_status = IFM_AVALID;
mii-mii_media_active = IFM_ETHER;
 
-   if ((sc-mii_flags  MIIF_PHYPRIV0) == 0  sc-mii_mpd_rev = 2) {
-   ssr = PHY_READ(sc, RGEPHY_MII_SSR);
-   if (ssr  RGEPHY_SSR_LINK)
-   mii-mii_media_status |= IFM_ACTIVE;
-   } else {
-   bmsr = PHY_READ(sc, RL_GMEDIASTAT);
-   if (bmsr  RL_GMEDIASTAT_LINK)
-   mii-mii_media_status |= IFM_ACTIVE;
-   }
+   if (rgephy_linkup(sc) != 0)
+   mii-mii_media_status |= IFM_ACTIVE;
 
bmsr = PHY_READ(sc, RGEPHY_MII_BMSR);
-
bmcr = PHY_READ(sc, RGEPHY_MII_BMCR);
if (bmcr  RGEPHY_BMCR_ISO) {
mii-mii_media_active |= IFM_NONE;
@@ -323,26 +332,50 @@ rgephy_status(struct mii_softc *sc)
}
}
 
-   if ((sc-mii_flags  MIIF_PHYPRIV0) == 0  sc-mii_mpd_rev = 2) {
-   ssr = PHY_READ(sc, RGEPHY_MII_SSR);
-   switch (ssr  RGEPHY_SSR_SPD_MASK) {
-   case RGEPHY_SSR_S1000:
-   mii-mii_media_active |= IFM_1000_T;
-   break;
-   case RGEPHY_SSR_S100:
-   mii-mii_media_active |= IFM_100_TX;
-   break;
-   case RGEPHY_SSR_S10:
-   mii-mii_media_active |= IFM_10_T;
-   break;
-   default:
-   mii-mii_media_active |= IFM_NONE;
-   break;
+   if ((sc-mii_flags  MIIF_PHYPRIV0) == 0 
+   sc-mii_mpd_rev = RGEPHY_8211B) {
+   if (sc-mii_mpd_rev == RGEPHY_8211F) {
+   ssr = PHY_READ(sc, RGEPHY_F_MII_SSR);
+   switch (ssr  RGEPHY_F_SSR_SPD_MASK) {
+   

svn commit: r279223 - head/sys/dev/bce

2015-02-23 Thread Pyun YongHyeon
Author: yongari
Date: Tue Feb 24 01:00:46 2015
New Revision: 279223
URL: https://svnweb.freebsd.org/changeset/base/279223

Log:
  Correct a typo.
  
  Reported by:  jmg

Modified:
  head/sys/dev/bce/if_bcereg.h

Modified: head/sys/dev/bce/if_bcereg.h
==
--- head/sys/dev/bce/if_bcereg.hMon Feb 23 22:58:51 2015
(r279222)
+++ head/sys/dev/bce/if_bcereg.hTue Feb 24 01:00:46 2015
(r279223)
@@ -419,7 +419,7 @@
 /* Returns FALSE in defects per 2^31 - 1 calls, otherwise returns TRUE. */
 #define DB_RANDOMFALSE(defects)(random()  defects)
 #define DB_OR_RANDOMFALSE(defects)  || (random()  defects)
-#define DB_AND_RANDOMFALSE(defects)  (random()  ddfects)
+#define DB_AND_RANDOMFALSE(defects)  (random()  defects)
 
 /* Returns TRUE in defects per 2^31 - 1 calls, otherwise returns FALSE. */
 #define DB_RANDOMTRUE(defects) (random()  defects)
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r277907 - head/sys/dev/alc

2015-01-29 Thread Pyun YongHyeon
Author: yongari
Date: Fri Jan 30 01:13:07 2015
New Revision: 277907
URL: https://svnweb.freebsd.org/changeset/base/277907

Log:
  Correct device description message.

Modified:
  head/sys/dev/alc/if_alc.c

Modified: head/sys/dev/alc/if_alc.c
==
--- head/sys/dev/alc/if_alc.c   Fri Jan 30 01:05:50 2015(r277906)
+++ head/sys/dev/alc/if_alc.c   Fri Jan 30 01:13:07 2015(r277907)
@@ -114,11 +114,11 @@ static struct alc_ident alc_ident_table[
{ VENDORID_ATHEROS, DEVICEID_ATHEROS_AR8161, 9 * 1024,
Atheros AR8161 PCIe Gigabit Ethernet },
{ VENDORID_ATHEROS, DEVICEID_ATHEROS_AR8162, 9 * 1024,
-   Atheros AR8161 PCIe Fast Ethernet },
+   Atheros AR8162 PCIe Fast Ethernet },
{ VENDORID_ATHEROS, DEVICEID_ATHEROS_AR8171, 9 * 1024,
-   Atheros AR8161 PCIe Gigabit Ethernet },
+   Atheros AR8171 PCIe Gigabit Ethernet },
{ VENDORID_ATHEROS, DEVICEID_ATHEROS_AR8172, 9 * 1024,
-   Atheros AR8161 PCIe Fast Ethernet },
+   Atheros AR8172 PCIe Fast Ethernet },
{ VENDORID_ATHEROS, DEVICEID_ATHEROS_E2200, 9 * 1024,
Killer E2200 Gigabit Ethernet },
{ 0, 0, 0, NULL}
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r277050 - head/sys/dev/nge

2015-01-11 Thread Pyun YongHyeon
Author: yongari
Date: Mon Jan 12 07:43:19 2015
New Revision: 277050
URL: https://svnweb.freebsd.org/changeset/base/277050

Log:
  Receive filter configuration is done in nge_rxfilter().  Remove
  unnecessary filter configuration code in nge_init_locked().
  While I'm here add a check for driver running state for multicast
  filter handling.  Also remove unnecessary assignment to error
  variable since it is cleared in the function entry.
  
  Suggested by: b...@openbsd.org

Modified:
  head/sys/dev/nge/if_nge.c

Modified: head/sys/dev/nge/if_nge.c
==
--- head/sys/dev/nge/if_nge.c   Mon Jan 12 07:39:52 2015(r277049)
+++ head/sys/dev/nge/if_nge.c   Mon Jan 12 07:43:19 2015(r277050)
@@ -2102,27 +2102,6 @@ nge_init_locked(struct nge_softc *sc)
 */
nge_list_tx_init(sc);
 
-   /*
-* For the NatSemi chip, we have to explicitly enable the
-* reception of ARP frames, as well as turn on the 'perfect
-* match' filter where we store the station address, otherwise
-* we won't receive unicasts meant for this host.
-*/
-   NGE_SETBIT(sc, NGE_RXFILT_CTL, NGE_RXFILTCTL_ARP);
-   NGE_SETBIT(sc, NGE_RXFILT_CTL, NGE_RXFILTCTL_PERFECT);
-
-   /*
-* Set the capture broadcast bit to capture broadcast frames.
-*/
-   if (ifp-if_flags  IFF_BROADCAST) {
-   NGE_SETBIT(sc, NGE_RXFILT_CTL, NGE_RXFILTCTL_BROAD);
-   } else {
-   NGE_CLRBIT(sc, NGE_RXFILT_CTL, NGE_RXFILTCTL_BROAD);
-   }
-
-   /* Turn the receive filter on. */
-   NGE_SETBIT(sc, NGE_RXFILT_CTL, NGE_RXFILTCTL_ENABLE);
-
/* Set Rx filter. */
nge_rxfilter(sc);
 
@@ -2335,9 +2314,9 @@ nge_ioctl(struct ifnet *ifp, u_long comm
case SIOCADDMULTI:
case SIOCDELMULTI:
NGE_LOCK(sc);
-   nge_rxfilter(sc);
+   if ((ifp-if_drv_flags  IFF_DRV_RUNNING) != 0)
+   nge_rxfilter(sc);
NGE_UNLOCK(sc);
-   error = 0;
break;
case SIOCGIFMEDIA:
case SIOCSIFMEDIA:
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r277048 - head/sys/dev/sis

2015-01-11 Thread Pyun YongHyeon
Author: yongari
Date: Mon Jan 12 07:37:06 2015
New Revision: 277048
URL: https://svnweb.freebsd.org/changeset/base/277048

Log:
  Enable receive filter in sis_rxfilter().
  While I'm here add a check for driver running state for multicast
  filter handling.
  
  Suggested by: b...@openbsd.org

Modified:
  head/sys/dev/sis/if_sis.c

Modified: head/sys/dev/sis/if_sis.c
==
--- head/sys/dev/sis/if_sis.c   Mon Jan 12 07:36:25 2015(r277047)
+++ head/sys/dev/sis/if_sis.c   Mon Jan 12 07:37:06 2015(r277048)
@@ -758,7 +758,8 @@ sis_rxfilter_ns(struct sis_softc *sc)
if_maddr_runlock(ifp);
}
 
-   CSR_WRITE_4(sc, SIS_RXFILT_CTL, filter);
+   /* Turn the receive filter on */
+   CSR_WRITE_4(sc, SIS_RXFILT_CTL, filter | SIS_RXFILTCTL_ENABLE);
CSR_READ_4(sc, SIS_RXFILT_CTL);
 }
 
@@ -820,7 +821,8 @@ sis_rxfilter_sis(struct sis_softc *sc)
CSR_WRITE_4(sc, SIS_RXFILT_DATA, hashes[i]);
}
 
-   CSR_WRITE_4(sc, SIS_RXFILT_CTL, filter);
+   /* Turn the receive filter on */
+   CSR_WRITE_4(sc, SIS_RXFILT_CTL, filter | SIS_RXFILTCTL_ENABLE);
CSR_READ_4(sc, SIS_RXFILT_CTL);
 }
 
@@ -2015,8 +2017,6 @@ sis_initl(struct sis_softc *sc)
}
 
sis_rxfilter(sc);
-   /* Turn the receive filter on */
-   SIS_SETBIT(sc, SIS_RXFILT_CTL, SIS_RXFILTCTL_ENABLE);
 
/*
 * Load the address of the RX and TX lists.
@@ -2138,7 +2138,8 @@ sis_ioctl(struct ifnet *ifp, u_long comm
case SIOCADDMULTI:
case SIOCDELMULTI:
SIS_LOCK(sc);
-   sis_rxfilter(sc);
+   if ((ifp-if_drv_flags  IFF_DRV_RUNNING) != 0)
+   sis_rxfilter(sc);
SIS_UNLOCK(sc);
break;
case SIOCGIFMEDIA:
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r275816 - head/sys/dev/sis

2014-12-15 Thread Pyun YongHyeon
Author: yongari
Date: Tue Dec 16 06:13:30 2014
New Revision: 275816
URL: https://svnweb.freebsd.org/changeset/base/275816

Log:
  Fix a bug introdiced in r217548.  According to NS DP83815 data
  sheet, RX filter should be disabled before programming.
  Previously it was clearing wrong bits so RX filter was not
  disabled in RX filter configuration.
  
  Reported by:  b...@openbsd.org

Modified:
  head/sys/dev/sis/if_sis.c

Modified: head/sys/dev/sis/if_sis.c
==
--- head/sys/dev/sis/if_sis.c   Mon Dec 15 22:20:14 2014(r275815)
+++ head/sys/dev/sis/if_sis.c   Tue Dec 16 06:13:30 2014(r275816)
@@ -780,7 +780,7 @@ sis_rxfilter_sis(struct sis_softc *sc)
 
filter = CSR_READ_4(sc, SIS_RXFILT_CTL);
if (filter  SIS_RXFILTCTL_ENABLE) {
-   CSR_WRITE_4(sc, SIS_RXFILT_CTL, filter  ~SIS_RXFILT_CTL);
+   CSR_WRITE_4(sc, SIS_RXFILT_CTL, filter  ~SIS_RXFILTCTL_ENABLE);
CSR_READ_4(sc, SIS_RXFILT_CTL);
}
filter = ~(SIS_RXFILTCTL_ALLPHYS | SIS_RXFILTCTL_BROAD |
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r273359 - head/sys/dev/re

2014-10-20 Thread Pyun YongHyeon
Author: yongari
Date: Tue Oct 21 01:31:24 2014
New Revision: 273359
URL: https://svnweb.freebsd.org/changeset/base/273359

Log:
  It seems multicast filtering of RTL8168F does not work.  Workaround
  the silicon bug by accepting any multicast packets.
  
  PR:   193488
  MFC After:1 week

Modified:
  head/sys/dev/re/if_re.c

Modified: head/sys/dev/re/if_re.c
==
--- head/sys/dev/re/if_re.c Tue Oct 21 01:15:43 2014(r273358)
+++ head/sys/dev/re/if_re.c Tue Oct 21 01:31:24 2014(r273359)
@@ -703,6 +703,12 @@ re_set_rxmode(struct rl_softc *sc)
rxfilt |= RL_RXCFG_RX_MULTI;
}
 
+   if  (sc-rl_hwrev-rl_rev == RL_HWREV_8168F) {
+   /* Disable multicast filtering due to silicon bug. */
+   hashes[0] = 0x;
+   hashes[1] = 0x;
+   }
+
 done:
CSR_WRITE_4(sc, RL_MAR0, hashes[0]);
CSR_WRITE_4(sc, RL_MAR4, hashes[1]);
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r273018 - head/sys/dev/alc

2014-10-12 Thread Pyun YongHyeon
Author: yongari
Date: Mon Oct 13 01:06:40 2014
New Revision: 273018
URL: https://svnweb.freebsd.org/changeset/base/273018

Log:
  Remove ALC_LOCK_ASSERT in alc_stop_queue().  This function is now
  called in device attach without holding a driver lock so it
  resulted in panic.
  
  Reported by:  markj

Modified:
  head/sys/dev/alc/if_alc.c

Modified: head/sys/dev/alc/if_alc.c
==
--- head/sys/dev/alc/if_alc.c   Mon Oct 13 00:33:59 2014(r273017)
+++ head/sys/dev/alc/if_alc.c   Mon Oct 13 01:06:40 2014(r273018)
@@ -4394,8 +4394,6 @@ alc_stop_queue(struct alc_softc *sc)
uint32_t reg;
int i;
 
-   ALC_LOCK_ASSERT(sc);
-
/* Disable RxQ. */
reg = CSR_READ_4(sc, ALC_RXQ_CFG);
if ((sc-alc_flags  ALC_FLAG_AR816X_FAMILY) == 0) {
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r272721 - in head/sys/dev: alc ale

2014-10-07 Thread Pyun YongHyeon
Author: yongari
Date: Wed Oct  8 01:03:32 2014
New Revision: 272721
URL: https://svnweb.freebsd.org/changeset/base/272721

Log:
  Fix a long standing bug in MAC statistics register access.  One
  additional register was erroneously added in the MAC register set
  such that 7 TX statistics counters were wrong.

Modified:
  head/sys/dev/alc/if_alc.c
  head/sys/dev/alc/if_alcreg.h
  head/sys/dev/ale/if_ale.c
  head/sys/dev/ale/if_alereg.h

Modified: head/sys/dev/alc/if_alc.c
==
--- head/sys/dev/alc/if_alc.c   Tue Oct  7 21:50:28 2014(r272720)
+++ head/sys/dev/alc/if_alc.c   Wed Oct  8 01:03:32 2014(r272721)
@@ -1287,8 +1287,6 @@ alc_sysctl_node(struct alc_softc *sc)
stats-tx_late_colls, Late collisions);
ALC_SYSCTL_STAT_ADD32(ctx, child, excess_colls,
stats-tx_excess_colls, Excessive collisions);
-   ALC_SYSCTL_STAT_ADD32(ctx, child, abort,
-   stats-tx_abort, Aborted frames due to Excessive collisions);
ALC_SYSCTL_STAT_ADD32(ctx, child, underruns,
stats-tx_underrun, FIFO underruns);
ALC_SYSCTL_STAT_ADD32(ctx, child, desc_underruns,
@@ -2599,7 +2597,6 @@ alc_stats_update(struct alc_softc *sc)
stat-tx_multi_colls += smb-tx_multi_colls;
stat-tx_late_colls += smb-tx_late_colls;
stat-tx_excess_colls += smb-tx_excess_colls;
-   stat-tx_abort += smb-tx_abort;
stat-tx_underrun += smb-tx_underrun;
stat-tx_desc_underrun += smb-tx_desc_underrun;
stat-tx_lenerrs += smb-tx_lenerrs;
@@ -2612,17 +2609,10 @@ alc_stats_update(struct alc_softc *sc)
 
if_inc_counter(ifp, IFCOUNTER_COLLISIONS, smb-tx_single_colls +
smb-tx_multi_colls * 2 + smb-tx_late_colls +
-   smb-tx_abort * HDPX_CFG_RETRY_DEFAULT);
+   smb-tx_excess_colls * HDPX_CFG_RETRY_DEFAULT);
 
-   /*
-* XXX
-* tx_pkts_truncated counter looks suspicious. It constantly
-* increments with no sign of Tx errors. This may indicate
-* the counter name is not correct one so I've removed the
-* counter in output errors.
-*/
-   if_inc_counter(ifp, IFCOUNTER_OERRORS,
-   smb-tx_abort + smb-tx_late_colls + smb-tx_underrun);
+   if_inc_counter(ifp, IFCOUNTER_OERRORS, smb-tx_late_colls +
+   smb-tx_excess_colls + smb-tx_underrun + smb-tx_pkts_truncated);
 
if_inc_counter(ifp, IFCOUNTER_IPACKETS, smb-rx_frames);
 

Modified: head/sys/dev/alc/if_alcreg.h
==
--- head/sys/dev/alc/if_alcreg.hTue Oct  7 21:50:28 2014
(r272720)
+++ head/sys/dev/alc/if_alcreg.hWed Oct  8 01:03:32 2014
(r272721)
@@ -860,7 +860,6 @@ struct smb {
uint32_t tx_multi_colls;
uint32_t tx_late_colls;
uint32_t tx_excess_colls;
-   uint32_t tx_abort;
uint32_t tx_underrun;
uint32_t tx_desc_underrun;
uint32_t tx_lenerrs;

Modified: head/sys/dev/ale/if_ale.c
==
--- head/sys/dev/ale/if_ale.c   Tue Oct  7 21:50:28 2014(r272720)
+++ head/sys/dev/ale/if_ale.c   Wed Oct  8 01:03:32 2014(r272721)
@@ -946,8 +946,6 @@ ale_sysctl_node(struct ale_softc *sc)
stats-tx_late_colls, Late collisions);
ALE_SYSCTL_STAT_ADD32(ctx, child, excess_colls,
stats-tx_excess_colls, Excessive collisions);
-   ALE_SYSCTL_STAT_ADD32(ctx, child, abort,
-   stats-tx_abort, Aborted frames due to Excessive collisions);
ALE_SYSCTL_STAT_ADD32(ctx, child, underruns,
stats-tx_underrun, FIFO underruns);
ALE_SYSCTL_STAT_ADD32(ctx, child, desc_underruns,
@@ -2197,7 +2195,6 @@ ale_stats_update(struct ale_softc *sc)
stat-tx_multi_colls += smb-tx_multi_colls;
stat-tx_late_colls += smb-tx_late_colls;
stat-tx_excess_colls += smb-tx_excess_colls;
-   stat-tx_abort += smb-tx_abort;
stat-tx_underrun += smb-tx_underrun;
stat-tx_desc_underrun += smb-tx_desc_underrun;
stat-tx_lenerrs += smb-tx_lenerrs;
@@ -2210,17 +2207,10 @@ ale_stats_update(struct ale_softc *sc)
 
if_inc_counter(ifp, IFCOUNTER_COLLISIONS, smb-tx_single_colls +
smb-tx_multi_colls * 2 + smb-tx_late_colls +
-   smb-tx_abort * HDPX_CFG_RETRY_DEFAULT);
+   smb-tx_excess_colls * HDPX_CFG_RETRY_DEFAULT);
 
-   /*
-* XXX
-* tx_pkts_truncated counter looks suspicious. It constantly
-* increments with no sign of Tx errors. This may indicate
-* the counter name is not correct one so I've removed the
-* counter in output errors.
-*/
-   if_inc_counter(ifp, IFCOUNTER_OERRORS,
-   smb-tx_abort + smb-tx_late_colls + smb-tx_underrun);
+   if_inc_counter(ifp, IFCOUNTER_OERRORS, smb-tx_late_colls +
+   

svn commit: r272729 - head/sys/dev/pci

2014-10-07 Thread Pyun YongHyeon
Author: yongari
Date: Wed Oct  8 05:34:39 2014
New Revision: 272729
URL: https://svnweb.freebsd.org/changeset/base/272729

Log:
  Add new quirk PCI_QUIRK_MSI_INTX_BUG to pci(4).
  QAC AR816x/E2200 controller has a silicon bug that MSI interrupt
  does not assert if PCIM_CMD_INTxDIS bit of command register is set.
  
  Reviewed by:  jhb

Modified:
  head/sys/dev/pci/pci.c

Modified: head/sys/dev/pci/pci.c
==
--- head/sys/dev/pci/pci.c  Wed Oct  8 05:04:31 2014(r272728)
+++ head/sys/dev/pci/pci.c  Wed Oct  8 05:34:39 2014(r272729)
@@ -207,6 +207,7 @@ struct pci_quirk {
 #definePCI_QUIRK_ENABLE_MSI_VM 3 /* Older chipset in VM where MSI 
works */
 #definePCI_QUIRK_UNMAP_REG 4 /* Ignore PCI map register */
 #definePCI_QUIRK_DISABLE_MSIX  5 /* MSI-X doesn't work */
+#definePCI_QUIRK_MSI_INTX_BUG  5 /* PCIM_CMD_INTxDIS disables MSI */
int arg1;
int arg2;
 };
@@ -266,6 +267,15 @@ static const struct pci_quirk pci_quirks
 */
{ 0x43851002, PCI_QUIRK_UNMAP_REG,  0x14,   0 },
 
+   /*
+* Atheros AR8161/AR8162/E2200 ethernet controller has a bug that
+* MSI interrupt does not assert if PCIM_CMD_INTxDIS bit of the
+* command register is set.
+*/
+   { 0x10911969, PCI_QUIRK_MSI_INTX_BUG,   0,  0 },
+   { 0xE0911969, PCI_QUIRK_MSI_INTX_BUG,   0,  0 },
+   { 0x10901969, PCI_QUIRK_MSI_INTX_BUG,   0,  0 },
+
{ 0 }
 };
 
@@ -3856,8 +3866,14 @@ pci_setup_intr(device_t dev, device_t ch
mte-mte_handlers++;
}
 
-   /* Make sure that INTx is disabled if we are using MSI/MSIX */
-   pci_set_command_bit(dev, child, PCIM_CMD_INTxDIS);
+   if (!pci_has_quirk(pci_get_devid(dev),
+   PCI_QUIRK_MSI_INTX_BUG)) {
+   /*
+* Make sure that INTx is disabled if we are
+* using MSI/MSIX
+*/
+   pci_set_command_bit(dev, child, PCIM_CMD_INTxDIS);
+   }
bad:
if (error) {
(void)bus_generic_teardown_intr(dev, child, irq,
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r272730 - head/sys/dev/alc

2014-10-07 Thread Pyun YongHyeon
Author: yongari
Date: Wed Oct  8 05:47:01 2014
New Revision: 272730
URL: https://svnweb.freebsd.org/changeset/base/272730

Log:
  Add support for QAC AR816x/AR817x Gigabit/Fast Ethernet controllers.
  These controllers seem to have the same feature of AR813x/AR815x and
  improved RSS support(4 TX queues and 8 RX queues).  alc(4) supports
  all hardware features except RSS.  I didn't implement RX checksum
  offloading for AR816x/AR817x just because I couldn't get
  confirmation from the Vendor whether AR816x/AR817x corrected its
  predecessor's RX checksum offloading bug on fragmented packets.
  This change adds supports for the following controllers.
   o AR8161 PCIe Gigabit Ethernet controller
   o AR8162 PCIe Fast Ethernet controller
   o AR8171 PCIe Gigabit Ethernet controller
   o AR8172 PCIe Fast Ethernet controller
   o Killer E2200 Gigabit Ethernet controller
  
  Tested by:Many
  Relnotes: yes
  MFC after:2 weeks
  HW donated by:Qualcomm Atheros Communications, Inc.

Modified:
  head/sys/dev/alc/if_alc.c
  head/sys/dev/alc/if_alcreg.h
  head/sys/dev/alc/if_alcvar.h

Modified: head/sys/dev/alc/if_alc.c
==
--- head/sys/dev/alc/if_alc.c   Wed Oct  8 05:34:39 2014(r272729)
+++ head/sys/dev/alc/if_alc.c   Wed Oct  8 05:47:01 2014(r272730)
@@ -111,17 +111,31 @@ static struct alc_ident alc_ident_table[
Atheros AR8152 v1.1 PCIe Fast Ethernet },
{ VENDORID_ATHEROS, DEVICEID_ATHEROS_AR8152_B2, 6 * 1024,
Atheros AR8152 v2.0 PCIe Fast Ethernet },
+   { VENDORID_ATHEROS, DEVICEID_ATHEROS_AR8161, 9 * 1024,
+   Atheros AR8161 PCIe Gigabit Ethernet },
+   { VENDORID_ATHEROS, DEVICEID_ATHEROS_AR8162, 9 * 1024,
+   Atheros AR8161 PCIe Fast Ethernet },
+   { VENDORID_ATHEROS, DEVICEID_ATHEROS_AR8171, 9 * 1024,
+   Atheros AR8161 PCIe Gigabit Ethernet },
+   { VENDORID_ATHEROS, DEVICEID_ATHEROS_AR8172, 9 * 1024,
+   Atheros AR8161 PCIe Fast Ethernet },
+   { VENDORID_ATHEROS, DEVICEID_ATHEROS_E2200, 9 * 1024,
+   Killer E2200 Gigabit Ethernet },
{ 0, 0, 0, NULL}
 };
 
-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 int alc_attach(device_t);
 static int alc_check_boundary(struct alc_softc *);
+static voidalc_config_msi(struct alc_softc *);
 static int alc_detach(device_t);
 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_dmamap_cb(void *, bus_dma_segment_t *, int, int);
+static voidalc_dsp_fixup(struct alc_softc *, int);
 static int alc_encap(struct alc_softc *, struct mbuf **);
 static struct alc_ident *
alc_find_ident(device_t);
@@ -130,6 +144,9 @@ static struct mbuf *
alc_fixup_rx(struct ifnet *, struct mbuf *);
 #endif
 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(void *);
 static voidalc_init_cmb(struct alc_softc *);
 static voidalc_init_locked(struct alc_softc *);
@@ -141,14 +158,26 @@ static void   alc_int_task(void *, int);
 static int alc_intr(void *);
 static int alc_ioctl(struct ifnet *, u_long, caddr_t);
 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 uint32_talc_mii_writereg_813x(struct alc_softc *, int, int, 
int);
+static uint32_talc_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 int alc_miibus_writereg(device_t, int, int, int);
+static uint32_talc_miidbg_readreg(struct alc_softc *, int);
+static uint32_talc_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_mediachange(struct ifnet *);
+static int alc_mediachange_locked(struct alc_softc *);
 static voidalc_mediastatus(struct ifnet *, struct ifmediareq *);
 static int alc_newbuf(struct alc_softc *, struct alc_rxdesc *);
+static voidalc_osc_reset(struct alc_softc *);
 static voidalc_phy_down(struct alc_softc *);
 static voidalc_phy_reset(struct alc_softc *);
+static voidalc_phy_reset_813x(struct alc_softc *);
+static void

svn commit: r272731 - head/share/man/man4

2014-10-07 Thread Pyun YongHyeon
Author: yongari
Date: Wed Oct  8 05:49:10 2014
New Revision: 272731
URL: https://svnweb.freebsd.org/changeset/base/272731

Log:
  Document newly added controller AR816x/AR817x.

Modified:
  head/share/man/man4/alc.4

Modified: head/share/man/man4/alc.4
==
--- head/share/man/man4/alc.4   Wed Oct  8 05:47:01 2014(r272730)
+++ head/share/man/man4/alc.4   Wed Oct  8 05:49:10 2014(r272731)
@@ -24,12 +24,12 @@
 .\
 .\ $FreeBSD$
 .\
-.Dd August 9, 2010
+.Dd October 8, 2014
 .Dt ALC 4
 .Os
 .Sh NAME
 .Nm alc
-.Nd Atheros AR813x/AR815x Gigabit/Fast Ethernet driver
+.Nd Atheros AR813x/AR815x/AR816x/AR817x Gigabit/Fast Ethernet driver
 .Sh SYNOPSIS
 To compile this driver into the kernel,
 place the following lines in your
@@ -48,8 +48,8 @@ if_alc_load=YES
 .Sh DESCRIPTION
 The
 .Nm
-device driver provides support for Atheros AR813x and AR815x PCI
-Express Gigabit/Fast Ethernet controllers.
+device driver provides support for Atheros AR813x, AR815x, AR816x
+and AR817x PCI Express Gigabit/Fast Ethernet controllers.
 .Pp
 All LOMs supported by the
 .Nm
@@ -58,9 +58,9 @@ segmentation offload (TSO), hardware VLA
 features, Wake On Lan (WOL) and an interrupt moderation mechanism
 as well as a 64-bit multicast hash filter.
 .Pp
-The AR813x and AR815x supports Jumbo Frames (up to 9216 and 6144
-bytes, respectively), which can be configured via the interface
-MTU setting.
+The AR813x, AR815x, AR816x and AR817x supports Jumbo Frames (up to
+9216, 6144, 9216 and 9216 bytes, respectively), which can be
+configured via the interface MTU setting.
 Selecting an MTU larger than 1500 bytes with the
 .Xr ifconfig 8
 utility configures the adapter to receive and transmit Jumbo Frames.
@@ -112,6 +112,16 @@ Atheros AR8151 v2.0 PCI Express Gigabit 
 Atheros AR8152 v1.1 PCI Express Fast Ethernet controller
 .It
 Atheros AR8152 v2.0 PCI Express Fast Ethernet controller
+.It
+Atheros AR8161 PCI Express Gigabit Ethernet controller
+.It
+Atheros AR8162 PCI Express Fast Ethernet controller
+.It
+Atheros AR8171 PCI Express Gigabit Ethernet controller
+.It
+Atheros AR8172 PCI Express Fast Ethernet controller
+.It
+Killer E2200 Gigabit Ethernet controller
 .El
 .Sh LOADER TUNABLES
 Tunables can be set at the
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r272732 - head/sys/dev/pci

2014-10-07 Thread Pyun YongHyeon
Author: yongari
Date: Wed Oct  8 05:53:04 2014
New Revision: 272732
URL: https://svnweb.freebsd.org/changeset/base/272732

Log:
  Oops, fix typo made in r272729.

Modified:
  head/sys/dev/pci/pci.c

Modified: head/sys/dev/pci/pci.c
==
--- head/sys/dev/pci/pci.c  Wed Oct  8 05:49:10 2014(r272731)
+++ head/sys/dev/pci/pci.c  Wed Oct  8 05:53:04 2014(r272732)
@@ -207,7 +207,7 @@ struct pci_quirk {
 #definePCI_QUIRK_ENABLE_MSI_VM 3 /* Older chipset in VM where MSI 
works */
 #definePCI_QUIRK_UNMAP_REG 4 /* Ignore PCI map register */
 #definePCI_QUIRK_DISABLE_MSIX  5 /* MSI-X doesn't work */
-#definePCI_QUIRK_MSI_INTX_BUG  5 /* PCIM_CMD_INTxDIS disables MSI */
+#definePCI_QUIRK_MSI_INTX_BUG  6 /* PCIM_CMD_INTxDIS disables MSI */
int arg1;
int arg2;
 };
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r271073 - head/sys/dev/mii

2014-09-03 Thread Pyun YongHyeon
Author: yongari
Date: Thu Sep  4 01:04:37 2014
New Revision: 271073
URL: http://svnweb.freebsd.org/changeset/base/271073

Log:
  Do not blindly announce 1000baseT half-duplex capability in
  autonegotiation.  Some controllers like cgem(4) do not support
  half-duplex at gigabit speeds.

Modified:
  head/sys/dev/mii/e1000phy.c

Modified: head/sys/dev/mii/e1000phy.c
==
--- head/sys/dev/mii/e1000phy.c Thu Sep  4 00:43:27 2014(r271072)
+++ head/sys/dev/mii/e1000phy.c Thu Sep  4 01:04:37 2014(r271073)
@@ -169,8 +169,12 @@ e1000phy_attach(device_t dev)
PHY_RESET(sc);
 
sc-mii_capabilities = PHY_READ(sc, MII_BMSR)  sc-mii_capmask;
-   if (sc-mii_capabilities  BMSR_EXTSTAT)
+   if (sc-mii_capabilities  BMSR_EXTSTAT) {
sc-mii_extcapabilities = PHY_READ(sc, MII_EXTSR);
+   if ((sc-mii_extcapabilities 
+   (EXTSR_1000TFDX | EXTSR_1000THDX)) != 0)
+   sc-mii_flags |= MIIF_HAVE_GTCR;
+   }
device_printf(dev,  );
mii_phy_add_media(sc);
printf(\n);
@@ -319,8 +323,7 @@ e1000phy_service(struct mii_softc *sc, s
speed = 0;
switch (IFM_SUBTYPE(ife-ifm_media)) {
case IFM_1000_T:
-   if ((sc-mii_extcapabilities 
-   (EXTSR_1000TFDX | EXTSR_1000THDX)) == 0)
+   if ((sc-mii_flags  MIIF_HAVE_GTCR) == 0)
return (EINVAL);
speed = E1000_CR_SPEED_1000;
break;
@@ -357,10 +360,9 @@ e1000phy_service(struct mii_softc *sc, s
 
if (IFM_SUBTYPE(ife-ifm_media) == IFM_1000_T) {
gig |= E1000_1GCR_MS_ENABLE;
-   if ((ife-ifm_media  IFM_ETH_MASTER) != 0) 
+   if ((ife-ifm_media  IFM_ETH_MASTER) != 0)
gig |= E1000_1GCR_MS_VALUE;
-   } else if ((sc-mii_extcapabilities 
-   (EXTSR_1000TFDX | EXTSR_1000THDX)) != 0)
+   } else if ((sc-mii_flags  MIIF_HAVE_GTCR) != 0)
gig = 0;
PHY_WRITE(sc, E1000_1GCR, gig);
PHY_WRITE(sc, E1000_AR, E1000_AR_SELECTOR_FIELD);
@@ -485,9 +487,14 @@ e1000phy_mii_phy_auto(struct mii_softc *
PHY_WRITE(sc, E1000_AR, reg | E1000_AR_SELECTOR_FIELD);
} else
PHY_WRITE(sc, E1000_AR, E1000_FA_1000X_FD | E1000_FA_1000X);
-   if ((sc-mii_extcapabilities  (EXTSR_1000TFDX | EXTSR_1000THDX)) != 0)
-   PHY_WRITE(sc, E1000_1GCR,
-   E1000_1GCR_1000T_FD | E1000_1GCR_1000T);
+   if ((sc-mii_flags  MIIF_HAVE_GTCR) != 0) {
+   reg = 0;
+   if ((sc-mii_extcapabilities  EXTSR_1000TFDX) != 0)
+   reg |= E1000_1GCR_1000T_FD;
+   if ((sc-mii_extcapabilities  EXTSR_1000THDX) != 0)
+   reg |= E1000_1GCR_1000T;
+   PHY_WRITE(sc, E1000_1GCR, reg);
+   }
PHY_WRITE(sc, E1000_CR,
E1000_CR_AUTO_NEG_ENABLE | E1000_CR_RESTART_AUTO_NEG);
 
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r265942 - head/sys/netinet

2014-05-12 Thread Pyun YongHyeon
Author: yongari
Date: Tue May 13 05:07:03 2014
New Revision: 265942
URL: http://svnweb.freebsd.org/changeset/base/265942

Log:
  Fix checksum computation.  Previously it didn't include carry.
  
  Reviewed by:  tuexen

Modified:
  head/sys/netinet/ip_input.c

Modified: head/sys/netinet/ip_input.c
==
--- head/sys/netinet/ip_input.c Mon May 12 23:35:10 2014(r265941)
+++ head/sys/netinet/ip_input.c Tue May 13 05:07:03 2014(r265942)
@@ -1080,8 +1080,9 @@ found:
 * (and not in for{} loop), though it implies we are not going to
 * reassemble more than 64k fragments.
 */
-   m-m_pkthdr.csum_data =
-   (m-m_pkthdr.csum_data  0x) + (m-m_pkthdr.csum_data  16);
+   while (m-m_pkthdr.csum_data  0x)
+   m-m_pkthdr.csum_data = (m-m_pkthdr.csum_data  0x) +
+   (m-m_pkthdr.csum_data  16);
 #ifdef MAC
mac_ipq_reassemble(fp, m);
mac_ipq_destroy(fp);
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r265943 - head/sys/dev/re

2014-05-12 Thread Pyun YongHyeon
Author: yongari
Date: Tue May 13 05:19:29 2014
New Revision: 265943
URL: http://svnweb.freebsd.org/changeset/base/265943

Log:
  Disable TX IP/TCP/UDP checksum offloading for RTL8168C/RTL8168CP.
  Previously only TX IP checksum offloading was disabled but it's
  reported that TX checksum offloading for UDP datagrams with IP
  options also generates corrupted frames.  Reporter's controller is
  RTL8168CP but I guess RTL8168C also have the same issue since it
  shall share the same core.
  
  Reported and tested by:   tuexen

Modified:
  head/sys/dev/re/if_re.c

Modified: head/sys/dev/re/if_re.c
==
--- head/sys/dev/re/if_re.c Tue May 13 05:07:03 2014(r265942)
+++ head/sys/dev/re/if_re.c Tue May 13 05:19:29 2014(r265943)
@@ -1619,16 +1619,18 @@ re_attach(device_t dev)
ifp-if_start = re_start;
/*
 * RTL8168/8111C generates wrong IP checksummed frame if the
-* packet has IP options so disable TX IP checksum offloading.
+* packet has IP options so disable TX checksum offloading.
 */
if (sc-rl_hwrev-rl_rev == RL_HWREV_8168C ||
sc-rl_hwrev-rl_rev == RL_HWREV_8168C_SPIN2 ||
-   sc-rl_hwrev-rl_rev == RL_HWREV_8168CP)
-   ifp-if_hwassist = CSUM_TCP | CSUM_UDP;
-   else
+   sc-rl_hwrev-rl_rev == RL_HWREV_8168CP) {
+   ifp-if_hwassist = 0;
+   ifp-if_capabilities = IFCAP_RXCSUM | IFCAP_TSO4;
+   } else {
ifp-if_hwassist = CSUM_IP | CSUM_TCP | CSUM_UDP;
+   ifp-if_capabilities = IFCAP_HWCSUM | IFCAP_TSO4;
+   }
ifp-if_hwassist |= CSUM_TSO;
-   ifp-if_capabilities = IFCAP_HWCSUM | IFCAP_TSO4;
ifp-if_capenable = ifp-if_capabilities;
ifp-if_init = re_init;
IFQ_SET_MAXLEN(ifp-if_snd, RL_IFQ_MAXLEN);
@@ -3364,7 +3366,6 @@ re_ioctl(struct ifnet *ifp, u_long comma
struct rl_softc *sc = ifp-if_softc;
struct ifreq*ifr = (struct ifreq *) data;
struct mii_data *mii;
-   uint32_trev;
int error = 0;
 
switch (command) {
@@ -3453,15 +3454,9 @@ re_ioctl(struct ifnet *ifp, u_long comma
if ((mask  IFCAP_TXCSUM) != 0 
(ifp-if_capabilities  IFCAP_TXCSUM) != 0) {
ifp-if_capenable ^= IFCAP_TXCSUM;
-   if ((ifp-if_capenable  IFCAP_TXCSUM) != 0) {
-   rev = sc-rl_hwrev-rl_rev;
-   if (rev == RL_HWREV_8168C ||
-   rev == RL_HWREV_8168C_SPIN2 ||
-   rev == RL_HWREV_8168CP)
-   ifp-if_hwassist |= CSUM_TCP | CSUM_UDP;
-   else
-   ifp-if_hwassist |= RE_CSUM_FEATURES;
-   } else
+   if ((ifp-if_capenable  IFCAP_TXCSUM) != 0)
+   ifp-if_hwassist |= RE_CSUM_FEATURES;
+   else
ifp-if_hwassist = ~RE_CSUM_FEATURES;
reinit = 1;
}
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r264293 - head/sys/dev/nfe

2014-04-08 Thread Pyun YongHyeon
Author: yongari
Date: Wed Apr  9 05:15:40 2014
New Revision: 264293
URL: http://svnweb.freebsd.org/changeset/base/264293

Log:
  Add workaround for MCP61 Ethernet controller found on MSI K9
  motherboard.  PHY hardware used for the controller responded at
  all possible addresses which in turn resulted in having 32 PHYs
  for the controller.  If driver detects MSI K9N6PGM2-V2 (MS-7309)
  motherboard, tell miibus(4) PHY is located at 0.
  
  Tested by:Chris H

Modified:
  head/sys/dev/nfe/if_nfe.c

Modified: head/sys/dev/nfe/if_nfe.c
==
--- head/sys/dev/nfe/if_nfe.c   Wed Apr  9 03:51:05 2014(r264292)
+++ head/sys/dev/nfe/if_nfe.c   Wed Apr  9 05:15:40 2014(r264293)
@@ -79,6 +79,7 @@ static int  nfe_suspend(device_t);
 static int  nfe_resume(device_t);
 static int nfe_shutdown(device_t);
 static int  nfe_can_use_msix(struct nfe_softc *);
+static int  nfe_detect_msik9(struct nfe_softc *);
 static void nfe_power(struct nfe_softc *);
 static int  nfe_miibus_readreg(device_t, int, int);
 static int  nfe_miibus_writereg(device_t, int, int, int);
@@ -334,13 +335,38 @@ nfe_alloc_msix(struct nfe_softc *sc, int
}
 }
 
+
+static int
+nfe_detect_msik9(struct nfe_softc *sc)
+{
+   static const char *maker = MSI;
+   static const char *product = K9N6PGM2-V2 (MS-7309);
+   char *m, *p;
+   int found;
+
+   found = 0;
+   m = getenv(smbios.planar.maker);
+   p = getenv(smbios.planar.product);
+   if (m != NULL  p != NULL) {
+   if (strcmp(m, maker) == 0  strcmp(p, product) == 0)
+   found = 1;
+   }
+   if (m != NULL)
+   freeenv(m);
+   if (p != NULL)
+   freeenv(p);
+
+   return (found);
+}
+
+
 static int
 nfe_attach(device_t dev)
 {
struct nfe_softc *sc;
struct ifnet *ifp;
bus_addr_t dma_addr_max;
-   int error = 0, i, msic, reg, rid;
+   int error = 0, i, msic, phyloc, reg, rid;
 
sc = device_get_softc(dev);
sc-nfe_dev = dev;
@@ -608,8 +634,16 @@ nfe_attach(device_t dev)
 #endif
 
/* Do MII setup */
+   phyloc = MII_PHY_ANY;
+   if (sc-nfe_devid == PCI_PRODUCT_NVIDIA_MCP61_LAN1 ||
+   sc-nfe_devid == PCI_PRODUCT_NVIDIA_MCP61_LAN2 ||
+   sc-nfe_devid == PCI_PRODUCT_NVIDIA_MCP61_LAN3 ||
+   sc-nfe_devid == PCI_PRODUCT_NVIDIA_MCP61_LAN4) {
+   if (nfe_detect_msik9(sc) != 0)
+   phyloc = 0;
+   }
error = mii_attach(dev, sc-nfe_miibus, ifp, nfe_ifmedia_upd,
-   nfe_ifmedia_sts, BMSR_DEFCAPMASK, MII_PHY_ANY, MII_OFFSET_ANY,
+   nfe_ifmedia_sts, BMSR_DEFCAPMASK, phyloc, MII_OFFSET_ANY,
MIIF_DOPAUSE);
if (error != 0) {
device_printf(dev, attaching PHYs failed\n);
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r264062 - head/sys/dev/usb/net

2014-04-02 Thread Pyun YongHyeon
Author: yongari
Date: Thu Apr  3 01:32:43 2014
New Revision: 264062
URL: http://svnweb.freebsd.org/changeset/base/264062

Log:
  Correct endianness handling in getting station address from EEPROM.
  While I'm here, remove aue_eeprom_getword() as its only usage is to
  read station address and make it more readable.  This change is
  inspired by NetBSD.
  With this change, aue(4) should work on big endian architectures.
  
  PR:   188177

Modified:
  head/sys/dev/usb/net/if_aue.c

Modified: head/sys/dev/usb/net/if_aue.c
==
--- head/sys/dev/usb/net/if_aue.c   Thu Apr  3 01:02:14 2014
(r264061)
+++ head/sys/dev/usb/net/if_aue.c   Thu Apr  3 01:32:43 2014
(r264062)
@@ -212,9 +212,7 @@ static uint8_t  aue_csr_read_1(struct aue
 static uint16_taue_csr_read_2(struct aue_softc *, uint16_t);
 static voidaue_csr_write_1(struct aue_softc *, uint16_t, uint8_t);
 static voidaue_csr_write_2(struct aue_softc *, uint16_t, uint16_t);
-static voidaue_eeprom_getword(struct aue_softc *, int, uint16_t *);
-static voidaue_read_eeprom(struct aue_softc *, uint8_t *, uint16_t,
-   uint16_t);
+static uint16_taue_eeprom_getword(struct aue_softc *, int);
 static voidaue_reset(struct aue_softc *);
 static voidaue_reset_pegasus_II(struct aue_softc *);
 
@@ -376,11 +374,10 @@ aue_csr_write_2(struct aue_softc *sc, ui
 /*
  * Read a word of data stored in the EEPROM at address 'addr.'
  */
-static void
-aue_eeprom_getword(struct aue_softc *sc, int addr, uint16_t *dest)
+static uint16_t
+aue_eeprom_getword(struct aue_softc *sc, int addr)
 {
int i;
-   uint16_t word = 0;
 
aue_csr_write_1(sc, AUE_EE_REG, addr);
aue_csr_write_1(sc, AUE_EE_CTL, AUE_EECTL_READ);
@@ -395,22 +392,23 @@ aue_eeprom_getword(struct aue_softc *sc,
if (i == AUE_TIMEOUT)
device_printf(sc-sc_ue.ue_dev, EEPROM read timed out\n);
 
-   word = aue_csr_read_2(sc, AUE_EE_DATA);
-   *dest = word;
+   return (aue_csr_read_2(sc, AUE_EE_DATA));
 }
 
 /*
- * Read a sequence of words from the EEPROM.
+ * Read station address(offset 0) from the EEPROM.
  */
 static void
-aue_read_eeprom(struct aue_softc *sc, uint8_t *dest,
-uint16_t off, uint16_t len)
+aue_read_mac(struct aue_softc *sc, uint8_t *eaddr)
 {
-   uint16_t *ptr = (uint16_t *)dest;
-   int i;
+   int i, offset;
+   uint16_t word;
 
-   for (i = 0; i != len; i++, ptr++)
-   aue_eeprom_getword(sc, off + i, ptr);
+   for (i = 0, offset = 0; i  ETHER_ADDR_LEN / 2; i++) {
+   word = aue_eeprom_getword(sc, offset + i);
+   eaddr[i * 2] = (uint8_t)word;
+   eaddr[i * 2 + 1] = (uint8_t)(word  8);
+   }
 }
 
 static int
@@ -636,7 +634,7 @@ aue_attach_post(struct usb_ether *ue)
aue_reset(sc);
 
/* get station address from the EEPROM */
-   aue_read_eeprom(sc, ue-ue_eaddr, 0, 3);
+   aue_read_mac(sc, ue-ue_eaddr);
 }
 
 /*
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r263957 - in head/sys: dev/age dev/alc dev/ale dev/bce dev/bge dev/fxp dev/jme dev/msk dev/nfe dev/sge pci

2014-03-30 Thread Pyun YongHyeon
Author: yongari
Date: Mon Mar 31 01:54:59 2014
New Revision: 263957
URL: http://svnweb.freebsd.org/changeset/base/263957

Log:
  Increase the number of TX DMA segments from 32 to 35.  It turned
  out 32 is not enough to support a full sized TSO packet.
  While I'm here fix a long standing bug introduced in r169632 in
  bce(4) where it didn't include L2 header length of TSO packet in
  the maximum DMA segment size calculation.
  
  In collaboration with:rmacklem
  MFC after:2 weeks

Modified:
  head/sys/dev/age/if_agevar.h
  head/sys/dev/alc/if_alcvar.h
  head/sys/dev/ale/if_alevar.h
  head/sys/dev/bce/if_bcereg.h
  head/sys/dev/bge/if_bgereg.h
  head/sys/dev/fxp/if_fxpreg.h
  head/sys/dev/jme/if_jmevar.h
  head/sys/dev/msk/if_mskreg.h
  head/sys/dev/nfe/if_nfereg.h
  head/sys/dev/sge/if_sgereg.h
  head/sys/pci/if_rlreg.h

Modified: head/sys/dev/age/if_agevar.h
==
--- head/sys/dev/age/if_agevar.hMon Mar 31 01:04:40 2014
(r263956)
+++ head/sys/dev/age/if_agevar.hMon Mar 31 01:54:59 2014
(r263957)
@@ -42,7 +42,7 @@
 
 #defineAGE_TSO_MAXSEGSIZE  4096
 #defineAGE_TSO_MAXSIZE (65535 + sizeof(struct 
ether_vlan_header))
-#defineAGE_MAXTXSEGS   32
+#defineAGE_MAXTXSEGS   35
 #defineAGE_RX_BUF_ALIGN8
 #ifndef __NO_STRICT_ALIGNMENT
 #defineAGE_RX_BUF_SIZE (MCLBYTES - AGE_RX_BUF_ALIGN)   

Modified: head/sys/dev/alc/if_alcvar.h
==
--- head/sys/dev/alc/if_alcvar.hMon Mar 31 01:04:40 2014
(r263956)
+++ head/sys/dev/alc/if_alcvar.hMon Mar 31 01:54:59 2014
(r263957)
@@ -42,7 +42,7 @@
 
 #defineALC_TSO_MAXSEGSIZE  4096
 #defineALC_TSO_MAXSIZE (65535 + sizeof(struct 
ether_vlan_header))
-#defineALC_MAXTXSEGS   32
+#defineALC_MAXTXSEGS   35
 
 #defineALC_ADDR_LO(x)  ((uint64_t) (x)  0x)
 #defineALC_ADDR_HI(x)  ((uint64_t) (x)  32)

Modified: head/sys/dev/ale/if_alevar.h
==
--- head/sys/dev/ale/if_alevar.hMon Mar 31 01:04:40 2014
(r263956)
+++ head/sys/dev/ale/if_alevar.hMon Mar 31 01:54:59 2014
(r263957)
@@ -40,7 +40,7 @@
 
 #defineALE_TSO_MAXSEGSIZE  4096
 #defineALE_TSO_MAXSIZE (65535 + sizeof(struct 
ether_vlan_header))
-#defineALE_MAXTXSEGS   32
+#defineALE_MAXTXSEGS   35
 
 #defineALE_ADDR_LO(x)  ((uint64_t) (x)  0x)
 #defineALE_ADDR_HI(x)  ((uint64_t) (x)  32)

Modified: head/sys/dev/bce/if_bcereg.h
==
--- head/sys/dev/bce/if_bcereg.hMon Mar 31 01:04:40 2014
(r263956)
+++ head/sys/dev/bce/if_bcereg.hMon Mar 31 01:54:59 2014
(r263957)
@@ -6309,8 +6309,8 @@ struct fw_info {
 
 #define BCE_TX_TIMEOUT 5
 
-#define BCE_MAX_SEGMENTS   32
-#define BCE_TSO_MAX_SIZE   65536
+#define BCE_MAX_SEGMENTS   35
+#define BCE_TSO_MAX_SIZE   (65535 + sizeof(struct ether_vlan_header))
 #define BCE_TSO_MAX_SEG_SIZE   4096
 
 #define BCE_DMA_ALIGN  8

Modified: head/sys/dev/bge/if_bgereg.h
==
--- head/sys/dev/bge/if_bgereg.hMon Mar 31 01:04:40 2014
(r263956)
+++ head/sys/dev/bge/if_bgereg.hMon Mar 31 01:54:59 2014
(r263957)
@@ -2852,7 +2852,7 @@ struct bge_gib {
  */
 
 #defineBGE_NSEG_JUMBO  4
-#defineBGE_NSEG_NEW32
+#defineBGE_NSEG_NEW35
 #defineBGE_TSOSEG_SZ   4096
 
 /* Maximum DMA address for controllers that have 40bit DMA address bug. */

Modified: head/sys/dev/fxp/if_fxpreg.h
==
--- head/sys/dev/fxp/if_fxpreg.hMon Mar 31 01:04:40 2014
(r263956)
+++ head/sys/dev/fxp/if_fxpreg.hMon Mar 31 01:54:59 2014
(r263957)
@@ -250,7 +250,7 @@ struct fxp_cb_ucode {
 /*
  * Number of DMA segments in a TxCB.
  */
-#define FXP_NTXSEG 32
+#define FXP_NTXSEG 35
 
 struct fxp_tbd {
uint32_t tb_addr;

Modified: head/sys/dev/jme/if_jmevar.h
==
--- head/sys/dev/jme/if_jmevar.hMon Mar 31 01:04:40 2014
(r263956)
+++ head/sys/dev/jme/if_jmevar.hMon Mar 31 01:54:59 2014
(r263957)
@@ -49,7 +49,7 @@
 #defineJME_RX_RING_ALIGN   16
 #defineJME_TSO_MAXSEGSIZE  4096
 #defineJME_TSO_MAXSIZE (65535 + sizeof(struct 
ether_vlan_header))
-#defineJME_MAXTXSEGS   32
+#define

svn commit: r261577 - head/sys/dev/msk

2014-02-06 Thread Pyun YongHyeon
Author: yongari
Date: Fri Feb  7 05:08:59 2014
New Revision: 261577
URL: http://svnweb.freebsd.org/changeset/base/261577

Log:
  Revert r234666.  Clearing TWSI IRQ seems to cause watchdog timeout
  on old Yukon II controllers.
  
  Tested by:bsam
  MFC after:2 weeks

Modified:
  head/sys/dev/msk/if_msk.c

Modified: head/sys/dev/msk/if_msk.c
==
--- head/sys/dev/msk/if_msk.c   Fri Feb  7 04:35:20 2014(r261576)
+++ head/sys/dev/msk/if_msk.c   Fri Feb  7 05:08:59 2014(r261577)
@@ -3750,9 +3750,6 @@ msk_intr(void *xsc)
if ((status  Y2_IS_STAT_BMU) != 0  domore == 0)
CSR_WRITE_4(sc, STAT_CTRL, SC_STAT_CLR_IRQ);
 
-   /* Clear TWSI IRQ. */
-   if ((status  Y2_IS_TWSI_RDY) != 0)
-   CSR_WRITE_4(sc, B2_I2C_IRQ, 1);
/* Reenable interrupts. */
CSR_WRITE_4(sc, B0_Y2_SP_ICR, 2);
 
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r260429 - head/sys/dev/ale

2014-01-07 Thread Pyun YongHyeon
Author: yongari
Date: Wed Jan  8 01:06:32 2014
New Revision: 260429
URL: http://svnweb.freebsd.org/changeset/base/260429

Log:
  m_defrag(9) does not touch original mbuf chain when it can't
  allocate new mbuf.  Free original mbuf chain when driver is not
  able to send the packet.

Modified:
  head/sys/dev/ale/if_ale.c

Modified: head/sys/dev/ale/if_ale.c
==
--- head/sys/dev/ale/if_ale.c   Tue Jan  7 23:51:41 2014(r260428)
+++ head/sys/dev/ale/if_ale.c   Wed Jan  8 01:06:32 2014(r260429)
@@ -1660,6 +1660,7 @@ ale_encap(struct ale_softc *sc, struct m
(mtod(m, intptr_t)  3) != 0) {
m = m_defrag(*m_head, M_NOWAIT);
if (m == NULL) {
+   m_freem(*m_head);
*m_head = NULL;
return (ENOBUFS);
}
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r259543 - head/sys/dev/ae

2013-12-17 Thread Pyun YongHyeon
Author: yongari
Date: Wed Dec 18 07:23:42 2013
New Revision: 259543
URL: http://svnweb.freebsd.org/changeset/base/259543

Log:
  Failed m_devget(9) indicates lack of free mbuf cluster.  Update
  if_iqdrops counter for that case since the received frame is ok.
  While here, simplify updating counter logic.

Modified:
  head/sys/dev/ae/if_ae.c

Modified: head/sys/dev/ae/if_ae.c
==
--- head/sys/dev/ae/if_ae.c Wed Dec 18 06:24:21 2013(r259542)
+++ head/sys/dev/ae/if_ae.c Wed Dec 18 07:23:42 2013(r259543)
@@ -135,7 +135,7 @@ static void ae_mac_config(ae_softc_t *sc
 static int ae_intr(void *arg);
 static voidae_int_task(void *arg, int pending);
 static voidae_tx_intr(ae_softc_t *sc);
-static int ae_rxeof(ae_softc_t *sc, ae_rxd_t *rxd);
+static voidae_rxeof(ae_softc_t *sc, ae_rxd_t *rxd);
 static voidae_rx_intr(ae_softc_t *sc);
 static voidae_watchdog(ae_softc_t *sc);
 static voidae_tick(void *arg);
@@ -1884,7 +1884,7 @@ ae_tx_intr(ae_softc_t *sc)
BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
 }
 
-static int
+static void
 ae_rxeof(ae_softc_t *sc, ae_rxd_t *rxd)
 {
struct ifnet *ifp;
@@ -1903,12 +1903,15 @@ ae_rxeof(ae_softc_t *sc, ae_rxd_t *rxd)
size = le16toh(rxd-len) - ETHER_CRC_LEN;
if (size  (ETHER_MIN_LEN - ETHER_CRC_LEN - ETHER_VLAN_ENCAP_LEN)) {
if_printf(ifp, Runt frame received.);
-   return (EIO);
+   ifp-if_ierrors++;
+   return;
}
 
m = m_devget(rxd-data[0], size, ETHER_ALIGN, ifp, NULL);
-   if (m == NULL)
-   return (ENOBUFS);
+   if (m == NULL) {
+   ifp-if_iqdrops++;
+   return;
+   }
 
if ((ifp-if_capenable  IFCAP_VLAN_HWTAGGING) != 0 
(flags  AE_RXD_HAS_VLAN) != 0) {
@@ -1916,14 +1919,13 @@ ae_rxeof(ae_softc_t *sc, ae_rxd_t *rxd)
m-m_flags |= M_VLANTAG;
}
 
+   ifp-if_ipackets++;
/*
 * Pass it through.
 */
AE_UNLOCK(sc);
(*ifp-if_input)(ifp, m);
AE_LOCK(sc);
-
-   return (0);
 }
 
 static void
@@ -1932,7 +1934,7 @@ ae_rx_intr(ae_softc_t *sc)
ae_rxd_t *rxd;
struct ifnet *ifp;
uint16_t flags;
-   int count, error;
+   int count;
 
KASSERT(sc != NULL, ([ae, %d]: sc is NULL!, __LINE__));
 
@@ -1960,17 +1962,10 @@ ae_rx_intr(ae_softc_t *sc)
 */
sc-rxd_cur = (sc-rxd_cur + 1) % AE_RXD_COUNT_DEFAULT;
 
-   if ((flags  AE_RXD_SUCCESS) == 0) {
-   ifp-if_ierrors++;
-   continue;
-   }
-   error = ae_rxeof(sc, rxd);
-   if (error != 0) {
+   if ((flags  AE_RXD_SUCCESS) != 0)
+   ae_rxeof(sc, rxd);
+   else
ifp-if_ierrors++;
-   continue;
-   } else {
-   ifp-if_ipackets++;
-   }
}
 
if (count  0) {
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r258830 - head/sys/dev/bge

2013-12-01 Thread Pyun YongHyeon
Author: yongari
Date: Mon Dec  2 05:21:54 2013
New Revision: 258830
URL: http://svnweb.freebsd.org/changeset/base/258830

Log:
  Add support for BCM57764, BCM57767, BCM57782, BCM57786 and BCM57787.
  Submitted by: jhb
  PR:   184304

Modified:
  head/sys/dev/bge/if_bge.c
  head/sys/dev/bge/if_bgereg.h

Modified: head/sys/dev/bge/if_bge.c
==
--- head/sys/dev/bge/if_bge.c   Mon Dec  2 03:59:45 2013(r258829)
+++ head/sys/dev/bge/if_bge.c   Mon Dec  2 05:21:54 2013(r258830)
@@ -221,11 +221,16 @@ static const struct bge_type {
{ BCOM_VENDORID,BCOM_DEVICEID_BCM57760 },
{ BCOM_VENDORID,BCOM_DEVICEID_BCM57761 },
{ BCOM_VENDORID,BCOM_DEVICEID_BCM57762 },
+   { BCOM_VENDORID,BCOM_DEVICEID_BCM57764 },
{ BCOM_VENDORID,BCOM_DEVICEID_BCM57765 },
{ BCOM_VENDORID,BCOM_DEVICEID_BCM57766 },
+   { BCOM_VENDORID,BCOM_DEVICEID_BCM57767 },
{ BCOM_VENDORID,BCOM_DEVICEID_BCM57780 },
{ BCOM_VENDORID,BCOM_DEVICEID_BCM57781 },
+   { BCOM_VENDORID,BCOM_DEVICEID_BCM57782 },
{ BCOM_VENDORID,BCOM_DEVICEID_BCM57785 },
+   { BCOM_VENDORID,BCOM_DEVICEID_BCM57786 },
+   { BCOM_VENDORID,BCOM_DEVICEID_BCM57787 },
{ BCOM_VENDORID,BCOM_DEVICEID_BCM57788 },
{ BCOM_VENDORID,BCOM_DEVICEID_BCM57790 },
{ BCOM_VENDORID,BCOM_DEVICEID_BCM57791 },
@@ -2694,6 +2699,9 @@ bge_chipid(device_t dev)
case BCOM_DEVICEID_BCM5725:
case BCOM_DEVICEID_BCM5727:
case BCOM_DEVICEID_BCM5762:
+   case BCOM_DEVICEID_BCM57764:
+   case BCOM_DEVICEID_BCM57767:
+   case BCOM_DEVICEID_BCM57787:
id = pci_read_config(dev,
BGE_PCI_GEN2_PRODID_ASICREV, 4);
break;
@@ -2702,7 +2710,9 @@ bge_chipid(device_t dev)
case BCOM_DEVICEID_BCM57765:
case BCOM_DEVICEID_BCM57766:
case BCOM_DEVICEID_BCM57781:
+   case BCOM_DEVICEID_BCM57782:
case BCOM_DEVICEID_BCM57785:
+   case BCOM_DEVICEID_BCM57786:
case BCOM_DEVICEID_BCM57791:
case BCOM_DEVICEID_BCM57795:
id = pci_read_config(dev,

Modified: head/sys/dev/bge/if_bgereg.h
==
--- head/sys/dev/bge/if_bgereg.hMon Dec  2 03:59:45 2013
(r258829)
+++ head/sys/dev/bge/if_bgereg.hMon Dec  2 05:21:54 2013
(r258830)
@@ -2503,11 +2503,16 @@ struct bge_status_block {
 #defineBCOM_DEVICEID_BCM57760  0x1690
 #defineBCOM_DEVICEID_BCM57761  0x16B0
 #defineBCOM_DEVICEID_BCM57762  0x1682
+#defineBCOM_DEVICEID_BCM57764  0x1642
 #defineBCOM_DEVICEID_BCM57765  0x16B4
 #defineBCOM_DEVICEID_BCM57766  0x1686
+#defineBCOM_DEVICEID_BCM57767  0x1683
 #defineBCOM_DEVICEID_BCM57780  0x1692
 #defineBCOM_DEVICEID_BCM57781  0x16B1
+#defineBCOM_DEVICEID_BCM57782  0x16B7
 #defineBCOM_DEVICEID_BCM57785  0x16B5
+#defineBCOM_DEVICEID_BCM57786  0x16B3
+#defineBCOM_DEVICEID_BCM57787  0x1641
 #defineBCOM_DEVICEID_BCM57788  0x1691
 #defineBCOM_DEVICEID_BCM57790  0x1694
 #defineBCOM_DEVICEID_BCM57791  0x16B2
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r257490 - head/sys/dev/msk

2013-10-31 Thread Pyun YongHyeon
Author: yongari
Date: Fri Nov  1 05:03:47 2013
New Revision: 257490
URL: http://svnweb.freebsd.org/changeset/base/257490

Log:
  Perform media change after setting IFF_DRV_RUNNING flag. Without it,
  driver would ignore the first link state update if controller
  already established a link.
  
  Reported by:  bsam
  Tested by:bsam

Modified:
  head/sys/dev/msk/if_msk.c

Modified: head/sys/dev/msk/if_msk.c
==
--- head/sys/dev/msk/if_msk.c   Fri Nov  1 02:04:05 2013(r257489)
+++ head/sys/dev/msk/if_msk.c   Fri Nov  1 05:03:47 2013(r257490)
@@ -4071,12 +4071,12 @@ msk_init_locked(struct msk_if_softc *sc_
CSR_WRITE_4(sc, B0_IMSK, sc-msk_intrmask);
CSR_READ_4(sc, B0_IMSK);
 
-   sc_if-msk_flags = ~MSK_FLAG_LINK;
-   mii_mediachg(mii);
-
ifp-if_drv_flags |= IFF_DRV_RUNNING;
ifp-if_drv_flags = ~IFF_DRV_OACTIVE;
 
+   sc_if-msk_flags = ~MSK_FLAG_LINK;
+   mii_mediachg(mii);
+
callout_reset(sc_if-msk_tick_ch, hz, msk_tick, sc_if);
 }
 
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r257307 - head/sys/dev/bce

2013-10-29 Thread Pyun YongHyeon
Author: yongari
Date: Tue Oct 29 06:37:27 2013
New Revision: 257307
URL: http://svnweb.freebsd.org/changeset/base/257307

Log:
  Fix regression introduced in r235816.
  r235816 triggered kernel panic or hang after warm boot.
  Don't blindly restore BCE_EMAC_MODE media configuration in
  bce_reset().  If driver is about to shutdown it will invoke
  bce_reset() which in turn results in restoring BCE_EMAC_MODE
  media configuration.  This operation seems to confuse controller
  firmware.
  
  Reported by:  Paul Herman (herman  cleverbridge dot com)
  Tested by:sbruno, Paul Herman (herman  cleverbridge dot com)

Modified:
  head/sys/dev/bce/if_bce.c

Modified: head/sys/dev/bce/if_bce.c
==
--- head/sys/dev/bce/if_bce.c   Tue Oct 29 05:37:05 2013(r257306)
+++ head/sys/dev/bce/if_bce.c   Tue Oct 29 06:37:27 2013(r257307)
@@ -5112,9 +5112,11 @@ bce_reset(struct bce_softc *sc, u32 rese
 
 bce_reset_exit:
/* Restore EMAC Mode bits needed to keep ASF/IPMI running. */
-   val = REG_RD(sc, BCE_EMAC_MODE);
-   val = (val  ~emac_mode_mask) | emac_mode_save;
-   REG_WR(sc, BCE_EMAC_MODE, val);
+   if (reset_code == BCE_DRV_MSG_CODE_RESET) {
+   val = REG_RD(sc, BCE_EMAC_MODE);
+   val = (val  ~emac_mode_mask) | emac_mode_save;
+   REG_WR(sc, BCE_EMAC_MODE, val);
+   }
 
DBEXIT(BCE_VERBOSE_RESET);
return (rc);
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r257304 - head/sys/dev/mii

2013-10-28 Thread Pyun YongHyeon
Author: yongari
Date: Tue Oct 29 05:14:38 2013
New Revision: 257304
URL: http://svnweb.freebsd.org/changeset/base/257304

Log:
  Add support for new Gigabit PHY of RealTek.
  I don't have a copy of data sheet so I'm not sure exact PHY model
  name. Vendor's web page indicates RTL8251 is latest PHY so I used
  the name. This PHY is used with RTL8168G, RTL8168GU and RTL8411B.

Modified:
  head/sys/dev/mii/miidevs
  head/sys/dev/mii/rgephy.c

Modified: head/sys/dev/mii/miidevs
==
--- head/sys/dev/mii/miidevsTue Oct 29 04:31:07 2013(r257303)
+++ head/sys/dev/mii/miidevsTue Oct 29 05:14:38 2013(r257304)
@@ -304,6 +304,7 @@ model yyREALTEK RTL8201L0x0020 RTL8201L
 model xxREALTEK RTL8169S   0x0011 RTL8169S/8110S/8211 1000BASE-T media 
interface
 model REALTEK RTL8305SC0x0005 RTL8305SC 10/100 802.1q switch
 model REALTEK RTL8201E 0x0008 RTL8201E 10/100 media interface
+model REALTEK RTL8251  0x RTL8251 1000BASE-T media interface
 model REALTEK RTL8169S 0x0011 RTL8169S/8110S/8211 1000BASE-T media 
interface
 
 /* Seeq Seeq PHYs */

Modified: head/sys/dev/mii/rgephy.c
==
--- head/sys/dev/mii/rgephy.c   Tue Oct 29 04:31:07 2013(r257303)
+++ head/sys/dev/mii/rgephy.c   Tue Oct 29 05:14:38 2013(r257304)
@@ -91,6 +91,7 @@ static void   rgephy_load_dspcode(struct m
 
 static const struct mii_phydesc rgephys[] = {
MII_PHY_DESC(REALTEK, RTL8169S),
+   MII_PHY_DESC(REALTEK, RTL8251),
MII_PHY_END
 };
 
@@ -395,7 +396,8 @@ rgephy_loop(struct mii_softc *sc)
 {
int i;
 
-   if (sc-mii_mpd_rev  2) {
+   if (sc-mii_mpd_model != MII_MODEL_REALTEK_RTL8251 
+   sc-mii_mpd_rev  2) {
PHY_WRITE(sc, RGEPHY_MII_BMCR, RGEPHY_BMCR_PDOWN);
DELAY(1000);
}
@@ -428,7 +430,8 @@ rgephy_load_dspcode(struct mii_softc *sc
 {
int val;
 
-   if (sc-mii_mpd_rev = 2)
+   if (sc-mii_mpd_model == MII_MODEL_REALTEK_RTL8251 ||
+   sc-mii_mpd_rev = 2)
return;
 
PHY_WRITE(sc, 31, 0x0001);
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r257305 - in head/sys: dev/re pci

2013-10-28 Thread Pyun YongHyeon
Author: yongari
Date: Tue Oct 29 05:30:21 2013
New Revision: 257305
URL: http://svnweb.freebsd.org/changeset/base/257305

Log:
  Add preliminary support for RTL8168G, RTL8168GU and RTL8411B.
  RTL8168GU has two variants(GMII and MII) but it uses the same chip
  revision id.  Driver checks PCI device id of controller and
  sets internal capability flag(i.e. jumbo frame and link speed down
  in WOL).
  
  H/W donated by:   RealTek Semiconductor Corp.

Modified:
  head/sys/dev/re/if_re.c
  head/sys/pci/if_rlreg.h

Modified: head/sys/dev/re/if_re.c
==
--- head/sys/dev/re/if_re.c Tue Oct 29 05:14:38 2013(r257304)
+++ head/sys/dev/re/if_re.c Tue Oct 29 05:30:21 2013(r257305)
@@ -182,7 +182,7 @@ static const struct rl_type re_devs[] = 
{ RT_VENDORID, RT_DEVICEID_8101E, 0,
RealTek 810xE PCIe 10/100baseTX },
{ RT_VENDORID, RT_DEVICEID_8168, 0,
-   RealTek 8168/8111 B/C/CP/D/DP/E/F PCIe Gigabit Ethernet },
+   RealTek 8168/8111 B/C/CP/D/DP/E/F/G PCIe Gigabit Ethernet },
{ RT_VENDORID, RT_DEVICEID_8169, 0,
RealTek 8169/8169S/8169SB(L)/8110S/8110SB(L) Gigabit Ethernet },
{ RT_VENDORID, RT_DEVICEID_8169SC, 0,
@@ -235,7 +235,10 @@ static const struct rl_hwrev re_hwrevs[]
{ RL_HWREV_8168E, RL_8169, 8168E/8111E, RL_JUMBO_MTU_9K},
{ RL_HWREV_8168E_VL, RL_8169, 8168E/8111E-VL, RL_JUMBO_MTU_6K},
{ RL_HWREV_8168F, RL_8169, 8168F/8111F, RL_JUMBO_MTU_9K},
+   { RL_HWREV_8168G, RL_8169, 8168G/8111G, RL_JUMBO_MTU_9K},
+   { RL_HWREV_8168GU, RL_8169, 8168GU/8111GU, RL_JUMBO_MTU_9K},
{ RL_HWREV_8411, RL_8169, 8411, RL_JUMBO_MTU_9K},
+   { RL_HWREV_8411B, RL_8169, 8411B, RL_JUMBO_MTU_9K},
{ 0, 0, NULL, 0 }
 };
 
@@ -1460,12 +1463,25 @@ re_attach(device_t dev)
break;
case RL_HWREV_8168E_VL:
case RL_HWREV_8168F:
+   case RL_HWREV_8168G:
case RL_HWREV_8411:
+   case RL_HWREV_8411B:
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_CMDSTOP_WAIT_TXQ | RL_FLAG_WOL_MANLINK;
break;
+   case RL_HWREV_8168GU:
+   if (pci_get_device(dev) == RT_DEVICEID_8101E) {
+   /* RTL8106EUS */
+   sc-rl_flags |= RL_FLAG_FASTETHER;
+   } else
+   sc-rl_flags |= RL_FLAG_JUMBOV2 | RL_FLAG_WOL_MANLINK;
+
+   sc-rl_flags |= RL_FLAG_PHYWAKE | RL_FLAG_PAR |
+   RL_FLAG_DESCV2 | RL_FLAG_MACSTAT | RL_FLAG_CMDSTOP |
+   RL_FLAG_AUTOPAD | RL_FLAG_CMDSTOP_WAIT_TXQ;
+   break;
case RL_HWREV_8169_8110SB:
case RL_HWREV_8169_8110SBL:
case RL_HWREV_8169_8110SC:
@@ -3336,7 +3352,9 @@ re_ioctl(struct ifnet *ifp, u_long comma
switch (command) {
case SIOCSIFMTU:
if (ifr-ifr_mtu  ETHERMIN ||
-   ifr-ifr_mtu  sc-rl_hwrev-rl_max_mtu) {
+   ifr-ifr_mtu  sc-rl_hwrev-rl_max_mtu ||
+   ((sc-rl_flags  RL_FLAG_FASTETHER) != 0 
+   ifr-ifr_mtu  RL_MTU)) {
error = EINVAL;
break;
}

Modified: head/sys/pci/if_rlreg.h
==
--- head/sys/pci/if_rlreg.h Tue Oct 29 05:14:38 2013(r257304)
+++ head/sys/pci/if_rlreg.h Tue Oct 29 05:30:21 2013(r257305)
@@ -192,6 +192,9 @@
 #defineRL_HWREV_8106E  0x4480
 #defineRL_HWREV_8168F  0x4800
 #defineRL_HWREV_8411   0x4880
+#defineRL_HWREV_8168G  0x4C00
+#defineRL_HWREV_8168GU 0x5080
+#defineRL_HWREV_8411B  0x5C80
 #defineRL_HWREV_8139   0x6000
 #defineRL_HWREV_8139A  0x7000
 #defineRL_HWREV_8139AG 0x7080
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r257306 - in head/sys: dev/re pci

2013-10-28 Thread Pyun YongHyeon
Author: yongari
Date: Tue Oct 29 05:37:05 2013
New Revision: 257306
URL: http://svnweb.freebsd.org/changeset/base/257306

Log:
  Add preliminary support for RTL8168EP.
  
  Submitted by: Edward O'Callaghan (eocallaghan  alterapraxis dot com)

Modified:
  head/sys/dev/re/if_re.c
  head/sys/pci/if_rlreg.h

Modified: head/sys/dev/re/if_re.c
==
--- head/sys/dev/re/if_re.c Tue Oct 29 05:30:21 2013(r257305)
+++ head/sys/dev/re/if_re.c Tue Oct 29 05:37:05 2013(r257306)
@@ -234,6 +234,7 @@ static const struct rl_hwrev re_hwrevs[]
{ RL_HWREV_8168DP, RL_8169, 8168DP/8111DP, RL_JUMBO_MTU_9K },
{ RL_HWREV_8168E, RL_8169, 8168E/8111E, RL_JUMBO_MTU_9K},
{ RL_HWREV_8168E_VL, RL_8169, 8168E/8111E-VL, RL_JUMBO_MTU_6K},
+   { RL_HWREV_8168EP, RL_8169, 8168EP/8111EP, RL_JUMBO_MTU_9K},
{ RL_HWREV_8168F, RL_8169, 8168F/8111F, RL_JUMBO_MTU_9K},
{ RL_HWREV_8168G, RL_8169, 8168G/8111G, RL_JUMBO_MTU_9K},
{ RL_HWREV_8168GU, RL_8169, 8168GU/8111GU, RL_JUMBO_MTU_9K},
@@ -1462,6 +1463,7 @@ re_attach(device_t dev)
RL_FLAG_WOL_MANLINK;
break;
case RL_HWREV_8168E_VL:
+   case RL_HWREV_8168EP:
case RL_HWREV_8168F:
case RL_HWREV_8168G:
case RL_HWREV_8411:

Modified: head/sys/pci/if_rlreg.h
==
--- head/sys/pci/if_rlreg.h Tue Oct 29 05:30:21 2013(r257305)
+++ head/sys/pci/if_rlreg.h Tue Oct 29 05:37:05 2013(r257306)
@@ -193,6 +193,7 @@
 #defineRL_HWREV_8168F  0x4800
 #defineRL_HWREV_8411   0x4880
 #defineRL_HWREV_8168G  0x4C00
+#defineRL_HWREV_8168EP 0x5000
 #defineRL_HWREV_8168GU 0x5080
 #defineRL_HWREV_8411B  0x5C80
 #defineRL_HWREV_8139   0x6000
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r256038 - head/sys/dev/nfe

2013-10-03 Thread Pyun YongHyeon
Author: yongari
Date: Fri Oct  4 02:21:39 2013
New Revision: 256038
URL: http://svnweb.freebsd.org/changeset/base/256038

Log:
  Fix clearing MAC stats registers. Previously it cleared every
  fourth register.
  
  Submitted by: Paul A. Patience paul-a.patie...@polymtl.ca
  Approved by:  re (gjb)

Modified:
  head/sys/dev/nfe/if_nfe.c

Modified: head/sys/dev/nfe/if_nfe.c
==
--- head/sys/dev/nfe/if_nfe.c   Fri Oct  4 02:18:30 2013(r256037)
+++ head/sys/dev/nfe/if_nfe.c   Fri Oct  4 02:21:39 2013(r256038)
@@ -3205,8 +3205,8 @@ nfe_stats_clear(struct nfe_softc *sc)
else
return;
 
-   for (i = 0; i  mib_cnt; i += sizeof(uint32_t))
-   NFE_READ(sc, NFE_TX_OCTET + i);
+   for (i = 0; i  mib_cnt; i++)
+   NFE_READ(sc, NFE_TX_OCTET + i * sizeof(uint32_t));
 
if ((sc-nfe_flags  NFE_MIB_V3) != 0) {
NFE_READ(sc, NFE_TX_UNICAST);
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r254118 - head/sys/dev/bge

2013-08-08 Thread Pyun YongHyeon
Author: yongari
Date: Fri Aug  9 01:15:32 2013
New Revision: 254118
URL: http://svnweb.freebsd.org/changeset/base/254118

Log:
  Fix for IPv4 fragment packets treated as RMCP.
  
  bit25 of rxMode MAC register of 5762 needs to be set for rx mgmt
  filter to work correctly when processing match for UDP header
  fields.  Otherwise false positive can occur which causes IPv4
  fragment to be received by APE instead of host.
  
  Reported by:  Geans Pin geans...@broadcom.com

Modified:
  head/sys/dev/bge/if_bge.c
  head/sys/dev/bge/if_bgereg.h

Modified: head/sys/dev/bge/if_bge.c
==
--- head/sys/dev/bge/if_bge.c   Fri Aug  9 01:10:33 2013(r254117)
+++ head/sys/dev/bge/if_bge.c   Fri Aug  9 01:15:32 2013(r254118)
@@ -5542,6 +5542,8 @@ bge_init_locked(struct bge_softc *sc)
mode = CSR_READ_4(sc, BGE_RX_MODE);
if (BGE_IS_5755_PLUS(sc))
mode |= BGE_RXMODE_IPV6_ENABLE;
+   if (sc-bge_asicrev == BGE_ASICREV_BCM5762)
+   mode |= BGE_RXMODE_IPV4_FRAG_FIX;
CSR_WRITE_4(sc,BGE_RX_MODE, mode | BGE_RXMODE_ENABLE);
DELAY(10);
 

Modified: head/sys/dev/bge/if_bgereg.h
==
--- head/sys/dev/bge/if_bgereg.hFri Aug  9 01:10:33 2013
(r254117)
+++ head/sys/dev/bge/if_bgereg.hFri Aug  9 01:15:32 2013
(r254118)
@@ -841,6 +841,7 @@
 #defineBGE_RXMODE_RX_NO_CRC_CHECK  0x0200
 #defineBGE_RXMODE_RX_KEEP_VLAN_DIAG0x0400
 #defineBGE_RXMODE_IPV6_ENABLE  0x0100
+#defineBGE_RXMODE_IPV4_FRAG_FIX0x0200
 
 /* Receive MAC status register */
 #defineBGE_RXSTAT_REMOTE_XOFFED0x0001
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r253540 - head/sys/dev/bge

2013-07-21 Thread Pyun YongHyeon
Author: yongari
Date: Mon Jul 22 05:45:54 2013
New Revision: 253540
URL: http://svnweb.freebsd.org/changeset/base/253540

Log:
  5725 family of devices corrupts TSO packets when TSO DMA buffers
  cross into regions which are within MSS bytes of a 4GB boundary.
  If we encounter the condition, drop the packet.
  
  Reviewed by:  Geans Pin geanspin@Broacom

Modified:
  head/sys/dev/bge/if_bge.c

Modified: head/sys/dev/bge/if_bge.c
==
--- head/sys/dev/bge/if_bge.c   Mon Jul 22 03:55:15 2013(r253539)
+++ head/sys/dev/bge/if_bge.c   Mon Jul 22 05:45:54 2013(r253540)
@@ -5257,17 +5257,51 @@ bge_encap(struct bge_softc *sc, struct m
csum_flags |= BGE_TXBDFLAG_VLAN_TAG;
vlan_tag = m-m_pkthdr.ether_vtag;
}
-   for (i = 0; ; i++) {
-   d = sc-bge_ldata.bge_tx_ring[idx];
-   d-bge_addr.bge_addr_lo = BGE_ADDR_LO(segs[i].ds_addr);
-   d-bge_addr.bge_addr_hi = BGE_ADDR_HI(segs[i].ds_addr);
-   d-bge_len = segs[i].ds_len;
-   d-bge_flags = csum_flags;
-   d-bge_vlan_tag = vlan_tag;
-   d-bge_mss = mss;
-   if (i == nsegs - 1)
-   break;
-   BGE_INC(idx, BGE_TX_RING_CNT);
+
+   if (sc-bge_asicrev == BGE_ASICREV_BCM5762 
+   (m-m_pkthdr.csum_flags  CSUM_TSO) != 0) {
+   /*
+* 5725 family of devices corrupts TSO packets when TSO DMA
+* buffers cross into regions which are within MSS bytes of
+* a 4GB boundary.  If we encounter the condition, drop the
+* packet.
+*/
+   for (i = 0; ; i++) {
+   d = sc-bge_ldata.bge_tx_ring[idx];
+   d-bge_addr.bge_addr_lo = BGE_ADDR_LO(segs[i].ds_addr);
+   d-bge_addr.bge_addr_hi = BGE_ADDR_HI(segs[i].ds_addr);
+   d-bge_len = segs[i].ds_len;
+   if (d-bge_addr.bge_addr_lo + segs[i].ds_len + mss 
+   d-bge_addr.bge_addr_lo)
+   break;
+   d-bge_flags = csum_flags;
+   d-bge_vlan_tag = vlan_tag;
+   d-bge_mss = mss;
+   if (i == nsegs - 1)
+   break;
+   BGE_INC(idx, BGE_TX_RING_CNT);
+   }
+   if (i != nsegs - 1) {
+   bus_dmamap_sync(sc-bge_cdata.bge_tx_mtag, map,
+   BUS_DMASYNC_POSTWRITE);
+   bus_dmamap_unload(sc-bge_cdata.bge_tx_mtag, map);
+   m_freem(*m_head);
+   *m_head = NULL;
+   return (EIO);
+   }
+   } else {
+   for (i = 0; ; i++) {
+   d = sc-bge_ldata.bge_tx_ring[idx];
+   d-bge_addr.bge_addr_lo = BGE_ADDR_LO(segs[i].ds_addr);
+   d-bge_addr.bge_addr_hi = BGE_ADDR_HI(segs[i].ds_addr);
+   d-bge_len = segs[i].ds_len;
+   d-bge_flags = csum_flags;
+   d-bge_vlan_tag = vlan_tag;
+   d-bge_mss = mss;
+   if (i == nsegs - 1)
+   break;
+   BGE_INC(idx, BGE_TX_RING_CNT);
+   }
}
 
/* Mark the last segment as end of packet... */
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r253480 - head/sys/dev/bge

2013-07-20 Thread Pyun YongHyeon
Author: yongari
Date: Sat Jul 20 07:09:50 2013
New Revision: 253480
URL: http://svnweb.freebsd.org/changeset/base/253480

Log:
  Setup the PCIE Fast Training Sequence (FTS) value to prevent
  transmit hangs for 57766 and non Ax versions of 57765.
  While here, correct definition of BGE_CHIPREV_57765_AX.

Modified:
  head/sys/dev/bge/if_bge.c
  head/sys/dev/bge/if_bgereg.h

Modified: head/sys/dev/bge/if_bge.c
==
--- head/sys/dev/bge/if_bge.c   Sat Jul 20 03:55:56 2013(r253479)
+++ head/sys/dev/bge/if_bge.c   Sat Jul 20 07:09:50 2013(r253480)
@@ -1796,6 +1796,20 @@ bge_chipinit(struct bge_softc *sc)
pci_write_config(sc-bge_dev, BGE_PCI_MSI_DATA + 2, val, 2);
}
 
+   if (sc-bge_asicrev == BGE_ASICREV_BCM57765 ||
+   sc-bge_asicrev == BGE_ASICREV_BCM57766) {
+   /*
+* For the 57766 and non Ax versions of 57765, bootcode
+* needs to setup the PCIE Fast Training Sequence (FTS)
+* value to prevent transmit hangs.
+*/
+   if (sc-bge_chiprev != BGE_CHIPREV_57765_AX) {
+   CSR_WRITE_4(sc, BGE_CPMU_PADRNG_CTL,
+   CSR_READ_4(sc, BGE_CPMU_PADRNG_CTL) |
+   BGE_CPMU_PADRNG_CTL_RDIV2);
+   }
+   }
+
/*
 * Set up the PCI DMA control register.
 */

Modified: head/sys/dev/bge/if_bgereg.h
==
--- head/sys/dev/bge/if_bgereg.hSat Jul 20 03:55:56 2013
(r253479)
+++ head/sys/dev/bge/if_bgereg.hSat Jul 20 07:09:50 2013
(r253480)
@@ -378,6 +378,7 @@
 #defineBGE_CHIPREV_5717_AX 0x57170
 #defineBGE_CHIPREV_5717_BX 0x57171
 #defineBGE_CHIPREV_5761_AX 0x57611
+#defineBGE_CHIPREV_57765_AX0x577850
 #defineBGE_CHIPREV_5784_AX 0x57841
 
 /* PCI DMA Read/Write Control register */
@@ -1289,6 +1290,7 @@
 #defineBGE_CPMU_MUTEX_REQ  0x365C
 #defineBGE_CPMU_MUTEX_GNT  0x3660
 #defineBGE_CPMU_PHY_STRAP  0x3664
+#defineBGE_CPMU_PADRNG_CTL 0x3668
 
 /* Central Power Management Unit (CPMU) register */
 #defineBGE_CPMU_CTRL_LINK_IDLE_MODE0x0200
@@ -1328,6 +1330,9 @@
 /* CPMU GPHY Strap register */
 #defineBGE_CPMU_PHY_STRAP_IS_SERDES0x0020
 
+/* CPMU Padring Control register */
+#defineBGE_CPMU_PADRNG_CTL_RDIV2   0x0004
+
 /*
  * Mbuf Cluster Free registers (has nothing to do with BSD mbufs)
  */
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r253481 - head/sys/dev/mii

2013-07-20 Thread Pyun YongHyeon
Author: yongari
Date: Sat Jul 20 07:24:01 2013
New Revision: 253481
URL: http://svnweb.freebsd.org/changeset/base/253481

Log:
  Recognize BCM5725C PHY.

Modified:
  head/sys/dev/mii/brgphy.c
  head/sys/dev/mii/miidevs

Modified: head/sys/dev/mii/brgphy.c
==
--- head/sys/dev/mii/brgphy.c   Sat Jul 20 07:09:50 2013(r253480)
+++ head/sys/dev/mii/brgphy.c   Sat Jul 20 07:24:01 2013(r253481)
@@ -147,6 +147,7 @@ static const struct mii_phydesc brgphys[
MII_PHY_DESC(BROADCOM3, BCM5720C),
MII_PHY_DESC(BROADCOM3, BCM57765),
MII_PHY_DESC(BROADCOM3, BCM57780),
+   MII_PHY_DESC(BROADCOM4, BCM5725C),
MII_PHY_DESC(xxBROADCOM_ALT1, BCM5906),
MII_PHY_END
 };
@@ -932,6 +933,8 @@ brgphy_reset(struct mii_softc *sc)
return;
}
break;
+   case MII_OUI_BROADCOM4:
+   return;
}
 
ifp = sc-mii_pdata-mii_ifp;

Modified: head/sys/dev/mii/miidevs
==
--- head/sys/dev/mii/miidevsSat Jul 20 07:09:50 2013(r253480)
+++ head/sys/dev/mii/miidevsSat Jul 20 07:24:01 2013(r253481)
@@ -52,6 +52,7 @@ oui AMD   0x1a
Advanced Micro Devic
 oui BROADCOM   0x001018Broadcom Corporation
 oui BROADCOM2  0x000af7Broadcom Corporation
 oui BROADCOM3  0x001be9Broadcom Corporation
+oui BROADCOM4  0x18c086Broadcom Corporation
 oui CICADA 0x0003f1Cicada Semiconductor
 oui DAVICOM0x00606eDavicom Semiconductor
 oui ENABLESEMI 0x0010ddEnable Semiconductor
@@ -186,6 +187,7 @@ model BROADCOM3 BCM5717C0x0020 BCM5717C
 model BROADCOM3 BCM5719C   0x0022 BCM5719C 1000BASE-T media interface
 model BROADCOM3 BCM57765   0x0024 BCM57765 1000BASE-T media interface
 model BROADCOM3 BCM5720C   0x0036 BCM5720C 1000BASE-T media interface
+model BROADCOM4 BCM5725C   0x0038 BCM5725C 1000BASE-T media interface
 model xxBROADCOM_ALT1 BCM5906  0x0004 BCM5906 10/100baseTX media interface
 
 /* Cicada Semiconductor PHYs (now owned by Vitesse?) */
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r253483 - head/sys/dev/bge

2013-07-20 Thread Pyun YongHyeon
Author: yongari
Date: Sat Jul 20 07:58:03 2013
New Revision: 253483
URL: http://svnweb.freebsd.org/changeset/base/253483

Log:
  Add support for upcoming BCM5725 (ASIC 5762) controller.  This is a
  new 1Gb server controller chip that will be going into production
  soon.
  BCM5725 combines MAC with triple-speed PHY, a Network Controller
  Sideband Interface (NC-SI) and on-chip memory buffer in a single
  device.  BCM5725 has an Application Processing Engine (APE) that is
  capable of on-chip management and offloading features.  BCM5725
  supports high-precision clock, time stamp registers for
  receive/transmit packets and programmable trigger inputs and
  watchdog timeouts. These new features are not yet supported by
  bge(4).
  Many thanks to Broadcom for continuing to support FreeBSD!
  
  Submitted by: Geans Pin geanspin@Broacom (initial version)
  Reviewed by:  Geans Pin geanspin@Broacom
  H/W donated by:   Broadcom

Modified:
  head/sys/dev/bge/if_bge.c
  head/sys/dev/bge/if_bgereg.h

Modified: head/sys/dev/bge/if_bge.c
==
--- head/sys/dev/bge/if_bge.c   Sat Jul 20 07:29:19 2013(r253482)
+++ head/sys/dev/bge/if_bge.c   Sat Jul 20 07:58:03 2013(r253483)
@@ -176,6 +176,8 @@ static const struct bge_type {
{ BCOM_VENDORID,BCOM_DEVICEID_BCM5721 },
{ BCOM_VENDORID,BCOM_DEVICEID_BCM5722 },
{ BCOM_VENDORID,BCOM_DEVICEID_BCM5723 },
+   { BCOM_VENDORID,BCOM_DEVICEID_BCM5725 },
+   { BCOM_VENDORID,BCOM_DEVICEID_BCM5727 },
{ BCOM_VENDORID,BCOM_DEVICEID_BCM5750 },
{ BCOM_VENDORID,BCOM_DEVICEID_BCM5750M },
{ BCOM_VENDORID,BCOM_DEVICEID_BCM5751 },
@@ -195,6 +197,7 @@ static const struct bge_type {
{ BCOM_VENDORID,BCOM_DEVICEID_BCM5761E },
{ BCOM_VENDORID,BCOM_DEVICEID_BCM5761S },
{ BCOM_VENDORID,BCOM_DEVICEID_BCM5761SE },
+   { BCOM_VENDORID,BCOM_DEVICEID_BCM5762 },
{ BCOM_VENDORID,BCOM_DEVICEID_BCM5764 },
{ BCOM_VENDORID,BCOM_DEVICEID_BCM5780 },
{ BCOM_VENDORID,BCOM_DEVICEID_BCM5780S },
@@ -310,6 +313,7 @@ static const struct bge_revision {
{ BGE_CHIPID_BCM5722_A0,BCM5722 A0 },
{ BGE_CHIPID_BCM5761_A0,BCM5761 A0 },
{ BGE_CHIPID_BCM5761_A1,BCM5761 A1 },
+   { BGE_CHIPID_BCM5762_A0,BCM5762 A0 },
{ BGE_CHIPID_BCM5784_A0,BCM5784 A0 },
{ BGE_CHIPID_BCM5784_A1,BCM5784 A1 },
/* 5754 and 5787 share the same ASIC ID */
@@ -354,6 +358,7 @@ static const struct bge_revision bge_maj
{ BGE_ASICREV_BCM5717,  unknown BCM5717 },
{ BGE_ASICREV_BCM5719,  unknown BCM5719 },
{ BGE_ASICREV_BCM5720,  unknown BCM5720 },
+   { BGE_ASICREV_BCM5762,  unknown BCM5762 },
 
{ 0, NULL }
 };
@@ -1885,8 +1890,9 @@ bge_chipinit(struct bge_softc *sc)
 * a status tag update and leave interrupts permanently
 * disabled.
 */
-   if (sc-bge_asicrev != BGE_ASICREV_BCM5717 
-   sc-bge_asicrev != BGE_ASICREV_BCM57765)
+   if (!BGE_IS_57765_PLUS(sc) 
+   sc-bge_asicrev != BGE_ASICREV_BCM5717 
+   sc-bge_asicrev != BGE_ASICREV_BCM5762)
dma_rw_ctl |= BGE_PCIDMARWCTL_TAGGED_STATUS_WA;
}
pci_write_config(sc-bge_dev, BGE_PCI_DMA_RW_CTL, dma_rw_ctl, 4);
@@ -1895,7 +1901,8 @@ bge_chipinit(struct bge_softc *sc)
 * Set up general mode register.
 */
mode_ctl = bge_dma_swap_options(sc);
-   if (sc-bge_asicrev == BGE_ASICREV_BCM5720) {
+   if (sc-bge_asicrev == BGE_ASICREV_BCM5720 ||
+   sc-bge_asicrev == BGE_ASICREV_BCM5762) {
/* Retain Host-2-BMC settings written by APE firmware. */
mode_ctl |= CSR_READ_4(sc, BGE_MODE_CTL) 
(BGE_MODECTL_BYTESWAP_B2HRX_DATA |
@@ -1953,7 +1960,7 @@ bge_blockinit(struct bge_softc *sc)
struct bge_rcb *rcb;
bus_size_t vrcb;
bge_hostaddr taddr;
-   uint32_t dmactl, val;
+   uint32_t dmactl, rdmareg, val;
int i, limit;
 
/*
@@ -2224,6 +2231,11 @@ bge_blockinit(struct bge_softc *sc)
if (!BGE_IS_5705_PLUS(sc))
/* 5700 to 5704 had 16 send rings. */
limit = BGE_TX_RINGS_EXTSSRAM_MAX;
+   else if (BGE_IS_57765_PLUS(sc) ||
+   sc-bge_asicrev == BGE_ASICREV_BCM5762)
+   limit = 2;
+   else if (BGE_IS_5717_PLUS(sc))
+   limit = 4;
else
limit = 1;
vrcb = BGE_MEMWIN_START + BGE_SEND_RING_RCB;
@@ -2262,6 +2274,7 @@ bge_blockinit(struct bge_softc *sc)
} else if (!BGE_IS_5705_PLUS(sc))
limit = BGE_RX_RINGS_MAX;
else if 

svn commit: r253404 - head/sys/dev/ae

2013-07-16 Thread Pyun YongHyeon
Author: yongari
Date: Wed Jul 17 01:24:23 2013
New Revision: 253404
URL: http://svnweb.freebsd.org/changeset/base/253404

Log:
   o TxD ring requires 8 bytes alignment to work so change alignment
 constraint to 8. Previously it may have triggered watchdog
 timeouts.
   o Check whether interrupt is ours or not.
   o Enable interrupts before attemping to transmit queued packets.
 This will slightly improve TX performance.
   o No need to clear IFF_DRV_OACTIVE in a loop. AE_FLAG_TXAVAIL is
 used to know whether there are enough available TxD ring space.
   o Added missing bus_dmamap_sync(9) in ae_rx_intr() and rearranged
 code to avoid unncessary register access.
   o Make sure to clear TxD, TxS, RxD rings in driver initialization.
 Otherwise some data in these rings could be interpreted as
 'updated' which in turn will advance internally maintained
 pointers and can trigger watchdog timeouts.
  
  PR:   kern/180382

Modified:
  head/sys/dev/ae/if_ae.c

Modified: head/sys/dev/ae/if_ae.c
==
--- head/sys/dev/ae/if_ae.c Wed Jul 17 00:58:23 2013(r253403)
+++ head/sys/dev/ae/if_ae.c Wed Jul 17 01:24:23 2013(r253404)
@@ -585,6 +585,9 @@ ae_init_locked(ae_softc_t *sc)
val = eaddr[0]  8 | eaddr[1];
AE_WRITE_4(sc, AE_EADDR1_REG, val);
 
+   bzero(sc-rxd_base_dma, AE_RXD_COUNT_DEFAULT * 1536 + 120);
+   bzero(sc-txd_base, AE_TXD_BUFSIZE_DEFAULT);
+   bzero(sc-txs_base, AE_TXS_COUNT_DEFAULT * 4);
/*
 * Set ring buffers base addresses.
 */
@@ -1115,7 +1118,7 @@ ae_alloc_rings(ae_softc_t *sc)
 * Create DMA tag for TxD.
 */
error = bus_dma_tag_create(sc-dma_parent_tag,
-   4, 0, BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR,
+   8, 0, BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR,
NULL, NULL, AE_TXD_BUFSIZE_DEFAULT, 1,
AE_TXD_BUFSIZE_DEFAULT, 0, NULL, NULL,
sc-dma_txd_tag);
@@ -1128,7 +1131,7 @@ ae_alloc_rings(ae_softc_t *sc)
 * Create DMA tag for TxS.
 */
error = bus_dma_tag_create(sc-dma_parent_tag,
-   4, 0, BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR,
+   8, 0, BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR,
NULL, NULL, AE_TXS_COUNT_DEFAULT * 4, 1,
AE_TXS_COUNT_DEFAULT * 4, 0, NULL, NULL,
sc-dma_txs_tag);
@@ -1761,6 +1764,10 @@ ae_int_task(void *arg, int pending)
ifp = sc-ifp;
 
val = AE_READ_4(sc, AE_ISR_REG);/* Read interrupt status. */
+   if (val == 0) {
+   AE_UNLOCK(sc);
+   return;
+   }
 
/*
 * Clear interrupts and disable them.
@@ -1783,12 +1790,16 @@ ae_int_task(void *arg, int pending)
ae_tx_intr(sc);
if ((val  AE_ISR_RX_EVENT) != 0)
ae_rx_intr(sc);
-   }
+   /*
+* Re-enable interrupts.
+*/
+   AE_WRITE_4(sc, AE_ISR_REG, 0);
 
-   /*
-* Re-enable interrupts.
-*/
-   AE_WRITE_4(sc, AE_ISR_REG, 0);
+   if ((sc-flags  AE_FLAG_TXAVAIL) != 0) {
+   if (!IFQ_DRV_IS_EMPTY(ifp-if_snd))
+   ae_start_locked(ifp);
+   }
+   }
 
AE_UNLOCK(sc);
 }
@@ -1849,10 +1860,10 @@ ae_tx_intr(ae_softc_t *sc)
ifp-if_oerrors++;
 
sc-tx_inproc--;
-
-   ifp-if_drv_flags = ~IFF_DRV_OACTIVE;
}
 
+   if ((sc-flags  AE_FLAG_TXAVAIL) != 0)
+   ifp-if_drv_flags = ~IFF_DRV_OACTIVE;
if (sc-tx_inproc  0) {
if_printf(ifp, Received stray Tx interrupt(s).\n);
sc-tx_inproc = 0;
@@ -1860,11 +1871,6 @@ ae_tx_intr(ae_softc_t *sc)
 
if (sc-tx_inproc == 0)
sc-wd_timer = 0;   /* Unarm watchdog. */
-   
-   if ((sc-flags  AE_FLAG_TXAVAIL) != 0) {
-   if (!IFQ_DRV_IS_EMPTY(ifp-if_snd))
-   ae_start_locked(ifp);
-   }
 
/*
 * Syncronize DMA buffers.
@@ -1923,7 +1929,7 @@ ae_rx_intr(ae_softc_t *sc)
ae_rxd_t *rxd;
struct ifnet *ifp;
uint16_t flags;
-   int error;
+   int count, error;
 
KASSERT(sc != NULL, ([ae, %d]: sc is NULL!, __LINE__));
 
@@ -1937,7 +1943,7 @@ ae_rx_intr(ae_softc_t *sc)
bus_dmamap_sync(sc-dma_rxd_tag, sc-dma_rxd_map,
BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE);
 
-   for (;;) {
+   for (count = 0;; count++) {
rxd = (ae_rxd_t *)(sc-rxd_base + sc-rxd_cur);
flags = le16toh(rxd-flags);
if ((flags  AE_RXD_UPDATE) == 0)
@@ -1964,10 +1970,14 @@ ae_rx_intr(ae_softc_t *sc)
}
}
 
-   /*
-* Update Rx index.
-*/
-   AE_WRITE_2(sc, AE_MB_RXD_IDX_REG, sc-rxd_cur);
+   if (count  0) {
+   

svn commit: r253406 - head/sys/dev/ae

2013-07-16 Thread Pyun YongHyeon
Author: yongari
Date: Wed Jul 17 01:34:25 2013
New Revision: 253406
URL: http://svnweb.freebsd.org/changeset/base/253406

Log:
  Avoid magic constant.
  No functional change.

Modified:
  head/sys/dev/ae/if_ae.c
  head/sys/dev/ae/if_aereg.h

Modified: head/sys/dev/ae/if_ae.c
==
--- head/sys/dev/ae/if_ae.c Wed Jul 17 01:32:29 2013(r253405)
+++ head/sys/dev/ae/if_ae.c Wed Jul 17 01:34:25 2013(r253406)
@@ -585,7 +585,7 @@ ae_init_locked(ae_softc_t *sc)
val = eaddr[0]  8 | eaddr[1];
AE_WRITE_4(sc, AE_EADDR1_REG, val);
 
-   bzero(sc-rxd_base_dma, AE_RXD_COUNT_DEFAULT * 1536 + 120);
+   bzero(sc-rxd_base_dma, AE_RXD_COUNT_DEFAULT * 1536 + AE_RXD_PADDING);
bzero(sc-txd_base, AE_TXD_BUFSIZE_DEFAULT);
bzero(sc-txs_base, AE_TXS_COUNT_DEFAULT * 4);
/*
@@ -1145,8 +1145,8 @@ ae_alloc_rings(ae_softc_t *sc)
 */
error = bus_dma_tag_create(sc-dma_parent_tag,
128, 0, BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR,
-   NULL, NULL, AE_RXD_COUNT_DEFAULT * 1536 + 120, 1,
-   AE_RXD_COUNT_DEFAULT * 1536 + 120, 0, NULL, NULL,
+   NULL, NULL, AE_RXD_COUNT_DEFAULT * 1536 + AE_RXD_PADDING, 1,
+   AE_RXD_COUNT_DEFAULT * 1536 + AE_RXD_PADDING, 0, NULL, NULL,
sc-dma_rxd_tag);
if (error != 0) {
device_printf(sc-dev, could not creare TxS DMA tag.\n);
@@ -1205,15 +1205,15 @@ ae_alloc_rings(ae_softc_t *sc)
return (error);
}
error = bus_dmamap_load(sc-dma_rxd_tag, sc-dma_rxd_map,
-   sc-rxd_base_dma, AE_RXD_COUNT_DEFAULT * 1536 + 120, ae_dmamap_cb,
-   busaddr, BUS_DMA_NOWAIT);
+   sc-rxd_base_dma, AE_RXD_COUNT_DEFAULT * 1536 + AE_RXD_PADDING,
+   ae_dmamap_cb, busaddr, BUS_DMA_NOWAIT);
if (error != 0 || busaddr == 0) {
device_printf(sc-dev,
could not load DMA map for RxD ring.\n);
return (error);
}
-   sc-dma_rxd_busaddr = busaddr + 120;
-   sc-rxd_base = (ae_rxd_t *)(sc-rxd_base_dma + 120);
+   sc-dma_rxd_busaddr = busaddr + AE_RXD_PADDING;
+   sc-rxd_base = (ae_rxd_t *)(sc-rxd_base_dma + AE_RXD_PADDING);
 
return (0);
 }

Modified: head/sys/dev/ae/if_aereg.h
==
--- head/sys/dev/ae/if_aereg.h  Wed Jul 17 01:32:29 2013(r253405)
+++ head/sys/dev/ae/if_aereg.h  Wed Jul 17 01:34:25 2013(r253406)
@@ -104,6 +104,8 @@
 #defineAE_RXD_COUNT_MIN16
 #defineAE_RXD_COUNT_MAX512
 #defineAE_RXD_COUNT_DEFAULT64
+/* Padding to align frames on a 128-byte boundary. */
+#defineAE_RXD_PADDING  120
 
 #defineAE_TXD_BUFSIZE_MIN  4096
 #defineAE_TXD_BUFSIZE_MAX  65536
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r253408 - head/sys/dev/bge

2013-07-16 Thread Pyun YongHyeon
Author: yongari
Date: Wed Jul 17 04:53:53 2013
New Revision: 253408
URL: http://svnweb.freebsd.org/changeset/base/253408

Log:
  Implement workaround for BCM5719/BCM5720 TX hang.
  The read DMA request logic operation is based on having sufficient
  available space in the transmit data buffer (TXMBUF) before a read
  DMA can be requested.  There are four read DMA channels that use
  the TXMBUF, and the logic checks if the available free space in the
  TXMBUF is large enough for all the data in the four Send Buffers
  for which buffer descriptors have been fetched.  The Enable_Request
  signal is asserted only if the free TXMBUF space is larger than the
  sum of the four DMA length registers.  The power-up default value
  of BGE_RDMA_LSO_CRPTEN_CTRL register bit 25 (bit 21 on BCM5720) is
  zero, which selects the DMA length registers to connect to the
  input of the adder block.  The DMA length registers are
  asynchronously reset following BCM5719/BCM5720 power-up, and due to
  the lack of synchronous deassertion of the length registers reset
  signal these resisters may contain uninitialized values following
  the reset deassertion.
  In the case of the failure the uninitialized DMA length register
  values added up to more than the TXMBUF size, which prevented the
  assertion of the Enable_Request signal and any subsequent read DMA
  to start.  This lockup condition is the root cause of failing to
  generate any transmit traffic.
  
  To workaround the issue, select alternate output of multiplexers
  and transmit the first four Ethernet frames. This overwrites the
  DMA length registers with valid values.
  
  Reported by:  Geans Pin geans...@broadcom.com
  Reviewed by:  Geans Pin geans...@broadcom.com

Modified:
  head/sys/dev/bge/if_bge.c
  head/sys/dev/bge/if_bgereg.h

Modified: head/sys/dev/bge/if_bge.c
==
--- head/sys/dev/bge/if_bge.c   Wed Jul 17 02:37:40 2013(r253407)
+++ head/sys/dev/bge/if_bge.c   Wed Jul 17 04:53:53 2013(r253408)
@@ -2508,6 +2508,24 @@ bge_blockinit(struct bge_softc *sc)
CSR_WRITE_4(sc, BGE_RDMA_MODE, val);
DELAY(40);
 
+   if (sc-bge_flags  BGE_FLAG_RDMA_BUG) {
+   for (i = 0; i  BGE_NUM_RDMA_CHANNELS / 2; i++) {
+   val = CSR_READ_4(sc, BGE_RDMA_LENGTH + i * 4);
+   if ((val  0x)  BGE_FRAMELEN)
+   break;
+   if (((val  16)  0x)  BGE_FRAMELEN)
+   break;
+   }
+   if (i != BGE_NUM_RDMA_CHANNELS / 2) {
+   val = CSR_READ_4(sc, BGE_RDMA_LSO_CRPTEN_CTRL);
+   if (sc-bge_asicrev == BGE_ASICREV_BCM5719)
+   val |= BGE_RDMA_TX_LENGTH_WA_5719;
+   else
+   val |= BGE_RDMA_TX_LENGTH_WA_5720;
+   CSR_WRITE_4(sc, BGE_RDMA_LSO_CRPTEN_CTRL, val);
+   }
+   }
+
/* Turn on RX data completion state machine */
CSR_WRITE_4(sc, BGE_RDC_MODE, BGE_RDCMODE_ENABLE);
 
@@ -3319,10 +3337,18 @@ bge_attach(device_t dev)
sc-bge_flags |= BGE_FLAG_5717_PLUS | BGE_FLAG_5755_PLUS |
BGE_FLAG_575X_PLUS | BGE_FLAG_5705_PLUS | BGE_FLAG_JUMBO |
BGE_FLAG_JUMBO_FRAME;
-   if (sc-bge_asicrev == BGE_ASICREV_BCM5719 
-   sc-bge_chipid == BGE_CHIPID_BCM5719_A0) {
-   /* Jumbo frame on BCM5719 A0 does not work. */
-   sc-bge_flags = ~BGE_FLAG_JUMBO;
+   if (sc-bge_asicrev == BGE_ASICREV_BCM5719 ||
+   sc-bge_asicrev == BGE_ASICREV_BCM5720) {
+   /*
+* Enable work around for DMA engine miscalculation
+* of TXMBUF available space.
+*/
+   sc-bge_flags |= BGE_FLAG_RDMA_BUG;
+   if (sc-bge_asicrev == BGE_ASICREV_BCM5719 
+   sc-bge_chipid == BGE_CHIPID_BCM5719_A0) {
+   /* Jumbo frame on BCM5719 A0 does not work. */
+   sc-bge_flags = ~BGE_FLAG_JUMBO;
+   }
}
break;
case BGE_ASICREV_BCM5755:
@@ -4740,6 +4766,7 @@ bge_stats_update_regs(struct bge_softc *
 {
struct ifnet *ifp;
struct bge_mac_stats *stats;
+   uint32_t val;
 
ifp = sc-bge_ifp;
stats = sc-bge_mac_stats;
@@ -4840,6 +4867,24 @@ bge_stats_update_regs(struct bge_softc *
ifp-if_collisions = (u_long)stats-etherStatsCollisions;
ifp-if_ierrors = (u_long)(stats-NoMoreRxBDs + stats-InputDiscards +
stats-InputErrors);
+
+   if (sc-bge_flags  BGE_FLAG_RDMA_BUG) {
+   /*
+* If controller transmitted more than 

svn commit: r253134 - head/sys/dev/hme

2013-07-10 Thread Pyun YongHyeon
Author: yongari
Date: Wed Jul 10 06:46:46 2013
New Revision: 253134
URL: http://svnweb.freebsd.org/changeset/base/253134

Log:
  Avoid controller reinitialization which could be triggered by
  dhclient(8) or alias addresses are added.
  
  Tested by:dcx dcy dcb...@hotmail.com

Modified:
  head/sys/dev/hme/if_hme.c

Modified: head/sys/dev/hme/if_hme.c
==
--- head/sys/dev/hme/if_hme.c   Wed Jul 10 04:59:10 2013(r253133)
+++ head/sys/dev/hme/if_hme.c   Wed Jul 10 06:46:46 2013(r253134)
@@ -742,6 +742,10 @@ hme_init_locked(struct hme_softc *sc)
u_int32_t n, v;
 
HME_LOCK_ASSERT(sc, MA_OWNED);
+
+   if ((ifp-if_drv_flags  IFF_DRV_RUNNING) != 0)
+   return;
+
/*
 * Initialization sequence. The numbered steps below correspond
 * to the sequence outlined in section 6.3.5.1 in the Ethernet
@@ -1324,6 +1328,7 @@ hme_eint(struct hme_softc *sc, u_int sta
/* check for fatal errors that needs reset to unfreeze DMA engine */
if ((status  HME_SEB_STAT_FATAL_ERRORS) != 0) {
HME_WHINE(sc-sc_dev, error signaled, status=%#x\n, status);
+   sc-sc_ifp-if_drv_flags = ~IFF_DRV_RUNNING;
hme_init_locked(sc);
}
 }
@@ -1370,6 +1375,7 @@ hme_watchdog(struct hme_softc *sc)
device_printf(sc-sc_dev, device timeout (no link)\n);
++ifp-if_oerrors;
 
+   ifp-if_drv_flags = ~IFF_DRV_RUNNING;
hme_init_locked(sc);
hme_start_locked(ifp);
return (EJUSTRETURN);
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r252402 - head/sys/dev/bce

2013-06-29 Thread Pyun YongHyeon
Author: yongari
Date: Sun Jun 30 05:12:18 2013
New Revision: 252402
URL: http://svnweb.freebsd.org/changeset/base/252402

Log:
  Fix triggering false watchdog timeout when controller is in PAUSE
  state.  Previously it used to check if controller has sent a
  PAUSE frame to the remote peer.
  
  Reported by:  David Imhoff via Brad Smith b...@openbsd.org
  Submitted by: davidch (initial version)
  Reviewed by:  davidch, David Imhoff dimhoff_de...@xs4all.nl

Modified:
  head/sys/dev/bce/if_bce.c
  head/sys/dev/bce/if_bcereg.h

Modified: head/sys/dev/bce/if_bce.c
==
--- head/sys/dev/bce/if_bce.c   Sun Jun 30 05:10:33 2013(r252401)
+++ head/sys/dev/bce/if_bce.c   Sun Jun 30 05:12:18 2013(r252402)
@@ -2077,10 +2077,12 @@ bce_miibus_statchg(device_t dev)
DBPRINT(sc, BCE_INFO_PHY,
%s(): Enabling RX flow control.\n, __FUNCTION__);
BCE_SETBIT(sc, BCE_EMAC_RX_MODE, BCE_EMAC_RX_MODE_FLOW_EN);
+   sc-bce_flags |= BCE_USING_RX_FLOW_CONTROL;
} else {
DBPRINT(sc, BCE_INFO_PHY,
%s(): Disabling RX flow control.\n, __FUNCTION__);
BCE_CLRBIT(sc, BCE_EMAC_RX_MODE, BCE_EMAC_RX_MODE_FLOW_EN);
+   sc-bce_flags = ~BCE_USING_RX_FLOW_CONTROL;
}
 
if ((IFM_OPTIONS(media_active)  IFM_ETH_TXPAUSE) != 0) {
@@ -7828,18 +7830,42 @@ bce_ioctl(struct ifnet *ifp, u_long comm
 static void
 bce_watchdog(struct bce_softc *sc)
 {
+   uint32_t status;
+
DBENTER(BCE_EXTREME_SEND);
 
BCE_LOCK_ASSERT(sc);
 
+   status = 0;
/* If the watchdog timer hasn't expired then just exit. */
if (sc-watchdog_timer == 0 || --sc-watchdog_timer)
goto bce_watchdog_exit;
 
+   status = REG_RD(sc, BCE_EMAC_RX_STATUS);
/* If pause frames are active then don't reset the hardware. */
-   /* ToDo: Should we reset the timer here? */
-   if (REG_RD(sc, BCE_EMAC_TX_STATUS)  BCE_EMAC_TX_STATUS_XOFFED)
-   goto bce_watchdog_exit;
+   if ((sc-bce_flags  BCE_USING_RX_FLOW_CONTROL) != 0) {
+   if ((status  BCE_EMAC_RX_STATUS_FFED) != 0) {
+   /*
+* If link partner has us in XOFF state then wait for
+* the condition to clear.
+*/
+   sc-watchdog_timer = BCE_TX_TIMEOUT;
+   goto bce_watchdog_exit;
+   } else if ((status  BCE_EMAC_RX_STATUS_FF_RECEIVED) != 0 
+   (status  BCE_EMAC_RX_STATUS_N_RECEIVED) != 0) {
+   /*
+* If we're not currently XOFF'ed but have recently
+* been XOFF'd/XON'd then assume that's delaying TX
+* this time around.
+*/
+   sc-watchdog_timer = BCE_TX_TIMEOUT;
+   goto bce_watchdog_exit;
+   }
+   /*
+* Any other condition is unexpected and the controller
+* should be reset.
+*/
+   }
 
BCE_PRINTF(%s(%d): Watchdog timeout occurred, resetting!\n,
__FILE__, __LINE__);
@@ -7863,6 +7889,7 @@ bce_watchdog(struct bce_softc *sc)
sc-bce_ifp-if_oerrors++;
 
 bce_watchdog_exit:
+   REG_WR(sc, BCE_EMAC_RX_STATUS, status);
DBEXIT(BCE_EXTREME_SEND);
 }
 

Modified: head/sys/dev/bce/if_bcereg.h
==
--- head/sys/dev/bce/if_bcereg.hSun Jun 30 05:10:33 2013
(r252401)
+++ head/sys/dev/bce/if_bcereg.hSun Jun 30 05:12:18 2013
(r252402)
@@ -6465,6 +6465,7 @@ struct bce_softc
 #define BCE_USING_MSIX_FLAG0x0100
 #define BCE_PCIE_FLAG  0x0200
 #define BCE_USING_TX_FLOW_CONTROL  0x0400
+#define BCE_USING_RX_FLOW_CONTROL  0x0800
 
/* Controller capability flags. */
u32 bce_cap_flags;
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r252404 - head/sys/dev/bge

2013-06-29 Thread Pyun YongHyeon
Author: yongari
Date: Sun Jun 30 05:56:13 2013
New Revision: 252404
URL: http://svnweb.freebsd.org/changeset/base/252404

Log:
  Fix triggering false watchdog timeout as done in bce(4) when
  controller is in PAUSE state.

Modified:
  head/sys/dev/bge/if_bge.c
  head/sys/dev/bge/if_bgereg.h

Modified: head/sys/dev/bge/if_bge.c
==
--- head/sys/dev/bge/if_bge.c   Sun Jun 30 05:25:24 2013(r252403)
+++ head/sys/dev/bge/if_bge.c   Sun Jun 30 05:56:13 2013(r252404)
@@ -5271,7 +5271,7 @@ bge_start_locked(struct ifnet *ifp)
/*
 * Set a timeout in case the chip goes out to lunch.
 */
-   sc-bge_timer = 5;
+   sc-bge_timer = BGE_TX_TIMEOUT;
}
 }
 
@@ -5776,12 +5776,40 @@ static void
 bge_watchdog(struct bge_softc *sc)
 {
struct ifnet *ifp;
+   uint32_t status;
 
BGE_LOCK_ASSERT(sc);
 
if (sc-bge_timer == 0 || --sc-bge_timer)
return;
 
+   /* If pause frames are active then don't reset the hardware. */
+   if ((CSR_READ_4(sc, BGE_RX_MODE)  BGE_RXMODE_FLOWCTL_ENABLE) != 0) {
+   status = CSR_READ_4(sc, BGE_RX_STS);
+   if ((status  BGE_RXSTAT_REMOTE_XOFFED) != 0) {
+   /*
+* If link partner has us in XOFF state then wait for
+* the condition to clear.
+*/
+   CSR_WRITE_4(sc, BGE_RX_STS, status);
+   sc-bge_timer = BGE_TX_TIMEOUT;
+   return;
+   } else if ((status  BGE_RXSTAT_RCVD_XOFF) != 0 
+   (status  BGE_RXSTAT_RCVD_XON) != 0) {
+   /*
+* If link partner has us in XOFF state then wait for
+* the condition to clear.
+*/
+   CSR_WRITE_4(sc, BGE_RX_STS, status);
+   sc-bge_timer = BGE_TX_TIMEOUT;
+   return;
+   }
+   /*
+* Any other condition is unexpected and the controller
+* should be reset.
+*/
+   }
+
ifp = sc-bge_ifp;
 
if_printf(ifp, watchdog timeout -- resetting\n);

Modified: head/sys/dev/bge/if_bgereg.h
==
--- head/sys/dev/bge/if_bgereg.hSun Jun 30 05:25:24 2013
(r252403)
+++ head/sys/dev/bge/if_bgereg.hSun Jun 30 05:56:13 2013
(r252404)
@@ -2918,6 +2918,7 @@ struct bge_dmamap_arg {
 #defineBGE_HWREV_TIGON_II  0x02
 #defineBGE_TIMEOUT 10
 #defineBGE_TXCONS_UNSET0x  /* impossible value */
+#defineBGE_TX_TIMEOUT  5
 
 struct bge_bcom_hack {
int reg;
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r252227 - head/sys/dev/bge

2013-06-25 Thread Pyun YongHyeon
Author: yongari
Date: Wed Jun 26 01:15:40 2013
New Revision: 252227
URL: http://svnweb.freebsd.org/changeset/base/252227

Log:
  Don't blidly clear GPIOs configuration. Just use firmware configured
  one.  This change also fixes non-working traffic LED on BCM57780.
  
  Submitted by: Masanobu SAITOH msai...@netbsd.org
  Tested by:Alexander Milanov a...@amilanov.com

Modified:
  head/sys/dev/bge/if_bge.c

Modified: head/sys/dev/bge/if_bge.c
==
--- head/sys/dev/bge/if_bge.c   Wed Jun 26 00:57:38 2013(r252226)
+++ head/sys/dev/bge/if_bge.c   Wed Jun 26 01:15:40 2013(r252227)
@@ -2401,7 +2401,7 @@ bge_blockinit(struct bge_softc *sc)
DELAY(40);
 
/* Set misc. local control, enable interrupts on attentions */
-   CSR_WRITE_4(sc, BGE_MISC_LOCAL_CTL, BGE_MLC_INTR_ONATTN);
+   BGE_SETBIT(sc, BGE_MISC_LOCAL_CTL, BGE_MLC_INTR_ONATTN);
 
 #ifdef notdef
/* Assert GPIO pins for PHY reset */
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r252185 - in head/sys/dev/usb: . net

2013-06-24 Thread Pyun YongHyeon
Author: yongari
Date: Tue Jun 25 00:26:30 2013
New Revision: 252185
URL: http://svnweb.freebsd.org/changeset/base/252185

Log:
  Add Lenovo USB 2.0 Ethernet adapter.
  
  PR:   usb/179920
  MFC After:1 week

Modified:
  head/sys/dev/usb/net/if_axe.c
  head/sys/dev/usb/usbdevs

Modified: head/sys/dev/usb/net/if_axe.c
==
--- head/sys/dev/usb/net/if_axe.c   Tue Jun 25 00:10:49 2013
(r252184)
+++ head/sys/dev/usb/net/if_axe.c   Tue Jun 25 00:26:30 2013
(r252185)
@@ -163,6 +163,7 @@ static const STRUCT_USB_HOST_ID axe_devs
AXE_DEV(GOODWAY, GWUSB2E, 0),
AXE_DEV(IODATA, ETGUS2, AXE_FLAG_178),
AXE_DEV(JVC, MP_PRX1, 0),
+   AXE_DEV(LENOVO, ETHERNET, AXE_FLAG_772B),
AXE_DEV(LINKSYS2, USB200M, 0),
AXE_DEV(LINKSYS4, USB1000, AXE_FLAG_178),
AXE_DEV(LOGITEC, LAN_GTJU2A, AXE_FLAG_178),

Modified: head/sys/dev/usb/usbdevs
==
--- head/sys/dev/usb/usbdevsTue Jun 25 00:10:49 2013(r252184)
+++ head/sys/dev/usb/usbdevsTue Jun 25 00:26:30 2013(r252185)
@@ -681,6 +681,7 @@ vendor ASUS20x1761  ASUS
 vendor SWEEX2  0x177f  Sweex
 vendor METAGEEK0x1781  MetaGeek
 vendor KAMSTRUP0x17a8  Kamstrup A/S
+vendor LENOVO  0x17ef  Lenovo
 vendor WAVESENSE   0x17f4  WaveSense
 vendor VAISALA 0x1843  Vaisala
 vendor AMIT0x18c5  AMIT
@@ -2462,6 +2463,9 @@ product LARSENBRUSGAARD ALTITRACK 0x0001
 /* Leadtek products */
 product LEADTEK 9531   0x2101  9531 GPS
 
+/* Lenovo products */
+product LENOVO ETHERNET0x7203  USB 2.0 Ethernet
+
 /* Lexar products */
 product LEXAR JUMPSHOT 0x0001  jumpSHOT CompactFlash Reader
 product LEXAR CF_READER0xb002  USB CF Reader
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r252143 - head/sys/dev/usb/net

2013-06-23 Thread Pyun YongHyeon
Author: yongari
Date: Mon Jun 24 05:18:31 2013
New Revision: 252143
URL: http://svnweb.freebsd.org/changeset/base/252143

Log:
  When RX checksum offloading is active, AX88772B will prepend a
  checksum header.  The header contains a received frame length but
  the defined length for AX88772B is different with other ASIX
  controllers.  When the RX checksum is off, AX88772B controller does
  not prepend a checksum header so driver has to use normal header
  length mask.
  This change should fix RX errors when RX checksum offloading is
  off.
  
  Tested by:kevlo
  MFC After:1 week

Modified:
  head/sys/dev/usb/net/if_axe.c

Modified: head/sys/dev/usb/net/if_axe.c
==
--- head/sys/dev/usb/net/if_axe.c   Mon Jun 24 05:03:42 2013
(r252142)
+++ head/sys/dev/usb/net/if_axe.c   Mon Jun 24 05:18:31 2013
(r252143)
@@ -1351,15 +1351,14 @@ axe_init(struct usb_ether *ue)
 
if (AXE_IS_178_FAMILY(sc)) {
sc-sc_flags = ~(AXE_FLAG_STD_FRAME | AXE_FLAG_CSUM_FRAME);
-   if ((sc-sc_flags  AXE_FLAG_772B) != 0)
-   sc-sc_lenmask = AXE_CSUM_HDR_LEN_MASK;
-   else
-   sc-sc_lenmask = AXE_HDR_LEN_MASK;
if ((sc-sc_flags  AXE_FLAG_772B) != 0 
-   (ifp-if_capenable  IFCAP_RXCSUM) != 0)
+   (ifp-if_capenable  IFCAP_RXCSUM) != 0) {
+   sc-sc_lenmask = AXE_CSUM_HDR_LEN_MASK;
sc-sc_flags |= AXE_FLAG_CSUM_FRAME;
-   else
+   } else {
+   sc-sc_lenmask = AXE_HDR_LEN_MASK;
sc-sc_flags |= AXE_FLAG_STD_FRAME;
+   }
}
 
/* Configure TX/RX checksum offloading. */
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r251600 - head/sys/dev/fxp

2013-06-10 Thread Pyun YongHyeon
Author: yongari
Date: Mon Jun 10 07:31:49 2013
New Revision: 251600
URL: http://svnweb.freebsd.org/changeset/base/251600

Log:
  Avoid unnecessary controller reinitialization by checking driver
  running state.  fxp(4) requires controller reinitialization for the
  following cases.
   o RX lockup condition on i82557
   o promiscuous mode change
   o multicast filter change
   o WOL configuration
   o TSO/VLAN hardware tagging/checksum offloading configuration
   o MAC reprogramming after speed/duplex/flow-control resolution
   o Any events that result in MAC reprogramming(link UP/DOWN,
 remote link partner's restart of auto-negotiation etc)
   o Microcode loading/unloading
  Apart from above cases which come from hardware limitation, upper
  stack also blindly reinitializes controller whenever an IP address
  is assigned. After r194573, fxp(4) no longer needs to reinitialize
  the controller to program multicast filter after upping the
  interface. So keeping track of driver running state should remove
  all unnecessary controller reinitializations.
  
  This change will also address endless controller reinitialization
  triggered by dhclient(8).
  
  Tested by:hrs, Alban Hertroys haram...@gmail.com

Modified:
  head/sys/dev/fxp/if_fxp.c

Modified: head/sys/dev/fxp/if_fxp.c
==
--- head/sys/dev/fxp/if_fxp.c   Mon Jun 10 06:04:58 2013(r251599)
+++ head/sys/dev/fxp/if_fxp.c   Mon Jun 10 07:31:49 2013(r251600)
@@ -1075,7 +1075,8 @@ fxp_suspend(device_t dev)
pmstat |= PCIM_PSTAT_PME | PCIM_PSTAT_PMEENABLE;
sc-flags |= FXP_FLAG_WOL;
/* Reconfigure hardware to accept magic frames. */
-   fxp_init_body(sc, 1);
+   ifp-if_drv_flags = ~IFF_DRV_RUNNING;
+   fxp_init_body(sc, 0);
}
pci_write_config(sc-dev, pmc + PCIR_POWER_STATUS, pmstat, 2);
}
@@ -2141,8 +2142,10 @@ fxp_tick(void *xsc)
 */
if (sc-rx_idle_secs  FXP_MAX_RX_IDLE) {
sc-rx_idle_secs = 0;
-   if ((ifp-if_drv_flags  IFF_DRV_RUNNING) != 0)
+   if ((ifp-if_drv_flags  IFF_DRV_RUNNING) != 0) {
+   ifp-if_drv_flags = ~IFF_DRV_RUNNING;
fxp_init_body(sc, 1);
+   }
return;
}
/*
@@ -2240,6 +2243,7 @@ fxp_watchdog(struct fxp_softc *sc)
device_printf(sc-dev, device timeout\n);
sc-ifp-if_oerrors++;
 
+   sc-ifp-if_drv_flags = ~IFF_DRV_RUNNING;
fxp_init_body(sc, 1);
 }
 
@@ -2274,6 +2278,10 @@ fxp_init_body(struct fxp_softc *sc, int 
int i, prm;
 
FXP_LOCK_ASSERT(sc, MA_OWNED);
+
+   if ((ifp-if_drv_flags  IFF_DRV_RUNNING) != 0)
+   return;
+
/*
 * Cancel any pending I/O
 */
@@ -2813,6 +2821,7 @@ fxp_miibus_statchg(device_t dev)
 */
if (sc-revision == FXP_REV_82557)
return;
+   ifp-if_drv_flags = ~IFF_DRV_RUNNING;
fxp_init_body(sc, 0);
 }
 
@@ -2836,9 +2845,10 @@ fxp_ioctl(struct ifnet *ifp, u_long comm
if (ifp-if_flags  IFF_UP) {
if (((ifp-if_drv_flags  IFF_DRV_RUNNING) != 0) 
((ifp-if_flags ^ sc-if_flags) 
-   (IFF_PROMISC | IFF_ALLMULTI | IFF_LINK0)) != 0)
+   (IFF_PROMISC | IFF_ALLMULTI | IFF_LINK0)) != 0) {
+   ifp-if_drv_flags = ~IFF_DRV_RUNNING;
fxp_init_body(sc, 0);
-   else if ((ifp-if_drv_flags  IFF_DRV_RUNNING) == 0)
+   } else if ((ifp-if_drv_flags  IFF_DRV_RUNNING) == 0)
fxp_init_body(sc, 1);
} else {
if ((ifp-if_drv_flags  IFF_DRV_RUNNING) != 0)
@@ -2851,8 +2861,10 @@ fxp_ioctl(struct ifnet *ifp, u_long comm
case SIOCADDMULTI:
case SIOCDELMULTI:
FXP_LOCK(sc);
-   if ((ifp-if_drv_flags  IFF_DRV_RUNNING) != 0)
+   if ((ifp-if_drv_flags  IFF_DRV_RUNNING) != 0) {
+   ifp-if_drv_flags = ~IFF_DRV_RUNNING;
fxp_init_body(sc, 0);
+   }
FXP_UNLOCK(sc);
break;
 
@@ -2942,8 +2954,10 @@ fxp_ioctl(struct ifnet *ifp, u_long comm
~(IFCAP_VLAN_HWTSO | IFCAP_VLAN_HWCSUM);
reinit++;
}
-   if (reinit  0  ifp-if_flags  IFF_UP)
+   if (reinit  0  (ifp-if_drv_flags  IFF_DRV_RUNNING) != 0) {
+   ifp-if_drv_flags = ~IFF_DRV_RUNNING;
fxp_init_body(sc, 0);
+   }
FXP_UNLOCK(sc);
VLAN_CAPABILITIES(ifp);
break;

svn commit: r251481 - head/sys/dev/bge

2013-06-06 Thread Pyun YongHyeon
Author: yongari
Date: Fri Jun  7 01:01:39 2013
New Revision: 251481
URL: http://svnweb.freebsd.org/changeset/base/251481

Log:
  Do not report current link status if driver is not running.
  Reporting link status in driver has a side-effect that makes mii(4)
  check current link status.  mii(4) will call link status change
  callback when it sees link state change.  Normally this wouldn't
  have problems. However, ASF/IPMI firmware can actively access PHY
  regardless of driver's running state such that reporting link
  status for not-running interface can generate meaningless link
  UP/DOWN messages.
  
  This change also makes dhclient think driver got a valid link
  regardless of link establishment so it will bypass dhclient's
  initial link status check. I think that wouldn't be issue
  though.
  
  Tested by:Daniel Braniss da...@cs.huji.ac.il

Modified:
  head/sys/dev/bge/if_bge.c

Modified: head/sys/dev/bge/if_bge.c
==
--- head/sys/dev/bge/if_bge.c   Fri Jun  7 00:48:01 2013(r251480)
+++ head/sys/dev/bge/if_bge.c   Fri Jun  7 01:01:39 2013(r251481)
@@ -5583,6 +5583,10 @@ bge_ifmedia_sts(struct ifnet *ifp, struc
 
BGE_LOCK(sc);
 
+   if ((ifp-if_flags  IFF_UP) == 0) {
+   BGE_UNLOCK(sc);
+   return;
+   }
if (sc-bge_flags  BGE_FLAG_TBI) {
ifmr-ifm_status = IFM_AVALID;
ifmr-ifm_active = IFM_ETHER;
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r251482 - head/sys/dev/bge

2013-06-06 Thread Pyun YongHyeon
Author: yongari
Date: Fri Jun  7 01:21:09 2013
New Revision: 251482
URL: http://svnweb.freebsd.org/changeset/base/251482

Log:
  Correct setting TX random backoff register. This register is
  implemented as a 10 bits linear feedback shift register so only
  lower 10 bits are valid.
  Because this register is used to initialize random backoff interval
  register only when resolved duplex is half-duplex, it wouldn't have
  caused issues in these days.
  
  Submitted by: Masanobu SAITOH msai...@netbsd.org

Modified:
  head/sys/dev/bge/if_bge.c
  head/sys/dev/bge/if_bgereg.h

Modified: head/sys/dev/bge/if_bge.c
==
--- head/sys/dev/bge/if_bge.c   Fri Jun  7 01:01:39 2013(r251481)
+++ head/sys/dev/bge/if_bge.c   Fri Jun  7 01:21:09 2013(r251482)
@@ -2280,9 +2280,9 @@ bge_blockinit(struct bge_softc *sc)
 
/* Set random backoff seed for TX */
CSR_WRITE_4(sc, BGE_TX_RANDOM_BACKOFF,
-   IF_LLADDR(sc-bge_ifp)[0] + IF_LLADDR(sc-bge_ifp)[1] +
+   (IF_LLADDR(sc-bge_ifp)[0] + IF_LLADDR(sc-bge_ifp)[1] +
IF_LLADDR(sc-bge_ifp)[2] + IF_LLADDR(sc-bge_ifp)[3] +
-   IF_LLADDR(sc-bge_ifp)[4] + IF_LLADDR(sc-bge_ifp)[5] +
+   IF_LLADDR(sc-bge_ifp)[4] + IF_LLADDR(sc-bge_ifp)[5]) 
BGE_TX_BACKOFF_SEED_MASK);
 
/* Set inter-packet gap */

Modified: head/sys/dev/bge/if_bgereg.h
==
--- head/sys/dev/bge/if_bgereg.hFri Jun  7 01:01:39 2013
(r251481)
+++ head/sys/dev/bge/if_bgereg.hFri Jun  7 01:21:09 2013
(r251482)
@@ -797,7 +797,7 @@
 #defineBGE_LEDCTL_BLINKPERIOD_OVERRIDE 0x8000
 
 /* TX backoff seed register */
-#defineBGE_TX_BACKOFF_SEED_MASK0x3F
+#defineBGE_TX_BACKOFF_SEED_MASK0x3FF
 
 /* Autopoll status register */
 #defineBGE_AUTOPOLLSTS_ERROR   0x0001
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r248993 - head/sys/dev/bge

2013-04-01 Thread Pyun YongHyeon
Author: yongari
Date: Tue Apr  2 00:57:54 2013
New Revision: 248993
URL: http://svnweb.freebsd.org/changeset/base/248993

Log:
  Fix a typo.
  
  Reported by:  David Imhoff via brad@OpenBSD
  Tested by:hrs
  Reviewed by:  davidch

Modified:
  head/sys/dev/bge/if_bge.c

Modified: head/sys/dev/bge/if_bge.c
==
--- head/sys/dev/bge/if_bge.c   Tue Apr  2 00:11:35 2013(r248992)
+++ head/sys/dev/bge/if_bge.c   Tue Apr  2 00:57:54 2013(r248993)
@@ -680,7 +680,7 @@ bge_ape_lock_init(struct bge_softc *sc)
bit = BGE_APE_LOCK_GRANT_DRIVER0;
break;
default:
-   if (sc-bge_func_addr != 0)
+   if (sc-bge_func_addr == 0)
bit = BGE_APE_LOCK_GRANT_DRIVER0;
else
bit = (1  sc-bge_func_addr);
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r248542 - head/sys/dev/mii

2013-03-19 Thread Pyun YongHyeon
Author: yongari
Date: Wed Mar 20 05:31:34 2013
New Revision: 248542
URL: http://svnweb.freebsd.org/changeset/base/248542

Log:
  For RTL8211B or later PHYs, enable crossover detection and
  auto-correction. This change makes re(4) establish a link with
  a system using non-crossover UTP cable.
  
  Tested by:Michael BlackHeart  amdmiek  gmail dot com 

Modified:
  head/sys/dev/mii/rgephy.c
  head/sys/dev/mii/rgephyreg.h

Modified: head/sys/dev/mii/rgephy.c
==
--- head/sys/dev/mii/rgephy.c   Wed Mar 20 05:23:23 2013(r248541)
+++ head/sys/dev/mii/rgephy.c   Wed Mar 20 05:31:34 2013(r248542)
@@ -488,7 +488,7 @@ rgephy_load_dspcode(struct mii_softc *sc
 static void
 rgephy_reset(struct mii_softc *sc)
 {
-   uint16_t ssr;
+   uint16_t pcr, ssr;
 
if ((sc-mii_flags  MIIF_PHYPRIV0) == 0  sc-mii_mpd_rev == 3) {
/* RTL8211C(L) */
@@ -499,6 +499,15 @@ rgephy_reset(struct mii_softc *sc)
}
}
 
+   if (sc-mii_mpd_rev = 2) {
+   pcr = PHY_READ(sc, RGEPHY_MII_PCR);
+   if ((pcr  RGEPHY_PCR_MDIX_AUTO) == 0) {
+   pcr = ~RGEPHY_PCR_MDI_MASK;
+   pcr |= RGEPHY_PCR_MDIX_AUTO;
+   PHY_WRITE(sc, RGEPHY_MII_PCR, pcr);
+   }
+   }
+
mii_phy_reset(sc);
DELAY(1000);
rgephy_load_dspcode(sc);

Modified: head/sys/dev/mii/rgephyreg.h
==
--- head/sys/dev/mii/rgephyreg.hWed Mar 20 05:23:23 2013
(r248541)
+++ head/sys/dev/mii/rgephyreg.hWed Mar 20 05:31:34 2013
(r248542)
@@ -138,6 +138,17 @@
 #define RGEPHY_EXTSTS_T_HD_CAP 0x1000  /* 1000base-T HD capable */
 
 /* RTL8211B(L)/RTL8211C(L) */
+#define RGEPHY_MII_PCR 0x10/* PHY Specific control register */
+#define RGEPHY_PCR_ASSERT_CRS  0x0800
+#define RGEPHY_PCR_FORCE_LINK  0x0400
+#define RGEPHY_PCR_MDI_MASK0x0060
+#define RGEPHY_PCR_MDIX_AUTO   0x0040
+#define RGEPHY_PCR_MDIX_MANUAL 0x0020
+#define RGEPHY_PCR_MDI_MANUAL  0x
+#define RGEPHY_PCR_CLK125_DIS  0x0010
+#define RGEPHY_PCR_JABBER_DIS  0x0001
+
+/* RTL8211B(L)/RTL8211C(L) */
 #define RGEPHY_MII_SSR 0x11/* PHY Specific status register */
 #defineRGEPHY_SSR_S10000x8000  /* 1000Mbps */
 #defineRGEPHY_SSR_S100 0x4000  /* 100Mbps */
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r248456 - head/sys/dev/sis

2013-03-17 Thread Pyun YongHyeon
Author: yongari
Date: Mon Mar 18 04:46:17 2013
New Revision: 248456
URL: http://svnweb.freebsd.org/changeset/base/248456

Log:
  r119712 introduced SIS_TYPE_83816 but it was not actually set in
  driver such that checking against the type was always false.
  To detect NS DP83816, driver should have checked silicon revision
  register for NS controllers. While here, remove SIS_TYPE_83816 to
  not make the similar mistake again.
  
  Reported by:  Brad Smith ( brad@openbsd )

Modified:
  head/sys/dev/sis/if_sis.c
  head/sys/dev/sis/if_sisreg.h

Modified: head/sys/dev/sis/if_sis.c
==
--- head/sys/dev/sis/if_sis.c   Mon Mar 18 02:29:57 2013(r248455)
+++ head/sys/dev/sis/if_sis.c   Mon Mar 18 04:46:17 2013(r248456)
@@ -625,7 +625,7 @@ sis_miibus_statchg(device_t dev)
SIS_CLRBIT(sc, SIS_RX_CFG, SIS_RXCFG_RX_TXPKTS);
}
 
-   if (sc-sis_type == SIS_TYPE_83816) {
+   if (sc-sis_type == SIS_TYPE_83815  sc-sis_srr = NS_SRR_16A) {
/*
 * MPII03.D: Half Duplex Excessive Collisions.
 * Also page 49 in 83816 manual
@@ -1989,7 +1989,7 @@ sis_initl(struct sis_softc *sc)
return;
}
 
-   if (sc-sis_type == SIS_TYPE_83815 || sc-sis_type == SIS_TYPE_83816) {
+   if (sc-sis_type == SIS_TYPE_83815) {
if (sc-sis_manual_pad != 0)
sc-sis_flags |= SIS_FLAG_MANUAL_PAD;
else

Modified: head/sys/dev/sis/if_sisreg.h
==
--- head/sys/dev/sis/if_sisreg.hMon Mar 18 02:29:57 2013
(r248455)
+++ head/sys/dev/sis/if_sisreg.hMon Mar 18 04:46:17 2013
(r248456)
@@ -439,7 +439,6 @@ struct sis_type {
 #define SIS_TYPE_900   1
 #define SIS_TYPE_7016  2
 #define SIS_TYPE_83815 3
-#define SIS_TYPE_83816 4
 
 struct sis_txdesc {
struct mbuf *tx_m;
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r248226 - head/sys/dev/bge

2013-03-12 Thread Pyun YongHyeon
Author: yongari
Date: Wed Mar 13 01:40:01 2013
New Revision: 248226
URL: http://svnweb.freebsd.org/changeset/base/248226

Log:
  r241438 broke IPMI access on Sun Fire X2200 M2(BCM5715).
  Fix the IPMI regression by sending BGE_FW_DRV_STATE_UNLOAD to
  ASF/IPMI firmware in driver attach phase.  Sending heartheat to
  ASF/IPMI is enabled only after upping interface so
  setting driver state to BGE_FW_DRV_STATE_START in attach phase
  broke IPMI access.
  While I'm here, add NVRAM arbitration lock before performing
  controller reset. ASF/IPMI firmware may be able to access the NVRAM
  while controller reset is in progress.  Without the arbitration
  lock before resetting the controller, ASF/IPMI may not initialize
  properly.
  
  Special thanks to Miroslav Lachman who provided full remote
  debugging environments.

Modified:
  head/sys/dev/bge/if_bge.c

Modified: head/sys/dev/bge/if_bge.c
==
--- head/sys/dev/bge/if_bge.c   Wed Mar 13 01:38:32 2013(r248225)
+++ head/sys/dev/bge/if_bge.c   Wed Mar 13 01:40:01 2013(r248226)
@@ -3594,15 +3594,15 @@ bge_attach(device_t dev)
}
 
bge_stop_fw(sc);
-   bge_sig_pre_reset(sc, BGE_RESET_START);
+   bge_sig_pre_reset(sc, BGE_RESET_SHUTDOWN);
if (bge_reset(sc)) {
device_printf(sc-bge_dev, chip reset failed\n);
error = ENXIO;
goto fail;
}
 
-   bge_sig_legacy(sc, BGE_RESET_START);
-   bge_sig_post_reset(sc, BGE_RESET_START);
+   bge_sig_legacy(sc, BGE_RESET_SHUTDOWN);
+   bge_sig_post_reset(sc, BGE_RESET_SHUTDOWN);
 
if (bge_chipinit(sc)) {
device_printf(sc-bge_dev, chip initialization failed\n);
@@ -3960,6 +3960,20 @@ bge_reset(struct bge_softc *sc)
} else
write_op = bge_writereg_ind;
 
+   if (sc-bge_asicrev != BGE_ASICREV_BCM5700 
+   sc-bge_asicrev != BGE_ASICREV_BCM5701) {
+   CSR_WRITE_4(sc, BGE_NVRAM_SWARB, BGE_NVRAMSWARB_SET1);
+   for (i = 0; i  8000; i++) {
+   if (CSR_READ_4(sc, BGE_NVRAM_SWARB) 
+   BGE_NVRAMSWARB_GNT1)
+   break;
+   DELAY(20);
+   }
+   if (i == 8000) {
+   if (bootverbose)
+   device_printf(dev, NVRAM lock timedout!\n);
+   }
+   }
/* Take APE lock when performing reset. */
bge_ape_lock(sc, BGE_APE_LOCK_GRC);
 
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r248227 - head/sys/dev/re

2013-03-12 Thread Pyun YongHyeon
Author: yongari
Date: Wed Mar 13 02:11:45 2013
New Revision: 248227
URL: http://svnweb.freebsd.org/changeset/base/248227

Log:
  Disable TX IP header checksum offloading on RL_HWREV_8168CP. The
  controller generates wrong checksummed frame if the IP packet has
  IP options.
  
  Submitted by: Alexander Bluhm via brad@openbsd

Modified:
  head/sys/dev/re/if_re.c

Modified: head/sys/dev/re/if_re.c
==
--- head/sys/dev/re/if_re.c Wed Mar 13 01:40:01 2013(r248226)
+++ head/sys/dev/re/if_re.c Wed Mar 13 02:11:45 2013(r248227)
@@ -1587,7 +1587,8 @@ re_attach(device_t dev)
 * packet has IP options so disable TX IP checksum offloading.
 */
if (sc-rl_hwrev-rl_rev == RL_HWREV_8168C ||
-   sc-rl_hwrev-rl_rev == RL_HWREV_8168C_SPIN2)
+   sc-rl_hwrev-rl_rev == RL_HWREV_8168C_SPIN2 ||
+   sc-rl_hwrev-rl_rev == RL_HWREV_8168CP)
ifp-if_hwassist = CSUM_TCP | CSUM_UDP;
else
ifp-if_hwassist = CSUM_IP | CSUM_TCP | CSUM_UDP;
@@ -3419,7 +3420,8 @@ re_ioctl(struct ifnet *ifp, u_long comma
if ((ifp-if_capenable  IFCAP_TXCSUM) != 0) {
rev = sc-rl_hwrev-rl_rev;
if (rev == RL_HWREV_8168C ||
-   rev == RL_HWREV_8168C_SPIN2)
+   rev == RL_HWREV_8168C_SPIN2 ||
+   rev == RL_HWREV_8168CP)
ifp-if_hwassist |= CSUM_TCP | CSUM_UDP;
else
ifp-if_hwassist |= RE_CSUM_FEATURES;
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r247382 - head/sys/dev/msk

2013-02-26 Thread Pyun YongHyeon
Author: yongari
Date: Wed Feb 27 05:03:35 2013
New Revision: 247382
URL: http://svnweb.freebsd.org/changeset/base/247382

Log:
  RX checksum offloading on old Yukon controllers seem to cause more
  problems.  Disable RX checksum offloading on controllers that don't
  use new descriptor format but give chance to enable it with
  ifconfig(8).

Modified:
  head/sys/dev/msk/if_msk.c

Modified: head/sys/dev/msk/if_msk.c
==
--- head/sys/dev/msk/if_msk.c   Wed Feb 27 05:02:40 2013(r247381)
+++ head/sys/dev/msk/if_msk.c   Wed Feb 27 05:03:35 2013(r247382)
@@ -1695,6 +1695,12 @@ msk_attach(device_t dev)
ifp-if_capabilities |= IFCAP_VLAN_HWCSUM;
}
ifp-if_capenable = ifp-if_capabilities;
+   /*
+* Disable RX checksum offloading on controllers that don't use
+* new descriptor format but give chance to enable it.
+*/
+   if ((sc_if-msk_flags  MSK_FLAG_DESCV2) == 0)
+   ifp-if_capenable = ~IFCAP_RXCSUM;
 
/*
 * Tell the upper layer(s) we support long frames.
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r246341 - head/sys/dev/age

2013-02-04 Thread Pyun YongHyeon
Author: yongari
Date: Tue Feb  5 00:37:45 2013
New Revision: 246341
URL: http://svnweb.freebsd.org/changeset/base/246341

Log:
  Rework jumbo frame handling.  QAC confirmed that the controller
  requires 8 bytes alignment on RX buffer.  Given that non-jumbo
  frame works on any alignments I guess this DMA limitation for RX
  buffer could be jumbo frame specific one.  Also I'm not sure
  whether this DMA limitation is related with 64bit DMA.  Previously
  age(4) disabled 64bit DMA addressing due to silent data corruption.
  So we may need more testing on re-enabling 64bit DMA in future.
  
  While I'm here, change mbuf chaining algorithm to use fixed sized
  buffer and force software checksum if controller reports length
  error. According to QAC, RFD is not updated at all for jumbo frame
  so it works just like alc(4) controllers.  This change also added
  alignment fixup for strict alignment architectures.  Because I'm
  not aware of any non-x86 machines that use age(4) controllers it's
  just for completeness at this moment.
  
  Wit this change, jumbo frame should work with age(4).
  
  Tested by:Christian Gusenbauer  c47g  gmx dot at 
  MFC after:1 week

Modified:
  head/sys/dev/age/if_age.c
  head/sys/dev/age/if_agevar.h

Modified: head/sys/dev/age/if_age.c
==
--- head/sys/dev/age/if_age.c   Tue Feb  5 00:33:32 2013(r246340)
+++ head/sys/dev/age/if_age.c   Tue Feb  5 00:37:45 2013(r246341)
@@ -142,6 +142,9 @@ static int age_init_rx_ring(struct age_s
 static void age_init_rr_ring(struct age_softc *);
 static void age_init_cmb_block(struct age_softc *);
 static void age_init_smb_block(struct age_softc *);
+#ifndef __NO_STRICT_ALIGNMENT
+static struct mbuf *age_fixup_rx(struct ifnet *, struct mbuf *);
+#endif
 static int age_newbuf(struct age_softc *, struct age_rxdesc *);
 static void age_rxvlan(struct age_softc *);
 static void age_rxfilter(struct age_softc *);
@@ -1133,7 +1136,7 @@ again:
/* Create tag for Rx buffers. */
error = bus_dma_tag_create(
sc-age_cdata.age_buffer_tag, /* parent */
-   1, 0,   /* alignment, boundary */
+   AGE_RX_BUF_ALIGN, 0,/* alignment, boundary */
BUS_SPACE_MAXADDR,  /* lowaddr */
BUS_SPACE_MAXADDR,  /* highaddr */
NULL, NULL, /* filter, filterarg */
@@ -2268,16 +2271,53 @@ age_txintr(struct age_softc *sc, int tpd
}
 }
 
+#ifndef __NO_STRICT_ALIGNMENT
+static struct mbuf *
+age_fixup_rx(struct ifnet *ifp, struct mbuf *m)
+{
+   struct mbuf *n;
+int i;
+uint16_t *src, *dst;
+
+   src = mtod(m, uint16_t *);
+   dst = src - 3;
+
+   if (m-m_next == NULL) {
+   for (i = 0; i  (m-m_len / sizeof(uint16_t) + 1); i++)
+   *dst++ = *src++;
+   m-m_data -= 6;
+   return (m);
+   }
+   /*
+* Append a new mbuf to received mbuf chain and copy ethernet
+* header from the mbuf chain. This can save lots of CPU
+* cycles for jumbo frame.
+*/
+   MGETHDR(n, M_NOWAIT, MT_DATA);
+   if (n == NULL) {
+   ifp-if_iqdrops++;
+   m_freem(m);
+   return (NULL);
+   }
+   bcopy(m-m_data, n-m_data, ETHER_HDR_LEN);
+   m-m_data += ETHER_HDR_LEN;
+   m-m_len -= ETHER_HDR_LEN;
+   n-m_len = ETHER_HDR_LEN;
+   M_MOVE_PKTHDR(n, m);
+   n-m_next = m;
+   return (n);
+}
+#endif
+
 /* Receive a frame. */
 static void
 age_rxeof(struct age_softc *sc, struct rx_rdesc *rxrd)
 {
struct age_rxdesc *rxd;
-   struct rx_desc *desc;
struct ifnet *ifp;
struct mbuf *mp, *m;
uint32_t status, index, vtag;
-   int count, nsegs, pktlen;
+   int count, nsegs;
int rx_cons;
 
AGE_LOCK_ASSERT(sc);
@@ -2289,9 +2329,7 @@ age_rxeof(struct age_softc *sc, struct r
nsegs = AGE_RX_NSEGS(index);
 
sc-age_cdata.age_rxlen = AGE_RX_BYTES(le32toh(rxrd-len));
-   if ((status  AGE_RRD_ERROR) != 0 
-   (status  (AGE_RRD_CRC | AGE_RRD_CODE | AGE_RRD_DRIBBLE |
-   AGE_RRD_RUNT | AGE_RRD_OFLOW | AGE_RRD_TRUNC)) != 0) {
+   if ((status  (AGE_RRD_ERROR | AGE_RRD_LENGTH_NOK)) != 0) {
/*
 * We want to pass the following frames to upper
 * layer regardless of error status of Rx return
@@ -2301,33 +2339,31 @@ age_rxeof(struct age_softc *sc, struct r
 *  o frame length and protocol specific length
 * does not match.
 */
-   sc-age_cdata.age_rx_cons += nsegs;
-   sc-age_cdata.age_rx_cons %= AGE_RX_RING_CNT;
-   return;
+   status |= AGE_RRD_IPCSUM_NOK | AGE_RRD_TCP_UDPCSUM_NOK;
+   if ((status  (AGE_RRD_CRC | AGE_RRD_CODE | AGE_RRD_DRIBBLE |
+   

svn commit: r245867 - head/sys/dev/bge

2013-01-23 Thread Pyun YongHyeon
Author: yongari
Date: Thu Jan 24 02:25:43 2013
New Revision: 245867
URL: http://svnweb.freebsd.org/changeset/base/245867

Log:
  For 57765 class controllers, set low watermark max receive frames to 1.

Modified:
  head/sys/dev/bge/if_bge.c

Modified: head/sys/dev/bge/if_bge.c
==
--- head/sys/dev/bge/if_bge.c   Thu Jan 24 02:20:25 2013(r245866)
+++ head/sys/dev/bge/if_bge.c   Thu Jan 24 02:25:43 2013(r245867)
@@ -5427,7 +5427,7 @@ bge_init_locked(struct bge_softc *sc)
 * this number of frames, it will drop subsequent incoming
 * frames until the MBUF High Watermark is reached.
 */
-   if (sc-bge_asicrev == BGE_ASICREV_BCM57765)
+   if (BGE_IS_57765_PLUS(sc))
CSR_WRITE_4(sc, BGE_MAX_RX_FRAME_LOWAT, 1);
else
CSR_WRITE_4(sc, BGE_MAX_RX_FRAME_LOWAT, 2);
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r245870 - head/sys/dev/bge

2013-01-23 Thread Pyun YongHyeon
Author: yongari
Date: Thu Jan 24 04:54:53 2013
New Revision: 245870
URL: http://svnweb.freebsd.org/changeset/base/245870

Log:
  bge_attach() can fail before attaching mii(4). So make sure to check
  bge_miibus before detaching mii(4).

Modified:
  head/sys/dev/bge/if_bge.c

Modified: head/sys/dev/bge/if_bge.c
==
--- head/sys/dev/bge/if_bge.c   Thu Jan 24 03:33:15 2013(r245869)
+++ head/sys/dev/bge/if_bge.c   Thu Jan 24 04:54:53 2013(r245870)
@@ -3899,9 +3899,9 @@ bge_detach(device_t dev)
if (sc-bge_tq)
taskqueue_drain(sc-bge_tq, sc-bge_intr_task);
 
-   if (sc-bge_flags  BGE_FLAG_TBI) {
+   if (sc-bge_flags  BGE_FLAG_TBI)
ifmedia_removeall(sc-bge_ifmedia);
-   } else {
+   else if (sc-bge_miibus != NULL) {
bus_generic_detach(dev);
device_delete_child(dev, sc-bge_miibus);
}
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r245485 - head/sys/pci

2013-01-15 Thread Pyun YongHyeon
Author: yongari
Date: Wed Jan 16 01:30:46 2013
New Revision: 245485
URL: http://svnweb.freebsd.org/changeset/base/245485

Log:
  Add D-Link DFE-520TX rev C1.
  
  Tested by:Ruslan Makhmatkhanov  cvs-src  yandex dot ru 
  MFC After:1 week

Modified:
  head/sys/pci/if_rl.c
  head/sys/pci/if_rlreg.h

Modified: head/sys/pci/if_rl.c
==
--- head/sys/pci/if_rl.cWed Jan 16 00:54:51 2013(r245484)
+++ head/sys/pci/if_rl.cWed Jan 16 01:30:46 2013(r245485)
@@ -148,6 +148,8 @@ static const struct rl_type rl_devs[] = 
Delta Electronics 8139 10/100BaseTX },
{ ADDTRON_VENDORID, ADDTRON_DEVICEID_8139, RL_8139,
Addtron Technology 8139 10/100BaseTX },
+   { DLINK_VENDORID, DLINK_DEVICEID_520TX_REVC1, RL_8139,
+   D-Link DFE-520TX (rev. C1) 10/100BaseTX },
{ DLINK_VENDORID, DLINK_DEVICEID_530TXPLUS, RL_8139,
D-Link DFE-530TX+ 10/100BaseTX },
{ DLINK_VENDORID, DLINK_DEVICEID_690TXD, RL_8139,

Modified: head/sys/pci/if_rlreg.h
==
--- head/sys/pci/if_rlreg.h Wed Jan 16 00:54:51 2013(r245484)
+++ head/sys/pci/if_rlreg.h Wed Jan 16 01:30:46 2013(r245485)
@@ -1048,6 +1048,11 @@ struct rl_softc {
 #defineDLINK_DEVICEID_530TXPLUS0x1300
 
 /*
+ * D-Link DFE-520TX rev. C1 device ID
+ */
+#defineDLINK_DEVICEID_520TX_REVC1  0x4200
+
+/*
  * D-Link DFE-5280T device ID
  */
 #defineDLINK_DEVICEID_528T 0x4300
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r245487 - head/share/man/man4

2013-01-15 Thread Pyun YongHyeon
Author: yongari
Date: Wed Jan 16 02:22:56 2013
New Revision: 245487
URL: http://svnweb.freebsd.org/changeset/base/245487

Log:
  Add D-Link DFE-520TX (rev. C1) to HARDWARE section.
  
  MFC After:1 week

Modified:
  head/share/man/man4/rl.4

Modified: head/share/man/man4/rl.4
==
--- head/share/man/man4/rl.4Wed Jan 16 01:49:07 2013(r245486)
+++ head/share/man/man4/rl.4Wed Jan 16 02:22:56 2013(r245487)
@@ -30,7 +30,7 @@
 .\
 .\ $FreeBSD$
 .\
-.Dd August 22, 2010
+.Dd January 16, 2013
 .Dt RL 4
 .Os
 .Sh NAME
@@ -155,6 +155,8 @@ Corega FEther CB-TXD
 .It
 Corega FEtherII CB-TXD
 .It
+D-Link DFE-520TX (rev. C1)
+.It
 D-Link DFE-528TX
 .It
 D-Link DFE-530TX+
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r244482 - head/sys/dev/mii

2012-12-19 Thread Pyun YongHyeon
Author: yongari
Date: Thu Dec 20 05:02:12 2012
New Revision: 244482
URL: http://svnweb.freebsd.org/changeset/base/244482

Log:
  Recognize 5720S PHY and treat it as 5708S PHY.
  Unfortunately 5720S uses 5709S PHY id so add a hack to detect 5720S
  PHY by checking parent device name.  5720S PHY does not support 2500SX.
  
  Tested by:Geans Pin  geanspin  broadcom dot com 

Modified:
  head/sys/dev/mii/brgphy.c
  head/sys/dev/mii/miidevs

Modified: head/sys/dev/mii/brgphy.c
==
--- head/sys/dev/mii/brgphy.c   Thu Dec 20 04:47:31 2012(r244481)
+++ head/sys/dev/mii/brgphy.c   Thu Dec 20 05:02:12 2012(r244482)
@@ -204,6 +204,13 @@ brgphy_attach(device_t dev)
brgphy_funcs, 0);
 
bsc-serdes_flags = 0;
+   ifp = sc-mii_pdata-mii_ifp;
+
+   /* Find the MAC driver associated with this PHY. */
+   if (strcmp(ifp-if_dname, bge) == 0)
+   bge_sc = ifp-if_softc;
+   else if (strcmp(ifp-if_dname, bce) == 0)
+   bce_sc = ifp-if_softc;
 
/* Handle any special cases based on the PHY ID */
switch (sc-mii_mpd_oui) {
@@ -235,22 +242,21 @@ brgphy_attach(device_t dev)
sc-mii_flags |= MIIF_HAVEFIBER;
break;
case MII_MODEL_BROADCOM2_BCM5709S:
-   bsc-serdes_flags |= BRGPHY_5709S;
+   /*
+* XXX
+* 5720S and 5709S shares the same PHY id.
+* Assume 5720S PHY if parent device is bge(4).
+*/
+   if (bge_sc != NULL)
+   bsc-serdes_flags |= BRGPHY_5708S;
+   else
+   bsc-serdes_flags |= BRGPHY_5709S;
sc-mii_flags |= MIIF_HAVEFIBER;
break;
}
break;
}
 
-   ifp = sc-mii_pdata-mii_ifp;
-
-   /* Find the MAC driver associated with this PHY. */
-   if (strcmp(ifp-if_dname, bge) == 0)  {
-   bge_sc = ifp-if_softc;
-   } else if (strcmp(ifp-if_dname, bce) == 0) {
-   bce_sc = ifp-if_softc;
-   }
-
PHY_RESET(sc);
 
/* Read the PHY's capabilities. */

Modified: head/sys/dev/mii/miidevs
==
--- head/sys/dev/mii/miidevsThu Dec 20 04:47:31 2012(r244481)
+++ head/sys/dev/mii/miidevsThu Dec 20 05:02:12 2012(r244482)
@@ -180,7 +180,7 @@ model BROADCOM2 BCM5722 0x002d BCM5722 
 model BROADCOM2 BCM57840x003a BCM5784 10/100/1000baseT PHY
 model BROADCOM2 BCM5709C   0x003c BCM5709 10/100/1000baseT PHY
 model BROADCOM2 BCM57610x003d BCM5761 10/100/1000baseT PHY
-model BROADCOM2 BCM5709S   0x003f BCM5709S 1000/2500baseSX PHY
+model BROADCOM2 BCM5709S   0x003f BCM5709S/5720S 1000/2500baseSX PHY
 model BROADCOM3 BCM57780   0x0019 BCM57780 1000BASE-T media interface
 model BROADCOM3 BCM5717C   0x0020 BCM5717C 1000BASE-T media interface
 model BROADCOM3 BCM5719C   0x0022 BCM5719C 1000BASE-T media interface
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r244341 - head/sys/dev/ale

2012-12-16 Thread Pyun YongHyeon
Author: yongari
Date: Mon Dec 17 06:01:57 2012
New Revision: 244341
URL: http://svnweb.freebsd.org/changeset/base/244341

Log:
  Make sure to stop both TX and RX MACs in ale_stop_mac(). Previously
  it used to stop TX MAC only such that MAC reconfiguration after
  getting a link didn't work as expected.
  
  PR:   kern/173652

Modified:
  head/sys/dev/ale/if_ale.c

Modified: head/sys/dev/ale/if_ale.c
==
--- head/sys/dev/ale/if_ale.c   Mon Dec 17 05:31:42 2012(r244340)
+++ head/sys/dev/ale/if_ale.c   Mon Dec 17 06:01:57 2012(r244341)
@@ -2932,7 +2932,7 @@ ale_stop_mac(struct ale_softc *sc)
 
reg = CSR_READ_4(sc, ALE_MAC_CFG);
if ((reg  (MAC_CFG_TX_ENB | MAC_CFG_RX_ENB)) != 0) {
-   reg = ~MAC_CFG_TX_ENB | MAC_CFG_RX_ENB;
+   reg = ~(MAC_CFG_TX_ENB | MAC_CFG_RX_ENB);
CSR_WRITE_4(sc, ALE_MAC_CFG, reg);
}
 
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r243686 - head/sys/dev/bge

2012-11-29 Thread Pyun YongHyeon
Author: yongari
Date: Fri Nov 30 01:38:00 2012
New Revision: 243686
URL: http://svnweb.freebsd.org/changeset/base/243686

Log:
  Add preliminary support for BCM57766 ASIC.
  While I'm here add BCM57762 device id which is found on Apple
  Thunderbolt ethernet.
  
  Tested by:Richard Kuhns  rjk  wintek dot com 

Modified:
  head/sys/dev/bge/if_bge.c
  head/sys/dev/bge/if_bgereg.h

Modified: head/sys/dev/bge/if_bge.c
==
--- head/sys/dev/bge/if_bge.c   Fri Nov 30 00:59:37 2012(r243685)
+++ head/sys/dev/bge/if_bge.c   Fri Nov 30 01:38:00 2012(r243686)
@@ -216,7 +216,9 @@ static const struct bge_type {
{ BCOM_VENDORID,BCOM_DEVICEID_BCM5906M },
{ BCOM_VENDORID,BCOM_DEVICEID_BCM57760 },
{ BCOM_VENDORID,BCOM_DEVICEID_BCM57761 },
+   { BCOM_VENDORID,BCOM_DEVICEID_BCM57762 },
{ BCOM_VENDORID,BCOM_DEVICEID_BCM57765 },
+   { BCOM_VENDORID,BCOM_DEVICEID_BCM57766 },
{ BCOM_VENDORID,BCOM_DEVICEID_BCM57780 },
{ BCOM_VENDORID,BCOM_DEVICEID_BCM57781 },
{ BCOM_VENDORID,BCOM_DEVICEID_BCM57785 },
@@ -347,6 +349,7 @@ static const struct bge_revision bge_maj
{ BGE_ASICREV_BCM5787,  unknown BCM5754/5787 },
{ BGE_ASICREV_BCM5906,  unknown BCM5906 },
{ BGE_ASICREV_BCM57765, unknown BCM57765 },
+   { BGE_ASICREV_BCM57766, unknown BCM57766 },
{ BGE_ASICREV_BCM57780, unknown BCM57780 },
{ BGE_ASICREV_BCM5717,  unknown BCM5717 },
{ BGE_ASICREV_BCM5719,  unknown BCM5719 },
@@ -362,6 +365,7 @@ static const struct bge_revision bge_maj
 #defineBGE_IS_575X_PLUS(sc)((sc)-bge_flags  
BGE_FLAG_575X_PLUS)
 #defineBGE_IS_5755_PLUS(sc)((sc)-bge_flags  
BGE_FLAG_5755_PLUS)
 #defineBGE_IS_5717_PLUS(sc)((sc)-bge_flags  
BGE_FLAG_5717_PLUS)
+#defineBGE_IS_57765_PLUS(sc)   ((sc)-bge_flags  
BGE_FLAG_57765_PLUS)
 
 const struct bge_revision * bge_lookup_rev(uint32_t);
 const struct bge_vendor * bge_lookup_vendor(uint16_t);
@@ -2243,7 +2247,7 @@ bge_blockinit(struct bge_softc *sc)
} else if (!BGE_IS_5705_PLUS(sc))
limit = BGE_RX_RINGS_MAX;
else if (sc-bge_asicrev == BGE_ASICREV_BCM5755 ||
-   sc-bge_asicrev == BGE_ASICREV_BCM57765)
+   BGE_IS_57765_PLUS(sc))
limit = 4;
else
limit = 1;
@@ -2657,7 +2661,9 @@ bge_probe(device_t dev)
BGE_PCI_GEN2_PRODID_ASICREV, 4);
break;
case BCOM_DEVICEID_BCM57761:
+   case BCOM_DEVICEID_BCM57762:
case BCOM_DEVICEID_BCM57765:
+   case BCOM_DEVICEID_BCM57766:
case BCOM_DEVICEID_BCM57781:
case BCOM_DEVICEID_BCM57785:
case BCOM_DEVICEID_BCM57791:
@@ -3258,7 +3264,9 @@ bge_attach(device_t dev)
BGE_PCI_GEN2_PRODID_ASICREV, 4);
break;
case BCOM_DEVICEID_BCM57761:
+   case BCOM_DEVICEID_BCM57762:
case BCOM_DEVICEID_BCM57765:
+   case BCOM_DEVICEID_BCM57766:
case BCOM_DEVICEID_BCM57781:
case BCOM_DEVICEID_BCM57785:
case BCOM_DEVICEID_BCM57791:
@@ -3321,10 +3329,13 @@ bge_attach(device_t dev)
 
/* Save chipset family. */
switch (sc-bge_asicrev) {
+   case BGE_ASICREV_BCM57765:
+   case BGE_ASICREV_BCM57766:
+   sc-bge_flags |= BGE_FLAG_57765_PLUS;
+   /* FALLTHROUGH */
case BGE_ASICREV_BCM5717:
case BGE_ASICREV_BCM5719:
case BGE_ASICREV_BCM5720:
-   case BGE_ASICREV_BCM57765:
sc-bge_flags |= BGE_FLAG_5717_PLUS | BGE_FLAG_5755_PLUS |
BGE_FLAG_575X_PLUS | BGE_FLAG_5705_PLUS | BGE_FLAG_JUMBO |
BGE_FLAG_JUMBO_FRAME;
@@ -3738,12 +3749,9 @@ bge_attach(device_t dev)
sc-bge_phy_flags |= BGE_PHY_NO_3LED;
if ((BGE_IS_5705_PLUS(sc)) 
sc-bge_asicrev != BGE_ASICREV_BCM5906 
-   sc-bge_asicrev != BGE_ASICREV_BCM5717 
-   sc-bge_asicrev != BGE_ASICREV_BCM5719 
-   sc-bge_asicrev != BGE_ASICREV_BCM5720 
sc-bge_asicrev != BGE_ASICREV_BCM5785 
-   sc-bge_asicrev != BGE_ASICREV_BCM57765 
-   sc-bge_asicrev != BGE_ASICREV_BCM57780) {
+   sc-bge_asicrev != BGE_ASICREV_BCM57780 
+   !BGE_IS_5717_PLUS(sc)) {
if (sc-bge_asicrev == BGE_ASICREV_BCM5755 ||
sc-bge_asicrev == BGE_ASICREV_BCM5761 ||
sc-bge_asicrev == 

svn commit: r242425 - head/sys/dev/ti

2012-11-01 Thread Pyun YongHyeon
Author: yongari
Date: Thu Nov  1 05:39:21 2012
New Revision: 242425
URL: http://svn.freebsd.org/changeset/base/242425

Log:
  Remove TCP/UDP checksum offloading feature for IP fragmented
  datagrams.  Traditionally upper stack fragmented packets without
  computing TCP/UDP checksum and these datagrams were passed to
  driver.  But there are chances that other packets slip into the
  interface queue in SMP world. If this happens firmware running on
  MIPS 4000 processor in the controller would see mixed packets and
  it shall send out corrupted packets.
  While I'm here simplify checksum offloading setup.
  
  MFC After:1 week

Modified:
  head/sys/dev/ti/if_ti.c

Modified: head/sys/dev/ti/if_ti.c
==
--- head/sys/dev/ti/if_ti.c Thu Nov  1 04:07:08 2012(r242424)
+++ head/sys/dev/ti/if_ti.c Thu Nov  1 05:39:21 2012(r242425)
@@ -127,7 +127,7 @@ __FBSDID($FreeBSD$);
 
 #include sys/sysctl.h
 
-#define TI_CSUM_FEATURES   (CSUM_IP | CSUM_TCP | CSUM_UDP | CSUM_IP_FRAGS)
+#define TI_CSUM_FEATURES   (CSUM_IP | CSUM_TCP | CSUM_UDP)
 /*
  * We can only turn on header splitting if we're using extended receive
  * BDs.
@@ -3082,16 +3082,10 @@ ti_encap(struct ti_softc *sc, struct mbu
 
m = *m_head;
csum_flags = 0;
-   if (m-m_pkthdr.csum_flags) {
-   if (m-m_pkthdr.csum_flags  CSUM_IP)
-   csum_flags |= TI_BDFLAG_IP_CKSUM;
-   if (m-m_pkthdr.csum_flags  (CSUM_TCP | CSUM_UDP))
-   csum_flags |= TI_BDFLAG_TCP_UDP_CKSUM;
-   if (m-m_flags  M_LASTFRAG)
-   csum_flags |= TI_BDFLAG_IP_FRAG_END;
-   else if (m-m_flags  M_FRAG)
-   csum_flags |= TI_BDFLAG_IP_FRAG;
-   }
+   if (m-m_pkthdr.csum_flags  CSUM_IP)
+   csum_flags |= TI_BDFLAG_IP_CKSUM;
+   if (m-m_pkthdr.csum_flags  (CSUM_TCP | CSUM_UDP))
+   csum_flags |= TI_BDFLAG_TCP_UDP_CKSUM;
 
frag = sc-ti_tx_saved_prodidx;
for (i = 0; i  nseg; i++) {
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r242426 - head/sys/dev/bge

2012-11-01 Thread Pyun YongHyeon
Author: yongari
Date: Thu Nov  1 06:02:27 2012
New Revision: 242426
URL: http://svn.freebsd.org/changeset/base/242426

Log:
  TCP/UDP checksum offloading feature for IP fragmented datagram was
  removed in r99417.  bge(4) controllers can do TCP checksum offload
  for IP fragmented datagrams but unlike ti(4), it lacks UDP checksum
  offloading for IP fragmented datagrams. The problem was bge(4)
  blindly requested TCP/UDP checksum for IP fragmented datagrams such
  that it resulted in corrupted UDP datagrams before r99417.
  Remove remaining code for TCP checksum offloading for IP fragmented
  datagrams which should have been removed in r99417.

Modified:
  head/sys/dev/bge/if_bge.c

Modified: head/sys/dev/bge/if_bge.c
==
--- head/sys/dev/bge/if_bge.c   Thu Nov  1 05:39:21 2012(r242425)
+++ head/sys/dev/bge/if_bge.c   Thu Nov  1 06:02:27 2012(r242426)
@@ -5103,10 +5103,6 @@ bge_encap(struct bge_softc *sc, struct m
return (error);
}
}
-   if (m-m_flags  M_LASTFRAG)
-   csum_flags |= BGE_TXBDFLAG_IP_FRAG_END;
-   else if (m-m_flags  M_FRAG)
-   csum_flags |= BGE_TXBDFLAG_IP_FRAG;
}
 
if ((m-m_pkthdr.csum_flags  CSUM_TSO) == 0) {
@@ -5228,29 +5224,6 @@ bge_start_locked(struct ifnet *ifp)
break;
 
/*
-* XXX
-* The code inside the if() block is never reached since we
-* must mark CSUM_IP_FRAGS in our if_hwassist to start getting
-* requests to checksum TCP/UDP in a fragmented packet.
-*
-* XXX
-* safety overkill.  If this is a fragmented packet chain
-* with delayed TCP/UDP checksums, then only encapsulate
-* it if we have enough descriptors to handle the entire
-* chain at once.
-* (paranoia -- may not actually be needed)
-*/
-   if (m_head-m_flags  M_FIRSTFRAG 
-   m_head-m_pkthdr.csum_flags  (CSUM_DELAY_DATA)) {
-   if ((BGE_TX_RING_CNT - sc-bge_txcnt) 
-   m_head-m_pkthdr.csum_data + 16) {
-   IFQ_DRV_PREPEND(ifp-if_snd, m_head);
-   ifp-if_drv_flags |= IFF_DRV_OACTIVE;
-   break;
-   }
-   }
-
-   /*
 * Pack the data into the transmit ring. If we
 * don't have room, set the OACTIVE flag and wait
 * for the NIC to drain the ring.
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r242348 - head/sys/dev/age

2012-10-30 Thread Pyun YongHyeon
Author: yongari
Date: Tue Oct 30 07:55:03 2012
New Revision: 242348
URL: http://svn.freebsd.org/changeset/base/242348

Log:
  TSO engine of L1 requires a separate DMA descriptor for TCP
  payload.  This means driver has to split a TX buffer into two
  pieces of TX buffers when the TX buffer contains both
  ethernet/IP/TCP header and partial TCP payload.  The controller
  does not require all header should be in a TX buffer but driver
  forced it to compute IP/TCP header size/offset which is required
  parameter to configure DMA descriptor for TSO.
  While here, slightly reorder DMA descriptor setup to enhance
  readability and remove unnecessary code for TSO(upper stack never
  requests TSO when the frame length is less than or equal to MTU).
  
  Reported by:  Yamagi Burmeister lists  yamagi dot org
  Tested by:Yamagi Burmeister lists  yamagi dot org
  MFC After:1 week

Modified:
  head/sys/dev/age/if_age.c

Modified: head/sys/dev/age/if_age.c
==
--- head/sys/dev/age/if_age.c   Tue Oct 30 07:51:18 2012(r242347)
+++ head/sys/dev/age/if_age.c   Tue Oct 30 07:55:03 2012(r242348)
@@ -1495,7 +1495,7 @@ age_encap(struct age_softc *sc, struct m
struct tcphdr *tcp;
bus_dma_segment_t txsegs[AGE_MAXTXSEGS];
bus_dmamap_t map;
-   uint32_t cflags, ip_off, poff, vtag;
+   uint32_t cflags, hdrlen, ip_off, poff, vtag;
int error, i, nsegs, prod, si;
 
AGE_LOCK_ASSERT(sc);
@@ -1562,8 +1562,12 @@ age_encap(struct age_softc *sc, struct m
*m_head = NULL;
return (ENOBUFS);
}
-   ip = (struct ip *)(mtod(m, char *) + ip_off);
tcp = (struct tcphdr *)(mtod(m, char *) + poff);
+   m = m_pullup(m, poff + (tcp-th_off  2));
+   if (m == NULL) {
+   *m_head = NULL;
+   return (ENOBUFS);
+   }
/*
 * L1 requires IP/TCP header size and offset as
 * well as TCP pseudo checksum which complicates
@@ -1578,14 +1582,11 @@ age_encap(struct age_softc *sc, struct m
 * Reset IP checksum and recompute TCP pseudo
 * checksum as NDIS specification said.
 */
+   ip = (struct ip *)(mtod(m, char *) + ip_off);
+   tcp = (struct tcphdr *)(mtod(m, char *) + poff);
ip-ip_sum = 0;
-   if (poff + (tcp-th_off  2) == m-m_pkthdr.len)
-   tcp-th_sum = in_pseudo(ip-ip_src.s_addr,
-   ip-ip_dst.s_addr,
-   htons((tcp-th_off  2) + IPPROTO_TCP));
-   else
-   tcp-th_sum = in_pseudo(ip-ip_src.s_addr,
-   ip-ip_dst.s_addr, htons(IPPROTO_TCP));
+   tcp-th_sum = in_pseudo(ip-ip_src.s_addr,
+   ip-ip_dst.s_addr, htons(IPPROTO_TCP));
}
*m_head = m;
}
@@ -1627,23 +1628,48 @@ age_encap(struct age_softc *sc, struct m
}
 
m = *m_head;
+   /* Configure VLAN hardware tag insertion. */
+   if ((m-m_flags  M_VLANTAG) != 0) {
+   vtag = AGE_TX_VLAN_TAG(m-m_pkthdr.ether_vtag);
+   vtag = ((vtag  AGE_TD_VLAN_SHIFT)  AGE_TD_VLAN_MASK);
+   cflags |= AGE_TD_INSERT_VLAN_TAG;
+   }
+
+   desc = NULL;
+   i = 0;
if ((m-m_pkthdr.csum_flags  CSUM_TSO) != 0) {
-   /* Configure TSO. */
-   if (poff + (tcp-th_off  2) == m-m_pkthdr.len) {
-   /* Not TSO but IP/TCP checksum offload. */
-   cflags |= AGE_TD_IPCSUM | AGE_TD_TCPCSUM;
-   /* Clear TSO in order not to set AGE_TD_TSO_HDR. */
-   m-m_pkthdr.csum_flags = ~CSUM_TSO;
-   } else {
-   /* Request TSO and set MSS. */
-   cflags |= AGE_TD_TSO_IPV4;
-   cflags |= AGE_TD_IPCSUM | AGE_TD_TCPCSUM;
-   cflags |= ((uint32_t)m-m_pkthdr.tso_segsz 
-   AGE_TD_TSO_MSS_SHIFT);
-   }
+   /* Request TSO and set MSS. */
+   cflags |= AGE_TD_TSO_IPV4;
+   cflags |= AGE_TD_IPCSUM | AGE_TD_TCPCSUM;
+   cflags |= ((uint32_t)m-m_pkthdr.tso_segsz 
+   AGE_TD_TSO_MSS_SHIFT);
/* Set IP/TCP header size. */
cflags |= ip-ip_hl  AGE_TD_IPHDR_LEN_SHIFT;
cflags |= tcp-th_off  AGE_TD_TSO_TCPHDR_LEN_SHIFT;
+   /*
+* L1 requires the first buffer should only hold 

svn commit: r241983 - head/sys/dev/bge

2012-10-23 Thread Pyun YongHyeon
Author: yongari
Date: Wed Oct 24 05:00:56 2012
New Revision: 241983
URL: http://svn.freebsd.org/changeset/base/241983

Log:
  Do not hardcode phy address. Multi-port controllers use different phy
  address.

Modified:
  head/sys/dev/bge/if_bge.c
  head/sys/dev/bge/if_bgereg.h

Modified: head/sys/dev/bge/if_bge.c
==
--- head/sys/dev/bge/if_bge.c   Wed Oct 24 02:54:21 2012(r241982)
+++ head/sys/dev/bge/if_bge.c   Wed Oct 24 05:00:56 2012(r241983)
@@ -3215,7 +3215,7 @@ bge_attach(device_t dev)
struct bge_softc *sc;
uint32_t hwcfg = 0, misccfg, pcistate;
u_char eaddr[ETHER_ADDR_LEN];
-   int capmask, error, msicount, phy_addr, reg, rid, trys;
+   int capmask, error, msicount, reg, rid, trys;
 
sc = device_get_softc(dev);
sc-bge_dev = dev;
@@ -3275,7 +3275,7 @@ bge_attach(device_t dev)
sc-bge_chiprev = BGE_CHIPREV(sc-bge_chipid);
 
/* Set default PHY address. */
-   phy_addr = 1;
+   sc-bge_phy_addr = 1;
 /*
  * PHY address mapping for various devices.
  *
@@ -3304,15 +3304,15 @@ bge_attach(device_t dev)
if (sc-bge_chipid != BGE_CHIPID_BCM5717_A0) {
if (CSR_READ_4(sc, BGE_SGDIG_STS) 
BGE_SGDIGSTS_IS_SERDES)
-   phy_addr = sc-bge_func_addr + 8;
+   sc-bge_phy_addr = sc-bge_func_addr + 8;
else
-   phy_addr = sc-bge_func_addr + 1;
+   sc-bge_phy_addr = sc-bge_func_addr + 1;
} else {
if (CSR_READ_4(sc, BGE_CPMU_PHY_STRAP) 
BGE_CPMU_PHY_STRAP_IS_SERDES)
-   phy_addr = sc-bge_func_addr + 8;
+   sc-bge_phy_addr = sc-bge_func_addr + 8;
else
-   phy_addr = sc-bge_func_addr + 1;
+   sc-bge_phy_addr = sc-bge_func_addr + 1;
}
}
 
@@ -3789,13 +3789,13 @@ again:
bge_asf_driver_up(sc);
 
error = mii_attach(dev, sc-bge_miibus, ifp, bge_ifmedia_upd,
-   bge_ifmedia_sts, capmask, phy_addr, MII_OFFSET_ANY,
+   bge_ifmedia_sts, capmask, sc-bge_phy_addr, MII_OFFSET_ANY,
MIIF_DOPAUSE);
if (error != 0) {
if (trys++  4) {
device_printf(sc-bge_dev, Try again\n);
-   bge_miibus_writereg(sc-bge_dev, 1, MII_BMCR,
-   BMCR_RESET);
+   bge_miibus_writereg(sc-bge_dev,
+   sc-bge_phy_addr, MII_BMCR, BMCR_RESET);
goto again;
}
device_printf(sc-bge_dev, attaching PHYs failed\n);
@@ -6017,9 +6017,10 @@ bge_link_upd(struct bge_softc *sc)
/* Clear the interrupt. */
CSR_WRITE_4(sc, BGE_MAC_EVT_ENB,
BGE_EVTENB_MI_INTERRUPT);
-   bge_miibus_readreg(sc-bge_dev, 1, BRGPHY_MII_ISR);
-   bge_miibus_writereg(sc-bge_dev, 1, BRGPHY_MII_IMR,
-   BRGPHY_INTRS);
+   bge_miibus_readreg(sc-bge_dev, sc-bge_phy_addr,
+   BRGPHY_MII_ISR);
+   bge_miibus_writereg(sc-bge_dev, sc-bge_phy_addr,
+   BRGPHY_MII_IMR, BRGPHY_INTRS);
}
return;
}

Modified: head/sys/dev/bge/if_bgereg.h
==
--- head/sys/dev/bge/if_bgereg.hWed Oct 24 02:54:21 2012
(r241982)
+++ head/sys/dev/bge/if_bgereg.hWed Oct 24 05:00:56 2012
(r241983)
@@ -2974,6 +2974,7 @@ struct bge_softc {
 #defineBGE_MFW_TYPE_DASH   0x0008
int bge_phy_ape_lock;
int bge_func_addr;
+   int bge_phy_addr;
uint32_tbge_phy_flags;
 #defineBGE_PHY_NO_WIRESPEED0x0001
 #defineBGE_PHY_ADC_BUG 0x0002
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r241984 - head/sys/dev/bge

2012-10-23 Thread Pyun YongHyeon
Author: yongari
Date: Wed Oct 24 05:22:41 2012
New Revision: 241984
URL: http://svn.freebsd.org/changeset/base/241984

Log:
  Ethernet@WireSpeed is defined for 1000baseT adapter to establish a
  link at a lower speed so enabling it for fiber adapters is wrong.
  Fix the issue by setting BGE_PHY_NO_WIRESPEED such that brgphy(4)
  wouldn't enable the feature.
  While I'm here move PHY specific feature/bug configuration to new
  location(just before mii attach) for readability.

Modified:
  head/sys/dev/bge/if_bge.c

Modified: head/sys/dev/bge/if_bge.c
==
--- head/sys/dev/bge/if_bge.c   Wed Oct 24 05:00:56 2012(r241983)
+++ head/sys/dev/bge/if_bge.c   Wed Oct 24 05:22:41 2012(r241984)
@@ -3316,17 +3316,6 @@ bge_attach(device_t dev)
}
}
 
-   /*
-* Don't enable Ethernet@WireSpeed for the 5700, 5906, or the
-* 5705 A0 and A1 chips.
-*/
-   if (sc-bge_asicrev == BGE_ASICREV_BCM5700 ||
-   (sc-bge_asicrev == BGE_ASICREV_BCM5705 
-   (sc-bge_chipid != BGE_CHIPID_BCM5705_A0 
-   sc-bge_chipid != BGE_CHIPID_BCM5705_A1)) ||
-   sc-bge_asicrev == BGE_ASICREV_BCM5906)
-   sc-bge_phy_flags |= BGE_PHY_NO_WIRESPEED;
-
if (bge_has_eaddr(sc))
sc-bge_flags |= BGE_FLAG_EADDR;
 
@@ -3411,38 +3400,6 @@ bge_attach(device_t dev)
/* Add SYSCTLs, requires the chipset family to be set. */
bge_add_sysctls(sc);
 
-   /* Set various PHY bug flags. */
-   if (sc-bge_chipid == BGE_CHIPID_BCM5701_A0 ||
-   sc-bge_chipid == BGE_CHIPID_BCM5701_B0)
-   sc-bge_phy_flags |= BGE_PHY_CRC_BUG;
-   if (sc-bge_chiprev == BGE_CHIPREV_5703_AX ||
-   sc-bge_chiprev == BGE_CHIPREV_5704_AX)
-   sc-bge_phy_flags |= BGE_PHY_ADC_BUG;
-   if (sc-bge_chipid == BGE_CHIPID_BCM5704_A0)
-   sc-bge_phy_flags |= BGE_PHY_5704_A0_BUG;
-   if (pci_get_subvendor(dev) == DELL_VENDORID)
-   sc-bge_phy_flags |= BGE_PHY_NO_3LED;
-   if ((BGE_IS_5705_PLUS(sc)) 
-   sc-bge_asicrev != BGE_ASICREV_BCM5906 
-   sc-bge_asicrev != BGE_ASICREV_BCM5717 
-   sc-bge_asicrev != BGE_ASICREV_BCM5719 
-   sc-bge_asicrev != BGE_ASICREV_BCM5720 
-   sc-bge_asicrev != BGE_ASICREV_BCM5785 
-   sc-bge_asicrev != BGE_ASICREV_BCM57765 
-   sc-bge_asicrev != BGE_ASICREV_BCM57780) {
-   if (sc-bge_asicrev == BGE_ASICREV_BCM5755 ||
-   sc-bge_asicrev == BGE_ASICREV_BCM5761 ||
-   sc-bge_asicrev == BGE_ASICREV_BCM5784 ||
-   sc-bge_asicrev == BGE_ASICREV_BCM5787) {
-   if (pci_get_device(dev) != BCOM_DEVICEID_BCM5722 
-   pci_get_device(dev) != BCOM_DEVICEID_BCM5756)
-   sc-bge_phy_flags |= BGE_PHY_JITTER_BUG;
-   if (pci_get_device(dev) == BCOM_DEVICEID_BCM5755M)
-   sc-bge_phy_flags |= BGE_PHY_ADJUST_TRIM;
-   } else
-   sc-bge_phy_flags |= BGE_PHY_BER_BUG;
-   }
-
/* Identify the chips that use an CPMU. */
if (BGE_IS_5717_PLUS(sc) ||
sc-bge_asicrev == BGE_ASICREV_BCM5784 ||
@@ -3760,12 +3717,56 @@ bge_attach(device_t dev)
/* The SysKonnect SK-9D41 is a 1000baseSX card. */
if ((pci_read_config(dev, BGE_PCI_SUBSYS, 4)  16) ==
SK_SUBSYSID_9D41 || (hwcfg  BGE_HWCFG_MEDIA) == BGE_MEDIA_FIBER) {
-   if (BGE_IS_5705_PLUS(sc))
+   if (BGE_IS_5705_PLUS(sc)) {
sc-bge_flags |= BGE_FLAG_MII_SERDES;
-   else
+   sc-bge_phy_flags |= BGE_PHY_NO_WIRESPEED;
+   } else
sc-bge_flags |= BGE_FLAG_TBI;
}
 
+   /* Set various PHY bug flags. */
+   if (sc-bge_chipid == BGE_CHIPID_BCM5701_A0 ||
+   sc-bge_chipid == BGE_CHIPID_BCM5701_B0)
+   sc-bge_phy_flags |= BGE_PHY_CRC_BUG;
+   if (sc-bge_chiprev == BGE_CHIPREV_5703_AX ||
+   sc-bge_chiprev == BGE_CHIPREV_5704_AX)
+   sc-bge_phy_flags |= BGE_PHY_ADC_BUG;
+   if (sc-bge_chipid == BGE_CHIPID_BCM5704_A0)
+   sc-bge_phy_flags |= BGE_PHY_5704_A0_BUG;
+   if (pci_get_subvendor(dev) == DELL_VENDORID)
+   sc-bge_phy_flags |= BGE_PHY_NO_3LED;
+   if ((BGE_IS_5705_PLUS(sc)) 
+   sc-bge_asicrev != BGE_ASICREV_BCM5906 
+   sc-bge_asicrev != BGE_ASICREV_BCM5717 
+   sc-bge_asicrev != BGE_ASICREV_BCM5719 
+   sc-bge_asicrev != BGE_ASICREV_BCM5720 
+   sc-bge_asicrev != BGE_ASICREV_BCM5785 
+   sc-bge_asicrev != BGE_ASICREV_BCM57765 
+   sc-bge_asicrev != BGE_ASICREV_BCM57780) {
+   if (sc-bge_asicrev == BGE_ASICREV_BCM5755 ||
+   sc-bge_asicrev == 

svn commit: r241985 - head/sys/dev/bge

2012-10-23 Thread Pyun YongHyeon
Author: yongari
Date: Wed Oct 24 05:54:17 2012
New Revision: 241985
URL: http://svn.freebsd.org/changeset/base/241985

Log:
  For fast ethernet controllers, Ethernet@WireSpeed is not defined so
  explicitly set BGE_PHY_NO_WIRESPEED flag.

Modified:
  head/sys/dev/bge/if_bge.c

Modified: head/sys/dev/bge/if_bge.c
==
--- head/sys/dev/bge/if_bge.c   Wed Oct 24 05:22:41 2012(r241984)
+++ head/sys/dev/bge/if_bge.c   Wed Oct 24 05:54:17 2012(r241985)
@@ -3460,6 +3460,7 @@ bge_attach(device_t dev)
sc-bge_asicrev == BGE_ASICREV_BCM5906) {
/* These chips are 10/100 only. */
capmask = ~BMSR_EXTSTAT;
+   sc-bge_phy_flags |= BGE_PHY_NO_WIRESPEED;
}
 
/*
@@ -3757,14 +3758,13 @@ bge_attach(device_t dev)
}
 
/*
-* Don't enable Ethernet@WireSpeed for the 5700, 5906, or the
+* Don't enable Ethernet@WireSpeed for the 5700 or the
 * 5705 A0 and A1 chips.
 */
if (sc-bge_asicrev == BGE_ASICREV_BCM5700 ||
(sc-bge_asicrev == BGE_ASICREV_BCM5705 
(sc-bge_chipid != BGE_CHIPID_BCM5705_A0 
-   sc-bge_chipid != BGE_CHIPID_BCM5705_A1)) ||
-   sc-bge_asicrev == BGE_ASICREV_BCM5906)
+   sc-bge_chipid != BGE_CHIPID_BCM5705_A1)))
sc-bge_phy_flags |= BGE_PHY_NO_WIRESPEED;
 
if (sc-bge_flags  BGE_FLAG_TBI) {
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r241437 - head/sys/dev/mii

2012-10-11 Thread Pyun YongHyeon
Author: yongari
Date: Thu Oct 11 06:07:48 2012
New Revision: 241437
URL: http://svn.freebsd.org/changeset/base/241437

Log:
  For 5717C/5719C/5720C and 57765 PHYs, do not perform any special
  handling(jumbo, wire speed etc) in brgphy_reset().  Touching
  BRGPHY_MII_AUXCTL register seems to confuse APE firmware such that
  it couldn't establish a link.

Modified:
  head/sys/dev/mii/brgphy.c

Modified: head/sys/dev/mii/brgphy.c
==
--- head/sys/dev/mii/brgphy.c   Thu Oct 11 05:48:04 2012(r241436)
+++ head/sys/dev/mii/brgphy.c   Thu Oct 11 06:07:48 2012(r241437)
@@ -918,6 +918,15 @@ brgphy_reset(struct mii_softc *sc)
break;
}
break;
+   case MII_OUI_BROADCOM3:
+   switch (sc-mii_mpd_model) {
+   case MII_MODEL_BROADCOM3_BCM5717C:
+   case MII_MODEL_BROADCOM3_BCM5719C:
+   case MII_MODEL_BROADCOM3_BCM5720C:
+   case MII_MODEL_BROADCOM3_BCM57765:
+   return;
+   }
+   break;
}
 
ifp = sc-mii_pdata-mii_ifp;
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r241438 - head/sys/dev/bge

2012-10-11 Thread Pyun YongHyeon
Author: yongari
Date: Thu Oct 11 06:43:43 2012
New Revision: 241438
URL: http://svn.freebsd.org/changeset/base/241438

Log:
  Add APE firmware support and improve firmware handshake procedure.
  This change will enable IPMI access on 5717/5718/5719/5720 and 5761
  controllers. Because ASF is not available when APE firmware is
  present, bge_allow_asf tunable is ignored when driver detects APE
  firmware.  Also bge(4) no longer performs two resets(one blind
  reset and the other reset with firmware in mind) in device attach.
  Now bge(4) performs a reset with enough information in bge_reset().
  The APE firmware also needs special handling to make suspend/resume
  work but it was not implemented yet.
  
  With this change, bge(4) should work on any 5717/5718/5719/5720
  controllers. Special thanks to Mike Hibler at Emulab who setup
  remote debugging on Dell R820. Without his help I couldn't be able
  to address several issues happened on Dell Rx20 systems. And many
  thanks to Broadcom for continuing to support FreeBSD!
  
  Submitted by: davidch (initial version)
  H/W donated by:   Broadcom
  Tested by:many
  Tested on:Del R820/R720/R620/R420/R320 and HP Proliant DL 360 G8

Modified:
  head/sys/dev/bge/if_bge.c
  head/sys/dev/bge/if_bgereg.h

Modified: head/sys/dev/bge/if_bge.c
==
--- head/sys/dev/bge/if_bge.c   Thu Oct 11 06:07:48 2012(r241437)
+++ head/sys/dev/bge/if_bge.c   Thu Oct 11 06:43:43 2012(r241438)
@@ -461,8 +461,9 @@ static void bge_miibus_statchg(device_t)
 static int bge_poll(struct ifnet *ifp, enum poll_cmd cmd, int count);
 #endif
 
-#defineBGE_RESET_START 1
-#defineBGE_RESET_STOP  2
+#defineBGE_RESET_SHUTDOWN  0
+#defineBGE_RESET_START 1
+#defineBGE_RESET_SUSPEND   2
 static void bge_sig_post_reset(struct bge_softc *, int);
 static void bge_sig_legacy(struct bge_softc *, int);
 static void bge_sig_pre_reset(struct bge_softc *, int);
@@ -470,6 +471,13 @@ static void bge_stop_fw(struct bge_softc
 static int bge_reset(struct bge_softc *);
 static void bge_link_upd(struct bge_softc *);
 
+static void bge_ape_lock_init(struct bge_softc *);
+static void bge_ape_read_fw_ver(struct bge_softc *);
+static int bge_ape_lock(struct bge_softc *, int);
+static void bge_ape_unlock(struct bge_softc *, int);
+static void bge_ape_send_event(struct bge_softc *, uint32_t);
+static void bge_ape_driver_state_change(struct bge_softc *, int);
+
 /*
  * The BGE_REGISTER_DEBUG option is only for low-level debugging.  It may
  * leak information to untrusted users.  It is also known to cause alignment
@@ -478,6 +486,7 @@ static void bge_link_upd(struct bge_soft
 #ifdef BGE_REGISTER_DEBUG
 static int bge_sysctl_debug_info(SYSCTL_HANDLER_ARGS);
 static int bge_sysctl_reg_read(SYSCTL_HANDLER_ARGS);
+static int bge_sysctl_ape_read(SYSCTL_HANDLER_ARGS);
 static int bge_sysctl_mem_read(SYSCTL_HANDLER_ARGS);
 #endif
 static void bge_add_sysctls(struct bge_softc *);
@@ -643,6 +652,318 @@ bge_writembx(struct bge_softc *sc, int o
 }
 
 /*
+ * Clear all stale locks and select the lock for this driver instance.
+ */
+static void
+bge_ape_lock_init(struct bge_softc *sc)
+{
+   uint32_t bit, regbase;
+   int i;
+
+   if (sc-bge_asicrev == BGE_ASICREV_BCM5761)
+   regbase = BGE_APE_LOCK_GRANT;
+   else
+   regbase = BGE_APE_PER_LOCK_GRANT;
+
+   /* Clear any stale locks. */
+   for (i = BGE_APE_LOCK_PHY0; i = BGE_APE_LOCK_GPIO; i++) {
+   switch (i) {
+   case BGE_APE_LOCK_PHY0:
+   case BGE_APE_LOCK_PHY1:
+   case BGE_APE_LOCK_PHY2:
+   case BGE_APE_LOCK_PHY3:
+   bit = BGE_APE_LOCK_GRANT_DRIVER0;
+   break;
+   default:
+   if (sc-bge_func_addr != 0)
+   bit = BGE_APE_LOCK_GRANT_DRIVER0;
+   else
+   bit = (1  sc-bge_func_addr);
+   }
+   APE_WRITE_4(sc, regbase + 4 * i, bit);
+   }
+
+   /* Select the PHY lock based on the device's function number. */
+   switch (sc-bge_func_addr) {
+   case 0:
+   sc-bge_phy_ape_lock = BGE_APE_LOCK_PHY0;
+   break;
+   case 1:
+   sc-bge_phy_ape_lock = BGE_APE_LOCK_PHY1;
+   break;
+   case 2:
+   sc-bge_phy_ape_lock = BGE_APE_LOCK_PHY2;
+   break;
+   case 3:
+   sc-bge_phy_ape_lock = BGE_APE_LOCK_PHY3;
+   break;
+   default:
+   device_printf(sc-bge_dev,
+   PHY lock not supported on this function\n);
+   }
+}
+
+/*
+ * Check for APE firmware, set flags, and print version info.
+ */
+static void
+bge_ape_read_fw_ver(struct bge_softc *sc)
+{
+   const char *fwtype;
+   uint32_t apedata, 

svn commit: r241388 - head/sys/dev/bge

2012-10-09 Thread Pyun YongHyeon
Author: yongari
Date: Wed Oct 10 01:24:02 2012
New Revision: 241388
URL: http://svn.freebsd.org/changeset/base/241388

Log:
  If the maximum payload size is 256 bytes or more, set the DMA write
  water mark to 256 bytes.  Otherwise controller will encounter DMA
  write under run errors and would result in RX DMA hang. If the
  maximum payload size is 128 bytes, the water mark is set to 128
  bytes as usual.
  While here, set maximum read request size to 2048 for BCM5719/BCM5720.
  For other PCIe devices, use 4096. And reprogram the maximum read
  request size whenever device reset is performed.

Modified:
  head/sys/dev/bge/if_bge.c
  head/sys/dev/bge/if_bgereg.h

Modified: head/sys/dev/bge/if_bge.c
==
--- head/sys/dev/bge/if_bge.c   Wed Oct 10 00:11:06 2012(r241387)
+++ head/sys/dev/bge/if_bge.c   Wed Oct 10 01:24:02 2012(r241388)
@@ -1466,8 +1466,10 @@ bge_chipinit(struct bge_softc *sc)
dma_rw_ctl = BGE_PCIDMARWCTL_RD_CMD_SHIFT(6) |
BGE_PCIDMARWCTL_WR_CMD_SHIFT(7);
if (sc-bge_flags  BGE_FLAG_PCIE) {
-   /* Read watermark not used, 128 bytes for write. */
-   dma_rw_ctl |= BGE_PCIDMARWCTL_WR_WAT_SHIFT(3);
+   if (sc-bge_mps = 256)
+   dma_rw_ctl |= BGE_PCIDMARWCTL_WR_WAT_SHIFT(7);
+   else
+   dma_rw_ctl |= BGE_PCIDMARWCTL_WR_WAT_SHIFT(3);
} else if (sc-bge_flags  BGE_FLAG_PCIX) {
if (BGE_IS_5714_FAMILY(sc)) {
/* 256 bytes for read and write. */
@@ -3161,11 +3163,16 @@ bge_attach(device_t dev)
 */
sc-bge_flags |= BGE_FLAG_PCIE;
sc-bge_expcap = reg;
+   /* Extract supported maximum payload size. */
+   sc-bge_mps = pci_read_config(dev, sc-bge_expcap +
+   PCIER_DEVICE_CAP, 2);
+   sc-bge_mps = 128  (sc-bge_mps  PCIEM_CAP_MAX_PAYLOAD);
if (sc-bge_asicrev == BGE_ASICREV_BCM5719 ||
sc-bge_asicrev == BGE_ASICREV_BCM5720)
-   pci_set_max_read_req(dev, 2048);
-   else if (pci_get_max_read_req(dev) != 4096)
-   pci_set_max_read_req(dev, 4096);
+   sc-bge_expmrq = 2048;
+   else
+   sc-bge_expmrq = 4096;
+   pci_set_max_read_req(dev, sc-bge_expmrq);
} else {
/*
 * Check if the device is in PCI-X Mode.
@@ -3642,6 +3649,7 @@ bge_reset(struct bge_softc *sc)
PCIEM_CTL_NOSNOOP_ENABLE);
pci_write_config(dev, sc-bge_expcap + PCIER_DEVICE_CTL,
devctl, 2);
+   pci_set_max_read_req(dev, sc-bge_expmrq);
/* Clear error status. */
pci_write_config(dev, sc-bge_expcap + PCIER_DEVICE_STA,
PCIEM_STA_CORRECTABLE_ERROR |

Modified: head/sys/dev/bge/if_bgereg.h
==
--- head/sys/dev/bge/if_bgereg.hWed Oct 10 00:11:06 2012
(r241387)
+++ head/sys/dev/bge/if_bgereg.hWed Oct 10 01:24:02 2012
(r241388)
@@ -2792,6 +2792,7 @@ struct bge_softc {
struct resource *bge_res;
struct ifmedia  bge_ifmedia;/* TBI media info */
int bge_expcap;
+   int bge_expmrq;
int bge_msicap;
int bge_pcixcap;
uint32_tbge_flags;
@@ -2835,6 +2836,7 @@ struct bge_softc {
uint32_tbge_chiprev;
uint8_t bge_asf_mode;
uint8_t bge_asf_count;
+   uint16_tbge_mps;
struct bge_ring_databge_ldata;  /* rings */
struct bge_chain_data   bge_cdata;  /* mbufs */
uint16_tbge_tx_saved_considx;
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


  1   2   3   4   5   6   >