Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/usb couple of minor API updates:
details: https://anonhg.NetBSD.org/src/rev/154a99260355
branches: trunk
changeset: 1002447:154a99260355
user: mrg <mrg%NetBSD.org@localhost>
date: Wed Jul 31 23:47:16 2019 +0000
description:
couple of minor API updates:
- change the read/write register callbacks to have the same phy/reg
order as the MII code.
- add "mii_flags" param to usbnet_attach_ifp(). axe(4) wants it.
also:
- add usbnet debug code, sysctl node support
- remove commented DPRINTF()s accidentally left in place
- add usbnet_softc()
- reorder some attach code to be consistent
- re-add USBD_FORCE_SHORT_XFER for axen rx chain
ride 9.99.2 bump.
diffstat:
sys/dev/usb/if_axen.c | 37 ++++++++++++----------------
sys/dev/usb/if_cdce.c | 6 ++--
sys/dev/usb/usbnet.c | 66 +++++++++++++++++++++++++++++++++++++-------------
sys/dev/usb/usbnet.h | 8 +++--
4 files changed, 73 insertions(+), 44 deletions(-)
diffs (truncated from 382 to 300 lines):
diff -r 8b8f2e06807f -r 154a99260355 sys/dev/usb/if_axen.c
--- a/sys/dev/usb/if_axen.c Wed Jul 31 21:50:25 2019 +0000
+++ b/sys/dev/usb/if_axen.c Wed Jul 31 23:47:16 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_axen.c,v 1.51 2019/07/31 09:13:16 mrg Exp $ */
+/* $NetBSD: if_axen.c,v 1.52 2019/07/31 23:47:16 mrg Exp $ */
/* $OpenBSD: if_axen.c,v 1.3 2013/10/21 10:10:22 yuo Exp $ */
/*
@@ -23,7 +23,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_axen.c,v 1.51 2019/07/31 09:13:16 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_axen.c,v 1.52 2019/07/31 23:47:16 mrg Exp $");
#ifdef _KERNEL_OPT
#include "opt_usb.h"
@@ -127,9 +127,9 @@
}
static usbd_status
-axen_mii_read_reg(struct usbnet *un, int reg, int phy, uint16_t *val)
+axen_mii_read_reg(struct usbnet *un, int phy, int reg, uint16_t *val)
{
- struct axen_softc * const sc = un->un_sc;
+ struct axen_softc * const sc = usbnet_softc(un);
uint16_t data;
usbd_status err = axen_cmd(sc, AXEN_CMD_MII_READ_REG, reg, phy, &data);
@@ -144,9 +144,9 @@
}
static usbd_status
-axen_mii_write_reg(struct usbnet *un, int reg, int phy, uint16_t val)
+axen_mii_write_reg(struct usbnet *un, int phy, int reg, uint16_t val)
{
- struct axen_softc * const sc = un->un_sc;
+ struct axen_softc * const sc = usbnet_softc(un);
uint16_t uval = htole16(val);
return axen_cmd(sc, AXEN_CMD_MII_WRITE_REG, reg, phy, &uval);
@@ -156,7 +156,7 @@
axen_miibus_statchg(struct ifnet *ifp)
{
struct usbnet * const un = ifp->if_softc;
- struct axen_softc * const sc = un->un_sc;
+ struct axen_softc * const sc = usbnet_softc(un);
struct mii_data * const mii = usbnet_mii(un);
int err;
uint16_t val;
@@ -215,7 +215,7 @@
static void
axen_setiff_locked(struct usbnet *un)
{
- struct axen_softc * const sc = un->un_sc;
+ struct axen_softc * const sc = usbnet_softc(un);
struct ifnet * const ifp = usbnet_ifp(un);
struct ethercom *ec = &un->un_ec;
struct ether_multi *enm;
@@ -519,7 +519,7 @@
static void
axen_setoe_locked(struct usbnet *un)
{
- struct axen_softc * const sc = un->un_sc;
+ struct axen_softc * const sc = usbnet_softc(un);
struct ifnet * const ifp = usbnet_ifp(un);
uint64_t enabled = ifp->if_capenable;
uint8_t val;
@@ -612,6 +612,9 @@
aprint_naive("\n");
aprint_normal("\n");
+ devinfop = usbd_devinfo_alloc(dev, 0);
+ aprint_normal_dev(self, "%s\n", devinfop);
+ usbd_devinfo_free(devinfop);
un->un_dev = self;
un->un_udev = dev;
@@ -626,10 +629,6 @@
un->un_init_cb = axen_init;
un->un_rx_xfer_flags = USBD_SHORT_XFER_OK;
un->un_tx_xfer_flags = USBD_FORCE_SHORT_XFER;
-
- devinfop = usbd_devinfo_alloc(dev, 0);
- aprint_normal_dev(self, "%s\n", devinfop);
- usbd_devinfo_free(devinfop);
err = usbd_set_config_no(dev, AXEN_CONFIG_NO, 1);
if (err) {
@@ -724,7 +723,7 @@
IFCAP_CSUM_UDPv6_Rx | IFCAP_CSUM_UDPv6_Tx;
usbnet_attach_ifp(un, true, IFF_SIMPLEX | IFF_BROADCAST | IFF_MULTICAST,
- 0);
+ 0, 0);
}
static int
@@ -916,7 +915,7 @@
axen_init_locked(struct ifnet *ifp)
{
struct usbnet * const un = ifp->if_softc;
- struct axen_softc * const sc = un->un_sc;
+ struct axen_softc * const sc = usbnet_softc(un);
uint16_t rxmode;
uint16_t wval;
uint8_t bval;
@@ -953,7 +952,7 @@
usbnet_unlock_mii_un_locked(un);
- return usbnet_init_rx_tx(un, 0, 0);
+ return usbnet_init_rx_tx(un, 0, USBD_FORCE_SHORT_XFER);
}
static int
@@ -968,15 +967,11 @@
return ret;
}
-/*
- * Stop the adapter and free any mbufs allocated to the
- * RX and TX lists.
- */
static void
axen_stop_cb(struct ifnet *ifp, int disable)
{
struct usbnet * const un = ifp->if_softc;
- struct axen_softc * const sc = un->un_sc;
+ struct axen_softc * const sc = usbnet_softc(un);
uint16_t rxmode, wval;
axen_reset(sc);
diff -r 8b8f2e06807f -r 154a99260355 sys/dev/usb/if_cdce.c
--- a/sys/dev/usb/if_cdce.c Wed Jul 31 21:50:25 2019 +0000
+++ b/sys/dev/usb/if_cdce.c Wed Jul 31 23:47:16 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_cdce.c,v 1.54 2019/07/31 09:13:16 mrg Exp $ */
+/* $NetBSD: if_cdce.c,v 1.55 2019/07/31 23:47:16 mrg Exp $ */
/*
* Copyright (c) 1997, 1998, 1999, 2000-2003 Bill Paul <wpaul%windriver.com@localhost>
@@ -40,7 +40,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_cdce.c,v 1.54 2019/07/31 09:13:16 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_cdce.c,v 1.55 2019/07/31 23:47:16 mrg Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@@ -254,7 +254,7 @@
usbnet_attach(un, "cdcedet", CDCE_RX_LIST_CNT, CDCE_TX_LIST_CNT);
usbnet_attach_ifp(un, false, IFF_SIMPLEX | IFF_BROADCAST | IFF_MULTICAST,
- 0);
+ 0, 0);
}
static int
diff -r 8b8f2e06807f -r 154a99260355 sys/dev/usb/usbnet.c
--- a/sys/dev/usb/usbnet.c Wed Jul 31 21:50:25 2019 +0000
+++ b/sys/dev/usb/usbnet.c Wed Jul 31 23:47:16 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: usbnet.c,v 1.1 2019/07/31 09:13:16 mrg Exp $ */
+/* $NetBSD: usbnet.c,v 1.2 2019/07/31 23:47:16 mrg Exp $ */
/*
* Copyright (c) 2019 Matthew R. Green
@@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: usbnet.c,v 1.1 2019/07/31 09:13:16 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usbnet.c,v 1.2 2019/07/31 23:47:16 mrg Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@@ -44,8 +44,46 @@
static int usbnet_modcmd(modcmd_t, void *);
-#define DPRINTF(fmt, ...) \
- printf("%s:%d: " fmt "\n", __func__, __LINE__, ## __VA_ARGS__)
+#ifdef USB_DEBUG
+#ifndef USBNET_DEBUG
+#define usbnetdebug 0
+#else
+static int usbnetdebug = 20;
+
+SYSCTL_SETUP(sysctl_hw_usbnet_setup, "sysctl hw.usbnet setup")
+{
+ int err;
+ const struct sysctlnode *rnode;
+ const struct sysctlnode *cnode;
+
+ err = sysctl_createv(clog, 0, NULL, &rnode,
+ CTLFLAG_PERMANENT, CTLTYPE_NODE, "usbnet",
+ SYSCTL_DESCR("usbnet global controls"),
+ NULL, 0, NULL, 0, CTL_HW, CTL_CREATE, CTL_EOL);
+
+ if (err)
+ goto fail;
+
+ /* control debugging printfs */
+ err = sysctl_createv(clog, 0, &rnode, &cnode,
+ CTLFLAG_PERMANENT | CTLFLAG_READWRITE, CTLTYPE_INT,
+ "debug", SYSCTL_DESCR("Enable debugging output"),
+ NULL, 0, &usbnetdebug, sizeof(usbnetdebug), CTL_CREATE, CTL_EOL);
+ if (err)
+ goto fail;
+
+ return;
+fail:
+ aprint_error("%s: sysctl_createv failed (err = %d)\n", __func__, err);
+}
+
+#endif /* USBNET_DEBUG */
+#endif /* USB_DEBUG */
+
+#define DPRINTF(FMT,A,B,C,D) USBHIST_LOGN(usbnetdebug,1,FMT,A,B,C,D)
+#define DPRINTFN(N,FMT,A,B,C,D) USBHIST_LOGN(usbnetdebug,N,FMT,A,B,C,D)
+#define USBNETHIST_FUNC() USBHIST_FUNC()
+#define USBNETHIST_CALLED(name) USBHIST_CALLED(usbnetdebug)
/* Interrupt handling. */
@@ -83,7 +121,6 @@
struct ifnet *ifp = &un->un_ec.ec_if;
struct mbuf *m;
-//DPRINTF("enter");
KASSERT(mutex_owned(&un->un_rxlock));
m = usbnet_newbuf();
@@ -113,7 +150,6 @@
struct ifnet *ifp = &un->un_ec.ec_if;
uint32_t total_len;
-//DPRINTF("enter");
mutex_enter(&un->un_rxlock);
if (un->un_dying || un->un_stopping ||
@@ -166,7 +202,6 @@
struct usbnet_cdata *cd = &un->un_cdata;
struct ifnet * const ifp = usbnet_ifp(un);
-//DPRINTF("enter");
mutex_enter(&un->un_txlock);
if (un->un_stopping || un->un_dying) {
mutex_exit(&un->un_txlock);
@@ -213,7 +248,6 @@
unsigned length;
int idx;
-//DPRINTF("enter");
KASSERT(mutex_owned(&un->un_txlock));
KASSERT(cd->uncd_tx_cnt <= cd->uncd_tx_list_cnt);
@@ -221,7 +255,6 @@
return;
idx = cd->uncd_tx_prod;
-//DPRINTF("idx %d", idx);
while (cd->uncd_tx_cnt < cd->uncd_tx_list_cnt) {
IFQ_POLL(&ifp->if_snd, m);
if (m == NULL)
@@ -262,7 +295,6 @@
idx = (idx + 1) % cd->uncd_tx_list_cnt;
cd->uncd_tx_cnt++;
}
-//DPRINTF("idx %d", idx);
cd->uncd_tx_prod = idx;
/*
@@ -276,7 +308,6 @@
{
struct usbnet * const un = ifp->if_softc;
-//DPRINTF("enter");
mutex_enter(&un->un_txlock);
if (!un->un_stopping)
usbnet_start_locked(ifp);
@@ -596,7 +627,7 @@
mutex_exit(&un->un_lock);
usbnet_lock_mii(un);
- err = (*un->un_read_reg_cb)(un, reg, phy, val);
+ err = (*un->un_read_reg_cb)(un, phy, reg, val);
usbnet_unlock_mii(un);
if (err) {
@@ -621,7 +652,7 @@
mutex_exit(&un->un_lock);
usbnet_lock_mii(un);
- err = (*un->un_write_reg_cb)(un, reg, phy, val);
+ err = (*un->un_write_reg_cb)(un, phy, reg, val);
usbnet_unlock_mii(un);
Home |
Main Index |
Thread Index |
Old Index