[PATCH 14/11] cxgb3 - CQ context operations time out too soon.

2007-08-22 Thread Divy Le Ray
From: Divy Le Ray <[EMAIL PROTECTED]>

Currently, the driver only tries up to 5 times (5us) to get the results
of a CQ context operation.  Testing has shown the chip can take as much
as 50us to return the response on SG_CONTEXT_CMD operations.  So we up
the retry count to 100 to cover high loads.

Signed-off-by: Divy Le Ray <[EMAIL PROTECTED]>
---

 drivers/net/cxgb3/t3_hw.c |   19 +++
 1 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/drivers/net/cxgb3/t3_hw.c b/drivers/net/cxgb3/t3_hw.c
index 9358959..8f6efdb 100644
--- a/drivers/net/cxgb3/t3_hw.c
+++ b/drivers/net/cxgb3/t3_hw.c
@@ -1867,6 +1867,8 @@ void t3_port_intr_clear(struct adapter *adapter, int idx)
phy->ops->intr_clear(phy);
 }
 
+#define SG_CONTEXT_CMD_ATTEMPTS 100
+
 /**
  * t3_sge_write_context - write an SGE context
  * @adapter: the adapter
@@ -1886,7 +1888,7 @@ static int t3_sge_write_context(struct adapter *adapter, 
unsigned int id,
t3_write_reg(adapter, A_SG_CONTEXT_CMD,
 V_CONTEXT_CMD_OPCODE(1) | type | V_CONTEXT(id));
return t3_wait_op_done(adapter, A_SG_CONTEXT_CMD, F_CONTEXT_CMD_BUSY,
-  0, 5, 1);
+  0, SG_CONTEXT_CMD_ATTEMPTS, 1);
 }
 
 /**
@@ -2072,7 +2074,7 @@ int t3_sge_enable_ecntxt(struct adapter *adapter, 
unsigned int id, int enable)
t3_write_reg(adapter, A_SG_CONTEXT_CMD,
 V_CONTEXT_CMD_OPCODE(1) | F_EGRESS | V_CONTEXT(id));
return t3_wait_op_done(adapter, A_SG_CONTEXT_CMD, F_CONTEXT_CMD_BUSY,
-  0, 5, 1);
+  0, SG_CONTEXT_CMD_ATTEMPTS, 1);
 }
 
 /**
@@ -2096,7 +2098,7 @@ int t3_sge_disable_fl(struct adapter *adapter, unsigned 
int id)
t3_write_reg(adapter, A_SG_CONTEXT_CMD,
 V_CONTEXT_CMD_OPCODE(1) | F_FREELIST | V_CONTEXT(id));
return t3_wait_op_done(adapter, A_SG_CONTEXT_CMD, F_CONTEXT_CMD_BUSY,
-  0, 5, 1);
+  0, SG_CONTEXT_CMD_ATTEMPTS, 1);
 }
 
 /**
@@ -2120,7 +2122,7 @@ int t3_sge_disable_rspcntxt(struct adapter *adapter, 
unsigned int id)
t3_write_reg(adapter, A_SG_CONTEXT_CMD,
 V_CONTEXT_CMD_OPCODE(1) | F_RESPONSEQ | V_CONTEXT(id));
return t3_wait_op_done(adapter, A_SG_CONTEXT_CMD, F_CONTEXT_CMD_BUSY,
-  0, 5, 1);
+  0, SG_CONTEXT_CMD_ATTEMPTS, 1);
 }
 
 /**
@@ -2144,7 +2146,7 @@ int t3_sge_disable_cqcntxt(struct adapter *adapter, 
unsigned int id)
t3_write_reg(adapter, A_SG_CONTEXT_CMD,
 V_CONTEXT_CMD_OPCODE(1) | F_CQ | V_CONTEXT(id));
return t3_wait_op_done(adapter, A_SG_CONTEXT_CMD, F_CONTEXT_CMD_BUSY,
-  0, 5, 1);
+  0, SG_CONTEXT_CMD_ATTEMPTS, 1);
 }
 
 /**
@@ -2169,7 +2171,7 @@ int t3_sge_cqcntxt_op(struct adapter *adapter, unsigned 
int id, unsigned int op,
t3_write_reg(adapter, A_SG_CONTEXT_CMD, V_CONTEXT_CMD_OPCODE(op) |
 V_CONTEXT(id) | F_CQ);
if (t3_wait_op_done_val(adapter, A_SG_CONTEXT_CMD, F_CONTEXT_CMD_BUSY,
-   0, 5, 1, &val))
+   0, SG_CONTEXT_CMD_ATTEMPTS, 1, &val))
return -EIO;
 
if (op >= 2 && op < 7) {
@@ -2179,7 +2181,8 @@ int t3_sge_cqcntxt_op(struct adapter *adapter, unsigned 
int id, unsigned int op,
t3_write_reg(adapter, A_SG_CONTEXT_CMD,
 V_CONTEXT_CMD_OPCODE(0) | F_CQ | V_CONTEXT(id));
if (t3_wait_op_done(adapter, A_SG_CONTEXT_CMD,
-   F_CONTEXT_CMD_BUSY, 0, 5, 1))
+   F_CONTEXT_CMD_BUSY, 0,
+   SG_CONTEXT_CMD_ATTEMPTS, 1))
return -EIO;
return G_CQ_INDEX(t3_read_reg(adapter, A_SG_CONTEXT_DATA0));
}
@@ -2205,7 +2208,7 @@ static int t3_sge_read_context(unsigned int type, struct 
adapter *adapter,
t3_write_reg(adapter, A_SG_CONTEXT_CMD,
 V_CONTEXT_CMD_OPCODE(0) | type | V_CONTEXT(id));
if (t3_wait_op_done(adapter, A_SG_CONTEXT_CMD, F_CONTEXT_CMD_BUSY, 0,
-   5, 1))
+   SG_CONTEXT_CMD_ATTEMPTS, 1))
return -EIO;
data[0] = t3_read_reg(adapter, A_SG_CONTEXT_DATA0);
data[1] = t3_read_reg(adapter, A_SG_CONTEXT_DATA1);
-
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 13/11] cxgb3 - Set the CQ_ERR bit in CQ contexts.

2007-08-22 Thread Divy Le Ray
From: Divy Le Ray <[EMAIL PROTECTED]>

The cxgb3 driver is incorrectly configuring the HW CQ context for CQ's
that use overflow-avoidance.  Namely the RDMA control CQ.  This results
in a bad DMA from the device to bus address 0.  The solution is to set
the CQ_ERR bit in the context for these types of CQs.

Signed-off-by: Divy Le Ray <[EMAIL PROTECTED]>
---

 drivers/net/cxgb3/sge_defs.h |4 
 drivers/net/cxgb3/t3_hw.c|3 ++-
 2 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/drivers/net/cxgb3/sge_defs.h b/drivers/net/cxgb3/sge_defs.h
index 514869e..29b6c80 100644
--- a/drivers/net/cxgb3/sge_defs.h
+++ b/drivers/net/cxgb3/sge_defs.h
@@ -106,6 +106,10 @@
 #define V_CQ_GEN(x) ((x) << S_CQ_GEN)
 #define F_CQ_GENV_CQ_GEN(1U)
 
+#define S_CQ_ERR30
+#define V_CQ_ERR(x) ((x) << S_CQ_ERR)
+#define F_CQ_ERRV_CQ_ERR(1U)
+
 #define S_CQ_OVERFLOW_MODE31
 #define V_CQ_OVERFLOW_MODE(x) ((x) << S_CQ_OVERFLOW_MODE)
 #define F_CQ_OVERFLOW_MODEV_CQ_OVERFLOW_MODE(1U)
diff --git a/drivers/net/cxgb3/t3_hw.c b/drivers/net/cxgb3/t3_hw.c
index 538b254..9358959 100644
--- a/drivers/net/cxgb3/t3_hw.c
+++ b/drivers/net/cxgb3/t3_hw.c
@@ -2043,7 +2043,8 @@ int t3_sge_init_cqcntxt(struct adapter *adapter, unsigned 
int id, u64 base_addr,
base_addr >>= 32;
t3_write_reg(adapter, A_SG_CONTEXT_DATA2,
 V_CQ_BASE_HI((u32) base_addr) | V_CQ_RSPQ(rspq) |
-V_CQ_GEN(1) | V_CQ_OVERFLOW_MODE(ovfl_mode));
+V_CQ_GEN(1) | V_CQ_OVERFLOW_MODE(ovfl_mode) |
+V_CQ_ERR(ovfl_mode));
t3_write_reg(adapter, A_SG_CONTEXT_DATA3, V_CQ_CREDITS(credits) |
 V_CQ_CREDIT_THRES(credit_thres));
return t3_sge_write_context(adapter, id, F_CQ);
-
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 12/11] cxgb3 - remove false positive in xgmac workaround

2007-08-22 Thread Divy Le Ray
From: Divy Le Ray <[EMAIL PROTECTED]>

Qualify toggling of xgmac tx enable with not getting pause frames, 
we might not make forward progress because the peer is sending 
lots of pause frames.

Signed-off-by: Divy Le Ray <[EMAIL PROTECTED]>
---

 drivers/net/cxgb3/common.h |1 +
 drivers/net/cxgb3/xgmac.c  |4 +++-
 2 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/drivers/net/cxgb3/common.h b/drivers/net/cxgb3/common.h
index ff867c2..3e5b0db 100644
--- a/drivers/net/cxgb3/common.h
+++ b/drivers/net/cxgb3/common.h
@@ -514,6 +514,7 @@ struct cmac {
u64 rx_mcnt;
unsigned int toggle_cnt;
unsigned int txen;
+   u64 rx_pause;
struct mac_stats stats;
 };
 
diff --git a/drivers/net/cxgb3/xgmac.c b/drivers/net/cxgb3/xgmac.c
index 1d1c391..ff9e9dc 100644
--- a/drivers/net/cxgb3/xgmac.c
+++ b/drivers/net/cxgb3/xgmac.c
@@ -452,6 +452,7 @@ int t3_mac_enable(struct cmac *mac, int which)
A_XGM_TX_SPI4_SOP_EOP_CNT +
oft)));
mac->rx_mcnt = s->rx_frames;
+   mac->rx_pause = s->rx_pause;
mac->rx_xcnt = (G_TXSPI4SOPCNT(t3_read_reg(adap,
A_XGM_RX_SPI4_SOP_EOP_CNT +
oft)));
@@ -504,7 +505,7 @@ int t3b2_mac_watchdog_task(struct cmac *mac)
tx_xcnt = 1;/* By default tx_xcnt is making progress */
tx_tcnt = mac->tx_tcnt; /* If tx_mcnt is progressing ignore tx_tcnt */
rx_xcnt = 1;/* By default rx_xcnt is making progress */
-   if (tx_mcnt == mac->tx_mcnt) {
+   if (tx_mcnt == mac->tx_mcnt && mac->rx_pause == s->rx_pause) {
tx_xcnt = (G_TXSPI4SOPCNT(t3_read_reg(adap,
A_XGM_TX_SPI4_SOP_EOP_CNT +
mac->offset)));
@@ -560,6 +561,7 @@ out:
mac->tx_mcnt = s->tx_frames;
mac->rx_xcnt = rx_xcnt;
mac->rx_mcnt = s->rx_frames;
+   mac->rx_pause = s->rx_pause;
if (status == 1) {
t3_write_reg(adap, A_XGM_TX_CTRL + mac->offset, 0);
t3_read_reg(adap, A_XGM_TX_CTRL + mac->offset);  /* flush */
-
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] cxgb3 driver update

2007-08-22 Thread Divy Le Ray

Hi Jeff,

I'm submitting three more patches for inclusion in netdev#upstream.
These patches are built over the series I resent yesterday night.
The patch numbering reflects the stacking.

Here is a brief description:
-   avoid false positives in the xgmac hang workaround
-   Properly set the CQ_ERR bit in RDMA CQ contexts.
-   Update CQ context operations time out values

Cheers,
Divy


-
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] improved xfrm_audit_log() patch

2007-08-22 Thread David Miller
From: Joy Latten <[EMAIL PROTECTED]>
Date: Wed, 22 Aug 2007 20:29:17 -0500

> On Wed, 2007-08-22 at 12:51 -0700, David Miller wrote:
> > From: David Miller <[EMAIL PROTECTED]>
> > Date: Tue, 21 Aug 2007 00:24:05 -0700 (PDT)
> > 
> > > Looks good, applied to net-2.6.24, thanks Joy.
> > 
> > Something is still buggered up in this patch, you can't add this local
> > "audit_info" variable unconditionally to these functions, and
> > alternatively you also can't add a bunch of ifdefs to xfrm_user.c to
> > cover it up either.
> > 
> I wonder if I am subconsciously trying to break a record or 
> something! My apologies as time is valuable. 
> 
> I mean to get this right. My rationale for using audit_info was to
> reduce amount of arguments to xfrm_audit_log(). However, I now like
> it better when I just called xfrm_audit_log(NETLINK_CB(skb).loginuid,
> NETLINK_CB(skb).sid, ...). User determines where/how to get loginuid and
> secid and nothing happens when AUDIT not configured. But would make
> xfrm_audit_log() have 7 arguments instead of 6.
> 
> My alternative is to remove xfrm_get_auditinfo() out of the 
> #ifdef CONFIG_AUDITSYSCALL and always fill in audit_info
> regardless if AUDIT is configured or not. Less calls to
> xfrm_audit_log() but perhaps unnecessary info when AUDIT 
> not configured.
> 
> Would first solution be acceptable?

I don't like either of these ideas, sorry.

I would suggest, at this point, to make purpose built situation
specific interfaces that pass specific objects (the ones being
operated upon) to the audit layer.

Let the audit layer pick out the bits it actually wants in the
format it likes.

For example, if we're creating a template, pass the policy and
the templace to the audit layer via a function called:

xfrm_audit_template_add()

or something like that.  That function only needs two arguments.

All of these call sites will rarely need more than 2 or 3 arguments in
any given situation, and the on-stack audit thing will be gone too.

This is the suggestion I made to you over a month ago, but you choose
to do the on-stack thing.

You must make this cost absolutely nothing when it is either
not configured, and have next to no cost when not enabled at
run time.  And it is very doable.
-
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] ucc_geth: kill unused include

2007-08-22 Thread David Gibson
On Wed, Aug 22, 2007 at 09:51:03PM -0500, Kumar Gala wrote:
> The ucc_geth_mii code is based on the gianfar_mii code that use to include
> ocp.h.  ucc never need this and it causes issues when we want to kill
> arch/ppc includes from arch/powerpc.
> 
> Signed-off-by: Kumar Gala <[EMAIL PROTECTED]>

Acked-by: David Gibson <[EMAIL PROTECTED]>

-- 
David Gibson| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au  | minimalist, thank you.  NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
-
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] ucc_geth: kill unused include

2007-08-22 Thread Kumar Gala
The ucc_geth_mii code is based on the gianfar_mii code that use to include
ocp.h.  ucc never need this and it causes issues when we want to kill
arch/ppc includes from arch/powerpc.

Signed-off-by: Kumar Gala <[EMAIL PROTECTED]>
---

Jeff, if you issue with this for 2.6.23, I'd prefer to push this via
the powerpc.git trees in 2.6.24 as part of a larger cleanup.  Let me know
one way or the other.

- k

 drivers/net/ucc_geth_mii.c |1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/drivers/net/ucc_geth_mii.c b/drivers/net/ucc_geth_mii.c
index 6c257b8..df884f0 100644
--- a/drivers/net/ucc_geth_mii.c
+++ b/drivers/net/ucc_geth_mii.c
@@ -32,7 +32,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
-- 
1.5.2.4

-
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 1/10 Rev4] [Doc] HOWTO Documentation for batching

2007-08-22 Thread Krishna Kumar2
Hi Randy,

Thanks for your suggestions. Will clean up those changes.

- KK

Randy Dunlap <[EMAIL PROTECTED]> wrote on 08/22/2007 09:20:13 PM:

> On Wed, 22 Aug 2007 13:58:58 +0530 Krishna Kumar wrote:
>
> > Add Documentation describing batching skb xmit capability.
> >
> > Signed-off-by: Krishna Kumar <[EMAIL PROTECTED]>
> > ---
> >  batching_skb_xmit.txt |   78
++
> >  1 files changed, 78 insertions(+)
> >
> > diff -ruNp org/Documentation/networking/batching_skb_xmit.txt
> new/Documentation/networking/batching_skb_xmit.txt
> > --- org/Documentation/networking/batching_skb_xmit.txt   1970-01-01
05:30:
> 00.0 +0530
> > +++ new/Documentation/networking/batching_skb_xmit.txt   2007-08-22
10:21:
> 19.0 +0530
> > @@ -0,0 +1,78 @@
> > +   HOWTO for batching skb xmit support
> > +   ---
> > +
> > +Section 1: What is batching skb xmit
> > +Section 2: How batching xmit works vs the regular xmit
> > +Section 3: How drivers can support batching
> > +Section 4: How users can work with batching
> > +
> > +
> > +Introduction: Kernel support for batching skb
> > +--
> > +
> > +A new capability to support xmit of multiple skbs is provided in the
netdevice
> > +layer. Drivers which enable this capability should be able to process
multiple
> > +skbs in a single call to their xmit handler.
> > +
> > +
> > +Section 1: What is batching skb xmit
> > +-
> > +
> > +   This capability is optionally enabled by a driver by setting the
> > +   NETIF_F_BATCH_SKBS bit in dev->features. The pre-requisite for a
>
>  prerequisite
>
> > +   driver to use this capability is that it should have a reasonably
>
>I would say "reasonably-sized".
>
> > +   sized hardware queue that can process multiple skbs.
> > +
> > +
> > +Section 2: How batching xmit works vs the regular xmit
> > +---
> > +
> > +   The network stack gets called from upper layer protocols with a
single
> > +   skb to transmit. This skb is first enqueue'd and an attempt is made
to
>
>enqueued
>
> > +   transmit it immediately (via qdisc_run). However, events like tx
lock
> > +   contention, tx queue stopped, etc, can result in the skb not
getting
>
>   etc.,
>
> > +   sent out and it remains in the queue. When the next xmit is called
or
> > +   when the queue is re-enabled, qdisc_run could potentially find
> > +   multiple packets in the queue, and iteratively send them all out
> > +   one-by-one.
> > +
> > +   Batching skb xmit is a mechanism to exploit this situation where
all
> > +   skbs can be passed in one shot to the device. This reduces driver
> > +   processing, locking at the driver (or in stack for ~LLTX drivers)
> > +   gets amortized over multiple skbs, and in case of specific drivers
> > +   where every xmit results in a completion processing (like IPoIB) -
> > +   optimizations can be made in the driver to request a completion for
> > +   only the last skb that was sent which results in saving interrupts
> > +   for every (but the last) skb that was sent in the same batch.
> > +
> > +   Batching can result in significant performance gains for systems
that
> > +   have multiple data stream paths over the same network interface
card.
> > +
> > +
> > +Section 3: How drivers can support batching
> > +-
> > +
> > +   Batching requires the driver to set the NETIF_F_BATCH_SKBS bit in
> > +   dev->features.
> > +
> > +   The driver's xmit handler should be modified to process multiple
skbs
> > +   instead of one skb. The driver's xmit handler is called either with
a
>
>
an
>
> > +   skb to transmit or NULL skb, where the latter case should be
handled
> > +   as a call to xmit multiple skbs. This is done by sending out all
skbs
> > +   in the dev->skb_blist list (where it was added by the core stack).
> > +
> > +
> > +Section 4: How users can work with batching
> > +-
> > +
> > +   Batching can be disabled for a particular device, e.g. on desktop
> > +   systems if only one stream of network activity for that device is
> > +   taking place, since performance could be slightly affected due to
> > +   extra processing that batching adds (unless packets are getting
> > +   sent fast resulting in stopped queue's). Batching can be enabled if
>
>queues).
>
> > +   more than one stream of network activity per device is being done,
> > +   e.g. on servers; or even desktop usage with multiple browser, chat,
> > +   file transfer sessions, etc.
> > +
> > +   Per device batching can be enabled/disabled by passing 'on' or
'off'
> > +   respectively to ethtool.
>
>with what other parameter(s

Re: [PATCH 10/10 Rev4] [E1000] Implement batching

2007-08-22 Thread Krishna Kumar2
Hi Auke,

"Kok, Auke" <[EMAIL PROTECTED]> wrote on 08/22/2007 08:09:31 PM:

> Krishna,
>
> while I appreciate the patch I would have preferred a patch to e1000e.
Not only
> does the e1000e driver remove a lot of the workarounds for old silicon,
it is
> also a good way for us to move the current e1000 driver into a bit more
stable
> maintenance mode.
>
> Do you think you can write this patch for e1000e instead? code-wise a lot
of
> things are still the same, so your patch should be relatively easy to
generate.
>
> e1000e currently lives in a branch from jeff garzik's netdev-2.6 tree

Definitely, I will pick it up and generate a patch.

Thanks,

- KK

-
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 0/9 Rev3] Implement batching skb API and support in IPoIB

2007-08-22 Thread Krishna Kumar2
David Miller <[EMAIL PROTECTED]> wrote on 08/22/2007 02:44:40 PM:

> From: Krishna Kumar2 <[EMAIL PROTECTED]>
> Date: Wed, 22 Aug 2007 12:33:04 +0530
>
> > Does turning off batching solve that problem? What I mean by that is:
> > batching can be disabled if a TSO device is worse for some cases.
>
> This new batching stuff isn't going to be enabled or disabled
> on a per-device basis just to get "parity" with how things are
> now.
>
> It should be enabled by default, and give at least as good
> performance as what can be obtained right now.

That was how it was in earlier revisions. In revision4 I coded it so
that it is enabled only if explicitly set by the user. I can revert
that change.

> Otherwise it's a clear regression.

Definitely. For drivers that support it, it should not reduce performance.

Thanks,

- KK

-
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] improved xfrm_audit_log() patch

2007-08-22 Thread Joy Latten
On Wed, 2007-08-22 at 12:51 -0700, David Miller wrote:
> From: David Miller <[EMAIL PROTECTED]>
> Date: Tue, 21 Aug 2007 00:24:05 -0700 (PDT)
> 
> > Looks good, applied to net-2.6.24, thanks Joy.
> 
> Something is still buggered up in this patch, you can't add this local
> "audit_info" variable unconditionally to these functions, and
> alternatively you also can't add a bunch of ifdefs to xfrm_user.c to
> cover it up either.
> 
I wonder if I am subconsciously trying to break a record or 
something! My apologies as time is valuable. 

I mean to get this right. My rationale for using audit_info was to
reduce amount of arguments to xfrm_audit_log(). However, I now like
it better when I just called xfrm_audit_log(NETLINK_CB(skb).loginuid,
NETLINK_CB(skb).sid, ...). User determines where/how to get loginuid and
secid and nothing happens when AUDIT not configured. But would make
xfrm_audit_log() have 7 arguments instead of 6.

My alternative is to remove xfrm_get_auditinfo() out of the 
#ifdef CONFIG_AUDITSYSCALL and always fill in audit_info
regardless if AUDIT is configured or not. Less calls to
xfrm_audit_log() but perhaps unnecessary info when AUDIT 
not configured.

Would first solution be acceptable?

Joy   


-
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] [02/10] pasemi_mac: Stop using the pci config space accessors for register read/writes

2007-08-22 Thread Stephen Rothwell
Hi Olof,

On Wed, 22 Aug 2007 09:12:48 -0500 Olof Johansson <[EMAIL PROTECTED]> wrote:
>
> -static unsigned int read_iob_reg(struct pasemi_mac *mac, unsigned int reg)
> +static inline unsigned int read_iob_reg(struct pasemi_mac *mac, unsigned int 
> reg)
  ^^
For static functions in C files, we tend not to bother marking them
inline any more as the compiler does a pretty good job theses days.

>  {
>   unsigned int val;
>  
> - pci_read_config_dword(mac->iob_pdev, reg, &val);
> + val = in_le32(mac->iob_regs+reg);
> +
>   return val;

Why not just "return in_le32(mac->iob_regs+reg);" ?
And similarly below?

> +static inline void __iomem * __devinit map_onedev(struct pci_dev *p, int 
> index)
  ^^^
Mixing inline and __*init is just plain silly :-)

> +fallback:
> + /* This is hardcoded and ugly, but we have some firmware versions
> +  * who don't provide the register space in the device tree. Luckily
   ^^^
"that"

-- 
Cheers,
Stephen Rothwell[EMAIL PROTECTED]
http://www.canb.auug.org.au/~sfr/


pgp00KliTG9BH.pgp
Description: PGP signature


[PATCH] IOAT: ioatdma needs to to play nice in a multi-dma-client world

2007-08-22 Thread Shannon Nelson
Now that the DMA engine has a multi-client interface, fix the ioatdma
driver to play along.  At the same time, remove a couple of unnecessary
reads and writes.

Signed-off-by: Shannon Nelson <[EMAIL PROTECTED]>
---

 drivers/dma/ioatdma.c |   18 --
 1 files changed, 4 insertions(+), 14 deletions(-)

diff --git a/drivers/dma/ioatdma.c b/drivers/dma/ioatdma.c
index 2d1f178..41b18c5 100644
--- a/drivers/dma/ioatdma.c
+++ b/drivers/dma/ioatdma.c
@@ -191,17 +191,12 @@ static int ioat_dma_alloc_chan_resources(struct dma_chan 
*chan)
int i;
LIST_HEAD(tmp_list);
 
-   /*
-* In-use bit automatically set by reading chanctrl
-* If 0, we got it, if 1, someone else did
-*/
-   chanctrl = readw(ioat_chan->reg_base + IOAT_CHANCTRL_OFFSET);
-   if (chanctrl & IOAT_CHANCTRL_CHANNEL_IN_USE)
-   return -EBUSY;
+   /* have we already been set up? */
+   if (!list_empty(&ioat_chan->free_desc))
+   return INITIAL_IOAT_DESC_COUNT;
 
 /* Setup register to interrupt and write completion status on error */
-   chanctrl = IOAT_CHANCTRL_CHANNEL_IN_USE |
-   IOAT_CHANCTRL_ERR_INT_EN |
+   chanctrl = IOAT_CHANCTRL_ERR_INT_EN |
IOAT_CHANCTRL_ANY_ERR_ABORT_EN |
IOAT_CHANCTRL_ERR_COMPLETION_EN;
 writew(chanctrl, ioat_chan->reg_base + IOAT_CHANCTRL_OFFSET);
@@ -282,11 +277,6 @@ static void ioat_dma_free_chan_resources(struct dma_chan 
*chan)
in_use_descs - 1);
 
ioat_chan->last_completion = ioat_chan->completion_addr = 0;
-
-   /* Tell hw the chan is free */
-   chanctrl = readw(ioat_chan->reg_base + IOAT_CHANCTRL_OFFSET);
-   chanctrl &= ~IOAT_CHANCTRL_CHANNEL_IN_USE;
-   writew(chanctrl, ioat_chan->reg_base + IOAT_CHANCTRL_OFFSET);
 }
 
 static struct dma_async_tx_descriptor *
-
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] remove obsolete shaper code

2007-08-22 Thread David Miller
From: Stephen Hemminger <[EMAIL PROTECTED]>
Date: Wed, 22 Aug 2007 16:58:54 -0700

> This driver is obsolete, and fixing it for adding upcoming changes
> to make hard_header_ops
> is problematic because it changes the underlying device handles.
> 
> The driver has been superseded by iproute2/traffic control for
> a long time. Let's kill it.
> 
> Signed-off-by: Stephen Hemminger <[EMAIL PROTECTED]>

