Skip to content

Commit

Permalink
rtl8192ee: Fix builds through kernel 6.1
Browse files Browse the repository at this point in the history
Signed-off-by: Larry Finger <[email protected]>
  • Loading branch information
lwfinger committed Oct 17, 2022
1 parent 951b543 commit 8af0b61
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 22 deletions.
34 changes: 17 additions & 17 deletions hal/rtl8192e/pci/pci_ops_linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ static int rtl8192ee_init_rx_ring(_adapter *padapter)
/* rx_queue_idx 1:RX_CMD_QUEUE */
for (rx_queue_idx = 0; rx_queue_idx < 1/*RX_MAX_QUEUE*/; rx_queue_idx++) {
precvpriv->rx_ring[rx_queue_idx].desc =
pci_alloc_consistent(pdev,
dma_alloc_coherent(&pdev->dev,
sizeof(*precvpriv->rx_ring[rx_queue_idx].desc) * precvpriv->rxringcount,
&precvpriv->rx_ring[rx_queue_idx].dma);
&precvpriv->rx_ring[rx_queue_idx].dma, GFP_KERNEL);

if (!precvpriv->rx_ring[rx_queue_idx].desc
|| (unsigned long)precvpriv->rx_ring[rx_queue_idx].desc & 0xFF) {
Expand All @@ -76,9 +76,9 @@ static int rtl8192ee_init_rx_ring(_adapter *padapter)
mapping = (dma_addr_t *)skb->cb;

/* just set skb->cb to mapping addr for pci_unmap_single use */
*mapping = pci_map_single(pdev, skb_tail_pointer(skb),
*mapping = dma_map_single(&pdev->dev, skb_tail_pointer(skb),
precvpriv->rxbuffersize,
PCI_DMA_FROMDEVICE);
DMA_FROM_DEVICE);

/* Reset FS, LS, Total len */
SET_RX_BUFFER_DESC_LS_92E(rx_desc, 0);
Expand Down Expand Up @@ -112,14 +112,14 @@ static void rtl8192ee_free_rx_ring(_adapter *padapter)
if (!skb)
continue;

pci_unmap_single(pdev,
dma_unmap_single(&pdev->dev,
*((dma_addr_t *) skb->cb),
precvpriv->rxbuffersize,
PCI_DMA_FROMDEVICE);
DMA_FROM_DEVICE);
kfree_skb(skb);
}

pci_free_consistent(pdev,
dma_free_coherent(&pdev->dev,
sizeof(*precvpriv->rx_ring[rx_queue_idx].desc) *
precvpriv->rxringcount,
precvpriv->rx_ring[rx_queue_idx].desc,
Expand All @@ -142,7 +142,7 @@ static int rtl8192ee_init_tx_ring(_adapter *padapter, unsigned int prio, unsigne


RTW_INFO("%s entries num:%d\n", __func__, entries);
ring = pci_alloc_consistent(pdev, sizeof(*ring) * entries, &dma);
ring = dma_alloc_coherent(&pdev->dev, sizeof(*ring) * entries, &dma, GFP_KERNEL);
if (!ring || (unsigned long)ring & 0xFF) {
RTW_INFO("Cannot allocate TX ring (prio = %d)\n", prio);
return _FAIL;
Expand Down Expand Up @@ -181,15 +181,15 @@ static void rtl8192ee_free_tx_ring(_adapter *padapter, unsigned int prio)

pxmitbuf = rtl8192ee_dequeue_xmitbuf(ring);
if (pxmitbuf) {
pci_unmap_single(pdev, GET_TX_DESC_TX_BUFFER_ADDRESS_92E(tx_desc), pxmitbuf->len, PCI_DMA_TODEVICE);
dma_unmap_single(&pdev->dev, GET_TX_DESC_TX_BUFFER_ADDRESS_92E(tx_desc), pxmitbuf->len, DMA_TO_DEVICE);
rtw_free_xmitbuf(pxmitpriv, pxmitbuf);
} else {
RTW_INFO("%s(): qlen(%d) is not zero, but have xmitbuf in pending queue\n", __func__, ring->qlen);
break;
}
}

pci_free_consistent(pdev, sizeof(*ring->desc) * ring->entries, ring->desc, ring->dma);
dma_free_coherent(&pdev->dev, sizeof(*ring->desc) * ring->entries, ring->desc, ring->dma);
ring->desc = NULL;

}
Expand Down Expand Up @@ -305,7 +305,7 @@ void rtl8192ee_reset_desc_ring(_adapter *padapter)

pxmitbuf = rtl8192ee_dequeue_xmitbuf(ring);
if (pxmitbuf) {
pci_unmap_single(pdvobjpriv->ppcidev, GET_TX_DESC_TX_BUFFER_ADDRESS_92E(tx_desc), pxmitbuf->len, PCI_DMA_TODEVICE);
dma_unmap_single(&pdvobjpriv->ppcidev->dev, GET_TX_DESC_TX_BUFFER_ADDRESS_92E(tx_desc), pxmitbuf->len, DMA_TO_DEVICE);
rtw_free_xmitbuf(pxmitpriv, pxmitbuf);
} else {
RTW_INFO("%s(): qlen(%d) is not zero, but have xmitbuf in pending queue\n", __func__, ring->qlen);
Expand Down Expand Up @@ -520,7 +520,7 @@ static void rtl8192ee_tx_isr(PADAPTER Adapter, int prio)
pxmitbuf = rtl8192ee_dequeue_xmitbuf(ring);

if (pxmitbuf) {
pci_unmap_single(pdvobjpriv->ppcidev, GET_TX_DESC_TX_BUFFER_ADDRESS_92E(tx_desc), pxmitbuf->len, PCI_DMA_TODEVICE);
dma_unmap_single(&pdvobjpriv->ppcidev->dev, GET_TX_DESC_TX_BUFFER_ADDRESS_92E(tx_desc), pxmitbuf->len, DMA_TO_DEVICE);
rtw_sctx_done(&pxmitbuf->sctx);
rtw_free_xmitbuf(&(pxmitbuf->padapter->xmitpriv), pxmitbuf);
} else
Expand Down Expand Up @@ -563,7 +563,7 @@ static void rtl8192ee_tx_isr(PADAPTER Adapter, int prio)

pxmitbuf = rtl8192ee_dequeue_xmitbuf(ring);
if (pxmitbuf) {
pci_unmap_single(pdvobjpriv->ppcidev, GET_TX_DESC_TX_BUFFER_ADDRESS_92E(tx_desc), pxmitbuf->len, PCI_DMA_TODEVICE);
dma_unmap_single(&pdvobjpriv->ppcidev->dev, GET_TX_DESC_TX_BUFFER_ADDRESS_92E(tx_desc), pxmitbuf->len, DMA_TO_DEVICE);
rtw_sctx_done(&pxmitbuf->sctx);
rtw_free_xmitbuf(&(pxmitbuf->padapter->xmitpriv), pxmitbuf);
} else
Expand Down Expand Up @@ -880,10 +880,10 @@ static void rtl8192ee_rx_mpdu(_adapter *padapter)
* 8192EE_TODO */
precvframe->u.hdr.len = 0;

pci_unmap_single(pdvobjpriv->ppcidev,
dma_unmap_single(&pdvobjpriv->ppcidev->dev,
*((dma_addr_t *)skb->cb),
precvpriv->rxbuffersize,
PCI_DMA_FROMDEVICE);
DMA_FROM_DEVICE);


rtl8192e_query_rx_desc_status(precvframe, skb->data);
Expand All @@ -903,7 +903,7 @@ static void rtl8192ee_rx_mpdu(_adapter *padapter)

rtw_free_recvframe(precvframe, &precvpriv->free_recv_queue);
RTW_INFO("rtl8192ee_rx_mpdu:can not allocate memory for skb copy\n");
*((dma_addr_t *) skb->cb) = pci_map_single(pdvobjpriv->ppcidev, skb_tail_pointer(skb), precvpriv->rxbuffersize, PCI_DMA_FROMDEVICE);
*((dma_addr_t *) skb->cb) = dma_map_single(&pdvobjpriv->ppcidev->dev, skb_tail_pointer(skb), precvpriv->rxbuffersize, DMA_FROM_DEVICE);
goto done;
}

Expand All @@ -918,7 +918,7 @@ static void rtl8192ee_rx_mpdu(_adapter *padapter)
}
rtw_free_recvframe(precvframe, pfree_recv_queue);
}
*((dma_addr_t *) skb->cb) = pci_map_single(pdvobjpriv->ppcidev, skb_tail_pointer(skb), precvpriv->rxbuffersize, PCI_DMA_FROMDEVICE);
*((dma_addr_t *) skb->cb) = dma_map_single(&pdvobjpriv->ppcidev->dev, skb_tail_pointer(skb), precvpriv->rxbuffersize, DMA_FROM_DEVICE);
}
done:

