Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src-draft/trunk]: src/sys/dev/usb Adapt USBHIST based debug output from -cur...



details:   https://anonhg.NetBSD.org/src-all/rev/64f8b616f297
branches:  trunk
changeset: 360371:64f8b616f297
user:      Martin Husemann <martin%NetBSD.org@localhost>
date:      Tue Jan 18 19:30:49 2022 +0100

description:
Adapt USBHIST based debug output from -current

diffstat:

 sys/dev/usb/if_urtwn.c |  362 +++++++++++++++++++++++++-----------------------
 1 files changed, 188 insertions(+), 174 deletions(-)

diffs (truncated from 1109 to 300 lines):

diff -r 9f3a7100b926 -r 64f8b616f297 sys/dev/usb/if_urtwn.c
--- a/sys/dev/usb/if_urtwn.c    Sat Jan 15 20:30:15 2022 +0100
+++ b/sys/dev/usb/if_urtwn.c    Tue Jan 18 19:30:49 2022 +0100
@@ -85,6 +85,7 @@
 #include <dev/firmload.h>
 
 #include <dev/usb/usbwifi.h>
+#include <dev/usb/usbhist.h>
 
 #include <dev/ic/rtwnreg.h>
 #include <dev/ic/rtwn_data.h>
@@ -101,10 +102,27 @@
 #define DBG_REG        __BIT(6)
 #define DBG_ALL        0xffffffffU
 u_int urtwn_debug = 0;
-#define DPRINTFN(n, s) \
-       do { if (urtwn_debug & (n)) printf s; } while (/*CONSTCOND*/0)
+#define DPRINTFN(n, fmt, a, b, c, d) do {                      \
+       if (urtwn_debug & (n)) {                                \
+               KERNHIST_LOG(usbhist, fmt, a, b, c, d);         \
+       }                                                       \
+} while (/*CONSTCOND*/0)
+#define URTWNHIST_FUNC() USBHIST_FUNC()
+#define URTWNHIST_CALLED() do {                                        \
+       if (urtwn_debug & DBG_FN) {                             \
+               KERNHIST_CALLED(usbhist);                       \
+       }                                                       \
+} while(/*CONSTCOND*/0)
+#define URTWNHIST_CALLARGS(fmt, a, b, c, d) do {               \
+       if (urtwn_debug & DBG_FN) {                             \
+               KERNHIST_CALLARGS(usbhist, fmt, a, b, c, d);    \
+       }                                                       \
+} while(/*CONSTCOND*/0)
 #else
-#define DPRINTFN(n, s)
+#define DPRINTFN(n, fmt, a, b, c, d)
+#define URTWNHIST_FUNC()
+#define URTWNHIST_CALLED()
+#define URTWNHIST_CALLARGS(fmt, a, b, c, d)
 #endif
 
 #define URTWN_DEV(v,p) { { USB_VENDOR_##v, USB_PRODUCT_##v##_##p }, 0 }
@@ -375,6 +393,8 @@
        // NNN loop below size_t i;
        int error, num_rx, num_tx;
 
+       URTWNHIST_FUNC(); URTWNHIST_CALLED();
+
        /*
         * Generic usbwifi(9) setup
         */
@@ -400,9 +420,6 @@
        aprint_naive("\n");
        aprint_normal("\n");
 
-       DPRINTFN(DBG_FN, ("%s: %s\n", device_xname(sc->sc_uw.uw_dev),
-           __func__));
-
        devinfop = usbd_devinfo_alloc(sc->sc_uw.uw_udev, 0);
        aprint_normal_dev(self, "%s\n", devinfop);
        usbd_devinfo_free(devinfop);
@@ -567,7 +584,7 @@
 {
        struct urtwn_softc *sc = device_private(self);
 
-       DPRINTFN(DBG_FN, ("%s: %s\n", device_xname(sc->sc_uw.uw_dev), __func__));
+       URTWNHIST_FUNC(); URTWNHIST_CALLED();
 
        usbwifi_set_dying(&sc->sc_uw, true);
 
@@ -597,7 +614,7 @@
        usb_endpoint_descriptor_t *ed;
        size_t i, ntx = 0, nrx = 0;
 
-       DPRINTFN(DBG_FN, ("%s: %s\n", device_xname(sc->sc_uw.uw_dev), __func__));
+       URTWNHIST_FUNC(); URTWNHIST_CALLED();
 
        /* Determine the number of bulk-out pipes. */
        id = usbd_get_interface_descriptor(sc->sc_uw.uw_iface);
@@ -634,8 +651,8 @@
                return EIO;
        }
 
-       DPRINTFN(DBG_INIT, ("%s: %s: found %zd/%zd bulk-in/out pipes\n",
-           device_xname(sc->sc_uw.uw_dev), __func__, nrx, ntx));
+       DPRINTFN(DBG_INIT, "found %jd/%jd bulk-in/out pipes",
+           nrx, ntx, 0, 0);
        *num_rx = nrx;
        *num_tx = ntx;
        memcpy(&sc->sc_uw.uw_ed[0], epaddr, sizeof(epaddr[0])*ntx);
@@ -666,7 +683,8 @@
        struct urtwn_host_cmd *cmd;
        int s;
 
-       DPRINTFN(DBG_FN, ("%s: %s\n", device_xname(sc->sc_uw.uw_dev), __func__));
+       URTWNHIST_FUNC(); URTWNHIST_CALLED();
+
        if (vap->iv_state == IEEE80211_S_RUN && 
            (ic->ic_opmode == IEEE80211_M_HOSTAP ||
            ic->ic_opmode == IEEE80211_M_IBSS)) {
@@ -717,8 +735,9 @@
        struct urtwn_host_cmd *cmd;
        int s;
 
-       DPRINTFN(DBG_FN, ("%s: %s: cb=%p, arg=%p, len=%d\n",
-           device_xname(sc->sc_uw.uw_dev), __func__, cb, arg, len));
+       URTWNHIST_FUNC(); URTWNHIST_CALLED();
+       DPRINTFN(DBG_FN, "cb=%jd, arg=%jd, len=%jd", (intptr_t)cb,
+           (intptr_t)arg, len, 0);
 
        s = splusb();
        mutex_spin_enter(&sc->sc_task_mtx);
@@ -741,7 +760,7 @@
 urtwn_wait_async(struct urtwn_softc *sc)
 {
 
-       DPRINTFN(DBG_FN, ("%s: %s\n", device_xname(sc->sc_uw.uw_dev), __func__));
+       URTWNHIST_FUNC(); URTWNHIST_CALLED();
 
        /* Wait for all queued asynchronous commands to complete. */
        while (sc->cmdq.queued > 0)
@@ -755,6 +774,7 @@
        usb_device_request_t req;
        usbd_status error;
 
+       URTWNHIST_FUNC(); URTWNHIST_CALLED();
        usbwifi_isowned_core(&sc->sc_uw);
 
        req.bmRequestType = UT_WRITE_VENDOR_DEVICE;
@@ -764,8 +784,8 @@
        USETW(req.wLength, len);
        error = usbd_do_request(sc->sc_uw.uw_udev, &req, buf);
        if (error != USBD_NORMAL_COMPLETION) {
-               DPRINTFN(DBG_REG, ("%s: %s: error=%d: addr=%#x, len=%d\n",
-                   device_xname(sc->sc_uw.uw_dev), __func__, error, addr, len));
+               DPRINTFN(DBG_REG, "error=%jd: addr=%#jx, len=%jd",
+                   error, (intptr_t)addr, len, 0);
        }
        return error;
 }
@@ -774,8 +794,8 @@
 urtwn_write_1(struct urtwn_softc *sc, uint16_t addr, uint8_t val)
 {
 
-       DPRINTFN(DBG_REG, ("%s: %s: addr=%#x, val=%#x\n",
-           device_xname(sc->sc_uw.uw_dev), __func__, addr, val));
+       URTWNHIST_FUNC(); URTWNHIST_CALLED();
+       DPRINTFN(DBG_REG, "addr=%#jx, val=%#jx", (intptr_t)addr, val, 0, 0);
 
        urtwn_write_region_1(sc, addr, &val, 1);
 }
@@ -785,8 +805,8 @@
 {
        uint8_t buf[2];
 
-       DPRINTFN(DBG_REG, ("%s: %s: addr=%#x, val=%#x\n",
-           device_xname(sc->sc_uw.uw_dev), __func__, addr, val));
+       URTWNHIST_FUNC(); URTWNHIST_CALLED();
+       DPRINTFN(DBG_REG, "addr=%#jx, val=%#jx", (intptr_t)addr, val, 0, 0);
 
        buf[0] = (uint8_t)val;
        buf[1] = (uint8_t)(val >> 8);
@@ -798,8 +818,8 @@
 {
        uint8_t buf[4];
 
-       DPRINTFN(DBG_REG, ("%s: %s: addr=%#x, val=%#x\n",
-           device_xname(sc->sc_uw.uw_dev), __func__, addr, val));
+       URTWNHIST_FUNC(); URTWNHIST_CALLED();
+       DPRINTFN(DBG_REG, "addr=%#jx, val=%#jx", (intptr_t)addr, val, 0, 0);
 
        buf[0] = (uint8_t)val;
        buf[1] = (uint8_t)(val >> 8);
@@ -813,8 +833,8 @@
     int len)
 {
 
-       DPRINTFN(DBG_REG, ("%s: %s: addr=%#x, len=%#x\n",
-           device_xname(sc->sc_uw.uw_dev), __func__, addr, len));
+       URTWNHIST_FUNC(); URTWNHIST_CALLED();
+       DPRINTFN(DBG_REG, "addr=%#jx, len=%#jx", (intptr_t)addr, len, 0, 0);
 
        return urtwn_write_region_1(sc, addr, buf, len);
 }
@@ -826,6 +846,7 @@
        usb_device_request_t req;
        usbd_status error;
 
+       URTWNHIST_FUNC(); URTWNHIST_CALLED();
        usbwifi_isowned_core(&sc->sc_uw);
 
        req.bmRequestType = UT_READ_VENDOR_DEVICE;
@@ -835,8 +856,8 @@
        USETW(req.wLength, len);
        error = usbd_do_request(sc->sc_uw.uw_udev, &req, buf);
        if (error != USBD_NORMAL_COMPLETION) {
-               DPRINTFN(DBG_REG, ("%s: %s: error=%d: addr=%#x, len=%d\n",
-                   device_xname(sc->sc_uw.uw_dev), __func__, error, addr, len));
+               DPRINTFN(DBG_REG, "error=%jd: addr=%#jx, len=%jd",
+                   error, (intptr_t)addr, len, 0);
        }
        return error;
 }
@@ -846,11 +867,13 @@
 {
        uint8_t val;
 
+       URTWNHIST_FUNC(); URTWNHIST_CALLED();
+
        if (urtwn_read_region_1(sc, addr, &val, 1) != USBD_NORMAL_COMPLETION)
                return 0xff;
 
-       DPRINTFN(DBG_REG, ("%s: %s: addr=%#x, val=%#x\n",
-           device_xname(sc->sc_uw.uw_dev), __func__, addr, val));
+       DPRINTFN(DBG_REG, "addr=%#jx, val=%#jx",
+           (intptr_t)addr, val, 0, 0);
        return val;
 }
 
@@ -860,12 +883,13 @@
        uint8_t buf[2];
        uint16_t val;
 
+       URTWNHIST_FUNC(); URTWNHIST_CALLED();
+
        if (urtwn_read_region_1(sc, addr, buf, 2) != USBD_NORMAL_COMPLETION)
                return 0xffff;
 
        val = LE_READ_2(&buf[0]);
-       DPRINTFN(DBG_REG, ("%s: %s: addr=%#x, val=%#x\n",
-           device_xname(sc->sc_uw.uw_dev), __func__, addr, val));
+       DPRINTFN(DBG_REG, "addr=%#jx, val=%#jx", (intptr_t)addr, val, 0, 0);
        return val;
 }
 
@@ -875,12 +899,13 @@
        uint8_t buf[4];
        uint32_t val;
 
+       URTWNHIST_FUNC(); URTWNHIST_CALLED();
+
        if (urtwn_read_region_1(sc, addr, buf, 4) != USBD_NORMAL_COMPLETION)
                return 0xffffffff;
 
        val = LE_READ_4(&buf[0]);
-       DPRINTFN(DBG_REG, ("%s: %s: addr=%#x, val=%#x\n",
-           device_xname(sc->sc_uw.uw_dev), __func__, addr, val));
+       DPRINTFN(DBG_REG, "addr=%#jx, val=%#jx", (intptr_t)addr, val, 0, 0);
        return val;
 }
 
@@ -892,8 +917,9 @@
        int fwcur;
        int ntries;
 
-       DPRINTFN(DBG_REG, ("%s: %s: id=%d, buf=%p, len=%d\n",
-           device_xname(sc->sc_uw.uw_dev), __func__, id, buf, len));
+       URTWNHIST_FUNC(); URTWNHIST_CALLED();
+       DPRINTFN(DBG_REG, "id=%jd, buf=%#jx, len=%jd", id, (intptr_t)buf,
+           len, 0);
 
        usbwifi_isowned_core(&sc->sc_uw);
 
@@ -1065,7 +1091,7 @@
        uint8_t off, msk;
        size_t i;
 
-       DPRINTFN(DBG_FN, ("%s: %s\n", device_xname(sc->sc_uw.uw_dev), __func__));
+       URTWNHIST_FUNC(); URTWNHIST_CALLED();
 
        usbwifi_isowned_core(&sc->sc_uw);
 
@@ -1128,7 +1154,7 @@
 {
        uint32_t reg;
 
-       DPRINTFN(DBG_FN, ("%s: %s\n", device_xname(sc->sc_uw.uw_dev), __func__));
+       URTWNHIST_FUNC(); URTWNHIST_CALLED();
 
        if (ISSET(sc->chip, URTWN_CHIP_88E) ||
            ISSET(sc->chip, URTWN_CHIP_92EU))
@@ -1247,7 +1273,7 @@
        struct ieee80211com *ic = &sc->sc_uw.uw_ic;
        struct r92c_rom *rom = &sc->rom;
 
-       DPRINTFN(DBG_FN, ("%s: %s\n", device_xname(sc->sc_uw.uw_dev), __func__));
+       URTWNHIST_FUNC(); URTWNHIST_CALLED();
 
        usbwifi_isowned_core(&sc->sc_uw);
 
@@ -1264,15 +1290,13 @@
        sc->regulatory = MS(rom->rf_opt1, R92C_ROM_RF1_REGULATORY);
 
        DPRINTFN(DBG_INIT,
-           ("%s: %s: PA setting=%#x, board=%#x, regulatory=%d\n",
-           device_xname(sc->sc_uw.uw_dev), __func__, sc->pa_setting,
-           sc->board_type, sc->regulatory));
+           "PA setting=%#jx, board=%#jx, regulatory=%jd",
+           sc->pa_setting, sc->board_type, sc->regulatory, 0);
 



Home | Main Index | Thread Index | Old Index