PERFORCE change 135289 for review

Sepherosa Ziehau sephe at FreeBSD.org
Tue Feb 12 21:25:44 PST 2008


http://perforce.freebsd.org/chv.cgi?CH=135289

Change 135289 by sephe at sephe_zealot:sam_wifi on 2008/02/13 05:25:27

	Modulize debug prints.
	
	Obtained from:	DragonFly

Affected files ...

.. //depot/projects/wifi/sys/dev/bwi/bwimac.c#3 edit
.. //depot/projects/wifi/sys/dev/bwi/bwirf.c#4 edit
.. //depot/projects/wifi/sys/dev/bwi/if_bwi.c#10 edit
.. //depot/projects/wifi/sys/dev/bwi/if_bwivar.h#6 edit

Differences ...

==== //depot/projects/wifi/sys/dev/bwi/bwimac.c#3 (text+ko) ====

@@ -485,10 +485,12 @@
 	CSR_WRITE_4(sc, BWI_MAC_STATUS, status);
 
 	if (link_phy) {
-		DPRINTF(sc, "%s\n", "PHY is linked");
+		DPRINTF(sc, BWI_DBG_MAC | BWI_DBG_ATTACH | BWI_DBG_INIT,
+			"%s\n", "PHY is linked");
 		mac->mac_phy.phy_flags |= BWI_PHY_F_LINKED;
 	} else {
-		DPRINTF(sc, "%s\n", "PHY is unlinked");
+		DPRINTF(sc, BWI_DBG_MAC | BWI_DBG_ATTACH | BWI_DBG_INIT,
+			"%s\n", "PHY is unlinked");
 		mac->mac_phy.phy_flags &= ~BWI_PHY_F_LINKED;
 	}
 }
@@ -679,7 +681,8 @@
 		break;
 	}
 back:
-	DPRINTF(sc, "bbp atten: %u, rf atten: %u, ctrl1: %u, ctrl2: %u\n",
+	DPRINTF(sc, BWI_DBG_MAC | BWI_DBG_INIT | BWI_DBG_TXPOWER,
+		"bbp atten: %u, rf atten: %u, ctrl1: %u, ctrl2: %u\n",
 		tpctl->bbp_atten, tpctl->rf_atten,
 		tpctl->tp_ctrl1, tpctl->tp_ctrl2);
 }
@@ -802,7 +805,8 @@
 
 	mac->mac_flags |= BWI_MAC_F_TPCTL_INITED;
 	rf->rf_base_tssi = PHY_READ(mac, 0x29);
-	DPRINTF(sc, "base tssi %d\n", rf->rf_base_tssi);
+	DPRINTF(sc, BWI_DBG_MAC | BWI_DBG_INIT | BWI_DBG_TXPOWER,
+		"base tssi %d\n", rf->rf_base_tssi);
 
 	if (abs(rf->rf_base_tssi - rf->rf_idle_tssi) >= 20) {
 		device_printf(sc->sc_dev, "base tssi measure failed\n");
@@ -1127,7 +1131,8 @@
 	/* Get the number of IVs in the IV image */
 	hdr = (const struct bwi_fwhdr *)fw->data;
 	n = be32toh(hdr->fw_iv_cnt);
-	DPRINTF(sc, "IV count %d\n", n);
+	DPRINTF(sc, BWI_DBG_MAC | BWI_DBG_INIT | BWI_DBG_FIRMWARE,
+		"IV count %d\n", n);
 
 	/* Calculate the IV image size, for later sanity check */
 	iv_img_size = fw->datasize - sizeof(*hdr);
@@ -1530,7 +1535,8 @@
 	 */
 	val = CSR_READ_4(sc, BWI_MAC_STATUS);
 	if (val & BWI_MAC_STATUS_BSWAP) {
-		DPRINTF(sc, "%s\n", "need byte swap");
+		DPRINTF(sc, BWI_DBG_MAC | BWI_DBG_ATTACH, "%s\n",
+			"need byte swap");
 		mac->mac_flags |= BWI_MAC_F_BSWAP;
 	}
 
@@ -1544,7 +1550,8 @@
 	    BWI_STATE_HI_FLAG_64BIT) {
 		/* 64bit address */
 		sc->sc_bus_space = BWI_BUS_SPACE_64BIT;
-		DPRINTF(sc, "%s\n", "64bit bus space");
+		DPRINTF(sc, BWI_DBG_MAC | BWI_DBG_ATTACH, "%s\n",
+			"64bit bus space");
 	} else {
 		uint32_t txrx_reg = BWI_TXRX_CTRL_BASE + BWI_TX32_CTRL;
 
@@ -1552,11 +1559,13 @@
 		if (CSR_READ_4(sc, txrx_reg) & BWI_TXRX32_CTRL_ADDRHI_MASK) {
 			/* 32bit address */
 			sc->sc_bus_space = BWI_BUS_SPACE_32BIT;
-			DPRINTF(sc, "%s\n", "32bit bus space");
+			DPRINTF(sc, BWI_DBG_MAC | BWI_DBG_ATTACH, "%s\n",
+				"32bit bus space");
 		} else {
 			/* 30bit address */
 			sc->sc_bus_space = BWI_BUS_SPACE_30BIT;
-			DPRINTF(sc, "%s\n", "30bit bus space");
+			DPRINTF(sc, BWI_DBG_MAC | BWI_DBG_ATTACH, "%s\n",
+				"30bit bus space");
 		}
 	}
 
