mt76: mt7615: introduce mt7615_mcu_send_message routine
authorLorenzo Bianconi <lorenzo@kernel.org>
Tue, 17 Mar 2020 16:41:13 +0000 (17:41 +0100)
committerFelix Fietkau <nbd@nbd.name>
Tue, 17 Mar 2020 16:47:52 +0000 (17:47 +0100)
Introduce mt7615_mcu_send_message routine in order to allocate mcu skb
out of mcu sending routine. This approach is useful when the mcu
message is complicated and it is convenient to rely on skb buffer API

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
drivers/net/wireless/mediatek/mt76/mt76.h
drivers/net/wireless/mediatek/mt76/mt7615/mcu.c

index aca4774..8e4759b 100644 (file)
@@ -139,6 +139,8 @@ struct mt76_sw_queue {
 struct mt76_mcu_ops {
        int (*mcu_send_msg)(struct mt76_dev *dev, int cmd, const void *data,
                            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_wr_rp)(struct mt76_dev *dev, u32 base,
                         const struct mt76_reg_pair *rp, int len);
        int (*mcu_rd_rp)(struct mt76_dev *dev, u32 base,
@@ -588,7 +590,9 @@ enum mt76_phy_type {
 #define mt76_rd_rp(dev, ...)   (dev)->mt76.bus->rd_rp(&((dev)->mt76), __VA_ARGS__)
 
 #define mt76_mcu_send_msg(dev, ...)    (dev)->mt76.mcu_ops->mcu_send_msg(&((dev)->mt76), __VA_ARGS__)
+
 #define __mt76_mcu_send_msg(dev, ...)  (dev)->mcu_ops->mcu_send_msg((dev), __VA_ARGS__)
+#define __mt76_mcu_skb_send_msg(dev, ...)      (dev)->mcu_ops->mcu_skb_send_msg((dev), __VA_ARGS__)
 #define mt76_mcu_restart(dev, ...)     (dev)->mt76.mcu_ops->mcu_restart(&((dev)->mt76))
 #define __mt76_mcu_restart(dev, ...)   (dev)->mcu_ops->mcu_restart((dev))
 
index b94b1b7..eb6867a 100644 (file)
@@ -166,17 +166,12 @@ int mt7615_mcu_wait_response(struct mt7615_dev *dev, int cmd, int seq)
 }
 
 static int
-mt7615_mcu_msg_send(struct mt76_dev *mdev, int cmd, const void *data,
-                   int len, bool wait_resp)
+mt7615_mcu_send_message(struct mt76_dev *mdev, struct sk_buff *skb,
+                       int cmd, bool wait_resp)
 {
        struct mt7615_dev *dev = container_of(mdev, struct mt7615_dev, mt76);
-       struct sk_buff *skb;
        int ret, seq;
 
-       skb = mt7615_mcu_msg_alloc(data, len);
-       if (!skb)
-               return -ENOMEM;
-
        mutex_lock(&mdev->mcu.mutex);
 
        ret = __mt7615_mcu_msg_send(dev, skb, cmd, &seq);
@@ -192,6 +187,19 @@ out:
        return ret;
 }
 
+static int
+mt7615_mcu_msg_send(struct mt76_dev *mdev, int cmd, const void *data,
+                   int len, bool wait_resp)
+{
+       struct sk_buff *skb;
+
+       skb = mt7615_mcu_msg_alloc(data, len);
+       if (!skb)
+               return -ENOMEM;
+
+       return __mt76_mcu_skb_send_msg(mdev, skb, cmd, wait_resp);
+}
+
 static void
 mt7615_mcu_csa_finish(void *priv, u8 *mac, struct ieee80211_vif *vif)
 {
@@ -704,6 +712,7 @@ int mt7615_mcu_fw_log_2_host(struct mt7615_dev *dev, u8 ctrl)
 int mt7615_mcu_init(struct mt7615_dev *dev)
 {
        static const struct mt76_mcu_ops mt7615_mcu_ops = {
+               .mcu_skb_send_msg = mt7615_mcu_send_message,
                .mcu_send_msg = mt7615_mcu_msg_send,
                .mcu_restart = mt7615_mcu_restart,
        };