diff options
Diffstat (limited to 'drivers/staging/vt6656/main_usb.c')
-rw-r--r-- | drivers/staging/vt6656/main_usb.c | 350 |
1 files changed, 180 insertions, 170 deletions
diff --git a/drivers/staging/vt6656/main_usb.c b/drivers/staging/vt6656/main_usb.c index 58edcae74efc..3c9323069e01 100644 --- a/drivers/staging/vt6656/main_usb.c +++ b/drivers/staging/vt6656/main_usb.c @@ -256,7 +256,7 @@ device_set_options(struct vnt_private *pDevice) { pDevice->byShortPreamble = PREAMBLE_TYPE_DEF; pDevice->ePSMode = PS_MODE_DEF; pDevice->b11hEnable = X80211h_MODE_DEF; - pDevice->eOPMode = OP_MODE_DEF; + pDevice->op_mode = NL80211_IFTYPE_UNSPECIFIED; pDevice->uConnectionRate = DATA_RATE_DEF; if (pDevice->uConnectionRate < RATE_AUTO) pDevice->bFixRate = true; pDevice->byBBType = BBP_TYPE_DEF; @@ -409,7 +409,7 @@ static int device_init_registers(struct vnt_private *pDevice) if (pDevice->abyCCKPwrTbl[ii] == 0) pDevice->abyCCKPwrTbl[ii] = pDevice->byCCKPwr; - pDevice->abyOFDMPwrTbl[ii] = + pDevice->abyOFDMPwrTbl[ii] = pDevice->abyEEPROM[ii + EEP_OFS_OFDM_PWR_TBL]; if (pDevice->abyOFDMPwrTbl[ii] == 0) pDevice->abyOFDMPwrTbl[ii] = pDevice->byOFDMPwrG; @@ -749,44 +749,47 @@ err_nomem: return rc; } -static void device_free_tx_bufs(struct vnt_private *pDevice) +static void device_free_tx_bufs(struct vnt_private *priv) { - struct vnt_usb_send_context *pTxContext; - int ii; + struct vnt_usb_send_context *tx_context; + int ii; - for (ii = 0; ii < pDevice->cbTD; ii++) { + for (ii = 0; ii < priv->cbTD; ii++) { + tx_context = priv->apTD[ii]; + /* deallocate URBs */ + if (tx_context->pUrb) { + usb_kill_urb(tx_context->pUrb); + usb_free_urb(tx_context->pUrb); + } - pTxContext = pDevice->apTD[ii]; - /* deallocate URBs */ - if (pTxContext->pUrb) { - usb_kill_urb(pTxContext->pUrb); - usb_free_urb(pTxContext->pUrb); - } - kfree(pTxContext); - } - return; + kfree(tx_context); + } + + return; } -static void device_free_rx_bufs(struct vnt_private *pDevice) +static void device_free_rx_bufs(struct vnt_private *priv) { - struct vnt_rcb *pRCB; + struct vnt_rcb *rcb; int ii; - for (ii = 0; ii < pDevice->cbRD; ii++) { + for (ii = 0; ii < priv->cbRD; ii++) { + rcb = priv->apRCB[ii]; - pRCB = pDevice->apRCB[ii]; - /* deallocate URBs */ - if (pRCB->pUrb) { - usb_kill_urb(pRCB->pUrb); - usb_free_urb(pRCB->pUrb); - } - /* deallocate skb */ - if (pRCB->skb) - dev_kfree_skb(pRCB->skb); - } - kfree(pDevice->pRCBMem); + /* deallocate URBs */ + if (rcb->pUrb) { + usb_kill_urb(rcb->pUrb); + usb_free_urb(rcb->pUrb); + } - return; + /* deallocate skb */ + if (rcb->skb) + dev_kfree_skb(rcb->skb); + } + + kfree(priv->pRCBMem); + + return; } static void usb_device_reset(struct vnt_private *pDevice) @@ -798,95 +801,109 @@ static void usb_device_reset(struct vnt_private *pDevice) return ; } -static void device_free_int_bufs(struct vnt_private *pDevice) +static void device_free_int_bufs(struct vnt_private *priv) { - kfree(pDevice->intBuf.pDataBuf); - return; + kfree(priv->int_buf.data_buf); + + return; } -static bool device_alloc_bufs(struct vnt_private *pDevice) +static bool device_alloc_bufs(struct vnt_private *priv) { - struct vnt_usb_send_context *pTxContext; - struct vnt_rcb *pRCB; + struct vnt_usb_send_context *tx_context; + struct vnt_rcb *rcb; int ii; - for (ii = 0; ii < pDevice->cbTD; ii++) { + 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; + } - pTxContext = kmalloc(sizeof(struct vnt_usb_send_context), GFP_KERNEL); - if (pTxContext == NULL) { - DBG_PRT(MSG_LEVEL_ERR,KERN_ERR "%s : allocate tx usb context failed\n", pDevice->dev->name); - goto free_tx; - } - pDevice->apTD[ii] = pTxContext; - pTxContext->pDevice = (void *) pDevice; - /* allocate URBs */ - pTxContext->pUrb = usb_alloc_urb(0, GFP_ATOMIC); - if (pTxContext->pUrb == NULL) { - DBG_PRT(MSG_LEVEL_ERR,KERN_ERR "alloc tx urb failed\n"); - goto free_tx; - } - pTxContext->bBoolInUse = false; - } + priv->apTD[ii] = tx_context; + tx_context->pDevice = priv; + + /* allocate URBs */ + tx_context->pUrb = usb_alloc_urb(0, GFP_ATOMIC); + if (tx_context->pUrb == NULL) { + DBG_PRT(MSG_LEVEL_ERR, + KERN_ERR "alloc tx urb failed\n"); + goto free_tx; + } + + tx_context->bBoolInUse = false; + } - /* allocate RCB mem */ - pDevice->pRCBMem = kzalloc((sizeof(struct vnt_rcb) * pDevice->cbRD), + /* allocate RCB mem */ + priv->pRCBMem = kzalloc((sizeof(struct vnt_rcb) * priv->cbRD), GFP_KERNEL); - if (pDevice->pRCBMem == NULL) { - DBG_PRT(MSG_LEVEL_ERR,KERN_ERR "%s : alloc rx usb context failed\n", pDevice->dev->name); - goto free_tx; - } + if (priv->pRCBMem == NULL) { + DBG_PRT(MSG_LEVEL_ERR, KERN_ERR + "%s : alloc rx usb context failed\n", + priv->dev->name); + goto free_tx; + } - pDevice->FirstRecvFreeList = NULL; - pDevice->LastRecvFreeList = NULL; - pDevice->FirstRecvMngList = NULL; - pDevice->LastRecvMngList = NULL; - pDevice->NumRecvFreeList = 0; + priv->FirstRecvFreeList = NULL; + priv->LastRecvFreeList = NULL; + priv->FirstRecvMngList = NULL; + priv->LastRecvMngList = NULL; + priv->NumRecvFreeList = 0; - pRCB = (struct vnt_rcb *)pDevice->pRCBMem; + rcb = (struct vnt_rcb *)priv->pRCBMem; - for (ii = 0; ii < pDevice->cbRD; ii++) { + for (ii = 0; ii < priv->cbRD; ii++) { + priv->apRCB[ii] = rcb; + rcb->pDevice = priv; - pDevice->apRCB[ii] = pRCB; - pRCB->pDevice = (void *) pDevice; - /* allocate URBs */ - pRCB->pUrb = usb_alloc_urb(0, GFP_ATOMIC); + /* 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; + } - if (pRCB->pUrb == NULL) { - DBG_PRT(MSG_LEVEL_ERR,KERN_ERR" Failed to alloc rx urb\n"); - goto free_rx_tx; - } - pRCB->skb = dev_alloc_skb((int)pDevice->rx_buf_sz); - if (pRCB->skb == NULL) { - DBG_PRT(MSG_LEVEL_ERR,KERN_ERR" Failed to alloc rx skb\n"); - goto free_rx_tx; - } - pRCB->skb->dev = pDevice->dev; - pRCB->bBoolInUse = false; - EnqueueRCB(pDevice->FirstRecvFreeList, pDevice->LastRecvFreeList, pRCB); - pDevice->NumRecvFreeList++; - pRCB++; - } + rcb->skb = netdev_alloc_skb(priv->dev, priv->rx_buf_sz); + if (rcb->skb == NULL) { + DBG_PRT(MSG_LEVEL_ERR, KERN_ERR + " Failed to alloc rx skb\n"); + goto free_rx_tx; + } + + rcb->bBoolInUse = false; + + EnqueueRCB(priv->FirstRecvFreeList, + priv->LastRecvFreeList, rcb); - pDevice->pInterruptURB = usb_alloc_urb(0, GFP_ATOMIC); - if (pDevice->pInterruptURB == NULL) { - DBG_PRT(MSG_LEVEL_ERR,KERN_ERR"Failed to alloc int urb\n"); - goto free_rx_tx; + priv->NumRecvFreeList++; + rcb++; } - pDevice->intBuf.pDataBuf = kmalloc(MAX_INTERRUPT_SIZE, GFP_KERNEL); - if (pDevice->intBuf.pDataBuf == NULL) { - DBG_PRT(MSG_LEVEL_ERR,KERN_ERR"Failed to alloc int buf\n"); - usb_free_urb(pDevice->pInterruptURB); - goto free_rx_tx; + 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; } - return true; + 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; free_rx_tx: - device_free_rx_bufs(pDevice); + device_free_rx_bufs(priv); free_tx: - device_free_tx_bufs(pDevice); + device_free_tx_bufs(priv); return false; } @@ -931,13 +948,11 @@ static void device_free_frag_bufs(struct vnt_private *pDevice) int device_alloc_frag_buf(struct vnt_private *pDevice, PSDeFragControlBlock pDeF) { + pDeF->skb = netdev_alloc_skb(pDevice->dev, pDevice->rx_buf_sz); + if (!pDeF->skb) + return false; - pDeF->skb = dev_alloc_skb((int)pDevice->rx_buf_sz); - if (pDeF->skb == NULL) - return false; - pDeF->skb->dev = pDevice->dev; - - return true; + return true; } static int device_open(struct net_device *dev) @@ -974,8 +989,6 @@ static int device_open(struct net_device *dev) goto free_all; } - device_set_multi(pDevice->dev); - /* init for key management */ KeyvInitTable(pDevice,&pDevice->sKey); memcpy(pDevice->vnt_mgmt.abyMACAddr, @@ -992,16 +1005,12 @@ static int device_open(struct net_device *dev) vMgrObjectInit(pDevice); - tasklet_init(&pDevice->EventWorkItem, (void *)INTvWorkItem, (unsigned long)pDevice); - schedule_delayed_work(&pDevice->second_callback_work, HZ); - pDevice->int_interval = 100; /* max 100 microframes */ + pDevice->int_interval = 1; /* bInterval is set to 1 */ pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled; pDevice->bIsRxWorkItemQueued = true; - pDevice->fKillEventPollingThread = false; - pDevice->bEventAvailable = false; pDevice->bWPADEVUp = false; pDevice->bwextstep0 = false; @@ -1084,7 +1093,6 @@ static int device_close(struct net_device *dev) MP_SET_FLAG(pDevice, fMP_DISCONNECTED); MP_CLEAR_FLAG(pDevice, fMP_POST_WRITES); MP_CLEAR_FLAG(pDevice, fMP_POST_READS); - pDevice->fKillEventPollingThread = true; cancel_delayed_work_sync(&pDevice->run_command_work); cancel_delayed_work_sync(&pDevice->second_callback_work); @@ -1098,8 +1106,6 @@ static int device_close(struct net_device *dev) cancel_work_sync(&pDevice->rx_mng_work_item); cancel_work_sync(&pDevice->read_work_item); - tasklet_kill(&pDevice->EventWorkItem); - pDevice->bRoaming = false; pDevice->bIsRoaming = false; pDevice->bEnableRoaming = false; @@ -1350,69 +1356,73 @@ static int Read_config_file(struct vnt_private *pDevice) static void device_set_multi(struct net_device *dev) { - struct vnt_private *pDevice = netdev_priv(dev); - struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; + struct vnt_private *priv = netdev_priv(dev); + 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; + struct vnt_manager *mgmt = &priv->vnt_mgmt; struct netdev_hw_addr *ha; - u32 mc_filter[2]; - int ii; - u8 pbyData[8] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; - u8 byTmpMode = 0; + u64 mc_filter = 0; + u8 tmp = 0; int rc; - spin_lock_irq(&pDevice->lock); - rc = CONTROLnsRequestIn(pDevice, - MESSAGE_TYPE_READ, - MAC_REG_RCR, - MESSAGE_REQUEST_MACREG, - 1, - &byTmpMode - ); - if (rc == 0) pDevice->byRxMode = byTmpMode; - - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pDevice->byRxMode in= %x\n", pDevice->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 */ - pDevice->byRxMode |= (RCR_MULTICAST|RCR_BROADCAST|RCR_UNICAST); - } - else if ((netdev_mc_count(dev) > pDevice->multicast_limit) || - (dev->flags & IFF_ALLMULTI)) { - CONTROLnsRequestOut(pDevice, - MESSAGE_TYPE_WRITE, - MAC_REG_MAR0, - MESSAGE_REQUEST_MACREG, - 8, - pbyData - ); - pDevice->byRxMode |= (RCR_MULTICAST|RCR_BROADCAST); - } - else { - memset(mc_filter, 0, sizeof(mc_filter)); - netdev_for_each_mc_addr(ha, dev) { - int bit_nr = ether_crc(ETH_ALEN, ha->addr) >> 26; - mc_filter[bit_nr >> 5] |= cpu_to_le32(1 << (bit_nr & 31)); - } - for (ii = 0; ii < 4; ii++) { - MACvWriteMultiAddr(pDevice, ii, *((u8 *)&mc_filter[0] + ii)); - MACvWriteMultiAddr(pDevice, ii+ 4, *((u8 *)&mc_filter[1] + ii)); - } - pDevice->byRxMode &= ~(RCR_UNICAST); - pDevice->byRxMode |= (RCR_MULTICAST|RCR_BROADCAST); - } + rc = CONTROLnsRequestIn(priv, MESSAGE_TYPE_READ, + 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; + MACvWriteMultiAddr(priv, mc_filter); + + priv->byRxMode |= (RCR_MULTICAST|RCR_BROADCAST); + } else { + netdev_for_each_mc_addr(ha, dev) { + int bit_nr = ether_crc(ETH_ALEN, ha->addr) >> 26; - if (pMgmt->eConfigMode == WMAC_CONFIG_AP) { - /* - * If AP mode, don't enable RCR_UNICAST since HW only compares - * addr1 with local MAC - */ - pDevice->byRxMode |= (RCR_MULTICAST|RCR_BROADCAST); - pDevice->byRxMode &= ~(RCR_UNICAST); - } - ControlvWriteByte(pDevice, MESSAGE_REQUEST_MACREG, MAC_REG_RCR, pDevice->byRxMode); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pDevice->byRxMode out= %x\n", pDevice->byRxMode); - spin_unlock_irq(&pDevice->lock); + mc_filter |= 1ULL << (bit_nr & 0x3f); + } + + MACvWriteMultiAddr(priv, mc_filter); + + priv->byRxMode &= ~(RCR_UNICAST); + priv->byRxMode |= (RCR_MULTICAST|RCR_BROADCAST); + } + + 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); + } + + ControlvWriteByte(priv, MESSAGE_REQUEST_MACREG, + MAC_REG_RCR, priv->byRxMode); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO + "priv->byRxMode out= %x\n", priv->byRxMode); } static struct net_device_stats *device_get_stats(struct net_device *dev) |