Skip to contentSkip to conversation

net: lpc32xx: Use IRAM for transmit buffer

PATCH In review Gregory CLEMENT 2 participants 2 messages Apr 17, 2019 – Apr 27, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: lpc32xx: Use IRAM for transmit buffer

Since the introduction of the driver, some memory in IRAM is reserved for the TX buffers.

However there are not used but instead of it, it is the buffer provided by the net stack which is used. As stated in the comment of the driver, not using the IRAM buffer could cause cache issue and lower the throughput.

For the second argument it is less the case for transmitting buffers because the throughput gain in IRAM is mitigated by the time to copy the data from RAM to IRAM, but the first argument is still valid and indeed this patch fixes issue seen with Ethernet on some boards

---
 drivers/net/lpc32xx_eth.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/net/lpc32xx_eth.c +7 -1
index 2d15fc8db2..ec5184edf8 100644
@@ -373,7 +373,8 @@ static int lpc32xx_eth_send(struct eth_device *dev, void *dataptr, int datasize)
 	tx_index = readl(&regs->txproduceindex);
 
 	/* set up transmit packet */
-	writel((u32)dataptr, &bufs->tx_desc[tx_index].packet);
+	memcpy((void *)&bufs->tx_buf[tx_index * PKTSIZE_ALIGN],
+	       (void *)dataptr, datasize);
 	writel(TX_CTRL_LAST | ((datasize - 1) & TX_CTRL_TXSIZE),
 	       &bufs->tx_desc[tx_index].control);
 	writel(0, &bufs->tx_stat[tx_index].statusinfo);
@@ -508,6 +509,11 @@ static int lpc32xx_eth_init(struct eth_device *dev)
 	writel((u32)(&bufs->rx_stat), &regs->rxstatus);
 	writel(RX_BUF_COUNT-1, &regs->rxdescriptornumber);
 
+	/* set up transmit buffers */
+	for (index = 0; index < TX_BUF_COUNT; index++)
+		bufs->tx_desc[index].packet =
+			(u32)(bufs->tx_buf + index * PKTSIZE_ALIGN);
+
 	/* Enable broadcast and matching address packets */
 	writel(RXFILTERCTRL_ACCEPTBROADCAST |
 		RXFILTERCTRL_ACCEPTPERFECT, &regs->rxfilterctrl);
Signature · 1 line
2.20.1
#1 lore raw
Quoted 8 lines · Gregory CLEMENT

Since the introduction of the driver, some memory in IRAM is reserved for the TX buffers.

However there are not used but instead of it, it is the buffer provided by the net stack which is used. As stated in the comment of the driver, not using the IRAM buffer could cause cache issue and lower the throughput.

Quoted 6 lines

For the second argument it is less the case for transmitting buffers because the throughput gain in IRAM is mitigated by the time to copy the data from RAM to IRAM, but the first argument is still valid and indeed this patch fixes issue seen with Ethernet on some boards

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190427/c08fd933/attachment.sig>