brcmfmac: remove brcmf_proto_hdrpull() from bus interface
authorArend van Spriel <arend@broadcom.com>
Wed, 2 Jan 2013 14:22:43 +0000 (15:22 +0100)
committerJohn W. Linville <linville@tuxdriver.com>
Mon, 7 Jan 2013 20:16:56 +0000 (15:16 -0500)
The use of the function brcmf_proto_hdrpull() is moved to the
common part of the driver and consequently it can be removed
from the bus interface.

Reviewed-by: Hante Meuleman <meuleman@broadcom.com>
Reviewed-by: Pieter-Paul Giesberts <pieterpg@broadcom.com>
Signed-off-by: Arend van Spriel <arend@broadcom.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/brcm80211/brcmfmac/dhd.h
drivers/net/wireless/brcm80211/brcmfmac/dhd_bus.h
drivers/net/wireless/brcm80211/brcmfmac/dhd_cdc.c
drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c
drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
drivers/net/wireless/brcm80211/brcmfmac/usb.c

index 7245b171190a16058df001a9bd9a9467c652236d..4937bf4d550653876c91bf1298151f52574eef3c 100644 (file)
@@ -577,6 +577,10 @@ extern int brcmf_proto_cdc_query_dcmd(struct brcmf_pub *drvr, int ifidx,
 extern int brcmf_proto_cdc_set_dcmd(struct brcmf_pub *drvr, int ifidx, uint cmd,
                                    void *buf, uint len);
 
+/* Remove any protocol-specific data header. */
+extern int brcmf_proto_hdrpull(struct brcmf_pub *drvr, u8 *ifidx,
+                              struct sk_buff *rxp);
+
 extern int brcmf_net_attach(struct brcmf_if *ifp);
 extern struct brcmf_if *brcmf_add_if(struct brcmf_pub *drvr, int ifidx,
                                     s32 bssidx, char *name, u8 *mac_addr);
index 639bc2a2d03c834370b210e4ee65b3b3fc878712..64c38f4226a3f145b57973a9369bd0f03f9040a4 100644 (file)
@@ -130,16 +130,11 @@ int brcmf_bus_rxctl(struct brcmf_bus *bus, unsigned char *msg, uint len)
  * interface functions from common layer
  */
 
-/* Remove any protocol-specific data header. */
-extern int brcmf_proto_hdrpull(struct device *dev, int *ifidx,
-                              struct sk_buff *rxp);
-
 extern bool brcmf_c_prec_enq(struct device *dev, struct pktq *q,
                         struct sk_buff *pkt, int prec);
 
 /* Receive frame for delivery to OS.  Callee disposes of rxp. */
-extern void brcmf_rx_frames(struct device *dev, u8 ifidx,
-                           struct sk_buff_head *rxlist);
+extern void brcmf_rx_frames(struct device *dev, struct sk_buff_head *rxlist);
 
 /* Indication from bus module regarding presence/insertion of dongle. */
 extern int brcmf_attach(uint bus_hdrlen, struct device *dev);
index 0c83998af181c52923a3a213acd7acfc4d90d325..aa37f3e614b680c90b9f39188db58573d981581c 100644 (file)
@@ -303,12 +303,10 @@ void brcmf_proto_hdrpush(struct brcmf_pub *drvr, int ifidx,
        BDC_SET_IF_IDX(h, ifidx);
 }
 
-int brcmf_proto_hdrpull(struct device *dev, int *ifidx,
+int brcmf_proto_hdrpull(struct brcmf_pub *drvr, u8 *ifidx,
                        struct sk_buff *pktbuf)
 {
        struct brcmf_proto_bdc_header *h;
-       struct brcmf_bus *bus_if = dev_get_drvdata(dev);
-       struct brcmf_pub *drvr = bus_if->drvr;
 
        brcmf_dbg(TRACE, "Enter\n");
 
@@ -346,6 +344,8 @@ int brcmf_proto_hdrpull(struct device *dev, int *ifidx,
        skb_pull(pktbuf, BDC_HEADER_LEN);
        skb_pull(pktbuf, h->data_offset << 2);
 
+       if (pktbuf->len == 0)
+               return -ENODATA;
        return 0;
 }
 
index a820f58100b70e10460119c7381d2c32605e429d..682cb02a46742859f3fe3607f8eb543a1f29043a 100644 (file)
@@ -248,8 +248,7 @@ void brcmf_txflowblock(struct device *dev, bool state)
                }
 }
 
-void brcmf_rx_frames(struct device *dev, u8 ifidx,
-                    struct sk_buff_head *skb_list)
+void brcmf_rx_frames(struct device *dev, struct sk_buff_head *skb_list)
 {
        unsigned char *eth;
        uint len;
@@ -257,12 +256,24 @@ void brcmf_rx_frames(struct device *dev, u8 ifidx,
        struct brcmf_if *ifp;
        struct brcmf_bus *bus_if = dev_get_drvdata(dev);
        struct brcmf_pub *drvr = bus_if->drvr;
+       u8 ifidx;
+       int ret;
 
        brcmf_dbg(TRACE, "Enter\n");
 
        skb_queue_walk_safe(skb_list, skb, pnext) {
                skb_unlink(skb, skb_list);
 
+               /* process and remove protocol-specific header
+                */
+               ret = brcmf_proto_hdrpull(drvr, &ifidx, skb);
+               if (ret < 0) {
+                       if (ret != -ENODATA)
+                               bus_if->dstats.rx_errors++;
+                       brcmu_pkt_buf_free_skb(skb);
+                       continue;
+               }
+
                /* Get the protocol, maintain skb around eth_type_trans()
                 * The main reason for this hack is for the limitation of
                 * Linux 2.4 where 'eth_type_trans' uses the
@@ -326,13 +337,13 @@ void brcmf_rx_frames(struct device *dev, u8 ifidx,
 
 void brcmf_txcomplete(struct device *dev, struct sk_buff *txp, bool success)
 {
-       uint ifidx;
+       u8 ifidx;
        struct ethhdr *eh;
        u16 type;
        struct brcmf_bus *bus_if = dev_get_drvdata(dev);
        struct brcmf_pub *drvr = bus_if->drvr;
 
-       brcmf_proto_hdrpull(dev, &ifidx, txp);
+       brcmf_proto_hdrpull(drvr, &ifidx, txp);
 
        eh = (struct ethhdr *)(txp->data);
        type = ntohs(eh->h_proto);
index 13ea9b48acdb431cccf4f624e7a506edf0bd80e4..7fef9b5ba00364b2c65d88049e580a06288e0032 100644 (file)
@@ -1167,7 +1167,6 @@ static u8 brcmf_sdbrcm_rxglom(struct brcmf_sdio *bus, u8 rxseq)
        int errcode;
        u8 doff, sfdoff;
 
-       int ifidx = 0;
        bool usechain = bus->use_rxchain;
 
        struct brcmf_sdio_read rd_new;
@@ -1386,13 +1385,6 @@ static u8 brcmf_sdbrcm_rxglom(struct brcmf_sdio *bus, u8 rxseq)
                                skb_unlink(pfirst, &bus->glom);
                                brcmu_pkt_buf_free_skb(pfirst);
                                continue;
-                       } else if (brcmf_proto_hdrpull(bus->sdiodev->dev,
-                                                      &ifidx, pfirst) != 0) {
-                               brcmf_err("rx protocol error\n");
-                               bus->sdiodev->bus_if->dstats.rx_errors++;
-                               skb_unlink(pfirst, &bus->glom);
-                               brcmu_pkt_buf_free_skb(pfirst);
-                               continue;
                        }
 
                        brcmf_dbg_hex_dump(BRCMF_GLOM_ON(),
@@ -1405,7 +1397,7 @@ static u8 brcmf_sdbrcm_rxglom(struct brcmf_sdio *bus, u8 rxseq)
                }
                /* sent any remaining packets up */
                if (bus->glom.qlen)
-                       brcmf_rx_frames(bus->sdiodev->dev, ifidx, &bus->glom);
+                       brcmf_rx_frames(bus->sdiodev->dev, &bus->glom);
 
                bus->sdcnt.rxglomframes++;
                bus->sdcnt.rxglompkts += bus->glom.qlen;
@@ -1560,7 +1552,6 @@ static uint brcmf_sdio_readframes(struct brcmf_sdio *bus, uint maxframes)
        u16 pad;                /* Number of pad bytes to read */
        uint rxleft = 0;        /* Remaining number of frames allowed */
        int sdret;              /* Return code from calls */
-       int ifidx = 0;
        uint rxcount = 0;       /* Total frames read */
        struct brcmf_sdio_read *rd = &bus->cur_read, rd_new;
        u8 head_read = 0;
@@ -1759,17 +1750,11 @@ static uint brcmf_sdio_readframes(struct brcmf_sdio *bus, uint maxframes)
                if (pkt->len == 0) {
                        brcmu_pkt_buf_free_skb(pkt);
                        continue;
-               } else if (brcmf_proto_hdrpull(bus->sdiodev->dev, &ifidx,
-                          pkt) != 0) {
-                       brcmf_err("rx protocol error\n");
-                       brcmu_pkt_buf_free_skb(pkt);
-                       bus->sdiodev->bus_if->dstats.rx_errors++;
-                       continue;
                }
 
                skb_queue_head_init(&pktlist);
                skb_queue_tail(&pktlist, pkt);
-               brcmf_rx_frames(bus->sdiodev->dev, ifidx, &pktlist);
+               brcmf_rx_frames(bus->sdiodev->dev, &pktlist);
        }
 
        rxcount = maxframes - rxleft;
index 34342ff718db05f5462cd75ab9c65efa2657f6ba..e15630cc3889fcb5f4644e9332ad60ecb68d679f 100644 (file)
@@ -444,14 +444,14 @@ static void brcmf_usb_rx_complete(struct urb *urb)
        struct brcmf_usbdev_info *devinfo = req->devinfo;
        struct sk_buff *skb;
        struct sk_buff_head skbq;
-       int ifidx = 0;
 
        brcmf_dbg(USB, "Enter, urb->status=%d\n", urb->status);
        brcmf_usb_del_fromq(devinfo, req);
        skb = req->skb;
        req->skb = NULL;
 
-       if (urb->status == 0) {
+       /* zero lenght packets indicate usb "failure". Do not refill */
+       if (urb->status == 0 && urb->actual_length) {
                devinfo->bus_pub.bus->dstats.rx_packets++;
        } else {
                devinfo->bus_pub.bus->dstats.rx_errors++;
@@ -464,17 +464,8 @@ static void brcmf_usb_rx_complete(struct urb *urb)
                skb_queue_head_init(&skbq);
                skb_queue_tail(&skbq, skb);
                skb_put(skb, urb->actual_length);
-               if (brcmf_proto_hdrpull(devinfo->dev, &ifidx, skb) != 0) {
-                       brcmf_err("rx protocol error\n");
-                       brcmu_pkt_buf_free_skb(skb);
-                       devinfo->bus_pub.bus->dstats.rx_errors++;
-               } else
-                       brcmf_rx_frames(devinfo->dev, ifidx, &skbq);
-               /* zero lenght packets indicate usb "failure". Do not refill */
-               if (urb->actual_length)
-                       brcmf_usb_rx_refill(devinfo, req);
-               else
-                       brcmf_usb_enq(devinfo, &devinfo->rx_freeq, req, NULL);
+               brcmf_rx_frames(devinfo->dev, &skbq);
+               brcmf_usb_rx_refill(devinfo, req);
        } else {
                brcmu_pkt_buf_free_skb(skb);
                brcmf_usb_enq(devinfo, &devinfo->rx_freeq, req, NULL);