Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a30825a3 authored by Arend van Spriel's avatar Arend van Spriel Committed by Greg Kroah-Hartman
Browse files

staging: brcm80211: remove counting of allocated sk_buff packets



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: default avatarBrett Rudley <brudley@broadcom.com>
Reviewed-by: default avatarHenry Ptasinski <henryp@broadcom.com>
Reviewed-by: default avatarRoland Vossen <rvossen@broadcom.com>
Signed-off-by: default avatarArend van Spriel <arend@broadcom.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 3c4d93d4
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -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));
@@ -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. */

@@ -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));
@@ -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",
+1 −1
Original line number Diff line number Diff line
@@ -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 */
+0 −10
Original line number Diff line number Diff line
@@ -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)	\
@@ -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)	\
+22 −25
Original line number Diff line number Diff line
@@ -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
@@ -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",
@@ -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;
@@ -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;
}
@@ -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 {
@@ -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;

@@ -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;
@@ -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));
@@ -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;

@@ -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;
@@ -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;
@@ -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 {
@@ -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 {
@@ -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 */
@@ -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;
@@ -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.
@@ -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;
@@ -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",
@@ -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));
@@ -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;
@@ -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);

+8 −12
Original line number Diff line number Diff line
@@ -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
@@ -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++;
	}

@@ -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++;
	}

@@ -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;

@@ -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;
}

@@ -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
Loading