Skip to content

Commit

Permalink
Merge branch 'master' of github.com:lwfinger/rtl8192ee
Browse files Browse the repository at this point in the history
  • Loading branch information
lwfinger committed Oct 17, 2022
2 parents 8af0b61 + 41c24c3 commit 772c973
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 6 deletions.
62 changes: 62 additions & 0 deletions hal/rtl8192e/pci/pci_ops_linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,15 @@ 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 =
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0))
dma_alloc_coherent(&pdev->dev,
sizeof(*precvpriv->rx_ring[rx_queue_idx].desc) * precvpriv->rxringcount,
&precvpriv->rx_ring[rx_queue_idx].dma, GFP_KERNEL);
#else
pci_alloc_consistent(pdev,
sizeof(*precvpriv->rx_ring[rx_queue_idx].desc) * precvpriv->rxringcount,
&precvpriv->rx_ring[rx_queue_idx].dma);
#endif

if (!precvpriv->rx_ring[rx_queue_idx].desc
|| (unsigned long)precvpriv->rx_ring[rx_queue_idx].desc & 0xFF) {
Expand All @@ -76,9 +82,15 @@ 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 */
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0))
*mapping = dma_map_single(&pdev->dev, skb_tail_pointer(skb),
precvpriv->rxbuffersize,
DMA_FROM_DEVICE);
#else
*mapping = pci_map_single(pdev, skb_tail_pointer(skb),
precvpriv->rxbuffersize,
PCI_DMA_FROMDEVICE);
#endif

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

#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0))
dma_unmap_single(&pdev->dev,
*((dma_addr_t *) skb->cb),
precvpriv->rxbuffersize,
DMA_FROM_DEVICE);
#else
pci_unmap_single(pdev,
*((dma_addr_t *) skb->cb),
precvpriv->rxbuffersize,
PCI_DMA_FROMDEVICE);
#endif
kfree_skb(skb);
}

#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0))
dma_free_coherent(&pdev->dev,
#else
pci_free_consistent(pdev,
#endif
sizeof(*precvpriv->rx_ring[rx_queue_idx].desc) *
precvpriv->rxringcount,
precvpriv->rx_ring[rx_queue_idx].desc,
Expand All @@ -142,7 +165,11 @@ static int rtl8192ee_init_tx_ring(_adapter *padapter, unsigned int prio, unsigne


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

pxmitbuf = rtl8192ee_dequeue_xmitbuf(ring);
if (pxmitbuf) {
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0))
dma_unmap_single(&pdev->dev, GET_TX_DESC_TX_BUFFER_ADDRESS_92E(tx_desc), pxmitbuf->len, DMA_TO_DEVICE);
#else
pci_unmap_single(pdev, GET_TX_DESC_TX_BUFFER_ADDRESS_92E(tx_desc), pxmitbuf->len, PCI_DMA_TODEVICE);
#endif
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;
}
}

#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0))
dma_free_coherent(&pdev->dev, sizeof(*ring->desc) * ring->entries, ring->desc, ring->dma);
#else
pci_free_consistent(pdev, sizeof(*ring->desc) * ring->entries, ring->desc, ring->dma);
#endif
ring->desc = NULL;

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

pxmitbuf = rtl8192ee_dequeue_xmitbuf(ring);
if (pxmitbuf) {
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0))
dma_unmap_single(&pdvobjpriv->ppcidev->dev, GET_TX_DESC_TX_BUFFER_ADDRESS_92E(tx_desc), pxmitbuf->len, DMA_TO_DEVICE);
#else
pci_unmap_single(pdvobjpriv->ppcidev, GET_TX_DESC_TX_BUFFER_ADDRESS_92E(tx_desc), pxmitbuf->len, PCI_DMA_TODEVICE);
#endif
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 +559,11 @@ static void rtl8192ee_tx_isr(PADAPTER Adapter, int prio)
pxmitbuf = rtl8192ee_dequeue_xmitbuf(ring);

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

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

