[PATCH] Allow kfree_skb to be called with a NULL argument

2006-02-22 Thread Jörn Engel
Fairly trivial.  The extra conditional should get optimized away with
current code.  But it also allows to walk through network drivers and
get rid of the permanent
if (skb)
kfree(skb);
conditionals.

Jörn

-- 
Unless something dramatically changes, by 2015 we'll be largely
wondering what all the fuss surrounding Linux was really about.
-- Rob Enderle

Allow kfree_skb to be called with a NULL argument.
This allows slight simplification of many drivers.

Signed-off-by: Jörn Engel [EMAIL PROTECTED]
---

 include/linux/skbuff.h |2 ++
 1 file changed, 2 insertions(+)

--- kfree_skb/include/linux/skbuff.h~kfree_skb_null 2006-02-22 
08:42:22.0 +0100
+++ kfree_skb/include/linux/skbuff.h2006-02-22 08:36:29.0 +0100
@@ -414,6 +414,8 @@ static inline struct sk_buff *skb_get(st
  */
 static inline void kfree_skb(struct sk_buff *skb)
 {
+   if (unlikely(!skb))
+   return;
if (likely(atomic_read(skb-users) == 1))
smp_rmb();
else if (likely(!atomic_dec_and_test(skb-users)))
-
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


Buglet in iproute2?

2006-02-22 Thread jpo234

Hello all,
reading the sources of iproute2-2.6.15-060110 I found something that 
actually might be a buglet. In libnetlink.c, function rtnl_talk is the 
following piece of code:


303:if (nladdr.nl_pid != peer ||
304:h-nlmsg_pid != rtnl-local.nl_pid ||
305:h-nlmsg_seq != seq) {
306:if (junk) {
307:err = junk(nladdr, h, jarg);
308:if (err  0)
309:return err;
310:}
311:continue;
312:}

The problem might be the continue statement in line 311. My 
understanding is, that this is meant to continue the big while-loop 
starting in line 271. It will actually continue the for-loop starting 
in line 289 without changing the termination condition and those 
creating an endless loop.


Regards
 Joerg
___
Try the New Netscape Mail Today!
Virtually Spam-Free | More Storage | Import Your Contact List
http://mail.netscape.com

-
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: XFRM_STATE_NOPMTUDISC, was : MTU/DF problem with 2.6

2006-02-22 Thread Herbert Xu
On Wed, Feb 22, 2006 at 10:39:03AM +0200, Ilia Sotnikov wrote:
 On 2/21/06, Herbert Xu [EMAIL PROTECTED] wrote:
  Actually, here is a better patch for your problem.  We should really
  be using the TOS when doing IPsec lookups:
 
  [IPSEC] Use TOS when doing tunnel lookups
 
  We should use the TOS because it's one of the routing keys.  It also
  means that we update the correct routing cache entry when PMTU occurs.
 
  Signed-off-by: Herbert Xu [EMAIL PROTECTED]
 
 Not using TOS for hash calculation in the routing cache doesn't  mean
 that we will find incorrent routing cache entry - we could find such a
 cached entry not using TOS, but when we compare its fields including
 TOS with a packet's fields ip_route_input_slow() will do fib_lookup()
 in case of false comparision result. As I wrote before, the patch
 could only reduce number of routing cache hits. Am I wrong somewhere?

No you're quite right.  However, this is not related to my patch which
fixes a real bug in the IPsec code.

The problem you raised is real and will be solved.

Thanks,
-- 
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmVHI~} [EMAIL PROTECTED]
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
-
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: no carrier detection after resume from swsusp (8139too)

2006-02-22 Thread Nikolaus Filus
Cc: networkamanger-list, as it seems now to be related to nm

On Wednesday 22 February 2006 00:49, Francois Romieu wrote:
 (owner of http://bugzilla.kernel.org/show_bug.cgi?id=5681 Cc:ed)

 Nikolaus Filus [EMAIL PROTECTED] :
 [...]

  I'm using linux 2.6.14.3 with swsusp2 2.2rc14 (not the most new
  ones). Since I'm using NetworkManager, which switches and manages my
  wired and wireless devices, I have to reload 8139too after resume,
  before plugin events of wired network are recognized. Some other
  users of NM are reporting similar problems.

 May I assume that your 8139too device does not need to be reloaded when
 you suspend/resume and NM is not used ?

I didn't look enough on this issue before.

After resume, I get invalid argument from
/sys/class/net/eth1/carrier. Reloading the driver *OR* restarting
networkmanager solves the problem! Is it possible a process like nm blocks 
some ressources, which are re-initialised by reloading the driver or 
restarting nm? Notice, that just stopping nm is not enough.

Thanks in advance,

Nikolaus
-
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] pktgen: fix races between control/worker threads

2006-02-22 Thread Robert Olsson

Jesse Brandeburg writes:
  
  I looked quickly at this on a couple different machines and wasn't
  able to reproduce, so don't let me block the patch.  I think its a
  good patch FWIW

 OK! 
 We ask Deve to apply it.

 Cheers.
--ro
-
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: pktgen + napi == kaboom

2006-02-22 Thread Ben Greear

Simon Kirby wrote:

2.6.15.4:

Just tried to do some benchmarks for outgoing packet rates with the
e1000 and tg3.  When I tried some vlan tagging with pktgen, it blew
up immediately:


For VLANs, make sure that the 'multi-skb' is always zero.  This is because
the VLAN code modifies the skb by re-assigning the skb-dev to the underlying
device.

I'm not sure if this is the problem you hit, but it could be...

Ben

--
Ben Greear [EMAIL PROTECTED]
Candela Technologies Inc  http://www.candelatech.com

-
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: pktgen + napi == kaboom

2006-02-22 Thread Ben Greear

Robert Olsson wrote:

Simon Kirby writes:

  Just tried to do some benchmarks for outgoing packet rates with the
  e1000 and tg3.  When I tried some vlan tagging with pktgen, it blew
  up immediately:
 
 Hello!


 No pktgen has no support vlan as-is .Guess there should be some config
 option to select vlan and enable it and fill vlan header in the packet. 
 If you're motivated give it a try.


VLAN devices will add the header for you...pktgen should work with
no modification.

It will work *best* if you use my patch to give stack feedback so
that pktgen + vlan doesn't drop so many pkts on transmit.

diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
--- a/net/8021q/vlan.c
+++ b/net/8021q/vlan.c
@@ -1,4 +1,4 @@
-/*
+/* -*- linux-c -*-
  * INET802.1Q VLAN
  * Ethernet-type device handling.
  *
diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c
--- a/net/8021q/vlan_dev.c
+++ b/net/8021q/vlan_dev.c
@@ -438,6 +438,11 @@ int vlan_dev_hard_start_xmit(struct sk_b
struct net_device_stats *stats = vlan_dev_get_stats(dev);
struct vlan_ethhdr *veth = (struct vlan_ethhdr *)(skb-data);

+   /* Please note, dev_queue_xmit consumes the pkt regardless of the
+* return value.  So, will copy the skb first and free if successful.
+*/
+   struct sk_buff* skb2 = skb_get(skb);
+
/* Handle non-VLAN frames if they are sent to us, for example by DHCP.
 *
 * NOTE: THIS ASSUMES DIX ETHERNET, SPECIFICALLY NOT SUPPORTING
@@ -467,6 +472,10 @@ int vlan_dev_hard_start_xmit(struct sk_b
skb = __vlan_put_tag(skb, veth_TCI);
if (!skb) {
stats-tx_dropped++;
+   /* Free the extra copy, assuming this is a 
non-recoverable
+* issue and we don't want calling code to retry.
+*/
+   kfree_skb(skb2);
return 0;
}

@@ -484,13 +493,24 @@ int vlan_dev_hard_start_xmit(struct sk_b
   veth-h_vlan_proto, veth-h_vlan_TCI, 
veth-h_vlan_encapsulated_proto);
 #endif

-   stats-tx_packets++; /* for statics only */
-   stats-tx_bytes += skb-len;
-
skb-dev = VLAN_DEV_INFO(dev)-real_dev;
-   dev_queue_xmit(skb);

-   return 0;
+   {
+   int rv = dev_queue_xmit(skb);
+   if (rv == 0) {
+   /* Was success, need to free the skb reference since
+* we bumped up the user count above.  If there was an
+* error instead, then the skb2 will not be freed, and 
so
+* the calling code will be able to re-send it.
+*/
+
+   stats-tx_packets++; /* for statics only */
+   stats-tx_bytes += skb2-len;
+
+   kfree_skb(skb2);
+   }
+   return rv;
+   }
 }

 int vlan_dev_hwaccel_hard_start_xmit(struct sk_buff *skb, struct net_device 
*dev)


Thanks,
Ben

--
Ben Greear [EMAIL PROTECTED]
Candela Technologies Inc  http://www.candelatech.com

-
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 0/3] skge: patches for 2.6.16

2006-02-22 Thread Stephen Hemminger
Bug fix patches to skge driver that need to go in 2.6.16.
Some of them are in -mm and some have already been sent (and ignored).


-
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] skge: protect interrupt mask

2006-02-22 Thread Stephen Hemminger

There is a race between updating the irq mask and setting it
which can be triggered on SMP with a bad cable.
Similar patch from Ingo Molnar and Thomas Gleixner


Signed-off-by: Stephen Hemminger [EMAIL PROTECTED]


--- netdev-2.6.orig/drivers/net/skge.c  2006-02-22 09:50:37.0 -0800
+++ netdev-2.6/drivers/net/skge.c   2006-02-22 09:51:33.0 -0800
@@ -2185,8 +2185,10 @@
skge-tx_avail = skge-tx_ring.count - 1;
 
/* Enable IRQ from port */
+   spin_lock_irq(hw-hw_lock);
hw-intr_mask |= portirqmask[port];
skge_write32(hw, B0_IMSK, hw-intr_mask);
+   spin_unlock_irq(hw-hw_lock);
 
/* Initialize MAC */
spin_lock_bh(hw-phy_lock);
@@ -2244,8 +2246,10 @@
else
yukon_stop(skge);
 
+   spin_lock_irq(hw-hw_lock);
hw-intr_mask = ~portirqmask[skge-port];
skge_write32(hw, B0_IMSK, hw-intr_mask);
+   spin_unlock_irq(hw-hw_lock);
 
