Date: Mon, 25 May 2015 14:30:44 +0000 (UTC) From: Gleb Smirnoff <glebius@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r283529 - head/sys/net80211 Message-ID: <201505251430.t4PEUiY9061003@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: glebius Date: Mon May 25 14:30:44 2015 New Revision: 283529 URL: https://svnweb.freebsd.org/changeset/base/283529 Log: Use name from ieee80211com instead of parent ifnet, in debugging printfs. Sponsored by: Netflix Sponsored by: Nginx, Inc. Modified: head/sys/net80211/ieee80211.c head/sys/net80211/ieee80211_ddb.c head/sys/net80211/ieee80211_dfs.c head/sys/net80211/ieee80211_freebsd.c head/sys/net80211/ieee80211_ht.c head/sys/net80211/ieee80211_node.c head/sys/net80211/ieee80211_proto.c head/sys/net80211/ieee80211_radiotap.c head/sys/net80211/ieee80211_regdomain.c head/sys/net80211/ieee80211_var.h Modified: head/sys/net80211/ieee80211.c ============================================================================== --- head/sys/net80211/ieee80211.c Mon May 25 14:12:50 2015 (r283528) +++ head/sys/net80211/ieee80211.c Mon May 25 14:30:44 2015 (r283529) @@ -35,9 +35,10 @@ __FBSDID("$FreeBSD$"); #include <sys/param.h> #include <sys/systm.h> #include <sys/kernel.h> - #include <sys/socket.h> +#include <machine/stdarg.h> + #include <net/if.h> #include <net/if_var.h> #include <net/if_dl.h> @@ -267,7 +268,20 @@ static void null_update_chw(struct ieee80211com *ic) { - if_printf(ic->ic_ifp, "%s: need callback\n", __func__); + ic_printf(ic, "%s: need callback\n", __func__); +} + +int +ic_printf(struct ieee80211com *ic, const char * fmt, ...) +{ + va_list ap; + int retval; + + retval = printf("%s: ", ic->ic_name); + va_start(ap, fmt); + retval += vprintf(fmt, ap); + va_end(ap); + return (retval); } /* @@ -284,8 +298,8 @@ ieee80211_ifattach(struct ieee80211com * KASSERT(ifp->if_type == IFT_IEEE80211, ("if_type %d", ifp->if_type)); - IEEE80211_LOCK_INIT(ic, ifp->if_xname); - IEEE80211_TX_LOCK_INIT(ic, ifp->if_xname); + IEEE80211_LOCK_INIT(ic, ic->ic_name); + IEEE80211_TX_LOCK_INIT(ic, ic->ic_name); TAILQ_INIT(&ic->ic_vaps); /* Create a taskqueue for all state changes */ @@ -427,7 +441,7 @@ ieee80211_vap_setup(struct ieee80211com ifp = if_alloc(IFT_ETHER); if (ifp == NULL) { - if_printf(ic->ic_ifp, "%s: unable to allocate ifnet\n", + ic_printf(ic, "%s: unable to allocate ifnet\n", __func__); return ENOMEM; } @@ -551,7 +565,7 @@ ieee80211_vap_attach(struct ieee80211vap IEEE80211_DPRINTF(vap, IEEE80211_MSG_STATE, "%s: %s parent %s flags 0x%x flags_ext 0x%x\n", __func__, ieee80211_opmode_name[vap->iv_opmode], - ic->ic_ifp->if_xname, vap->iv_flags, vap->iv_flags_ext); + ic->ic_name, vap->iv_flags, vap->iv_flags_ext); /* * Do late attach work that cannot happen until after @@ -608,7 +622,7 @@ ieee80211_vap_detach(struct ieee80211vap IEEE80211_DPRINTF(vap, IEEE80211_MSG_STATE, "%s: %s parent %s\n", __func__, ieee80211_opmode_name[vap->iv_opmode], - ic->ic_ifp->if_xname); + ic->ic_name); /* NB: bpfdetach is called by ether_ifdetach and claims all taps */ ether_ifdetach(ifp); @@ -900,7 +914,7 @@ int ieee80211_chan2ieee(struct ieee80211com *ic, const struct ieee80211_channel *c) { if (c == NULL) { - if_printf(ic->ic_ifp, "invalid channel (NULL)\n"); + ic_printf(ic, "invalid channel (NULL)\n"); return 0; /* XXX */ } return (c == IEEE80211_CHAN_ANYC ? IEEE80211_CHAN_ANY : c->ic_ieee); @@ -1169,7 +1183,6 @@ ieee80211_get_suprates(struct ieee80211c void ieee80211_announce(struct ieee80211com *ic) { - struct ifnet *ifp = ic->ic_ifp; int i, rate, mword; enum ieee80211_phymode mode; const struct ieee80211_rateset *rs; @@ -1178,7 +1191,7 @@ ieee80211_announce(struct ieee80211com * for (mode = IEEE80211_MODE_AUTO+1; mode < IEEE80211_MODE_11NA; mode++) { if (isclr(ic->ic_modecaps, mode)) continue; - if_printf(ifp, "%s rates: ", ieee80211_phymode_name[mode]); + ic_printf(ic, "%s rates: ", ieee80211_phymode_name[mode]); rs = &ic->ic_sup_rates[mode]; for (i = 0; i < rs->rs_nrates; i++) { mword = ieee80211_rate2media(ic, rs->rs_rates[i], mode); Modified: head/sys/net80211/ieee80211_ddb.c ============================================================================== --- head/sys/net80211/ieee80211_ddb.c Mon May 25 14:12:50 2015 (r283528) +++ head/sys/net80211/ieee80211_ddb.c Mon May 25 14:30:44 2015 (r283529) @@ -521,6 +521,7 @@ _db_show_com(const struct ieee80211com * db_printf(" %s(%p)", vap->iv_ifp->if_xname, vap); db_printf("\n"); db_printf("\tifp %p(%s)", ic->ic_ifp, ic->ic_ifp->if_xname); + db_printf("\tname %s", ic->ic_name); db_printf(" comlock %p", &ic->ic_comlock); db_printf("\n"); db_printf("\theadroom %d", ic->ic_headroom); Modified: head/sys/net80211/ieee80211_dfs.c ============================================================================== --- head/sys/net80211/ieee80211_dfs.c Mon May 25 14:12:50 2015 (r283528) +++ head/sys/net80211/ieee80211_dfs.c Mon May 25 14:30:44 2015 (r283529) @@ -253,8 +253,8 @@ dfs_timeout(void *arg) * msg instead of one for every channel * table entry. */ - if_printf(ic->ic_ifp, "radar on channel" - " %u (%u MHz) cleared after timeout\n", + ic_printf(ic, "radar on channel %u " + "(%u MHz) cleared after timeout\n", c->ic_ieee, c->ic_freq); /* notify user space */ c->ic_state &= @@ -272,14 +272,14 @@ dfs_timeout(void *arg) } static void -announce_radar(struct ifnet *ifp, const struct ieee80211_channel *curchan, +announce_radar(struct ieee80211com *ic, const struct ieee80211_channel *curchan, const struct ieee80211_channel *newchan) { if (newchan == NULL) - if_printf(ifp, "radar detected on channel %u (%u MHz)\n", + ic_printf(ic, "radar detected on channel %u (%u MHz)\n", curchan->ic_ieee, curchan->ic_freq); else - if_printf(ifp, "radar detected on channel %u (%u MHz), " + ic_printf(ic, "radar detected on channel %u (%u MHz), " "moving to channel %u (%u MHz)\n", curchan->ic_ieee, curchan->ic_freq, newchan->ic_ieee, newchan->ic_freq); @@ -309,7 +309,7 @@ ieee80211_dfs_notify_radar(struct ieee80 * along merrily. */ if (ieee80211_dfs_debug == DFS_DBG_NOCSANOL) { - announce_radar(ic->ic_ifp, chan, chan); + announce_radar(ic, chan, chan); ieee80211_notify_radar(ic, chan); return; } @@ -364,7 +364,7 @@ ieee80211_dfs_notify_radar(struct ieee80 else dfs->newchan = chan; - announce_radar(ic->ic_ifp, chan, dfs->newchan); + announce_radar(ic, chan, dfs->newchan); if (callout_pending(&dfs->cac_timer)) callout_schedule(&dfs->cac_timer, 0); @@ -380,7 +380,7 @@ ieee80211_dfs_notify_radar(struct ieee80 * on the NOL to expire. */ /*XXX*/ - if_printf(ic->ic_ifp, "%s: No free channels; waiting for entry " + ic_printf(ic, "%s: No free channels; waiting for entry " "on NOL to expire\n", __func__); } } else { @@ -390,9 +390,9 @@ ieee80211_dfs_notify_radar(struct ieee80 if (dfs->lastchan != chan) { dfs->lastchan = chan; dfs->cureps = 0; - announce_radar(ic->ic_ifp, chan, NULL); + announce_radar(ic, chan, NULL); } else if (ppsratecheck(&dfs->lastevent, &dfs->cureps, 1)) { - announce_radar(ic->ic_ifp, chan, NULL); + announce_radar(ic, chan, NULL); } } } @@ -434,6 +434,6 @@ ieee80211_dfs_pickchannel(struct ieee802 (c->ic_flags & flags) == flags) return c; } - if_printf(ic->ic_ifp, "HELP, no channel located to switch to!\n"); + ic_printf(ic, "HELP, no channel located to switch to!\n"); return NULL; } Modified: head/sys/net80211/ieee80211_freebsd.c ============================================================================== --- head/sys/net80211/ieee80211_freebsd.c Mon May 25 14:12:50 2015 (r283528) +++ head/sys/net80211/ieee80211_freebsd.c Mon May 25 14:30:44 2015 (r283529) @@ -207,9 +207,8 @@ static int ieee80211_sysctl_parent(SYSCTL_HANDLER_ARGS) { struct ieee80211com *ic = arg1; - const char *name = ic->ic_ifp->if_xname; - return SYSCTL_OUT_STR(req, name); + return SYSCTL_OUT_STR(req, ic->ic_name); } static int Modified: head/sys/net80211/ieee80211_ht.c ============================================================================== --- head/sys/net80211/ieee80211_ht.c Mon May 25 14:12:50 2015 (r283528) +++ head/sys/net80211/ieee80211_ht.c Mon May 25 14:30:44 2015 (r283529) @@ -354,7 +354,6 @@ static struct printranges { static void ht_rateprint(struct ieee80211com *ic, enum ieee80211_phymode mode, int ratetype) { - struct ifnet *ifp = ic->ic_ifp; int minrate, maxrate; struct printranges *range; @@ -369,12 +368,12 @@ ht_rateprint(struct ieee80211com *ic, en minrate = ht_getrate(ic, range->minmcs, mode, ratetype); maxrate = ht_getrate(ic, range->maxmcs, mode, ratetype); if (range->maxmcs) { - if_printf(ifp, "MCS %d-%d: %d%sMbps - %d%sMbps\n", + ic_printf(ic, "MCS %d-%d: %d%sMbps - %d%sMbps\n", range->minmcs, range->maxmcs, minrate/2, ((minrate & 0x1) != 0 ? ".5" : ""), maxrate/2, ((maxrate & 0x1) != 0 ? ".5" : "")); } else { - if_printf(ifp, "MCS %d: %d%sMbps\n", range->minmcs, + ic_printf(ic, "MCS %d: %d%sMbps\n", range->minmcs, minrate/2, ((minrate & 0x1) != 0 ? ".5" : "")); } } @@ -383,22 +382,21 @@ ht_rateprint(struct ieee80211com *ic, en static void ht_announce(struct ieee80211com *ic, enum ieee80211_phymode mode) { - struct ifnet *ifp = ic->ic_ifp; const char *modestr = ieee80211_phymode_name[mode]; - if_printf(ifp, "%s MCS 20MHz\n", modestr); + ic_printf(ic, "%s MCS 20MHz\n", modestr); ht_rateprint(ic, mode, 0); if (ic->ic_htcaps & IEEE80211_HTCAP_SHORTGI20) { - if_printf(ifp, "%s MCS 20MHz SGI\n", modestr); + ic_printf(ic, "%s MCS 20MHz SGI\n", modestr); ht_rateprint(ic, mode, 1); } if (ic->ic_htcaps & IEEE80211_HTCAP_CHWIDTH40) { - if_printf(ifp, "%s MCS 40MHz:\n", modestr); + ic_printf(ic, "%s MCS 40MHz:\n", modestr); ht_rateprint(ic, mode, 2); } if ((ic->ic_htcaps & IEEE80211_HTCAP_CHWIDTH40) && (ic->ic_htcaps & IEEE80211_HTCAP_SHORTGI40)) { - if_printf(ifp, "%s MCS 40MHz SGI:\n", modestr); + ic_printf(ic, "%s MCS 40MHz SGI:\n", modestr); ht_rateprint(ic, mode, 3); } } @@ -406,11 +404,10 @@ ht_announce(struct ieee80211com *ic, enu void ieee80211_ht_announce(struct ieee80211com *ic) { - struct ifnet *ifp = ic->ic_ifp; if (isset(ic->ic_modecaps, IEEE80211_MODE_11NA) || isset(ic->ic_modecaps, IEEE80211_MODE_11NG)) - if_printf(ifp, "%dT%dR\n", ic->ic_txstream, ic->ic_rxstream); + ic_printf(ic, "%dT%dR\n", ic->ic_txstream, ic->ic_rxstream); if (isset(ic->ic_modecaps, IEEE80211_MODE_11NA)) ht_announce(ic, IEEE80211_MODE_11NA); if (isset(ic->ic_modecaps, IEEE80211_MODE_11NG)) Modified: head/sys/net80211/ieee80211_node.c ============================================================================== --- head/sys/net80211/ieee80211_node.c Mon May 25 14:12:50 2015 (r283528) +++ head/sys/net80211/ieee80211_node.c Mon May 25 14:30:44 2015 (r283529) @@ -1908,11 +1908,10 @@ ieee80211_node_table_init(struct ieee802 struct ieee80211_node_table *nt, const char *name, int inact, int keyixmax) { - struct ifnet *ifp = ic->ic_ifp; nt->nt_ic = ic; - IEEE80211_NODE_LOCK_INIT(nt, ifp->if_xname); - IEEE80211_NODE_ITERATE_LOCK_INIT(nt, ifp->if_xname); + IEEE80211_NODE_LOCK_INIT(nt, ic->ic_name); + IEEE80211_NODE_ITERATE_LOCK_INIT(nt, ic->ic_name); TAILQ_INIT(&nt->nt_node); nt->nt_name = name; nt->nt_scangen = 1; @@ -1923,7 +1922,7 @@ ieee80211_node_table_init(struct ieee802 keyixmax * sizeof(struct ieee80211_node *), M_80211_NODE, M_NOWAIT | M_ZERO); if (nt->nt_keyixmap == NULL) - if_printf(ic->ic_ifp, + ic_printf(ic, "Cannot allocate key index map with %u entries\n", keyixmax); } else @@ -2256,8 +2255,8 @@ ieee80211_iterate_nt(struct ieee80211_no TAILQ_FOREACH(ni, &nt->nt_node, ni_list) { if (i >= max_aid) { ret = E2BIG; - if_printf(nt->nt_ic->ic_ifp, - "Node array overflow: max=%u", max_aid); + ic_printf(nt->nt_ic, "Node array overflow: max=%u", + max_aid); break; } ni_arr[i] = ieee80211_ref_node(ni); Modified: head/sys/net80211/ieee80211_proto.c ============================================================================== --- head/sys/net80211/ieee80211_proto.c Mon May 25 14:12:50 2015 (r283528) +++ head/sys/net80211/ieee80211_proto.c Mon May 25 14:30:44 2015 (r283529) @@ -113,9 +113,8 @@ static int null_raw_xmit(struct ieee80211_node *ni, struct mbuf *m, const struct ieee80211_bpf_params *params) { - struct ifnet *ifp = ni->ni_ic->ic_ifp; - if_printf(ifp, "missing ic_raw_xmit callback, drop frame\n"); + ic_printf(ni->ni_ic, "missing ic_raw_xmit callback, drop frame\n"); m_freem(m); return ENETDOWN; } Modified: head/sys/net80211/ieee80211_radiotap.c ============================================================================== --- head/sys/net80211/ieee80211_radiotap.c Mon May 25 14:12:50 2015 (r283528) +++ head/sys/net80211/ieee80211_radiotap.c Mon May 25 14:30:44 2015 (r283529) @@ -80,8 +80,8 @@ ieee80211_radiotap_attachv(struct ieee80 else if (tx_radiotap & B(IEEE80211_RADIOTAP_XCHANNEL)) off = radiotap_offset(th, n_tx_v, IEEE80211_RADIOTAP_XCHANNEL); if (off == -1) { - if_printf(ic->ic_ifp, "%s: no tx channel, radiotap 0x%x\n", - __func__, tx_radiotap); + ic_printf(ic, "%s: no tx channel, radiotap 0x%x\n", __func__, + tx_radiotap); /* NB: we handle this case but data will have no chan spec */ } else ic->ic_txchan = ((uint8_t *) th) + off; @@ -96,8 +96,8 @@ ieee80211_radiotap_attachv(struct ieee80 else if (rx_radiotap & B(IEEE80211_RADIOTAP_XCHANNEL)) off = radiotap_offset(rh, n_rx_v, IEEE80211_RADIOTAP_XCHANNEL); if (off == -1) { - if_printf(ic->ic_ifp, "%s: no rx channel, radiotap 0x%x\n", - __func__, rx_radiotap); + ic_printf(ic, "%s: no rx channel, radiotap 0x%x\n", __func__, + rx_radiotap); /* NB: we handle this case but data will have no chan spec */ } else ic->ic_rxchan = ((uint8_t *) rh) + off; Modified: head/sys/net80211/ieee80211_regdomain.c ============================================================================== --- head/sys/net80211/ieee80211_regdomain.c Mon May 25 14:12:50 2015 (r283528) +++ head/sys/net80211/ieee80211_regdomain.c Mon May 25 14:30:44 2015 (r283529) @@ -304,16 +304,16 @@ ieee80211_alloc_countryie(struct ieee802 aie = malloc(IEEE80211_COUNTRY_MAX_SIZE, M_80211_NODE_IE, M_NOWAIT | M_ZERO); if (aie == NULL) { - if_printf(ic->ic_ifp, - "%s: unable to allocate memory for country ie\n", __func__); + ic_printf(ic, "%s: unable to allocate memory for country ie\n", + __func__); /* XXX stat */ return NULL; } ie = (struct ieee80211_country_ie *) aie->ie_data; ie->ie = IEEE80211_ELEMID_COUNTRY; if (rd->isocc[0] == '\0') { - if_printf(ic->ic_ifp, "no ISO country string for cc %d; " - "using blanks\n", rd->country); + ic_printf(ic, "no ISO country string for cc %d; using blanks\n", + rd->country); ie->cc[0] = ie->cc[1] = ' '; } else { ie->cc[0] = rd->isocc[0]; @@ -350,7 +350,7 @@ ieee80211_alloc_countryie(struct ieee802 if (c->ic_ieee != nextchan || c->ic_maxregpower != frm[-1]) { /* new run */ if (nruns == IEEE80211_COUNTRY_MAX_BANDS) { - if_printf(ic->ic_ifp, "%s: country ie too big, " + ic_printf(ic, "%s: country ie too big, " "runs > max %d, truncating\n", __func__, IEEE80211_COUNTRY_MAX_BANDS); /* XXX stat? fail? */ Modified: head/sys/net80211/ieee80211_var.h ============================================================================== --- head/sys/net80211/ieee80211_var.h Mon May 25 14:12:50 2015 (r283528) +++ head/sys/net80211/ieee80211_var.h Mon May 25 14:30:44 2015 (r283529) @@ -676,6 +676,7 @@ MALLOC_DECLARE(M_80211_VAP); "\20\1LDPC\2CHWIDTH40\5GREENFIELD\6SHORTGI20\7SHORTGI40\10TXSTBC" \ "\21AMPDU\22AMSDU\23HT\24SMPS\25RIFS" +int ic_printf(struct ieee80211com *, const char *, ...) __printflike(2, 3); void ieee80211_ifattach(struct ieee80211com *, const uint8_t macaddr[IEEE80211_ADDR_LEN]); void ieee80211_ifdetach(struct ieee80211com *);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201505251430.t4PEUiY9061003>