d59d69f9e1
Manually rebased: backport-5.15/704-15-v5.19-net-mtk_eth_soc-move-MAC_MCR-setting-to-mac_finish.patch Removed upstreamed: backport-5.15/060-v6.0-01-tools-build-Add-feature-test-for-init_disassemble_in.patch[1] backport-5.15/060-v6.0-02-tools-include-add-dis-asm-compat.h-to-handle-version.patch[2] backport-5.15/060-v6.0-03-tools-perf-Fix-compilation-error-with-new-binutils.patch[3] backport-5.15/060-v6.0-04-tools-bpf_jit_disasm-Fix-compilation-error-with-new-.patch[4] backport-5.15/060-v6.0-05-tools-bpftool-Fix-compilation-error-with-new-binutil.patch[5] pending-5.15/733-02-net-ethernet-mtk_eth_soc-fix-RX-data-corruption-issu.patch[6] bcm47xx/patches-5.15/170-bgmac-fix-initial-chip-reset-to-support-BCM5358.patch[7] All other patches automatically rebased. 1. https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=v5.15.103&id=51b99dc38c1a053e2e732d7f9e2740e343ae7eae 2. https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=v5.15.103&id=451c9d7b16169645ed291ebb2ca9844caa088f2d 3. https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=v5.15.103&id=97f005c0bdbaf656a7808586d234965385a06c58 4. https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=v5.15.103&id=1c27fab243333821375e4d63128d60093fdbe149 5. https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=v5.15.103&id=4441a90091931fd81607567961dc122f24f735bb 6. https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=v5.15.103&id=2adc29350a5b4669544566f71f208d2abaec60ab 7. https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=v5.15.103&id=04bfc5bcdfc0fdb73587487c71b04d63807ae15a Build system: x86_64 Build-tested: bcm2711/RPi4B, ramips/tplink_archer-a6-v3, filogic/xiaomi_redmi-router-ax6000-ubootmod Run-tested: bcm2711/RPi4B, ramips/tplink_archer-a6-v3, filogic/xiaomi_redmi-router-ax6000-ubootmod Signed-off-by: John Audia <therealgraysky@proton.me>
110 lines
3.5 KiB
Diff
110 lines
3.5 KiB
Diff
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
|
Date: Fri, 20 May 2022 20:11:30 +0200
|
|
Subject: [PATCH] net: ethernet: mtk_eth_soc: rely on txd_size in
|
|
mtk_desc_to_tx_buf
|
|
|
|
This is a preliminary patch to add mt7986 ethernet support.
|
|
|
|
Tested-by: Sam Shih <sam.shih@mediatek.com>
|
|
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
|
Signed-off-by: David S. Miller <davem@davemloft.net>
|
|
---
|
|
|
|
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
|
|
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
|
|
@@ -891,10 +891,11 @@ static inline void *mtk_qdma_phys_to_vir
|
|
return ret + (desc - ring->phys);
|
|
}
|
|
|
|
-static inline struct mtk_tx_buf *mtk_desc_to_tx_buf(struct mtk_tx_ring *ring,
|
|
- struct mtk_tx_dma *txd)
|
|
+static struct mtk_tx_buf *mtk_desc_to_tx_buf(struct mtk_tx_ring *ring,
|
|
+ struct mtk_tx_dma *txd,
|
|
+ u32 txd_size)
|
|
{
|
|
- int idx = txd - ring->dma;
|
|
+ int idx = ((void *)txd - (void *)ring->dma) / txd_size;
|
|
|
|
return &ring->buf[idx];
|
|
}
|
|
@@ -1016,6 +1017,7 @@ static int mtk_tx_map(struct sk_buff *sk
|
|
};
|
|
struct mtk_mac *mac = netdev_priv(dev);
|
|
struct mtk_eth *eth = mac->hw;
|
|
+ const struct mtk_soc_data *soc = eth->soc;
|
|
struct mtk_tx_dma *itxd, *txd;
|
|
struct mtk_tx_dma *itxd_pdma, *txd_pdma;
|
|
struct mtk_tx_buf *itx_buf, *tx_buf;
|
|
@@ -1027,7 +1029,7 @@ static int mtk_tx_map(struct sk_buff *sk
|
|
if (itxd == ring->last_free)
|
|
return -ENOMEM;
|
|
|
|
- itx_buf = mtk_desc_to_tx_buf(ring, itxd);
|
|
+ itx_buf = mtk_desc_to_tx_buf(ring, itxd, soc->txrx.txd_size);
|
|
memset(itx_buf, 0, sizeof(*itx_buf));
|
|
|
|
txd_info.addr = dma_map_single(eth->dma_dev, skb->data, txd_info.size,
|
|
@@ -1055,7 +1057,7 @@ static int mtk_tx_map(struct sk_buff *sk
|
|
while (frag_size) {
|
|
bool new_desc = true;
|
|
|
|
- if (MTK_HAS_CAPS(eth->soc->caps, MTK_QDMA) ||
|
|
+ if (MTK_HAS_CAPS(soc->caps, MTK_QDMA) ||
|
|
(i & 0x1)) {
|
|
txd = mtk_qdma_phys_to_virt(ring, txd->txd2);
|
|
txd_pdma = qdma_to_pdma(ring, txd);
|
|
@@ -1079,7 +1081,8 @@ static int mtk_tx_map(struct sk_buff *sk
|
|
|
|
mtk_tx_set_dma_desc(dev, txd, &txd_info);
|
|
|
|
- tx_buf = mtk_desc_to_tx_buf(ring, txd);
|
|
+ tx_buf = mtk_desc_to_tx_buf(ring, txd,
|
|
+ soc->txrx.txd_size);
|
|
if (new_desc)
|
|
memset(tx_buf, 0, sizeof(*tx_buf));
|
|
tx_buf->skb = (struct sk_buff *)MTK_DMA_DUMMY_DESC;
|
|
@@ -1098,7 +1101,7 @@ static int mtk_tx_map(struct sk_buff *sk
|
|
/* store skb to cleanup */
|
|
itx_buf->skb = skb;
|
|
|
|
- if (!MTK_HAS_CAPS(eth->soc->caps, MTK_QDMA)) {
|
|
+ if (!MTK_HAS_CAPS(soc->caps, MTK_QDMA)) {
|
|
if (k & 0x1)
|
|
txd_pdma->txd2 |= TX_DMA_LS0;
|
|
else
|
|
@@ -1116,7 +1119,7 @@ static int mtk_tx_map(struct sk_buff *sk
|
|
*/
|
|
wmb();
|
|
|
|
- if (MTK_HAS_CAPS(eth->soc->caps, MTK_QDMA)) {
|
|
+ if (MTK_HAS_CAPS(soc->caps, MTK_QDMA)) {
|
|
if (netif_xmit_stopped(netdev_get_tx_queue(dev, 0)) ||
|
|
!netdev_xmit_more())
|
|
mtk_w32(eth, txd->txd2, MTK_QTX_CTX_PTR);
|
|
@@ -1130,13 +1133,13 @@ static int mtk_tx_map(struct sk_buff *sk
|
|
|
|
err_dma:
|
|
do {
|
|
- tx_buf = mtk_desc_to_tx_buf(ring, itxd);
|
|
+ tx_buf = mtk_desc_to_tx_buf(ring, itxd, soc->txrx.txd_size);
|
|
|
|
/* unmap dma */
|
|
mtk_tx_unmap(eth, tx_buf, false);
|
|
|
|
itxd->txd3 = TX_DMA_LS0 | TX_DMA_OWNER_CPU;
|
|
- if (!MTK_HAS_CAPS(eth->soc->caps, MTK_QDMA))
|
|
+ if (!MTK_HAS_CAPS(soc->caps, MTK_QDMA))
|
|
itxd_pdma->txd2 = TX_DMA_DESP2_DEF;
|
|
|
|
itxd = mtk_qdma_phys_to_virt(ring, itxd->txd2);
|
|
@@ -1450,7 +1453,8 @@ static int mtk_poll_tx_qdma(struct mtk_e
|
|
if ((desc->txd3 & TX_DMA_OWNER_CPU) == 0)
|
|
break;
|
|
|
|
- tx_buf = mtk_desc_to_tx_buf(ring, desc);
|
|
+ tx_buf = mtk_desc_to_tx_buf(ring, desc,
|
|
+ eth->soc->txrx.txd_size);
|
|
if (tx_buf->flags & MTK_TX_FLAGS_FPORT1)
|
|
mac = 1;
|
|
|