* Re: [RFC] net: napi fix
From: Stephen Hemminger @ 2007-12-13 18:22 UTC (permalink / raw)
To: David Miller
Cc: gallatin, joonwpark81, auke-jan.h.kok, netdev, linux-kernel,
jgarzik, jesse.brandeburg
In-Reply-To: <20071213.061938.86541759.davem@davemloft.net>
On Thu, 13 Dec 2007 06:19:38 -0800 (PST)
David Miller <davem@davemloft.net> wrote:
> From: Andrew Gallatin <gallatin@myri.com>
> Date: Thu, 13 Dec 2007 09:13:54 -0500
>
> > If the netif_running() check is indeed required to make a device break
> > out of napi polling and respond to an ifconfig down, then I think the
> > netif_running() check should be moved up into net_rx_action() to avoid
> > potential for driver complexity and bugs like the ones you found.
>
> That, or something like it, definitely sounds reasonable and much
> better than putting the check into every driver :-)
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
It is not possible to do netif_running() check in generic code as currently
written because of the case of devices where a single NAPI object is
being used to handle two devices. The association between napi and netdevice
is M to N. There are cases like niu that have multiple NAPI's and one
netdevice; and devices like sky2 that can have one NAPI and 2 netdevice's.
The existing pointer from napi to netdevice is only used by netconsole
now. For devices like sky2 it means that netconsole can't work on the the
second port which is a not a big problem. But adding a netif_running()
check would be a big issue.
--
Stephen Hemminger <shemminger@linux-foundation.org>
^ permalink raw reply
* Re: 2.6.24-rc5-mm1
From: Adrian Bunk @ 2007-12-13 17:54 UTC (permalink / raw)
To: bbpetkov, Benjamin Thery, Pierre Peiffer, Andrew Morton,
linux-kernel, netdev@
In-Reply-To: <20071213160744.GA4509@gollum.tnic>
On Thu, Dec 13, 2007 at 05:07:44PM +0100, Borislav Petkov wrote:
> On Thu, Dec 13, 2007 at 04:01:34PM +0100, Benjamin Thery wrote:
> > The problem comes from the new macro UDPX_INC_STATS_BH introduced
> > by Herbert, which was a nice addition to increment the correct
> > UDP MIB depending on the socket family, but unfortunately
> > the use of this macro from kernel code (I mean code not compiled
> > as module) requires that IPv6 is also compiled in kernel
> > (CONFIG_IPv6=y) in order to have udp_stats_in6 defined at link
> > time.
> >
> > Benjamin
> >
> > Pierre Peiffer wrote:
> > > Hi,
> > >
> > > My config does not link any more:
> > >
> > > ...
> > > CHK include/linux/compile.h
> > > UPD include/linux/compile.h
> > > CC init/version.o
> > > LD init/built-in.o
> > > LD .tmp_vmlinux1
> > > net/built-in.o: In function `xs_udp_data_ready':
> > > /home/peifferp/containers/kernel/linux-2.6.24-rc5-mm1/net/sunrpc/xprtsock.c:842:
> > > undefined reference to `udp_stats_in6'
> > > /home/peifferp/containers/kernel/linux-2.6.24-rc5-mm1/net/sunrpc/xprtsock.c:846:
> > > undefined reference to `udp_stats_in6'
> > > make[1]: *** [.tmp_vmlinux1] Error 1
> > > make: *** [sub-make] Error 2
> > >
> > > After a first look, udp_stats_in6 seems to be defined in ipv6 (file
> > > net/ipv6/udp.c) but I have
> > >
> > > CONFIG_IPV6=m
> > > and
> > > CONFIG_SUNRPC=y
> > >
> > > So, SUNRPC uses something defined in a module in my case ?
> > >
> > > ... looking more, this dependency seems to have been introduced by the patch
> > > [UDP]: Restore missing inDatagrams increments
> > > ( http://thread.gmane.org/gmane.linux.network/79716/focus=79831 )
> > >
> > > (I cc netdev)
> > >
> > > I don't know what is the right way to fix this ... ?
>
> you might do "select IPV6" in the SUNRPC section of fs/Kconfig, however select is
> evil...
select itself isn't evil.
Nonsensical selects like the one you suggest (sunrpc does not require
IPV6) are evil.
> Regards/Gruß,
> Boris.
cu
Adrian
--
"Is there not promise of rain?" Ling Tan asked suddenly out
of the darkness. There had been need of rain for many days.
"Only a promise," Lao Er said.
Pearl S. Buck - Dragon Seed
^ permalink raw reply
* Re: [PATCH 2.6.25] [IPV4] Thresholds in fib_trie.c are used as consts, so make them const.
From: David Miller @ 2007-12-13 17:48 UTC (permalink / raw)
To: den; +Cc: containers, devel, netdev
In-Reply-To: <20071213080618.GA6530@iris.sw.ru>
From: "Denis V. Lunev" <den@openvz.org>
Date: Thu, 13 Dec 2007 11:06:18 +0300
> [IPV4] Thresholds in fib_trie.c are used as consts, so make them const.
>
> There are several thresholds for trie fib hash management. They are used
> in the code as a constants. Make them constants from the compiler point of
> view.
>
> Signed-off-by: Denis V. Lunev <den@openvz.org>
Applied, thanks for fixing this patch up.
^ permalink raw reply
* Re: [patch 2/2] ipv6/sit: Rebinding of SIT tunnels to other interfaces
From: David Miller @ 2007-12-13 17:47 UTC (permalink / raw)
To: mschmidt; +Cc: netdev, kaber, mmaslano
In-Reply-To: <20071213133922.468540197@redhat.com>
From: mschmidt@redhat.com
Date: Thu, 13 Dec 2007 14:37:50 +0100
> This is similar to the change already done for IPIP tunnels.
>
> Once created, a SIT tunnel can't be bound to another device.
> To reproduce:
>
> # create a tunnel:
> ip tunnel add tunneltest0 mode sit remote 10.0.0.1 dev eth0
> # try to change the bounding device from eth0 to eth1:
> ip tunnel change tunneltest0 dev eth1
> # show the result:
> ip tunnel show tunneltest0
>
> tunneltest0: ipv6/ip remote 10.0.0.1 local any dev eth0 ttl inherit
>
> Notice the bound device has not changed from eth0 to eth1.
>
> This patch fixes it. When changing the binding, it also recalculates the
> MTU according to the new bound device's MTU.
>
> Signed-off-by: Michal Schmidt <mschmidt@redhat.com>
Also applied, thanks.
^ permalink raw reply
* Re: [patch 1/2] ip_gre: Rebinding of GRE tunnels to other interfaces
From: David Miller @ 2007-12-13 17:47 UTC (permalink / raw)
To: mschmidt; +Cc: netdev, kaber, mmaslano
In-Reply-To: <20071213133922.223489455@redhat.com>
From: mschmidt@redhat.com
Date: Thu, 13 Dec 2007 14:37:49 +0100
> This is similar to the change already done for IPIP tunnels.
>
> Once created, a GRE tunnel can't be bound to another device.
> To reproduce:
>
> # create a tunnel:
> ip tunnel add tunneltest0 mode gre remote 10.0.0.1 dev eth0
> # try to change the bounding device from eth0 to eth1:
> ip tunnel change tunneltest0 dev eth1
> # show the result:
> ip tunnel show tunneltest0
>
> tunneltest0: gre/ip remote 10.0.0.1 local any dev eth0 ttl inherit
>
> Notice the bound device has not changed from eth0 to eth1.
>
> This patch fixes it. When changing the binding, it also recalculates the
> MTU according to the new bound device's MTU.
>
> Signed-off-by: Michal Schmidt <mschmidt@redhat.com>
Applied to net-2.6.25, thanks.
^ permalink raw reply
* Re: 2.6.24-rc5-mm1
From: David Miller @ 2007-12-13 17:45 UTC (permalink / raw)
To: benjamin.thery; +Cc: pierre.peiffer, akpm, linux-kernel, netdev, herbert
In-Reply-To: <4761494E.1050704@bull.net>
From: Benjamin Thery <benjamin.thery@bull.net>
Date: Thu, 13 Dec 2007 16:01:34 +0100
> The problem comes from the new macro UDPX_INC_STATS_BH introduced
> by Herbert, which was a nice addition to increment the correct
> UDP MIB depending on the socket family, but unfortunately
> the use of this macro from kernel code (I mean code not compiled
> as module) requires that IPv6 is also compiled in kernel
> (CONFIG_IPv6=y) in order to have udp_stats_in6 defined at link
> time.
Herbert, please take a look at this, thanks!
> Benjamin
>
> Pierre Peiffer wrote:
> > Hi,
> >
> > My config does not link any more:
> >
> > ...
> > CHK include/linux/compile.h
> > UPD include/linux/compile.h
> > CC init/version.o
> > LD init/built-in.o
> > LD .tmp_vmlinux1
> > net/built-in.o: In function `xs_udp_data_ready':
> > /home/peifferp/containers/kernel/linux-2.6.24-rc5-mm1/net/sunrpc/xprtsock.c:842:
> > undefined reference to `udp_stats_in6'
> > /home/peifferp/containers/kernel/linux-2.6.24-rc5-mm1/net/sunrpc/xprtsock.c:846:
> > undefined reference to `udp_stats_in6'
> > make[1]: *** [.tmp_vmlinux1] Error 1
> > make: *** [sub-make] Error 2
> >
> > After a first look, udp_stats_in6 seems to be defined in ipv6 (file
> > net/ipv6/udp.c) but I have
> >
> > CONFIG_IPV6=m
> > and
> > CONFIG_SUNRPC=y
> >
> > So, SUNRPC uses something defined in a module in my case ?
> >
> > ... looking more, this dependency seems to have been introduced by the patch
> > [UDP]: Restore missing inDatagrams increments
> > ( http://thread.gmane.org/gmane.linux.network/79716/focus=79831 )
> >
> > (I cc netdev)
> >
> > I don't know what is the right way to fix this ... ?
> >
> > P.
> > Andrew Morton wrote:
> >> ftp://ftp.kernel.org/pub/linux/kernel/people/akpm/patches/2.6/2.6.24-rc5/2.6.24-rc5-mm1/
> >>
> >> - If something goes wrong with a PCI device's probing or initialisation, try
> >> reverting pci-disable-decoding-during-sizing-of-bars.patch.
> >>
> >> - git-sched was dropped due to breaking suspend-to-RAM.
> >>
> >> - git-block has been restored after having had a few problems
> >>
> >> - git-newsetup.patch was dropped due to conflicts with git-x86
> >>
> >> - git-perfmon.patch is still dropped for the same reason
> >>
> >> - git-kgdb.patch is still dropped for the same reason
> >>
> >> - Please do try to cc the correct developer and mailing list when
> >> reporting problems - I'm just buried in bugs over here.
> >>
> >>
> >>
> >> Boilerplate:
> >>
> >> - See the `hot-fixes' directory for any important updates to this patchset.
> >>
> >> - To fetch an -mm tree using git, use (for example)
> >>
> >> git-fetch git://git.kernel.org/pub/scm/linux/kernel/git/smurf/linux-trees.git tag v2.6.16-rc2-mm1
> >> git-checkout -b local-v2.6.16-rc2-mm1 v2.6.16-rc2-mm1
> >>
> >> - -mm kernel commit activity can be reviewed by subscribing to the
> >> mm-commits mailing list.
> >>
> >> echo "subscribe mm-commits" | mail majordomo@vger.kernel.org
> >>
> >> - If you hit a bug in -mm and it is not obvious which patch caused it, it is
> >> most valuable if you can perform a bisection search to identify which patch
> >> introduced the bug. Instructions for this process are at
> >>
> >> http://www.zip.com.au/~akpm/linux/patches/stuff/bisecting-mm-trees.txt
> >>
> >> But beware that this process takes some time (around ten rebuilds and
> >> reboots), so consider reporting the bug first and if we cannot immediately
> >> identify the faulty patch, then perform the bisection search.
> >>
> >> - When reporting bugs, please try to Cc: the relevant maintainer and mailing
> >> list on any email.
> >>
> >> - When reporting bugs in this kernel via email, please also rewrite the
> >> email Subject: in some manner to reflect the nature of the bug. Some
> >> developers filter by Subject: when looking for messages to read.
> >>
> >> - Occasional snapshots of the -mm lineup are uploaded to
> >> ftp://ftp.kernel.org/pub/linux/kernel/people/akpm/mm/ and are announced on
> >> the mm-commits list. These probably are at least compilable.
> >>
> >> - More-than-daily -mm snapshots may be found at
> >> http://userweb.kernel.org/~akpm/mmotm/. These are almost certainly not
> >> compileable.
> >>
> >>
> >>
> >> Changes since 2.6.24-rc4-mm1:
> >>
> >>
> >> origin.patch
> >> git-acpi.patch
> >> git-alsa.patch
> >> git-agpgart.patch
> >> git-arm.patch
> >> git-arm-master.patch
> >> git-avr32.patch
> >> git-cpufreq.patch
> >> git-powerpc.patch
> >> git-drm.patch
> >> git-dvb.patch
> >> git-hwmon.patch
> >> git-gfs2-nmw.patch
> >> git-hid.patch
> >> git-hrt.patch
> >> git-ieee1394.patch
> >> git-infiniband.patch
> >> git-input.patch
> >> git-jfs.patch
> >> git-kbuild.patch
> >> git-kvm.patch
> >> git-lblnet.patch
> >> git-leds.patch
> >> git-libata-all.patch
> >> git-md-accel.patch
> >> git-mips.patch
> >> git-mmc.patch
> >> git-mtd.patch
> >> git-ubi.patch
> >> git-net.patch
> >> git-netdev-all.patch
> >> git-battery.patch
> >> git-nfs.patch
> >> git-nfsd.patch
> >> git-ocfs2.patch
> >> git-s390.patch
> >> git-sh.patch
> >> git-scsi-misc.patch
> >> git-scsi-rc-fixes.patch
> >> git-block.patch
> >> git-unionfs.patch
> >> git-v9fs.patch
> >> git-watchdog.patch
> >> git-wireless.patch
> >> git-ipwireless_cs.patch
> >> git-x86.patch
> >> git-xfs.patch
> >> git-cryptodev.patch
> >> git-xtensa.patch
> >>
> >> git trees
> >>
> >> -aio-only-account-i-o-wait-time-in-read_events-if-there-are-active-requests.patch
> >> -fix-cloneclone_newpid.patch
> >> -rtc-assure-proper-memory-ordering-with-respect-to-rtc_dev_busy-flag.patch
> >> -ufs-fix-nexstep-dir-block-size.patch
> >> -ufs-fix-nexstep-dir-block-size-checkpatch-fixes.patch
> >> -aoe-properly-initialise-the-request_queues-backing_dev_info.patch
> >> -mm-backing-devc-fix-percpu_counter_destroy-call-bug-in-bdi_init.patch
> >> -add-export_symbolksize.patch
> >> -spi-use-mutex-not-semaphore.patch
> >> -spi-at25-driver-is-for-eeprom-not-flash.patch
> >> -spi-simplify-spi_sync-calling-convention.patch
> >> -spi-use-simplified-spi_sync-calling-convention.patch
> >> -spi-initial-bf54x-spi-support.patch
> >> -spi-bfin-spi-uses-portmux-calls.patch
> >> -spi-spi_bfin-cleanups-error-handling.patch
> >> -spi-spi_bfin-handles-spi_transfercs_change.patch
> >> -spi-spi_bfin-dont-bypass-spi-framework.patch
> >> -spi-spi_bfin-uses-platform-device-resources.patch
> >> -spi-spi_bfin-uses-portmux-for-additional-busses.patch
> >> -spi-spi_bfin-rearrange-portmux-calls.patch
> >> -spi-spi_bfin-change-handling-of-communication-parameters.patch
> >> -spi-spi_bfin-relocate-spin-waits.patch
> >> -spi-spi_bfin-handle-multiple-spi_masters.patch
> >> -spi-spi_bfin-bugfix-for-816-bit-word-sizes.patch
> >> -spi-spi_bfin-update-handling-of-delay-after-deselect.patch
> >> -spi-spi_bfin-resequence-dma-start-stop.patch
> >> -blackfin-spi-driver-use-cpu_relax-to-replace-continue-in-while-busywait.patch
> >> -blackfin-spi-driver-use-void-__iomem-for-regs_base.patch
> >> -blackfin-spi-driver-move-hard-coded-pin_req-to-board-file.patch
> >> -blackfin-spi-driver-reconfigure-speed_hz-and-bits_per_word-in-each-spi-transfer.patch
> >> -avoid-potential-null-dereference-in-unregister_sysctl_table.patch
> >> -gpio_cs5535-disable-aux-on-output.patch
> >> -mm-fix-xip-file-writes.patch
> >> -revert-dpt_i2o-convert-to-scsi-hotplug-model.patch
> >> -jbd-fix-assertion-failure-in-fs-jbd-checkpointc.patch
> >> -proc-fix-pde-refcounting.patch
> >> -powerpc-invalid-size-for-swapper_pg_dir-with-config_pte_64bit=y.patch
> >> -gregkh-driver-kset-add-kset_create_and_register-function.patch
> >> -gregkh-driver-kobject-add-kobject_create_and_register-function.patch
> >> -gregkh-driver-kset-convert-pci-hotplug-to-use-kset_create_and_register.patch
> >> -gregkh-driver-kset-convert-drivers-base-busc-kset_create_and_register.patch
> >> -gregkh-driver-kset-convert-drivers-base-classc-kset_create_and_register.patch
> >> -gregkh-driver-kset-convert-drivers-base-firmwarec-kset_create_and_register.patch
> >> -gregkh-driver-driver-core-remove-owner-field-from-struct-bus_type.patch
> >> -gregkh-driver-driver-core-add-way-to-get-to-bus-kset.patch
> >> -gregkh-driver-driver-core-add-way-to-get-to-bus-device-klist.patch
> >> -gregkh-driver-driver-core-remove-fields-from-struct-bus_type.patch
> >> -gregkh-driver-kobject-convert-hvc_console-to-use-kref-not-kobject.patch
> >> -gregkh-driver-kobject-convert-hvcs-to-use-kref-not-kobject.patch
> >> -gregkh-driver-kobject-fix-up-kobject_set_name-to-use-kvasprintf.patch
> >> -gregkh-driver-kobject-add-kobject_init_ng-kobject_add_ng-and-kobject_init_and_add-functions.patch
> >> -gregkh-driver-driver-core-move-the-driver-specific-module-code-into-the-driver-core-fix.patch
> >> -remove-saa7134-oss.patch
> >> -jdelvare-i2c-i2c-delete-old-documentation.patch
> >> -jdelvare-i2c-i2c-gpio-set-hwmon-class.patch
> >> -jdelvare-i2c-i2c-add-missing-space.patch
> >> -rename-_bss-to-__bss_start.patch
> >> -ia64-efi-make-full-use-of-macro-efi_md_size.patch
> >> -ads7846-stop-updating-dev-powerpower_state.patch
> >> -remove-trailing-nuls-from-network-bonding-sysfs-interface.patch
> >> -net-bonding-return-nothing-for-not-applicable-values.patch
> >> -net-bonding-purely-cosmetic-rename-a-local-variable.patch
> >> -git-watchdog-hpwdt-build-fix.patch
> >> -iwlwifi-3945-fix-race-conditional-panic.patch
> >> -iwlwifi-4965-fix-race-conditional-panic.patch
> >> -bcm43xx_debugfs-sscanf-fix.patch
> >> -arch-xtensa-remove-duplicate-includes.patch
> >> -xtensa-kernel-setupc-remove-dead-code.patch
> >> -ia64-increase-datapatch-offset.patch
> >> -ia64-dont-assume-that-unwcheckpy-is-executable.patch
> >> -ia64-export-copy_page-to-modules.patch
> >> -add-mike-christie-to-maintainers.patch
> >> -scsi-early-detection-of-medium-not-present-updated.patch
> >> -slubs-ksize-fails-for-size-2048.patch
> >> -vm-security-add-security-hook-to-do_brk.patch
> >> -mm-sparsec-check-the-return-value-of-sparse_index_alloc.patch
> >> -mm-sparsec-improve-the-error-handling-for-sparse_add_one_section.patch
> >> -pie-executable-randomization.patch
> >> -pie-executable-randomization-uninlining.patch
> >> -pie-executable-randomization-checkpatch-fixes.patch
> >>
> >> Merged into mainline or a subsystem tree
> >>
> >> +revert-hibernation-use-temporary-page-tables-for-kernel-text-mapping-on-x86_64.patch
> >> +uml-stop-gdb-from-deleting-breakpoints-when-running-uml.patch
> >> +alpha-strncpy-strncat-fixes.patch
> >> +rtc-at32ap700x-fix-irq-init-oops.patch
> >> +parport-dev-timeslice-is-an-unsigned-long-not-an-int.patch
> >> +ecryptfs-initialize-new-auth_tokens-before-teardown.patch
> >> +knfsd-change-mailing-list-for-nfsd-in-maintainers.patch
> >> +fix-lguest-documentation.patch
> >> +sparsemem-make-sparsemem_vmemmap-selectable.patch
> >> +fs-kconfig-grammar-fix.patch
> >> +ext3-ext4-avoid-divide-by-zero.patch
> >> +alpha-build-fixes.patch
> >>
> >> 2.6.24 queue
> >>
> >> +timerfd-v3-new-timerfd-api-s390-fix.patch
> >> +timerfd-v3-new-timerfd-api-sparc64-fix.patch
> >>
> >> Fix timerfd-v3-new-timerfd-api.patch a ridiculous number of times.
> >>
> >> +git-acpi-build-fix.patch
> >>
> >> Fix git-acpi.patch more.
> >>
> >> +acpi-remove-duplicated-warning-message.patch
> >> +acpi_pci_irq_find_prt_entry-use-list_for_each_entry-instead-of-list_for_each.patch
> >>
> >> ACPI things
> >>
> >> +alsa-nopage.patch
> >> +alsa-usx2y-nopage.patch
> >>
> >> ALSA things
> >>
> >> -git-avr32-fixup.patch
> >>
> >> Unneeded
> >>
> >> +agk-dm-dm-crypt-use-bio_add_page.patch
> >> +agk-dm-dm-convert-suspend_lock-semaphore-to-mutex.patch
> >> +agk-dm-dm-snapshot-combine-consecutive-exceptions-in-memory.patch
> >>
> >> DM updates
> >>
> >> +powerpc-dont-cast-a-pointer-to-pointer-of-list_head.patch
> >> +arch-powerpc-add-missing-of_node_put.patch
> >> +arch-powerpc-platforms-cell-cbe_regsc-add-missing-of_node_put.patch
> >>
> >> powerpc stuff
> >>
> >> +gregkh-driver-kobject-fix-the-documentation-of-how-kobject_set_name-works.patch
> >> +gregkh-driver-kobject-convert-ibmasm-to-use-kref-not-kobject.patch
> >> +gregkh-driver-kobject-convert-hvc_console-to-use-kref-not-kobject.patch
> >> +gregkh-driver-kobject-convert-hvcs-to-use-kref-not-kobject.patch
> >> +gregkh-driver-kobject-convert-icom-to-use-kref-not-kobject.patch
> >> +gregkh-driver-kobject-fix-up-kobject_set_name-to-use-kvasprintf.patch
> >> +gregkh-driver-kobject-make-kobject_cleanup-be-static.patch
> >> +gregkh-driver-kobject-add-kobject_init_ng-function.patch
> >> +gregkh-driver-kobject-add-kobject_add_ng-function.patch
> >> +gregkh-driver-kobject-add-kobject_init_and_add-function.patch
> >> +gregkh-driver-kset-add-kset_create_and_add-function.patch
> >> +gregkh-driver-kobject-add-kobject_create_and_add-function.patch
> >> +gregkh-driver-kset-convert-pci-hotplug-to-use-kset_create_and_add.patch
> >> +gregkh-driver-kset-convert-drivers-base-busc-to-use-kset_create.patch
> >> +gregkh-driver-kset-convert-drivers-base-classc-to-use-kset_create.patch
> >> +gregkh-driver-kset-convert-drivers-base-firmwarec-to-use-kset_create.patch
> >> +gregkh-driver-uio-fix-kobject-usage.patch
> >> +gregkh-driver-driver-core-remove-owner-field-from-struct-bus_type.patch
> >> +gregkh-driver-driver-core-add-way-to-get-to-bus-kset.patch
> >> +gregkh-driver-driver-core-add-way-to-get-to-bus-device-klist.patch
> >> +gregkh-driver-driver-core-remove-fields-from-struct-bus_type.patch
> >> +gregkh-driver-driver-core-introduce-default-attribute-groups.patch
> >> +gregkh-driver-netiucv-use-device_driver-default-attribute-groups.patch
> >> +gregkh-driver-zfcp-use-device_driver-default-attribute-groups.patch
> >> +gregkh-driver-infiniband-make-ipath-driver-use-default-driver-groups.patch
> >>
> >> Driver tree updates
> >>
> >> +revert-gregkh-driver-pm-acquire-device-locks-prior-to-suspending.patch
> >>
> >> Fix it.
> >>
> >> -driver-tree-broke-infiniband.patch
> >>
> >> Unneeded
> >>
> >> +drm-dont-cast-a-pointer-to-pointer-of-list_head.patch
> >>
> >> DRM cleanup
> >>
> >> +git-dvb-fix-build-in-drivers-media-dvb-frontends-tda18271h.patch
> >> +git-dvb-one-videobuf_read_start-is-enough.patch
> >> +git-dvb-drivers-media-dvb-frontends-zl10353c-avoid-64-bit-divide.patch
> >> +git-dvb-drivers-media-video-et61x251-et61x251_corec-fix-warnings.patch
> >>
> >> Fix git-dvb
> >>
> >> +media-video-usbvision-add-mutex_unlock-to-error-paths.patch
> >> +media-video-usbvision-add-mutex_unlock-to-error-paths-fix.patch
> >> +media-video-usbvision-remove-ctrlurblock.patch
> >>
> >> DVB things
> >>
> >> +jdelvare-i2c-i2c-deprecate-video-bus-drivers.patch
> >> +jdelvare-i2c-i2c-drop-redundant-client-usage-count.patch
> >> +jdelvare-i2c-i2c-change-refcounting-prototypes.patch
> >> +jdelvare-i2c-i2c-remove-redundant-i2c_adapter-list.patch
> >> +jdelvare-i2c-i2c-remove-redundant-i2c_driver-list.patch
> >> +jdelvare-i2c-i2c-core-rename-lock.patch
> >>
> >> I2C tree updates
> >>
> >> +i2c-fix-drivers-media-video-bt866c.patch
> >>
> >> Fix it.
> >>
> >> +applesmc-sensors-set-for-macbook2-try-2.patch
> >>
> >> Update applesmc-sensors-set-for-macbook2.patch
> >>
> >> +gfs2-avoid-64-bit-divide.patch
> >>
> >> Fix git-gfs2-nmw.patch
> >>
> >> +ia64-ia32-nopage.patch
> >>
> >> ia64 cleanup
> >>
> >> +ieee1394-nopage.patch
> >>
> >> firewire cleanup
> >>
> >> +ib-nopage.patch
> >>
> >> Infiniband cleanup
> >>
> >> +fujitsu-application-panel-led-value.patch
> >>
> >> apanel update
> >>
> >> +ads7846-stop-updating-dev-powerpower_state.patch
> >> +wistron_btns-add-support-for-x86_64-systems.patch
> >> +wistron_btns-add-support-for-fujitsu-siemens-amilo-pro-edition-v3505.patch
> >> +hp6xx-hp7xx-clean-up-drivers-input-keyboardtouchscreen-kconfigs.patch
> >>
> >> input things
> >>
> >> +pata_legacy-restructure-and-revamp.patch
> >>
> >> pata upate
> >>
> >> +ide-mm-ide-dma-reporting-and-validity-checking-fixes-take-3.patch
> >> +ide-mm-ide-cd-remove-dead-post_transform_command.patch
> >> +ide-mm-pdc202xx_new-fix-promise-tx4-support.patch
> >> +ide-mm-hpt366-fix-hpt37x-pio-mode-timings-take-2.patch
> >> +ide-mm-hpt366-change-timing-register-masks.patch
> >> +ide-mm-hpt366-kill-set_dma_mode-method-wrapper.patch
> >> +ide-mm-ide-remove-dead-code-from-__ide_dma_test_irq.patch
> >> +ide-mm-ide-remove-stale-changelog-from-ide-disk-c.patch
> >> +ide-mm-ide-remove-stale-changelog-from-ide-probe-c.patch
> >> +ide-mm-ide-add-ide_busy_sleep-helper.patch
> >> +ide-mm-ide-remove-broken-disk-byte-swapping-support.patch
> >> +ide-mm-cmd64x-remove-proc-ide-cmd64x.patch
> >>
> >> IDE tree updates
> >>
> >> +md-balance-braces-in-raid5-debug-code.patch
> >>
> >> Fix git-md-accel.patch
> >>
> >> +mips-fix-makefile-borkage.patch
> >>
> >> MIPS fix
> >>
> >> +ipsec-fix-reversed-icmp6-policy-check.patch
> >> +ipsec-do-not-let-packets-pass-when-icmp-flag-is-off.patch
> >> +git-net-vs-git-lblnet.patch
> >> +git-net-fix-drivers-net-ns83820c-build.patch
> >> +updates-to-nfsroot-documentation-take-3.patch
> >> +net-use-mutex_is_locked-for-assert_rtnl.patch
> >> +tipc-fix-semaphore-handling.patch
> >> +ppp-synchronous-tty-convert-dead_sem-to-completion.patch
> >>
> >> net things
> >>
> >> +e1000e-make-e1000e-default-to-the-same-kconfig-setting-as-e1000.patch
> >>
> >> Make e1000e config sane
> >>
> >> +plip-driver-convert-killed_timer_sem-to-completion.patch
> >>
> >> plip cleanup
> >>
> >> +backlight-omap1-backlight-driver.patch
> >> +backlight-omap1-backlight-driver-fix.patch
> >>
> >> backlight driver
> >>
> >> +pcmcia-include-bad-cis-filename-in-error-message.patch
> >>
> >> pcmcia niceness
> >>
> >> +pci-disable-decoding-during-sizing-of-bars.patch
> >>
> >> PCI fix
> >>
> >> +pcie-aer-dont-check-_osc-when-acpi-is-disabled.patch
> >> +pci-dont-load-acpi_php-when-acpi-is-disabled.patch
> >> +pci-dont-load-acpi_php-when-acpi-is-disabled-fix.patch
> >>
> >> PCIE and PCI fixes
> >>
> >> +kernel-time-make-tick_do_broadcast-static.patch
> >>
> >> cleanup
> >>
> >> -git-scsi-misc-fixup.patch
> >>
> >> Unneeded
> >>
> >> +git-scsi-misc-fix-build-in-drivers-scsi-scsi_tgt_libc.patch
> >>
> >> Fix git-scsi-misc
> >>
> >> +sg-nopage.patch
> >> +3w-raid-drivers-memset-not-needed-in-probe.patch
> >> +hptiop-add-more-adapter-models-and-other-fixes.patch
> >> +hptiop-add-more-adapter-models-and-other-fixes-update.patch
> >> +hptiop-add-more-adapter-models-and-other-fixes-fix-2.patch
> >> +drivers-scsi-iprc-use-list_head-instead-of-list_head_init.patch
> >>
> >> scsi things
> >>
> >> -bidi-support-sr-sd-remove-dead-code.patch
> >> -bidi-support-tgt-use-scsi_init_io-instead-of-scsi_alloc_sgtable.patch
> >> -bidi-support-scsi_data_buffer.patch
> >> -scsi-pending-arm-convert-to-accessors.patch
> >> -scsi-bidi-support.patch
> >>
> >> scsi changes killed this
> >>
> >> +usb-mon-nopage.patch
> >>
> >> USB cleanup
> >>
> >> +9p-util-fix-semaphore-handling.patch
> >>
> >> 9p fix
> >>
> >> +watchdog-use-sgi_has_indydog-for-indydog-depends.patch
> >>
> >> watchdog cleanup
> >>
> >> +wireless-libertas-dont-cast-a-pointer-to-pointer-of-list_head.patch
> >>
> >> wireless cleanup
> >>
> >> -revert-git-kvm-changes-in-arch-x86-kconfig.patch
> >> -revert-revert-git-kvm-changes-in-arch-x86-kconfig.patch
> >>
> >> Unneeded
> >>
> >> +git-x86-fix-allnoconfig-build.patch
> >>
> >> x86 fix
> >>
> >> +mcheck-mce_64-mce_read_sem-to-mutex.patch
> >>
> >> x86 cleanup
> >>
> >> +x86_64-efi-runtime-service-support-efi-basic-runtime-service-support-calling-convention-fix.patch
> >>
> >> Fix x86_64-efi-runtime-service-support-efi-basic-runtime-service-support-fixes.patch
> >>
> >> +x86-boot-use-e820-memory-map-on-efi-32-platform.patch
> >>
> >> x86 fix
> >>
> >> +iommu-sg-add-iommu-helper-functions-for-the-free-area-management.patch
> >> +iommu-sg-powerpc-convert-iommu-to-use-the-iommu-helper.patch
> >> +iommu-sg-powerpc-remove-dma-4gb-boundary-protection.patch
> >> +iommu-sg-x86-convert-calgary-iommu-to-use-the-iommu-helper.patch
> >> +iommu-sg-x86-convert-gart-iommu-to-use-the-iommu-helper.patch
> >> +iommu-sg-kill-__clear_bit_string-and-find_next_zero_string.patch
> >>
> >> More iommu work
> >>
> >> +drivers-cpufreq-cpufreq_statsc-section-fix.patch
> >> +bonding-locking-fix.patch
> >> +bridge-assign-random-address.patch
> >> +nfs-fix-an-oops-in-nfs-unmount.patch
> >> +acpi-sbs-reset-alarm-bit.patch
> >> +acpi-sbs-ignore-alarms-coming-from-unknown-devices.patch
> >> +acpi-sbs-return-rate-in-mw-if-capacity-in-mwh.patch
> >> +usb-use-irqf_disabled-for-hcd-interrupt-handlers.patch
> >> +usb-at91_udc-correct-hanging-while-disconnecting-usb-cable.patch
> >> +iwlwifi3945-4965-fix-rate-control-algo-reference-leak.patch
> >> +iwlwifi3945-4965-fix-rate-control-algo-reference-leak-fix.patch
> >> +mm-sparsec-check-the-return-value-of-sparse_index_alloc.patch
> >> +mm-sparsec-improve-the-error-handling-for-sparse_add_one_section.patch
> >> +mm-sparsec-improve-the-error-handling-for-sparse_add_one_section-fix.patch
> >> +pktcdvd-add-kobject_put-when-kobject-register-fails.patch
> >> +libertas-select-wireless_ext.patch
> >> +bcm43xx_debugfs-sscanf-fix.patch
> >> +apm_eventinfo_t-are-userspace-types.patch
> >> +drivers-macintosh-via-pmuc-added-a-missing-iounmap.patch
> >>
> >> More 2.6.24 queue
> >>
> >> +slub-optimise-the-clearing-of-__gfp_zero.patch
> >>
> >> Slub speedup
> >>
> >> +mm-special-mapping-nopage.patch
> >> +remove-unused-arguments-in-zone_init_free_lists.patch
> >>
> >> MM things
> >>
> >> +smack-getpeercred_stream-fix-for-so_peersec-and-tcp.patch
> >>
> >> smack update
> >>
> >> +agp-alpha-nopage.patch
> >> +alpha-fix-warning-by-fixing-flush_tlb_kernel_range.patch
> >>
> >> alpha stuff
> >>
> >> +arch-cris-added-a-missing-iounmap.patch
> >>
> >> cris fix
> >>
> >> +uml-remove-duplicate-config-symbol-and-unused-file-and-variables.patch
> >> +uml-fix-mconsole-stop.patch
> >> +uml-miscellaneous-code-cleanups.patch
> >> +uml-style-fixes-in-filec.patch
> >> +uml-64-bit-tlb-fixes.patch
> >> +uml-customize-tlbh.patch
> >> +uml-runtime-detection-of-host-vmsplit-on-i386.patch
> >> +uml-eliminate-setjmp_wrapper.patch
> >> +uml-install-panic-notifier-earlier.patch
> >> +uml-use-barrier-instead-of-mb.patch
> >> +uml-tidy-helper-code.patch
> >> +uml-dont-kill-pid-0.patch
> >> +uml-get-rid-of-syscall-counters.patch
> >> +uml-dont-allow-processes-to-call-into-stub.patch
> >> +uml-move-sig_handler_common_skas.patch
> >> +uml-clean-up-sig_handler_common_skas.patch
> >>
> >> UML updates
> >>
> >> +get-rid-of-nr_open-and-introduce-a-sysctl_nr_open-fix.patch
> >>
> >> Fix get-rid-of-nr_open-and-introduce-a-sysctl_nr_open.patch
> >>
> >> +dio-fix-kernel-doc-notation.patch
> >> +relay-nopage.patch
> >> +uio-nopage.patch
> >> +deprecate-smbfs-in-favour-of-cifs.patch
> >> +drivers-char-use-list_head-instead-of-list_head_init.patch
> >> +remove-one-useless-extern-declaration.patch
> >> +quota-improve-inode-list-scanning-in-add_dquot_ref.patch
> >> +quota-improve-inode-list-scanning-in-add_dquot_ref-fix.patch
> >> +rcu-move-three-variables-to-__read_mostly-to-save-space.patch
> >> +add-arch_ptrace_stop.patch
> >> +tty-enable-the-echoing-of-c-in-the-n_tty-discipline.patch
> >> +tty-enable-the-echoing-of-c-in-the-n_tty-discipline-checkpatch-fixes.patch
> >> +docs-kernel-locking-convert-semaphore-references.patch
> >> +virtio_net-remove-double-ether_setup.patch
> >> +drivers-char-ipmi-ipmi_msghandlerc-use-list_head-instead-of-list_head_init.patch
> >> +fs-reiserfs-xattrc-use-list_head-instead-of-list_head_init.patch
> >> +stopmachine-semaphore-to-mutex.patch
> >> +stopmachine-semaphore-to-mutex-fix.patch
> >> +amiga-serial-driver-port_write_mutex-fixup.patch
> >> +ext2-xip-check-fix.patch
> >> +parport-add-support-for-the-quatech-sppxp-100-parallel-port-pci-expresscard.patch
> >> +parport-add-support-for-the-quatech-sppxp-100-parallel-port-pci-expresscard-fix.patch
> >> +parport_serial-netmos-9855-fix.patch
> >> +partition-use-default_sgi_partition-for-sgi_partion-default.patch
> >>
> >> Misc
> >>
> >> +atmel_spi-chain-dma-transfers-update.patch
> >>
> >> Fix atmel_spi-chain-dma-transfers.patch
> >>
> >> +create-arch-kconfig.patch
> >> +add-have_oprofile.patch
> >> +add-have_kprobes.patch
> >> +move-kconfiginstrumentation-to-arch-kconfig-and-init-kconfig.patch
> >>
> >> Fiddle with Kconfig
> >>
> >> -move-kprobes-examples-to-samples-resend.patch
> >> -move-kprobes-examples-to-samples-resend-checkpatch-fixes.patch
> >> -move-kprobes-examples-to-samples-resend-vs-git-x86.patch
> >>
> >> These need updating
> >>
> >> +ecryptfs-make-show_options-reflect-actual-mount-options.patch
> >> +ecryptfs-make-show_options-reflect-actual-mount-options-fix.patch
> >>
> >> ecryptfs cleanups/fixes
> >>
> >> +rtc-add-support-for-the-s-35390a-rtc-chip.patch
> >> +rtc-add-support-for-the-s-35390a-rtc-chip-fix.patch
> >>
> >> RTC update
> >>
> >> +fb-defio-nopage.patch
> >> +atmel_lcdfb-validate-display-timings.patch
> >> +vgacon-fix-sparse-warning-about-shadowing-i-symbol.patch
> >> +fbcon-fix-sparse-warning-about-shadowing-p-symbol.patch
> >> +fbcon-fix-sparse-warning-about-shadowing-rotate-symbol.patch
> >> +logo-move-declarations-of-logos-to-linux_logoh.patch
> >> +logo-move-declarations-of-logos-to-linux_logoh-fix.patch
> >>
> >> fbdev things
> >>
> >> +md-raid6-fix-mktablec.patch
> >> +md-raid6-clean-up-the-style-of-raid6test-testc.patch
> >> +md-update-md-bitmap-during-resync.patch
> >> +md-update-md-bitmap-during-resync-fix.patch
> >>
> >> RAID updates
> >>
> >> +pnp-do-not-stop-start-devices-in-suspend-resume-path.patch
> >>
> >> PNP fix
> >>
> >> -pnp-request-ioport-and-iomem-resources-used-by-active-devices.patch
> >>
> >> Dropped for now.
> >>
> >> +ext-fix-comment-for-nonexistent-variable.patch
> >> +ext-use-ext_get_group_desc.patch
> >> +ext-remove-unused-argument-for-ext_find_goal.patch
> >> +ext-cleanup-ext_bg_num_gdb.patch
> >>
> >> ext2/3/4 cleanups
> >>
> >> +per-zone-and-reclaim-enhancements-for-memory-controller-take-3-modifies-vmscanc-for-isolate-globa-cgroup-lru-activity-fix-accounting-in-vmscanc-for-memory-controller.patch
> >> +update-documentation-controller-memorytxt.patch
> >>
> >> memory controller updates
> >>
> >> +drivers-dma-iop-admac-use-list_head-instead-of-list_head_init.patch
> >>
> >> DMS driver cleanup
> >>
> >> +proc-seqfile-convert-proc_pid_status-to-properly-handle-pid-namespaces-fix-2.patch
> >> +proc-seqfile-convert-proc_pid_status-to-properly-handle-pid-namespaces-fix-3.patch
> >>
> >> Fix
> >> proc-seqfile-convert-proc_pid_status-to-properly-handle-pid-namespaces.patch
> >> even more
> >>
> >> +fix-group-stop-with-exit-race.patch
> >> +sys_setsid-remove-now-unneeded-session-=-1-check.patch
> >> +move-the-related-code-from-exit_notify-to-exit_signals.patch
> >> +pid-sys_wait-fixes-v2.patch
> >> +pid-sys_wait-fixes-v2-checkpatch-fixes.patch
> >> +pid-extend-fix-pid_vnr.patch
> >> +sys_getsid-dont-use-nsproxy-directly.patch
> >> +pid-fix-mips-irix-emulation-pid-usage.patch
> >> +pid-fix-solaris_procids.patch
> >> +uglify-kill_pid_info-to-fix-kill-vs-exec-race.patch
> >> +uglify-while_each_pid_task-to-make-sure-we-dont-count-the-execing-pricess-twice.patch
> >> +itimer_real-convert-to-use-struct-pid.patch
> >>
> >> Core kernel updates
> >>
> >> +rd-support-xip.patch
> >>
> >> SUpport XIP in rd.c
> >>
> >> -cramfs-make-cramfs-little-endian-only.patch
> >> -cramfs-make-cramfs-little-endian-only-update.patch
> >> -cramfs-make-cramfs-little-endian-only-fix.patch
> >>
> >> Dropped
> >>
> >>
> >> 5041 commits in 1616 patch files
> >>
> >> All patches:
> >>
> >> ftp://ftp.kernel.org/pub/linux/kernel/people/akpm/patches/2.6/2.6.24-rc5/2.6.24-rc5-mm1/patch-list
> >>
> >>
> >> --
> >> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> >> the body of a message to majordomo@vger.kernel.org
> >> More majordomo info at http://vger.kernel.org/majordomo-info.html
> >> Please read the FAQ at http://www.tux.org/lkml/
> >>
> >
>
>
> --
> B e n j a m i n T h e r y - BULL/DT/Open Software R&D
>
> http://www.bull.com
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* Re: [PATCH 2.6.25] [IPV6] Always pass a valid nl_info to inet6_rt_notify.
From: David Miller @ 2007-12-13 17:45 UTC (permalink / raw)
To: den; +Cc: containers, devel, netdev, dlezcano
In-Reply-To: <20071213135854.GA9691@iris.sw.ru>
From: "Denis V. Lunev" <den@openvz.org>
Date: Thu, 13 Dec 2007 16:58:54 +0300
> [IPV6] Always pass a valid nl_info to inet6_rt_notify.
>
> This makes the code in the inet6_rt_notify more straightforward and provides
> groud for namespace passing.
>
> Signed-off-by: Denis V. Lunev <den@openvz.org>
Applied, thanks!
^ permalink raw reply
* Re: 2.6.24-rc4-mm1 - BUG in tcp_fragment
From: Cedric Le Goater @ 2007-12-13 17:45 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-kernel, Netdev, David Miller, Ilpo Järvinen
In-Reply-To: <20071204211701.994dfce6.akpm@linux-foundation.org>
Andrew Morton wrote:
> Temporarily at
>
> http://userweb.kernel.org/~akpm/2.6.24-rc4-mm1/
>
> Will appear later at
>
> ftp://ftp.kernel.org/pub/linux/kernel/people/akpm/patches/2.6/2.6.24-rc4/2.6.24-rc4-mm1/
I got this one while compiling on NFS.
C.
kernel BUG at /home/legoater/linux/2.6.24-rc4-mm1/include/net/tcp.h:1480!
invalid opcode: 0000 [1] SMP
last sysfs file: /sys/devices/pci0000:00/0000:00:1e.0/0000:01:01.0/local_cpus
CPU 1
Modules linked in: autofs4 nfs lockd sunrpc tg3 sg joydev ext3 jbd ehci_hcd ohci_hcd uhci_hcd
Pid: 0, comm: swapper Not tainted 2.6.24-rc4-mm1 #3
RIP: 0010:[<ffffffff80418d93>] [<ffffffff80418d93>] tcp_fragment+0x5ee/0x6f7
RSP: 0018:ffff810147c9f9e0 EFLAGS: 00010217
RAX: 000000001526c311 RBX: ffff8100c2ce1d00 RCX: ffff810143cc6aa0
RDX: 0000000000000001 RSI: ffff810102b37b00 RDI: ffff810102b37b50
RBP: ffff810147c9fa50 R08: 000000000000004a R09: 0000000000000001
R10: 0000000000000b50 R11: 0000000000000001 R12: ffff81013a575700
R13: 0000000000000000 R14: ffff810143cc6400 R15: ffff81013a575750
FS: 0000000000000000(0000) GS:ffff810147c57140(0000) knlGS:0000000000000000
CS: 0010 DS: 0018 ES: 0018 CR0: 000000008005003b
CR2: 00002ad5d294b000 CR3: 00000000bd11b000 CR4: 00000000000006e0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
Process swapper (pid: 0, threadinfo ffff810147c98000, task ffff810147c89040)
Stack: ffff810147c9fa00 ffffffff00000000 000005a843cc6400 ffff810143cc6400
ffff810147c9fa70 ffff8100c2ce1d50 ffff810143cc6590 ffff810143cc6aa0
1526542100000000 ffff810143cc6400 ffff810143cc6400 ffff81013a575700
Call Trace:
<IRQ> [<ffffffff804190c7>] tcp_retransmit_skb+0xd6/0x713
[<ffffffff804197d4>] tcp_xmit_retransmit_queue+0xd0/0x330
[<ffffffff8041209b>] tcp_fastretrans_alert+0xb92/0xbf2
[<ffffffff80413f30>] tcp_ack+0xdf3/0xfbe
[<ffffffff80417295>] tcp_rcv_established+0x66a/0x76d
[<ffffffff8041d285>] tcp_v4_do_rcv+0x37/0x3aa
[<ffffffff8041fb73>] tcp_v4_rcv+0x9a9/0xa76
[<ffffffff80402e4e>] ip_local_deliver_finish+0x161/0x23c
[<ffffffff80403363>] ip_local_deliver+0x72/0x77
[<ffffffff80402ca9>] ip_rcv_finish+0x371/0x3b5
[<ffffffff804032bd>] ip_rcv+0x292/0x2c6
[<ffffffff803e3dcc>] netif_receive_skb+0x267/0x340
[<ffffffff8806eff4>] :tg3:tg3_poll+0x5d2/0x89e
[<ffffffff803e639d>] net_rx_action+0xd5/0x1ad
[<ffffffff8023b605>] __do_softirq+0x5f/0xe3
[<ffffffff8020c86c>] call_softirq+0x1c/0x28
[<ffffffff8020e739>] do_softirq+0x39/0x9f
[<ffffffff8023b5a4>] irq_exit+0x4e/0x50
[<ffffffff8020e880>] do_IRQ+0xb7/0xd7
[<ffffffff8020a803>] mwait_idle+0x0/0x55
[<ffffffff8020bb66>] ret_from_intr+0x0/0xf
<EOI> [<ffffffff8024d623>] __atomic_notifier_call_chain+0x20/0x83
[<ffffffff8020a84b>] mwait_idle+0x48/0x55
[<ffffffff80209e79>] enter_idle+0x22/0x24
[<ffffffff8020a793>] cpu_idle+0xa1/0xc5
[<ffffffff8021dfd5>] start_secondary+0x3b9/0x3c5
Code: 0f 0b eb fe 48 85 f6 74 08 8b 46 6c 3b 41 68 75 55 48 8d 41
RIP [<ffffffff80418d93>] tcp_fragment+0x5ee/0x6f7
RSP <ffff810147c9f9e0>
Kernel panic - not syncing: Aiee, killing interrupt handler!
^ permalink raw reply
* Re: [PATCHES 0/12]: DCCP patches for 2.6.25
From: David Miller @ 2007-12-13 17:43 UTC (permalink / raw)
To: acme; +Cc: netdev, dccp
In-Reply-To: <1197558365-31134-1-git-send-email-acme@redhat.com>
From: Arnaldo Carvalho de Melo <acme@redhat.com>
Date: Thu, 13 Dec 2007 13:05:53 -0200
> Please consider pulling from:
>
> master.kernel.org:/pub/scm/linux/kernel/git/acme/net-2.6.25
Looks good, pulled and pushed back out to net-2.6.25
Thanks!
^ permalink raw reply
* tcp_sacktag_one() WARNING (was Re: 2.6.24-rc4-mm1)
From: Cedric Le Goater @ 2007-12-13 17:38 UTC (permalink / raw)
To: Ilpo Järvinen
Cc: Andrew Morton, Reuben Farrelly, David Miller, LKML,
Linux Netdev List, Auke Kok
In-Reply-To: <476034B5.80106@fr.ibm.com>
Cedric Le Goater wrote:
> Ilpo Järvinen wrote:
>> On Wed, 5 Dec 2007, Andrew Morton wrote:
>>
>>> On Thu, 06 Dec 2007 17:59:37 +1100 Reuben Farrelly <reuben-linuxkernel@reub.net> wrote:
>>>
>>>> This non fatal oops which I have just noticed may be related to this change then
>>>> - certainly looks networking related.
>>> yep, but it isn't e1000. It's core TCP.
>>>
>>>> WARNING: at net/ipv4/tcp_input.c:2518 tcp_fastretrans_alert()
>>>> Pid: 0, comm: swapper Not tainted 2.6.24-rc4-mm1 #1
>>> Ilpo, Reuben's kernel is talking to you ;)
>> ...Please try the patch below. Andrew, this probably fixes your problem
>> (the packets <= tp->packets_out) as well.
>
> nah. I got the WARNINGs again with this patch.
I got this new one on a 2.6.24-rc5-mm1. It looked similar ?
C.
WARNING: at /home/legoater/linux/2.6.24-rc5-mm1/net/ipv4/tcp_input.c:1280 tcp_sacktag_one()
Pid: 0, comm: swapper Not tainted 2.6.24-rc5-mm1 #1
Call Trace:
<IRQ> [<ffffffff80410e0e>] tcp_sacktag_walk+0x2bc/0x62a
[<ffffffff80411711>] tcp_sacktag_write_queue+0x595/0xa7c
[<ffffffff8028ce66>] kfree+0xd4/0xe0
[<ffffffff80411e9f>] tcp_ack+0x2a7/0xfc7
[<ffffffff80252ca1>] mark_held_locks+0x47/0x6a
[<ffffffff80252e5c>] trace_hardirqs_on+0xfe/0x139
[<ffffffff80415d59>] tcp_rcv_established+0x66a/0x76d
[<ffffffff8041bd35>] tcp_v4_do_rcv+0x37/0x3aa
[<ffffffff8041e623>] tcp_v4_rcv+0x9a9/0xa76
[<ffffffff80401832>] ip_local_deliver_finish+0x161/0x23c
[<ffffffff80401d47>] ip_local_deliver+0x72/0x77
[<ffffffff8040168d>] ip_rcv_finish+0x371/0x3b5
[<ffffffff80401ca1>] ip_rcv+0x292/0x2c6
[<ffffffff803e2aae>] netif_receive_skb+0x267/0x340
[<ffffffff8806eff4>] :tg3:tg3_poll+0x5d2/0x89e
[<ffffffff803e505c>] net_rx_action+0xd5/0x1ad
[<ffffffff8023b0b9>] __do_softirq+0x5f/0xe3
[<ffffffff8020c8ec>] call_softirq+0x1c/0x28
[<ffffffff8020e7b9>] do_softirq+0x39/0x9f
[<ffffffff8023b058>] irq_exit+0x4e/0x50
[<ffffffff8020e900>] do_IRQ+0xb7/0xd7
[<ffffffff8020a892>] mwait_idle+0x0/0x52
[<ffffffff8020bbe6>] ret_from_intr+0x0/0xf
<EOI> [<ffffffff8024d0cb>] __atomic_notifier_call_chain+0x20/0x83
[<ffffffff8020a8da>] mwait_idle+0x48/0x52
[<ffffffff80209e79>] enter_idle+0x22/0x24
[<ffffffff8020a822>] cpu_idle+0xa1/0xc5
[<ffffffff8021e755>] start_secondary+0x3b9/0x3c5
^ permalink raw reply
* [PATCH 1/2] tulip: napi full quantum bug
From: Stephen Hemminger @ 2007-12-13 17:35 UTC (permalink / raw)
To: kristjan, David S. Miller, Jeff Garzik; +Cc: netdev
In-Reply-To: <1dd3c7c0712080344q414fe7c3w32d7ca6d900a52b5@mail.gmail.com>
This should fix the kernel warn/oops reported while routing.
The tulip driver has a fencepost bug with new NAPI in 2.6.24
It has an off by one bug if a full quantum is reached.
Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>
--- a/drivers/net/tulip/interrupt.c 2007-12-13 09:20:27.000000000 -0800
+++ b/drivers/net/tulip/interrupt.c 2007-12-13 09:23:34.000000000 -0800
@@ -151,7 +151,8 @@ int tulip_poll(struct napi_struct *napi,
if (tulip_debug > 5)
printk(KERN_DEBUG "%s: In tulip_rx(), entry %d %8.8x.\n",
dev->name, entry, status);
- if (work_done++ >= budget)
+
+ if (++work_done >= budget)
goto not_done;
if ((status & 0x38008300) != 0x0300) {
^ permalink raw reply
* [PATCH 2/2] tulip: hardware mitigation simplify
From: Stephen Hemminger @ 2007-12-13 17:35 UTC (permalink / raw)
To: David S. Miller, Jeff Garzik; +Cc: netdev, kristjan
The hardware mitigation in tulip can be simpified.
1. The budget with new NAPI will always be less than RX_RING_SIZE
because RX_RING_SIZE is 128 and weight is 16.
2. The received counter is redundunt, just use the work_done value.
3. Only one value is used from the mit_table[]
Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>
---
This can wait for 2.6.25
--- a/drivers/net/tulip/interrupt.c 2007-12-13 09:26:35.000000000 -0800
+++ b/drivers/net/tulip/interrupt.c 2007-12-13 09:27:29.000000000 -0800
@@ -21,45 +21,6 @@
int tulip_rx_copybreak;
unsigned int tulip_max_interrupt_work;
-#ifdef CONFIG_TULIP_NAPI_HW_MITIGATION
-#define MIT_SIZE 15
-#define MIT_TABLE 15 /* We use 0 or max */
-
-static unsigned int mit_table[MIT_SIZE+1] =
-{
- /* CRS11 21143 hardware Mitigation Control Interrupt
- We use only RX mitigation we other techniques for
- TX intr. mitigation.
-
- 31 Cycle Size (timer control)
- 30:27 TX timer in 16 * Cycle size
- 26:24 TX No pkts before Int.
- 23:20 RX timer in Cycle size
- 19:17 RX No pkts before Int.
- 16 Continues Mode (CM)
- */
-
- 0x0, /* IM disabled */
- 0x80150000, /* RX time = 1, RX pkts = 2, CM = 1 */
- 0x80150000,
- 0x80270000,
- 0x80370000,
- 0x80490000,
- 0x80590000,
- 0x80690000,
- 0x807B0000,
- 0x808B0000,
- 0x809D0000,
- 0x80AD0000,
- 0x80BD0000,
- 0x80CF0000,
- 0x80DF0000,
-// 0x80FF0000 /* RX time = 16, RX pkts = 7, CM = 1 */
- 0x80F10000 /* RX time = 16, RX pkts = 0, CM = 1 */
-};
-#endif
-
-
int tulip_refill_rx(struct net_device *dev)
{
struct tulip_private *tp = netdev_priv(dev);
@@ -113,21 +74,10 @@ int tulip_poll(struct napi_struct *napi,
struct net_device *dev = tp->dev;
int entry = tp->cur_rx % RX_RING_SIZE;
int work_done = 0;
-#ifdef CONFIG_TULIP_NAPI_HW_MITIGATION
- int received = 0;
-#endif
if (!netif_running(dev))
goto done;
-#ifdef CONFIG_TULIP_NAPI_HW_MITIGATION
-
-/* that one buffer is needed for mit activation; or might be a
- bug in the ring buffer code; check later -- JHS*/
-
- if (budget >=RX_RING_SIZE) budget--;
-#endif
-
if (tulip_debug > 4)
printk(KERN_DEBUG " In tulip_rx(), entry %d %8.8x.\n", entry,
tp->rx_ring[entry].status);
@@ -239,9 +189,6 @@ int tulip_poll(struct napi_struct *napi,
tp->stats.rx_packets++;
tp->stats.rx_bytes += pkt_len;
}
-#ifdef CONFIG_TULIP_NAPI_HW_MITIGATION
- received++;
-#endif
entry = (++tp->cur_rx) % RX_RING_SIZE;
if (tp->cur_rx - tp->dirty_rx > RX_RING_SIZE/4)
@@ -279,14 +226,14 @@ done:
ON: More then 1 pkt received (per intr.) OR we are dropping
OFF: Only 1 pkt received
- Note. We only use min and max (0, 15) settings from mit_table */
-
+ Note. We only use max or min values for mit */
if( tp->flags & HAS_INTR_MITIGATION) {
- if( received > 1 ) {
+ if( work_done > 1 ) {
if( ! tp->mit_on ) {
tp->mit_on = 1;
- iowrite32(mit_table[MIT_TABLE], tp->base_addr + CSR11);
+ /* RX time = 16, RX pkts = 0, CM = 1 */
+ iowrite32(0x80F10000, tp->base_addr + CSR11);
}
}
else {
^ permalink raw reply
* [PATCH] e1000: remove no longer used code for pci read/write cfg
From: Auke Kok @ 2007-12-13 17:36 UTC (permalink / raw)
To: jeff; +Cc: netdev, bunk
From: Adrian Bunk <bunk@stusta.de>
Signed-off-by: Adrian Bunk <bunk@stusta.de>
Signed-off-by: Auke Kok <auke-jan.h.kok@intel.com>
---
drivers/net/e1000/e1000_hw.h | 2 --
drivers/net/e1000/e1000_main.c | 16 ----------------
2 files changed, 0 insertions(+), 18 deletions(-)
diff --git a/drivers/net/e1000/e1000_hw.h b/drivers/net/e1000/e1000_hw.h
index a2a86c5..930554b 100644
--- a/drivers/net/e1000/e1000_hw.h
+++ b/drivers/net/e1000/e1000_hw.h
@@ -421,8 +421,6 @@ void e1000_tbi_adjust_stats(struct e1000_hw *hw, struct e1000_hw_stats *stats, u
void e1000_get_bus_info(struct e1000_hw *hw);
void e1000_pci_set_mwi(struct e1000_hw *hw);
void e1000_pci_clear_mwi(struct e1000_hw *hw);
-void e1000_read_pci_cfg(struct e1000_hw *hw, uint32_t reg, uint16_t * value);
-void e1000_write_pci_cfg(struct e1000_hw *hw, uint32_t reg, uint16_t * value);
int32_t e1000_read_pcie_cap_reg(struct e1000_hw *hw, uint32_t reg, uint16_t *value);
void e1000_pcix_set_mmrbc(struct e1000_hw *hw, int mmrbc);
int e1000_pcix_get_mmrbc(struct e1000_hw *hw);
diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c
index 724f067..efd8c2d 100644
--- a/drivers/net/e1000/e1000_main.c
+++ b/drivers/net/e1000/e1000_main.c
@@ -4866,22 +4866,6 @@ e1000_pci_clear_mwi(struct e1000_hw *hw)
pci_clear_mwi(adapter->pdev);
}
-void
-e1000_read_pci_cfg(struct e1000_hw *hw, uint32_t reg, uint16_t *value)
-{
- struct e1000_adapter *adapter = hw->back;
-
- pci_read_config_word(adapter->pdev, reg, value);
-}
-
-void
-e1000_write_pci_cfg(struct e1000_hw *hw, uint32_t reg, uint16_t *value)
-{
- struct e1000_adapter *adapter = hw->back;
-
- pci_write_config_word(adapter->pdev, reg, *value);
-}
-
int
e1000_pcix_get_mmrbc(struct e1000_hw *hw)
{
^ permalink raw reply related
* Re: [IPSEC]: Fix zero return value in xfrm_lookup on error
From: David Miller @ 2007-12-13 17:31 UTC (permalink / raw)
To: herbert; +Cc: netdev
In-Reply-To: <20071213164448.GA7310@gondor.apana.org.au>
From: Herbert Xu <herbert@gondor.apana.org.au>
Date: Fri, 14 Dec 2007 00:44:48 +0800
> [IPSEC]: Fix zero return value in xfrm_lookup on error
>
> Further testing shows that my ICMP relookup patch can cause xfrm_lookup
> to return zero on error which isn't very nice since it leads to the caller
> dying on null pointer dereference. The bug is due to not setting err
> to ENOENT just before we leave xfrm_lookup in case of no policy.
>
> This patch moves the err setting to where it should be.
>
> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Applied, thanks.
^ permalink raw reply
* Re: kernel 2.6.23.8: KERNEL: assertion in net/ipv4/tcp_input.c
From: Wolfgang Walter @ 2007-12-13 16:51 UTC (permalink / raw)
To: Ilpo Järvinen; +Cc: Netdev
In-Reply-To: <Pine.LNX.4.64.0712030840540.26423@kivilampi-30.cs.helsinki.fi>
Hello Ilpo,
it happened again with your patch applied:
WARNING: at net/ipv4/tcp_input.c:1018 tcp_sacktag_write_queue()
Call Trace:
<IRQ> [<ffffffff80549290>] tcp_sacktag_write_queue+0x7d0/0xa60
[<ffffffff80283869>] add_partial+0x19/0x60
[<ffffffff80549ac4>] tcp_ack+0x5a4/0x1d70
[<ffffffff8054e625>] tcp_rcv_established+0x485/0x7b0
[<ffffffff80554c3d>] tcp_v4_do_rcv+0xed/0x3e0
[<ffffffff80556fe7>] tcp_v4_rcv+0x947/0x970
[<ffffffff80538c6c>] ip_local_deliver+0xac/0x290
[<ffffffff80538862>] ip_rcv+0x362/0x6c0
[<ffffffff804fc5d3>] netif_receive_skb+0x323/0x420
[<ffffffff8042ab40>] tg3_poll+0x630/0xa50
[<ffffffff804fecba>] net_rx_action+0x8a/0x140
[<ffffffff8023a269>] __do_softirq+0x69/0xe0
[<ffffffff8020d47c>] call_softirq+0x1c/0x30
[<ffffffff8020f315>] do_softirq+0x35/0x90
[<ffffffff8023a105>] irq_exit+0x55/0x60
[<ffffffff8020f3f0>] do_IRQ+0x80/0x100
[<ffffffff8020c7d1>] ret_from_intr+0x0/0xa
<EOI>
Am Montag, 3. Dezember 2007 14:34 schrieb Ilpo Järvinen:
> On Mon, 3 Dec 2007, Wolfgang Walter wrote:
> > with kernel 2.6.23.8 we saw a
> >
> > KERNEL: assertion ((int)tcp_packets_in_flight(tp) >= 0) failed at
> > net/ipv4/tcp_input.c (1292)
>
> Is this the only message? Are there any Leak printouts?
> Any tweaking done to TCP related sysctls?
net/core/somaxconn=2048
net/ipv4/tcp_syncookies=1
net/ipv4/tcp_max_syn_backlog=8192
net/ipv4/tcp_max_tw_buckets=1800000
net/ipv4/tcp_window_scaling=0
net/ipv4/tcp_timestamps=0
>
> Most likely I broke the manual synchronization for left_out in sacktag by
> skipping over it when packets_out == 0 but so far I haven't been able to
> figure out how such state could develop in the first place... Ie., I
> couldn't find a case where tcp_fastretrans_alert wouldn't be called if
> left_out was non-zero (and it did the sync_left_out after modifying
> either sacked_out or lost_out, IIRC).
>
> ...If you can reproduce it, you could try if this patch below changes
> anything (should silence the assert and trigger earlier a WARN_ON or
> two :-)). ...If this triggers, then I'm sure we can pollute TCP code
> by a larger number of more costly checks to catch it in early.
>
> This might reveal a long-standing inconsistency of left_out in some
> case I just couldn't come up with by code review. Left_out will be
> (is) anyway dropped as unnecessary in 2.6.24. In 2.6.23 sync for
> left_out occurs quite soon after that BUG_TRAP anyway so the effect
> won't be too dramatic, prior_in_flight would be once stale, won't
> lead to big problems (either missed cnwd or cwnd_cnt increment, or
> failure to do application limited check at that particular ACK).
>
> Thanks anyway for the report. ...If I figure something out here, I'll
> let you know.
>
> --
>
> diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
> index c9298a7..0c5194d 100644
> --- a/net/ipv4/tcp_input.c
> +++ b/net/ipv4/tcp_input.c
> @@ -1012,8 +1012,12 @@ tcp_sacktag_write_queue(struct sock *sk, struct
> sk_buff *ack_skb, u32 prior_snd_ if (before(TCP_SKB_CB(ack_skb)->ack_seq,
> prior_snd_una - tp->max_window)) return 0;
>
> - if (!tp->packets_out)
> + if (!tp->packets_out) {
> + WARN_ON(tp->sacked_out);
> + WARN_ON(tp->lost_out);
> + WARN_ON(tp->left_out);
> goto out;
> + }
>
> /* SACK fastpath:
> * if the only SACK change is the increase of the end_seq of
> @@ -1277,14 +1281,14 @@ tcp_sacktag_write_queue(struct sock *sk, struct
> sk_buff *ack_skb, u32 prior_snd_ }
> }
>
> +out:
> +
> tp->left_out = tp->sacked_out + tp->lost_out;
>
> if ((reord < tp->fackets_out) && icsk->icsk_ca_state != TCP_CA_Loss &&
> (!tp->frto_highmark || after(tp->snd_una, tp->frto_highmark)))
> tcp_update_reordering(sk, ((tp->fackets_out + 1) - reord), 0);
>
> -out:
> -
> #if FASTRETRANS_DEBUG > 0
> BUG_TRAP((int)tp->sacked_out >= 0);
> BUG_TRAP((int)tp->lost_out >= 0);
Regards,
--
Wolfgang Walter
Studentenwerk München
Anstalt des öffentlichen Rechts
^ permalink raw reply
* Re: [RFC] net: napi fix
From: Kok, Auke @ 2007-12-13 16:45 UTC (permalink / raw)
To: David Miller
Cc: gallatin, joonwpark81, netdev, linux-kernel, jgarzik, shemminger,
jesse.brandeburg
In-Reply-To: <20071213.061938.86541759.davem@davemloft.net>
David Miller wrote:
> From: Andrew Gallatin <gallatin@myri.com>
> Date: Thu, 13 Dec 2007 09:13:54 -0500
>
>> If the netif_running() check is indeed required to make a device break
>> out of napi polling and respond to an ifconfig down, then I think the
>> netif_running() check should be moved up into net_rx_action() to avoid
>> potential for driver complexity and bugs like the ones you found.
>
> That, or something like it, definitely sounds reasonable and much
> better than putting the check into every driver :-)
hear hear!
Auke
^ permalink raw reply
* [IPSEC]: Fix zero return value in xfrm_lookup on error
From: Herbert Xu @ 2007-12-13 16:44 UTC (permalink / raw)
To: David S. Miller, netdev
Hi Dave:
Found another silly bug in my ICMP relookup patch.
[IPSEC]: Fix zero return value in xfrm_lookup on error
Further testing shows that my ICMP relookup patch can cause xfrm_lookup
to return zero on error which isn't very nice since it leads to the caller
dying on null pointer dereference. The bug is due to not setting err
to ENOENT just before we leave xfrm_lookup in case of no policy.
This patch moves the err setting to where it should be.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
index b04d88c..d2084b1 100644
--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -1469,8 +1469,6 @@ restart:
goto dropdst;
}
- err = -ENOENT;
-
if (!policy) {
/* To accelerate a bit... */
if ((dst_orig->flags & DST_NOXFRM) ||
@@ -1492,6 +1490,7 @@ restart:
npols ++;
xfrm_nr += pols[0]->xfrm_nr;
+ err = -ENOENT;
if ((flags & XFRM_LOOKUP_ICMP) && !(policy->flags & XFRM_POLICY_ICMP))
goto error;
@@ -1657,6 +1656,7 @@ dropdst:
return err;
nopol:
+ err = -ENOENT;
if (flags & XFRM_LOOKUP_ICMP)
goto dropdst;
return 0;
Thanks,
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply related
* Re: 2.6.24-rc5-mm1
From: Borislav Petkov @ 2007-12-13 16:07 UTC (permalink / raw)
To: Benjamin Thery
Cc: Pierre Peiffer, Andrew Morton, linux-kernel, netdev, Herbert Xu
In-Reply-To: <4761494E.1050704@bull.net>
On Thu, Dec 13, 2007 at 04:01:34PM +0100, Benjamin Thery wrote:
> The problem comes from the new macro UDPX_INC_STATS_BH introduced
> by Herbert, which was a nice addition to increment the correct
> UDP MIB depending on the socket family, but unfortunately
> the use of this macro from kernel code (I mean code not compiled
> as module) requires that IPv6 is also compiled in kernel
> (CONFIG_IPv6=y) in order to have udp_stats_in6 defined at link
> time.
>
> Benjamin
>
> Pierre Peiffer wrote:
> > Hi,
> >
> > My config does not link any more:
> >
> > ...
> > CHK include/linux/compile.h
> > UPD include/linux/compile.h
> > CC init/version.o
> > LD init/built-in.o
> > LD .tmp_vmlinux1
> > net/built-in.o: In function `xs_udp_data_ready':
> > /home/peifferp/containers/kernel/linux-2.6.24-rc5-mm1/net/sunrpc/xprtsock.c:842:
> > undefined reference to `udp_stats_in6'
> > /home/peifferp/containers/kernel/linux-2.6.24-rc5-mm1/net/sunrpc/xprtsock.c:846:
> > undefined reference to `udp_stats_in6'
> > make[1]: *** [.tmp_vmlinux1] Error 1
> > make: *** [sub-make] Error 2
> >
> > After a first look, udp_stats_in6 seems to be defined in ipv6 (file
> > net/ipv6/udp.c) but I have
> >
> > CONFIG_IPV6=m
> > and
> > CONFIG_SUNRPC=y
> >
> > So, SUNRPC uses something defined in a module in my case ?
> >
> > ... looking more, this dependency seems to have been introduced by the patch
> > [UDP]: Restore missing inDatagrams increments
> > ( http://thread.gmane.org/gmane.linux.network/79716/focus=79831 )
> >
> > (I cc netdev)
> >
> > I don't know what is the right way to fix this ... ?
you might do "select IPV6" in the SUNRPC section of fs/Kconfig, however select is
evil...
--
Regards/Gruß,
Boris.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
^ permalink raw reply
* Re: [PATCH] PS3: gelic: Add wireless support for PS3
From: Dan Williams @ 2007-12-13 15:33 UTC (permalink / raw)
To: Masakazu Mokuno
Cc: linux-wireless-u79uwXL29TY76Z2rM5mHXA,
netdev-u79uwXL29TY76Z2rM5mHXA,
geoffrey.levand-mEdOJwZ7QcZBDgjK7y7TUQ, Geert Uytterhoeven
In-Reply-To: <20071213211626.BF8E.MOKUNO-DfbDroY8Xu1L9jVzuh4AOg@public.gmane.org>
On Thu, 2007-12-13 at 21:27 +0900, Masakazu Mokuno wrote:
> Hi all,
>
> PS3: gelic: Add wireless support for PS3
>
> This is the re-worked (rewritten) version wireless support driver for
> PS3. The formar one was submitted to net-dev ML in June 2007.
>
> Major differnces from the previous one are:
> - The new driver has separate ethX interface from ethernet.
> They share same one MAC address.
> - Thus we can use both ethernet and wireless simultaenously.
> - The new driver returns AP's cipher information by the common IE
> format in the scan information.
> - Cipher selection is done via the common wirelee extension way
>
> This patch depends on the patch set I submitted to netdev ML
> (http://marc.info/?l=linux-netdev&m=119754603814092)
>
> Thanks for reviewing!
Just one comment...
You'll need to emit more NULL IWAP events on association failure. For
example, gelic_wl_assoc_worker() should probably send one right before
both instances of 'goto scan_lock_out' in that function (the first where
there are no scan results, and the second where no compatible BSS can be
found). Also, gelic_wl_associate_bss() needs to send a disassociation
event in the failure case where it sets GELIC_WL_ASSOC_STAT_DISCONN.
Other than that, looks pretty good to me. You might want to run
checkpatch.pl over it before submitting again just to be sure. Thanks
for fixing the WPA IE and scan table handling!
Dan
> Signed-off-by: Masakazu Mokuno <mokuno-DfbDroY8Xu1L9jVzuh4AOg@public.gmane.org>
> ---
> drivers/net/Kconfig | 10
> drivers/net/Makefile | 3
> drivers/net/ps3_gelic_net.c | 18
> drivers/net/ps3_gelic_net.h | 6
> drivers/net/ps3_gelic_wireless.c | 2750 +++++++++++++++++++++++++++++++++++++++
> drivers/net/ps3_gelic_wireless.h | 329 ++++
> 6 files changed, 3114 insertions(+), 2 deletions(-)
>
> --- a/drivers/net/Kconfig
> +++ b/drivers/net/Kconfig
> @@ -2302,6 +2302,16 @@ config GELIC_NET
> To compile this driver as a module, choose M here: the
> module will be called ps3_gelic.
>
> +config GELIC_WIRELESS
> + bool "PS3 Wireless support"
> + depends on GELIC_NET
> + help
> + This option adds the support for the wireless feature of PS3.
> + If you have the wireless-less model of PS3 or have no plan to
> + use wireless feature, disabling this option saves memory. As
> + the driver automatically distinguishes the models, you can
> + safely enable this option even if you have a wireless-less model.
> +
> config GIANFAR
> tristate "Gianfar Ethernet"
> depends on 85xx || 83xx || PPC_86xx
> --- a/drivers/net/Makefile
> +++ b/drivers/net/Makefile
> @@ -66,7 +66,8 @@ obj-$(CONFIG_BNX2) += bnx2.o
> spidernet-y += spider_net.o spider_net_ethtool.o
> obj-$(CONFIG_SPIDER_NET) += spidernet.o sungem_phy.o
> obj-$(CONFIG_GELIC_NET) += ps3_gelic.o
> -ps3_gelic-objs += ps3_gelic_net.o
> +gelic_wireless-$(CONFIG_GELIC_WIRELESS) += ps3_gelic_wireless.o
> +ps3_gelic-objs += ps3_gelic_net.o $(gelic_wireless-y)
> obj-$(CONFIG_TC35815) += tc35815.o
> obj-$(CONFIG_SKGE) += skge.o
> obj-$(CONFIG_SKY2) += sky2.o
> --- a/drivers/net/ps3_gelic_net.c
> +++ b/drivers/net/ps3_gelic_net.c
> @@ -46,9 +46,10 @@
> #include <asm/lv1call.h>
>
> #include "ps3_gelic_net.h"
> +#include "ps3_gelic_wireless.h"
>
> #define DRV_NAME "Gelic Network Driver"
> -#define DRV_VERSION "1.1"
> +#define DRV_VERSION "2.0"
>
> MODULE_AUTHOR("SCE Inc.");
> MODULE_DESCRIPTION("Gelic Network driver");
> @@ -1122,6 +1123,12 @@ static irqreturn_t gelic_card_interrupt(
> if (status & GELIC_CARD_PORT_STATUS_CHANGED)
> gelic_card_get_ether_port_status(card, 1);
>
> +#ifdef CONFIG_GELIC_WIRELESS
> + if (status & (GELIC_CARD_WLAN_EVENT_RECEIVED |
> + GELIC_CARD_WLAN_COMMAND_COMPLETED))
> + gelic_wl_interrupt(card->netdev[GELIC_PORT_WIRELESS], status);
> +#endif
> +
> return IRQ_HANDLED;
> }
>
> @@ -1603,6 +1610,12 @@ static int ps3_gelic_driver_probe(struct
> goto fail_setup_netdev;
> }
>
> +#ifdef CONFIG_GELIC_WIRELESS
> + if (gelic_wl_driver_probe(card)) {
> + dev_dbg(&dev->core, "%s: WL init failed\n", __func__);
> + goto fail_setup_netdev;
> + }
> +#endif
> pr_debug("%s: done\n", __func__);
> return 0;
>
> @@ -1642,6 +1655,9 @@ static int ps3_gelic_driver_remove(struc
> struct net_device *netdev0;
> pr_debug("%s: called\n", __func__);
>
> +#ifdef CONFIG_GELIC_WIRELESS
> + gelic_wl_driver_remove(card);
> +#endif
> /* stop interrupt */
> gelic_card_set_irq_mask(card, 0);
>
> --- a/drivers/net/ps3_gelic_net.h
> +++ b/drivers/net/ps3_gelic_net.h
> @@ -57,6 +57,8 @@
> #define GELIC_CARD_RX_PROTECTION_ERR 0x0000000004000000L
> #define GELIC_CARD_TX_TCP_UDP_CHECKSUM_ERR 0x0000000008000000L
> #define GELIC_CARD_PORT_STATUS_CHANGED 0x0000000020000000L
> +#define GELIC_CARD_WLAN_EVENT_RECEIVED 0x0000000040000000L
> +#define GELIC_CARD_WLAN_COMMAND_COMPLETED 0x0000000080000000L
> /* INT 0 */
> #define GELIC_CARD_TX_FLAGGED_DESCR 0x0004000000000000L
> #define GELIC_CARD_RX_FLAGGED_DESCR 0x0040000000000000L
> @@ -180,6 +182,10 @@ enum gelic_lv1_net_control_code {
> GELIC_LV1_GET_ETH_PORT_STATUS = 2,
> GELIC_LV1_SET_NEGOTIATION_MODE = 3,
> GELIC_LV1_GET_VLAN_ID = 4,
> + GELIC_LV1_GET_CHANNEL = 6,
> + GELIC_LV1_POST_WLAN_CMD = 9,
> + GELIC_LV1_GET_WLAN_CMD_RESULT = 10,
> + GELIC_LV1_GET_WLAN_EVENT = 11
> };
>
> /* status returened from GET_ETH_PORT_STATUS */
> --- /dev/null
> +++ b/drivers/net/ps3_gelic_wireless.c
> @@ -0,0 +1,2750 @@
> +/*
> + * PS3 gelic network driver.
> + *
> + * Copyright (C) 2007 Sony Computer Entertainment Inc.
> + * Copyright 2007 Sony Corporation
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2
> + * as published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write to the Free Software
> + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
> + */
> +#undef DEBUG
> +
> +#include <linux/kernel.h>
> +#include <linux/module.h>
> +
> +#include <linux/etherdevice.h>
> +#include <linux/ethtool.h>
> +#include <linux/if_vlan.h>
> +
> +#include <linux/in.h>
> +#include <linux/ip.h>
> +#include <linux/tcp.h>
> +#include <linux/wireless.h>
> +#include <linux/ctype.h>
> +#include <linux/string.h>
> +#include <net/iw_handler.h>
> +#include <net/ieee80211.h>
> +
> +#include <linux/dma-mapping.h>
> +#include <net/checksum.h>
> +#include <asm/firmware.h>
> +#include <asm/ps3.h>
> +#include <asm/lv1call.h>
> +
> +#include "ps3_gelic_net.h"
> +#include "ps3_gelic_wireless.h"
> +
> +
> +static int gelic_wl_start_scan(struct gelic_wl_info *wl, int always_scan);
> +static int gelic_wl_try_associate(struct net_device *netdev);
> +
> +/*
> + * tables
> + */
> +
> +/* 802.11b/g channel to freq in MHz */
> +static const int channel_freq[] = {
> + 2412, 2417, 2422, 2427, 2432,
> + 2437, 2442, 2447, 2452, 2457,
> + 2462, 2467, 2472, 2484
> +};
> +#define NUM_CHANNELS ARRAY_SIZE(channel_freq)
> +
> +/* in bps */
> +static const int bitrate_list[] = {
> + 1000000,
> + 2000000,
> + 5500000,
> + 11000000,
> + 6000000,
> + 9000000,
> + 12000000,
> + 18000000,
> + 24000000,
> + 36000000,
> + 48000000,
> + 54000000
> +};
> +#define NUM_BITRATES ARRAY_SIZE(bitrate_list)
> +
> +/*
> + * wpa2 support requires the hypervisor version 2.0 or later
> + */
> +static inline int wpa2_capable(void)
> +{
> + return (0 <= ps3_compare_firmware_version(2, 0, 0));
> +}
> +
> +static inline int precise_ie(void)
> +{
> + return 0; /* FIXME */
> +}
> +/*
> + * post_eurus_cmd helpers
> + */
> +struct eurus_cmd_arg_info {
> + int pre_arg; /* command requres arg1, arg2 at POST COMMAND */
> + int post_arg; /* command requires arg1, arg2 at GET_RESULT */
> +};
> +
> +static const struct eurus_cmd_arg_info cmd_info[GELIC_EURUS_CMD_MAX_INDEX] = {
> + [GELIC_EURUS_CMD_SET_COMMON_CFG] = { .pre_arg = 1},
> + [GELIC_EURUS_CMD_SET_WEP_CFG] = { .pre_arg = 1},
> + [GELIC_EURUS_CMD_SET_WPA_CFG] = { .pre_arg = 1},
> + [GELIC_EURUS_CMD_GET_COMMON_CFG] = { .post_arg = 1},
> + [GELIC_EURUS_CMD_GET_WEP_CFG] = { .post_arg = 1},
> + [GELIC_EURUS_CMD_GET_WPA_CFG] = { .post_arg = 1},
> + [GELIC_EURUS_CMD_GET_RSSI_CFG] = { .post_arg = 1},
> + [GELIC_EURUS_CMD_GET_SCAN] = { .post_arg = 1},
> +};
> +
> +#ifdef DEBUG
> +static const char *cmdstr(enum gelic_eurus_command ix)
> +{
> + switch (ix) {
> + case GELIC_EURUS_CMD_ASSOC:
> + return "ASSOC";
> + case GELIC_EURUS_CMD_DISASSOC:
> + return "DISASSOC";
> + case GELIC_EURUS_CMD_START_SCAN:
> + return "SCAN";
> + case GELIC_EURUS_CMD_GET_SCAN:
> + return "GET SCAN";
> + case GELIC_EURUS_CMD_SET_COMMON_CFG:
> + return "SET_COMMON_CFG";
> + case GELIC_EURUS_CMD_GET_COMMON_CFG:
> + return "GET_COMMON_CFG";
> + case GELIC_EURUS_CMD_SET_WEP_CFG:
> + return "SET_WEP_CFG";
> + case GELIC_EURUS_CMD_GET_WEP_CFG:
> + return "GET_WEP_CFG";
> + case GELIC_EURUS_CMD_SET_WPA_CFG:
> + return "SET_WPA_CFG";
> + case GELIC_EURUS_CMD_GET_WPA_CFG:
> + return "GET_WPA_CFG";
> + case GELIC_EURUS_CMD_GET_RSSI_CFG:
> + return "GET_RSSI";
> + default:
> + break;
> + }
> + return "";
> +};
> +#else
> +static inline const char *cmdstr(enum gelic_eurus_command ix)
> +{
> + return "";
> +}
> +#endif
> +
> +/* synchronously do eurus commands */
> +static void gelic_eurus_sync_cmd_worker(struct work_struct *work)
> +{
> + struct gelic_eurus_cmd *cmd;
> + struct gelic_card *card;
> + struct gelic_wl_info *wl;
> +
> + u64 arg1, arg2;
> +
> + pr_debug("%s: <-\n", __func__);
> + cmd = container_of(work, struct gelic_eurus_cmd, work);
> + BUG_ON(cmd_info[cmd->cmd].pre_arg &&
> + cmd_info[cmd->cmd].post_arg);
> + wl = cmd->wl;
> + card = port_to_card(wl_port(wl));
> +
> + if (cmd_info[cmd->cmd].pre_arg) {
> + arg1 = ps3_mm_phys_to_lpar(__pa(cmd->buffer));
> + arg2 = cmd->buf_size;
> + } else {
> + arg1 = 0;
> + arg2 = 0;
> + }
> + init_completion(&wl->cmd_done_intr);
> + pr_debug("%s: cmd='%s' start\n", __func__, cmdstr(cmd->cmd));
> + cmd->status = lv1_net_control(bus_id(card), dev_id(card),
> + GELIC_LV1_POST_WLAN_CMD,
> + cmd->cmd, arg1, arg2,
> + &cmd->tag, &cmd->size);
> + if (cmd->status) {
> + complete(&cmd->done);
> + pr_info("%s: cmd issue failed\n", __func__);
> + return;
> + }
> +
> + wait_for_completion(&wl->cmd_done_intr);
> +
> + if (cmd_info[cmd->cmd].post_arg) {
> + arg1 = ps3_mm_phys_to_lpar(__pa(cmd->buffer));
> + arg2 = cmd->buf_size;
> + } else {
> + arg1 = 0;
> + arg2 = 0;
> + }
> +
> + cmd->status = lv1_net_control(bus_id(card), dev_id(card),
> + GELIC_LV1_GET_WLAN_CMD_RESULT,
> + cmd->tag, arg1, arg2,
> + &cmd->cmd_status, &cmd->size);
> +#ifdef DEBUG
> + if (cmd->status || cmd->cmd_status) {
> + pr_debug("%s: cmd done tag=%#lx arg1=%#lx, arg2=%#lx\n", __func__,
> + cmd->tag, arg1, arg2);
> + pr_debug("%s: cmd done status=%#x cmd_status=%#lx size=%#lx\n",
> + __func__, cmd->status, cmd->cmd_status, cmd->size);
> + }
> +#endif
> + complete(&cmd->done);
> + pr_debug("%s: cmd='%s' done\n", __func__, cmdstr(cmd->cmd));
> +}
> +
> +static struct gelic_eurus_cmd *gelic_eurus_sync_cmd(struct gelic_wl_info *wl,
> + unsigned int eurus_cmd,
> + void *buffer,
> + unsigned int buf_size)
> +{
> + struct gelic_eurus_cmd *cmd;
> +
> + /* allocate cmd */
> + cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
> + if (!cmd)
> + return NULL;
> +
> + /* initialize members */
> + cmd->cmd = eurus_cmd;
> + cmd->buffer = buffer;
> + cmd->buf_size = buf_size;
> + cmd->wl = wl;
> + INIT_WORK(&cmd->work, gelic_eurus_sync_cmd_worker);
> + init_completion(&cmd->done);
> + queue_work(wl->eurus_cmd_queue, &cmd->work);
> +
> + /* wait for command completion */
> + wait_for_completion(&cmd->done);
> +
> + return cmd;
> +}
> +
> +static u32 gelic_wl_get_link(struct net_device *netdev)
> +{
> + struct gelic_wl_info *wl = port_wl(netdev_port(netdev));
> + u32 ret;
> +
> + pr_debug("%s: <-\n", __func__);
> + down(&wl->assoc_stat_lock);
> + if (wl->assoc_stat == GELIC_WL_ASSOC_STAT_ASSOCIATED)
> + ret = 1;
> + else
> + ret = 0;
> + up(&wl->assoc_stat_lock);
> + pr_debug("%s: ->\n", __func__);
> + return ret;
> +}
> +
> +/*
> + * wireless extension handlers and helpers
> + */
> +
> +/* SIOGIWNAME */
> +static int gelic_wl_get_name(struct net_device *dev,
> + struct iw_request_info *info,
> + union iwreq_data *iwreq, char *extra)
> +{
> + strcpy(iwreq->name, "IEEE 802.11bg");
> + return 0;
> +}
> +
> +static void gelic_wl_get_ch_info(struct gelic_wl_info *wl)
> +{
> + struct gelic_card *card = port_to_card(wl_port(wl));
> + u64 ch_info_raw, tmp;
> + int status;
> +
> + if (!test_and_set_bit(GELIC_WL_STAT_CH_INFO, &wl->stat)) {
> + status = lv1_net_control(bus_id(card), dev_id(card),
> + GELIC_LV1_GET_CHANNEL, 0, 0, 0,
> + &ch_info_raw,
> + &tmp);
> + /* some fw versions may return error */
> + if (status) {
> + if (status != LV1_NO_ENTRY)
> + pr_info("%s: available ch unknown\n", __func__);
> + wl->ch_info = 0x07ff;/* 11 ch */
> + } else
> + /* 16 bits of MSB has available channels */
> + wl->ch_info = ch_info_raw >> 48;
> + }
> + return;
> +}
> +
> +/* SIOGIWRANGE */
> +static int gelic_wl_get_range(struct net_device *netdev,
> + struct iw_request_info *info,
> + union iwreq_data *iwreq, char *extra)
> +{
> + struct iw_point *point = &iwreq->data;
> + struct iw_range *range = (struct iw_range *)extra;
> + struct gelic_wl_info *wl = port_wl(netdev_port(netdev));
> + unsigned int i, chs;
> +
> + pr_debug("%s: <-\n", __func__);
> + point->length = sizeof(struct iw_range);
> + memset(range, 0, sizeof(struct iw_range));
> +
> + range->we_version_compiled = WIRELESS_EXT;
> + range->we_version_source = 22;
> +
> + /* available channels and frequencies */
> + gelic_wl_get_ch_info(wl);
> +
> + for (i = 0, chs = 0;
> + i < NUM_CHANNELS && chs < IW_MAX_FREQUENCIES; i++)
> + if (wl->ch_info & (1 << i)) {
> + range->freq[chs].i = i + 1;
> + range->freq[chs].m = channel_freq[i];
> + range->freq[chs].e = 6;
> + chs++;
> + }
> + range->num_frequency = chs;
> + range->old_num_frequency = chs;
> + range->num_channels = chs;
> + range->old_num_channels = chs;
> +
> + /* bitrates */
> + for (i = 0; i < NUM_BITRATES; i++)
> + range->bitrate[i] = bitrate_list[i];
> + range->num_bitrates = i;
> +
> + /* signal levels */
> + range->max_qual.qual = 100; /* relative value */
> + range->max_qual.level = 100;
> + range->avg_qual.qual = 50;
> + range->avg_qual.level = 50;
> + range->sensitivity = 0;
> +
> + /* Event capability */
> + IW_EVENT_CAPA_SET_KERNEL(range->event_capa);
> + IW_EVENT_CAPA_SET(range->event_capa, SIOCGIWAP);
> + IW_EVENT_CAPA_SET(range->event_capa, SIOCGIWSCAN);
> +
> + /* encryption capability */
> + range->enc_capa = IW_ENC_CAPA_WPA |
> + IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
> + if (wpa2_capable())
> + range->enc_capa |= IW_ENC_CAPA_WPA2;
> + range->encoding_size[0] = 5; /* 40bit WEP */
> + range->encoding_size[1] = 13; /* 104bit WEP */
> + range->encoding_size[2] = 32; /* WPA-PSK */
> + range->num_encoding_sizes = 3;
> + range->max_encoding_tokens = GELIC_WEP_KEYS;
> +
> + pr_debug("%s: ->\n", __func__);
> + return 0;
> +
> +}
> +
> +/* SIOC{G,S}IWSCAN */
> +static int gelic_wl_set_scan(struct net_device *netdev,
> + struct iw_request_info *info,
> + union iwreq_data *wrqu, char *extra)
> +{
> + struct gelic_wl_info *wl = port_wl(netdev_priv(netdev));
> +
> + return gelic_wl_start_scan(wl, 1);
> +}
> +
> +#define OUI_LEN 3
> +static const u8 rsn_oui[OUI_LEN] = { 0x00, 0x0f, 0xac };
> +static const u8 wpa_oui[OUI_LEN] = { 0x00, 0x50, 0xf2 };
> +
> +/*
> + * synthesize WPA/RSN IE data
> + * See WiFi WPA specification and IEEE 802.11-2007 7.3.2.25
> + * for the format
> + */
> +static size_t gelic_wl_synthesize_ie(u8 *buf,
> + struct gelic_eurus_scan_info *scan)
> +{
> +
> + const u8 *oui_header;
> + u8 *start = buf;
> + int rsn;
> + int ccmp;
> +
> + pr_debug("%s: <- sec=%16x\n", __func__, scan->security);
> + switch (be16_to_cpu(scan->security) & GELIC_EURUS_SCAN_SEC_MASK) {
> + case GELIC_EURUS_SCAN_SEC_WPA:
> + rsn = 0;
> + break;
> + case GELIC_EURUS_SCAN_SEC_WPA2:
> + rsn = 1;
> + break;
> + default:
> + /* WEP or none. No IE returned */
> + return 0;
> + }
> +
> + switch (be16_to_cpu(scan->security) & GELIC_EURUS_SCAN_SEC_WPA_MASK) {
> + case GELIC_EURUS_SCAN_SEC_WPA_TKIP:
> + ccmp = 0;
> + break;
> + case GELIC_EURUS_SCAN_SEC_WPA_AES:
> + ccmp = 1;
> + break;
> + default:
> + if (rsn) {
> + ccmp = 1;
> + pr_info("%s: no cipher info. defaulted to CCMP\n",
> + __func__);
> + } else {
> + ccmp = 0;
> + pr_info("%s: no cipher info. defaulted to TKIP\n",
> + __func__);
> + }
> + }
> +
> + if (rsn)
> + oui_header = rsn_oui;
> + else
> + oui_header = wpa_oui;
> +
> + /* element id */
> + if (rsn)
> + *buf++ = MFIE_TYPE_RSN;
> + else
> + *buf++ = MFIE_TYPE_GENERIC;
> +
> + /* length filed; set later */
> + buf++;
> +
> + /* wpa special header */
> + if (!rsn) {
> + memcpy(buf, wpa_oui, OUI_LEN);
> + buf += OUI_LEN;
> + *buf++ = 0x01;
> + }
> +
> + /* version */
> + *buf++ = 0x01; /* version 1.0 */
> + *buf++ = 0x00;
> +
> + /* group cipher */
> + memcpy(buf, oui_header, OUI_LEN);
> + buf += OUI_LEN;
> +
> + if (ccmp)
> + *buf++ = 0x04; /* CCMP */
> + else
> + *buf++ = 0x02; /* TKIP */
> +
> + /* pairwise key count always 1 */
> + *buf++ = 0x01;
> + *buf++ = 0x00;
> +
> + /* pairwise key suit */
> + memcpy(buf, oui_header, OUI_LEN);
> + buf += OUI_LEN;
> + if (ccmp)
> + *buf++ = 0x04; /* CCMP */
> + else
> + *buf++ = 0x02; /* TKIP */
> +
> + /* AKM count is 1 */
> + *buf++ = 0x01;
> + *buf++ = 0x00;
> +
> + /* AKM suite is assumed as PSK*/
> + memcpy(buf, oui_header, OUI_LEN);
> + buf += OUI_LEN;
> + *buf++ = 0x02; /* PSK */
> +
> + /* RSN capabilities is 0 */
> + *buf++ = 0x00;
> + *buf++ = 0x00;
> +
> + /* set length field */
> + start[1] = (buf - start - 2);
> +
> + pr_debug("%s: ->\n", __func__);
> + return (buf - start);
> +}
> +
> +struct ie_item {
> + u8 *data;
> + u8 len;
> +};
> +
> +struct ie_info {
> + struct ie_item wpa;
> + struct ie_item rsn;
> +};
> +
> +static void gelic_wl_parse_ie(u8 *data, size_t len,
> + struct ie_info *ie_info)
> +{
> + size_t data_left = len;
> + u8 *pos = data;
> + u8 item_len;
> + u8 item_id;
> +
> + pr_debug("%s: data=%p len=%ld \n", __func__,
> + data, len);
> + memset(ie_info, 0, sizeof(struct ie_info));
> +
> + while (0 < data_left) {
> + item_id = *pos++;
> + item_len = *pos++;
> +
> + switch (item_id) {
> + case MFIE_TYPE_GENERIC:
> + if (!memcmp(pos, wpa_oui, OUI_LEN) &&
> + pos[OUI_LEN] == 0x01) {
> + ie_info->wpa.data = pos - 2;
> + ie_info->wpa.len = item_len + 2;
> + }
> + break;
> + case MFIE_TYPE_RSN:
> + ie_info->rsn.data = pos - 2;
> + /* length includes the header */
> + ie_info->rsn.len = item_len + 2;
> + break;
> + default:
> + pr_debug("%s: ignore %#x,%d\n", __func__,
> + item_id, item_len);
> + break;
> + }
> + pos += item_len;
> + data_left -= item_len + 2;
> + }
> + pr_debug("%s: wpa=%p,%d wpa2=%p,%d\n", __func__,
> + ie_info->wpa.data, ie_info->wpa.len,
> + ie_info->rsn.data, ie_info->rsn.len);
> +}
> +
> +
> +/*
> + * translate the scan informations from hypervisor to a
> + * independent format
> + */
> +static char *gelic_wl_translate_scan(struct net_device *netdev,
> + char *ev,
> + char *stop,
> + struct gelic_wl_scan_info *network)
> +{
> + struct iw_event iwe;
> + struct gelic_eurus_scan_info *scan = network->hwinfo;
> + char *tmp;
> + u8 rate;
> + unsigned int i, j, len;
> + u8 buf[MAX_WPA_IE_LEN];
> +
> + pr_debug("%s: <-\n", __func__);
> +
> + /* first entry should be AP's mac address */
> + iwe.cmd = SIOCGIWAP;
> + iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
> + memcpy(iwe.u.ap_addr.sa_data, &scan->bssid[2], ETH_ALEN);
> + ev = iwe_stream_add_event(ev, stop, &iwe, IW_EV_ADDR_LEN);
> +
> + /* ESSID */
> + iwe.cmd = SIOCGIWESSID;
> + iwe.u.data.flags = 1;
> + iwe.u.data.length = strnlen(scan->essid, 32);
> + ev = iwe_stream_add_point(ev, stop, &iwe, scan->essid);
> +
> + /* FREQUENCY */
> + iwe.cmd = SIOCGIWFREQ;
> + iwe.u.freq.m = be16_to_cpu(scan->channel);
> + iwe.u.freq.e = 0; /* table value in MHz */
> + iwe.u.freq.i = 0;
> + ev = iwe_stream_add_event(ev, stop, &iwe, IW_EV_FREQ_LEN);
> +
> + /* RATES */
> + iwe.cmd = SIOCGIWRATE;
> + iwe.u.bitrate.fixed = iwe.u.bitrate.disabled = 0;
> + /* to stuff multiple values in one event */
> + tmp = ev + IW_EV_LCP_LEN;
> + /* put them in ascendant order (older is first) */
> + i = 0;
> + j = 0;
> + pr_debug("%s: rates=%d rate=%d\n", __func__,
> + network->rate_len, network->rate_ext_len);
> + while (i < network->rate_len) {
> + if (j < network->rate_ext_len &&
> + ((scan->ext_rate[j] & 0x7f) < (scan->rate[i] & 0x7f)))
> + rate = scan->ext_rate[j++] & 0x7f;
> + else
> + rate = scan->rate[i++] & 0x7f;
> + iwe.u.bitrate.value = rate * 500000; /* 500kbps unit */
> + tmp = iwe_stream_add_value(ev, tmp, stop, &iwe,
> + IW_EV_PARAM_LEN);
> + }
> + while (j < network->rate_ext_len) {
> + iwe.u.bitrate.value = (scan->ext_rate[j++] & 0x7f) * 500000;
> + tmp = iwe_stream_add_value(ev, tmp, stop, &iwe,
> + IW_EV_PARAM_LEN);
> + }
> + /* Check if we added any rate */
> + if (IW_EV_LCP_LEN < (tmp - ev))
> + ev = tmp;
> +
> + /* ENCODE */
> + iwe.cmd = SIOCGIWENCODE;
> + if (be16_to_cpu(scan->capability) & WLAN_CAPABILITY_PRIVACY)
> + iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
> + else
> + iwe.u.data.flags = IW_ENCODE_DISABLED;
> + iwe.u.data.length = 0;
> + ev = iwe_stream_add_point(ev, stop, &iwe, scan->essid);
> +
> + /* MODE */
> + iwe.cmd = SIOCGIWMODE;
> + if (be16_to_cpu(scan->capability) &
> + (WLAN_CAPABILITY_ESS | WLAN_CAPABILITY_IBSS)) {
> + if (be16_to_cpu(scan->capability) & WLAN_CAPABILITY_ESS)
> + iwe.u.mode = IW_MODE_MASTER;
> + else
> + iwe.u.mode = IW_MODE_ADHOC;
> + ev = iwe_stream_add_event(ev, stop, &iwe, IW_EV_UINT_LEN);
> + }
> +
> + /* QUAL */
> + iwe.cmd = IWEVQUAL;
> + iwe.u.qual.updated = IW_QUAL_ALL_UPDATED |
> + IW_QUAL_QUAL_INVALID | IW_QUAL_NOISE_INVALID;
> + iwe.u.qual.level = be16_to_cpu(scan->rssi);
> + iwe.u.qual.qual = be16_to_cpu(scan->rssi);
> + iwe.u.qual.noise = 0;
> + ev = iwe_stream_add_event(ev, stop, &iwe, IW_EV_QUAL_LEN);
> +
> + /* RSN */
> + memset(&iwe, 0, sizeof(iwe));
> + if (be16_to_cpu(scan->size) <= sizeof(*scan)) {
> + /* If wpa[2] capable station, synthesize IE and put it */
> + len = gelic_wl_synthesize_ie(buf, scan);
> + if (len) {
> + iwe.cmd = IWEVGENIE;
> + iwe.u.data.length = len;
> + ev = iwe_stream_add_point(ev, stop, &iwe, buf);
> + }
> + } else {
> + /* this scan info has IE data */
> + struct ie_info ie_info;
> + size_t data_len;
> +
> + data_len = be16_to_cpu(scan->size) - sizeof(*scan);
> +
> + gelic_wl_parse_ie(scan->elements, data_len, &ie_info);
> +
> + if (ie_info.wpa.len && (ie_info.wpa.len <= sizeof(buf))) {
> + memcpy(buf, ie_info.wpa.data, ie_info.wpa.len);
> + iwe.cmd = IWEVGENIE;
> + iwe.u.data.length = ie_info.wpa.len;
> + ev = iwe_stream_add_point(ev, stop, &iwe, buf);
> + }
> +
> + if (ie_info.rsn.len && (ie_info.rsn.len <= sizeof(buf))) {
> + memset(&iwe, 0, sizeof(iwe));
> + memcpy(buf, ie_info.rsn.data, ie_info.rsn.len);
> + iwe.cmd = IWEVGENIE;
> + iwe.u.data.length = ie_info.rsn.len;
> + ev = iwe_stream_add_point(ev, stop, &iwe, buf);
> + }
> + }
> +
> + pr_debug("%s: ->\n", __func__);
> + return ev;
> +}
> +
> +
> +static int gelic_wl_get_scan(struct net_device *netdev,
> + struct iw_request_info *info,
> + union iwreq_data *wrqu, char *extra)
> +{
> + struct gelic_wl_info *wl = port_wl(netdev_priv(netdev));
> + struct gelic_wl_scan_info *scan_info;
> + char *ev = extra;
> + char *stop = ev + wrqu->data.length;
> + int ret = 0;
> + unsigned long this_time = jiffies;
> +
> + pr_debug("%s: <-\n", __func__);
> + if (down_interruptible(&wl->scan_lock))
> + return -EAGAIN;
> +
> + switch (wl->scan_stat) {
> + case GELIC_WL_SCAN_STAT_SCANNING:
> + /* If a scan in progress, caller should call me again */
> + ret = -EAGAIN;
> + goto out;
> + break;
> +
> + case GELIC_WL_SCAN_STAT_INIT:
> + /* last scan request failed or never issued */
> + ret = -ENODEV;
> + goto out;
> + break;
> + case GELIC_WL_SCAN_STAT_GOT_LIST:
> + /* ok, use current list */
> + break;
> + }
> +
> + list_for_each_entry(scan_info, &wl->network_list, list) {
> + if (wl->scan_age == 0 ||
> + time_after(scan_info->last_scanned + wl->scan_age,
> + this_time))
> + ev = gelic_wl_translate_scan(netdev, ev, stop,
> + scan_info);
> + else
> + pr_debug("%s:entry too old\n", __func__);
> +
> + if (stop - ev <= IW_EV_ADDR_LEN) {
> + ret = -E2BIG;
> + goto out;
> + }
> + }
> +
> + wrqu->data.length = ev - extra;
> + wrqu->data.flags = 0;
> +out:
> + up(&wl->scan_lock);
> + pr_debug("%s: -> %d %d\n", __func__, ret, wrqu->data.length);
> + return ret;
> +}
> +
> +#ifdef DEBUG
> +static void scan_list_dump(struct gelic_wl_info *wl)
> +{
> + struct gelic_wl_scan_info *scan_info;
> + int i;
> + DECLARE_MAC_BUF(mac);
> +
> + i = 0;
> + list_for_each_entry(scan_info, &wl->network_list, list) {
> + pr_debug("%s: item %d\n", __func__, i++);
> + pr_debug("valid=%d eurusindex=%d last=%lx\n",
> + scan_info->valid, scan_info->eurus_index,
> + scan_info->last_scanned);
> + pr_debug("r_len=%d r_ext_len=%d essid_len=%d\n",
> + scan_info->rate_len, scan_info->rate_ext_len,
> + scan_info->essid_len);
> + /* -- */
> + pr_debug("bssid=%s\n",
> + print_mac(mac, &scan_info->hwinfo->bssid[2]));
> + pr_debug("essid=%s\n", scan_info->hwinfo->essid);
> + }
> +}
> +#endif
> +
> +static int gelic_wl_set_auth(struct net_device *netdev,
> + struct iw_request_info *info,
> + union iwreq_data *data, char *extra)
> +{
> + struct iw_param *param = &data->param;
> + struct gelic_wl_info *wl = port_wl(netdev_port(netdev));
> + unsigned long irqflag;
> + int ret = 0;
> +
> + pr_debug("%s: <- %d\n", __func__, param->flags & IW_AUTH_INDEX);
> + spin_lock_irqsave(&wl->lock, irqflag);
> + switch (param->flags & IW_AUTH_INDEX) {
> + case IW_AUTH_WPA_VERSION:
> + if (param->value & IW_AUTH_WPA_VERSION_DISABLED) {
> + pr_debug("%s: NO WPA selected\n", __func__);
> + wl->wpa_level = GELIC_WL_WPA_LEVEL_NONE;
> + wl->group_cipher_method = GELIC_WL_CIPHER_WEP;
> + wl->pairwise_cipher_method = GELIC_WL_CIPHER_WEP;
> + }
> + if (param->value & IW_AUTH_WPA_VERSION_WPA) {
> + pr_debug("%s: WPA version 1 selected\n", __func__);
> + wl->wpa_level = GELIC_WL_WPA_LEVEL_WPA;
> + wl->group_cipher_method = GELIC_WL_CIPHER_TKIP;
> + wl->pairwise_cipher_method = GELIC_WL_CIPHER_TKIP;
> + wl->auth_method = GELIC_EURUS_AUTH_OPEN;
> + }
> + if (param->value & IW_AUTH_WPA_VERSION_WPA2) {
> + /*
> + * As the hypervisor may not tell the cipher
> + * information of the AP if it is WPA2,
> + * you will not decide suitable cipher from
> + * its beacon.
> + * You should have knowledge about the AP's
> + * cipher infomation in other method prior to
> + * the association.
> + */
> + if (!precise_ie())
> + pr_info("%s: WPA2 may not work\n", __func__);
> + if (wpa2_capable()) {
> + wl->wpa_level = GELIC_WL_WPA_LEVEL_WPA2;
> + wl->group_cipher_method = GELIC_WL_CIPHER_AES;
> + wl->pairwise_cipher_method =
> + GELIC_WL_CIPHER_AES;
> + wl->auth_method = GELIC_EURUS_AUTH_OPEN;
> + } else
> + ret = -EINVAL;
> + }
> + break;
> +
> + case IW_AUTH_CIPHER_PAIRWISE:
> + if (param->value &
> + (IW_AUTH_CIPHER_WEP104 | IW_AUTH_CIPHER_WEP40)) {
> + pr_debug("%s: WEP selected\n", __func__);
> + wl->pairwise_cipher_method = GELIC_WL_CIPHER_WEP;
> + }
> + if (param->value & IW_AUTH_CIPHER_TKIP) {
> + pr_debug("%s: TKIP selected\n", __func__);
> + wl->pairwise_cipher_method = GELIC_WL_CIPHER_TKIP;
> + }
> + if (param->value & IW_AUTH_CIPHER_CCMP) {
> + pr_debug("%s: CCMP selected\n", __func__);
> + wl->pairwise_cipher_method = GELIC_WL_CIPHER_AES;
> + }
> + if (param->value & IW_AUTH_CIPHER_NONE) {
> + pr_debug("%s: no auth selected\n", __func__);
> + wl->pairwise_cipher_method = GELIC_WL_CIPHER_NONE;
> + }
> + break;
> + case IW_AUTH_CIPHER_GROUP:
> + if (param->value &
> + (IW_AUTH_CIPHER_WEP104 | IW_AUTH_CIPHER_WEP40)) {
> + pr_debug("%s: WEP selected\n", __func__);
> + wl->group_cipher_method = GELIC_WL_CIPHER_WEP;
> + }
> + if (param->value & IW_AUTH_CIPHER_TKIP) {
> + pr_debug("%s: TKIP selected\n", __func__);
> + wl->group_cipher_method = GELIC_WL_CIPHER_TKIP;
> + }
> + if (param->value & IW_AUTH_CIPHER_CCMP) {
> + pr_debug("%s: CCMP selected\n", __func__);
> + wl->group_cipher_method = GELIC_WL_CIPHER_AES;
> + }
> + if (param->value & IW_AUTH_CIPHER_NONE) {
> + pr_debug("%s: no auth selected\n", __func__);
> + wl->group_cipher_method = GELIC_WL_CIPHER_NONE;
> + }
> + break;
> + case IW_AUTH_80211_AUTH_ALG:
> + if (param->value & IW_AUTH_ALG_SHARED_KEY) {
> + pr_debug("%s: shared key specified\n", __func__);
> + wl->auth_method = GELIC_EURUS_AUTH_SHARED;
> + } else if (param->value & IW_AUTH_ALG_OPEN_SYSTEM) {
> + pr_debug("%s: open system specified\n", __func__);
> + wl->auth_method = GELIC_EURUS_AUTH_OPEN;
> + } else
> + ret = -EINVAL;
> + break;
> +
> + case IW_AUTH_WPA_ENABLED:
> + if (param->value) {
> + pr_debug("%s: WPA enabled\n", __func__);
> + wl->wpa_level = GELIC_WL_WPA_LEVEL_WPA;
> + } else {
> + pr_debug("%s: WPA disabled\n", __func__);
> + wl->wpa_level = GELIC_WL_WPA_LEVEL_NONE;
> + }
> + break;
> +
> + case IW_AUTH_KEY_MGMT:
> + if (param->value & IW_AUTH_KEY_MGMT_PSK)
> + break;
> + /* intentionally fall through */
> + default:
> + ret = -EOPNOTSUPP;
> + break;
> + };
> +
> + if (!ret)
> + set_bit(GELIC_WL_STAT_CONFIGURED, &wl->stat);
> +
> + spin_unlock_irqrestore(&wl->lock, irqflag);
> + pr_debug("%s: -> %d\n", __func__, ret);
> + return ret;
> +}
> +
> +static int gelic_wl_get_auth(struct net_device *netdev,
> + struct iw_request_info *info,
> + union iwreq_data *iwreq, char *extra)
> +{
> + struct iw_param *param = &iwreq->param;
> + struct gelic_wl_info *wl = port_wl(netdev_port(netdev));
> + unsigned long irqflag;
> + int ret = 0;
> +
> + pr_debug("%s: <- %d\n", __func__, param->flags & IW_AUTH_INDEX);
> + spin_lock_irqsave(&wl->lock, irqflag);
> + switch (param->flags & IW_AUTH_INDEX) {
> + case IW_AUTH_WPA_VERSION:
> + switch (wl->wpa_level) {
> + case GELIC_WL_WPA_LEVEL_WPA:
> + param->value |= IW_AUTH_WPA_VERSION_WPA;
> + break;
> + case GELIC_WL_WPA_LEVEL_WPA2:
> + param->value |= IW_AUTH_WPA_VERSION_WPA2;
> + break;
> + default:
> + param->value |= IW_AUTH_WPA_VERSION_DISABLED;
> + }
> + break;
> +
> + case IW_AUTH_80211_AUTH_ALG:
> + if (wl->auth_method == GELIC_EURUS_AUTH_SHARED)
> + param->value = IW_AUTH_ALG_SHARED_KEY;
> + else if (wl->auth_method == GELIC_EURUS_AUTH_OPEN)
> + param->value = IW_AUTH_ALG_OPEN_SYSTEM;
> + break;
> +
> + case IW_AUTH_WPA_ENABLED:
> + switch (wl->wpa_level) {
> + case GELIC_WL_WPA_LEVEL_WPA:
> + case GELIC_WL_WPA_LEVEL_WPA2:
> + param->value = 1;
> + break;
> + default:
> + param->value = 0;
> + break;
> + }
> + break;
> + default:
> + ret = -EOPNOTSUPP;
> + }
> +
> + spin_unlock_irqrestore(&wl->lock, irqflag);
> + pr_debug("%s: -> %d\n", __func__, ret);
> + return ret;
> +}
> +
> +/* SIOC{S,G}IWESSID */
> +static int gelic_wl_set_essid(struct net_device *netdev,
> + struct iw_request_info *info,
> + union iwreq_data *data, char *extra)
> +{
> + struct gelic_wl_info *wl = port_wl(netdev_priv(netdev));
> + unsigned long irqflag;
> +
> + pr_debug("%s: <- l=%d f=%d\n", __func__,
> + data->essid.length, data->essid.flags);
> + if (IW_ESSID_MAX_SIZE < data->essid.length)
> + return -EINVAL;
> +
> + spin_lock_irqsave(&wl->lock, irqflag);
> + if (data->essid.flags) {
> + wl->essid_len = data->essid.length;
> + memcpy(wl->essid, extra, wl->essid_len);
> + pr_debug("%s: essid = '%s'\n", __func__, extra);
> + set_bit(GELIC_WL_STAT_ESSID_SET, &wl->stat);
> + } else {
> + pr_debug("%s: ESSID any \n", __func__);
> + clear_bit(GELIC_WL_STAT_ESSID_SET, &wl->stat);
> + }
> + set_bit(GELIC_WL_STAT_CONFIGURED, &wl->stat);
> + spin_unlock_irqrestore(&wl->lock, irqflag);
> +
> +
> + gelic_wl_try_associate(netdev); /* FIXME */
> + pr_debug("%s: -> \n", __func__);
> + return 0;
> +}
> +
> +static int gelic_wl_get_essid(struct net_device *netdev,
> + struct iw_request_info *info,
> + union iwreq_data *data, char *extra)
> +{
> + struct gelic_wl_info *wl = port_wl(netdev_priv(netdev));
> + unsigned long irqflag;
> +
> + pr_debug("%s: <- \n", __func__);
> + down(&wl->assoc_stat_lock);
> + spin_lock_irqsave(&wl->lock, irqflag);
> + if (test_bit(GELIC_WL_STAT_ESSID_SET, &wl->stat) ||
> + wl->assoc_stat == GELIC_WL_ASSOC_STAT_ASSOCIATED) {
> + memcpy(extra, wl->essid, wl->essid_len);
> + data->essid.length = wl->essid_len;
> + data->essid.flags = 1;
> + } else
> + data->essid.flags = 0;
> +
> + up(&wl->assoc_stat_lock);
> + spin_unlock_irqrestore(&wl->lock, irqflag);
> + pr_debug("%s: -> len=%d \n", __func__, data->essid.length);
> +
> + return 0;
> +}
> +
> +/* SIO{S,G}IWENCODE */
> +static int gelic_wl_set_encode(struct net_device *netdev,
> + struct iw_request_info *info,
> + union iwreq_data *data, char *extra)
> +{
> + struct gelic_wl_info *wl = port_wl(netdev_priv(netdev));
> + struct iw_point *enc = &data->encoding;
> + __u16 flags;
> + unsigned int irqflag;
> + int key_index, index_specified;
> + int ret = 0;
> +
> + pr_debug("%s: <- \n", __func__);
> + flags = enc->flags & IW_ENCODE_FLAGS;
> + key_index = enc->flags & IW_ENCODE_INDEX;
> +
> + pr_debug("%s: key_index = %d\n", __func__, key_index);
> + pr_debug("%s: key_len = %d\n", __func__, enc->length);
> + pr_debug("%s: flag=%x\n", __func__, enc->flags & IW_ENCODE_FLAGS);
> +
> + if (GELIC_WEP_KEYS < key_index)
> + return -EINVAL;
> +
> + spin_lock_irqsave(&wl->lock, irqflag);
> + if (key_index) {
> + index_specified = 1;
> + key_index--;
> + } else {
> + index_specified = 0;
> + key_index = wl->current_key;
> + }
> +
> + if (flags & IW_ENCODE_NOKEY) {
> + /* if just IW_ENCODE_NOKEY, change current key index */
> + if (!flags && index_specified) {
> + wl->current_key = key_index;
> + goto done;
> + }
> +
> + if (flags & IW_ENCODE_DISABLED) {
> + if (!index_specified) {
> + /* disable encryption */
> + wl->group_cipher_method = GELIC_WL_CIPHER_NONE;
> + wl->pairwise_cipher_method =
> + GELIC_WL_CIPHER_NONE;
> + /* invalidate all key */
> + wl->key_enabled = 0;
> + } else
> + clear_bit(key_index, &wl->key_enabled);
> + }
> +
> + if (flags & IW_ENCODE_OPEN)
> + wl->auth_method = GELIC_EURUS_AUTH_OPEN;
> + if (flags & IW_ENCODE_RESTRICTED) {
> + pr_info("%s: shared key mode enabled\n", __func__);
> + wl->auth_method = GELIC_EURUS_AUTH_SHARED;
> + }
> + } else {
> + if (IW_ENCODING_TOKEN_MAX < enc->length) {
> + ret = -EINVAL;
> + goto done;
> + }
> + wl->key_len[key_index] = enc->length;
> + memcpy(wl->key[key_index], extra, enc->length);
> + set_bit(key_index, &wl->key_enabled);
> + wl->pairwise_cipher_method = GELIC_WL_CIPHER_WEP;
> + wl->group_cipher_method = GELIC_WL_CIPHER_WEP;
> + }
> + set_bit(GELIC_WL_STAT_CONFIGURED, &wl->stat);
> +done:
> + spin_unlock_irqrestore(&wl->lock, irqflag);
> + pr_debug("%s: -> \n", __func__);
> + return ret;
> +}
> +
> +static int gelic_wl_get_encode(struct net_device *netdev,
> + struct iw_request_info *info,
> + union iwreq_data *data, char *extra)
> +{
> + struct gelic_wl_info *wl = port_wl(netdev_priv(netdev));
> + struct iw_point *enc = &data->encoding;
> + unsigned int irqflag;
> + unsigned int key_index, index_specified;
> + int ret = 0;
> +
> + pr_debug("%s: <- \n", __func__);
> + key_index = enc->flags & IW_ENCODE_INDEX;
> + pr_debug("%s: flag=%#x point=%p len=%d extra=%p\n", __func__,
> + enc->flags, enc->pointer, enc->length, extra);
> + if (GELIC_WEP_KEYS < key_index)
> + return -EINVAL;
> +
> + spin_lock_irqsave(&wl->lock, irqflag);
> + if (key_index) {
> + index_specified = 1;
> + key_index--;
> + } else {
> + index_specified = 0;
> + key_index = wl->current_key;
> + }
> +
> + if (wl->group_cipher_method == GELIC_WL_CIPHER_WEP) {
> + switch (wl->auth_method) {
> + case GELIC_EURUS_AUTH_OPEN:
> + enc->flags = IW_ENCODE_OPEN;
> + break;
> + case GELIC_EURUS_AUTH_SHARED:
> + enc->flags = IW_ENCODE_RESTRICTED;
> + break;
> + }
> + } else
> + enc->flags = IW_ENCODE_DISABLED;
> +
> + if (test_bit(key_index, &wl->key_enabled)) {
> + if (enc->length < wl->key_len[key_index]) {
> + ret = -EINVAL;
> + goto done;
> + }
> + enc->length = wl->key_len[key_index];
> + memcpy(extra, wl->key[key_index], wl->key_len[key_index]);
> + } else {
> + enc->length = 0;
> + enc->flags |= IW_ENCODE_NOKEY;
> + }
> + enc->flags |= key_index + 1;
> + pr_debug("%s: -> flag=%x len=%d\n", __func__,
> + enc->flags, enc->length);
> +
> +done:
> + spin_unlock_irqrestore(&wl->lock, irqflag);
> + return ret;
> +}
> +
> +/* SIOC{S,G}IWAP */
> +static int gelic_wl_set_ap(struct net_device *netdev,
> + struct iw_request_info *info,
> + union iwreq_data *data, char *extra)
> +{
> + struct gelic_wl_info *wl = port_wl(netdev_priv(netdev));
> + unsigned long irqflag;
> +
> + pr_debug("%s: <-\n", __func__);
> + if (data->ap_addr.sa_family != ARPHRD_ETHER)
> + return -EINVAL;
> +
> + spin_lock_irqsave(&wl->lock, irqflag);
> + if (is_valid_ether_addr(data->ap_addr.sa_data)) {
> + memcpy(wl->bssid, data->ap_addr.sa_data,
> + ETH_ALEN);
> + set_bit(GELIC_WL_STAT_BSSID_SET, &wl->stat);
> + set_bit(GELIC_WL_STAT_CONFIGURED, &wl->stat);
> + pr_debug("%s: bss=%02x:%02x:%02x:%02x:%02x:%02x\n",
> + __func__,
> + wl->bssid[0], wl->bssid[1],
> + wl->bssid[2], wl->bssid[3],
> + wl->bssid[4], wl->bssid[5]);
> + } else {
> + pr_debug("%s: clear bssid\n", __func__);
> + clear_bit(GELIC_WL_STAT_BSSID_SET, &wl->stat);
> + memset(wl->bssid, 0, ETH_ALEN);
> + }
> + spin_unlock_irqrestore(&wl->lock, irqflag);
> + pr_debug("%s: ->\n", __func__);
> + return 0;
> +}
> +
> +static int gelic_wl_get_ap(struct net_device *netdev,
> + struct iw_request_info *info,
> + union iwreq_data *data, char *extra)
> +{
> + struct gelic_wl_info *wl = port_wl(netdev_priv(netdev));
> + unsigned long irqflag;
> +
> + pr_debug("%s: <-\n", __func__);
> + down(&wl->assoc_stat_lock);
> + spin_lock_irqsave(&wl->lock, irqflag);
> + if (wl->assoc_stat == GELIC_WL_ASSOC_STAT_ASSOCIATED) {
> + data->ap_addr.sa_family = ARPHRD_ETHER;
> + memcpy(data->ap_addr.sa_data, wl->active_bssid,
> + ETH_ALEN);
> + } else
> + memset(data->ap_addr.sa_data, 0, ETH_ALEN);
> +
> + spin_unlock_irqrestore(&wl->lock, irqflag);
> + up(&wl->assoc_stat_lock);
> + pr_debug("%s: ->\n", __func__);
> + return 0;
> +}
> +
> +/* SIOC{S,G}IWENCODEEXT */
> +static int gelic_wl_set_encodeext(struct net_device *netdev,
> + struct iw_request_info *info,
> + union iwreq_data *data, char *extra)
> +{
> + struct gelic_wl_info *wl = port_wl(netdev_priv(netdev));
> + struct iw_point *enc = &data->encoding;
> + struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
> + __u16 alg;
> + __u16 flags;
> + unsigned int irqflag;
> + int key_index;
> + int ret = 0;
> +
> + pr_debug("%s: <- \n", __func__);
> + flags = enc->flags & IW_ENCODE_FLAGS;
> + alg = ext->alg;
> + key_index = enc->flags & IW_ENCODE_INDEX;
> +
> + pr_debug("%s: key_index = %d\n", __func__, key_index);
> + pr_debug("%s: key_len = %d\n", __func__, enc->length);
> + pr_debug("%s: flag=%x\n", __func__, enc->flags & IW_ENCODE_FLAGS);
> + pr_debug("%s: ext_flag=%x\n", __func__, ext->ext_flags);
> + pr_debug("%s: ext_key_len=%x\n", __func__, ext->key_len);
> +
> + if (GELIC_WEP_KEYS < key_index)
> + return -EINVAL;
> +
> + spin_lock_irqsave(&wl->lock, irqflag);
> + if (key_index)
> + key_index--;
> + else
> + key_index = wl->current_key;
> +
> + if (!enc->length && (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)) {
> + /* reques to change default key index */
> + pr_debug("%s: request to change default key to %d\n",
> + __func__, key_index);
> + wl->current_key = key_index;
> + goto done;
> + }
> +
> + if (alg == IW_ENCODE_ALG_NONE || (flags & IW_ENCODE_DISABLED)) {
> + pr_debug("%s: alg disabled\n", __func__);
> + wl->wpa_level = GELIC_WL_WPA_LEVEL_NONE;
> + wl->group_cipher_method = GELIC_WL_CIPHER_NONE;
> + wl->pairwise_cipher_method = GELIC_WL_CIPHER_NONE;
> + wl->auth_method = GELIC_EURUS_AUTH_OPEN; /* should be open */
> + } else if (alg == IW_ENCODE_ALG_WEP) {
> + pr_debug("%s: WEP requested\n", __func__);
> + if (flags & IW_ENCODE_OPEN) {
> + pr_debug("%s: open key mode\n", __func__);
> + wl->auth_method = GELIC_EURUS_AUTH_OPEN;
> + }
> + if (flags & IW_ENCODE_RESTRICTED) {
> + pr_debug("%s: shared key mode\n", __func__);
> + wl->auth_method = GELIC_EURUS_AUTH_SHARED;
> + }
> + if (IW_ENCODING_TOKEN_MAX < ext->key_len) {
> + pr_info("%s: key is too long %d\n", __func__,
> + ext->key_len);
> + ret = -EINVAL;
> + goto done;
> + }
> + /* OK, update the key */
> + wl->key_len[key_index] = ext->key_len;
> + memset(wl->key[key_index], 0, IW_ENCODING_TOKEN_MAX);
> + memcpy(wl->key[key_index], ext->key, ext->key_len);
> + set_bit(key_index, &wl->key_enabled);
> + /* remember wep info changed */
> + set_bit(GELIC_WL_STAT_CONFIGURED, &wl->stat);
> + } else if ((alg == IW_ENCODE_ALG_TKIP) || (alg == IW_ENCODE_ALG_CCMP)) {
> + pr_debug("%s: TKIP/CCMP requested alg=%d\n", __func__, alg);
> + /* check key length */
> + if (IW_ENCODING_TOKEN_MAX < ext->key_len) {
> + pr_info("%s: key is too long %d\n", __func__,
> + ext->key_len);
> + ret = -EINVAL;
> + goto done;
> + }
> + if (alg == IW_ENCODE_ALG_CCMP) {
> + pr_debug("%s: AES selected\n", __func__);
> + wl->group_cipher_method = GELIC_WL_CIPHER_AES;
> + wl->pairwise_cipher_method = GELIC_WL_CIPHER_AES;
> + wl->wpa_level = GELIC_WL_WPA_LEVEL_WPA2;
> + } else {
> + pr_debug("%s: TKIP selected, WPA forced\n", __func__);
> + wl->group_cipher_method = GELIC_WL_CIPHER_TKIP;
> + wl->pairwise_cipher_method = GELIC_WL_CIPHER_TKIP;
> + /* FIXME: how do we do if WPA2 + TKIP? */
> + wl->wpa_level = GELIC_WL_WPA_LEVEL_WPA;
> + }
> + if (flags & IW_ENCODE_RESTRICTED)
> + BUG();
> + wl->auth_method = GELIC_EURUS_AUTH_OPEN;
> + /* We should use same key for both and unicast */
> + if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY)
> + pr_debug("%s: group key \n", __func__);
> + else
> + pr_debug("%s: unicast key \n", __func__);
> + /* OK, update the key */
> + wl->key_len[key_index] = ext->key_len;
> + memset(wl->key[key_index], 0, IW_ENCODING_TOKEN_MAX);
> + memcpy(wl->key[key_index], ext->key, ext->key_len);
> + set_bit(key_index, &wl->key_enabled);
> + /* remember info changed */
> + set_bit(GELIC_WL_STAT_CONFIGURED, &wl->stat);
> + }
> +done:
> + spin_unlock_irqrestore(&wl->lock, irqflag);
> + pr_debug("%s: -> \n", __func__);
> + return ret;
> +}
> +
> +static int gelic_wl_get_encodeext(struct net_device *netdev,
> + struct iw_request_info *info,
> + union iwreq_data *data, char *extra)
> +{
> + struct gelic_wl_info *wl = port_wl(netdev_priv(netdev));
> + struct iw_point *enc = &data->encoding;
> + struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
> + unsigned int irqflag;
> + int key_index;
> + int ret = 0;
> + int max_key_len;
> +
> + pr_debug("%s: <- \n", __func__);
> +
> + max_key_len = enc->length - sizeof(struct iw_encode_ext);
> + if (max_key_len < 0)
> + return -EINVAL;
> + key_index = enc->flags & IW_ENCODE_INDEX;
> +
> + pr_debug("%s: key_index = %d\n", __func__, key_index);
> + pr_debug("%s: key_len = %d\n", __func__, enc->length);
> + pr_debug("%s: flag=%x\n", __func__, enc->flags & IW_ENCODE_FLAGS);
> +
> + if (GELIC_WEP_KEYS < key_index)
> + return -EINVAL;
> +
> + spin_lock_irqsave(&wl->lock, irqflag);
> + if (key_index)
> + key_index--;
> + else
> + key_index = wl->current_key;
> +
> + memset(ext, 0, sizeof(struct iw_encode_ext));
> + switch (wl->group_cipher_method) {
> + case GELIC_WL_CIPHER_WEP:
> + ext->alg = IW_ENCODE_ALG_WEP;
> + enc->flags |= IW_ENCODE_ENABLED;
> + break;
> + case GELIC_WL_CIPHER_TKIP:
> + ext->alg = IW_ENCODE_ALG_TKIP;
> + enc->flags |= IW_ENCODE_ENABLED;
> + break;
> + case GELIC_WL_CIPHER_AES:
> + ext->alg = IW_ENCODE_ALG_CCMP;
> + enc->flags |= IW_ENCODE_ENABLED;
> + break;
> + case GELIC_WL_CIPHER_NONE:
> + default:
> + ext->alg = IW_ENCODE_ALG_NONE;
> + enc->flags |= IW_ENCODE_NOKEY;
> + break;
> + }
> +
> + if (!(enc->flags & IW_ENCODE_NOKEY)) {
> + if (max_key_len < wl->key_len[key_index]) {
> + ret = -E2BIG;
> + goto out;
> + }
> + if (test_bit(key_index, &wl->key_enabled))
> + memcpy(ext->key, wl->key[key_index],
> + wl->key_len[key_index]);
> + else
> + pr_debug("%s: disabled key requested ix=%d\n",
> + __func__, key_index);
> + }
> +out:
> + spin_unlock_irqrestore(&wl->lock, irqflag);
> + pr_debug("%s: -> \n", __func__);
> + return ret;
> +}
> +/* SIOC{S,G}IWMODE */
> +static int gelic_wl_set_mode(struct net_device *netdev,
> + struct iw_request_info *info,
> + union iwreq_data *data, char *extra)
> +{
> + __u32 mode = data->mode;
> + int ret;
> +
> + pr_debug("%s: <- \n", __func__);
> + if (mode == IW_MODE_INFRA)
> + ret = 0;
> + else
> + ret = -EOPNOTSUPP;
> + pr_debug("%s: -> %d\n", __func__, ret);
> + return ret;
> +}
> +
> +static int gelic_wl_get_mode(struct net_device *netdev,
> + struct iw_request_info *info,
> + union iwreq_data *data, char *extra)
> +{
> + __u32 *mode = &data->mode;
> + pr_debug("%s: <- \n", __func__);
> + *mode = IW_MODE_INFRA;
> + pr_debug("%s: ->\n", __func__);
> + return 0;
> +}
> +
> +/* SIOCIWFIRSTPRIV */
> +static int hex2bin(u8 *str, u8 *bin, unsigned int len)
> +{
> + unsigned int i;
> + static unsigned char *hex = "0123456789ABCDEF";
> + unsigned char *p, *q;
> + u8 tmp;
> +
> + if (len != WPA_PSK_LEN * 2)
> + return -EINVAL;
> +
> + for (i = 0; i < WPA_PSK_LEN * 2; i += 2) {
> + p = strchr(hex, toupper(str[i]));
> + q = strchr(hex, toupper(str[i + 1]));
> + if (!p || !q) {
> + pr_info("%s: unconvertible PSK digit=%d\n",
> + __func__, i);
> + return -EINVAL;
> + }
> + tmp = ((p - hex) << 4) + (q - hex);
> + *bin++ = tmp;
> + }
> + return 0;
> +};
> +
> +int gelic_wl_priv_set_psk(struct net_device *net_dev,
> + struct iw_request_info *info,
> + union iwreq_data *data, char *extra)
> +{
> + struct gelic_wl_info *wl = port_wl(netdev_priv(net_dev));
> + unsigned int len;
> + unsigned int irqflag;
> + int ret = 0;
> +
> + pr_debug("%s:<- len=%d\n", __func__, data->data.length);
> + len = data->data.length - 1;
> + if (len <= 2)
> + return -EINVAL;
> +
> + spin_lock_irqsave(&wl->lock, irqflag);
> + if (extra[0] == '"' && extra[len - 1] == '"') {
> + pr_debug("%s: passphrase mode\n", __func__);
> + /* pass phrase */
> + if (GELIC_WL_EURUS_PSK_MAX_LEN < (len - 2)) {
> + pr_info("%s: passphrase too long\n", __func__);
> + ret = -E2BIG;
> + goto out;
> + }
> + memset(wl->psk, 0, sizeof(wl->psk));
> + wl->psk_len = len - 2;
> + memcpy(wl->psk, &(extra[1]), wl->psk_len);
> + wl->psk_type = GELIC_EURUS_WPA_PSK_PASSPHRASE;
> + } else {
> + ret = hex2bin(extra, wl->psk, len);
> + if (ret)
> + goto out;
> + wl->psk_len = WPA_PSK_LEN;
> + wl->psk_type = GELIC_EURUS_WPA_PSK_BIN;
> + }
> + set_bit(GELIC_WL_STAT_WPA_PSK_SET, &wl->stat);
> +out:
> + spin_unlock_irqrestore(&wl->lock, irqflag);
> + pr_debug("%s:->\n", __func__);
> + return ret;
> +}
> +
> +static int gelic_wl_priv_get_psk(struct net_device *net_dev,
> + struct iw_request_info *info,
> + union iwreq_data *data, char *extra)
> +{
> + struct gelic_wl_info *wl = port_wl(netdev_priv(net_dev));
> + char *p;
> + unsigned int irqflag;
> + unsigned int i;
> +
> + pr_debug("%s:<-\n", __func__);
> + if (!capable(CAP_NET_ADMIN))
> + return -EPERM;
> +
> + spin_lock_irqsave(&wl->lock, irqflag);
> + p = extra;
> + if (test_bit(GELIC_WL_STAT_WPA_PSK_SET, &wl->stat)) {
> + if (wl->psk_type == GELIC_EURUS_WPA_PSK_BIN) {
> + for (i = 0; i < wl->psk_len; i++) {
> + sprintf(p, "%02xu", wl->psk[i]);
> + p += 2;
> + }
> + *p = '\0';
> + data->data.length = wl->psk_len * 2;
> + } else {
> + *p++ = '"';
> + memcpy(p, wl->psk, wl->psk_len);
> + p += wl->psk_len;
> + *p++ = '"';
> + *p = '\0';
> + data->data.length = wl->psk_len + 2;
> + }
> + } else
> + /* no psk set */
> + data->data.length = 0;
> + spin_unlock_irqrestore(&wl->lock, irqflag);
> + pr_debug("%s:-> %d\n", __func__, data->data.length);
> + return 0;
> +}
> +
> +/* SIOCGIWNICKN */
> +static int gelic_wl_get_nick(struct net_device *net_dev,
> + struct iw_request_info *info,
> + union iwreq_data *data, char *extra)
> +{
> + strcpy(extra, "gelic_wl");
> + data->data.length = strlen(extra);
> + data->data.flags = 1;
> + return 0;
> +}
> +
> +
> +/* --- */
> +
> +static struct iw_statistics *gelic_wl_get_wireless_stats(
> + struct net_device *netdev)
> +{
> +
> + struct gelic_wl_info *wl = port_wl(netdev_priv(netdev));
> + struct gelic_eurus_cmd *cmd;
> + struct iw_statistics *is;
> + struct gelic_eurus_rssi_info *rssi;
> +
> + pr_debug("%s: <-\n", __func__);
> +
> + is = &wl->iwstat;
> + memset(is, 0, sizeof(*is));
> + cmd = gelic_eurus_sync_cmd(wl, GELIC_EURUS_CMD_GET_RSSI_CFG,
> + wl->buf, sizeof(*rssi));
> + if (cmd && !cmd->status && !cmd->cmd_status) {
> + rssi = wl->buf;
> + is->qual.level = be16_to_cpu(rssi->rssi);
> + is->qual.updated = IW_QUAL_LEVEL_UPDATED |
> + IW_QUAL_QUAL_INVALID | IW_QUAL_NOISE_INVALID;
> + } else
> + /* not associated */
> + is->qual.updated = IW_QUAL_ALL_INVALID;
> +
> + kfree(cmd);
> + pr_debug("%s: ->\n", __func__);
> + return is;
> +}
> +
> +/*
> + * scanning helpers
> + */
> +static int gelic_wl_start_scan(struct gelic_wl_info *wl, int always_scan)
> +{
> + struct gelic_eurus_cmd *cmd;
> + int ret = 0;
> +
> + pr_debug("%s: <- always=%d\n", __func__, always_scan);
> + if (down_interruptible(&wl->scan_lock))
> + return -ERESTARTSYS;
> +
> + /*
> + * If already a scan in progress, do not trigger more
> + */
> + if (wl->scan_stat == GELIC_WL_SCAN_STAT_SCANNING) {
> + pr_debug("%s: scanning now\n", __func__);
> + goto out;
> + }
> +
> + init_completion(&wl->scan_done);
> + /*
> + * If we have already a bss list, don't try to get new
> + */
> + if (!always_scan && wl->scan_stat == GELIC_WL_SCAN_STAT_GOT_LIST) {
> + pr_debug("%s: already has the list\n", __func__);
> + complete(&wl->scan_done);
> + goto out;
> + }
> + /*
> + * issue start scan request
> + */
> + wl->scan_stat = GELIC_WL_SCAN_STAT_SCANNING;
> + cmd = gelic_eurus_sync_cmd(wl, GELIC_EURUS_CMD_START_SCAN,
> + NULL, 0);
> + if (!cmd || cmd->status || cmd->cmd_status) {
> + wl->scan_stat = GELIC_WL_SCAN_STAT_INIT;
> + complete(&wl->scan_done);
> + ret = -ENOMEM;
> + goto out;
> + }
> + kfree(cmd);
> +out:
> + up(&wl->scan_lock);
> + pr_debug("%s: ->\n", __func__);
> + return ret;
> +}
> +
> +/*
> + * retrieve scan result from the chip (hypervisor)
> + * this function is invoked by schedule work.
> + */
> +static void gelic_wl_scan_complete_event(struct gelic_wl_info *wl)
> +{
> + struct gelic_eurus_cmd *cmd = NULL;
> + struct gelic_wl_scan_info *target, *tmp;
> + struct gelic_wl_scan_info *oldest = NULL;
> + struct gelic_eurus_scan_info *scan_info;
> + unsigned int scan_info_size;
> + union iwreq_data data;
> + unsigned long this_time = jiffies;
> + unsigned int data_len, i, found, r;
> + DECLARE_MAC_BUF(mac);
> +
> + pr_debug("%s:start\n", __func__);
> + down(&wl->scan_lock);
> +
> + if (wl->scan_stat != GELIC_WL_SCAN_STAT_SCANNING) {
> + /*
> + * stop() may be called while scanning, ignore result
> + */
> + pr_debug("%s: scan complete when stat != scanning(%d)\n",
> + __func__, wl->scan_stat);
> + goto out;
> + }
> +
> + cmd = gelic_eurus_sync_cmd(wl, GELIC_EURUS_CMD_GET_SCAN,
> + wl->buf, PAGE_SIZE);
> + if (!cmd || cmd->status || cmd->cmd_status) {
> + wl->scan_stat = GELIC_WL_SCAN_STAT_INIT;
> + pr_info("%s:cmd failed\n", __func__);
> + kfree(cmd);
> + goto out;
> + }
> + data_len = cmd->size;
> + pr_debug("%s: data_len = %d\n", __func__, data_len);
> + kfree(cmd);
> +
> + /* OK, bss list retrieved */
> + wl->scan_stat = GELIC_WL_SCAN_STAT_GOT_LIST;
> +
> + /* mark all entries are old */
> + list_for_each_entry_safe(target, tmp, &wl->network_list, list) {
> + target->valid = 0;
> + /* expire too old entries */
> + if (time_before(target->last_scanned + wl->scan_age,
> + this_time)) {
> + kfree(target->hwinfo);
> + target->hwinfo = NULL;
> + list_move_tail(&target->list, &wl->network_free_list);
> + }
> + }
> +
> + /* put them in the newtork_list */
> + scan_info = wl->buf;
> + scan_info_size = 0;
> + i = 0;
> + while (scan_info_size < data_len) {
> + pr_debug("%s:size=%d bssid=%s scan_info=%p\n", __func__,
> + be16_to_cpu(scan_info->size),
> + print_mac(mac, &scan_info->bssid[2]), scan_info);
> + found = 0;
> + oldest = NULL;
> + list_for_each_entry(target, &wl->network_list, list) {
> + if (!compare_ether_addr(&target->hwinfo->bssid[2],
> + &scan_info->bssid[2])) {
> + found = 1;
> + pr_debug("%s: same BBS found scanned list\n",
> + __func__);
> + break;
> + }
> + if (!oldest ||
> + (target->last_scanned < oldest->last_scanned))
> + oldest = target;
> + }
> +
> + if (!found) {
> + /* not found in the list */
> + if (list_empty(&wl->network_free_list)) {
> + /* expire oldest */
> + target = oldest;
> + } else {
> + target = list_entry(wl->network_free_list.next,
> + struct gelic_wl_scan_info,
> + list);
> + }
> + }
> +
> + /* update the item */
> + target->last_scanned = this_time;
> + target->valid = 1;
> + target->eurus_index = i;
> + kfree(target->hwinfo);
> + target->hwinfo = kzalloc(be16_to_cpu(scan_info->size),
> + GFP_KERNEL);
> + if (!target->hwinfo) {
> + pr_info("%s: kzalloc failed\n", __func__);
> + i++;
> + scan_info_size += be16_to_cpu(scan_info->size);
> + scan_info = (void *)scan_info +
> + be16_to_cpu(scan_info->size);
> + continue;
> + }
> + /* copy hw scan info */
> + memcpy(target->hwinfo, scan_info, scan_info->size);
> + target->essid_len = strnlen(scan_info->essid,
> + sizeof(scan_info->essid));
> + target->rate_len = 0;
> + for (r = 0; r < MAX_RATES_LENGTH; r++)
> + if (scan_info->rate[r])
> + target->rate_len++;
> + if (8 < target->rate_len)
> + pr_info("%s: AP returns %d rates\n", __func__,
> + target->rate_len);
> + target->rate_ext_len = 0;
> + for (r = 0; r < MAX_RATES_EX_LENGTH; r++)
> + if (scan_info->ext_rate[r])
> + target->rate_ext_len++;
> + list_move_tail(&target->list, &wl->network_list);
> + /* bump pointer */
> + i++;
> + scan_info_size += be16_to_cpu(scan_info->size);
> + scan_info = (void *)scan_info + be16_to_cpu(scan_info->size);
> + }
> + memset(&data, 0, sizeof(data));
> + wireless_send_event(port_to_netdev(wl_port(wl)), SIOCGIWSCAN, &data,
> + NULL);
> +out:
> + complete(&wl->scan_done);
> + up(&wl->scan_lock);
> + pr_debug("%s:end\n", __func__);
> +}
> +
> +/*
> + * Select an appropriate bss from current scan list regarding
> + * current settings from userspace.
> + * The caller must hold wl->scan_lock,
> + * and on the state of wl->scan_state == GELIC_WL_SCAN_GOT_LIST
> + */
> +static void update_best(struct gelic_wl_scan_info **best,
> + struct gelic_wl_scan_info *candid,
> + int *best_weight,
> + int *weight)
> +{
> + if (*best_weight < ++(*weight)) {
> + *best_weight = *weight;
> + *best = candid;
> + }
> +}
> +
> +static
> +struct gelic_wl_scan_info *gelic_wl_find_best_bss(struct gelic_wl_info *wl)
> +{
> + struct gelic_wl_scan_info *scan_info;
> + struct gelic_wl_scan_info *best_bss;
> + int weight, best_weight;
> + u16 security;
> + DECLARE_MAC_BUF(mac);
> +
> + pr_debug("%s: <-\n", __func__);
> +
> + best_bss = NULL;
> + best_weight = 0;
> +
> + list_for_each_entry(scan_info, &wl->network_list, list) {
> + pr_debug("%s: station %p\n", __func__, scan_info);
> +
> + if (!scan_info->valid) {
> + pr_debug("%s: station invalid\n", __func__);
> + continue;
> + }
> +
> + /* If bss specified, check it only */
> + if (test_bit(GELIC_WL_STAT_BSSID_SET, &wl->stat)) {
> + if (!compare_ether_addr(&scan_info->hwinfo->bssid[2],
> + wl->bssid)) {
> + best_bss = scan_info;
> + pr_debug("%s: bssid matched\n", __func__);
> + break;
> + } else {
> + pr_debug("%s: bssid unmached\n", __func__);
> + continue;
> + }
> + }
> +
> + weight = 0;
> +
> + /* security */
> + security = be16_to_cpu(scan_info->hwinfo->security) &
> + GELIC_EURUS_SCAN_SEC_MASK;
> + if (wl->wpa_level == GELIC_WL_WPA_LEVEL_WPA2) {
> + if (security == GELIC_EURUS_SCAN_SEC_WPA2)
> + update_best(&best_bss, scan_info,
> + &best_weight, &weight);
> + else
> + continue;
> + } else if (wl->wpa_level == GELIC_WL_WPA_LEVEL_WPA) {
> + if (security == GELIC_EURUS_SCAN_SEC_WPA)
> + update_best(&best_bss, scan_info,
> + &best_weight, &weight);
> + else
> + continue;
> + } else if (wl->wpa_level == GELIC_WL_WPA_LEVEL_NONE &&
> + wl->group_cipher_method == GELIC_WL_CIPHER_WEP) {
> + if (security == GELIC_EURUS_SCAN_SEC_WEP)
> + update_best(&best_bss, scan_info,
> + &best_weight, &weight);
> + else
> + continue;
> + }
> +
> + /* If ESSID is set, check it */
> + if (test_bit(GELIC_WL_STAT_ESSID_SET, &wl->stat)) {
> + if ((scan_info->essid_len == wl->essid_len) &&
> + !strncmp(wl->essid,
> + scan_info->hwinfo->essid,
> + scan_info->essid_len))
> + update_best(&best_bss, scan_info,
> + &best_weight, &weight);
> + else
> + continue;
> + }
> + }
> +
> +#ifdef DEBUG
> + pr_debug("%s: -> bss=%p\n", __func__, best_bss);
> + if (best_bss) {
> + pr_debug("%s:addr=%s\n", __func__,
> + print_mac(mac, &best_bss->hwinfo->bssid[2]));
> + }
> +#endif
> + return best_bss;
> +}
> +
> +/*
> + * Setup WEP configuration to the chip
> + * The caller must hold wl->scan_lock,
> + * and on the state of wl->scan_state == GELIC_WL_SCAN_GOT_LIST
> + */
> +static int gelic_wl_do_wep_setup(struct gelic_wl_info *wl)
> +{
> + unsigned int i;
> + struct gelic_eurus_wep_cfg *wep;
> + struct gelic_eurus_cmd *cmd;
> + int wep104 = 0;
> + int have_key = 0;
> + int ret = 0;
> +
> + pr_debug("%s: <-\n", __func__);
> + /* we can assume no one should uses the buffer */
> + wep = wl->buf;
> + memset(wep, 0, sizeof(*wep));
> +
> + if (wl->group_cipher_method == GELIC_WL_CIPHER_WEP) {
> + pr_debug("%s: WEP mode\n", __func__);
> + for (i = 0; i < GELIC_WEP_KEYS; i++) {
> + if (!test_bit(i, &wl->key_enabled))
> + continue;
> +
> + pr_debug("%s: key#%d enabled\n", __func__, i);
> + have_key = 1;
> + if (wl->key_len[i] == 13)
> + wep104 = 1;
> + else if (wl->key_len[i] != 5) {
> + pr_info("%s: wrong wep key[%d]=%d\n",
> + __func__, i, wl->key_len[i]);
> + ret = -EINVAL;
> + goto out;
> + }
> + memcpy(wep->key[i], wl->key[i], wl->key_len[i]);
> + }
> +
> + if (!have_key) {
> + pr_info("%s: all wep key disabled\n", __func__);
> + ret = -EINVAL;
> + goto out;
> + }
> +
> + if (wep104) {
> + pr_debug("%s: 104bit key\n", __func__);
> + wep->security = cpu_to_be16(GELIC_EURUS_WEP_SEC_104BIT);
> + } else {
> + pr_debug("%s: 40bit key\n", __func__);
> + wep->security = cpu_to_be16(GELIC_EURUS_WEP_SEC_40BIT);
> + }
> + } else {
> + pr_debug("%s: NO encryption\n", __func__);
> + wep->security = cpu_to_be16(GELIC_EURUS_WEP_SEC_NONE);
> + }
> +
> + /* issue wep setup */
> + cmd = gelic_eurus_sync_cmd(wl, GELIC_EURUS_CMD_SET_WEP_CFG,
> + wep, sizeof(*wep));
> + if (!cmd)
> + ret = -ENOMEM;
> + else if (cmd->status || cmd->cmd_status)
> + ret = -ENXIO;
> +
> + kfree(cmd);
> +out:
> + pr_debug("%s: ->\n", __func__);
> + return ret;
> +}
> +
> +#ifdef DEBUG
> +static const char *wpasecstr(enum gelic_eurus_wpa_security sec)
> +{
> + switch (sec) {
> + case GELIC_EURUS_WPA_SEC_NONE:
> + return "NONE";
> + break;
> + case GELIC_EURUS_WPA_SEC_WPA_TKIP_TKIP:
> + return "WPA_TKIP_TKIP";
> + break;
> + case GELIC_EURUS_WPA_SEC_WPA_TKIP_AES:
> + return "WPA_TKIP_AES";
> + break;
> + case GELIC_EURUS_WPA_SEC_WPA_AES_AES:
> + return "WPA_AES_AES";
> + break;
> + case GELIC_EURUS_WPA_SEC_WPA2_TKIP_TKIP:
> + return "WPA2_TKIP_TKIP";
> + break;
> + case GELIC_EURUS_WPA_SEC_WPA2_TKIP_AES:
> + return "WPA2_TKIP_AES";
> + break;
> + case GELIC_EURUS_WPA_SEC_WPA2_AES_AES:
> + return "WPA2_AES_AES";
> + break;
> + }
> + return "";
> +};
> +#endif
> +
> +static int gelic_wl_do_wpa_setup(struct gelic_wl_info *wl)
> +{
> + struct gelic_eurus_wpa_cfg *wpa;
> + struct gelic_eurus_cmd *cmd;
> + u16 security;
> + int ret = 0;
> +
> + pr_debug("%s: <-\n", __func__);
> + /* we can assume no one should uses the buffer */
> + wpa = wl->buf;
> + memset(wpa, 0, sizeof(*wpa));
> +
> + if (!test_bit(GELIC_WL_STAT_WPA_PSK_SET, &wl->stat))
> + pr_info("%s: PSK not configured yet\n", __func__);
> +
> + /* copy key */
> + memcpy(wpa->psk, wl->psk, wl->psk_len);
> +
> + /* set security level */
> + if (wl->wpa_level == GELIC_WL_WPA_LEVEL_WPA2) {
> + if (wl->group_cipher_method == GELIC_WL_CIPHER_AES) {
> + security = GELIC_EURUS_WPA_SEC_WPA2_AES_AES;
> + } else {
> + if (wl->pairwise_cipher_method == GELIC_WL_CIPHER_AES &&
> + precise_ie())
> + security = GELIC_EURUS_WPA_SEC_WPA2_TKIP_AES;
> + else
> + security = GELIC_EURUS_WPA_SEC_WPA2_TKIP_TKIP;
> + }
> + } else {
> + if (wl->group_cipher_method == GELIC_WL_CIPHER_AES) {
> + security = GELIC_EURUS_WPA_SEC_WPA_AES_AES;
> + } else {
> + if (wl->pairwise_cipher_method == GELIC_WL_CIPHER_AES &&
> + precise_ie())
> + security = GELIC_EURUS_WPA_SEC_WPA_TKIP_AES;
> + else
> + security = GELIC_EURUS_WPA_SEC_WPA_TKIP_TKIP;
> + }
> + }
> + wpa->security = cpu_to_be16(security);
> +
> + /* PSK type */
> + wpa->psk_type = cpu_to_be16(wl->psk_type);
> +#ifdef DEBUG
> + pr_debug("%s: sec=%s psktype=%s\nn", __func__,
> + wpasecstr(wpa->security),
> + (wpa->psk_type == GELIC_EURUS_WPA_PSK_BIN) ?
> + "BIN" : "passphrase");
> +#if 0
> + /*
> + * don't enable here if you plan to submit
> + * the debug log because this dumps your precious
> + * passphrase/key.
> + */
> + pr_debug("%s: psk=%s\n",
> + (wpa->psk_type == GELIC_EURUS_WPA_PSK_BIN) ?
> + (char *)"N/A" : (char *)wpa->psk);
> +#endif
> +#endif
> + /* issue wpa setup */
> + cmd = gelic_eurus_sync_cmd(wl, GELIC_EURUS_CMD_SET_WPA_CFG,
> + wpa, sizeof(*wpa));
> + if (!cmd)
> + ret = -ENOMEM;
> + else if (cmd->status || cmd->cmd_status)
> + ret = -ENXIO;
> + kfree(cmd);
> + pr_debug("%s: --> %d\n", __func__, ret);
> + return ret;
> +}
> +
> +/*
> + * Start association. caller must hold assoc_stat_lock
> + */
> +static int gelic_wl_associate_bss(struct gelic_wl_info *wl,
> + struct gelic_wl_scan_info *bss)
> +{
> + struct gelic_eurus_cmd *cmd;
> + struct gelic_eurus_common_cfg *common;
> + int ret = 0;
> + unsigned long rc;
> +
> + pr_debug("%s: <-\n", __func__);
> +
> + /* do common config */
> + common = wl->buf;
> + memset(common, 0, sizeof(*common));
> + common->bss_type = cpu_to_be16(GELIC_EURUS_BSS_INFRA);
> + common->op_mode = cpu_to_be16(GELIC_EURUS_OPMODE_11BG);
> +
> + common->scan_index = cpu_to_be16(bss->eurus_index);
> + switch (wl->auth_method) {
> + case GELIC_EURUS_AUTH_OPEN:
> + common->auth_method = cpu_to_be16(GELIC_EURUS_AUTH_OPEN);
> + break;
> + case GELIC_EURUS_AUTH_SHARED:
> + common->auth_method = cpu_to_be16(GELIC_EURUS_AUTH_SHARED);
> + break;
> + }
> +
> +#ifdef DEBUG
> + scan_list_dump(wl);
> +#endif
> + pr_debug("%s: common cfg index=%d bsstype=%d auth=%d\n", __func__,
> + be16_to_cpu(common->scan_index),
> + be16_to_cpu(common->bss_type),
> + be16_to_cpu(common->auth_method));
> +
> + cmd = gelic_eurus_sync_cmd(wl, GELIC_EURUS_CMD_SET_COMMON_CFG,
> + common, sizeof(*common));
> + if (!cmd || cmd->status || cmd->cmd_status) {
> + ret = -ENOMEM;
> + kfree(cmd);
> + goto out;
> + }
> + kfree(cmd);
> +
> + /* WEP/WPA */
> + switch (wl->wpa_level) {
> + case GELIC_WL_WPA_LEVEL_NONE:
> + /* If WEP or no security, setup WEP config */
> + ret = gelic_wl_do_wep_setup(wl);
> + break;
> + case GELIC_WL_WPA_LEVEL_WPA:
> + case GELIC_WL_WPA_LEVEL_WPA2:
> + ret = gelic_wl_do_wpa_setup(wl);
> + break;
> + };
> +
> + if (ret) {
> + pr_debug("%s: WEP/WPA setup failed %d\n", __func__,
> + ret);
> + }
> +
> + /* start association */
> + init_completion(&wl->assoc_done);
> + wl->assoc_stat = GELIC_WL_ASSOC_STAT_ASSOCIATING;
> + cmd = gelic_eurus_sync_cmd(wl, GELIC_EURUS_CMD_ASSOC,
> + NULL, 0);
> + if (!cmd || cmd->status || cmd->cmd_status) {
> + pr_debug("%s: assoc request failed\n", __func__);
> + wl->assoc_stat = GELIC_WL_ASSOC_STAT_DISCONN;
> + kfree(cmd);
> + ret = -ENOMEM;
> + goto out;
> + }
> + kfree(cmd);
> +
> + /* wait for connected event */
> + rc = wait_for_completion_timeout(&wl->assoc_done, HZ * 4);/*FIXME*/
> +
> + if (!rc) {
> + /* timeouted. Maybe key or cyrpt mode is wrong */
> + pr_info("%s: connect timeout \n", __func__);
> + cmd = gelic_eurus_sync_cmd(wl, GELIC_EURUS_CMD_DISASSOC,
> + NULL, 0);
> + kfree(cmd);
> + wl->assoc_stat = GELIC_WL_ASSOC_STAT_DISCONN;
> + ret = -ENXIO;
> + } else {
> + union iwreq_data data;
> +
> + wl->assoc_stat = GELIC_WL_ASSOC_STAT_ASSOCIATED;
> + /* copy bssid */
> + memcpy(wl->active_bssid, &bss->hwinfo->bssid[2], ETH_ALEN);
> +
> + /* send event */
> + memset(&data, 0, sizeof(data));
> + memcpy(data.ap_addr.sa_data, wl->active_bssid, ETH_ALEN);
> + data.ap_addr.sa_family = ARPHRD_ETHER;
> + wireless_send_event(port_to_netdev(wl_port(wl)), SIOCGIWAP,
> + &data, NULL);
> + pr_info("%s: connected\n", __func__);
> + }
> +out:
> + pr_debug("%s: ->\n", __func__);
> + return ret;
> +}
> +
> +/*
> + * connected event
> + */
> +static void gelic_wl_connected_event(struct gelic_wl_info *wl,
> + u64 event)
> +{
> + u64 desired_event = 0;
> +
> + switch (wl->wpa_level) {
> + case GELIC_WL_WPA_LEVEL_NONE:
> + desired_event = GELIC_LV1_WL_EVENT_CONNECTED;
> + break;
> + case GELIC_WL_WPA_LEVEL_WPA:
> + case GELIC_WL_WPA_LEVEL_WPA2:
> + desired_event = GELIC_LV1_WL_EVENT_WPA_CONNECTED;
> + break;
> + }
> +
> + if (desired_event == event) {
> + pr_debug("%s: completed \n", __func__);
> + complete(&wl->assoc_done);
> + netif_carrier_on(port_to_netdev(wl_port(wl)));
> + } else
> + pr_debug("%s: event %#lx under wpa\n",
> + __func__, event);
> +}
> +
> +/*
> + * disconnect event
> + */
> +static void gelic_wl_disconnect_event(struct gelic_wl_info *wl,
> + u64 event)
> +{
> + struct gelic_eurus_cmd *cmd;
> + union iwreq_data data;
> + int lock;
> +
> + /*
> + * If we fall here in the middle of association,
> + * associate_bss() should be waiting for complation of
> + * wl->assoc_done.
> + * As it waits with timeout, just leave assoc_done
> + * uncompleted, then it terminates with timeout
> + */
> + if (down_trylock(&wl->assoc_stat_lock)) {
> + pr_debug("%s: already locked\n", __func__);
> + lock = 0;
> + } else {
> + pr_debug("%s: obtain lock\n", __func__);
> + lock = 1;
> + }
> +
> + cmd = gelic_eurus_sync_cmd(wl, GELIC_EURUS_CMD_DISASSOC, NULL, 0);
> + kfree(cmd);
> +
> + /* send disconnected event to the supplicant */
> + if (wl->assoc_stat == GELIC_WL_ASSOC_STAT_ASSOCIATED) {
> + memset(&data, 0, sizeof(data));
> + data.ap_addr.sa_family = ARPHRD_ETHER;
> + wireless_send_event(port_to_netdev(wl_port(wl)), SIOCGIWAP,
> + &data, NULL);
> + }
> + wl->assoc_stat = GELIC_WL_ASSOC_STAT_DISCONN;
> + netif_carrier_off(port_to_netdev(wl_port(wl)));
> +
> + if (lock)
> + up(&wl->assoc_stat_lock);
> +}
> +/*
> + * event worker
> + */
> +#ifdef DEBUG
> +static const char *eventstr(enum gelic_lv1_wl_event event)
> +{
> + static char buf[32];
> + char *ret;
> + if (event & GELIC_LV1_WL_EVENT_DEVICE_READY)
> + ret = "EURUS_READY";
> + else if (event & GELIC_LV1_WL_EVENT_SCAN_COMPLETED)
> + ret = "SCAN_COMPLETED";
> + else if (event & GELIC_LV1_WL_EVENT_DEAUTH)
> + ret = "DEAUTH";
> + else if (event & GELIC_LV1_WL_EVENT_BEACON_LOST)
> + ret = "BEACON_LOST";
> + else if (event & GELIC_LV1_WL_EVENT_CONNECTED)
> + ret = "CONNECTED";
> + else if (event & GELIC_LV1_WL_EVENT_WPA_CONNECTED)
> + ret = "WPA_CONNECTED";
> + else if (event & GELIC_LV1_WL_EVENT_WPA_ERROR)
> + ret = "WPA_ERROR";
> + else {
> + sprintf(buf, "Unknown(%#x)", event);
> + ret = buf;
> + }
> + return ret;
> +}
> +#else
> +static const char *eventstr(enum gelic_lv1_wl_event event)
> +{
> + return 0;
> +}
> +#endif
> +static void gelic_wl_event_worker(struct work_struct *work)
> +{
> + struct gelic_wl_info *wl;
> + struct gelic_port *port;
> + u64 event, tmp;
> + int status;
> +
> + pr_debug("%s:start\n", __func__);
> + wl = container_of(work, struct gelic_wl_info, event_work.work);
> + port = wl_port(wl);
> + while (1) {
> + status = lv1_net_control(bus_id(port->card), dev_id(port->card),
> + GELIC_LV1_GET_WLAN_EVENT, 0, 0, 0,
> + &event, &tmp);
> + if (status) {
> + if (status != LV1_NO_ENTRY)
> + pr_debug("%s:wlan event failed %d\n",
> + __func__, status);
> + /* got all events */
> + pr_debug("%s:end\n", __func__);
> + return;
> + }
> + pr_debug("%s: event=%s\n", __func__, eventstr(event));
> + switch (event) {
> + case GELIC_LV1_WL_EVENT_SCAN_COMPLETED:
> + gelic_wl_scan_complete_event(wl);
> + break;
> + case GELIC_LV1_WL_EVENT_BEACON_LOST:
> + case GELIC_LV1_WL_EVENT_DEAUTH:
> + gelic_wl_disconnect_event(wl, event);
> + break;
> + case GELIC_LV1_WL_EVENT_CONNECTED:
> + case GELIC_LV1_WL_EVENT_WPA_CONNECTED:
> + gelic_wl_connected_event(wl, event);
> + break;
> + default:
> + break;
> + }
> + } /* while */
> +}
> +/*
> + * association worker
> + */
> +static void gelic_wl_assoc_worker(struct work_struct *work)
> +{
> + struct gelic_wl_info *wl;
> +
> + struct gelic_wl_scan_info *best_bss;
> + int ret;
> +
> + wl = container_of(work, struct gelic_wl_info, assoc_work.work);
> +
> + down(&wl->assoc_stat_lock);
> +
> + if (wl->assoc_stat != GELIC_WL_ASSOC_STAT_DISCONN)
> + goto out;
> +
> + ret = gelic_wl_start_scan(wl, 0);
> + if (ret == -ERESTARTSYS) {
> + pr_debug("%s: scan start failed association\n", __func__);
> + schedule_delayed_work(&wl->assoc_work, HZ/10); /*FIXME*/
> + goto out;
> + } else if (ret) {
> + pr_info("%s: scan prerequisite failed\n", __func__);
> + goto out;
> + }
> +
> + /*
> + * Wait for bss scan completion
> + * If we have scan list already, gelic_wl_start_scan()
> + * returns OK and raises the complete. Thus,
> + * it's ok to wait unconditionally here
> + */
> + wait_for_completion(&wl->scan_done);
> +
> + pr_debug("%s: scan done\n", __func__);
> + down(&wl->scan_lock);
> + if (wl->scan_stat != GELIC_WL_SCAN_STAT_GOT_LIST) {
> + pr_info("%s: no scan list. association failed\n", __func__);
> + goto scan_lock_out;
> + }
> +
> + /* find best matching bss */
> + best_bss = gelic_wl_find_best_bss(wl);
> + if (!best_bss) {
> + pr_info("%s: no bss matched. association failed\n", __func__);
> + goto scan_lock_out;
> + }
> +
> + /* ok, do association */
> + ret = gelic_wl_associate_bss(wl, best_bss);
> + if (ret)
> + pr_info("%s: association failed %d\n", __func__, ret);
> +scan_lock_out:
> + up(&wl->scan_lock);
> +out:
> + up(&wl->assoc_stat_lock);
> +}
> +/*
> + * Interrupt handler
> + * Called from the ethernet interrupt handler
> + * Processes wireless specific virtual interrupts only
> + */
> +void gelic_wl_interrupt(struct net_device *netdev, u64 status)
> +{
> + struct gelic_wl_info *wl = port_wl(netdev_priv(netdev));
> +
> + if (status & GELIC_CARD_WLAN_COMMAND_COMPLETED) {
> + pr_debug("%s:cmd complete\n", __func__);
> + complete(&wl->cmd_done_intr);
> + }
> +
> + if (status & GELIC_CARD_WLAN_EVENT_RECEIVED) {
> + pr_debug("%s:event received\n", __func__);
> + queue_delayed_work(wl->event_queue, &wl->event_work, 0);
> + }
> +}
> +/*
> + * driver helpers
> + */
> +#define IW_IOCTL(n) [(n) - SIOCSIWCOMMIT]
> +static const iw_handler gelic_wl_wext_handler[] =
> +{
> + IW_IOCTL(SIOCGIWNAME) = gelic_wl_get_name,
> + IW_IOCTL(SIOCGIWRANGE) = gelic_wl_get_range,
> + IW_IOCTL(SIOCSIWSCAN) = gelic_wl_set_scan,
> + IW_IOCTL(SIOCGIWSCAN) = gelic_wl_get_scan,
> + IW_IOCTL(SIOCSIWAUTH) = gelic_wl_set_auth,
> + IW_IOCTL(SIOCGIWAUTH) = gelic_wl_get_auth,
> + IW_IOCTL(SIOCSIWESSID) = gelic_wl_set_essid,
> + IW_IOCTL(SIOCGIWESSID) = gelic_wl_get_essid,
> + IW_IOCTL(SIOCSIWENCODE) = gelic_wl_set_encode,
> + IW_IOCTL(SIOCGIWENCODE) = gelic_wl_get_encode,
> + IW_IOCTL(SIOCSIWAP) = gelic_wl_set_ap,
> + IW_IOCTL(SIOCGIWAP) = gelic_wl_get_ap,
> + IW_IOCTL(SIOCSIWENCODEEXT) = gelic_wl_set_encodeext,
> + IW_IOCTL(SIOCGIWENCODEEXT) = gelic_wl_get_encodeext,
> + IW_IOCTL(SIOCSIWMODE) = gelic_wl_set_mode,
> + IW_IOCTL(SIOCGIWMODE) = gelic_wl_get_mode,
> + IW_IOCTL(SIOCGIWNICKN) = gelic_wl_get_nick,
> +};
> +
> +static struct iw_priv_args gelic_wl_private_args[] =
> +{
> + {
> + .cmd = GELIC_WL_PRIV_SET_PSK,
> + .set_args = IW_PRIV_TYPE_CHAR |
> + (GELIC_WL_EURUS_PSK_MAX_LEN + 2),
> + .name = "set_psk"
> + },
> + {
> + .cmd = GELIC_WL_PRIV_GET_PSK,
> + .get_args = IW_PRIV_TYPE_CHAR |
> + (GELIC_WL_EURUS_PSK_MAX_LEN + 2),
> + .name = "get_psk"
> + }
> +};
> +
> +static const iw_handler gelic_wl_private_handler[] =
> +{
> + gelic_wl_priv_set_psk,
> + gelic_wl_priv_get_psk,
> +};
> +
> +static const struct iw_handler_def gelic_wl_wext_handler_def = {
> + .num_standard = ARRAY_SIZE(gelic_wl_wext_handler),
> + .standard = gelic_wl_wext_handler,
> + .get_wireless_stats = gelic_wl_get_wireless_stats,
> + .num_private = ARRAY_SIZE(gelic_wl_private_handler),
> + .num_private_args = ARRAY_SIZE(gelic_wl_private_args),
> + .private = gelic_wl_private_handler,
> + .private_args = gelic_wl_private_args,
> +};
> +
> +static struct net_device *gelic_wl_alloc(struct gelic_card *card)
> +{
> + struct net_device *netdev;
> + struct gelic_port *port;
> + struct gelic_wl_info *wl;
> + unsigned int i;
> +
> + pr_debug("%s:start\n", __func__);
> + netdev = alloc_etherdev(sizeof(struct gelic_port) +
> + sizeof(struct gelic_wl_info));
> + pr_debug("%s: netdev =%p card=%p \np", __func__, netdev, card);
> + if (!netdev)
> + return NULL;
> +
> + port = netdev_priv(netdev);
> + port->netdev = netdev;
> + port->card = card;
> + port->type = GELIC_PORT_WIRELESS;
> +
> + wl = port_wl(port);
> + pr_debug("%s: wl=%p port=%p\n", __func__, wl, port);
> +
> + /* allocate scan list */
> + wl->networks = kzalloc(sizeof(struct gelic_wl_scan_info) *
> + GELIC_WL_BSS_MAX_ENT, GFP_KERNEL);
> +
> + if (!wl->networks)
> + goto fail_bss;
> +
> + wl->eurus_cmd_queue = create_singlethread_workqueue("gelic_cmd");
> + if (!wl->eurus_cmd_queue)
> + goto fail_cmd_workqueue;
> +
> + wl->event_queue = create_singlethread_workqueue("gelic_event");
> + if (!wl->event_queue)
> + goto fail_event_workqueue;
> +
> + INIT_LIST_HEAD(&wl->network_free_list);
> + INIT_LIST_HEAD(&wl->network_list);
> + for (i = 0; i < GELIC_WL_BSS_MAX_ENT; i++)
> + list_add_tail(&wl->networks[i].list,
> + &wl->network_free_list);
> + init_completion(&wl->cmd_done_intr);
> +
> + INIT_DELAYED_WORK(&wl->event_work, gelic_wl_event_worker);
> + INIT_DELAYED_WORK(&wl->assoc_work, gelic_wl_assoc_worker);
> + init_MUTEX(&wl->scan_lock);
> + init_MUTEX(&wl->assoc_stat_lock);
> +
> + init_completion(&wl->scan_done);
> + /* for the case that no scan request is issued and stop() is called */
> + complete(&wl->scan_done);
> +
> + spin_lock_init(&wl->lock);
> +
> + wl->scan_age = 5*HZ; /* FIXME */
> +
> + /* buffer for receiving scanned list etc */
> + BUILD_BUG_ON(PAGE_SIZE <
> + sizeof(struct gelic_eurus_scan_info) *
> + GELIC_EURUS_MAX_SCAN);
> + wl->buf = (void *)get_zeroed_page(GFP_KERNEL);
> + if (!wl->buf) {
> + pr_info("%s:buffer allocation failed\n", __func__);
> + goto fail_getpage;
> + }
> + pr_debug("%s:end\n", __func__);
> + return netdev;
> +
> +fail_getpage:
> + destroy_workqueue(wl->event_queue);
> +fail_event_workqueue:
> + destroy_workqueue(wl->eurus_cmd_queue);
> +fail_cmd_workqueue:
> + kfree(wl->networks);
> +fail_bss:
> + free_netdev(netdev);
> + pr_debug("%s:end error\n", __func__);
> + return NULL;
> +
> +}
> +
> +void gelic_wl_free(struct gelic_wl_info *wl)
> +{
> + struct gelic_wl_scan_info *scan_info;
> + unsigned int i;
> +
> + pr_debug("%s: <-\n", __func__);
> +
> + pr_debug("%s: destroy queues\n", __func__);
> + destroy_workqueue(wl->eurus_cmd_queue);
> + destroy_workqueue(wl->event_queue);
> +
> + scan_info = wl->networks;
> + for (i = 0; i < GELIC_WL_BSS_MAX_ENT; i++, scan_info++)
> + kfree(scan_info->hwinfo);
> + kfree(wl->networks);
> +
> + free_netdev(port_to_netdev(wl_port(wl)));
> +
> + pr_debug("%s: ->\n", __func__);
> +}
> +
> +int gelic_wl_try_associate(struct net_device *netdev)
> +{
> + struct gelic_wl_info *wl = port_wl(netdev_priv(netdev));
> + int ret = -1;
> + unsigned int i;
> +
> + pr_debug("%s: <-\n", __func__);
> +
> + /* check constraits for start association */
> + /* for no access restriction AP */
> + if (wl->group_cipher_method == GELIC_WL_CIPHER_NONE) {
> + if (test_bit(GELIC_WL_STAT_CONFIGURED,
> + &wl->stat))
> + goto do_associate;
> + else {
> + pr_debug("%s: no wep, not configured\n", __func__);
> + return ret;
> + }
> + }
> +
> + /* for WEP, one of four keys should be set */
> + if (wl->group_cipher_method == GELIC_WL_CIPHER_WEP) {
> + /* one of keys set */
> + for (i = 0; i < GELIC_WEP_KEYS; i++) {
> + if (test_bit(i, &wl->key_enabled))
> + goto do_associate;
> + }
> + pr_debug("%s: WEP, but no key specified\n", __func__);
> + return ret;
> + }
> +
> + /* for WPA[2], psk should be set */
> + if ((wl->group_cipher_method == GELIC_WL_CIPHER_TKIP) ||
> + (wl->group_cipher_method == GELIC_WL_CIPHER_AES)) {
> + if (test_bit(GELIC_WL_STAT_WPA_PSK_SET,
> + &wl->stat))
> + goto do_associate;
> + else {
> + pr_debug("%s: AES/TKIP, but PSK not configured\n",
> + __func__);
> + return ret;
> + }
> + }
> +
> +do_associate:
> + ret = schedule_delayed_work(&wl->assoc_work, 0);
> + pr_debug("%s: start association work %d\n", __func__, ret);
> + return ret;
> +}
> +
> +/*
> + * netdev handlers
> + */
> +static int gelic_wl_open(struct net_device *netdev)
> +{
> + struct gelic_card *card = netdev_card(netdev);
> +
> + pr_debug("%s:->%p\n", __func__, netdev);
> +
> + gelic_card_up(card);
> +
> + /* try to associate */
> + gelic_wl_try_associate(netdev);
> +
> + netif_start_queue(netdev);
> +
> + pr_debug("%s:<-\n", __func__);
> + return 0;
> +}
> +
> +/*
> + * reset state machine
> + */
> +static int gelic_wl_reset_state(struct gelic_wl_info *wl)
> +{
> + struct gelic_wl_scan_info *target;
> + struct gelic_wl_scan_info *tmp;
> +
> + /* empty scan list */
> + list_for_each_entry_safe(target, tmp, &wl->network_list, list) {
> + list_move_tail(&target->list, &wl->network_free_list);
> + }
> + wl->scan_stat = GELIC_WL_SCAN_STAT_INIT;
> +
> + /* clear configuration */
> + wl->auth_method = GELIC_EURUS_AUTH_OPEN;
> + wl->group_cipher_method = GELIC_WL_CIPHER_NONE;
> + wl->pairwise_cipher_method = GELIC_WL_CIPHER_NONE;
> + wl->wpa_level = GELIC_WL_WPA_LEVEL_NONE;
> +
> + wl->key_enabled = 0;
> + wl->current_key = 0;
> +
> + wl->psk_type = GELIC_EURUS_WPA_PSK_PASSPHRASE;
> + wl->psk_len = 0;
> +
> + wl->essid_len = 0;
> + memset(wl->essid, 0, sizeof(wl->essid));
> + memset(wl->bssid, 0, sizeof(wl->bssid));
> + memset(wl->active_bssid, 0, sizeof(wl->active_bssid));
> +
> + wl->assoc_stat = GELIC_WL_ASSOC_STAT_DISCONN;
> +
> + memset(&wl->iwstat, 0, sizeof(wl->iwstat));
> + /* all status bit clear */
> + wl->stat = 0;
> + return 0;
> +}
> +
> +/*
> + * Tell eurus to terminate association
> + */
> +static void gelic_wl_disconnect(struct net_device *netdev)
> +{
> + struct gelic_port *port = netdev_priv(netdev);
> + struct gelic_wl_info *wl = port_wl(port);
> + struct gelic_eurus_cmd *cmd;
> + union iwreq_data data;
> +
> + /*
> + * If scann process is running on chip,
> + * further requests will be rejected
> + */
> + if (wl->scan_stat == GELIC_WL_SCAN_STAT_SCANNING)
> + wait_for_completion_timeout(&wl->scan_done, HZ);
> +
> + cmd = gelic_eurus_sync_cmd(wl, GELIC_EURUS_CMD_DISASSOC, NULL, 0);
> + kfree(cmd);
> + memset(&data, 0, sizeof(data));
> + data.ap_addr.sa_family = ARPHRD_ETHER;
> + wireless_send_event(port_to_netdev(wl_port(wl)), SIOCGIWAP,
> + &data, NULL);
> +};
> +
> +static int gelic_wl_stop(struct net_device *netdev)
> +{
> + struct gelic_port *port = netdev_priv(netdev);
> + struct gelic_wl_info *wl = port_wl(port);
> + struct gelic_card *card = netdev_card(netdev);
> +
> + pr_debug("%s:<-\n", __func__);
> +
> + /*
> + * Cancel pending association work.
> + * event work can run after netdev down
> + */
> + cancel_delayed_work(&wl->assoc_work);
> +
> + if (wl->assoc_stat == GELIC_WL_ASSOC_STAT_ASSOCIATED)
> + gelic_wl_disconnect(netdev);
> +
> + /* reset our state machine */
> + gelic_wl_reset_state(wl);
> +
> + netif_stop_queue(netdev);
> +
> + gelic_card_down(card);
> +
> + pr_debug("%s:->\n", __func__);
> + return 0;
> +}
> +
> +/* -- */
> +
> +static struct ethtool_ops gelic_wl_ethtool_ops = {
> + .get_drvinfo = gelic_net_get_drvinfo,
> + .get_link = gelic_wl_get_link,
> + .get_tx_csum = ethtool_op_get_tx_csum,
> + .set_tx_csum = ethtool_op_set_tx_csum,
> + .get_rx_csum = gelic_net_get_rx_csum,
> + .set_rx_csum = gelic_net_set_rx_csum,
> +};
> +
> +static void gelic_wl_setup_netdev_ops(struct net_device *netdev)
> +{
> + struct gelic_wl_info *wl;
> + wl = port_wl(netdev_priv(netdev));
> + BUG_ON(!wl);
> + netdev->open = &gelic_wl_open;
> + netdev->stop = &gelic_wl_stop;
> + netdev->hard_start_xmit = &gelic_net_xmit;
> + netdev->set_multicast_list = &gelic_net_set_multi;
> + netdev->change_mtu = &gelic_net_change_mtu;
> + netdev->wireless_data = &wl->wireless_data;
> + netdev->wireless_handlers = &gelic_wl_wext_handler_def;
> + /* tx watchdog */
> + netdev->tx_timeout = &gelic_net_tx_timeout;
> + netdev->watchdog_timeo = GELIC_NET_WATCHDOG_TIMEOUT;
> +
> + netdev->ethtool_ops = &gelic_wl_ethtool_ops;
> +#ifdef CONFIG_NET_POLL_CONTROLLER
> + netdev->poll_controller = gelic_net_poll_controller;
> +#endif
> +}
> +
> +/*
> + * driver probe/remove
> + */
> +int gelic_wl_driver_probe(struct gelic_card *card)
> +{
> + int ret;
> + struct net_device *netdev;
> +
> + pr_debug("%s:start\n", __func__);
> +
> + if (ps3_compare_firmware_version(1, 6, 0) < 0)
> + return 0;
> + if (!card->vlan[GELIC_PORT_WIRELESS].tx)
> + return 0;
> +
> + /* alloc netdevice for wireless */
> + netdev = gelic_wl_alloc(card);
> + if (!netdev)
> + return -ENOMEM;
> +
> + /* setup net_device structure */
> + gelic_wl_setup_netdev_ops(netdev);
> +
> + /* setup some of net_device and register it */
> + ret = gelic_net_setup_netdev(netdev, card);
> + if (ret)
> + goto fail_setup;
> + card->netdev[GELIC_PORT_WIRELESS] = netdev;
> +
> + /* add enable wireless interrupt */
> + card->irq_mask |= GELIC_CARD_WLAN_EVENT_RECEIVED |
> + GELIC_CARD_WLAN_COMMAND_COMPLETED;
> + /* to allow wireless commands while both interfaces are down */
> + gelic_card_set_irq_mask(card, GELIC_CARD_WLAN_EVENT_RECEIVED |
> + GELIC_CARD_WLAN_COMMAND_COMPLETED);
> + pr_debug("%s:end\n", __func__);
> + return 0;
> +
> +fail_setup:
> + gelic_wl_free(port_wl(netdev_port(netdev)));
> +
> + return ret;
> +}
> +
> +int gelic_wl_driver_remove(struct gelic_card *card)
> +{
> + struct gelic_wl_info *wl;
> + struct net_device *netdev;
> +
> + pr_debug("%s:start\n", __func__);
> +
> + if (ps3_compare_firmware_version(1, 6, 0) < 0)
> + return 0;
> + if (!card->vlan[GELIC_PORT_WIRELESS].tx)
> + return 0;
> +
> + netdev = card->netdev[GELIC_PORT_WIRELESS];
> + wl = port_wl(netdev_priv(netdev));
> +
> + /* if the interface was not up, but associated */
> + if (wl->assoc_stat == GELIC_WL_ASSOC_STAT_ASSOCIATED)
> + gelic_wl_disconnect(netdev);
> +
> + complete(&wl->cmd_done_intr);
> +
> + /* cancel all work queue */
> + cancel_delayed_work(&wl->assoc_work);
> + cancel_delayed_work(&wl->event_work);
> + flush_workqueue(wl->eurus_cmd_queue);
> + flush_workqueue(wl->event_queue);
> +
> + unregister_netdev(netdev);
> +
> + /* disable wireless interrupt */
> + pr_debug("%s: disable intr\n", __func__);
> + card->irq_mask &= ~(GELIC_CARD_WLAN_EVENT_RECEIVED |
> + GELIC_CARD_WLAN_COMMAND_COMPLETED);
> + /* free bss list, netdev*/
> + gelic_wl_free(wl);
> + pr_debug("%s:end\n", __func__);
> + return 0;
> +}
> --- /dev/null
> +++ b/drivers/net/ps3_gelic_wireless.h
> @@ -0,0 +1,329 @@
> +/*
> + * PS3 gelic network driver.
> + *
> + * Copyright (C) 2007 Sony Computer Entertainment Inc.
> + * Copyright 2007 Sony Corporation
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation version 2.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write to the Free Software
> + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
> + */
> +#ifndef _GELIC_WIRELESS_H
> +#define _GELIC_WIRELESS_H
> +
> +#include <linux/wireless.h>
> +#include <net/iw_handler.h>
> +
> +
> +/* return value from GELIC_LV1_GET_WLAN_EVENT netcontrol */
> +enum gelic_lv1_wl_event {
> + GELIC_LV1_WL_EVENT_DEVICE_READY = 0x01, /* Eurus ready */
> + GELIC_LV1_WL_EVENT_SCAN_COMPLETED = 0x02, /* Scan has completed */
> + GELIC_LV1_WL_EVENT_DEAUTH = 0x04, /* Deauthed by the AP */
> + GELIC_LV1_WL_EVENT_BEACON_LOST = 0x08, /* Beacon lost detected */
> + GELIC_LV1_WL_EVENT_CONNECTED = 0x10, /* Connected to AP */
> + GELIC_LV1_WL_EVENT_WPA_CONNECTED = 0x20, /* WPA connection */
> + GELIC_LV1_WL_EVENT_WPA_ERROR = 0x40, /* MIC error */
> +};
> +
> +/* arguments for GELIC_LV1_POST_WLAN_COMMAND netcontrol */
> +enum gelic_eurus_command {
> + GELIC_EURUS_CMD_ASSOC = 1, /* association start */
> + GELIC_EURUS_CMD_DISASSOC = 2, /* disassociate */
> + GELIC_EURUS_CMD_START_SCAN = 3, /* scan start */
> + GELIC_EURUS_CMD_GET_SCAN = 4, /* get scan result */
> + GELIC_EURUS_CMD_SET_COMMON_CFG = 5, /* set common config */
> + GELIC_EURUS_CMD_GET_COMMON_CFG = 6, /* set common config */
> + GELIC_EURUS_CMD_SET_WEP_CFG = 7, /* set WEP config */
> + GELIC_EURUS_CMD_GET_WEP_CFG = 8, /* get WEP config */
> + GELIC_EURUS_CMD_SET_WPA_CFG = 9, /* set WPA config */
> + GELIC_EURUS_CMD_GET_WPA_CFG = 10, /* get WPA config */
> + GELIC_EURUS_CMD_GET_RSSI_CFG = 11, /* get RSSI info. */
> + GELIC_EURUS_CMD_MAX_INDEX
> +};
> +
> +/* for GELIC_EURUS_CMD_COMMON_CFG */
> +enum gelic_eurus_bss_type {
> + GELIC_EURUS_BSS_INFRA = 0,
> + GELIC_EURUS_BSS_ADHOC = 1, /* not supported */
> +};
> +
> +enum gelic_eurus_auth_method {
> + GELIC_EURUS_AUTH_OPEN = 0, /* FIXME: WLAN_AUTH_OPEN */
> + GELIC_EURUS_AUTH_SHARED = 1, /* not supported */
> +};
> +
> +enum gelic_eurus_opmode {
> + GELIC_EURUS_OPMODE_11BG = 0, /* 802.11b/g */
> + GELIC_EURUS_OPMODE_11B = 1, /* 802.11b only */
> + GELIC_EURUS_OPMODE_11G = 2, /* 802.11g only */
> +};
> +
> +struct gelic_eurus_common_cfg {
> + /* all fields are big endian */
> + u16 scan_index;
> + u16 bss_type; /* infra or adhoc */
> + u16 auth_method; /* shared key or open */
> + u16 op_mode; /* B/G */
> +} __attribute__((packed));
> +
> +
> +/* for GELIC_EURUS_CMD_WEP_CFG */
> +enum gelic_eurus_wep_security {
> + GELIC_EURUS_WEP_SEC_NONE = 0,
> + GELIC_EURUS_WEP_SEC_40BIT = 1,
> + GELIC_EURUS_WEP_SEC_104BIT = 2,
> +};
> +
> +struct gelic_eurus_wep_cfg {
> + /* all fields are big endian */
> + u16 security;
> + u8 key[4][16];
> +} __attribute__((packed));
> +
> +/* for GELIC_EURUS_CMD_WPA_CFG */
> +enum gelic_eurus_wpa_security {
> + GELIC_EURUS_WPA_SEC_NONE = 0x0000,
> + /* group=TKIP, pairwise=TKIP */
> + GELIC_EURUS_WPA_SEC_WPA_TKIP_TKIP = 0x0001,
> + /* group=AES, pairwise=AES */
> + GELIC_EURUS_WPA_SEC_WPA_AES_AES = 0x0002,
> + /* group=TKIP, pairwise=TKIP */
> + GELIC_EURUS_WPA_SEC_WPA2_TKIP_TKIP = 0x0004,
> + /* group=AES, pairwise=AES */
> + GELIC_EURUS_WPA_SEC_WPA2_AES_AES = 0x0008,
> + /* group=TKIP, pairwise=AES */
> + GELIC_EURUS_WPA_SEC_WPA_TKIP_AES = 0x0010,
> + /* group=TKIP, pairwise=AES */
> + GELIC_EURUS_WPA_SEC_WPA2_TKIP_AES = 0x0020,
> +};
> +
> +enum gelic_eurus_wpa_psk_type {
> + GELIC_EURUS_WPA_PSK_PASSPHRASE = 0, /* passphrase string */
> + GELIC_EURUS_WPA_PSK_BIN = 1, /* 32 bytes binary key */
> +};
> +
> +#define GELIC_WL_EURUS_PSK_MAX_LEN 64
> +#define WPA_PSK_LEN 32 /* WPA spec says 256bit */
> +
> +struct gelic_eurus_wpa_cfg {
> + /* all fields are big endian */
> + u16 security;
> + u16 psk_type; /* psk key encoding type */
> + u8 psk[GELIC_WL_EURUS_PSK_MAX_LEN]; /* psk key; hex or passphrase */
> +} __attribute__((packed));
> +
> +/* for GELIC_EURUS_CMD_{START,GET}_SCAN */
> +enum gelic_eurus_scan_capability {
> + GELIC_EURUS_SCAN_CAP_ADHOC = 0x0000,
> + GELIC_EURUS_SCAN_CAP_INFRA = 0x0001,
> + GELIC_EURUS_SCAN_CAP_MASK = 0x0001,
> +};
> +
> +enum gelic_eurus_scan_sec_type {
> + GELIC_EURUS_SCAN_SEC_NONE = 0x0000,
> + GELIC_EURUS_SCAN_SEC_WEP = 0x0100,
> + GELIC_EURUS_SCAN_SEC_WPA = 0x0200,
> + GELIC_EURUS_SCAN_SEC_WPA2 = 0x0400,
> + GELIC_EURUS_SCAN_SEC_MASK = 0x0f00,
> +};
> +
> +enum gelic_eurus_scan_sec_wep_type {
> + GELIC_EURUS_SCAN_SEC_WEP_UNKNOWN = 0x0000,
> + GELIC_EURUS_SCAN_SEC_WEP_40 = 0x0001,
> + GELIC_EURUS_SCAN_SEC_WEP_104 = 0x0002,
> + GELIC_EURUS_SCAN_SEC_WEP_MASK = 0x0003,
> +};
> +
> +enum gelic_eurus_scan_sec_wpa_type {
> + GELIC_EURUS_SCAN_SEC_WPA_UNKNOWN = 0x0000,
> + GELIC_EURUS_SCAN_SEC_WPA_TKIP = 0x0001,
> + GELIC_EURUS_SCAN_SEC_WPA_AES = 0x0002,
> + GELIC_EURUS_SCAN_SEC_WPA_MASK = 0x0003,
> +};
> +
> +/*
> + * hw BSS information structure returned from GELIC_EURUS_CMD_GET_SCAN
> + */
> +struct gelic_eurus_scan_info {
> + /* all fields are big endian */
> + __be16 size;
> + __be16 rssi; /* percentage */
> + __be16 channel; /* channel number */
> + __be16 beacon_period; /* FIXME: in msec unit */
> + __be16 capability;
> + __be16 security;
> + u8 bssid[8]; /* last ETH_ALEN are valid. bssid[0],[1] are unused */
> + u8 essid[32]; /* IW_ESSID_MAX_SIZE */
> + u8 rate[16]; /* first MAX_RATES_LENGTH(12) are valid */
> + u8 ext_rate[16]; /* first MAX_RATES_EX_LENGTH(16) are valid */
> + __be32 reserved1;
> + __be32 reserved2;
> + __be32 reserved3;
> + __be32 reserved4;
> + u8 elements[0]; /* ie */
> +} __attribute__ ((packed));
> +
> +/* the hypervisor returns bbs up to 16 */
> +#define GELIC_EURUS_MAX_SCAN (16)
> +struct gelic_wl_scan_info {
> + struct list_head list;
> + struct gelic_eurus_scan_info *hwinfo;
> +
> + int valid; /* set 1 if this entry was in latest scanned list
> + * from Eurus */
> + unsigned int eurus_index; /* index in the Eurus list */
> + unsigned long last_scanned; /* acquired time */
> +
> + unsigned int rate_len;
> + unsigned int rate_ext_len;
> + unsigned int essid_len;
> +};
> +
> +/* for GELIC_EURUS_CMD_GET_RSSI */
> +struct gelic_eurus_rssi_info {
> + /* big endian */
> + __be16 rssi;
> +} __attribute__ ((packed));
> +
> +
> +/* for 'stat' member of gelic_wl_info */
> +enum gelic_wl_info_status_bit {
> + GELIC_WL_STAT_CONFIGURED,
> + GELIC_WL_STAT_CH_INFO, /* ch info aquired */
> + GELIC_WL_STAT_ESSID_SET, /* ESSID specified by userspace */
> + GELIC_WL_STAT_BSSID_SET, /* BSSID specified by userspace */
> + GELIC_WL_STAT_WPA_PSK_SET, /* PMK specified by userspace */
> + GELIC_WL_STAT_WPA_LEVEL_SET, /* WEP or WPA[2] selected */
> +};
> +
> +/* for 'scan_stat' member of gelic_wl_info */
> +enum gelic_wl_scan_state {
> + /* just initialized or get last scan result failed */
> + GELIC_WL_SCAN_STAT_INIT,
> + /* scan request issued, accepted or chip is scanning */
> + GELIC_WL_SCAN_STAT_SCANNING,
> + /* scan results retrieved */
> + GELIC_WL_SCAN_STAT_GOT_LIST,
> +};
> +
> +/* for 'cipher_method' */
> +enum gelic_wl_cipher_method {
> + GELIC_WL_CIPHER_NONE,
> + GELIC_WL_CIPHER_WEP,
> + GELIC_WL_CIPHER_TKIP,
> + GELIC_WL_CIPHER_AES,
> +};
> +
> +/* for 'wpa_level' */
> +enum gelic_wl_wpa_level {
> + GELIC_WL_WPA_LEVEL_NONE,
> + GELIC_WL_WPA_LEVEL_WPA,
> + GELIC_WL_WPA_LEVEL_WPA2,
> +};
> +
> +/* for 'assoc_stat' */
> +enum gelic_wl_assoc_state {
> + GELIC_WL_ASSOC_STAT_DISCONN,
> + GELIC_WL_ASSOC_STAT_ASSOCIATING,
> + GELIC_WL_ASSOC_STAT_ASSOCIATED,
> +};
> +/* part of private data alloc_etherdev() allocated */
> +#define GELIC_WEP_KEYS 4
> +struct gelic_wl_info {
> + /* bss list */
> + struct semaphore scan_lock;
> + struct list_head network_list;
> + struct list_head network_free_list;
> + struct gelic_wl_scan_info *networks;
> +
> + unsigned long scan_age; /* last scanned time */
> + enum gelic_wl_scan_state scan_stat;
> + struct completion scan_done;
> +
> + /* eurus command queue */
> + struct workqueue_struct *eurus_cmd_queue;
> + struct completion cmd_done_intr;
> +
> + /* eurus event handling */
> + struct workqueue_struct *event_queue;
> + struct delayed_work event_work;
> +
> + /* wl status bits */
> + unsigned long stat;
> + enum gelic_eurus_auth_method auth_method; /* open/shared */
> + enum gelic_wl_cipher_method group_cipher_method;
> + enum gelic_wl_cipher_method pairwise_cipher_method;
> + enum gelic_wl_wpa_level wpa_level; /* wpa/wpa2 */
> +
> + /* association handling */
> + struct semaphore assoc_stat_lock;
> + struct delayed_work assoc_work;
> + enum gelic_wl_assoc_state assoc_stat;
> + struct completion assoc_done;
> +
> + spinlock_t lock;
> + u16 ch_info; /* available channels. bit0 = ch1 */
> + /* WEP keys */
> + u8 key[GELIC_WEP_KEYS][IW_ENCODING_TOKEN_MAX];
> + unsigned long key_enabled;
> + unsigned int key_len[GELIC_WEP_KEYS];
> + unsigned int current_key;
> + /* WWPA PSK */
> + u8 psk[GELIC_WL_EURUS_PSK_MAX_LEN];
> + enum gelic_eurus_wpa_psk_type psk_type;
> + unsigned int psk_len;
> +
> + u8 essid[IW_ESSID_MAX_SIZE];
> + u8 bssid[ETH_ALEN]; /* userland requested */
> + u8 active_bssid[ETH_ALEN]; /* associated bssid */
> + unsigned int essid_len;
> +
> + /* buffer for hypervisor IO */
> + void *buf;
> +
> + struct iw_public_data wireless_data;
> + struct iw_statistics iwstat;
> +};
> +
> +#define GELIC_WL_BSS_MAX_ENT 32
> +#define GELIC_WL_ASSOC_RETRY 50
> +static inline struct gelic_port *wl_port(struct gelic_wl_info *wl)
> +{
> + return container_of((void *)wl, struct gelic_port, priv);
> +}
> +static inline struct gelic_wl_info *port_wl(struct gelic_port *port)
> +{
> + return port_priv(port);
> +}
> +
> +struct gelic_eurus_cmd {
> + struct work_struct work;
> + struct gelic_wl_info *wl;
> + unsigned int cmd; /* command code */
> + u64 tag;
> + u64 size;
> + void *buffer;
> + unsigned int buf_size;
> + struct completion done;
> + int status;
> + u64 cmd_status;
> +};
> +
> +/* private ioctls to pass PSK */
> +#define GELIC_WL_PRIV_SET_PSK (SIOCIWFIRSTPRIV + 0)
> +#define GELIC_WL_PRIV_GET_PSK (SIOCIWFIRSTPRIV + 1)
> +
> +extern int gelic_wl_driver_probe(struct gelic_card *card);
> +extern int gelic_wl_driver_remove(struct gelic_card *card);
> +extern void gelic_wl_interrupt(struct net_device *netdev, u64 status);
> +#endif /* _GELIC_WIRELESS_H */
>
^ permalink raw reply
* [PATCH 11/12] [DCCP]: Make code assumptions explicit
From: Arnaldo Carvalho de Melo @ 2007-12-13 15:06 UTC (permalink / raw)
To: David S. Miller
Cc: netdev, dccp, Gerrit Renker, Ian McDonald,
Arnaldo Carvalho de Melo
In-Reply-To: <1197558365-31134-11-git-send-email-acme@redhat.com>
From: Gerrit Renker <gerrit@erg.abdn.ac.uk>
This removes several `XXX' references which indicate a missing support
for non-1-byte feature values: this is unnecessary, as all currently known
(standardised) SP feature values are 1-byte quantities.
Signed-off-by: Gerrit Renker <gerrit@erg.abdn.ac.uk>
Signed-off-by: Ian McDonald <ian.mcdonald@jandi.co.nz>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
net/dccp/feat.c | 17 ++++++++++-------
1 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/net/dccp/feat.c b/net/dccp/feat.c
index 084744e..4a4f6ce 100644
--- a/net/dccp/feat.c
+++ b/net/dccp/feat.c
@@ -4,10 +4,16 @@
* An implementation of the DCCP protocol
* Andrea Bittau <a.bittau@cs.ucl.ac.uk>
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version
- * 2 of the License, or (at your option) any later version.
+ * ASSUMPTIONS
+ * -----------
+ * o All currently known SP features have 1-byte quantities. If in the future
+ * extensions of RFCs 4340..42 define features with item lengths larger than
+ * one byte, a feature-specific extension of the code will be required.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
*/
#include <linux/module.h>
@@ -95,7 +101,6 @@ static int dccp_feat_update_ccid(struct sock *sk, u8 type, u8 new_ccid_nr)
return 0;
}
-/* XXX taking only u8 vals */
static int dccp_feat_update(struct sock *sk, u8 type, u8 feat, u8 val)
{
dccp_feat_debug(type, feat, val);
@@ -140,7 +145,6 @@ static int dccp_feat_reconcile(struct sock *sk, struct dccp_opt_pend *opt,
/* FIXME sanity check vals */
/* Are values in any order? XXX Lame "algorithm" here */
- /* XXX assume values are 1 byte */
for (i = 0; i < slen; i++) {
for (j = 0; j < rlen; j++) {
if (spref[i] == rpref[j]) {
@@ -175,7 +179,6 @@ static int dccp_feat_reconcile(struct sock *sk, struct dccp_opt_pend *opt,
}
/* need to put result and our preference list */
- /* XXX assume 1 byte vals */
rlen = 1 + opt->dccpop_len;
rpref = kmalloc(rlen, GFP_ATOMIC);
if (rpref == NULL)
--
1.5.3.4
^ permalink raw reply related
* [PATCH 07/12] [DCCP]: Add (missing) option parsing to request_sock processing
From: Arnaldo Carvalho de Melo @ 2007-12-13 15:06 UTC (permalink / raw)
To: David S. Miller
Cc: netdev, dccp, Gerrit Renker, Ian McDonald,
Arnaldo Carvalho de Melo
In-Reply-To: <1197558365-31134-7-git-send-email-acme@redhat.com>
From: Gerrit Renker <gerrit@erg.abdn.ac.uk>
This adds option-parsing code to processing of Acks in the listening state
on request_socks on the server, serving two purposes
(i) resolves a FIXME (removed);
(ii) paves the way for feature-negotiation during connection-setup.
There is an intended subtlety here with regard to dccp_check_req:
Parsing options happens only after testing whether the received packet is
a retransmitted Request. Otherwise, if the Request contained (a possibly
large number of) feature-negotiation options, recomputing state would have to
happen each time a retransmitted Request arrives, which opens the door to an
easy DoS attack. Since in a genuine retransmission the options should not be
different from the original, reusing the already computed state seems better.
The other point is - if there are timestamp options on the Request, they will
not be answered; which means that in the presence of retransmission (likely
due to loss and/or other problems), the use of Request/Response RTT sampling
is suspended, so that startup problems here do not propagate.
Signed-off-by: Gerrit Renker <gerrit@erg.abdn.ac.uk>
Signed-off-by: Ian McDonald <ian.mcdonald@jandi.co.nz>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
net/dccp/minisocks.c | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/net/dccp/minisocks.c b/net/dccp/minisocks.c
index 831b76e..b1d5da6 100644
--- a/net/dccp/minisocks.c
+++ b/net/dccp/minisocks.c
@@ -200,10 +200,10 @@ struct sock *dccp_check_req(struct sock *sk, struct sk_buff *skb,
struct request_sock **prev)
{
struct sock *child = NULL;
+ struct dccp_request_sock *dreq = dccp_rsk(req);
/* Check for retransmitted REQUEST */
if (dccp_hdr(skb)->dccph_type == DCCP_PKT_REQUEST) {
- struct dccp_request_sock *dreq = dccp_rsk(req);
if (after48(DCCP_SKB_CB(skb)->dccpd_seq, dreq->dreq_isr)) {
dccp_pr_debug("Retransmitted REQUEST\n");
@@ -227,22 +227,22 @@ struct sock *dccp_check_req(struct sock *sk, struct sk_buff *skb,
goto drop;
/* Invalid ACK */
- if (DCCP_SKB_CB(skb)->dccpd_ack_seq != dccp_rsk(req)->dreq_iss) {
+ if (DCCP_SKB_CB(skb)->dccpd_ack_seq != dreq->dreq_iss) {
dccp_pr_debug("Invalid ACK number: ack_seq=%llu, "
"dreq_iss=%llu\n",
(unsigned long long)
DCCP_SKB_CB(skb)->dccpd_ack_seq,
- (unsigned long long)
- dccp_rsk(req)->dreq_iss);
+ (unsigned long long) dreq->dreq_iss);
goto drop;
}
+ if (dccp_parse_options(sk, dreq, skb))
+ goto drop;
+
child = inet_csk(sk)->icsk_af_ops->syn_recv_sock(sk, skb, req, NULL);
if (child == NULL)
goto listen_overflow;
- /* FIXME: deal with options */
-
inet_csk_reqsk_queue_unlink(sk, req, prev);
inet_csk_reqsk_queue_removed(sk, req);
inet_csk_reqsk_queue_add(sk, req, child);
--
1.5.3.4
^ permalink raw reply related
* [PATCH 08/12] [DCCP]: Handle timestamps on Request/Response exchange separately
From: Arnaldo Carvalho de Melo @ 2007-12-13 15:06 UTC (permalink / raw)
To: David S. Miller; +Cc: netdev, dccp, Gerrit Renker, Arnaldo Carvalho de Melo
In-Reply-To: <1197558365-31134-8-git-send-email-acme@redhat.com>
From: Gerrit Renker <gerrit@erg.abdn.ac.uk>
In DCCP, timestamps can occur on packets anytime, CCID3 uses a timestamp(/echo) on the Request/Response
exchange. This patch addresses the following situation:
* timestamps are recorded on the listening socket;
* Responses are sent from dccp_request_sockets;
* suppose two connections reach the listening socket with very small time in between:
* the first timestamp value gets overwritten by the second connection request.
This is not really good, so this patch separates timestamps into
* those which are received by the server during the initial handshake (on dccp_request_sock);
* those which are received by the client or the client after connection establishment.
As before, a timestamp of 0 is regarded as indicating that no (meaningful) timestamp has been
received (in addition, a warning message is printed if hosts send 0-valued timestamps).
The timestamp-echoing now works as follows:
* when a timestamp is present on the initial Request, it is placed into dreq, due to the
call to dccp_parse_options in dccp_v{4,6}_conn_request;
* when a timestamp is present on the Ack leading from RESPOND => OPEN, it is copied over
from the request_sock into the child cocket in dccp_create_openreq_child;
* timestamps received on an (established) dccp_sock are treated as before.
Since Elapsed Time is measured in hundredths of milliseconds (13.2), the new dccp_timestamp()
function is used, as it is expected that the time between receiving the timestamp and
sending the timestamp echo will be very small against the wrap-around time. As a byproduct,
this allows smaller timestamping-time fields.
Furthermore, inserting the Timestamp Echo option has been taken out of the block starting with
'!dccp_packet_without_ack()', since Timestamp Echo can be carried on any packet (5.8 and 13.3).
Signed-off-by: Gerrit Renker <gerrit@erg.abdn.ac.uk>
Acked-by: Ian McDonald <ian.mcdonald@jandi.co.nz>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
include/linux/dccp.h | 16 ++++++++++++-
net/dccp/minisocks.c | 21 +++++++++++-------
net/dccp/options.c | 56 ++++++++++++++++++++++++++++++++-----------------
3 files changed, 63 insertions(+), 30 deletions(-)
diff --git a/include/linux/dccp.h b/include/linux/dccp.h
index 7214031..484e45c 100644
--- a/include/linux/dccp.h
+++ b/include/linux/dccp.h
@@ -407,11 +407,23 @@ struct dccp_opt_pend {
extern void dccp_minisock_init(struct dccp_minisock *dmsk);
+/**
+ * struct dccp_request_sock - represent DCCP-specific connection request
+ * @dreq_inet_rsk: structure inherited from
+ * @dreq_iss: initial sequence number sent on the Response (RFC 4340, 7.1)
+ * @dreq_isr: initial sequence number received on the Request
+ * @dreq_service: service code present on the Request (there is just one)
+ * The following two fields are analogous to the ones in dccp_sock:
+ * @dreq_timestamp_echo: last received timestamp to echo (13.1)
+ * @dreq_timestamp_echo: the time of receiving the last @dreq_timestamp_echo
+ */
struct dccp_request_sock {
struct inet_request_sock dreq_inet_rsk;
__u64 dreq_iss;
__u64 dreq_isr;
__be32 dreq_service;
+ __u32 dreq_timestamp_echo;
+ __u32 dreq_timestamp_time;
};
static inline struct dccp_request_sock *dccp_rsk(const struct request_sock *req)
@@ -477,8 +489,8 @@ struct dccp_ackvec;
* @dccps_gar - greatest valid ack number received on a non-Sync; initialized to %dccps_iss
* @dccps_service - first (passive sock) or unique (active sock) service code
* @dccps_service_list - second .. last service code on passive socket
- * @dccps_timestamp_time - time of latest TIMESTAMP option
* @dccps_timestamp_echo - latest timestamp received on a TIMESTAMP option
+ * @dccps_timestamp_time - time of receiving latest @dccps_timestamp_echo
* @dccps_l_ack_ratio - feature-local Ack Ratio
* @dccps_r_ack_ratio - feature-remote Ack Ratio
* @dccps_pcslen - sender partial checksum coverage (via sockopt)
@@ -514,8 +526,8 @@ struct dccp_sock {
__u64 dccps_gar;
__be32 dccps_service;
struct dccp_service_list *dccps_service_list;
- ktime_t dccps_timestamp_time;
__u32 dccps_timestamp_echo;
+ __u32 dccps_timestamp_time;
__u16 dccps_l_ack_ratio;
__u16 dccps_r_ack_ratio;
__u16 dccps_pcslen;
diff --git a/net/dccp/minisocks.c b/net/dccp/minisocks.c
index b1d5da6..027d181 100644
--- a/net/dccp/minisocks.c
+++ b/net/dccp/minisocks.c
@@ -117,11 +117,13 @@ struct sock *dccp_create_openreq_child(struct sock *sk,
struct dccp_sock *newdp = dccp_sk(newsk);
struct dccp_minisock *newdmsk = dccp_msk(newsk);
- newdp->dccps_role = DCCP_ROLE_SERVER;
- newdp->dccps_hc_rx_ackvec = NULL;
- newdp->dccps_service_list = NULL;
- newdp->dccps_service = dreq->dreq_service;
- newicsk->icsk_rto = DCCP_TIMEOUT_INIT;
+ newdp->dccps_role = DCCP_ROLE_SERVER;
+ newdp->dccps_hc_rx_ackvec = NULL;
+ newdp->dccps_service_list = NULL;
+ newdp->dccps_service = dreq->dreq_service;
+ newdp->dccps_timestamp_echo = dreq->dreq_timestamp_echo;
+ newdp->dccps_timestamp_time = dreq->dreq_timestamp_time;
+ newicsk->icsk_rto = DCCP_TIMEOUT_INIT;
if (dccp_feat_clone(sk, newsk))
goto out_free;
@@ -303,9 +305,12 @@ EXPORT_SYMBOL_GPL(dccp_reqsk_send_ack);
void dccp_reqsk_init(struct request_sock *req, struct sk_buff *skb)
{
- inet_rsk(req)->rmt_port = dccp_hdr(skb)->dccph_sport;
- inet_rsk(req)->acked = 0;
- req->rcv_wnd = sysctl_dccp_feat_sequence_window;
+ struct dccp_request_sock *dreq = dccp_rsk(req);
+
+ inet_rsk(req)->rmt_port = dccp_hdr(skb)->dccph_sport;
+ inet_rsk(req)->acked = 0;
+ req->rcv_wnd = sysctl_dccp_feat_sequence_window;
+ dreq->dreq_timestamp_echo = 0;
}
EXPORT_SYMBOL_GPL(dccp_reqsk_init);
diff --git a/net/dccp/options.c b/net/dccp/options.c
index f496d4d..0c996d8 100644
--- a/net/dccp/options.c
+++ b/net/dccp/options.c
@@ -166,16 +166,27 @@ int dccp_parse_options(struct sock *sk, struct dccp_request_sock *dreq,
case DCCPO_TIMESTAMP:
if (len != 4)
goto out_invalid_option;
-
+ /*
+ * RFC 4340 13.1: "The precise time corresponding to
+ * Timestamp Value zero is not specified". We use
+ * zero to indicate absence of a meaningful timestamp.
+ */
opt_val = get_unaligned((__be32 *)value);
- opt_recv->dccpor_timestamp = ntohl(opt_val);
-
- /* FIXME: if dreq != NULL, don't store this on listening socket */
- dp->dccps_timestamp_echo = opt_recv->dccpor_timestamp;
- dp->dccps_timestamp_time = ktime_get_real();
+ if (unlikely(opt_val == 0)) {
+ DCCP_WARN("Timestamp with zero value\n");
+ break;
+ }
+ if (dreq != NULL) {
+ dreq->dreq_timestamp_echo = ntohl(opt_val);
+ dreq->dreq_timestamp_time = dccp_timestamp();
+ } else {
+ opt_recv->dccpor_timestamp =
+ dp->dccps_timestamp_echo = ntohl(opt_val);
+ dp->dccps_timestamp_time = dccp_timestamp();
+ }
dccp_pr_debug("%s rx opt: TIMESTAMP=%u, ackno=%llu\n",
- dccp_role(sk), opt_recv->dccpor_timestamp,
+ dccp_role(sk), ntohl(opt_val),
(unsigned long long)
DCCP_SKB_CB(skb)->dccpd_ack_seq);
break;
@@ -393,16 +404,24 @@ int dccp_insert_option_timestamp(struct sock *sk, struct sk_buff *skb)
EXPORT_SYMBOL_GPL(dccp_insert_option_timestamp);
-static int dccp_insert_option_timestamp_echo(struct sock *sk,
+static int dccp_insert_option_timestamp_echo(struct dccp_sock *dp,
+ struct dccp_request_sock *dreq,
struct sk_buff *skb)
{
- struct dccp_sock *dp = dccp_sk(sk);
__be32 tstamp_echo;
- int len, elapsed_time_len;
unsigned char *to;
- const suseconds_t delta = ktime_us_delta(ktime_get_real(),
- dp->dccps_timestamp_time);
- u32 elapsed_time = delta / 10;
+ u32 elapsed_time, elapsed_time_len, len;
+
+ if (dreq != NULL) {
+ elapsed_time = dccp_timestamp() - dreq->dreq_timestamp_time;
+ tstamp_echo = htonl(dreq->dreq_timestamp_echo);
+ dreq->dreq_timestamp_echo = 0;
+ } else {
+ elapsed_time = dccp_timestamp() - dp->dccps_timestamp_time;
+ tstamp_echo = htonl(dp->dccps_timestamp_echo);
+ dp->dccps_timestamp_echo = 0;
+ }
+
elapsed_time_len = dccp_elapsed_time_len(elapsed_time);
len = 6 + elapsed_time_len;
@@ -415,7 +434,6 @@ static int dccp_insert_option_timestamp_echo(struct sock *sk,
*to++ = DCCPO_TIMESTAMP_ECHO;
*to++ = len;
- tstamp_echo = htonl(dp->dccps_timestamp_echo);
memcpy(to, &tstamp_echo, 4);
to += 4;
@@ -427,8 +445,6 @@ static int dccp_insert_option_timestamp_echo(struct sock *sk,
memcpy(to, &var32, 4);
}
- dp->dccps_timestamp_echo = 0;
- dp->dccps_timestamp_time = ktime_set(0, 0);
return 0;
}
@@ -537,10 +553,6 @@ int dccp_insert_options(struct sock *sk, struct sk_buff *skb)
dccp_ackvec_pending(dp->dccps_hc_rx_ackvec) &&
dccp_insert_option_ackvec(sk, skb))
return -1;
-
- if (dp->dccps_timestamp_echo != 0 &&
- dccp_insert_option_timestamp_echo(sk, skb))
- return -1;
}
if (dp->dccps_hc_rx_insert_options) {
@@ -564,6 +576,10 @@ int dccp_insert_options(struct sock *sk, struct sk_buff *skb)
dccp_insert_option_timestamp(sk, skb))
return -1;
+ if (dp->dccps_timestamp_echo != 0 &&
+ dccp_insert_option_timestamp_echo(dp, NULL, skb))
+ return -1;
+
/* XXX: insert other options when appropriate */
if (DCCP_SKB_CB(skb)->dccpd_opt_len != 0) {
--
1.5.3.4
^ permalink raw reply related
* [PATCH 12/12] [DCCP]: Ignore feature negotiation on Data packets
From: Arnaldo Carvalho de Melo @ 2007-12-13 15:06 UTC (permalink / raw)
To: David S. Miller
Cc: netdev, dccp, Gerrit Renker, Ian McDonald,
Arnaldo Carvalho de Melo
In-Reply-To: <1197558365-31134-12-git-send-email-acme@redhat.com>
From: Gerrit Renker <gerrit@erg.abdn.ac.uk>
This implements [RFC 4340, p. 32]: "any feature negotiation options received
on DCCP-Data packets MUST be ignored".
Also added a FIXME for further processing, since the code currently (wrongly)
classifies empty Confirm options as invalid - this needs to be resolved in
a separate patch.
Signed-off-by: Gerrit Renker <gerrit@erg.abdn.ac.uk>
Signed-off-by: Ian McDonald <ian.mcdonald@jandi.co.nz>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
net/dccp/options.c | 6 +++++-
1 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/net/dccp/options.c b/net/dccp/options.c
index bedb5da..d2a84a2 100644
--- a/net/dccp/options.c
+++ b/net/dccp/options.c
@@ -132,6 +132,8 @@ int dccp_parse_options(struct sock *sk, struct dccp_request_sock *dreq,
case DCCPO_CHANGE_L:
/* fall through */
case DCCPO_CHANGE_R:
+ if (pkt_type == DCCP_PKT_DATA)
+ break;
if (len < 2)
goto out_invalid_option;
rc = dccp_feat_change_recv(sk, opt, *value, value + 1,
@@ -148,7 +150,9 @@ int dccp_parse_options(struct sock *sk, struct dccp_request_sock *dreq,
case DCCPO_CONFIRM_L:
/* fall through */
case DCCPO_CONFIRM_R:
- if (len < 2)
+ if (pkt_type == DCCP_PKT_DATA)
+ break;
+ if (len < 2) /* FIXME this disallows empty confirm */
goto out_invalid_option;
if (dccp_feat_confirm_recv(sk, opt, *value,
value + 1, len - 1))
--
1.5.3.4
^ permalink raw reply related
* [PATCH 06/12] [DCCP]: Allow to parse options on Request Sockets
From: Arnaldo Carvalho de Melo @ 2007-12-13 15:05 UTC (permalink / raw)
To: David S. Miller
Cc: netdev, dccp, Gerrit Renker, Ian McDonald,
Arnaldo Carvalho de Melo
In-Reply-To: <1197558365-31134-6-git-send-email-acme@redhat.com>
From: Gerrit Renker <gerrit@erg.abdn.ac.uk>
The option parsing code currently only parses on full sk's. This causes a problem for
options sent during the initial handshake (in particular timestamps and feature-negotiation
options). Therefore, this patch extends the option parsing code with an additional argument
for request_socks: if it is non-NULL, options are parsed on the request socket, otherwise
the normal path (parsing on the sk) is used.
Subsequent patches, which implement feature negotiation during connection setup, make use
of this facility.
Signed-off-by: Gerrit Renker <gerrit@erg.abdn.ac.uk>
Signed-off-by: Ian McDonald <ian.mcdonald@jandi.co.nz>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
include/linux/dccp.h | 5 +++--
net/dccp/input.c | 6 +++---
net/dccp/ipv4.c | 8 ++++----
net/dccp/ipv6.c | 8 ++++----
net/dccp/options.c | 34 +++++++++++++++++++++++-----------
5 files changed, 37 insertions(+), 24 deletions(-)
diff --git a/include/linux/dccp.h b/include/linux/dccp.h
index c676021..7214031 100644
--- a/include/linux/dccp.h
+++ b/include/linux/dccp.h
@@ -407,8 +407,6 @@ struct dccp_opt_pend {
extern void dccp_minisock_init(struct dccp_minisock *dmsk);
-extern int dccp_parse_options(struct sock *sk, struct sk_buff *skb);
-
struct dccp_request_sock {
struct inet_request_sock dreq_inet_rsk;
__u64 dreq_iss;
@@ -423,6 +421,9 @@ static inline struct dccp_request_sock *dccp_rsk(const struct request_sock *req)
extern struct inet_timewait_death_row dccp_death_row;
+extern int dccp_parse_options(struct sock *sk, struct dccp_request_sock *dreq,
+ struct sk_buff *skb);
+
struct dccp_options_received {
u32 dccpor_ndp; /* only 24 bits */
u32 dccpor_timestamp;
diff --git a/net/dccp/input.c b/net/dccp/input.c
index dacd4fd..08392ed 100644
--- a/net/dccp/input.c
+++ b/net/dccp/input.c
@@ -369,7 +369,7 @@ int dccp_rcv_established(struct sock *sk, struct sk_buff *skb,
if (dccp_check_seqno(sk, skb))
goto discard;
- if (dccp_parse_options(sk, skb))
+ if (dccp_parse_options(sk, NULL, skb))
goto discard;
if (DCCP_SKB_CB(skb)->dccpd_ack_seq != DCCP_PKT_WITHOUT_ACK_SEQ)
@@ -427,7 +427,7 @@ static int dccp_rcv_request_sent_state_process(struct sock *sk,
goto out_invalid_packet;
}
- if (dccp_parse_options(sk, skb))
+ if (dccp_parse_options(sk, NULL, skb))
goto out_invalid_packet;
/* Obtain usec RTT sample from SYN exchange (used by CCID 3) */
@@ -609,7 +609,7 @@ int dccp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
/*
* Step 8: Process options and mark acknowledgeable
*/
- if (dccp_parse_options(sk, skb))
+ if (dccp_parse_options(sk, NULL, skb))
goto discard;
if (dcb->dccpd_ack_seq != DCCP_PKT_WITHOUT_ACK_SEQ)
diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c
index db17b83..02fc91c 100644
--- a/net/dccp/ipv4.c
+++ b/net/dccp/ipv4.c
@@ -600,11 +600,12 @@ int dccp_v4_conn_request(struct sock *sk, struct sk_buff *skb)
if (req == NULL)
goto drop;
- if (dccp_parse_options(sk, skb))
- goto drop_and_free;
-
dccp_reqsk_init(req, skb);
+ dreq = dccp_rsk(req);
+ if (dccp_parse_options(sk, dreq, skb))
+ goto drop_and_free;
+
if (security_inet_conn_request(sk, skb, req))
goto drop_and_free;
@@ -621,7 +622,6 @@ int dccp_v4_conn_request(struct sock *sk, struct sk_buff *skb)
* In fact we defer setting S.GSR, S.SWL, S.SWH to
* dccp_create_openreq_child.
*/
- dreq = dccp_rsk(req);
dreq->dreq_isr = dcb->dccpd_seq;
dreq->dreq_iss = dccp_v4_init_sequence(skb);
dreq->dreq_service = service;
diff --git a/net/dccp/ipv6.c b/net/dccp/ipv6.c
index a08e2cb..f42b75c 100644
--- a/net/dccp/ipv6.c
+++ b/net/dccp/ipv6.c
@@ -415,11 +415,12 @@ static int dccp_v6_conn_request(struct sock *sk, struct sk_buff *skb)
if (req == NULL)
goto drop;
- if (dccp_parse_options(sk, skb))
- goto drop_and_free;
-
dccp_reqsk_init(req, skb);
+ dreq = dccp_rsk(req);
+ if (dccp_parse_options(sk, dreq, skb))
+ goto drop_and_free;
+
if (security_inet_conn_request(sk, skb, req))
goto drop_and_free;
@@ -449,7 +450,6 @@ static int dccp_v6_conn_request(struct sock *sk, struct sk_buff *skb)
* In fact we defer setting S.GSR, S.SWL, S.SWH to
* dccp_create_openreq_child.
*/
- dreq = dccp_rsk(req);
dreq->dreq_isr = dcb->dccpd_seq;
dreq->dreq_iss = dccp_v6_init_sequence(skb);
dreq->dreq_service = service;
diff --git a/net/dccp/options.c b/net/dccp/options.c
index 523250b..f496d4d 100644
--- a/net/dccp/options.c
+++ b/net/dccp/options.c
@@ -46,7 +46,13 @@ static u32 dccp_decode_value_var(const unsigned char *bf, const u8 len)
return value;
}
-int dccp_parse_options(struct sock *sk, struct sk_buff *skb)
+/**
+ * dccp_parse_options - Parse DCCP options present in @skb
+ * @sk: client|server|listening dccp socket (when @dreq != NULL)
+ * @dreq: request socket to use during connection setup, or NULL
+ */
+int dccp_parse_options(struct sock *sk, struct dccp_request_sock *dreq,
+ struct sk_buff *skb)
{
struct dccp_sock *dp = dccp_sk(sk);
const struct dccp_hdr *dh = dccp_hdr(skb);
@@ -92,6 +98,20 @@ int dccp_parse_options(struct sock *sk, struct sk_buff *skb)
goto out_invalid_option;
}
+ /*
+ * CCID-Specific Options (from RFC 4340, sec. 10.3):
+ *
+ * Option numbers 128 through 191 are for options sent from the
+ * HC-Sender to the HC-Receiver; option numbers 192 through 255
+ * are for options sent from the HC-Receiver to the HC-Sender.
+ *
+ * CCID-specific options are ignored during connection setup, as
+ * negotiation may still be in progress (see RFC 4340, 10.3).
+ *
+ */
+ if (dreq != NULL && opt >= 128)
+ goto ignore_option;
+
switch (opt) {
case DCCPO_PADDING:
break;
@@ -150,6 +170,7 @@ int dccp_parse_options(struct sock *sk, struct sk_buff *skb)
opt_val = get_unaligned((__be32 *)value);
opt_recv->dccpor_timestamp = ntohl(opt_val);
+ /* FIXME: if dreq != NULL, don't store this on listening socket */
dp->dccps_timestamp_echo = opt_recv->dccpor_timestamp;
dp->dccps_timestamp_time = ktime_get_real();
@@ -213,15 +234,6 @@ int dccp_parse_options(struct sock *sk, struct sk_buff *skb)
dccp_pr_debug("%s rx opt: ELAPSED_TIME=%d\n",
dccp_role(sk), elapsed_time);
break;
- /*
- * From RFC 4340, sec. 10.3:
- *
- * Option numbers 128 through 191 are for
- * options sent from the HC-Sender to the
- * HC-Receiver; option numbers 192 through 255
- * are for options sent from the HC-Receiver to
- * the HC-Sender.
- */
case 128 ... 191: {
const u16 idx = value - options;
@@ -245,7 +257,7 @@ int dccp_parse_options(struct sock *sk, struct sk_buff *skb)
"implemented, ignoring", sk, opt, len);
break;
}
-
+ignore_option:
if (opt != DCCPO_MANDATORY)
mandatory = 0;
}
--
1.5.3.4
^ permalink raw reply related
* [PATCH 09/12] [DCCP]: Support inserting options during the 3-way handshake
From: Arnaldo Carvalho de Melo @ 2007-12-13 15:06 UTC (permalink / raw)
To: David S. Miller
Cc: netdev, dccp, Gerrit Renker, Ian McDonald,
Arnaldo Carvalho de Melo
In-Reply-To: <1197558365-31134-9-git-send-email-acme@redhat.com>
From: Gerrit Renker <gerrit@erg.abdn.ac.uk>
This provides a separate routine to insert options during the initial handshake.
The main purpose is to conduct feature negotiation, for the moment the only user
is the timestamp echo needed for the (CCID3) handshake RTT sample.
Padding of options has been put into a small separate routine, to be shared among
the two functions. This could also be used as a generic routine to finish inserting
options.
Also removed an `XXX' comment since its content was obvious.
Signed-off-by: Gerrit Renker <gerrit@erg.abdn.ac.uk>
Signed-off-by: Ian McDonald <ian.mcdonald@jandi.co.nz>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
net/dccp/dccp.h | 1 +
net/dccp/options.c | 32 ++++++++++++++++++++++----------
net/dccp/output.c | 2 +-
3 files changed, 24 insertions(+), 11 deletions(-)
diff --git a/net/dccp/dccp.h b/net/dccp/dccp.h
index 3af3320..b138e20 100644
--- a/net/dccp/dccp.h
+++ b/net/dccp/dccp.h
@@ -428,6 +428,7 @@ static inline int dccp_ack_pending(const struct sock *sk)
}
extern int dccp_insert_options(struct sock *sk, struct sk_buff *skb);
+extern int dccp_insert_options_rsk(struct dccp_request_sock*, struct sk_buff*);
extern int dccp_insert_option_elapsed_time(struct sock *sk,
struct sk_buff *skb,
u32 elapsed_time);
diff --git a/net/dccp/options.c b/net/dccp/options.c
index 0c996d8..bedb5da 100644
--- a/net/dccp/options.c
+++ b/net/dccp/options.c
@@ -537,6 +537,18 @@ static int dccp_insert_options_feat(struct sock *sk, struct sk_buff *skb)
return 0;
}
+/* The length of all options needs to be a multiple of 4 (5.8) */
+static void dccp_insert_option_padding(struct sk_buff *skb)
+{
+ int padding = DCCP_SKB_CB(skb)->dccpd_opt_len % 4;
+
+ if (padding != 0) {
+ padding = 4 - padding;
+ memset(skb_push(skb, padding), 0, padding);
+ DCCP_SKB_CB(skb)->dccpd_opt_len += padding;
+ }
+}
+
int dccp_insert_options(struct sock *sk, struct sk_buff *skb)
{
struct dccp_sock *dp = dccp_sk(sk);
@@ -580,18 +592,18 @@ int dccp_insert_options(struct sock *sk, struct sk_buff *skb)
dccp_insert_option_timestamp_echo(dp, NULL, skb))
return -1;
- /* XXX: insert other options when appropriate */
+ dccp_insert_option_padding(skb);
+ return 0;
+}
- if (DCCP_SKB_CB(skb)->dccpd_opt_len != 0) {
- /* The length of all options has to be a multiple of 4 */
- int padding = DCCP_SKB_CB(skb)->dccpd_opt_len % 4;
+int dccp_insert_options_rsk(struct dccp_request_sock *dreq, struct sk_buff *skb)
+{
+ DCCP_SKB_CB(skb)->dccpd_opt_len = 0;
- if (padding != 0) {
- padding = 4 - padding;
- memset(skb_push(skb, padding), 0, padding);
- DCCP_SKB_CB(skb)->dccpd_opt_len += padding;
- }
- }
+ if (dreq->dreq_timestamp_echo != 0 &&
+ dccp_insert_option_timestamp_echo(NULL, dreq, skb))
+ return -1;
+ dccp_insert_option_padding(skb);
return 0;
}
diff --git a/net/dccp/output.c b/net/dccp/output.c
index b2e1791..5589a5e 100644
--- a/net/dccp/output.c
+++ b/net/dccp/output.c
@@ -303,7 +303,7 @@ struct sk_buff *dccp_make_response(struct sock *sk, struct dst_entry *dst,
DCCP_SKB_CB(skb)->dccpd_type = DCCP_PKT_RESPONSE;
DCCP_SKB_CB(skb)->dccpd_seq = dreq->dreq_iss;
- if (dccp_insert_options(sk, skb)) {
+ if (dccp_insert_options_rsk(dreq, skb)) {
kfree_skb(skb);
return NULL;
}
--
1.5.3.4
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox