1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright(c) 2009-2014 Realtek Corporation.*/
16 static u8
_rtl8723be_map_hwqueue_to_fwqueue(struct sk_buff
*skb
, u8 hw_queue
)
18 __le16 fc
= rtl_get_fc(skb
);
20 if (unlikely(ieee80211_is_beacon(fc
)))
22 if (ieee80211_is_mgmt(fc
) || ieee80211_is_ctl(fc
))
28 static void _rtl8723be_query_rxphystatus(struct ieee80211_hw
*hw
,
29 struct rtl_stats
*pstatus
,
31 struct rx_fwinfo_8723be
*p_drvinfo
,
32 bool bpacket_match_bssid
,
36 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
37 struct phy_status_rpt
*p_phystrpt
= (struct phy_status_rpt
*)p_drvinfo
;
38 s8 rx_pwr_all
= 0, rx_pwr
[4];
39 u8 rf_rx_num
= 0, evm
, pwdb_all
, pwdb_all_bt
= 0;
40 u8 i
, max_spatial_stream
;
41 u32 rssi
, total_rssi
= 0;
42 bool is_cck
= pstatus
->is_cck
;
45 /* Record it for next packet processing */
46 pstatus
->packet_matchbssid
= bpacket_match_bssid
;
47 pstatus
->packet_toself
= bpacket_toself
;
48 pstatus
->packet_beacon
= packet_beacon
;
49 pstatus
->rx_mimo_signalquality
[0] = -1;
50 pstatus
->rx_mimo_signalquality
[1] = -1;
55 cck_agc_rpt
= p_phystrpt
->cck_agc_rpt_ofdm_cfosho_a
;
57 /* (1)Hardware does not provide RSSI for CCK */
58 /* (2)PWDB, Average PWDB cacluated by
59 * hardware (for rate adaptive)
61 rtl_get_bbreg(hw
, RFPGA0_XA_HSSIPARAMETER2
, BIT(9));
63 lan_idx
= ((cck_agc_rpt
& 0xE0) >> 5);
64 vga_idx
= (cck_agc_rpt
& 0x1f);
67 /* 46 53 73 95 201301231630 */
68 /* 46 53 77 99 201301241630 */
70 rx_pwr_all
= -34 - (2 * vga_idx
);
73 rx_pwr_all
= -14 - (2 * vga_idx
);
76 rx_pwr_all
= 6 - (2 * vga_idx
);
79 rx_pwr_all
= 16 - (2 * vga_idx
);
85 pwdb_all
= rtl_query_rxpwrpercentage(rx_pwr_all
);
89 pstatus
->rx_pwdb_all
= pwdb_all
;
90 pstatus
->bt_rx_rssi_percentage
= pwdb_all
;
91 pstatus
->recvsignalpower
= rx_pwr_all
;
93 /* (3) Get Signal Quality (EVM) */
94 if (bpacket_match_bssid
) {
96 if (pstatus
->rx_pwdb_all
> 40) {
99 sq_rpt
= p_phystrpt
->cck_sig_qual_ofdm_pwdb_all
;
102 else if (sq_rpt
< 20)
105 sq
= ((64 - sq_rpt
) * 100) / 44;
107 pstatus
->signalquality
= sq
;
108 pstatus
->rx_mimo_signalquality
[0] = sq
;
109 pstatus
->rx_mimo_signalquality
[1] = -1;
112 /* (1)Get RSSI for HT rate */
113 for (i
= RF90_PATH_A
; i
< RF6052_MAX_PATH
; i
++) {
114 /* we will judge RF RX path now. */
115 if (rtlpriv
->dm
.rfpath_rxenable
[i
])
118 rx_pwr
[i
] = ((p_phystrpt
->path_agc
[i
].gain
& 0x3f) * 2)
121 pstatus
->rx_pwr
[i
] = rx_pwr
[i
];
122 /* Translate DBM to percentage. */
123 rssi
= rtl_query_rxpwrpercentage(rx_pwr
[i
]);
126 pstatus
->rx_mimo_signalstrength
[i
] = (u8
)rssi
;
129 /* (2)PWDB, Average PWDB cacluated by
130 * hardware (for rate adaptive)
132 rx_pwr_all
= ((p_phystrpt
->cck_sig_qual_ofdm_pwdb_all
>> 1) &
135 pwdb_all
= rtl_query_rxpwrpercentage(rx_pwr_all
);
136 pwdb_all_bt
= pwdb_all
;
137 pstatus
->rx_pwdb_all
= pwdb_all
;
138 pstatus
->bt_rx_rssi_percentage
= pwdb_all_bt
;
139 pstatus
->rxpower
= rx_pwr_all
;
140 pstatus
->recvsignalpower
= rx_pwr_all
;
142 /* (3)EVM of HT rate */
143 if (pstatus
->rate
>= DESC92C_RATEMCS8
&&
144 pstatus
->rate
<= DESC92C_RATEMCS15
)
145 max_spatial_stream
= 2;
147 max_spatial_stream
= 1;
149 for (i
= 0; i
< max_spatial_stream
; i
++) {
150 evm
= rtl_evm_db_to_percentage(
151 p_phystrpt
->stream_rxevm
[i
]);
153 if (bpacket_match_bssid
) {
154 /* Fill value in RFD, Get the first
155 * spatial stream only
158 pstatus
->signalquality
=
160 pstatus
->rx_mimo_signalquality
[i
] =
165 if (bpacket_match_bssid
) {
166 for (i
= RF90_PATH_A
; i
<= RF90_PATH_B
; i
++)
167 rtl_priv(hw
)->dm
.cfo_tail
[i
] =
168 (int)p_phystrpt
->path_cfotail
[i
];
170 if (rtl_priv(hw
)->dm
.packet_count
== 0xffffffff)
171 rtl_priv(hw
)->dm
.packet_count
= 0;
173 rtl_priv(hw
)->dm
.packet_count
++;
177 /* UI BSS List signal strength(in percentage),
178 * make it good looking, from 0~100.
181 pstatus
->signalstrength
= (u8
)(rtl_signal_scale_mapping(hw
,
183 else if (rf_rx_num
!= 0)
184 pstatus
->signalstrength
= (u8
)(rtl_signal_scale_mapping(hw
,
185 total_rssi
/= rf_rx_num
));
188 static void _rtl8723be_translate_rx_signal_stuff(struct ieee80211_hw
*hw
,
190 struct rtl_stats
*pstatus
,
192 struct rx_fwinfo_8723be
*p_drvinfo
)
194 struct rtl_mac
*mac
= rtl_mac(rtl_priv(hw
));
195 struct rtl_efuse
*rtlefuse
= rtl_efuse(rtl_priv(hw
));
196 struct ieee80211_hdr
*hdr
;
201 bool packet_matchbssid
, packet_toself
, packet_beacon
;
203 tmp_buf
= skb
->data
+ pstatus
->rx_drvinfo_size
+ pstatus
->rx_bufshift
;
205 hdr
= (struct ieee80211_hdr
*)tmp_buf
;
206 fc
= le16_to_cpu(hdr
->frame_control
);
207 type
= WLAN_FC_GET_TYPE(hdr
->frame_control
);
209 psaddr
= ieee80211_get_SA(hdr
);
210 memcpy(pstatus
->psaddr
, psaddr
, ETH_ALEN
);
212 packet_matchbssid
= ((IEEE80211_FTYPE_CTL
!= type
) &&
213 (ether_addr_equal(mac
->bssid
, (fc
& IEEE80211_FCTL_TODS
) ?
214 hdr
->addr1
: (fc
& IEEE80211_FCTL_FROMDS
) ?
215 hdr
->addr2
: hdr
->addr3
)) &&
216 (!pstatus
->hwerror
) &&
217 (!pstatus
->crc
) && (!pstatus
->icv
));
219 packet_toself
= packet_matchbssid
&&
220 (ether_addr_equal(praddr
, rtlefuse
->dev_addr
));
222 /* YP: packet_beacon is not initialized,
223 * this assignment is neccesary,
224 * otherwise it counld be true in this case
225 * the situation is much worse in Kernel 3.10
227 if (ieee80211_is_beacon(hdr
->frame_control
))
228 packet_beacon
= true;
230 packet_beacon
= false;
232 if (packet_beacon
&& packet_matchbssid
)
233 rtl_priv(hw
)->dm
.dbginfo
.num_qry_beacon_pkt
++;
235 _rtl8723be_query_rxphystatus(hw
, pstatus
, pdesc
, p_drvinfo
,
240 rtl_process_phyinfo(hw
, tmp_buf
, pstatus
);
243 static void _rtl8723be_insert_emcontent(struct rtl_tcb_desc
*ptcb_desc
,
244 __le32
*virtualaddress
)
247 memset(virtualaddress
, 0, 8);
249 set_earlymode_pktnum(virtualaddress
, ptcb_desc
->empkt_num
);
250 if (ptcb_desc
->empkt_num
== 1) {
251 dwtmp
= ptcb_desc
->empkt_len
[0];
253 dwtmp
= ptcb_desc
->empkt_len
[0];
254 dwtmp
+= ((dwtmp
% 4) ? (4 - dwtmp
% 4) : 0) + 4;
255 dwtmp
+= ptcb_desc
->empkt_len
[1];
257 set_earlymode_len0(virtualaddress
, dwtmp
);
259 if (ptcb_desc
->empkt_num
<= 3) {
260 dwtmp
= ptcb_desc
->empkt_len
[2];
262 dwtmp
= ptcb_desc
->empkt_len
[2];
263 dwtmp
+= ((dwtmp
% 4) ? (4 - dwtmp
% 4) : 0) + 4;
264 dwtmp
+= ptcb_desc
->empkt_len
[3];
266 set_earlymode_len1(virtualaddress
, dwtmp
);
267 if (ptcb_desc
->empkt_num
<= 5) {
268 dwtmp
= ptcb_desc
->empkt_len
[4];
270 dwtmp
= ptcb_desc
->empkt_len
[4];
271 dwtmp
+= ((dwtmp
% 4) ? (4 - dwtmp
% 4) : 0) + 4;
272 dwtmp
+= ptcb_desc
->empkt_len
[5];
274 set_earlymode_len2_1(virtualaddress
, dwtmp
& 0xF);
275 set_earlymode_len2_2(virtualaddress
, dwtmp
>> 4);
276 if (ptcb_desc
->empkt_num
<= 7) {
277 dwtmp
= ptcb_desc
->empkt_len
[6];
279 dwtmp
= ptcb_desc
->empkt_len
[6];
280 dwtmp
+= ((dwtmp
% 4) ? (4 - dwtmp
% 4) : 0) + 4;
281 dwtmp
+= ptcb_desc
->empkt_len
[7];
283 set_earlymode_len3(virtualaddress
, dwtmp
);
284 if (ptcb_desc
->empkt_num
<= 9) {
285 dwtmp
= ptcb_desc
->empkt_len
[8];
287 dwtmp
= ptcb_desc
->empkt_len
[8];
288 dwtmp
+= ((dwtmp
% 4) ? (4 - dwtmp
% 4) : 0) + 4;
289 dwtmp
+= ptcb_desc
->empkt_len
[9];
291 set_earlymode_len4(virtualaddress
, dwtmp
);
294 bool rtl8723be_rx_query_desc(struct ieee80211_hw
*hw
,
295 struct rtl_stats
*status
,
296 struct ieee80211_rx_status
*rx_status
,
297 u8
*pdesc8
, struct sk_buff
*skb
)
299 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
300 struct rx_fwinfo_8723be
*p_drvinfo
;
301 struct ieee80211_hdr
*hdr
;
303 __le32
*pdesc
= (__le32
*)pdesc8
;
304 u32 phystatus
= get_rx_desc_physt(pdesc
);
306 status
->length
= (u16
)get_rx_desc_pkt_len(pdesc
);
307 status
->rx_drvinfo_size
= (u8
)get_rx_desc_drv_info_size(pdesc
) *
308 RX_DRV_INFO_SIZE_UNIT
;
309 status
->rx_bufshift
= (u8
)(get_rx_desc_shift(pdesc
) & 0x03);
310 status
->icv
= (u16
)get_rx_desc_icv(pdesc
);
311 status
->crc
= (u16
)get_rx_desc_crc32(pdesc
);
312 status
->hwerror
= (status
->crc
| status
->icv
);
313 status
->decrypted
= !get_rx_desc_swdec(pdesc
);
314 status
->rate
= (u8
)get_rx_desc_rxmcs(pdesc
);
315 status
->shortpreamble
= (u16
)get_rx_desc_splcp(pdesc
);
316 status
->isampdu
= (bool)(get_rx_desc_paggr(pdesc
) == 1);
317 status
->isfirst_ampdu
= (bool)(get_rx_desc_paggr(pdesc
) == 1);
318 status
->timestamp_low
= get_rx_desc_tsfl(pdesc
);
319 status
->rx_is40mhzpacket
= (bool)get_rx_desc_bw(pdesc
);
320 status
->bandwidth
= (u8
)get_rx_desc_bw(pdesc
);
321 status
->macid
= get_rx_desc_macid(pdesc
);
322 status
->is_ht
= (bool)get_rx_desc_rxht(pdesc
);
324 status
->is_cck
= RX_HAL_IS_CCK_RATE(status
->rate
);
326 if (get_rx_status_desc_rpt_sel(pdesc
))
327 status
->packet_report_type
= C2H_PACKET
;
329 status
->packet_report_type
= NORMAL_RX
;
332 if (get_rx_status_desc_pattern_match(pdesc
))
334 else if (get_rx_status_desc_magic_match(pdesc
))
336 else if (get_rx_status_desc_unicast_match(pdesc
))
341 rtl_dbg(rtlpriv
, COMP_RXDESC
, DBG_LOUD
,
342 "GGGGGGGGGGGGGet Wakeup Packet!! WakeMatch=%d\n",
344 rx_status
->freq
= hw
->conf
.chandef
.chan
->center_freq
;
345 rx_status
->band
= hw
->conf
.chandef
.chan
->band
;
347 hdr
= (struct ieee80211_hdr
*)(skb
->data
+ status
->rx_drvinfo_size
+
348 status
->rx_bufshift
);
351 rx_status
->flag
|= RX_FLAG_FAILED_FCS_CRC
;
353 if (status
->rx_is40mhzpacket
)
354 rx_status
->bw
= RATE_INFO_BW_40
;
357 rx_status
->encoding
= RX_ENC_HT
;
359 rx_status
->flag
|= RX_FLAG_MACTIME_START
;
361 /* hw will set status->decrypted true, if it finds the
362 * frame is open data frame or mgmt frame.
363 * So hw will not decryption robust managment frame
364 * for IEEE80211w but still set status->decrypted
365 * true, so here we should set it back to undecrypted
366 * for IEEE80211w frame, and mac80211 sw will help
369 if (status
->decrypted
) {
370 if ((!_ieee80211_is_robust_mgmt_frame(hdr
)) &&
371 (ieee80211_has_protected(hdr
->frame_control
)))
372 rx_status
->flag
|= RX_FLAG_DECRYPTED
;
374 rx_status
->flag
&= ~RX_FLAG_DECRYPTED
;
377 /* rate_idx: index of data rate into band's
378 * supported rates or MCS index if HT rates
379 * are use (RX_FLAG_HT)
381 rx_status
->rate_idx
= rtlwifi_rate_mapping(hw
, status
->is_ht
,
382 false, status
->rate
);
384 rx_status
->mactime
= status
->timestamp_low
;
386 p_drvinfo
= (struct rx_fwinfo_8723be
*)(skb
->data
+
387 status
->rx_bufshift
);
389 _rtl8723be_translate_rx_signal_stuff(hw
, skb
, status
,
392 rx_status
->signal
= status
->recvsignalpower
+ 10;
393 if (status
->packet_report_type
== TX_REPORT2
) {
394 status
->macid_valid_entry
[0] =
395 get_rx_rpt2_desc_macid_valid_1(pdesc
);
396 status
->macid_valid_entry
[1] =
397 get_rx_rpt2_desc_macid_valid_2(pdesc
);
402 void rtl8723be_tx_fill_desc(struct ieee80211_hw
*hw
,
403 struct ieee80211_hdr
*hdr
, u8
*pdesc8
,
404 u8
*txbd
, struct ieee80211_tx_info
*info
,
405 struct ieee80211_sta
*sta
, struct sk_buff
*skb
,
406 u8 hw_queue
, struct rtl_tcb_desc
*ptcb_desc
)
408 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
409 struct rtl_mac
*mac
= rtl_mac(rtl_priv(hw
));
410 struct rtl_pci
*rtlpci
= rtl_pcidev(rtl_pcipriv(hw
));
411 struct rtl_hal
*rtlhal
= rtl_hal(rtlpriv
);
412 struct rtlwifi_tx_info
*tx_info
= rtl_tx_skb_cb_info(skb
);
413 __le32
*pdesc
= (__le32
*)pdesc8
;
415 __le16 fc
= hdr
->frame_control
;
416 unsigned int buf_len
= 0;
417 unsigned int skb_len
= skb
->len
;
418 u8 fw_qsel
= _rtl8723be_map_hwqueue_to_fwqueue(skb
, hw_queue
);
419 bool firstseg
= ((hdr
->seq_ctrl
&
420 cpu_to_le16(IEEE80211_SCTL_FRAG
)) == 0);
421 bool lastseg
= ((hdr
->frame_control
&
422 cpu_to_le16(IEEE80211_FCTL_MOREFRAGS
)) == 0);
427 if (mac
->opmode
== NL80211_IFTYPE_STATION
) {
429 } else if (mac
->opmode
== NL80211_IFTYPE_AP
||
430 mac
->opmode
== NL80211_IFTYPE_ADHOC
) {
432 bw_40
= sta
->ht_cap
.cap
&
433 IEEE80211_HT_CAP_SUP_WIDTH_20_40
;
435 seq_number
= (le16_to_cpu(hdr
->seq_ctrl
) & IEEE80211_SCTL_SEQ
) >> 4;
436 rtl_get_tcb_desc(hw
, info
, sta
, skb
, ptcb_desc
);
437 /* reserve 8 byte for AMPDU early mode */
438 if (rtlhal
->earlymode_enable
) {
439 skb_push(skb
, EM_HDR_LEN
);
440 memset(skb
->data
, 0, EM_HDR_LEN
);
443 mapping
= dma_map_single(&rtlpci
->pdev
->dev
, skb
->data
, skb
->len
,
445 if (dma_mapping_error(&rtlpci
->pdev
->dev
, mapping
)) {
446 rtl_dbg(rtlpriv
, COMP_SEND
, DBG_TRACE
, "DMA mapping error\n");
449 clear_pci_tx_desc_content(pdesc
, sizeof(struct tx_desc_8723be
));
450 if (ieee80211_is_nullfunc(fc
) || ieee80211_is_ctl(fc
)) {
455 if (rtlhal
->earlymode_enable
) {
456 set_tx_desc_pkt_offset(pdesc
, 1);
457 set_tx_desc_offset(pdesc
, USB_HWDESC_HEADER_LEN
+
459 if (ptcb_desc
->empkt_num
) {
460 rtl_dbg(rtlpriv
, COMP_SEND
, DBG_TRACE
,
461 "Insert 8 byte.pTcb->EMPktNum:%d\n",
462 ptcb_desc
->empkt_num
);
463 _rtl8723be_insert_emcontent(ptcb_desc
,
464 (__le32
*)(skb
->data
));
467 set_tx_desc_offset(pdesc
, USB_HWDESC_HEADER_LEN
);
471 /* ptcb_desc->use_driver_rate = true; */
472 set_tx_desc_tx_rate(pdesc
, ptcb_desc
->hw_rate
);
473 if (ptcb_desc
->hw_rate
> DESC92C_RATEMCS0
)
474 short_gi
= (ptcb_desc
->use_shortgi
) ? 1 : 0;
476 short_gi
= (ptcb_desc
->use_shortpreamble
) ? 1 : 0;
478 set_tx_desc_data_shortgi(pdesc
, short_gi
);
480 if (info
->flags
& IEEE80211_TX_CTL_AMPDU
) {
481 set_tx_desc_agg_enable(pdesc
, 1);
482 set_tx_desc_max_agg_num(pdesc
, 0x14);
484 set_tx_desc_seq(pdesc
, seq_number
);
485 set_tx_desc_rts_enable(pdesc
, ((ptcb_desc
->rts_enable
&&
486 !ptcb_desc
->cts_enable
) ?
488 set_tx_desc_hw_rts_enable(pdesc
, 0);
489 set_tx_desc_cts2self(pdesc
, ((ptcb_desc
->cts_enable
) ?
492 set_tx_desc_rts_rate(pdesc
, ptcb_desc
->rts_rate
);
494 set_tx_desc_rts_sc(pdesc
, ptcb_desc
->rts_sc
);
495 set_tx_desc_rts_short(pdesc
,
496 ((ptcb_desc
->rts_rate
<= DESC92C_RATE54M
) ?
497 (ptcb_desc
->rts_use_shortpreamble
? 1 : 0) :
498 (ptcb_desc
->rts_use_shortgi
? 1 : 0)));
500 if (ptcb_desc
->tx_enable_sw_calc_duration
)
501 set_tx_desc_nav_use_hdr(pdesc
, 1);
504 if (ptcb_desc
->packet_bw
== HT_CHANNEL_WIDTH_20_40
) {
505 set_tx_desc_data_bw(pdesc
, 1);
506 set_tx_desc_tx_sub_carrier(pdesc
, 3);
508 set_tx_desc_data_bw(pdesc
, 0);
509 set_tx_desc_tx_sub_carrier(pdesc
, mac
->cur_40_prime_sc
);
512 set_tx_desc_data_bw(pdesc
, 0);
513 set_tx_desc_tx_sub_carrier(pdesc
, 0);
516 set_tx_desc_linip(pdesc
, 0);
517 set_tx_desc_pkt_size(pdesc
, (u16
)skb_len
);
519 u8 ampdu_density
= sta
->ht_cap
.ampdu_density
;
520 set_tx_desc_ampdu_density(pdesc
, ampdu_density
);
522 if (info
->control
.hw_key
) {
523 struct ieee80211_key_conf
*keyconf
=
524 info
->control
.hw_key
;
525 switch (keyconf
->cipher
) {
526 case WLAN_CIPHER_SUITE_WEP40
:
527 case WLAN_CIPHER_SUITE_WEP104
:
528 case WLAN_CIPHER_SUITE_TKIP
:
529 set_tx_desc_sec_type(pdesc
, 0x1);
531 case WLAN_CIPHER_SUITE_CCMP
:
532 set_tx_desc_sec_type(pdesc
, 0x3);
535 set_tx_desc_sec_type(pdesc
, 0x0);
540 set_tx_desc_queue_sel(pdesc
, fw_qsel
);
541 set_tx_desc_data_rate_fb_limit(pdesc
, 0x1F);
542 set_tx_desc_rts_rate_fb_limit(pdesc
, 0xF);
543 set_tx_desc_disable_fb(pdesc
, ptcb_desc
->disable_ratefallback
?
545 set_tx_desc_use_rate(pdesc
, ptcb_desc
->use_driver_rate
? 1 : 0);
547 /* Set TxRate and RTSRate in TxDesc */
548 /* This prevent Tx initial rate of new-coming packets */
549 /* from being overwritten by retried packet rate.*/
550 if (ieee80211_is_data_qos(fc
)) {
552 rtl_dbg(rtlpriv
, COMP_SEND
, DBG_TRACE
,
553 "Enable RDG function.\n");
554 set_tx_desc_rdg_enable(pdesc
, 1);
555 set_tx_desc_htc(pdesc
, 1);
559 rtl_set_tx_report(ptcb_desc
, pdesc8
, hw
, tx_info
);
562 set_tx_desc_first_seg(pdesc
, (firstseg
? 1 : 0));
563 set_tx_desc_last_seg(pdesc
, (lastseg
? 1 : 0));
564 set_tx_desc_tx_buffer_size(pdesc
, (u16
)buf_len
);
565 set_tx_desc_tx_buffer_address(pdesc
, mapping
);
566 /* if (rtlpriv->dm.useramask) { */
568 set_tx_desc_rate_id(pdesc
, ptcb_desc
->ratr_index
);
569 set_tx_desc_macid(pdesc
, ptcb_desc
->mac_id
);
571 set_tx_desc_rate_id(pdesc
, 0xC + ptcb_desc
->ratr_index
);
572 set_tx_desc_macid(pdesc
, ptcb_desc
->mac_id
);
574 if (!ieee80211_is_data_qos(fc
)) {
575 set_tx_desc_hwseq_en(pdesc
, 1);
576 set_tx_desc_hwseq_sel(pdesc
, 0);
578 set_tx_desc_more_frag(pdesc
, (lastseg
? 0 : 1));
579 if (is_multicast_ether_addr(ieee80211_get_DA(hdr
)) ||
580 is_broadcast_ether_addr(ieee80211_get_DA(hdr
))) {
581 set_tx_desc_bmc(pdesc
, 1);
584 rtl_dbg(rtlpriv
, COMP_SEND
, DBG_TRACE
, "\n");
587 void rtl8723be_tx_fill_cmddesc(struct ieee80211_hw
*hw
, u8
*pdesc8
,
588 bool firstseg
, bool lastseg
,
591 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
592 struct rtl_pci
*rtlpci
= rtl_pcidev(rtl_pcipriv(hw
));
593 u8 fw_queue
= QSLT_BEACON
;
594 __le32
*pdesc
= (__le32
*)pdesc8
;
596 dma_addr_t mapping
= dma_map_single(&rtlpci
->pdev
->dev
, skb
->data
,
597 skb
->len
, DMA_TO_DEVICE
);
599 if (dma_mapping_error(&rtlpci
->pdev
->dev
, mapping
)) {
600 rtl_dbg(rtlpriv
, COMP_SEND
, DBG_TRACE
,
601 "DMA mapping error\n");
604 clear_pci_tx_desc_content(pdesc
, TX_DESC_SIZE
);
606 set_tx_desc_offset(pdesc
, USB_HWDESC_HEADER_LEN
);
608 set_tx_desc_tx_rate(pdesc
, DESC92C_RATE1M
);
610 set_tx_desc_seq(pdesc
, 0);
612 set_tx_desc_linip(pdesc
, 0);
614 set_tx_desc_queue_sel(pdesc
, fw_queue
);
616 set_tx_desc_first_seg(pdesc
, 1);
617 set_tx_desc_last_seg(pdesc
, 1);
619 set_tx_desc_tx_buffer_size(pdesc
, (u16
)(skb
->len
));
621 set_tx_desc_tx_buffer_address(pdesc
, mapping
);
623 set_tx_desc_rate_id(pdesc
, 0);
624 set_tx_desc_macid(pdesc
, 0);
626 set_tx_desc_own(pdesc
, 1);
628 set_tx_desc_pkt_size(pdesc
, (u16
)(skb
->len
));
630 set_tx_desc_first_seg(pdesc
, 1);
631 set_tx_desc_last_seg(pdesc
, 1);
633 set_tx_desc_use_rate(pdesc
, 1);
635 RT_PRINT_DATA(rtlpriv
, COMP_CMD
, DBG_LOUD
,
636 "H2C Tx Cmd Content\n", pdesc
, TX_DESC_SIZE
);
639 void rtl8723be_set_desc(struct ieee80211_hw
*hw
, u8
*pdesc8
,
640 bool istx
, u8 desc_name
, u8
*val
)
642 __le32
*pdesc
= (__le32
*)pdesc8
;
647 set_tx_desc_own(pdesc
, 1);
649 case HW_DESC_TX_NEXTDESC_ADDR
:
650 set_tx_desc_next_desc_address(pdesc
, *(u32
*)val
);
653 WARN_ONCE(true, "rtl8723be: ERR txdesc :%d not processed\n",
660 set_rx_desc_own(pdesc
, 1);
662 case HW_DESC_RXBUFF_ADDR
:
663 set_rx_desc_buff_addr(pdesc
, *(u32
*)val
);
665 case HW_DESC_RXPKT_LEN
:
666 set_rx_desc_pkt_len(pdesc
, *(u32
*)val
);
669 set_rx_desc_eor(pdesc
, 1);
672 WARN_ONCE(true, "rtl8723be: ERR rxdesc :%d not process\n",
679 u64
rtl8723be_get_desc(struct ieee80211_hw
*hw
,
680 u8
*pdesc8
, bool istx
, u8 desc_name
)
683 __le32
*pdesc
= (__le32
*)pdesc8
;
688 ret
= get_tx_desc_own(pdesc
);
690 case HW_DESC_TXBUFF_ADDR
:
691 ret
= get_tx_desc_tx_buffer_address(pdesc
);
694 WARN_ONCE(true, "rtl8723be: ERR txdesc :%d not process\n",
701 ret
= get_rx_desc_own(pdesc
);
703 case HW_DESC_RXPKT_LEN
:
704 ret
= get_rx_desc_pkt_len(pdesc
);
706 case HW_DESC_RXBUFF_ADDR
:
707 ret
= get_rx_desc_buff_addr(pdesc
);
710 WARN_ONCE(true, "rtl8723be: ERR rxdesc :%d not processed\n",
718 bool rtl8723be_is_tx_desc_closed(struct ieee80211_hw
*hw
,
719 u8 hw_queue
, u16 index
)
721 struct rtl_pci
*rtlpci
= rtl_pcidev(rtl_pcipriv(hw
));
722 struct rtl8192_tx_ring
*ring
= &rtlpci
->tx_ring
[hw_queue
];
723 u8
*entry
= (u8
*)(&ring
->desc
[ring
->idx
]);
724 u8 own
= (u8
)rtl8723be_get_desc(hw
, entry
, true, HW_DESC_OWN
);
726 /*beacon packet will only use the first
727 *descriptor defautly,and the own may not
728 *be cleared by the hardware
735 void rtl8723be_tx_polling(struct ieee80211_hw
*hw
, u8 hw_queue
)
737 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
738 if (hw_queue
== BEACON_QUEUE
) {
739 rtl_write_word(rtlpriv
, REG_PCIE_CTRL_REG
, BIT(4));
741 rtl_write_word(rtlpriv
, REG_PCIE_CTRL_REG
,
742 BIT(0) << (hw_queue
));