]> 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 4cdecaa4b00977e3ec5292de276026be0b7a350a..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 <linux/kernel.h>
+#include <linux/string.h>
+#include <bcmdefs.h>
+#include <linux/netdevice.h>
 #include <osl.h>
 #include <bcmutils.h>
 #include <bcmendian.h>
@@ -141,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;
 
@@ -155,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);
 
@@ -327,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;
 
@@ -338,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 */
@@ -348,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 */
@@ -357,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);
@@ -367,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 */
@@ -377,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
@@ -524,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];
@@ -598,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++) {
@@ -615,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:
@@ -967,8 +962,6 @@ void print_buf(void *pbuf, int len, int bytes_per_line)
        printf("\n");
 }
 
-#define strtoul(nptr, endptr, base) bcm_strtoul((nptr), (endptr), (base))
-
 /* Convert user's input in hex pattern to byte-size mask */
 static int wl_pattern_atoh(char *src, char *dst)
 {
@@ -986,7 +979,7 @@ static int wl_pattern_atoh(char *src, char *dst)
                char num[3];
                strncpy(num, src, 2);
                num[2] = '\0';
-               dst[i] = (u8) strtoul(num, NULL, 16);
+               dst[i] = (u8) simple_strtoul(num, NULL, 16);
                src += 2;
        }
        return i;
@@ -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;
@@ -1015,7 +1008,7 @@ dhd_pktfilter_offload_enable(dhd_pub_t *dhd, char *arg, int enable,
        arg_org = arg_save;
        memcpy(arg_save, arg, strlen(arg) + 1);
 
-       argv[i] = bcmstrtok(&arg_save, " ", 0);
+       argv[i] = strsep(&arg_save, " ");
 
        i = 0;
        if (NULL == argv[i]) {
@@ -1032,7 +1025,7 @@ dhd_pktfilter_offload_enable(dhd_pub_t *dhd, char *arg, int enable,
        pkt_filterp = (wl_pkt_filter_enable_t *) (buf + str_len + 1);
 
        /* Parse packet filter id. */
-       enable_parm.id = htod32(strtoul(argv[i], NULL, 0));
+       enable_parm.id = htod32(simple_strtoul(argv[i], NULL, 0));
 
        /* Parse enable/disable value. */
        enable_parm.enable = htod32(enable);
@@ -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;
@@ -1101,9 +1094,9 @@ void dhd_pktfilter_offload_set(dhd_pub_t *dhd, char *arg)
                goto fail;
        }
 
-       argv[i] = bcmstrtok(&arg_save, " ", 0);
+       argv[i] = strsep(&arg_save, " ");
        while (argv[i++])
-               argv[i] = bcmstrtok(&arg_save, " ", 0);
+               argv[i] = strsep(&arg_save, " ");
 
        i = 0;
        if (NULL == argv[i]) {
@@ -1120,7 +1113,7 @@ void dhd_pktfilter_offload_set(dhd_pub_t *dhd, char *arg)
        pkt_filterp = (wl_pkt_filter_t *) (buf + str_len + 1);
 
        /* Parse packet filter id. */
-       pkt_filter.id = htod32(strtoul(argv[i], NULL, 0));
+       pkt_filter.id = htod32(simple_strtoul(argv[i], NULL, 0));
 
        if (NULL == argv[++i]) {
                DHD_ERROR(("Polarity not provided\n"));
@@ -1128,7 +1121,7 @@ void dhd_pktfilter_offload_set(dhd_pub_t *dhd, char *arg)
        }
 
        /* Parse filter polarity. */
-       pkt_filter.negate_match = htod32(strtoul(argv[i], NULL, 0));
+       pkt_filter.negate_match = htod32(simple_strtoul(argv[i], NULL, 0));
 
        if (NULL == argv[++i]) {
                DHD_ERROR(("Filter type not provided\n"));
@@ -1136,7 +1129,7 @@ void dhd_pktfilter_offload_set(dhd_pub_t *dhd, char *arg)
        }
 
        /* Parse filter type. */
-       pkt_filter.type = htod32(strtoul(argv[i], NULL, 0));
+       pkt_filter.type = htod32(simple_strtoul(argv[i], NULL, 0));
 
        if (NULL == argv[++i]) {
                DHD_ERROR(("Offset not provided\n"));
@@ -1144,7 +1137,7 @@ void dhd_pktfilter_offload_set(dhd_pub_t *dhd, char *arg)
        }
 
        /* Parse pattern filter offset. */
-       pkt_filter.u.pattern.offset = htod32(strtoul(argv[i], NULL, 0));
+       pkt_filter.u.pattern.offset = htod32(simple_strtoul(argv[i], NULL, 0));
 
        if (NULL == argv[++i]) {
                DHD_ERROR(("Bitmask not provided\n"));
@@ -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)
@@ -1290,7 +1283,7 @@ int dhd_preinit_ioctls(dhd_pub_t *dhd)
        ptr = buf;
        bcm_mkiovar("ver", 0, 0, buf, sizeof(buf));
        dhdcdc_query_ioctl(dhd, 0, WLC_GET_VAR, buf, sizeof(buf));
-       bcmstrtok(&ptr, "\n", 0);
+       strsep(&ptr, "\n");
        /* Print fw version info */
        DHD_ERROR(("Firmware version = %s\n", buf));
 
@@ -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: