]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
mt76: usb: use mt76x02u_tx_prepare_skb to fill txwi
authorLorenzo Bianconi <lorenzo.bianconi@redhat.com>
Mon, 1 Oct 2018 16:58:20 +0000 (18:58 +0200)
committerFelix Fietkau <nbd@nbd.name>
Fri, 5 Oct 2018 18:05:44 +0000 (20:05 +0200)
Use mt76x02u_tx_prepare_skb routine to fill txwi in mt76x2u and
mt76x0u driver and remove duplicated code. Moreover add static
qualifier to mt76x02_mac_tx_rate_val and mt76x02_mac_fill_txwi
routines

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
drivers/net/wireless/mediatek/mt76/mt76x0/mt76x0.h
drivers/net/wireless/mediatek/mt76/mt76x0/tx.c
drivers/net/wireless/mediatek/mt76/mt76x0/usb.c
drivers/net/wireless/mediatek/mt76/mt76x02_mac.c
drivers/net/wireless/mediatek/mt76/mt76x02_mac.h
drivers/net/wireless/mediatek/mt76/mt76x02_usb.h
drivers/net/wireless/mediatek/mt76/mt76x02_usb_core.c
drivers/net/wireless/mediatek/mt76/mt76x2/Makefile
drivers/net/wireless/mediatek/mt76/mt76x2/mt76x2u.h
drivers/net/wireless/mediatek/mt76/mt76x2/usb_core.c [deleted file]
drivers/net/wireless/mediatek/mt76/mt76x2/usb_init.c

index a37dbf944b155ec77bbb15115fe5bae0f65988ce..e54468af6ba7284ba290aa288aa0408ecc90f291 100644 (file)
@@ -168,11 +168,6 @@ void mt76x0_mac_set_ampdu_factor(struct mt76x0_dev *dev);
 /* TX */
 void mt76x0_tx(struct ieee80211_hw *hw, struct ieee80211_tx_control *control,
                struct sk_buff *skb);
-struct mt76x02_txwi *
-mt76x0_push_txwi(struct mt76x0_dev *dev, struct sk_buff *skb,
-                struct ieee80211_sta *sta, struct mt76_wcid *wcid,
-                int pkt_len);
-
 void mt76x0_queue_rx_skb(struct mt76_dev *mdev, enum mt76_rxq_id q,
                         struct sk_buff *skb);
 
index b3c5dc2ffeb1ea2ecd01bfe4539486ada61b3efa..79c0b3ba1ccb749ee62c1732a225edc40b1d2b33 100644 (file)
 #include "../mt76x02_util.h"
 #include "../mt76x02_usb.h"
 
