net: emaclite: Setup RX/TX ping pong for every instance
Subsystems (2)
PATCH v2 1/3 net: emaclite: Setup RX/TX ping pong for every instance
Setup RX/TX ping-pong buffer for every emaclite IP separately. The next patch move initialization directly to board code.
---
v2: Fix coding style violations
--- drivers/net/xilinx_emaclite.c | 123 ++++++++++++++++++++++------------------ 1 files changed, 68 insertions(+), 55 deletions(-)
drivers/net/xilinx_emaclite.c +68 -55
@@ -66,6 +66,8 @@struct xemaclite {u32 nexttxbuffertouse;/* Next TX buffer to write to */ u32 nextrxbuffertouse;/* Next RX buffer to read from */ +u32 txpp;/* TX ping pong buffer */ +u32 rxpp;/* RX ping pong buffer */ };static u32 etherrxbuff[PKTSIZE_ALIGN /4 ];/* Receive buffer */
@@ -131,6 +133,7 @@ static void emaclite_halt(struct eth_device *dev)static int emaclite_init (struct eth_device *dev,bd_t *bis) { +struct xemaclite *emaclite = dev->priv;debug ("EmacLite Initialization Started\n" );/*
@@ -150,28 +153,28 @@ static int emaclite_init(struct eth_device *dev, bd_t *bis) XEL_TSR_PROG_MAC_ADDR) != 0) ; -#ifdef CONFIG_XILINX_EMACLITE_TX_PING_PONG -/* The same operation with PONG TX */ -out_be32 (dev->iobase +XEL_TSR_OFFSET +XEL_BUFFER_OFFSET ,0 ); -xemaclite_alignedwrite (dev->enetaddr, dev->iobase + -XEL_BUFFER_OFFSET ,ENET_ADDR_LENGTH ); -out_be32 (dev->iobase +XEL_TPLR_OFFSET ,ENET_ADDR_LENGTH ); -out_be32 (dev->iobase +XEL_TSR_OFFSET +XEL_BUFFER_OFFSET , -XEL_TSR_PROG_MAC_ADDR ); -while ((in_be32 (dev->iobase +XEL_TSR_OFFSET + -XEL_BUFFER_OFFSET ) &XEL_TSR_PROG_MAC_ADDR ) !=0 ) - ; -#endif +if (emaclite->txpp) { +/* The same operation with PONG TX */ +out_be32 (dev->iobase +XEL_TSR_OFFSET +XEL_BUFFER_OFFSET ,0 ); +xemaclite_alignedwrite (dev->enetaddr, dev->iobase + +XEL_BUFFER_OFFSET ,ENET_ADDR_LENGTH ); +out_be32 (dev->iobase +XEL_TPLR_OFFSET ,ENET_ADDR_LENGTH ); +out_be32 (dev->iobase +XEL_TSR_OFFSET +XEL_BUFFER_OFFSET , +XEL_TSR_PROG_MAC_ADDR ); +while ((in_be32 (dev->iobase +XEL_TSR_OFFSET + +XEL_BUFFER_OFFSET ) &XEL_TSR_PROG_MAC_ADDR ) !=0 ) + ; + }/* * RX - RX_PING & RX_PONG initialization */ /* Write out the value to flush the RX buffer */ out_be32 (dev->iobase +XEL_RSR_OFFSET ,XEL_RSR_RECV_IE_MASK ); -#ifdef CONFIG_XILINX_EMACLITE_RX_PING_PONG -out_be32 (dev->iobase +XEL_RSR_OFFSET +XEL_BUFFER_OFFSET , -XEL_RSR_RECV_IE_MASK ); -#endif + +if (emaclite->rxpp) +out_be32 (dev->iobase +XEL_RSR_OFFSET +XEL_BUFFER_OFFSET , +XEL_RSR_RECV_IE_MASK );debug ("EmacLite Initialization complete\n" );return 0 ;
@@ -221,10 +224,10 @@ static int emaclite_send (struct eth_device *dev, volatile void *ptr, int len)printf ("Error: Timeout waiting for ethernet TX buffer\n" );/* Restart PING TX */ out_be32 (dev->iobase +XEL_TSR_OFFSET ,0 ); -#ifdef CONFIG_XILINX_EMACLITE_TX_PING_PONG -out_be32 (dev->iobase +XEL_TSR_OFFSET + -XEL_BUFFER_OFFSET ,0 ); -#endif +if (emaclite->txpp) { +out_be32 (dev->iobase +XEL_TSR_OFFSET + +XEL_BUFFER_OFFSET ,0 ); + }return -1 ; }
@@ -237,9 +240,9 @@ static int emaclite_send (struct eth_device *dev, volatile void *ptr, int len) && ((in_be32 ((baseaddress) + XEL_TSR_OFFSET) & XEL_TSR_XMIT_ACTIVE_MASK) == 0)) { -#ifdef CONFIG_XILINX_EMACLITE_TX_PING_PONG - emaclite->nexttxbuffertouse ^=XEL_BUFFER_OFFSET ; -#endif +if (emaclite->txpp) + emaclite->nexttxbuffertouse ^=XEL_BUFFER_OFFSET ; +debug ("Send packet from 0x%x\n" , baseaddress);/* Write the frame to the buffer */ xemaclite_alignedwrite ((void *) ptr, baseaddress, len);
@@ -253,28 +256,30 @@ static int emaclite_send (struct eth_device *dev, volatile void *ptr, int len)out_be32 (baseaddress +XEL_TSR_OFFSET , reg);return 0 ; } -#ifdef CONFIG_XILINX_EMACLITE_TX_PING_PONG -/* Switch to second buffer */ - baseaddress ^=XEL_BUFFER_OFFSET ; -/* Determine if the expected buffer address is empty */ - reg =in_be32 (baseaddress +XEL_TSR_OFFSET ); -if (((reg &XEL_TSR_XMIT_BUSY_MASK ) ==0 ) - && ((in_be32 ((baseaddress) +XEL_TSR_OFFSET ) - &XEL_TSR_XMIT_ACTIVE_MASK ) ==0 )) { -debug ("Send packet from 0x%x\n" , baseaddress); -/* Write the frame to the buffer */ -xemaclite_alignedwrite ((void *) ptr, baseaddress, len); -out_be32 (baseaddress +XEL_TPLR_OFFSET ,(len & - (XEL_TPLR_LENGTH_MASK_HI |XEL_TPLR_LENGTH_MASK_LO ))); + +if (emaclite->txpp) { +/* Switch to second buffer */ + baseaddress ^=XEL_BUFFER_OFFSET ; +/* Determine if the expected buffer address is empty */ reg =in_be32 (baseaddress +XEL_TSR_OFFSET ); - reg |=XEL_TSR_XMIT_BUSY_MASK ; -if ((reg &XEL_TSR_XMIT_IE_MASK ) !=0 ) { - reg |=XEL_TSR_XMIT_ACTIVE_MASK ; +if (((reg &XEL_TSR_XMIT_BUSY_MASK ) ==0 ) + && ((in_be32 ((baseaddress) +XEL_TSR_OFFSET ) + &XEL_TSR_XMIT_ACTIVE_MASK ) ==0 )) { +debug ("Send packet from 0x%x\n" , baseaddress); +/* Write the frame to the buffer */ +xemaclite_alignedwrite ((void *) ptr, baseaddress, len); +out_be32 (baseaddress +XEL_TPLR_OFFSET , (len & + (XEL_TPLR_LENGTH_MASK_HI | +XEL_TPLR_LENGTH_MASK_LO ))); + reg =in_be32 (baseaddress +XEL_TSR_OFFSET ); + reg |=XEL_TSR_XMIT_BUSY_MASK ; +if ((reg &XEL_TSR_XMIT_IE_MASK ) !=0 ) + reg |=XEL_TSR_XMIT_ACTIVE_MASK ; +out_be32 (baseaddress +XEL_TSR_OFFSET , reg); +return 0 ; } -out_be32 (baseaddress +XEL_TSR_OFFSET , reg); -return 0 ; } -#endif +puts ("Error while sending frame\n" );return -1 ; }
@@ -290,23 +295,24 @@ static int emaclite_recv(struct eth_device *dev) reg =in_be32 (baseaddress +XEL_RSR_OFFSET );debug ("Testing data at address 0x%x\n" , baseaddress);if ((reg &XEL_RSR_RECV_DONE_MASK ) ==XEL_RSR_RECV_DONE_MASK ) { -#ifdef CONFIG_XILINX_EMACLITE_RX_PING_PONG - emaclite->nextrxbuffertouse ^=XEL_BUFFER_OFFSET ; -#endif +if (emaclite->rxpp) + emaclite->nextrxbuffertouse ^=XEL_BUFFER_OFFSET ; }else { -#ifndef CONFIG_XILINX_EMACLITE_RX_PING_PONG -debug ("No data was available - address 0x%x\n" , baseaddress); -return 0 ; -#else - baseaddress ^=XEL_BUFFER_OFFSET ; - reg =in_be32 (baseaddress +XEL_RSR_OFFSET ); -if ((reg &XEL_RSR_RECV_DONE_MASK ) != -XEL_RSR_RECV_DONE_MASK ) { + +if (!emaclite->rxpp) {debug ("No data was available - address 0x%x\n" , - baseaddress); + baseaddress);return 0 ; + }else { + baseaddress ^=XEL_BUFFER_OFFSET ; + reg =in_be32 (baseaddress +XEL_RSR_OFFSET ); +if ((reg &XEL_RSR_RECV_DONE_MASK ) != +XEL_RSR_RECV_DONE_MASK ) { +debug ("No data was available - address 0x%x\n" , + baseaddress); +return 0 ; + } } -#endif }/* Get the length of the frame that arrived */ switch(((ntohl(in_be32 (baseaddress + XEL_RXBUFF_OFFSET + 0xC))) &
@@ -358,6 +364,13 @@ int xilinx_emaclite_initialize (bd_t *bis, int base_addr) dev->priv = emaclite; +#ifdef CONFIG_XILINX_EMACLITE_TX_PING_PONG + emaclite->txpp =1 ; +#endif +#ifdef CONFIG_XILINX_EMACLITE_RX_PING_PONG + emaclite->rxpp =1 ; +#endif +sprintf (dev->name,"Xelite.%x" , base_addr); dev->iobase = base_addr;
Signature · 1 line
1.5.5.6
PATCH 2/3 net: emaclite: Use PKTSIZE directly
Do not setup additional ENET_MAX_MTU macro.
--- drivers/net/xilinx_emaclite.c | 10 ++++------ 1 files changed, 4 insertions(+), 6 deletions(-)
drivers/net/xilinx_emaclite.c +4 -6
@@ -31,8 +31,6 @@#undef DEBUG -#define ENET_MAX_MTU PKTSIZE -#define ENET_MAX_MTU_ALIGNED PKTSIZE_ALIGN#define ENET_ADDR_LENGTH 6/* EmacLite constants */
@@ -212,8 +210,8 @@ static int emaclite_send (struct eth_device *dev, volatile void *ptr, int len)u32 maxtry =1000 ; -if (len >ENET_MAX_MTU ) - len =ENET_MAX_MTU ; +if (len >PKTSIZE ) + len =PKTSIZE ;while (!xemaclite_txbufferavailable (dev) && maxtry) {udelay (10 );
@@ -328,8 +326,8 @@ static int emaclite_recv(struct eth_device *dev)debug ("IP Packet\n" );break ;default : -debug ("Other Packet\n" ); - length =ENET_MAX_MTU ; +debug ("Other Packet\n" ); + length =PKTSIZE ;break ; }
Signature · 1 line
1.5.5.6
PATCH 3/3 net: emaclite: Fix coding style
Checked by checkpatch.pl script.
No functional changes.
--- drivers/net/xilinx_emaclite.c | 57 +++++++++++++++++++--------------------- 1 files changed, 27 insertions(+), 30 deletions(-)
drivers/net/xilinx_emaclite.c +27 -30
@@ -70,7 +70,7 @@ struct xemaclite {static u32 etherrxbuff[PKTSIZE_ALIGN /4 ];/* Receive buffer */ -static void xemaclite_alignedread (u32 *srcptr,void *destptr,u32 bytecount) +static void xemaclite_alignedread (u32 *srcptr,void *destptr,u32 bytecount) {u32 i;u32 alignbuffer;
@@ -90,14 +90,13 @@ static void xemaclite_alignedread (u32 *srcptr, void *destptr, u32 bytecount) to8ptr = (u8 *) to32ptr; alignbuffer = *from32ptr++; - from8ptr = (u8 *) & alignbuffer; + from8ptr = (u8 *) &alignbuffer; -for (i =0 ; i < bytecount; i++) { +for (i =0 ; i < bytecount; i++) *to8ptr++ = *from8ptr++; - } } -static void xemaclite_alignedwrite (void *srcptr,u32 destptr,u32 bytecount) +static void xemaclite_alignedwrite (void *srcptr,u32 destptr,u32 bytecount) {u32 i;u32 alignbuffer;
@@ -114,25 +113,24 @@ static void xemaclite_alignedwrite (void *srcptr, u32 destptr, u32 bytecount) } alignbuffer =0 ; - to8ptr = (u8 *) & alignbuffer; + to8ptr = (u8 *) &alignbuffer; from8ptr = (u8 *) from32ptr; -for (i =0 ; i < bytecount; i++) { +for (i =0 ; i < bytecount; i++) *to8ptr++ = *from8ptr++; - } *to32ptr++ = alignbuffer; }static void emaclite_halt (struct eth_device *dev) { -debug ("eth_halt\n" ); +debug ("eth_halt\n" ); }static int emaclite_init (struct eth_device *dev,bd_t *bis) {struct xemaclite *emaclite = dev->priv; -debug ("EmacLite Initialization Started\n" ); +debug ("EmacLite Initialization Started\n" );/* * TX - TX_PING & TX_PONG initialization
@@ -140,8 +138,7 @@ static int emaclite_init(struct eth_device *dev, bd_t *bis)/* Restart PING TX */ out_be32 (dev->iobase +XEL_TSR_OFFSET ,0 );/* Copy MAC address */ -xemaclite_alignedwrite (dev->enetaddr, - dev->iobase,ENET_ADDR_LENGTH ); +xemaclite_alignedwrite (dev->enetaddr, dev->iobase,ENET_ADDR_LENGTH );/* Set the length */ out_be32 (dev->iobase +XEL_TPLR_OFFSET ,ENET_ADDR_LENGTH );/* Update the MAC address in the EMAC Lite */
@@ -174,7 +171,7 @@ static int emaclite_init(struct eth_device *dev, bd_t *bis)out_be32 (dev->iobase +XEL_RSR_OFFSET +XEL_BUFFER_OFFSET ,XEL_RSR_RECV_IE_MASK ); -debug ("EmacLite Initialization complete\n" ); +debug ("EmacLite Initialization complete\n" );return 0 ; }
@@ -199,10 +196,10 @@ static int xemaclite_txbufferavailable(struct eth_device *dev) txpongbusy = ((reg &XEL_TSR_XMIT_BUSY_MASK ) ==XEL_TSR_XMIT_BUSY_MASK ); -return (!(txpingbusy && txpongbusy)); +return !(txpingbusy && txpongbusy); } -static int emaclite_send (struct eth_device *dev,volatile void *ptr,int len) +static int emaclite_send (struct eth_device *dev,volatile void *ptr,int len) {u32 reg;u32 baseaddress;
@@ -214,12 +211,12 @@ static int emaclite_send (struct eth_device *dev, volatile void *ptr, int len) len =PKTSIZE ;while (!xemaclite_txbufferavailable (dev) && maxtry) { -udelay (10 ); +udelay (10 ); maxtry--; }if (!maxtry) { -printf ("Error: Timeout waiting for ethernet TX buffer\n" ); +printf ("Error: Timeout waiting for ethernet TX buffer\n" );/* Restart PING TX */ out_be32 (dev->iobase +XEL_TSR_OFFSET ,0 );if (emaclite->txpp) {
@@ -241,16 +238,15 @@ static int emaclite_send (struct eth_device *dev, volatile void *ptr, int len)if (emaclite->txpp) emaclite->nexttxbuffertouse ^=XEL_BUFFER_OFFSET ; -debug ("Send packet from 0x%x\n" , baseaddress); +debug ("Send packet from 0x%x\n" , baseaddress);/* Write the frame to the buffer */ -xemaclite_alignedwrite ((void *) ptr, baseaddress, len); +xemaclite_alignedwrite ((void *) ptr, baseaddress, len);out_be32 (baseaddress +XEL_TPLR_OFFSET ,(len & (XEL_TPLR_LENGTH_MASK_HI |XEL_TPLR_LENGTH_MASK_LO ))); reg =in_be32 (baseaddress +XEL_TSR_OFFSET ); reg |=XEL_TSR_XMIT_BUSY_MASK ; -if ((reg &XEL_TSR_XMIT_IE_MASK ) !=0 ) { +if ((reg &XEL_TSR_XMIT_IE_MASK ) !=0 ) reg |=XEL_TSR_XMIT_ACTIVE_MASK ; - }out_be32 (baseaddress +XEL_TSR_OFFSET , reg);return 0 ; }
@@ -278,7 +274,7 @@ static int emaclite_send (struct eth_device *dev, volatile void *ptr, int len) } } -puts ("Error while sending frame\n" ); +puts ("Error while sending frame\n" );return -1 ; }
@@ -291,14 +287,14 @@ static int emaclite_recv(struct eth_device *dev) baseaddress = dev->iobase + emaclite->nextrxbuffertouse; reg =in_be32 (baseaddress +XEL_RSR_OFFSET ); -debug ("Testing data at address 0x%x\n" , baseaddress); +debug ("Testing data at address 0x%x\n" , baseaddress);if ((reg &XEL_RSR_RECV_DONE_MASK ) ==XEL_RSR_RECV_DONE_MASK ) {if (emaclite->rxpp) emaclite->nextrxbuffertouse ^=XEL_BUFFER_OFFSET ; }else {if (!emaclite->rxpp) { -debug ("No data was available - address 0x%x\n" , +debug ("No data was available - address 0x%x\n" , baseaddress);return 0 ; }else {
@@ -317,12 +313,13 @@ static int emaclite_recv(struct eth_device *dev) 0xFFFF0000 ) >> 16) {case 0x806 : length =42 +20 ;/* FIXME size of ARP */ -debug ("ARP Packet\n" ); +debug ("ARP Packet\n" );break ;case 0x800 : length =14 +14 + - (((ntohl (in_be32 (baseaddress +XEL_RXBUFF_OFFSET +0x10 ))) & -0xFFFF0000 ) >>16 );/* FIXME size of IP packet */ + (((ntohl (in_be32 (baseaddress +XEL_RXBUFF_OFFSET + +0x10 ))) &0xFFFF0000 ) >>16 ); +/* FIXME size of IP packet */ debug ("IP Packet\n" );break ;default :
@@ -331,7 +328,7 @@ static int emaclite_recv(struct eth_device *dev)break ; } -xemaclite_alignedread ((u32 *) (baseaddress +XEL_RXBUFF_OFFSET ), +xemaclite_alignedread ((u32 *) (baseaddress +XEL_RXBUFF_OFFSET ), etherrxbuff, length);/* Acknowledge the frame */
@@ -339,8 +336,8 @@ static int emaclite_recv(struct eth_device *dev) reg &= ~XEL_RSR_RECV_DONE_MASK ;out_be32 (baseaddress +XEL_RSR_OFFSET , reg); -debug ("Packet receive from 0x%x, length %dB\n" , baseaddress, length); -NetReceive ((uchar *) etherrxbuff, length); +debug ("Packet receive from 0x%x, length %dB\n" , baseaddress, length); +NetReceive ((uchar *) etherrxbuff, length);return length; }
Signature · 1 line
1.5.5.6
PATCH 3/3 net: emaclite: Fix coding style
Dear Michal Simek,
Quoted 2 lines · In message <[email protected]> you wrote:
Checked by checkpatch.pl script.
No functional changes.
Note : this should go into the comment section (pwclient picked the original submit anyway).
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de There is a time in the tides of men, Which, taken at its flood, leads on to success. On the other hand, don't count on it. - T. K. Lawson
Wolfgang Denk
AppliedPATCH 3/3 net: emaclite: Fix coding style
In reply to Michal SimekDear Michal Simek,
Quoted 7 lines · In message <[email protected]> you wrote:
Checked by checkpatch.pl script.
No functional changes.Signed-off-by Michal Simek <[email protected]>--- drivers/net/xilinx_emaclite.c | 57 +++++++++++++++++++--------------------- 1 files changed, 27 insertions(+), 30 deletions(-)
Applied, thanks.
Best regards,
Wolfgang Denk
Signature · 4 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de Machines take me by surprise with great frequency. - Alan Turing
Wolfgang Denk
AppliedPATCH 2/3 net: emaclite: Use PKTSIZE directly
In reply to Michal SimekDear Michal Simek,
Quoted 6 lines · In message <[email protected]> you wrote:
Do not setup additional
ENET_MAX_MTUmacro.Signed-off-by Michal Simek <[email protected]>--- drivers/net/xilinx_emaclite.c | 10 ++++------ 1 files changed, 4 insertions(+), 6 deletions(-)
Applied, thanks.
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Perl already has an IDE. It's called Unix.
-- Tom Christiansen in 375bd509 at cs.colorado.eduPATCH v2 1/3 net: emaclite: Setup RX/TX ping pong for every instance
In reply to Michal SimekQuoted 10 lines · Michal Simek
Setup RX/TX ping-pong buffer for every emaclite IP separately. The next patch move initialization directly to board code.
Signed-off-by Michal Simek <[email protected]>---
v2: Fix coding style violations--- drivers/net/xilinx_emaclite.c | 123 ++++++++++++++++++++++------------------ 1 files changed, 68 insertions(+), 55 deletions(-)
Any comment? If not please add them to mainline tree. I have two more follow-up patches for emaclite.
Thanks,
Michal
Signature · 4 lines
Michal Simek, Ing. (M.Eng) w: www.monstr.eu p: +42-0-721842854 Maintainer of Linux kernel 2.6 Microblaze Linux - http://www.monstr.eu/fdt/ Microblaze U-BOOT custodian
Wolfgang Denk
AppliedPATCH v2 1/3 net: emaclite: Setup RX/TX ping pong for every instance
In reply to Michal SimekDear Michal Simek,
Quoted 10 lines · In message <[email protected]> you wrote:
Setup RX/TX ping-pong buffer for every emaclite IP separately. The next patch move initialization directly to board code.
Signed-off-by Michal Simek <[email protected]>---
v2: Fix coding style violations--- drivers/net/xilinx_emaclite.c | 123 ++++++++++++++++++++++------------------ 1 files changed, 68 insertions(+), 55 deletions(-)
Applied, thanks.
Best regards,
Wolfgang Denk
Signature · 7 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de Romulan women are not like Vulcan females. We are not dedicated to pure logic and the sterility of non-emotion. -- Romulan Commander, "The Enterprise Incident", stardate 5027.3