Please do this with a proper feature-removal-schedule.txt entry and
timeframe.
-
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


[RFC] remove obsolete shaper code

2007-08-22 Thread Stephen Hemminger
This driver is obsolete, and fixing it for adding upcoming changes
to make hard_header_ops
is problematic because it changes the underlying device handles.

The driver has been superseded by iproute2/traffic control for
a long time. Let's kill it.

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

--- a/drivers/net/Kconfig   2007-08-22 13:15:51.0 -0700
+++ b/drivers/net/Kconfig   2007-08-22 16:45:11.0 -0700
@@ -2970,23 +2970,6 @@ config NET_FC
  adaptor below. You also should have said Y to "SCSI support" and
  "SCSI generic support".
 
-config SHAPER
-   tristate "Traffic Shaper (OBSOLETE)"
-   depends on EXPERIMENTAL
-   ---help---
- The traffic shaper is a virtual network device that allows you to
- limit the rate of outgoing data flow over some other network device.
- The traffic that you want to slow down can then be routed through
- these virtual devices. See
-  for more information.
-
- An alternative to this traffic shaper are traffic schedulers which
- you'll get if you say Y to "QoS and/or fair queuing" in
- "Networking options".
-
- To compile this driver as a module, choose M here: the module
- will be called shaper.  If unsure, say N.
-
 config NETCONSOLE
tristate "Network console logging support (EXPERIMENTAL)"
depends on EXPERIMENTAL
--- a/drivers/net/shaper.c  2007-08-22 16:32:18.0 -0700
+++ /dev/null   1970-01-01 00:00:00.0 +
@@ -1,650 +0,0 @@
-/*
- * Simple traffic shaper for Linux NET3.
- *
- * (c) Copyright 1996 Alan Cox <[EMAIL PROTECTED]>, All Rights Reserved.
- * http://www.redhat.com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version
- * 2 of the License, or (at your option) any later version.
- *
- * Neither Alan Cox nor CymruNet Ltd. admit liability nor provide
- * warranty for any of this software. This material is provided
- * "AS-IS" and at no charge.
- *
- *
- * Algorithm:
- *
- * Queue Frame:
- * Compute time length of frame at regulated speed
- * Add frame to queue at appropriate point
- * Adjust time length computation for followup frames
- * Any frame that falls outside of its boundaries is freed
- *
- * We work to the following constants
- *
- * SHAPER_QLEN Maximum queued frames
- * SHAPER_LATENCY  Bounding latency on a frame. Leaving this 
latency
- * window drops the frame. This stops us queueing
- * frames for a long time and confusing a remote
- * host.
- * SHAPER_MAXSLIP  Maximum time a priority frame may jump forward.
- * That bounds the penalty we will inflict on low
- * priority traffic.
- * SHAPER_BURSTTime range we call "now" in order to reduce
- * system load. The more we make this the burstier
- * the behaviour, the better local performance you
- * get through packet clustering on routers and the
- * worse the remote end gets to judge rtts.
- *
- * This is designed to handle lower speed links ( < 200K/second or so). We
- * run off a 100-150Hz base clock typically. This gives us a resolution at
- * 200Kbit/second of about 2Kbit or 256 bytes. Above that our timer
- * resolution may start to cause much more burstiness in the traffic. We
- * could avoid a lot of that by calling kick_shaper() at the end of the
- * tied device transmissions. If you run above about 100K second you
- * may need to tune the supposed speed rate for the right values.
- *
- * BUGS:
- * Downing the interface under the shaper before the shaper
- * will render your machine defunct. Don't for now shape over
- * PPP or SLIP therefore!
- * This will be fixed in BETA4
- *
- * Update History :
- *
- *  bh_atomic() SMP races fixes and rewritten the locking code to
- *  be SMP safe and irq-mask friendly.
- *  NOTE: we can't use start_bh_atomic() in kick_shaper()
- *  because it's going to be recalled from an irq handler,
- *  and synchronize_bh() is a nono if called from irq context.
- * 1999  Andrea Arcangeli
- *
- *  Device statistics (tx_pakets, tx_bytes,
- *  tx_drops: queue_over_time and collisions: max_queue_exceded)
- *   1999/06/18 Jordi Murgo <[EMAIL PROTECTED]>
- *
- * Use skb->cb for pri

Re: [RFT] sky2: yukon-ec-u phy power problems

2007-08-22 Thread Kevin E

--- Stephen Hemminger
<[EMAIL PROTECTED]> wrote:

> The sky2 driver clears some bits in the PHY control
> register, that cause
> the PHY interface to get changed.  Some of these
> deal with voltage and power
> savings as well. This may explain some of the
> failures on Gigabyte DS-3 motherboard.
> 
> The clue to possible problem was looking at why
> loading/unloading sky2 would
> break vendor sk98lin driver (ie what registers
> changed).
> 
> 
> --- a/drivers/net/sky2.c  2007-08-21
> 09:53:41.0 -0700
> +++ b/drivers/net/sky2.c  2007-08-21
> 09:53:43.0 -0700
> @@ -696,8 +696,8 @@ static void sky2_mac_init(struct
> sky2_hw
>   int i;
>   const u8 *addr = hw->dev[port]->dev_addr;
>  
> - sky2_write32(hw, SK_REG(port, GPHY_CTRL),
> GPC_RST_SET);
> - sky2_write32(hw, SK_REG(port, GPHY_CTRL),
> GPC_RST_CLR);
> + sky2_write8(hw, SK_REG(port, GPHY_CTRL),
> GPC_RST_SET);
> + sky2_write8(hw, SK_REG(port, GPHY_CTRL),
> GPC_RST_CLR);
>  
>   sky2_write8(hw, SK_REG(port, GMAC_CTRL),
> GMC_RST_CLR);
>  

This appears to have fixed the problem!  I made the
change to the kernel on the broken MB and the link
stayed up.  So I went ahead and made the change to the
kernel on the working one too.   Right now I'm using
netcat to saturate the link and make sure it stays up.
 So far it's looking good, if I have any problems I'll
let you know.

Thanks,
Kevin



   

Building a website is a piece of cake. Yahoo! Small Business gives you all the 
tools to get online.
http://smallbusiness.yahoo.com/webhosting 
-
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] Wild and crazy ideas involving struct sk_buff

2007-08-22 Thread James Morris
On Wed, 22 Aug 2007, Paul Moore wrote:

> > Don't forget Rusty's skb reservation patches from 1999...
> 
> I'm guessing those would probably need to be forward ported just a teensy 
> weensy bit ;)

The point being that the idea has been around since last century and has 
never gone anywhere :-)


-- 
James Morris
<[EMAIL PROTECTED]>
-
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] Wild and crazy ideas involving struct sk_buff

2007-08-22 Thread Paul Moore
On Wednesday, August 22 2007 6:09:36 pm James Morris wrote:
> On Wed, 22 Aug 2007, David Miller wrote:
> > From: Paul Moore <[EMAIL PROTECTED]>
> > Date: Wed, 22 Aug 2007 17:26:36 -0400
> >
> > > Was it just a thought, or was there some actual design/code/patchset
> > > to go along with it that described the idea?
> >
> > It was a thought mentioned at the first two netconfs, but it
> > went nowhere because the more we discussed the implementation
> > the more horrific it began to sound :-)
>
> Don't forget Rusty's skb reservation patches from 1999...

I'm guessing those would probably need to be forward ported just a teensy 
weensy bit ;)

-- 
paul moore
linux security @ hp
-
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: eHEA driver issues from net-2.6.24

2007-08-22 Thread Andrew Theurer

David Miller wrote:

From: Andrew Theurer <[EMAIL PROTECTED]>
Date: Wed, 22 Aug 2007 16:55:03 -0500

Thanks for finally getting to test this, I thought nobody
would test this until it got merged into 2.6.24 :-/

  

kernel BUG at include/linux/netdevice.h:318!
enter ? for help
[cf613e40] c03fe394 .net_rx_action+0x1b8/0x254
[cf613ef0] c0057b70 .__do_softirq+0xa8/0x164
[cf613f90] c0024438 .call_do_softirq+0x14/0x24
[c00b8ffbf9f0] c000bd30 .do_softirq+0x68/0xac
[c00b8ffbfa80] c0057cc4 .irq_exit+0x54/0x6c
[c00b8ffbfb00] c000c358 .do_IRQ+0x170/0x1ac
[c00b8ffbfb90] c0004780 hardware_interrupt_entry+0x18/0x98
--- Exception: 501 (Hardware Interrupt) at c0010bdc 
.cpu_idle+0x114/0x1e0

[c00b8ffbfe80] c0010bd0 .cpu_idle+0x108/0x1e0 (unreliable)
[c00b8ffbff00] c0026db0 .start_secondary+0x160/0x184
[c00b8ffbff90] c0008364 .start_secondary_prolog+0xc/0x10

I'm a little confused if the port_napi_enable() is being called when the 
device is initialized, but then again, this is all new to me (should it 
be called in ehea_open?).  I see it called on some reset routines, but 
not on the first initialization.



This is similar to the problem that Arnaldo hit a few minutes
ago in the VIA Rhine driver.

You can't only make a napi_enable() call when there has been
a previous napi_disable().

One way to fix this would be to forcefully napi_disable() on
all the per-port NAPI structs at the beginning of ehea_open(),
which should set things up to satisfy the pre-condition of the
napi_enable() calls.
  
OK, Ill try this. 

You'll need to audit the entire driver to make sure this invariant
is held properly.

  

Also, on this code, in ehea_sense_port_attr()

/* Number of default QPs */
if (use_mcs)
port->num_def_qps = cb0->num_default_qps;
else
port->num_def_qps = 1;
   

When using napi, since we have multi-queue napi support now, wouldn't we 
want to use all the default qps instead of 1?



I don't know how this hardware works, you tell me :-)
  

Heh, I don't know it well, either. Maybe Jan Bernd can chime in.

Thanks for your help,

-Andrew

-
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][VIA-RHINE]: Fix CONFIG_VIA_RHINE_NAPI usage

2007-08-22 Thread Arnaldo Carvalho de Melo
Em Wed, Aug 22, 2007 at 02:58:55PM -0700, David Miller escreveu:
> From: Arnaldo Carvalho de Melo <[EMAIL PROTECTED]>
> Date: Wed, 22 Aug 2007 18:46:59 -0300
> 
> > Hi David,
> > 
> > napi is broken here, with this patch at least I can isolate this
> > breakage and boot the machine with a non-napi via-rhine driver.
> > 
> 
> Thanks for finding this problem.
> 
> The core issue seems to be that via-rhine.c tries to perform
> a napi_enable() when there has not been a previous napi_disable().
> 
> So lets make sure that all paths that lead to an init_registers()
> call makes a preceeding napi_disable().
> 
> Please give this patch a try:

Tried with and without CONFIG_VIA_RHINE_NAPI, did stress testing with
netperf only with NAPI enabled. Works great


Signed-off-by: Arnaldo Carvalho de Melo <[EMAIL PROTECTED]>
 
> diff --git a/drivers/net/via-rhine.c b/drivers/net/via-rhine.c
> index 8f4cf82..0e6aefe 100644
> --- a/drivers/net/via-rhine.c
> +++ b/drivers/net/via-rhine.c
> @@ -1167,6 +1167,7 @@ static int rhine_open(struct net_device *dev)
>   free_irq(rp->pdev->irq, dev);
>   return rc;
>   }
> + napi_disable(&rp->napi);
>   alloc_rbufs(dev);
>   alloc_tbufs(dev);
>   rhine_chip_reset(dev);
> @@ -1195,6 +1196,8 @@ static void rhine_tx_timeout(struct net_device *dev)
>   /* protect against concurrent rx interrupts */
>   disable_irq(rp->pdev->irq);
>  
> + napi_disable(&rp->napi);
> +
>   spin_lock(&rp->lock);
>  
>   /* clear all descriptors */
> @@ -1935,6 +1938,7 @@ static int rhine_suspend(struct pci_dev *pdev, 
> pm_message_t state)
>   if (!netif_running(dev))
>   return 0;
>  
> + napi_disable(&rp->napi);
>   netif_device_detach(dev);
>   pci_save_state(pdev);
>  
> -
> 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
-
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] Wild and crazy ideas involving struct sk_buff

2007-08-22 Thread James Morris
On Wed, 22 Aug 2007, David Miller wrote:

> From: Paul Moore <[EMAIL PROTECTED]>
> Date: Wed, 22 Aug 2007 17:26:36 -0400
> 
> > Was it just a thought, or was there some actual design/code/patchset
> > to go along with it that described the idea?
> 
> It was a thought mentioned at the first two netconfs, but it
> went nowhere because the more we discussed the implementation
> the more horrific it began to sound :-)

Don't forget Rusty's skb reservation patches from 1999...


-- 
James Morris
<[EMAIL PROTECTED]>
-
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] Wild and crazy ideas involving struct sk_buff

2007-08-22 Thread Arnaldo Carvalho de Melo
Em Wed, Aug 22, 2007 at 02:36:27PM -0700, David Miller escreveu:
> From: Paul Moore <[EMAIL PROTECTED]>
> Date: Wed, 22 Aug 2007 17:26:36 -0400
> 
> > Was it just a thought, or was there some actual design/code/patchset
> > to go along with it that described the idea?
> 
> It was a thought mentioned at the first two netconfs, but it
> went nowhere because the more we discussed the implementation
> the more horrific it began to sound :-)

Which makes it more interesting to make it work :-)

Anyway, there is space there to be used, in 32 and 64 bits we have two
bytes after queue_mapping (this kernel doesn't have CONFIG_NET_SCHED nor
CONFIG_NET_CLS_ACT enabled, if the first was we wouldn't have the hole,
but if both, as its common in distro kernels, were we would have the 2
bytes hole, as we can see on the pahole output for the 64bits kernel,
that uses the kernel config used in the Red Hat kernels.

Bonus points would go to continue the skb offset fight and reduce the
size of mac_header to two bytes, and then moving it to just after
queue_mapping. Do that and you'll get some credits :-P

- Arnaldo

[EMAIL PROTECTED] net-2.6.24]$ pahole -C sk_buff ../32bits/net/core/skbuff.o
struct sk_buff {
struct sk_buff *   next; /* 0 4 */
struct sk_buff *   prev; /* 4 4 */
struct sock *  sk;   /* 8 4 */
ktime_ttstamp;   /*12 8 */
struct net_device *dev;  /*20 4 */
struct dst_entry * dst;  /*24 4 */
struct sec_path *  sp;   /*28 4 */
char   cb[48];   /*3248 */
/* --- cacheline 1 boundary (64 bytes) was 16 bytes ago --- */
unsigned int   len;  /*80 4 */
unsigned int   data_len; /*84 4 */
__u16  mac_len;  /*88 2 */
__u16  hdr_len;  /*90 2 */
union {
__wsum csum; /*   4 */
struct {
__u16  csum_start;   /*92 2 */
__u16  csum_offset;  /*94 2 */
}/*   4 */
};   /*92 4 */
__u32  priority; /*96 4 */
__u8   local_df:1;   /*   100 1 */
__u8   cloned:1; /*   100 1 */
__u8   ip_summed:2;  /*   100 1 */
__u8   nohdr:1;  /*   100 1 */
__u8   nfctinfo:3;   /*   100 1 */
__u8   pkt_type:3;   /*   101 1 */
__u8   fclone:2; /*   101 1 */
__u8   ipvs_property:1;  /*   101 1 */
__u8   nf_trace:1;   /*   101 1 */

/* XXX 1 bit hole, try to pack */

__be16 protocol; /*   102 2 */
void(*destructor)(struct sk_buff *); /*   104 4 */
intiif;  /*   108 4 */
__u16  queue_mapping;/*   112 2 */

/* XXX 2 bytes hole, try to pack */

__u32  mark; /*   116 4 */
sk_buff_data_t transport_header; /*   120 4 */
sk_buff_data_t network_header;   /*   124 4 */
/* --- cacheline 2 boundary (128 bytes) --- */
sk_buff_data_t mac_header;   /*   128 4 */
sk_buff_data_t tail; /*   132 4 */
sk_buff_data_t end;  /*   136 4 */
unsigned char *head; /*   140 4 */
unsigned char *data; /*   144 4 */
unsigned int   truesize; /*   148 4 */
atomic_t   users;/*   152 4 */

/* size: 156, cachelines: 3 */
/* sum members: 154, holes: 1, sum holes: 2 */
/* bit holes: 1, sum bit holes: 1 bits */
/* last cacheline: 28 bytes */
};

[EMAIL PROTECTED] net-2.6.24]$ pahole -C sk_buff ../64bits/net/core/skbuff.o
struct sk_buff {
struct sk_buff *   next; /* 0 8 */
struct sk_buff *   prev; /* 8 8 */
struct sock *   

Re: eHEA driver issues from net-2.6.24

2007-08-22 Thread David Miller
From: Andrew Theurer <[EMAIL PROTECTED]>
Date: Wed, 22 Aug 2007 16:55:03 -0500

Thanks for finally getting to test this, I thought nobody
would test this until it got merged into 2.6.24 :-/

> kernel BUG at include/linux/netdevice.h:318!
> enter ? for help
> [cf613e40] c03fe394 .net_rx_action+0x1b8/0x254
> [cf613ef0] c0057b70 .__do_softirq+0xa8/0x164
> [cf613f90] c0024438 .call_do_softirq+0x14/0x24
> [c00b8ffbf9f0] c000bd30 .do_softirq+0x68/0xac
> [c00b8ffbfa80] c0057cc4 .irq_exit+0x54/0x6c
> [c00b8ffbfb00] c000c358 .do_IRQ+0x170/0x1ac
> [c00b8ffbfb90] c0004780 hardware_interrupt_entry+0x18/0x98
> --- Exception: 501 (Hardware Interrupt) at c0010bdc 
> .cpu_idle+0x114/0x1e0
> [c00b8ffbfe80] c0010bd0 .cpu_idle+0x108/0x1e0 (unreliable)
> [c00b8ffbff00] c0026db0 .start_secondary+0x160/0x184
> [c00b8ffbff90] c0008364 .start_secondary_prolog+0xc/0x10
>
> I'm a little confused if the port_napi_enable() is being called when the 
> device is initialized, but then again, this is all new to me (should it 
> be called in ehea_open?).  I see it called on some reset routines, but 
> not on the first initialization.

This is similar to the problem that Arnaldo hit a few minutes
ago in the VIA Rhine driver.

You can't only make a napi_enable() call when there has been
a previous napi_disable().

One way to fix this would be to forcefully napi_disable() on
all the per-port NAPI structs at the beginning of ehea_open(),
which should set things up to satisfy the pre-condition of the
napi_enable() calls.

You'll need to audit the entire driver to make sure this invariant
is held properly.

> Also, on this code, in ehea_sense_port_attr()
> 
> /* Number of default QPs */
> if (use_mcs)
> port->num_def_qps = cb0->num_default_qps;
> else
> port->num_def_qps = 1;
>
> 
> When using napi, since we have multi-queue napi support now, wouldn't we 
> want to use all the default qps instead of 1?

I don't know how this hardware works, you tell me :-)
-
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][VIA-RHINE]: Fix CONFIG_VIA_RHINE_NAPI usage

2007-08-22 Thread David Miller
From: Arnaldo Carvalho de Melo <[EMAIL PROTECTED]>
Date: Wed, 22 Aug 2007 18:46:59 -0300

> Hi David,
> 
>   napi is broken here, with this patch at least I can isolate this
> breakage and boot the machine with a non-napi via-rhine driver.
> 
> Signed-off-by: Arnaldo Carvalho de Melo <[EMAIL PROTECTED]>

Thanks for finding this problem.

The core issue seems to be that via-rhine.c tries to perform
a napi_enable() when there has not been a previous napi_disable().

So lets make sure that all paths that lead to an init_registers()
call makes a preceeding napi_disable().

Please give this patch a try:

diff --git a/drivers/net/via-rhine.c b/drivers/net/via-rhine.c
index 8f4cf82..0e6aefe 100644
--- a/drivers/net/via-rhine.c
+++ b/drivers/net/via-rhine.c
@@ -1167,6 +1167,7 @@ static int rhine_open(struct net_device *dev)
free_irq(rp->pdev->irq, dev);
return rc;
}
+   napi_disable(&rp->napi);
alloc_rbufs(dev);
alloc_tbufs(dev);
rhine_chip_reset(dev);
@@ -1195,6 +1196,8 @@ static void rhine_tx_timeout(struct net_device *dev)
/* protect against concurrent rx interrupts */
disable_irq(rp->pdev->irq);
 
+   napi_disable(&rp->napi);
+
spin_lock(&rp->lock);
 
/* clear all descriptors */
@@ -1935,6 +1938,7 @@ static int rhine_suspend(struct pci_dev *pdev, 
pm_message_t state)
if (!netif_running(dev))
return 0;
 
+   napi_disable(&rp->napi);
netif_device_detach(dev);
pci_save_state(pdev);
 
-
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


eHEA driver issues from net-2.6.24

2007-08-22 Thread Andrew Theurer

In testing the new NAPI improvements on ehea, I get the following:

kernel BUG at include/linux/netdevice.h:318!
cpu 0x1: Vector: 700 (Program Check) at [cf613ac0]
   pc: d0091054: .ehea_poll+0x1e8/0x1334 [ehea]
   lr: c03fe394: .net_rx_action+0x1b8/0x254
   sp: cf613d40
  msr: 80029032
 current = 0xc005aff9e8b0
 paca= 0xc06e1300
   pid   = 0, comm = swapper
kernel BUG at include/linux/netdevice.h:318!
enter ? for help
[cf613e40] c03fe394 .net_rx_action+0x1b8/0x254
[cf613ef0] c0057b70 .__do_softirq+0xa8/0x164
[cf613f90] c0024438 .call_do_softirq+0x14/0x24
[c00b8ffbf9f0] c000bd30 .do_softirq+0x68/0xac
[c00b8ffbfa80] c0057cc4 .irq_exit+0x54/0x6c
[c00b8ffbfb00] c000c358 .do_IRQ+0x170/0x1ac
[c00b8ffbfb90] c0004780 hardware_interrupt_entry+0x18/0x98
--- Exception: 501 (Hardware Interrupt) at c0010bdc 
.cpu_idle+0x114/0x1e0

[c00b8ffbfe80] c0010bd0 .cpu_idle+0x108/0x1e0 (unreliable)
[c00b8ffbff00] c0026db0 .start_secondary+0x160/0x184
[c00b8ffbff90] c0008364 .start_secondary_prolog+0xc/0x10


I'm a little confused if the port_napi_enable() is being called when the 
device is initialized, but then again, this is all new to me (should it 
be called in ehea_open?).  I see it called on some reset routines, but 
not on the first initialization.



Also, on this code, in ehea_sense_port_attr()

/* Number of default QPs */
   if (use_mcs)
   port->num_def_qps = cb0->num_default_qps;
   else
   port->num_def_qps = 1;
  

When using napi, since we have multi-queue napi support now, wouldn't we 
want to use all the default qps instead of 1?


Thanks,

-Andrew





-
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][VIA-RHINE]: Fix CONFIG_VIA_RHINE_NAPI usage

2007-08-22 Thread Arnaldo Carvalho de Melo
Hi David,

napi is broken here, with this patch at least I can isolate this
breakage and boot the machine with a non-napi via-rhine driver.

Signed-off-by: Arnaldo Carvalho de Melo <[EMAIL PROTECTED]>

diff --git a/drivers/net/via-rhine.c b/drivers/net/via-rhine.c
index 8f4cf82..4cecd06 100644
--- a/drivers/net/via-rhine.c
+++ b/drivers/net/via-rhine.c
@@ -390,7 +390,9 @@ struct rhine_private {
struct pci_dev *pdev;
long pioaddr;
struct net_device *dev;
+#ifdef CONFIG_VIA_RHINE_NAPI
struct napi_struct napi;
+#endif
struct net_device_stats stats;
spinlock_t lock;
 
@@ -1059,9 +1061,9 @@ static void init_registers(struct net_device *dev)
iowrite32(rp->tx_ring_dma, ioaddr + TxRingPtr);
 
rhine_set_rx_mode(dev);
-
+#ifdef CONFIG_VIA_RHINE_NAPI
napi_enable(&rp->napi);
-
+#endif
/* Enable interrupts by setting the interrupt mask. */
iowrite16(IntrRxDone | IntrRxErr | IntrRxEmpty| IntrRxOverflow |
   IntrRxDropped | IntrRxNoBuf | IntrTxAborted |
@@ -1836,8 +1838,9 @@ static int rhine_close(struct net_device *dev)
spin_lock_irq(&rp->lock);
 
netif_stop_queue(dev);
+#ifdef CONFIG_VIA_RHINE_NAPI
napi_disable(&rp->napi);
-
+#endif
if (debug > 1)
printk(KERN_DEBUG "%s: Shutting down ethercard, "
   "status was %4.4x.\n",
-
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 0/24] make atomic_read() behave consistently across all architectures

2007-08-22 Thread Adrian Bunk
On Tue, Aug 21, 2007 at 06:51:16PM -0400, [EMAIL PROTECTED] wrote:
> On Tue, 21 Aug 2007 09:16:43 PDT, "Paul E. McKenney" said:
> 
> > I agree that instant gratification is hard to come by when synching
> > up compiler and kernel versions.  Nonetheless, it should be possible
> > to create APIs that are are conditioned on the compiler version.
> 
> We've tried that, sort of.  See the mess surrounding the whole
> extern/static/inline/__whatever boondogle, which seems to have
> changed semantics in every single gcc release since 2.95 or so.
>...

There is exactly one semantics change in gcc in this area, and that is 
the change of the "extern inline" semantics in gcc 4.3 to the
C99 semantics.

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: [RFC] Wild and crazy ideas involving struct sk_buff

2007-08-22 Thread David Miller
From: Paul Moore <[EMAIL PROTECTED]>
Date: Wed, 22 Aug 2007 17:26:36 -0400

> Was it just a thought, or was there some actual design/code/patchset
> to go along with it that described the idea?

It was a thought mentioned at the first two netconfs, but it
went nowhere because the more we discussed the implementation
the more horrific it began to sound :-)
-
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] Wild and crazy ideas involving struct sk_buff

2007-08-22 Thread Paul Moore
On Wednesday, August 22 2007 5:20:05 pm Thomas Graf wrote:
> * Paul Moore <[EMAIL PROTECTED]> 2007-08-22 16:31
>
> > We're currently talking about several different ideas to solve the
> > problem, including leveraging the sk_buff.secmark field, and one of the
> > ideas was to add an additional field to the sk_buff structure.  Knowing
> > how well that idea would go over (lead balloon is probably an
> > understatement at best) I started looking at what I might be able to
> > remove from the sk_buff struct to make room for a new field (the new
> > field would be a u32).  Looking at the sk_buff structure it appears that
> > the sk_buff.dev and sk_buff.iif fields are a bit redundant and removing
> > the sk_buff.dev field could free 32/64 bits depending on the platform. 
> > Is there any reason (performance?) for keeping the sk_buff.dev field
> > around?  Would the community be open to patches which removed it and
> > transition users over to the sk_buff.iif field?  Finally, assuming the
> > sk_buff.dev field was removed, would the community be open to adding a
> > new LSM/SELinux related u32 field to the sk_buff struct?
>
> This reminds of an idea someone brought up a while ago, it involved
> having a way to attach additional space to an sk_buff for all the
> different marks and other non-essential fields.

Interesting.  Was it just a thought, or was there some actual 
design/code/patchset to go along with it that described the idea?

-- 
paul moore
linux security @ hp
-
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] Wild and crazy ideas involving struct sk_buff

2007-08-22 Thread Paul Moore
On Wednesday, August 22 2007 5:08:05 pm David Miller wrote:
> From: Paul Moore <[EMAIL PROTECTED]>
> Date: Wed, 22 Aug 2007 16:31:34 -0400
>
> > We're currently talking about several different ideas to solve the
> > problem, including leveraging the sk_buff.secmark field, and one of the
> > ideas was to add an additional field to the sk_buff structure.  Knowing
> > how well that idea would go over (lead balloon is probably an
> > understatement at best) I started looking at what I might be able to
> > remove from the sk_buff struct to make room for a new field (the new
> > field would be a u32).  Looking at the sk_buff structure it appears that
> > the sk_buff.dev and sk_buff.iif fields are a bit redundant and removing
> > the sk_buff.dev field could free 32/64 bits depending on the platform. 
> > Is there any reason (performance?) for keeping the sk_buff.dev field
> > around?  Would the community be open to patches which removed it and
> > transition users over to the sk_buff.iif field?  Finally, assuming the
> > sk_buff.dev field was removed, would the community be open to adding a
> > new LSM/SELinux related u32 field to the sk_buff struct?
>
> It's there for performance, and I bet there might be some semantic
> issues involved.

Okay, thought that was probably the case considering the efforts to shrink the 
sk_buff as much as possible.

> And ironically James Morris still owes me a struct sk_buff removal
> from when I let him put the "secmark" thing in there!
>
> Stop spending money you guys haven't earned yet :-)

Hey, I was just asking how much it cost ... but then again, you know the old 
adage, "if you have to ask, you can't afford it" ;)

Thanks.

-- 
paul moore
linux security @ hp
-
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] Wild and crazy ideas involving struct sk_buff

2007-08-22 Thread Thomas Graf
* Paul Moore <[EMAIL PROTECTED]> 2007-08-22 16:31
> We're currently talking about several different ideas to solve the problem, 
> including leveraging the sk_buff.secmark field, and one of the ideas was to 
> add an additional field to the sk_buff structure.  Knowing how well that idea 
> would go over (lead balloon is probably an understatement at best) I started 
> looking at what I might be able to remove from the sk_buff struct to make 
> room for a new field (the new field would be a u32).  Looking at the sk_buff 
> structure it appears that the sk_buff.dev and sk_buff.iif fields are a bit 
> redundant and removing the sk_buff.dev field could free 32/64 bits depending 
> on the platform.  Is there any reason (performance?) for keeping the 
> sk_buff.dev field around?  Would the community be open to patches which 
> removed it and transition users over to the sk_buff.iif field?  Finally, 
> assuming the sk_buff.dev field was removed, would the community be open to 
> adding a new LSM/SELinux related u32 field to the sk_buff struct?

This reminds of an idea someone brought up a while ago, it involved
having a way to attach additional space to an sk_buff for all the
different marks and other non-essential fields.

I think skb->dev is required because we need to have a reference on the
device while a packet being processing is put on a queue somewhere.
-
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/7] fs_enet: mac-fcc: Eliminate __fcc-* macros.

2007-08-22 Thread Scott Wood

Vitaly Bordug wrote:

-#define W8(_p, _m, _v) __fcc_out8(&(_p)->_m, (_v))
-#define R8(_p, _m) __fcc_in8(&(_p)->_m)
+#define W8(_p, _m, _v) out_8(&(_p)->_m, (_v))
+#define R8(_p, _m) in_8(&(_p)->_m)
#define S8(_p, _m, _v)  W8(_p, _m, R8(_p, _m) | (_v))
#define C8(_p, _m, _v)  W8(_p, _m, R8(_p, _m) & ~(_v))

@@ -290,7 +281,7 @@ static void restart(struct net_device *dev)

/* clear everything (slow & steady does it) */
for (i = 0; i < sizeof(*ep); i++)
-   __fcc_out8((char *)ep + i, 0);
+   out_8((char *)ep + i, 0);



Perhaps W8() here, to keep consistency?


W8 expects a struct pointer and member, which we don't have here.

-Scott
-
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 6/7 v2] fs_enet: Be an of_platform device when CONFIG_PPC_CPM_NEW_BINDING is set.

2007-08-22 Thread Scott Wood

Vitaly Bordug wrote:

yes, wrong snippet what about



#ifdef CONFIG_CPM2 +r = fs_enet_mdio_bb_init(); +   if (r != 0) +
goto out_mdio_bb; +#endif +#ifdef CONFIG_8xx +  r =
fs_enet_mdio_fec_init(); +	if (r != 0) +		goto out_mdio_fec; 
+#endif



We had to pray and hope that 8xx would only have fec, and cpm2 has
some bitbanged stuff. now we can inquire dts and know for sure, at
least it seems so.


Yeah, that sucks.  We should add kconfig options for each mii type, and
let them have their own init functions.

That only affects the initcalls (and kernel size), though; it still uses 
the phy-handle to decide what mdio controller to actually talk to.



How is that different from the old code, where you're hosed without
 fep->fpi->bus_id?




I wasn't defending old code, and consider "old code is POS, new one
is just great" game meaningless. I am just stating the problem, that
we'll have to address later. On 8xx even reference boards may be 
without phy at all.


OK -- would it suffice to just never call any phylib functions and
always assume the link is up if the phy-handle property is undefined?


ok, agreed, size is most serious judge here. we'll definitely have to
revisit pin problem later too (because custom designs sometimes
switch contradictory devices on-the-fly, disable soc parts for
alternative function, etc.)


If it's really on-the-fly (and not jumpered/once-per-boot), then board 
code should expose some kind of API to switch the functions, acting like 
a hotplug bus.  Associating it with open/close of the device won't work 
if one of the devices is something like USB which needs to start working 
without any internal open()-like action.


-Scott
-
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


net-2.6.24 rebased

2007-08-22 Thread David Miller

I needed to pull out the xfrm auditing patch, and I had been
meaning to combine the NAPI struct patch with all the little
bug fixes we've accumulated.

Also, as mentioned here throughout the day, I've also added
Thomas Graf's xfrm_user cleanups and Stephen Hemminger's
netdevice docbook additions.

Enjoy.
-
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/7] fs_enet: mac-fcc: Eliminate __fcc-* macros.

2007-08-22 Thread Vitaly Bordug
On Fri, 17 Aug 2007 12:54:02 -0500
Scott Wood wrote:

> These macros accomplish nothing other than defeating type checking.
> 
> This patch also fixes one instance of the wrong register size being
> used that was revealed by enabling type checking.
> 
> Signed-off-by: Scott Wood <[EMAIL PROTECTED]>
> ---
>  drivers/net/fs_enet/mac-fcc.c |   25 -
>  1 files changed, 8 insertions(+), 17 deletions(-)
> 
> diff --git a/drivers/net/fs_enet/mac-fcc.c
> b/drivers/net/fs_enet/mac-fcc.c index ad3c5fa..8b30361 100644
> --- a/drivers/net/fs_enet/mac-fcc.c
> +++ b/drivers/net/fs_enet/mac-fcc.c
> @@ -48,28 +48,19 @@
>  
>  /* FCC access macros */
>  
> -#define __fcc_out32(addr, x) out_be32((unsigned *)addr, x)
> -#define __fcc_out16(addr, x) out_be16((unsigned short *)addr,
> x) -#define __fcc_out8(addr, x)   out_8((unsigned char *)addr, x)
> -#define __fcc_in32(addr) in_be32((unsigned *)addr)
> -#define __fcc_in16(addr) in_be16((unsigned short *)addr)
> -#define __fcc_in8(addr)  in_8((unsigned char *)addr)
> -
> -/* parameter space */
> -
>  /* write, read, set bits, clear bits */
> -#define W32(_p, _m, _v)  __fcc_out32(&(_p)->_m, (_v))
> -#define R32(_p, _m)  __fcc_in32(&(_p)->_m)
> +#define W32(_p, _m, _v)  out_be32(&(_p)->_m, (_v))
> +#define R32(_p, _m)  in_be32(&(_p)->_m)
>  #define S32(_p, _m, _v)  W32(_p, _m, R32(_p, _m) | (_v))
>  #define C32(_p, _m, _v)  W32(_p, _m, R32(_p, _m) & ~(_v))
>  
> -#define W16(_p, _m, _v)  __fcc_out16(&(_p)->_m, (_v))
> -#define R16(_p, _m)  __fcc_in16(&(_p)->_m)
> +#define W16(_p, _m, _v)  out_be16(&(_p)->_m, (_v))
> +#define R16(_p, _m)  in_be16(&(_p)->_m)
>  #define S16(_p, _m, _v)  W16(_p, _m, R16(_p, _m) | (_v))
>  #define C16(_p, _m, _v)  W16(_p, _m, R16(_p, _m) & ~(_v))
>  
> -#define W8(_p, _m, _v)   __fcc_out8(&(_p)->_m, (_v))
> -#define R8(_p, _m)   __fcc_in8(&(_p)->_m)
> +#define W8(_p, _m, _v)   out_8(&(_p)->_m, (_v))
> +#define R8(_p, _m)   in_8(&(_p)->_m)
>  #define S8(_p, _m, _v)   W8(_p, _m, R8(_p, _m) | (_v))
>  #define C8(_p, _m, _v)   W8(_p, _m, R8(_p, _m) & ~(_v))
>  
> @@ -290,7 +281,7 @@ static void restart(struct net_device *dev)
>  
>   /* clear everything (slow & steady does it) */
>   for (i = 0; i < sizeof(*ep); i++)
> - __fcc_out8((char *)ep + i, 0);
> + out_8((char *)ep + i, 0);
>  
Perhaps W8() here, to keep consistency?


>   /* get physical address */
>   rx_bd_base_phys = fep->ring_mem_addr;
> @@ -495,7 +486,7 @@ static void tx_kickstart(struct net_device *dev)
>   struct fs_enet_private *fep = netdev_priv(dev);
>   fcc_t *fccp = fep->fcc.fccp;
>  
> - S32(fccp, fcc_ftodr, 0x80);
> + S16(fccp, fcc_ftodr, 0x8000);
>  }
>  
>  static u32 get_int_events(struct net_device *dev)


-- 
Sincerely, Vitaly
-
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] Wild and crazy ideas involving struct sk_buff

2007-08-22 Thread David Miller
From: Paul Moore <[EMAIL PROTECTED]>
Date: Wed, 22 Aug 2007 16:31:34 -0400

> We're currently talking about several different ideas to solve the problem, 
> including leveraging the sk_buff.secmark field, and one of the ideas was to 
> add an additional field to the sk_buff structure.  Knowing how well that idea 
> would go over (lead balloon is probably an understatement at best) I started 
> looking at what I might be able to remove from the sk_buff struct to make 
> room for a new field (the new field would be a u32).  Looking at the sk_buff 
> structure it appears that the sk_buff.dev and sk_buff.iif fields are a bit 
> redundant and removing the sk_buff.dev field could free 32/64 bits depending 
> on the platform.  Is there any reason (performance?) for keeping the 
> sk_buff.dev field around?  Would the community be open to patches which 
> removed it and transition users over to the sk_buff.iif field?  Finally, 
> assuming the sk_buff.dev field was removed, would the community be open to 
> adding a new LSM/SELinux related u32 field to the sk_buff struct?

It's there for performance, and I bet there might be some semantic
issues involved.

And ironically James Morris still owes me a struct sk_buff removal
from when I let him put the "secmark" thing in there!

Stop spending money you guys haven't earned yet :-)
-
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 2/7] fs_enet: Whitespace cleanup.

2007-08-22 Thread Vitaly Bordug
On Fri, 17 Aug 2007 12:53:59 -0500
Scott Wood wrote:

> Signed-off-by: Scott Wood <[EMAIL PROTECTED]>

Acked-by: Vitaly Bordug <[EMAIL PROTECTED]>


> ---
>  drivers/net/fs_enet/fs_enet-main.c |   85
> ---
> drivers/net/fs_enet/fs_enet.h  |4 +-
> drivers/net/fs_enet/mac-fcc.c  |1 -
> drivers/net/fs_enet/mii-fec.c  |1 - 4 files changed, 41
> insertions(+), 50 deletions(-)
> 
> diff --git a/drivers/net/fs_enet/fs_enet-main.c
> b/drivers/net/fs_enet/fs_enet-main.c index a4a2a0e..f261b90 100644
> --- a/drivers/net/fs_enet/fs_enet-main.c
> +++ b/drivers/net/fs_enet/fs_enet-main.c
> @@ -353,7 +353,6 @@ static void fs_enet_tx(struct net_device *dev)
>  
>   do_wake = do_restart = 0;
>   while (((sc = CBDR_SC(bdp)) & BD_ENET_TX_READY) == 0) {
> -
>   dirtyidx = bdp - fep->tx_bd_base;
>  
>   if (fep->tx_free == fep->tx_ring)
> @@ -454,7 +453,6 @@ fs_enet_interrupt(int irq, void *dev_id)
>  
>   nr = 0;
>   while ((int_events = (*fep->ops->get_int_events)(dev)) != 0)
> { -
>   nr++;
>  
>   int_clr_events = int_events;
> @@ -710,45 +708,43 @@ static void fs_timeout(struct net_device *dev)
>   
> *-*/
>  static void generic_adjust_link(struct  net_device *dev)
>  {
> -   struct fs_enet_private *fep = netdev_priv(dev);
> -   struct phy_device *phydev = fep->phydev;
> -   int new_state = 0;
> -
> -   if (phydev->link) {
> -
> -   /* adjust to duplex mode */
> -   if (phydev->duplex != fep->oldduplex){
> -   new_state = 1;
> -   fep->oldduplex = phydev->duplex;
> -   }
> -
> -   if (phydev->speed != fep->oldspeed) {
> -   new_state = 1;
> -   fep->oldspeed = phydev->speed;
> -   }
> -
> -   if (!fep->oldlink) {
> -   new_state = 1;
> -   fep->oldlink = 1;
> -   netif_schedule(dev);
> -   netif_carrier_on(dev);
> -   netif_start_queue(dev);
> -   }
> -
> -   if (new_state)
> -   fep->ops->restart(dev);
> -
> -   } else if (fep->oldlink) {
> -   new_state = 1;
> -   fep->oldlink = 0;
> -   fep->oldspeed = 0;
> -   fep->oldduplex = -1;
> -   netif_carrier_off(dev);
> -   netif_stop_queue(dev);
> -   }
> -
> -   if (new_state && netif_msg_link(fep))
> -   phy_print_status(phydev);
> + struct fs_enet_private *fep = netdev_priv(dev);
> + struct phy_device *phydev = fep->phydev;
> + int new_state = 0;
> +
> + if (phydev->link) {
> + /* adjust to duplex mode */
> + if (phydev->duplex != fep->oldduplex) {
> + new_state = 1;
> + fep->oldduplex = phydev->duplex;
> + }
> +
> + if (phydev->speed != fep->oldspeed) {
> + new_state = 1;
> + fep->oldspeed = phydev->speed;
> + }
> +
> + if (!fep->oldlink) {
> + new_state = 1;
> + fep->oldlink = 1;
> + netif_schedule(dev);
> + netif_carrier_on(dev);
> + netif_start_queue(dev);
> + }
> +
> + if (new_state)
> + fep->ops->restart(dev);
> + } else if (fep->oldlink) {
> + new_state = 1;
> + fep->oldlink = 0;
> + fep->oldspeed = 0;
> + fep->oldduplex = -1;
> + netif_carrier_off(dev);
> + netif_stop_queue(dev);
> + }
> +
> + if (new_state && netif_msg_link(fep))
> + phy_print_status(phydev);
>  }
>  
>  
> @@ -792,7 +788,6 @@ static int fs_init_phy(struct net_device *dev)
>   return 0;
>  }
>  
> -
>  static int fs_enet_open(struct net_device *dev)
>  {
>   struct fs_enet_private *fep = netdev_priv(dev);
> @@ -978,7 +973,7 @@ static struct net_device *fs_init_instance(struct
> device *dev, #endif
>  
>  #ifdef CONFIG_FS_ENET_HAS_SCC
> - if (fs_get_scc_index(fpi->fs_no) >=0 )
> + if (fs_get_scc_index(fpi->fs_no) >= 0)
>   fep->ops = &fs_scc_ops;
>  #endif
>  
> @@ -1069,9 +1064,8 @@ static struct net_device
> *fs_init_instance(struct device *dev, 
>   return ndev;
>  
> -  err:
> +err:
>   if (ndev != NULL) {
> -
>   if (registered)
>   unregister_netdev(ndev);
>  
> @@ -1262,7 +1256,6 @@ static int __init fs_init(void)
>  err:
>   cleanup_immap();
>   return r;
> - 
>  }
>  
>  static void __exit fs_cleanup(void)
> diff --git a/drivers/net/fs_enet/fs_enet.h
> b/drivers/net/fs_enet/fs_enet.h index 569be22..72a61e9 100644

Re: [PATCH 16/16] [XFRM] netlink: Inline attach_encap_tmpl(), attach_sec_ctx(), and attach_one_addr()

2007-08-22 Thread David Miller
From: Thomas Graf <[EMAIL PROTECTED]>
Date: Wed, 22 Aug 2007 16:55:54 +0200

> These functions are only used once and are a lot easier to understand if
> inlined directly into the function.
> 
> Signed-off-by: Thomas Graf <[EMAIL PROTECTED]>

Also applied.

Thanks for doing all of this work Thomas! :)
-
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 13/16] [XFRM] netlink: Use nlattr instead of rtattr

2007-08-22 Thread David Miller
From: Thomas Graf <[EMAIL PROTECTED]>
Date: Wed, 22 Aug 2007 16:55:51 +0200

> Signed-off-by: Thomas Graf <[EMAIL PROTECTED]>

Applied.
-
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 14/16] [XFRM] netlink: Use nla_memcpy() in xfrm_update_ae_params()

2007-08-22 Thread David Miller
From: Thomas Graf <[EMAIL PROTECTED]>
Date: Wed, 22 Aug 2007 16:55:52 +0200

> Signed-off-by: Thomas Graf <[EMAIL PROTECTED]>

Applied.
-
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 15/16] [XFRM] netlink: Remove dependency on rtnetlink

2007-08-22 Thread David Miller
From: Thomas Graf <[EMAIL PROTECTED]>
Date: Wed, 22 Aug 2007 16:55:53 +0200

> Signed-off-by: Thomas Graf <[EMAIL PROTECTED]>

Applied.
-
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 12/16] [XFRM] netlink: Rename attribyte array from xfrma[] to attrs[]

2007-08-22 Thread David Miller
From: Thomas Graf <[EMAIL PROTECTED]>
Date: Wed, 22 Aug 2007 16:55:50 +0200

> Increases readability a lot.
> 
> Signed-off-by: Thomas Graf <[EMAIL PROTECTED]>

Applied.

I named it like this to mean "XFRM Attributes" :-)
-
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 6/7 v2] fs_enet: Be an of_platform device when CONFIG_PPC_CPM_NEW_BINDING is set.

2007-08-22 Thread Vitaly Bordug
On Tue, 21 Aug 2007 11:47:41 -0500
Scott Wood <[EMAIL PROTECTED]> wrote:

> Vitaly Bordug wrote:
> > On Fri, 17 Aug 2007 13:17:18 -0500
> > Scott Wood wrote:
> > 
> > 
> >>The existing OF glue code was crufty and broken.  Rather than fix
> >>it, it will be removed, and the ethernet driver now talks to the
> >>device tree directly.
> >>
> > 
> > A bit short description, I'd rather expect some specific
> > improvements list, that are now up and running using device tree.
> > Or if it is just move to new infrastucture, let's state that, too.
> 
> Some of specific binding changes (there are too many to exhaustively 
> list) are enumerated in the "new CPM binding" patch, which I'll send 
> after Kumar's include/asm-ppc patch goes in (since it modifies one of 
> those files).
> 
ok
> >>+#ifdef CONFIG_PPC_CPM_NEW_BINDING
> >>+static int __devinit find_phy(struct device_node *np,
> >>+  struct fs_platform_info *fpi)
> >>+{
> >>+   struct device_node *phynode, *mdionode;
> >>+   struct resource res;
> >>+   int ret = 0, len;
> >>+
> >>+   const u32 *data = of_get_property(np, "phy-handle", &len);
> >>+   if (!data || len != 4)
> >>+   return -EINVAL;
> >>+
> >>+   phynode = of_find_node_by_phandle(*data);
> >>+   if (!phynode)
> >>+   return -EINVAL;
> >>+
> >>+   mdionode = of_get_parent(phynode);
> >>+   if (!phynode)
> >>+   goto out_put_phy;
> >>+
> >>+   ret = of_address_to_resource(mdionode, 0, &res);
> >>+   if (ret)
> >>+   goto out_put_mdio;
> >>+
> >>+   data = of_get_property(phynode, "reg", &len);
> >>+   if (!data || len != 4)
> >>+   goto out_put_mdio;
> >>+
> >>+   snprintf(fpi->bus_id, 16, PHY_ID_FMT, res.start, *data);
> >>+
> >>+out_put_mdio:
> >>+   of_node_put(mdionode);
> >>+out_put_phy:
> >>+   of_node_put(phynode);
> >>+   return ret;
> >>+}
> > 
> > And without phy node? 
> 
> It returns -EINVAL. :-)
> 
> >>+#ifdef CONFIG_FS_ENET_HAS_FEC
> >>+#define IS_FEC(match) ((match)->data == &fs_fec_ops)
> >>+#else
> >>+#define IS_FEC(match) 0
> >>+#endif
> >>+
> > 
> > Since we're talking directly with device tree, why bother with
> > CONFIG_ stuff? We are able to figure it out from dts..
> 
> We are figuring it out from the DTS (that's what match->data is).  I 
> just didn't want boards without a FEC to have to build in support for
> it and waste memory.

yes, wrong snippet
what about 

> #ifdef CONFIG_CPM2
> + r = fs_enet_mdio_bb_init();
> + if (r != 0)
> + goto out_mdio_bb;
> +#endif
> +#ifdef CONFIG_8xx
> + r = fs_enet_mdio_fec_init();
> + if (r != 0)
> + goto out_mdio_fec;
> +#endif

We had to pray and hope that 8xx would only have fec, and cpm2 has some 
bitbanged stuff. now we can inquire dts and know for sure, at least it seems so.



> 
> >>+   fpi->rx_ring = 32;
> >>+   fpi->tx_ring = 32;
> >>+   fpi->rx_copybreak = 240;
> >>+   fpi->use_napi = 0;
> >>+   fpi->napi_weight = 17;
> >>+
> > 
> > 
> > move params over to  dts?
> 
> No.  These aren't attributes of the hardware, they're choices the
> driver makes about how much memory to use and how to interact with
> the rest of the kernel.
> 
> >>+   ret = find_phy(ofdev->node, fpi);
> >>+   if (ret)
> >>+   goto out_free_fpi;
> >>+
> > 
> > so we're hosed without phy node.
> 
> How is that different from the old code, where you're hosed without 
> fep->fpi->bus_id?
> 

I wasn't defending old code, and consider "old code is POS, new one is just 
great" game meaningless.
I am just stating the problem, that we'll have to address later. On 8xx even 
reference boards may be 
without phy at all.

> >>+static struct of_device_id fs_enet_match[] = {
> >>+#ifdef CONFIG_FS_ENET_HAS_SCC
> > 
> > 
> > same nagging. Are we able to get rid of Kconfig arcane defining
> > which SoC currently plays the game for fs_enet?
> 
> No, it's still needed for mpc885ads to determine pin setup and 
> conflicting device tree node removal (though that could go away if
> the device tree is changed to reflect the jumper settings).
> 
> It's also useful for excluding unwanted code.  I don't like using 
> 8xx/CPM2 as the decision point for that -- why should I build in 
> mac-scc.c if I have no intention of using an SCC ethernet (either 
> because my board doesn't have one, or because it's slow and conflicts 
> with other devices)?

ok, agreed, size is most serious judge here. we'll definitely have to revisit 
pin problem later too
(because custom designs sometimes switch contradictory devices on-the-fly, 
disable soc parts for alternative function, etc.) QE-like pin encoding may be 
an option for this or not- I'm inclined to look at
most resource-safe approach.

> 
> -Scott

-- 
Sincerely, Vitaly
-
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 10/16] [XFRM] netlink: Establish an attribute policy

2007-08-22 Thread David Miller
From: Thomas Graf <[EMAIL PROTECTED]>
Date: Wed, 22 Aug 2007 16:55:48 +0200

> Adds a policy defining the minimal payload lengths for all the attributes
> allowing for most attribute validation checks to be removed from in
> the middle of the code path. Makes updates more consistent as many format
> errors are recognised earlier, before any changes have been attempted.
> 
> Signed-off-by: Thomas Graf <[EMAIL PROTECTED]>

Applied.
-
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 11/16] [XFRM] netlink: Enhance indexing of the attribute array

2007-08-22 Thread David Miller
From: Thomas Graf <[EMAIL PROTECTED]>
Date: Wed, 22 Aug 2007 16:55:49 +0200

> nlmsg_parse() puts attributes at array[type] so the indexing
> method can be simpilfied by removing the obscuring "- 1".
> 
> Signed-off-by: Thomas Graf <[EMAIL PROTECTED]>

Applied.
-
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 08/16] [XFRM] netlink: Use nlmsg_new() and type-safe size calculation helpers

2007-08-22 Thread David Miller
From: Thomas Graf <[EMAIL PROTECTED]>
Date: Wed, 22 Aug 2007 16:55:46 +0200

> Moves all complex message size calculation into own inlined helper
> functions and makes use of the type-safe netlink interface.
> 
> Using nlmsg_new() simplifies the calculation itself as it takes care
> of the netlink header length by itself.
> 
> Signed-off-by: Thomas Graf <[EMAIL PROTECTED]>

Applied.
-
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 09/16] [XFRM] netlink: Use nlmsg_parse() to parse attributes

2007-08-22 Thread David Miller
From: Thomas Graf <[EMAIL PROTECTED]>
Date: Wed, 22 Aug 2007 16:55:47 +0200

> Uses nlmsg_parse() to parse the attributes. This actually changes
> behaviour as unknown attributes (type > MAXTYPE) no longer cause
> an error. Instead unknown attributes will be ignored henceforth
> to keep older kernels compatible with more recent userspace tools.
> 
> Signed-off-by: Thomas Graf <[EMAIL PROTECTED]>

Applied.
-
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 07/16] [XFRM] netlink: Clear up some of the CONFIG_XFRM_SUB_POLICY ifdef mess

2007-08-22 Thread David Miller
From: Thomas Graf <[EMAIL PROTECTED]>
Date: Wed, 22 Aug 2007 16:55:45 +0200

> Moves all of the SUB_POLICY ifdefs related to the attribute size
> calculation into a function.
> 
> Signed-off-by: Thomas Graf <[EMAIL PROTECTED]>

Applied.
-
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 06/16] [XFRM] netlink: Move algorithm length calculation to its own function

2007-08-22 Thread David Miller
From: Thomas Graf <[EMAIL PROTECTED]>
Date: Wed, 22 Aug 2007 16:55:44 +0200

> Adds alg_len() to calculate the properly padded length of an
> algorithm attribute to simplify the code.
> 
> Signed-off-by: Thomas Graf <[EMAIL PROTECTED]>

Applied.
-
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 04/16] [XFRM] netlink: Use nlmsg_broadcast() and nlmsg_unicast()

