Commit b33f0e28 authored by Henry Ptasinski's avatar Henry Ptasinski Committed by Greg Kroah-Hartman

staging: brcm80211: move utility functions into new module

Move utility functions shared by the brcmsmac and brcmfmac drivers into a new
module, brcmutil.ko.  This eliminates the need to compile and link the shared
functions into both drivers.  Prefix all exported symbols with "bcm_".

Cc: devel@linuxdriverproject.org
Reviewed-by: default avatarRoland Vossen <rvossen@broadcom.com>
Reviewed-by: default avatarBrett Rudley <brudley@broadcom.com>
Signed-off-by: default avatarArend van Spriel <arend@broadcom.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 4e458c1d
config BRCMUTIL
tristate
default n
config BRCMSMAC
tristate "Broadcom IEEE802.11n PCIe SoftMAC WLAN driver"
default n
depends on PCI
depends on WLAN && MAC80211
select BRCMUTIL
select FW_LOADER
select CRC_CCITT
---help---
......@@ -15,6 +20,7 @@ config BRCMFMAC
default n
depends on MMC
depends on WLAN && CFG80211
select BRCMUTIL
select FW_LOADER
select WIRELESS_EXT
select WEXT_PRIV
......
......@@ -19,5 +19,6 @@
subdir-ccflags-y := -DBCMDMA32
subdir-ccflags-$(CONFIG_BRCMDBG) += -DBCMDBG -DBCMDBG_ASSERT
obj-$(CONFIG_BRCMUTIL) += util/
obj-$(CONFIG_BRCMFMAC) += brcmfmac/
obj-$(CONFIG_BRCMSMAC) += brcmsmac/
......@@ -50,9 +50,7 @@ DHDOFILES = \
bcmsdh.o \
bcmsdh_linux.o \
bcmsdh_sdmmc.o \
bcmsdh_sdmmc_linux.o \
bcmutils.o \
bcmwifi.o
bcmsdh_sdmmc_linux.o
obj-m += brcmfmac.o
brcmfmac-objs += $(DHDOFILES)
......@@ -1042,9 +1042,9 @@ sdioh_request_buffer(sdioh_info_t *sd, uint pio_dma, uint fix_inc, uint write,
if (pkt == NULL) {
sd_data(("%s: Creating new %s Packet, len=%d\n",
__func__, write ? "TX" : "RX", buflen_u));
mypkt = pkt_buf_get_skb(buflen_u);
mypkt = bcm_pkt_buf_get_skb(buflen_u);
if (!mypkt) {
sd_err(("%s: pkt_buf_get_skb failed: len %d\n",
sd_err(("%s: bcm_pkt_buf_get_skb failed: len %d\n",
__func__, buflen_u));
return SDIOH_API_RC_FAIL;
}
......@@ -1060,7 +1060,7 @@ sdioh_request_buffer(sdioh_info_t *sd, uint pio_dma, uint fix_inc, uint write,
if (!write)
memcpy(buffer, mypkt->data, buflen_u);
pkt_buf_free_skb(mypkt);
bcm_pkt_buf_free_skb(mypkt);
} else if (((u32) (pkt->data) & DMA_ALIGN_MASK) != 0) {
/* Case 2: We have a packet, but it is unaligned. */
......@@ -1069,9 +1069,9 @@ sdioh_request_buffer(sdioh_info_t *sd, uint pio_dma, uint fix_inc, uint write,
sd_data(("%s: Creating aligned %s Packet, len=%d\n",
__func__, write ? "TX" : "RX", pkt->len));
mypkt = pkt_buf_get_skb(pkt->len);
mypkt = bcm_pkt_buf_get_skb(pkt->len);
if (!mypkt) {
sd_err(("%s: pkt_buf_get_skb failed: len %d\n",
sd_err(("%s: bcm_pkt_buf_get_skb failed: len %d\n",
__func__, pkt->len));
return SDIOH_API_RC_FAIL;
}
......@@ -1087,7 +1087,7 @@ sdioh_request_buffer(sdioh_info_t *sd, uint pio_dma, uint fix_inc, uint write,
if (!write)
memcpy(pkt->data, mypkt->data, mypkt->len);
pkt_buf_free_skb(mypkt);
bcm_pkt_buf_free_skb(mypkt);
} else { /* case 3: We have a packet and
it is aligned. */
sd_data(("%s: Aligned %s Packet, direct DMA\n",
......
......@@ -316,7 +316,7 @@ bool dhd_prec_enq(dhd_pub_t *dhdp, struct pktq *q, struct sk_buff *pkt,
* exceeding total queue length
*/
if (!pktq_pfull(q, prec) && !pktq_full(q)) {
pktq_penq(q, prec, pkt);
bcm_pktq_penq(q, prec, pkt);
return true;
}
......@@ -324,7 +324,7 @@ bool dhd_prec_enq(dhd_pub_t *dhdp, struct pktq *q, struct sk_buff *pkt,
if (pktq_pfull(q, prec))
eprec = prec;
else if (pktq_full(q)) {
p = pktq_peek_tail(q, &eprec);
p = bcm_pktq_peek_tail(q, &eprec);
ASSERT(p);
if (eprec > prec)
return false;
......@@ -338,21 +338,21 @@ bool dhd_prec_enq(dhd_pub_t *dhdp, struct pktq *q, struct sk_buff *pkt,
if (eprec == prec && !discard_oldest)
return false; /* refuse newer (incoming) packet */
/* Evict packet according to discard policy */
p = discard_oldest ? pktq_pdeq(q, eprec) : pktq_pdeq_tail(q,
eprec);
p = discard_oldest ? bcm_pktq_pdeq(q, eprec) :
bcm_pktq_pdeq_tail(q, eprec);
if (p == NULL) {
DHD_ERROR(("%s: pktq_penq() failed, oldest %d.",
DHD_ERROR(("%s: bcm_pktq_penq() failed, oldest %d.",
__func__, discard_oldest));
ASSERT(p);
}
pkt_buf_free_skb(p);
bcm_pkt_buf_free_skb(p);
}
/* Enqueue */
p = pktq_penq(q, prec, pkt);
p = bcm_pktq_penq(q, prec, pkt);
if (p == NULL) {
DHD_ERROR(("%s: pktq_penq() failed.", __func__));
DHD_ERROR(("%s: bcm_pktq_penq() failed.", __func__));
ASSERT(p);
}
......
......@@ -375,7 +375,7 @@ wl_iw_set_freq(struct net_device *dev,
if (fwrq->m > 4000 && fwrq->m < 5000)
sf = WF_CHAN_FACTOR_4_G;
chan = wf_mhz2channel(fwrq->m, sf);
chan = bcm_mhz2channel(fwrq->m, sf);
}
chan = cpu_to_le32(chan);
......
......@@ -51,8 +51,6 @@ BRCMSMAC_OFILES := \
bcmsrom.o \
hnddma.o \
nicpci.o \
../util/bcmutils.o \
../util/bcmwifi.o \
nvram.o
MODULEPFX := brcmsmac
......
......@@ -256,7 +256,7 @@ sprom_read_pci(si_t *sih, u16 *sprom, uint wordoff,
/* fixup the endianness so crc8 will pass */
htol16_buf(buf, nwords * 2);
if (hndcrc8((u8 *) buf, nwords * 2, CRC8_INIT_VALUE) !=
if (bcm_crc8((u8 *) buf, nwords * 2, CRC8_INIT_VALUE) !=
CRC8_GOOD_VALUE) {
/* DBG only pci always read srom4 first, then srom8/9 */
err = 1;
......@@ -296,7 +296,7 @@ static int otp_read_pci(si_t *sih, u16 *buf, uint bufsz)
/* fixup the endianness so crc8 will pass */
htol16_buf(buf, bufsz);
if (hndcrc8((u8 *) buf, SROM4_WORDS * 2, CRC8_INIT_VALUE) !=
if (bcm_crc8((u8 *) buf, SROM4_WORDS * 2, CRC8_INIT_VALUE) !=
CRC8_GOOD_VALUE) {
err = 1;
}
......
......@@ -772,7 +772,7 @@ static void *BCMFASTPATH _dma_rx(dma_info_t *di)
if ((di->hnddma.dmactrlflags & DMA_CTRL_RXMULTI) == 0) {
DMA_ERROR(("%s: dma_rx: bad frame length (%d)\n",
di->name, len));
pkt_buf_free_skb(head);
bcm_pkt_buf_free_skb(head);
di->hnddma.rxgiants++;
goto next_frame;
}
......@@ -820,7 +820,7 @@ static bool BCMFASTPATH _dma_rxfill(dma_info_t *di)
size to be allocated
*/
p = pkt_buf_get_skb(di->rxbufsize + extra_offset);
p = bcm_pkt_buf_get_skb(di->rxbufsize + extra_offset);
if (p == NULL) {
DMA_ERROR(("%s: dma_rxfill: out of rxbufs\n",
......@@ -918,7 +918,7 @@ static void _dma_rxreclaim(dma_info_t *di)
DMA_TRACE(("%s: dma_rxreclaim\n", di->name));
while ((p = _dma_getnextrxp(di, true)))
pkt_buf_free_skb(p);
bcm_pkt_buf_free_skb(p);
}
static void *BCMFASTPATH _dma_getnextrxp(dma_info_t *di, bool forceall)
......@@ -1152,7 +1152,7 @@ static void BCMFASTPATH dma64_txreclaim(dma_info_t *di, txd_range_t range)
while ((p = dma64_getnexttxp(di, range))) {
/* For unframed data, we don't have any packets to free */
if (!(di->hnddma.dmactrlflags & DMA_CTRL_UNFRAMED))
pkt_buf_free_skb(p);
bcm_pkt_buf_free_skb(p);
}
}
......@@ -1489,7 +1489,7 @@ static int BCMFASTPATH dma64_txfast(dma_info_t *di, struct sk_buff *p0,
outoftxd:
DMA_ERROR(("%s: dma_txfast: out of txds !!!\n", di->name));
pkt_buf_free_skb(p0);
bcm_pkt_buf_free_skb(p0);
di->hnddma.txavail = 0;
di->hnddma.txnobuf++;
return -1;
......
......@@ -593,7 +593,7 @@ wl_ops_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
wl->pub->global_ampdu = &(scb->scb_ampdu);
wl->pub->global_ampdu->scb = scb;
wl->pub->global_ampdu->max_pdu = 16;
pktq_init(&scb->scb_ampdu.txq, AMPDU_MAX_SCB_TID,
bcm_pktq_init(&scb->scb_ampdu.txq, AMPDU_MAX_SCB_TID,
AMPDU_MAX_SCB_TID * PKTQ_LEN_DEFAULT);
sta->ht_cap.ht_supported = true;
......
......@@ -622,7 +622,7 @@ wlc_sendampdu(struct ampdu_info *ampdu, struct wlc_txq_info *qi,
len = roundup(len, 4);
ampdu_len += (len + (ndelim + 1) * AMPDU_DELIMITER_LEN);
dma_len += (u16) pkttotlen(p);
dma_len += (u16) bcm_pkttotlen(p);
BCMMSG(wlc->wiphy, "wl%d: ampdu_len %d"
" seg_cnt %d null delim %d\n",
......@@ -718,7 +718,7 @@ wlc_sendampdu(struct ampdu_info *ampdu, struct wlc_txq_info *qi,
((u8) (p->priority) == tid)) {
plen =
pkttotlen(p) + AMPDU_MAX_MPDU_OVERHEAD;
bcm_pkttotlen(p) + AMPDU_MAX_MPDU_OVERHEAD;
plen = max(scb_ampdu->min_len, plen);
if ((plen + ampdu_len) > maxlen) {
......@@ -735,7 +735,7 @@ wlc_sendampdu(struct ampdu_info *ampdu, struct wlc_txq_info *qi,
p = NULL;
continue;
}
p = pktq_pdeq(&qi->q, prec);
p = bcm_pktq_pdeq(&qi->q, prec);
} else {
p = NULL;
}
......@@ -899,7 +899,7 @@ wlc_ampdu_dotxstatus(struct ampdu_info *ampdu, struct scb *scb,
tx_info = IEEE80211_SKB_CB(p);
txh = (d11txh_t *) p->data;
mcl = le16_to_cpu(txh->MacTxControlLow);
pkt_buf_free_skb(p);
bcm_pkt_buf_free_skb(p);
/* break out if last packet of ampdu */
if (((mcl & TXC_AMPDU_MASK) >> TXC_AMPDU_SHIFT) ==
TXC_AMPDU_LAST)
......@@ -1034,7 +1034,7 @@ wlc_ampdu_dotxstatus_complete(struct ampdu_info *ampdu, struct scb *scb,
txs->phyerr);
if (WL_ERROR_ON()) {
prpkt("txpkt (AMPDU)", p);
bcm_prpkt("txpkt (AMPDU)", p);
wlc_print_txdesc((d11txh_t *) p->data);
}
wlc_print_txstatus(txs);
......@@ -1148,7 +1148,7 @@ ampdu_cleanup_tid_ini(struct ampdu_info *ampdu, scb_ampdu_t *scb_ampdu, u8 tid,
scb_ampdu = SCB_AMPDU_CUBBY(ampdu, ini->scb);
/* free all buffered tx packets */
pktq_pflush(&scb_ampdu->txq, ini->tid, true, NULL, 0);
bcm_pktq_pflush(&scb_ampdu->txq, ini->tid, true, NULL, 0);
}
/* initialize the initiator code for tid */
......@@ -1337,7 +1337,7 @@ void wlc_ampdu_flush(struct wlc_info *wlc,
ampdu_pars.sta = sta;
ampdu_pars.tid = tid;
for (prec = 0; prec < pq->num_prec; prec++) {
pktq_pflush(pq, prec, true, cb_del_ampdu_pkt,
bcm_pktq_pflush(pq, prec, true, cb_del_ampdu_pkt,
(int)&ampdu_pars);
}
wlc_inval_dma_pkts(wlc->hw, sta, dma_cb_fn_ampdu);
......
......@@ -1494,7 +1494,7 @@ wlc_valid_chanspec_ext(wlc_cm_info_t *wlc_cm, chanspec_t chspec, bool dualband)
u8 channel = CHSPEC_CHANNEL(chspec);
/* check the chanspec */
if (wf_chspec_malformed(chspec)) {
if (bcm_chspec_malformed(chspec)) {
wiphy_err(wlc->wiphy, "wl%d: malformed chanspec 0x%x\n",
wlc->pub->unit, chspec);
return false;
......
......@@ -709,8 +709,8 @@ static u8 wlc_local_constraint_qdbm(struct wlc_info *wlc)
local = WLC_TXPWR_MAX;
if (wlc->pub->associated &&
(wf_chspec_ctlchan(wlc->chanspec) ==
wf_chspec_ctlchan(wlc->home_chanspec))) {
(bcm_chspec_ctlchan(wlc->chanspec) ==
bcm_chspec_ctlchan(wlc->home_chanspec))) {
/* get the local power constraint if we are on the AP's
* channel [802.11h, 7.3.2.13]
......@@ -2521,7 +2521,7 @@ uint wlc_down(struct wlc_info *wlc)
/* flush tx queues */
for (qi = wlc->tx_queues; qi != NULL; qi = qi->next) {
pktq_flush(&qi->q, true, NULL, 0);
bcm_pktq_flush(&qi->q, true, NULL, 0);
}
callbacks += wlc_bmac_down_finish(wlc->hw);
......@@ -4682,7 +4682,8 @@ void wlc_print_txdesc(d11txh_t *txh)
char hexbuf[256];
/* add plcp header along with txh descriptor */
prhex("Raw TxDesc + plcp header", (unsigned char *) txh, sizeof(d11txh_t) + 48);
bcm_prhex("Raw TxDesc + plcp header", (unsigned char *) txh,
sizeof(d11txh_t) + 48);
printk(KERN_DEBUG "TxCtlLow: %04x ", mtcl);
printk(KERN_DEBUG "TxCtlHigh: %04x ", mtch);
......@@ -4753,7 +4754,7 @@ void wlc_print_rxh(d11rxhdr_t *rxh)
{0, NULL}
};
prhex("Raw RxDesc", (unsigned char *) rxh, sizeof(d11rxhdr_t));
bcm_prhex("Raw RxDesc", (unsigned char *) rxh, sizeof(d11rxhdr_t));
bcm_format_flags(macstat_flags, macstatus1, flagstr, 64);
......@@ -4829,7 +4830,7 @@ wlc_prec_enq_head(struct wlc_info *wlc, struct pktq *q, struct sk_buff *pkt,
if (pktq_pfull(q, prec))
eprec = prec;
else if (pktq_full(q)) {
p = pktq_peek_tail(q, &eprec);
p = bcm_pktq_peek_tail(q, &eprec);
if (eprec > prec) {
wiphy_err(wlc->wiphy, "%s: Failing: eprec %d > prec %d"
"\n", __func__, eprec, prec);
......@@ -4851,25 +4852,25 @@ wlc_prec_enq_head(struct wlc_info *wlc, struct pktq *q, struct sk_buff *pkt,
}
/* Evict packet according to discard policy */
p = discard_oldest ? pktq_pdeq(q, eprec) : pktq_pdeq_tail(q,
eprec);
p = discard_oldest ? bcm_pktq_pdeq(q, eprec) :
bcm_pktq_pdeq_tail(q, eprec);
/* Increment wme stats */
if (WME_ENAB(wlc->pub)) {
WLCNTINCR(wlc->pub->_wme_cnt->
tx_failed[WME_PRIO2AC(p->priority)].packets);
WLCNTADD(wlc->pub->_wme_cnt->
tx_failed[WME_PRIO2AC(p->priority)].bytes,
pkttotlen(p));
bcm_pkttotlen(p));
}
pkt_buf_free_skb(p);
bcm_pkt_buf_free_skb(p);
wlc->pub->_cnt->txnobuf++;
}
/* Enqueue */
if (head)
p = pktq_penq_head(q, prec, pkt);
p = bcm_pktq_penq_head(q, prec, pkt);
else
p = pktq_penq(q, prec, pkt);
p = bcm_pktq_penq(q, prec, pkt);
return true;
}
......@@ -4894,7 +4895,7 @@ void BCMFASTPATH wlc_txq_enq(void *ctx, struct scb *scb, struct sk_buff *sdu,
* XXX we might hit this condtion in case
* packet flooding from mac80211 stack
*/
pkt_buf_free_skb(sdu);
bcm_pkt_buf_free_skb(sdu);
wlc->pub->_cnt->txnobuf++;
}
......@@ -4961,7 +4962,7 @@ void BCMFASTPATH wlc_send_q(struct wlc_info *wlc)
/* Send all the enq'd pkts that we can.
* Dequeue packets with precedence with empty HW fifo only
*/
while (prec_map && (pkt[0] = pktq_mdeq(q, prec_map, &prec))) {
while (prec_map && (pkt[0] = bcm_pktq_mdeq(q, prec_map, &prec))) {
tx_info = IEEE80211_SKB_CB(pkt[0]);
if (tx_info->flags & IEEE80211_TX_CTL_AMPDU) {
err = wlc_sendampdu(wlc->ampdu, qi, pkt, prec);
......@@ -4976,7 +4977,7 @@ void BCMFASTPATH wlc_send_q(struct wlc_info *wlc)
}
if (err == -EBUSY) {
pktq_penq_head(q, prec, pkt[0]);
bcm_pktq_penq_head(q, prec, pkt[0]);
/* If send failed due to any other reason than a change in
* HW FIFO condition, quit. Otherwise, read the new prec_map!
*/
......@@ -5444,7 +5445,7 @@ wlc_d11hdrs_mac80211(struct wlc_info *wlc, struct ieee80211_hw *hw,
qos = ieee80211_is_data_qos(h->frame_control);
/* compute length of frame in bytes for use in PLCP computations */
len = pkttotlen(p);
len = bcm_pkttotlen(p);
phylen = len + FCS_LEN;
/* If WEP enabled, add room in phylen for the additional bytes of
......@@ -6330,7 +6331,7 @@ wlc_dotxstatus(struct wlc_info *wlc, tx_status_t *txs, u32 frm_tx2)
tx_info->flags |= IEEE80211_TX_STAT_ACK;
}
totlen = pkttotlen(p);
totlen = bcm_pkttotlen(p);
free_pdu = true;
wlc_txfifo_complete(wlc, queue, 1);
......@@ -6353,7 +6354,7 @@ wlc_dotxstatus(struct wlc_info *wlc, tx_status_t *txs, u32 frm_tx2)
fatal:
if (p)
pkt_buf_free_skb(p);
bcm_pkt_buf_free_skb(p);
return true;
......@@ -6758,7 +6759,7 @@ void BCMFASTPATH wlc_recv(struct wlc_info *wlc, struct sk_buff *p)
return;
toss:
pkt_buf_free_skb(p);
bcm_pkt_buf_free_skb(p);
}
/* calculate frame duration for Mixed-mode L-SIG spoofing, return
......@@ -8049,7 +8050,7 @@ static struct wlc_txq_info *wlc_txq_alloc(struct wlc_info *wlc)
* leave PS mode. The watermark for flowcontrol to OS packets
* will remain the same
*/
pktq_init(&qi->q, WLC_PREC_COUNT,
bcm_pktq_init(&qi->q, WLC_PREC_COUNT,
(2 * wlc->pub->tunables->datahiwat) + PKTQ_LEN_DEFAULT
+ wlc->pub->psq_pkts_total);
......@@ -8133,7 +8134,7 @@ void wlc_wait_for_tx_completion(struct wlc_info *wlc, bool drop)
{
/* flush packet queue when requested */
if (drop)
pktq_flush(&wlc->pkt_queue->q, false, NULL, 0);
bcm_pktq_flush(&wlc->pkt_queue->q, false, NULL, 0);
/* wait for queue and DMA fifos to run dry */
while (!pktq_empty(&wlc->pkt_queue->q) ||
......
......@@ -87,25 +87,26 @@
#define pktq_ppeek(pq, prec) ((pq)->q[prec].head)
#define pktq_ppeek_tail(pq, prec) ((pq)->q[prec].tail)
extern struct sk_buff *pktq_penq(struct pktq *pq, int prec,
extern struct sk_buff *bcm_pktq_penq(struct pktq *pq, int prec,
struct sk_buff *p);
extern struct sk_buff *pktq_penq_head(struct pktq *pq, int prec,
extern struct sk_buff *bcm_pktq_penq_head(struct pktq *pq, int prec,
struct sk_buff *p);
extern struct sk_buff *pktq_pdeq(struct pktq *pq, int prec);
extern struct sk_buff *pktq_pdeq_tail(struct pktq *pq, int prec);
extern struct sk_buff *bcm_pktq_pdeq(struct pktq *pq, int prec);
extern struct sk_buff *bcm_pktq_pdeq_tail(struct pktq *pq, int prec);
/* packet primitives */
extern struct sk_buff *pkt_buf_get_skb(uint len);
extern void pkt_buf_free_skb(struct sk_buff *skb);
extern struct sk_buff *bcm_pkt_buf_get_skb(uint len);
extern void bcm_pkt_buf_free_skb(struct sk_buff *skb);
/* Empty the queue at particular precedence level */
extern void pktq_pflush(struct pktq *pq, int prec,
extern void bcm_pktq_pflush(struct pktq *pq, int prec,
bool dir, ifpkt_cb_t fn, int arg);
/* operations on a set of precedences in packet queue */
extern int pktq_mlen(struct pktq *pq, uint prec_bmp);
extern struct sk_buff *pktq_mdeq(struct pktq *pq, uint prec_bmp, int *prec_out);
extern int bcm_pktq_mlen(struct pktq *pq, uint prec_bmp);
extern struct sk_buff *bcm_pktq_mdeq(struct pktq *pq, uint prec_bmp,
int *prec_out);
/* operations on packet queue as a whole */
......@@ -116,35 +117,35 @@ extern struct sk_buff *pktq_mdeq(struct pktq *pq, uint prec_bmp, int *prec_out);
#define pktq_empty(pq) ((pq)->len == 0)
/* operations for single precedence queues */
#define pktenq(pq, p) pktq_penq(((struct pktq *)pq), 0, (p))
#define pktenq_head(pq, p) pktq_penq_head(((struct pktq *)pq), 0, (p))
#define pktdeq(pq) pktq_pdeq(((struct pktq *)pq), 0)
#define pktdeq_tail(pq) pktq_pdeq_tail(((struct pktq *)pq), 0)
#define pktqinit(pq, len) pktq_init(((struct pktq *)pq), 1, len)
#define pktenq(pq, p) bcm_pktq_penq(((struct pktq *)pq), 0, (p))
#define pktenq_head(pq, p) bcm_pktq_penq_head(((struct pktq *)pq), 0, (p))
#define pktdeq(pq) bcm_pktq_pdeq(((struct pktq *)pq), 0)
#define pktdeq_tail(pq) bcm_pktq_pdeq_tail(((struct pktq *)pq), 0)
#define pktqinit(pq, len) bcm_pktq_init(((struct pktq *)pq), 1, len)
extern void pktq_init(struct pktq *pq, int num_prec, int max_len);
extern void bcm_pktq_init(struct pktq *pq, int num_prec, int max_len);
/* prec_out may be NULL if caller is not interested in return value */
extern struct sk_buff *pktq_peek_tail(struct pktq *pq, int *prec_out);
extern void pktq_flush(struct pktq *pq, bool dir,
ifpkt_cb_t fn, int arg);
extern struct sk_buff *bcm_pktq_peek_tail(struct pktq *pq, int *prec_out);
extern void bcm_pktq_flush(struct pktq *pq, bool dir,
ifpkt_cb_t fn, int arg);
/* externs */
/* packet */
extern uint pktfrombuf(struct sk_buff *p,
uint offset, int len, unsigned char *buf);
extern uint pkttotlen(struct sk_buff *p);
extern uint bcm_pktfrombuf(struct sk_buff *p,
uint offset, int len, unsigned char *buf);
extern uint bcm_pkttotlen(struct sk_buff *p);
/* ethernet address */
extern int bcm_ether_atoe(char *p, u8 *ea);
extern int bcm_ether_atoe(char *p, u8 *ea);
/* ip address */
struct ipv4_addr;
extern char *bcm_ip_ntoa(struct ipv4_addr *ia, char *buf);
#ifdef BCMDBG
extern void prpkt(const char *msg, struct sk_buff *p0);
extern void bcm_prpkt(const char *msg, struct sk_buff *p0);
#else
#define prpkt(a, b)
#define bcm_prpkt(a, b)
#endif /* BCMDBG */
#define bcm_perf_enable()
......@@ -467,7 +468,7 @@ extern struct sk_buff *pktq_mdeq(struct pktq *pq, uint prec_bmp, int *prec_out);
/* externs */
/* crc */
extern u8 hndcrc8(u8 *p, uint nbytes, u8 crc);
extern u8 bcm_crc8(u8 *p, uint nbytes, u8 crc);
/* format/print */
#if defined(BCMDBG)
extern int bcm_format_flags(const bcm_bit_desc_t *bd, u32 flags,
......@@ -475,7 +476,7 @@ extern struct sk_buff *pktq_mdeq(struct pktq *pq, uint prec_bmp, int *prec_out);
extern int bcm_format_hex(char *str, const void *bytes, int len);
#endif
extern char *bcm_chipname(uint chipid, char *buf, uint len);
extern void prhex(const char *msg, unsigned char *buf, uint len);
extern void bcm_prhex(const char *msg, unsigned char *buf, uint len);
extern bcm_tlv_t *bcm_parse_tlvs(void *buf, int buflen,
uint key);
......
......@@ -134,14 +134,14 @@ typedef u16 chanspec_t;
* combination could be legal given any set of circumstances.
* RETURNS: true is the chanspec is malformed, false if it looks good.
*/
extern bool wf_chspec_malformed(chanspec_t chanspec);
extern bool bcm_chspec_malformed(chanspec_t chanspec);
/*
* This function returns the channel number that control traffic is being sent on, for legacy
* channels this is just the channel number, for 40MHZ channels it is the upper or lowre 20MHZ
* sideband depending on the chanspec selected
*/
extern u8 wf_chspec_ctlchan(chanspec_t chspec);
extern u8 bcm_chspec_ctlchan(chanspec_t chspec);
/*
* Return the channel number for a given frequency and base frequency.
......@@ -162,6 +162,6 @@ extern u8 wf_chspec_ctlchan(chanspec_t chspec);
*
* Reference 802.11 REVma, section 17.3.8.3, and 802.11B section 18.4.6.2
*/
extern int wf_mhz2channel(uint freq, uint start_factor);
extern int bcm_mhz2channel(uint freq, uint start_factor);
#endif /* _bcmwifi_h_ */
#
# Makefile fragment for Broadcom 802.11n Networking Device Driver Utilities
#
# Copyright (c) 2011 Broadcom Corporation
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
# SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
# OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
ccflags-y := \
-Idrivers/staging/brcm80211/util \
-Idrivers/staging/brcm80211/include
BRCMUTIL_OFILES := \
bcmutils.o \
bcmwifi.o
MODULEPFX := brcmutil
obj-$(CONFIG_BRCMUTIL) += $(MODULEPFX).o
$(MODULEPFX)-objs = $(BRCMUTIL_OFILES)
......@@ -28,7 +28,12 @@
#include <bcmdevs.h>
#include <proto/802.11.h>
struct sk_buff *BCMFASTPATH pkt_buf_get_skb(uint len)
MODULE_AUTHOR("Broadcom Corporation");
MODULE_DESCRIPTION("Broadcom 802.11n wireless LAN driver utilities.");
MODULE_SUPPORTED_DEVICE("Broadcom 802.11n WLAN cards");
MODULE_LICENSE("Dual BSD/GPL");
struct sk_buff *BCMFASTPATH bcm_pkt_buf_get_skb(uint len)
{
struct sk_buff *skb;
......@@ -40,9 +45,10 @@ struct sk_buff *BCMFASTPATH pkt_buf_get_skb(uint len)
return skb;
}
EXPORT_SYMBOL(bcm_pkt_buf_get_skb);
/* Free the driver packet. Free the tag if present */
void BCMFASTPATH pkt_buf_free_skb(struct sk_buff *skb)
void BCMFASTPATH bcm_pkt_buf_free_skb(struct sk_buff *skb)
{
struct sk_buff *nskb;
int nest = 0;
......@@ -67,9 +73,11 @@ void BCMFASTPATH pkt_buf_free_skb(struct sk_buff *skb)
skb = nskb;
}
}
EXPORT_SYMBOL(bcm_pkt_buf_free_skb);
/* copy a buffer into a pkt buffer chain */
uint pktfrombuf(struct sk_buff *p, uint offset, int len,
uint bcm_pktfrombuf(struct sk_buff *p, uint offset, int len,
unsigned char *buf)
{
uint n, ret = 0;
......@@ -96,8 +104,10 @@ uint pktfrombuf(struct sk_buff *p, uint offset, int len,
return ret;
}
EXPORT_SYMBOL(bcm_pktfrombuf);
/* return total length of buffer chain */
uint BCMFASTPATH pkttotlen(struct sk_buff *p)
uint BCMFASTPATH bcm_pkttotlen(struct sk_buff *p)
{
uint total;
......@@ -106,12 +116,13 @@ uint BCMFASTPATH pkttotlen(struct sk_buff *p)
total += p->len;
return total;
}
EXPORT_SYMBOL(bcm_pkttotlen);
/*
* osl multiple-precedence packet queue
* hi_prec is always >= the number of the highest non-empty precedence
*/
struct sk_buff *BCMFASTPATH pktq_penq(struct pktq *pq, int prec,
struct sk_buff *BCMFASTPATH bcm_pktq_penq(struct pktq *pq, int prec,
struct sk_buff *p)
{
struct pktq_prec *q;
......@@ -136,8 +147,9 @@ struct sk_buff *BCMFASTPATH pktq_penq(struct pktq *pq, int prec,
return p;
}
EXPORT_SYMBOL(bcm_pktq_penq);
struct sk_buff *BCMFASTPATH pktq_penq_head(struct pktq *pq, int prec,
struct sk_buff *BCMFASTPATH bcm_pktq_penq_head(struct pktq *pq, int prec,
struct sk_buff *p)
{
struct pktq_prec *q;
......@@ -161,8 +173,9 @@ struct sk_buff *BCMFASTPATH pktq_penq_head(struct pktq *pq, int prec,
return p;
}
EXPORT_SYMBOL(bcm_pktq_penq_head);
struct sk_buff *BCMFASTPATH pktq_pdeq(struct pktq *pq, int prec)
struct sk_buff *BCMFASTPATH bcm_pktq_pdeq(struct pktq *pq, int prec)
{
struct pktq_prec *q;
struct sk_buff *p;
......@@ -185,8 +198,9 @@ struct sk_buff *BCMFASTPATH pktq_pdeq(struct pktq *pq, int prec)
return p;
}
EXPORT_SYMBOL(bcm_pktq_pdeq);
struct sk_buff *BCMFASTPATH pktq_pdeq_tail(struct pktq *pq, int prec)
struct sk_buff *BCMFASTPATH bcm_pktq_pdeq_tail(struct pktq *pq, int prec)
{
struct pktq_prec *q;
struct sk_buff *p, *prev;
......@@ -212,9 +226,10 @@ struct sk_buff *BCMFASTPATH pktq_pdeq_tail(struct pktq *pq, int prec)
return p;
}
EXPORT_SYMBOL(bcm_pktq_pdeq_tail);
void
pktq_pflush(struct pktq *pq, int prec, bool dir,
bcm_pktq_pflush(struct pktq *pq, int prec, bool dir,
ifpkt_cb_t fn, int arg)
{
struct pktq_prec *q;
......@@ -230,7 +245,7 @@ pktq_pflush(struct pktq *pq, int prec, bool dir,
else
prev->prev = p->prev;
p->prev = NULL;
pkt_buf_free_skb(p);
bcm_pkt_buf_free_skb(p);
q->len--;
pq->len--;
p = (head ? q->head : prev->prev);
......@@ -244,16 +259,18 @@ pktq_pflush(struct pktq *pq, int prec, bool dir,
q->tail = NULL;
}
}
EXPORT_SYMBOL(bcm_pktq_pflush);
void pktq_flush(struct pktq *pq, bool dir,
void bcm_pktq_flush(struct pktq *pq, bool dir,
ifpkt_cb_t fn, int arg)
{
int prec;
for (prec = 0; prec < pq->num_prec; prec++)
pktq_pflush(pq, prec, dir, fn, arg);
bcm_pktq_pflush(pq, prec, dir, fn, arg);
}
EXPORT_SYMBOL(bcm_pktq_flush);
void pktq_init(struct pktq *pq, int num_prec, int max_len)
void bcm_pktq_init(struct pktq *pq, int num_prec, int max_len)
{
int prec;
......@@ -268,8 +285,9 @@ void pktq_init(struct pktq *pq, int num_prec, int max_len)
for (prec = 0; prec < num_prec; prec++)
pq->q[prec].max = pq->max;
}
EXPORT_SYMBOL(bcm_pktq_init);
struct sk_buff *pktq_peek_tail(struct pktq *pq, int *prec_out)
struct sk_buff *bcm_pktq_peek_tail(struct pktq *pq, int *prec_out)
{
int prec;
......@@ -285,9 +303,10 @@ struct sk_buff *pktq_peek_tail(struct pktq *pq, int *prec_out)
return pq->q[prec].tail;
}
EXPORT_SYMBOL(bcm_pktq_peek_tail);
/* Return sum of lengths of a specific set of precedences */
int pktq_mlen(struct pktq *pq, uint prec_bmp)
int bcm_pktq_mlen(struct pktq *pq, uint prec_bmp)
{
int prec, len;
......@@ -299,8 +318,10 @@ int pktq_mlen(struct pktq *pq, uint prec_bmp)
return len;
}
EXPORT_SYMBOL(bcm_pktq_mlen);
/* Priority dequeue from a specific set of precedences */
struct sk_buff *BCMFASTPATH pktq_mdeq(struct pktq *pq, uint prec_bmp,
struct sk_buff *BCMFASTPATH bcm_pktq_mdeq(struct pktq *pq, uint prec_bmp,
int *prec_out)
{
struct pktq_prec *q;
......@@ -338,6 +359,7 @@ struct sk_buff *BCMFASTPATH pktq_mdeq(struct pktq *pq, uint prec_bmp,
return p;
}
EXPORT_SYMBOL(bcm_pktq_mdeq);
/* parse a xx:xx:xx:xx:xx:xx format ethernet address */
int bcm_ether_atoe(char *p, u8 *ea)
......@@ -352,10 +374,11 @@ int bcm_ether_atoe(char *p, u8 *ea)
return i == 6;
}
EXPORT_SYMBOL(bcm_ether_atoe);
#if defined(BCMDBG)
/* pretty hex print a pkt buffer chain */
void prpkt(const char *msg, struct sk_buff *p0)
void bcm_prpkt(const char *msg, struct sk_buff *p0)
{
struct sk_buff *p;
......@@ -363,8 +386,9 @@ void prpkt(const char *msg, struct sk_buff *p0)
printk(KERN_DEBUG "%s:\n", msg);
for (p = p0; p; p = p->next)
prhex(NULL, p->data, p->len);
bcm_prhex(NULL, p->data, p->len);
}
EXPORT_SYMBOL(bcm_prpkt);
#endif /* defined(BCMDBG) */
/* iovar table lookup */
......@@ -388,6 +412,7 @@ const bcm_iovar_t *bcm_iovar_lookup(const bcm_iovar_t *table, const char *name)
return NULL; /* var name not found */
}
EXPORT_SYMBOL(bcm_iovar_lookup);
int bcm_iovar_lencheck(const bcm_iovar_t *vi, void *arg, int len, bool set)
{
......@@ -432,6 +457,7 @@ int bcm_iovar_lencheck(const bcm_iovar_t *vi, void *arg, int len, bool set)
return bcmerror;
}
EXPORT_SYMBOL(bcm_iovar_lencheck);
/*******************************************************************************
* crc8
......@@ -490,7 +516,7 @@ static const u8 crc8_table[256] = {
0xF4, 0x03, 0x4D, 0xBA, 0xD1, 0x26, 0x68, 0x9F
};
u8 hndcrc8(u8 *pdata, /* pointer to array of data to process */
u8 bcm_crc8(u8 *pdata, /* pointer to array of data to process */
uint nbytes, /* number of input data bytes to process */
u8 crc /* either CRC8_INIT_VALUE or previous return value */
) {
......@@ -500,6 +526,7 @@ u8 hndcrc8(u8 *pdata, /* pointer to array of data to process */
return crc;
}
EXPORT_SYMBOL(bcm_crc8);
/*
* Traverse a string of 1-byte tag/1-byte length/variable-length value
......@@ -528,6 +555,7 @@ bcm_tlv_t *bcm_parse_tlvs(void *buf, int buflen, uint key)
return NULL;
}
EXPORT_SYMBOL(bcm_parse_tlvs);
#if defined(BCMDBG)
......@@ -583,6 +611,7 @@ bcm_format_flags(const bcm_bit_desc_t *bd, u32 flags, char *buf, int len)
return (int)(p - buf);
}
EXPORT_SYMBOL(bcm_format_flags);
/* print bytes formatted as hex to a string. return the resulting string length */
int bcm_format_hex(char *str, const void *bytes, int len)
......@@ -597,10 +626,11 @@ int bcm_format_hex(char *str, const void *bytes, int len)
}
return (int)(p - str);
}
EXPORT_SYMBOL(bcm_format_hex);
#endif /* defined(BCMDBG) */
/* pretty hex print a contiguous buffer */
void prhex(const char *msg, unsigned char *buf, uint nbytes)
void bcm_prhex(const char *msg, unsigned char *buf, uint nbytes)
{
char line[128], *p;
int len = sizeof(line);
......@@ -634,6 +664,7 @@ void prhex(const char *msg, unsigned char *buf, uint nbytes)
if (p != line)
printk(KERN_DEBUG "%s\n", line);
}
EXPORT_SYMBOL(bcm_prhex);
char *bcm_chipname(uint chipid, char *buf, uint len)
{
......@@ -643,6 +674,7 @@ char *bcm_chipname(uint chipid, char *buf, uint len)
snprintf(buf, len, fmt, chipid);
return buf;
}
EXPORT_SYMBOL(bcm_chipname);
uint bcm_mkiovar(char *name, char *data, uint datalen, char *buf, uint buflen)
{
......@@ -661,6 +693,7 @@ uint bcm_mkiovar(char *name, char *data, uint datalen, char *buf, uint buflen)
return len;
}
EXPORT_SYMBOL(bcm_mkiovar);
/* Quarter dBm units to mW
* Table starts at QDBM_OFFSET, so the first entry is mW for qdBm=153
......@@ -715,6 +748,8 @@ u16 bcm_qdbm_to_mw(u8 qdbm)
*/
return (nqdBm_to_mW_map[idx] + factor / 2) / factor;
}
EXPORT_SYMBOL(bcm_qdbm_to_mw);
u8 bcm_mw_to_qdbm(u16 mw)
{
u8 qdbm;
......@@ -745,6 +780,8 @@ u8 bcm_mw_to_qdbm(u16 mw)
return qdbm;
}
EXPORT_SYMBOL(bcm_mw_to_qdbm);
uint bcm_bitcount(u8 *bitmap, uint length)
{
uint bitcount = 0, i;
......@@ -758,12 +795,15 @@ uint bcm_bitcount(u8 *bitmap, uint length)
}
return bitcount;
}
EXPORT_SYMBOL(bcm_bitcount);
/* Initialization of bcmstrbuf structure */
void bcm_binit(struct bcmstrbuf *b, char *buf, uint size)
{
b->origsize = b->size = size;
b->origbuf = b->buf = buf;
}
EXPORT_SYMBOL(bcm_binit);
/* Buffer sprintf wrapper to guard against buffer overflow */
int bcm_bprintf(struct bcmstrbuf *b, const char *fmt, ...)
......@@ -789,3 +829,4 @@ int bcm_bprintf(struct bcmstrbuf *b, const char *fmt, ...)
return r;
}
EXPORT_SYMBOL(bcm_bprintf);
......@@ -15,6 +15,7 @@
*/
#include <linux/ctype.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <bcmdefs.h>
#include <bcmutils.h>
#include <bcmwifi.h>
......@@ -25,7 +26,7 @@
* combination could be legal given any set of circumstances.
* RETURNS: true is the chanspec is malformed, false if it looks good.
*/
bool wf_chspec_malformed(chanspec_t chanspec)
bool bcm_chspec_malformed(chanspec_t chanspec)
{
/* must be 2G or 5G band */
if (!CHSPEC_IS5G(chanspec) && !CHSPEC_IS2G(chanspec))
......@@ -45,13 +46,14 @@ bool wf_chspec_malformed(chanspec_t chanspec)
return false;
}
EXPORT_SYMBOL(bcm_chspec_malformed);
/*
* This function returns the channel number that control traffic is being sent on, for legacy
* channels this is just the channel number, for 40MHZ channels it is the upper or lowre 20MHZ
* sideband depending on the chanspec selected
*/
u8 wf_chspec_ctlchan(chanspec_t chspec)
u8 bcm_chspec_ctlchan(chanspec_t chspec)
{
u8 ctl_chan;
......@@ -74,6 +76,7 @@ u8 wf_chspec_ctlchan(chanspec_t chspec)
return ctl_chan;
}
EXPORT_SYMBOL(bcm_chspec_ctlchan);
/*
* Return the channel number for a given frequency and base frequency.
......@@ -94,7 +97,7 @@ u8 wf_chspec_ctlchan(chanspec_t chspec)
*
* Reference 802.11 REVma, section 17.3.8.3, and 802.11B section 18.4.6.2
*/
int wf_mhz2channel(uint freq, uint start_factor)
int bcm_mhz2channel(uint freq, uint start_factor)
{
int ch = -1;
uint base;
......@@ -130,4 +133,5 @@ int wf_mhz2channel(uint freq, uint start_factor)
return ch;
}
EXPORT_SYMBOL(bcm_mhz2channel);
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