@@ -1604,7 +1613,8 @@
 	 */
 	if (sc->sc_nmac != 0 &&
 	    sc->sc_pci_did != PCI_PRODUCT_BROADCOM_BCM4309) {
-		DPRINTF(sc, "%s\n", "ignore second MAC");
+		DPRINTF(sc, BWI_DBG_MAC | BWI_DBG_ATTACH, "%s\n",
+			"ignore second MAC");
 		return 0;
 	}
 
@@ -1637,7 +1647,8 @@
 
 	if (mac->mac_rev < 5) {
 		mac->mac_flags |= BWI_MAC_F_HAS_TXSTATS;
-		DPRINTF(sc, "%s\n", "has TX stats");
+		DPRINTF(sc, BWI_DBG_MAC | BWI_DBG_ATTACH, "%s\n",
+			"has TX stats");
 	}
 
 	device_printf(sc->sc_dev, "MAC: rev %u\n", rev);
@@ -1769,12 +1780,14 @@
 	int txpwr_diff, rf_atten_adj, bbp_atten_adj;
 
 	if (mac->mac_flags & BWI_MAC_F_TPCTL_ERROR) {
-		DPRINTF(sc, "%s\n", "tpctl error happened, can't set txpower");
+		DPRINTF(sc, BWI_DBG_MAC | BWI_DBG_TXPOWER, "%s\n",
+			"tpctl error happened, can't set txpower");
 		return;
 	}
 
 	if (BWI_IS_BRCM_BU4306(sc)) {
-		DPRINTF(sc, "%s\n", "BU4306, can't set txpower");
+		DPRINTF(sc, BWI_DBG_MAC | BWI_DBG_TXPOWER, "%s\n",
+			"BU4306, can't set txpower");
 		return;
 	}
 
@@ -1784,7 +1797,8 @@
 	ofdm_tssi = 0;
 	error = bwi_rf_get_latest_tssi(mac, tssi, BWI_COMM_MOBJ_TSSI_DS);
 	if (error) {
-		DPRINTF(sc, "%s\n", "no DS tssi");
+		DPRINTF(sc, BWI_DBG_MAC | BWI_DBG_TXPOWER, "%s\n",
+			"no DS tssi");
 
 		if (mac->mac_phy.phy_mode == IEEE80211_MODE_11B)
 			return;
@@ -1792,7 +1806,8 @@
 		error = bwi_rf_get_latest_tssi(mac, tssi,
 				BWI_COMM_MOBJ_TSSI_OFDM);
 		if (error) {
-			DPRINTF(sc, "%s\n", "no OFDM tssi");
+			DPRINTF(sc, BWI_DBG_MAC | BWI_DBG_TXPOWER, "%s\n",
+				"no OFDM tssi");
 			return;
 		}
 
@@ -1804,7 +1819,8 @@
 	}
 	bwi_rf_clear_tssi(mac);
 
-	DPRINTF(sc, "tssi0 %d, tssi1 %d, tssi2 %d, tssi3 %d\n",
+	DPRINTF(sc, BWI_DBG_MAC | BWI_DBG_TXPOWER,
+		"tssi0 %d, tssi1 %d, tssi2 %d, tssi3 %d\n",
 		tssi[0], tssi[1], tssi[2], tssi[3]);
 
 	/*
@@ -1817,12 +1833,13 @@
 	if (ofdm_tssi && (HFLAGS_READ(mac) & BWI_HFLAG_PWR_BOOST_DS))
 		tssi_avg -= 13;
 
-	DPRINTF(sc, "tssi avg %d\n", tssi_avg);
+	DPRINTF(sc, BWI_DBG_MAC | BWI_DBG_TXPOWER, "tssi avg %d\n", tssi_avg);
 
 	error = bwi_rf_tssi2dbm(mac, tssi_avg, &cur_txpwr);
 	if (error)
 		return;
-	DPRINTF(sc, "current txpower %d\n", cur_txpwr);
+	DPRINTF(sc, BWI_DBG_MAC | BWI_DBG_TXPOWER, "current txpower %d\n",
+		cur_txpwr);
 
 	txpwr_diff = rf->rf_txpower_max - cur_txpwr; /* XXX ni_txpower */
 
@@ -1831,12 +1848,14 @@
 			(BWI_RF_ATTEN_FACTOR * rf_atten_adj);
 
 	if (rf_atten_adj == 0 && bbp_atten_adj == 0) {
-		DPRINTF(sc, "%s\n", "no need to adjust RF/BBP attenuation");
+		DPRINTF(sc, BWI_DBG_MAC | BWI_DBG_TXPOWER, "%s\n",
+			"no need to adjust RF/BBP attenuation");
 		/* TODO: LO */
 		return;
 	}
 
-	DPRINTF(sc, "rf atten adjust %d, bbp atten adjust %d\n",
+	DPRINTF(sc, BWI_DBG_MAC | BWI_DBG_TXPOWER,
+		"rf atten adjust %d, bbp atten adjust %d\n",
 		rf_atten_adj, bbp_atten_adj);
 	bwi_mac_adjust_tpctl(mac, rf_atten_adj, bbp_atten_adj);
 	/* TODO: LO */

==== //depot/projects/wifi/sys/dev/bwi/bwirf.c#4 (text+ko) ====

@@ -490,7 +490,8 @@
 	 */
 	rf->rf_lo_gain = (loop2 * 6) - (loop1 * 4) - 11;
 	rf->rf_rx_gain = trsw * 2;
-	DPRINTF(mac->mac_sc, "lo gain: %u, rx gain: %u\n",
+	DPRINTF(mac->mac_sc, BWI_DBG_RF | BWI_DBG_INIT,
+		"lo gain: %u, rx gain: %u\n",
 		rf->rf_lo_gain, rf->rf_rx_gain);
 
 #undef SAVE_RF_MAX
@@ -934,7 +935,8 @@
 	else
 		rf->rf_calib = calib;
 	if (rf->rf_calib != 0xffff) {
-		DPRINTF(sc, "RF calibration value: 0x%04x\n", rf->rf_calib);
+		DPRINTF(sc, BWI_DBG_RF | BWI_DBG_INIT,
+			"RF calibration value: 0x%04x\n", rf->rf_calib);
 		rf->rf_flags |= BWI_RF_F_INITED;
 	}
 
@@ -1083,7 +1085,8 @@
 		device_printf(sc->sc_dev, "invalid max txpower in sprom\n");
 		rf->rf_txpower_max = 74;
 	}
-	DPRINTF(sc, "max txpower from sprom: %d dBm\n", rf->rf_txpower_max);
+	DPRINTF(sc, BWI_DBG_RF | BWI_DBG_TXPOWER | BWI_DBG_ATTACH,
+		"max txpower from sprom: %d dBm\n", rf->rf_txpower_max);
 
 	/*
 	 * Find out region/domain max TX power, which is adjusted
@@ -1100,17 +1103,20 @@
 		ant_gain = 2;
 	}
 	ant_gain *= 4;
-	DPRINTF(sc, "ant gain %d dBm\n", ant_gain);
+	DPRINTF(sc, BWI_DBG_RF | BWI_DBG_TXPOWER | BWI_DBG_ATTACH,
+		"ant gain %d dBm\n", ant_gain);
 
 	reg_txpower_max = 90 - ant_gain - 6;	/* XXX magic number */
-	DPRINTF(sc, "region/domain max txpower %d dBm\n", reg_txpower_max);
+	DPRINTF(sc, BWI_DBG_RF | BWI_DBG_TXPOWER | BWI_DBG_ATTACH,
+		"region/domain max txpower %d dBm\n", reg_txpower_max);
 
 	/*
 	 * Force max TX power within region/domain TX power limit
 	 */
 	if (rf->rf_txpower_max > reg_txpower_max)
 		rf->rf_txpower_max = reg_txpower_max;
-	DPRINTF(sc, "max txpower %d dBm\n", rf->rf_txpower_max);
+	DPRINTF(sc, BWI_DBG_RF | BWI_DBG_TXPOWER | BWI_DBG_ATTACH,
+		"max txpower %d dBm\n", rf->rf_txpower_max);
 
 	/*
 	 * Create TSSI to TX power mapping
@@ -1152,9 +1158,14 @@
 			}
 
 			if (phy->phy_mode == IEEE80211_MODE_11G) {
-				DPRINTF(sc, "%s\n", "use default 11g TSSI map");
+				DPRINTF(sc,
+				BWI_DBG_RF | BWI_DBG_TXPOWER | BWI_DBG_ATTACH,
+				"%s\n", "use default 11g TSSI map");
 				txpower_map = bwi_txpower_map_11g;
 			} else {
+				DPRINTF(sc,
+				BWI_DBG_RF | BWI_DBG_TXPOWER | BWI_DBG_ATTACH,
+				"%s\n", "use default 11b TSSI map");
 				txpower_map = bwi_txpower_map_11b;
 			}
 
@@ -1175,7 +1186,8 @@
 	 * Extract idle TSSI from SPROM.
 	 */
 	val = bwi_read_sprom(sc, BWI_SPROM_IDLE_TSSI);
-	DPRINTF(sc, "sprom idle tssi: 0x%04x\n", val);
+	DPRINTF(sc, BWI_DBG_RF | BWI_DBG_TXPOWER | BWI_DBG_ATTACH,
+		"sprom idle tssi: 0x%04x\n", val);
 
 	if (phy->phy_mode == IEEE80211_MODE_11A)
 		mask = BWI_SPROM_IDLE_TSSI_MASK_11A;
@@ -1191,7 +1203,8 @@
 	/*
 	 * Calculate TX power map, which is indexed by TSSI
 	 */
-	device_printf(sc->sc_dev, "TSSI-TX power map:\n");
+	DPRINTF(sc, BWI_DBG_RF | BWI_DBG_ATTACH | BWI_DBG_TXPOWER,
+		"%s\n", "TSSI-TX power map:");
 	for (i = 0; i < BWI_TSSI_MAX; ++i) {
 		error = bwi_rf_calc_txpower(&rf->rf_txpower_map0[i], i,
 					    pa_params);
@@ -1200,13 +1213,22 @@
 				  "bwi_rf_calc_txpower failed\n");
 			break;
 		}
-		if (i != 0 && i % 8 == 0)
-			printf("\n");
-		printf("%d ", rf->rf_txpower_map0[i]);
+
+#ifdef BWI_DEBUG
+		if (i != 0 && i % 8 == 0) {
+			_DPRINTF(sc,
+			BWI_DBG_RF | BWI_DBG_ATTACH | BWI_DBG_TXPOWER,
+			"%s\n", "");
+		}
+#endif
+		_DPRINTF(sc, BWI_DBG_RF | BWI_DBG_ATTACH | BWI_DBG_TXPOWER,
+			 "%d ", rf->rf_txpower_map0[i]);
 	}
