Message ID | eca56ab1af7f4bbedc4a6d0990a10ff58911d842.1652716741.git.lorenzo@kernel.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | introduce mt7986 ethernet support | expand |
On Mon, 16 May 2022 18:06:37 +0200 Lorenzo Bianconi wrote: > + > + rxd = (void *)ring->dma + i * eth->soc->txrx.rxd_size; > + rxd->rxd1 = (unsigned int)dma_addr; > > if (MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_MT7628)) > - ring->dma[i].rxd2 = RX_DMA_LSO; > + rxd->rxd2 = RX_DMA_LSO; > else > - ring->dma[i].rxd2 = RX_DMA_PLEN0(ring->buf_size); > + rxd->rxd2 = RX_DMA_PLEN0(ring->buf_size); > + > + rxd->rxd3 = 0; > + rxd->rxd4 = 0; The clearing of rxd3/rxd4 should probably have been mentioned in the commit message. It does not seem related to descriptor size.
> On Mon, 16 May 2022 18:06:37 +0200 Lorenzo Bianconi wrote: > > + > > + rxd = (void *)ring->dma + i * eth->soc->txrx.rxd_size; > > + rxd->rxd1 = (unsigned int)dma_addr; > > > > if (MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_MT7628)) > > - ring->dma[i].rxd2 = RX_DMA_LSO; > > + rxd->rxd2 = RX_DMA_LSO; > > else > > - ring->dma[i].rxd2 = RX_DMA_PLEN0(ring->buf_size); > > + rxd->rxd2 = RX_DMA_PLEN0(ring->buf_size); > > + > > + rxd->rxd3 = 0; > > + rxd->rxd4 = 0; > > The clearing of rxd3/rxd4 should probably have been mentioned in the > commit message. It does not seem related to descriptor size. ack, I will do it in v3. Regards, Lorenzo
diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c index d431311578e8..1e2fddc2bdcb 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c @@ -1728,18 +1728,25 @@ static int mtk_rx_alloc(struct mtk_eth *eth, int ring_no, int rx_flag) return -ENOMEM; for (i = 0; i < rx_dma_size; i++) { + struct mtk_rx_dma *rxd; + dma_addr_t dma_addr = dma_map_single(eth->dma_dev, ring->data[i] + NET_SKB_PAD + eth->ip_align, ring->buf_size, DMA_FROM_DEVICE); if (unlikely(dma_mapping_error(eth->dma_dev, dma_addr))) return -ENOMEM; - ring->dma[i].rxd1 = (unsigned int)dma_addr; + + rxd = (void *)ring->dma + i * eth->soc->txrx.rxd_size; + rxd->rxd1 = (unsigned int)dma_addr; if (MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_MT7628)) - ring->dma[i].rxd2 = RX_DMA_LSO; + rxd->rxd2 = RX_DMA_LSO; else - ring->dma[i].rxd2 = RX_DMA_PLEN0(ring->buf_size); + rxd->rxd2 = RX_DMA_PLEN0(ring->buf_size); + + rxd->rxd3 = 0; + rxd->rxd4 = 0; } ring->dma_size = rx_dma_size; ring->calc_idx_update = false; @@ -1764,14 +1771,17 @@ static void mtk_rx_clean(struct mtk_eth *eth, struct mtk_rx_ring *ring) if (ring->data && ring->dma) { for (i = 0; i < ring->dma_size; i++) { + struct mtk_rx_dma *rxd; + if (!ring->data[i]) continue; - if (!ring->dma[i].rxd1) + + rxd = (void *)ring->dma + i * eth->soc->txrx.rxd_size; + if (!rxd->rxd1) continue; - dma_unmap_single(eth->dma_dev, - ring->dma[i].rxd1, - ring->buf_size, - DMA_FROM_DEVICE); + + dma_unmap_single(eth->dma_dev, rxd->rxd1, + ring->buf_size, DMA_FROM_DEVICE); skb_free_frag(ring->data[i]); } kfree(ring->data);