// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries.
* All rights reserved.
*/
#include <linux/if_ether.h>
#include <linux/ip.h>
#include "wilc_wfi_cfgoperations.h"
#include "wilc_wlan_cfg.h"
static inline bool is_wilc1000(u32 id)
{
return (id & 0xfffff000) == 0x100000;
}
static inline void acquire_bus(struct wilc *wilc, enum bus_acquire acquire)
{
mutex_lock(&wilc->hif_cs);
if (acquire == WILC_BUS_ACQUIRE_AND_WAKEUP)
chip_wakeup(wilc);
}
static inline void release_bus(struct wilc *wilc, enum bus_release release)
{
if (release == WILC_BUS_RELEASE_ALLOW_SLEEP)
chip_allow_sleep(wilc);
mutex_unlock(&wilc->hif_cs);
}
static void wilc_wlan_txq_remove(struct wilc *wilc, struct txq_entry_t *tqe)
{
list_del(&tqe->list);
wilc->txq_entries -= 1;
}
static struct txq_entry_t *
wilc_wlan_txq_remove_from_head(struct net_device *dev)
{
struct txq_entry_t *tqe = NULL;
unsigned long flags;
struct wilc_vif *vif = netdev_priv(dev);
struct wilc *wilc = vif->wilc;
spin_lock_irqsave(&wilc->txq_spinlock, flags);
if (!list_empty(&wilc->txq_head.list)) {
tqe = list_first_entry(&wilc->txq_head.list, struct txq_entry_t,
list);
list_del(&tqe->list);
wilc->txq_entries -= 1;
}
spin_unlock_irqrestore(&wilc->txq_spinlock, flags);
return tqe;
}
static void wilc_wlan_txq_add_to_tail(struct net_device *dev,
struct txq_entry_t *tqe)
{
unsigned long flags;
struct wilc_vif *vif = netdev_priv(dev);
struct wilc *wilc = vif->wilc;
spin_lock_irqsave(&wilc->txq_spinlock, flags);
list_add_tail(&tqe->list, &wilc->txq_head.list);
wilc->txq_entries += 1;
spin_unlock_irqrestore(&wilc->txq_spinlock, flags);
complete(&wilc->txq_event);
}
static void wilc_wlan_txq_add_to_head(struct wilc_vif *vif,
struct txq_entry_t *tqe)
{
unsigned long