/*
* Copyright (c) 2007-2008 Atheros Communications Inc.
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* Module Name : wwrap.c */
/* Abstract */
/* This module contains wrapper functions. */
/* */
/* NOTES */
/* Platform dependent. */
/* */
/* Please include your header files here */
#include "oal_dt.h"
#include "usbdrv.h"
#include <linux/netlink.h>
#include <linux/slab.h>
#include <net/iw_handler.h>
extern void zfiRecv80211(zdev_t* dev, zbuf_t* buf, struct zsAdditionInfo* addInfo);
extern void zfCoreRecv(zdev_t* dev, zbuf_t* buf, struct zsAdditionInfo* addInfo);
extern void zfIdlChkRsp(zdev_t* dev, u32_t* rsp, u16_t rspLen);
extern void zfIdlRsp(zdev_t* dev, u32_t *rsp, u16_t rspLen);
//extern struct zsWdsStruct wds[ZM_WDS_PORT_NUMBER];
extern struct zsVapStruct vap[ZM_VAP_PORT_NUMBER];
u32_t zfLnxUsbSubmitTxData(zdev_t* dev);
u32_t zfLnxUsbIn(zdev_t* dev, urb_t *urb, zbuf_t *buf);
u32_t zfLnxSubmitRegInUrb(zdev_t *dev);
u32_t zfLnxUsbSubmitBulkUrb(urb_t *urb, struct usb_device *usb, u16_t epnum, u16_t direction,
void *transfer_buffer, int buffer_length, usb_complete_t complete, void *context);
u32_t zfLnxUsbSubmitIntUrb(urb_t *urb, struct usb_device *usb, u16_t epnum, u16_t direction,
void *transfer_buffer, int buffer_length, usb_complete_t complete, void *context,
u32_t interval);
u16_t zfLnxGetFreeTxUrb(zdev_t *dev)
{
struct usbdrv_private *macp = dev->ml_priv;
u16_t idx;
unsigned long irqFlag;
spin_lock_irqsave(&macp->cs_lock, irqFlag);
//idx = ((macp->TxUrbTail + 1) & (ZM_MAX_TX_URB_NUM - 1));
//if (idx != macp->TxUrbHead)
if (macp->TxUrbCnt != 0)
{
idx = macp->TxUrbTail;
macp->TxUrbTail = ((macp->TxUrbTail + 1) & (ZM_MAX_TX_URB_NUM - 1));
macp->TxUrbCnt--;
}
else
{
//printk(KERN_ERR "macp->TxUrbCnt: %d\n", macp->TxUrbCnt);
idx = 0xffff;
}
spin_unlock_irqrestore(&macp->cs_lock, irqFlag);
return idx;
}
void zfLnxPutTxUrb(zdev_t *dev)
{
struct usbdrv_private *macp = dev->ml_priv;
u16_t idx;
unsigned long irqFlag;
spin_lock_irqsave(&macp->cs_lock, irqFlag);
idx = ((macp->TxUrbHead + 1) & (ZM_MAX_TX_URB_NUM - 1));
//if (idx != macp->TxUrbTail)
if (macp->TxUrbCnt < ZM_MAX_TX_URB_NUM)
{
macp->TxUrbHead = idx;
macp->TxUrbCnt++;
}
else
{
printk("UsbTxUrbQ inconsistent: TxUrbHead: %d, TxUrbTail: %d\n",
macp->TxUrbHead, macp->TxUrbTail);
}
spin_unlock_irqrestore(&macp->cs_lock, irqFlag);
}
u16_t zfLnxCheckTxBufferCnt(zdev_t *dev)
{
struct usbdrv_private *macp = dev->ml_priv;
u16_t TxBufCnt;
unsigned long irqFlag;
spin_lock_irqsave(&macp->cs_lock, irqFlag);
TxBufCnt = macp->TxBufCnt;
spin_unlock_irqrestore(&macp->cs_lock, irqFlag