1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright(c) 2009-2012 Realtek Corporation.*/
15 #include "../rtl8192c/fw_common.h"
17 static int configvertoutep(struct ieee80211_hw *hw)
22 struct rtl_priv *rtlpriv = rtl_priv(hw);
23 struct rtl_usb_priv *usb_priv = rtl_usbpriv(hw);
24 struct rtl_usb *rtlusb = rtl_usbdev(usb_priv);
26 rtlusb->out_queue_sel = 0;
27 ep_cfg = rtl_read_byte(rtlpriv, REG_TEST_SIE_OPTIONAL);
28 ep_cfg = (ep_cfg & USB_TEST_EP_MASK) >> USB_TEST_EP_SHIFT;
30 case 0: /* 2 bulk OUT, 1 bulk IN */
32 rtlusb->out_queue_sel = TX_SELE_HQ | TX_SELE_LQ;
35 case 1: /* 1 bulk IN/OUT => map all endpoint to Low queue */
36 case 2: /* 1 bulk IN, 1 bulk OUT => map all endpoint to High queue */
37 txqsele = rtl_read_byte(rtlpriv, REG_TEST_USB_TXQS);
38 if (txqsele & 0x0F) /* /map all endpoint to High queue */
39 rtlusb->out_queue_sel = TX_SELE_HQ;
40 else if (txqsele&0xF0) /* map all endpoint to Low queue */
41 rtlusb->out_queue_sel = TX_SELE_LQ;
47 return (rtlusb->out_ep_nums == ep_nums) ? 0 : -EINVAL;
50 static int configvernoutep(struct ieee80211_hw *hw)
55 struct rtl_priv *rtlpriv = rtl_priv(hw);
56 struct rtl_usb_priv *usb_priv = rtl_usbpriv(hw);
57 struct rtl_usb *rtlusb = rtl_usbdev(usb_priv);
59 rtlusb->out_queue_sel = 0;
60 /* Normal and High queue */
61 ep_cfg = rtl_read_byte(rtlpriv, (REG_NORMAL_SIE_EP + 1));
62 if (ep_cfg & USB_NORMAL_SIE_EP_MASK) {
63 rtlusb->out_queue_sel |= TX_SELE_HQ;
66 if ((ep_cfg >> USB_NORMAL_SIE_EP_SHIFT) & USB_NORMAL_SIE_EP_MASK) {
67 rtlusb->out_queue_sel |= TX_SELE_NQ;
71 ep_cfg = rtl_read_byte(rtlpriv, (REG_NORMAL_SIE_EP + 2));
72 if (ep_cfg & USB_NORMAL_SIE_EP_MASK) {
73 rtlusb->out_queue_sel |= TX_SELE_LQ;
76 return (rtlusb->out_ep_nums == ep_nums) ? 0 : -EINVAL;
79 static void twooutepmapping(struct ieee80211_hw *hw, bool is_chip8,
80 bool bwificfg, struct rtl_ep_map *ep_map)
82 struct rtl_priv *rtlpriv = rtl_priv(hw);
84 if (bwificfg) { /* for WMM */
85 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
86 "USB Chip-B & WMM Setting.....\n");
87 ep_map->ep_mapping[RTL_TXQ_BE] = 2;
88 ep_map->ep_mapping[RTL_TXQ_BK] = 3;
89 ep_map->ep_mapping[RTL_TXQ_VI] = 3;
90 ep_map->ep_mapping[RTL_TXQ_VO] = 2;
91 ep_map->ep_mapping[RTL_TXQ_MGT] = 2;
92 ep_map->ep_mapping[RTL_TXQ_BCN] = 2;
93 ep_map->ep_mapping[RTL_TXQ_HI] = 2;
94 } else { /* typical setting */
95 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
96 "USB typical Setting.....\n");
97 ep_map->ep_mapping[RTL_TXQ_BE] = 3;
98 ep_map->ep_mapping[RTL_TXQ_BK] = 3;
99 ep_map->ep_mapping[RTL_TXQ_VI] = 2;
100 ep_map->ep_mapping[RTL_TXQ_VO] = 2;
101 ep_map->ep_mapping[RTL_TXQ_MGT] = 2;
102 ep_map->ep_mapping[RTL_TXQ_BCN] = 2;
103 ep_map->ep_mapping[RTL_TXQ_HI] = 2;
107 static void threeoutepmapping(struct ieee80211_hw *hw, bool bwificfg,
108 struct rtl_ep_map *ep_map)
110 struct rtl_priv *rtlpriv = rtl_priv(hw);
112 if (bwificfg) { /* for WMM */
113 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
114 "USB 3EP Setting for WMM.....\n");
115 ep_map->ep_mapping[RTL_TXQ_BE] = 5;
116 ep_map->ep_mapping[RTL_TXQ_BK] = 3;
117 ep_map->ep_mapping[RTL_TXQ_VI] = 3;
118 ep_map->ep_mapping[RTL_TXQ_VO] = 2;
119 ep_map->ep_mapping[RTL_TXQ_MGT] = 2;
120 ep_map->ep_mapping[RTL_TXQ_BCN] = 2;
121 ep_map->ep_mapping[RTL_TXQ_HI] = 2;
122 } else { /* typical setting */
123 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
124 "USB 3EP Setting for typical.....\n");
125 ep_map->ep_mapping[RTL_TXQ_BE] = 5;
126 ep_map->ep_mapping[RTL_TXQ_BK] = 5;
127 ep_map->ep_mapping[RTL_TXQ_VI] = 3;
128 ep_map->ep_mapping[RTL_TXQ_VO] = 2;
129 ep_map->ep_mapping[RTL_TXQ_MGT] = 2;
130 ep_map->ep_mapping[RTL_TXQ_BCN] = 2;
131 ep_map->ep_mapping[RTL_TXQ_HI] = 2;
135 static void oneoutepmapping(struct ieee80211_hw *hw, struct rtl_ep_map *ep_map)
137 ep_map->ep_mapping[RTL_TXQ_BE] = 2;
138 ep_map->ep_mapping[RTL_TXQ_BK] = 2;
139 ep_map->ep_mapping[RTL_TXQ_VI] = 2;
140 ep_map->ep_mapping[RTL_TXQ_VO] = 2;
141 ep_map->ep_mapping[RTL_TXQ_MGT] = 2;
142 ep_map->ep_mapping[RTL_TXQ_BCN] = 2;
143 ep_map->ep_mapping[RTL_TXQ_HI] = 2;
146 static int _out_ep_mapping(struct ieee80211_hw *hw)
149 bool ischipn, bwificfg = false;
150 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
151 struct rtl_usb_priv *usb_priv = rtl_usbpriv(hw);
152 struct rtl_usb *rtlusb = rtl_usbdev(usb_priv);
153 struct rtl_ep_map *ep_map = &(rtlusb->ep_map);
155 ischipn = IS_NORMAL_CHIP(rtlhal->version);
156 switch (rtlusb->out_ep_nums) {
158 twooutepmapping(hw, ischipn, bwificfg, ep_map);
161 /* Test chip doesn't support three out EPs. */
166 threeoutepmapping(hw, ischipn, ep_map);
169 oneoutepmapping(hw, ep_map);
180 /* endpoint mapping */
181 int rtl8192cu_endpoint_mapping(struct ieee80211_hw *hw)
183 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
186 if (likely(IS_NORMAL_CHIP(rtlhal->version)))
187 error = configvernoutep(hw);
189 error = configvertoutep(hw);
192 error = _out_ep_mapping(hw);
199 u16 rtl8192cu_mq_to_hwq(__le16 fc, u16 mac80211_queue_index)
203 if (unlikely(ieee80211_is_beacon(fc))) {
204 hw_queue_index = RTL_TXQ_BCN;
207 if (ieee80211_is_mgmt(fc)) {
208 hw_queue_index = RTL_TXQ_MGT;
211 switch (mac80211_queue_index) {
213 hw_queue_index = RTL_TXQ_VO;
216 hw_queue_index = RTL_TXQ_VI;
219 hw_queue_index = RTL_TXQ_BE;
222 hw_queue_index = RTL_TXQ_BK;
225 hw_queue_index = RTL_TXQ_BE;
226 WARN_ONCE(true, "rtl8192cu: QSLT_BE queue, skb_queue:%d\n",
227 mac80211_queue_index);
231 return hw_queue_index;
234 static enum rtl_desc_qsel _rtl8192cu_mq_to_descq(struct ieee80211_hw *hw,
235 __le16 fc, u16 mac80211_queue_index)
237 enum rtl_desc_qsel qsel;
238 struct rtl_priv *rtlpriv = rtl_priv(hw);
240 if (unlikely(ieee80211_is_beacon(fc))) {
244 if (ieee80211_is_mgmt(fc)) {
248 switch (mac80211_queue_index) {
251 RT_TRACE(rtlpriv, COMP_USB, DBG_DMESG,
252 "VO queue, set qsel = 0x%x\n", QSLT_VO);
256 RT_TRACE(rtlpriv, COMP_USB, DBG_DMESG,
257 "VI queue, set qsel = 0x%x\n", QSLT_VI);
261 RT_TRACE(rtlpriv, COMP_USB, DBG_DMESG,
262 "BK queue, set qsel = 0x%x\n", QSLT_BK);
267 RT_TRACE(rtlpriv, COMP_USB, DBG_DMESG,
268 "BE queue, set qsel = 0x%x\n", QSLT_BE);
275 /* =============================================================== */
277 /*----------------------------------------------------------------------
281 *---------------------------------------------------------------------- */
282 bool rtl92cu_rx_query_desc(struct ieee80211_hw *hw,
283 struct rtl_stats *stats,
284 struct ieee80211_rx_status *rx_status,
285 u8 *pdesc, struct sk_buff *skb)
287 struct rx_fwinfo_92c *p_drvinfo;
288 struct rx_desc_92c *p_desc = (struct rx_desc_92c *)pdesc;
289 u32 phystatus = GET_RX_DESC_PHY_STATUS(pdesc);
291 stats->length = (u16) GET_RX_DESC_PKT_LEN(pdesc);
292 stats->rx_drvinfo_size = (u8)GET_RX_DESC_DRVINFO_SIZE(pdesc) *
293 RX_DRV_INFO_SIZE_UNIT;
294 stats->rx_bufshift = (u8) (GET_RX_DESC_SHIFT(pdesc) & 0x03);
295 stats->icv = (u16) GET_RX_DESC_ICV(pdesc);
296 stats->crc = (u16) GET_RX_DESC_CRC32(pdesc);
297 stats->hwerror = (stats->crc | stats->icv);
298 stats->decrypted = !GET_RX_DESC_SWDEC(pdesc);
299 stats->rate = (u8) GET_RX_DESC_RX_MCS(pdesc);
300 stats->shortpreamble = (u16) GET_RX_DESC_SPLCP(pdesc);
301 stats->isampdu = (bool) (GET_RX_DESC_PAGGR(pdesc) == 1);
302 stats->isfirst_ampdu = (bool)((GET_RX_DESC_PAGGR(pdesc) == 1)
303 && (GET_RX_DESC_FAGGR(pdesc) == 1));
304 stats->timestamp_low = GET_RX_DESC_TSFL(pdesc);
305 stats->rx_is40mhzpacket = (bool)GET_RX_DESC_BW(pdesc);
306 stats->is_ht = (bool)GET_RX_DESC_RX_HT(pdesc);
307 rx_status->freq = hw->conf.chandef.chan->center_freq;
308 rx_status->band = hw->conf.chandef.chan->band;
309 if (GET_RX_DESC_CRC32(pdesc))
310 rx_status->flag |= RX_FLAG_FAILED_FCS_CRC;
311 if (!GET_RX_DESC_SWDEC(pdesc))
312 rx_status->flag |= RX_FLAG_DECRYPTED;
313 if (GET_RX_DESC_BW(pdesc))
314 rx_status->bw = RATE_INFO_BW_40;
315 if (GET_RX_DESC_RX_HT(pdesc))
316 rx_status->encoding = RX_ENC_HT;
317 rx_status->flag |= RX_FLAG_MACTIME_START;
318 if (stats->decrypted)
319 rx_status->flag |= RX_FLAG_DECRYPTED;
320 rx_status->rate_idx = rtlwifi_rate_mapping(hw, stats->is_ht,
322 rx_status->mactime = GET_RX_DESC_TSFL(pdesc);
324 p_drvinfo = (struct rx_fwinfo_92c *)(skb->data +
326 rtl92c_translate_rx_signal_stuff(hw, skb, stats, p_desc,
329 /*rx_status->qual = stats->signal; */
330 rx_status->signal = stats->recvsignalpower + 10;
334 #define RTL_RX_DRV_INFO_UNIT 8
336 static void _rtl_rx_process(struct ieee80211_hw *hw, struct sk_buff *skb)
338 struct ieee80211_rx_status *rx_status =
339 (struct ieee80211_rx_status *)IEEE80211_SKB_RXCB(skb);
340 u32 skb_len, pkt_len, drvinfo_len;
341 struct rtl_priv *rtlpriv = rtl_priv(hw);
343 struct rtl_stats stats = {
347 struct rx_fwinfo_92c *p_drvinfo;
350 struct ieee80211_hdr *hdr;
352 memset(rx_status, 0, sizeof(*rx_status));
355 drvinfo_len = (GET_RX_DESC_DRVINFO_SIZE(rxdesc) * RTL_RX_DRV_INFO_UNIT);
356 pkt_len = GET_RX_DESC_PKT_LEN(rxdesc);
357 /* TODO: Error recovery. drop this skb or something. */
358 WARN_ON(skb_len < (pkt_len + RTL_RX_DESC_SIZE + drvinfo_len));
359 stats.length = (u16) GET_RX_DESC_PKT_LEN(rxdesc);
360 stats.rx_drvinfo_size = (u8)GET_RX_DESC_DRVINFO_SIZE(rxdesc) *
361 RX_DRV_INFO_SIZE_UNIT;
362 stats.rx_bufshift = (u8) (GET_RX_DESC_SHIFT(rxdesc) & 0x03);
363 stats.icv = (u16) GET_RX_DESC_ICV(rxdesc);
364 stats.crc = (u16) GET_RX_DESC_CRC32(rxdesc);
365 stats.hwerror = (stats.crc | stats.icv);
366 stats.decrypted = !GET_RX_DESC_SWDEC(rxdesc);
367 stats.rate = (u8) GET_RX_DESC_RX_MCS(rxdesc);
368 stats.shortpreamble = (u16) GET_RX_DESC_SPLCP(rxdesc);
369 stats.isampdu = (bool) ((GET_RX_DESC_PAGGR(rxdesc) == 1)
370 && (GET_RX_DESC_FAGGR(rxdesc) == 1));
371 stats.timestamp_low = GET_RX_DESC_TSFL(rxdesc);
372 stats.rx_is40mhzpacket = (bool)GET_RX_DESC_BW(rxdesc);
373 stats.is_ht = (bool)GET_RX_DESC_RX_HT(rxdesc);
374 /* TODO: is center_freq changed when doing scan? */
375 /* TODO: Shall we add protection or just skip those two step? */
376 rx_status->freq = hw->conf.chandef.chan->center_freq;
377 rx_status->band = hw->conf.chandef.chan->band;
378 if (GET_RX_DESC_CRC32(rxdesc))
379 rx_status->flag |= RX_FLAG_FAILED_FCS_CRC;
380 if (!GET_RX_DESC_SWDEC(rxdesc))
381 rx_status->flag |= RX_FLAG_DECRYPTED;
382 if (GET_RX_DESC_BW(rxdesc))
383 rx_status->bw = RATE_INFO_BW_40;
384 if (GET_RX_DESC_RX_HT(rxdesc))
385 rx_status->encoding = RX_ENC_HT;
387 rx_status->rate_idx = rtlwifi_rate_mapping(hw, stats.is_ht,
389 /* There is a phy status after this rx descriptor. */
390 if (GET_RX_DESC_PHY_STATUS(rxdesc)) {
391 p_drvinfo = (struct rx_fwinfo_92c *)(rxdesc + RTL_RX_DESC_SIZE);
392 rtl92c_translate_rx_signal_stuff(hw, skb, &stats,
393 (struct rx_desc_92c *)rxdesc, p_drvinfo);
395 skb_pull(skb, (drvinfo_len + RTL_RX_DESC_SIZE));
396 hdr = (struct ieee80211_hdr *)(skb->data);
397 fc = hdr->frame_control;
398 bv = ieee80211_is_probe_resp(fc);
400 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
401 "Got probe response frame\n");
402 if (ieee80211_is_beacon(fc))
403 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, "Got beacon frame\n");
404 if (ieee80211_is_data(fc))
405 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, "Got data frame\n");
406 RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
407 "Fram: fc = 0x%X addr1 = 0x%02X:0x%02X:0x%02X:0x%02X:0x%02X:0x%02X\n",
409 (u32)hdr->addr1[0], (u32)hdr->addr1[1],
410 (u32)hdr->addr1[2], (u32)hdr->addr1[3],
411 (u32)hdr->addr1[4], (u32)hdr->addr1[5]);
412 ieee80211_rx(hw, skb);
415 void rtl8192cu_rx_hdl(struct ieee80211_hw *hw, struct sk_buff * skb)
417 _rtl_rx_process(hw, skb);
420 /*----------------------------------------------------------------------
424 *---------------------------------------------------------------------- */
425 void rtl8192c_tx_cleanup(struct ieee80211_hw *hw, struct sk_buff *skb)
429 int rtl8192c_tx_post_hdl(struct ieee80211_hw *hw, struct urb *urb,
435 struct sk_buff *rtl8192c_tx_aggregate_hdl(struct ieee80211_hw *hw,
436 struct sk_buff_head *list)
438 return skb_dequeue(list);
441 /*======================================== trx ===============================*/
443 static void _rtl_fill_usb_tx_desc(u8 *txdesc)
445 SET_TX_DESC_OWN(txdesc, 1);
446 SET_TX_DESC_LAST_SEG(txdesc, 1);
447 SET_TX_DESC_FIRST_SEG(txdesc, 1);
451 * For HW recovery information
453 static void _rtl_tx_desc_checksum(u8 *txdesc)
455 __le16 *ptr = (__le16 *)txdesc;
460 SET_TX_DESC_TX_DESC_CHECKSUM(txdesc, 0);
461 for (index = 0; index < 16; index++)
462 checksum = checksum ^ le16_to_cpu(*(ptr + index));
463 SET_TX_DESC_TX_DESC_CHECKSUM(txdesc, checksum);
466 void rtl92cu_tx_fill_desc(struct ieee80211_hw *hw,
467 struct ieee80211_hdr *hdr, u8 *pdesc_tx,
468 u8 *pbd_desc_tx, struct ieee80211_tx_info *info,
469 struct ieee80211_sta *sta,
472 struct rtl_tcb_desc *tcb_desc)
474 struct rtl_priv *rtlpriv = rtl_priv(hw);
475 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
476 struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
477 bool defaultadapter = true;
478 u8 *qc = ieee80211_get_qos_ctl(hdr);
479 u8 tid = qc[0] & IEEE80211_QOS_CTL_TID_MASK;
481 __le16 fc = hdr->frame_control;
482 u8 rate_flag = info->control.rates[0].flags;
483 u16 pktlen = skb->len;
484 enum rtl_desc_qsel fw_qsel = _rtl8192cu_mq_to_descq(hw, fc,
485 skb_get_queue_mapping(skb));
488 seq_number = (le16_to_cpu(hdr->seq_ctrl) & IEEE80211_SCTL_SEQ) >> 4;
489 rtl_get_tcb_desc(hw, info, sta, skb, tcb_desc);
490 txdesc = skb_push(skb, RTL_TX_HEADER_SIZE);
491 memset(txdesc, 0, RTL_TX_HEADER_SIZE);
492 SET_TX_DESC_PKT_SIZE(txdesc, pktlen);
493 SET_TX_DESC_LINIP(txdesc, 0);
494 SET_TX_DESC_PKT_OFFSET(txdesc, RTL_DUMMY_OFFSET);
495 SET_TX_DESC_OFFSET(txdesc, RTL_TX_HEADER_SIZE);
496 SET_TX_DESC_TX_RATE(txdesc, tcb_desc->hw_rate);
497 if (tcb_desc->use_shortgi || tcb_desc->use_shortpreamble)
498 SET_TX_DESC_DATA_SHORTGI(txdesc, 1);
499 if (mac->tids[tid].agg.agg_state == RTL_AGG_ON &&
500 info->flags & IEEE80211_TX_CTL_AMPDU) {
501 SET_TX_DESC_AGG_ENABLE(txdesc, 1);
502 SET_TX_DESC_MAX_AGG_NUM(txdesc, 0x14);
504 SET_TX_DESC_AGG_BREAK(txdesc, 1);
506 SET_TX_DESC_SEQ(txdesc, seq_number);
507 SET_TX_DESC_RTS_ENABLE(txdesc, ((tcb_desc->rts_enable &&
508 !tcb_desc->cts_enable) ? 1 : 0));
509 SET_TX_DESC_HW_RTS_ENABLE(txdesc, ((tcb_desc->rts_enable ||
510 tcb_desc->cts_enable) ? 1 : 0));
511 SET_TX_DESC_CTS2SELF(txdesc, ((tcb_desc->cts_enable) ? 1 : 0));
512 SET_TX_DESC_RTS_STBC(txdesc, ((tcb_desc->rts_stbc) ? 1 : 0));
513 SET_TX_DESC_RTS_RATE(txdesc, tcb_desc->rts_rate);
514 SET_TX_DESC_RTS_BW(txdesc, 0);
515 SET_TX_DESC_RTS_SC(txdesc, tcb_desc->rts_sc);
516 SET_TX_DESC_RTS_SHORT(txdesc,
517 ((tcb_desc->rts_rate <= DESC_RATE54M) ?
518 (tcb_desc->rts_use_shortpreamble ? 1 : 0)
519 : (tcb_desc->rts_use_shortgi ? 1 : 0)));
521 if (rate_flag & IEEE80211_TX_RC_DUP_DATA) {
522 SET_TX_DESC_DATA_BW(txdesc, 1);
523 SET_TX_DESC_DATA_SC(txdesc, 3);
524 } else if(rate_flag & IEEE80211_TX_RC_40_MHZ_WIDTH){
525 SET_TX_DESC_DATA_BW(txdesc, 1);
526 SET_TX_DESC_DATA_SC(txdesc, mac->cur_40_prime_sc);
528 SET_TX_DESC_DATA_BW(txdesc, 0);
529 SET_TX_DESC_DATA_SC(txdesc, 0);
532 SET_TX_DESC_DATA_BW(txdesc, 0);
533 SET_TX_DESC_DATA_SC(txdesc, 0);
536 sta = ieee80211_find_sta(mac->vif, mac->bssid);
538 u8 ampdu_density = sta->ht_cap.ampdu_density;
540 SET_TX_DESC_AMPDU_DENSITY(txdesc, ampdu_density);
543 if (info->control.hw_key) {
544 struct ieee80211_key_conf *keyconf = info->control.hw_key;
546 switch (keyconf->cipher) {
547 case WLAN_CIPHER_SUITE_WEP40:
548 case WLAN_CIPHER_SUITE_WEP104:
549 case WLAN_CIPHER_SUITE_TKIP:
550 SET_TX_DESC_SEC_TYPE(txdesc, 0x1);
552 case WLAN_CIPHER_SUITE_CCMP:
553 SET_TX_DESC_SEC_TYPE(txdesc, 0x3);
556 SET_TX_DESC_SEC_TYPE(txdesc, 0x0);
560 SET_TX_DESC_PKT_ID(txdesc, 0);
561 SET_TX_DESC_QUEUE_SEL(txdesc, fw_qsel);
562 SET_TX_DESC_DATA_RATE_FB_LIMIT(txdesc, 0x1F);
563 SET_TX_DESC_RTS_RATE_FB_LIMIT(txdesc, 0xF);
564 SET_TX_DESC_DISABLE_FB(txdesc, 0);
565 SET_TX_DESC_USE_RATE(txdesc, tcb_desc->use_driver_rate ? 1 : 0);
566 if (ieee80211_is_data_qos(fc)) {
568 RT_TRACE(rtlpriv, COMP_SEND, DBG_TRACE,
569 "Enable RDG function\n");
570 SET_TX_DESC_RDG_ENABLE(txdesc, 1);
571 SET_TX_DESC_HTC(txdesc, 1);
574 if (rtlpriv->dm.useramask) {
575 SET_TX_DESC_RATE_ID(txdesc, tcb_desc->ratr_index);
576 SET_TX_DESC_MACID(txdesc, tcb_desc->mac_id);
578 SET_TX_DESC_RATE_ID(txdesc, 0xC + tcb_desc->ratr_index);
579 SET_TX_DESC_MACID(txdesc, tcb_desc->ratr_index);
581 if ((!ieee80211_is_data_qos(fc)) && ppsc->leisure_ps &&
583 SET_TX_DESC_HWSEQ_EN(txdesc, 1);
584 SET_TX_DESC_PKT_ID(txdesc, 8);
586 SET_TX_DESC_QOS(txdesc, 1);
588 if (ieee80211_has_morefrags(fc))
589 SET_TX_DESC_MORE_FRAG(txdesc, 1);
590 if (is_multicast_ether_addr(ieee80211_get_DA(hdr)) ||
591 is_broadcast_ether_addr(ieee80211_get_DA(hdr)))
592 SET_TX_DESC_BMC(txdesc, 1);
593 _rtl_fill_usb_tx_desc(txdesc);
594 _rtl_tx_desc_checksum(txdesc);
595 RT_TRACE(rtlpriv, COMP_SEND, DBG_TRACE, "==>\n");
598 void rtl92cu_fill_fake_txdesc(struct ieee80211_hw *hw, u8 *pdesc,
599 u32 buffer_len, bool is_pspoll)
601 /* Clear all status */
602 memset(pdesc, 0, RTL_TX_HEADER_SIZE);
603 SET_TX_DESC_FIRST_SEG(pdesc, 1); /* bFirstSeg; */
604 SET_TX_DESC_LAST_SEG(pdesc, 1); /* bLastSeg; */
605 SET_TX_DESC_OFFSET(pdesc, RTL_TX_HEADER_SIZE); /* Offset = 32 */
606 SET_TX_DESC_PKT_SIZE(pdesc, buffer_len); /* Buffer size + command hdr */
607 SET_TX_DESC_QUEUE_SEL(pdesc, QSLT_MGNT); /* Fixed queue of Mgnt queue */
608 /* Set NAVUSEHDR to prevent Ps-poll AId filed to be changed to error
611 SET_TX_DESC_NAV_USE_HDR(pdesc, 1);
613 SET_TX_DESC_HWSEQ_EN(pdesc, 1); /* Hw set sequence number */
614 SET_TX_DESC_PKT_ID(pdesc, 0x100); /* set bit3 to 1. */
616 SET_TX_DESC_USE_RATE(pdesc, 1); /* use data rate which is set by Sw */
617 SET_TX_DESC_OWN(pdesc, 1);
618 SET_TX_DESC_TX_RATE(pdesc, DESC_RATE1M);
619 _rtl_tx_desc_checksum(pdesc);
622 void rtl92cu_tx_fill_cmddesc(struct ieee80211_hw *hw,
623 u8 *pdesc, bool firstseg,
624 bool lastseg, struct sk_buff *skb)
626 struct rtl_priv *rtlpriv = rtl_priv(hw);
627 u8 fw_queue = QSLT_BEACON;
628 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)(skb->data);
629 __le16 fc = hdr->frame_control;
631 memset((void *)pdesc, 0, RTL_TX_HEADER_SIZE);
633 SET_TX_DESC_OFFSET(pdesc, RTL_TX_HEADER_SIZE);
634 SET_TX_DESC_TX_RATE(pdesc, DESC_RATE1M);
635 SET_TX_DESC_SEQ(pdesc, 0);
636 SET_TX_DESC_LINIP(pdesc, 0);
637 SET_TX_DESC_QUEUE_SEL(pdesc, fw_queue);
638 SET_TX_DESC_FIRST_SEG(pdesc, 1);
639 SET_TX_DESC_LAST_SEG(pdesc, 1);
640 SET_TX_DESC_RATE_ID(pdesc, 7);
641 SET_TX_DESC_MACID(pdesc, 0);
642 SET_TX_DESC_OWN(pdesc, 1);
643 SET_TX_DESC_PKT_SIZE(pdesc, (u16)skb->len);
644 SET_TX_DESC_FIRST_SEG(pdesc, 1);
645 SET_TX_DESC_LAST_SEG(pdesc, 1);
646 SET_TX_DESC_OFFSET(pdesc, 0x20);
647 SET_TX_DESC_USE_RATE(pdesc, 1);
648 if (!ieee80211_is_data_qos(fc)) {
649 SET_TX_DESC_HWSEQ_EN(pdesc, 1);
650 SET_TX_DESC_PKT_ID(pdesc, 8);
652 RT_PRINT_DATA(rtlpriv, COMP_CMD, DBG_LOUD, "H2C Tx Cmd Content",
653 pdesc, RTL_TX_DESC_SIZE);