int len, bool wait_resp);
int (*mcu_skb_send_msg)(struct mt76_dev *dev, struct sk_buff *skb,
int cmd, bool wait_resp);
+ int (*mcu_parse_response)(struct mt76_dev *dev, int cmd,
+ struct sk_buff *skb, int seq);
u32 (*mcu_rr)(struct mt76_dev *dev, u32 offset);
void (*mcu_wr)(struct mt76_dev *dev, u32 offset, u32 val);
int (*mcu_wr_rp)(struct mt76_dev *dev, u32 base,
} __packed;
static int
+mt7603_mcu_parse_response(struct mt76_dev *mdev, int cmd,
+ struct sk_buff *skb, int seq)
+{
+ struct mt7603_mcu_rxd *rxd = (struct mt7603_mcu_rxd *)skb->data;
+
+ if (seq != rxd->seq)
+ return -EAGAIN;
+
+ return 0;
+}
+
+static int
__mt7603_mcu_msg_send(struct mt7603_dev *dev, struct sk_buff *skb,
int cmd, int *wait_seq)
{
{
struct mt7603_dev *dev = container_of(mdev, struct mt7603_dev, mt76);
unsigned long expires = jiffies + 3 * HZ;
- struct mt7603_mcu_rxd *rxd;
struct sk_buff *skb;
int ret, seq;
goto out;
while (wait_resp) {
- bool check_seq = false;
-
skb = mt76_mcu_get_response(&dev->mt76, expires);
if (!skb) {
dev_err(mdev->dev,
break;
}
- rxd = (struct mt7603_mcu_rxd *)skb->data;
- if (seq == rxd->seq)
- check_seq = true;
-
+ ret = mt7603_mcu_parse_response(mdev, cmd, skb, seq);
dev_kfree_skb(skb);
-
- if (check_seq)
+ if (ret != -EAGAIN)
break;
}
static const struct mt76_mcu_ops mt7603_mcu_ops = {
.headroom = sizeof(struct mt7603_mcu_txd),
.mcu_send_msg = mt7603_mcu_msg_send,
+ .mcu_parse_response = mt7603_mcu_parse_response,
.mcu_restart = mt7603_mcu_restart,
};
return mt76_tx_queue_skb_raw(dev, qid, skb, 0);
}
-static int
-mt7615_mcu_parse_response(struct mt7615_dev *dev, int cmd,
- struct sk_buff *skb, int seq)
+int mt7615_mcu_parse_response(struct mt76_dev *mdev, int cmd,
+ struct sk_buff *skb, int seq)
{
struct mt7615_mcu_rxd *rxd = (struct mt7615_mcu_rxd *)skb->data;
int ret = 0;
- if (seq != rxd->seq) {
- ret = -EAGAIN;
- goto out;
- }
+ if (seq != rxd->seq)
+ return -EAGAIN;
switch (cmd) {
case MCU_CMD_PATCH_SEM_CONTROL:
default:
break;
}
-out:
- dev_kfree_skb(skb);
return ret;
}
+EXPORT_SYMBOL_GPL(mt7615_mcu_parse_response);
int mt7615_mcu_wait_response(struct mt7615_dev *dev, int cmd, int seq)
{
return -ETIMEDOUT;
}
- ret = mt7615_mcu_parse_response(dev, cmd, skb, seq);
+ ret = mt7615_mcu_parse_response(&dev->mt76, cmd, skb, seq);
+ dev_kfree_skb(skb);
if (ret != -EAGAIN)
break;
}
.headroom = sizeof(struct mt7615_mcu_txd),
.mcu_skb_send_msg = mt7615_mcu_send_message,
.mcu_send_msg = mt7615_mcu_msg_send,
+ .mcu_parse_response = mt7615_mcu_parse_response,
.mcu_restart = mt7615_mcu_restart,
};
int ret;
int mt7615_mcu_wait_response(struct mt7615_dev *dev, int cmd, int seq);
int mt7615_mcu_msg_send(struct mt76_dev *mdev, int cmd, const void *data,
int len, bool wait_resp);
+int mt7615_mcu_parse_response(struct mt76_dev *mdev, int cmd,
+ struct sk_buff *skb, int seq);
u32 mt7615_rf_rr(struct mt7615_dev *dev, u32 wf, u32 reg);
int mt7615_rf_wr(struct mt7615_dev *dev, u32 wf, u32 reg, u32 val);
int mt7615_mcu_set_dbdc(struct mt7615_dev *dev);
.tailroom = MT_USB_TAIL_SIZE,
.mcu_skb_send_msg = mt7663s_mcu_send_message,
.mcu_send_msg = mt7615_mcu_msg_send,
+ .mcu_parse_response = mt7615_mcu_parse_response,
.mcu_restart = mt7615_mcu_restart,
.mcu_rr = mt7615_mcu_reg_rr,
.mcu_wr = mt7615_mcu_reg_wr,
.tailroom = MT_USB_TAIL_SIZE,
.mcu_skb_send_msg = mt7663u_mcu_send_message,
.mcu_send_msg = mt7615_mcu_msg_send,
+ .mcu_parse_response = mt7615_mcu_parse_response,
.mcu_restart = mt7615_mcu_restart,
};
int ret;
{
static const struct mt76_mcu_ops mt76x0e_mcu_ops = {
.mcu_send_msg = mt76x02_mcu_msg_send,
+ .mcu_parse_response = mt76x02_mcu_parse_response,
};
int err;
#include "mt76x02_mcu.h"
+int mt76x02_mcu_parse_response(struct mt76_dev *mdev, int cmd,
+ struct sk_buff *skb, int seq)
+{
+ u32 *rxfce = (u32 *)skb->cb;
+
+ if (seq != FIELD_GET(MT_RX_FCE_INFO_CMD_SEQ, *rxfce))
+ return -EAGAIN;
+
+ return 0;
+}
+EXPORT_SYMBOL_GPL(mt76x02_mcu_parse_response);
+
int mt76x02_mcu_msg_send(struct mt76_dev *mdev, int cmd, const void *data,
int len, bool wait_resp)
{
goto out;
while (wait_resp) {
- u32 *rxfce;
- bool check_seq = false;
-
skb = mt76_mcu_get_response(&dev->mt76, expires);
if (!skb) {
dev_err(mdev->dev,
break;
}
- rxfce = (u32 *)skb->cb;
-
- if (seq == FIELD_GET(MT_RX_FCE_INFO_CMD_SEQ, *rxfce))
- check_seq = true;
-
+ ret = mt76x02_mcu_parse_response(mdev, cmd, skb, seq);
dev_kfree_skb(skb);
- if (check_seq)
+ if (ret != -EAGAIN)
break;
}
int mt76x02_mcu_calibrate(struct mt76x02_dev *dev, int type, u32 param);
int mt76x02_mcu_msg_send(struct mt76_dev *mdev, int cmd, const void *data,
int len, bool wait_resp);
+int mt76x02_mcu_parse_response(struct mt76_dev *mdev, int cmd,
+ struct sk_buff *skb, int seq);
int mt76x02_mcu_function_select(struct mt76x02_dev *dev, enum mcu_function func,
u32 val);
int mt76x02_mcu_set_radio_state(struct mt76x02_dev *dev, bool on);
.headroom = MT_CMD_HDR_LEN,
.tailroom = 8,
.mcu_send_msg = mt76x02u_mcu_send_msg,
+ .mcu_parse_response = mt76x02_mcu_parse_response,
.mcu_wr_rp = mt76x02u_mcu_wr_rp,
.mcu_rd_rp = mt76x02u_mcu_rd_rp,
};
static const struct mt76_mcu_ops mt76x2_mcu_ops = {
.mcu_restart = mt76pci_mcu_restart,
.mcu_send_msg = mt76x02_mcu_msg_send,
+ .mcu_parse_response = mt76x02_mcu_parse_response,
};
int ret;
}
static int
-mt7915_mcu_parse_response(struct mt7915_dev *dev, int cmd,
+mt7915_mcu_parse_response(struct mt76_dev *mdev, int cmd,
struct sk_buff *skb, int seq)
{
+ struct mt7915_dev *dev = container_of(mdev, struct mt7915_dev, mt76);
struct mt7915_mcu_rxd *rxd = (struct mt7915_mcu_rxd *)skb->data;
int ret = 0;
- if (seq != rxd->seq) {
- ret = -EAGAIN;
- goto out;
- }
+ if (seq != rxd->seq)
+ return -EAGAIN;
switch (cmd) {
case -MCU_CMD_PATCH_SEM_CONTROL:
default:
break;
}
-out:
- dev_kfree_skb(skb);
return ret;
}
return -ETIMEDOUT;
}
- ret = mt7915_mcu_parse_response(dev, cmd, skb, seq);
+ ret = mt7915_mcu_parse_response(&dev->mt76, cmd, skb, seq);
+ dev_kfree_skb(skb);
if (ret != -EAGAIN)
break;
}
.headroom = sizeof(struct mt7915_mcu_txd),
.mcu_skb_send_msg = mt7915_mcu_send_message,
.mcu_send_msg = mt7915_mcu_msg_send,
+ .mcu_parse_response = mt7915_mcu_parse_response,
.mcu_restart = mt7915_mcu_restart,
};
int ret;