BigW Consortium Gitlab

Commit 9297fb0f by David Frey Committed by David Clark

mt7697: indent kernel code with tabs

parent 831a8bec
......@@ -29,11 +29,11 @@ static int mt7697q_irq_run(struct mt7697q_info *qinfo)
u8 s2m_mbox;
ret = mt7697q_get_s2m_mbx(qinfo, &s2m_mbox);
if (ret < 0) {
if (ret < 0) {
dev_err(qinfo->dev,
"%s(): mt7697q_get_s2m_mbx() failed(%d)\n",
__func__, ret);
goto cleanup;
goto cleanup;
}
if (s2m_mbox) {
......@@ -43,7 +43,7 @@ static int mt7697q_irq_run(struct mt7697q_info *qinfo)
"%s(): queue_delayed_work() failed\n",
__func__);
ret = -EINVAL;
}
}
} else {
enable_irq(qinfo->irq);
}
......@@ -61,8 +61,8 @@ static int mt7697q_irq_run(struct mt7697q_info *qinfo)
dev_err(qinfo->dev,
"%s(): mt7697q_proc_data() failed(%d)\n",
__func__, ret);
goto cleanup;
}
goto cleanup;
}
} else if (mt7697q_blocked_writer(qs)) {
WARN_ON(!qs->notify_tx_fcn);
ret = qs->notify_tx_fcn(qs->priv,
......@@ -71,7 +71,7 @@ static int mt7697q_irq_run(struct mt7697q_info *qinfo)
dev_err(qs->qinfo->dev,
"%s(): notify_tx_fcn() failed(%d)\n",
__func__, ret);
}
}
}
}
}
......@@ -91,7 +91,7 @@ void mt7697q_irq_delayed_work(struct work_struct *irq_delayed_work)
if (ret < 0) {
dev_err(qinfo->dev, "%s(): mt7697q_irq_run() failed(%d)\n",
__func__, ret);
goto cleanup;
goto cleanup;
}
cleanup:
......@@ -110,7 +110,7 @@ void mt7697q_irq_work(struct work_struct *irq_work)
dev_err(qinfo->dev,
"%s(): mt7697q_irq_run() failed(%d)\n",
__func__, ret);
goto cleanup;
goto cleanup;
}
cleanup:
......@@ -124,7 +124,7 @@ irqreturn_t mt7697q_isr(int irq, void *arg)
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;
}
......@@ -38,41 +38,41 @@ static int mt7697io_write16(struct mt7697q_info *qinfo, u8 reg, u16 value)
value & 0xFF,
};
WARN_ON(reg % sizeof(u16));
WARN_ON(reg % sizeof(u16));
ret = qinfo->hw_ops->write(qinfo->hw_priv, txBuffer, sizeof(txBuffer));
if (ret < 0) {
dev_err(qinfo->dev, "%s(): write() failed(%d)\n",
__func__, ret);
goto cleanup;
}
goto cleanup;
}
cleanup:
return ret;
return ret;
}
static int mt7697io_write32(struct mt7697q_info *qinfo, u8 reg, u32 value)
{
int ret;
WARN_ON(reg % sizeof(u32));
WARN_ON(reg % sizeof(u32));
ret = mt7697io_write16(qinfo, reg, BF_GET(value, 0, 16));
if (ret < 0)
goto fail;
ret = mt7697io_write16(qinfo, reg + 2, BF_GET(value, 16, 16));
if (ret < 0)
goto fail;
goto fail;
ret = mt7697io_write16(qinfo, reg + 2, BF_GET(value, 16, 16));
if (ret < 0)
goto fail;
return ret;
fail:
dev_err(qinfo->dev, "%s(): mt7697io_write16() failed(%d)\n", __func__,
ret);
return ret;
return ret;
}
static int mt7697io_read16(struct mt7697q_info *qinfo, u8 reg, u16 *value)
{
int ret;
int ret;
u8 spi_buffer[4] = {
MT7697_IO_CMD_READ,
reg,
......@@ -84,13 +84,13 @@ static int mt7697io_read16(struct mt7697q_info *qinfo, u8 reg, u16 *value)
if (ret < 0) {
dev_err(qinfo->dev, "%s(): write_then_read() failed(%d)\n",
__func__, ret);
goto cleanup;
}
goto cleanup;
}
*value = ((spi_buffer[2] << 8) | spi_buffer[3]);
cleanup:
return ret;
return ret;
}
static int mt7697io_read32(struct mt7697q_info *qinfo, u8 reg, u32 *value)
......@@ -100,13 +100,13 @@ static int mt7697io_read32(struct mt7697q_info *qinfo, u8 reg, u32 *value)
u16 high;
WARN_ON(reg % sizeof(u32));
ret = mt7697io_read16(qinfo, reg, &low);
if (ret < 0)
goto fail;
ret = mt7697io_read16(qinfo, reg + sizeof(u16), &high);
ret = mt7697io_read16(qinfo, reg, &low);
if (ret < 0)
goto fail;
*value = (low | (high << 16));
goto fail;
ret = mt7697io_read16(qinfo, reg + sizeof(u16), &high);
if (ret < 0)
goto fail;
*value = (low | (high << 16));
return ret;
......@@ -119,19 +119,19 @@ fail:
static int mt7697io_chk_slave_busy(struct mt7697q_info *qinfo, bool *slave_busy)
{
int ret;
u16 value;
u16 value;
ret = mt7697io_read16(qinfo, MT7697_IO_SLAVE_REG_STATUS, &value);
if (ret < 0) {
dev_err(qinfo->dev, "%s(): mt7697io_read16() failed(%d)\n",
__func__, ret);
goto cleanup;
}
goto cleanup;
}
*slave_busy = mt7697io_busy(value);
cleanup:
return ret;
return ret;
}
static int mt7697io_slave_wait(struct mt7697q_info *qinfo)
......@@ -144,13 +144,13 @@ static int mt7697io_slave_wait(struct mt7697q_info *qinfo)
dev_err(qinfo->dev,
"%s(): mt7697io_chk_slave_busy() failed(%d)\n",
__func__, ret);
goto cleanup;
}
goto cleanup;
}
udelay(1);
} while (slave_busy);
cleanup:
return ret;
return ret;
}
static u8 mt7697io_get_s2m_mbox(u16 value)
......@@ -175,38 +175,38 @@ int mt7697io_wr_m2s_mbx(struct mt7697q_info *qinfo, u8 bits)
MT7697_IO_M2S_MAILBOX_REG_MAILBOX_WIDTH);
dev_dbg(qinfo->dev, "%s(): m2s mbx(0x%02x)\n", __func__, bits);
WARN_ON((GENMASK(MT7697_IO_M2S_MAILBOX_REG_MAILBOX_WIDTH, 0) & bits) !=
WARN_ON((GENMASK(MT7697_IO_M2S_MAILBOX_REG_MAILBOX_WIDTH, 0) & bits) !=
bits);
ret = mt7697io_write16(qinfo, MT7697_IO_SLAVE_REG_MAILBOX_M2S, value);
ret = mt7697io_write16(qinfo, MT7697_IO_SLAVE_REG_MAILBOX_M2S, value);
if (ret < 0) {
dev_err(qinfo->dev, "%s(): mt7697io_write16() failed(%d)\n",
__func__, ret);
goto cleanup;
}
goto cleanup;
}
cleanup:
return ret;
return ret;
}
int mt7697io_rd_s2m_mbx(struct mt7697q_info *qinfo, u8 *s2m_mbx)
{
int ret;
u16 value;
u16 value;
ret = mt7697io_read16(qinfo, MT7697_IO_SLAVE_REG_MAILBOX_S2M, &value);
if (ret < 0) {
ret = mt7697io_read16(qinfo, MT7697_IO_SLAVE_REG_MAILBOX_S2M, &value);
if (ret < 0) {
dev_err(qinfo->dev, "%s(): mt7697io_read16() failed(%d)\n",
__func__, ret);
goto cleanup;
}
goto cleanup;
}
*s2m_mbx = mt7697io_get_s2m_mbox(value);
dev_dbg(qinfo->dev, "%s(): s2m mbx(0x%02x)\n",
__func__, *s2m_mbx);
cleanup:
return ret;
return ret;
}
int mt7697io_clr_s2m_mbx(struct mt7697q_info *qinfo, u8 s2m_mbx)
......@@ -214,13 +214,13 @@ int mt7697io_clr_s2m_mbx(struct mt7697q_info *qinfo, u8 s2m_mbx)
const u16 value = mt7697io_set_s2m_mbox(s2m_mbx);
int ret;
ret = mt7697io_write16(qinfo, MT7697_IO_SLAVE_REG_MAILBOX_S2M, value);
ret = mt7697io_write16(qinfo, MT7697_IO_SLAVE_REG_MAILBOX_S2M, value);
if (ret < 0) {
dev_err(qinfo->dev, "%s(): mt7697io_write16() failed(%d)\n",
__func__, ret);
}
}
return ret;
return ret;
}
int mt7697io_wr(struct mt7697q_info *qinfo, u32 addr, const u32 *data,
......@@ -229,26 +229,26 @@ int mt7697io_wr(struct mt7697q_info *qinfo, u32 addr, const u32 *data,
size_t i;
int ret;
WARN_ON(num == 0);
WARN_ON(num == 0);
ret = mt7697io_write32(qinfo, MT7697_IO_SLAVE_REG_BUS_ADDR_LOW, addr);
if (ret < 0) {
ret = mt7697io_write32(qinfo, MT7697_IO_SLAVE_REG_BUS_ADDR_LOW, addr);
if (ret < 0) {
dev_err(qinfo->dev, "%s(): mt7697io_write32() failed(%d)\n",
__func__, ret);
goto cleanup;
}
goto cleanup;
}
for (i = 0; i < num; i++) {
ret = mt7697io_write32(
for (i = 0; i < num; i++) {
ret = mt7697io_write32(
qinfo, MT7697_IO_SLAVE_REG_WRITE_DATA_LOW, data[i]);
if (ret < 0) {
dev_err(qinfo->dev,
"%s(): mt7697io_write32() failed(%d)\n",
__func__, ret);
goto cleanup;
}
goto cleanup;
}
ret = mt7697io_write16(qinfo, MT7697_IO_SLAVE_REG_COMMAND, (
ret = mt7697io_write16(qinfo, MT7697_IO_SLAVE_REG_COMMAND, (
BF_DEFINE(MT7697_IO_COMMAND_REG_BUS_SIZE_VAL_WORD,
MT7697_IO_COMMAND_REG_BUS_SIZE_OFFSET,
MT7697_IO_COMMAND_REG_BUS_SIZE_WIDTH) |
......@@ -259,20 +259,20 @@ int mt7697io_wr(struct mt7697q_info *qinfo, u32 addr, const u32 *data,
dev_err(qinfo->dev,
"%s(): mt7697io_write16() failed(%d)\n",
__func__, ret);
goto cleanup;
}
goto cleanup;
}
ret = mt7697io_slave_wait(qinfo);
if (ret < 0) {
dev_err(qinfo->dev,
"%s(): mt7697io_slave_wait() failed(%d)\n",
__func__, ret);
goto cleanup;
}
}
goto cleanup;
}
}
cleanup:
return ret;
return ret;
}
int mt7697io_rd(struct mt7697q_info *qinfo, u32 addr, u32 *data, size_t num)
......@@ -280,65 +280,67 @@ int mt7697io_rd(struct mt7697q_info *qinfo, u32 addr, u32 *data, size_t num)
size_t i;
int ret;
WARN_ON(num == 0);
WARN_ON(num == 0);
ret = mt7697io_write32(qinfo, MT7697_IO_SLAVE_REG_BUS_ADDR_LOW, addr);
ret = mt7697io_write32(qinfo, MT7697_IO_SLAVE_REG_BUS_ADDR_LOW, addr);
if (ret < 0) {
dev_err(qinfo->dev, "%s(): mt7697io_write32() failed(%d)\n",
__func__, ret);
goto cleanup;
}
for (i = 0; i < num; i++) {
ret = mt7697io_write16(qinfo, MT7697_IO_SLAVE_REG_COMMAND, (
BF_DEFINE(MT7697_IO_COMMAND_REG_BUS_SIZE_VAL_WORD,
MT7697_IO_COMMAND_REG_BUS_SIZE_OFFSET,
MT7697_IO_COMMAND_REG_BUS_SIZE_WIDTH) |
BF_DEFINE(MT7697_IO_COMMAND_REG_RW_VAL_READ,
MT7697_IO_COMMAND_REG_RW_OFFSET,
MT7697_IO_COMMAND_REG_RW_WIDTH)));
goto cleanup;
}
for (i = 0; i < num; i++) {
ret = mt7697io_write16(
qinfo, MT7697_IO_SLAVE_REG_COMMAND, (
BF_DEFINE(MT7697_IO_COMMAND_REG_BUS_SIZE_VAL_WORD,
MT7697_IO_COMMAND_REG_BUS_SIZE_OFFSET,
MT7697_IO_COMMAND_REG_BUS_SIZE_WIDTH) |
BF_DEFINE(MT7697_IO_COMMAND_REG_RW_VAL_READ,
MT7697_IO_COMMAND_REG_RW_OFFSET,
MT7697_IO_COMMAND_REG_RW_WIDTH)));
if (ret < 0) {
dev_err(qinfo->dev,
"%s(): mt7697io_write16() failed(%d)\n",
__func__, ret);
goto cleanup;
}
goto cleanup;
}
ret = mt7697io_slave_wait(qinfo);
ret = mt7697io_slave_wait(qinfo);
if (ret < 0) {
dev_err(qinfo->dev,
"%s(): mt7697io_slave_wait() failed(%d)\n",
__func__, ret);
goto cleanup;
}
goto cleanup;
}
ret = mt7697io_read32(
ret = mt7697io_read32(
qinfo, MT7697_IO_SLAVE_REG_READ_DATA_LOW, &data[i]);
if (ret < 0) {
if (ret < 0) {
dev_err(qinfo->dev,
"%s(): mt7697io_read32() failed(%d)\n",
__func__, ret);
goto cleanup;
}
}
goto cleanup;
}
}
cleanup:
return ret;
return ret;
}
int mt7697io_trigger_intr(struct mt7697q_info *qinfo)
{
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));
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));
if (ret < 0) {
dev_err(qinfo->dev, "%s(): mt7697io_write16() failed(%d)\n",
__func__, ret);
goto cleanup;
}
goto cleanup;
}
cleanup:
return ret;
return ret;
}
......@@ -25,31 +25,31 @@ static ssize_t mt7697q_buf_diff(u32 size, u32 from, u32 to)
{
if (from >= size) {
pr_info("%s(): ERROR from(%u) >= size(%u)\n",
__func__, from, size);
WARN_ON(from >= size);
__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);
__func__, to, size);
WARN_ON(to >= size);
}
return (from <= to) ? (to - from):((size - from) + to);
return (from <= to) ? (to - from):((size - from) + to);
}
static size_t mt7697q_get_capacity(const struct mt7697q_spec *qs)
{
return BF_GET(qs->data.flags, MT7697_QUEUE_FLAGS_NUM_WORDS_OFFSET,
MT7697_QUEUE_FLAGS_NUM_WORDS_WIDTH) - 1;
return BF_GET(qs->data.flags, MT7697_QUEUE_FLAGS_NUM_WORDS_OFFSET,
MT7697_QUEUE_FLAGS_NUM_WORDS_WIDTH) - 1;
}
static 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);
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 int mt7697q_wr_init(u8 tx_ch, u8 rx_ch, struct mt7697q_spec *qs)
......@@ -63,14 +63,14 @@ static int mt7697q_wr_init(u8 tx_ch, u8 rx_ch, struct mt7697q_spec *qs)
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);
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));
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));
"%s(): mt7697q_write() failed(%d != %d)\n",
__func__, ret, LEN_TO_WORD(req.cmd.len));
ret = (ret < 0) ? ret:-EIO;
goto cleanup;
}
......@@ -84,24 +84,24 @@ cleanup:
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, rd_offset);
(qs->ch * sizeof(struct mt7697q_data)) +
offsetof(struct mt7697q_data, rd_offset);
u32 rd_offset;
int ret;
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_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;
__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);
__func__, qs->ch, qs->data.rd_offset);
cleanup:
return ret;
......@@ -110,39 +110,39 @@ cleanup:
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);
(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);
__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)));
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);
goto cleanup;
}
__func__, ret);
goto cleanup;
}
ret = mt7697io_wr_m2s_mbx(qs->qinfo, 1 << qs->ch);
ret = mt7697io_wr_m2s_mbx(qs->qinfo, 1 << qs->ch);
if (ret < 0) {
dev_err(qs->qinfo->dev,
"%s(): mt7697io_wr_m2s_mbx() failed(%d)\n",
__func__, ret);
goto cleanup;
}
"%s(): mt7697io_wr_m2s_mbx() failed(%d)\n",
__func__, ret);
goto cleanup;
}
ret = mt7697io_trigger_intr(qs->qinfo);
ret = mt7697io_trigger_intr(qs->qinfo);
if (ret < 0) {
dev_err(qs->qinfo->dev,
"%s(): mt7697io_trigger_intr() failed(%d)\n",
__func__, ret);
goto cleanup;
}
"%s(): mt7697io_trigger_intr() failed(%d)\n",
__func__, ret);
goto cleanup;
}
cleanup:
mutex_unlock(&qs->qinfo->mutex);
......@@ -152,26 +152,26 @@ cleanup:
static int mt7697q_pull_wr_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);
(qs->ch * sizeof(struct mt7697q_data)) +
offsetof(struct mt7697q_data, wr_offset);
u32 wr_offset;
int ret;
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) {
__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;
__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);
__func__, qs->ch, qs->data.wr_offset);
cleanup:
mutex_unlock(&qs->qinfo->mutex);
......@@ -181,38 +181,38 @@ cleanup:
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);
(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);
__func__, write_addr, qs->data.wr_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) {
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);
goto cleanup;
}
__func__, ret);
goto cleanup;
}
ret = mt7697io_wr_m2s_mbx(qs->qinfo, 1 << qs->ch);
ret = mt7697io_wr_m2s_mbx(qs->qinfo, 1 << qs->ch);
if (ret < 0) {
dev_err(qs->qinfo->dev,
"%s(): mt7697io_wr_m2s_mbx() failed(%d)\n",
__func__, ret);
goto cleanup;
}
"%s(): mt7697io_wr_m2s_mbx() failed(%d)\n",
__func__, ret);
goto cleanup;
}
ret = mt7697io_trigger_intr(qs->qinfo);
ret = mt7697io_trigger_intr(qs->qinfo);
if (ret < 0) {
dev_err(qs->qinfo->dev,
"%s(): mt7697io_trigger_intr() failed(%d)\n",
__func__, ret);
goto cleanup;
}
"%s(): mt7697io_trigger_intr() failed(%d)\n",
__func__, ret);
goto cleanup;
}
cleanup:
return ret;
......@@ -224,38 +224,39 @@ static int mt7697q_read_state(u8 ch, struct mt7697q_spec *qs)
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)));
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;
}
__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);
__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);
__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);
__func__, qs->data.base_addr);
ret = -EINVAL;
goto cleanup;
} else if (!qs->data.flags) {
goto cleanup;
} else if (!qs->data.flags) {
dev_err(qs->qinfo->dev, "%s(): invalid flags(0x%08x)\n",
__func__, qs->data.flags);
__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))) {
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);
"%s(): invalid rd/wr offset(0x%08x/0x%08x)\n",
__func__, qs->data.rd_offset, qs->data.wr_offset);
ret = -EINVAL;
goto cleanup;
}
goto cleanup;
}
cleanup:
mutex_unlock(&qs->qinfo->mutex);
......@@ -269,17 +270,17 @@ static int mt7697q_proc_queue_rsp(struct mt7697q_spec *qs)
switch(qs->qinfo->rsp.cmd.type) {
case MT7697_CMD_QUEUE_INIT_RSP:
dev_dbg(qs->qinfo->dev, "%s(): --> QUEUE INIT RSP\n",
__func__);
__func__);
break;
case MT7697_CMD_QUEUE_RESET_RSP:
dev_dbg(qs->qinfo->dev, "%s(): --> QUEUE RESET RSP\n",
__func__);
__func__);
break;
default:
dev_err(qs->qinfo->dev, "%s(): unsupported cmd(%d)\n",
__func__, qs->qinfo->rsp.cmd.type);
__func__, qs->qinfo->rsp.cmd.type);
ret = -EINVAL;
goto cleanup;
}
......@@ -301,20 +302,20 @@ static int mt7697q_wr_unused(
req.s2m_ch = qsS2M->ch;
qsM2S->data.flags &= ~BF_GET(qsM2S->data.flags,
MT7697_QUEUE_FLAGS_IN_USE_OFFSET,
MT7697_QUEUE_FLAGS_IN_USE_WIDTH);
MT7697_QUEUE_FLAGS_IN_USE_OFFSET,
MT7697_QUEUE_FLAGS_IN_USE_WIDTH);
qsS2M->data.flags &= ~BF_GET(qsS2M->data.flags,
MT7697_QUEUE_FLAGS_IN_USE_OFFSET,
MT7697_QUEUE_FLAGS_IN_USE_WIDTH);
MT7697_QUEUE_FLAGS_IN_USE_OFFSET,
MT7697_QUEUE_FLAGS_IN_USE_WIDTH);
dev_dbg(qsM2S->qinfo->dev, "%s(): <-- QUEUE UNUSED(%u/%u)\n",
__func__, req.m2s_ch, req.s2m_ch);
dev_dbg(qsM2S->qinfo->dev, "%s(): <-- QUEUE UNUSED(%u/%u)\n",
__func__, req.m2s_ch, req.s2m_ch);
ret = mt7697q_write(qsM2S, (const u32*)&req,
LEN_TO_WORD(req.cmd.len));
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));
"%s(): mt7697q_write() failed(%d != %d)\n",
__func__, ret, LEN_TO_WORD(req.cmd.len));
ret = (ret < 0) ? ret:-EIO;
goto cleanup;
}
......@@ -327,7 +328,7 @@ cleanup:
size_t mt7697q_get_free_words(const struct mt7697q_spec *qs)
{
return mt7697q_get_capacity(qs) - mt7697q_get_num_words(qs);
return mt7697q_get_capacity(qs) - mt7697q_get_num_words(qs);
}
int mt7697q_get_s2m_mbx(struct mt7697q_info *qinfo, u8 *s2m_mbox)
......@@ -339,26 +340,26 @@ int mt7697q_get_s2m_mbx(struct mt7697q_info *qinfo, u8 *s2m_mbox)
ret = mt7697io_rd_s2m_mbx(qinfo, s2m_mbox);
if (ret < 0) {
dev_err(qinfo->dev, "%s(): mt7697io_rd_s2m_mbx() failed(%d)\n",
__func__, ret);
goto cleanup;
}
__func__, ret);
goto cleanup;
}
ret = mt7697io_clr_s2m_mbx(qinfo, *s2m_mbox);
if (ret < 0) {
dev_err(qinfo->dev,
"%s(): mt7697io_clr_s2m_mbx() failed(%d)\n",
__func__, ret);
"%s(): mt7697io_clr_s2m_mbx() failed(%d)\n",
__func__, ret);
goto cleanup;
}
}
cleanup:
mutex_unlock(&qinfo->mutex);
return ret;
return ret;
}
int mt7697q_blocked_writer(const struct mt7697q_spec *qs)
{
return atomic_read(&qs->qinfo->blocked_writer);
return atomic_read(&qs->qinfo->blocked_writer);
}
int mt7697q_proc_data(struct mt7697q_spec *qsS2M)
......@@ -370,62 +371,62 @@ int mt7697q_proc_data(struct mt7697q_spec *qsS2M)
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;
}
"%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 mt7697_rsp_hdr)) :
sizeof(struct mt7697_rsp_hdr)) :
LEN_TO_WORD(sizeof(struct mt7697_rsp_hdr));
dev_dbg(qsS2M->qinfo->dev, "%s(): avail(%u) len(%u) req(%u)\n",
__func__, avail, qsS2M->qinfo->rsp.cmd.len, req);
__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);
req);
if (ret != req) {
dev_err(qsS2M->qinfo->dev,
"%s(): mt7697q_read() failed(%d != %d)\n",
__func__, ret, req);
goto cleanup;
}
"%s(): mt7697q_read() failed(%d != %d)\n",
__func__, ret, req);
goto cleanup;
}
avail -= LEN_TO_WORD(sizeof(struct mt7697_rsp_hdr));
req = LEN_TO_WORD(qsS2M->qinfo->rsp.cmd.len -
sizeof(struct mt7697_rsp_hdr));
sizeof(struct mt7697_rsp_hdr));
dev_dbg(qsS2M->qinfo->dev,
"%s(): avail(%u) len(%u) req(%u)\n", __func__,
avail, qsS2M->qinfo->rsp.cmd.len, req);
"%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);
"%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;
}
"%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);
__func__, avail, qsS2M->qinfo->rsp.cmd.len, req);
if (avail < req) {
dev_dbg(qsS2M->qinfo->dev,
"%s(): queue need more data\n", __func__);
"%s(): queue need more data\n", __func__);
goto cleanup;
}
......@@ -433,47 +434,47 @@ int mt7697q_proc_data(struct mt7697q_spec *qsS2M)
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;
}
"%s(): mt7697q_proc_queue_rsp() failed(%d)\n",
__func__, ret);
goto cleanup;
}
} else {
WARN_ON(!qsS2M->rx_fcn);
ret = qsS2M->rx_fcn((const struct mt7697_rsp_hdr*)
&qsS2M->qinfo->rsp, qsS2M->priv);
&qsS2M->qinfo->rsp, qsS2M->priv);
if (ret < 0) {
dev_err(qsS2M->qinfo->dev,
"%s(): rx_fcn() failed(%d)\n",
__func__, ret);
}
"%s(): rx_fcn() failed(%d)\n",
__func__, ret);
}
}
avail -= req;
qsS2M->qinfo->rsp.cmd.len = 0;
req = LEN_TO_WORD(sizeof(struct mt7697_rsp_hdr));
dev_dbg(qsS2M->qinfo->dev, "%s(): avail(%u) len(%u) req(%u)\n",
__func__, avail, qsS2M->qinfo->rsp.cmd.len, req);
__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;
}
"%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);
__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;
"%s(): mt7697q_push_rd_ptr() failed(%d)\n",
__func__, ret);
goto cleanup;
}
}
......@@ -484,7 +485,7 @@ cleanup:
void mt7697q_unblock_writer(void *hndl)
{
struct mt7697q_spec *qs = (struct mt7697q_spec*)hndl;
atomic_set(&qs->qinfo->blocked_writer, false);
atomic_set(&qs->qinfo->blocked_writer, false);
}
EXPORT_SYMBOL(mt7697q_unblock_writer);
......@@ -502,14 +503,14 @@ int mt7697q_wr_reset(void *tx_hndl, void* rx_hndl)
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);
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));
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));
"%s(): mt7697q_write() failed(%d != %d)\n",
__func__, ret, LEN_TO_WORD(req.cmd.len));
ret = (ret < 0) ? ret:-EIO;
goto cleanup;
}
......@@ -523,7 +524,7 @@ cleanup:
EXPORT_SYMBOL(mt7697q_wr_reset);
int mt7697q_init(u8 tx_ch, u8 rx_ch, void *priv, notify_tx_hndlr notify_tx_fcn,
rx_hndlr rx_fcn, void** tx_hndl, void** rx_hndl)
rx_hndlr rx_fcn, void** tx_hndl, void** rx_hndl)
{
char str[32];
struct spi_master *master = NULL;
......@@ -535,11 +536,11 @@ int mt7697q_init(u8 tx_ch, u8 rx_ch, void *priv, notify_tx_hndlr notify_tx_fcn,
int ret;
pr_info(DRVNAME" %s(): initialize queue(%u/%u)\n",
__func__, tx_ch, rx_ch);
__func__, tx_ch, rx_ch);
while (!master && (bus_num >= 0)) {
pr_info(DRVNAME" %s(): get SPI master bus(%u)\n",
__func__, bus_num);
__func__, bus_num);
master = spi_busnum_to_master(bus_num);
if (!master)
bus_num--;
......@@ -547,19 +548,19 @@ int mt7697q_init(u8 tx_ch, u8 rx_ch, void *priv, notify_tx_hndlr notify_tx_fcn,
if (!master) {
pr_err(DRVNAME" %s(): spi_busnum_to_master() failed\n",
__func__);
__func__);
ret = -EINVAL;
goto cleanup;
}
snprintf(str, sizeof(str), "%s.%u", dev_name(&master->dev),
MT7697_SPI_CS);
MT7697_SPI_CS);
dev_dbg(&master->dev, "%s(): find SPI device('%s')\n", __func__, str);
dev = bus_find_device_by_name(&spi_bus_type, NULL, str);
if (!dev) {
dev_err(&master->dev,
"%s(): '%s' bus_find_device_by_name() failed\n",
__func__, str);
"%s(): '%s' bus_find_device_by_name() failed\n",
__func__, str);
ret = -EINVAL;
goto cleanup;
}
......@@ -567,7 +568,7 @@ int mt7697q_init(u8 tx_ch, u8 rx_ch, void *priv, notify_tx_hndlr notify_tx_fcn,
spi = container_of(dev, struct spi_device, dev);
if (!spi) {
dev_err(&master->dev, "%s(): get SPI device failed\n",
__func__);
__func__);
ret = -EINVAL;
goto cleanup;
}
......@@ -575,18 +576,18 @@ int mt7697q_init(u8 tx_ch, u8 rx_ch, void *priv, notify_tx_hndlr notify_tx_fcn,
qinfo = spi_get_drvdata(spi);
if (!qinfo) {
dev_dbg(&master->dev, "%s(): spi_get_drvdata() failed\n",
__func__);
__func__);
ret = -EINVAL;
goto cleanup;
}
dev_dbg(qinfo->dev, "%s(): init queue spec(%u/%u)\n",
__func__, tx_ch, rx_ch);
__func__, tx_ch, rx_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);
__func__, tx_ch, rx_ch);
ret = -EINVAL;
goto cleanup;
}
......@@ -599,7 +600,7 @@ int mt7697q_init(u8 tx_ch, u8 rx_ch, void *priv, notify_tx_hndlr notify_tx_fcn,
atomic_set(&qsTx->qinfo->blocked_writer, false);
*tx_hndl = qsTx;
qsRx = &qinfo->queues[rx_ch];
qsRx = &qinfo->queues[rx_ch];
qsRx->qinfo = qinfo;
qsRx->ch = rx_ch;
qsRx->rx_fcn = rx_fcn;
......@@ -610,27 +611,27 @@ int mt7697q_init(u8 tx_ch, u8 rx_ch, void *priv, notify_tx_hndlr notify_tx_fcn,
ret = mt7697q_read_state(tx_ch, qsTx);
if (ret < 0) {
dev_err(qinfo->dev, "%s(): mt7697q_read_state() failed(%d)\n",
__func__, ret);
goto cleanup;
}
__func__, ret);
goto cleanup;
}
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;
}
__func__, ret);
goto cleanup;
}
qsTx->data.flags |= BF_DEFINE(1, MT7697_QUEUE_FLAGS_IN_USE_OFFSET,
MT7697_QUEUE_FLAGS_IN_USE_WIDTH);
MT7697_QUEUE_FLAGS_IN_USE_WIDTH);
qsRx->data.flags |= BF_DEFINE(1, MT7697_QUEUE_FLAGS_IN_USE_OFFSET,
MT7697_QUEUE_FLAGS_IN_USE_WIDTH);
MT7697_QUEUE_FLAGS_IN_USE_WIDTH);
ret = mt7697q_wr_init(tx_ch, rx_ch, qsTx);
if (ret < 0) {
dev_err(qinfo->dev, "%s(): mt7697q_wr_init() failed(%d)\n",
__func__, ret);
__func__, ret);
goto cleanup;
}
......@@ -640,7 +641,7 @@ cleanup:
memset(&qsRx, 0, sizeof(struct mt7697q_spec));
}
return ret;
return ret;
}
EXPORT_SYMBOL(mt7697q_init);
......@@ -651,11 +652,11 @@ int mt7697q_shutdown(void **tx_hndl, void **rx_hndl)
struct mt7697q_spec *qsS2M = *rx_hndl;
int ret;
ret = mt7697q_wr_unused(qsM2S, qsS2M);
ret = mt7697q_wr_unused(qsM2S, qsS2M);
if (ret < 0) {
dev_err(qsM2S->qinfo->dev,
"%s(): mt7697q_wr_unused() failed(%d)\n", __func__,
ret);
"%s(): mt7697q_wr_unused() failed(%d)\n", __func__,
ret);
goto cleanup;
}
......@@ -670,87 +671,87 @@ EXPORT_SYMBOL(mt7697q_shutdown);
size_t mt7697q_read(void *hndl, u32 *buf, size_t num)
{
struct mt7697q_spec *qs = (struct mt7697q_spec*)hndl;
struct mt7697q_spec *qs = (struct mt7697q_spec*)hndl;
size_t rd_words = 0;
u16 write_offset;
u16 read_offset;
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);
MT7697_QUEUE_FLAGS_NUM_WORDS_OFFSET,
MT7697_QUEUE_FLAGS_NUM_WORDS_WIDTH);
write_offset = qs->data.wr_offset;
read_offset = qs->data.rd_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, 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 +
__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) ?
const size_t rd_num = (num <= words_to_end) ?
num : words_to_end;
dev_dbg(qs->qinfo->dev,
"%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);
"%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,
"%s(): mt7697io_rd() failed(%d)\n",
__func__, ret);
goto cleanup;
}
"%s(): mt7697io_rd() failed(%d)\n",
__func__, ret);
goto cleanup;
}
rd_words += rd_num;
read_offset += rd_num;
rd_words += rd_num;
read_offset += rd_num;
if (read_offset == buff_words) {
/*
if (read_offset == buff_words) {
/*
* If we have read to the end, then
* set the read pointer to the beginning
* set the read pointer to the beginning
*/
read_offset = 0;
}
}
if (rd_words < num) {
/* NOTE: rd_offset assumed to be <= wr_offset at this point */
const size_t words_avail = write_offset - read_offset;
const u32 rd_addr = qs->data.base_addr +
read_offset = 0;
}
}
if (rd_words < num) {
/* NOTE: rd_offset assumed to be <= wr_offset at this point */
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 =
const size_t words_req = num - rd_words;
const size_t rd_num =
(words_req <= words_avail) ? words_req : words_avail;
dev_dbg(qs->qinfo->dev,
"%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) {
"%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,
"%s(): mt7697io_rd() failed(%d)\n",
__func__, ret);
goto cleanup;
}
"%s(): mt7697io_rd() failed(%d)\n",
__func__, ret);
goto cleanup;
}
rd_words += rd_num;
read_offset += rd_num;
}
rd_words += rd_num;
read_offset += rd_num;
}
if (read_offset >= buff_words) {
dev_err(qs->qinfo->dev, "%s(): rd offset(%u) >= size(%u)\n",
__func__, read_offset, buff_words);
__func__, read_offset, buff_words);
WARN_ON(read_offset >= buff_words);
ret = -EINVAL;
goto cleanup;
}
dev_dbg(qs->qinfo->dev, "%s(): queue(%u) rd offset(%u) read(%u)\n",
__func__, qs->ch, read_offset, rd_words);
__func__, qs->ch, read_offset, rd_words);
qs->data.rd_offset = read_offset;
ret = rd_words;
......@@ -764,7 +765,7 @@ EXPORT_SYMBOL(mt7697q_read);
size_t mt7697q_write(void *hndl, const u32 *buff, size_t num)
{
struct mt7697q_spec *qs = (struct mt7697q_spec*)hndl;
struct mt7697q_spec *qs = (struct mt7697q_spec*)hndl;
size_t avail;
size_t words_written = 0;
u16 read_offset;
......@@ -780,14 +781,14 @@ size_t mt7697q_write(void *hndl, const u32 *buff, size_t num)
ret = mt7697q_pull_rd_ptr(qs);
if (ret < 0) {
dev_err(qs->qinfo->dev,
"%s(): mt7697q_pull_rd_ptr() failed(%d)\n",
__func__, ret);
goto cleanup;
}
"%s(): mt7697q_pull_rd_ptr() failed(%d)\n",
__func__, ret);
goto cleanup;
}
if (avail < num) {
dev_dbg(qs->qinfo->dev, "%s(): queue avail(%u < %u)\n",
__func__, avail, num);
__func__, avail, num);
atomic_set(&qs->qinfo->blocked_writer, true);
ret = -EAGAIN;
goto cleanup;
......@@ -795,92 +796,92 @@ size_t mt7697q_write(void *hndl, const u32 *buff, size_t num)
}
buff_words = BF_GET(qs->data.flags, MT7697_QUEUE_FLAGS_NUM_WORDS_OFFSET,
MT7697_QUEUE_FLAGS_NUM_WORDS_WIDTH);
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, 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) ?
__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 +
const size_t words_to_write =
(num <= words_avail) ? num : words_avail;
const u32 write_addr = qs->data.base_addr +
(write_offset * sizeof(u32));
dev_dbg(qs->qinfo->dev,
"%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);
if (ret < 0) {
"%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);
if (ret < 0) {
dev_err(qs->qinfo->dev,
"%s(): mt7697io_wr() failed(%d)\n",
__func__, ret);
goto cleanup;
}
"%s(): mt7697io_wr() failed(%d)\n",
__func__, ret);
goto cleanup;
}
words_written += words_to_write;
words_written += words_to_write;
num -= words_to_write;
write_offset += words_to_write;
if (write_offset == buff_words) {
write_offset = 0;
}
}
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) ?
write_offset += words_to_write;
if (write_offset == buff_words) {
write_offset = 0;
}
}
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 +
const uint32_t write_addr = qs->data.base_addr +
(write_offset * sizeof(u32));
dev_dbg(qs->qinfo->dev,
"%s(): wr(%u) queue(%u) wr offset(%u) addr(0x%08x)\n",
__func__, words_to_write, qs->ch, write_offset,
write_addr);
"%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);
if (ret < 0) {
words_to_write);
if (ret < 0) {
dev_err(qs->qinfo->dev,
"%s(): mt7697io_wr() failed(%d)\n",
__func__, ret);
goto cleanup;
}
"%s(): mt7697io_wr() failed(%d)\n",
__func__, ret);
goto cleanup;
}
words_written += words_to_write;
words_written += words_to_write;
num -= words_to_write;
write_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);
__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);
__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,
"%s(): mt7697q_push_wr_ptr() failed(%d)\n",
__func__, ret);
goto cleanup;
}
"%s(): mt7697q_push_wr_ptr() failed(%d)\n",
__func__, ret);
goto cleanup;
}
ret = words_written;
cleanup:
mutex_unlock(&qs->qinfo->mutex);
return ret;
return ret;
}
EXPORT_SYMBOL(mt7697q_write);
......@@ -888,11 +889,11 @@ EXPORT_SYMBOL(mt7697q_write);
u32 mt7697q_flags_get_in_use(u32 flags)
{
return BF_GET(flags, MT7697_QUEUE_FLAGS_IN_USE_OFFSET,
MT7697_QUEUE_FLAGS_IN_USE_WIDTH);
MT7697_QUEUE_FLAGS_IN_USE_WIDTH);
}
u32 mt7697q_flags_get_dir(u32 flags)
{
return BF_GET(flags,MT7697_QUEUE_FLAGS_DIR_OFFSET,
MT7697_QUEUE_FLAGS_DIR_WIDTH);
MT7697_QUEUE_FLAGS_DIR_WIDTH);
}
......@@ -35,39 +35,39 @@
#define MT7697_QUEUE_DEBUG_DUMP_LIMIT 1024
struct mt7697q_data {
u32 flags;
u32 base_addr;
u16 rd_offset;
u16 reserved1;
u16 wr_offset;
u16 reserved2;
u32 flags;
u32 base_addr;
u16 rd_offset;
u16 reserved1;
u16 wr_offset;
u16 reserved2;
};
struct mt7697q_spec {
struct mt7697q_data data;
struct mt7697q_data data;
struct mt7697q_info *qinfo;
void *priv;
notify_tx_hndlr notify_tx_fcn;
rx_hndlr rx_fcn;
u8 ch;
void *priv;
notify_tx_hndlr notify_tx_fcn;
rx_hndlr rx_fcn;
u8 ch;
};
struct mt7697q_info {
struct mt7697q_spec queues[MT7697_NUM_QUEUES];
struct mt7697_rsp_hdr rsp;
struct mt7697q_spec queues[MT7697_NUM_QUEUES];
struct mt7697_rsp_hdr rsp;
struct device *dev;
void *hw_priv;
const struct mt7697spi_hw_ops *hw_ops;
struct device *dev;
void *hw_priv;
const struct mt7697spi_hw_ops *hw_ops;
struct mutex mutex;
struct workqueue_struct *irq_workq;
struct workqueue_struct *irq_workq;
struct work_struct irq_work;
struct delayed_work irq_delayed_work;
atomic_t blocked_writer;
int gpio_pin;
int irq;
struct delayed_work irq_delayed_work;
atomic_t blocked_writer;
int gpio_pin;
int irq;
};
void mt7697q_irq_delayed_work(struct work_struct*);
......
......@@ -19,13 +19,13 @@
#include "mt7697_i.h"
#define mt7697_queue_init_rsp mt7697_rsp_hdr
#define mt7697_queue_reset_rsp mt7697_rsp_hdr
#define mt7697_queue_init_rsp mt7697_rsp_hdr
#define mt7697_queue_reset_rsp mt7697_rsp_hdr
enum mt7697q_dir
{
MT7697_QUEUE_DIR_M2S = 0,
MT7697_QUEUE_DIR_S2M,
MT7697_QUEUE_DIR_M2S = 0,
MT7697_QUEUE_DIR_S2M,
};
enum mt7697q_cmd_types {
......@@ -37,21 +37,21 @@ enum mt7697q_cmd_types {
};
struct mt7697_queue_init_req {
struct mt7697_cmd_hdr cmd;
__be32 m2s_ch;
__be32 s2m_ch;
struct mt7697_cmd_hdr cmd;
__be32 m2s_ch;
__be32 s2m_ch;
} __attribute__((packed, aligned(4)));
struct mt7697_queue_unused_req {
struct mt7697_cmd_hdr cmd;
__be32 m2s_ch;
__be32 s2m_ch;
struct mt7697_cmd_hdr cmd;
__be32 m2s_ch;
__be32 s2m_ch;
} __attribute__((packed, aligned(4)));
struct mt7697_queue_reset_req {
struct mt7697_cmd_hdr cmd;
__be32 m2s_ch;
__be32 s2m_ch;
struct mt7697_cmd_hdr cmd;
__be32 m2s_ch;
__be32 s2m_ch;
} __attribute__((packed, aligned(4)));
u32 mt7697q_flags_get_in_use(u32);
......
......@@ -31,7 +31,7 @@
#include "spi.h"
static int mt7697spi_write_then_read(struct spi_device *spi, const void *txbuf,
void *rxbuf, unsigned len)
void *rxbuf, unsigned len)
{
struct spi_transfer transfer = {
.tx_buf = txbuf,
......@@ -98,19 +98,19 @@ static int __init mt7697spi_init(void)
ret = cp2130_update_ch_config(master, MT7697_SPI_CONFIG);
if (ret < 0) {
dev_err(&master->dev,
"%s(): cp2130_update_ch_config() failed(%d)\n",
__func__, ret);
"%s(): cp2130_update_ch_config() failed(%d)\n",
__func__, ret);
goto cleanup;
}
snprintf(str, sizeof(str), "%s.%u", dev_name(&master->dev),
MT7697_SPI_CS);
MT7697_SPI_CS);
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) {
dev_err(&master->dev,
"%s(): bus_find_device_by_name('%s') failed\n",
__func__, str);
"%s(): bus_find_device_by_name('%s') failed\n",
__func__, str);
ret = -EINVAL;
goto cleanup;
......@@ -119,65 +119,65 @@ static int __init mt7697spi_init(void)
spi = to_spi_device(dev);
if (!spi) {
dev_err(&master->dev, "%s(): get SPI device failed\n",
__func__);
__func__);
ret = -EINVAL;
goto cleanup;
}
dev_info(&master->dev, "%s(): dev('%s') mode(%d) max speed(%d) "
"CS(%d) bits/word(%d)\n",
__func__, spi->modalias, spi->mode, spi->max_speed_hz,
spi->chip_select, spi->bits_per_word);
"CS(%d) bits/word(%d)\n",
__func__, spi->modalias, spi->mode, spi->max_speed_hz,
spi->chip_select, spi->bits_per_word);
qinfo = kzalloc(sizeof(struct mt7697q_info), GFP_KERNEL);
if (!qinfo) {
dev_err(&master->dev, "%s(): create queue info failed\n",
__func__);
__func__);
ret = -ENOMEM;
goto cleanup;
}
qinfo->dev = &spi->dev;
qinfo->hw_priv = spi;
qinfo->hw_ops = &hw_ops;
qinfo->hw_priv = spi;
qinfo->hw_ops = &hw_ops;
mutex_init(&qinfo->mutex);
INIT_DELAYED_WORK(&qinfo->irq_delayed_work, mt7697q_irq_delayed_work);
INIT_WORK(&qinfo->irq_work, mt7697q_irq_work);
qinfo->irq_workq = alloc_workqueue(DRVNAME"wq",
WQ_HIGHPRI | WQ_MEM_RECLAIM | WQ_UNBOUND, 1);
WQ_HIGHPRI | WQ_MEM_RECLAIM | WQ_UNBOUND, 1);
if (!qinfo->irq_workq) {
dev_err(qinfo->dev, "%s(): alloc_workqueue() failed\n",
__func__);
__func__);
ret = -ENOMEM;
goto cleanup;
}
qinfo->gpio_pin = MT7697_SPI_INTR_GPIO_PIN;
ret = gpio_request(qinfo->gpio_pin, MT7697_SPI_GPIO_IRQ_NAME);
if (ret < 0) {
if (ret < 0) {
if (ret != -EBUSY) {
dev_err(qinfo->dev, "%s(): gpio_request() failed(%d)",
__func__, ret);
dev_err(qinfo->dev, "%s(): gpio_request() failed(%d)",
__func__, ret);
goto failed_workqueue;
}
qinfo->irq = gpio_to_irq(qinfo->gpio_pin);
qinfo->gpio_pin = MT7697_SPI_INTR_GPIO_PIN_INVALID;
} else {
} else {
gpio_direction_input(qinfo->gpio_pin);
qinfo->irq = gpio_to_irq(qinfo->gpio_pin);
}
dev_info(qinfo->dev, "%s(): request irq(%d)\n", __func__, qinfo->irq);
ret = request_irq(qinfo->irq, mt7697q_isr, 0, DRVNAME, qinfo);
if (ret < 0) {
dev_err(qinfo->dev, "%s(): request_irq() failed(%d)",
__func__, ret);
goto failed_gpio_req;
}
if (ret < 0) {
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);
......@@ -218,27 +218,27 @@ static void __exit mt7697spi_exit(void)
}
snprintf(str, sizeof(str), "%s.%u", dev_name(&master->dev),
MT7697_SPI_CS);
MT7697_SPI_CS);
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) {
dev_err(&master->dev,
"%s(): '%s' bus_find_device_by_name() failed\n",
__func__, str);
"%s(): '%s' bus_find_device_by_name() failed\n",
__func__, str);
goto cleanup;
}
spi = to_spi_device(dev);
if (!spi) {
dev_err(dev, "%s(): get SPI device failed\n",
__func__);
__func__);
goto cleanup;
}
qinfo = spi_get_drvdata(spi);
if (!qinfo) {
dev_err(dev, "%s(): SPI device no queue info\n",
__func__);
__func__);
goto cleanup;
}
......
......@@ -30,14 +30,14 @@ static int mt7697_uart_snd_shutdown_req(struct mt7697_uart_info* uart_info)
req.type = MT7697_CMD_UART_SHUTDOWN_REQ;
dev_dbg(uart_info->dev, "%s(): <-- UART SHUTDOWN len(%u)\n",
__func__, req.len);
__func__, req.len);
ret = mt7697_uart_write(uart_info, (const u32*)&req,
LEN_TO_WORD(sizeof(struct mt7697_uart_shutdown_req)));
LEN_TO_WORD(sizeof(struct mt7697_uart_shutdown_req)));
if (ret != LEN_TO_WORD(sizeof(struct mt7697_uart_shutdown_req))) {
dev_err(uart_info->dev,
"%s(): mt7697_uart_write() failed(%d != %d)\n",
__func__, ret,
LEN_TO_WORD(sizeof(struct mt7697_uart_shutdown_req)));
"%s(): mt7697_uart_write() failed(%d != %d)\n",
__func__, ret,
LEN_TO_WORD(sizeof(struct mt7697_uart_shutdown_req)));
ret = (ret < 0) ? ret:-EIO;
goto cleanup;
}
......@@ -55,38 +55,38 @@ static int mt7697_uart_rx_poll(struct mt7697_uart_info* uart_info)
int ret = 0;
WARN_ON(!uart_info->fd_hndl->f_op->poll);
poll_initwait(&table);
poll_initwait(&table);
while (1) {
mask = uart_info->fd_hndl->f_op->poll(
mask = uart_info->fd_hndl->f_op->poll(
uart_info->fd_hndl, &table.pt);
if (mask & POLLERR) {
dev_warn(uart_info->dev,
"%s(): poll error\n", __func__);
"%s(): poll error\n", __func__);
ret = -EIO;
goto cleanup;
} else if (mask & POLLHUP) {
dev_warn(uart_info->dev,
"%s(): poll hangup\n", __func__);
"%s(): poll hangup\n", __func__);
ret = -EPIPE;
goto cleanup;
} else if (mask & (POLLRDNORM | POLLRDBAND | POLLIN)) {
dev_dbg(uart_info->dev, "%s(): Rx data mask(0x%08x)\n",
__func__, mask);
break;
}
__func__, mask);
break;
}
if (signal_pending(current)) {
dev_warn(uart_info->dev,
"%s(): signal_pending()\n", __func__);
"%s(): signal_pending()\n", __func__);
ret = -EINTR;
goto cleanup;
}
if (!schedule_timeout_interruptible(MAX_SCHEDULE_TIMEOUT)) {
dev_err(uart_info->dev,
"%s(): schedule_timeout_interruptible() failed\n",
__func__);
"%s(): schedule_timeout_interruptible() failed\n",
__func__);
ret = -ETIMEDOUT;
goto cleanup;
}
......@@ -100,7 +100,7 @@ cleanup:
static void mt7697_uart_rx_work(struct work_struct *rx_work)
{
struct mt7697_uart_info* uart_info = container_of(rx_work,
struct mt7697_uart_info, rx_work);
struct mt7697_uart_info, rx_work);
size_t ret;
int err;
......@@ -108,49 +108,49 @@ static void mt7697_uart_rx_work(struct work_struct *rx_work)
ret = mt7697_uart_rx_poll(uart_info);
if (ret) {
dev_err(uart_info->dev,
"%s(): mt7697_uart_rx_poll() failed(%d)\n",
__func__, ret);
"%s(): mt7697_uart_rx_poll() failed(%d)\n",
__func__, ret);
goto cleanup;
}
ret = mt7697_uart_read(uart_info, (u32*)&uart_info->rsp,
LEN_TO_WORD(sizeof(struct mt7697_rsp_hdr)));
LEN_TO_WORD(sizeof(struct mt7697_rsp_hdr)));
if (ret != LEN_TO_WORD(sizeof(struct mt7697_rsp_hdr))) {
if (ret) {
dev_err(uart_info->dev,
"%s(): mt7697_uart_read() failed(%d != %d)\n",
__func__, ret,
LEN_TO_WORD(sizeof(struct mt7697_rsp_hdr)));
"%s(): mt7697_uart_read() failed(%d != %d)\n",
__func__, ret,
LEN_TO_WORD(sizeof(struct mt7697_rsp_hdr)));
} else {
dev_warn(uart_info->dev, "%s(): closed\n",
__func__);
__func__);
}
goto cleanup;
}
goto cleanup;
}
if (uart_info->rsp.result < 0) {
dev_warn(uart_info->dev,
"%s(): cmd(%u) result(%d)\n",
__func__, uart_info->rsp.cmd.type,
uart_info->rsp.result);
"%s(): cmd(%u) result(%d)\n",
__func__, uart_info->rsp.cmd.type,
uart_info->rsp.result);
}
if (uart_info->rsp.cmd.grp == MT7697_CMD_GRP_UART) {
if (uart_info->rsp.cmd.type ==
MT7697_CMD_UART_SHUTDOWN_RSP) {
dev_dbg(uart_info->dev,
"%s(): --> UART SHUTDOWN RSP\n",
__func__);
"%s(): --> UART SHUTDOWN RSP\n",
__func__);
} else {
dev_err(uart_info->dev,
"%s(): Rx invalid message type(%d)\n",
__func__, uart_info->rsp.cmd.type);
"%s(): Rx invalid message type(%d)\n",
__func__, uart_info->rsp.cmd.type);
}
if (atomic_read(&uart_info->close)) {
dev_warn(uart_info->dev, "%s(): closed\n",
__func__);
__func__);
goto cleanup;
}
} else {
......@@ -159,12 +159,12 @@ static void mt7697_uart_rx_work(struct work_struct *rx_work)
(const struct mt7697_rsp_hdr*)&uart_info->rsp,
uart_info->rx_hndl);
dev_dbg(uart_info->dev, "%s(): rx_fcn ret(%d)\n",
__func__, err);
__func__, err);
if (err < 0) {
dev_err(uart_info->dev,
"%s(): rx_fcn() failed(%d)\n",
__func__, err);
}
"%s(): rx_fcn() failed(%d)\n",
__func__, err);
}
}
}
......@@ -183,12 +183,12 @@ void* mt7697_uart_open(rx_hndlr rx_fcn, void* rx_hndl)
void *ret = NULL;
pr_info("%s(): find UART device('%s')\n", __func__,
MT7697_UART_DRVNAME);
MT7697_UART_DRVNAME);
dev = bus_find_device_by_name(&platform_bus_type, NULL,
MT7697_UART_DRVNAME);
MT7697_UART_DRVNAME);
if (!dev) {
pr_err("%s(): '%s' bus_find_device_by_name() failed\n",
__func__, MT7697_UART_DRVNAME);
__func__, MT7697_UART_DRVNAME);
goto cleanup;
}
......@@ -201,7 +201,7 @@ void* mt7697_uart_open(rx_hndlr rx_fcn, void* rx_hndl)
uart_info = platform_get_drvdata(uart);
if (!uart_info) {
dev_err(&uart->dev, "%s(): platform_get_drvdata() failed\n",
__func__);
__func__);
goto cleanup;
}
......@@ -209,16 +209,16 @@ void* mt7697_uart_open(rx_hndlr rx_fcn, void* rx_hndl)
dev_err(uart_info->dev, "%s(): open serial device '%s'\n",
__func__, uart_info->dev_file);
uart_info->fd_hndl = filp_open((const char __user*)uart_info->dev_file,
O_RDWR, 0600);
O_RDWR, 0600);
if (IS_ERR(uart_info->fd_hndl)) {
dev_err(uart_info->dev, "%s(): filp_open() '%s' failed\n",
__func__, MT7697_UART_DEVICE);
__func__, MT7697_UART_DEVICE);
uart_info->fd_hndl = MT7697_UART_INVALID_FD;
goto cleanup;
}
dev_dbg(uart_info->dev, "%s(): fd_hndl(0x%p)\n",
__func__, uart_info->fd_hndl);
__func__, uart_info->fd_hndl);
uart_info->rx_fcn = rx_fcn;
uart_info->rx_hndl = rx_hndl;
......@@ -241,7 +241,7 @@ int mt7697_uart_close(void *arg)
int ret = 0;
dev_dbg(uart_info->dev, "%s(): fd_hndl(0x%p)\n",
__func__, uart_info->fd_hndl);
__func__, uart_info->fd_hndl);
if (uart_info->fd_hndl == MT7697_UART_INVALID_FD ||
IS_ERR(uart_info->fd_hndl)) {
......@@ -253,27 +253,27 @@ int mt7697_uart_close(void *arg)
ret = mt7697_uart_snd_shutdown_req(uart_info);
if (ret < 0) {
dev_err(uart_info->dev,
"%s(): mt7697_uart_snd_shutdown_req() failed(%d)\n",
__func__, ret);
"%s(): mt7697_uart_snd_shutdown_req() failed(%d)\n",
__func__, ret);
goto cleanup;
}
wait_event_interruptible(uart_info->close_wq,
!atomic_read(&uart_info->close));
!atomic_read(&uart_info->close));
mutex_lock(&uart_info->mutex);
mutex_lock(&uart_info->mutex);
ret = filp_close(uart_info->fd_hndl, 0);
if (ret < 0) {
dev_err(uart_info->dev, "%s(): filp_close() failed(%d)\n",
__func__, ret);
__func__, ret);
goto unlock;
}
uart_info->fd_hndl = MT7697_UART_INVALID_FD;
unlock:
mutex_unlock(&uart_info->mutex);
mutex_unlock(&uart_info->mutex);
cleanup:
return ret;
......@@ -290,7 +290,7 @@ size_t mt7697_uart_read(void *arg, u32 *buf, size_t len)
unsigned long count = len * sizeof(u32);
int err;
oldfs = get_fs();
oldfs = get_fs();
set_fs(get_ds());
if (!uart_info->fd_hndl) {
......@@ -304,8 +304,8 @@ size_t mt7697_uart_read(void *arg, u32 *buf, size_t len)
dev_dbg(uart_info->dev, "%s(): read(%d)\n", __func__, err);
if (err < 0) {
dev_err(uart_info->dev,
"%s(): kernel_read() failed(%d)\n", __func__,
err);
"%s(): kernel_read() failed(%d)\n", __func__,
err);
goto cleanup;
} else if (!err) {
dev_warn(uart_info->dev, "%s(): CLOSED\n", __func__);
......@@ -323,7 +323,7 @@ size_t mt7697_uart_read(void *arg, u32 *buf, size_t len)
cleanup:
dev_dbg(uart_info->dev, "%s(): return(%u)\n", __func__, ret);
set_fs(oldfs);
return ret;
return ret;
}
EXPORT_SYMBOL(mt7697_uart_read);
......@@ -338,12 +338,12 @@ size_t mt7697_uart_write(void *arg, const u32 *buf, size_t len)
struct mt7697_uart_info *uart_info = arg;
u8* ptr = (u8*)buf;
mutex_lock(&uart_info->mutex);
mutex_lock(&uart_info->mutex);
oldfs = get_fs();
set_fs(get_ds());
if (uart_info->fd_hndl == MT7697_UART_INVALID_FD ||
if (uart_info->fd_hndl == MT7697_UART_INVALID_FD ||
IS_ERR(uart_info->fd_hndl)) {
dev_warn(uart_info->dev, "%s(): device closed\n", __func__);
goto cleanup;
......@@ -353,11 +353,11 @@ size_t mt7697_uart_write(void *arg, const u32 *buf, size_t len)
while (1) {
num_write = kernel_write(uart_info->fd_hndl, ptr, left, 0);
dev_dbg(uart_info->dev, "%s(): written(%u)\n", __func__,
num_write);
num_write);
if (num_write < 0) {
dev_err(uart_info->dev,
"%s(): kernel_write() failed(%d)\n", __func__,
num_write);
"%s(): kernel_write() failed(%d)\n", __func__,
num_write);
goto cleanup;
} else if (!num_write) {
dev_warn(uart_info->dev, "%s(): CLOSED\n", __func__);
......@@ -375,7 +375,7 @@ size_t mt7697_uart_write(void *arg, const u32 *buf, size_t len)
cleanup:
dev_dbg(uart_info->dev, "%s(): return(%u)\n", __func__, ret);
set_fs(oldfs);
mutex_unlock(&uart_info->mutex);
mutex_unlock(&uart_info->mutex);
return ret;
}
......@@ -384,9 +384,9 @@ EXPORT_SYMBOL(mt7697_uart_write);
static int mt7697_uart_probe(struct platform_device *pdev)
{
struct mt7697_uart_info* uart_info;
int ret;
int ret;
dev_info(&pdev->dev, "%s(): init\n", __func__);
dev_info(&pdev->dev, "%s(): init\n", __func__);
uart_info = kzalloc(sizeof(struct mt7697_uart_info), GFP_KERNEL);
if (!uart_info) {
......@@ -401,14 +401,14 @@ static int mt7697_uart_probe(struct platform_device *pdev)
uart_info->fd_hndl = MT7697_UART_INVALID_FD;
uart_info->dev_file = MT7697_UART_DEVICE;
mutex_init(&uart_info->mutex);
mutex_init(&uart_info->mutex);
init_waitqueue_head(&uart_info->close_wq);
INIT_WORK(&uart_info->rx_work, mt7697_uart_rx_work);
platform_set_drvdata(pdev, uart_info);
dev_info(&pdev->dev, "%s(): '%s' initialized\n", __func__,
MT7697_UART_DRVNAME);
MT7697_UART_DRVNAME);
return 0;
cleanup:
......@@ -430,7 +430,7 @@ static int mt7697_uart_remove(struct platform_device *pdev)
ret = mt7697_uart_close(uart_info);
if (ret < 0) {
dev_err(&pdev->dev, "%s(): mt7697_uart_close() failed(%ld)\n",
__func__, ret);
__func__, ret);
}
kfree(uart_info);
......@@ -443,9 +443,9 @@ static void mt7697_uart_release(struct device *dev)
}
static struct platform_device mt7697_uart_platform_device = {
.name = MT7697_UART_DRVNAME,
.id = PLATFORM_DEVID_NONE,
.dev = {
.name = MT7697_UART_DRVNAME,
.id = PLATFORM_DEVID_NONE,
.dev = {
.release = mt7697_uart_release,
},
};
......
......@@ -22,12 +22,12 @@
#include "mt7697_i.h"
#include "uart_i.h"
#define MT7697_UART_DRVNAME "mt7697serial"
#define MT7697_UART_DEVICE "/dev/ttyHS0"
#define MT7697_UART_INVALID_FD NULL
#define MT7697_UART_DRVNAME "mt7697serial"
#define MT7697_UART_DEVICE "/dev/ttyHS0"
#define MT7697_UART_INVALID_FD NULL
#define mt7697_uart_shutdown_req mt7697_cmd_hdr
#define mt7697_uart_shutdown_rsp mt7697_rsp_hdr
#define mt7697_uart_shutdown_req mt7697_cmd_hdr
#define mt7697_uart_shutdown_rsp mt7697_rsp_hdr
enum mt7697_uart_cmd_types {
MT7697_CMD_UART_SHUTDOWN_REQ = 0,
......@@ -35,20 +35,20 @@ enum mt7697_uart_cmd_types {
};
struct mt7697_uart_info {
struct platform_device *pdev;
struct device *dev;
struct platform_device *pdev;
struct device *dev;
char* dev_file;
struct file *fd_hndl;
char *dev_file;
struct file *fd_hndl;
struct mutex mutex;
struct work_struct rx_work;
struct mt7697_rsp_hdr rsp;
rx_hndlr rx_fcn;
void *rx_hndl;
struct mutex mutex;
struct work_struct rx_work;
struct mt7697_rsp_hdr rsp;
rx_hndlr rx_fcn;
void *rx_hndl;
wait_queue_head_t close_wq;
atomic_t close;
wait_queue_head_t close_wq;
atomic_t close;
};
#endif
......@@ -100,30 +100,30 @@ struct ieee80211_channel mt7697_2ghz_channels[] = {
* https://docs.labs.mediatek.com/resource/mt7687-mt7697/en/documentation
*/
struct ieee80211_channel mt7697_5ghz_a_channels[] = {
CHAN5G(36, 5180, 0),
CHAN5G(40, 5200, 0),
CHAN5G(44, 5220, 0),
CHAN5G(48, 5240, 0),
CHAN5G(52, 5260, 0),
CHAN5G(56, 5280, 0),
CHAN5G(60, 5300, 0),
CHAN5G(64, 5320, 0),
CHAN5G(100, 5500, 0),
CHAN5G(104, 5520, 0),
CHAN5G(108, 5540, 0),
CHAN5G(112, 5560, 0),
CHAN5G(116, 5580, 0),
CHAN5G(120, 5600, 0),
CHAN5G(124, 5620, 0),
CHAN5G(128, 5640, 0),
CHAN5G(132, 5660, 0),
CHAN5G(136, 5680, 0),
CHAN5G(140, 5700, 0),
CHAN5G(149, 5745, 0),
CHAN5G(153, 5765, 0),
CHAN5G(157, 5785, 0),
CHAN5G(161, 5805, 0),
CHAN5G(165, 5825, 0),
CHAN5G(36, 5180, 0),
CHAN5G(40, 5200, 0),
CHAN5G(44, 5220, 0),
CHAN5G(48, 5240, 0),
CHAN5G(52, 5260, 0),
CHAN5G(56, 5280, 0),
CHAN5G(60, 5300, 0),
CHAN5G(64, 5320, 0),
CHAN5G(100, 5500, 0),
CHAN5G(104, 5520, 0),
CHAN5G(108, 5540, 0),
CHAN5G(112, 5560, 0),
CHAN5G(116, 5580, 0),
CHAN5G(120, 5600, 0),
CHAN5G(124, 5620, 0),
CHAN5G(128, 5640, 0),
CHAN5G(132, 5660, 0),
CHAN5G(136, 5680, 0),
CHAN5G(140, 5700, 0),
CHAN5G(149, 5745, 0),
CHAN5G(153, 5765, 0),
CHAN5G(157, 5785, 0),
CHAN5G(161, 5805, 0),
CHAN5G(165, 5825, 0),
};
static struct ieee80211_supported_band mt7697_band_2ghz = {
......@@ -145,11 +145,11 @@ static struct ieee80211_supported_band mt7697_band_5ghz = {
};
static const u32 mt7697_cipher_suites[] = {
WLAN_CIPHER_SUITE_WEP40,
WLAN_CIPHER_SUITE_WEP104,
WLAN_CIPHER_SUITE_TKIP,
WLAN_CIPHER_SUITE_CCMP,
WLAN_CIPHER_SUITE_AES_CMAC,
WLAN_CIPHER_SUITE_WEP40,
WLAN_CIPHER_SUITE_WEP104,
WLAN_CIPHER_SUITE_TKIP,
WLAN_CIPHER_SUITE_CCMP,
WLAN_CIPHER_SUITE_AES_CMAC,
};
static int mt7697_set_key_mgmt(struct mt7697_vif *vif, u32 key_mgmt)
......@@ -221,7 +221,7 @@ cleanup:
}
static int mt7697_set_wpa_version(struct mt7697_vif *vif,
enum nl80211_wpa_versions wpa_version)
enum nl80211_wpa_versions wpa_version)
{
int ret = 0;
......@@ -247,8 +247,8 @@ cleanup:
}
static struct cfg80211_bss* mt7697_add_bss_if_needed(struct mt7697_vif *vif,
const u8* bssid,
u32 freq)
const u8* bssid,
u32 freq)
{
struct ieee80211_channel *chan;
struct mt7697_cfg80211_info *cfg = vif->cfg;
......@@ -334,10 +334,10 @@ cleanup:
}
static struct wireless_dev* mt7697_cfg80211_add_iface(struct wiphy *wiphy,
const char *name,
enum nl80211_iftype type,
u32 *flags,
struct vif_params *params)
const char *name,
enum nl80211_iftype type,
u32 *flags,
struct vif_params *params)
{
struct mt7697_cfg80211_info *cfg = wiphy_priv(wiphy);
struct mt7697_vif *vif;
......@@ -374,7 +374,7 @@ cleanup:
}
static int mt7697_cfg80211_del_iface(struct wiphy *wiphy,
struct wireless_dev *wdev)
struct wireless_dev *wdev)
{
struct mt7697_cfg80211_info *cfg = wiphy_priv(wiphy);
struct mt7697_vif *vif = netdev_priv(wdev->netdev);
......@@ -391,7 +391,7 @@ static int mt7697_cfg80211_del_iface(struct wiphy *wiphy,
dev_err(cfg->dev,
"%s(): mt7697_cfg80211_stop() failed(%d)\n",
__func__, ret);
goto cleanup;
goto cleanup;
}
unregister_netdev(vif->ndev);
......@@ -401,9 +401,9 @@ cleanup:
}
static int mt7697_cfg80211_change_iface(struct wiphy *wiphy,
struct net_device *ndev,
enum nl80211_iftype type, u32 *flags,
struct vif_params *params)
struct net_device *ndev,
enum nl80211_iftype type, u32 *flags,
struct vif_params *params)
{
struct mt7697_cfg80211_info *cfg = wiphy_priv(wiphy);
struct mt7697_vif *vif = netdev_priv(ndev);
......@@ -426,8 +426,8 @@ static int mt7697_cfg80211_change_iface(struct wiphy *wiphy,
dev_err(cfg->dev,
"%s(): mt7697_wr_set_op_mode_req() failed(%d)\n",
__func__, ret);
goto cleanup;
}
goto cleanup;
}
}
break;
......@@ -443,8 +443,8 @@ static int mt7697_cfg80211_change_iface(struct wiphy *wiphy,
dev_err(cfg->dev,
"%s(): mt7697_wr_set_op_mode_req() failed(%d)\n",
__func__, ret);
goto cleanup;
}
goto cleanup;
}
}
break;
......@@ -465,8 +465,8 @@ cleanup:
}
static int mt7697_cfg80211_set_txq_params(struct wiphy *wiphy,
struct net_device *ndev,
struct ieee80211_txq_params *params)
struct net_device *ndev,
struct ieee80211_txq_params *params)
{
struct mt7697_cfg80211_info *cfg = mt7697_priv(ndev);
dev_dbg(cfg->dev,
......@@ -477,7 +477,7 @@ static int mt7697_cfg80211_set_txq_params(struct wiphy *wiphy,
}
static int mt7697_cfg80211_scan(struct wiphy *wiphy,
struct cfg80211_scan_request *request)
struct cfg80211_scan_request *request)
{
struct mt7697_vif *vif = mt7697_vif_from_wdev(request->wdev);
struct mt7697_cfg80211_info *cfg = wiphy_to_cfg(wiphy);
......@@ -504,12 +504,12 @@ static int mt7697_cfg80211_scan(struct wiphy *wiphy,
GFP_KERNEL);
}
vif->scan_req = request;
ret = mt7697_wr_scan_req(cfg, vif->fw_vif_idx, request);
vif->scan_req = request;
ret = mt7697_wr_scan_req(cfg, vif->fw_vif_idx, request);
if (ret < 0) {
dev_err(cfg->dev, "%s(): mt7697_wr_scan_req() failed(%d)\n",
__func__, ret);
goto out;
goto out;
}
out:
......@@ -527,7 +527,7 @@ static int mt7697_cfg80211_connect(struct wiphy *wiphy,
}
static int mt7697_cfg80211_disconnect(struct wiphy *wiphy,
struct net_device *ndev, u16 reason_code)
struct net_device *ndev, u16 reason_code)
{
struct mt7697_cfg80211_info *cfg = mt7697_priv(ndev);
struct mt7697_vif *vif = netdev_priv(ndev);
......@@ -568,10 +568,10 @@ cleanup:
}
static int mt7697_cfg80211_add_key(struct wiphy *wiphy,
struct net_device *ndev,
u8 key_index, bool pairwise,
const u8 *mac_addr,
struct key_params *params)
struct net_device *ndev,
u8 key_index, bool pairwise,
const u8 *mac_addr,
struct key_params *params)
{
struct mt7697_cfg80211_info *cfg = mt7697_priv(ndev);
dev_dbg(cfg->dev, "%s(): ADD KEY index(%u) cipher(0x%08x)\n",
......@@ -594,7 +594,7 @@ static int mt7697_cfg80211_add_key(struct wiphy *wiphy,
}
static int mt7697_cfg80211_get_key(struct wiphy *wiphy,
struct net_device *ndev,
struct net_device *ndev,
u8 key_index, bool pairwise,
const u8 *mac_addr, void *cookie,
void (*callback) (void *cookie,
......@@ -612,9 +612,9 @@ static int mt7697_cfg80211_get_key(struct wiphy *wiphy,
}
static int mt7697_cfg80211_del_key(struct wiphy *wiphy,
struct net_device *ndev,
u8 key_index, bool pairwise,
const u8 *mac_addr)
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(%u)\n", __func__, key_index);
......@@ -622,9 +622,9 @@ static int mt7697_cfg80211_del_key(struct wiphy *wiphy,
}
static int mt7697_cfg80211_set_default_key(struct wiphy *wiphy,
struct net_device *ndev,
u8 key_index, bool unicast,
bool multicast)
struct net_device *ndev,
u8 key_index, bool unicast,
bool multicast)
{
struct mt7697_cfg80211_info *cfg = mt7697_priv(ndev);
dev_dbg(cfg->dev,
......@@ -634,8 +634,8 @@ static int mt7697_cfg80211_set_default_key(struct wiphy *wiphy,
}
static int mt7697_cfg80211_join_ibss(struct wiphy *wiphy,
struct net_device *ndev,
struct cfg80211_ibss_params *ibss_param)
struct net_device *ndev,
struct cfg80211_ibss_params *ibss_param)
{
struct mt7697_cfg80211_info *cfg = mt7697_priv(ndev);
struct mt7697_vif *vif = netdev_priv(ndev);
......@@ -651,7 +651,7 @@ static int mt7697_cfg80211_join_ibss(struct wiphy *wiphy,
}
static int mt7697_cfg80211_leave_ibss(struct wiphy *wiphy,
struct net_device *ndev)
struct net_device *ndev)
{
struct mt7697_cfg80211_info *cfg = mt7697_priv(ndev);
struct mt7697_vif *vif = netdev_priv(ndev);
......@@ -676,8 +676,8 @@ static int mt7697_cfg80211_set_wiphy_params(struct wiphy *wiphy, u32 changed)
}
static int mt7697_cfg80211_start_ap(struct wiphy *wiphy,
struct net_device *ndev,
struct cfg80211_ap_settings *settings)
struct net_device *ndev,
struct cfg80211_ap_settings *settings)
{
struct mt7697_cfg80211_info *cfg =
(struct mt7697_cfg80211_info*)wiphy_priv(wiphy);
......@@ -733,14 +733,14 @@ static int mt7697_cfg80211_start_ap(struct wiphy *wiphy,
true);
if (ret < 0) {
dev_err(cfg->dev, "mt7697_set_cipher() failed(%d)\n", ret);
goto cleanup;
goto cleanup;
}
ret = mt7697_set_cipher(vif, settings->crypto.cipher_group, false);
if (ret < 0) {
dev_err(cfg->dev, "%s: mt7697_set_cipher() failed(%d)\n",
__func__, ret);
goto cleanup;
goto cleanup;
}
if (settings->crypto.n_akm_suites) {
......@@ -749,7 +749,7 @@ static int mt7697_cfg80211_start_ap(struct wiphy *wiphy,
dev_err(cfg->dev,
"%s: mt7697_set_key_mgmt() failed(%d)\n",
__func__, ret);
goto cleanup;
goto cleanup;
}
}
......@@ -759,7 +759,7 @@ static int mt7697_cfg80211_start_ap(struct wiphy *wiphy,
dev_err(cfg->dev,
"%s: mt7697_wr_set_security_mode_req() failed(%d)\n",
__func__, ret);
goto cleanup;
goto cleanup;
}
ret = mt7697_wr_reload_settings_req(cfg, vif->fw_vif_idx);
......@@ -775,7 +775,7 @@ cleanup:
}
static int mt7697_cfg80211_stop_ap(struct wiphy *wiphy,
struct net_device *ndev)
struct net_device *ndev)
{
struct mt7697_cfg80211_info *cfg =
(struct mt7697_cfg80211_info*)wiphy_priv(wiphy);
......@@ -795,14 +795,14 @@ static int mt7697_cfg80211_change_beacon(struct wiphy *wiphy,
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,44)
static int mt7697_cfg80211_add_station(struct wiphy *wiphy,
struct net_device *ndev,
const u8 *mac,
struct station_parameters *params)
struct net_device *ndev,
const u8 *mac,
struct station_parameters *params)
#else
static int mt7697_cfg80211_add_station(struct wiphy *wiphy,
struct net_device *ndev,
u8 *mac,
struct station_parameters *params)
struct net_device *ndev,
u8 *mac,
struct station_parameters *params)
#endif
{
struct mt7697_cfg80211_info *cfg = mt7697_priv(ndev);
......@@ -818,14 +818,14 @@ static int mt7697_cfg80211_add_station(struct wiphy *wiphy,
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,44)
static int mt7697_cfg80211_get_station(struct wiphy *wiphy,
struct net_device *ndev,
const u8 *mac,
struct station_info *sinfo)
struct net_device *ndev,
const u8 *mac,
struct station_info *sinfo)
#else
static int mt7697_cfg80211_get_station(struct wiphy *wiphy,
struct net_device *ndev,
u8 *mac,
struct station_info *sinfo)
struct net_device *ndev,
u8 *mac,
struct station_info *sinfo)
#endif
{
struct mt7697_cfg80211_info *cfg = mt7697_priv(ndev);
......@@ -841,15 +841,15 @@ static int mt7697_cfg80211_get_station(struct wiphy *wiphy,
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,44)
static int mt7697_cfg80211_del_station(struct wiphy *wiphy,
struct net_device *ndev,
struct net_device *ndev,
struct station_del_parameters *params)
#else
static int mt7697_cfg80211_del_station(struct wiphy *wiphy,
struct net_device *ndev,
struct net_device *ndev,
u8 *mac)
#endif
{
struct mt7697_cfg80211_info *cfg = mt7697_priv(ndev);
struct mt7697_cfg80211_info *cfg = mt7697_priv(ndev);
dev_dbg(cfg->dev, "%s(): DEL STATION\n", __func__);
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,18,44)
......@@ -863,14 +863,14 @@ static int mt7697_cfg80211_del_station(struct wiphy *wiphy,
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,44)
static int mt7697_cfg80211_change_station(struct wiphy *wiphy,
struct net_device *ndev,
const u8 *mac,
struct station_parameters *params)
struct net_device *ndev,
const u8 *mac,
struct station_parameters *params)
#else
static int mt7697_cfg80211_change_station(struct wiphy *wiphy,
struct net_device *ndev,
u8 *mac,
struct station_parameters *params)
struct net_device *ndev,
u8 *mac,
struct station_parameters *params)
#endif
{
struct mt7697_cfg80211_info *cfg = mt7697_priv(ndev);
......@@ -907,8 +907,8 @@ cleanup:
}
static int mt7697_cfg80211_set_pmksa(struct wiphy *wiphy,
struct net_device *ndev,
struct cfg80211_pmksa *pmksa)
struct net_device *ndev,
struct cfg80211_pmksa *pmksa)
{
struct mt7697_cfg80211_info *cfg = wiphy_to_cfg(wiphy);
dev_dbg(cfg->dev, "%s(): SET PMKSA\n", __func__);
......@@ -916,8 +916,8 @@ static int mt7697_cfg80211_set_pmksa(struct wiphy *wiphy,
}
static int mt7697_cfg80211_del_pmksa(struct wiphy *wiphy,
struct net_device *ndev,
struct cfg80211_pmksa *pmksa)
struct net_device *ndev,
struct cfg80211_pmksa *pmksa)
{
struct mt7697_cfg80211_info *cfg = wiphy_to_cfg(wiphy);
dev_dbg(cfg->dev, "%s(): DEL PMKSA\n", __func__);
......@@ -925,7 +925,7 @@ static int mt7697_cfg80211_del_pmksa(struct wiphy *wiphy,
}
static int mt7697_cfg80211_flush_pmksa(struct wiphy *wiphy,
struct net_device *ndev)
struct net_device *ndev)
{
struct mt7697_cfg80211_info *cfg = wiphy_to_cfg(wiphy);
dev_dbg(cfg->dev, "%s(): FLUSH PMKSA\n", __func__);
......@@ -933,31 +933,31 @@ static int mt7697_cfg80211_flush_pmksa(struct wiphy *wiphy,
}
static int mt7697_cfg80211_remain_on_channel(struct wiphy *wiphy,
struct wireless_dev *wdev,
struct ieee80211_channel *chan,
unsigned int duration,
u64 *cookie)
struct wireless_dev *wdev,
struct ieee80211_channel *chan,
unsigned int duration,
u64 *cookie)
{
struct mt7697_cfg80211_info *cfg = wiphy_to_cfg(wiphy);
struct mt7697_cfg80211_info *cfg = wiphy_to_cfg(wiphy);
dev_dbg(cfg->dev, "%s(): REMAIN ON CH\n", __func__);
return 0;
}
static int mt7697_cfg80211_cancel_remain_on_channel(struct wiphy *wiphy,
struct wireless_dev *wdev,
u64 cookie)
struct wireless_dev *wdev,
u64 cookie)
{
struct mt7697_cfg80211_info *cfg = wiphy_to_cfg(wiphy);
struct mt7697_cfg80211_info *cfg = wiphy_to_cfg(wiphy);
dev_dbg(cfg->dev, "%s(): CANCEL REMAIN ON CH\n", __func__);
return 0;
}
static int mt7697_cfg80211_mgmt_tx(struct wiphy *wiphy,
struct wireless_dev *wdev,
struct cfg80211_mgmt_tx_params *params,
u64 *cookie)
struct wireless_dev *wdev,
struct cfg80211_mgmt_tx_params *params,
u64 *cookie)
{
struct mt7697_cfg80211_info *cfg = wiphy_to_cfg(wiphy);
struct mt7697_cfg80211_info *cfg = wiphy_to_cfg(wiphy);
dev_dbg(cfg->dev, "%s(): MGMT TX len(%u)\n", __func__, params->len);
print_hex_dump(KERN_DEBUG, DRVNAME" MGMT Tx ", DUMP_PREFIX_OFFSET,
......@@ -967,11 +967,11 @@ static int mt7697_cfg80211_mgmt_tx(struct wiphy *wiphy,
}
static void mt7697_cfg80211_mgmt_frame_register(struct wiphy *wiphy,
struct wireless_dev *wdev,
u16 frame_type, bool reg)
struct wireless_dev *wdev,
u16 frame_type, bool reg)
{
struct mt7697_vif *vif = mt7697_vif_from_wdev(wdev);
struct mt7697_cfg80211_info *cfg = wiphy_to_cfg(wiphy);
struct mt7697_cfg80211_info *cfg = wiphy_to_cfg(wiphy);
dev_dbg(cfg->dev, "%s(): MGMT FRAME REG type(0x%04x) reg(%u)\n",
__func__, frame_type, reg);
......@@ -987,34 +987,34 @@ static void mt7697_cfg80211_mgmt_frame_register(struct wiphy *wiphy,
static const struct cfg80211_ops mt7697_cfg80211_ops =
{
.add_virtual_intf = mt7697_cfg80211_add_iface,
.del_virtual_intf = mt7697_cfg80211_del_iface,
.change_virtual_intf = mt7697_cfg80211_change_iface,
.set_txq_params = mt7697_cfg80211_set_txq_params,
.scan = mt7697_cfg80211_scan,
.connect = mt7697_cfg80211_connect,
.disconnect = mt7697_cfg80211_disconnect,
.add_key = mt7697_cfg80211_add_key,
.get_key = mt7697_cfg80211_get_key,
.del_key = mt7697_cfg80211_del_key,
.set_default_key = mt7697_cfg80211_set_default_key,
.join_ibss = mt7697_cfg80211_join_ibss,
.leave_ibss = mt7697_cfg80211_leave_ibss,
.set_wiphy_params = mt7697_cfg80211_set_wiphy_params,
.start_ap = mt7697_cfg80211_start_ap,
.stop_ap = mt7697_cfg80211_stop_ap,
.change_beacon = mt7697_cfg80211_change_beacon,
.add_station = mt7697_cfg80211_add_station,
.get_station = mt7697_cfg80211_get_station,
.del_station = mt7697_cfg80211_del_station,
.change_station = mt7697_cfg80211_change_station,
.set_pmksa = mt7697_cfg80211_set_pmksa,
.del_pmksa = mt7697_cfg80211_del_pmksa,
.flush_pmksa = mt7697_cfg80211_flush_pmksa,
.remain_on_channel = mt7697_cfg80211_remain_on_channel,
.cancel_remain_on_channel = mt7697_cfg80211_cancel_remain_on_channel,
.mgmt_tx = mt7697_cfg80211_mgmt_tx,
.mgmt_frame_register = mt7697_cfg80211_mgmt_frame_register,
.add_virtual_intf = mt7697_cfg80211_add_iface,
.del_virtual_intf = mt7697_cfg80211_del_iface,
.change_virtual_intf = mt7697_cfg80211_change_iface,
.set_txq_params = mt7697_cfg80211_set_txq_params,
.scan = mt7697_cfg80211_scan,
.connect = mt7697_cfg80211_connect,
.disconnect = mt7697_cfg80211_disconnect,
.add_key = mt7697_cfg80211_add_key,
.get_key = mt7697_cfg80211_get_key,
.del_key = mt7697_cfg80211_del_key,
.set_default_key = mt7697_cfg80211_set_default_key,
.join_ibss = mt7697_cfg80211_join_ibss,
.leave_ibss = mt7697_cfg80211_leave_ibss,
.set_wiphy_params = mt7697_cfg80211_set_wiphy_params,
.start_ap = mt7697_cfg80211_start_ap,
.stop_ap = mt7697_cfg80211_stop_ap,
.change_beacon = mt7697_cfg80211_change_beacon,
.add_station = mt7697_cfg80211_add_station,
.get_station = mt7697_cfg80211_get_station,
.del_station = mt7697_cfg80211_del_station,
.change_station = mt7697_cfg80211_change_station,
.set_pmksa = mt7697_cfg80211_set_pmksa,
.del_pmksa = mt7697_cfg80211_del_pmksa,
.flush_pmksa = mt7697_cfg80211_flush_pmksa,
.remain_on_channel = mt7697_cfg80211_remain_on_channel,
.cancel_remain_on_channel = mt7697_cfg80211_cancel_remain_on_channel,
.mgmt_tx = mt7697_cfg80211_mgmt_tx,
.mgmt_frame_register = mt7697_cfg80211_mgmt_frame_register,
};
int mt7697_cfg80211_stop(struct mt7697_vif *vif)
......@@ -1093,8 +1093,8 @@ int mt7697_cfg80211_stop(struct mt7697_vif *vif)
dev_err(vif->cfg->dev,
"%s(): mt7697_wr_set_op_mode_req() failed(%d)\n",
__func__, ret);
goto cleanup;
}
goto cleanup;
}
memset(vif->ssid, 0, IEEE80211_MAX_SSID_LEN);
memset(vif->req_bssid, 0, ETH_ALEN);
......@@ -1115,7 +1115,7 @@ int mt7697_cfg80211_stop(struct mt7697_vif *vif)
__func__, ret);
}
vif->cfg->txq_hdl = NULL;
vif->cfg->txq_hdl = NULL;
vif->cfg->rxq_hdl = NULL;
cleanup:
......@@ -1124,7 +1124,7 @@ cleanup:
static const struct ieee80211_txrx_stypes
mt7697_txrx_stypes[NUM_NL80211_IFTYPES] = {
[NL80211_IFTYPE_STATION] = {
[NL80211_IFTYPE_STATION] = {
.tx = BIT(IEEE80211_STYPE_ACTION >> 4) |
BIT(IEEE80211_STYPE_PROBE_RESP >> 4),
.rx = BIT(IEEE80211_STYPE_ACTION >> 4) |
......@@ -1151,8 +1151,8 @@ static int mt7697_cfg80211_vif_init(struct mt7697_vif *vif)
static void mt7697_cfg80211_disconnect_work(struct work_struct *work)
{
struct mt7697_vif *vif = container_of(work, struct mt7697_vif,
disconnect_work);
struct mt7697_vif *vif = container_of(work, struct mt7697_vif,
disconnect_work);
struct mt7697_cfg80211_info *cfg = vif->cfg;
int ret;
......@@ -1203,7 +1203,7 @@ static void mt7697_cleanup_vif(struct mt7697_cfg80211_info *cfg)
}
struct mt7697_vif* mt7697_get_vif_by_idx(struct mt7697_cfg80211_info *cfg,
u32 if_idx)
u32 if_idx)
{
struct mt7697_vif *vif, *found = NULL;
......@@ -1227,7 +1227,7 @@ struct mt7697_vif* mt7697_get_vif_by_idx(struct mt7697_cfg80211_info *cfg,
struct wireless_dev* mt7697_interface_add(struct mt7697_cfg80211_info *cfg,
const char *name,
enum nl80211_iftype type,
enum nl80211_iftype type,
u8 fw_vif_idx)
{
struct net_device *ndev;
......@@ -1239,19 +1239,19 @@ struct wireless_dev* mt7697_interface_add(struct mt7697_cfg80211_info *cfg,
if (list_empty(&cfg->vif_list)) {
ndev = alloc_etherdev(sizeof(struct mt7697_vif));
if (!ndev) {
dev_err(cfg->dev, "%s(): alloc_etherdev() failed\n",
__func__);
if (!ndev) {
dev_err(cfg->dev, "%s(): alloc_etherdev() failed\n",
__func__);
goto err;
}
}
err = dev_alloc_name(ndev, name);
if (err < 0) {
dev_err(cfg->dev,
"%s(): dev_alloc_name() failed(%d)\n", __func__,
err);
if (err < 0) {
dev_err(cfg->dev,
"%s(): dev_alloc_name() failed(%d)\n", __func__,
err);
goto err;
}
}
vif = netdev_priv(ndev);
ndev->ieee80211_ptr = &vif->wdev;
......@@ -1388,7 +1388,7 @@ cleanup:
}
int mt7697_cfg80211_connect_event(struct mt7697_vif *vif, const u8* bssid,
u32 channel)
u32 channel)
{
struct mt7697_cfg80211_info *cfg = vif->cfg;
struct wiphy *wiphy = cfg_to_wiphy(cfg);
......@@ -1403,10 +1403,10 @@ int mt7697_cfg80211_connect_event(struct mt7697_vif *vif, const u8* bssid,
clear_bit(CONNECT_PEND, &vif->flags);
dev_dbg(cfg->dev, "%s(): vif flags(0x%08lx)\n", __func__, vif->flags);
if (bssid) {
print_hex_dump(KERN_DEBUG, DRVNAME" BSSID ",
DUMP_PREFIX_OFFSET, 16, 1, bssid, ETH_ALEN, 0);
}
if (bssid) {
print_hex_dump(KERN_DEBUG, DRVNAME" BSSID ",
DUMP_PREFIX_OFFSET, 16, 1, bssid, ETH_ALEN, 0);
}
if ((channel > 0) && (channel <= MT7697_CH_MAX_2G_CHANNEL)) {
band = wiphy->bands[IEEE80211_BAND_2GHZ];
......@@ -1530,17 +1530,17 @@ int mt7697_cfg80211_init(struct mt7697_cfg80211_info *cfg)
cfg->wireless_mode = MT7697_WIFI_PHY_11ABGN_MIXED;
wiphy->mgmt_stypes = mt7697_txrx_stypes;
wiphy->max_remain_on_channel_duration = 5000;
wiphy->max_remain_on_channel_duration = 5000;
set_wiphy_dev(wiphy, cfg->dev);
wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) |
BIT(NL80211_IFTYPE_ADHOC) |
BIT(NL80211_IFTYPE_AP);
wiphy->interface_modes = (BIT(NL80211_IFTYPE_STATION) |
BIT(NL80211_IFTYPE_ADHOC) |
BIT(NL80211_IFTYPE_AP));
wiphy->max_scan_ssids = MT7697_SCAN_MAX_ITEMS;
wiphy->max_scan_ie_len = IEEE80211_MAX_SSID_LEN;
wiphy->max_scan_ssids = MT7697_SCAN_MAX_ITEMS;
wiphy->max_scan_ie_len = IEEE80211_MAX_SSID_LEN;
wiphy->max_scan_ie_len = 1000; /* FIX: what is correct limit? */
wiphy->max_scan_ie_len = 1000; /* FIX: what is correct limit? */
switch (cfg->wireless_mode) {
case MT7697_WIFI_PHY_11AN_MIXED:
case MT7697_WIFI_PHY_11N_5G:
......@@ -1589,8 +1589,8 @@ int mt7697_cfg80211_init(struct mt7697_cfg80211_info *cfg)
wiphy->bands[IEEE80211_BAND_5GHZ] = band_5gig ? &mt7697_band_5ghz : NULL;
wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
wiphy->cipher_suites = mt7697_cipher_suites;
wiphy->n_cipher_suites = ARRAY_SIZE(mt7697_cipher_suites);
wiphy->cipher_suites = mt7697_cipher_suites;
wiphy->n_cipher_suites = ARRAY_SIZE(mt7697_cipher_suites);
#ifdef CONFIG_PM
wiphy->wowlan = &mt7697_wowlan_support;
......@@ -1605,18 +1605,18 @@ int mt7697_cfg80211_init(struct mt7697_cfg80211_info *cfg)
NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS2 |
NL80211_PROBE_RESP_OFFLOAD_SUPPORT_P2P;
err = wiphy_register(wiphy);
if (err < 0) {
dev_err(cfg->dev, "%s(): wiphy_register() failed(%d)\n",
__func__, err);
goto cleanup;
}
err = wiphy_register(wiphy);
if (err < 0) {
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;
return err;
}
void mt7697_cfg80211_cleanup(struct mt7697_cfg80211_info *cfg)
......
......@@ -66,19 +66,19 @@ enum mt7697_sme_state {
};
enum mt7697_vif_state {
CONNECTED,
CONNECT_PEND,
WMM_ENABLED,
NETQ_STOPPED,
DTIM_EXPIRED,
CLEAR_BSSFILTER_ON_BEACON,
DTIM_PERIOD_AVAIL,
WLAN_ENABLED,
STATS_UPDATE_PEND,
HOST_SLEEP_MODE_CMD_PROCESSED,
NETDEV_MCAST_ALL_ON,
NETDEV_MCAST_ALL_OFF,
SCHED_SCANNING,
CONNECTED,
CONNECT_PEND,
WMM_ENABLED,
NETQ_STOPPED,
DTIM_EXPIRED,
CLEAR_BSSFILTER_ON_BEACON,
DTIM_PERIOD_AVAIL,
WLAN_ENABLED,
STATS_UPDATE_PEND,
HOST_SLEEP_MODE_CMD_PROCESSED,
NETDEV_MCAST_ALL_ON,
NETDEV_MCAST_ALL_OFF,
SCHED_SCANNING,
};
struct mt7697_tx_pkt {
......@@ -88,7 +88,7 @@ struct mt7697_tx_pkt {
struct mt7697_cfg80211_info {
struct device *dev;
struct wiphy *wiphy;
struct wiphy *wiphy;
struct semaphore sem;
struct platform_device *hif_priv;
......@@ -196,12 +196,12 @@ struct mt7697_vif {
static inline struct wiphy *cfg_to_wiphy(struct mt7697_cfg80211_info *cfg)
{
return cfg->wiphy;
return cfg->wiphy;
}
static inline struct mt7697_cfg80211_info *wiphy_to_cfg(struct wiphy *w)
{
return (struct mt7697_cfg80211_info *)(wiphy_priv(w));
return (struct mt7697_cfg80211_info *)(wiphy_priv(w));
}
static inline struct mt7697_cfg80211_info *mt7697_priv(struct net_device *ndev)
......@@ -211,7 +211,7 @@ static inline struct mt7697_cfg80211_info *mt7697_priv(struct net_device *ndev)
static inline struct mt7697_vif *mt7697_vif_from_wdev(struct wireless_dev *wdev)
{
return container_of(wdev, struct mt7697_vif, wdev);
return container_of(wdev, struct mt7697_vif, wdev);
}
void mt7697_init_netdev(struct net_device*);
......
......@@ -38,27 +38,27 @@ static int mt7697_wext_siwfreq(struct net_device *ndev,
int ret = 0;
if ((frq->e == 0) && (frq->m <= 1000)) {
/* Setting by channel number */
chan = frq->m;
/* Setting by channel number */
chan = frq->m;
dev_dbg(cfg->dev, "%s(): freq(%u)\n", __func__, frq->m);
} else {
/* Setting by frequency */
} else {
/* Setting by frequency */
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,44)
if (frq->e == 1 &&
frq->m / 100000 >= freq_list[0] &&
frq->m / 100000 <= freq_list[FREQ_COUNT - 1]) {
int ch;
int fr = frq->m / 100000;
for (ch = 0; ch < FREQ_COUNT; ch++) {
if (fr == freq_list[ch]) {
frq->e = 0;
frq->m = ch + 1;
break;
}
}
}
if (frq->e != 0 || frq->m < 1 || frq->m > FREQ_COUNT) {
if (frq->e == 1 &&
frq->m / 100000 >= freq_list[0] &&
frq->m / 100000 <= freq_list[FREQ_COUNT - 1]) {
int ch;
int fr = frq->m / 100000;
for (ch = 0; ch < FREQ_COUNT; ch++) {
if (fr == freq_list[ch]) {
frq->e = 0;
frq->m = ch + 1;
break;
}
}
}
if (frq->e != 0 || frq->m < 1 || frq->m > FREQ_COUNT) {
dev_err(cfg->dev,
"%s(): unsupported frequency(%u/%u)\n",
__func__, frq->e, frq->m);
......@@ -66,19 +66,19 @@ static int mt7697_wext_siwfreq(struct net_device *ndev,
goto cleanup;
}
chan = frq->m;
chan = frq->m;
#else
int denom = 1;
int i;
int denom = 1;
int i;
/* Calculate denominator to rescale to MHz */
for (i = 0; i < (6 - frq->e); i++)
denom *= 10;
/* Calculate denominator to rescale to MHz */
for (i = 0; i < (6 - frq->e); i++)
denom *= 10;
chan = ieee80211_freq_to_dsss_chan(frq->m / denom);
chan = ieee80211_freq_to_dsss_chan(frq->m / denom);
#endif
dev_dbg(cfg->dev, "%s(): chan(%u)\n", __func__, chan);
}
}
vif->ch_hint = chan;
......@@ -99,26 +99,26 @@ static int mt7697_wext_giwfreq(struct net_device *ndev,
}
static int mt7697_wext_siwmode(struct net_device *ndev,
struct iw_request_info *info,
struct iw_request_info *info,
u32 *mode, char *extra)
{
struct mt7697_cfg80211_info *cfg = mt7697_priv(ndev);
struct wireless_dev *wdev = ndev->ieee80211_ptr;
struct wireless_dev *wdev = ndev->ieee80211_ptr;
struct mt7697_vif *vif = mt7697_vif_from_wdev(wdev);
int ret = 0;
int ret = 0;
dev_dbg(cfg->dev, "%s(): mode(%u)\n", __func__, *mode);
switch (*mode) {
dev_dbg(cfg->dev, "%s(): mode(%u)\n", __func__, *mode);
switch (*mode) {
case IW_MODE_MASTER:
if (cfg->wifi_cfg.opmode != MT7697_WIFI_MODE_AP_ONLY) {
if ((cfg->wifi_cfg.opmode == MT7697_WIFI_MODE_STA_ONLY) &&
(test_bit(CONNECTED, &vif->flags) ||
test_bit(CONNECT_PEND, &vif->flags))) {
dev_err(cfg->dev,
"%s(): STA interface connected\n",
__func__);
"%s(): STA interface connected\n",
__func__);
ret = -EBUSY;
goto cleanup;
goto cleanup;
}
cfg->wifi_cfg.opmode = MT7697_WIFI_MODE_AP_ONLY;
......@@ -126,8 +126,8 @@ static int mt7697_wext_siwmode(struct net_device *ndev,
vif->wdev.iftype = NL80211_IFTYPE_AP;
}
break;
case IW_MODE_INFRA:
break;
case IW_MODE_INFRA:
if (cfg->wifi_cfg.opmode != MT7697_WIFI_MODE_STA_ONLY) {
if ((cfg->wifi_cfg.opmode == MT7697_WIFI_MODE_AP_ONLY) &&
!list_empty(&cfg->vif_list)) {
......@@ -135,7 +135,7 @@ static int mt7697_wext_siwmode(struct net_device *ndev,
"%s(): AP interface connected STAs\n",
__func__);
ret = -EBUSY;
goto cleanup;
goto cleanup;
}
cfg->wifi_cfg.opmode = MT7697_WIFI_MODE_STA_ONLY;
......@@ -143,113 +143,113 @@ static int mt7697_wext_siwmode(struct net_device *ndev,
vif->wdev.iftype = NL80211_IFTYPE_STATION;
}
break;
default:
dev_err(cfg->dev, "%s(): unsupported mode(%u)\n",
__func__, *mode);
ret = -EINVAL;
break;
default:
dev_err(cfg->dev, "%s(): unsupported mode(%u)\n",
__func__, *mode);
ret = -EINVAL;
goto cleanup;
}
}
cleanup:
return ret;
}
static int mt7697_wext_giwrange(struct net_device *ndev,
struct iw_request_info *info,
struct iw_request_info *info,
struct iw_point *dwrq, char *extra)
{
struct mt7697_cfg80211_info *cfg = mt7697_priv(ndev);
struct wiphy *wiphy = cfg->wiphy;
struct iw_range *range = (struct iw_range *) extra;
int i;
struct iw_range *range = (struct iw_range *) extra;
int i;
dev_dbg(cfg->dev, "%s():\n", __func__);
memset(range, 0, sizeof (struct iw_range));
dwrq->length = sizeof (struct iw_range);
/* set the wireless extension version number */
range->we_version_source = SUPPORTED_WIRELESS_EXT;
range->we_version_compiled = WIRELESS_EXT;
/* Now the encoding capabilities */
range->num_encoding_sizes = 3;
/* 64(40) bits WEP */
range->encoding_size[0] = 5;
/* 128(104) bits WEP */
range->encoding_size[1] = 13;
/* 256 bits for WPA-PSK */
range->encoding_size[2] = 32;
/* 4 keys are allowed */
range->max_encoding_tokens = 4;
/* we don't know the quality range... */
range->max_qual.level = 0;
range->max_qual.noise = 0;
range->max_qual.qual = 0;
/* these value describe an average quality. Needs more tweaking... */
range->avg_qual.level = -80; /* -80 dBm */
range->avg_qual.noise = 0; /* don't know what to put here */
range->avg_qual.qual = 0;
range->sensitivity = 200;
/* retry limit capabilities */
range->retry_capa = IW_RETRY_LIMIT | IW_RETRY_LIFETIME;
range->retry_flags = IW_RETRY_LIMIT;
range->r_time_flags = IW_RETRY_LIFETIME;
/* I don't know the range. Put stupid things here */
range->min_retry = 1;
range->max_retry = 65535;
range->min_r_time = 1024;
range->max_r_time = 65535 * 1024;
/* txpower is supported in dBm's */
range->txpower_capa = IW_TXPOW_DBM;
/* Event capability (kernel + driver) */
range->event_capa[0] = IW_EVENT_CAPA_K_0;
range->event_capa[1] = IW_EVENT_CAPA_K_1;
range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_4WAY_HANDSHAKE;
range->num_channels = wiphy->bands[IEEE80211_BAND_2GHZ]->n_channels +
wiphy->bands[IEEE80211_BAND_5GHZ]->n_channels;
range->num_frequency = wiphy->bands[IEEE80211_BAND_2GHZ]->n_channels +
wiphy->bands[IEEE80211_BAND_5GHZ]->n_channels;
for (i = 0; i < wiphy->bands[IEEE80211_BAND_2GHZ]->n_channels; i++) {
range->freq[i].m =
wiphy->bands[IEEE80211_BAND_2GHZ]->channels[i].center_freq;
range->freq[i].e = 6;
range->freq[i].i =
wiphy->bands[IEEE80211_BAND_2GHZ]->channels[i].hw_value;
}
memset(range, 0, sizeof (struct iw_range));
dwrq->length = sizeof (struct iw_range);
/* set the wireless extension version number */
range->we_version_source = SUPPORTED_WIRELESS_EXT;
range->we_version_compiled = WIRELESS_EXT;
/* Now the encoding capabilities */
range->num_encoding_sizes = 3;
/* 64(40) bits WEP */
range->encoding_size[0] = 5;
/* 128(104) bits WEP */
range->encoding_size[1] = 13;
/* 256 bits for WPA-PSK */
range->encoding_size[2] = 32;
/* 4 keys are allowed */
range->max_encoding_tokens = 4;
/* we don't know the quality range... */
range->max_qual.level = 0;
range->max_qual.noise = 0;
range->max_qual.qual = 0;
/* these value describe an average quality. Needs more tweaking... */
range->avg_qual.level = -80; /* -80 dBm */
range->avg_qual.noise = 0; /* don't know what to put here */
range->avg_qual.qual = 0;
range->sensitivity = 200;
/* retry limit capabilities */
range->retry_capa = IW_RETRY_LIMIT | IW_RETRY_LIFETIME;
range->retry_flags = IW_RETRY_LIMIT;
range->r_time_flags = IW_RETRY_LIFETIME;
/* I don't know the range. Put stupid things here */
range->min_retry = 1;
range->max_retry = 65535;
range->min_r_time = 1024;
range->max_r_time = 65535 * 1024;
/* txpower is supported in dBm's */
range->txpower_capa = IW_TXPOW_DBM;
/* Event capability (kernel + driver) */
range->event_capa[0] = IW_EVENT_CAPA_K_0;
range->event_capa[1] = IW_EVENT_CAPA_K_1;
range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_4WAY_HANDSHAKE;
range->num_channels = wiphy->bands[IEEE80211_BAND_2GHZ]->n_channels +
wiphy->bands[IEEE80211_BAND_5GHZ]->n_channels;
range->num_frequency = wiphy->bands[IEEE80211_BAND_2GHZ]->n_channels +
wiphy->bands[IEEE80211_BAND_5GHZ]->n_channels;
for (i = 0; i < wiphy->bands[IEEE80211_BAND_2GHZ]->n_channels; i++) {
range->freq[i].m =
wiphy->bands[IEEE80211_BAND_2GHZ]->channels[i].center_freq;
range->freq[i].e = 6;
range->freq[i].i =
wiphy->bands[IEEE80211_BAND_2GHZ]->channels[i].hw_value;
}
for (i = 0; i < wiphy->bands[IEEE80211_BAND_5GHZ]->n_channels; i++) {
range->freq[i].m =
wiphy->bands[IEEE80211_BAND_5GHZ]->channels[i].center_freq;
range->freq[i].e = 6;
range->freq[i].i =
wiphy->bands[IEEE80211_BAND_5GHZ]->channels[i].hw_value;
}
range->freq[i].m =
wiphy->bands[IEEE80211_BAND_5GHZ]->channels[i].center_freq;
range->freq[i].e = 6;
range->freq[i].i =
wiphy->bands[IEEE80211_BAND_5GHZ]->channels[i].hw_value;
}
range->num_bitrates = wiphy->bands[IEEE80211_BAND_2GHZ]->n_bitrates +
wiphy->bands[IEEE80211_BAND_5GHZ]->n_bitrates;
for (i = 0; i < wiphy->bands[IEEE80211_BAND_2GHZ]->n_bitrates; i++) {
range->bitrate[i] =
wiphy->bands[IEEE80211_BAND_5GHZ]->n_bitrates;
for (i = 0; i < wiphy->bands[IEEE80211_BAND_2GHZ]->n_bitrates; i++) {
range->bitrate[i] =
wiphy->bands[IEEE80211_BAND_2GHZ]->bitrates[i].bitrate * 100000;
}
}
for (i = 0; i < wiphy->bands[IEEE80211_BAND_5GHZ]->n_bitrates; i++) {
range->bitrate[i] =
for (i = 0; i < wiphy->bands[IEEE80211_BAND_5GHZ]->n_bitrates; i++) {
range->bitrate[i] =
wiphy->bands[IEEE80211_BAND_5GHZ]->bitrates[i].bitrate * 100000;
}
}
return 0;
return 0;
}
static int mt7697_wext_siwap(struct net_device *ndev,
......@@ -301,34 +301,34 @@ static int mt7697_wext_siwessid(struct net_device *ndev,
struct mt7697_cfg80211_info *cfg = mt7697_priv(ndev);
struct wireless_dev *wdev = ndev->ieee80211_ptr;
struct mt7697_vif *vif = mt7697_vif_from_wdev(wdev);
size_t len = data->length;
int ret = 0;
size_t len = data->length;
int ret = 0;
dev_dbg(cfg->dev, "%s(): iftype(%u) ssid('%s')\n",
__func__, wdev->iftype, ssid);
/* call only for station! */
if (WARN_ON((wdev->iftype != NL80211_IFTYPE_STATION) &&
/* call only for station! */
if (WARN_ON((wdev->iftype != NL80211_IFTYPE_STATION) &&
(wdev->iftype != NL80211_IFTYPE_AP))) {
dev_warn(cfg->dev, "%s(): unsupported iftype(%u)\n",
__func__, wdev->iftype);
ret = -EINVAL;
ret = -EINVAL;
goto cleanup;
}
if (!data->flags)
len = 0;
if (!data->flags)
len = 0;
/* iwconfig uses nul termination in SSID.. */
if (len > 0 && ssid[len - 1] == '\0')
len--;
/* iwconfig uses nul termination in SSID.. */
if (len > 0 && ssid[len - 1] == '\0')
len--;
memset(vif->ssid, 0, sizeof(vif->ssid));
vif->ssid_len = len;
memcpy(vif->ssid, ssid, len);
memcpy(wdev->ssid, ssid, len);
wdev->ssid_len = len;
wdev->ssid_len = len;
if (vif->ssid_len > 0) {
ret = mt7697_wr_set_op_mode_req(cfg);
......@@ -336,8 +336,8 @@ static int mt7697_wext_siwessid(struct net_device *ndev,
dev_err(cfg->dev,
"%s(): mt7697_wr_set_op_mode_req() failed(%d)\n",
__func__, ret);
goto cleanup;
}
goto cleanup;
}
}
ret = mt7697_wr_set_ssid_req(cfg, len, ssid);
......@@ -395,7 +395,7 @@ static int mt7697_wext_siwessid(struct net_device *ndev,
goto cleanup;
}
set_bit(CONNECT_PEND, &vif->flags);
set_bit(CONNECT_PEND, &vif->flags);
vif->sme_state = SME_CONNECTING;
if (test_bit(DESTROY_IN_PROGRESS, &cfg->flag)) {
......@@ -405,24 +405,23 @@ static int mt7697_wext_siwessid(struct net_device *ndev,
goto cleanup;
}
ret = mt7697_wr_reload_settings_req(cfg, vif->fw_vif_idx);
ret = mt7697_wr_reload_settings_req(cfg, vif->fw_vif_idx);
if (ret < 0) {
dev_err(cfg->dev,
"%s(): mt7697_wr_reload_settings_req() failed(%d)\n",
__func__, ret);
goto cleanup;
}
}
else if ((cfg->wifi_cfg.opmode == MT7697_WIFI_MODE_STA_ONLY) &&
test_bit(CONNECTED, &vif->flags)) {
ret = mt7697_wr_disconnect_req(vif->cfg, NULL);
} else if ((cfg->wifi_cfg.opmode == MT7697_WIFI_MODE_STA_ONLY) &&
test_bit(CONNECTED, &vif->flags)) {
ret = mt7697_wr_disconnect_req(vif->cfg, NULL);
if (ret < 0) {
dev_err(vif->cfg->dev,
"%s(): mt7697_wr_disconnect_req() failed(%d)\n",
__func__, ret);
goto cleanup;
}
}
}
cleanup:
return ret;
......@@ -543,14 +542,14 @@ static int mt7697_wext_siwencodeext(struct net_device *ndev,
struct wireless_dev *wdev = ndev->ieee80211_ptr;
struct mt7697_vif *vif = mt7697_vif_from_wdev(wdev);
struct iw_encode_ext *ext = (struct iw_encode_ext *) extra;
int ret = 0;
int ret = 0;
dev_dbg(cfg->dev, "%s(): iftype(%u)\n", __func__, wdev->iftype);
if (wdev->iftype != NL80211_IFTYPE_STATION &&
wdev->iftype != NL80211_IFTYPE_AP) {
if (wdev->iftype != NL80211_IFTYPE_STATION &&
wdev->iftype != NL80211_IFTYPE_AP) {
dev_err(cfg->dev, "%s(): iftype(%d) not supported\n",
__func__, wdev->iftype);
ret = -EOPNOTSUPP;
ret = -EOPNOTSUPP;
goto cleanup;
}
......@@ -559,7 +558,7 @@ static int mt7697_wext_siwencodeext(struct net_device *ndev,
print_hex_dump(KERN_DEBUG, DRVNAME" PMK ",
DUMP_PREFIX_OFFSET, 16, 1, ext->key, ext->key_len, 0);
memcpy(vif->pmk, ext->key, ext->key_len);
}
}
cleanup:
return ret;
......@@ -576,40 +575,40 @@ static int mt7697_wext_giwencodeext(struct net_device *ndev,
}
static const iw_handler mt7697_wireless_handler[] = {
[IW_IOCTL_IDX(SIOCGIWNAME)] = (iw_handler) cfg80211_wext_giwname,
[IW_IOCTL_IDX(SIOCSIWFREQ)] = (iw_handler) mt7697_wext_siwfreq,
[IW_IOCTL_IDX(SIOCGIWFREQ)] = (iw_handler) mt7697_wext_giwfreq,
[IW_IOCTL_IDX(SIOCSIWMODE)] = (iw_handler) mt7697_wext_siwmode,
[IW_IOCTL_IDX(SIOCGIWMODE)] = (iw_handler) cfg80211_wext_giwmode,
[IW_IOCTL_IDX(SIOCGIWRANGE)] = (iw_handler) mt7697_wext_giwrange,
[IW_IOCTL_IDX(SIOCSIWAP)] = (iw_handler) mt7697_wext_siwap,
[IW_IOCTL_IDX(SIOCGIWAP)] = (iw_handler) mt7697_wext_giwap,
[IW_IOCTL_IDX(SIOCSIWMLME)] = (iw_handler) mt7697_wext_siwmlme,
[IW_IOCTL_IDX(SIOCSIWSCAN)] = (iw_handler) cfg80211_wext_siwscan,
[IW_IOCTL_IDX(SIOCGIWSCAN)] = (iw_handler) cfg80211_wext_giwscan,
[IW_IOCTL_IDX(SIOCSIWESSID)] = (iw_handler) mt7697_wext_siwessid,
[IW_IOCTL_IDX(SIOCGIWESSID)] = (iw_handler) mt7697_wext_giwessid,
[IW_IOCTL_IDX(SIOCSIWRATE)] = (iw_handler) mt7697_wext_siwrate,
[IW_IOCTL_IDX(SIOCGIWRATE)] = (iw_handler) mt7697_wext_giwrate,
[IW_IOCTL_IDX(SIOCSIWRTS)] = (iw_handler) cfg80211_wext_siwrts,
[IW_IOCTL_IDX(SIOCGIWRTS)] = (iw_handler) cfg80211_wext_giwrts,
[IW_IOCTL_IDX(SIOCSIWFRAG)] = (iw_handler) cfg80211_wext_siwfrag,
[IW_IOCTL_IDX(SIOCGIWFRAG)] = (iw_handler) cfg80211_wext_giwfrag,
[IW_IOCTL_IDX(SIOCGIWRETRY)] = (iw_handler) cfg80211_wext_giwretry,
[IW_IOCTL_IDX(SIOCSIWENCODE)] = (iw_handler) mt7697_wext_siwencode,
[IW_IOCTL_IDX(SIOCGIWENCODE)] = (iw_handler) mt7697_wext_giwencode,
[IW_IOCTL_IDX(SIOCSIWPOWER)] = (iw_handler) mt7697_wext_siwpower,
[IW_IOCTL_IDX(SIOCGIWPOWER)] = (iw_handler) mt7697_wext_giwpower,
[IW_IOCTL_IDX(SIOCSIWGENIE)] = (iw_handler) mt7697_wext_siwgenie,
[IW_IOCTL_IDX(SIOCGIWNAME)] = (iw_handler) cfg80211_wext_giwname,
[IW_IOCTL_IDX(SIOCSIWFREQ)] = (iw_handler) mt7697_wext_siwfreq,
[IW_IOCTL_IDX(SIOCGIWFREQ)] = (iw_handler) mt7697_wext_giwfreq,
[IW_IOCTL_IDX(SIOCSIWMODE)] = (iw_handler) mt7697_wext_siwmode,
[IW_IOCTL_IDX(SIOCGIWMODE)] = (iw_handler) cfg80211_wext_giwmode,
[IW_IOCTL_IDX(SIOCGIWRANGE)] = (iw_handler) mt7697_wext_giwrange,
[IW_IOCTL_IDX(SIOCSIWAP)] = (iw_handler) mt7697_wext_siwap,
[IW_IOCTL_IDX(SIOCGIWAP)] = (iw_handler) mt7697_wext_giwap,
[IW_IOCTL_IDX(SIOCSIWMLME)] = (iw_handler) mt7697_wext_siwmlme,
[IW_IOCTL_IDX(SIOCSIWSCAN)] = (iw_handler) cfg80211_wext_siwscan,
[IW_IOCTL_IDX(SIOCGIWSCAN)] = (iw_handler) cfg80211_wext_giwscan,
[IW_IOCTL_IDX(SIOCSIWESSID)] = (iw_handler) mt7697_wext_siwessid,
[IW_IOCTL_IDX(SIOCGIWESSID)] = (iw_handler) mt7697_wext_giwessid,
[IW_IOCTL_IDX(SIOCSIWRATE)] = (iw_handler) mt7697_wext_siwrate,
[IW_IOCTL_IDX(SIOCGIWRATE)] = (iw_handler) mt7697_wext_giwrate,
[IW_IOCTL_IDX(SIOCSIWRTS)] = (iw_handler) cfg80211_wext_siwrts,
[IW_IOCTL_IDX(SIOCGIWRTS)] = (iw_handler) cfg80211_wext_giwrts,
[IW_IOCTL_IDX(SIOCSIWFRAG)] = (iw_handler) cfg80211_wext_siwfrag,
[IW_IOCTL_IDX(SIOCGIWFRAG)] = (iw_handler) cfg80211_wext_giwfrag,
[IW_IOCTL_IDX(SIOCGIWRETRY)] = (iw_handler) cfg80211_wext_giwretry,
[IW_IOCTL_IDX(SIOCSIWENCODE)] = (iw_handler) mt7697_wext_siwencode,
[IW_IOCTL_IDX(SIOCGIWENCODE)] = (iw_handler) mt7697_wext_giwencode,
[IW_IOCTL_IDX(SIOCSIWPOWER)] = (iw_handler) mt7697_wext_siwpower,
[IW_IOCTL_IDX(SIOCGIWPOWER)] = (iw_handler) mt7697_wext_giwpower,
[IW_IOCTL_IDX(SIOCSIWGENIE)] = (iw_handler) mt7697_wext_siwgenie,
[IW_IOCTL_IDX(SIOCGIWGENIE)] = (iw_handler) mt7697_wext_giwgenie,
[IW_IOCTL_IDX(SIOCSIWAUTH)] = (iw_handler) mt7697_wext_siwauth,
[IW_IOCTL_IDX(SIOCGIWAUTH)] = (iw_handler) mt7697_wext_giwauth,
[IW_IOCTL_IDX(SIOCSIWENCODEEXT)]= (iw_handler) mt7697_wext_siwencodeext,
[IW_IOCTL_IDX(SIOCSIWAUTH)] = (iw_handler) mt7697_wext_siwauth,
[IW_IOCTL_IDX(SIOCGIWAUTH)] = (iw_handler) mt7697_wext_giwauth,
[IW_IOCTL_IDX(SIOCSIWENCODEEXT)]= (iw_handler) mt7697_wext_siwencodeext,
[IW_IOCTL_IDX(SIOCGIWENCODEEXT)]= (iw_handler) mt7697_wext_giwencodeext,
};
const struct iw_handler_def mt7697_wireless_hndlrs = {
.num_standard = ARRAY_SIZE(mt7697_wireless_handler),
.standard = (iw_handler *) mt7697_wireless_handler,
.num_standard = ARRAY_SIZE(mt7697_wireless_handler),
.standard = (iw_handler *) mt7697_wireless_handler,
.get_wireless_stats = NULL,
};
......@@ -36,15 +36,15 @@ MODULE_PARM_DESC(itf_idx_start, "MT7697 WiFi interface start index");
static void mt7697_to_lower(char** in)
{
char* ptr = (char*)*in;
while (*ptr != '\0') {
if (((*ptr <= 'Z') && (*ptr >= 'A')) ||
((*ptr <= 'z') && (*ptr >= 'a')))
*ptr = ((*ptr <= 'Z') && (*ptr >= 'A')) ?
char* ptr = (char*)*in;
while (*ptr != '\0') {
if (((*ptr <= 'Z') && (*ptr >= 'A')) ||
((*ptr <= 'z') && (*ptr >= 'a')))
*ptr = ((*ptr <= 'Z') && (*ptr >= 'A')) ?
*ptr + 'a' - 'A':*ptr;
ptr++;
}
ptr++;
}
}
static int mt7697_open(struct net_device *ndev)
......@@ -55,8 +55,8 @@ static int mt7697_open(struct net_device *ndev)
dev_dbg(cfg->dev, "%s(): open net device\n", __func__);
if (!cfg->rxq_hdl && !cfg->txq_hdl) {
dev_dbg(cfg->dev, "%s(): open mt7697 uart\n", __func__);
if (!cfg->rxq_hdl && !cfg->txq_hdl) {
dev_dbg(cfg->dev, "%s(): open mt7697 uart\n", __func__);
cfg->txq_hdl = cfg->hif_ops->open(mt7697_proc_80211cmd, cfg);
if (!cfg->txq_hdl) {
dev_err(cfg->dev, "%s(): open() failed\n", __func__);
......@@ -64,7 +64,7 @@ static int mt7697_open(struct net_device *ndev)
}
cfg->rxq_hdl = cfg->txq_hdl;
}
}
set_bit(WLAN_ENABLED, &vif->flags);
......@@ -140,7 +140,7 @@ static void mt7697_set_multicast_list(struct net_device *ndev)
static void mt7697_init_hw_start(struct work_struct *work)
{
struct mt7697_cfg80211_info *cfg = container_of(work,
struct mt7697_cfg80211_info *cfg = container_of(work,
struct mt7697_cfg80211_info, init_work);
int err;
......@@ -151,7 +151,7 @@ static void mt7697_init_hw_start(struct work_struct *work)
err = cfg->hif_ops->init(MT7697_MAC80211_QUEUE_TX,
MT7697_MAC80211_QUEUE_RX, cfg,
mt7697_notify_tx,
mt7697_proc_80211cmd,
mt7697_proc_80211cmd,
&cfg->txq_hdl, &cfg->rxq_hdl);
if (err < 0) {
dev_err(cfg->dev, "%s(): queue(%u) init() failed(%d)\n",
......@@ -181,22 +181,22 @@ failed:
}
static const struct net_device_ops mt7697_netdev_ops = {
.ndo_open = mt7697_open,
.ndo_stop = mt7697_stop,
.ndo_start_xmit = mt7697_data_tx,
.ndo_open = mt7697_open,
.ndo_stop = mt7697_stop,
.ndo_start_xmit = mt7697_data_tx,
.ndo_get_stats = mt7697_get_stats,
.ndo_set_rx_mode = mt7697_set_multicast_list,
.ndo_set_rx_mode = mt7697_set_multicast_list,
};
void mt7697_init_netdev(struct net_device *ndev)
{
ndev->netdev_ops = &mt7697_netdev_ops;
ndev->netdev_ops = &mt7697_netdev_ops;
ndev->wireless_handlers = &mt7697_wireless_hndlrs;
ndev->destructor = free_netdev;
ndev->watchdog_timeo = MT7697_TX_TIMEOUT;
ndev->needed_headroom = sizeof(struct ieee80211_hdr) +
sizeof(struct mt7697_llc_snap_hdr);
ndev->hw_features |= NETIF_F_IP_CSUM | NETIF_F_RXCSUM;
ndev->destructor = free_netdev;
ndev->watchdog_timeo = MT7697_TX_TIMEOUT;
ndev->needed_headroom = sizeof(struct ieee80211_hdr) +
sizeof(struct mt7697_llc_snap_hdr);
ndev->hw_features |= NETIF_F_IP_CSUM | NETIF_F_RXCSUM;
}
static struct mt7697_if_ops if_ops;
......@@ -210,22 +210,22 @@ static int mt7697_probe(struct platform_device *pdev)
dev_dbg(&pdev->dev, "%s(): probe\n", __func__);
cfg = mt7697_cfg80211_create();
if (!cfg) {
dev_err(&pdev->dev,
dev_err(&pdev->dev,
"%s(): mt7697_cfg80211_create() failed()\n",
__func__);
err = -ENOMEM;
goto failed;
}
}
sema_init(&cfg->sem, 1);
cfg->tx_workq = create_workqueue(DRVNAME);
if (!cfg->tx_workq) {
dev_err(&pdev->dev,
dev_err(&pdev->dev,
"%s(): create_workqueue() failed()\n",
__func__);
err = -ENOMEM;
goto failed;
}
}
INIT_WORK(&cfg->init_work, mt7697_init_hw_start);
INIT_WORK(&cfg->tx_work, mt7697_tx_work);
......@@ -268,11 +268,11 @@ static int mt7697_probe(struct platform_device *pdev)
err = mt7697_cfg80211_init(cfg);
if (err < 0) {
dev_err(&pdev->dev,
dev_err(&pdev->dev,
"%s(): mt7697_cfg80211_init() failed(%d)\n",
__func__, err);
goto failed;
}
}
platform_set_drvdata(pdev, cfg);
schedule_work(&cfg->init_work);
......@@ -302,20 +302,20 @@ static void mt7697_release(struct device *dev)
}
static struct platform_device mt7697_platform_device = {
.name = DRVNAME,
.id = PLATFORM_DEVID_NONE,
.dev = {
.release = mt7697_release,
.name = DRVNAME,
.id = PLATFORM_DEVID_NONE,
.dev = {
.release = mt7697_release,
},
};
static struct platform_driver mt7697_platform_driver = {
.driver = {
.name = DRVNAME,
.name = DRVNAME,
.owner = THIS_MODULE,
},
.probe = mt7697_probe,
.probe = mt7697_probe,
.remove = mt7697_remove,
};
......
......@@ -72,7 +72,7 @@ int mt7697_data_tx(struct sk_buff *skb, struct net_device *ndev)
__func__);
ret = NETDEV_TX_BUSY;
goto cleanup;
}
}
tx_skb->skb = skb;
dev_dbg(cfg->dev, "%s(): tx pkt(%u/%p)\n",
......@@ -106,7 +106,7 @@ cleanup:
void mt7697_tx_work(struct work_struct *work)
{
struct mt7697_cfg80211_info *cfg = container_of(work,
struct mt7697_cfg80211_info *cfg = container_of(work,
struct mt7697_cfg80211_info, tx_work);
struct mt7697_tx_pkt *tx_pkt, *tx_pkt_next = NULL;
struct ieee80211_hdr *hdr;
......@@ -116,12 +116,12 @@ void mt7697_tx_work(struct work_struct *work)
struct mt7697_vif *vif = netdev_priv(tx_pkt->skb->dev);
WARN_ON(!vif);
/* validate length for ether packet */
if (tx_pkt->skb->len < sizeof(*hdr)) {
/* validate length for ether packet */
if (tx_pkt->skb->len < sizeof(*hdr)) {
dev_err(cfg->dev, "%s(): invalid skb len(%u < %u)\n",
__func__, tx_pkt->skb->len, sizeof(*hdr));
vif->net_stats.tx_errors++;
}
}
ret = mt7697_wr_tx_raw_packet(cfg, tx_pkt->skb->data,
tx_pkt->skb->len);
......@@ -150,7 +150,7 @@ void mt7697_tx_work(struct work_struct *work)
void mt7697_tx_stop(struct mt7697_cfg80211_info *cfg)
{
struct mt7697_tx_pkt *tx_pkt, *tx_pkt_next = NULL;
struct mt7697_tx_pkt *tx_pkt, *tx_pkt_next = NULL;
list_for_each_entry_safe(tx_pkt, tx_pkt_next, &cfg->tx_skb_list, next) {
struct mt7697_vif *vif = netdev_priv(tx_pkt->skb->dev);
......@@ -204,7 +204,7 @@ int mt7697_rx_data(struct mt7697_cfg80211_info *cfg, u32 len, u32 if_idx)
}
skb_put(skb, len);
memcpy(skb->data, cfg->rx_data, len);
memcpy(skb->data, cfg->rx_data, len);
skb->dev = vif->ndev;
vif->net_stats.rx_packets++;
......
......@@ -35,33 +35,38 @@
/**@brief Specifies 20MHz | 40MHz bandwidth in the 2.4GHz band.
*/
#define MT7697_WIFI_IOT_COMMAND_CONFIG_BANDWIDTH_2040MHZ (MT7697_WIFI_IOT_COMMAND_CONFIG_BANDWIDTH_20MHZ | \
MT7697_WIFI_IOT_COMMAND_CONFIG_BANDWIDTH_40MHZ)
#define MT7697_WIFI_IOT_COMMAND_CONFIG_BANDWIDTH_2040MHZ \
(MT7697_WIFI_IOT_COMMAND_CONFIG_BANDWIDTH_20MHZ | \
MT7697_WIFI_IOT_COMMAND_CONFIG_BANDWIDTH_40MHZ)
/**
* @brief Station operation mode. In this mode the device works as a Wi-Fi client.
*/
* @brief Station operation mode. In this mode the device works as a Wi-Fi
* client.
*/
#define MT7697_WIFI_MODE_STA_ONLY (1)
/**
* @brief SoftAP operation mode. In AP mode, other client devices can connect to the Wi-Fi AP.
*/
* @brief SoftAP operation mode. In AP mode, other client devices can connect to
* the Wi-Fi AP.
*/
#define MT7697_WIFI_MODE_AP_ONLY (2)
/**
* @brief Repeater mode. There are two virtual ports in repeater mode, one is #WIFI_PORT_AP, and the other is #WIFI_PORT_APCLI.
* Both ports should be configured to operate on the same channel with the same bandwidth, while their other settings can be different.
* For example, both ports can have different MAC addresses and security modes.
*/
* @brief Repeater mode. There are two virtual ports in repeater mode, one is
* #WIFI_PORT_AP, and the other is #WIFI_PORT_APCLI. Both ports should be
* configured to operate on the same channel with the same bandwidth, while
* their other settings can be different. For example, both ports can have
* different MAC addresses and security modes.
*/
#define MT7697_WIFI_MODE_REPEATER (3)
/**
* @brief This macro defines the monitoring mode. In this mode it can sniffer
* the Wi-Fi packet in the air given the specific channel and bandwidth.
* It is used to enter a hybrid mode and handle a raw packet.
* Call #wifi_config_register_rx_handler() to register a raw packet handler
* once this mode is set.
*/
* @brief This macro defines the monitoring mode. In this mode it can sniffer
* the Wi-Fi packet in the air given the specific channel and bandwidth. It is
* used to enter a hybrid mode and handle a raw packet. Call
* #wifi_config_register_rx_handler() to register a raw packet handler once this
* mode is set.
*/
#define MT7697_WIFI_MODE_MONITOR (4)
enum mt7697_port_type {
......@@ -81,116 +86,124 @@ enum mt7697_scan_option {
MT7697_WIFI_SCAN_OPTION_FORCE_ACTIVE,
};
/** @brief This enumeration defines the wireless authentication mode to indicate the Wi-Fi device’s authentication attribute.
*/
/**
* @brief This enumeration defines the wireless authentication mode to indicate
* the Wi-Fi device’s authentication attribute.
*/
enum mt7697_wifi_auth_mode_t {
MT7697_WIFI_AUTH_MODE_OPEN = 0, /**< Open mode. */
MT7697_WIFI_AUTH_MODE_SHARED, /**< Not supported. */
MT7697_WIFI_AUTH_MODE_AUTO_WEP, /**< Not supported. */
MT7697_WIFI_AUTH_MODE_WPA, /**< Not supported. */
MT7697_WIFI_AUTH_MODE_WPA_PSK, /**< WPA_PSK. */
MT7697_WIFI_AUTH_MODE_WPA_None, /**< Not supported. */
MT7697_WIFI_AUTH_MODE_WPA2, /**< Not supported. */
MT7697_WIFI_AUTH_MODE_WPA2_PSK, /**< WPA2_PSK. */
MT7697_WIFI_AUTH_MODE_WPA_WPA2, /**< Not supported. */
MT7697_WIFI_AUTH_MODE_WPA_PSK_WPA2_PSK, /**< Mixture mode. */
MT7697_WIFI_AUTH_MODE_OPEN = 0, /**< Open mode. */
MT7697_WIFI_AUTH_MODE_SHARED, /**< Not supported. */
MT7697_WIFI_AUTH_MODE_AUTO_WEP, /**< Not supported. */
MT7697_WIFI_AUTH_MODE_WPA, /**< Not supported. */
MT7697_WIFI_AUTH_MODE_WPA_PSK, /**< WPA_PSK. */
MT7697_WIFI_AUTH_MODE_WPA_None, /**< Not supported. */
MT7697_WIFI_AUTH_MODE_WPA2, /**< Not supported. */
MT7697_WIFI_AUTH_MODE_WPA2_PSK, /**< WPA2_PSK. */
MT7697_WIFI_AUTH_MODE_WPA_WPA2, /**< Not supported. */
MT7697_WIFI_AUTH_MODE_WPA_PSK_WPA2_PSK, /**< Mixture mode. */
};
/** @brief This enumeration defines the wireless encryption type to indicate the Wi-Fi device’s encryption attribute.
*/
/**
* @brief This enumeration defines the wireless encryption type to indicate the
* Wi-Fi device’s encryption attribute.
*/
enum mt7697_wifi_encrypt_type_t {
MT7697_WIFI_ENCRYPT_TYPE_WEP_ENABLED = 0, /**< WEP encryption type. */
MT7697_WIFI_ENCRYPT_TYPE_ENCRYPT1_ENABLED = MT7697_WIFI_ENCRYPT_TYPE_WEP_ENABLED, /**< WEP encryption type. */
MT7697_WIFI_ENCRYPT_TYPE_WEP_DISABLED = 1, /**< No encryption. */
MT7697_WIFI_ENCRYPT_TYPE_ENCRYPT_DISABLED = MT7697_WIFI_ENCRYPT_TYPE_WEP_DISABLED, /**< No encryption. */
MT7697_WIFI_ENCRYPT_TYPE_WEP_KEY_ABSENT = 2, /**< Not supported. */
MT7697_WIFI_ENCRYPT_TYPE_ENCRYPT_KEY_ABSENT = MT7697_WIFI_ENCRYPT_TYPE_WEP_KEY_ABSENT, /**< Not supported. */
MT7697_WIFI_ENCRYPT_TYPE_WEP_NOT_SUPPORTED = 3, /**< Not supported. */
MT7697_WIFI_ENCRYPT_TYPE_ENCRYPT_NOT_SUPPORTED = MT7697_WIFI_ENCRYPT_TYPE_WEP_NOT_SUPPORTED,/**< Not supported. */
MT7697_WIFI_ENCRYPT_TYPE_TKIP_ENABLED = 4, /**< TKIP encryption. */
MT7697_WIFI_ENCRYPT_TYPE_ENCRYPT2_ENABLED = MT7697_WIFI_ENCRYPT_TYPE_TKIP_ENABLED, /**< TKIP encryption. */
MT7697_WIFI_ENCRYPT_TYPE_AES_ENABLED = 6, /**< AES encryption. */
MT7697_WIFI_ENCRYPT_TYPE_ENCRYPT3_ENABLED = MT7697_WIFI_ENCRYPT_TYPE_AES_ENABLED, /**< AES encryption. */
MT7697_WIFI_ENCRYPT_TYPE_AES_KEY_ABSENT = 7, /**< Not supported. */
MT7697_WIFI_ENCRYPT_TYPE_TKIP_AES_MIX = 8, /**< TKIP or AES mix. */
MT7697_WIFI_ENCRYPT_TYPE_ENCRYPT4_ENABLED = MT7697_WIFI_ENCRYPT_TYPE_TKIP_AES_MIX, /**< TKIP or AES mix. */
MT7697_WIFI_ENCRYPT_TYPE_TKIP_AES_KEY_ABSENT = 9, /**< Not supported. */
MT7697_WIFI_ENCRYPT_TYPE_GROUP_WEP40_ENABLED = 10, /**< Not supported. */
MT7697_WIFI_ENCRYPT_TYPE_GROUP_WEP104_ENABLED = 11, /**< Not supported. */
MT7697_WIFI_ENCRYPT_TYPE_WEP_ENABLED = 0, /**< WEP encryption type. */
MT7697_WIFI_ENCRYPT_TYPE_ENCRYPT1_ENABLED = MT7697_WIFI_ENCRYPT_TYPE_WEP_ENABLED, /**< WEP encryption type. */
MT7697_WIFI_ENCRYPT_TYPE_WEP_DISABLED = 1, /**< No encryption. */
MT7697_WIFI_ENCRYPT_TYPE_ENCRYPT_DISABLED = MT7697_WIFI_ENCRYPT_TYPE_WEP_DISABLED, /**< No encryption. */
MT7697_WIFI_ENCRYPT_TYPE_WEP_KEY_ABSENT = 2, /**< Not supported. */
MT7697_WIFI_ENCRYPT_TYPE_ENCRYPT_KEY_ABSENT = MT7697_WIFI_ENCRYPT_TYPE_WEP_KEY_ABSENT, /**< Not supported. */
MT7697_WIFI_ENCRYPT_TYPE_WEP_NOT_SUPPORTED = 3, /**< Not supported. */
MT7697_WIFI_ENCRYPT_TYPE_ENCRYPT_NOT_SUPPORTED = MT7697_WIFI_ENCRYPT_TYPE_WEP_NOT_SUPPORTED, /**< Not supported. */
MT7697_WIFI_ENCRYPT_TYPE_TKIP_ENABLED = 4, /**< TKIP encryption. */
MT7697_WIFI_ENCRYPT_TYPE_ENCRYPT2_ENABLED = MT7697_WIFI_ENCRYPT_TYPE_TKIP_ENABLED, /**< TKIP encryption. */
MT7697_WIFI_ENCRYPT_TYPE_AES_ENABLED = 6, /**< AES encryption. */
MT7697_WIFI_ENCRYPT_TYPE_ENCRYPT3_ENABLED = MT7697_WIFI_ENCRYPT_TYPE_AES_ENABLED, /**< AES encryption. */
MT7697_WIFI_ENCRYPT_TYPE_AES_KEY_ABSENT = 7, /**< Not supported. */
MT7697_WIFI_ENCRYPT_TYPE_TKIP_AES_MIX = 8, /**< TKIP or AES mix. */
MT7697_WIFI_ENCRYPT_TYPE_ENCRYPT4_ENABLED = MT7697_WIFI_ENCRYPT_TYPE_TKIP_AES_MIX, /**< TKIP or AES mix. */
MT7697_WIFI_ENCRYPT_TYPE_TKIP_AES_KEY_ABSENT = 9, /**< Not supported. */
MT7697_WIFI_ENCRYPT_TYPE_GROUP_WEP40_ENABLED = 10, /**< Not supported. */
MT7697_WIFI_ENCRYPT_TYPE_GROUP_WEP104_ENABLED = 11, /**< Not supported. */
#ifdef WAPI_SUPPORT
MT7697_WIFI_ENCRYPT_TYPE_ENCRYPT_SMS4_ENABLED, /**< WPI SMS4 support. */
MT7697_WIFI_ENCRYPT_TYPE_ENCRYPT_SMS4_ENABLED, /**< WPI SMS4 support. */
#endif /* WAPI_SUPPORT */
};
/** @brief This enumeration defines the wireless physical mode.
*/
enum mt7697_wifi_phy_mode_t {
MT7697_WIFI_PHY_11BG_MIXED = 0, /**< 0, 2.4GHz band. */
MT7697_WIFI_PHY_11B, /**< 1, 2.4GHz band. */
MT7697_WIFI_PHY_11A, /**< 2, 5GHz band. */
MT7697_WIFI_PHY_11ABG_MIXED, /**< 3, both 2.4G and 5G band. */
MT7697_WIFI_PHY_11G, /**< 4, 2.4GHz band. */
MT7697_WIFI_PHY_11ABGN_MIXED, /**< 5, both 2.4G and 5G band. */
MT7697_WIFI_PHY_11N_2_4G, /**< 6, 11n-only with 2.4GHz band. */
MT7697_WIFI_PHY_11GN_MIXED, /**< 7, 2.4GHz band. */
MT7697_WIFI_PHY_11AN_MIXED, /**< 8, 5GHz band. */
MT7697_WIFI_PHY_11BGN_MIXED, /**< 9, 2.4GHz band. */
MT7697_WIFI_PHY_11AGN_MIXED, /**< 10, both 2.4G and 5G band. */
MT7697_WIFI_PHY_11N_5G, /**< 11, 11n-only with 5GHz band. */
MT7697_WIFI_PHY_11BG_MIXED = 0, /**< 0, 2.4GHz band. */
MT7697_WIFI_PHY_11B, /**< 1, 2.4GHz band. */
MT7697_WIFI_PHY_11A, /**< 2, 5GHz band. */
MT7697_WIFI_PHY_11ABG_MIXED, /**< 3, both 2.4G and 5G band. */
MT7697_WIFI_PHY_11G, /**< 4, 2.4GHz band. */
MT7697_WIFI_PHY_11ABGN_MIXED, /**< 5, both 2.4G and 5G band. */
MT7697_WIFI_PHY_11N_2_4G, /**< 6, 11n-only with 2.4GHz band. */
MT7697_WIFI_PHY_11GN_MIXED, /**< 7, 2.4GHz band. */
MT7697_WIFI_PHY_11AN_MIXED, /**< 8, 5GHz band. */
MT7697_WIFI_PHY_11BGN_MIXED, /**< 9, 2.4GHz band. */
MT7697_WIFI_PHY_11AGN_MIXED, /**< 10, both 2.4G and 5G band. */
MT7697_WIFI_PHY_11N_5G, /**< 11, 11n-only with 5GHz band. */
};
/** @brief This enumeration defines the RX filter register's bitmap. Each bit indicates a specific drop frame.
*/
/**
* @brief This enumeration defines the RX filter register's bitmap. Each bit
* indicates a specific drop frame.
*/
enum mt7697_wifi_rx_filter_t {
MT7697_WIFI_RX_FILTER_DROP_STBC_BCN_BC_MC, /**< bit 0 Drops the STBC beacon/BC/MC frames. */
MT7697_WIFI_RX_FILTER_DROP_FCS_ERR, /**< bit 1 Drops the FCS error frames. */
MT7697_WIFI_RX_FILTER_RESERVED, /**< bit 2 A reserved bit, not used. */
MT7697_WIFI_RX_FILTER_DROP_VER_NOT_0, /**< bit 3 Drops the version field of Frame Control field. It cannot be 0. */
MT7697_WIFI_RX_FILTER_DROP_PROBE_REQ, /**< bit 4 Drops the probe request frame. */
MT7697_WIFI_RX_FILTER_DROP_MC_FRAME, /**< bit 5 Drops multicast frame. */
MT7697_WIFI_RX_FILTER_DROP_BC_FRAME, /**< bit 6 Drops broadcast frame. */
MT7697_WIFI_RX_FILTER_RM_FRAME_REPORT_EN = 12, /**< bit 12 Enables report frames. */
MT7697_WIFI_RX_FILTER_DROP_CTRL_RSV, /**< bit 13 Drops reserved definition control frames. */
MT7697_WIFI_RX_FILTER_DROP_CTS, /**< bit 14 Drops CTS frames. */
MT7697_WIFI_RX_FILTER_DROP_RTS, /**< bit 15 Drops RTS frames. */
MT7697_WIFI_RX_FILTER_DROP_DUPLICATE, /**< bit 16 Drops duplicate frames. */
MT7697_WIFI_RX_FILTER_DROP_NOT_MY_BSSID, /**< bit 17 Drops not my BSSID frames. */
MT7697_WIFI_RX_FILTER_DROP_NOT_UC2ME, /**< bit 18 Drops not unicast to me frames. */
MT7697_WIFI_RX_FILTER_DROP_DIFF_BSSID_BTIM, /**< bit 19 Drops different BSSID TIM (Traffic Indication Map) Broadcast frame. */
MT7697_WIFI_RX_FILTER_DROP_NDPA /**< bit 20 Drops the NDPA or not. */
MT7697_WIFI_RX_FILTER_DROP_STBC_BCN_BC_MC, /**< bit 0 Drops the STBC beacon/BC/MC frames. */
MT7697_WIFI_RX_FILTER_DROP_FCS_ERR, /**< bit 1 Drops the FCS error frames. */
MT7697_WIFI_RX_FILTER_RESERVED, /**< bit 2 A reserved bit, not used. */
MT7697_WIFI_RX_FILTER_DROP_VER_NOT_0, /**< bit 3 Drops the version field of Frame Control field. It cannot be 0. */
MT7697_WIFI_RX_FILTER_DROP_PROBE_REQ, /**< bit 4 Drops the probe request frame. */
MT7697_WIFI_RX_FILTER_DROP_MC_FRAME, /**< bit 5 Drops multicast frame. */
MT7697_WIFI_RX_FILTER_DROP_BC_FRAME, /**< bit 6 Drops broadcast frame. */
MT7697_WIFI_RX_FILTER_RM_FRAME_REPORT_EN = 12, /**< bit 12 Enables report frames. */
MT7697_WIFI_RX_FILTER_DROP_CTRL_RSV, /**< bit 13 Drops reserved definition control frames. */
MT7697_WIFI_RX_FILTER_DROP_CTS, /**< bit 14 Drops CTS frames. */
MT7697_WIFI_RX_FILTER_DROP_RTS, /**< bit 15 Drops RTS frames. */
MT7697_WIFI_RX_FILTER_DROP_DUPLICATE, /**< bit 16 Drops duplicate frames. */
MT7697_WIFI_RX_FILTER_DROP_NOT_MY_BSSID, /**< bit 17 Drops not my BSSID frames. */
MT7697_WIFI_RX_FILTER_DROP_NOT_UC2ME, /**< bit 18 Drops not unicast to me frames. */
MT7697_WIFI_RX_FILTER_DROP_DIFF_BSSID_BTIM, /**< bit 19 Drops different BSSID TIM (Traffic Indication Map) Broadcast frame. */
MT7697_WIFI_RX_FILTER_DROP_NDPA /**< bit 20 Drops the NDPA or not. */
};
/** @brief This structure is the Wi-Fi configuration for initialization in STA mode.
*/
/**
* @brief This structure is the Wi-Fi configuration for initialization in STA
* mode.
*/
struct mt7697_wifi_sta_config_t {
u8 ssid[IEEE80211_MAX_SSID_LEN]; /**< The SSID of the target AP. */
u8 ssid_len; /**< The length of the SSID. */
u8 bssid_present; /**< The BSSID is present if it is set to 1. Otherwise, it is set to 0. */
u8 bssid[ETH_ALEN]; /**< The MAC address of the target AP. */
u8 pw[MT7697_WIFI_LENGTH_PASSPHRASE]; /**< The password of the target AP. */
u8 pw_len; /**< The length of the password. */
u8 ssid[IEEE80211_MAX_SSID_LEN]; /**< The SSID of the target AP. */
u8 ssid_len; /**< The length of the SSID. */
u8 bssid_present; /**< The BSSID is present if it is set to 1. Otherwise, it is set to 0. */
u8 bssid[ETH_ALEN]; /**< The MAC address of the target AP. */
u8 pw[MT7697_WIFI_LENGTH_PASSPHRASE]; /**< The password of the target AP. */
u8 pw_len; /**< The length of the password. */
} __attribute__((__packed__));
/** @brief This structure is the Wi-Fi configuration for initialization in AP mode.
*/
struct mt7697_wifi_ap_config_t {
u8 ssid[IEEE80211_MAX_SSID_LEN]; /**< The SSID of the AP. */
u8 ssid_len; /**< The length of the SSID. */
u8 pw[MT7697_WIFI_LENGTH_PASSPHRASE]; /**< The password of the AP. */
u8 pw_len; /**< The length of the password. */
u8 auth_mode; /**< The authentication mode. */
u8 encrypt_type; /**< The encryption mode. */
u8 ch; /**< The channel. */
u8 bandwidth; /**< The bandwidth that is either #WIFI_IOT_COMMAND_CONFIG_BANDWIDTH_20MHZ or #WIFI_IOT_COMMAND_CONFIG_BANDWIDTH_40MHZ. */
u8 bandwidth_ext; /**< The bandwidth extension. It is only applicable when the bandwidth is set to #WIFI_IOT_COMMAND_CONFIG_BANDWIDTH_40MHZ. */
u8 ssid[IEEE80211_MAX_SSID_LEN]; /**< The SSID of the AP. */
u8 ssid_len; /**< The length of the SSID. */
u8 pw[MT7697_WIFI_LENGTH_PASSPHRASE]; /**< The password of the AP. */
u8 pw_len; /**< The length of the password. */
u8 auth_mode; /**< The authentication mode. */
u8 encrypt_type; /**< The encryption mode. */
u8 ch; /**< The channel. */
u8 bandwidth; /**< The bandwidth that is either #WIFI_IOT_COMMAND_CONFIG_BANDWIDTH_20MHZ or #WIFI_IOT_COMMAND_CONFIG_BANDWIDTH_40MHZ. */
u8 bandwidth_ext; /**< The bandwidth extension. It is only applicable when the bandwidth is set to #WIFI_IOT_COMMAND_CONFIG_BANDWIDTH_40MHZ. */
} __attribute__((__packed__));
/** @brief Wi-Fi configuration for initialization.
*/
struct mt7697_wifi_config_t {
u8 opmode; /**< The operation mode. The value should be #WIFI_MODE_STA_ONLY, #WIFI_MODE_AP_ONLY, #WIFI_MODE_REPEATER or #WIFI_MODE_MONITOR*/
struct mt7697_wifi_sta_config_t sta; /**< The configurations for the STA. It should be set when the OPMODE is #WIFI_MODE_STA_ONLY or #WIFI_MODE_REPEATER. */
struct mt7697_wifi_ap_config_t ap; /**< The configurations for the AP. It should be set when the OPMODE is #WIFI_MODE_AP_ONLY or #WIFI_MODE_REPEATER. */
u8 opmode; /**< The operation mode. The value should be #WIFI_MODE_STA_ONLY, #WIFI_MODE_AP_ONLY, #WIFI_MODE_REPEATER or #WIFI_MODE_MONITOR*/
struct mt7697_wifi_sta_config_t sta; /**< The configurations for the STA. It should be set when the OPMODE is #WIFI_MODE_STA_ONLY or #WIFI_MODE_REPEATER. */
struct mt7697_wifi_ap_config_t ap; /**< The configurations for the AP. It should be set when the OPMODE is #WIFI_MODE_AP_ONLY or #WIFI_MODE_REPEATER. */
} __attribute__((__packed__));
#endif
......@@ -38,7 +38,7 @@ static int mt7697_proc_mac_addr(const struct mt7697_rsp_hdr* rsp,
__func__, rsp->cmd.len,
sizeof(struct mt7697_mac_addr_rsp));
ret = -EINVAL;
goto cleanup;
goto cleanup;
}
ret = cfg->hif_ops->read(cfg->rxq_hdl, (u32*)&addr,
......@@ -47,8 +47,8 @@ static int mt7697_proc_mac_addr(const struct mt7697_rsp_hdr* rsp,
dev_err(cfg->dev, "%s(): read() failed(%d != %d)\n",
__func__, ret, LEN_TO_WORD(sizeof(addr)));
ret = (ret < 0) ? ret:-EIO;
goto cleanup;
}
goto cleanup;
}
print_hex_dump(KERN_DEBUG, DRVNAME" MAC address ",
DUMP_PREFIX_OFFSET, 16, 1, addr, ETH_ALEN, 0);
......@@ -92,7 +92,7 @@ static int mt7697_proc_get_wireless_mode(const struct mt7697_rsp_hdr* rsp,
rsp->cmd.len - sizeof(struct mt7697_rsp_hdr),
sizeof(u32));
ret = -EINVAL;
goto cleanup;
goto cleanup;
}
ret = cfg->hif_ops->read(cfg->rxq_hdl, (u32*)&wireless_mode,
......@@ -102,8 +102,8 @@ static int mt7697_proc_get_wireless_mode(const struct mt7697_rsp_hdr* rsp,
__func__, ret,
LEN_TO_WORD(sizeof(wireless_mode)));
ret = (ret < 0) ? ret:-EIO;
goto cleanup;
}
goto cleanup;
}
dev_dbg(cfg->dev, "%s(): wireless mode(%u)\n",
__func__, wireless_mode);
......@@ -129,7 +129,7 @@ static int mt7697_proc_get_cfg(const struct mt7697_rsp_hdr* rsp,
rsp->cmd.len - sizeof(struct mt7697_rsp_hdr),
LEN32_ALIGNED(sizeof(struct mt7697_wifi_config_t)));
ret = -EINVAL;
goto cleanup;
goto cleanup;
}
rd_buf = kzalloc(LEN32_ALIGNED(sizeof(struct mt7697_wifi_config_t)),
......@@ -137,7 +137,7 @@ static int mt7697_proc_get_cfg(const struct mt7697_rsp_hdr* rsp,
if (!rd_buf) {
dev_err(cfg->dev, "%s(): kzalloc() failed\n", __func__);
ret = -ENOMEM;
goto cleanup;
goto cleanup;
}
ret = cfg->hif_ops->read(cfg->rxq_hdl, (u32*)rd_buf,
......@@ -147,8 +147,8 @@ static int mt7697_proc_get_cfg(const struct mt7697_rsp_hdr* rsp,
__func__, ret,
LEN_TO_WORD(sizeof(struct mt7697_wifi_config_t)));
ret = (ret < 0) ? ret:-EIO;
goto cleanup;
}
goto cleanup;
}
wifi_cfg = (struct mt7697_wifi_config_t*)rd_buf;
dev_dbg(cfg->dev, "%s(): operation mode(%u)\n",
......@@ -284,7 +284,7 @@ static int mt7697_proc_get_listen_interval(const struct mt7697_rsp_hdr* rsp,
rsp->cmd.len - sizeof(struct mt7697_rsp_hdr),
sizeof(u32));
ret = -EINVAL;
goto cleanup;
goto cleanup;
}
ret = cfg->hif_ops->read(cfg->rxq_hdl, (u32*)&interval,
......@@ -293,8 +293,8 @@ static int mt7697_proc_get_listen_interval(const struct mt7697_rsp_hdr* rsp,
dev_err(cfg->dev, "%s(): read() failed(%d != %d)\n",
__func__, ret, LEN_TO_WORD(sizeof(u32)));
ret = (ret < 0) ? ret:-EIO;
goto cleanup;
}
goto cleanup;
}
cfg->listen_interval = interval;
dev_dbg(cfg->dev, "%s(): listen interval(%u)\n",
......@@ -311,7 +311,7 @@ static int mt7697_proc_scan_ind(const struct mt7697_rsp_hdr* rsp,
struct ieee80211_mgmt *rx_mgmt_frame;
s32 rssi;
u32 ch;
u32 probe_rsp_len;
u32 probe_rsp_len;
int ret;
__le16 fc;
......@@ -322,7 +322,7 @@ static int mt7697_proc_scan_ind(const struct mt7697_rsp_hdr* rsp,
__func__, rsp->cmd.len,
sizeof(struct mt7697_scan_ind));
ret = -EINVAL;
goto cleanup;
goto cleanup;
}
ret = cfg->hif_ops->read(cfg->rxq_hdl, (s32*)&rssi,
......@@ -331,8 +331,8 @@ static int mt7697_proc_scan_ind(const struct mt7697_rsp_hdr* rsp,
dev_err(cfg->dev, "%s(): read() failed(%d != %d)\n",
__func__, ret, LEN_TO_WORD(sizeof(s32)));
ret = (ret < 0) ? ret:-EIO;
goto cleanup;
}
goto cleanup;
}
dev_dbg(cfg->dev, "%s(): rssi(%d)\n", __func__, rssi);
ret = cfg->hif_ops->read(cfg->rxq_hdl, (u32*)&ch,
......@@ -341,8 +341,8 @@ static int mt7697_proc_scan_ind(const struct mt7697_rsp_hdr* rsp,
dev_err(cfg->dev, "%s(): read() failed(%d != %d)\n",
__func__, ret, LEN_TO_WORD(sizeof(u32)));
ret = (ret < 0) ? ret:-EIO;
goto cleanup;
}
goto cleanup;
}
dev_dbg(cfg->dev, "%s(): channel(%u)\n", __func__, ch);
probe_rsp_len = rsp->result;
......@@ -350,12 +350,12 @@ static int mt7697_proc_scan_ind(const struct mt7697_rsp_hdr* rsp,
dev_err(cfg->dev, "%s(): invalid probe rsp len(%d > %d)\n",
__func__, probe_rsp_len, IEEE80211_MAX_DATA_LEN);
ret = -EINVAL;
goto cleanup;
goto cleanup;
} else if (!probe_rsp_len) {
dev_err(cfg->dev, "%s(): invalid probe rsp len(%d)\n",
__func__, probe_rsp_len);
ret = -EINVAL;
goto cleanup;
goto cleanup;
}
dev_dbg(cfg->dev, "%s(): probe rsp len(%u)\n",
__func__, probe_rsp_len);
......@@ -367,8 +367,8 @@ static int mt7697_proc_scan_ind(const struct mt7697_rsp_hdr* rsp,
__func__, ret,
LEN_TO_WORD(LEN32_ALIGNED(probe_rsp_len)));
ret = (ret < 0) ? ret:-EIO;
goto cleanup;
}
goto cleanup;
}
rx_mgmt_frame = (struct ieee80211_mgmt*)cfg->probe_data;
fc = rx_mgmt_frame->frame_control;
......@@ -459,8 +459,8 @@ static int mt7697_proc_scan_rsp(const struct mt7697_rsp_hdr* rsp,
dev_err(cfg->dev, "%s(): read() failed(%d != %d)\n",
__func__, ret, LEN_TO_WORD(sizeof(u32)));
ret = (ret < 0) ? ret:-EIO;
goto cleanup;
}
goto cleanup;
}
dev_dbg(cfg->dev, "%s(): if idx(%d)\n", __func__, if_idx);
if ((rsp->result < 0) && (vif->scan_req != NULL)) {
......@@ -499,8 +499,8 @@ static int mt7697_proc_scan_complete_ind(struct mt7697_cfg80211_info *cfg)
dev_err(cfg->dev, "%s(): read() failed(%d != %d)\n",
__func__, ret, LEN_TO_WORD(sizeof(u32)));
ret = (ret < 0) ? ret:-EIO;
goto cleanup;
}
goto cleanup;
}
dev_dbg(cfg->dev, "%s(): if idx(%u)\n", __func__, if_idx);
vif = mt7697_get_vif_by_idx(cfg, if_idx);
......@@ -547,8 +547,8 @@ static int mt7697_proc_connect_ind(const struct mt7697_rsp_hdr* rsp,
dev_err(cfg->dev, "%s(): read() failed(%d != %d)\n",
__func__, ret, LEN_TO_WORD(sizeof(u32)));
ret = (ret < 0) ? ret:-EIO;
goto cleanup;
}
goto cleanup;
}
dev_dbg(cfg->dev, "%s(): if idx(%d)\n", __func__, if_idx);
ret = cfg->hif_ops->read(cfg->rxq_hdl, (u32*)&channel,
......@@ -557,8 +557,8 @@ static int mt7697_proc_connect_ind(const struct mt7697_rsp_hdr* rsp,
dev_err(cfg->dev, "%s(): read() failed(%d != %d)\n",
__func__, ret, LEN_TO_WORD(sizeof(u32)));
ret = (ret < 0) ? ret:-EIO;
goto cleanup;
}
goto cleanup;
}
dev_dbg(cfg->dev, "%s(): channel(%d)\n", __func__, channel);
ret = cfg->hif_ops->read(cfg->rxq_hdl, (u32*)bssid,
......@@ -567,15 +567,15 @@ static int mt7697_proc_connect_ind(const struct mt7697_rsp_hdr* rsp,
dev_err(cfg->dev, "%s(): read() failed(%d != %d)\n",
__func__, ret, LEN_TO_WORD(sizeof(bssid)));
ret = (ret < 0) ? ret:-EIO;
goto cleanup;
}
goto cleanup;
}
print_hex_dump(KERN_DEBUG, DRVNAME" BSSID ",
DUMP_PREFIX_OFFSET, 16, 1, bssid, ETH_ALEN, 0);
if (list_empty(&cfg->vif_list)) {
dev_dbg(cfg->dev, "%s(): no interfaces\n", __func__);
goto cleanup;
goto cleanup;
}
if (cfg->wifi_cfg.opmode == MT7697_WIFI_MODE_STA_ONLY) {
......@@ -615,8 +615,8 @@ static int mt7697_proc_connect_ind(const struct mt7697_rsp_hdr* rsp,
dev_err(cfg->dev,
"%s(): mt7697_cfg80211_new_sta() failed(%d)\n",
__func__, ret);
goto cleanup;
}
goto cleanup;
}
cfg80211_new_sta(vif->ndev, bssid, &sinfo, GFP_KERNEL);
......@@ -650,8 +650,8 @@ static int mt7697_proc_disconnect_ind(struct mt7697_cfg80211_info *cfg)
dev_err(cfg->dev, "%s(): read() failed(%d != %d)\n",
__func__, ret, LEN_TO_WORD(sizeof(u32)));
ret = (ret < 0) ? ret:-EIO;
goto cleanup;
}
goto cleanup;
}
dev_dbg(cfg->dev, "%s(): if idx(%d)\n", __func__, if_idx);
ret = cfg->hif_ops->read(cfg->rxq_hdl, (u32*)bssid,
......@@ -660,15 +660,15 @@ static int mt7697_proc_disconnect_ind(struct mt7697_cfg80211_info *cfg)
dev_err(cfg->dev, "%s(): read() failed(%d != %d)\n",
__func__, ret, LEN_TO_WORD(sizeof(bssid)));
ret = (ret < 0) ? ret:-EIO;
goto cleanup;
}
goto cleanup;
}
print_hex_dump(KERN_DEBUG, DRVNAME" BSSID ",
DUMP_PREFIX_OFFSET, 16, 1, bssid, ETH_ALEN, 0);
if (list_empty(&cfg->vif_list)) {
dev_dbg(cfg->dev, "%s(): no interfaces\n", __func__);
goto cleanup;
goto cleanup;
}
if (cfg->wifi_cfg.opmode == MT7697_WIFI_MODE_STA_ONLY) {
......@@ -754,7 +754,7 @@ static int mt7697_rx_raw(const struct mt7697_rsp_hdr* rsp,
__func__, rsp->cmd.len,
sizeof(struct mt7697_rsp_hdr));
ret = -EINVAL;
goto cleanup;
goto cleanup;
}
dev_dbg(cfg->dev, "%s(): len(%d)\n", __func__, rsp->result);
......@@ -762,7 +762,7 @@ static int mt7697_rx_raw(const struct mt7697_rsp_hdr* rsp,
dev_err(cfg->dev, "%s(): invalid rx data len(%u > %u)\n",
__func__, rsp->result, IEEE80211_MAX_FRAME_LEN);
ret = -EINVAL;
goto cleanup;
goto cleanup;
}
ret = cfg->hif_ops->read(cfg->rxq_hdl, (u32*)cfg->rx_data,
......@@ -772,15 +772,15 @@ static int mt7697_rx_raw(const struct mt7697_rsp_hdr* rsp,
__func__, ret,
LEN_TO_WORD(LEN32_ALIGNED(rsp->result)));
ret = (ret < 0) ? ret:-EIO;
goto cleanup;
}
goto cleanup;
}
// print_hex_dump(KERN_DEBUG, DRVNAME" RX ", DUMP_PREFIX_OFFSET,
// 16, 1, cfg->rx_data, rsp->result, 0);
if (list_empty(&cfg->vif_list)) {
dev_dbg(cfg->dev, "%s(): no interfaces\n", __func__);
goto cleanup;
goto cleanup;
}
/* TODO: interface index come from MT7697 */
......@@ -810,7 +810,7 @@ int mt7697_proc_80211cmd(const struct mt7697_rsp_hdr* rsp, void* priv)
"%s(): mt7697_proc_mac_addr() failed(%d)\n",
__func__, ret);
goto cleanup;
}
}
break;
case MT7697_CMD_GET_WIRELESS_MODE_RSP:
......@@ -820,7 +820,7 @@ int mt7697_proc_80211cmd(const struct mt7697_rsp_hdr* rsp, void* priv)
"%s(): mt7697_proc_get_wireless_mode() failed(%d)\n",
__func__, ret);
goto cleanup;
}
}
break;
case MT7697_CMD_GET_CFG_RSP:
......@@ -830,7 +830,7 @@ int mt7697_proc_80211cmd(const struct mt7697_rsp_hdr* rsp, void* priv)
"%s(): mt7697_proc_get_cfg() failed(%d)\n",
__func__, ret);
goto cleanup;
}
}
break;
case MT7697_CMD_GET_LISTEN_INTERVAL_RSP:
......@@ -840,7 +840,7 @@ int mt7697_proc_80211cmd(const struct mt7697_rsp_hdr* rsp, void* priv)
"%s(): mt7697_proc_get_listen_interval() failed(%d)\n",
__func__, ret);
goto cleanup;
}
}
break;
case MT7697_CMD_SCAN_RSP:
......@@ -850,7 +850,7 @@ int mt7697_proc_80211cmd(const struct mt7697_rsp_hdr* rsp, void* priv)
"%s(): mt7697_proc_scan_rsp() failed(%d)\n",
__func__, ret);
goto cleanup;
}
}
break;
case MT7697_CMD_SCAN_IND:
......@@ -860,7 +860,7 @@ int mt7697_proc_80211cmd(const struct mt7697_rsp_hdr* rsp, void* priv)
"%s(): mt7697_proc_scan_ind() failed(%d)\n",
__func__, ret);
goto cleanup;
}
}
break;
case MT7697_CMD_SCAN_COMPLETE_IND:
......@@ -870,7 +870,7 @@ int mt7697_proc_80211cmd(const struct mt7697_rsp_hdr* rsp, void* priv)
"%s(): mt7697_proc_scan_complete_ind() failed(%d)\n",
__func__, ret);
goto cleanup;
}
}
break;
case MT7697_CMD_CONNECT_IND:
......@@ -880,7 +880,7 @@ int mt7697_proc_80211cmd(const struct mt7697_rsp_hdr* rsp, void* priv)
"%s(): mt7697_proc_connect_ind() failed(%d)\n",
__func__, ret);
goto cleanup;
}
}
break;
case MT7697_CMD_DISCONNECT_IND:
......@@ -890,7 +890,7 @@ int mt7697_proc_80211cmd(const struct mt7697_rsp_hdr* rsp, void* priv)
"%s(): mt7697_proc_disconnect_ind() failed(%d)\n",
__func__, ret);
goto cleanup;
}
}
break;
case MT7697_CMD_RX_RAW:
......@@ -898,10 +898,10 @@ int mt7697_proc_80211cmd(const struct mt7697_rsp_hdr* rsp, void* priv)
if (ret < 0) {
dev_err(cfg->dev, "%s(): mt7697_rx_raw() failed(%d)\n",
__func__, ret);
}
}
break;
case MT7697_CMD_SET_OP_MODE_RSP:
case MT7697_CMD_SET_OP_MODE_RSP:
dev_dbg(cfg->dev, "%s(): --> SET OP MODE RSP\n", __func__);
break;
......@@ -1032,7 +1032,7 @@ int mt7697_wr_set_pmk_req(const struct mt7697_cfg80211_info *cfg, const u8 *pmk)
req.port = cfg->port_type;
for (i = 0; i < MT7697_WIFI_LENGTH_PMK; i++) {
snprintf(tmp, sizeof(tmp), "%02x", pmk[i]);
snprintf(tmp, sizeof(tmp), "%02x", pmk[i]);
memcpy(&req.pmk[i*2], tmp, 2*sizeof(u8));
}
......@@ -1477,7 +1477,7 @@ int mt7697_wr_tx_raw_packet(struct mt7697_cfg80211_info* cfg,
cfg->tx_req.cmd.len = sizeof(struct mt7697_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);
memcpy(cfg->tx_req.data, data, len);
dev_dbg(cfg->dev, "%s(): <-- TX RAW PKT len(%u)\n",
__func__, cfg->tx_req.len);
......
......@@ -23,40 +23,40 @@
#include "mt7697_i.h"
#include "wifi_api.h"
#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_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_set_wireless_mode_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_pmk_rsp mt7697_rsp_hdr
#define mt7697_set_channel_rsp mt7697_rsp_hdr
#define mt7697_set_bssid_rsp mt7697_rsp_hdr
#define mt7697_set_ssid_rsp mt7697_rsp_hdr
#define mt7697_set_security_mode_rsp mt7697_rsp_hdr
#define mt7697_scan_stop_rsp mt7697_rsp_hdr
#define mt7697_reload_settings_rsp mt7697_rsp_hdr
#define mt7697_disconnect_rsp mt7697_rsp_hdr
#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_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_set_wireless_mode_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_pmk_rsp mt7697_rsp_hdr
#define mt7697_set_channel_rsp mt7697_rsp_hdr
#define mt7697_set_bssid_rsp mt7697_rsp_hdr
#define mt7697_set_ssid_rsp mt7697_rsp_hdr
#define mt7697_set_security_mode_rsp mt7697_rsp_hdr
#define mt7697_scan_stop_rsp mt7697_rsp_hdr
#define mt7697_reload_settings_rsp mt7697_rsp_hdr
#define mt7697_disconnect_rsp mt7697_rsp_hdr
enum mt7697_connect_ctrl_flags_bits {
MT7697_CONNECT_ASSOC_POLICY_USER = 0x0001,
MT7697_CONNECT_SEND_REASSOC = 0x0002,
MT7697_CONNECT_ASSOC_POLICY_USER = 0x0001,
MT7697_CONNECT_SEND_REASSOC = 0x0002,
MT7697_CONNECT_IGNORE_WPAx_GROUP_CIPHER = 0x0004,
MT7697_CONNECT_PROFILE_MATCH_DONE = 0x0008,
MT7697_CONNECT_IGNORE_AAC_BEACON = 0x0010,
MT7697_CONNECT_CSA_FOLLOW_BSS = 0x0020,
MT7697_CONNECT_DO_WPA_OFFLOAD = 0x0040,
MT7697_CONNECT_DO_NOT_DEAUTH = 0x0080,
MT7697_CONNECT_WPS_FLAG = 0x0100,
MT7697_CONNECT_PROFILE_MATCH_DONE = 0x0008,
MT7697_CONNECT_IGNORE_AAC_BEACON = 0x0010,
MT7697_CONNECT_CSA_FOLLOW_BSS = 0x0020,
MT7697_CONNECT_DO_WPA_OFFLOAD = 0x0040,
MT7697_CONNECT_DO_NOT_DEAUTH = 0x0080,
MT7697_CONNECT_WPS_FLAG = 0x0100,
};
enum mt7697_wifi_cmd_types {
......@@ -106,156 +106,156 @@ struct mt7697_cfg80211_info;
struct cfg80211_scan_request;
struct mt7697_mac_addr_req {
struct mt7697_cmd_hdr cmd;
__be32 port;
struct mt7697_cmd_hdr cmd;
__be32 port;
} __attribute__((packed, aligned(4)));
struct mt7697_mac_addr_rsp {
struct mt7697_rsp_hdr rsp;
u8 addr[LEN32_ALIGNED(ETH_ALEN)];
struct mt7697_rsp_hdr rsp;
u8 addr[LEN32_ALIGNED(ETH_ALEN)];
} __attribute__((packed, aligned(4)));
struct mt7697_get_wireless_mode_req {
struct mt7697_cmd_hdr cmd;
__be32 port;
struct mt7697_cmd_hdr cmd;
__be32 port;
} __attribute__((packed, aligned(4)));
struct mt7697_get_wireless_mode_rsp {
struct mt7697_rsp_hdr rsp;
__be32 mode;
struct mt7697_rsp_hdr rsp;
__be32 mode;
} __attribute__((packed, aligned(4)));
struct mt7697_set_wireless_mode_req {
struct mt7697_cmd_hdr cmd;
__be32 port;
__be32 mode;
struct mt7697_cmd_hdr cmd;
__be32 port;
__be32 mode;
} __attribute__((packed, aligned(4)));
struct mt7697_cfg_rsp {
struct mt7697_rsp_hdr rsp;
struct mt7697_wifi_config_t cfg;
struct mt7697_rsp_hdr rsp;
struct mt7697_wifi_config_t cfg;
} __attribute__((packed, aligned(4)));
struct mt7697_set_op_mode_req {
struct mt7697_cmd_hdr cmd;
__be32 opmode;
struct mt7697_cmd_hdr cmd;
__be32 opmode;
} __attribute__((packed, aligned(4)));
struct mt7697_get_listen_interval_rsp {
struct mt7697_rsp_hdr rsp;
__be32 interval;
struct mt7697_rsp_hdr rsp;
__be32 interval;
} __attribute__((packed, aligned(4)));
struct mt7697_set_listen_interval_req {
struct mt7697_cmd_hdr cmd;
__be32 interval;
struct mt7697_cmd_hdr cmd;
__be32 interval;
} __attribute__((packed, aligned(4)));
struct mt7697_reload_settings_req {
struct mt7697_cmd_hdr cmd;
__be32 if_idx;
struct mt7697_cmd_hdr cmd;
__be32 if_idx;
} __attribute__((packed, aligned(4)));
struct mt7697_scan_req {
struct mt7697_cmd_hdr cmd;
__be32 if_idx;
__be32 mode;
__be32 option;
__be32 bssid_len;
u8 bssid[LEN32_ALIGNED(ETH_ALEN)];
__be32 ssid_len;
u8 ssid[LEN32_ALIGNED(IEEE80211_MAX_SSID_LEN)];
struct mt7697_cmd_hdr cmd;
__be32 if_idx;
__be32 mode;
__be32 option;
__be32 bssid_len;
u8 bssid[LEN32_ALIGNED(ETH_ALEN)];
__be32 ssid_len;
u8 ssid[LEN32_ALIGNED(IEEE80211_MAX_SSID_LEN)];
} __attribute__((packed, aligned(4)));
struct mt7697_scan_rsp {
struct mt7697_rsp_hdr rsp;
__be32 if_idx;
struct mt7697_rsp_hdr rsp;
__be32 if_idx;
} __attribute__((packed, aligned(4)));
struct mt7697_scan_ind {
struct mt7697_rsp_hdr rsp;
__be32 rssi;
__be32 channel;
u8 probe_rsp[];
struct mt7697_rsp_hdr rsp;
__be32 rssi;
__be32 channel;
u8 probe_rsp[];
} __attribute__((packed, aligned(4)));
struct mt7697_scan_complete_ind {
struct mt7697_rsp_hdr rsp;
__be32 if_idx;
struct mt7697_rsp_hdr rsp;
__be32 if_idx;
} __attribute__((packed, aligned(4)));
struct mt7697_set_pmk_req {
struct mt7697_cmd_hdr cmd;
__be32 port;
u8 pmk[LEN32_ALIGNED(MT7697_WIFI_LENGTH_PASSPHRASE)];
struct mt7697_cmd_hdr cmd;
__be32 port;
u8 pmk[LEN32_ALIGNED(MT7697_WIFI_LENGTH_PASSPHRASE)];
} __attribute__((packed, aligned(4)));
struct mt7697_set_channel_req {
struct mt7697_cmd_hdr cmd;
__be32 port;
__be32 ch;
struct mt7697_cmd_hdr cmd;
__be32 port;
__be32 ch;
} __attribute__((packed, aligned(4)));
struct mt7697_set_bssid_req {
struct mt7697_cmd_hdr cmd;
u8 bssid[LEN32_ALIGNED(ETH_ALEN)];
struct mt7697_cmd_hdr cmd;
u8 bssid[LEN32_ALIGNED(ETH_ALEN)];
} __attribute__((packed, aligned(4)));
struct mt7697_set_ssid_req {
struct mt7697_cmd_hdr cmd;
__be32 port;
__be32 len;
u8 ssid[LEN32_ALIGNED(IEEE80211_MAX_SSID_LEN)];
struct mt7697_cmd_hdr cmd;
__be32 port;
__be32 len;
u8 ssid[LEN32_ALIGNED(IEEE80211_MAX_SSID_LEN)];
} __attribute__((packed, aligned(4)));
struct mt7697_set_security_mode_req {
struct mt7697_cmd_hdr cmd;
__be32 port;
__be32 auth_mode;
__be32 encrypt_type;
struct mt7697_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;
__be32 if_idx;
__be32 port;
struct mt7697_cmd_hdr cmd;
__be32 if_idx;
__be32 port;
} __attribute__((packed, aligned(4)));
struct mt7697_get_security_mode_rsp {
struct mt7697_rsp_hdr rsp;
__be32 if_idx;
__be32 auth_mode;
__be32 encrypt_type;
struct mt7697_rsp_hdr rsp;
__be32 if_idx;
__be32 auth_mode;
__be32 encrypt_type;
} __attribute__((packed, aligned(4)));
struct mt7697_connect_ind {
struct mt7697_rsp_hdr rsp;
__be32 if_idx;
__be32 channel;
u8 bssid[LEN32_ALIGNED(ETH_ALEN)];
struct mt7697_rsp_hdr rsp;
__be32 if_idx;
__be32 channel;
u8 bssid[LEN32_ALIGNED(ETH_ALEN)];
} __attribute__((packed, aligned(4)));
struct mt7697_disconnect_req {
struct mt7697_cmd_hdr cmd;
__be32 port;
u8 addr[LEN32_ALIGNED(ETH_ALEN)];
struct mt7697_cmd_hdr cmd;
__be32 port;
u8 addr[LEN32_ALIGNED(ETH_ALEN)];
} __attribute__((packed, aligned(4)));
struct mt7697_disconnect_ind {
struct mt7697_rsp_hdr rsp;
__be32 if_idx;
u8 bssid[LEN32_ALIGNED(ETH_ALEN)];
struct mt7697_rsp_hdr rsp;
__be32 if_idx;
u8 bssid[LEN32_ALIGNED(ETH_ALEN)];
} __attribute__((packed, aligned(4)));
struct mt7697_tx_raw_packet {
struct mt7697_cmd_hdr cmd;
__be32 len;
u8 data[LEN32_ALIGNED(IEEE80211_MAX_FRAME_LEN)];
struct mt7697_cmd_hdr cmd;
__be32 len;
u8 data[LEN32_ALIGNED(IEEE80211_MAX_FRAME_LEN)];
} __attribute__((packed, aligned(4)));
struct mt7697_rx_raw_packet {
struct mt7697_rsp_hdr hdr;
u8 data[];
struct mt7697_rsp_hdr hdr;
u8 data[];
} __attribute__((packed, aligned(4)));
int mt7697_wr_set_wireless_mode_req(const struct mt7697_cfg80211_info*, u8);
......
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