2009-06-13 11:38:31 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*
|
|
|
|
* File: main_usb.c
|
|
|
|
*
|
|
|
|
* Purpose: driver entry for initial, open, close, tx and rx.
|
|
|
|
*
|
|
|
|
* Author: Lyndon Chen
|
|
|
|
*
|
|
|
|
* Date: Dec 8, 2005
|
|
|
|
*
|
|
|
|
* Functions:
|
|
|
|
*
|
2010-04-13 22:43:07 +00:00
|
|
|
* vt6656_probe - module initial (insmod) driver entry
|
2009-06-13 11:38:31 +00:00
|
|
|
* device_remove1 - module remove entry
|
|
|
|
* device_open - allocate dma/descripter resource & initial mac/bbp function
|
2012-08-26 15:16:43 +00:00
|
|
|
* device_xmit - asynchronous data tx function
|
2009-06-13 11:38:31 +00:00
|
|
|
* device_set_multi - set mac filter
|
|
|
|
* device_ioctl - ioctl entry
|
2012-08-26 15:16:43 +00:00
|
|
|
* device_close - shutdown mac/bbp & free dma/descriptor resource
|
2009-06-13 11:38:31 +00:00
|
|
|
* device_alloc_frag_buf - rx fragement pre-allocated function
|
|
|
|
* device_free_tx_bufs - free tx buffer function
|
|
|
|
* device_dma0_tx_80211- tx 802.11 frame via dma0
|
2012-08-26 15:16:43 +00:00
|
|
|
* device_dma0_xmit- tx PS buffered frame via dma0
|
2009-06-13 11:38:31 +00:00
|
|
|
* device_init_registers- initial MAC & BBP & RF internal registers.
|
|
|
|
* device_init_rings- initial tx/rx ring buffer
|
|
|
|
* device_init_defrag_cb- initial & allocate de-fragement buffer.
|
|
|
|
* device_tx_srv- tx interrupt service function
|
|
|
|
*
|
|
|
|
* Revision History:
|
|
|
|
*/
|
|
|
|
#undef __NO_VERSION__
|
|
|
|
|
2013-04-06 22:00:07 +00:00
|
|
|
#include <linux/file.h>
|
2009-06-13 11:38:31 +00:00
|
|
|
#include "device.h"
|
|
|
|
#include "card.h"
|
|
|
|
#include "baseband.h"
|
|
|
|
#include "mac.h"
|
|
|
|
#include "tether.h"
|
|
|
|
#include "wmgr.h"
|
|
|
|
#include "wctl.h"
|
|
|
|
#include "power.h"
|
|
|
|
#include "wcmd.h"
|
|
|
|
#include "iocmd.h"
|
|
|
|
#include "rxtx.h"
|
|
|
|
#include "bssdb.h"
|
|
|
|
#include "wpactl.h"
|
|
|
|
#include "iwctl.h"
|
|
|
|
#include "dpc.h"
|
|
|
|
#include "datarate.h"
|
|
|
|
#include "rf.h"
|
|
|
|
#include "firmware.h"
|
2014-05-26 12:59:07 +00:00
|
|
|
#include "usbpipe.h"
|
2009-06-13 11:38:31 +00:00
|
|
|
#include "channel.h"
|
|
|
|
#include "int.h"
|
|
|
|
#include "iowpa.h"
|
|
|
|
|
2013-01-31 23:23:07 +00:00
|
|
|
/* static int msglevel = MSG_LEVEL_DEBUG; */
|
2009-06-13 11:38:31 +00:00
|
|
|
static int msglevel =MSG_LEVEL_INFO;
|
|
|
|
|
2013-01-31 23:23:07 +00:00
|
|
|
/*
|
|
|
|
* define module options
|
|
|
|
*/
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2013-01-31 23:23:07 +00:00
|
|
|
/* version information */
|
|
|
|
#define DRIVER_AUTHOR \
|
|
|
|
"VIA Networking Technologies, Inc., <lyndonchen@vntek.com.tw>"
|
2009-06-13 11:38:31 +00:00
|
|
|
MODULE_AUTHOR(DRIVER_AUTHOR);
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
MODULE_DESCRIPTION(DEVICE_FULL_DRV_NAM);
|
|
|
|
|
|
|
|
#define DEVICE_PARAM(N,D) \
|
|
|
|
static int N[MAX_UINTS]=OPTION_DEFAULT;\
|
|
|
|
module_param_array(N, int, NULL, 0);\
|
|
|
|
MODULE_PARM_DESC(N, D);
|
|
|
|
|
|
|
|
#define RX_DESC_DEF0 64
|
|
|
|
DEVICE_PARAM(RxDescriptors0,"Number of receive usb desc buffer");
|
|
|
|
|
|
|
|
#define TX_DESC_DEF0 64
|
|
|
|
DEVICE_PARAM(TxDescriptors0,"Number of transmit usb desc buffer");
|
|
|
|
|
|
|
|
#define CHANNEL_DEF 6
|
|
|
|
DEVICE_PARAM(Channel, "Channel number");
|
|
|
|
|
|
|
|
/* PreambleType[] is the preamble length used for transmit.
|
|
|
|
0: indicate allows long preamble type
|
|
|
|
1: indicate allows short preamble type
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define PREAMBLE_TYPE_DEF 1
|
|
|
|
|
|
|
|
DEVICE_PARAM(PreambleType, "Preamble Type");
|
|
|
|
|
|
|
|
#define RTS_THRESH_DEF 2347
|
|
|
|
DEVICE_PARAM(RTSThreshold, "RTS threshold");
|
|
|
|
|
|
|
|
#define FRAG_THRESH_DEF 2346
|
|
|
|
DEVICE_PARAM(FragThreshold, "Fragmentation threshold");
|
|
|
|
|
|
|
|
#define DATA_RATE_DEF 13
|
|
|
|
/* datarate[] index
|
|
|
|
0: indicate 1 Mbps 0x02
|
|
|
|
1: indicate 2 Mbps 0x04
|
|
|
|
2: indicate 5.5 Mbps 0x0B
|
|
|
|
3: indicate 11 Mbps 0x16
|
|
|
|
4: indicate 6 Mbps 0x0c
|
|
|
|
5: indicate 9 Mbps 0x12
|
|
|
|
6: indicate 12 Mbps 0x18
|
|
|
|
7: indicate 18 Mbps 0x24
|
|
|
|
8: indicate 24 Mbps 0x30
|
|
|
|
9: indicate 36 Mbps 0x48
|
|
|
|
10: indicate 48 Mbps 0x60
|
|
|
|
11: indicate 54 Mbps 0x6c
|
|
|
|
12: indicate 72 Mbps 0x90
|
|
|
|
13: indicate auto rate
|
|
|
|
*/
|
|
|
|
|
|
|
|
DEVICE_PARAM(ConnectionRate, "Connection data rate");
|
|
|
|
|
|
|
|
#define OP_MODE_DEF 0
|
|
|
|
DEVICE_PARAM(OPMode, "Infrastruct, adhoc, AP mode ");
|
|
|
|
|
|
|
|
/* OpMode[] is used for transmit.
|
|
|
|
0: indicate infrastruct mode used
|
|
|
|
1: indicate adhoc mode used
|
|
|
|
2: indicate AP mode used
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* PSMode[]
|
|
|
|
0: indicate disable power saving mode
|
|
|
|
1: indicate enable power saving mode
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define PS_MODE_DEF 0
|
|
|
|
DEVICE_PARAM(PSMode, "Power saving mode");
|
|
|
|
|
|
|
|
#define SHORT_RETRY_DEF 8
|
|
|
|
DEVICE_PARAM(ShortRetryLimit, "Short frame retry limits");
|
|
|
|
|
|
|
|
#define LONG_RETRY_DEF 4
|
|
|
|
DEVICE_PARAM(LongRetryLimit, "long frame retry limits");
|
|
|
|
|
|
|
|
/* BasebandType[] baseband type selected
|
|
|
|
0: indicate 802.11a type
|
|
|
|
1: indicate 802.11b type
|
|
|
|
2: indicate 802.11g type
|
|
|
|
*/
|
|
|
|
|
2012-07-03 02:59:30 +00:00
|
|
|
#define BBP_TYPE_DEF 2
|
2009-06-13 11:38:31 +00:00
|
|
|
DEVICE_PARAM(BasebandType, "baseband type");
|
|
|
|
|
|
|
|
/* 80211hEnable[]
|
|
|
|
0: indicate disable 802.11h
|
|
|
|
1: indicate enable 802.11h
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define X80211h_MODE_DEF 0
|
|
|
|
|
|
|
|
DEVICE_PARAM(b80211hEnable, "802.11h mode");
|
|
|
|
|
2013-01-31 23:23:07 +00:00
|
|
|
/*
|
|
|
|
* Static vars definitions
|
|
|
|
*/
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2012-08-18 00:48:33 +00:00
|
|
|
static struct usb_device_id vt6656_table[] = {
|
2009-06-13 11:38:31 +00:00
|
|
|
{USB_DEVICE(VNT_USB_VENDOR_ID, VNT_USB_PRODUCT_ID)},
|
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
2013-01-31 23:23:07 +00:00
|
|
|
/* frequency list (map channels to frequencies) */
|
2009-06-13 11:38:31 +00:00
|
|
|
/*
|
|
|
|
static const long frequency_list[] = {
|
|
|
|
2412, 2417, 2422, 2427, 2432, 2437, 2442, 2447, 2452, 2457, 2462, 2467, 2472, 2484,
|
|
|
|
4915, 4920, 4925, 4935, 4940, 4945, 4960, 4980,
|
|
|
|
5035, 5040, 5045, 5055, 5060, 5080, 5170, 5180, 5190, 5200, 5210, 5220, 5230, 5240,
|
|
|
|
5260, 5280, 5300, 5320, 5500, 5520, 5540, 5560, 5580, 5600, 5620, 5640, 5660, 5680,
|
|
|
|
5700, 5745, 5765, 5785, 5805, 5825
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct iw_handler_def iwctl_handler_def;
|
|
|
|
*/
|
|
|
|
|
2010-04-13 22:43:07 +00:00
|
|
|
static int vt6656_probe(struct usb_interface *intf,
|
|
|
|
const struct usb_device_id *id);
|
|
|
|
static void vt6656_disconnect(struct usb_interface *intf);
|
2009-06-13 11:38:31 +00:00
|
|
|
|
|
|
|
#ifdef CONFIG_PM /* Minimal support for suspend and resume */
|
2010-04-13 22:43:07 +00:00
|
|
|
static int vt6656_suspend(struct usb_interface *intf, pm_message_t message);
|
|
|
|
static int vt6656_resume(struct usb_interface *intf);
|
|
|
|
#endif /* CONFIG_PM */
|
|
|
|
|
2009-06-13 11:38:31 +00:00
|
|
|
static struct net_device_stats *device_get_stats(struct net_device *dev);
|
|
|
|
static int device_open(struct net_device *dev);
|
|
|
|
static int device_xmit(struct sk_buff *skb, struct net_device *dev);
|
|
|
|
static void device_set_multi(struct net_device *dev);
|
|
|
|
static int device_close(struct net_device *dev);
|
|
|
|
static int device_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
|
|
|
|
|
2013-11-03 17:40:51 +00:00
|
|
|
static int device_init_registers(struct vnt_private *pDevice);
|
2013-02-13 01:36:28 +00:00
|
|
|
static bool device_init_defrag_cb(struct vnt_private *pDevice);
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2014-01-13 16:21:09 +00:00
|
|
|
static int ethtool_ioctl(struct net_device *dev, struct ifreq *);
|
2012-12-10 21:59:10 +00:00
|
|
|
static void device_free_tx_bufs(struct vnt_private *pDevice);
|
|
|
|
static void device_free_rx_bufs(struct vnt_private *pDevice);
|
|
|
|
static void device_free_int_bufs(struct vnt_private *pDevice);
|
|
|
|
static void device_free_frag_bufs(struct vnt_private *pDevice);
|
2013-02-13 01:36:28 +00:00
|
|
|
static bool device_alloc_bufs(struct vnt_private *pDevice);
|
2012-12-10 21:59:10 +00:00
|
|
|
|
|
|
|
static int Read_config_file(struct vnt_private *pDevice);
|
|
|
|
static unsigned char *Config_FileOperation(struct vnt_private *pDevice);
|
2010-05-18 00:34:01 +00:00
|
|
|
static int Config_FileGetParameter(unsigned char *string,
|
|
|
|
unsigned char *dest,
|
|
|
|
unsigned char *source);
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2012-12-10 21:59:10 +00:00
|
|
|
static void usb_device_reset(struct vnt_private *pDevice);
|
2009-06-13 11:38:31 +00:00
|
|
|
|
|
|
|
static void
|
2012-12-10 21:59:10 +00:00
|
|
|
device_set_options(struct vnt_private *pDevice) {
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2013-02-26 01:32:51 +00:00
|
|
|
u8 abyBroadcastAddr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
|
|
|
|
u8 abySNAP_RFC1042[ETH_ALEN] = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0x00};
|
2010-04-14 00:54:48 +00:00
|
|
|
u8 abySNAP_Bridgetunnel[ETH_ALEN] = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0xF8};
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2010-04-14 00:54:48 +00:00
|
|
|
memcpy(pDevice->abyBroadcastAddr, abyBroadcastAddr, ETH_ALEN);
|
|
|
|
memcpy(pDevice->abySNAP_RFC1042, abySNAP_RFC1042, ETH_ALEN);
|
|
|
|
memcpy(pDevice->abySNAP_Bridgetunnel, abySNAP_Bridgetunnel, ETH_ALEN);
|
2009-06-13 11:38:31 +00:00
|
|
|
|
|
|
|
pDevice->cbTD = TX_DESC_DEF0;
|
|
|
|
pDevice->cbRD = RX_DESC_DEF0;
|
|
|
|
pDevice->uChannel = CHANNEL_DEF;
|
|
|
|
pDevice->wRTSThreshold = RTS_THRESH_DEF;
|
|
|
|
pDevice->wFragmentationThreshold = FRAG_THRESH_DEF;
|
|
|
|
pDevice->byShortRetryLimit = SHORT_RETRY_DEF;
|
|
|
|
pDevice->byLongRetryLimit = LONG_RETRY_DEF;
|
|
|
|
pDevice->wMaxTransmitMSDULifetime = DEFAULT_MSDU_LIFETIME;
|
|
|
|
pDevice->byShortPreamble = PREAMBLE_TYPE_DEF;
|
|
|
|
pDevice->ePSMode = PS_MODE_DEF;
|
|
|
|
pDevice->b11hEnable = X80211h_MODE_DEF;
|
2014-02-15 21:56:20 +00:00
|
|
|
pDevice->op_mode = NL80211_IFTYPE_UNSPECIFIED;
|
2009-06-13 11:38:31 +00:00
|
|
|
pDevice->uConnectionRate = DATA_RATE_DEF;
|
2013-02-13 01:36:30 +00:00
|
|
|
if (pDevice->uConnectionRate < RATE_AUTO) pDevice->bFixRate = true;
|
2009-06-13 11:38:31 +00:00
|
|
|
pDevice->byBBType = BBP_TYPE_DEF;
|
|
|
|
pDevice->byPacketType = pDevice->byBBType;
|
|
|
|
pDevice->byAutoFBCtrl = AUTO_FB_0;
|
|
|
|
pDevice->byPreambleType = 0;
|
2013-02-13 01:36:29 +00:00
|
|
|
pDevice->bExistSWNetAddr = false;
|
2009-06-13 11:38:31 +00:00
|
|
|
}
|
|
|
|
|
2013-01-31 23:23:07 +00:00
|
|
|
/*
|
|
|
|
* initialization of MAC & BBP registers
|
|
|
|
*/
|
2013-11-03 17:40:51 +00:00
|
|
|
static int device_init_registers(struct vnt_private *pDevice)
|
2009-06-13 11:38:31 +00:00
|
|
|
{
|
2012-12-10 21:59:10 +00:00
|
|
|
struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
|
2013-11-03 17:49:32 +00:00
|
|
|
struct vnt_cmd_card_init *init_cmd = &pDevice->init_command;
|
|
|
|
struct vnt_rsp_card_init *init_rsp = &pDevice->init_response;
|
2012-12-10 21:59:10 +00:00
|
|
|
u8 abyBroadcastAddr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
|
|
|
|
u8 abySNAP_RFC1042[ETH_ALEN] = {0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00};
|
|
|
|
u8 abySNAP_Bridgetunnel[ETH_ALEN]
|
|
|
|
= {0xaa, 0xaa, 0x03, 0x00, 0x00, 0xf8};
|
|
|
|
u8 byAntenna;
|
|
|
|
int ii;
|
|
|
|
int ntStatus = STATUS_SUCCESS;
|
|
|
|
u8 byTmp;
|
|
|
|
u8 byCalibTXIQ = 0, byCalibTXDC = 0, byCalibRXIQ = 0;
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2013-11-03 17:40:51 +00:00
|
|
|
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "---->INIbInitAdapter. [%d][%d]\n",
|
|
|
|
DEVICE_INIT_COLD, pDevice->byPacketType);
|
|
|
|
|
|
|
|
memcpy(pDevice->abyBroadcastAddr, abyBroadcastAddr, ETH_ALEN);
|
|
|
|
memcpy(pDevice->abySNAP_RFC1042, abySNAP_RFC1042, ETH_ALEN);
|
2013-11-03 17:52:15 +00:00
|
|
|
memcpy(pDevice->abySNAP_Bridgetunnel, abySNAP_Bridgetunnel, ETH_ALEN);
|
|
|
|
|
2014-06-04 17:25:33 +00:00
|
|
|
if (!vnt_check_firmware_version(pDevice)) {
|
2014-06-04 17:25:31 +00:00
|
|
|
if (vnt_download_firmware(pDevice) == true) {
|
2014-06-04 17:25:32 +00:00
|
|
|
if (vnt_firmware_branch_to_sram(pDevice) == false) {
|
2013-11-03 17:52:15 +00:00
|
|
|
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO
|
2014-06-04 17:25:32 +00:00
|
|
|
" vnt_firmware_branch_to_sram fail\n");
|
2013-11-03 17:52:15 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO
|
|
|
|
" FIRMWAREbDownload fail\n");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!BBbVT3184Init(pDevice)) {
|
|
|
|
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" BBbVT3184Init fail\n");
|
|
|
|
return false;
|
|
|
|
}
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2013-11-03 17:49:32 +00:00
|
|
|
init_cmd->init_class = DEVICE_INIT_COLD;
|
|
|
|
init_cmd->exist_sw_net_addr = (u8) pDevice->bExistSWNetAddr;
|
2013-11-03 17:43:23 +00:00
|
|
|
for (ii = 0; ii < 6; ii++)
|
2013-11-03 17:49:32 +00:00
|
|
|
init_cmd->sw_net_addr[ii] = pDevice->abyCurrentNetAddr[ii];
|
|
|
|
init_cmd->short_retry_limit = pDevice->byShortRetryLimit;
|
|
|
|
init_cmd->long_retry_limit = pDevice->byLongRetryLimit;
|
2013-11-03 17:43:23 +00:00
|
|
|
|
|
|
|
/* issue card_init command to device */
|
2014-05-26 12:59:01 +00:00
|
|
|
ntStatus = vnt_control_out(pDevice,
|
2013-11-03 17:43:23 +00:00
|
|
|
MESSAGE_TYPE_CARDINIT, 0, 0,
|
2013-11-03 17:49:32 +00:00
|
|
|
sizeof(struct vnt_cmd_card_init), (u8 *)init_cmd);
|
2013-11-03 17:52:15 +00:00
|
|
|
if (ntStatus != STATUS_SUCCESS) {
|
|
|
|
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" Issue Card init fail\n");
|
|
|
|
return false;
|
|
|
|
}
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2014-05-26 12:59:02 +00:00
|
|
|
ntStatus = vnt_control_in(pDevice, MESSAGE_TYPE_INIT_RSP, 0, 0,
|
2013-11-03 17:49:32 +00:00
|
|
|
sizeof(struct vnt_rsp_card_init), (u8 *)init_rsp);
|
2013-11-03 17:40:51 +00:00
|
|
|
if (ntStatus != STATUS_SUCCESS) {
|
|
|
|
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO
|
|
|
|
"Cardinit request in status fail!\n");
|
|
|
|
return false;
|
|
|
|
}
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2013-01-31 23:23:07 +00:00
|
|
|
/* local ID for AES functions */
|
2014-05-26 12:59:02 +00:00
|
|
|
ntStatus = vnt_control_in(pDevice, MESSAGE_TYPE_READ,
|
2013-11-03 17:40:51 +00:00
|
|
|
MAC_REG_LOCALID, MESSAGE_REQUEST_MACREG, 1,
|
|
|
|
&pDevice->byLocalID);
|
2014-05-15 21:49:12 +00:00
|
|
|
if (ntStatus != STATUS_SUCCESS)
|
2013-11-03 17:40:51 +00:00
|
|
|
return false;
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2013-01-31 23:23:07 +00:00
|
|
|
/* do MACbSoftwareReset in MACvInitialize */
|
|
|
|
|
2013-02-13 01:36:29 +00:00
|
|
|
pDevice->bProtectMode = false;
|
2013-01-31 23:23:07 +00:00
|
|
|
/* only used in 11g type, sync with ERP IE */
|
2013-11-03 17:40:51 +00:00
|
|
|
pDevice->bNonERPPresent = false;
|
|
|
|
pDevice->bBarkerPreambleMd = false;
|
|
|
|
if (pDevice->bFixRate) {
|
|
|
|
pDevice->wCurrentRate = (u16)pDevice->uConnectionRate;
|
|
|
|
} else {
|
|
|
|
if (pDevice->byBBType == BB_TYPE_11B)
|
|
|
|
pDevice->wCurrentRate = RATE_11M;
|
|
|
|
else
|
|
|
|
pDevice->wCurrentRate = RATE_54M;
|
|
|
|
}
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2013-11-03 17:40:51 +00:00
|
|
|
CHvInitChannelTable(pDevice);
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2013-11-03 17:40:51 +00:00
|
|
|
pDevice->byTopOFDMBasicRate = RATE_24M;
|
|
|
|
pDevice->byTopCCKBasicRate = RATE_1M;
|
2014-05-17 08:50:31 +00:00
|
|
|
|
2013-01-31 23:23:07 +00:00
|
|
|
/* target to IF pin while programming to RF chip */
|
2013-11-03 17:40:51 +00:00
|
|
|
pDevice->byCurPwr = 0xFF;
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2013-11-03 17:40:51 +00:00
|
|
|
pDevice->byCCKPwr = pDevice->abyEEPROM[EEP_OFS_PWR_CCK];
|
|
|
|
pDevice->byOFDMPwrG = pDevice->abyEEPROM[EEP_OFS_PWR_OFDMG];
|
2013-01-31 23:23:07 +00:00
|
|
|
/* load power table */
|
|
|
|
for (ii = 0; ii < 14; ii++) {
|
2013-11-03 17:40:51 +00:00
|
|
|
pDevice->abyCCKPwrTbl[ii] =
|
|
|
|
pDevice->abyEEPROM[ii + EEP_OFS_CCK_PWR_TBL];
|
|
|
|
|
|
|
|
if (pDevice->abyCCKPwrTbl[ii] == 0)
|
|
|
|
pDevice->abyCCKPwrTbl[ii] = pDevice->byCCKPwr;
|
2014-02-07 18:10:34 +00:00
|
|
|
pDevice->abyOFDMPwrTbl[ii] =
|
2013-11-03 17:40:51 +00:00
|
|
|
pDevice->abyEEPROM[ii + EEP_OFS_OFDM_PWR_TBL];
|
|
|
|
if (pDevice->abyOFDMPwrTbl[ii] == 0)
|
|
|
|
pDevice->abyOFDMPwrTbl[ii] = pDevice->byOFDMPwrG;
|
|
|
|
}
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2013-01-31 23:23:07 +00:00
|
|
|
/*
|
|
|
|
* original zonetype is USA, but custom zonetype is Europe,
|
|
|
|
* then need to recover 12, 13, 14 channels with 11 channel
|
|
|
|
*/
|
2013-11-03 17:40:51 +00:00
|
|
|
if (((pDevice->abyEEPROM[EEP_OFS_ZONETYPE] == ZoneType_Japan) ||
|
|
|
|
(pDevice->abyEEPROM[EEP_OFS_ZONETYPE] == ZoneType_Europe)) &&
|
|
|
|
(pDevice->byOriginalZonetype == ZoneType_USA)) {
|
2010-05-20 02:50:00 +00:00
|
|
|
for (ii = 11; ii < 14; ii++) {
|
|
|
|
pDevice->abyCCKPwrTbl[ii] = pDevice->abyCCKPwrTbl[10];
|
|
|
|
pDevice->abyOFDMPwrTbl[ii] = pDevice->abyOFDMPwrTbl[10];
|
|
|
|
}
|
2013-11-03 17:40:51 +00:00
|
|
|
}
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2013-11-03 17:40:51 +00:00
|
|
|
pDevice->byOFDMPwrA = 0x34; /* same as RFbMA2829SelectChannel */
|
2013-01-31 23:23:07 +00:00
|
|
|
|
2013-11-03 17:40:51 +00:00
|
|
|
/* load OFDM A power table */
|
|
|
|
for (ii = 0; ii < CB_MAX_CHANNEL_5G; ii++) {
|
|
|
|
pDevice->abyOFDMAPwrTbl[ii] =
|
|
|
|
pDevice->abyEEPROM[ii + EEP_OFS_OFDMA_PWR_TBL];
|
|
|
|
|
|
|
|
if (pDevice->abyOFDMAPwrTbl[ii] == 0)
|
|
|
|
pDevice->abyOFDMAPwrTbl[ii] = pDevice->byOFDMPwrA;
|
|
|
|
}
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2013-11-03 17:40:51 +00:00
|
|
|
byAntenna = pDevice->abyEEPROM[EEP_OFS_ANTENNA];
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2013-11-03 17:40:51 +00:00
|
|
|
if (byAntenna & EEP_ANTINV)
|
|
|
|
pDevice->bTxRxAntInv = true;
|
|
|
|
else
|
|
|
|
pDevice->bTxRxAntInv = false;
|
|
|
|
|
|
|
|
byAntenna &= (EEP_ANTENNA_AUX | EEP_ANTENNA_MAIN);
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2013-01-31 23:23:07 +00:00
|
|
|
if (byAntenna == 0) /* if not set default is both */
|
2013-11-03 17:40:51 +00:00
|
|
|
byAntenna = (EEP_ANTENNA_AUX | EEP_ANTENNA_MAIN);
|
|
|
|
|
|
|
|
if (byAntenna == (EEP_ANTENNA_AUX | EEP_ANTENNA_MAIN)) {
|
|
|
|
pDevice->byAntennaCount = 2;
|
|
|
|
pDevice->byTxAntennaMode = ANT_B;
|
|
|
|
pDevice->dwTxAntennaSel = 1;
|
|
|
|
pDevice->dwRxAntennaSel = 1;
|
|
|
|
|
|
|
|
if (pDevice->bTxRxAntInv == true)
|
|
|
|
pDevice->byRxAntennaMode = ANT_A;
|
|
|
|
else
|
|
|
|
pDevice->byRxAntennaMode = ANT_B;
|
|
|
|
} else {
|
|
|
|
pDevice->byAntennaCount = 1;
|
|
|
|
pDevice->dwTxAntennaSel = 0;
|
|
|
|
pDevice->dwRxAntennaSel = 0;
|
|
|
|
|
|
|
|
if (byAntenna & EEP_ANTENNA_AUX) {
|
|
|
|
pDevice->byTxAntennaMode = ANT_A;
|
|
|
|
|
|
|
|
if (pDevice->bTxRxAntInv == true)
|
|
|
|
pDevice->byRxAntennaMode = ANT_B;
|
|
|
|
else
|
|
|
|
pDevice->byRxAntennaMode = ANT_A;
|
|
|
|
} else {
|
|
|
|
pDevice->byTxAntennaMode = ANT_B;
|
|
|
|
|
|
|
|
if (pDevice->bTxRxAntInv == true)
|
|
|
|
pDevice->byRxAntennaMode = ANT_A;
|
|
|
|
else
|
|
|
|
pDevice->byRxAntennaMode = ANT_B;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-31 23:23:07 +00:00
|
|
|
/* get Auto Fall Back type */
|
2013-11-03 17:52:15 +00:00
|
|
|
pDevice->byAutoFBCtrl = AUTO_FB_0;
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2013-01-31 23:23:07 +00:00
|
|
|
/* default Auto Mode */
|
|
|
|
/* pDevice->NetworkType = Ndis802_11Automode; */
|
2013-11-03 17:52:15 +00:00
|
|
|
pDevice->eConfigPHYMode = PHY_TYPE_AUTO;
|
|
|
|
pDevice->byBBType = BB_TYPE_11G;
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2013-01-31 23:23:07 +00:00
|
|
|
/* get channel range */
|
2013-11-03 17:52:15 +00:00
|
|
|
pDevice->byMinChannel = 1;
|
|
|
|
pDevice->byMaxChannel = CB_MAX_CHANNEL;
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2013-01-31 23:23:07 +00:00
|
|
|
/* get RFType */
|
2013-11-03 17:49:32 +00:00
|
|
|
pDevice->byRFType = init_rsp->rf_type;
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2013-01-31 23:23:07 +00:00
|
|
|
/* load vt3266 calibration parameters in EEPROM */
|
2013-11-03 17:40:51 +00:00
|
|
|
if (pDevice->byRFType == RF_VT3226D0) {
|
|
|
|
if ((pDevice->abyEEPROM[EEP_OFS_MAJOR_VER] == 0x1) &&
|
|
|
|
(pDevice->abyEEPROM[EEP_OFS_MINOR_VER] >= 0x4)) {
|
|
|
|
|
|
|
|
byCalibTXIQ = pDevice->abyEEPROM[EEP_OFS_CALIB_TX_IQ];
|
|
|
|
byCalibTXDC = pDevice->abyEEPROM[EEP_OFS_CALIB_TX_DC];
|
|
|
|
byCalibRXIQ = pDevice->abyEEPROM[EEP_OFS_CALIB_RX_IQ];
|
|
|
|
if (byCalibTXIQ || byCalibTXDC || byCalibRXIQ) {
|
2013-01-31 23:23:07 +00:00
|
|
|
/* CR255, enable TX/RX IQ and DC compensation mode */
|
2014-05-26 12:59:03 +00:00
|
|
|
vnt_control_out_u8(pDevice,
|
2013-11-03 17:52:15 +00:00
|
|
|
MESSAGE_REQUEST_BBREG,
|
|
|
|
0xff,
|
|
|
|
0x03);
|
2013-01-31 23:23:07 +00:00
|
|
|
/* CR251, TX I/Q Imbalance Calibration */
|
2014-05-26 12:59:03 +00:00
|
|
|
vnt_control_out_u8(pDevice,
|
2013-11-03 17:52:15 +00:00
|
|
|
MESSAGE_REQUEST_BBREG,
|
|
|
|
0xfb,
|
|
|
|
byCalibTXIQ);
|
2013-01-31 23:23:07 +00:00
|
|
|
/* CR252, TX DC-Offset Calibration */
|
2014-05-26 12:59:03 +00:00
|
|
|
vnt_control_out_u8(pDevice,
|
2013-11-03 17:52:15 +00:00
|
|
|
MESSAGE_REQUEST_BBREG,
|
|
|
|
0xfC,
|
|
|
|
byCalibTXDC);
|
2013-01-31 23:23:07 +00:00
|
|
|
/* CR253, RX I/Q Imbalance Calibration */
|
2014-05-26 12:59:03 +00:00
|
|
|
vnt_control_out_u8(pDevice,
|
2013-11-03 17:52:15 +00:00
|
|
|
MESSAGE_REQUEST_BBREG,
|
|
|
|
0xfd,
|
|
|
|
byCalibRXIQ);
|
2013-11-03 17:40:51 +00:00
|
|
|
} else {
|
2013-01-31 23:23:07 +00:00
|
|
|
/* CR255, turn off BB Calibration compensation */
|
2014-05-26 12:59:03 +00:00
|
|
|
vnt_control_out_u8(pDevice,
|
2013-11-03 17:52:15 +00:00
|
|
|
MESSAGE_REQUEST_BBREG,
|
|
|
|
0xff,
|
|
|
|
0x0);
|
2013-11-03 17:40:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-11-03 17:52:15 +00:00
|
|
|
|
|
|
|
pMgmt->eScanType = WMAC_SCAN_PASSIVE;
|
|
|
|
pMgmt->uCurrChannel = pDevice->uChannel;
|
|
|
|
pMgmt->uIBSSChannel = pDevice->uChannel;
|
2014-05-30 15:27:40 +00:00
|
|
|
|
|
|
|
vnt_set_channel(pDevice, pMgmt->uCurrChannel);
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2013-01-31 23:23:07 +00:00
|
|
|
/* get permanent network address */
|
2013-11-03 17:49:32 +00:00
|
|
|
memcpy(pDevice->abyPermanentNetAddr, init_rsp->net_addr, 6);
|
2010-04-14 00:54:48 +00:00
|
|
|
memcpy(pDevice->abyCurrentNetAddr,
|
2013-11-03 17:52:15 +00:00
|
|
|
pDevice->abyPermanentNetAddr, ETH_ALEN);
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2013-01-31 23:23:07 +00:00
|
|
|
/* if exist SW network address, use it */
|
2011-07-26 07:35:31 +00:00
|
|
|
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Network address = %pM\n",
|
|
|
|
pDevice->abyCurrentNetAddr);
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2013-11-03 17:52:15 +00:00
|
|
|
/*
|
|
|
|
* set BB and packet type at the same time
|
|
|
|
* set Short Slot Time, xIFS, and RSPINF
|
|
|
|
*/
|
|
|
|
if (pDevice->byBBType == BB_TYPE_11A) {
|
2014-05-30 15:27:47 +00:00
|
|
|
vnt_add_basic_rate(pDevice, RATE_6M);
|
2013-11-03 17:52:15 +00:00
|
|
|
pDevice->bShortSlotTime = true;
|
|
|
|
} else {
|
2014-05-30 15:27:47 +00:00
|
|
|
vnt_add_basic_rate(pDevice, RATE_1M);
|
2013-11-03 17:52:15 +00:00
|
|
|
pDevice->bShortSlotTime = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
BBvSetShortSlotTime(pDevice);
|
2014-05-30 22:22:54 +00:00
|
|
|
vnt_set_bss_mode(pDevice);
|
2013-11-03 17:52:15 +00:00
|
|
|
|
2014-05-17 08:50:39 +00:00
|
|
|
pDevice->byBBVGACurrent = pDevice->abyBBVGA[0];
|
|
|
|
pDevice->byBBVGANew = pDevice->byBBVGACurrent;
|
2013-11-03 17:52:15 +00:00
|
|
|
|
2014-05-17 08:50:39 +00:00
|
|
|
BBvSetVGAGainOffset(pDevice, pDevice->abyBBVGA[0]);
|
2013-11-03 17:52:15 +00:00
|
|
|
|
|
|
|
pDevice->byRadioCtl = pDevice->abyEEPROM[EEP_OFS_RADIOCTL];
|
|
|
|
pDevice->bHWRadioOff = false;
|
|
|
|
|
|
|
|
if ((pDevice->byRadioCtl & EEP_RADIOCTL_ENABLE) != 0) {
|
2014-05-26 12:59:02 +00:00
|
|
|
ntStatus = vnt_control_in(pDevice, MESSAGE_TYPE_READ,
|
2013-11-03 17:52:15 +00:00
|
|
|
MAC_REG_GPIOCTL1, MESSAGE_REQUEST_MACREG, 1, &byTmp);
|
|
|
|
|
2014-05-15 21:49:12 +00:00
|
|
|
if (ntStatus != STATUS_SUCCESS)
|
2013-11-03 17:52:15 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
if ((byTmp & GPIO3_DATA) == 0) {
|
|
|
|
pDevice->bHWRadioOff = true;
|
2014-05-31 10:50:42 +00:00
|
|
|
vnt_mac_reg_bits_on(pDevice, MAC_REG_GPIOCTL1,
|
|
|
|
GPIO3_INTMD);
|
2013-11-03 17:52:15 +00:00
|
|
|
} else {
|
2014-05-31 10:50:41 +00:00
|
|
|
vnt_mac_reg_bits_off(pDevice, MAC_REG_GPIOCTL1,
|
|
|
|
GPIO3_INTMD);
|
2013-11-03 17:52:15 +00:00
|
|
|
pDevice->bHWRadioOff = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-05-26 12:59:04 +00:00
|
|
|
vnt_mac_set_led(pDevice, LEDSTS_TMLEN, 0x38);
|
2013-11-03 17:52:15 +00:00
|
|
|
|
2014-05-26 12:59:04 +00:00
|
|
|
vnt_mac_set_led(pDevice, LEDSTS_STS, LEDSTS_SLOW);
|
2013-11-03 17:52:15 +00:00
|
|
|
|
2014-05-31 10:50:42 +00:00
|
|
|
vnt_mac_reg_bits_on(pDevice, MAC_REG_GPIOCTL0, 0x01);
|
2013-11-03 17:52:15 +00:00
|
|
|
|
|
|
|
if ((pDevice->bHWRadioOff == true) ||
|
|
|
|
(pDevice->bRadioControlOff == true)) {
|
2014-05-30 22:22:52 +00:00
|
|
|
vnt_radio_power_off(pDevice);
|
2013-11-03 17:52:15 +00:00
|
|
|
} else {
|
2014-05-30 22:22:53 +00:00
|
|
|
vnt_radio_power_on(pDevice);
|
2013-11-03 17:52:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"<----INIbInitAdapter Exit\n");
|
|
|
|
|
|
|
|
return true;
|
2009-06-13 11:38:31 +00:00
|
|
|
}
|
|
|
|
|
2009-06-13 11:38:54 +00:00
|
|
|
static const struct net_device_ops device_netdev_ops = {
|
|
|
|
.ndo_open = device_open,
|
|
|
|
.ndo_stop = device_close,
|
|
|
|
.ndo_do_ioctl = device_ioctl,
|
|
|
|
.ndo_get_stats = device_get_stats,
|
|
|
|
.ndo_start_xmit = device_xmit,
|
2011-08-16 06:29:01 +00:00
|
|
|
.ndo_set_rx_mode = device_set_multi,
|
2009-06-13 11:38:54 +00:00
|
|
|
};
|
|
|
|
|
2014-02-28 23:58:36 +00:00
|
|
|
static void device_free_tx_bufs(struct vnt_private *priv)
|
2010-05-01 17:25:00 +00:00
|
|
|
{
|
2014-02-28 23:58:36 +00:00
|
|
|
struct vnt_usb_send_context *tx_context;
|
|
|
|
int ii;
|
|
|
|
|
|
|
|
for (ii = 0; ii < priv->cbTD; ii++) {
|
|
|
|
tx_context = priv->apTD[ii];
|
|
|
|
/* deallocate URBs */
|
2014-05-15 21:49:11 +00:00
|
|
|
if (tx_context->urb) {
|
|
|
|
usb_kill_urb(tx_context->urb);
|
|
|
|
usb_free_urb(tx_context->urb);
|
2014-02-28 23:58:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
kfree(tx_context);
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
2009-06-13 11:38:31 +00:00
|
|
|
}
|
|
|
|
|
2014-02-28 23:58:35 +00:00
|
|
|
static void device_free_rx_bufs(struct vnt_private *priv)
|
2010-05-01 17:25:00 +00:00
|
|
|
{
|
2014-02-28 23:58:35 +00:00
|
|
|
struct vnt_rcb *rcb;
|
2013-08-28 20:12:35 +00:00
|
|
|
int ii;
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2014-02-28 23:58:35 +00:00
|
|
|
for (ii = 0; ii < priv->cbRD; ii++) {
|
|
|
|
rcb = priv->apRCB[ii];
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2014-02-28 23:58:35 +00:00
|
|
|
/* deallocate URBs */
|
|
|
|
if (rcb->pUrb) {
|
|
|
|
usb_kill_urb(rcb->pUrb);
|
|
|
|
usb_free_urb(rcb->pUrb);
|
|
|
|
}
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2014-02-28 23:58:35 +00:00
|
|
|
/* deallocate skb */
|
|
|
|
if (rcb->skb)
|
|
|
|
dev_kfree_skb(rcb->skb);
|
|
|
|
}
|
|
|
|
|
|
|
|
kfree(priv->pRCBMem);
|
|
|
|
|
|
|
|
return;
|
2009-06-13 11:38:31 +00:00
|
|
|
}
|
|
|
|
|
2012-12-10 21:59:10 +00:00
|
|
|
static void usb_device_reset(struct vnt_private *pDevice)
|
2009-06-13 11:38:31 +00:00
|
|
|
{
|
|
|
|
int status;
|
|
|
|
status = usb_reset_device(pDevice->usb);
|
|
|
|
if (status)
|
|
|
|
printk("usb_device_reset fail status=%d\n",status);
|
|
|
|
return ;
|
|
|
|
}
|
|
|
|
|
2014-02-28 23:58:37 +00:00
|
|
|
static void device_free_int_bufs(struct vnt_private *priv)
|
2010-05-01 17:25:00 +00:00
|
|
|
{
|
2014-02-28 23:58:37 +00:00
|
|
|
kfree(priv->int_buf.data_buf);
|
|
|
|
|
2014-02-19 18:39:09 +00:00
|
|
|
return;
|
2009-06-13 11:38:31 +00:00
|
|
|
}
|
|
|
|
|
2014-02-28 23:58:34 +00:00
|
|
|
static bool device_alloc_bufs(struct vnt_private *priv)
|
2012-12-10 21:59:10 +00:00
|
|
|
{
|
2014-02-28 23:58:34 +00:00
|
|
|
struct vnt_usb_send_context *tx_context;
|
|
|
|
struct vnt_rcb *rcb;
|
2013-08-28 20:12:35 +00:00
|
|
|
int ii;
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2014-02-28 23:58:34 +00:00
|
|
|
for (ii = 0; ii < priv->cbTD; ii++) {
|
|
|
|
tx_context = kmalloc(sizeof(struct vnt_usb_send_context),
|
|
|
|
GFP_KERNEL);
|
|
|
|
if (tx_context == NULL) {
|
|
|
|
DBG_PRT(MSG_LEVEL_ERR, KERN_ERR
|
|
|
|
"%s : allocate tx usb context failed\n",
|
|
|
|
priv->dev->name);
|
|
|
|
goto free_tx;
|
|
|
|
}
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2014-02-28 23:58:34 +00:00
|
|
|
priv->apTD[ii] = tx_context;
|
2014-05-15 21:49:11 +00:00
|
|
|
tx_context->priv = priv;
|
2014-02-28 23:58:34 +00:00
|
|
|
|
|
|
|
/* allocate URBs */
|
2014-05-15 21:49:11 +00:00
|
|
|
tx_context->urb = usb_alloc_urb(0, GFP_ATOMIC);
|
|
|
|
if (!tx_context->urb) {
|
2014-02-28 23:58:34 +00:00
|
|
|
DBG_PRT(MSG_LEVEL_ERR,
|
|
|
|
KERN_ERR "alloc tx urb failed\n");
|
|
|
|
goto free_tx;
|
|
|
|
}
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2014-05-15 21:49:11 +00:00
|
|
|
tx_context->in_use = false;
|
2014-02-28 23:58:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* allocate RCB mem */
|
|
|
|
priv->pRCBMem = kzalloc((sizeof(struct vnt_rcb) * priv->cbRD),
|
2013-08-28 20:12:35 +00:00
|
|
|
GFP_KERNEL);
|
2014-02-28 23:58:34 +00:00
|
|
|
if (priv->pRCBMem == NULL) {
|
|
|
|
DBG_PRT(MSG_LEVEL_ERR, KERN_ERR
|
|
|
|
"%s : alloc rx usb context failed\n",
|
|
|
|
priv->dev->name);
|
|
|
|
goto free_tx;
|
|
|
|
}
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2014-02-28 23:58:34 +00:00
|
|
|
priv->FirstRecvFreeList = NULL;
|
|
|
|
priv->LastRecvFreeList = NULL;
|
|
|
|
priv->FirstRecvMngList = NULL;
|
|
|
|
priv->LastRecvMngList = NULL;
|
|
|
|
priv->NumRecvFreeList = 0;
|
2013-08-28 20:12:35 +00:00
|
|
|
|
2014-02-28 23:58:34 +00:00
|
|
|
rcb = (struct vnt_rcb *)priv->pRCBMem;
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2014-02-28 23:58:34 +00:00
|
|
|
for (ii = 0; ii < priv->cbRD; ii++) {
|
|
|
|
priv->apRCB[ii] = rcb;
|
|
|
|
rcb->pDevice = priv;
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2014-02-28 23:58:34 +00:00
|
|
|
/* allocate URBs */
|
|
|
|
rcb->pUrb = usb_alloc_urb(0, GFP_ATOMIC);
|
|
|
|
if (rcb->pUrb == NULL) {
|
|
|
|
DBG_PRT(MSG_LEVEL_ERR, KERN_ERR
|
|
|
|
" Failed to alloc rx urb\n");
|
|
|
|
goto free_rx_tx;
|
|
|
|
}
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2014-06-25 20:14:22 +00:00
|
|
|
rcb->skb = dev_alloc_skb(priv->rx_buf_sz);
|
2014-02-28 23:58:34 +00:00
|
|
|
if (rcb->skb == NULL) {
|
|
|
|
DBG_PRT(MSG_LEVEL_ERR, KERN_ERR
|
|
|
|
" Failed to alloc rx skb\n");
|
|
|
|
goto free_rx_tx;
|
|
|
|
}
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2014-02-28 23:58:34 +00:00
|
|
|
rcb->bBoolInUse = false;
|
|
|
|
|
|
|
|
EnqueueRCB(priv->FirstRecvFreeList,
|
|
|
|
priv->LastRecvFreeList, rcb);
|
|
|
|
|
|
|
|
priv->NumRecvFreeList++;
|
|
|
|
rcb++;
|
2009-06-13 11:38:31 +00:00
|
|
|
}
|
|
|
|
|
2014-02-28 23:58:34 +00:00
|
|
|
priv->pInterruptURB = usb_alloc_urb(0, GFP_ATOMIC);
|
|
|
|
if (priv->pInterruptURB == NULL) {
|
|
|
|
DBG_PRT(MSG_LEVEL_ERR, KERN_ERR"Failed to alloc int urb\n");
|
|
|
|
goto free_rx_tx;
|
2009-06-13 11:38:31 +00:00
|
|
|
}
|
|
|
|
|
2014-02-28 23:58:34 +00:00
|
|
|
priv->int_buf.data_buf = kmalloc(MAX_INTERRUPT_SIZE, GFP_KERNEL);
|
|
|
|
if (priv->int_buf.data_buf == NULL) {
|
|
|
|
DBG_PRT(MSG_LEVEL_ERR, KERN_ERR"Failed to alloc int buf\n");
|
|
|
|
usb_free_urb(priv->pInterruptURB);
|
|
|
|
goto free_rx_tx;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
2009-06-13 11:38:31 +00:00
|
|
|
|
|
|
|
free_rx_tx:
|
2014-02-28 23:58:34 +00:00
|
|
|
device_free_rx_bufs(priv);
|
2009-06-13 11:38:31 +00:00
|
|
|
|
|
|
|
free_tx:
|
2014-02-28 23:58:34 +00:00
|
|
|
device_free_tx_bufs(priv);
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2013-02-13 01:36:29 +00:00
|
|
|
return false;
|
2009-06-13 11:38:31 +00:00
|
|
|
}
|
|
|
|
|
2013-02-13 01:36:28 +00:00
|
|
|
static bool device_init_defrag_cb(struct vnt_private *pDevice)
|
2012-12-10 21:59:10 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
PSDeFragControlBlock pDeF;
|
2009-06-13 11:38:31 +00:00
|
|
|
|
|
|
|
/* Init the fragment ctl entries */
|
|
|
|
for (i = 0; i < CB_MAX_RX_FRAG; i++) {
|
|
|
|
pDeF = &(pDevice->sRxDFCB[i]);
|
|
|
|
if (!device_alloc_frag_buf(pDevice, pDeF)) {
|
|
|
|
DBG_PRT(MSG_LEVEL_ERR,KERN_ERR "%s: can not alloc frag bufs\n",
|
|
|
|
pDevice->dev->name);
|
|
|
|
goto free_frag;
|
2011-04-10 21:31:32 +00:00
|
|
|
}
|
2009-06-13 11:38:31 +00:00
|
|
|
}
|
|
|
|
pDevice->cbDFCB = CB_MAX_RX_FRAG;
|
|
|
|
pDevice->cbFreeDFCB = pDevice->cbDFCB;
|
2013-02-13 01:36:30 +00:00
|
|
|
return true;
|
2009-06-13 11:38:31 +00:00
|
|
|
|
|
|
|
free_frag:
|
|
|
|
device_free_frag_bufs(pDevice);
|
2013-02-13 01:36:29 +00:00
|
|
|
return false;
|
2009-06-13 11:38:31 +00:00
|
|
|
}
|
|
|
|
|
2012-12-10 21:59:10 +00:00
|
|
|
static void device_free_frag_bufs(struct vnt_private *pDevice)
|
|
|
|
{
|
|
|
|
PSDeFragControlBlock pDeF;
|
|
|
|
int i;
|
2009-06-13 11:38:31 +00:00
|
|
|
|
|
|
|
for (i = 0; i < CB_MAX_RX_FRAG; i++) {
|
|
|
|
|
|
|
|
pDeF = &(pDevice->sRxDFCB[i]);
|
|
|
|
|
|
|
|
if (pDeF->skb)
|
|
|
|
dev_kfree_skb(pDeF->skb);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-12-10 21:59:10 +00:00
|
|
|
int device_alloc_frag_buf(struct vnt_private *pDevice,
|
|
|
|
PSDeFragControlBlock pDeF)
|
|
|
|
{
|
2014-02-28 23:58:33 +00:00
|
|
|
pDeF->skb = netdev_alloc_skb(pDevice->dev, pDevice->rx_buf_sz);
|
|
|
|
if (!pDeF->skb)
|
|
|
|
return false;
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2014-02-28 23:58:33 +00:00
|
|
|
return true;
|
2009-06-13 11:38:31 +00:00
|
|
|
}
|
|
|
|
|
2012-12-10 21:59:10 +00:00
|
|
|
static int device_open(struct net_device *dev)
|
|
|
|
{
|
|
|
|
struct vnt_private *pDevice = netdev_priv(dev);
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2013-02-13 01:36:29 +00:00
|
|
|
pDevice->fWPA_Authened = false;
|
2009-06-13 11:38:31 +00:00
|
|
|
|
|
|
|
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " device_open...\n");
|
|
|
|
|
|
|
|
pDevice->rx_buf_sz = MAX_TOTAL_SIZE_WITH_ALL_HEADERS;
|
|
|
|
|
2013-02-13 01:36:29 +00:00
|
|
|
if (device_alloc_bufs(pDevice) == false) {
|
2009-06-13 11:38:31 +00:00
|
|
|
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " device_alloc_bufs fail... \n");
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
2013-02-13 01:36:29 +00:00
|
|
|
if (device_init_defrag_cb(pDevice)== false) {
|
2012-08-26 15:16:43 +00:00
|
|
|
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " Initial defragment cb fail \n");
|
2009-06-13 11:38:31 +00:00
|
|
|
goto free_rx_tx;
|
|
|
|
}
|
|
|
|
|
|
|
|
MP_CLEAR_FLAG(pDevice, fMP_DISCONNECTED);
|
|
|
|
MP_SET_FLAG(pDevice, fMP_POST_READS);
|
|
|
|
MP_SET_FLAG(pDevice, fMP_POST_WRITES);
|
|
|
|
|
2013-01-31 23:23:07 +00:00
|
|
|
/* read config file */
|
2009-06-13 11:38:31 +00:00
|
|
|
Read_config_file(pDevice);
|
|
|
|
|
2013-11-03 17:40:51 +00:00
|
|
|
if (device_init_registers(pDevice) == false) {
|
|
|
|
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " init register fail\n");
|
|
|
|
goto free_all;
|
|
|
|
}
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2013-01-31 23:23:07 +00:00
|
|
|
/* init for key management */
|
2009-06-13 11:38:31 +00:00
|
|
|
KeyvInitTable(pDevice,&pDevice->sKey);
|
2013-01-17 23:19:37 +00:00
|
|
|
memcpy(pDevice->vnt_mgmt.abyMACAddr,
|
|
|
|
pDevice->abyCurrentNetAddr, ETH_ALEN);
|
2010-04-14 00:54:48 +00:00
|
|
|
memcpy(pDevice->dev->dev_addr, pDevice->abyCurrentNetAddr, ETH_ALEN);
|
2013-02-13 01:36:29 +00:00
|
|
|
pDevice->bStopTx0Pkt = false;
|
|
|
|
pDevice->bStopDataPkt = false;
|
|
|
|
pDevice->bRoaming = false;
|
|
|
|
pDevice->bIsRoaming = false;
|
|
|
|
pDevice->bEnableRoaming = false;
|
2009-06-13 11:38:31 +00:00
|
|
|
|
|
|
|
vMgrObjectInit(pDevice);
|
2013-09-27 15:55:45 +00:00
|
|
|
|
2013-09-27 15:51:13 +00:00
|
|
|
schedule_delayed_work(&pDevice->second_callback_work, HZ);
|
|
|
|
|
2014-03-17 21:15:03 +00:00
|
|
|
pDevice->int_interval = 1; /* bInterval is set to 1 */
|
2009-06-13 11:38:31 +00:00
|
|
|
pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled;
|
|
|
|
|
2013-02-13 01:36:30 +00:00
|
|
|
pDevice->bIsRxWorkItemQueued = true;
|
2013-02-13 01:36:29 +00:00
|
|
|
|
|
|
|
pDevice->bWPADEVUp = false;
|
|
|
|
pDevice->bwextstep0 = false;
|
|
|
|
pDevice->bwextstep1 = false;
|
|
|
|
pDevice->bwextstep2 = false;
|
|
|
|
pDevice->bwextstep3 = false;
|
|
|
|
pDevice->bWPASuppWextEnabled = false;
|
2009-06-13 11:38:31 +00:00
|
|
|
pDevice->byReAssocCount = 0;
|
|
|
|
|
2013-09-27 15:53:55 +00:00
|
|
|
schedule_work(&pDevice->read_work_item);
|
2009-06-13 11:38:31 +00:00
|
|
|
INTvWorkItem(pDevice);
|
|
|
|
|
2013-01-31 23:23:07 +00:00
|
|
|
/* if WEP key already set by iwconfig but device not yet open */
|
2013-02-13 01:36:30 +00:00
|
|
|
if ((pDevice->bEncryptionEnable == true) && (pDevice->bTransmitKey == true)) {
|
2009-06-13 11:38:31 +00:00
|
|
|
KeybSetDefaultKey( pDevice,
|
|
|
|
&(pDevice->sKey),
|
|
|
|
pDevice->byKeyIndex | (1 << 31),
|
|
|
|
pDevice->uKeyLength,
|
|
|
|
NULL,
|
|
|
|
pDevice->abyKey,
|
|
|
|
KEY_CTL_WEP
|
|
|
|
);
|
2014-05-15 21:49:12 +00:00
|
|
|
|
2009-06-13 11:38:31 +00:00
|
|
|
pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled;
|
|
|
|
}
|
|
|
|
|
2013-01-17 23:19:37 +00:00
|
|
|
if (pDevice->vnt_mgmt.eConfigMode == WMAC_CONFIG_AP)
|
2010-05-06 23:34:29 +00:00
|
|
|
bScheduleCommand((void *) pDevice, WLAN_CMD_RUN_AP, NULL);
|
2013-01-17 23:19:37 +00:00
|
|
|
else
|
|
|
|
bScheduleCommand((void *) pDevice, WLAN_CMD_BSSID_SCAN, NULL);
|
2009-06-13 11:38:31 +00:00
|
|
|
|
|
|
|
netif_stop_queue(pDevice->dev);
|
|
|
|
pDevice->flags |= DEVICE_FLAGS_OPENED;
|
|
|
|
|
2012-11-24 14:47:11 +00:00
|
|
|
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "device_open success..\n");
|
|
|
|
return 0;
|
2009-06-13 11:38:31 +00:00
|
|
|
|
|
|
|
free_all:
|
|
|
|
device_free_frag_bufs(pDevice);
|
|
|
|
free_rx_tx:
|
|
|
|
device_free_rx_bufs(pDevice);
|
|
|
|
device_free_tx_bufs(pDevice);
|
|
|
|
device_free_int_bufs(pDevice);
|
2009-08-12 21:54:14 +00:00
|
|
|
usb_kill_urb(pDevice->pInterruptURB);
|
2009-06-13 11:38:31 +00:00
|
|
|
usb_free_urb(pDevice->pInterruptURB);
|
|
|
|
|
|
|
|
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "device_open fail.. \n");
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
2012-12-10 21:59:10 +00:00
|
|
|
static int device_close(struct net_device *dev)
|
|
|
|
{
|
|
|
|
struct vnt_private *pDevice = netdev_priv(dev);
|
|
|
|
struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
|
2014-05-23 17:00:03 +00:00
|
|
|
u8 uu;
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2012-12-10 21:59:10 +00:00
|
|
|
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "device_close1\n");
|
2009-06-13 11:38:31 +00:00
|
|
|
if (pDevice == NULL)
|
|
|
|
return -ENODEV;
|
|
|
|
|
|
|
|
if (pDevice->bLinkPass) {
|
2010-05-06 23:34:29 +00:00
|
|
|
bScheduleCommand((void *) pDevice, WLAN_CMD_DISASSOCIATE, NULL);
|
2009-06-13 11:38:31 +00:00
|
|
|
mdelay(30);
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
|
2013-02-13 01:36:29 +00:00
|
|
|
pMgmt->bShareKeyAlgorithm = false;
|
|
|
|
pDevice->bEncryptionEnable = false;
|
2009-06-13 11:38:31 +00:00
|
|
|
pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled;
|
2014-05-15 21:49:12 +00:00
|
|
|
|
2010-05-20 02:50:00 +00:00
|
|
|
for (uu = 0; uu < MAX_KEY_TABLE; uu++)
|
2014-05-31 10:50:39 +00:00
|
|
|
vnt_mac_disable_keyentry(pDevice, uu);
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2014-05-31 10:50:37 +00:00
|
|
|
if ((pDevice->flags & DEVICE_FLAGS_UNPLUG) == false)
|
|
|
|
vnt_mac_shutdown(pDevice);
|
|
|
|
|
2009-06-13 11:38:31 +00:00
|
|
|
netif_stop_queue(pDevice->dev);
|
|
|
|
MP_SET_FLAG(pDevice, fMP_DISCONNECTED);
|
|
|
|
MP_CLEAR_FLAG(pDevice, fMP_POST_WRITES);
|
|
|
|
MP_CLEAR_FLAG(pDevice, fMP_POST_READS);
|
2013-09-27 15:48:14 +00:00
|
|
|
|
|
|
|
cancel_delayed_work_sync(&pDevice->run_command_work);
|
2013-09-27 15:51:13 +00:00
|
|
|
cancel_delayed_work_sync(&pDevice->second_callback_work);
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2013-09-27 15:55:45 +00:00
|
|
|
cancel_work_sync(&pDevice->rx_mng_work_item);
|
2013-09-27 15:53:55 +00:00
|
|
|
cancel_work_sync(&pDevice->read_work_item);
|
|
|
|
|
2013-02-13 01:36:29 +00:00
|
|
|
pDevice->bRoaming = false;
|
|
|
|
pDevice->bIsRoaming = false;
|
|
|
|
pDevice->bEnableRoaming = false;
|
|
|
|
pDevice->bCmdRunning = false;
|
|
|
|
pDevice->bLinkPass = false;
|
2009-06-13 11:38:31 +00:00
|
|
|
memset(pMgmt->abyCurrBSSID, 0, 6);
|
|
|
|
pMgmt->eCurrState = WMAC_STATE_IDLE;
|
|
|
|
|
2013-09-22 18:48:54 +00:00
|
|
|
pDevice->flags &= ~DEVICE_FLAGS_OPENED;
|
|
|
|
|
2009-06-13 11:38:31 +00:00
|
|
|
device_free_tx_bufs(pDevice);
|
|
|
|
device_free_rx_bufs(pDevice);
|
|
|
|
device_free_int_bufs(pDevice);
|
|
|
|
device_free_frag_bufs(pDevice);
|
|
|
|
|
2009-08-12 21:54:14 +00:00
|
|
|
usb_kill_urb(pDevice->pInterruptURB);
|
2009-06-13 11:38:31 +00:00
|
|
|
usb_free_urb(pDevice->pInterruptURB);
|
|
|
|
|
|
|
|
BSSvClearNodeDBTable(pDevice, 0);
|
|
|
|
|
|
|
|
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "device_close2 \n");
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-06-25 20:14:25 +00:00
|
|
|
static void vnt_tx_80211(struct ieee80211_hw *hw,
|
|
|
|
struct ieee80211_tx_control *control, struct sk_buff *skb)
|
|
|
|
{
|
|
|
|
struct vnt_private *priv = hw->priv;
|
|
|
|
|
|
|
|
ieee80211_stop_queues(hw);
|
|
|
|
|
|
|
|
if (vnt_tx_packet(priv, skb)) {
|
|
|
|
ieee80211_free_txskb(hw, skb);
|
|
|
|
|
|
|
|
ieee80211_wake_queues(hw);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int vnt_start(struct ieee80211_hw *hw)
|
|
|
|
{
|
|
|
|
struct vnt_private *priv = hw->priv;
|
|
|
|
|
|
|
|
priv->rx_buf_sz = MAX_TOTAL_SIZE_WITH_ALL_HEADERS;
|
|
|
|
|
|
|
|
if (device_alloc_bufs(priv) == false) {
|
|
|
|
dev_dbg(&priv->usb->dev, "device_alloc_bufs fail...\n");
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
MP_CLEAR_FLAG(priv, fMP_DISCONNECTED);
|
|
|
|
MP_SET_FLAG(priv, fMP_POST_READS);
|
|
|
|
MP_SET_FLAG(priv, fMP_POST_WRITES);
|
|
|
|
|
|
|
|
if (device_init_registers(priv) == false) {
|
|
|
|
dev_dbg(&priv->usb->dev, " init register fail\n");
|
|
|
|
goto free_all;
|
|
|
|
}
|
|
|
|
|
|
|
|
priv->int_interval = 1; /* bInterval is set to 1 */
|
|
|
|
|
|
|
|
schedule_work(&priv->read_work_item);
|
|
|
|
INTvWorkItem(priv);
|
|
|
|
|
|
|
|
priv->flags |= DEVICE_FLAGS_OPENED;
|
|
|
|
|
|
|
|
ieee80211_wake_queues(hw);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
free_all:
|
|
|
|
device_free_rx_bufs(priv);
|
|
|
|
device_free_tx_bufs(priv);
|
|
|
|
device_free_int_bufs(priv);
|
|
|
|
|
|
|
|
usb_kill_urb(priv->pInterruptURB);
|
|
|
|
usb_free_urb(priv->pInterruptURB);
|
|
|
|
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void vnt_stop(struct ieee80211_hw *hw)
|
|
|
|
{
|
|
|
|
struct vnt_private *priv = hw->priv;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (!priv)
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (i = 0; i < MAX_KEY_TABLE; i++)
|
|
|
|
vnt_mac_disable_keyentry(priv, i);
|
|
|
|
|
|
|
|
/* clear all keys */
|
|
|
|
priv->key_entry_inuse = 0;
|
|
|
|
|
|
|
|
if ((priv->flags & DEVICE_FLAGS_UNPLUG) == false)
|
|
|
|
vnt_mac_shutdown(priv);
|
|
|
|
|
|
|
|
ieee80211_stop_queues(hw);
|
|
|
|
|
|
|
|
MP_SET_FLAG(priv, fMP_DISCONNECTED);
|
|
|
|
MP_CLEAR_FLAG(priv, fMP_POST_WRITES);
|
|
|
|
MP_CLEAR_FLAG(priv, fMP_POST_READS);
|
|
|
|
|
|
|
|
cancel_delayed_work_sync(&priv->run_command_work);
|
|
|
|
cancel_work_sync(&priv->read_work_item);
|
|
|
|
|
|
|
|
priv->bCmdRunning = false;
|
|
|
|
|
|
|
|
priv->flags &= ~DEVICE_FLAGS_OPENED;
|
|
|
|
|
|
|
|
device_free_tx_bufs(priv);
|
|
|
|
device_free_rx_bufs(priv);
|
|
|
|
device_free_int_bufs(priv);
|
|
|
|
|
|
|
|
usb_kill_urb(priv->pInterruptURB);
|
|
|
|
usb_free_urb(priv->pInterruptURB);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int vnt_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
|
|
|
|
{
|
|
|
|
struct vnt_private *priv = hw->priv;
|
|
|
|
|
|
|
|
priv->vif = vif;
|
|
|
|
|
|
|
|
switch (vif->type) {
|
|
|
|
case NL80211_IFTYPE_STATION:
|
|
|
|
break;
|
|
|
|
case NL80211_IFTYPE_ADHOC:
|
|
|
|
vnt_mac_reg_bits_off(priv, MAC_REG_RCR, RCR_UNICAST);
|
|
|
|
|
|
|
|
vnt_mac_reg_bits_on(priv, MAC_REG_HOSTCR, HOSTCR_ADHOC);
|
|
|
|
|
|
|
|
break;
|
|
|
|
case NL80211_IFTYPE_AP:
|
|
|
|
vnt_mac_reg_bits_off(priv, MAC_REG_RCR, RCR_UNICAST);
|
|
|
|
|
|
|
|
vnt_mac_reg_bits_on(priv, MAC_REG_HOSTCR, HOSTCR_AP);
|
|
|
|
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
|
|
|
|
priv->op_mode = vif->type;
|
|
|
|
|
|
|
|
/* LED blink on TX */
|
|
|
|
vnt_mac_set_led(priv, LEDSTS_STS, LEDSTS_INTER);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void vnt_remove_interface(struct ieee80211_hw *hw,
|
|
|
|
struct ieee80211_vif *vif)
|
|
|
|
{
|
|
|
|
struct vnt_private *priv = hw->priv;
|
|
|
|
|
|
|
|
switch (vif->type) {
|
|
|
|
case NL80211_IFTYPE_STATION:
|
|
|
|
break;
|
|
|
|
case NL80211_IFTYPE_ADHOC:
|
|
|
|
vnt_mac_reg_bits_off(priv, MAC_REG_TCR, TCR_AUTOBCNTX);
|
|
|
|
vnt_mac_reg_bits_off(priv, MAC_REG_TFTCTL, TFTCTL_TSFCNTREN);
|
|
|
|
vnt_mac_reg_bits_off(priv, MAC_REG_HOSTCR, HOSTCR_ADHOC);
|
|
|
|
break;
|
|
|
|
case NL80211_IFTYPE_AP:
|
|
|
|
vnt_mac_reg_bits_off(priv, MAC_REG_TCR, TCR_AUTOBCNTX);
|
|
|
|
vnt_mac_reg_bits_off(priv, MAC_REG_TFTCTL, TFTCTL_TSFCNTREN);
|
|
|
|
vnt_mac_reg_bits_off(priv, MAC_REG_HOSTCR, HOSTCR_AP);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
vnt_radio_power_off(priv);
|
|
|
|
|
|
|
|
priv->op_mode = NL80211_IFTYPE_UNSPECIFIED;
|
|
|
|
|
|
|
|
/* LED slow blink */
|
|
|
|
vnt_mac_set_led(priv, LEDSTS_STS, LEDSTS_SLOW);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int vnt_config(struct ieee80211_hw *hw, u32 changed)
|
|
|
|
{
|
|
|
|
struct vnt_private *priv = hw->priv;
|
|
|
|
struct ieee80211_conf *conf = &hw->conf;
|
|
|
|
u8 bb_type;
|
|
|
|
|
|
|
|
if (changed & IEEE80211_CONF_CHANGE_PS) {
|
|
|
|
if (conf->flags & IEEE80211_CONF_PS)
|
|
|
|
vnt_enable_power_saving(priv, conf->listen_interval);
|
|
|
|
else
|
|
|
|
vnt_disable_power_saving(priv);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((changed & IEEE80211_CONF_CHANGE_CHANNEL) ||
|
|
|
|
(conf->flags & IEEE80211_CONF_OFFCHANNEL)) {
|
|
|
|
vnt_set_channel(priv, conf->chandef.chan->hw_value);
|
|
|
|
|
|
|
|
if (conf->chandef.chan->band == IEEE80211_BAND_5GHZ)
|
|
|
|
bb_type = BB_TYPE_11A;
|
|
|
|
else
|
|
|
|
bb_type = BB_TYPE_11G;
|
|
|
|
|
|
|
|
if (priv->byBBType != bb_type) {
|
|
|
|
priv->byBBType = bb_type;
|
|
|
|
|
|
|
|
vnt_set_bss_mode(priv);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (changed & IEEE80211_CONF_CHANGE_POWER) {
|
|
|
|
if (priv->byBBType == BB_TYPE_11B)
|
|
|
|
priv->wCurrentRate = RATE_1M;
|
|
|
|
else
|
|
|
|
priv->wCurrentRate = RATE_54M;
|
|
|
|
|
|
|
|
vnt_rf_setpower(priv, priv->wCurrentRate,
|
|
|
|
conf->chandef.chan->hw_value);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void vnt_bss_info_changed(struct ieee80211_hw *hw,
|
|
|
|
struct ieee80211_vif *vif, struct ieee80211_bss_conf *conf,
|
|
|
|
u32 changed)
|
|
|
|
{
|
|
|
|
struct vnt_private *priv = hw->priv;
|
|
|
|
priv->current_aid = conf->aid;
|
|
|
|
|
|
|
|
if (changed & BSS_CHANGED_BSSID)
|
|
|
|
vnt_mac_set_bssid_addr(priv, (u8 *)conf->bssid);
|
|
|
|
|
|
|
|
|
|
|
|
if (changed & BSS_CHANGED_BASIC_RATES) {
|
|
|
|
priv->wBasicRate = conf->basic_rates;
|
|
|
|
|
|
|
|
vnt_update_top_rates(priv);
|
|
|
|
|
|
|
|
dev_dbg(&priv->usb->dev, "basic rates %x\n", conf->basic_rates);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (changed & BSS_CHANGED_ERP_PREAMBLE) {
|
|
|
|
if (conf->use_short_preamble) {
|
|
|
|
vnt_mac_enable_barker_preamble_mode(priv);
|
|
|
|
priv->byPreambleType = true;
|
|
|
|
} else {
|
|
|
|
vnt_mac_disable_barker_preamble_mode(priv);
|
|
|
|
priv->byPreambleType = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (changed & BSS_CHANGED_ERP_CTS_PROT) {
|
|
|
|
if (conf->use_cts_prot)
|
|
|
|
vnt_mac_enable_protect_mode(priv);
|
|
|
|
else
|
|
|
|
vnt_mac_disable_protect_mode(priv);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (changed & BSS_CHANGED_ERP_SLOT) {
|
|
|
|
if (conf->use_short_slot)
|
|
|
|
priv->bShortSlotTime = true;
|
|
|
|
else
|
|
|
|
priv->bShortSlotTime = false;
|
|
|
|
|
|
|
|
BBvSetShortSlotTime(priv);
|
|
|
|
BBvSetVGAGainOffset(priv, priv->abyBBVGA[0]);
|
|
|
|
BBvUpdatePreEDThreshold(priv, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (changed & BSS_CHANGED_TXPOWER)
|
|
|
|
vnt_rf_setpower(priv, priv->wCurrentRate,
|
|
|
|
conf->chandef.chan->hw_value);
|
|
|
|
|
|
|
|
if (changed & BSS_CHANGED_BEACON_ENABLED) {
|
|
|
|
dev_dbg(&priv->usb->dev,
|
|
|
|
"Beacon enable %d\n", conf->enable_beacon);
|
|
|
|
|
|
|
|
if (conf->enable_beacon) {
|
|
|
|
vnt_beacon_enable(priv, vif, conf);
|
|
|
|
|
|
|
|
vnt_mac_reg_bits_on(priv, MAC_REG_TCR, TCR_AUTOBCNTX);
|
|
|
|
} else {
|
|
|
|
vnt_mac_reg_bits_off(priv, MAC_REG_TCR, TCR_AUTOBCNTX);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static u64 vnt_prepare_multicast(struct ieee80211_hw *hw,
|
|
|
|
struct netdev_hw_addr_list *mc_list)
|
|
|
|
{
|
|
|
|
struct vnt_private *priv = hw->priv;
|
|
|
|
struct netdev_hw_addr *ha;
|
|
|
|
u64 mc_filter = 0;
|
|
|
|
u32 bit_nr = 0;
|
|
|
|
|
|
|
|
netdev_hw_addr_list_for_each(ha, mc_list) {
|
|
|
|
bit_nr = ether_crc(ETH_ALEN, ha->addr) >> 26;
|
|
|
|
|
|
|
|
mc_filter |= 1ULL << (bit_nr & 0x3f);
|
|
|
|
}
|
|
|
|
|
|
|
|
priv->mc_list_count = mc_list->count;
|
|
|
|
|
|
|
|
return mc_filter;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void vnt_configure(struct ieee80211_hw *hw,
|
|
|
|
unsigned int changed_flags, unsigned int *total_flags, u64 multicast)
|
|
|
|
{
|
|
|
|
struct vnt_private *priv = hw->priv;
|
|
|
|
u8 rx_mode = 0;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
*total_flags &= FIF_ALLMULTI | FIF_OTHER_BSS | FIF_PROMISC_IN_BSS |
|
|
|
|
FIF_BCN_PRBRESP_PROMISC;
|
|
|
|
|
|
|
|
rc = vnt_control_in(priv, MESSAGE_TYPE_READ, MAC_REG_RCR,
|
|
|
|
MESSAGE_REQUEST_MACREG, sizeof(u8), &rx_mode);
|
|
|
|
|
|
|
|
if (!rc)
|
|
|
|
rx_mode = RCR_MULTICAST | RCR_BROADCAST;
|
|
|
|
|
|
|
|
dev_dbg(&priv->usb->dev, "rx mode in = %x\n", rx_mode);
|
|
|
|
|
|
|
|
if (changed_flags & FIF_PROMISC_IN_BSS) {
|
|
|
|
/* unconditionally log net taps */
|
|
|
|
if (*total_flags & FIF_PROMISC_IN_BSS)
|
|
|
|
rx_mode |= RCR_UNICAST;
|
|
|
|
else
|
|
|
|
rx_mode &= ~RCR_UNICAST;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (changed_flags & FIF_ALLMULTI) {
|
|
|
|
if (*total_flags & FIF_ALLMULTI) {
|
|
|
|
if (priv->mc_list_count > 2)
|
|
|
|
vnt_mac_set_filter(priv, ~0);
|
|
|
|
else
|
|
|
|
vnt_mac_set_filter(priv, multicast);
|
|
|
|
|
|
|
|
rx_mode |= RCR_MULTICAST | RCR_BROADCAST;
|
|
|
|
} else {
|
|
|
|
rx_mode &= ~(RCR_MULTICAST | RCR_BROADCAST);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (changed_flags & (FIF_OTHER_BSS | FIF_BCN_PRBRESP_PROMISC)) {
|
|
|
|
if (*total_flags & (FIF_OTHER_BSS | FIF_BCN_PRBRESP_PROMISC))
|
|
|
|
rx_mode &= ~RCR_BSSID;
|
|
|
|
else
|
|
|
|
rx_mode |= RCR_BSSID;
|
|
|
|
}
|
|
|
|
|
|
|
|
vnt_control_out_u8(priv, MESSAGE_REQUEST_MACREG, MAC_REG_RCR, rx_mode);
|
|
|
|
|
|
|
|
dev_dbg(&priv->usb->dev, "rx mode out= %x\n", rx_mode);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int vnt_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
|
|
|
|
struct ieee80211_vif *vif, struct ieee80211_sta *sta,
|
|
|
|
struct ieee80211_key_conf *key)
|
|
|
|
{
|
|
|
|
struct vnt_private *priv = hw->priv;
|
|
|
|
|
|
|
|
switch (cmd) {
|
|
|
|
case SET_KEY:
|
|
|
|
if (vnt_set_keys(hw, sta, vif, key))
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
break;
|
|
|
|
case DISABLE_KEY:
|
|
|
|
if (test_bit(key->hw_key_idx, &priv->key_entry_inuse))
|
|
|
|
clear_bit(key->hw_key_idx, &priv->key_entry_inuse);
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void vnt_sw_scan_start(struct ieee80211_hw *hw)
|
|
|
|
{
|
|
|
|
struct vnt_private *priv = hw->priv;
|
|
|
|
|
|
|
|
/* Set max sensitivity*/
|
|
|
|
BBvUpdatePreEDThreshold(priv, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void vnt_sw_scan_complete(struct ieee80211_hw *hw)
|
|
|
|
{
|
|
|
|
struct vnt_private *priv = hw->priv;
|
|
|
|
|
|
|
|
/* Return sensitivity to channel level*/
|
|
|
|
BBvUpdatePreEDThreshold(priv, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
static u64 vnt_get_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
|
|
|
|
{
|
|
|
|
struct vnt_private *priv = hw->priv;
|
|
|
|
|
|
|
|
return priv->qwCurrTSF;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void vnt_set_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
|
|
|
|
u64 tsf)
|
|
|
|
{
|
|
|
|
struct vnt_private *priv = hw->priv;
|
|
|
|
|
|
|
|
vnt_update_next_tbtt(priv, tsf, vif->bss_conf.beacon_int);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void vnt_reset_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
|
|
|
|
{
|
|
|
|
struct vnt_private *priv = hw->priv;
|
|
|
|
|
|
|
|
vnt_mac_reg_bits_off(priv, MAC_REG_TFTCTL, TFTCTL_TSFCNTREN);
|
|
|
|
|
|
|
|
vnt_clear_current_tsf(priv);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct ieee80211_ops vnt_mac_ops = {
|
|
|
|
.tx = vnt_tx_80211,
|
|
|
|
.start = vnt_start,
|
|
|
|
.stop = vnt_stop,
|
|
|
|
.add_interface = vnt_add_interface,
|
|
|
|
.remove_interface = vnt_remove_interface,
|
|
|
|
.config = vnt_config,
|
|
|
|
.bss_info_changed = vnt_bss_info_changed,
|
|
|
|
.prepare_multicast = vnt_prepare_multicast,
|
|
|
|
.configure_filter = vnt_configure,
|
|
|
|
.set_key = vnt_set_key,
|
|
|
|
.sw_scan_start = vnt_sw_scan_start,
|
|
|
|
.sw_scan_complete = vnt_sw_scan_complete,
|
|
|
|
.get_tsf = vnt_get_tsf,
|
|
|
|
.set_tsf = vnt_set_tsf,
|
|
|
|
.reset_tsf = vnt_reset_tsf,
|
|
|
|
};
|
|
|
|
|
|
|
|
int vnt_init(struct vnt_private *priv)
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!(device_init_registers(priv)))
|
|
|
|
return -EAGAIN;
|
|
|
|
|
|
|
|
SET_IEEE80211_PERM_ADDR(priv->hw, priv->abyPermanentNetAddr);
|
|
|
|
|
|
|
|
if (ieee80211_register_hw(priv->hw))
|
|
|
|
return -ENODEV;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
vt6656_probe(struct usb_interface *intf, const struct usb_device_id *id)
|
|
|
|
{
|
|
|
|
struct usb_device *udev;
|
|
|
|
struct vnt_private *priv;
|
|
|
|
struct ieee80211_hw *hw;
|
|
|
|
struct wiphy *wiphy;
|
|
|
|
int rc = 0;
|
|
|
|
|
|
|
|
udev = usb_get_dev(interface_to_usbdev(intf));
|
|
|
|
|
|
|
|
dev_notice(&udev->dev, "%s Ver. %s\n",
|
|
|
|
DEVICE_FULL_DRV_NAM, DEVICE_VERSION);
|
|
|
|
dev_notice(&udev->dev,
|
|
|
|
"Copyright (c) 2004 VIA Networking Technologies, Inc.\n");
|
|
|
|
|
|
|
|
hw = ieee80211_alloc_hw(sizeof(struct vnt_private), &vnt_mac_ops);
|
|
|
|
if (!hw) {
|
|
|
|
dev_err(&udev->dev, "could not register ieee80211_hw\n");
|
|
|
|
goto err_nomem;
|
|
|
|
}
|
|
|
|
|
|
|
|
priv = hw->priv;
|
|
|
|
priv->hw = hw;
|
|
|
|
priv->usb = udev;
|
|
|
|
|
|
|
|
device_set_options(priv);
|
|
|
|
|
|
|
|
spin_lock_init(&priv->lock);
|
|
|
|
mutex_init(&priv->usb_lock);
|
|
|
|
|
|
|
|
INIT_DELAYED_WORK(&priv->run_command_work, vRunCommand);
|
|
|
|
INIT_WORK(&priv->read_work_item, RXvWorkItem);
|
|
|
|
|
|
|
|
priv->vnt_mgmt.pAdapter = priv;
|
|
|
|
|
|
|
|
usb_set_intfdata(intf, priv);
|
|
|
|
|
|
|
|
wiphy = priv->hw->wiphy;
|
|
|
|
|
|
|
|
wiphy->frag_threshold = FRAG_THRESH_DEF;
|
|
|
|
wiphy->rts_threshold = RTS_THRESH_DEF;
|
|
|
|
wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) |
|
|
|
|
BIT(NL80211_IFTYPE_ADHOC) | BIT(NL80211_IFTYPE_AP);
|
|
|
|
|
|
|
|
priv->hw->flags = IEEE80211_HW_RX_INCLUDES_FCS |
|
|
|
|
IEEE80211_HW_REPORTS_TX_ACK_STATUS |
|
|
|
|
IEEE80211_HW_SIGNAL_DBM |
|
|
|
|
IEEE80211_HW_TIMING_BEACON_ONLY;
|
|
|
|
|
|
|
|
priv->hw->rate_control_algorithm = "pid";
|
|
|
|
priv->hw->max_signal = 100;
|
|
|
|
|
|
|
|
SET_IEEE80211_DEV(priv->hw, &intf->dev);
|
|
|
|
|
|
|
|
usb_device_reset(priv);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
err_nomem:
|
|
|
|
usb_put_dev(udev);
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2012-11-19 18:26:58 +00:00
|
|
|
static void vt6656_disconnect(struct usb_interface *intf)
|
2009-06-13 11:38:31 +00:00
|
|
|
{
|
2014-06-25 20:14:25 +00:00
|
|
|
struct vnt_private *priv = usb_get_intfdata(intf);
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2014-06-25 20:14:25 +00:00
|
|
|
if (!priv)
|
2010-06-22 23:43:39 +00:00
|
|
|
return;
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2014-06-25 20:14:25 +00:00
|
|
|
ieee80211_unregister_hw(priv->hw);
|
|
|
|
|
2009-06-13 11:38:31 +00:00
|
|
|
usb_set_intfdata(intf, NULL);
|
2010-06-22 23:43:39 +00:00
|
|
|
usb_put_dev(interface_to_usbdev(intf));
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2014-06-25 20:14:25 +00:00
|
|
|
priv->flags |= DEVICE_FLAGS_UNPLUG;
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2014-06-25 20:14:25 +00:00
|
|
|
ieee80211_free_hw(priv->hw);
|
2009-06-13 11:38:31 +00:00
|
|
|
}
|
|
|
|
|
2014-06-25 20:14:25 +00:00
|
|
|
#ifdef CONFIG_PM
|
|
|
|
|
|
|
|
static int vt6656_suspend(struct usb_interface *intf, pm_message_t message)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int vt6656_resume(struct usb_interface *intf)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* CONFIG_PM */
|
|
|
|
|
2010-07-12 22:28:25 +00:00
|
|
|
static int device_xmit(struct sk_buff *skb, struct net_device *dev)
|
|
|
|
{
|
2012-12-10 21:59:10 +00:00
|
|
|
struct vnt_private *pDevice = netdev_priv(dev);
|
2010-07-12 22:28:25 +00:00
|
|
|
struct net_device_stats *stats = &pDevice->stats;
|
2014-05-15 21:49:21 +00:00
|
|
|
unsigned long flags;
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2014-05-15 21:49:21 +00:00
|
|
|
spin_lock_irqsave(&pDevice->lock, flags);
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2010-07-12 22:28:25 +00:00
|
|
|
netif_stop_queue(dev);
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2010-07-12 22:28:25 +00:00
|
|
|
if (!pDevice->bLinkPass) {
|
|
|
|
dev_kfree_skb_irq(skb);
|
|
|
|
goto out;
|
|
|
|
}
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2010-07-12 22:28:25 +00:00
|
|
|
if (pDevice->bStopDataPkt) {
|
|
|
|
dev_kfree_skb_irq(skb);
|
|
|
|
stats->tx_dropped++;
|
|
|
|
goto out;
|
|
|
|
}
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2014-04-30 20:31:12 +00:00
|
|
|
if (nsDMA_tx_packet(pDevice, skb)) {
|
2010-07-12 22:28:25 +00:00
|
|
|
if (netif_queue_stopped(dev))
|
|
|
|
netif_wake_queue(dev);
|
|
|
|
}
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2010-07-12 22:28:25 +00:00
|
|
|
out:
|
2014-05-15 21:49:21 +00:00
|
|
|
spin_unlock_irqrestore(&pDevice->lock, flags);
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2010-07-12 22:28:25 +00:00
|
|
|
return NETDEV_TX_OK;
|
2009-06-13 11:38:31 +00:00
|
|
|
}
|
|
|
|
|
2013-01-31 23:23:07 +00:00
|
|
|
/* find out the start position of str2 from str1 */
|
2010-05-18 00:34:01 +00:00
|
|
|
static unsigned char *kstrstr(const unsigned char *str1,
|
|
|
|
const unsigned char *str2) {
|
|
|
|
int str1_len = strlen(str1);
|
|
|
|
int str2_len = strlen(str2);
|
2009-06-13 11:38:31 +00:00
|
|
|
|
|
|
|
while (str1_len >= str2_len) {
|
|
|
|
str1_len--;
|
|
|
|
if(memcmp(str1,str2,str2_len)==0)
|
2010-05-18 00:34:01 +00:00
|
|
|
return (unsigned char *) str1;
|
2009-06-13 11:38:31 +00:00
|
|
|
str1++;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2010-05-18 00:34:01 +00:00
|
|
|
static int Config_FileGetParameter(unsigned char *string,
|
|
|
|
unsigned char *dest,
|
|
|
|
unsigned char *source)
|
2009-06-13 11:38:31 +00:00
|
|
|
{
|
2010-05-18 00:34:01 +00:00
|
|
|
unsigned char buf1[100];
|
|
|
|
unsigned char buf2[100];
|
|
|
|
unsigned char *start_p = NULL, *end_p = NULL, *tmp_p = NULL;
|
2009-06-13 11:38:31 +00:00
|
|
|
int ii;
|
|
|
|
|
|
|
|
memset(buf1,0,100);
|
|
|
|
strcat(buf1, string);
|
|
|
|
strcat(buf1, "=");
|
|
|
|
source+=strlen(buf1);
|
|
|
|
|
2013-01-31 23:23:07 +00:00
|
|
|
/* find target string start point */
|
2010-03-25 05:17:06 +00:00
|
|
|
start_p = kstrstr(source,buf1);
|
|
|
|
if (start_p == NULL)
|
2013-02-13 01:36:29 +00:00
|
|
|
return false;
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2013-01-31 23:23:07 +00:00
|
|
|
/* check if current config line is marked by "#" */
|
2010-05-20 02:50:00 +00:00
|
|
|
for (ii = 1; ; ii++) {
|
|
|
|
if (memcmp(start_p - ii, "\n", 1) == 0)
|
|
|
|
break;
|
|
|
|
if (memcmp(start_p - ii, "#", 1) == 0)
|
2013-02-13 01:36:29 +00:00
|
|
|
return false;
|
2010-05-20 02:50:00 +00:00
|
|
|
}
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2013-01-31 23:23:07 +00:00
|
|
|
/* find target string end point */
|
2010-03-25 05:17:06 +00:00
|
|
|
end_p = kstrstr(start_p,"\n");
|
2013-01-31 23:23:07 +00:00
|
|
|
if (end_p == NULL) { /* can't find "\n", but don't care */
|
|
|
|
end_p = start_p + strlen(start_p); /* no include "\n" */
|
|
|
|
}
|
2009-06-13 11:38:31 +00:00
|
|
|
|
|
|
|
memset(buf2,0,100);
|
2013-01-31 23:23:07 +00:00
|
|
|
memcpy(buf2, start_p, end_p-start_p); /* get the target line */
|
2009-06-13 11:38:31 +00:00
|
|
|
buf2[end_p-start_p]='\0';
|
|
|
|
|
2013-01-31 23:23:07 +00:00
|
|
|
/* find value */
|
2010-03-25 05:17:06 +00:00
|
|
|
start_p = kstrstr(buf2,"=");
|
|
|
|
if (start_p == NULL)
|
2013-02-13 01:36:29 +00:00
|
|
|
return false;
|
2009-06-13 11:38:31 +00:00
|
|
|
memset(buf1,0,100);
|
|
|
|
strcpy(buf1,start_p+1);
|
|
|
|
|
2013-01-31 23:23:07 +00:00
|
|
|
/* except space */
|
2009-06-13 11:38:31 +00:00
|
|
|
tmp_p = buf1;
|
|
|
|
while(*tmp_p != 0x00) {
|
|
|
|
if(*tmp_p==' ')
|
|
|
|
tmp_p++;
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
memcpy(dest,tmp_p,strlen(tmp_p));
|
2013-02-13 01:36:30 +00:00
|
|
|
return true;
|
2009-06-13 11:38:31 +00:00
|
|
|
}
|
|
|
|
|
2013-01-31 23:23:07 +00:00
|
|
|
/* if read fails, return NULL, or return data pointer */
|
2012-12-10 21:59:10 +00:00
|
|
|
static unsigned char *Config_FileOperation(struct vnt_private *pDevice)
|
2010-05-18 00:34:01 +00:00
|
|
|
{
|
2013-04-06 22:00:07 +00:00
|
|
|
unsigned char *buffer = kmalloc(1024, GFP_KERNEL);
|
|
|
|
struct file *file;
|
2013-01-31 23:23:07 +00:00
|
|
|
|
2013-04-06 22:00:07 +00:00
|
|
|
if (!buffer) {
|
|
|
|
printk("allocate mem for file fail?\n");
|
|
|
|
return NULL;
|
|
|
|
}
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2013-04-06 22:00:07 +00:00
|
|
|
file = filp_open(CONFIG_PATH, O_RDONLY, 0);
|
|
|
|
if (IS_ERR(file)) {
|
|
|
|
kfree(buffer);
|
|
|
|
printk("Config_FileOperation file Not exist\n");
|
|
|
|
return NULL;
|
|
|
|
}
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2013-04-06 22:00:07 +00:00
|
|
|
if (kernel_read(file, 0, buffer, 1024) < 0) {
|
|
|
|
printk("read file error?\n");
|
|
|
|
kfree(buffer);
|
|
|
|
buffer = NULL;
|
|
|
|
}
|
2009-06-13 11:38:47 +00:00
|
|
|
|
2013-04-06 22:00:07 +00:00
|
|
|
fput(file);
|
|
|
|
return buffer;
|
2009-06-13 11:38:31 +00:00
|
|
|
}
|
|
|
|
|
2013-01-31 23:23:07 +00:00
|
|
|
/* return --->-1:fail; >=0:successful */
|
2012-12-10 21:59:10 +00:00
|
|
|
static int Read_config_file(struct vnt_private *pDevice)
|
|
|
|
{
|
|
|
|
int result = 0;
|
|
|
|
unsigned char tmpbuffer[100];
|
|
|
|
unsigned char *buffer = NULL;
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2013-01-31 23:23:07 +00:00
|
|
|
/* init config setting */
|
2009-06-13 11:38:31 +00:00
|
|
|
pDevice->config_file.ZoneType = -1;
|
|
|
|
pDevice->config_file.eAuthenMode = -1;
|
|
|
|
pDevice->config_file.eEncryptionStatus = -1;
|
|
|
|
|
2010-03-25 05:17:06 +00:00
|
|
|
buffer = Config_FileOperation(pDevice);
|
|
|
|
if (buffer == NULL) {
|
2009-06-13 11:38:31 +00:00
|
|
|
result =-1;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-01-31 23:23:07 +00:00
|
|
|
/* get zonetype */
|
2009-06-13 11:38:31 +00:00
|
|
|
{
|
|
|
|
memset(tmpbuffer,0,sizeof(tmpbuffer));
|
2013-02-13 01:36:30 +00:00
|
|
|
if(Config_FileGetParameter("ZONETYPE",tmpbuffer,buffer) ==true) {
|
2009-06-13 11:38:31 +00:00
|
|
|
if(memcmp(tmpbuffer,"USA",3)==0) {
|
|
|
|
pDevice->config_file.ZoneType=ZoneType_USA;
|
|
|
|
}
|
|
|
|
else if(memcmp(tmpbuffer,"JAPAN",5)==0) {
|
|
|
|
pDevice->config_file.ZoneType=ZoneType_Japan;
|
|
|
|
}
|
|
|
|
else if(memcmp(tmpbuffer,"EUROPE",6)==0) {
|
|
|
|
pDevice->config_file.ZoneType=ZoneType_Europe;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
printk("Unknown Zonetype[%s]?\n",tmpbuffer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-31 23:23:07 +00:00
|
|
|
/* get other parameter */
|
2009-06-13 11:38:31 +00:00
|
|
|
{
|
|
|
|
memset(tmpbuffer,0,sizeof(tmpbuffer));
|
2013-02-13 01:36:30 +00:00
|
|
|
if(Config_FileGetParameter("AUTHENMODE",tmpbuffer,buffer)==true) {
|
2009-06-13 11:38:31 +00:00
|
|
|
pDevice->config_file.eAuthenMode = (int) simple_strtol(tmpbuffer, NULL, 10);
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(tmpbuffer,0,sizeof(tmpbuffer));
|
2013-02-13 01:36:30 +00:00
|
|
|
if(Config_FileGetParameter("ENCRYPTIONMODE",tmpbuffer,buffer)==true) {
|
2009-06-13 11:38:31 +00:00
|
|
|
pDevice->config_file.eEncryptionStatus= (int) simple_strtol(tmpbuffer, NULL, 10);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
kfree(buffer);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2012-12-10 21:59:10 +00:00
|
|
|
static void device_set_multi(struct net_device *dev)
|
|
|
|
{
|
2014-02-12 19:22:37 +00:00
|
|
|
struct vnt_private *priv = netdev_priv(dev);
|
2014-02-19 19:34:18 +00:00
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
if (priv->flags & DEVICE_FLAGS_OPENED) {
|
|
|
|
spin_lock_irqsave(&priv->lock, flags);
|
|
|
|
|
|
|
|
bScheduleCommand(priv, WLAN_CMD_CONFIGURE_FILTER, NULL);
|
|
|
|
|
|
|
|
spin_unlock_irqrestore(&priv->lock, flags);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void vnt_configure_filter(struct vnt_private *priv)
|
|
|
|
{
|
|
|
|
struct net_device *dev = priv->dev;
|
2014-02-12 19:22:37 +00:00
|
|
|
struct vnt_manager *mgmt = &priv->vnt_mgmt;
|
2012-12-10 21:59:10 +00:00
|
|
|
struct netdev_hw_addr *ha;
|
2014-02-12 19:18:26 +00:00
|
|
|
u64 mc_filter = 0;
|
2014-02-12 19:22:37 +00:00
|
|
|
u8 tmp = 0;
|
2012-12-10 21:59:10 +00:00
|
|
|
int rc;
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2014-05-26 12:59:02 +00:00
|
|
|
rc = vnt_control_in(priv, MESSAGE_TYPE_READ,
|
2014-02-12 19:22:37 +00:00
|
|
|
MAC_REG_RCR, MESSAGE_REQUEST_MACREG, 1, &tmp);
|
|
|
|
if (rc == 0)
|
|
|
|
priv->byRxMode = tmp;
|
|
|
|
|
|
|
|
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "priv->byRxMode in= %x\n",
|
|
|
|
priv->byRxMode);
|
|
|
|
|
|
|
|
if (dev->flags & IFF_PROMISC) { /* set promiscuous mode */
|
|
|
|
DBG_PRT(MSG_LEVEL_ERR, KERN_NOTICE
|
|
|
|
"%s: Promiscuous mode enabled.\n", dev->name);
|
|
|
|
/* unconditionally log net taps */
|
|
|
|
priv->byRxMode |= (RCR_MULTICAST|RCR_BROADCAST|RCR_UNICAST);
|
|
|
|
} else if ((netdev_mc_count(dev) > priv->multicast_limit) ||
|
|
|
|
(dev->flags & IFF_ALLMULTI)) {
|
|
|
|
mc_filter = ~0x0;
|
2014-05-31 10:50:36 +00:00
|
|
|
vnt_mac_set_filter(priv, mc_filter);
|
2014-02-12 19:22:37 +00:00
|
|
|
|
|
|
|
priv->byRxMode |= (RCR_MULTICAST|RCR_BROADCAST);
|
|
|
|
} else {
|
|
|
|
netdev_for_each_mc_addr(ha, dev) {
|
|
|
|
int bit_nr = ether_crc(ETH_ALEN, ha->addr) >> 26;
|
2014-02-12 19:18:26 +00:00
|
|
|
|
2014-02-12 19:22:37 +00:00
|
|
|
mc_filter |= 1ULL << (bit_nr & 0x3f);
|
|
|
|
}
|
|
|
|
|
2014-05-31 10:50:36 +00:00
|
|
|
vnt_mac_set_filter(priv, mc_filter);
|
2014-02-12 19:22:37 +00:00
|
|
|
|
|
|
|
priv->byRxMode &= ~(RCR_UNICAST);
|
|
|
|
priv->byRxMode |= (RCR_MULTICAST|RCR_BROADCAST);
|
2014-02-12 19:18:26 +00:00
|
|
|
}
|
|
|
|
|
2014-02-12 19:22:37 +00:00
|
|
|
if (mgmt->eConfigMode == WMAC_CONFIG_AP) {
|
|
|
|
/*
|
|
|
|
* If AP mode, don't enable RCR_UNICAST since HW only compares
|
|
|
|
* addr1 with local MAC
|
|
|
|
*/
|
|
|
|
priv->byRxMode |= (RCR_MULTICAST|RCR_BROADCAST);
|
|
|
|
priv->byRxMode &= ~(RCR_UNICAST);
|
|
|
|
}
|
2014-02-12 19:18:26 +00:00
|
|
|
|
2014-05-26 12:59:03 +00:00
|
|
|
vnt_control_out_u8(priv, MESSAGE_REQUEST_MACREG,
|
2014-02-12 19:22:37 +00:00
|
|
|
MAC_REG_RCR, priv->byRxMode);
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2014-02-12 19:22:37 +00:00
|
|
|
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO
|
|
|
|
"priv->byRxMode out= %x\n", priv->byRxMode);
|
2009-06-13 11:38:31 +00:00
|
|
|
}
|
|
|
|
|
2012-11-24 14:44:29 +00:00
|
|
|
static struct net_device_stats *device_get_stats(struct net_device *dev)
|
|
|
|
{
|
2012-12-10 21:59:10 +00:00
|
|
|
struct vnt_private *pDevice = netdev_priv(dev);
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2012-12-10 21:59:10 +00:00
|
|
|
return &pDevice->stats;
|
2009-06-13 11:38:31 +00:00
|
|
|
}
|
|
|
|
|
2012-11-24 14:44:29 +00:00
|
|
|
static int device_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
|
|
|
|
{
|
2012-11-13 21:04:36 +00:00
|
|
|
int rc = 0;
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2012-11-24 14:44:29 +00:00
|
|
|
switch (cmd) {
|
2009-06-13 11:38:31 +00:00
|
|
|
case SIOCETHTOOL:
|
2014-01-13 16:21:09 +00:00
|
|
|
return ethtool_ioctl(dev, rq);
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2012-11-24 14:44:29 +00:00
|
|
|
}
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2012-11-24 14:44:29 +00:00
|
|
|
return rc;
|
2009-06-13 11:38:31 +00:00
|
|
|
}
|
|
|
|
|
2014-01-13 16:21:09 +00:00
|
|
|
static int ethtool_ioctl(struct net_device *dev, struct ifreq *rq)
|
2009-06-13 11:38:31 +00:00
|
|
|
{
|
|
|
|
u32 ethcmd;
|
|
|
|
|
2014-01-13 16:21:09 +00:00
|
|
|
if (copy_from_user(ðcmd, rq->ifr_data, sizeof(ethcmd)))
|
2009-06-13 11:38:31 +00:00
|
|
|
return -EFAULT;
|
|
|
|
|
|
|
|
switch (ethcmd) {
|
|
|
|
case ETHTOOL_GDRVINFO: {
|
|
|
|
struct ethtool_drvinfo info = {ETHTOOL_GDRVINFO};
|
|
|
|
strncpy(info.driver, DEVICE_NAME, sizeof(info.driver)-1);
|
|
|
|
strncpy(info.version, DEVICE_VERSION, sizeof(info.version)-1);
|
2014-01-13 16:21:09 +00:00
|
|
|
if (copy_to_user(rq->ifr_data, &info, sizeof(info)))
|
2009-06-13 11:38:31 +00:00
|
|
|
return -EFAULT;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
|
2010-04-13 22:43:07 +00:00
|
|
|
MODULE_DEVICE_TABLE(usb, vt6656_table);
|
2009-06-13 11:38:31 +00:00
|
|
|
|
2010-04-13 22:43:07 +00:00
|
|
|
static struct usb_driver vt6656_driver = {
|
|
|
|
.name = DEVICE_NAME,
|
|
|
|
.probe = vt6656_probe,
|
|
|
|
.disconnect = vt6656_disconnect,
|
|
|
|
.id_table = vt6656_table,
|
2009-06-13 11:38:31 +00:00
|
|
|
#ifdef CONFIG_PM
|
2010-04-13 22:43:07 +00:00
|
|
|
.suspend = vt6656_suspend,
|
|
|
|
.resume = vt6656_resume,
|
|
|
|
#endif /* CONFIG_PM */
|
2009-06-13 11:38:31 +00:00
|
|
|
};
|
|
|
|
|
2011-11-18 17:42:11 +00:00
|
|
|
module_usb_driver(vt6656_driver);
|