-	printf("\n");
+	_DPRINTF(sc, BWI_DBG_RF | BWI_DBG_ATTACH | BWI_DBG_TXPOWER,
+		 "%s\n", "");
 back:
-	DPRINTF(sc, "idle tssi0: %d\n", rf->rf_idle_tssi0);
+	DPRINTF(sc, BWI_DBG_RF | BWI_DBG_TXPOWER | BWI_DBG_ATTACH,
+		"idle tssi0: %d\n", rf->rf_idle_tssi0);
 	return error;
 }
 
@@ -2405,10 +2427,9 @@
 
 	lna_gain = __SHIFTOUT(le16toh(hdr->rxh_phyinfo),
 			      BWI_RXH_PHYINFO_LNAGAIN);
-#if 0
-	DPRINTF(mac->mac_sc, "lna_gain %d, phyinfo 0x%04x\n",
+	DPRINTF(mac->mac_sc, BWI_DBG_RF | BWI_DBG_RX,
+		"lna_gain %d, phyinfo 0x%04x\n",
 		lna_gain, le16toh(hdr->rxh_phyinfo));
-#endif
 	switch (lna_gain) {
 	case 0:
 		rssi += 27;

==== //depot/projects/wifi/sys/dev/bwi/if_bwi.c#10 (text+ko) ====

@@ -288,6 +288,15 @@
 	[108]	= { 7, 3 }
 };
 
+#ifdef BWI_DEBUG
+#ifdef BWI_DEBUG_VERBOSE
+static uint32_t bwi_debug = BWI_DBG_ATTACH | BWI_DBG_INIT | BWI_DBG_TXPOWER;
+#else
+static uint32_t	bwi_debug;
+#endif
+TUNABLE_INT("hw.bwi.debug", (int *)&bwi_debug);
+#endif	/* BWI_DEBUG */
+
 static const uint8_t bwi_zero_addr[IEEE80211_ADDR_LEN];
 
 uint16_t
@@ -336,6 +345,14 @@
 
 	BWI_LOCK_INIT(sc);
 
+	/*
+	 * Initialize sysctl variables
+	 */
+	sc->sc_fw_version = BWI_FW_VERSION3;
+	sc->sc_led_idle = (2350 * hz) / 1000;
+	sc->sc_led_blink = 1;
+	sc->sc_debug = bwi_debug;
+
 	bwi_power_on(sc, 1);
 
 	error = bwi_bbp_attach(sc);
@@ -425,7 +442,7 @@
 	/* Get locale */
 	sc->sc_locale = __SHIFTOUT(bwi_read_sprom(sc, BWI_SPROM_CARD_INFO),
 				   BWI_SPROM_CARD_INFO_LOCALE);
-	DPRINTF(sc, "locale: %d\n", sc->sc_locale);
+	DPRINTF(sc, BWI_DBG_ATTACH, "locale: %d\n", sc->sc_locale);
 
 	/*
 	 * Setup ratesets, phytype, channels and get MAC address
@@ -461,12 +478,6 @@
 	/* XXX use locale */
 	ieee80211_init_channels(ic, 0, CTRY_DEFAULT, bands, 0, 1);
 
-	sc->sc_fw_version = BWI_FW_VERSION3;
-
-	/* Initialize LED vars */
-	sc->sc_led_idle = (2350 * hz) / 1000;
-	sc->sc_led_blink = 1;
-
 	ic->ic_ifp = ifp;
 	ic->ic_caps = IEEE80211_C_SHSLOT |
 		      IEEE80211_C_SHPREAMBLE |
@@ -679,8 +690,9 @@
 	*type = BWI_ID_HI_REGWIN_TYPE(val);
 	*rev = BWI_ID_HI_REGWIN_REV(val);
 
-	DPRINTF(sc, "regwin: type 0x%03x, rev %d, vendor 0x%04x\n",
-		*type, *rev, __SHIFTOUT(val, BWI_ID_HI_REGWIN_VENDOR_MASK));
+	DPRINTF(sc, BWI_DBG_ATTACH, "regwin: type 0x%03x, rev %d, "
+		"vendor 0x%04x\n", *type, *rev,
+		__SHIFTOUT(val, BWI_ID_HI_REGWIN_VENDOR_MASK));
 }
 
 static int
@@ -760,7 +772,8 @@
 	device_printf(sc->sc_dev, "BBP: id 0x%04x, rev 0x%x, pkg %d\n",
 		      sc->sc_bbp_id, sc->sc_bbp_rev, sc->sc_bbp_pkg);
 
-	DPRINTF(sc, "nregwin %d, cap 0x%08x\n", nregwin, sc->sc_cap);
+	DPRINTF(sc, BWI_DBG_ATTACH, "nregwin %d, cap 0x%08x\n",
+		nregwin, sc->sc_cap);
 
 	/*
 	 * Create rest of the regwins
@@ -941,7 +954,7 @@
 	    sc->sc_pci_revid > 0x40)
 		sc->sc_card_flags |= BWI_CARD_F_PA_GPIO9;
 
-	DPRINTF(sc, "card flags 0x%04x\n", sc->sc_card_flags);
+	DPRINTF(sc, BWI_DBG_ATTACH, "card flags 0x%04x\n", sc->sc_card_flags);
 #undef PCI_VENDOR_DELL
 #undef PCI_VENDOR_APPLE
 }
@@ -1009,14 +1022,14 @@
 	KASSERT(src >= 0 && src < BWI_CLKSRC_MAX, ("bad src %d", src));
 	KASSERT(div != 0, ("div zero"));
 
-	DPRINTF(sc, "clksrc %s\n",
+	DPRINTF(sc, BWI_DBG_ATTACH, "clksrc %s\n",
 		src == BWI_CLKSRC_PCI ? "PCI" :
 		(src == BWI_CLKSRC_LP_OSC ? "LP_OSC" : "CS_OSC"));
 
 	freq->clkfreq_min = bwi_clkfreq[src].freq_min / div;
 	freq->clkfreq_max = bwi_clkfreq[src].freq_max / div;
 
-	DPRINTF(sc, "clkfreq min %u, max %u\n",
+	DPRINTF(sc, BWI_DBG_ATTACH, "clkfreq min %u, max %u\n",
 		freq->clkfreq_min, freq->clkfreq_max);
 }
 
@@ -1126,8 +1139,6 @@
 
 	BWI_LOCK(sc);
 
-	DPRINTF(sc, "%s\n", __func__);
-
 	bwi_stop(sc);
 
 	bwi_bbp_power_on(sc, BWI_CLOCK_MODE_FAST);
@@ -1388,8 +1399,6 @@
 
 	BWI_LOCK(sc);
 
-	DPRINTF(sc, "%s\n", __func__);
-
 	ieee80211_new_state(ic, IEEE80211_S_INIT, -1);
 
 	if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
@@ -1452,9 +1461,7 @@
 		return;
 	}
 
-#if 0
-	if_printf(ifp, "intr status 0x%08x\n", intr_status);
-#endif
+	DPRINTF(sc, BWI_DBG_INTR, "intr status 0x%08x\n", intr_status);
 
 	intr_status &= CSR_READ_4(sc, BWI_MAC_INTR_MASK);
 	if (intr_status == 0) {		/* Nothing is interesting */
