#include "wilc_wfi_netdevice.h"
#include "wilc_wlan_cfg.h"
-typedef struct {
- int quit;
- int cfg_frame_in_use;
- struct wilc_cfg_frame cfg_frame;
- u32 cfg_frame_offset;
- int cfg_seq_no;
-
- u8 *rx_buffer;
- u32 rx_buffer_offset;
- u8 *tx_buffer;
-
- unsigned long txq_spinlock_flags;
-
- struct txq_entry_t *txq_head;
- struct txq_entry_t *txq_tail;
- int txq_entries;
- int txq_exit;
-
- struct rxq_entry_t *rxq_head;
- struct rxq_entry_t *rxq_tail;
- int rxq_entries;
- int rxq_exit;
-} wilc_wlan_dev_t;
-
-static wilc_wlan_dev_t g_wlan;
-
#ifdef WILC_OPTIMIZE_SLEEP_INT
static inline void chip_allow_sleep(struct wilc *wilc);
#endif
#ifdef TCP_ACK_FILTER
static void wilc_wlan_txq_remove(struct txq_entry_t *tqe)
{
- wilc_wlan_dev_t *p = &g_wlan;
-
- if (tqe == p->txq_head) {
- p->txq_head = tqe->next;
- if (p->txq_head)
- p->txq_head->prev = NULL;
- } else if (tqe == p->txq_tail) {
- p->txq_tail = (tqe->prev);
- if (p->txq_tail)
- p->txq_tail->next = NULL;
+
+ if (tqe == wilc->txq_head) {
+ wilc->txq_head = tqe->next;
+ if (wilc->txq_head)
+ wilc->txq_head->prev = NULL;
+ } else if (tqe == wilc->txq_tail) {
+ wilc->txq_tail = (tqe->prev);
+ if (wilc->txq_tail)
+ wilc->txq_tail->next = NULL;
} else {
tqe->prev->next = tqe->next;
tqe->next->prev = tqe->prev;
}
- p->txq_entries -= 1;
+ wilc->txq_entries -= 1;
}
#endif
wilc_wlan_txq_remove_from_head(struct net_device *dev)
{
struct txq_entry_t *tqe;
- wilc_wlan_dev_t *p = &g_wlan;
unsigned long flags;
perInterface_wlan_t *nic;
struct wilc *wilc;
wilc = nic->wilc;
spin_lock_irqsave(&wilc->txq_spinlock, flags);
- if (p->txq_head) {
- tqe = p->txq_head;
- p->txq_head = tqe->next;
- if (p->txq_head)
- p->txq_head->prev = NULL;
+ if (wilc->txq_head) {
+ tqe = wilc->txq_head;
+ wilc->txq_head = tqe->next;
+ if (wilc->txq_head)
+ wilc->txq_head->prev = NULL;
- p->txq_entries -= 1;
+ wilc->txq_entries -= 1;
} else {
tqe = NULL;
}
static void wilc_wlan_txq_add_to_tail(struct net_device *dev,
struct txq_entry_t *tqe)
{
- wilc_wlan_dev_t *p = &g_wlan;
unsigned long flags;
perInterface_wlan_t *nic;
struct wilc *wilc;
spin_lock_irqsave(&wilc->txq_spinlock, flags);
- if (!p->txq_head) {
+ if (!wilc->txq_head) {
tqe->next = NULL;
tqe->prev = NULL;
- p->txq_head = tqe;
- p->txq_tail = tqe;
+ wilc->txq_head = tqe;
+ wilc->txq_tail = tqe;
} else {
tqe->next = NULL;
- tqe->prev = p->txq_tail;
- p->txq_tail->next = tqe;
- p->txq_tail = tqe;
+ tqe->prev = wilc->txq_tail;
+ wilc->txq_tail->next = tqe;
+ wilc->txq_tail = tqe;
}
- p->txq_entries += 1;
- PRINT_D(TX_DBG, "Number of entries in TxQ = %d\n", p->txq_entries);
+ wilc->txq_entries += 1;
+ PRINT_D(TX_DBG, "Number of entries in TxQ = %d\n", wilc->txq_entries);
spin_unlock_irqrestore(&wilc->txq_spinlock, flags);
static int wilc_wlan_txq_add_to_head(struct wilc *wilc, struct txq_entry_t *tqe)
{
- wilc_wlan_dev_t *p = &g_wlan;
unsigned long flags;
if (wilc_lock_timeout(wilc, &wilc->txq_add_to_head_cs,
CFG_PKTS_TIMEOUT))
spin_lock_irqsave(&wilc->txq_spinlock, flags);
- if (!p->txq_head) {
+ if (!wilc->txq_head) {
tqe->next = NULL;
tqe->prev = NULL;
- p->txq_head = tqe;
- p->txq_tail = tqe;
+ wilc->txq_head = tqe;
+ wilc->txq_tail = tqe;
} else {
- tqe->next = p->txq_head;
+ tqe->next = wilc->txq_head;
tqe->prev = NULL;
- p->txq_head->prev = tqe;
- p->txq_head = tqe;
+ wilc->txq_head->prev = tqe;
+ wilc->txq_head = tqe;
}
- p->txq_entries += 1;
- PRINT_D(TX_DBG, "Number of entries in TxQ = %d\n", p->txq_entries);
+ wilc->txq_entries += 1;
+ PRINT_D(TX_DBG, "Number of entries in TxQ = %d\n", wilc->txq_entries);
spin_unlock_irqrestore(&wilc->txq_spinlock, flags);
up(&wilc->txq_add_to_head_cs);
}
static inline int remove_TCP_related(struct wilc *wilc)
{
- wilc_wlan_dev_t *p = &g_wlan;
unsigned long flags;
spin_lock_irqsave(&wilc->txq_spinlock, flags);
u8 *buffer = tqe->buffer;
unsigned short h_proto;
int i;
- wilc_wlan_dev_t *p = &g_wlan;
unsigned long flags;
perInterface_wlan_t *nic;
struct wilc *wilc;
struct wilc *wilc;
u32 i = 0;
u32 dropped = 0;
- wilc_wlan_dev_t *p = &g_wlan;
nic = netdev_priv(dev);
wilc = nic->wilc;
- spin_lock_irqsave(&wilc->txq_spinlock, p->txq_spinlock_flags);
+ spin_lock_irqsave(&wilc->txq_spinlock, wilc->txq_spinlock_flags);
for (i = pending_base; i < (pending_base + pending_acks); i++) {
if (pending_acks_info[i].ack_num < ack_session_info[pending_acks_info[i].session_index].bigger_ack_num) {
struct txq_entry_t *tqe;
else
pending_base = 0;
- spin_unlock_irqrestore(&wilc->txq_spinlock, p->txq_spinlock_flags);
+ spin_unlock_irqrestore(&wilc->txq_spinlock, wilc->txq_spinlock_flags);
while (dropped > 0) {
wilc_lock_timeout(wilc, &wilc->txq_event, 1);
static int wilc_wlan_txq_add_cfg_pkt(struct wilc *wilc, u8 *buffer, u32 buffer_size)
{
- wilc_wlan_dev_t *p = &g_wlan;
struct txq_entry_t *tqe;
PRINT_D(TX_DBG, "Adding config packet ...\n");
- if (p->quit) {
+ if (wilc->quit) {
PRINT_D(TX_DBG, "Return due to clear function\n");
up(&wilc->cfg_event);
return 0;
int wilc_wlan_txq_add_net_pkt(struct net_device *dev, void *priv, u8 *buffer,
u32 buffer_size, wilc_tx_complete_func_t func)
{
- wilc_wlan_dev_t *p = &g_wlan;
struct txq_entry_t *tqe;
+ perInterface_wlan_t *nic = netdev_priv(dev);
+ struct wilc *wilc;
+
+ wilc = nic->wilc;
- if (p->quit)
+ if (wilc->quit)
return 0;
tqe = kmalloc(sizeof(*tqe), GFP_ATOMIC);
tcp_process(dev, tqe);
#endif
wilc_wlan_txq_add_to_tail(dev, tqe);
- return p->txq_entries;
+ return wilc->txq_entries;
}
int wilc_wlan_txq_add_mgmt_pkt(struct net_device *dev, void *priv, u8 *buffer,
u32 buffer_size, wilc_tx_complete_func_t func)
{
- wilc_wlan_dev_t *p = &g_wlan;
struct txq_entry_t *tqe;
+ perInterface_wlan_t *nic = netdev_priv(dev);
+ struct wilc *wilc;
+
+ wilc = nic->wilc;
- if (p->quit)
+ if (wilc->quit)
return 0;
tqe = kmalloc(sizeof(*tqe), GFP_KERNEL);
static struct txq_entry_t *wilc_wlan_txq_get_first(struct wilc *wilc)
{
- wilc_wlan_dev_t *p = &g_wlan;
struct txq_entry_t *tqe;
unsigned long flags;
spin_lock_irqsave(&wilc->txq_spinlock, flags);
- tqe = p->txq_head;
+ tqe = wilc->txq_head;
spin_unlock_irqrestore(&wilc->txq_spinlock, flags);
static int wilc_wlan_rxq_add(struct wilc *wilc, struct rxq_entry_t *rqe)
{
- wilc_wlan_dev_t *p = &g_wlan;
- if (p->quit)
+ if (wilc->quit)
return 0;
mutex_lock(&wilc->rxq_cs);
- if (!p->rxq_head) {
+ if (!wilc->rxq_head) {
PRINT_D(RX_DBG, "Add to Queue head\n");
rqe->next = NULL;
- p->rxq_head = rqe;
- p->rxq_tail = rqe;
+ wilc->rxq_head = rqe;
+ wilc->rxq_tail = rqe;
} else {
PRINT_D(RX_DBG, "Add to Queue tail\n");
- p->rxq_tail->next = rqe;
+ wilc->rxq_tail->next = rqe;
rqe->next = NULL;
- p->rxq_tail = rqe;
+ wilc->rxq_tail = rqe;
}
- p->rxq_entries += 1;
- PRINT_D(RX_DBG, "Number of queue entries: %d\n", p->rxq_entries);
+ wilc->rxq_entries += 1;
+ PRINT_D(RX_DBG, "Number of queue entries: %d\n", wilc->rxq_entries);
mutex_unlock(&wilc->rxq_cs);
- return p->rxq_entries;
+ return wilc->rxq_entries;
}
static struct rxq_entry_t *wilc_wlan_rxq_remove(struct wilc *wilc)
{
- wilc_wlan_dev_t *p = &g_wlan;
PRINT_D(RX_DBG, "Getting rxQ element\n");
- if (p->rxq_head) {
+ if (wilc->rxq_head) {
struct rxq_entry_t *rqe;
mutex_lock(&wilc->rxq_cs);
- rqe = p->rxq_head;
- p->rxq_head = p->rxq_head->next;
- p->rxq_entries -= 1;
+ rqe = wilc->rxq_head;
+ wilc->rxq_head = wilc->rxq_head->next;
+ wilc->rxq_entries -= 1;
PRINT_D(RX_DBG, "RXQ entries decreased\n");
mutex_unlock(&wilc->rxq_cs);
return rqe;
int wilc_wlan_handle_txq(struct net_device *dev, u32 *txq_count)
{
- wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan;
int i, entries = 0;
u32 sum;
u32 reg;
- u8 *txb = p->tx_buffer;
+ u8 *txb;
u32 offset = 0;
int vmm_sz = 0;
struct txq_entry_t *tqe;
nic = netdev_priv(dev);
wilc = nic->wilc;
- p->txq_exit = 0;
+ txb = wilc->tx_buffer;
+ wilc->txq_exit = 0;
do {
- if (p->quit)
+ if (wilc->quit)
break;
wilc_lock_timeout(wilc, &wilc->txq_add_to_head_cs,
usleep_range(3000, 3000);
acquire_bus(wilc, ACQUIRE_AND_WAKEUP);
}
- } while (!p->quit);
+ } while (!wilc->quit);
if (!ret)
goto _end_;
} while (0);
up(&wilc->txq_add_to_head_cs);
- p->txq_exit = 1;
+ wilc->txq_exit = 1;
PRINT_D(TX_DBG, "THREAD: Exiting txq\n");
- *txq_count = p->txq_entries;
+ *txq_count = wilc->txq_entries;
return ret;
}
static void wilc_wlan_handle_rxq(struct wilc *wilc)
{
- wilc_wlan_dev_t *p = &g_wlan;
int offset = 0, size, has_packet = 0;
u8 *buffer;
struct rxq_entry_t *rqe;
- p->rxq_exit = 0;
+ wilc->rxq_exit = 0;
do {
- if (p->quit) {
+ if (wilc->quit) {
PRINT_D(RX_DBG, "exit 1st do-while due to Clean_UP function\n");
up(&wilc->cfg_event);
break;
wilc_wlan_cfg_indicate_rx(&buffer[pkt_offset + offset], pkt_len, &rsp);
if (rsp.type == WILC_CFG_RSP) {
- PRINT_D(RX_DBG, "p->cfg_seq_no = %d - rsp.seq_no = %d\n", p->cfg_seq_no, rsp.seq_no);
- if (p->cfg_seq_no == rsp.seq_no)
+ PRINT_D(RX_DBG, "wilc->cfg_seq_no = %d - rsp.seq_no = %d\n", wilc->cfg_seq_no, rsp.seq_no);
+ if (wilc->cfg_seq_no == rsp.seq_no)
up(&wilc->cfg_event);
} else if (rsp.type == WILC_CFG_RSP_STATUS) {
wilc_mac_indicate(wilc, WILC_MAC_INDICATE_STATUS);
} while (1);
- p->rxq_exit = 1;
+ wilc->rxq_exit = 1;
PRINT_D(RX_DBG, "THREAD: Exiting RX thread\n");
}
static void wilc_wlan_handle_isr_ext(struct wilc *wilc, u32 int_status)
{
- wilc_wlan_dev_t *p = &g_wlan;
- u32 offset = p->rx_buffer_offset;
+ u32 offset = wilc->rx_buffer_offset;
u8 *buffer = NULL;
u32 size;
u32 retries = 0;
if (LINUX_RX_SIZE - offset < size)
offset = 0;
- if (p->rx_buffer) {
- buffer = &p->rx_buffer[offset];
+ if (wilc->rx_buffer) {
+ buffer = &wilc->rx_buffer[offset];
} else {
wilc_debug(N_ERR, "[wilc isr]: fail Rx Buffer is NULL...drop the packets (%d)\n", size);
goto _end_;
_end_:
if (ret) {
offset += size;
- p->rx_buffer_offset = offset;
+ wilc->rx_buffer_offset = offset;
rqe = kmalloc(sizeof(*rqe), GFP_KERNEL);
if (rqe) {
rqe->buffer = buffer;
void wilc_wlan_cleanup(struct net_device *dev)
{
- wilc_wlan_dev_t *p = &g_wlan;
struct txq_entry_t *tqe;
struct rxq_entry_t *rqe;
u32 reg = 0;
nic = netdev_priv(dev);
wilc = nic->wilc;
- p->quit = 1;
+ wilc->quit = 1;
do {
tqe = wilc_wlan_txq_remove_from_head(dev);
if (!tqe)
kfree(rqe);
} while (1);
- kfree(p->rx_buffer);
- p->rx_buffer = NULL;
- kfree(p->tx_buffer);
+ kfree(wilc->rx_buffer);
+ wilc->rx_buffer = NULL;
+ kfree(wilc->tx_buffer);
acquire_bus(wilc, ACQUIRE_AND_WAKEUP);
static int wilc_wlan_cfg_commit(struct wilc *wilc, int type, u32 drv_handler)
{
- wilc_wlan_dev_t *p = &g_wlan;
- struct wilc_cfg_frame *cfg = &p->cfg_frame;
- int total_len = p->cfg_frame_offset + 4 + DRIVER_HANDLER_SIZE;
- int seq_no = p->cfg_seq_no % 256;
+ struct wilc_cfg_frame *cfg = &wilc->cfg_frame;
+ int total_len = wilc->cfg_frame_offset + 4 + DRIVER_HANDLER_SIZE;
+ int seq_no = wilc->cfg_seq_no % 256;
int driver_handler = (u32)drv_handler;
if (type == WILC_CFG_SET)
cfg->wid_header[5] = (u8)(driver_handler >> 8);
cfg->wid_header[6] = (u8)(driver_handler >> 16);
cfg->wid_header[7] = (u8)(driver_handler >> 24);
- p->cfg_seq_no = seq_no;
+ wilc->cfg_seq_no = seq_no;
if (!wilc_wlan_txq_add_cfg_pkt(wilc, &cfg->wid_header[0], total_len))
return -1;
int wilc_wlan_cfg_set(struct wilc *wilc, int start, u32 wid, u8 *buffer,
u32 buffer_size, int commit, u32 drv_handler)
{
- wilc_wlan_dev_t *p = &g_wlan;
u32 offset;
int ret_size;
- if (p->cfg_frame_in_use)
+ if (wilc->cfg_frame_in_use)
return 0;
if (start)
- p->cfg_frame_offset = 0;
+ wilc->cfg_frame_offset = 0;
- offset = p->cfg_frame_offset;
- ret_size = wilc_wlan_cfg_set_wid(p->cfg_frame.frame, offset, (u16)wid,
- buffer, buffer_size);
+ offset = wilc->cfg_frame_offset;
+ ret_size = wilc_wlan_cfg_set_wid(wilc->cfg_frame.frame, offset,
+ (u16)wid, buffer, buffer_size);
offset += ret_size;
- p->cfg_frame_offset = offset;
+ wilc->cfg_frame_offset = offset;
if (commit) {
PRINT_D(TX_DBG, "[WILC]PACKET Commit with sequence number %d\n",
- p->cfg_seq_no);
+ wilc->cfg_seq_no);
PRINT_D(RX_DBG, "Processing cfg_set()\n");
- p->cfg_frame_in_use = 1;
+ wilc->cfg_frame_in_use = 1;
if (wilc_wlan_cfg_commit(wilc, WILC_CFG_SET, drv_handler))
ret_size = 0;
PRINT_D(TX_DBG, "Set Timed Out\n");
ret_size = 0;
}
- p->cfg_frame_in_use = 0;
- p->cfg_frame_offset = 0;
- p->cfg_seq_no += 1;
+ wilc->cfg_frame_in_use = 0;
+ wilc->cfg_frame_offset = 0;
+ wilc->cfg_seq_no += 1;
}
return ret_size;
int wilc_wlan_cfg_get(struct wilc *wilc, int start, u32 wid, int commit,
u32 drv_handler)
{
- wilc_wlan_dev_t *p = &g_wlan;
u32 offset;
int ret_size;
- if (p->cfg_frame_in_use)
+ if (wilc->cfg_frame_in_use)
return 0;
if (start)
- p->cfg_frame_offset = 0;
+ wilc->cfg_frame_offset = 0;
- offset = p->cfg_frame_offset;
- ret_size = wilc_wlan_cfg_get_wid(p->cfg_frame.frame, offset, (u16)wid);
+ offset = wilc->cfg_frame_offset;
+ ret_size = wilc_wlan_cfg_get_wid(wilc->cfg_frame.frame, offset,
+ (u16)wid);
offset += ret_size;
- p->cfg_frame_offset = offset;
+ wilc->cfg_frame_offset = offset;
if (commit) {
- p->cfg_frame_in_use = 1;
+ wilc->cfg_frame_in_use = 1;
if (wilc_wlan_cfg_commit(wilc, WILC_CFG_QUERY, drv_handler))
ret_size = 0;
ret_size = 0;
}
PRINT_D(GENERIC_DBG, "[WILC]Get Response received\n");
- p->cfg_frame_in_use = 0;
- p->cfg_frame_offset = 0;
- p->cfg_seq_no += 1;
+ wilc->cfg_frame_in_use = 0;
+ wilc->cfg_frame_offset = 0;
+ wilc->cfg_seq_no += 1;
}
return ret_size;
PRINT_D(INIT_DBG, "Initializing WILC_Wlan ...\n");
- memset((void *)&g_wlan, 0, sizeof(wilc_wlan_dev_t));
if (!wilc->hif_func->hif_init(wilc, wilc_debug)) {
ret = -EIO;
goto _fail_;
goto _fail_;
}
- if (!g_wlan.tx_buffer)
- g_wlan.tx_buffer = kmalloc(LINUX_TX_SIZE, GFP_KERNEL);
- PRINT_D(TX_DBG, "g_wlan.tx_buffer = %p\n", g_wlan.tx_buffer);
+ if (!wilc->tx_buffer)
+ wilc->tx_buffer = kmalloc(LINUX_TX_SIZE, GFP_KERNEL);
+ PRINT_D(TX_DBG, "wilc->tx_buffer = %p\n", wilc->tx_buffer);
- if (!g_wlan.tx_buffer) {
+ if (!wilc->tx_buffer) {
ret = -ENOBUFS;
PRINT_ER("Can't allocate Tx Buffer");
goto _fail_;
}
- if (!g_wlan.rx_buffer)
- g_wlan.rx_buffer = kmalloc(LINUX_RX_SIZE, GFP_KERNEL);
- PRINT_D(TX_DBG, "g_wlan.rx_buffer =%p\n", g_wlan.rx_buffer);
- if (!g_wlan.rx_buffer) {
+ if (!wilc->rx_buffer)
+ wilc->rx_buffer = kmalloc(LINUX_RX_SIZE, GFP_KERNEL);
+ PRINT_D(TX_DBG, "wilc->rx_buffer =%p\n", wilc->rx_buffer);
+ if (!wilc->rx_buffer) {
ret = -ENOBUFS;
PRINT_ER("Can't allocate Rx Buffer");
goto _fail_;
_fail_:
- kfree(g_wlan.rx_buffer);
- g_wlan.rx_buffer = NULL;
- kfree(g_wlan.tx_buffer);
- g_wlan.tx_buffer = NULL;
+ kfree(wilc->rx_buffer);
+ wilc->rx_buffer = NULL;
+ kfree(wilc->tx_buffer);
+ wilc->tx_buffer = NULL;
return ret;
}