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;
56 cck_agc_rpt
= p_phystrpt
->cck_agc_rpt_ofdm_cfosho_a
;
58 /* (1)Hardware does not provide RSSI for CCK */
59 /* (2)PWDB, Average PWDB cacluated by
60 * hardware (for rate adaptive)
62 cck_highpwr
= (u8
)rtl_get_bbreg(hw
, RFPGA0_XA_HSSIPARAMETER2
,
65 lan_idx
= ((cck_agc_rpt
& 0xE0) >> 5);
66 vga_idx
= (cck_agc_rpt
& 0x1f);
69 /* 46 53 73 95 201301231630 */
70 /* 46 53 77 99 201301241630 */
72 rx_pwr_all
= -34 - (2 * vga_idx
);
75 rx_pwr_all
= -14 - (2 * vga_idx
);
78 rx_pwr_all
= 6 - (2 * vga_idx
);
81 rx_pwr_all
= 16 - (2 * vga_idx
);
87 pwdb_all
= rtl_query_rxpwrpercentage(rx_pwr_all
);
91 pstatus
->rx_pwdb_all
= pwdb_all
;
92 pstatus
->bt_rx_rssi_percentage
= pwdb_all
;
93 pstatus
->recvsignalpower
= rx_pwr_all
;
95 /* (3) Get Signal Quality (EVM) */
96 if (bpacket_match_bssid
) {
98 if (pstatus
->rx_pwdb_all
> 40) {
101 sq_rpt
= p_phystrpt
->cck_sig_qual_ofdm_pwdb_all
;
104 else if (sq_rpt
< 20)
107 sq
= ((64 - sq_rpt
) * 100) / 44;
109 pstatus
->signalquality
= sq
;
110 pstatus
->rx_mimo_signalquality
[0] = sq
;
111 pstatus
->rx_mimo_signalquality
[1] = -1;
114 /* (1)Get RSSI for HT rate */
115 for (i
= RF90_PATH_A
; i
< RF6052_MAX_PATH
; i
++) {
116 /* we will judge RF RX path now. */
117 if (rtlpriv
->dm
.rfpath_rxenable
[i
])
120 rx_pwr
[i
] = ((p_phystrpt
->path_agc
[i
].gain
& 0x3f) * 2)
123 pstatus
->rx_pwr
[i
] = rx_pwr
[i
];
124 /* Translate DBM to percentage. */
125 rssi
= rtl_query_rxpwrpercentage(rx_pwr
[i
]);
128 pstatus
->rx_mimo_signalstrength
[i
] = (u8
)rssi
;
131 /* (2)PWDB, Average PWDB cacluated by
132 * hardware (for rate adaptive)
134 rx_pwr_all
= ((p_phystrpt
->cck_sig_qual_ofdm_pwdb_all
>> 1) &
137 pwdb_all
= rtl_query_rxpwrpercentage(rx_pwr_all
);
138 pwdb_all_bt
= pwdb_all
;
139 pstatus
->rx_pwdb_all
= pwdb_all
;
140 pstatus
->bt_rx_rssi_percentage
= pwdb_all_bt
;
141 pstatus
->rxpower
= rx_pwr_all
;
142 pstatus
->recvsignalpower
= rx_pwr_all
;
144 /* (3)EVM of HT rate */
145 if (pstatus
->rate
>= DESC92C_RATEMCS8
&&
146 pstatus
->rate
<= DESC92C_RATEMCS15
)
147 max_spatial_stream
= 2;
149 max_spatial_stream
= 1;
151 for (i
= 0; i
< max_spatial_stream
; i
++) {
152 evm
= rtl_evm_db_to_percentage(
153 p_phystrpt
->stream_rxevm
[i
]);
155 if (bpacket_match_bssid
) {
156 /* Fill value in RFD, Get the first
157 * spatial stream only
160 pstatus
->signalquality
=
162 pstatus
->rx_mimo_signalquality
[i
] =
167 if (bpacket_match_bssid
) {
168 for (i
= RF90_PATH_A
; i
<= RF90_PATH_B
; i
++)
169 rtl_priv(hw
)->dm
.cfo_tail
[i
] =
170 (int)p_phystrpt
->path_cfotail
[i
];
172 if (rtl_priv(hw
)->dm
.packet_count
== 0xffffffff)
173 rtl_priv(hw
)->dm
.packet_count
= 0;
175 rtl_priv(hw
)->dm
.packet_count
++;
179 /* UI BSS List signal strength(in percentage),
180 * make it good looking, from 0~100.
183 pstatus
->signalstrength
= (u8
)(rtl_signal_scale_mapping(hw
,
185 else if (rf_rx_num
!= 0)
186 pstatus
->signalstrength
= (u8
)(rtl_signal_scale_mapping(hw
,
187 total_rssi
/= rf_rx_num
));
190 static void _rtl8723be_translate_rx_signal_stuff(struct ieee80211_hw
*hw
,
192 struct rtl_stats
*pstatus
,
194 struct rx_fwinfo_8723be
*p_drvinfo
)
196 struct rtl_mac
*mac
= rtl_mac(rtl_priv(hw
));
197 struct rtl_efuse
*rtlefuse
= rtl_efuse(rtl_priv(hw
));
198 struct ieee80211_hdr
*hdr
;
203 bool packet_matchbssid
, packet_toself
, packet_beacon
;
205 tmp_buf
= skb
->data
+ pstatus
->rx_drvinfo_size
+ pstatus
->rx_bufshift
;
207 hdr
= (struct ieee80211_hdr
*)tmp_buf
;
208 fc
= le16_to_cpu(hdr
->frame_control
);
209 type
= WLAN_FC_GET_TYPE(hdr
->frame_control
);
211 psaddr
= ieee80211_get_SA(hdr
);
212 memcpy(pstatus
->psaddr
, psaddr
, ETH_ALEN
);
214 packet_matchbssid
= ((IEEE80211_FTYPE_CTL
!= type
) &&
215 (ether_addr_equal(mac
->bssid
, (fc
& IEEE80211_FCTL_TODS
) ?
216 hdr
->addr1
: (fc
& IEEE80211_FCTL_FROMDS
) ?
217 hdr
->addr2
: hdr
->addr3
)) &&
218 (!pstatus
->hwerror
) &&
219 (!pstatus
->crc
) && (!pstatus
->icv
));
221 packet_toself
= packet_matchbssid
&&
222 (ether_addr_equal(praddr
, rtlefuse
->dev_addr
));
224 /* YP: packet_beacon is not initialized,
225 * this assignment is neccesary,
226 * otherwise it counld be true in this case
227 * the situation is much worse in Kernel 3.10
229 if (ieee80211_is_beacon(hdr
->frame_control
))
230 packet_beacon
= true;
232 packet_beacon
= false;
234 if (packet_beacon
&& packet_matchbssid
)
235 rtl_priv(hw
)->dm
.dbginfo
.num_qry_beacon_pkt
++;
237 _rtl8723be_query_rxphystatus(hw
, pstatus
, pdesc
, p_drvinfo
,
242 rtl_process_phyinfo(hw
, tmp_buf
, pstatus
);
245 static void _rtl8723be_insert_emcontent(struct rtl_tcb_desc
*ptcb_desc
,
246 __le32
*virtualaddress
)
249 memset(virtualaddress
, 0, 8);
251 set_earlymode_pktnum(virtualaddress
, ptcb_desc
->empkt_num
);
252 if (ptcb_desc
->empkt_num
== 1) {
253 dwtmp
= ptcb_desc
->empkt_len
[0];
255 dwtmp
= ptcb_desc
->empkt_len
[0];
256 dwtmp
+= ((dwtmp
% 4) ? (4 - dwtmp
% 4) : 0) + 4;
257 dwtmp
+= ptcb_desc
->empkt_len
[1];
259 set_earlymode_len0(virtualaddress
, dwtmp
);
261 if (ptcb_desc
->empkt_num
<= 3) {
262 dwtmp
= ptcb_desc
->empkt_len
[2];
264 dwtmp
= ptcb_desc
->empkt_len
[2];
265 dwtmp
+= ((dwtmp
% 4) ? (4 - dwtmp
% 4) : 0) + 4;
266 dwtmp
+= ptcb_desc
->empkt_len
[3];
268 set_earlymode_len1(virtualaddress
, dwtmp
);
269 if (ptcb_desc
->empkt_num
<= 5) {
270 dwtmp
= ptcb_desc
->empkt_len
[4];
272 dwtmp
= ptcb_desc
->empkt_len
[4];
273 dwtmp
+= ((dwtmp
% 4) ? (4 - dwtmp
% 4) : 0) + 4;
274 dwtmp
+= ptcb_desc
->empkt_len
[5];
276 set_earlymode_len2_1(virtualaddress
, dwtmp
& 0xF);
277 set_earlymode_len2_2(virtualaddress
, dwtmp
>> 4);
278 if (ptcb_desc
->empkt_num
<= 7) {
279 dwtmp
= ptcb_desc
->empkt_len
[6];
281 dwtmp
= ptcb_desc
->empkt_len
[6];
282 dwtmp
+= ((dwtmp
% 4) ? (4 - dwtmp
% 4) : 0) + 4;
283 dwtmp
+= ptcb_desc
->empkt_len
[7];
285 set_earlymode_len3(virtualaddress
, dwtmp
);
286 if (ptcb_desc
->empkt_num
<= 9) {
287 dwtmp
= ptcb_desc
->empkt_len
[8];
289 dwtmp
= ptcb_desc
->empkt_len
[8];
290 dwtmp
+= ((dwtmp
% 4) ? (4 - dwtmp
% 4) : 0) + 4;
291 dwtmp
+= ptcb_desc
->empkt_len
[9];
293 set_earlymode_len4(virtualaddress
, dwtmp
);
296 bool rtl8723be_rx_query_desc(struct ieee80211_hw
*hw
,
297 struct rtl_stats
*status
,
298 struct ieee80211_rx_status
*rx_status
,
299 u8
*pdesc8
, struct sk_buff
*skb
)
301 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
302 struct rx_fwinfo_8723be
*p_drvinfo
;
303 struct ieee80211_hdr
*hdr
;
305 __le32
*pdesc
= (__le32
*)pdesc8
;
306 u32 phystatus
= get_rx_desc_physt(pdesc
);
308 status
->length
= (u16
)get_rx_desc_pkt_len(pdesc
);
309 status
->rx_drvinfo_size
= (u8
)get_rx_desc_drv_info_size(pdesc
) *
310 RX_DRV_INFO_SIZE_UNIT
;
311 status
->rx_bufshift
= (u8
)(get_rx_desc_shift(pdesc
) & 0x03);
312 status
->icv
= (u16
)get_rx_desc_icv(pdesc
);
313 status
->crc
= (u16
)get_rx_desc_crc32(pdesc
);
314 status
->hwerror
= (status
->crc
| status
->icv
);
315 status
->decrypted
= !get_rx_desc_swdec(pdesc
);
316 status
->rate
= (u8
)get_rx_desc_rxmcs(pdesc
);
317 status
->shortpreamble
= (u16
)get_rx_desc_splcp(pdesc
);
318 status
->isampdu
= (bool)(get_rx_desc_paggr(pdesc
) == 1);
319 status
->isfirst_ampdu
= (bool)(get_rx_desc_paggr(pdesc
) == 1);
320 status
->timestamp_low
= get_rx_desc_tsfl(pdesc
);
321 status
->rx_is40mhzpacket
= (bool)get_rx_desc_bw(pdesc
);
322 status
->bandwidth
= (u8
)get_rx_desc_bw(pdesc
);
323 status
->macid
= get_rx_desc_macid(pdesc
);
324 status
->is_ht
= (bool)get_rx_desc_rxht(pdesc
);
326 status
->is_cck
= RX_HAL_IS_CCK_RATE(status
->rate
);
328 if (get_rx_status_desc_rpt_sel(pdesc
))
329 status
->packet_report_type
= C2H_PACKET
;
331 status
->packet_report_type
= NORMAL_RX
;
334 if (get_rx_status_desc_pattern_match(pdesc
))
336 else if (get_rx_status_desc_magic_match(pdesc
))
338 else if (get_rx_status_desc_unicast_match(pdesc
))
343 RT_TRACE(rtlpriv
, COMP_RXDESC
, DBG_LOUD
,
344 "GGGGGGGGGGGGGet Wakeup Packet!! WakeMatch=%d\n",
346 rx_status
->freq
= hw
->conf
.chandef
.chan
->center_freq
;
347 rx_status
->band
= hw
->conf
.chandef
.chan
->band
;
349 hdr
= (struct ieee80211_hdr
*)(skb
->data
+ status
->rx_drvinfo_size
+
350 status
->rx_bufshift
);
353 rx_status
->flag
|= RX_FLAG_FAILED_FCS_CRC
;
355 if (status
->rx_is40mhzpacket
)
356 rx_status
->bw
= RATE_INFO_BW_40
;
359 rx_status
->encoding
= RX_ENC_HT
;
361 rx_status
->flag
|= RX_FLAG_MACTIME_START
;
363 /* hw will set status->decrypted true, if it finds the
364 * frame is open data frame or mgmt frame.
365 * So hw will not decryption robust managment frame
366 * for IEEE80211w but still set status->decrypted
367 * true, so here we should set it back to undecrypted
368 * for IEEE80211w frame, and mac80211 sw will help
371 if (status
->decrypted
) {
372 if ((!_ieee80211_is_robust_mgmt_frame(hdr
)) &&
373 (ieee80211_has_protected(hdr
->frame_control
)))
374 rx_status
->flag
|= RX_FLAG_DECRYPTED
;
376 rx_status
->flag
&= ~RX_FLAG_DECRYPTED
;
379 /* rate_idx: index of data rate into band's
380 * supported rates or MCS index if HT rates
381 * are use (RX_FLAG_HT)
383 rx_status
->rate_idx
= rtlwifi_rate_mapping(hw
, status
->is_ht
,
384 false, status
->rate
);
386 rx_status
->mactime
= status
->timestamp_low
;
388 p_drvinfo
= (struct rx_fwinfo_8723be
*)(skb
->data
+
389 status
->rx_bufshift
);
391 _rtl8723be_translate_rx_signal_stuff(hw
, skb
, status
,
394 rx_status
->signal
= status
->recvsignalpower
+ 10;
395 if (status
->packet_report_type
== TX_REPORT2
) {
396 status
->macid_valid_entry
[0] =
397 get_rx_rpt2_desc_macid_valid_1(pdesc
);
398 status
->macid_valid_entry
[1] =
399 get_rx_rpt2_desc_macid_valid_2(pdesc
);
404 void rtl8723be_tx_fill_desc(struct ieee80211_hw
*hw
,
405 struct ieee80211_hdr
*hdr
, u8
*pdesc8
,
406 u8
*txbd
, struct ieee80211_tx_info
*info
,
407 struct ieee80211_sta
*sta
, struct sk_buff
*skb
,
408 u8 hw_queue
, struct rtl_tcb_desc
*ptcb_desc
)
410 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
411 struct rtl_mac
*mac
= rtl_mac(rtl_priv(hw
));
412 struct rtl_pci
*rtlpci
= rtl_pcidev(rtl_pcipriv(hw
));
413 struct rtl_hal
*rtlhal
= rtl_hal(rtlpriv
);
414 struct rtlwifi_tx_info
*tx_info
= rtl_tx_skb_cb_info(skb
);
415 __le32
*pdesc
= (__le32
*)pdesc8
;
417 __le16 fc
= hdr
->frame_control
;
418 unsigned int buf_len
= 0;
419 unsigned int skb_len
= skb
->len
;
420 u8 fw_qsel
= _rtl8723be_map_hwqueue_to_fwqueue(skb
, hw_queue
);
421 bool firstseg
= ((hdr
->seq_ctrl
&
422 cpu_to_le16(IEEE80211_SCTL_FRAG
)) == 0);
423 bool lastseg
= ((hdr
->frame_control
&
424 cpu_to_le16(IEEE80211_FCTL_MOREFRAGS
)) == 0);
429 if (mac
->opmode
== NL80211_IFTYPE_STATION
) {
431 } else if (mac
->opmode
== NL80211_IFTYPE_AP
||
432 mac
->opmode
== NL80211_IFTYPE_ADHOC
) {
434 bw_40
= sta
->ht_cap
.cap
&
435 IEEE80211_HT_CAP_SUP_WIDTH_20_40
;
437 seq_number
= (le16_to_cpu(hdr
->seq_ctrl
) & IEEE80211_SCTL_SEQ
) >> 4;
438 rtl_get_tcb_desc(hw
, info
, sta
, skb
, ptcb_desc
);
439 /* reserve 8 byte for AMPDU early mode */
440 if (rtlhal
->earlymode_enable
) {
441 skb_push(skb
, EM_HDR_LEN
);
442 memset(skb
->data
, 0, EM_HDR_LEN
);
445 mapping
= pci_map_single(rtlpci
->pdev
, skb
->data
, skb
->len
,
447 if (pci_dma_mapping_error(rtlpci
->pdev
, mapping
)) {
448 RT_TRACE(rtlpriv
, COMP_SEND
, DBG_TRACE
, "DMA mapping error\n");
451 clear_pci_tx_desc_content(pdesc
, sizeof(struct tx_desc_8723be
));
452 if (ieee80211_is_nullfunc(fc
) || ieee80211_is_ctl(fc
)) {
457 if (rtlhal
->earlymode_enable
) {
458 set_tx_desc_pkt_offset(pdesc
, 1);
459 set_tx_desc_offset(pdesc
, USB_HWDESC_HEADER_LEN
+
461 if (ptcb_desc
->empkt_num
) {
462 RT_TRACE(rtlpriv
, COMP_SEND
, DBG_TRACE
,
463 "Insert 8 byte.pTcb->EMPktNum:%d\n",
464 ptcb_desc
->empkt_num
);
465 _rtl8723be_insert_emcontent(ptcb_desc
,
466 (__le32
*)(skb
->data
));
469 set_tx_desc_offset(pdesc
, USB_HWDESC_HEADER_LEN
);
473 /* ptcb_desc->use_driver_rate = true; */
474 set_tx_desc_tx_rate(pdesc
, ptcb_desc
->hw_rate
);
475 if (ptcb_desc
->hw_rate
> DESC92C_RATEMCS0
)
476 short_gi
= (ptcb_desc
->use_shortgi
) ? 1 : 0;
478 short_gi
= (ptcb_desc
->use_shortpreamble
) ? 1 : 0;
480 set_tx_desc_data_shortgi(pdesc
, short_gi
);
482 if (info
->flags
& IEEE80211_TX_CTL_AMPDU
) {
483 set_tx_desc_agg_enable(pdesc
, 1);
484 set_tx_desc_max_agg_num(pdesc
, 0x14);
486 set_tx_desc_seq(pdesc
, seq_number
);
487 set_tx_desc_rts_enable(pdesc
, ((ptcb_desc
->rts_enable
&&
488 !ptcb_desc
->cts_enable
) ?
490 set_tx_desc_hw_rts_enable(pdesc
, 0);
491 set_tx_desc_cts2self(pdesc
, ((ptcb_desc
->cts_enable
) ?
494 set_tx_desc_rts_rate(pdesc
, ptcb_desc
->rts_rate
);
496 set_tx_desc_rts_sc(pdesc
, ptcb_desc
->rts_sc
);
497 set_tx_desc_rts_short(pdesc
,
498 ((ptcb_desc
->rts_rate
<= DESC92C_RATE54M
) ?
499 (ptcb_desc
->rts_use_shortpreamble
? 1 : 0) :
500 (ptcb_desc
->rts_use_shortgi
? 1 : 0)));
502 if (ptcb_desc
->tx_enable_sw_calc_duration
)
503 set_tx_desc_nav_use_hdr(pdesc
, 1);
506 if (ptcb_desc
->packet_bw
== HT_CHANNEL_WIDTH_20_40
) {
507 set_tx_desc_data_bw(pdesc
, 1);
508 set_tx_desc_tx_sub_carrier(pdesc
, 3);
510 set_tx_desc_data_bw(pdesc
, 0);
511 set_tx_desc_tx_sub_carrier(pdesc
, mac
->cur_40_prime_sc
);
514 set_tx_desc_data_bw(pdesc
, 0);
515 set_tx_desc_tx_sub_carrier(pdesc
, 0);
518 set_tx_desc_linip(pdesc
, 0);
519 set_tx_desc_pkt_size(pdesc
, (u16
)skb_len
);
521 u8 ampdu_density
= sta
->ht_cap
.ampdu_density
;
522 set_tx_desc_ampdu_density(pdesc
, ampdu_density
);
524 if (info
->control
.hw_key
) {
525 struct ieee80211_key_conf
*keyconf
=
526 info
->control
.hw_key
;
527 switch (keyconf
->cipher
) {
528 case WLAN_CIPHER_SUITE_WEP40
:
529 case WLAN_CIPHER_SUITE_WEP104
:
530 case WLAN_CIPHER_SUITE_TKIP
:
531 set_tx_desc_sec_type(pdesc
, 0x1);
533 case WLAN_CIPHER_SUITE_CCMP
:
534 set_tx_desc_sec_type(pdesc
, 0x3);
537 set_tx_desc_sec_type(pdesc
, 0x0);
542 set_tx_desc_queue_sel(pdesc
, fw_qsel
);
543 set_tx_desc_data_rate_fb_limit(pdesc
, 0x1F);
544 set_tx_desc_rts_rate_fb_limit(pdesc
, 0xF);
545 set_tx_desc_disable_fb(pdesc
, ptcb_desc
->disable_ratefallback
?
547 set_tx_desc_use_rate(pdesc
, ptcb_desc
->use_driver_rate
? 1 : 0);
549 /* Set TxRate and RTSRate in TxDesc */
550 /* This prevent Tx initial rate of new-coming packets */
551 /* from being overwritten by retried packet rate.*/
552 if (ieee80211_is_data_qos(fc
)) {
554 RT_TRACE(rtlpriv
, COMP_SEND
, DBG_TRACE
,
555 "Enable RDG function.\n");
556 set_tx_desc_rdg_enable(pdesc
, 1);
557 set_tx_desc_htc(pdesc
, 1);
561 rtl_set_tx_report(ptcb_desc
, pdesc8
, hw
, tx_info
);
564 set_tx_desc_first_seg(pdesc
, (firstseg
? 1 : 0));
565 set_tx_desc_last_seg(pdesc
, (lastseg
? 1 : 0));
566 set_tx_desc_tx_buffer_size(pdesc
, (u16
)buf_len
);
567 set_tx_desc_tx_buffer_address(pdesc
, mapping
);
568 /* if (rtlpriv->dm.useramask) { */
570 set_tx_desc_rate_id(pdesc
, ptcb_desc
->ratr_index
);
571 set_tx_desc_macid(pdesc
, ptcb_desc
->mac_id
);
573 set_tx_desc_rate_id(pdesc
, 0xC + ptcb_desc
->ratr_index
);
574 set_tx_desc_macid(pdesc
, ptcb_desc
->mac_id
);
576 if (!ieee80211_is_data_qos(fc
)) {
577 set_tx_desc_hwseq_en(pdesc
, 1);
578 set_tx_desc_hwseq_sel(pdesc
, 0);
580 set_tx_desc_more_frag(pdesc
, (lastseg
? 0 : 1));
581 if (is_multicast_ether_addr(ieee80211_get_DA(hdr
)) ||
582 is_broadcast_ether_addr(ieee80211_get_DA(hdr
))) {
583 set_tx_desc_bmc(pdesc
, 1);
586 RT_TRACE(rtlpriv
, COMP_SEND
, DBG_TRACE
, "\n");
589 void rtl8723be_tx_fill_cmddesc(struct ieee80211_hw
*hw
, u8
*pdesc8
,
590 bool firstseg
, bool lastseg
,
593 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
594 struct rtl_pci
*rtlpci
= rtl_pcidev(rtl_pcipriv(hw
));
595 u8 fw_queue
= QSLT_BEACON
;
596 __le32
*pdesc
= (__le32
*)pdesc8
;
598 dma_addr_t mapping
= pci_map_single(rtlpci
->pdev
,
602 if (pci_dma_mapping_error(rtlpci
->pdev
, mapping
)) {
603 RT_TRACE(rtlpriv
, COMP_SEND
, DBG_TRACE
,
604 "DMA mapping error\n");
607 clear_pci_tx_desc_content(pdesc
, TX_DESC_SIZE
);
609 set_tx_desc_offset(pdesc
, USB_HWDESC_HEADER_LEN
);
611 set_tx_desc_tx_rate(pdesc
, DESC92C_RATE1M
);
613 set_tx_desc_seq(pdesc
, 0);
615 set_tx_desc_linip(pdesc
, 0);
617 set_tx_desc_queue_sel(pdesc
, fw_queue
);
619 set_tx_desc_first_seg(pdesc
, 1);
620 set_tx_desc_last_seg(pdesc
, 1);
622 set_tx_desc_tx_buffer_size(pdesc
, (u16
)(skb
->len
));
624 set_tx_desc_tx_buffer_address(pdesc
, mapping
);
626 set_tx_desc_rate_id(pdesc
, 0);
627 set_tx_desc_macid(pdesc
, 0);
629 set_tx_desc_own(pdesc
, 1);
631 set_tx_desc_pkt_size(pdesc
, (u16
)(skb
->len
));
633 set_tx_desc_first_seg(pdesc
, 1);
634 set_tx_desc_last_seg(pdesc
, 1);
636 set_tx_desc_use_rate(pdesc
, 1);
638 RT_PRINT_DATA(rtlpriv
, COMP_CMD
, DBG_LOUD
,
639 "H2C Tx Cmd Content\n", pdesc
, TX_DESC_SIZE
);
642 void rtl8723be_set_desc(struct ieee80211_hw
*hw
, u8
*pdesc8
,
643 bool istx
, u8 desc_name
, u8
*val
)
645 __le32
*pdesc
= (__le32
*)pdesc8
;
650 set_tx_desc_own(pdesc
, 1);
652 case HW_DESC_TX_NEXTDESC_ADDR
:
653 set_tx_desc_next_desc_address(pdesc
, *(u32
*)val
);
656 WARN_ONCE(true, "rtl8723be: ERR txdesc :%d not processed\n",
663 set_rx_desc_own(pdesc
, 1);
665 case HW_DESC_RXBUFF_ADDR
:
666 set_rx_desc_buff_addr(pdesc
, *(u32
*)val
);
668 case HW_DESC_RXPKT_LEN
:
669 set_rx_desc_pkt_len(pdesc
, *(u32
*)val
);
672 set_rx_desc_eor(pdesc
, 1);
675 WARN_ONCE(true, "rtl8723be: ERR rxdesc :%d not process\n",
682 u64
rtl8723be_get_desc(struct ieee80211_hw
*hw
,
683 u8
*pdesc8
, bool istx
, u8 desc_name
)
686 __le32
*pdesc
= (__le32
*)pdesc8
;
691 ret
= get_tx_desc_own(pdesc
);
693 case HW_DESC_TXBUFF_ADDR
:
694 ret
= get_tx_desc_tx_buffer_address(pdesc
);
697 WARN_ONCE(true, "rtl8723be: ERR txdesc :%d not process\n",
704 ret
= get_rx_desc_own(pdesc
);
706 case HW_DESC_RXPKT_LEN
:
707 ret
= get_rx_desc_pkt_len(pdesc
);
709 case HW_DESC_RXBUFF_ADDR
:
710 ret
= get_rx_desc_buff_addr(pdesc
);
713 WARN_ONCE(true, "rtl8723be: ERR rxdesc :%d not processed\n",
721 bool rtl8723be_is_tx_desc_closed(struct ieee80211_hw
*hw
,
722 u8 hw_queue
, u16 index
)
724 struct rtl_pci
*rtlpci
= rtl_pcidev(rtl_pcipriv(hw
));
725 struct rtl8192_tx_ring
*ring
= &rtlpci
->tx_ring
[hw_queue
];
726 u8
*entry
= (u8
*)(&ring
->desc
[ring
->idx
]);
727 u8 own
= (u8
)rtl8723be_get_desc(hw
, entry
, true, HW_DESC_OWN
);
729 /*beacon packet will only use the first
730 *descriptor defautly,and the own may not
731 *be cleared by the hardware
738 void rtl8723be_tx_polling(struct ieee80211_hw
*hw
, u8 hw_queue
)
740 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
741 if (hw_queue
== BEACON_QUEUE
) {
742 rtl_write_word(rtlpriv
, REG_PCIE_CTRL_REG
, BIT(4));
744 rtl_write_word(rtlpriv
, REG_PCIE_CTRL_REG
,
745 BIT(0) << (hw_queue
));