Expand Down
4 changes: 4 additions & 0 deletions hal/rtl8192e/pci/rtl8192ee_xmit.c
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,11 @@ void update_txdesc_buf(struct xmit_frame *pxmitframe, u8 *pmem, s32 sz)
HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter);


#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
mapping = dma_map_single(&pdvobjpriv->ppcidev->dev, pxmitframe->buf_addr , sz + TX_WIFI_INFO_SIZE, DMA_TO_DEVICE);
#else
mapping = pci_map_single(pdvobjpriv->ppcidev, pxmitframe->buf_addr , sz + TX_WIFI_INFO_SIZE, PCI_DMA_TODEVICE);
#endif

/* Calculate page size. Total buffer length including TX_WIFI_INFO and PacketLen */
if (tx_page_size_reg > 0) {
Expand Down
37 changes: 32 additions & 5 deletions os_dep/linux/ioctl_cfg80211.c
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,11 @@ u8 rtw_cfg80211_ch_switch_notify(_adapter *adapter, u8 ch, u8 bw, u8 offset, u8
if (ret != _SUCCESS)
goto exit;

#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 19, 2)
cfg80211_ch_switch_notify(adapter->pnetdev, &chdef);
#else
cfg80211_ch_switch_notify(adapter->pnetdev, &chdef, 0);
#endif

#else
int freq = rtw_ch2freq(ch);
Expand Down Expand Up @@ -981,7 +985,11 @@ void rtw_cfg80211_indicate_connect(_adapter *padapter)
#endif

#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 0, 0)
roam_info.links[0].bssid = cur_network->network.MacAddress;
#else
roam_info.bssid = cur_network->network.MacAddress;
#endif
roam_info.req_ie = pmlmepriv->assoc_req + sizeof(struct rtw_ieee80211_hdr_3addr) + 2;
roam_info.req_ie_len = pmlmepriv->assoc_req_len - sizeof(struct rtw_ieee80211_hdr_3addr) - 2;
roam_info.resp_ie = pmlmepriv->assoc_rsp + sizeof(struct rtw_ieee80211_hdr_3addr) + 6;
Expand Down Expand Up @@ -1622,6 +1630,9 @@ static int rtw_cfg80211_set_encryption(struct net_device *dev, struct ieee_param
}

static int cfg80211_rtw_add_key(struct wiphy *wiphy, struct net_device *ndev,
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)
int link_id,
#endif
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37)) || defined(COMPAT_KERNEL_RELEASE)
u8 key_index, bool pairwise, const u8 *mac_addr,
#else /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37)) */
Expand Down Expand Up @@ -1759,6 +1770,9 @@ static int cfg80211_rtw_add_key(struct wiphy *wiphy, struct net_device *ndev,
}

static int cfg80211_rtw_get_key(struct wiphy *wiphy, struct net_device *ndev,
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)
int link_id,
#endif
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37)) || defined(COMPAT_KERNEL_RELEASE)
u8 key_index, bool pairwise, const u8 *mac_addr,
#else /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37)) */
Expand Down Expand Up @@ -1792,6 +1806,9 @@ static int cfg80211_rtw_get_key(struct wiphy *wiphy, struct net_device *ndev,

static int cfg80211_rtw_del_key(struct wiphy *wiphy, struct net_device *ndev,
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37)) || defined(COMPAT_KERNEL_RELEASE)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)
int link_id,
#endif
u8 key_index, bool pairwise, const u8 *mac_addr)
#else /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37)) */
u8 key_index, const u8 *mac_addr)
Expand All @@ -1811,7 +1828,11 @@ static int cfg80211_rtw_del_key(struct wiphy *wiphy, struct net_device *ndev,
}

static int cfg80211_rtw_set_default_key(struct wiphy *wiphy,
struct net_device *ndev, u8 key_index
struct net_device *ndev,
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)
int link_id,
#endif
u8 key_index
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 38)) || defined(COMPAT_KERNEL_RELEASE)
, bool unicast, bool multicast
#endif
Expand Down Expand Up @@ -2602,10 +2623,8 @@ static int cfg80211_rtw_scan(struct wiphy *wiphy

#ifdef CONFIG_P2P
if (pwdinfo->driver_interface == DRIVER_CFG80211) {
if (ssids->ssid != NULL
&& _rtw_memcmp(ssids->ssid, "DIRECT-", 7)
&& rtw_get_p2p_ie((u8 *)request->ie, request->ie_len, NULL, NULL)
) {
if (_rtw_memcmp(ssids->ssid, "DIRECT-", 7) &&
rtw_get_p2p_ie((u8 *)request->ie, request->ie_len, NULL, NULL)) {
if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE))
rtw_p2p_enable(padapter, P2P_ROLE_DEVICE);
else {
Expand Down Expand Up @@ -4460,7 +4479,11 @@ static int cfg80211_rtw_change_beacon(struct wiphy *wiphy, struct net_device *nd
return ret;
}

#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,19, 2))
static int cfg80211_rtw_stop_ap(struct wiphy *wiphy, struct net_device *ndev, unsigned int link_id)
#else
static int cfg80211_rtw_stop_ap(struct wiphy *wiphy, struct net_device *ndev)
#endif
{
RTW_INFO(FUNC_NDEV_FMT"\n", FUNC_NDEV_ARG(ndev));
return 0;
Expand Down Expand Up @@ -7563,7 +7586,11 @@ void rtw_wdev_unregister(struct wireless_dev *wdev)
rtw_cfg80211_indicate_scan_done(adapter, _TRUE);

#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) || defined(COMPAT_KERNEL_RELEASE)
#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 19, 2)
if (wdev->current_bss) {
#else
if (wdev->connected) {
#endif
RTW_INFO(FUNC_ADPT_FMT" clear current_bss by cfg80211_disconnected\n", FUNC_ADPT_ARG(adapter));
rtw_cfg80211_indicate_disconnect(adapter, 0, 1);
}
Expand Down
4 changes: 4 additions & 0 deletions os_dep/linux/os_intfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1582,7 +1582,11 @@ int rtw_os_ndev_register(_adapter *adapter, const char *name)
u8 rtnl_lock_needed = rtw_rtnl_lock_needed(dvobj);

#ifdef CONFIG_RTW_NAPI
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)
netif_napi_add(ndev, &adapter->napi, rtw_recv_napi_poll);
#else
netif_napi_add(ndev, &adapter->napi, rtw_recv_napi_poll, RTL_NAPI_WEIGHT);
#endif
#endif /* CONFIG_RTW_NAPI */

#if defined(CONFIG_IOCTL_CFG80211)
Expand Down
6 changes: 6 additions & 0 deletions os_dep/linux/pci_intf.c
Original file line number Diff line number Diff line change
Expand Up @@ -1123,8 +1123,14 @@ static struct dvobj_priv *pci_dvobj_init(struct pci_dev *pdev, const struct pci_
} else
#endif
{
#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 18, 0)
if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(32))) {
err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32));
#else
if (!dma_set_mask(&pdev->dev, DMA_BIT_MASK(64))) {
RTW_INFO("RTL819xCE: Using 64bit DMA\n");
err = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(64));
#endif
if (err != 0) {
RTW_ERR("Unable to obtain 32bit DMA for consistent allocations\n");
goto disable_picdev;
Expand Down

0 comments on commit 8af0b61

Please sign in to comment.