Skip to contentSkip to conversation

bnx2x: annotate struct eth_tx_db_data

PATCH In review Harvey Harrison 2 participants 2 messages Jan 21, 2009 – Jan 22, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 2/9 bnx2x: annotate struct eth_tx_db_data

Always treated as little-endian values, annotate as such, use the leXX_add_cpu helpers rather than opencoded byteswapping.

---
 drivers/net/bnx2x_hsi.h  |    4 ++--
 drivers/net/bnx2x_main.c |   12 ++++--------
 2 files changed, 6 insertions(+), 10 deletions(-)
drivers/net/bnx2x_hsi.h +2 -2
index efd7644..a3c1068 100644
@@ -2355,8 +2355,8 @@ struct eth_spe {
  * doorbell data in host memory
  */
 struct eth_tx_db_data {
-	u32 packets_prod;
-	u16 bds_prod;
+	__le32 packets_prod;
+	__le16 bds_prod;
 	u16 reserved;
 };
 
drivers/net/bnx2x_main.c +4 -8
index 897f370..2f8d64c 100644
@@ -8774,11 +8774,9 @@ static int bnx2x_run_loopback(struct bnx2x *bp, int loopback_mode, u8 link_up)
 
 	wmb();
 
-	fp->hw_tx_prods->bds_prod =
-		cpu_to_le16(le16_to_cpu(fp->hw_tx_prods->bds_prod) + 1);
+	le16_add_cpu(&fp->hw_tx_prods->bds_prod, 1);
 	mb(); /* FW restriction: must not reorder writing nbd and packets */
-	fp->hw_tx_prods->packets_prod =
-		cpu_to_le32(le32_to_cpu(fp->hw_tx_prods->packets_prod) + 1);
+	le32_add_cpu(&fp->hw_tx_prods->packets_prod, 1);
 	DOORBELL(bp, fp->index, 0);
 
 	mmiowb();
@@ -9774,11 +9772,9 @@ static int bnx2x_start_xmit(struct sk_buff *skb, struct net_device *dev)
 	 */
 	wmb();
 
-	fp->hw_tx_prods->bds_prod =
-		cpu_to_le16(le16_to_cpu(fp->hw_tx_prods->bds_prod) + nbd);
+	le16_add_cpu(&fp->hw_tx_prods->bds_prod, nbd);
 	mb(); /* FW restriction: must not reorder writing nbd and packets */
-	fp->hw_tx_prods->packets_prod =
-		cpu_to_le32(le32_to_cpu(fp->hw_tx_prods->packets_prod) + 1);
+	le32_add_cpu(&fp->hw_tx_prods->packets_prod, 1);
 	DOORBELL(bp, fp->index, 0);
 
 	mmiowb();
Signature · 1 line
1.6.1.249.g455e5
#1 lore raw
Quoted 4 lines · Harvey Harrison

Always treated as little-endian values, annotate as such, use the leXX_add_cpu helpers rather than opencoded byteswapping.

The next few patches are similar, and I feel more comfortable combining them. I will try to follow your lead and will work on a suggestion that will complete this task in the next couple of days. I rather not to submit it half-backed.

Thanks,
Eilon