All of lore.kernel.org
 help / color / mirror / Atom feed
From: Max Filippov <jcmvbkbc@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 1/8] net/ethoc: support private memory configurations
Date: Wed, 20 Aug 2014 21:42:06 +0400	[thread overview]
Message-ID: <1408556533-22433-2-git-send-email-jcmvbkbc@gmail.com> (raw)
In-Reply-To: <1408556533-22433-1-git-send-email-jcmvbkbc@gmail.com>

From: Chris Zankel <chris@zankel.net>

The 'ethoc' device could also be configured to have a private memory
region instead of having access to the main memory. In that case,
the packets must be copied into (transmit) or out of (receive) that
memory.

This behavior is configured by defining CONFIG_SYS_ETHOC_BUFFER_ADDR.
Make sure to have enough memory for the configured buffers
(one for transmit, and 'PKTBUFSRX' for receive)

Signed-off-by: Chris Zankel <chris@zankel.net>
Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
---
 drivers/net/ethoc.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/drivers/net/ethoc.c b/drivers/net/ethoc.c
index af06d4f..46b9bae 100644
--- a/drivers/net/ethoc.c
+++ b/drivers/net/ethoc.c
@@ -248,6 +248,9 @@ static int ethoc_init_ring(struct eth_device *dev)
 {
 	struct ethoc *priv = (struct ethoc *)dev->priv;
 	struct ethoc_bd bd;
+#ifdef CONFIG_SYS_ETHOC_BUFFER_ADDR
+	unsigned long addr = CONFIG_SYS_ETHOC_BUFFER_ADDR;
+#endif
 	int i;
 
 	priv->cur_tx = 0;
@@ -258,6 +261,10 @@ static int ethoc_init_ring(struct eth_device *dev)
 	bd.stat = TX_BD_IRQ | TX_BD_CRC;
 
 	for (i = 0; i < priv->num_tx; i++) {
+#ifdef CONFIG_SYS_ETHOC_BUFFER_ADDR
+		bd.addr = addr;
+		addr += PKTSIZE_ALIGN;
+#endif
 		if (i == priv->num_tx - 1)
 			bd.stat |= TX_BD_WRAP;
 
@@ -267,7 +274,12 @@ static int ethoc_init_ring(struct eth_device *dev)
 	bd.stat = RX_BD_EMPTY | RX_BD_IRQ;
 
 	for (i = 0; i < priv->num_rx; i++) {
+#ifdef CONFIG_SYS_ETHOC_BUFFER_ADDR
+		bd.addr = addr;
+		addr += PKTSIZE_ALIGN;
+#else
 		bd.addr = (u32)NetRxPackets[i];
+#endif
 		if (i == priv->num_rx - 1)
 			bd.stat |= RX_BD_WRAP;
 
@@ -372,7 +384,12 @@ static int ethoc_rx(struct eth_device *dev, int limit)
 		if (ethoc_update_rx_stats(&bd) == 0) {
 			int size = bd.stat >> 16;
 			size -= 4;	/* strip the CRC */
+#ifdef CONFIG_SYS_ETHOC_BUFFER_ADDR
+			memcpy(NetRxPackets[0], (void *)bd.addr, size);
+			NetReceive(NetRxPackets[0], size);
+#else
 			NetReceive((void *)bd.addr, size);
+#endif
 		}
 
 		/* clear the buffer descriptor so it can be reused */
@@ -428,7 +445,11 @@ static int ethoc_send(struct eth_device *dev, void *packet, int length)
 		bd.stat |= TX_BD_PAD;
 	else
 		bd.stat &= ~TX_BD_PAD;
+#ifdef CONFIG_SYS_ETHOC_BUFFER_ADDR
+	memcpy((void *)bd.addr, (const void *)packet, length);
+#else
 	bd.addr = (u32)packet;
+#endif
 
 	flush_dcache_range(bd.addr, bd.addr + length);
 	bd.stat &= ~(TX_BD_STATS | TX_BD_LEN_MASK);
-- 
1.8.1.4

  reply	other threads:[~2014-08-20 17:42 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-20 17:42 [U-Boot] [PATCH 0/8] U-Boot port to Xtensa architecture Max Filippov
2014-08-20 17:42 ` Max Filippov [this message]
2014-08-20 17:42 ` [U-Boot] [PATCH 2/8] net/ethoc: fix warnings from ethoc_read/ethoc_write Max Filippov
2014-08-20 17:42 ` [U-Boot] [PATCH 3/8] net/ethoc: don't advertise gigabit on the connected PHY Max Filippov
2014-08-20 17:42 ` [U-Boot] [PATCH 4/8] Makefile: allow overriding '-ansi' in LDPPFLAGS Max Filippov
2014-08-20 17:42 ` [U-Boot] [PATCH 5/8] xtensa: add support for the xtensa processor architecture [1/2] Max Filippov
2014-08-20 17:42 ` [U-Boot] [PATCH 6/8] xtensa: add support for the xtensa processor architecture [2/2] Max Filippov
2014-09-01  5:02   ` Simon Glass
2014-09-01 20:16     ` Max Filippov
2014-08-20 17:42 ` [U-Boot] [PATCH 7/8] xtensa: add core information for the dc232b processor Max Filippov
2014-08-20 17:42 ` [U-Boot] [PATCH 8/8] xtensa: add support for the 'xtfpga' evaluation board Max Filippov
2014-08-27 20:59 ` [U-Boot] [PATCH 0/8] U-Boot port to Xtensa architecture Max Filippov
2014-08-28 19:52   ` Tom Rini
2014-08-29 11:50 ` Michal Simek
2014-08-29 12:25   ` Max Filippov
2014-08-29 13:46     ` Michal Simek
2014-09-13  1:39       ` Max Filippov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1408556533-22433-2-git-send-email-jcmvbkbc@gmail.com \
    --to=jcmvbkbc@gmail.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.