}
static int
-mt7615_mcu_msg_send(struct mt7615_dev *dev, int cmd, const void *data,
+mt7615_mcu_msg_send(struct mt76_dev *mdev, int cmd, const void *data,
int len, bool wait_resp)
{
+ struct mt7615_dev *dev = container_of(mdev, struct mt7615_dev, mt76);
unsigned long expires = jiffies + 10 * HZ;
struct mt7615_mcu_rxd *rxd;
struct sk_buff *skb;
if (!skb)
return -ENOMEM;
- mutex_lock(&dev->mt76.mmio.mcu.mutex);
+ mutex_lock(&mdev->mmio.mcu.mutex);
ret = __mt7615_mcu_msg_send(dev, skb, cmd, &seq);
if (ret)
goto out;
while (wait_resp) {
- skb = mt76_mcu_get_response(&dev->mt76, expires);
+ skb = mt76_mcu_get_response(mdev, expires);
if (!skb) {
- dev_err(dev->mt76.dev, "Message %d (seq %d) timeout\n",
+ dev_err(mdev->dev, "Message %d (seq %d) timeout\n",
cmd, seq);
ret = -ETIMEDOUT;
break;
}
out:
- mutex_unlock(&dev->mt76.mmio.mcu.mutex);
+ mutex_unlock(&mdev->mmio.mcu.mutex);
return ret;
}
.mode = cpu_to_le32(mode),
};
- return mt7615_mcu_msg_send(dev, -MCU_CMD_TARGET_ADDRESS_LEN_REQ,
+ return __mt76_mcu_send_msg(&dev->mt76, -MCU_CMD_TARGET_ADDRESS_LEN_REQ,
&req, sizeof(req), true);
}
.addr = cpu_to_le32(addr),
};
- return mt7615_mcu_msg_send(dev, -MCU_CMD_FW_START_REQ,
+ return __mt76_mcu_send_msg(&dev->mt76, -MCU_CMD_FW_START_REQ,
&req, sizeof(req), true);
}
static int mt7615_mcu_restart(struct mt7615_dev *dev)
{
- return mt7615_mcu_msg_send(dev, -MCU_CMD_RESTART_DL_REQ,
+ return __mt76_mcu_send_msg(&dev->mt76, -MCU_CMD_RESTART_DL_REQ,
NULL, 0, true);
}
.op = cpu_to_le32(get ? PATCH_SEM_GET : PATCH_SEM_RELEASE),
};
- return mt7615_mcu_msg_send(dev, -MCU_CMD_PATCH_SEM_CONTROL,
+ return __mt76_mcu_send_msg(&dev->mt76, -MCU_CMD_PATCH_SEM_CONTROL,
&req, sizeof(req), true);
}
.check_crc = 0,
};
- return mt7615_mcu_msg_send(dev, -MCU_CMD_PATCH_FINISH_REQ,
+ return __mt76_mcu_send_msg(&dev->mt76, -MCU_CMD_PATCH_FINISH_REQ,
&req, sizeof(req), true);
}
int mt7615_mcu_init(struct mt7615_dev *dev)
{
+ static const struct mt76_mcu_ops mt7615_mcu_ops = {
+ .mcu_send_msg = mt7615_mcu_msg_send,
+ };
int ret;
+ dev->mt76.mcu_ops = &mt7615_mcu_ops,
+
ret = mt7615_driver_own(dev);
if (ret)
return ret;
memcpy(req + sizeof(req_hdr), eep + MT_EE_NIC_CONF_0,
__MT_EE_MAX - MT_EE_NIC_CONF_0);
- ret = mt7615_mcu_msg_send(dev, MCU_EXT_CMD_EFUSE_BUFFER_MODE,
+ ret = __mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD_EFUSE_BUFFER_MODE,
req, len, true);
kfree(req);
.band = 0,
};
- return mt7615_mcu_msg_send(dev, MCU_EXT_CMD_MAC_INIT_CTRL,
+ return __mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD_MAC_INIT_CTRL,
&req, sizeof(req), true);
}
.pkt_thresh = cpu_to_le32(0x2),
};
- return mt7615_mcu_msg_send(dev, MCU_EXT_CMD_PROTECT_CTRL,
+ return __mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD_PROTECT_CTRL,
&req, sizeof(req), true);
}
req.cw_max = cpu_to_le16(params->cw_max);
}
- return mt7615_mcu_msg_send(dev, MCU_EXT_CMD_EDCA_UPDATE,
+ return __mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD_EDCA_UPDATE,
&req, sizeof(req), true);
}
.band_idx = 0,
};
- return mt7615_mcu_msg_send(dev, MCU_EXT_CMD_PM_STATE_CTRL,
+ return __mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD_PM_STATE_CTRL,
&req, sizeof(req), true);
}
};
memcpy(data.tlv.omac_addr, vif->addr, ETH_ALEN);
- return mt7615_mcu_msg_send(dev, MCU_EXT_CMD_DEV_INFO_UPDATE,
+ return __mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD_DEV_INFO_UPDATE,
&data, sizeof(data), true);
}
}
}
- ret = mt7615_mcu_msg_send(dev, MCU_EXT_CMD_BSS_INFO_UPDATE,
+ ret = __mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD_BSS_INFO_UPDATE,
buf, len, true);
kfree(buf);
req.key.key_len = sizeof(req.key.key_material);
}
- return mt7615_mcu_msg_send(dev, MCU_EXT_CMD_WTBL_UPDATE,
+ return __mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD_WTBL_UPDATE,
&req, sizeof(req), true);
}
};
eth_broadcast_addr(req.g_wtbl.peer_addr);
- return mt7615_mcu_msg_send(dev, MCU_EXT_CMD_WTBL_UPDATE,
+ return __mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD_WTBL_UPDATE,
&req, sizeof(req), true);
}
.operation = WTBL_RESET_AND_SET,
};
- return mt7615_mcu_msg_send(dev, MCU_EXT_CMD_WTBL_UPDATE,
+ return __mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD_WTBL_UPDATE,
&req, sizeof(req), true);
}
};
memcpy(req.g_wtbl.peer_addr, sta->addr, ETH_ALEN);
- return mt7615_mcu_msg_send(dev, MCU_EXT_CMD_WTBL_UPDATE,
+ return __mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD_WTBL_UPDATE,
&req, sizeof(req), true);
}
.operation = WTBL_RESET_AND_SET,
};
- return mt7615_mcu_msg_send(dev, MCU_EXT_CMD_WTBL_UPDATE,
+ return __mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD_WTBL_UPDATE,
&req, sizeof(req), true);
}
.operation = WTBL_RESET_ALL,
};
- return mt7615_mcu_msg_send(dev, MCU_EXT_CMD_WTBL_UPDATE,
+ return __mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD_WTBL_UPDATE,
&req, sizeof(req), true);
}
req.basic.extra_info = cpu_to_le16(EXTRA_INFO_VER);
}
- return mt7615_mcu_msg_send(dev, MCU_EXT_CMD_STA_REC_UPDATE,
+ return __mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD_STA_REC_UPDATE,
&req, sizeof(req), true);
}
req.basic.extra_info = cpu_to_le16(EXTRA_INFO_VER);
}
- return mt7615_mcu_msg_send(dev, MCU_EXT_CMD_STA_REC_UPDATE,
+ return __mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD_STA_REC_UPDATE,
&req, sizeof(req), true);
}
dev_kfree_skb(skb);
- return mt7615_mcu_msg_send(dev, MCU_EXT_CMD_BCN_OFFLOAD,
+ return __mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD_BCN_OFFLOAD,
&req, sizeof(req), true);
}
}
memset(req.txpower_sku, 0x3f, 49);
- ret = mt7615_mcu_msg_send(dev, MCU_EXT_CMD_CHANNEL_SWITCH,
+ ret = __mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD_CHANNEL_SWITCH,
&req, sizeof(req), true);
if (ret)
return ret;
- return mt7615_mcu_msg_send(dev, MCU_EXT_CMD_SET_RX_PATH,
+ return __mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD_SET_RX_PATH,
&req, sizeof(req), true);
}
wtbl_raw->val = cpu_to_le32(val);
wtbl_hdr->tlv_num = cpu_to_le16(ntlv);
- ret = mt7615_mcu_msg_send(dev, MCU_EXT_CMD_WTBL_UPDATE,
+ ret = __mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD_WTBL_UPDATE,
buf, buf_len, true);
if (ret)
goto out;
cpu_to_le16(sta->vht_cap.vht_mcs.tx_mcs_map);
}
- ret = mt7615_mcu_msg_send(dev, MCU_EXT_CMD_STA_REC_UPDATE,
+ ret = __mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD_STA_REC_UPDATE,
buf, buf_len, true);
out:
kfree(buf);
wtbl_req.ba.ba_winsize_idx = idx;
}
- ret = mt7615_mcu_msg_send(dev, MCU_EXT_CMD_WTBL_UPDATE,
+ ret = __mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD_WTBL_UPDATE,
&wtbl_req, sizeof(wtbl_req), true);
if (ret)
return ret;
- return mt7615_mcu_msg_send(dev, MCU_EXT_CMD_STA_REC_UPDATE,
+ return __mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD_STA_REC_UPDATE,
&sta_req, sizeof(sta_req), true);
}
memcpy(wtbl_req.ba.peer_addr, params->sta->addr, ETH_ALEN);
- ret = mt7615_mcu_msg_send(dev, MCU_EXT_CMD_STA_REC_UPDATE,
+ ret = __mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD_STA_REC_UPDATE,
&sta_req, sizeof(sta_req), true);
if (ret || !add)
return ret;
- return mt7615_mcu_msg_send(dev, MCU_EXT_CMD_WTBL_UPDATE,
+ return __mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD_WTBL_UPDATE,
&wtbl_req, sizeof(wtbl_req), true);
}