diff options
Diffstat (limited to 'drivers/staging/brcm80211/brcmfmac/dhd_common.c')
-rw-r--r-- | drivers/staging/brcm80211/brcmfmac/dhd_common.c | 250 |
1 files changed, 92 insertions, 158 deletions
diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_common.c b/drivers/staging/brcm80211/brcmfmac/dhd_common.c index 3dbf72eebd4a..aa171f6181e9 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_common.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_common.c @@ -17,9 +17,7 @@ #include <linux/string.h> #include <bcmdefs.h> #include <linux/netdevice.h> -#include <osl.h> #include <bcmutils.h> -#include <bcmendian.h> #include <dngl_stats.h> #include <dhd.h> #include <dhd_bus.h> @@ -37,11 +35,6 @@ u32 dhd_conn_event; u32 dhd_conn_status; u32 dhd_conn_reason; -#define htod32(i) i -#define htod16(i) i -#define dtoh32(i) i -#define dtoh16(i) i - extern int dhdcdc_set_ioctl(dhd_pub_t *dhd, int ifidx, uint cmd, void *buf, uint len); extern void dhd_ind_scan_confirm(void *h, bool status); @@ -57,8 +50,8 @@ void dhd_iscan_unlock(void); #error DHD_SDALIGN is not a power of 2! #endif -#ifdef DHD_DEBUG #define EPI_VERSION_STR "4.218.248.5" +#ifdef DHD_DEBUG const char dhd_version[] = "Dongle Host Driver, version " EPI_VERSION_STR "\nCompiled on " __DATE__ " at " __TIME__; @@ -214,7 +207,7 @@ dhd_doiovar(dhd_pub_t *dhd_pub, const bcm_iovar_t *vi, u32 actionid, goto exit; if (plen >= (int)sizeof(int_val)) - bcopy(params, &int_val, sizeof(int_val)); + memcpy(&int_val, params, sizeof(int_val)); switch (actionid) { case IOV_GVAL(IOV_VERSION): @@ -224,7 +217,7 @@ dhd_doiovar(dhd_pub_t *dhd_pub, const bcm_iovar_t *vi, u32 actionid, case IOV_GVAL(IOV_MSGLEVEL): int_val = (s32) dhd_msg_level; - bcopy(&int_val, arg, val_size); + memcpy(arg, &int_val, val_size); break; case IOV_SVAL(IOV_MSGLEVEL): @@ -239,12 +232,12 @@ dhd_doiovar(dhd_pub_t *dhd_pub, const bcm_iovar_t *vi, u32 actionid, case IOV_GVAL(IOV_BCMERROR): int_val = (s32) dhd_pub->bcmerror; - bcopy(&int_val, arg, val_size); + memcpy(arg, &int_val, val_size); break; case IOV_GVAL(IOV_WDTICK): int_val = (s32) dhd_watchdog_ms; - bcopy(&int_val, arg, val_size); + memcpy(arg, &int_val, val_size); break; case IOV_SVAL(IOV_WDTICK): @@ -262,7 +255,7 @@ dhd_doiovar(dhd_pub_t *dhd_pub, const bcm_iovar_t *vi, u32 actionid, #ifdef DHD_DEBUG case IOV_GVAL(IOV_DCONSOLE_POLL): int_val = (s32) dhd_console_ms; - bcopy(&int_val, arg, val_size); + memcpy(arg, &int_val, val_size); break; case IOV_SVAL(IOV_DCONSOLE_POLL): @@ -290,7 +283,7 @@ dhd_doiovar(dhd_pub_t *dhd_pub, const bcm_iovar_t *vi, u32 actionid, case IOV_GVAL(IOV_IOCTLTIMEOUT):{ int_val = (s32) dhd_os_get_ioctl_resp_timeout(); - bcopy(&int_val, arg, sizeof(int_val)); + memcpy(arg, &int_val, sizeof(int_val)); break; } @@ -312,21 +305,6 @@ exit: return bcmerror; } -/* Store the status of a connection attempt for later retrieval by an iovar */ -void dhd_store_conn_status(u32 event, u32 status, u32 reason) -{ - /* Do not overwrite a WLC_E_PRUNE with a WLC_E_SET_SSID - * because an encryption/rsn mismatch results in both events, and - * the important information is in the WLC_E_PRUNE. - */ - if (!(event == WLC_E_SET_SSID && status == WLC_E_STATUS_FAIL && - dhd_conn_event == WLC_E_PRUNE)) { - dhd_conn_event = event; - dhd_conn_status = status; - dhd_conn_reason = reason; - } -} - bool dhd_prec_enq(dhd_pub_t *dhdp, struct pktq *q, struct sk_buff *pkt, int prec) { @@ -368,7 +346,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 */ @@ -592,14 +570,14 @@ static void wl_show_host_event(wl_event_msg_t *event, void *event_data) WLC_E_PFN_SCAN_COMPLETE, "SCAN_COMPLETE"} }; uint event_type, flags, auth_type, datalen; - event_type = ntoh32(event->event_type); - flags = ntoh16(event->flags); - status = ntoh32(event->status); - reason = ntoh32(event->reason); - auth_type = ntoh32(event->auth_type); - datalen = ntoh32(event->datalen); + event_type = be32_to_cpu(event->event_type); + flags = be16_to_cpu(event->flags); + status = be32_to_cpu(event->status); + reason = be32_to_cpu(event->reason); + auth_type = be32_to_cpu(event->auth_type); + datalen = be32_to_cpu(event->datalen); /* debug dump of event messages */ - sprintf(eabuf, "%pM", event->addr.octet); + sprintf(eabuf, "%pM", event->addr); event_name = "UNKNOWN"; for (i = 0; i < ARRAY_SIZE(event_names); i++) { @@ -653,9 +631,9 @@ static void wl_show_host_event(wl_event_msg_t *event, void *event_data) case WLC_E_AUTH: case WLC_E_AUTH_IND: - if (auth_type == DOT11_OPEN_SYSTEM) + if (auth_type == WLAN_AUTH_OPEN) auth_str = "Open System"; - else if (auth_type == DOT11_SHARED_KEY) + else if (auth_type == WLAN_AUTH_SHARED_KEY) auth_str = "Shared Key"; else { sprintf(err_msg, "AUTH unknown: %d", (int)auth_type); @@ -754,34 +732,35 @@ static void wl_show_host_event(wl_event_msg_t *event, void *event_data) memcpy(&hdr, buf, MSGTRACE_HDRLEN); if (hdr.version != MSGTRACE_VERSION) { - printf + DHD_ERROR( ("\nMACEVENT: %s [unsupported version --> " "dhd version:%d dongle version:%d]\n", - event_name, MSGTRACE_VERSION, hdr.version); + event_name, MSGTRACE_VERSION, hdr.version) + ); /* Reset datalen to avoid display below */ datalen = 0; break; } /* There are 2 bytes available at the end of data */ - buf[MSGTRACE_HDRLEN + ntoh16(hdr.len)] = '\0'; + buf[MSGTRACE_HDRLEN + be16_to_cpu(hdr.len)] = '\0'; - if (ntoh32(hdr.discarded_bytes) - || ntoh32(hdr.discarded_printf)) { - printf + if (be32_to_cpu(hdr.discarded_bytes) + || be32_to_cpu(hdr.discarded_printf)) { + DHD_ERROR( ("\nWLC_E_TRACE: [Discarded traces in dongle -->" "discarded_bytes %d discarded_printf %d]\n", - ntoh32(hdr.discarded_bytes), - ntoh32(hdr.discarded_printf)); + be32_to_cpu(hdr.discarded_bytes), + be32_to_cpu(hdr.discarded_printf))); } - nblost = ntoh32(hdr.seqnum) - seqnum_prev - 1; + nblost = be32_to_cpu(hdr.seqnum) - seqnum_prev - 1; if (nblost > 0) { - printf + DHD_ERROR( ("\nWLC_E_TRACE: [Event lost --> seqnum %d nblost %d\n", - ntoh32(hdr.seqnum), nblost); + be32_to_cpu(hdr.seqnum), nblost)); } - seqnum_prev = ntoh32(hdr.seqnum); + seqnum_prev = be32_to_cpu(hdr.seqnum); /* Display the trace buffer. Advance from \n to \n to * avoid display big @@ -790,10 +769,10 @@ static void wl_show_host_event(wl_event_msg_t *event, void *event_data) p = (char *)&buf[MSGTRACE_HDRLEN]; while ((s = strstr(p, "\n")) != NULL) { *s = '\0'; - printf("%s\n", p); + printk(KERN_DEBUG"%s\n", p); p = s + 1; } - printf("%s\n", p); + printk(KERN_DEBUG "%s\n", p); /* Reset datalen to avoid display below */ datalen = 0; @@ -802,7 +781,7 @@ static void wl_show_host_event(wl_event_msg_t *event, void *event_data) case WLC_E_RSSI: DHD_EVENT(("MACEVENT: %s %d\n", event_name, - ntoh32(*((int *)event_data)))); + be32_to_cpu(*((int *)event_data)))); break; default: @@ -840,7 +819,7 @@ wl_host_event(struct dhd_info *dhd, int *ifidx, void *pktdata, } /* BRCM event pkt may be unaligned - use xxx_ua to load user_subtype. */ - if (ntoh16_ua((void *)&pvt_data->bcm_hdr.usr_subtype) != + if (get_unaligned_be16(&pvt_data->bcm_hdr.usr_subtype) != BCMILCP_BCM_SUBTYPE_EVENT) { DHD_ERROR(("%s: mismatched subtype, bailing\n", __func__)); return BCME_ERROR; @@ -852,10 +831,10 @@ wl_host_event(struct dhd_info *dhd, int *ifidx, void *pktdata, /* memcpy since BRCM event pkt may be unaligned. */ memcpy(event, &pvt_data->event, sizeof(wl_event_msg_t)); - type = ntoh32_ua((void *)&event->event_type); - flags = ntoh16_ua((void *)&event->flags); - status = ntoh32_ua((void *)&event->status); - evlen = ntoh32_ua((void *)&event->datalen) + sizeof(bcm_event_t); + type = get_unaligned_be32(&event->event_type); + flags = get_unaligned_be16(&event->flags); + status = get_unaligned_be32(&event->status); + evlen = get_unaligned_be32(&event->datalen) + sizeof(bcm_event_t); switch (type) { case WLC_E_IF: @@ -868,7 +847,7 @@ wl_host_event(struct dhd_info *dhd, int *ifidx, void *pktdata, if (ifevent->action == WLC_E_IF_ADD) dhd_add_if(dhd, ifevent->ifidx, NULL, event->ifname, - pvt_data->eth.ether_dhost, + pvt_data->eth.h_dest, ifevent->flags, ifevent->bssidx); else @@ -909,10 +888,10 @@ wl_host_event(struct dhd_info *dhd, int *ifidx, void *pktdata, if (type == WLC_E_NDIS_LINK) { u32 temp; - temp = ntoh32_ua((void *)&event->event_type); + temp = get_unaligned_be32(&event->event_type); DHD_TRACE(("Converted to WLC_E_LINK type %d\n", temp)); - temp = ntoh32(WLC_E_NDIS_LINK); + temp = be32_to_cpu(WLC_E_NDIS_LINK); memcpy((void *)(&pvt_data->event.event_type), &temp, sizeof(pvt_data->event.event_type)); } @@ -926,42 +905,6 @@ wl_host_event(struct dhd_info *dhd, int *ifidx, void *pktdata, return BCME_OK; } -void wl_event_to_host_order(wl_event_msg_t *evt) -{ - /* Event struct members passed from dongle to host are stored - * in network - * byte order. Convert all members to host-order. - */ - evt->event_type = ntoh32(evt->event_type); - evt->flags = ntoh16(evt->flags); - evt->status = ntoh32(evt->status); - evt->reason = ntoh32(evt->reason); - evt->auth_type = ntoh32(evt->auth_type); - evt->datalen = ntoh32(evt->datalen); - evt->version = ntoh16(evt->version); -} - -void print_buf(void *pbuf, int len, int bytes_per_line) -{ - int i, j = 0; - unsigned char *buf = pbuf; - - if (bytes_per_line == 0) - bytes_per_line = len; - - for (i = 0; i < len; i++) { - printf("%2.2x", *buf++); - j++; - if (j == bytes_per_line) { - printf("\n"); - j = 0; - } else { - printf(":"); - } - } - printf("\n"); -} - /* Convert user's input in hex pattern to byte-size mask */ static int wl_pattern_atoh(char *src, char *dst) { @@ -1025,10 +968,10 @@ 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(simple_strtoul(argv[i], NULL, 0)); + enable_parm.id = simple_strtoul(argv[i], NULL, 0); /* Parse enable/disable value. */ - enable_parm.enable = htod32(enable); + enable_parm.enable = enable; buf_len += sizeof(enable_parm); memcpy((char *)pkt_filterp, &enable_parm, sizeof(enable_parm)); @@ -1053,8 +996,7 @@ dhd_pktfilter_offload_enable(dhd_pub_t *dhd, char *arg, int enable, __func__, arg, rc)); fail: - if (arg_org) - kfree(arg_org); + kfree(arg_org); } void dhd_pktfilter_offload_set(dhd_pub_t *dhd, char *arg) @@ -1113,7 +1055,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(simple_strtoul(argv[i], NULL, 0)); + pkt_filter.id = simple_strtoul(argv[i], NULL, 0); if (NULL == argv[++i]) { DHD_ERROR(("Polarity not provided\n")); @@ -1121,7 +1063,7 @@ void dhd_pktfilter_offload_set(dhd_pub_t *dhd, char *arg) } /* Parse filter polarity. */ - pkt_filter.negate_match = htod32(simple_strtoul(argv[i], NULL, 0)); + pkt_filter.negate_match = simple_strtoul(argv[i], NULL, 0); if (NULL == argv[++i]) { DHD_ERROR(("Filter type not provided\n")); @@ -1129,7 +1071,7 @@ void dhd_pktfilter_offload_set(dhd_pub_t *dhd, char *arg) } /* Parse filter type. */ - pkt_filter.type = htod32(simple_strtoul(argv[i], NULL, 0)); + pkt_filter.type = simple_strtoul(argv[i], NULL, 0); if (NULL == argv[++i]) { DHD_ERROR(("Offset not provided\n")); @@ -1137,7 +1079,7 @@ void dhd_pktfilter_offload_set(dhd_pub_t *dhd, char *arg) } /* Parse pattern filter offset. */ - pkt_filter.u.pattern.offset = htod32(simple_strtoul(argv[i], NULL, 0)); + pkt_filter.u.pattern.offset = simple_strtoul(argv[i], NULL, 0); if (NULL == argv[++i]) { DHD_ERROR(("Bitmask not provided\n")); @@ -1146,8 +1088,8 @@ void dhd_pktfilter_offload_set(dhd_pub_t *dhd, char *arg) /* Parse pattern filter mask. */ mask_size = - htod32(wl_pattern_atoh - (argv[i], (char *)pkt_filterp->u.pattern.mask_and_pattern)); + wl_pattern_atoh + (argv[i], (char *)pkt_filterp->u.pattern.mask_and_pattern); if (NULL == argv[++i]) { DHD_ERROR(("Pattern not provided\n")); @@ -1156,9 +1098,9 @@ void dhd_pktfilter_offload_set(dhd_pub_t *dhd, char *arg) /* Parse pattern filter pattern. */ pattern_size = - htod32(wl_pattern_atoh(argv[i], + wl_pattern_atoh(argv[i], (char *)&pkt_filterp->u.pattern. - mask_and_pattern[mask_size])); + mask_and_pattern[mask_size]); if (mask_size != pattern_size) { DHD_ERROR(("Mask and pattern not the same size\n")); @@ -1189,11 +1131,9 @@ void dhd_pktfilter_offload_set(dhd_pub_t *dhd, char *arg) __func__, arg)); fail: - if (arg_org) - kfree(arg_org); + kfree(arg_org); - if (buf) - kfree(buf); + kfree(buf); } void dhd_arp_offload_set(dhd_pub_t *dhd, int arp_mode) @@ -1242,7 +1182,7 @@ int dhd_preinit_ioctls(dhd_pub_t *dhd) int scan_unassoc_time = 40; #ifdef GET_CUSTOM_MAC_ENABLE int ret = 0; - struct ether_addr ea_addr; + u8 ea_addr[ETH_ALEN]; #endif /* GET_CUSTOM_MAC_ENABLE */ dhd_os_proto_block(dhd); @@ -1254,9 +1194,9 @@ int dhd_preinit_ioctls(dhd_pub_t *dhd) ** firmware but unique per board mac address maybe provided by ** customer code */ - ret = dhd_custom_get_mac_address(ea_addr.octet); + ret = dhd_custom_get_mac_address(ea_addr); if (!ret) { - bcm_mkiovar("cur_etheraddr", (void *)&ea_addr, ETH_ALEN, + bcm_mkiovar("cur_etheraddr", (void *)ea_addr, ETH_ALEN, buf, sizeof(buf)); ret = dhdcdc_set_ioctl(dhd, 0, WLC_SET_VAR, buf, sizeof(buf)); if (ret < 0) { @@ -1478,8 +1418,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 *)((unsigned long)bi + - dtoh32(bi->length)); + bi = (wl_bss_info_t *)((unsigned long)bi + bi->length); } iscan_cur = iscan_cur->next; l++; @@ -1543,18 +1482,16 @@ 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 *)((unsigned long)bi + - dtoh32 - (bi->length)); + bi = (wl_bss_info_t *)((unsigned long) + bi + bi->length); /* if(bi && bi_new) { - bcopy(bi, bi_new, results->buflen - - dtoh32(bi_new->length)); - results->buflen -= dtoh32(bi_new->length); + memcpy(bi_new, bi, results->buflen - + bi_new->length); + results->buflen -= bi_new->length; } */ - results->buflen -= - dtoh32(bi_new->length); + results->buflen -= bi_new->length; results->count--; for (j = i; j < results->count; j++) { @@ -1570,16 +1507,13 @@ int dhd_iscan_delete_bss(void *dhdp, void *addr, iscan_buf_t *iscan_skip) bi_next = (wl_bss_info_t *)((unsigned long)bi + - dtoh32 - (bi->length)); - bcopy(bi, bi_new, - dtoh32 - (bi->length)); + bi->length); + memcpy(bi_new, bi, + bi->length); bi_new = (wl_bss_info_t *)((unsigned long)bi_new + - dtoh32 - (bi_new-> - length)); + bi_new-> + length); bi = bi_next; } } @@ -1594,7 +1528,7 @@ int dhd_iscan_delete_bss(void *dhdp, void *addr, iscan_buf_t *iscan_skip) break; } bi = (wl_bss_info_t *)((unsigned long)bi + - dtoh32(bi->length)); + bi->length); } } iscan_cur = iscan_cur->next; @@ -1648,7 +1582,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 *)((unsigned long)bi + dtoh32(bi->length)); + bi = (wl_bss_info_t *)((unsigned long)bi + bi->length); } done: @@ -1677,15 +1611,15 @@ int dhd_iscan_request(void *dhdp, u16 action) params.params.bss_type = DOT11_BSSTYPE_ANY; params.params.scan_type = DOT11_SCANTYPE_ACTIVE; - params.params.nprobes = htod32(-1); - params.params.active_time = htod32(-1); - params.params.passive_time = htod32(-1); - params.params.home_time = htod32(-1); - params.params.channel_num = htod32(0); + params.params.nprobes = -1; + params.params.active_time = -1; + params.params.passive_time = -1; + params.params.home_time = -1; + params.params.channel_num = 0; - params.version = htod32(ISCAN_REQ_VERSION); - params.action = htod16(action); - params.scan_duration = htod16(0); + params.version = ISCAN_REQ_VERSION; + params.action = action; + params.scan_duration = 0; bcm_mkiovar("iscan", (char *)¶ms, sizeof(wl_iscan_params_t), buf, WLC_IOCTL_SMLEN); @@ -1722,16 +1656,16 @@ static int dhd_iscan_get_partial_result(void *dhdp, uint *scan_count) results->count = 0; memset(&list, 0, sizeof(list)); - list.results.buflen = htod32(WLC_IW_ISCAN_MAXLEN); + list.results.buflen = WLC_IW_ISCAN_MAXLEN; bcm_mkiovar("iscanresults", (char *)&list, WL_ISCAN_RESULTS_FIXED_SIZE, iscan_cur->iscan_buf, WLC_IW_ISCAN_MAXLEN); rc = dhd_wl_ioctl(dhdp, WLC_GET_VAR, iscan_cur->iscan_buf, WLC_IW_ISCAN_MAXLEN); - results->buflen = dtoh32(results->buflen); - results->version = dtoh32(results->version); - *scan_count = results->count = dtoh32(results->count); - status = dtoh32(list_buf->status); + results->buflen = results->buflen; + results->version = results->version; + *scan_count = results->count = results->count; + status = list_buf->status; dhd_iscan_unlock(); @@ -1854,12 +1788,12 @@ dhd_pno_set(dhd_pub_t *dhd, wlc_ssid_t *ssids_local, int nssid, unsigned char sc memset(&pfn_element, 0, sizeof(pfn_element)); /* set pfn parameters */ - pfn_param.version = htod32(PFN_VERSION); - pfn_param.flags = htod16((PFN_LIST_ORDER << SORT_CRITERIA_BIT)); + pfn_param.version = PFN_VERSION; + pfn_param.flags = (PFN_LIST_ORDER << SORT_CRITERIA_BIT); /* set up pno scan fr */ if (scan_fr != 0) - pfn_param.scan_freq = htod32(scan_fr); + pfn_param.scan_freq = scan_fr; bcm_mkiovar("pfn_set", (char *)&pfn_param, sizeof(pfn_param), iovbuf, sizeof(iovbuf)); @@ -1868,11 +1802,11 @@ dhd_pno_set(dhd_pub_t *dhd, wlc_ssid_t *ssids_local, int nssid, unsigned char sc /* set all pfn ssid */ for (i = 0; i < nssid; i++) { - pfn_element.bss_type = htod32(DOT11_BSSTYPE_INFRASTRUCTURE); - pfn_element.auth = (DOT11_OPEN_SYSTEM); - pfn_element.wpa_auth = htod32(WPA_AUTH_PFN_ANY); - pfn_element.wsec = htod32(0); - pfn_element.infra = htod32(1); + pfn_element.bss_type = DOT11_BSSTYPE_INFRASTRUCTURE; + pfn_element.auth = WLAN_AUTH_OPEN; + pfn_element.wpa_auth = WPA_AUTH_PFN_ANY; + pfn_element.wsec = 0; + pfn_element.infra = 1; memcpy((char *)pfn_element.ssid.SSID, ssids_local[i].SSID, ssids_local[i].SSID_len); |