@@ -1463,9 +1470,7 @@
 	}
 
 	txrx_error = 0;
-#if 0
-	if_printf(ifp, "TX/RX intr");
-#endif
+	DPRINTF(sc, BWI_DBG_INTR, "%s\n", "TX/RX intr");
 	for (i = 0; i < BWI_TXRX_NRING; ++i) {
 		uint32_t mask;
 
@@ -1477,9 +1482,8 @@
 		txrx_intr_status[i] =
 		CSR_READ_4(sc, BWI_TXRX_INTR_STATUS(i)) & mask;
 
-#if 0
-		printf(", %d 0x%08x", i, txrx_intr_status[i]);
-#endif
+		_DPRINTF(sc, BWI_DBG_INTR, ", %d 0x%08x",
+			 i, txrx_intr_status[i]);
 
 		if (txrx_intr_status[i] & BWI_TXRX_INTR_ERROR) {
 			if_printf(ifp, "intr fatal TX/RX (%d) error 0x%08x\n",
@@ -1487,9 +1491,7 @@
 			txrx_error = 1;
 		}
 	}
-#if 0
-	printf("\n");
-#endif
+	_DPRINTF(sc, BWI_DBG_INTR, "%s\n", "");
 
 	/*
 	 * Acknowledge interrupt
@@ -3027,10 +3029,9 @@
 		printf("%02x ", p[i]);
 	}
 	printf("\n");
-
-	if_printf(ic->ic_ifp, "idx %d, pkt_len %d, buflen %d\n",
-		  idx, pkt_len, m->m_pkthdr.len);
 #endif
+	DPRINTF(sc, BWI_DBG_TX, "idx %d, pkt_len %d, buflen %d\n",
+		idx, pkt_len, m->m_pkthdr.len);
 
 	/* Setup TX descriptor */
 	sc->sc_setup_txdesc(sc, rd, idx, paddr, m->m_pkthdr.len);
@@ -3102,24 +3103,20 @@
 		return;
 	}
 
-#if 0
-	if_printf(ifp, "acked %d, data_txcnt %d\n", acked, data_txcnt);
-#endif
-
 	ring_idx = __SHIFTOUT(tx_id, BWI_TXH_ID_RING_MASK);
 	buf_idx = __SHIFTOUT(tx_id, BWI_TXH_ID_IDX_MASK);
 
 	KASSERT(ring_idx == BWI_TX_DATA_RING, ("ring_idx %d", ring_idx));
 	KASSERT(buf_idx < BWI_TX_NDESC, ("buf_idx %d", buf_idx));
-#if 0
-	if_printf(ifp, "txeof idx %d\n", buf_idx);
-#endif
 
 	tbd = &sc->sc_tx_bdata[ring_idx];
 	KASSERT(tbd->tbd_used > 0, ("tbd_used %d", tbd->tbd_used));
 	tbd->tbd_used--;
 
 	tb = &tbd->tbd_buf[buf_idx];
+	DPRINTF(sc, BWI_DBG_TXEOF, "txeof idx %d, "
+		"acked %d, data_txcnt %d, ni %p\n",
+		buf_idx, acked, data_txcnt, tb->tb_ni);
 
 	bus_dmamap_unload(sc->sc_buf_dtag, tb->tb_dmap);
 
@@ -3245,7 +3242,7 @@
 
 	val = CSR_READ_4(sc, BWI_PLL_ON_DELAY);
 	sc->sc_pwron_delay = howmany((val + 2) * 1000000, freq.clkfreq_min);
-	DPRINTF(sc, "power on delay %u\n", sc->sc_pwron_delay);
+	DPRINTF(sc, BWI_DBG_ATTACH, "power on delay %u\n", sc->sc_pwron_delay);
 
 	return bwi_regwin_switch(sc, old, NULL);
 }
@@ -3295,7 +3292,8 @@
 
 	/* XXX cache this */
 	busrev = __SHIFTOUT(CSR_READ_4(sc, BWI_ID_LO), BWI_ID_LO_BUSREV_MASK);
-	DPRINTF(sc, "bus rev %u\n", busrev);
+	DPRINTF(sc, BWI_DBG_ATTACH | BWI_DBG_INIT | BWI_DBG_MISC,
+		"bus rev %u\n", busrev);
 
 	if (busrev == BWI_BUSREV_0)
 		return BWI_STATE_LO_DISABLE1;
@@ -3316,10 +3314,12 @@
 	if ((val & (BWI_STATE_LO_CLOCK |
 		    BWI_STATE_LO_RESET |
 		    disable_bits)) == BWI_STATE_LO_CLOCK) {
-		DPRINTF(sc, "%s is enabled\n", bwi_regwin_name(rw));
+		DPRINTF(sc, BWI_DBG_ATTACH | BWI_DBG_INIT, "%s is enabled\n",
+			bwi_regwin_name(rw));
 		return 1;
 	} else {
-		DPRINTF(sc, "%s is disabled\n", bwi_regwin_name(rw));
+		DPRINTF(sc, BWI_DBG_ATTACH | BWI_DBG_INIT, "%s is disabled\n",
+			bwi_regwin_name(rw));
 		return 0;
 	}
 }
@@ -3336,7 +3336,8 @@
 	 * If current regwin is in 'reset' state, it was already disabled.
 	 */
 	if (state_lo & BWI_STATE_LO_RESET) {
-		DPRINTF(sc, "%s was already disabled\n", bwi_regwin_name(rw));
+		DPRINTF(sc, BWI_DBG_ATTACH | BWI_DBG_INIT,
+			"%s was already disabled\n", bwi_regwin_name(rw));
 		return;
 	}
 
@@ -3488,7 +3489,7 @@
 
 	BWI_LOCK(sc);
 	if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
-		DPRINTF(sc, "%s\n", __func__);
+		DPRINTF(sc, BWI_DBG_80211, "%s\n", __func__);
 
 		KASSERT(sc->sc_cur_regwin->rw_type == BWI_REGWIN_T_MAC,
 		    ("current regwin type %d", sc->sc_cur_regwin->rw_type));
@@ -3627,8 +3628,9 @@
 			}
 		}
 
-		DPRINTF(sc, "%dth led, act %d, lowact %d\n",
-		    i, led->l_act, led->l_flags & BWI_LED_F_ACTLOW);
+		DPRINTF(sc, BWI_DBG_LED | BWI_DBG_ATTACH,
+			"%dth led, act %d, lowact %d\n", i,
+			led->l_act, led->l_flags & BWI_LED_F_ACTLOW);
 	}
 	callout_init(&sc->sc_led_blink_ch, CALLOUT_MPSAFE);
 }

==== //depot/projects/wifi/sys/dev/bwi/if_bwivar.h#6 (text+ko) ====

@@ -92,10 +92,25 @@
 
 #define BWI_DEBUG
 #ifdef BWI_DEBUG
-#define DPRINTF(sc, fmt, ...)	device_printf(sc->sc_dev, fmt, __VA_ARGS__)
-#else
-#define DPRINTF(sc, fmt, ...)	((void)0)
-#endif
+
+#define DPRINTF(sc, dbg, fmt, ...) \
+do { \
+	if ((sc)->sc_debug & (dbg)) \
+		device_printf((sc)->sc_dev, fmt, __VA_ARGS__); \
+} while (0)
+
+#define _DPRINTF(sc, dbg, fmt, ...) \
+do { \
+	if ((sc)->sc_debug & (dbg)) \
+		printf(fmt, __VA_ARGS__); \
+} while (0)
+
+#else	/* !BWI_DEBUG */
+
+#define DPRINTF(sc, dbg, fmt, ...)	((void)0)
+#define _DPRINTF(sc, dbg, fmt, ...)	((void)0)
+
+#endif	/* BWI_DEBUG */
 
 struct bwi_desc32 {
 	/* Little endian */
@@ -512,8 +527,8 @@
 };
 
 struct bwi_softc {
+	struct ieee80211com	sc_ic;
 	struct ifnet		*sc_ifp;
-	struct ieee80211com	sc_ic;
 	struct ieee80211_amrr	sc_amrr;
 	uint32_t		sc_flags;	/* BWI_F_ */
 	device_t		sc_dev;
@@ -615,11 +630,28 @@
 	int			sc_dwell_time;	/* milliseconds */
 	int			sc_led_idle;
 	int			sc_led_blink;
+	uint32_t		sc_debug;	/* BWI_DBG_ */
 };
 
 #define BWI_F_BUS_INITED	0x1
 #define BWI_F_PROMISC		0x2
 
+#define BWI_DBG_MAC		0x00000001
+#define BWI_DBG_RF		0x00000002
+#define BWI_DBG_PHY		0x00000004
+#define BWI_DBG_MISC		0x00000008
+
+#define BWI_DBG_ATTACH		0x00000010
+#define BWI_DBG_INIT		0x00000020
+#define BWI_DBG_FIRMWARE	0x00000040
+#define BWI_DBG_80211		0x00000080
+#define BWI_DBG_TXPOWER		0x00000100
+#define BWI_DBG_INTR		0x00000200
+#define BWI_DBG_RX		0x00000400
+#define BWI_DBG_TX		0x00000800
+#define BWI_DBG_TXEOF		0x00001000
+#define BWI_DBG_LED		0x00002000
+
 #define	BWI_LOCK_INIT(sc) \
 	mtx_init(&(sc)->sc_mtx, device_get_nameunit((sc)->sc_dev), \
 	    MTX_NETWORK_LOCK, MTX_DEF | MTX_RECURSE);


More information about the p4-projects mailing list