2007-08-22 Thread David Miller
From: Thomas Graf <[EMAIL PROTECTED]>
Date: Wed, 22 Aug 2007 16:55:42 +0200

> This simplifies successful return codes from >0 to 0.
> 
> Signed-off-by: Thomas Graf <[EMAIL PROTECTED]>

Applied, thanks.
-
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 05/16] [XFRM] netlink: Use nla_put()/NLA_PUT() variantes

2007-08-22 Thread David Miller
From: Thomas Graf <[EMAIL PROTECTED]>
Date: Wed, 22 Aug 2007 16:55:43 +0200

> Also makes use of copy_sec_ctx() in another place and removes
> duplicated code.
> 
> Signed-off-by: Thomas Graf <[EMAIL PROTECTED]>

Applied.
-
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


[RFC] Wild and crazy ideas involving struct sk_buff

2007-08-22 Thread Paul Moore
Over in LSM/SELinux land there has been a lot of talk recently about how to 
deal with loopback and forwarded traffic, specifically, how to preserve the 
sender's security label on those two types of traffic.  Yes, there is the 
existing sk_buff.secmark field but that is already being used for something 
else and utilizing it for this purpose has it's pros/cons.

We're currently talking about several different ideas to solve the problem, 
including leveraging the sk_buff.secmark field, and one of the ideas was to 
add an additional field to the sk_buff structure.  Knowing how well that idea 
would go over (lead balloon is probably an understatement at best) I started 
looking at what I might be able to remove from the sk_buff struct to make 
room for a new field (the new field would be a u32).  Looking at the sk_buff 
structure it appears that the sk_buff.dev and sk_buff.iif fields are a bit 
redundant and removing the sk_buff.dev field could free 32/64 bits depending 
on the platform.  Is there any reason (performance?) for keeping the 
sk_buff.dev field around?  Would the community be open to patches which 
removed it and transition users over to the sk_buff.iif field?  Finally, 
assuming the sk_buff.dev field was removed, would the community be open to 
adding a new LSM/SELinux related u32 field to the sk_buff struct?

Thanks.
 
-- 
paul moore
linux security @ hp
-
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/2] Net: ath5k, remove sysctls

2007-08-22 Thread Jiri Slaby
ath5k, remove sysctls

Syscalls were buggy and defunct in later kernels (due to sysctl check).

Signed-off-by: Jiri Slaby <[EMAIL PROTECTED]>

---
commit 069bfbe93facb3468f579568434d18f1268a487c
tree 87c19ebf2c91d9fb07f1847adcb6098f2235eaaa
parent b01c0e9a02b248c3e2f2923da9728ba2c3961dee
author Jiri Slaby <[EMAIL PROTECTED]> Wed, 22 Aug 2007 22:48:41 +0200
committer Jiri Slaby <[EMAIL PROTECTED]> Wed, 22 Aug 2007 22:48:41 +0200

 drivers/net/wireless/ath5k_base.c |   23 ---
 1 files changed, 8 insertions(+), 15 deletions(-)

diff --git a/drivers/net/wireless/ath5k_base.c 
b/drivers/net/wireless/ath5k_base.c
index 2ce82ed..7f938c4 100644
--- a/drivers/net/wireless/ath5k_base.c
+++ b/drivers/net/wireless/ath5k_base.c
@@ -2440,21 +2440,13 @@ static struct pci_driver ath_pci_drv_id = {
.resume = ath_pci_resume,
 };
 