/* Stop transmitter */
skge_write8(hw, Q_ADDR(txqaddr[port], Q_CSR), CSR_STOP);
@@ -2701,10 +2705,11 @@
if (work_done =  to_do)
return 1; /* not done */
 
-   netif_rx_complete(dev);
-   hw-intr_mask |= portirqmask[skge-port];
-   skge_write32(hw, B0_IMSK, hw-intr_mask);
-   skge_read32(hw, B0_IMSK);
+   spin_lock_irq(hw-hw_lock);
+   __netif_rx_complete(dev);
+   hw-intr_mask |= portirqmask[skge-port];
+   skge_write32(hw, B0_IMSK, hw-intr_mask);
+   spin_unlock_irq(hw-hw_lock);
 
return 0;
 }
@@ -2864,10 +2869,10 @@
}
spin_unlock(hw-phy_lock);
 
-   local_irq_disable();
+   spin_lock_irq(hw-hw_lock);
hw-intr_mask |= IS_EXT_REG;
skge_write32(hw, B0_IMSK, hw-intr_mask);
-   local_irq_enable();
+   spin_unlock_irq(hw-hw_lock);
 }
 
 static irqreturn_t skge_intr(int irq, void *dev_id, struct pt_regs *regs)
@@ -2878,7 +2883,7 @@
if (status == 0 || status == ~0) /* hotplug or shared irq */
return IRQ_NONE;
 
-   status = hw-intr_mask;
+   spin_lock(hw-hw_lock);
if (status  IS_R1_F) {
skge_write8(hw, Q_ADDR(Q_R1, Q_CSR), CSR_IRQ_CL_F);
hw-intr_mask = ~IS_R1_F;
@@ -2930,6 +2935,7 @@
}
 
skge_write32(hw, B0_IMSK, hw-intr_mask);
+   spin_unlock(hw-hw_lock);
 
return IRQ_HANDLED;
 }
@@ -3298,6 +3304,7 @@
 
hw-pdev = pdev;
spin_lock_init(hw-phy_lock);
+   spin_lock_init(hw-hw_lock);
tasklet_init(hw-ext_tasklet, skge_extirq, (unsigned long) hw);
 
hw-regs = ioremap_nocache(pci_resource_start(pdev, 0), 0x4000);
--- netdev-2.6.orig/drivers/net/skge.h  2006-02-21 09:20:10.0 -0800
+++ netdev-2.6/drivers/net/skge.h   2006-02-22 09:50:57.0 -0800
@@ -2402,6 +2402,7 @@
 
struct tasklet_struct ext_tasklet;
spinlock_t   phy_lock;
+   spinlock_t   hw_lock;
 };
 
 enum {

--

-
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 1/3] skge: NAPI/irq race fix

2006-02-22 Thread Stephen Hemminger
Fix a race in the receive NAPI, irq handling. The interrupt clear and the
start need to be separated.  Otherwise there is a window between the last
frame received and the NAPI done level handling.

Signed-off-by: Stephen Hemminger [EMAIL PROTECTED]


--- netdev-2.6.orig/drivers/net/skge.c  2006-02-21 09:20:10.0 -0800
+++ netdev-2.6/drivers/net/skge.c   2006-02-22 09:50:03.0 -0800
@@ -2678,8 +2678,7 @@
 
/* restart receiver */
wmb();
-   skge_write8(hw, Q_ADDR(rxqaddr[skge-port], Q_CSR),
-   CSR_START | CSR_IRQ_CL_F);
+   skge_write8(hw, Q_ADDR(rxqaddr[skge-port], Q_CSR), CSR_START);
 
*budget -= work_done;
dev-quota -= work_done;
@@ -2856,14 +2855,6 @@
local_irq_enable();
 }
 
-static inline void skge_wakeup(struct net_device *dev)
-{
-   struct skge_port *skge = netdev_priv(dev);
-
-   prefetch(skge-rx_ring.to_clean);
-   netif_rx_schedule(dev);
-}
-
 static irqreturn_t skge_intr(int irq, void *dev_id, struct pt_regs *regs)
 {
struct skge_hw *hw = dev_id;
@@ -2874,13 +2865,15 @@
 
status = hw-intr_mask;
if (status  IS_R1_F) {
+   skge_write8(hw, Q_ADDR(Q_R1, Q_CSR), CSR_IRQ_CL_F);
hw-intr_mask = ~IS_R1_F;
-   skge_wakeup(hw-dev[0]);
+   netif_rx_schedule(hw-dev[0]);
}
 
if (status  IS_R2_F) {
+   skge_write8(hw, Q_ADDR(Q_R2, Q_CSR), CSR_IRQ_CL_F);
hw-intr_mask = ~IS_R2_F;
-   skge_wakeup(hw-dev[1]);
+   netif_rx_schedule(hw-dev[1]);
}
 
if (status  IS_XA1_F)

--

-
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 6/6] sky2: close race on IRQ mask update.

2006-02-22 Thread Stephen Hemminger
Need to avoid race in updating IRQ mask.  This can probably be replaced
smarter use of the interrupt control registers (if/when chipset
docs are available).

Signed-off-by: Stephen Hemminger [EMAIL PROTECTED]


--- sky2.orig/drivers/net/sky2.c2006-02-22 11:33:41.0 -0800
+++ sky2/drivers/net/sky2.c 2006-02-22 11:33:45.0 -0800
@@ -1079,8 +1079,10 @@
goto err_out;
 
/* Enable interrupts from phy/mac for port */
+   spin_lock_irq(hw-hw_lock);
hw-intr_mask |= (port == 0) ? Y2_IS_PORT_1 : Y2_IS_PORT_2;
sky2_write32(hw, B0_IMSK, hw-intr_mask);
+   spin_unlock_irq(hw-hw_lock);
return 0;
 
 err_out:
@@ -1380,10 +1382,10 @@
netif_stop_queue(dev);
 
/* Disable port IRQ */
-   local_irq_disable();
+   spin_lock_irq(hw-hw_lock);
hw-intr_mask = ~((sky2-port == 0) ? Y2_IS_IRQ_PHY1 : Y2_IS_IRQ_PHY2);
sky2_write32(hw, B0_IMSK, hw-intr_mask);
-   local_irq_enable();
+   spin_unlock_irq(hw-hw_lock);
 
flush_scheduled_work();
 
@@ -1665,10 +1667,10 @@
 out:
up(sky2-phy_sema);
 
-   local_irq_disable();
+   spin_lock_irq(hw-hw_lock);
hw-intr_mask |= (sky2-port == 0) ? Y2_IS_IRQ_PHY1 : Y2_IS_IRQ_PHY2;
sky2_write32(hw, B0_IMSK, hw-intr_mask);
-   local_irq_enable();
+   spin_unlock_irq(hw-hw_lock);
 }
 
 
@@ -1994,9 +1996,13 @@
}
 
if (likely(work_done  to_do)) {
-   netif_rx_complete(dev0);
+   spin_lock_irq(hw-hw_lock);
+   __netif_rx_complete(dev0);
+
hw-intr_mask |= Y2_IS_STAT_BMU;
sky2_write32(hw, B0_IMSK, hw-intr_mask);
+   spin_unlock_irq(hw-hw_lock);
+
return 0;
} else {
*budget -= work_done;
@@ -2128,6 +2134,7 @@
 
hw-intr_mask = ~(port == 0 ? Y2_IS_IRQ_PHY1 : Y2_IS_IRQ_PHY2);
sky2_write32(hw, B0_IMSK, hw-intr_mask);
+
schedule_work(sky2-phy_task);
 }
 
@@ -2141,6 +2148,7 @@
if (status == 0 || status == ~0)
return IRQ_NONE;
 
+   spin_lock(hw-hw_lock);
if (status  Y2_IS_HW_ERR)
sky2_hw_intr(hw);
 
@@ -2169,7 +2177,7 @@
 
sky2_write32(hw, B0_Y2_SP_ICR, 2);
 
-   sky2_read32(hw, B0_IMSK);
+   spin_unlock(hw-hw_lock);
 
return IRQ_HANDLED;
 }
@@ -3241,6 +3249,7 @@
goto err_out_free_hw;
}
hw-pm_cap = pm_cap;
+   spin_lock_init(hw-hw_lock);
 
 #ifdef __BIG_ENDIAN
/* byte swap descriptors in hardware */
--- sky2.orig/drivers/net/sky2.h2006-02-22 11:33:41.0 -0800
+++ sky2/drivers/net/sky2.h 2006-02-22 11:33:45.0 -0800
@@ -1876,8 +1876,9 @@
 struct sky2_hw {
void __iomem *regs;
struct pci_dev   *pdev;
-   u32  intr_mask;
struct net_device*dev[2];
+   spinlock_t   hw_lock;
+   u32  intr_mask;
 
int  pm_cap;
int  msi;

--

-
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/6] sky2: limit coalescing values to ring size

2006-02-22 Thread Stephen Hemminger
Don't allow coalescing values to be bigger than the transmit ring.
Since if you set them that big, the interrupt never happens and driver
livelocks.

Signed-off-by: Stephen Hemminger [EMAIL PROTECTED]


--- sky2-1.0.orig/drivers/net/sky2.c2006-02-20 09:48:32.0 -0800
+++ sky2-1.0/drivers/net/sky2.c 2006-02-20 12:12:04.0 -0800
@@ -2884,11 +2884,11 @@
(ecmd-rx_coalesce_usecs_irq  tmin || ecmd-rx_coalesce_usecs_irq 
 tmax))
return -EINVAL;
 
-   if (ecmd-tx_max_coalesced_frames  0x)
+   if (ecmd-tx_max_coalesced_frames = TX_RING_SIZE-1)
return -EINVAL;
-   if (ecmd-rx_max_coalesced_frames  0xff)
+   if (ecmd-rx_max_coalesced_frames  RX_MAX_PENDING)
return -EINVAL;
-   if (ecmd-rx_max_coalesced_frames_irq  0xff)
+   if (ecmd-rx_max_coalesced_frames_irq RX_MAX_PENDING)
return -EINVAL;
 
if (ecmd-tx_coalesce_usecs == 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 3/6] sky2: poke coalescing timer to fix hang

2006-02-22 Thread Stephen Hemminger
Need to restart the interrupt coalescing timer after clearing the interrupt,
to avoid races with interrupt timer and processing.

Patch from Carl-Daniel Halfinger

Signed-off-by: Stephen Hemminger [EMAIL PROTECTED]


--- sky2.orig/drivers/net/sky2.c2006-02-21 09:14:34.0 -0800
+++ sky2/drivers/net/sky2.c 2006-02-21 09:15:04.0 -0800
@@ -1895,6 +1895,17 @@
 
sky2_write32(hw, STAT_CTRL, SC_STAT_CLR_IRQ);
 
+   /*
+* Kick the STAT_LEV_TIMER_CTRL timer.
+* This fixes my hangs on Yukon-EC (0xb6) rev 1.
+* The if clause is there to start the timer only if it has been
+* configured correctly and not been disabled via ethtool.
+*/
+   if (sky2_read8(hw, STAT_LEV_TIMER_CTRL) == TIM_START) {
+   sky2_write8(hw, STAT_LEV_TIMER_CTRL, TIM_STOP);
+   sky2_write8(hw, STAT_LEV_TIMER_CTRL, TIM_START);
+   }
+
hwidx = sky2_read16(hw, STAT_PUT_IDX);
BUG_ON(hwidx = STATUS_RING_SIZE);
rmb();

--

-
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 5/6] sky2: use device iomem to access PCI config

2006-02-22 Thread Stephen Hemminger
To avoid problems with PCI config access without ACPI (or busted ACPI tables),
use the device's window into PCI config space.

I know this probably will upset the purists, but I would rather have users
than ACPI testers. It also generates less code.

Signed-off-by: Stephen Hemminger [EMAIL PROTECTED]


--- sky2.orig/drivers/net/sky2.c2006-02-22 11:33:33.0 -0800
+++ sky2/drivers/net/sky2.c 2006-02-22 11:33:41.0 -0800
@@ -195,11 +195,11 @@
pr_debug(sky2_set_power_state %d\n, state);
sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_ON);
 
-   pci_read_config_word(hw-pdev, hw-pm_cap + PCI_PM_PMC, power_control);
+   power_control = sky2_pci_read16(hw, hw-pm_cap + PCI_PM_PMC);
vaux = (sky2_read16(hw, B0_CTST)  Y2_VAUX_AVAIL) 
(power_control  PCI_PM_CAP_PME_D3cold);
 
-   pci_read_config_word(hw-pdev, hw-pm_cap + PCI_PM_CTRL, 
power_control);
+   power_control = sky2_pci_read16(hw, hw-pm_cap + PCI_PM_CTRL);
 
power_control |= PCI_PM_CTRL_PME_STATUS;
power_control = ~(PCI_PM_CTRL_STATE_MASK);
@@ -223,7 +223,7 @@
sky2_write8(hw, B2_Y2_CLK_GATE, 0);
 
/* Turn off phy power saving */
-   pci_read_config_dword(hw-pdev, PCI_DEV_REG1, reg1);
+   reg1 = sky2_pci_read32(hw, PCI_DEV_REG1);
reg1 = ~(PCI_Y2_PHY1_POWD | PCI_Y2_PHY2_POWD);
 
/* looks like this XL is back asswards .. */
@@ -234,26 +234,26 @@
}
 
if (hw-chip_id == CHIP_ID_YUKON_EC_U) {
-   pci_write_config_dword(hw-pdev, PCI_DEV_REG3, 0);
-   pci_read_config_dword(hw-pdev, PCI_DEV_REG4, reg1);
+   sky2_pci_write32(hw, PCI_DEV_REG3, 0);
+   reg1 = sky2_pci_read32(hw, PCI_DEV_REG4);
reg1 = P_ASPM_CONTROL_MSK;
-   pci_write_config_dword(hw-pdev, PCI_DEV_REG4, reg1);
-   pci_write_config_dword(hw-pdev, PCI_DEV_REG5, 0);
+   sky2_pci_write32(hw, PCI_DEV_REG4, reg1);
+   sky2_pci_write32(hw, PCI_DEV_REG5, 0);
}
 
-   pci_write_config_dword(hw-pdev, PCI_DEV_REG1, reg1);
+   sky2_pci_write32(hw, PCI_DEV_REG1, reg1);
 
break;
 
case PCI_D3hot:
case PCI_D3cold:
/* Turn on phy power saving */
-   pci_read_config_dword(hw-pdev, PCI_DEV_REG1, reg1);
+   reg1 = sky2_pci_read32(hw, PCI_DEV_REG1);
if (hw-chip_id == CHIP_ID_YUKON_XL  hw-chip_rev  1)
reg1 = ~(PCI_Y2_PHY1_POWD | PCI_Y2_PHY2_POWD);
else
reg1 |= (PCI_Y2_PHY1_POWD | PCI_Y2_PHY2_POWD);
-   pci_write_config_dword(hw-pdev, PCI_DEV_REG1, reg1);
+   sky2_pci_write32(hw, PCI_DEV_REG1, reg1);
 
if (hw-chip_id == CHIP_ID_YUKON_XL  hw-chip_rev  1)
sky2_write8(hw, B2_Y2_CLK_GATE, 0);
@@ -275,7 +275,7 @@
ret = -1;
}
 
-   pci_write_config_byte(hw-pdev, hw-pm_cap + PCI_PM_CTRL, 
power_control);
+   sky2_pci_write16(hw, hw-pm_cap + PCI_PM_CTRL, power_control);
sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_OFF);
return ret;
 }
@@ -2059,13 +2059,13 @@
if (status  (Y2_IS_MST_ERR | Y2_IS_IRQ_STAT)) {
u16 pci_err;
 
-   pci_read_config_word(hw-pdev, PCI_STATUS, pci_err);
+   pci_err = sky2_pci_read16(hw, PCI_STATUS);
if (net_ratelimit())
printk(KERN_ERR PFX %s: pci hw error (0x%x)\n,
   pci_name(hw-pdev), pci_err);
 
sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_ON);
-   pci_write_config_word(hw-pdev, PCI_STATUS,
+   sky2_pci_write16(hw, PCI_STATUS,
  pci_err | PCI_STATUS_ERROR_BITS);
sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_OFF);
}
@@ -2074,7 +2074,7 @@
/* PCI-Express uncorrectable Error occurred */
u32 pex_err;
 
-   pci_read_config_dword(hw-pdev, PEX_UNC_ERR_STAT, pex_err);
+   pex_err = sky2_pci_read32(hw, PEX_UNC_ERR_STAT);
 
