aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/ks7010/ks_hostif.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2018-06-09 10:32:39 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2018-06-09 10:32:39 -0700
commiteafdca4d7010a0e019aaaace3dd71b432a69b54c (patch)
tree0206168276ece10426dbbef7b3de7e8d84c8674d /drivers/staging/ks7010/ks_hostif.c
parentMerge tag 'libnvdimm-for-4.18' of git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm (diff)
parentstaging: ipx: delete it from the tree (diff)
downloadlinux-dev-eafdca4d7010a0e019aaaace3dd71b432a69b54c.tar.xz
linux-dev-eafdca4d7010a0e019aaaace3dd71b432a69b54c.zip
Merge tag 'staging-4.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging
Pull staging/IIO updates from Greg KH: "Here is the big staging and IIO driver update for 4.18-rc1. It was delayed as I wanted to make sure the final driver deletions did not cause any major merge issues, and all now looks good. There are a lot of patches here, just over 1000. The diffstat summary shows the major changes here: 1007 files changed, 16828 insertions(+), 227770 deletions(-) Because of this, we might be close to shrinking the overall kernel source code size for two releases in a row. There was loads of work in this release cycle, primarily: - tons of ks7010 driver cleanups - lots of mt7621 driver fixes and cleanups - most driver cleanups - wilc1000 fixes and cleanups - lots and lots of IIO driver cleanups and new additions - debugfs cleanups for all staging drivers - lots of other staging driver cleanups and fixes, the shortlog has the full details. but the big user-visable things here are the removal of 3 chunks of code: - ncpfs and ipx were removed on schedule, no one has cared about this code since it moved to staging last year, and if it needs to come back, it can be reverted. - lustre file system is removed. I've ranted at the lustre developers about once a year for the past 5 years, with no real forward progress at all to clean things up and get the code into the "real" part of the kernel. Given that the lustre developers continue to work on an external tree and try to port those changes to the in-kernel tree every once in a while, this whole thing really really is not working out at all. So I'm deleting it so that the developers can spend the time working in their out-of-tree location and get things cleaned up properly to get merged into the tree correctly at a later date. Because of these file removals, you will have merge issues on some of these files (2 in the ipx code, 1 in the ncpfs code, and 1 in the atomisp driver). Just delete those files, it's a simple merge :) All of this has been in linux-next for a while with no reported problems" * tag 'staging-4.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging: (1011 commits) staging: ipx: delete it from the tree ncpfs: remove uapi .h files ncpfs: remove Documentation ncpfs: remove compat functionality staging: ncpfs: delete it staging: lustre: delete the filesystem from the tree. staging: vc04_services: no need to save the log debufs dentries staging: vc04_services: vchiq_debugfs_log_entry can be a void * staging: vc04_services: remove struct vchiq_debugfs_info staging: vc04_services: move client dbg directory into static variable staging: vc04_services: remove odd vchiq_debugfs_top() wrapper staging: vc04_services: no need to check debugfs return values staging: mt7621-gpio: reorder includes alphabetically staging: mt7621-gpio: change gc_map to don't use pointers staging: mt7621-gpio: use GPIOF_DIR_OUT and GPIOF_DIR_IN macros instead of custom values staging: mt7621-gpio: change 'to_mediatek_gpio' to make just a one line return staging: mt7621-gpio: dt-bindings: update documentation for #interrupt-cells property staging: mt7621-gpio: update #interrupt-cells for the gpio node staging: mt7621-gpio: dt-bindings: complete documentation for the gpio staging: mt7621-dts: add missing properties to gpio node ...
Diffstat (limited to 'drivers/staging/ks7010/ks_hostif.c')
-rw-r--r--drivers/staging/ks7010/ks_hostif.c1043
1 files changed, 431 insertions, 612 deletions
diff --git a/drivers/staging/ks7010/ks_hostif.c b/drivers/staging/ks7010/ks_hostif.c
index 676961cf4103..0ecffab52ec2 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -1,25 +1,19 @@
+// SPDX-License-Identifier: GPL-2.0
/*
* Driver for KeyStream wireless LAN cards.
*
* Copyright (C) 2005-2008 KeyStream Corp.
* Copyright (C) 2009 Renesas Technology Corp.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
*/
-#include "ks_wlan.h"
-#include "ks_hostif.h"
+#include <linux/circ_buf.h>
+#include <linux/if_arp.h>
+#include <net/iw_handler.h>
+#include <uapi/linux/llc.h>
#include "eap_packet.h"
+#include "ks_wlan.h"
#include "michael_mic.h"
-
-#include <linux/etherdevice.h>
-#include <linux/if_ether.h>
-#include <linux/if_arp.h>
-
-/* Include Wireless Extension definition and check version */
-#include <net/iw_handler.h> /* New driver API */
+#include "ks_hostif.h"
static inline void inc_smeqhead(struct ks_wlan_private *priv)
{
@@ -33,13 +27,10 @@ static inline void inc_smeqtail(struct ks_wlan_private *priv)
static inline unsigned int cnt_smeqbody(struct ks_wlan_private *priv)
{
- unsigned int sme_cnt = priv->sme_i.qtail - priv->sme_i.qhead;
-
- return (sme_cnt + SME_EVENT_BUFF_SIZE) % SME_EVENT_BUFF_SIZE;
+ return CIRC_CNT_TO_END(priv->sme_i.qhead, priv->sme_i.qtail,
+ SME_EVENT_BUFF_SIZE);
}
-#define KS_WLAN_MEM_FLAG (GFP_ATOMIC)
-
static inline u8 get_byte(struct ks_wlan_private *priv)
{
u8 data;
@@ -96,82 +87,59 @@ static void ks_wlan_hw_wakeup_task(struct work_struct *work)
tasklet_enable(&priv->sme_task);
}
-static
-int ks_wlan_do_power_save(struct ks_wlan_private *priv)
+static void ks_wlan_do_power_save(struct ks_wlan_private *priv)
{
if (is_connect_status(priv->connect_status))
hostif_sme_enqueue(priv, SME_POW_MNGMT_REQUEST);
else
priv->dev_state = DEVICE_STATE_READY;
- return 0;
}
static
-int get_current_ap(struct ks_wlan_private *priv, struct link_ap_info_t *ap_info)
+int get_current_ap(struct ks_wlan_private *priv, struct link_ap_info *ap_info)
{
- struct local_ap_t *ap;
+ struct local_ap *ap;
union iwreq_data wrqu;
struct net_device *netdev = priv->net_dev;
+ u8 size;
ap = &priv->current_ap;
if (is_disconnect_status(priv->connect_status)) {
- memset(ap, 0, sizeof(struct local_ap_t));
+ memset(ap, 0, sizeof(struct local_ap));
return -EPERM;
}
- /* bssid */
- memcpy(ap->bssid, ap_info->bssid, ETH_ALEN);
- /* essid */
+ ether_addr_copy(ap->bssid, ap_info->bssid);
memcpy(ap->ssid.body, priv->reg.ssid.body,
priv->reg.ssid.size);
ap->ssid.size = priv->reg.ssid.size;
- /* rate_set */
memcpy(ap->rate_set.body, ap_info->rate_set.body,
ap_info->rate_set.size);
ap->rate_set.size = ap_info->rate_set.size;
if (ap_info->ext_rate_set.size != 0) {
- /* rate_set */
memcpy(&ap->rate_set.body[ap->rate_set.size],
ap_info->ext_rate_set.body,
ap_info->ext_rate_set.size);
ap->rate_set.size += ap_info->ext_rate_set.size;
}
- /* channel */
ap->channel = ap_info->ds_parameter.channel;
- /* rssi */
ap->rssi = ap_info->rssi;
- /* sq */
ap->sq = ap_info->sq;
- /* noise */
ap->noise = ap_info->noise;
- /* capability */
ap->capability = le16_to_cpu(ap_info->capability);
- /* rsn */
+ size = (ap_info->rsn.size <= RSN_IE_BODY_MAX) ?
+ ap_info->rsn.size : RSN_IE_BODY_MAX;
if ((ap_info->rsn_mode & RSN_MODE_WPA2) &&
(priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)) {
- ap->rsn_ie.id = 0x30;
- if (ap_info->rsn.size <= RSN_IE_BODY_MAX) {
- ap->rsn_ie.size = ap_info->rsn.size;
- memcpy(ap->rsn_ie.body, ap_info->rsn.body,
- ap_info->rsn.size);
- } else {
- ap->rsn_ie.size = RSN_IE_BODY_MAX;
- memcpy(ap->rsn_ie.body, ap_info->rsn.body,
- RSN_IE_BODY_MAX);
- }
+ ap->rsn_ie.id = RSN_INFO_ELEM_ID;
+ ap->rsn_ie.size = size;
+ memcpy(ap->rsn_ie.body, ap_info->rsn.body, size);
} else if ((ap_info->rsn_mode & RSN_MODE_WPA) &&
(priv->wpa.version == IW_AUTH_WPA_VERSION_WPA)) {
- ap->wpa_ie.id = 0xdd;
- if (ap_info->rsn.size <= RSN_IE_BODY_MAX) {
- ap->wpa_ie.size = ap_info->rsn.size;
- memcpy(ap->wpa_ie.body, ap_info->rsn.body,
- ap_info->rsn.size);
- } else {
- ap->wpa_ie.size = RSN_IE_BODY_MAX;
- memcpy(ap->wpa_ie.body, ap_info->rsn.body,
- RSN_IE_BODY_MAX);
- }
+ ap->wpa_ie.id = WPA_INFO_ELEM_ID;
+ ap->wpa_ie.size = size;
+ memcpy(ap->wpa_ie.body, ap_info->rsn.body, size);
} else {
ap->rsn_ie.id = 0;
ap->rsn_ie.size = 0;
@@ -183,20 +151,24 @@ int get_current_ap(struct ks_wlan_private *priv, struct link_ap_info_t *ap_info)
wrqu.data.flags = 0;
wrqu.ap_addr.sa_family = ARPHRD_ETHER;
if (is_connect_status(priv->connect_status)) {
- memcpy(wrqu.ap_addr.sa_data,
- priv->current_ap.bssid, ETH_ALEN);
+ ether_addr_copy(wrqu.ap_addr.sa_data, priv->current_ap.bssid);
netdev_dbg(priv->net_dev,
- "IWEVENT: connect bssid=%pM\n", wrqu.ap_addr.sa_data);
+ "IWEVENT: connect bssid=%pM\n",
+ wrqu.ap_addr.sa_data);
wireless_send_event(netdev, SIOCGIWAP, &wrqu, NULL);
}
- netdev_dbg(priv->net_dev, " Link AP\n");
- netdev_dbg(priv->net_dev, " bssid=%02X:%02X:%02X:%02X:%02X:%02X\n"
- " essid=%s\n"
- " rate_set=%02X,%02X,%02X,%02X,%02X,%02X,%02X,%02X\n"
- " channel=%d\n"
- " rssi=%d\n"
- " sq=%d\n"
- " capability=%04X\n",
+ netdev_dbg(priv->net_dev, "Link AP\n"
+ "- bssid=%02X:%02X:%02X:%02X:%02X:%02X\n"
+ "- essid=%s\n"
+ "- rate_set=%02X,%02X,%02X,%02X,%02X,%02X,%02X,%02X\n"
+ "- channel=%d\n"
+ "- rssi=%d\n"
+ "- sq=%d\n"
+ "- capability=%04X\n"
+ "- rsn.mode=%d\n"
+ "- rsn.size=%d\n"
+ "- ext_rate_set_size=%d\n"
+ "- rate_set_size=%d\n",
ap->bssid[0], ap->bssid[1], ap->bssid[2],
ap->bssid[3], ap->bssid[4], ap->bssid[5],
&(ap->ssid.body[0]),
@@ -204,10 +176,8 @@ int get_current_ap(struct ks_wlan_private *priv, struct link_ap_info_t *ap_info)
ap->rate_set.body[2], ap->rate_set.body[3],
ap->rate_set.body[4], ap->rate_set.body[5],
ap->rate_set.body[6], ap->rate_set.body[7],
- ap->channel, ap->rssi, ap->sq, ap->capability);
- netdev_dbg(priv->net_dev, " Link AP\n rsn.mode=%d\n rsn.size=%d\n",
- ap_info->rsn_mode, ap_info->rsn.size);
- netdev_dbg(priv->net_dev, " ext_rate_set_size=%d\n rate_set_size=%d\n",
+ ap->channel, ap->rssi, ap->sq, ap->capability,
+ ap_info->rsn_mode, ap_info->rsn.size,
ap_info->ext_rate_set.size, ap_info->rate_set.size);
return 0;
@@ -223,25 +193,19 @@ static u8 read_ie(unsigned char *bp, u8 max, u8 *body)
static
-int get_ap_information(struct ks_wlan_private *priv, struct ap_info_t *ap_info,
- struct local_ap_t *ap)
+int get_ap_information(struct ks_wlan_private *priv, struct ap_info *ap_info,
+ struct local_ap *ap)
{
unsigned char *bp;
int bsize, offset;
- memset(ap, 0, sizeof(struct local_ap_t));
+ memset(ap, 0, sizeof(struct local_ap));
- /* bssid */
- memcpy(ap->bssid, ap_info->bssid, ETH_ALEN);
- /* rssi */
+ ether_addr_copy(ap->bssid, ap_info->bssid);
ap->rssi = ap_info->rssi;
- /* sq */
ap->sq = ap_info->sq;
- /* noise */
ap->noise = ap_info->noise;
- /* capability */
ap->capability = le16_to_cpu(ap_info->capability);
- /* channel */
ap->channel = ap_info->ch_info;
bp = ap_info->body;
@@ -269,8 +233,6 @@ int get_ap_information(struct ks_wlan_private *priv, struct ap_info_t *ap_info,
(RATE_SET_MAX_SIZE - ap->rate_set.size);
}
break;
- case WLAN_EID_DS_PARAMS:
- break;
case WLAN_EID_RSN:
ap->rsn_ie.id = *bp;
ap->rsn_ie.size = read_ie(bp, RSN_IE_BODY_MAX,
@@ -284,7 +246,7 @@ int get_ap_information(struct ks_wlan_private *priv, struct ap_info_t *ap_info,
ap->wpa_ie.body);
}
break;
-
+ case WLAN_EID_DS_PARAMS:
case WLAN_EID_FH_PARAMS:
case WLAN_EID_CF_PARAMS:
case WLAN_EID_TIM:
@@ -293,7 +255,8 @@ int get_ap_information(struct ks_wlan_private *priv, struct ap_info_t *ap_info,
case WLAN_EID_ERP_INFO:
break;
default:
- netdev_err(priv->net_dev, "unknown Element ID=%d\n", *bp);
+ netdev_err(priv->net_dev,
+ "unknown Element ID=%d\n", *bp);
break;
}
@@ -314,11 +277,11 @@ int hostif_data_indication_wpa(struct ks_wlan_private *priv,
unsigned char recv_mic[8];
char buf[128];
unsigned long now;
- struct mic_failure_t *mic_failure;
- struct michael_mic_t michael_mic;
+ struct mic_failure *mic_failure;
+ struct michael_mic michael_mic;
union iwreq_data wrqu;
unsigned int key_index = auth_type - 1;
- struct wpa_key_t *key = &priv->wpa.key[key_index];
+ struct wpa_key *key = &priv->wpa.key[key_index];
eth_hdr = (struct ether_hdr *)(priv->rxp);
eth_proto = ntohs(eth_hdr->h_proto);
@@ -341,12 +304,9 @@ int hostif_data_indication_wpa(struct ks_wlan_private *priv,
memcpy(&recv_mic[0], (priv->rxp) + ((priv->rx_size) - 8), 8);
priv->rx_size = priv->rx_size - 8;
if (auth_type > 0 && auth_type < 4) { /* auth_type check */
- michael_mic_function(&michael_mic,
- (uint8_t *)key->rx_mic_key,
- (uint8_t *)priv->rxp,
- (int)priv->rx_size,
- (uint8_t)0, /* priority */
- (uint8_t *)michael_mic.result);
+ michael_mic_function(&michael_mic, key->rx_mic_key,
+ priv->rxp, priv->rx_size,
+ 0, michael_mic.result);
}
if (memcmp(michael_mic.result, recv_mic, 8) != 0) {
now = jiffies;
@@ -363,8 +323,9 @@ int hostif_data_indication_wpa(struct ks_wlan_private *priv,
} else if (mic_failure->failure == 1) {
mic_failure->failure = 2;
mic_failure->counter =
- (uint16_t)((now - mic_failure->last_failure_time) / HZ);
- if (!mic_failure->counter) /* range 1-60 */
+ (u16)((now - mic_failure->last_failure_time) / HZ);
+ /* range 1-60 */
+ if (!mic_failure->counter)
mic_failure->counter = 1;
}
priv->wpa.mic_failure.last_failure_time = now;
@@ -390,7 +351,7 @@ void hostif_data_indication(struct ks_wlan_private *priv)
{
unsigned int rx_ind_size; /* indicate data size */
struct sk_buff *skb;
- unsigned short auth_type;
+ u16 auth_type;
unsigned char temp[256];
struct ether_hdr *eth_hdr;
unsigned short eth_proto;
@@ -411,7 +372,7 @@ void hostif_data_indication(struct ks_wlan_private *priv)
eth_proto = ntohs(eth_hdr->h_proto);
/* source address check */
- if (memcmp(&priv->eth_addr[0], eth_hdr->h_source, ETH_ALEN) == 0) {
+ if (ether_addr_equal(&priv->eth_addr[0], eth_hdr->h_source)) {
netdev_err(priv->net_dev, "invalid : source is own mac address !!\n");
netdev_err(priv->net_dev,
"eth_hdrernet->h_dest=%02X:%02X:%02X:%02X:%02X:%02X\n",
@@ -436,7 +397,7 @@ void hostif_data_indication(struct ks_wlan_private *priv)
/* check 13th byte at rx data */
switch (*(priv->rxp + 12)) {
- case 0xAA: /* SNAP */
+ case LLC_SAP_SNAP:
rx_ind_size = priv->rx_size - 6;
skb = dev_alloc_skb(rx_ind_size);
if (!skb) {
@@ -456,7 +417,7 @@ void hostif_data_indication(struct ks_wlan_private *priv)
aa1x_hdr = (struct ieee802_1x_hdr *)(priv->rxp + ETHER_HDR_SIZE);
break;
- case 0xF0: /* NETBEUI/NetBIOS */
+ case LLC_SAP_NETBEUI:
rx_ind_size = (priv->rx_size + 2);
skb = dev_alloc_skb(rx_ind_size);
if (!skb) {
@@ -506,13 +467,12 @@ void hostif_mib_get_confirm(struct ks_wlan_private *priv)
u16 mib_val_size;
u16 mib_val_type;
- mib_status = get_dword(priv); /* MIB status */
- mib_attribute = get_dword(priv); /* MIB atttibute */
- mib_val_size = get_word(priv); /* MIB value size */
- mib_val_type = get_word(priv); /* MIB value type */
+ mib_status = get_dword(priv);
+ mib_attribute = get_dword(priv);
+ mib_val_size = get_word(priv);
+ mib_val_type = get_word(priv);
if (mib_status) {
- /* in case of error */
netdev_err(priv->net_dev, "attribute=%08X, status=%08X\n",
mib_attribute, mib_status);
return;
@@ -520,22 +480,13 @@ void hostif_mib_get_confirm(struct ks_wlan_private *priv)
switch (mib_attribute) {
case DOT11_MAC_ADDRESS:
- /* MAC address */
hostif_sme_enqueue(priv, SME_GET_MAC_ADDRESS);
- memcpy(priv->eth_addr, priv->rxp, ETH_ALEN);
+ ether_addr_copy(priv->eth_addr, priv->rxp);
priv->mac_address_valid = true;
- dev->dev_addr[0] = priv->eth_addr[0];
- dev->dev_addr[1] = priv->eth_addr[1];
- dev->dev_addr[2] = priv->eth_addr[2];
- dev->dev_addr[3] = priv->eth_addr[3];
- dev->dev_addr[4] = priv->eth_addr[4];
- dev->dev_addr[5] = priv->eth_addr[5];
- dev->dev_addr[6] = 0x00;
- dev->dev_addr[7] = 0x00;
+ ether_addr_copy(dev->dev_addr, priv->eth_addr);
netdev_info(dev, "MAC ADDRESS = %pM\n", priv->eth_addr);
break;
case DOT11_PRODUCT_VERSION:
- /* firmware version */
priv->version_size = priv->rx_size;
memcpy(priv->firmware_version, priv->rxp, priv->rx_size);
priv->firmware_version[priv->rx_size] = '\0';
@@ -553,18 +504,15 @@ void hostif_mib_get_confirm(struct ks_wlan_private *priv)
break;
case LOCAL_EEPROM_SUM:
memcpy(&priv->eeprom_sum, priv->rxp, sizeof(priv->eeprom_sum));
- if (priv->eeprom_sum.type == 0) {
- priv->eeprom_checksum = EEPROM_CHECKSUM_NONE;
- } else if (priv->eeprom_sum.type == 1) {
- if (priv->eeprom_sum.result == 0) {
- priv->eeprom_checksum = EEPROM_NG;
- netdev_info(dev, "LOCAL_EEPROM_SUM NG\n");
- } else if (priv->eeprom_sum.result == 1) {
- priv->eeprom_checksum = EEPROM_OK;
- }
- } else {
+ if (priv->eeprom_sum.type != 0 &&
+ priv->eeprom_sum.type != 1) {
netdev_err(dev, "LOCAL_EEPROM_SUM error!\n");
+ return;
}
+ priv->eeprom_checksum = (priv->eeprom_sum.type == 0) ?
+ EEPROM_CHECKSUM_NONE :
+ (priv->eeprom_sum.result == 0) ?
+ EEPROM_NG : EEPROM_OK;
break;
default:
netdev_err(priv->net_dev, "mib_attribute=%08x\n",
@@ -576,11 +524,11 @@ void hostif_mib_get_confirm(struct ks_wlan_private *priv)
static
void hostif_mib_set_confirm(struct ks_wlan_private *priv)
{
- u32 mib_status; /* +04 MIB Status */
- u32 mib_attribute; /* +08 MIB attribute */
+ u32 mib_status;
+ u32 mib_attribute;
- mib_status = get_dword(priv); /* MIB Status */
- mib_attribute = get_dword(priv); /* MIB attribute */
+ mib_status = get_dword(priv);
+ mib_attribute = get_dword(priv);
if (mib_status) {
/* in case of error */
@@ -649,8 +597,6 @@ void hostif_mib_set_confirm(struct ks_wlan_private *priv)
case DOT11_RSN_CONFIG_AUTH_SUITE:
hostif_sme_enqueue(priv, SME_RSN_AUTH_CONFIRM);
break;
- case DOT11_PMK_TSC:
- break;
case DOT11_GMK1_TSC:
if (atomic_read(&priv->psstatus.snooze_guard))
atomic_set(&priv->psstatus.snooze_guard, 0);
@@ -659,16 +605,11 @@ void hostif_mib_set_confirm(struct ks_wlan_private *priv)
if (atomic_read(&priv->psstatus.snooze_guard))
atomic_set(&priv->psstatus.snooze_guard, 0);
break;
+ case DOT11_PMK_TSC:
case LOCAL_PMK:
- break;
case LOCAL_GAIN:
- break;
-#ifdef WPS
case LOCAL_WPS_ENABLE:
- break;
case LOCAL_WPS_PROBE_REQ:
- break;
-#endif /* WPS */
case LOCAL_REGION:
default:
break;
@@ -698,7 +639,6 @@ void hostif_sleep_confirm(struct ks_wlan_private *priv)
static
void hostif_start_confirm(struct ks_wlan_private *priv)
{
-#ifdef WPS
union iwreq_data wrqu;
wrqu.data.length = 0;
@@ -708,7 +648,6 @@ void hostif_start_confirm(struct ks_wlan_private *priv)
eth_zero_addr(wrqu.ap_addr.sa_data);
wireless_send_event(priv->net_dev, SIOCGIWAP, &wrqu, NULL);
}
-#endif
netdev_dbg(priv->net_dev, " scan_ind_count=%d\n", priv->scan_ind_count);
hostif_sme_enqueue(priv, SME_START_CONFIRM);
}
@@ -716,7 +655,7 @@ void hostif_start_confirm(struct ks_wlan_private *priv)
static
void hostif_connect_indication(struct ks_wlan_private *priv)
{
- unsigned short connect_code;
+ u16 connect_code;
unsigned int tmp = 0;
unsigned int old_status = priv->connect_status;
struct net_device *netdev = priv->net_dev;
@@ -725,13 +664,13 @@ void hostif_connect_indication(struct ks_wlan_private *priv)
connect_code = get_word(priv);
switch (connect_code) {
- case RESULT_CONNECT: /* connect */
+ case RESULT_CONNECT:
if (!(priv->connect_status & FORCE_DISCONNECT))
netif_carrier_on(netdev);
tmp = FORCE_DISCONNECT & priv->connect_status;
priv->connect_status = tmp + CONNECT_STATUS;
break;
- case RESULT_DISCONNECT: /* disconnect */
+ case RESULT_DISCONNECT:
netif_carrier_off(netdev);
tmp = FORCE_DISCONNECT & priv->connect_status;
priv->connect_status = tmp + DISCONNECT_STATUS;
@@ -745,7 +684,7 @@ void hostif_connect_indication(struct ks_wlan_private *priv)
break;
}
- get_current_ap(priv, (struct link_ap_info_t *)priv->rxp);
+ get_current_ap(priv, (struct link_ap_info *)priv->rxp);
if (is_connect_status(priv->connect_status) &&
is_disconnect_status(old_status)) {
/* for power save */
@@ -771,10 +710,11 @@ static
void hostif_scan_indication(struct ks_wlan_private *priv)
{
int i;
- struct ap_info_t *ap_info;
+ struct ap_info *ap_info;
- netdev_dbg(priv->net_dev, "scan_ind_count = %d\n", priv->scan_ind_count);
- ap_info = (struct ap_info_t *)(priv->rxp);
+ netdev_dbg(priv->net_dev,
+ "scan_ind_count = %d\n", priv->scan_ind_count);
+ ap_info = (struct ap_info *)(priv->rxp);
if (priv->scan_ind_count) {
/* bssid check */
@@ -794,7 +734,7 @@ void hostif_scan_indication(struct ks_wlan_private *priv)
if (priv->scan_ind_count < LOCAL_APLIST_MAX + 1) {
netdev_dbg(priv->net_dev, " scan_ind_count=%d :: aplist.size=%d\n",
priv->scan_ind_count, priv->aplist.size);
- get_ap_information(priv, (struct ap_info_t *)(priv->rxp),
+ get_ap_information(priv, (struct ap_info *)(priv->rxp),
&(priv->aplist.ap[priv->scan_ind_count - 1]));
priv->aplist.size = priv->scan_ind_count;
} else {
@@ -863,8 +803,8 @@ void hostif_adhoc_set_confirm(struct ks_wlan_private *priv)
static
void hostif_associate_indication(struct ks_wlan_private *priv)
{
- struct association_request_t *assoc_req;
- struct association_response_t *assoc_resp;
+ struct association_request *assoc_req;
+ struct association_response *assoc_resp;
unsigned char *pb;
union iwreq_data wrqu;
char buf[IW_CUSTOM_MAX];
@@ -874,8 +814,8 @@ void hostif_associate_indication(struct ks_wlan_private *priv)
static const char associnfo_leader0[] = "ASSOCINFO(ReqIEs=";
static const char associnfo_leader1[] = " RespIEs=";
- assoc_req = (struct association_request_t *)(priv->rxp);
- assoc_resp = (struct association_response_t *)(assoc_req + 1);
+ assoc_req = (struct association_request *)(priv->rxp);
+ assoc_resp = (struct association_response *)(assoc_req + 1);
pb = (unsigned char *)(assoc_resp + 1);
memset(&wrqu, 0, sizeof(wrqu));
@@ -905,13 +845,13 @@ void hostif_associate_indication(struct ks_wlan_private *priv)
static
void hostif_bss_scan_confirm(struct ks_wlan_private *priv)
{
- unsigned int result_code;
+ u32 result_code;
struct net_device *dev = priv->net_dev;
union iwreq_data wrqu;
result_code = get_dword(priv);
- netdev_dbg(priv->net_dev, "result=%d :: scan_ind_count=%d\n", result_code,
- priv->scan_ind_count);
+ netdev_dbg(priv->net_dev, "result=%d :: scan_ind_count=%d\n",
+ result_code, priv->scan_ind_count);
priv->sme_i.sme_flag &= ~SME_AP_SCAN;
hostif_sme_enqueue(priv, SME_BSS_SCAN_CONFIRM);
@@ -926,10 +866,10 @@ static
void hostif_phy_information_confirm(struct ks_wlan_private *priv)
{
struct iw_statistics *wstats = &priv->wstats;
- unsigned char rssi, signal, noise;
- unsigned char link_speed;
- unsigned int transmitted_frame_count, received_fragment_count;
- unsigned int failed_count, fcs_error_count;
+ u8 rssi, signal, noise;
+ u8 link_speed;
+ u32 transmitted_frame_count, received_fragment_count;
+ u32 failed_count, fcs_error_count;
rssi = get_byte(priv);
signal = get_byte(priv);
@@ -964,16 +904,17 @@ void hostif_phy_information_confirm(struct ks_wlan_private *priv)
static
void hostif_mic_failure_confirm(struct ks_wlan_private *priv)
{
- netdev_dbg(priv->net_dev, "mic_failure=%u\n", priv->wpa.mic_failure.failure);
+ netdev_dbg(priv->net_dev, "mic_failure=%u\n",
+ priv->wpa.mic_failure.failure);
hostif_sme_enqueue(priv, SME_MIC_FAILURE_CONFIRM);
}
static
void hostif_event_check(struct ks_wlan_private *priv)
{
- unsigned short event;
+ u16 event;
- event = get_word(priv); /* get event */
+ event = get_word(priv);
switch (event) {
case HIF_DATA_IND:
hostif_data_indication(priv);
@@ -1044,11 +985,11 @@ static void *hostif_generic_request(size_t size, int event)
{
struct hostif_hdr *p;
- p = kzalloc(hif_align_size(size), KS_WLAN_MEM_FLAG);
+ p = kzalloc(hif_align_size(size), GFP_ATOMIC);
if (!p)
return NULL;
- p->size = cpu_to_le16((u16)(size - sizeof(p->size)));
+ p->size = cpu_to_le16(size - sizeof(p->size));
p->event = cpu_to_le16(event);
return p;
@@ -1057,15 +998,14 @@ static void *hostif_generic_request(size_t size, int event)
int hostif_data_request(struct ks_wlan_private *priv, struct sk_buff *skb)
{
unsigned int skb_len = 0;
-
unsigned char *buffer = NULL;
unsigned int length = 0;
- struct hostif_data_request_t *pp;
+ struct hostif_data_request *pp;
unsigned char *p;
int result = 0;
unsigned short eth_proto;
struct ether_hdr *eth_hdr;
- struct michael_mic_t michael_mic;
+ struct michael_mic michael_mic;
unsigned short keyinfo = 0;
struct ieee802_1x_hdr *aa1x_hdr;
struct wpa_eapol_key *eap_key;
@@ -1098,7 +1038,7 @@ int hostif_data_request(struct ks_wlan_private *priv, struct sk_buff *skb)
}
size = sizeof(*pp) + 6 + skb_len + 8;
- pp = kmalloc(hif_align_size(size), KS_WLAN_MEM_FLAG);
+ pp = kmalloc(hif_align_size(size), GFP_ATOMIC);
if (!pp) {
ret = -ENOMEM;
goto err_kfree_skb;
@@ -1111,9 +1051,10 @@ int hostif_data_request(struct ks_wlan_private *priv, struct sk_buff *skb)
/* skb check */
eth = (struct ethhdr *)skb->data;
- if (memcmp(&priv->eth_addr[0], eth->h_source, ETH_ALEN) != 0) {
- netdev_err(priv->net_dev, "invalid mac address !!\n");
- netdev_err(priv->net_dev, "ethernet->h_source=%pM\n", eth->h_source);
+ if (!ether_addr_equal(&priv->eth_addr[0], eth->h_source)) {
+ netdev_err(priv->net_dev,
+ "Invalid mac address: ethernet->h_source=%pM\n",
+ eth->h_source);
ret = -ENXIO;
goto err_kfree;
}
@@ -1128,7 +1069,6 @@ int hostif_data_request(struct ks_wlan_private *priv, struct sk_buff *skb)
/* EtherType/Length check */
if (*(buffer + 1) + (*buffer << 8) > 1500) {
/* ProtocolEAP = *(buffer+1) + (*buffer << 8); */
- /* netdev_dbg(priv->net_dev, "Send [SNAP]Type %x\n",ProtocolEAP); */
/* SAP/CTL/OUI(6 byte) add */
*p++ = 0xAA; /* DSAP */
*p++ = 0xAA; /* SSAP */
@@ -1169,40 +1109,37 @@ int hostif_data_request(struct ks_wlan_private *priv, struct sk_buff *skb)
priv->wpa.key[1].key_len == 0 &&
priv->wpa.key[2].key_len == 0 &&
priv->wpa.key[3].key_len == 0) {
- pp->auth_type = cpu_to_le16((uint16_t)TYPE_AUTH);
+ pp->auth_type = cpu_to_le16(TYPE_AUTH);
} else {
if (priv->wpa.pairwise_suite == IW_AUTH_CIPHER_TKIP) {
michael_mic_function(&michael_mic,
- (uint8_t *)priv->wpa.key[0].tx_mic_key,
- (uint8_t *)&pp->data[0],
- (int)skb_len,
- (uint8_t)0, /* priority */
- (uint8_t *)michael_mic.result);
+ priv->wpa.key[0].tx_mic_key,
+ &pp->data[0], skb_len,
+ 0, michael_mic.result);
memcpy(p, michael_mic.result, 8);
length += 8;
skb_len += 8;
p += 8;
pp->auth_type =
- cpu_to_le16((uint16_t)TYPE_DATA);
+ cpu_to_le16(TYPE_DATA);
} else if (priv->wpa.pairwise_suite ==
IW_AUTH_CIPHER_CCMP) {
pp->auth_type =
- cpu_to_le16((uint16_t)TYPE_DATA);
+ cpu_to_le16(TYPE_DATA);
}
}
} else {
if (eth_proto == ETH_P_PAE)
- pp->auth_type = cpu_to_le16((uint16_t)TYPE_AUTH);
+ pp->auth_type = cpu_to_le16(TYPE_AUTH);
else
- pp->auth_type = cpu_to_le16((uint16_t)TYPE_DATA);
+ pp->auth_type = cpu_to_le16(TYPE_DATA);
}
/* header value set */
pp->header.size =
- cpu_to_le16((uint16_t)
- (sizeof(*pp) - sizeof(pp->header.size) + skb_len));
- pp->header.event = cpu_to_le16((uint16_t)HIF_DATA_REQ);
+ cpu_to_le16((sizeof(*pp) - sizeof(pp->header.size) + skb_len));
+ pp->header.event = cpu_to_le16(HIF_DATA_REQ);
/* tx request */
result = ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp) + skb_len),
@@ -1213,7 +1150,8 @@ int hostif_data_request(struct ks_wlan_private *priv, struct sk_buff *skb)
priv->wpa.mic_failure.failure > 0) {
if (keyinfo & WPA_KEY_INFO_ERROR &&
keyinfo & WPA_KEY_INFO_REQUEST) {
- netdev_err(priv->net_dev, " MIC ERROR Report SET : %04X\n", keyinfo);
+ netdev_err(priv->net_dev,
+ "MIC ERROR Report SET : %04X\n", keyinfo);
hostif_sme_enqueue(priv, SME_MIC_FAILURE_REQUEST);
}
if (priv->wpa.mic_failure.failure == 2)
@@ -1236,27 +1174,31 @@ static inline void ps_confirm_wait_inc(struct ks_wlan_private *priv)
atomic_inc(&priv->psstatus.confirm_wait);
}
-static
-void hostif_mib_get_request(struct ks_wlan_private *priv,
- unsigned long mib_attribute)
+static inline void send_request_to_device(struct ks_wlan_private *priv,
+ void *data, size_t size)
+{
+ ps_confirm_wait_inc(priv);
+ ks_wlan_hw_tx(priv, data, size, NULL, NULL);
+}
+
+static void hostif_mib_get_request(struct ks_wlan_private *priv,
+ u32 mib_attribute)
{
- struct hostif_mib_get_request_t *pp;
+ struct hostif_mib_get_request *pp;
pp = hostif_generic_request(sizeof(*pp), HIF_MIB_GET_REQ);
if (!pp)
return;
- pp->mib_attribute = cpu_to_le32((uint32_t)mib_attribute);
+ pp->mib_attribute = cpu_to_le32(mib_attribute);
- /* send to device request */
- ps_confirm_wait_inc(priv);
- ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL);
+ send_request_to_device(priv, pp, hif_align_size(sizeof(*pp)));
}
-static
-void hostif_mib_set_request(struct ks_wlan_private *priv,
- unsigned long mib_attribute, unsigned short size,
- unsigned short type, void *vp)
+static void hostif_mib_set_request(struct ks_wlan_private *priv,
+ enum mib_attribute attr,
+ enum mib_data_type type,
+ void *data, size_t size)
{
struct hostif_mib_set_request_t *pp;
@@ -1267,30 +1209,52 @@ void hostif_mib_set_request(struct ks_wlan_private *priv,
if (!pp)
return;
- pp->mib_attribute = cpu_to_le32((uint32_t)mib_attribute);
- pp->mib_value.size = cpu_to_le16((uint16_t)size);
- pp->mib_value.type = cpu_to_le16((uint16_t)type);
- memcpy(&pp->mib_value.body, vp, size);
+ pp->mib_attribute = cpu_to_le32(attr);
+ pp->mib_value.size = cpu_to_le16(size);
+ pp->mib_value.type = cpu_to_le16(type);
+ memcpy(&pp->mib_value.body, data, size);
- /* send to device request */
- ps_confirm_wait_inc(priv);
- ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp) + size), NULL, NULL);
+ send_request_to_device(priv, pp, hif_align_size(sizeof(*pp) + size));
+}
+
+static inline void hostif_mib_set_request_int(struct ks_wlan_private *priv,
+ enum mib_attribute attr, int val)
+{
+ __le32 v = cpu_to_le32(val);
+ size_t size = sizeof(v);
+
+ hostif_mib_set_request(priv, attr, MIB_VALUE_TYPE_INT, &v, size);
+}
+
+static inline void hostif_mib_set_request_bool(struct ks_wlan_private *priv,
+ enum mib_attribute attr,
+ bool val)
+{
+ __le32 v = cpu_to_le32(val);
+ size_t size = sizeof(v);
+
+ hostif_mib_set_request(priv, attr, MIB_VALUE_TYPE_BOOL, &v, size);
+}
+
+static inline void hostif_mib_set_request_ostring(struct ks_wlan_private *priv,
+ enum mib_attribute attr,
+ void *data, size_t size)
+{
+ hostif_mib_set_request(priv, attr, MIB_VALUE_TYPE_OSTRING, data, size);
}
static
void hostif_start_request(struct ks_wlan_private *priv, unsigned char mode)
{
- struct hostif_start_request_t *pp;
+ struct hostif_start_request *pp;
pp = hostif_generic_request(sizeof(*pp), HIF_START_REQ);
if (!pp)
return;
- pp->mode = cpu_to_le16((uint16_t)mode);
+ pp->mode = cpu_to_le16(mode);
- /* send to device request */
- ps_confirm_wait_inc(priv);
- ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL);
+ send_request_to_device(priv, pp, hif_align_size(sizeof(*pp)));
priv->aplist.size = 0;
priv->scan_ind_count = 0;
@@ -1310,14 +1274,15 @@ static __le16 ks_wlan_cap(struct ks_wlan_private *priv)
capability &= ~(WLAN_CAPABILITY_DSSS_OFDM);
}
- return cpu_to_le16((uint16_t)capability);
+ return cpu_to_le16(capability);
}
-static void init_request(struct ks_wlan_private *priv, struct hostif_request_t *req)
+static void init_request(struct ks_wlan_private *priv,
+ struct hostif_request *req)
{
- req->phy_type = cpu_to_le16((uint16_t)(priv->reg.phy_type));
- req->cts_mode = cpu_to_le16((uint16_t)(priv->reg.cts_mode));
- req->scan_type = cpu_to_le16((uint16_t)(priv->reg.scan_type));
+ req->phy_type = cpu_to_le16(priv->reg.phy_type);
+ req->cts_mode = cpu_to_le16(priv->reg.cts_mode);
+ req->scan_type = cpu_to_le16(priv->reg.scan_type);
req->rate_set.size = priv->reg.rate_set.size;
req->capability = ks_wlan_cap(priv);
memcpy(&req->rate_set.body[0], &priv->reg.rate_set.body[0],
@@ -1327,24 +1292,22 @@ static void init_request(struct ks_wlan_private *priv, struct hostif_request_t *
static
void hostif_ps_adhoc_set_request(struct ks_wlan_private *priv)
{
- struct hostif_ps_adhoc_set_request_t *pp;
+ struct hostif_ps_adhoc_set_request *pp;
pp = hostif_generic_request(sizeof(*pp), HIF_PS_ADH_SET_REQ);
if (!pp)
return;
init_request(priv, &pp->request);
- pp->channel = cpu_to_le16((uint16_t)(priv->reg.channel));
+ pp->channel = cpu_to_le16(priv->reg.channel);
- /* send to device request */
- ps_confirm_wait_inc(priv);
- ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL);
+ send_request_to_device(priv, pp, hif_align_size(sizeof(*pp)));
}
static
void hostif_infrastructure_set_request(struct ks_wlan_private *priv, int event)
{
- struct hostif_infrastructure_set_request_t *pp;
+ struct hostif_infrastructure_set_request *pp;
pp = hostif_generic_request(sizeof(*pp), event);
if (!pp)
@@ -1354,8 +1317,8 @@ void hostif_infrastructure_set_request(struct ks_wlan_private *priv, int event)
pp->ssid.size = priv->reg.ssid.size;
memcpy(&pp->ssid.body[0], &priv->reg.ssid.body[0], priv->reg.ssid.size);
pp->beacon_lost_count =
- cpu_to_le16((uint16_t)(priv->reg.beacon_lost_count));
- pp->auth_type = cpu_to_le16((uint16_t)(priv->reg.authenticate_type));
+ cpu_to_le16(priv->reg.beacon_lost_count);
+ pp->auth_type = cpu_to_le16(priv->reg.authenticate_type);
pp->channel_list.body[0] = 1;
pp->channel_list.body[1] = 8;
@@ -1377,34 +1340,30 @@ void hostif_infrastructure_set_request(struct ks_wlan_private *priv, int event)
pp->channel_list.size = 14;
}
- /* send to device request */
- ps_confirm_wait_inc(priv);
- ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL);
+ send_request_to_device(priv, pp, hif_align_size(sizeof(*pp)));
}
static
void hostif_adhoc_set_request(struct ks_wlan_private *priv)
{
- struct hostif_adhoc_set_request_t *pp;
+ struct hostif_adhoc_set_request *pp;
pp = hostif_generic_request(sizeof(*pp), HIF_ADH_SET_REQ);
if (!pp)
return;
init_request(priv, &pp->request);
- pp->channel = cpu_to_le16((uint16_t)(priv->reg.channel));
+ pp->channel = cpu_to_le16(priv->reg.channel);
pp->ssid.size = priv->reg.ssid.size;
memcpy(&pp->ssid.body[0], &priv->reg.ssid.body[0], priv->reg.ssid.size);
- /* send to device request */
- ps_confirm_wait_inc(priv);
- ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL);
+ send_request_to_device(priv, pp, hif_align_size(sizeof(*pp)));
}
static
void hostif_adhoc_set2_request(struct ks_wlan_private *priv)
{
- struct hostif_adhoc_set2_request_t *pp;
+ struct hostif_adhoc_set2_request *pp;
pp = hostif_generic_request(sizeof(*pp), HIF_ADH_SET_REQ);
if (!pp)
@@ -1418,82 +1377,70 @@ void hostif_adhoc_set2_request(struct ks_wlan_private *priv)
pp->channel_list.size = 1;
memcpy(pp->bssid, priv->reg.bssid, ETH_ALEN);
- /* send to device request */
- ps_confirm_wait_inc(priv);
- ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL);
+ send_request_to_device(priv, pp, hif_align_size(sizeof(*pp)));
}
static
void hostif_stop_request(struct ks_wlan_private *priv)
{
- struct hostif_stop_request_t *pp;
+ struct hostif_stop_request *pp;
pp = hostif_generic_request(sizeof(*pp), HIF_STOP_REQ);
if (!pp)
return;
- /* send to device request */
- ps_confirm_wait_inc(priv);
- ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL);
+ send_request_to_device(priv, pp, hif_align_size(sizeof(*pp)));
}
static
void hostif_phy_information_request(struct ks_wlan_private *priv)
{
- struct hostif_phy_information_request_t *pp;
+ struct hostif_phy_information_request *pp;
pp = hostif_generic_request(sizeof(*pp), HIF_PHY_INFO_REQ);
if (!pp)
return;
if (priv->reg.phy_info_timer) {
- pp->type = cpu_to_le16((uint16_t)TIME_TYPE);
- pp->time = cpu_to_le16((uint16_t)(priv->reg.phy_info_timer));
+ pp->type = cpu_to_le16(TIME_TYPE);
+ pp->time = cpu_to_le16(priv->reg.phy_info_timer);
} else {
- pp->type = cpu_to_le16((uint16_t)NORMAL_TYPE);
- pp->time = cpu_to_le16((uint16_t)0);
+ pp->type = cpu_to_le16(NORMAL_TYPE);
+ pp->time = cpu_to_le16(0);
}
- /* send to device request */
- ps_confirm_wait_inc(priv);
- ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL);
+ send_request_to_device(priv, pp, hif_align_size(sizeof(*pp)));
}
static
void hostif_power_mgmt_request(struct ks_wlan_private *priv,
- unsigned long mode, unsigned long wake_up,
- unsigned long receive_dtims)
+ u32 mode, u32 wake_up, u32 receive_dtims)
{
- struct hostif_power_mgmt_request_t *pp;
+ struct hostif_power_mgmt_request *pp;
pp = hostif_generic_request(sizeof(*pp), HIF_POWER_MGMT_REQ);
if (!pp)
return;
- pp->mode = cpu_to_le32((uint32_t)mode);
- pp->wake_up = cpu_to_le32((uint32_t)wake_up);
- pp->receive_dtims = cpu_to_le32((uint32_t)receive_dtims);
+ pp->mode = cpu_to_le32(mode);
+ pp->wake_up = cpu_to_le32(wake_up);
+ pp->receive_dtims = cpu_to_le32(receive_dtims);
- /* send to device request */
- ps_confirm_wait_inc(priv);
- ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL);
+ send_request_to_device(priv, pp, hif_align_size(sizeof(*pp)));
}
static
void hostif_sleep_request(struct ks_wlan_private *priv,
enum sleep_mode_type mode)
{
- struct hostif_sleep_request_t *pp;
+ struct hostif_sleep_request *pp;
if (mode == SLP_SLEEP) {
pp = hostif_generic_request(sizeof(*pp), HIF_SLEEP_REQ);
if (!pp)
return;
- /* send to device request */
- ps_confirm_wait_inc(priv);
- ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL,
- NULL);
+ send_request_to_device(priv, pp, hif_align_size(sizeof(*pp)));
} else if (mode == SLP_ACTIVE) {
atomic_set(&priv->sleepstatus.wakeup_request, 1);
queue_delayed_work(priv->wq, &priv->rw_dwork, 1);
@@ -1505,10 +1452,10 @@ void hostif_sleep_request(struct ks_wlan_private *priv,
static
void hostif_bss_scan_request(struct ks_wlan_private *priv,
- unsigned long scan_type, uint8_t *scan_ssid,
- uint8_t scan_ssid_len)
+ unsigned long scan_type, u8 *scan_ssid,
+ u8 scan_ssid_len)
{
- struct hostif_bss_scan_request_t *pp;
+ struct hostif_bss_scan_request *pp;
pp = hostif_generic_request(sizeof(*pp), HIF_SCAN_REQ);
if (!pp)
@@ -1516,8 +1463,8 @@ void hostif_bss_scan_request(struct ks_wlan_private *priv,
pp->scan_type = scan_type;
- pp->ch_time_min = cpu_to_le32((uint32_t)110); /* default value */
- pp->ch_time_max = cpu_to_le32((uint32_t)130); /* default value */
+ pp->ch_time_min = cpu_to_le32(110); /* default value */
+ pp->ch_time_max = cpu_to_le32(130); /* default value */
pp->channel_list.body[0] = 1;
pp->channel_list.body[1] = 8;
pp->channel_list.body[2] = 2;
@@ -1545,9 +1492,7 @@ void hostif_bss_scan_request(struct ks_wlan_private *priv,
memcpy(&pp->ssid.body[0], scan_ssid, scan_ssid_len);
}
- /* send to device request */
- ps_confirm_wait_inc(priv);
- ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL);
+ send_request_to_device(priv, pp, hif_align_size(sizeof(*pp)));
priv->aplist.size = 0;
priv->scan_ind_count = 0;
@@ -1555,45 +1500,42 @@ void hostif_bss_scan_request(struct ks_wlan_private *priv,
static
void hostif_mic_failure_request(struct ks_wlan_private *priv,
- unsigned short failure_count,
- unsigned short timer)
+ u16 failure_count, u16 timer)
{
- struct hostif_mic_failure_request_t *pp;
+ struct hostif_mic_failure_request *pp;
pp = hostif_generic_request(sizeof(*pp), HIF_MIC_FAILURE_REQ);
if (!pp)
return;
- pp->failure_count = cpu_to_le16((uint16_t)failure_count);
- pp->timer = cpu_to_le16((uint16_t)timer);
+ pp->failure_count = cpu_to_le16(failure_count);
+ pp->timer = cpu_to_le16(timer);
- /* send to device request */
- ps_confirm_wait_inc(priv);
- ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL);
+ send_request_to_device(priv, pp, hif_align_size(sizeof(*pp)));
}
/* Device I/O Receive indicate */
static void devio_rec_ind(struct ks_wlan_private *priv, unsigned char *p,
unsigned int size)
{
- if (priv->device_open_status) {
- spin_lock(&priv->dev_read_lock); /* request spin lock */
- priv->dev_data[atomic_read(&priv->rec_count)] = p;
- priv->dev_size[atomic_read(&priv->rec_count)] = size;
-
- if (atomic_read(&priv->event_count) != DEVICE_STOCK_COUNT) {
- /* rx event count inc */
- atomic_inc(&priv->event_count);
- }
- atomic_inc(&priv->rec_count);
- if (atomic_read(&priv->rec_count) == DEVICE_STOCK_COUNT)
- atomic_set(&priv->rec_count, 0);
+ if (!priv->is_device_open)
+ return;
- wake_up_interruptible_all(&priv->devread_wait);
+ spin_lock(&priv->dev_read_lock);
+ priv->dev_data[atomic_read(&priv->rec_count)] = p;
+ priv->dev_size[atomic_read(&priv->rec_count)] = size;
- /* release spin lock */
- spin_unlock(&priv->dev_read_lock);
+ if (atomic_read(&priv->event_count) != DEVICE_STOCK_COUNT) {
+ /* rx event count inc */
+ atomic_inc(&priv->event_count);
}
+ atomic_inc(&priv->rec_count);
+ if (atomic_read(&priv->rec_count) == DEVICE_STOCK_COUNT)
+ atomic_set(&priv->rec_count, 0);
+
+ wake_up_interruptible_all(&priv->devread_wait);
+
+ spin_unlock(&priv->dev_read_lock);
}
void hostif_receive(struct ks_wlan_private *priv, unsigned char *p,
@@ -1604,247 +1546,183 @@ void hostif_receive(struct ks_wlan_private *priv, unsigned char *p,
priv->rxp = p;
priv->rx_size = size;
- if (get_word(priv) == priv->rx_size) { /* length check !! */
- hostif_event_check(priv); /* event check */
- }
+ if (get_word(priv) == priv->rx_size)
+ hostif_event_check(priv);
}
-static
-void hostif_sme_set_wep(struct ks_wlan_private *priv, int type)
+static void hostif_sme_set_wep(struct ks_wlan_private *priv, int type)
{
- __le32 val;
-
switch (type) {
case SME_WEP_INDEX_REQUEST:
- val = cpu_to_le32((uint32_t)(priv->reg.wep_index));
- hostif_mib_set_request(priv, DOT11_WEP_DEFAULT_KEY_ID,
- sizeof(val), MIB_VALUE_TYPE_INT, &val);
+ hostif_mib_set_request_int(priv, DOT11_WEP_DEFAULT_KEY_ID,
+ priv->reg.wep_index);
break;
case SME_WEP_KEY1_REQUEST:
- if (!priv->wpa.wpa_enabled)
- hostif_mib_set_request(priv,
+ if (priv->wpa.wpa_enabled)
+ return;
+ hostif_mib_set_request_ostring(priv,
DOT11_WEP_DEFAULT_KEY_VALUE1,
- priv->reg.wep_key[0].size,
- MIB_VALUE_TYPE_OSTRING,
- &priv->reg.wep_key[0].val[0]);
+ &priv->reg.wep_key[0].val[0],
+ priv->reg.wep_key[0].size);
break;
case SME_WEP_KEY2_REQUEST:
- if (!priv->wpa.wpa_enabled)
- hostif_mib_set_request(priv,
+ if (priv->wpa.wpa_enabled)
+ return;
+ hostif_mib_set_request_ostring(priv,
DOT11_WEP_DEFAULT_KEY_VALUE2,
- priv->reg.wep_key[1].size,
- MIB_VALUE_TYPE_OSTRING,
- &priv->reg.wep_key[1].val[0]);
+ &priv->reg.wep_key[1].val[0],
+ priv->reg.wep_key[1].size);
break;
case SME_WEP_KEY3_REQUEST:
- if (!priv->wpa.wpa_enabled)
- hostif_mib_set_request(priv,
+ if (priv->wpa.wpa_enabled)
+ return;
+ hostif_mib_set_request_ostring(priv,
DOT11_WEP_DEFAULT_KEY_VALUE3,
- priv->reg.wep_key[2].size,
- MIB_VALUE_TYPE_OSTRING,
- &priv->reg.wep_key[2].val[0]);
+ &priv->reg.wep_key[2].val[0],
+ priv->reg.wep_key[2].size);
break;
case SME_WEP_KEY4_REQUEST:
- if (!priv->wpa.wpa_enabled)
- hostif_mib_set_request(priv,
+ if (priv->wpa.wpa_enabled)
+ return;
+ hostif_mib_set_request_ostring(priv,
DOT11_WEP_DEFAULT_KEY_VALUE4,
- priv->reg.wep_key[3].size,
- MIB_VALUE_TYPE_OSTRING,
- &priv->reg.wep_key[3].val[0]);
+ &priv->reg.wep_key[3].val[0],
+ priv->reg.wep_key[3].size);
break;
case SME_WEP_FLAG_REQUEST:
- val = cpu_to_le32((uint32_t)(priv->reg.privacy_invoked));
- hostif_mib_set_request(priv, DOT11_PRIVACY_INVOKED,
- sizeof(val), MIB_VALUE_TYPE_BOOL, &val);
+ hostif_mib_set_request_bool(priv, DOT11_PRIVACY_INVOKED,
+ priv->reg.privacy_invoked);
break;
}
}
-struct wpa_suite_t {
+struct wpa_suite {
__le16 size;
unsigned char suite[4][CIPHER_ID_LEN];
} __packed;
-struct rsn_mode_t {
+struct rsn_mode {
__le32 rsn_mode;
__le16 rsn_capability;
} __packed;
-static
-void hostif_sme_set_rsn(struct ks_wlan_private *priv, int type)
+static void hostif_sme_set_rsn(struct ks_wlan_private *priv, int type)
{
- struct wpa_suite_t wpa_suite;
- struct rsn_mode_t rsn_mode;
- __le32 val;
+ struct wpa_suite wpa_suite;
+ struct rsn_mode rsn_mode;
+ size_t size;
+ u32 mode;
+ const u8 *buf = NULL;
memset(&wpa_suite, 0, sizeof(wpa_suite));
switch (type) {
case SME_RSN_UCAST_REQUEST:
- wpa_suite.size = cpu_to_le16((uint16_t)1);
+ wpa_suite.size = cpu_to_le16(1);
switch (priv->wpa.pairwise_suite) {
case IW_AUTH_CIPHER_NONE:
- if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
- memcpy(&wpa_suite.suite[0][0],
- CIPHER_ID_WPA2_NONE, CIPHER_ID_LEN);
- else
- memcpy(&wpa_suite.suite[0][0],
- CIPHER_ID_WPA_NONE, CIPHER_ID_LEN);
+ buf = (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) ?
+ CIPHER_ID_WPA2_NONE : CIPHER_ID_WPA_NONE;
break;
case IW_AUTH_CIPHER_WEP40:
- if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
- memcpy(&wpa_suite.suite[0][0],
- CIPHER_ID_WPA2_WEP40, CIPHER_ID_LEN);
- else
- memcpy(&wpa_suite.suite[0][0],
- CIPHER_ID_WPA_WEP40, CIPHER_ID_LEN);
+ buf = (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) ?
+ CIPHER_ID_WPA2_WEP40 : CIPHER_ID_WPA_WEP40;
break;
case IW_AUTH_CIPHER_TKIP:
- if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
- memcpy(&wpa_suite.suite[0][0],
- CIPHER_ID_WPA2_TKIP, CIPHER_ID_LEN);
- else
- memcpy(&wpa_suite.suite[0][0],
- CIPHER_ID_WPA_TKIP, CIPHER_ID_LEN);
+ buf = (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) ?
+ CIPHER_ID_WPA2_TKIP : CIPHER_ID_WPA_TKIP;
break;
case IW_AUTH_CIPHER_CCMP:
- if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
- memcpy(&wpa_suite.suite[0][0],
- CIPHER_ID_WPA2_CCMP, CIPHER_ID_LEN);
- else
- memcpy(&wpa_suite.suite[0][0],
- CIPHER_ID_WPA_CCMP, CIPHER_ID_LEN);
+ buf = (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) ?
+ CIPHER_ID_WPA2_CCMP : CIPHER_ID_WPA_CCMP;
break;
case IW_AUTH_CIPHER_WEP104:
- if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
- memcpy(&wpa_suite.suite[0][0],
- CIPHER_ID_WPA2_WEP104, CIPHER_ID_LEN);
- else
- memcpy(&wpa_suite.suite[0][0],
- CIPHER_ID_WPA_WEP104, CIPHER_ID_LEN);
+ buf = (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) ?
+ CIPHER_ID_WPA2_WEP104 : CIPHER_ID_WPA_WEP104;
break;
}
- hostif_mib_set_request(priv, DOT11_RSN_CONFIG_UNICAST_CIPHER,
- sizeof(wpa_suite.size) +
- CIPHER_ID_LEN *
- le16_to_cpu(wpa_suite.size),
- MIB_VALUE_TYPE_OSTRING, &wpa_suite);
+ if (buf)
+ memcpy(&wpa_suite.suite[0][0], buf, CIPHER_ID_LEN);
+ size = sizeof(wpa_suite.size) +
+ (CIPHER_ID_LEN * le16_to_cpu(wpa_suite.size));
+ hostif_mib_set_request_ostring(priv,
+ DOT11_RSN_CONFIG_UNICAST_CIPHER,
+ &wpa_suite, size);
break;
case SME_RSN_MCAST_REQUEST:
switch (priv->wpa.group_suite) {
case IW_AUTH_CIPHER_NONE:
- if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
- memcpy(&wpa_suite.suite[0][0],
- CIPHER_ID_WPA2_NONE, CIPHER_ID_LEN);
- else
- memcpy(&wpa_suite.suite[0][0],
- CIPHER_ID_WPA_NONE, CIPHER_ID_LEN);
+ buf = (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) ?
+ CIPHER_ID_WPA2_NONE : CIPHER_ID_WPA_NONE;
break;
case IW_AUTH_CIPHER_WEP40:
- if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
- memcpy(&wpa_suite.suite[0][0],
- CIPHER_ID_WPA2_WEP40, CIPHER_ID_LEN);
- else
- memcpy(&wpa_suite.suite[0][0],
- CIPHER_ID_WPA_WEP40, CIPHER_ID_LEN);
+ buf = (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) ?
+ CIPHER_ID_WPA2_WEP40 : CIPHER_ID_WPA_WEP40;
break;
case IW_AUTH_CIPHER_TKIP:
- if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
- memcpy(&wpa_suite.suite[0][0],
- CIPHER_ID_WPA2_TKIP, CIPHER_ID_LEN);
- else
- memcpy(&wpa_suite.suite[0][0],
- CIPHER_ID_WPA_TKIP, CIPHER_ID_LEN);
+ buf = (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) ?
+ CIPHER_ID_WPA2_TKIP : CIPHER_ID_WPA_TKIP;
break;
case IW_AUTH_CIPHER_CCMP:
- if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
- memcpy(&wpa_suite.suite[0][0],
- CIPHER_ID_WPA2_CCMP, CIPHER_ID_LEN);
- else
- memcpy(&wpa_suite.suite[0][0],
- CIPHER_ID_WPA_CCMP, CIPHER_ID_LEN);
+ buf = (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) ?
+ CIPHER_ID_WPA2_CCMP : CIPHER_ID_WPA_CCMP;
break;
case IW_AUTH_CIPHER_WEP104:
- if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
- memcpy(&wpa_suite.suite[0][0],
- CIPHER_ID_WPA2_WEP104, CIPHER_ID_LEN);
- else
- memcpy(&wpa_suite.suite[0][0],
- CIPHER_ID_WPA_WEP104, CIPHER_ID_LEN);
+ buf = (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) ?
+ CIPHER_ID_WPA2_WEP104 : CIPHER_ID_WPA_WEP104;
break;
}
-
- hostif_mib_set_request(priv, DOT11_RSN_CONFIG_MULTICAST_CIPHER,
- CIPHER_ID_LEN, MIB_VALUE_TYPE_OSTRING,
- &wpa_suite.suite[0][0]);
+ if (buf)
+ memcpy(&wpa_suite.suite[0][0], buf, CIPHER_ID_LEN);
+ hostif_mib_set_request_ostring(priv,
+ DOT11_RSN_CONFIG_MULTICAST_CIPHER,
+ &wpa_suite.suite[0][0],
+ CIPHER_ID_LEN);
break;
case SME_RSN_AUTH_REQUEST:
- wpa_suite.size = cpu_to_le16((uint16_t)1);
+ wpa_suite.size = cpu_to_le16(1);
switch (priv->wpa.key_mgmt_suite) {
case IW_AUTH_KEY_MGMT_802_1X:
- if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
- memcpy(&wpa_suite.suite[0][0],
- KEY_MGMT_ID_WPA2_1X, KEY_MGMT_ID_LEN);
- else
- memcpy(&wpa_suite.suite[0][0],
- KEY_MGMT_ID_WPA_1X, KEY_MGMT_ID_LEN);
+ buf = (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) ?
+ KEY_MGMT_ID_WPA2_1X : KEY_MGMT_ID_WPA_1X;
break;
case IW_AUTH_KEY_MGMT_PSK:
- if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
- memcpy(&wpa_suite.suite[0][0],
- KEY_MGMT_ID_WPA2_PSK, KEY_MGMT_ID_LEN);
- else
- memcpy(&wpa_suite.suite[0][0],
- KEY_MGMT_ID_WPA_PSK, KEY_MGMT_ID_LEN);
+ buf = (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) ?
+ KEY_MGMT_ID_WPA2_PSK : KEY_MGMT_ID_WPA_PSK;
break;
case 0:
- if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
- memcpy(&wpa_suite.suite[0][0],
- KEY_MGMT_ID_WPA2_NONE, KEY_MGMT_ID_LEN);
- else
- memcpy(&wpa_suite.suite[0][0],
- KEY_MGMT_ID_WPA_NONE, KEY_MGMT_ID_LEN);
+ buf = (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) ?
+ KEY_MGMT_ID_WPA2_NONE : KEY_MGMT_ID_WPA_NONE;
break;
case 4:
- if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)
- memcpy(&wpa_suite.suite[0][0],
- KEY_MGMT_ID_WPA2_WPANONE,
- KEY_MGMT_ID_LEN);
- else
- memcpy(&wpa_suite.suite[0][0],
- KEY_MGMT_ID_WPA_WPANONE,
- KEY_MGMT_ID_LEN);
+ buf = (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) ?
+ KEY_MGMT_ID_WPA2_WPANONE :
+ KEY_MGMT_ID_WPA_WPANONE;
break;
}
- hostif_mib_set_request(priv, DOT11_RSN_CONFIG_AUTH_SUITE,
- sizeof(wpa_suite.size) +
- KEY_MGMT_ID_LEN *
- le16_to_cpu(wpa_suite.size),
- MIB_VALUE_TYPE_OSTRING, &wpa_suite);
+ if (buf)
+ memcpy(&wpa_suite.suite[0][0], buf, KEY_MGMT_ID_LEN);
+ size = sizeof(wpa_suite.size) +
+ (KEY_MGMT_ID_LEN * le16_to_cpu(wpa_suite.size));
+ hostif_mib_set_request_ostring(priv,
+ DOT11_RSN_CONFIG_AUTH_SUITE,
+ &wpa_suite, size);
break;
case SME_RSN_ENABLED_REQUEST:
- val = cpu_to_le32((uint32_t)(priv->wpa.rsn_enabled));
- hostif_mib_set_request(priv, DOT11_RSN_ENABLED,
- sizeof(val), MIB_VALUE_TYPE_BOOL, &val);
+ hostif_mib_set_request_bool(priv, DOT11_RSN_ENABLED,
+ priv->wpa.rsn_enabled);
break;
case SME_RSN_MODE_REQUEST:
- if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) {
- rsn_mode.rsn_mode =
- cpu_to_le32((uint32_t)RSN_MODE_WPA2);
- rsn_mode.rsn_capability = cpu_to_le16((uint16_t)0);
- } else if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA) {
- rsn_mode.rsn_mode =
- cpu_to_le32((uint32_t)RSN_MODE_WPA);
- rsn_mode.rsn_capability = cpu_to_le16((uint16_t)0);
- } else {
- rsn_mode.rsn_mode =
- cpu_to_le32((uint32_t)RSN_MODE_NONE);
- rsn_mode.rsn_capability = cpu_to_le16((uint16_t)0);
- }
- hostif_mib_set_request(priv, LOCAL_RSN_MODE, sizeof(rsn_mode),
- MIB_VALUE_TYPE_OSTRING, &rsn_mode);
+ mode = (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) ?
+ RSN_MODE_WPA2 :
+ (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA) ?
+ RSN_MODE_WPA : RSN_MODE_NONE;
+ rsn_mode.rsn_mode = cpu_to_le32(mode);
+ rsn_mode.rsn_capability = cpu_to_le16(0);
+ hostif_mib_set_request_ostring(priv, LOCAL_RSN_MODE,
+ &rsn_mode, sizeof(rsn_mode));
break;
}
}
@@ -1884,7 +1762,7 @@ void hostif_sme_mode_setup(struct ks_wlan_private *priv)
/* rate mask by phy setting */
if (priv->reg.phy_type == D_11B_ONLY_MODE) {
for (i = 0; i < priv->reg.rate_set.size; i++) {
- if (!IS_11B_RATE(priv->reg.rate_set.body[i]))
+ if (!is_11b_rate(priv->reg.rate_set.body[i]))
break;
if ((priv->reg.rate_set.body[i] & RATE_MASK) >= TX_RATE_5M) {
@@ -1897,10 +1775,10 @@ void hostif_sme_mode_setup(struct ks_wlan_private *priv)
} else { /* D_11G_ONLY_MODE or D_11BG_COMPATIBLE_MODE */
for (i = 0; i < priv->reg.rate_set.size; i++) {
- if (!IS_11BG_RATE(priv->reg.rate_set.body[i]))
+ if (!is_11bg_rate(priv->reg.rate_set.body[i]))
break;
- if (IS_OFDM_EXT_RATE(priv->reg.rate_set.body[i])) {
+ if (is_ofdm_ext_rate(priv->reg.rate_set.body[i])) {
rate_octet[i] = priv->reg.rate_set.body[i] &
RATE_MASK;
} else {
@@ -1923,21 +1801,20 @@ void hostif_sme_mode_setup(struct ks_wlan_private *priv)
switch (priv->reg.operation_mode) {
case MODE_PSEUDO_ADHOC:
- /* Pseudo Ad-Hoc mode */
hostif_ps_adhoc_set_request(priv);
break;
case MODE_INFRASTRUCTURE:
- /* Infrastructure mode */
if (!is_valid_ether_addr((u8 *)priv->reg.bssid)) {
- hostif_infrastructure_set_request(priv, HIF_INFRA_SET_REQ);
+ hostif_infrastructure_set_request(priv,
+ HIF_INFRA_SET_REQ);
} else {
- hostif_infrastructure_set_request(priv, HIF_INFRA_SET2_REQ);
+ hostif_infrastructure_set_request(priv,
+ HIF_INFRA_SET2_REQ);
netdev_dbg(priv->net_dev,
"Infra bssid = %pM\n", priv->reg.bssid);
}
break;
case MODE_ADHOC:
- /* IEEE802.11 Ad-Hoc mode */
if (!is_valid_ether_addr((u8 *)priv->reg.bssid)) {
hostif_adhoc_set_request(priv);
} else {
@@ -1958,7 +1835,6 @@ void hostif_sme_multicast_set(struct ks_wlan_private *priv)
int mc_count;
struct netdev_hw_addr *ha;
char set_address[NIC_MAX_MCAST_LIST * ETH_ALEN];
- __le32 filter_type;
int i = 0;
spin_lock(&priv->multicast_spin);
@@ -1966,156 +1842,117 @@ void hostif_sme_multicast_set(struct ks_wlan_private *priv)
memset(set_address, 0, NIC_MAX_MCAST_LIST * ETH_ALEN);
if (dev->flags & IFF_PROMISC) {
- filter_type = cpu_to_le32((uint32_t)MCAST_FILTER_PROMISC);
- hostif_mib_set_request(priv, LOCAL_MULTICAST_FILTER,
- sizeof(filter_type), MIB_VALUE_TYPE_BOOL,
- &filter_type);
+ hostif_mib_set_request_bool(priv, LOCAL_MULTICAST_FILTER,
+ MCAST_FILTER_PROMISC);
goto spin_unlock;
}
if ((netdev_mc_count(dev) > NIC_MAX_MCAST_LIST) ||
(dev->flags & IFF_ALLMULTI)) {
- filter_type = cpu_to_le32((uint32_t)MCAST_FILTER_MCASTALL);
- hostif_mib_set_request(priv, LOCAL_MULTICAST_FILTER,
- sizeof(filter_type), MIB_VALUE_TYPE_BOOL,
- &filter_type);
+ hostif_mib_set_request_bool(priv, LOCAL_MULTICAST_FILTER,
+ MCAST_FILTER_MCASTALL);
goto spin_unlock;
}
if (priv->sme_i.sme_flag & SME_MULTICAST) {
mc_count = netdev_mc_count(dev);
netdev_for_each_mc_addr(ha, dev) {
- memcpy(&set_address[i * ETH_ALEN], ha->addr, ETH_ALEN);
+ ether_addr_copy(&set_address[i * ETH_ALEN], ha->addr);
i++;
}
priv->sme_i.sme_flag &= ~SME_MULTICAST;
- hostif_mib_set_request(priv, LOCAL_MULTICAST_ADDRESS,
- ETH_ALEN * mc_count,
- MIB_VALUE_TYPE_OSTRING,
- &set_address[0]);
+ hostif_mib_set_request_ostring(priv, LOCAL_MULTICAST_ADDRESS,
+ &set_address[0],
+ ETH_ALEN * mc_count);
} else {
- filter_type = cpu_to_le32((uint32_t)MCAST_FILTER_MCAST);
priv->sme_i.sme_flag |= SME_MULTICAST;
- hostif_mib_set_request(priv, LOCAL_MULTICAST_FILTER,
- sizeof(filter_type), MIB_VALUE_TYPE_BOOL,
- &filter_type);
+ hostif_mib_set_request_bool(priv, LOCAL_MULTICAST_FILTER,
+ MCAST_FILTER_MCAST);
}
spin_unlock:
spin_unlock(&priv->multicast_spin);
}
-static
-void hostif_sme_power_mgmt_set(struct ks_wlan_private *priv)
+static void hostif_sme_power_mgmt_set(struct ks_wlan_private *priv)
{
- unsigned long mode, wake_up, receive_dtims;
+ u32 mode, wake_up, receive_dtims;
- switch (priv->reg.power_mgmt) {
- case POWER_MGMT_ACTIVE:
+ if (priv->reg.power_mgmt != POWER_MGMT_SAVE1 &&
+ priv->reg.power_mgmt != POWER_MGMT_SAVE2) {
mode = POWER_ACTIVE;
wake_up = 0;
receive_dtims = 0;
- break;
- case POWER_MGMT_SAVE1:
- if (priv->reg.operation_mode == MODE_INFRASTRUCTURE) {
- mode = POWER_SAVE;
- wake_up = 0;
- receive_dtims = 0;
- } else {
- mode = POWER_ACTIVE;
- wake_up = 0;
- receive_dtims = 0;
- }
- break;
- case POWER_MGMT_SAVE2:
- if (priv->reg.operation_mode == MODE_INFRASTRUCTURE) {
- mode = POWER_SAVE;
- wake_up = 0;
- receive_dtims = 1;
- } else {
- mode = POWER_ACTIVE;
- wake_up = 0;
- receive_dtims = 0;
- }
- break;
- default:
- mode = POWER_ACTIVE;
+ } else {
+ mode = (priv->reg.operation_mode == MODE_INFRASTRUCTURE) ?
+ POWER_SAVE : POWER_ACTIVE;
wake_up = 0;
- receive_dtims = 0;
- break;
+ receive_dtims = (priv->reg.operation_mode == MODE_INFRASTRUCTURE &&
+ priv->reg.power_mgmt == POWER_MGMT_SAVE2);
}
+
hostif_power_mgmt_request(priv, mode, wake_up, receive_dtims);
}
-static
-void hostif_sme_sleep_set(struct ks_wlan_private *priv)
+static void hostif_sme_sleep_set(struct ks_wlan_private *priv)
{
- switch (priv->sleep_mode) {
- case SLP_SLEEP:
- hostif_sleep_request(priv, priv->sleep_mode);
- break;
- case SLP_ACTIVE:
- hostif_sleep_request(priv, priv->sleep_mode);
- break;
- default:
- break;
- }
+ if (priv->sleep_mode != SLP_SLEEP &&
+ priv->sleep_mode != SLP_ACTIVE)
+ return;
+
+ hostif_sleep_request(priv, priv->sleep_mode);
}
static
void hostif_sme_set_key(struct ks_wlan_private *priv, int type)
{
- __le32 val;
-
switch (type) {
case SME_SET_FLAG:
- val = cpu_to_le32((uint32_t)(priv->reg.privacy_invoked));
- hostif_mib_set_request(priv, DOT11_PRIVACY_INVOKED,
- sizeof(val), MIB_VALUE_TYPE_BOOL, &val);
+ hostif_mib_set_request_bool(priv, DOT11_PRIVACY_INVOKED,
+ priv->reg.privacy_invoked);
break;
case SME_SET_TXKEY:
- val = cpu_to_le32((uint32_t)(priv->wpa.txkey));
- hostif_mib_set_request(priv, DOT11_WEP_DEFAULT_KEY_ID,
- sizeof(val), MIB_VALUE_TYPE_INT, &val);
+ hostif_mib_set_request_int(priv, DOT11_WEP_DEFAULT_KEY_ID,
+ priv->wpa.txkey);
break;
case SME_SET_KEY1:
- hostif_mib_set_request(priv, DOT11_WEP_DEFAULT_KEY_VALUE1,
- priv->wpa.key[0].key_len,
- MIB_VALUE_TYPE_OSTRING,
- &priv->wpa.key[0].key_val[0]);
+ hostif_mib_set_request_ostring(priv,
+ DOT11_WEP_DEFAULT_KEY_VALUE1,
+ &priv->wpa.key[0].key_val[0],
+ priv->wpa.key[0].key_len);
break;
case SME_SET_KEY2:
- hostif_mib_set_request(priv, DOT11_WEP_DEFAULT_KEY_VALUE2,
- priv->wpa.key[1].key_len,
- MIB_VALUE_TYPE_OSTRING,
- &priv->wpa.key[1].key_val[0]);
+ hostif_mib_set_request_ostring(priv,
+ DOT11_WEP_DEFAULT_KEY_VALUE2,
+ &priv->wpa.key[1].key_val[0],
+ priv->wpa.key[1].key_len);
break;
case SME_SET_KEY3:
- hostif_mib_set_request(priv, DOT11_WEP_DEFAULT_KEY_VALUE3,
- priv->wpa.key[2].key_len,
- MIB_VALUE_TYPE_OSTRING,
- &priv->wpa.key[2].key_val[0]);
+ hostif_mib_set_request_ostring(priv,
+ DOT11_WEP_DEFAULT_KEY_VALUE3,
+ &priv->wpa.key[2].key_val[0],
+ priv->wpa.key[2].key_len);
break;
case SME_SET_KEY4:
- hostif_mib_set_request(priv, DOT11_WEP_DEFAULT_KEY_VALUE4,
- priv->wpa.key[3].key_len,
- MIB_VALUE_TYPE_OSTRING,
- &priv->wpa.key[3].key_val[0]);
+ hostif_mib_set_request_ostring(priv,
+ DOT11_WEP_DEFAULT_KEY_VALUE4,
+ &priv->wpa.key[3].key_val[0],
+ priv->wpa.key[3].key_len);
break;
case SME_SET_PMK_TSC:
- hostif_mib_set_request(priv, DOT11_PMK_TSC,
- WPA_RX_SEQ_LEN, MIB_VALUE_TYPE_OSTRING,
- &priv->wpa.key[0].rx_seq[0]);
+ hostif_mib_set_request_ostring(priv, DOT11_PMK_TSC,
+ &priv->wpa.key[0].rx_seq[0],
+ WPA_RX_SEQ_LEN);
break;
case SME_SET_GMK1_TSC:
- hostif_mib_set_request(priv, DOT11_GMK1_TSC,
- WPA_RX_SEQ_LEN, MIB_VALUE_TYPE_OSTRING,
- &priv->wpa.key[1].rx_seq[0]);
+ hostif_mib_set_request_ostring(priv, DOT11_GMK1_TSC,
+ &priv->wpa.key[1].rx_seq[0],
+ WPA_RX_SEQ_LEN);
break;
case SME_SET_GMK2_TSC:
- hostif_mib_set_request(priv, DOT11_GMK2_TSC,
- WPA_RX_SEQ_LEN, MIB_VALUE_TYPE_OSTRING,
- &priv->wpa.key[2].rx_seq[0]);
+ hostif_mib_set_request_ostring(priv, DOT11_GMK2_TSC,
+ &priv->wpa.key[2].rx_seq[0],
+ WPA_RX_SEQ_LEN);
break;
}
}
@@ -2123,38 +1960,34 @@ void hostif_sme_set_key(struct ks_wlan_private *priv, int type)
static
void hostif_sme_set_pmksa(struct ks_wlan_private *priv)
{
- struct pmk_cache_t {
+ struct pmk_cache {
__le16 size;
struct {
u8 bssid[ETH_ALEN];
u8 pmkid[IW_PMKID_LEN];
} __packed list[PMK_LIST_MAX];
} __packed pmkcache;
- struct pmk_t *pmk;
- int i;
+ struct pmk *pmk;
+ size_t size;
+ int i = 0;
- i = 0;
list_for_each_entry(pmk, &priv->pmklist.head, list) {
- if (i < PMK_LIST_MAX) {
- memcpy(pmkcache.list[i].bssid, pmk->bssid, ETH_ALEN);
- memcpy(pmkcache.list[i].pmkid, pmk->pmkid,
- IW_PMKID_LEN);
- i++;
- }
+ if (i >= PMK_LIST_MAX)
+ break;
+ ether_addr_copy(pmkcache.list[i].bssid, pmk->bssid);
+ memcpy(pmkcache.list[i].pmkid, pmk->pmkid, IW_PMKID_LEN);
+ i++;
}
- pmkcache.size = cpu_to_le16((uint16_t)(priv->pmklist.size));
- hostif_mib_set_request(priv, LOCAL_PMK,
- sizeof(priv->pmklist.size) + (ETH_ALEN +
- IW_PMKID_LEN) *
- (priv->pmklist.size), MIB_VALUE_TYPE_OSTRING,
- &pmkcache);
+ pmkcache.size = cpu_to_le16(priv->pmklist.size);
+ size = sizeof(priv->pmklist.size) +
+ ((ETH_ALEN + IW_PMKID_LEN) * priv->pmklist.size);
+ hostif_mib_set_request_ostring(priv, LOCAL_PMK, &pmkcache, size);
}
/* execute sme */
-static
-void hostif_sme_execute(struct ks_wlan_private *priv, int event)
+static void hostif_sme_execute(struct ks_wlan_private *priv, int event)
{
- __le32 val;
+ u16 failure;
switch (event) {
case SME_START:
@@ -2165,9 +1998,8 @@ void hostif_sme_execute(struct ks_wlan_private *priv, int event)
hostif_sme_multicast_set(priv);
break;
case SME_MACADDRESS_SET_REQUEST:
- hostif_mib_set_request(priv, LOCAL_CURRENTADDRESS, ETH_ALEN,
- MIB_VALUE_TYPE_OSTRING,
- &priv->eth_addr[0]);
+ hostif_mib_set_request_ostring(priv, LOCAL_CURRENTADDRESS,
+ &priv->eth_addr[0], ETH_ALEN);
break;
case SME_BSS_SCAN_REQUEST:
hostif_bss_scan_request(priv, priv->reg.scan_type,
@@ -2180,18 +2012,15 @@ void hostif_sme_execute(struct ks_wlan_private *priv, int event)
hostif_phy_information_request(priv);
break;
case SME_MIC_FAILURE_REQUEST:
- if (priv->wpa.mic_failure.failure == 1) {
- hostif_mic_failure_request(priv,
- priv->wpa.mic_failure.failure - 1,
- 0);
- } else if (priv->wpa.mic_failure.failure == 2) {
- hostif_mic_failure_request(priv,
- priv->wpa.mic_failure.failure - 1,
- priv->wpa.mic_failure.counter);
- } else {
- netdev_err(priv->net_dev, "SME_MIC_FAILURE_REQUEST: failure count=%u error?\n",
- priv->wpa.mic_failure.failure);
+ failure = priv->wpa.mic_failure.failure;
+ if (failure != 1 && failure != 2) {
+ netdev_err(priv->net_dev,
+ "SME_MIC_FAILURE_REQUEST: failure count=%u error?\n",
+ failure);
+ return;
}
+ hostif_mic_failure_request(priv, failure - 1, (failure == 1) ?
+ 0 : priv->wpa.mic_failure.counter);
break;
case SME_MIC_FAILURE_CONFIRM:
if (priv->wpa.mic_failure.failure == 2) {
@@ -2213,14 +2042,12 @@ void hostif_sme_execute(struct ks_wlan_private *priv, int event)
hostif_stop_request(priv);
break;
case SME_RTS_THRESHOLD_REQUEST:
- val = cpu_to_le32((uint32_t)(priv->reg.rts));
- hostif_mib_set_request(priv, DOT11_RTS_THRESHOLD,
- sizeof(val), MIB_VALUE_TYPE_INT, &val);
+ hostif_mib_set_request_int(priv, DOT11_RTS_THRESHOLD,
+ priv->reg.rts);
break;
case SME_FRAGMENTATION_THRESHOLD_REQUEST:
- val = cpu_to_le32((uint32_t)(priv->reg.fragment));
- hostif_mib_set_request(priv, DOT11_FRAGMENTATION_THRESHOLD,
- sizeof(val), MIB_VALUE_TYPE_INT, &val);
+ hostif_mib_set_request_int(priv, DOT11_FRAGMENTATION_THRESHOLD,
+ priv->reg.fragment);
break;
case SME_WEP_INDEX_REQUEST:
case SME_WEP_KEY1_REQUEST:
@@ -2251,26 +2078,20 @@ void hostif_sme_execute(struct ks_wlan_private *priv, int event)
case SME_SET_PMKSA:
hostif_sme_set_pmksa(priv);
break;
-#ifdef WPS
case SME_WPS_ENABLE_REQUEST:
- hostif_mib_set_request(priv, LOCAL_WPS_ENABLE,
- sizeof(priv->wps.wps_enabled),
- MIB_VALUE_TYPE_INT,
- &priv->wps.wps_enabled);
+ hostif_mib_set_request_int(priv, LOCAL_WPS_ENABLE,
+ priv->wps.wps_enabled);
break;
case SME_WPS_PROBE_REQUEST:
- hostif_mib_set_request(priv, LOCAL_WPS_PROBE_REQ,
- priv->wps.ielen,
- MIB_VALUE_TYPE_OSTRING, priv->wps.ie);
+ hostif_mib_set_request_ostring(priv, LOCAL_WPS_PROBE_REQ,
+ priv->wps.ie, priv->wps.ielen);
break;
-#endif /* WPS */
case SME_MODE_SET_REQUEST:
hostif_sme_mode_setup(priv);
break;
case SME_SET_GAIN:
- hostif_mib_set_request(priv, LOCAL_GAIN,
- sizeof(priv->gain),
- MIB_VALUE_TYPE_OSTRING, &priv->gain);
+ hostif_mib_set_request_ostring(priv, LOCAL_GAIN,
+ &priv->gain, sizeof(priv->gain));
break;
case SME_GET_GAIN:
hostif_mib_get_request(priv, LOCAL_GAIN);
@@ -2295,9 +2116,7 @@ void hostif_sme_execute(struct ks_wlan_private *priv, int event)
hostif_sme_sleep_set(priv);
break;
case SME_SET_REGION:
- val = cpu_to_le32((uint32_t)(priv->region));
- hostif_mib_set_request(priv, LOCAL_REGION,
- sizeof(val), MIB_VALUE_TYPE_INT, &val);
+ hostif_mib_set_request_int(priv, LOCAL_REGION, priv->region);
break;
case SME_MULTICAST_CONFIRM:
case SME_BSS_SCAN_CONFIRM:
@@ -2318,7 +2137,6 @@ void hostif_sme_execute(struct ks_wlan_private *priv, int event)
case SME_RSN_ENABLED_CONFIRM:
case SME_RSN_MODE_CONFIRM:
case SME_MODE_SET_CONFIRM:
- break;
case SME_TERMINATE:
default:
break;
@@ -2343,7 +2161,7 @@ void hostif_sme_task(unsigned long dev)
}
/* send to Station Management Entity module */
-void hostif_sme_enqueue(struct ks_wlan_private *priv, unsigned short event)
+void hostif_sme_enqueue(struct ks_wlan_private *priv, u16 event)
{
/* enqueue sme event */
if (cnt_smeqbody(priv) < (SME_EVENT_BUFF_SIZE - 1)) {
@@ -2359,7 +2177,8 @@ void hostif_sme_enqueue(struct ks_wlan_private *priv, unsigned short event)
static inline void hostif_aplist_init(struct ks_wlan_private *priv)
{
- size_t size = LOCAL_APLIST_MAX * sizeof(struct local_ap_t);
+ size_t size = LOCAL_APLIST_MAX * sizeof(struct local_ap);
+
priv->aplist.size = 0;
memset(&priv->aplist.ap[0], 0, size);
}
@@ -2384,7 +2203,7 @@ static inline void hostif_sme_init(struct ks_wlan_private *priv)
static inline void hostif_wpa_init(struct ks_wlan_private *priv)
{
memset(&priv->wpa, 0, sizeof(priv->wpa));
- priv->wpa.rsn_enabled = 0;
+ priv->wpa.rsn_enabled = false;
priv->wpa.mic_failure.failure = 0;
priv->wpa.mic_failure.last_failure_time = 0;
priv->wpa.mic_failure.stop = 0;