cosmetic changes
---
dev/usb/if_axen.c | 142 +++++++++++++++++++++++++++++++++++++++-------
1 file changed, 120 insertions(+), 22 deletions(-)
diff --git a/dev/usb/if_axen.c b/dev/usb/if_axen.c
index 817cad8..f3a71f4 100644
--- a/dev/usb/if_axen.c
+++ b/dev/usb/if_axen.c
@@ -162,7 +162,7 @@ axen_cmd(struct axen_softc *sc, int cmd, int index, int
val, void *buf)
USETW(req.wLength, AXEN_CMD_LEN(cmd));
err = usbd_do_request(sc->axen_udev, &req, buf);
- DPRINTFN(5, ("axen_cmd: cmd 0x%04x val 0x%04x len %d\n",
+ DPRINTFN(15, ("axen_cmd: cmd 0x%04x val 0x%04x len %d\n",
cmd, val, AXEN_CMD_LEN(cmd)));
if (err) {
@@ -199,7 +199,7 @@ axen_miibus_readreg(struct device *dev, int phy, int reg)
}
ival = UGETW(val);
- DPRINTFN(2,("axen_miibus_readreg: phy 0x%x reg 0x%x val 0x%x\n",
+ DPRINTFN(12,("axen_miibus_readreg: phy 0x%x reg 0x%x val 0x%x\n",
phy, reg, ival));
if (reg == MII_BMSR) {
@@ -226,7 +226,7 @@ axen_miibus_writereg(struct device *dev, int phy, int reg,
int val)
axen_lock_mii(sc);
err = axen_cmd(sc, AXEN_CMD_MII_WRITE_REG, reg, phy, &uval);
axen_unlock_mii(sc);
- DPRINTFN(2, ("axen_miibus_writereg: phy 0x%x reg 0x%x val 0x%0x\n",
+ DPRINTFN(12, ("axen_miibus_writereg: phy 0x%x reg 0x%x val 0x%0x\n",
phy, reg, val));
if (err) {
@@ -269,13 +269,18 @@ axen_miibus_statchg(struct device *dev)
}
/* Lost link, do nothing. */
- if (sc->axen_link == 0)
+ if (sc->axen_link == 0) {
+ DPRINTF(("%s: %s: lost link\n", sc->axen_dev.dv_xname,
+ __func__));
goto done;
+ }
err = axen_cmd(sc, AXEN_CMD_MAC_READ, 1, AXEN_PHYSICAL_LINK_STATUS,
&link_status);
if (err)
goto error;
+ DPRINTF(("%s: %s: link status: 0x%x\n", sc->axen_dev.dv_xname,
+ __func__, link_status));
/* both freebsd and linux don't define/set AXEN_MEDIUM_ALWAYS_ONE,
* but 6.2.2.10 of the datasheet (p40) sets it to 1 */
@@ -283,11 +288,22 @@ axen_miibus_statchg(struct device *dev)
if ((IFM_OPTIONS(mii->mii_media_active) & IFM_FDX) != 0) {
val |= AXEN_MEDIUM_FDX;
+#if 0
+ if ((IFM_OPTIONS(mii->mii_media_active) & IFM_ETH_TXPAUSE) != 0)
+ val |= AXEN_MEDIUM_TXFLOW_CTRL_EN;
+ if ((IFM_OPTIONS(mii->mii_media_active) & IFM_ETH_RXPAUSE) != 0)
+ val |= AXEN_MEDIUM_RXFLOW_CTRL_EN;
+#else
val |= AXEN_MEDIUM_TXFLOW_CTRL_EN | AXEN_MEDIUM_RXFLOW_CTRL_EN;
+#endif
}
switch (IFM_SUBTYPE(mii->mii_media_active)) {
case IFM_1000_T:
+ if (!(link_status & AXEN_EPHY_1000)) {
+ printf("%s: wrong phy link (want 1000)\n",
+ sc->axen_dev.dv_xname);
+ }
val |= AXEN_MEDIUM_GIGA;
if (link_status & AXEN_USB_SS)
qctrl = &axen_bulk_size[0];
@@ -297,6 +313,10 @@ axen_miibus_statchg(struct device *dev)
qctrl = &axen_bulk_size[3];
break;
case IFM_100_TX:
+ if (!(link_status & AXEN_EPHY_100)) {
+ printf("%s: wrong phy link (want 100)\n",
+ sc->axen_dev.dv_xname);
+ }
val |= AXEN_MEDIUM_PORTSPEED_100;
if (link_status & (AXEN_USB_SS | AXEN_USB_HS))
qctrl = &axen_bulk_size[2];
@@ -304,6 +324,10 @@ axen_miibus_statchg(struct device *dev)
qctrl = &axen_bulk_size[3];
break;
case IFM_10_T:
+ if (!(link_status & AXEN_EPHY_10)) {
+ printf("%s: wrong phy link (want 10)\n",
+ sc->axen_dev.dv_xname);
+ }
qctrl = &axen_bulk_size[3];
break;
default:
@@ -314,6 +338,9 @@ axen_miibus_statchg(struct device *dev)
/* XXX change buffer size here */
/* RX bulk configuration. */
+ DPRINTF(("%s: %s: qtrl bufsize = 0x%x, ifg = 0x%x\n",
+ sc->axen_dev.dv_xname, __func__,
+ qctrl->bufsize, qctrl->ifg));
err = axen_cmd(sc, AXEN_CMD_MAC_SET_RXSR, 5, AXEN_RX_BULKIN_QCTRL,
qctrl);
if (err)
@@ -385,6 +412,8 @@ axen_iff(struct axen_softc *sc)
u_int8_t hashtbl[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
uWord wval;
+ DPRINTFN(2,("%s: %s: enter\n", sc->axen_dev.dv_xname,__func__));
+
if (usbd_is_dying(sc->axen_udev))
return;
@@ -422,9 +451,15 @@ axen_iff(struct axen_softc *sc)
}
}
- axen_cmd(sc, AXEN_CMD_MAC_WRITE_FILTER, 8, AXEN_FILTER_MULTI,
+ DPRINTFN(5,("%s: %s: hashtbl: %x %x %x %x %x %x %x %x\n",
+ sc->axen_dev.dv_xname,__func__,
+ hashtbl[0], hashtbl[1], hashtbl[2], hashtbl[3],
+ hashtbl[4], hashtbl[5], hashtbl[6], hashtbl[7]));
+ axen_cmd(sc, AXEN_CMD_MAC_WRITE_FILTER, 8, AXEN_FILTER_MULTI,
(void *)&hashtbl);
+ DPRINTFN(2,("%s: %s: rxmode: 0x%x\n",
+ sc->axen_dev.dv_xname,__func__,rxmode));
USETW(wval, rxmode);
axen_cmd(sc, AXEN_CMD_MAC_WRITE2, 2, AXEN_MAC_RXCTL, &wval);
axen_unlock_mii(sc);
@@ -453,6 +488,8 @@ axen_ax88179_init(struct axen_softc *sc)
uByte val;
u_int16_t ctl, temp;
+ DPRINTFN(2,("%s: %s: enter\n", sc->axen_dev.dv_xname,__func__));
+
axen_lock_mii(sc);
/* XXX: ? */
@@ -585,13 +622,14 @@ axen_ax88179_init(struct axen_softc *sc)
0x002c);
#endif
- /* disable eee */
+#if 1 /* disable eee */
axen_miibus_writereg(&sc->axen_dev, sc->axen_phyno,
AXEN_GMII_PHY_PAGE_SELECT, AXEN_GMII_PHY_PGSEL_PAGE3);
axen_miibus_writereg(&sc->axen_dev, sc->axen_phyno,
AXEN_MII_PHYADDR, 0x3246);
axen_miibus_writereg(&sc->axen_dev, sc->axen_phyno,
AXEN_GMII_PHY_PAGE_SELECT, AXEN_GMII_PHY_PGSEL_PAGE0);
+#endif
#if 0 /* XXX: phy hack ? */
axen_miibus_writereg(&sc->axen_dev, sc->axen_phyno, 0x1F, 0x0005);
@@ -628,6 +666,8 @@ axen_attach(struct device *parent, struct device *self,
void *aux)
struct ifnet *ifp;
int i, s;
+ DPRINTFN(2,("%s: %s: enter\n", sc->axen_dev.dv_xname,__func__));
+
sc->axen_unit = self->dv_unit; /*device_get_unit(self);*/
sc->axen_udev = uaa->device;
sc->axen_iface = uaa->iface;
@@ -660,7 +700,7 @@ axen_attach(struct device *parent, struct device *self,
void *aux)
printf("%s: not supported usb bus type", sc->axen_dev.dv_xname);
return;
}
-
+
/* Find endpoints. */
for (i = 0; i < id->bNumEndpoints; i++) {
ed = usbd_interface2endpoint_descriptor(sc->axen_iface, i);
@@ -836,7 +876,8 @@ axen_rx_list_init(struct axen_softc *sc)
struct axen_chain *c;
int i;
- DPRINTF(("%s: %s: enter\n", sc->axen_dev.dv_xname, __func__));
+ DPRINTF(("%s: %s: %d rx list entries of size %u\n",
+ sc->axen_dev.dv_xname, __func__,AXEN_RX_LIST_CNT,sc->axen_bufsz));
cd = &sc->axen_cdata;
for (i = 0; i < AXEN_RX_LIST_CNT; i++) {
@@ -867,7 +908,8 @@ axen_tx_list_init(struct axen_softc *sc)
struct axen_chain *c;
int i;
- DPRINTF(("%s: %s: enter\n", sc->axen_dev.dv_xname, __func__));
+ DPRINTF(("%s: %s: %d tx list entries of size %u\n",
+ sc->axen_dev.dv_xname, __func__,AXEN_TX_LIST_CNT,sc->axen_bufsz));
cd = &sc->axen_cdata;
for (i = 0; i < AXEN_TX_LIST_CNT; i++) {
@@ -916,21 +958,35 @@ axen_rxeof(struct usbd_xfer *xfer, void *priv,
usbd_status status)
DPRINTFN(10,("%s: %s: enter\n", sc->axen_dev.dv_xname,__func__));
- if (usbd_is_dying(sc->axen_udev))
+ if (usbd_is_dying(sc->axen_udev)) {
+ DPRINTFN(15,("%s: %s: usbd_is_dying\n",
+ sc->axen_dev.dv_xname,__func__));
return;
+ }
- if (!(ifp->if_flags & IFF_RUNNING))
+ if (!(ifp->if_flags & IFF_RUNNING)) {
+ DPRINTFN(15,("%s: %s: ! IFF_RUNNING\n",
+ sc->axen_dev.dv_xname,__func__));
return;
+ }
if (status != USBD_NORMAL_COMPLETION) {
+ DPRINTFN(9,("%s: %s: ! USBD_NORMAL_COMPLETION: 0x%x\n",
+ sc->axen_dev.dv_xname,__func__,status));
if (status == USBD_NOT_STARTED || status == USBD_CANCELLED)
return;
if (usbd_ratecheck(&sc->axen_rx_notice)) {
printf("%s: usb errors on rx: %s\n",
sc->axen_dev.dv_xname, usbd_errstr(status));
}
- if (status == USBD_STALLED)
-
usbd_clear_endpoint_stall_async(sc->axen_ep[AXEN_ENDPT_RX]);
+ if (status == USBD_STALLED) {
+ DPRINTFN(9,("%s: %s: USBD_STALLED\n",
+ sc->axen_dev.dv_xname,__func__));
+ usbd_clear_endpoint_stall_async(
+ sc->axen_ep[AXEN_ENDPT_RX]);
+ }
+ DPRINTFN(10,("%s: %s: ! USBD_NORMAL_COMPLETION: done\n",
+ sc->axen_dev.dv_xname,__func__));
goto done;
}
@@ -975,6 +1031,10 @@ axen_rxeof(struct usbd_xfer *xfer, void *priv,
usbd_status status)
/* sanity check */
if (hdr_offset > total_len - sizeof(rx_hdr)) {
+ DPRINTFN(7,("%s: %s: hdr_offset (%u) > total_len (%u)"
+ " - sizeof(pkt_hdr) (%lu)\n",
+ sc->axen_dev.dv_xname,__func__,hdr_offset,total_len,
+ sizeof(rx_hdr)));
ifp->if_ierrors++;
goto done;
}
@@ -985,7 +1045,7 @@ axen_rxeof(struct usbd_xfer *xfer, void *priv, usbd_status
status)
#ifdef AXEN_DEBUG
#define AXEN_MAX_PACKED_PACKET 200
if (pkt_count > AXEN_MAX_PACKED_PACKET) {
- DPRINTF(("Too many packets (%d) in a transaction, discard.\n",
+ DPRINTF(("Too many packets (%d) in a transaction, discard.\n",
pkt_count));
ifp->if_ierrors += pkt_count;
goto done;
@@ -995,6 +1055,8 @@ axen_rxeof(struct usbd_xfer *xfer, void *priv, usbd_status
status)
* ax88179 will pack multiple ip packet to a USB transaction.
* process all of packets in the buffer
*/
+ DPRINTFN(10,("%s: %s: pkt_count = %u\n",
+ sc->axen_dev.dv_xname,__func__,pkt_count));
while(pkt_count--) {
/* verify the header offset */
if (hdr_p >= hdr_end) {
@@ -1008,7 +1070,7 @@ axen_rxeof(struct usbd_xfer *xfer, void *priv,
usbd_status status)
pkt_len = (pkt_hdr >> 16) & 0x1fff;
DPRINTFN(10,("rxeof: packet#%d, pkt_hdr 0x%08x, pkt_len %zu\n",
- pkt_count, pkt_hdr, pkt_len));
+ pkt_count, pkt_hdr, pkt_len));
/* verify the data length */
if ((void *)buf + pkt_len > (void *)hdr_p) {
@@ -1038,18 +1100,17 @@ axen_rxeof(struct usbd_xfer *xfer, void *priv,
usbd_status status)
DPRINTFN(7,("\n"));
#endif
ifp->if_ierrors++;
+ /* move to next pkt header */
goto nextpkt;
}
#ifdef AXEN_TOE
/* cheksum err */
- if ((pkt_hdr & AXEN_RXHDR_L3CSUM_ERR) ||
+ if ((pkt_hdr & AXEN_RXHDR_L3CSUM_ERR) ||
(pkt_hdr & AXEN_RXHDR_L4CSUM_ERR)) {
printf("%s: checksum err (pkt#%d)\n",
sc->axen_dev.dv_xname, pkt_count);
goto nextpkt;
- } else {
- m->m_pkthdr.csum_flags |= M_IPV4_CSUM_IN_OK;
}
#endif
@@ -1067,11 +1128,42 @@ axen_rxeof(struct usbd_xfer *xfer, void *priv,
usbd_status status)
goto input;
}
+#if 0 /* ifdef AXEN_TOE */
+ switch ((pkt_hdr & AXEN_RXHDR_L3_TYPE_MASK) >>
+ AXEN_RXHDR_L3_TYPE_OFFSET) {
+ case AXEN_RXHDR_L3_TYPE_IPV4:
+ m->m_pkthdr.csum_flags |= M_IPV4_CSUM_IN_OK;
+ break;
+ case AXEN_RXHDR_L3_TYPE_IPV6:
+ /* XXX IPV6 equivalent of M_IPV4_CSUM_IN_OK? */
+ break;
+ default:
+ /* do we need to set something here? */
+ break;
+ }
+
+ switch ((pkt_hdr & AXEN_RXHDR_L4_TYPE_MASK) >>
+ AXEN_RXHDR_L4_TYPE_OFFSET) {
+ case AXEN_RXHDR_L4_TYPE_ICMP:
+ m->m_pkthdr.csum_flags |= M_ICMP_CSUM_IN_OK;
+ break;
+ case AXEN_RXHDR_L4_TYPE_UDP:
+ m->m_pkthdr.csum_flags |= M_UDP_CSUM_IN_OK;
+ break;
+ case AXEN_RXHDR_L4_TYPE_TCP:
+ m->m_pkthdr.csum_flags |= M_TCP_CSUM_IN_OK;
+ break;
+ default:
+ /* do we need to set something here? */
+ break;
+ }
+#endif
+
ml_enqueue(&ml, m);
nextpkt:
/*
- * prepare next packet
+ * prepare next packet
* as each packet will be aligned 8byte boundary,
* need to fix up the start point of the buffer.
*/
@@ -1096,7 +1188,7 @@ done:
USBD_NO_TIMEOUT, axen_rxeof);
usbd_transfer(xfer);
- DPRINTFN(10,("%s: %s: start rx\n", sc->axen_dev.dv_xname, __func__));
+ DPRINTFN(10,("%s: %s: end rx\n", sc->axen_dev.dv_xname, __func__));
}
/*
@@ -1129,7 +1221,8 @@ axen_txeof(struct usbd_xfer *xfer, void *priv,
usbd_status status)
printf("axen%d: usb error on tx: %s\n", sc->axen_unit,
usbd_errstr(status));
if (status == USBD_STALLED)
-
usbd_clear_endpoint_stall_async(sc->axen_ep[AXEN_ENDPT_TX]);
+ usbd_clear_endpoint_stall_async(
+ sc->axen_ep[AXEN_ENDPT_TX]);
splx(s);
return;
}
@@ -1243,6 +1336,8 @@ axen_encap(struct axen_softc *sc, struct mbuf *m, int idx)
/* Transmit */
err = usbd_transfer(c->axen_xfer);
if (err != USBD_IN_PROGRESS) {
+ DPRINTFN(2,("%s: %s: usbd_transfer err = %d\n",
+ sc->axen_dev.dv_xname,__func__, err));
axen_stop(sc);
return EIO;
}
@@ -1305,6 +1400,8 @@ axen_init(void *xsc)
uWord wval;
uint16_t rxmode;
+ DPRINTFN(2,("%s: %s: enter\n", sc->axen_dev.dv_xname,__func__));
+
s = splnet();
/*
@@ -1447,7 +1544,7 @@ axen_watchdog(struct ifnet *ifp)
sc = ifp->if_softc;
ifp->if_oerrors++;
- printf("axen%d: watchdog timeout\n", sc->axen_unit);
+ printf("%s: watchdog timeout\n", sc->axen_dev.dv_xname);
s = splusb();
c = &sc->axen_cdata.axen_tx_chain[0];
@@ -1472,6 +1569,7 @@ axen_stop(struct axen_softc *sc)
u_int16_t ctl;
uWord wval;
+ DPRINTFN(2,("%s: %s: enter\n", sc->axen_dev.dv_xname,__func__));
ifp = &sc->arpcom.ac_if;
ifp->if_timer = 0;
--
2.20.1