iproute2: Issue with link type link/generic for NETROM links

2019-04-04 Thread Ralf Baechle
For a NETROM "ip link show dev nr0" will show

4: nr0:  mtu 236 qdisc noqueue state UNKNOWN mode DEFAULT 
group default qlen 1000
link/generic 88:98:6a:a4:84:40:0a brd 00:00:00:00:00:00:00

But rather link/netrom is expected to be displayed.

I have below patch to change ip such that link/netrom will be displayed
but I'm wondering if it's going to cause non-obvious breakage or would
be acceptable?

Thanks,

  Ralf

Signed-off-by: Ralf Baechle 

 lib/ll_types.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/ll_types.c b/lib/ll_types.c
index bd8893ed..32d04b5a 100644
--- a/lib/ll_types.c
+++ b/lib/ll_types.c
@@ -32,7 +32,7 @@ static const struct {
int type;
const char *name;
 } arphrd_names[] = {
-{ 0, "generic" },
+__PF(NETROM,netrom)
 __PF(ETHER,ether)
 __PF(EETHER,eether)
 __PF(AX25,ax25)


Re: [PATCH net] ipv6: Consider sk_bound_dev_if when binding a socket to an address

2019-01-03 Thread Ralf Jung
Hi all,

thanks a lot!  I can confirm that this fixes my test script.

Kind regards,
Ralf

On 03.01.19 03:57, David Ahern wrote:
> From: David Ahern 
> 
> IPv6 does not consider if the socket is bound to a device when binding
> to an address. The result is that a socket can be bound to eth0 and then
> bound to the address of eth1. If the device is a VRF, the result is that
> a socket can only be bound to an address in the default VRF.
> 
> Resolve by considering the device if sk_bound_dev_if is set.
> 
> This problem exists from the beginning of git history.
> 
> Signed-off-by: David Ahern 
> ---
>  net/ipv6/af_inet6.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c
> index f0cd291034f0..0bfb6cc0a30a 100644
> --- a/net/ipv6/af_inet6.c
> +++ b/net/ipv6/af_inet6.c
> @@ -350,6 +350,9 @@ static int __inet6_bind(struct sock *sk, struct sockaddr 
> *uaddr, int addr_len,
>   err = -EINVAL;
>   goto out_unlock;
>   }
> + }
> +
> + if (sk->sk_bound_dev_if) {
>   dev = dev_get_by_index_rcu(net, 
> sk->sk_bound_dev_if);
>   if (!dev) {
>   err = -ENODEV;
> 


Re: Cannot bind to IPv6 address in VRF

2019-01-01 Thread Ralf Jung
Hi,

> I see the problem. The check on the address bind is not considering the
> L3 domain - or even the device at all. That's why binding to an address
> in the default VRF works, but bind to an address in a VRF fails
> (requires an l3mdev match). Not sure how this has fallen through the
> cracks over the last 3 years.
> 
> I will send a patch. Most likely will not happen until tomorrow.

Thanks for the quick reply!  Good to know I can stop searching the problem
elsewhere. :)

Kind regards,
Ralf


Cannot bind to IPv6 address in VRF

2019-01-01 Thread Ralf Jung
Hi all,

I am experiencing trouble with using Bird over IPv6 inside a VRF, and reduced
this down to a problem with IPv6 `bind`.

I have a VRF called "vrf_freifunk", with some GRE tunnel devices in it:

> 3: vrf_freifunk:  mtu 65536 qdisc noqueue state UP 
> group default qlen 1000
> link/ether 6e:6d:9f:5d:f3:f2 brd ff:ff:ff:ff:ff:ff
> 12: tun-up-a_ak@NONE:  mtu 1280 qdisc noqueue 
> master vrf_freifunk state UNKNOWN group default qlen 1000
> link/gre 82.165.162.239 peer 185.66.195.0
> inet 100.64.3.21/31 scope global tun-up-a_ak
>valid_lft forever preferred_lft forever
> inet6 2a03:2260:0:194::2/64 scope global 
>valid_lft forever preferred_lft forever
> inet6 fe80::200:5efe:52a5:a2ef/64 scope link 
>valid_lft forever preferred_lft forever

Now I am running the following python script to reproduce the problem:

> #!/usr/bin/python3
>   
>
> import socket
> 
> s = socket.socket(socket.AF_INET, socket.SOCK_STREAM, socket.IPPROTO_TCP)
> s.setsockopt(socket.SOL_SOCKET, socket.SO_BINDTODEVICE, b"vrf_freifunk")
> s.bind(("100.64.3.21", 188))
> 
> s = socket.socket(socket.AF_INET6, socket.SOCK_STREAM, socket.IPPROTO_TCP)
> s.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_V6ONLY, 1)
> s.setsockopt(socket.SOL_SOCKET, socket.SO_BINDTODEVICE, b"vrf_freifunk")
> s.bind(("2a03:2260:0:194::2", 188))

The IPv4 block completes successfully, but doing the same with IPv6 in the
second block fails saying:

> Traceback (most recent call last):
>   File "./test.py", line 11, in 
> s.bind(("2a03:2260:0:194::2", 188))
> OSError: [Errno 99] Cannot assign requested address

If instead, in the last line, I use the IPv6 address of eth0 (which is not
inside this VRF), the `bind` call succeeds.  On the other hand, when I try using
the eth0 IPv4 address in the first block, `bind` fails as expected because the
address is not inside `vrf_freifunk`.
If I replace `vrf_freifunk` by `tun-up-a_ak` (which is more like what Bird
does), the behavior remains the same.

I think this is a kernel bug, it seems like setting `SO_BINDTODEVICE` on the
IPv6 socket is just ignored entirely.

This is using a Debian stable backports kernel:

> $ uname -a
> Linux gw1.saar.freifunk.net 4.18.0-0.bpo.3-amd64 #1 SMP Debian 
> 4.18.20-2~bpo9+1 (2018-12-08) x86_64 GNU/Linux

Any help debugging this would be appreciated.
Kind regards,
Ralf


Re: [PATCH 10/13] timer: Remove expires and data arguments from DEFINE_TIMER

2017-10-09 Thread Ralf Baechle
On Wed, Oct 04, 2017 at 04:27:04PM -0700, Kees Cook wrote:

> Subject: [PATCH 10/13] timer: Remove expires and data arguments from
>  DEFINE_TIMER
> 
> Drop the arguments from the macro and adjust all callers with the
> following script:
> 
>   perl -pi -e 's/DEFINE_TIMER\((.*), 0, 0\);/DEFINE_TIMER($1);/g;' \
> $(git grep DEFINE_TIMER | cut -d: -f1 | sort -u | grep -v timer.h)
> 
> Signed-off-by: Kees Cook 
> Acked-by: Geert Uytterhoeven  # for m68k parts
> ---
>  arch/arm/mach-ixp4xx/dsmg600-setup.c  | 2 +-
>  arch/arm/mach-ixp4xx/nas100d-setup.c  | 2 +-
>  arch/m68k/amiga/amisound.c| 2 +-
>  arch/m68k/mac/macboing.c  | 2 +-
>  arch/mips/mti-malta/malta-display.c   | 2 +-
>  arch/parisc/kernel/pdc_cons.c | 2 +-
>  arch/s390/mm/cmm.c| 2 +-
>  drivers/atm/idt77105.c| 4 ++--
>  drivers/atm/iphase.c  | 2 +-
>  drivers/block/ataflop.c   | 8 
>  drivers/char/dtlk.c   | 2 +-
>  drivers/char/hangcheck-timer.c| 2 +-
>  drivers/char/nwbutton.c   | 2 +-
>  drivers/char/rtc.c| 2 +-
>  drivers/input/touchscreen/s3c2410_ts.c| 2 +-
>  drivers/net/cris/eth_v10.c| 6 +++---
>  drivers/net/hamradio/yam.c| 2 +-
>  drivers/net/wireless/atmel/at76c50x-usb.c | 2 +-
>  drivers/staging/speakup/main.c| 2 +-
>  drivers/staging/speakup/synth.c   | 2 +-
>  drivers/tty/cyclades.c| 2 +-
>  drivers/tty/isicom.c  | 2 +-
>  drivers/tty/moxa.c| 2 +-
>  drivers/tty/rocket.c  | 2 +-
>  drivers/tty/vt/keyboard.c | 2 +-
>  drivers/tty/vt/vt.c   | 2 +-
>  drivers/watchdog/alim7101_wdt.c   | 2 +-
>  drivers/watchdog/machzwd.c| 2 +-
>  drivers/watchdog/mixcomwd.c   | 2 +-
>  drivers/watchdog/sbc60xxwdt.c | 2 +-
>  drivers/watchdog/sc520_wdt.c  | 2 +-
>  drivers/watchdog/via_wdt.c| 2 +-
>  drivers/watchdog/w83877f_wdt.c| 2 +-
>  drivers/xen/grant-table.c | 2 +-
>  fs/pstore/platform.c  | 2 +-
>  include/linux/timer.h | 4 ++--
>  kernel/irq/spurious.c | 2 +-
>  lib/random32.c| 2 +-
>  net/atm/mpc.c | 2 +-
>  net/decnet/dn_route.c | 2 +-
>  net/ipv6/ip6_flowlabel.c  | 2 +-
>  net/netrom/nr_loopback.c  | 2 +-
>  security/keys/gc.c| 2 +-
>  sound/oss/midibuf.c   | 2 +-
>  sound/oss/soundcard.c | 2 +-
>  sound/oss/sys_timer.c | 2 +-
>  sound/oss/uart6850.c  | 2 +-
>  47 files changed, 54 insertions(+), 54 deletions(-)

Acked-by: Ralf Baechle 

Thanks,

  Ralf


Re: [PATCH 09/13] timer: Remove users of expire and data arguments to DEFINE_TIMER

2017-10-09 Thread Ralf Baechle
On Wed, Oct 04, 2017 at 04:27:03PM -0700, Kees Cook wrote:

> Subject: [PATCH 09/13] timer: Remove users of expire and data arguments to
>  DEFINE_TIMER
> 
> The expire and data arguments of DEFINE_TIMER are only used in two places
> and are ignored by the code (malta-display.c only uses mod_timer(),
> never add_timer(), so the preset expires value is ignored). Set both
> sets of arguments to zero.
> 
> Cc: Ralf Baechle 
> Cc: Wim Van Sebroeck 
> Cc: Guenter Roeck 
> Cc: Geert Uytterhoeven 
> Cc: linux-m...@linux-mips.org
> Cc: linux-watch...@vger.kernel.org
> Signed-off-by: Kees Cook 
> ---
>  arch/mips/mti-malta/malta-display.c | 6 +++---
>  drivers/watchdog/alim7101_wdt.c | 4 ++--
>  2 files changed, 5 insertions(+), 5 deletions(-)

For malta-display:

Acked-by: Ralf Baechle 

  Ralf


[PATCH] sni_82596: Add Thomas' email address to driver.

2017-08-26 Thread Ralf Baechle
---
Reviewing Christoph's DMA patch I noticed Thomas' email address was missing
from the entire driver file.

 drivers/net/ethernet/i825xx/sni_82596.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/i825xx/sni_82596.c 
b/drivers/net/ethernet/i825xx/sni_82596.c
index 2af7f77345fb..38e0e16c9bfb 100644
--- a/drivers/net/ethernet/i825xx/sni_82596.c
+++ b/drivers/net/ethernet/i825xx/sni_82596.c
@@ -39,7 +39,7 @@ static const char sni_82596_string[] = "snirm_82596";
 
 #include "lib82596.c"
 
-MODULE_AUTHOR("Thomas Bogendoerfer");
+MODULE_AUTHOR("Thomas Bogendoerfer ");
 MODULE_DESCRIPTION("i82596 driver");
 MODULE_LICENSE("GPL");
 MODULE_ALIAS("platform:snirm_82596");


Re: [PATCH 3/4] i825xx: switch to switch to dma_alloc_attrs

2017-08-26 Thread Ralf Baechle
On Sat, Aug 26, 2017 at 09:21:24AM +0200, Christoph Hellwig wrote:

Adding Thomas Bogendoerfer , the author of
sni_82596.c to cc.

> This way we can always pass DMA_ATTR_NON_CONSISTENT, the SNI mips version
> will simply ignore the flag.
> 
> Signed-off-by: Christoph Hellwig 
> ---
>  drivers/net/ethernet/i825xx/lasi_82596.c | 6 ++
>  drivers/net/ethernet/i825xx/lib82596.c   | 9 +
>  drivers/net/ethernet/i825xx/sni_82596.c  | 6 ++
>  3 files changed, 9 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/net/ethernet/i825xx/lasi_82596.c 
> b/drivers/net/ethernet/i825xx/lasi_82596.c
> index d787fdd5db7b..d5b5021aa759 100644
> --- a/drivers/net/ethernet/i825xx/lasi_82596.c
> +++ b/drivers/net/ethernet/i825xx/lasi_82596.c
> @@ -96,8 +96,6 @@
>  
>  #define OPT_SWAP_PORT0x0001  /* Need to wordswp on the MPU port */
>  
> -#define DMA_ALLOCdma_alloc_noncoherent
> -#define DMA_FREE dma_free_noncoherent
>  #define DMA_WBACK(ndev, addr, len) \
>   do { dma_cache_sync((ndev)->dev.parent, (void *)addr, len, 
> DMA_TO_DEVICE); } while (0)
>  
> @@ -200,8 +198,8 @@ static int lan_remove_chip(struct parisc_device *pdev)
>   struct i596_private *lp = netdev_priv(dev);
>  
>   unregister_netdev (dev);
> - DMA_FREE(&pdev->dev, sizeof(struct i596_private),
> -  (void *)lp->dma, lp->dma_addr);
> + dma_free_attrs(&pdev->dev, sizeof(struct i596_private), lp->dma,
> +lp->dma_addr, DMA_ATTR_NON_CONSISTENT);
>   free_netdev (dev);
>   return 0;
>  }
> diff --git a/drivers/net/ethernet/i825xx/lib82596.c 
> b/drivers/net/ethernet/i825xx/lib82596.c
> index 8449c58f01fd..f00a1dc2128c 100644
> --- a/drivers/net/ethernet/i825xx/lib82596.c
> +++ b/drivers/net/ethernet/i825xx/lib82596.c
> @@ -1063,8 +1063,9 @@ static int i82596_probe(struct net_device *dev)
>   if (!dev->base_addr || !dev->irq)
>   return -ENODEV;
>  
> - dma = (struct i596_dma *) DMA_ALLOC(dev->dev.parent,
> - sizeof(struct i596_dma), &lp->dma_addr, GFP_KERNEL);
> + dma = dma_alloc_attrs(dev->dev.parent, sizeof(struct i596_dma),
> +   &lp->dma_addr, GFP_KERNEL,
> +   DMA_ATTR_NON_CONSISTENT);
>   if (!dma) {
>   printk(KERN_ERR "%s: Couldn't get shared memory\n", __FILE__);
>   return -ENOMEM;
> @@ -1085,8 +1086,8 @@ static int i82596_probe(struct net_device *dev)
>  
>   i = register_netdev(dev);
>   if (i) {
> - DMA_FREE(dev->dev.parent, sizeof(struct i596_dma),
> - (void *)dma, lp->dma_addr);
> + dma_free_attrs(dev->dev.parent, sizeof(struct i596_dma),
> +dma, lp->dma_addr, DMA_ATTR_NON_CONSISTENT);
>   return i;
>   }
>  
> diff --git a/drivers/net/ethernet/i825xx/sni_82596.c 
> b/drivers/net/ethernet/i825xx/sni_82596.c
> index 2af7f77345fb..b2c04a789744 100644
> --- a/drivers/net/ethernet/i825xx/sni_82596.c
> +++ b/drivers/net/ethernet/i825xx/sni_82596.c
> @@ -23,8 +23,6 @@
>  
>  static const char sni_82596_string[] = "snirm_82596";
>  
> -#define DMA_ALLOC  dma_alloc_coherent
> -#define DMA_FREE   dma_free_coherent
>  #define DMA_WBACK(priv, addr, len) do { } while (0)
>  #define DMA_INV(priv, addr, len)   do { } while (0)
>  #define DMA_WBACK_INV(priv, addr, len) do { } while (0)
> @@ -152,8 +150,8 @@ static int sni_82596_driver_remove(struct platform_device 
> *pdev)
>   struct i596_private *lp = netdev_priv(dev);
>  
>   unregister_netdev(dev);
> - DMA_FREE(dev->dev.parent, sizeof(struct i596_private),
> -  lp->dma, lp->dma_addr);
> + dma_free_attrs(dev->dev.parent, sizeof(struct i596_private), lp->dma,
> +lp->dma_addr, DMA_ATTR_NON_CONSISTENT);
>   iounmap(lp->ca);
>   iounmap(lp->mpu_port);
>   free_netdev (dev);
> -- 
> 2.11.0


Re: [PATCH 1/4] sgiseeq: switch to dma_alloc_attrs

2017-08-26 Thread Ralf Baechle
On Sat, Aug 26, 2017 at 09:21:22AM +0200, Christoph Hellwig wrote:

Looks good,

Acked-by: Ralf Baechle 

  Ralf


Re: [PATCH v2 0/5] MIPS: Implement eBPF JIT.

2017-06-14 Thread Ralf Baechle
On Tue, Jun 13, 2017 at 03:28:42PM -0700, David Daney wrote:

> Changes in v2:
> 
>   - Squash a couple of the uasm cleanups.
> 
>   - Make insn_table_MM const (suggested by Matt Redfearn)
> 
>   - Put the eBPF in its own source file (should fix build
> warnings/errors on 32-bit kernel builds).
> 
>   - Use bpf_jit_binary_alloc() (suggested by Daniel Borkmann)
> 
>   - Implement tail calls.
> 
>   - Fix system call tracing to extract arguments for
> kprobe/__seccomp_filter() tracing (perhaps not really part the the
> JIT, but necessary to have fun with the samples/bpf programs).
> 
> Most things in samples/bpf work, still working on the incantations to
> build tools/testing/selftests/bpf/ ... 
> 
> 
> >From v1:
> 
> The first three patches improve MIPS uasm in preparation for use by
> the JIT.  Then the eBPF JIT implementation.
> 
> I am CCing netdev@ and the BPF maintainers for their comments, but
> would expect Ralf to merge via the MIPS tree if and when it all looks
> good.

Thanks, applied after fixing a minor conflict in arch/mips/Kconfig.

  Ralf


Re: [PATCH v2 0/5] MIPS: BPF: JIT fixes and improvements.

2017-03-15 Thread Ralf Baechle
On Tue, Mar 14, 2017 at 05:34:02PM -0700, David Daney wrote:

> > What tree are you targetting with these changes?  Do you expect
> > them to go via the MIPS or the net-next tree?
> > 
> > Please be explicit about this in the future.
> > 
> 
> Sorry I didn't mention it.
> 
> My expectation is that Ralf would merge it via the MIPS tree, as it is fully
> contained within arch/mips/*

Thanks, applied.

  Ralf


[PATCH] NET: Fix /proc/net/arp for AX.25

2017-02-10 Thread Ralf Baechle
When sending ARP requests over AX.25 links the hwaddress in the neighbour
cache are not getting initialized.  For such an incomplete arp entry
ax2asc2 will generate an empty string resulting in /proc/net/arp output
like the following:

$ cat /proc/net/arp
IP address   HW type Flags   HW addressMask Device
192.168.122.10x1 0x2 52:54:00:00:5d:5f *ens3
172.20.1.99  0x3 0x0  *bpq0

The missing field will confuse the procfs parsing of arp(8) resulting in
incorrect output for the device such as the following:

$ arp
Address  HWtype  HWaddress   Flags MaskIface
gateway  ether   52:54:00:00:5d:5f   C ens3
172.20.1.99  (incomplete)  ens3

This changes the content of /proc/net/arp to:

$ cat /proc/net/arp
IP address   HW type Flags   HW addressMask Device
172.20.1.99  0x3 0x0 * *bpq0
192.168.122.10x1 0x2 52:54:00:00:5d:5f *ens3

To do so it change ax2asc to put the string "*" in buf for a NULL address
argument.  Finally the HW address field is left aligned in a 17 character
field (the length of an ethernet HW address in the usual hex notation) for
readability.

Signed-off-by: Ralf Baechle 
---
 net/ipv4/arp.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/net/ipv4/arp.c b/net/ipv4/arp.c
index 89a8cac4..51b27ae 100644
--- a/net/ipv4/arp.c
+++ b/net/ipv4/arp.c
@@ -1263,7 +1263,7 @@ void __init arp_init(void)
 /*
  * ax25 -> ASCII conversion
  */
-static char *ax2asc2(ax25_address *a, char *buf)
+static void ax2asc2(ax25_address *a, char *buf)
 {
char c, *s;
int n;
@@ -1285,10 +1285,10 @@ static char *ax2asc2(ax25_address *a, char *buf)
*s++ = n + '0';
*s++ = '\0';
 
-   if (*buf == '\0' || *buf == '-')
-   return "*";
-
-   return buf;
+   if (*buf == '\0' || *buf == '-') {
+   buf[0] = '*';
+   buf[1] = '\0';
+   }
 }
 #endif /* CONFIG_AX25 */
 
@@ -1322,7 +1322,7 @@ static void arp_format_neigh_entry(struct seq_file *seq,
}
 #endif
sprintf(tbuf, "%pI4", n->primary_key);
-   seq_printf(seq, "%-16s 0x%-10x0x%-10x%s *%s\n",
+   seq_printf(seq, "%-16s 0x%-10x0x%-10x%-17s *%s\n",
   tbuf, hatype, arp_state_to_flags(n), hbuffer, dev->name);
read_unlock(&n->lock);
 }


[PATCH] NET: mkiss/6pack: Fix SIOCSIFENCAP ioctl

2017-02-10 Thread Ralf Baechle
When looking at Thomas' mkiss fix 7ba1b6890387 ("NET: mkiss: Fix panic")
I noticed that the mkiss SIOCSIFENCAPS ioctl was also doing a slightly
strange assignment 

   dev->hard_header_len = AX25_KISS_HEADER_LEN +
  AX25_MAX_HEADER_LEN + 3;

AX25_MAX_HEADER_LEN already accounts for the KISS byte so adding
AX25_KISS_HEADER_LEN is a double allocation nor does the "+ 3" seem to
be necessary.  So this can be simplified to

   dev->hard_header_len = AX25_MAX_HEADER_LEN

which after the preceeding fix is a redundant assignment of what
ax_setup has already assigned so delete the line.  The assignments
to dev->addr_len and dev->type are similarly redundant.

The SIOCSIFENCAP argument was never checked for validity.  Check that
it is 4 and return -EINVAL if not.  The magic constant 4 dates back to
the days when KISS was handled by the SLIP driver where it had the
symbol name SL_MODE_AX25.

Since however mkiss.c only supports a single encapsulation mode there
is no point in storing it in struct mkiss so delete all that.

Note that while useless we can't delete the SIOCSIFENCAP ioctl as
kissattach(8) is still using it and without mkiss issuing a
SIOCSIFENCAP ioctl an older kernel that does not have Thomas' mkiss fix
would still panic on attempt to transmit via mkiss.

6pack was suffering from the same issue except there SIOCGIFENCAP was
return 0 for the encapsulation while the spattach utility was passing 4
for the mode, so the mode check added for 6pack is a bit more lenient
allow the values 0 and 4 to be set.  That way we retain the option
to set different encapsulation modes for future extensions.

Signed-off-by: Ralf Baechle 

 drivers/net/hamradio/6pack.c | 10 --
 drivers/net/hamradio/mkiss.c | 10 --
 2 files changed, 8 insertions(+), 12 deletions(-)

diff --git a/drivers/net/hamradio/6pack.c b/drivers/net/hamradio/6pack.c
index 470b3dc..d949b9f 100644
--- a/drivers/net/hamradio/6pack.c
+++ b/drivers/net/hamradio/6pack.c
@@ -104,7 +104,6 @@ struct sixpack {
int buffsize;   /* Max buffers sizes */
 
unsigned long   flags;  /* Flag values/ mode etc */
-   unsigned char   mode;   /* 6pack mode */
 
/* 6pack stuff */
unsigned char   tx_delay;
@@ -723,11 +722,10 @@ static int sixpack_ioctl(struct tty_struct *tty, struct 
file *file,
break;
}
 
-   sp->mode = tmp;
-   dev->addr_len= AX25_ADDR_LEN;
-   dev->hard_header_len = AX25_KISS_HEADER_LEN +
-  AX25_MAX_HEADER_LEN + 3;
-   dev->type= ARPHRD_AX25;
+   if (tmp != 0 && tmp != 4) {
+   err = -EINVAL;
+   break;
+   }
 
err = 0;
break;
diff --git a/drivers/net/hamradio/mkiss.c b/drivers/net/hamradio/mkiss.c
index 1dfe230..cdaf819 100644
--- a/drivers/net/hamradio/mkiss.c
+++ b/drivers/net/hamradio/mkiss.c
@@ -71,7 +71,6 @@ struct mkiss {
 #define AXF_KEEPTEST   3   /* Keepalive test flag  */
 #define AXF_OUTWAIT4   /* is outpacket was flag*/
 
-   int mode;
 intcrcmode;/* MW: for FlexNet, SMACK etc.  */
int crcauto;/* CRC auto mode */
 
@@ -841,11 +840,10 @@ static int mkiss_ioctl(struct tty_struct *tty, struct 
file *file,
break;
}
 
-   ax->mode = tmp;
-   dev->addr_len= AX25_ADDR_LEN;
-   dev->hard_header_len = AX25_KISS_HEADER_LEN +
-  AX25_MAX_HEADER_LEN + 3;
-   dev->type= ARPHRD_AX25;
+   if (tmp != 4) {
+   err = -EINVAL;
+   break;
+   }
 
err = 0;
break;


[PATCH] NET: mkiss: Fix panic

2017-02-09 Thread Ralf Baechle
If a USB-to-serial adapter is unplugged, the driver re-initializes, with
dev->hard_header_len and dev->addr_len set to zero, instead of the correct
values.  If then a packet is sent through the half-dead interface, the
kernel will panic due to running out of headroom in the skb when pushing
for the AX.25 headers resulting in this panic:

[] (skb_panic) from [] (skb_push+0x4c/0x50)
[] (skb_push) from [] (ax25_hard_header+0x34/0xf4 [ax25])
[] (ax25_hard_header [ax25]) from [] (ax_header+0x38/0x40 
[mkiss])
[] (ax_header [mkiss]) from [] 
(neigh_compat_output+0x8c/0xd8)
[] (neigh_compat_output) from [] 
(ip_finish_output+0x2a0/0x914)
[] (ip_finish_output) from [] (ip_output+0xd8/0xf0)
[] (ip_output) from [] (ip_local_out_sk+0x44/0x48)

This patch makes mkiss behave like the 6pack driver. 6pack does not
panic.  In 6pack.c sp_setup() (same function name here) the values for
dev->hard_header_len and dev->addr_len are set to the same values as in
my mkiss patch.

[r...@linux-mips.org: Massages original submission to conform to the usual
standards for patch submissions.]

Signed-off-by: Thomas Osterried 
Signed-off-by: Ralf Baechle 

---

 drivers/net/hamradio/mkiss.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/hamradio/mkiss.c b/drivers/net/hamradio/mkiss.c
index 1dfe230..e0a6b1a 100644
--- a/drivers/net/hamradio/mkiss.c
+++ b/drivers/net/hamradio/mkiss.c
@@ -648,8 +648,8 @@ static void ax_setup(struct net_device *dev)
 {
/* Finish setting up the DEVICE info. */
dev->mtu = AX_MTU;
-   dev->hard_header_len = 0;
-   dev->addr_len= 0;
+   dev->hard_header_len = AX25_MAX_HEADER_LEN;
+   dev->addr_len= AX25_ADDR_LEN;
dev->type= ARPHRD_AX25;
dev->tx_queue_len= 10;
dev->header_ops  = &ax25_header_ops;


[PATCH iproute2] ip: HSR: Fix cut and paste error

2017-02-06 Thread Ralf Baechle
Fixes: 5c0aec93a516 ("ip: Add HSR support")
Signed-off-by: Ralf Baechle 
---
I found this by coincidence when reading the HSR code.

 ip/iplink_hsr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ip/iplink_hsr.c b/ip/iplink_hsr.c
index cb744eb..696b2c9 100644
--- a/ip/iplink_hsr.c
+++ b/ip/iplink_hsr.c
@@ -144,7 +144,7 @@ static void hsr_print_help(struct link_util *lu, int argc, 
char **argv,
 
 struct link_util hsr_link_util = {
.id = "hsr",
-   .maxattr= IFLA_VLAN_MAX,
+   .maxattr= IFLA_HSR_MAX,
.parse_opt  = hsr_parse_opt,
.print_opt  = hsr_print_opt,
.print_help = hsr_print_help,


Re: [PATCH net-next 20/27] net/bpf_jit: MIPS: split VLAN_PRESENT bit handling from VLAN_TCI

2016-12-12 Thread Ralf Baechle
I assume you want to merge this together with the rest of you series, so

Acked-by: Ralf Baechle 

Cheers,

  Ralf

On Tue, Dec 13, 2016 at 01:12:39AM +0100, Michał Mirosław wrote:
> Date:   Tue, 13 Dec 2016 01:12:39 +0100 (CET)
> From: Michał Mirosław 
> To: netdev@vger.kernel.org
> Cc: Ralf Baechle , "open list:MIPS"
>  
> Subject: [PATCH net-next 20/27] net/bpf_jit: MIPS: split VLAN_PRESENT bit
>  handling from VLAN_TCI
> Content-Type: text/plain; charset=UTF-8
> 
> Signed-off-by: Michał Mirosław 
> ---
>  arch/mips/net/bpf_jit.c | 20 
>  1 file changed, 12 insertions(+), 8 deletions(-)
> 
> diff --git a/arch/mips/net/bpf_jit.c b/arch/mips/net/bpf_jit.c
> index 49a2e22..4b12b5d 100644
> --- a/arch/mips/net/bpf_jit.c
> +++ b/arch/mips/net/bpf_jit.c
> @@ -1138,19 +1138,23 @@ static int build_body(struct jit_ctx *ctx)
>   emit_load(r_A, r_skb, off, ctx);
>   break;
>   case BPF_ANC | SKF_AD_VLAN_TAG:
> - case BPF_ANC | SKF_AD_VLAN_TAG_PRESENT:
>   ctx->flags |= SEEN_SKB | SEEN_A;
>   BUILD_BUG_ON(FIELD_SIZEOF(struct sk_buff,
> vlan_tci) != 2);
>   off = offsetof(struct sk_buff, vlan_tci);
>   emit_half_load(r_s0, r_skb, off, ctx);
> - if (code == (BPF_ANC | SKF_AD_VLAN_TAG)) {
> - emit_andi(r_A, r_s0, (u16)~VLAN_TAG_PRESENT, 
> ctx);
> - } else {
> - emit_andi(r_A, r_s0, VLAN_TAG_PRESENT, ctx);
> - /* return 1 if present */
> - emit_sltu(r_A, r_zero, r_A, ctx);
> - }
> +#ifdef VLAN_TAG_PRESENT
> + emit_andi(r_A, r_s0, (u16)~VLAN_TAG_PRESENT, ctx);
> +#endif
> + break;
> + case BPF_ANC | SKF_AD_VLAN_TAG_PRESENT:
> + ctx->flags |= SEEN_SKB | SEEN_A;
> + emit_load_byte(r_A, r_skb, PKT_VLAN_PRESENT_OFFSET(), 
> ctx);
> + if (PKT_VLAN_PRESENT_BIT)
> + emit_srl(r_A, r_A, PKT_VLAN_PRESENT_BIT, ctx);
> + emit_andi(r_A, r_s0, 1, ctx);
> + /* return 1 if present */
> + emit_sltu(r_A, r_zero, r_A, ctx);
>   break;
>   case BPF_ANC | SKF_AD_PKTTYPE:
>   ctx->flags |= SEEN_SKB;
> -- 
> 2.10.2


Re: [PATCH] rose: correct integer overflow check

2016-02-18 Thread Ralf Baechle
On Thu, Feb 18, 2016 at 04:03:16PM -0500, Insu Yun wrote:

> 
> Because of the types on the right hand side of the comparison
> the expressions are all promoted to unsigned.
> 
> Did you look at the compiler's assembler output?  I did when
> reviewing your patch.
> 
> 
> I checked the assembler output right now.
> You are right.
> I realized that right hand side becomes unsigned due to sizeof.
> I think this patch is wrong. 
> Thanks. 

On a different level, the current whole approach of ROSE to just generate
a fixed number of devices at initialization time of ROSE is if not wrong
then at least very archaic.  The default number is 10 devices and probably
of those 9 are unused on a typical setup - that is, if the module has
been loaded intentionally at all.

As a solution I've implemented a patch to support creating of ROSE
devices through netlink plus the necessary changes to iproute2 to go
along with that.

  Ralf


Re: use-after-free in sixpack_close

2015-12-17 Thread Ralf Baechle DL5RB
On Thu, Dec 17, 2015 at 04:05:32PM -0500, David Miller wrote:

> This should fix it, the only thing I'm unsure of is if we should perhaps
> also use del_timer_sync() here.  Anyone?

I think so.

  Ralf
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/2] mkiss: Fix use after free in sixpack_close().

2015-12-17 Thread Ralf Baechle
On Thu, Dec 17, 2015 at 04:05:49PM -0500, David Miller wrote:

> Subject: [PATCH 2/2] mkiss: Fix use after free in sixpack_close().

Make that subject "... mkiss_close()."

  Ralf
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH net-next v3 04/17] tx4939: use __ethtool_get_ksettings

2015-11-30 Thread Ralf Baechle
On Mon, Nov 30, 2015 at 02:05:42PM -0800, David Decotigny wrote:

Acked-by: Ralf Baechle 

  Ralf
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] MIPS: Remove all the uses of custom gpio.h

2015-08-03 Thread Ralf Baechle
On Mon, Aug 03, 2015 at 09:13:27AM +0200, Linus Walleij wrote:

> Very good job being done here.
> Reviewed-by: Linus Walleij 
> 
> I guess this better go in through the MIPS tree.
> Given all the OpenWRT ports using MIPS this is excellent
> progress for a large hobbyist community.

Alban has posted a v2 [1] already but I take it that your Reviewed-by: applies
to the v2 patch as well?

  Ralf

[1] https://patchwork.linux-mips.org/patch/10828/
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH net-tools] Fix stale references to axattach

2015-07-14 Thread Ralf Baechle
Rename all references to axattach to kissattach.

Axattach has been renamed early to kissattach early in the history of
the ax25-utils package which itself has been superseeded by libax25,
ax25-tools and ax25-apps but stale references have remained.

Signed-off-by: Ralf Baechle 
---
 TODO | 2 +-
 man/de_DE/slattach.8 | 4 ++--
 man/en_US/slattach.8 | 4 ++--
 man/fr_FR/slattach.8 | 4 ++--
 4 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/TODO b/TODO
index c8a10dc..798aa19 100644
--- a/TODO
+++ b/TODO
@@ -24,7 +24,7 @@ TODO for net-tools
 [ ] Config file only works with bash not ash.
 [ ] Token ring is almost totally untested.
 [ ] additional tools for IPX, AX.25 etc be bundled [ipxripd004, ipx_* tools
-   from caldera, axattach] into existing bins
+   from caldera, kissattach] into existing bins
 [ ] "SIOCAX25OPTRT" [Joerg (DL1BKE)]. 1.3.75
 [ ] dummy NOARP?! (2. default route for preveting hostunreachables on linedrop)
 [ ] ppp_dev_stat called for each dev in ifconfig, why? (1.3.17)
diff --git a/man/de_DE/slattach.8 b/man/de_DE/slattach.8
index 603281c..ff6e2f2 100644
--- a/man/de_DE/slattach.8
+++ b/man/de_DE/slattach.8
@@ -76,7 +76,7 @@ ben\(:otigt um eine Leitung zu betreiben.
 F\(:ur
 .B kiss
 Verbindungen sollte stattdessen das
-.B axattach
+.B kissattach
 Programm verwendet werden.
 .TP
 .B "[-s Geschwindigkeit]"
@@ -91,7 +91,7 @@ zu erhalten, f\(:ur andere zu sperren und zu \(:offnen.
 .SH FEHLER
 Keine bekannt.
 .SH SIEHE ALSO
-axattach(8), dip(8) pppd(8), sliplogin(8).
+kissattach(8), dip(8) pppd(8), sliplogin(8).
 .SH AUTOREN
 Fred N. van Kempen, 
 .br
diff --git a/man/en_US/slattach.8 b/man/en_US/slattach.8
index 0e2cfcc..15c12d7 100644
--- a/man/en_US/slattach.8
+++ b/man/en_US/slattach.8
@@ -73,7 +73,7 @@ can be used to put the device back into normal serial 
operation.
 Using 'ppp' mode is not normally useful as ppp requires an additional ppp 
daemon
 .B pppd
 to be active on the line. For kiss connections the 
-.B axattach
+.B kissattach
 program should be used.
 .TP
 .B "[\-s speed]"
@@ -87,7 +87,7 @@ indicated terminal port, lock it, and open it.
 .SH BUGS
 None known.
 .SH SEE ALSO
-axattach(8), dip(8) pppd(8), sliplogin(8).
+kissattach(8), dip(8) pppd(8), sliplogin(8).
 .SH AUTHORS
 Fred N. van Kempen, 
 .br
diff --git a/man/fr_FR/slattach.8 b/man/fr_FR/slattach.8
index d21d0d7..177de18 100644
--- a/man/fr_FR/slattach.8
+++ b/man/fr_FR/slattach.8
@@ -72,7 +72,7 @@ fonctionnement série normal. L'utilisation du mode 'ppp' 
n'est en
 principe pas utile puisque ppp nécessite le démon additionnel
 .B pppd
 pour être actif sur la ligne. Pour les connexions `kiss', le programme 
-.B axattach
+.B kissattach
 doit être utilisé.
 .TP
 .B "[-s vitesse]"
@@ -87,7 +87,7 @@ vérouillé et ouvert.
 .SH BUGS
 Aucun connu.
 .SH VOIR AUSSI
-axattach(8), dip(8) pppd(8), sliplogin(8).
+kissattach(8), dip(8) pppd(8), sliplogin(8).
 .SH AUTEURS
 Fred N. van Kempen, 
 .br
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2] NET: AX.25: Stop heartbeat timer on disconnect.

2015-07-13 Thread Ralf Baechle
From: Richard Stearn 

This may result in a kernel panic.  The bug has always existed but
somehow we've run out of luck now and it bites.

Signed-off-by: Richard Stearn 
Cc: sta...@vger.kernel.org  # all branches
Signed-off-by: Ralf Baechle 
---
v2: Correctly attribute the patch to Richard Stearn in the From: line

 net/ax25/ax25_subr.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/ax25/ax25_subr.c b/net/ax25/ax25_subr.c
index 1997538..3b78e84 100644
--- a/net/ax25/ax25_subr.c
+++ b/net/ax25/ax25_subr.c
@@ -264,6 +264,7 @@ void ax25_disconnect(ax25_cb *ax25, int reason)
 {
ax25_clear_queues(ax25);
 
+   ax25_stop_heartbeat(ax25);
ax25_stop_t1timer(ax25);
ax25_stop_t2timer(ax25);
ax25_stop_t3timer(ax25);

- End forwarded message -

  Ralf
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] NET: AX.25: Stop heartbeat timer on disconnect.

2015-07-13 Thread Ralf Baechle
This may result in a kernel panic.  The bug has always existed but
somehow we've run out of luck now and it bites.

Signed-off-by: Richard Stearn 
Cc: sta...@vger.kernel.org  # all branches
Signed-off-by: Ralf Baechle 
---
 net/ax25/ax25_subr.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/ax25/ax25_subr.c b/net/ax25/ax25_subr.c
index 1997538..3b78e84 100644
--- a/net/ax25/ax25_subr.c
+++ b/net/ax25/ax25_subr.c
@@ -264,6 +264,7 @@ void ax25_disconnect(ax25_cb *ax25, int reason)
 {
ax25_clear_queues(ax25);
 
+   ax25_stop_heartbeat(ax25);
ax25_stop_t1timer(ax25);
ax25_stop_t2timer(ax25);
ax25_stop_t3timer(ax25);
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] NET: hamradio: Fix IP over bpq encapsulation.

2015-07-05 Thread Ralf Baechle
Since 1d5da757da860a6916adbf68b09e868062b4b3b8 (ax25: Stop using magic
neighbour cache operations.) any attempt to transmit IP packets over
a bpqether device will result in a message like "Dead loop on virtual
device bpq0, fix it urgently!"

Fix suggested by Eric W. Biederman .

Signed-off-by: Ralf Baechle 
Cc:  # 4.1
---
 drivers/net/hamradio/bpqether.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/hamradio/bpqether.c b/drivers/net/hamradio/bpqether.c
index 63ff08a..5b54b18 100644
--- a/drivers/net/hamradio/bpqether.c
+++ b/drivers/net/hamradio/bpqether.c
@@ -483,6 +483,7 @@ static void bpq_setup(struct net_device *dev)
memcpy(dev->dev_addr,  &ax25_defaddr, AX25_ADDR_LEN);
 
dev->flags  = 0;
+   dev->features   = NETIF_F_LLTX; /* Allow recursion */
 
 #if defined(CONFIG_AX25) || defined(CONFIG_AX25_MODULE)
dev->header_ops  = &ax25_header_ops;
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Bpqether broken in 4.1

2015-07-02 Thread Ralf Baechle
On Thu, Jul 02, 2015 at 04:03:07PM -0500, Eric W. Biederman wrote:

> > Eric's Commit 1d5da757da860a6916adbf68b09e868062b4b3b8 (ax25: Stop using
> > magic neighbour cache operations.) breaks IP traffic over the AX.25 bpqether
> > driver.
> 
> Sigh.  NETIF_F_LLTX is not set so recursion does not work :(
> 
> So we can either set NETIF_F_LLTX or just rever the offending commit.

The AX.25 stack has a sufficient number of hacks that attempts to fix
any hack is likely to cause issues somewhere else and the header and
neighbour stuff is the worst minefield.  I'm happy that your patch at
least concentrates all those hacks in the AX.25 stack itself removing
the impact from the generic networking code.

> I think either will work.  ax25 is so very weird it just abuses the
> neighbour table something awful.  It ax25 is not caching ip address to
> ax25 address translations in there, ax25 should really not be using the
> neighbour table.  Sigh.
> 
> So perhaps something like the below will be good enough.
> 
> diff --git a/drivers/net/hamradio/bpqether.c b/drivers/net/hamradio/bpqether.c
> index 63ff08a26da8..fc2be36c9425 100644
> --- a/drivers/net/hamradio/bpqether.c
> +++ b/drivers/net/hamradio/bpqether.c
> @@ -483,6 +483,7 @@ static void bpq_setup(struct net_device *dev)
> memcpy(dev->dev_addr,  &ax25_defaddr, AX25_ADDR_LEN);
>  
> dev->flags  = 0;
> +   dev->features   = NETIF_F_LLTX; /* Allow recursion */
>  
>  #if defined(CONFIG_AX25) || defined(CONFIG_AX25_MODULE)
> dev->header_ops  = &ax25_header_ops;

Thanks, that restored bpqether to work.  I will cook up a patch to fix
all other AX.25 drivers.

Thanks!

  Ralf
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Bpqether broken in 4.1

2015-07-02 Thread Ralf Baechle
Eric's Commit 1d5da757da860a6916adbf68b09e868062b4b3b8 (ax25: Stop using
magic neighbour cache operations.) breaks IP traffic over the AX.25 bpqether
driver.

Here's how to reproduce the issue if you don't have an AX.25 setup.  The
arp command is there to fudge things if you don't have a peer that would
answer ARP requests.

# modprobe bpqether
# ifconfig bpq0 hw ax25 abcdef-7 172.20.4.1/24
# arp -H ax25 -s 172.20.4.2 uvwxyz-9
# ping 172.20.4.2

Result in one "Dead loop on virtual device bpq0, fix it urgently!" message
per ping packet.  With the following little debug patch

diff --git a/net/core/dev.c b/net/core/dev.c
index aa82f9a..5fef868 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -3011,6 +3011,7 @@ static int __dev_queue_xmit(struct sk_buff *skb, void 
*accel_priv)
 recursion_alert:
net_crit_ratelimited("Dead loop on virtual device %s, 
fix it urgently!\n",
 dev->name);
+   WARN_ON(1);
}
}
 
I get the following backtrace:

[   33.149171] Dead loop on virtual device bpq0, fix it urgently!
[   33.149718] [ cut here ]
[   33.149754] WARNING: CPU: 0 PID: 0 at net/core/dev.c:3014 
__dev_queue_xmit+0x3f6/0x530()
[   33.149769] Modules linked in:
[   33.149789] CPU: 0 PID: 0 Comm: swapper/0 Not tainted 
4.1.0-00010-g21c6d95-dirty #18
[   33.149799] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 
1.8.1-20150318_183358- 04/01/2014
[   33.149810]   de52945c8e778a65 88007fc039a8 
816d2165
[   33.149823]    88007fc039e8 
810634aa
[   33.149833]  88007fc039c8  880078f9 
880078f9
[   33.149844] Call Trace:
[   33.149885][] dump_stack+0x45/0x57
[   33.149927]  [] warn_slowpath_common+0x8a/0xc0
[   33.149939]  [] warn_slowpath_null+0x1a/0x20
[   33.149949]  [] __dev_queue_xmit+0x3f6/0x530
[   33.149967]  [] ? ttwu_do_wakeup+0x1d/0xe0
[   33.149978]  [] dev_queue_xmit_sk+0x13/0x20
[   33.149994]  [] ax25_queue_xmit+0x61/0x70
[   33.150005]  [] ax25_ip_xmit+0xd6/0x2d0
[   33.150022]  [] ? wake_up_process+0x27/0x50
[   33.150050]  [] bpq_xmit+0x1d5/0x200
[   33.150061]  [] dev_hard_start_xmit+0x264/0x3e0
[   33.150073]  [] __dev_queue_xmit+0x4bd/0x530
[   33.150083]  [] dev_queue_xmit_sk+0x13/0x20
[   33.150099]  [] neigh_connected_output+0xc2/0x110
[   33.150110]  [] neigh_update+0x333/0x770
[   33.150117]  [] arp_process.isra.15+0x2f7/0x690
[   33.150117]  [] arp_rcv+0xe6/0x130
[   33.150117]  [] __netif_receive_skb_core+0x693/0x830
[   33.150117]  [] __netif_receive_skb+0x18/0x60
[   33.150117]  [] process_backlog+0xb2/0x150
[   33.150117]  [] net_rx_action+0x212/0x340
[   33.150117]  [] __do_softirq+0x10b/0x2d0
[   33.150117]  [] irq_exit+0x145/0x150
[   33.150117]  [] do_IRQ+0x58/0xf0
[   33.150117]  [] common_interrupt+0x6e/0x6e
[   33.150117][] ? native_safe_halt+0x6/0x10
[   33.150117]  [] ? rcu_eqs_enter+0xa3/0xb0
[   33.150117]  [] default_idle+0x1e/0xc0
[   33.150117]  [] arch_cpu_idle+0xf/0x20
[   33.150117]  [] cpu_startup_entry+0x377/0x3f0
[   33.150117]  [] rest_init+0x7c/0x80
[   33.150117]  [] start_kernel+0x484/0x4a5
[   33.150117]  [] ? early_idt_handler_array+0x120/0x120
[   33.150117]  [] x86_64_start_reservations+0x2a/0x2c
[   33.150117]  [] x86_64_start_kernel+0x145/0x168
[   33.150117] ---[ end trace ff4df9d904cced48 ]---

  Ralf
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/2] ax25: Stop using sock->sk_protinfo.

2015-06-26 Thread Ralf Baechle
On Thu, Jun 25, 2015 at 06:19:07AM -0700, David Miller wrote:

> Just make a ax25_sock structure that provides the ax25_cb pointer.

Nice minimal solution, thanks!

I have the big solution my queue which combines struct sock with ax25_cb
into struct ax25_sock but that's more complex because currently there is
the possibility for an ax25_cb to be created by an incoming connection
request even without a socket.

  Ralf
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] NET: ROSE: Don't dereference NULL neighbour pointer.

2015-06-18 Thread Ralf Baechle
A ROSE socket doesn't necessarily always have a neighbour pointer so check
if the neighbour pointer is valid before dereferencing it.

Signed-off-by: Ralf Baechle 
Tested-by: Bernard Pidoux 
Cc: sta...@vger.kernel.org #2.6.11+

diff --git a/net/rose/af_rose.c b/net/rose/af_rose.c
index 8ae6030..dd304bc 100644
--- a/net/rose/af_rose.c
+++ b/net/rose/af_rose.c
@@ -192,7 +192,8 @@ static void rose_kill_by_device(struct net_device *dev)
 
if (rose->device == dev) {
rose_disconnect(s, ENETUNREACH, ROSE_OUT_OF_ORDER, 0);
-   rose->neighbour->use--;
+   if (rose->neighbour)
+   rose->neighbour->use--;
rose->device = NULL;
}
}
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] ssb: fix handling of ssb_pmu_get_alp_clock()

2015-06-09 Thread Ralf Baechle
On Sun, Jun 07, 2015 at 09:02:23AM +0200, Michael Büsch wrote:

> Signed-off-by: Michael Buesch 
> 
> Can some MIPS people take this, please?

Will do, as usual.  Unfortunately this missed my last pull request so
it's going to Linus by the end of the week.

  Ralf
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] net: rose: Use mod_timer

2015-06-06 Thread Ralf Baechle DL5RB
Hi Vaishali,

On Sat, Jun 06, 2015 at 09:52:34AM +0530, Vaishali Thakkar wrote:

> Use mod_timer instead of del_timer followed by add_timer to update
> the expire field of the active timer.
> 
> The semantic patch that performs this transformation is as follows:
> 
> @change@
> expression e1, e2, e3, e4;
> @@
> 
> - del_timer(&e1);
> ... when != e1 = e3
> - e1.expires = e2;
> ... when != e1 = e4
> - add_timer (&e1);
> + mod_timer (&e1, e2);

This isn't quite right.  All the instances of this pattern in the ROSE
stack also modify the timer's data and function fields which if the timer
is still running and expiring while being fiddled with, might result in
a race condition, that is the old function but new data field being used
in combination or something like that.

For some of the timers (maybe all?) it should be possible to proof that
always the same values for data and function are being used.  These
initializations could then be used elsewhere and the code could then
indeed be switched to mod_timer.

  Ralf
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [UPDATED PATCH] SGISEEQ: use cached memory access to make driver work on IP28

2007-12-19 Thread Ralf Baechle
On Wed, Dec 19, 2007 at 01:42:36PM +0100, Thomas Bogendoerfer wrote:

> - Use inline functions for dma_sync_* instead of macros 
> - added Kconfig change to make selection for similair SGI boxes easier
> 
> Signed-off-by: Thomas Bogendoerfer <[EMAIL PROTECTED]>

Acked-by: Ralf Baechle <[EMAIL PROTECTED]>

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


Re: Inconsistent lock state and possible irq lock inversion dependency detected in ax25.ko

2007-12-04 Thread Ralf Baechle
On Wed, Dec 05, 2007 at 12:17:47AM +0100, Jarek Poplawski wrote:

> Bernard, I think you've forgotten at least about some distinct
> changelog and signed-off-by?
> 
> Jarek P.
> ---
> 
> ax25_subr.c part:
> Acked-by: Jarek Poplawski <[EMAIL PROTECTED]>

The fix for the deadlock due to taking rose_node_list_lock twice:

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

Part of Bernard's patch is undoing d85838c55d836c33077344fab424f200f2827d84,
this one should probably reverted separately.

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


Re: [UPDATED PATCH] SGISEEQ: use cached memory access to make driver work on IP28

2007-12-04 Thread Ralf Baechle
On Tue, Dec 04, 2007 at 03:14:46PM -0500, Jeff Garzik wrote:

>> Changes to last version:
>> - Use inline functions for dma_sync_* instead of macros (suggested by Ralf)
>> - added Kconfig change to make selection for similair SGI boxes easier
>
> Has Ralf ACK'd this updated version?

Acked-by: Ralf Baechle <[EMAIL PROTECTED]>

> This is for 2.6.25 (i.e. not a bug fix for 2.6.24-rc) I presume?

Yes.  IP28 support it scheduled to be merged for 2.6.25.

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


Re: [PATCH] SGISEEQ: use cached memory access to make driver work on IP28

2007-11-27 Thread Ralf Baechle
On Sat, Nov 24, 2007 at 01:29:19PM +0100, Thomas Bogendoerfer wrote:

> Following patch is clearly 2.6.25 material and is needed to get SGI IP28
> machines supported.
> 
> Thomas.
> 
> SGI IP28 machines would need special treatment (enable adding addtional
> wait states) when accessing memory uncached. To avoid this pain I changed
> the driver to use only cached access to memory.
> 
> Signed-off-by: Thomas Bogendoerfer <[EMAIL PROTECTED]>

IP28 is clearly a maximum weirdo beast.  Technically the patch looks fine
it's just a few stilistic issues such as there no reason for
DMA_SYNC_DESC_CPU and DMA_SYNC_DESC_DEV being macros so why not using
inlines.

Acked-by: Ralf Baechle <[EMAIL PROTECTED]>

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


Re: [RFC] dependencies for platform drivers (was Re: ax88796: add superh to kconfig dependencies)

2007-11-09 Thread Ralf Baechle
On Thu, Nov 08, 2007 at 08:18:54AM +, Al Viro wrote:

> On Thu, Nov 08, 2007 at 04:31:05PM +0900, Magnus Damm wrote:
> >  config AX88796
> > tristate "ASIX AX88796 NE2000 clone support"
> > -   depends on ARM || MIPS
> > +   depends on ARM || MIPS || SUPERH
> 
> You know, that really sucks more and more.  How about doing the following:
>   a) making it depend on PLAT_HAS_AX88796
>   b) adding selects for all subarchitectures that have the corresponding
> platform device
> and setting that as a uniform policy for platform drivers?  For things like
> SM501 we would do
> config MFD_SM501
>   depends on PCI || PLAT_HAS_SM501
> etc.
> 
> Seriously, folks, we are getting shitloads of platform drivers with no
> dependencies whatsoever, needed on a handful of targets and occasionally
> failing to build on unrelated architectures.  Moreover, having a list
> of architectures in dependencies for each of those suckers is a PITA
> from the conflict POV.  Not to mention platform drivers that fall into
> the mainline kernel with not a single platform device for them, etc.
> 
> Comments?

commit def47c5095d53814512bb0c62ec02dfdec769db1
Author: Jeff Garzik <[EMAIL PROTECTED]>
Date:   Tue Jul 10 14:06:48 2007 -0400

[netdrvr] Fix dependencies for ax88796 ne2k clone driver

It needs writesb(), not available on all platforms.

Signed-off-by: Jeff Garzik <[EMAIL PROTECTED]>

diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index a3bef22..a64c2fb 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -199,6 +199,7 @@ source "drivers/net/arm/Kconfig"
 
 config AX88796
tristate "ASIX AX88796 NE2000 clone support"
+   depends on ARM || MIPS
select CRC32
select MII
help


If writesb() is not an official API then maybe the answer should have been
to either add that API to other architectures or fix the driver.

I guess this incident means I need to go through all Kconfig* files to
see what bogus architecture dependencies on MIPS or !MIPS exist ...

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


Re: [PATCH] Fix/Rewrite of the mipsnet driver

2007-10-28 Thread Ralf Baechle
On Sun, Oct 28, 2007 at 01:22:04PM -0700, Stephen Hemminger wrote:

> > -#define MIPSNET_INTCTL_TXDONE ((uint32_t)(1 <<  0))
> > -#define MIPSNET_INTCTL_RXDONE ((uint32_t)(1 <<  1))
> > -#define MIPSNET_INTCTL_TESTBIT((uint32_t)(1 << 31))
> > -#define MIPSNET_INTCTL_ALLSOURCES  (MIPSNET_INTCTL_TXDONE | \
> > -MIPSNET_INTCTL_RXDONE | \
> > -MIPSNET_INTCTL_TESTBIT)
> 
> It is standard practice in the kernel to use u32 rather than uint32_t.

uint32_t has widely leaked in and as long as it's not used in headers
exported to userland is perfectly fine.  But if we want to achieve
consistence throughout the kernel it'll take a little witch hunt for
uint32_t and co.

> Also cast of shift is unneeded  (1u << 0) works fine.

Old sins of mipsnet.h which was just copied into mipsnet.c.  Or toothing
pains of a driver on its way to sanity.

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


Re: [PATCH] Fix/Rewrite of the mipsnet driver

2007-10-28 Thread Ralf Baechle
On Sun, Oct 28, 2007 at 04:38:46AM +, Thiemo Seufer wrote:

> Hello All,
> 
> currently the mipsnet driver fails after transmitting a number of
> packages because SKBs are allocated but never freed. I fixed that
> and coudn't refrain from removing the most egregious warts.
> 
> - mipsnet.h folded into mipsnet.c, as it doesn't provide any
>   useful external interface.
> - Free SKB after transmission.
> - Call free_irq in mipsnet_close, to balance the request_irq in
>   mipsnet_open.
> - Removed duplicate read of rxDataCount.
> - Some identifiers are now less verbose.
> - Removed dead and/or unnecessarily complex code.
> - Code formatting fixes.
> 
> Tested on Qemu's mipssim emulation, with this patch it can boot a
> Debian NFSroot.

The patch does no longer apply to a recent tree, can you respin it?

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


Re: [PATCH] Remove always-true tests in irq handlers

2007-10-26 Thread Ralf Baechle
On Fri, Oct 26, 2007 at 05:40:24AM -0400, Jeff Garzik wrote:

> In these drivers, dev_id is always non-NULL.
> 
> Signed-off-by: Jeff Garzik <[EMAIL PROTECTED]>
> ---
>  arch/ia64/hp/sim/simeth.c   |5 -
>  arch/mips/pmc-sierra/msp71xx/msp_hwbutton.c |    5 +

Acked-by: Ralf Baechle <[EMAIL PROTECTED]>

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


[MIPS] MIPSnet: Delete all the useless debugging printks.

2007-10-22 Thread Ralf Baechle
Plus minor formatting fixes.

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

 drivers/net/mipsnet.c |   44 
 1 file changed, 4 insertions(+), 40 deletions(-)

diff --git a/drivers/net/mipsnet.c b/drivers/net/mipsnet.c
index 37707a0..aafc3ce 100644
--- a/drivers/net/mipsnet.c
+++ b/drivers/net/mipsnet.c
@@ -30,6 +30,7 @@ static int ioiocpy_frommipsnet(struct net_device *dev, 
unsigned char *kdata,
int len)
 {
uint32_t available_len = inl(mipsnet_reg_address(dev, rxDataCount));
+
if (available_len < len)
return -EFAULT;
 
@@ -45,14 +46,8 @@ static inline ssize_t mipsnet_put_todevice(struct net_device 
*dev,
int count_to_go = skb->len;
char *buf_ptr = skb->data;
 
-   pr_debug("%s: %s(): telling MIPSNET txDataCount(%d)\n",
-dev->name, __FUNCTION__, skb->len);
-
outl(skb->len, mipsnet_reg_address(dev, txDataCount));
 
-   pr_debug("%s: %s(): sending data to MIPSNET txDataBuffer(%d)\n",
-dev->name, __FUNCTION__, skb->len);
-
for (; count_to_go; buf_ptr++, count_to_go--)
outb(*buf_ptr, mipsnet_reg_address(dev, txDataBuffer));
 
@@ -64,10 +59,8 @@ static inline ssize_t mipsnet_put_todevice(struct net_device 
*dev,
 
 static int mipsnet_xmit(struct sk_buff *skb, struct net_device *dev)
 {
-   pr_debug("%s:%s(): transmitting %d bytes\n",
-dev->name, __FUNCTION__, skb->len);
-
-   /* Only one packet at a time. Once TXDONE interrupt is serviced, the
+   /*
+* Only one packet at a time. Once TXDONE interrupt is serviced, the
 * queue will be restarted.
 */
netif_stop_queue(dev);
@@ -94,8 +87,6 @@ static inline ssize_t mipsnet_get_fromdev(struct net_device 
*dev, size_t count)
skb->protocol = eth_type_trans(skb, dev);
skb->ip_summed = CHECKSUM_UNNECESSARY;
 
-   pr_debug("%s:%s(): pushing RXed data to kernel\n",
-dev->name, __FUNCTION__);
netif_rx(skb);
 
dev->stats.rx_packets++;
@@ -112,44 +103,29 @@ static irqreturn_t mipsnet_interrupt(int irq, void 
*dev_id)
uint64_t interruptFlags;
 
if (irq == dev->irq) {
-   pr_debug("%s:%s(): irq %d for device\n",
-dev->name, __FUNCTION__, irq);
-
retval = IRQ_HANDLED;
 
interruptFlags =
inl(mipsnet_reg_address(dev, interruptControl));
-   pr_debug("%s:%s(): intCtl=0x%016llx\n", dev->name,
-__FUNCTION__, interruptFlags);
 
if (interruptFlags & MIPSNET_INTCTL_TXDONE) {
-   pr_debug("%s:%s(): got TXDone\n",
-dev->name, __FUNCTION__);
outl(MIPSNET_INTCTL_TXDONE,
 mipsnet_reg_address(dev, interruptControl));
/* only one packet at a time, we are done. */
netif_wake_queue(dev);
} else if (interruptFlags & MIPSNET_INTCTL_RXDONE) {
-   pr_debug("%s:%s(): got RX data\n",
-dev->name, __FUNCTION__);
mipsnet_get_fromdev(dev,
inl(mipsnet_reg_address(dev, rxDataCount)));
-   pr_debug("%s:%s(): clearing RX int\n",
-dev->name, __FUNCTION__);
outl(MIPSNET_INTCTL_RXDONE,
 mipsnet_reg_address(dev, interruptControl));
 
} else if (interruptFlags & MIPSNET_INTCTL_TESTBIT) {
-   pr_debug("%s:%s(): got test interrupt\n",
-dev->name, __FUNCTION__);
/*
 * TESTBIT is cleared on read.
 * And takes effect after a write with 0
 */
outl(0, mipsnet_reg_address(dev, interruptControl));
} else {
-   pr_debug("%s:%s(): no valid fags 0x%016llx\n",
-dev->name, __FUNCTION__, interruptFlags);
/* Maybe shared IRQ, just ignore, no clearing. */
retval = IRQ_NONE;
}
@@ -165,22 +141,15 @@ static irqreturn_t mipsnet_interrupt(int irq, void 
*dev_id)
 static int mipsnet_open(struct net_device *dev)
 {
int err;
-   pr_debug("%s: mipsnet_open\n", dev->name);
 
err = request_irq(dev->irq, &mipsnet_interrupt,
  IRQF_SHARED, dev->name, (void *) dev);
 
if (err) {
-   pr_debug("%s: %s(): can't get

[NET] TC35815: Fix build

2007-10-15 Thread Ralf Baechle
bea3348eef27e6044b6161fd04c3152215f96411 broke the build of tc35815.c
for the non-NAPI case:

  CC  drivers/net/tc35815.o
drivers/net/tc35815.c: In function 'tc35815_interrupt':
drivers/net/tc35815.c:1464: error: redefinition of 'lp'
drivers/net/tc35815.c:1443: error: previous definition of 'lp' was here

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

diff --git a/drivers/net/tc35815.c b/drivers/net/tc35815.c
index a679f43..8038f28 100644
--- a/drivers/net/tc35815.c
+++ b/drivers/net/tc35815.c
@@ -1461,7 +1461,6 @@ static irqreturn_t tc35815_interrupt(int irq, void 
*dev_id)
}
return IRQ_NONE;
 #else
-   struct tc35815_local *lp = dev->priv;
int handled;
u32 status;
 
-
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] SAA9730: Fix build

2007-10-15 Thread Ralf Baechle
Fix build breakage by the recent statistics cleanup in cset
09f75cd7bf13720738e6a196cc0107ce9a5bd5a0.

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

diff --git a/drivers/net/saa9730.c b/drivers/net/saa9730.c
index 14361e8..c65199d 100644
--- a/drivers/net/saa9730.c
+++ b/drivers/net/saa9730.c
@@ -97,13 +97,16 @@ static void evm_saa9730_unblock_lan_int(struct 
lan_saa9730_private *lp)
   &lp->evm_saa9730_regs->InterruptBlock1);
 }
 
-static void __attribute_used__ show_saa9730_regs(struct lan_saa9730_private 
*lp)
+static void __used show_saa9730_regs(struct net_device *dev)
 {
+   struct lan_saa9730_private *lp = netdev_priv(dev);
int i, j;
+
printk("TxmBufferA = %p\n", lp->TxmBuffer[0][0]);
printk("TxmBufferB = %p\n", lp->TxmBuffer[1][0]);
printk("RcvBufferA = %p\n", lp->RcvBuffer[0][0]);
printk("RcvBufferB = %p\n", lp->RcvBuffer[1][0]);
+
for (i = 0; i < LAN_SAA9730_BUFFERS; i++) {
for (j = 0; j < LAN_SAA9730_TXM_Q_SIZE; j++) {
printk("TxmBuffer[%d][%d] = %x\n", i, j,
@@ -146,11 +149,13 @@ static void __attribute_used__ show_saa9730_regs(struct 
lan_saa9730_private *lp)
   readl(&lp->lan_saa9730_regs->RxCtl));
printk("lp->lan_saa9730_regs->RxStatus = %x\n",
   readl(&lp->lan_saa9730_regs->RxStatus));
+
for (i = 0; i < LAN_SAA9730_CAM_DWORDS; i++) {
writel(i, &lp->lan_saa9730_regs->CamAddress);
printk("lp->lan_saa9730_regs->CamData = %x\n",
   readl(&lp->lan_saa9730_regs->CamData));
}
+
printk("dev->stats.tx_packets = %lx\n", dev->stats.tx_packets);
printk("dev->stats.tx_errors = %lx\n", dev->stats.tx_errors);
printk("dev->stats.tx_aborted_errors = %lx\n",
@@ -855,7 +860,7 @@ static void lan_saa9730_tx_timeout(struct net_device *dev)
/* Transmitter timeout, serious problems */
dev->stats.tx_errors++;
printk("%s: transmit timed out, reset\n", dev->name);
-   /*show_saa9730_regs(lp); */
+   /*show_saa9730_regs(dev); */
lan_saa9730_restart(lp);
 
dev->trans_start = jiffies;
-
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] Jazzsonic: Fix warning about unused variable.

2007-10-15 Thread Ralf Baechle
Caused by "[NET]: Introduce and use print_mac() and DECLARE_MAC_BUF()"
aka 0795af5729b18218767fab27c44b1384f72dc9ad.

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

diff --git a/drivers/net/jazzsonic.c b/drivers/net/jazzsonic.c
index d3825c8..5c154fe 100644
--- a/drivers/net/jazzsonic.c
+++ b/drivers/net/jazzsonic.c
@@ -208,7 +208,6 @@ static int __init jazz_sonic_probe(struct platform_device 
*pdev)
struct sonic_local *lp;
struct resource *res;
int err = 0;
-   int i;
DECLARE_MAC_BUF(mac);
 
res = platform_get_resource(pdev, IORESOURCE_MEM, 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


[NET] MIPSsim: General cleanup

2007-10-12 Thread Ralf Baechle
General cleanups mostly as suggested by checkpatch plus getting rid of
homebrew version of offsetof().

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

 drivers/net/mipsnet.c |   63 ++---
 drivers/net/mipsnet.h |   83 ++
 2 files changed, 75 insertions(+), 71 deletions(-)

diff --git a/drivers/net/mipsnet.c b/drivers/net/mipsnet.c
index d593175..37707a0 100644
--- a/drivers/net/mipsnet.c
+++ b/drivers/net/mipsnet.c
@@ -7,12 +7,12 @@
 #define DEBUG
 
 #include 
+#include 
 #include 
 #include 
 #include 
 #include 
 #include 
-#include 
 #include 
 
 #include "mipsnet.h"   /* actual device IO mapping */
@@ -33,9 +33,8 @@ static int ioiocpy_frommipsnet(struct net_device *dev, 
unsigned char *kdata,
if (available_len < len)
return -EFAULT;
 
-   for (; len > 0; len--, kdata++) {
+   for (; len > 0; len--, kdata++)
*kdata = inb(mipsnet_reg_address(dev, rxDataBuffer));
-   }
 
return inl(mipsnet_reg_address(dev, rxDataCount));
 }
@@ -47,16 +46,15 @@ static inline ssize_t mipsnet_put_todevice(struct 
net_device *dev,
char *buf_ptr = skb->data;
 
pr_debug("%s: %s(): telling MIPSNET txDataCount(%d)\n",
-dev->name, __FUNCTION__, skb->len);
+dev->name, __FUNCTION__, skb->len);
 
outl(skb->len, mipsnet_reg_address(dev, txDataCount));
 
pr_debug("%s: %s(): sending data to MIPSNET txDataBuffer(%d)\n",
-dev->name, __FUNCTION__, skb->len);
+dev->name, __FUNCTION__, skb->len);
 
-   for (; count_to_go; buf_ptr++, count_to_go--) {
+   for (; count_to_go; buf_ptr++, count_to_go--)
outb(*buf_ptr, mipsnet_reg_address(dev, txDataBuffer));
-   }
 
dev->stats.tx_packets++;
dev->stats.tx_bytes += skb->len;
@@ -67,7 +65,7 @@ static inline ssize_t mipsnet_put_todevice(struct net_device 
*dev,
 static int mipsnet_xmit(struct sk_buff *skb, struct net_device *dev)
 {
pr_debug("%s:%s(): transmitting %d bytes\n",
-dev->name, __FUNCTION__, skb->len);
+dev->name, __FUNCTION__, skb->len);
 
/* Only one packet at a time. Once TXDONE interrupt is serviced, the
 * queue will be restarted.
@@ -83,7 +81,8 @@ static inline ssize_t mipsnet_get_fromdev(struct net_device 
*dev, size_t count)
struct sk_buff *skb;
size_t len = count;
 
-   if (!(skb = alloc_skb(len + 2, GFP_KERNEL))) {
+   skb = alloc_skb(len + 2, GFP_KERNEL);
+   if (!skb) {
dev->stats.rx_dropped++;
return -ENOMEM;
}
@@ -96,7 +95,7 @@ static inline ssize_t mipsnet_get_fromdev(struct net_device 
*dev, size_t count)
skb->ip_summed = CHECKSUM_UNNECESSARY;
 
pr_debug("%s:%s(): pushing RXed data to kernel\n",
-dev->name, __FUNCTION__);
+dev->name, __FUNCTION__);
netif_rx(skb);
 
dev->stats.rx_packets++;
@@ -114,42 +113,44 @@ static irqreturn_t mipsnet_interrupt(int irq, void 
*dev_id)
 
if (irq == dev->irq) {
pr_debug("%s:%s(): irq %d for device\n",
-dev->name, __FUNCTION__, irq);
+dev->name, __FUNCTION__, irq);
 
retval = IRQ_HANDLED;
 
interruptFlags =
inl(mipsnet_reg_address(dev, interruptControl));
pr_debug("%s:%s(): intCtl=0x%016llx\n", dev->name,
-__FUNCTION__, interruptFlags);
+__FUNCTION__, interruptFlags);
 
if (interruptFlags & MIPSNET_INTCTL_TXDONE) {
pr_debug("%s:%s(): got TXDone\n",
-dev->name, __FUNCTION__);
+dev->name, __FUNCTION__);
outl(MIPSNET_INTCTL_TXDONE,
 mipsnet_reg_address(dev, interruptControl));
-   // only one packet at a time, we are done.
+   /* only one packet at a time, we are done. */
netif_wake_queue(dev);
} else if (interruptFlags & MIPSNET_INTCTL_RXDONE) {
pr_debug("%s:%s(): got RX data\n",
-dev->name, __FUNCTION__);
+dev->name, __FUNCTION__);
mipsnet_get_fromdev(dev,
-   inl(mipsnet_reg_address(dev, rxDataCount)));
+   inl(mipsnet_reg_address(dev, rxDataCount)));
pr_debug("%s:%s(): clearing RX int\n",
-dev->name, __FUNCTION_

Re: [PATCH] sb1250-mac: Driver model & phylib update

2007-09-25 Thread Ralf Baechle
On Fri, Sep 21, 2007 at 12:44:09PM -0700, Andrew Morton wrote:

> >  A driver model and phylib update.
> 
> akpm:/usr/src/25> diffstat patches/git-net.patch | tail -n 1
>  1013 files changed, 187667 insertions(+), 23587 deletions(-)
> 
> Sorry, but raising networking patches against Linus's crufty
> old mainline tree just isn't viable at present.

Out of curiosity:

[EMAIL PROTECTED] linux-queue]$ git diff $(git merge-base master 
v2.6.23-rc8-mm1)..v2.6.23-rc8-mm1 | wc -cl
1046669 31900996
[EMAIL PROTECTED] linux-queue]$ git diff $(git merge-base master 
v2.6.23-rc8-mm1)..v2.6.23-rc8-mm1 | diffstat | tail -1
 6049 files changed, 573635 insertions(+), 207630 deletions(-)
[EMAIL PROTECTED] linux-queue]$ 

We're all a little too productive ;-)

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


Re: [PATCH] sb1250-mac.c: De-typedef, de-volatile, de-etc...

2007-09-13 Thread Ralf Baechle
On Thu, Sep 13, 2007 at 03:13:06PM +0100, Maciej W. Rozycki wrote:

>  Hmm, works fine with linux-2.6.git#master.  I do not recall any recent 
> activity with this driver -- I wonder what the difference is.  Let me 
> see...

Hmm...  HEAD du jour has no differences for the sb1250-mac between lmo
and kernel.org.

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


Re: [PATCH][MIPS][7/7] AR7: ethernet

2007-09-13 Thread Ralf Baechle
On Thu, Sep 13, 2007 at 02:42:46AM +0100, Thiemo Seufer wrote:

> > All struct members here are sized such that there is no padding needed, so
> > the packed attribute doesn't buy you anything - unless of course the
> > entire structure is missaligned but I don't see how that would be possible
> > in this driver so the __attribute__ ((packed)) should go - it result in
> > somwhat larger and slower code.
> 
> FWIW, a modern gcc will warn about such superfluous packed attributes,
> that's another reason to remove those.

I doubt it will in this case; the packed structure is dereferenced by a
pointer so no way for gcc to know the alignment.

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


Re: [PATCH][MIPS][7/7] AR7: ethernet

2007-09-12 Thread Ralf Baechle
; + struct cpmac_priv *priv;
> + struct net_device *dev;
> + struct plat_cpmac_data *pdata;
> +
> + pdata = pdev->dev.platform_data;
> +
> + for (phy_id = 0; phy_id < PHY_MAX_ADDR; phy_id++) {
> + if (!(pdata->phy_mask & (1 << phy_id)))
> + continue;
> + if (!cpmac_mii.phy_map[phy_id])
> + continue;
> + break;
> + }
> +
> + if (phy_id == PHY_MAX_ADDR) {
> + if (external_switch)
> + phy_id = 0;
> + else {
> + printk(KERN_ERR "cpmac: no PHY present\n");
> + return -ENODEV;
> + }
> + }
> +
> + dev = alloc_etherdev(sizeof(struct cpmac_priv));
> +
> + if (!dev) {
> + printk(KERN_ERR
> + "cpmac: Unable to allocate net_device structure!\n");
> + return -ENOMEM;
> + }
> +
> + SET_MODULE_OWNER(dev);

Set SET_MODULE_OWNER is a useless nop which only exists in 2.6 for
driver source compatibility with 2.4.  So you can remove this call.

I used the opportunity to send out a patch to remove SET_MODULE_OWNER
from the kernel entirely.

> + platform_set_drvdata(pdev, dev);
> + priv = netdev_priv(dev);
> +
> + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "regs");
> + if (!res) {
> + rc = -ENODEV;
> + goto fail;
> + }
> +
> + dev->mem_start = res->start;
> + dev->mem_end = res->end;
> + dev->irq = platform_get_irq_byname(pdev, "irq");
> +
> + dev->mtu= 1500;

Initializing this field is redundant; alloc_etherdev has already done it,
so remove this line.

> + dev->open   = cpmac_open;
> + dev->stop   = cpmac_stop;
> + dev->set_config = cpmac_config;
> + dev->hard_start_xmit= cpmac_start_xmit;
> + dev->do_ioctl   = cpmac_ioctl;
> + dev->get_stats  = cpmac_stats;
> + dev->change_mtu = cpmac_change_mtu;
> + dev->set_mac_address= cpmac_set_mac_address;
> + dev->set_multicast_list = cpmac_set_multicast_list;
> + dev->tx_timeout = cpmac_tx_timeout;
> + dev->ethtool_ops= &cpmac_ethtool_ops;
> + if (!disable_napi) {
> + dev->poll = cpmac_poll;
> + dev->weight = min(rx_ring_size, 64);
> + }
> +
> + memset(priv, 0, sizeof(struct cpmac_priv));

Useless, alloc_etherdev does that already.

> + spin_lock_init(&priv->lock);
> + priv->msg_enable = netif_msg_init(NETIF_MSG_WOL, 0x3fff);
> + priv->config = pdata;
> + priv->dev = dev;
> + memcpy(dev->dev_addr, priv->config->dev_addr, sizeof(dev->dev_addr));
> + if (phy_id == 31)
> + snprintf(priv->phy_name, BUS_ID_SIZE, PHY_ID_FMT,
> +  cpmac_mii.id, phy_id);
> + else
> + snprintf(priv->phy_name, BUS_ID_SIZE, "[EMAIL PROTECTED]:%d", 
> 100, 1);
> +
> + if ((rc = register_netdev(dev))) {
> + printk(KERN_ERR "cpmac: error %i registering device %s\n",
> +rc, dev->name);
> + goto fail;
> + }
> +
> + printk(KERN_INFO "cpmac: device %s (regs: %p, irq: %d, phy: %s, mac: ",
> +dev->name, (u32 *)dev->mem_start, dev->irq,
> +priv->phy_name);
> + for (i = 0; i < 6; i++)
> + printk("%02x%s", dev->dev_addr[i], i < 5 ? ":" : ")\n");
> +
> + return 0;
> +
> +fail:
> + free_netdev(dev);
> + return rc;
> +}
> +
> +static int __devexit cpmac_remove(struct platform_device *pdev)
> +{
> + struct net_device *dev = platform_get_drvdata(pdev);
> + unregister_netdev(dev);
> + free_netdev(dev);
> + return 0;
> +}
> +
> +static struct platform_driver cpmac_driver = {
> + .driver.name = "cpmac",
> + .probe = cpmac_probe,
> + .remove = cpmac_remove,

This should be:

.remove = __devexit_p(cpmac_remove),

to avoid the final link from blowing up when the driver is built into the
kernel.

> +};
> +
> +int __devinit cpmac_init(void)

Make this function static; no need to export.

> +{
> + u32 mask;
> + int i, res;
> + cpmac_mii.priv =
> + ioremap_nocache(AR7_REGS_MDIO, sizeof(struct cpmac_mdio_regs));
> +
> + if (!cpmac_mii.priv) {
> + printk(KERN_ERR "Can't ioremap mdio registers\n");
> + return -ENXIO;
> + }
> +
> +#warning FIXME: unhardcode gpio&reset bits

Seeing such warnings always gives me a warm fuzzy feeling ;-)

> + ar7_gpio_disable(26);
> + ar7_gpio_disable(27);
> + ar7_device_reset(AR7_RESET_BIT_CPMAC_LO);
> + ar7_device_reset(AR7_RESET_BIT_CPMAC_HI);
> + ar7_device_reset(AR7_RESET_BIT_EPHY);
> +
> + cpmac_mii.reset(&cpmac_mii);
> +
> + for (i = 0; i < 30; i++) {
> + mask = ((struct cpmac_mdio_regs *)cpmac_mii.priv)->alive;
> + if (mask)
> + break;
> + }
> +
> +/*   mask &= 0x7fff;
> + if (mask & (mask - 1)) {*/
> + external_switch = 1;
> + mask = 0;
> +/*   }*/
> +
> + cpmac_mii.phy_mask = ~(mask | 0x8000);
> +
> + res = mdiobus_register(&cpmac_mii);
> + if (res)
> + goto fail_mii;
> +
> + res = platform_driver_register(&cpmac_driver);
> + if (res)
> + goto fail_cpmac;
> +
> + return 0;
> +
> +fail_cpmac:
> + mdiobus_unregister(&cpmac_mii);
> +
> +fail_mii:
> + iounmap(cpmac_mii.priv);
> +
> + return res;
> +}
> +
> +void __devexit cpmac_exit(void)
> +{
> + platform_driver_unregister(&cpmac_driver);
> + mdiobus_unregister(&cpmac_mii);
> +}
> +
> +module_init(cpmac_init);
> +module_exit(cpmac_exit);

Time to run ...

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


Re: [NET] Nuke SET_NETDEV_DEVICE macro

2007-09-12 Thread Ralf Baechle
On Wed, Sep 12, 2007 at 05:27:13PM +0100, Ralf Baechle wrote:

> It's been a useless no-op for long enough in 2.6 so I figured it's time to
> remove it.  The number of people that could object because they're
> maintaining unified 2.4 and 2.6 drivers is probably rather small.

Whops, wrong patch and subject, please ignore.
-
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] sb1250-mac.c: De-typedef, de-volatile, de-etc...

2007-09-10 Thread Ralf Baechle
On Mon, Sep 10, 2007 at 01:20:38PM +0100, Maciej W. Rozycki wrote:

>  Remove typedefs, volatiles and convert kmalloc()/memset() pairs to
> kcalloc().  Also reformat the surrounding clutter.
> 
> Signed-off-by: Maciej W. Rozycki <[EMAIL PROTECTED]>
> ---
>  Per your request, Andrew, a while ago.  It builds, runs, passes 
> checkpatch.pl and sparse.  No semantic changes.

One step closer to sanity for this driver.  So it's got my ACK.

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


Re: [PATCH 1/2] remove asm/bitops.h includes

2007-09-10 Thread Ralf Baechle
On Sat, Sep 08, 2007 at 09:00:08PM +0100, Jiri Slaby wrote:

> 
> remove asm/bitops.h includes
> 
> including asm/bitops directly may cause compile errors. don't include it
> and include linux/bitops instead. next patch will deny including asm header
> directly.
> 
> Cc: Adrian Bunk <[EMAIL PROTECTED]>
> Signed-off-by: Jiri Slaby <[EMAIL PROTECTED]>

For the MIPS and hamradio bits:

Acked-by: Ralf Baechle <[EMAIL PROTECTED]>

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


[NET] sgiseeq: replace use of dma_cache_wback_inv

2007-09-04 Thread Ralf Baechle
The sgiseeq driver is one of the few remaining users of the ancient
cache banging DMA API.  Replaced with the modern days DMA API.

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

diff --git a/drivers/net/sgiseeq.c b/drivers/net/sgiseeq.c
index 0fb74cb..eb67b02 100644
--- a/drivers/net/sgiseeq.c
+++ b/drivers/net/sgiseeq.c
@@ -75,6 +75,7 @@ struct sgiseeq_init_block { /* Note the name ;-) */
 
 struct sgiseeq_private {
struct sgiseeq_init_block *srings;
+   dma_addr_t srings_dma;
 
/* Ptrs to the descriptors in uncached space. */
struct sgiseeq_rx_desc *rx_desc;
@@ -643,13 +644,20 @@ static int __init sgiseeq_probe(struct platform_device 
*pdev)
sp = netdev_priv(dev);
 
/* Make private data page aligned */
-   sr = (struct sgiseeq_init_block *) get_zeroed_page(GFP_KERNEL);
+   sr = dma_alloc_coherent(&pdev->dev, sizeof(*sp->srings),
+   &sp->srings_dma, GFP_KERNEL);
if (!sr) {
printk(KERN_ERR "Sgiseeq: Page alloc failed, aborting.\n");
err = -ENOMEM;
goto err_out_free_dev;
}
sp->srings = sr;
+   sp->rx_desc = sp->srings->rxvector;
+   sp->tx_desc = sp->srings->txvector;
+
+   /* A couple calculations now, saves many cycles later. */
+   setup_rx_ring(sp->rx_desc, SEEQ_RX_BUFFERS);
+   setup_tx_ring(sp->tx_desc, SEEQ_TX_BUFFERS);
 
memcpy(dev->dev_addr, pd->mac, ETH_ALEN);
 
@@ -662,19 +670,6 @@ static int __init sgiseeq_probe(struct platform_device 
*pdev)
sp->name = sgiseeqstr;
sp->mode = SEEQ_RCMD_RBCAST;
 
-   sp->rx_desc = (struct sgiseeq_rx_desc *)
- CKSEG1ADDR(ALIGNED(&sp->srings->rxvector[0]));
-   dma_cache_wback_inv((unsigned long)&sp->srings->rxvector,
-   sizeof(sp->srings->rxvector));
-   sp->tx_desc = (struct sgiseeq_tx_desc *)
- CKSEG1ADDR(ALIGNED(&sp->srings->txvector[0]));
-   dma_cache_wback_inv((unsigned long)&sp->srings->txvector,
-   sizeof(sp->srings->txvector));
-
-   /* A couple calculations now, saves many cycles later. */
-   setup_rx_ring(sp->rx_desc, SEEQ_RX_BUFFERS);
-   setup_tx_ring(sp->tx_desc, SEEQ_TX_BUFFERS);
-
/* Setup PIO and DMA transfer timing */
sp->hregs->pconfig = 0x161;
sp->hregs->dconfig = HPC3_EDCFG_FIRQ | HPC3_EDCFG_FEOP |
@@ -732,7 +727,8 @@ static int __exit sgiseeq_remove(struct platform_device 
*pdev)
struct sgiseeq_private *sp = netdev_priv(dev);
 
unregister_netdev(dev);
-   free_page((unsigned long) sp->srings);
+   dma_free_coherent(&pdev->dev, sizeof(*sp->srings), sp->srings,
+ sp->srings_dma);
free_netdev(dev);
platform_set_drvdata(pdev, NULL);
 
-
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 8/9] define global BIT macro

2007-08-23 Thread Ralf Baechle
On Sat, Aug 18, 2007 at 11:44:12AM +0200, Jiri Slaby wrote:

> define global BIT macro
> 
> move all local BIT defines to the new globally define macro.
> 
> Signed-off-by: Jiri Slaby <[EMAIL PROTECTED]>

Acked-by: Ralf Baechle <[EMAIL PROTECTED]>

for the MACE ethernet and MIPS bits.

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


[NET] sgiseeq: Fix return type of sgiseeq_remove

2007-08-22 Thread Ralf Baechle
The driver remove method needs to return an int not void.  This was just
never noticed because usually this driver is not being built as a module.

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

diff --git a/drivers/net/sgiseeq.c b/drivers/net/sgiseeq.c
index 384b468..0fb74cb 100644
--- a/drivers/net/sgiseeq.c
+++ b/drivers/net/sgiseeq.c
@@ -726,7 +726,7 @@ err_out:
return err;
 }
 
-static void __exit sgiseeq_remove(struct platform_device *pdev)
+static int __exit sgiseeq_remove(struct platform_device *pdev)
 {
struct net_device *dev = platform_get_drvdata(pdev);
struct sgiseeq_private *sp = netdev_priv(dev);
@@ -735,6 +735,8 @@ static void __exit sgiseeq_remove(struct platform_device 
*pdev)
free_page((unsigned long) sp->srings);
free_netdev(dev);
platform_set_drvdata(pdev, NULL);
+
+   return 0;
 }
 
 static struct platform_driver sgiseeq_driver = {
-
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


[METH] Don't use GFP_DMA for zone allocation.

2007-08-15 Thread Ralf Baechle
IP32 doesn't even have a ZONE_DMA so no point in using GFP_DMA in any
IP32-specific device driver.

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

diff --git a/drivers/net/meth.c b/drivers/net/meth.c
index 92b403b..32bed6b 100644
--- a/drivers/net/meth.c
+++ b/drivers/net/meth.c
@@ -405,7 +405,7 @@ static void meth_rx(struct net_device* dev, unsigned long 
int_status)
priv->stats.rx_length_errors++;
skb = priv->rx_skbs[priv->rx_write];
} else {
-   skb = alloc_skb(METH_RX_BUFF_SIZE, GFP_ATOMIC | 
GFP_DMA);
+   skb = alloc_skb(METH_RX_BUFF_SIZE, GFP_ATOMIC);
if (!skb) {
/* Ouch! No memory! Drop packet on the 
floor */
DPRINTK("No mem: dropping packet\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 13/24] make atomic_read() behave consistently on mips

2007-08-10 Thread Ralf Baechle
On Thu, Aug 09, 2007 at 10:00:04AM -0400, Chris Snook wrote:

> Purify volatile use for atomic[64]_t on mips.
> 
> Signed-off-by: Chris Snook <[EMAIL PROTECTED]>

Acked-by: Ralf Baechle <[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


[NET] IOC3: Switch hw checksumming to ethtool configurable.

2007-07-25 Thread Ralf Baechle
Signed-off-by: Ralf Baechle <[EMAIL PROTECTED]>

---

I've previously sent out this patch a long time ago.  At that time I was
told NETIF_F_IP_CSUM wouldn't make any sense without NETIF_F_SG.  IOC3's
S/G abilities are very limited; it can do upto three segments of which
the first one is upto 104 bytes and part of the packet's TX ring entry,
the second and 3rd ones can be anywhere in the 64-bit PCI address space
but may not cross a 16kB page boundary.  So setting NETIF_F_SG isn't
really an option unless the IOC3 was going to linearize any packet it
can't cope with itself.

So the big question, does NETIF_F_IP_CSUM without NETIF_F_SG make sense?

 drivers/net/Kconfig|   20 
 drivers/net/ioc3-eth.c |   48 
 2 files changed, 32 insertions(+), 36 deletions(-)

Index: linux-2.6/drivers/net/Kconfig
===
--- linux-2.6.orig/drivers/net/Kconfig
+++ linux-2.6/drivers/net/Kconfig
@@ -480,26 +480,6 @@ config SGI_IOC3_ETH
  the Ethernet-HOWTO, available from
  <http://www.tldp.org/docs.html#howto>.
 
-config SGI_IOC3_ETH_HW_RX_CSUM
-   bool "Receive hardware checksums"
-   depends on SGI_IOC3_ETH && INET
-   default y
-   help
- The SGI IOC3 network adapter supports TCP and UDP checksums in
- hardware to offload processing of these checksums from the CPU.  At
- the moment only acceleration of IPv4 is supported.  This option
- enables offloading for checksums on receive.  If unsure, say Y.
-
-config SGI_IOC3_ETH_HW_TX_CSUM
-   bool "Transmit hardware checksums"
-   depends on SGI_IOC3_ETH && INET
-   default y
-   help
- The SGI IOC3 network adapter supports TCP and UDP checksums in
- hardware to offload processing of these checksums from the CPU.  At
- the moment only acceleration of IPv4 is supported.  This option
- enables offloading for checksums on transmit.  If unsure, say Y.
-
 config MIPS_SIM_NET
tristate "MIPS simulator Network device"
depends on MIPS_SIM
Index: linux-2.6/drivers/net/ioc3-eth.c
===
--- linux-2.6.orig/drivers/net/ioc3-eth.c
+++ linux-2.6/drivers/net/ioc3-eth.c
@@ -5,7 +5,7 @@
  *
  * Driver for SGI's IOC3 based Ethernet cards as found in the PCI card.
  *
- * Copyright (C) 1999, 2000, 2001, 2003 Ralf Baechle
+ * Copyright (C) 1999, 2000, 01, 03, 06 Ralf Baechle
  * Copyright (C) 1995, 1999, 2000, 2001 by Silicon Graphics, Inc.
  *
  * References:
@@ -61,12 +61,7 @@
 #include 
 #include 
 #include 
-#include 
-#include 
-#include 
-#include 
 #include 
-#include 
 #include 
 
 /*
@@ -94,6 +89,9 @@ struct ioc3_private {
u32 emcr, ehar_h, ehar_l;
spinlock_t ioc3_lock;
struct mii_if_info mii;
+   unsigned long flags;
+#define IOC3_FLAG_RX_CHECKSUMS 1
+
struct pci_dev *pdev;
 
/* Members used by autonegotiation  */
@@ -520,8 +518,6 @@ static struct net_device_stats *ioc3_get
return &ip->stats;
 }
 
-#ifdef CONFIG_SGI_IOC3_ETH_HW_RX_CSUM
-
 static void ioc3_tcpudp_checksum(struct sk_buff *skb, uint32_t hwsum, int len)
 {
struct ethhdr *eh = eth_hdr(skb);
@@ -589,7 +585,6 @@ static void ioc3_tcpudp_checksum(struct 
if (csum == 0x)
skb->ip_summed = CHECKSUM_UNNECESSARY;
 }
-#endif /* CONFIG_SGI_IOC3_ETH_HW_RX_CSUM */
 
 static inline void ioc3_rx(struct ioc3_private *ip)
 {
@@ -624,9 +619,9 @@ static inline void ioc3_rx(struct ioc3_p
goto next;
}
 
-#ifdef CONFIG_SGI_IOC3_ETH_HW_RX_CSUM
-   ioc3_tcpudp_checksum(skb, w0 & ERXBUF_IPCKSUM_MASK,len);
-#endif
+   if (likely(ip->flags & IOC3_FLAG_RX_CHECKSUMS))
+   ioc3_tcpudp_checksum(skb,
+   w0 & ERXBUF_IPCKSUM_MASK, len);
 
netif_rx(skb);
 
@@ -1298,9 +1293,7 @@ static int ioc3_probe(struct pci_dev *pd
dev->set_multicast_list = ioc3_set_multicast_list;
dev->set_mac_address= ioc3_set_mac_address;
dev->ethtool_ops= &ioc3_ethtool_ops;
-#ifdef CONFIG_SGI_IOC3_ETH_HW_TX_CSUM
dev->features   = NETIF_F_IP_CSUM;
-#endif
 
sw_physid1 = ioc3_mdio_read(dev, ip->mii.phy_id, MII_PHYSID1);
sw_physid2 = ioc3_mdio_read(dev, ip->mii.phy_id, MII_PHYSID2);
@@ -1390,7 +1383,6 @@ static int ioc3_start_xmit(struct sk_buf
uint32_t w0 = 0;
int produce;
 
-#ifdef CONFIG_SGI_IOC3_ETH_HW_TX_CSUM
/*
 * IOC3 has a fairly simple minded checksumming hardware which simply
 * adds up the 1's complement checksum for the entire packet and
@@ -14

[IOC3] Switch to pci refcounting safe APIs

2007-07-10 Thread Ralf Baechle
From:   Alan Cox <[EMAIL PROTECTED]>

Convert the IOC3 driver to use ref counting pci interfaces so that we can
obsolete the (usually unsafe) pci_find_{slot/device} interfaces and avoid
future authors writing hotplug-unsafe device drivers.

Signed-off-by: Alan Cox <[EMAIL PROTECTED]>

Build fixes:
Signed-off-by: Ralf Baechle <[EMAIL PROTECTED]>

Index: upstream-linus/drivers/net/ioc3-eth.c
===
--- upstream-linus.orig/drivers/net/ioc3-eth.c
+++ upstream-linus/drivers/net/ioc3-eth.c
@@ -352,13 +352,12 @@ static u64 nic_find(struct ioc3 *ioc3, i
 
 static int nic_init(struct ioc3 *ioc3)
 {
-   const char *type;
+   const char *unknown = "unknown";
+   const char *type = unknown;
u8 crc;
u8 serial[6];
int save = 0, i;
 
-   type = "unknown";
-
while (1) {
u64 reg;
reg = nic_find(ioc3, &save);
@@ -392,7 +391,7 @@ static int nic_init(struct ioc3 *ioc3)
}
 
printk("Found %s NIC", type);
-   if (type != "unknown") {
+   if (type != unknown) {
printk (" registration number %02x:%02x:%02x:%02x:%02x:%02x,"
" CRC %02x", serial[0], serial[1], serial[2],
serial[3], serial[4], serial[5], crc);
@@ -1103,20 +1102,28 @@ static int ioc3_close(struct net_device 
  * MiniDINs; all other subdevices are left swinging in the wind, leave
  * them disabled.
  */
-static inline int ioc3_is_menet(struct pci_dev *pdev)
+
+static int ioc3_adjacent_is_ioc3(struct pci_dev *pdev, int slot)
 {
-   struct pci_dev *dev;
+   struct pci_dev *dev = pci_get_slot(pdev->bus, PCI_DEVFN(slot, 0));
+   int ret = 0;
+
+   if (dev) {
+   if (dev->vendor == PCI_VENDOR_ID_SGI &&
+   dev->device == PCI_DEVICE_ID_SGI_IOC3)
+   ret = 1;
+   pci_dev_put(dev);
+   }
 
-   return pdev->bus->parent == NULL
-  && (dev = pci_find_slot(pdev->bus->number, PCI_DEVFN(0, 0)))
-  && dev->vendor == PCI_VENDOR_ID_SGI
-  && dev->device == PCI_DEVICE_ID_SGI_IOC3
-  && (dev = pci_find_slot(pdev->bus->number, PCI_DEVFN(1, 0)))
-  && dev->vendor == PCI_VENDOR_ID_SGI
-  && dev->device == PCI_DEVICE_ID_SGI_IOC3
-  && (dev = pci_find_slot(pdev->bus->number, PCI_DEVFN(2, 0)))
-  && dev->vendor == PCI_VENDOR_ID_SGI
-  && dev->device == PCI_DEVICE_ID_SGI_IOC3;
+   return ret;
+}
+
+static int ioc3_is_menet(struct pci_dev *pdev)
+{
+   return pdev->bus->parent == NULL &&
+  ioc3_adjacent_is_ioc3(pdev, 0) &&
+  ioc3_adjacent_is_ioc3(pdev, 1) &&
+  ioc3_adjacent_is_ioc3(pdev, 2);
 }
 
 #ifdef CONFIG_SERIAL_8250
-
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: [NET] au1000_eth: Fix warnings.

2007-06-26 Thread Ralf Baechle
On Mon, Jun 25, 2007 at 04:02:16PM -0700, Andrew Morton wrote:

> That's more than a warning fix.  On most platforms, dma_alloc_noncoherent()
> is a #define so the driver just won't link there.
> 
> 
> 
> But the driver is mips-only, and MIPS uses a regular C function for
> dma_alloc_noncoherent(), so you got lucky.

Yep, the way this driver is being used (32-bit only) it happens to just
work.

> Still, I'd say this is for-2.6.22.

Yep.

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


[NET] au1000_eth: Fix warnings.

2007-06-24 Thread Ralf Baechle
Fixed by including :

  CC  drivers/net/au1000_eth.o
drivers/net/au1000_eth.c: In function 'au1000_probe':
drivers/net/au1000_eth.c:661: warning: implicit declaration of function 
'dma_alloc_noncoherent'
drivers/net/au1000_eth.c:802: warning: implicit declaration of function 
'dma_free_noncoherent'

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

diff --git a/drivers/net/au1000_eth.c b/drivers/net/au1000_eth.c
index c39ab80..c27cfce 100644
--- a/drivers/net/au1000_eth.c
+++ b/drivers/net/au1000_eth.c
@@ -34,7 +34,7 @@
  *
  *
  */
-
+#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


[NET] meth driver renovation

2007-05-24 Thread Ralf Baechle
The meth ethernet driver for the SGI IP32 aka O2 is so far still an old
style driver which does not use the device driver model.  This is now
causing issues with some udev based gadgetry in debian-stable.  Fixed by
converting the meth driver to a platform device.

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

--
Fixes since previous patch:

  o Fixed typo in meth_exit_module()

diff --git a/arch/mips/sgi-ip32/Makefile b/arch/mips/sgi-ip32/Makefile
index 7e14167..60f0227 100644
--- a/arch/mips/sgi-ip32/Makefile
+++ b/arch/mips/sgi-ip32/Makefile
@@ -3,5 +3,5 @@
 # under Linux.
 #
 
-obj-y  += ip32-berr.o ip32-irq.o ip32-setup.o ip32-reset.o \
+obj-y  += ip32-berr.o ip32-irq.o ip32-platform.o ip32-setup.o ip32-reset.o \
   crime.o ip32-memory.o
diff --git a/arch/mips/sgi-ip32/ip32-platform.c 
b/arch/mips/sgi-ip32/ip32-platform.c
new file mode 100644
index 000..120b159
--- /dev/null
+++ b/arch/mips/sgi-ip32/ip32-platform.c
@@ -0,0 +1,20 @@
+#include 
+#include 
+
+static __init int meth_devinit(void)
+{
+   struct platform_device *pd;
+   int ret;
+
+   pd = platform_device_alloc("meth", -1);
+   if (!pd)
+   return -ENOMEM;
+
+   ret = platform_device_add(pd);
+   if (ret)
+   platform_device_put(pd);
+
+   return ret;
+}
+
+device_initcall(meth_devinit);
diff --git a/drivers/net/meth.c b/drivers/net/meth.c
index 0343ea1..92b403b 100644
--- a/drivers/net/meth.c
+++ b/drivers/net/meth.c
@@ -8,15 +8,16 @@
  * as published by the Free Software Foundation; either version
  * 2 of the License, or (at your option) any later version.
  */
-#include 
-#include 
-
-#include  /* printk() */
 #include 
+#include 
+#include 
+#include 
+#include 
+#include 
 #include 
-#include   /* error codes */
-#include   /* size_t */
-#include  /* mark_bh */
+#include 
+#include 
+#include 
 
 #include 
 #include 
@@ -33,7 +34,6 @@
 
 #include 
 #include 
-#include 
 
 #include "meth.h"
 
@@ -51,8 +51,6 @@
 
 
 static const char *meth_str="SGI O2 Fast Ethernet";
-MODULE_AUTHOR("Ilya Volynets <[EMAIL PROTECTED]>");
-MODULE_DESCRIPTION("SGI O2 Builtin Fast Ethernet driver");
 
 #define HAVE_TX_TIMEOUT
 /* The maximum time waited (in jiffies) before assuming a Tx failed. (400ms) */
@@ -784,15 +782,15 @@ static struct net_device_stats *meth_stats(struct 
net_device *dev)
 /*
  * The init function.
  */
-static struct net_device *meth_init(void)
+static int __init meth_probe(struct platform_device *pdev)
 {
struct net_device *dev;
struct meth_private *priv;
-   int ret;
+   int err;
 
dev = alloc_etherdev(sizeof(struct meth_private));
if (!dev)
-   return ERR_PTR(-ENOMEM);
+   return -ENOMEM;
 
dev->open= meth_open;
dev->stop= meth_release;
@@ -808,11 +806,12 @@ static struct net_device *meth_init(void)
 
priv = netdev_priv(dev);
spin_lock_init(&priv->meth_lock);
+   SET_NETDEV_DEV(dev, &pdev->dev);
 
-   ret = register_netdev(dev);
-   if (ret) {
+   err = register_netdev(dev);
+   if (err) {
free_netdev(dev);
-   return ERR_PTR(ret);
+   return err;
}
 
printk(KERN_INFO "%s: SGI MACE Ethernet rev. %d\n",
@@ -820,21 +819,44 @@ static struct net_device *meth_init(void)
return 0;
 }
 
-static struct net_device *meth_dev;
+static int __exit meth_remove(struct platform_device *pdev)
+{
+   struct net_device *dev = platform_get_drvdata(pdev);
+
+   unregister_netdev(dev);
+   free_netdev(dev);
+   platform_set_drvdata(pdev, NULL);
+
+   return 0;
+}
+
+static struct platform_driver meth_driver = {
+   .probe  = meth_probe,
+   .remove = __devexit_p(meth_remove),
+   .driver = {
+   .name   = "meth",
+   }
+};
 
 static int __init meth_init_module(void)
 {
-   meth_dev = meth_init();
-   if (IS_ERR(meth_dev))
-   return PTR_ERR(meth_dev);
-   return 0;
+   int err;
+
+   err = platform_driver_register(&meth_driver);
+   if (err)
+   printk(KERN_ERR "Driver registration failed\n");
+
+   return err;
 }
 
 static void __exit meth_exit_module(void)
 {
-   unregister_netdev(meth_dev);
-   free_netdev(meth_dev);
+   platform_driver_unregister(&meth_driver);
 }
 
 module_init(meth_init_module);
 module_exit(meth_exit_module);
+
+MODULE_AUTHOR("Ilya Volynets <[EMAIL PROTECTED]>");
+MODULE_DESCRIPTION("SGI O2 Builtin Fast Ethernet driver");
+MODULE_LICENSE("GPL");
-
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: [NET] meth driver renovation

2007-05-24 Thread Ralf Baechle
On Wed, May 23, 2007 at 01:02:18PM -0700, Shane McDonald wrote:

> >  static void __exit meth_exit_module(void)
> >  {
> > -   unregister_netdev(meth_dev);
> > -   free_netdev(meth_dev);
> > +   platform_driver_register(&meth_driver);
> >  }
> 
>   
> 
>   platform_driver_unregister(&meth_driver);

Indeed.  Will send new patch in separate email.

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


Re: [NET] meth driver renovation

2007-05-23 Thread Ralf Baechle
On Wed, May 23, 2007 at 09:43:30AM +0100, Ralf Baechle wrote:

> The meth ethernet driver for the SGI IP32 aka O2 is so far still an old
> style driver which does not use the device driver model.  This is now
> causing issues with some udev based gadgetry in debian-stable.  Fixed by
> converting the meth driver to a platform device.

Since this seems to cause some real world problems I'd like to get this
patch into 2.6.22.

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


[NET] meth driver renovation

2007-05-23 Thread Ralf Baechle
The meth ethernet driver for the SGI IP32 aka O2 is so far still an old
style driver which does not use the device driver model.  This is now
causing issues with some udev based gadgetry in debian-stable.  Fixed by
converting the meth driver to a platform device.

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

diff --git a/arch/mips/sgi-ip32/Makefile b/arch/mips/sgi-ip32/Makefile
index 7e14167..60f0227 100644
--- a/arch/mips/sgi-ip32/Makefile
+++ b/arch/mips/sgi-ip32/Makefile
@@ -3,5 +3,5 @@
 # under Linux.
 #
 
-obj-y  += ip32-berr.o ip32-irq.o ip32-setup.o ip32-reset.o \
+obj-y  += ip32-berr.o ip32-irq.o ip32-platform.o ip32-setup.o ip32-reset.o \
   crime.o ip32-memory.o
diff --git a/arch/mips/sgi-ip32/ip32-platform.c 
b/arch/mips/sgi-ip32/ip32-platform.c
new file mode 100644
index 000..120b159
--- /dev/null
+++ b/arch/mips/sgi-ip32/ip32-platform.c
@@ -0,0 +1,20 @@
+#include 
+#include 
+
+static __init int meth_devinit(void)
+{
+   struct platform_device *pd;
+   int ret;
+
+   pd = platform_device_alloc("meth", -1);
+   if (!pd)
+   return -ENOMEM;
+
+   ret = platform_device_add(pd);
+   if (ret)
+   platform_device_put(pd);
+
+   return ret;
+}
+
+device_initcall(meth_devinit);
diff --git a/drivers/net/meth.c b/drivers/net/meth.c
index 0343ea1..f300d3f 100644
--- a/drivers/net/meth.c
+++ b/drivers/net/meth.c
@@ -8,15 +8,16 @@
  * as published by the Free Software Foundation; either version
  * 2 of the License, or (at your option) any later version.
  */
-#include 
-#include 
-
-#include  /* printk() */
 #include 
+#include 
+#include 
+#include 
+#include 
+#include 
 #include 
-#include   /* error codes */
-#include   /* size_t */
-#include  /* mark_bh */
+#include 
+#include 
+#include 
 
 #include 
 #include 
@@ -33,7 +34,6 @@
 
 #include 
 #include 
-#include 
 
 #include "meth.h"
 
@@ -51,8 +51,6 @@
 
 
 static const char *meth_str="SGI O2 Fast Ethernet";
-MODULE_AUTHOR("Ilya Volynets <[EMAIL PROTECTED]>");
-MODULE_DESCRIPTION("SGI O2 Builtin Fast Ethernet driver");
 
 #define HAVE_TX_TIMEOUT
 /* The maximum time waited (in jiffies) before assuming a Tx failed. (400ms) */
@@ -784,15 +782,15 @@ static struct net_device_stats *meth_stats(struct 
net_device *dev)
 /*
  * The init function.
  */
-static struct net_device *meth_init(void)
+static int __init meth_probe(struct platform_device *pdev)
 {
struct net_device *dev;
struct meth_private *priv;
-   int ret;
+   int err;
 
dev = alloc_etherdev(sizeof(struct meth_private));
if (!dev)
-   return ERR_PTR(-ENOMEM);
+   return -ENOMEM;
 
dev->open= meth_open;
dev->stop= meth_release;
@@ -808,11 +806,12 @@ static struct net_device *meth_init(void)
 
priv = netdev_priv(dev);
spin_lock_init(&priv->meth_lock);
+   SET_NETDEV_DEV(dev, &pdev->dev);
 
-   ret = register_netdev(dev);
-   if (ret) {
+   err = register_netdev(dev);
+   if (err) {
free_netdev(dev);
-   return ERR_PTR(ret);
+   return err;
}
 
printk(KERN_INFO "%s: SGI MACE Ethernet rev. %d\n",
@@ -820,21 +819,44 @@ static struct net_device *meth_init(void)
return 0;
 }
 
-static struct net_device *meth_dev;
+static int __exit meth_remove(struct platform_device *pdev)
+{
+   struct net_device *dev = platform_get_drvdata(pdev);
+
+   unregister_netdev(dev);
+   free_netdev(dev);
+   platform_set_drvdata(pdev, NULL);
+
+   return 0;
+}
+
+static struct platform_driver meth_driver = {
+   .probe  = meth_probe,
+   .remove = __devexit_p(meth_remove),
+   .driver = {
+   .name   = "meth",
+   }
+};
 
 static int __init meth_init_module(void)
 {
-   meth_dev = meth_init();
-   if (IS_ERR(meth_dev))
-   return PTR_ERR(meth_dev);
-   return 0;
+   int err;
+
+   err = platform_driver_register(&meth_driver);
+   if (err)
+   printk(KERN_ERR "Driver registration failed\n");
+
+   return err;
 }
 
 static void __exit meth_exit_module(void)
 {
-   unregister_netdev(meth_dev);
-   free_netdev(meth_dev);
+   platform_driver_register(&meth_driver);
 }
 
 module_init(meth_init_module);
 module_exit(meth_exit_module);
+
+MODULE_AUTHOR("Ilya Volynets <[EMAIL PROTECTED]>");
+MODULE_DESCRIPTION("SGI O2 Builtin Fast Ethernet driver");
+MODULE_LICENSE("GPL");
-
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/5] ne: MIPS: Use platform_driver for ne on RBTX49XX

2007-05-01 Thread Ralf Baechle
On Tue, May 01, 2007 at 12:27:58AM +0900, Atsushi Nemoto wrote:

> This patch lets RBTX49XX boards use generic platform_driver interface
> for the ne driver.
> 
> * Use platform_device to pass ioaddr and irq to the ne driver.
> * Remove unnecessary ifdefs for RBTX49XX from the ne driver.
> * Make the ne driver selectable on these boards regardless of CONFIG_ISA
> 
> Signed-off-by: Atsushi Nemoto <[EMAIL PROTECTED]>

Acked-by: Ralf Baechle <[EMAIL PROTECTED]>

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


[NET] SAA9730: Fix large pile of warnings

2007-03-20 Thread Ralf Baechle
s integer 
from pointer without a cast
drivers/net/saa9730.c:560: warning: passing argument 2 of 'outl' makes integer 
from pointer without a cast
drivers/net/saa9730.c:564: warning: passing argument 2 of 'outl' makes integer 
from pointer without a cast
drivers/net/saa9730.c:567: warning: passing argument 2 of 'outl' makes integer 
from pointer without a cast
drivers/net/saa9730.c: In function 'lan_saa9730_tx':
drivers/net/saa9730.c:590: warning: passing argument 2 of 'outl' makes integer 
from pointer without a cast
drivers/net/saa9730.c: In function 'lan_saa9730_rx':
drivers/net/saa9730.c:664: warning: passing argument 2 of 'outl' makes integer 
from pointer without a cast
drivers/net/saa9730.c:729: warning: passing argument 2 of 'outl' makes integer 
from pointer without a cast
drivers/net/saa9730.c: In function 'lan_saa9730_write':
drivers/net/saa9730.c:848: warning: passing argument 2 of 'outl' makes integer 
from pointer without a cast
drivers/net/saa9730.c: In function 'lan_saa9730_set_multicast':
drivers/net/saa9730.c:943: warning: passing argument 2 of 'outl' makes integer 
from pointer without a cast
drivers/net/saa9730.c:949: warning: passing argument 2 of 'outl' makes integer 
from pointer without a cast

Fixed by using writel instead of outl.  42 warnings less.

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

diff --git a/drivers/net/saa9730.c b/drivers/net/saa9730.c
index b269513..143958f 100644
--- a/drivers/net/saa9730.c
+++ b/drivers/net/saa9730.c
@@ -64,37 +64,37 @@ static unsigned int pci_irq_line;
 
 static void evm_saa9730_enable_lan_int(struct lan_saa9730_private *lp)
 {
-   outl(readl(&lp->evm_saa9730_regs->InterruptBlock1) | EVM_LAN_INT,
-&lp->evm_saa9730_regs->InterruptBlock1);
-   outl(readl(&lp->evm_saa9730_regs->InterruptStatus1) | EVM_LAN_INT,
-&lp->evm_saa9730_regs->InterruptStatus1);
-   outl(readl(&lp->evm_saa9730_regs->InterruptEnable1) | EVM_LAN_INT |
-EVM_MASTER_EN, &lp->evm_saa9730_regs->InterruptEnable1);
+   writel(readl(&lp->evm_saa9730_regs->InterruptBlock1) | EVM_LAN_INT,
+  &lp->evm_saa9730_regs->InterruptBlock1);
+   writel(readl(&lp->evm_saa9730_regs->InterruptStatus1) | EVM_LAN_INT,
+  &lp->evm_saa9730_regs->InterruptStatus1);
+   writel(readl(&lp->evm_saa9730_regs->InterruptEnable1) | EVM_LAN_INT |
+  EVM_MASTER_EN, &lp->evm_saa9730_regs->InterruptEnable1);
 }
 
 static void evm_saa9730_disable_lan_int(struct lan_saa9730_private *lp)
 {
-   outl(readl(&lp->evm_saa9730_regs->InterruptBlock1) & ~EVM_LAN_INT,
-&lp->evm_saa9730_regs->InterruptBlock1);
-   outl(readl(&lp->evm_saa9730_regs->InterruptEnable1) & ~EVM_LAN_INT,
-&lp->evm_saa9730_regs->InterruptEnable1);
+   writel(readl(&lp->evm_saa9730_regs->InterruptBlock1) & ~EVM_LAN_INT,
+  &lp->evm_saa9730_regs->InterruptBlock1);
+   writel(readl(&lp->evm_saa9730_regs->InterruptEnable1) & ~EVM_LAN_INT,
+  &lp->evm_saa9730_regs->InterruptEnable1);
 }
 
 static void evm_saa9730_clear_lan_int(struct lan_saa9730_private *lp)
 {
-   outl(EVM_LAN_INT, &lp->evm_saa9730_regs->InterruptStatus1);
+   writel(EVM_LAN_INT, &lp->evm_saa9730_regs->InterruptStatus1);
 }
 
 static void evm_saa9730_block_lan_int(struct lan_saa9730_private *lp)
 {
-   outl(readl(&lp->evm_saa9730_regs->InterruptBlock1) & ~EVM_LAN_INT,
-&lp->evm_saa9730_regs->InterruptBlock1);
+   writel(readl(&lp->evm_saa9730_regs->InterruptBlock1) & ~EVM_LAN_INT,
+  &lp->evm_saa9730_regs->InterruptBlock1);
 }
 
 static void evm_saa9730_unblock_lan_int(struct lan_saa9730_private *lp)
 {
-   outl(readl(&lp->evm_saa9730_regs->InterruptBlock1) | EVM_LAN_INT,
-&lp->evm_saa9730_regs->InterruptBlock1);
+   writel(readl(&lp->evm_saa9730_regs->InterruptBlock1) | EVM_LAN_INT,
+  &lp->evm_saa9730_regs->InterruptBlock1);
 }
 
 static void __attribute_used__ show_saa9730_regs(struct lan_saa9730_private 
*lp)
@@ -147,7 +147,7 @@ static void __attribute_used__ show_saa9730_regs(struct 
lan_saa9730_private *lp)
printk("lp->lan_saa9730_regs->RxStatus = %x\n",
   readl(&lp->lan_saa9730_regs->RxStatus));
for (i = 0; i < LAN_SAA9730_CAM_DWORDS; i++) {
-   outl(i, &lp->lan_saa9730_regs->CamAddress);
+   writel(i, &lp->lan_saa9730_regs->CamAddress);
printk("lp->lan_sa

Re: [PATCH] Netpoll support for Sibyte MAC

2007-03-20 Thread Ralf Baechle
On Mon, Mar 19, 2007 at 03:43:11PM -0700, Deepak Saxena wrote:

> +#ifdef CONFIG_SBMAC_COALESCE

Not your patch's fault but ...  CONFIG_SBMAC_COALESCE is being defined
in sb1250-mac.c but the CONFIG_* namespace is reserved for kconfig.

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


[NET] AX.25 Kconfig and docs updates and fixes

2007-03-13 Thread Ralf Baechle
 o The AX.25 Howto is unmaintained since several years.  I've replaced it
   with a wiki at http://www.linux-ax25.org which provides more uptodate
   information.
 o Change default for AX25_DAMA_SLAVE to Y.  AX25_DAMA_SLAVE only compiles
   in support for DAMA but doesn't activate it.  I hope this gets Linux
   distributions to ship their AX.25 kernels with AX25_DAMA_SLAVE enabled.
   The price for this would be very small.
 o Delete historic changelog from comments, that's what SCM systems are
   meant to do.
 o ---help--- in Kconfig looks so yellingly eye insulting.  Use just help.
 o Rewrite the commented out piece of old Linux 2.4 configuration language
   to Kconfig for consistency.
 o Fixup dependencies.

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

diff --git a/Documentation/networking/ax25.txt 
b/Documentation/networking/ax25.txt
index 37c25b0..8257dbf 100644
--- a/Documentation/networking/ax25.txt
+++ b/Documentation/networking/ax25.txt
@@ -1,16 +1,10 @@
 To use the amateur radio protocols within Linux you will need to get a
-suitable copy of the AX.25 Utilities. More detailed information about these
-and associated programs can be found on http://zone.pspt.fi/~jsn/.
-
-For more information about the AX.25, NET/ROM and ROSE protocol stacks, see
-the AX25-HOWTO written by Terry Dawson <[EMAIL PROTECTED]>
-who is also the AX.25 Utilities maintainer.
+suitable copy of the AX.25 Utilities. More detailed information about
+AX.25, NET/ROM and ROSE, associated programs and and utilities can be
+found on http://www.linux-ax25.org.
 
 There is an active mailing list for discussing Linux amateur radio matters
-called linux-hams. To subscribe to it, send a message to
+called [EMAIL PROTECTED] To subscribe to it, send a message to
 [EMAIL PROTECTED] with the words "subscribe linux-hams" in the body
-of the message, the subject field is ignored.
-
-Jonathan G4KLX
-
[EMAIL PROTECTED]
+of the message, the subject field is ignored.  You don't need to be
+subscribed to post but of course that means you might miss an answer.
diff --git a/net/ax25/Kconfig b/net/ax25/Kconfig
index a8993a0..43dd86f 100644
--- a/net/ax25/Kconfig
+++ b/net/ax25/Kconfig
@@ -1,30 +1,27 @@
 #
 # Amateur Radio protocols and AX.25 device configuration
 #
-# 19971130 Now in an own category to make correct compilation of the
-#  AX.25 stuff easier...
-#  Joerg Reuter DL1BKE <[EMAIL PROTECTED]>
-# 19980129 Moved to net/ax25/Config.in, sourcing device drivers.
 
 menuconfig HAMRADIO
depends on NET
bool "Amateur Radio support"
help
  If you want to connect your Linux box to an amateur radio, answer Y
- here. You want to read <http://www.tapr.org/tapr/html/pkthome.html> 
and
- the AX25-HOWTO, available from <http://www.tldp.org/docs.html#howto>.
+ here. You want to read <http://www.tapr.org/tapr/html/pkthome.html>
+ and more specifically about AX.25 on Linux
+ <http://www.linux-ax25.org/>.
 
  Note that the answer to this question won't directly affect the
  kernel: saying N will just cause the configurator to skip all
  the questions about amateur radio.
 
 comment "Packet Radio protocols"
-   depends on HAMRADIO && NET
+   depends on HAMRADIO
 
 config AX25
tristate "Amateur Radio AX.25 Level 2 protocol"
-   depends on HAMRADIO && NET
-   ---help---
+   depends on HAMRADIO
+   help
  This is the protocol used for computer communication over amateur
  radio. It is either used by itself for point-to-point links, or to
  carry other protocols such as tcp/ip. To use it, you need a device
@@ -52,6 +49,7 @@ config AX25
 
 config AX25_DAMA_SLAVE
bool "AX.25 DAMA Slave support"
+   default y
depends on AX25
help
  DAMA is a mechanism to prevent collisions when doing AX.25
@@ -59,23 +57,38 @@ config AX25_DAMA_SLAVE
  from clients (called "slaves") and redistributes it to other slaves.
  If you say Y here, your Linux box will act as a DAMA slave; this is
  transparent in that you don't have to do any special DAMA
- configuration. (Linux cannot yet act as a DAMA server.) If unsure,
- say N.
+ configuration. Linux cannot yet act as a DAMA server.  This option
+ only compiles DAMA slave support into the kernel.  It still needs to
+ be enabled at runtime.  For more about DAMA see
+ <http://www.linux-ax25.org>.  If unsure, say Y.
+
+# placeholder until implemented
+config AX25_DAMA_MASTER
+   bool 'AX.25 DAMA Master support'
+   depends on AX25_DAMA_SLAVE && BROKEN
+   help
+ DAMA is a mechanism to prevent collisions when doing AX.25
+ networking. A DAMA server (called

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

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

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

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

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

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

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

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

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

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

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

  Ralf

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


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

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

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

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

-- 

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


[NET] 3c59x: Fix several modpost warnings

2007-03-08 Thread Ralf Baechle
WARNING: drivers/net/3c59x.o - Section mismatch: reference to .init.text: from 
.text between 'vortex_eisa_probe' (at offset 0x4580) and 'vortex_eisa_remove'
WARNING: drivers/net/3c59x.o - Section mismatch: reference to .init.text: from 
.text between 'vortex_eisa_probe' (at offset 0x4584) and 'vortex_eisa_remove'
WARNING: drivers/net/3c59x.o - Section mismatch: reference to .init.text: from 
.text between 'vortex_eisa_probe' (at offset 0x4588) and 'vortex_eisa_remove'
WARNING: drivers/net/3c59x.o - Section mismatch: reference to .init.text: from 
.text between 'vortex_eisa_probe' (at offset 0x458c) and 'vortex_eisa_remove'

Fixed by:

 o move definition of vortex_eisa_driver below the functions it references.
 o remove now unnecessary prototypes for vortex_eisa_probe and
   vortex_eisa_remove.
 o Make vortex_eisa_probe an __init function.
 o Make vortex_eisa_remove a __devexit function.
 o Wrap vortex_eisa_driver reference to vortex_eisa_remove with
   __devexit_p().

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

 drivers/net/3c59x.c |   28 +---
 1 file changed, 13 insertions(+), 15 deletions(-)

Index: linux-mips/drivers/net/3c59x.c
===
--- linux-mips.orig/drivers/net/3c59x.c
+++ linux-mips/drivers/net/3c59x.c
@@ -858,19 +858,7 @@ static struct eisa_device_id vortex_eisa
 };
 MODULE_DEVICE_TABLE(eisa, vortex_eisa_ids);
 
-static int vortex_eisa_probe(struct device *device);
-static int vortex_eisa_remove(struct device *device);
-
-static struct eisa_driver vortex_eisa_driver = {
-   .id_table = vortex_eisa_ids,
-   .driver   = {
-   .name= "3c59x",
-   .probe   = vortex_eisa_probe,
-   .remove  = vortex_eisa_remove
-   }
-};
-
-static int vortex_eisa_probe(struct device *device)
+static int __init vortex_eisa_probe(struct device *device)
 {
void __iomem *ioaddr;
struct eisa_device *edev;
@@ -893,7 +881,7 @@ static int vortex_eisa_probe(struct devi
return 0;
 }
 
-static int vortex_eisa_remove(struct device *device)
+static int __devexit vortex_eisa_remove(struct device *device)
 {
struct eisa_device *edev;
struct net_device *dev;
@@ -918,7 +906,17 @@ static int vortex_eisa_remove(struct dev
free_netdev(dev);
return 0;
 }
-#endif
+
+static struct eisa_driver vortex_eisa_driver = {
+   .id_table = vortex_eisa_ids,
+   .driver   = {
+   .name= "3c59x",
+   .probe   = vortex_eisa_probe,
+   .remove  = __devexit_p(vortex_eisa_remove)
+   }
+};
+
+#endif /* CONFIG_EISA */
 
 /* returns count found (>= 0), or negative on error */
 static int __init vortex_eisa_init(void)
-
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] ibmtr: Drain rich supply of modpost warnings.

2007-03-08 Thread Ralf Baechle
Building ibmtr as a module produces a spectacular pile of modpost warnings:

WARNING: drivers/net/tokenring/ibmtr.o - Section mismatch: reference to 
.init.text:ibmtr_probe1 from .text between 'ibmtr_probe_card' (at offset 0x450) 
and 'ibmtr_reset_timer'
WARNING: drivers/net/tokenring/ibmtr.o - Section mismatch: reference to 
.init.text:ibmtr_probe1 from .text between 'ibmtr_probe_card' (at offset 0x454) 
and 'ibmtr_reset_timer'
WARNING: drivers/net/tokenring/ibmtr.o - Section mismatch: reference to 
.init.text:ibmtr_probe1 from .text between 'ibmtr_probe_card' (at offset 0x458) 
and 'ibmtr_reset_timer'
WARNING: drivers/net/tokenring/ibmtr.o - Section mismatch: reference to 
.init.text:ibmtr_probe1 from .text between 'ibmtr_probe_card' (at offset 0x45c) 
and 'ibmtr_reset_timer'
WARNING: drivers/net/tokenring/ibmtr.o - Section mismatch: reference to 
.init.data:ibmtr_portlist from .text between 'ibmtr_probe_card' (at offset 
0x4e8) and 'ibmtr_reset_timer'
WARNING: drivers/net/tokenring/ibmtr.o - Section mismatch: reference to 
.init.data:ibmtr_portlist from .text between 'ibmtr_probe_card' (at offset 
0x4ec) and 'ibmtr_reset_timer'
WARNING: drivers/net/tokenring/ibmtr.o - Section mismatch: reference to 
.init.data:ibmtr_portlist from .text between 'ibmtr_probe_card' (at offset 
0x4f0) and 'ibmtr_reset_timer'
WARNING: drivers/net/tokenring/ibmtr.o - Section mismatch: reference to 
.init.data:ibmtr_portlist from .text between 'ibmtr_probe_card' (at offset 
0x4f4) and 'ibmtr_reset_timer'
WARNING: drivers/net/tokenring/ibmtr.o - Section mismatch: reference to 
.init.text:find_turbo_adapters from .text between 'ibmtr_probe_card' (at offset 
0x500) and 'ibmtr_reset_timer'
WARNING: drivers/net/tokenring/ibmtr.o - Section mismatch: reference to 
.init.text:find_turbo_adapters from .text between 'ibmtr_probe_card' (at offset 
0x504) and 'ibmtr_reset_timer'
WARNING: drivers/net/tokenring/ibmtr.o - Section mismatch: reference to 
.init.text:find_turbo_adapters from .text between 'ibmtr_probe_card' (at offset 
0x508) and 'ibmtr_reset_timer'
WARNING: drivers/net/tokenring/ibmtr.o - Section mismatch: reference to 
.init.text:find_turbo_adapters from .text between 'ibmtr_probe_card' (at offset 
0x50c) and 'ibmtr_reset_timer'
WARNING: drivers/net/tokenring/ibmtr.o - Section mismatch: reference to 
.init.data:ibmtr_portlist from .text between 'ibmtr_probe_card' (at offset 
0x520) and 'ibmtr_reset_timer'
WARNING: drivers/net/tokenring/ibmtr.o - Section mismatch: reference to 
.init.data:ibmtr_portlist from .text between 'ibmtr_probe_card' (at offset 
0x524) and 'ibmtr_reset_timer'
WARNING: drivers/net/tokenring/ibmtr.o - Section mismatch: reference to 
.init.data:ibmtr_portlist from .text between 'ibmtr_probe_card' (at offset 
0x528) and 'ibmtr_reset_timer'
WARNING: drivers/net/tokenring/ibmtr.o - Section mismatch: reference to 
.init.data:ibmtr_portlist from .text between 'ibmtr_probe_card' (at offset 
0x534) and 'ibmtr_reset_timer'
WARNING: drivers/net/tokenring/ibmtr.o - Section mismatch: reference to 
.init.data: from .text between 'ibmtr_probe_card' (at offset 0x540) and 
'ibmtr_reset_timer'
WARNING: drivers/net/tokenring/ibmtr.o - Section mismatch: reference to 
.init.data: from .text between 'ibmtr_probe_card' (at offset 0x544) and 
'ibmtr_reset_timer'
WARNING: drivers/net/tokenring/ibmtr.o - Section mismatch: reference to 
.init.data: from .text between 'ibmtr_probe_card' (at offset 0x548) and 
'ibmtr_reset_timer'
WARNING: drivers/net/tokenring/ibmtr.o - Section mismatch: reference to 
.init.data: from .text between 'ibmtr_probe_card' (at offset 0x54c) and 
'ibmtr_reset_timer'
WARNING: drivers/net/tokenring/ibmtr.o - Section mismatch: reference to 
.init.text:ibmtr_probe1 from .text between 'ibmtr_probe_card' (at offset 0x558) 
and 'ibmtr_reset_timer'
WARNING: drivers/net/tokenring/ibmtr.o - Section mismatch: reference to 
.init.text:ibmtr_probe1 from .text between 'ibmtr_probe_card' (at offset 0x55c) 
and 'ibmtr_reset_timer'
WARNING: drivers/net/tokenring/ibmtr.o - Section mismatch: reference to 
.init.text:ibmtr_probe1 from .text between 'ibmtr_probe_card' (at offset 0x560) 
and 'ibmtr_reset_timer'
WARNING: drivers/net/tokenring/ibmtr.o - Section mismatch: reference to 
.init.text:ibmtr_probe1 from .text between 'ibmtr_probe_card' (at offset 0x564) 
and 'ibmtr_reset_timer'

Fix by making ibmtr_probe an __init function.

While at it, move move ibmtr_probe_card below ibmtr_probe so the protoype
for ibmtr_probe can be deleted.

Signed-off-by: Ral

Re: [PATCH 1/2] pcnet32: only allocate init_block dma consistent

2007-03-07 Thread Ralf Baechle
On Wed, Mar 07, 2007 at 08:35:30AM -0800, Michael K. Edwards wrote:

> >Price question: why would this patch make a difference under VMware? :-)
> 
> Moving the struct pcnet32_private from the GFP_DMA32 init_block to the
> GFP_KERNEL netdev allocation may be a win even on systems where
> GFP_DMA32 is normally cached, because the private area will get read
> ahead into cache when the netdev is touched.

GFP_* flags have no influence on caching or prefetching.

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


Re: [PATCH 1/2] pcnet32: only allocate init_block dma consistent

2007-03-06 Thread Ralf Baechle
On Tue, Mar 06, 2007 at 07:39:21PM -0800, Michael K. Edwards wrote:

> On 3/6/07, Ralf Baechle <[EMAIL PROTECTED]> wrote:
> >This small change btw. delivers about ~ 3% extra performance on a very
> >slow test system.
> 
> Has this change been tested / benchmarked under VMWare?  pcnet32 is
> the (default?) virtual device presented by VMWare Workstation, and
> that's probably a large fraction of its use in the field these days.
> But then Don probably already knows that.  :-)

Price question: why would this patch make a difference under VMware? :-)

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


Re: [PATCH 1/2] pcnet32: only allocate init_block dma consistent

2007-03-06 Thread Ralf Baechle
On Tue, Mar 06, 2007 at 10:45:23AM -0800, Don Fry wrote:

> The patch below moves the init_block out of the private struct and
> only allocates init block with pci_alloc_consistent. 
> 
> This has two effects:
> 
> 1. Performance increase for non cache coherent machines, because the
>CPU only data in the private struct are now cached

This small change btw. delivers about ~ 3% extra performance on a very
slow test system.

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


[NET] netxen: fix warnings

2007-03-06 Thread Ralf Baechle
  CC [M]  drivers/net/netxen/netxen_nic_hw.o
drivers/net/netxen/netxen_nic_hw.c: In function 'netxen_nic_hw_resources':
drivers/net/netxen/netxen_nic_hw.c:231: warning: format '%llx' expects type 
'long long unsigned int', but argument 2 has type 'dma_addr_t'
drivers/net/netxen/netxen_nic_hw.c:250: warning: format '%llx' expects type 
'long long unsigned int', but argument 2 has type 'dma_addr_t'

u64 is unsigned long so the cast to u64 will result in a warning on the
printf arguments for 64-bit builds.  So cast to unsigned long long instead.

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

diff --git a/drivers/net/netxen/netxen_nic_hw.c 
b/drivers/net/netxen/netxen_nic_hw.c
index a2877f3..1be5570 100644
--- a/drivers/net/netxen/netxen_nic_hw.c
+++ b/drivers/net/netxen/netxen_nic_hw.c
@@ -228,7 +228,7 @@ int netxen_nic_hw_resources(struct netxen_adapter *adapter)
&adapter->ctx_desc_pdev);
 
printk("ctx_desc_phys_addr: 0x%llx\n",
-  (u64) adapter->ctx_desc_phys_addr);
+  (unsigned long long) adapter->ctx_desc_phys_addr);
if (addr == NULL) {
DPRINTK(ERR, "bad return from pci_alloc_consistent\n");
err = -ENOMEM;
@@ -247,7 +247,8 @@ int netxen_nic_hw_resources(struct netxen_adapter *adapter)
adapter->max_tx_desc_count,
(dma_addr_t *) & hw->cmd_desc_phys_addr,
&adapter->ahw.cmd_desc_pdev);
-   printk("cmd_desc_phys_addr: 0x%llx\n", (u64) hw->cmd_desc_phys_addr);
+   printk("cmd_desc_phys_addr: 0x%llx\n",
+  (unsigned long long) hw->cmd_desc_phys_addr);
 
if (addr == NULL) {
DPRINTK(ERR, "bad return from pci_alloc_consistent\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 2/2] div64_64: common code

2007-03-06 Thread Ralf Baechle
On Tue, Mar 06, 2007 at 02:42:28AM -0800, [EMAIL PROTECTED] wrote:

> Implement div64_64(): 64-bit by 64-bit division.  Needed by networking (at
> least).

Your patch only implements div64_64() for 32-bit MIPS.  Below patch adds
the trivial 64-bit bits.

  Ralf

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

 include/asm-mips/div64.h |7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Index: linux-mips/include/asm-mips/div64.h
===
--- linux-mips.orig/include/asm-mips/div64.h
+++ linux-mips/include/asm-mips/div64.h
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2000, 2004  Maciej W. Rozycki
- * Copyright (C) 2003 Ralf Baechle
+ * Copyright (C) 2003, 07 Ralf Baechle ([EMAIL PROTECTED])
  *
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
@@ -105,6 +105,11 @@ extern uint64_t div64_64(uint64_t divide
(n) = __quot; \
__mod; })
 
+static inline uint64_t div64_64(uint64_t dividend, uint64_t divisor)
+{
+   return dividend / divisor;
+}
+
 #endif /* (_MIPS_SZLONG == 64) */
 
 #endif /* _ASM_DIV64_H */
-
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] Fix PCnet32 performance bug on non-coherent architecutres

2007-03-04 Thread Ralf Baechle
The PCnet32 driver always passed the the size of the largest possible packet
to the pci_dma_sync_single_for_cpu and pci_dma_sync_single_for_device.
This results in a fairly large "colateral damage" in the caches and makes
the flush operation itself much slower.  On a system with a 40MHz CPU this
patch increases network bandwidth by about 12%.

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

diff --git a/drivers/net/pcnet32.c b/drivers/net/pcnet32.c
index 36f9d98..4d94ba7 100644
--- a/drivers/net/pcnet32.c
+++ b/drivers/net/pcnet32.c
@@ -1234,14 +1234,14 @@ static void pcnet32_rx_entry(struct net_device *dev,
skb_put(skb, pkt_len);  /* Make room */
pci_dma_sync_single_for_cpu(lp->pci_dev,
lp->rx_dma_addr[entry],
-   PKT_BUF_SZ - 2,
+   pkt_len,
PCI_DMA_FROMDEVICE);
eth_copy_and_sum(skb,
 (unsigned char *)(lp->rx_skbuff[entry]->data),
 pkt_len, 0);
pci_dma_sync_single_for_device(lp->pci_dev,
   lp->rx_dma_addr[entry],
-  PKT_BUF_SZ - 2,
+  pkt_len,
   PCI_DMA_FROMDEVICE);
}
lp->stats.rx_bytes += skb->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


Re: [PATCH] Fix broken RBTX4927 support in ne.c

2007-02-28 Thread Ralf Baechle
On Thu, Mar 01, 2007 at 01:22:23AM +0900, Atsushi Nemoto wrote:

> There are some ifdefs for RBTX4927, but need some more bits.

Acked-by: Ralf Baechle <[EMAIL PROTECTED]>

Longer term I think NE2000 will need to support platform_devices.  It's
been used too widely in too creative ways and we don't want all the
clutter to deal with that in ne.c.

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


[NET] Add support for Seeq 8003 on Challenge S Mezz board.

2007-02-27 Thread Ralf Baechle
From: Ladislav Michl <[EMAIL PROTECTED]>

Thanks to Jö Fahlke for donating hardware.

Signed-off-by: Ladislav Michl <[EMAIL PROTECTED]>

Forward porting of Ladis' 2.4 patch.

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

diff --git a/drivers/net/sgiseeq.c b/drivers/net/sgiseeq.c
index 52ed522..b881330 100644
--- a/drivers/net/sgiseeq.c
+++ b/drivers/net/sgiseeq.c
@@ -625,7 +625,7 @@ static inline void setup_rx_ring(struct sgiseeq_rx_desc 
*buf, int nbufs)
 
 #define ALIGNED(x)  unsigned long)(x)) + 0xf) & ~(0xf))
 
-static int sgiseeq_init(struct hpc3_regs* hpcregs, int irq)
+static int sgiseeq_init(struct hpc3_regs* hpcregs, int irq, int has_eeprom)
 {
struct sgiseeq_init_block *sr;
struct sgiseeq_private *sp;
@@ -651,7 +651,9 @@ static int sgiseeq_init(struct hpc3_regs* hpcregs, int irq)
 
 #define EADDR_NVOFS 250
for (i = 0; i < 3; i++) {
-   unsigned short tmp = ip22_nvram_read(EADDR_NVOFS / 2 + i);
+   unsigned short tmp = has_eeprom ?
+   ip22_eeprom_read(&hpcregs->eeprom, EADDR_NVOFS / 2+i) :
+   ip22_nvram_read(EADDR_NVOFS / 2+i);
 
dev->dev_addr[2 * i] = tmp >> 8;
dev->dev_addr[2 * i + 1] = tmp & 0xff;
@@ -684,6 +686,11 @@ static int sgiseeq_init(struct hpc3_regs* hpcregs, int irq)
sp->hregs->dconfig = HPC3_EDCFG_FIRQ | HPC3_EDCFG_FEOP |
 HPC3_EDCFG_FRXDC | HPC3_EDCFG_PTO | 0x026;
 
+   /* Setup PIO and DMA transfer timing */
+   sp->hregs->pconfig = 0x161;
+   sp->hregs->dconfig = HPC3_EDCFG_FIRQ | HPC3_EDCFG_FEOP |
+HPC3_EDCFG_FRXDC | HPC3_EDCFG_PTO | 0x026;
+
/* Reset the chip. */
hpc3_eth_reset(sp->hregs);
 
@@ -730,8 +737,23 @@ err_out:
 
 static int __init sgiseeq_probe(void)
 {
+   unsigned int tmp, ret1, ret2 = 0;
+
/* On board adapter on 1st HPC is always present */
-   return sgiseeq_init(hpc3c0, SGI_ENET_IRQ);
+   ret1 = sgiseeq_init(hpc3c0, SGI_ENET_IRQ, 0);
+   /* Let's see if second HPC is there */
+   if (!(ip22_is_fullhouse()) &&
+   get_dbe(tmp, (unsigned int *)&hpc3c1->pbdma[1]) == 0) {
+   sgimc->giopar |= SGIMC_GIOPAR_MASTEREXP1 |
+SGIMC_GIOPAR_EXP164 |
+SGIMC_GIOPAR_HPC264;
+   hpc3c1->pbus_piocfg[0][0] = 0x3;
+   /* interrupt/config register on Challenge S Mezz board */
+   hpc3c1->pbus_extregs[0][0] = 0x30;
+   ret2 = sgiseeq_init(hpc3c1, SGI_GIO_0_IRQ, 1);
+   }
+
+   return (ret1 & ret2) ? ret1 : 0;
 }
 
 static void __exit sgiseeq_exit(void)
-
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] jmr3927: do not call tc35815_killall().

2007-02-27 Thread Ralf Baechle
No need to stop tc35815 before resetting the board.  This fixes the
build of tc35815 as a module.  This also means there is no caller of
tc35815_killall left, so remove that function also.

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

diff --git a/arch/mips/jmr3927/rbhma3100/setup.c 
b/arch/mips/jmr3927/rbhma3100/setup.c
index 7ca3d6d..ecabe5b 100644
--- a/arch/mips/jmr3927/rbhma3100/setup.c
+++ b/arch/mips/jmr3927/rbhma3100/setup.c
@@ -137,10 +137,6 @@ int jmr3927_ccfg_toeon = 0;
 
 static inline void do_reset(void)
 {
-#ifdef CONFIG_TC35815
-   extern void tc35815_killall(void);
-   tc35815_killall();
-#endif
 #if 1  /* Resetting PCI bus */
jmr3927_ioc_reg_out(0, JMR3927_IOC_RESET_ADDR);
jmr3927_ioc_reg_out(JMR3927_IOC_RESET_PCI, JMR3927_IOC_RESET_ADDR);
diff --git a/drivers/net/tc35815.c b/drivers/net/tc35815.c
index 81ed82f..911ff51 100644
--- a/drivers/net/tc35815.c
+++ b/drivers/net/tc35815.c
@@ -1703,19 +1703,6 @@ static void tc35815_chip_init(struct net_device *dev)
spin_unlock_irqrestore(&lp->lock, flags);
 }
 
-/* XXX */
-void
-tc35815_killall(void)
-{
-   struct net_device *dev;
-
-   for (dev = root_tc35815_dev; dev; dev = ((struct tc35815_local 
*)dev->priv)->next_module) {
-   if (dev->flags&IFF_UP){
-   dev->stop(dev);
-   }
-   }
-}
-
 static struct pci_driver tc35815_driver = {
.name = TC35815_MODULE_NAME,
.probe = tc35815_probe,
-
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][NET] Alignment in mv643xx_eth

2007-02-26 Thread Ralf Baechle
The driver contains this little piece of candy:

#if defined(CONFIG_DMA_NONCOHERENT) || defined(CONFIG_NOT_COHERENT_CACHE)
#define ETH_DMA_ALIGN   L1_CACHE_BYTES
#else
#define ETH_DMA_ALIGN   8
#endif

Any reason why we're not using dma_get_cache_alignment() instead?

  Ralf

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

diff --git a/drivers/net/mv643xx_eth.c b/drivers/net/mv643xx_eth.c
index d98e53e..3e045a6 100644
--- a/drivers/net/mv643xx_eth.c
+++ b/drivers/net/mv643xx_eth.c
@@ -147,13 +147,13 @@ static void mv643xx_eth_rx_refill_descs(struct net_device 
*dev)
int unaligned;
 
while (mp->rx_desc_count < mp->rx_ring_size) {
-   skb = dev_alloc_skb(ETH_RX_SKB_SIZE + ETH_DMA_ALIGN);
+   skb = dev_alloc_skb(ETH_RX_SKB_SIZE + 
dma_get_cache_alignment());
if (!skb)
break;
mp->rx_desc_count++;
-   unaligned = (u32)skb->data & (ETH_DMA_ALIGN - 1);
+   unaligned = (u32)skb->data & (dma_get_cache_alignment() - 1);
if (unaligned)
-   skb_reserve(skb, ETH_DMA_ALIGN - unaligned);
+   skb_reserve(skb, dma_get_cache_alignment() - unaligned);
pkt_info.cmd_sts = ETH_RX_ENABLE_INTERRUPT;
pkt_info.byte_cnt = ETH_RX_SKB_SIZE;
pkt_info.buf_ptr = dma_map_single(NULL, skb->data,
diff --git a/drivers/net/mv643xx_eth.h b/drivers/net/mv643xx_eth.h
index 33c5faf..7cb0a41 100644
--- a/drivers/net/mv643xx_eth.h
+++ b/drivers/net/mv643xx_eth.h
@@ -42,17 +42,6 @@
 #define MAX_DESCS_PER_SKB  1
 #endif
 
-/*
- * The MV643XX HW requires 8-byte alignment.  However, when I/O
- * is non-cache-coherent, we need to ensure that the I/O buffers
- * we use don't share cache lines with other data.
- */
-#if defined(CONFIG_DMA_NONCOHERENT) || defined(CONFIG_NOT_COHERENT_CACHE)
-#define ETH_DMA_ALIGN  L1_CACHE_BYTES
-#else
-#define ETH_DMA_ALIGN  8
-#endif
-
 #define ETH_VLAN_HLEN  4
 #define ETH_FCS_LEN4
 #define ETH_HW_IP_ALIGN2   /* hw aligns IP header 
*/
-
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: possible bug in net/tc35815.c in linux-2.6.19

2007-02-26 Thread Ralf Baechle
On Sat, Feb 24, 2007 at 05:04:01PM -0500, Jeff Garzik wrote:

> >>I am a graduate student working on finding bugs in Linux drivers using
> >>an automated research tool.  I think I've found a possible bug in
> >>net/tc35815.c, and I'd appreciate it if you could confirm/disconfirm it.
> >>
> >>Thanks,
> >>Philip
> >>
> >>---
> >>net/tc35815.c
> >>
> >>tc35815_driver is never unregistered in tc35815_cleanup_module()
> >>
> >>static int __init tc35815_init_module(void)
> >>{
> >>return pci_register_driver(&tc35815_driver);
> >>}
> >>
> >>static void __exit tc35815_cleanup_module(void)
> >>{
> >>struct net_device *next_dev;
> >>
> >>while (root_tc35815_dev) {
> >>struct net_device *dev = root_tc35815_dev;
> >>next_dev = ((struct tc35815_local *)dev->priv)->next_module;
> >>iounmap((void *)(dev->base_addr));
> >>unregister_netdev(dev);
> >>free_netdev(dev);
> >>root_tc35815_dev = next_dev;
> >>}
> >>}
> >>
> >>
> >
> >I think that you are right, but I don't know this code.
> >
> >Jeff, what do you think about this?
> >
> >Regards,
> >Michal
> 
> I created my own patch for this (and one other bug), and checked it in.
> 
> Really, though, someone in MIPS-land should give this driver some loving 
> care.  It is filled with bugs and 2.4-era anachronisms.

Took a look at it.  It's sort of a non-bug because the driver cannot be
compiled as module, so the module_exit function cannot possibly be
executed.  The board support code is calling into the driver which makes
it impossible to build this driver as a module, yet it's possible to
select building this driver as a module ...  Oh yeah, that root_tc35815_dev
stuff is also pretty ugly.

Atsushi?

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


[NET] sgiseeq: Don't include unnecessary headerfiles.

2007-02-25 Thread Ralf Baechle
Signed-off-by: Ralf Baechle <[EMAIL PROTECTED]>

diff --git a/drivers/net/sgiseeq.c b/drivers/net/sgiseeq.c
index a833e7f..52ed522 100644
--- a/drivers/net/sgiseeq.c
+++ b/drivers/net/sgiseeq.c
@@ -12,26 +12,15 @@
 #include 
 #include 
 #include 
-#include 
-#include 
-#include 
-#include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
-#include 
 
-#include 
-#include 
-#include 
-#include 
-#include 
 #include 
 #include 
-#include 
 
 #include "sgiseeq.h"
 
-
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] Eliminate user-selectable CONFIG_MV643XX_ETH_[012]

2007-02-20 Thread Ralf Baechle
On Tue, Feb 20, 2007 at 11:27:30AM -0500, Jeff Garzik wrote:

> >It was a mis-feature that the supported ports were ever user-selectable.
> >Which ports the hardware supports should be specified by platform-specific
> >code, not by the user.
> >
> > arch/mips/momentum/jaguar_atx/platform.c |   21 -
> > arch/mips/momentum/ocelot_3/platform.c   |   21 -
> > arch/mips/momentum/ocelot_c/platform.c   |   14 --
> > arch/ppc/Kconfig |   15 +++
> > drivers/net/Kconfig  |   21 -
> > 5 files changed, 15 insertions(+), 77 deletions(-)
> 
> ACK.
> 
> I'll let Paul, Ralf or Andrew push this one upstream.

Okay, will do that.

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


Re: [PATCH] Eliminate user-selectable CONFIG_MV643XX_ETH_[012]

2007-02-20 Thread Ralf Baechle
On Tue, Feb 20, 2007 at 05:15:20AM -0700, Dale Farnsworth wrote:

> From: Dale Farnsworth <[EMAIL PROTECTED]>
> 
> Remove the use of CONFIG_MV643XX_ETH_[012] variables on most
> platforms.  Instead, platform-specific code enables the ports
> supported by the hardware.  After this patch, these config
> variables are only used in arch/ppc, so also move them from
> drivers/net/Kconfig to arch/ppc/Kconfig.
> 
> Signed-off-by: Dale Farnsworth <[EMAIL PROTECTED]>

Acked-by: Ralf Baechle <[EMAIL PROTECTED]>

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


[IOC3] Fix link autonegotiation timer.

2007-02-16 Thread Ralf Baechle
Start link negotiation in the open method.  Previously it was started
on driver initialialization and shutdown on close so an ifdown would
have results in closing negotiation for good.

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

diff --git a/drivers/net/ioc3-eth.c b/drivers/net/ioc3-eth.c
index ee6bca0..f5d277c 100644
--- a/drivers/net/ioc3-eth.c
+++ b/drivers/net/ioc3-eth.c
@@ -831,13 +831,17 @@ static int ioc3_mii_init(struct ioc3_private *ip)
}
 
ip->mii.phy_id = i;
+
+out:
+   return res;
+}
+
+static void ioc3_mii_start(struct ioc3_private *ip)
+{
ip->ioc3_timer.expires = jiffies + (12 * HZ)/10;  /* 1.2 sec. */
ip->ioc3_timer.data = (unsigned long) ip;
ip->ioc3_timer.function = &ioc3_timer;
add_timer(&ip->ioc3_timer);
-
-out:
-   return res;
 }
 
 static inline void ioc3_clean_rx_ring(struct ioc3_private *ip)
@@ -1066,6 +1070,7 @@ static int ioc3_open(struct net_device *dev)
ip->ehar_h = 0;
ip->ehar_l = 0;
ioc3_init(dev);
+   ioc3_mii_start(ip);
 
netif_start_queue(dev);
return 0;
@@ -1269,6 +1274,7 @@ static int ioc3_probe(struct pci_dev *pdev, const struct 
pci_device_id *ent)
goto out_stop;
}
 
+   ioc3_mii_start(ip);
ioc3_ssram_disc(ip);
ioc3_get_eaddr(ip);
 
@@ -1307,6 +1313,7 @@ static int ioc3_probe(struct pci_dev *pdev, const struct 
pci_device_id *ent)
 
 out_stop:
ioc3_stop(ip);
+   del_timer_sync(&ip->ioc3_timer);
ioc3_free_rings(ip);
 out_res:
pci_release_regions(pdev);
@@ -1328,6 +1335,8 @@ static void __devexit ioc3_remove_one (struct pci_dev 
*pdev)
struct ioc3 *ioc3 = ip->regs;
 
unregister_netdev(dev);
+   del_timer_sync(&ip->ioc3_timer);
+
iounmap(ioc3);
pci_release_regions(pdev);
free_netdev(dev);
@@ -1483,6 +1492,7 @@ static void ioc3_timeout(struct net_device *dev)
ioc3_stop(ip);
ioc3_init(dev);
ioc3_mii_init(ip);
+   ioc3_mii_start(ip);
 
spin_unlock_irq(&ip->ioc3_lock);
 
-
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] Convert meth to netdev_priv

2007-02-16 Thread Ralf Baechle
And while at it loose plenty of useless casts.

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

diff --git a/drivers/net/meth.c b/drivers/net/meth.c
index d38b7c7..7e69ca6 100644
--- a/drivers/net/meth.c
+++ b/drivers/net/meth.c
@@ -170,7 +170,7 @@ static int mdio_probe(struct meth_private *priv)
 
 static void meth_check_link(struct net_device *dev)
 {
-   struct meth_private *priv = (struct meth_private *) dev->priv;
+   struct meth_private *priv = netdev_priv(dev);
unsigned long mii_advertising = mdio_read(priv, 4);
unsigned long mii_partner = mdio_read(priv, 5);
unsigned long negotiated = mii_advertising & mii_partner;
@@ -268,7 +268,7 @@ static void meth_free_rx_ring(struct meth_private *priv)
 
 int meth_reset(struct net_device *dev)
 {
-   struct meth_private *priv = (struct meth_private *) dev->priv;
+   struct meth_private *priv = netdev_priv(dev);
 
/* Reset card */
mace->eth.mac_ctrl = SGI_MAC_RESET;
@@ -310,7 +310,7 @@ int meth_reset(struct net_device *dev)
  */
 static int meth_open(struct net_device *dev)
 {
-   struct meth_private *priv = dev->priv;
+   struct meth_private *priv = netdev_priv(dev);
int ret;
 
priv->phy_addr = -1;/* No PHY is known yet... */
@@ -354,7 +354,7 @@ out_free_tx_ring:
 
 static int meth_release(struct net_device *dev)
 {
-   struct meth_private *priv = dev->priv;
+   struct meth_private *priv = netdev_priv(dev);
 
DPRINTK("Stopping queue\n");
netif_stop_queue(dev); /* can't transmit any more */
@@ -376,7 +376,7 @@ static void meth_rx(struct net_device* dev, unsigned long 
int_status)
 {
struct sk_buff *skb;
unsigned long status;
-   struct meth_private *priv = (struct meth_private *) dev->priv;
+   struct meth_private *priv = netdev_priv(dev);
unsigned long fifo_rptr = (int_status & METH_INT_RX_RPTR_MASK) >> 8;
 
spin_lock(&priv->meth_lock);
@@ -466,14 +466,14 @@ static void meth_rx(struct net_device* dev, unsigned long 
int_status)
 
 static int meth_tx_full(struct net_device *dev)
 {
-   struct meth_private *priv = (struct meth_private *) dev->priv;
+   struct meth_private *priv = netdev_priv(dev);
 
return (priv->tx_count >= TX_RING_ENTRIES - 1);
 }
 
 static void meth_tx_cleanup(struct net_device* dev, unsigned long int_status)
 {
-   struct meth_private *priv = dev->priv;
+   struct meth_private *priv = netdev_priv(dev);
unsigned long status;
struct sk_buff *skb;
unsigned long rptr = (int_status&TX_INFO_RPTR) >> 16;
@@ -536,7 +536,7 @@ static void meth_tx_cleanup(struct net_device* dev, 
unsigned long int_status)
 
 static void meth_error(struct net_device* dev, unsigned status)
 {
-   struct meth_private *priv = (struct meth_private *) dev->priv;
+   struct meth_private *priv = netdev_priv(dev);
 
printk(KERN_WARNING "meth: error status: 0x%08x\n",status);
/* check for errors too... */
@@ -570,7 +570,7 @@ static void meth_error(struct net_device* dev, unsigned 
status)
 static irqreturn_t meth_interrupt(int irq, void *dev_id)
 {
struct net_device *dev = (struct net_device *)dev_id;
-   struct meth_private *priv = (struct meth_private *) dev->priv;
+   struct meth_private *priv = netdev_priv(dev);
unsigned long status;
 
status = mace->eth.int_stat;
@@ -695,7 +695,7 @@ static void meth_add_to_tx_ring(struct meth_private *priv, 
struct sk_buff *skb)
  */
 static int meth_tx(struct sk_buff *skb, struct net_device *dev)
 {
-   struct meth_private *priv = (struct meth_private *) dev->priv;
+   struct meth_private *priv = netdev_priv(dev);
unsigned long flags;
 
spin_lock_irqsave(&priv->meth_lock, flags);
@@ -726,7 +726,7 @@ static int meth_tx(struct sk_buff *skb, struct net_device 
*dev)
  */
 static void meth_tx_timeout(struct net_device *dev)
 {
-   struct meth_private *priv = (struct meth_private *) dev->priv;
+   struct meth_private *priv = netdev_priv(dev);
unsigned long flags;
 
printk(KERN_WARNING "%s: transmit timed out\n", dev->name);
@@ -778,7 +778,7 @@ static int meth_ioctl(struct net_device *dev, struct ifreq 
*rq, int cmd)
  */
 static struct net_device_stats *meth_stats(struct net_device *dev)
 {
-   struct meth_private *priv = (struct meth_private *) dev->priv;
+   struct meth_private *priv = netdev_priv(dev);
return &priv->stats;
 }
 
@@ -807,7 +807,7 @@ static struct net_device *meth_init(void)
dev->irq = MACE_ETHERNET_IRQ;
dev->base_addr   = (unsigned long)&mace->eth;
 
-   priv = (struct meth_private *) dev->priv;
+   priv = netdev_priv(dev);
spin_lock_init(&priv->meth_lock);
 
ret = register_netdev(dev);
-
To un

[HAMRADIO] Replace local random function with random32()

2007-02-16 Thread Ralf Baechle
Signed-off-by: Joe Perches <[EMAIL PROTECTED]>
Signed-off-by: Ralf Baechle <[EMAIL PROTECTED]>

diff --git a/drivers/net/hamradio/baycom_epp.c 
b/drivers/net/hamradio/baycom_epp.c
index 153b6dc..84aa211 100644
--- a/drivers/net/hamradio/baycom_epp.c
+++ b/drivers/net/hamradio/baycom_epp.c
@@ -52,6 +52,7 @@
 #include 
 #include 
 #include 
+#include 
 #include  
 #include 
 
@@ -433,16 +434,6 @@ static void encode_hdlc(struct baycom_state *bc)
 
 /* -- */
 
-static unsigned short random_seed;
-
-static inline unsigned short random_num(void)
-{
-   random_seed = 28629 * random_seed + 157;
-   return random_seed;
-}
-
-/* -- */
-
 static int transmit(struct baycom_state *bc, int cnt, unsigned char stat)
 {
struct parport *pp = bc->pdev->port;
@@ -464,7 +455,7 @@ static int transmit(struct baycom_state *bc, int cnt, 
unsigned char stat)
if ((--bc->hdlctx.slotcnt) > 0)
return 0;
bc->hdlctx.slotcnt = bc->ch_params.slottime;
-   if ((random_num() % 256) > bc->ch_params.ppersist)
+   if ((random32() % 256) > bc->ch_params.ppersist)
return 0;
}
}
diff --git a/drivers/net/hamradio/hdlcdrv.c b/drivers/net/hamradio/hdlcdrv.c
index 452873e..f5a17ad 100644
--- a/drivers/net/hamradio/hdlcdrv.c
+++ b/drivers/net/hamradio/hdlcdrv.c
@@ -56,6 +56,7 @@
 #include 
 #include 
 #include 
+#include 
 #include  
 #include 
 
@@ -371,16 +372,6 @@ static void start_tx(struct net_device *dev, struct 
hdlcdrv_state *s)
 
 /* -- */
 
-static unsigned short random_seed;
-
-static inline unsigned short random_num(void)
-{
-   random_seed = 28629 * random_seed + 157;
-   return random_seed;
-}
-
-/* -- */
-
 void hdlcdrv_arbitrate(struct net_device *dev, struct hdlcdrv_state *s)
 {
if (!s || s->magic != HDLCDRV_MAGIC || s->hdlctx.ptt || !s->skb) 
@@ -396,7 +387,7 @@ void hdlcdrv_arbitrate(struct net_device *dev, struct 
hdlcdrv_state *s)
if ((--s->hdlctx.slotcnt) > 0)
return;
s->hdlctx.slotcnt = s->ch_params.slottime;
-   if ((random_num() % 256) > s->ch_params.ppersist)
+   if ((random32() % 256) > s->ch_params.ppersist)
return;
start_tx(dev, s);
 }
diff --git a/drivers/net/hamradio/yam.c b/drivers/net/hamradio/yam.c
index 6d74f08..efc0bcd 100644
--- a/drivers/net/hamradio/yam.c
+++ b/drivers/net/hamradio/yam.c
@@ -50,6 +50,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -566,14 +567,6 @@ static void yam_start_tx(struct net_device *dev, struct 
yam_port *yp)
ptt_on(dev);
 }
 
-static unsigned short random_seed;
-
-static inline unsigned short random_num(void)
-{
-   random_seed = 28629 * random_seed + 157;
-   return random_seed;
-}
-
 static void yam_arbitrate(struct net_device *dev)
 {
struct yam_port *yp = netdev_priv(dev);
@@ -600,7 +593,7 @@ static void yam_arbitrate(struct net_device *dev)
yp->slotcnt = yp->slot / 10;
 
/* is random > persist ? */
-   if ((random_num() % 256) > yp->pers)
+   if ((random32() % 256) > yp->pers)
return;
 
yam_start_tx(dev, yp);
-
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 5/59] sysctl: rose remove unnecessary insert_at_head flag

2007-01-16 Thread Ralf Baechle
On Tue, Jan 16, 2007 at 09:39:10AM -0700, Eric W. Biederman wrote:

Looks ok, for these:

Subject: [PATCH 5/59] sysctl: rose remove unnecessary insert_at_head flag
Subject: [PATCH 6/59] sysctl: netrom remove unnecessary insert_at_head flag
Subject: [PATCH 11/59] sysctl: ax25 remove unnecessary insert_at_head flag
Subject: [PATCH 30/59] sysctl: mips/au1000 Remove sys_sysctl support
Subject: [PATCH 31/59] sysctl: C99 convert the ctl_tables in 
arch/mips/au1000/common/power.c
Subject: [PATCH 32/59] sysctl: C99 convert arch/mips/lasat/sysctl.c and remove 
ABI breakage.
Subject: [PATCH 43/59] sysctl: Remove sys_sysctl support from drivers/char/rtc.c
Subject: [PATCH 55/59] sysctl: Remove insert_at_head from register_sysctl

Acked-by: Ralf Baechle <[EMAIL PROTECTED]>

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


Re: Using 802.11x wireless usb device on MIPS platform

2007-01-09 Thread Ralf Baechle
On Tue, Jan 09, 2007 at 10:52:14AM +0800, colin wrote:

> I have used two 802.11x wireless usb devices successfully on MIPS platform.
> One is realtek 8187 and the other one is ralink 2571.
> I would like to put them into kernel tree and then I found that there are
> not many 802.11x devices supported in Linux.

If you want to submit a driver to the kernel, please post it to
[EMAIL PROTECTED]  Don't expect a driver to be just accepted; it
will go through a thorough review and after all the issues have been
resolved it will be accepted.

> Moreover, there is no any wireless usb device supported.

Wireless support under Linux is suffering from several problems:

 o some core require microcode to be loaded but the vendor does not
   give such permission.
 o lack of documentation, sometimes for paranoid or bogus legal reasons or
   "intellectual property" concerns.

At times it really seems vendors are working to maximize pain for the user ...

> It is also very strange that 8187 and 2571 both have their own ieee802.11x
> stack and crypt drivers. It seems that Linux doesn't offer them.
> I am wondering why Linux is so complex in 802.11x.

Well, for one thing because 802.11 is complex.  The Linux wireless support
has gone through several generations; some of the wireless work was for
one or the other reason never integrated in the kernel.org kernel.

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


[AX.25 5/7] Fix unchecked ax25_linkfail_register uses

2006-12-14 Thread Ralf Baechle
ax25_linkfail_register uses kmalloc and the callers were ignoring the
error value.  Rewrite to let the caller deal with the allocation.  This
allows the use of static allocation of kmalloc use entirely.

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

 include/net/ax25.h |   10 +++-
 net/ax25/ax25_iface.c  |   55 -
 net/netrom/af_netrom.c |8 +--
 net/rose/af_rose.c |8 +--
 4 files changed, 29 insertions(+), 52 deletions(-)

Index: linux-net/include/net/ax25.h
===
--- linux-net.orig/include/net/ax25.h
+++ linux-net/include/net/ax25.h
@@ -342,8 +342,14 @@ struct ax25_protocol {
 
 extern void ax25_register_pid(struct ax25_protocol *ap);
 extern void ax25_protocol_release(unsigned int);
-extern int __must_check ax25_linkfail_register(void (*)(ax25_cb *, int));
-extern void ax25_linkfail_release(void (*)(ax25_cb *, int));
+
+struct ax25_linkfail {
+   struct hlist_node lf_node;
+   void (*func)(ax25_cb *, int);
+};
+
+extern void ax25_linkfail_register(struct ax25_linkfail *lf);
+extern void ax25_linkfail_release(struct ax25_linkfail *lf);
 extern int __must_check ax25_listen_register(ax25_address *,
struct net_device *);
 extern void ax25_listen_release(ax25_address *, struct net_device *);
Index: linux-net/net/ax25/ax25_iface.c
===
--- linux-net.orig/net/ax25/ax25_iface.c
+++ linux-net/net/ax25/ax25_iface.c
@@ -32,10 +32,7 @@
 static struct ax25_protocol *protocol_list;
 static DEFINE_RWLOCK(protocol_list_lock);
 
-static struct linkfail_struct {
-   struct linkfail_struct *next;
-   void (*func)(ax25_cb *, int);
-} *linkfail_list = NULL;
+static HLIST_HEAD(ax25_linkfail_list);
 static DEFINE_SPINLOCK(linkfail_lock);
 
 static struct listen_struct {
@@ -93,54 +90,19 @@ void ax25_protocol_release(unsigned int 
 
 EXPORT_SYMBOL(ax25_protocol_release);
 
-int ax25_linkfail_register(void (*func)(ax25_cb *, int))
+void ax25_linkfail_register(struct ax25_linkfail *lf)
 {
-   struct linkfail_struct *linkfail;
-
-   if ((linkfail = kmalloc(sizeof(*linkfail), GFP_ATOMIC)) == NULL)
-   return 0;
-
-   linkfail->func = func;
-
spin_lock_bh(&linkfail_lock);
-   linkfail->next = linkfail_list;
-   linkfail_list  = linkfail;
+   hlist_add_head(&lf->lf_node, &ax25_linkfail_list);
spin_unlock_bh(&linkfail_lock);
-
-   return 1;
 }
 
 EXPORT_SYMBOL(ax25_linkfail_register);
 
-void ax25_linkfail_release(void (*func)(ax25_cb *, int))
+void ax25_linkfail_release(struct ax25_linkfail *lf)
 {
-   struct linkfail_struct *s, *linkfail;
-
spin_lock_bh(&linkfail_lock);
-   linkfail = linkfail_list;
-   if (linkfail == NULL) {
-   spin_unlock_bh(&linkfail_lock);
-   return;
-   }
-
-   if (linkfail->func == func) {
-   linkfail_list = linkfail->next;
-   spin_unlock_bh(&linkfail_lock);
-   kfree(linkfail);
-   return;
-   }
-
-   while (linkfail != NULL && linkfail->next != NULL) {
-   if (linkfail->next->func == func) {
-   s = linkfail->next;
-   linkfail->next = linkfail->next->next;
-   spin_unlock_bh(&linkfail_lock);
-   kfree(s);
-   return;
-   }
-
-   linkfail = linkfail->next;
-   }
+   hlist_del_init(&lf->lf_node);
spin_unlock_bh(&linkfail_lock);
 }
 
@@ -237,11 +199,12 @@ int (*ax25_protocol_function(unsigned in
 
 void ax25_link_failed(ax25_cb *ax25, int reason)
 {
-   struct linkfail_struct *linkfail;
+   struct ax25_linkfail *lf;
+   struct hlist_node *node;
 
spin_lock_bh(&linkfail_lock);
-   for (linkfail = linkfail_list; linkfail != NULL; linkfail = 
linkfail->next)
-   (linkfail->func)(ax25, reason);
+   hlist_for_each_entry(lf, node, &ax25_linkfail_list, lf_node)
+   lf->func(ax25, reason);
spin_unlock_bh(&linkfail_lock);
 }
 
Index: linux-net/net/netrom/af_netrom.c
===
--- linux-net.orig/net/netrom/af_netrom.c
+++ linux-net/net/netrom/af_netrom.c
@@ -1382,6 +1382,10 @@ static struct ax25_protocol nr_pid = {
.func   = nr_route_frame
 };
 
+static struct ax25_linkfail nr_linkfail_notifier = {
+   .func   = nr_link_failed,
+};
+
 static int __init nr_proto_init(void)
 {
int i;
@@ -1430,7 +1434,7 @@ static int __init nr_proto_init(void)
register_netdevice_notifier(&nr_dev_notifier);
 
ax25_register_pid(&nr_pid);
-   ax25_linkfail_register(nr_link_failed);
+   ax25_linkfail_register(&n

[AX.25 3/7] Fix unchecked ax25_listen_register uses

2006-12-14 Thread Ralf Baechle
Fix ax25_listen_register to return something that's a sane error code,
then all callers to use it.

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

 net/ax25/ax25_iface.c |7 ---
 net/netrom/nr_dev.c   |   24 ++--
 net/rose/af_rose.c|3 ++-
 3 files changed, 24 insertions(+), 10 deletions(-)

Index: linux-net/net/ax25/ax25_iface.c
===
--- linux-net.orig/net/ax25/ax25_iface.c
+++ linux-net/net/ax25/ax25_iface.c
@@ -154,7 +154,7 @@ int ax25_listen_register(ax25_address *c
return 0;
 
if ((listen = kmalloc(sizeof(*listen), GFP_ATOMIC)) == NULL)
-   return 0;
+   return -ENOMEM;
 
listen->callsign = *callsign;
listen->dev  = dev;
@@ -164,7 +164,7 @@ int ax25_listen_register(ax25_address *c
listen_list  = listen;
spin_unlock_bh(&listen_lock);
 
-   return 1;
+   return 0;
 }
 
 EXPORT_SYMBOL(ax25_listen_register);
@@ -225,7 +225,8 @@ int ax25_listen_mine(ax25_address *calls
 
spin_lock_bh(&listen_lock);
for (listen = listen_list; listen != NULL; listen = listen->next)
-   if (ax25cmp(&listen->callsign, callsign) == 0 && (listen->dev 
== dev || listen->dev == NULL)) {
+   if (ax25cmp(&listen->callsign, callsign) == 0 &&
+   (listen->dev == dev || listen->dev == NULL)) {
spin_unlock_bh(&listen_lock);
return 1;
}
Index: linux-net/net/netrom/nr_dev.c
===
--- linux-net.orig/net/netrom/nr_dev.c
+++ linux-net/net/netrom/nr_dev.c
@@ -128,25 +128,37 @@ static int nr_header(struct sk_buff *skb
return -37;
 }
 
-static int nr_set_mac_address(struct net_device *dev, void *addr)
+static int __must_check nr_set_mac_address(struct net_device *dev, void *addr)
 {
struct sockaddr *sa = addr;
+   int err;
+
+   if (!memcmp(dev->dev_addr, sa->sa_data, dev->addr_len))
+   return 0;
+
+   if (dev->flags & IFF_UP) {
+   err = ax25_listen_register((ax25_address *)sa->sa_data, NULL);
+   if (err)
+   return err;
 
-   if (dev->flags & IFF_UP)
ax25_listen_release((ax25_address *)dev->dev_addr, NULL);
+   }
 
memcpy(dev->dev_addr, sa->sa_data, dev->addr_len);
 
-   if (dev->flags & IFF_UP)
-   ax25_listen_register((ax25_address *)dev->dev_addr, NULL);
-
return 0;
 }
 
 static int nr_open(struct net_device *dev)
 {
+   int err;
+
+   err = ax25_listen_register((ax25_address *)dev->dev_addr, NULL);
+   if (err)
+   return err;
+
netif_start_queue(dev);
-   ax25_listen_register((ax25_address *)dev->dev_addr, NULL);
+
return 0;
 }
 
Index: linux-net/net/rose/af_rose.c
===
--- linux-net.orig/net/rose/af_rose.c
+++ linux-net/net/rose/af_rose.c
@@ -1314,7 +1314,8 @@ static int rose_ioctl(struct socket *soc
if (copy_from_user(&rose_callsign, argp, sizeof(ax25_address)))
return -EFAULT;
if (ax25cmp(&rose_callsign, &null_ax25_address) != 0)
-   ax25_listen_register(&rose_callsign, NULL);
+   return ax25_listen_register(&rose_callsign, NULL);
+
return 0;
 
case SIOCRSGL2CALL:
-
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


[AX.25 6/7] Fix unchecked rose_add_loopback_node uses

2006-12-14 Thread Ralf Baechle
Signed-off-by: Ralf Baechle <[EMAIL PROTECTED]>

 net/rose/rose_dev.c |   22 ++
 1 file changed, 18 insertions(+), 4 deletions(-)

Index: linux-net/net/rose/rose_dev.c
===
--- linux-net.orig/net/rose/rose_dev.c
+++ linux-net/net/rose/rose_dev.c
@@ -93,20 +93,34 @@ static int rose_rebuild_header(struct sk
 static int rose_set_mac_address(struct net_device *dev, void *addr)
 {
struct sockaddr *sa = addr;
+   int err;
 
-   rose_del_loopback_node((rose_address *)dev->dev_addr);
+   if (!memcpy(dev->dev_addr, sa->sa_data, dev->addr_len))
+   return 0;
 
-   memcpy(dev->dev_addr, sa->sa_data, dev->addr_len);
+   if (dev->flags & IFF_UP) {
+   err = rose_add_loopback_node((rose_address *)dev->dev_addr);
+   if (err)
+   return err;
+
+   rose_del_loopback_node((rose_address *)dev->dev_addr);
+   }
 
-   rose_add_loopback_node((rose_address *)dev->dev_addr);
+   memcpy(dev->dev_addr, sa->sa_data, dev->addr_len);
 
return 0;
 }
 
 static int rose_open(struct net_device *dev)
 {
+   int err;
+
+   err = rose_add_loopback_node((rose_address *)dev->dev_addr);
+   if (err)
+   return err;
+
netif_start_queue(dev);
-   rose_add_loopback_node((rose_address *)dev->dev_addr);
+
return 0;
 }
 
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[AX.25 2/7] Fix unchecked ax25_protocol_register uses.

2006-12-14 Thread Ralf Baechle
Replace ax25_protocol_register by ax25_register_pid which assumes the
caller has done the memory allocation.  This allows replacing the
kmalloc allocations entirely by static allocations.

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

 include/net/ax25.h |9 -
 net/ax25/ax25_iface.c  |   41 -
 net/netrom/af_netrom.c |7 ++-
 net/rose/af_rose.c |7 ++-
 4 files changed, 32 insertions(+), 32 deletions(-)

Index: linux-net/include/net/ax25.h
===
--- linux-net.orig/include/net/ax25.h
+++ linux-net/include/net/ax25.h
@@ -333,7 +333,14 @@ extern void ax25_ds_t3timer_expiry(ax25_
 extern void ax25_ds_idletimer_expiry(ax25_cb *);
 
 /* ax25_iface.c */
-extern int __must_check ax25_protocol_register(unsigned int, int (*)(struct 
sk_buff *, ax25_cb *));
+
+struct ax25_protocol {
+   struct ax25_protocol *next;
+   unsigned int pid;
+   int (*func)(struct sk_buff *, ax25_cb *);
+};
+
+extern void ax25_register_pid(struct ax25_protocol *ap);
 extern void ax25_protocol_release(unsigned int);
 extern int __must_check ax25_linkfail_register(void (*)(ax25_cb *, int));
 extern void ax25_linkfail_release(void (*)(ax25_cb *, int));
Index: linux-net/net/ax25/ax25_iface.c
===
--- linux-net.orig/net/ax25/ax25_iface.c
+++ linux-net/net/ax25/ax25_iface.c
@@ -29,11 +29,7 @@
 #include 
 #include 
 
-static struct protocol_struct {
-   struct protocol_struct *next;
-   unsigned int pid;
-   int (*func)(struct sk_buff *, ax25_cb *);
-} *protocol_list = NULL;
+static struct ax25_protocol *protocol_list;
 static DEFINE_RWLOCK(protocol_list_lock);
 
 static struct linkfail_struct {
@@ -49,36 +45,23 @@ static struct listen_struct {
 } *listen_list = NULL;
 static DEFINE_SPINLOCK(listen_lock);
 
-int ax25_protocol_register(unsigned int pid,
-   int (*func)(struct sk_buff *, ax25_cb *))
+/*
+ * Do not register the internal protocols AX25_P_TEXT, AX25_P_SEGMENT,
+ * AX25_P_IP or AX25_P_ARP ...
+ */
+void ax25_register_pid(struct ax25_protocol *ap)
 {
-   struct protocol_struct *protocol;
-
-   if (pid == AX25_P_TEXT || pid == AX25_P_SEGMENT)
-   return 0;
-#ifdef CONFIG_INET
-   if (pid == AX25_P_IP || pid == AX25_P_ARP)
-   return 0;
-#endif
-   if ((protocol = kmalloc(sizeof(*protocol), GFP_ATOMIC)) == NULL)
-   return 0;
-
-   protocol->pid  = pid;
-   protocol->func = func;
-
write_lock_bh(&protocol_list_lock);
-   protocol->next = protocol_list;
-   protocol_list  = protocol;
+   ap->next = protocol_list;
+   protocol_list = ap;
write_unlock_bh(&protocol_list_lock);
-
-   return 1;
 }
 
-EXPORT_SYMBOL(ax25_protocol_register);
+EXPORT_SYMBOL_GPL(ax25_register_pid);
 
 void ax25_protocol_release(unsigned int pid)
 {
-   struct protocol_struct *s, *protocol;
+   struct ax25_protocol *s, *protocol;
 
write_lock_bh(&protocol_list_lock);
protocol = protocol_list;
@@ -223,7 +206,7 @@ EXPORT_SYMBOL(ax25_listen_release);
 int (*ax25_protocol_function(unsigned int pid))(struct sk_buff *, ax25_cb *)
 {
int (*res)(struct sk_buff *, ax25_cb *) = NULL;
-   struct protocol_struct *protocol;
+   struct ax25_protocol *protocol;
 
read_lock(&protocol_list_lock);
for (protocol = protocol_list; protocol != NULL; protocol = 
protocol->next)
@@ -263,7 +246,7 @@ void ax25_link_failed(ax25_cb *ax25, int
 
 int ax25_protocol_is_registered(unsigned int pid)
 {
-   struct protocol_struct *protocol;
+   struct ax25_protocol *protocol;
int res = 0;
 
read_lock_bh(&protocol_list_lock);
Index: linux-net/net/netrom/af_netrom.c
===
--- linux-net.orig/net/netrom/af_netrom.c
+++ linux-net/net/netrom/af_netrom.c
@@ -1377,6 +1377,11 @@ static struct notifier_block nr_dev_noti
 
 static struct net_device **dev_nr;
 
+static struct ax25_protocol nr_pid = {
+   .pid= AX25_P_NETROM,
+   .func   = nr_route_frame
+};
+
 static int __init nr_proto_init(void)
 {
int i;
@@ -1424,7 +1429,7 @@ static int __init nr_proto_init(void)

register_netdevice_notifier(&nr_dev_notifier);
 
-   ax25_protocol_register(AX25_P_NETROM, nr_route_frame);
+   ax25_register_pid(&nr_pid);
ax25_linkfail_register(nr_link_failed);
 
 #ifdef CONFIG_SYSCTL
Index: linux-net/net/rose/af_rose.c
===
--- linux-net.orig/net/rose/af_rose.c
+++ linux-net/net/rose/af_rose.c
@@ -1481,6 +1481,11 @@ static struct notifier_block rose_dev_no
 
 static struct net_device **dev_rose;
 
+static struct ax25_protocol rose_pid = {
+   .pid= AX25_P_ROSE,
+   .func   = rose_route_fr

[AX.25 1/7] Mark all kmalloc users __must_check

2006-12-14 Thread Ralf Baechle
The recent fix 0506d4068bad834aab1141b5dc5e748eb175c6b3 made obvious that
error values were not being propagated through the AX.25 stack.  To help
with that this patch marks all kmalloc users in the AX.25, NETROM and
ROSE stacks as __must_check.

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

 include/net/ax25.h|   11 ++-
 include/net/rose.h|4 ++--
 net/ax25/af_ax25.c|4 ++--
 net/ax25/ax25_route.c |2 +-
 net/netrom/nr_route.c |8 +---
 net/rose/rose_route.c |2 +-
 6 files changed, 17 insertions(+), 14 deletions(-)

Index: linux-net/include/net/ax25.h
===
--- linux-net.orig/include/net/ax25.h
+++ linux-net/include/net/ax25.h
@@ -277,7 +277,7 @@ struct sock *ax25_get_socket(ax25_addres
 extern ax25_cb *ax25_find_cb(ax25_address *, ax25_address *, ax25_digi *, 
struct net_device *);
 extern void ax25_send_to_raw(ax25_address *, struct sk_buff *, int);
 extern void ax25_destroy_socket(ax25_cb *);
-extern ax25_cb *ax25_create_cb(void);
+extern ax25_cb * __must_check ax25_create_cb(void);
 extern void ax25_fillin_cb(ax25_cb *, ax25_dev *);
 extern struct sock *ax25_make_new(struct sock *, struct ax25_dev *);
 
@@ -333,11 +333,12 @@ extern void ax25_ds_t3timer_expiry(ax25_
 extern void ax25_ds_idletimer_expiry(ax25_cb *);
 
 /* ax25_iface.c */
-extern int  ax25_protocol_register(unsigned int, int (*)(struct sk_buff *, 
ax25_cb *));
+extern int __must_check ax25_protocol_register(unsigned int, int (*)(struct 
sk_buff *, ax25_cb *));
 extern void ax25_protocol_release(unsigned int);
-extern int  ax25_linkfail_register(void (*)(ax25_cb *, int));
+extern int __must_check ax25_linkfail_register(void (*)(ax25_cb *, int));
 extern void ax25_linkfail_release(void (*)(ax25_cb *, int));
-extern int  ax25_listen_register(ax25_address *, struct net_device *);
+extern int __must_check ax25_listen_register(ax25_address *,
+   struct net_device *);
 extern void ax25_listen_release(ax25_address *, struct net_device *);
 extern int  (*ax25_protocol_function(unsigned int))(struct sk_buff *, ax25_cb 
*);
 extern int  ax25_listen_mine(ax25_address *, struct net_device *);
@@ -415,7 +416,7 @@ extern unsigned long ax25_display_timer(
 /* ax25_uid.c */
 extern int  ax25_uid_policy;
 extern ax25_uid_assoc *ax25_findbyuid(uid_t);
-extern int  ax25_uid_ioctl(int, struct sockaddr_ax25 *);
+extern int __must_check ax25_uid_ioctl(int, struct sockaddr_ax25 *);
 extern struct file_operations ax25_uid_fops;
 extern void ax25_uid_free(void);
 
Index: linux-net/include/net/rose.h
===
--- linux-net.orig/include/net/rose.h
+++ linux-net/include/net/rose.h
@@ -193,8 +193,8 @@ extern struct file_operations rose_neigh
 extern struct file_operations rose_nodes_fops;
 extern struct file_operations rose_routes_fops;
 
-extern int  rose_add_loopback_neigh(void);
-extern int  rose_add_loopback_node(rose_address *);
+extern int __must_check rose_add_loopback_neigh(void);
+extern int __must_check rose_add_loopback_node(rose_address *);
 extern void rose_del_loopback_node(rose_address *);
 extern void rose_rt_device_down(struct net_device *);
 extern void rose_link_device_down(struct net_device *);
Index: linux-net/net/ax25/af_ax25.c
===
--- linux-net.orig/net/ax25/af_ax25.c
+++ linux-net/net/ax25/af_ax25.c
@@ -1088,8 +1088,8 @@ out:
 /*
  * FIXME: nonblock behaviour looks like it may have a bug.
  */
-static int ax25_connect(struct socket *sock, struct sockaddr *uaddr,
-   int addr_len, int flags)
+static int __must_check ax25_connect(struct socket *sock,
+   struct sockaddr *uaddr, int addr_len, int flags)
 {
struct sock *sk = sock->sk;
ax25_cb *ax25 = ax25_sk(sk), *ax25t;
Index: linux-net/net/ax25/ax25_route.c
===
--- linux-net.orig/net/ax25/ax25_route.c
+++ linux-net/net/ax25/ax25_route.c
@@ -71,7 +71,7 @@ void ax25_rt_device_down(struct net_devi
write_unlock(&ax25_route_lock);
 }
 
-static int ax25_rt_add(struct ax25_routes_struct *route)
+static int __must_check ax25_rt_add(struct ax25_routes_struct *route)
 {
ax25_route *ax25_rt;
ax25_dev *ax25_dev;
Index: linux-net/net/rose/rose_route.c
===
--- linux-net.orig/net/rose/rose_route.c
+++ linux-net/net/rose/rose_route.c
@@ -52,7 +52,7 @@ struct rose_neigh *rose_loopback_neigh;
  * Add a new route to a node, and in the process add the node and the
  * neighbour if it is new.
  */
-static int rose_add_node(struct rose_route_struct *rose_route,
+static int __must_check rose_add_node(struct rose_route_struct *rose_route,
struct net_device *dev)
 {
struct rose_node  *rose_node, *rose_tmpn, *rose_tmpp;
Index: linux-net/net/netr

[AX.25 7/7] Fix unchecked rose_add_loopback_neigh uses

2006-12-14 Thread Ralf Baechle
rose_add_loopback_neigh uses kmalloc and the callers were ignoring the
error value.  Rewrite to let the caller deal with the allocation.  This
allows the use of static allocation of kmalloc use entirely.

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

 include/net/rose.h   |4 ++--
 net/rose/rose_loopback.c |5 +++--
 net/rose/rose_route.c|   45 +
 3 files changed, 26 insertions(+), 28 deletions(-)

Index: linux-net/include/net/rose.h
===
--- linux-net.orig/include/net/rose.h
+++ linux-net/include/net/rose.h
@@ -188,12 +188,12 @@ extern void rose_kick(struct sock *);
 extern void rose_enquiry_response(struct sock *);
 
 /* rose_route.c */
-extern struct rose_neigh *rose_loopback_neigh;
+extern struct rose_neigh rose_loopback_neigh;
 extern struct file_operations rose_neigh_fops;
 extern struct file_operations rose_nodes_fops;
 extern struct file_operations rose_routes_fops;
 
-extern int __must_check rose_add_loopback_neigh(void);
+extern void rose_add_loopback_neigh(void);
 extern int __must_check rose_add_loopback_node(rose_address *);
 extern void rose_del_loopback_node(rose_address *);
 extern void rose_rt_device_down(struct net_device *);
Index: linux-net/net/rose/rose_loopback.c
===
--- linux-net.orig/net/rose/rose_loopback.c
+++ linux-net/net/rose/rose_loopback.c
@@ -79,7 +79,8 @@ static void rose_loopback_timer(unsigned
 
skb->h.raw = skb->data;
 
-   if ((sk = rose_find_socket(lci_o, rose_loopback_neigh)) != 
NULL) {
+   sk = rose_find_socket(lci_o, &rose_loopback_neigh);
+   if (sk) {
if (rose_process_rx_frame(sk, skb) == 0)
kfree_skb(skb);
continue;
@@ -87,7 +88,7 @@ static void rose_loopback_timer(unsigned
 
if (frametype == ROSE_CALL_REQUEST) {
if ((dev = rose_dev_get(dest)) != NULL) {
-   if (rose_rx_call_request(skb, dev, 
rose_loopback_neigh, lci_o) == 0)
+   if (rose_rx_call_request(skb, dev, 
&rose_loopback_neigh, lci_o) == 0)
kfree_skb(skb);
} else {
kfree_skb(skb);
Index: linux-net/net/rose/rose_route.c
===
--- linux-net.orig/net/rose/rose_route.c
+++ linux-net/net/rose/rose_route.c
@@ -46,7 +46,7 @@ static DEFINE_SPINLOCK(rose_neigh_list_l
 static struct rose_route *rose_route_list;
 static DEFINE_SPINLOCK(rose_route_list_lock);
 
-struct rose_neigh *rose_loopback_neigh;
+struct rose_neigh rose_loopback_neigh;
 
 /*
  * Add a new route to a node, and in the process add the node and the
@@ -361,33 +361,30 @@ out:
 /*
  * Add the loopback neighbour.
  */
-int rose_add_loopback_neigh(void)
+void rose_add_loopback_neigh(void)
 {
-   if ((rose_loopback_neigh = kmalloc(sizeof(struct rose_neigh), 
GFP_ATOMIC)) == NULL)
-   return -ENOMEM;
+   struct rose_neigh *sn = &rose_loopback_neigh;
 
-   rose_loopback_neigh->callsign  = null_ax25_address;
-   rose_loopback_neigh->digipeat  = NULL;
-   rose_loopback_neigh->ax25  = NULL;
-   rose_loopback_neigh->dev   = NULL;
-   rose_loopback_neigh->count = 0;
-   rose_loopback_neigh->use   = 0;
-   rose_loopback_neigh->dce_mode  = 1;
-   rose_loopback_neigh->loopback  = 1;
-   rose_loopback_neigh->number= rose_neigh_no++;
-   rose_loopback_neigh->restarted = 1;
+   sn->callsign  = null_ax25_address;
+   sn->digipeat  = NULL;
+   sn->ax25  = NULL;
+   sn->dev   = NULL;
+   sn->count = 0;
+   sn->use   = 0;
+   sn->dce_mode  = 1;
+   sn->loopback  = 1;
+   sn->number= rose_neigh_no++;
+   sn->restarted = 1;
 
-   skb_queue_head_init(&rose_loopback_neigh->queue);
+   skb_queue_head_init(&sn->queue);
 
-   init_timer(&rose_loopback_neigh->ftimer);
-   init_timer(&rose_loopback_neigh->t0timer);
+   init_timer(&sn->ftimer);
+   init_timer(&sn->t0timer);
 
spin_lock_bh(&rose_neigh_list_lock);
-   rose_loopback_neigh->next = rose_neigh_list;
-   rose_neigh_list   = rose_loopback_neigh;
+   sn->next = rose_neigh_list;
+   rose_neigh_list   = sn;
spin_unlock_bh(&rose_neigh_list_lock);
-
-   return 0;
 }
 
 /*
@@ -421,13 +418,13 @@ int rose_add_loopback_node(rose_address 
rose_node->mask = 10;
rose_node->count= 1;
rose_node->loopback = 1;
-   rose_node->neighbour[0] = rose_loopbac

[AX.25 4/7] Fix unchecked nr_add_node uses

2006-12-14 Thread Ralf Baechle
Signed-off-by: Ralf Baechle <[EMAIL PROTECTED]>

 net/netrom/nr_route.c |   11 ---
 1 file changed, 8 insertions(+), 3 deletions(-)

Index: linux-net/net/netrom/nr_route.c
===
--- linux-net.orig/net/netrom/nr_route.c
+++ linux-net/net/netrom/nr_route.c
@@ -779,9 +779,13 @@ int nr_route_frame(struct sk_buff *skb, 
nr_src  = (ax25_address *)(skb->data + 0);
nr_dest = (ax25_address *)(skb->data + 7);
 
-   if (ax25 != NULL)
-   nr_add_node(nr_src, "", &ax25->dest_addr, ax25->digipeat,
-   ax25->ax25_dev->dev, 0, 
sysctl_netrom_obsolescence_count_initialiser);
+   if (ax25 != NULL) {
+   ret = nr_add_node(nr_src, "", &ax25->dest_addr, ax25->digipeat,
+ ax25->ax25_dev->dev, 0,
+ sysctl_netrom_obsolescence_count_initialiser);
+   if (ret)
+   return ret;
+   }
 
if ((dev = nr_dev_get(nr_dest)) != NULL) {  /* Its for me */
if (ax25 == NULL)   /* Its from me */
@@ -846,6 +850,7 @@ int nr_route_frame(struct sk_buff *skb, 
ret = (nr_neigh->ax25 != NULL);
nr_node_unlock(nr_node);
nr_node_put(nr_node);
+
return ret;
 }
 
-
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   >