#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0))
dma_unmap_single(&pdvobjpriv->ppcidev->dev,
*((dma_addr_t *)skb->cb),
precvpriv->rxbuffersize,
DMA_FROM_DEVICE);
#else
pci_unmap_single(pdvobjpriv->ppcidev,
*((dma_addr_t *)skb->cb),
precvpriv->rxbuffersize,
PCI_DMA_FROMDEVICE);
#endif


rtl8192e_query_rx_desc_status(precvframe, skb->data);
Expand All @@ -903,7 +957,11 @@ 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");
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0))
*((dma_addr_t *) skb->cb) = dma_map_single(&pdvobjpriv->ppcidev->dev, skb_tail_pointer(skb), precvpriv->rxbuffersize, DMA_FROM_DEVICE);
#else
*((dma_addr_t *) skb->cb) = pci_map_single(pdvobjpriv->ppcidev, skb_tail_pointer(skb), precvpriv->rxbuffersize, PCI_DMA_FROMDEVICE);
#endif
goto done;
}

Expand All @@ -918,7 +976,11 @@ static void rtl8192ee_rx_mpdu(_adapter *padapter)
}
rtw_free_recvframe(precvframe, pfree_recv_queue);
}
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0))
*((dma_addr_t *) skb->cb) = dma_map_single(&pdvobjpriv->ppcidev->dev, skb_tail_pointer(skb), precvpriv->rxbuffersize, DMA_FROM_DEVICE);
#else
*((dma_addr_t *) skb->cb) = pci_map_single(pdvobjpriv->ppcidev, skb_tail_pointer(skb), precvpriv->rxbuffersize, PCI_DMA_FROMDEVICE);
#endif
}
done:

Expand Down
2 changes: 1 addition & 1 deletion hal/rtl8192e/pci/rtl8192ee_xmit.c
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ 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)
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 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);
Expand Down
12 changes: 12 additions & 0 deletions include/ieee80211.h
Original file line number Diff line number Diff line change
Expand Up @@ -1425,18 +1425,30 @@ enum ieee80211_state {
(((Addr[2]) & 0xff) == 0xff) && (((Addr[3]) & 0xff) == 0xff) && (((Addr[4]) & 0xff) == 0xff) && \
(((Addr[5]) & 0xff) == 0xff))
#else
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0))
static inline int is_multicast_mac_addr(const u8 *addr)
#else
extern __inline int is_multicast_mac_addr(const u8 *addr)
#endif
{
return (addr[0] != 0xff) && (0x01 & addr[0]);
}

#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0))
static inline int is_broadcast_mac_addr(const u8 *addr)
#else
extern __inline int is_broadcast_mac_addr(const u8 *addr)
#endif
{
return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) && \
(addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff));
}

#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0))
static inline int is_zero_mac_addr(const u8 *addr)
#else
extern __inline int is_zero_mac_addr(const u8 *addr)
#endif
{
return ((addr[0] == 0x00) && (addr[1] == 0x00) && (addr[2] == 0x00) && \
(addr[3] == 0x00) && (addr[4] == 0x00) && (addr[5] == 0x00));
Expand Down
15 changes: 10 additions & 5 deletions os_dep/linux/pci_intf.c
Original file line number Diff line number Diff line change
Expand Up @@ -1112,9 +1112,15 @@ static struct dvobj_priv *pci_dvobj_init(struct pci_dev *pdev, const struct pci_
}

#ifdef CONFIG_64BIT_DMA
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0))
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));
#else
if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(64))) {
RTW_INFO("RTL819xCE: Using 64bit DMA\n");
err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64));
#endif
if (err != 0) {
RTW_ERR("Unable to obtain 64bit DMA for consistent allocations\n");
goto disable_picdev;
Expand All @@ -1123,13 +1129,12 @@ 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 (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0))
if (!dma_set_mask(&pdev->dev, DMA_BIT_MASK(32))) {
err = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32));
#else
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");
Expand Down

0 comments on commit 772c973

Please sign in to comment.