| .. | .. |
|---|
| 1 | | -/****************************************************************************** |
|---|
| 2 | | - * |
|---|
| 3 | | - * Copyright(c) 2009-2014 Realtek Corporation. |
|---|
| 4 | | - * |
|---|
| 5 | | - * This program is free software; you can redistribute it and/or modify it |
|---|
| 6 | | - * under the terms of version 2 of the GNU General Public License as |
|---|
| 7 | | - * published by the Free Software Foundation. |
|---|
| 8 | | - * |
|---|
| 9 | | - * This program is distributed in the hope that it will be useful, but WITHOUT |
|---|
| 10 | | - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|---|
| 11 | | - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
|---|
| 12 | | - * more details. |
|---|
| 13 | | - * |
|---|
| 14 | | - * The full GNU General Public License is included in this distribution in the |
|---|
| 15 | | - * file called LICENSE. |
|---|
| 16 | | - * |
|---|
| 17 | | - * Contact Information: |
|---|
| 18 | | - * wlanfae <wlanfae@realtek.com> |
|---|
| 19 | | - * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, |
|---|
| 20 | | - * Hsinchu 300, Taiwan. |
|---|
| 21 | | - * |
|---|
| 22 | | - * Larry Finger <Larry.Finger@lwfinger.net> |
|---|
| 23 | | - * |
|---|
| 24 | | - *****************************************************************************/ |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0 |
|---|
| 2 | +/* Copyright(c) 2009-2014 Realtek Corporation.*/ |
|---|
| 25 | 3 | |
|---|
| 26 | 4 | #include "../wifi.h" |
|---|
| 27 | 5 | #include "../pci.h" |
|---|
| .. | .. |
|---|
| 48 | 26 | } |
|---|
| 49 | 27 | |
|---|
| 50 | 28 | static void _rtl8723be_query_rxphystatus(struct ieee80211_hw *hw, |
|---|
| 51 | | - struct rtl_stats *pstatus, u8 *pdesc, |
|---|
| 29 | + struct rtl_stats *pstatus, |
|---|
| 30 | + __le32 *pdesc, |
|---|
| 52 | 31 | struct rx_fwinfo_8723be *p_drvinfo, |
|---|
| 53 | 32 | bool bpacket_match_bssid, |
|---|
| 54 | 33 | bool bpacket_toself, |
|---|
| .. | .. |
|---|
| 211 | 190 | static void _rtl8723be_translate_rx_signal_stuff(struct ieee80211_hw *hw, |
|---|
| 212 | 191 | struct sk_buff *skb, |
|---|
| 213 | 192 | struct rtl_stats *pstatus, |
|---|
| 214 | | - u8 *pdesc, |
|---|
| 193 | + __le32 *pdesc, |
|---|
| 215 | 194 | struct rx_fwinfo_8723be *p_drvinfo) |
|---|
| 216 | 195 | { |
|---|
| 217 | 196 | struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); |
|---|
| .. | .. |
|---|
| 264 | 243 | } |
|---|
| 265 | 244 | |
|---|
| 266 | 245 | static void _rtl8723be_insert_emcontent(struct rtl_tcb_desc *ptcb_desc, |
|---|
| 267 | | - u8 *virtualaddress) |
|---|
| 246 | + __le32 *virtualaddress) |
|---|
| 268 | 247 | { |
|---|
| 269 | 248 | u32 dwtmp = 0; |
|---|
| 270 | 249 | memset(virtualaddress, 0, 8); |
|---|
| 271 | 250 | |
|---|
| 272 | | - SET_EARLYMODE_PKTNUM(virtualaddress, ptcb_desc->empkt_num); |
|---|
| 251 | + set_earlymode_pktnum(virtualaddress, ptcb_desc->empkt_num); |
|---|
| 273 | 252 | if (ptcb_desc->empkt_num == 1) { |
|---|
| 274 | 253 | dwtmp = ptcb_desc->empkt_len[0]; |
|---|
| 275 | 254 | } else { |
|---|
| .. | .. |
|---|
| 277 | 256 | dwtmp += ((dwtmp % 4) ? (4 - dwtmp % 4) : 0) + 4; |
|---|
| 278 | 257 | dwtmp += ptcb_desc->empkt_len[1]; |
|---|
| 279 | 258 | } |
|---|
| 280 | | - SET_EARLYMODE_LEN0(virtualaddress, dwtmp); |
|---|
| 259 | + set_earlymode_len0(virtualaddress, dwtmp); |
|---|
| 281 | 260 | |
|---|
| 282 | 261 | if (ptcb_desc->empkt_num <= 3) { |
|---|
| 283 | 262 | dwtmp = ptcb_desc->empkt_len[2]; |
|---|
| .. | .. |
|---|
| 286 | 265 | dwtmp += ((dwtmp % 4) ? (4 - dwtmp % 4) : 0) + 4; |
|---|
| 287 | 266 | dwtmp += ptcb_desc->empkt_len[3]; |
|---|
| 288 | 267 | } |
|---|
| 289 | | - SET_EARLYMODE_LEN1(virtualaddress, dwtmp); |
|---|
| 268 | + set_earlymode_len1(virtualaddress, dwtmp); |
|---|
| 290 | 269 | if (ptcb_desc->empkt_num <= 5) { |
|---|
| 291 | 270 | dwtmp = ptcb_desc->empkt_len[4]; |
|---|
| 292 | 271 | } else { |
|---|
| .. | .. |
|---|
| 294 | 273 | dwtmp += ((dwtmp % 4) ? (4 - dwtmp % 4) : 0) + 4; |
|---|
| 295 | 274 | dwtmp += ptcb_desc->empkt_len[5]; |
|---|
| 296 | 275 | } |
|---|
| 297 | | - SET_EARLYMODE_LEN2_1(virtualaddress, dwtmp & 0xF); |
|---|
| 298 | | - SET_EARLYMODE_LEN2_2(virtualaddress, dwtmp >> 4); |
|---|
| 276 | + set_earlymode_len2_1(virtualaddress, dwtmp & 0xF); |
|---|
| 277 | + set_earlymode_len2_2(virtualaddress, dwtmp >> 4); |
|---|
| 299 | 278 | if (ptcb_desc->empkt_num <= 7) { |
|---|
| 300 | 279 | dwtmp = ptcb_desc->empkt_len[6]; |
|---|
| 301 | 280 | } else { |
|---|
| .. | .. |
|---|
| 303 | 282 | dwtmp += ((dwtmp % 4) ? (4 - dwtmp % 4) : 0) + 4; |
|---|
| 304 | 283 | dwtmp += ptcb_desc->empkt_len[7]; |
|---|
| 305 | 284 | } |
|---|
| 306 | | - SET_EARLYMODE_LEN3(virtualaddress, dwtmp); |
|---|
| 285 | + set_earlymode_len3(virtualaddress, dwtmp); |
|---|
| 307 | 286 | if (ptcb_desc->empkt_num <= 9) { |
|---|
| 308 | 287 | dwtmp = ptcb_desc->empkt_len[8]; |
|---|
| 309 | 288 | } else { |
|---|
| .. | .. |
|---|
| 311 | 290 | dwtmp += ((dwtmp % 4) ? (4 - dwtmp % 4) : 0) + 4; |
|---|
| 312 | 291 | dwtmp += ptcb_desc->empkt_len[9]; |
|---|
| 313 | 292 | } |
|---|
| 314 | | - SET_EARLYMODE_LEN4(virtualaddress, dwtmp); |
|---|
| 293 | + set_earlymode_len4(virtualaddress, dwtmp); |
|---|
| 315 | 294 | } |
|---|
| 316 | 295 | |
|---|
| 317 | 296 | bool rtl8723be_rx_query_desc(struct ieee80211_hw *hw, |
|---|
| 318 | 297 | struct rtl_stats *status, |
|---|
| 319 | 298 | struct ieee80211_rx_status *rx_status, |
|---|
| 320 | | - u8 *pdesc, struct sk_buff *skb) |
|---|
| 299 | + u8 *pdesc8, struct sk_buff *skb) |
|---|
| 321 | 300 | { |
|---|
| 322 | 301 | struct rtl_priv *rtlpriv = rtl_priv(hw); |
|---|
| 323 | 302 | struct rx_fwinfo_8723be *p_drvinfo; |
|---|
| 324 | 303 | struct ieee80211_hdr *hdr; |
|---|
| 304 | + u8 wake_match; |
|---|
| 305 | + __le32 *pdesc = (__le32 *)pdesc8; |
|---|
| 306 | + u32 phystatus = get_rx_desc_physt(pdesc); |
|---|
| 325 | 307 | |
|---|
| 326 | | - u32 phystatus = GET_RX_DESC_PHYST(pdesc); |
|---|
| 327 | | - |
|---|
| 328 | | - status->length = (u16)GET_RX_DESC_PKT_LEN(pdesc); |
|---|
| 329 | | - status->rx_drvinfo_size = (u8)GET_RX_DESC_DRV_INFO_SIZE(pdesc) * |
|---|
| 308 | + status->length = (u16)get_rx_desc_pkt_len(pdesc); |
|---|
| 309 | + status->rx_drvinfo_size = (u8)get_rx_desc_drv_info_size(pdesc) * |
|---|
| 330 | 310 | RX_DRV_INFO_SIZE_UNIT; |
|---|
| 331 | | - status->rx_bufshift = (u8)(GET_RX_DESC_SHIFT(pdesc) & 0x03); |
|---|
| 332 | | - status->icv = (u16) GET_RX_DESC_ICV(pdesc); |
|---|
| 333 | | - status->crc = (u16) GET_RX_DESC_CRC32(pdesc); |
|---|
| 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); |
|---|
| 334 | 314 | status->hwerror = (status->crc | status->icv); |
|---|
| 335 | | - status->decrypted = !GET_RX_DESC_SWDEC(pdesc); |
|---|
| 336 | | - status->rate = (u8)GET_RX_DESC_RXMCS(pdesc); |
|---|
| 337 | | - status->shortpreamble = (u16)GET_RX_DESC_SPLCP(pdesc); |
|---|
| 338 | | - status->isampdu = (bool)(GET_RX_DESC_PAGGR(pdesc) == 1); |
|---|
| 339 | | - status->isfirst_ampdu = (bool)(GET_RX_DESC_PAGGR(pdesc) == 1); |
|---|
| 340 | | - status->timestamp_low = GET_RX_DESC_TSFL(pdesc); |
|---|
| 341 | | - status->rx_is40Mhzpacket = (bool)GET_RX_DESC_BW(pdesc); |
|---|
| 342 | | - status->bandwidth = (u8)GET_RX_DESC_BW(pdesc); |
|---|
| 343 | | - status->macid = GET_RX_DESC_MACID(pdesc); |
|---|
| 344 | | - status->is_ht = (bool)GET_RX_DESC_RXHT(pdesc); |
|---|
| 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); |
|---|
| 345 | 325 | |
|---|
| 346 | 326 | status->is_cck = RX_HAL_IS_CCK_RATE(status->rate); |
|---|
| 347 | 327 | |
|---|
| 348 | | - if (GET_RX_STATUS_DESC_RPT_SEL(pdesc)) |
|---|
| 328 | + if (get_rx_status_desc_rpt_sel(pdesc)) |
|---|
| 349 | 329 | status->packet_report_type = C2H_PACKET; |
|---|
| 350 | 330 | else |
|---|
| 351 | 331 | status->packet_report_type = NORMAL_RX; |
|---|
| 352 | 332 | |
|---|
| 353 | 333 | |
|---|
| 354 | | - if (GET_RX_STATUS_DESC_MAGIC_MATCH(pdesc)) |
|---|
| 355 | | - status->wake_match = BIT(2); |
|---|
| 356 | | - else if (GET_RX_STATUS_DESC_MAGIC_MATCH(pdesc)) |
|---|
| 357 | | - status->wake_match = BIT(1); |
|---|
| 358 | | - else if (GET_RX_STATUS_DESC_UNICAST_MATCH(pdesc)) |
|---|
| 359 | | - status->wake_match = BIT(0); |
|---|
| 334 | + if (get_rx_status_desc_pattern_match(pdesc)) |
|---|
| 335 | + wake_match = BIT(2); |
|---|
| 336 | + else if (get_rx_status_desc_magic_match(pdesc)) |
|---|
| 337 | + wake_match = BIT(1); |
|---|
| 338 | + else if (get_rx_status_desc_unicast_match(pdesc)) |
|---|
| 339 | + wake_match = BIT(0); |
|---|
| 360 | 340 | else |
|---|
| 361 | | - status->wake_match = 0; |
|---|
| 362 | | - if (status->wake_match) |
|---|
| 363 | | - RT_TRACE(rtlpriv, COMP_RXDESC, DBG_LOUD, |
|---|
| 364 | | - "GGGGGGGGGGGGGet Wakeup Packet!! WakeMatch=%d\n", |
|---|
| 365 | | - status->wake_match); |
|---|
| 341 | + wake_match = 0; |
|---|
| 342 | + if (wake_match) |
|---|
| 343 | + rtl_dbg(rtlpriv, COMP_RXDESC, DBG_LOUD, |
|---|
| 344 | + "GGGGGGGGGGGGGet Wakeup Packet!! WakeMatch=%d\n", |
|---|
| 345 | + wake_match); |
|---|
| 366 | 346 | rx_status->freq = hw->conf.chandef.chan->center_freq; |
|---|
| 367 | 347 | rx_status->band = hw->conf.chandef.chan->band; |
|---|
| 368 | 348 | |
|---|
| .. | .. |
|---|
| 372 | 352 | if (status->crc) |
|---|
| 373 | 353 | rx_status->flag |= RX_FLAG_FAILED_FCS_CRC; |
|---|
| 374 | 354 | |
|---|
| 375 | | - if (status->rx_is40Mhzpacket) |
|---|
| 355 | + if (status->rx_is40mhzpacket) |
|---|
| 376 | 356 | rx_status->bw = RATE_INFO_BW_40; |
|---|
| 377 | 357 | |
|---|
| 378 | 358 | if (status->is_ht) |
|---|
| .. | .. |
|---|
| 414 | 394 | rx_status->signal = status->recvsignalpower + 10; |
|---|
| 415 | 395 | if (status->packet_report_type == TX_REPORT2) { |
|---|
| 416 | 396 | status->macid_valid_entry[0] = |
|---|
| 417 | | - GET_RX_RPT2_DESC_MACID_VALID_1(pdesc); |
|---|
| 397 | + get_rx_rpt2_desc_macid_valid_1(pdesc); |
|---|
| 418 | 398 | status->macid_valid_entry[1] = |
|---|
| 419 | | - GET_RX_RPT2_DESC_MACID_VALID_2(pdesc); |
|---|
| 399 | + get_rx_rpt2_desc_macid_valid_2(pdesc); |
|---|
| 420 | 400 | } |
|---|
| 421 | 401 | return true; |
|---|
| 422 | 402 | } |
|---|
| 423 | 403 | |
|---|
| 424 | 404 | void rtl8723be_tx_fill_desc(struct ieee80211_hw *hw, |
|---|
| 425 | | - struct ieee80211_hdr *hdr, u8 *pdesc_tx, |
|---|
| 405 | + struct ieee80211_hdr *hdr, u8 *pdesc8, |
|---|
| 426 | 406 | u8 *txbd, struct ieee80211_tx_info *info, |
|---|
| 427 | 407 | struct ieee80211_sta *sta, struct sk_buff *skb, |
|---|
| 428 | 408 | u8 hw_queue, struct rtl_tcb_desc *ptcb_desc) |
|---|
| .. | .. |
|---|
| 432 | 412 | struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); |
|---|
| 433 | 413 | struct rtl_hal *rtlhal = rtl_hal(rtlpriv); |
|---|
| 434 | 414 | struct rtlwifi_tx_info *tx_info = rtl_tx_skb_cb_info(skb); |
|---|
| 435 | | - u8 *pdesc = (u8 *)pdesc_tx; |
|---|
| 415 | + __le32 *pdesc = (__le32 *)pdesc8; |
|---|
| 436 | 416 | u16 seq_number; |
|---|
| 437 | 417 | __le16 fc = hdr->frame_control; |
|---|
| 438 | 418 | unsigned int buf_len = 0; |
|---|
| .. | .. |
|---|
| 462 | 442 | memset(skb->data, 0, EM_HDR_LEN); |
|---|
| 463 | 443 | } |
|---|
| 464 | 444 | buf_len = skb->len; |
|---|
| 465 | | - mapping = pci_map_single(rtlpci->pdev, skb->data, skb->len, |
|---|
| 466 | | - PCI_DMA_TODEVICE); |
|---|
| 467 | | - if (pci_dma_mapping_error(rtlpci->pdev, mapping)) { |
|---|
| 468 | | - RT_TRACE(rtlpriv, COMP_SEND, DBG_TRACE, "DMA mapping error\n"); |
|---|
| 445 | + mapping = dma_map_single(&rtlpci->pdev->dev, skb->data, skb->len, |
|---|
| 446 | + DMA_TO_DEVICE); |
|---|
| 447 | + if (dma_mapping_error(&rtlpci->pdev->dev, mapping)) { |
|---|
| 448 | + rtl_dbg(rtlpriv, COMP_SEND, DBG_TRACE, "DMA mapping error\n"); |
|---|
| 469 | 449 | return; |
|---|
| 470 | 450 | } |
|---|
| 471 | | - CLEAR_PCI_TX_DESC_CONTENT(pdesc, sizeof(struct tx_desc_8723be)); |
|---|
| 451 | + clear_pci_tx_desc_content(pdesc, sizeof(struct tx_desc_8723be)); |
|---|
| 472 | 452 | if (ieee80211_is_nullfunc(fc) || ieee80211_is_ctl(fc)) { |
|---|
| 473 | 453 | firstseg = true; |
|---|
| 474 | 454 | lastseg = true; |
|---|
| 475 | 455 | } |
|---|
| 476 | 456 | if (firstseg) { |
|---|
| 477 | 457 | if (rtlhal->earlymode_enable) { |
|---|
| 478 | | - SET_TX_DESC_PKT_OFFSET(pdesc, 1); |
|---|
| 479 | | - SET_TX_DESC_OFFSET(pdesc, USB_HWDESC_HEADER_LEN + |
|---|
| 458 | + set_tx_desc_pkt_offset(pdesc, 1); |
|---|
| 459 | + set_tx_desc_offset(pdesc, USB_HWDESC_HEADER_LEN + |
|---|
| 480 | 460 | EM_HDR_LEN); |
|---|
| 481 | 461 | if (ptcb_desc->empkt_num) { |
|---|
| 482 | | - RT_TRACE(rtlpriv, COMP_SEND, DBG_TRACE, |
|---|
| 483 | | - "Insert 8 byte.pTcb->EMPktNum:%d\n", |
|---|
| 484 | | - ptcb_desc->empkt_num); |
|---|
| 462 | + rtl_dbg(rtlpriv, COMP_SEND, DBG_TRACE, |
|---|
| 463 | + "Insert 8 byte.pTcb->EMPktNum:%d\n", |
|---|
| 464 | + ptcb_desc->empkt_num); |
|---|
| 485 | 465 | _rtl8723be_insert_emcontent(ptcb_desc, |
|---|
| 486 | | - (u8 *)(skb->data)); |
|---|
| 466 | + (__le32 *)(skb->data)); |
|---|
| 487 | 467 | } |
|---|
| 488 | 468 | } else { |
|---|
| 489 | | - SET_TX_DESC_OFFSET(pdesc, USB_HWDESC_HEADER_LEN); |
|---|
| 469 | + set_tx_desc_offset(pdesc, USB_HWDESC_HEADER_LEN); |
|---|
| 490 | 470 | } |
|---|
| 491 | 471 | |
|---|
| 492 | 472 | |
|---|
| 493 | 473 | /* ptcb_desc->use_driver_rate = true; */ |
|---|
| 494 | | - SET_TX_DESC_TX_RATE(pdesc, ptcb_desc->hw_rate); |
|---|
| 474 | + set_tx_desc_tx_rate(pdesc, ptcb_desc->hw_rate); |
|---|
| 495 | 475 | if (ptcb_desc->hw_rate > DESC92C_RATEMCS0) |
|---|
| 496 | 476 | short_gi = (ptcb_desc->use_shortgi) ? 1 : 0; |
|---|
| 497 | 477 | else |
|---|
| 498 | 478 | short_gi = (ptcb_desc->use_shortpreamble) ? 1 : 0; |
|---|
| 499 | 479 | |
|---|
| 500 | | - SET_TX_DESC_DATA_SHORTGI(pdesc, short_gi); |
|---|
| 480 | + set_tx_desc_data_shortgi(pdesc, short_gi); |
|---|
| 501 | 481 | |
|---|
| 502 | 482 | if (info->flags & IEEE80211_TX_CTL_AMPDU) { |
|---|
| 503 | | - SET_TX_DESC_AGG_ENABLE(pdesc, 1); |
|---|
| 504 | | - SET_TX_DESC_MAX_AGG_NUM(pdesc, 0x14); |
|---|
| 483 | + set_tx_desc_agg_enable(pdesc, 1); |
|---|
| 484 | + set_tx_desc_max_agg_num(pdesc, 0x14); |
|---|
| 505 | 485 | } |
|---|
| 506 | | - SET_TX_DESC_SEQ(pdesc, seq_number); |
|---|
| 507 | | - SET_TX_DESC_RTS_ENABLE(pdesc, ((ptcb_desc->rts_enable && |
|---|
| 486 | + set_tx_desc_seq(pdesc, seq_number); |
|---|
| 487 | + set_tx_desc_rts_enable(pdesc, ((ptcb_desc->rts_enable && |
|---|
| 508 | 488 | !ptcb_desc->cts_enable) ? |
|---|
| 509 | 489 | 1 : 0)); |
|---|
| 510 | | - SET_TX_DESC_HW_RTS_ENABLE(pdesc, 0); |
|---|
| 511 | | - SET_TX_DESC_CTS2SELF(pdesc, ((ptcb_desc->cts_enable) ? |
|---|
| 490 | + set_tx_desc_hw_rts_enable(pdesc, 0); |
|---|
| 491 | + set_tx_desc_cts2self(pdesc, ((ptcb_desc->cts_enable) ? |
|---|
| 512 | 492 | 1 : 0)); |
|---|
| 513 | 493 | |
|---|
| 514 | | - SET_TX_DESC_RTS_RATE(pdesc, ptcb_desc->rts_rate); |
|---|
| 494 | + set_tx_desc_rts_rate(pdesc, ptcb_desc->rts_rate); |
|---|
| 515 | 495 | |
|---|
| 516 | | - SET_TX_DESC_RTS_SC(pdesc, ptcb_desc->rts_sc); |
|---|
| 517 | | - SET_TX_DESC_RTS_SHORT(pdesc, |
|---|
| 496 | + set_tx_desc_rts_sc(pdesc, ptcb_desc->rts_sc); |
|---|
| 497 | + set_tx_desc_rts_short(pdesc, |
|---|
| 518 | 498 | ((ptcb_desc->rts_rate <= DESC92C_RATE54M) ? |
|---|
| 519 | 499 | (ptcb_desc->rts_use_shortpreamble ? 1 : 0) : |
|---|
| 520 | 500 | (ptcb_desc->rts_use_shortgi ? 1 : 0))); |
|---|
| 521 | 501 | |
|---|
| 522 | 502 | if (ptcb_desc->tx_enable_sw_calc_duration) |
|---|
| 523 | | - SET_TX_DESC_NAV_USE_HDR(pdesc, 1); |
|---|
| 503 | + set_tx_desc_nav_use_hdr(pdesc, 1); |
|---|
| 524 | 504 | |
|---|
| 525 | 505 | if (bw_40) { |
|---|
| 526 | 506 | if (ptcb_desc->packet_bw == HT_CHANNEL_WIDTH_20_40) { |
|---|
| 527 | | - SET_TX_DESC_DATA_BW(pdesc, 1); |
|---|
| 528 | | - SET_TX_DESC_TX_SUB_CARRIER(pdesc, 3); |
|---|
| 507 | + set_tx_desc_data_bw(pdesc, 1); |
|---|
| 508 | + set_tx_desc_tx_sub_carrier(pdesc, 3); |
|---|
| 529 | 509 | } else { |
|---|
| 530 | | - SET_TX_DESC_DATA_BW(pdesc, 0); |
|---|
| 531 | | - SET_TX_DESC_TX_SUB_CARRIER(pdesc, mac->cur_40_prime_sc); |
|---|
| 510 | + set_tx_desc_data_bw(pdesc, 0); |
|---|
| 511 | + set_tx_desc_tx_sub_carrier(pdesc, mac->cur_40_prime_sc); |
|---|
| 532 | 512 | } |
|---|
| 533 | 513 | } else { |
|---|
| 534 | | - SET_TX_DESC_DATA_BW(pdesc, 0); |
|---|
| 535 | | - SET_TX_DESC_TX_SUB_CARRIER(pdesc, 0); |
|---|
| 514 | + set_tx_desc_data_bw(pdesc, 0); |
|---|
| 515 | + set_tx_desc_tx_sub_carrier(pdesc, 0); |
|---|
| 536 | 516 | } |
|---|
| 537 | 517 | |
|---|
| 538 | | - SET_TX_DESC_LINIP(pdesc, 0); |
|---|
| 539 | | - SET_TX_DESC_PKT_SIZE(pdesc, (u16) skb_len); |
|---|
| 518 | + set_tx_desc_linip(pdesc, 0); |
|---|
| 519 | + set_tx_desc_pkt_size(pdesc, (u16)skb_len); |
|---|
| 540 | 520 | if (sta) { |
|---|
| 541 | 521 | u8 ampdu_density = sta->ht_cap.ampdu_density; |
|---|
| 542 | | - SET_TX_DESC_AMPDU_DENSITY(pdesc, ampdu_density); |
|---|
| 522 | + set_tx_desc_ampdu_density(pdesc, ampdu_density); |
|---|
| 543 | 523 | } |
|---|
| 544 | 524 | if (info->control.hw_key) { |
|---|
| 545 | 525 | struct ieee80211_key_conf *keyconf = |
|---|
| .. | .. |
|---|
| 548 | 528 | case WLAN_CIPHER_SUITE_WEP40: |
|---|
| 549 | 529 | case WLAN_CIPHER_SUITE_WEP104: |
|---|
| 550 | 530 | case WLAN_CIPHER_SUITE_TKIP: |
|---|
| 551 | | - SET_TX_DESC_SEC_TYPE(pdesc, 0x1); |
|---|
| 531 | + set_tx_desc_sec_type(pdesc, 0x1); |
|---|
| 552 | 532 | break; |
|---|
| 553 | 533 | case WLAN_CIPHER_SUITE_CCMP: |
|---|
| 554 | | - SET_TX_DESC_SEC_TYPE(pdesc, 0x3); |
|---|
| 534 | + set_tx_desc_sec_type(pdesc, 0x3); |
|---|
| 555 | 535 | break; |
|---|
| 556 | 536 | default: |
|---|
| 557 | | - SET_TX_DESC_SEC_TYPE(pdesc, 0x0); |
|---|
| 537 | + set_tx_desc_sec_type(pdesc, 0x0); |
|---|
| 558 | 538 | break; |
|---|
| 559 | 539 | } |
|---|
| 560 | 540 | } |
|---|
| 561 | 541 | |
|---|
| 562 | | - SET_TX_DESC_QUEUE_SEL(pdesc, fw_qsel); |
|---|
| 563 | | - SET_TX_DESC_DATA_RATE_FB_LIMIT(pdesc, 0x1F); |
|---|
| 564 | | - SET_TX_DESC_RTS_RATE_FB_LIMIT(pdesc, 0xF); |
|---|
| 565 | | - SET_TX_DESC_DISABLE_FB(pdesc, ptcb_desc->disable_ratefallback ? |
|---|
| 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 ? |
|---|
| 566 | 546 | 1 : 0); |
|---|
| 567 | | - SET_TX_DESC_USE_RATE(pdesc, ptcb_desc->use_driver_rate ? 1 : 0); |
|---|
| 547 | + set_tx_desc_use_rate(pdesc, ptcb_desc->use_driver_rate ? 1 : 0); |
|---|
| 568 | 548 | |
|---|
| 569 | 549 | /* Set TxRate and RTSRate in TxDesc */ |
|---|
| 570 | 550 | /* This prevent Tx initial rate of new-coming packets */ |
|---|
| 571 | 551 | /* from being overwritten by retried packet rate.*/ |
|---|
| 572 | 552 | if (ieee80211_is_data_qos(fc)) { |
|---|
| 573 | 553 | if (mac->rdg_en) { |
|---|
| 574 | | - RT_TRACE(rtlpriv, COMP_SEND, DBG_TRACE, |
|---|
| 575 | | - "Enable RDG function.\n"); |
|---|
| 576 | | - SET_TX_DESC_RDG_ENABLE(pdesc, 1); |
|---|
| 577 | | - SET_TX_DESC_HTC(pdesc, 1); |
|---|
| 554 | + rtl_dbg(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); |
|---|
| 578 | 558 | } |
|---|
| 579 | 559 | } |
|---|
| 580 | 560 | /* tx report */ |
|---|
| 581 | | - rtl_set_tx_report(ptcb_desc, pdesc, hw, tx_info); |
|---|
| 561 | + rtl_set_tx_report(ptcb_desc, pdesc8, hw, tx_info); |
|---|
| 582 | 562 | } |
|---|
| 583 | 563 | |
|---|
| 584 | | - SET_TX_DESC_FIRST_SEG(pdesc, (firstseg ? 1 : 0)); |
|---|
| 585 | | - SET_TX_DESC_LAST_SEG(pdesc, (lastseg ? 1 : 0)); |
|---|
| 586 | | - SET_TX_DESC_TX_BUFFER_SIZE(pdesc, (u16) buf_len); |
|---|
| 587 | | - SET_TX_DESC_TX_BUFFER_ADDRESS(pdesc, mapping); |
|---|
| 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); |
|---|
| 588 | 568 | /* if (rtlpriv->dm.useramask) { */ |
|---|
| 589 | 569 | if (1) { |
|---|
| 590 | | - SET_TX_DESC_RATE_ID(pdesc, ptcb_desc->ratr_index); |
|---|
| 591 | | - SET_TX_DESC_MACID(pdesc, ptcb_desc->mac_id); |
|---|
| 570 | + set_tx_desc_rate_id(pdesc, ptcb_desc->ratr_index); |
|---|
| 571 | + set_tx_desc_macid(pdesc, ptcb_desc->mac_id); |
|---|
| 592 | 572 | } else { |
|---|
| 593 | | - SET_TX_DESC_RATE_ID(pdesc, 0xC + ptcb_desc->ratr_index); |
|---|
| 594 | | - 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); |
|---|
| 595 | 575 | } |
|---|
| 596 | 576 | if (!ieee80211_is_data_qos(fc)) { |
|---|
| 597 | | - SET_TX_DESC_HWSEQ_EN(pdesc, 1); |
|---|
| 598 | | - SET_TX_DESC_HWSEQ_SEL(pdesc, 0); |
|---|
| 577 | + set_tx_desc_hwseq_en(pdesc, 1); |
|---|
| 578 | + set_tx_desc_hwseq_sel(pdesc, 0); |
|---|
| 599 | 579 | } |
|---|
| 600 | | - SET_TX_DESC_MORE_FRAG(pdesc, (lastseg ? 0 : 1)); |
|---|
| 580 | + set_tx_desc_more_frag(pdesc, (lastseg ? 0 : 1)); |
|---|
| 601 | 581 | if (is_multicast_ether_addr(ieee80211_get_DA(hdr)) || |
|---|
| 602 | 582 | is_broadcast_ether_addr(ieee80211_get_DA(hdr))) { |
|---|
| 603 | | - SET_TX_DESC_BMC(pdesc, 1); |
|---|
| 583 | + set_tx_desc_bmc(pdesc, 1); |
|---|
| 604 | 584 | } |
|---|
| 605 | 585 | |
|---|
| 606 | | - RT_TRACE(rtlpriv, COMP_SEND, DBG_TRACE, "\n"); |
|---|
| 586 | + rtl_dbg(rtlpriv, COMP_SEND, DBG_TRACE, "\n"); |
|---|
| 607 | 587 | } |
|---|
| 608 | 588 | |
|---|
| 609 | | -void rtl8723be_tx_fill_cmddesc(struct ieee80211_hw *hw, u8 *pdesc, |
|---|
| 589 | +void rtl8723be_tx_fill_cmddesc(struct ieee80211_hw *hw, u8 *pdesc8, |
|---|
| 610 | 590 | bool firstseg, bool lastseg, |
|---|
| 611 | 591 | struct sk_buff *skb) |
|---|
| 612 | 592 | { |
|---|
| 613 | 593 | struct rtl_priv *rtlpriv = rtl_priv(hw); |
|---|
| 614 | 594 | struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); |
|---|
| 615 | 595 | u8 fw_queue = QSLT_BEACON; |
|---|
| 596 | + __le32 *pdesc = (__le32 *)pdesc8; |
|---|
| 616 | 597 | |
|---|
| 617 | | - dma_addr_t mapping = pci_map_single(rtlpci->pdev, |
|---|
| 618 | | - skb->data, skb->len, |
|---|
| 619 | | - PCI_DMA_TODEVICE); |
|---|
| 598 | + dma_addr_t mapping = dma_map_single(&rtlpci->pdev->dev, skb->data, |
|---|
| 599 | + skb->len, DMA_TO_DEVICE); |
|---|
| 620 | 600 | |
|---|
| 621 | | - if (pci_dma_mapping_error(rtlpci->pdev, mapping)) { |
|---|
| 622 | | - RT_TRACE(rtlpriv, COMP_SEND, DBG_TRACE, |
|---|
| 623 | | - "DMA mapping error\n"); |
|---|
| 601 | + if (dma_mapping_error(&rtlpci->pdev->dev, mapping)) { |
|---|
| 602 | + rtl_dbg(rtlpriv, COMP_SEND, DBG_TRACE, |
|---|
| 603 | + "DMA mapping error\n"); |
|---|
| 624 | 604 | return; |
|---|
| 625 | 605 | } |
|---|
| 626 | | - CLEAR_PCI_TX_DESC_CONTENT(pdesc, TX_DESC_SIZE); |
|---|
| 606 | + clear_pci_tx_desc_content(pdesc, TX_DESC_SIZE); |
|---|
| 627 | 607 | |
|---|
| 628 | | - SET_TX_DESC_OFFSET(pdesc, USB_HWDESC_HEADER_LEN); |
|---|
| 608 | + set_tx_desc_offset(pdesc, USB_HWDESC_HEADER_LEN); |
|---|
| 629 | 609 | |
|---|
| 630 | | - SET_TX_DESC_TX_RATE(pdesc, DESC92C_RATE1M); |
|---|
| 610 | + set_tx_desc_tx_rate(pdesc, DESC92C_RATE1M); |
|---|
| 631 | 611 | |
|---|
| 632 | | - SET_TX_DESC_SEQ(pdesc, 0); |
|---|
| 612 | + set_tx_desc_seq(pdesc, 0); |
|---|
| 633 | 613 | |
|---|
| 634 | | - SET_TX_DESC_LINIP(pdesc, 0); |
|---|
| 614 | + set_tx_desc_linip(pdesc, 0); |
|---|
| 635 | 615 | |
|---|
| 636 | | - SET_TX_DESC_QUEUE_SEL(pdesc, fw_queue); |
|---|
| 616 | + set_tx_desc_queue_sel(pdesc, fw_queue); |
|---|
| 637 | 617 | |
|---|
| 638 | | - SET_TX_DESC_FIRST_SEG(pdesc, 1); |
|---|
| 639 | | - SET_TX_DESC_LAST_SEG(pdesc, 1); |
|---|
| 618 | + set_tx_desc_first_seg(pdesc, 1); |
|---|
| 619 | + set_tx_desc_last_seg(pdesc, 1); |
|---|
| 640 | 620 | |
|---|
| 641 | | - SET_TX_DESC_TX_BUFFER_SIZE(pdesc, (u16)(skb->len)); |
|---|
| 621 | + set_tx_desc_tx_buffer_size(pdesc, (u16)(skb->len)); |
|---|
| 642 | 622 | |
|---|
| 643 | | - SET_TX_DESC_TX_BUFFER_ADDRESS(pdesc, mapping); |
|---|
| 623 | + set_tx_desc_tx_buffer_address(pdesc, mapping); |
|---|
| 644 | 624 | |
|---|
| 645 | | - SET_TX_DESC_RATE_ID(pdesc, 0); |
|---|
| 646 | | - SET_TX_DESC_MACID(pdesc, 0); |
|---|
| 625 | + set_tx_desc_rate_id(pdesc, 0); |
|---|
| 626 | + set_tx_desc_macid(pdesc, 0); |
|---|
| 647 | 627 | |
|---|
| 648 | | - SET_TX_DESC_OWN(pdesc, 1); |
|---|
| 628 | + set_tx_desc_own(pdesc, 1); |
|---|
| 649 | 629 | |
|---|
| 650 | | - SET_TX_DESC_PKT_SIZE((u8 *)pdesc, (u16)(skb->len)); |
|---|
| 630 | + set_tx_desc_pkt_size(pdesc, (u16)(skb->len)); |
|---|
| 651 | 631 | |
|---|
| 652 | | - SET_TX_DESC_FIRST_SEG(pdesc, 1); |
|---|
| 653 | | - SET_TX_DESC_LAST_SEG(pdesc, 1); |
|---|
| 632 | + set_tx_desc_first_seg(pdesc, 1); |
|---|
| 633 | + set_tx_desc_last_seg(pdesc, 1); |
|---|
| 654 | 634 | |
|---|
| 655 | | - SET_TX_DESC_USE_RATE(pdesc, 1); |
|---|
| 635 | + set_tx_desc_use_rate(pdesc, 1); |
|---|
| 656 | 636 | |
|---|
| 657 | 637 | RT_PRINT_DATA(rtlpriv, COMP_CMD, DBG_LOUD, |
|---|
| 658 | 638 | "H2C Tx Cmd Content\n", pdesc, TX_DESC_SIZE); |
|---|
| 659 | 639 | } |
|---|
| 660 | 640 | |
|---|
| 661 | | -void rtl8723be_set_desc(struct ieee80211_hw *hw, u8 *pdesc, |
|---|
| 641 | +void rtl8723be_set_desc(struct ieee80211_hw *hw, u8 *pdesc8, |
|---|
| 662 | 642 | bool istx, u8 desc_name, u8 *val) |
|---|
| 663 | 643 | { |
|---|
| 644 | + __le32 *pdesc = (__le32 *)pdesc8; |
|---|
| 645 | + |
|---|
| 664 | 646 | if (istx) { |
|---|
| 665 | 647 | switch (desc_name) { |
|---|
| 666 | 648 | case HW_DESC_OWN: |
|---|
| 667 | | - SET_TX_DESC_OWN(pdesc, 1); |
|---|
| 649 | + set_tx_desc_own(pdesc, 1); |
|---|
| 668 | 650 | break; |
|---|
| 669 | 651 | case HW_DESC_TX_NEXTDESC_ADDR: |
|---|
| 670 | | - SET_TX_DESC_NEXT_DESC_ADDRESS(pdesc, *(u32 *)val); |
|---|
| 652 | + set_tx_desc_next_desc_address(pdesc, *(u32 *)val); |
|---|
| 671 | 653 | break; |
|---|
| 672 | 654 | default: |
|---|
| 673 | 655 | WARN_ONCE(true, "rtl8723be: ERR txdesc :%d not processed\n", |
|---|
| .. | .. |
|---|
| 677 | 659 | } else { |
|---|
| 678 | 660 | switch (desc_name) { |
|---|
| 679 | 661 | case HW_DESC_RXOWN: |
|---|
| 680 | | - SET_RX_DESC_OWN(pdesc, 1); |
|---|
| 662 | + set_rx_desc_own(pdesc, 1); |
|---|
| 681 | 663 | break; |
|---|
| 682 | 664 | case HW_DESC_RXBUFF_ADDR: |
|---|
| 683 | | - SET_RX_DESC_BUFF_ADDR(pdesc, *(u32 *)val); |
|---|
| 665 | + set_rx_desc_buff_addr(pdesc, *(u32 *)val); |
|---|
| 684 | 666 | break; |
|---|
| 685 | 667 | case HW_DESC_RXPKT_LEN: |
|---|
| 686 | | - SET_RX_DESC_PKT_LEN(pdesc, *(u32 *)val); |
|---|
| 668 | + set_rx_desc_pkt_len(pdesc, *(u32 *)val); |
|---|
| 687 | 669 | break; |
|---|
| 688 | 670 | case HW_DESC_RXERO: |
|---|
| 689 | | - SET_RX_DESC_EOR(pdesc, 1); |
|---|
| 671 | + set_rx_desc_eor(pdesc, 1); |
|---|
| 690 | 672 | break; |
|---|
| 691 | 673 | default: |
|---|
| 692 | 674 | WARN_ONCE(true, "rtl8723be: ERR rxdesc :%d not process\n", |
|---|
| .. | .. |
|---|
| 697 | 679 | } |
|---|
| 698 | 680 | |
|---|
| 699 | 681 | u64 rtl8723be_get_desc(struct ieee80211_hw *hw, |
|---|
| 700 | | - u8 *pdesc, bool istx, u8 desc_name) |
|---|
| 682 | + u8 *pdesc8, bool istx, u8 desc_name) |
|---|
| 701 | 683 | { |
|---|
| 702 | 684 | u32 ret = 0; |
|---|
| 685 | + __le32 *pdesc = (__le32 *)pdesc8; |
|---|
| 703 | 686 | |
|---|
| 704 | 687 | if (istx) { |
|---|
| 705 | 688 | switch (desc_name) { |
|---|
| 706 | 689 | case HW_DESC_OWN: |
|---|
| 707 | | - ret = GET_TX_DESC_OWN(pdesc); |
|---|
| 690 | + ret = get_tx_desc_own(pdesc); |
|---|
| 708 | 691 | break; |
|---|
| 709 | 692 | case HW_DESC_TXBUFF_ADDR: |
|---|
| 710 | | - ret = GET_TX_DESC_TX_BUFFER_ADDRESS(pdesc); |
|---|
| 693 | + ret = get_tx_desc_tx_buffer_address(pdesc); |
|---|
| 711 | 694 | break; |
|---|
| 712 | 695 | default: |
|---|
| 713 | 696 | WARN_ONCE(true, "rtl8723be: ERR txdesc :%d not process\n", |
|---|
| .. | .. |
|---|
| 717 | 700 | } else { |
|---|
| 718 | 701 | switch (desc_name) { |
|---|
| 719 | 702 | case HW_DESC_OWN: |
|---|
| 720 | | - ret = GET_RX_DESC_OWN(pdesc); |
|---|
| 703 | + ret = get_rx_desc_own(pdesc); |
|---|
| 721 | 704 | break; |
|---|
| 722 | 705 | case HW_DESC_RXPKT_LEN: |
|---|
| 723 | | - ret = GET_RX_DESC_PKT_LEN(pdesc); |
|---|
| 706 | + ret = get_rx_desc_pkt_len(pdesc); |
|---|
| 724 | 707 | break; |
|---|
| 725 | 708 | case HW_DESC_RXBUFF_ADDR: |
|---|
| 726 | | - ret = GET_RX_DESC_BUFF_ADDR(pdesc); |
|---|
| 709 | + ret = get_rx_desc_buff_addr(pdesc); |
|---|
| 727 | 710 | break; |
|---|
| 728 | 711 | default: |
|---|
| 729 | 712 | WARN_ONCE(true, "rtl8723be: ERR rxdesc :%d not processed\n", |
|---|