]> git.karo-electronics.de Git - mv-sheeva.git/blobdiff - drivers/staging/brcm80211/brcmfmac/dhd_common.c
staging: brcm80211: change packet buffer type to native struct sk_buff
[mv-sheeva.git] / drivers / staging / brcm80211 / brcmfmac / dhd_common.c
index 481c35d98b384a9c1436f7c6f989b0484329ab14..e212abb8a357825335847e716a1f29a26e5c788e 100644 (file)
  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
-#include <typedefs.h>
-#include <osl.h>
 #include <linux/kernel.h>
 #include <linux/string.h>
+#include <bcmdefs.h>
+#include <linux/netdevice.h>
+#include <osl.h>
 #include <bcmutils.h>
 #include <bcmendian.h>
 #include <dngl_stats.h>
@@ -143,8 +144,6 @@ void dhd_common_init(void)
 
 static int dhd_dump(dhd_pub_t *dhdp, char *buf, int buflen)
 {
-       char eabuf[ETHER_ADDR_STR_LEN];
-
        struct bcmstrbuf b;
        struct bcmstrbuf *strbuf = &b;
 
@@ -157,9 +156,8 @@ static int dhd_dump(dhd_pub_t *dhdp, char *buf, int buflen)
                    dhdp->up, dhdp->txoff, dhdp->busstate);
        bcm_bprintf(strbuf, "pub.hdrlen %d pub.maxctl %d pub.rxsz %d\n",
                    dhdp->hdrlen, dhdp->maxctl, dhdp->rxsz);
-       bcm_bprintf(strbuf, "pub.iswl %d pub.drv_version %ld pub.mac %s\n",
-                   dhdp->iswl, dhdp->drv_version, bcm_ether_ntoa(&dhdp->mac,
-                                                                 eabuf));
+       bcm_bprintf(strbuf, "pub.iswl %d pub.drv_version %ld pub.mac %pM\n",
+                   dhdp->iswl, dhdp->drv_version, &dhdp->mac);
        bcm_bprintf(strbuf, "pub.bcmerror %d tickcnt %d\n", dhdp->bcmerror,
                    dhdp->tickcnt);
 
@@ -329,9 +327,10 @@ void dhd_store_conn_status(u32 event, u32 status, u32 reason)
        }
 }
 
-bool dhd_prec_enq(dhd_pub_t *dhdp, struct pktq *q, void *pkt, int prec)
+bool dhd_prec_enq(dhd_pub_t *dhdp, struct pktq *q, struct sk_buff *pkt,
+                 int prec)
 {
-       void *p;
+       struct sk_buff *p;
        int eprec = -1;         /* precedence to evict from */
        bool discard_oldest;
 
@@ -340,7 +339,7 @@ bool dhd_prec_enq(dhd_pub_t *dhdp, struct pktq *q, void *pkt, int prec)
         */
        if (!pktq_pfull(q, prec) && !pktq_full(q)) {
                pktq_penq(q, prec, pkt);
-               return TRUE;
+               return true;
        }
 
        /* Determine precedence from which to evict packet, if any */
@@ -350,7 +349,7 @@ bool dhd_prec_enq(dhd_pub_t *dhdp, struct pktq *q, void *pkt, int prec)
                p = pktq_peek_tail(q, &eprec);
                ASSERT(p);
                if (eprec > prec)
-                       return FALSE;
+                       return false;
        }
 
        /* Evict if needed */
@@ -359,7 +358,7 @@ bool dhd_prec_enq(dhd_pub_t *dhdp, struct pktq *q, void *pkt, int prec)
                ASSERT(!pktq_pempty(q, eprec));
                discard_oldest = AC_BITMAP_TST(dhdp->wme_dp, eprec);
                if (eprec == prec && !discard_oldest)
-                       return FALSE;   /* refuse newer (incoming) packet */
+                       return false;   /* refuse newer (incoming) packet */
                /* Evict packet according to discard policy */
                p = discard_oldest ? pktq_pdeq(q, eprec) : pktq_pdeq_tail(q,
                                                  eprec);
@@ -369,7 +368,7 @@ bool dhd_prec_enq(dhd_pub_t *dhdp, struct pktq *q, void *pkt, int prec)
                        ASSERT(p);
                }
 
-               PKTFREE(dhdp->osh, p, TRUE);
+               PKTFREE(dhdp->osh, p, true);
        }
 
        /* Enqueue */
