Commit 1e023829 authored by Joe Perches's avatar Joe Perches Committed by John W. Linville

brcm80211: Add and use brcmX_dbg_dump_hex

Reduce the number of #ifdef DEBUG uses by
adding a dbg_hex_dump routine which has the
appropriate #ifdef DEBUG test.
Signed-off-by: default avatarJoe Perches <joe@perches.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent d6400c29
...@@ -68,6 +68,12 @@ do { \ ...@@ -68,6 +68,12 @@ do { \
#endif /* defined(DEBUG) */ #endif /* defined(DEBUG) */
#define brcmf_dbg_hex_dump(test, data, len, fmt, ...) \
do { \
if (test) \
brcmu_dbg_hex_dump(data, len, fmt, ##__VA_ARGS__); \
} while (0)
extern int brcmf_msg_level; extern int brcmf_msg_level;
#endif /* _BRCMF_DBG_H_ */ #endif /* _BRCMF_DBG_H_ */
...@@ -1279,13 +1279,10 @@ static u8 brcmf_sdbrcm_rxglom(struct brcmf_sdio *bus, u8 rxseq) ...@@ -1279,13 +1279,10 @@ static u8 brcmf_sdbrcm_rxglom(struct brcmf_sdio *bus, u8 rxseq)
} }
return 0; return 0;
} }
#ifdef DEBUG
if (BRCMF_GLOM_ON()) { brcmf_dbg_hex_dump(BRCMF_GLOM_ON(),
printk(KERN_DEBUG "SUPERFRAME:\n"); pfirst->data, min_t(int, pfirst->len, 48),
print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, "SUPERFRAME:\n");
pfirst->data, min_t(int, pfirst->len, 48));
}
#endif
/* Validate the superframe header */ /* Validate the superframe header */
dptr = (u8 *) (pfirst->data); dptr = (u8 *) (pfirst->data);
...@@ -1362,13 +1359,8 @@ static u8 brcmf_sdbrcm_rxglom(struct brcmf_sdio *bus, u8 rxseq) ...@@ -1362,13 +1359,8 @@ static u8 brcmf_sdbrcm_rxglom(struct brcmf_sdio *bus, u8 rxseq)
check = get_unaligned_le16(dptr + sizeof(u16)); check = get_unaligned_le16(dptr + sizeof(u16));
chan = SDPCM_PACKET_CHANNEL(&dptr[SDPCM_FRAMETAG_LEN]); chan = SDPCM_PACKET_CHANNEL(&dptr[SDPCM_FRAMETAG_LEN]);
doff = SDPCM_DOFFSET_VALUE(&dptr[SDPCM_FRAMETAG_LEN]); doff = SDPCM_DOFFSET_VALUE(&dptr[SDPCM_FRAMETAG_LEN]);
#ifdef DEBUG brcmf_dbg_hex_dump(BRCMF_GLOM_ON(),
if (BRCMF_GLOM_ON()) { dptr, 32, "subframe:\n");
printk(KERN_DEBUG "subframe:\n");
print_hex_dump_bytes("", DUMP_PREFIX_OFFSET,
dptr, 32);
}
#endif
if ((u16)~(sublen ^ check)) { if ((u16)~(sublen ^ check)) {
brcmf_dbg(ERROR, "(subframe %d): HW hdr error: len/check 0x%04x/0x%04x\n", brcmf_dbg(ERROR, "(subframe %d): HW hdr error: len/check 0x%04x/0x%04x\n",
...@@ -1433,13 +1425,8 @@ static u8 brcmf_sdbrcm_rxglom(struct brcmf_sdio *bus, u8 rxseq) ...@@ -1433,13 +1425,8 @@ static u8 brcmf_sdbrcm_rxglom(struct brcmf_sdio *bus, u8 rxseq)
} }
rxseq++; rxseq++;
#ifdef DEBUG brcmf_dbg_hex_dump(BRCMF_BYTES_ON() && BRCMF_DATA_ON(),
if (BRCMF_BYTES_ON() && BRCMF_DATA_ON()) { dptr, dlen, "Rx Subframe Data:\n");
printk(KERN_DEBUG "Rx Subframe Data:\n");
print_hex_dump_bytes("", DUMP_PREFIX_OFFSET,
dptr, dlen);
}
#endif
__skb_trim(pfirst, sublen); __skb_trim(pfirst, sublen);
skb_pull(pfirst, doff); skb_pull(pfirst, doff);
...@@ -1457,17 +1444,13 @@ static u8 brcmf_sdbrcm_rxglom(struct brcmf_sdio *bus, u8 rxseq) ...@@ -1457,17 +1444,13 @@ static u8 brcmf_sdbrcm_rxglom(struct brcmf_sdio *bus, u8 rxseq)
continue; continue;
} }
#ifdef DEBUG brcmf_dbg_hex_dump(BRCMF_GLOM_ON(),
if (BRCMF_GLOM_ON()) { pfirst->data,
brcmf_dbg(GLOM, "subframe %d to stack, %p (%p/%d) nxt/lnk %p/%p\n", min_t(int, pfirst->len, 32),
bus->glom.qlen, pfirst, pfirst->data, "subframe %d to stack, %p (%p/%d) nxt/lnk %p/%p\n",
pfirst->len, pfirst->next, bus->glom.qlen, pfirst, pfirst->data,
pfirst->prev); pfirst->len, pfirst->next,
print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, pfirst->prev);
pfirst->data,
min_t(int, pfirst->len, 32));
}
#endif /* DEBUG */
} }
/* sent any remaining packets up */ /* sent any remaining packets up */
if (bus->glom.qlen) { if (bus->glom.qlen) {
...@@ -1584,12 +1567,8 @@ brcmf_sdbrcm_read_control(struct brcmf_sdio *bus, u8 *hdr, uint len, uint doff) ...@@ -1584,12 +1567,8 @@ brcmf_sdbrcm_read_control(struct brcmf_sdio *bus, u8 *hdr, uint len, uint doff)
gotpkt: gotpkt:
#ifdef DEBUG brcmf_dbg_hex_dump(BRCMF_BYTES_ON() && BRCMF_CTL_ON(),
if (BRCMF_BYTES_ON() && BRCMF_CTL_ON()) { bus->rxctl, len, "RxCtrl:\n");
printk(KERN_DEBUG "RxCtrl:\n");
print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, bus->rxctl, len);
}
#endif
/* Point to valid data and indicate its length */ /* Point to valid data and indicate its length */
bus->rxctl += doff; bus->rxctl += doff;
...@@ -1818,17 +1797,13 @@ brcmf_sdbrcm_readframes(struct brcmf_sdio *bus, uint maxframes, bool *finished) ...@@ -1818,17 +1797,13 @@ brcmf_sdbrcm_readframes(struct brcmf_sdio *bus, uint maxframes, bool *finished)
} }
bus->tx_max = txmax; bus->tx_max = txmax;
#ifdef DEBUG brcmf_dbg_hex_dump(BRCMF_BYTES_ON() && BRCMF_DATA_ON(),
if (BRCMF_BYTES_ON() && BRCMF_DATA_ON()) { rxbuf, len, "Rx Data:\n");
printk(KERN_DEBUG "Rx Data:\n"); brcmf_dbg_hex_dump(!(BRCMF_BYTES_ON() &&
print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, BRCMF_DATA_ON()) &&
rxbuf, len); BRCMF_HDRS_ON(),
} else if (BRCMF_HDRS_ON()) { bus->rxhdr, SDPCM_HDRLEN,
printk(KERN_DEBUG "RxHdr:\n"); "RxHdr:\n");
print_hex_dump_bytes("", DUMP_PREFIX_OFFSET,
bus->rxhdr, SDPCM_HDRLEN);
}
#endif
if (chan == SDPCM_CONTROL_CHANNEL) { if (chan == SDPCM_CONTROL_CHANNEL) {
brcmf_dbg(ERROR, "(nextlen): readahead on control packet %d?\n", brcmf_dbg(ERROR, "(nextlen): readahead on control packet %d?\n",
...@@ -1865,13 +1840,9 @@ brcmf_sdbrcm_readframes(struct brcmf_sdio *bus, uint maxframes, bool *finished) ...@@ -1865,13 +1840,9 @@ brcmf_sdbrcm_readframes(struct brcmf_sdio *bus, uint maxframes, bool *finished)
brcmf_sdbrcm_rxfail(bus, true, true); brcmf_sdbrcm_rxfail(bus, true, true);
continue; continue;
} }
#ifdef DEBUG brcmf_dbg_hex_dump(BRCMF_BYTES_ON() || BRCMF_HDRS_ON(),
if (BRCMF_BYTES_ON() || BRCMF_HDRS_ON()) { bus->rxhdr, SDPCM_HDRLEN, "RxHdr:\n");
printk(KERN_DEBUG "RxHdr:\n");
print_hex_dump_bytes("", DUMP_PREFIX_OFFSET,
bus->rxhdr, SDPCM_HDRLEN);
}
#endif
/* Extract hardware header fields */ /* Extract hardware header fields */
len = get_unaligned_le16(bus->rxhdr); len = get_unaligned_le16(bus->rxhdr);
...@@ -2024,13 +1995,8 @@ brcmf_sdbrcm_readframes(struct brcmf_sdio *bus, uint maxframes, bool *finished) ...@@ -2024,13 +1995,8 @@ brcmf_sdbrcm_readframes(struct brcmf_sdio *bus, uint maxframes, bool *finished)
skb_push(pkt, BRCMF_FIRSTREAD); skb_push(pkt, BRCMF_FIRSTREAD);
memcpy(pkt->data, bus->rxhdr, BRCMF_FIRSTREAD); memcpy(pkt->data, bus->rxhdr, BRCMF_FIRSTREAD);
#ifdef DEBUG brcmf_dbg_hex_dump(BRCMF_BYTES_ON() && BRCMF_DATA_ON(),
if (BRCMF_BYTES_ON() && BRCMF_DATA_ON()) { pkt->data, len, "Rx Data:\n");
printk(KERN_DEBUG "Rx Data:\n");
print_hex_dump_bytes("", DUMP_PREFIX_OFFSET,
pkt->data, len);
}
#endif
deliver: deliver:
/* Save superframe descriptor and allocate packet frame */ /* Save superframe descriptor and allocate packet frame */
...@@ -2038,14 +2004,9 @@ brcmf_sdbrcm_readframes(struct brcmf_sdio *bus, uint maxframes, bool *finished) ...@@ -2038,14 +2004,9 @@ brcmf_sdbrcm_readframes(struct brcmf_sdio *bus, uint maxframes, bool *finished)
if (SDPCM_GLOMDESC(&bus->rxhdr[SDPCM_FRAMETAG_LEN])) { if (SDPCM_GLOMDESC(&bus->rxhdr[SDPCM_FRAMETAG_LEN])) {
brcmf_dbg(GLOM, "glom descriptor, %d bytes:\n", brcmf_dbg(GLOM, "glom descriptor, %d bytes:\n",
len); len);
#ifdef DEBUG brcmf_dbg_hex_dump(BRCMF_GLOM_ON(),
if (BRCMF_GLOM_ON()) { pkt->data, len,
printk(KERN_DEBUG "Glom Data:\n"); "Glom Data:\n");
print_hex_dump_bytes("",
DUMP_PREFIX_OFFSET,
pkt->data, len);
}
#endif
__skb_trim(pkt, len); __skb_trim(pkt, len);
skb_pull(pkt, SDPCM_HDRLEN); skb_pull(pkt, SDPCM_HDRLEN);
bus->glomd = pkt; bus->glomd = pkt;
...@@ -2178,16 +2139,18 @@ static int brcmf_sdbrcm_txpkt(struct brcmf_sdio *bus, struct sk_buff *pkt, ...@@ -2178,16 +2139,18 @@ static int brcmf_sdbrcm_txpkt(struct brcmf_sdio *bus, struct sk_buff *pkt,
#ifdef DEBUG #ifdef DEBUG
tx_packets[pkt->priority]++; tx_packets[pkt->priority]++;
if (BRCMF_BYTES_ON() &&
(((BRCMF_CTL_ON() && (chan == SDPCM_CONTROL_CHANNEL)) || brcmf_dbg_hex_dump(BRCMF_BYTES_ON() &&
(BRCMF_DATA_ON() && (chan != SDPCM_CONTROL_CHANNEL))))) { ((BRCMF_CTL_ON() && chan == SDPCM_CONTROL_CHANNEL) ||
printk(KERN_DEBUG "Tx Frame:\n"); (BRCMF_DATA_ON() && chan != SDPCM_CONTROL_CHANNEL)),
print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, frame, len); frame, len, "Tx Frame:\n");
} else if (BRCMF_HDRS_ON()) { brcmf_dbg_hex_dump(!(BRCMF_BYTES_ON() &&
printk(KERN_DEBUG "TxHdr:\n"); ((BRCMF_CTL_ON() &&
print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, chan == SDPCM_CONTROL_CHANNEL) ||
frame, min_t(u16, len, 16)); (BRCMF_DATA_ON() &&
} chan != SDPCM_CONTROL_CHANNEL))) &&
BRCMF_HDRS_ON(),
frame, min_t(u16, len, 16), "TxHdr:\n");
#endif #endif
/* Raise len to next SDIO block to eliminate tail command */ /* Raise len to next SDIO block to eliminate tail command */
...@@ -2982,17 +2945,11 @@ brcmf_sdbrcm_bus_txctl(struct device *dev, unsigned char *msg, uint msglen) ...@@ -2982,17 +2945,11 @@ brcmf_sdbrcm_bus_txctl(struct device *dev, unsigned char *msg, uint msglen)
} }
if (ret == -1) { if (ret == -1) {
#ifdef DEBUG brcmf_dbg_hex_dump(BRCMF_BYTES_ON() && BRCMF_CTL_ON(),
if (BRCMF_BYTES_ON() && BRCMF_CTL_ON()) { frame, len, "Tx Frame:\n");
printk(KERN_DEBUG "Tx Frame:\n"); brcmf_dbg_hex_dump(!(BRCMF_BYTES_ON() && BRCMF_CTL_ON()) &&
print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, BRCMF_HDRS_ON(),
frame, len); frame, min_t(u16, len, 16), "TxHdr:\n");
} else if (BRCMF_HDRS_ON()) {
printk(KERN_DEBUG "TxHdr:\n");
print_hex_dump_bytes("", DUMP_PREFIX_OFFSET,
frame, min_t(u16, len, 16));
}
#endif
do { do {
ret = brcmf_tx_frame(bus, frame, len); ret = brcmf_tx_frame(bus, frame, len);
......
...@@ -253,4 +253,22 @@ void brcmu_prpkt(const char *msg, struct sk_buff *p0) ...@@ -253,4 +253,22 @@ void brcmu_prpkt(const char *msg, struct sk_buff *p0)
print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, p->data, p->len); print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, p->data, p->len);
} }
EXPORT_SYMBOL(brcmu_prpkt); EXPORT_SYMBOL(brcmu_prpkt);
void brcmu_dbg_hex_dump(const void *data, size_t size, const char *fmt, ...)
{
struct va_format vaf;
va_list args;
va_start(args, fmt);
vaf.fmt = fmt;
vaf.va = &args;
pr_debug("%pV", &vaf);
va_end(args);
print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, data, size);
}
EXPORT_SYMBOL(brcmu_dbg_hex_dump);
#endif /* defined(DEBUG) */ #endif /* defined(DEBUG) */
...@@ -182,4 +182,15 @@ extern void brcmu_prpkt(const char *msg, struct sk_buff *p0); ...@@ -182,4 +182,15 @@ extern void brcmu_prpkt(const char *msg, struct sk_buff *p0);
#define brcmu_prpkt(a, b) #define brcmu_prpkt(a, b)
#endif /* DEBUG */ #endif /* DEBUG */
#ifdef DEBUG
extern __printf(3, 4)
void brcmu_dbg_hex_dump(const void *data, size_t size, const char *fmt, ...);
#else
__printf(3, 4)
static inline
void brcmu_dbg_hex_dump(const void *data, size_t size, const char *fmt, ...)
{
}
#endif
#endif /* _BRCMU_UTILS_H_ */ #endif /* _BRCMU_UTILS_H_ */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment