]> git.karo-electronics.de Git - linux-beck.git/commitdiff
rtl8xxxu: Split filling of TX descriptors into separate functions
authorJes Sorensen <Jes.Sorensen@redhat.com>
Fri, 19 Aug 2016 21:46:40 +0000 (17:46 -0400)
committerKalle Valo <kvalo@codeaurora.org>
Sat, 3 Sep 2016 16:57:31 +0000 (19:57 +0300)
Split the filling of TX descriptors into a generic portion used on all
devices, and format specific helper functions provided in the fops
structure.

This also cleaned up some mess, even if non harmful, in the handling
of txdesc40 descriptors, where the code randomly would switch between
the pointer to tx_desc and tx_desc40.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192c.c
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723a.c
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c

index 68d80c437449b02c580fbfa0f8821d82df9c7a73..1f54b8928d3c1f81455a4418818f85ecc1020792 100644 (file)
@@ -1336,6 +1336,10 @@ struct rtl8xxxu_fileops {
                                  u32 ramask, int sgi);
        void (*report_connect) (struct rtl8xxxu_priv *priv,
                                u8 macid, bool connect);
+       void (*fill_txdesc) (struct ieee80211_hdr *hdr,
+                            struct rtl8xxxu_txdesc32 *tx_desc, u32 rate,
+                            u16 rate_flag, bool sgi, bool short_preamble,
+                            bool ampdu_enable);
        int writeN_block_size;
        int rx_agg_buf_size;
        char tx_desc_size;
@@ -1429,6 +1433,14 @@ int rtl8xxxu_parse_rxdesc24(struct rtl8xxxu_priv *priv, struct sk_buff *skb);
 int rtl8xxxu_gen2_channel_to_group(int channel);
 bool rtl8xxxu_gen2_simularity_compare(struct rtl8xxxu_priv *priv,
                                      int result[][8], int c1, int c2);
+void rtl8xxxu_fill_txdesc_v1(struct ieee80211_hdr *hdr,
+                            struct rtl8xxxu_txdesc32 *tx_desc, u32 rate,
+                            u16 rate_flag, bool sgi, bool short_preamble,
+                            bool ampdu_enable);
+void rtl8xxxu_fill_txdesc_v2(struct ieee80211_hdr *hdr,
+                            struct rtl8xxxu_txdesc32 *tx_desc32, u32 rate,
+                            u16 rate_flag, bool sgi, bool short_preamble,
+                            bool ampdu_enable);
 
 extern struct rtl8xxxu_fileops rtl8192cu_fops;
 extern struct rtl8xxxu_fileops rtl8192eu_fops;
index cd13c2538f0d434a0e5403373fea84fa26efd989..f9e2050812ab356babc702cd3dac151b395cc889 100644 (file)
@@ -567,6 +567,7 @@ struct rtl8xxxu_fileops rtl8192cu_fops = {
        .set_tx_power = rtl8xxxu_gen1_set_tx_power,
        .update_rate_mask = rtl8xxxu_update_rate_mask,
        .report_connect = rtl8xxxu_gen1_report_connect,
+       .fill_txdesc = rtl8xxxu_fill_txdesc_v1,
        .writeN_block_size = 128,
        .rx_agg_buf_size = 16000,
        .tx_desc_size = sizeof(struct rtl8xxxu_txdesc32),
index 99011999829a17f6cda5bcdcdfaabc43e4987227..841522ee6379914c76c894854b68915c5ebc710e 100644 (file)
@@ -1501,6 +1501,7 @@ struct rtl8xxxu_fileops rtl8192eu_fops = {
        .set_tx_power = rtl8192e_set_tx_power,
        .update_rate_mask = rtl8xxxu_gen2_update_rate_mask,
        .report_connect = rtl8xxxu_gen2_report_connect,
+       .fill_txdesc = rtl8xxxu_fill_txdesc_v2,
        .writeN_block_size = 128,
        .tx_desc_size = sizeof(struct rtl8xxxu_txdesc40),
        .rx_desc_size = sizeof(struct rtl8xxxu_rxdesc24),
index d6f496899be0a736b9ad44152bea82046cfca8ee..aef373028155fb8061d8fdd6eb7fd32ccb46b59b 100644 (file)
@@ -384,6 +384,7 @@ struct rtl8xxxu_fileops rtl8723au_fops = {
        .set_tx_power = rtl8xxxu_gen1_set_tx_power,
        .update_rate_mask = rtl8xxxu_update_rate_mask,
        .report_connect = rtl8xxxu_gen1_report_connect,
+       .fill_txdesc = rtl8xxxu_fill_txdesc_v1,
        .writeN_block_size = 1024,
        .rx_agg_buf_size = 16000,
        .tx_desc_size = sizeof(struct rtl8xxxu_txdesc32),
index dd2c0f0ec0aabb4808849d86f820fb187ab6ec1a..6c086b5657e94845b4362860620185828d7c3e2c 100644 (file)
@@ -1662,6 +1662,7 @@ struct rtl8xxxu_fileops rtl8723bu_fops = {
        .set_tx_power = rtl8723b_set_tx_power,
        .update_rate_mask = rtl8xxxu_gen2_update_rate_mask,
        .report_connect = rtl8xxxu_gen2_report_connect,
+       .fill_txdesc = rtl8xxxu_fill_txdesc_v2,
        .writeN_block_size = 1024,
        .tx_desc_size = sizeof(struct rtl8xxxu_txdesc40),
        .rx_desc_size = sizeof(struct rtl8xxxu_rxdesc24),
index cfb2dfd54277bca1949a49f0032b71a69c74f4a0..e02fab09949674f9bcb18a0f542527bc4ddd6bb6 100644 (file)
@@ -4750,6 +4750,113 @@ static void rtl8xxxu_dump_action(struct device *dev,
        }
 }
 
+/*
+ * Fill in v1 (gen1) specific TX descriptor bits.
+ * This format is used on 8188cu/8192cu/8723au
+ */
+void
+rtl8xxxu_fill_txdesc_v1(struct ieee80211_hdr *hdr,
+                       struct rtl8xxxu_txdesc32 *tx_desc, u32 rate,
+                       u16 rate_flag, bool sgi, bool short_preamble,
+                       bool ampdu_enable)
+{
+       u16 seq_number;
+
+       seq_number = IEEE80211_SEQ_TO_SN(le16_to_cpu(hdr->seq_ctrl));
+
+       tx_desc->txdw5 = cpu_to_le32(rate);
+
+       if (ieee80211_is_data(hdr->frame_control))
+               tx_desc->txdw5 |= cpu_to_le32(0x0001ff00);
+
+       tx_desc->txdw3 = cpu_to_le32((u32)seq_number << TXDESC32_SEQ_SHIFT);
+
+       if (ampdu_enable)
+               tx_desc->txdw1 |= cpu_to_le32(TXDESC32_AGG_ENABLE);
+       else
+               tx_desc->txdw1 |= cpu_to_le32(TXDESC32_AGG_BREAK);
+
+       if (ieee80211_is_mgmt(hdr->frame_control)) {
+               tx_desc->txdw5 = cpu_to_le32(rate);
+               tx_desc->txdw4 |= cpu_to_le32(TXDESC32_USE_DRIVER_RATE);
+               tx_desc->txdw5 |= cpu_to_le32(6 << TXDESC32_RETRY_LIMIT_SHIFT);
+               tx_desc->txdw5 |= cpu_to_le32(TXDESC32_RETRY_LIMIT_ENABLE);
+       }
+
+       if (ieee80211_is_data_qos(hdr->frame_control))
+               tx_desc->txdw4 |= cpu_to_le32(TXDESC32_QOS);
+
+       if (short_preamble)
+               tx_desc->txdw4 |= cpu_to_le32(TXDESC32_SHORT_PREAMBLE);
+
+       if (sgi)
+               tx_desc->txdw5 |= cpu_to_le32(TXDESC32_SHORT_GI);
+
+       if (rate_flag & IEEE80211_TX_RC_USE_RTS_CTS) {
+               /*
+                * Use RTS rate 24M - does the mac80211 tell
+                * us which to use?
+                */
+               tx_desc->txdw4 |= cpu_to_le32(DESC_RATE_24M <<
+                                             TXDESC32_RTS_RATE_SHIFT);
+               tx_desc->txdw4 |= cpu_to_le32(TXDESC32_RTS_CTS_ENABLE);
+               tx_desc->txdw4 |= cpu_to_le32(TXDESC32_HW_RTS_ENABLE);
+       }
+}
+
+/*
+ * Fill in v2 (gen2) specific TX descriptor bits.
+ * This format is used on 8192eu/8723bu
+ */
+void
+rtl8xxxu_fill_txdesc_v2(struct ieee80211_hdr *hdr,
+                       struct rtl8xxxu_txdesc32 *tx_desc32, u32 rate,
+                       u16 rate_flag, bool sgi, bool short_preamble,
+                       bool ampdu_enable)
+{
+       struct rtl8xxxu_txdesc40 *tx_desc40;
+       u16 seq_number;
+
+       tx_desc40 = (struct rtl8xxxu_txdesc40 *)tx_desc32;
+
+       seq_number = IEEE80211_SEQ_TO_SN(le16_to_cpu(hdr->seq_ctrl));
+
+       tx_desc40->txdw4 = cpu_to_le32(rate);
+       if (ieee80211_is_data(hdr->frame_control)) {
+               tx_desc40->txdw4 |= cpu_to_le32(0x1f <<
+                                               TXDESC40_DATA_RATE_FB_SHIFT);
+       }
+
+       tx_desc40->txdw9 = cpu_to_le32((u32)seq_number << TXDESC40_SEQ_SHIFT);
+
+       if (ampdu_enable)
+               tx_desc40->txdw2 |= cpu_to_le32(TXDESC40_AGG_ENABLE);
+       else
+               tx_desc40->txdw2 |= cpu_to_le32(TXDESC40_AGG_BREAK);
+
+       if (ieee80211_is_mgmt(hdr->frame_control)) {
+               tx_desc40->txdw4 = cpu_to_le32(rate);
+               tx_desc40->txdw3 |= cpu_to_le32(TXDESC40_USE_DRIVER_RATE);
+               tx_desc40->txdw4 |=
+                       cpu_to_le32(6 << TXDESC40_RETRY_LIMIT_SHIFT);
+               tx_desc40->txdw4 |= cpu_to_le32(TXDESC40_RETRY_LIMIT_ENABLE);
+       }
+
+       if (short_preamble)
+               tx_desc40->txdw5 |= cpu_to_le32(TXDESC40_SHORT_PREAMBLE);
+
+       if (rate_flag & IEEE80211_TX_RC_USE_RTS_CTS) {
+               /*
+                * Use RTS rate 24M - does the mac80211 tell
+                * us which to use?
+                */
+               tx_desc40->txdw4 |= cpu_to_le32(DESC_RATE_24M <<
+                                               TXDESC40_RTS_RATE_SHIFT);
+               tx_desc40->txdw3 |= cpu_to_le32(TXDESC40_RTS_CTS_ENABLE);
+               tx_desc40->txdw3 |= cpu_to_le32(TXDESC40_HW_RTS_ENABLE);
+       }
+}
+
 static void rtl8xxxu_tx(struct ieee80211_hw *hw,
                        struct ieee80211_tx_control *control,
                        struct sk_buff *skb)
@@ -4759,7 +4866,6 @@ static void rtl8xxxu_tx(struct ieee80211_hw *hw,
        struct ieee80211_rate *tx_rate = ieee80211_get_tx_rate(hw, tx_info);
        struct rtl8xxxu_priv *priv = hw->priv;
        struct rtl8xxxu_txdesc32 *tx_desc;
-       struct rtl8xxxu_txdesc40 *tx_desc40;
        struct rtl8xxxu_tx_urb *tx_urb;
        struct ieee80211_sta *sta = NULL;
        struct ieee80211_vif *vif = tx_info->control.vif;
@@ -4865,95 +4971,9 @@ static void rtl8xxxu_tx(struct ieee80211_hw *hw,
                short_preamble = true;
 
        seq_number = IEEE80211_SEQ_TO_SN(le16_to_cpu(hdr->seq_ctrl));
-       if (!usedesc40) {
-               tx_desc->txdw5 = cpu_to_le32(rate);
-
-               if (ieee80211_is_data(hdr->frame_control))
-                       tx_desc->txdw5 |= cpu_to_le32(0x0001ff00);
-
-               tx_desc->txdw3 =
-                       cpu_to_le32((u32)seq_number << TXDESC32_SEQ_SHIFT);
-
-               if (ampdu_enable)
-                       tx_desc->txdw1 |= cpu_to_le32(TXDESC32_AGG_ENABLE);
-               else
-                       tx_desc->txdw1 |= cpu_to_le32(TXDESC32_AGG_BREAK);
-
-               if (ieee80211_is_mgmt(hdr->frame_control)) {
-                       tx_desc->txdw5 = cpu_to_le32(rate);
-                       tx_desc->txdw4 |=
-                               cpu_to_le32(TXDESC32_USE_DRIVER_RATE);
-                       tx_desc->txdw5 |=
-                               cpu_to_le32(6 << TXDESC32_RETRY_LIMIT_SHIFT);
-                       tx_desc->txdw5 |=
-                               cpu_to_le32(TXDESC32_RETRY_LIMIT_ENABLE);
-               }
-
-               if (ieee80211_is_data_qos(hdr->frame_control))
-                       tx_desc->txdw4 |= cpu_to_le32(TXDESC32_QOS);
 
-               if (short_preamble)
-                       tx_desc->txdw4 |= cpu_to_le32(TXDESC32_SHORT_PREAMBLE);
-
-               if (sgi)
-                       tx_desc->txdw5 |= cpu_to_le32(TXDESC32_SHORT_GI);
-
-               if (rate_flag & IEEE80211_TX_RC_USE_RTS_CTS) {
-                       /*
-                        * Use RTS rate 24M - does the mac80211 tell
-                        * us which to use?
-                        */
-                       tx_desc->txdw4 |=
-                               cpu_to_le32(DESC_RATE_24M <<
-                                           TXDESC32_RTS_RATE_SHIFT);
-                       tx_desc->txdw4 |=
-                               cpu_to_le32(TXDESC32_RTS_CTS_ENABLE);
-                       tx_desc->txdw4 |= cpu_to_le32(TXDESC32_HW_RTS_ENABLE);
-               }
-       } else {
-               tx_desc40 = (struct rtl8xxxu_txdesc40 *)tx_desc;
-
-               tx_desc40->txdw4 = cpu_to_le32(rate);
-               if (ieee80211_is_data(hdr->frame_control)) {
-                       tx_desc->txdw4 |=
-                               cpu_to_le32(0x1f <<
-                                           TXDESC40_DATA_RATE_FB_SHIFT);
-               }
-
-               tx_desc40->txdw9 =
-                       cpu_to_le32((u32)seq_number << TXDESC40_SEQ_SHIFT);
-
-               if (ampdu_enable)
-                       tx_desc40->txdw2 |= cpu_to_le32(TXDESC40_AGG_ENABLE);
-               else
-                       tx_desc40->txdw2 |= cpu_to_le32(TXDESC40_AGG_BREAK);
-
-               if (ieee80211_is_mgmt(hdr->frame_control)) {
-                       tx_desc40->txdw4 = cpu_to_le32(rate);
-                       tx_desc40->txdw3 |=
-                               cpu_to_le32(TXDESC40_USE_DRIVER_RATE);
-                       tx_desc40->txdw4 |=
-                               cpu_to_le32(6 << TXDESC40_RETRY_LIMIT_SHIFT);
-                       tx_desc40->txdw4 |=
-                               cpu_to_le32(TXDESC40_RETRY_LIMIT_ENABLE);
-               }
-
-               if (short_preamble)
-                       tx_desc40->txdw5 |=
-                               cpu_to_le32(TXDESC40_SHORT_PREAMBLE);
-
-               if (rate_flag & IEEE80211_TX_RC_USE_RTS_CTS) {
-                       /*
-                        * Use RTS rate 24M - does the mac80211 tell
-                        * us which to use?
-                        */
-                       tx_desc->txdw4 |=
-                               cpu_to_le32(DESC_RATE_24M <<
-                                           TXDESC40_RTS_RATE_SHIFT);
-                       tx_desc->txdw3 |= cpu_to_le32(TXDESC40_RTS_CTS_ENABLE);
-                       tx_desc->txdw3 |= cpu_to_le32(TXDESC40_HW_RTS_ENABLE);
-               }
-       }
+       priv->fops->fill_txdesc(hdr, tx_desc, rate, rate_flag,
+                               sgi, short_preamble, ampdu_enable);
 
        rtl8xxxu_calc_tx_desc_csum(tx_desc);