BigW Consortium Gitlab

Commit 82174f7c by David Clark

Updates after getting WiFi Tx and Rx working (except not both at the same time)

parent 3b911ff1
......@@ -15,197 +15,106 @@
*/
#include <linux/device.h>
#include <linux/gpio.h>
#include <linux/interrupt.h>
#include "interrupt.h"
#include "queue.h"
#include "io.h"
/*
static void mt7697_flush_deferred_work(struct mt7697_data *wl)
{
struct sk_buff *skb;
*/
/* Pass all received frames to the network stack */
/* while ((skb = skb_dequeue(&wl->deferred_rx_queue)))
ieee80211_rx_ni(wl->hw, skb);
*/
/* Return sent skbs to the network stack */
/* while ((skb = skb_dequeue(&wl->deferred_tx_queue)))
ieee80211_tx_status_ni(wl->hw, skb);
}
*/
/*
static int mt7697_irq_locked(struct mt7697_data *wl)
{
int ret = 0;
int loopcount = MT7697_IRQ_MAX_LOOPS;
bool done = false;
unsigned int defer_count;
unsigned long flags;
#include "spi.h"
if (unlikely(wl->state != MT7697_STATE_ON))
goto out;
while (!done && loopcount--) {
clear_bit(MT7697_FLAG_IRQ_RUNNING, &wl->flags);
ret = mt7697_rx(wl);
if (ret < 0) {
dev_err(wl->dev, "%s(): mt7697_rx() failed(%d)\n", __func__, ret);
goto out;
}
*/
/* Check if any tx blocks were freed */
/* spin_lock_irqsave(&wl->lock, flags);
if (!test_bit(MT7697_FLAG_FW_TX_BUSY, &wl->flags) &&
mt7697_tx_total_queue_count(wl) > 0) {
spin_unlock_irqrestore(&wl->lock, flags);*/
/*
* In order to avoid starvation of the TX path,
* call the work function directly.
*/
/* ret = mt7697_tx_work_locked(wl);
if (ret < 0) {
dev_err(wl->dev, "%s(): mt7697_tx_work_locked() failed(%d)\n", __func__, ret);
goto out;
}
} else {
spin_unlock_irqrestore(&wl->lock, flags);
}
*/
/* check for tx results */
// ret = mt7697_hw_tx_delayed_compl(wl);
/* if (ret < 0) {
dev_err(wl->dev, "%s(): mt7697_hw_tx_delayed_compl() failed(%d)\n", __func__, ret);
goto out;
}
*/
/* Make sure the deferred queues don't get too long */
/* defer_count = skb_queue_len(&wl->deferred_tx_queue) +
skb_queue_len(&wl->deferred_rx_queue);
if (defer_count > MT7697_DEFERRED_QUEUE_LIMIT)
mt7697_flush_deferred_work(wl);
}
out:
return ret;
}*/
/*
irqreturn_t mt7697_irq(int irq, void *cookie)
{
struct mt7697_data *wl = cookie;
int ret;
unsigned long flags;
spin_lock_irqsave(&wl->lock, flags);
if (test_bit(MT7697_FLAG_SUSPENDED, &wl->flags)) {*/
/* don't enqueue a work right now. mark it as pending */
/* set_bit(MT7697_FLAG_PENDING_WORK, &wl->flags);
dev_info(wl->dev, "should not enqueue work\n");
// disable_irq_nosync(wl->irq);
// pm_wakeup_event(wl->dev, 0);
spin_unlock_irqrestore(&wl->lock, flags);
return IRQ_HANDLED;
}
spin_unlock_irqrestore(&wl->lock, flags);
*/
/* TX might be handled here, avoid redundant work */
/* set_bit(MT7697_FLAG_TX_PENDING, &wl->flags);
cancel_work_sync(&wl->tx_work);
mutex_lock(&wl->mutex);
ret = mt7697_irq_locked(wl);
if (ret) {
dev_warn(wl->dev, "%s(): mt7697_irq_locked() failed(%d)\n", __func__, ret);
// mt7697_queue_recovery_work(wl);
}
spin_lock_irqsave(&wl->lock, flags);*/
/* In case TX was not handled here, queue TX work */
/* clear_bit(MT7697_FLAG_TX_PENDING, &wl->flags);
if (!test_bit(MT7697_FLAG_FW_TX_BUSY, &wl->flags) &&
mt7697_tx_total_queue_count(wl) > 0)
ieee80211_queue_work(wl->hw, &wl->tx_work);
spin_unlock_irqrestore(&wl->lock, flags);
mutex_unlock(&wl->mutex);
return IRQ_HANDLED;
}*/
void mt7697_irq_work(struct work_struct *irq_work)
int mt7697_irq_run(struct mt7697q_info *qinfo)
{
struct mt7697q_info *qinfo = container_of(irq_work,
struct mt7697q_info, irq_work);
int ch;
int ret;
u8 ch;
u8 s2m_mbox;
mutex_lock(&qinfo->mutex);
ret = mt7697io_rd_s2m_mbx(qinfo);
ret = mt7697q_get_s2m_mbx(qinfo, &s2m_mbox);
if (ret < 0) {
dev_err(qinfo->dev, "%s(): mt7697io_rd_s2m_mbx() failed(%d)\n",
dev_err(qinfo->dev,
"%s(): mt7697q_get_s2m_mbx() failed(%d)\n",
__func__, ret);
goto cleanup;
}
if (!qinfo->s2m_mbox)
goto cleanup;
ret = mt7697io_clr_s2m_mbx(qinfo);
if (ret < 0) {
if (s2m_mbox) {
if (!queue_delayed_work(qinfo->irq_workq,
&qinfo->irq_delayed_work, usecs_to_jiffies(100))) {
dev_err(qinfo->dev,
"%s(): mt7697io_clr_s2m_mbx() failed(%d)\n",
__func__, ret);
goto cleanup;
"%s(): queue_delayed_work() failed\n",
__func__);
ret = -EINVAL;
}
}
else
enable_irq(qinfo->irq);
for (ch = 0; ch < MT7697_NUM_QUEUES; ch++) {
if (qinfo->s2m_mbox & (0x01 << ch)) {
struct mt7697q_spec *qs = &qinfo->queues[ch];
u32 in_use = mt7697q_flags_get_in_use(qs->data.flags);
u32 dir = mt7697q_flags_get_dir(qs->data.flags);
if (in_use &&
(dir == MT7697_QUEUE_DIR_SLAVE_TO_MASTER)) {
WARN_ON(!qs->rx_fcn);
mutex_unlock(&qinfo->mutex);
ret = qs->rx_fcn(qs->priv);
(s2m_mbox & (0x01 << ch)) &&
(dir == MT7697_QUEUE_DIR_S2M)) {
ret = mt7697q_proc_data(qs);
if (ret < 0) {
dev_err(qinfo->dev,
"%s(): rx_fcn() failed(%d)\n",
"%s(): mt7697q_proc_data() failed(%d)\n",
__func__, ret);
goto cleanup;
}
mutex_lock(&qinfo->mutex);
}
else if (!in_use) {
dev_warn(qinfo->dev,
"%s(): unused channel(%d)\n",
__func__, ch);
}
}
cleanup:
return ret;
}
void mt7697_irq_delayed_work(struct work_struct *irq_delayed_work)
{
struct mt7697q_info *qinfo = container_of(irq_delayed_work,
struct mt7697q_info, irq_delayed_work.work);
int ret;
dev_dbg(qinfo->dev, "%s(): process work\n", __func__);
ret = mt7697_irq_run(qinfo);
if (ret < 0) {
dev_err(qinfo->dev, "%s(): mt7697_irq_run() failed(%d)\n",
__func__, ret);
goto cleanup;
}
cleanup:
ret = queue_delayed_work(qinfo->irq_workq, &qinfo->irq_work,
msecs_to_jiffies(100));
return;
}
void mt7697_irq_work(struct work_struct *irq_work)
{
struct mt7697q_info *qinfo = container_of(irq_work,
struct mt7697q_info, irq_work);
int ret;
dev_dbg(qinfo->dev, "%s(): process work\n", __func__);
ret = mt7697_irq_run(qinfo);
if (ret < 0) {
dev_err(qinfo->dev,
"%s(): queue_delayed_work() failed(%d)\n",
"%s(): mt7697_irq_run() failed(%d)\n",
__func__, ret);
goto cleanup;
}
mutex_unlock(&qinfo->mutex);
cleanup:
return;
}
irqreturn_t mt7697_irq(int irq, void *cookie)
irqreturn_t mt7697_isr(int irq, void *cookie)
{
/* struct mt7697q_info *qinfo = cookie;
int err = queue_work(qinfo->irq_workq, &qinfo->irq_work);
if (err < 0) {
dev_err(qinfo->dev, "queue_work() failed(%d)\n", err);
}*/
struct mt7697q_info *qinfo = cookie;
disable_irq_nosync(qinfo->irq);
if (!queue_work(qinfo->irq_workq, &qinfo->irq_work)) {
dev_err(qinfo->dev, "%s(): queue_work() failed\n", __func__);
}
return IRQ_HANDLED;
}
......@@ -19,10 +19,7 @@
#include <linux/interrupt.h>
#define MT7697_USBHUB_IRQ_PIN 6
#define MT7697_IRQ_MAX_LOOPS 256
irqreturn_t mt7697_irq(int, void*);
irqreturn_t mt7697_isr(int, void*);
void mt7697_irq_work(struct work_struct*);
#endif
......@@ -21,6 +21,12 @@
#include "io.h"
#include "spi.h"
static __inline u8 mt7697io_busy(u16 value)
{
return BF_GET(value, MT7697_IO_STATUS_REG_BUSY_OFFSET,
MT7697_IO_STATUS_REG_BUSY_WIDTH);
}
static int mt7697io_write16(struct mt7697q_info *qinfo, u8 reg, u16 value)
{
int ret;
......@@ -131,7 +137,7 @@ static int mt7697io_chk_slave_busy(struct mt7697q_info *qinfo)
goto cleanup;
}
qinfo->slave_busy = mt7697q_busy(value) == MT7697_IO_STATUS_REG_BUSY_VAL_BUSY;
qinfo->slave_busy = mt7697io_busy(value) == MT7697_IO_STATUS_REG_BUSY_VAL_BUSY;
cleanup:
return ret;
......@@ -206,7 +212,7 @@ int mt7697io_rd_s2m_mbx(struct mt7697q_info *qinfo)
}
qinfo->s2m_mbox = mt7697io_get_s2m_mbox(value);
dev_dbg(qinfo->dev, "%s(): s2m mbx(0x%04x)\n",
dev_dbg(qinfo->dev, "%s(): s2m mbx(0x%02x)\n",
__func__, qinfo->s2m_mbox);
cleanup:
......@@ -346,9 +352,7 @@ cleanup:
int mt7697io_trigger_intr(struct mt7697q_info *qinfo)
{
int ret;
ret = mt7697io_write16(qinfo, MT7697_IO_SLAVE_REG_IRQ,
int ret = mt7697io_write16(qinfo, MT7697_IO_SLAVE_REG_IRQ,
BF_DEFINE(MT7697_IO_IRQ_REG_IRQ_STATUS_VAL_ACTIVE,
MT7697_IO_IRQ_REG_IRQ_STATUS_OFFSET,
MT7697_IO_IRQ_REG_IRQ_STATUS_WIDTH));
......
......@@ -76,7 +76,7 @@
#define MT7697_IO_IRQ_REG_IRQ_STATUS_VAL_ACTIVE 1
#define MT7697_IO_S2M_MAILBOX_REG_MAILBOX_OFFSET 0
#define MT7697_IO_S2M_MAILBOX_REG_MAILBOX_WIDTH 7
#define MT7697_IO_S2M_MAILBOX_REG_MAILBOX_WIDTH 6
#define MT7697_IO_M2S_MAILBOX_REG_MAILBOX_OFFSET 0
#define MT7697_IO_M2S_MAILBOX_REG_MAILBOX_WIDTH 7
......
......@@ -23,22 +23,110 @@
static __inline ssize_t mt7697q_buf_diff(u32 size, u32 from, u32 to)
{
WARN_ON(from >= size || to >= size);
if (from >= size) {
pr_info("%s(): ERROR from(%u) >= size(%u)\n",
__func__, from, size);
WARN_ON(from >= size);
}
if (to >= size) {
pr_info("%s(): ERROR to(%u) >= size(%u)\n",
__func__, to, size);
WARN_ON(to >= size);
}
return (from <= to) ? (to - from):((size - from) + to);
}
static int mt7697q_push_wr_ptr(struct mt7697q_spec *qs)
static __inline size_t mt7697q_get_capacity(const struct mt7697q_spec *qs)
{
const uint32_t write_addr = MT7697_IO_SLAVE_BUFFER_ADDRESS +
return BF_GET(qs->data.flags, MT7697_QUEUE_FLAGS_NUM_WORDS_OFFSET,
MT7697_QUEUE_FLAGS_NUM_WORDS_WIDTH) - 1;
}
static __inline size_t mt7697q_get_num_words(const struct mt7697q_spec *qs)
{
return mt7697q_buf_diff(BF_GET(qs->data.flags,
MT7697_QUEUE_FLAGS_NUM_WORDS_OFFSET,
MT7697_QUEUE_FLAGS_NUM_WORDS_WIDTH),
qs->data.rd_offset, qs->data.wr_offset);
}
static __inline size_t mt7697q_get_free_words(const struct mt7697q_spec *qs)
{
return mt7697q_get_capacity(qs) - mt7697q_get_num_words(qs);
}
static int mt7697q_send_init(u8 tx_ch, u8 rx_ch, struct mt7697q_spec *qs)
{
struct mt7697_queue_init_req req;
int ret;
req.cmd.len = sizeof(struct mt7697_queue_init_req);
req.cmd.grp = MT7697_CMD_GRP_QUEUE;
req.cmd.type = MT7697_CMD_QUEUE_INIT;
req.m2s_ch = tx_ch;
req.s2m_ch = rx_ch;
dev_dbg(qs->qinfo->dev, "%s(): <-- QUEUE INIT channel(%u/%u)\n",
__func__, tx_ch, rx_ch);
ret = mt7697q_write(qs, (const u32*)&req,
LEN_TO_WORD(req.cmd.len));
if (ret != LEN_TO_WORD(req.cmd.len)) {
dev_err(qs->qinfo->dev,
"%s(): mt7697q_write() failed(%d != %d)\n",
__func__, ret, LEN_TO_WORD(req.cmd.len));
ret = (ret < 0) ? ret:-EIO;
goto cleanup;
}
ret = 0;
cleanup:
return ret;
}
static int mt7697q_pull_rd_ptr(struct mt7697q_spec *qs)
{
const u32 read_addr = MT7697_IO_SLAVE_BUFFER_ADDRESS +
(qs->ch * sizeof(struct mt7697q_data)) +
offsetof(struct mt7697q_data, wr_offset);
offsetof(struct mt7697q_data, rd_offset);
u32 rd_offset;
int ret;
dev_dbg(qs->qinfo->dev, "%s(): ptr/offset(0x%08x/%u)\n",
__func__, write_addr, qs->data.wr_offset);
dev_dbg(qs->qinfo->dev, "%s(): queue(%u) addr(0x%08x)\n",
__func__, qs->ch, read_addr);
ret = mt7697io_rd(qs->qinfo, read_addr, &rd_offset,
LEN_TO_WORD(sizeof(rd_offset)));
if (ret < 0) {
dev_err(qs->qinfo->dev, "%s(): mt7697io_rd() failed(%d)\n",
__func__, ret);
goto cleanup;
}
qs->data.rd_offset = rd_offset;
dev_dbg(qs->qinfo->dev, "%s(): queue(%u) rd offset(%u)\n",
__func__, qs->ch, qs->data.rd_offset);
ret = mt7697io_wr(qs->qinfo, write_addr, &qs->data.wr_offset,
MT7697_QUEUE_LEN_TO_WORD(sizeof(qs->data.wr_offset)));
cleanup:
return ret;
}
static int mt7697q_push_rd_ptr(struct mt7697q_spec *qs)
{
const u32 write_addr = MT7697_IO_SLAVE_BUFFER_ADDRESS +
(qs->ch * sizeof(struct mt7697q_data)) +
offsetof(struct mt7697q_data, rd_offset);
u32 rd_offset;
int ret;
mutex_lock(&qs->qinfo->mutex);
dev_dbg(qs->qinfo->dev, "%s(): rd ptr/offset(0x%08x/%u)\n",
__func__, write_addr, qs->data.rd_offset);
rd_offset = qs->data.rd_offset;
ret = mt7697io_wr(qs->qinfo, write_addr, &rd_offset,
LEN_TO_WORD(sizeof(rd_offset)));
if (ret < 0) {
dev_err(qs->qinfo->dev, "%s(): mt7697io_wr() failed(%d)\n",
__func__, ret);
......@@ -62,21 +150,53 @@ static int mt7697q_push_wr_ptr(struct mt7697q_spec *qs)
}
cleanup:
mutex_unlock(&qs->qinfo->mutex);
return ret;
}
static int mt7697q_push_rd_ptr(struct mt7697q_spec *qs)
static int mt7697q_pull_wr_ptr(struct mt7697q_spec *qs)
{
const u32 write_addr = MT7697_IO_SLAVE_BUFFER_ADDRESS +
const u32 read_addr = MT7697_IO_SLAVE_BUFFER_ADDRESS +
(qs->ch * sizeof(struct mt7697q_data)) +
offsetof(struct mt7697q_data, rd_offset);
offsetof(struct mt7697q_data, wr_offset);
u32 wr_offset;
int ret;
dev_dbg(qs->qinfo->dev, "%s(): ptr/offset(0x%08x/%u)\n",
__func__, write_addr, qs->data.rd_offset);
mutex_lock(&qs->qinfo->mutex);
dev_dbg(qs->qinfo->dev, "%s(): queue(%u) addr(0x%08x)\n",
__func__, qs->ch, read_addr);
ret = mt7697io_rd(qs->qinfo, read_addr, &wr_offset,
LEN_TO_WORD(sizeof(wr_offset)));
if (ret < 0) {
dev_err(qs->qinfo->dev, "%s(): mt7697io_rd() failed(%d)\n",
__func__, ret);
goto cleanup;
}
qs->data.wr_offset = wr_offset;
dev_dbg(qs->qinfo->dev, "%s(): queue(%u) wr offset(%u)\n",
__func__, qs->ch, qs->data.wr_offset);
cleanup:
mutex_unlock(&qs->qinfo->mutex);
return ret;
}
static int mt7697q_push_wr_ptr(struct mt7697q_spec *qs)
{
const uint32_t write_addr = MT7697_IO_SLAVE_BUFFER_ADDRESS +
(qs->ch * sizeof(struct mt7697q_data)) +
offsetof(struct mt7697q_data, wr_offset);
u32 wr_offset;
int ret;
dev_dbg(qs->qinfo->dev, "%s(): wr ptr/offset(0x%08x/%u)\n",
__func__, write_addr, qs->data.wr_offset);
ret = mt7697io_wr(qs->qinfo, write_addr, &qs->data.rd_offset,
MT7697_QUEUE_LEN_TO_WORD(sizeof(qs->data.rd_offset)));
wr_offset = qs->data.wr_offset;
ret = mt7697io_wr(qs->qinfo, write_addr, &wr_offset,
LEN_TO_WORD(sizeof(wr_offset)));
if (ret < 0) {
dev_err(qs->qinfo->dev, "%s(): mt7697io_wr() failed(%d)\n",
__func__, ret);
......@@ -103,20 +223,282 @@ cleanup:
return ret;
}
void* mt7697q_init(u8 ch, void *priv, rx_hndlr rx_fcn)
static int mt7697q_read_state(u8 ch, struct mt7697q_spec *qs)
{
int ret;
mutex_lock(&qs->qinfo->mutex);
ret = mt7697io_rd(qs->qinfo,
MT7697_IO_SLAVE_BUFFER_ADDRESS + ch * sizeof(struct mt7697q_data),
(u32*)&qs->data,
LEN_TO_WORD(sizeof(struct mt7697q_data)));
if (ret < 0) {
dev_err(qs->qinfo->dev, "%s(): mt7697io_rd() failed(%d)\n",
__func__, ret);
goto cleanup;
}
dev_dbg(qs->qinfo->dev, "%s(): flags(0x%08x) base addr(0x%08x)\n",
__func__, qs->data.flags, qs->data.base_addr);
dev_dbg(qs->qinfo->dev, "%s(): rd/wr offset(0x%08x/0x%08x)\n",
__func__, qs->data.rd_offset, qs->data.wr_offset);
if (!qs->data.base_addr) {
dev_err(qs->qinfo->dev, "%s(): invalid base address(0x%08x)\n",
__func__, qs->data.base_addr);
ret = -EINVAL;
goto cleanup;
}
else if (!qs->data.flags) {
dev_err(qs->qinfo->dev, "%s(): invalid flags(0x%08x)\n",
__func__, qs->data.flags);
ret = -EINVAL;
goto cleanup;
}
else if ((qs->data.rd_offset > mt7697q_get_capacity(qs)) ||
(qs->data.wr_offset > mt7697q_get_capacity(qs))) {
dev_err(qs->qinfo->dev,
"%s(): invalid rd/wr offset(0x%08x/0x%08x)\n",
__func__, qs->data.rd_offset, qs->data.wr_offset);
ret = -EINVAL;
goto cleanup;
}
cleanup:
mutex_unlock(&qs->qinfo->mutex);
return ret;
}
static int mt7697q_proc_queue_rsp(struct mt7697q_spec *qs)
{
int ret = 0;
switch(qs->qinfo->rsp.cmd.type) {
case MT7697_CMD_QUEUE_INIT_RSP:
dev_dbg(qs->qinfo->dev, "%s(): --> QUEUE INIT RSP\n",
__func__);
break;
case MT7697_CMD_QUEUE_UNUSED_RSP:
dev_dbg(qs->qinfo->dev, "%s(): --> QUEUE UNUSED RSP\n",
__func__);
break;
case MT7697_CMD_QUEUE_RESET_RSP:
dev_dbg(qs->qinfo->dev, "%s(): --> QUEUE RESET RSP\n",
__func__);
break;
default:
dev_err(qs->qinfo->dev, "%s(): unsupported cmd(%d)\n",
__func__, qs->qinfo->rsp.cmd.type);
ret = -EINVAL;
goto cleanup;
}
cleanup:
return ret;
}
int mt7697q_get_s2m_mbx(struct mt7697q_info *qinfo, u8* s2m_mbox)
{
int ret;
mutex_lock(&qinfo->mutex);
ret = mt7697io_rd_s2m_mbx(qinfo);
if (ret < 0) {
dev_err(qinfo->dev, "%s(): mt7697io_rd_s2m_mbx() failed(%d)\n",
__func__, ret);
goto cleanup;
}
*s2m_mbox = qinfo->s2m_mbox;
ret = mt7697io_clr_s2m_mbx(qinfo);
if (ret < 0) {
dev_err(qinfo->dev,
"%s(): mt7697io_clr_s2m_mbx() failed(%d)\n",
__func__, ret);
goto cleanup;
}
cleanup:
mutex_unlock(&qinfo->mutex);
return ret;
}
int mt7697q_proc_data(struct mt7697q_spec *qsS2M)
{
size_t avail;
u32 req = 0;
int ret;
ret = mt7697q_pull_wr_ptr(qsS2M);
if (ret < 0) {
dev_err(qsS2M->qinfo->dev,
"%s(): mt7697q_pull_wr_ptr() failed(%d)\n",
__func__, ret);
goto cleanup;
}
avail = mt7697q_get_num_words(qsS2M);
req = (qsS2M->qinfo->rsp.cmd.len > 0) ?
LEN_TO_WORD(qsS2M->qinfo->rsp.cmd.len - sizeof(struct mt7697q_rsp_hdr)) :
LEN_TO_WORD(sizeof(struct mt7697q_rsp_hdr));
dev_dbg(qsS2M->qinfo->dev, "%s(): avail(%u) len(%u) req(%u)\n",
__func__, avail, qsS2M->qinfo->rsp.cmd.len, req);
while (avail >= req) {
if (!qsS2M->qinfo->rsp.cmd.len) {
ret = mt7697q_read(qsS2M, (u32*)&qsS2M->qinfo->rsp, req);
if (ret != req) {
dev_err(qsS2M->qinfo->dev,
"%s(): mt7697q_read() failed(%d != %d)\n",
__func__, ret, req);
goto cleanup;
}
avail -= LEN_TO_WORD(sizeof(struct mt7697q_rsp_hdr));
req = LEN_TO_WORD(qsS2M->qinfo->rsp.cmd.len - sizeof(struct mt7697q_rsp_hdr));
dev_dbg(qsS2M->qinfo->dev, "%s(): avail(%u) len(%u) req(%u)\n",
__func__, avail, qsS2M->qinfo->rsp.cmd.len, req);
}
if (qsS2M->qinfo->rsp.result < 0) {
dev_warn(qsS2M->qinfo->dev,
"%s(): cmd(%u) result(%d)\n",
__func__, qsS2M->qinfo->rsp.cmd.type,
qsS2M->qinfo->rsp.result);
}
if (avail < req) {
ret = mt7697q_pull_wr_ptr(qsS2M);
if (ret < 0) {
dev_err(qsS2M->qinfo->dev,
"%s(): mt7697q_pull_wr_ptr() failed(%d)\n",
__func__, ret);
goto cleanup;
}
avail = mt7697q_get_num_words(qsS2M);
}
dev_dbg(qsS2M->qinfo->dev, "%s(): avail(%u) len(%u) req(%u)\n",
__func__, avail, qsS2M->qinfo->rsp.cmd.len, req);
if (avail < req) {
dev_dbg(qsS2M->qinfo->dev,
"%s(): queue need more data\n", __func__);
goto cleanup;
}
if (qsS2M->qinfo->rsp.cmd.grp == MT7697_CMD_GRP_QUEUE) {
ret = mt7697q_proc_queue_rsp(qsS2M);
if (ret < 0) {
dev_err(qsS2M->qinfo->dev,
"%s(): mt7697q_proc_queue_rsp() failed(%d)\n",
__func__, ret);
goto cleanup;
}
}
else {
WARN_ON(!qsS2M->rx_fcn);
ret = qsS2M->rx_fcn((const struct mt7697q_rsp_hdr*)&qsS2M->qinfo->rsp, qsS2M->priv);
if (ret < 0) {
dev_err(qsS2M->qinfo->dev,
"%s(): rx_fcn() failed(%d)\n",
__func__, ret);
}
}
avail -= req;
qsS2M->qinfo->rsp.cmd.len = 0;
req = LEN_TO_WORD(sizeof(struct mt7697q_rsp_hdr));
dev_dbg(qsS2M->qinfo->dev, "%s(): avail(%u) len(%u) req(%u)\n",
__func__, avail, qsS2M->qinfo->rsp.cmd.len, req);
if (avail < req) {
ret = mt7697q_pull_wr_ptr(qsS2M);
if (ret < 0) {
dev_err(qsS2M->qinfo->dev,
"%s(): mt7697q_pull_wr_ptr() failed(%d)\n",
__func__, ret);
goto cleanup;
}
avail = mt7697q_get_num_words(qsS2M);
dev_dbg(qsS2M->qinfo->dev, "%s(): avail(%u) len(%u) req(%u)\n",
__func__, avail, qsS2M->qinfo->rsp.cmd.len, req);
}
}
ret = mt7697q_push_rd_ptr(qsS2M);
if (ret < 0) {
dev_err(qsS2M->qinfo->dev,
"%s(): mt7697q_push_rd_ptr() failed(%d)\n",
__func__, ret);
goto cleanup;
}
cleanup:
return ret;
}
int mt7697q_send_reset(void *tx_hndl, void* rx_hndl)
{
struct mt7697q_spec *qsM2S = (struct mt7697q_spec*)tx_hndl;
struct mt7697q_spec *qsS2M = (struct mt7697q_spec*)rx_hndl;
struct mt7697_queue_reset_req req;
int ret;
req.cmd.len = sizeof(struct mt7697_queue_reset_req);
req.cmd.grp = MT7697_CMD_GRP_QUEUE;
req.cmd.type = MT7697_CMD_QUEUE_RESET;
req.m2s_ch = qsM2S->ch;
req.s2m_ch = qsS2M->ch;
dev_dbg(qsM2S->qinfo->dev, "%s(): <-- QUEUE RESET(%u/%u)\n",
__func__, req.m2s_ch, req.s2m_ch);
ret = mt7697q_write(qsM2S, (const u32*)&req,
LEN_TO_WORD(req.cmd.len));
if (ret != LEN_TO_WORD(req.cmd.len)) {
dev_err(qsM2S->qinfo->dev,
"%s(): mt7697q_write() failed(%d != %d)\n",
__func__, ret, LEN_TO_WORD(req.cmd.len));
ret = (ret < 0) ? ret:-EIO;
goto cleanup;
}
ret = 0;
cleanup:
return ret;
}
EXPORT_SYMBOL(mt7697q_send_reset);
int mt7697q_init(u8 tx_ch, u8 rx_ch, void *priv, rx_hndlr rx_fcn,
void** tx_hndl, void** rx_hndl)
{
char str[32];
struct spi_master *master;
struct device *dev;
struct spi_device *spi;
struct mt7697q_info *qinfo;
struct mt7697q_spec *qs;
struct mt7697q_spec *qsTx, *qsRx;
int ret;
pr_info(DRVNAME" %s(): initialize queue(%u/%u)\n",
__func__, tx_ch, rx_ch);
pr_info(DRVNAME" %s(): get SPI master bus(%u)\n",
__func__, MT7697_SPI_BUS_NUM);
master = spi_busnum_to_master(MT7697_SPI_BUS_NUM);
if (!master) {
pr_err(DRVNAME" spi_busnum_to_master(%d) failed\n",
MT7697_SPI_BUS_NUM);
pr_err(DRVNAME" %s(): spi_busnum_to_master(%d) failed\n",
__func__, MT7697_SPI_BUS_NUM);
ret = -EINVAL;
goto cleanup;
}
......@@ -127,6 +509,7 @@ void* mt7697q_init(u8 ch, void *priv, rx_hndlr rx_fcn)
dev_err(&master->dev,
"%s(): '%s' bus_find_device_by_name() failed\n",
__func__, str);
ret = -EINVAL;
goto cleanup;
}
......@@ -134,6 +517,7 @@ void* mt7697q_init(u8 ch, void *priv, rx_hndlr rx_fcn)
if (!spi) {
dev_err(&master->dev, "%s(): get SPI device failed\n",
__func__);
ret = -EINVAL;
goto cleanup;
}
......@@ -141,68 +525,68 @@ void* mt7697q_init(u8 ch, void *priv, rx_hndlr rx_fcn)
if (!qinfo) {
dev_dbg(&master->dev, "%s(): spi_get_drvdata() failed\n",
__func__);
ret = -EINVAL;
goto cleanup;
}
dev_dbg(&master->dev, "%s(): init queue(%u)\n", __func__, ch);
dev_dbg(qinfo->dev, "%s(): init queue spec(%u/%u)\n",
__func__, tx_ch, rx_ch);
if (ch >= MT7697_NUM_QUEUES) {
dev_err(&master->dev, "%s(): invalid queue(%u)\n",
__func__, ch);
if ((tx_ch >= MT7697_NUM_QUEUES) ||
(rx_ch >= MT7697_NUM_QUEUES)) {
dev_err(qinfo->dev, "%s(): invalid queue(%u/%u)\n",
__func__, tx_ch, rx_ch);
ret = -EINVAL;
goto cleanup;
}
qs = &qinfo->queues[ch];
qs->qinfo = qinfo;
qs->ch = ch;
qs->rx_fcn = rx_fcn;
qs->priv = priv;
qsTx = &qinfo->queues[tx_ch];
qsTx->qinfo = qinfo;
qsTx->ch = tx_ch;
qsTx->priv = priv;
*tx_hndl = qsTx;
mutex_lock(&qinfo->mutex);
qsRx = &qinfo->queues[rx_ch];
qsRx->qinfo = qinfo;
qsRx->ch = rx_ch;
qsRx->rx_fcn = rx_fcn;
qsRx->priv = priv;
ret = mt7697io_rd(qinfo,
MT7697_IO_SLAVE_BUFFER_ADDRESS + ch * sizeof(struct mt7697q_data),
(u32*)&qs->data,
MT7697_QUEUE_LEN_TO_WORD(sizeof(struct mt7697q_data)));
*rx_hndl = qsRx;
ret = mt7697q_read_state(tx_ch, qsTx);
if (ret < 0) {
dev_err(&master->dev, "%s(): mt7697io_rd() failed(%d)\n",
dev_err(qinfo->dev, "%s(): mt7697q_read_state() failed(%d)\n",
__func__, ret);
goto failed_rd;
goto cleanup;
}
dev_dbg(&master->dev, "%s(): flags(0x%08x)\n",
__func__, qs->data.flags);
dev_dbg(&master->dev, "%s(): base_addr(0x%08x)\n",
__func__, qs->data.base_addr);
dev_dbg(&master->dev, "%s(): rd_offset(0x%08x)\n",
__func__, qs->data.rd_offset);
dev_dbg(&master->dev, "%s(): wr_offset(0x%08x)\n",
__func__, qs->data.wr_offset);
if (!qs->data.base_addr) {
dev_err(&master->dev, "%s(): invalid base address(0x%08x)\n",
__func__, qs->data.base_addr);
goto failed_rd;
}
else if (!qs->data.flags) {
dev_err(&master->dev, "%s(): invalid flags(0x%08x)\n",
__func__, qs->data.flags);
goto failed_rd;
}
else if (qs->data.rd_offset || qs->data.wr_offset) {
dev_err(&master->dev,
"%s(): invalid rd/wr offset(0x%08x/0x%08x)\n",
__func__, qs->data.rd_offset, qs->data.wr_offset);
goto failed_rd;
ret = mt7697q_read_state(rx_ch, qsRx);
if (ret < 0) {
dev_err(qinfo->dev, "%s(): mt7697q_read_state() failed(%d)\n",
__func__, ret);
goto cleanup;
}
mutex_unlock(&qinfo->mutex);
return qs;
qsTx->data.flags |= BF_DEFINE(1, MT7697_QUEUE_FLAGS_IN_USE_OFFSET,
MT7697_QUEUE_FLAGS_IN_USE_WIDTH);
qsRx->data.flags |= BF_DEFINE(1, MT7697_QUEUE_FLAGS_IN_USE_OFFSET,
MT7697_QUEUE_FLAGS_IN_USE_WIDTH);
ret = mt7697q_send_init(tx_ch, rx_ch, qsTx);
if (ret < 0) {
dev_err(qinfo->dev, "%s(): mt7697q_send_init() failed(%d)\n",
__func__, ret);
goto cleanup;
}
failed_rd:
mutex_unlock(&qinfo->mutex);
cleanup:
memset(&qs, 0, sizeof(struct mt7697q_spec));
return NULL;
if (ret < 0) {
memset(&qsTx, 0, sizeof(struct mt7697q_spec));
memset(&qsRx, 0, sizeof(struct mt7697q_spec));
}
return ret;
}
EXPORT_SYMBOL(mt7697q_init);
......@@ -211,26 +595,30 @@ size_t mt7697q_read(void *hndl, u32 *buf, size_t num)
{
struct mt7697q_spec *qs = (struct mt7697q_spec*)hndl;
size_t rd_words = 0;
u16 write_offset;
u16 read_offset;
u32 buff_words;
int ret;
mutex_lock(&qs->qinfo->mutex);
buff_words = BF_GET(qs->data.flags,
MT7697_QUEUE_FLAGS_NUM_WORDS_OFFSET,
MT7697_QUEUE_FLAGS_NUM_WORDS_WIDTH);
write_offset = qs->data.wr_offset;
read_offset = qs->data.rd_offset;
dev_dbg(qs->qinfo->dev, "%s(): rd(%u) queue(%d) rd/wr offset(%d/%d)",
__func__, num, qs->ch, qs->data.rd_offset, qs->data.wr_offset);
if (qs->data.rd_offset > qs->data.wr_offset) {
const size_t words_to_end = buff_words -
qs->data.rd_offset;
const u32 rd_addr = qs->data.base_addr +
(qs->data.rd_offset * sizeof(u32));
__func__, num, qs->ch, read_offset, write_offset);
if (read_offset > write_offset) {
const size_t words_to_end = buff_words - read_offset;
const u32 rd_addr = qs->data.base_addr + (read_offset * sizeof(u32));
const size_t rd_num = (num <= words_to_end) ?
num : words_to_end;
dev_dbg(qs->qinfo->dev,
"%s(): rd(%u) queue(%u) offset(%u) addr(0x%08x)\n",
__func__, rd_num, qs->ch, qs->data.rd_offset, rd_addr);
"%s(): rd(%u) queue(%u) rd offset(%u) addr(0x%08x)\n",
__func__, rd_num, qs->ch, read_offset, rd_addr);
ret = mt7697io_rd(qs->qinfo, rd_addr, &buf[rd_words], rd_num);
if (ret < 0) {
dev_err(qs->qinfo->dev,
......@@ -240,30 +628,27 @@ size_t mt7697q_read(void *hndl, u32 *buf, size_t num)
}
rd_words += rd_num;
qs->data.rd_offset += rd_num;
read_offset += rd_num;
if (qs->data.rd_offset == buff_words) {
if (read_offset == buff_words) {
/*
* If we have read to the end, then
* set the read pointer to the beginning
*/
qs->data.rd_offset = 0;
read_offset = 0;
}
}
if (rd_words < num) {
/* NOTE: rd_offset assumed to be <= wr_offset at this point */
const size_t words_avail = qs->data.wr_offset -
qs->data.rd_offset;
const u32 rd_addr = qs->data.base_addr +
(qs->data.rd_offset * sizeof(u32));
const size_t words_avail = write_offset - read_offset;
const u32 rd_addr = qs->data.base_addr + (read_offset * sizeof(u32));
const size_t words_req = num - rd_words;
const size_t rd_num = (words_req <= words_avail) ?
words_req : words_avail;
const size_t rd_num = (words_req <= words_avail) ? words_req : words_avail;
dev_dbg(qs->qinfo->dev,
"%s(): rd(%u) queue(%u) offset(%u) addr(0x%08x)\n",
__func__, rd_num, qs->ch, qs->data.rd_offset, rd_addr);
"%s(): rd(%u) queue(%u) rd offset(%u) addr(0x%08x)\n",
__func__, rd_num, qs->ch, read_offset, rd_addr);
ret = mt7697io_rd(qs->qinfo, rd_addr, &buf[rd_words], rd_num);
if (ret < 0) {
dev_err(qs->qinfo->dev,
......@@ -273,22 +658,25 @@ size_t mt7697q_read(void *hndl, u32 *buf, size_t num)
}
rd_words += rd_num;
qs->data.rd_offset += rd_num;
read_offset += rd_num;
}
ret = mt7697q_push_rd_ptr(qs);
if (ret < 0) {
dev_err(qs->qinfo->dev,
"%s(): mt7697q_push_rd_ptr() failed(%d)\n",
__func__, ret);
if (read_offset >= buff_words) {
dev_err(qs->qinfo->dev, "%s(): rd offset(%u) >= size(%u)\n",
__func__, read_offset, buff_words);
WARN_ON(read_offset >= buff_words);
ret = -EINVAL;
goto cleanup;
}
dev_dbg(qs->qinfo->dev, "%s(): queue(%u) offset(%u) read(%u)\n",
__func__, qs->ch, qs->data.rd_offset, rd_words);
dev_dbg(qs->qinfo->dev, "%s(): queue(%u) rd offset(%u) read(%u)\n",
__func__, qs->ch, read_offset, rd_words);
qs->data.rd_offset = read_offset;
ret = rd_words;
cleanup:
mutex_unlock(&qs->qinfo->mutex);
return ret;
}
......@@ -299,7 +687,9 @@ size_t mt7697q_write(void *hndl, const u32 *buff, size_t num)
struct mt7697q_spec *qs = (struct mt7697q_spec*)hndl;
size_t avail;
size_t words_written = 0;
uint32_t wr_words;
u16 read_offset;
u16 write_offset;
uint32_t buff_words;
int ret;
mutex_lock(&qs->qinfo->mutex);
......@@ -314,31 +704,32 @@ size_t mt7697q_write(void *hndl, const u32 *buff, size_t num)
avail = mt7697q_get_free_words(qs);
dev_dbg(qs->qinfo->dev, "%s(): free words(%u)\n", __func__, avail);
if (avail < num)
{
if (avail < num) {
dev_warn(qs->qinfo->dev, "%s(): queue avail(%u < %u)\n",
__func__, avail, num);
ret = -EAGAIN;
goto cleanup;
}
wr_words = BF_GET(qs->data.flags, MT7697_QUEUE_FLAGS_NUM_WORDS_OFFSET,
buff_words = BF_GET(qs->data.flags, MT7697_QUEUE_FLAGS_NUM_WORDS_OFFSET,
MT7697_QUEUE_FLAGS_NUM_WORDS_WIDTH);
read_offset = qs->data.rd_offset;
write_offset = qs->data.wr_offset;
dev_dbg(qs->qinfo->dev, "%s(): wr(%u) queue(%d) rd/wr offset(%d/%d)",
__func__, num, qs->ch, qs->data.rd_offset, qs->data.wr_offset);
if (qs->data.wr_offset >= qs->data.rd_offset) {
const size_t words_to_end = wr_words - qs->data.wr_offset;
const size_t words_avail = (qs->data.rd_offset == 0) ?
__func__, num, qs->ch, read_offset, write_offset);
if (write_offset >= read_offset) {
const size_t words_to_end = buff_words - write_offset;
const size_t words_avail = (read_offset == 0) ?
(words_to_end - 1) : words_to_end;
const size_t words_to_write =
(num <= words_avail) ? num : words_avail;
const u32 write_addr = qs->data.base_addr +
(qs->data.wr_offset * sizeof(u32));
(write_offset * sizeof(u32));
dev_dbg(qs->qinfo->dev,
"%s(): wr(%u) queue(%u) offset(%u) addr(0x%08x)\n",
__func__, words_to_write, qs->ch, qs->data.wr_offset,
"%s(): wr(%u) queue(%u) wr offset(%u) addr(0x%08x)\n",
__func__, words_to_write, qs->ch, write_offset,
write_addr);
ret = mt7697io_wr(qs->qinfo, write_addr, &buff[words_written],
words_to_write);
......@@ -351,22 +742,22 @@ size_t mt7697q_write(void *hndl, const u32 *buff, size_t num)
words_written += words_to_write;
num -= words_to_write;
qs->data.wr_offset += words_to_write;
if (qs->data.wr_offset == wr_words) {
qs->data.wr_offset = 0;
write_offset += words_to_write;
if (write_offset == buff_words) {
write_offset = 0;
}
}
if ((qs->data.wr_offset < qs->data.rd_offset) && (num > 0)) {
const size_t words_to_read = qs->data.rd_offset - qs->data.wr_offset - 1;
if ((write_offset < read_offset) && (num > 0)) {
const size_t words_to_read = read_offset - write_offset - 1;
const size_t words_to_write = (num <= words_to_read) ?
num : words_to_read;
const uint32_t write_addr = qs->data.base_addr +
(qs->data.wr_offset * sizeof(u32));
(write_offset * sizeof(u32));
dev_dbg(qs->qinfo->dev,
"%s(): wr(%u) queue(%u) offset(%u) addr(0x%08x)\n",
__func__, words_to_write, qs->ch, qs->data.wr_offset,
"%s(): wr(%u) queue(%u) wr offset(%u) addr(0x%08x)\n",
__func__, words_to_write, qs->ch, write_offset,
write_addr);
ret = mt7697io_wr(qs->qinfo, write_addr, &buff[words_written],
words_to_write);
......@@ -379,9 +770,21 @@ size_t mt7697q_write(void *hndl, const u32 *buff, size_t num)
words_written += words_to_write;
num -= words_to_write;
qs->data.wr_offset += words_to_write;
write_offset += words_to_write;
}
if (write_offset >= buff_words) {
dev_err(qs->qinfo->dev, "%s(): wr offset(%u) >= size(%u)\n",
__func__, write_offset, buff_words);
WARN_ON(write_offset >= buff_words);
ret = -EINVAL;
goto cleanup;
}
dev_dbg(qs->qinfo->dev, "%s(): queue(%u) wr offset(%u) write(%u)\n",
__func__, qs->ch, write_offset, words_written);
qs->data.wr_offset = write_offset;
ret = mt7697q_push_wr_ptr(qs);
if (ret < 0) {
dev_err(qs->qinfo->dev,
......@@ -390,8 +793,6 @@ size_t mt7697q_write(void *hndl, const u32 *buff, size_t num)
goto cleanup;
}
dev_dbg(qs->qinfo->dev, "%s(): queue(%u) offset(%u) write(%u)\n",
__func__, qs->ch, qs->data.wr_offset, words_written);
ret = words_written;
cleanup:
......@@ -401,87 +802,6 @@ cleanup:
EXPORT_SYMBOL(mt7697q_write);
int mt7697q_pull_wr_ptr(void *hndl)
{
struct mt7697q_spec *qs = (struct mt7697q_spec*)hndl;
const u32 read_addr = MT7697_IO_SLAVE_BUFFER_ADDRESS +
(qs->ch * sizeof(struct mt7697q_data)) +
offsetof(struct mt7697q_data, wr_offset);
int ret;
qs->qinfo->s2m_mbox = 1 << qs->ch;
ret = mt7697io_clr_s2m_mbx(qs->qinfo);
if (ret < 0) {
dev_err(qs->qinfo->dev,
"%s(): mt7697io_clr_s2m_mbx() failed(%d)\n",
__func__, ret);
goto cleanup;
}
dev_dbg(qs->qinfo->dev,
"%s(): pull wr ptr queue(%u) rd addr(0x%08x)\n",
__func__, qs->ch, read_addr);
ret = mt7697io_rd(qs->qinfo, read_addr, &qs->data.wr_offset,
MT7697_QUEUE_LEN_TO_WORD(sizeof(qs->data.wr_offset)));
if (ret < 0) {
dev_err(qs->qinfo->dev, "%s(): mt7697io_rd() failed(%d)\n",
__func__, ret);
goto cleanup;
}
dev_dbg(qs->qinfo->dev, "%s(): wr offset(%u)\n",
__func__, qs->data.wr_offset);
cleanup:
return ret;
}
EXPORT_SYMBOL(mt7697q_pull_wr_ptr);
int mt7697q_pull_rd_ptr(void *hndl)
{
struct mt7697q_spec *qs = (struct mt7697q_spec*)hndl;
const u32 read_addr = MT7697_IO_SLAVE_BUFFER_ADDRESS +
(qs->ch * sizeof(struct mt7697q_data)) +
offsetof(struct mt7697q_data, rd_offset);
int ret;
qs->qinfo->s2m_mbox = 1 << qs->ch;
ret = mt7697io_clr_s2m_mbx(qs->qinfo);
if (ret < 0) {
dev_err(qs->qinfo->dev,
"%s(): mt7697io_clr_s2m_mbx() failed(%d)\n",
__func__, ret);
goto cleanup;
}
dev_dbg(qs->qinfo->dev,
"%s(): pull rd ptr queue(%u) rd addr(0x%08x)\n",
__func__, qs->ch, read_addr);
ret = mt7697io_rd(qs->qinfo, read_addr, &qs->data.rd_offset,
MT7697_QUEUE_LEN_TO_WORD(sizeof(qs->data.rd_offset)));
if (ret < 0) {
dev_err(qs->qinfo->dev, "%s(): mt7697io_rd() failed(%d)\n",
__func__, ret);
goto cleanup;
}
dev_dbg(qs->qinfo->dev, "%s(): rd offset(%u)\n",
__func__, qs->data.rd_offset);
cleanup:
return ret;
}
EXPORT_SYMBOL(mt7697q_pull_rd_ptr);
__inline u8 mt7697q_busy(u16 value)
{
return BF_GET(value,
MT7697_IO_STATUS_REG_BUSY_OFFSET,
MT7697_IO_STATUS_REG_BUSY_WIDTH);
}
__inline u32 mt7697q_flags_get_in_use(u32 flags)
{
return BF_GET(flags, MT7697_QUEUE_FLAGS_IN_USE_OFFSET,
......@@ -494,30 +814,3 @@ __inline u32 mt7697q_flags_get_dir(u32 flags)
MT7697_QUEUE_FLAGS_DIR_WIDTH);
}
__inline size_t mt7697q_get_capacity(const void *hndl)
{
const struct mt7697q_spec *qs = (const struct mt7697q_spec*)hndl;
return BF_GET(qs->data.flags, MT7697_QUEUE_FLAGS_NUM_WORDS_OFFSET,
MT7697_QUEUE_FLAGS_NUM_WORDS_WIDTH) - 1;
}
EXPORT_SYMBOL(mt7697q_get_capacity);
__inline size_t mt7697q_get_num_words(const void *hndl)
{
const struct mt7697q_spec *qs = (const struct mt7697q_spec*)hndl;
return mt7697q_buf_diff(BF_GET(qs->data.flags,
MT7697_QUEUE_FLAGS_NUM_WORDS_OFFSET,
MT7697_QUEUE_FLAGS_NUM_WORDS_WIDTH),
qs->data.rd_offset, qs->data.wr_offset);
}
EXPORT_SYMBOL(mt7697q_get_num_words);
__inline size_t mt7697q_get_free_words(const void *hndl)
{
return mt7697q_get_capacity(hndl) -
mt7697q_get_num_words(hndl);
}
EXPORT_SYMBOL(mt7697q_get_free_words);
......@@ -18,9 +18,10 @@
#define _MT7697_QUEUE_H_
#include <linux/types.h>
#include <linux/interrupt.h>
#include "queue_i.h"
#define MT7697_NUM_QUEUES 7
#define MT7697_NUM_QUEUES 6
#define MT7697_QUEUE_FLAGS_IN_USE_OFFSET 0
#define MT7697_QUEUE_FLAGS_IN_USE_WIDTH 1
......@@ -33,14 +34,14 @@
#define MT7697_QUEUE_DEBUG_DUMP_LIMIT 1024
typedef int (*rx_hndlr)(void*);
struct mt7697q_data {
u32 flags;
u32 base_addr;
u32 rd_offset;
u32 wr_offset;
} __attribute__((packed));
u16 rd_offset;
u16 reserved1;
u16 wr_offset;
u16 reserved2;
};
struct mt7697q_spec {
struct mt7697q_data data;
......@@ -52,6 +53,7 @@ struct mt7697q_spec {
struct mt7697q_info {
struct mt7697q_spec queues[MT7697_NUM_QUEUES];
struct mt7697q_rsp_hdr rsp;
u8 txBuffer[sizeof(u32)];
u8 rxBuffer[sizeof(u16)];
......@@ -62,30 +64,18 @@ struct mt7697q_info {
struct mutex mutex;
struct workqueue_struct *irq_workq;
// struct work_struct irq_work;
struct delayed_work irq_work;
struct work_struct irq_work;
struct delayed_work irq_delayed_work;
int irq;
u8 s2m_mbox;
bool slave_busy;
};
u8 mt7697q_busy(u16);
u8 mt7697q_get_s2m_mbox(u16);
u16 mt7697q_set_s2m_mbox(u8);
u8 mt7697q_get_m2s_mbox(u16);
u32 mt7697q_flags_get_in_use(u32);
u32 mt7697q_flags_get_dir(u32);
void* mt7697q_init(u8, void*, rx_hndlr);
size_t mt7697q_read(void*, u32*, size_t);
size_t mt7697q_write(void*, const u32*, size_t);
int mt7697q_pull_rd_ptr(void*);
int mt7697q_pull_wr_ptr(void*);
void mt7697_irq_delayed_work(struct work_struct*);
void mt7697_irq_work(struct work_struct*);
irqreturn_t mt7697_isr(int, void*);
size_t mt7697q_get_capacity(const void*);
size_t mt7697q_get_num_words(const void*);
size_t mt7697q_get_free_words(const void*);
int mt7697q_proc_data(struct mt7697q_spec*);
int mt7697q_get_s2m_mbx(struct mt7697q_info*, u8*);
#endif
......@@ -17,49 +17,83 @@
#ifndef _MT7697_QUEUE_I_H_
#define _MT7697_QUEUE_I_H_
#define MT7697_QUEUE_LEN_TO_WORD(x) ((x) / sizeof(u32) + \
#define LEN32_ALIGNED(x) (((x) / sizeof(u32) + \
((x) % sizeof(u32) ? 1:0)) * sizeof(u32))
#define LEN_TO_WORD(x) ((x) / sizeof(u32) + \
((x) % sizeof(u32) ? 1:0))
#define mt7697_queue_init_rsp mt7697q_rsp_hdr
#define mt7697_queue_unused_rsp mt7697q_rsp_hdr
#define mt7697_queue_reset_rsp mt7697q_rsp_hdr
enum mt7697q_dir
{
MT7697_QUEUE_DIR_MASTER_TO_SLAVE = 0,
MT7697_QUEUE_DIR_SLAVE_TO_MASTER,
MT7697_QUEUE_DIR_M2S = 0,
MT7697_QUEUE_DIR_S2M,
};
enum mt7697q_cmd_grp {
MT7697_CMD_GRP_QUEUE = 0,
MT7697_CMD_GRP_80211,
MT7697_CMD_GRP_BT,
};
typedef int (*rx_hndlr)(void*);
enum mt7697q_cmd_types {
MT7697_CMD_QUEUE_INIT = 0,
MT7697_CMD_QUEUE_INIT_RSP,
MT7697_CMD_QUEUE_UNUSED,
MT7697_CMD_QUEUE_UNUSED_RSP,
MT7697_CMD_QUEUE_RESET,
MT7697_CMD_QUEUE_RESET_RSP,
};
struct mt7697q_cmd_hdr {
__be16 len;
u8 grp;
u8 type;
} __attribute__((__packed__, aligned(4)));
struct mt7697q_rsp_hdr {
struct mt7697q_cmd_hdr cmd;
__be32 result;
} __attribute__((__packed__, aligned(4)));
struct mt7697_queue_init_req {
struct mt7697q_cmd_hdr cmd;
__be32 m2s_ch;
__be32 s2m_ch;
} __attribute__((packed, aligned(4)));
struct mt7697_queue_unused_req {
struct mt7697q_cmd_hdr cmd;
__be32 m2s_ch;
__be32 s2m_ch;
} __attribute__((packed, aligned(4)));
struct mt7697_queue_reset_req {
struct mt7697q_cmd_hdr cmd;
__be32 m2s_ch;
__be32 s2m_ch;
} __attribute__((packed, aligned(4)));
typedef int (*rx_hndlr)(const struct mt7697q_rsp_hdr*, void*);
struct mt7697q_if_ops {
void* (*init)(u8, void*, rx_hndlr);
int (*init)(u8, u8, void*, rx_hndlr, void**, void**);
size_t (*read)(void*, u32*, size_t);
size_t (*write)(void*, const u32*, size_t);
int (*pull_rd_ptr)(void*);
int (*pull_wr_ptr)(void*);
size_t (*capacity)(const void*);
size_t (*num_wr)(const void*);
size_t (*num_rd)(const void*);
void (*reset)(void*);
void (*enable_irq)(void*);
void (*disable_irq)(void*);
};
u8 mt7697q_busy(u16);
u8 mt7697q_get_s2m_mbox(u16);
u16 mt7697q_set_s2m_mbox(u8);
u8 mt7697q_get_m2s_mbox(u16);
u16 mt7697q_set_m2s_mbox(u8);
u32 mt7697q_flags_get_in_use(u32);
u32 mt7697q_flags_get_dir(u32);
void* mt7697q_init(u8, void*, rx_hndlr);
int mt7697q_init(u8, u8, void*, rx_hndlr, void**, void**);
size_t mt7697q_read(void*, u32*, size_t);
size_t mt7697q_write(void*, const u32*, size_t);
int mt7697q_pull_rd_ptr(void*);
int mt7697q_pull_wr_ptr(void*);
size_t mt7697q_get_capacity(const void*);
size_t mt7697q_get_num_words(const void*);
size_t mt7697q_get_free_words(const void*);
int mt7697q_send_reset(void*, void*);
#endif
......@@ -24,6 +24,7 @@
#include <linux/irq.h>
#include <linux/of.h>
#include <linux/usb.h>
#include <linux/gpio.h>
#include "interrupt.h"
#include "queue.h"
#include "spi.h"
......@@ -35,12 +36,16 @@ static void mt7697spi_reset(struct spi_device *spi)
static void mt7697spi_enable_irq(struct spi_device *spi)
{
enable_irq(spi->irq);
struct mt7697q_info *qinfo = spi_get_drvdata(spi);
WARN_ON(!qinfo);
enable_irq(qinfo->irq);
}
static void mt7697spi_disable_irq(struct spi_device *spi)
{
disable_irq(spi->irq);
struct mt7697q_info *qinfo = spi_get_drvdata(spi);
WARN_ON(!qinfo);
disable_irq(qinfo->irq);
}
static const struct mt7697spi_hw_ops hw_ops =
......@@ -62,6 +67,10 @@ static int __init mt7697spi_init(void)
struct mt7697q_info *qinfo;
int ret = 0;
pr_info(DRVNAME" %s(): '%s' initialize\n", __func__, DRVNAME);
pr_info(DRVNAME" %s(): get SPI master bus(%u)\n",
__func__, MT7697_SPI_BUS_NUM);
master = spi_busnum_to_master(MT7697_SPI_BUS_NUM);
if (!master) {
pr_err(DRVNAME" spi_busnum_to_master(%d) failed\n",
......@@ -70,27 +79,31 @@ static int __init mt7697spi_init(void)
}
snprintf(str, sizeof(str), "%s.%u", dev_name(&master->dev), MT7697_SPI_CS);
pr_info(DRVNAME" find SPI device('%s')\n", str);
dev_info(&master->dev, "%s(): find SPI device('%s')\n", __func__, str);
dev = bus_find_device_by_name(&spi_bus_type, NULL, str);
if (!dev) {
pr_err(DRVNAME" '%s' bus_find_device_by_name() failed\n", str);
dev_err(&master->dev,
"%s(): '%s' bus_find_device_by_name() failed\n",
__func__, str);
goto cleanup;
}
spi = container_of(dev, struct spi_device, dev);
if (!spi) {
pr_err(DRVNAME" get SPI device failed\n");
dev_err(&master->dev, "%s(): get SPI device failed\n",
__func__);
goto cleanup;
}
pr_info(DRVNAME" init dev('%s') mode(%d) max speed(%d) "
dev_info(&master->dev, "%s(): init dev('%s') mode(%d) max speed(%d) "
"CS(%d) GPIO(%d) bits/word(%d)\n",
spi->modalias, spi->mode, spi->max_speed_hz, spi->chip_select,
spi->cs_gpio, spi->bits_per_word);
__func__, spi->modalias, spi->mode, spi->max_speed_hz,
spi->chip_select, spi->cs_gpio, spi->bits_per_word);
qinfo = kzalloc(sizeof(struct mt7697q_info), GFP_KERNEL);
if (!qinfo) {
pr_err(DRVNAME" create queue info failed\n");
dev_err(&master->dev, "%s(): create queue info failed\n",
__func__);
ret = -ENOMEM;
goto cleanup;
}
......@@ -102,40 +115,47 @@ static int __init mt7697spi_init(void)
qinfo->hw_ops = &hw_ops;
mutex_init(&qinfo->mutex);
INIT_DELAYED_WORK(&qinfo->irq_delayed_work, mt7697_irq_delayed_work);
INIT_WORK(&qinfo->irq_work, mt7697_irq_work);
qinfo->irq_workq = create_workqueue(DRVNAME);
if (!qinfo) {
pr_err(DRVNAME" create_workqueue() failed\n");
qinfo->irq_workq = create_workqueue(DRVNAME"wq");
if (!qinfo->irq_workq) {
dev_err(qinfo->dev, "%s(): create_workqueue() failed\n",
__func__);
ret = -ENOMEM;
goto cleanup;
}
/* TODO: revove after CP2130 working */
INIT_DELAYED_WORK(&qinfo->irq_work, mt7697_irq_work);
// INIT_WORK(&qinfo->irq_work, mt7697_irq_work);
qinfo->irq = spi->irq;
dev_info(qinfo->dev, "'%s' request irq(%d)\n", spi->modalias, spi->irq);
/* ret = request_irq(spi->irq, mt7697_irq,
IRQF_SHARED| IRQF_NO_SUSPEND, spi->modalias, qinfo);
ret = gpio_request(MT7697_SPI_INTR_GPIO_PIN, MT7697_GPIO_IRQ_NAME);
if (ret < 0) {
pr_err(DRVNAME" request_irq() failed(%d)", ret);
goto failed_irq;
dev_err(qinfo->dev, "%s(): gpio_request() failed(%d)",
__func__, ret);
goto failed_workqueue;
}
*/
spi_set_drvdata(spi, qinfo);
/* TODO: revove after CP2130 working */
ret = queue_delayed_work(qinfo->irq_workq, &qinfo->irq_work,
msecs_to_jiffies(1000));
gpio_direction_input(MT7697_SPI_INTR_GPIO_PIN);
qinfo->irq = gpio_to_irq(MT7697_SPI_INTR_GPIO_PIN);
dev_info(qinfo->dev, "%s(): request irq(%d)\n", __func__, qinfo->irq);
ret = request_irq(qinfo->irq, mt7697_isr, 0, DRVNAME, qinfo);
if (ret < 0) {
dev_err(qinfo->dev,
"queue_delayed_work() failed(%d)\n", ret);
dev_err(qinfo->dev, "%s(): request_irq() failed(%d)",
__func__, ret);
goto failed_gpio_req;
}
irq_set_irq_type(qinfo->irq, IRQ_TYPE_EDGE_BOTH);
spi_set_drvdata(spi, qinfo);
dev_info(qinfo->dev, "%s(): '%s' initialized\n", __func__, DRVNAME);
return 0;
/*failed_irq:
failed_workqueue:
destroy_workqueue(qinfo->irq_workq);
free_irq(spi->irq, qinfo);*/
failed_gpio_req:
gpio_free(MT7697_SPI_INTR_GPIO_PIN);
cleanup:
kfree(qinfo);
return ret;
......@@ -149,35 +169,48 @@ static void __exit mt7697spi_exit(void)
struct spi_device *spi;
struct mt7697q_info *qinfo;
pr_info(DRVNAME" %s(): get SPI master bus(%u)\n",
__func__, MT7697_SPI_BUS_NUM);
master = spi_busnum_to_master(MT7697_SPI_BUS_NUM);
if (!master) {
pr_err(DRVNAME" spi_busnum_to_master(%d) failed\n",
MT7697_SPI_BUS_NUM);
pr_err(DRVNAME" %s(): spi_busnum_to_master(%d) failed\n",
__func__, MT7697_SPI_BUS_NUM);
goto cleanup;
}
snprintf(str, sizeof(str), "%s.%u", dev_name(&master->dev), MT7697_SPI_CS);
pr_info(DRVNAME" find SPI device('%s')\n", str);
dev_info(&master->dev, "%s(): find SPI device('%s')\n", __func__, str);
dev = bus_find_device_by_name(&spi_bus_type, NULL, str);
if (!dev) {
pr_err(DRVNAME" '%s' bus_find_device_by_name() failed\n", str);
dev_err(&master->dev,
"%s(): '%s' bus_find_device_by_name() failed\n",
__func__, str);
goto cleanup;
}
spi = container_of(dev, struct spi_device, dev);
if (!spi) {
pr_err(DRVNAME" get SPI device failed\n");
dev_err(dev, "%s(): get SPI device failed\n",
__func__);
goto cleanup;
}
qinfo = spi_get_drvdata(spi);
if (qinfo) {
dev_info(qinfo->dev, "remove\n");
if (!qinfo) {
dev_err(dev, "%s(): SPI device no queue info\n",
__func__);
goto cleanup;
}
dev_info(qinfo->dev, "%s(): remove '%s'\n", __func__, DRVNAME);
cancel_delayed_work_sync(&qinfo->irq_delayed_work);
cancel_work_sync(&qinfo->irq_work);
flush_workqueue(qinfo->irq_workq);
destroy_workqueue(qinfo->irq_workq);
// free_irq(spi->irq, qinfo);
free_irq(qinfo->irq, qinfo);
gpio_free(MT7697_SPI_INTR_GPIO_PIN);
kfree(qinfo);
}
cleanup:
return;
......
......@@ -25,6 +25,9 @@
#include <linux/spi/spi.h>
#define DRVNAME "mt7697q"
#define MT7697_GPIO_IRQ_NAME "mt7697q irq"
#define MT7697_SPI_INTR_GPIO_PIN 50//21
#define MT7697_SPI_BUS_NUM 32766
#define MT7697_SPI_CS 0
......
- use variable length fields
- use msg to set if idx for each mode (STA, AP)
- connect/scan/connect failed - need to notify cfg of disconnect
- master to slave rd offset corrupted
- use memory pool for MT7697 SPI messages
......@@ -169,6 +169,9 @@ static int mt7697_cfg80211_vif_stop(struct mt7697_vif *vif, bool wmi_ready)
}
del_timer(&vif->disconnect_timer);
memset(vif->ssid, 0, sizeof(vif->ssid));
vif->ssid_len = 0;
}
if (vif->scan_req) {
......@@ -214,7 +217,7 @@ static int mt7697_set_assoc_req_ies(struct mt7697_vif *vif, const u8 *ies,
if (ies && ies_len) {
buf = kmalloc(ies_len, GFP_KERNEL);
if (buf == NULL) {
dev_err(cfg->dev, "%s: kmalloc() failed\n", __func__);
dev_err(cfg->dev, "%s(): kmalloc() failed\n", __func__);
ret = -ENOMEM;
goto cleanup;
}
......@@ -251,7 +254,7 @@ static int mt7697_set_key_mgmt(struct mt7697_vif *vif, u32 key_mgmt)
{
int ret = 0;
dev_dbg(vif->cfg->dev, "%s: key mgmt(0x%08x)\n", __func__, key_mgmt);
dev_dbg(vif->cfg->dev, "%s(): key mgmt(0x%08x)\n", __func__, key_mgmt);
if (key_mgmt == WLAN_AKM_SUITE_PSK) {
if (vif->auth_mode == MT7697_WIFI_AUTH_MODE_WPA)
......@@ -259,7 +262,7 @@ static int mt7697_set_key_mgmt(struct mt7697_vif *vif, u32 key_mgmt)
else if (vif->auth_mode == MT7697_WIFI_AUTH_MODE_WPA2)
vif->auth_mode = MT7697_WIFI_AUTH_MODE_WPA2_PSK;
} else if (key_mgmt == 0x00409600) {
dev_err(vif->cfg->dev, "%s: key mgmt(0x%08x) not supported\n",
dev_err(vif->cfg->dev, "%s(): key mgmt(0x%08x) not supported\n",
__func__, key_mgmt);
ret = -ENOTSUPP;
goto cleanup;
......@@ -267,7 +270,7 @@ static int mt7697_set_key_mgmt(struct mt7697_vif *vif, u32 key_mgmt)
vif->auth_mode = MT7697_WIFI_AUTH_MODE_OPEN;
}
dev_dbg(vif->cfg->dev, "%s: auth mode(%u)\n",
dev_dbg(vif->cfg->dev, "%s(): auth mode(%u)\n",
__func__, vif->auth_mode);
cleanup:
......@@ -282,7 +285,7 @@ static int mt7697_set_cipher(struct mt7697_vif *vif, u32 cipher, bool ucast)
&vif->grp_crypto_len;
int ret = 0;
dev_dbg(vif->cfg->dev, "%s: cipher(0x%08x), ucast(%u)\n",
dev_dbg(vif->cfg->dev, "%s(): cipher(0x%08x), ucast(%u)\n",
__func__, cipher, ucast);
switch (cipher) {
......@@ -303,12 +306,13 @@ static int mt7697_set_cipher(struct mt7697_vif *vif, u32 cipher, bool ucast)
case WLAN_CIPHER_SUITE_WEP40:
case WLAN_CIPHER_SUITE_SMS4:
default:
dev_err(vif->cfg->dev, "cipher(0x%08x) not supported\n", cipher);
dev_err(vif->cfg->dev, "cipher(0x%08x) not supported\n",
cipher);
ret = -ENOTSUPP;
goto cleanup;
}
dev_dbg(vif->cfg->dev, "%s: set cipher(%u)\n", __func__, *_cipher);
dev_dbg(vif->cfg->dev, "%s(): set cipher(%u)\n", __func__, *_cipher);
cleanup:
return ret;
......@@ -319,7 +323,7 @@ static int mt7697_set_auth_type(struct mt7697_vif *vif,
{
int ret = 0;
dev_dbg(vif->cfg->dev, "%s: type(%u)\n", __func__, auth_type);
dev_dbg(vif->cfg->dev, "%s(): type(%u)\n", __func__, auth_type);
switch (auth_type) {
case NL80211_AUTHTYPE_OPEN_SYSTEM:
......@@ -333,7 +337,7 @@ static int mt7697_set_auth_type(struct mt7697_vif *vif,
break;
default:
dev_err(vif->cfg->dev, "%s: type(%u) not supported\n",
dev_err(vif->cfg->dev, "%s(): type(%u) not supported\n",
__func__, auth_type);
ret = -ENOTSUPP;
goto cleanup;
......@@ -348,7 +352,8 @@ static int mt7697_set_wpa_version(struct mt7697_vif *vif,
{
int ret = 0;
dev_dbg(vif->cfg->dev, "%s: WPA version(%u)\n", __func__, wpa_version);
dev_dbg(vif->cfg->dev, "%s(): WPA version(%u)\n",
__func__, wpa_version);
if (!wpa_version) {
vif->auth_mode = MT7697_WIFI_AUTH_MODE_OPEN;
......@@ -357,7 +362,7 @@ static int mt7697_set_wpa_version(struct mt7697_vif *vif,
} else if (wpa_version & NL80211_WPA_VERSION_1) {
vif->auth_mode = MT7697_WIFI_AUTH_MODE_WPA;
} else {
dev_err(vif->cfg->dev, "%s: WPA version(%u) not supported\n",
dev_err(vif->cfg->dev, "%s(): WPA version(%u) not supported\n",
__func__, wpa_version);
ret = -ENOTSUPP;
goto cleanup;
......@@ -410,7 +415,7 @@ static struct cfg80211_bss* mt7697_add_bss_if_needed(struct mt7697_vif *vif,
chan = ieee80211_get_channel(cfg->wiphy, freq);
if (!chan) {
dev_err(cfg->dev, "%s: ieee80211_get_channel(%u) failed\n",
dev_err(cfg->dev, "%s(): ieee80211_get_channel(%u) failed\n",
__func__, freq);
goto cleanup;
}
......@@ -427,7 +432,7 @@ static struct cfg80211_bss* mt7697_add_bss_if_needed(struct mt7697_vif *vif,
*/
ie = kmalloc(2 + vif->ssid_len, GFP_KERNEL);
if (ie == NULL) {
dev_err(cfg->dev, "%s: kmalloc() failed\n",
dev_err(cfg->dev, "%s(): kmalloc() failed\n",
__func__);
goto cleanup;
}
......@@ -436,7 +441,7 @@ static struct cfg80211_bss* mt7697_add_bss_if_needed(struct mt7697_vif *vif,
ie[1] = vif->ssid_len;
memcpy(ie + 2, vif->ssid, vif->ssid_len);
dev_dbg(cfg->dev, "%s: inform bss ssid(%u/'%s')\n",
dev_dbg(cfg->dev, "%s(): inform bss ssid(%u/'%s')\n",
__func__, vif->ssid_len, vif->ssid);
print_hex_dump(KERN_DEBUG, DRVNAME" inform bss BSSID ",
DUMP_PREFIX_OFFSET, 16, 1, bssid, ETH_ALEN, 0);
......@@ -446,15 +451,16 @@ static struct cfg80211_bss* mt7697_add_bss_if_needed(struct mt7697_vif *vif,
ie, 2 + vif->ssid_len,
0, GFP_KERNEL);
if (!bss) {
dev_err(cfg->dev, "%s: cfg80211_inform_bss() failed\n",
dev_err(cfg->dev, "%s(): cfg80211_inform_bss() failed\n",
__func__);
goto cleanup;
}
dev_dbg(cfg->dev, "%s: added bss %pM to cfg80211\n",
dev_dbg(cfg->dev, "%s(): added bss %pM to cfg80211\n",
__func__, bssid);
} else
dev_dbg(cfg->dev, "%s: cfg80211 already has a bss\n", __func__);
dev_dbg(cfg->dev, "%s(): cfg80211 already has a bss\n",
__func__);
cleanup:
if (ie) kfree(ie);
......@@ -471,22 +477,24 @@ static struct wireless_dev *mt7697_cfg80211_add_iface(struct wiphy *wiphy,
struct wireless_dev *wdev = NULL;
u8 if_idx;
dev_dbg(cfg->dev, "%s: iface('%s') type(%u)\n", __func__, name, type);
dev_dbg(cfg->dev, "%s(): iface('%s') type(%u)\n",
__func__, name, type);
if (cfg->num_vif == cfg->vif_max) {
dev_err(cfg->dev, "maximum number of supported vif(%u)\n",
dev_err(cfg->dev, "max # of supported vif(%u)\n",
cfg->num_vif);
goto cleanup;
}
if (!mt7697_is_valid_iftype(cfg, type, &if_idx)) {
dev_err(cfg->dev, "%s: unsupported interface type(%d)\n",
dev_err(cfg->dev, "%s(): unsupported interface type(%d)\n",
__func__, type);
goto cleanup;
}
wdev = mt7697_interface_add(cfg, name, type, if_idx);
if (!wdev) {
dev_err(cfg->dev, "%s: mt7697_interface_add() failed\n", __func__);
dev_err(cfg->dev, "%s(): mt7697_interface_add() failed\n",
__func__);
goto cleanup;
}
......@@ -503,7 +511,7 @@ static int mt7697_cfg80211_del_iface(struct wiphy *wiphy,
struct mt7697_vif *vif = netdev_priv(wdev->netdev);
int ret;
dev_dbg(cfg->dev, "%s: DEL IFACE\n", __func__);
dev_dbg(cfg->dev, "%s(): DEL IFACE\n", __func__);
spin_lock_bh(&cfg->vif_list_lock);
list_del(&vif->list);
......@@ -511,7 +519,7 @@ static int mt7697_cfg80211_del_iface(struct wiphy *wiphy,
ret = mt7697_cfg80211_vif_stop(vif, test_bit(WMI_READY, &cfg->flag));
if (ret < 0) {
dev_err(cfg->dev, "%s: mt7697_cfg80211_vif_stop() failed(%d)\n",
dev_err(cfg->dev, "%s(): mt7697_cfg80211_vif_stop() failed(%d)\n",
__func__, ret);
goto cleanup;
}
......@@ -529,7 +537,7 @@ static int mt7697_cfg80211_change_iface(struct wiphy *wiphy,
struct mt7697_vif *vif = netdev_priv(ndev);
int ret = 0;
dev_dbg(cfg->dev, "%s: iface type(%u)\n", __func__, type);
dev_dbg(cfg->dev, "%s(): iface type(%u)\n", __func__, type);
switch (type) {
case NL80211_IFTYPE_AP:
......@@ -539,7 +547,7 @@ static int mt7697_cfg80211_change_iface(struct wiphy *wiphy,
case NL80211_IFTYPE_P2P_GO:
case NL80211_IFTYPE_P2P_CLIENT:
default:
dev_err(cfg->dev, "%s: invalid interface type %u\n",
dev_err(cfg->dev, "%s(): invalid interface type %u\n",
__func__, type);
ret = -EOPNOTSUPP;
goto cleanup;
......@@ -558,29 +566,40 @@ static int mt7697_cfg80211_scan(struct wiphy *wiphy,
struct mt7697_cfg80211_info *cfg = wiphy_to_cfg(wiphy);
int ret;
dev_dbg(cfg->dev, "%s: START SCAN\n", __func__);
dev_dbg(cfg->dev, "%s(): START SCAN\n", __func__);
if (test_bit(CONNECTED, &vif->flags)) {
dev_warn(cfg->dev,
"%s: connected scan not allowed\n", __func__);
"%s(): connected scan not allowed\n", __func__);
ret = -EINVAL;
goto out;
}
if (test_bit(CONNECT_PEND, &vif->flags)) {
dev_dbg(cfg->dev, "%s: pending connection t/o\n", __func__);
dev_dbg(cfg->dev, "%s(): pending connection t/o\n", __func__);
print_hex_dump(KERN_DEBUG, DRVNAME" BSSID ",
DUMP_PREFIX_OFFSET, 16, 1, vif->req_bssid, ETH_ALEN, 0);
cfg80211_connect_result(vif->ndev, vif->req_bssid,
NULL, 0,
NULL, 0,
WLAN_STATUS_UNSPECIFIED_FAILURE, GFP_KERNEL);
WLAN_STATUS_UNSPECIFIED_FAILURE,
GFP_KERNEL);
}
if (cfg->reg_rx_hndlr) {
ret = mt7697_wr_unreg_rx_hndlr_req(cfg);
if (ret < 0) {
dev_err(cfg->dev,
"%s(): mt7697_wr_unreg_rx_hndlr_req() failed(%d)\n",
__func__, ret);
goto out;
}
}
vif->scan_req = request;
ret = mt7697_send_scan_req(cfg, vif->fw_vif_idx, request);
ret = mt7697_wr_scan_req(cfg, vif->fw_vif_idx, request);
if (ret < 0) {
dev_err(cfg->dev, "%s: mt7697_send_scan_req() failed(%d)\n",
dev_err(cfg->dev, "%s(): mt7697_wr_scan_req() failed(%d)\n",
__func__, ret);
goto out;
}
......@@ -590,7 +609,8 @@ out:
return ret;
}
static int mt7697_cfg80211_connect(struct wiphy *wiphy, struct net_device *ndev,
static int mt7697_cfg80211_connect(struct wiphy *wiphy,
struct net_device *ndev,
struct cfg80211_connect_params *sme)
{
struct mt7697_cfg80211_info *cfg = mt7697_priv(ndev);
......@@ -598,24 +618,27 @@ static int mt7697_cfg80211_connect(struct wiphy *wiphy, struct net_device *ndev,
u32 interval;
int ret;
dev_dbg(cfg->dev, "%s: ssid(%u/'%s')\n",
dev_dbg(cfg->dev, "%s(): ssid(%u/'%s')\n",
__func__, sme->ssid_len, sme->ssid);
if (test_bit(CONNECTED, &vif->flags)) {
dev_dbg(cfg->dev, "%s: already connected\n", __func__);
dev_dbg(cfg->dev, "%s(): already connected\n", __func__);
goto cleanup;
}
vif->sme_state = SME_CONNECTING;
if (down_interruptible(&cfg->sem)) {
dev_err(cfg->dev, "%s: busy, couldn't get access\n", __func__);
dev_err(cfg->dev, "%s(): busy, couldn't get access\n",
__func__);
ret = -ERESTARTSYS;
goto cleanup;
}
if (test_bit(DESTROY_IN_PROGRESS, &cfg->flag)) {
dev_err(cfg->dev, "%s: busy, destroy in progress\n", __func__);
dev_err(cfg->dev, "%s(): busy, destroy in progress\n",
__func__);
ret = -EBUSY;
goto cleanup;
}
......@@ -632,7 +655,7 @@ static int mt7697_cfg80211_connect(struct wiphy *wiphy, struct net_device *ndev,
ret = mt7697_set_assoc_req_ies(vif, sme->ie, sme->ie_len);
if (ret < 0) {
dev_err(cfg->dev,
"%s: mt7697_set_assoc_req_ies() failed(%d)\n",
"%s(): mt7697_set_assoc_req_ies() failed(%d)\n",
__func__, ret);
goto cleanup;
}
......@@ -646,26 +669,26 @@ static int mt7697_cfg80211_connect(struct wiphy *wiphy, struct net_device *ndev,
if (sme->channel) {
vif->ch_hint = sme->channel->center_freq;
dev_dbg(cfg->dev, "%s: ch_hint(%u)\n", __func__, vif->ch_hint);
dev_dbg(cfg->dev, "%s(): ch_hint(%u)\n", __func__, vif->ch_hint);
}
else
vif->ch_hint = 0;
ret = mt7697_set_wpa_version(vif, sme->crypto.wpa_versions);
if (ret < 0) {
dev_err(cfg->dev, "%s: mt7697_set_wpa_version() failed(%d)\n",
dev_err(cfg->dev, "%s(): mt7697_set_wpa_version() failed(%d)\n",
__func__, ret);
goto cleanup;
}
ret = mt7697_set_auth_type(vif, sme->auth_type);
if (ret < 0) {
dev_err(cfg->dev, "%s: mt7697_set_auth_type() failed(%d)\n",
dev_err(cfg->dev, "%s(): mt7697_set_auth_type() failed(%d)\n",
__func__, ret);
goto cleanup;
}
dev_dbg(cfg->dev, "%s: WEP key len/idx(%u/%u)\n",
dev_dbg(cfg->dev, "%s(): WEP key len/idx(%u/%u)\n",
__func__, sme->key_len, sme->key_idx);
print_hex_dump(KERN_DEBUG, DRVNAME" key ",
......@@ -685,7 +708,7 @@ static int mt7697_cfg80211_connect(struct wiphy *wiphy, struct net_device *ndev,
ret = mt7697_set_cipher(vif, sme->crypto.cipher_group, false);
if (ret < 0) {
dev_err(cfg->dev, "%s: mt7697_set_cipher() failed(%d)\n",
dev_err(cfg->dev, "%s(): mt7697_set_cipher() failed(%d)\n",
__func__, ret);
goto cleanup;
}
......@@ -693,18 +716,18 @@ static int mt7697_cfg80211_connect(struct wiphy *wiphy, struct net_device *ndev,
if (sme->crypto.n_akm_suites) {
ret = mt7697_set_key_mgmt(vif, sme->crypto.akm_suites[0]);
if (ret < 0) {
dev_err(cfg->dev, "%s: mt7697_set_key_mgmt() failed(%d)\n",
dev_err(cfg->dev, "%s(): mt7697_set_key_mgmt() failed(%d)\n",
__func__, ret);
goto cleanup;
}
}
if (cfg->hw_wireless_mode != cfg->wireless_mode) {
ret = mt7697_send_set_wireless_mode_req(cfg, MT7697_PORT_STA,
ret = mt7697_wr_set_wireless_mode_req(cfg, MT7697_PORT_STA,
MT7697_WIFI_PHY_11ABGN_MIXED);
if (ret < 0) {
dev_err(cfg->dev,
"%s: mt7697_send_set_wireless_mode_req() failed(%d)\n",
"%s(): mt7697_wr_set_wireless_mode_req() failed(%d)\n",
__func__, ret);
goto cleanup;
}
......@@ -712,11 +735,11 @@ static int mt7697_cfg80211_connect(struct wiphy *wiphy, struct net_device *ndev,
cfg->hw_wireless_mode = cfg->wireless_mode;
}
ret = mt7697_send_set_security_mode_req(cfg, MT7697_PORT_STA,
ret = mt7697_wr_set_security_mode_req(cfg, MT7697_PORT_STA,
vif->auth_mode, vif->prwise_crypto);
if (ret < 0) {
dev_err(cfg->dev,
"%s: mt7697_send_set_security_mode_req() failed(%d)\n",
"%s(): mt7697_wr_set_security_mode_req() failed(%d)\n",
__func__, ret);
goto cleanup;
}
......@@ -727,7 +750,7 @@ static int mt7697_cfg80211_connect(struct wiphy *wiphy, struct net_device *ndev,
struct mt7697_key *key = NULL;
if (sme->key_idx > MT7697_MAX_KEY_INDEX) {
dev_err(cfg->dev, "%s: key index(%d) out of bounds\n",
dev_err(cfg->dev, "%s(): key index(%d) out of bounds\n",
__func__, sme->key_idx);
ret = -ENOENT;
goto cleanup;
......@@ -748,7 +771,7 @@ static int mt7697_cfg80211_connect(struct wiphy *wiphy, struct net_device *ndev,
NO_SYNC_WMIFLAG);*/
}
dev_dbg(cfg->dev, "%s: connect auth mode(%d) auto connect(%d) "
dev_dbg(cfg->dev, "%s(): connect auth mode(%d) auto connect(%d) "
"PW crypto/len(%d/%d) GRP crypto/len(%d/%d) "
"channel hint(%u)\n",
__func__,
......@@ -759,21 +782,21 @@ static int mt7697_cfg80211_connect(struct wiphy *wiphy, struct net_device *ndev,
if (cfg->wifi_config.opmode == MT7697_WIFI_MODE_AP_ONLY) {
interval = max_t(u8, vif->listen_intvl_t,
MT7697_MAX_WOW_LISTEN_INTL);
ret = mt7697_send_set_listen_interval_req(cfg, interval);
ret = mt7697_wr_set_listen_interval_req(cfg, interval);
if (ret < 0) {
dev_err(cfg->dev,
"%s: mt7697_send_set_listen_interval_req() failed(%d)\n",
"%s(): mt7697_wr_set_listen_interval_req() failed(%d)\n",
__func__, ret);
goto cleanup;
}
}
ret = mt7697_send_connect_req(cfg, MT7697_PORT_STA, vif->fw_vif_idx,
ret = mt7697_wr_connect_req(cfg, MT7697_PORT_STA, vif->fw_vif_idx,
vif->req_bssid, vif->ssid, vif->ssid_len, vif->ch_hint);
if (ret < 0) {
memset(vif->ssid, 0, sizeof(vif->ssid));
vif->ssid_len = 0;
dev_err(cfg->dev,"%s: mt7697_send_connect_req() failed(%d)\n",
dev_err(cfg->dev,"%s(): mt7697_wr_connect_req() failed(%d)\n",
__func__, ret);
goto cleanup;
}
......@@ -785,14 +808,14 @@ static int mt7697_cfg80211_connect(struct wiphy *wiphy, struct net_device *ndev,
/* configure default value if not specified */
sme->bg_scan_period = MT7697_DEFAULT_BG_SCAN_PERIOD;
}
/*
if ((!(cfg->connect_ctrl_flags & MT7697_CONNECT_DO_WPA_OFFLOAD)) &&
((vif->auth_mode == MT7697_WIFI_AUTH_MODE_WPA_PSK) ||
(vif->auth_mode == MT7697_WIFI_AUTH_MODE_WPA2_PSK))) {
mod_timer(&vif->disconnect_timer,
jiffies + msecs_to_jiffies(MT7697_DISCON_TIMER_INTVAL_MSEC));
}
*/
cfg->connect_ctrl_flags &= ~MT7697_CONNECT_DO_WPA_OFFLOAD;
set_bit(CONNECT_PEND, &vif->flags);
......@@ -808,16 +831,16 @@ static int mt7697_cfg80211_disconnect(struct wiphy *wiphy,
struct mt7697_vif *vif = netdev_priv(ndev);
int ret;
dev_dbg(cfg->dev, "%s: DISCONNECT\n", __func__);
dev_dbg(cfg->dev, "%s(): DISCONNECT\n", __func__);
if (down_interruptible(&cfg->sem)) {
dev_err(cfg->dev, "%s: down_interruptible() failed\n", __func__);
dev_err(cfg->dev, "%s(): down_interruptible() failed\n", __func__);
ret = -ERESTARTSYS;
goto cleanup;
}
if (test_bit(DESTROY_IN_PROGRESS, &cfg->flag)) {
dev_err(cfg->dev, "%s: busy, destroy in progress\n", __func__);
dev_err(cfg->dev, "%s(): busy, destroy in progress\n", __func__);
ret = -EBUSY;
goto cleanup;
}
......@@ -827,15 +850,13 @@ static int mt7697_cfg80211_disconnect(struct wiphy *wiphy,
ret = mt7697_disconnect(vif);
if (ret < 0) {
dev_err(cfg->dev,
"%s: mt7697_disconnect() failed(%d)\n", __func__, ret);
"%s(): mt7697_disconnect() failed(%d)\n", __func__, ret);
goto cleanup;
}
memset(vif->ssid, 0, sizeof(vif->ssid));
vif->ssid_len = 0;
vif->sme_state = SME_DISCONNECTED;
cleanup:
up(&cfg->sem);
return ret;
......@@ -848,7 +869,7 @@ static int mt7697_cfg80211_add_key(struct wiphy *wiphy,
struct key_params *params)
{
struct mt7697_cfg80211_info *cfg = mt7697_priv(ndev);
dev_dbg(cfg->dev, "%s: ADD KEY\n", __func__);
dev_dbg(cfg->dev, "%s(): ADD KEY\n", __func__);
return 0;
}
......@@ -860,16 +881,17 @@ static int mt7697_cfg80211_get_key(struct wiphy *wiphy,
struct key_params *))
{
struct mt7697_cfg80211_info *cfg = mt7697_priv(ndev);
dev_dbg(cfg->dev, "%s: GET KEY\n", __func__);
dev_dbg(cfg->dev, "%s(): GET KEY\n", __func__);
return 0;
}
static int mt7697_cfg80211_del_key(struct wiphy *wiphy, struct net_device *ndev,
static int mt7697_cfg80211_del_key(struct wiphy *wiphy,
struct net_device *ndev,
u8 key_index, bool pairwise,
const u8 *mac_addr)
{
struct mt7697_vif *vif = netdev_priv(ndev);
dev_dbg(vif->cfg->dev, "%s: DEL KEY\n", __func__);
dev_dbg(vif->cfg->dev, "%s(): DEL KEY\n", __func__);
return 0;
}
......@@ -879,7 +901,7 @@ static int mt7697_cfg80211_set_default_key(struct wiphy *wiphy,
bool multicast)
{
struct mt7697_cfg80211_info *cfg = mt7697_priv(ndev);
dev_dbg(cfg->dev, "%s: SET DEFAULT KEY\n", __func__);
dev_dbg(cfg->dev, "%s(): SET DEFAULT KEY\n", __func__);
return 0;
}
......@@ -891,7 +913,8 @@ static int mt7697_cfg80211_join_ibss(struct wiphy *wiphy,
struct mt7697_vif *vif = netdev_priv(ndev);
int ret = 0;
dev_dbg(cfg->dev, "%s: JOIN IBSS('%s')\n", __func__, ibss_param->ssid);
dev_dbg(cfg->dev, "%s(): JOIN IBSS('%s')\n",
__func__, ibss_param->ssid);
vif->ssid_len = ibss_param->ssid_len;
memcpy(vif->ssid, ibss_param->ssid, vif->ssid_len);
......@@ -906,7 +929,7 @@ static int mt7697_cfg80211_leave_ibss(struct wiphy *wiphy,
struct mt7697_vif *vif = netdev_priv(ndev);
int ret = 0;
dev_dbg(cfg->dev, "%s: LEAVE IBSS\n", __func__);
dev_dbg(cfg->dev, "%s(): LEAVE IBSS\n", __func__);
mt7697_disconnect(vif);
memset(vif->ssid, 0, sizeof(vif->ssid));
......@@ -922,7 +945,7 @@ static int mt7697_cfg80211_set_pmksa(struct wiphy *wiphy,
struct mt7697_cfg80211_info *cfg = mt7697_priv(ndev);
int ret;
dev_dbg(cfg->dev, "%s: SET PMKSA\n", __func__);
dev_dbg(cfg->dev, "%s(): SET PMKSA\n", __func__);
if (pmksa->bssid) {
print_hex_dump(KERN_DEBUG, DRVNAME" BSSID ",
......@@ -930,18 +953,18 @@ static int mt7697_cfg80211_set_pmksa(struct wiphy *wiphy,
}
if (pmksa->pmkid == NULL) {
dev_err(cfg->dev, "%s: NULL PSK\n", __func__);
dev_err(cfg->dev, "%s(): NULL PSK\n", __func__);
ret = -EINVAL;
goto cleanup;
}
dev_dbg(cfg->dev, "%s: PSK('%s')\n", __func__, pmksa->pmkid);
dev_dbg(cfg->dev, "%s(): PSK('%s')\n", __func__, pmksa->pmkid);
if (memcmp(pmksa->pmkid, cfg->psk, WLAN_MAX_KEY_LEN)) {
ret = mt7697_send_set_psk_req(cfg, MT7697_PORT_STA, pmksa->pmkid);
ret = mt7697_wr_set_psk_req(cfg, MT7697_PORT_STA, pmksa->pmkid);
if (ret) {
dev_err(cfg->dev,
"%s: mt7697_send_set_psk_req() failed(%d)\n",
"%s(): mt7697_wr_set_psk_req() failed(%d)\n",
__func__, ret);
goto cleanup;
}
......@@ -961,16 +984,16 @@ static int mt7697_cfg80211_del_pmksa(struct wiphy *wiphy,
struct mt7697_cfg80211_info *cfg = mt7697_priv(ndev);
int ret;
dev_dbg(cfg->dev, "%s: DEL PMKSA\n", __func__);
dev_dbg(cfg->dev, "%s(): DEL PMKSA\n", __func__);
print_hex_dump(KERN_DEBUG, DRVNAME" BSSID ",
DUMP_PREFIX_OFFSET, 16, 1, pmksa->bssid, ETH_ALEN, 0);
if (memcmp(psk, cfg->psk, WLAN_MAX_KEY_LEN)) {
ret = mt7697_send_set_psk_req(cfg, MT7697_PORT_STA, psk);
ret = mt7697_wr_set_psk_req(cfg, MT7697_PORT_STA, psk);
if (ret) {
dev_err(cfg->dev,
"%s: mt7697_send_set_psk_req() failed(%d)\n",
"%s(): mt7697_wr_set_psk_req() failed(%d)\n",
__func__, ret);
goto cleanup;
}
......@@ -990,13 +1013,13 @@ static int mt7697_cfg80211_flush_pmksa(struct wiphy *wiphy,
struct mt7697_vif *vif = netdev_priv(ndev);
int ret = 0;
dev_dbg(cfg->dev, "%s: FLUSH PMKSA\n", __func__);
dev_dbg(cfg->dev, "%s(): FLUSH PMKSA\n", __func__);
if (test_bit(CONNECTED, &vif->flags)) {
ret = mt7697_send_set_psk_req(cfg, MT7697_PORT_STA, psk);
ret = mt7697_wr_set_psk_req(cfg, MT7697_PORT_STA, psk);
if (ret) {
dev_err(cfg->dev,
"%s: mt7697_send_set_psk_req() failed(%d)\n",
"%s(): mt7697_wr_set_psk_req() failed(%d)\n",
__func__, ret);
goto cleanup;
}
......@@ -1013,7 +1036,7 @@ static int mt7697_cfg80211_del_station(struct wiphy *wiphy,
u8 *mac)
{
struct mt7697_cfg80211_info *cfg = mt7697_priv(ndev);
dev_dbg(cfg->dev, "%s: DEL STATION\n", __func__);
dev_dbg(cfg->dev, "%s(): DEL STATION\n", __func__);
return 0;
}
......@@ -1026,14 +1049,14 @@ static int mt7697_cfg80211_change_station(struct wiphy *wiphy,
struct mt7697_vif *vif = netdev_priv(ndev);
int err = 0;
dev_dbg(cfg->dev, "%s: CHANGE STATION flags(0x%08x)\n",
dev_dbg(cfg->dev, "%s(): CHANGE STATION flags(0x%08x)\n",
__func__, params->sta_flags_set);
print_hex_dump(KERN_DEBUG, DRVNAME" MAC ",
DUMP_PREFIX_OFFSET, 16, 1, mac, ETH_ALEN, 0);
if ((vif->wdev.iftype != NL80211_IFTYPE_STATION)) {
dev_err(cfg->dev, "%s: iftype(%u) not supported\n",
dev_err(cfg->dev, "%s(): iftype(%u) not supported\n",
__func__, vif->wdev.iftype);
err = -EOPNOTSUPP;
goto cleanup;
......@@ -1043,12 +1066,12 @@ static int mt7697_cfg80211_change_station(struct wiphy *wiphy,
CFG80211_STA_AP_MLME_CLIENT);
if (err) {
dev_err(cfg->dev,
"%s: cfg80211_check_station_change() failed(%d)\n",
"%s(): cfg80211_check_station_change() failed(%d)\n",
__func__, err);
goto cleanup;
}
dev_dbg(cfg->dev, "%s: set mlme('%s')\n",
dev_dbg(cfg->dev, "%s(): set mlme('%s')\n",
__func__,
params->sta_flags_set & BIT(NL80211_STA_FLAG_AUTHORIZED) ?
"AUTHORIZED":"UNAUTHORIZE");
......@@ -1073,7 +1096,7 @@ static int mt7697_cfg80211_remain_on_channel(struct wiphy *wiphy,
u64 *cookie)
{
struct mt7697_cfg80211_info *cfg = wiphy_to_cfg(wiphy);
dev_dbg(cfg->dev, "%s: REMAIN ON CH\n", __func__);
dev_dbg(cfg->dev, "%s(): REMAIN ON CH\n", __func__);
return 0;
}
......@@ -1082,7 +1105,7 @@ static int mt7697_cfg80211_cancel_remain_on_channel(struct wiphy *wiphy,
u64 cookie)
{
struct mt7697_cfg80211_info *cfg = wiphy_to_cfg(wiphy);
dev_dbg(cfg->dev, "%s: CANCEL REMAIN ON CH\n", __func__);
dev_dbg(cfg->dev, "%s(): CANCEL REMAIN ON CH\n", __func__);
return 0;
}
......@@ -1092,7 +1115,7 @@ static int mt7697_cfg80211_mgmt_tx(struct wiphy *wiphy,
u64 *cookie)
{
struct mt7697_cfg80211_info *cfg = wiphy_to_cfg(wiphy);
dev_dbg(cfg->dev, "%s: MGMT TX len(%u)\n", __func__, params->len);
dev_dbg(cfg->dev, "%s(): MGMT TX len(%u)\n", __func__, params->len);
print_hex_dump(KERN_DEBUG, DRVNAME" MGMT Tx ", DUMP_PREFIX_OFFSET,
16, 1, params->buf, params->len, 0);
......@@ -1106,7 +1129,7 @@ static void mt7697_cfg80211_mgmt_frame_register(struct wiphy *wiphy,
{
struct mt7697_vif *vif = mt7697_vif_from_wdev(wdev);
struct mt7697_cfg80211_info *cfg = wiphy_to_cfg(wiphy);
dev_dbg(cfg->dev, "%s: MGMT FRAME REG type(0x%04x) reg(%u)\n",
dev_dbg(cfg->dev, "%s(): MGMT FRAME REG type(0x%04x) reg(%u)\n",
__func__, frame_type, reg);
if (frame_type == IEEE80211_STYPE_PROBE_REQ) {
......@@ -1224,11 +1247,14 @@ static void mt7697_cfg80211_disconnect_work(struct work_struct *work)
ret = mt7697_disconnect(vif);
if (ret < 0) {
dev_err(cfg->dev, "%s: mt7697_disconnect() failed(%d)\n",
dev_err(cfg->dev, "%s(): mt7697_disconnect() failed(%d)\n",
__func__, ret);
goto cleanup;
}
memset(vif->ssid, 0, sizeof(vif->ssid));
vif->ssid_len = 0;
cleanup:
return;
}
......@@ -1239,7 +1265,7 @@ struct mt7697_vif* mt7697_get_vif_by_idx(struct mt7697_cfg80211_info *cfg,
struct mt7697_vif *vif, *found = NULL;
if (WARN_ON(if_idx > (cfg->vif_max - 1))) {
dev_err(cfg->dev, "%s: invalid if idx(%u > %u)\n",
dev_err(cfg->dev, "%s(): invalid if idx(%u > %u)\n",
__func__, if_idx, cfg->vif_max - 1);
return NULL;
}
......@@ -1263,12 +1289,12 @@ struct wireless_dev *mt7697_interface_add(
struct net_device *ndev;
struct mt7697_vif *vif;
dev_err(cfg->dev, "%s: add interface('%s') type(%u)\n",
dev_err(cfg->dev, "%s(): add interface('%s') type(%u)\n",
__func__, name, type);
ndev = alloc_netdev(sizeof(struct mt7697_vif), name, ether_setup);
if (!ndev) {
dev_err(cfg->dev, "%s: alloc_netdev() failed\n", __func__);
dev_err(cfg->dev, "%s(): alloc_netdev() failed\n", __func__);
return NULL;
}
......@@ -1289,13 +1315,13 @@ struct wireless_dev *mt7697_interface_add(
mt7697_init_netdev(ndev);
if (mt7697_cfg80211_vif_init(vif)) {
dev_err(cfg->dev, "%s: mt7697_cfg80211_vif_init() failed\n",
dev_err(cfg->dev, "%s(): mt7697_cfg80211_vif_init() failed\n",
__func__);
goto err;
}
if (register_netdevice(ndev)) {
dev_err(cfg->dev, "%s: register_netdevice() failed\n",
dev_err(cfg->dev, "%s(): register_netdevice() failed\n",
__func__);
goto err;
}
......@@ -1332,14 +1358,14 @@ int mt7697_cfg80211_connect_event(struct mt7697_vif *vif, const u8* bssid,
(channel <= MT7697_CH_MAX_5G_CHANNEL))
band = wiphy->bands[IEEE80211_BAND_5GHZ];
else {
dev_err(cfg->dev, "%s: invalid channel(%u)\n",
dev_err(cfg->dev, "%s(): invalid channel(%u)\n",
__func__, channel);
ret = -EINVAL;
goto cleanup;
}
if (!band) {
dev_err(cfg->dev, "%s: channel(%u) NULL band\n",
dev_err(cfg->dev, "%s(): channel(%u) NULL band\n",
__func__, channel);
ret = -EINVAL;
goto cleanup;
......@@ -1348,7 +1374,7 @@ int mt7697_cfg80211_connect_event(struct mt7697_vif *vif, const u8* bssid,
freq = ieee80211_channel_to_frequency(channel, band->band);
if (!freq) {
dev_err(cfg->dev,
"%s: ieee80211_channel_to_frequency() failed\n",
"%s(): ieee80211_channel_to_frequency() failed\n",
__func__);
ret = -EINVAL;
goto cleanup;
......@@ -1356,17 +1382,19 @@ int mt7697_cfg80211_connect_event(struct mt7697_vif *vif, const u8* bssid,
bss = mt7697_add_bss_if_needed(vif, bssid, freq);
if (!bss) {
dev_err(cfg->dev, "%s: mt7697_add_bss_if_needed() failed\n",
dev_err(cfg->dev, "%s(): mt7697_add_bss_if_needed() failed\n",
__func__);
ret = -EINVAL;
goto cleanup;
}
WARN_ON(!vif->ndev);
dev_dbg(cfg->dev, "%s: vif sme_state(%u)\n", __func__, vif->sme_state);
dev_dbg(cfg->dev, "%s(): vif sme_state(%u)\n",
__func__, vif->sme_state);
if ((vif->sme_state == SME_CONNECTING) ||
(vif->sme_state == SME_DISCONNECTED)) {
vif->sme_state = SME_CONNECTED;
memcpy(vif->bssid, bssid, ETH_ALEN);
cfg80211_connect_result(vif->ndev, bssid,
NULL, 0,
NULL, 0,
......@@ -1382,7 +1410,7 @@ int mt7697_cfg80211_connect_event(struct mt7697_vif *vif, const u8* bssid,
set_bit(CONNECTED, &vif->flags);
clear_bit(CONNECT_PEND, &vif->flags);
dev_dbg(cfg->dev, "%s: vif flags(0x%08lx)\n", __func__, vif->flags);
dev_dbg(cfg->dev, "%s(): vif flags(0x%08lx)\n", __func__, vif->flags);
netif_wake_queue(vif->ndev);
netif_carrier_on(vif->ndev);
......@@ -1412,6 +1440,7 @@ int mt7697_cfg80211_init(struct mt7697_cfg80211_info *cfg)
bool band_2gig = false, band_5gig = false, ht = false;
s32 err = 0;
dev_dbg(cfg->dev, "%s(): init mt7697 cfg80211\n", __func__);
cfg->tx_req.cmd.grp = MT7697_CMD_GRP_80211;
cfg->tx_req.cmd.type = MT7697_CMD_TX_RAW;
......@@ -1453,7 +1482,8 @@ int mt7697_cfg80211_init(struct mt7697_cfg80211_info *cfg)
band_5gig = true;
break;
default:
dev_err(cfg->dev, "%s: invalid phy capability!\n", __func__);
dev_err(cfg->dev, "%s(): invalid phy capability(%d)\n",
__func__, cfg->wireless_mode);
err = -EINVAL;
goto cleanup;
}
......@@ -1495,12 +1525,13 @@ int mt7697_cfg80211_init(struct mt7697_cfg80211_info *cfg)
err = wiphy_register(wiphy);
if (err < 0) {
dev_err(cfg->dev, "%s: wiphy_register() failed(%d)\n",
dev_err(cfg->dev, "%s(): wiphy_register() failed(%d)\n",
__func__, err);
goto cleanup;
}
cfg->wiphy_registered = true;
dev_dbg(cfg->dev, "%s(): wiphy registered\n", __func__);
cleanup:
return err;
......
/*
* Copyright (c) 2017 Sierra Wireless Corporation
*
* 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.
*/
#ifndef _MT7697_COMMON_H_
#define _MT7697_COMMON_H_
struct mt7697_llc_snap_hdr {
u8 dsap;
u8 ssap;
u8 cntl;
u8 org_code[3];
__be16 eth_type;
} __packed;
#endif
......@@ -100,10 +100,8 @@ struct mt7697_cfg80211_info {
struct work_struct tx_work;
struct mt7697_tx_raw_packet tx_req;
u8 rx_data[MT7697_LEN32_ALIGNED(IEEE80211_MAX_FRAME_LEN)];
u8 probe_data[MT7697_LEN32_ALIGNED(IEEE80211_MAX_DATA_LEN)];
struct mt7697_rsp_hdr rsp;
u8 rx_data[LEN32_ALIGNED(IEEE80211_MAX_FRAME_LEN)];
u8 probe_data[LEN32_ALIGNED(IEEE80211_MAX_DATA_LEN)];
enum mt7697_radio_state radio_state;
enum mt7697_wifi_phy_mode_t wireless_mode;
......@@ -113,6 +111,7 @@ struct mt7697_cfg80211_info {
int listen_interval;
enum mt7697_wifi_rx_filter_t rx_filter;
u8 smart_conn_filter;
u8 reg_rx_hndlr;
u8 psk[MT7697_PASSPHRASE_LEN];
struct list_head vif_list;
......@@ -171,6 +170,8 @@ struct mt7697_vif {
enum mt7697_sme_state sme_state;
int reconnect_flag;
u8 listen_intvl_t;
struct net_device_stats net_stats;
};
static inline struct wiphy *cfg_to_wiphy(struct mt7697_cfg80211_info *cfg)
......@@ -200,7 +201,8 @@ struct wireless_dev *mt7697_interface_add(struct mt7697_cfg80211_info*,
const char*, enum nl80211_iftype, u8 fw_vif_idx);
void mt7697_tx_work(struct work_struct *);
int mt7697_data_tx(struct sk_buff*, struct net_device*);
int mt7697_rx_data(struct mt7697_cfg80211_info*, u32);
int mt7697_rx_data(struct mt7697_cfg80211_info*, u32, u32);
int mt7697_proc_80211cmd(const struct mt7697q_rsp_hdr*, void*);
void mt7697_disconnect_timer_hndlr(unsigned long);
int mt7697_disconnect(struct mt7697_vif*);
......
......@@ -19,6 +19,7 @@
#include <linux/platform_device.h>
#include <net/cfg80211.h>
#include "queue_i.h"
#include "common.h"
#include "core.h"
#include "cfg80211.h"
......@@ -29,7 +30,7 @@ static int mt7697_open(struct net_device *ndev)
struct mt7697_cfg80211_info *cfg = mt7697_priv(ndev);
struct mt7697_vif *vif = netdev_priv(ndev);
dev_dbg(cfg->dev, "%s: open net device\n", __func__);
dev_dbg(cfg->dev, "%s(): open net device\n", __func__);
set_bit(WLAN_ENABLED, &vif->flags);
......@@ -47,7 +48,7 @@ static int mt7697_stop(struct net_device *ndev)
struct mt7697_cfg80211_info *cfg = mt7697_priv(ndev);
struct mt7697_vif *vif = netdev_priv(ndev);
dev_dbg(cfg->dev, "%s: stop net device\n", __func__);
dev_dbg(cfg->dev, "%s(): stop net device\n", __func__);
netif_stop_queue(ndev);
mt7697_cfg80211_stop(vif);
......@@ -56,11 +57,17 @@ static int mt7697_stop(struct net_device *ndev)
return 0;
}
static struct net_device_stats *mt7697_get_stats(struct net_device *dev)
{
struct mt7697_vif *vif = netdev_priv(dev);
return &vif->net_stats;
}
static int mt7697_set_features(struct net_device *ndev,
netdev_features_t features)
{
struct mt7697_cfg80211_info *cfg = mt7697_priv(ndev);
dev_dbg(cfg->dev, "%s: net device set features\n", __func__);
dev_dbg(cfg->dev, "%s(): net device set features\n", __func__);
return 0;
}
......@@ -71,7 +78,7 @@ static void mt7697_set_multicast_list(struct net_device *ndev)
bool mc_all_on = false;
int mc_count = netdev_mc_count(ndev);
dev_dbg(cfg->dev, "%s: net device set multicast\n", __func__);
dev_dbg(cfg->dev, "%s(): net device set multicast\n", __func__);
/* Enable multicast-all filter. */
mc_all_on = !!(ndev->flags & IFF_PROMISC) ||
......@@ -91,7 +98,7 @@ static void mt7697_set_multicast_list(struct net_device *ndev)
}
/* Enable/disable "multicast-all" filter*/
dev_dbg(cfg->dev, "%s: %s multicast-all filter\n",
dev_dbg(cfg->dev, "%s(): %s multicast-all filter\n",
__func__, mc_all_on ? "enable" : "disable");
}
......@@ -101,86 +108,76 @@ static void mt7697_init_hw_start(struct work_struct *work)
struct mt7697_cfg80211_info, init_work);
int err;
cfg->txq_hdl = cfg->hif_ops->init(MT7697_MAC80211_QUEUE_TX, cfg, NULL);
if (!cfg->txq_hdl) {
dev_err(cfg->dev, "%s: queue(%u) init() failed()\n",
__func__, MT7697_MAC80211_QUEUE_TX);
goto failed;
}
cfg->rxq_hdl = cfg->hif_ops->init(MT7697_MAC80211_QUEUE_RX, cfg,
mt7697_proc_data);
if (!cfg->rxq_hdl) {
dev_err(cfg->dev, "%s: queue(%u) init() failed()\n",
__func__, MT7697_MAC80211_QUEUE_RX);
goto failed;
}
err = mt7697_send_init(cfg);
dev_dbg(cfg->dev, "%s(): init mt7697 queue(%u/%u)\n",
__func__, MT7697_MAC80211_QUEUE_TX, MT7697_MAC80211_QUEUE_RX);
err = cfg->hif_ops->init(MT7697_MAC80211_QUEUE_TX,
MT7697_MAC80211_QUEUE_RX, cfg, mt7697_proc_80211cmd,
&cfg->txq_hdl, &cfg->rxq_hdl);
if (err < 0) {
dev_err(cfg->dev, "%s: mt7697_send_init() failed(%d)\n",
__func__, err);
dev_err(cfg->dev, "%s(): queue(%u) init() failed(%d)\n",
__func__, MT7697_MAC80211_QUEUE_TX, err);
goto failed;
}
err = mt7697_send_cfg_req(cfg);
err = mt7697_wr_cfg_req(cfg);
if (err < 0) {
dev_err(cfg->dev, "%s: mt7697_send_cfg_req() failed(%d)\n",
dev_err(cfg->dev, "%s(): mt7697_wr_cfg_req() failed(%d)\n",
__func__, err);
goto failed;
}
err = mt7697_send_get_wireless_mode_req(cfg, MT7697_PORT_STA);
err = mt7697_wr_get_wireless_mode_req(cfg, MT7697_PORT_STA);
if (err < 0) {
dev_err(cfg->dev,
"%s: mt7697_send_get_wireless_mode_req() failed(%d)\n",
"%s(): mt7697_wr_get_wireless_mode_req() failed(%d)\n",
__func__, err);
goto failed;
}
err = mt7697_send_get_rx_filter_req(cfg);
err = mt7697_wr_get_rx_filter_req(cfg);
if (err < 0) {
dev_err(cfg->dev,
"%s: mt7697_send_get_rx_filter_req() failed(%d)\n",
"%s(): mt7697_wr_get_rx_filter_req() failed(%d)\n",
__func__, err);
goto failed;
}
err = mt7697_send_get_smart_conn_filter_req(cfg);
err = mt7697_wr_get_smart_conn_filter_req(cfg);
if (err < 0) {
dev_err(cfg->dev,
"%s: mt7697_send_get_smart_conn_filter_req() failed(%d)\n",
"%s(): mt7697_wr_get_smart_conn_filter_req() failed(%d)\n",
__func__, err);
goto failed;
}
err = mt7697_send_get_listen_interval_req(cfg);
err = mt7697_wr_get_listen_interval_req(cfg);
if (err < 0) {
dev_err(cfg->dev,
"%s: mt7697_send_get_listen_interval_req() failed(%d)\n",
"%s(): mt7697_wr_get_listen_interval_req() failed(%d)\n",
__func__, err);
goto failed;
}
err = mt7697_send_get_radio_state_req(cfg);
err = mt7697_wr_get_radio_state_req(cfg);
if (err < 0) {
dev_err(cfg->dev,
"%s: mt7697_send_get_radio_state_req() failed(%d)\n",
"%s(): mt7697_wr_get_radio_state_req() failed(%d)\n",
__func__, err);
goto failed;
}
err = mt7697_send_get_psk_req(cfg, MT7697_PORT_STA);
err = mt7697_wr_get_psk_req(cfg, MT7697_PORT_STA);
if (err < 0) {
dev_err(cfg->dev, "%s: mt7697_send_get_psk_req() failed(%d)\n",
dev_err(cfg->dev,
"%s(): mt7697_wr_get_psk_req() failed(%d)\n",
__func__, err);
goto failed;
}
err = mt7697_send_mac_addr_req(cfg, MT7697_PORT_STA);
err = mt7697_wr_mac_addr_req(cfg, MT7697_PORT_STA);
if (err < 0) {
dev_err(cfg->dev,
"%s: mt7697_send_mac_addr_req() failed(%d)\n",
"%s(): mt7697_wr_mac_addr_req() failed(%d)\n",
__func__, err);
goto failed;
}
......@@ -193,6 +190,7 @@ static const struct net_device_ops mt7697_netdev_ops = {
.ndo_open = mt7697_open,
.ndo_stop = mt7697_stop,
.ndo_start_xmit = mt7697_data_tx,
.ndo_get_stats = mt7697_get_stats,
.ndo_set_features = mt7697_set_features,
.ndo_set_rx_mode = mt7697_set_multicast_list,
};
......@@ -202,19 +200,14 @@ void mt7697_init_netdev(struct net_device *dev)
dev->netdev_ops = &mt7697_netdev_ops;
dev->destructor = free_netdev;
dev->watchdog_timeo = MT7697_TX_TIMEOUT;
dev->needed_headroom = ETH_HLEN;
dev->hw_features |= NETIF_F_IP_CSUM | NETIF_F_RXCSUM;
dev->needed_headroom = sizeof(struct ieee80211_hdr) + sizeof(struct mt7697_llc_snap_hdr);
dev->hw_features |= NETIF_F_HW_CSUM | NETIF_F_RXCSUM;
}
static const struct mt7697q_if_ops if_ops = {
.init = mt7697q_init,
.read = mt7697q_read,
.write = mt7697q_write,
.pull_rd_ptr = mt7697q_pull_rd_ptr,
.pull_wr_ptr = mt7697q_pull_wr_ptr,
.capacity = mt7697q_get_capacity,
.num_rd = mt7697q_get_num_words,
.num_wr = mt7697q_get_free_words,
};
static void mt7697_cookie_init(struct mt7697_cfg80211_info *cfg)
......@@ -242,9 +235,11 @@ static int mt7697_probe(struct platform_device *pdev)
struct mt7697_cfg80211_info *cfg;
int err = 0;
dev_dbg(&pdev->dev, "%s(): probe\n", __func__);
cfg = mt7697_cfg80211_create();
if (!cfg) {
dev_err(&pdev->dev, "%s: mt7697_cfg80211_create() failed()\n",
dev_err(&pdev->dev,
"%s(): mt7697_cfg80211_create() failed()\n",
__func__);
err = -ENOMEM;
goto failed;
......@@ -263,7 +258,8 @@ static int mt7697_probe(struct platform_device *pdev)
err = mt7697_cfg80211_init(cfg);
if (err < 0) {
dev_err(&pdev->dev, "%s: mt7697_cfg80211_init() failed(%d)\n",
dev_err(&pdev->dev,
"%s(): mt7697_cfg80211_init() failed(%d)\n",
__func__, err);
goto failed;
}
......@@ -285,9 +281,9 @@ static int mt7697_remove(struct platform_device *pdev)
struct mt7697_cfg80211_info *cfg = platform_get_drvdata(pdev);
int ret;
ret = mt7697_send_reset(cfg);
ret = mt7697q_send_reset(cfg->txq_hdl, cfg->rxq_hdl);
if (ret < 0) {
dev_err(&pdev->dev, "%s: mt7697_send_reset() failed(%d)\n",
dev_err(&pdev->dev, "%s(): mt7697q_send_reset() failed(%d)\n",
__func__, ret);
goto failed;
}
......@@ -295,7 +291,7 @@ static int mt7697_remove(struct platform_device *pdev)
mt7697_cfg80211_cleanup(cfg);
mt7697_cfg80211_destroy(cfg);
mt7697_cookie_cleanup(cfg);
dev_dbg(&pdev->dev, "%s: removed.\n", __func__);
dev_dbg(&pdev->dev, "%s(): removed.\n", __func__);
platform_set_drvdata(pdev, NULL);
......@@ -318,18 +314,18 @@ static int __init mt7697_init(void)
{
int ret;
pr_info(DRVNAME" init\n");
pr_info(DRVNAME" initialize\n");
ret = platform_driver_register(&mt7697_platform_driver);
if (ret) {
pr_err(DRVNAME" %s: platform_driver_register() failed(%d)\n",
pr_err(DRVNAME" %s(): platform_driver_register() failed(%d)\n",
__func__, ret);
goto cleanup;
}
pdev = platform_device_alloc(DRVNAME, -1);
if (!pdev) {
pr_err(DRVNAME" %s: platform_device_alloc() failed(%d)\n",
__func__, ret);
pr_err(DRVNAME" %s(): platform_device_alloc() failed\n",
__func__);
platform_driver_unregister(&mt7697_platform_driver);
ret = -ENOMEM;
goto cleanup;
......@@ -337,7 +333,7 @@ static int __init mt7697_init(void)
ret = platform_device_add(pdev);
if (ret) {
pr_err(DRVNAME" %s: platform_device_add() failed(%d)\n",
pr_err(DRVNAME" %s(): platform_device_add() failed(%d)\n",
__func__, ret);
goto cleanup;
}
......@@ -371,13 +367,33 @@ int mt7697_disconnect(struct mt7697_vif *vif)
{
int ret = 0;
dev_dbg(vif->cfg->dev, "%s(): disconnect\n", __func__);
if (test_bit(CONNECTED, &vif->flags) ||
test_bit(CONNECT_PEND, &vif->flags)) {
ret = mt7697_send_disconnect_req(vif->cfg, vif->fw_vif_idx,
if (vif->cfg->reg_rx_hndlr) {
ret = mt7697_wr_set_op_mode_req(vif->cfg,
vif->cfg->wifi_config.opmode);
if (ret < 0) {
dev_err(vif->cfg->dev,
"%s(): mt7697_wr_set_op_mode_req() failed(%d)\n",
__func__, ret);
goto failed;
}
ret = mt7697_wr_unreg_rx_hndlr_req(vif->cfg);
if (ret < 0) {
dev_err(vif->cfg->dev,
"%s(): mt7697_wr_unreg_rx_hndlr_req() failed(%d)\n",
__func__, ret);
goto failed;
}
}
ret = mt7697_wr_disconnect_req(vif->cfg, vif->fw_vif_idx,
NULL);
if (ret < 0) {
dev_err(vif->cfg->dev,
"%s: mt7697_send_disconnect_req() failed(%d)\n",
"%s(): mt7697_wr_disconnect_req() failed(%d)\n",
__func__, ret);
goto failed;
}
......@@ -407,12 +423,14 @@ struct mt7697_cookie *mt7697_alloc_cookie(struct mt7697_cfg80211_info *cfg)
return cookie;
}
void mt7697_free_cookie(struct mt7697_cfg80211_info *cfg, struct mt7697_cookie *cookie)
void mt7697_free_cookie(struct mt7697_cfg80211_info *cfg,
struct mt7697_cookie *cookie)
{
/* Insert first */
if (!cfg || !cookie)
return;
cookie->skb = NULL;
cookie->arc_list_next = cfg->cookie_list;
cfg->cookie_list = cookie;
cfg->cookie_count++;
......
......@@ -13,7 +13,7 @@ mt_wifi_start() {
if [ $? -eq 1 ]; then
insmod /tmp/spi-cp2130.ko || exit 127
for f in `ls -d /sys/class/gpio/gpiochip*`; do echo $f `cat $f/label $f/base $f/ngpio` ; done
echo -n 0,2,6,0,0,1,2,0,0,0,0,mt7697 > /sys/devices/platform/msm_hsic_host/usb1/1-1/1-1.1/1-1.1:1.0/channel_config
echo -n 0,2,-1,0,0,1,0,0,0,0,0,mt7697 > /sys/devices/platform/msm_hsic_host/usb1/1-1/1-1.1/1-1.1:1.0/channel_config
fi
lsmod | grep cfg80211 >/dev/null
......
......@@ -15,37 +15,172 @@
*/
#include <linux/etherdevice.h>
#include "common.h"
#include "core.h"
static int mt7697_80211_to_ethernet(struct sk_buff *skb,
struct net_device *ndev)
{
struct mt7697_cfg80211_info *cfg = mt7697_priv(ndev);
struct mt7697_vif *vif = netdev_priv(ndev);
struct ieee80211_hdr *hdr = (struct ieee80211_hdr*) skb->data;
struct ethhdr *ehdr;
u8 *payload;
u16 hdrlen, ethertype;
__be16 len;
u8 dst[ETH_ALEN];
u8 src[ETH_ALEN] __aligned(2);
int ret = 0;
print_hex_dump(KERN_DEBUG, DRVNAME" --> Rx 802.11 Frame",
DUMP_PREFIX_OFFSET, 16, 1, skb->data, skb->len, 0);
if (unlikely(!ieee80211_is_data_present(hdr->frame_control))) {
dev_warn(cfg->dev, "%s(): no data present\n", __func__);
ret = -EINVAL;
goto cleanup;
}
hdrlen = ieee80211_hdrlen(hdr->frame_control);
/* convert IEEE 802.11 header + possible LLC headers into Ethernet
* header
* IEEE 802.11 address fields:
* ToDS FromDS Addr1 Addr2 Addr3 Addr4
* 0 0 DA SA BSSID n/a
* 0 1 DA BSSID SA n/a
* 1 0 BSSID SA DA n/a
* 1 1 RA TA DA SA
*/
memcpy(dst, ieee80211_get_DA(hdr), ETH_ALEN);
memcpy(src, ieee80211_get_SA(hdr), ETH_ALEN);
if (!pskb_may_pull(skb, hdrlen + 8)) {
dev_warn(cfg->dev, "%s(): pskb_may_pull() failed\n", __func__);
ret = -EINVAL;
goto cleanup;
}
payload = skb->data + hdrlen;
ethertype = (payload[6] << 8) | payload[7];
skb_pull(skb, hdrlen);
len = htons(skb->len);
ehdr = (struct ethhdr*)skb_push(skb, sizeof(struct ethhdr));
memcpy(ehdr->h_dest, dst, ETH_ALEN);
memcpy(ehdr->h_source, src, ETH_ALEN);
ehdr->h_proto = len;
print_hex_dump(KERN_DEBUG, DRVNAME" Rx 802.3 Frame ",
DUMP_PREFIX_OFFSET, 16, 1, skb->data, skb->len, 0);
if (!is_broadcast_ether_addr(ehdr->h_dest))
vif->net_stats.multicast++;
cleanup:
return ret;
}
static void mt7697_ethernet_to_80211(struct sk_buff *skb,
struct net_device *ndev)
{
struct ieee80211_hdr hdr;
struct mt7697_cfg80211_info *cfg = mt7697_priv(ndev);
struct mt7697_vif *vif = netdev_priv(ndev);
struct ethhdr *eth_hdr = (struct ethhdr*)skb->data;
struct mt7697_llc_snap_hdr *llc_hdr;
u8 *datap;
__be16 type = eth_hdr->h_proto;
__le16 fc;
u16 hdrlen;
dev_dbg(cfg->dev, "%s(): Tx 802.3 Frame len(%u)\n", __func__, skb->len);
print_hex_dump(KERN_DEBUG, DRVNAME" 802.3 Frame ", DUMP_PREFIX_OFFSET,
16, 1, skb->data, skb->len, 0);
fc = cpu_to_le16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_DATA);
// fc |= cpu_to_le16(IEEE80211_FCTL_FROMDS);
fc |= cpu_to_le16(IEEE80211_FCTL_TODS);
/* DA BSSID SA */
hdr.frame_control = fc;
hdr.duration_id = 0;
// memcpy(hdr.addr1, eth_hdr->h_dest, ETH_ALEN);
// memcpy(hdr.addr2, vif->bssid, ETH_ALEN);
// memcpy(hdr.addr3, eth_hdr->h_source, ETH_ALEN);
memcpy(hdr.addr1, vif->bssid, ETH_ALEN);
memcpy(hdr.addr2, eth_hdr->h_source, ETH_ALEN);
memcpy(hdr.addr3, eth_hdr->h_dest, ETH_ALEN);
hdr.seq_ctrl = 0;
hdrlen = sizeof(struct ieee80211_hdr_3addr);
datap = skb_push(skb, hdrlen + sizeof(struct mt7697_llc_snap_hdr) - sizeof(struct ethhdr));
memcpy(datap, &hdr, hdrlen);
llc_hdr = (struct mt7697_llc_snap_hdr*)(datap + hdrlen);
llc_hdr->dsap = 0xAA;
llc_hdr->ssap = 0xAA;
llc_hdr->cntl = 0x03;
llc_hdr->org_code[0] = 0x0;
llc_hdr->org_code[1] = 0x0;
llc_hdr->org_code[2] = 0x0;
llc_hdr->eth_type = type;
dev_dbg(cfg->dev, "%s(): Tx 802.11 Frame len(%u)\n",
__func__, skb->len);
print_hex_dump(KERN_DEBUG, DRVNAME" <-- Tx 802.11 Frame ", DUMP_PREFIX_OFFSET,
16, 1, skb->data, skb->len, 0);
}
int mt7697_data_tx(struct sk_buff *skb, struct net_device *ndev)
{
struct mt7697_cfg80211_info *cfg = mt7697_priv(ndev);
struct mt7697_vif *vif = netdev_priv(ndev);
struct mt7697_cookie *cookie;
int ret;
int ret = 0;
dev_dbg(cfg->dev, "%s: tx cookie cnt(%u) skb(0x%p), data(0x%p), len(%u)\n",
dev_dbg(cfg->dev,
"%s(): tx cookie cnt(%u) skb(0x%p), data(0x%p), len(%u)\n",
__func__, cfg->cookie_count, skb, skb->data, skb->len);
if (!test_bit(CONNECTED, &vif->flags)) {
dev_warn(cfg->dev, "%s: interface not associated\n", __func__);
dev_warn(cfg->dev, "%s(): interface not associated\n",
__func__);
ret = -EAGAIN;
goto fail_tx;
goto cleanup;
}
dev_dbg(cfg->dev, "%s(): headroom skb/needed(%u/%u)\n",
__func__, skb_headroom(skb), ndev->needed_headroom);
if (skb_headroom(skb) < ndev->needed_headroom) {
struct sk_buff *tmp_skb = skb;
skb = skb_realloc_headroom(skb, ndev->needed_headroom);
kfree_skb(tmp_skb);
if (skb == NULL) {
dev_dbg(cfg->dev, "%s(): tx dropped\n", __func__);
goto cleanup;
}
}
mt7697_ethernet_to_80211(skb, ndev);
cookie = mt7697_alloc_cookie(cfg);
if (cookie == NULL) {
ret = -ENOMEM;
goto fail_tx;
goto cleanup;
}
dev_dbg(cfg->dev, "%s: tx cookie/cnt(0x%p/%u)\n",
dev_dbg(cfg->dev, "%s(): tx cookie/cnt(0x%p/%u)\n",
__func__, cookie, cfg->cookie_count);
cookie->skb = skb;
schedule_work(&cfg->tx_work);
return 0;
fail_tx:
return NETDEV_TX_OK;
cleanup:
vif->net_stats.tx_dropped++;
vif->net_stats.tx_aborted_errors++;
dev_kfree_skb(skb);
return ret;
}
......@@ -54,76 +189,121 @@ void mt7697_tx_work(struct work_struct *work)
{
struct mt7697_cfg80211_info *cfg = container_of(work,
struct mt7697_cfg80211_info, tx_work);
struct mt7697_cookie *cookie = &cfg->cookie_mem[cfg->cookie_count];
struct sk_buff_head skb_queue;
struct ieee80211_hdr *hdr;
int ret;
dev_dbg(cfg->dev, "%s: tx work cookie/cnt(0x%p/%u)\n",
__func__, cookie, cfg->cookie_count);
skb_queue_head_init(&skb_queue);
dev_dbg(cfg->dev, "%s(): tx cookie cnt(%u)\n",
__func__, cfg->cookie_count);
while (cfg->cookie_count < MT7697_MAX_COOKIE_NUM) {
print_hex_dump(KERN_DEBUG, DRVNAME" <-- Tx ", DUMP_PREFIX_OFFSET,
16, 1, cookie->skb->data, cookie->skb->len, 0);
struct mt7697_vif *vif;
struct mt7697_cookie *cookie = &cfg->cookie_mem[cfg->cookie_count];
if (!cookie->skb)
break;
vif = netdev_priv(cookie->skb->dev);
WARN_ON(!vif);
ret = mt7697_send_tx_raw_packet(cfg, cookie->skb->data,
/* validate length for ether packet */
if (cookie->skb->len < sizeof(*hdr)) {
dev_err(cfg->dev, "%s(): invalid skb len(%u < %u)\n",
__func__, cookie->skb->len, sizeof(*hdr));
vif->net_stats.tx_errors++;
ret = -EINVAL;
goto cleanup;
}
ret = mt7697_wr_tx_raw_packet(cfg, cookie->skb->data,
cookie->skb->len);
if (ret < 0) {
dev_err(cfg->dev,
"%s: mt7697_send_tx_raw_packet() failed(%d)\n",
"%s(): mt7697_wr_tx_raw_packet() failed(%d)\n",
__func__, ret);
vif->net_stats.tx_errors++;
goto cleanup;
}
dev_kfree_skb(cookie->skb);
vif->net_stats.tx_packets++;
vif->net_stats.tx_bytes += cookie->skb->len;
__skb_queue_tail(&skb_queue, cookie->skb);
mt7697_free_cookie(cfg, cookie);
dev_dbg(cfg->dev, "%s: tx cookie cnt(%u)\n",
dev_dbg(cfg->dev, "%s(): tx cookie cnt(%u)\n",
__func__, cfg->cookie_count);
if (cfg->cookie_count < MT7697_MAX_COOKIE_NUM)
cookie = &cfg->cookie_mem[cfg->cookie_count];
}
__skb_queue_purge(&skb_queue);
cleanup:
return;
}
int mt7697_rx_data(struct mt7697_cfg80211_info *cfg, u32 if_idx)
int mt7697_rx_data(struct mt7697_cfg80211_info *cfg, u32 len, u32 if_idx)
{
struct mt7697_vif *vif;
struct sk_buff *skb;
struct sk_buff *skb = NULL;
struct ieee80211_hdr *hdr;
int ret = 0;
skb = alloc_skb(cfg->rsp.result, GFP_KERNEL);
if (!skb) {
dev_err(cfg->dev, "%s: alloc_skb() failed\n", __func__);
ret = -ENOMEM;
vif = mt7697_get_vif_by_idx(cfg, if_idx);
if (!vif) {
dev_err(cfg->dev, "%s(): mt7697_get_vif_by_idx(%u) failed\n",
__func__, if_idx);
ret = -EINVAL;
goto cleanup;
}
skb_put(skb, cfg->rsp.result);
memcpy(skb->data, cfg->rx_data, cfg->rsp.result);
dev_dbg(cfg->dev, "%s(): vif(%u)\n", __func__, vif->fw_vif_idx);
if (!(vif->ndev->flags & IFF_UP)) {
dev_warn(cfg->dev, "%s(): net device NOT up\n", __func__);
ret = -EINVAL;
goto cleanup;
}
vif = mt7697_get_vif_by_idx(cfg, if_idx);
if (!vif) {
dev_err(cfg->dev, "%s: mt7697_get_vif_by_idx(%u) failed\n",
__func__, if_idx);
if ((len < sizeof(*hdr)) || (len > IEEE80211_MAX_FRAME_LEN)) {
dev_warn(cfg->dev, "%s(): invalid Rx frame size(%u)\n",
__func__, len);
vif->net_stats.rx_length_errors++;
ret = -EINVAL;
goto cleanup;
}
dev_dbg(cfg->dev, "%s: vif(%u)\n", __func__, vif->fw_vif_idx);
skb = alloc_skb(len, GFP_KERNEL);
if (!skb) {
dev_err(cfg->dev, "%s(): alloc_skb() failed\n", __func__);
ret = -ENOMEM;
goto cleanup;
}
skb_put(skb, len);
memcpy(skb->data, cfg->rx_data, len);
skb->dev = vif->ndev;
if (!(skb->dev->flags & IFF_UP)) {
dev_warn(cfg->dev, "%s: net device NOT up\n", __func__);
ret = -EINVAL;
ret = mt7697_80211_to_ethernet(skb, vif->ndev);
if (ret < 0) {
dev_err(cfg->dev,
"%s(): mt7697_80211_to_ethernet() failed(%d)\n",
__func__, ret);
goto cleanup;
}
skb->protocol = eth_type_trans(skb, skb->dev);
dev_dbg(cfg->dev, "%s: protocol(%u)\n", __func__, skb->protocol);
vif->net_stats.rx_packets++;
vif->net_stats.rx_bytes += len;
netif_rx_ni(skb);
cleanup:
if (ret && skb) dev_kfree_skb(skb);
if (ret < 0) {
vif->net_stats.tx_errors++;
if (skb) dev_kfree_skb(skb);
}
return ret;
}
......@@ -22,75 +22,78 @@
#include "core.h"
#include "cfg80211.h"
static int mt7697_proc_get_psk(struct mt7697_cfg80211_info *cfg)
static int mt7697_proc_get_psk(const struct mt7697q_rsp_hdr* rsp,
struct mt7697_cfg80211_info *cfg)
{
u32 len = 0;
int ret = 0;
dev_dbg(cfg->dev, "%s: --> PSK(%u)\n", __func__, cfg->rsp.cmd.len);
if (cfg->rsp.cmd.len != sizeof(struct mt7697_get_psk_rsp)) {
dev_err(cfg->dev, "%s: invalid PSK rsp len(%u != %u)\n",
__func__, cfg->rsp.cmd.len,
dev_dbg(cfg->dev, "%s(): --> PSK\n", __func__);
if (rsp->cmd.len != sizeof(struct mt7697_get_psk_rsp)) {
dev_err(cfg->dev, "%s(): invalid PSK rsp len(%u != %u)\n",
__func__, rsp->cmd.len,
sizeof(struct mt7697_get_psk_rsp));
ret = -EINVAL;
goto cleanup;
}
ret = cfg->hif_ops->read(cfg->rxq_hdl, (u32*)&len,
MT7697_QUEUE_LEN_TO_WORD(sizeof(u32)));
if (ret != MT7697_QUEUE_LEN_TO_WORD(sizeof(u32))) {
dev_err(cfg->dev, "%s: read() failed(%d != %d)\n",
__func__, ret, MT7697_QUEUE_LEN_TO_WORD(sizeof(u32)));
LEN_TO_WORD(sizeof(u32)));
if (ret != LEN_TO_WORD(sizeof(u32))) {
dev_err(cfg->dev, "%s(): read() failed(%d != %d)\n",
__func__, ret, LEN_TO_WORD(sizeof(u32)));
ret = (ret < 0) ? ret:-EIO;
goto cleanup;
}
else if (!len || len > MT7697_PASSPHRASE_LEN) {
dev_err(cfg->dev, "%s: invalid PSK length(%d)\n",
WARN_ON(len > MT7697_PASSPHRASE_LEN);
if (len > MT7697_PASSPHRASE_LEN) {
dev_err(cfg->dev, "%s(): invalid PSK length(%d)\n",
__func__, len);
ret = -EINVAL;
goto cleanup;
}
dev_dbg(cfg->dev, "%s: PSK length(%d)\n", __func__, len);
dev_dbg(cfg->dev, "%s(): PSK length(%d)\n", __func__, len);
memset(cfg->psk, 0, MT7697_PASSPHRASE_LEN);
ret = cfg->hif_ops->read(cfg->rxq_hdl, (u32*)&cfg->psk,
MT7697_QUEUE_LEN_TO_WORD(MT7697_PASSPHRASE_LEN));
if (ret != MT7697_QUEUE_LEN_TO_WORD(MT7697_PASSPHRASE_LEN)) {
dev_err(cfg->dev, "%s: read() failed(%d != %d)\n",
LEN_TO_WORD(MT7697_PASSPHRASE_LEN));
if (ret != LEN_TO_WORD(MT7697_PASSPHRASE_LEN)) {
dev_err(cfg->dev, "%s(): read() failed(%d != %d)\n",
__func__, ret,
MT7697_QUEUE_LEN_TO_WORD(MT7697_PASSPHRASE_LEN));
LEN_TO_WORD(MT7697_PASSPHRASE_LEN));
ret = (ret < 0) ? ret:-EIO;
goto cleanup;
}
dev_dbg(cfg->dev, "%s: PSK('%s')\n", __func__, cfg->psk);
dev_dbg(cfg->dev, "%s(): PSK('%s')\n", __func__, cfg->psk);
cleanup:
return ret;
}
static int mt7697_proc_mac_addr(struct mt7697_cfg80211_info *cfg)
static int mt7697_proc_mac_addr(const struct mt7697q_rsp_hdr* rsp,
struct mt7697_cfg80211_info *cfg)
{
u8 addr[MT7697_LEN32_ALIGNED(ETH_ALEN)];
u8 addr[LEN32_ALIGNED(ETH_ALEN)];
struct wireless_dev *wdev;
int ret = 0;
dev_dbg(cfg->dev, "%s: --> MAC ADDRESS(%u)\n",
__func__, cfg->rsp.cmd.len);
if (cfg->rsp.cmd.len != sizeof(struct mt7697_mac_addr_rsp)) {
dev_dbg(cfg->dev, "%s(): --> MAC ADDRESS\n", __func__);
if (rsp->cmd.len != sizeof(struct mt7697_mac_addr_rsp)) {
dev_err(cfg->dev,
"%s: invalid MAC address rsp len(%u != %u)\n",
__func__, cfg->rsp.cmd.len,
"%s(): invalid MAC address rsp len(%u != %u)\n",
__func__, rsp->cmd.len,
sizeof(struct mt7697_mac_addr_rsp));
ret = -EINVAL;
goto cleanup;
}
ret = cfg->hif_ops->read(cfg->rxq_hdl, (u32*)&addr,
MT7697_QUEUE_LEN_TO_WORD(sizeof(addr)));
if (ret != MT7697_QUEUE_LEN_TO_WORD(sizeof(addr))) {
dev_err(cfg->dev, "%s: read() failed(%d != %d)\n",
__func__, ret, MT7697_QUEUE_LEN_TO_WORD(sizeof(addr)));
LEN_TO_WORD(sizeof(addr)));
if (ret != LEN_TO_WORD(sizeof(addr))) {
dev_err(cfg->dev, "%s(): read() failed(%d != %d)\n",
__func__, ret, LEN_TO_WORD(sizeof(addr)));
ret = (ret < 0) ? ret:-EIO;
goto cleanup;
}
......@@ -106,98 +109,101 @@ static int mt7697_proc_mac_addr(struct mt7697_cfg80211_info *cfg)
rtnl_unlock();
if (!wdev) {
dev_err(cfg->dev, "%s: mt7697_interface_add() failed\n",
dev_err(cfg->dev, "%s(): mt7697_interface_add() failed\n",
__func__);
ret = -ENOMEM;
goto cleanup;
}
dev_dbg(cfg->dev, "%s: name/type('%s'/%u) netdev(0x%p), cfg(0x%p)\n",
dev_dbg(cfg->dev, "%s(): name/type('%s'/%u) netdev(0x%p), cfg(0x%p)\n",
__func__, wdev->netdev->name, wdev->iftype, wdev->netdev, cfg);
cleanup:
return ret;
}
static int mt7697_proc_get_wireless_mode(struct mt7697_cfg80211_info *cfg)
static int mt7697_proc_get_wireless_mode(const struct mt7697q_rsp_hdr* rsp,
struct mt7697_cfg80211_info *cfg)
{
u32 wireless_mode;
int ret = 0;
dev_dbg(cfg->dev, "%s: --> WIRELESS MODE(%u)\n", __func__, cfg->rsp.cmd.len);
if (cfg->rsp.cmd.len - sizeof(struct mt7697_rsp_hdr) != sizeof(wireless_mode)) {
dev_err(cfg->dev, "%s: invalid wireless mode rsp len(%u != %u)\n",
dev_dbg(cfg->dev, "%s(): --> WIRELESS MODE\n", __func__);
if (rsp->cmd.len - sizeof(struct mt7697q_rsp_hdr) != sizeof(u32)) {
dev_err(cfg->dev,
"%s(): invalid wireless mode rsp len(%u != %u)\n",
__func__,
cfg->rsp.cmd.len - sizeof(struct mt7697_rsp_hdr),
sizeof(wireless_mode));
rsp->cmd.len - sizeof(struct mt7697q_rsp_hdr),
sizeof(u32));
ret = -EINVAL;
goto cleanup;
}
ret = cfg->hif_ops->read(cfg->rxq_hdl, (u32*)&wireless_mode,
MT7697_QUEUE_LEN_TO_WORD(sizeof(wireless_mode)));
if (ret != MT7697_QUEUE_LEN_TO_WORD(sizeof(wireless_mode))) {
dev_err(cfg->dev, "%s: read() failed(%d != %d)\n",
LEN_TO_WORD(sizeof(u32)));
if (ret != LEN_TO_WORD(sizeof(u32))) {
dev_err(cfg->dev, "%s(): read() failed(%d != %d)\n",
__func__, ret,
MT7697_QUEUE_LEN_TO_WORD(sizeof(wireless_mode)));
LEN_TO_WORD(sizeof(wireless_mode)));
ret = (ret < 0) ? ret:-EIO;
goto cleanup;
}
dev_dbg(cfg->dev, "%s: wireless mode(%u)\n", __func__, wireless_mode);
dev_dbg(cfg->dev, "%s(): wireless mode(%u)\n",
__func__, wireless_mode);
cfg->hw_wireless_mode = wireless_mode;
cleanup:
return ret;
}
static int mt7697_proc_get_cfg(struct mt7697_cfg80211_info *cfg)
static int mt7697_proc_get_cfg(const struct mt7697q_rsp_hdr* rsp,
struct mt7697_cfg80211_info *cfg)
{
struct mt7697_wifi_config_t *wifi_cfg;
u8* rd_buf = NULL;
int ret = 0;
dev_dbg(cfg->dev, "%s: --> CONFIG(%u)\n", __func__, cfg->rsp.cmd.len);
if (cfg->rsp.cmd.len - sizeof(struct mt7697_rsp_hdr) !=
MT7697_LEN32_ALIGNED(sizeof(struct mt7697_wifi_config_t))) {
dev_err(cfg->dev, "%s: invalid cfg rsp len(%u != %u)\n",
dev_dbg(cfg->dev, "%s(): --> CONFIG\n", __func__);
if (rsp->cmd.len - sizeof(struct mt7697q_rsp_hdr) !=
LEN32_ALIGNED(sizeof(struct mt7697_wifi_config_t))) {
dev_err(cfg->dev, "%s(): invalid cfg rsp len(%u != %u)\n",
__func__,
cfg->rsp.cmd.len - sizeof(struct mt7697_rsp_hdr),
MT7697_LEN32_ALIGNED(sizeof(struct mt7697_wifi_config_t)));
rsp->cmd.len - sizeof(struct mt7697q_rsp_hdr),
LEN32_ALIGNED(sizeof(struct mt7697_wifi_config_t)));
ret = -EINVAL;
goto cleanup;
}
rd_buf = kzalloc(
MT7697_LEN32_ALIGNED(sizeof(struct mt7697_wifi_config_t)),
rd_buf = kzalloc(LEN32_ALIGNED(sizeof(struct mt7697_wifi_config_t)),
GFP_KERNEL);
if (!rd_buf) {
dev_err(cfg->dev, "%s: kzalloc() failed\n", __func__);
dev_err(cfg->dev, "%s(): kzalloc() failed\n", __func__);
ret = -ENOMEM;
goto cleanup;
}
ret = cfg->hif_ops->read(cfg->rxq_hdl, (u32*)rd_buf,
MT7697_QUEUE_LEN_TO_WORD(sizeof(struct mt7697_wifi_config_t)));
if (ret != MT7697_QUEUE_LEN_TO_WORD(sizeof(struct mt7697_wifi_config_t))) {
dev_err(cfg->dev, "%s: read() failed(%d != %d)\n",
LEN_TO_WORD(sizeof(struct mt7697_wifi_config_t)));
if (ret != LEN_TO_WORD(sizeof(struct mt7697_wifi_config_t))) {
dev_err(cfg->dev, "%s(): read() failed(%d != %d)\n",
__func__, ret,
MT7697_QUEUE_LEN_TO_WORD(sizeof(struct mt7697_wifi_config_t)));
LEN_TO_WORD(sizeof(struct mt7697_wifi_config_t)));
ret = (ret < 0) ? ret:-EIO;
goto cleanup;
}
wifi_cfg = (struct mt7697_wifi_config_t*)rd_buf;
dev_dbg(cfg->dev, "%s: operation mode(%u)\n",
dev_dbg(cfg->dev, "%s(): operation mode(%u)\n",
__func__, wifi_cfg->opmode);
if ((wifi_cfg->opmode == MT7697_WIFI_MODE_STA_ONLY) ||
(wifi_cfg->opmode == MT7697_WIFI_MODE_REPEATER)) {
dev_dbg(cfg->dev, "%s: STA ssid len(%u)\n",
dev_dbg(cfg->dev, "%s(): STA ssid len(%u)\n",
__func__, wifi_cfg->sta_config.ssid_length);
if (wifi_cfg->sta_config.ssid_length > 0) {
if (wifi_cfg->sta_config.ssid_length > IEEE80211_MAX_SSID_LEN) {
dev_err(cfg->dev,
"%s: invalid STA SSID len(%u > %u)\n",
"%s(): invalid STA SSID len(%u > %u)\n",
__func__,
wifi_cfg->sta_config.ssid_length,
IEEE80211_MAX_SSID_LEN);
......@@ -205,7 +211,7 @@ static int mt7697_proc_get_cfg(struct mt7697_cfg80211_info *cfg)
goto cleanup;
}
dev_dbg(cfg->dev, "%s: STA ssid('%s')\n",
dev_dbg(cfg->dev, "%s(): STA ssid('%s')\n",
__func__, wifi_cfg->sta_config.ssid);
}
......@@ -214,12 +220,12 @@ static int mt7697_proc_get_cfg(struct mt7697_cfg80211_info *cfg)
16, 1, wifi_cfg->sta_config.bssid, ETH_ALEN, 0);
}
dev_dbg(cfg->dev, "%s: STA passphrase len(%u)\n",
dev_dbg(cfg->dev, "%s(): STA passphrase len(%u)\n",
__func__, wifi_cfg->sta_config.password_length);
if (wifi_cfg->sta_config.password_length > 0) {
if (wifi_cfg->sta_config.password_length > MT7697_WIFI_LENGTH_PASSPHRASE) {
dev_err(cfg->dev,
"%s: invalid STA passphrase len(%u > %u)\n",
"%s(): invalid STA passphrase len(%u > %u)\n",
__func__,
wifi_cfg->sta_config.password_length,
MT7697_WIFI_LENGTH_PASSPHRASE);
......@@ -227,19 +233,19 @@ static int mt7697_proc_get_cfg(struct mt7697_cfg80211_info *cfg)
goto cleanup;
}
dev_dbg(cfg->dev, "%s: STA passphrase('%s')\n",
dev_dbg(cfg->dev, "%s(): STA passphrase('%s')\n",
__func__, wifi_cfg->sta_config.password);
}
}
if ((wifi_cfg->opmode == MT7697_WIFI_MODE_AP_ONLY) ||
(wifi_cfg->opmode == MT7697_WIFI_MODE_REPEATER)) {
dev_dbg(cfg->dev, "%s: AP ssid len(%u)\n",
dev_dbg(cfg->dev, "%s(): AP ssid len(%u)\n",
__func__, wifi_cfg->ap_config.ssid_length);
if (wifi_cfg->ap_config.ssid_length > 0) {
if (wifi_cfg->ap_config.ssid_length > IEEE80211_MAX_SSID_LEN) {
dev_err(cfg->dev,
"%s: invalid AP SSID len(%u > %u)\n",
"%s(): invalid AP SSID len(%u > %u)\n",
__func__,
wifi_cfg->ap_config.ssid_length,
IEEE80211_MAX_SSID_LEN);
......@@ -247,16 +253,16 @@ static int mt7697_proc_get_cfg(struct mt7697_cfg80211_info *cfg)
goto cleanup;
}
dev_dbg(cfg->dev, "%s: AP ssid('%s')\n",
dev_dbg(cfg->dev, "%s(): AP ssid('%s')\n",
__func__, wifi_cfg->ap_config.ssid);
}
dev_dbg(cfg->dev, "%s: AP passphrase len(%u)\n",
dev_dbg(cfg->dev, "%s(): AP passphrase len(%u)\n",
__func__, wifi_cfg->ap_config.password_length);
if (wifi_cfg->ap_config.password_length > 0) {
if (wifi_cfg->ap_config.password_length > MT7697_WIFI_LENGTH_PASSPHRASE) {
dev_err(cfg->dev,
"%s: invalid AP passphrase len(%u > %u)\n",
"%s(): invalid AP passphrase len(%u > %u)\n",
__func__,
wifi_cfg->ap_config.password_length,
MT7697_WIFI_LENGTH_PASSPHRASE);
......@@ -264,18 +270,18 @@ static int mt7697_proc_get_cfg(struct mt7697_cfg80211_info *cfg)
goto cleanup;
}
dev_dbg(cfg->dev, "%s: AP passphrase('%s')\n",
dev_dbg(cfg->dev, "%s(): AP passphrase('%s')\n",
__func__, wifi_cfg->ap_config.password);
}
dev_dbg(cfg->dev, "%s: AP auth mode(%u) encrypt type(%u)\n",
dev_dbg(cfg->dev, "%s(): AP auth mode(%u) encrypt type(%u)\n",
__func__, wifi_cfg->ap_config.auth_mode,
wifi_cfg->ap_config.encrypt_type);
dev_dbg(cfg->dev, "%s: AP channel(%u) bandwidth(%u)\n",
dev_dbg(cfg->dev, "%s(): AP channel(%u) bandwidth(%u)\n",
__func__, wifi_cfg->ap_config.channel,
wifi_cfg->ap_config.bandwidth);
if (wifi_cfg->ap_config.bandwidth == MT7697_WIFI_IOT_COMMAND_CONFIG_BANDWIDTH_40MHZ) {
dev_dbg(cfg->dev, "%s: AP bandwidth ext(%u)\n",
dev_dbg(cfg->dev, "%s(): AP bandwidth ext(%u)\n",
__func__, wifi_cfg->ap_config.bandwidth_ext);
}
}
......@@ -287,142 +293,143 @@ cleanup:
return ret;
}
static int mt7697_proc_get_rx_filter(struct mt7697_cfg80211_info *cfg)
static int mt7697_proc_get_rx_filter(const struct mt7697q_rsp_hdr* rsp,
struct mt7697_cfg80211_info *cfg)
{
u32 rx_filter;
int ret = 0;
dev_dbg(cfg->dev, "%s: --> GET RX FILTER(%u)\n",
__func__, cfg->rsp.cmd.len);
if (cfg->rsp.cmd.len - sizeof(struct mt7697_rsp_hdr) != sizeof(rx_filter)) {
dev_err(cfg->dev, "%s: invalid rx filter rsp len(%u != %u)\n",
dev_dbg(cfg->dev, "%s(): --> GET RX FILTER\n", __func__);
if (rsp->cmd.len - sizeof(struct mt7697q_rsp_hdr) != sizeof(u32)) {
dev_err(cfg->dev,
"%s(): invalid rx filter rsp len(%u != %u)\n",
__func__,
cfg->rsp.cmd.len - sizeof(struct mt7697_rsp_hdr),
sizeof(rx_filter));
rsp->cmd.len - sizeof(struct mt7697q_rsp_hdr),
sizeof(u32));
ret = -EINVAL;
goto cleanup;
}
ret = cfg->hif_ops->read(cfg->rxq_hdl, (u32*)&rx_filter,
MT7697_QUEUE_LEN_TO_WORD(sizeof(rx_filter)));
if (ret != MT7697_QUEUE_LEN_TO_WORD(sizeof(rx_filter))) {
dev_err(cfg->dev, "%s: read() failed(%d != %d)\n",
__func__, ret,
MT7697_QUEUE_LEN_TO_WORD(sizeof(rx_filter)));
LEN_TO_WORD(sizeof(u32)));
if (ret != LEN_TO_WORD(sizeof(u32))) {
dev_err(cfg->dev, "%s(): read() failed(%d != %d)\n",
__func__, ret, LEN_TO_WORD(sizeof(rx_filter)));
ret = (ret < 0) ? ret:-EIO;
goto cleanup;
}
cfg->rx_filter = rx_filter;
dev_dbg(cfg->dev, "%s: rx filter(0x%08x)\n", __func__, cfg->rx_filter);
dev_dbg(cfg->dev, "%s(): rx filter(0x%08x)\n",
__func__, cfg->rx_filter);
cleanup:
return ret;
}
static int mt7697_proc_get_smart_conn_filter(struct mt7697_cfg80211_info *cfg)
static int mt7697_proc_get_smart_conn_filter(const struct mt7697q_rsp_hdr* rsp,
struct mt7697_cfg80211_info *cfg)
{
u32 smart_conn_filter;
int ret = 0;
dev_dbg(cfg->dev, "%s: --> GET SMART CONN FILTER(%u)\n",
__func__, cfg->rsp.cmd.len);
if (cfg->rsp.cmd.len - sizeof(struct mt7697_rsp_hdr) != sizeof(smart_conn_filter)) {
dev_err(cfg->dev, "%s: invalid rx filter rsp len(%u != %u)\n",
dev_dbg(cfg->dev, "%s(): --> GET SMART CONN FILTER\n", __func__);
if (rsp->cmd.len - sizeof(struct mt7697q_rsp_hdr) != sizeof(smart_conn_filter)) {
dev_err(cfg->dev, "%s(): invalid rx filter rsp len(%u != %u)\n",
__func__,
cfg->rsp.cmd.len - sizeof(struct mt7697_rsp_hdr),
rsp->cmd.len - sizeof(struct mt7697q_rsp_hdr),
sizeof(smart_conn_filter));
ret = -EINVAL;
goto cleanup;
}
ret = cfg->hif_ops->read(cfg->rxq_hdl, (u32*)&smart_conn_filter,
MT7697_QUEUE_LEN_TO_WORD(sizeof(smart_conn_filter)));
if (ret != MT7697_QUEUE_LEN_TO_WORD(sizeof(smart_conn_filter))) {
dev_err(cfg->dev, "%s: read() failed(%d != %d)\n",
__func__, ret,
MT7697_QUEUE_LEN_TO_WORD(sizeof(smart_conn_filter)));
LEN_TO_WORD(sizeof(u32)));
if (ret != LEN_TO_WORD(sizeof(u32))) {
dev_err(cfg->dev, "%s(): read() failed(%d != %d)\n",
__func__, ret, LEN_TO_WORD(sizeof(u32)));
ret = (ret < 0) ? ret:-EIO;
goto cleanup;
}
cfg->smart_conn_filter = smart_conn_filter;
dev_dbg(cfg->dev, "%s: smart connection filter(%u)\n",
dev_dbg(cfg->dev, "%s(): smart connection filter(%u)\n",
__func__, cfg->smart_conn_filter);
cleanup:
return ret;
}
static int mt7697_proc_get_radio_state(struct mt7697_cfg80211_info *cfg)
static int mt7697_proc_get_radio_state(const struct mt7697q_rsp_hdr* rsp,
struct mt7697_cfg80211_info *cfg)
{
u32 state;
int ret = 0;
dev_dbg(cfg->dev, "%s: --> GET RADIO STATE(%u)\n",
__func__, cfg->rsp.cmd.len);
if (cfg->rsp.cmd.len - sizeof(struct mt7697_rsp_hdr) != sizeof(state)) {
dev_err(cfg->dev, "%s: invalid get radio state rsp len(%u != %u)\n",
dev_dbg(cfg->dev, "%s(): --> GET RADIO STATE\n", __func__);
if (rsp->cmd.len - sizeof(struct mt7697q_rsp_hdr) != sizeof(u32)) {
dev_err(cfg->dev,
"%s(): invalid get radio state rsp len(%u != %u)\n",
__func__,
cfg->rsp.cmd.len - sizeof(struct mt7697_rsp_hdr),
sizeof(state));
rsp->cmd.len - sizeof(struct mt7697q_rsp_hdr),
sizeof(u32));
ret = -EINVAL;
goto cleanup;
}
ret = cfg->hif_ops->read(cfg->rxq_hdl, (u32*)&state,
MT7697_QUEUE_LEN_TO_WORD(sizeof(state)));
if (ret != MT7697_QUEUE_LEN_TO_WORD(sizeof(state))) {
dev_err(cfg->dev, "%s: read() failed(%d != %d)\n",
__func__, ret,
MT7697_QUEUE_LEN_TO_WORD(sizeof(state)));
LEN_TO_WORD(sizeof(u32)));
if (ret != LEN_TO_WORD(sizeof(u32))) {
dev_err(cfg->dev, "%s(): read() failed(%d != %d)\n",
__func__, ret, LEN_TO_WORD(sizeof(u32)));
ret = (ret < 0) ? ret:-EIO;
goto cleanup;
}
cfg->radio_state = state;
dev_dbg(cfg->dev, "%s: radio state(%u)\n", __func__, cfg->radio_state);
dev_dbg(cfg->dev, "%s(): radio state(%u)\n",
__func__, cfg->radio_state);
cleanup:
return ret;
}
static int mt7697_proc_get_listen_interval(struct mt7697_cfg80211_info *cfg)
static int mt7697_proc_get_listen_interval(const struct mt7697q_rsp_hdr* rsp,
struct mt7697_cfg80211_info *cfg)
{
u32 interval;
int ret = 0;
dev_dbg(cfg->dev, "%s: --> GET LISTEN INTERVAL(%u)\n",
__func__, cfg->rsp.cmd.len);
if (cfg->rsp.cmd.len - sizeof(struct mt7697_rsp_hdr) != sizeof(interval)) {
dev_dbg(cfg->dev, "%s(): --> GET LISTEN INTERVAL\n", __func__);
if (rsp->cmd.len - sizeof(struct mt7697q_rsp_hdr) != sizeof(u32)) {
dev_err(cfg->dev,
"%s: invalid get listen interval rsp len(%u != %u)\n",
"%s(): invalid get listen interval rsp len(%u != %u)\n",
__func__,
cfg->rsp.cmd.len - sizeof(struct mt7697_rsp_hdr),
sizeof(interval));
rsp->cmd.len - sizeof(struct mt7697q_rsp_hdr),
sizeof(u32));
ret = -EINVAL;
goto cleanup;
}
ret = cfg->hif_ops->read(cfg->rxq_hdl, (u32*)&interval,
MT7697_QUEUE_LEN_TO_WORD(sizeof(interval)));
if (ret != MT7697_QUEUE_LEN_TO_WORD(sizeof(interval))) {
dev_err(cfg->dev, "%s: read() failed(%d != %d)\n",
__func__, ret,
MT7697_QUEUE_LEN_TO_WORD(sizeof(interval)));
LEN_TO_WORD(sizeof(u32)));
if (ret != LEN_TO_WORD(sizeof(u32))) {
dev_err(cfg->dev, "%s(): read() failed(%d != %d)\n",
__func__, ret, LEN_TO_WORD(sizeof(u32)));
ret = (ret < 0) ? ret:-EIO;
goto cleanup;
}
cfg->listen_interval = interval;
dev_dbg(cfg->dev, "%s: listen interval(%u)\n",
dev_dbg(cfg->dev, "%s(): listen interval(%u)\n",
__func__, cfg->listen_interval);
cleanup:
return ret;
}
static int mt7697_proc_scan_rsp(struct mt7697_cfg80211_info *cfg)
static int mt7697_proc_scan_ind(const struct mt7697q_rsp_hdr* rsp,
struct mt7697_cfg80211_info *cfg)
{
struct ieee80211_mgmt *rx_mgmt_frame;
s32 rssi;
......@@ -431,60 +438,58 @@ static int mt7697_proc_scan_rsp(struct mt7697_cfg80211_info *cfg)
int ret = 0;
__le16 fc;
dev_dbg(cfg->dev, "%s: --> SCAN ITEM(%u)\n",
__func__, cfg->rsp.cmd.len);
dev_dbg(cfg->dev, "%s(): --> SCAN IND\n", __func__);
if (cfg->rsp.cmd.len <= sizeof(struct mt7697_scan_rsp)) {
dev_err(cfg->dev, "%s: invalid scan rsp len(%u <= %u)\n",
__func__, cfg->rsp.cmd.len,
sizeof(struct mt7697_scan_rsp));
if (rsp->cmd.len <= sizeof(struct mt7697_scan_ind)) {
dev_err(cfg->dev, "%s(): invalid scan ind len(%u <= %u)\n",
__func__, rsp->cmd.len,
sizeof(struct mt7697_scan_ind));
ret = -EINVAL;
goto cleanup;
}
ret = cfg->hif_ops->read(cfg->rxq_hdl, (s32*)&rssi,
MT7697_QUEUE_LEN_TO_WORD(sizeof(s32)));
if (ret != MT7697_QUEUE_LEN_TO_WORD(sizeof(s32))) {
dev_err(cfg->dev, "%s: read() failed(%d != %d)\n",
__func__, ret, MT7697_QUEUE_LEN_TO_WORD(sizeof(s32)));
LEN_TO_WORD(sizeof(s32)));
if (ret != LEN_TO_WORD(sizeof(s32))) {
dev_err(cfg->dev, "%s(): read() failed(%d != %d)\n",
__func__, ret, LEN_TO_WORD(sizeof(s32)));
ret = (ret < 0) ? ret:-EIO;
goto cleanup;
}
dev_dbg(cfg->dev, "%s: rssi(%d)\n", __func__, rssi);
dev_dbg(cfg->dev, "%s(): rssi(%d)\n", __func__, rssi);
ret = cfg->hif_ops->read(cfg->rxq_hdl, (u32*)&ch,
MT7697_QUEUE_LEN_TO_WORD(sizeof(u32)));
if (ret != MT7697_QUEUE_LEN_TO_WORD(sizeof(u32))) {
dev_err(cfg->dev, "%s: read() failed(%d != %d)\n",
__func__, ret, MT7697_QUEUE_LEN_TO_WORD(sizeof(u32)));
ret = (ret < 0) ? ret:-EIO;
goto cleanup;
}
dev_dbg(cfg->dev, "%s: channel(%u)\n", __func__, ch);
ret = cfg->hif_ops->read(cfg->rxq_hdl, (u32*)&probe_rsp_len,
MT7697_QUEUE_LEN_TO_WORD(sizeof(u32)));
if (ret != MT7697_QUEUE_LEN_TO_WORD(sizeof(u32))) {
dev_err(cfg->dev, "%s: read() failed(%d != %d)\n",
__func__, ret, MT7697_QUEUE_LEN_TO_WORD(sizeof(u32)));
LEN_TO_WORD(sizeof(u32)));
if (ret != LEN_TO_WORD(sizeof(u32))) {
dev_err(cfg->dev, "%s(): read() failed(%d != %d)\n",
__func__, ret, LEN_TO_WORD(sizeof(u32)));
ret = (ret < 0) ? ret:-EIO;
goto cleanup;
}
dev_dbg(cfg->dev, "%s(): channel(%u)\n", __func__, ch);
probe_rsp_len = rsp->result;
if (probe_rsp_len > IEEE80211_MAX_DATA_LEN) {
dev_err(cfg->dev, "%s: invalid probe rsp len(%d > %d)\n",
dev_err(cfg->dev, "%s(): invalid probe rsp len(%d > %d)\n",
__func__, probe_rsp_len, IEEE80211_MAX_DATA_LEN);
ret = -EINVAL;
goto cleanup;
}
dev_dbg(cfg->dev, "%s: probe rsp len(%u)\n", __func__, probe_rsp_len);
else if (!probe_rsp_len) {
dev_err(cfg->dev, "%s(): invalid probe rsp len(%d)\n",
__func__, probe_rsp_len);
ret = -EINVAL;
goto cleanup;
}
dev_dbg(cfg->dev, "%s(): probe rsp len(%u)\n",
__func__, probe_rsp_len);
ret = cfg->hif_ops->read(cfg->rxq_hdl, (u32*)cfg->probe_data,
MT7697_QUEUE_LEN_TO_WORD(MT7697_LEN32_ALIGNED(probe_rsp_len)));
if (ret != MT7697_QUEUE_LEN_TO_WORD(MT7697_LEN32_ALIGNED(probe_rsp_len))) {
dev_err(cfg->dev, "%s: read() failed(%d != %d)\n",
LEN_TO_WORD(LEN32_ALIGNED(probe_rsp_len)));
if (ret != LEN_TO_WORD(LEN32_ALIGNED(probe_rsp_len))) {
dev_err(cfg->dev, "%s(): read() failed(%d != %d)\n",
__func__, ret,
MT7697_QUEUE_LEN_TO_WORD(MT7697_LEN32_ALIGNED(probe_rsp_len)));
LEN_TO_WORD(LEN32_ALIGNED(probe_rsp_len)));
ret = (ret < 0) ? ret:-EIO;
goto cleanup;
}
......@@ -503,7 +508,7 @@ static int mt7697_proc_scan_rsp(struct mt7697_cfg80211_info *cfg)
(ch <= MT7697_CH_MAX_5G_CHANNEL))
band = cfg->wiphy->bands[IEEE80211_BAND_5GHZ];
else {
dev_err(cfg->dev, "%s: invalid channel(%u)\n",
dev_err(cfg->dev, "%s(): invalid channel(%u)\n",
__func__, ch);
ret = -EINVAL;
goto cleanup;
......@@ -512,7 +517,7 @@ static int mt7697_proc_scan_rsp(struct mt7697_cfg80211_info *cfg)
freq = ieee80211_channel_to_frequency(ch, band->band);
if (!freq) {
dev_err(cfg->dev,
"%s: ieee80211_channel_to_frequency() failed\n",
"%s(): ieee80211_channel_to_frequency() failed\n",
__func__);
ret = -EINVAL;
goto cleanup;
......@@ -521,7 +526,7 @@ static int mt7697_proc_scan_rsp(struct mt7697_cfg80211_info *cfg)
channel = ieee80211_get_channel(cfg->wiphy, freq);
if (!channel) {
dev_err(cfg->dev,
"%s: ieee80211_get_channel() failed\n",
"%s(): ieee80211_get_channel() failed\n",
__func__);
ret = -EINVAL;
goto cleanup;
......@@ -532,7 +537,7 @@ static int mt7697_proc_scan_rsp(struct mt7697_cfg80211_info *cfg)
GFP_ATOMIC);
if (!bss) {
dev_err(cfg->dev,
"%s: cfg80211_inform_bss_frame() failed\n",
"%s(): cfg80211_inform_bss_frame() failed\n",
__func__);
ret = -ENOMEM;
goto cleanup;
......@@ -540,17 +545,20 @@ static int mt7697_proc_scan_rsp(struct mt7697_cfg80211_info *cfg)
print_hex_dump(KERN_DEBUG, DRVNAME" BSS BSSID ",
DUMP_PREFIX_OFFSET, 16, 1, bss->bssid, ETH_ALEN, 0);
dev_dbg(cfg->dev, "%s: BSS signal(%d) scan width(%u) cap(0x%08x)\n",
__func__, bss->signal, bss->scan_width, bss->capability);
dev_dbg(cfg->dev,
"%s(): BSS signal(%d) scan width(%u) cap(0x%08x)\n",
__func__, bss->signal, bss->scan_width,
bss->capability);
if (bss->channel) {
dev_dbg(cfg->dev,
"%s: BSS channel band(%u) center freq(%u)\n",
"%s(): BSS channel band(%u) center freq(%u)\n",
__func__, bss->channel->band,
bss->channel->center_freq);
}
}
else {
dev_err(cfg->dev, "%s: Rx unsupported mgmt frame\n", __func__);
dev_err(cfg->dev, "%s(): Rx unsupported mgmt frame\n",
__func__);
ret = -EINVAL;
goto cleanup;
}
......@@ -559,85 +567,195 @@ cleanup:
return ret;
}
static int mt7697_proc_scan_complete(struct mt7697_cfg80211_info *cfg)
static int mt7697_proc_scan_rsp(const struct mt7697q_rsp_hdr* rsp,
struct mt7697_cfg80211_info *cfg)
{
struct mt7697_vif *vif;
u16 if_idx;
u32 if_idx;
int ret;
dev_dbg(cfg->dev, "%s: --> SCAN COMPLETE\n", __func__);
dev_dbg(cfg->dev, "%s(): --> SCAN RSP result(%d)\n",
__func__, rsp->result);
ret = cfg->hif_ops->read(cfg->rxq_hdl, (u32*)&if_idx,
MT7697_QUEUE_LEN_TO_WORD(sizeof(u32)));
if (ret != MT7697_QUEUE_LEN_TO_WORD(sizeof(u32))) {
dev_err(cfg->dev, "%s: read() failed(%d != %d)\n",
__func__, ret, MT7697_QUEUE_LEN_TO_WORD(sizeof(u32)));
LEN_TO_WORD(sizeof(u32)));
if (ret != LEN_TO_WORD(sizeof(u32))) {
dev_err(cfg->dev, "%s(): read() failed(%d != %d)\n",
__func__, ret, LEN_TO_WORD(sizeof(u32)));
ret = (ret < 0) ? ret:-EIO;
goto cleanup;
}
dev_dbg(cfg->dev, "%s: if idx(%d)\n", __func__, if_idx);
dev_dbg(cfg->dev, "%s(): if idx(%d)\n", __func__, if_idx);
if (rsp->result < 0) {
vif = mt7697_get_vif_by_idx(cfg, if_idx);
if (!vif) {
dev_err(cfg->dev, "%s: mt7697_get_vif_by_idx(%u) failed\n",
dev_err(cfg->dev,
"%s(): mt7697_get_vif_by_idx(%u) failed\n",
__func__, if_idx);
ret = -EINVAL;
goto cleanup;
}
dev_dbg(cfg->dev, "%s: vif(%u)\n", __func__, vif->fw_vif_idx);
dev_dbg(cfg->dev, "%s(): vif(%u)\n",
__func__, vif->fw_vif_idx);
cfg80211_scan_done(vif->scan_req, true);
vif->scan_req = NULL;
}
cleanup:
return ret;
}
static int mt7697_proc_scan_complete_ind(struct mt7697_cfg80211_info *cfg)
{
struct mt7697_vif *vif;
u32 if_idx;
int ret;
dev_dbg(cfg->dev, "%s(): --> SCAN COMPLETE IND\n", __func__);
ret = cfg->hif_ops->read(cfg->rxq_hdl, (u32*)&if_idx,
LEN_TO_WORD(sizeof(u32)));
if (ret != LEN_TO_WORD(sizeof(u32))) {
dev_err(cfg->dev, "%s(): read() failed(%d != %d)\n",
__func__, ret, LEN_TO_WORD(sizeof(u32)));
ret = (ret < 0) ? ret:-EIO;
goto cleanup;
}
dev_dbg(cfg->dev, "%s(): if idx(%u)\n", __func__, if_idx);
vif = mt7697_get_vif_by_idx(cfg, if_idx);
if (!vif) {
dev_err(cfg->dev, "%s(): mt7697_get_vif_by_idx(%u) failed\n",
__func__, if_idx);
ret = -EINVAL;
goto cleanup;
}
dev_dbg(cfg->dev, "%s(): vif(%u)\n", __func__, vif->fw_vif_idx);
cfg80211_scan_done(vif->scan_req, false);
vif->scan_req = NULL;
ret = mt7697_wr_scan_stop_req(cfg);
if (ret < 0) {
dev_err(cfg->dev, "%s(): mt7697_wr_scan_stop_req() failed(%d)\n",
__func__, ret);
goto cleanup;
}
cleanup:
return ret;
}
static int mt7697_proc_connect(struct mt7697_cfg80211_info *cfg)
static void mt7697_proc_reg_rx_hndlr(struct mt7697_cfg80211_info *cfg)
{
dev_dbg(cfg->dev, "%s(): --> REGISTER RX HANDLER RSP\n", __func__);
cfg->reg_rx_hndlr = true;
}
static void mt7697_proc_unreg_rx_hndlr(struct mt7697_cfg80211_info *cfg)
{
u8 bssid[MT7697_LEN32_ALIGNED(ETH_ALEN)];
dev_dbg(cfg->dev, "%s(): --> UNREGISTER RX HANDLER RSP\n", __func__);
cfg->reg_rx_hndlr = false;
}
static int mt7697_proc_connect_rsp(const struct mt7697q_rsp_hdr* rsp,
struct mt7697_cfg80211_info *cfg)
{
u8 bssid[LEN32_ALIGNED(ETH_ALEN)];
struct mt7697_vif *vif;
enum mt7697_wifi_rx_filter_t rx_filter;
u32 if_idx;
int ret;
dev_dbg(cfg->dev, "%s(): --> CONNECT RSP result(%d)\n",
__func__, rsp->result);
ret = cfg->hif_ops->read(cfg->rxq_hdl, (u32*)&if_idx,
LEN_TO_WORD(sizeof(u32)));
if (ret != LEN_TO_WORD(sizeof(u32))) {
dev_err(cfg->dev, "%s(): read() failed(%d != %d)\n",
__func__, ret, LEN_TO_WORD(sizeof(u32)));
ret = (ret < 0) ? ret:-EIO;
goto cleanup;
}
dev_dbg(cfg->dev, "%s(): if idx(%u)\n", __func__, if_idx);
ret = cfg->hif_ops->read(cfg->rxq_hdl, (u32*)bssid,
LEN_TO_WORD(sizeof(bssid)));
if (ret != LEN_TO_WORD(sizeof(bssid))) {
dev_err(cfg->dev, "%s(): read() failed(%d != %d)\n",
__func__, ret, LEN_TO_WORD(sizeof(bssid)));
ret = (ret < 0) ? ret:-EIO;
goto cleanup;
}
print_hex_dump(KERN_DEBUG, DRVNAME" BSSID ",
DUMP_PREFIX_OFFSET, 16, 1, bssid, ETH_ALEN, 0);
vif = mt7697_get_vif_by_idx(cfg, if_idx);
if (!vif) {
dev_err(cfg->dev, "%s(): mt7697_get_vif_by_idx(%u) failed\n",
__func__, if_idx);
ret = -EINVAL;
goto cleanup;
}
if (rsp->result < 0) {
cfg80211_connect_result(vif->ndev, bssid,
NULL, 0, NULL, 0,
WLAN_STATUS_UNSPECIFIED_FAILURE,
GFP_KERNEL);
}
cleanup:
return ret;
}
static int mt7697_proc_connect_ind(const struct mt7697q_rsp_hdr* rsp,
struct mt7697_cfg80211_info *cfg)
{
u8 bssid[LEN32_ALIGNED(ETH_ALEN)];
struct mt7697_vif *vif;
// enum mt7697_wifi_rx_filter_t rx_filter = cfg->rx_filter;
u32 if_idx;
u32 channel;
int ret;
dev_dbg(cfg->dev, "%s: --> CONNECT RSP(%u)\n",
__func__, cfg->rsp.cmd.len);
if (cfg->rsp.cmd.len != sizeof(struct mt7697_connect_rsp)) {
dev_err(cfg->dev, "%s: invalid connect rsp len(%d != %d)\n",
__func__, cfg->rsp.cmd.len,
sizeof(struct mt7697_connect_rsp));
dev_dbg(cfg->dev, "%s(): --> CONNECT IND\n", __func__);
if (rsp->cmd.len != sizeof(struct mt7697_connect_ind)) {
dev_err(cfg->dev, "%s(): invalid connect ind len(%d != %d)\n",
__func__, rsp->cmd.len,
sizeof(struct mt7697_connect_ind));
ret = -EINVAL;
goto cleanup;
}
ret = cfg->hif_ops->read(cfg->rxq_hdl, (u32*)&if_idx,
MT7697_QUEUE_LEN_TO_WORD(sizeof(u32)));
if (ret != MT7697_QUEUE_LEN_TO_WORD(sizeof(u32))) {
dev_err(cfg->dev, "%s: read() failed(%d != %d)\n",
__func__, ret, MT7697_QUEUE_LEN_TO_WORD(sizeof(u32)));
LEN_TO_WORD(sizeof(u32)));
if (ret != LEN_TO_WORD(sizeof(u32))) {
dev_err(cfg->dev, "%s(): read() failed(%d != %d)\n",
__func__, ret, LEN_TO_WORD(sizeof(u32)));
ret = (ret < 0) ? ret:-EIO;
goto cleanup;
}
dev_dbg(cfg->dev, "%s: if idx(%d)\n", __func__, if_idx);
dev_dbg(cfg->dev, "%s(): if idx(%d)\n", __func__, if_idx);
ret = cfg->hif_ops->read(cfg->rxq_hdl, (u32*)&channel,
MT7697_QUEUE_LEN_TO_WORD(sizeof(u32)));
if (ret != MT7697_QUEUE_LEN_TO_WORD(sizeof(u32))) {
dev_err(cfg->dev, "%s: read() failed(%d != %d)\n",
__func__, ret, MT7697_QUEUE_LEN_TO_WORD(sizeof(u32)));
LEN_TO_WORD(sizeof(u32)));
if (ret != LEN_TO_WORD(sizeof(u32))) {
dev_err(cfg->dev, "%s(): read() failed(%d != %d)\n",
__func__, ret, LEN_TO_WORD(sizeof(u32)));
ret = (ret < 0) ? ret:-EIO;
goto cleanup;
}
dev_dbg(cfg->dev, "%s: channel(%d)\n", __func__, channel);
dev_dbg(cfg->dev, "%s(): channel(%d)\n", __func__, channel);
ret = cfg->hif_ops->read(cfg->rxq_hdl, (u32*)bssid,
MT7697_QUEUE_LEN_TO_WORD(sizeof(bssid)));
if (ret != MT7697_QUEUE_LEN_TO_WORD(sizeof(bssid))) {
dev_err(cfg->dev, "%s: read() failed(%d != %d)\n",
__func__, ret,
MT7697_QUEUE_LEN_TO_WORD(sizeof(bssid)));
LEN_TO_WORD(sizeof(bssid)));
if (ret != LEN_TO_WORD(sizeof(bssid))) {
dev_err(cfg->dev, "%s(): read() failed(%d != %d)\n",
__func__, ret, LEN_TO_WORD(sizeof(bssid)));
ret = (ret < 0) ? ret:-EIO;
goto cleanup;
}
......@@ -647,21 +765,23 @@ static int mt7697_proc_connect(struct mt7697_cfg80211_info *cfg)
vif = mt7697_get_vif_by_idx(cfg, if_idx);
if (!vif) {
dev_err(cfg->dev, "%s: mt7697_get_vif_by_idx(%u) failed\n",
dev_err(cfg->dev, "%s(): mt7697_get_vif_by_idx(%u) failed\n",
__func__, if_idx);
ret = -EINVAL;
goto cleanup;
}
rx_filter |= BIT(MT7697_WIFI_RX_FILTER_RM_FRAME_REPORT_EN);
/*
rx_filter &= ~BIT(MT7697_WIFI_RX_FILTER_DROP_NOT_MY_BSSID);
rx_filter &= ~BIT(MT7697_WIFI_RX_FILTER_DROP_NOT_UC2ME);
rx_filter |= BIT(MT7697_WIFI_RX_FILTER_DROP_PROBE_REQ);
rx_filter |= BIT(MT7697_WIFI_RX_FILTER_DROP_STBC_BCN_BC_MC);
rx_filter &= ~BIT(MT7697_WIFI_RX_FILTER_DROP_BC_FRAME);
rx_filter &= ~BIT(MT7697_WIFI_RX_FILTER_DROP_MC_FRAME);
if (rx_filter != cfg->rx_filter) {
ret = mt7697_send_set_rx_filter_req(cfg, cfg->rx_filter);
ret = mt7697_wr_set_rx_filter_req(cfg, cfg->rx_filter);
if (ret < 0) {
dev_err(cfg->dev,
"%s: mt7697_send_set_rx_filter_req() failed(%d)\n",
"%s(): mt7697_wr_set_rx_filter_req() failed(%d)\n",
__func__, ret);
goto cleanup;
}
......@@ -670,30 +790,40 @@ static int mt7697_proc_connect(struct mt7697_cfg80211_info *cfg)
}
if (!cfg->smart_conn_filter) {
ret = mt7697_send_set_smart_conn_filter_req(cfg, true);
ret = mt7697_wr_set_smart_conn_filter_req(cfg, true);
if (ret < 0) {
dev_err(cfg->dev,
"%s: mt7697_send_set_smart_conn_filter_req() failed(%d)\n",
"%s(): mt7697_wr_set_smart_conn_filter_req() failed(%d)\n",
__func__, ret);
goto cleanup;
}
cfg->smart_conn_filter = true;
}
*/
if (!cfg->reg_rx_hndlr) {
/* ret = mt7697_wr_set_op_mode_req(cfg, MT7697_WIFI_MODE_MONITOR);
if (ret < 0) {
dev_err(cfg->dev,
"%s(): mt7697_wr_set_op_mode_req() failed(%d)\n",
__func__, ret);
goto cleanup;
}
ret = mt7697_send_register_rx_hndlr_req(cfg);
ret = mt7697_wr_reg_rx_hndlr_req(cfg);
if (ret < 0) {
dev_err(cfg->dev,
"%s: mt7697_send_register_rx_hndlr_req() failed(%d)\n",
"%s(): mt7697_wr_reg_rx_hndlr_req() failed(%d)\n",
__func__, ret);
goto cleanup;
}*/
}
dev_dbg(cfg->dev, "%s: vif(%u)\n", __func__, vif->fw_vif_idx);
dev_dbg(cfg->dev, "%s(): vif(%u)\n", __func__, vif->fw_vif_idx);
ret = mt7697_cfg80211_connect_event(vif, bssid, channel);
if (ret < 0) {
dev_err(cfg->dev,
"%s: mt7697_cfg80211_connect_event() failed(%d)\n",
"%s(): mt7697_cfg80211_connect_event() failed(%d)\n",
__func__, ret);
goto cleanup;
}
......@@ -702,32 +832,59 @@ cleanup:
return ret;
}
static int mt7697_proc_disconnect(struct mt7697_cfg80211_info *cfg)
static int mt7697_proc_disconnect_rsp(struct mt7697_cfg80211_info *cfg)
{
u8 bssid[MT7697_LEN32_ALIGNED(ETH_ALEN)];
int ret;
dev_dbg(cfg->dev, "%s(): --> DISCONNECT RSP\n", __func__);
if (cfg->reg_rx_hndlr) {
/* ret = mt7697_wr_set_op_mode_req(cfg, cfg->wifi_config.opmode);
if (ret < 0) {
dev_err(cfg->dev,
"%s(): mt7697_wr_set_op_mode_req() failed(%d)\n",
__func__, ret);
goto cleanup;
}
*/
ret = mt7697_wr_unreg_rx_hndlr_req(cfg);
if (ret < 0) {
dev_err(cfg->dev,
"%s(): mt7697_wr_unreg_rx_hndlr_req() failed(%d)\n",
__func__, ret);
goto cleanup;
}
}
cleanup:
return ret;
}
static int mt7697_proc_disconnect_ind(struct mt7697_cfg80211_info *cfg)
{
u8 bssid[LEN32_ALIGNED(ETH_ALEN)];
struct mt7697_vif *vif;
u16 if_idx;
u32 if_idx;
u16 proto_reason = 0;
int ret;
dev_dbg(cfg->dev, "%s: --> DISCONNECT RSP(%u)\n", __func__, cfg->rsp.cmd.len);
dev_dbg(cfg->dev, "%s(): --> DISCONNECT IND\n", __func__);
ret = cfg->hif_ops->read(cfg->rxq_hdl, (u32*)&if_idx,
MT7697_QUEUE_LEN_TO_WORD(sizeof(u32)));
if (ret != MT7697_QUEUE_LEN_TO_WORD(sizeof(u32))) {
dev_err(cfg->dev, "%s: read() failed(%d != %d)\n",
__func__, ret, MT7697_QUEUE_LEN_TO_WORD(sizeof(u32)));
LEN_TO_WORD(sizeof(u32)));
if (ret != LEN_TO_WORD(sizeof(u32))) {
dev_err(cfg->dev, "%s(): read() failed(%d != %d)\n",
__func__, ret, LEN_TO_WORD(sizeof(u32)));
ret = (ret < 0) ? ret:-EIO;
goto cleanup;
}
dev_dbg(cfg->dev, "%s: if idx(%d)\n", __func__, if_idx);
dev_dbg(cfg->dev, "%s(): if idx(%d)\n", __func__, if_idx);
ret = cfg->hif_ops->read(cfg->rxq_hdl, (u32*)bssid,
MT7697_QUEUE_LEN_TO_WORD(sizeof(bssid)));
if (ret != MT7697_QUEUE_LEN_TO_WORD(sizeof(bssid))) {
dev_err(cfg->dev, "%s: read() failed(%d != %d)\n",
__func__, ret,
MT7697_QUEUE_LEN_TO_WORD(sizeof(bssid)));
LEN_TO_WORD(sizeof(bssid)));
if (ret != LEN_TO_WORD(sizeof(bssid))) {
dev_err(cfg->dev, "%s(): read() failed(%d != %d)\n",
__func__, ret, LEN_TO_WORD(sizeof(bssid)));
ret = (ret < 0) ? ret:-EIO;
goto cleanup;
}
......@@ -737,28 +894,29 @@ static int mt7697_proc_disconnect(struct mt7697_cfg80211_info *cfg)
vif = mt7697_get_vif_by_idx(cfg, if_idx);
if (!vif) {
dev_err(cfg->dev, "%s: mt7697_get_vif_by_idx(%u) failed\n",
dev_err(cfg->dev, "%s(): mt7697_get_vif_by_idx(%u) failed\n",
__func__, if_idx);
ret = -EINVAL;
goto cleanup;
}
ret = mt7697_send_unregister_rx_hndlr_req(cfg);
dev_dbg(cfg->dev, "%s(): vif(%u)\n", __func__, vif->fw_vif_idx);
if (vif->sme_state == SME_CONNECTING)
cfg80211_connect_result(vif->ndev, bssid,
NULL, 0,
NULL, 0,
WLAN_STATUS_UNSPECIFIED_FAILURE,
GFP_KERNEL);
else if (vif->sme_state == SME_CONNECTED) {
ret = mt7697_wr_disconnect_req(cfg, vif->fw_vif_idx,
NULL);
if (ret < 0) {
dev_err(cfg->dev,
"%s: mt7697_send_unregister_rx_hndlr_req() failed(%d)\n",
"%s(): mt7697_wr_disconnect_req() failed(%d)\n",
__func__, ret);
goto cleanup;
}
dev_dbg(cfg->dev, "%s: vif(%u)\n", __func__, vif->fw_vif_idx);
if (vif->sme_state == SME_CONNECTING) {
cfg80211_connect_result(vif->ndev, bssid,
NULL, 0,
NULL, 0,
WLAN_STATUS_UNSPECIFIED_FAILURE,
GFP_KERNEL);
} else if (vif->sme_state == SME_CONNECTED) {
cfg80211_disconnected(vif->ndev, proto_reason,
NULL, 0, GFP_KERNEL);
}
......@@ -767,7 +925,7 @@ static int mt7697_proc_disconnect(struct mt7697_cfg80211_info *cfg)
spin_lock_bh(&vif->if_lock);
clear_bit(CONNECT_PEND, &vif->flags);
clear_bit(CONNECTED, &vif->flags);
dev_dbg(cfg->dev, "%s: vif sme_state(%u), flags(0x%08lx)\n",
dev_dbg(cfg->dev, "%s(): vif sme_state(%u), flags(0x%08lx)\n",
__func__, vif->sme_state, vif->flags);
spin_unlock_bh(&vif->if_lock);
......@@ -775,44 +933,43 @@ cleanup:
return ret;
}
static int mt7697_rx_raw(struct mt7697_cfg80211_info *cfg)
static int mt7697_rx_raw(const struct mt7697q_rsp_hdr* rsp,
struct mt7697_cfg80211_info *cfg)
{
int ret;
dev_dbg(cfg->dev, "%s: --> RX RAW(%u)\n", __func__, cfg->rsp.cmd.len);
dev_dbg(cfg->dev, "%s(): --> RX RAW(%u)\n", __func__, rsp->cmd.len);
if (cfg->rsp.cmd.len <= sizeof(struct mt7697_rsp_hdr)) {
dev_err(cfg->dev, "%s: invalid rx raw len(%u <= %u)\n",
__func__, cfg->rsp.cmd.len,
sizeof(struct mt7697_rsp_hdr));
if (rsp->cmd.len <= sizeof(struct mt7697q_rsp_hdr)) {
dev_err(cfg->dev, "%s(): invalid rx raw len(%u <= %u)\n",
__func__, rsp->cmd.len,
sizeof(struct mt7697q_rsp_hdr));
ret = -EINVAL;
goto cleanup;
}
dev_dbg(cfg->dev, "%s: len(%d)\n", __func__, cfg->rsp.result);
if (cfg->rsp.result > IEEE80211_MAX_FRAME_LEN) {
dev_err(cfg->dev, "%s: invalid rx data len(%u <= %u)\n",
__func__, cfg->rsp.result, IEEE80211_MAX_FRAME_LEN);
dev_dbg(cfg->dev, "%s(): len(%d)\n", __func__, rsp->result);
if (rsp->result > IEEE80211_MAX_FRAME_LEN) {
dev_err(cfg->dev, "%s(): invalid rx data len(%u > %u)\n",
__func__, rsp->result, IEEE80211_MAX_FRAME_LEN);
ret = -EINVAL;
goto cleanup;
}
ret = cfg->hif_ops->read(cfg->rxq_hdl, (u32*)cfg->rx_data,
MT7697_QUEUE_LEN_TO_WORD(cfg->rsp.result));
if (ret != MT7697_QUEUE_LEN_TO_WORD(cfg->rsp.result)) {
dev_err(cfg->dev, "%s: read() failed(%d != %d)\n",
__func__, ret, MT7697_QUEUE_LEN_TO_WORD(cfg->rsp.result));
LEN_TO_WORD(LEN32_ALIGNED(rsp->result)));
if (ret != LEN_TO_WORD(LEN32_ALIGNED(rsp->result))) {
dev_err(cfg->dev, "%s(): read() failed(%d != %d)\n",
__func__, ret,
LEN_TO_WORD(LEN32_ALIGNED(rsp->result)));
ret = (ret < 0) ? ret:-EIO;
goto cleanup;
}
print_hex_dump(KERN_DEBUG, DRVNAME" RX DATA ",
DUMP_PREFIX_OFFSET, 16, 1, cfg->rx_data, cfg->rsp.result, 0);
/* TODO: interface index come from MT7697 */
ret = mt7697_rx_data(cfg, 0);
ret = mt7697_rx_data(cfg, rsp->result, 0);
if (ret) {
dev_err(cfg->dev, "%s: mt7697_rx_data() failed(%d)\n",
dev_err(cfg->dev, "%s(): mt7697_rx_data() failed(%d)\n",
__func__, ret);
goto cleanup;
}
......@@ -821,73 +978,74 @@ cleanup:
return ret;
}
static int mt7697_proc_80211cmd(struct mt7697_cfg80211_info *cfg)
int mt7697_proc_80211cmd(const struct mt7697q_rsp_hdr* rsp, void* priv)
{
int ret;
struct mt7697_cfg80211_info *cfg = (struct mt7697_cfg80211_info*)priv;
int ret = 0;
switch (cfg->rsp.cmd.type) {
switch (rsp->cmd.type) {
case MT7697_CMD_GET_PSK_RSP:
ret = mt7697_proc_get_psk(cfg);
ret = mt7697_proc_get_psk(rsp, cfg);
if (ret < 0) {
dev_err(cfg->dev,
"%s: mt7697_proc_get_psk() failed(%d)\n",
"%s(): mt7697_proc_get_psk() failed(%d)\n",
__func__, ret);
goto cleanup;
}
break;
case MT7697_CMD_MAC_ADDR_RSP:
ret = mt7697_proc_mac_addr(cfg);
ret = mt7697_proc_mac_addr(rsp, cfg);
if (ret < 0) {
dev_err(cfg->dev,
"%s: mt7697_proc_mac_addr() failed(%d)\n",
"%s(): mt7697_proc_mac_addr() failed(%d)\n",
__func__, ret);
goto cleanup;
}
break;
case MT7697_CMD_GET_WIRELESS_MODE_RSP:
ret = mt7697_proc_get_wireless_mode(cfg);
ret = mt7697_proc_get_wireless_mode(rsp, cfg);
if (ret < 0) {
dev_err(cfg->dev,
"%s: mt7697_proc_get_wireless_mode() failed(%d)\n",
"%s(): mt7697_proc_get_wireless_mode() failed(%d)\n",
__func__, ret);
goto cleanup;
}
break;
case MT7697_CMD_GET_CFG_RSP:
ret = mt7697_proc_get_cfg(cfg);
ret = mt7697_proc_get_cfg(rsp, cfg);
if (ret < 0) {
dev_err(cfg->dev,
"%s: mt7697_proc_get_cfg() failed(%d)\n",
"%s(): mt7697_proc_get_cfg() failed(%d)\n",
__func__, ret);
goto cleanup;
}
break;
case MT7697_CMD_GET_RX_FILTER_RSP:
ret = mt7697_proc_get_rx_filter(cfg);
ret = mt7697_proc_get_rx_filter(rsp, cfg);
if (ret < 0) {
dev_err(cfg->dev,
"%s: mt7697_proc_get_rx_filter() failed(%d)\n",
"%s(): mt7697_proc_get_rx_filter() failed(%d)\n",
__func__, ret);
goto cleanup;
}
break;
case MT7697_CMD_GET_SMART_CONN_FILTER_RSP:
ret = mt7697_proc_get_smart_conn_filter(cfg);
ret = mt7697_proc_get_smart_conn_filter(rsp, cfg);
if (ret < 0) {
dev_err(cfg->dev,
"%s: mt7697_proc_get_smart_conn_filter() failed(%d)\n",
"%s(): mt7697_proc_get_smart_conn_filter() failed(%d)\n",
__func__, ret);
goto cleanup;
}
break;
case MT7697_CMD_GET_RADIO_STATE_RSP:
ret = mt7697_proc_get_radio_state(cfg);
ret = mt7697_proc_get_radio_state(rsp, cfg);
if (ret < 0) {
dev_err(cfg->dev,
"mt7697_proc_get_radio_state() failed(%d)\n",
......@@ -897,123 +1055,142 @@ static int mt7697_proc_80211cmd(struct mt7697_cfg80211_info *cfg)
break;
case MT7697_CMD_GET_LISTEN_INTERVAL_RSP:
ret = mt7697_proc_get_listen_interval(cfg);
ret = mt7697_proc_get_listen_interval(rsp, cfg);
if (ret < 0) {
dev_err(cfg->dev,
"%s: mt7697_proc_get_listen_interval() failed(%d)\n",
"%s(): mt7697_proc_get_listen_interval() failed(%d)\n",
__func__, ret);
goto cleanup;
}
break;
case MT7697_CMD_SCAN_RSP:
ret = mt7697_proc_scan_rsp(cfg);
ret = mt7697_proc_scan_rsp(rsp, cfg);
if (ret < 0) {
dev_err(cfg->dev,
"%s(): mt7697_proc_scan_rsp() failed(%d)\n",
__func__, ret);
goto cleanup;
}
break;
case MT7697_CMD_SCAN_IND:
ret = mt7697_proc_scan_ind(rsp, cfg);
if (ret < 0) {
dev_err(cfg->dev,
"%s: mt7697_proc_scan_rsp() failed(%d)\n",
"%s(): mt7697_proc_scan_ind() failed(%d)\n",
__func__, ret);
goto cleanup;
}
break;
case MT7697_CMD_SCAN_COMPLETE:
ret = mt7697_proc_scan_complete(cfg);
case MT7697_CMD_SCAN_COMPLETE_IND:
ret = mt7697_proc_scan_complete_ind(cfg);
if (ret < 0) {
dev_err(cfg->dev,
"%s: mt7697_proc_scan_complete() failed(%d)\n",
"%s(): mt7697_proc_scan_complete_ind() failed(%d)\n",
__func__, ret);
goto cleanup;
}
break;
case MT7697_CMD_REGISTER_RX_HNDLR_RSP:
mt7697_proc_reg_rx_hndlr(cfg);
break;
case MT7697_CMD_UNREGISTER_RX_HNDLR_RSP:
mt7697_proc_unreg_rx_hndlr(cfg);
break;
case MT7697_CMD_CONNECT_RSP:
ret = mt7697_proc_connect(cfg);
ret = mt7697_proc_connect_rsp(rsp, cfg);
if (ret < 0) {
dev_err(cfg->dev,
"%s(): mt7697_proc_connect_rsp() failed(%d)\n",
__func__, ret);
goto cleanup;
}
break;
case MT7697_CMD_CONNECT_IND:
ret = mt7697_proc_connect_ind(rsp, cfg);
if (ret < 0) {
dev_err(cfg->dev,
"%s: mt7697_proc_connect() failed(%d)\n",
"%s(): mt7697_proc_connect_ind() failed(%d)\n",
__func__, ret);
goto cleanup;
}
break;
case MT7697_CMD_DISCONNECT_RSP:
ret = mt7697_proc_disconnect(cfg);
ret = mt7697_proc_disconnect_rsp(cfg);
if (ret < 0) {
dev_err(cfg->dev,
"%s: mt7697_proc_disconnect() failed(%d)\n",
"%s(): mt7697_proc_disconnect_rsp() failed(%d)\n",
__func__, ret);
goto cleanup;
}
break;
case MT7697_CMD_RX_RAW:
ret = mt7697_rx_raw(cfg);
case MT7697_CMD_DISCONNECT_IND:
ret = mt7697_proc_disconnect_ind(cfg);
if (ret < 0) {
dev_err(cfg->dev,
"%s: mt7697_rx_raw() failed(%d)\n",
"%s(): mt7697_proc_disconnect_ind() failed(%d)\n",
__func__, ret);
goto cleanup;
}
break;
case MT7697_CMD_RX_RAW:
ret = mt7697_rx_raw(rsp, cfg);
if (ret < 0) {
dev_err(cfg->dev, "%s(): mt7697_rx_raw() failed(%d)\n",
__func__, ret);
goto cleanup;
}
break;
case MT7697_CMD_SET_PSK_RSP:
dev_dbg(cfg->dev, "%s: --> SET PSK(%u)\n",
__func__, cfg->rsp.cmd.len);
dev_dbg(cfg->dev, "%s(): --> SET PSK\n", __func__);
break;
case MT7697_CMD_SET_LISTEN_INTERVAL_RSP:
dev_dbg(cfg->dev, "%s: --> SET LISTEN INTERVAL(%u)\n",
__func__, cfg->rsp.cmd.len);
dev_dbg(cfg->dev, "%s(): --> SET LISTEN INTERVAL\n", __func__);
break;
case MT7697_CMD_SET_OP_MODE_RSP:
dev_dbg(cfg->dev, "%s: --> SET OP MODE(%u)\n",
__func__, cfg->rsp.cmd.len);
dev_dbg(cfg->dev, "%s(): --> SET OP MODE\n", __func__);
break;
case MT7697_CMD_SET_WIRELESS_MODE_RSP:
dev_dbg(cfg->dev, "%s: --> SET WIRELESS MODE(%u)\n",
__func__, cfg->rsp.cmd.len);
dev_dbg(cfg->dev, "%s(): --> SET WIRELESS MODE\n", __func__);
break;
case MT7697_CMD_SET_RADIO_STATE_RSP:
dev_dbg(cfg->dev, "%s: --> SET RADIO STATE(%u)\n",
__func__, cfg->rsp.cmd.len);
dev_dbg(cfg->dev, "%s(): --> SET RADIO STATE\n", __func__);
break;
case MT7697_CMD_SET_RX_FILTER_RSP:
dev_dbg(cfg->dev, "%s: --> SET RX FILTER(%u)\n",
__func__, cfg->rsp.cmd.len);
dev_dbg(cfg->dev, "%s(): --> SET RX FILTER\n", __func__);
break;
case MT7697_CMD_SET_SMART_CONN_FILTER_RSP:
dev_dbg(cfg->dev, "%s: --> SET SMART CONN FILTER(%u)\n",
__func__, cfg->rsp.cmd.len);
dev_dbg(cfg->dev, "%s(): --> SET SMART CONN FILTER\n",
__func__);
break;
case MT7697_CMD_SET_SECURITY_MODE_RSP:
dev_dbg(cfg->dev, "%s: --> SET SECURITY MODE(%u)\n",
__func__, cfg->rsp.cmd.len);
dev_dbg(cfg->dev, "%s(): --> SET SECURITY MODE\n", __func__);
break;
case MT7697_CMD_SCAN_STOP_RSP:
dev_dbg(cfg->dev, "%s: --> SCAN STOP(%u)\n",
__func__, cfg->rsp.cmd.len);
break;
case MT7697_CMD_REGISTER_RX_HNDLR_RSP:
dev_dbg(cfg->dev, "%s: --> REGISTER RX HANDLER(%u)\n",
__func__, cfg->rsp.cmd.len);
break;
case MT7697_CMD_UNREGISTER_RX_HNDLR_RSP:
dev_dbg(cfg->dev, "%s: --> UNREGISTER RX HANDLER(%u)\n",
__func__, cfg->rsp.cmd.len);
dev_dbg(cfg->dev, "%s(): --> SCAN STOP\n", __func__);
break;
default:
dev_err(cfg->dev, "%s: unsupported cmd(%d)\n",
__func__, cfg->rsp.cmd.type);
dev_err(cfg->dev, "%s(): unsupported cmd(%u)\n",
__func__, rsp->cmd.type);
ret = -EINVAL;
goto cleanup;
}
......@@ -1022,57 +1199,7 @@ cleanup:
return ret;
}
int mt7697_send_init(struct mt7697_cfg80211_info *cfg)
{
struct mt7697_cmd_hdr req;
int ret;
req.len = sizeof(struct mt7697_cmd_hdr);
req.grp = MT7697_CMD_GRP_QUEUE;
req.type = MT7697_CMD_INIT;
dev_dbg(cfg->dev, "%s: <-- QUEUE INIT\n", __func__);
ret = cfg->hif_ops->write(cfg->txq_hdl, (const u32*)&req,
MT7697_QUEUE_LEN_TO_WORD(req.len));
if (ret != MT7697_QUEUE_LEN_TO_WORD(req.len)) {
dev_err(cfg->dev, "%s: write() failed(%d != %d)\n",
__func__, ret, MT7697_QUEUE_LEN_TO_WORD(req.len));
ret = (ret < 0) ? ret:-EIO;
goto cleanup;
}
ret = 0;
cleanup:
return ret;
}
int mt7697_send_reset(struct mt7697_cfg80211_info *cfg)
{
struct mt7697_cmd_hdr req;
int ret;
req.len = sizeof(struct mt7697_cmd_hdr);
req.grp = MT7697_CMD_GRP_QUEUE;
req.type = MT7697_CMD_RESET;
dev_dbg(cfg->dev, "%s: <-- QUEUE RESET\n", __func__);
ret = cfg->hif_ops->write(cfg->txq_hdl, (const u32*)&req,
MT7697_QUEUE_LEN_TO_WORD(req.len));
if (ret != MT7697_QUEUE_LEN_TO_WORD(req.len)) {
dev_err(cfg->dev, "%s: write() failed(%d != %d)\n",
__func__, ret, MT7697_QUEUE_LEN_TO_WORD(req.len));
ret = (ret < 0) ? ret:-EIO;
goto cleanup;
}
ret = 0;
cleanup:
return ret;
}
int mt7697_send_get_wireless_mode_req(struct mt7697_cfg80211_info *cfg, u8 port)
int mt7697_wr_get_wireless_mode_req(struct mt7697_cfg80211_info *cfg, u8 port)
{
struct mt7697_get_wireless_mode_req req;
int ret;
......@@ -1082,12 +1209,13 @@ int mt7697_send_get_wireless_mode_req(struct mt7697_cfg80211_info *cfg, u8 port)
req.cmd.type = MT7697_CMD_GET_WIRELESS_MODE_REQ;
req.port = port;
dev_dbg(cfg->dev, "%s: <-- GET WIRELESS MODE PORT(%u)\n", __func__, port);
dev_dbg(cfg->dev, "%s(): <-- GET WIRELESS MODE PORT(%u) len(%u)\n",
__func__, port, req.cmd.len);
ret = cfg->hif_ops->write(cfg->txq_hdl, (const u32*)&req,
MT7697_QUEUE_LEN_TO_WORD(req.cmd.len));
if (ret != MT7697_QUEUE_LEN_TO_WORD(req.cmd.len)) {
dev_err(cfg->dev, "%s: write() failed(%d != %d)\n",
__func__, ret, MT7697_QUEUE_LEN_TO_WORD(req.cmd.len));
LEN_TO_WORD(req.cmd.len));
if (ret != LEN_TO_WORD(req.cmd.len)) {
dev_err(cfg->dev, "%s(): write() failed(%d != %d)\n",
__func__, ret, LEN_TO_WORD(req.cmd.len));
ret = (ret < 0) ? ret:-EIO;
goto cleanup;
}
......@@ -1098,7 +1226,8 @@ cleanup:
return ret;
}
int mt7697_send_set_wireless_mode_req(struct mt7697_cfg80211_info *cfg, u8 port, u8 mode)
int mt7697_wr_set_wireless_mode_req(struct mt7697_cfg80211_info *cfg, u8 port,
u8 mode)
{
struct mt7697_set_wireless_mode_req req;
int ret;
......@@ -1109,12 +1238,13 @@ int mt7697_send_set_wireless_mode_req(struct mt7697_cfg80211_info *cfg, u8 port,
req.port = port;
req.mode = mode;
dev_dbg(cfg->dev, "%s: <-- SET WIRELESS MODE port(%u)\n", __func__, port);
dev_dbg(cfg->dev, "%s(): <-- SET WIRELESS MODE port(%u) len(%u)\n",
__func__, port, req.cmd.len);
ret = cfg->hif_ops->write(cfg->txq_hdl, (const u32*)&req,
MT7697_QUEUE_LEN_TO_WORD(req.cmd.len));
if (ret != MT7697_QUEUE_LEN_TO_WORD(req.cmd.len)) {
dev_err(cfg->dev, "%s: write() failed(%d != %d)\n",
__func__, ret, MT7697_QUEUE_LEN_TO_WORD(req.cmd.len));
LEN_TO_WORD(req.cmd.len));
if (ret != LEN_TO_WORD(req.cmd.len)) {
dev_err(cfg->dev, "%s(): write() failed(%d != %d)\n",
__func__, ret, LEN_TO_WORD(req.cmd.len));
ret = (ret < 0) ? ret:-EIO;
goto cleanup;
}
......@@ -1125,7 +1255,7 @@ cleanup:
return ret;
}
int mt7697_send_get_psk_req(struct mt7697_cfg80211_info *cfg, u8 port)
int mt7697_wr_get_psk_req(struct mt7697_cfg80211_info *cfg, u8 port)
{
struct mt7697_get_psk_req req;
int ret;
......@@ -1135,12 +1265,13 @@ int mt7697_send_get_psk_req(struct mt7697_cfg80211_info *cfg, u8 port)
req.cmd.type = MT7697_CMD_GET_PSK_REQ;
req.port = port;
dev_dbg(cfg->dev, "%s: <-- GET PSK port(%u)\n", __func__, port);
dev_dbg(cfg->dev, "%s(): <-- GET PSK port(%u) len(%u)\n",
__func__, port, req.cmd.len);
ret = cfg->hif_ops->write(cfg->txq_hdl, (const u32*)&req,
MT7697_QUEUE_LEN_TO_WORD(req.cmd.len));
if (ret != MT7697_QUEUE_LEN_TO_WORD(req.cmd.len)) {
dev_err(cfg->dev, "%s: write() failed(%d != %d)\n",
__func__, ret, MT7697_QUEUE_LEN_TO_WORD(req.cmd.len));
LEN_TO_WORD(req.cmd.len));
if (ret != LEN_TO_WORD(req.cmd.len)) {
dev_err(cfg->dev, "%s(): write() failed(%d != %d)\n",
__func__, ret, LEN_TO_WORD(req.cmd.len));
ret = (ret < 0) ? ret:-EIO;
goto cleanup;
}
......@@ -1151,7 +1282,7 @@ cleanup:
return ret;
}
int mt7697_send_set_psk_req(struct mt7697_cfg80211_info *cfg, u8 port,
int mt7697_wr_set_psk_req(struct mt7697_cfg80211_info *cfg, u8 port,
const u8 psk[])
{
struct mt7697_set_psk_req req;
......@@ -1164,13 +1295,14 @@ int mt7697_send_set_psk_req(struct mt7697_cfg80211_info *cfg, u8 port,
req.len = strlen(psk);
memcpy(req.psk, psk, req.len);
dev_dbg(cfg->dev, "%s: <-- SET PSK port(%u)\n", __func__, port);
dev_dbg(cfg->dev, "%s(): <-- SET PSK port(%u) len(%u)\n",
__func__, port, req.cmd.len);
ret = cfg->hif_ops->write(cfg->txq_hdl, (const u32*)&req,
MT7697_QUEUE_LEN_TO_WORD(sizeof(struct mt7697_set_psk_req)));
if (ret != MT7697_QUEUE_LEN_TO_WORD(sizeof(struct mt7697_set_psk_req))) {
dev_err(cfg->dev, "%s: write() failed(%d != %d)\n",
LEN_TO_WORD(sizeof(struct mt7697_set_psk_req)));
if (ret != LEN_TO_WORD(sizeof(struct mt7697_set_psk_req))) {
dev_err(cfg->dev, "%s(): write() failed(%d != %d)\n",
__func__, ret,
MT7697_QUEUE_LEN_TO_WORD(sizeof(struct mt7697_set_psk_req)));
LEN_TO_WORD(sizeof(struct mt7697_set_psk_req)));
ret = (ret < 0) ? ret:-EIO;
goto cleanup;
}
......@@ -1181,7 +1313,7 @@ cleanup:
return ret;
}
int mt7697_send_mac_addr_req(struct mt7697_cfg80211_info *cfg, u8 port)
int mt7697_wr_mac_addr_req(struct mt7697_cfg80211_info *cfg, u8 port)
{
struct mt7697_mac_addr_req req;
int ret;
......@@ -1191,12 +1323,13 @@ int mt7697_send_mac_addr_req(struct mt7697_cfg80211_info *cfg, u8 port)
req.cmd.type = MT7697_CMD_MAC_ADDR_REQ;
req.port = port;
dev_dbg(cfg->dev, "%s: <-- GET MAC ADDRESS port(%u)\n", __func__, port);
dev_dbg(cfg->dev, "%s(): <-- GET MAC ADDRESS port(%u) len(%u)\n",
__func__, port, req.cmd.len);
ret = cfg->hif_ops->write(cfg->txq_hdl, (const u32*)&req,
MT7697_QUEUE_LEN_TO_WORD(req.cmd.len));
if (ret != MT7697_QUEUE_LEN_TO_WORD(req.cmd.len)) {
dev_err(cfg->dev, "%s: write() failed(%d != %d)\n",
__func__, ret, MT7697_QUEUE_LEN_TO_WORD(req.cmd.len));
LEN_TO_WORD(req.cmd.len));
if (ret != LEN_TO_WORD(req.cmd.len)) {
dev_err(cfg->dev, "%s(): write() failed(%d != %d)\n",
__func__, ret, LEN_TO_WORD(req.cmd.len));
ret = (ret < 0) ? ret:-EIO;
goto cleanup;
}
......@@ -1207,7 +1340,7 @@ cleanup:
return ret;
}
int mt7697_send_set_op_mode_req(struct mt7697_cfg80211_info* cfg, u8 opmode)
int mt7697_wr_set_op_mode_req(struct mt7697_cfg80211_info* cfg, u8 opmode)
{
struct mt7697_set_op_mode_req req;
int ret;
......@@ -1217,12 +1350,13 @@ int mt7697_send_set_op_mode_req(struct mt7697_cfg80211_info* cfg, u8 opmode)
req.cmd.type = MT7697_CMD_SET_OP_MODE_REQ;
req.opmode = opmode;
dev_dbg(cfg->dev, "%s: <-- SET OPMODE(%u)\n", __func__, opmode);
dev_dbg(cfg->dev, "%s(): <-- SET OPMODE(%u) len(%u)\n",
__func__, opmode, req.cmd.len);
ret = cfg->hif_ops->write(cfg->txq_hdl, (const u32*)&req,
MT7697_QUEUE_LEN_TO_WORD(req.cmd.len));
if (ret != MT7697_QUEUE_LEN_TO_WORD(req.cmd.len)) {
dev_err(cfg->dev, "%s: write() failed(%d != %d)\n",
__func__, ret, MT7697_QUEUE_LEN_TO_WORD(req.cmd.len));
LEN_TO_WORD(req.cmd.len));
if (ret != LEN_TO_WORD(req.cmd.len)) {
dev_err(cfg->dev, "%s(): write() failed(%d != %d)\n",
__func__, ret, LEN_TO_WORD(req.cmd.len));
ret = (ret < 0) ? ret:-EIO;
goto cleanup;
}
......@@ -1233,7 +1367,7 @@ cleanup:
return ret;
}
int mt7697_send_cfg_req(struct mt7697_cfg80211_info *cfg)
int mt7697_wr_cfg_req(struct mt7697_cfg80211_info *cfg)
{
struct mt7697_cfg_req req;
int ret;
......@@ -1242,12 +1376,13 @@ int mt7697_send_cfg_req(struct mt7697_cfg80211_info *cfg)
req.grp = MT7697_CMD_GRP_80211;
req.type = MT7697_CMD_GET_CFG_REQ;
dev_dbg(cfg->dev, "%s: <-- GET CONFIG\n", __func__);
dev_dbg(cfg->dev, "%s(): <-- GET CONFIG len(%u)\n",
__func__, req.len);
ret = cfg->hif_ops->write(cfg->txq_hdl, (const u32*)&req,
MT7697_QUEUE_LEN_TO_WORD(req.len));
if (ret != MT7697_QUEUE_LEN_TO_WORD(req.len)) {
dev_err(cfg->dev, "%s: write() failed(%d != %d)\n",
__func__, ret, MT7697_QUEUE_LEN_TO_WORD(req.len));
LEN_TO_WORD(req.len));
if (ret != LEN_TO_WORD(req.len)) {
dev_err(cfg->dev, "%s(): write() failed(%d != %d)\n",
__func__, ret, LEN_TO_WORD(req.len));
ret = (ret < 0) ? ret:-EIO;
goto cleanup;
}
......@@ -1258,7 +1393,7 @@ cleanup:
return ret;
}
int mt7697_send_register_rx_hndlr_req(struct mt7697_cfg80211_info* cfg)
int mt7697_wr_reg_rx_hndlr_req(struct mt7697_cfg80211_info* cfg)
{
struct mt7697_register_rx_hndlr_req req;
int ret;
......@@ -1267,12 +1402,13 @@ int mt7697_send_register_rx_hndlr_req(struct mt7697_cfg80211_info* cfg)
req.grp = MT7697_CMD_GRP_80211;
req.type = MT7697_CMD_REGISTER_RX_HNDLR_REQ;
dev_dbg(cfg->dev, "%s: <-- REGISTER RX HANDLER\n", __func__);
dev_dbg(cfg->dev, "%s(): <-- REGISTER RX HANDLER len(%u)\n",
__func__, req.len);
ret = cfg->hif_ops->write(cfg->txq_hdl, (const u32*)&req,
MT7697_QUEUE_LEN_TO_WORD(req.len));
if (ret != MT7697_QUEUE_LEN_TO_WORD(req.len)) {
dev_err(cfg->dev, "%s: write() failed(%d != %d)\n",
__func__, ret, MT7697_QUEUE_LEN_TO_WORD(req.len));
LEN_TO_WORD(req.len));
if (ret != LEN_TO_WORD(req.len)) {
dev_err(cfg->dev, "%s(): write() failed(%d != %d)\n",
__func__, ret, LEN_TO_WORD(req.len));
ret = (ret < 0) ? ret:-EIO;
goto cleanup;
}
......@@ -1283,7 +1419,7 @@ cleanup:
return ret;
}
int mt7697_send_unregister_rx_hndlr_req(struct mt7697_cfg80211_info* cfg)
int mt7697_wr_unreg_rx_hndlr_req(struct mt7697_cfg80211_info* cfg)
{
struct mt7697_unregister_rx_hndlr_req req;
int ret;
......@@ -1292,12 +1428,13 @@ int mt7697_send_unregister_rx_hndlr_req(struct mt7697_cfg80211_info* cfg)
req.grp = MT7697_CMD_GRP_80211;
req.type = MT7697_CMD_UNREGISTER_RX_HNDLR_REQ;
dev_dbg(cfg->dev, "%s: <-- UNREGISTER RX HANDLER\n", __func__);
dev_dbg(cfg->dev, "%s(): <-- UNREGISTER RX HANDLER len(%u)\n",
__func__, req.len);
ret = cfg->hif_ops->write(cfg->txq_hdl, (const u32*)&req,
MT7697_QUEUE_LEN_TO_WORD(req.len));
if (ret != MT7697_QUEUE_LEN_TO_WORD(req.len)) {
dev_err(cfg->dev, "%s: write() failed(%d != %d)\n",
__func__, ret, MT7697_QUEUE_LEN_TO_WORD(req.len));
LEN_TO_WORD(req.len));
if (ret != LEN_TO_WORD(req.len)) {
dev_err(cfg->dev, "%s(): write() failed(%d != %d)\n",
__func__, ret, LEN_TO_WORD(req.len));
ret = (ret < 0) ? ret:-EIO;
goto cleanup;
}
......@@ -1308,7 +1445,7 @@ cleanup:
return ret;
}
int mt7697_send_get_radio_state_req(struct mt7697_cfg80211_info* cfg)
int mt7697_wr_get_radio_state_req(struct mt7697_cfg80211_info* cfg)
{
struct mt7697_get_radio_state_req req;
int ret;
......@@ -1317,12 +1454,13 @@ int mt7697_send_get_radio_state_req(struct mt7697_cfg80211_info* cfg)
req.grp = MT7697_CMD_GRP_80211;
req.type = MT7697_CMD_GET_RADIO_STATE_REQ;
dev_dbg(cfg->dev, "%s: <-- GET RADIO STATE\n", __func__);
dev_dbg(cfg->dev, "%s(): <-- GET RADIO STATE len(%u)\n",
__func__, req.len);
ret = cfg->hif_ops->write(cfg->txq_hdl, (const u32*)&req,
MT7697_QUEUE_LEN_TO_WORD(req.len));
if (ret != MT7697_QUEUE_LEN_TO_WORD(req.len)) {
dev_err(cfg->dev, "%s: write() failed(%d != %d)\n",
__func__, ret, MT7697_QUEUE_LEN_TO_WORD(req.len));
LEN_TO_WORD(req.len));
if (ret != LEN_TO_WORD(req.len)) {
dev_err(cfg->dev, "%s(): write() failed(%d != %d)\n",
__func__, ret, LEN_TO_WORD(req.len));
ret = (ret < 0) ? ret:-EIO;
goto cleanup;
}
......@@ -1333,7 +1471,7 @@ cleanup:
return ret;
}
int mt7697_send_set_radio_state_req(struct mt7697_cfg80211_info* cfg, u8 state)
int mt7697_wr_set_radio_state_req(struct mt7697_cfg80211_info* cfg, u8 state)
{
struct mt7697_set_radio_state_req req;
int ret;
......@@ -1343,12 +1481,13 @@ int mt7697_send_set_radio_state_req(struct mt7697_cfg80211_info* cfg, u8 state)
req.cmd.type = MT7697_CMD_SET_RADIO_STATE_REQ;
req.state = state;
dev_dbg(cfg->dev, "%s: <-- SET RADIO STATE(%u)\n", __func__, state);
dev_dbg(cfg->dev, "%s(): <-- SET RADIO STATE(%u) len(%u)\n",
__func__, state, req.cmd.len);
ret = cfg->hif_ops->write(cfg->txq_hdl, (const u32*)&req,
MT7697_QUEUE_LEN_TO_WORD(req.cmd.len));
if (ret != MT7697_QUEUE_LEN_TO_WORD(req.cmd.len)) {
dev_err(cfg->dev, "%s: write() failed(%d != %d)\n",
__func__, ret, MT7697_QUEUE_LEN_TO_WORD(req.cmd.len));
LEN_TO_WORD(req.cmd.len));
if (ret != LEN_TO_WORD(req.cmd.len)) {
dev_err(cfg->dev, "%s(): write() failed(%d != %d)\n",
__func__, ret, LEN_TO_WORD(req.cmd.len));
ret = (ret < 0) ? ret:-EIO;
goto cleanup;
}
......@@ -1359,7 +1498,7 @@ cleanup:
return ret;
}
int mt7697_send_get_rx_filter_req(struct mt7697_cfg80211_info* cfg)
int mt7697_wr_get_rx_filter_req(struct mt7697_cfg80211_info* cfg)
{
struct mt7697_get_rx_filter_req req;
int ret;
......@@ -1368,12 +1507,13 @@ int mt7697_send_get_rx_filter_req(struct mt7697_cfg80211_info* cfg)
req.grp = MT7697_CMD_GRP_80211;
req.type = MT7697_CMD_GET_RX_FILTER_REQ;
dev_dbg(cfg->dev, "%s: <-- GET RX FILTER\n", __func__);
dev_dbg(cfg->dev, "%s(): <-- GET RX FILTER len(%u)\n",
__func__, req.len);
ret = cfg->hif_ops->write(cfg->txq_hdl, (const u32*)&req,
MT7697_QUEUE_LEN_TO_WORD(req.len));
if (ret != MT7697_QUEUE_LEN_TO_WORD(req.len)) {
dev_err(cfg->dev, "%s: write() failed(%d != %d)\n",
__func__, ret, MT7697_QUEUE_LEN_TO_WORD(req.len));
LEN_TO_WORD(req.len));
if (ret != LEN_TO_WORD(req.len)) {
dev_err(cfg->dev, "%s(): write() failed(%d != %d)\n",
__func__, ret, LEN_TO_WORD(req.len));
ret = (ret < 0) ? ret:-EIO;
goto cleanup;
}
......@@ -1384,7 +1524,7 @@ cleanup:
return ret;
}
int mt7697_send_set_rx_filter_req(struct mt7697_cfg80211_info* cfg,
int mt7697_wr_set_rx_filter_req(struct mt7697_cfg80211_info* cfg,
u32 rx_filter)
{
struct mt7697_set_rx_filter_req req;
......@@ -1395,13 +1535,13 @@ int mt7697_send_set_rx_filter_req(struct mt7697_cfg80211_info* cfg,
req.cmd.type = MT7697_CMD_SET_RX_FILTER_REQ;
req.rx_filter = rx_filter;
dev_dbg(cfg->dev, "%s: <-- SET RX FILTER(0x%08x)\n",
__func__, rx_filter);
dev_dbg(cfg->dev, "%s(): <-- SET RX FILTER(0x%08x) len(%u)\n",
__func__, rx_filter, req.cmd.len);
ret = cfg->hif_ops->write(cfg->txq_hdl, (const u32*)&req,
MT7697_QUEUE_LEN_TO_WORD(req.cmd.len));
if (ret != MT7697_QUEUE_LEN_TO_WORD(req.cmd.len)) {
dev_err(cfg->dev, "%s: write() failed(%d != %d)\n",
__func__, ret, MT7697_QUEUE_LEN_TO_WORD(req.cmd.len));
LEN_TO_WORD(req.cmd.len));
if (ret != LEN_TO_WORD(req.cmd.len)) {
dev_err(cfg->dev, "%s(): write() failed(%d != %d)\n",
__func__, ret, LEN_TO_WORD(req.cmd.len));
ret = (ret < 0) ? ret:-EIO;
goto cleanup;
}
......@@ -1412,7 +1552,7 @@ cleanup:
return ret;
}
int mt7697_send_get_smart_conn_filter_req(struct mt7697_cfg80211_info* cfg)
int mt7697_wr_get_smart_conn_filter_req(struct mt7697_cfg80211_info* cfg)
{
struct mt7697_get_smart_conn_filter_req req;
int ret;
......@@ -1421,12 +1561,13 @@ int mt7697_send_get_smart_conn_filter_req(struct mt7697_cfg80211_info* cfg)
req.grp = MT7697_CMD_GRP_80211;
req.type = MT7697_CMD_GET_SMART_CONN_FILTER_REQ;
dev_dbg(cfg->dev, "%s: <-- GET SMART CONN FILTER\n", __func__);
dev_dbg(cfg->dev, "%s(): <-- GET SMART CONN FILTER len(%u)\n",
__func__, req.len);
ret = cfg->hif_ops->write(cfg->txq_hdl, (const u32*)&req,
MT7697_QUEUE_LEN_TO_WORD(req.len));
if (ret != MT7697_QUEUE_LEN_TO_WORD(req.len)) {
dev_err(cfg->dev, "%s: write() failed(%d != %d)\n",
__func__, ret, MT7697_QUEUE_LEN_TO_WORD(req.len));
LEN_TO_WORD(req.len));
if (ret != LEN_TO_WORD(req.len)) {
dev_err(cfg->dev, "%s(): write() failed(%d != %d)\n",
__func__, ret, LEN_TO_WORD(req.len));
ret = (ret < 0) ? ret:-EIO;
goto cleanup;
}
......@@ -1437,7 +1578,8 @@ cleanup:
return ret;
}
int mt7697_send_set_smart_conn_filter_req(struct mt7697_cfg80211_info* cfg, u8 flag)
int mt7697_wr_set_smart_conn_filter_req(struct mt7697_cfg80211_info* cfg,
u8 flag)
{
struct mt7697_set_smart_conn_filter_req req;
int ret;
......@@ -1447,13 +1589,13 @@ int mt7697_send_set_smart_conn_filter_req(struct mt7697_cfg80211_info* cfg, u8 f
req.cmd.type = MT7697_CMD_SET_SMART_CONN_FILTER_REQ;
req.flag = flag;
dev_dbg(cfg->dev, "%s: <-- SET SMART CONN FILTER(%u)\n",
__func__, flag);
dev_dbg(cfg->dev, "%s(): <-- SET SMART CONN FILTER(%u) len(%u)\n",
__func__, flag, req.cmd.len);
ret = cfg->hif_ops->write(cfg->txq_hdl, (const u32*)&req,
MT7697_QUEUE_LEN_TO_WORD(req.cmd.len));
if (ret != MT7697_QUEUE_LEN_TO_WORD(req.cmd.len)) {
dev_err(cfg->dev, "%s: write() failed(%d != %d)\n",
__func__, ret, MT7697_QUEUE_LEN_TO_WORD(req.cmd.len));
LEN_TO_WORD(req.cmd.len));
if (ret != LEN_TO_WORD(req.cmd.len)) {
dev_err(cfg->dev, "%s(): write() failed(%d != %d)\n",
__func__, ret, LEN_TO_WORD(req.cmd.len));
ret = (ret < 0) ? ret:-EIO;
goto cleanup;
}
......@@ -1464,7 +1606,7 @@ cleanup:
return ret;
}
int mt7697_send_get_listen_interval_req(struct mt7697_cfg80211_info* cfg)
int mt7697_wr_get_listen_interval_req(struct mt7697_cfg80211_info* cfg)
{
struct mt7697_get_listen_interval_req req;
int ret;
......@@ -1473,12 +1615,13 @@ int mt7697_send_get_listen_interval_req(struct mt7697_cfg80211_info* cfg)
req.grp = MT7697_CMD_GRP_80211;
req.type = MT7697_CMD_GET_LISTEN_INTERVAL_REQ;
dev_dbg(cfg->dev, "%s: <-- GET LISTEN INTERVAL\n", __func__);
dev_dbg(cfg->dev, "%s(): <-- GET LISTEN INTERVAL len(%u)\n",
__func__, req.len);
ret = cfg->hif_ops->write(cfg->txq_hdl, (const u32*)&req,
MT7697_QUEUE_LEN_TO_WORD(req.len));
if (ret != MT7697_QUEUE_LEN_TO_WORD(req.len)) {
dev_err(cfg->dev, "%s: write() failed(%d != %d)\n",
__func__, ret, MT7697_QUEUE_LEN_TO_WORD(req.len));
LEN_TO_WORD(req.len));
if (ret != LEN_TO_WORD(req.len)) {
dev_err(cfg->dev, "%s(): write() failed(%d != %d)\n",
__func__, ret, LEN_TO_WORD(req.len));
ret = (ret < 0) ? ret:-EIO;
goto cleanup;
}
......@@ -1489,7 +1632,7 @@ cleanup:
return ret;
}
int mt7697_send_set_listen_interval_req(struct mt7697_cfg80211_info* cfg,
int mt7697_wr_set_listen_interval_req(struct mt7697_cfg80211_info* cfg,
u32 interval)
{
struct mt7697_set_listen_interval_req req;
......@@ -1500,13 +1643,13 @@ int mt7697_send_set_listen_interval_req(struct mt7697_cfg80211_info* cfg,
req.cmd.type = MT7697_CMD_SET_LISTEN_INTERVAL_REQ;
req.interval = interval;
dev_dbg(cfg->dev, "%s: <-- SET LISTEN INTERVAL(%u)\n",
__func__, interval);
dev_dbg(cfg->dev, "%s(): <-- SET LISTEN INTERVAL(%u) len(%u)\n",
__func__, interval, req.cmd.len);
ret = cfg->hif_ops->write(cfg->txq_hdl, (const u32*)&req,
MT7697_QUEUE_LEN_TO_WORD(req.cmd.len));
if (ret != MT7697_QUEUE_LEN_TO_WORD(req.cmd.len)) {
dev_err(cfg->dev, "%s: write() failed(%d != %d)\n",
__func__, ret, MT7697_QUEUE_LEN_TO_WORD(req.cmd.len));
LEN_TO_WORD(req.cmd.len));
if (ret != LEN_TO_WORD(req.cmd.len)) {
dev_err(cfg->dev, "%s(): write() failed(%d != %d)\n",
__func__, ret, LEN_TO_WORD(req.cmd.len));
ret = (ret < 0) ? ret:-EIO;
goto cleanup;
}
......@@ -1517,7 +1660,7 @@ cleanup:
return ret;
}
int mt7697_send_set_security_mode_req(struct mt7697_cfg80211_info* cfg,
int mt7697_wr_set_security_mode_req(struct mt7697_cfg80211_info* cfg,
u8 port, u8 auth_mode, u8 encrypt_type)
{
struct mt7697_set_security_mode_req req;
......@@ -1530,13 +1673,14 @@ int mt7697_send_set_security_mode_req(struct mt7697_cfg80211_info* cfg,
req.auth_mode = auth_mode;
req.encrypt_type = encrypt_type;
dev_dbg(cfg->dev, "%s: <-- SET SECURITY MODE auth/encrypt(%u/%u)\n",
__func__, auth_mode, encrypt_type);
dev_dbg(cfg->dev,
"%s(): <-- SET SECURITY MODE auth/encrypt(%u/%u) len(%u)\n",
__func__, auth_mode, encrypt_type, req.cmd.len);
ret = cfg->hif_ops->write(cfg->txq_hdl, (const u32*)&req,
MT7697_QUEUE_LEN_TO_WORD(req.cmd.len));
if (ret != MT7697_QUEUE_LEN_TO_WORD(req.cmd.len)) {
dev_err(cfg->dev, "%s: write() failed(%d != %d)\n",
__func__, ret, MT7697_QUEUE_LEN_TO_WORD(req.cmd.len));
LEN_TO_WORD(req.cmd.len));
if (ret != LEN_TO_WORD(req.cmd.len)) {
dev_err(cfg->dev, "%s(): write() failed(%d != %d)\n",
__func__, ret, LEN_TO_WORD(req.cmd.len));
ret = (ret < 0) ? ret:-EIO;
goto cleanup;
}
......@@ -1547,7 +1691,7 @@ cleanup:
return ret;
}
int mt7697_send_get_security_mode_req(struct mt7697_cfg80211_info* cfg,
int mt7697_wr_get_security_mode_req(struct mt7697_cfg80211_info* cfg,
u32 if_idx, u8 port)
{
struct mt7697_get_security_mode_req req;
......@@ -1559,12 +1703,13 @@ int mt7697_send_get_security_mode_req(struct mt7697_cfg80211_info* cfg,
req.if_idx = if_idx;
req.port = port;
dev_dbg(cfg->dev, "%s: <-- GET SECURITY MODE\n", __func__);
dev_dbg(cfg->dev, "%s(): <-- GET SECURITY MODE len(%u)\n",
__func__, req.cmd.len);
ret = cfg->hif_ops->write(cfg->txq_hdl, (const u32*)&req,
MT7697_QUEUE_LEN_TO_WORD(req.cmd.len));
if (ret != MT7697_QUEUE_LEN_TO_WORD(req.cmd.len)) {
dev_err(cfg->dev, "%s: write() failed(%d != %d)\n",
__func__, ret, MT7697_QUEUE_LEN_TO_WORD(req.cmd.len));
LEN_TO_WORD(req.cmd.len));
if (ret != LEN_TO_WORD(req.cmd.len)) {
dev_err(cfg->dev, "%s(): write() failed(%d != %d)\n",
__func__, ret, LEN_TO_WORD(req.cmd.len));
ret = (ret < 0) ? ret:-EIO;
goto cleanup;
}
......@@ -1575,13 +1720,12 @@ cleanup:
return ret;
}
int mt7697_send_scan_req(struct mt7697_cfg80211_info *cfg, u32 if_idx,
int mt7697_wr_scan_req(struct mt7697_cfg80211_info *cfg, u32 if_idx,
const struct cfg80211_scan_request *req)
{
struct mt7697_scan_req scan_req;
int ret;
dev_dbg(cfg->dev, "%s: <-- START SCAN\n", __func__);
memset(&scan_req, 0, sizeof(scan_req));
scan_req.cmd.len = sizeof(struct mt7697_scan_req);
scan_req.cmd.grp = MT7697_CMD_GRP_80211;
......@@ -1590,10 +1734,10 @@ int mt7697_send_scan_req(struct mt7697_cfg80211_info *cfg, u32 if_idx,
scan_req.mode = MT7697_WIFI_SCAN_MODE_FULL;
scan_req.option = MT7697_WIFI_SCAN_OPTION_FORCE_ACTIVE;
dev_dbg(cfg->dev, "%s: # ssids(%d)\n", __func__, req->n_ssids);
dev_dbg(cfg->dev, "%s(): # ssids(%d)\n", __func__, req->n_ssids);
WARN_ON(req->n_ssids > 1);
if (req->n_ssids) {
dev_dbg(cfg->dev, "%s: ssid len(%d)\n",
dev_dbg(cfg->dev, "%s(): ssid len(%d)\n",
__func__, req->ssids[0].ssid_len);
scan_req.ssid_len = req->ssids[0].ssid_len;
print_hex_dump(KERN_DEBUG, DRVNAME" SSID ",
......@@ -1603,11 +1747,13 @@ int mt7697_send_scan_req(struct mt7697_cfg80211_info *cfg, u32 if_idx,
req->ssids[0].ssid_len);
}
dev_dbg(cfg->dev, "%s(): <-- START SCAN len(%u)\n",
__func__, scan_req.cmd.len);
ret = cfg->hif_ops->write(cfg->txq_hdl, (const u32*)&scan_req,
MT7697_QUEUE_LEN_TO_WORD(scan_req.cmd.len));
if (ret != MT7697_QUEUE_LEN_TO_WORD(scan_req.cmd.len)) {
dev_err(cfg->dev, "%s: write() failed(%d != %d)\n",
__func__, ret, MT7697_QUEUE_LEN_TO_WORD(scan_req.cmd.len));
LEN_TO_WORD(scan_req.cmd.len));
if (ret != LEN_TO_WORD(scan_req.cmd.len)) {
dev_err(cfg->dev, "%s(): write() failed(%d != %d)\n",
__func__, ret, LEN_TO_WORD(scan_req.cmd.len));
ret = (ret < 0) ? ret:-EIO;
goto cleanup;
}
......@@ -1618,7 +1764,7 @@ cleanup:
return ret;
}
int mt7697_send_scan_stop_req(struct mt7697_cfg80211_info* cfg)
int mt7697_wr_scan_stop_req(struct mt7697_cfg80211_info* cfg)
{
struct mt7697_scan_stop req;
int ret;
......@@ -1627,12 +1773,12 @@ int mt7697_send_scan_stop_req(struct mt7697_cfg80211_info* cfg)
req.grp = MT7697_CMD_GRP_80211;
req.type = MT7697_CMD_SCAN_STOP;
dev_dbg(cfg->dev, "%s: <-- STOP SCAN\n", __func__);
dev_dbg(cfg->dev, "%s(): <-- STOP SCAN len(%u)\n", __func__, req.len);
ret = cfg->hif_ops->write(cfg->txq_hdl, (const u32*)&req,
MT7697_QUEUE_LEN_TO_WORD(req.len));
if (ret != MT7697_QUEUE_LEN_TO_WORD(req.len)) {
dev_err(cfg->dev, "%s: write() failed(%d != %d)\n",
__func__, ret, MT7697_QUEUE_LEN_TO_WORD(req.len));
LEN_TO_WORD(req.len));
if (ret != LEN_TO_WORD(req.len)) {
dev_err(cfg->dev, "%s(): write() failed(%d != %d)\n",
__func__, ret, LEN_TO_WORD(req.len));
ret = (ret < 0) ? ret:-EIO;
goto cleanup;
}
......@@ -1643,7 +1789,7 @@ cleanup:
return ret;
}
int mt7697_send_connect_req(struct mt7697_cfg80211_info *cfg,
int mt7697_wr_connect_req(struct mt7697_cfg80211_info *cfg,
u8 port, u32 if_idx, const u8* bssid,
const u8* ssid, u32 ssid_len,
u32 channel)
......@@ -1659,17 +1805,18 @@ int mt7697_send_connect_req(struct mt7697_cfg80211_info *cfg,
req.cmd.type = MT7697_CMD_CONNECT_REQ;
req.if_idx = if_idx;
req.port = port;
req.channel = channel ? ieee80211_frequency_to_channel(channel):channel;
req.channel = channel ?
ieee80211_frequency_to_channel(channel) : channel;
memcpy(req.bssid, bssid, ETH_ALEN);
req.ssid_len = ssid_len;
memcpy(req.ssid, ssid, ssid_len);
dev_dbg(cfg->dev, "%s: <-- CONNECT(%u)\n", __func__, req.cmd.len);
dev_dbg(cfg->dev, "%s(): <-- CONNECT len(%u)\n", __func__, req.cmd.len);
ret = cfg->hif_ops->write(cfg->txq_hdl, (const u32*)&req,
MT7697_QUEUE_LEN_TO_WORD(req.cmd.len));
if (ret != MT7697_QUEUE_LEN_TO_WORD(req.cmd.len)) {
dev_err(cfg->dev, "%s: write() failed(%d != %d)\n",
__func__, ret, MT7697_QUEUE_LEN_TO_WORD(req.cmd.len));
LEN_TO_WORD(req.cmd.len));
if (ret != LEN_TO_WORD(req.cmd.len)) {
dev_err(cfg->dev, "%s(): write() failed(%d != %d)\n",
__func__, ret, LEN_TO_WORD(req.cmd.len));
ret = (ret < 0) ? ret:-EIO;
goto cleanup;
}
......@@ -1680,7 +1827,7 @@ cleanup:
return ret;
}
int mt7697_send_disconnect_req(struct mt7697_cfg80211_info *cfg, u32 if_idx,
int mt7697_wr_disconnect_req(struct mt7697_cfg80211_info *cfg, u32 if_idx,
const u8 *addr)
{
struct mt7697_disconnect_req req;
......@@ -1699,12 +1846,13 @@ int mt7697_send_disconnect_req(struct mt7697_cfg80211_info *cfg, u32 if_idx,
else
req.port = MT7697_PORT_STA;
dev_dbg(cfg->dev, "%s: <-- DISCONNECT(%u)\n", __func__, req.cmd.len);
dev_dbg(cfg->dev, "%s(): <-- DISCONNECT len(%u)\n",
__func__, req.cmd.len);
ret = cfg->hif_ops->write(cfg->txq_hdl, (const u32*)&req,
MT7697_QUEUE_LEN_TO_WORD(req.cmd.len));
if (ret != MT7697_QUEUE_LEN_TO_WORD(req.cmd.len)) {
dev_err(cfg->dev, "%s: write() failed(%d != %d)\n",
__func__, ret, MT7697_QUEUE_LEN_TO_WORD(req.cmd.len));
LEN_TO_WORD(req.cmd.len));
if (ret != LEN_TO_WORD(req.cmd.len)) {
dev_err(cfg->dev, "%s(): write() failed(%d != %d)\n",
__func__, ret, LEN_TO_WORD(req.cmd.len));
ret = (ret < 0) ? ret:-EIO;
goto cleanup;
}
......@@ -1715,112 +1863,30 @@ cleanup:
return ret;
}
int mt7697_send_tx_raw_packet(struct mt7697_cfg80211_info* cfg,
int mt7697_wr_tx_raw_packet(struct mt7697_cfg80211_info* cfg,
const u8* data, u32 len)
{
int ret;
cfg->tx_req.cmd.len = sizeof(struct mt7697_cmd_hdr) + sizeof(len) + len;
cfg->tx_req.cmd.len = sizeof(struct mt7697q_cmd_hdr) + sizeof(len) + len;
cfg->tx_req.len = len;
WARN_ON(len > sizeof(cfg->tx_req.data));
memcpy(cfg->tx_req.data, data, len);
dev_dbg(cfg->dev, "%s: <-- TX RAW PKT(%u)\n", __func__, cfg->tx_req.len);
dev_dbg(cfg->dev, "%s(): <-- TX RAW PKT len(%u)\n",
__func__, cfg->tx_req.len);
ret = cfg->hif_ops->write(cfg->txq_hdl, (const u32*)&cfg->tx_req,
MT7697_QUEUE_LEN_TO_WORD(cfg->tx_req.cmd.len));
if (ret != MT7697_QUEUE_LEN_TO_WORD(cfg->tx_req.cmd.len)) {
dev_err(cfg->dev, "%s: write() failed(%d != %d)\n",
LEN_TO_WORD(LEN32_ALIGNED(cfg->tx_req.cmd.len)));
if (ret != LEN_TO_WORD(LEN32_ALIGNED(cfg->tx_req.cmd.len))) {
dev_err(cfg->dev, "%s(): write() failed(%d != %d)\n",
__func__, ret,
MT7697_QUEUE_LEN_TO_WORD(cfg->tx_req.cmd.len));
LEN_TO_WORD(LEN32_ALIGNED(cfg->tx_req.cmd.len)));
ret = (ret < 0) ? ret:-EIO;
goto cleanup;
}
cleanup:
return ret;
}
int mt7697_proc_data(void *priv)
{
struct mt7697_cfg80211_info *cfg = (struct mt7697_cfg80211_info *)priv;
size_t avail;
int ret;
ret = cfg->hif_ops->pull_wr_ptr(cfg->rxq_hdl);
if (ret < 0) {
dev_err(cfg->dev, "%s: pull_wr_ptr() failed(%d)\n",
__func__, ret);
goto cleanup;
}
/* TODO: Do not starve Tx here */
avail = cfg->hif_ops->num_rd(cfg->rxq_hdl);
while (avail > MT7697_QUEUE_LEN_TO_WORD(sizeof(struct mt7697_rsp_hdr))) {
if (!cfg->rsp.cmd.len) {
if (avail < MT7697_QUEUE_LEN_TO_WORD(sizeof(struct mt7697_rsp_hdr))) {
dev_dbg(cfg->dev,
"%s: queue need more data\n", __func__);
goto cleanup;
}
ret = cfg->hif_ops->read(cfg->rxq_hdl, (u32*)&cfg->rsp,
MT7697_QUEUE_LEN_TO_WORD(sizeof(struct mt7697_rsp_hdr)));
if (ret != MT7697_QUEUE_LEN_TO_WORD(sizeof(struct mt7697_rsp_hdr))) {
dev_err(cfg->dev, "%s: read() failed(%d != %d)\n",
__func__, ret,
MT7697_QUEUE_LEN_TO_WORD(sizeof(struct mt7697_rsp_hdr)));
goto cleanup;
}
if (cfg->rsp.result && (cfg->rsp.cmd.type != MT7697_CMD_RX_RAW)) {
dev_warn(cfg->dev, "%s: result(%d)\n",
__func__, cfg->rsp.result);
}
ret = cfg->hif_ops->pull_wr_ptr(cfg->rxq_hdl);
if (ret < 0) {
dev_err(cfg->dev, "%s: pull_wr_ptr() failed(%d)\n",
__func__, ret);
goto cleanup;
}
avail = cfg->hif_ops->num_rd(cfg->rxq_hdl);
}
if (avail < MT7697_QUEUE_LEN_TO_WORD(cfg->rsp.cmd.len -
sizeof(struct mt7697_rsp_hdr))) {
dev_dbg(cfg->dev, "%s: queue need more data\n", __func__);
goto cleanup;
}
if (cfg->rsp.cmd.grp == MT7697_CMD_GRP_80211) {
ret = mt7697_proc_80211cmd(cfg);
if (ret < 0) {
dev_err(cfg->dev,
"%s: mt7697_proc_80211cmd() failed(%d)\n",
__func__, ret);
}
}
else {
dev_err(cfg->dev, "%s: invalid grp(%d)\n",
__func__, cfg->rsp.cmd.grp);
ret = -EINVAL;
goto cleanup;
}
cfg->rsp.cmd.len = 0;
ret = cfg->hif_ops->pull_wr_ptr(cfg->rxq_hdl);
if (ret < 0) {
dev_err(cfg->dev, "%s: pull_wr_ptr() failed(%d)\n",
__func__, ret);
goto cleanup;
}
avail = cfg->hif_ops->num_rd(cfg->rxq_hdl);
}
ret = 0;
cleanup:
if (ret < 0) cfg->rsp.cmd.len = 0;
return ret;
}
......@@ -20,36 +20,34 @@
#include <linux/ieee80211.h>
#include <linux/if_ether.h>
#include "queue_i.h"
#include "wifi_api.h"
#define MT7697_LEN32_ALIGNED(x) (((x) / sizeof(u32) + \
((x) % sizeof(u32) ? 1:0)) * sizeof(u32))
#define MT7697_WOW_MAX_FILTERS_PER_LIST 4
#define MT7697_WOW_PATTERN_SIZE 64
#define MT7697_PASSPHRASE_LEN 64
#define mt7697_cfg_req mt7697_cmd_hdr
#define mt7697_get_radio_state_req mt7697_cmd_hdr
#define mt7697_get_rx_filter_req mt7697_cmd_hdr
#define mt7697_get_listen_interval_req mt7697_cmd_hdr
#define mt7697_get_smart_conn_filter_req mt7697_cmd_hdr
#define mt7697_scan_stop mt7697_cmd_hdr
#define mt7697_register_rx_hndlr_req mt7697_cmd_hdr
#define mt7697_unregister_rx_hndlr_req mt7697_cmd_hdr
#define mt7697_set_wireless_mode_rsp mt7697_rsp_hdr
#define mt7697_set_radio_state_rsp mt7697_rsp_hdr
#define mt7697_set_op_mode_rsp mt7697_rsp_hdr
#define mt7697_set_rx_filter_rsp mt7697_rsp_hdr
#define mt7697_set_smart_conn_filter_rsp mt7697_rsp_hdr
#define mt7697_set_listen_interval_rsp mt7697_rsp_hdr
#define mt7697_set_psk_rsp mt7697_rsp_hdr
#define mt7697_set_security_mode_rsp mt7697_rsp_hdr
#define mt7697_scan_stop_rsp mt7697_rsp_hdr
#define mt7697_register_rx_hndlr_rsp mt7697_rsp_hdr
#define mt7697_unregister_rx_hndlr_rsp mt7697_rsp_hdr
#define mt7697_cfg_req mt7697q_cmd_hdr
#define mt7697_get_radio_state_req mt7697q_cmd_hdr
#define mt7697_get_rx_filter_req mt7697q_cmd_hdr
#define mt7697_get_listen_interval_req mt7697q_cmd_hdr
#define mt7697_get_smart_conn_filter_req mt7697q_cmd_hdr
#define mt7697_scan_stop mt7697q_cmd_hdr
#define mt7697_register_rx_hndlr_req mt7697q_cmd_hdr
#define mt7697_unregister_rx_hndlr_req mt7697q_cmd_hdr
#define mt7697_set_wireless_mode_rsp mt7697q_rsp_hdr
#define mt7697_set_radio_state_rsp mt7697q_rsp_hdr
#define mt7697_set_op_mode_rsp mt7697q_rsp_hdr
#define mt7697_set_rx_filter_rsp mt7697q_rsp_hdr
#define mt7697_set_smart_conn_filter_rsp mt7697q_rsp_hdr
#define mt7697_set_listen_interval_rsp mt7697q_rsp_hdr
#define mt7697_set_psk_rsp mt7697q_rsp_hdr
#define mt7697_set_security_mode_rsp mt7697q_rsp_hdr
#define mt7697_scan_stop_rsp mt7697q_rsp_hdr
#define mt7697_register_rx_hndlr_rsp mt7697q_rsp_hdr
#define mt7697_unregister_rx_hndlr_rsp mt7697q_rsp_hdr
#define mt7697_disconnect_rsp mt7697q_rsp_hdr
enum mt7697_connect_ctrl_flags_bits {
MT7697_CONNECT_ASSOC_POLICY_USER = 0x0001,
......@@ -63,17 +61,6 @@ enum mt7697_connect_ctrl_flags_bits {
MT7697_CONNECT_WPS_FLAG = 0x0100,
};
enum mt7697_cmd_grp {
MT7697_CMD_GRP_QUEUE = 0,
MT7697_CMD_GRP_80211,
MT7697_CMD_GRP_BT,
};
enum mt7697_queue_cmd_types {
MT7697_CMD_INIT = 0,
MT7697_CMD_RESET,
};
enum mt7697_wifi_cmd_types {
MT7697_CMD_MAC_ADDR_REQ = 0,
MT7697_CMD_MAC_ADDR_RSP,
......@@ -109,17 +96,20 @@ enum mt7697_wifi_cmd_types {
MT7697_CMD_REGISTER_RX_HNDLR_RSP,
MT7697_CMD_UNREGISTER_RX_HNDLR_REQ,
MT7697_CMD_UNREGISTER_RX_HNDLR_RSP,
MT7697_CMD_SCAN_IND,
MT7697_CMD_SCAN_REQ,
MT7697_CMD_SCAN_RSP,
MT7697_CMD_SCAN_COMPLETE,
MT7697_CMD_SCAN_COMPLETE_IND,
MT7697_CMD_SCAN_STOP,
MT7697_CMD_SCAN_STOP_RSP,
MT7697_CMD_GET_PSK_REQ,
MT7697_CMD_GET_PSK_RSP,
MT7697_CMD_SET_PSK_REQ,
MT7697_CMD_SET_PSK_RSP,
MT7697_CMD_CONNECT_IND,
MT7697_CMD_CONNECT_REQ,
MT7697_CMD_CONNECT_RSP,
MT7697_CMD_DISCONNECT_IND,
MT7697_CMD_DISCONNECT_REQ,
MT7697_CMD_DISCONNECT_RSP,
MT7697_CMD_TX_RAW,
......@@ -129,225 +119,224 @@ enum mt7697_wifi_cmd_types {
struct mt7697_cfg80211_info;
struct cfg80211_scan_request;
struct mt7697_cmd_hdr {
__be16 len;
u8 grp;
u8 type;
} __attribute__((__packed__, aligned(4)));
struct mt7697_rsp_hdr {
struct mt7697_cmd_hdr cmd;
__be32 result;
} __attribute__((__packed__, aligned(4)));
struct mt7697_mac_addr_req {
struct mt7697_cmd_hdr cmd;
struct mt7697q_cmd_hdr cmd;
__be32 port;
} __attribute__((packed, aligned(4)));
struct mt7697_mac_addr_rsp {
struct mt7697_rsp_hdr rsp;
u8 addr[MT7697_LEN32_ALIGNED(ETH_ALEN)];
struct mt7697q_rsp_hdr rsp;
u8 addr[LEN32_ALIGNED(ETH_ALEN)];
} __attribute__((packed, aligned(4)));
struct mt7697_get_wireless_mode_req {
struct mt7697_cmd_hdr cmd;
struct mt7697q_cmd_hdr cmd;
__be32 port;
} __attribute__((packed, aligned(4)));
struct mt7697_get_wireless_mode_rsp {
struct mt7697_rsp_hdr rsp;
struct mt7697q_rsp_hdr rsp;
__be32 mode;
} __attribute__((packed, aligned(4)));
struct mt7697_set_wireless_mode_req {
struct mt7697_cmd_hdr cmd;
struct mt7697q_cmd_hdr cmd;
__be32 port;
__be32 mode;
} __attribute__((packed, aligned(4)));
struct mt7697_cfg_rsp {
struct mt7697_rsp_hdr rsp;
struct mt7697q_rsp_hdr rsp;
struct mt7697_wifi_config_t cfg;
} __attribute__((packed, aligned(4)));
struct mt7697_set_op_mode_req {
struct mt7697_cmd_hdr cmd;
struct mt7697q_cmd_hdr cmd;
__be32 opmode;
} __attribute__((packed, aligned(4)));
struct mt7697_get_radio_state_rsp {
struct mt7697_rsp_hdr rsp;
struct mt7697q_rsp_hdr rsp;
__be32 state;
} __attribute__((packed, aligned(4)));
struct mt7697_set_radio_state_req {
struct mt7697_cmd_hdr cmd;
struct mt7697q_cmd_hdr cmd;
__be32 state;
} __attribute__((packed, aligned(4)));
struct mt7697_get_rx_filter_rsp {
struct mt7697_rsp_hdr rsp;
struct mt7697q_rsp_hdr rsp;
__be32 rx_filter;
} __attribute__((packed, aligned(4)));
struct mt7697_set_rx_filter_req {
struct mt7697_cmd_hdr cmd;
struct mt7697q_cmd_hdr cmd;
__be32 rx_filter;
} __attribute__((packed, aligned(4)));
struct mt7697_get_smart_conn_filter_rsp {
struct mt7697_rsp_hdr rsp;
struct mt7697q_rsp_hdr rsp;
__be32 flag;
} __attribute__((packed, aligned(4)));
struct mt7697_set_smart_conn_filter_req {
struct mt7697_cmd_hdr cmd;
struct mt7697q_cmd_hdr cmd;
__be32 flag;
} __attribute__((packed, aligned(4)));
struct mt7697_get_listen_interval_rsp {
struct mt7697_rsp_hdr rsp;
struct mt7697q_rsp_hdr rsp;
__be32 interval;
} __attribute__((packed, aligned(4)));
struct mt7697_set_listen_interval_req {
struct mt7697_cmd_hdr cmd;
struct mt7697q_cmd_hdr cmd;
__be32 interval;
} __attribute__((packed, aligned(4)));
struct mt7697_scan_req {
struct mt7697_cmd_hdr cmd;
struct mt7697q_cmd_hdr cmd;
__be32 if_idx;
__be32 mode;
__be32 option;
__be32 bssid_len;
u8 bssid[MT7697_LEN32_ALIGNED(ETH_ALEN)];
u8 bssid[LEN32_ALIGNED(ETH_ALEN)];
__be32 ssid_len;
u8 ssid[MT7697_LEN32_ALIGNED(IEEE80211_MAX_SSID_LEN)];
u8 ssid[LEN32_ALIGNED(IEEE80211_MAX_SSID_LEN)];
} __attribute__((packed, aligned(4)));
struct mt7697_scan_rsp {
struct mt7697_rsp_hdr rsp;
struct mt7697q_rsp_hdr rsp;
__be32 if_idx;
} __attribute__((packed, aligned(4)));
struct mt7697_scan_ind {
struct mt7697q_rsp_hdr rsp;
__be32 rssi;
__be32 channel;
__be32 probe_rsp_len;
u8 probe_rsp[];
} __attribute__((packed, aligned(4)));
struct mt7697_scan_complete_rsp {
struct mt7697_rsp_hdr rsp;
struct mt7697_scan_complete_ind {
struct mt7697q_rsp_hdr rsp;
__be32 if_idx;
} __attribute__((packed, aligned(4)));
struct mt7697_get_psk_req {
struct mt7697_cmd_hdr cmd;
struct mt7697q_cmd_hdr cmd;
__be32 port;
} __attribute__((packed, aligned(4)));
struct mt7697_get_psk_rsp {
struct mt7697_rsp_hdr rsp;
struct mt7697q_rsp_hdr rsp;
__be32 len;
u8 psk[MT7697_LEN32_ALIGNED(MT7697_PASSPHRASE_LEN)];
u8 psk[LEN32_ALIGNED(MT7697_PASSPHRASE_LEN)];
} __attribute__((packed, aligned(4)));
struct mt7697_set_psk_req {
struct mt7697_cmd_hdr cmd;
struct mt7697q_cmd_hdr cmd;
__be32 port;
__be32 len;
u8 psk[MT7697_LEN32_ALIGNED(MT7697_PASSPHRASE_LEN)];
u8 psk[LEN32_ALIGNED(MT7697_PASSPHRASE_LEN)];
} __attribute__((packed, aligned(4)));
struct mt7697_set_security_mode_req {
struct mt7697_cmd_hdr cmd;
struct mt7697q_cmd_hdr cmd;
__be32 port;
__be32 auth_mode;
__be32 encrypt_type;
} __attribute__((packed, aligned(4)));
struct mt7697_get_security_mode_req {
struct mt7697_cmd_hdr cmd;
struct mt7697q_cmd_hdr cmd;
__be32 if_idx;
__be32 port;
} __attribute__((packed, aligned(4)));
struct mt7697_get_security_mode_rsp {
struct mt7697_rsp_hdr rsp;
struct mt7697q_rsp_hdr rsp;
__be32 if_idx;
__be32 auth_mode;
__be32 encrypt_type;
} __attribute__((packed, aligned(4)));
struct mt7697_connect_req {
struct mt7697_cmd_hdr cmd;
struct mt7697q_cmd_hdr cmd;
__be32 if_idx;
__be32 port;
__be32 channel;
u8 bssid[MT7697_LEN32_ALIGNED(ETH_ALEN)];
u8 bssid[LEN32_ALIGNED(ETH_ALEN)];
__be32 ssid_len;
u8 ssid[MT7697_LEN32_ALIGNED(IEEE80211_MAX_SSID_LEN)];
u8 ssid[LEN32_ALIGNED(IEEE80211_MAX_SSID_LEN)];
} __attribute__((packed, aligned(4)));
struct mt7697_connect_rsp {
struct mt7697_rsp_hdr rsp;
struct mt7697_connect_ind {
struct mt7697q_rsp_hdr rsp;
__be32 if_idx;
__be32 channel;
u8 bssid[MT7697_LEN32_ALIGNED(ETH_ALEN)];
u8 bssid[LEN32_ALIGNED(ETH_ALEN)];
} __attribute__((packed, aligned(4)));
struct mt7697_connect_rsp {
struct mt7697q_rsp_hdr rsp;
__be32 if_idx;
u8 bssid[LEN32_ALIGNED(ETH_ALEN)];
} __attribute__((packed, aligned(4)));
struct mt7697_disconnect_req {
struct mt7697_cmd_hdr cmd;
struct mt7697q_cmd_hdr cmd;
__be32 if_idx;
__be32 port;
u8 addr[MT7697_LEN32_ALIGNED(ETH_ALEN)];
u8 addr[LEN32_ALIGNED(ETH_ALEN)];
} __attribute__((packed, aligned(4)));
struct mt7697_disconnect_rsp {
struct mt7697_rsp_hdr rsp;
struct mt7697_disconnect_ind {
struct mt7697q_rsp_hdr rsp;
__be32 if_idx;
u8 bssid[MT7697_LEN32_ALIGNED(ETH_ALEN)];
u8 bssid[LEN32_ALIGNED(ETH_ALEN)];
} __attribute__((packed, aligned(4)));
struct mt7697_tx_raw_packet {
struct mt7697_cmd_hdr cmd;
struct mt7697q_cmd_hdr cmd;
__be32 len;
u8 data[MT7697_LEN32_ALIGNED(IEEE80211_MAX_FRAME_LEN)];
u8 data[LEN32_ALIGNED(IEEE80211_MAX_FRAME_LEN)];
} __attribute__((packed, aligned(4)));
struct mt7697_rx_raw_packet {
struct mt7697_rsp_hdr hdr;
struct mt7697q_rsp_hdr hdr;
u8 data[];
} __attribute__((packed, aligned(4)));
int mt7697_send_init(struct mt7697_cfg80211_info*);
int mt7697_send_reset(struct mt7697_cfg80211_info*);
int mt7697_send_set_wireless_mode_req(struct mt7697_cfg80211_info*, u8, u8);
int mt7697_send_get_wireless_mode_req(struct mt7697_cfg80211_info*, u8);
int mt7697_send_get_psk_req(struct mt7697_cfg80211_info*, u8);
int mt7697_send_set_psk_req(struct mt7697_cfg80211_info*, u8, const u8[]);
int mt7697_send_mac_addr_req(struct mt7697_cfg80211_info*, u8);
int mt7697_send_cfg_req(struct mt7697_cfg80211_info*);
int mt7697_send_register_rx_hndlr_req(struct mt7697_cfg80211_info*);
int mt7697_send_unregister_rx_hndlr_req(struct mt7697_cfg80211_info*);
int mt7697_send_set_op_mode_req(struct mt7697_cfg80211_info*, u8);
int mt7697_send_get_radio_state_req(struct mt7697_cfg80211_info*);
int mt7697_send_set_radio_state_req(struct mt7697_cfg80211_info*, u8);
int mt7697_send_get_rx_filter_req(struct mt7697_cfg80211_info*);
int mt7697_send_set_rx_filter_req(struct mt7697_cfg80211_info*, u32);
int mt7697_send_get_smart_conn_filter_req(struct mt7697_cfg80211_info*);
int mt7697_send_set_smart_conn_filter_req(struct mt7697_cfg80211_info*, u8);
int mt7697_send_get_listen_interval_req(struct mt7697_cfg80211_info*);
int mt7697_send_set_listen_interval_req(struct mt7697_cfg80211_info*, u32);
int mt7697_send_scan_req(struct mt7697_cfg80211_info*, u32,
int mt7697_wr_init(struct mt7697_cfg80211_info*);
int mt7697_wr_reset(struct mt7697_cfg80211_info*);
int mt7697_wr_set_wireless_mode_req(struct mt7697_cfg80211_info*, u8, u8);
int mt7697_wr_get_wireless_mode_req(struct mt7697_cfg80211_info*, u8);
int mt7697_wr_get_psk_req(struct mt7697_cfg80211_info*, u8);
int mt7697_wr_set_psk_req(struct mt7697_cfg80211_info*, u8, const u8[]);
int mt7697_wr_mac_addr_req(struct mt7697_cfg80211_info*, u8);
int mt7697_wr_cfg_req(struct mt7697_cfg80211_info*);
int mt7697_wr_reg_rx_hndlr_req(struct mt7697_cfg80211_info*);
int mt7697_wr_unreg_rx_hndlr_req(struct mt7697_cfg80211_info*);
int mt7697_wr_set_op_mode_req(struct mt7697_cfg80211_info*, u8);
int mt7697_wr_get_radio_state_req(struct mt7697_cfg80211_info*);
int mt7697_wr_set_radio_state_req(struct mt7697_cfg80211_info*, u8);
int mt7697_wr_get_rx_filter_req(struct mt7697_cfg80211_info*);
int mt7697_wr_set_rx_filter_req(struct mt7697_cfg80211_info*, u32);
int mt7697_wr_get_smart_conn_filter_req(struct mt7697_cfg80211_info*);
int mt7697_wr_set_smart_conn_filter_req(struct mt7697_cfg80211_info*, u8);
int mt7697_wr_get_listen_interval_req(struct mt7697_cfg80211_info*);
int mt7697_wr_set_listen_interval_req(struct mt7697_cfg80211_info*, u32);
int mt7697_wr_scan_req(struct mt7697_cfg80211_info*, u32,
const struct cfg80211_scan_request*);
int mt7697_send_set_security_mode_req(struct mt7697_cfg80211_info*, u8, u8, u8);
int mt7697_send_get_security_mode_req(struct mt7697_cfg80211_info*, u32, u8);
int mt7697_send_scan_stop_req(struct mt7697_cfg80211_info*);
int mt7697_send_connect_req(struct mt7697_cfg80211_info*,
int mt7697_wr_set_security_mode_req(struct mt7697_cfg80211_info*, u8, u8, u8);
int mt7697_wr_get_security_mode_req(struct mt7697_cfg80211_info*, u32, u8);
int mt7697_wr_scan_stop_req(struct mt7697_cfg80211_info*);
int mt7697_wr_connect_req(struct mt7697_cfg80211_info*,
u8, u32, const u8*, const u8*, u32, u32);
int mt7697_send_disconnect_req(struct mt7697_cfg80211_info*, u32, const u8*);
int mt7697_send_tx_raw_packet(struct mt7697_cfg80211_info*, const u8*, u32);
int mt7697_wr_disconnect_req(struct mt7697_cfg80211_info*, u32, const u8*);
int mt7697_wr_tx_raw_packet(struct mt7697_cfg80211_info*, const u8*, u32);
int mt7697_proc_data(void*);
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment