Skip to content

Commit

Permalink
staging: brcm80211: remove counting of allocated sk_buff packets
Browse files Browse the repository at this point in the history
The function pkt_buf_get_skb and pkt_buf_free_skb were using struct
osl_info field pktalloced to maintain counter of buffers in use in
the driver. It was decided to remove this facility. The prototypes
of these functions have been modified and the calling code adapted.

Reviewed-by: Brett Rudley <brudley@broadcom.com>
Reviewed-by: Henry Ptasinski <henryp@broadcom.com>
Reviewed-by: Roland Vossen <rvossen@broadcom.com>
Signed-off-by: Arend van Spriel <arend@broadcom.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Arend van Spriel authored and Greg Kroah-Hartman committed Mar 3, 2011
1 parent 3c4d93d commit a30825a
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 68 deletions.
8 changes: 4 additions & 4 deletions drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1038,7 +1038,7 @@ 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(sd->osh, buflen_u);
mypkt = pkt_buf_get_skb(buflen_u);
if (!mypkt) {
sd_err(("%s: pkt_buf_get_skb failed: len %d\n",
__func__, buflen_u));
Expand All @@ -1056,7 +1056,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(sd->osh, mypkt, write ? true : false);
pkt_buf_free_skb(mypkt);
} else if (((u32) (pkt->data) & DMA_ALIGN_MASK) != 0) {
/* Case 2: We have a packet, but it is unaligned. */

Expand All @@ -1065,7 +1065,7 @@ 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(sd->osh, pkt->len);
mypkt = pkt_buf_get_skb(pkt->len);
if (!mypkt) {
sd_err(("%s: pkt_buf_get_skb failed: len %d\n",
__func__, pkt->len));
Expand All @@ -1083,7 +1083,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(sd->osh, mypkt, write ? true : false);
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",
Expand Down
2 changes: 1 addition & 1 deletion drivers/staging/brcm80211/brcmfmac/dhd_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ bool dhd_prec_enq(dhd_pub_t *dhdp, struct pktq *q, struct sk_buff *pkt,
ASSERT(p);
}

pkt_buf_free_skb(dhdp->osh, p, true);
pkt_buf_free_skb(p);
}

/* Enqueue */
Expand Down
10 changes: 0 additions & 10 deletions drivers/staging/brcm80211/brcmfmac/dhd_linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -1049,11 +1049,6 @@ int dhd_sendpkt(dhd_pub_t *dhdp, int ifidx, struct sk_buff *pktbuf)
static inline void *
osl_pkt_frmnative(struct osl_info *osh, struct sk_buff *skb)
{
struct sk_buff *nskb;

for (nskb = skb; nskb; nskb = nskb->next)
osh->pktalloced++;

return (void *)skb;
}
#define PKTFRMNATIVE(osh, skb) \
Expand All @@ -1062,11 +1057,6 @@ osl_pkt_frmnative(struct osl_info *osh, struct sk_buff *skb)
static inline struct sk_buff *
osl_pkt_tonative(struct osl_info *osh, void *pkt)
{
struct sk_buff *nskb;

for (nskb = (struct sk_buff *)pkt; nskb; nskb = nskb->next)
osh->pktalloced--;

return (struct sk_buff *)pkt;
}
#define PKTTONATIVE(osh, pkt) \
Expand Down
47 changes: 22 additions & 25 deletions drivers/staging/brcm80211/brcmfmac/dhd_sdio.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@
* bufpool was present for gspi bus.
*/
#define PKTFREE2() if ((bus->bus != SPI_BUS) || bus->usebufpool) \
pkt_buf_free_skb(bus->dhd->osh, pkt, false);
pkt_buf_free_skb(pkt);

/*
* Conversion of 802.1D priority to precedence level
Expand Down Expand Up @@ -939,7 +939,7 @@ static int dhdsdio_txpkt(dhd_bus_t *bus, struct sk_buff *pkt, uint chan,
DHD_INFO(("%s: insufficient headroom %d for %d pad\n",
__func__, skb_headroom(pkt), pad));
bus->dhd->tx_realloc++;
new = pkt_buf_get_skb(osh, (pkt->len + DHD_SDALIGN));
new = pkt_buf_get_skb(pkt->len + DHD_SDALIGN);
if (!new) {
DHD_ERROR(("%s: couldn't allocate new %d-byte "
"packet\n",
Expand All @@ -951,7 +951,7 @@ static int dhdsdio_txpkt(dhd_bus_t *bus, struct sk_buff *pkt, uint chan,
PKTALIGN(osh, new, pkt->len, DHD_SDALIGN);
memcpy(new->data, pkt->data, pkt->len);
if (free_pkt)
pkt_buf_free_skb(osh, pkt, true);
pkt_buf_free_skb(pkt);
/* free the pkt if canned one is not used */
free_pkt = true;
pkt = new;
Expand Down Expand Up @@ -1065,7 +1065,7 @@ static int dhdsdio_txpkt(dhd_bus_t *bus, struct sk_buff *pkt, uint chan,
dhd_os_sdlock(bus->dhd);

if (free_pkt)
pkt_buf_free_skb(osh, pkt, true);
pkt_buf_free_skb(pkt);

return ret;
}
Expand Down Expand Up @@ -1116,7 +1116,7 @@ int dhd_bus_txdata(struct dhd_bus *bus, struct sk_buff *pkt)
if (dhd_prec_enq(bus->dhd, &bus->txq, pkt, prec) == false) {
skb_pull(pkt, SDPCM_HDRLEN);
dhd_txcomplete(bus->dhd, pkt, false);
pkt_buf_free_skb(osh, pkt, true);
pkt_buf_free_skb(pkt);
DHD_ERROR(("%s: out of bus->txq !!!\n", __func__));
ret = BCME_NORESOURCE;
} else {
Expand Down Expand Up @@ -2886,10 +2886,10 @@ void dhd_bus_stop(struct dhd_bus *bus, bool enforce_mutex)

/* Clear any held glomming stuff */
if (bus->glomd)
pkt_buf_free_skb(osh, bus->glomd, false);
pkt_buf_free_skb(bus->glomd);

if (bus->glom)
pkt_buf_free_skb(osh, bus->glom, false);
pkt_buf_free_skb(bus->glom);

bus->glom = bus->glomd = NULL;

Expand Down Expand Up @@ -3188,7 +3188,6 @@ static u8 dhdsdio_rxglom(dhd_bus_t *bus, u8 rxseq)

u16 sublen, check;
struct sk_buff *pfirst, *plast, *pnext, *save_pfirst;
struct osl_info *osh = bus->dhd->osh;

int errcode;
u8 chan, seq, doff, sfdoff;
Expand Down Expand Up @@ -3244,7 +3243,7 @@ static u8 dhdsdio_rxglom(dhd_bus_t *bus, u8 rxseq)
}

/* Allocate/chain packet for next subframe */
pnext = pkt_buf_get_skb(osh, sublen + DHD_SDALIGN);
pnext = pkt_buf_get_skb(sublen + DHD_SDALIGN);
if (pnext == NULL) {
DHD_ERROR(("%s: pkt_buf_get_skb failed, num %d len %d\n",
__func__, num, sublen));
Expand Down Expand Up @@ -3280,13 +3279,13 @@ static u8 dhdsdio_rxglom(dhd_bus_t *bus, u8 rxseq)
pfirst = pnext = NULL;
} else {
if (pfirst)
pkt_buf_free_skb(osh, pfirst, false);
pkt_buf_free_skb(pfirst);
bus->glom = NULL;
num = 0;
}

/* Done with descriptor packet */
pkt_buf_free_skb(osh, bus->glomd, false);
pkt_buf_free_skb(bus->glomd);
bus->glomd = NULL;
bus->nextlen = 0;

Expand Down Expand Up @@ -3355,7 +3354,7 @@ static u8 dhdsdio_rxglom(dhd_bus_t *bus, u8 rxseq)
bus->glomerr = 0;
dhdsdio_rxfail(bus, true, false);
dhd_os_sdlock_rxq(bus->dhd);
pkt_buf_free_skb(osh, bus->glom, false);
pkt_buf_free_skb(bus->glom);
dhd_os_sdunlock_rxq(bus->dhd);
bus->rxglomfail++;
bus->glom = NULL;
Expand Down Expand Up @@ -3484,7 +3483,7 @@ static u8 dhdsdio_rxglom(dhd_bus_t *bus, u8 rxseq)
bus->glomerr = 0;
dhdsdio_rxfail(bus, true, false);
dhd_os_sdlock_rxq(bus->dhd);
pkt_buf_free_skb(osh, bus->glom, false);
pkt_buf_free_skb(bus->glom);
dhd_os_sdunlock_rxq(bus->dhd);
bus->rxglomfail++;
bus->glom = NULL;
Expand Down Expand Up @@ -3532,7 +3531,7 @@ static u8 dhdsdio_rxglom(dhd_bus_t *bus, u8 rxseq)
skb_pull(pfirst, doff);

if (pfirst->len == 0) {
pkt_buf_free_skb(bus->dhd->osh, pfirst, false);
pkt_buf_free_skb(pfirst);
if (plast) {
plast->next = pnext;
} else {
Expand All @@ -3545,7 +3544,7 @@ static u8 dhdsdio_rxglom(dhd_bus_t *bus, u8 rxseq)
DHD_ERROR(("%s: rx protocol error\n",
__func__));
bus->dhd->rx_errors++;
pkt_buf_free_skb(osh, pfirst, false);
pkt_buf_free_skb(pfirst);
if (plast) {
plast->next = pnext;
} else {
Expand Down Expand Up @@ -3589,7 +3588,6 @@ static u8 dhdsdio_rxglom(dhd_bus_t *bus, u8 rxseq)
/* Return true if there may be more frames to read */
static uint dhdsdio_readframes(dhd_bus_t *bus, uint maxframes, bool *finished)
{
struct osl_info *osh = bus->dhd->osh;
bcmsdh_info_t *sdh = bus->sdh;

u16 len, check; /* Extracted hardware header fields */
Expand Down Expand Up @@ -3684,7 +3682,7 @@ static uint dhdsdio_readframes(dhd_bus_t *bus, uint maxframes, bool *finished)
*/
/* Allocate a packet buffer */
dhd_os_sdlock_rxq(bus->dhd);
pkt = pkt_buf_get_skb(osh, rdlen + DHD_SDALIGN);
pkt = pkt_buf_get_skb(rdlen + DHD_SDALIGN);
if (!pkt) {
if (bus->bus == SPI_BUS) {
bus->usebufpool = false;
Expand Down Expand Up @@ -3757,7 +3755,7 @@ static uint dhdsdio_readframes(dhd_bus_t *bus, uint maxframes, bool *finished)
if (sdret < 0) {
DHD_ERROR(("%s (nextlen): read %d bytes failed: %d\n",
__func__, rdlen, sdret));
pkt_buf_free_skb(bus->dhd->osh, pkt, false);
pkt_buf_free_skb(pkt);
bus->dhd->rx_errors++;
dhd_os_sdunlock_rxq(bus->dhd);
/* Force retry w/normal header read.
Expand Down Expand Up @@ -3905,8 +3903,7 @@ static uint dhdsdio_readframes(dhd_bus_t *bus, uint maxframes, bool *finished)
doff);
if (bus->usebufpool) {
dhd_os_sdlock_rxq(bus->dhd);
pkt_buf_free_skb(bus->dhd->osh, pkt,
false);
pkt_buf_free_skb(pkt);
dhd_os_sdunlock_rxq(bus->dhd);
}
continue;
Expand Down Expand Up @@ -4095,7 +4092,7 @@ static uint dhdsdio_readframes(dhd_bus_t *bus, uint maxframes, bool *finished)
}

dhd_os_sdlock_rxq(bus->dhd);
pkt = pkt_buf_get_skb(osh, (rdlen + firstread + DHD_SDALIGN));
pkt = pkt_buf_get_skb(rdlen + firstread + DHD_SDALIGN);
if (!pkt) {
/* Give up on data, request rtx of events */
DHD_ERROR(("%s: pkt_buf_get_skb failed: rdlen %d chan %d\n",
Expand Down Expand Up @@ -4131,7 +4128,7 @@ static uint dhdsdio_readframes(dhd_bus_t *bus, uint maxframes, bool *finished)
? "data" : "test")),
sdret));
dhd_os_sdlock_rxq(bus->dhd);
pkt_buf_free_skb(bus->dhd->osh, pkt, false);
pkt_buf_free_skb(pkt);
dhd_os_sdunlock_rxq(bus->dhd);
bus->dhd->rx_errors++;
dhdsdio_rxfail(bus, true, RETRYCHAN(chan));
Expand Down Expand Up @@ -4184,13 +4181,13 @@ static uint dhdsdio_readframes(dhd_bus_t *bus, uint maxframes, bool *finished)

if (pkt->len == 0) {
dhd_os_sdlock_rxq(bus->dhd);
pkt_buf_free_skb(bus->dhd->osh, pkt, false);
pkt_buf_free_skb(pkt);
dhd_os_sdunlock_rxq(bus->dhd);
continue;
} else if (dhd_prot_hdrpull(bus->dhd, &ifidx, pkt) != 0) {
DHD_ERROR(("%s: rx protocol error\n", __func__));
dhd_os_sdlock_rxq(bus->dhd);
pkt_buf_free_skb(bus->dhd->osh, pkt, false);
pkt_buf_free_skb(pkt);
dhd_os_sdunlock_rxq(bus->dhd);
bus->dhd->rx_errors++;
continue;
Expand Down Expand Up @@ -5012,7 +5009,7 @@ extern int dhd_bus_console_in(dhd_pub_t *dhdp, unsigned char *msg, uint msglen)
/* Bump dongle by sending an empty event pkt.
* sdpcm_sendup (RX) checks for virtual console input.
*/
pkt = pkt_buf_get_skb(bus->dhd->osh, 4 + SDPCM_RESERVE);
pkt = pkt_buf_get_skb(4 + SDPCM_RESERVE);
if ((pkt != NULL) && bus->clkstate == CLK_AVAIL)
dhdsdio_txpkt(bus, pkt, SDPCM_EVENT_CHANNEL, true);

Expand Down
20 changes: 8 additions & 12 deletions drivers/staging/brcm80211/brcmsmac/wlc_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2734,12 +2734,6 @@ uint wlc_down(struct wlc_info *wlc)
/* wlc_bmac_down_finish has done wlc_coredisable(). so clk is off */
wlc->clk = false;


/* Verify all packets are flushed from the driver */
if (wlc->osh->pktalloced != 0) {
WL_ERROR("%d packets not freed at wlc_down!!!!!!\n",
wlc->osh->pktalloced);
}
#ifdef BCMDBG
/* Since all the packets should have been freed,
* all callbacks should have been called
Expand Down Expand Up @@ -5122,7 +5116,7 @@ wlc_prec_enq_head(struct wlc_info *wlc, struct pktq *q, struct sk_buff *pkt,
tx_failed[WME_PRIO2AC(p->priority)].bytes,
pkttotlen(p));
}
pkt_buf_free_skb(wlc->osh, p, true);
pkt_buf_free_skb(p);
wlc->pub->_cnt->txnobuf++;
}

Expand Down Expand Up @@ -5154,8 +5148,11 @@ void BCMFASTPATH wlc_txq_enq(void *ctx, struct scb *scb, struct sk_buff *sdu,
WL_ERROR("wl%d: wlc_txq_enq: txq overflow\n",
wlc->pub->unit);

/* ASSERT(9 == 8); *//* XXX we might hit this condtion in case packet flooding from mac80211 stack */
pkt_buf_free_skb(wlc->osh, sdu, true);
/*
* XXX we might hit this condtion in case
* packet flooding from mac80211 stack
*/
pkt_buf_free_skb(sdu);
wlc->pub->_cnt->txnobuf++;
}

Expand Down Expand Up @@ -6710,7 +6707,7 @@ wlc_dotxstatus(struct wlc_info *wlc, tx_status_t *txs, u32 frm_tx2)
fatal:
ASSERT(0);
if (p)
pkt_buf_free_skb(wlc->osh, p, true);
pkt_buf_free_skb(p);

return true;

Expand Down Expand Up @@ -6977,7 +6974,6 @@ wlc_recvctl(struct wlc_info *wlc, d11rxhdr_t *rxh, struct sk_buff *p)
ieee80211_rx_irqsafe(wlc->pub->ieee_hw, p);

wlc->pub->_cnt->ieee_rx++;
wlc->osh->pktalloced--;
return;
}

Expand Down Expand Up @@ -7094,7 +7090,7 @@ void BCMFASTPATH wlc_recv(struct wlc_info *wlc, struct sk_buff *p)
return;

toss:
pkt_buf_free_skb(wlc->osh, p, false);
pkt_buf_free_skb(p);
}

/* calculate frame duration for Mixed-mode L-SIG spoofing, return
Expand Down
5 changes: 2 additions & 3 deletions drivers/staging/brcm80211/include/bcmutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,8 @@ extern struct sk_buff *pktq_pdeq(struct pktq *pq, int prec);
extern struct sk_buff *pktq_pdeq_tail(struct pktq *pq, int prec);

/* packet primitives */
extern struct sk_buff *pkt_buf_get_skb(struct osl_info *osh, uint len);
extern void pkt_buf_free_skb(struct osl_info *osh,
struct sk_buff *skb, bool send);
extern struct sk_buff *pkt_buf_get_skb(uint len);
extern void pkt_buf_free_skb(struct sk_buff *skb);

/* Empty the queue at particular precedence level */
#ifdef BRCM_FULLMAC
Expand Down
Loading

0 comments on commit a30825a

Please sign in to comment.