Skip to contentSkip to conversation

Fix dm9000 receive status and len little endian issue

PATCH New Tsi-Chung Liew 2 participants 6 messages Jun 25, 2008 – Jul 2, 2008 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix dm9000 receive status and len little endian issue

From: TsiChung Liew <[email protected]>

The received status and len was in little endian format and caused the ethernet unable to proceed further. Add __le16_to_cpu() in dm9000_rx_status_8/16/32bit().

---
 drivers/net/dm9000x.c |   16 ++++++++++------
 1 files changed, 10 insertions(+), 6 deletions(-)
drivers/net/dm9000x.c +10 -6
index 844fb76..e7365fe 100644
@@ -214,24 +214,28 @@ static void dm9000_rx_status_32bit(u16 *RxStatus, u16 *RxLen)
 	DM9000_outb(DM9000_MRCMD, DM9000_IO);
 
 	tmpdata = DM9000_inl(DM9000_DATA);
-	*RxStatus = tmpdata;
-	*RxLen = tmpdata >> 16;
+	*RxStatus = __le16_to_cpu(tmpdata);
+	*RxLen = __le16_to_cpu(tmpdata >> 16);
 }
 
 static void dm9000_rx_status_16bit(u16 *RxStatus, u16 *RxLen)
 {
 	DM9000_outb(DM9000_MRCMD, DM9000_IO);
 
-	*RxStatus = DM9000_inw(DM9000_DATA);
-	*RxLen = DM9000_inw(DM9000_DATA);
+	*RxStatus = __le16_to_cpu(DM9000_inw(DM9000_DATA));
+	*RxLen = __le16_to_cpu(DM9000_inw(DM9000_DATA));
 }
 
 static void dm9000_rx_status_8bit(u16 *RxStatus, u16 *RxLen)
 {
 	DM9000_outb(DM9000_MRCMD, DM9000_IO);
 
-	*RxStatus = DM9000_inb(DM9000_DATA) + (DM9000_inb(DM9000_DATA) << 8);
-	*RxLen = DM9000_inb(DM9000_DATA) + (DM9000_inb(DM9000_DATA) << 8);
+	*RxStatus =
+	    __le16_to_cpu(DM9000_inb(DM9000_DATA) +
+			  (DM9000_inb(DM9000_DATA) << 8));
+	*RxLen =
+	    __le16_to_cpu(DM9000_inb(DM9000_DATA) +
+			  (DM9000_inb(DM9000_DATA) << 8));
 }
 
 /*
Signature · 1 line
1.5.4.1
#1 lore raw

PATCH 1/1 Fix dm9000 receive status and len little endian issue

Quoted 41 lines · Tsi-Chung Liew

From: TsiChung Liew <[email protected]>

The received status and len was in little endian format and caused the ethernet unable to proceed further. Add __le16_to_cpu() in dm9000_rx_status_8/16/32bit().

---
 drivers/net/dm9000x.c |   16 ++++++++++------
 1 files changed, 10 insertions(+), 6 deletions(-)
drivers/net/dm9000x.c +4 -5
index 844fb76..e7365fe 100644
@@ -214,24 +214,28 @@ static void dm9000_rx_status_32bit(u16 *RxStatus, u16 *RxLen)
 	DM9000_outb(DM9000_MRCMD, DM9000_IO);
 
 	tmpdata = DM9000_inl(DM9000_DATA);
-	*RxStatus = tmpdata;
-	*RxLen = tmpdata >> 16;
+	*RxStatus = __le16_to_cpu(tmpdata);
+	*RxLen = __le16_to_cpu(tmpdata >> 16);
 }
 
 static void dm9000_rx_status_16bit(u16 *RxStatus, u16 *RxLen)
 {
 	DM9000_outb(DM9000_MRCMD, DM9000_IO);
 
-	*RxStatus = DM9000_inw(DM9000_DATA);
-	*RxLen = DM9000_inw(DM9000_DATA);
+	*RxStatus = __le16_to_cpu(DM9000_inw(DM9000_DATA));
+	*RxLen = __le16_to_cpu(DM9000_inw(DM9000_DATA));
 }
 
 static void dm9000_rx_status_8bit(u16 *RxStatus, u16 *RxLen)
 {
 	DM9000_outb(DM9000_MRCMD, DM9000_IO);
 
-	*RxStatus = DM9000_inb(DM9000_DATA) + (DM9000_inb(DM9000_DATA) << 8);

drivers/net/dm9000x.c static void dm9000_rx_status_32bit(u16 *RxStatus, u16 *RxLen) · line 241

Quoted 10 lines
drivers/net/dm9000x.c +6 -1
-	*RxLen = DM9000_inb(DM9000_DATA) + (DM9000_inb(DM9000_DATA) << 8);
+	*RxStatus =
+	    __le16_to_cpu(DM9000_inb(DM9000_DATA) +
+			  (DM9000_inb(DM9000_DATA) << 8));
+	*RxLen =
+	    __le16_to_cpu(DM9000_inb(DM9000_DATA) +
+			  (DM9000_inb(DM9000_DATA) << 8));
 }
 
 /*

Sorry for opening Pandora's box, but wouldn't it be better to redefine the DM9000_x macros instead of where they're called?

regards,
Ben

#2 lore raw

PATCH 1/1 Fix dm9000 receive status and len little endian issue

Ben,

The data (packet data) and the status/len are different in
LE/BE, cannot use just the macro dm9000_x to cover both. In my case, packet data is already in BE, but the status/len is in LE; therefore, status/len require byteswap. This has to do with cpu endian mode.

Regards,
TsiChung

-----Original Message-----
From: Ben Warren [mailto:biggerbadderben at gmail.com]
Sent: Wednesday, June 25, 2008 4:01 PM
To: Liew Tsi Chung
Cc: U-Boot-Users; Rigby John
Subject: Re: [PATCH] Fix dm9000 receive status and len little endian issue

drivers/net/dm9000x.c static void dm9000_rx_status_32bit(u16

Quoted 17 lines · Tsi-Chung Liew

From: TsiChung Liew <[email protected]>

The received status and len was in little endian format and caused the

ethernet unable to proceed further. Add __le16_to_cpu() in dm9000_rx_status_8/16/32bit().

---
 drivers/net/dm9000x.c |   16 ++++++++++------
 1 files changed, 10 insertions(+), 6 deletions(-)
drivers/net/dm9000x.c index renamed from drivers/net/dm9000x.c +0 -0

844fb76..e7365fe 100644

drivers/net/dm9000x.c +0 -0
@@ -214,24 +214,28 @@ static void dm9000_rx_status_32bit(u16

*RxStatus, u16 *RxLen)

Quoted 12 lines
drivers/net/dm9000x.c +2 -2
 	DM9000_outb(DM9000_MRCMD, DM9000_IO);
 
 	tmpdata = DM9000_inl(DM9000_DATA);
-	*RxStatus = tmpdata;
-	*RxLen = tmpdata >> 16;
+	*RxStatus = __le16_to_cpu(tmpdata);
+	*RxLen = __le16_to_cpu(tmpdata >> 16);
 }
 
 static void dm9000_rx_status_16bit(u16 *RxStatus, u16 *RxLen)  {
 	DM9000_outb(DM9000_MRCMD, DM9000_IO);
 

drivers/net/dm9000x.c static void dm9000_rx_status_32bit(u16 *RxStatus, u16 *RxLen)

Quoted 10 lines
drivers/net/dm9000x.c +2 -3
-	*RxStatus = DM9000_inw(DM9000_DATA);
-	*RxLen = DM9000_inw(DM9000_DATA);
+	*RxStatus = __le16_to_cpu(DM9000_inw(DM9000_DATA));
+	*RxLen = __le16_to_cpu(DM9000_inw(DM9000_DATA));
 }
 
 static void dm9000_rx_status_8bit(u16 *RxStatus, u16 *RxLen)  {
 	DM9000_outb(DM9000_MRCMD, DM9000_IO);
 
-	*RxStatus = DM9000_inb(DM9000_DATA) + (DM9000_inb(DM9000_DATA)

<< 8);

drivers/net/dm9000x.c static void dm9000_rx_status_32bit(u16 · line 232

Quoted 1 line
drivers/net/dm9000x.c +0 -1
-	*RxLen = DM9000_inb(DM9000_DATA) + (DM9000_inb(DM9000_DATA) <<

8);

drivers/net/dm9000x.c static void dm9000_rx_status_32bit(u16 *RxStatus, u16 *RxLen)

Quoted 10 lines
drivers/net/dm9000x.c +6 -0
+	*RxStatus =
+	    __le16_to_cpu(DM9000_inb(DM9000_DATA) +
+			  (DM9000_inb(DM9000_DATA) << 8));
+	*RxLen =
+	    __le16_to_cpu(DM9000_inb(DM9000_DATA) +
+			  (DM9000_inb(DM9000_DATA) << 8));
 }
 
 /*
 

Sorry for opening Pandora's box, but wouldn't it be better to redefine the DM9000_x macros instead of where they're called?

regards,
Ben

#4 lore raw

PATCH 1/1 Fix dm9000 receive status and len little endian issue

Quoted 8 lines · Liew Tsi Chung

Ben,

May I know the status on this patch?

Regards,
TsiChung

Sorry, I'll address it tonight.

regards,
Ben