
From: "Luis R. Rodriguez" <mcgrof@studorgs.rutgers.edu>

2004-04-26	Margit Schubert-While <margitsw@t-online.de>

- islpci_mgt.h : Replace init_wds with a define.  The compiler does not
  optimize it out (and also generates the field in the ro section of every
  module)

- prismcompat(24).h : Include linux/compiler.h Now we can play with the
  likely/unlikely macros

- islpci_eth.c, islpci_dev.c : Align skb->data unconditonally after
  allocation.  This would appear to improve RX rate.  Do a little bit of
  likely/unlikely.

Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 25-akpm/drivers/net/wireless/prism54/isl_ioctl.c     |    4 +--
 25-akpm/drivers/net/wireless/prism54/islpci_dev.c    |    3 +-
 25-akpm/drivers/net/wireless/prism54/islpci_eth.c    |   20 ++++++++++---------
 25-akpm/drivers/net/wireless/prism54/islpci_mgt.h    |    4 +--
 25-akpm/drivers/net/wireless/prism54/prismcompat.h   |    1 
 25-akpm/drivers/net/wireless/prism54/prismcompat24.h |    2 +
 6 files changed, 20 insertions(+), 14 deletions(-)

diff -puN drivers/net/wireless/prism54/isl_ioctl.c~prism54-start-using-likely-unlikely drivers/net/wireless/prism54/isl_ioctl.c
--- 25/drivers/net/wireless/prism54/isl_ioctl.c~prism54-start-using-likely-unlikely	Wed May 26 16:17:19 2004
+++ 25-akpm/drivers/net/wireless/prism54/isl_ioctl.c	Wed May 26 16:17:19 2004
@@ -1,4 +1,4 @@
-/*  $Header: /var/lib/cvs/prism54-ng/ksrc/isl_ioctl.c,v 1.152 2004/04/17 08:46:04 ajfa Exp $
+/*  $Header: /var/lib/cvs/prism54-ng/ksrc/isl_ioctl.c,v 1.153 2004/04/22 12:20:39 ajfa Exp $
  *  
  *  Copyright (C) 2002 Intersil Americas Inc.
  *            (C) 2003,2004 Aurelien Alleaume <slts@free.fr>
@@ -2146,7 +2146,7 @@ static const struct iw_priv_args prism54
 	{PRISM54_DBG_OID, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0,
 	 "dbg_oid"},
 	{PRISM54_DBG_GET_OID, 0, IW_PRIV_TYPE_BYTE | 256, "dbg_get_oid"},
-	{PRISM54_DBG_SET_OID, IW_PRIV_TYPE_BYTE | 256, 0, "dbg_get_oid"},
+	{PRISM54_DBG_SET_OID, IW_PRIV_TYPE_BYTE | 256, 0, "dbg_set_oid"},
 	/* --- sub-ioctls handlers --- */
 	{PRISM54_GET_OID,
 	 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | PRIV_STR_SIZE, ""},
diff -puN drivers/net/wireless/prism54/islpci_dev.c~prism54-start-using-likely-unlikely drivers/net/wireless/prism54/islpci_dev.c
--- 25/drivers/net/wireless/prism54/islpci_dev.c~prism54-start-using-likely-unlikely	Wed May 26 16:17:19 2004
+++ 25-akpm/drivers/net/wireless/prism54/islpci_dev.c	Wed May 26 16:17:19 2004
@@ -1,4 +1,4 @@
-/*  $Header: /var/lib/cvs/prism54-ng/ksrc/islpci_dev.c,v 1.76 2004/04/19 18:33:45 ajfa Exp $
+/*  $Header: /var/lib/cvs/prism54-ng/ksrc/islpci_dev.c,v 1.77 2004/04/26 10:09:58 msw Exp $
  *  
  *  Copyright (C) 2002 Intersil Americas Inc.
  *  Copyright (C) 2003 Herbert Valerio Riedel <hvr@gnu.org>
@@ -560,6 +560,7 @@ islpci_alloc_memory(islpci_private *priv
 			skb = NULL;
 			goto out_free;
 		}
+		skb_reserve(skb, (4 - (long) skb->data) & 0x03);
 		/* add the new allocated sk_buff to the buffer array */
 		priv->data_low_rx[counter] = skb;
 
diff -puN drivers/net/wireless/prism54/islpci_eth.c~prism54-start-using-likely-unlikely drivers/net/wireless/prism54/islpci_eth.c
--- 25/drivers/net/wireless/prism54/islpci_eth.c~prism54-start-using-likely-unlikely	Wed May 26 16:17:19 2004
+++ 25-akpm/drivers/net/wireless/prism54/islpci_eth.c	Wed May 26 16:17:19 2004
@@ -1,4 +1,4 @@
-/*  $Header: /var/lib/cvs/prism54-ng/ksrc/islpci_eth.c,v 1.35 2004/03/20 16:58:36 mcgrof Exp $
+/*  $Header: /var/lib/cvs/prism54-ng/ksrc/islpci_eth.c,v 1.36 2004/04/26 10:09:58 msw Exp $
  *  
  *  Copyright (C) 2002 Intersil Americas Inc.
  *  Copyright (C) 2004 Aurelien Alleaume <slts@free.fr>
@@ -105,7 +105,7 @@ islpci_eth_transmit(struct sk_buff *skb,
 
 	/* check whether the destination queue has enough fragments for the frame */
 	curr_frag = le32_to_cpu(cb->driver_curr_frag[ISL38XX_CB_TX_DATA_LQ]);
-	if (curr_frag - priv->free_data_tx >= ISL38XX_CB_TX_QSIZE) {
+	if (unlikely(curr_frag - priv->free_data_tx >= ISL38XX_CB_TX_QSIZE)) {
 		printk(KERN_ERR "%s: transmit device queue full when awake\n",
 		       ndev->name);
 		netif_stop_queue(ndev);
@@ -121,7 +121,7 @@ islpci_eth_transmit(struct sk_buff *skb,
 	/* Check alignment and WDS frame formatting. The start of the packet should
 	 * be aligned on a 4-byte boundary. If WDS is enabled add another 6 bytes
 	 * and add WDS address information */
-	if (((long) skb->data & 0x03) | init_wds) {
+	if (unlikely(((long) skb->data & 0x03) | init_wds)) {
 		/* get the number of bytes to add and re-allign */
 		offset = (4 - (long) skb->data) & 0x03;
 		offset += init_wds ? 6 : 0;
@@ -192,7 +192,7 @@ islpci_eth_transmit(struct sk_buff *skb,
 	pci_map_address = pci_map_single(priv->pdev,
 					 (void *) skb->data, skb->len,
 					 PCI_DMA_TODEVICE);
-	if (pci_map_address == 0) {
+	if (unlikely(pci_map_address == 0)) {
 		printk(KERN_WARNING "%s: cannot map buffer to PCI\n",
 		       ndev->name);
 
@@ -382,10 +382,10 @@ islpci_eth_receive(islpci_private *priv)
 	skb->dev = ndev;
 
 	/* take care of monitor mode and spy monitoring. */
-	if (priv->iw_mode == IW_MODE_MONITOR)
+	if (unlikely(priv->iw_mode == IW_MODE_MONITOR))
 		discard = islpci_monitor_rx(priv, &skb);
 	else {
-		if (skb->data[2 * ETH_ALEN] == 0) {
+		if (unlikely(skb->data[2 * ETH_ALEN] == 0)) {
 			/* The packet has a rx_annex. Read it for spy monitoring, Then
 			 * remove it, while keeping the 2 leading MAC addr.
 			 */
@@ -418,7 +418,7 @@ islpci_eth_receive(islpci_private *priv)
 	     skb->data[0], skb->data[1], skb->data[2], skb->data[3],
 	     skb->data[4], skb->data[5]);
 #endif
-	if (discard) {
+	if (unlikely(discard)) {
 		dev_kfree_skb(skb);
 		skb = NULL;
 	} else
@@ -434,11 +434,13 @@ islpci_eth_receive(islpci_private *priv)
 	       index - priv->free_data_rx < ISL38XX_CB_RX_QSIZE) {
 		/* allocate an sk_buff for received data frames storage
 		 * include any required allignment operations */
-		if (skb = dev_alloc_skb(MAX_FRAGMENT_SIZE_RX + 2), skb == NULL) {
+		skb = dev_alloc_skb(MAX_FRAGMENT_SIZE_RX + 2);
+		if (unlikely(skb == NULL)) {
 			/* error allocating an sk_buff structure elements */
 			DEBUG(SHOW_ERROR_MESSAGES, "Error allocating skb \n");
 			break;
 		}
+		skb_reserve(skb, (4 - (long) skb->data) & 0x03);
 		/* store the new skb structure pointer */
 		index = index % ISL38XX_CB_RX_QSIZE;
 		priv->data_low_rx[index] = skb;
@@ -454,7 +456,7 @@ islpci_eth_receive(islpci_private *priv)
 		    pci_map_single(priv->pdev, (void *) skb->data,
 				   MAX_FRAGMENT_SIZE_RX + 2,
 				   PCI_DMA_FROMDEVICE);
-		if (priv->pci_map_rx_address[index] == (dma_addr_t) NULL) {
+		if (unlikely(priv->pci_map_rx_address[index] == (dma_addr_t) NULL)) {
 			/* error mapping the buffer to device accessable memory address */
 			DEBUG(SHOW_ERROR_MESSAGES,
 			      "Error mapping DMA address\n");
diff -puN drivers/net/wireless/prism54/islpci_mgt.h~prism54-start-using-likely-unlikely drivers/net/wireless/prism54/islpci_mgt.h
--- 25/drivers/net/wireless/prism54/islpci_mgt.h~prism54-start-using-likely-unlikely	Wed May 26 16:17:19 2004
+++ 25-akpm/drivers/net/wireless/prism54/islpci_mgt.h	Wed May 26 16:17:19 2004
@@ -1,4 +1,4 @@
-/*  $Header: /var/lib/cvs/prism54-ng/ksrc/islpci_mgt.h,v 1.25 2004/03/20 16:58:37 mcgrof Exp $
+/*  $Header: /var/lib/cvs/prism54-ng/ksrc/islpci_mgt.h,v 1.26 2004/04/26 10:09:58 msw Exp $
  *  
  *  Copyright (C) 2002 Intersil Americas Inc.
  *  Copyright (C) 2003 Luis R. Rodriguez <mcgrof@ruslug.rutgers.edu>
@@ -34,7 +34,7 @@
 #define TRACE(devname)   K_DEBUG(SHOW_TRACING, VERBOSE, "%s:  -> " __FUNCTION__ "()\n", devname)
 
 extern int pc_debug;
-static const int init_wds = 0;	/* help compiler optimize away dead code */
+#define init_wds   0	/* help compiler optimize away dead code */
 
 
 /* General driver definitions */
diff -puN drivers/net/wireless/prism54/prismcompat24.h~prism54-start-using-likely-unlikely drivers/net/wireless/prism54/prismcompat24.h
--- 25/drivers/net/wireless/prism54/prismcompat24.h~prism54-start-using-likely-unlikely	Wed May 26 16:17:19 2004
+++ 25-akpm/drivers/net/wireless/prism54/prismcompat24.h	Wed May 26 16:17:19 2004
@@ -26,6 +26,8 @@
 #include <linux/firmware.h>
 #include <linux/config.h>
 #include <linux/tqueue.h>
+#include <linux/version.h>
+#include <linux/compiler.h>
 
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,25)
 #define module_param(x, y, z)	MODULE_PARM(x, "i")
diff -puN drivers/net/wireless/prism54/prismcompat.h~prism54-start-using-likely-unlikely drivers/net/wireless/prism54/prismcompat.h
--- 25/drivers/net/wireless/prism54/prismcompat.h~prism54-start-using-likely-unlikely	Wed May 26 16:17:19 2004
+++ 25-akpm/drivers/net/wireless/prism54/prismcompat.h	Wed May 26 16:17:19 2004
@@ -32,6 +32,7 @@
 #include <linux/config.h>
 #include <linux/moduleparam.h>
 #include <linux/workqueue.h>
+#include <linux/compiler.h>
 
 #if !defined(CONFIG_FW_LOADER) && !defined(CONFIG_FW_LOADER_MODULE)
 #error Firmware Loading is not configured in the kernel !
_
