Re: [PATCH] natsemi: netpoll fixes

2007-03-11 Thread Mark Brown
On Sat, Mar 10, 2007 at 11:25:05PM +0300, Sergei Shtylyov wrote:

Oops, I was going to recast the patch but my attention switched 
elsewhere for couple of days, and it slipped into mainline. I'm now 
 preparing a better patch to also protect...

Ah, I was also looking at it.  I enclose my current patch which appears
to work although I have not finished testing it yet.

 interrupt handler, check the dev-state __LINK_STATE_SCHED flag - if 
 it's set, leave immediately, it can't be our interrupt. If it's clear, 
 read the irq enable hardware register.  If enabled, do the rest of the 
 interrupt handler.

It seems that there's no need to read it, as it gets set to 0 
 synchronously with setting the 'hands_off' flag (except in NAPI 
 callback)...

hands_off is stronger than that - it's used for sync with some of the
other code paths like suspend/resume and means don't touch the chip.
I've added a new driver local flag instead.

Yeah, it seems currently unjustified.  However IntrEnable would have 
been an ultimate criterion on taking or ignoring an interrupt otherwise...

 I guess the tradeoff depends on the probability 
 of getting the isr called when NAPI is active for the device.

Didn't get it... :-/

Some systems can provoke this fairly easily - Sokeris have some boards
where at least three natsemis share a single interrupt line, for example
(the model I'm looking at has three, they look to have another
configuration where 5 would end up on the line).

BTW, it seems I've found another interrupt lossage path in the driver:

 netdev_poll() - netdev_rx() - reset_rx()

 If the netdev_rx() detects an oversized packet, it will call reset_rx() 
 which will spin in a loop collecting interrupt status until it sees 
 RxResetDone there.  The issue is 'intr_status' field will get overwritten 
 and interrupt status lost after netdev_rx() returns to netdev_poll().  How 
 do you think, is this corner case worth fixing (by moving netdev_rx() call
 to the top of a do/while loop)?

Moving netdev_rx() would fix that one but there's some others too -
there's one in the timer routine if the chip crashes.  In the case you
describe above the consequences shouldn't be too bad since it tends to
only occur at high volume so further traffic will tend to occur and
cause things to recover - all the testing of that patch was done with
the bug present and no ill effects.

Subject: natsemi: Fix NAPI for interrupt sharing
To: Jeff Garzik [EMAIL PROTECTED]
Cc: Sergei Shtylyov [EMAIL PROTECTED], Simon Blake [EMAIL PROTECTED], John 
Philips [EMAIL PROTECTED], netdev@vger.kernel.org

The interrupt status register for the natsemi chips is clear on read and
was read unconditionally from both the interrupt and from the NAPI poll
routine, meaning that if the interrupt service routine was called (for 
example, due to a shared interrupt) while a NAPI poll was scheduled
interrupts could be missed.  This patch fixes that by ensuring that the
interrupt status register is only read when there is no poll scheduled.

It also reverts a workaround for this problem from the netpoll hook.

Thanks to Sergei Shtylyov [EMAIL PROTECTED] for spotting the
issue and Simon Blake [EMAIL PROTECTED] for testing resources.

Signed-Off-By: Mark Brown [EMAIL PROTECTED]

Index: linux-2.6/drivers/net/natsemi.c
===
--- linux-2.6.orig/drivers/net/natsemi.c2007-03-11 02:32:43.0 
+
+++ linux-2.6/drivers/net/natsemi.c 2007-03-11 12:09:14.0 +
@@ -571,6 +571,8 @@
int oom;
/* Interrupt status */
u32 intr_status;
+   int poll_active;
+   spinlock_t intr_lock;
/* Do not touch the nic registers */
int hands_off;
/* Don't pay attention to the reported link state. */
@@ -812,9 +814,11 @@
pci_set_drvdata(pdev, dev);
np-iosize = iosize;
spin_lock_init(np-lock);
+   spin_lock_init(np-intr_lock);
np-msg_enable = (debug = 0) ? (1debug)-1 : NATSEMI_DEF_MSG;
np-hands_off = 0;
np-intr_status = 0;
+   np-poll_active = 0;
np-eeprom_size = natsemi_pci_info[chip_idx].eeprom_size;
if (natsemi_pci_info[chip_idx].flags  NATSEMI_FLAG_IGNORE_PHY)
np-ignore_phy = 1;
@@ -1406,6 +1410,8 @@
writel(rfcr, ioaddr + RxFilterAddr);
 }
 
+/* MUST be called so that both NAPI poll and ISR are excluded due to
+ * use of intr_status. */
 static void reset_rx(struct net_device *dev)
 {
int i;
@@ -2118,30 +2124,45 @@
struct net_device *dev = dev_instance;
struct netdev_private *np = netdev_priv(dev);
void __iomem * ioaddr = ns_ioaddr(dev);
+   unsigned long flags;
+   irqreturn_t status = IRQ_NONE;
 
if (np-hands_off)
return IRQ_NONE;
 
-   /* Reading automatically acknowledges. */
-   np-intr_status = readl(ioaddr + IntrStatus);
-
-   if (netif_msg_intr(np))
-  

[PATCH] Attempt to add suspend/resume support to uli526x

2007-03-11 Thread Rafael J. Wysocki
Hi,

The uli526x network driver doesn't implement .suspend and .resume methods
and the interface handled by it is unuseable after the resume.  Since I have
one of these boards in a box which is used to test the suspend/resume
functionality, I've prepared the appended patch that adds the .suspend and
.resume routines to the uli526x driver based on the ones implemented by 3c59x.

Please have a look at it and let me know if there's anything wrong with it (it
seems to work and doesn't seem to break anything).

Greetings,
Rafael

---
 drivers/net/tulip/uli526x.c |  125 ++--
 1 file changed, 110 insertions(+), 15 deletions(-)

Index: linux-2.6.21-rc3-mm2/drivers/net/tulip/uli526x.c
===
--- linux-2.6.21-rc3-mm2.orig/drivers/net/tulip/uli526x.c   2007-02-04 
19:44:54.0 +0100
+++ linux-2.6.21-rc3-mm2/drivers/net/tulip/uli526x.c2007-03-11 
14:24:29.0 +0100
@@ -425,21 +425,14 @@ static void __devexit uli526x_remove_one
 
 
 /*
- * Open the interface.
- * The interface is opened whenever ifconfig activates it.
+ * Bring the interface up.
+ * Used by uli526x_open and uli526x_resume.
  */
 
-static int uli526x_open(struct net_device *dev)
+static void uli526x_up(struct net_device *dev)
 {
-   int ret;
struct uli526x_board_info *db = netdev_priv(dev);
 
-   ULI526X_DBUG(0, uli526x_open, 0);
-
-   ret = request_irq(dev-irq, uli526x_interrupt, IRQF_SHARED, dev-name, 
dev);
-   if (ret)
-   return ret;
-
/* system variable init */
db-cr6_data = CR6_DEFAULT | uli526x_cr6_user_set;
db-tx_packet_cnt = 0;
@@ -467,7 +460,25 @@ static int uli526x_open(struct net_devic
db-timer.data = (unsigned long)dev;
db-timer.function = uli526x_timer;
add_timer(db-timer);
+}
+
+
+/*
+ * Open the interface.
+ * The interface is opened whenever ifconfig activates it.
+ */
+
+static int uli526x_open(struct net_device *dev)
+{
+   int ret;
+
+   ULI526X_DBUG(0, uli526x_open, 0);
+
+   ret = request_irq(dev-irq, uli526x_interrupt, IRQF_SHARED, dev-name, 
dev);
+   if (ret)
+   return ret;
 
+   uli526x_up(dev);
return 0;
 }
 
@@ -613,17 +624,15 @@ static int uli526x_start_xmit(struct sk_
 
 
 /*
- * Stop the interface.
- * The interface is stopped when it is brought.
+ * Take the interface down.
+ * Used by uli526x_stop and uli526x_suspend.
  */
 
-static int uli526x_stop(struct net_device *dev)
+static void uli526x_down(struct net_device *dev)
 {
struct uli526x_board_info *db = netdev_priv(dev);
unsigned long ioaddr = dev-base_addr;
 
-   ULI526X_DBUG(0, uli526x_stop, 0);
-
/* disable system */
netif_stop_queue(dev);
 
@@ -634,6 +643,21 @@ static int uli526x_stop(struct net_devic
outl(ULI526X_RESET, ioaddr + DCR0);
udelay(5);
phy_write(db-ioaddr, db-phy_addr, 0, 0x8000, db-chip_id);
+}
+
+
+/*
+ * Stop the interface.
+ * The interface is stopped when it is brought.
+ */
+
+static int uli526x_stop(struct net_device *dev)
+{
+   struct uli526x_board_info *db = netdev_priv(dev);
+
+   ULI526X_DBUG(0, uli526x_stop, 0);
+
+   uli526x_down(dev);
 
/* free interrupt */
free_irq(dev-irq, dev);
@@ -654,6 +678,73 @@ static int uli526x_stop(struct net_devic
 }
 
 
+#ifdef CONFIG_PM
+
+/*
+ * Suspend the interface.
+ */
+
+static int uli526x_suspend(struct pci_dev *pdev, pm_message_t state)
+{
+   struct net_device *dev = pci_get_drvdata(pdev);
+
+   ULI526X_DBUG(0, uli526x_suspend, 0);
+
+   if (dev  netdev_priv(dev)) {
+   if (netif_running(dev)) {
+   netif_device_detach(dev);
+   uli526x_down(dev);
+   }
+   pci_save_state(pdev);
+   pci_enable_wake(pdev, pci_choose_state(pdev, state), 0);
+   free_irq(dev-irq, dev);
+   pci_disable_device(pdev);
+   pci_set_power_state(pdev, pci_choose_state(pdev, state));
+   }
+   return 0;
+}
+
+/*
+ * Resume the interface.
+ */
+
+static int uli526x_resume(struct pci_dev *pdev)
+{
+   struct net_device *dev = pci_get_drvdata(pdev);
+   struct uli526x_board_info *db = netdev_priv(dev);
+   int err;
+
+   ULI526X_DBUG(0, uli526x_resume, 0);
+
+   if (dev  db) {
+   pci_set_power_state(pdev, PCI_D0);
+   pci_restore_state(pdev);
+   err = pci_enable_device(pdev);
+   if (err) {
+   printk(KERN_WARNING %s: Could not enable device \n,
+   dev-name);
+   return err;
+   }
+   pci_set_master(pdev);
+   err = request_irq(dev-irq, uli526x_interrupt, IRQF_SHARED,
+   dev-name, dev);
+ 

Re: SSB/b44 build failure

2007-03-11 Thread Adrian Bunk
On Sat, Mar 10, 2007 at 11:22:40AM -0500, John W. Linville wrote:
 On Sat, Mar 10, 2007 at 04:38:16PM +0100, Adrian Bunk wrote:
  On Sat, Mar 10, 2007 at 10:03:46AM -0500, John W. Linville wrote:
 
   diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
   index 6a4325b..b2e1deb 100644
   --- a/drivers/net/Kconfig
   +++ b/drivers/net/Kconfig
   @@ -1402,6 +1402,7 @@ config B44
config B44_PCI
 bool Broadcom 4400 PCI device support
 depends on B44  NET_PCI
   + select SSB_PCIHOST
 default y
 help
   Support for b44 PCI devices.
  
  
  This also requires a depends or select on SSB.
 
 It depends on B44, which selects SSB.

Oops, you are correct.

 John

cu
Adrian

-- 

   Is there not promise of rain? Ling Tan asked suddenly out
of the darkness. There had been need of rain for many days.
   Only a promise, Lao Er said.
   Pearl S. Buck - Dragon Seed

-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: wireless extensions vs. 64-bit architectures

2007-03-11 Thread Johannes Berg
On Fri, 2007-03-09 at 13:35 -0800, Jean Tourrilhes wrote:

   It's not as bad as it look like. All userspace programs
 nowadays use either the iwlib or wpa_supplicant. For example,
 NetworkManager gets its stuff through wpa_supplicant, and kdenetwork
 uses iwlib. So, in essence, there is only two places to fix.

That's definitely not true, the latest network manager I have sources to
on my laptop right now (0.6.4) uses iwlib but only iw_get_ext and no
parsing functions. I would guess that others use iwlib like that too.

   By the way, I've just released version 29.pre16 which has a
 better band aid. It fixes bugs of the previous version and is more
 forward compatible (i.e. it's compatible with option 2).

Can you please also *document* the bandaid and actually *describe* it in
*words* instead of dense code without comments?

I'm still not convinced that papering over the problem in userspace is a
real solution.

johannes


signature.asc
Description: This is a digitally signed message part


[PATCH] zd1211rw-mac80211: Use compare_ether_addr()

2007-03-11 Thread Daniel Drake
Suggested by Maxime Austruy, based on mac80211 changes from Stephen
Hemminger

Signed-off-by: Daniel Drake [EMAIL PROTECTED]
---
 drivers/net/wireless/zd1211rw/zd_mac.c |   11 ++-
 1 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/net/wireless/zd1211rw/zd_mac.c 
b/drivers/net/wireless/zd1211rw/zd_mac.c
index 4c5f78e..af5ca04 100644
--- a/drivers/net/wireless/zd1211rw/drivers/net/wireless/zd1211rw/zd_mac.c
+++ b/drivers/net/wireless/zd1211rw/drivers/net/wireless/zd1211rw/zd_mac.c
@@ -974,14 +974,14 @@ static int is_data_packet_for_us(struct ieee80211_device 
*ieee,
switch (ieee-iw_mode) {
case IW_MODE_ADHOC:
if ((fc  (IEEE80211_FCTL_TODS|IEEE80211_FCTL_FROMDS)) != 0 ||
-   memcmp(hdr-addr3, ieee-bssid, ETH_ALEN) != 0)
+   compare_ether_addr(hdr-addr3, ieee-bssid) != 0)
return 0;
break;
case IW_MODE_AUTO:
case IW_MODE_INFRA:
if ((fc  (IEEE80211_FCTL_TODS|IEEE80211_FCTL_FROMDS)) !=
IEEE80211_FCTL_FROMDS ||
-   memcmp(hdr-addr2, ieee-bssid, ETH_ALEN) != 0)
+   compare_ether_addr(hdr-addr2, ieee-bssid) != 0)
return 0;
break;
default:
@@ -989,9 +989,9 @@ static int is_data_packet_for_us(struct ieee80211_device 
*ieee,
return 0;
}
 
-   return memcmp(hdr-addr1, netdev-dev_addr, ETH_ALEN) == 0 ||
+   return compare_ether_addr(hdr-addr1, netdev-dev_addr) == 0 ||
   (is_multicast_ether_addr(hdr-addr1) 
-   memcmp(hdr-addr3, netdev-dev_addr, ETH_ALEN) != 0) ||
+   compare_ether_addr(hdr-addr3, netdev-dev_addr) != 0) ||
   (netdev-flags  IFF_PROMISC);
 }
 
@@ -1047,7 +1047,8 @@ static void update_qual_rssi(struct zd_mac *mac,
hdr = (struct ieee80211_hdr_3addr *)buffer;
if (length  offsetof(struct ieee80211_hdr_3addr, addr3))
return;
-   if (memcmp(hdr-addr2, zd_mac_to_ieee80211(mac)-bssid, ETH_ALEN) != 0)
+   if (compare_ether_addr(hdr-addr2,
+   zd_mac_to_ieee80211(mac)-bssid) != 0)
return;
 
spin_lock_irqsave(mac-lock, flags);
-- 
1.5.0.3

-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] zd1211rw-mac80211: changed Kconfig

2007-03-11 Thread Daniel Drake
From: Ulrich Kunitz [EMAIL PROTECTED]

Changed the reference to Devicescape stack to mac80211.

Signed-off-by: Ulrich Kunitz [EMAIL PROTECTED]
Signed-off-by: Daniel Drake [EMAIL PROTECTED]
---
 drivers/net/wireless/mac80211/zd1211rw/Kconfig |6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/mac80211/zd1211rw/Kconfig 
b/drivers/net/wireless/mac80211/zd1211rw/Kconfig
index f6a5f25..b3c64e0 100644
--- 
a/drivers/net/wireless/zd1211rw/drivers/net/wireless/mac80211/zd1211rw/Kconfig
+++ 
b/drivers/net/wireless/zd1211rw/drivers/net/wireless/mac80211/zd1211rw/Kconfig
@@ -1,13 +1,13 @@
 config ZD1211RW_MAC80211
-   tristate ZyDAS ZD1211/ZD1211B USB-wireless support (DeviceScape stack)
+   tristate ZyDAS ZD1211/ZD1211B USB support (mac80211 stack)
depends on USB  MAC80211  WLAN_80211  EXPERIMENTAL
select FW_LOADER
---help---
  This is an experimental driver for the ZyDAS ZD1211/ZD1211B wireless
  chip, present in many USB-wireless adapters.
 
- Device firmware is required alongside this driver. You can download 
the
- firmware distribution from http://zd1211.ath.cx/get-firmware
+ Device firmware is required alongside this driver. You can download
+ the firmware distribution from http://zd1211.ath.cx/get-firmware
 
 config ZD1211RW_MAC80211_DEBUG
bool ZyDAS ZD1211 debugging
-- 
1.5.0.3

-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] zd1211rw-mac80211: Add AL2230S RF support

2007-03-11 Thread Daniel Drake
ZD1211 appears to be back in production: a number of new devices have
been appearing! Some of them are using new radios.

This patch adds support for the next generation AL2230 RF chip which has
been spotted in a few new devices.

Signed-off-by: Daniel Drake [EMAIL PROTECTED]
---
 drivers/net/wireless/mac80211/zd1211rw/zd_chip.c   |6 +-
 drivers/net/wireless/mac80211/zd1211rw/zd_chip.h   |2 +-
 drivers/net/wireless/mac80211/zd1211rw/zd_rf.c |2 +-
 drivers/net/wireless/mac80211/zd1211rw/zd_rf.h |2 +-
 .../net/wireless/mac80211/zd1211rw/zd_rf_al2230.c  |   83 +---
 5 files changed, 80 insertions(+), 15 deletions(-)

diff --git a/drivers/net/wireless/mac80211/zd1211rw/zd_chip.c 
b/drivers/net/wireless/mac80211/zd1211rw/zd_chip.c
index 1a8ff99..4d226dc 100644
--- 
a/drivers/net/wireless/zd1211rw/drivers/net/wireless/mac80211/zd1211rw/zd_chip.c
+++ 
b/drivers/net/wireless/zd1211rw/drivers/net/wireless/mac80211/zd1211rw/zd_chip.c
@@ -67,11 +67,12 @@ static int scnprint_id(struct zd_chip *chip, char *buffer, 
size_t size)
i += scnprint_mac_oui(chip-e2p_mac, buffer+i, size-i);
i += scnprintf(buffer+i, size-i,  );
i += zd_rf_scnprint_id(chip-rf, buffer+i, size-i);
-   i += scnprintf(buffer+i, size-i,  pa%1x %c%c%c%c, chip-pa_type,
+   i += scnprintf(buffer+i, size-i,  pa%1x %c%c%c%c%c, chip-pa_type,
chip-patch_cck_gain ? 'g' : '-',
chip-patch_cr157 ? '7' : '-',
chip-patch_6m_band_edge ? '6' : '-',
-   chip-new_phy_layout ? 'N' : '-');
+   chip-new_phy_layout ? 'N' : '-',
+   chip-al2230s_bit ? 'S' : '-');
return i;
 }
 
@@ -337,6 +338,7 @@ static int read_pod(struct zd_chip *chip, u8 *rf_type)
chip-patch_cr157 = (value  13)  0x1;
chip-patch_6m_band_edge = (value  21)  0x1;
chip-new_phy_layout = (value  31)  0x1;
+   chip-al2230s_bit = (value  7)  0x1;
chip-link_led = ((value  4)  1) ? LED1 : LED2;
chip-supports_tx_led = 1;
if (value  (1  24)) { /* LED scenario */
diff --git a/drivers/net/wireless/mac80211/zd1211rw/zd_chip.h 
b/drivers/net/wireless/mac80211/zd1211rw/zd_chip.h
index 4be3c9d..a4dc06c 100644
--- 
a/drivers/net/wireless/zd1211rw/drivers/net/wireless/mac80211/zd1211rw/zd_chip.h
+++ 
b/drivers/net/wireless/zd1211rw/drivers/net/wireless/mac80211/zd1211rw/zd_chip.h
@@ -703,7 +703,7 @@ struct zd_chip {
u16 link_led;
unsigned int pa_type:4,
patch_cck_gain:1, patch_cr157:1, patch_6m_band_edge:1,
-   new_phy_layout:1,
+   new_phy_layout:1, al2230s_bit:1,
is_zd1211b:1, supports_tx_led:1;
 };
 
diff --git a/drivers/net/wireless/mac80211/zd1211rw/zd_rf.c 
b/drivers/net/wireless/mac80211/zd1211rw/zd_rf.c
index f50cff3..e6d604b 100644
--- 
a/drivers/net/wireless/zd1211rw/drivers/net/wireless/mac80211/zd1211rw/zd_rf.c
+++ 
b/drivers/net/wireless/zd1211rw/drivers/net/wireless/mac80211/zd1211rw/zd_rf.c
@@ -34,7 +34,7 @@ static const char *rfs[] = {
[AL2210_RF] = AL2210_RF,
[MAXIM_NEW_RF]  = MAXIM_NEW_RF,
[UW2453_RF] = UW2453_RF,
-   [AL2230S_RF]= AL2230S_RF,
+   [UNKNOWN_A_RF]  = UNKNOWN_A_RF,
[RALINK_RF] = RALINK_RF,
[INTERSIL_RF]   = INTERSIL_RF,
[RF2959_RF] = RF2959_RF,
diff --git a/drivers/net/wireless/mac80211/zd1211rw/zd_rf.h 
b/drivers/net/wireless/mac80211/zd1211rw/zd_rf.h
index a57732e..ee8ac3a 100644
--- 
a/drivers/net/wireless/zd1211rw/drivers/net/wireless/mac80211/zd1211rw/zd_rf.h
+++ 
b/drivers/net/wireless/zd1211rw/drivers/net/wireless/mac80211/zd1211rw/zd_rf.h
@@ -26,7 +26,7 @@
 #define AL2210_RF  0x7
 #define MAXIM_NEW_RF   0x8
 #define UW2453_RF  0x9
-#define AL2230S_RF 0xa
+#define UNKNOWN_A_RF   0xa
 #define RALINK_RF  0xb
 #define INTERSIL_RF0xc
 #define RF2959_RF  0xd
diff --git a/drivers/net/wireless/mac80211/zd1211rw/zd_rf_al2230.c 
b/drivers/net/wireless/mac80211/zd1211rw/zd_rf_al2230.c
index 25323a1..85a9ad2 100644
--- 
a/drivers/net/wireless/zd1211rw/drivers/net/wireless/mac80211/zd1211rw/zd_rf_al2230.c
+++ 
b/drivers/net/wireless/zd1211rw/drivers/net/wireless/mac80211/zd1211rw/zd_rf_al2230.c
@@ -59,6 +59,18 @@ static const struct zd_ioreq16 zd1211b_ioreqs_shared_1[] = {
{ CR240, 0x57 }, { CR9,   0xe0 },
 };
 
+static const struct zd_ioreq16 ioreqs_init_al2230s[] = {
+   { CR47,   0x1e }, /* MARK_002 */
+   { CR106,  0x22 },
+   { CR107,  0x2a }, /* MARK_002 */
+   { CR109,  0x13 }, /* MARK_002 */
+   { CR118,  0xf8 }, /* MARK_002 */
+   { CR119,  0x12 }, { CR122,  0xe0 },
+   { CR128,  0x10 }, /* MARK_001 from 0xe-0x10 */
+   { CR129,  0x0e }, /* MARK_001 from 0xd-0x0e */
+   { CR130,  0x10 }, /* MARK_001 from 0xb-0x0d */
+};
+
 static int 

Questions regarding kernel 2.6 3C59x driver on EISA systems

2007-03-11 Thread Alfred Arnold
Hi,

I recently was able to get hold of a 3C597 card for my Jensen Alpha.
Compiling the driver for it however gives error messages about undefined
symbols:

pci_alloc_consistent
pci_free_consistent
pci_map_single
pci_map_unsingle

These functions do not exist on a pure EISA system (like the Jensen
Alpha), however the calls to these functions seem to be hardwired in the
driver, regardless of the card's interface type (PCI or EISA).  Seems to
me this driver hasn't been compiled on a pure EISA system for a while ;-)

I had some success by replacing these functions with

dma_alloc_coherent
dma_free_coherent
dma_map_single
dma_unmap_single

The driver will then load, correctly identify the card and at least send
packets (I still have trouble with interrupts, but that might be due to
the incomplete EISA setup of the Jensen).  I'm not sure however if this is
the correct change, I copied this from the AHA1742 driver.

Are the EISA 3C59x variants still supported at all?  If yes, this should
IMHO be fixed.  I can provide my patch, which is basically an #ifdef
CONFIG_PCI conditional, but this will probably not work in mixed PCI/EISA
systems.

I am using Linux kernel 2.6.20.1 .  I sent the same mail a week ago to
Andrew Morton ([EMAIL PROTECTED]), which is the address mentioned in the
'vortex.txt' documentation file.  I haven't received any answers since
then, however :-(

Best regards

Alfred Arnold

-- 
Alfred Arnold   E-Mail: [EMAIL PROTECTED]
Computer Club at thehttp://john.ccac.rwth-aachen.de:8000/alf/
Technical UniversityPhone: +49-241-406526
of Aachen   Fax:   +49-241-406527
-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] zd1211rw-mac80211: Use compare_ether_addr()

2007-03-11 Thread Daniel Drake

Daniel Drake wrote:

Suggested by Maxime Austruy, based on mac80211 changes from Stephen
Hemminger


Sorry, paths were broken on these patches. Resends coming a little later.

Daniel

-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 4/4] PPPoE: race between interface going down and release()

2007-03-11 Thread Michal Ostrowski
I need some more time to think about this one; there are some problem
I'm seeing here but I can't look at it right now.  I'll send out my
version of a patch for this tomorrow and we can discuss more.

Regarding the previous three patches, they seem fine after a first pass.
However, I'd like to ask you to please use a Signed-off-by statement.
That why I can ack it and push it upstream without hesitation.



-- 
Michal Ostrowski [EMAIL PROTECTED]



On Sun, 2007-03-11 at 05:41 +0100, Florian Zumbiehl wrote:
 Hi,
 
 below you find the last patch for now. It (hopefully) fixes a race
 between a socket being release()d and the interface it's using going
 down. As pppoe_release() didn't lock the socket, and pppoe_flush_dev()
 did the locking in the wrong place, pppoe_flush_dev() could set
 po-pppoe_dev to NULL, which would then cause pppoe_release() to not
 dev_put() the interface, but to still mark the socket as DEAD,
 which in turn would cause pppoe_flush_dev() to not dev_put() the
 interface, effectively leaking one reference to the device, thus making it
 impossible to remove (ignoring the possibility of overflowing the reference
 counter by repeated use of this race ;-).
 
 The thing I'm not quite sure about is whether the outer
 
 |if (po-pppoe_dev == dev) {
 
 is actually reliable this way on SMP systems, as far as cache consistency
 is concerned. I left it that way for now, as any alternative locking
 strategies that would lock the socket before doing this comparison seemed
 to be pretty complicated to implement because of the need to drop the
 hash table lock before trying to acquire the socket lock, so I'd rather
 be sure that this actually is a problem before I try to solve it ;-)
 
 Florian
 
 ---
 diff --git a/drivers/net/pppoe.c b/drivers/net/pppoe.c
 index 1aeac2c..f5abfff 100644
 --- a/drivers/net/pppoe.c
 +++ b/drivers/net/pppoe.c
 @@ -253,7 +253,6 @@ static void pppoe_flush_dev(struct net_device *dev)
   struct sock *sk = sk_pppox(po);
  
   sock_hold(sk);
 - po-pppoe_dev = NULL;
  
   /* We hold a reference to SK, now drop the
* hash table lock so that we may attempt
 @@ -263,12 +262,15 @@ static void pppoe_flush_dev(struct net_device *dev)
  
   lock_sock(sk);
  
 - if (sk-sk_state 
 - (PPPOX_CONNECTED | PPPOX_BOUND)) {
 - pppox_unbind_sock(sk);
 + if(po-pppoe_dev==dev){
   dev_put(dev);
 - sk-sk_state = PPPOX_ZOMBIE;
 - sk-sk_state_change(sk);
 + po-pppoe_dev = NULL;
 + if (sk-sk_state 
 + (PPPOX_CONNECTED | PPPOX_BOUND)) {
 + pppox_unbind_sock(sk);
 + sk-sk_state = PPPOX_ZOMBIE;
 + sk-sk_state_change(sk);
 + }
   }
  
   release_sock(sk);
 @@ -504,8 +506,11 @@ static int pppoe_release(struct socket *sock)
   if (!sk)
   return 0;
  
 - if (sock_flag(sk, SOCK_DEAD))
 + lock_sock(sk);
 + if (sock_flag(sk, SOCK_DEAD)){
 + release_sock(sk);
   return -EBADF;
 + }
  
   pppox_unbind_sock(sk);
  
 @@ -526,6 +531,7 @@ static int pppoe_release(struct socket *sock)
   sock-sk = NULL;
  
   skb_queue_purge(sk-sk_receive_queue);
 + release_sock(sk);
   sock_put(sk);
  
   return 0;
 

-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH RESEND] zd1211rw-mac80211: Use compare_ether_addr()

2007-03-11 Thread Daniel Drake
Suggested by Maxime Austruy, based on mac80211 changes from Stephen
Hemminger

Signed-off-by: Daniel Drake [EMAIL PROTECTED]
---
 drivers/net/wireless/mac80211/zd1211rw/zd_mac.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/net/wireless/mac80211/zd1211rw/zd_mac.c 
b/drivers/net/wireless/mac80211/zd1211rw/zd_mac.c
index 0d75ef2..94aa791 100644
--- a/drivers/net/wireless/mac80211/zd1211rw/zd_mac.c
+++ b/drivers/net/wireless/mac80211/zd1211rw/zd_mac.c
@@ -440,7 +440,7 @@ static int filter_ack(struct ieee80211_hw *dev, struct 
ieee80211_hdr *rx_hdr,
 
tx_hdr = (struct ieee80211_hdr *) skb-data;
 
-   if (!memcmp(tx_hdr-addr2, rx_hdr-addr1, ETH_ALEN))
+   if (!compare_ether_addr(tx_hdr-addr2, rx_hdr-addr1))
skb = __skb_dequeue(mac-tx_queue);
else {
spin_unlock(mac-tx_queue.lock);
-- 
1.5.0.3

-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH RESEND] zd1211rw-mac80211: changed Kconfig

2007-03-11 Thread Daniel Drake
From: Ulrich Kunitz [EMAIL PROTECTED]

Changed the reference to Devicescape stack to mac80211.

Signed-off-by: Ulrich Kunitz [EMAIL PROTECTED]
Signed-off-by: Daniel Drake [EMAIL PROTECTED]
---
 drivers/net/wireless/mac80211/zd1211rw/Kconfig |6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/mac80211/zd1211rw/Kconfig 
b/drivers/net/wireless/mac80211/zd1211rw/Kconfig
index f6a5f25..b3c64e0 100644
--- a/drivers/net/wireless/mac80211/zd1211rw/Kconfig
+++ b/drivers/net/wireless/mac80211/zd1211rw/Kconfig
@@ -1,13 +1,13 @@
 config ZD1211RW_MAC80211
-   tristate ZyDAS ZD1211/ZD1211B USB-wireless support (DeviceScape stack)
+   tristate ZyDAS ZD1211/ZD1211B USB support (mac80211 stack)
depends on USB  MAC80211  WLAN_80211  EXPERIMENTAL
select FW_LOADER
---help---
  This is an experimental driver for the ZyDAS ZD1211/ZD1211B wireless
  chip, present in many USB-wireless adapters.
 
- Device firmware is required alongside this driver. You can download 
the
- firmware distribution from http://zd1211.ath.cx/get-firmware
+ Device firmware is required alongside this driver. You can download
+ the firmware distribution from http://zd1211.ath.cx/get-firmware
 
 config ZD1211RW_MAC80211_DEBUG
bool ZyDAS ZD1211 debugging
-- 
1.5.0.3

-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH RESEND] zd1211rw-mac80211: sparse-annotate radiotap header

2007-03-11 Thread Daniel Drake
From: Pavel Roskin [EMAIL PROTECTED]

All fields in radiotap header must be little endian.  The driver does it
correctly, but the structure definition must be annotated.

Signed-off-by: Pavel Roskin [EMAIL PROTECTED]
Signed-off-by: Ulrich Kunitz [EMAIL PROTECTED]
Signed-off-by: Daniel Drake [EMAIL PROTECTED]
---
 drivers/net/wireless/mac80211/zd1211rw/zd_mac.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/mac80211/zd1211rw/zd_mac.c 
b/drivers/net/wireless/mac80211/zd1211rw/zd_mac.c
index b69688c..0d75ef2 100644
--- a/drivers/net/wireless/mac80211/zd1211rw/zd_mac.c
+++ b/drivers/net/wireless/mac80211/zd1211rw/zd_mac.c
@@ -359,8 +359,8 @@ struct zd_rt_hdr {
struct ieee80211_radiotap_header rt_hdr;
u8  rt_flags;
u8  rt_rate;
-   u16 rt_channel;
-   u16 rt_chbitmask;
+   __le16 rt_channel;
+   __le16 rt_chbitmask;
 } __attribute__((packed));
 
 static void fill_rt_header(void *buffer, struct zd_mac *mac,
-- 
1.5.0.3

-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH RESEND] zd1211rw-mac80211: Add AL2230S RF support

2007-03-11 Thread Daniel Drake
ZD1211 appears to be back in production: a number of new devices have
been appearing! Some of them are using new radios.

This patch adds support for the next generation AL2230 RF chip which has
been spotted in a few new devices.

Signed-off-by: Daniel Drake [EMAIL PROTECTED]
---
 drivers/net/wireless/mac80211/zd1211rw/zd_chip.c   |6 +-
 drivers/net/wireless/mac80211/zd1211rw/zd_chip.h   |2 +-
 drivers/net/wireless/mac80211/zd1211rw/zd_rf.c |2 +-
 drivers/net/wireless/mac80211/zd1211rw/zd_rf.h |2 +-
 .../net/wireless/mac80211/zd1211rw/zd_rf_al2230.c  |   83 +---
 5 files changed, 80 insertions(+), 15 deletions(-)

diff --git a/drivers/net/wireless/mac80211/zd1211rw/zd_chip.c 
b/drivers/net/wireless/mac80211/zd1211rw/zd_chip.c
index 1a8ff99..4d226dc 100644
--- a/drivers/net/wireless/mac80211/zd1211rw/zd_chip.c
+++ b/drivers/net/wireless/mac80211/zd1211rw/zd_chip.c
@@ -67,11 +67,12 @@ static int scnprint_id(struct zd_chip *chip, char *buffer, 
size_t size)
i += scnprint_mac_oui(chip-e2p_mac, buffer+i, size-i);
i += scnprintf(buffer+i, size-i,  );
i += zd_rf_scnprint_id(chip-rf, buffer+i, size-i);
-   i += scnprintf(buffer+i, size-i,  pa%1x %c%c%c%c, chip-pa_type,
+   i += scnprintf(buffer+i, size-i,  pa%1x %c%c%c%c%c, chip-pa_type,
chip-patch_cck_gain ? 'g' : '-',
chip-patch_cr157 ? '7' : '-',
chip-patch_6m_band_edge ? '6' : '-',
-   chip-new_phy_layout ? 'N' : '-');
+   chip-new_phy_layout ? 'N' : '-',
+   chip-al2230s_bit ? 'S' : '-');
return i;
 }
 
@@ -337,6 +338,7 @@ static int read_pod(struct zd_chip *chip, u8 *rf_type)
chip-patch_cr157 = (value  13)  0x1;
chip-patch_6m_band_edge = (value  21)  0x1;
chip-new_phy_layout = (value  31)  0x1;
+   chip-al2230s_bit = (value  7)  0x1;
chip-link_led = ((value  4)  1) ? LED1 : LED2;
chip-supports_tx_led = 1;
if (value  (1  24)) { /* LED scenario */
diff --git a/drivers/net/wireless/mac80211/zd1211rw/zd_chip.h 
b/drivers/net/wireless/mac80211/zd1211rw/zd_chip.h
index 4be3c9d..a4dc06c 100644
--- a/drivers/net/wireless/mac80211/zd1211rw/zd_chip.h
+++ b/drivers/net/wireless/mac80211/zd1211rw/zd_chip.h
@@ -703,7 +703,7 @@ struct zd_chip {
u16 link_led;
unsigned int pa_type:4,
patch_cck_gain:1, patch_cr157:1, patch_6m_band_edge:1,
-   new_phy_layout:1,
+   new_phy_layout:1, al2230s_bit:1,
is_zd1211b:1, supports_tx_led:1;
 };
 
diff --git a/drivers/net/wireless/mac80211/zd1211rw/zd_rf.c 
b/drivers/net/wireless/mac80211/zd1211rw/zd_rf.c
index f50cff3..e6d604b 100644
--- a/drivers/net/wireless/mac80211/zd1211rw/zd_rf.c
+++ b/drivers/net/wireless/mac80211/zd1211rw/zd_rf.c
@@ -34,7 +34,7 @@ static const char *rfs[] = {
[AL2210_RF] = AL2210_RF,
[MAXIM_NEW_RF]  = MAXIM_NEW_RF,
[UW2453_RF] = UW2453_RF,
-   [AL2230S_RF]= AL2230S_RF,
+   [UNKNOWN_A_RF]  = UNKNOWN_A_RF,
[RALINK_RF] = RALINK_RF,
[INTERSIL_RF]   = INTERSIL_RF,
[RF2959_RF] = RF2959_RF,
diff --git a/drivers/net/wireless/mac80211/zd1211rw/zd_rf.h 
b/drivers/net/wireless/mac80211/zd1211rw/zd_rf.h
index a57732e..ee8ac3a 100644
--- a/drivers/net/wireless/mac80211/zd1211rw/zd_rf.h
+++ b/drivers/net/wireless/mac80211/zd1211rw/zd_rf.h
@@ -26,7 +26,7 @@
 #define AL2210_RF  0x7
 #define MAXIM_NEW_RF   0x8
 #define UW2453_RF  0x9
-#define AL2230S_RF 0xa
+#define UNKNOWN_A_RF   0xa
 #define RALINK_RF  0xb
 #define INTERSIL_RF0xc
 #define RF2959_RF  0xd
diff --git a/drivers/net/wireless/mac80211/zd1211rw/zd_rf_al2230.c 
b/drivers/net/wireless/mac80211/zd1211rw/zd_rf_al2230.c
index 25323a1..85a9ad2 100644
--- a/drivers/net/wireless/mac80211/zd1211rw/zd_rf_al2230.c
+++ b/drivers/net/wireless/mac80211/zd1211rw/zd_rf_al2230.c
@@ -59,6 +59,18 @@ static const struct zd_ioreq16 zd1211b_ioreqs_shared_1[] = {
{ CR240, 0x57 }, { CR9,   0xe0 },
 };
 
+static const struct zd_ioreq16 ioreqs_init_al2230s[] = {
+   { CR47,   0x1e }, /* MARK_002 */
+   { CR106,  0x22 },
+   { CR107,  0x2a }, /* MARK_002 */
+   { CR109,  0x13 }, /* MARK_002 */
+   { CR118,  0xf8 }, /* MARK_002 */
+   { CR119,  0x12 }, { CR122,  0xe0 },
+   { CR128,  0x10 }, /* MARK_001 from 0xe-0x10 */
+   { CR129,  0x0e }, /* MARK_001 from 0xd-0x0e */
+   { CR130,  0x10 }, /* MARK_001 from 0xb-0x0d */
+};
+
 static int zd1211b_al2230_finalize_rf(struct zd_chip *chip)
 {
int r;
@@ -90,7 +102,7 @@ static int zd1211_al2230_init_hw(struct zd_rf *rf)
int r;
struct zd_chip *chip = zd_rf_to_chip(rf);
 
-   static const struct zd_ioreq16 ioreqs[] = {
+   static const struct zd_ioreq16 ioreqs_init[] = {

[PATCH] zd1211rw-mac80211: More device IDs

2007-03-11 Thread Daniel Drake
ASUS A9Rp
Tested by Serge
zd1211b chip 0b05:171b v4802 high 00-17-31 AL2230_RF pa0 g--

ZyXEL G-202
Tested by Marcus D. Hanwell
zd1211b chip 0586:3410 v4810 high 00-13-49 AL2230_RF pa0 g---

US Robotics USR805423
Tested by Pascal S. de Kloe
FCC ID: RAXWN4501H
zd1211b chip 0baf:0121 v4810 high 00-14-c1 AL2230_RF pa0 g--N
Julien Pinon reports this also comes in AL2230S form

Signed-off-by: Daniel Drake [EMAIL PROTECTED]

Index: linux-wireless-dev/drivers/net/wireless/mac80211/zd1211rw/zd_usb.c
===
--- linux-wireless-dev.orig/drivers/net/wireless/mac80211/zd1211rw/zd_usb.c
+++ linux-wireless-dev/drivers/net/wireless/mac80211/zd1211rw/zd_usb.c
@@ -60,6 +60,9 @@ static struct usb_device_id usb_ids[] = 
{ USB_DEVICE(0x0471, 0x1236), .driver_info = DEVICE_ZD1211B },
{ USB_DEVICE(0x13b1, 0x0024), .driver_info = DEVICE_ZD1211B },
{ USB_DEVICE(0x0586, 0x340f), .driver_info = DEVICE_ZD1211B },
+   { USB_DEVICE(0x0b05, 0x171b), .driver_info = DEVICE_ZD1211B },
+   { USB_DEVICE(0x0586, 0x3410), .driver_info = DEVICE_ZD1211B },
+   { USB_DEVICE(0x0baf, 0x0121), .driver_info = DEVICE_ZD1211B },
/* Driverless devices that need ejecting */
{ USB_DEVICE(0x0ace, 0x2011), .driver_info = DEVICE_INSTALLER },
{}
-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] zd1211rw: Use compare_ether_addr()

2007-03-11 Thread Daniel Drake
Suggested by Maxime Austruy, based on mac80211 changes from Stephen
Hemminger

Signed-off-by: Daniel Drake [EMAIL PROTECTED]
---
 zd_mac.c |   10 +-
 1 files changed, 5 insertions(+), 5 deletions(-)

Index: linux/drivers/net/wireless/zd1211rw/zd_mac.c
===
--- linux.orig/drivers/net/wireless/zd1211rw/zd_mac.c
+++ linux/drivers/net/wireless/zd1211rw/zd_mac.c
@@ -974,14 +974,14 @@ static int is_data_packet_for_us(struct 
switch (ieee-iw_mode) {
case IW_MODE_ADHOC:
if ((fc  (IEEE80211_FCTL_TODS|IEEE80211_FCTL_FROMDS)) != 0 ||
-   memcmp(hdr-addr3, ieee-bssid, ETH_ALEN) != 0)
+   compare_ether_addr(hdr-addr3, ieee-bssid) != 0)
return 0;
break;
case IW_MODE_AUTO:
case IW_MODE_INFRA:
if ((fc  (IEEE80211_FCTL_TODS|IEEE80211_FCTL_FROMDS)) !=
IEEE80211_FCTL_FROMDS ||
-   memcmp(hdr-addr2, ieee-bssid, ETH_ALEN) != 0)
+   compare_ether_addr(hdr-addr2, ieee-bssid) != 0)
return 0;
break;
default:
@@ -989,9 +989,9 @@ static int is_data_packet_for_us(struct 
return 0;
}
 
-   return memcmp(hdr-addr1, netdev-dev_addr, ETH_ALEN) == 0 ||
+   return compare_ether_addr(hdr-addr1, netdev-dev_addr) == 0 ||
   (is_multicast_ether_addr(hdr-addr1) 
-   memcmp(hdr-addr3, netdev-dev_addr, ETH_ALEN) != 0) ||
+   compare_ether_addr(hdr-addr3, netdev-dev_addr) != 0) ||
   (netdev-flags  IFF_PROMISC);
 }
 
@@ -1047,7 +1047,7 @@ static void update_qual_rssi(struct zd_m
hdr = (struct ieee80211_hdr_3addr *)buffer;
if (length  offsetof(struct ieee80211_hdr_3addr, addr3))
return;
-   if (memcmp(hdr-addr2, zd_mac_to_ieee80211(mac)-bssid, ETH_ALEN) != 0)
+   if (compare_ether_addr(hdr-addr2, zd_mac_to_ieee80211(mac)-bssid) != 
0)
return;
 
spin_lock_irqsave(mac-lock, flags);
-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] zd1211rw: Add AL2230S RF support

2007-03-11 Thread Daniel Drake
ZD1211 appears to be back in production: a number of new devices have
been appearing! Some of them are using new radios.

This patch adds support for the next generation AL2230 RF chip which has
been spotted in a few new devices.

Signed-off-by: Daniel Drake [EMAIL PROTECTED]
---
 zd_chip.c  |5 ++-
 zd_rf.c|2 +-
 zd_rf.h|2 +-
 zd_rf_al2230.c |   89 ++--
 4 files changed, 78 insertions(+), 20 deletions(-)

Index: linux/drivers/net/wireless/zd1211rw/zd_chip.c
===
--- linux.orig/drivers/net/wireless/zd1211rw/zd_chip.c
+++ linux/drivers/net/wireless/zd1211rw/zd_chip.c
@@ -67,11 +67,12 @@ static int scnprint_id(struct zd_chip *c
i += scnprint_mac_oui(chip-e2p_mac, buffer+i, size-i);
i += scnprintf(buffer+i, size-i,  );
i += zd_rf_scnprint_id(chip-rf, buffer+i, size-i);
-   i += scnprintf(buffer+i, size-i,  pa%1x %c%c%c%c, chip-pa_type,
+   i += scnprintf(buffer+i, size-i,  pa%1x %c%c%c%c%c, chip-pa_type,
chip-patch_cck_gain ? 'g' : '-',
chip-patch_cr157 ? '7' : '-',
chip-patch_6m_band_edge ? '6' : '-',
-   chip-new_phy_layout ? 'N' : '-');
+   chip-new_phy_layout ? 'N' : '-',
+   chip-al2230s_bit ? 'S' : '-');
return i;
 }
 
Index: linux/drivers/net/wireless/zd1211rw/zd_rf.c
===
--- linux.orig/drivers/net/wireless/zd1211rw/zd_rf.c
+++ linux/drivers/net/wireless/zd1211rw/zd_rf.c
@@ -34,7 +34,7 @@ static const char *rfs[] = {
[AL2210_RF] = AL2210_RF,
[MAXIM_NEW_RF]  = MAXIM_NEW_RF,
[UW2453_RF] = UW2453_RF,
-   [AL2230S_RF]= AL2230S_RF,
+   [UNKNOWN_A_RF]  = UNKNOWN_A_RF,
[RALINK_RF] = RALINK_RF,
[INTERSIL_RF]   = INTERSIL_RF,
[RF2959_RF] = RF2959_RF,
Index: linux/drivers/net/wireless/zd1211rw/zd_rf.h
===
--- linux.orig/drivers/net/wireless/zd1211rw/zd_rf.h
+++ linux/drivers/net/wireless/zd1211rw/zd_rf.h
@@ -26,7 +26,7 @@
 #define AL2210_RF  0x7
 #define MAXIM_NEW_RF   0x8
 #define UW2453_RF  0x9
-#define AL2230S_RF 0xa
+#define UNKNOWN_A_RF   0xa
 #define RALINK_RF  0xb
 #define INTERSIL_RF0xc
 #define RF2959_RF  0xd
Index: linux/drivers/net/wireless/zd1211rw/zd_rf_al2230.c
===
--- linux.orig/drivers/net/wireless/zd1211rw/zd_rf_al2230.c
+++ linux/drivers/net/wireless/zd1211rw/zd_rf_al2230.c
@@ -59,6 +59,18 @@ static const struct zd_ioreq16 zd1211b_i
{ CR240, 0x57 }, { CR9,   0xe0 },
 };
 
+static const struct zd_ioreq16 ioreqs_init_al2230s[] = {
+   { CR47,   0x1e }, /* MARK_002 */
+   { CR106,  0x22 },
+   { CR107,  0x2a }, /* MARK_002 */
+   { CR109,  0x13 }, /* MARK_002 */
+   { CR118,  0xf8 }, /* MARK_002 */
+   { CR119,  0x12 }, { CR122,  0xe0 },
+   { CR128,  0x10 }, /* MARK_001 from 0xe-0x10 */
+   { CR129,  0x0e }, /* MARK_001 from 0xd-0x0e */
+   { CR130,  0x10 }, /* MARK_001 from 0xb-0x0d */
+};
+
 static int zd1211b_al2230_finalize_rf(struct zd_chip *chip)
 {
int r;
@@ -90,7 +102,7 @@ static int zd1211_al2230_init_hw(struct 
int r;
struct zd_chip *chip = zd_rf_to_chip(rf);
 
-   static const struct zd_ioreq16 ioreqs[] = {
+   static const struct zd_ioreq16 ioreqs_init[] = {
{ CR15,   0x20 }, { CR23,   0x40 }, { CR24,  0x20 },
{ CR26,   0x11 }, { CR28,   0x3e }, { CR29,  0x00 },
{ CR44,   0x33 }, { CR106,  0x2a }, { CR107, 0x1a },
@@ -117,10 +129,9 @@ static int zd1211_al2230_init_hw(struct 
{ CR119,  0x10 }, { CR120,  0x4f }, { CR121, 0x77 },
{ CR122,  0xe0 }, { CR137,  0x88 }, { CR252, 0xff },
{ CR253,  0xff },
+   };
 
-   /* These following happen separately in the vendor driver */
-   { },
-
+   static const struct zd_ioreq16 ioreqs_pll[] = {
/* shdnb(PLL_ON)=0 */
{ CR251,  0x2f },
/* shdnb(PLL_ON)=1 */
@@ -128,7 +139,7 @@ static int zd1211_al2230_init_hw(struct 
{ CR138,  0x28 }, { CR203,  0x06 },
};
 
-   static const u32 rv[] = {
+   static const u32 rv1[] = {
/* Channel 1 */
0x03f790,
0x01,
@@ -137,6 +148,9 @@ static int zd1211_al2230_init_hw(struct 
0x0b3331,
0x03b812,
0x00fff3,
+   };
+
+   static const u32 rv2[] = {
0x000da4,
0x0f4dc5, /* fix freq shift, 0x04edc5 */
0x0805b6,
@@ 

[PATCH] zd1211rw: More device IDs

2007-03-11 Thread Daniel Drake
ASUS A9Rp
Tested by Serge
zd1211b chip 0b05:171b v4802 high 00-17-31 AL2230_RF pa0 g--

ZyXEL G-202
Tested by Marcus D. Hanwell
zd1211b chip 0586:3410 v4810 high 00-13-49 AL2230_RF pa0 g---

US Robotics USR805423
Tested by Pascal S. de Kloe
FCC ID: RAXWN4501H
zd1211b chip 0baf:0121 v4810 high 00-14-c1 AL2230_RF pa0 g--N
Julien Pinon reports this also comes in AL2230S form

Signed-off-by: Daniel Drake [EMAIL PROTECTED]
---
 zd_usb.c |3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

Index: linux/drivers/net/wireless/zd1211rw/zd_usb.c
===
--- linux.orig/drivers/net/wireless/zd1211rw/zd_usb.c
+++ linux/drivers/net/wireless/zd1211rw/zd_usb.c
@@ -62,6 +62,9 @@ static struct usb_device_id usb_ids[] = 
{ USB_DEVICE(0x0471, 0x1236), .driver_info = DEVICE_ZD1211B },
{ USB_DEVICE(0x13b1, 0x0024), .driver_info = DEVICE_ZD1211B },
{ USB_DEVICE(0x0586, 0x340f), .driver_info = DEVICE_ZD1211B },
+   { USB_DEVICE(0x0b05, 0x171b), .driver_info = DEVICE_ZD1211B },
+   { USB_DEVICE(0x0586, 0x3410), .driver_info = DEVICE_ZD1211B },
+   { USB_DEVICE(0x0baf, 0x0121), .driver_info = DEVICE_ZD1211B },
/* Driverless devices that need ejecting */
{ USB_DEVICE(0x0ace, 0x2011), .driver_info = DEVICE_INSTALLER },
{}
-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] zd1211rw: Reject AL2230S devices

2007-03-11 Thread Daniel Drake
zd1211rw currently detects AL2230S-based devices as AL2230, and hence
programs the RF incorrectly. Transmit silently fails on this
misconfiguration.

After this patch, AL2230S devices are rejected with an error message, to
avoid any confusion with an apparent driver bug.

Signed-off-by: Daniel Drake [EMAIL PROTECTED]
---

John: please merge this into 2.6.21. A patch to actually support AL2230S will
follow, but it's too late for 2.6.21 inclusion. All I'm trying to do here is
avoid the unexplainable and silent failure when AL2230S devices are used with
the current driver code. Thanks!

 zd_chip.c  |1 +
 zd_chip.h  |2 +-
 zd_rf_al2230.c |6 ++
 3 files changed, 8 insertions(+), 1 deletions(-)

Index: linux/drivers/net/wireless/zd1211rw/zd_chip.c
===
--- linux.orig/drivers/net/wireless/zd1211rw/zd_chip.c
+++ linux/drivers/net/wireless/zd1211rw/zd_chip.c
@@ -337,6 +337,7 @@ static int read_pod(struct zd_chip *chip
chip-patch_cr157 = (value  13)  0x1;
chip-patch_6m_band_edge = (value  21)  0x1;
chip-new_phy_layout = (value  31)  0x1;
+   chip-al2230s_bit = (value  7)  0x1;
chip-link_led = ((value  4)  1) ? LED1 : LED2;
chip-supports_tx_led = 1;
if (value  (1  24)) { /* LED scenario */
Index: linux/drivers/net/wireless/zd1211rw/zd_chip.h
===
--- linux.orig/drivers/net/wireless/zd1211rw/zd_chip.h
+++ linux/drivers/net/wireless/zd1211rw/zd_chip.h
@@ -711,7 +711,7 @@ struct zd_chip {
u16 link_led;
unsigned int pa_type:4,
patch_cck_gain:1, patch_cr157:1, patch_6m_band_edge:1,
-   new_phy_layout:1,
+   new_phy_layout:1, al2230s_bit:1,
is_zd1211b:1, supports_tx_led:1;
 };
 
Index: linux/drivers/net/wireless/zd1211rw/zd_rf_al2230.c
===
--- linux.orig/drivers/net/wireless/zd1211rw/zd_rf_al2230.c
+++ linux/drivers/net/wireless/zd1211rw/zd_rf_al2230.c
@@ -358,6 +358,12 @@ int zd_rf_init_al2230(struct zd_rf *rf)
 {
struct zd_chip *chip = zd_rf_to_chip(rf);
 
+   if (chip-al2230s_bit) {
+   dev_err(zd_chip_dev(chip), AL2230S devices are not yet 
+   supported by this driver.\n);
+   return -ENODEV;
+   }
+
rf-switch_radio_off = al2230_switch_radio_off;
if (chip-is_zd1211b) {
rf-init_hw = zd1211b_al2230_init_hw;
-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: wireless extensions vs. 64-bit architectures

2007-03-11 Thread Ulrich Kunitz
 I'm still not convinced that papering over the problem in userspace is a
 real solution.
 
 johannes

Just my 2 cents. I support this. What are the options? I see only
two:

1. Use different magic numbers for 32 bit and 64 bit structures. A
   flag is an alternative, but will be more difficult to debug.
   Generation of the magic should be easy, use sizeof(unsigned
   long) as test. User space has to care than for the rest.

2. Make the data representation identical in 32 bit and 64 bit.

   This shouldn't be to difficult, if only u8, u16 and u32 types
   are used. Pointers should be given as offsets. If necessary
   align and/or packed attributes could be used.

If the kernel interface can be changed, I vote for option 2,
because user space has then to deal with a unique data layout.
If the wext kernel interface cannot be changed to maintain
backward compatibility, then I have to admit band-aids in user
space are needed. However cfg80211 must not suffer from the same issues.

-- 
Uli Kunitz
-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: wireless extensions vs. 64-bit architectures

2007-03-11 Thread Michael Buesch
On Sunday 11 March 2007 21:11, Ulrich Kunitz wrote:
  I'm still not convinced that papering over the problem in userspace is a
  real solution.
  
  johannes
 
 Just my 2 cents. I support this. What are the options? I see only
 two:
 
 1. Use different magic numbers for 32 bit and 64 bit structures. A
flag is an alternative, but will be more difficult to debug.
Generation of the magic should be easy, use sizeof(unsigned
long) as test. User space has to care than for the rest.
 
 2. Make the data representation identical in 32 bit and 64 bit.
 
This shouldn't be to difficult, if only u8, u16 and u32 types
are used.

Pointers should be given as offsets.

Offsets to what?

If necessary  
align and/or packed attributes could be used.
 
 If the kernel interface can be changed, I vote for option 2,
 because user space has then to deal with a unique data layout.
 If the wext kernel interface cannot be changed to maintain
 backward compatibility, then I have to admit band-aids in user
 space are needed. However cfg80211 must not suffer from the same issues.

All your suggestions break the userspace ABI on all machines,
which is a thing we _really_ want to avoid.

The right fix is to have a compatibility wrapper in the kernel,
but it turns out to be hard to implement. I don't think we want
to change the structures layout and break ABI.

-- 
Greetings Michael.
-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH RESEND] zd1211rw-mac80211: changed Kconfig

2007-03-11 Thread Michael Wu
On Sunday 11 March 2007 15:19, Daniel Drake wrote:
 Changed the reference to Devicescape stack to mac80211.

I referred to Devicescape originally because the only other driver that had 
both softmac and devicescape versions was bcm43xx, so I copied (DeviceScape 
stack) in order to be consistent. I would prefer that there be one patch to 
replace both instances of (DeviceScape stack) with (mac80211 stack).

-Michael Wu


pgpdfFfONCtcV.pgp
Description: PGP signature


[PATCH 1/3] Remove ourselves from waitqueue when receiving a signal

2007-03-11 Thread ralf
Signed-off-by: Ralf Baechle [EMAIL PROTECTED]

 net/rose/af_rose.c |2 ++
 1 file changed, 2 insertions(+)

Index: linux-net/net/rose/af_rose.c
===
--- linux-net.orig/net/rose/af_rose.c
+++ linux-net/net/rose/af_rose.c
@@ -877,6 +877,8 @@ static int rose_accept(struct socket *so
lock_sock(sk);
continue;
}
+   current-state = TASK_RUNNING;
+   remove_wait_queue(sk-sk_sleep, wait);
return -ERESTARTSYS;
}
current-state = TASK_RUNNING;

-- 

-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/3] Socket locking is a great invention.

2007-03-11 Thread ralf
Especially if you actually try to do it ;-)

Signed-off-by: Ralf Baechle [EMAIL PROTECTED]

 net/rose/af_rose.c |   78 +
 1 file changed, 50 insertions(+), 28 deletions(-)

Index: linux-net/net/rose/af_rose.c
===
--- linux-net.orig/net/rose/af_rose.c
+++ linux-net/net/rose/af_rose.c
@@ -700,23 +700,7 @@ static int rose_connect(struct socket *s
unsigned char cause, diagnostic;
struct net_device *dev;
ax25_uid_assoc *user;
-   int n;
-
-   if (sk-sk_state == TCP_ESTABLISHED  sock-state == SS_CONNECTING) {
-   sock-state = SS_CONNECTED;
-   return 0;   /* Connect completed during a ERESTARTSYS event 
*/
-   }
-
-   if (sk-sk_state == TCP_CLOSE  sock-state == SS_CONNECTING) {
-   sock-state = SS_UNCONNECTED;
-   return -ECONNREFUSED;
-   }
-
-   if (sk-sk_state == TCP_ESTABLISHED)
-   return -EISCONN;/* No reconnect on a seqpacket socket */
-
-   sk-sk_state   = TCP_CLOSE;
-   sock-state = SS_UNCONNECTED;
+   int n, err = 0;
 
if (addr_len != sizeof(struct sockaddr_rose)  addr_len != 
sizeof(struct full_sockaddr_rose))
return -EINVAL;
@@ -734,24 +718,53 @@ static int rose_connect(struct socket *s
if ((rose-source_ndigis + addr-srose_ndigis)  ROSE_MAX_DIGIS)
return -EINVAL;
 
+   lock_sock(sk);
+
+   if (sk-sk_state == TCP_ESTABLISHED  sock-state == SS_CONNECTING) {
+   /* Connect completed during a ERESTARTSYS event */
+   sock-state = SS_CONNECTED;
+   goto out_release;
+   }
+
+   if (sk-sk_state == TCP_CLOSE  sock-state == SS_CONNECTING) {
+   sock-state = SS_UNCONNECTED;
+   err = -ECONNREFUSED;
+   goto out_release;
+   }
+
+   if (sk-sk_state == TCP_ESTABLISHED) {
+   /* No reconnect on a seqpacket socket */
+   err = -EISCONN;
+   goto out_release;
+   }
+
+   sk-sk_state   = TCP_CLOSE;
+   sock-state = SS_UNCONNECTED;
+
rose-neighbour = rose_get_neigh(addr-srose_addr, cause,
 diagnostic);
if (!rose-neighbour)
return -ENETUNREACH;
 
rose-lci = rose_new_lci(rose-neighbour);
-   if (!rose-lci)
-   return -ENETUNREACH;
+   if (!rose-lci) {
+   err = -ENETUNREACH;
+   goto out_release;
+   }
 
if (sock_flag(sk, SOCK_ZAPPED)) {   /* Must bind first - 
autobinding in this may or may not work */
sock_reset_flag(sk, SOCK_ZAPPED);
 
-   if ((dev = rose_dev_first()) == NULL)
-   return -ENETUNREACH;
+   if ((dev = rose_dev_first()) == NULL) {
+   err = -ENETUNREACH;
+   goto out_release;
+   }
 
user = ax25_findbyuid(current-euid);
-   if (!user)
-   return -EINVAL;
+   if (!user) {
+   err = -EINVAL;
+   goto out_release;
+   }
 
memcpy(rose-source_addr, dev-dev_addr, ROSE_ADDR_LEN);
rose-source_call = user-call;
@@ -789,8 +802,10 @@ rose_try_next_neigh:
rose_start_t1timer(sk);
 
/* Now the loop */
-   if (sk-sk_state != TCP_ESTABLISHED  (flags  O_NONBLOCK))
-   return -EINPROGRESS;
+   if (sk-sk_state != TCP_ESTABLISHED  (flags  O_NONBLOCK)) {
+   err = -EINPROGRESS;
+   goto out_release;
+   }
 
/*
 * A Connect Ack with Choke or timeout or failed routing will go to
@@ -805,8 +820,10 @@ rose_try_next_neigh:
set_current_state(TASK_INTERRUPTIBLE);
if (sk-sk_state != TCP_SYN_SENT)
break;
+   release_sock(sk);
if (!signal_pending(tsk)) {
schedule();
+   lock_sock(sk);
continue;
}
current-state = TASK_RUNNING;
@@ -822,14 +839,19 @@ rose_try_next_neigh:
rose-neighbour = rose_get_neigh(addr-srose_addr, cause, 
diagnostic);
if (rose-neighbour)
goto rose_try_next_neigh;
-   /* No more neighbour */
+
+   /* No more neighbours */
sock-state = SS_UNCONNECTED;
-   return sock_error(sk);  /* Always set at this point */
+   err = sock_error(sk);   /* Always set at this point */
+   goto out_release;
}
 
sock-state = SS_CONNECTED;
 
-   return 0;
+out_release:
+   release_sock(sk);
+
+   return err;
 }
 
 static int 

[PATCH 0/3] AX.25, NETROM and ROSE fixes and cleanups

2007-03-11 Thread ralf
Patches 1/3 and 2/3 are fixes for 2.6.21 and -stable.  3/3 is a cleanup
even though it seems to partly paper over a connection establishment issue
on extremly fast networks such as loopback I'm still chasing.

  Ralf

-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/3] Convert to use modern wait queue API

2007-03-11 Thread ralf
Signed-off-by: Ralf Baechle [EMAIL PROTECTED]

 net/ax25/af_ax25.c |   77 +++-
 net/netrom/af_netrom.c |   93 -
 net/rose/af_rose.c |   54 +---
 3 files changed, 109 insertions(+), 115 deletions(-)

Index: linux-net/net/ax25/af_ax25.c
===
--- linux-net.orig/net/ax25/af_ax25.c
+++ linux-net/net/ax25/af_ax25.c
@@ -1127,22 +1127,22 @@ static int __must_check ax25_connect(str
switch (sk-sk_state) {
case TCP_SYN_SENT: /* still trying */
err = -EINPROGRESS;
-   goto out;
+   goto out_release;
 
case TCP_ESTABLISHED: /* connection established */
sock-state = SS_CONNECTED;
-   goto out;
+   goto out_release;
 
case TCP_CLOSE: /* connection refused */
sock-state = SS_UNCONNECTED;
err = -ECONNREFUSED;
-   goto out;
+   goto out_release;
}
}
 
if (sk-sk_state == TCP_ESTABLISHED  sk-sk_type == SOCK_SEQPACKET) {
err = -EISCONN; /* No reconnect on a seqpacket socket */
-   goto out;
+   goto out_release;
}
 
sk-sk_state   = TCP_CLOSE;
@@ -1159,12 +1159,12 @@ static int __must_check ax25_connect(str
/* Valid number of digipeaters ? */
if (fsa-fsa_ax25.sax25_ndigis  1 || 
fsa-fsa_ax25.sax25_ndigis  AX25_MAX_DIGIS) {
err = -EINVAL;
-   goto out;
+   goto out_release;
}
 
if ((digi = kmalloc(sizeof(ax25_digi), GFP_KERNEL)) == NULL) {
err = -ENOBUFS;
-   goto out;
+   goto out_release;
}
 
digi-ndigi  = fsa-fsa_ax25.sax25_ndigis;
@@ -1194,7 +1194,7 @@ static int __must_check ax25_connect(str
current-comm);
if ((err = ax25_rt_autobind(ax25, fsa-fsa_ax25.sax25_call))  
0) {
kfree(digi);
-   goto out;
+   goto out_release;
}
 
ax25_fillin_cb(ax25, ax25-ax25_dev);
@@ -1203,7 +1203,7 @@ static int __must_check ax25_connect(str
if (ax25-ax25_dev == NULL) {
kfree(digi);
err = -EHOSTUNREACH;
-   goto out;
+   goto out_release;
}
}
 
@@ -1213,7 +1213,7 @@ static int __must_check ax25_connect(str
kfree(digi);
err = -EADDRINUSE;  /* Already such a connection */
ax25_cb_put(ax25t);
-   goto out;
+   goto out_release;
}
 
ax25-dest_addr = fsa-fsa_ax25.sax25_call;
@@ -1223,7 +1223,7 @@ static int __must_check ax25_connect(str
if (sk-sk_type != SOCK_SEQPACKET) {
sock-state = SS_CONNECTED;
sk-sk_state   = TCP_ESTABLISHED;
-   goto out;
+   goto out_release;
}
 
/* Move to connecting socket, ax.25 lapb WAIT_UA.. */
@@ -1255,55 +1255,53 @@ static int __must_check ax25_connect(str
/* Now the loop */
if (sk-sk_state != TCP_ESTABLISHED  (flags  O_NONBLOCK)) {
err = -EINPROGRESS;
-   goto out;
+   goto out_release;
}
 
if (sk-sk_state == TCP_SYN_SENT) {
-   struct task_struct *tsk = current;
-   DECLARE_WAITQUEUE(wait, tsk);
+   DEFINE_WAIT(wait);
 
-   add_wait_queue(sk-sk_sleep, wait);
for (;;) {
+   prepare_to_wait(sk-sk_sleep, wait,
+   TASK_INTERRUPTIBLE);
if (sk-sk_state != TCP_SYN_SENT)
break;
-   set_current_state(TASK_INTERRUPTIBLE);
-   release_sock(sk);
-   if (!signal_pending(tsk)) {
+   if (!signal_pending(current)) {
+   release_sock(sk);
schedule();
lock_sock(sk);
continue;
}
-   current-state = TASK_RUNNING;
-   remove_wait_queue(sk-sk_sleep, wait);
-   return -ERESTARTSYS;
+   err = -ERESTARTSYS;
+   break;
}
-   current-state = TASK_RUNNING;
-   remove_wait_queue(sk-sk_sleep, wait);
+   finish_wait(sk-sk_sleep, 

Re: [PATCH 4/4] PPPoE: race between interface going down and release()

2007-03-11 Thread Michal Ostrowski
Attached below is my take on how to address this problem.  
This addresses any concerns you may have had about checking po-pppoe_dev==NULL,
because accesses to this field are now synchronized with pppoe_hash_lock.

Once we can settle on a fix for this, I'll deal with the SID==0 issue 
(trying to do that now would just cause patch conflicts).

-- 
Michal Ostrowski [EMAIL PROTECTED]



[PATCH] PPPOE Fix device tear-down notification.

pppoe_flush_dev() kicks all sockets bound to a device that is going down.
In doing so, locks must be taken in the right order consistently (sock lock,
followed by the pppoe_hash_lock).  However, the scan process is based on
us holding the sock lock.  So, when something is found in the scan we must
release the lock we're holding and grab the sock lock.

This patch fixes race conditions between this code and pppoe_release(),
both of which perform similar functions but would naturally prefer to grab
locks in opposing orders.  Both code paths are now going after these locks
in a consistent manner.

pppoe_hash_lock protects the contents of the pppox_sock objects that reside
inside the hash.  Thus, NULL'ing out the pppoe_dev field should be done
under the protection of this lock.

Signed-off-by: Michal Ostrowski [EMAIL PROTECTED]
---
 drivers/net/pppoe.c |   93 +++---
 1 files changed, 50 insertions(+), 43 deletions(-)

diff --git a/drivers/net/pppoe.c b/drivers/net/pppoe.c
index e097688..0961bf9 100644
--- a/drivers/net/pppoe.c
+++ b/drivers/net/pppoe.c
@@ -241,56 +241,53 @@ static inline struct pppox_sock *delete_item(unsigned 
long sid, char *addr, int
 static void pppoe_flush_dev(struct net_device *dev)
 {
int hash;
-
BUG_ON(dev == NULL);
 
-   read_lock_bh(pppoe_hash_lock);
+   write_lock_bh(pppoe_hash_lock);
for (hash = 0; hash  PPPOE_HASH_SIZE; hash++) {
struct pppox_sock *po = item_hash_table[hash];
 
while (po != NULL) {
-   if (po-pppoe_dev == dev) {
-   struct sock *sk = sk_pppox(po);
-
-   sock_hold(sk);
-
-   /* We hold a reference to SK, now drop the
-* hash table lock so that we may attempt
-* to lock the socket (which can sleep).
-*/
-   read_unlock_bh(pppoe_hash_lock);
-
-   lock_sock(sk);
-
-   if(po-pppoe_dev==dev){
-   dev_put(dev);
-   po-pppoe_dev = NULL;
-   if (sk-sk_state 
-   (PPPOX_CONNECTED | PPPOX_BOUND)) {
-   pppox_unbind_sock(sk);
-   sk-sk_state = PPPOX_ZOMBIE;
-   sk-sk_state_change(sk);
-   }
-   }
-
-   release_sock(sk);
-
-   sock_put(sk);
-
-   read_lock_bh(pppoe_hash_lock);
-
-   /* Now restart from the beginning of this
-* hash chain.  We always NULL out pppoe_dev
-* so we are guaranteed to make forward
-* progress.
-*/
-   po = item_hash_table[hash];
+   struct sock *sk = sk_pppox(po);
+   if (po-pppoe_dev != dev) {
+   po = po-next;
continue;
}
-   po = po-next;
+   po-pppoe_dev = NULL;
+   dev_put(dev);
+   
+
+   /* We always grab the socket lock, followed by the
+* pppoe_hash_lock, in that order.  Since we should
+* hold the sock lock while doing any unbinding, 
+* we need to release the lock we're holding.  
+* Hold a reference to the sock so it doesn't disappear
+* as we're jumping between locks.
+*/
+
+   sock_hold(sk);
+
+   write_unlock_bh(pppoe_hash_lock);
+   lock_sock(sk);
+
+   if (sk-sk_state  (PPPOX_CONNECTED | PPPOX_BOUND)) {
+   pppox_unbind_sock(sk);
+   sk-sk_state = PPPOX_ZOMBIE;
+   sk-sk_state_change(sk);
+   }
+
+   release_sock(sk);
+   sock_put(sk);
+   

Re: [PATCHES 0/11] skb-mac.raw refactorings

2007-03-11 Thread David Miller
From: Arnaldo Carvalho de Melo [EMAIL PROTECTED]
Date: Sat, 10 Mar 2007 13:45:44 -0300

 Hi David,
 
  Paving the way for turning the layer headers offsets, to
 shrink struct sk_buff on 64bits (and perhaps on 32 bits too).
 
  Please consider pulling from:
 
 master.kernel.org:/pub/scm/linux/kernel/git/acme/net-2.6.22.git

Looks great, pulled, thanks a lot Arnaldo!
-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCHES 00/18] skb-nh refactorings

2007-03-11 Thread Arnaldo Carvalho de Melo

Hi David,

 Paving the way for turning the layer headers offsets, to
shrink struct sk_buff on 64bits (and perhaps on 32 bits too), this
time for skb-nh, more on this layer still to come (ip_hdr(), etc).

 Please consider pulling from:

master.kernel.org:/pub/scm/linux/kernel/git/acme/net-2.6.22.git

Best Regards,

- Arnaldo
-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 01/18][PPPOE]: Introduce pppoe_hdr()

2007-03-11 Thread Arnaldo Carvalho de Melo

For consistency with all the other skb-nh.raw accessors.

Also do some really obvious simplifications in pppoe_recvmsg, well the
kfree_skb one is not so obvious, but free() and kfree() have the same behaviour
(hint :-) ).

Signed-off-by: Arnaldo Carvalho de Melo [EMAIL PROTECTED]
---
drivers/net/pppoe.c  |   22 --
include/linux/if_pppox.h |7 +++
2 files changed, 15 insertions(+), 14 deletions(-)
From 44e47d74c33c877d9a86ab66ed29ab1a1df55f36 Mon Sep 17 00:00:00 2001
From: Arnaldo Carvalho de Melo [EMAIL PROTECTED]
Date: Sat, 10 Mar 2007 15:56:08 -0300
Subject: [PATCH 01/18] [PPPOE]: Introduce pppoe_hdr()

For consistency with all the other skb-nh.raw accessors.

Also do some really obvious simplifications in pppoe_recvmsg, well the
kfree_skb one is not so obvious, but free() and kfree() have the same behaviour
(hint :-) ).

Signed-off-by: Arnaldo Carvalho de Melo [EMAIL PROTECTED]
---
 drivers/net/pppoe.c  |   22 --
 include/linux/if_pppox.h |7 +++
 2 files changed, 15 insertions(+), 14 deletions(-)

diff --git a/drivers/net/pppoe.c b/drivers/net/pppoe.c
index ebfa296..3080a44 100644
--- a/drivers/net/pppoe.c
+++ b/drivers/net/pppoe.c
@@ -347,7 +347,7 @@ static int pppoe_rcv_core(struct sock *sk, struct sk_buff *skb)
 	struct pppox_sock *relay_po = NULL;
 
 	if (sk-sk_state  PPPOX_BOUND) {
-		struct pppoe_hdr *ph = (struct pppoe_hdr *) skb-nh.raw;
+		struct pppoe_hdr *ph = pppoe_hdr(skb);
 		int len = ntohs(ph-length);
 		skb_pull_rcsum(skb, sizeof(struct pppoe_hdr));
 		if (pskb_trim_rcsum(skb, len))
@@ -401,7 +401,7 @@ static int pppoe_rcv(struct sk_buff *skb,
 	if (!(skb = skb_share_check(skb, GFP_ATOMIC)))
 		goto out;
 
-	ph = (struct pppoe_hdr *) skb-nh.raw;
+	ph = pppoe_hdr(skb);
 
 	po = get_item((unsigned long) ph-sid, eth_hdr(skb)-h_source, dev-ifindex);
 	if (po != NULL)
@@ -433,7 +433,7 @@ static int pppoe_disc_rcv(struct sk_buff *skb,
 	if (!(skb = skb_share_check(skb, GFP_ATOMIC)))
 		goto out;
 
-	ph = (struct pppoe_hdr *) skb-nh.raw;
+	ph = pppoe_hdr(skb);
 	if (ph-code != PADT_CODE)
 		goto abort;
 
@@ -931,8 +931,6 @@ static int pppoe_recvmsg(struct kiocb *iocb, struct socket *sock,
 	struct sock *sk = sock-sk;
 	struct sk_buff *skb = NULL;
 	int error = 0;
-	int len;
-	struct pppoe_hdr *ph = NULL;
 
 	if (sk-sk_state  PPPOX_BOUND) {
 		error = -EIO;
@@ -949,19 +947,15 @@ static int pppoe_recvmsg(struct kiocb *iocb, struct socket *sock,
 	m-msg_namelen = 0;
 
 	if (skb) {
-		error = 0;
-		ph = (struct pppoe_hdr *) skb-nh.raw;
-		len = ntohs(ph-length);
+		struct pppoe_hdr *ph = pppoe_hdr(skb);
+		const int len = ntohs(ph-length);
 
 		error = memcpy_toiovec(m-msg_iov, (unsigned char *) ph-tag[0], len);
-		if (error  0)
-			goto do_skb_free;
-		error = len;
+		if (error == 0)
+			error = len;
 	}
 
-do_skb_free:
-	if (skb)
-		kfree_skb(skb);
+	kfree_skb(skb);
 end:
 	return error;
 }
diff --git a/include/linux/if_pppox.h b/include/linux/if_pppox.h
index e33ee76..7044f8a 100644
--- a/include/linux/if_pppox.h
+++ b/include/linux/if_pppox.h
@@ -112,6 +112,13 @@ struct pppoe_hdr {
 } __attribute__ ((packed));
 
 #ifdef __KERNEL__
+#include linux/skbuff.h
+
+static inline struct pppoe_hdr *pppoe_hdr(const struct sk_buff *skb)
+{
+	return (struct pppoe_hdr *)skb-nh.raw;
+}
+
 struct pppoe_opt {
 	struct net_device  *dev;	  /* device associated with socket*/
 	int			ifindex;  /* ifindex of device associated with socket */
-- 
1.5.0.2



[PATCH 02/18][BONDING]: Introduce arp_pkt()

2007-03-11 Thread Arnaldo Carvalho de Melo

For consistency with all the other skb-nh.raw accessors.

Signed-off-by: Arnaldo Carvalho de Melo [EMAIL PROTECTED]
---
drivers/net/bonding/bond_alb.c |9 +++--
1 files changed, 7 insertions(+), 2 deletions(-)
From 017d8a3262d70f04de22c653e80ef1137bacb88b Mon Sep 17 00:00:00 2001
From: Arnaldo Carvalho de Melo [EMAIL PROTECTED]
Date: Sat, 10 Mar 2007 16:07:19 -0300
Subject: [PATCH 02/18] [BONDING]: Introduce arp_pkt()

For consistency with all the other skb-nh.raw accessors.

Signed-off-by: Arnaldo Carvalho de Melo [EMAIL PROTECTED]
---
 drivers/net/bonding/bond_alb.c |9 +++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/net/bonding/bond_alb.c b/drivers/net/bonding/bond_alb.c
index 916162c..36b8e86 100644
--- a/drivers/net/bonding/bond_alb.c
+++ b/drivers/net/bonding/bond_alb.c
@@ -104,6 +104,11 @@ struct arp_pkt {
 };
 #pragma pack()
 
+static inline struct arp_pkt *arp_pkt(const struct sk_buff *skb)
+{
+	return (struct arp_pkt *)skb-nh.raw;
+}
+
 /* Forward declaration */
 static void alb_send_learning_packets(struct slave *slave, u8 mac_addr[]);
 
@@ -613,7 +618,7 @@ static void rlb_req_update_subnet_clients(struct bonding *bond, u32 src_ip)
 static struct slave *rlb_choose_channel(struct sk_buff *skb, struct bonding *bond)
 {
 	struct alb_bond_info *bond_info = (BOND_ALB_INFO(bond));
-	struct arp_pkt *arp = (struct arp_pkt *)skb-nh.raw;
+	struct arp_pkt *arp = arp_pkt(skb);
 	struct slave *assigned_slave;
 	struct rlb_client_info *client_info;
 	u32 hash_index = 0;
@@ -701,7 +706,7 @@ static struct slave *rlb_choose_channel(struct sk_buff *skb, struct bonding *bon
  */
 static struct slave *rlb_arp_xmit(struct sk_buff *skb, struct bonding *bond)
 {
-	struct arp_pkt *arp = (struct arp_pkt *)skb-nh.raw;
+	struct arp_pkt *arp = arp_pkt(skb);
 	struct slave *tx_slave = NULL;
 
 	if (arp-op_code == __constant_htons(ARPOP_REPLY)) {
-- 
1.5.0.2



[PATCH 03/18][IPV6]: Use skb-nh.ipv6h instead of casting skb-nh.raw

2007-03-11 Thread Arnaldo Carvalho de Melo

nh.ipv6h is there exactly for this reason! Use it while it exists ;-)

Signed-off-by: Arnaldo Carvalho de Melo [EMAIL PROTECTED]
---
net/ipv6/exthdrs.c |2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
From 45e1146ca9763f450277260d9c41f2b2e83b6d4e Mon Sep 17 00:00:00 2001
From: Arnaldo Carvalho de Melo [EMAIL PROTECTED]
Date: Sat, 10 Mar 2007 16:21:45 -0300
Subject: [PATCH 03/18] [IPV6]: Use skb-nh.ipv6h instead of casting skb-nh.raw

nh.ipv6h is there exactly for this reason! Use it while it exists ;-)

Signed-off-by: Arnaldo Carvalho de Melo [EMAIL PROTECTED]
---
 net/ipv6/exthdrs.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/net/ipv6/exthdrs.c b/net/ipv6/exthdrs.c
index e88befd..32b5560 100644
--- a/net/ipv6/exthdrs.c
+++ b/net/ipv6/exthdrs.c
@@ -200,7 +200,7 @@ static int ipv6_dest_hao(struct sk_buff **skbp, int optoff)
 	struct sk_buff *skb = *skbp;
 	struct ipv6_destopt_hao *hao;
 	struct inet6_skb_parm *opt = IP6CB(skb);
-	struct ipv6hdr *ipv6h = (struct ipv6hdr *)skb-nh.raw;
+	struct ipv6hdr *ipv6h = skb-nh.ipv6h;
 	struct in6_addr tmp_addr;
 	int ret;
 
-- 
1.5.0.2



[PATCH 04/18][SK_BUFF]: Introduce skb_reset_network_header(skb)

2007-03-11 Thread Arnaldo Carvalho de Melo

For the common, open coded 'skb-nh.raw = skb-data' operation, so that we can
later turn skb-nh.raw into a offset, reducing the size of struct sk_buff in
64bit land while possibly keeping it as a pointer on 32bit.

This one touches just the most simple case, next will handle the slightly more
complex cases.

Signed-off-by: Arnaldo Carvalho de Melo [EMAIL PROTECTED]
From 7d4879ce36c1494f0af3900c3676ee5ad4fbe16c Mon Sep 17 00:00:00 2001
From: Arnaldo Carvalho de Melo [EMAIL PROTECTED]
Date: Sat, 10 Mar 2007 16:56:45 -0300
Subject: [PATCH 04/18] [SK_BUFF]: Introduce skb_reset_network_header(skb)

For the common, open coded 'skb-nh.raw = skb-data' operation, so that we can
later turn skb-nh.raw into a offset, reducing the size of struct sk_buff in
64bit land while possibly keeping it as a pointer on 32bit.

This one touches just the most simple case, next will handle the slightly more
complex cases.

Signed-off-by: Arnaldo Carvalho de Melo [EMAIL PROTECTED]
---
 drivers/block/aoe/aoecmd.c|2 +-
 drivers/net/cxgb3/sge.c   |3 ++-
 drivers/net/hamradio/bpqether.c   |2 +-
 drivers/net/loopback.c|2 +-
 drivers/net/pppoe.c   |4 ++--
 drivers/net/wan/hdlc_cisco.c  |2 +-
 drivers/net/wan/hdlc_fr.c |2 +-
 drivers/net/wan/lmc/lmc_main.c|4 ++--
 drivers/net/wireless/hostap/hostap_80211_rx.c |4 ++--
 drivers/net/wireless/hostap/hostap_ap.c   |2 +-
 drivers/net/wireless/hostap/hostap_main.c |2 +-
 include/linux/skbuff.h|5 +
 include/net/llc_pdu.h |2 +-
 net/appletalk/aarp.c  |2 +-
 net/atm/mpc.c |2 +-
 net/ax25/af_ax25.c|2 +-
 net/ax25/ax25_ds_subr.c   |2 +-
 net/ax25/ax25_in.c|8 
 net/ax25/ax25_ip.c|2 +-
 net/ax25/ax25_out.c   |2 +-
 net/ax25/ax25_subr.c  |4 ++--
 net/core/dev.c|5 +++--
 net/core/netpoll.c|5 +++--
 net/decnet/dn_dev.c   |4 ++--
 net/decnet/dn_neigh.c |6 +++---
 net/decnet/dn_route.c |2 +-
 net/econet/af_econet.c|2 +-
 net/ieee80211/ieee80211_rx.c  |2 +-
 net/ipv4/arp.c|2 +-
 net/ipv4/ip_gre.c |2 +-
 net/ipv4/ip_output.c  |4 ++--
 net/ipv4/ipip.c   |4 ++--
 net/ipv4/route.c  |2 +-
 net/ipv4/xfrm4_mode_beet.c|2 +-
 net/ipv4/xfrm4_mode_tunnel.c  |2 +-
 net/ipv6/ip6_output.c |4 ++--
 net/ipv6/ip6_tunnel.c |6 +++---
 net/ipv6/sit.c|4 ++--
 net/ipv6/xfrm6_mode_beet.c|4 ++--
 net/ipv6/xfrm6_mode_tunnel.c  |4 ++--
 net/ipv6/xfrm6_output.c   |2 +-
 net/irda/irlap_frame.c|3 ++-
 net/iucv/af_iucv.c|2 +-
 net/llc/llc_sap.c |3 ++-
 net/netrom/nr_dev.c   |2 +-
 net/packet/af_packet.c|6 +++---
 net/tipc/eth_media.c  |2 +-
 net/wanrouter/af_wanpipe.c|2 +-
 net/x25/x25_dev.c |2 +-
 49 files changed, 80 insertions(+), 70 deletions(-)

diff --git a/drivers/block/aoe/aoecmd.c b/drivers/block/aoe/aoecmd.c
index 74062dc..1a6aeac 100644
--- a/drivers/block/aoe/aoecmd.c
+++ b/drivers/block/aoe/aoecmd.c
@@ -28,7 +28,7 @@ new_skb(ulong len)
 	skb = alloc_skb(len, GFP_ATOMIC);
 	if (skb) {
 		skb_reset_mac_header(skb);
-		skb-nh.raw = skb-data;
+		skb_reset_network_header(skb);
 		skb-protocol = __constant_htons(ETH_P_AOE);
 		skb-priority = 0;
 		skb-next = skb-prev = NULL;
diff --git a/drivers/net/cxgb3/sge.c b/drivers/net/cxgb3/sge.c
index 17fc3b0..c342b10 100644
--- a/drivers/net/cxgb3/sge.c
+++ b/drivers/net/cxgb3/sge.c
@@ -1621,7 +1621,8 @@ static inline int rx_offload(struct t3cdev *tdev, struct sge_rspq *rq,
 {
 	rq-offload_pkts++;
 	skb_reset_mac_header(skb);
-	skb-nh.raw = skb-h.raw = skb-data;
+	skb_reset_network_header(skb);
+	skb-h.raw = skb-data;
 
 	if (rq-polling) {
 		rx_gather[gather_idx++] = skb;
diff --git a/drivers/net/hamradio/bpqether.c b/drivers/net/hamradio/bpqether.c
index d254269..656f278 100644
--- a/drivers/net/hamradio/bpqether.c
+++ b/drivers/net/hamradio/bpqether.c
@@ -282,7 +282,7 @@ static int bpq_xmit(struct 

[PATCH 05/18][SK_BUFF]: Use skb_reset_network_header in skb_push cases

2007-03-11 Thread Arnaldo Carvalho de Melo

skb_push updates and returns skb-data, so we can just call
skb_reset_network_header after the call to skb_push.

Signed-off-by: Arnaldo Carvalho de Melo [EMAIL PROTECTED]
---
net/core/netpoll.c  |4 +++-
net/ipv4/ip_gre.c   |3 ++-
net/ipv4/ip_output.c|3 ++-
net/ipv4/ipip.c |3 ++-
net/ipv4/ipmr.c |3 ++-
net/ipv4/ipvs/ip_vs_xmit.c  |3 ++-
net/ipv4/xfrm4_mode_beet.c  |3 ++-
net/ipv4/xfrm4_mode_transport.c |4 +++-
net/ipv4/xfrm4_mode_tunnel.c|3 ++-
net/ipv6/ip6_output.c   |   14 ++
net/ipv6/ip6_tunnel.c   |3 ++-
net/ipv6/sit.c  |3 ++-
12 files changed, 34 insertions(+), 15 deletions(-)
From d3a4fc53413195467774a990ab3613873421f36f Mon Sep 17 00:00:00 2001
From: Arnaldo Carvalho de Melo [EMAIL PROTECTED]
Date: Sat, 10 Mar 2007 17:10:14 -0300
Subject: [PATCH 05/18] [SK_BUFF]: Use skb_reset_network_header in skb_push cases

skb_push updates and returns skb-data, so we can just call
skb_reset_network_header after the call to skb_push.

Signed-off-by: Arnaldo Carvalho de Melo [EMAIL PROTECTED]
---
 net/core/netpoll.c  |4 +++-
 net/ipv4/ip_gre.c   |3 ++-
 net/ipv4/ip_output.c|3 ++-
 net/ipv4/ipip.c |3 ++-
 net/ipv4/ipmr.c |3 ++-
 net/ipv4/ipvs/ip_vs_xmit.c  |3 ++-
 net/ipv4/xfrm4_mode_beet.c  |3 ++-
 net/ipv4/xfrm4_mode_transport.c |4 +++-
 net/ipv4/xfrm4_mode_tunnel.c|3 ++-
 net/ipv6/ip6_output.c   |   14 ++
 net/ipv6/ip6_tunnel.c   |3 ++-
 net/ipv6/sit.c  |3 ++-
 12 files changed, 34 insertions(+), 15 deletions(-)

diff --git a/net/core/netpoll.c b/net/core/netpoll.c
index d9560f4..355499b 100644
--- a/net/core/netpoll.c
+++ b/net/core/netpoll.c
@@ -308,7 +308,9 @@ void netpoll_send_udp(struct netpoll *np, const char *msg, int len)
 	if (udph-check == 0)
 		udph-check = CSUM_MANGLED_0;
 
-	skb-nh.iph = iph = (struct iphdr *)skb_push(skb, sizeof(*iph));
+	skb_push(skb, sizeof(*iph));
+	skb_reset_network_header(skb);
+	iph = skb-nh.iph;
 
 	/* iph-version = 4; iph-ihl = 5; */
 	put_unaligned(0x45, (unsigned char *)iph);
diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
index ced2c4b..f84ca66 100644
--- a/net/ipv4/ip_gre.c
+++ b/net/ipv4/ip_gre.c
@@ -828,7 +828,8 @@ static int ipgre_tunnel_xmit(struct sk_buff *skb, struct net_device *dev)
 	}
 
 	skb-h.raw = skb-nh.raw;
-	skb-nh.raw = skb_push(skb, gre_hlen);
+	skb_push(skb, gre_hlen);
+	skb_reset_network_header(skb);
 	memset((IPCB(skb)-opt), 0, sizeof(IPCB(skb)-opt));
 	IPCB(skb)-flags = ~(IPSKB_XFRM_TUNNEL_SIZE | IPSKB_XFRM_TRANSFORMED |
 			  IPSKB_REROUTED);
diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
index 32f1a23..d329718 100644
--- a/net/ipv4/ip_output.c
+++ b/net/ipv4/ip_output.c
@@ -503,7 +503,8 @@ int ip_fragment(struct sk_buff *skb, int (*output)(struct sk_buff*))
 			if (frag) {
 frag-ip_summed = CHECKSUM_NONE;
 frag-h.raw = frag-data;
-frag-nh.raw = __skb_push(frag, hlen);
+__skb_push(frag, hlen);
+skb_reset_network_header(frag);
 memcpy(frag-nh.raw, iph, hlen);
 iph = frag-nh.iph;
 iph-tot_len = htons(frag-len);
diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c
index 5f886c8..843cc09 100644
--- a/net/ipv4/ipip.c
+++ b/net/ipv4/ipip.c
@@ -619,7 +619,8 @@ static int ipip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev)
 	}
 
 	skb-h.raw = skb-nh.raw;
-	skb-nh.raw = skb_push(skb, sizeof(struct iphdr));
+	skb_push(skb, sizeof(struct iphdr));
+	skb_reset_network_header(skb);
 	memset((IPCB(skb)-opt), 0, sizeof(IPCB(skb)-opt));
 	IPCB(skb)-flags = ~(IPSKB_XFRM_TUNNEL_SIZE | IPSKB_XFRM_TRANSFORMED |
 			  IPSKB_REROUTED);
diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c
index f73f4e4..05c82ca 100644
--- a/net/ipv4/ipmr.c
+++ b/net/ipv4/ipmr.c
@@ -1593,7 +1593,8 @@ int ipmr_get_route(struct sk_buff *skb, struct rtmsg *rtm, int nowait)
 			return -ENOMEM;
 		}
 
-		skb2-nh.raw = skb_push(skb2, sizeof(struct iphdr));
+		skb_push(skb2, sizeof(struct iphdr));
+		skb_reset_network_header(skb2);
 		skb2-nh.iph-ihl = sizeof(struct iphdr)2;
 		skb2-nh.iph-saddr = rt-rt_src;
 		skb2-nh.iph-daddr = rt-rt_dst;
diff --git a/net/ipv4/ipvs/ip_vs_xmit.c b/net/ipv4/ipvs/ip_vs_xmit.c
index f73c5ac..d1403d0 100644
--- a/net/ipv4/ipvs/ip_vs_xmit.c
+++ b/net/ipv4/ipvs/ip_vs_xmit.c
@@ -385,7 +385,8 @@ ip_vs_tunnel_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
 	/* fix old IP header checksum */
 	ip_send_check(old_iph);
 
-	skb-nh.raw = skb_push(skb, sizeof(struct iphdr));
+	skb_push(skb, sizeof(struct iphdr));
+	skb_reset_network_header(skb);
 	memset((IPCB(skb)-opt), 0, sizeof(IPCB(skb)-opt));
 
 	/* drop old route */
diff --git a/net/ipv4/xfrm4_mode_beet.c b/net/ipv4/xfrm4_mode_beet.c
index 415eeba..19c31be 100644
--- a/net/ipv4/xfrm4_mode_beet.c
+++ b/net/ipv4/xfrm4_mode_beet.c
@@ -40,7 

[PATCH 06/18][SK_BUFF]: Use skb_reset_network_header where the skb_pull return was being used

2007-03-11 Thread Arnaldo Carvalho de Melo

But only in the cases where its a newly allocated skb, i.e. one where skb-tail
is equal to skb-data, or just after skb_reserve, where this requirement is
maintained.

Signed-off-by: Arnaldo Carvalho de Melo [EMAIL PROTECTED]
---
net/appletalk/aarp.c |   12 +---
net/ipv4/igmp.c  |8 ++--
net/ipv4/raw.c   |4 +++-
net/ipx/af_ipx.c |4 +++-
net/ipx/ipx_route.c  |4 +++-
5 files changed, 24 insertions(+), 8 deletions(-)
From 52fa2da26b01d0f0d2fc15ace358b33847c38a29 Mon Sep 17 00:00:00 2001
From: Arnaldo Carvalho de Melo [EMAIL PROTECTED]
Date: Sat, 10 Mar 2007 18:40:59 -0300
Subject: [PATCH 06/18] [SK_BUFF]: Use skb_reset_network_header where the skb_pull return was being used

But only in the cases where its a newly allocated skb, i.e. one where skb-tail
is equal to skb-data, or just after skb_reserve, where this requirement is
maintained.

Signed-off-by: Arnaldo Carvalho de Melo [EMAIL PROTECTED]
---
 net/appletalk/aarp.c |   12 +---
 net/ipv4/igmp.c  |8 ++--
 net/ipv4/raw.c   |4 +++-
 net/ipx/af_ipx.c |4 +++-
 net/ipx/ipx_route.c  |4 +++-
 5 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/net/appletalk/aarp.c b/net/appletalk/aarp.c
index d4e5ba2..de495c5 100644
--- a/net/appletalk/aarp.c
+++ b/net/appletalk/aarp.c
@@ -118,7 +118,9 @@ static void __aarp_send_query(struct aarp_entry *a)
 
 	/* Set up the buffer */
 	skb_reserve(skb, dev-hard_header_len + aarp_dl-header_length);
-	skb-nh.raw  = skb-h.raw = skb_put(skb, sizeof(*eah));
+	skb_reset_network_header(skb);
+	skb-h.raw	 = skb-data;
+	skb_put(skb, sizeof(*eah));
 	skb-protocol= htons(ETH_P_ATALK);
 	skb-dev	 = dev;
 	eah		 = aarp_hdr(skb);
@@ -163,7 +165,9 @@ static void aarp_send_reply(struct net_device *dev, struct atalk_addr *us,
 
 	/* Set up the buffer */
 	skb_reserve(skb, dev-hard_header_len + aarp_dl-header_length);
-	skb-nh.raw  = skb-h.raw = skb_put(skb, sizeof(*eah));
+	skb_reset_network_header(skb);
+	skb-h.raw	 = skb-data;
+	skb_put(skb, sizeof(*eah));
 	skb-protocol= htons(ETH_P_ATALK);
 	skb-dev	 = dev;
 	eah		 = aarp_hdr(skb);
@@ -212,7 +216,9 @@ static void aarp_send_probe(struct net_device *dev, struct atalk_addr *us)
 
 	/* Set up the buffer */
 	skb_reserve(skb, dev-hard_header_len + aarp_dl-header_length);
-	skb-nh.raw  = skb-h.raw = skb_put(skb, sizeof(*eah));
+	skb_reset_network_header(skb);
+	skb-h.raw	 = skb-data;
+	skb_put(skb, sizeof(*eah));
 	skb-protocol= htons(ETH_P_ATALK);
 	skb-dev	 = dev;
 	eah		 = aarp_hdr(skb);
diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c
index 1c6a084..019ec21 100644
--- a/net/ipv4/igmp.c
+++ b/net/ipv4/igmp.c
@@ -314,7 +314,9 @@ static struct sk_buff *igmpv3_newpack(struct net_device *dev, int size)
 
 	skb_reserve(skb, LL_RESERVED_SPACE(dev));
 
-	skb-nh.iph = pip =(struct iphdr *)skb_put(skb, sizeof(struct iphdr)+4);
+	skb_reset_network_header(skb);
+	pip = skb-nh.iph;
+	skb_put(skb, sizeof(struct iphdr) + 4);
 
 	pip-version  = 4;
 	pip-ihl  = (sizeof(struct iphdr)+4)2;
@@ -664,7 +666,9 @@ static int igmp_send_report(struct in_device *in_dev, struct ip_mc_list *pmc,
 
 	skb_reserve(skb, LL_RESERVED_SPACE(dev));
 
-	skb-nh.iph = iph = (struct iphdr *)skb_put(skb, sizeof(struct iphdr)+4);
+	skb_reset_network_header(skb);
+	iph = skb-nh.iph;
+	skb_put(skb, sizeof(struct iphdr) + 4);
 
 	iph-version  = 4;
 	iph-ihl  = (sizeof(struct iphdr)+4)2;
diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
index 87e9c16..67e5e3c 100644
--- a/net/ipv4/raw.c
+++ b/net/ipv4/raw.c
@@ -291,7 +291,9 @@ static int raw_send_hdrinc(struct sock *sk, void *from, size_t length,
 	skb-priority = sk-sk_priority;
 	skb-dst = dst_clone(rt-u.dst);
 
-	skb-nh.iph = iph = (struct iphdr *)skb_put(skb, length);
+	skb_reset_network_header(skb);
+	iph = skb-nh.iph;
+	skb_put(skb, length);
 
 	skb-ip_summed = CHECKSUM_NONE;
 
diff --git a/net/ipx/af_ipx.c b/net/ipx/af_ipx.c
index 6c6c0a3..9aa7b96 100644
--- a/net/ipx/af_ipx.c
+++ b/net/ipx/af_ipx.c
@@ -576,7 +576,9 @@ static struct sk_buff *ipxitf_adjust_skbuff(struct ipx_interface *intrfc,
 	skb2 = alloc_skb(len, GFP_ATOMIC);
 	if (skb2) {
 		skb_reserve(skb2, out_offset);
-		skb2-nh.raw = skb2-h.raw = skb_put(skb2, skb-len);
+		skb_reset_network_header(skb2);
+		skb2-h.raw = skb2-data;
+		skb_put(skb2, skb-len);
 		memcpy(ipx_hdr(skb2), ipx_hdr(skb), skb-len);
 		memcpy(skb2-cb, skb-cb, sizeof(skb-cb));
 	}
diff --git a/net/ipx/ipx_route.c b/net/ipx/ipx_route.c
index 8e1cad9..e8277f5 100644
--- a/net/ipx/ipx_route.c
+++ b/net/ipx/ipx_route.c
@@ -203,7 +203,9 @@ int ipxrtr_route_packet(struct sock *sk, struct sockaddr_ipx *usipx,
 	skb-sk = sk;
 
 	/* Fill in IPX header */
-	skb-h.raw = skb-nh.raw = skb_put(skb, sizeof(struct ipxhdr));
+	skb_reset_network_header(skb);
+	skb-h.raw = skb-data;
+	skb_put(skb, sizeof(struct ipxhdr));
 	ipx = ipx_hdr(skb);
 	ipx-ipx_pktsize = htons(len + sizeof(struct ipxhdr));
 	IPX_SKB_CB(skb)-ipx_tctrl = 0;
-- 
1.5.0.2



[PATCH 07/18][SK_BUFF]: Use skb_reset_network_header where the return of __pskb_pull was being used

2007-03-11 Thread Arnaldo Carvalho de Melo

It returns skb-data, so we can just use skb_reset_network_header after it.

Signed-off-by: Arnaldo Carvalho de Melo [EMAIL PROTECTED]
---
net/ipv4/ip_gre.c |3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
From 5993129f2113315b46f5045d2a7c333a24f3ae1b Mon Sep 17 00:00:00 2001
From: Arnaldo Carvalho de Melo [EMAIL PROTECTED]
Date: Sat, 10 Mar 2007 18:42:03 -0300
Subject: [PATCH 07/18] [SK_BUFF]: Use skb_reset_network_header where the return of __pskb_pull was being used

It returns skb-data, so we can just use skb_reset_network_header after it.

Signed-off-by: Arnaldo Carvalho de Melo [EMAIL PROTECTED]
---
 net/ipv4/ip_gre.c |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
index f84ca66..7c6fda6 100644
--- a/net/ipv4/ip_gre.c
+++ b/net/ipv4/ip_gre.c
@@ -617,7 +617,8 @@ static int ipgre_rcv(struct sk_buff *skb)
 		}
 
 		skb_reset_mac_header(skb);
-		skb-nh.raw = __pskb_pull(skb, offset);
+		__pskb_pull(skb, offset);
+		skb_reset_network_header(skb);
 		skb_postpull_rcsum(skb, skb-h.raw, offset);
 		skb-pkt_type = PACKET_HOST;
 #ifdef CONFIG_NET_IPGRE_BROADCAST
-- 
1.5.0.2



[PATCH 08/18][SK_BUFF]: Some more simple skb_reset_network_header conversions

2007-03-11 Thread Arnaldo Carvalho de Melo

This time of the type:

skb-nh.iph = (struct iphdr *)skb-data;

That is completely equivalent to:

skb-nh.raw = skb-data;

Wonder why people love casts... :-)

Signed-off-by: Arnaldo Carvalho de Melo [EMAIL PROTECTED]
---
net/ieee80211/ieee80211_rx.c |2 +-
net/ipv4/ipmr.c  |4 ++--
net/sctp/input.c |2 +-
3 files changed, 4 insertions(+), 4 deletions(-)
From 983fc856a958d2151f2b29ffaa55327aaeb4ea3e Mon Sep 17 00:00:00 2001
From: Arnaldo Carvalho de Melo [EMAIL PROTECTED]
Date: Sat, 10 Mar 2007 19:04:55 -0300
Subject: [PATCH 08/18] [SK_BUFF]: Some more simple skb_reset_network_header conversions

This time of the type:

 skb-nh.iph = (struct iphdr *)skb-data;

That is completely equivalent to:

 skb-nh.raw = skb-data;

Wonder why people love casts... :-)

Signed-off-by: Arnaldo Carvalho de Melo [EMAIL PROTECTED]
---
 net/ieee80211/ieee80211_rx.c |2 +-
 net/ipv4/ipmr.c  |4 ++--
 net/sctp/input.c |2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/net/ieee80211/ieee80211_rx.c b/net/ieee80211/ieee80211_rx.c
index be5ffaf..7f5a352 100644
--- a/net/ieee80211/ieee80211_rx.c
+++ b/net/ieee80211/ieee80211_rx.c
@@ -793,7 +793,7 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
 		skb2-protocol = __constant_htons(ETH_P_802_3);
 		skb_reset_mac_header(skb2);
 		skb_reset_network_header(skb2);
-		/* skb2-nh.raw = skb2-data + ETH_HLEN; */
+		/* skb2-nh.raw += ETH_HLEN; */
 		dev_queue_xmit(skb2);
 	}
 #endif
diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c
index 05c82ca..45435f0 100644
--- a/net/ipv4/ipmr.c
+++ b/net/ipv4/ipmr.c
@@ -1454,7 +1454,7 @@ int pim_rcv_v1(struct sk_buff * skb)
 
 	skb-mac.raw = skb-nh.raw;
 	skb_pull(skb, (u8*)encap - skb-data);
-	skb-nh.iph = (struct iphdr *)skb-data;
+	skb_reset_network_header(skb);
 	skb-dev = reg_dev;
 	skb-protocol = htons(ETH_P_IP);
 	skb-ip_summed = 0;
@@ -1509,7 +1509,7 @@ static int pim_rcv(struct sk_buff * skb)
 
 	skb-mac.raw = skb-nh.raw;
 	skb_pull(skb, (u8*)encap - skb-data);
-	skb-nh.iph = (struct iphdr *)skb-data;
+	skb_reset_network_header(skb);
 	skb-dev = reg_dev;
 	skb-protocol = htons(ETH_P_IP);
 	skb-ip_summed = 0;
diff --git a/net/sctp/input.c b/net/sctp/input.c
index 71db668..2b0863a 100644
--- a/net/sctp/input.c
+++ b/net/sctp/input.c
@@ -528,7 +528,7 @@ void sctp_v4_err(struct sk_buff *skb, __u32 info)
 	/* Fix up skb to look at the embedded net header. */
 	saveip = skb-nh.raw;
 	savesctp  = skb-h.raw;
-	skb-nh.iph = iph;
+	skb_reset_network_header(skb);
 	skb-h.raw = (char *)sh;
 	sk = sctp_err_lookup(AF_INET, skb, sh, asoc, transport);
 	/* Put back, the original pointers. */
-- 
1.5.0.2



[PATCH 10/18][SK_BUFF] ipconfig: Another conversion to skb_reset_network_header related to skb_put

2007-03-11 Thread Arnaldo Carvalho de Melo

boot_pkt-iph is the first member, that is at skb-data, so just use
skb_reset_network_header().

Signed-off-by: Arnaldo Carvalho de Melo [EMAIL PROTECTED]
---
net/ipv4/ipconfig.c |3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
From 71ecb4941b897c724bb7b9762cf49d1979403362 Mon Sep 17 00:00:00 2001
From: Arnaldo Carvalho de Melo [EMAIL PROTECTED]
Date: Sat, 10 Mar 2007 19:27:27 -0300
Subject: [PATCH 10/18] [SK_BUFF] ipconfig: Another conversion to skb_reset_network_header related to skb_put

boot_pkt-iph is the first member, that is at skb-data, so just use
skb_reset_network_header().

Signed-off-by: Arnaldo Carvalho de Melo [EMAIL PROTECTED]
---
 net/ipv4/ipconfig.c |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
index c43699f..6e89984 100644
--- a/net/ipv4/ipconfig.c
+++ b/net/ipv4/ipconfig.c
@@ -702,7 +702,8 @@ static void __init ic_bootp_send_if(struct ic_device *d, unsigned long jiffies_d
 	memset(b, 0, sizeof(struct bootp_pkt));
 
 	/* Construct IP header */
-	skb-nh.iph = h = b-iph;
+	skb_reset_network_header(skb);
+	h = skb-nh.iph;
 	h-version = 4;
 	h-ihl = 5;
 	h-tot_len = htons(sizeof(struct bootp_pkt));
-- 
1.5.0.2



[PATCH 11/18][SK_BUFF]: Use skb_reset_network_header after skb_push

2007-03-11 Thread Arnaldo Carvalho de Melo

Some more cases where skb-nh.iph was being set that were converted
to using skb_reset_network_header.

Signed-off-by: Arnaldo Carvalho de Melo [EMAIL PROTECTED]
---
net/ipv4/ip_output.c |   14 ++
net/ipv4/ipmr.c  |9 ++---
2 files changed, 12 insertions(+), 11 deletions(-)
From 56b07c24188ae240271e35b7d9f1a887a7a59fd8 Mon Sep 17 00:00:00 2001
From: Arnaldo Carvalho de Melo [EMAIL PROTECTED]
Date: Sat, 10 Mar 2007 19:40:39 -0300
Subject: [PATCH 11/18] [SK_BUFF]: Use skb_reset_network_header after skb_push

Some more cases where skb-nh.iph was being set that were converted
to using skb_reset_network_header.

Signed-off-by: Arnaldo Carvalho de Melo [EMAIL PROTECTED]
---
 net/ipv4/ip_output.c |   14 ++
 net/ipv4/ipmr.c  |9 ++---
 2 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
index dde51fb..99cd90c 100644
--- a/net/ipv4/ip_output.c
+++ b/net/ipv4/ip_output.c
@@ -125,11 +125,9 @@ int ip_build_and_send_pkt(struct sk_buff *skb, struct sock *sk,
 	struct iphdr *iph;
 
 	/* Build the IP header. */
-	if (opt)
-		iph=(struct iphdr *)skb_push(skb,sizeof(struct iphdr) + opt-optlen);
-	else
-		iph=(struct iphdr *)skb_push(skb,sizeof(struct iphdr));
-
+	skb_push(skb, sizeof(struct iphdr) + (opt ? opt-optlen : 0));
+	skb_reset_network_header(skb);
+	iph = skb-nh.iph;
 	iph-version  = 4;
 	iph-ihl  = 5;
 	iph-tos  = inet-tos;
@@ -143,7 +141,6 @@ int ip_build_and_send_pkt(struct sk_buff *skb, struct sock *sk,
 	iph-protocol = sk-sk_protocol;
 	iph-tot_len  = htons(skb-len);
 	ip_select_ident(iph, rt-u.dst, sk);
-	skb-nh.iph   = iph;
 
 	if (opt  opt-optlen) {
 		iph-ihl += opt-optlen2;
@@ -333,7 +330,9 @@ packet_routed:
 		goto no_route;
 
 	/* OK, we know where to send it, allocate and build IP header. */
-	iph = (struct iphdr *) skb_push(skb, sizeof(struct iphdr) + (opt ? opt-optlen : 0));
+	skb_push(skb, sizeof(struct iphdr) + (opt ? opt-optlen : 0));
+	skb_reset_network_header(skb);
+	iph = skb-nh.iph;
 	*((__be16 *)iph) = htons((4  12) | (5  8) | (inet-tos  0xff));
 	iph-tot_len = htons(skb-len);
 	if (ip_dont_fragment(sk, rt-u.dst)  !ipfragok)
@@ -344,7 +343,6 @@ packet_routed:
 	iph-protocol = sk-sk_protocol;
 	iph-saddr= rt-rt_src;
 	iph-daddr= rt-rt_dst;
-	skb-nh.iph   = iph;
 	/* Transport layer set skb-h.foo itself. */
 
 	if (opt  opt-optlen) {
diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c
index 45435f0..51528d3 100644
--- a/net/ipv4/ipmr.c
+++ b/net/ipv4/ipmr.c
@@ -1093,7 +1093,12 @@ static struct notifier_block ip_mr_notifier={
 
 static void ip_encap(struct sk_buff *skb, __be32 saddr, __be32 daddr)
 {
-	struct iphdr *iph = (struct iphdr *)skb_push(skb,sizeof(struct iphdr));
+	struct iphdr *iph;
+
+	skb_push(skb, sizeof(struct iphdr));
+	skb-h.ipiph = skb-nh.iph;
+	skb_reset_network_header(skb);
+	iph = skb-nh.iph;
 
 	iph-version	= 	4;
 	iph-tos	=	skb-nh.iph-tos;
@@ -1107,8 +1112,6 @@ static void ip_encap(struct sk_buff *skb, __be32 saddr, __be32 daddr)
 	ip_select_ident(iph, skb-dst, NULL);
 	ip_send_check(iph);
 
-	skb-h.ipiph = skb-nh.iph;
-	skb-nh.iph = iph;
 	memset((IPCB(skb)-opt), 0, sizeof(IPCB(skb)-opt));
 	nf_reset(skb);
 }
-- 
1.5.0.2



[PATCH 12/18][SK_BUFF] ipv6: More skb_reset_network_header conversions related to skb_pull

2007-03-11 Thread Arnaldo Carvalho de Melo

Now related to this form:

skb-nh.ipv6h = (struct ipv6hdr *)skb_put(skb, length);

That, as the others, is done when skb-tail is still equal to skb-data, making
the conversion to skb_reset_network_header possible.

Also one more case equivalent to skb-nh.raw = skb-data, of this form:

iph = (struct ipv6hdr *)skb-data;
SNIP
skb-nh.ipv6h = iph;

Signed-off-by: Arnaldo Carvalho de Melo [EMAIL PROTECTED]
---
net/ipv6/datagram.c  |5 +++--
net/ipv6/netfilter/ip6t_REJECT.c |5 +++--
net/ipv6/raw.c   |4 +++-
net/sctp/ipv6.c  |3 +--
4 files changed, 10 insertions(+), 7 deletions(-)
From a2440f6dec2b4f3fd9690bf1c9d01f9aad13e99d Mon Sep 17 00:00:00 2001
From: Arnaldo Carvalho de Melo [EMAIL PROTECTED]
Date: Sat, 10 Mar 2007 19:57:15 -0300
Subject: [PATCH 12/18] [SK_BUFF] ipv6: More skb_reset_network_header conversions related to skb_pull

Now related to this form:

skb-nh.ipv6h = (struct ipv6hdr *)skb_put(skb, length);

That, as the others, is done when skb-tail is still equal to skb-data, making
the conversion to skb_reset_network_header possible.

Also one more case equivalent to skb-nh.raw = skb-data, of this form:

iph = (struct ipv6hdr *)skb-data;
SNIP
skb-nh.ipv6h = iph;

Signed-off-by: Arnaldo Carvalho de Melo [EMAIL PROTECTED]
---
 net/ipv6/datagram.c  |5 +++--
 net/ipv6/netfilter/ip6t_REJECT.c |5 +++--
 net/ipv6/raw.c   |4 +++-
 net/sctp/ipv6.c  |3 +--
 4 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/net/ipv6/datagram.c b/net/ipv6/datagram.c
index 3b4e8dc..31a20f1 100644
--- a/net/ipv6/datagram.c
+++ b/net/ipv6/datagram.c
@@ -251,8 +251,9 @@ void ipv6_local_error(struct sock *sk, int err, struct flowi *fl, u32 info)
 	if (!skb)
 		return;
 
-	iph = (struct ipv6hdr*)skb_put(skb, sizeof(struct ipv6hdr));
-	skb-nh.ipv6h = iph;
+	skb_put(skb, sizeof(struct ipv6hdr));
+	skb_reset_network_header(skb);
+	iph = skb-nh.ipv6h;
 	ipv6_addr_copy(iph-daddr, fl-fl6_dst);
 
 	serr = SKB_EXT_ERR(skb);
diff --git a/net/ipv6/netfilter/ip6t_REJECT.c b/net/ipv6/netfilter/ip6t_REJECT.c
index 6abee94..4441bed 100644
--- a/net/ipv6/netfilter/ip6t_REJECT.c
+++ b/net/ipv6/netfilter/ip6t_REJECT.c
@@ -120,8 +120,9 @@ static void send_reset(struct sk_buff *oldskb)
 
 	skb_reserve(nskb, hh_len + dst-header_len);
 
-	ip6h = nskb-nh.ipv6h = (struct ipv6hdr *)
-	skb_put(nskb, sizeof(struct ipv6hdr));
+	skb_put(nskb, sizeof(struct ipv6hdr));
+	skb_reset_network_header(nskb);
+	ip6h = nskb-nh.ipv6h;
 	ip6h-version = 6;
 	ip6h-hop_limit = dst_metric(dst, RTAX_HOPLIMIT);
 	ip6h-nexthdr = IPPROTO_TCP;
diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
index 306d5d8..f2b09a7 100644
--- a/net/ipv6/raw.c
+++ b/net/ipv6/raw.c
@@ -575,7 +575,9 @@ static int rawv6_send_hdrinc(struct sock *sk, void *from, int length,
 	skb-priority = sk-sk_priority;
 	skb-dst = dst_clone(rt-u.dst);
 
-	skb-nh.ipv6h = iph = (struct ipv6hdr *)skb_put(skb, length);
+	skb_put(skb, length);
+	skb_reset_network_header(skb);
+	iph = skb-nh.ipv6h;
 
 	skb-ip_summed = CHECKSUM_NONE;
 
diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
index 63fe109..3a9272f 100644
--- a/net/sctp/ipv6.c
+++ b/net/sctp/ipv6.c
@@ -122,7 +122,6 @@ SCTP_STATIC void sctp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
 			 int type, int code, int offset, __be32 info)
 {
 	struct inet6_dev *idev;
-	struct ipv6hdr *iph = (struct ipv6hdr *)skb-data;
 	struct sctphdr *sh = (struct sctphdr *)(skb-data + offset);
 	struct sock *sk;
 	struct sctp_association *asoc;
@@ -136,7 +135,7 @@ SCTP_STATIC void sctp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
 	/* Fix up skb to look at the embedded net header. */
 	saveip = skb-nh.raw;
 	savesctp  = skb-h.raw;
-	skb-nh.ipv6h = iph;
+	skb_reset_network_header(skb);
 	skb-h.raw = (char *)sh;
 	sk = sctp_err_lookup(AF_INET6, skb, sh, asoc, transport);
 	/* Put back, the original pointers. */
-- 
1.5.0.2



[PATCH 13/18][SK_BUFF] xfrm4: use skb_reset_network_header

2007-03-11 Thread Arnaldo Carvalho de Melo

Setting it to skb-h.raw, which is valid, in the (to become) old pointer based
world order and in the new world of offset based layer headers.

Signed-off-by: Arnaldo Carvalho de Melo [EMAIL PROTECTED]
---
net/ipv4/xfrm4_mode_transport.c |6 --
1 files changed, 4 insertions(+), 2 deletions(-)
From 1be06f79a01bf57737caf1b7280e3b07335b0f7e Mon Sep 17 00:00:00 2001
From: Arnaldo Carvalho de Melo [EMAIL PROTECTED]
Date: Sat, 10 Mar 2007 19:59:16 -0300
Subject: [PATCH 13/18] [SK_BUFF] xfrm4: use skb_reset_network_header

Setting it to skb-h.raw, which is valid, in the (to become) old pointer based
world order and in the new world of offset based layer headers.

Signed-off-by: Arnaldo Carvalho de Melo [EMAIL PROTECTED]
---
 net/ipv4/xfrm4_mode_transport.c |6 --
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/net/ipv4/xfrm4_mode_transport.c b/net/ipv4/xfrm4_mode_transport.c
index 290c0f2..a820dde 100644
--- a/net/ipv4/xfrm4_mode_transport.c
+++ b/net/ipv4/xfrm4_mode_transport.c
@@ -50,8 +50,10 @@ static int xfrm4_transport_input(struct xfrm_state *x, struct sk_buff *skb)
 {
 	int ihl = skb-data - skb-h.raw;
 
-	if (skb-h.raw != skb-nh.raw)
-		skb-nh.raw = memmove(skb-h.raw, skb-nh.raw, ihl);
+	if (skb-h.raw != skb-nh.raw) {
+		memmove(skb-h.raw, skb-nh.raw, ihl);
+		skb-nh.raw = skb-h.raw;
+	}
 	skb-nh.iph-tot_len = htons(skb-len + ihl);
 	skb-h.raw = skb-data;
 	return 0;
-- 
1.5.0.2



[PATCH 14/18][SK_BUFF] bonding: Set skb-nh.raw relative to skb-mac.raw

2007-03-11 Thread Arnaldo Carvalho de Melo

Signed-off-by: Arnaldo Carvalho de Melo [EMAIL PROTECTED]
---
drivers/net/bonding/bond_3ad.c |4 ++--
drivers/net/bonding/bond_alb.c |2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
From c71af7068c66bcbc377b1e4593eb58bec961699c Mon Sep 17 00:00:00 2001
From: Arnaldo Carvalho de Melo [EMAIL PROTECTED]
Date: Sat, 10 Mar 2007 20:09:45 -0300
Subject: [PATCH 14/18] [SK_BUFF] bonding: Set skb-nh.raw relative to skb-mac.raw

Signed-off-by: Arnaldo Carvalho de Melo [EMAIL PROTECTED]
---
 drivers/net/bonding/bond_3ad.c |4 ++--
 drivers/net/bonding/bond_alb.c |2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/bonding/bond_3ad.c b/drivers/net/bonding/bond_3ad.c
index e3c9e2e..05c870d 100644
--- a/drivers/net/bonding/bond_3ad.c
+++ b/drivers/net/bonding/bond_3ad.c
@@ -885,7 +885,7 @@ static int ad_lacpdu_send(struct port *port)
 
 	skb-dev = slave-dev;
 	skb_reset_mac_header(skb);
-	skb-nh.raw = skb-data + ETH_HLEN;
+	skb-nh.raw = skb-mac.raw + ETH_HLEN;
 	skb-protocol = PKT_TYPE_LACPDU;
 	skb-priority = TC_PRIO_CONTROL;
 
@@ -929,7 +929,7 @@ static int ad_marker_send(struct port *port, struct marker *marker)
 
 	skb-dev = slave-dev;
 	skb_reset_mac_header(skb);
-	skb-nh.raw = skb-data + ETH_HLEN;
+	skb-nh.raw = skb-mac.raw + ETH_HLEN;
 	skb-protocol = PKT_TYPE_LACPDU;
 
 	marker_header = (struct marker_header *)skb_put(skb, length);
diff --git a/drivers/net/bonding/bond_alb.c b/drivers/net/bonding/bond_alb.c
index 36b8e86..5c2a12c 100644
--- a/drivers/net/bonding/bond_alb.c
+++ b/drivers/net/bonding/bond_alb.c
@@ -896,7 +896,7 @@ static void alb_send_learning_packets(struct slave *slave, u8 mac_addr[])
 		memcpy(data, pkt, size);
 
 		skb_reset_mac_header(skb);
-		skb-nh.raw = data + ETH_HLEN;
+		skb-nh.raw = skb-mac.raw + ETH_HLEN;
 		skb-protocol = pkt.type;
 		skb-priority = TC_PRIO_CONTROL;
 		skb-dev = slave-dev;
-- 
1.5.0.2



[PATCH 15/18][SK_BUFF]: Introduce skb_network_offset()

2007-03-11 Thread Arnaldo Carvalho de Melo

For the quite common 'skb-nh.raw - skb-data' sequence.

Signed-off-by: Arnaldo Carvalho de Melo [EMAIL PROTECTED]
From 578a14f390cd7731eefaa81905ed8383a7c567f6 Mon Sep 17 00:00:00 2001
From: Arnaldo Carvalho de Melo [EMAIL PROTECTED]
Date: Sat, 10 Mar 2007 22:16:10 -0300
Subject: [PATCH 15/18] [SK_BUFF]: Introduce skb_network_offset()

For the quite common 'skb-nh.raw - skb-data' sequence.

Signed-off-by: Arnaldo Carvalho de Melo [EMAIL PROTECTED]
---
 drivers/isdn/i4l/isdn_net.c|2 +-
 drivers/net/atl1/atl1_main.c   |2 +-
 drivers/net/chelsio/sge.c  |2 +-
 drivers/net/cxgb3/sge.c|2 +-
 drivers/net/e1000/e1000_main.c |2 +-
 drivers/net/gianfar.c  |2 +-
 drivers/net/ixgb/ixgb_main.c   |2 +-
 drivers/net/netxen/netxen_nic_hw.c |2 +-
 include/linux/skbuff.h |5 +
 net/ax25/ax25_out.c|4 ++--
 net/core/neighbour.c   |6 +++---
 net/ipv4/ip_output.c   |4 ++--
 net/ipv6/icmp.c|4 ++--
 net/ipv6/ip6_output.c  |4 ++--
 net/netfilter/nf_conntrack_core.c  |4 ++--
 net/packet/af_packet.c |8 
 net/sched/sch_teql.c   |2 +-
 security/selinux/hooks.c   |4 ++--
 18 files changed, 33 insertions(+), 28 deletions(-)

diff --git a/drivers/isdn/i4l/isdn_net.c b/drivers/isdn/i4l/isdn_net.c
index fadb929..0c2b375 100644
--- a/drivers/isdn/i4l/isdn_net.c
+++ b/drivers/isdn/i4l/isdn_net.c
@@ -1121,7 +1121,7 @@ isdn_net_adjust_hdr(struct sk_buff *skb, struct net_device *dev)
 	if (!skb)
 		return;
 	if (lp-p_encap == ISDN_NET_ENCAP_ETHER) {
-		int pullsize = (ulong)skb-nh.raw - (ulong)skb-data - ETH_HLEN;
+		const int pullsize = skb_network_offset(skb) - ETH_HLEN;
 		if (pullsize  0) {
 			printk(KERN_DEBUG isdn_net: Pull junk %d\n, pullsize);
 			skb_pull(skb, pullsize);
diff --git a/drivers/net/atl1/atl1_main.c b/drivers/net/atl1/atl1_main.c
index 45cdcc3..636c382 100644
--- a/drivers/net/atl1/atl1_main.c
+++ b/drivers/net/atl1/atl1_main.c
@@ -1300,7 +1300,7 @@ static int atl1_tso(struct atl1_adapter *adapter, struct sk_buff *skb,
 			~csum_tcpudp_magic(skb-nh.iph-saddr,
 	   skb-nh.iph-daddr, 0,
 	   IPPROTO_TCP, 0);
-			ipofst = skb-nh.raw - skb-data;
+			ipofst = skb_network_offset(skb);
 			if (ipofst != ENET_HEADER_SIZE) /* 802.3 frame */
 tso-tsopl |= 1  TSO_PARAM_ETHTYPE_SHIFT;
 
diff --git a/drivers/net/chelsio/sge.c b/drivers/net/chelsio/sge.c
index 47fa8dc..8cdee67 100644
--- a/drivers/net/chelsio/sge.c
+++ b/drivers/net/chelsio/sge.c
@@ -1865,7 +1865,7 @@ int t1_start_xmit(struct sk_buff *skb, struct net_device *dev)
 
 		++st-tx_tso;
 
-		eth_type = skb-nh.raw - skb-data == ETH_HLEN ?
+		eth_type = skb_network_offset(skb) == ETH_HLEN ?
 			CPL_ETH_II : CPL_ETH_II_VLAN;
 
 		hdr = (struct cpl_tx_pkt_lso *)skb_push(skb, sizeof(*hdr));
diff --git a/drivers/net/cxgb3/sge.c b/drivers/net/cxgb3/sge.c
index c342b10..6a2a365 100644
--- a/drivers/net/cxgb3/sge.c
+++ b/drivers/net/cxgb3/sge.c
@@ -897,7 +897,7 @@ static void write_tx_pkt_wr(struct adapter *adap, struct sk_buff *skb,
 		d-flit[2] = 0;
 		cntrl |= V_TXPKT_OPCODE(CPL_TX_PKT_LSO);
 		hdr-cntrl = htonl(cntrl);
-		eth_type = skb-nh.raw - skb-data == ETH_HLEN ?
+		eth_type = skb_network_offset(skb) == ETH_HLEN ?
 		CPL_ETH_II : CPL_ETH_II_VLAN;
 		tso_info |= V_LSO_ETH_TYPE(eth_type) |
 		V_LSO_IPHDR_WORDS(skb-nh.iph-ihl) |
diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c
index 1d08e93..130bc0b 100644
--- a/drivers/net/e1000/e1000_main.c
+++ b/drivers/net/e1000/e1000_main.c
@@ -2910,7 +2910,7 @@ e1000_tso(struct e1000_adapter *adapter, struct e1000_tx_ring *tx_ring,
 		 0);
 			ipcse = 0;
 		}
-		ipcss = skb-nh.raw - skb-data;
+		ipcss = skb_network_offset(skb);
 		ipcso = (void *)(skb-nh.iph-check) - (void *)skb-data;
 		tucss = skb-h.raw - skb-data;
 		tucso = (void *)(skb-h.th-check) - (void *)skb-data;
diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c
index 1d01919..c7a7093 100644
--- a/drivers/net/gianfar.c
+++ b/drivers/net/gianfar.c
@@ -952,7 +952,7 @@ static inline void gfar_tx_checksum(struct sk_buff *skb, struct txfcb *fcb)
 	 * frame (skb-data) and the start of the IP hdr.
 	 * l4os is the distance between the start of the
 	 * l3 hdr and the l4 hdr */
-	fcb-l3os = (u16)(skb-nh.raw - skb-data - GMAC_FCB_LEN);
+	fcb-l3os = (u16)(skb_network_offset(skb) - GMAC_FCB_LEN);
 	fcb-l4os = (u16)(skb-h.raw - skb-nh.raw);
 
 	fcb-flags = flags;
diff --git a/drivers/net/ixgb/ixgb_main.c b/drivers/net/ixgb/ixgb_main.c
index afc2ec7..cfb791b 100644
--- a/drivers/net/ixgb/ixgb_main.c
+++ b/drivers/net/ixgb/ixgb_main.c
@@ -1195,7 +1195,7 @@ ixgb_tso(struct ixgb_adapter *adapter, struct sk_buff *skb)
 		skb-h.th-check = ~csum_tcpudp_magic(skb-nh.iph-saddr,
 		  skb-nh.iph-daddr,
 		  0, IPPROTO_TCP, 0);
-		ipcss = skb-nh.raw - skb-data;
+		

[PATCH 17/18][SK_BUFF] ipmr: Another skb_push related conversion to skb_reset_network_header

2007-03-11 Thread Arnaldo Carvalho de Melo

Signed-off-by: Arnaldo Carvalho de Melo [EMAIL PROTECTED]
---
net/ipv4/ipmr.c |6 --
1 files changed, 4 insertions(+), 2 deletions(-)
From 98ed69cabc5d06b65d34d8fa779aacec791d4ef3 Mon Sep 17 00:00:00 2001
From: Arnaldo Carvalho de Melo [EMAIL PROTECTED]
Date: Sun, 11 Mar 2007 22:38:29 -0300
Subject: [PATCH 17/18] [SK_BUFF] ipmr: Another skb_push related conversion to skb_reset_network_header

Signed-off-by: Arnaldo Carvalho de Melo [EMAIL PROTECTED]
---
 net/ipv4/ipmr.c |6 --
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c
index 4a8d99b..465459d 100644
--- a/net/ipv4/ipmr.c
+++ b/net/ipv4/ipmr.c
@@ -561,8 +561,10 @@ static int ipmr_cache_report(struct sk_buff *pkt, vifi_t vifi, int assert)
 		   And all this only to mangle msg-im_msgtype and
 		   to set msg-im_mbz to mbz :-)
 		 */
-		msg = (struct igmpmsg*)skb_push(skb, sizeof(struct iphdr));
-		skb-nh.raw = skb-h.raw = (u8*)msg;
+		skb_push(skb, sizeof(struct iphdr));
+		skb_reset_network_header(skb);
+		skb-h.raw = skb-data;
+		msg = (struct igmpmsg *)skb-nh.raw;
 		memcpy(msg, skb_network_header(pkt), sizeof(struct iphdr));
 		msg-im_msgtype = IGMPMSG_WHOLEPKT;
 		msg-im_mbz = 0;
-- 
1.5.0.2



[PATCH 18/18][SK_BUFF]: Introduce skb_set_network_header

2007-03-11 Thread Arnaldo Carvalho de Melo

For the cases where the network header is being set to a offset from skb-data.

Signed-off-by: Arnaldo Carvalho de Melo [EMAIL PROTECTED]
From 03b510407695a4ad4edb3cb54dd489ca486e0165 Mon Sep 17 00:00:00 2001
From: Arnaldo Carvalho de Melo [EMAIL PROTECTED]
Date: Sun, 11 Mar 2007 22:39:41 -0300
Subject: [PATCH 18/18] [SK_BUFF]: Introduce skb_set_network_header

For the cases where the network header is being set to a offset from skb-data.

Signed-off-by: Arnaldo Carvalho de Melo [EMAIL PROTECTED]
---
 include/linux/skbuff.h |5 +
 net/ax25/ax25_out.c|6 --
 net/ipv4/ip_output.c   |4 ++--
 net/ipv4/tcp_input.c   |3 ++-
 net/ipv6/ip6_output.c  |4 ++--
 5 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 52e8307..2fb9dc3 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -968,6 +968,11 @@ static inline void skb_reset_network_header(struct sk_buff *skb)
 	skb-nh.raw = skb-data;
 }
 
+static inline void skb_set_network_header(struct sk_buff *skb, const int offset)
+{
+	skb-nh.raw = skb-data + offset;
+}
+
 static inline int skb_network_offset(const struct sk_buff *skb)
 {
 	return skb-nh.raw - skb-data;
diff --git a/net/ax25/ax25_out.c b/net/ax25/ax25_out.c
index 02dea85..e66953c 100644
--- a/net/ax25/ax25_out.c
+++ b/net/ax25/ax25_out.c
@@ -148,7 +148,8 @@ void ax25_output(ax25_cb *ax25, int paclen, struct sk_buff *skb)
 
 			if (ka9qfrag == 1) {
 skb_reserve(skbn, frontlen + 2);
-skbn-nh.raw = skbn-data + skb_network_offset(skb);
+skb_set_network_header(skbn,
+		  skb_network_offset(skb));
 memcpy(skb_put(skbn, len), skb-data, len);
 p = skb_push(skbn, 2);
 
@@ -161,7 +162,8 @@ void ax25_output(ax25_cb *ax25, int paclen, struct sk_buff *skb)
 }
 			} else {
 skb_reserve(skbn, frontlen + 1);
-skbn-nh.raw = skbn-data + skb_network_offset(skb);
+skb_set_network_header(skbn,
+		  skb_network_offset(skb));
 memcpy(skb_put(skbn, len), skb-data, len);
 p = skb_push(skbn, 1);
 *p = AX25_P_TEXT;
diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
index eae2284..15de9d4 100644
--- a/net/ipv4/ip_output.c
+++ b/net/ipv4/ip_output.c
@@ -928,9 +928,9 @@ alloc_new_skb:
 			 *	Find where to start putting bytes.
 			 */
 			data = skb_put(skb, fraglen);
-			skb-nh.raw = data + exthdrlen;
+			skb_set_network_header(skb, exthdrlen);
+			skb-h.raw = skb-nh.raw + fragheaderlen;
 			data += fragheaderlen;
-			skb-h.raw = data + exthdrlen;
 
 			if (fraggap) {
 skb-csum = skb_copy_and_csum_bits(
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index 0019083..5da823a 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -3634,7 +3634,8 @@ tcp_collapse(struct sock *sk, struct sk_buff_head *list,
 			return;
 
 		skb_set_mac_header(nskb, skb_mac_header(skb) - skb-head);
-		nskb-nh.raw = nskb-data + (skb_network_header(skb) - skb-head);
+		skb_set_network_header(nskb,
+   skb_network_header(skb) - skb-head);
 		nskb-h.raw = nskb-data + (skb-h.raw - skb-head);
 
 		skb_reserve(nskb, header);
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index f1dfcc3..bd25825 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -1206,9 +1206,9 @@ alloc_new_skb:
 			 *	Find where to start putting bytes
 			 */
 			data = skb_put(skb, fraglen);
-			skb-nh.raw = data + exthdrlen;
+			skb_set_network_header(skb, exthdrlen);
 			data += fragheaderlen;
-			skb-h.raw = data + exthdrlen;
+			skb-h.raw = skb-nh.raw + fragheaderlen;
 
 			if (fraggap) {
 skb-csum = skb_copy_and_csum_bits(
-- 
1.5.0.2



Re: [PATCH 0/5] NetXen: Driver bug fixes

2007-03-11 Thread Amit Kale
On Saturday 10 March 2007 16:52, Jeff Garzik wrote:
 Amit Kale wrote:
  On Friday 09 March 2007 22:26, Jeff Garzik wrote:
  Linsys Contractor Mithlesh Thukral wrote:
  Hi All,
 
  I will be sending updates to NetXen: 1G/10G Ethernet driver in
  subsequent mails. The patches will be with respect to netdev#upstream.
 
  Are you sure you don't want some of these in #upstream-fixes, queued for
  2.6.21-rc?
 
  We really want them in both places. If we send them to #upstream-fixes,
  they'll break #upstream. Should we send them against both of these
  branches?

 Well, I can drop NetXen patches in #upstream, apply these to
 #upstream-fixes, and wait for a resend?

Could you do that, please? (drop NetXen patches in #upstream)

We'll resend them against #upstream-fixes.
Thanks.
-Amit
-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: 2.6.21-rc2-mm2: drivers/net/wireless/libertas/debugfs.c addr bogosity

2007-03-11 Thread Tony Breeds
On Fri, Mar 09, 2007 at 09:14:29AM -0800, Randy Dunlap wrote:
 
 Good to use FIELD_SIZEOF(),

Thanks.

 but in general, we prefer to use it
 directly, not in yet another wrapper.

I left the item_{size,addr} in place as it seemed to make the item[]
more compact.

I'm not certain using the FIELD_SIZEOF() macro directly is a win.

From: Tony Breeds [EMAIL PROTECTED]

Cleanup drivers/net/wireless/libertas/debugfs.c to use standard kernel macros 
and functions.

Signed-off-by: Tony Breeds [EMAIL PROTECTED]

---
only compile tested on x86

 drivers/net/wireless/libertas/debugfs.c |   56 +++
 1 files changed, 12 insertions(+), 44 deletions(-)

diff --git a/drivers/net/wireless/libertas/debugfs.c 
b/drivers/net/wireless/libertas/debugfs.c
index 3ad1e03..8b0e3ec 100644
--- a/drivers/net/wireless/libertas/debugfs.c
+++ b/drivers/net/wireless/libertas/debugfs.c
@@ -1771,58 +1771,26 @@ void libertas_debugfs_remove_one(wlan_private *priv)
 }
 
 /* debug entry */
-
-#define item_size(n) (sizeof ((wlan_adapter *)0)-n)
-#define item_addr(n) ((u32) ((wlan_adapter *)0)-n)
-
 struct debug_data {
char name[32];
u32 size;
u32 addr;
 };
 
-/* To debug any member of wlan_adapter, simply add one line here.
- */
+/* To debug any member of wlan_adapter, simply add a record here. */
 static struct debug_data items[] = {
-   {intcounter, item_size(intcounter), item_addr(intcounter)},
-   {psmode, item_size(psmode), item_addr(psmode)},
-   {psstate, item_size(psstate), item_addr(psstate)},
+   { .name = intcounter,
+ .size = FIELD_SIZEOF(wlan_adapter, intcounter),
+ .addr = offsetof(wlan_adapter, intcounter) },
+   { .name = psmode,
+ .size = FIELD_SIZEOF(wlan_adapter, psmode),
+ .addr = offsetof(wlan_adapter, psmode) },
+   { .name = psstate,
+ .size = FIELD_SIZEOF(wlan_adapter, psstate),
+ .addr = offsetof(wlan_adapter, psstate) },
 };
 
-static int num_of_items = sizeof(items) / sizeof(items[0]);
-
-/**
- *  @brief convert string to number
- *
- *  @param s  pointer to numbered string
- *  @return   converted number from string s
- */
-static int string_to_number(char *s)
-{
-   int r = 0;
-   int base = 0;
-
-   if ((strncmp(s, 0x, 2) == 0) || (strncmp(s, 0X, 2) == 0))
-   base = 16;
-   else
-   base = 10;
-
-   if (base == 16)
-   s += 2;
-
-   for (s = s; *s != 0; s++) {
-   if ((*s = 48)  (*s = 57))
-   r = (r * base) + (*s - 48);
-   else if ((*s = 65)  (*s = 70))
-   r = (r * base) + (*s - 55);
-   else if ((*s = 97)  (*s = 102))
-   r = (r * base) + (*s - 87);
-   else
-   break;
-   }
-
-   return r;
-}
+static int num_of_items = ARRAY_SIZE(items);
 
 /**
  *  @brief proc read function
@@ -1912,7 +1880,7 @@ static int wlan_debugfs_write(struct file *f, const char 
__user *buf,
if (!p2)
break;
p2++;
-   r = string_to_number(p2);
+   r = simple_strtoul(p2, NULL, 0);
if (d[i].size == 1)
*((u8 *) d[i].addr) = (u8) r;
else if (d[i].size == 2)


Yours Tony

  linux.conf.auhttp://linux.conf.au/ || http://lca2008.linux.org.au/
  Jan 28 - Feb 02 2008 The Australian Linux Technical Conference!

-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html