netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] [DM9000] Added support for big-endian hosts
@ 2007-08-16  8:15 Laurent Pinchart
  2007-08-16 17:00 ` Ben Dooks
  2007-08-25  4:31 ` Jeff Garzik
  0 siblings, 2 replies; 4+ messages in thread
From: Laurent Pinchart @ 2007-08-16  8:15 UTC (permalink / raw)
  To: netdev; +Cc: Ben Dooks

This patch splits the receive status in 8bit wide fields and convert the
packet length from little endian to CPU byte order.

Signed-off-by: Laurent Pinchart <laurentp@cse-semaphore.com>
---
 drivers/net/dm9000.c |   13 +++++++------
 1 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/net/dm9000.c b/drivers/net/dm9000.c
index c3de81b..a424810 100644
--- a/drivers/net/dm9000.c
+++ b/drivers/net/dm9000.c
@@ -894,7 +894,8 @@ dm9000_timer(unsigned long data)
 }
 
 struct dm9000_rxhdr {
-	u16	RxStatus;
+	u8	RxPktReady;
+	u8	RxStatus;
 	u16	RxLen;
 } __attribute__((__packed__));
 
@@ -935,7 +936,7 @@ dm9000_rx(struct net_device *dev)
 
 		(db->inblk)(db->io_data, &rxhdr, sizeof(rxhdr));
 
-		RxLen = rxhdr.RxLen;
+		RxLen = le16_to_cpu(rxhdr.RxLen);
 
 		/* Packet Status check */
 		if (RxLen < 0x40) {
@@ -947,17 +948,17 @@ dm9000_rx(struct net_device *dev)
 			PRINTK1("RST: RX Len:%x\n", RxLen);
 		}
 