if (net_ratelimit())
printk(KERN_ERR PFX %s: pci express error (0x%x)\n,
@@ -2082,7 +2082,7 @@
 
/* clear the interrupt */
sky2_write32(hw, B2_TST_CTRL1, TST_CFG_WRITE_ON);
-   pci_write_config_dword(hw-pdev, PEX_UNC_ERR_STAT,
+   sky2_pci_write32(hw, PEX_UNC_ERR_STAT,
   0xUL);
sky2_write32(hw, B2_TST_CTRL1, TST_CFG_WRITE_OFF);
 
@@ -2212,7 +2212,7 @@
 {
u16 status;
u8 t8, pmd_type;
-   int i, err;
+   int i;
 
sky2_write8(hw, B0_CTST, CS_RST_CLR);
 
@@ 

[no subject]

2006-02-22 Thread Stephen Hemminger
Need to force a transmit coalesce timer restart after processing
transmit packets. Otherwise, can get transmit status after last
update and chip doesn't send the next one.

Can go with the chip defaults for coalescing timers, except for
Tx timer which needs to be bigger.

Signed-off-by: Stephen Hemminger [EMAIL PROTECTED]

--- sky2.orig/drivers/net/sky2.c2006-02-22 11:33:17.0 -0800
+++ sky2/drivers/net/sky2.c 2006-02-22 11:33:33.0 -0800
@@ -1988,13 +1988,12 @@
sky2_tx_check(hw, 0, tx_done[0]);
sky2_tx_check(hw, 1, tx_done[1]);
 
-   if (likely(work_done  to_do)) {
-   /* need to restart TX timer */
-   if (is_ec_a1(hw)) {
-   sky2_write8(hw, STAT_TX_TIMER_CTRL, TIM_STOP);
-   sky2_write8(hw, STAT_TX_TIMER_CTRL, TIM_START);
-   }
+   if (sky2_read8(hw, STAT_TX_TIMER_CTRL) == TIM_START) {
+   sky2_write8(hw, STAT_TX_TIMER_CTRL, TIM_STOP);
+   sky2_write8(hw, STAT_TX_TIMER_CTRL, TIM_START);
+   }
 
+   if (likely(work_done  to_do)) {
netif_rx_complete(dev0);
hw-intr_mask |= Y2_IS_STAT_BMU;
sky2_write32(hw, B0_IMSK, hw-intr_mask);
@@ -2352,8 +2351,7 @@
sky2_write8(hw, STAT_FIFO_ISR_WM, 16);
 
sky2_write32(hw, STAT_TX_TIMER_INI, sky2_us2clk(hw, 1000));
-   sky2_write32(hw, STAT_LEV_TIMER_INI, sky2_us2clk(hw, 100));
-   sky2_write32(hw, STAT_ISR_TIMER_INI, sky2_us2clk(hw, 20));
+   sky2_write32(hw, STAT_ISR_TIMER_INI, sky2_us2clk(hw, 7));
}
 
/* enable status unit */

--

-
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: [RFC] Some infrastructure for interrupt-less TX

2006-02-22 Thread Caitlin Bestler
[EMAIL PROTECTED] wrote:
 Below patch wasn't even compile tested.  I'm not involved
 with network drivers anymore, so my personal interest is
 fairly low.  But since I firmly believe in the advantages and
 feasibility of interrupt-less TX, there should at least be an
 ugly broken patch to flame about.  Go for it, tell me how stupid I am!
 
 Jörn

I am assuming the real goal is avoiding interrupts when
transmit completions can be reported without them on a
reasonably periodic basis.

Wouldn't that goal be achievable by the type of transmit
buffer ring implied for net channels?

-
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: pktgen + napi == kaboom

2006-02-22 Thread Simon Kirby
On Wed, Feb 22, 2006 at 10:56:31AM -0800, Ben Greear wrote:

 For VLANs, make sure that the 'multi-skb' is always zero.  This is because
 the VLAN code modifies the skb by re-assigning the skb-dev to the 
 underlying
 device.
 
 I'm not sure if this is the problem you hit, but it could be...

Yup, that was it.

Of course, now it doesn't send as fast.  Hrmph. :)  On this older Xeon
2.4 Ghz w/533 FSB and e1000  tg3 @ PCI-X 133 Mhz 64 bit, SMP kernel,
single pktgen thread, I'm only seeing:

clone_skb=0, 802.1Q tagging, 60 byte:
e1000: 558526pps 268Mb/sec (268092480bps) errors: 0
tg3: 621260pps 298Mb/sec (298204800bps) errors: 0

clone_skb=0, no 802.1Q, 60 byte:
e1000: 664558pps 318Mb/sec (318987840bps) errors: 0
tg3:   772650pps 370Mb/sec (370872000bps) errors: 0

clone_skb=16384, no 802.1Q, 60 byte:
e1000: 684206pps 328Mb/sec (328418880bps) errors: 0
tg3: 1069830pps 513Mb/sec (513518400bps) errors: 0

I tried on an Opteron 140 box and it was faster for both cards, but not
by much.  oprofile showed a lot of do_getttimeofday, so I hacked a bunch
of calls out of pktgen -- I noticed the CPU time shifted around but the
throughput was still the same as before, as if it's card or bus limited. 

Why is it so difficult to actually get 1 Gbps of small packets?  I also
tried changing ring buffer sizes, txqueuelen, interrupt coalescing
settings, etc... all I was able to do was make it slower or very
slightly faster.

Simon-
-
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] WE-20 for kernel 2.6.16

2006-02-22 Thread Jean Tourrilhes
Hi Jeff,

This is version 20 of the Wireless Extensions. This is the
completion of the RtNetlink work I started early 2004, it enables the
full Wireless Extension API over RtNetlink.
The patch has been fully tested with 2.6.16-rc2 and 2.6.16-rc3
and various wireless drivers, and is in its final version. Would you
mind pushing that into Linus's kernel at the next opportunity, for
example for 2.6.17-pre.

Few comments on the patch :
o totally driver transparent, no change in drivers needed.
o iwevent were already RtNetlink based since they were created
(around 2.5.7). This adds all the regular SET and GET requests over
RtNetlink, using the exact same mechanism and data format as iwevents.
o This is a Kconfig option, as currently most people have no
need for it. Surprisingly, patch is actually small and well
encapsulated.
o Tested on SMP, attention as been paid to make it 64 bits clean.
o Code do probably too many checks and could be further
optimised, but better safe than sorry.
o RtNetlink based version of the Wireless Tools available on
my web page for people inclined to try out this stuff.

I would also like to thank Alexey Kuznetsov for his helpful
suggestions to make this patch better.

Have fun...

Jean

Signed-off-by: Jean Tourrilhes [EMAIL PROTECTED]

---

diff -u -p linux/include/linux/wireless.19.h linux/include/linux/wireless.h
--- linux/include/linux/wireless.19.h   2006-02-17 10:49:04.0 -0800
+++ linux/include/linux/wireless.h  2006-02-17 17:58:10.0 -0800
@@ -1,10 +1,10 @@
 /*
  * This file define a set of standard wireless extensions
  *
- * Version :   19  18.3.05
+ * Version :   20  17.2.06
  *
  * Authors :   Jean Tourrilhes - HPL - [EMAIL PROTECTED]
- * Copyright (c) 1997-2005 Jean Tourrilhes, All Rights Reserved.
+ * Copyright (c) 1997-2006 Jean Tourrilhes, All Rights Reserved.
  */
 
 #ifndef _LINUX_WIRELESS_H
@@ -80,7 +80,7 @@
  * (there is some stuff that will be added in the future...)
  * I just plan to increment with each new version.
  */
-#define WIRELESS_EXT   19
+#define WIRELESS_EXT   20
 
 /*
  * Changes :
@@ -204,6 +204,10 @@
  * - Add IW_QUAL_ALL_UPDATED and IW_QUAL_ALL_INVALID macros
  * - Add explicit flag to tell stats are in dBm : IW_QUAL_DBM
  * - Add IW_IOCTL_IDX() and IW_EVENT_IDX() macros
+ *
+ * V19 to V20
+ * --
+ * - RtNetlink requests support (SET/GET)
  */
 
 / CONSTANTS /
diff -u -p linux/include/net/iw_handler.19.h linux/include/net/iw_handler.h
--- linux/include/net/iw_handler.19.h   2006-02-17 10:49:15.0 -0800
+++ linux/include/net/iw_handler.h  2006-02-17 18:01:36.0 -0800
@@ -4,7 +4,7 @@
  * Version :   7   18.3.05
  *
  * Authors :   Jean Tourrilhes - HPL - [EMAIL PROTECTED]
- * Copyright (c) 2001-2005 Jean Tourrilhes, All Rights Reserved.
+ * Copyright (c) 2001-2006 Jean Tourrilhes, All Rights Reserved.
  */
 
 #ifndef _IW_HANDLER_H
@@ -436,6 +436,16 @@ extern int dev_get_wireless_info(char * 
 /* Handle IOCTLs, called in net/core/dev.c */
 extern int wireless_process_ioctl(struct ifreq *ifr, unsigned int cmd);
 
+/* Handle RtNetlink requests, called in net/core/rtnetlink.c */
+extern int wireless_rtnetlink_set(struct net_device *  dev,
+ char *data,
+ int   len);
+extern int wireless_rtnetlink_get(struct net_device *  dev,
+ char *data,
+ int   len,
+ char **   p_buf,
+ int * p_len);
+
 /* Second : functions that may be called by driver modules */
 
 /* Send a single event to user space */
diff -u -p linux/drivers/net/wireless/Kconfig.19 
linux/drivers/net/wireless/Kconfig
--- linux/drivers/net/wireless/Kconfig.19   2006-02-21 13:11:34.0 
-0800
+++ linux/drivers/net/wireless/Kconfig  2006-02-22 11:48:27.0 -0800
@@ -24,6 +24,15 @@ config NET_RADIO
  the tools from
  http://www.hpl.hp.com/personal/Jean_Tourrilhes/Linux/Tools.html.
 
+config NET_WIRELESS_RTNETLINK
+   bool Wireless Extension API over RtNetlink
+   ---help---
+ Support the Wireless Extension API over the RtNetlink socket
+ in addition to the traditional ioctl interface (selected above).
+
+ For now, few tools use this facility, but it might grow in the
+ future. The only downside is that it adds 4.5 kB to your kernel.
+
 # Note : the cards are obsolete (can't buy them anymore), but the drivers
 # are not, as people are still using them...
 comment Obsolete Wireless cards support (pre-802.11)
diff -u -p linux/net/core/rtnetlink.19.c 

Re: [PATCH 0/6] sky2: fixes for 2.6.16

2006-02-22 Thread Francois Romieu
Stephen Hemminger [EMAIL PROTECTED] :
 This set of patches covers the set of bug fixes that need
 to go into 2.6.16 for the sky2 driver.

#1..#6 Applied to branch 'for-jeff' at
git://electric-eye.fr.zoreil.com/home/romieu/linux-2.6.git

I have replaced the empty summary message of #4 by 
'[PATCH] sky2: force early transmit status'

-- 
Ueimor
-
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: Problem with Ipsec transport mode over NAT

2006-02-22 Thread Patrick McHardy
Chinh Nguyen wrote:
 I discovered that the bug is in the function tcp_v4_rcv for kernel 
 2.6.16-rc1.
 
 After the ESP packet is decapped and decrypted in xfrm4_rcv_encap_finish, the
 unencrypted packet is pushed back through ip_local_deliver. For a UDP packet, 
 it
 goes (back) to function udp_queue_rcv_skb. The first thing this function does 
 is
 called xfrm4_policy_check. As noted previously, in xfrm4_policy_check, if the
 skb-sp != NULL, the esp_post_input function is called. The post input 
 function
 sets skb-ip_summed to CHECKSUM_UNNECESSASRY if we are in transport mode.
 Therefore, further down in udp_queue_rcv_skb, we skip the checksum check and 
 the
 packet is passed up the stack.
 
 However, for a decrypted TCP packet, the packet goes to tcp_v4_rcv. This
 function does the checksum check right away if skb-ip_summed !=
 CHECKSUM_UNNECESSARY while xfrm4_policy_check is called a little later in the
 function. Therefore, the esp post input has not yet set the ip_summed to
 unnecessary. The decrypted packet fails the checksum and is discarded.
 
 To confirm this, I added another call to xfrm4_policy_check before the 
 checksum
 check in tcp_v4_rcv (to call esp post input). Once patched, my systems were 
 able
 to initiate TCP connections using Transport Mode/NAT.

What values does skb-ip_summed have before that?
-
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: [RFC] Some infrastructure for interrupt-less TX

2006-02-22 Thread Jörn Engel
On Wed, 22 February 2006 12:37:48 -0800, Caitlin Bestler wrote:
 [EMAIL PROTECTED] wrote:
  Below patch wasn't even compile tested.  I'm not involved
  with network drivers anymore, so my personal interest is
  fairly low.  But since I firmly believe in the advantages and
  feasibility of interrupt-less TX, there should at least be an
  ugly broken patch to flame about.  Go for it, tell me how stupid I am!
  
  Jörn
 
 I am assuming the real goal is avoiding interrupts when
 transmit completions can be reported without them on a
 reasonably periodic basis.

Not necessarily on a periodic basis.  For some network driver I once
worked on, the hardware simply had a ring buffer of n frames.
Whenever a n+1th frame was transmitted, the first would be checked for
completion.  If it was completed, it was freed, else the new frame was
dropped (and freed).

So for this driver, the hardware permanently owned n memory areas
which would never get freed.  Nice performance at the cost of a little
wasted memory.

Alternatively you could set a timer as well, sure.

 Wouldn't that goal be achievable by the type of transmit
 buffer ring implied for net channels?

Possibly.  I don't really understand the transmit side of net channels
yet.  But the principle should be the same.  Whatever data structures
the kernel need on top of the raw packet is freed early, the raw
packet is handed over to the hardware and freed late.

Jörn

-- 
There's nothing better for promoting creativity in a medium than
making an audience feel Hmm ­ I could do better than that!
-- Douglas Adams in a slashdot interview
-
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