Message ID | 1467992526-13417-7-git-send-email-jcmvbkbc@gmail.com |
---|---|
State | Changes Requested |
Delegated to: | Tom Rini |
Headers | show |
Hi, On 8 July 2016 at 09:42, Max Filippov <jcmvbkbc@gmail.com> wrote: > 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 edb3c80..ee7c01e 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; These should be in Kconfig. Also you might find bouncebuf.c useful, although it allocates memory with malloc(). Regards, Simon
Hi Simon, On Tue, Jul 12, 2016 at 03:56:54PM -0600, Simon Glass wrote: > On 8 July 2016 at 09:42, Max Filippov <jcmvbkbc@gmail.com> wrote: > > 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 edb3c80..ee7c01e 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; > > These should be in Kconfig. Ok. > Also you might find bouncebuf.c useful, although it allocates memory > with malloc(). The ethoc variant that we use in XTFPGA boards can only access packets in its dedicated packet memory and we don't have other DMA, so bouncebuf doesn't look useful for our case.
Hi Max, On 14 July 2016 at 17:34, Max Filippov <jcmvbkbc@gmail.com> wrote: > Hi Simon, > > On Tue, Jul 12, 2016 at 03:56:54PM -0600, Simon Glass wrote: >> On 8 July 2016 at 09:42, Max Filippov <jcmvbkbc@gmail.com> wrote: >> > 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 edb3c80..ee7c01e 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; >> >> These should be in Kconfig. > > Ok. > >> Also you might find bouncebuf.c useful, although it allocates memory >> with malloc(). > > The ethoc variant that we use in XTFPGA boards can only access packets > in its dedicated packet memory and we don't have other DMA, so bouncebuf > doesn't look useful for our case. OK. Regards, Simon
diff --git a/drivers/net/ethoc.c b/drivers/net/ethoc.c index edb3c80..ee7c01e 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)net_rx_packets[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(net_rx_packets[0], (void *)bd.addr, size); + net_process_received_packet(net_rx_packets[0], size); +#else net_process_received_packet((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);