-struct mt76x02_txwi *
-mt76x0_push_txwi(struct mt76x0_dev *dev, struct sk_buff *skb,
-                struct ieee80211_sta *sta, struct mt76_wcid *wcid,
-                int pkt_len)
-{
-       struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
-       struct ieee80211_tx_rate *rate = &info->control.rates[0];
-       struct mt76x02_txwi *txwi;
-       unsigned long flags;
-       u16 rate_ctl;
-       u8 nss;
-
-       txwi = (struct mt76x02_txwi *)skb_push(skb, sizeof(struct mt76x02_txwi));
-       memset(txwi, 0, sizeof(*txwi));
-
-       if (!wcid->tx_rate_set)
-               ieee80211_get_tx_rates(info->control.vif, sta, skb,
-                                      info->control.rates, 1);
-
-       spin_lock_irqsave(&dev->mt76.lock, flags);
-       if (rate->idx < 0 || !rate->count) {
-               rate_ctl = wcid->tx_rate;
-               nss = wcid->tx_rate_nss;
-       } else {
-               rate_ctl = mt76x02_mac_tx_rate_val(&dev->mt76, rate, &nss);
-       }
-       spin_unlock_irqrestore(&dev->mt76.lock, flags);
-
-       txwi->wcid = wcid->idx;
-       txwi->rate = cpu_to_le16(rate_ctl);
-       txwi->pktid = (!(info->flags & IEEE80211_TX_CTL_NO_ACK)) ? 1 : 0;
-
-       mt76x02_mac_fill_txwi(txwi, skb, sta, pkt_len, nss);
-
-       return txwi;
-}
-EXPORT_SYMBOL_GPL(mt76x0_push_txwi);
-
 void mt76x0_tx(struct ieee80211_hw *hw, struct ieee80211_tx_control *control,
               struct sk_buff *skb)
 {
index 57862cacf22ae9d67ff71e245e1615ba78cdddb8..4cc11e29d81d7435b4389207cda503dcd892fa1a 100644 (file)
@@ -159,21 +159,6 @@ static const struct ieee80211_ops mt76x0u_ops = {
        .wake_tx_queue = mt76_wake_tx_queue,
 };
 
-static int mt76x0u_tx_prepare_skb(struct mt76_dev *mdev, void *data,
-                                 struct sk_buff *skb, struct mt76_queue *q,
-                                 struct mt76_wcid *wcid, struct ieee80211_sta *sta,
-                                 u32 *tx_info)
-{
-       struct mt76x0_dev *dev = container_of(mdev, struct mt76x0_dev, mt76);
-       struct mt76x02_txwi *txwi;
-       int len = skb->len;
-
-       mt76x02_insert_hdr_pad(skb);
-       txwi = mt76x0_push_txwi(dev, skb, sta, wcid, len);
-
-       return mt76x02u_set_txinfo(skb, wcid, q2ep(q->hw_idx));
-}
-
 static int mt76x0u_register_device(struct mt76x0_dev *dev)
 {
        struct ieee80211_hw *hw = dev->mt76.hw;
@@ -230,7 +215,7 @@ static int mt76x0u_probe(struct usb_interface *usb_intf,
                         const struct usb_device_id *id)
 {
        static const struct mt76_driver_ops drv_ops = {
-               .tx_prepare_skb = mt76x0u_tx_prepare_skb,
+               .tx_prepare_skb = mt76x02u_tx_prepare_skb,
                .tx_complete_skb = mt76x02_tx_complete_skb,
                .tx_status_data = mt76x02_tx_status_data,
                .rx_skb = mt76x0_queue_rx_skb,
index 71d677a6b88a90404153e9f0e63445a518f3d371..a02e976654633c68db458320dcb0de3c15d50e45 100644 (file)
@@ -157,8 +157,9 @@ void mt76x02_txq_init(struct mt76_dev *dev, struct ieee80211_txq *txq)
 }
 EXPORT_SYMBOL_GPL(mt76x02_txq_init);
 
-void mt76x02_mac_fill_txwi(struct mt76x02_txwi *txwi, struct sk_buff *skb,
-                         struct ieee80211_sta *sta, int len, u8 nss)
+static void
+mt76x02_mac_fill_txwi(struct mt76x02_txwi *txwi, struct sk_buff *skb,
+                     struct ieee80211_sta *sta, int len, u8 nss)
 {
        struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
        struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
@@ -197,9 +198,8 @@ void mt76x02_mac_fill_txwi(struct mt76x02_txwi *txwi, struct sk_buff *skb,
        txwi->flags |= cpu_to_le16(txwi_flags);
        txwi->len_ctl = cpu_to_le16(len);
 }
-EXPORT_SYMBOL_GPL(mt76x02_mac_fill_txwi);
 
-__le16
+static __le16
 mt76x02_mac_tx_rate_val(struct mt76_dev *dev,
                       const struct ieee80211_tx_rate *rate, u8 *nss_val)
 {
@@ -249,7 +249,6 @@ mt76x02_mac_tx_rate_val(struct mt76_dev *dev,
        *nss_val = nss;
        return cpu_to_le16(rateval);
 }
-EXPORT_SYMBOL_GPL(mt76x02_mac_tx_rate_val);
 
 void mt76x02_mac_wcid_set_rate(struct mt76_dev *dev, struct mt76_wcid *wcid,
                              const struct ieee80211_tx_rate *rate)
index ddc8057fbbabdd3ec7b1442076fb0eccd357669b..8788c54c6c3dd2ab1904e3c6a5bb0f4bb56c2b87 100644 (file)
@@ -180,8 +180,6 @@ static inline bool mt76x02_wait_for_mac(struct mt76_dev *dev)
 }
 
 void mt76x02_txq_init(struct mt76_dev *dev, struct ieee80211_txq *txq);
-void mt76x02_mac_fill_txwi(struct mt76x02_txwi *txwi, struct sk_buff *skb,
-                         struct ieee80211_sta *sta, int len, u8 nss);
 enum mt76x02_cipher_type
 mt76x02_mac_get_key_info(struct ieee80211_key_conf *key, u8 *key_data);
 
@@ -193,9 +191,6 @@ void mt76x02_mac_wcid_setup(struct mt76_dev *dev, u8 idx, u8 vif_idx, u8 *mac);
 void mt76x02_mac_wcid_set_drop(struct mt76_dev *dev, u8 idx, bool drop);
 void mt76x02_mac_wcid_set_rate(struct mt76_dev *dev, struct mt76_wcid *wcid,
                              const struct ieee80211_tx_rate *rate);
-__le16
-mt76x02_mac_tx_rate_val(struct mt76_dev *dev,
-                      const struct ieee80211_tx_rate *rate, u8 *nss_val);
 bool mt76x02_mac_load_tx_status(struct mt76_dev *dev,
                               struct mt76x02_tx_status *stat);
 void mt76x02_send_tx_status(struct mt76_dev *dev,
index 39dcfeee39f2cd3f88da41ce8ed26c27a30389cd..e70ba4f977618cf8a8d204189c784619aaf74c37 100644 (file)
@@ -25,5 +25,8 @@ int mt76x02u_mcu_fw_send_data(struct mt76_dev *dev, const void *data,
                              int data_len, u32 max_payload, u32 offset);
 
 int mt76x02u_skb_dma_info(struct sk_buff *skb, int port, u32 flags);
-int mt76x02u_set_txinfo(struct sk_buff *skb, struct mt76_wcid *wcid, u8 ep);
+int mt76x02u_tx_prepare_skb(struct mt76_dev *dev, void *data,
+                           struct sk_buff *skb, struct mt76_queue *q,
+                           struct mt76_wcid *wcid, struct ieee80211_sta *sta,
+                           u32 *tx_info);
 #endif /* __MT76x02_USB_H */
index aecbe0c429ea85595a39f0d5650cfa6f98e2b8e1..dea944b435767f0b1def17432b00b5dad1d1708d 100644 (file)
 
 #include "mt76.h"
 #include "mt76x02_dma.h"
+#include "mt76x02_mac.h"
+#include "mt76x02_util.h"
+
+static int mt76x02u_check_skb_rooms(struct sk_buff *skb)
+{
+       int hdr_len = ieee80211_get_hdrlen_from_skb(skb);
+       u32 need_head;
+
+       need_head = sizeof(struct mt76x02_txwi) + MT_DMA_HDR_LEN;
+       if (hdr_len % 4)
+               need_head += 2;
+       return skb_cow(skb, need_head);
+}
 
 int mt76x02u_skb_dma_info(struct sk_buff *skb, int port, u32 flags)
 {
@@ -50,7 +63,8 @@ int mt76x02u_skb_dma_info(struct sk_buff *skb, int port, u32 flags)
        return 0;
 }
 
-int mt76x02u_set_txinfo(struct sk_buff *skb, struct mt76_wcid *wcid, u8 ep)
+static int
+mt76x02u_set_txinfo(struct sk_buff *skb, struct mt76_wcid *wcid, u8 ep)
 {
        struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
        enum mt76_qsel qsel;
@@ -69,4 +83,24 @@ int mt76x02u_set_txinfo(struct sk_buff *skb, struct mt76_wcid *wcid, u8 ep)
 
        return mt76x02u_skb_dma_info(skb, WLAN_PORT, flags);
 }
-EXPORT_SYMBOL_GPL(mt76x02u_set_txinfo);
+
+int mt76x02u_tx_prepare_skb(struct mt76_dev *dev, void *data,
+                           struct sk_buff *skb, struct mt76_queue *q,
+                           struct mt76_wcid *wcid, struct ieee80211_sta *sta,
+                           u32 *tx_info)
+{
+       struct mt76x02_txwi *txwi;
+       int err, len = skb->len;
+
+       err = mt76x02u_check_skb_rooms(skb);
+       if (err < 0)
+               return -ENOMEM;
+
+       mt76x02_insert_hdr_pad(skb);
+
+       txwi = skb_push(skb, sizeof(struct mt76x02_txwi));
+       mt76x02_mac_write_txwi(dev, txwi, skb, wcid, sta, len);
+
+       return mt76x02u_set_txinfo(skb, wcid, q2ep(q->hw_idx));
+}
+EXPORT_SYMBOL_GPL(mt76x02u_tx_prepare_skb);
index 2b5a3164274eada8418b9c3a303f539008b7097c..560c46e02ec7b72f0e7245fbc5952155ece38391 100644 (file)
@@ -13,6 +13,6 @@ mt76x2e-y := \
 
 mt76x2u-y := \
        usb.o usb_init.o usb_main.o usb_mac.o usb_mcu.o \
-       usb_phy.o usb_core.o
+       usb_phy.o
 
 CFLAGS_pci_trace.o := -I$(src)
index 969e8e15fc5879d7653c8e1aadb5d84744c1b01e..e5d08cc8ca73ba17208ba9a2e0104732613c5673 100644 (file)
@@ -55,10 +55,6 @@ int mt76x2u_mcu_fw_init(struct mt76x2_dev *dev);
 int mt76x2u_alloc_queues(struct mt76x2_dev *dev);
 void mt76x2u_queues_deinit(struct mt76x2_dev *dev);
 void mt76x2u_stop_queues(struct mt76x2_dev *dev);
-int mt76x2u_tx_prepare_skb(struct mt76_dev *mdev, void *data,
-                          struct sk_buff *skb, struct mt76_queue *q,
-                          struct mt76_wcid *wcid, struct ieee80211_sta *sta,
-                          u32 *tx_info);
 int mt76x2u_skb_dma_info(struct sk_buff *skb, enum dma_msg_port port,
                         u32 flags);
 
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2/usb_core.c b/drivers/net/wireless/mediatek/mt76/mt76x2/usb_core.c
deleted file mode 100644 (file)
index a740f05..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (C) 2018 Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include "mt76x2u.h"
-#include "../dma.h"
-#include "../mt76x02_util.h"
-#include "../mt76x02_usb.h"
-
-static int
-mt76x2u_check_skb_rooms(struct sk_buff *skb)
-{
-       int hdr_len = ieee80211_get_hdrlen_from_skb(skb);
-       u32 need_head;
-
-       need_head = sizeof(struct mt76x02_txwi) + MT_DMA_HDR_LEN;
-       if (hdr_len % 4)
-               need_head += 2;
-       return skb_cow(skb, need_head);
-}
-
-int mt76x2u_tx_prepare_skb(struct mt76_dev *mdev, void *data,
-                          struct sk_buff *skb, struct mt76_queue *q,
-                          struct mt76_wcid *wcid, struct ieee80211_sta *sta,
-                          u32 *tx_info)
-{
-       struct mt76x02_txwi *txwi;
-       int err, len = skb->len;
-
-       err = mt76x2u_check_skb_rooms(skb);
-       if (err < 0)
-               return -ENOMEM;
-
-       mt76x02_insert_hdr_pad(skb);
-
-       txwi = skb_push(skb, sizeof(struct mt76x02_txwi));
-       mt76x02_mac_write_txwi(mdev, txwi, skb, wcid, sta, len);
-
-       return mt76x02u_set_txinfo(skb, wcid, q2ep(q->hw_idx));
-}
index a8222447d805d912eda7b0f04bc134a1600c3aeb..3570d0714f4dfdca8cf58217a15cb8dfe4c84294 100644 (file)
@@ -20,6 +20,7 @@
 #include "../mt76x02_util.h"
 #include "../mt76x02_phy.h"
 #include "eeprom.h"
+#include "../mt76x02_usb.h"
 
 static void mt76x2u_init_dma(struct mt76x2_dev *dev)
 {
@@ -137,7 +138,7 @@ static int mt76x2u_init_eeprom(struct mt76x2_dev *dev)
 struct mt76x2_dev *mt76x2u_alloc_device(struct device *pdev)
 {
        static const struct mt76_driver_ops drv_ops = {
-               .tx_prepare_skb = mt76x2u_tx_prepare_skb,
+               .tx_prepare_skb = mt76x02u_tx_prepare_skb,
                .tx_complete_skb = mt76x02_tx_complete_skb,
                .tx_status_data = mt76x02_tx_status_data,
                .rx_skb = mt76x2_queue_rx_skb,