-		if (rxhdr.RxStatus & 0xbf00) {
+		if (rxhdr.RxStatus & 0xbf) {
 			GoodPacket = false;
-			if (rxhdr.RxStatus & 0x100) {
+			if (rxhdr.RxStatus & 0x01) {
 				PRINTK1("fifo error\n");
 				db->stats.rx_fifo_errors++;
 			}
-			if (rxhdr.RxStatus & 0x200) {
+			if (rxhdr.RxStatus & 0x02) {
 				PRINTK1("crc error\n");
 				db->stats.rx_crc_errors++;
 			}
-			if (rxhdr.RxStatus & 0x8000) {
+			if (rxhdr.RxStatus & 0x80) {
 				PRINTK1("length error\n");
 				db->stats.rx_length_errors++;
 			}
-- 
1.5.0

-- 
Laurent Pinchart
CSE Semaphore Belgium

Chaussée de Bruxelles, 732A
B-1410 Waterloo
Belgium

T +32 (2) 387 42 59
F +32 (2) 387 42 75

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] [DM9000] Added support for big-endian hosts
  2007-08-16  8:15 [PATCH 1/2] [DM9000] Added support for big-endian hosts Laurent Pinchart
@ 2007-08-16 17:00 ` Ben Dooks
  2007-08-25  4:31 ` Jeff Garzik
  1 sibling, 0 replies; 4+ messages in thread
From: Ben Dooks @ 2007-08-16 17:00 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: netdev, Ben Dooks

On Thu, Aug 16, 2007 at 10:15:35AM +0200, Laurent Pinchart wrote:
> This patch splits the receive status in 8bit wide fields and convert the
> packet length from little endian to CPU byte order.
> 
> Signed-off-by: Laurent Pinchart <laurentp@cse-semaphore.com>
Acked-by: Ben Dooks <ben-linux@fluff.org>
> ---
>  drivers/net/dm9000.c |   13 +++++++------
>  1 files changed, 7 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/net/dm9000.c b/drivers/net/dm9000.c
> index c3de81b..a424810 100644
> --- a/drivers/net/dm9000.c
> +++ b/drivers/net/dm9000.c
> @@ -894,7 +894,8 @@ dm9000_timer(unsigned long data)
>  }
>  
>  struct dm9000_rxhdr {
> -	u16	RxStatus;
> +	u8	RxPktReady;
> +	u8	RxStatus;
>  	u16	RxLen;
>  } __attribute__((__packed__));
>  
> @@ -935,7 +936,7 @@ dm9000_rx(struct net_device *dev)
>  
>  		(db->inblk)(db->io_data, &rxhdr, sizeof(rxhdr));
>  
> -		RxLen = rxhdr.RxLen;
> +		RxLen = le16_to_cpu(rxhdr.RxLen);
>  
>  		/* Packet Status check */
>  		if (RxLen < 0x40) {
> @@ -947,17 +948,17 @@ dm9000_rx(struct net_device *dev)
>  			PRINTK1("RST: RX Len:%x\n", RxLen);
>  		}
>  
> -		if (rxhdr.RxStatus & 0xbf00) {
> +		if (rxhdr.RxStatus & 0xbf) {
>  			GoodPacket = false;
> -			if (rxhdr.RxStatus & 0x100) {
> +			if (rxhdr.RxStatus & 0x01) {
>  				PRINTK1("fifo error\n");
>  				db->stats.rx_fifo_errors++;
>  			}
> -			if (rxhdr.RxStatus & 0x200) {
> +			if (rxhdr.RxStatus & 0x02) {
>  				PRINTK1("crc error\n");
>  				db->stats.rx_crc_errors++;
>  			}
> -			if (rxhdr.RxStatus & 0x8000) {
> +			if (rxhdr.RxStatus & 0x80) {
>  				PRINTK1("length error\n");
>  				db->stats.rx_length_errors++;
>  			}
> -- 
> 1.5.0
> 
> -- 
> Laurent Pinchart
> CSE Semaphore Belgium
> 
> Chauss?e de Bruxelles, 732A
> B-1410 Waterloo
> Belgium
> 
> T +32 (2) 387 42 59
> F +32 (2) 387 42 75
> -
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

-- 
Ben (ben@fluff.org, http://www.fluff.org/)

  'a smiley only costs 4 bytes'

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] [DM9000] Added support for big-endian hosts
  2007-08-16  8:15 [PATCH 1/2] [DM9000] Added support for big-endian hosts Laurent Pinchart
  2007-08-16 17:00 ` Ben Dooks
@ 2007-08-25  4:31 ` Jeff Garzik
  2007-08-27  7:51   ` Laurent Pinchart
  1 sibling, 1 reply; 4+ messages in thread
From: Jeff Garzik @ 2007-08-25  4:31 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: netdev, Ben Dooks

Laurent Pinchart wrote:
> This patch splits the receive status in 8bit wide fields and convert the
> packet length from little endian to CPU byte order.
> 
> Signed-off-by: Laurent Pinchart <laurentp@cse-semaphore.com>
> ---
>  drivers/net/dm9000.c |   13 +++++++------
>  1 files changed, 7 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/net/dm9000.c b/drivers/net/dm9000.c
> index c3de81b..a424810 100644
> --- a/drivers/net/dm9000.c
> +++ b/drivers/net/dm9000.c
> @@ -894,7 +894,8 @@ dm9000_timer(unsigned long data)
>  }
>  
>  struct dm9000_rxhdr {
> -	u16	RxStatus;
> +	u8	RxPktReady;
> +	u8	RxStatus;
>  	u16	RxLen;
>  } __attribute__((__packed__));

why does this not need endian conversions as well?

	Jeff




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] [DM9000] Added support for big-endian hosts
  2007-08-25  4:31 ` Jeff Garzik
@ 2007-08-27  7:51   ` Laurent Pinchart
  0 siblings, 0 replies; 4+ messages in thread
From: Laurent Pinchart @ 2007-08-27  7:51 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: netdev, Ben Dooks

On Saturday 25 August 2007 06:31, Jeff Garzik wrote:
> Laurent Pinchart wrote:
> > This patch splits the receive status in 8bit wide fields and convert the
> > packet length from little endian to CPU byte order.
> >
> > Signed-off-by: Laurent Pinchart <laurentp@cse-semaphore.com>
> > ---
> >  drivers/net/dm9000.c |   13 +++++++------
> >  1 files changed, 7 insertions(+), 6 deletions(-)
> >
> > diff --git a/drivers/net/dm9000.c b/drivers/net/dm9000.c
> > index c3de81b..a424810 100644
> > --- a/drivers/net/dm9000.c
> > +++ b/drivers/net/dm9000.c
> > @@ -894,7 +894,8 @@ dm9000_timer(unsigned long data)
> >  }
> >
> >  struct dm9000_rxhdr {
> > -	u16	RxStatus;
> > +	u8	RxPktReady;
> > +	u8	RxStatus;
> >  	u16	RxLen;
> >  } __attribute__((__packed__));
>
> why does this not need endian conversions as well?
>
> 	Jeff

The rx header is a 4-byte structure layed out as above (packet ready, status 
and length). The first two fields are 8-bit wide so don't need endian 
conversion. The length field is a 16-bit big endian value which is converted 
to CPU order in dm9000_rx().

Before this patch, the driver accessed the status and packet ready fields as a 
16-bit value, which was obviously endianess-dependant.

Best regards,

-- 
Laurent Pinchart
CSE Semaphore Belgium

Chaussée de Bruxelles, 732A
B-1410 Waterloo
Belgium

T +32 (2) 387 42 59
F +32 (2) 387 42 75

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-08-27  7:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-08-16  8:15 [PATCH 1/2] [DM9000] Added support for big-endian hosts Laurent Pinchart
2007-08-16 17:00 ` Ben Dooks
2007-08-25  4:31 ` Jeff Garzik
2007-08-27  7:51   ` Laurent Pinchart

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).