-/*
- * Static (i.e. global) sysctls.  Note that the hal sysctls
- * are located under ours by sharing the setting for DEV_ATH.
- */
-enum {
-   DEV_ATH = 9,/* XXX known by hal */
-};
-
 static int mincalibrate = 1;
 static int maxcalibrate = INT_MAX / 1000;
 #defineCTL_AUTO-2  /* cannot be CTL_ANY or CTL_NONE */
 
 static ctl_table ath_static_sysctls[] = {
 #if AR_DEBUG
-   { .ctl_name = CTL_AUTO,
+   {
  .procname = "debug",
  .mode = 0644,
  .data = &ath_debug,
@@ -2462,28 +2454,28 @@ static ctl_table ath_static_sysctls[] = {
  .proc_handler = proc_dointvec
},
 #endif
-   { .ctl_name = CTL_AUTO,
+   {
  .procname = "countrycode",
  .mode = 0444,
  .data = &countrycode,
  .maxlen   = sizeof(countrycode),
  .proc_handler = proc_dointvec
},
-   { .ctl_name = CTL_AUTO,
+   {
  .procname = "outdoor",
  .mode = 0444,
  .data = &outdoor,
  .maxlen   = sizeof(outdoor),
  .proc_handler = proc_dointvec
},
-   { .ctl_name = CTL_AUTO,
+   {
  .procname = "xchanmode",
  .mode = 0444,
  .data = &xchanmode,
  .maxlen   = sizeof(xchanmode),
  .proc_handler = proc_dointvec
},
-   { .ctl_name = CTL_AUTO,
+   {
  .procname = "calibrate",
  .mode = 0644,
  .data = &ath_calinterval,
@@ -2495,14 +2487,15 @@ static ctl_table ath_static_sysctls[] = {
{ 0 }
 };
 static ctl_table ath_ath_table[] = {
-   { .ctl_name = DEV_ATH,
+   {
  .procname = "ath",
  .mode = 0555,
  .child= ath_static_sysctls
}, { 0 }
 };
 static ctl_table ath_root_table[] = {
-   { .ctl_name = CTL_DEV,
+   {
+ .ctl_name = CTL_DEV,
  .procname = "dev",
  .mode = 0555,
  .child= ath_ath_table
-
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/2] Net: ath5k, no printk after STA->IBSS switch

2007-08-22 Thread Jiri Slaby
ath5k, no printk after STA->IBSS switch

If STA->IBSS switch was done, but beacon_update weas not called so far, do
not emit a warning about non-existent skbuf.

Signed-off-by: Jiri Slaby <[EMAIL PROTECTED]>

---
commit b01c0e9a02b248c3e2f2923da9728ba2c3961dee
tree c3e10a57aed39698f20c346679854aa3a9a54639
parent 8c5f91fb39c6208b23306687343cc5fbf830fa17
author Jiri Slaby <[EMAIL PROTECTED]> Wed, 22 Aug 2007 22:47:06 +0200
committer Jiri Slaby <[EMAIL PROTECTED]> Wed, 22 Aug 2007 22:47:06 +0200

 drivers/net/wireless/ath5k_base.c |4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/drivers/net/wireless/ath5k_base.c 
b/drivers/net/wireless/ath5k_base.c
index 847218b..2ce82ed 100644
--- a/drivers/net/wireless/ath5k_base.c
+++ b/drivers/net/wireless/ath5k_base.c
@@ -655,7 +655,9 @@ static void ath_beacon_config(struct ath_softc *sc)
DPRINTF(sc, ATH_DEBUG_BEACON, "%s: intval %u hw tsftu %u\n", __func__,
intval, tsftu);
 
-   if (sc->opmode == IEEE80211_IF_TYPE_STA) {
+   if (sc->opmode == IEEE80211_IF_TYPE_STA ||
+   (sc->opmode == IEEE80211_IF_TYPE_IBSS &&
+   !sc->bbuf->skb)) {
ath5k_hw_set_intr(ah, 0);
sc->imask |= AR5K_INT_BMISS;
sc->bmisscount = 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


Re: [PATCH] netdevice: kernel docbook addition

2007-08-22 Thread Randy Dunlap
On Wed, 22 Aug 2007 12:33:14 -0700 Stephen Hemminger wrote:

> Add more kernel doc's for part of the network device API.
> This is only a start, and needs more work.
> 
> Applies against net-2.6.24

Thanks!

---
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***
-
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 0/9 Rev3] Implement batching skb API and support in IPoIB

2007-08-22 Thread David Miller
From: Rick Jones <[EMAIL PROTECTED]>
Date: Wed, 22 Aug 2007 10:09:37 -0700

> Should it be any more or less worrysome than small packet
> performance (eg the TCP_RR stuff I posted recently) being rather
> worse with TSO enabled than with it disabled?

That, like any such thing shown by the batching changes, is a bug
to fix.
-
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] improved xfrm_audit_log() patch

2007-08-22 Thread David Miller
From: David Miller <[EMAIL PROTECTED]>
Date: Tue, 21 Aug 2007 00:24:05 -0700 (PDT)

> Looks good, applied to net-2.6.24, thanks Joy.

Something is still buggered up in this patch, you can't add this local
"audit_info" variable unconditionally to these functions, and
alternatively you also can't add a bunch of ifdefs to xfrm_user.c to
cover it up either.

  CC [M]  net/xfrm/xfrm_user.o
net/xfrm/xfrm_user.c: In function $,1rx(Bxfrm_add_sa$,1ry(B:
net/xfrm/xfrm_user.c:450: warning: unused variable $,1rx(Baudit_info$,1ry(B
net/xfrm/xfrm_user.c: In function $,1rx(Bxfrm_del_sa$,1ry(B:
net/xfrm/xfrm_user.c:525: warning: unused variable $,1rx(Baudit_info$,1ry(B
net/xfrm/xfrm_user.c: In function $,1rx(Bxfrm_add_policy$,1ry(B:
net/xfrm/xfrm_user.c:1140: warning: unused variable $,1rx(Baudit_info$,1ry(B
net/xfrm/xfrm_user.c: In function $,1rx(Bxfrm_get_policy$,1ry(B:
net/xfrm/xfrm_user.c:1404: warning: unused variable $,1rx(Baudit_info$,1ry(B
net/xfrm/xfrm_user.c: In function $,1rx(Bxfrm_add_pol_expire$,1ry(B:
net/xfrm/xfrm_user.c:1651: warning: unused variable $,1rx(Baudit_info$,1ry(B
net/xfrm/xfrm_user.c: In function $,1rx(Bxfrm_add_sa_expire$,1ry(B:
net/xfrm/xfrm_user.c:1688: warning: unused variable $,1rx(Baudit_info$,1ry(B

So I'm going to revert for now.  Let me know when you have
a fixed version of the patch.

Thanks.
-
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 03/16] [XFRM] netlink: Use nlmsg_data() instead of NLMSG_DATA()

2007-08-22 Thread David Miller
From: Thomas Graf <[EMAIL PROTECTED]>
Date: Wed, 22 Aug 2007 16:55:41 +0200

> Signed-off-by: Thomas Graf <[EMAIL PROTECTED]>

Applied, thanks.
-
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: r8169: slow samba performance

2007-08-22 Thread Bruce Cole

Shane wrote:

On Wed, Aug 22, 2007 at 09:39:47AM -0700, Bruce Cole wrote:
  

Shane, join the crowd :)  Try the fix I just re-posted over here:



Bruce, gigabit speeds thanks for the pointer.  This fix
works well for me though I just added the three or so lines
in the elseif statement as it rejected with the
r8169-20070818.  I suppose I could've merged the whole
thing and if you need that tested, let me know but this is
looking good.
  
Glad it works for you.  I'm not the maintainer, and also don't have 
adequate specs from Realtek to definitively explain why the NPQ bit 
apparently needs to be re-enabled when some but not all of the TX FIFO 
is dequeued.  It is documented as if it isn't cleared until the FIFO is 
empty.  So I assume an official patch will have to wait until Francois 
is back.




-
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 01/16] [XFRM] netlink: Use nlmsg_put() instead of NLMSG_PUT()

2007-08-22 Thread David Miller
From: Thomas Graf <[EMAIL PROTECTED]>
Date: Wed, 22 Aug 2007 16:55:39 +0200

> Signed-off-by: Thomas Graf <[EMAIL PROTECTED]>

Applied.
-
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] xfrm: export sysctl_xfrm_acq_expires

2007-08-22 Thread Neil Horman
Hey all-
I had noticed that an extra sysctl for xfrm had been added while back
(specifically sysctl_xfrm_acq_expires).  Unlike its related sysctl's however,
this was never exported so that out-of-tree modules could access it, and I
thought it would be a good idea if it was.  This patch handles that.

Thanks & Regards
Neil

Signed-off-by: Neil Horman <[EMAIL PROTECTED]>


 xfrm_state.c |1 +
 1 file changed, 1 insertion(+)


diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
index d4356e6..62ae5a2 100644
--- a/net/xfrm/xfrm_state.c
+++ b/net/xfrm/xfrm_state.c
@@ -34,6 +34,7 @@ u32 sysctl_xfrm_aevent_rseqth __read_mostly = 
XFRM_AE_SEQT_SIZE;
 EXPORT_SYMBOL(sysctl_xfrm_aevent_rseqth);
 
 u32 sysctl_xfrm_acq_expires __read_mostly = 30;
+EXPORT_SYMBOL(sysctl_xfrm_acq_expires);
 
 /* Each xfrm_state may be linked to two tables:
 
-- 
/***
 *Neil Horman
 *Software Engineer
 *Red Hat, Inc.
 [EMAIL PROTECTED]
 *gpg keyid: 1024D / 0x92A74FA1
 *http://pgp.mit.edu
 ***/
-
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 02/16] [XFRM] netlink: Use nlmsg_end() and nlmsg_cancel()

2007-08-22 Thread David Miller
From: Thomas Graf <[EMAIL PROTECTED]>
Date: Wed, 22 Aug 2007 16:55:40 +0200

> Signed-off-by: Thomas Graf <[EMAIL PROTECTED]>

Applied.
-
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] netdevice: kernel docbook addition

2007-08-22 Thread David Miller
From: Stephen Hemminger <[EMAIL PROTECTED]>
Date: Wed, 22 Aug 2007 12:33:14 -0700

> Add more kernel doc's for part of the network device API.
> This is only a start, and needs more work.
> 
> Applies against net-2.6.24
> 
> Signed-off-by: Stephen Hemminger <[EMAIL PROTECTED]>

Applied, thanks Stephen.
-
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] xfrm: export sysctl_xfrm_acq_expires

2007-08-22 Thread David Miller
From: Neil Horman <[EMAIL PROTECTED]>
Date: Wed, 22 Aug 2007 15:42:02 -0400

> Hey all-
>   I had noticed that an extra sysctl for xfrm had been added while back
> (specifically sysctl_xfrm_acq_expires).  Unlike its related sysctl's however,
> this was never exported so that out-of-tree modules could access it, and I
> thought it would be a good idea if it was.  This patch handles that.
> 
> Thanks & Regards
> Neil
> 
> Signed-off-by: Neil Horman <[EMAIL PROTECTED]>

There is no reason for out-of-tree code to access it and no
current examples exist.

It is an internal knob controlling how a specific part of the IPSEC
rule lookup operates, and that is all in-tree.

-
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 IPROUTE]: Add flow classifier support

2007-08-22 Thread David Miller
From: Stephen Hemminger <[EMAIL PROTECTED]>
Date: Wed, 22 Aug 2007 10:46:15 -0700

> On Wed, 30 May 2007 11:42:01 +0200
> Patrick McHardy <[EMAIL PROTECTED]> wrote:
> 
> > The iproute patch for the flow classifier.
> > 
> > 
> 
> This patch is on hold since the netlink changes haven't made it upstream yet.

I don't have the kernel side in my queue either, perhaps
I lost it or I didn't see it when it was sent out.

Patrick?
-
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] AH4: Update IPv4 options handling to conform to RFC 4302.

2007-08-22 Thread David Miller
From: Nick Bowler <[EMAIL PROTECTED]>
Date: Wed, 22 Aug 2007 10:22:53 -0400

> In testing our ESP/AH offload hardware, I discovered an issue with how AH
> handles mutable fields in IPv4.  RFC 4302 (AH) states the following on the
> subject:
> 
> For IPv4, the entire option is viewed as a unit; so even
> though the type and length fields within most options are immutable
> in transit, if an option is classified as mutable, the entire option
> is zeroed for ICV computation purposes.
> 
> The current implementation does not zero the type and length fields, resulting
> in authentication failures when communicating with hosts that do (i.e. 
> FreeBSD).
> 
> I have tested record route and timestamp options (ping -R and ping -T) on a
> small network involving Windows XP, FreeBSD 6.2, and Linux hosts, with one
> router.  In the presence of these options, the FreeBSD and Linux hosts (with
> the patch or with the hardware) can communicate.  The Windows XP host simply
> fails to accept these packets with or without the patch.
> 
> I have also been trying to test source routing options (using traceroute -g),
> but haven't had much luck getting this option to work *without* AH, let alone
> with.
> 
> Signed-off-by: Nick Bowler <[EMAIL PROTECTED]>

Patch applied, thanks a lot Nick.
-
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] santize tc_ematch headers

2007-08-22 Thread David Miller
From: Stephen Hemminger <[EMAIL PROTECTED]>
Date: Wed, 22 Aug 2007 10:18:38 -0700

> The headers in tc_ematch are used by iproute2, so these headers
> should be processed.
> 
> Signed-off-by: Stephen Hemminger <[EMAIL PROTECTED]>

Applied, thanks Stephen.
-
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] netdevice: kernel docbook addition

2007-08-22 Thread Stephen Hemminger
Add more kernel doc's for part of the network device API.
This is only a start, and needs more work.

Applies against net-2.6.24

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

--- a/Documentation/DocBook/kernel-api.tmpl 2007-08-21 15:43:37.0 
-0700
+++ b/Documentation/DocBook/kernel-api.tmpl 2007-08-22 12:30:33.0 
-0700
@@ -240,17 +240,23 @@ X!Ilib/string.c
  Driver Support
 !Enet/core/dev.c
 !Enet/ethernet/eth.c
+!Enet/sched/sch_generic.c
 !Iinclude/linux/etherdevice.h
+!Iinclude/linux/netdevice.h
+ 
+ PHY Support
 !Edrivers/net/phy/phy.c
 !Idrivers/net/phy/phy.c
 !Edrivers/net/phy/phy_device.c
 !Idrivers/net/phy/phy_device.c
 !Edrivers/net/phy/mdio_bus.c
 !Idrivers/net/phy/mdio_bus.c
+ 
 
  
+-->
  Synchronous PPP
 !Edrivers/net/wan/syncppp.c
  
--- a/include/linux/netdevice.h 2007-08-21 15:44:00.0 -0700
+++ b/include/linux/netdevice.h 2007-08-22 12:00:16.0 -0700
@@ -302,17 +302,38 @@ enum
 
 extern void FASTCALL(__napi_schedule(struct napi_struct *n));
 
+/**
+ * napi_schedule_prep - check if napi can be scheduled
+ * @n: napi context
+ *
+ * Test if NAPI routine is already running, and if not mark
+ * it as running.  This is used as a condition variable
+ * insure only one NAPI poll instance runs
+ */
 static inline int napi_schedule_prep(struct napi_struct *n)
 {
return !test_and_set_bit(NAPI_STATE_SCHED, &n->state);
 }
 
+/**
+ * napi_schedule - schedule NAPI poll
+ * @n: napi context
+ *
+ * Schedule NAPI poll routine to be called if it is not already
+ * running.
+ */
 static inline void napi_schedule(struct napi_struct *n)
 {
if (napi_schedule_prep(n))
__napi_schedule(n);
 }
 
+/**
+ * napi_complete - NAPI processing complete
+ * @n: napi context
+ *
+ * Mark NAPI processing as complete.
+ */
 static inline void napi_complete(struct napi_struct *n)
 {
BUG_ON(!test_bit(NAPI_STATE_SCHED, &n->state));
@@ -320,12 +341,26 @@ static inline void napi_complete(struct 
clear_bit(NAPI_STATE_SCHED, &n->state);
 }
 
+/**
+ * napi_disable - prevent NAPI from scheduling
+ * @n: napi context
+ *
+ * Stop NAPI from being scheduled on this context.
+ * Waits till any outstanding processing completes.
+ */
 static inline void napi_disable(struct napi_struct *n)
 {
while (test_and_set_bit(NAPI_STATE_SCHED, &n->state))
msleep_interruptible(1);
 }
 
+/**
+ * napi_disable - prevent NAPI from scheduling
+ * @n: napi context
+ *
+ * Resume NAPI from being scheduled on this context.
+ * Must be paired with napi_disable.
+ */
 static inline void napi_enable(struct napi_struct *n)
 {
BUG_ON(!test_bit(NAPI_STATE_SCHED, &n->state));
@@ -636,6 +671,12 @@ struct net_device
 #defineNETDEV_ALIGN32
 #defineNETDEV_ALIGN_CONST  (NETDEV_ALIGN - 1)
 
+/**
+ * netdev_priv - access network device private data
+ * @dev: network device
+ *
+ * Get network device private data
+ */
 static inline void *netdev_priv(const struct net_device *dev)
 {
return dev->priv;
@@ -773,11 +814,24 @@ static inline void netif_schedule(struct
__netif_schedule(dev);
 }
 
+/**
+ * netif_start_queue - allow transmit
+ * @dev: network device
+ *
+ * Allow upper layers to call the device hard_start_xmit routine.
+ */
 static inline void netif_start_queue(struct net_device *dev)
 {
clear_bit(__LINK_STATE_XOFF, &dev->state);
 }
 
+/**
+ * netif_wake_queue - restart transmit
+ * @dev: network device
+ *
+ * Allow upper layers to call the device hard_start_xmit routine.
+ * Used for flow control when transmit resources are available.
+ */
 static inline void netif_wake_queue(struct net_device *dev)
 {
 #ifdef CONFIG_NETPOLL_TRAP
@@ -790,16 +844,35 @@ static inline void netif_wake_queue(stru
__netif_schedule(dev);
 }
 
+/**
+ * netif_stop_queue - stop transmitted packets
+ * @dev: network device
+ *
+ * Stop upper layers calling the device hard_start_xmit routine.
+ * Used for flow control when transmit resources are unavailable.
+ */
 static inline void netif_stop_queue(struct net_device *dev)
 {
set_bit(__LINK_STATE_XOFF, &dev->state);
 }
 
+/**
+ * netif_queue_stopped - test if transmit queue is flowblocked
+ * @dev: network device
+ *
+ * Test if transmit queue on device is currently unable to send.
+ */
 static inline int netif_queue_stopped(const struct net_device *dev)
 {
return test_bit(__LINK_STATE_XOFF, &dev->state);
 }
 
+/**
+ * netif_running - test if up
+ * @dev: network device
+ *
+ * Test if the device has been brought up.
+ */
 static inline int netif_running(const struct net_device *dev)
 {
return test_bit(__LINK_STATE_START, &dev->state);
@@ -811,6 +884,14 @@ static inline int netif_running(const st
  * done at the overall netdevice level.
  * Also test the device if we're multiq

[ANNOUNCE] iproute2-2.6.23-rc3

2007-08-22 Thread Stephen Hemminger
There have been a lot of changes for 2.6.23, so here is a test release
of iproute2 that should capture all the submitted patches


http://developer.osdl.org/shemminger/iproute2/download/iproute2-2.6.23-rc3.tar.gz

Johannes Berg (1):
  show multicast groups

PJ Waskiewicz (1):
  iproute2: sch_rr support in tc

Patrick McHardy (6):
  TC action parsing bug fix
  Bug fix tc action drop
  IPROUTE2: RTNETLINK nested attributes
  Use FRA_* attributes for routing rules
  iplink: use netlink for link configuration
  Fix meta ematch usage of 0 values

Pavel Emelianov (1):
  Make ip utility veth driver aware

Sridhar Samudrala (1):
  Fix bug  in display of ipv6 cloned/cached routes

Stephen Hemminger (3):
  Fix ss to handle partial records.
  sanitized headers update to 2.6.23-rc3
  Fix m_ipt build

-- 
Stephen Hemminger <[EMAIL PROTECTED]>
-
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 IPROUTE]: Add flow classifier support

2007-08-22 Thread Stephen Hemminger
On Wed, 30 May 2007 11:42:01 +0200
Patrick McHardy <[EMAIL PROTECTED]> wrote:

> The iproute patch for the flow classifier.
> 
> 

This patch is on hold since the netlink changes haven't made it upstream yet.

-- 
Stephen Hemminger <[EMAIL PROTECTED]>
-
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] santize tc_ematch headers

2007-08-22 Thread Stephen Hemminger
The headers in tc_ematch are used by iproute2, so these headers
should be processed.

Signed-off-by: Stephen Hemminger <[EMAIL PROTECTED]>
---
 include/linux/Kbuild |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/include/linux/Kbuild b/include/linux/Kbuild
index ad7f71a..818cc3a 100644
--- a/include/linux/Kbuild
+++ b/include/linux/Kbuild
@@ -7,6 +7,7 @@ header-y += raid/
 header-y += spi/
 header-y += sunrpc/
 header-y += tc_act/
+header-y += tc_ematch/
 header-y += netfilter/
 header-y += netfilter_arp/
 header-y += netfilter_bridge/
-- 
1.5.2.4

-
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 0/9 Rev3] Implement batching skb API and support in IPoIB

2007-08-22 Thread Rick Jones

David Miller wrote:

I think the jury is still out, but seeing TSO perform even slightly
worse with the batching changes in place would be very worrysome.
This applies to both throughput and cpu utilization.


Should it be any more or less worrysome than small packet performance (eg the 
TCP_RR stuff I posted recently) being rather worse with TSO enabled than with it 
disabled?


rick jones

-
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: Oops in e100_up

2007-08-22 Thread Arnaldo Carvalho de Melo
Em Wed, Aug 22, 2007 at 09:35:04AM -0700, Kok, Auke escreveu:
> Gerrit Renker wrote:
> >With the davem-2.6.24 tree I get the following Oops in the e100 driver 
> >(cribbed from console):
> >
> >Code: 6c ff ff ff 8b 48 0c ba 01 00 00 00 89 f0 e8 1b f2 ff ff c7 86 9c 00 
> >00 00
> >  01 00 00 00 e9 4e ff ff ff 89 d0 e8 b3 f8 0b 00 eb 8e <0f> 0b eb fe 
> >  55 89 e5
> >  56 53 83 ec 0c 8b 98 dc 01 00 00 e8 ff b9
> >
> >EIP: e100_up+0x11d/0x121 
> >
> >SS:ESP 0068:f759ce38
> >
> >Stack: syscall_call -> sys_ioctl -> vfs_ioctl -> do_ioctl -> sock_ioctl -> 
> >inet_ioctl -> devinet_ioctl ->
> >   dev_change_flags -> dev_open -> e100_open -> oops
> >
> >The system log then goes on reporting "eth0: link up, 100Mbps, 
> >full-duplex" and hangs while trying to
> >restore the serial console state (not sure that this is related).
> 
> restore? Is this during resume from suspend or something?

This seems to have been fixed by a bug reported by akpm and fixed by
Thomas Graf, check a recent post with "netconsole" on the subject.

- 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


r8169: slow samba performance

2007-08-22 Thread Bruce Cole

Just upgraded a motherboard and it came with an onboard
Realtek card which appears to use the r8169 driver.  The
machine is a samba server and when serving files to a local
Linux or Windows client, I only get approx 40-60 kbps. 
Write performance is fine though, in the tens of mbps and

scp, nfs, and ftp server all work well so it appears
specific to the Samba load.  However, when serving to more
than one client symoltaniously, performance goes up
dramatically, again into the tens of mbps or when there is
other network activity.


Shane, join the crowd :)  Try the fix I just re-posted over here:

http://www.spinics.net/lists/netdev/msg39244.html



-
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: Oops in e100_up

2007-08-22 Thread Kok, Auke

Gerrit Renker wrote:

With the davem-2.6.24 tree I get the following Oops in the e100 driver (cribbed 
from console):

Code: 6c ff ff ff 8b 48 0c ba 01 00 00 00 89 f0 e8 1b f2 ff ff c7 86 9c 00 00 00
  01 00 00 00 e9 4e ff ff ff 89 d0 e8 b3 f8 0b 00 eb 8e <0f> 0b eb fe 55 89 
e5
  56 53 83 ec 0c 8b 98 dc 01 00 00 e8 ff b9

EIP: e100_up+0x11d/0x121 


SS:ESP 0068:f759ce38

Stack: syscall_call -> sys_ioctl -> vfs_ioctl -> do_ioctl -> sock_ioctl -> inet_ioctl 
-> devinet_ioctl ->
   dev_change_flags -> dev_open -> e100_open -> oops

The system log then goes on reporting "eth0: link up, 100Mbps, full-duplex" and 
hangs while trying to
restore the serial console state (not sure that this is related).


restore? Is this during resume from suspend or something?

Auke
-
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] [-MM] e1000e: incorporate napi_struct changes from net-2.6.24.git

2007-08-22 Thread Auke Kok
This incorporates the new napi_struct changes into e1000e.

Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
---

 drivers/net/e1000e/e1000.h  |2 ++
 drivers/net/e1000e/netdev.c |   37 ++---
 2 files changed, 20 insertions(+), 19 deletions(-)

diff --git a/drivers/net/e1000e/e1000.h b/drivers/net/e1000e/e1000.h
index e3cd877..ea6a9fe 100644
--- a/drivers/net/e1000e/e1000.h
+++ b/drivers/net/e1000e/e1000.h
@@ -196,6 +196,8 @@ struct e1000_adapter {
struct e1000_ring *tx_ring /* One per active queue */
cacheline_aligned_in_smp;
 
+   struct napi_struct napi;
+
unsigned long tx_queue_len;
unsigned int restart_queue;
u32 txd_cmd;
diff --git a/drivers/net/e1000e/netdev.c b/drivers/net/e1000e/netdev.c
index 8ebe238..e30eae2 100644
--- a/drivers/net/e1000e/netdev.c
+++ b/drivers/net/e1000e/netdev.c
@@ -1149,12 +1149,12 @@ static irqreturn_t e1000_intr_msi(int irq, void *data)
mod_timer(&adapter->watchdog_timer, jiffies + 1);
}
 
-   if (netif_rx_schedule_prep(netdev)) {
+   if (netif_rx_schedule_prep(netdev, &adapter->napi)) {
adapter->total_tx_bytes = 0;
adapter->total_tx_packets = 0;
adapter->total_rx_bytes = 0;
adapter->total_rx_packets = 0;
-   __netif_rx_schedule(netdev);
+   __netif_rx_schedule(netdev, &adapter->napi);
} else {
atomic_dec(&adapter->irq_sem);
}
@@ -1212,12 +1212,12 @@ static irqreturn_t e1000_intr(int irq, void *data)
mod_timer(&adapter->watchdog_timer, jiffies + 1);
}
 
-   if (netif_rx_schedule_prep(netdev)) {
+   if (netif_rx_schedule_prep(netdev, &adapter->napi)) {
adapter->total_tx_bytes = 0;
adapter->total_tx_packets = 0;
adapter->total_rx_bytes = 0;
adapter->total_rx_packets = 0;
-   __netif_rx_schedule(netdev);
+   __netif_rx_schedule(netdev, &adapter->napi);
} else {
atomic_dec(&adapter->irq_sem);
}
@@ -1663,10 +1663,10 @@ set_itr_now:
  * e1000_clean - NAPI Rx polling callback
  * @adapter: board private structure
  **/
-static int e1000_clean(struct net_device *poll_dev, int *budget)
+static int e1000_clean(struct napi_struct *napi, int budget)
 {
-   struct e1000_adapter *adapter;
-   int work_to_do = min(*budget, poll_dev->quota);
+   struct e1000_adapter *adapter = container_of(napi, struct 
e1000_adapter, napi);
+   struct net_device *poll_dev = adapter->netdev;
int tx_cleaned = 0, work_done = 0;
 
/* Must NOT use netdev_priv macro here. */
@@ -1685,17 +1685,15 @@ static int e1000_clean(struct net_device *poll_dev, int 
*budget)
spin_unlock(&adapter->tx_queue_lock);
}
 
-   adapter->clean_rx(adapter, &work_done, work_to_do);
-   *budget -= work_done;
-   poll_dev->quota -= work_done;
+   adapter->clean_rx(adapter, &work_done, budget);
 
/* If no Tx and not enough Rx work done, exit the polling mode */
-   if ((!tx_cleaned && (work_done == 0)) ||
+   if ((tx_cleaned && (work_done < budget)) ||
   !netif_running(poll_dev)) {
 quit_polling:
if (adapter->itr_setting & 3)
e1000_set_itr(adapter);
-   netif_rx_complete(poll_dev);
+   netif_rx_complete(poll_dev, napi);
if (test_bit(__E1000_DOWN, &adapter->state))
atomic_dec(&adapter->irq_sem);
else
@@ -1703,7 +1701,7 @@ quit_polling:
return 0;
}
 
-   return 1;
+   return work_done;
 }
 
 static void e1000_vlan_rx_add_vid(struct net_device *netdev, u16 vid)
@@ -2441,7 +2439,7 @@ int e1000e_up(struct e1000_adapter *adapter)
 
clear_bit(__E1000_DOWN, &adapter->state);
 
-   netif_poll_enable(adapter->netdev);
+   napi_enable(&adapter->napi);
e1000_irq_enable(adapter);
 
/* fire a link change interrupt to start the watchdog */
@@ -2474,7 +2472,7 @@ void e1000e_down(struct e1000_adapter *adapter)
e1e_flush();
msleep(10);
 
-   netif_poll_disable(netdev);
+   napi_disable(&adapter->napi);
e1000_irq_disable(adapter);
 
del_timer_sync(&adapter->watchdog_timer);
@@ -2607,7 +2605,7 @@ static int e1000_open(struct net_device *netdev)
/* From here on the code is the same as e1000e_up() */
clear_bit(__E1000_DOWN, &adapter->state);
 
-   netif_poll_enable(netdev);
+   napi_enable(&adapter->napi);
 
e1000_irq_enable(adapter);
 
@@ -2643,6 +2641,8 @@ static int e1000_close(struct net_device *netdev)
 {
struct e1000_adapter *adapter = netdev_priv(netdev);
 
+   napi_disable(&adapter->napi);
+
WARN_ON(test_bit(__E1000_RESETTING, &adapter->state));

Re: [2.6.20.17 review 35/58] forcedeth bug fix: realtek phy

2007-08-22 Thread Willy Tarreau
On Wed, Aug 22, 2007 at 11:56:42AM -0400, Chuck Ebbert wrote:
> On 08/22/2007 05:39 AM, Willy Tarreau wrote:
> > This patch contains errata fixes for the realtek phy. It only renamed the
> > defines to be phy specific.
> > 
> > Signed-off-by: Ayaz Abdulla <[EMAIL PROTECTED]>
> > Signed-off-by: Greg Kroah-Hartman <[EMAIL PROTECTED]>
> > Signed-off-by: Willy Tarreau <[EMAIL PROTECTED]>
> > ---
> >  drivers/net/forcedeth.c |   54 
> > +++
> >  1 files changed, 54 insertions(+), 0 deletions(-)
> > 
> > diff --git a/drivers/net/forcedeth.c b/drivers/net/forcedeth.c
> > index c383dc3..dbfdbed 100644
> > --- a/drivers/net/forcedeth.c
> > +++ b/drivers/net/forcedeth.c
> > @@ -554,6 +554,7 @@ union ring_type {
> >  #define PHY_OUI_MARVELL0x5043
> >  #define PHY_OUI_CICADA 0x03f1
> >  #define PHY_OUI_VITESSE0x01c1
> > +#define PHY_OUI_REALTEK0x01c1
> >  #define PHYID1_OUI_MASK0x03ff
> >  #define PHYID1_OUI_SHFT6
> >  #define PHYID2_OUI_MASK0xfc00
> 
> Realtek is 0x0732
> 
> This is still wrong upstream -- what happened to the patch to fix it?

Good catch, thanks Chuck! I've already seen the fix somewhere, I believe it
was on netdev, though I'm not sure. I'm fixing the patch in place right now.
I can add your signoff if you want.

Cheers,
Willy

-
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 1/10 Rev4] [Doc] HOWTO Documentation for batching

2007-08-22 Thread Randy Dunlap
On Wed, 22 Aug 2007 13:58:58 +0530 Krishna Kumar wrote:

> Add Documentation describing batching skb xmit capability.
> 
> Signed-off-by: Krishna Kumar <[EMAIL PROTECTED]>
> ---
>  batching_skb_xmit.txt |   78 
> ++
>  1 files changed, 78 insertions(+)
> 
> diff -ruNp org/Documentation/networking/batching_skb_xmit.txt 
> new/Documentation/networking/batching_skb_xmit.txt
> --- org/Documentation/networking/batching_skb_xmit.txt1970-01-01 
> 05:30:00.0 +0530
> +++ new/Documentation/networking/batching_skb_xmit.txt2007-08-22 
> 10:21:19.0 +0530
> @@ -0,0 +1,78 @@
> +  HOWTO for batching skb xmit support
> +  ---
> +
> +Section 1: What is batching skb xmit
> +Section 2: How batching xmit works vs the regular xmit
> +Section 3: How drivers can support batching
> +Section 4: How users can work with batching
> +
> +
> +Introduction: Kernel support for batching skb
> +--
> +
> +A new capability to support xmit of multiple skbs is provided in the 
> netdevice
> +layer. Drivers which enable this capability should be able to process 
> multiple
> +skbs in a single call to their xmit handler.
> +
> +
> +Section 1: What is batching skb xmit
> +-
> +
> + This capability is optionally enabled by a driver by setting the
> + NETIF_F_BATCH_SKBS bit in dev->features. The pre-requisite for a

 prerequisite

> + driver to use this capability is that it should have a reasonably

I would say "reasonably-sized".

> + sized hardware queue that can process multiple skbs.
> +
> +
> +Section 2: How batching xmit works vs the regular xmit
> +---
> +
> + The network stack gets called from upper layer protocols with a single
> + skb to transmit. This skb is first enqueue'd and an attempt is made to

   enqueued

> + transmit it immediately (via qdisc_run). However, events like tx lock
> + contention, tx queue stopped, etc, can result in the skb not getting

  etc.,

> + sent out and it remains in the queue. When the next xmit is called or
> + when the queue is re-enabled, qdisc_run could potentially find
> + multiple packets in the queue, and iteratively send them all out
> + one-by-one.
> +
> + Batching skb xmit is a mechanism to exploit this situation where all
> + skbs can be passed in one shot to the device. This reduces driver
> + processing, locking at the driver (or in stack for ~LLTX drivers)
> + gets amortized over multiple skbs, and in case of specific drivers
> + where every xmit results in a completion processing (like IPoIB) -
> + optimizations can be made in the driver to request a completion for
> + only the last skb that was sent which results in saving interrupts
> + for every (but the last) skb that was sent in the same batch.
> +
> + Batching can result in significant performance gains for systems that
> + have multiple data stream paths over the same network interface card.
> +
> +
> +Section 3: How drivers can support batching
> +-
> +
> + Batching requires the driver to set the NETIF_F_BATCH_SKBS bit in
> + dev->features.
> +
> + The driver's xmit handler should be modified to process multiple skbs
> + instead of one skb. The driver's xmit handler is called either with a

   an

> + skb to transmit or NULL skb, where the latter case should be handled
> + as a call to xmit multiple skbs. This is done by sending out all skbs
> + in the dev->skb_blist list (where it was added by the core stack).
> +
> +
> +Section 4: How users can work with batching
> +-
> +
> + Batching can be disabled for a particular device, e.g. on desktop
> + systems if only one stream of network activity for that device is
> + taking place, since performance could be slightly affected due to
> + extra processing that batching adds (unless packets are getting
> + sent fast resulting in stopped queue's). Batching can be enabled if

   queues).

> + more than one stream of network activity per device is being done,
> + e.g. on servers; or even desktop usage with multiple browser, chat,
> + file transfer sessions, etc.
> +
> + Per device batching can be enabled/disabled by passing 'on' or 'off'
> + respectively to ethtool.

with what other parameter(s), e.g.,

ethtool  batching on/off ?

---
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***
-
To unsubscribe f

[PATCH 07/16] [XFRM] netlink: Clear up some of the CONFIG_XFRM_SUB_POLICY ifdef mess

2007-08-22 Thread Thomas Graf
Moves all of the SUB_POLICY ifdefs related to the attribute size
calculation into a function.

Signed-off-by: Thomas Graf <[EMAIL PROTECTED]>

Index: net-2.6.24/net/xfrm/xfrm_user.c
===
--- net-2.6.24.orig/net/xfrm/xfrm_user.c2007-08-21 17:03:43.0 
+0200
+++ net-2.6.24/net/xfrm/xfrm_user.c 2007-08-21 17:04:46.0 +0200
@@ -1224,6 +1224,14 @@ static inline int copy_to_user_sec_ctx(s
}
return 0;
 }
+static inline size_t userpolicy_type_attrsize(void)
+{
+#ifdef CONFIG_XFRM_SUB_POLICY
+   return nla_total_size(sizeof(struct xfrm_userpolicy_type));
+#else
+   return 0;
+#endif
+}
 
 #ifdef CONFIG_XFRM_SUB_POLICY
 static int copy_to_user_policy_type(u8 type, struct sk_buff *skb)
@@ -1857,9 +1865,7 @@ static int xfrm_send_migrate(struct xfrm
 
len = RTA_SPACE(sizeof(struct xfrm_user_migrate) * num_migrate);
len += NLMSG_SPACE(sizeof(struct xfrm_userpolicy_id));
-#ifdef CONFIG_XFRM_SUB_POLICY
-   len += RTA_SPACE(sizeof(struct xfrm_userpolicy_type));
-#endif
+   len += userpolicy_type_attrsize();
skb = alloc_skb(len, GFP_ATOMIC);
if (skb == NULL)
return -ENOMEM;
@@ -2214,9 +2220,7 @@ static int xfrm_send_acquire(struct xfrm
len = RTA_SPACE(sizeof(struct xfrm_user_tmpl) * xp->xfrm_nr);
len += NLMSG_SPACE(sizeof(struct xfrm_user_acquire));
len += RTA_SPACE(xfrm_user_sec_ctx_size(x->security));
-#ifdef CONFIG_XFRM_SUB_POLICY
-   len += RTA_SPACE(sizeof(struct xfrm_userpolicy_type));
-#endif
+   len += userpolicy_type_attrsize();
skb = alloc_skb(len, GFP_ATOMIC);
if (skb == NULL)
return -ENOMEM;
@@ -2322,9 +2326,7 @@ static int xfrm_exp_policy_notify(struct
len = RTA_SPACE(sizeof(struct xfrm_user_tmpl) * xp->xfrm_nr);
len += NLMSG_SPACE(sizeof(struct xfrm_user_polexpire));
len += RTA_SPACE(xfrm_user_sec_ctx_size(xp->security));
-#ifdef CONFIG_XFRM_SUB_POLICY
-   len += RTA_SPACE(sizeof(struct xfrm_userpolicy_type));
-#endif
+   len += userpolicy_type_attrsize();
skb = alloc_skb(len, GFP_ATOMIC);
if (skb == NULL)
return -ENOMEM;
@@ -2349,9 +2351,7 @@ static int xfrm_notify_policy(struct xfr
len += RTA_SPACE(headlen);
headlen = sizeof(*id);
}
-#ifdef CONFIG_XFRM_SUB_POLICY
-   len += RTA_SPACE(sizeof(struct xfrm_userpolicy_type));
-#endif
+   len += userpolicy_type_attrsize();
len += NLMSG_SPACE(headlen);
 
skb = alloc_skb(len, GFP_ATOMIC);
@@ -2401,9 +2401,7 @@ static int xfrm_notify_policy_flush(stru
struct nlmsghdr *nlh;
struct sk_buff *skb;
int len = 0;
-#ifdef CONFIG_XFRM_SUB_POLICY
-   len += RTA_SPACE(sizeof(struct xfrm_userpolicy_type));
-#endif
+   len += userpolicy_type_attrsize();
len += NLMSG_LENGTH(0);
 
skb = alloc_skb(len, GFP_ATOMIC);

-- 

-
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 04/16] [XFRM] netlink: Use nlmsg_broadcast() and nlmsg_unicast()

2007-08-22 Thread Thomas Graf
This simplifies successful return codes from >0 to 0.

Signed-off-by: Thomas Graf <[EMAIL PROTECTED]>

Index: net-2.6.24/net/xfrm/xfrm_user.c
===
--- net-2.6.24.orig/net/xfrm/xfrm_user.c2007-08-21 16:13:57.0 
+0200
+++ net-2.6.24/net/xfrm/xfrm_user.c 2007-08-21 16:15:03.0 +0200
@@ -800,8 +800,7 @@ static int xfrm_get_sa(struct sk_buff *s
if (IS_ERR(resp_skb)) {
err = PTR_ERR(resp_skb);
} else {
-   err = netlink_unicast(xfrm_nl, resp_skb,
- NETLINK_CB(skb).pid, MSG_DONTWAIT);
+   err = nlmsg_unicast(xfrm_nl, resp_skb, NETLINK_CB(skb).pid);
}
xfrm_state_put(x);
 out_noput:
@@ -882,8 +881,7 @@ static int xfrm_alloc_userspi(struct sk_
goto out;
}
 
-   err = netlink_unicast(xfrm_nl, resp_skb,
- NETLINK_CB(skb).pid, MSG_DONTWAIT);
+   err = nlmsg_unicast(xfrm_nl, resp_skb, NETLINK_CB(skb).pid);
 
 out:
xfrm_state_put(x);
@@ -1393,9 +1391,8 @@ static int xfrm_get_policy(struct sk_buf
if (IS_ERR(resp_skb)) {
err = PTR_ERR(resp_skb);
} else {
-   err = netlink_unicast(xfrm_nl, resp_skb,
- NETLINK_CB(skb).pid,
- MSG_DONTWAIT);
+   err = nlmsg_unicast(xfrm_nl, resp_skb,
+   NETLINK_CB(skb).pid);
}
} else {
xfrm_audit_log(NETLINK_CB(skb).loginuid, NETLINK_CB(skb).sid,
@@ -1525,8 +1522,7 @@ static int xfrm_get_ae(struct sk_buff *s
 
if (build_aevent(r_skb, x, &c) < 0)
BUG();
-   err = netlink_unicast(xfrm_nl, r_skb,
- NETLINK_CB(skb).pid, MSG_DONTWAIT);
+   err = nlmsg_unicast(xfrm_nl, r_skb, NETLINK_CB(skb).pid);
spin_unlock_bh(&x->lock);
xfrm_state_put(x);
return err;
@@ -1903,9 +1899,7 @@ static int xfrm_send_migrate(struct xfrm
if (build_migrate(skb, m, num_migrate, sel, dir, type) < 0)
BUG();
 
-   NETLINK_CB(skb).dst_group = XFRMNLGRP_MIGRATE;
-   return netlink_broadcast(xfrm_nl, skb, 0, XFRMNLGRP_MIGRATE,
-GFP_ATOMIC);
+   return nlmsg_multicast(xfrm_nl, skb, 0, XFRMNLGRP_MIGRATE, GFP_ATOMIC);
 }
 #else
 static int xfrm_send_migrate(struct xfrm_selector *sel, u8 dir, u8 type,
@@ -2061,8 +2055,7 @@ static int xfrm_exp_state_notify(struct 
if (build_expire(skb, x, c) < 0)
BUG();
 
-   NETLINK_CB(skb).dst_group = XFRMNLGRP_EXPIRE;
-   return netlink_broadcast(xfrm_nl, skb, 0, XFRMNLGRP_EXPIRE, GFP_ATOMIC);
+   return nlmsg_multicast(xfrm_nl, skb, 0, XFRMNLGRP_EXPIRE, GFP_ATOMIC);
 }
 
 static int xfrm_aevent_state_notify(struct xfrm_state *x, struct km_event *c)
@@ -2079,8 +2072,7 @@ static int xfrm_aevent_state_notify(stru
if (build_aevent(skb, x, c) < 0)
BUG();
 
-   NETLINK_CB(skb).dst_group = XFRMNLGRP_AEVENTS;
-   return netlink_broadcast(xfrm_nl, skb, 0, XFRMNLGRP_AEVENTS, 
GFP_ATOMIC);
+   return nlmsg_multicast(xfrm_nl, skb, 0, XFRMNLGRP_AEVENTS, GFP_ATOMIC);
 }
 
 static int xfrm_notify_sa_flush(struct km_event *c)
@@ -2105,8 +2097,7 @@ static int xfrm_notify_sa_flush(struct k
 
nlmsg_end(skb, nlh);
 
-   NETLINK_CB(skb).dst_group = XFRMNLGRP_SA;
-   return netlink_broadcast(xfrm_nl, skb, 0, XFRMNLGRP_SA, GFP_ATOMIC);
+   return nlmsg_multicast(xfrm_nl, skb, 0, XFRMNLGRP_SA, GFP_ATOMIC);
 }
 
 static inline int xfrm_sa_len(struct xfrm_state *x)
@@ -2175,8 +2166,7 @@ static int xfrm_notify_sa(struct xfrm_st
 
nlmsg_end(skb, nlh);
 
-   NETLINK_CB(skb).dst_group = XFRMNLGRP_SA;
-   return netlink_broadcast(xfrm_nl, skb, 0, XFRMNLGRP_SA, GFP_ATOMIC);
+   return nlmsg_multicast(xfrm_nl, skb, 0, XFRMNLGRP_SA, GFP_ATOMIC);
 
 nlmsg_failure:
 rtattr_failure:
@@ -2262,8 +2252,7 @@ static int xfrm_send_acquire(struct xfrm
if (build_acquire(skb, x, xt, xp, dir) < 0)
BUG();
 
-   NETLINK_CB(skb).dst_group = XFRMNLGRP_ACQUIRE;
-   return netlink_broadcast(xfrm_nl, skb, 0, XFRMNLGRP_ACQUIRE, 
GFP_ATOMIC);
+   return nlmsg_multicast(xfrm_nl, skb, 0, XFRMNLGRP_ACQUIRE, GFP_ATOMIC);
 }
 
 /* User gives us xfrm_user_policy_info followed by an array of 0
@@ -2371,8 +2360,7 @@ static int xfrm_exp_policy_notify(struct
if (build_polexpire(skb, xp, dir, c) < 0)
BUG();
 
-   NETLINK_CB(skb).dst_group = XFRMNLGRP_EXPIRE;
-   return netlink_broadcast(xfrm_nl, skb, 0, XFRMNLGRP_EXPIRE, GFP_ATOMIC);
+   return nlmsg_multicast(xfrm_nl, skb, 0, XFRMNLGRP_EXPIRE, GFP_ATOMIC);
 }
 
 static int xfrm_notify_policy(struct xfrm_policy *xp, int dir, struct km_event 
*c)
@@ -2423,8 +2411,

[PATCH 03/16] [XFRM] netlink: Use nlmsg_data() instead of NLMSG_DATA()

2007-08-22 Thread Thomas Graf
Signed-off-by: Thomas Graf <[EMAIL PROTECTED]>

Index: net-2.6.24/net/xfrm/xfrm_user.c
===
--- net-2.6.24.orig/net/xfrm/xfrm_user.c2007-08-21 16:12:20.0 
+0200
+++ net-2.6.24/net/xfrm/xfrm_user.c 2007-08-21 16:13:57.0 +0200
@@ -443,7 +443,7 @@ error_no_put:
 static int xfrm_add_sa(struct sk_buff *skb, struct nlmsghdr *nlh,
struct rtattr **xfrma)
 {
-   struct xfrm_usersa_info *p = NLMSG_DATA(nlh);
+   struct xfrm_usersa_info *p = nlmsg_data(nlh);
struct xfrm_state *x;
int err;
struct km_event c;
@@ -520,7 +520,7 @@ static int xfrm_del_sa(struct sk_buff *s
struct xfrm_state *x;
int err = -ESRCH;
struct km_event c;
-   struct xfrm_usersa_id *p = NLMSG_DATA(nlh);
+   struct xfrm_usersa_id *p = nlmsg_data(nlh);
 
x = xfrm_user_state_lookup(p, xfrma, &err);
if (x == NULL)
@@ -592,7 +592,7 @@ static int dump_one_state(struct xfrm_st
if (nlh == NULL)
return -EMSGSIZE;
 
-   p = NLMSG_DATA(nlh);
+   p = nlmsg_data(nlh);
copy_to_user_state(x, p);
 
if (x->aalg)
@@ -715,7 +715,7 @@ static int xfrm_get_spdinfo(struct sk_bu
struct rtattr **xfrma)
 {
struct sk_buff *r_skb;
-   u32 *flags = NLMSG_DATA(nlh);
+   u32 *flags = nlmsg_data(nlh);
u32 spid = NETLINK_CB(skb).pid;
u32 seq = nlh->nlmsg_seq;
int len = NLMSG_LENGTH(sizeof(u32));
@@ -765,7 +765,7 @@ static int xfrm_get_sadinfo(struct sk_bu
struct rtattr **xfrma)
 {
struct sk_buff *r_skb;
-   u32 *flags = NLMSG_DATA(nlh);
+   u32 *flags = nlmsg_data(nlh);
u32 spid = NETLINK_CB(skb).pid;
u32 seq = nlh->nlmsg_seq;
int len = NLMSG_LENGTH(sizeof(u32));
@@ -787,7 +787,7 @@ static int xfrm_get_sadinfo(struct sk_bu
 static int xfrm_get_sa(struct sk_buff *skb, struct nlmsghdr *nlh,
struct rtattr **xfrma)
 {
-   struct xfrm_usersa_id *p = NLMSG_DATA(nlh);
+   struct xfrm_usersa_id *p = nlmsg_data(nlh);
struct xfrm_state *x;
struct sk_buff *resp_skb;
int err = -ESRCH;
@@ -841,7 +841,7 @@ static int xfrm_alloc_userspi(struct sk_
int family;
int err;
 
-   p = NLMSG_DATA(nlh);
+   p = nlmsg_data(nlh);
err = verify_userspi_info(p);
if (err)
goto out_noput;
@@ -1130,7 +1130,7 @@ static struct xfrm_policy *xfrm_policy_c
 static int xfrm_add_policy(struct sk_buff *skb, struct nlmsghdr *nlh,
struct rtattr **xfrma)
 {
-   struct xfrm_userpolicy_info *p = NLMSG_DATA(nlh);
+   struct xfrm_userpolicy_info *p = nlmsg_data(nlh);
struct xfrm_policy *xp;
struct km_event c;
int err;
@@ -1277,8 +1277,8 @@ static int dump_one_policy(struct xfrm_p
XFRM_MSG_NEWPOLICY, sizeof(*p), sp->nlmsg_flags);
if (nlh == NULL)
return -EMSGSIZE;
-   p = NLMSG_DATA(nlh);
 
+   p = nlmsg_data(nlh);
copy_to_user_policy(xp, p, dir);
if (copy_to_user_tmpl(xp, skb) < 0)
goto nlmsg_failure;
@@ -1351,7 +1351,7 @@ static int xfrm_get_policy(struct sk_buf
struct km_event c;
int delete;
 
-   p = NLMSG_DATA(nlh);
+   p = nlmsg_data(nlh);
delete = nlh->nlmsg_type == XFRM_MSG_DELPOLICY;
 
err = copy_from_user_policy_type(&type, xfrma);
@@ -1420,7 +1420,7 @@ static int xfrm_flush_sa(struct sk_buff 
struct rtattr **xfrma)
 {
struct km_event c;
-   struct xfrm_usersa_flush *p = NLMSG_DATA(nlh);
+   struct xfrm_usersa_flush *p = nlmsg_data(nlh);
struct xfrm_audit audit_info;
int err;
 
@@ -1448,8 +1448,8 @@ static int build_aevent(struct sk_buff *
nlh = nlmsg_put(skb, c->pid, c->seq, XFRM_MSG_NEWAE, sizeof(*id), 0);
if (nlh == NULL)
return -EMSGSIZE;
-   id = NLMSG_DATA(nlh);
 
+   id = nlmsg_data(nlh);
memcpy(&id->sa_id.daddr, &x->id.daddr,sizeof(x->id.daddr));
id->sa_id.spi = x->id.spi;
id->sa_id.family = x->props.family;
@@ -1490,7 +1490,7 @@ static int xfrm_get_ae(struct sk_buff *s
struct sk_buff *r_skb;
int err;
struct km_event c;
-   struct xfrm_aevent_id *p = NLMSG_DATA(nlh);
+   struct xfrm_aevent_id *p = nlmsg_data(nlh);
int len = NLMSG_LENGTH(sizeof(struct xfrm_aevent_id));
struct xfrm_usersa_id *id = &p->sa_id;
 
@@ -1538,7 +1538,7 @@ static int xfrm_new_ae(struct sk_buff *s
struct xfrm_state *x;
struct km_event c;
int err = - EINVAL;
-   struct xfrm_aevent_id *p = NLMSG_DATA(nlh);
+   struct xfrm_aevent_id *p = nlmsg_data(nlh);
struct rtattr *rp = xfrma[XFRMA_REPLAY_VAL-1];
struct rtattr *lt = xfrma[XFRMA_LTIME_VAL-1];
 
@@ -1602,7 +1602,7 @@ static int xfrm_add_pol_expire(struct sk

[PATCH 15/16] [XFRM] netlink: Remove dependency on rtnetlink

2007-08-22 Thread Thomas Graf
Signed-off-by: Thomas Graf <[EMAIL PROTECTED]>

Index: net-2.6.24/net/xfrm/xfrm_user.c
===
--- net-2.6.24.orig/net/xfrm/xfrm_user.c2007-08-21 17:36:59.0 
+0200
+++ net-2.6.24/net/xfrm/xfrm_user.c 2007-08-21 17:37:18.0 +0200
@@ -19,7 +19,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 

-- 

-
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 13/16] [XFRM] netlink: Use nlattr instead of rtattr

2007-08-22 Thread Thomas Graf
Signed-off-by: Thomas Graf <[EMAIL PROTECTED]>

Index: net-2.6.24/net/xfrm/xfrm_user.c
===
--- net-2.6.24.orig/net/xfrm/xfrm_user.c2007-08-21 17:34:29.0 
+0200
+++ net-2.6.24/net/xfrm/xfrm_user.c 2007-08-21 17:35:13.0 +0200
@@ -38,16 +38,16 @@ static inline int alg_len(struct xfrm_al
return sizeof(*alg) + ((alg->alg_key_len + 7) / 8);
 }
 
-static int verify_one_alg(struct rtattr **attrs, enum xfrm_attr_type_t type)
+static int verify_one_alg(struct nlattr **attrs, enum xfrm_attr_type_t type)
 {
-   struct rtattr *rt = attrs[type];
+   struct nlattr *rt = attrs[type];
struct xfrm_algo *algp;
 
if (!rt)
return 0;
 
-   algp = RTA_DATA(rt);
-   if (RTA_PAYLOAD(rt) < alg_len(algp))
+   algp = nla_data(rt);
+   if (nla_len(rt) < alg_len(algp))
return -EINVAL;
 
switch (type) {
@@ -75,24 +75,24 @@ static int verify_one_alg(struct rtattr 
return 0;
 }
 
-static void verify_one_addr(struct rtattr **attrs, enum xfrm_attr_type_t type,
+static void verify_one_addr(struct nlattr **attrs, enum xfrm_attr_type_t type,
   xfrm_address_t **addrp)
 {
-   struct rtattr *rt = attrs[type];
+   struct nlattr *rt = attrs[type];
 
if (rt && addrp)
-   *addrp = RTA_DATA(rt);
+   *addrp = nla_data(rt);
 }
 
-static inline int verify_sec_ctx_len(struct rtattr **attrs)
+static inline int verify_sec_ctx_len(struct nlattr **attrs)
 {
-   struct rtattr *rt = attrs[XFRMA_SEC_CTX];
+   struct nlattr *rt = attrs[XFRMA_SEC_CTX];
struct xfrm_user_sec_ctx *uctx;
 
if (!rt)
return 0;
 
-   uctx = RTA_DATA(rt);
+   uctx = nla_data(rt);
if (uctx->len != (sizeof(struct xfrm_user_sec_ctx) + uctx->ctx_len))
return -EINVAL;
 
@@ -101,7 +101,7 @@ static inline int verify_sec_ctx_len(str
 
 
 static int verify_newsa_info(struct xfrm_usersa_info *p,
-struct rtattr **attrs)
+struct nlattr **attrs)
 {
int err;
 
@@ -191,16 +191,15 @@ out:
 
 static int attach_one_algo(struct xfrm_algo **algpp, u8 *props,
   struct xfrm_algo_desc *(*get_byname)(char *, int),
-  struct rtattr *u_arg)
+  struct nlattr *rta)
 {
-   struct rtattr *rta = u_arg;
struct xfrm_algo *p, *ualg;
struct xfrm_algo_desc *algo;
 
if (!rta)
return 0;
 
-   ualg = RTA_DATA(rta);
+   ualg = nla_data(rta);
 
algo = get_byname(ualg->alg_name, 1);
if (!algo)
@@ -216,15 +215,14 @@ static int attach_one_algo(struct xfrm_a
return 0;
 }
 
-static int attach_encap_tmpl(struct xfrm_encap_tmpl **encapp, struct rtattr 
*u_arg)
+static int attach_encap_tmpl(struct xfrm_encap_tmpl **encapp, struct nlattr 
*rta)
 {
-   struct rtattr *rta = u_arg;
struct xfrm_encap_tmpl *p, *uencap;
 
if (!rta)
return 0;
 
-   uencap = RTA_DATA(rta);
+   uencap = nla_data(rta);
p = kmemdup(uencap, sizeof(*p), GFP_KERNEL);
if (!p)
return -ENOMEM;
@@ -245,26 +243,25 @@ static inline int xfrm_user_sec_ctx_size
return len;
 }
 
-static int attach_sec_ctx(struct xfrm_state *x, struct rtattr *u_arg)
+static int attach_sec_ctx(struct xfrm_state *x, struct nlattr *u_arg)
 {
struct xfrm_user_sec_ctx *uctx;
 
if (!u_arg)
return 0;
 
-   uctx = RTA_DATA(u_arg);
+   uctx = nla_data(u_arg);
return security_xfrm_state_alloc(x, uctx);
 }
 
-static int attach_one_addr(xfrm_address_t **addrpp, struct rtattr *u_arg)
+static int attach_one_addr(xfrm_address_t **addrpp, struct nlattr *rta)
 {
-   struct rtattr *rta = u_arg;
xfrm_address_t *p, *uaddrp;
 
if (!rta)
return 0;
 
-   uaddrp = RTA_DATA(rta);
+   uaddrp = nla_data(rta);
p = kmemdup(uaddrp, sizeof(*p), GFP_KERNEL);
if (!p)
return -ENOMEM;
@@ -298,23 +295,23 @@ static void copy_from_user_state(struct 
  * somehow made shareable and move it to xfrm_state.c - JHS
  *
 */
-static void xfrm_update_ae_params(struct xfrm_state *x, struct rtattr **attrs)
+static void xfrm_update_ae_params(struct xfrm_state *x, struct nlattr **attrs)
 {
-   struct rtattr *rp = attrs[XFRMA_REPLAY_VAL];
-   struct rtattr *lt = attrs[XFRMA_LTIME_VAL];
-   struct rtattr *et = attrs[XFRMA_ETIMER_THRESH];
-   struct rtattr *rt = attrs[XFRMA_REPLAY_THRESH];
+   struct nlattr *rp = attrs[XFRMA_REPLAY_VAL];
+   struct nlattr *lt = attrs[XFRMA_LTIME_VAL];
+   struct nlattr *et = attrs[XFRMA_ETIMER_THRESH];
+   struct nlattr *rt = attrs[XFRMA_REPLAY_THRESH];
 
if (rp) {
struct xfrm_replay_state *replay;
-   replay = RTA_D

[PATCH 05/16] [XFRM] netlink: Use nla_put()/NLA_PUT() variantes

2007-08-22 Thread Thomas Graf
Also makes use of copy_sec_ctx() in another place and removes
duplicated code.

Signed-off-by: Thomas Graf <[EMAIL PROTECTED]>

Index: net-2.6.24/net/xfrm/xfrm_user.c
===
--- net-2.6.24.orig/net/xfrm/xfrm_user.c2007-08-21 16:15:03.0 
+0200
+++ net-2.6.24/net/xfrm/xfrm_user.c 2007-08-21 16:16:03.0 +0200
@@ -576,6 +576,27 @@ struct xfrm_dump_info {
int this_idx;
 };
 
+static int copy_sec_ctx(struct xfrm_sec_ctx *s, struct sk_buff *skb)
+{
+   int ctx_size = sizeof(struct xfrm_sec_ctx) + s->ctx_len;
+   struct xfrm_user_sec_ctx *uctx;
+   struct nlattr *attr;
+
+   attr = nla_reserve(skb, XFRMA_SEC_CTX, ctx_size);
+   if (attr == NULL)
+   return -EMSGSIZE;
+
+   uctx = nla_data(attr);
+   uctx->exttype = XFRMA_SEC_CTX;
+   uctx->len = ctx_size;
+   uctx->ctx_doi = s->ctx_doi;
+   uctx->ctx_alg = s->ctx_alg;
+   uctx->ctx_len = s->ctx_len;
+   memcpy(uctx + 1, s->ctx_str, s->ctx_len);
+
+   return 0;
+}
+
 static int dump_one_state(struct xfrm_state *x, int count, void *ptr)
 {
struct xfrm_dump_info *sp = ptr;
@@ -596,43 +617,32 @@ static int dump_one_state(struct xfrm_st
copy_to_user_state(x, p);
 
if (x->aalg)
-   RTA_PUT(skb, XFRMA_ALG_AUTH,
+   NLA_PUT(skb, XFRMA_ALG_AUTH,
sizeof(*(x->aalg))+(x->aalg->alg_key_len+7)/8, x->aalg);
if (x->ealg)
-   RTA_PUT(skb, XFRMA_ALG_CRYPT,
+   NLA_PUT(skb, XFRMA_ALG_CRYPT,
sizeof(*(x->ealg))+(x->ealg->alg_key_len+7)/8, x->ealg);
if (x->calg)
-   RTA_PUT(skb, XFRMA_ALG_COMP, sizeof(*(x->calg)), x->calg);
+   NLA_PUT(skb, XFRMA_ALG_COMP, sizeof(*(x->calg)), x->calg);
 
if (x->encap)
-   RTA_PUT(skb, XFRMA_ENCAP, sizeof(*x->encap), x->encap);
+   NLA_PUT(skb, XFRMA_ENCAP, sizeof(*x->encap), x->encap);
 
-   if (x->security) {
-   int ctx_size = sizeof(struct xfrm_sec_ctx) +
-   x->security->ctx_len;
-   struct rtattr *rt = __RTA_PUT(skb, XFRMA_SEC_CTX, ctx_size);
-   struct xfrm_user_sec_ctx *uctx = RTA_DATA(rt);
-
-   uctx->exttype = XFRMA_SEC_CTX;
-   uctx->len = ctx_size;
-   uctx->ctx_doi = x->security->ctx_doi;
-   uctx->ctx_alg = x->security->ctx_alg;
-   uctx->ctx_len = x->security->ctx_len;
-   memcpy(uctx + 1, x->security->ctx_str, x->security->ctx_len);
-   }
+   if (x->security && copy_sec_ctx(x->security, skb) < 0)
+   goto nla_put_failure;
 
if (x->coaddr)
-   RTA_PUT(skb, XFRMA_COADDR, sizeof(*x->coaddr), x->coaddr);
+   NLA_PUT(skb, XFRMA_COADDR, sizeof(*x->coaddr), x->coaddr);
 
if (x->lastused)
-   RTA_PUT(skb, XFRMA_LASTUSED, sizeof(x->lastused), &x->lastused);
+   NLA_PUT_U64(skb, XFRMA_LASTUSED, x->lastused);
 
nlmsg_end(skb, nlh);
 out:
sp->this_idx++;
return 0;
 
-rtattr_failure:
+nla_put_failure:
nlmsg_cancel(skb, nlh);
return -EMSGSIZE;
 }
@@ -1193,32 +1203,9 @@ static int copy_to_user_tmpl(struct xfrm
up->ealgos = kp->ealgos;
up->calgos = kp->calgos;
}
-   RTA_PUT(skb, XFRMA_TMPL,
-   (sizeof(struct xfrm_user_tmpl) * xp->xfrm_nr),
-   vec);
-
-   return 0;
-
-rtattr_failure:
-   return -1;
-}
-
-static int copy_sec_ctx(struct xfrm_sec_ctx *s, struct sk_buff *skb)
-{
-   int ctx_size = sizeof(struct xfrm_sec_ctx) + s->ctx_len;
-   struct rtattr *rt = __RTA_PUT(skb, XFRMA_SEC_CTX, ctx_size);
-   struct xfrm_user_sec_ctx *uctx = RTA_DATA(rt);
-
-   uctx->exttype = XFRMA_SEC_CTX;
-   uctx->len = ctx_size;
-   uctx->ctx_doi = s->ctx_doi;
-   uctx->ctx_alg = s->ctx_alg;
-   uctx->ctx_len = s->ctx_len;
-   memcpy(uctx + 1, s->ctx_str, s->ctx_len);
-   return 0;
 
- rtattr_failure:
-   return -1;
+   return nla_put(skb, XFRMA_TMPL,
+  sizeof(struct xfrm_user_tmpl) * xp->xfrm_nr, vec);
 }
 
 static inline int copy_to_user_state_sec_ctx(struct xfrm_state *x, struct 
sk_buff *skb)
@@ -1240,17 +1227,11 @@ static inline int copy_to_user_sec_ctx(s
 #ifdef CONFIG_XFRM_SUB_POLICY
 static int copy_to_user_policy_type(u8 type, struct sk_buff *skb)
 {
-   struct xfrm_userpolicy_type upt;
+   struct xfrm_userpolicy_type upt = {
+   .type = type,
+   };
 
-   memset(&upt, 0, sizeof(upt));
-   upt.type = type;
-
-   RTA_PUT(skb, XFRMA_POLICY_TYPE, sizeof(upt), &upt);
-
-   return 0;
-
-rtattr_failure:
-   return -1;
+   return nla_put(skb, XFRMA_POLICY_TYPE, sizeof(upt), &upt);
 }
 
 #else
@@ -1440,7 +1421,6 @@ static int build_aevent(struct sk_buff *
 {
struct xfr

[PATCH 11/16] [XFRM] netlink: Enhance indexing of the attribute array

2007-08-22 Thread Thomas Graf
nlmsg_parse() puts attributes at array[type] so the indexing
method can be simpilfied by removing the obscuring "- 1".

Signed-off-by: Thomas Graf <[EMAIL PROTECTED]>

Index: net-2.6.24/net/xfrm/xfrm_user.c
===
--- net-2.6.24.orig/net/xfrm/xfrm_user.c2007-08-21 17:31:56.0 
+0200
+++ net-2.6.24/net/xfrm/xfrm_user.c 2007-08-21 17:34:10.0 +0200
@@ -40,7 +40,7 @@ static inline int alg_len(struct xfrm_al
 
 static int verify_one_alg(struct rtattr **xfrma, enum xfrm_attr_type_t type)
 {
-   struct rtattr *rt = xfrma[type - 1];
+   struct rtattr *rt = xfrma[type];
struct xfrm_algo *algp;
 
if (!rt)
@@ -78,7 +78,7 @@ static int verify_one_alg(struct rtattr 
 static void verify_one_addr(struct rtattr **xfrma, enum xfrm_attr_type_t type,
   xfrm_address_t **addrp)
 {
-   struct rtattr *rt = xfrma[type - 1];
+   struct rtattr *rt = xfrma[type];
 
if (rt && addrp)
*addrp = RTA_DATA(rt);
@@ -86,7 +86,7 @@ static void verify_one_addr(struct rtatt
 
 static inline int verify_sec_ctx_len(struct rtattr **xfrma)
 {
-   struct rtattr *rt = xfrma[XFRMA_SEC_CTX - 1];
+   struct rtattr *rt = xfrma[XFRMA_SEC_CTX];
struct xfrm_user_sec_ctx *uctx;
 
if (!rt)
@@ -125,35 +125,35 @@ static int verify_newsa_info(struct xfrm
err = -EINVAL;
switch (p->id.proto) {
case IPPROTO_AH:
-   if (!xfrma[XFRMA_ALG_AUTH-1]||
-   xfrma[XFRMA_ALG_CRYPT-1]||
-   xfrma[XFRMA_ALG_COMP-1])
+   if (!xfrma[XFRMA_ALG_AUTH]  ||
+   xfrma[XFRMA_ALG_CRYPT]  ||
+   xfrma[XFRMA_ALG_COMP])
goto out;
break;
 
case IPPROTO_ESP:
-   if ((!xfrma[XFRMA_ALG_AUTH-1] &&
-!xfrma[XFRMA_ALG_CRYPT-1]) ||
-   xfrma[XFRMA_ALG_COMP-1])
+   if ((!xfrma[XFRMA_ALG_AUTH] &&
+!xfrma[XFRMA_ALG_CRYPT])   ||
+   xfrma[XFRMA_ALG_COMP])
goto out;
break;
 
case IPPROTO_COMP:
-   if (!xfrma[XFRMA_ALG_COMP-1]||
-   xfrma[XFRMA_ALG_AUTH-1] ||
-   xfrma[XFRMA_ALG_CRYPT-1])
+   if (!xfrma[XFRMA_ALG_COMP]  ||
+   xfrma[XFRMA_ALG_AUTH]   ||
+   xfrma[XFRMA_ALG_CRYPT])
goto out;
break;
 
 #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
case IPPROTO_DSTOPTS:
case IPPROTO_ROUTING:
-   if (xfrma[XFRMA_ALG_COMP-1] ||
-   xfrma[XFRMA_ALG_AUTH-1] ||
-   xfrma[XFRMA_ALG_CRYPT-1]||
-   xfrma[XFRMA_ENCAP-1]||
-   xfrma[XFRMA_SEC_CTX-1]  ||
-   !xfrma[XFRMA_COADDR-1])
+   if (xfrma[XFRMA_ALG_COMP]   ||
+   xfrma[XFRMA_ALG_AUTH]   ||
+   xfrma[XFRMA_ALG_CRYPT]  ||
+   xfrma[XFRMA_ENCAP]  ||
+   xfrma[XFRMA_SEC_CTX]||
+   !xfrma[XFRMA_COADDR])
goto out;
break;
 #endif
@@ -300,10 +300,10 @@ static void copy_from_user_state(struct 
 */
 static void xfrm_update_ae_params(struct xfrm_state *x, struct rtattr **xfrma)
 {
-   struct rtattr *rp = xfrma[XFRMA_REPLAY_VAL-1];
-   struct rtattr *lt = xfrma[XFRMA_LTIME_VAL-1];
-   struct rtattr *et = xfrma[XFRMA_ETIMER_THRESH-1];
-   struct rtattr *rt = xfrma[XFRMA_REPLAY_THRESH-1];
+   struct rtattr *rp = xfrma[XFRMA_REPLAY_VAL];
+   struct rtattr *lt = xfrma[XFRMA_LTIME_VAL];
+   struct rtattr *et = xfrma[XFRMA_ETIMER_THRESH];
+   struct rtattr *rt = xfrma[XFRMA_REPLAY_THRESH];
 
if (rp) {
struct xfrm_replay_state *replay;
@@ -342,25 +342,25 @@ static struct xfrm_state *xfrm_state_con
 
if ((err = attach_one_algo(&x->aalg, &x->props.aalgo,
   xfrm_aalg_get_byname,
-  xfrma[XFRMA_ALG_AUTH-1])))
+  xfrma[XFRMA_ALG_AUTH])))
goto error;
if ((err = attach_one_algo(&x->ealg, &x->props.ealgo,
   xfrm_ealg_get_byname,
-  xfrma[XFRMA_ALG_CRYPT-1])))
+  xfrma[XFRMA_ALG_CRYPT])))
goto error;
if ((err = attach_one_algo(&x->calg, &x->props.calgo,
   xfrm_calg_get_byname,
-  xfrma[XFRMA_ALG_COMP-1])))
+  xfrma[XFRMA_ALG_COMP])))
goto error;
-   if ((err = attach_encap_tmpl(&x->encap, xfrma[XFRMA_ENCAP-1])))
+   if ((err = at

[PATCH 10/16] [XFRM] netlink: Establish an attribute policy

2007-08-22 Thread Thomas Graf
Adds a policy defining the minimal payload lengths for all the attributes
allowing for most attribute validation checks to be removed from in
the middle of the code path. Makes updates more consistent as many format
errors are recognised earlier, before any changes have been attempted.

Signed-off-by: Thomas Graf <[EMAIL PROTECTED]>

Index: net-2.6.24/net/xfrm/xfrm_user.c
===
--- net-2.6.24.orig/net/xfrm/xfrm_user.c2007-08-21 17:31:04.0 
+0200
+++ net-2.6.24/net/xfrm/xfrm_user.c 2007-08-21 17:31:56.0 +0200
@@ -42,19 +42,12 @@ static int verify_one_alg(struct rtattr 
 {
struct rtattr *rt = xfrma[type - 1];
struct xfrm_algo *algp;
-   int len;
 
if (!rt)
return 0;
 
-   len = (rt->rta_len - sizeof(*rt)) - sizeof(*algp);
-   if (len < 0)
-   return -EINVAL;
-
algp = RTA_DATA(rt);
-
-   len -= (algp->alg_key_len + 7U) / 8;
-   if (len < 0)
+   if (RTA_PAYLOAD(rt) < alg_len(algp))
return -EINVAL;
 
switch (type) {
@@ -82,55 +75,25 @@ static int verify_one_alg(struct rtattr 
return 0;
 }
 
-static int verify_encap_tmpl(struct rtattr **xfrma)
-{
-   struct rtattr *rt = xfrma[XFRMA_ENCAP - 1];
-   struct xfrm_encap_tmpl *encap;
-
-   if (!rt)
-   return 0;
-
-   if ((rt->rta_len - sizeof(*rt)) < sizeof(*encap))
-   return -EINVAL;
-
-   return 0;
-}
-
-static int verify_one_addr(struct rtattr **xfrma, enum xfrm_attr_type_t type,
+static void verify_one_addr(struct rtattr **xfrma, enum xfrm_attr_type_t type,
   xfrm_address_t **addrp)
 {
struct rtattr *rt = xfrma[type - 1];
 
-   if (!rt)
-   return 0;
-
-   if ((rt->rta_len - sizeof(*rt)) < sizeof(**addrp))
-   return -EINVAL;
-
-   if (addrp)
+   if (rt && addrp)
*addrp = RTA_DATA(rt);
-
-   return 0;
 }
 
 static inline int verify_sec_ctx_len(struct rtattr **xfrma)
 {
struct rtattr *rt = xfrma[XFRMA_SEC_CTX - 1];
struct xfrm_user_sec_ctx *uctx;
-   int len = 0;
 
if (!rt)
return 0;
 
-   if (rt->rta_len < sizeof(*uctx))
-   return -EINVAL;
-
uctx = RTA_DATA(rt);
-
-   len += sizeof(struct xfrm_user_sec_ctx);
-   len += uctx->ctx_len;
-
-   if (uctx->len != len)
+   if (uctx->len != (sizeof(struct xfrm_user_sec_ctx) + uctx->ctx_len))
return -EINVAL;
 
return 0;
@@ -205,12 +168,8 @@ static int verify_newsa_info(struct xfrm
goto out;
if ((err = verify_one_alg(xfrma, XFRMA_ALG_COMP)))
goto out;
-   if ((err = verify_encap_tmpl(xfrma)))
-   goto out;
if ((err = verify_sec_ctx_len(xfrma)))
goto out;
-   if ((err = verify_one_addr(xfrma, XFRMA_COADDR, NULL)))
-   goto out;
 
err = -EINVAL;
switch (p->mode) {
@@ -339,9 +298,8 @@ static void copy_from_user_state(struct 
  * somehow made shareable and move it to xfrm_state.c - JHS
  *
 */
-static int xfrm_update_ae_params(struct xfrm_state *x, struct rtattr **xfrma)
+static void xfrm_update_ae_params(struct xfrm_state *x, struct rtattr **xfrma)
 {
-   int err = - EINVAL;
struct rtattr *rp = xfrma[XFRMA_REPLAY_VAL-1];
struct rtattr *lt = xfrma[XFRMA_LTIME_VAL-1];
struct rtattr *et = xfrma[XFRMA_ETIMER_THRESH-1];
@@ -349,8 +307,6 @@ static int xfrm_update_ae_params(struct 
 
if (rp) {
struct xfrm_replay_state *replay;
-   if (RTA_PAYLOAD(rp) < sizeof(*replay))
-   goto error;
replay = RTA_DATA(rp);
memcpy(&x->replay, replay, sizeof(*replay));
memcpy(&x->preplay, replay, sizeof(*replay));
@@ -358,8 +314,6 @@ static int xfrm_update_ae_params(struct 
 
if (lt) {
struct xfrm_lifetime_cur *ltime;
-   if (RTA_PAYLOAD(lt) < sizeof(*ltime))
-   goto error;
ltime = RTA_DATA(lt);
x->curlft.bytes = ltime->bytes;
x->curlft.packets = ltime->packets;
@@ -367,21 +321,11 @@ static int xfrm_update_ae_params(struct 
x->curlft.use_time = ltime->use_time;
}
 
-   if (et) {
-   if (RTA_PAYLOAD(et) < sizeof(u32))
-   goto error;
+   if (et)
x->replay_maxage = *(u32*)RTA_DATA(et);
-   }
 
-   if (rt) {
-   if (RTA_PAYLOAD(rt) < sizeof(u32))
-   goto error;
+   if (rt)
x->replay_maxdiff = *(u32*)RTA_DATA(rt);
-   }
-
-   return 0;
-error:
-   return err;
 }
 
 static struct xfrm_state *xfrm_state_construct(struct xfrm_usersa_info *p,
@@ -429,9 +373,7 @@ static struct xfrm_state *xfrm_state_con
 
/* overrid

[PATCH 14/16] [XFRM] netlink: Use nla_memcpy() in xfrm_update_ae_params()

2007-08-22 Thread Thomas Graf
Signed-off-by: Thomas Graf <[EMAIL PROTECTED]>

Index: net-2.6.24/net/xfrm/xfrm_user.c
===
--- net-2.6.24.orig/net/xfrm/xfrm_user.c2007-08-21 17:35:13.0 
+0200
+++ net-2.6.24/net/xfrm/xfrm_user.c 2007-08-21 17:36:59.0 +0200
@@ -303,20 +303,12 @@ static void xfrm_update_ae_params(struct
struct nlattr *rt = attrs[XFRMA_REPLAY_THRESH];
 
if (rp) {
-   struct xfrm_replay_state *replay;
-   replay = nla_data(rp);
-   memcpy(&x->replay, replay, sizeof(*replay));
-   memcpy(&x->preplay, replay, sizeof(*replay));
+   nla_memcpy(&x->replay, rp, sizeof(x->replay));
+   nla_memcpy(&x->preplay, rp, sizeof(x->preplay));
}
 
-   if (lt) {
-   struct xfrm_lifetime_cur *ltime;
-   ltime = nla_data(lt);
-   x->curlft.bytes = ltime->bytes;
-   x->curlft.packets = ltime->packets;
-   x->curlft.add_time = ltime->add_time;
-   x->curlft.use_time = ltime->use_time;
-   }
+   if (lt)
+   nla_memcpy(&x->curlft, lt, sizeof(x->curlft));
 
if (et)
x->replay_maxage = nla_get_u32(et);

-- 

-
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 06/16] [XFRM] netlink: Move algorithm length calculation to its own function

2007-08-22 Thread Thomas Graf
Adds alg_len() to calculate the properly padded length of an
algorithm attribute to simplify the code.

Signed-off-by: Thomas Graf <[EMAIL PROTECTED]>

Index: net-2.6.24/net/xfrm/xfrm_user.c
===
--- net-2.6.24.orig/net/xfrm/xfrm_user.c2007-08-21 16:16:03.0 
+0200
+++ net-2.6.24/net/xfrm/xfrm_user.c 2007-08-21 17:03:43.0 +0200
@@ -33,6 +33,11 @@
 #endif
 #include 
 
+static inline int alg_len(struct xfrm_algo *alg)
+{
+   return sizeof(*alg) + ((alg->alg_key_len + 7) / 8);
+}
+
 static int verify_one_alg(struct rtattr **xfrma, enum xfrm_attr_type_t type)
 {
struct rtattr *rt = xfrma[type - 1];
@@ -232,7 +237,6 @@ static int attach_one_algo(struct xfrm_a
struct rtattr *rta = u_arg;
struct xfrm_algo *p, *ualg;
struct xfrm_algo_desc *algo;
-   int len;
 
if (!rta)
return 0;
@@ -244,8 +248,7 @@ static int attach_one_algo(struct xfrm_a
return -ENOSYS;
*props = algo->desc.sadb_alg_id;
 
-   len = sizeof(*ualg) + (ualg->alg_key_len + 7U) / 8;
-   p = kmemdup(ualg, len, GFP_KERNEL);
+   p = kmemdup(ualg, alg_len(ualg), GFP_KERNEL);
if (!p)
return -ENOMEM;
 
@@ -617,11 +620,9 @@ static int dump_one_state(struct xfrm_st
copy_to_user_state(x, p);
 
if (x->aalg)
-   NLA_PUT(skb, XFRMA_ALG_AUTH,
-   sizeof(*(x->aalg))+(x->aalg->alg_key_len+7)/8, x->aalg);
+   NLA_PUT(skb, XFRMA_ALG_AUTH, alg_len(x->aalg), x->aalg);
if (x->ealg)
-   NLA_PUT(skb, XFRMA_ALG_CRYPT,
-   sizeof(*(x->ealg))+(x->ealg->alg_key_len+7)/8, x->ealg);
+   NLA_PUT(skb, XFRMA_ALG_CRYPT, alg_len(x->ealg), x->ealg);
if (x->calg)
NLA_PUT(skb, XFRMA_ALG_COMP, sizeof(*(x->calg)), x->calg);
 
@@ -2072,9 +2073,9 @@ static inline int xfrm_sa_len(struct xfr
 {
int l = 0;
if (x->aalg)
-   l += RTA_SPACE(sizeof(*x->aalg) + (x->aalg->alg_key_len+7)/8);
+   l += RTA_SPACE(alg_len(x->aalg));
if (x->ealg)
-   l += RTA_SPACE(sizeof(*x->ealg) + (x->ealg->alg_key_len+7)/8);
+   l += RTA_SPACE(alg_len(x->ealg));
if (x->calg)
l += RTA_SPACE(sizeof(*x->calg));
if (x->encap)
@@ -2127,11 +2128,9 @@ static int xfrm_notify_sa(struct xfrm_st
copy_to_user_state(x, p);
 
if (x->aalg)
-   NLA_PUT(skb, XFRMA_ALG_AUTH,
-   sizeof(*(x->aalg))+(x->aalg->alg_key_len+7)/8, x->aalg);
+   NLA_PUT(skb, XFRMA_ALG_AUTH, alg_len(x->aalg), x->aalg);
if (x->ealg)
-   NLA_PUT(skb, XFRMA_ALG_CRYPT,
-   sizeof(*(x->ealg))+(x->ealg->alg_key_len+7)/8, x->ealg);
+   NLA_PUT(skb, XFRMA_ALG_CRYPT, alg_len(x->ealg), x->ealg);
if (x->calg)
NLA_PUT(skb, XFRMA_ALG_COMP, sizeof(*(x->calg)), x->calg);
 

-- 

-
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 12/16] [XFRM] netlink: Rename attribyte array from xfrma[] to attrs[]

2007-08-22 Thread Thomas Graf
Increases readability a lot.

Signed-off-by: Thomas Graf <[EMAIL PROTECTED]>

Index: net-2.6.24/net/xfrm/xfrm_user.c
===
--- net-2.6.24.orig/net/xfrm/xfrm_user.c2007-08-21 17:34:10.0 
+0200
+++ net-2.6.24/net/xfrm/xfrm_user.c 2007-08-21 17:34:29.0 +0200
@@ -38,9 +38,9 @@ static inline int alg_len(struct xfrm_al
return sizeof(*alg) + ((alg->alg_key_len + 7) / 8);
 }
 
-static int verify_one_alg(struct rtattr **xfrma, enum xfrm_attr_type_t type)
+static int verify_one_alg(struct rtattr **attrs, enum xfrm_attr_type_t type)
 {
-   struct rtattr *rt = xfrma[type];
+   struct rtattr *rt = attrs[type];
struct xfrm_algo *algp;
 
if (!rt)
@@ -75,18 +75,18 @@ static int verify_one_alg(struct rtattr 
return 0;
 }
 
-static void verify_one_addr(struct rtattr **xfrma, enum xfrm_attr_type_t type,
+static void verify_one_addr(struct rtattr **attrs, enum xfrm_attr_type_t type,
   xfrm_address_t **addrp)
 {
-   struct rtattr *rt = xfrma[type];
+   struct rtattr *rt = attrs[type];
 
if (rt && addrp)
*addrp = RTA_DATA(rt);
 }
 
-static inline int verify_sec_ctx_len(struct rtattr **xfrma)
+static inline int verify_sec_ctx_len(struct rtattr **attrs)
 {
-   struct rtattr *rt = xfrma[XFRMA_SEC_CTX];
+   struct rtattr *rt = attrs[XFRMA_SEC_CTX];
struct xfrm_user_sec_ctx *uctx;
 
if (!rt)
@@ -101,7 +101,7 @@ static inline int verify_sec_ctx_len(str
 
 
 static int verify_newsa_info(struct xfrm_usersa_info *p,
-struct rtattr **xfrma)
+struct rtattr **attrs)
 {
int err;
 
@@ -125,35 +125,35 @@ static int verify_newsa_info(struct xfrm
err = -EINVAL;
switch (p->id.proto) {
case IPPROTO_AH:
-   if (!xfrma[XFRMA_ALG_AUTH]  ||
-   xfrma[XFRMA_ALG_CRYPT]  ||
-   xfrma[XFRMA_ALG_COMP])
+   if (!attrs[XFRMA_ALG_AUTH]  ||
+   attrs[XFRMA_ALG_CRYPT]  ||
+   attrs[XFRMA_ALG_COMP])
goto out;
break;
 
case IPPROTO_ESP:
-   if ((!xfrma[XFRMA_ALG_AUTH] &&
-!xfrma[XFRMA_ALG_CRYPT])   ||
-   xfrma[XFRMA_ALG_COMP])
+   if ((!attrs[XFRMA_ALG_AUTH] &&
+!attrs[XFRMA_ALG_CRYPT])   ||
+   attrs[XFRMA_ALG_COMP])
goto out;
break;
 
case IPPROTO_COMP:
-   if (!xfrma[XFRMA_ALG_COMP]  ||
-   xfrma[XFRMA_ALG_AUTH]   ||
-   xfrma[XFRMA_ALG_CRYPT])
+   if (!attrs[XFRMA_ALG_COMP]  ||
+   attrs[XFRMA_ALG_AUTH]   ||
+   attrs[XFRMA_ALG_CRYPT])
goto out;
break;
 
 #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
case IPPROTO_DSTOPTS:
case IPPROTO_ROUTING:
-   if (xfrma[XFRMA_ALG_COMP]   ||
-   xfrma[XFRMA_ALG_AUTH]   ||
-   xfrma[XFRMA_ALG_CRYPT]  ||
-   xfrma[XFRMA_ENCAP]  ||
-   xfrma[XFRMA_SEC_CTX]||
-   !xfrma[XFRMA_COADDR])
+   if (attrs[XFRMA_ALG_COMP]   ||
+   attrs[XFRMA_ALG_AUTH]   ||
+   attrs[XFRMA_ALG_CRYPT]  ||
+   attrs[XFRMA_ENCAP]  ||
+   attrs[XFRMA_SEC_CTX]||
+   !attrs[XFRMA_COADDR])
goto out;
break;
 #endif
@@ -162,13 +162,13 @@ static int verify_newsa_info(struct xfrm
goto out;
}
 
-   if ((err = verify_one_alg(xfrma, XFRMA_ALG_AUTH)))
+   if ((err = verify_one_alg(attrs, XFRMA_ALG_AUTH)))
goto out;
-   if ((err = verify_one_alg(xfrma, XFRMA_ALG_CRYPT)))
+   if ((err = verify_one_alg(attrs, XFRMA_ALG_CRYPT)))
goto out;
-   if ((err = verify_one_alg(xfrma, XFRMA_ALG_COMP)))
+   if ((err = verify_one_alg(attrs, XFRMA_ALG_COMP)))
goto out;
-   if ((err = verify_sec_ctx_len(xfrma)))
+   if ((err = verify_sec_ctx_len(attrs)))
goto out;
 
err = -EINVAL;
@@ -298,12 +298,12 @@ static void copy_from_user_state(struct 
  * somehow made shareable and move it to xfrm_state.c - JHS
  *
 */
-static void xfrm_update_ae_params(struct xfrm_state *x, struct rtattr **xfrma)
+static void xfrm_update_ae_params(struct xfrm_state *x, struct rtattr **attrs)
 {
-   struct rtattr *rp = xfrma[XFRMA_REPLAY_VAL];
-   struct rtattr *lt = xfrma[XFRMA_LTIME_VAL];
-   struct rtattr *et = xfrma[XFRMA_ETIMER_THRESH];
-   struct rtattr *rt = xfrma[XFRMA_REPLAY_THRESH];
+   struct rtattr *rp = attrs[XFRMA_REPLAY_VA

[PATCH 02/16] [XFRM] netlink: Use nlmsg_end() and nlmsg_cancel()

2007-08-22 Thread Thomas Graf
Signed-off-by: Thomas Graf <[EMAIL PROTECTED]>

Index: net-2.6.24/net/xfrm/xfrm_user.c
===
--- net-2.6.24.orig/net/xfrm/xfrm_user.c2007-08-21 16:10:34.0 
+0200
+++ net-2.6.24/net/xfrm/xfrm_user.c 2007-08-21 16:12:20.0 +0200
@@ -583,7 +583,6 @@ static int dump_one_state(struct xfrm_st
struct sk_buff *skb = sp->out_skb;
struct xfrm_usersa_info *p;
struct nlmsghdr *nlh;
-   unsigned char *b = skb_tail_pointer(skb);
 
if (sp->this_idx < sp->start_idx)
goto out;
@@ -628,14 +627,14 @@ static int dump_one_state(struct xfrm_st
if (x->lastused)
RTA_PUT(skb, XFRMA_LASTUSED, sizeof(x->lastused), &x->lastused);
 
-   nlh->nlmsg_len = skb_tail_pointer(skb) - b;
+   nlmsg_end(skb, nlh);
 out:
sp->this_idx++;
return 0;
 
 rtattr_failure:
-   nlmsg_trim(skb, b);
-   return -1;
+   nlmsg_cancel(skb, nlh);
+   return -EMSGSIZE;
 }
 
 static int xfrm_dump_sa(struct sk_buff *skb, struct netlink_callback *cb)
@@ -1270,7 +1269,6 @@ static int dump_one_policy(struct xfrm_p
struct sk_buff *in_skb = sp->in_skb;
struct sk_buff *skb = sp->out_skb;
struct nlmsghdr *nlh;
-   unsigned char *b = skb_tail_pointer(skb);
 
if (sp->this_idx < sp->start_idx)
goto out;
@@ -1289,14 +1287,14 @@ static int dump_one_policy(struct xfrm_p
if (copy_to_user_policy_type(xp->type, skb) < 0)
goto nlmsg_failure;
 
-   nlh->nlmsg_len = skb_tail_pointer(skb) - b;
+   nlmsg_end(skb, nlh);
 out:
sp->this_idx++;
return 0;
 
 nlmsg_failure:
-   nlmsg_trim(skb, b);
-   return -1;
+   nlmsg_cancel(skb, nlh);
+   return -EMSGSIZE;
 }
 
 static int xfrm_dump_policy(struct sk_buff *skb, struct netlink_callback *cb)
@@ -1446,7 +1444,6 @@ static int build_aevent(struct sk_buff *
struct xfrm_aevent_id *id;
struct nlmsghdr *nlh;
struct xfrm_lifetime_cur ltime;
-   unsigned char *b = skb_tail_pointer(skb);
 
nlh = nlmsg_put(skb, c->pid, c->seq, XFRM_MSG_NEWAE, sizeof(*id), 0);
if (nlh == NULL)
@@ -1479,12 +1476,11 @@ static int build_aevent(struct sk_buff *
RTA_PUT(skb,XFRMA_ETIMER_THRESH,sizeof(u32),&etimer);
}
 
-   nlh->nlmsg_len = skb_tail_pointer(skb) - b;
-   return skb->len;
+   return nlmsg_end(skb, nlh);
 
 rtattr_failure:
-   nlmsg_trim(skb, b);
-   return -1;
+   nlmsg_cancel(skb, nlh);
+   return -EMSGSIZE;
 }
 
 static int xfrm_get_ae(struct sk_buff *skb, struct nlmsghdr *nlh,
@@ -1862,7 +1858,6 @@ static int build_migrate(struct sk_buff 
struct xfrm_migrate *mp;
struct xfrm_userpolicy_id *pol_id;
struct nlmsghdr *nlh;
-   unsigned char *b = skb_tail_pointer(skb);
int i;
 
nlh = nlmsg_put(skb, 0, 0, XFRM_MSG_MIGRATE, sizeof(*pol_id), 0);
@@ -1883,11 +1878,10 @@ static int build_migrate(struct sk_buff 
goto nlmsg_failure;
}
 
-   nlh->nlmsg_len = skb_tail_pointer(skb) - b;
-   return skb->len;
+   return nlmsg_end(skb, nlh);
 nlmsg_failure:
-   nlmsg_trim(skb, b);
-   return -1;
+   nlmsg_cancel(skb, nlh);
+   return -EMSGSIZE;
 }
 
 static int xfrm_send_migrate(struct xfrm_selector *sel, u8 dir, u8 type,
@@ -2043,7 +2037,6 @@ static int build_expire(struct sk_buff *
 {
struct xfrm_user_expire *ue;
struct nlmsghdr *nlh;
-   unsigned char *b = skb_tail_pointer(skb);
 
nlh = nlmsg_put(skb, c->pid, 0, XFRM_MSG_EXPIRE, sizeof(*ue), 0);
if (nlh == NULL)
@@ -2053,8 +2046,7 @@ static int build_expire(struct sk_buff *
copy_to_user_state(x, &ue->state);
ue->hard = (c->data.hard != 0) ? 1 : 0;
 
-   nlh->nlmsg_len = skb_tail_pointer(skb) - b;
-   return skb->len;
+   return nlmsg_end(skb, nlh);
 }
 
 static int xfrm_exp_state_notify(struct xfrm_state *x, struct km_event *c)
@@ -2096,13 +2088,11 @@ static int xfrm_notify_sa_flush(struct k
struct xfrm_usersa_flush *p;
struct nlmsghdr *nlh;
struct sk_buff *skb;
-   sk_buff_data_t b;
int len = NLMSG_LENGTH(sizeof(struct xfrm_usersa_flush));
 
skb = alloc_skb(len, GFP_ATOMIC);
if (skb == NULL)
return -ENOMEM;
-   b = skb->tail;
 
nlh = nlmsg_put(skb, c->pid, c->seq, XFRM_MSG_FLUSHSA, sizeof(*p), 0);
if (nlh == NULL) {
@@ -2113,7 +2103,7 @@ static int xfrm_notify_sa_flush(struct k
p = NLMSG_DATA(nlh);
p->proto = c->data.proto;
 
-   nlh->nlmsg_len = skb->tail - b;
+   nlmsg_end(skb, nlh);
 
NETLINK_CB(skb).dst_group = XFRMNLGRP_SA;
return netlink_broadcast(xfrm_nl, skb, 0, XFRMNLGRP_SA, GFP_ATOMIC);
@@ -2140,7 +2130,6 @@ static int xfrm_notify_sa(struct xfrm_st
struct xfrm_usersa_id *id;
struct nlmsghdr *n

[PATCH 16/16] [XFRM] netlink: Inline attach_encap_tmpl(), attach_sec_ctx(), and attach_one_addr()

2007-08-22 Thread Thomas Graf
These functions are only used once and are a lot easier to understand if
inlined directly into the function.

Signed-off-by: Thomas Graf <[EMAIL PROTECTED]>

Index: net-2.6.24/net/xfrm/xfrm_user.c
===
--- net-2.6.24.orig/net/xfrm/xfrm_user.c2007-08-21 23:05:30.0 
+0200
+++ net-2.6.24/net/xfrm/xfrm_user.c 2007-08-22 16:45:31.0 +0200
@@ -214,23 +214,6 @@ static int attach_one_algo(struct xfrm_a
return 0;
 }
 
-static int attach_encap_tmpl(struct xfrm_encap_tmpl **encapp, struct nlattr 
*rta)
-{
-   struct xfrm_encap_tmpl *p, *uencap;
-
-   if (!rta)
-   return 0;
-
-   uencap = nla_data(rta);
-   p = kmemdup(uencap, sizeof(*p), GFP_KERNEL);
-   if (!p)
-   return -ENOMEM;
-
-   *encapp = p;
-   return 0;
-}
-
-
 static inline int xfrm_user_sec_ctx_size(struct xfrm_sec_ctx *xfrm_ctx)
 {
int len = 0;
@@ -242,33 +225,6 @@ static inline int xfrm_user_sec_ctx_size
return len;
 }
 
-static int attach_sec_ctx(struct xfrm_state *x, struct nlattr *u_arg)
-{
-   struct xfrm_user_sec_ctx *uctx;
-
-   if (!u_arg)
-   return 0;
-
-   uctx = nla_data(u_arg);
-   return security_xfrm_state_alloc(x, uctx);
-}
-
-static int attach_one_addr(xfrm_address_t **addrpp, struct nlattr *rta)
-{
-   xfrm_address_t *p, *uaddrp;
-
-   if (!rta)
-   return 0;
-
-   uaddrp = nla_data(rta);
-   p = kmemdup(uaddrp, sizeof(*p), GFP_KERNEL);
-   if (!p)
-   return -ENOMEM;
-
-   *addrpp = p;
-   return 0;
-}
-
 static void copy_from_user_state(struct xfrm_state *x, struct xfrm_usersa_info 
*p)
 {
memcpy(&x->id, &p->id, sizeof(x->id));
@@ -340,15 +296,27 @@ static struct xfrm_state *xfrm_state_con
   xfrm_calg_get_byname,
   attrs[XFRMA_ALG_COMP])))
goto error;
-   if ((err = attach_encap_tmpl(&x->encap, attrs[XFRMA_ENCAP])))
-   goto error;
-   if ((err = attach_one_addr(&x->coaddr, attrs[XFRMA_COADDR])))
-   goto error;
+
+   if (attrs[XFRMA_ENCAP]) {
+   x->encap = kmemdup(nla_data(attrs[XFRMA_ENCAP]),
+  sizeof(x->encap), GFP_KERNEL);
+   if (x->encap == NULL)
+   goto error;
+   }
+
+   if (attrs[XFRMA_COADDR]) {
+   x->coaddr = kmemdup(nla_data(attrs[XFRMA_COADDR]),
+   sizeof(x->coaddr), GFP_KERNEL);
+   if (x->coaddr == NULL)
+   goto error;
+   }
+
err = xfrm_init_state(x);
if (err)
goto error;
 
-   if ((err = attach_sec_ctx(x, attrs[XFRMA_SEC_CTX])))
+   if (attrs[XFRMA_SEC_CTX] &&
+   security_xfrm_state_alloc(x, nla_data(attrs[XFRMA_SEC_CTX])))
goto error;
 
x->km.seq = p->seq;

-- 

-
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 09/16] [XFRM] netlink: Use nlmsg_parse() to parse attributes

2007-08-22 Thread Thomas Graf
Uses nlmsg_parse() to parse the attributes. This actually changes
behaviour as unknown attributes (type > MAXTYPE) no longer cause
an error. Instead unknown attributes will be ignored henceforth
to keep older kernels compatible with more recent userspace tools.

Signed-off-by: Thomas Graf <[EMAIL PROTECTED]>

Index: net-2.6.24/net/xfrm/xfrm_user.c
===
--- net-2.6.24.orig/net/xfrm/xfrm_user.c2007-08-21 17:07:38.0 
+0200
+++ net-2.6.24/net/xfrm/xfrm_user.c 2007-08-21 17:31:04.0 +0200
@@ -1890,7 +1890,7 @@ static int xfrm_send_migrate(struct xfrm
 }
 #endif
 
-#define XMSGSIZE(type) NLMSG_LENGTH(sizeof(struct type))
+#define XMSGSIZE(type) sizeof(struct type)
 
 static const int xfrm_msg_min[XFRM_NR_MSGTYPES] = {
[XFRM_MSG_NEWSA   - XFRM_MSG_BASE] = XMSGSIZE(xfrm_usersa_info),
@@ -1906,13 +1906,13 @@ static const int xfrm_msg_min[XFRM_NR_MS
[XFRM_MSG_UPDSA   - XFRM_MSG_BASE] = XMSGSIZE(xfrm_usersa_info),
[XFRM_MSG_POLEXPIRE   - XFRM_MSG_BASE] = XMSGSIZE(xfrm_user_polexpire),
[XFRM_MSG_FLUSHSA - XFRM_MSG_BASE] = XMSGSIZE(xfrm_usersa_flush),
-   [XFRM_MSG_FLUSHPOLICY - XFRM_MSG_BASE] = NLMSG_LENGTH(0),
+   [XFRM_MSG_FLUSHPOLICY - XFRM_MSG_BASE] = 0,
[XFRM_MSG_NEWAE   - XFRM_MSG_BASE] = XMSGSIZE(xfrm_aevent_id),
[XFRM_MSG_GETAE   - XFRM_MSG_BASE] = XMSGSIZE(xfrm_aevent_id),
[XFRM_MSG_REPORT  - XFRM_MSG_BASE] = XMSGSIZE(xfrm_user_report),
[XFRM_MSG_MIGRATE - XFRM_MSG_BASE] = XMSGSIZE(xfrm_userpolicy_id),
-   [XFRM_MSG_GETSADINFO  - XFRM_MSG_BASE] = NLMSG_LENGTH(sizeof(u32)),
-   [XFRM_MSG_GETSPDINFO  - XFRM_MSG_BASE] = NLMSG_LENGTH(sizeof(u32)),
+   [XFRM_MSG_GETSADINFO  - XFRM_MSG_BASE] = sizeof(u32),
+   [XFRM_MSG_GETSPDINFO  - XFRM_MSG_BASE] = sizeof(u32),
 };
 
 #undef XMSGSIZE
@@ -1946,9 +1946,9 @@ static struct xfrm_link {
 
 static int xfrm_user_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
 {
-   struct rtattr *xfrma[XFRMA_MAX];
+   struct nlattr *xfrma[XFRMA_MAX+1];
struct xfrm_link *link;
-   int type, min_len;
+   int type, err;
 
type = nlh->nlmsg_type;
if (type > XFRM_MSG_MAX)
@@ -1970,30 +1970,16 @@ static int xfrm_user_rcv_msg(struct sk_b
return netlink_dump_start(xfrm_nl, skb, nlh, link->dump, NULL);
}
 
-   memset(xfrma, 0, sizeof(xfrma));
-
-   if (nlh->nlmsg_len < (min_len = xfrm_msg_min[type]))
-   return -EINVAL;
-
-   if (nlh->nlmsg_len > min_len) {
-   int attrlen = nlh->nlmsg_len - NLMSG_ALIGN(min_len);
-   struct rtattr *attr = (void *) nlh + NLMSG_ALIGN(min_len);
-
-   while (RTA_OK(attr, attrlen)) {
-   unsigned short flavor = attr->rta_type;
-   if (flavor) {
-   if (flavor > XFRMA_MAX)
-   return -EINVAL;
-   xfrma[flavor - 1] = attr;
-   }
-   attr = RTA_NEXT(attr, attrlen);
-   }
-   }
+   /* FIXME: Temporary hack, nlmsg_parse() starts at xfrma[1], old code
+* expects first attribute at xfrma[0] */
+   err = nlmsg_parse(nlh, xfrm_msg_min[type], xfrma-1, XFRMA_MAX, NULL);
+   if (err < 0)
+   return err;
 
if (link->doit == NULL)
return -EINVAL;
 
-   return link->doit(skb, nlh, xfrma);
+   return link->doit(skb, nlh, (struct rtattr **) xfrma);
 }
 
 static void xfrm_netlink_rcv(struct sock *sk, int len)

-- 

-
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 08/16] [XFRM] netlink: Use nlmsg_new() and type-safe size calculation helpers

2007-08-22 Thread Thomas Graf
Moves all complex message size calculation into own inlined helper
functions and makes use of the type-safe netlink interface.

Using nlmsg_new() simplifies the calculation itself as it takes care
of the netlink header length by itself.

Signed-off-by: Thomas Graf <[EMAIL PROTECTED]>

Index: net-2.6.24/net/xfrm/xfrm_user.c
===
--- net-2.6.24.orig/net/xfrm/xfrm_user.c2007-08-21 17:04:46.0 
+0200
+++ net-2.6.24/net/xfrm/xfrm_user.c 2007-08-21 17:07:38.0 +0200
@@ -670,7 +670,7 @@ static struct sk_buff *xfrm_state_netlin
struct xfrm_dump_info info;
struct sk_buff *skb;
 
-   skb = alloc_skb(NLMSG_GOODSIZE, GFP_ATOMIC);
+   skb = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_ATOMIC);
if (!skb)
return ERR_PTR(-ENOMEM);
 
@@ -688,6 +688,13 @@ static struct sk_buff *xfrm_state_netlin
return skb;
 }
 
+static inline size_t xfrm_spdinfo_msgsize(void)
+{
+   return NLMSG_ALIGN(4)
+  + nla_total_size(sizeof(struct xfrmu_spdinfo))
+  + nla_total_size(sizeof(struct xfrmu_spdhinfo));
+}
+
 static int build_spdinfo(struct sk_buff *skb, u32 pid, u32 seq, u32 flags)
 {
struct xfrmk_spdinfo si;
@@ -729,12 +736,8 @@ static int xfrm_get_spdinfo(struct sk_bu
u32 *flags = nlmsg_data(nlh);
u32 spid = NETLINK_CB(skb).pid;
u32 seq = nlh->nlmsg_seq;
-   int len = NLMSG_LENGTH(sizeof(u32));
 
-   len += RTA_SPACE(sizeof(struct xfrmu_spdinfo));
-   len += RTA_SPACE(sizeof(struct xfrmu_spdhinfo));
-
-   r_skb = alloc_skb(len, GFP_ATOMIC);
+   r_skb = nlmsg_new(xfrm_spdinfo_msgsize(), GFP_ATOMIC);
if (r_skb == NULL)
return -ENOMEM;
 
@@ -744,6 +747,13 @@ static int xfrm_get_spdinfo(struct sk_bu
return nlmsg_unicast(xfrm_nl, r_skb, spid);
 }
 
+static inline size_t xfrm_sadinfo_msgsize(void)
+{
+   return NLMSG_ALIGN(4)
+  + nla_total_size(sizeof(struct xfrmu_sadhinfo))
+  + nla_total_size(4); /* XFRMA_SAD_CNT */
+}
+
 static int build_sadinfo(struct sk_buff *skb, u32 pid, u32 seq, u32 flags)
 {
struct xfrmk_sadinfo si;
@@ -779,13 +789,8 @@ static int xfrm_get_sadinfo(struct sk_bu
u32 *flags = nlmsg_data(nlh);
u32 spid = NETLINK_CB(skb).pid;
u32 seq = nlh->nlmsg_seq;
-   int len = NLMSG_LENGTH(sizeof(u32));
-
-   len += RTA_SPACE(sizeof(struct xfrmu_sadhinfo));
-   len += RTA_SPACE(sizeof(u32));
-
-   r_skb = alloc_skb(len, GFP_ATOMIC);
 
+   r_skb = nlmsg_new(xfrm_sadinfo_msgsize(), GFP_ATOMIC);
if (r_skb == NULL)
return -ENOMEM;
 
@@ -1311,7 +1316,7 @@ static struct sk_buff *xfrm_policy_netli
struct xfrm_dump_info info;
struct sk_buff *skb;
 
-   skb = alloc_skb(NLMSG_GOODSIZE, GFP_KERNEL);
+   skb = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
if (!skb)
return ERR_PTR(-ENOMEM);
 
@@ -1425,6 +1430,14 @@ static int xfrm_flush_sa(struct sk_buff 
return 0;
 }
 
+static inline size_t xfrm_aevent_msgsize(void)
+{
+   return NLMSG_ALIGN(sizeof(struct xfrm_aevent_id))
+  + nla_total_size(sizeof(struct xfrm_replay_state))
+  + nla_total_size(sizeof(struct xfrm_lifetime_cur))
+  + nla_total_size(4) /* XFRM_AE_RTHR */
+  + nla_total_size(4); /* XFRM_AE_ETHR */
+}
 
 static int build_aevent(struct sk_buff *skb, struct xfrm_state *x, struct 
km_event *c)
 {
@@ -1469,19 +1482,9 @@ static int xfrm_get_ae(struct sk_buff *s
int err;
struct km_event c;
struct xfrm_aevent_id *p = nlmsg_data(nlh);
-   int len = NLMSG_LENGTH(sizeof(struct xfrm_aevent_id));
struct xfrm_usersa_id *id = &p->sa_id;
 
-   len += RTA_SPACE(sizeof(struct xfrm_replay_state));
-   len += RTA_SPACE(sizeof(struct xfrm_lifetime_cur));
-
-   if (p->flags&XFRM_AE_RTHR)
-   len+=RTA_SPACE(sizeof(u32));
-
-   if (p->flags&XFRM_AE_ETHR)
-   len+=RTA_SPACE(sizeof(u32));
-
-   r_skb = alloc_skb(len, GFP_ATOMIC);
+   r_skb = nlmsg_new(xfrm_aevent_msgsize(), GFP_ATOMIC);
if (r_skb == NULL)
return -ENOMEM;
 
@@ -1824,6 +1827,13 @@ static int copy_to_user_migrate(struct x
return nla_put(skb, XFRMA_MIGRATE, sizeof(um), &um);
 }
 
+static inline size_t xfrm_migrate_msgsize(int num_migrate)
+{
+   return NLMSG_ALIGN(sizeof(struct xfrm_userpolicy_id))
+  + nla_total_size(sizeof(struct xfrm_user_migrate) * num_migrate)
+  + userpolicy_type_attrsize();
+}
+
 static int build_migrate(struct sk_buff *skb, struct xfrm_migrate *m,
 int num_migrate, struct xfrm_selector *sel,
 u8 dir, u8 type)
@@ -1861,12 +1871,8 @@ static int xfrm_send_migrate(struct xfrm
 struct xfrm_migrate *m, int num_migrate)
 {
struct sk_buff *skb;
-   siz

[PATCH 00/16] xfrm netlink interface cleanups

2007-08-22 Thread Thomas Graf
This patchset converts the xfrm netlink bits over to the type
safe netlink interface and does some cleanups.

 xfrm_user.c | 1041 
 1 file changed, 433 insertions(+), 608 deletions(-)

-
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/16] [XFRM] netlink: Use nlmsg_put() instead of NLMSG_PUT()

2007-08-22 Thread Thomas Graf
Signed-off-by: Thomas Graf <[EMAIL PROTECTED]>

Index: net-2.6.24/net/xfrm/xfrm_user.c
===
--- net-2.6.24.orig/net/xfrm/xfrm_user.c2007-08-20 17:09:48.0 
+0200
+++ net-2.6.24/net/xfrm/xfrm_user.c 2007-08-21 16:10:34.0 +0200
@@ -588,10 +588,10 @@ static int dump_one_state(struct xfrm_st
if (sp->this_idx < sp->start_idx)
goto out;
 
-   nlh = NLMSG_PUT(skb, NETLINK_CB(in_skb).pid,
-   sp->nlmsg_seq,
-   XFRM_MSG_NEWSA, sizeof(*p));
-   nlh->nlmsg_flags = sp->nlmsg_flags;
+   nlh = nlmsg_put(skb, NETLINK_CB(in_skb).pid, sp->nlmsg_seq,
+   XFRM_MSG_NEWSA, sizeof(*p), sp->nlmsg_flags);
+   if (nlh == NULL)
+   return -EMSGSIZE;
 
p = NLMSG_DATA(nlh);
copy_to_user_state(x, p);
@@ -633,7 +633,6 @@ out:
sp->this_idx++;
return 0;
 
-nlmsg_failure:
 rtattr_failure:
nlmsg_trim(skb, b);
return -1;
@@ -1276,11 +1275,11 @@ static int dump_one_policy(struct xfrm_p
if (sp->this_idx < sp->start_idx)
goto out;
 
-   nlh = NLMSG_PUT(skb, NETLINK_CB(in_skb).pid,
-   sp->nlmsg_seq,
-   XFRM_MSG_NEWPOLICY, sizeof(*p));
+   nlh = nlmsg_put(skb, NETLINK_CB(in_skb).pid, sp->nlmsg_seq,
+   XFRM_MSG_NEWPOLICY, sizeof(*p), sp->nlmsg_flags);
+   if (nlh == NULL)
+   return -EMSGSIZE;
p = NLMSG_DATA(nlh);
-   nlh->nlmsg_flags = sp->nlmsg_flags;
 
copy_to_user_policy(xp, p, dir);
if (copy_to_user_tmpl(xp, skb) < 0)
@@ -1449,9 +1448,10 @@ static int build_aevent(struct sk_buff *
struct xfrm_lifetime_cur ltime;
unsigned char *b = skb_tail_pointer(skb);
 
-   nlh = NLMSG_PUT(skb, c->pid, c->seq, XFRM_MSG_NEWAE, sizeof(*id));
+   nlh = nlmsg_put(skb, c->pid, c->seq, XFRM_MSG_NEWAE, sizeof(*id), 0);
+   if (nlh == NULL)
+   return -EMSGSIZE;
id = NLMSG_DATA(nlh);
-   nlh->nlmsg_flags = 0;
 
memcpy(&id->sa_id.daddr, &x->id.daddr,sizeof(x->id.daddr));
id->sa_id.spi = x->id.spi;
@@ -1483,7 +1483,6 @@ static int build_aevent(struct sk_buff *
return skb->len;
 
 rtattr_failure:
-nlmsg_failure:
nlmsg_trim(skb, b);
return -1;
 }
@@ -1866,9 +1865,10 @@ static int build_migrate(struct sk_buff 
unsigned char *b = skb_tail_pointer(skb);
int i;
 
-   nlh = NLMSG_PUT(skb, 0, 0, XFRM_MSG_MIGRATE, sizeof(*pol_id));
+   nlh = nlmsg_put(skb, 0, 0, XFRM_MSG_MIGRATE, sizeof(*pol_id), 0);
+   if (nlh == NULL)
+   return -EMSGSIZE;
pol_id = NLMSG_DATA(nlh);
-   nlh->nlmsg_flags = 0;
 
/* copy data from selector, dir, and type to the pol_id */
memset(pol_id, 0, sizeof(*pol_id));
@@ -2045,20 +2045,16 @@ static int build_expire(struct sk_buff *
struct nlmsghdr *nlh;
unsigned char *b = skb_tail_pointer(skb);
 
-   nlh = NLMSG_PUT(skb, c->pid, 0, XFRM_MSG_EXPIRE,
-   sizeof(*ue));
+   nlh = nlmsg_put(skb, c->pid, 0, XFRM_MSG_EXPIRE, sizeof(*ue), 0);
+   if (nlh == NULL)
+   return -EMSGSIZE;
ue = NLMSG_DATA(nlh);
-   nlh->nlmsg_flags = 0;
 
copy_to_user_state(x, &ue->state);
ue->hard = (c->data.hard != 0) ? 1 : 0;
 
nlh->nlmsg_len = skb_tail_pointer(skb) - b;
return skb->len;
-
-nlmsg_failure:
-   nlmsg_trim(skb, b);
-   return -1;
 }
 
 static int xfrm_exp_state_notify(struct xfrm_state *x, struct km_event *c)
@@ -2108,9 +2104,11 @@ static int xfrm_notify_sa_flush(struct k
return -ENOMEM;
b = skb->tail;
 
-   nlh = NLMSG_PUT(skb, c->pid, c->seq,
-   XFRM_MSG_FLUSHSA, sizeof(*p));
-   nlh->nlmsg_flags = 0;
+   nlh = nlmsg_put(skb, c->pid, c->seq, XFRM_MSG_FLUSHSA, sizeof(*p), 0);
+   if (nlh == NULL) {
+   kfree_skb(skb);
+   return -EMSGSIZE;
+   }
 
p = NLMSG_DATA(nlh);
p->proto = c->data.proto;
@@ -2119,10 +2117,6 @@ static int xfrm_notify_sa_flush(struct k
 
NETLINK_CB(skb).dst_group = XFRMNLGRP_SA;
return netlink_broadcast(xfrm_nl, skb, 0, XFRMNLGRP_SA, GFP_ATOMIC);
-
-nlmsg_failure:
-   kfree_skb(skb);
-   return -1;
 }
 
 static inline int xfrm_sa_len(struct xfrm_state *x)
@@ -2162,8 +2156,9 @@ static int xfrm_notify_sa(struct xfrm_st
return -ENOMEM;
b = skb->tail;
 
-   nlh = NLMSG_PUT(skb, c->pid, c->seq, c->event, headlen);
-   nlh->nlmsg_flags = 0;
+   nlh = nlmsg_put(skb, c->pid, c->seq, c->event, headlen, 0);
+   if (nlh == NULL)
+   goto nlmsg_failure;
 
p = NLMSG_DATA(nlh);
if (c->event == XFRM_MSG_DELSA) {
@@ -2233,10 +2228,10 @@ static int build_acquire(struct sk_buff 
unsigned char *b = skb_tail_pointe

[PATCH] [07/10] pasemi_mac: Enable LLTX

2007-08-22 Thread Olof Johansson
Enable LLTX on pasemi_mac: we're already doing sufficient locking
in the driver to enable it.


Signed-off-by: Olof Johansson <[EMAIL PROTECTED]>

Index: mainline/drivers/net/pasemi_mac.c
===
--- mainline.orig/drivers/net/pasemi_mac.c
+++ mainline/drivers/net/pasemi_mac.c
@@ -1235,7 +1235,7 @@ pasemi_mac_probe(struct pci_dev *pdev, c
dev->set_multicast_list = pasemi_mac_set_rx_mode;
dev->weight = 64;
dev->poll = pasemi_mac_poll;
-   dev->features = NETIF_F_HW_CSUM;
+   dev->features = NETIF_F_HW_CSUM | NETIF_F_LLTX;
 
err = pasemi_mac_map_regs(mac);
if (err)

--
-
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] [04/10] pasemi_mac: Fix memcpy amount for short receives

2007-08-22 Thread Olof Johansson
Fix up memcpy for short receives.

Signed-off-by: Olof Johansson <[EMAIL PROTECTED]>


Index: mainline/drivers/net/pasemi_mac.c
===
--- mainline.orig/drivers/net/pasemi_mac.c
+++ mainline/drivers/net/pasemi_mac.c
@@ -516,9 +516,7 @@ static int pasemi_mac_clean_rx(struct pa
netdev_alloc_skb(mac->netdev, len + NET_IP_ALIGN);
if (new_skb) {
skb_reserve(new_skb, NET_IP_ALIGN);
-   memcpy(new_skb->data - NET_IP_ALIGN,
-   skb->data - NET_IP_ALIGN,
-   len + NET_IP_ALIGN);
+   memcpy(new_skb->data, skb->data, len);
/* save the skb in buffer_info as good */
skb = new_skb;
}

--
-
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] [02/10] pasemi_mac: Stop using the pci config space accessors for register read/writes

2007-08-22 Thread Olof Johansson
Move away from using the pci config access functions for simple register
access.  Our device has all of the registers in the config space (hey,
from the hardware point of view it looks reasonable :-), so we need to
somehow get to it. Newer firmwares have it in the device tree such that
we can just get it and ioremap it there (in case it ever moves in future
products). For now, provide a hardcoded fallback for older firmwares.


Signed-off-by: Olof Johansson <[EMAIL PROTECTED]>


Index: mainline/drivers/net/pasemi_mac.c
===
--- mainline.orig/drivers/net/pasemi_mac.c
+++ mainline/drivers/net/pasemi_mac.c
@@ -81,46 +81,47 @@ MODULE_PARM_DESC(debug, "PA Semi MAC bit
 
 static struct pasdma_status *dma_status;
 
-static unsigned int read_iob_reg(struct pasemi_mac *mac, unsigned int reg)
+static inline unsigned int read_iob_reg(struct pasemi_mac *mac, unsigned int 
reg)
 {
unsigned int val;
 
-   pci_read_config_dword(mac->iob_pdev, reg, &val);
+   val = in_le32(mac->iob_regs+reg);
+
return val;
 }
 
-static void write_iob_reg(struct pasemi_mac *mac, unsigned int reg,
+static inline void write_iob_reg(struct pasemi_mac *mac, unsigned int reg,
  unsigned int val)
 {
-   pci_write_config_dword(mac->iob_pdev, reg, val);
+   out_le32(mac->iob_regs+reg, val);
 }
 
-static unsigned int read_mac_reg(struct pasemi_mac *mac, unsigned int reg)
+static inline unsigned int read_mac_reg(struct pasemi_mac *mac, unsigned int 
reg)
 {
unsigned int val;
 
-   pci_read_config_dword(mac->pdev, reg, &val);
+   val = in_le32(mac->regs+reg);
return val;
 }
 
-static void write_mac_reg(struct pasemi_mac *mac, unsigned int reg,
+static inline void write_mac_reg(struct pasemi_mac *mac, unsigned int reg,
  unsigned int val)
 {
-   pci_write_config_dword(mac->pdev, reg, val);
+   out_le32(mac->regs+reg, val);
 }
 
-static unsigned int read_dma_reg(struct pasemi_mac *mac, unsigned int reg)
+static inline unsigned int read_dma_reg(struct pasemi_mac *mac, unsigned int 
reg)
 {
unsigned int val;
 
-   pci_read_config_dword(mac->dma_pdev, reg, &val);
+   val = in_le32(mac->dma_regs+reg);
return val;
 }
 
-static void write_dma_reg(struct pasemi_mac *mac, unsigned int reg,
+static inline void write_dma_reg(struct pasemi_mac *mac, unsigned int reg,
  unsigned int val)
 {
-   pci_write_config_dword(mac->dma_pdev, reg, val);
+   out_le32(mac->dma_regs+reg, val);
 }
 
 static int pasemi_get_mac_addr(struct pasemi_mac *mac)
@@ -585,7 +586,6 @@ static int pasemi_mac_clean_tx(struct pa
}
mac->tx->next_to_clean += count;
spin_unlock_irqrestore(&mac->tx->lock, flags);
-
netif_wake_queue(mac->netdev);
 
return count;
@@ -1076,6 +1076,73 @@ static int pasemi_mac_poll(struct net_de
}
 }
 
+static inline void __iomem * __devinit map_onedev(struct pci_dev *p, int index)
+{
+   struct device_node *dn;
+   void __iomem *ret;
+
+   dn = pci_device_to_OF_node(p);
+   if (!dn)
+   goto fallback;
+
+   ret = of_iomap(dn, index);
+   if (!ret)
+   goto fallback;
+
+   return ret;
+fallback:
+   /* This is hardcoded and ugly, but we have some firmware versions
+* who don't provide the register space in the device tree. Luckily
+* they are at well-known locations so we can just do the math here.
+*/
+   return ioremap(0xe000 + (p->devfn << 12), 0x2000);
+}
+
+static int __devinit pasemi_mac_map_regs(struct pasemi_mac *mac)
+{
+   struct resource res;
+   struct device_node *dn;
+   int err;
+
+   mac->dma_pdev = pci_get_device(PCI_VENDOR_ID_PASEMI, 0xa007, NULL);
+   if (!mac->dma_pdev) {
+   dev_err(&mac->pdev->dev, "Can't find DMA Controller\n");
+   return -ENODEV;
+   }
+
+   mac->iob_pdev = pci_get_device(PCI_VENDOR_ID_PASEMI, 0xa001, NULL);
+   if (!mac->iob_pdev) {
+   dev_err(&mac->pdev->dev, "Can't find I/O Bridge\n");
+   return -ENODEV;
+   }
+
+   mac->regs = map_onedev(mac->pdev, 0);
+   mac->dma_regs = map_onedev(mac->dma_pdev, 0);
+   mac->iob_regs = map_onedev(mac->iob_pdev, 0);
+
+   if (!mac->regs || !mac->dma_regs || !mac->iob_regs) {
+   dev_err(&mac->pdev->dev, "Can't map registers\n");
+   return -ENODEV;
+   }
+
+   /* The dma status structure is located in the I/O bridge, and
+* is cache coherent.
+*/
+   if (!dma_status) {
+   dn = pci_device_to_OF_node(mac->iob_pdev);
+   if (dn)
+   err = of_address_to_resource(dn, 1, &res);
+   if (!dn || err) {
+   /* Fallback for old firmware */
+   res.start = 0xfd80;
+   res

[PATCH] [06/10] pasemi_mac: Batch up TX buffer frees

2007-08-22 Thread Olof Johansson
Postpone pci unmap and skb free of the transmitted buffers to outside of
the tx ring lock, batching them up 32 at a time.

Also increase the count threshold to 128.

Signed-off-by: Olof Johansson <[EMAIL PROTECTED]>

Index: mainline/drivers/net/pasemi_mac.c
===
--- mainline.orig/drivers/net/pasemi_mac.c
+++ mainline/drivers/net/pasemi_mac.c
@@ -561,37 +561,56 @@ static int pasemi_mac_clean_tx(struct pa
int i;
struct pasemi_mac_buffer *info;
struct pas_dma_xct_descr *dp;
-   int start, count;
+   unsigned int start, count, limit;
+   unsigned int total_count;
int flags;
+   struct sk_buff *skbs[32];
+   dma_addr_t dmas[32];
 
+   total_count = 0;
+restart:
spin_lock_irqsave(&mac->tx->lock, flags);
 
start = mac->tx->next_to_clean;
+   limit = min(mac->tx->next_to_use, start+32);
+
count = 0;
 
-   for (i = start; i < mac->tx->next_to_use; i++) {
+   for (i = start; i < limit; i++) {
dp = &TX_DESC(mac, i);
+
if (unlikely(dp->mactx & XCT_MACTX_O))
+   /* Not yet transmitted */
break;
 
-   count++;
-
info = &TX_DESC_INFO(mac, i);
-
-   pci_unmap_single(mac->dma_pdev, info->dma,
-info->skb->len, PCI_DMA_TODEVICE);
-   dev_kfree_skb_irq(info->skb);
+   skbs[count] = info->skb;
+   dmas[count] = info->dma;
 
info->skb = NULL;
info->dma = 0;
dp->mactx = 0;
dp->ptr = 0;
+
+   count++;
}
mac->tx->next_to_clean += count;
spin_unlock_irqrestore(&mac->tx->lock, flags);
netif_wake_queue(mac->netdev);
 
-   return count;
+   for (i = 0; i < count; i++) {
+   pci_unmap_single(mac->dma_pdev, dmas[i],
+skbs[i]->len, PCI_DMA_TODEVICE);
+   dev_kfree_skb_irq(skbs[i]);
+   }
+
+   total_count += count;
+
+   /* If the batch was full, try to clean more */
+   if (count == 32)
+   goto restart;
+
+   return total_count;
 }
 
 
@@ -787,7 +806,7 @@ static int pasemi_mac_open(struct net_de
   PAS_IOB_DMA_RXCH_CFG_CNTTH(0));
 
write_iob_reg(mac, PAS_IOB_DMA_TXCH_CFG(mac->dma_txch),
-  PAS_IOB_DMA_TXCH_CFG_CNTTH(32));
+  PAS_IOB_DMA_TXCH_CFG_CNTTH(128));
 
/* Clear out any residual packet count state from firmware */
pasemi_mac_restart_rx_intr(mac);

--
-
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] [08/10] pasemi_mac: Fix TX ring wrap checking

2007-08-22 Thread Olof Johansson
The old logic didn't detect full (tx) ring cases properly, causing
overruns and general badness. Clean it up a bit and abstract out the
ring size checks, always making sure to leave 1 slot open.


Signed-off-by: Olof Johansson <[EMAIL PROTECTED]>

Index: mainline/drivers/net/pasemi_mac.c
===
--- mainline.orig/drivers/net/pasemi_mac.c
+++ mainline/drivers/net/pasemi_mac.c
@@ -69,6 +69,10 @@
 #define RX_DESC_INFO(mac, num) ((mac)->rx->desc_info[(num) & (RX_RING_SIZE-1)])
 #define RX_BUFF(mac, num)  ((mac)->rx->buffers[(num) & (RX_RING_SIZE-1)])
 
+#define RING_USED(ring)(((ring)->next_to_fill - 
(ring)->next_to_clean) \
+& ((ring)->size - 1))
+#define RING_AVAIL(ring)   ((ring->size) - RING_USED(ring))
+
 #define BUF_SIZE 1646 /* 1500 MTU + ETH_HLEN + VLAN_HLEN + 2 64B cachelines */
 
 MODULE_LICENSE("GPL");
@@ -184,6 +188,7 @@ static int pasemi_mac_setup_rx_resources
 
spin_lock_init(&ring->lock);
 
+   ring->size = RX_RING_SIZE;
ring->desc_info = kzalloc(sizeof(struct pasemi_mac_buffer) *
  RX_RING_SIZE, GFP_KERNEL);
 
@@ -263,6 +268,7 @@ static int pasemi_mac_setup_tx_resources
 
spin_lock_init(&ring->lock);
 
+   ring->size = TX_RING_SIZE;
ring->desc_info = kzalloc(sizeof(struct pasemi_mac_buffer) *
  TX_RING_SIZE, GFP_KERNEL);
if (!ring->desc_info)
@@ -291,7 +297,7 @@ static int pasemi_mac_setup_tx_resources
   PAS_DMA_TXCHAN_CFG_UP |
   PAS_DMA_TXCHAN_CFG_WT(2));
 
-   ring->next_to_use = 0;
+   ring->next_to_fill = 0;
ring->next_to_clean = 0;
 
snprintf(ring->irq_name, sizeof(ring->irq_name),
@@ -386,9 +392,7 @@ static void pasemi_mac_replenish_rx_ring
int start = mac->rx->next_to_fill;
unsigned int limit, count;
 
-   limit = (mac->rx->next_to_clean + RX_RING_SIZE -
-mac->rx->next_to_fill) & (RX_RING_SIZE - 1);
-
+   limit = RING_AVAIL(mac->rx);
/* Check to see if we're doing first-time setup */
if (unlikely(mac->rx->next_to_clean == 0 && mac->rx->next_to_fill == 0))
limit = RX_RING_SIZE;
@@ -572,7 +576,7 @@ restart:
spin_lock_irqsave(&mac->tx->lock, flags);
 
start = mac->tx->next_to_clean;
-   limit = min(mac->tx->next_to_use, start+32);
+   limit = min(mac->tx->next_to_fill, start+32);
 
count = 0;
 
@@ -1013,14 +1017,13 @@ static int pasemi_mac_start_tx(struct sk
 
spin_lock_irqsave(&txring->lock, flags);
 
-   if (txring->next_to_clean - txring->next_to_use == TX_RING_SIZE) {
+   if (RING_AVAIL(txring) <= 1) {
spin_unlock_irqrestore(&txring->lock, flags);
pasemi_mac_clean_tx(mac);
pasemi_mac_restart_tx_intr(mac);
spin_lock_irqsave(&txring->lock, flags);
 
-   if (txring->next_to_clean - txring->next_to_use ==
-   TX_RING_SIZE) {
+   if (RING_AVAIL(txring) <= 1) {
/* Still no room -- stop the queue and wait for tx
 * intr when there's room.
 */
@@ -1029,15 +1032,15 @@ static int pasemi_mac_start_tx(struct sk
}
}
 
-   dp = &TX_DESC(mac, txring->next_to_use);
-   info = &TX_DESC_INFO(mac, txring->next_to_use);
+   dp = &TX_DESC(mac, txring->next_to_fill);
+   info = &TX_DESC_INFO(mac, txring->next_to_fill);
 
dp->mactx = mactx;
dp->ptr   = ptr;
info->dma = map;
info->skb = skb;
 
-   txring->next_to_use++;
+   txring->next_to_fill++;
mac->stats.tx_packets++;
mac->stats.tx_bytes += skb->len;
 
Index: mainline/drivers/net/pasemi_mac.h
===
--- mainline.orig/drivers/net/pasemi_mac.h
+++ mainline/drivers/net/pasemi_mac.h
@@ -31,7 +31,7 @@ struct pasemi_mac_txring {
struct pas_dma_xct_descr*desc;
dma_addr_t   dma;
unsigned int size;
-   unsigned int next_to_use;
+   unsigned int next_to_fill;
unsigned int next_to_clean;
struct pasemi_mac_buffer *desc_info;
char irq_name[10];  /* "eth%d tx" */

--
-
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


  1   2   >