@@ -379,7 +378,7 @@ bool dhd_prec_enq(dhd_pub_t *dhdp, struct pktq *q, void *pkt, int prec)
                ASSERT(p);
        }
 
-       return TRUE;
+       return true;
 }
 
 static int
@@ -526,7 +525,7 @@ int dhd_ioctl(dhd_pub_t *dhd_pub, dhd_ioctl_t *ioc, void *buf, uint buflen)
 static void wl_show_host_event(wl_event_msg_t *event, void *event_data)
 {
        uint i, status, reason;
-       bool group = FALSE, flush_txq = FALSE, link = FALSE;
+       bool group = false, flush_txq = false, link = false;
        char *auth_str, *event_name;
        unsigned char *buf;
        char err_msg[256], eabuf[ETHER_ADDR_STR_LEN];
@@ -600,13 +599,7 @@ static void wl_show_host_event(wl_event_msg_t *event, void *event_data)
        auth_type = ntoh32(event->auth_type);
        datalen = ntoh32(event->datalen);
        /* debug dump of event messages */
-       sprintf(eabuf, "%02x:%02x:%02x:%02x:%02x:%02x",
-               (unsigned char) event->addr.octet[0] & 0xff,
-               (unsigned char) event->addr.octet[1] & 0xff,
-               (unsigned char) event->addr.octet[2] & 0xff,
-               (unsigned char) event->addr.octet[3] & 0xff,
-               (unsigned char) event->addr.octet[4] & 0xff,
-               (unsigned char) event->addr.octet[5] & 0xff);
+       sprintf(eabuf, "%pM", event->addr.octet);
 
        event_name = "UNKNOWN";
        for (i = 0; i < ARRAY_SIZE(event_names); i++) {
@@ -617,11 +610,11 @@ static void wl_show_host_event(wl_event_msg_t *event, void *event_data)
        DHD_EVENT(("EVENT: %s, event ID = %d\n", event_name, event_type));
 
        if (flags & WLC_EVENT_MSG_LINK)
-               link = TRUE;
+               link = true;
        if (flags & WLC_EVENT_MSG_GROUP)
-               group = TRUE;
+               group = true;
        if (flags & WLC_EVENT_MSG_FLUSHTXQ)
-               flush_txq = TRUE;
+               flush_txq = true;
 
        switch (event_type) {
        case WLC_E_START:
@@ -1007,7 +1000,7 @@ dhd_pktfilter_offload_enable(dhd_pub_t *dhd, char *arg, int enable,
        wl_pkt_filter_enable_t enable_parm;
        wl_pkt_filter_enable_t *pkt_filterp;
 
-       arg_save = MALLOC(dhd->osh, strlen(arg) + 1);
+       arg_save = kmalloc(strlen(arg) + 1, GFP_ATOMIC);
        if (!arg_save) {
                DHD_ERROR(("%s: kmalloc failed\n", __func__));
                goto fail;
@@ -1061,7 +1054,7 @@ dhd_pktfilter_offload_enable(dhd_pub_t *dhd, char *arg, int enable,
 
 fail:
        if (arg_org)
-               MFREE(dhd->osh, arg_org, strlen(arg) + 1);
+               kfree(arg_org);
 }
 
 void dhd_pktfilter_offload_set(dhd_pub_t *dhd, char *arg)
@@ -1079,7 +1072,7 @@ void dhd_pktfilter_offload_set(dhd_pub_t *dhd, char *arg)
        char *arg_save = 0, *arg_org = 0;
 #define BUF_SIZE               2048
 
-       arg_save = MALLOC(dhd->osh, strlen(arg) + 1);
+       arg_save = kmalloc(strlen(arg) + 1, GFP_ATOMIC);
        if (!arg_save) {
                DHD_ERROR(("%s: kmalloc failed\n", __func__));
                goto fail;
@@ -1087,7 +1080,7 @@ void dhd_pktfilter_offload_set(dhd_pub_t *dhd, char *arg)
 
        arg_org = arg_save;
 
-       buf = MALLOC(dhd->osh, BUF_SIZE);
+       buf = kmalloc(BUF_SIZE, GFP_ATOMIC);
        if (!buf) {
                DHD_ERROR(("%s: kmalloc failed\n", __func__));
                goto fail;
@@ -1197,10 +1190,10 @@ void dhd_pktfilter_offload_set(dhd_pub_t *dhd, char *arg)
 
 fail:
        if (arg_org)
-               MFREE(dhd->osh, arg_org, strlen(arg) + 1);
+               kfree(arg_org);
 
        if (buf)
-               MFREE(dhd->osh, buf, BUF_SIZE);
+               kfree(buf);
 }
 
 void dhd_arp_offload_set(dhd_pub_t *dhd, int arp_mode)
@@ -1372,7 +1365,7 @@ iscan_buf_t *dhd_iscan_allocate_buf(dhd_pub_t *dhd, iscan_buf_t **iscanbuf)
 
        dhd_iscan_lock();
 
-       iscanbuf_alloc = (iscan_buf_t *) MALLOC(dhd->osh, sizeof(iscan_buf_t));
+       iscanbuf_alloc = kmalloc(sizeof(iscan_buf_t), GFP_ATOMIC);
        if (iscanbuf_alloc == NULL)
                goto fail;
 
@@ -1415,7 +1408,7 @@ void dhd_iscan_free_buf(void *dhdp, iscan_buf_t *iscan_delete)
                        iscanbuf_free = iscanbuf_cur;
                        iscanbuf_cur = iscanbuf_cur->next;
                        iscanbuf_free->next = 0;
-                       MFREE(dhd->osh, iscanbuf_free, sizeof(iscan_buf_t));
+                       kfree(iscanbuf_free);
                }
                iscan_chain = 0;
        } else {
@@ -1429,7 +1422,7 @@ void dhd_iscan_free_buf(void *dhdp, iscan_buf_t *iscan_delete)
                        iscanbuf_prv->next = iscan_delete->next;
 
                iscan_delete->next = 0;
-               MFREE(dhd->osh, iscan_delete, sizeof(iscan_buf_t));
+               kfree(iscan_delete);
 
                if (!iscanbuf_prv)
                        iscan_chain = 0;
@@ -1485,7 +1478,7 @@ int dhd_iscan_print_cache(iscan_buf_t *iscan_skip)
                                   bi->BSSID.octet[2], bi->BSSID.octet[3],
                                   bi->BSSID.octet[4], bi->BSSID.octet[5]));
 
-                       bi = (wl_bss_info_t *) ((uintptr) bi +
+                       bi = (wl_bss_info_t *)((unsigned long)bi +
                                                dtoh32(bi->length));
                }
                iscan_cur = iscan_cur->next;
@@ -1550,7 +1543,7 @@ int dhd_iscan_delete_bss(void *dhdp, void *addr, iscan_buf_t *iscan_skip)
                                        bi->BSSID.octet[5]));
 
                                        bi_new = bi;
-                                       bi = (wl_bss_info_t *) ((uintptr) bi +
+                                       bi = (wl_bss_info_t *)((unsigned long)bi +
                                                                dtoh32
                                                                (bi->length));
 /*
@@ -1576,17 +1569,14 @@ int dhd_iscan_delete_bss(void *dhdp, void *addr, iscan_buf_t *iscan_skip)
                                                        bi->BSSID.octet[5]));
 
                                                        bi_next =
-                                                           (wl_bss_info_t
-                                                            *) ((uintptr) bi +
+                                                           (wl_bss_info_t *)((unsigned long)bi +
                                                                 dtoh32
                                                                 (bi->length));
                                                        bcopy(bi, bi_new,
                                                              dtoh32
                                                              (bi->length));
                                                        bi_new =
-                                                           (wl_bss_info_t
-                                                            *) ((uintptr)
-                                                                bi_new +
+                                                           (wl_bss_info_t *)((unsigned long)bi_new +
                                                                 dtoh32
                                                                 (bi_new->
                                                                  length));
@@ -1603,7 +1593,7 @@ int dhd_iscan_delete_bss(void *dhdp, void *addr, iscan_buf_t *iscan_skip)
                                        }
                                        break;
                                }
-                               bi = (wl_bss_info_t *) ((uintptr) bi +
+                               bi = (wl_bss_info_t *)((unsigned long)bi +
                                                        dtoh32(bi->length));
                        }
                }
@@ -1658,7 +1648,7 @@ int dhd_iscan_remove_duplicates(void *dhdp, iscan_buf_t *iscan_cur)
 
                dhd_iscan_delete_bss(dhdp, bi->BSSID.octet, iscan_cur);
 
-               bi = (wl_bss_info_t *) ((uintptr) bi + dtoh32(bi->length));
+               bi = (wl_bss_info_t *)((unsigned long)bi + dtoh32(bi->length));
        }
 
 done: