diff --git a/[refs] b/[refs] index f1fe380d6e0d..9f6b52011ce2 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: cd0d7228b4f0279f219bc555fa0192dc072d79cd +refs/heads/master: 4017dbdc14af1903dc9fcba4d08b89c02325069d diff --git a/trunk/CREDITS b/trunk/CREDITS index 1deb331d96ed..d78359f5f64d 100644 --- a/trunk/CREDITS +++ b/trunk/CREDITS @@ -518,7 +518,7 @@ N: Zach Brown E: zab@zabbo.net D: maestro pci sound -N: David Brownell +M: David Brownell D: Kernel engineer, mentor, and friend. Maintained USB EHCI and D: gadget layers, SPI subsystem, GPIO subsystem, and more than a few D: device drivers. His encouragement also helped many engineers get diff --git a/trunk/Documentation/Changes b/trunk/Documentation/Changes index b17580885273..5f4828a034e3 100644 --- a/trunk/Documentation/Changes +++ b/trunk/Documentation/Changes @@ -2,7 +2,13 @@ Intro ===== This document is designed to provide a list of the minimum levels of -software necessary to run the 3.0 kernels. +software necessary to run the 2.6 kernels, as well as provide brief +instructions regarding any other "Gotchas" users may encounter when +trying life on the Bleeding Edge. If upgrading from a pre-2.4.x +kernel, please consult the Changes file included with 2.4.x kernels for +additional information; most of that information will not be repeated +here. Basically, this document assumes that your system is already +functional and running at least 2.4.x kernels. This document is originally based on my "Changes" file for 2.0.x kernels and therefore owes credit to the same people as that file (Jared Mauch, @@ -16,10 +22,11 @@ Upgrade to at *least* these software revisions before thinking you've encountered a bug! If you're unsure what version you're currently running, the suggested command should tell you. -Again, keep in mind that this list assumes you are already functionally -running a Linux kernel. Also, not all tools are necessary on all -systems; obviously, if you don't have any ISDN hardware, for example, -you probably needn't concern yourself with isdn4k-utils. +Again, keep in mind that this list assumes you are already +functionally running a Linux 2.4 kernel. Also, not all tools are +necessary on all systems; obviously, if you don't have any ISDN +hardware, for example, you probably needn't concern yourself with +isdn4k-utils. o Gnu C 3.2 # gcc --version o Gnu make 3.80 # make --version @@ -107,12 +114,12 @@ Ksymoops If the unthinkable happens and your kernel oopses, you may need the ksymoops tool to decode it, but in most cases you don't. -It is generally preferred to build the kernel with CONFIG_KALLSYMS so -that it produces readable dumps that can be used as-is (this also -produces better output than ksymoops). If for some reason your kernel -is not build with CONFIG_KALLSYMS and you have no way to rebuild and -reproduce the Oops with that option, then you can still decode that Oops -with ksymoops. +In the 2.6 kernel it is generally preferred to build the kernel with +CONFIG_KALLSYMS so that it produces readable dumps that can be used as-is +(this also produces better output than ksymoops). +If for some reason your kernel is not build with CONFIG_KALLSYMS and +you have no way to rebuild and reproduce the Oops with that option, then +you can still decode that Oops with ksymoops. Module-Init-Tools ----------------- @@ -254,8 +261,8 @@ needs to be recompiled or (preferably) upgraded. NFS-utils --------- -In ancient (2.4 and earlier) kernels, the nfs server needed to know -about any client that expected to be able to access files via NFS. This +In 2.4 and earlier kernels, the nfs server needed to know about any +client that expected to be able to access files via NFS. This information would be given to the kernel by "mountd" when the client mounted the filesystem, or by "exportfs" at system startup. exportfs would take information about active clients from /var/lib/nfs/rmtab. @@ -265,11 +272,11 @@ which is not always easy, particularly when trying to implement fail-over. Even when the system is working well, rmtab suffers from getting lots of old entries that never get removed. -With modern kernels we have the option of having the kernel tell mountd -when it gets a request from an unknown host, and mountd can give -appropriate export information to the kernel. This removes the -dependency on rmtab and means that the kernel only needs to know about -currently active clients. +With 2.6 we have the option of having the kernel tell mountd when it +gets a request from an unknown host, and mountd can give appropriate +export information to the kernel. This removes the dependency on +rmtab and means that the kernel only needs to know about currently +active clients. To enable this new functionality, you need to: diff --git a/trunk/Documentation/CodingStyle b/trunk/Documentation/CodingStyle index fa6e25b94a54..58b0bf917834 100644 --- a/trunk/Documentation/CodingStyle +++ b/trunk/Documentation/CodingStyle @@ -680,8 +680,8 @@ ones already enabled by DEBUG. Chapter 14: Allocating memory The kernel provides the following general purpose memory allocators: -kmalloc(), kzalloc(), kcalloc(), vmalloc(), and vzalloc(). Please refer to -the API documentation for further information about them. +kmalloc(), kzalloc(), kcalloc(), and vmalloc(). Please refer to the API +documentation for further information about them. The preferred form for passing a size of a struct is the following: diff --git a/trunk/Documentation/cgroups/blkio-controller.txt b/trunk/Documentation/cgroups/blkio-controller.txt index 84f0a15fc210..cd45c8ea7463 100644 --- a/trunk/Documentation/cgroups/blkio-controller.txt +++ b/trunk/Documentation/cgroups/blkio-controller.txt @@ -77,7 +77,7 @@ Throttling/Upper Limit policy - Specify a bandwidth rate on particular device for root group. The format for policy is ": ". - echo "8:16 1048576" > /sys/fs/cgroup/blkio/blkio.throttle.read_bps_device + echo "8:16 1048576" > /sys/fs/cgroup/blkio/blkio.read_bps_device Above will put a limit of 1MB/second on reads happening for root group on device having major/minor number 8:16. @@ -90,7 +90,7 @@ Throttling/Upper Limit policy 1024+0 records out 4194304 bytes (4.2 MB) copied, 4.0001 s, 1.0 MB/s - Limits for writes can be put using blkio.throttle.write_bps_device file. + Limits for writes can be put using blkio.write_bps_device file. Hierarchical Cgroups ==================== @@ -286,28 +286,28 @@ Throttling/Upper limit policy files specified in bytes per second. Rules are per deivce. Following is the format. - echo ": " > /cgrp/blkio.throttle.read_bps_device + echo ": " > /cgrp/blkio.read_bps_device - blkio.throttle.write_bps_device - Specifies upper limit on WRITE rate to the device. IO rate is specified in bytes per second. Rules are per deivce. Following is the format. - echo ": " > /cgrp/blkio.throttle.write_bps_device + echo ": " > /cgrp/blkio.write_bps_device - blkio.throttle.read_iops_device - Specifies upper limit on READ rate from the device. IO rate is specified in IO per second. Rules are per deivce. Following is the format. - echo ": " > /cgrp/blkio.throttle.read_iops_device + echo ": " > /cgrp/blkio.read_iops_device - blkio.throttle.write_iops_device - Specifies upper limit on WRITE rate to the device. IO rate is specified in io per second. Rules are per deivce. Following is the format. - echo ": " > /cgrp/blkio.throttle.write_iops_device + echo ": " > /cgrp/blkio.write_iops_device Note: If both BW and IOPS rules are specified for a device, then IO is subjectd to both the constraints. diff --git a/trunk/Documentation/feature-removal-schedule.txt b/trunk/Documentation/feature-removal-schedule.txt index b1c921c27519..72e238465b0b 100644 --- a/trunk/Documentation/feature-removal-schedule.txt +++ b/trunk/Documentation/feature-removal-schedule.txt @@ -583,25 +583,3 @@ Why: Superseded by the UVCIOC_CTRL_QUERY ioctl. Who: Laurent Pinchart ---------------------------- - -What: For VIDIOC_S_FREQUENCY the type field must match the device node's type. - If not, return -EINVAL. -When: 3.2 -Why: It makes no sense to switch the tuner to radio mode by calling - VIDIOC_S_FREQUENCY on a video node, or to switch the tuner to tv mode by - calling VIDIOC_S_FREQUENCY on a radio node. This is the first step of a - move to more consistent handling of tv and radio tuners. -Who: Hans Verkuil - ----------------------------- - -What: Opening a radio device node will no longer automatically switch the - tuner mode from tv to radio. -When: 3.3 -Why: Just opening a V4L device should not change the state of the hardware - like that. It's very unexpected and against the V4L spec. Instead, you - switch to radio mode by calling VIDIOC_S_FREQUENCY. This is the second - and last step of the move to consistent handling of tv and radio tuners. -Who: Hans Verkuil - ----------------------------- diff --git a/trunk/Documentation/filesystems/caching/netfs-api.txt b/trunk/Documentation/filesystems/caching/netfs-api.txt index 7cc6bf2871eb..a167ab876c35 100644 --- a/trunk/Documentation/filesystems/caching/netfs-api.txt +++ b/trunk/Documentation/filesystems/caching/netfs-api.txt @@ -673,22 +673,6 @@ storage request to complete, or it may attempt to cancel the storage request - in which case the page will not be stored in the cache this time. -BULK INODE PAGE UNCACHE ------------------------ - -A convenience routine is provided to perform an uncache on all the pages -attached to an inode. This assumes that the pages on the inode correspond on a -1:1 basis with the pages in the cache. - - void fscache_uncache_all_inode_pages(struct fscache_cookie *cookie, - struct inode *inode); - -This takes the netfs cookie that the pages were cached with and the inode that -the pages are attached to. This function will wait for pages to finish being -written to the cache and for the cache to finish with the page generally. No -error is returned. - - ========================== INDEX AND DATA FILE UPDATE ========================== diff --git a/trunk/Documentation/hwmon/f71882fg b/trunk/Documentation/hwmon/f71882fg index de91c0db5846..84d2623810f3 100644 --- a/trunk/Documentation/hwmon/f71882fg +++ b/trunk/Documentation/hwmon/f71882fg @@ -22,10 +22,6 @@ Supported chips: Prefix: 'f71869' Addresses scanned: none, address read from Super I/O config space Datasheet: Available from the Fintek website - * Fintek F71869A - Prefix: 'f71869a' - Addresses scanned: none, address read from Super I/O config space - Datasheet: Not public * Fintek F71882FG and F71883FG Prefix: 'f71882fg' Addresses scanned: none, address read from Super I/O config space diff --git a/trunk/Documentation/hwmon/k10temp b/trunk/Documentation/hwmon/k10temp index a10f73624ad3..0393c89277c0 100644 --- a/trunk/Documentation/hwmon/k10temp +++ b/trunk/Documentation/hwmon/k10temp @@ -9,8 +9,8 @@ Supported chips: Socket S1G3: Athlon II, Sempron, Turion II * AMD Family 11h processors: Socket S1G2: Athlon (X2), Sempron (X2), Turion X2 (Ultra) -* AMD Family 12h processors: "Llano" (E2/A4/A6/A8-Series) -* AMD Family 14h processors: "Brazos" (C/E/G/Z-Series) +* AMD Family 12h processors: "Llano" +* AMD Family 14h processors: "Brazos" (C/E/G-Series) * AMD Family 15h processors: "Bulldozer" Prefix: 'k10temp' @@ -20,16 +20,12 @@ Supported chips: http://support.amd.com/us/Processor_TechDocs/31116.pdf BIOS and Kernel Developer's Guide (BKDG) for AMD Family 11h Processors: http://support.amd.com/us/Processor_TechDocs/41256.pdf - BIOS and Kernel Developer's Guide (BKDG) for AMD Family 12h Processors: - http://support.amd.com/us/Processor_TechDocs/41131.pdf BIOS and Kernel Developer's Guide (BKDG) for AMD Family 14h Models 00h-0Fh Processors: http://support.amd.com/us/Processor_TechDocs/43170.pdf Revision Guide for AMD Family 10h Processors: http://support.amd.com/us/Processor_TechDocs/41322.pdf Revision Guide for AMD Family 11h Processors: http://support.amd.com/us/Processor_TechDocs/41788.pdf - Revision Guide for AMD Family 12h Processors: - http://support.amd.com/us/Processor_TechDocs/44739.pdf Revision Guide for AMD Family 14h Models 00h-0Fh Processors: http://support.amd.com/us/Processor_TechDocs/47534.pdf AMD Family 11h Processor Power and Thermal Data Sheet for Notebooks: diff --git a/trunk/Documentation/kernel-parameters.txt b/trunk/Documentation/kernel-parameters.txt index aa47be71df4c..fd248a318211 100644 --- a/trunk/Documentation/kernel-parameters.txt +++ b/trunk/Documentation/kernel-parameters.txt @@ -2015,8 +2015,6 @@ bytes respectively. Such letter suffixes can also be entirely omitted. the default. off: Turn ECRC off on: Turn ECRC on. - realloc reallocate PCI resources if allocations done by BIOS - are erroneous. pcie_aspm= [PCIE] Forcibly enable or disable PCIe Active State Power Management. diff --git a/trunk/Documentation/laptops/thinkpad-acpi.txt b/trunk/Documentation/laptops/thinkpad-acpi.txt index 61815483efa3..1565eefd6fd5 100644 --- a/trunk/Documentation/laptops/thinkpad-acpi.txt +++ b/trunk/Documentation/laptops/thinkpad-acpi.txt @@ -534,8 +534,6 @@ Events that are never propagated by the driver: 0x2404 System is waking up from hibernation to undock 0x2405 System is waking up from hibernation to eject bay 0x5010 Brightness level changed/control event -0x6000 KEYBOARD: Numlock key pressed -0x6005 KEYBOARD: Fn key pressed (TO BE VERIFIED) Events that are propagated by the driver to userspace: @@ -547,8 +545,6 @@ Events that are propagated by the driver to userspace: 0x3006 Bay hotplug request (hint to power up SATA link when the optical drive tray is ejected) 0x4003 Undocked (see 0x2x04), can sleep again -0x4010 Docked into hotplug port replicator (non-ACPI dock) -0x4011 Undocked from hotplug port replicator (non-ACPI dock) 0x500B Tablet pen inserted into its storage bay 0x500C Tablet pen removed from its storage bay 0x6011 ALARM: battery is too hot @@ -556,7 +552,6 @@ Events that are propagated by the driver to userspace: 0x6021 ALARM: a sensor is too hot 0x6022 ALARM: a sensor is extremely hot 0x6030 System thermal table changed -0x6040 Nvidia Optimus/AC adapter related (TO BE VERIFIED) Battery nearly empty alarms are a last resort attempt to get the operating system to hibernate or shutdown cleanly (0x2313), or shutdown diff --git a/trunk/Documentation/networking/ifenslave.c b/trunk/Documentation/networking/ifenslave.c index 65968fbf1e49..2bac9618c345 100644 --- a/trunk/Documentation/networking/ifenslave.c +++ b/trunk/Documentation/networking/ifenslave.c @@ -260,7 +260,7 @@ int main(int argc, char *argv[]) case 'V': opt_V++; exclusive++; break; case '?': - fprintf(stderr, "%s", usage_msg); + fprintf(stderr, usage_msg); res = 2; goto out; } @@ -268,13 +268,13 @@ int main(int argc, char *argv[]) /* options check */ if (exclusive > 1) { - fprintf(stderr, "%s", usage_msg); + fprintf(stderr, usage_msg); res = 2; goto out; } if (opt_v || opt_V) { - printf("%s", version); + printf(version); if (opt_V) { res = 0; goto out; @@ -282,14 +282,14 @@ int main(int argc, char *argv[]) } if (opt_u) { - printf("%s", usage_msg); + printf(usage_msg); res = 0; goto out; } if (opt_h) { - printf("%s", usage_msg); - printf("%s", help_msg); + printf(usage_msg); + printf(help_msg); res = 0; goto out; } @@ -309,7 +309,7 @@ int main(int argc, char *argv[]) goto out; } else { /* Just show usage */ - fprintf(stderr, "%s", usage_msg); + fprintf(stderr, usage_msg); res = 2; goto out; } @@ -320,7 +320,7 @@ int main(int argc, char *argv[]) master_ifname = *spp++; if (master_ifname == NULL) { - fprintf(stderr, "%s", usage_msg); + fprintf(stderr, usage_msg); res = 2; goto out; } @@ -339,7 +339,7 @@ int main(int argc, char *argv[]) if (slave_ifname == NULL) { if (opt_d || opt_c) { - fprintf(stderr, "%s", usage_msg); + fprintf(stderr, usage_msg); res = 2; goto out; } diff --git a/trunk/Documentation/networking/ip-sysctl.txt b/trunk/Documentation/networking/ip-sysctl.txt index db2a4067013c..3dcb26cd33f6 100644 --- a/trunk/Documentation/networking/ip-sysctl.txt +++ b/trunk/Documentation/networking/ip-sysctl.txt @@ -336,7 +336,7 @@ tcp_orphan_retries - INTEGER when RTO retransmissions remain unacknowledged. See tcp_retries2 for more details. - The default value is 8. + The default value is 7. If your machine is a loaded WEB server, you should think about lowering this value, such sockets may consume significant resources. Cf. tcp_max_orphans. @@ -384,7 +384,7 @@ tcp_rmem - vector of 3 INTEGERs: min, default, max min: Minimal size of receive buffer used by TCP sockets. It is guaranteed to each TCP socket, even under moderate memory pressure. - Default: 1 page + Default: 8K default: initial size of receive buffer used by TCP sockets. This value overrides net.core.rmem_default used by other protocols. @@ -473,7 +473,7 @@ tcp_window_scaling - BOOLEAN tcp_wmem - vector of 3 INTEGERs: min, default, max min: Amount of memory reserved for send buffers for TCP sockets. Each TCP socket has rights to use it due to fact of its birth. - Default: 1 page + Default: 4K default: initial size of send buffer used by TCP sockets. This value overrides net.core.wmem_default used by other protocols. @@ -543,13 +543,13 @@ udp_rmem_min - INTEGER Minimal size of receive buffer used by UDP sockets in moderation. Each UDP socket is able to use the size for receiving data, even if total pages of UDP sockets exceed udp_mem pressure. The unit is byte. - Default: 1 page + Default: 4096 udp_wmem_min - INTEGER Minimal size of send buffer used by UDP sockets in moderation. Each UDP socket is able to use the size for sending data, even if total pages of UDP sockets exceed udp_mem pressure. The unit is byte. - Default: 1 page + Default: 4096 CIPSOv4 Variables: @@ -1455,17 +1455,10 @@ sctp_mem - vector of 3 INTEGERs: min, pressure, max Default is calculated at boot time from amount of available memory. sctp_rmem - vector of 3 INTEGERs: min, default, max - Only the first value ("min") is used, "default" and "max" are - ignored. - - min: Minimal size of receive buffer used by SCTP socket. - It is guaranteed to each SCTP socket (but not association) even - under moderate memory pressure. - - Default: 1 page + See tcp_rmem for a description. sctp_wmem - vector of 3 INTEGERs: min, default, max - Currently this tunable has no effect. + See tcp_wmem for a description. addr_scope_policy - INTEGER Control IPv4 address scoping - draft-stewart-tsvwg-sctp-ipv4-00 diff --git a/trunk/Documentation/networking/netdev-features.txt b/trunk/Documentation/networking/netdev-features.txt deleted file mode 100644 index 4b1c0dcef84c..000000000000 --- a/trunk/Documentation/networking/netdev-features.txt +++ /dev/null @@ -1,154 +0,0 @@ -Netdev features mess and how to get out from it alive -===================================================== - -Author: - Michał Mirosław - - - - Part I: Feature sets -====================== - -Long gone are the days when a network card would just take and give packets -verbatim. Today's devices add multiple features and bugs (read: offloads) -that relieve an OS of various tasks like generating and checking checksums, -splitting packets, classifying them. Those capabilities and their state -are commonly referred to as netdev features in Linux kernel world. - -There are currently three sets of features relevant to the driver, and -one used internally by network core: - - 1. netdev->hw_features set contains features whose state may possibly - be changed (enabled or disabled) for a particular device by user's - request. This set should be initialized in ndo_init callback and not - changed later. - - 2. netdev->features set contains features which are currently enabled - for a device. This should be changed only by network core or in - error paths of ndo_set_features callback. - - 3. netdev->vlan_features set contains features whose state is inherited - by child VLAN devices (limits netdev->features set). This is currently - used for all VLAN devices whether tags are stripped or inserted in - hardware or software. - - 4. netdev->wanted_features set contains feature set requested by user. - This set is filtered by ndo_fix_features callback whenever it or - some device-specific conditions change. This set is internal to - networking core and should not be referenced in drivers. - - - - Part II: Controlling enabled features -======================================= - -When current feature set (netdev->features) is to be changed, new set -is calculated and filtered by calling ndo_fix_features callback -and netdev_fix_features(). If the resulting set differs from current -set, it is passed to ndo_set_features callback and (if the callback -returns success) replaces value stored in netdev->features. -NETDEV_FEAT_CHANGE notification is issued after that whenever current -set might have changed. - -The following events trigger recalculation: - 1. device's registration, after ndo_init returned success - 2. user requested changes in features state - 3. netdev_update_features() is called - -ndo_*_features callbacks are called with rtnl_lock held. Missing callbacks -are treated as always returning success. - -A driver that wants to trigger recalculation must do so by calling -netdev_update_features() while holding rtnl_lock. This should not be done -from ndo_*_features callbacks. netdev->features should not be modified by -driver except by means of ndo_fix_features callback. - - - - Part III: Implementation hints -================================ - - * ndo_fix_features: - -All dependencies between features should be resolved here. The resulting -set can be reduced further by networking core imposed limitations (as coded -in netdev_fix_features()). For this reason it is safer to disable a feature -when its dependencies are not met instead of forcing the dependency on. - -This callback should not modify hardware nor driver state (should be -stateless). It can be called multiple times between successive -ndo_set_features calls. - -Callback must not alter features contained in NETIF_F_SOFT_FEATURES or -NETIF_F_NEVER_CHANGE sets. The exception is NETIF_F_VLAN_CHALLENGED but -care must be taken as the change won't affect already configured VLANs. - - * ndo_set_features: - -Hardware should be reconfigured to match passed feature set. The set -should not be altered unless some error condition happens that can't -be reliably detected in ndo_fix_features. In this case, the callback -should update netdev->features to match resulting hardware state. -Errors returned are not (and cannot be) propagated anywhere except dmesg. -(Note: successful return is zero, >0 means silent error.) - - - - Part IV: Features -=================== - -For current list of features, see include/linux/netdev_features.h. -This section describes semantics of some of them. - - * Transmit checksumming - -For complete description, see comments near the top of include/linux/skbuff.h. - -Note: NETIF_F_HW_CSUM is a superset of NETIF_F_IP_CSUM + NETIF_F_IPV6_CSUM. -It means that device can fill TCP/UDP-like checksum anywhere in the packets -whatever headers there might be. - - * Transmit TCP segmentation offload - -NETIF_F_TSO_ECN means that hardware can properly split packets with CWR bit -set, be it TCPv4 (when NETIF_F_TSO is enabled) or TCPv6 (NETIF_F_TSO6). - - * Transmit DMA from high memory - -On platforms where this is relevant, NETIF_F_HIGHDMA signals that -ndo_start_xmit can handle skbs with frags in high memory. - - * Transmit scatter-gather - -Those features say that ndo_start_xmit can handle fragmented skbs: -NETIF_F_SG --- paged skbs (skb_shinfo()->frags), NETIF_F_FRAGLIST --- -chained skbs (skb->next/prev list). - - * Software features - -Features contained in NETIF_F_SOFT_FEATURES are features of networking -stack. Driver should not change behaviour based on them. - - * LLTX driver (deprecated for hardware drivers) - -NETIF_F_LLTX should be set in drivers that implement their own locking in -transmit path or don't need locking at all (e.g. software tunnels). -In ndo_start_xmit, it is recommended to use a try_lock and return -NETDEV_TX_LOCKED when the spin lock fails. The locking should also properly -protect against other callbacks (the rules you need to find out). - -Don't use it for new drivers. - - * netns-local device - -NETIF_F_NETNS_LOCAL is set for devices that are not allowed to move between -network namespaces (e.g. loopback). - -Don't use it in drivers. - - * VLAN challenged - -NETIF_F_VLAN_CHALLENGED should be set for devices which can't cope with VLAN -headers. Some drivers set this because the cards can't handle the bigger MTU. -[FIXME: Those cases could be fixed in VLAN code by allowing only reduced-MTU -VLANs. This may be not useful, though.] diff --git a/trunk/Documentation/networking/nfc.txt b/trunk/Documentation/networking/nfc.txt deleted file mode 100644 index b24c29bdae27..000000000000 --- a/trunk/Documentation/networking/nfc.txt +++ /dev/null @@ -1,128 +0,0 @@ -Linux NFC subsystem -=================== - -The Near Field Communication (NFC) subsystem is required to standardize the -NFC device drivers development and to create an unified userspace interface. - -This document covers the architecture overview, the device driver interface -description and the userspace interface description. - -Architecture overview ---------------------- - -The NFC subsystem is responsible for: - - NFC adapters management; - - Polling for targets; - - Low-level data exchange; - -The subsystem is divided in some parts. The 'core' is responsible for -providing the device driver interface. On the other side, it is also -responsible for providing an interface to control operations and low-level -data exchange. - -The control operations are available to userspace via generic netlink. - -The low-level data exchange interface is provided by the new socket family -PF_NFC. The NFC_SOCKPROTO_RAW performs raw communication with NFC targets. - - - +--------------------------------------+ - | USER SPACE | - +--------------------------------------+ - ^ ^ - | low-level | control - | data exchange | operations - | | - | v - | +-----------+ - | AF_NFC | netlink | - | socket +-----------+ - | raw ^ - | | - v v - +---------+ +-----------+ - | rawsock | <--------> | core | - +---------+ +-----------+ - ^ - | - v - +-----------+ - | driver | - +-----------+ - -Device Driver Interface ------------------------ - -When registering on the NFC subsystem, the device driver must inform the core -of the set of supported NFC protocols and the set of ops callbacks. The ops -callbacks that must be implemented are the following: - -* start_poll - setup the device to poll for targets -* stop_poll - stop on progress polling operation -* activate_target - select and initialize one of the targets found -* deactivate_target - deselect and deinitialize the selected target -* data_exchange - send data and receive the response (transceive operation) - -Userspace interface --------------------- - -The userspace interface is divided in control operations and low-level data -exchange operation. - -CONTROL OPERATIONS: - -Generic netlink is used to implement the interface to the control operations. -The operations are composed by commands and events, all listed below: - -* NFC_CMD_GET_DEVICE - get specific device info or dump the device list -* NFC_CMD_START_POLL - setup a specific device to polling for targets -* NFC_CMD_STOP_POLL - stop the polling operation in a specific device -* NFC_CMD_GET_TARGET - dump the list of targets found by a specific device - -* NFC_EVENT_DEVICE_ADDED - reports an NFC device addition -* NFC_EVENT_DEVICE_REMOVED - reports an NFC device removal -* NFC_EVENT_TARGETS_FOUND - reports START_POLL results when 1 or more targets -are found - -The user must call START_POLL to poll for NFC targets, passing the desired NFC -protocols through NFC_ATTR_PROTOCOLS attribute. The device remains in polling -state until it finds any target. However, the user can stop the polling -operation by calling STOP_POLL command. In this case, it will be checked if -the requester of STOP_POLL is the same of START_POLL. - -If the polling operation finds one or more targets, the event TARGETS_FOUND is -sent (including the device id). The user must call GET_TARGET to get the list of -all targets found by such device. Each reply message has target attributes with -relevant information such as the supported NFC protocols. - -All polling operations requested through one netlink socket are stopped when -it's closed. - -LOW-LEVEL DATA EXCHANGE: - -The userspace must use PF_NFC sockets to perform any data communication with -targets. All NFC sockets use AF_NFC: - -struct sockaddr_nfc { - sa_family_t sa_family; - __u32 dev_idx; - __u32 target_idx; - __u32 nfc_protocol; -}; - -To establish a connection with one target, the user must create an -NFC_SOCKPROTO_RAW socket and call the 'connect' syscall with the sockaddr_nfc -struct correctly filled. All information comes from NFC_EVENT_TARGETS_FOUND -netlink event. As a target can support more than one NFC protocol, the user -must inform which protocol it wants to use. - -Internally, 'connect' will result in an activate_target call to the driver. -When the socket is closed, the target is deactivated. - -The data format exchanged through the sockets is NFC protocol dependent. For -instance, when communicating with MIFARE tags, the data exchanged are MIFARE -commands and their responses. - -The first received package is the response to the first sent package and so -on. In order to allow valid "empty" responses, every data received has a NULL -header of 1 byte. diff --git a/trunk/Documentation/power/devices.txt b/trunk/Documentation/power/devices.txt index 64565aac6e40..88880839ece4 100644 --- a/trunk/Documentation/power/devices.txt +++ b/trunk/Documentation/power/devices.txt @@ -520,20 +520,59 @@ Support for power domains is provided through the pwr_domain field of struct device. This field is a pointer to an object of type struct dev_power_domain, defined in include/linux/pm.h, providing a set of power management callbacks analogous to the subsystem-level and device driver callbacks that are executed -for the given device during all power transitions, instead of the respective -subsystem-level callbacks. Specifically, if a device's pm_domain pointer is -not NULL, the ->suspend() callback from the object pointed to by it will be -executed instead of its subsystem's (e.g. bus type's) ->suspend() callback and -anlogously for all of the remaining callbacks. In other words, power management -domain callbacks, if defined for the given device, always take precedence over -the callbacks provided by the device's subsystem (e.g. bus type). - -The support for device power management domains is only relevant to platforms -needing to use the same device driver power management callbacks in many -different power domain configurations and wanting to avoid incorporating the -support for power domains into subsystem-level callbacks, for example by -modifying the platform bus type. Other platforms need not implement it or take -it into account in any way. +for the given device during all power transitions, in addition to the respective +subsystem-level callbacks. Specifically, the power domain "suspend" callbacks +(i.e. ->runtime_suspend(), ->suspend(), ->freeze(), ->poweroff(), etc.) are +executed after the analogous subsystem-level callbacks, while the power domain +"resume" callbacks (i.e. ->runtime_resume(), ->resume(), ->thaw(), ->restore, +etc.) are executed before the analogous subsystem-level callbacks. Error codes +returned by the "suspend" and "resume" power domain callbacks are ignored. + +Power domain ->runtime_idle() callback is executed before the subsystem-level +->runtime_idle() callback and the result returned by it is not ignored. Namely, +if it returns error code, the subsystem-level ->runtime_idle() callback will not +be called and the helper function rpm_idle() executing it will return error +code. This mechanism is intended to help platforms where saving device state +is a time consuming operation and should only be carried out if all devices +in the power domain are idle, before turning off the shared power resource(s). +Namely, the power domain ->runtime_idle() callback may return error code until +the pm_runtime_idle() helper (or its asychronous version) has been called for +all devices in the power domain (it is recommended that the returned error code +be -EBUSY in those cases), preventing the subsystem-level ->runtime_idle() +callback from being run prematurely. + +The support for device power domains is only relevant to platforms needing to +use the same subsystem-level (e.g. platform bus type) and device driver power +management callbacks in many different power domain configurations and wanting +to avoid incorporating the support for power domains into the subsystem-level +callbacks. The other platforms need not implement it or take it into account +in any way. + + +System Devices +-------------- +System devices (sysdevs) follow a slightly different API, which can be found in + + include/linux/sysdev.h + drivers/base/sys.c + +System devices will be suspended with interrupts disabled, and after all other +devices have been suspended. On resume, they will be resumed before any other +devices, and also with interrupts disabled. These things occur in special +"sysdev_driver" phases, which affect only system devices. + +Thus, after the suspend_noirq (or freeze_noirq or poweroff_noirq) phase, when +the non-boot CPUs are all offline and IRQs are disabled on the remaining online +CPU, then a sysdev_driver.suspend phase is carried out, and the system enters a +sleep state (or a system image is created). During resume (or after the image +has been created or loaded) a sysdev_driver.resume phase is carried out, IRQs +are enabled on the only online CPU, the non-boot CPUs are enabled, and the +resume_noirq (or thaw_noirq or restore_noirq) phase begins. + +Code to actually enter and exit the system-wide low power state sometimes +involves hardware details that are only known to the boot firmware, and +may leave a CPU running software (from SRAM or flash memory) that monitors +the system and manages its wakeup sequence. Device Low Power (suspend) States diff --git a/trunk/Documentation/power/runtime_pm.txt b/trunk/Documentation/power/runtime_pm.txt index b24875b1ced5..654097b130b4 100644 --- a/trunk/Documentation/power/runtime_pm.txt +++ b/trunk/Documentation/power/runtime_pm.txt @@ -501,29 +501,13 @@ helper functions described in Section 4. In that case, pm_runtime_resume() should be used. Of course, for this purpose the device's run-time PM has to be enabled earlier by calling pm_runtime_enable(). -If the device bus type's or driver's ->probe() callback runs +If the device bus type's or driver's ->probe() or ->remove() callback runs pm_runtime_suspend() or pm_runtime_idle() or their asynchronous counterparts, they will fail returning -EAGAIN, because the device's usage counter is -incremented by the driver core before executing ->probe(). Still, it may be -desirable to suspend the device as soon as ->probe() has finished, so the driver -core uses pm_runtime_put_sync() to invoke the subsystem-level idle callback for -the device at that time. - -Moreover, the driver core prevents runtime PM callbacks from racing with the bus -notifier callback in __device_release_driver(), which is necessary, because the -notifier is used by some subsystems to carry out operations affecting the -runtime PM functionality. It does so by calling pm_runtime_get_sync() before -driver_sysfs_remove() and the BUS_NOTIFY_UNBIND_DRIVER notifications. This -resumes the device if it's in the suspended state and prevents it from -being suspended again while those routines are being executed. - -To allow bus types and drivers to put devices into the suspended state by -calling pm_runtime_suspend() from their ->remove() routines, the driver core -executes pm_runtime_put_sync() after running the BUS_NOTIFY_UNBIND_DRIVER -notifications in __device_release_driver(). This requires bus types and -drivers to make their ->remove() callbacks avoid races with runtime PM directly, -but also it allows of more flexibility in the handling of devices during the -removal of their drivers. +incremented by the core before executing ->probe() and ->remove(). Still, it +may be desirable to suspend the device as soon as ->probe() or ->remove() has +finished, so the PM core uses pm_runtime_idle_sync() to invoke the +subsystem-level idle callback for the device at that time. The user space can effectively disallow the driver of the device to power manage it at run time by changing the value of its /sys/devices/.../power/control @@ -582,6 +566,11 @@ to do this is: pm_runtime_set_active(dev); pm_runtime_enable(dev); +The PM core always increments the run-time usage counter before calling the +->prepare() callback and decrements it after calling the ->complete() callback. +Hence disabling run-time PM temporarily like this will not cause any run-time +suspend callbacks to be lost. + 7. Generic subsystem callbacks Subsystems may wish to conserve code space by using the set of generic power diff --git a/trunk/Documentation/spinlocks.txt b/trunk/Documentation/spinlocks.txt index 9dbe885ecd8d..2e3c64b1a6a5 100644 --- a/trunk/Documentation/spinlocks.txt +++ b/trunk/Documentation/spinlocks.txt @@ -13,8 +13,18 @@ static DEFINE_SPINLOCK(xxx_lock); The above is always safe. It will disable interrupts _locally_, but the spinlock itself will guarantee the global lock, so it will guarantee that there is only one thread-of-control within the region(s) protected by that -lock. This works well even under UP also, so the code does _not_ need to -worry about UP vs SMP issues: the spinlocks work correctly under both. +lock. This works well even under UP. The above sequence under UP +essentially is just the same as doing + + unsigned long flags; + + save_flags(flags); cli(); + ... critical section ... + restore_flags(flags); + +so the code does _not_ need to worry about UP vs SMP issues: the spinlocks +work correctly under both (and spinlocks are actually more efficient on +architectures that allow doing the "save_flags + cli" in one operation). NOTE! Implications of spin_locks for memory are further described in: @@ -26,7 +36,27 @@ The above is usually pretty simple (you usually need and want only one spinlock for most things - using more than one spinlock can make things a lot more complex and even slower and is usually worth it only for sequences that you _know_ need to be split up: avoid it at all cost if you -aren't sure). +aren't sure). HOWEVER, it _does_ mean that if you have some code that does + + cli(); + .. critical section .. + sti(); + +and another sequence that does + + spin_lock_irqsave(flags); + .. critical section .. + spin_unlock_irqrestore(flags); + +then they are NOT mutually exclusive, and the critical regions can happen +at the same time on two different CPU's. That's fine per se, but the +critical regions had better be critical for different things (ie they +can't stomp on each other). + +The above is a problem mainly if you end up mixing code - for example the +routines in ll_rw_block() tend to use cli/sti to protect the atomicity of +their actions, and if a driver uses spinlocks instead then you should +think about issues like the above. This is really the only really hard part about spinlocks: once you start using spinlocks they tend to expand to areas you might not have noticed @@ -90,10 +120,11 @@ Lesson 3: spinlocks revisited. The single spin-lock primitives above are by no means the only ones. They are the most safe ones, and the ones that work under all circumstances, -but partly _because_ they are safe they are also fairly slow. They are slower -than they'd need to be, because they do have to disable interrupts -(which is just a single instruction on a x86, but it's an expensive one - -and on other architectures it can be worse). +but partly _because_ they are safe they are also fairly slow. They are +much faster than a generic global cli/sti pair, but slower than they'd +need to be, because they do have to disable interrupts (which is just a +single instruction on a x86, but it's an expensive one - and on other +architectures it can be worse). If you have a case where you have to protect a data structure across several CPU's and you want to use spinlocks you can potentially use diff --git a/trunk/Documentation/usb/error-codes.txt b/trunk/Documentation/usb/error-codes.txt index b3f606b81a03..d83703ea74b2 100644 --- a/trunk/Documentation/usb/error-codes.txt +++ b/trunk/Documentation/usb/error-codes.txt @@ -76,13 +76,6 @@ A transfer's actual_length may be positive even when an error has been reported. That's because transfers often involve several packets, so that one or more packets could finish before an error stops further endpoint I/O. -For isochronous URBs, the urb status value is non-zero only if the URB is -unlinked, the device is removed, the host controller is disabled, or the total -transferred length is less than the requested length and the URB_SHORT_NOT_OK -flag is set. Completion handlers for isochronous URBs should only see -urb->status set to zero, -ENOENT, -ECONNRESET, -ESHUTDOWN, or -EREMOTEIO. -Individual frame descriptor status fields may report more status codes. - 0 Transfer completed successfully @@ -139,7 +132,7 @@ Individual frame descriptor status fields may report more status codes. device removal events immediately. -EXDEV ISO transfer only partially completed - (only set in iso_frame_desc[n].status, not urb->status) + look at individual frame status for details -EINVAL ISO madness, if this happens: Log off and go home diff --git a/trunk/MAINTAINERS b/trunk/MAINTAINERS index 7a9569e06b0a..f0358cd91de3 100644 --- a/trunk/MAINTAINERS +++ b/trunk/MAINTAINERS @@ -594,16 +594,6 @@ S: Maintained F: arch/arm/lib/floppydma.S F: arch/arm/include/asm/floppy.h -ARM PMU PROFILING AND DEBUGGING -M: Will Deacon -S: Maintained -F: arch/arm/kernel/perf_event* -F: arch/arm/oprofile/common.c -F: arch/arm/kernel/pmu.c -F: arch/arm/include/asm/pmu.h -F: arch/arm/kernel/hw_breakpoint.c -F: arch/arm/include/asm/hw_breakpoint.h - ARM PORT M: Russell King L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) @@ -1355,18 +1345,16 @@ F: drivers/auxdisplay/ F: include/linux/cfag12864b.h AVR32 ARCHITECTURE -M: Haavard Skinnemoen -M: Hans-Christian Egtvedt +M: Hans-Christian Egtvedt W: http://www.atmel.com/products/AVR32/ W: http://avr32linux.org/ W: http://avrfreaks.net/ -S: Maintained +S: Supported F: arch/avr32/ AVR32/AT32AP MACHINE SUPPORT -M: Haavard Skinnemoen -M: Hans-Christian Egtvedt -S: Maintained +M: Hans-Christian Egtvedt +S: Supported F: arch/avr32/mach-at32ap/ AX.25 NETWORK LAYER @@ -1402,6 +1390,7 @@ F: include/linux/backlight.h BATMAN ADVANCED M: Marek Lindner M: Simon Wunderlich +M: Sven Eckelmann L: b.a.t.m.a.n@lists.open-mesh.org W: http://www.open-mesh.org/ S: Maintained @@ -1434,6 +1423,7 @@ S: Supported F: arch/blackfin/ BLACKFIN EMAC DRIVER +M: Michael Hennerich L: uclinux-dist-devel@blackfin.uclinux.org W: http://blackfin.uclinux.org S: Supported @@ -1649,7 +1639,7 @@ CAN NETWORK LAYER M: Oliver Hartkopp M: Oliver Hartkopp M: Urs Thuermann -L: socketcan-core@lists.berlios.de (subscribers-only) +L: socketcan-core@lists.berlios.de L: netdev@vger.kernel.org W: http://developer.berlios.de/projects/socketcan/ S: Maintained @@ -1661,7 +1651,7 @@ F: include/linux/can/raw.h CAN NETWORK DRIVERS M: Wolfgang Grandegger -L: socketcan-core@lists.berlios.de (subscribers-only) +L: socketcan-core@lists.berlios.de L: netdev@vger.kernel.org W: http://developer.berlios.de/projects/socketcan/ S: Maintained @@ -2207,7 +2197,7 @@ F: drivers/acpi/dock.c DOCUMENTATION M: Randy Dunlap L: linux-doc@vger.kernel.org -T: quilt http://userweb.kernel.org/~rdunlap/kernel-doc-patches/current/ +T: quilt oss.oracle.com/~rdunlap/kernel-doc-patches/current/ S: Maintained F: Documentation/ @@ -4289,8 +4279,8 @@ S: Maintained F: drivers/usb/musb/ MYRICOM MYRI-10G 10GbE DRIVER (MYRI10GE) -M: Jon Mason M: Andrew Gallatin +M: Brice Goglin L: netdev@vger.kernel.org W: http://www.myri.com/scs/download-Myri10GE.html S: Supported @@ -4992,7 +4982,7 @@ F: drivers/power/power_supply* PNP SUPPORT M: Adam Belay -M: Bjorn Helgaas +M: Bjorn Helgaas S: Maintained F: drivers/pnp/ @@ -5191,7 +5181,6 @@ S: Supported F: drivers/net/qlcnic/ QLOGIC QLGE 10Gb ETHERNET DRIVER -M: Jitendra Kalsaria M: Ron Mercer M: linux-driver@qlogic.com L: netdev@vger.kernel.org @@ -6445,9 +6434,8 @@ S: Maintained F: drivers/usb/misc/rio500* USB EHCI DRIVER -M: Alan Stern L: linux-usb@vger.kernel.org -S: Maintained +S: Orphan F: Documentation/usb/ehci.txt F: drivers/usb/host/ehci* @@ -6477,12 +6465,6 @@ S: Maintained F: Documentation/hid/hiddev.txt F: drivers/hid/usbhid/ -USB/IP DRIVERS -M: Matt Mooney -L: linux-usb@vger.kernel.org -S: Maintained -F: drivers/staging/usbip/ - USB ISP116X DRIVER M: Olav Kongas L: linux-usb@vger.kernel.org @@ -6512,9 +6494,8 @@ S: Maintained F: sound/usb/midi.* USB OHCI DRIVER -M: Alan Stern L: linux-usb@vger.kernel.org -S: Maintained +S: Orphan F: Documentation/usb/ohci.txt F: drivers/usb/host/ohci* @@ -6743,7 +6724,6 @@ F: fs/fat/ VIDEOBUF2 FRAMEWORK M: Pawel Osciak M: Marek Szyprowski -M: Kyungmin Park L: linux-media@vger.kernel.org S: Maintained F: drivers/media/video/videobuf2-* diff --git a/trunk/Makefile b/trunk/Makefile index 60d91f76c2fd..41330a06e4ec 100644 --- a/trunk/Makefile +++ b/trunk/Makefile @@ -1,7 +1,7 @@ VERSION = 3 PATCHLEVEL = 0 SUBLEVEL = 0 -EXTRAVERSION = -rc7 +EXTRAVERSION = -rc4 NAME = Sneaky Weasel # *DOCUMENTATION* diff --git a/trunk/README b/trunk/README index 0d5a7ddbe3ee..8510017a3576 100644 --- a/trunk/README +++ b/trunk/README @@ -1,6 +1,6 @@ - Linux kernel release 3.x + Linux kernel release 2.6.xx -These are the release notes for Linux version 3. Read them carefully, +These are the release notes for Linux version 2.6. Read them carefully, as they tell you what this is all about, explain how to install the kernel, and what to do if something goes wrong. @@ -62,10 +62,10 @@ INSTALLING the kernel source: directory where you have permissions (eg. your home directory) and unpack it: - gzip -cd linux-3.X.tar.gz | tar xvf - + gzip -cd linux-2.6.XX.tar.gz | tar xvf - or - bzip2 -dc linux-3.X.tar.bz2 | tar xvf - + bzip2 -dc linux-2.6.XX.tar.bz2 | tar xvf - Replace "XX" with the version number of the latest kernel. @@ -75,15 +75,15 @@ INSTALLING the kernel source: files. They should match the library, and not get messed up by whatever the kernel-du-jour happens to be. - - You can also upgrade between 3.x releases by patching. Patches are + - You can also upgrade between 2.6.xx releases by patching. Patches are distributed in the traditional gzip and the newer bzip2 format. To install by patching, get all the newer patch files, enter the - top level directory of the kernel source (linux-3.x) and execute: + top level directory of the kernel source (linux-2.6.xx) and execute: - gzip -cd ../patch-3.x.gz | patch -p1 + gzip -cd ../patch-2.6.xx.gz | patch -p1 or - bzip2 -dc ../patch-3.x.bz2 | patch -p1 + bzip2 -dc ../patch-2.6.xx.bz2 | patch -p1 (repeat xx for all versions bigger than the version of your current source tree, _in_order_) and you should be ok. You may want to remove @@ -91,9 +91,9 @@ INSTALLING the kernel source: failed patches (xxx# or xxx.rej). If there are, either you or me has made a mistake. - Unlike patches for the 3.x kernels, patches for the 3.x.y kernels + Unlike patches for the 2.6.x kernels, patches for the 2.6.x.y kernels (also known as the -stable kernels) are not incremental but instead apply - directly to the base 3.x kernel. Please read + directly to the base 2.6.x kernel. Please read Documentation/applying-patches.txt for more information. Alternatively, the script patch-kernel can be used to automate this @@ -107,14 +107,14 @@ INSTALLING the kernel source: an alternative directory can be specified as the second argument. - If you are upgrading between releases using the stable series patches - (for example, patch-3.x.y), note that these "dot-releases" are - not incremental and must be applied to the 3.x base tree. For - example, if your base kernel is 3.0 and you want to apply the - 3.0.3 patch, you do not and indeed must not first apply the - 3.0.1 and 3.0.2 patches. Similarly, if you are running kernel - version 3.0.2 and want to jump to 3.0.3, you must first - reverse the 3.0.2 patch (that is, patch -R) _before_ applying - the 3.0.3 patch. + (for example, patch-2.6.xx.y), note that these "dot-releases" are + not incremental and must be applied to the 2.6.xx base tree. For + example, if your base kernel is 2.6.12 and you want to apply the + 2.6.12.3 patch, you do not and indeed must not first apply the + 2.6.12.1 and 2.6.12.2 patches. Similarly, if you are running kernel + version 2.6.12.2 and want to jump to 2.6.12.3, you must first + reverse the 2.6.12.2 patch (that is, patch -R) _before_ applying + the 2.6.12.3 patch. You can read more on this in Documentation/applying-patches.txt - Make sure you have no stale .o files and dependencies lying around: @@ -126,7 +126,7 @@ INSTALLING the kernel source: SOFTWARE REQUIREMENTS - Compiling and running the 3.x kernels requires up-to-date + Compiling and running the 2.6.xx kernels requires up-to-date versions of various software packages. Consult Documentation/Changes for the minimum version numbers required and how to get updates for these packages. Beware that using @@ -142,11 +142,11 @@ BUILD directory for the kernel: Using the option "make O=output/dir" allow you to specify an alternate place for the output files (including .config). Example: - kernel source code: /usr/src/linux-3.N + kernel source code: /usr/src/linux-2.6.N build directory: /home/name/build/kernel To configure and build the kernel use: - cd /usr/src/linux-3.N + cd /usr/src/linux-2.6.N make O=/home/name/build/kernel menuconfig make O=/home/name/build/kernel sudo make O=/home/name/build/kernel modules_install install diff --git a/trunk/arch/alpha/include/asm/mmzone.h b/trunk/arch/alpha/include/asm/mmzone.h index 445dc42e0334..8af56ce346ad 100644 --- a/trunk/arch/alpha/include/asm/mmzone.h +++ b/trunk/arch/alpha/include/asm/mmzone.h @@ -56,6 +56,7 @@ PLAT_NODE_DATA_LOCALNR(unsigned long p, int n) * Given a kernel address, find the home node of the underlying memory. */ #define kvaddr_to_nid(kaddr) pa_to_nid(__pa(kaddr)) +#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn) /* * Given a kaddr, LOCAL_BASE_ADDR finds the owning node of the memory diff --git a/trunk/arch/arm/boot/compressed/head.S b/trunk/arch/arm/boot/compressed/head.S index 940b20178107..942fad97e447 100644 --- a/trunk/arch/arm/boot/compressed/head.S +++ b/trunk/arch/arm/boot/compressed/head.S @@ -597,8 +597,6 @@ __common_mmu_cache_on: sub pc, lr, r0, lsr #32 @ properly flush pipeline #endif -#define PROC_ENTRY_SIZE (4*5) - /* * Here follow the relocatable cache support functions for the * various processors. This is a generic hook for locating an @@ -626,7 +624,7 @@ call_cache_fn: adr r12, proc_types ARM( addeq pc, r12, r3 ) @ call cache function THUMB( addeq r12, r3 ) THUMB( moveq pc, r12 ) @ call cache function - add r12, r12, #PROC_ENTRY_SIZE + add r12, r12, #4*5 b 1b /* @@ -796,16 +794,6 @@ proc_types: .size proc_types, . - proc_types - /* - * If you get a "non-constant expression in ".if" statement" - * error from the assembler on this line, check that you have - * not accidentally written a "b" instruction where you should - * have written W(b). - */ - .if (. - proc_types) % PROC_ENTRY_SIZE != 0 - .error "The size of one or more proc_types entries is wrong." - .endif - /* * Turn off the Cache and MMU. ARMv3 does not support * reading the control register, but ARMv4 does. diff --git a/trunk/arch/arm/common/dmabounce.c b/trunk/arch/arm/common/dmabounce.c index 841df7d21c2f..e5681636626f 100644 --- a/trunk/arch/arm/common/dmabounce.c +++ b/trunk/arch/arm/common/dmabounce.c @@ -255,7 +255,7 @@ static inline dma_addr_t map_single(struct device *dev, void *ptr, size_t size, if (buf == 0) { dev_err(dev, "%s: unable to map unsafe buffer %p!\n", __func__, ptr); - return ~0; + return 0; } dev_dbg(dev, diff --git a/trunk/arch/arm/include/asm/assembler.h b/trunk/arch/arm/include/asm/assembler.h index 65c3f2474f5e..bc2d2d75f706 100644 --- a/trunk/arch/arm/include/asm/assembler.h +++ b/trunk/arch/arm/include/asm/assembler.h @@ -13,9 +13,6 @@ * Do not include any C declarations in this file - it is included by * assembler source. */ -#ifndef __ASM_ASSEMBLER_H__ -#define __ASM_ASSEMBLER_H__ - #ifndef __ASSEMBLY__ #error "Only include this from assembly code" #endif @@ -293,4 +290,3 @@ .macro ldrusr, reg, ptr, inc, cond=al, rept=1, abort=9001f usracc ldr, \reg, \ptr, \inc, \cond, \rept, \abort .endm -#endif /* __ASM_ASSEMBLER_H__ */ diff --git a/trunk/arch/arm/include/asm/entry-macro-multi.S b/trunk/arch/arm/include/asm/entry-macro-multi.S index 2da8547de6d6..ec0bbf79c71f 100644 --- a/trunk/arch/arm/include/asm/entry-macro-multi.S +++ b/trunk/arch/arm/include/asm/entry-macro-multi.S @@ -1,5 +1,3 @@ -#include - /* * Interrupt handling. Preserves r7, r8, r9 */ diff --git a/trunk/arch/arm/kernel/module.c b/trunk/arch/arm/kernel/module.c index 016d6a0830a3..fee7c36349eb 100644 --- a/trunk/arch/arm/kernel/module.c +++ b/trunk/arch/arm/kernel/module.c @@ -193,17 +193,8 @@ apply_relocate(Elf32_Shdr *sechdrs, const char *strtab, unsigned int symindex, offset -= 0x02000000; offset += sym->st_value - loc; - /* - * For function symbols, only Thumb addresses are - * allowed (no interworking). - * - * For non-function symbols, the destination - * has no specific ARM/Thumb disposition, so - * the branch is resolved under the assumption - * that interworking is not required. - */ - if ((ELF32_ST_TYPE(sym->st_info) == STT_FUNC && - !(offset & 1)) || + /* only Thumb addresses allowed (no interworking) */ + if (!(offset & 1) || offset <= (s32)0xff000000 || offset >= (s32)0x01000000) { pr_err("%s: section %u reloc %u sym '%s': relocation %u out of range (%#lx -> %#x)\n", diff --git a/trunk/arch/arm/kernel/perf_event.c b/trunk/arch/arm/kernel/perf_event.c index 2b5b1421596c..d53c0abc4dd3 100644 --- a/trunk/arch/arm/kernel/perf_event.c +++ b/trunk/arch/arm/kernel/perf_event.c @@ -583,7 +583,7 @@ static int armpmu_event_init(struct perf_event *event) static void armpmu_enable(struct pmu *pmu) { /* Enable all of the perf events on hardware. */ - int idx, enabled = 0; + int idx; struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events); if (!armpmu) @@ -596,11 +596,9 @@ static void armpmu_enable(struct pmu *pmu) continue; armpmu->enable(&event->hw, idx); - enabled = 1; } - if (enabled) - armpmu->start(); + armpmu->start(); } static void armpmu_disable(struct pmu *pmu) diff --git a/trunk/arch/arm/kernel/setup.c b/trunk/arch/arm/kernel/setup.c index acbb447ac6b5..ed11fb08b05a 100644 --- a/trunk/arch/arm/kernel/setup.c +++ b/trunk/arch/arm/kernel/setup.c @@ -73,7 +73,6 @@ __setup("fpe=", fpe_setup); #endif extern void paging_init(struct machine_desc *desc); -extern void sanity_check_meminfo(void); extern void reboot_setup(char *str); unsigned int processor_id; @@ -901,7 +900,6 @@ void __init setup_arch(char **cmdline_p) parse_early_param(); - sanity_check_meminfo(); arm_memblock_init(&meminfo, mdesc); paging_init(mdesc); diff --git a/trunk/arch/arm/kernel/smp.c b/trunk/arch/arm/kernel/smp.c index e7f92a4321f3..344e52b16c8c 100644 --- a/trunk/arch/arm/kernel/smp.c +++ b/trunk/arch/arm/kernel/smp.c @@ -318,13 +318,9 @@ asmlinkage void __cpuinit secondary_start_kernel(void) smp_store_cpu_info(cpu); /* - * OK, now it's safe to let the boot CPU continue. Wait for - * the CPU migration code to notice that the CPU is online - * before we continue. + * OK, now it's safe to let the boot CPU continue */ set_cpu_online(cpu, true); - while (!cpu_active(cpu)) - cpu_relax(); /* * OK, it's off to the idle thread for us diff --git a/trunk/arch/arm/kernel/smp_twd.c b/trunk/arch/arm/kernel/smp_twd.c index 2c277d40cee6..60636f499cb3 100644 --- a/trunk/arch/arm/kernel/smp_twd.c +++ b/trunk/arch/arm/kernel/smp_twd.c @@ -115,7 +115,7 @@ static void __cpuinit twd_calibrate_rate(void) twd_timer_rate = (0xFFFFFFFFU - count) * (HZ / 5); printk("%lu.%02luMHz.\n", twd_timer_rate / 1000000, - (twd_timer_rate / 10000) % 100); + (twd_timer_rate / 1000000) % 100); } } diff --git a/trunk/arch/arm/mach-at91/at91cap9.c b/trunk/arch/arm/mach-at91/at91cap9.c index f1013d08bb57..17fae4a42ab5 100644 --- a/trunk/arch/arm/mach-at91/at91cap9.c +++ b/trunk/arch/arm/mach-at91/at91cap9.c @@ -223,15 +223,15 @@ static struct clk *periph_clocks[] __initdata = { }; static struct clk_lookup periph_clocks_lookups[] = { - CLKDEV_CON_DEV_ID("hclk", "atmel_usba_udc", &utmi_clk), - CLKDEV_CON_DEV_ID("pclk", "atmel_usba_udc", &udphs_clk), + CLKDEV_CON_DEV_ID("hclk", "atmel_usba_udc.0", &utmi_clk), + CLKDEV_CON_DEV_ID("pclk", "atmel_usba_udc.0", &udphs_clk), CLKDEV_CON_DEV_ID("mci_clk", "at91_mci.0", &mmc0_clk), CLKDEV_CON_DEV_ID("mci_clk", "at91_mci.1", &mmc1_clk), CLKDEV_CON_DEV_ID("spi_clk", "atmel_spi.0", &spi0_clk), CLKDEV_CON_DEV_ID("spi_clk", "atmel_spi.1", &spi1_clk), CLKDEV_CON_DEV_ID("t0_clk", "atmel_tcb.0", &tcb_clk), - CLKDEV_CON_DEV_ID("pclk", "ssc.0", &ssc0_clk), - CLKDEV_CON_DEV_ID("pclk", "ssc.1", &ssc1_clk), + CLKDEV_CON_DEV_ID("ssc", "ssc.0", &ssc0_clk), + CLKDEV_CON_DEV_ID("ssc", "ssc.1", &ssc1_clk), }; static struct clk_lookup usart_clocks_lookups[] = { diff --git a/trunk/arch/arm/mach-at91/at91cap9_devices.c b/trunk/arch/arm/mach-at91/at91cap9_devices.c index dba0d8d8a4bd..cd850ed6f335 100644 --- a/trunk/arch/arm/mach-at91/at91cap9_devices.c +++ b/trunk/arch/arm/mach-at91/at91cap9_devices.c @@ -1220,7 +1220,7 @@ void __init at91_set_serial_console(unsigned portnr) { if (portnr < ATMEL_MAX_UART) { atmel_default_console_device = at91_uarts[portnr]; - at91cap9_set_console_clock(at91_uarts[portnr]->id); + at91cap9_set_console_clock(portnr); } } diff --git a/trunk/arch/arm/mach-at91/at91rm9200.c b/trunk/arch/arm/mach-at91/at91rm9200.c index 83a1a3fee554..b228ce9e21a1 100644 --- a/trunk/arch/arm/mach-at91/at91rm9200.c +++ b/trunk/arch/arm/mach-at91/at91rm9200.c @@ -199,9 +199,9 @@ static struct clk_lookup periph_clocks_lookups[] = { CLKDEV_CON_DEV_ID("t0_clk", "atmel_tcb.1", &tc3_clk), CLKDEV_CON_DEV_ID("t1_clk", "atmel_tcb.1", &tc4_clk), CLKDEV_CON_DEV_ID("t2_clk", "atmel_tcb.1", &tc5_clk), - CLKDEV_CON_DEV_ID("pclk", "ssc.0", &ssc0_clk), - CLKDEV_CON_DEV_ID("pclk", "ssc.1", &ssc1_clk), - CLKDEV_CON_DEV_ID("pclk", "ssc.2", &ssc2_clk), + CLKDEV_CON_DEV_ID("ssc", "ssc.0", &ssc0_clk), + CLKDEV_CON_DEV_ID("ssc", "ssc.1", &ssc1_clk), + CLKDEV_CON_DEV_ID("ssc", "ssc.2", &ssc2_clk), }; static struct clk_lookup usart_clocks_lookups[] = { diff --git a/trunk/arch/arm/mach-at91/at91rm9200_devices.c b/trunk/arch/arm/mach-at91/at91rm9200_devices.c index 7227755ffec6..a0ba475be04c 100644 --- a/trunk/arch/arm/mach-at91/at91rm9200_devices.c +++ b/trunk/arch/arm/mach-at91/at91rm9200_devices.c @@ -1135,7 +1135,7 @@ void __init at91_set_serial_console(unsigned portnr) { if (portnr < ATMEL_MAX_UART) { atmel_default_console_device = at91_uarts[portnr]; - at91rm9200_set_console_clock(at91_uarts[portnr]->id); + at91rm9200_set_console_clock(portnr); } } diff --git a/trunk/arch/arm/mach-at91/at91sam9260_devices.c b/trunk/arch/arm/mach-at91/at91sam9260_devices.c index 39f81f47b4ba..1fdeb9058a76 100644 --- a/trunk/arch/arm/mach-at91/at91sam9260_devices.c +++ b/trunk/arch/arm/mach-at91/at91sam9260_devices.c @@ -1173,7 +1173,7 @@ void __init at91_set_serial_console(unsigned portnr) { if (portnr < ATMEL_MAX_UART) { atmel_default_console_device = at91_uarts[portnr]; - at91sam9260_set_console_clock(at91_uarts[portnr]->id); + at91sam9260_set_console_clock(portnr); } } diff --git a/trunk/arch/arm/mach-at91/at91sam9261_devices.c b/trunk/arch/arm/mach-at91/at91sam9261_devices.c index 5004bf0a05f2..3eb4538fceeb 100644 --- a/trunk/arch/arm/mach-at91/at91sam9261_devices.c +++ b/trunk/arch/arm/mach-at91/at91sam9261_devices.c @@ -1013,7 +1013,7 @@ void __init at91_set_serial_console(unsigned portnr) { if (portnr < ATMEL_MAX_UART) { atmel_default_console_device = at91_uarts[portnr]; - at91sam9261_set_console_clock(at91_uarts[portnr]->id); + at91sam9261_set_console_clock(portnr); } } diff --git a/trunk/arch/arm/mach-at91/at91sam9263_devices.c b/trunk/arch/arm/mach-at91/at91sam9263_devices.c index a050f41fc860..ffe081b77ed0 100644 --- a/trunk/arch/arm/mach-at91/at91sam9263_devices.c +++ b/trunk/arch/arm/mach-at91/at91sam9263_devices.c @@ -1395,7 +1395,7 @@ void __init at91_set_serial_console(unsigned portnr) { if (portnr < ATMEL_MAX_UART) { atmel_default_console_device = at91_uarts[portnr]; - at91sam9263_set_console_clock(at91_uarts[portnr]->id); + at91sam9263_set_console_clock(portnr); } } diff --git a/trunk/arch/arm/mach-at91/at91sam9g45.c b/trunk/arch/arm/mach-at91/at91sam9g45.c index 11e214121b23..2bb6ff9af1c7 100644 --- a/trunk/arch/arm/mach-at91/at91sam9g45.c +++ b/trunk/arch/arm/mach-at91/at91sam9g45.c @@ -217,11 +217,11 @@ static struct clk *periph_clocks[] __initdata = { static struct clk_lookup periph_clocks_lookups[] = { /* One additional fake clock for ohci */ CLKDEV_CON_ID("ohci_clk", &uhphs_clk), - CLKDEV_CON_DEV_ID("ehci_clk", "atmel-ehci", &uhphs_clk), - CLKDEV_CON_DEV_ID("hclk", "atmel_usba_udc", &utmi_clk), - CLKDEV_CON_DEV_ID("pclk", "atmel_usba_udc", &udphs_clk), - CLKDEV_CON_DEV_ID("mci_clk", "atmel_mci.0", &mmc0_clk), - CLKDEV_CON_DEV_ID("mci_clk", "atmel_mci.1", &mmc1_clk), + CLKDEV_CON_DEV_ID("ehci_clk", "atmel-ehci.0", &uhphs_clk), + CLKDEV_CON_DEV_ID("hclk", "atmel_usba_udc.0", &utmi_clk), + CLKDEV_CON_DEV_ID("pclk", "atmel_usba_udc.0", &udphs_clk), + CLKDEV_CON_DEV_ID("mci_clk", "at91_mci.0", &mmc0_clk), + CLKDEV_CON_DEV_ID("mci_clk", "at91_mci.1", &mmc1_clk), CLKDEV_CON_DEV_ID("spi_clk", "atmel_spi.0", &spi0_clk), CLKDEV_CON_DEV_ID("spi_clk", "atmel_spi.1", &spi1_clk), CLKDEV_CON_DEV_ID("t0_clk", "atmel_tcb.0", &tcb0_clk), diff --git a/trunk/arch/arm/mach-at91/at91sam9g45_devices.c b/trunk/arch/arm/mach-at91/at91sam9g45_devices.c index 600bffb01edb..05674865bc21 100644 --- a/trunk/arch/arm/mach-at91/at91sam9g45_devices.c +++ b/trunk/arch/arm/mach-at91/at91sam9g45_devices.c @@ -1550,7 +1550,7 @@ void __init at91_set_serial_console(unsigned portnr) { if (portnr < ATMEL_MAX_UART) { atmel_default_console_device = at91_uarts[portnr]; - at91sam9g45_set_console_clock(at91_uarts[portnr]->id); + at91sam9g45_set_console_clock(portnr); } } diff --git a/trunk/arch/arm/mach-at91/at91sam9rl.c b/trunk/arch/arm/mach-at91/at91sam9rl.c index 29dff18ed130..1a40f16b66c8 100644 --- a/trunk/arch/arm/mach-at91/at91sam9rl.c +++ b/trunk/arch/arm/mach-at91/at91sam9rl.c @@ -191,8 +191,8 @@ static struct clk *periph_clocks[] __initdata = { }; static struct clk_lookup periph_clocks_lookups[] = { - CLKDEV_CON_DEV_ID("hclk", "atmel_usba_udc", &utmi_clk), - CLKDEV_CON_DEV_ID("pclk", "atmel_usba_udc", &udphs_clk), + CLKDEV_CON_DEV_ID("hclk", "atmel_usba_udc.0", &utmi_clk), + CLKDEV_CON_DEV_ID("pclk", "atmel_usba_udc.0", &udphs_clk), CLKDEV_CON_DEV_ID("t0_clk", "atmel_tcb.0", &tc0_clk), CLKDEV_CON_DEV_ID("t1_clk", "atmel_tcb.0", &tc1_clk), CLKDEV_CON_DEV_ID("t2_clk", "atmel_tcb.0", &tc2_clk), diff --git a/trunk/arch/arm/mach-at91/at91sam9rl_devices.c b/trunk/arch/arm/mach-at91/at91sam9rl_devices.c index aacb19dc9225..c296045f2b6a 100644 --- a/trunk/arch/arm/mach-at91/at91sam9rl_devices.c +++ b/trunk/arch/arm/mach-at91/at91sam9rl_devices.c @@ -1168,7 +1168,7 @@ void __init at91_set_serial_console(unsigned portnr) { if (portnr < ATMEL_MAX_UART) { atmel_default_console_device = at91_uarts[portnr]; - at91sam9rl_set_console_clock(at91_uarts[portnr]->id); + at91sam9rl_set_console_clock(portnr); } } diff --git a/trunk/arch/arm/mach-at91/board-cap9adk.c b/trunk/arch/arm/mach-at91/board-cap9adk.c index cdb65d483250..1904fdf87613 100644 --- a/trunk/arch/arm/mach-at91/board-cap9adk.c +++ b/trunk/arch/arm/mach-at91/board-cap9adk.c @@ -215,7 +215,7 @@ static void __init cap9adk_add_device_nand(void) csa = at91_sys_read(AT91_MATRIX_EBICSA); at91_sys_write(AT91_MATRIX_EBICSA, csa | AT91_MATRIX_EBI_VDDIOMSEL_3_3V); - cap9adk_nand_data.bus_width_16 = board_have_nand_16bit(); + cap9adk_nand_data.bus_width_16 = !board_have_nand_8bit(); /* setup bus-width (8 or 16) */ if (cap9adk_nand_data.bus_width_16) cap9adk_nand_smc_config.mode |= AT91_SMC_DBW_16; diff --git a/trunk/arch/arm/mach-at91/board-sam9260ek.c b/trunk/arch/arm/mach-at91/board-sam9260ek.c index 5c240743c5b7..d600dc123227 100644 --- a/trunk/arch/arm/mach-at91/board-sam9260ek.c +++ b/trunk/arch/arm/mach-at91/board-sam9260ek.c @@ -214,7 +214,7 @@ static struct sam9_smc_config __initdata ek_nand_smc_config = { static void __init ek_add_device_nand(void) { - ek_nand_data.bus_width_16 = board_have_nand_16bit(); + ek_nand_data.bus_width_16 = !board_have_nand_8bit(); /* setup bus-width (8 or 16) */ if (ek_nand_data.bus_width_16) ek_nand_smc_config.mode |= AT91_SMC_DBW_16; diff --git a/trunk/arch/arm/mach-at91/board-sam9261ek.c b/trunk/arch/arm/mach-at91/board-sam9261ek.c index b60c22b6e241..f897f84d43dc 100644 --- a/trunk/arch/arm/mach-at91/board-sam9261ek.c +++ b/trunk/arch/arm/mach-at91/board-sam9261ek.c @@ -220,7 +220,7 @@ static struct sam9_smc_config __initdata ek_nand_smc_config = { static void __init ek_add_device_nand(void) { - ek_nand_data.bus_width_16 = board_have_nand_16bit(); + ek_nand_data.bus_width_16 = !board_have_nand_8bit(); /* setup bus-width (8 or 16) */ if (ek_nand_data.bus_width_16) ek_nand_smc_config.mode |= AT91_SMC_DBW_16; diff --git a/trunk/arch/arm/mach-at91/board-sam9263ek.c b/trunk/arch/arm/mach-at91/board-sam9263ek.c index 9bbdc92ea194..605b26f40a4c 100644 --- a/trunk/arch/arm/mach-at91/board-sam9263ek.c +++ b/trunk/arch/arm/mach-at91/board-sam9263ek.c @@ -221,7 +221,7 @@ static struct sam9_smc_config __initdata ek_nand_smc_config = { static void __init ek_add_device_nand(void) { - ek_nand_data.bus_width_16 = board_have_nand_16bit(); + ek_nand_data.bus_width_16 = !board_have_nand_8bit(); /* setup bus-width (8 or 16) */ if (ek_nand_data.bus_width_16) ek_nand_smc_config.mode |= AT91_SMC_DBW_16; diff --git a/trunk/arch/arm/mach-at91/board-sam9g20ek.c b/trunk/arch/arm/mach-at91/board-sam9g20ek.c index 1325a50101a8..7624cf0d006b 100644 --- a/trunk/arch/arm/mach-at91/board-sam9g20ek.c +++ b/trunk/arch/arm/mach-at91/board-sam9g20ek.c @@ -198,7 +198,7 @@ static struct sam9_smc_config __initdata ek_nand_smc_config = { static void __init ek_add_device_nand(void) { - ek_nand_data.bus_width_16 = board_have_nand_16bit(); + ek_nand_data.bus_width_16 = !board_have_nand_8bit(); /* setup bus-width (8 or 16) */ if (ek_nand_data.bus_width_16) ek_nand_smc_config.mode |= AT91_SMC_DBW_16; diff --git a/trunk/arch/arm/mach-at91/board-sam9m10g45ek.c b/trunk/arch/arm/mach-at91/board-sam9m10g45ek.c index 33eaa135f248..063c95d0e8f0 100644 --- a/trunk/arch/arm/mach-at91/board-sam9m10g45ek.c +++ b/trunk/arch/arm/mach-at91/board-sam9m10g45ek.c @@ -178,7 +178,7 @@ static struct sam9_smc_config __initdata ek_nand_smc_config = { static void __init ek_add_device_nand(void) { - ek_nand_data.bus_width_16 = board_have_nand_16bit(); + ek_nand_data.bus_width_16 = !board_have_nand_8bit(); /* setup bus-width (8 or 16) */ if (ek_nand_data.bus_width_16) ek_nand_smc_config.mode |= AT91_SMC_DBW_16; diff --git a/trunk/arch/arm/mach-at91/include/mach/system_rev.h b/trunk/arch/arm/mach-at91/include/mach/system_rev.h index 8f4866045b41..b855ee75f72c 100644 --- a/trunk/arch/arm/mach-at91/include/mach/system_rev.h +++ b/trunk/arch/arm/mach-at91/include/mach/system_rev.h @@ -13,13 +13,13 @@ * the 16-31 bit are reserved for at91 generic information * * bit 31: - * 0 => nand 8 bit - * 1 => nand 16 bit + * 0 => nand 16 bit + * 1 => nand 8 bit */ -#define BOARD_HAVE_NAND_16BIT (1 << 31) -static inline int board_have_nand_16bit(void) +#define BOARD_HAVE_NAND_8BIT (1 << 31) +static int inline board_have_nand_8bit(void) { - return system_rev & BOARD_HAVE_NAND_16BIT; + return system_rev & BOARD_HAVE_NAND_8BIT; } #endif /* __ARCH_SYSTEM_REV_H__ */ diff --git a/trunk/arch/arm/mach-davinci/irq.c b/trunk/arch/arm/mach-davinci/irq.c index d8c1af025931..bfe68ec4e1a6 100644 --- a/trunk/arch/arm/mach-davinci/irq.c +++ b/trunk/arch/arm/mach-davinci/irq.c @@ -53,7 +53,7 @@ davinci_alloc_gc(void __iomem *base, unsigned int irq_start, unsigned int num) gc = irq_alloc_generic_chip("AINTC", 1, irq_start, base, handle_edge_irq); ct = gc->chip_types; - ct->chip.irq_ack = irq_gc_ack_set_bit; + ct->chip.irq_ack = irq_gc_ack; ct->chip.irq_mask = irq_gc_mask_clr_bit; ct->chip.irq_unmask = irq_gc_mask_set_bit; diff --git a/trunk/arch/arm/mach-ep93xx/core.c b/trunk/arch/arm/mach-ep93xx/core.c index 6659a0d137a3..1d4b65fd673e 100644 --- a/trunk/arch/arm/mach-ep93xx/core.c +++ b/trunk/arch/arm/mach-ep93xx/core.c @@ -251,9 +251,9 @@ static void ep93xx_uart_set_mctrl(struct amba_device *dev, unsigned int mcr; mcr = 0; - if (mctrl & TIOCM_RTS) + if (!(mctrl & TIOCM_RTS)) mcr |= 2; - if (mctrl & TIOCM_DTR) + if (!(mctrl & TIOCM_DTR)) mcr |= 1; __raw_writel(mcr, base + EP93XX_UART_MCR_OFFSET); diff --git a/trunk/arch/arm/mach-exynos4/cpu.c b/trunk/arch/arm/mach-exynos4/cpu.c index bfd621460abf..9babe4473e88 100644 --- a/trunk/arch/arm/mach-exynos4/cpu.c +++ b/trunk/arch/arm/mach-exynos4/cpu.c @@ -23,7 +23,6 @@ #include #include #include -#include #include @@ -133,11 +132,6 @@ void __init exynos4_map_io(void) s3c_fimc_setname(1, "exynos4-fimc"); s3c_fimc_setname(2, "exynos4-fimc"); s3c_fimc_setname(3, "exynos4-fimc"); - - /* The I2C bus controllers are directly compatible with s3c2440 */ - s3c_i2c0_setname("s3c2440-i2c"); - s3c_i2c1_setname("s3c2440-i2c"); - s3c_i2c2_setname("s3c2440-i2c"); } void __init exynos4_init_clocks(int xtal) diff --git a/trunk/arch/arm/mach-exynos4/dev-audio.c b/trunk/arch/arm/mach-exynos4/dev-audio.c index 983069a53239..1eed5f9f7bd3 100644 --- a/trunk/arch/arm/mach-exynos4/dev-audio.c +++ b/trunk/arch/arm/mach-exynos4/dev-audio.c @@ -330,7 +330,7 @@ struct platform_device exynos4_device_ac97 = { static int exynos4_spdif_cfg_gpio(struct platform_device *pdev) { - s3c_gpio_cfgpin_range(EXYNOS4_GPC1(0), 2, S3C_GPIO_SFN(4)); + s3c_gpio_cfgpin_range(EXYNOS4_GPC1(0), 2, S3C_GPIO_SFN(3)); return 0; } diff --git a/trunk/arch/arm/mach-exynos4/headsmp.S b/trunk/arch/arm/mach-exynos4/headsmp.S index 3cdeb3647542..6c6cfc50c46b 100644 --- a/trunk/arch/arm/mach-exynos4/headsmp.S +++ b/trunk/arch/arm/mach-exynos4/headsmp.S @@ -13,7 +13,7 @@ #include #include - __CPUINIT + __INIT /* * exynos4 specific entry point for secondary CPUs. This provides diff --git a/trunk/arch/arm/mach-exynos4/init.c b/trunk/arch/arm/mach-exynos4/init.c index a8a83e3881a4..cf91f50e43ab 100644 --- a/trunk/arch/arm/mach-exynos4/init.c +++ b/trunk/arch/arm/mach-exynos4/init.c @@ -35,7 +35,6 @@ void __init exynos4_common_init_uarts(struct s3c2410_uartcfg *cfg, int no) tcfg->clocks = exynos4_serial_clocks; tcfg->clocks_size = ARRAY_SIZE(exynos4_serial_clocks); } - tcfg->flags |= NO_NEED_CHECK_CLKSRC; } s3c24xx_init_uartdevs("s5pv210-uart", s5p_uart_resources, cfg, no); diff --git a/trunk/arch/arm/mach-exynos4/mach-smdkv310.c b/trunk/arch/arm/mach-exynos4/mach-smdkv310.c index edd814110da8..152676471b67 100644 --- a/trunk/arch/arm/mach-exynos4/mach-smdkv310.c +++ b/trunk/arch/arm/mach-exynos4/mach-smdkv310.c @@ -78,7 +78,9 @@ static struct s3c2410_uartcfg smdkv310_uartcfgs[] __initdata = { }; static struct s3c_sdhci_platdata smdkv310_hsmmc0_pdata __initdata = { - .cd_type = S3C_SDHCI_CD_INTERNAL, + .cd_type = S3C_SDHCI_CD_GPIO, + .ext_cd_gpio = EXYNOS4_GPK0(2), + .ext_cd_gpio_invert = 1, .clk_type = S3C_SDHCI_CLK_DIV_EXTERNAL, #ifdef CONFIG_EXYNOS4_SDHCI_CH0_8BIT .max_width = 8, @@ -94,7 +96,9 @@ static struct s3c_sdhci_platdata smdkv310_hsmmc1_pdata __initdata = { }; static struct s3c_sdhci_platdata smdkv310_hsmmc2_pdata __initdata = { - .cd_type = S3C_SDHCI_CD_INTERNAL, + .cd_type = S3C_SDHCI_CD_GPIO, + .ext_cd_gpio = EXYNOS4_GPK2(2), + .ext_cd_gpio_invert = 1, .clk_type = S3C_SDHCI_CLK_DIV_EXTERNAL, #ifdef CONFIG_EXYNOS4_SDHCI_CH2_8BIT .max_width = 8, diff --git a/trunk/arch/arm/mach-h720x/Kconfig b/trunk/arch/arm/mach-h720x/Kconfig index abf356c02343..9b6982efbd22 100644 --- a/trunk/arch/arm/mach-h720x/Kconfig +++ b/trunk/arch/arm/mach-h720x/Kconfig @@ -6,14 +6,12 @@ config ARCH_H7201 bool "gms30c7201" depends on ARCH_H720X select CPU_H7201 - select ZONE_DMA help Say Y here if you are using the Hynix GMS30C7201 Reference Board config ARCH_H7202 bool "hms30c7202" select CPU_H7202 - select ZONE_DMA depends on ARCH_H720X help Say Y here if you are using the Hynix HMS30C7202 Reference Board diff --git a/trunk/arch/arm/mach-mmp/pxa168.c b/trunk/arch/arm/mach-mmp/pxa168.c index ab9f999106c7..72b4e7631583 100644 --- a/trunk/arch/arm/mach-mmp/pxa168.c +++ b/trunk/arch/arm/mach-mmp/pxa168.c @@ -79,7 +79,7 @@ static APBC_CLK(ssp4, PXA168_SSP4, 4, 0); static APBC_CLK(ssp5, PXA168_SSP5, 4, 0); static APBC_CLK(keypad, PXA168_KPC, 0, 32000); -static APMU_CLK(nand, NAND, 0x19b, 156000000); +static APMU_CLK(nand, NAND, 0x01db, 208000000); static APMU_CLK(lcd, LCD, 0x7f, 312000000); /* device and clock bindings */ diff --git a/trunk/arch/arm/mach-mmp/pxa910.c b/trunk/arch/arm/mach-mmp/pxa910.c index 1464607aa60d..8f92ccd26edf 100644 --- a/trunk/arch/arm/mach-mmp/pxa910.c +++ b/trunk/arch/arm/mach-mmp/pxa910.c @@ -110,7 +110,7 @@ static APBC_CLK(pwm2, PXA910_PWM2, 1, 13000000); static APBC_CLK(pwm3, PXA910_PWM3, 1, 13000000); static APBC_CLK(pwm4, PXA910_PWM4, 1, 13000000); -static APMU_CLK(nand, NAND, 0x19b, 156000000); +static APMU_CLK(nand, NAND, 0x01db, 208000000); static APMU_CLK(u2o, USB, 0x1b, 480000000); /* device and clock bindings */ diff --git a/trunk/arch/arm/mach-omap1/board-ams-delta.c b/trunk/arch/arm/mach-omap1/board-ams-delta.c index f49ce85d2448..de88c9297b68 100644 --- a/trunk/arch/arm/mach-omap1/board-ams-delta.c +++ b/trunk/arch/arm/mach-omap1/board-ams-delta.c @@ -215,7 +215,7 @@ static struct omap_kp_platform_data ams_delta_kp_data __initdata = { .delay = 9, }; -static struct platform_device ams_delta_kp_device = { +static struct platform_device ams_delta_kp_device __initdata = { .name = "omap-keypad", .id = -1, .dev = { @@ -225,12 +225,12 @@ static struct platform_device ams_delta_kp_device = { .resource = ams_delta_kp_resources, }; -static struct platform_device ams_delta_lcd_device = { +static struct platform_device ams_delta_lcd_device __initdata = { .name = "lcd_ams_delta", .id = -1, }; -static struct platform_device ams_delta_led_device = { +static struct platform_device ams_delta_led_device __initdata = { .name = "ams-delta-led", .id = -1 }; @@ -267,7 +267,7 @@ static struct soc_camera_link ams_delta_iclink = { .power = ams_delta_camera_power, }; -static struct platform_device ams_delta_camera_device = { +static struct platform_device ams_delta_camera_device __initdata = { .name = "soc-camera-pdrv", .id = 0, .dev = { diff --git a/trunk/arch/arm/mach-omap1/gpio15xx.c b/trunk/arch/arm/mach-omap1/gpio15xx.c index 364137c2042c..04c4b04cf54e 100644 --- a/trunk/arch/arm/mach-omap1/gpio15xx.c +++ b/trunk/arch/arm/mach-omap1/gpio15xx.c @@ -41,7 +41,7 @@ static struct __initdata omap_gpio_platform_data omap15xx_mpu_gpio_config = { .bank_stride = 1, }; -static struct platform_device omap15xx_mpu_gpio = { +static struct __initdata platform_device omap15xx_mpu_gpio = { .name = "omap_gpio", .id = 0, .dev = { @@ -70,7 +70,7 @@ static struct __initdata omap_gpio_platform_data omap15xx_gpio_config = { .bank_width = 16, }; -static struct platform_device omap15xx_gpio = { +static struct __initdata platform_device omap15xx_gpio = { .name = "omap_gpio", .id = 1, .dev = { diff --git a/trunk/arch/arm/mach-omap1/gpio16xx.c b/trunk/arch/arm/mach-omap1/gpio16xx.c index 293a246e2824..5dd0d4c82b24 100644 --- a/trunk/arch/arm/mach-omap1/gpio16xx.c +++ b/trunk/arch/arm/mach-omap1/gpio16xx.c @@ -44,7 +44,7 @@ static struct __initdata omap_gpio_platform_data omap16xx_mpu_gpio_config = { .bank_stride = 1, }; -static struct platform_device omap16xx_mpu_gpio = { +static struct __initdata platform_device omap16xx_mpu_gpio = { .name = "omap_gpio", .id = 0, .dev = { @@ -73,7 +73,7 @@ static struct __initdata omap_gpio_platform_data omap16xx_gpio1_config = { .bank_width = 16, }; -static struct platform_device omap16xx_gpio1 = { +static struct __initdata platform_device omap16xx_gpio1 = { .name = "omap_gpio", .id = 1, .dev = { @@ -102,7 +102,7 @@ static struct __initdata omap_gpio_platform_data omap16xx_gpio2_config = { .bank_width = 16, }; -static struct platform_device omap16xx_gpio2 = { +static struct __initdata platform_device omap16xx_gpio2 = { .name = "omap_gpio", .id = 2, .dev = { @@ -131,7 +131,7 @@ static struct __initdata omap_gpio_platform_data omap16xx_gpio3_config = { .bank_width = 16, }; -static struct platform_device omap16xx_gpio3 = { +static struct __initdata platform_device omap16xx_gpio3 = { .name = "omap_gpio", .id = 3, .dev = { @@ -160,7 +160,7 @@ static struct __initdata omap_gpio_platform_data omap16xx_gpio4_config = { .bank_width = 16, }; -static struct platform_device omap16xx_gpio4 = { +static struct __initdata platform_device omap16xx_gpio4 = { .name = "omap_gpio", .id = 4, .dev = { diff --git a/trunk/arch/arm/mach-omap1/gpio7xx.c b/trunk/arch/arm/mach-omap1/gpio7xx.c index c6ad248d63a6..1204c8b871af 100644 --- a/trunk/arch/arm/mach-omap1/gpio7xx.c +++ b/trunk/arch/arm/mach-omap1/gpio7xx.c @@ -46,7 +46,7 @@ static struct __initdata omap_gpio_platform_data omap7xx_mpu_gpio_config = { .bank_stride = 2, }; -static struct platform_device omap7xx_mpu_gpio = { +static struct __initdata platform_device omap7xx_mpu_gpio = { .name = "omap_gpio", .id = 0, .dev = { @@ -75,7 +75,7 @@ static struct __initdata omap_gpio_platform_data omap7xx_gpio1_config = { .bank_width = 32, }; -static struct platform_device omap7xx_gpio1 = { +static struct __initdata platform_device omap7xx_gpio1 = { .name = "omap_gpio", .id = 1, .dev = { @@ -104,7 +104,7 @@ static struct __initdata omap_gpio_platform_data omap7xx_gpio2_config = { .bank_width = 32, }; -static struct platform_device omap7xx_gpio2 = { +static struct __initdata platform_device omap7xx_gpio2 = { .name = "omap_gpio", .id = 2, .dev = { @@ -133,7 +133,7 @@ static struct __initdata omap_gpio_platform_data omap7xx_gpio3_config = { .bank_width = 32, }; -static struct platform_device omap7xx_gpio3 = { +static struct __initdata platform_device omap7xx_gpio3 = { .name = "omap_gpio", .id = 3, .dev = { @@ -162,7 +162,7 @@ static struct __initdata omap_gpio_platform_data omap7xx_gpio4_config = { .bank_width = 32, }; -static struct platform_device omap7xx_gpio4 = { +static struct __initdata platform_device omap7xx_gpio4 = { .name = "omap_gpio", .id = 4, .dev = { @@ -191,7 +191,7 @@ static struct __initdata omap_gpio_platform_data omap7xx_gpio5_config = { .bank_width = 32, }; -static struct platform_device omap7xx_gpio5 = { +static struct __initdata platform_device omap7xx_gpio5 = { .name = "omap_gpio", .id = 5, .dev = { @@ -220,7 +220,7 @@ static struct __initdata omap_gpio_platform_data omap7xx_gpio6_config = { .bank_width = 32, }; -static struct platform_device omap7xx_gpio6 = { +static struct __initdata platform_device omap7xx_gpio6 = { .name = "omap_gpio", .id = 6, .dev = { diff --git a/trunk/arch/arm/mach-omap2/board-rx51-peripherals.c b/trunk/arch/arm/mach-omap2/board-rx51-peripherals.c index 88bd6f7705f0..990366726c58 100644 --- a/trunk/arch/arm/mach-omap2/board-rx51-peripherals.c +++ b/trunk/arch/arm/mach-omap2/board-rx51-peripherals.c @@ -558,7 +558,7 @@ static struct radio_si4713_platform_data rx51_si4713_data __initdata_or_module = .subdev_board_info = &rx51_si4713_board_info, }; -static struct platform_device rx51_si4713_dev = { +static struct platform_device rx51_si4713_dev __initdata_or_module = { .name = "radio-si4713", .id = -1, .dev = { diff --git a/trunk/arch/arm/mach-pxa/mfp-pxa2xx.c b/trunk/arch/arm/mach-pxa/mfp-pxa2xx.c index b27544bcafcb..87ae3129f4f7 100644 --- a/trunk/arch/arm/mach-pxa/mfp-pxa2xx.c +++ b/trunk/arch/arm/mach-pxa/mfp-pxa2xx.c @@ -347,9 +347,9 @@ static int pxa2xx_mfp_suspend(void) if ((gpio_desc[i].config & MFP_LPM_KEEP_OUTPUT) && (GPDR(i) & GPIO_bit(i))) { if (GPLR(i) & GPIO_bit(i)) - PGSR(gpio_to_bank(i)) |= GPIO_bit(i); + PGSR(i) |= GPIO_bit(i); else - PGSR(gpio_to_bank(i)) &= ~GPIO_bit(i); + PGSR(i) &= ~GPIO_bit(i); } } diff --git a/trunk/arch/arm/mach-pxa/raumfeld.c b/trunk/arch/arm/mach-pxa/raumfeld.c index 2f37d43f51b6..d130f77b6d11 100644 --- a/trunk/arch/arm/mach-pxa/raumfeld.c +++ b/trunk/arch/arm/mach-pxa/raumfeld.c @@ -573,10 +573,10 @@ static struct pxafb_mode_info sharp_lq043t3dx02_mode = { .xres = 480, .yres = 272, .bpp = 16, - .hsync_len = 41, + .hsync_len = 4, .left_margin = 2, .right_margin = 1, - .vsync_len = 10, + .vsync_len = 1, .upper_margin = 3, .lower_margin = 1, .sync = 0, @@ -596,31 +596,29 @@ static void __init raumfeld_lcd_init(void) { int ret; + pxa_set_fb_info(NULL, &raumfeld_sharp_lcd_info); + + /* Earlier devices had the backlight regulator controlled + * via PWM, later versions use another controller for that */ + if ((system_rev & 0xff) < 2) { + mfp_cfg_t raumfeld_pwm_pin_config = GPIO17_PWM0_OUT; + pxa3xx_mfp_config(&raumfeld_pwm_pin_config, 1); + platform_device_register(&raumfeld_pwm_backlight_device); + } else + platform_device_register(&raumfeld_lt3593_device); + ret = gpio_request(GPIO_TFT_VA_EN, "display VA enable"); if (ret < 0) pr_warning("Unable to request GPIO_TFT_VA_EN\n"); else gpio_direction_output(GPIO_TFT_VA_EN, 1); - msleep(100); - ret = gpio_request(GPIO_DISPLAY_ENABLE, "display enable"); if (ret < 0) pr_warning("Unable to request GPIO_DISPLAY_ENABLE\n"); else gpio_direction_output(GPIO_DISPLAY_ENABLE, 1); - /* Hardware revision 2 has the backlight regulator controlled - * by an LT3593, earlier and later devices use PWM for that. */ - if ((system_rev & 0xff) == 2) { - platform_device_register(&raumfeld_lt3593_device); - } else { - mfp_cfg_t raumfeld_pwm_pin_config = GPIO17_PWM0_OUT; - pxa3xx_mfp_config(&raumfeld_pwm_pin_config, 1); - platform_device_register(&raumfeld_pwm_backlight_device); - } - - pxa_set_fb_info(NULL, &raumfeld_sharp_lcd_info); platform_device_register(&pxa3xx_device_gcu); } @@ -659,10 +657,10 @@ static struct lis3lv02d_platform_data lis3_pdata = { #define SPI_AK4104 \ { \ - .modalias = "ak4104-codec", \ - .max_speed_hz = 10000, \ - .bus_num = 0, \ - .chip_select = 0, \ + .modalias = "ak4104", \ + .max_speed_hz = 10000, \ + .bus_num = 0, \ + .chip_select = 0, \ .controller_data = (void *) GPIO_SPDIF_CS, \ } diff --git a/trunk/arch/arm/mach-s3c2440/mach-mini2440.c b/trunk/arch/arm/mach-s3c2440/mach-mini2440.c index fc2dc0b3d4fe..dd3120df09fe 100644 --- a/trunk/arch/arm/mach-s3c2440/mach-mini2440.c +++ b/trunk/arch/arm/mach-s3c2440/mach-mini2440.c @@ -552,7 +552,7 @@ struct mini2440_features_t { struct platform_device *optional[8]; }; -static void __init mini2440_parse_features( +static void mini2440_parse_features( struct mini2440_features_t * features, const char * features_str ) { diff --git a/trunk/arch/arm/mach-s3c64xx/dev-spi.c b/trunk/arch/arm/mach-s3c64xx/dev-spi.c index 5e6b42089eb4..82db072cb836 100644 --- a/trunk/arch/arm/mach-s3c64xx/dev-spi.c +++ b/trunk/arch/arm/mach-s3c64xx/dev-spi.c @@ -88,7 +88,6 @@ static struct s3c64xx_spi_info s3c64xx_spi0_pdata = { .cfg_gpio = s3c64xx_spi_cfg_gpio, .fifo_lvl_mask = 0x7f, .rx_lvl_offset = 13, - .tx_st_done = 21, }; static u64 spi_dmamask = DMA_BIT_MASK(32); @@ -133,7 +132,6 @@ static struct s3c64xx_spi_info s3c64xx_spi1_pdata = { .cfg_gpio = s3c64xx_spi_cfg_gpio, .fifo_lvl_mask = 0x7f, .rx_lvl_offset = 13, - .tx_st_done = 21, }; struct platform_device s3c64xx_device_spi1 = { diff --git a/trunk/arch/arm/mach-s5p64x0/dev-spi.c b/trunk/arch/arm/mach-s5p64x0/dev-spi.c index ac825e826326..e78ee18c76e3 100644 --- a/trunk/arch/arm/mach-s5p64x0/dev-spi.c +++ b/trunk/arch/arm/mach-s5p64x0/dev-spi.c @@ -112,14 +112,12 @@ static struct s3c64xx_spi_info s5p6440_spi0_pdata = { .cfg_gpio = s5p6440_spi_cfg_gpio, .fifo_lvl_mask = 0x1ff, .rx_lvl_offset = 15, - .tx_st_done = 25, }; static struct s3c64xx_spi_info s5p6450_spi0_pdata = { .cfg_gpio = s5p6450_spi_cfg_gpio, .fifo_lvl_mask = 0x1ff, .rx_lvl_offset = 15, - .tx_st_done = 25, }; static u64 spi_dmamask = DMA_BIT_MASK(32); @@ -162,14 +160,12 @@ static struct s3c64xx_spi_info s5p6440_spi1_pdata = { .cfg_gpio = s5p6440_spi_cfg_gpio, .fifo_lvl_mask = 0x7f, .rx_lvl_offset = 15, - .tx_st_done = 25, }; static struct s3c64xx_spi_info s5p6450_spi1_pdata = { .cfg_gpio = s5p6450_spi_cfg_gpio, .fifo_lvl_mask = 0x7f, .rx_lvl_offset = 15, - .tx_st_done = 25, }; struct platform_device s5p64x0_device_spi1 = { diff --git a/trunk/arch/arm/mach-s5pc100/dev-spi.c b/trunk/arch/arm/mach-s5pc100/dev-spi.c index e5d6c4dceb56..57b19794d9bb 100644 --- a/trunk/arch/arm/mach-s5pc100/dev-spi.c +++ b/trunk/arch/arm/mach-s5pc100/dev-spi.c @@ -15,7 +15,6 @@ #include #include #include -#include #include #include @@ -91,7 +90,6 @@ static struct s3c64xx_spi_info s5pc100_spi0_pdata = { .fifo_lvl_mask = 0x7f, .rx_lvl_offset = 13, .high_speed = 1, - .tx_st_done = 21, }; static u64 spi_dmamask = DMA_BIT_MASK(32); @@ -136,7 +134,6 @@ static struct s3c64xx_spi_info s5pc100_spi1_pdata = { .fifo_lvl_mask = 0x7f, .rx_lvl_offset = 13, .high_speed = 1, - .tx_st_done = 21, }; struct platform_device s5pc100_device_spi1 = { @@ -179,7 +176,6 @@ static struct s3c64xx_spi_info s5pc100_spi2_pdata = { .fifo_lvl_mask = 0x7f, .rx_lvl_offset = 13, .high_speed = 1, - .tx_st_done = 21, }; struct platform_device s5pc100_device_spi2 = { diff --git a/trunk/arch/arm/mach-s5pv210/dev-spi.c b/trunk/arch/arm/mach-s5pv210/dev-spi.c index eaf9a7bff7a0..e3249a47e3b1 100644 --- a/trunk/arch/arm/mach-s5pv210/dev-spi.c +++ b/trunk/arch/arm/mach-s5pv210/dev-spi.c @@ -85,7 +85,6 @@ static struct s3c64xx_spi_info s5pv210_spi0_pdata = { .fifo_lvl_mask = 0x1ff, .rx_lvl_offset = 15, .high_speed = 1, - .tx_st_done = 25, }; static u64 spi_dmamask = DMA_BIT_MASK(32); @@ -130,7 +129,6 @@ static struct s3c64xx_spi_info s5pv210_spi1_pdata = { .fifo_lvl_mask = 0x7f, .rx_lvl_offset = 15, .high_speed = 1, - .tx_st_done = 25, }; struct platform_device s5pv210_device_spi1 = { diff --git a/trunk/arch/arm/mach-shmobile/board-ag5evm.c b/trunk/arch/arm/mach-shmobile/board-ag5evm.c index ce5c2513c6ce..1e2aba23e0d6 100644 --- a/trunk/arch/arm/mach-shmobile/board-ag5evm.c +++ b/trunk/arch/arm/mach-shmobile/board-ag5evm.c @@ -381,7 +381,7 @@ void ag5evm_sdhi1_set_pwr(struct platform_device *pdev, int state) gpio_set_value(GPIO_PORT114, state); } -static struct sh_mobile_sdhi_info sh_sdhi1_info = { +static struct sh_mobile_sdhi_info sh_sdhi1_platdata = { .tmio_flags = TMIO_MMC_WRPROTECT_DISABLE, .tmio_caps = MMC_CAP_NONREMOVABLE | MMC_CAP_SDIO_IRQ, .tmio_ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, @@ -413,7 +413,7 @@ static struct platform_device sdhi1_device = { .name = "sh_mobile_sdhi", .id = 1, .dev = { - .platform_data = &sh_sdhi1_info, + .platform_data = &sh_sdhi1_platdata, }, .num_resources = ARRAY_SIZE(sdhi1_resources), .resource = sdhi1_resources, diff --git a/trunk/arch/arm/mach-shmobile/board-ap4evb.c b/trunk/arch/arm/mach-shmobile/board-ap4evb.c index 803bc6edfca4..f6b687f61c28 100644 --- a/trunk/arch/arm/mach-shmobile/board-ap4evb.c +++ b/trunk/arch/arm/mach-shmobile/board-ap4evb.c @@ -913,7 +913,7 @@ static struct i2c_board_info imx074_info = { I2C_BOARD_INFO("imx074", 0x1a), }; -static struct soc_camera_link imx074_link = { +struct soc_camera_link imx074_link = { .bus_id = 0, .board_info = &imx074_info, .i2c_adapter_id = 0, diff --git a/trunk/arch/arm/mach-shmobile/board-mackerel.c b/trunk/arch/arm/mach-shmobile/board-mackerel.c index 3802f2afabef..7e1d37584321 100644 --- a/trunk/arch/arm/mach-shmobile/board-mackerel.c +++ b/trunk/arch/arm/mach-shmobile/board-mackerel.c @@ -1287,9 +1287,9 @@ static struct platform_device *mackerel_devices[] __initdata = { &nor_flash_device, &smc911x_device, &lcdc_device, + &usbhs0_device, &usb1_host_device, &usbhs1_device, - &usbhs0_device, &leds_device, &fsi_device, &fsi_ak4643_device, diff --git a/trunk/arch/arm/mach-ux500/board-mop500-pins.c b/trunk/arch/arm/mach-ux500/board-mop500-pins.c index 70cdbd60596a..fd4cf1ca5efd 100644 --- a/trunk/arch/arm/mach-ux500/board-mop500-pins.c +++ b/trunk/arch/arm/mach-ux500/board-mop500-pins.c @@ -110,18 +110,10 @@ static pin_cfg_t mop500_pins_common[] = { GPIO168_KP_O0, /* UART */ - /* uart-0 pins gpio configuration should be - * kept intact to prevent glitch in tx line - * when tty dev is opened. Later these pins - * are configured to uart mop500_pins_uart0 - * - * It will be replaced with uart configuration - * once the issue is solved. - */ - GPIO0_GPIO | PIN_INPUT_PULLUP, - GPIO1_GPIO | PIN_OUTPUT_HIGH, - GPIO2_GPIO | PIN_INPUT_PULLUP, - GPIO3_GPIO | PIN_OUTPUT_HIGH, + GPIO0_U0_CTSn | PIN_INPUT_PULLUP, + GPIO1_U0_RTSn | PIN_OUTPUT_HIGH, + GPIO2_U0_RXD | PIN_INPUT_PULLUP, + GPIO3_U0_TXD | PIN_OUTPUT_HIGH, GPIO29_U2_RXD | PIN_INPUT_PULLUP, GPIO30_U2_TXD | PIN_OUTPUT_HIGH, diff --git a/trunk/arch/arm/mach-ux500/board-mop500.c b/trunk/arch/arm/mach-ux500/board-mop500.c index 2a08c07dec6d..bb26f40493e6 100644 --- a/trunk/arch/arm/mach-ux500/board-mop500.c +++ b/trunk/arch/arm/mach-ux500/board-mop500.c @@ -27,21 +27,18 @@ #include #include #include -#include #include #include #include #include -#include #include #include #include #include -#include "pins-db8500.h" #include "ste-dma40-db8500.h" #include "devices-db8500.h" #include "board-mop500.h" @@ -396,63 +393,12 @@ static struct stedma40_chan_cfg uart2_dma_cfg_tx = { }; #endif - -static pin_cfg_t mop500_pins_uart0[] = { - GPIO0_U0_CTSn | PIN_INPUT_PULLUP, - GPIO1_U0_RTSn | PIN_OUTPUT_HIGH, - GPIO2_U0_RXD | PIN_INPUT_PULLUP, - GPIO3_U0_TXD | PIN_OUTPUT_HIGH, -}; - -#define PRCC_K_SOFTRST_SET 0x18 -#define PRCC_K_SOFTRST_CLEAR 0x1C -static void ux500_uart0_reset(void) -{ - void __iomem *prcc_rst_set, *prcc_rst_clr; - - prcc_rst_set = (void __iomem *)IO_ADDRESS(U8500_CLKRST1_BASE + - PRCC_K_SOFTRST_SET); - prcc_rst_clr = (void __iomem *)IO_ADDRESS(U8500_CLKRST1_BASE + - PRCC_K_SOFTRST_CLEAR); - - /* Activate soft reset PRCC_K_SOFTRST_CLEAR */ - writel((readl(prcc_rst_clr) | 0x1), prcc_rst_clr); - udelay(1); - - /* Release soft reset PRCC_K_SOFTRST_SET */ - writel((readl(prcc_rst_set) | 0x1), prcc_rst_set); - udelay(1); -} - -static void ux500_uart0_init(void) -{ - int ret; - - ret = nmk_config_pins(mop500_pins_uart0, - ARRAY_SIZE(mop500_pins_uart0)); - if (ret < 0) - pr_err("pl011: uart pins_enable failed\n"); -} - -static void ux500_uart0_exit(void) -{ - int ret; - - ret = nmk_config_pins_sleep(mop500_pins_uart0, - ARRAY_SIZE(mop500_pins_uart0)); - if (ret < 0) - pr_err("pl011: uart pins_disable failed\n"); -} - static struct amba_pl011_data uart0_plat = { #ifdef CONFIG_STE_DMA40 .dma_filter = stedma40_filter, .dma_rx_param = &uart0_dma_cfg_rx, .dma_tx_param = &uart0_dma_cfg_tx, #endif - .init = ux500_uart0_init, - .exit = ux500_uart0_exit, - .reset = ux500_uart0_reset, }; static struct amba_pl011_data uart1_plat = { diff --git a/trunk/arch/arm/mach-vt8500/irq.c b/trunk/arch/arm/mach-vt8500/irq.c index 642de0408f25..245140c0df10 100644 --- a/trunk/arch/arm/mach-vt8500/irq.c +++ b/trunk/arch/arm/mach-vt8500/irq.c @@ -39,10 +39,9 @@ static void __iomem *ic_regbase; static void __iomem *sic_regbase; -static void vt8500_irq_mask(struct irq_data *d) +static void vt8500_irq_mask(unsigned int irq) { void __iomem *base = ic_regbase; - unsigned irq = d->irq; u8 edge; if (irq >= 64) { @@ -65,10 +64,9 @@ static void vt8500_irq_mask(struct irq_data *d) } } -static void vt8500_irq_unmask(struct irq_data *d) +static void vt8500_irq_unmask(unsigned int irq) { void __iomem *base = ic_regbase; - unsigned irq = d->irq; u8 dctr; if (irq >= 64) { @@ -80,11 +78,10 @@ static void vt8500_irq_unmask(struct irq_data *d) writeb(dctr, base + VT8500_IC_DCTR + irq); } -static int vt8500_irq_set_type(struct irq_data *d, unsigned int flow_type) +static int vt8500_irq_set_type(unsigned int irq, unsigned int flow_type) { void __iomem *base = ic_regbase; - unsigned irq = d->irq; - unsigned orig_irq = irq; + unsigned int orig_irq = irq; u8 dctr; if (irq >= 64) { @@ -117,11 +114,11 @@ static int vt8500_irq_set_type(struct irq_data *d, unsigned int flow_type) } static struct irq_chip vt8500_irq_chip = { - .name = "vt8500", - .irq_ack = vt8500_irq_mask, - .irq_mask = vt8500_irq_mask, - .irq_unmask = vt8500_irq_unmask, - .irq_set_type = vt8500_irq_set_type, + .name = "vt8500", + .ack = vt8500_irq_mask, + .mask = vt8500_irq_mask, + .unmask = vt8500_irq_unmask, + .set_type = vt8500_irq_set_type, }; void __init vt8500_init_irq(void) diff --git a/trunk/arch/arm/mm/cache-l2x0.c b/trunk/arch/arm/mm/cache-l2x0.c index 44c086710d2b..ef59099a5463 100644 --- a/trunk/arch/arm/mm/cache-l2x0.c +++ b/trunk/arch/arm/mm/cache-l2x0.c @@ -120,22 +120,17 @@ static void l2x0_cache_sync(void) spin_unlock_irqrestore(&l2x0_lock, flags); } -static void __l2x0_flush_all(void) -{ - debug_writel(0x03); - writel_relaxed(l2x0_way_mask, l2x0_base + L2X0_CLEAN_INV_WAY); - cache_wait_way(l2x0_base + L2X0_CLEAN_INV_WAY, l2x0_way_mask); - cache_sync(); - debug_writel(0x00); -} - static void l2x0_flush_all(void) { unsigned long flags; /* clean all ways */ spin_lock_irqsave(&l2x0_lock, flags); - __l2x0_flush_all(); + debug_writel(0x03); + writel_relaxed(l2x0_way_mask, l2x0_base + L2X0_CLEAN_INV_WAY); + cache_wait_way(l2x0_base + L2X0_CLEAN_INV_WAY, l2x0_way_mask); + cache_sync(); + debug_writel(0x00); spin_unlock_irqrestore(&l2x0_lock, flags); } @@ -271,9 +266,7 @@ static void l2x0_disable(void) unsigned long flags; spin_lock_irqsave(&l2x0_lock, flags); - __l2x0_flush_all(); - writel_relaxed(0, l2x0_base + L2X0_CTRL); - dsb(); + writel(0, l2x0_base + L2X0_CTRL); spin_unlock_irqrestore(&l2x0_lock, flags); } diff --git a/trunk/arch/arm/mm/mmu.c b/trunk/arch/arm/mm/mmu.c index 594d677b92c8..9d9e736c2b4f 100644 --- a/trunk/arch/arm/mm/mmu.c +++ b/trunk/arch/arm/mm/mmu.c @@ -759,7 +759,7 @@ early_param("vmalloc", early_vmalloc); static phys_addr_t lowmem_limit __initdata = 0; -void __init sanity_check_meminfo(void) +static void __init sanity_check_meminfo(void) { int i, j, highmem = 0; @@ -1032,9 +1032,8 @@ void __init paging_init(struct machine_desc *mdesc) { void *zero_page; - memblock_set_current_limit(lowmem_limit); - build_mem_type_table(); + sanity_check_meminfo(); prepare_page_table(); map_lowmem(); devicemaps_init(mdesc); diff --git a/trunk/arch/arm/mm/nommu.c b/trunk/arch/arm/mm/nommu.c index 941a98c9e8aa..687d02319a41 100644 --- a/trunk/arch/arm/mm/nommu.c +++ b/trunk/arch/arm/mm/nommu.c @@ -27,10 +27,6 @@ void __init arm_mm_memblock_reserve(void) memblock_reserve(CONFIG_VECTORS_BASE, PAGE_SIZE); } -void __init sanity_check_meminfo(void) -{ -} - /* * paging_init() sets up the page tables, initialises the zone memory * maps, and sets up the zero page, bad page and bad page tables. diff --git a/trunk/arch/arm/mm/proc-v7.S b/trunk/arch/arm/mm/proc-v7.S index 089c0b5e454f..3c3867850a30 100644 --- a/trunk/arch/arm/mm/proc-v7.S +++ b/trunk/arch/arm/mm/proc-v7.S @@ -210,21 +210,19 @@ cpu_v7_name: /* Suspend/resume support: derived from arch/arm/mach-s5pv210/sleep.S */ .globl cpu_v7_suspend_size -.equ cpu_v7_suspend_size, 4 * 9 +.equ cpu_v7_suspend_size, 4 * 8 #ifdef CONFIG_PM_SLEEP ENTRY(cpu_v7_do_suspend) stmfd sp!, {r4 - r11, lr} mrc p15, 0, r4, c13, c0, 0 @ FCSE/PID mrc p15, 0, r5, c13, c0, 1 @ Context ID - mrc p15, 0, r6, c13, c0, 3 @ User r/o thread ID - stmia r0!, {r4 - r6} mrc p15, 0, r6, c3, c0, 0 @ Domain ID mrc p15, 0, r7, c2, c0, 0 @ TTB 0 mrc p15, 0, r8, c2, c0, 1 @ TTB 1 mrc p15, 0, r9, c1, c0, 0 @ Control register mrc p15, 0, r10, c1, c0, 1 @ Auxiliary control register mrc p15, 0, r11, c1, c0, 2 @ Co-processor access control - stmia r0, {r6 - r11} + stmia r0, {r4 - r11} ldmfd sp!, {r4 - r11, pc} ENDPROC(cpu_v7_do_suspend) @@ -232,11 +230,9 @@ ENTRY(cpu_v7_do_resume) mov ip, #0 mcr p15, 0, ip, c8, c7, 0 @ invalidate TLBs mcr p15, 0, ip, c7, c5, 0 @ invalidate I cache - ldmia r0!, {r4 - r6} + ldmia r0, {r4 - r11} mcr p15, 0, r4, c13, c0, 0 @ FCSE/PID mcr p15, 0, r5, c13, c0, 1 @ Context ID - mcr p15, 0, r6, c13, c0, 3 @ User r/o thread ID - ldmia r0, {r6 - r11} mcr p15, 0, r6, c3, c0, 0 @ Domain ID mcr p15, 0, r7, c2, c0, 0 @ TTB 0 mcr p15, 0, r8, c2, c0, 1 @ TTB 1 @@ -422,9 +418,9 @@ ENTRY(v7_processor_functions) .word cpu_v7_dcache_clean_area .word cpu_v7_switch_mm .word cpu_v7_set_pte_ext - .word cpu_v7_suspend_size - .word cpu_v7_do_suspend - .word cpu_v7_do_resume + .word 0 + .word 0 + .word 0 .size v7_processor_functions, . - v7_processor_functions .section ".rodata" diff --git a/trunk/arch/arm/plat-iop/cp6.c b/trunk/arch/arm/plat-iop/cp6.c index bab73e2c79db..9612a87e2a88 100644 --- a/trunk/arch/arm/plat-iop/cp6.c +++ b/trunk/arch/arm/plat-iop/cp6.c @@ -18,7 +18,6 @@ */ #include #include -#include static int cp6_trap(struct pt_regs *regs, unsigned int instr) { diff --git a/trunk/arch/arm/plat-orion/gpio.c b/trunk/arch/arm/plat-orion/gpio.c index 41ab97ebe4cf..5b4fffab1eb4 100644 --- a/trunk/arch/arm/plat-orion/gpio.c +++ b/trunk/arch/arm/plat-orion/gpio.c @@ -432,7 +432,7 @@ void __init orion_gpio_init(int gpio_base, int ngpio, ct->regs.mask = ochip->mask_offset + GPIO_EDGE_MASK_OFF; ct->regs.ack = GPIO_EDGE_CAUSE_OFF; ct->type = IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING; - ct->chip.irq_ack = irq_gc_ack_clr_bit; + ct->chip.irq_ack = irq_gc_ack; ct->chip.irq_mask = irq_gc_mask_clr_bit; ct->chip.irq_unmask = irq_gc_mask_set_bit; ct->chip.irq_set_type = gpio_irq_set_type; diff --git a/trunk/arch/arm/plat-pxa/gpio.c b/trunk/arch/arm/plat-pxa/gpio.c index a11dc3670505..48ebb9479b61 100644 --- a/trunk/arch/arm/plat-pxa/gpio.c +++ b/trunk/arch/arm/plat-pxa/gpio.c @@ -50,7 +50,7 @@ static inline void __iomem *gpio_chip_base(struct gpio_chip *c) return container_of(c, struct pxa_gpio_chip, chip)->regbase; } -static inline struct pxa_gpio_chip *gpio_to_pxachip(unsigned gpio) +static inline struct pxa_gpio_chip *gpio_to_chip(unsigned gpio) { return &pxa_gpio_chips[gpio_to_bank(gpio)]; } @@ -161,7 +161,7 @@ static int pxa_gpio_irq_type(struct irq_data *d, unsigned int type) int gpio = irq_to_gpio(d->irq); unsigned long gpdr, mask = GPIO_bit(gpio); - c = gpio_to_pxachip(gpio); + c = gpio_to_chip(gpio); if (type == IRQ_TYPE_PROBE) { /* Don't mess with enabled GPIOs using preconfigured edges or @@ -230,7 +230,7 @@ static void pxa_gpio_demux_handler(unsigned int irq, struct irq_desc *desc) static void pxa_ack_muxed_gpio(struct irq_data *d) { int gpio = irq_to_gpio(d->irq); - struct pxa_gpio_chip *c = gpio_to_pxachip(gpio); + struct pxa_gpio_chip *c = gpio_to_chip(gpio); __raw_writel(GPIO_bit(gpio), c->regbase + GEDR_OFFSET); } @@ -238,7 +238,7 @@ static void pxa_ack_muxed_gpio(struct irq_data *d) static void pxa_mask_muxed_gpio(struct irq_data *d) { int gpio = irq_to_gpio(d->irq); - struct pxa_gpio_chip *c = gpio_to_pxachip(gpio); + struct pxa_gpio_chip *c = gpio_to_chip(gpio); uint32_t grer, gfer; c->irq_mask &= ~GPIO_bit(gpio); @@ -252,7 +252,7 @@ static void pxa_mask_muxed_gpio(struct irq_data *d) static void pxa_unmask_muxed_gpio(struct irq_data *d) { int gpio = irq_to_gpio(d->irq); - struct pxa_gpio_chip *c = gpio_to_pxachip(gpio); + struct pxa_gpio_chip *c = gpio_to_chip(gpio); c->irq_mask |= GPIO_bit(gpio); update_edge_detect(c); diff --git a/trunk/arch/arm/plat-s3c24xx/dma.c b/trunk/arch/arm/plat-s3c24xx/dma.c index a79a8ccd25f6..2abf9660bc6c 100644 --- a/trunk/arch/arm/plat-s3c24xx/dma.c +++ b/trunk/arch/arm/plat-s3c24xx/dma.c @@ -1027,13 +1027,17 @@ int s3c2410_dma_config(unsigned int channel, struct s3c2410_dma_chan *chan = s3c_dma_lookup_channel(channel); unsigned int dcon; - pr_debug("%s: chan=%d, xfer_unit=%d\n", __func__, channel, xferunit); + pr_debug("%s: chan=%d, xfer_unit=%d, dcon=%08x\n", + __func__, channel, xferunit, dcon); if (chan == NULL) return -EINVAL; + pr_debug("%s: Initial dcon is %08x\n", __func__, dcon); + dcon = chan->dcon & dma_sel.dcon_mask; - pr_debug("%s: dcon is %08x\n", __func__, dcon); + + pr_debug("%s: New dcon is %08x\n", __func__, dcon); switch (chan->req_ch) { case DMACH_I2S_IN: @@ -1231,7 +1235,7 @@ static void s3c2410_dma_resume_chan(struct s3c2410_dma_chan *cp) /* restore channel's hardware configuration */ if (!cp->in_use) - return; + return 0; printk(KERN_INFO "dma%d: restoring configuration\n", cp->number); @@ -1242,6 +1246,8 @@ static void s3c2410_dma_resume_chan(struct s3c2410_dma_chan *cp) if (cp->map != NULL) dma_sel.select(cp, cp->map); + + return 0; } static void s3c2410_dma_resume(void) diff --git a/trunk/arch/arm/plat-s5p/irq-gpioint.c b/trunk/arch/arm/plat-s5p/irq-gpioint.c index 327ab9f662e8..135abda31c9a 100644 --- a/trunk/arch/arm/plat-s5p/irq-gpioint.c +++ b/trunk/arch/arm/plat-s5p/irq-gpioint.c @@ -152,7 +152,7 @@ static __init int s5p_gpioint_add(struct s3c_gpio_chip *chip) if (!gc) return -ENOMEM; ct = gc->chip_types; - ct->chip.irq_ack = irq_gc_ack_set_bit; + ct->chip.irq_ack = irq_gc_ack; ct->chip.irq_mask = irq_gc_mask_set_bit; ct->chip.irq_unmask = irq_gc_mask_clr_bit; ct->chip.irq_set_type = s5p_gpioint_set_type, diff --git a/trunk/arch/arm/plat-s5p/s5p-time.c b/trunk/arch/arm/plat-s5p/s5p-time.c index 612934c48b0d..899a8cc011ff 100644 --- a/trunk/arch/arm/plat-s5p/s5p-time.c +++ b/trunk/arch/arm/plat-s5p/s5p-time.c @@ -370,11 +370,11 @@ static void __init s5p_clocksource_init(void) clock_rate = clk_get_rate(tin_source); + init_sched_clock(&cd, s5p_update_sched_clock, 32, clock_rate); + s5p_time_setup(timer_source.source_id, TCNT_MAX); s5p_time_start(timer_source.source_id, PERIODIC); - init_sched_clock(&cd, s5p_update_sched_clock, 32, clock_rate); - if (clocksource_register_hz(&time_clocksource, clock_rate)) panic("%s: can't register clocksource\n", time_clocksource.name); } diff --git a/trunk/arch/arm/plat-samsung/include/plat/devs.h b/trunk/arch/arm/plat-samsung/include/plat/devs.h index e3b31c26ac3e..4af108ff4112 100644 --- a/trunk/arch/arm/plat-samsung/include/plat/devs.h +++ b/trunk/arch/arm/plat-samsung/include/plat/devs.h @@ -12,10 +12,6 @@ * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ - -#ifndef __PLAT_DEVS_H -#define __PLAT_DEVS_H __FILE__ - #include struct s3c24xx_uart_resources { @@ -163,5 +159,3 @@ extern struct platform_device s3c_device_ac97; */ extern void *s3c_set_platdata(void *pd, size_t pdsize, struct platform_device *pdev); - -#endif /* __PLAT_DEVS_H */ diff --git a/trunk/arch/arm/plat-samsung/include/plat/regs-serial.h b/trunk/arch/arm/plat-samsung/include/plat/regs-serial.h index 116edfe120b9..c151c5f94a87 100644 --- a/trunk/arch/arm/plat-samsung/include/plat/regs-serial.h +++ b/trunk/arch/arm/plat-samsung/include/plat/regs-serial.h @@ -224,8 +224,6 @@ #define S5PV210_UFSTAT_RXMASK (255<<0) #define S5PV210_UFSTAT_RXSHIFT (0) -#define NO_NEED_CHECK_CLKSRC 1 - #ifndef __ASSEMBLY__ /* struct s3c24xx_uart_clksrc diff --git a/trunk/arch/arm/plat-samsung/include/plat/s3c64xx-spi.h b/trunk/arch/arm/plat-samsung/include/plat/s3c64xx-spi.h index 4c16fa3621bb..0ffe34a21554 100644 --- a/trunk/arch/arm/plat-samsung/include/plat/s3c64xx-spi.h +++ b/trunk/arch/arm/plat-samsung/include/plat/s3c64xx-spi.h @@ -39,7 +39,6 @@ struct s3c64xx_spi_csinfo { * @fifo_lvl_mask: All tx fifo_lvl fields start at offset-6 * @rx_lvl_offset: Depends on tx fifo_lvl field and bus number * @high_speed: If the controller supports HIGH_SPEED_EN bit - * @tx_st_done: Depends on tx fifo_lvl field */ struct s3c64xx_spi_info { int src_clk_nr; @@ -54,7 +53,6 @@ struct s3c64xx_spi_info { int fifo_lvl_mask; int rx_lvl_offset; int high_speed; - int tx_st_done; }; /** diff --git a/trunk/arch/arm/plat-samsung/irq-uart.c b/trunk/arch/arm/plat-samsung/irq-uart.c index 0e46588d847b..32582c0958e3 100644 --- a/trunk/arch/arm/plat-samsung/irq-uart.c +++ b/trunk/arch/arm/plat-samsung/irq-uart.c @@ -55,7 +55,7 @@ static void __init s3c_init_uart_irq(struct s3c_uart_irq *uirq) gc = irq_alloc_generic_chip("s3c-uart", 1, uirq->base_irq, reg_base, handle_level_irq); ct = gc->chip_types; - ct->chip.irq_ack = irq_gc_ack_set_bit; + ct->chip.irq_ack = irq_gc_ack; ct->chip.irq_mask = irq_gc_mask_set_bit; ct->chip.irq_unmask = irq_gc_mask_clr_bit; ct->regs.ack = S3C64XX_UINTP; diff --git a/trunk/arch/m32r/include/asm/mmzone.h b/trunk/arch/m32r/include/asm/mmzone.h index 115ced33febd..9f3b5accda88 100644 --- a/trunk/arch/m32r/include/asm/mmzone.h +++ b/trunk/arch/m32r/include/asm/mmzone.h @@ -14,6 +14,12 @@ extern struct pglist_data *node_data[]; #define NODE_DATA(nid) (node_data[nid]) #define node_localnr(pfn, nid) ((pfn) - NODE_DATA(nid)->node_start_pfn) +#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn) +#define node_end_pfn(nid) \ +({ \ + pg_data_t *__pgdat = NODE_DATA(nid); \ + __pgdat->node_start_pfn + __pgdat->node_spanned_pages - 1; \ +}) #define pmd_page(pmd) (pfn_to_page(pmd_val(pmd) >> PAGE_SHIFT)) /* @@ -38,7 +44,7 @@ static __inline__ int pfn_to_nid(unsigned long pfn) int node; for (node = 0 ; node < MAX_NUMNODES ; node++) - if (pfn >= node_start_pfn(node) && pfn < node_end_pfn(node)) + if (pfn >= node_start_pfn(node) && pfn <= node_end_pfn(node)) break; return node; diff --git a/trunk/arch/mn10300/include/asm/uaccess.h b/trunk/arch/mn10300/include/asm/uaccess.h index 780560b330d9..3d6e60dad9d9 100644 --- a/trunk/arch/mn10300/include/asm/uaccess.h +++ b/trunk/arch/mn10300/include/asm/uaccess.h @@ -15,7 +15,6 @@ * User space memory access functions */ #include -#include #include #include diff --git a/trunk/arch/parisc/include/asm/mmzone.h b/trunk/arch/parisc/include/asm/mmzone.h index e67eb9c3d1bf..9608d2cf214a 100644 --- a/trunk/arch/parisc/include/asm/mmzone.h +++ b/trunk/arch/parisc/include/asm/mmzone.h @@ -14,6 +14,13 @@ extern struct node_map_data node_data[]; #define NODE_DATA(nid) (&node_data[nid].pg_data) +#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn) +#define node_end_pfn(nid) \ +({ \ + pg_data_t *__pgdat = NODE_DATA(nid); \ + __pgdat->node_start_pfn + __pgdat->node_spanned_pages; \ +}) + /* We have these possible memory map layouts: * Astro: 0-3.75, 67.75-68, 4-64 * zx1: 0-1, 257-260, 4-256 diff --git a/trunk/arch/powerpc/boot/dts/p1022ds.dts b/trunk/arch/powerpc/boot/dts/p1022ds.dts index 98d9426d4b85..4f685a779f4c 100644 --- a/trunk/arch/powerpc/boot/dts/p1022ds.dts +++ b/trunk/arch/powerpc/boot/dts/p1022ds.dts @@ -209,10 +209,8 @@ wm8776:codec@1a { compatible = "wlf,wm8776"; reg = <0x1a>; - /* - * clock-frequency will be set by U-Boot if - * the clock is enabled. - */ + /* MCLK source is a stand-alone oscillator */ + clock-frequency = <12288000>; }; }; @@ -282,8 +280,7 @@ codec-handle = <&wm8776>; fsl,playback-dma = <&dma00>; fsl,capture-dma = <&dma01>; - fsl,fifo-depth = <15>; - fsl,ssi-asynchronous; + fsl,fifo-depth = <16>; }; dma@c300 { diff --git a/trunk/arch/powerpc/configs/pseries_defconfig b/trunk/arch/powerpc/configs/pseries_defconfig index 80bc5de7ee1d..c9f212b5f3de 100644 --- a/trunk/arch/powerpc/configs/pseries_defconfig +++ b/trunk/arch/powerpc/configs/pseries_defconfig @@ -148,6 +148,7 @@ CONFIG_SCSI_SAS_ATTRS=m CONFIG_SCSI_CXGB3_ISCSI=m CONFIG_SCSI_CXGB4_ISCSI=m CONFIG_SCSI_BNX2_ISCSI=m +CONFIG_SCSI_BNX2_ISCSI=m CONFIG_BE2ISCSI=m CONFIG_SCSI_IBMVSCSI=y CONFIG_SCSI_IBMVFC=m diff --git a/trunk/arch/powerpc/include/asm/mmzone.h b/trunk/arch/powerpc/include/asm/mmzone.h index 7b589178be46..fd3fd58bad84 100644 --- a/trunk/arch/powerpc/include/asm/mmzone.h +++ b/trunk/arch/powerpc/include/asm/mmzone.h @@ -38,6 +38,13 @@ u64 memory_hotplug_max(void); #define memory_hotplug_max() memblock_end_of_DRAM() #endif +/* + * Following are macros that each numa implmentation must define. + */ + +#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn) +#define node_end_pfn(nid) (NODE_DATA(nid)->node_end_pfn) + #else #define memory_hotplug_max() memblock_end_of_DRAM() #endif /* CONFIG_NEED_MULTIPLE_NODES */ diff --git a/trunk/arch/powerpc/kernel/rtas-rtc.c b/trunk/arch/powerpc/kernel/rtas-rtc.c index c57c19358a26..77578c093dda 100644 --- a/trunk/arch/powerpc/kernel/rtas-rtc.c +++ b/trunk/arch/powerpc/kernel/rtas-rtc.c @@ -4,7 +4,6 @@ #include #include #include -#include #include #include #include @@ -30,10 +29,9 @@ unsigned long __init rtas_get_boot_time(void) } } while (wait_time && (get_tb() < max_wait_tb)); - if (error != 0) { - printk_ratelimited(KERN_WARNING - "error: reading the clock failed (%d)\n", - error); + if (error != 0 && printk_ratelimit()) { + printk(KERN_WARNING "error: reading the clock failed (%d)\n", + error); return 0; } @@ -57,21 +55,19 @@ void rtas_get_rtc_time(struct rtc_time *rtc_tm) wait_time = rtas_busy_delay_time(error); if (wait_time) { - if (in_interrupt()) { + if (in_interrupt() && printk_ratelimit()) { memset(rtc_tm, 0, sizeof(struct rtc_time)); - printk_ratelimited(KERN_WARNING - "error: reading clock " - "would delay interrupt\n"); + printk(KERN_WARNING "error: reading clock" + " would delay interrupt\n"); return; /* delay not allowed */ } msleep(wait_time); } } while (wait_time && (get_tb() < max_wait_tb)); - if (error != 0) { - printk_ratelimited(KERN_WARNING - "error: reading the clock failed (%d)\n", - error); + if (error != 0 && printk_ratelimit()) { + printk(KERN_WARNING "error: reading the clock failed (%d)\n", + error); return; } @@ -103,10 +99,9 @@ int rtas_set_rtc_time(struct rtc_time *tm) } } while (wait_time && (get_tb() < max_wait_tb)); - if (error != 0) - printk_ratelimited(KERN_WARNING - "error: setting the clock failed (%d)\n", - error); + if (error != 0 && printk_ratelimit()) + printk(KERN_WARNING "error: setting the clock failed (%d)\n", + error); return 0; } diff --git a/trunk/arch/powerpc/kernel/signal_32.c b/trunk/arch/powerpc/kernel/signal_32.c index 78b76dc54dfb..b96a3a010c26 100644 --- a/trunk/arch/powerpc/kernel/signal_32.c +++ b/trunk/arch/powerpc/kernel/signal_32.c @@ -25,7 +25,6 @@ #include #include #include -#include #ifdef CONFIG_PPC64 #include #include @@ -893,12 +892,11 @@ int handle_rt_signal32(unsigned long sig, struct k_sigaction *ka, printk("badframe in handle_rt_signal, regs=%p frame=%p newsp=%lx\n", regs, frame, newsp); #endif - if (show_unhandled_signals) - printk_ratelimited(KERN_INFO - "%s[%d]: bad frame in handle_rt_signal32: " - "%p nip %08lx lr %08lx\n", - current->comm, current->pid, - addr, regs->nip, regs->link); + if (show_unhandled_signals && printk_ratelimit()) + printk(KERN_INFO "%s[%d]: bad frame in handle_rt_signal32: " + "%p nip %08lx lr %08lx\n", + current->comm, current->pid, + addr, regs->nip, regs->link); force_sigsegv(sig, current); return 0; @@ -1060,12 +1058,11 @@ long sys_rt_sigreturn(int r3, int r4, int r5, int r6, int r7, int r8, return 0; bad: - if (show_unhandled_signals) - printk_ratelimited(KERN_INFO - "%s[%d]: bad frame in sys_rt_sigreturn: " - "%p nip %08lx lr %08lx\n", - current->comm, current->pid, - rt_sf, regs->nip, regs->link); + if (show_unhandled_signals && printk_ratelimit()) + printk(KERN_INFO "%s[%d]: bad frame in sys_rt_sigreturn: " + "%p nip %08lx lr %08lx\n", + current->comm, current->pid, + rt_sf, regs->nip, regs->link); force_sig(SIGSEGV, current); return 0; @@ -1152,12 +1149,12 @@ int sys_debug_setcontext(struct ucontext __user *ctx, * We kill the task with a SIGSEGV in this situation. */ if (do_setcontext(ctx, regs, 1)) { - if (show_unhandled_signals) - printk_ratelimited(KERN_INFO "%s[%d]: bad frame in " - "sys_debug_setcontext: %p nip %08lx " - "lr %08lx\n", - current->comm, current->pid, - ctx, regs->nip, regs->link); + if (show_unhandled_signals && printk_ratelimit()) + printk(KERN_INFO "%s[%d]: bad frame in " + "sys_debug_setcontext: %p nip %08lx " + "lr %08lx\n", + current->comm, current->pid, + ctx, regs->nip, regs->link); force_sig(SIGSEGV, current); goto out; @@ -1239,12 +1236,11 @@ int handle_signal32(unsigned long sig, struct k_sigaction *ka, printk("badframe in handle_signal, regs=%p frame=%p newsp=%lx\n", regs, frame, newsp); #endif - if (show_unhandled_signals) - printk_ratelimited(KERN_INFO - "%s[%d]: bad frame in handle_signal32: " - "%p nip %08lx lr %08lx\n", - current->comm, current->pid, - frame, regs->nip, regs->link); + if (show_unhandled_signals && printk_ratelimit()) + printk(KERN_INFO "%s[%d]: bad frame in handle_signal32: " + "%p nip %08lx lr %08lx\n", + current->comm, current->pid, + frame, regs->nip, regs->link); force_sigsegv(sig, current); return 0; @@ -1292,12 +1288,11 @@ long sys_sigreturn(int r3, int r4, int r5, int r6, int r7, int r8, return 0; badframe: - if (show_unhandled_signals) - printk_ratelimited(KERN_INFO - "%s[%d]: bad frame in sys_sigreturn: " - "%p nip %08lx lr %08lx\n", - current->comm, current->pid, - addr, regs->nip, regs->link); + if (show_unhandled_signals && printk_ratelimit()) + printk(KERN_INFO "%s[%d]: bad frame in sys_sigreturn: " + "%p nip %08lx lr %08lx\n", + current->comm, current->pid, + addr, regs->nip, regs->link); force_sig(SIGSEGV, current); return 0; diff --git a/trunk/arch/powerpc/kernel/signal_64.c b/trunk/arch/powerpc/kernel/signal_64.c index e91c736cc842..da989fff19cc 100644 --- a/trunk/arch/powerpc/kernel/signal_64.c +++ b/trunk/arch/powerpc/kernel/signal_64.c @@ -24,7 +24,6 @@ #include #include #include -#include #include #include @@ -381,10 +380,10 @@ int sys_rt_sigreturn(unsigned long r3, unsigned long r4, unsigned long r5, printk("badframe in sys_rt_sigreturn, regs=%p uc=%p &uc->uc_mcontext=%p\n", regs, uc, &uc->uc_mcontext); #endif - if (show_unhandled_signals) - printk_ratelimited(regs->msr & MSR_64BIT ? fmt64 : fmt32, - current->comm, current->pid, "rt_sigreturn", - (long)uc, regs->nip, regs->link); + if (show_unhandled_signals && printk_ratelimit()) + printk(regs->msr & MSR_64BIT ? fmt64 : fmt32, + current->comm, current->pid, "rt_sigreturn", + (long)uc, regs->nip, regs->link); force_sig(SIGSEGV, current); return 0; @@ -469,10 +468,10 @@ int handle_rt_signal64(int signr, struct k_sigaction *ka, siginfo_t *info, printk("badframe in setup_rt_frame, regs=%p frame=%p newsp=%lx\n", regs, frame, newsp); #endif - if (show_unhandled_signals) - printk_ratelimited(regs->msr & MSR_64BIT ? fmt64 : fmt32, - current->comm, current->pid, "setup_rt_frame", - (long)frame, regs->nip, regs->link); + if (show_unhandled_signals && printk_ratelimit()) + printk(regs->msr & MSR_64BIT ? fmt64 : fmt32, + current->comm, current->pid, "setup_rt_frame", + (long)frame, regs->nip, regs->link); force_sigsegv(signr, current); return 0; diff --git a/trunk/arch/powerpc/kernel/traps.c b/trunk/arch/powerpc/kernel/traps.c index 1a0141426cda..0ff4ab98d50c 100644 --- a/trunk/arch/powerpc/kernel/traps.c +++ b/trunk/arch/powerpc/kernel/traps.c @@ -34,7 +34,6 @@ #include #include #include -#include #include #include @@ -198,11 +197,12 @@ void _exception(int signr, struct pt_regs *regs, int code, unsigned long addr) if (die("Exception in kernel mode", regs, signr)) return; } else if (show_unhandled_signals && - unhandled_signal(current, signr)) { - printk_ratelimited(regs->msr & MSR_64BIT ? fmt64 : fmt32, - current->comm, current->pid, signr, - addr, regs->nip, regs->link, code); - } + unhandled_signal(current, signr) && + printk_ratelimit()) { + printk(regs->msr & MSR_64BIT ? fmt64 : fmt32, + current->comm, current->pid, signr, + addr, regs->nip, regs->link, code); + } memset(&info, 0, sizeof(info)); info.si_signo = signr; @@ -425,7 +425,7 @@ int machine_check_e500mc(struct pt_regs *regs) unsigned long reason = mcsr; int recoverable = 1; - if (reason & MCSR_LD) { + if (reason & MCSR_BUS_RBERR) { recoverable = fsl_rio_mcheck_exception(regs); if (recoverable == 1) goto silent_out; @@ -1342,8 +1342,9 @@ void altivec_assist_exception(struct pt_regs *regs) } else { /* didn't recognize the instruction */ /* XXX quick hack for now: set the non-Java bit in the VSCR */ - printk_ratelimited(KERN_ERR "Unrecognized altivec instruction " - "in %s at %lx\n", current->comm, regs->nip); + if (printk_ratelimit()) + printk(KERN_ERR "Unrecognized altivec instruction " + "in %s at %lx\n", current->comm, regs->nip); current->thread.vscr.u[3] |= 0x10000; } } @@ -1547,8 +1548,9 @@ u32 ppc_warn_emulated; void ppc_warn_emulated_print(const char *type) { - pr_warn_ratelimited("%s used emulated %s instruction\n", current->comm, - type); + if (printk_ratelimit()) + pr_warning("%s used emulated %s instruction\n", current->comm, + type); } static int __init ppc_warn_emulated_init(void) diff --git a/trunk/arch/powerpc/mm/fault.c b/trunk/arch/powerpc/mm/fault.c index ad35f66c69e8..54f4fb994e99 100644 --- a/trunk/arch/powerpc/mm/fault.c +++ b/trunk/arch/powerpc/mm/fault.c @@ -31,7 +31,6 @@ #include #include #include -#include #include #include @@ -347,10 +346,11 @@ int __kprobes do_page_fault(struct pt_regs *regs, unsigned long address, return 0; } - if (is_exec && (error_code & DSISR_PROTFAULT)) - printk_ratelimited(KERN_CRIT "kernel tried to execute NX-protected" - " page (%lx) - exploit attempt? (uid: %d)\n", - address, current_uid()); + if (is_exec && (error_code & DSISR_PROTFAULT) + && printk_ratelimit()) + printk(KERN_CRIT "kernel tried to execute NX-protected" + " page (%lx) - exploit attempt? (uid: %d)\n", + address, current_uid()); return SIGSEGV; diff --git a/trunk/arch/powerpc/platforms/pseries/hotplug-memory.c b/trunk/arch/powerpc/platforms/pseries/hotplug-memory.c index 9d6a8effeda2..33867ec4a234 100644 --- a/trunk/arch/powerpc/platforms/pseries/hotplug-memory.c +++ b/trunk/arch/powerpc/platforms/pseries/hotplug-memory.c @@ -12,8 +12,6 @@ #include #include #include -#include - #include #include #include @@ -22,25 +20,24 @@ static unsigned long get_memblock_size(void) { struct device_node *np; - unsigned int memblock_size = MIN_MEMORY_BLOCK_SIZE; - struct resource r; + unsigned int memblock_size = 0; np = of_find_node_by_path("/ibm,dynamic-reconfiguration-memory"); if (np) { - const __be64 *size; + const unsigned long *size; size = of_get_property(np, "ibm,lmb-size", NULL); - if (size) - memblock_size = be64_to_cpup(size); + memblock_size = size ? *size : 0; + of_node_put(np); - } else if (machine_is(pseries)) { - /* This fallback really only applies to pseries */ + } else { unsigned int memzero_size = 0; + const unsigned int *regs; np = of_find_node_by_path("/memory@0"); if (np) { - if (!of_address_to_resource(np, 0, &r)) - memzero_size = resource_size(&r); + regs = of_get_property(np, "reg", NULL); + memzero_size = regs ? regs[3] : 0; of_node_put(np); } @@ -53,21 +50,16 @@ static unsigned long get_memblock_size(void) sprintf(buf, "/memory@%x", memzero_size); np = of_find_node_by_path(buf); if (np) { - if (!of_address_to_resource(np, 0, &r)) - memblock_size = resource_size(&r); + regs = of_get_property(np, "reg", NULL); + memblock_size = regs ? regs[3] : 0; of_node_put(np); } } } + return memblock_size; } -/* WARNING: This is going to override the generic definition whenever - * pseries is built-in regardless of what platform is active at boot - * time. This is fine for now as this is the only "option" and it - * should work everywhere. If not, we'll have to turn this into a - * ppc_md. callback - */ unsigned long memory_block_size_bytes(void) { return get_memblock_size(); diff --git a/trunk/arch/powerpc/sysdev/fsl_rio.c b/trunk/arch/powerpc/sysdev/fsl_rio.c index b3fd081d56f5..5b206a2fe17c 100644 --- a/trunk/arch/powerpc/sysdev/fsl_rio.c +++ b/trunk/arch/powerpc/sysdev/fsl_rio.c @@ -283,24 +283,23 @@ static void __iomem *rio_regs_win; #ifdef CONFIG_E500 int fsl_rio_mcheck_exception(struct pt_regs *regs) { - const struct exception_table_entry *entry; - unsigned long reason; - - if (!rio_regs_win) - return 0; - - reason = in_be32((u32 *)(rio_regs_win + RIO_LTLEDCSR)); - if (reason & (RIO_LTLEDCSR_IER | RIO_LTLEDCSR_PRT)) { - /* Check if we are prepared to handle this fault */ - entry = search_exception_tables(regs->nip); - if (entry) { - pr_debug("RIO: %s - MC Exception handled\n", - __func__); - out_be32((u32 *)(rio_regs_win + RIO_LTLEDCSR), - 0); - regs->msr |= MSR_RI; - regs->nip = entry->fixup; - return 1; + const struct exception_table_entry *entry = NULL; + unsigned long reason = mfspr(SPRN_MCSR); + + if (reason & MCSR_BUS_RBERR) { + reason = in_be32((u32 *)(rio_regs_win + RIO_LTLEDCSR)); + if (reason & (RIO_LTLEDCSR_IER | RIO_LTLEDCSR_PRT)) { + /* Check if we are prepared to handle this fault */ + entry = search_exception_tables(regs->nip); + if (entry) { + pr_debug("RIO: %s - MC Exception handled\n", + __func__); + out_be32((u32 *)(rio_regs_win + RIO_LTLEDCSR), + 0); + regs->msr |= MSR_RI; + regs->nip = entry->fixup; + return 1; + } } } diff --git a/trunk/arch/powerpc/sysdev/mpic.c b/trunk/arch/powerpc/sysdev/mpic.c index 58d7a534f877..3a8de5bb628a 100644 --- a/trunk/arch/powerpc/sysdev/mpic.c +++ b/trunk/arch/powerpc/sysdev/mpic.c @@ -29,7 +29,6 @@ #include #include #include -#include #include #include @@ -1649,8 +1648,9 @@ static unsigned int _mpic_get_one_irq(struct mpic *mpic, int reg) return NO_IRQ; } if (unlikely(mpic->protected && test_bit(src, mpic->protected))) { - printk_ratelimited(KERN_WARNING "%s: Got protected source %d !\n", - mpic->name, (int)src); + if (printk_ratelimit()) + printk(KERN_WARNING "%s: Got protected source %d !\n", + mpic->name, (int)src); mpic_eoi(mpic); return NO_IRQ; } @@ -1688,8 +1688,9 @@ unsigned int mpic_get_coreint_irq(void) return NO_IRQ; } if (unlikely(mpic->protected && test_bit(src, mpic->protected))) { - printk_ratelimited(KERN_WARNING "%s: Got protected source %d !\n", - mpic->name, (int)src); + if (printk_ratelimit()) + printk(KERN_WARNING "%s: Got protected source %d !\n", + mpic->name, (int)src); return NO_IRQ; } diff --git a/trunk/arch/s390/Kconfig b/trunk/arch/s390/Kconfig index c03fef7a9c22..90d77bd078f5 100644 --- a/trunk/arch/s390/Kconfig +++ b/trunk/arch/s390/Kconfig @@ -579,7 +579,6 @@ config S390_GUEST def_bool y prompt "s390 guest support for KVM (EXPERIMENTAL)" depends on 64BIT && EXPERIMENTAL - select VIRTUALIZATION select VIRTIO select VIRTIO_RING select VIRTIO_CONSOLE diff --git a/trunk/arch/s390/kernel/smp.c b/trunk/arch/s390/kernel/smp.c index 1d55c95f617c..52420d2785b3 100644 --- a/trunk/arch/s390/kernel/smp.c +++ b/trunk/arch/s390/kernel/smp.c @@ -262,7 +262,7 @@ void smp_ctl_set_bit(int cr, int bit) memset(&parms.orvals, 0, sizeof(parms.orvals)); memset(&parms.andvals, 0xff, sizeof(parms.andvals)); - parms.orvals[cr] = 1UL << bit; + parms.orvals[cr] = 1 << bit; on_each_cpu(smp_ctl_bit_callback, &parms, 1); } EXPORT_SYMBOL(smp_ctl_set_bit); @@ -276,7 +276,7 @@ void smp_ctl_clear_bit(int cr, int bit) memset(&parms.orvals, 0, sizeof(parms.orvals)); memset(&parms.andvals, 0xff, sizeof(parms.andvals)); - parms.andvals[cr] = ~(1UL << bit); + parms.andvals[cr] = ~(1L << bit); on_each_cpu(smp_ctl_bit_callback, &parms, 1); } EXPORT_SYMBOL(smp_ctl_clear_bit); diff --git a/trunk/arch/s390/oprofile/init.c b/trunk/arch/s390/oprofile/init.c index 0e358c2cffeb..5995e9bc72d9 100644 --- a/trunk/arch/s390/oprofile/init.c +++ b/trunk/arch/s390/oprofile/init.c @@ -25,7 +25,7 @@ extern void s390_backtrace(struct pt_regs * const regs, unsigned int depth); #include "hwsampler.h" -#define DEFAULT_INTERVAL 4127518 +#define DEFAULT_INTERVAL 4096 #define DEFAULT_SDBT_BLOCKS 1 #define DEFAULT_SDB_BLOCKS 511 @@ -151,12 +151,6 @@ static int oprofile_hwsampler_init(struct oprofile_operations *ops) if (oprofile_max_interval == 0) return -ENODEV; - /* The initial value should be sane */ - if (oprofile_hw_interval < oprofile_min_interval) - oprofile_hw_interval = oprofile_min_interval; - if (oprofile_hw_interval > oprofile_max_interval) - oprofile_hw_interval = oprofile_max_interval; - if (oprofile_timer_init(ops)) return -ENODEV; diff --git a/trunk/arch/sh/Kconfig b/trunk/arch/sh/Kconfig index bbdeb48bbf8e..f03338c2f088 100644 --- a/trunk/arch/sh/Kconfig +++ b/trunk/arch/sh/Kconfig @@ -348,7 +348,6 @@ config CPU_SUBTYPE_SH7720 select SYS_SUPPORTS_CMT select ARCH_WANT_OPTIONAL_GPIOLIB select USB_ARCH_HAS_OHCI - select USB_OHCI_SH if USB_OHCI_HCD help Select SH7720 if you have a SH3-DSP SH7720 CPU. @@ -358,7 +357,6 @@ config CPU_SUBTYPE_SH7721 select CPU_HAS_DSP select SYS_SUPPORTS_CMT select USB_ARCH_HAS_OHCI - select USB_OHCI_SH if USB_OHCI_HCD help Select SH7721 if you have a SH3-DSP SH7721 CPU. @@ -442,7 +440,6 @@ config CPU_SUBTYPE_SH7763 bool "Support SH7763 processor" select CPU_SH4A select USB_ARCH_HAS_OHCI - select USB_OHCI_SH if USB_OHCI_HCD help Select SH7763 if you have a SH4A SH7763(R5S77631) CPU. @@ -470,9 +467,7 @@ config CPU_SUBTYPE_SH7786 select GENERIC_CLOCKEVENTS_BROADCAST if SMP select ARCH_WANT_OPTIONAL_GPIOLIB select USB_ARCH_HAS_OHCI - select USB_OHCI_SH if USB_OHCI_HCD select USB_ARCH_HAS_EHCI - select USB_EHCI_SH if USB_EHCI_HCD config CPU_SUBTYPE_SHX3 bool "Support SH-X3 processor" diff --git a/trunk/arch/sh/configs/sh7757lcr_defconfig b/trunk/arch/sh/configs/sh7757lcr_defconfig index cfde98ddb29d..33ddb130a7c8 100644 --- a/trunk/arch/sh/configs/sh7757lcr_defconfig +++ b/trunk/arch/sh/configs/sh7757lcr_defconfig @@ -9,6 +9,7 @@ CONFIG_TASK_XACCT=y CONFIG_TASK_IO_ACCOUNTING=y CONFIG_LOG_BUF_SHIFT=14 CONFIG_BLK_DEV_INITRD=y +# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set # CONFIG_SYSCTL_SYSCALL is not set CONFIG_KALLSYMS_ALL=y CONFIG_SLAB=y @@ -38,6 +39,8 @@ CONFIG_IPV6=y CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" # CONFIG_FW_LOADER is not set CONFIG_MTD=y +CONFIG_MTD_CONCAT=y +CONFIG_MTD_PARTITIONS=y CONFIG_MTD_CHAR=y CONFIG_MTD_BLOCK=y CONFIG_MTD_M25P80=y @@ -53,19 +56,18 @@ CONFIG_SH_ETH=y # CONFIG_KEYBOARD_ATKBD is not set # CONFIG_MOUSE_PS2 is not set # CONFIG_SERIO is not set -# CONFIG_LEGACY_PTYS is not set CONFIG_SERIAL_SH_SCI=y CONFIG_SERIAL_SH_SCI_NR_UARTS=3 CONFIG_SERIAL_SH_SCI_CONSOLE=y +# CONFIG_LEGACY_PTYS is not set # CONFIG_HW_RANDOM is not set CONFIG_SPI=y CONFIG_SPI_SH=y # CONFIG_HWMON is not set +CONFIG_MFD_SH_MOBILE_SDHI=y CONFIG_USB=y CONFIG_USB_EHCI_HCD=y -CONFIG_USB_EHCI_SH=y CONFIG_USB_OHCI_HCD=y -CONFIG_USB_OHCI_SH=y CONFIG_USB_STORAGE=y CONFIG_MMC=y CONFIG_MMC_SDHI=y diff --git a/trunk/arch/sh/include/asm/mmzone.h b/trunk/arch/sh/include/asm/mmzone.h index 15a8496960e6..8887baff5eff 100644 --- a/trunk/arch/sh/include/asm/mmzone.h +++ b/trunk/arch/sh/include/asm/mmzone.h @@ -9,6 +9,10 @@ extern struct pglist_data *node_data[]; #define NODE_DATA(nid) (node_data[nid]) +#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn) +#define node_end_pfn(nid) (NODE_DATA(nid)->node_start_pfn + \ + NODE_DATA(nid)->node_spanned_pages) + static inline int pfn_to_nid(unsigned long pfn) { int nid; diff --git a/trunk/arch/sh/kernel/cpu/sh4a/setup-sh7757.c b/trunk/arch/sh/kernel/cpu/sh4a/setup-sh7757.c index e915deafac89..423dabf542d3 100644 --- a/trunk/arch/sh/kernel/cpu/sh4a/setup-sh7757.c +++ b/trunk/arch/sh/kernel/cpu/sh4a/setup-sh7757.c @@ -183,7 +183,7 @@ static const struct sh_dmae_slave_config sh7757_dmae1_slaves[] = { { .slave_id = SHDMA_SLAVE_SCIF2_RX, .addr = 0x1f4b0014, - .chcr = DM_INC | 0x800 | 0x40000000 | + .chcr = SM_INC | 0x800 | 0x40000000 | TS_INDEX2VAL(XMIT_SZ_8BIT), .mid_rid = 0x22, }, @@ -197,7 +197,7 @@ static const struct sh_dmae_slave_config sh7757_dmae1_slaves[] = { { .slave_id = SHDMA_SLAVE_SCIF3_RX, .addr = 0x1f4c0014, - .chcr = DM_INC | 0x800 | 0x40000000 | + .chcr = SM_INC | 0x800 | 0x40000000 | TS_INDEX2VAL(XMIT_SZ_8BIT), .mid_rid = 0x2a, }, @@ -211,7 +211,7 @@ static const struct sh_dmae_slave_config sh7757_dmae1_slaves[] = { { .slave_id = SHDMA_SLAVE_SCIF4_RX, .addr = 0x1f4d0014, - .chcr = DM_INC | 0x800 | 0x40000000 | + .chcr = SM_INC | 0x800 | 0x40000000 | TS_INDEX2VAL(XMIT_SZ_8BIT), .mid_rid = 0x42, }, @@ -228,7 +228,7 @@ static const struct sh_dmae_slave_config sh7757_dmae2_slaves[] = { { .slave_id = SHDMA_SLAVE_RIIC0_RX, .addr = 0x1e500013, - .chcr = DM_INC | 0x800 | 0x40000000 | + .chcr = SM_INC | 0x800 | 0x40000000 | TS_INDEX2VAL(XMIT_SZ_8BIT), .mid_rid = 0x22, }, @@ -242,7 +242,7 @@ static const struct sh_dmae_slave_config sh7757_dmae2_slaves[] = { { .slave_id = SHDMA_SLAVE_RIIC1_RX, .addr = 0x1e510013, - .chcr = DM_INC | 0x800 | 0x40000000 | + .chcr = SM_INC | 0x800 | 0x40000000 | TS_INDEX2VAL(XMIT_SZ_8BIT), .mid_rid = 0x2a, }, @@ -256,7 +256,7 @@ static const struct sh_dmae_slave_config sh7757_dmae2_slaves[] = { { .slave_id = SHDMA_SLAVE_RIIC2_RX, .addr = 0x1e520013, - .chcr = DM_INC | 0x800 | 0x40000000 | + .chcr = SM_INC | 0x800 | 0x40000000 | TS_INDEX2VAL(XMIT_SZ_8BIT), .mid_rid = 0xa2, }, @@ -265,12 +265,12 @@ static const struct sh_dmae_slave_config sh7757_dmae2_slaves[] = { .addr = 0x1e530012, .chcr = SM_INC | 0x800 | 0x40000000 | TS_INDEX2VAL(XMIT_SZ_8BIT), - .mid_rid = 0xa9, + .mid_rid = 0xab, }, { .slave_id = SHDMA_SLAVE_RIIC3_RX, .addr = 0x1e530013, - .chcr = DM_INC | 0x800 | 0x40000000 | + .chcr = SM_INC | 0x800 | 0x40000000 | TS_INDEX2VAL(XMIT_SZ_8BIT), .mid_rid = 0xaf, }, @@ -279,14 +279,14 @@ static const struct sh_dmae_slave_config sh7757_dmae2_slaves[] = { .addr = 0x1e540012, .chcr = SM_INC | 0x800 | 0x40000000 | TS_INDEX2VAL(XMIT_SZ_8BIT), - .mid_rid = 0xc5, + .mid_rid = 0xc1, }, { .slave_id = SHDMA_SLAVE_RIIC4_RX, .addr = 0x1e540013, - .chcr = DM_INC | 0x800 | 0x40000000 | + .chcr = SM_INC | 0x800 | 0x40000000 | TS_INDEX2VAL(XMIT_SZ_8BIT), - .mid_rid = 0xc6, + .mid_rid = 0xc2, }, }; @@ -301,7 +301,7 @@ static const struct sh_dmae_slave_config sh7757_dmae3_slaves[] = { { .slave_id = SHDMA_SLAVE_RIIC5_RX, .addr = 0x1e550013, - .chcr = DM_INC | 0x800 | 0x40000000 | + .chcr = SM_INC | 0x800 | 0x40000000 | TS_INDEX2VAL(XMIT_SZ_8BIT), .mid_rid = 0x22, }, @@ -315,7 +315,7 @@ static const struct sh_dmae_slave_config sh7757_dmae3_slaves[] = { { .slave_id = SHDMA_SLAVE_RIIC6_RX, .addr = 0x1e560013, - .chcr = DM_INC | 0x800 | 0x40000000 | + .chcr = SM_INC | 0x800 | 0x40000000 | TS_INDEX2VAL(XMIT_SZ_8BIT), .mid_rid = 0x2a, }, @@ -329,7 +329,7 @@ static const struct sh_dmae_slave_config sh7757_dmae3_slaves[] = { { .slave_id = SHDMA_SLAVE_RIIC7_RX, .addr = 0x1e570013, - .chcr = DM_INC | 0x800 | 0x40000000 | + .chcr = SM_INC | 0x800 | 0x40000000 | TS_INDEX2VAL(XMIT_SZ_8BIT), .mid_rid = 0x42, }, @@ -343,7 +343,7 @@ static const struct sh_dmae_slave_config sh7757_dmae3_slaves[] = { { .slave_id = SHDMA_SLAVE_RIIC8_RX, .addr = 0x1e580013, - .chcr = DM_INC | 0x800 | 0x40000000 | + .chcr = SM_INC | 0x800 | 0x40000000 | TS_INDEX2VAL(XMIT_SZ_8BIT), .mid_rid = 0x46, }, @@ -357,7 +357,7 @@ static const struct sh_dmae_slave_config sh7757_dmae3_slaves[] = { { .slave_id = SHDMA_SLAVE_RIIC9_RX, .addr = 0x1e590013, - .chcr = DM_INC | 0x800 | 0x40000000 | + .chcr = SM_INC | 0x800 | 0x40000000 | TS_INDEX2VAL(XMIT_SZ_8BIT), .mid_rid = 0x52, }, @@ -659,54 +659,6 @@ static struct platform_device spi0_device = { .resource = spi0_resources, }; -static struct resource usb_ehci_resources[] = { - [0] = { - .start = 0xfe4f1000, - .end = 0xfe4f10ff, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = 57, - .end = 57, - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device usb_ehci_device = { - .name = "sh_ehci", - .id = -1, - .dev = { - .dma_mask = &usb_ehci_device.dev.coherent_dma_mask, - .coherent_dma_mask = DMA_BIT_MASK(32), - }, - .num_resources = ARRAY_SIZE(usb_ehci_resources), - .resource = usb_ehci_resources, -}; - -static struct resource usb_ohci_resources[] = { - [0] = { - .start = 0xfe4f1800, - .end = 0xfe4f18ff, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = 57, - .end = 57, - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device usb_ohci_device = { - .name = "sh_ohci", - .id = -1, - .dev = { - .dma_mask = &usb_ohci_device.dev.coherent_dma_mask, - .coherent_dma_mask = DMA_BIT_MASK(32), - }, - .num_resources = ARRAY_SIZE(usb_ohci_resources), - .resource = usb_ohci_resources, -}; - static struct platform_device *sh7757_devices[] __initdata = { &scif2_device, &scif3_device, @@ -718,8 +670,6 @@ static struct platform_device *sh7757_devices[] __initdata = { &dma2_device, &dma3_device, &spi0_device, - &usb_ehci_device, - &usb_ohci_device, }; static int __init sh7757_devices_setup(void) @@ -1089,13 +1039,13 @@ static DECLARE_INTC_DESC(intc_desc, "sh7757", vectors, groups, /* Support for external interrupt pins in IRQ mode */ static struct intc_vect vectors_irq0123[] __initdata = { - INTC_VECT(IRQ0, 0x200), INTC_VECT(IRQ1, 0x240), - INTC_VECT(IRQ2, 0x280), INTC_VECT(IRQ3, 0x2c0), + INTC_VECT(IRQ0, 0x240), INTC_VECT(IRQ1, 0x280), + INTC_VECT(IRQ2, 0x2c0), INTC_VECT(IRQ3, 0x300), }; static struct intc_vect vectors_irq4567[] __initdata = { - INTC_VECT(IRQ4, 0x300), INTC_VECT(IRQ5, 0x340), - INTC_VECT(IRQ6, 0x380), INTC_VECT(IRQ7, 0x3c0), + INTC_VECT(IRQ4, 0x340), INTC_VECT(IRQ5, 0x380), + INTC_VECT(IRQ6, 0x3c0), INTC_VECT(IRQ7, 0x200), }; static struct intc_sense_reg sense_registers[] __initdata = { @@ -1129,14 +1079,14 @@ static struct intc_vect vectors_irl0123[] __initdata = { }; static struct intc_vect vectors_irl4567[] __initdata = { - INTC_VECT(IRL4_LLLL, 0x200), INTC_VECT(IRL4_LLLH, 0x220), - INTC_VECT(IRL4_LLHL, 0x240), INTC_VECT(IRL4_LLHH, 0x260), - INTC_VECT(IRL4_LHLL, 0x280), INTC_VECT(IRL4_LHLH, 0x2a0), - INTC_VECT(IRL4_LHHL, 0x2c0), INTC_VECT(IRL4_LHHH, 0x2e0), - INTC_VECT(IRL4_HLLL, 0x300), INTC_VECT(IRL4_HLLH, 0x320), - INTC_VECT(IRL4_HLHL, 0x340), INTC_VECT(IRL4_HLHH, 0x360), - INTC_VECT(IRL4_HHLL, 0x380), INTC_VECT(IRL4_HHLH, 0x3a0), - INTC_VECT(IRL4_HHHL, 0x3c0), + INTC_VECT(IRL4_LLLL, 0xb00), INTC_VECT(IRL4_LLLH, 0xb20), + INTC_VECT(IRL4_LLHL, 0xb40), INTC_VECT(IRL4_LLHH, 0xb60), + INTC_VECT(IRL4_LHLL, 0xb80), INTC_VECT(IRL4_LHLH, 0xba0), + INTC_VECT(IRL4_LHHL, 0xbc0), INTC_VECT(IRL4_LHHH, 0xbe0), + INTC_VECT(IRL4_HLLL, 0xc00), INTC_VECT(IRL4_HLLH, 0xc20), + INTC_VECT(IRL4_HLHL, 0xc40), INTC_VECT(IRL4_HLHH, 0xc60), + INTC_VECT(IRL4_HHLL, 0xc80), INTC_VECT(IRL4_HHLH, 0xca0), + INTC_VECT(IRL4_HHHL, 0xcc0), }; static DECLARE_INTC_DESC(intc_desc_irl0123, "sh7757-irl0123", vectors_irl0123, diff --git a/trunk/arch/sh/kernel/irq.c b/trunk/arch/sh/kernel/irq.c index a3ee91971129..91971103b62b 100644 --- a/trunk/arch/sh/kernel/irq.c +++ b/trunk/arch/sh/kernel/irq.c @@ -13,7 +13,6 @@ #include #include #include -#include #include #include #include @@ -269,8 +268,9 @@ void migrate_irqs(void) unsigned int newcpu = cpumask_any_and(data->affinity, cpu_online_mask); if (newcpu >= nr_cpu_ids) { - pr_info_ratelimited("IRQ%u no longer affine to CPU%u\n", - irq, cpu); + if (printk_ratelimit()) + printk(KERN_INFO "IRQ%u no longer affine to CPU%u\n", + irq, cpu); cpumask_setall(data->affinity); newcpu = cpumask_any_and(data->affinity, diff --git a/trunk/arch/sh/mm/alignment.c b/trunk/arch/sh/mm/alignment.c index 620fa7ff9eec..b2595b8548ee 100644 --- a/trunk/arch/sh/mm/alignment.c +++ b/trunk/arch/sh/mm/alignment.c @@ -13,7 +13,6 @@ #include #include #include -#include #include #include @@ -96,13 +95,13 @@ int set_unalign_ctl(struct task_struct *tsk, unsigned int val) void unaligned_fixups_notify(struct task_struct *tsk, insn_size_t insn, struct pt_regs *regs) { - if (user_mode(regs) && (se_usermode & UM_WARN)) - pr_notice_ratelimited("Fixing up unaligned userspace access " + if (user_mode(regs) && (se_usermode & UM_WARN) && printk_ratelimit()) + pr_notice("Fixing up unaligned userspace access " "in \"%s\" pid=%d pc=0x%p ins=0x%04hx\n", tsk->comm, task_pid_nr(tsk), (void *)instruction_pointer(regs), insn); - else if (se_kernmode_warn) - pr_notice_ratelimited("Fixing up unaligned kernel access " + else if (se_kernmode_warn && printk_ratelimit()) + pr_notice("Fixing up unaligned kernel access " "in \"%s\" pid=%d pc=0x%p ins=0x%04hx\n", tsk->comm, task_pid_nr(tsk), (void *)instruction_pointer(regs), insn); diff --git a/trunk/arch/sparc/include/asm/mmzone.h b/trunk/arch/sparc/include/asm/mmzone.h index 99d9b9f577bf..e8c648741ed4 100644 --- a/trunk/arch/sparc/include/asm/mmzone.h +++ b/trunk/arch/sparc/include/asm/mmzone.h @@ -8,6 +8,8 @@ extern struct pglist_data *node_data[]; #define NODE_DATA(nid) (node_data[nid]) +#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn) +#define node_end_pfn(nid) (NODE_DATA(nid)->node_end_pfn) extern int numa_cpu_lookup_table[]; extern cpumask_t numa_cpumask_lookup_table[]; diff --git a/trunk/arch/tile/include/asm/mmzone.h b/trunk/arch/tile/include/asm/mmzone.h index 9d3dbce8f953..c6344c4f32ac 100644 --- a/trunk/arch/tile/include/asm/mmzone.h +++ b/trunk/arch/tile/include/asm/mmzone.h @@ -40,6 +40,17 @@ static inline int pfn_to_nid(unsigned long pfn) return highbits_to_node[__pfn_to_highbits(pfn)]; } +/* + * Following are macros that each numa implmentation must define. + */ + +#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn) +#define node_end_pfn(nid) \ +({ \ + pg_data_t *__pgdat = NODE_DATA(nid); \ + __pgdat->node_start_pfn + __pgdat->node_spanned_pages; \ +}) + #define kern_addr_valid(kaddr) virt_addr_valid((void *)kaddr) static inline int pfn_valid(int pfn) diff --git a/trunk/arch/um/include/asm/percpu.h b/trunk/arch/um/include/asm/percpu.h deleted file mode 100644 index efe7508d8abd..000000000000 --- a/trunk/arch/um/include/asm/percpu.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef __UM_PERCPU_H -#define __UM_PERCPU_H - -#include - -#endif /* __UM_PERCPU_H */ diff --git a/trunk/arch/x86/include/asm/apb_timer.h b/trunk/arch/x86/include/asm/apb_timer.h index af60d8a2e288..2fefa501d3ba 100644 --- a/trunk/arch/x86/include/asm/apb_timer.h +++ b/trunk/arch/x86/include/asm/apb_timer.h @@ -62,7 +62,7 @@ extern int sfi_mtimer_num; #else /* CONFIG_APB_TIMER */ static inline unsigned long apbt_quick_calibrate(void) {return 0; } -static inline void apbt_time_init(void) { } +static inline void apbt_time_init(void) {return 0; } #endif #endif /* ASM_X86_APBT_H */ diff --git a/trunk/arch/x86/include/asm/mmzone_32.h b/trunk/arch/x86/include/asm/mmzone_32.h index ffa037f28d39..5e83a416eca8 100644 --- a/trunk/arch/x86/include/asm/mmzone_32.h +++ b/trunk/arch/x86/include/asm/mmzone_32.h @@ -48,6 +48,17 @@ static inline int pfn_to_nid(unsigned long pfn) #endif } +/* + * Following are macros that each numa implmentation must define. + */ + +#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn) +#define node_end_pfn(nid) \ +({ \ + pg_data_t *__pgdat = NODE_DATA(nid); \ + __pgdat->node_start_pfn + __pgdat->node_spanned_pages; \ +}) + static inline int pfn_valid(int pfn) { int nid = pfn_to_nid(pfn); @@ -57,8 +68,6 @@ static inline int pfn_valid(int pfn) return 0; } -#define early_pfn_valid(pfn) pfn_valid((pfn)) - #endif /* CONFIG_DISCONTIGMEM */ #ifdef CONFIG_NEED_MULTIPLE_NODES diff --git a/trunk/arch/x86/include/asm/mmzone_64.h b/trunk/arch/x86/include/asm/mmzone_64.h index 129d9aa3ceb3..b3f88d7867c7 100644 --- a/trunk/arch/x86/include/asm/mmzone_64.h +++ b/trunk/arch/x86/include/asm/mmzone_64.h @@ -13,5 +13,8 @@ extern struct pglist_data *node_data[]; #define NODE_DATA(nid) (node_data[nid]) +#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn) +#define node_end_pfn(nid) (NODE_DATA(nid)->node_start_pfn + \ + NODE_DATA(nid)->node_spanned_pages) #endif #endif /* _ASM_X86_MMZONE_64_H */ diff --git a/trunk/arch/x86/kernel/acpi/realmode/wakeup.S b/trunk/arch/x86/kernel/acpi/realmode/wakeup.S index b4fd836e4053..ead21b663117 100644 --- a/trunk/arch/x86/kernel/acpi/realmode/wakeup.S +++ b/trunk/arch/x86/kernel/acpi/realmode/wakeup.S @@ -28,8 +28,6 @@ pmode_cr3: .long 0 /* Saved %cr3 */ pmode_cr4: .long 0 /* Saved %cr4 */ pmode_efer: .quad 0 /* Saved EFER */ pmode_gdt: .quad 0 -pmode_misc_en: .quad 0 /* Saved MISC_ENABLE MSR */ -pmode_behavior: .long 0 /* Wakeup behavior flags */ realmode_flags: .long 0 real_magic: .long 0 trampoline_segment: .word 0 @@ -93,18 +91,6 @@ wakeup_code: /* Call the C code */ calll main - /* Restore MISC_ENABLE before entering protected mode, in case - BIOS decided to clear XD_DISABLE during S3. */ - movl pmode_behavior, %eax - btl $WAKEUP_BEHAVIOR_RESTORE_MISC_ENABLE, %eax - jnc 1f - - movl pmode_misc_en, %eax - movl pmode_misc_en + 4, %edx - movl $MSR_IA32_MISC_ENABLE, %ecx - wrmsr -1: - /* Do any other stuff... */ #ifndef CONFIG_64BIT diff --git a/trunk/arch/x86/kernel/acpi/realmode/wakeup.h b/trunk/arch/x86/kernel/acpi/realmode/wakeup.h index 97a29e1430e3..e1828c07e79c 100644 --- a/trunk/arch/x86/kernel/acpi/realmode/wakeup.h +++ b/trunk/arch/x86/kernel/acpi/realmode/wakeup.h @@ -21,9 +21,6 @@ struct wakeup_header { u32 pmode_efer_low; /* Protected mode EFER */ u32 pmode_efer_high; u64 pmode_gdt; - u32 pmode_misc_en_low; /* Protected mode MISC_ENABLE */ - u32 pmode_misc_en_high; - u32 pmode_behavior; /* Wakeup routine behavior flags */ u32 realmode_flags; u32 real_magic; u16 trampoline_segment; /* segment with trampoline code, 64-bit only */ @@ -42,7 +39,4 @@ extern struct wakeup_header wakeup_header; #define WAKEUP_HEADER_SIGNATURE 0x51ee1111 #define WAKEUP_END_SIGNATURE 0x65a22c82 -/* Wakeup behavior bits */ -#define WAKEUP_BEHAVIOR_RESTORE_MISC_ENABLE 0 - #endif /* ARCH_X86_KERNEL_ACPI_RM_WAKEUP_H */ diff --git a/trunk/arch/x86/kernel/acpi/sleep.c b/trunk/arch/x86/kernel/acpi/sleep.c index 103b6ab368d3..18a857ba7a25 100644 --- a/trunk/arch/x86/kernel/acpi/sleep.c +++ b/trunk/arch/x86/kernel/acpi/sleep.c @@ -77,12 +77,6 @@ int acpi_suspend_lowlevel(void) header->pmode_cr0 = read_cr0(); header->pmode_cr4 = read_cr4_safe(); - header->pmode_behavior = 0; - if (!rdmsr_safe(MSR_IA32_MISC_ENABLE, - &header->pmode_misc_en_low, - &header->pmode_misc_en_high)) - header->pmode_behavior |= - (1 << WAKEUP_BEHAVIOR_RESTORE_MISC_ENABLE); header->realmode_flags = acpi_realmode_flags; header->real_magic = 0x12345678; diff --git a/trunk/arch/x86/kernel/reboot.c b/trunk/arch/x86/kernel/reboot.c index 4f0d46fefa7f..0c016f727695 100644 --- a/trunk/arch/x86/kernel/reboot.c +++ b/trunk/arch/x86/kernel/reboot.c @@ -294,14 +294,6 @@ static struct dmi_system_id __initdata reboot_dmi_table[] = { DMI_MATCH(DMI_BOARD_NAME, "VersaLogic Menlow board"), }, }, - { /* Handle reboot issue on Acer Aspire one */ - .callback = set_bios_reboot, - .ident = "Acer Aspire One A110", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "Acer"), - DMI_MATCH(DMI_PRODUCT_NAME, "AOA110"), - }, - }, { } }; diff --git a/trunk/arch/x86/kvm/emulate.c b/trunk/arch/x86/kvm/emulate.c index adc98675cda0..6df88c7885c0 100644 --- a/trunk/arch/x86/kvm/emulate.c +++ b/trunk/arch/x86/kvm/emulate.c @@ -3372,7 +3372,7 @@ x86_decode_insn(struct x86_emulate_ctxt *ctxt, void *insn, int insn_len) int def_op_bytes, def_ad_bytes, goffset, simd_prefix; bool op_prefix = false; struct opcode opcode; - struct operand memop = { .type = OP_NONE }, *memopp = NULL; + struct operand memop = { .type = OP_NONE }; c->eip = ctxt->eip; c->fetch.start = c->eip; @@ -3547,6 +3547,9 @@ x86_decode_insn(struct x86_emulate_ctxt *ctxt, void *insn, int insn_len) if (memop.type == OP_MEM && c->ad_bytes != 8) memop.addr.mem.ea = (u32)memop.addr.mem.ea; + if (memop.type == OP_MEM && c->rip_relative) + memop.addr.mem.ea += c->eip; + /* * Decode and fetch the source operand: register, memory * or immediate. @@ -3568,7 +3571,6 @@ x86_decode_insn(struct x86_emulate_ctxt *ctxt, void *insn, int insn_len) c->op_bytes; srcmem_common: c->src = memop; - memopp = &c->src; break; case SrcImmU16: rc = decode_imm(ctxt, &c->src, 2, false); @@ -3665,7 +3667,6 @@ x86_decode_insn(struct x86_emulate_ctxt *ctxt, void *insn, int insn_len) case DstMem: case DstMem64: c->dst = memop; - memopp = &c->dst; if ((c->d & DstMask) == DstMem64) c->dst.bytes = 8; else @@ -3699,13 +3700,10 @@ x86_decode_insn(struct x86_emulate_ctxt *ctxt, void *insn, int insn_len) /* Special instructions do their own operand decoding. */ default: c->dst.type = OP_NONE; /* Disable writeback. */ - break; + return 0; } done: - if (memopp && memopp->type == OP_MEM && c->rip_relative) - memopp->addr.mem.ea += c->eip; - return (rc == X86EMUL_UNHANDLEABLE) ? EMULATION_FAILED : EMULATION_OK; } diff --git a/trunk/arch/x86/mm/init_64.c b/trunk/arch/x86/mm/init_64.c index bbaaa005bf0e..d865c4aeec55 100644 --- a/trunk/arch/x86/mm/init_64.c +++ b/trunk/arch/x86/mm/init_64.c @@ -28,7 +28,6 @@ #include #include #include -#include #include #include #include @@ -896,6 +895,8 @@ const char *arch_vma_name(struct vm_area_struct *vma) } #ifdef CONFIG_X86_UV +#define MIN_MEMORY_BLOCK_SIZE (1 << SECTION_SIZE_BITS) + unsigned long memory_block_size_bytes(void) { if (is_uv_system()) { diff --git a/trunk/arch/x86/oprofile/nmi_int.c b/trunk/arch/x86/oprofile/nmi_int.c index 68894fdc034b..cf9750004a08 100644 --- a/trunk/arch/x86/oprofile/nmi_int.c +++ b/trunk/arch/x86/oprofile/nmi_int.c @@ -112,10 +112,8 @@ static void nmi_cpu_start(void *dummy) static int nmi_start(void) { get_online_cpus(); - ctr_running = 1; - /* make ctr_running visible to the nmi handler: */ - smp_mb(); on_each_cpu(nmi_cpu_start, NULL, 1); + ctr_running = 1; put_online_cpus(); return 0; } @@ -506,18 +504,15 @@ static int nmi_setup(void) nmi_enabled = 0; ctr_running = 0; - /* make variables visible to the nmi handler: */ - smp_mb(); + barrier(); err = register_die_notifier(&profile_exceptions_nb); if (err) goto fail; get_online_cpus(); register_cpu_notifier(&oprofile_cpu_nb); - nmi_enabled = 1; - /* make nmi_enabled visible to the nmi handler: */ - smp_mb(); on_each_cpu(nmi_cpu_setup, NULL, 1); + nmi_enabled = 1; put_online_cpus(); return 0; @@ -536,8 +531,7 @@ static void nmi_shutdown(void) nmi_enabled = 0; ctr_running = 0; put_online_cpus(); - /* make variables visible to the nmi handler: */ - smp_mb(); + barrier(); unregister_die_notifier(&profile_exceptions_nb); msrs = &get_cpu_var(cpu_msrs); model->shutdown(msrs); diff --git a/trunk/arch/x86/pci/acpi.c b/trunk/arch/x86/pci/acpi.c index 68c3c1395202..0972315c3860 100644 --- a/trunk/arch/x86/pci/acpi.c +++ b/trunk/arch/x86/pci/acpi.c @@ -188,7 +188,7 @@ static bool resource_contains(struct resource *res, resource_size_t point) return false; } -static void coalesce_windows(struct pci_root_info *info, unsigned long type) +static void coalesce_windows(struct pci_root_info *info, int type) { int i, j; struct resource *res1, *res2; diff --git a/trunk/arch/x86/pci/xen.c b/trunk/arch/x86/pci/xen.c index f567965c0620..8214724ce54d 100644 --- a/trunk/arch/x86/pci/xen.c +++ b/trunk/arch/x86/pci/xen.c @@ -327,7 +327,7 @@ int __init pci_xen_hvm_init(void) } #ifdef CONFIG_XEN_DOM0 -static int xen_register_pirq(u32 gsi, int gsi_override, int triggering) +static int xen_register_pirq(u32 gsi, int triggering) { int rc, pirq, irq = -1; struct physdev_map_pirq map_irq; @@ -344,18 +344,16 @@ static int xen_register_pirq(u32 gsi, int gsi_override, int triggering) shareable = 1; name = "ioapic-level"; } + pirq = xen_allocate_pirq_gsi(gsi); if (pirq < 0) goto out; - if (gsi_override >= 0) - irq = xen_bind_pirq_gsi_to_irq(gsi_override, pirq, shareable, name); - else - irq = xen_bind_pirq_gsi_to_irq(gsi, pirq, shareable, name); + irq = xen_bind_pirq_gsi_to_irq(gsi, pirq, shareable, name); if (irq < 0) goto out; - printk(KERN_DEBUG "xen: --> pirq=%d -> irq=%d (gsi=%d)\n", pirq, irq, gsi); + printk(KERN_DEBUG "xen: --> pirq=%d -> irq=%d\n", pirq, irq); map_irq.domid = DOMID_SELF; map_irq.type = MAP_PIRQ_TYPE_GSI; @@ -372,7 +370,7 @@ static int xen_register_pirq(u32 gsi, int gsi_override, int triggering) return irq; } -static int xen_register_gsi(u32 gsi, int gsi_override, int triggering, int polarity) +static int xen_register_gsi(u32 gsi, int triggering, int polarity) { int rc, irq; struct physdev_setup_gsi setup_gsi; @@ -383,7 +381,7 @@ static int xen_register_gsi(u32 gsi, int gsi_override, int triggering, int polar printk(KERN_DEBUG "xen: registering gsi %u triggering %d polarity %d\n", gsi, triggering, polarity); - irq = xen_register_pirq(gsi, gsi_override, triggering); + irq = xen_register_pirq(gsi, triggering); setup_gsi.gsi = gsi; setup_gsi.triggering = (triggering == ACPI_EDGE_SENSITIVE ? 0 : 1); @@ -405,8 +403,6 @@ static __init void xen_setup_acpi_sci(void) int rc; int trigger, polarity; int gsi = acpi_sci_override_gsi; - int irq = -1; - int gsi_override = -1; if (!gsi) return; @@ -423,25 +419,7 @@ static __init void xen_setup_acpi_sci(void) printk(KERN_INFO "xen: sci override: global_irq=%d trigger=%d " "polarity=%d\n", gsi, trigger, polarity); - /* Before we bind the GSI to a Linux IRQ, check whether - * we need to override it with bus_irq (IRQ) value. Usually for - * IRQs below IRQ_LEGACY_IRQ this holds IRQ == GSI, as so: - * ACPI: INT_SRC_OVR (bus 0 bus_irq 9 global_irq 9 low level) - * but there are oddballs where the IRQ != GSI: - * ACPI: INT_SRC_OVR (bus 0 bus_irq 9 global_irq 20 low level) - * which ends up being: gsi_to_irq[9] == 20 - * (which is what acpi_gsi_to_irq ends up calling when starting the - * the ACPI interpreter and keels over since IRQ 9 has not been - * setup as we had setup IRQ 20 for it). - */ - /* Check whether the GSI != IRQ */ - if (acpi_gsi_to_irq(gsi, &irq) == 0) { - if (irq >= 0 && irq != gsi) - /* Bugger, we MUST have that IRQ. */ - gsi_override = irq; - } - - gsi = xen_register_gsi(gsi, gsi_override, trigger, polarity); + gsi = xen_register_gsi(gsi, trigger, polarity); printk(KERN_INFO "xen: acpi sci %d\n", gsi); return; @@ -450,7 +428,7 @@ static __init void xen_setup_acpi_sci(void) static int acpi_register_gsi_xen(struct device *dev, u32 gsi, int trigger, int polarity) { - return xen_register_gsi(gsi, -1 /* no GSI override */, trigger, polarity); + return xen_register_gsi(gsi, trigger, polarity); } static int __init pci_xen_initial_domain(void) @@ -489,7 +467,7 @@ void __init xen_setup_pirqs(void) if (acpi_get_override_irq(irq, &trigger, &polarity) == -1) continue; - xen_register_pirq(irq, -1 /* no GSI override */, + xen_register_pirq(irq, trigger ? ACPI_LEVEL_SENSITIVE : ACPI_EDGE_SENSITIVE); } } diff --git a/trunk/arch/x86/platform/efi/efi.c b/trunk/arch/x86/platform/efi/efi.c index 899e393d8e73..474356b98ede 100644 --- a/trunk/arch/x86/platform/efi/efi.c +++ b/trunk/arch/x86/platform/efi/efi.c @@ -504,6 +504,9 @@ void __init efi_init(void) x86_platform.set_wallclock = efi_set_rtc_mmss; #endif + /* Setup for EFI runtime service */ + reboot_type = BOOT_EFI; + #if EFI_DEBUG print_efi_memmap(); #endif diff --git a/trunk/arch/x86/xen/mmu.c b/trunk/arch/x86/xen/mmu.c index 0ccccb67a993..673e968df3cf 100644 --- a/trunk/arch/x86/xen/mmu.c +++ b/trunk/arch/x86/xen/mmu.c @@ -1232,11 +1232,7 @@ static void xen_flush_tlb_others(const struct cpumask *cpus, { struct { struct mmuext_op op; -#ifdef CONFIG_SMP DECLARE_BITMAP(mask, num_processors); -#else - DECLARE_BITMAP(mask, NR_CPUS); -#endif } *args; struct multicall_space mcs; diff --git a/trunk/block/blk-throttle.c b/trunk/block/blk-throttle.c index 3689f833afdc..a62be8d0dc1b 100644 --- a/trunk/block/blk-throttle.c +++ b/trunk/block/blk-throttle.c @@ -927,7 +927,7 @@ static int throtl_dispatch(struct request_queue *q) bio_list_init(&bio_list_on_stack); - throtl_log(td, "dispatch nr_queued=%d read=%u write=%u", + throtl_log(td, "dispatch nr_queued=%lu read=%u write=%u", total_nr_queued(td), td->nr_queued[READ], td->nr_queued[WRITE]); @@ -1204,7 +1204,7 @@ int blk_throtl_bio(struct request_queue *q, struct bio **biop) } queue_bio: - throtl_log_tg(td, tg, "[%c] bio. bdisp=%llu sz=%u bps=%llu" + throtl_log_tg(td, tg, "[%c] bio. bdisp=%u sz=%u bps=%llu" " iodisp=%u iops=%u queued=%d/%d", rw == READ ? 'R' : 'W', tg->bytes_disp[rw], bio->bi_size, tg->bps[rw], diff --git a/trunk/block/cfq-iosched.c b/trunk/block/cfq-iosched.c index ae21919f15e1..3c7b537bf908 100644 --- a/trunk/block/cfq-iosched.c +++ b/trunk/block/cfq-iosched.c @@ -988,10 +988,9 @@ static void cfq_group_served(struct cfq_data *cfqd, struct cfq_group *cfqg, cfq_log_cfqg(cfqd, cfqg, "served: vt=%llu min_vt=%llu", cfqg->vdisktime, st->min_vdisktime); - cfq_log_cfqq(cfqq->cfqd, cfqq, - "sl_used=%u disp=%u charge=%u iops=%u sect=%lu", - used_sl, cfqq->slice_dispatch, charge, - iops_mode(cfqd), cfqq->nr_sectors); + cfq_log_cfqq(cfqq->cfqd, cfqq, "sl_used=%u disp=%u charge=%u iops=%u" + " sect=%u", used_sl, cfqq->slice_dispatch, charge, + iops_mode(cfqd), cfqq->nr_sectors); cfq_blkiocg_update_timeslice_used(&cfqg->blkg, used_sl, unaccounted_sl); cfq_blkiocg_set_start_empty_time(&cfqg->blkg); @@ -2024,8 +2023,8 @@ static void cfq_arm_slice_timer(struct cfq_data *cfqd) */ if (sample_valid(cic->ttime_samples) && (cfqq->slice_end - jiffies < cic->ttime_mean)) { - cfq_log_cfqq(cfqd, cfqq, "Not idling. think_time:%lu", - cic->ttime_mean); + cfq_log_cfqq(cfqd, cfqq, "Not idling. think_time:%d", + cic->ttime_mean); return; } @@ -2773,14 +2772,8 @@ static void __cfq_exit_single_io_context(struct cfq_data *cfqd, smp_wmb(); cic->key = cfqd_dead_key(cfqd); - rcu_read_lock(); - if (rcu_dereference(ioc->ioc_data) == cic) { - rcu_read_unlock(); - spin_lock(&ioc->lock); + if (ioc->ioc_data == cic) rcu_assign_pointer(ioc->ioc_data, NULL); - spin_unlock(&ioc->lock); - } else - rcu_read_unlock(); if (cic->cfqq[BLK_RW_ASYNC]) { cfq_exit_cfqq(cfqd, cic->cfqq[BLK_RW_ASYNC]); @@ -3087,8 +3080,7 @@ cfq_drop_dead_cic(struct cfq_data *cfqd, struct io_context *ioc, spin_lock_irqsave(&ioc->lock, flags); - BUG_ON(rcu_dereference_check(ioc->ioc_data, - lockdep_is_held(&ioc->lock)) == cic); + BUG_ON(ioc->ioc_data == cic); radix_tree_delete(&ioc->radix_root, cfqd->cic_index); hlist_del_rcu(&cic->cic_list); diff --git a/trunk/block/genhd.c b/trunk/block/genhd.c index 3608289c8ecd..95822ae25cfe 100644 --- a/trunk/block/genhd.c +++ b/trunk/block/genhd.c @@ -1371,7 +1371,6 @@ struct disk_events { struct gendisk *disk; /* the associated disk */ spinlock_t lock; - struct mutex block_mutex; /* protects blocking */ int block; /* event blocking depth */ unsigned int pending; /* events already sent out */ unsigned int clearing; /* events being cleared */ @@ -1415,44 +1414,22 @@ static unsigned long disk_events_poll_jiffies(struct gendisk *disk) return msecs_to_jiffies(intv_msecs); } -/** - * disk_block_events - block and flush disk event checking - * @disk: disk to block events for - * - * On return from this function, it is guaranteed that event checking - * isn't in progress and won't happen until unblocked by - * disk_unblock_events(). Events blocking is counted and the actual - * unblocking happens after the matching number of unblocks are done. - * - * Note that this intentionally does not block event checking from - * disk_clear_events(). - * - * CONTEXT: - * Might sleep. - */ -void disk_block_events(struct gendisk *disk) +static void __disk_block_events(struct gendisk *disk, bool sync) { struct disk_events *ev = disk->ev; unsigned long flags; bool cancel; - if (!ev) - return; - - /* - * Outer mutex ensures that the first blocker completes canceling - * the event work before further blockers are allowed to finish. - */ - mutex_lock(&ev->block_mutex); - spin_lock_irqsave(&ev->lock, flags); cancel = !ev->block++; spin_unlock_irqrestore(&ev->lock, flags); - if (cancel) - cancel_delayed_work_sync(&disk->ev->dwork); - - mutex_unlock(&ev->block_mutex); + if (cancel) { + if (sync) + cancel_delayed_work_sync(&disk->ev->dwork); + else + cancel_delayed_work(&disk->ev->dwork); + } } static void __disk_unblock_events(struct gendisk *disk, bool check_now) @@ -1483,6 +1460,27 @@ static void __disk_unblock_events(struct gendisk *disk, bool check_now) spin_unlock_irqrestore(&ev->lock, flags); } +/** + * disk_block_events - block and flush disk event checking + * @disk: disk to block events for + * + * On return from this function, it is guaranteed that event checking + * isn't in progress and won't happen until unblocked by + * disk_unblock_events(). Events blocking is counted and the actual + * unblocking happens after the matching number of unblocks are done. + * + * Note that this intentionally does not block event checking from + * disk_clear_events(). + * + * CONTEXT: + * Might sleep. + */ +void disk_block_events(struct gendisk *disk) +{ + if (disk->ev) + __disk_block_events(disk, true); +} + /** * disk_unblock_events - unblock disk event checking * @disk: disk to unblock events for @@ -1510,18 +1508,10 @@ void disk_unblock_events(struct gendisk *disk) */ void disk_check_events(struct gendisk *disk) { - struct disk_events *ev = disk->ev; - unsigned long flags; - - if (!ev) - return; - - spin_lock_irqsave(&ev->lock, flags); - if (!ev->block) { - cancel_delayed_work(&ev->dwork); - queue_delayed_work(system_nrt_wq, &ev->dwork, 0); + if (disk->ev) { + __disk_block_events(disk, false); + __disk_unblock_events(disk, true); } - spin_unlock_irqrestore(&ev->lock, flags); } EXPORT_SYMBOL_GPL(disk_check_events); @@ -1556,7 +1546,7 @@ unsigned int disk_clear_events(struct gendisk *disk, unsigned int mask) spin_unlock_irq(&ev->lock); /* uncondtionally schedule event check and wait for it to finish */ - disk_block_events(disk); + __disk_block_events(disk, true); queue_delayed_work(system_nrt_wq, &ev->dwork, 0); flush_delayed_work(&ev->dwork); __disk_unblock_events(disk, false); @@ -1674,7 +1664,7 @@ static ssize_t disk_events_poll_msecs_store(struct device *dev, if (intv < 0 && intv != -1) return -EINVAL; - disk_block_events(disk); + __disk_block_events(disk, true); disk->ev->poll_msecs = intv; __disk_unblock_events(disk, true); @@ -1760,7 +1750,6 @@ static void disk_add_events(struct gendisk *disk) INIT_LIST_HEAD(&ev->node); ev->disk = disk; spin_lock_init(&ev->lock); - mutex_init(&ev->block_mutex); ev->block = 1; ev->poll_msecs = -1; INIT_DELAYED_WORK(&ev->dwork, disk_events_workfn); @@ -1781,7 +1770,7 @@ static void disk_del_events(struct gendisk *disk) if (!disk->ev) return; - disk_block_events(disk); + __disk_block_events(disk, true); mutex_lock(&disk_events_mutex); list_del_init(&disk->ev->node); diff --git a/trunk/crypto/deflate.c b/trunk/crypto/deflate.c index b0165ecad0c5..b5ccae29be74 100644 --- a/trunk/crypto/deflate.c +++ b/trunk/crypto/deflate.c @@ -32,6 +32,7 @@ #include #include #include +#include #define DEFLATE_DEF_LEVEL Z_DEFAULT_COMPRESSION #define DEFLATE_DEF_WINBITS 11 @@ -72,7 +73,7 @@ static int deflate_decomp_init(struct deflate_ctx *ctx) int ret = 0; struct z_stream_s *stream = &ctx->decomp_stream; - stream->workspace = vzalloc(zlib_inflate_workspacesize()); + stream->workspace = kzalloc(zlib_inflate_workspacesize(), GFP_KERNEL); if (!stream->workspace) { ret = -ENOMEM; goto out; @@ -85,7 +86,7 @@ static int deflate_decomp_init(struct deflate_ctx *ctx) out: return ret; out_free: - vfree(stream->workspace); + kfree(stream->workspace); goto out; } @@ -98,7 +99,7 @@ static void deflate_comp_exit(struct deflate_ctx *ctx) static void deflate_decomp_exit(struct deflate_ctx *ctx) { zlib_inflateEnd(&ctx->decomp_stream); - vfree(ctx->decomp_stream.workspace); + kfree(ctx->decomp_stream.workspace); } static int deflate_init(struct crypto_tfm *tfm) diff --git a/trunk/crypto/zlib.c b/trunk/crypto/zlib.c index 06b62e5cdcc7..d11d761a5e41 100644 --- a/trunk/crypto/zlib.c +++ b/trunk/crypto/zlib.c @@ -29,6 +29,7 @@ #include #include #include +#include #include @@ -59,7 +60,7 @@ static void zlib_decomp_exit(struct zlib_ctx *ctx) if (stream->workspace) { zlib_inflateEnd(stream); - vfree(stream->workspace); + kfree(stream->workspace); stream->workspace = NULL; } } @@ -227,13 +228,13 @@ static int zlib_decompress_setup(struct crypto_pcomp *tfm, void *params, ? nla_get_u32(tb[ZLIB_DECOMP_WINDOWBITS]) : DEF_WBITS; - stream->workspace = vzalloc(zlib_inflate_workspacesize()); + stream->workspace = kzalloc(zlib_inflate_workspacesize(), GFP_KERNEL); if (!stream->workspace) return -ENOMEM; ret = zlib_inflateInit2(stream, ctx->decomp_windowBits); if (ret != Z_OK) { - vfree(stream->workspace); + kfree(stream->workspace); stream->workspace = NULL; return -EINVAL; } diff --git a/trunk/drivers/Kconfig b/trunk/drivers/Kconfig index 258473ce8d01..3bb154d8c8cc 100644 --- a/trunk/drivers/Kconfig +++ b/trunk/drivers/Kconfig @@ -94,6 +94,8 @@ source "drivers/memstick/Kconfig" source "drivers/leds/Kconfig" +source "drivers/nfc/Kconfig" + source "drivers/accessibility/Kconfig" source "drivers/infiniband/Kconfig" diff --git a/trunk/drivers/Makefile b/trunk/drivers/Makefile index 1bc896571a3a..09f3232bcdcd 100644 --- a/trunk/drivers/Makefile +++ b/trunk/drivers/Makefile @@ -122,4 +122,3 @@ obj-y += ieee802154/ obj-y += clk/ obj-$(CONFIG_HWSPINLOCK) += hwspinlock/ -obj-$(CONFIG_NFC) += nfc/ diff --git a/trunk/drivers/ata/libahci.c b/trunk/drivers/ata/libahci.c index 41223c7f0206..d38c40fe4ddb 100644 --- a/trunk/drivers/ata/libahci.c +++ b/trunk/drivers/ata/libahci.c @@ -452,7 +452,7 @@ void ahci_save_initial_config(struct device *dev, } if (mask_port_map) { - dev_printk(KERN_WARNING, dev, "masking port_map 0x%x -> 0x%x\n", + dev_printk(KERN_ERR, dev, "masking port_map 0x%x -> 0x%x\n", port_map, port_map & mask_port_map); port_map &= mask_port_map; diff --git a/trunk/drivers/ata/libata-core.c b/trunk/drivers/ata/libata-core.c index 000d03ae6653..736bee5dafeb 100644 --- a/trunk/drivers/ata/libata-core.c +++ b/trunk/drivers/ata/libata-core.c @@ -4143,9 +4143,9 @@ static const struct ata_blacklist_entry ata_device_blacklist [] = { * Devices which choke on SETXFER. Applies only if both the * device and controller are SATA. */ - { "PIONEER DVD-RW DVRTD08", NULL, ATA_HORKAGE_NOSETXFER }, - { "PIONEER DVD-RW DVR-212D", NULL, ATA_HORKAGE_NOSETXFER }, - { "PIONEER DVD-RW DVR-216D", NULL, ATA_HORKAGE_NOSETXFER }, + { "PIONEER DVD-RW DVRTD08", "1.00", ATA_HORKAGE_NOSETXFER }, + { "PIONEER DVD-RW DVR-212D", "1.28", ATA_HORKAGE_NOSETXFER }, + { "PIONEER DVD-RW DVR-216D", "1.08", ATA_HORKAGE_NOSETXFER }, /* End Marker */ { } diff --git a/trunk/drivers/ata/libata-scsi.c b/trunk/drivers/ata/libata-scsi.c index 927f968e99d9..d51f9795c064 100644 --- a/trunk/drivers/ata/libata-scsi.c +++ b/trunk/drivers/ata/libata-scsi.c @@ -3797,12 +3797,6 @@ EXPORT_SYMBOL_GPL(ata_sas_port_alloc); */ int ata_sas_port_start(struct ata_port *ap) { - /* - * the port is marked as frozen at allocation time, but if we don't - * have new eh, we won't thaw it - */ - if (!ap->ops->error_handler) - ap->pflags &= ~ATA_PFLAG_FROZEN; return 0; } EXPORT_SYMBOL_GPL(ata_sas_port_start); diff --git a/trunk/drivers/ata/pata_marvell.c b/trunk/drivers/ata/pata_marvell.c index 5d7f58a7e34d..75a6a0c0094f 100644 --- a/trunk/drivers/ata/pata_marvell.c +++ b/trunk/drivers/ata/pata_marvell.c @@ -161,9 +161,6 @@ static const struct pci_device_id marvell_pci_tbl[] = { { PCI_DEVICE(0x11AB, 0x6121), }, { PCI_DEVICE(0x11AB, 0x6123), }, { PCI_DEVICE(0x11AB, 0x6145), }, - { PCI_DEVICE(0x1B4B, 0x91A0), }, - { PCI_DEVICE(0x1B4B, 0x91A4), }, - { } /* terminate list */ }; diff --git a/trunk/drivers/ata/sata_dwc_460ex.c b/trunk/drivers/ata/sata_dwc_460ex.c index dc88a39e7db8..1c4b3aa4c7c4 100644 --- a/trunk/drivers/ata/sata_dwc_460ex.c +++ b/trunk/drivers/ata/sata_dwc_460ex.c @@ -389,7 +389,7 @@ static void sata_dwc_tf_dump(struct ata_taskfile *tf) /* * Function: get_burst_length_encode * arguments: datalength: length in bytes of data - * returns value to be programmed in register corresponding to data length + * returns value to be programmed in register corrresponding to data length * This value is effectively the log(base 2) of the length */ static int get_burst_length_encode(int datalength) diff --git a/trunk/drivers/atm/ambassador.c b/trunk/drivers/atm/ambassador.c index bb3b016b6ce8..a5fcb1eb862f 100644 --- a/trunk/drivers/atm/ambassador.c +++ b/trunk/drivers/atm/ambassador.c @@ -813,7 +813,7 @@ static void fill_rx_pool (amb_dev * dev, unsigned char pool, return; } -// top up all RX pools +// top up all RX pools (can also be called as a bottom half) static void fill_rx_pools (amb_dev * dev) { unsigned char pool; @@ -872,7 +872,11 @@ static irqreturn_t interrupt_handler(int irq, void *dev_id) { ++irq_work; if (irq_work) { +#ifdef FILL_RX_POOLS_IN_BH + schedule_work (&dev->bh); +#else fill_rx_pools (dev); +#endif PRINTD (DBG_IRQ, "work done: %u", irq_work); } else { @@ -2150,6 +2154,11 @@ static void setup_dev(amb_dev *dev, struct pci_dev *pci_dev) dev->tx_avail = ATM_OC3_PCR; dev->rx_avail = ATM_OC3_PCR; +#ifdef FILL_RX_POOLS_IN_BH + // initialise bottom half + INIT_WORK(&dev->bh, (void (*)(void *)) fill_rx_pools, dev); +#endif + // semaphore for txer/rxer modifications - we cannot use a // spinlock as the critical region needs to switch processes mutex_init(&dev->vcc_sf); diff --git a/trunk/drivers/atm/ambassador.h b/trunk/drivers/atm/ambassador.h index aa9710556bd6..bd1c46a7ef49 100644 --- a/trunk/drivers/atm/ambassador.h +++ b/trunk/drivers/atm/ambassador.h @@ -630,6 +630,10 @@ struct amb_dev { u32 iobase; u32 * membase; +#ifdef FILL_RX_POOLS_IN_BH + struct work_struct bh; +#endif + amb_cq cq; amb_txq txq; amb_rxq rxq[NUM_RX_POOLS]; diff --git a/trunk/drivers/atm/lanai.c b/trunk/drivers/atm/lanai.c index e828c5487493..4e8ba56f75d3 100644 --- a/trunk/drivers/atm/lanai.c +++ b/trunk/drivers/atm/lanai.c @@ -1947,6 +1947,7 @@ static int __devinit lanai_pci_start(struct lanai_dev *lanai) { struct pci_dev *pci = lanai->pci; int result; + u16 w; if (pci_enable_device(pci) != 0) { printk(KERN_ERR DEV_LABEL "(itf %d): can't enable " @@ -1964,7 +1965,13 @@ static int __devinit lanai_pci_start(struct lanai_dev *lanai) "(itf %d): No suitable DMA available.\n", lanai->number); return -EBUSY; } - result = check_board_id_and_rev("PCI", pci->subsystem_device, NULL); + result = pci_read_config_word(pci, PCI_SUBSYSTEM_ID, &w); + if (result != PCIBIOS_SUCCESSFUL) { + printk(KERN_ERR DEV_LABEL "(itf %d): can't read " + "PCI_SUBSYSTEM_ID: %d\n", lanai->number, result); + return -EINVAL; + } + result = check_board_id_and_rev("PCI", w, NULL); if (result != 0) return result; /* Set latency timer to zero as per lanai docs */ diff --git a/trunk/drivers/base/memory.c b/trunk/drivers/base/memory.c index 45d7c8fc73bd..9f9b2359f718 100644 --- a/trunk/drivers/base/memory.c +++ b/trunk/drivers/base/memory.c @@ -30,6 +30,7 @@ static DEFINE_MUTEX(mem_sysfs_mutex); #define MEMORY_CLASS_NAME "memory" +#define MIN_MEMORY_BLOCK_SIZE (1 << SECTION_SIZE_BITS) static int sections_per_block; diff --git a/trunk/drivers/base/platform.c b/trunk/drivers/base/platform.c index 6040717b62bb..1c291af637b3 100644 --- a/trunk/drivers/base/platform.c +++ b/trunk/drivers/base/platform.c @@ -367,7 +367,7 @@ EXPORT_SYMBOL_GPL(platform_device_unregister); * * Returns &struct platform_device pointer on success, or ERR_PTR() on error. */ -struct platform_device *platform_device_register_resndata( +struct platform_device *__init_or_module platform_device_register_resndata( struct device *parent, const char *name, int id, const struct resource *res, unsigned int num, diff --git a/trunk/drivers/base/power/clock_ops.c b/trunk/drivers/base/power/clock_ops.c index ad367c4139b1..eaa8a854af03 100644 --- a/trunk/drivers/base/power/clock_ops.c +++ b/trunk/drivers/base/power/clock_ops.c @@ -387,7 +387,7 @@ static int pm_runtime_clk_notify(struct notifier_block *nb, clknb = container_of(nb, struct pm_clk_notifier_block, nb); switch (action) { - case BUS_NOTIFY_BIND_DRIVER: + case BUS_NOTIFY_ADD_DEVICE: if (clknb->con_ids[0]) { for (con_id = clknb->con_ids; *con_id; con_id++) enable_clock(dev, *con_id); @@ -395,7 +395,7 @@ static int pm_runtime_clk_notify(struct notifier_block *nb, enable_clock(dev, NULL); } break; - case BUS_NOTIFY_UNBOUND_DRIVER: + case BUS_NOTIFY_DEL_DEVICE: if (clknb->con_ids[0]) { for (con_id = clknb->con_ids; *con_id; con_id++) disable_clock(dev, *con_id); diff --git a/trunk/drivers/base/power/main.c b/trunk/drivers/base/power/main.c index 06f09bf89cb2..aa6320207745 100644 --- a/trunk/drivers/base/power/main.c +++ b/trunk/drivers/base/power/main.c @@ -57,8 +57,7 @@ static int async_error; */ void device_pm_init(struct device *dev) { - dev->power.is_prepared = false; - dev->power.is_suspended = false; + dev->power.in_suspend = false; init_completion(&dev->power.completion); complete_all(&dev->power.completion); dev->power.wakeup = NULL; @@ -92,7 +91,7 @@ void device_pm_add(struct device *dev) pr_debug("PM: Adding info for %s:%s\n", dev->bus ? dev->bus->name : "No Bus", dev_name(dev)); mutex_lock(&dpm_list_mtx); - if (dev->parent && dev->parent->power.is_prepared) + if (dev->parent && dev->parent->power.in_suspend) dev_warn(dev, "parent %s should not be sleeping\n", dev_name(dev->parent)); list_add_tail(&dev->power.entry, &dpm_list); @@ -512,14 +511,7 @@ static int device_resume(struct device *dev, pm_message_t state, bool async) dpm_wait(dev->parent, async); device_lock(dev); - /* - * This is a fib. But we'll allow new children to be added below - * a resumed device, even if the device hasn't been completed yet. - */ - dev->power.is_prepared = false; - - if (!dev->power.is_suspended) - goto Unlock; + dev->power.in_suspend = false; if (dev->pwr_domain) { pm_dev_dbg(dev, state, "power domain "); @@ -556,9 +548,6 @@ static int device_resume(struct device *dev, pm_message_t state, bool async) } End: - dev->power.is_suspended = false; - - Unlock: device_unlock(dev); complete_all(&dev->power.completion); @@ -681,7 +670,7 @@ void dpm_complete(pm_message_t state) struct device *dev = to_device(dpm_prepared_list.prev); get_device(dev); - dev->power.is_prepared = false; + dev->power.in_suspend = false; list_move(&dev->power.entry, &list); mutex_unlock(&dpm_list_mtx); @@ -846,11 +835,11 @@ static int __device_suspend(struct device *dev, pm_message_t state, bool async) device_lock(dev); if (async_error) - goto Unlock; + goto End; if (pm_wakeup_pending()) { async_error = -EBUSY; - goto Unlock; + goto End; } if (dev->pwr_domain) { @@ -888,9 +877,6 @@ static int __device_suspend(struct device *dev, pm_message_t state, bool async) } End: - dev->power.is_suspended = !error; - - Unlock: device_unlock(dev); complete_all(&dev->power.completion); @@ -1056,7 +1042,7 @@ int dpm_prepare(pm_message_t state) put_device(dev); break; } - dev->power.is_prepared = true; + dev->power.in_suspend = true; if (!list_empty(&dev->power.entry)) list_move_tail(&dev->power.entry, &dpm_prepared_list); put_device(dev); diff --git a/trunk/drivers/base/syscore.c b/trunk/drivers/base/syscore.c index e8d11b6630ee..c126db3cb7d1 100644 --- a/trunk/drivers/base/syscore.c +++ b/trunk/drivers/base/syscore.c @@ -9,7 +9,6 @@ #include #include #include -#include static LIST_HEAD(syscore_ops_list); static DEFINE_MUTEX(syscore_ops_lock); @@ -49,13 +48,6 @@ int syscore_suspend(void) struct syscore_ops *ops; int ret = 0; - pr_debug("Checking wakeup interrupts\n"); - - /* Return error code if there are any wakeup interrupts pending. */ - ret = check_wakeup_irqs(); - if (ret) - return ret; - WARN_ONCE(!irqs_disabled(), "Interrupts enabled before system core suspend.\n"); diff --git a/trunk/drivers/bcma/Kconfig b/trunk/drivers/bcma/Kconfig index ae0a02e1b808..83e9adf46441 100644 --- a/trunk/drivers/bcma/Kconfig +++ b/trunk/drivers/bcma/Kconfig @@ -27,12 +27,6 @@ config BCMA_HOST_PCI bool "Support for BCMA on PCI-host bus" depends on BCMA_HOST_PCI_POSSIBLE -config BCMA_DRIVER_PCI_HOSTMODE - bool "Driver for PCI core working in hostmode" - depends on BCMA && MIPS - help - PCI core hostmode operation (external PCI bus). - config BCMA_DEBUG bool "BCMA debugging" depends on BCMA diff --git a/trunk/drivers/bcma/Makefile b/trunk/drivers/bcma/Makefile index a2161cceafb9..cde0182bd1dc 100644 --- a/trunk/drivers/bcma/Makefile +++ b/trunk/drivers/bcma/Makefile @@ -1,7 +1,6 @@ bcma-y += main.o scan.o core.o sprom.o bcma-y += driver_chipcommon.o driver_chipcommon_pmu.o bcma-y += driver_pci.o -bcma-$(CONFIG_BCMA_DRIVER_PCI_HOSTMODE) += driver_pci_host.o bcma-$(CONFIG_BCMA_HOST_PCI) += host_pci.o obj-$(CONFIG_BCMA) += bcma.o diff --git a/trunk/drivers/bcma/bcma_private.h b/trunk/drivers/bcma/bcma_private.h index e02ff21835c9..12a75ab3dd23 100644 --- a/trunk/drivers/bcma/bcma_private.h +++ b/trunk/drivers/bcma/bcma_private.h @@ -13,8 +13,8 @@ struct bcma_bus; /* main.c */ -int bcma_bus_register(struct bcma_bus *bus); -void bcma_bus_unregister(struct bcma_bus *bus); +extern int bcma_bus_register(struct bcma_bus *bus); +extern void bcma_bus_unregister(struct bcma_bus *bus); /* scan.c */ int bcma_bus_scan(struct bcma_bus *bus); @@ -28,8 +28,4 @@ extern int __init bcma_host_pci_init(void); extern void __exit bcma_host_pci_exit(void); #endif /* CONFIG_BCMA_HOST_PCI */ -#ifdef CONFIG_BCMA_DRIVER_PCI_HOSTMODE -void bcma_core_pci_hostmode_init(struct bcma_drv_pci *pc); -#endif /* CONFIG_BCMA_DRIVER_PCI_HOSTMODE */ - #endif diff --git a/trunk/drivers/bcma/core.c b/trunk/drivers/bcma/core.c index 1ec7d4528dd0..ced379f7b371 100644 --- a/trunk/drivers/bcma/core.c +++ b/trunk/drivers/bcma/core.c @@ -19,7 +19,7 @@ bool bcma_core_is_enabled(struct bcma_device *core) } EXPORT_SYMBOL_GPL(bcma_core_is_enabled); -void bcma_core_disable(struct bcma_device *core, u32 flags) +static void bcma_core_disable(struct bcma_device *core, u32 flags) { if (bcma_aread32(core, BCMA_RESET_CTL) & BCMA_RESET_CTL_RESET) return; @@ -31,7 +31,6 @@ void bcma_core_disable(struct bcma_device *core, u32 flags) bcma_awrite32(core, BCMA_RESET_CTL, BCMA_RESET_CTL_RESET); udelay(1); } -EXPORT_SYMBOL_GPL(bcma_core_disable); int bcma_core_enable(struct bcma_device *core, u32 flags) { diff --git a/trunk/drivers/bcma/driver_chipcommon_pmu.c b/trunk/drivers/bcma/driver_chipcommon_pmu.c index dd5846bef029..f44177a644c7 100644 --- a/trunk/drivers/bcma/driver_chipcommon_pmu.c +++ b/trunk/drivers/bcma/driver_chipcommon_pmu.c @@ -53,7 +53,6 @@ static void bcma_pmu_resources_init(struct bcma_drv_cc *cc) max_msk = 0xFFFF; break; case 43224: - case 43225: break; default: pr_err("PMU resource config unknown for device 0x%04X\n", @@ -75,7 +74,6 @@ void bcma_pmu_swreg_init(struct bcma_drv_cc *cc) case 0x4313: case 0x4331: case 43224: - case 43225: break; default: pr_err("PMU switch/regulators init unknown for device " @@ -98,13 +96,11 @@ void bcma_pmu_workarounds(struct bcma_drv_cc *cc) if (bus->chipinfo.rev == 0) { pr_err("Workarounds for 43224 rev 0 not fully " "implemented\n"); - bcma_chipco_chipctl_maskset(cc, 0, ~0, 0x00F000F0); + bcma_chipco_chipctl_maskset(cc, 0, ~0, 0xF0); } else { bcma_chipco_chipctl_maskset(cc, 0, ~0, 0xF0); } break; - case 43225: - break; default: pr_err("Workarounds unknown for device 0x%04X\n", bus->chipinfo.id); diff --git a/trunk/drivers/bcma/driver_pci.c b/trunk/drivers/bcma/driver_pci.c index dc6f34ac96a0..789d68b4858b 100644 --- a/trunk/drivers/bcma/driver_pci.c +++ b/trunk/drivers/bcma/driver_pci.c @@ -157,45 +157,9 @@ static void bcma_pcicore_serdes_workaround(struct bcma_drv_pci *pc) * Init. **************************************************/ -static void bcma_core_pci_clientmode_init(struct bcma_drv_pci *pc) -{ - bcma_pcicore_serdes_workaround(pc); -} - -static bool bcma_core_pci_is_in_hostmode(struct bcma_drv_pci *pc) -{ - struct bcma_bus *bus = pc->core->bus; - u16 chipid_top; - - chipid_top = (bus->chipinfo.id & 0xFF00); - if (chipid_top != 0x4700 && - chipid_top != 0x5300) - return false; - - if (bus->sprom.boardflags_lo & SSB_PCICORE_BFL_NOPCI) - return false; - -#if 0 - /* TODO: on BCMA we use address from EROM instead of magic formula */ - u32 tmp; - return !mips_busprobe32(tmp, (bus->mmio + - (pc->core->core_index * BCMA_CORE_SIZE))); -#endif - - return true; -} - void bcma_core_pci_init(struct bcma_drv_pci *pc) { - if (bcma_core_pci_is_in_hostmode(pc)) { -#ifdef CONFIG_BCMA_DRIVER_PCI_HOSTMODE - bcma_core_pci_hostmode_init(pc); -#else - pr_err("Driver compiled without support for hostmode PCI\n"); -#endif /* CONFIG_BCMA_DRIVER_PCI_HOSTMODE */ - } else { - bcma_core_pci_clientmode_init(pc); - } + bcma_pcicore_serdes_workaround(pc); } int bcma_core_pci_irq_ctl(struct bcma_drv_pci *pc, struct bcma_device *core, @@ -220,4 +184,3 @@ int bcma_core_pci_irq_ctl(struct bcma_drv_pci *pc, struct bcma_device *core, out: return err; } -EXPORT_SYMBOL_GPL(bcma_core_pci_irq_ctl); diff --git a/trunk/drivers/bcma/driver_pci_host.c b/trunk/drivers/bcma/driver_pci_host.c deleted file mode 100644 index eb332b75ce83..000000000000 --- a/trunk/drivers/bcma/driver_pci_host.c +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Broadcom specific AMBA - * PCI Core in hostmode - * - * Licensed under the GNU/GPL. See COPYING for details. - */ - -#include "bcma_private.h" -#include - -void bcma_core_pci_hostmode_init(struct bcma_drv_pci *pc) -{ - pr_err("No support for PCI core in hostmode yet\n"); -} diff --git a/trunk/drivers/bcma/host_pci.c b/trunk/drivers/bcma/host_pci.c index ac4bc626c149..2a526bc3342f 100644 --- a/trunk/drivers/bcma/host_pci.c +++ b/trunk/drivers/bcma/host_pci.c @@ -227,7 +227,6 @@ static DEFINE_PCI_DEVICE_TABLE(bcma_pci_bridge_tbl) = { { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x0576) }, { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4331) }, { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4353) }, - { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4357) }, { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4727) }, { 0, }, }; diff --git a/trunk/drivers/bcma/main.c b/trunk/drivers/bcma/main.c index 08a14a3d667e..11e96dc6011a 100644 --- a/trunk/drivers/bcma/main.c +++ b/trunk/drivers/bcma/main.c @@ -7,7 +7,6 @@ #include "bcma_private.h" #include -#include MODULE_DESCRIPTION("Broadcom's specific AMBA driver"); MODULE_LICENSE("GPL"); @@ -161,11 +160,13 @@ int bcma_bus_register(struct bcma_bus *bus) return 0; } +EXPORT_SYMBOL_GPL(bcma_bus_register); void bcma_bus_unregister(struct bcma_bus *bus) { bcma_unregister_cores(bus); } +EXPORT_SYMBOL_GPL(bcma_bus_unregister); int __bcma_driver_register(struct bcma_driver *drv, struct module *owner) { diff --git a/trunk/drivers/block/drbd/drbd_actlog.c b/trunk/drivers/block/drbd/drbd_actlog.c index cf0e63dd97da..09ef9a878ef0 100644 --- a/trunk/drivers/block/drbd/drbd_actlog.c +++ b/trunk/drivers/block/drbd/drbd_actlog.c @@ -79,7 +79,7 @@ static int _drbd_md_sync_page_io(struct drbd_conf *mdev, md_io.error = 0; if ((rw & WRITE) && !test_bit(MD_NO_FUA, &mdev->flags)) - rw |= REQ_FUA | REQ_FLUSH; + rw |= REQ_FUA; rw |= REQ_SYNC; bio = bio_alloc(GFP_NOIO, 1); diff --git a/trunk/drivers/block/drbd/drbd_bitmap.c b/trunk/drivers/block/drbd/drbd_bitmap.c index 7b976296b564..f440a02dfdb1 100644 --- a/trunk/drivers/block/drbd/drbd_bitmap.c +++ b/trunk/drivers/block/drbd/drbd_bitmap.c @@ -112,6 +112,9 @@ struct drbd_bitmap { struct task_struct *bm_task; }; +static int __bm_change_bits_to(struct drbd_conf *mdev, const unsigned long s, + unsigned long e, int val, const enum km_type km); + #define bm_print_lock_info(m) __bm_print_lock_info(m, __func__) static void __bm_print_lock_info(struct drbd_conf *mdev, const char *func) { @@ -991,9 +994,6 @@ static void bm_page_io_async(struct bm_aio_ctx *ctx, int page_nr, int rw) __must bio_endio(bio, -EIO); } else { submit_bio(rw, bio); - /* this should not count as user activity and cause the - * resync to throttle -- see drbd_rs_should_slow_down(). */ - atomic_add(len >> 9, &mdev->rs_sect_ev); } } @@ -1256,7 +1256,7 @@ unsigned long _drbd_bm_find_next_zero(struct drbd_conf *mdev, unsigned long bm_f * expected to be called for only a few bits (e - s about BITS_PER_LONG). * Must hold bitmap lock already. */ static int __bm_change_bits_to(struct drbd_conf *mdev, const unsigned long s, - unsigned long e, int val) + unsigned long e, int val, const enum km_type km) { struct drbd_bitmap *b = mdev->bitmap; unsigned long *p_addr = NULL; @@ -1274,14 +1274,14 @@ static int __bm_change_bits_to(struct drbd_conf *mdev, const unsigned long s, unsigned int page_nr = bm_bit_to_page_idx(b, bitnr); if (page_nr != last_page_nr) { if (p_addr) - __bm_unmap(p_addr, KM_IRQ1); + __bm_unmap(p_addr, km); if (c < 0) bm_set_page_lazy_writeout(b->bm_pages[last_page_nr]); else if (c > 0) bm_set_page_need_writeout(b->bm_pages[last_page_nr]); changed_total += c; c = 0; - p_addr = __bm_map_pidx(b, page_nr, KM_IRQ1); + p_addr = __bm_map_pidx(b, page_nr, km); last_page_nr = page_nr; } if (val) @@ -1290,7 +1290,7 @@ static int __bm_change_bits_to(struct drbd_conf *mdev, const unsigned long s, c -= (0 != __test_and_clear_bit_le(bitnr & BITS_PER_PAGE_MASK, p_addr)); } if (p_addr) - __bm_unmap(p_addr, KM_IRQ1); + __bm_unmap(p_addr, km); if (c < 0) bm_set_page_lazy_writeout(b->bm_pages[last_page_nr]); else if (c > 0) @@ -1318,7 +1318,7 @@ static int bm_change_bits_to(struct drbd_conf *mdev, const unsigned long s, if ((val ? BM_DONT_SET : BM_DONT_CLEAR) & b->bm_flags) bm_print_lock_info(mdev); - c = __bm_change_bits_to(mdev, s, e, val); + c = __bm_change_bits_to(mdev, s, e, val, KM_IRQ1); spin_unlock_irqrestore(&b->bm_lock, flags); return c; @@ -1343,17 +1343,16 @@ static inline void bm_set_full_words_within_one_page(struct drbd_bitmap *b, { int i; int bits; - unsigned long *paddr = kmap_atomic(b->bm_pages[page_nr], KM_IRQ1); + unsigned long *paddr = kmap_atomic(b->bm_pages[page_nr], KM_USER0); for (i = first_word; i < last_word; i++) { bits = hweight_long(paddr[i]); paddr[i] = ~0UL; b->bm_set += BITS_PER_LONG - bits; } - kunmap_atomic(paddr, KM_IRQ1); + kunmap_atomic(paddr, KM_USER0); } -/* Same thing as drbd_bm_set_bits, - * but more efficient for a large bit range. +/* Same thing as drbd_bm_set_bits, but without taking the spin_lock_irqsave. * You must first drbd_bm_lock(). * Can be called to set the whole bitmap in one go. * Sets bits from s to e _inclusive_. */ @@ -1367,7 +1366,6 @@ void _drbd_bm_set_bits(struct drbd_conf *mdev, const unsigned long s, const unsi * Do not use memset, because we must account for changes, * so we need to loop over the words with hweight() anyways. */ - struct drbd_bitmap *b = mdev->bitmap; unsigned long sl = ALIGN(s,BITS_PER_LONG); unsigned long el = (e+1) & ~((unsigned long)BITS_PER_LONG-1); int first_page; @@ -1378,19 +1376,15 @@ void _drbd_bm_set_bits(struct drbd_conf *mdev, const unsigned long s, const unsi if (e - s <= 3*BITS_PER_LONG) { /* don't bother; el and sl may even be wrong. */ - spin_lock_irq(&b->bm_lock); - __bm_change_bits_to(mdev, s, e, 1); - spin_unlock_irq(&b->bm_lock); + __bm_change_bits_to(mdev, s, e, 1, KM_USER0); return; } /* difference is large enough that we can trust sl and el */ - spin_lock_irq(&b->bm_lock); - /* bits filling the current long */ if (sl) - __bm_change_bits_to(mdev, s, sl-1, 1); + __bm_change_bits_to(mdev, s, sl-1, 1, KM_USER0); first_page = sl >> (3 + PAGE_SHIFT); last_page = el >> (3 + PAGE_SHIFT); @@ -1403,10 +1397,8 @@ void _drbd_bm_set_bits(struct drbd_conf *mdev, const unsigned long s, const unsi /* first and full pages, unless first page == last page */ for (page_nr = first_page; page_nr < last_page; page_nr++) { bm_set_full_words_within_one_page(mdev->bitmap, page_nr, first_word, last_word); - spin_unlock_irq(&b->bm_lock); cond_resched(); first_word = 0; - spin_lock_irq(&b->bm_lock); } /* last page (respectively only page, for first page == last page) */ @@ -1419,8 +1411,7 @@ void _drbd_bm_set_bits(struct drbd_conf *mdev, const unsigned long s, const unsi * it would trigger an assert in __bm_change_bits_to() */ if (el <= e) - __bm_change_bits_to(mdev, el, e, 1); - spin_unlock_irq(&b->bm_lock); + __bm_change_bits_to(mdev, el, e, 1, KM_USER0); } /* returns bit state diff --git a/trunk/drivers/block/drbd/drbd_receiver.c b/trunk/drivers/block/drbd/drbd_receiver.c index 43beaca53179..25d32c5aa50a 100644 --- a/trunk/drivers/block/drbd/drbd_receiver.c +++ b/trunk/drivers/block/drbd/drbd_receiver.c @@ -4602,11 +4602,6 @@ int drbd_asender(struct drbd_thread *thi) dev_err(DEV, "meta connection shut down by peer.\n"); goto reconnect; } else if (rv == -EAGAIN) { - /* If the data socket received something meanwhile, - * that is good enough: peer is still alive. */ - if (time_after(mdev->last_received, - jiffies - mdev->meta.socket->sk->sk_rcvtimeo)) - continue; if (ping_timeout_active) { dev_err(DEV, "PingAck did not arrive in time.\n"); goto reconnect; @@ -4642,7 +4637,6 @@ int drbd_asender(struct drbd_thread *thi) goto reconnect; } if (received == expect) { - mdev->last_received = jiffies; D_ASSERT(cmd != NULL); if (!cmd->process(mdev, h)) goto reconnect; diff --git a/trunk/drivers/block/drbd/drbd_worker.c b/trunk/drivers/block/drbd/drbd_worker.c index 4d3e6f6213ba..4d76b06b6b20 100644 --- a/trunk/drivers/block/drbd/drbd_worker.c +++ b/trunk/drivers/block/drbd/drbd_worker.c @@ -536,7 +536,12 @@ static int w_make_resync_request(struct drbd_conf *mdev, return 1; } - max_bio_size = queue_max_hw_sectors(mdev->rq_queue) << 9; + /* starting with drbd 8.3.8, we can handle multi-bio EEs, + * if it should be necessary */ + max_bio_size = + mdev->agreed_pro_version < 94 ? queue_max_hw_sectors(mdev->rq_queue) << 9 : + mdev->agreed_pro_version < 95 ? DRBD_MAX_SIZE_H80_PACKET : DRBD_MAX_BIO_SIZE; + number = drbd_rs_number_requests(mdev); if (number == 0) goto requeue; diff --git a/trunk/drivers/char/agp/intel-agp.h b/trunk/drivers/char/agp/intel-agp.h index 5da67f165afa..999803ce10dc 100644 --- a/trunk/drivers/char/agp/intel-agp.h +++ b/trunk/drivers/char/agp/intel-agp.h @@ -90,10 +90,9 @@ #define G4x_GMCH_SIZE_MASK (0xf << 8) #define G4x_GMCH_SIZE_1M (0x1 << 8) #define G4x_GMCH_SIZE_2M (0x3 << 8) -#define G4x_GMCH_SIZE_VT_EN (0x8 << 8) -#define G4x_GMCH_SIZE_VT_1M (G4x_GMCH_SIZE_1M | G4x_GMCH_SIZE_VT_EN) -#define G4x_GMCH_SIZE_VT_1_5M ((0x2 << 8) | G4x_GMCH_SIZE_VT_EN) -#define G4x_GMCH_SIZE_VT_2M (G4x_GMCH_SIZE_2M | G4x_GMCH_SIZE_VT_EN) +#define G4x_GMCH_SIZE_VT_1M (0x9 << 8) +#define G4x_GMCH_SIZE_VT_1_5M (0xa << 8) +#define G4x_GMCH_SIZE_VT_2M (0xc << 8) #define GFX_FLSH_CNTL 0x2170 /* 915+ */ diff --git a/trunk/drivers/connector/connector.c b/trunk/drivers/connector/connector.c index dde6a0fad408..219d88a0eeae 100644 --- a/trunk/drivers/connector/connector.c +++ b/trunk/drivers/connector/connector.c @@ -139,7 +139,6 @@ static int cn_call_callback(struct sk_buff *skb) spin_unlock_bh(&dev->cbdev->queue_lock); if (cbq != NULL) { - err = 0; cbq->callback(msg, nsp); kfree_skb(skb); cn_queue_release_callback(cbq); diff --git a/trunk/drivers/cpufreq/acpi-cpufreq.c b/trunk/drivers/cpufreq/acpi-cpufreq.c index 596d5dd32f41..4e04e1274388 100644 --- a/trunk/drivers/cpufreq/acpi-cpufreq.c +++ b/trunk/drivers/cpufreq/acpi-cpufreq.c @@ -759,7 +759,7 @@ static void __exit acpi_cpufreq_exit(void) cpufreq_unregister_driver(&acpi_cpufreq_driver); - free_acpi_perf_data(); + free_percpu(acpi_perf_data); } module_param(acpi_pstate_strict, uint, 0644); diff --git a/trunk/drivers/crypto/caam/caamalg.c b/trunk/drivers/crypto/caam/caamalg.c index 676d957c22b0..d0e65d6ddc77 100644 --- a/trunk/drivers/crypto/caam/caamalg.c +++ b/trunk/drivers/crypto/caam/caamalg.c @@ -238,9 +238,9 @@ static int build_sh_desc_ipsec(struct caam_ctx *ctx) /* build shared descriptor for this session */ sh_desc = kmalloc(CAAM_CMD_SZ * DESC_AEAD_SHARED_TEXT_LEN + - (keys_fit_inline ? - ctx->split_key_pad_len + ctx->enckeylen : - CAAM_PTR_SZ * 2), GFP_DMA | GFP_KERNEL); + keys_fit_inline ? + ctx->split_key_pad_len + ctx->enckeylen : + CAAM_PTR_SZ * 2, GFP_DMA | GFP_KERNEL); if (!sh_desc) { dev_err(jrdev, "could not allocate shared descriptor\n"); return -ENOMEM; diff --git a/trunk/drivers/firewire/net.c b/trunk/drivers/firewire/net.c index eced1c25bf58..b9762d07198d 100644 --- a/trunk/drivers/firewire/net.c +++ b/trunk/drivers/firewire/net.c @@ -261,16 +261,16 @@ static int fwnet_header_rebuild(struct sk_buff *skb) } static int fwnet_header_cache(const struct neighbour *neigh, - struct hh_cache *hh, __be16 type) + struct hh_cache *hh) { struct net_device *net; struct fwnet_header *h; - if (type == cpu_to_be16(ETH_P_802_3)) + if (hh->hh_type == cpu_to_be16(ETH_P_802_3)) return -1; net = neigh->dev; h = (struct fwnet_header *)((u8 *)hh->hh_data + 16 - sizeof(*h)); - h->h_proto = type; + h->h_proto = hh->hh_type; memcpy(h->h_dest, neigh->ha, net->addr_len); hh->hh_len = FWNET_HLEN; diff --git a/trunk/drivers/firewire/ohci.c b/trunk/drivers/firewire/ohci.c index ebb897329c1e..438e6c831170 100644 --- a/trunk/drivers/firewire/ohci.c +++ b/trunk/drivers/firewire/ohci.c @@ -264,7 +264,6 @@ static char ohci_driver_name[] = KBUILD_MODNAME; #define PCI_DEVICE_ID_AGERE_FW643 0x5901 #define PCI_DEVICE_ID_JMICRON_JMB38X_FW 0x2380 #define PCI_DEVICE_ID_TI_TSB12LV22 0x8009 -#define PCI_VENDOR_ID_PINNACLE_SYSTEMS 0x11bd #define QUIRK_CYCLE_TIMER 1 #define QUIRK_RESET_PACKET 2 @@ -3191,11 +3190,6 @@ static int __devinit pci_probe(struct pci_dev *dev, int i, err; size_t size; - if (dev->vendor == PCI_VENDOR_ID_PINNACLE_SYSTEMS) { - dev_err(&dev->dev, "Pinnacle MovieBoard is not yet supported\n"); - return -ENOSYS; - } - ohci = kzalloc(sizeof(*ohci), GFP_KERNEL); if (ohci == NULL) { err = -ENOMEM; diff --git a/trunk/drivers/firmware/google/Kconfig b/trunk/drivers/firmware/google/Kconfig index 2f21b0bfe653..87096b6ca5c9 100644 --- a/trunk/drivers/firmware/google/Kconfig +++ b/trunk/drivers/firmware/google/Kconfig @@ -13,7 +13,6 @@ menu "Google Firmware Drivers" config GOOGLE_SMI tristate "SMI interface for Google platforms" depends on ACPI && DMI - select EFI select EFI_VARS help Say Y here if you want to enable SMI callbacks for Google diff --git a/trunk/drivers/gpio/langwell_gpio.c b/trunk/drivers/gpio/langwell_gpio.c index 644ba1255d3c..bd6571e0097a 100644 --- a/trunk/drivers/gpio/langwell_gpio.c +++ b/trunk/drivers/gpio/langwell_gpio.c @@ -223,7 +223,7 @@ static void lnw_irq_handler(unsigned irq, struct irq_desc *desc) gedr = gpio_reg(&lnw->chip, base, GEDR); pending = readl(gedr); while (pending) { - gpio = __ffs(pending); + gpio = __ffs(pending) - 1; mask = BIT(gpio); pending &= ~mask; /* Clear before handling so we can't lose an edge */ diff --git a/trunk/drivers/gpio/tps65910-gpio.c b/trunk/drivers/gpio/tps65910-gpio.c index 15097ca616d6..8d1ddfdd63eb 100644 --- a/trunk/drivers/gpio/tps65910-gpio.c +++ b/trunk/drivers/gpio/tps65910-gpio.c @@ -81,10 +81,8 @@ void tps65910_gpio_init(struct tps65910 *tps65910, int gpio_base) switch(tps65910_chip_id(tps65910)) { case TPS65910: tps65910->gpio.ngpio = 6; - break; case TPS65911: tps65910->gpio.ngpio = 9; - break; default: return; } diff --git a/trunk/drivers/gpu/drm/drm_crtc.c b/trunk/drivers/gpu/drm/drm_crtc.c index 82db18506662..21058e6ad2b8 100644 --- a/trunk/drivers/gpu/drm/drm_crtc.c +++ b/trunk/drivers/gpu/drm/drm_crtc.c @@ -886,6 +886,9 @@ int drm_mode_group_init(struct drm_device *dev, struct drm_mode_group *group) total_objects += dev->mode_config.num_connector; total_objects += dev->mode_config.num_encoder; + if (total_objects == 0) + return -EINVAL; + group->id_list = kzalloc(total_objects * sizeof(uint32_t), GFP_KERNEL); if (!group->id_list) return -ENOMEM; diff --git a/trunk/drivers/gpu/drm/drm_gem.c b/trunk/drivers/gpu/drm/drm_gem.c index 4012fe423460..74e4ff578017 100644 --- a/trunk/drivers/gpu/drm/drm_gem.c +++ b/trunk/drivers/gpu/drm/drm_gem.c @@ -34,7 +34,6 @@ #include #include #include -#include #include "drmP.h" /** @file drm_gem.c diff --git a/trunk/drivers/gpu/drm/i915/i915_debugfs.c b/trunk/drivers/gpu/drm/i915/i915_debugfs.c index 0a893f7400fa..4d46441cbe2d 100644 --- a/trunk/drivers/gpu/drm/i915/i915_debugfs.c +++ b/trunk/drivers/gpu/drm/i915/i915_debugfs.c @@ -1207,17 +1207,13 @@ static int i915_context_status(struct seq_file *m, void *unused) if (ret) return ret; - if (dev_priv->pwrctx) { - seq_printf(m, "power context "); - describe_obj(m, dev_priv->pwrctx); - seq_printf(m, "\n"); - } + seq_printf(m, "power context "); + describe_obj(m, dev_priv->pwrctx); + seq_printf(m, "\n"); - if (dev_priv->renderctx) { - seq_printf(m, "render context "); - describe_obj(m, dev_priv->renderctx); - seq_printf(m, "\n"); - } + seq_printf(m, "render context "); + describe_obj(m, dev_priv->renderctx); + seq_printf(m, "\n"); mutex_unlock(&dev->mode_config.mutex); diff --git a/trunk/drivers/gpu/drm/i915/i915_dma.c b/trunk/drivers/gpu/drm/i915/i915_dma.c index 296fbd66f0e1..0239e9974bf2 100644 --- a/trunk/drivers/gpu/drm/i915/i915_dma.c +++ b/trunk/drivers/gpu/drm/i915/i915_dma.c @@ -1266,6 +1266,30 @@ static int i915_load_modeset_init(struct drm_device *dev) intel_modeset_gem_init(dev); + if (IS_IVYBRIDGE(dev)) { + /* Share pre & uninstall handlers with ILK/SNB */ + dev->driver->irq_handler = ivybridge_irq_handler; + dev->driver->irq_preinstall = ironlake_irq_preinstall; + dev->driver->irq_postinstall = ivybridge_irq_postinstall; + dev->driver->irq_uninstall = ironlake_irq_uninstall; + dev->driver->enable_vblank = ivybridge_enable_vblank; + dev->driver->disable_vblank = ivybridge_disable_vblank; + } else if (HAS_PCH_SPLIT(dev)) { + dev->driver->irq_handler = ironlake_irq_handler; + dev->driver->irq_preinstall = ironlake_irq_preinstall; + dev->driver->irq_postinstall = ironlake_irq_postinstall; + dev->driver->irq_uninstall = ironlake_irq_uninstall; + dev->driver->enable_vblank = ironlake_enable_vblank; + dev->driver->disable_vblank = ironlake_disable_vblank; + } else { + dev->driver->irq_preinstall = i915_driver_irq_preinstall; + dev->driver->irq_postinstall = i915_driver_irq_postinstall; + dev->driver->irq_uninstall = i915_driver_irq_uninstall; + dev->driver->irq_handler = i915_driver_irq_handler; + dev->driver->enable_vblank = i915_enable_vblank; + dev->driver->disable_vblank = i915_disable_vblank; + } + ret = drm_irq_install(dev); if (ret) goto cleanup_gem; @@ -1943,7 +1967,7 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags) if (!dev_priv->mm.gtt) { DRM_ERROR("Failed to initialize GTT\n"); ret = -ENODEV; - goto out_rmmap; + goto out_iomapfree; } agp_size = dev_priv->mm.gtt->gtt_mappable_entries << PAGE_SHIFT; @@ -1987,13 +2011,18 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags) if (dev_priv->wq == NULL) { DRM_ERROR("Failed to create our workqueue.\n"); ret = -ENOMEM; - goto out_mtrrfree; + goto out_iomapfree; } /* enable GEM by default */ dev_priv->has_gem = 1; - intel_irq_init(dev); + dev->driver->get_vblank_counter = i915_get_vblank_counter; + dev->max_vblank_count = 0xffffff; /* only 24 bits of frame count */ + if (IS_G4X(dev) || IS_GEN5(dev) || IS_GEN6(dev) || IS_IVYBRIDGE(dev)) { + dev->max_vblank_count = 0xffffffff; /* full 32 bit counter */ + dev->driver->get_vblank_counter = gm45_get_vblank_counter; + } /* Try to make sure MCHBAR is enabled before poking at it */ intel_setup_mchbar(dev); @@ -2074,21 +2103,13 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags) return 0; out_gem_unload: - if (dev_priv->mm.inactive_shrinker.shrink) - unregister_shrinker(&dev_priv->mm.inactive_shrinker); - if (dev->pdev->msi_enabled) pci_disable_msi(dev->pdev); intel_teardown_gmbus(dev); intel_teardown_mchbar(dev); destroy_workqueue(dev_priv->wq); -out_mtrrfree: - if (dev_priv->mm.gtt_mtrr >= 0) { - mtrr_del(dev_priv->mm.gtt_mtrr, dev->agp->base, - dev->agp->agp_info.aper_size * 1024 * 1024); - dev_priv->mm.gtt_mtrr = -1; - } +out_iomapfree: io_mapping_free(dev_priv->mm.gtt_mapping); out_rmmap: pci_iounmap(dev->pdev, dev_priv->regs); @@ -2161,8 +2182,9 @@ int i915_driver_unload(struct drm_device *dev) /* Flush any outstanding unpin_work. */ flush_workqueue(dev_priv->wq); - mutex_lock(&dev->struct_mutex); i915_gem_free_all_phys_object(dev); + + mutex_lock(&dev->struct_mutex); i915_gem_cleanup_ringbuffer(dev); mutex_unlock(&dev->struct_mutex); if (I915_HAS_FBC(dev) && i915_powersave) diff --git a/trunk/drivers/gpu/drm/i915/i915_drv.c b/trunk/drivers/gpu/drm/i915/i915_drv.c index eb91e2dd7914..0defd4270594 100644 --- a/trunk/drivers/gpu/drm/i915/i915_drv.c +++ b/trunk/drivers/gpu/drm/i915/i915_drv.c @@ -52,7 +52,7 @@ module_param_named(powersave, i915_powersave, int, 0600); unsigned int i915_semaphores = 0; module_param_named(semaphores, i915_semaphores, int, 0600); -unsigned int i915_enable_rc6 = 0; +unsigned int i915_enable_rc6 = 1; module_param_named(i915_enable_rc6, i915_enable_rc6, int, 0600); unsigned int i915_enable_fbc = 0; @@ -577,12 +577,8 @@ int i915_reset(struct drm_device *dev, u8 flags) if (get_seconds() - dev_priv->last_gpu_reset < 5) { DRM_ERROR("GPU hanging too fast, declaring wedged!\n"); } else switch (INTEL_INFO(dev)->gen) { - case 7: case 6: ret = gen6_do_reset(dev, flags); - /* If reset with a user forcewake, try to restore */ - if (atomic_read(&dev_priv->forcewake_count)) - __gen6_gt_force_wake_get(dev_priv); break; case 5: ret = ironlake_do_reset(dev, flags); @@ -766,6 +762,14 @@ static struct drm_driver driver = { .resume = i915_resume, .device_is_agp = i915_driver_device_is_agp, + .enable_vblank = i915_enable_vblank, + .disable_vblank = i915_disable_vblank, + .get_vblank_timestamp = i915_get_vblank_timestamp, + .get_scanout_position = i915_get_crtc_scanoutpos, + .irq_preinstall = i915_driver_irq_preinstall, + .irq_postinstall = i915_driver_irq_postinstall, + .irq_uninstall = i915_driver_irq_uninstall, + .irq_handler = i915_driver_irq_handler, .reclaim_buffers = drm_core_reclaim_buffers, .master_create = i915_master_create, .master_destroy = i915_master_destroy, diff --git a/trunk/drivers/gpu/drm/i915/i915_drv.h b/trunk/drivers/gpu/drm/i915/i915_drv.h index f245c588ae95..f63ee162f124 100644 --- a/trunk/drivers/gpu/drm/i915/i915_drv.h +++ b/trunk/drivers/gpu/drm/i915/i915_drv.h @@ -211,9 +211,6 @@ struct drm_i915_display_funcs { void (*fdi_link_train)(struct drm_crtc *crtc); void (*init_clock_gating)(struct drm_device *dev); void (*init_pch_clock_gating)(struct drm_device *dev); - int (*queue_flip)(struct drm_device *dev, struct drm_crtc *crtc, - struct drm_framebuffer *fb, - struct drm_i915_gem_object *obj); /* clock updates for mode set */ /* cursor updates */ /* render clock increase/decrease */ @@ -997,6 +994,8 @@ extern unsigned int i915_enable_fbc; extern int i915_suspend(struct drm_device *dev, pm_message_t state); extern int i915_resume(struct drm_device *dev); +extern void i915_save_display(struct drm_device *dev); +extern void i915_restore_display(struct drm_device *dev); extern int i915_master_create(struct drm_device *dev, struct drm_master *master); extern void i915_master_destroy(struct drm_device *dev, struct drm_master *master); @@ -1031,12 +1030,33 @@ extern int i915_irq_emit(struct drm_device *dev, void *data, extern int i915_irq_wait(struct drm_device *dev, void *data, struct drm_file *file_priv); -extern void intel_irq_init(struct drm_device *dev); +extern irqreturn_t i915_driver_irq_handler(DRM_IRQ_ARGS); +extern void i915_driver_irq_preinstall(struct drm_device * dev); +extern int i915_driver_irq_postinstall(struct drm_device *dev); +extern void i915_driver_irq_uninstall(struct drm_device * dev); + +extern irqreturn_t ironlake_irq_handler(DRM_IRQ_ARGS); +extern void ironlake_irq_preinstall(struct drm_device *dev); +extern int ironlake_irq_postinstall(struct drm_device *dev); +extern void ironlake_irq_uninstall(struct drm_device *dev); + +extern irqreturn_t ivybridge_irq_handler(DRM_IRQ_ARGS); +extern void ivybridge_irq_preinstall(struct drm_device *dev); +extern int ivybridge_irq_postinstall(struct drm_device *dev); +extern void ivybridge_irq_uninstall(struct drm_device *dev); extern int i915_vblank_pipe_set(struct drm_device *dev, void *data, struct drm_file *file_priv); extern int i915_vblank_pipe_get(struct drm_device *dev, void *data, struct drm_file *file_priv); +extern int i915_enable_vblank(struct drm_device *dev, int crtc); +extern void i915_disable_vblank(struct drm_device *dev, int crtc); +extern int ironlake_enable_vblank(struct drm_device *dev, int crtc); +extern void ironlake_disable_vblank(struct drm_device *dev, int crtc); +extern int ivybridge_enable_vblank(struct drm_device *dev, int crtc); +extern void ivybridge_disable_vblank(struct drm_device *dev, int crtc); +extern u32 i915_get_vblank_counter(struct drm_device *dev, int crtc); +extern u32 gm45_get_vblank_counter(struct drm_device *dev, int crtc); extern int i915_vblank_swap(struct drm_device *dev, void *data, struct drm_file *file_priv); @@ -1047,6 +1067,13 @@ void i915_disable_pipestat(drm_i915_private_t *dev_priv, int pipe, u32 mask); void intel_enable_asle (struct drm_device *dev); +int i915_get_vblank_timestamp(struct drm_device *dev, int crtc, + int *max_error, + struct timeval *vblank_time, + unsigned flags); + +int i915_get_crtc_scanoutpos(struct drm_device *dev, int pipe, + int *vpos, int *hpos); #ifdef CONFIG_DEBUG_FS extern void i915_destroy_error_state(struct drm_device *dev); diff --git a/trunk/drivers/gpu/drm/i915/i915_gem.c b/trunk/drivers/gpu/drm/i915/i915_gem.c index 5c0d1247f453..94c84d744100 100644 --- a/trunk/drivers/gpu/drm/i915/i915_gem.c +++ b/trunk/drivers/gpu/drm/i915/i915_gem.c @@ -31,7 +31,6 @@ #include "i915_drv.h" #include "i915_trace.h" #include "intel_drv.h" -#include #include #include #include @@ -360,7 +359,8 @@ i915_gem_shmem_pread_fast(struct drm_device *dev, if ((page_offset + remain) > PAGE_SIZE) page_length = PAGE_SIZE - page_offset; - page = shmem_read_mapping_page(mapping, offset >> PAGE_SHIFT); + page = read_cache_page_gfp(mapping, offset >> PAGE_SHIFT, + GFP_HIGHUSER | __GFP_RECLAIMABLE); if (IS_ERR(page)) return PTR_ERR(page); @@ -463,7 +463,8 @@ i915_gem_shmem_pread_slow(struct drm_device *dev, if ((data_page_offset + page_length) > PAGE_SIZE) page_length = PAGE_SIZE - data_page_offset; - page = shmem_read_mapping_page(mapping, offset >> PAGE_SHIFT); + page = read_cache_page_gfp(mapping, offset >> PAGE_SHIFT, + GFP_HIGHUSER | __GFP_RECLAIMABLE); if (IS_ERR(page)) { ret = PTR_ERR(page); goto out; @@ -796,7 +797,8 @@ i915_gem_shmem_pwrite_fast(struct drm_device *dev, if ((page_offset + remain) > PAGE_SIZE) page_length = PAGE_SIZE - page_offset; - page = shmem_read_mapping_page(mapping, offset >> PAGE_SHIFT); + page = read_cache_page_gfp(mapping, offset >> PAGE_SHIFT, + GFP_HIGHUSER | __GFP_RECLAIMABLE); if (IS_ERR(page)) return PTR_ERR(page); @@ -905,7 +907,8 @@ i915_gem_shmem_pwrite_slow(struct drm_device *dev, if ((data_page_offset + page_length) > PAGE_SIZE) page_length = PAGE_SIZE - data_page_offset; - page = shmem_read_mapping_page(mapping, offset >> PAGE_SHIFT); + page = read_cache_page_gfp(mapping, offset >> PAGE_SHIFT, + GFP_HIGHUSER | __GFP_RECLAIMABLE); if (IS_ERR(page)) { ret = PTR_ERR(page); goto out; @@ -1216,12 +1219,12 @@ int i915_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf) ret = i915_gem_object_bind_to_gtt(obj, 0, true); if (ret) goto unlock; - - ret = i915_gem_object_set_to_gtt_domain(obj, write); - if (ret) - goto unlock; } + ret = i915_gem_object_set_to_gtt_domain(obj, write); + if (ret) + goto unlock; + if (obj->tiling_mode == I915_TILING_NONE) ret = i915_gem_object_put_fence(obj); else @@ -1555,10 +1558,12 @@ i915_gem_object_get_pages_gtt(struct drm_i915_gem_object *obj, inode = obj->base.filp->f_path.dentry->d_inode; mapping = inode->i_mapping; - gfpmask |= mapping_gfp_mask(mapping); - for (i = 0; i < page_count; i++) { - page = shmem_read_mapping_page_gfp(mapping, i, gfpmask); + page = read_cache_page_gfp(mapping, i, + GFP_HIGHUSER | + __GFP_COLD | + __GFP_RECLAIMABLE | + gfpmask); if (IS_ERR(page)) goto err_pages; @@ -1696,10 +1701,13 @@ i915_gem_object_truncate(struct drm_i915_gem_object *obj) /* Our goal here is to return as much of the memory as * is possible back to the system as we are called from OOM. * To do this we must instruct the shmfs to drop all of its - * backing pages, *now*. + * backing pages, *now*. Here we mirror the actions taken + * when by shmem_delete_inode() to release the backing store. */ inode = obj->base.filp->f_path.dentry->d_inode; - shmem_truncate_range(inode, 0, (loff_t)-1); + truncate_inode_pages(inode->i_mapping, 0); + if (inode->i_op->truncate_range) + inode->i_op->truncate_range(inode, 0, (loff_t)-1); obj->madv = __I915_MADV_PURGED; } @@ -2072,8 +2080,8 @@ i915_wait_request(struct intel_ring_buffer *ring, if (!ier) { DRM_ERROR("something (likely vbetool) disabled " "interrupts, re-enabling\n"); - ring->dev->driver->irq_preinstall(ring->dev); - ring->dev->driver->irq_postinstall(ring->dev); + i915_driver_irq_preinstall(ring->dev); + i915_driver_irq_postinstall(ring->dev); } trace_i915_gem_request_wait_begin(ring, seqno); @@ -2918,6 +2926,8 @@ i915_gem_object_flush_gtt_write_domain(struct drm_i915_gem_object *obj) */ wmb(); + i915_gem_release_mmap(obj); + old_write_domain = obj->base.write_domain; obj->base.write_domain = 0; @@ -3557,7 +3567,6 @@ struct drm_i915_gem_object *i915_gem_alloc_object(struct drm_device *dev, { struct drm_i915_private *dev_priv = dev->dev_private; struct drm_i915_gem_object *obj; - struct address_space *mapping; obj = kzalloc(sizeof(*obj), GFP_KERNEL); if (obj == NULL) @@ -3568,9 +3577,6 @@ struct drm_i915_gem_object *i915_gem_alloc_object(struct drm_device *dev, return NULL; } - mapping = obj->base.filp->f_path.dentry->d_inode->i_mapping; - mapping_set_gfp_mask(mapping, GFP_HIGHUSER | __GFP_RECLAIMABLE); - i915_gem_info_add_obj(dev_priv, size); obj->base.write_domain = I915_GEM_DOMAIN_CPU; @@ -3946,7 +3952,8 @@ void i915_gem_detach_phys_object(struct drm_device *dev, page_count = obj->base.size / PAGE_SIZE; for (i = 0; i < page_count; i++) { - struct page *page = shmem_read_mapping_page(mapping, i); + struct page *page = read_cache_page_gfp(mapping, i, + GFP_HIGHUSER | __GFP_RECLAIMABLE); if (!IS_ERR(page)) { char *dst = kmap_atomic(page); memcpy(dst, vaddr + i*PAGE_SIZE, PAGE_SIZE); @@ -4007,7 +4014,8 @@ i915_gem_attach_phys_object(struct drm_device *dev, struct page *page; char *dst, *src; - page = shmem_read_mapping_page(mapping, i); + page = read_cache_page_gfp(mapping, i, + GFP_HIGHUSER | __GFP_RECLAIMABLE); if (IS_ERR(page)) return PTR_ERR(page); diff --git a/trunk/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/trunk/drivers/gpu/drm/i915/i915_gem_execbuffer.c index 4934cf84c320..20a4cc5b818f 100644 --- a/trunk/drivers/gpu/drm/i915/i915_gem_execbuffer.c +++ b/trunk/drivers/gpu/drm/i915/i915_gem_execbuffer.c @@ -187,6 +187,10 @@ i915_gem_object_set_to_gpu_domain(struct drm_i915_gem_object *obj, if ((flush_domains | invalidate_domains) & I915_GEM_DOMAIN_CPU) i915_gem_clflush_object(obj); + /* blow away mappings if mapped through GTT */ + if ((flush_domains | invalidate_domains) & I915_GEM_DOMAIN_GTT) + i915_gem_release_mmap(obj); + if (obj->base.pending_write_domain) cd->flips |= atomic_read(&obj->pending_flip); diff --git a/trunk/drivers/gpu/drm/i915/i915_irq.c b/trunk/drivers/gpu/drm/i915/i915_irq.c index 3b03f85ea627..9e34a1abeb61 100644 --- a/trunk/drivers/gpu/drm/i915/i915_irq.c +++ b/trunk/drivers/gpu/drm/i915/i915_irq.c @@ -152,7 +152,7 @@ i915_pipe_enabled(struct drm_device *dev, int pipe) /* Called from drm generic code, passed a 'crtc', which * we use as a pipe index */ -static u32 i915_get_vblank_counter(struct drm_device *dev, int pipe) +u32 i915_get_vblank_counter(struct drm_device *dev, int pipe) { drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; unsigned long high_frame; @@ -184,7 +184,7 @@ static u32 i915_get_vblank_counter(struct drm_device *dev, int pipe) return (high1 << 8) | low; } -static u32 gm45_get_vblank_counter(struct drm_device *dev, int pipe) +u32 gm45_get_vblank_counter(struct drm_device *dev, int pipe) { drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; int reg = PIPE_FRMCOUNT_GM45(pipe); @@ -198,7 +198,7 @@ static u32 gm45_get_vblank_counter(struct drm_device *dev, int pipe) return I915_READ(reg); } -static int i915_get_crtc_scanoutpos(struct drm_device *dev, int pipe, +int i915_get_crtc_scanoutpos(struct drm_device *dev, int pipe, int *vpos, int *hpos) { drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; @@ -264,7 +264,7 @@ static int i915_get_crtc_scanoutpos(struct drm_device *dev, int pipe, return ret; } -static int i915_get_vblank_timestamp(struct drm_device *dev, int pipe, +int i915_get_vblank_timestamp(struct drm_device *dev, int pipe, int *max_error, struct timeval *vblank_time, unsigned flags) @@ -462,7 +462,7 @@ static void pch_irq_handler(struct drm_device *dev) DRM_DEBUG_DRIVER("PCH transcoder A underrun interrupt\n"); } -static irqreturn_t ivybridge_irq_handler(DRM_IRQ_ARGS) +irqreturn_t ivybridge_irq_handler(DRM_IRQ_ARGS) { struct drm_device *dev = (struct drm_device *) arg; drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; @@ -550,7 +550,7 @@ static irqreturn_t ivybridge_irq_handler(DRM_IRQ_ARGS) return ret; } -static irqreturn_t ironlake_irq_handler(DRM_IRQ_ARGS) +irqreturn_t ironlake_irq_handler(DRM_IRQ_ARGS) { struct drm_device *dev = (struct drm_device *) arg; drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; @@ -1209,7 +1209,7 @@ static void i915_pageflip_stall_check(struct drm_device *dev, int pipe) } } -static irqreturn_t i915_driver_irq_handler(DRM_IRQ_ARGS) +irqreturn_t i915_driver_irq_handler(DRM_IRQ_ARGS) { struct drm_device *dev = (struct drm_device *) arg; drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; @@ -1454,7 +1454,7 @@ int i915_irq_wait(struct drm_device *dev, void *data, /* Called from drm generic code, passed 'crtc' which * we use as a pipe index */ -static int i915_enable_vblank(struct drm_device *dev, int pipe) +int i915_enable_vblank(struct drm_device *dev, int pipe) { drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; unsigned long irqflags; @@ -1478,7 +1478,7 @@ static int i915_enable_vblank(struct drm_device *dev, int pipe) return 0; } -static int ironlake_enable_vblank(struct drm_device *dev, int pipe) +int ironlake_enable_vblank(struct drm_device *dev, int pipe) { drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; unsigned long irqflags; @@ -1494,7 +1494,7 @@ static int ironlake_enable_vblank(struct drm_device *dev, int pipe) return 0; } -static int ivybridge_enable_vblank(struct drm_device *dev, int pipe) +int ivybridge_enable_vblank(struct drm_device *dev, int pipe) { drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; unsigned long irqflags; @@ -1513,7 +1513,7 @@ static int ivybridge_enable_vblank(struct drm_device *dev, int pipe) /* Called from drm generic code, passed 'crtc' which * we use as a pipe index */ -static void i915_disable_vblank(struct drm_device *dev, int pipe) +void i915_disable_vblank(struct drm_device *dev, int pipe) { drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; unsigned long irqflags; @@ -1529,7 +1529,7 @@ static void i915_disable_vblank(struct drm_device *dev, int pipe) spin_unlock_irqrestore(&dev_priv->irq_lock, irqflags); } -static void ironlake_disable_vblank(struct drm_device *dev, int pipe) +void ironlake_disable_vblank(struct drm_device *dev, int pipe) { drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; unsigned long irqflags; @@ -1540,7 +1540,7 @@ static void ironlake_disable_vblank(struct drm_device *dev, int pipe) spin_unlock_irqrestore(&dev_priv->irq_lock, irqflags); } -static void ivybridge_disable_vblank(struct drm_device *dev, int pipe) +void ivybridge_disable_vblank(struct drm_device *dev, int pipe) { drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; unsigned long irqflags; @@ -1728,7 +1728,7 @@ void i915_hangcheck_elapsed(unsigned long data) /* drm_dma.h hooks */ -static void ironlake_irq_preinstall(struct drm_device *dev) +void ironlake_irq_preinstall(struct drm_device *dev) { drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; @@ -1740,7 +1740,7 @@ static void ironlake_irq_preinstall(struct drm_device *dev) INIT_WORK(&dev_priv->rps_work, gen6_pm_rps_work); I915_WRITE(HWSTAM, 0xeffe); - if (IS_GEN6(dev) || IS_GEN7(dev)) { + if (IS_GEN6(dev)) { /* Workaround stalls observed on Sandy Bridge GPUs by * making the blitter command streamer generate a * write to the Hardware Status Page for @@ -1749,7 +1749,6 @@ static void ironlake_irq_preinstall(struct drm_device *dev) * happens. */ I915_WRITE(GEN6_BLITTER_HWSTAM, ~GEN6_BLITTER_USER_INTERRUPT); - I915_WRITE(GEN6_BSD_HWSTAM, ~GEN6_BSD_USER_INTERRUPT); } /* XXX hotplug from PCH */ @@ -1769,7 +1768,7 @@ static void ironlake_irq_preinstall(struct drm_device *dev) POSTING_READ(SDEIER); } -static int ironlake_irq_postinstall(struct drm_device *dev) +int ironlake_irq_postinstall(struct drm_device *dev) { drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; /* enable kind of interrupts always enabled */ @@ -1841,7 +1840,7 @@ static int ironlake_irq_postinstall(struct drm_device *dev) return 0; } -static int ivybridge_irq_postinstall(struct drm_device *dev) +int ivybridge_irq_postinstall(struct drm_device *dev) { drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; /* enable kind of interrupts always enabled */ @@ -1891,7 +1890,7 @@ static int ivybridge_irq_postinstall(struct drm_device *dev) return 0; } -static void i915_driver_irq_preinstall(struct drm_device * dev) +void i915_driver_irq_preinstall(struct drm_device * dev) { drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; int pipe; @@ -1918,7 +1917,7 @@ static void i915_driver_irq_preinstall(struct drm_device * dev) * Must be called after intel_modeset_init or hotplug interrupts won't be * enabled correctly. */ -static int i915_driver_irq_postinstall(struct drm_device *dev) +int i915_driver_irq_postinstall(struct drm_device *dev) { drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; u32 enable_mask = I915_INTERRUPT_ENABLE_FIX | I915_INTERRUPT_ENABLE_VAR; @@ -1994,7 +1993,7 @@ static int i915_driver_irq_postinstall(struct drm_device *dev) return 0; } -static void ironlake_irq_uninstall(struct drm_device *dev) +void ironlake_irq_uninstall(struct drm_device *dev) { drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; @@ -2014,7 +2013,7 @@ static void ironlake_irq_uninstall(struct drm_device *dev) I915_WRITE(GTIIR, I915_READ(GTIIR)); } -static void i915_driver_irq_uninstall(struct drm_device * dev) +void i915_driver_irq_uninstall(struct drm_device * dev) { drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; int pipe; @@ -2040,41 +2039,3 @@ static void i915_driver_irq_uninstall(struct drm_device * dev) I915_READ(PIPESTAT(pipe)) & 0x8000ffff); I915_WRITE(IIR, I915_READ(IIR)); } - -void intel_irq_init(struct drm_device *dev) -{ - dev->driver->get_vblank_counter = i915_get_vblank_counter; - dev->max_vblank_count = 0xffffff; /* only 24 bits of frame count */ - if (IS_G4X(dev) || IS_GEN5(dev) || IS_GEN6(dev) || IS_IVYBRIDGE(dev)) { - dev->max_vblank_count = 0xffffffff; /* full 32 bit counter */ - dev->driver->get_vblank_counter = gm45_get_vblank_counter; - } - - - dev->driver->get_vblank_timestamp = i915_get_vblank_timestamp; - dev->driver->get_scanout_position = i915_get_crtc_scanoutpos; - - if (IS_IVYBRIDGE(dev)) { - /* Share pre & uninstall handlers with ILK/SNB */ - dev->driver->irq_handler = ivybridge_irq_handler; - dev->driver->irq_preinstall = ironlake_irq_preinstall; - dev->driver->irq_postinstall = ivybridge_irq_postinstall; - dev->driver->irq_uninstall = ironlake_irq_uninstall; - dev->driver->enable_vblank = ivybridge_enable_vblank; - dev->driver->disable_vblank = ivybridge_disable_vblank; - } else if (HAS_PCH_SPLIT(dev)) { - dev->driver->irq_handler = ironlake_irq_handler; - dev->driver->irq_preinstall = ironlake_irq_preinstall; - dev->driver->irq_postinstall = ironlake_irq_postinstall; - dev->driver->irq_uninstall = ironlake_irq_uninstall; - dev->driver->enable_vblank = ironlake_enable_vblank; - dev->driver->disable_vblank = ironlake_disable_vblank; - } else { - dev->driver->irq_preinstall = i915_driver_irq_preinstall; - dev->driver->irq_postinstall = i915_driver_irq_postinstall; - dev->driver->irq_uninstall = i915_driver_irq_uninstall; - dev->driver->irq_handler = i915_driver_irq_handler; - dev->driver->enable_vblank = i915_enable_vblank; - dev->driver->disable_vblank = i915_disable_vblank; - } -} diff --git a/trunk/drivers/gpu/drm/i915/i915_reg.h b/trunk/drivers/gpu/drm/i915/i915_reg.h index 5d5def756c9e..2f967af8e62e 100644 --- a/trunk/drivers/gpu/drm/i915/i915_reg.h +++ b/trunk/drivers/gpu/drm/i915/i915_reg.h @@ -531,7 +531,6 @@ #define GEN6_BSD_SLEEP_PSMI_CONTROL_RC_ILDL_MESSAGE_ENABLE 0 #define GEN6_BSD_SLEEP_PSMI_CONTROL_IDLE_INDICATOR (1 << 3) -#define GEN6_BSD_HWSTAM 0x12098 #define GEN6_BSD_IMR 0x120a8 #define GEN6_BSD_USER_INTERRUPT (1 << 12) diff --git a/trunk/drivers/gpu/drm/i915/i915_suspend.c b/trunk/drivers/gpu/drm/i915/i915_suspend.c index 5257cfc34c35..60a94d2b5264 100644 --- a/trunk/drivers/gpu/drm/i915/i915_suspend.c +++ b/trunk/drivers/gpu/drm/i915/i915_suspend.c @@ -597,7 +597,7 @@ static void i915_restore_modeset_reg(struct drm_device *dev) return; } -static void i915_save_display(struct drm_device *dev) +void i915_save_display(struct drm_device *dev) { struct drm_i915_private *dev_priv = dev->dev_private; @@ -689,7 +689,7 @@ static void i915_save_display(struct drm_device *dev) i915_save_vga(dev); } -static void i915_restore_display(struct drm_device *dev) +void i915_restore_display(struct drm_device *dev) { struct drm_i915_private *dev_priv = dev->dev_private; @@ -780,7 +780,6 @@ static void i915_restore_display(struct drm_device *dev) I915_WRITE(CPU_VGACNTRL, dev_priv->saveVGACNTRL); else I915_WRITE(VGACNTRL, dev_priv->saveVGACNTRL); - I915_WRITE(VGA0, dev_priv->saveVGA0); I915_WRITE(VGA1, dev_priv->saveVGA1); I915_WRITE(VGA_PD, dev_priv->saveVGA_PD); @@ -797,8 +796,6 @@ int i915_save_state(struct drm_device *dev) pci_read_config_byte(dev->pdev, LBB, &dev_priv->saveLBB); - mutex_lock(&dev->struct_mutex); - /* Hardware status page */ dev_priv->saveHWS = I915_READ(HWS_PGA); @@ -838,8 +835,6 @@ int i915_save_state(struct drm_device *dev) for (i = 0; i < 3; i++) dev_priv->saveSWF2[i] = I915_READ(SWF30 + (i << 2)); - mutex_unlock(&dev->struct_mutex); - return 0; } @@ -850,8 +845,6 @@ int i915_restore_state(struct drm_device *dev) pci_write_config_byte(dev->pdev, LBB, dev_priv->saveLBB); - mutex_lock(&dev->struct_mutex); - /* Hardware status page */ I915_WRITE(HWS_PGA, dev_priv->saveHWS); @@ -869,7 +862,6 @@ int i915_restore_state(struct drm_device *dev) I915_WRITE(IER, dev_priv->saveIER); I915_WRITE(IMR, dev_priv->saveIMR); } - mutex_unlock(&dev->struct_mutex); intel_init_clock_gating(dev); @@ -881,8 +873,6 @@ int i915_restore_state(struct drm_device *dev) if (IS_GEN6(dev)) gen6_enable_rps(dev_priv); - mutex_lock(&dev->struct_mutex); - /* Cache mode state */ I915_WRITE (CACHE_MODE_0, dev_priv->saveCACHE_MODE_0 | 0xffff0000); @@ -896,8 +886,6 @@ int i915_restore_state(struct drm_device *dev) for (i = 0; i < 3; i++) I915_WRITE(SWF30 + (i << 2), dev_priv->saveSWF2[i]); - mutex_unlock(&dev->struct_mutex); - intel_i2c_reset(dev); return 0; diff --git a/trunk/drivers/gpu/drm/i915/intel_display.c b/trunk/drivers/gpu/drm/i915/intel_display.c index 21b6f93fe919..81a9059b6a94 100644 --- a/trunk/drivers/gpu/drm/i915/intel_display.c +++ b/trunk/drivers/gpu/drm/i915/intel_display.c @@ -4687,7 +4687,6 @@ static int i9xx_crtc_mode_set(struct drm_crtc *crtc, I915_WRITE(DSPCNTR(plane), dspcntr); POSTING_READ(DSPCNTR(plane)); - intel_enable_plane(dev_priv, plane, pipe); ret = intel_pipe_set_base(crtc, x, y, old_fb); @@ -5218,6 +5217,8 @@ static int ironlake_crtc_mode_set(struct drm_crtc *crtc, I915_WRITE(DSPCNTR(plane), dspcntr); POSTING_READ(DSPCNTR(plane)); + if (!HAS_PCH_SPLIT(dev)) + intel_enable_plane(dev_priv, plane, pipe); ret = intel_pipe_set_base(crtc, x, y, old_fb); @@ -6261,197 +6262,6 @@ void intel_prepare_page_flip(struct drm_device *dev, int plane) spin_unlock_irqrestore(&dev->event_lock, flags); } -static int intel_gen2_queue_flip(struct drm_device *dev, - struct drm_crtc *crtc, - struct drm_framebuffer *fb, - struct drm_i915_gem_object *obj) -{ - struct drm_i915_private *dev_priv = dev->dev_private; - struct intel_crtc *intel_crtc = to_intel_crtc(crtc); - unsigned long offset; - u32 flip_mask; - int ret; - - ret = intel_pin_and_fence_fb_obj(dev, obj, LP_RING(dev_priv)); - if (ret) - goto out; - - /* Offset into the new buffer for cases of shared fbs between CRTCs */ - offset = crtc->y * fb->pitch + crtc->x * fb->bits_per_pixel/8; - - ret = BEGIN_LP_RING(6); - if (ret) - goto out; - - /* Can't queue multiple flips, so wait for the previous - * one to finish before executing the next. - */ - if (intel_crtc->plane) - flip_mask = MI_WAIT_FOR_PLANE_B_FLIP; - else - flip_mask = MI_WAIT_FOR_PLANE_A_FLIP; - OUT_RING(MI_WAIT_FOR_EVENT | flip_mask); - OUT_RING(MI_NOOP); - OUT_RING(MI_DISPLAY_FLIP | - MI_DISPLAY_FLIP_PLANE(intel_crtc->plane)); - OUT_RING(fb->pitch); - OUT_RING(obj->gtt_offset + offset); - OUT_RING(MI_NOOP); - ADVANCE_LP_RING(); -out: - return ret; -} - -static int intel_gen3_queue_flip(struct drm_device *dev, - struct drm_crtc *crtc, - struct drm_framebuffer *fb, - struct drm_i915_gem_object *obj) -{ - struct drm_i915_private *dev_priv = dev->dev_private; - struct intel_crtc *intel_crtc = to_intel_crtc(crtc); - unsigned long offset; - u32 flip_mask; - int ret; - - ret = intel_pin_and_fence_fb_obj(dev, obj, LP_RING(dev_priv)); - if (ret) - goto out; - - /* Offset into the new buffer for cases of shared fbs between CRTCs */ - offset = crtc->y * fb->pitch + crtc->x * fb->bits_per_pixel/8; - - ret = BEGIN_LP_RING(6); - if (ret) - goto out; - - if (intel_crtc->plane) - flip_mask = MI_WAIT_FOR_PLANE_B_FLIP; - else - flip_mask = MI_WAIT_FOR_PLANE_A_FLIP; - OUT_RING(MI_WAIT_FOR_EVENT | flip_mask); - OUT_RING(MI_NOOP); - OUT_RING(MI_DISPLAY_FLIP_I915 | - MI_DISPLAY_FLIP_PLANE(intel_crtc->plane)); - OUT_RING(fb->pitch); - OUT_RING(obj->gtt_offset + offset); - OUT_RING(MI_NOOP); - - ADVANCE_LP_RING(); -out: - return ret; -} - -static int intel_gen4_queue_flip(struct drm_device *dev, - struct drm_crtc *crtc, - struct drm_framebuffer *fb, - struct drm_i915_gem_object *obj) -{ - struct drm_i915_private *dev_priv = dev->dev_private; - struct intel_crtc *intel_crtc = to_intel_crtc(crtc); - uint32_t pf, pipesrc; - int ret; - - ret = intel_pin_and_fence_fb_obj(dev, obj, LP_RING(dev_priv)); - if (ret) - goto out; - - ret = BEGIN_LP_RING(4); - if (ret) - goto out; - - /* i965+ uses the linear or tiled offsets from the - * Display Registers (which do not change across a page-flip) - * so we need only reprogram the base address. - */ - OUT_RING(MI_DISPLAY_FLIP | - MI_DISPLAY_FLIP_PLANE(intel_crtc->plane)); - OUT_RING(fb->pitch); - OUT_RING(obj->gtt_offset | obj->tiling_mode); - - /* XXX Enabling the panel-fitter across page-flip is so far - * untested on non-native modes, so ignore it for now. - * pf = I915_READ(pipe == 0 ? PFA_CTL_1 : PFB_CTL_1) & PF_ENABLE; - */ - pf = 0; - pipesrc = I915_READ(PIPESRC(intel_crtc->pipe)) & 0x0fff0fff; - OUT_RING(pf | pipesrc); - ADVANCE_LP_RING(); -out: - return ret; -} - -static int intel_gen6_queue_flip(struct drm_device *dev, - struct drm_crtc *crtc, - struct drm_framebuffer *fb, - struct drm_i915_gem_object *obj) -{ - struct drm_i915_private *dev_priv = dev->dev_private; - struct intel_crtc *intel_crtc = to_intel_crtc(crtc); - uint32_t pf, pipesrc; - int ret; - - ret = intel_pin_and_fence_fb_obj(dev, obj, LP_RING(dev_priv)); - if (ret) - goto out; - - ret = BEGIN_LP_RING(4); - if (ret) - goto out; - - OUT_RING(MI_DISPLAY_FLIP | - MI_DISPLAY_FLIP_PLANE(intel_crtc->plane)); - OUT_RING(fb->pitch | obj->tiling_mode); - OUT_RING(obj->gtt_offset); - - pf = I915_READ(PF_CTL(intel_crtc->pipe)) & PF_ENABLE; - pipesrc = I915_READ(PIPESRC(intel_crtc->pipe)) & 0x0fff0fff; - OUT_RING(pf | pipesrc); - ADVANCE_LP_RING(); -out: - return ret; -} - -/* - * On gen7 we currently use the blit ring because (in early silicon at least) - * the render ring doesn't give us interrpts for page flip completion, which - * means clients will hang after the first flip is queued. Fortunately the - * blit ring generates interrupts properly, so use it instead. - */ -static int intel_gen7_queue_flip(struct drm_device *dev, - struct drm_crtc *crtc, - struct drm_framebuffer *fb, - struct drm_i915_gem_object *obj) -{ - struct drm_i915_private *dev_priv = dev->dev_private; - struct intel_crtc *intel_crtc = to_intel_crtc(crtc); - struct intel_ring_buffer *ring = &dev_priv->ring[BCS]; - int ret; - - ret = intel_pin_and_fence_fb_obj(dev, obj, ring); - if (ret) - goto out; - - ret = intel_ring_begin(ring, 4); - if (ret) - goto out; - - intel_ring_emit(ring, MI_DISPLAY_FLIP_I915 | (intel_crtc->plane << 19)); - intel_ring_emit(ring, (fb->pitch | obj->tiling_mode)); - intel_ring_emit(ring, (obj->gtt_offset)); - intel_ring_emit(ring, (MI_NOOP)); - intel_ring_advance(ring); -out: - return ret; -} - -static int intel_default_queue_flip(struct drm_device *dev, - struct drm_crtc *crtc, - struct drm_framebuffer *fb, - struct drm_i915_gem_object *obj) -{ - return -ENODEV; -} - static int intel_crtc_page_flip(struct drm_crtc *crtc, struct drm_framebuffer *fb, struct drm_pending_vblank_event *event) @@ -6462,7 +6272,9 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc, struct drm_i915_gem_object *obj; struct intel_crtc *intel_crtc = to_intel_crtc(crtc); struct intel_unpin_work *work; - unsigned long flags; + unsigned long flags, offset; + int pipe = intel_crtc->pipe; + u32 pf, pipesrc; int ret; work = kzalloc(sizeof *work, GFP_KERNEL); @@ -6491,6 +6303,9 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc, obj = intel_fb->obj; mutex_lock(&dev->struct_mutex); + ret = intel_pin_and_fence_fb_obj(dev, obj, LP_RING(dev_priv)); + if (ret) + goto cleanup_work; /* Reference the objects for the scheduled work. */ drm_gem_object_reference(&work->old_fb_obj->base); @@ -6502,18 +6317,91 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc, if (ret) goto cleanup_objs; + if (IS_GEN3(dev) || IS_GEN2(dev)) { + u32 flip_mask; + + /* Can't queue multiple flips, so wait for the previous + * one to finish before executing the next. + */ + ret = BEGIN_LP_RING(2); + if (ret) + goto cleanup_objs; + + if (intel_crtc->plane) + flip_mask = MI_WAIT_FOR_PLANE_B_FLIP; + else + flip_mask = MI_WAIT_FOR_PLANE_A_FLIP; + OUT_RING(MI_WAIT_FOR_EVENT | flip_mask); + OUT_RING(MI_NOOP); + ADVANCE_LP_RING(); + } + work->pending_flip_obj = obj; work->enable_stall_check = true; + /* Offset into the new buffer for cases of shared fbs between CRTCs */ + offset = crtc->y * fb->pitch + crtc->x * fb->bits_per_pixel/8; + + ret = BEGIN_LP_RING(4); + if (ret) + goto cleanup_objs; + /* Block clients from rendering to the new back buffer until * the flip occurs and the object is no longer visible. */ atomic_add(1 << intel_crtc->plane, &work->old_fb_obj->pending_flip); - ret = dev_priv->display.queue_flip(dev, crtc, fb, obj); - if (ret) - goto cleanup_pending; + switch (INTEL_INFO(dev)->gen) { + case 2: + OUT_RING(MI_DISPLAY_FLIP | + MI_DISPLAY_FLIP_PLANE(intel_crtc->plane)); + OUT_RING(fb->pitch); + OUT_RING(obj->gtt_offset + offset); + OUT_RING(MI_NOOP); + break; + + case 3: + OUT_RING(MI_DISPLAY_FLIP_I915 | + MI_DISPLAY_FLIP_PLANE(intel_crtc->plane)); + OUT_RING(fb->pitch); + OUT_RING(obj->gtt_offset + offset); + OUT_RING(MI_NOOP); + break; + + case 4: + case 5: + /* i965+ uses the linear or tiled offsets from the + * Display Registers (which do not change across a page-flip) + * so we need only reprogram the base address. + */ + OUT_RING(MI_DISPLAY_FLIP | + MI_DISPLAY_FLIP_PLANE(intel_crtc->plane)); + OUT_RING(fb->pitch); + OUT_RING(obj->gtt_offset | obj->tiling_mode); + + /* XXX Enabling the panel-fitter across page-flip is so far + * untested on non-native modes, so ignore it for now. + * pf = I915_READ(pipe == 0 ? PFA_CTL_1 : PFB_CTL_1) & PF_ENABLE; + */ + pf = 0; + pipesrc = I915_READ(PIPESRC(pipe)) & 0x0fff0fff; + OUT_RING(pf | pipesrc); + break; + + case 6: + case 7: + OUT_RING(MI_DISPLAY_FLIP | + MI_DISPLAY_FLIP_PLANE(intel_crtc->plane)); + OUT_RING(fb->pitch | obj->tiling_mode); + OUT_RING(obj->gtt_offset); + + pf = I915_READ(PF_CTL(pipe)) & PF_ENABLE; + pipesrc = I915_READ(PIPESRC(pipe)) & 0x0fff0fff; + OUT_RING(pf | pipesrc); + break; + } + ADVANCE_LP_RING(); mutex_unlock(&dev->struct_mutex); @@ -6521,11 +6409,10 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc, return 0; -cleanup_pending: - atomic_sub(1 << intel_crtc->plane, &work->old_fb_obj->pending_flip); cleanup_objs: drm_gem_object_unreference(&work->old_fb_obj->base); drm_gem_object_unreference(&obj->base); +cleanup_work: mutex_unlock(&dev->struct_mutex); spin_lock_irqsave(&dev->event_lock, flags); @@ -7770,31 +7657,6 @@ static void intel_init_display(struct drm_device *dev) else dev_priv->display.get_fifo_size = i830_get_fifo_size; } - - /* Default just returns -ENODEV to indicate unsupported */ - dev_priv->display.queue_flip = intel_default_queue_flip; - - switch (INTEL_INFO(dev)->gen) { - case 2: - dev_priv->display.queue_flip = intel_gen2_queue_flip; - break; - - case 3: - dev_priv->display.queue_flip = intel_gen3_queue_flip; - break; - - case 4: - case 5: - dev_priv->display.queue_flip = intel_gen4_queue_flip; - break; - - case 6: - dev_priv->display.queue_flip = intel_gen6_queue_flip; - break; - case 7: - dev_priv->display.queue_flip = intel_gen7_queue_flip; - break; - } } /* diff --git a/trunk/drivers/gpu/drm/i915/intel_dp.c b/trunk/drivers/gpu/drm/i915/intel_dp.c index e2aced6eec4c..391b55f1cc74 100644 --- a/trunk/drivers/gpu/drm/i915/intel_dp.c +++ b/trunk/drivers/gpu/drm/i915/intel_dp.c @@ -50,6 +50,7 @@ struct intel_dp { bool has_audio; int force_audio; uint32_t color_range; + int dpms_mode; uint8_t link_bw; uint8_t lane_count; uint8_t dpcd[4]; @@ -137,8 +138,8 @@ intel_dp_max_lane_count(struct intel_dp *intel_dp) { int max_lane_count = 4; - if (intel_dp->dpcd[DP_DPCD_REV] >= 0x11) { - max_lane_count = intel_dp->dpcd[DP_MAX_LANE_COUNT] & 0x1f; + if (intel_dp->dpcd[0] >= 0x11) { + max_lane_count = intel_dp->dpcd[2] & 0x1f; switch (max_lane_count) { case 1: case 2: case 4: break; @@ -152,7 +153,7 @@ intel_dp_max_lane_count(struct intel_dp *intel_dp) static int intel_dp_max_link_bw(struct intel_dp *intel_dp) { - int max_link_bw = intel_dp->dpcd[DP_MAX_LINK_RATE]; + int max_link_bw = intel_dp->dpcd[1]; switch (max_link_bw) { case DP_LINK_BW_1_62: @@ -773,8 +774,7 @@ intel_dp_mode_set(struct drm_encoder *encoder, struct drm_display_mode *mode, /* * Check for DPCD version > 1.1 and enhanced framing support */ - if (intel_dp->dpcd[DP_DPCD_REV] >= 0x11 && - (intel_dp->dpcd[DP_MAX_LANE_COUNT] & DP_ENHANCED_FRAME_CAP)) { + if (intel_dp->dpcd[0] >= 0x11 && (intel_dp->dpcd[2] & DP_ENHANCED_FRAME_CAP)) { intel_dp->link_configuration[1] |= DP_LANE_COUNT_ENHANCED_FRAME_EN; intel_dp->DP |= DP_ENHANCED_FRAMING; } @@ -942,44 +942,11 @@ static void ironlake_edp_pll_off(struct drm_encoder *encoder) udelay(200); } -/* If the sink supports it, try to set the power state appropriately */ -static void intel_dp_sink_dpms(struct intel_dp *intel_dp, int mode) -{ - int ret, i; - - /* Should have a valid DPCD by this point */ - if (intel_dp->dpcd[DP_DPCD_REV] < 0x11) - return; - - if (mode != DRM_MODE_DPMS_ON) { - ret = intel_dp_aux_native_write_1(intel_dp, DP_SET_POWER, - DP_SET_POWER_D3); - if (ret != 1) - DRM_DEBUG_DRIVER("failed to write sink power state\n"); - } else { - /* - * When turning on, we need to retry for 1ms to give the sink - * time to wake up. - */ - for (i = 0; i < 3; i++) { - ret = intel_dp_aux_native_write_1(intel_dp, - DP_SET_POWER, - DP_SET_POWER_D0); - if (ret == 1) - break; - msleep(1); - } - } -} - static void intel_dp_prepare(struct drm_encoder *encoder) { struct intel_dp *intel_dp = enc_to_intel_dp(encoder); struct drm_device *dev = encoder->dev; - /* Wake up the sink first */ - intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_ON); - if (is_edp(intel_dp)) { ironlake_edp_backlight_off(dev); ironlake_edp_panel_off(dev); @@ -1023,7 +990,6 @@ intel_dp_dpms(struct drm_encoder *encoder, int mode) if (mode != DRM_MODE_DPMS_ON) { if (is_edp(intel_dp)) ironlake_edp_backlight_off(dev); - intel_dp_sink_dpms(intel_dp, mode); intel_dp_link_down(intel_dp); if (is_edp(intel_dp)) ironlake_edp_panel_off(dev); @@ -1032,7 +998,6 @@ intel_dp_dpms(struct drm_encoder *encoder, int mode) } else { if (is_edp(intel_dp)) ironlake_edp_panel_vdd_on(intel_dp); - intel_dp_sink_dpms(intel_dp, mode); if (!(dp_reg & DP_PORT_EN)) { intel_dp_start_link_train(intel_dp); if (is_edp(intel_dp)) { @@ -1044,31 +1009,7 @@ intel_dp_dpms(struct drm_encoder *encoder, int mode) if (is_edp(intel_dp)) ironlake_edp_backlight_on(dev); } -} - -/* - * Native read with retry for link status and receiver capability reads for - * cases where the sink may still be asleep. - */ -static bool -intel_dp_aux_native_read_retry(struct intel_dp *intel_dp, uint16_t address, - uint8_t *recv, int recv_bytes) -{ - int ret, i; - - /* - * Sinks are *supposed* to come up within 1ms from an off state, - * but we're also supposed to retry 3 times per the spec. - */ - for (i = 0; i < 3; i++) { - ret = intel_dp_aux_native_read(intel_dp, address, recv, - recv_bytes); - if (ret == recv_bytes) - return true; - msleep(1); - } - - return false; + intel_dp->dpms_mode = mode; } /* @@ -1078,10 +1019,14 @@ intel_dp_aux_native_read_retry(struct intel_dp *intel_dp, uint16_t address, static bool intel_dp_get_link_status(struct intel_dp *intel_dp) { - return intel_dp_aux_native_read_retry(intel_dp, - DP_LANE0_1_STATUS, - intel_dp->link_status, - DP_LINK_STATUS_SIZE); + int ret; + + ret = intel_dp_aux_native_read(intel_dp, + DP_LANE0_1_STATUS, + intel_dp->link_status, DP_LINK_STATUS_SIZE); + if (ret != DP_LINK_STATUS_SIZE) + return false; + return true; } static uint8_t @@ -1570,8 +1515,6 @@ intel_dp_link_down(struct intel_dp *intel_dp) static void intel_dp_check_link_status(struct intel_dp *intel_dp) { - int ret; - if (!intel_dp->base.base.crtc) return; @@ -1580,15 +1523,6 @@ intel_dp_check_link_status(struct intel_dp *intel_dp) return; } - /* Try to read receiver status if the link appears to be up */ - ret = intel_dp_aux_native_read(intel_dp, - 0x000, intel_dp->dpcd, - sizeof (intel_dp->dpcd)); - if (ret != sizeof(intel_dp->dpcd)) { - intel_dp_link_down(intel_dp); - return; - } - if (!intel_channel_eq_ok(intel_dp)) { intel_dp_start_link_train(intel_dp); intel_dp_complete_link_train(intel_dp); @@ -1599,7 +1533,6 @@ static enum drm_connector_status ironlake_dp_detect(struct intel_dp *intel_dp) { enum drm_connector_status status; - bool ret; /* Can't disconnect eDP, but you can close the lid... */ if (is_edp(intel_dp)) { @@ -1610,11 +1543,13 @@ ironlake_dp_detect(struct intel_dp *intel_dp) } status = connector_status_disconnected; - ret = intel_dp_aux_native_read_retry(intel_dp, - 0x000, intel_dp->dpcd, - sizeof (intel_dp->dpcd)); - if (ret && intel_dp->dpcd[DP_DPCD_REV] != 0) - status = connector_status_connected; + if (intel_dp_aux_native_read(intel_dp, + 0x000, intel_dp->dpcd, + sizeof (intel_dp->dpcd)) + == sizeof(intel_dp->dpcd)) { + if (intel_dp->dpcd[0] != 0) + status = connector_status_connected; + } DRM_DEBUG_KMS("DPCD: %hx%hx%hx%hx\n", intel_dp->dpcd[0], intel_dp->dpcd[1], intel_dp->dpcd[2], intel_dp->dpcd[3]); return status; @@ -1651,7 +1586,7 @@ g4x_dp_detect(struct intel_dp *intel_dp) if (intel_dp_aux_native_read(intel_dp, 0x000, intel_dp->dpcd, sizeof (intel_dp->dpcd)) == sizeof (intel_dp->dpcd)) { - if (intel_dp->dpcd[DP_DPCD_REV] != 0) + if (intel_dp->dpcd[0] != 0) status = connector_status_connected; } @@ -1855,7 +1790,8 @@ intel_dp_hot_plug(struct intel_encoder *intel_encoder) { struct intel_dp *intel_dp = container_of(intel_encoder, struct intel_dp, base); - intel_dp_check_link_status(intel_dp); + if (intel_dp->dpms_mode == DRM_MODE_DPMS_ON) + intel_dp_check_link_status(intel_dp); } /* Return which DP Port should be selected for Transcoder DP control */ @@ -1923,6 +1859,7 @@ intel_dp_init(struct drm_device *dev, int output_reg) return; intel_dp->output_reg = output_reg; + intel_dp->dpms_mode = -1; intel_connector = kzalloc(sizeof(struct intel_connector), GFP_KERNEL); if (!intel_connector) { @@ -2017,9 +1954,8 @@ intel_dp_init(struct drm_device *dev, int output_reg) sizeof(intel_dp->dpcd)); ironlake_edp_panel_vdd_off(intel_dp); if (ret == sizeof(intel_dp->dpcd)) { - if (intel_dp->dpcd[DP_DPCD_REV] >= 0x11) - dev_priv->no_aux_handshake = - intel_dp->dpcd[DP_MAX_DOWNSPREAD] & + if (intel_dp->dpcd[0] >= 0x11) + dev_priv->no_aux_handshake = intel_dp->dpcd[3] & DP_NO_AUX_HANDSHAKE_LINK_TRAINING; } else { /* if this fails, presume the device is a ghost */ diff --git a/trunk/drivers/gpu/drm/i915/intel_overlay.c b/trunk/drivers/gpu/drm/i915/intel_overlay.c index 9e2959bc91cd..a670c006982e 100644 --- a/trunk/drivers/gpu/drm/i915/intel_overlay.c +++ b/trunk/drivers/gpu/drm/i915/intel_overlay.c @@ -1409,11 +1409,6 @@ void intel_setup_overlay(struct drm_device *dev) overlay = kzalloc(sizeof(struct intel_overlay), GFP_KERNEL); if (!overlay) return; - - mutex_lock(&dev->struct_mutex); - if (WARN_ON(dev_priv->overlay)) - goto out_free; - overlay->dev = dev; reg_bo = i915_gem_alloc_object(dev, PAGE_SIZE); @@ -1453,7 +1448,7 @@ void intel_setup_overlay(struct drm_device *dev) regs = intel_overlay_map_regs(overlay); if (!regs) - goto out_unpin_bo; + goto out_free_bo; memset(regs, 0, sizeof(struct overlay_registers)); update_polyphase_filter(regs); @@ -1462,17 +1457,14 @@ void intel_setup_overlay(struct drm_device *dev) intel_overlay_unmap_regs(overlay, regs); dev_priv->overlay = overlay; - mutex_unlock(&dev->struct_mutex); DRM_INFO("initialized overlay support\n"); return; out_unpin_bo: - if (!OVERLAY_NEEDS_PHYSICAL(dev)) - i915_gem_object_unpin(reg_bo); + i915_gem_object_unpin(reg_bo); out_free_bo: drm_gem_object_unreference(®_bo->base); out_free: - mutex_unlock(&dev->struct_mutex); kfree(overlay); return; } diff --git a/trunk/drivers/gpu/drm/i915/intel_ringbuffer.h b/trunk/drivers/gpu/drm/i915/intel_ringbuffer.h index 39ac2b634ae5..c0e0ee63fbf4 100644 --- a/trunk/drivers/gpu/drm/i915/intel_ringbuffer.h +++ b/trunk/drivers/gpu/drm/i915/intel_ringbuffer.h @@ -165,7 +165,7 @@ void intel_cleanup_ring_buffer(struct intel_ring_buffer *ring); int __must_check intel_wait_ring_buffer(struct intel_ring_buffer *ring, int n); static inline int intel_wait_ring_idle(struct intel_ring_buffer *ring) { - return intel_wait_ring_buffer(ring, ring->size - 8); + return intel_wait_ring_buffer(ring, ring->space - 8); } int __must_check intel_ring_begin(struct intel_ring_buffer *ring, int n); diff --git a/trunk/drivers/gpu/drm/nouveau/nouveau_state.c b/trunk/drivers/gpu/drm/nouveau/nouveau_state.c index 731acea865b5..144f79a350ae 100644 --- a/trunk/drivers/gpu/drm/nouveau/nouveau_state.c +++ b/trunk/drivers/gpu/drm/nouveau/nouveau_state.c @@ -371,6 +371,7 @@ static int nouveau_init_engine_ptrs(struct drm_device *dev) engine->vram.flags_valid = nv50_vram_flags_valid; break; case 0xC0: + case 0xD0: engine->instmem.init = nvc0_instmem_init; engine->instmem.takedown = nvc0_instmem_takedown; engine->instmem.suspend = nvc0_instmem_suspend; @@ -922,6 +923,7 @@ int nouveau_load(struct drm_device *dev, unsigned long flags) dev_priv->card_type = NV_50; break; case 0xc0: + case 0xd0: dev_priv->card_type = NV_C0; break; default: diff --git a/trunk/drivers/gpu/drm/radeon/evergreen.c b/trunk/drivers/gpu/drm/radeon/evergreen.c index 15bd0477a3e8..445af7981637 100644 --- a/trunk/drivers/gpu/drm/radeon/evergreen.c +++ b/trunk/drivers/gpu/drm/radeon/evergreen.c @@ -985,19 +985,17 @@ void evergreen_mc_stop(struct radeon_device *rdev, struct evergreen_mc_save *sav { save->vga_control[0] = RREG32(D1VGA_CONTROL); save->vga_control[1] = RREG32(D2VGA_CONTROL); + save->vga_control[2] = RREG32(EVERGREEN_D3VGA_CONTROL); + save->vga_control[3] = RREG32(EVERGREEN_D4VGA_CONTROL); + save->vga_control[4] = RREG32(EVERGREEN_D5VGA_CONTROL); + save->vga_control[5] = RREG32(EVERGREEN_D6VGA_CONTROL); save->vga_render_control = RREG32(VGA_RENDER_CONTROL); save->vga_hdp_control = RREG32(VGA_HDP_CONTROL); save->crtc_control[0] = RREG32(EVERGREEN_CRTC_CONTROL + EVERGREEN_CRTC0_REGISTER_OFFSET); save->crtc_control[1] = RREG32(EVERGREEN_CRTC_CONTROL + EVERGREEN_CRTC1_REGISTER_OFFSET); - if (rdev->num_crtc >= 4) { - save->vga_control[2] = RREG32(EVERGREEN_D3VGA_CONTROL); - save->vga_control[3] = RREG32(EVERGREEN_D4VGA_CONTROL); + if (!(rdev->flags & RADEON_IS_IGP)) { save->crtc_control[2] = RREG32(EVERGREEN_CRTC_CONTROL + EVERGREEN_CRTC2_REGISTER_OFFSET); save->crtc_control[3] = RREG32(EVERGREEN_CRTC_CONTROL + EVERGREEN_CRTC3_REGISTER_OFFSET); - } - if (rdev->num_crtc >= 6) { - save->vga_control[4] = RREG32(EVERGREEN_D5VGA_CONTROL); - save->vga_control[5] = RREG32(EVERGREEN_D6VGA_CONTROL); save->crtc_control[4] = RREG32(EVERGREEN_CRTC_CONTROL + EVERGREEN_CRTC4_REGISTER_OFFSET); save->crtc_control[5] = RREG32(EVERGREEN_CRTC_CONTROL + EVERGREEN_CRTC5_REGISTER_OFFSET); } @@ -1006,45 +1004,35 @@ void evergreen_mc_stop(struct radeon_device *rdev, struct evergreen_mc_save *sav WREG32(VGA_RENDER_CONTROL, 0); WREG32(EVERGREEN_CRTC_UPDATE_LOCK + EVERGREEN_CRTC0_REGISTER_OFFSET, 1); WREG32(EVERGREEN_CRTC_UPDATE_LOCK + EVERGREEN_CRTC1_REGISTER_OFFSET, 1); - if (rdev->num_crtc >= 4) { + if (!(rdev->flags & RADEON_IS_IGP)) { WREG32(EVERGREEN_CRTC_UPDATE_LOCK + EVERGREEN_CRTC2_REGISTER_OFFSET, 1); WREG32(EVERGREEN_CRTC_UPDATE_LOCK + EVERGREEN_CRTC3_REGISTER_OFFSET, 1); - } - if (rdev->num_crtc >= 6) { WREG32(EVERGREEN_CRTC_UPDATE_LOCK + EVERGREEN_CRTC4_REGISTER_OFFSET, 1); WREG32(EVERGREEN_CRTC_UPDATE_LOCK + EVERGREEN_CRTC5_REGISTER_OFFSET, 1); } WREG32(EVERGREEN_CRTC_CONTROL + EVERGREEN_CRTC0_REGISTER_OFFSET, 0); WREG32(EVERGREEN_CRTC_CONTROL + EVERGREEN_CRTC1_REGISTER_OFFSET, 0); - if (rdev->num_crtc >= 4) { + if (!(rdev->flags & RADEON_IS_IGP)) { WREG32(EVERGREEN_CRTC_CONTROL + EVERGREEN_CRTC2_REGISTER_OFFSET, 0); WREG32(EVERGREEN_CRTC_CONTROL + EVERGREEN_CRTC3_REGISTER_OFFSET, 0); - } - if (rdev->num_crtc >= 6) { WREG32(EVERGREEN_CRTC_CONTROL + EVERGREEN_CRTC4_REGISTER_OFFSET, 0); WREG32(EVERGREEN_CRTC_CONTROL + EVERGREEN_CRTC5_REGISTER_OFFSET, 0); } WREG32(EVERGREEN_CRTC_UPDATE_LOCK + EVERGREEN_CRTC0_REGISTER_OFFSET, 0); WREG32(EVERGREEN_CRTC_UPDATE_LOCK + EVERGREEN_CRTC1_REGISTER_OFFSET, 0); - if (rdev->num_crtc >= 4) { + if (!(rdev->flags & RADEON_IS_IGP)) { WREG32(EVERGREEN_CRTC_UPDATE_LOCK + EVERGREEN_CRTC2_REGISTER_OFFSET, 0); WREG32(EVERGREEN_CRTC_UPDATE_LOCK + EVERGREEN_CRTC3_REGISTER_OFFSET, 0); - } - if (rdev->num_crtc >= 6) { WREG32(EVERGREEN_CRTC_UPDATE_LOCK + EVERGREEN_CRTC4_REGISTER_OFFSET, 0); WREG32(EVERGREEN_CRTC_UPDATE_LOCK + EVERGREEN_CRTC5_REGISTER_OFFSET, 0); } WREG32(D1VGA_CONTROL, 0); WREG32(D2VGA_CONTROL, 0); - if (rdev->num_crtc >= 4) { - WREG32(EVERGREEN_D3VGA_CONTROL, 0); - WREG32(EVERGREEN_D4VGA_CONTROL, 0); - } - if (rdev->num_crtc >= 6) { - WREG32(EVERGREEN_D5VGA_CONTROL, 0); - WREG32(EVERGREEN_D6VGA_CONTROL, 0); - } + WREG32(EVERGREEN_D3VGA_CONTROL, 0); + WREG32(EVERGREEN_D4VGA_CONTROL, 0); + WREG32(EVERGREEN_D5VGA_CONTROL, 0); + WREG32(EVERGREEN_D6VGA_CONTROL, 0); } void evergreen_mc_resume(struct radeon_device *rdev, struct evergreen_mc_save *save) @@ -1067,7 +1055,7 @@ void evergreen_mc_resume(struct radeon_device *rdev, struct evergreen_mc_save *s WREG32(EVERGREEN_GRPH_SECONDARY_SURFACE_ADDRESS + EVERGREEN_CRTC1_REGISTER_OFFSET, (u32)rdev->mc.vram_start); - if (rdev->num_crtc >= 4) { + if (!(rdev->flags & RADEON_IS_IGP)) { WREG32(EVERGREEN_GRPH_PRIMARY_SURFACE_ADDRESS_HIGH + EVERGREEN_CRTC2_REGISTER_OFFSET, upper_32_bits(rdev->mc.vram_start)); WREG32(EVERGREEN_GRPH_SECONDARY_SURFACE_ADDRESS_HIGH + EVERGREEN_CRTC2_REGISTER_OFFSET, @@ -1085,8 +1073,7 @@ void evergreen_mc_resume(struct radeon_device *rdev, struct evergreen_mc_save *s (u32)rdev->mc.vram_start); WREG32(EVERGREEN_GRPH_SECONDARY_SURFACE_ADDRESS + EVERGREEN_CRTC3_REGISTER_OFFSET, (u32)rdev->mc.vram_start); - } - if (rdev->num_crtc >= 6) { + WREG32(EVERGREEN_GRPH_PRIMARY_SURFACE_ADDRESS_HIGH + EVERGREEN_CRTC4_REGISTER_OFFSET, upper_32_bits(rdev->mc.vram_start)); WREG32(EVERGREEN_GRPH_SECONDARY_SURFACE_ADDRESS_HIGH + EVERGREEN_CRTC4_REGISTER_OFFSET, @@ -1114,41 +1101,31 @@ void evergreen_mc_resume(struct radeon_device *rdev, struct evergreen_mc_save *s /* Restore video state */ WREG32(D1VGA_CONTROL, save->vga_control[0]); WREG32(D2VGA_CONTROL, save->vga_control[1]); - if (rdev->num_crtc >= 4) { - WREG32(EVERGREEN_D3VGA_CONTROL, save->vga_control[2]); - WREG32(EVERGREEN_D4VGA_CONTROL, save->vga_control[3]); - } - if (rdev->num_crtc >= 6) { - WREG32(EVERGREEN_D5VGA_CONTROL, save->vga_control[4]); - WREG32(EVERGREEN_D6VGA_CONTROL, save->vga_control[5]); - } + WREG32(EVERGREEN_D3VGA_CONTROL, save->vga_control[2]); + WREG32(EVERGREEN_D4VGA_CONTROL, save->vga_control[3]); + WREG32(EVERGREEN_D5VGA_CONTROL, save->vga_control[4]); + WREG32(EVERGREEN_D6VGA_CONTROL, save->vga_control[5]); WREG32(EVERGREEN_CRTC_UPDATE_LOCK + EVERGREEN_CRTC0_REGISTER_OFFSET, 1); WREG32(EVERGREEN_CRTC_UPDATE_LOCK + EVERGREEN_CRTC1_REGISTER_OFFSET, 1); - if (rdev->num_crtc >= 4) { + if (!(rdev->flags & RADEON_IS_IGP)) { WREG32(EVERGREEN_CRTC_UPDATE_LOCK + EVERGREEN_CRTC2_REGISTER_OFFSET, 1); WREG32(EVERGREEN_CRTC_UPDATE_LOCK + EVERGREEN_CRTC3_REGISTER_OFFSET, 1); - } - if (rdev->num_crtc >= 6) { WREG32(EVERGREEN_CRTC_UPDATE_LOCK + EVERGREEN_CRTC4_REGISTER_OFFSET, 1); WREG32(EVERGREEN_CRTC_UPDATE_LOCK + EVERGREEN_CRTC5_REGISTER_OFFSET, 1); } WREG32(EVERGREEN_CRTC_CONTROL + EVERGREEN_CRTC0_REGISTER_OFFSET, save->crtc_control[0]); WREG32(EVERGREEN_CRTC_CONTROL + EVERGREEN_CRTC1_REGISTER_OFFSET, save->crtc_control[1]); - if (rdev->num_crtc >= 4) { + if (!(rdev->flags & RADEON_IS_IGP)) { WREG32(EVERGREEN_CRTC_CONTROL + EVERGREEN_CRTC2_REGISTER_OFFSET, save->crtc_control[2]); WREG32(EVERGREEN_CRTC_CONTROL + EVERGREEN_CRTC3_REGISTER_OFFSET, save->crtc_control[3]); - } - if (rdev->num_crtc >= 6) { WREG32(EVERGREEN_CRTC_CONTROL + EVERGREEN_CRTC4_REGISTER_OFFSET, save->crtc_control[4]); WREG32(EVERGREEN_CRTC_CONTROL + EVERGREEN_CRTC5_REGISTER_OFFSET, save->crtc_control[5]); } WREG32(EVERGREEN_CRTC_UPDATE_LOCK + EVERGREEN_CRTC0_REGISTER_OFFSET, 0); WREG32(EVERGREEN_CRTC_UPDATE_LOCK + EVERGREEN_CRTC1_REGISTER_OFFSET, 0); - if (rdev->num_crtc >= 4) { + if (!(rdev->flags & RADEON_IS_IGP)) { WREG32(EVERGREEN_CRTC_UPDATE_LOCK + EVERGREEN_CRTC2_REGISTER_OFFSET, 0); WREG32(EVERGREEN_CRTC_UPDATE_LOCK + EVERGREEN_CRTC3_REGISTER_OFFSET, 0); - } - if (rdev->num_crtc >= 6) { WREG32(EVERGREEN_CRTC_UPDATE_LOCK + EVERGREEN_CRTC4_REGISTER_OFFSET, 0); WREG32(EVERGREEN_CRTC_UPDATE_LOCK + EVERGREEN_CRTC5_REGISTER_OFFSET, 0); } @@ -2000,7 +1977,7 @@ static void evergreen_gpu_init(struct radeon_device *rdev) gb_backend_map = 0x66442200; break; case CHIP_JUNIPER: - gb_backend_map = 0x00002200; + gb_backend_map = 0x00006420; break; default: gb_backend_map = @@ -2036,9 +2013,9 @@ static void evergreen_gpu_init(struct radeon_device *rdev) rdev->config.evergreen.tile_config |= (3 << 0); break; } - /* num banks is 8 on all fusion asics. 0 = 4, 1 = 8, 2 = 16 */ + /* num banks is 8 on all fusion asics */ if (rdev->flags & RADEON_IS_IGP) - rdev->config.evergreen.tile_config |= 1 << 4; + rdev->config.evergreen.tile_config |= 8 << 4; else rdev->config.evergreen.tile_config |= ((mc_arb_ramcfg & NOOFBANK_MASK) >> NOOFBANK_SHIFT) << 4; @@ -2271,10 +2248,7 @@ int evergreen_mc_init(struct radeon_device *rdev) /* Get VRAM informations */ rdev->mc.vram_is_ddr = true; - if (rdev->flags & RADEON_IS_IGP) - tmp = RREG32(FUS_MC_ARB_RAMCFG); - else - tmp = RREG32(MC_ARB_RAMCFG); + tmp = RREG32(MC_ARB_RAMCFG); if (tmp & CHANSIZE_OVERRIDE) { chansize = 16; } else if (tmp & CHANSIZE_MASK) { @@ -2440,22 +2414,18 @@ void evergreen_disable_interrupt_state(struct radeon_device *rdev) WREG32(GRBM_INT_CNTL, 0); WREG32(INT_MASK + EVERGREEN_CRTC0_REGISTER_OFFSET, 0); WREG32(INT_MASK + EVERGREEN_CRTC1_REGISTER_OFFSET, 0); - if (rdev->num_crtc >= 4) { + if (!(rdev->flags & RADEON_IS_IGP)) { WREG32(INT_MASK + EVERGREEN_CRTC2_REGISTER_OFFSET, 0); WREG32(INT_MASK + EVERGREEN_CRTC3_REGISTER_OFFSET, 0); - } - if (rdev->num_crtc >= 6) { WREG32(INT_MASK + EVERGREEN_CRTC4_REGISTER_OFFSET, 0); WREG32(INT_MASK + EVERGREEN_CRTC5_REGISTER_OFFSET, 0); } WREG32(GRPH_INT_CONTROL + EVERGREEN_CRTC0_REGISTER_OFFSET, 0); WREG32(GRPH_INT_CONTROL + EVERGREEN_CRTC1_REGISTER_OFFSET, 0); - if (rdev->num_crtc >= 4) { + if (!(rdev->flags & RADEON_IS_IGP)) { WREG32(GRPH_INT_CONTROL + EVERGREEN_CRTC2_REGISTER_OFFSET, 0); WREG32(GRPH_INT_CONTROL + EVERGREEN_CRTC3_REGISTER_OFFSET, 0); - } - if (rdev->num_crtc >= 6) { WREG32(GRPH_INT_CONTROL + EVERGREEN_CRTC4_REGISTER_OFFSET, 0); WREG32(GRPH_INT_CONTROL + EVERGREEN_CRTC5_REGISTER_OFFSET, 0); } @@ -2574,25 +2544,19 @@ int evergreen_irq_set(struct radeon_device *rdev) WREG32(INT_MASK + EVERGREEN_CRTC0_REGISTER_OFFSET, crtc1); WREG32(INT_MASK + EVERGREEN_CRTC1_REGISTER_OFFSET, crtc2); - if (rdev->num_crtc >= 4) { + if (!(rdev->flags & RADEON_IS_IGP)) { WREG32(INT_MASK + EVERGREEN_CRTC2_REGISTER_OFFSET, crtc3); WREG32(INT_MASK + EVERGREEN_CRTC3_REGISTER_OFFSET, crtc4); - } - if (rdev->num_crtc >= 6) { WREG32(INT_MASK + EVERGREEN_CRTC4_REGISTER_OFFSET, crtc5); WREG32(INT_MASK + EVERGREEN_CRTC5_REGISTER_OFFSET, crtc6); } WREG32(GRPH_INT_CONTROL + EVERGREEN_CRTC0_REGISTER_OFFSET, grph1); WREG32(GRPH_INT_CONTROL + EVERGREEN_CRTC1_REGISTER_OFFSET, grph2); - if (rdev->num_crtc >= 4) { - WREG32(GRPH_INT_CONTROL + EVERGREEN_CRTC2_REGISTER_OFFSET, grph3); - WREG32(GRPH_INT_CONTROL + EVERGREEN_CRTC3_REGISTER_OFFSET, grph4); - } - if (rdev->num_crtc >= 6) { - WREG32(GRPH_INT_CONTROL + EVERGREEN_CRTC4_REGISTER_OFFSET, grph5); - WREG32(GRPH_INT_CONTROL + EVERGREEN_CRTC5_REGISTER_OFFSET, grph6); - } + WREG32(GRPH_INT_CONTROL + EVERGREEN_CRTC2_REGISTER_OFFSET, grph3); + WREG32(GRPH_INT_CONTROL + EVERGREEN_CRTC3_REGISTER_OFFSET, grph4); + WREG32(GRPH_INT_CONTROL + EVERGREEN_CRTC4_REGISTER_OFFSET, grph5); + WREG32(GRPH_INT_CONTROL + EVERGREEN_CRTC5_REGISTER_OFFSET, grph6); WREG32(DC_HPD1_INT_CONTROL, hpd1); WREG32(DC_HPD2_INT_CONTROL, hpd2); @@ -2616,57 +2580,53 @@ static inline void evergreen_irq_ack(struct radeon_device *rdev) rdev->irq.stat_regs.evergreen.disp_int_cont5 = RREG32(DISP_INTERRUPT_STATUS_CONTINUE5); rdev->irq.stat_regs.evergreen.d1grph_int = RREG32(GRPH_INT_STATUS + EVERGREEN_CRTC0_REGISTER_OFFSET); rdev->irq.stat_regs.evergreen.d2grph_int = RREG32(GRPH_INT_STATUS + EVERGREEN_CRTC1_REGISTER_OFFSET); - if (rdev->num_crtc >= 4) { - rdev->irq.stat_regs.evergreen.d3grph_int = RREG32(GRPH_INT_STATUS + EVERGREEN_CRTC2_REGISTER_OFFSET); - rdev->irq.stat_regs.evergreen.d4grph_int = RREG32(GRPH_INT_STATUS + EVERGREEN_CRTC3_REGISTER_OFFSET); - } - if (rdev->num_crtc >= 6) { - rdev->irq.stat_regs.evergreen.d5grph_int = RREG32(GRPH_INT_STATUS + EVERGREEN_CRTC4_REGISTER_OFFSET); - rdev->irq.stat_regs.evergreen.d6grph_int = RREG32(GRPH_INT_STATUS + EVERGREEN_CRTC5_REGISTER_OFFSET); - } + rdev->irq.stat_regs.evergreen.d3grph_int = RREG32(GRPH_INT_STATUS + EVERGREEN_CRTC2_REGISTER_OFFSET); + rdev->irq.stat_regs.evergreen.d4grph_int = RREG32(GRPH_INT_STATUS + EVERGREEN_CRTC3_REGISTER_OFFSET); + rdev->irq.stat_regs.evergreen.d5grph_int = RREG32(GRPH_INT_STATUS + EVERGREEN_CRTC4_REGISTER_OFFSET); + rdev->irq.stat_regs.evergreen.d6grph_int = RREG32(GRPH_INT_STATUS + EVERGREEN_CRTC5_REGISTER_OFFSET); if (rdev->irq.stat_regs.evergreen.d1grph_int & GRPH_PFLIP_INT_OCCURRED) WREG32(GRPH_INT_STATUS + EVERGREEN_CRTC0_REGISTER_OFFSET, GRPH_PFLIP_INT_CLEAR); if (rdev->irq.stat_regs.evergreen.d2grph_int & GRPH_PFLIP_INT_OCCURRED) WREG32(GRPH_INT_STATUS + EVERGREEN_CRTC1_REGISTER_OFFSET, GRPH_PFLIP_INT_CLEAR); + if (rdev->irq.stat_regs.evergreen.d3grph_int & GRPH_PFLIP_INT_OCCURRED) + WREG32(GRPH_INT_STATUS + EVERGREEN_CRTC2_REGISTER_OFFSET, GRPH_PFLIP_INT_CLEAR); + if (rdev->irq.stat_regs.evergreen.d4grph_int & GRPH_PFLIP_INT_OCCURRED) + WREG32(GRPH_INT_STATUS + EVERGREEN_CRTC3_REGISTER_OFFSET, GRPH_PFLIP_INT_CLEAR); + if (rdev->irq.stat_regs.evergreen.d5grph_int & GRPH_PFLIP_INT_OCCURRED) + WREG32(GRPH_INT_STATUS + EVERGREEN_CRTC4_REGISTER_OFFSET, GRPH_PFLIP_INT_CLEAR); + if (rdev->irq.stat_regs.evergreen.d6grph_int & GRPH_PFLIP_INT_OCCURRED) + WREG32(GRPH_INT_STATUS + EVERGREEN_CRTC5_REGISTER_OFFSET, GRPH_PFLIP_INT_CLEAR); + if (rdev->irq.stat_regs.evergreen.disp_int & LB_D1_VBLANK_INTERRUPT) WREG32(VBLANK_STATUS + EVERGREEN_CRTC0_REGISTER_OFFSET, VBLANK_ACK); if (rdev->irq.stat_regs.evergreen.disp_int & LB_D1_VLINE_INTERRUPT) WREG32(VLINE_STATUS + EVERGREEN_CRTC0_REGISTER_OFFSET, VLINE_ACK); + if (rdev->irq.stat_regs.evergreen.disp_int_cont & LB_D2_VBLANK_INTERRUPT) WREG32(VBLANK_STATUS + EVERGREEN_CRTC1_REGISTER_OFFSET, VBLANK_ACK); if (rdev->irq.stat_regs.evergreen.disp_int_cont & LB_D2_VLINE_INTERRUPT) WREG32(VLINE_STATUS + EVERGREEN_CRTC1_REGISTER_OFFSET, VLINE_ACK); - if (rdev->num_crtc >= 4) { - if (rdev->irq.stat_regs.evergreen.d3grph_int & GRPH_PFLIP_INT_OCCURRED) - WREG32(GRPH_INT_STATUS + EVERGREEN_CRTC2_REGISTER_OFFSET, GRPH_PFLIP_INT_CLEAR); - if (rdev->irq.stat_regs.evergreen.d4grph_int & GRPH_PFLIP_INT_OCCURRED) - WREG32(GRPH_INT_STATUS + EVERGREEN_CRTC3_REGISTER_OFFSET, GRPH_PFLIP_INT_CLEAR); - if (rdev->irq.stat_regs.evergreen.disp_int_cont2 & LB_D3_VBLANK_INTERRUPT) - WREG32(VBLANK_STATUS + EVERGREEN_CRTC2_REGISTER_OFFSET, VBLANK_ACK); - if (rdev->irq.stat_regs.evergreen.disp_int_cont2 & LB_D3_VLINE_INTERRUPT) - WREG32(VLINE_STATUS + EVERGREEN_CRTC2_REGISTER_OFFSET, VLINE_ACK); - if (rdev->irq.stat_regs.evergreen.disp_int_cont3 & LB_D4_VBLANK_INTERRUPT) - WREG32(VBLANK_STATUS + EVERGREEN_CRTC3_REGISTER_OFFSET, VBLANK_ACK); - if (rdev->irq.stat_regs.evergreen.disp_int_cont3 & LB_D4_VLINE_INTERRUPT) - WREG32(VLINE_STATUS + EVERGREEN_CRTC3_REGISTER_OFFSET, VLINE_ACK); - } - - if (rdev->num_crtc >= 6) { - if (rdev->irq.stat_regs.evergreen.d5grph_int & GRPH_PFLIP_INT_OCCURRED) - WREG32(GRPH_INT_STATUS + EVERGREEN_CRTC4_REGISTER_OFFSET, GRPH_PFLIP_INT_CLEAR); - if (rdev->irq.stat_regs.evergreen.d6grph_int & GRPH_PFLIP_INT_OCCURRED) - WREG32(GRPH_INT_STATUS + EVERGREEN_CRTC5_REGISTER_OFFSET, GRPH_PFLIP_INT_CLEAR); - if (rdev->irq.stat_regs.evergreen.disp_int_cont4 & LB_D5_VBLANK_INTERRUPT) - WREG32(VBLANK_STATUS + EVERGREEN_CRTC4_REGISTER_OFFSET, VBLANK_ACK); - if (rdev->irq.stat_regs.evergreen.disp_int_cont4 & LB_D5_VLINE_INTERRUPT) - WREG32(VLINE_STATUS + EVERGREEN_CRTC4_REGISTER_OFFSET, VLINE_ACK); - if (rdev->irq.stat_regs.evergreen.disp_int_cont5 & LB_D6_VBLANK_INTERRUPT) - WREG32(VBLANK_STATUS + EVERGREEN_CRTC5_REGISTER_OFFSET, VBLANK_ACK); - if (rdev->irq.stat_regs.evergreen.disp_int_cont5 & LB_D6_VLINE_INTERRUPT) - WREG32(VLINE_STATUS + EVERGREEN_CRTC5_REGISTER_OFFSET, VLINE_ACK); - } + if (rdev->irq.stat_regs.evergreen.disp_int_cont2 & LB_D3_VBLANK_INTERRUPT) + WREG32(VBLANK_STATUS + EVERGREEN_CRTC2_REGISTER_OFFSET, VBLANK_ACK); + if (rdev->irq.stat_regs.evergreen.disp_int_cont2 & LB_D3_VLINE_INTERRUPT) + WREG32(VLINE_STATUS + EVERGREEN_CRTC2_REGISTER_OFFSET, VLINE_ACK); + + if (rdev->irq.stat_regs.evergreen.disp_int_cont3 & LB_D4_VBLANK_INTERRUPT) + WREG32(VBLANK_STATUS + EVERGREEN_CRTC3_REGISTER_OFFSET, VBLANK_ACK); + if (rdev->irq.stat_regs.evergreen.disp_int_cont3 & LB_D4_VLINE_INTERRUPT) + WREG32(VLINE_STATUS + EVERGREEN_CRTC3_REGISTER_OFFSET, VLINE_ACK); + + if (rdev->irq.stat_regs.evergreen.disp_int_cont4 & LB_D5_VBLANK_INTERRUPT) + WREG32(VBLANK_STATUS + EVERGREEN_CRTC4_REGISTER_OFFSET, VBLANK_ACK); + if (rdev->irq.stat_regs.evergreen.disp_int_cont4 & LB_D5_VLINE_INTERRUPT) + WREG32(VLINE_STATUS + EVERGREEN_CRTC4_REGISTER_OFFSET, VLINE_ACK); + + if (rdev->irq.stat_regs.evergreen.disp_int_cont5 & LB_D6_VBLANK_INTERRUPT) + WREG32(VBLANK_STATUS + EVERGREEN_CRTC5_REGISTER_OFFSET, VBLANK_ACK); + if (rdev->irq.stat_regs.evergreen.disp_int_cont5 & LB_D6_VLINE_INTERRUPT) + WREG32(VLINE_STATUS + EVERGREEN_CRTC5_REGISTER_OFFSET, VLINE_ACK); if (rdev->irq.stat_regs.evergreen.disp_int & DC_HPD1_INTERRUPT) { tmp = RREG32(DC_HPD1_INT_CONTROL); @@ -3274,7 +3234,6 @@ void evergreen_fini(struct radeon_device *rdev) r700_cp_fini(rdev); r600_irq_fini(rdev); radeon_wb_fini(rdev); - radeon_ib_pool_fini(rdev); radeon_irq_kms_fini(rdev); evergreen_pcie_gart_fini(rdev); radeon_gem_fini(rdev); diff --git a/trunk/drivers/gpu/drm/radeon/evergreen_blit_kms.c b/trunk/drivers/gpu/drm/radeon/evergreen_blit_kms.c index 2eb251858e72..57f3bc17b87e 100644 --- a/trunk/drivers/gpu/drm/radeon/evergreen_blit_kms.c +++ b/trunk/drivers/gpu/drm/radeon/evergreen_blit_kms.c @@ -252,7 +252,7 @@ draw_auto(struct radeon_device *rdev) } -/* emits 39 */ +/* emits 36 */ static void set_default_state(struct radeon_device *rdev) { @@ -531,11 +531,6 @@ set_default_state(struct radeon_device *rdev) radeon_ring_write(rdev, (SQ_DYN_GPR_CNTL_PS_FLUSH_REQ - PACKET3_SET_CONFIG_REG_START) >> 2); radeon_ring_write(rdev, 0); - /* setup LDS */ - radeon_ring_write(rdev, PACKET3(PACKET3_SET_CONFIG_REG, 1)); - radeon_ring_write(rdev, (SQ_LDS_RESOURCE_MGMT - PACKET3_SET_CONFIG_REG_START) >> 2); - radeon_ring_write(rdev, 0x10001000); - /* SQ config */ radeon_ring_write(rdev, PACKET3(PACKET3_SET_CONFIG_REG, 11)); radeon_ring_write(rdev, (SQ_CONFIG - PACKET3_SET_CONFIG_REG_START) >> 2); @@ -778,7 +773,7 @@ int evergreen_blit_prepare_copy(struct radeon_device *rdev, int size_bytes) /* calculate number of loops correctly */ ring_size = num_loops * dwords_per_loop; /* set default + shaders */ - ring_size += 55; /* shaders + def state */ + ring_size += 52; /* shaders + def state */ ring_size += 10; /* fence emit for VB IB */ ring_size += 5; /* done copy */ ring_size += 10; /* fence emit for done copy */ diff --git a/trunk/drivers/gpu/drm/radeon/evergreend.h b/trunk/drivers/gpu/drm/radeon/evergreend.h index b7b2714f0b32..1636e3449825 100644 --- a/trunk/drivers/gpu/drm/radeon/evergreend.h +++ b/trunk/drivers/gpu/drm/radeon/evergreend.h @@ -466,7 +466,7 @@ #define IH_RB_WPTR_ADDR_LO 0x3e14 #define IH_CNTL 0x3e18 # define ENABLE_INTR (1 << 0) -# define IH_MC_SWAP(x) ((x) << 1) +# define IH_MC_SWAP(x) ((x) << 2) # define IH_MC_SWAP_NONE 0 # define IH_MC_SWAP_16BIT 1 # define IH_MC_SWAP_32BIT 2 @@ -547,7 +547,7 @@ # define LB_D5_VBLANK_INTERRUPT (1 << 3) # define DC_HPD5_INTERRUPT (1 << 17) # define DC_HPD5_RX_INTERRUPT (1 << 18) -#define DISP_INTERRUPT_STATUS_CONTINUE5 0x6150 +#define DISP_INTERRUPT_STATUS_CONTINUE5 0x6050 # define LB_D6_VLINE_INTERRUPT (1 << 2) # define LB_D6_VBLANK_INTERRUPT (1 << 3) # define DC_HPD6_INTERRUPT (1 << 17) diff --git a/trunk/drivers/gpu/drm/radeon/ni.c b/trunk/drivers/gpu/drm/radeon/ni.c index 559dbd412906..16caafeadf5e 100644 --- a/trunk/drivers/gpu/drm/radeon/ni.c +++ b/trunk/drivers/gpu/drm/radeon/ni.c @@ -1581,7 +1581,6 @@ void cayman_fini(struct radeon_device *rdev) cayman_cp_fini(rdev); r600_irq_fini(rdev); radeon_wb_fini(rdev); - radeon_ib_pool_fini(rdev); radeon_irq_kms_fini(rdev); cayman_pcie_gart_fini(rdev); radeon_gem_fini(rdev); diff --git a/trunk/drivers/gpu/drm/radeon/nid.h b/trunk/drivers/gpu/drm/radeon/nid.h index 4672869cdb26..9736746da2d6 100644 --- a/trunk/drivers/gpu/drm/radeon/nid.h +++ b/trunk/drivers/gpu/drm/radeon/nid.h @@ -320,7 +320,7 @@ #define CGTS_USER_TCC_DISABLE 0x914C #define TCC_DISABLE_MASK 0xFFFF0000 #define TCC_DISABLE_SHIFT 16 -#define CGTS_SM_CTRL_REG 0x9150 +#define CGTS_SM_CTRL_REG 0x915C #define OVERRIDE (1 << 21) #define TA_CNTL_AUX 0x9508 diff --git a/trunk/drivers/gpu/drm/radeon/r600.c b/trunk/drivers/gpu/drm/radeon/r600.c index bc54b26cb32f..f79d2ccb6755 100644 --- a/trunk/drivers/gpu/drm/radeon/r600.c +++ b/trunk/drivers/gpu/drm/radeon/r600.c @@ -2628,7 +2628,6 @@ void r600_fini(struct radeon_device *rdev) r600_cp_fini(rdev); r600_irq_fini(rdev); radeon_wb_fini(rdev); - radeon_ib_pool_fini(rdev); radeon_irq_kms_fini(rdev); r600_pcie_gart_fini(rdev); radeon_agp_fini(rdev); diff --git a/trunk/drivers/gpu/drm/radeon/r600d.h b/trunk/drivers/gpu/drm/radeon/r600d.h index 0245ae6c204e..f140a0d5cb54 100644 --- a/trunk/drivers/gpu/drm/radeon/r600d.h +++ b/trunk/drivers/gpu/drm/radeon/r600d.h @@ -536,7 +536,7 @@ #define IH_RB_WPTR_ADDR_LO 0x3e14 #define IH_CNTL 0x3e18 # define ENABLE_INTR (1 << 0) -# define IH_MC_SWAP(x) ((x) << 1) +# define IH_MC_SWAP(x) ((x) << 2) # define IH_MC_SWAP_NONE 0 # define IH_MC_SWAP_16BIT 1 # define IH_MC_SWAP_32BIT 2 diff --git a/trunk/drivers/gpu/drm/radeon/radeon.h b/trunk/drivers/gpu/drm/radeon/radeon.h index ef0e0e016914..27f45579e64b 100644 --- a/trunk/drivers/gpu/drm/radeon/radeon.h +++ b/trunk/drivers/gpu/drm/radeon/radeon.h @@ -179,7 +179,6 @@ void radeon_pm_resume(struct radeon_device *rdev); void radeon_combios_get_power_modes(struct radeon_device *rdev); void radeon_atombios_get_power_modes(struct radeon_device *rdev); void radeon_atom_set_voltage(struct radeon_device *rdev, u16 voltage_level, u8 voltage_type); -int radeon_atom_get_max_vddc(struct radeon_device *rdev, u16 *voltage); void rs690_pm_info(struct radeon_device *rdev); extern int rv6xx_get_temp(struct radeon_device *rdev); extern int rv770_get_temp(struct radeon_device *rdev); diff --git a/trunk/drivers/gpu/drm/radeon/radeon_atombios.c b/trunk/drivers/gpu/drm/radeon/radeon_atombios.c index bf2b61584cdb..1e725d9f767f 100644 --- a/trunk/drivers/gpu/drm/radeon/radeon_atombios.c +++ b/trunk/drivers/gpu/drm/radeon/radeon_atombios.c @@ -2320,14 +2320,6 @@ static bool radeon_atombios_parse_pplib_clock_info(struct radeon_device *rdev, le16_to_cpu(clock_info->r600.usVDDC); } - /* patch up vddc if necessary */ - if (rdev->pm.power_state[state_index].clock_info[mode_index].voltage.voltage == 0xff01) { - u16 vddc; - - if (radeon_atom_get_max_vddc(rdev, &vddc) == 0) - rdev->pm.power_state[state_index].clock_info[mode_index].voltage.voltage = vddc; - } - if (rdev->flags & RADEON_IS_IGP) { /* skip invalid modes */ if (rdev->pm.power_state[state_index].clock_info[mode_index].sclk == 0) @@ -2638,35 +2630,7 @@ void radeon_atom_set_voltage(struct radeon_device *rdev, u16 voltage_level, u8 v atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args); } -int radeon_atom_get_max_vddc(struct radeon_device *rdev, - u16 *voltage) -{ - union set_voltage args; - int index = GetIndexIntoMasterTable(COMMAND, SetVoltage); - u8 frev, crev; - - if (!atom_parse_cmd_header(rdev->mode_info.atom_context, index, &frev, &crev)) - return -EINVAL; - - switch (crev) { - case 1: - return -EINVAL; - case 2: - args.v2.ucVoltageType = SET_VOLTAGE_GET_MAX_VOLTAGE; - args.v2.ucVoltageMode = 0; - args.v2.usVoltageLevel = 0; - - atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args); - - *voltage = le16_to_cpu(args.v2.usVoltageLevel); - break; - default: - DRM_ERROR("Unknown table version %d, %d\n", frev, crev); - return -EINVAL; - } - return 0; -} void radeon_atom_initialize_bios_scratch_regs(struct drm_device *dev) { diff --git a/trunk/drivers/gpu/drm/radeon/radeon_bios.c b/trunk/drivers/gpu/drm/radeon/radeon_bios.c index 229a20f10e2b..1aba85cad1a8 100644 --- a/trunk/drivers/gpu/drm/radeon/radeon_bios.c +++ b/trunk/drivers/gpu/drm/radeon/radeon_bios.c @@ -104,7 +104,7 @@ static bool radeon_read_bios(struct radeon_device *rdev) static bool radeon_atrm_get_bios(struct radeon_device *rdev) { int ret; - int size = 256 * 1024; + int size = 64 * 1024; int i; if (!radeon_atrm_supported(rdev->pdev)) @@ -331,7 +331,7 @@ static bool avivo_read_disabled_bios(struct radeon_device *rdev) seprom_cntl1 = RREG32(RADEON_SEPROM_CNTL1); viph_control = RREG32(RADEON_VIPH_CONTROL); - bus_cntl = RREG32(RV370_BUS_CNTL); + bus_cntl = RREG32(RADEON_BUS_CNTL); d1vga_control = RREG32(AVIVO_D1VGA_CONTROL); d2vga_control = RREG32(AVIVO_D2VGA_CONTROL); vga_render_control = RREG32(AVIVO_VGA_RENDER_CONTROL); @@ -350,7 +350,7 @@ static bool avivo_read_disabled_bios(struct radeon_device *rdev) WREG32(RADEON_VIPH_CONTROL, (viph_control & ~RADEON_VIPH_EN)); /* enable the rom */ - WREG32(RV370_BUS_CNTL, (bus_cntl & ~RV370_BUS_BIOS_DIS_ROM)); + WREG32(RADEON_BUS_CNTL, (bus_cntl & ~RADEON_BUS_BIOS_DIS_ROM)); /* Disable VGA mode */ WREG32(AVIVO_D1VGA_CONTROL, @@ -367,7 +367,7 @@ static bool avivo_read_disabled_bios(struct radeon_device *rdev) /* restore regs */ WREG32(RADEON_SEPROM_CNTL1, seprom_cntl1); WREG32(RADEON_VIPH_CONTROL, viph_control); - WREG32(RV370_BUS_CNTL, bus_cntl); + WREG32(RADEON_BUS_CNTL, bus_cntl); WREG32(AVIVO_D1VGA_CONTROL, d1vga_control); WREG32(AVIVO_D2VGA_CONTROL, d2vga_control); WREG32(AVIVO_VGA_RENDER_CONTROL, vga_render_control); @@ -390,10 +390,7 @@ static bool legacy_read_disabled_bios(struct radeon_device *rdev) seprom_cntl1 = RREG32(RADEON_SEPROM_CNTL1); viph_control = RREG32(RADEON_VIPH_CONTROL); - if (rdev->flags & RADEON_IS_PCIE) - bus_cntl = RREG32(RV370_BUS_CNTL); - else - bus_cntl = RREG32(RADEON_BUS_CNTL); + bus_cntl = RREG32(RADEON_BUS_CNTL); crtc_gen_cntl = RREG32(RADEON_CRTC_GEN_CNTL); crtc2_gen_cntl = 0; crtc_ext_cntl = RREG32(RADEON_CRTC_EXT_CNTL); @@ -415,10 +412,7 @@ static bool legacy_read_disabled_bios(struct radeon_device *rdev) WREG32(RADEON_VIPH_CONTROL, (viph_control & ~RADEON_VIPH_EN)); /* enable the rom */ - if (rdev->flags & RADEON_IS_PCIE) - WREG32(RV370_BUS_CNTL, (bus_cntl & ~RV370_BUS_BIOS_DIS_ROM)); - else - WREG32(RADEON_BUS_CNTL, (bus_cntl & ~RADEON_BUS_BIOS_DIS_ROM)); + WREG32(RADEON_BUS_CNTL, (bus_cntl & ~RADEON_BUS_BIOS_DIS_ROM)); /* Turn off mem requests and CRTC for both controllers */ WREG32(RADEON_CRTC_GEN_CNTL, @@ -445,10 +439,7 @@ static bool legacy_read_disabled_bios(struct radeon_device *rdev) /* restore regs */ WREG32(RADEON_SEPROM_CNTL1, seprom_cntl1); WREG32(RADEON_VIPH_CONTROL, viph_control); - if (rdev->flags & RADEON_IS_PCIE) - WREG32(RV370_BUS_CNTL, bus_cntl); - else - WREG32(RADEON_BUS_CNTL, bus_cntl); + WREG32(RADEON_BUS_CNTL, bus_cntl); WREG32(RADEON_CRTC_GEN_CNTL, crtc_gen_cntl); if (!(rdev->flags & RADEON_SINGLE_CRTC)) { WREG32(RADEON_CRTC2_GEN_CNTL, crtc2_gen_cntl); diff --git a/trunk/drivers/gpu/drm/radeon/radeon_connectors.c b/trunk/drivers/gpu/drm/radeon/radeon_connectors.c index 9792d4ffdc86..cbfca3a24fdf 100644 --- a/trunk/drivers/gpu/drm/radeon/radeon_connectors.c +++ b/trunk/drivers/gpu/drm/radeon/radeon_connectors.c @@ -52,12 +52,6 @@ void radeon_connector_hotplug(struct drm_connector *connector) struct radeon_device *rdev = dev->dev_private; struct radeon_connector *radeon_connector = to_radeon_connector(connector); - /* bail if the connector does not have hpd pin, e.g., - * VGA, TV, etc. - */ - if (radeon_connector->hpd.hpd == RADEON_HPD_NONE) - return; - radeon_hpd_set_polarity(rdev, radeon_connector->hpd.hpd); /* powering up/down the eDP panel generates hpd events which diff --git a/trunk/drivers/gpu/drm/radeon/radeon_reg.h b/trunk/drivers/gpu/drm/radeon/radeon_reg.h index bc44a3d35ec6..ec93a75369e6 100644 --- a/trunk/drivers/gpu/drm/radeon/radeon_reg.h +++ b/trunk/drivers/gpu/drm/radeon/radeon_reg.h @@ -300,8 +300,6 @@ # define RADEON_BUS_READ_BURST (1 << 30) #define RADEON_BUS_CNTL1 0x0034 # define RADEON_BUS_WAIT_ON_LOCK_EN (1 << 4) -#define RV370_BUS_CNTL 0x004c -# define RV370_BUS_BIOS_DIS_ROM (1 << 2) /* rv370/rv380, rv410, r423/r430/r480, r5xx */ #define RADEON_MSI_REARM_EN 0x0160 # define RV370_MSI_REARM_EN (1 << 0) diff --git a/trunk/drivers/gpu/drm/radeon/rs600.c b/trunk/drivers/gpu/drm/radeon/rs600.c index 1f5850e473cc..6e3b11e5abbe 100644 --- a/trunk/drivers/gpu/drm/radeon/rs600.c +++ b/trunk/drivers/gpu/drm/radeon/rs600.c @@ -426,7 +426,7 @@ int rs600_gart_init(struct radeon_device *rdev) return radeon_gart_table_vram_alloc(rdev); } -static int rs600_gart_enable(struct radeon_device *rdev) +int rs600_gart_enable(struct radeon_device *rdev) { u32 tmp; int r, i; @@ -440,8 +440,8 @@ static int rs600_gart_enable(struct radeon_device *rdev) return r; radeon_gart_restore(rdev); /* Enable bus master */ - tmp = RREG32(RADEON_BUS_CNTL) & ~RS600_BUS_MASTER_DIS; - WREG32(RADEON_BUS_CNTL, tmp); + tmp = RREG32(R_00004C_BUS_CNTL) & C_00004C_BUS_MASTER_DIS; + WREG32(R_00004C_BUS_CNTL, tmp); /* FIXME: setup default page */ WREG32_MC(R_000100_MC_PT0_CNTL, (S_000100_EFFECTIVE_L2_CACHE_SIZE(6) | diff --git a/trunk/drivers/gpu/drm/radeon/rv770.c b/trunk/drivers/gpu/drm/radeon/rv770.c index 4de51891aa6d..6f508ffd1035 100644 --- a/trunk/drivers/gpu/drm/radeon/rv770.c +++ b/trunk/drivers/gpu/drm/radeon/rv770.c @@ -575,12 +575,6 @@ static void rv770_program_channel_remap(struct radeon_device *rdev) else tcp_chan_steer = 0x00fac688; - /* RV770 CE has special chremap setup */ - if (rdev->pdev->device == 0x944e) { - tcp_chan_steer = 0x00b08b08; - mc_shared_chremap = 0x00b08b08; - } - WREG32(TCP_CHAN_STEER, tcp_chan_steer); WREG32(MC_SHARED_CHREMAP, mc_shared_chremap); } @@ -1368,7 +1362,6 @@ void rv770_fini(struct radeon_device *rdev) r700_cp_fini(rdev); r600_irq_fini(rdev); radeon_wb_fini(rdev); - radeon_ib_pool_fini(rdev); radeon_irq_kms_fini(rdev); rv770_pcie_gart_fini(rdev); rv770_vram_scratch_fini(rdev); diff --git a/trunk/drivers/gpu/drm/ttm/ttm_tt.c b/trunk/drivers/gpu/drm/ttm/ttm_tt.c index 58c271ebc0f7..90e23e0bfadb 100644 --- a/trunk/drivers/gpu/drm/ttm/ttm_tt.c +++ b/trunk/drivers/gpu/drm/ttm/ttm_tt.c @@ -31,7 +31,6 @@ #include #include #include -#include #include #include #include @@ -485,7 +484,7 @@ static int ttm_tt_swapin(struct ttm_tt *ttm) swap_space = swap_storage->f_path.dentry->d_inode->i_mapping; for (i = 0; i < ttm->num_pages; ++i) { - from_page = shmem_read_mapping_page(swap_space, i); + from_page = read_mapping_page(swap_space, i, NULL); if (IS_ERR(from_page)) { ret = PTR_ERR(from_page); goto out_err; @@ -558,7 +557,7 @@ int ttm_tt_swapout(struct ttm_tt *ttm, struct file *persistent_swap_storage) from_page = ttm->pages[i]; if (unlikely(from_page == NULL)) continue; - to_page = shmem_read_mapping_page(swap_space, i); + to_page = read_mapping_page(swap_space, i, NULL); if (unlikely(IS_ERR(to_page))) { ret = PTR_ERR(to_page); goto out_err; diff --git a/trunk/drivers/hid/hid-core.c b/trunk/drivers/hid/hid-core.c index 6f3289a57888..f7440e8ce3e7 100644 --- a/trunk/drivers/hid/hid-core.c +++ b/trunk/drivers/hid/hid-core.c @@ -1423,7 +1423,6 @@ static const struct hid_device_id hid_have_special_driver[] = { { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_SPACETRAVELLER) }, { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_SPACENAVIGATOR) }, { HID_USB_DEVICE(USB_VENDOR_ID_LUMIO, USB_DEVICE_ID_CRYSTALTOUCH) }, - { HID_USB_DEVICE(USB_VENDOR_ID_LUMIO, USB_DEVICE_ID_CRYSTALTOUCH_DUAL) }, { HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICOLCD) }, { HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICOLCD_BOOTLOADER) }, { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_SIDEWINDER_GV) }, diff --git a/trunk/drivers/hid/hid-ids.h b/trunk/drivers/hid/hid-ids.h index a756ee6c7df5..aecb5a4b8d6d 100644 --- a/trunk/drivers/hid/hid-ids.h +++ b/trunk/drivers/hid/hid-ids.h @@ -449,7 +449,6 @@ #define USB_VENDOR_ID_LUMIO 0x202e #define USB_DEVICE_ID_CRYSTALTOUCH 0x0006 -#define USB_DEVICE_ID_CRYSTALTOUCH_DUAL 0x0007 #define USB_VENDOR_ID_MCC 0x09db #define USB_DEVICE_ID_MCC_PMD1024LS 0x0076 diff --git a/trunk/drivers/hid/hid-multitouch.c b/trunk/drivers/hid/hid-multitouch.c index 62cac4dc3b62..0b2dcd0ee591 100644 --- a/trunk/drivers/hid/hid-multitouch.c +++ b/trunk/drivers/hid/hid-multitouch.c @@ -271,8 +271,6 @@ static int mt_input_mapping(struct hid_device *hdev, struct hid_input *hi, } return 1; case HID_DG_CONTACTID: - if (!td->maxcontacts) - td->maxcontacts = MT_DEFAULT_MAXCONTACT; input_mt_init_slots(hi->input, td->maxcontacts); td->last_slot_field = usage->hid; td->last_field_index = field->index; @@ -549,6 +547,9 @@ static int mt_probe(struct hid_device *hdev, const struct hid_device_id *id) if (ret) goto fail; + if (!td->maxcontacts) + td->maxcontacts = MT_DEFAULT_MAXCONTACT; + td->slots = kzalloc(td->maxcontacts * sizeof(struct mt_slot), GFP_KERNEL); if (!td->slots) { @@ -676,9 +677,6 @@ static const struct hid_device_id mt_devices[] = { { .driver_data = MT_CLS_CONFIDENCE_MINUS_ONE, HID_USB_DEVICE(USB_VENDOR_ID_LUMIO, USB_DEVICE_ID_CRYSTALTOUCH) }, - { .driver_data = MT_CLS_CONFIDENCE_MINUS_ONE, - HID_USB_DEVICE(USB_VENDOR_ID_LUMIO, - USB_DEVICE_ID_CRYSTALTOUCH_DUAL) }, /* MosArt panels */ { .driver_data = MT_CLS_CONFIDENCE_MINUS_ONE, @@ -709,10 +707,10 @@ static const struct hid_device_id mt_devices[] = { HID_USB_DEVICE(USB_VENDOR_ID_STANTUM, USB_DEVICE_ID_MTP)}, { .driver_data = MT_CLS_CONFIDENCE, - HID_USB_DEVICE(USB_VENDOR_ID_STANTUM_STM, + HID_USB_DEVICE(USB_VENDOR_ID_STANTUM, USB_DEVICE_ID_MTP_STM)}, { .driver_data = MT_CLS_CONFIDENCE, - HID_USB_DEVICE(USB_VENDOR_ID_STANTUM_SITRONIX, + HID_USB_DEVICE(USB_VENDOR_ID_STANTUM, USB_DEVICE_ID_MTP_SITRONIX)}, /* Touch International panels */ diff --git a/trunk/drivers/hwmon/Kconfig b/trunk/drivers/hwmon/Kconfig index 5f888f7e7dcb..16db83c83c8b 100644 --- a/trunk/drivers/hwmon/Kconfig +++ b/trunk/drivers/hwmon/Kconfig @@ -333,7 +333,7 @@ config SENSORS_F71882FG F71858FG F71862FG F71863FG - F71869F/E/A + F71869F/E F71882FG F71883FG F71889FG/ED/A diff --git a/trunk/drivers/hwmon/adm1275.c b/trunk/drivers/hwmon/adm1275.c index b9b7caf4a1d2..c2ee2048ab91 100644 --- a/trunk/drivers/hwmon/adm1275.c +++ b/trunk/drivers/hwmon/adm1275.c @@ -32,7 +32,6 @@ static int adm1275_probe(struct i2c_client *client, const struct i2c_device_id *id) { int config; - int ret; struct pmbus_driver_info *info; if (!i2c_check_functionality(client->adapter, @@ -44,10 +43,8 @@ static int adm1275_probe(struct i2c_client *client, return -ENOMEM; config = i2c_smbus_read_byte_data(client, ADM1275_PMON_CONFIG); - if (config < 0) { - ret = config; - goto err_mem; - } + if (config < 0) + return config; info->pages = 1; info->direct[PSC_VOLTAGE_IN] = true; @@ -79,14 +76,7 @@ static int adm1275_probe(struct i2c_client *client, else info->func[0] |= PMBUS_HAVE_VIN | PMBUS_HAVE_STATUS_INPUT; - ret = pmbus_do_probe(client, id, info); - if (ret) - goto err_mem; - return 0; - -err_mem: - kfree(info); - return ret; + return pmbus_do_probe(client, id, info); } static int adm1275_remove(struct i2c_client *client) diff --git a/trunk/drivers/hwmon/emc6w201.c b/trunk/drivers/hwmon/emc6w201.c index 0064432f361f..e0ef32378ac6 100644 --- a/trunk/drivers/hwmon/emc6w201.c +++ b/trunk/drivers/hwmon/emc6w201.c @@ -78,9 +78,8 @@ static u16 emc6w201_read16(struct i2c_client *client, u8 reg) lsb = i2c_smbus_read_byte_data(client, reg); msb = i2c_smbus_read_byte_data(client, reg + 1); - if (unlikely(lsb < 0 || msb < 0)) { - dev_err(&client->dev, "%d-bit %s failed at 0x%02x\n", - 16, "read", reg); + if (lsb < 0 || msb < 0) { + dev_err(&client->dev, "16-bit read failed at 0x%02x\n", reg); return 0xFFFF; /* Arbitrary value */ } @@ -96,39 +95,10 @@ static int emc6w201_write16(struct i2c_client *client, u8 reg, u16 val) int err; err = i2c_smbus_write_byte_data(client, reg, val & 0xff); - if (likely(!err)) + if (!err) err = i2c_smbus_write_byte_data(client, reg + 1, val >> 8); - if (unlikely(err < 0)) - dev_err(&client->dev, "%d-bit %s failed at 0x%02x\n", - 16, "write", reg); - - return err; -} - -/* Read 8-bit value from register */ -static u8 emc6w201_read8(struct i2c_client *client, u8 reg) -{ - int val; - - val = i2c_smbus_read_byte_data(client, reg); - if (unlikely(val < 0)) { - dev_err(&client->dev, "%d-bit %s failed at 0x%02x\n", - 8, "read", reg); - return 0x00; /* Arbitrary value */ - } - - return val; -} - -/* Write 8-bit value to register */ -static int emc6w201_write8(struct i2c_client *client, u8 reg, u8 val) -{ - int err; - - err = i2c_smbus_write_byte_data(client, reg, val); - if (unlikely(err < 0)) - dev_err(&client->dev, "%d-bit %s failed at 0x%02x\n", - 8, "write", reg); + if (err < 0) + dev_err(&client->dev, "16-bit write failed at 0x%02x\n", reg); return err; } @@ -144,25 +114,25 @@ static struct emc6w201_data *emc6w201_update_device(struct device *dev) if (time_after(jiffies, data->last_updated + HZ) || !data->valid) { for (nr = 0; nr < 6; nr++) { data->in[input][nr] = - emc6w201_read8(client, + i2c_smbus_read_byte_data(client, EMC6W201_REG_IN(nr)); data->in[min][nr] = - emc6w201_read8(client, + i2c_smbus_read_byte_data(client, EMC6W201_REG_IN_LOW(nr)); data->in[max][nr] = - emc6w201_read8(client, + i2c_smbus_read_byte_data(client, EMC6W201_REG_IN_HIGH(nr)); } for (nr = 0; nr < 6; nr++) { data->temp[input][nr] = - emc6w201_read8(client, + i2c_smbus_read_byte_data(client, EMC6W201_REG_TEMP(nr)); data->temp[min][nr] = - emc6w201_read8(client, + i2c_smbus_read_byte_data(client, EMC6W201_REG_TEMP_LOW(nr)); data->temp[max][nr] = - emc6w201_read8(client, + i2c_smbus_read_byte_data(client, EMC6W201_REG_TEMP_HIGH(nr)); } @@ -222,7 +192,7 @@ static ssize_t set_in(struct device *dev, struct device_attribute *devattr, mutex_lock(&data->update_lock); data->in[sf][nr] = SENSORS_LIMIT(val, 0, 255); - err = emc6w201_write8(client, reg, data->in[sf][nr]); + err = i2c_smbus_write_byte_data(client, reg, data->in[sf][nr]); mutex_unlock(&data->update_lock); return err < 0 ? err : count; @@ -259,7 +229,7 @@ static ssize_t set_temp(struct device *dev, struct device_attribute *devattr, mutex_lock(&data->update_lock); data->temp[sf][nr] = SENSORS_LIMIT(val, -127, 128); - err = emc6w201_write8(client, reg, data->temp[sf][nr]); + err = i2c_smbus_write_byte_data(client, reg, data->temp[sf][nr]); mutex_unlock(&data->update_lock); return err < 0 ? err : count; @@ -474,7 +444,7 @@ static int emc6w201_detect(struct i2c_client *client, /* Check configuration */ config = i2c_smbus_read_byte_data(client, EMC6W201_REG_CONFIG); - if (config < 0 || (config & 0xF4) != 0x04) + if ((config & 0xF4) != 0x04) return -ENODEV; if (!(config & 0x01)) { dev_err(&client->dev, "Monitoring not enabled\n"); diff --git a/trunk/drivers/hwmon/f71882fg.c b/trunk/drivers/hwmon/f71882fg.c index 2d96ed2bf8ed..a4a94a096c90 100644 --- a/trunk/drivers/hwmon/f71882fg.c +++ b/trunk/drivers/hwmon/f71882fg.c @@ -52,7 +52,6 @@ #define SIO_F71858_ID 0x0507 /* Chipset ID */ #define SIO_F71862_ID 0x0601 /* Chipset ID */ #define SIO_F71869_ID 0x0814 /* Chipset ID */ -#define SIO_F71869A_ID 0x1007 /* Chipset ID */ #define SIO_F71882_ID 0x0541 /* Chipset ID */ #define SIO_F71889_ID 0x0723 /* Chipset ID */ #define SIO_F71889E_ID 0x0909 /* Chipset ID */ @@ -109,8 +108,8 @@ static unsigned short force_id; module_param(force_id, ushort, 0); MODULE_PARM_DESC(force_id, "Override the detected device ID"); -enum chips { f71808e, f71808a, f71858fg, f71862fg, f71869, f71869a, f71882fg, - f71889fg, f71889ed, f71889a, f8000, f81865f }; +enum chips { f71808e, f71808a, f71858fg, f71862fg, f71869, f71882fg, f71889fg, + f71889ed, f71889a, f8000, f81865f }; static const char *f71882fg_names[] = { "f71808e", @@ -118,7 +117,6 @@ static const char *f71882fg_names[] = { "f71858fg", "f71862fg", "f71869", /* Both f71869f and f71869e, reg. compatible and same id */ - "f71869a", "f71882fg", "f71889fg", /* f81801u too, same id */ "f71889ed", @@ -133,7 +131,6 @@ static const char f71882fg_has_in[][F71882FG_MAX_INS] = { [f71858fg] = { 1, 1, 1, 0, 0, 0, 0, 0, 0 }, [f71862fg] = { 1, 1, 1, 1, 1, 1, 1, 1, 1 }, [f71869] = { 1, 1, 1, 1, 1, 1, 1, 1, 1 }, - [f71869a] = { 1, 1, 1, 1, 1, 1, 1, 1, 1 }, [f71882fg] = { 1, 1, 1, 1, 1, 1, 1, 1, 1 }, [f71889fg] = { 1, 1, 1, 1, 1, 1, 1, 1, 1 }, [f71889ed] = { 1, 1, 1, 1, 1, 1, 1, 1, 1 }, @@ -148,7 +145,6 @@ static const char f71882fg_has_in1_alarm[] = { [f71858fg] = 0, [f71862fg] = 0, [f71869] = 0, - [f71869a] = 0, [f71882fg] = 1, [f71889fg] = 1, [f71889ed] = 1, @@ -163,7 +159,6 @@ static const char f71882fg_fan_has_beep[] = { [f71858fg] = 0, [f71862fg] = 1, [f71869] = 1, - [f71869a] = 1, [f71882fg] = 1, [f71889fg] = 1, [f71889ed] = 1, @@ -178,7 +173,6 @@ static const char f71882fg_nr_fans[] = { [f71858fg] = 3, [f71862fg] = 3, [f71869] = 3, - [f71869a] = 3, [f71882fg] = 4, [f71889fg] = 3, [f71889ed] = 3, @@ -193,7 +187,6 @@ static const char f71882fg_temp_has_beep[] = { [f71858fg] = 0, [f71862fg] = 1, [f71869] = 1, - [f71869a] = 1, [f71882fg] = 1, [f71889fg] = 1, [f71889ed] = 1, @@ -208,7 +201,6 @@ static const char f71882fg_nr_temps[] = { [f71858fg] = 3, [f71862fg] = 3, [f71869] = 3, - [f71869a] = 3, [f71882fg] = 3, [f71889fg] = 3, [f71889ed] = 3, @@ -2251,7 +2243,6 @@ static int __devinit f71882fg_probe(struct platform_device *pdev) case f71808e: case f71808a: case f71869: - case f71869a: /* These always have signed auto point temps */ data->auto_point_temp_signed = 1; /* Fall through to select correct fan/pwm reg bank! */ @@ -2314,7 +2305,6 @@ static int __devinit f71882fg_probe(struct platform_device *pdev) case f71808e: case f71808a: case f71869: - case f71869a: case f71889fg: case f71889ed: case f71889a: @@ -2538,9 +2528,6 @@ static int __init f71882fg_find(int sioaddr, unsigned short *address, case SIO_F71869_ID: sio_data->type = f71869; break; - case SIO_F71869A_ID: - sio_data->type = f71869a; - break; case SIO_F71882_ID: sio_data->type = f71882fg; break; @@ -2675,7 +2662,7 @@ static void __exit f71882fg_exit(void) } MODULE_DESCRIPTION("F71882FG Hardware Monitoring Driver"); -MODULE_AUTHOR("Hans Edgington, Hans de Goede "); +MODULE_AUTHOR("Hans Edgington, Hans de Goede (hdegoede@redhat.com)"); MODULE_LICENSE("GPL"); module_init(f71882fg_init); diff --git a/trunk/drivers/hwmon/hwmon-vid.c b/trunk/drivers/hwmon/hwmon-vid.c index c8195a077da3..2582bfef6ccb 100644 --- a/trunk/drivers/hwmon/hwmon-vid.c +++ b/trunk/drivers/hwmon/hwmon-vid.c @@ -202,7 +202,7 @@ static struct vrm_model vrm_models[] = { {X86_VENDOR_CENTAUR, 0x6, 0x7, ANY, 85}, /* Eden ESP/Ezra */ {X86_VENDOR_CENTAUR, 0x6, 0x8, 0x7, 85}, /* Ezra T */ - {X86_VENDOR_CENTAUR, 0x6, 0x9, 0x7, 85}, /* Nehemiah */ + {X86_VENDOR_CENTAUR, 0x6, 0x9, 0x7, 85}, /* Nemiah */ {X86_VENDOR_CENTAUR, 0x6, 0x9, ANY, 17}, /* C3-M, Eden-N */ {X86_VENDOR_CENTAUR, 0x6, 0xA, 0x7, 0}, /* No information */ {X86_VENDOR_CENTAUR, 0x6, 0xA, ANY, 13}, /* C7, Esther */ diff --git a/trunk/drivers/hwmon/lm95241.c b/trunk/drivers/hwmon/lm95241.c index d3b464b74ced..1a6dfb6df1e7 100644 --- a/trunk/drivers/hwmon/lm95241.c +++ b/trunk/drivers/hwmon/lm95241.c @@ -98,16 +98,11 @@ struct lm95241_data { }; /* Conversions */ -static int temp_from_reg_signed(u8 val_h, u8 val_l) +static int TempFromReg(u8 val_h, u8 val_l) { - s16 val_hl = (val_h << 8) | val_l; - return val_hl * 1000 / 256; -} - -static int temp_from_reg_unsigned(u8 val_h, u8 val_l) -{ - u16 val_hl = (val_h << 8) | val_l; - return val_hl * 1000 / 256; + if (val_h & 0x80) + return val_h - 0x100; + return val_h * 1000 + val_l * 1000 / 256; } static struct lm95241_data *lm95241_update_device(struct device *dev) @@ -140,13 +135,10 @@ static ssize_t show_input(struct device *dev, struct device_attribute *attr, char *buf) { struct lm95241_data *data = lm95241_update_device(dev); - int index = to_sensor_dev_attr(attr)->index; return snprintf(buf, PAGE_SIZE - 1, "%d\n", - index == 0 || (data->config & (1 << (index / 2))) ? - temp_from_reg_signed(data->temp[index], data->temp[index + 1]) : - temp_from_reg_unsigned(data->temp[index], - data->temp[index + 1])); + TempFromReg(data->temp[to_sensor_dev_attr(attr)->index], + data->temp[to_sensor_dev_attr(attr)->index + 1])); } static ssize_t show_type(struct device *dev, struct device_attribute *attr, @@ -347,7 +339,7 @@ static int lm95241_detect(struct i2c_client *new_client, if ((i2c_smbus_read_byte_data(new_client, LM95241_REG_R_MAN_ID) == MANUFACTURER_ID) && (i2c_smbus_read_byte_data(new_client, LM95241_REG_R_CHIP_ID) - == DEFAULT_REVISION)) { + >= DEFAULT_REVISION)) { name = DEVNAME; } else { dev_dbg(&adapter->dev, "LM95241 detection failed at 0x%02x\n", diff --git a/trunk/drivers/hwmon/pmbus.c b/trunk/drivers/hwmon/pmbus.c index 9b1f0c37ef77..98e2e28899e2 100644 --- a/trunk/drivers/hwmon/pmbus.c +++ b/trunk/drivers/hwmon/pmbus.c @@ -47,29 +47,22 @@ static void pmbus_find_sensor_groups(struct i2c_client *client, if (info->func[0] && pmbus_check_byte_register(client, 0, PMBUS_STATUS_INPUT)) info->func[0] |= PMBUS_HAVE_STATUS_INPUT; - if (pmbus_check_byte_register(client, 0, PMBUS_FAN_CONFIG_12) && - pmbus_check_word_register(client, 0, PMBUS_READ_FAN_SPEED_1)) { + if (pmbus_check_word_register(client, 0, PMBUS_READ_FAN_SPEED_1)) { info->func[0] |= PMBUS_HAVE_FAN12; if (pmbus_check_byte_register(client, 0, PMBUS_STATUS_FAN_12)) info->func[0] |= PMBUS_HAVE_STATUS_FAN12; } - if (pmbus_check_byte_register(client, 0, PMBUS_FAN_CONFIG_34) && - pmbus_check_word_register(client, 0, PMBUS_READ_FAN_SPEED_3)) { + if (pmbus_check_word_register(client, 0, PMBUS_READ_FAN_SPEED_3)) { info->func[0] |= PMBUS_HAVE_FAN34; if (pmbus_check_byte_register(client, 0, PMBUS_STATUS_FAN_34)) info->func[0] |= PMBUS_HAVE_STATUS_FAN34; } - if (pmbus_check_word_register(client, 0, PMBUS_READ_TEMPERATURE_1)) + if (pmbus_check_word_register(client, 0, PMBUS_READ_TEMPERATURE_1)) { info->func[0] |= PMBUS_HAVE_TEMP; - if (pmbus_check_word_register(client, 0, PMBUS_READ_TEMPERATURE_2)) - info->func[0] |= PMBUS_HAVE_TEMP2; - if (pmbus_check_word_register(client, 0, PMBUS_READ_TEMPERATURE_3)) - info->func[0] |= PMBUS_HAVE_TEMP3; - if (info->func[0] & (PMBUS_HAVE_TEMP | PMBUS_HAVE_TEMP2 - | PMBUS_HAVE_TEMP3) - && pmbus_check_byte_register(client, 0, - PMBUS_STATUS_TEMPERATURE)) + if (pmbus_check_byte_register(client, 0, + PMBUS_STATUS_TEMPERATURE)) info->func[0] |= PMBUS_HAVE_STATUS_TEMP; + } /* Sensors detected on all pages */ for (page = 0; page < info->pages; page++) { diff --git a/trunk/drivers/hwmon/pmbus_core.c b/trunk/drivers/hwmon/pmbus_core.c index 744672c1f26d..354770ed3186 100644 --- a/trunk/drivers/hwmon/pmbus_core.c +++ b/trunk/drivers/hwmon/pmbus_core.c @@ -1430,9 +1430,14 @@ int pmbus_do_probe(struct i2c_client *client, const struct i2c_device_id *id, i2c_set_clientdata(client, data); mutex_init(&data->update_lock); - /* Bail out if PMBus status register does not exist. */ - if (i2c_smbus_read_byte_data(client, PMBUS_STATUS_BYTE) < 0) { - dev_err(&client->dev, "PMBus status register not found\n"); + /* + * Bail out if status register or PMBus revision register + * does not exist. + */ + if (i2c_smbus_read_byte_data(client, PMBUS_STATUS_BYTE) < 0 + || i2c_smbus_read_byte_data(client, PMBUS_REVISION) < 0) { + dev_err(&client->dev, + "Status or revision register not found\n"); ret = -ENODEV; goto out_data; } diff --git a/trunk/drivers/hwmon/sch5627.c b/trunk/drivers/hwmon/sch5627.c index 3494a4cce414..020c87273ea1 100644 --- a/trunk/drivers/hwmon/sch5627.c +++ b/trunk/drivers/hwmon/sch5627.c @@ -887,7 +887,7 @@ static void __exit sch5627_exit(void) } MODULE_DESCRIPTION("SMSC SCH5627 Hardware Monitoring Driver"); -MODULE_AUTHOR("Hans de Goede "); +MODULE_AUTHOR("Hans de Goede (hdegoede@redhat.com)"); MODULE_LICENSE("GPL"); module_init(sch5627_init); diff --git a/trunk/drivers/i2c/busses/i2c-bfin-twi.c b/trunk/drivers/i2c/busses/i2c-bfin-twi.c index cbc98aea5b09..52b545a795f2 100644 --- a/trunk/drivers/i2c/busses/i2c-bfin-twi.c +++ b/trunk/drivers/i2c/busses/i2c-bfin-twi.c @@ -193,13 +193,7 @@ static void bfin_twi_handle_interrupt(struct bfin_twi_iface *iface, return; } if (twi_int_status & MCOMP) { - if ((read_MASTER_CTL(iface) & MEN) == 0 && - (iface->cur_mode == TWI_I2C_MODE_REPEAT || - iface->cur_mode == TWI_I2C_MODE_COMBINED)) { - iface->result = -1; - write_INT_MASK(iface, 0); - write_MASTER_CTL(iface, 0); - } else if (iface->cur_mode == TWI_I2C_MODE_COMBINED) { + if (iface->cur_mode == TWI_I2C_MODE_COMBINED) { if (iface->readNum == 0) { /* set the read number to 1 and ask for manual * stop in block combine mode diff --git a/trunk/drivers/i2c/busses/i2c-s3c2410.c b/trunk/drivers/i2c/busses/i2c-s3c2410.c index f84a63c6dd97..6c00c107ebf3 100644 --- a/trunk/drivers/i2c/busses/i2c-s3c2410.c +++ b/trunk/drivers/i2c/busses/i2c-s3c2410.c @@ -248,12 +248,12 @@ static inline int is_msgend(struct s3c24xx_i2c *i2c) return i2c->msg_ptr >= i2c->msg->len; } -/* i2c_s3c_irq_nextbyte +/* i2s_s3c_irq_nextbyte * * process an interrupt and work out what to do */ -static int i2c_s3c_irq_nextbyte(struct s3c24xx_i2c *i2c, unsigned long iicstat) +static int i2s_s3c_irq_nextbyte(struct s3c24xx_i2c *i2c, unsigned long iicstat) { unsigned long tmp; unsigned char byte; @@ -264,6 +264,7 @@ static int i2c_s3c_irq_nextbyte(struct s3c24xx_i2c *i2c, unsigned long iicstat) case STATE_IDLE: dev_err(i2c->dev, "%s: called in STATE_IDLE\n", __func__); goto out; + break; case STATE_STOP: dev_err(i2c->dev, "%s: called in STATE_STOP\n", __func__); @@ -443,7 +444,7 @@ static irqreturn_t s3c24xx_i2c_irq(int irqno, void *dev_id) /* pretty much this leaves us with the fact that we've * transmitted or received whatever byte we last sent */ - i2c_s3c_irq_nextbyte(i2c, status); + i2s_s3c_irq_nextbyte(i2c, status); out: return IRQ_HANDLED; diff --git a/trunk/drivers/i2c/busses/i2c-taos-evm.c b/trunk/drivers/i2c/busses/i2c-taos-evm.c index 26c352a09298..dd39c1eb03ed 100644 --- a/trunk/drivers/i2c/busses/i2c-taos-evm.c +++ b/trunk/drivers/i2c/busses/i2c-taos-evm.c @@ -234,7 +234,7 @@ static int taos_connect(struct serio *serio, struct serio_driver *drv) if (taos->state != TAOS_STATE_IDLE) { err = -ENODEV; - dev_err(&serio->dev, "TAOS EVM reset failed (state=%d, " + dev_dbg(&serio->dev, "TAOS EVM reset failed (state=%d, " "pos=%d)\n", taos->state, taos->pos); goto exit_close; } @@ -255,7 +255,7 @@ static int taos_connect(struct serio *serio, struct serio_driver *drv) msecs_to_jiffies(250)); if (taos->state != TAOS_STATE_IDLE) { err = -ENODEV; - dev_err(&serio->dev, "TAOS EVM echo off failed " + dev_err(&adapter->dev, "Echo off failed " "(state=%d)\n", taos->state); goto exit_close; } @@ -263,7 +263,7 @@ static int taos_connect(struct serio *serio, struct serio_driver *drv) err = i2c_add_adapter(adapter); if (err) goto exit_close; - dev_info(&serio->dev, "Connected to TAOS EVM\n"); + dev_dbg(&serio->dev, "Connected to TAOS EVM\n"); taos->client = taos_instantiate_device(adapter); return 0; @@ -288,7 +288,7 @@ static void taos_disconnect(struct serio *serio) serio_set_drvdata(serio, NULL); kfree(taos); - dev_info(&serio->dev, "Disconnected from TAOS EVM\n"); + dev_dbg(&serio->dev, "Disconnected from TAOS EVM\n"); } static struct serio_device_id taos_serio_ids[] = { diff --git a/trunk/drivers/i2c/busses/i2c-tegra.c b/trunk/drivers/i2c/busses/i2c-tegra.c index fb3b4f8f8152..4d9319665e32 100644 --- a/trunk/drivers/i2c/busses/i2c-tegra.c +++ b/trunk/drivers/i2c/busses/i2c-tegra.c @@ -40,10 +40,8 @@ #define I2C_CNFG_NEW_MASTER_FSM (1<<11) #define I2C_STATUS 0x01C #define I2C_SL_CNFG 0x020 -#define I2C_SL_CNFG_NACK (1<<1) #define I2C_SL_CNFG_NEWSL (1<<2) #define I2C_SL_ADDR1 0x02c -#define I2C_SL_ADDR2 0x030 #define I2C_TX_FIFO 0x050 #define I2C_RX_FIFO 0x054 #define I2C_PACKET_TRANSFER_STATUS 0x058 @@ -339,11 +337,7 @@ static int tegra_i2c_init(struct tegra_i2c_dev *i2c_dev) if (!i2c_dev->is_dvc) { u32 sl_cfg = i2c_readl(i2c_dev, I2C_SL_CNFG); - sl_cfg |= I2C_SL_CNFG_NACK | I2C_SL_CNFG_NEWSL; - i2c_writel(i2c_dev, sl_cfg, I2C_SL_CNFG); - i2c_writel(i2c_dev, 0xfc, I2C_SL_ADDR1); - i2c_writel(i2c_dev, 0x00, I2C_SL_ADDR2); - + i2c_writel(i2c_dev, sl_cfg | I2C_SL_CNFG_NEWSL, I2C_SL_CNFG); } val = 7 << I2C_FIFO_CONTROL_TX_TRIG_SHIFT | diff --git a/trunk/drivers/i2c/muxes/pca954x.c b/trunk/drivers/i2c/muxes/pca954x.c index 6f8953664636..54e1ce73534b 100644 --- a/trunk/drivers/i2c/muxes/pca954x.c +++ b/trunk/drivers/i2c/muxes/pca954x.c @@ -201,11 +201,10 @@ static int pca954x_probe(struct i2c_client *client, i2c_set_clientdata(client, data); - /* Write the mux register at addr to verify - * that the mux is in fact present. This also - * initializes the mux to disconnected state. + /* Read the mux register at addr to verify + * that the mux is in fact present. */ - if (i2c_smbus_write_byte(client, 0) < 0) { + if (i2c_smbus_read_byte(client) < 0) { dev_warn(&client->dev, "probe failed\n"); goto exit_free; } diff --git a/trunk/drivers/ieee802154/Makefile b/trunk/drivers/ieee802154/Makefile index 800a3894af0d..68999137dedf 100644 --- a/trunk/drivers/ieee802154/Makefile +++ b/trunk/drivers/ieee802154/Makefile @@ -1 +1,3 @@ obj-$(CONFIG_IEEE802154_FAKEHARD) += fakehard.o + +ccflags-y := -DDEBUG -DCONFIG_FFD diff --git a/trunk/drivers/ieee802154/fakehard.c b/trunk/drivers/ieee802154/fakehard.c index eb0e2ccc79ae..a5a49a1baae7 100644 --- a/trunk/drivers/ieee802154/fakehard.c +++ b/trunk/drivers/ieee802154/fakehard.c @@ -370,6 +370,8 @@ static int __devinit ieee802154fake_probe(struct platform_device *pdev) return -ENOMEM; } + phy->dev.platform_data = dev; + memcpy(dev->dev_addr, "\xba\xbe\xca\xfe\xde\xad\xbe\xef", dev->addr_len); memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len); diff --git a/trunk/drivers/infiniband/core/cm.c b/trunk/drivers/infiniband/core/cm.c index fc0f2bd9ca82..f62f52fb9ece 100644 --- a/trunk/drivers/infiniband/core/cm.c +++ b/trunk/drivers/infiniband/core/cm.c @@ -3641,8 +3641,7 @@ static struct kobj_type cm_port_obj_type = { static char *cm_devnode(struct device *dev, mode_t *mode) { - if (mode) - *mode = 0666; + *mode = 0666; return kasprintf(GFP_KERNEL, "infiniband/%s", dev_name(dev)); } diff --git a/trunk/drivers/infiniband/core/uverbs_main.c b/trunk/drivers/infiniband/core/uverbs_main.c index 56898b6578a4..e49a85f8a44d 100644 --- a/trunk/drivers/infiniband/core/uverbs_main.c +++ b/trunk/drivers/infiniband/core/uverbs_main.c @@ -826,8 +826,7 @@ static void ib_uverbs_remove_one(struct ib_device *device) static char *uverbs_devnode(struct device *dev, mode_t *mode) { - if (mode) - *mode = 0666; + *mode = 0666; return kasprintf(GFP_KERNEL, "infiniband/%s", dev_name(dev)); } diff --git a/trunk/drivers/infiniband/hw/cxgb4/cm.c b/trunk/drivers/infiniband/hw/cxgb4/cm.c index 31fb44085c9b..f660cd04ec2f 100644 --- a/trunk/drivers/infiniband/hw/cxgb4/cm.c +++ b/trunk/drivers/infiniband/hw/cxgb4/cm.c @@ -1463,9 +1463,9 @@ static int peer_close(struct c4iw_dev *dev, struct sk_buff *skb) struct c4iw_qp_attributes attrs; int disconnect = 1; int release = 0; + int abort = 0; struct tid_info *t = dev->rdev.lldi.tids; unsigned int tid = GET_TID(hdr); - int ret; ep = lookup_tid(t, tid); PDBG("%s ep %p tid %u\n", __func__, ep, ep->hwtid); @@ -1501,12 +1501,10 @@ static int peer_close(struct c4iw_dev *dev, struct sk_buff *skb) start_ep_timer(ep); __state_set(&ep->com, CLOSING); attrs.next_state = C4IW_QP_STATE_CLOSING; - ret = c4iw_modify_qp(ep->com.qp->rhp, ep->com.qp, + abort = c4iw_modify_qp(ep->com.qp->rhp, ep->com.qp, C4IW_QP_ATTR_NEXT_STATE, &attrs, 1); - if (ret != -ECONNRESET) { - peer_close_upcall(ep); - disconnect = 1; - } + peer_close_upcall(ep); + disconnect = 1; break; case ABORTING: disconnect = 0; @@ -2111,16 +2109,15 @@ int c4iw_ep_disconnect(struct c4iw_ep *ep, int abrupt, gfp_t gfp) break; } + mutex_unlock(&ep->com.mutex); if (close) { - if (abrupt) { - close_complete_upcall(ep); - ret = send_abort(ep, NULL, gfp); - } else + if (abrupt) + ret = abort_connection(ep, NULL, gfp); + else ret = send_halfclose(ep, gfp); if (ret) fatal = 1; } - mutex_unlock(&ep->com.mutex); if (fatal) release_ep_resources(ep); return ret; @@ -2304,31 +2301,6 @@ static int fw6_msg(struct c4iw_dev *dev, struct sk_buff *skb) return 0; } -static int peer_abort_intr(struct c4iw_dev *dev, struct sk_buff *skb) -{ - struct cpl_abort_req_rss *req = cplhdr(skb); - struct c4iw_ep *ep; - struct tid_info *t = dev->rdev.lldi.tids; - unsigned int tid = GET_TID(req); - - ep = lookup_tid(t, tid); - if (is_neg_adv_abort(req->status)) { - PDBG("%s neg_adv_abort ep %p tid %u\n", __func__, ep, - ep->hwtid); - kfree_skb(skb); - return 0; - } - PDBG("%s ep %p tid %u state %u\n", __func__, ep, ep->hwtid, - ep->com.state); - - /* - * Wake up any threads in rdma_init() or rdma_fini(). - */ - c4iw_wake_up(&ep->com.wr_wait, -ECONNRESET); - sched(dev, skb); - return 0; -} - /* * Most upcalls from the T4 Core go to sched() to * schedule the processing on a work queue. @@ -2345,7 +2317,7 @@ c4iw_handler_func c4iw_handlers[NUM_CPL_CMDS] = { [CPL_PASS_ESTABLISH] = sched, [CPL_PEER_CLOSE] = sched, [CPL_CLOSE_CON_RPL] = sched, - [CPL_ABORT_REQ_RSS] = peer_abort_intr, + [CPL_ABORT_REQ_RSS] = sched, [CPL_RDMA_TERMINATE] = sched, [CPL_FW4_ACK] = sched, [CPL_SET_TCB_RPL] = set_tcb_rpl, diff --git a/trunk/drivers/infiniband/hw/cxgb4/cq.c b/trunk/drivers/infiniband/hw/cxgb4/cq.c index 1720dc790d13..8d8f8add6fcd 100644 --- a/trunk/drivers/infiniband/hw/cxgb4/cq.c +++ b/trunk/drivers/infiniband/hw/cxgb4/cq.c @@ -801,10 +801,6 @@ struct ib_cq *c4iw_create_cq(struct ib_device *ibdev, int entries, if (ucontext) { memsize = roundup(memsize, PAGE_SIZE); hwentries = memsize / sizeof *chp->cq.queue; - while (hwentries > T4_MAX_IQ_SIZE) { - memsize -= PAGE_SIZE; - hwentries = memsize / sizeof *chp->cq.queue; - } } chp->cq.size = hwentries; chp->cq.memsize = memsize; diff --git a/trunk/drivers/infiniband/hw/cxgb4/mem.c b/trunk/drivers/infiniband/hw/cxgb4/mem.c index 0347eed4a167..273ffe49525a 100644 --- a/trunk/drivers/infiniband/hw/cxgb4/mem.c +++ b/trunk/drivers/infiniband/hw/cxgb4/mem.c @@ -625,7 +625,7 @@ struct ib_mr *c4iw_reg_user_mr(struct ib_pd *pd, u64 start, u64 length, mhp->attr.perms = c4iw_ib_to_tpt_access(acc); mhp->attr.va_fbo = virt; mhp->attr.page_size = shift - 12; - mhp->attr.len = length; + mhp->attr.len = (u32) length; err = register_mem(rhp, php, mhp, shift); if (err) diff --git a/trunk/drivers/infiniband/hw/cxgb4/qp.c b/trunk/drivers/infiniband/hw/cxgb4/qp.c index a41578e48c7b..3b773b05a898 100644 --- a/trunk/drivers/infiniband/hw/cxgb4/qp.c +++ b/trunk/drivers/infiniband/hw/cxgb4/qp.c @@ -1207,8 +1207,11 @@ int c4iw_modify_qp(struct c4iw_dev *rhp, struct c4iw_qp *qhp, c4iw_get_ep(&qhp->ep->com); } ret = rdma_fini(rhp, qhp, ep); - if (ret) + if (ret) { + if (internal) + c4iw_get_ep(&qhp->ep->com); goto err; + } break; case C4IW_QP_STATE_TERMINATE: set_state(qhp, C4IW_QP_STATE_TERMINATE); diff --git a/trunk/drivers/infiniband/hw/qib/qib_iba7322.c b/trunk/drivers/infiniband/hw/qib/qib_iba7322.c index 8ec5237031a0..9f53e68a096a 100644 --- a/trunk/drivers/infiniband/hw/qib/qib_iba7322.c +++ b/trunk/drivers/infiniband/hw/qib/qib_iba7322.c @@ -469,8 +469,6 @@ static u8 ib_rate_to_delay[IB_RATE_120_GBPS + 1] = { #define IB_7322_LT_STATE_RECOVERIDLE 0x0f #define IB_7322_LT_STATE_CFGENH 0x10 #define IB_7322_LT_STATE_CFGTEST 0x11 -#define IB_7322_LT_STATE_CFGWAITRMTTEST 0x12 -#define IB_7322_LT_STATE_CFGWAITENH 0x13 /* link state machine states from IBC */ #define IB_7322_L_STATE_DOWN 0x0 @@ -500,10 +498,8 @@ static const u8 qib_7322_physportstate[0x20] = { IB_PHYSPORTSTATE_LINK_ERR_RECOVER, [IB_7322_LT_STATE_CFGENH] = IB_PHYSPORTSTATE_CFG_ENH, [IB_7322_LT_STATE_CFGTEST] = IB_PHYSPORTSTATE_CFG_TRAIN, - [IB_7322_LT_STATE_CFGWAITRMTTEST] = - IB_PHYSPORTSTATE_CFG_TRAIN, - [IB_7322_LT_STATE_CFGWAITENH] = - IB_PHYSPORTSTATE_CFG_WAIT_ENH, + [0x12] = IB_PHYSPORTSTATE_CFG_TRAIN, + [0x13] = IB_PHYSPORTSTATE_CFG_WAIT_ENH, [0x14] = IB_PHYSPORTSTATE_CFG_TRAIN, [0x15] = IB_PHYSPORTSTATE_CFG_TRAIN, [0x16] = IB_PHYSPORTSTATE_CFG_TRAIN, @@ -1696,9 +1692,7 @@ static void handle_serdes_issues(struct qib_pportdata *ppd, u64 ibcst) break; } - if (((ibclt >= IB_7322_LT_STATE_CFGTEST && - ibclt <= IB_7322_LT_STATE_CFGWAITENH) || - ibclt == IB_7322_LT_STATE_LINKUP) && + if (ibclt == IB_7322_LT_STATE_CFGTEST && (ibcst & SYM_MASK(IBCStatusA_0, LinkSpeedQDR))) { force_h1(ppd); ppd->cpspec->qdr_reforce = 1; @@ -7307,17 +7301,12 @@ static void ibsd_wr_allchans(struct qib_pportdata *ppd, int addr, unsigned data, static void serdes_7322_los_enable(struct qib_pportdata *ppd, int enable) { u64 data = qib_read_kreg_port(ppd, krp_serdesctrl); - u8 state = SYM_FIELD(data, IBSerdesCtrl_0, RXLOSEN); - - if (enable && !state) { - printk(KERN_INFO QIB_DRV_NAME " IB%u:%u Turning LOS on\n", - ppd->dd->unit, ppd->port); + printk(KERN_INFO QIB_DRV_NAME " IB%u:%u Turning LOS %s\n", + ppd->dd->unit, ppd->port, (enable ? "on" : "off")); + if (enable) data |= SYM_MASK(IBSerdesCtrl_0, RXLOSEN); - } else if (!enable && state) { - printk(KERN_INFO QIB_DRV_NAME " IB%u:%u Turning LOS off\n", - ppd->dd->unit, ppd->port); + else data &= ~SYM_MASK(IBSerdesCtrl_0, RXLOSEN); - } qib_write_kreg_port(ppd, krp_serdesctrl, data); } diff --git a/trunk/drivers/infiniband/hw/qib/qib_intr.c b/trunk/drivers/infiniband/hw/qib/qib_intr.c index 6ae57d23004a..a693c56ec8a6 100644 --- a/trunk/drivers/infiniband/hw/qib/qib_intr.c +++ b/trunk/drivers/infiniband/hw/qib/qib_intr.c @@ -96,12 +96,8 @@ void qib_handle_e_ibstatuschanged(struct qib_pportdata *ppd, u64 ibcs) * states, or if it transitions from any of the up (INIT or better) * states into any of the down states (except link recovery), then * call the chip-specific code to take appropriate actions. - * - * ppd->lflags could be 0 if this is the first time the interrupt - * handlers has been called but the link is already up. */ - if (lstate >= IB_PORT_INIT && - (!ppd->lflags || (ppd->lflags & QIBL_LINKDOWN)) && + if (lstate >= IB_PORT_INIT && (ppd->lflags & QIBL_LINKDOWN) && ltstate == IB_PHYSPORTSTATE_LINKUP) { /* transitioned to UP */ if (dd->f_ib_updown(ppd, 1, ibcs)) diff --git a/trunk/drivers/input/keyboard/pmic8xxx-keypad.c b/trunk/drivers/input/keyboard/pmic8xxx-keypad.c index 6229c3e8e78b..40b02ae96f86 100644 --- a/trunk/drivers/input/keyboard/pmic8xxx-keypad.c +++ b/trunk/drivers/input/keyboard/pmic8xxx-keypad.c @@ -520,8 +520,7 @@ static void pmic8xxx_kp_close(struct input_dev *dev) */ static int __devinit pmic8xxx_kp_probe(struct platform_device *pdev) { - const struct pm8xxx_keypad_platform_data *pdata = - dev_get_platdata(&pdev->dev); + const struct pm8xxx_keypad_platform_data *pdata = mfd_get_data(pdev); const struct matrix_keymap_data *keymap_data; struct pmic8xxx_kp *kp; int rc; diff --git a/trunk/drivers/input/misc/pmic8xxx-pwrkey.c b/trunk/drivers/input/misc/pmic8xxx-pwrkey.c index b3cfb9c71e66..97e07e786e41 100644 --- a/trunk/drivers/input/misc/pmic8xxx-pwrkey.c +++ b/trunk/drivers/input/misc/pmic8xxx-pwrkey.c @@ -90,8 +90,7 @@ static int __devinit pmic8xxx_pwrkey_probe(struct platform_device *pdev) unsigned int delay; u8 pon_cntl; struct pmic8xxx_pwrkey *pwrkey; - const struct pm8xxx_pwrkey_platform_data *pdata = - dev_get_platdata(&pdev->dev); + const struct pm8xxx_pwrkey_platform_data *pdata = mfd_get_data(pdev); if (!pdata) { dev_err(&pdev->dev, "power key platform data not supplied\n"); diff --git a/trunk/drivers/isdn/i4l/isdn_net.c b/trunk/drivers/isdn/i4l/isdn_net.c index 48e9cc0369b1..97988111e45a 100644 --- a/trunk/drivers/isdn/i4l/isdn_net.c +++ b/trunk/drivers/isdn/i4l/isdn_net.c @@ -1983,14 +1983,13 @@ isdn_net_rebuild_header(struct sk_buff *skb) return ret; } -static int isdn_header_cache(const struct neighbour *neigh, struct hh_cache *hh, - __be16 type) +static int isdn_header_cache(const struct neighbour *neigh, struct hh_cache *hh) { const struct net_device *dev = neigh->dev; isdn_net_local *lp = netdev_priv(dev); if (lp->p_encap == ISDN_NET_ENCAP_ETHER) - return eth_header_cache(neigh, hh, type); + return eth_header_cache(neigh, hh); return -1; } diff --git a/trunk/drivers/leds/leds-lp5521.c b/trunk/drivers/leds/leds-lp5521.c index cc1dc4817fac..c0cff64a1ae6 100644 --- a/trunk/drivers/leds/leds-lp5521.c +++ b/trunk/drivers/leds/leds-lp5521.c @@ -593,7 +593,7 @@ static void lp5521_unregister_sysfs(struct i2c_client *client) &lp5521_led_attribute_group); } -static int __devinit lp5521_init_led(struct lp5521_led *led, +static int __init lp5521_init_led(struct lp5521_led *led, struct i2c_client *client, int chan, struct lp5521_platform_data *pdata) { @@ -637,7 +637,7 @@ static int __devinit lp5521_init_led(struct lp5521_led *led, return 0; } -static int __devinit lp5521_probe(struct i2c_client *client, +static int lp5521_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct lp5521_chip *chip; diff --git a/trunk/drivers/leds/leds-lp5523.c b/trunk/drivers/leds/leds-lp5523.c index 5971e309b234..e19fed25f137 100644 --- a/trunk/drivers/leds/leds-lp5523.c +++ b/trunk/drivers/leds/leds-lp5523.c @@ -826,7 +826,7 @@ static int __init lp5523_init_engine(struct lp5523_engine *engine, int id) return 0; } -static int __devinit lp5523_init_led(struct lp5523_led *led, struct device *dev, +static int __init lp5523_init_led(struct lp5523_led *led, struct device *dev, int chan, struct lp5523_platform_data *pdata) { char name[32]; @@ -872,7 +872,7 @@ static int __devinit lp5523_init_led(struct lp5523_led *led, struct device *dev, static struct i2c_driver lp5523_driver; -static int __devinit lp5523_probe(struct i2c_client *client, +static int lp5523_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct lp5523_chip *chip; diff --git a/trunk/drivers/leds/leds-pca9532.c b/trunk/drivers/leds/leds-pca9532.c index a2c874623e35..d8d3a1e910a1 100644 --- a/trunk/drivers/leds/leds-pca9532.c +++ b/trunk/drivers/leds/leds-pca9532.c @@ -88,7 +88,7 @@ static const struct pca9532_chip_info pca9532_chip_info_tbl[] = { static struct i2c_driver pca9532_driver = { .driver = { - .name = "leds-pca953x", + .name = "pca953x", }, .probe = pca9532_probe, .remove = pca9532_remove, diff --git a/trunk/drivers/md/md.c b/trunk/drivers/md/md.c index 91e31e260b4a..4332fc2f25d4 100644 --- a/trunk/drivers/md/md.c +++ b/trunk/drivers/md/md.c @@ -7088,7 +7088,6 @@ static int remove_and_add_spares(mddev_t *mddev) list_for_each_entry(rdev, &mddev->disks, same_set) { if (rdev->raid_disk >= 0 && !test_bit(In_sync, &rdev->flags) && - !test_bit(Faulty, &rdev->flags) && !test_bit(Blocked, &rdev->flags)) spares++; if (rdev->raid_disk < 0 diff --git a/trunk/drivers/media/rc/fintek-cir.c b/trunk/drivers/media/rc/fintek-cir.c index 7f7079b12f23..8fa539dde1b4 100644 --- a/trunk/drivers/media/rc/fintek-cir.c +++ b/trunk/drivers/media/rc/fintek-cir.c @@ -597,17 +597,12 @@ static void __devexit fintek_remove(struct pnp_dev *pdev) static int fintek_suspend(struct pnp_dev *pdev, pm_message_t state) { struct fintek_dev *fintek = pnp_get_drvdata(pdev); - unsigned long flags; fit_dbg("%s called", __func__); - spin_lock_irqsave(&fintek->fintek_lock, flags); - /* disable all CIR interrupts */ fintek_cir_reg_write(fintek, CIR_STATUS_IRQ_MASK, CIR_STATUS); - spin_unlock_irqrestore(&fintek->fintek_lock, flags); - fintek_config_mode_enable(fintek); /* disable cir logical dev */ diff --git a/trunk/drivers/media/rc/imon.c b/trunk/drivers/media/rc/imon.c index 6bc35eeb653b..3f3c70716268 100644 --- a/trunk/drivers/media/rc/imon.c +++ b/trunk/drivers/media/rc/imon.c @@ -307,14 +307,6 @@ static const struct { /* 0xffdc iMON MCE VFD */ { 0x00010000ffffffeell, KEY_VOLUMEUP }, { 0x01000000ffffffeell, KEY_VOLUMEDOWN }, - { 0x00000001ffffffeell, KEY_MUTE }, - { 0x0000000fffffffeell, KEY_MEDIA }, - { 0x00000012ffffffeell, KEY_UP }, - { 0x00000013ffffffeell, KEY_DOWN }, - { 0x00000014ffffffeell, KEY_LEFT }, - { 0x00000015ffffffeell, KEY_RIGHT }, - { 0x00000016ffffffeell, KEY_ENTER }, - { 0x00000017ffffffeell, KEY_ESC }, /* iMON Knob values */ { 0x000100ffffffffeell, KEY_VOLUMEUP }, { 0x010000ffffffffeell, KEY_VOLUMEDOWN }, @@ -1590,16 +1582,16 @@ static void imon_incoming_packet(struct imon_context *ictx, /* Only panel type events left to process now */ spin_lock_irqsave(&ictx->kc_lock, flags); - do_gettimeofday(&t); /* KEY_MUTE repeats from knob need to be suppressed */ if (ictx->kc == KEY_MUTE && ictx->kc == ictx->last_keycode) { + do_gettimeofday(&t); msec = tv2int(&t, &prev_time); + prev_time = t; if (msec < ictx->idev->rep[REP_DELAY]) { spin_unlock_irqrestore(&ictx->kc_lock, flags); return; } } - prev_time = t; kc = ictx->kc; spin_unlock_irqrestore(&ictx->kc_lock, flags); @@ -1611,9 +1603,7 @@ static void imon_incoming_packet(struct imon_context *ictx, input_report_key(ictx->idev, kc, 0); input_sync(ictx->idev); - spin_lock_irqsave(&ictx->kc_lock, flags); ictx->last_keycode = kc; - spin_unlock_irqrestore(&ictx->kc_lock, flags); return; @@ -1750,8 +1740,6 @@ static void imon_get_ffdc_type(struct imon_context *ictx) detected_display_type = IMON_DISPLAY_TYPE_VFD; break; /* iMON VFD, MCE IR */ - case 0x46: - case 0x7e: case 0x9e: dev_info(ictx->dev, "0xffdc iMON VFD, MCE IR"); detected_display_type = IMON_DISPLAY_TYPE_VFD; @@ -1767,9 +1755,6 @@ static void imon_get_ffdc_type(struct imon_context *ictx) dev_info(ictx->dev, "Unknown 0xffdc device, " "defaulting to VFD and iMON IR"); detected_display_type = IMON_DISPLAY_TYPE_VFD; - /* We don't know which one it is, allow user to set the - * RC6 one from userspace if OTHER wasn't correct. */ - allowed_protos |= RC_TYPE_RC6; break; } diff --git a/trunk/drivers/media/rc/ir-raw.c b/trunk/drivers/media/rc/ir-raw.c index 423ed45d6c55..11c19d8d0ee0 100644 --- a/trunk/drivers/media/rc/ir-raw.c +++ b/trunk/drivers/media/rc/ir-raw.c @@ -114,20 +114,18 @@ int ir_raw_event_store_edge(struct rc_dev *dev, enum raw_event_type type) s64 delta; /* ns */ DEFINE_IR_RAW_EVENT(ev); int rc = 0; - int delay; if (!dev->raw) return -EINVAL; now = ktime_get(); delta = ktime_to_ns(ktime_sub(now, dev->raw->last_event)); - delay = MS_TO_NS(dev->input_dev->rep[REP_DELAY]); /* Check for a long duration since last event or if we're * being called for the first time, note that delta can't * possibly be negative. */ - if (delta > delay || !dev->raw->last_type) + if (delta > IR_MAX_DURATION || !dev->raw->last_type) type |= IR_START_EVENT; else ev.duration = delta; diff --git a/trunk/drivers/media/rc/ite-cir.c b/trunk/drivers/media/rc/ite-cir.c index ecd3d0280768..e716b931cf7e 100644 --- a/trunk/drivers/media/rc/ite-cir.c +++ b/trunk/drivers/media/rc/ite-cir.c @@ -1347,7 +1347,6 @@ static const struct ite_dev_params ite_dev_descs[] = { { /* 0: ITE8704 */ .model = "ITE8704 CIR transceiver", .io_region_size = IT87_IOREG_LENGTH, - .io_rsrc_no = 0, .hw_tx_capable = true, .sample_period = (u32) (1000000000ULL / 115200), .tx_carrier_freq = 38000, @@ -1372,7 +1371,6 @@ static const struct ite_dev_params ite_dev_descs[] = { { /* 1: ITE8713 */ .model = "ITE8713 CIR transceiver", .io_region_size = IT87_IOREG_LENGTH, - .io_rsrc_no = 0, .hw_tx_capable = true, .sample_period = (u32) (1000000000ULL / 115200), .tx_carrier_freq = 38000, @@ -1397,7 +1395,6 @@ static const struct ite_dev_params ite_dev_descs[] = { { /* 2: ITE8708 */ .model = "ITE8708 CIR transceiver", .io_region_size = IT8708_IOREG_LENGTH, - .io_rsrc_no = 0, .hw_tx_capable = true, .sample_period = (u32) (1000000000ULL / 115200), .tx_carrier_freq = 38000, @@ -1423,7 +1420,6 @@ static const struct ite_dev_params ite_dev_descs[] = { { /* 3: ITE8709 */ .model = "ITE8709 CIR transceiver", .io_region_size = IT8709_IOREG_LENGTH, - .io_rsrc_no = 2, .hw_tx_capable = true, .sample_period = (u32) (1000000000ULL / 115200), .tx_carrier_freq = 38000, @@ -1465,7 +1461,6 @@ static int ite_probe(struct pnp_dev *pdev, const struct pnp_device_id struct rc_dev *rdev = NULL; int ret = -ENOMEM; int model_no; - int io_rsrc_no; ite_dbg("%s called", __func__); @@ -1495,11 +1490,10 @@ static int ite_probe(struct pnp_dev *pdev, const struct pnp_device_id /* get the description for the device */ dev_desc = &ite_dev_descs[model_no]; - io_rsrc_no = dev_desc->io_rsrc_no; /* validate pnp resources */ - if (!pnp_port_valid(pdev, io_rsrc_no) || - pnp_port_len(pdev, io_rsrc_no) != dev_desc->io_region_size) { + if (!pnp_port_valid(pdev, 0) || + pnp_port_len(pdev, 0) != dev_desc->io_region_size) { dev_err(&pdev->dev, "IR PNP Port not valid!\n"); goto failure; } @@ -1510,7 +1504,7 @@ static int ite_probe(struct pnp_dev *pdev, const struct pnp_device_id } /* store resource values */ - itdev->cir_addr = pnp_port_start(pdev, io_rsrc_no); + itdev->cir_addr = pnp_port_start(pdev, 0); itdev->cir_irq = pnp_irq(pdev, 0); /* initialize spinlocks */ diff --git a/trunk/drivers/media/rc/ite-cir.h b/trunk/drivers/media/rc/ite-cir.h index aa899a0b9750..16a19f5fd718 100644 --- a/trunk/drivers/media/rc/ite-cir.h +++ b/trunk/drivers/media/rc/ite-cir.h @@ -57,9 +57,6 @@ struct ite_dev_params { /* size of the I/O region */ int io_region_size; - /* IR pnp I/O resource number */ - int io_rsrc_no; - /* true if the hardware supports transmission */ bool hw_tx_capable; diff --git a/trunk/drivers/media/rc/keymaps/rc-pinnacle-pctv-hd.c b/trunk/drivers/media/rc/keymaps/rc-pinnacle-pctv-hd.c index 8d558ae63456..bb10ffe086b4 100644 --- a/trunk/drivers/media/rc/keymaps/rc-pinnacle-pctv-hd.c +++ b/trunk/drivers/media/rc/keymaps/rc-pinnacle-pctv-hd.c @@ -15,39 +15,43 @@ /* Pinnacle PCTV HD 800i mini remote */ static struct rc_map_table pinnacle_pctv_hd[] = { - /* Key codes for the tiny Pinnacle remote*/ - { 0x0700, KEY_MUTE }, - { 0x0701, KEY_MENU }, /* Pinnacle logo */ - { 0x0739, KEY_POWER }, - { 0x0703, KEY_VOLUMEUP }, - { 0x0709, KEY_VOLUMEDOWN }, - { 0x0706, KEY_CHANNELUP }, - { 0x070c, KEY_CHANNELDOWN }, - { 0x070f, KEY_1 }, - { 0x0715, KEY_2 }, - { 0x0710, KEY_3 }, - { 0x0718, KEY_4 }, - { 0x071b, KEY_5 }, - { 0x071e, KEY_6 }, - { 0x0711, KEY_7 }, - { 0x0721, KEY_8 }, - { 0x0712, KEY_9 }, - { 0x0727, KEY_0 }, - { 0x0724, KEY_ZOOM }, /* 'Square' key */ - { 0x072a, KEY_SUBTITLE }, /* 'T' key */ - { 0x072d, KEY_REWIND }, - { 0x0730, KEY_PLAYPAUSE }, - { 0x0733, KEY_FASTFORWARD }, - { 0x0736, KEY_RECORD }, - { 0x073c, KEY_STOP }, - { 0x073f, KEY_HELP }, /* '?' key */ + + { 0x0f, KEY_1 }, + { 0x15, KEY_2 }, + { 0x10, KEY_3 }, + { 0x18, KEY_4 }, + { 0x1b, KEY_5 }, + { 0x1e, KEY_6 }, + { 0x11, KEY_7 }, + { 0x21, KEY_8 }, + { 0x12, KEY_9 }, + { 0x27, KEY_0 }, + + { 0x24, KEY_ZOOM }, + { 0x2a, KEY_SUBTITLE }, + + { 0x00, KEY_MUTE }, + { 0x01, KEY_ENTER }, /* Pinnacle Logo */ + { 0x39, KEY_POWER }, + + { 0x03, KEY_VOLUMEUP }, + { 0x09, KEY_VOLUMEDOWN }, + { 0x06, KEY_CHANNELUP }, + { 0x0c, KEY_CHANNELDOWN }, + + { 0x2d, KEY_REWIND }, + { 0x30, KEY_PLAYPAUSE }, + { 0x33, KEY_FASTFORWARD }, + { 0x3c, KEY_STOP }, + { 0x36, KEY_RECORD }, + { 0x3f, KEY_EPG }, /* Labeled "?" */ }; static struct rc_map_list pinnacle_pctv_hd_map = { .map = { .scan = pinnacle_pctv_hd, .size = ARRAY_SIZE(pinnacle_pctv_hd), - .rc_type = RC_TYPE_RC5, + .rc_type = RC_TYPE_UNKNOWN, /* Legacy IR type */ .name = RC_MAP_PINNACLE_PCTV_HD, } }; diff --git a/trunk/drivers/media/rc/lirc_dev.c b/trunk/drivers/media/rc/lirc_dev.c index 27997a9ceb0d..fd237ab120bb 100644 --- a/trunk/drivers/media/rc/lirc_dev.c +++ b/trunk/drivers/media/rc/lirc_dev.c @@ -55,8 +55,6 @@ struct irctl { struct lirc_buffer *buf; unsigned int chunk_size; - struct cdev *cdev; - struct task_struct *task; long jiffies_to_wait; }; @@ -64,6 +62,7 @@ struct irctl { static DEFINE_MUTEX(lirc_dev_lock); static struct irctl *irctls[MAX_IRCTL_DEVICES]; +static struct cdev cdevs[MAX_IRCTL_DEVICES]; /* Only used for sysfs but defined to void otherwise */ static struct class *lirc_class; @@ -168,13 +167,9 @@ static struct file_operations lirc_dev_fops = { static int lirc_cdev_add(struct irctl *ir) { - int retval = -ENOMEM; + int retval; struct lirc_driver *d = &ir->d; - struct cdev *cdev; - - cdev = kzalloc(sizeof(*cdev), GFP_KERNEL); - if (!cdev) - goto err_out; + struct cdev *cdev = &cdevs[d->minor]; if (d->fops) { cdev_init(cdev, d->fops); @@ -185,20 +180,12 @@ static int lirc_cdev_add(struct irctl *ir) } retval = kobject_set_name(&cdev->kobj, "lirc%d", d->minor); if (retval) - goto err_out; + return retval; retval = cdev_add(cdev, MKDEV(MAJOR(lirc_base_dev), d->minor), 1); - if (retval) { + if (retval) kobject_put(&cdev->kobj); - goto err_out; - } - - ir->cdev = cdev; - - return 0; -err_out: - kfree(cdev); return retval; } @@ -227,7 +214,7 @@ int lirc_register_driver(struct lirc_driver *d) if (MAX_IRCTL_DEVICES <= d->minor) { dev_err(d->dev, "lirc_dev: lirc_register_driver: " "\"minor\" must be between 0 and %d (%d)!\n", - MAX_IRCTL_DEVICES - 1, d->minor); + MAX_IRCTL_DEVICES-1, d->minor); err = -EBADRQC; goto out; } @@ -382,7 +369,7 @@ int lirc_unregister_driver(int minor) if (minor < 0 || minor >= MAX_IRCTL_DEVICES) { printk(KERN_ERR "lirc_dev: %s: minor (%d) must be between " - "0 and %d!\n", __func__, minor, MAX_IRCTL_DEVICES - 1); + "0 and %d!\n", __func__, minor, MAX_IRCTL_DEVICES-1); return -EBADRQC; } @@ -393,7 +380,7 @@ int lirc_unregister_driver(int minor) return -ENOENT; } - cdev = ir->cdev; + cdev = &cdevs[minor]; mutex_lock(&lirc_dev_lock); @@ -423,7 +410,6 @@ int lirc_unregister_driver(int minor) } else { lirc_irctl_cleanup(ir); cdev_del(cdev); - kfree(cdev); kfree(ir); irctls[minor] = NULL; } @@ -467,7 +453,7 @@ int lirc_dev_fop_open(struct inode *inode, struct file *file) goto error; } - cdev = ir->cdev; + cdev = &cdevs[iminor(inode)]; if (try_module_get(cdev->owner)) { ir->open++; retval = ir->d.set_use_inc(ir->d.data); @@ -498,15 +484,13 @@ EXPORT_SYMBOL(lirc_dev_fop_open); int lirc_dev_fop_close(struct inode *inode, struct file *file) { struct irctl *ir = irctls[iminor(inode)]; - struct cdev *cdev; + struct cdev *cdev = &cdevs[iminor(inode)]; if (!ir) { printk(KERN_ERR "%s: called with invalid irctl\n", __func__); return -EINVAL; } - cdev = ir->cdev; - dev_dbg(ir->d.dev, LOGHEAD "close called\n", ir->d.name, ir->d.minor); WARN_ON(mutex_lock_killable(&lirc_dev_lock)); @@ -519,7 +503,6 @@ int lirc_dev_fop_close(struct inode *inode, struct file *file) lirc_irctl_cleanup(ir); cdev_del(cdev); irctls[ir->d.minor] = NULL; - kfree(cdev); kfree(ir); } diff --git a/trunk/drivers/media/rc/mceusb.c b/trunk/drivers/media/rc/mceusb.c index 06dfe0957b5e..ad927fcaa020 100644 --- a/trunk/drivers/media/rc/mceusb.c +++ b/trunk/drivers/media/rc/mceusb.c @@ -108,12 +108,6 @@ static int debug = 1; static int debug; #endif -#define mce_dbg(dev, fmt, ...) \ - do { \ - if (debug) \ - dev_info(dev, fmt, ## __VA_ARGS__); \ - } while (0) - /* general constants */ #define SEND_FLAG_IN_PROGRESS 1 #define SEND_FLAG_COMPLETE 2 @@ -252,9 +246,6 @@ static struct usb_device_id mceusb_dev_table[] = { .driver_info = MCE_GEN2_TX_INV }, /* SMK eHome Infrared Transceiver */ { USB_DEVICE(VENDOR_SMK, 0x0338) }, - /* SMK/I-O Data GV-MC7/RCKIT Receiver */ - { USB_DEVICE(VENDOR_SMK, 0x0353), - .driver_info = MCE_GEN2_NO_TX }, /* Tatung eHome Infrared Transceiver */ { USB_DEVICE(VENDOR_TATUNG, 0x9150) }, /* Shuttle eHome Infrared Transceiver */ @@ -615,15 +606,12 @@ static void mce_async_callback(struct urb *urb, struct pt_regs *regs) if (ir) { len = urb->actual_length; - mce_dbg(ir->dev, "callback called (status=%d len=%d)\n", + dev_dbg(ir->dev, "callback called (status=%d len=%d)\n", urb->status, len); mceusb_dev_printdata(ir, urb->transfer_buffer, 0, len, true); } - /* the transfer buffer and urb were allocated in mce_request_packet */ - kfree(urb->transfer_buffer); - usb_free_urb(urb); } /* request incoming or send outgoing usb packet - used to initialize remote */ @@ -667,17 +655,17 @@ static void mce_request_packet(struct mceusb_dev *ir, unsigned char *data, return; } - mce_dbg(dev, "receive request called (size=%#x)\n", size); + dev_dbg(dev, "receive request called (size=%#x)\n", size); async_urb->transfer_buffer_length = size; async_urb->dev = ir->usbdev; res = usb_submit_urb(async_urb, GFP_ATOMIC); if (res) { - mce_dbg(dev, "receive request FAILED! (res=%d)\n", res); + dev_dbg(dev, "receive request FAILED! (res=%d)\n", res); return; } - mce_dbg(dev, "receive request complete (res=%d)\n", res); + dev_dbg(dev, "receive request complete (res=%d)\n", res); } static void mce_async_out(struct mceusb_dev *ir, unsigned char *data, int size) @@ -685,9 +673,9 @@ static void mce_async_out(struct mceusb_dev *ir, unsigned char *data, int size) mce_request_packet(ir, data, size, MCEUSB_TX); } -static void mce_flush_rx_buffer(struct mceusb_dev *ir, int size) +static void mce_sync_in(struct mceusb_dev *ir, unsigned char *data, int size) { - mce_request_packet(ir, NULL, size, MCEUSB_RX); + mce_request_packet(ir, data, size, MCEUSB_RX); } /* Send data out the IR blaster port(s) */ @@ -806,7 +794,7 @@ static int mceusb_set_tx_carrier(struct rc_dev *dev, u32 carrier) ir->carrier = carrier; cmdbuf[2] = MCE_CMD_SIG_END; cmdbuf[3] = MCE_IRDATA_TRAILER; - mce_dbg(ir->dev, "%s: disabling carrier " + dev_dbg(ir->dev, "%s: disabling carrier " "modulation\n", __func__); mce_async_out(ir, cmdbuf, sizeof(cmdbuf)); return carrier; @@ -818,7 +806,7 @@ static int mceusb_set_tx_carrier(struct rc_dev *dev, u32 carrier) ir->carrier = carrier; cmdbuf[2] = prescaler; cmdbuf[3] = divisor; - mce_dbg(ir->dev, "%s: requesting %u HZ " + dev_dbg(ir->dev, "%s: requesting %u HZ " "carrier\n", __func__, carrier); /* Transmit new carrier to mce device */ @@ -891,7 +879,7 @@ static void mceusb_process_ir_data(struct mceusb_dev *ir, int buf_len) rawir.duration = (ir->buf_in[i] & MCE_PULSE_MASK) * US_TO_NS(MCE_TIME_UNIT); - mce_dbg(ir->dev, "Storing %s with duration %d\n", + dev_dbg(ir->dev, "Storing %s with duration %d\n", rawir.pulse ? "pulse" : "space", rawir.duration); @@ -923,7 +911,7 @@ static void mceusb_process_ir_data(struct mceusb_dev *ir, int buf_len) if (ir->parser_state != CMD_HEADER && !ir->rem) ir->parser_state = CMD_HEADER; } - mce_dbg(ir->dev, "processed IR data, calling ir_raw_event_handle\n"); + dev_dbg(ir->dev, "processed IR data, calling ir_raw_event_handle\n"); ir_raw_event_handle(ir->rc); } @@ -945,7 +933,7 @@ static void mceusb_dev_recv(struct urb *urb, struct pt_regs *regs) if (ir->send_flags == RECV_FLAG_IN_PROGRESS) { ir->send_flags = SEND_FLAG_COMPLETE; - mce_dbg(ir->dev, "setup answer received %d bytes\n", + dev_dbg(ir->dev, "setup answer received %d bytes\n", buf_len); } @@ -963,7 +951,7 @@ static void mceusb_dev_recv(struct urb *urb, struct pt_regs *regs) case -EPIPE: default: - mce_dbg(ir->dev, "Error: urb status = %d\n", urb->status); + dev_dbg(ir->dev, "Error: urb status = %d\n", urb->status); break; } @@ -973,6 +961,7 @@ static void mceusb_dev_recv(struct urb *urb, struct pt_regs *regs) static void mceusb_gen1_init(struct mceusb_dev *ir) { int ret; + int maxp = ir->len_in; struct device *dev = ir->dev; char *data; @@ -989,8 +978,8 @@ static void mceusb_gen1_init(struct mceusb_dev *ir) ret = usb_control_msg(ir->usbdev, usb_rcvctrlpipe(ir->usbdev, 0), USB_REQ_SET_ADDRESS, USB_TYPE_VENDOR, 0, 0, data, USB_CTRL_MSG_SZ, HZ * 3); - mce_dbg(dev, "%s - ret = %d\n", __func__, ret); - mce_dbg(dev, "%s - data[0] = %d, data[1] = %d\n", + dev_dbg(dev, "%s - ret = %d\n", __func__, ret); + dev_dbg(dev, "%s - data[0] = %d, data[1] = %d\n", __func__, data[0], data[1]); /* set feature: bit rate 38400 bps */ @@ -998,56 +987,71 @@ static void mceusb_gen1_init(struct mceusb_dev *ir) USB_REQ_SET_FEATURE, USB_TYPE_VENDOR, 0xc04e, 0x0000, NULL, 0, HZ * 3); - mce_dbg(dev, "%s - ret = %d\n", __func__, ret); + dev_dbg(dev, "%s - ret = %d\n", __func__, ret); /* bRequest 4: set char length to 8 bits */ ret = usb_control_msg(ir->usbdev, usb_sndctrlpipe(ir->usbdev, 0), 4, USB_TYPE_VENDOR, 0x0808, 0x0000, NULL, 0, HZ * 3); - mce_dbg(dev, "%s - retB = %d\n", __func__, ret); + dev_dbg(dev, "%s - retB = %d\n", __func__, ret); /* bRequest 2: set handshaking to use DTR/DSR */ ret = usb_control_msg(ir->usbdev, usb_sndctrlpipe(ir->usbdev, 0), 2, USB_TYPE_VENDOR, 0x0000, 0x0100, NULL, 0, HZ * 3); - mce_dbg(dev, "%s - retC = %d\n", __func__, ret); + dev_dbg(dev, "%s - retC = %d\n", __func__, ret); /* device reset */ mce_async_out(ir, DEVICE_RESET, sizeof(DEVICE_RESET)); + mce_sync_in(ir, NULL, maxp); /* get hw/sw revision? */ mce_async_out(ir, GET_REVISION, sizeof(GET_REVISION)); + mce_sync_in(ir, NULL, maxp); kfree(data); }; static void mceusb_gen2_init(struct mceusb_dev *ir) { + int maxp = ir->len_in; + /* device reset */ mce_async_out(ir, DEVICE_RESET, sizeof(DEVICE_RESET)); + mce_sync_in(ir, NULL, maxp); /* get hw/sw revision? */ mce_async_out(ir, GET_REVISION, sizeof(GET_REVISION)); + mce_sync_in(ir, NULL, maxp); /* unknown what the next two actually return... */ mce_async_out(ir, GET_UNKNOWN, sizeof(GET_UNKNOWN)); + mce_sync_in(ir, NULL, maxp); mce_async_out(ir, GET_UNKNOWN2, sizeof(GET_UNKNOWN2)); + mce_sync_in(ir, NULL, maxp); } static void mceusb_get_parameters(struct mceusb_dev *ir) { + int maxp = ir->len_in; + /* get the carrier and frequency */ mce_async_out(ir, GET_CARRIER_FREQ, sizeof(GET_CARRIER_FREQ)); + mce_sync_in(ir, NULL, maxp); - if (!ir->flags.no_tx) + if (!ir->flags.no_tx) { /* get the transmitter bitmask */ mce_async_out(ir, GET_TX_BITMASK, sizeof(GET_TX_BITMASK)); + mce_sync_in(ir, NULL, maxp); + } /* get receiver timeout value */ mce_async_out(ir, GET_RX_TIMEOUT, sizeof(GET_RX_TIMEOUT)); + mce_sync_in(ir, NULL, maxp); /* get receiver sensor setting */ mce_async_out(ir, GET_RX_SENSOR, sizeof(GET_RX_SENSOR)); + mce_sync_in(ir, NULL, maxp); } static struct rc_dev *mceusb_init_rc_dev(struct mceusb_dev *ir) @@ -1118,7 +1122,7 @@ static int __devinit mceusb_dev_probe(struct usb_interface *intf, bool tx_mask_normal; int ir_intfnum; - mce_dbg(&intf->dev, "%s called\n", __func__); + dev_dbg(&intf->dev, "%s called\n", __func__); idesc = intf->cur_altsetting; @@ -1146,7 +1150,7 @@ static int __devinit mceusb_dev_probe(struct usb_interface *intf, ep_in = ep; ep_in->bmAttributes = USB_ENDPOINT_XFER_INT; ep_in->bInterval = 1; - mce_dbg(&intf->dev, "acceptable inbound endpoint " + dev_dbg(&intf->dev, "acceptable inbound endpoint " "found\n"); } @@ -1161,12 +1165,12 @@ static int __devinit mceusb_dev_probe(struct usb_interface *intf, ep_out = ep; ep_out->bmAttributes = USB_ENDPOINT_XFER_INT; ep_out->bInterval = 1; - mce_dbg(&intf->dev, "acceptable outbound endpoint " + dev_dbg(&intf->dev, "acceptable outbound endpoint " "found\n"); } } if (ep_in == NULL) { - mce_dbg(&intf->dev, "inbound and/or endpoint not found\n"); + dev_dbg(&intf->dev, "inbound and/or endpoint not found\n"); return -ENODEV; } @@ -1211,16 +1215,16 @@ static int __devinit mceusb_dev_probe(struct usb_interface *intf, if (!ir->rc) goto rc_dev_fail; + /* flush buffers on the device */ + mce_sync_in(ir, NULL, maxp); + mce_sync_in(ir, NULL, maxp); + /* wire up inbound data handler */ usb_fill_int_urb(ir->urb_in, dev, pipe, ir->buf_in, maxp, (usb_complete_t) mceusb_dev_recv, ir, ep_in->bInterval); ir->urb_in->transfer_dma = ir->dma_in; ir->urb_in->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; - /* flush buffers on the device */ - mce_dbg(&intf->dev, "Flushing receive buffers\n"); - mce_flush_rx_buffer(ir, maxp); - /* initialize device */ if (ir->flags.microsoft_gen1) mceusb_gen1_init(ir); diff --git a/trunk/drivers/media/rc/nuvoton-cir.c b/trunk/drivers/media/rc/nuvoton-cir.c index 565f24c20d77..bf3060ea6107 100644 --- a/trunk/drivers/media/rc/nuvoton-cir.c +++ b/trunk/drivers/media/rc/nuvoton-cir.c @@ -991,6 +991,7 @@ static int nvt_open(struct rc_dev *dev) unsigned long flags; spin_lock_irqsave(&nvt->nvt_lock, flags); + nvt->in_use = true; nvt_enable_cir(nvt); spin_unlock_irqrestore(&nvt->nvt_lock, flags); @@ -1003,6 +1004,7 @@ static void nvt_close(struct rc_dev *dev) unsigned long flags; spin_lock_irqsave(&nvt->nvt_lock, flags); + nvt->in_use = false; nvt_disable_cir(nvt); spin_unlock_irqrestore(&nvt->nvt_lock, flags); } diff --git a/trunk/drivers/media/rc/nuvoton-cir.h b/trunk/drivers/media/rc/nuvoton-cir.h index 1241fc89a36c..379795d61ea7 100644 --- a/trunk/drivers/media/rc/nuvoton-cir.h +++ b/trunk/drivers/media/rc/nuvoton-cir.h @@ -70,6 +70,7 @@ struct nvt_dev { struct ir_raw_event rawir; spinlock_t nvt_lock; + bool in_use; /* for rx */ u8 buf[RX_BUF_LEN]; diff --git a/trunk/drivers/media/rc/rc-main.c b/trunk/drivers/media/rc/rc-main.c index 3186ac7c2c10..f57cd5677ac2 100644 --- a/trunk/drivers/media/rc/rc-main.c +++ b/trunk/drivers/media/rc/rc-main.c @@ -522,20 +522,18 @@ EXPORT_SYMBOL_GPL(rc_g_keycode_from_table); /** * ir_do_keyup() - internal function to signal the release of a keypress * @dev: the struct rc_dev descriptor of the device - * @sync: whether or not to call input_sync * * This function is used internally to release a keypress, it must be * called with keylock held. */ -static void ir_do_keyup(struct rc_dev *dev, bool sync) +static void ir_do_keyup(struct rc_dev *dev) { if (!dev->keypressed) return; IR_dprintk(1, "keyup key 0x%04x\n", dev->last_keycode); input_report_key(dev->input_dev, dev->last_keycode, 0); - if (sync) - input_sync(dev->input_dev); + input_sync(dev->input_dev); dev->keypressed = false; } @@ -551,7 +549,7 @@ void rc_keyup(struct rc_dev *dev) unsigned long flags; spin_lock_irqsave(&dev->keylock, flags); - ir_do_keyup(dev, true); + ir_do_keyup(dev); spin_unlock_irqrestore(&dev->keylock, flags); } EXPORT_SYMBOL_GPL(rc_keyup); @@ -580,7 +578,7 @@ static void ir_timer_keyup(unsigned long cookie) */ spin_lock_irqsave(&dev->keylock, flags); if (time_is_before_eq_jiffies(dev->keyup_jiffies)) - ir_do_keyup(dev, true); + ir_do_keyup(dev); spin_unlock_irqrestore(&dev->keylock, flags); } @@ -599,7 +597,6 @@ void rc_repeat(struct rc_dev *dev) spin_lock_irqsave(&dev->keylock, flags); input_event(dev->input_dev, EV_MSC, MSC_SCAN, dev->last_scancode); - input_sync(dev->input_dev); if (!dev->keypressed) goto out; @@ -625,28 +622,29 @@ EXPORT_SYMBOL_GPL(rc_repeat); static void ir_do_keydown(struct rc_dev *dev, int scancode, u32 keycode, u8 toggle) { - bool new_event = !dev->keypressed || - dev->last_scancode != scancode || - dev->last_toggle != toggle; + input_event(dev->input_dev, EV_MSC, MSC_SCAN, scancode); + + /* Repeat event? */ + if (dev->keypressed && + dev->last_scancode == scancode && + dev->last_toggle == toggle) + return; - if (new_event && dev->keypressed) - ir_do_keyup(dev, false); + /* Release old keypress */ + ir_do_keyup(dev); - input_event(dev->input_dev, EV_MSC, MSC_SCAN, scancode); + dev->last_scancode = scancode; + dev->last_toggle = toggle; + dev->last_keycode = keycode; - if (new_event && keycode != KEY_RESERVED) { - /* Register a keypress */ - dev->keypressed = true; - dev->last_scancode = scancode; - dev->last_toggle = toggle; - dev->last_keycode = keycode; - - IR_dprintk(1, "%s: key down event, " - "key 0x%04x, scancode 0x%04x\n", - dev->input_name, keycode, scancode); - input_report_key(dev->input_dev, keycode, 1); - } + if (keycode == KEY_RESERVED) + return; + /* Register a keypress */ + dev->keypressed = true; + IR_dprintk(1, "%s: key down event, key 0x%04x, scancode 0x%04x\n", + dev->input_name, keycode, scancode); + input_report_key(dev->input_dev, dev->last_keycode, 1); input_sync(dev->input_dev); } diff --git a/trunk/drivers/media/video/bt8xx/bttv-driver.c b/trunk/drivers/media/video/bt8xx/bttv-driver.c index 834a48394bce..a97cf2750bd9 100644 --- a/trunk/drivers/media/video/bt8xx/bttv-driver.c +++ b/trunk/drivers/media/video/bt8xx/bttv-driver.c @@ -3474,7 +3474,7 @@ static int radio_s_tuner(struct file *file, void *priv, if (0 != t->index) return -EINVAL; - bttv_call_all(btv, tuner, s_tuner, t); + bttv_call_all(btv, tuner, g_tuner, t); return 0; } diff --git a/trunk/drivers/media/video/cx18/cx18-ioctl.c b/trunk/drivers/media/video/cx18/cx18-ioctl.c index e80134f52ef5..1933d4d11bf2 100644 --- a/trunk/drivers/media/video/cx18/cx18-ioctl.c +++ b/trunk/drivers/media/video/cx18/cx18-ioctl.c @@ -695,10 +695,14 @@ static int cx18_g_tuner(struct file *file, void *fh, struct v4l2_tuner *vt) cx18_call_all(cx, tuner, g_tuner, vt); - if (vt->type == V4L2_TUNER_RADIO) + if (test_bit(CX18_F_I_RADIO_USER, &cx->i_flags)) { strlcpy(vt->name, "cx18 Radio Tuner", sizeof(vt->name)); - else + vt->type = V4L2_TUNER_RADIO; + } else { strlcpy(vt->name, "cx18 TV Tuner", sizeof(vt->name)); + vt->type = V4L2_TUNER_ANALOG_TV; + } + return 0; } diff --git a/trunk/drivers/media/video/ivtv/ivtv-ioctl.c b/trunk/drivers/media/video/ivtv/ivtv-ioctl.c index 120c7d8e0895..f9e347dae739 100644 --- a/trunk/drivers/media/video/ivtv/ivtv-ioctl.c +++ b/trunk/drivers/media/video/ivtv/ivtv-ioctl.c @@ -1184,10 +1184,14 @@ static int ivtv_g_tuner(struct file *file, void *fh, struct v4l2_tuner *vt) ivtv_call_all(itv, tuner, g_tuner, vt); - if (vt->type == V4L2_TUNER_RADIO) + if (test_bit(IVTV_F_I_RADIO_USER, &itv->i_flags)) { strlcpy(vt->name, "ivtv Radio Tuner", sizeof(vt->name)); - else + vt->type = V4L2_TUNER_RADIO; + } else { strlcpy(vt->name, "ivtv TV Tuner", sizeof(vt->name)); + vt->type = V4L2_TUNER_ANALOG_TV; + } + return 0; } diff --git a/trunk/drivers/media/video/m5mols/m5mols.h b/trunk/drivers/media/video/m5mols/m5mols.h index 89d09a8914f8..10b55c854487 100644 --- a/trunk/drivers/media/video/m5mols/m5mols.h +++ b/trunk/drivers/media/video/m5mols/m5mols.h @@ -2,10 +2,10 @@ * Header for M-5MOLS 8M Pixel camera sensor with ISP * * Copyright (C) 2011 Samsung Electronics Co., Ltd. - * Author: HeungJun Kim + * Author: HeungJun Kim, riverful.kim@samsung.com * * Copyright (C) 2009 Samsung Electronics Co., Ltd. - * Author: Dongsoo Nathaniel Kim + * Author: Dongsoo Nathaniel Kim, dongsoo45.kim@samsung.com * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -106,23 +106,23 @@ struct m5mols_capture { * The each value according to each scenemode is recommended in the documents. */ struct m5mols_scenemode { - u8 metering; - u8 ev_bias; - u8 wb_mode; - u8 wb_preset; - u8 chroma_en; - u8 chroma_lvl; - u8 edge_en; - u8 edge_lvl; - u8 af_range; - u8 fd_mode; - u8 mcc; - u8 light; - u8 flash; - u8 tone; - u8 iso; - u8 capt_mode; - u8 wdr; + u32 metering; + u32 ev_bias; + u32 wb_mode; + u32 wb_preset; + u32 chroma_en; + u32 chroma_lvl; + u32 edge_en; + u32 edge_lvl; + u32 af_range; + u32 fd_mode; + u32 mcc; + u32 light; + u32 flash; + u32 tone; + u32 iso; + u32 capt_mode; + u32 wdr; }; /** @@ -154,6 +154,7 @@ struct m5mols_version { u8 str[VERSION_STRING_SIZE]; u8 af; }; +#define VERSION_SIZE sizeof(struct m5mols_version) /** * struct m5mols_info - M-5MOLS driver data structure @@ -215,9 +216,9 @@ struct m5mols_info { bool lock_ae; bool lock_awb; u8 resolution; - u8 interrupt; - u8 mode; - u8 mode_save; + u32 interrupt; + u32 mode; + u32 mode_save; int (*set_power)(struct device *dev, int on); }; @@ -255,11 +256,9 @@ struct m5mols_info { * +-------+---+----------+-----+------+------+------+------+ * - d[0..3]: according to size1 */ -int m5mols_read_u8(struct v4l2_subdev *sd, u32 reg_comb, u8 *val); -int m5mols_read_u16(struct v4l2_subdev *sd, u32 reg_comb, u16 *val); -int m5mols_read_u32(struct v4l2_subdev *sd, u32 reg_comb, u32 *val); +int m5mols_read(struct v4l2_subdev *sd, u32 reg_comb, u32 *val); int m5mols_write(struct v4l2_subdev *sd, u32 reg_comb, u32 val); -int m5mols_busy(struct v4l2_subdev *sd, u8 category, u8 cmd, u8 value); +int m5mols_busy(struct v4l2_subdev *sd, u8 category, u8 cmd, u32 value); /* * Mode operation of the M-5MOLS @@ -281,12 +280,12 @@ int m5mols_busy(struct v4l2_subdev *sd, u8 category, u8 cmd, u8 value); * The available executing order between each modes are as follows: * PARAMETER <---> MONITOR <---> CAPTURE */ -int m5mols_mode(struct m5mols_info *info, u8 mode); +int m5mols_mode(struct m5mols_info *info, u32 mode); -int m5mols_enable_interrupt(struct v4l2_subdev *sd, u8 reg); +int m5mols_enable_interrupt(struct v4l2_subdev *sd, u32 reg); int m5mols_sync_controls(struct m5mols_info *info); int m5mols_start_capture(struct m5mols_info *info); -int m5mols_do_scenemode(struct m5mols_info *info, u8 mode); +int m5mols_do_scenemode(struct m5mols_info *info, u32 mode); int m5mols_lock_3a(struct m5mols_info *info, bool lock); int m5mols_set_ctrl(struct v4l2_ctrl *ctrl); diff --git a/trunk/drivers/media/video/m5mols/m5mols_capture.c b/trunk/drivers/media/video/m5mols/m5mols_capture.c index d9471928369d..d71a3903b60f 100644 --- a/trunk/drivers/media/video/m5mols/m5mols_capture.c +++ b/trunk/drivers/media/video/m5mols/m5mols_capture.c @@ -2,10 +2,10 @@ * The Capture code for Fujitsu M-5MOLS ISP * * Copyright (C) 2011 Samsung Electronics Co., Ltd. - * Author: HeungJun Kim + * Author: HeungJun Kim, riverful.kim@samsung.com * * Copyright (C) 2009 Samsung Electronics Co., Ltd. - * Author: Dongsoo Nathaniel Kim + * Author: Dongsoo Nathaniel Kim, dongsoo45.kim@samsung.com * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -58,9 +58,9 @@ static int m5mols_read_rational(struct v4l2_subdev *sd, u32 addr_num, { u32 num, den; - int ret = m5mols_read_u32(sd, addr_num, &num); + int ret = m5mols_read(sd, addr_num, &num); if (!ret) - ret = m5mols_read_u32(sd, addr_den, &den); + ret = m5mols_read(sd, addr_den, &den); if (ret) return ret; *val = den == 0 ? 0 : num / den; @@ -99,20 +99,20 @@ static int m5mols_capture_info(struct m5mols_info *info) if (ret) return ret; - ret = m5mols_read_u16(sd, EXIF_INFO_ISO, &exif->iso_speed); + ret = m5mols_read(sd, EXIF_INFO_ISO, (u32 *)&exif->iso_speed); if (!ret) - ret = m5mols_read_u16(sd, EXIF_INFO_FLASH, &exif->flash); + ret = m5mols_read(sd, EXIF_INFO_FLASH, (u32 *)&exif->flash); if (!ret) - ret = m5mols_read_u16(sd, EXIF_INFO_SDR, &exif->sdr); + ret = m5mols_read(sd, EXIF_INFO_SDR, (u32 *)&exif->sdr); if (!ret) - ret = m5mols_read_u16(sd, EXIF_INFO_QVAL, &exif->qval); + ret = m5mols_read(sd, EXIF_INFO_QVAL, (u32 *)&exif->qval); if (ret) return ret; if (!ret) - ret = m5mols_read_u32(sd, CAPC_IMAGE_SIZE, &info->cap.main); + ret = m5mols_read(sd, CAPC_IMAGE_SIZE, &info->cap.main); if (!ret) - ret = m5mols_read_u32(sd, CAPC_THUMB_SIZE, &info->cap.thumb); + ret = m5mols_read(sd, CAPC_THUMB_SIZE, &info->cap.thumb); if (!ret) info->cap.total = info->cap.main + info->cap.thumb; @@ -122,7 +122,7 @@ static int m5mols_capture_info(struct m5mols_info *info) int m5mols_start_capture(struct m5mols_info *info) { struct v4l2_subdev *sd = &info->sd; - u8 resolution = info->resolution; + u32 resolution = info->resolution; int timeout; int ret; diff --git a/trunk/drivers/media/video/m5mols/m5mols_controls.c b/trunk/drivers/media/video/m5mols/m5mols_controls.c index d135d20d09cf..817c16fec368 100644 --- a/trunk/drivers/media/video/m5mols/m5mols_controls.c +++ b/trunk/drivers/media/video/m5mols/m5mols_controls.c @@ -2,10 +2,10 @@ * Controls for M-5MOLS 8M Pixel camera sensor with ISP * * Copyright (C) 2011 Samsung Electronics Co., Ltd. - * Author: HeungJun Kim + * Author: HeungJun Kim, riverful.kim@samsung.com * * Copyright (C) 2009 Samsung Electronics Co., Ltd. - * Author: Dongsoo Nathaniel Kim + * Author: Dongsoo Nathaniel Kim, dongsoo45.kim@samsung.com * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -130,7 +130,7 @@ static struct m5mols_scenemode m5mols_default_scenemode[] = { * * WARNING: The execution order is important. Do not change the order. */ -int m5mols_do_scenemode(struct m5mols_info *info, u8 mode) +int m5mols_do_scenemode(struct m5mols_info *info, u32 mode) { struct v4l2_subdev *sd = &info->sd; struct m5mols_scenemode scenemode = m5mols_default_scenemode[mode]; diff --git a/trunk/drivers/media/video/m5mols/m5mols_core.c b/trunk/drivers/media/video/m5mols/m5mols_core.c index 43c68f51c5ce..76eac26e84ae 100644 --- a/trunk/drivers/media/video/m5mols/m5mols_core.c +++ b/trunk/drivers/media/video/m5mols/m5mols_core.c @@ -2,10 +2,10 @@ * Driver for M-5MOLS 8M Pixel camera sensor with ISP * * Copyright (C) 2011 Samsung Electronics Co., Ltd. - * Author: HeungJun Kim + * Author: HeungJun Kim, riverful.kim@samsung.com * * Copyright (C) 2009 Samsung Electronics Co., Ltd. - * Author: Dongsoo Nathaniel Kim + * Author: Dongsoo Nathaniel Kim, dongsoo45.kim@samsung.com * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -133,13 +133,13 @@ static u32 m5mols_swap_byte(u8 *data, u8 length) /** * m5mols_read - I2C read function * @reg: combination of size, category and command for the I2C packet - * @size: desired size of I2C packet * @val: read value */ -static int m5mols_read(struct v4l2_subdev *sd, u32 size, u32 reg, u32 *val) +int m5mols_read(struct v4l2_subdev *sd, u32 reg, u32 *val) { struct i2c_client *client = v4l2_get_subdevdata(sd); u8 rbuf[M5MOLS_I2C_MAX_SIZE + 1]; + u8 size = I2C_SIZE(reg); u8 category = I2C_CATEGORY(reg); u8 cmd = I2C_COMMAND(reg); struct i2c_msg msg[2]; @@ -149,6 +149,11 @@ static int m5mols_read(struct v4l2_subdev *sd, u32 size, u32 reg, u32 *val) if (!client->adapter) return -ENODEV; + if (size != 1 && size != 2 && size != 4) { + v4l2_err(sd, "Wrong data size\n"); + return -EINVAL; + } + msg[0].addr = client->addr; msg[0].flags = 0; msg[0].len = 5; @@ -179,52 +184,6 @@ static int m5mols_read(struct v4l2_subdev *sd, u32 size, u32 reg, u32 *val) return 0; } -int m5mols_read_u8(struct v4l2_subdev *sd, u32 reg, u8 *val) -{ - u32 val_32; - int ret; - - if (I2C_SIZE(reg) != 1) { - v4l2_err(sd, "Wrong data size\n"); - return -EINVAL; - } - - ret = m5mols_read(sd, I2C_SIZE(reg), reg, &val_32); - if (ret) - return ret; - - *val = (u8)val_32; - return ret; -} - -int m5mols_read_u16(struct v4l2_subdev *sd, u32 reg, u16 *val) -{ - u32 val_32; - int ret; - - if (I2C_SIZE(reg) != 2) { - v4l2_err(sd, "Wrong data size\n"); - return -EINVAL; - } - - ret = m5mols_read(sd, I2C_SIZE(reg), reg, &val_32); - if (ret) - return ret; - - *val = (u16)val_32; - return ret; -} - -int m5mols_read_u32(struct v4l2_subdev *sd, u32 reg, u32 *val) -{ - if (I2C_SIZE(reg) != 4) { - v4l2_err(sd, "Wrong data size\n"); - return -EINVAL; - } - - return m5mols_read(sd, I2C_SIZE(reg), reg, val); -} - /** * m5mols_write - I2C command write function * @reg: combination of size, category and command for the I2C packet @@ -272,14 +231,13 @@ int m5mols_write(struct v4l2_subdev *sd, u32 reg, u32 val) return 0; } -int m5mols_busy(struct v4l2_subdev *sd, u8 category, u8 cmd, u8 mask) +int m5mols_busy(struct v4l2_subdev *sd, u8 category, u8 cmd, u32 mask) { - u8 busy; - int i; + u32 busy, i; int ret; for (i = 0; i < M5MOLS_I2C_CHECK_RETRY; i++) { - ret = m5mols_read_u8(sd, I2C_REG(category, cmd, 1), &busy); + ret = m5mols_read(sd, I2C_REG(category, cmd, 1), &busy); if (ret < 0) return ret; if ((busy & mask) == mask) @@ -294,14 +252,14 @@ int m5mols_busy(struct v4l2_subdev *sd, u8 category, u8 cmd, u8 mask) * Before writing desired interrupt value the INT_FACTOR register should * be read to clear pending interrupts. */ -int m5mols_enable_interrupt(struct v4l2_subdev *sd, u8 reg) +int m5mols_enable_interrupt(struct v4l2_subdev *sd, u32 reg) { struct m5mols_info *info = to_m5mols(sd); - u8 mask = is_available_af(info) ? REG_INT_AF : 0; - u8 dummy; + u32 mask = is_available_af(info) ? REG_INT_AF : 0; + u32 dummy; int ret; - ret = m5mols_read_u8(sd, SYSTEM_INT_FACTOR, &dummy); + ret = m5mols_read(sd, SYSTEM_INT_FACTOR, &dummy); if (!ret) ret = m5mols_write(sd, SYSTEM_INT_ENABLE, reg & ~mask); return ret; @@ -313,7 +271,7 @@ int m5mols_enable_interrupt(struct v4l2_subdev *sd, u8 reg) * It always accompanies a little delay changing the M-5MOLS mode, so it is * needed checking current busy status to guarantee right mode. */ -static int m5mols_reg_mode(struct v4l2_subdev *sd, u8 mode) +static int m5mols_reg_mode(struct v4l2_subdev *sd, u32 mode) { int ret = m5mols_write(sd, SYSTEM_SYSMODE, mode); @@ -328,16 +286,16 @@ static int m5mols_reg_mode(struct v4l2_subdev *sd, u8 mode) * can be guaranteed only when the sensor is operating in mode which which * a command belongs to. */ -int m5mols_mode(struct m5mols_info *info, u8 mode) +int m5mols_mode(struct m5mols_info *info, u32 mode) { struct v4l2_subdev *sd = &info->sd; int ret = -EINVAL; - u8 reg; + u32 reg; if (mode < REG_PARAMETER && mode > REG_CAPTURE) return ret; - ret = m5mols_read_u8(sd, SYSTEM_SYSMODE, ®); + ret = m5mols_read(sd, SYSTEM_SYSMODE, ®); if ((!ret && reg == mode) || ret) return ret; @@ -386,37 +344,41 @@ int m5mols_mode(struct m5mols_info *info, u8 mode) static int m5mols_get_version(struct v4l2_subdev *sd) { struct m5mols_info *info = to_m5mols(sd); - struct m5mols_version *ver = &info->ver; - u8 *str = ver->str; - int i; + union { + struct m5mols_version ver; + u8 bytes[VERSION_SIZE]; + } version; + u32 *value; + u8 cmd = CAT0_VER_CUSTOMER; int ret; - ret = m5mols_read_u8(sd, SYSTEM_VER_CUSTOMER, &ver->customer); - if (!ret) - ret = m5mols_read_u8(sd, SYSTEM_VER_PROJECT, &ver->project); - if (!ret) - ret = m5mols_read_u16(sd, SYSTEM_VER_FIRMWARE, &ver->fw); - if (!ret) - ret = m5mols_read_u16(sd, SYSTEM_VER_HARDWARE, &ver->hw); - if (!ret) - ret = m5mols_read_u16(sd, SYSTEM_VER_PARAMETER, &ver->param); - if (!ret) - ret = m5mols_read_u16(sd, SYSTEM_VER_AWB, &ver->awb); - if (!ret) - ret = m5mols_read_u8(sd, AF_VERSION, &ver->af); - if (ret) - return ret; + do { + value = (u32 *)&version.bytes[cmd]; + ret = m5mols_read(sd, SYSTEM_CMD(cmd), value); + if (ret) + return ret; + } while (cmd++ != CAT0_VER_AWB); - for (i = 0; i < VERSION_STRING_SIZE; i++) { - ret = m5mols_read_u8(sd, SYSTEM_VER_STRING, &str[i]); + do { + value = (u32 *)&version.bytes[cmd]; + ret = m5mols_read(sd, SYSTEM_VER_STRING, value); if (ret) return ret; - } + if (cmd >= VERSION_SIZE - 1) + return -EINVAL; + } while (version.bytes[cmd++]); + + value = (u32 *)&version.bytes[cmd]; + ret = m5mols_read(sd, AF_VERSION, value); + if (ret) + return ret; - ver->fw = be16_to_cpu(ver->fw); - ver->hw = be16_to_cpu(ver->hw); - ver->param = be16_to_cpu(ver->param); - ver->awb = be16_to_cpu(ver->awb); + /* store version information swapped for being readable */ + info->ver = version.ver; + info->ver.fw = be16_to_cpu(info->ver.fw); + info->ver.hw = be16_to_cpu(info->ver.hw); + info->ver.param = be16_to_cpu(info->ver.param); + info->ver.awb = be16_to_cpu(info->ver.awb); v4l2_info(sd, "Manufacturer\t[%s]\n", is_manufacturer(info, REG_SAMSUNG_ELECTRO) ? @@ -760,7 +722,7 @@ static int m5mols_init_controls(struct m5mols_info *info) int ret; /* Determine value's range & step of controls for various FW version */ - ret = m5mols_read_u16(sd, AE_MAX_GAIN_MON, &max_exposure); + ret = m5mols_read(sd, AE_MAX_GAIN_MON, (u32 *)&max_exposure); if (!ret) step_zoom = is_manufacturer(info, REG_SAMSUNG_OPTICS) ? 31 : 1; if (ret) @@ -880,18 +842,18 @@ static void m5mols_irq_work(struct work_struct *work) struct m5mols_info *info = container_of(work, struct m5mols_info, work_irq); struct v4l2_subdev *sd = &info->sd; - u8 reg; + u32 reg; int ret; if (!is_powered(info) || - m5mols_read_u8(sd, SYSTEM_INT_FACTOR, &info->interrupt)) + m5mols_read(sd, SYSTEM_INT_FACTOR, &info->interrupt)) return; switch (info->interrupt & REG_INT_MASK) { case REG_INT_AF: if (!is_available_af(info)) break; - ret = m5mols_read_u8(sd, AF_STATUS, ®); + ret = m5mols_read(sd, AF_STATUS, ®); v4l2_dbg(2, m5mols_debug, sd, "AF %s\n", reg == REG_AF_FAIL ? "Failed" : reg == REG_AF_SUCCESS ? "Success" : diff --git a/trunk/drivers/media/video/m5mols/m5mols_reg.h b/trunk/drivers/media/video/m5mols/m5mols_reg.h index c755bd6edfe9..b83e36fc6ac6 100644 --- a/trunk/drivers/media/video/m5mols/m5mols_reg.h +++ b/trunk/drivers/media/video/m5mols/m5mols_reg.h @@ -2,10 +2,10 @@ * Register map for M-5MOLS 8M Pixel camera sensor with ISP * * Copyright (C) 2011 Samsung Electronics Co., Ltd. - * Author: HeungJun Kim + * Author: HeungJun Kim, riverful.kim@samsung.com * * Copyright (C) 2009 Samsung Electronics Co., Ltd. - * Author: Dongsoo Nathaniel Kim + * Author: Dongsoo Nathaniel Kim, dongsoo45.kim@samsung.com * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -56,24 +56,13 @@ * more specific contents, see definition if file m5mols.h. */ #define CAT0_VER_CUSTOMER 0x00 /* customer version */ -#define CAT0_VER_PROJECT 0x01 /* project version */ -#define CAT0_VER_FIRMWARE 0x02 /* Firmware version */ -#define CAT0_VER_HARDWARE 0x04 /* Hardware version */ -#define CAT0_VER_PARAMETER 0x06 /* Parameter version */ -#define CAT0_VER_AWB 0x08 /* Auto WB version */ +#define CAT0_VER_AWB 0x09 /* Auto WB version */ #define CAT0_VER_STRING 0x0a /* string including M-5MOLS */ #define CAT0_SYSMODE 0x0b /* SYSTEM mode register */ #define CAT0_STATUS 0x0c /* SYSTEM mode status register */ #define CAT0_INT_FACTOR 0x10 /* interrupt pending register */ #define CAT0_INT_ENABLE 0x11 /* interrupt enable register */ -#define SYSTEM_VER_CUSTOMER I2C_REG(CAT_SYSTEM, CAT0_VER_CUSTOMER, 1) -#define SYSTEM_VER_PROJECT I2C_REG(CAT_SYSTEM, CAT0_VER_PROJECT, 1) -#define SYSTEM_VER_FIRMWARE I2C_REG(CAT_SYSTEM, CAT0_VER_FIRMWARE, 2) -#define SYSTEM_VER_HARDWARE I2C_REG(CAT_SYSTEM, CAT0_VER_HARDWARE, 2) -#define SYSTEM_VER_PARAMETER I2C_REG(CAT_SYSTEM, CAT0_VER_PARAMETER, 2) -#define SYSTEM_VER_AWB I2C_REG(CAT_SYSTEM, CAT0_VER_AWB, 2) - #define SYSTEM_SYSMODE I2C_REG(CAT_SYSTEM, CAT0_SYSMODE, 1) #define REG_SYSINIT 0x00 /* SYSTEM mode */ #define REG_PARAMETER 0x01 /* PARAMETER mode */ @@ -393,8 +382,8 @@ #define REG_CAP_START_MAIN 0x01 #define REG_CAP_START_THUMB 0x03 -#define CAPC_IMAGE_SIZE I2C_REG(CAT_CAPT_CTRL, CATC_CAP_IMAGE_SIZE, 4) -#define CAPC_THUMB_SIZE I2C_REG(CAT_CAPT_CTRL, CATC_CAP_THUMB_SIZE, 4) +#define CAPC_IMAGE_SIZE I2C_REG(CAT_CAPT_CTRL, CATC_CAP_IMAGE_SIZE, 1) +#define CAPC_THUMB_SIZE I2C_REG(CAT_CAPT_CTRL, CATC_CAP_THUMB_SIZE, 1) /* * Category F - Flash diff --git a/trunk/drivers/media/video/msp3400-driver.c b/trunk/drivers/media/video/msp3400-driver.c index c43c81f5f978..de5d481b0328 100644 --- a/trunk/drivers/media/video/msp3400-driver.c +++ b/trunk/drivers/media/video/msp3400-driver.c @@ -480,14 +480,12 @@ static int msp_g_tuner(struct v4l2_subdev *sd, struct v4l2_tuner *vt) struct msp_state *state = to_state(sd); struct i2c_client *client = v4l2_get_subdevdata(sd); - if (vt->type != V4L2_TUNER_ANALOG_TV) + if (state->radio) return 0; - if (!state->radio) { - if (state->opmode == OPMODE_AUTOSELECT) - msp_detect_stereo(client); - vt->rxsubchans = state->rxsubchans; - } - vt->audmode = state->audmode; + if (state->opmode == OPMODE_AUTOSELECT) + msp_detect_stereo(client); + vt->audmode = state->audmode; + vt->rxsubchans = state->rxsubchans; vt->capability |= V4L2_TUNER_CAP_STEREO | V4L2_TUNER_CAP_LANG1 | V4L2_TUNER_CAP_LANG2; return 0; diff --git a/trunk/drivers/media/video/mx1_camera.c b/trunk/drivers/media/video/mx1_camera.c index 63f8a0cc33d8..bc0c23a1009c 100644 --- a/trunk/drivers/media/video/mx1_camera.c +++ b/trunk/drivers/media/video/mx1_camera.c @@ -444,9 +444,12 @@ static int mx1_camera_add_device(struct soc_camera_device *icd) { struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent); struct mx1_camera_dev *pcdev = ici->priv; + int ret; - if (pcdev->icd) - return -EBUSY; + if (pcdev->icd) { + ret = -EBUSY; + goto ebusy; + } dev_info(icd->dev.parent, "MX1 Camera driver attached to camera %d\n", icd->devnum); @@ -455,7 +458,8 @@ static int mx1_camera_add_device(struct soc_camera_device *icd) pcdev->icd = icd; - return 0; +ebusy: + return ret; } static void mx1_camera_remove_device(struct soc_camera_device *icd) diff --git a/trunk/drivers/media/video/omap/omap_vout.c b/trunk/drivers/media/video/omap/omap_vout.c index 4d07c5844402..4ada9be1d430 100644 --- a/trunk/drivers/media/video/omap/omap_vout.c +++ b/trunk/drivers/media/video/omap/omap_vout.c @@ -982,14 +982,6 @@ static int omap_vout_buffer_setup(struct videobuf_queue *q, unsigned int *count, startindex = (vout->vid == OMAP_VIDEO1) ? video1_numbuffers : video2_numbuffers; - /* Check the size of the buffer */ - if (*size > vout->buffer_size) { - v4l2_err(&vout->vid_dev->v4l2_dev, - "buffer allocation mismatch [%u] [%u]\n", - *size, vout->buffer_size); - return -ENOMEM; - } - for (i = startindex; i < *count; i++) { vout->buffer_size = *size; @@ -1236,14 +1228,6 @@ static int omap_vout_mmap(struct file *file, struct vm_area_struct *vma) (vma->vm_pgoff << PAGE_SHIFT)); return -EINVAL; } - /* Check the size of the buffer */ - if (size > vout->buffer_size) { - v4l2_err(&vout->vid_dev->v4l2_dev, - "insufficient memory [%lu] [%u]\n", - size, vout->buffer_size); - return -ENOMEM; - } - q->bufs[i]->baddr = vma->vm_start; vma->vm_flags |= VM_RESERVED; @@ -2407,7 +2391,7 @@ static int __init omap_vout_create_video_devices(struct platform_device *pdev) /* Register the Video device with V4L2 */ vfd = vout->vfd; - if (video_register_device(vfd, VFL_TYPE_GRABBER, -1) < 0) { + if (video_register_device(vfd, VFL_TYPE_GRABBER, k + 1) < 0) { dev_err(&pdev->dev, ": Could not register " "Video for Linux device\n"); vfd->minor = -1; diff --git a/trunk/drivers/media/video/omap/omap_voutlib.c b/trunk/drivers/media/video/omap/omap_voutlib.c index 8ae74817a110..2aa6a76c5e59 100644 --- a/trunk/drivers/media/video/omap/omap_voutlib.c +++ b/trunk/drivers/media/video/omap/omap_voutlib.c @@ -193,7 +193,7 @@ int omap_vout_new_crop(struct v4l2_pix_format *pix, return -EINVAL; if (cpu_is_omap24xx()) { - if (try_crop.height != win->w.height) { + if (crop->height != win->w.height) { /* If we're resizing vertically, we can't support a * crop width wider than 768 pixels. */ @@ -202,7 +202,7 @@ int omap_vout_new_crop(struct v4l2_pix_format *pix, } } /* vertical resizing */ - vresize = (1024 * try_crop.height) / win->w.height; + vresize = (1024 * crop->height) / win->w.height; if (cpu_is_omap24xx() && (vresize > 2048)) vresize = 2048; else if (cpu_is_omap34xx() && (vresize > 4096)) @@ -221,7 +221,7 @@ int omap_vout_new_crop(struct v4l2_pix_format *pix, try_crop.height = 2; } /* horizontal resizing */ - hresize = (1024 * try_crop.width) / win->w.width; + hresize = (1024 * crop->width) / win->w.width; if (cpu_is_omap24xx() && (hresize > 2048)) hresize = 2048; else if (cpu_is_omap34xx() && (hresize > 4096)) diff --git a/trunk/drivers/media/video/omap3isp/isp.c b/trunk/drivers/media/video/omap3isp/isp.c index 94b6ed89e195..c9fd04ee70a8 100644 --- a/trunk/drivers/media/video/omap3isp/isp.c +++ b/trunk/drivers/media/video/omap3isp/isp.c @@ -1748,7 +1748,7 @@ static int isp_register_entities(struct isp_device *isp) goto done; /* Register external entities */ - for (subdevs = pdata->subdevs; subdevs && subdevs->subdevs; ++subdevs) { + for (subdevs = pdata->subdevs; subdevs->subdevs; ++subdevs) { struct v4l2_subdev *sensor; struct media_entity *input; unsigned int flags; diff --git a/trunk/drivers/media/video/pvrusb2/pvrusb2-hdw.c b/trunk/drivers/media/video/pvrusb2/pvrusb2-hdw.c index e98d38212791..9d0dd08f57f8 100644 --- a/trunk/drivers/media/video/pvrusb2/pvrusb2-hdw.c +++ b/trunk/drivers/media/video/pvrusb2/pvrusb2-hdw.c @@ -3046,8 +3046,6 @@ static void pvr2_subdev_update(struct pvr2_hdw *hdw) if (hdw->input_dirty || hdw->audiomode_dirty || hdw->force_dirty) { struct v4l2_tuner vt; memset(&vt, 0, sizeof(vt)); - vt.type = (hdw->input_val == PVR2_CVAL_INPUT_RADIO) ? - V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; vt.audmode = hdw->audiomode_val; v4l2_device_call_all(&hdw->v4l2_dev, 0, tuner, s_tuner, &vt); } @@ -5173,8 +5171,6 @@ void pvr2_hdw_status_poll(struct pvr2_hdw *hdw) { struct v4l2_tuner *vtp = &hdw->tuner_signal_info; memset(vtp, 0, sizeof(*vtp)); - vtp->type = (hdw->input_val == PVR2_CVAL_INPUT_RADIO) ? - V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; hdw->tuner_signal_stale = 0; /* Note: There apparently is no replacement for VIDIOC_CROPCAP using v4l2-subdev - therefore we can't support that AT ALL right diff --git a/trunk/drivers/media/video/pwc/pwc-ctrl.c b/trunk/drivers/media/video/pwc/pwc-ctrl.c index 760b4de13adf..1593f8deb810 100644 --- a/trunk/drivers/media/video/pwc/pwc-ctrl.c +++ b/trunk/drivers/media/video/pwc/pwc-ctrl.c @@ -1414,7 +1414,7 @@ long pwc_ioctl(struct pwc_device *pdev, unsigned int cmd, void *arg) { ARG_DEF(struct pwc_probe, probe) - strcpy(ARGR(probe).name, pdev->vdev.name); + strcpy(ARGR(probe).name, pdev->vdev->name); ARGR(probe).type = pdev->type; ARG_OUT(probe) break; diff --git a/trunk/drivers/media/video/pwc/pwc-if.c b/trunk/drivers/media/video/pwc/pwc-if.c index b0bde5a87c8a..356cd42b593b 100644 --- a/trunk/drivers/media/video/pwc/pwc-if.c +++ b/trunk/drivers/media/video/pwc/pwc-if.c @@ -40,7 +40,7 @@ Oh yes, convention: to disctinguish between all the various pointers to device-structures, I use these names for the pointer variables: udev: struct usb_device * - vdev: struct video_device (member of pwc_dev) + vdev: struct video_device * pdev: struct pwc_devive * */ @@ -152,7 +152,6 @@ static ssize_t pwc_video_read(struct file *file, char __user *buf, size_t count, loff_t *ppos); static unsigned int pwc_video_poll(struct file *file, poll_table *wait); static int pwc_video_mmap(struct file *file, struct vm_area_struct *vma); -static void pwc_video_release(struct video_device *vfd); static const struct v4l2_file_operations pwc_fops = { .owner = THIS_MODULE, @@ -165,11 +164,41 @@ static const struct v4l2_file_operations pwc_fops = { }; static struct video_device pwc_template = { .name = "Philips Webcam", /* Filled in later */ - .release = pwc_video_release, + .release = video_device_release, .fops = &pwc_fops, - .ioctl_ops = &pwc_ioctl_ops, }; +/***************************************************************************/ + +/* Okay, this is some magic that I worked out and the reasoning behind it... + + The biggest problem with any USB device is of course: "what to do + when the user unplugs the device while it is in use by an application?" + We have several options: + 1) Curse them with the 7 plagues when they do (requires divine intervention) + 2) Tell them not to (won't work: they'll do it anyway) + 3) Oops the kernel (this will have a negative effect on a user's uptime) + 4) Do something sensible. + + Of course, we go for option 4. + + It happens that this device will be linked to two times, once from + usb_device and once from the video_device in their respective 'private' + pointers. This is done when the device is probed() and all initialization + succeeded. The pwc_device struct links back to both structures. + + When a device is unplugged while in use it will be removed from the + list of known USB devices; I also de-register it as a V4L device, but + unfortunately I can't free the memory since the struct is still in use + by the file descriptor. This free-ing is then deferend until the first + opportunity. Crude, but it works. + + A small 'advantage' is that if a user unplugs the cam and plugs it back + in, it should get assigned the same video device minor, but unfortunately + it's non-trivial to re-link the cam back to the video device... (that + would surely be magic! :)) +*/ + /***************************************************************************/ /* Private functions */ @@ -987,15 +1016,16 @@ static ssize_t show_snapshot_button_status(struct device *class_dev, static DEVICE_ATTR(button, S_IRUGO | S_IWUSR, show_snapshot_button_status, NULL); -static int pwc_create_sysfs_files(struct pwc_device *pdev) +static int pwc_create_sysfs_files(struct video_device *vdev) { + struct pwc_device *pdev = video_get_drvdata(vdev); int rc; - rc = device_create_file(&pdev->vdev.dev, &dev_attr_button); + rc = device_create_file(&vdev->dev, &dev_attr_button); if (rc) goto err; if (pdev->features & FEATURE_MOTOR_PANTILT) { - rc = device_create_file(&pdev->vdev.dev, &dev_attr_pan_tilt); + rc = device_create_file(&vdev->dev, &dev_attr_pan_tilt); if (rc) goto err_button; } @@ -1003,17 +1033,19 @@ static int pwc_create_sysfs_files(struct pwc_device *pdev) return 0; err_button: - device_remove_file(&pdev->vdev.dev, &dev_attr_button); + device_remove_file(&vdev->dev, &dev_attr_button); err: PWC_ERROR("Could not create sysfs files.\n"); return rc; } -static void pwc_remove_sysfs_files(struct pwc_device *pdev) +static void pwc_remove_sysfs_files(struct video_device *vdev) { + struct pwc_device *pdev = video_get_drvdata(vdev); + if (pdev->features & FEATURE_MOTOR_PANTILT) - device_remove_file(&pdev->vdev.dev, &dev_attr_pan_tilt); - device_remove_file(&pdev->vdev.dev, &dev_attr_button); + device_remove_file(&vdev->dev, &dev_attr_pan_tilt); + device_remove_file(&vdev->dev, &dev_attr_button); } #ifdef CONFIG_USB_PWC_DEBUG @@ -1074,7 +1106,7 @@ static int pwc_video_open(struct file *file) if (ret >= 0) { PWC_DEBUG_OPEN("This %s camera is equipped with a %s (%d).\n", - pdev->vdev.name, + pdev->vdev->name, pwc_sensor_type_to_string(i), i); } } @@ -1148,15 +1180,16 @@ static int pwc_video_open(struct file *file) return 0; } -static void pwc_video_release(struct video_device *vfd) + +static void pwc_cleanup(struct pwc_device *pdev) { - struct pwc_device *pdev = container_of(vfd, struct pwc_device, vdev); - int hint; + pwc_remove_sysfs_files(pdev->vdev); + video_unregister_device(pdev->vdev); - /* search device_hint[] table if we occupy a slot, by any chance */ - for (hint = 0; hint < MAX_DEV_HINTS; hint++) - if (device_hint[hint].pdev == pdev) - device_hint[hint].pdev = NULL; +#ifdef CONFIG_USB_PWC_INPUT_EVDEV + if (pdev->button_dev) + input_unregister_device(pdev->button_dev); +#endif kfree(pdev); } @@ -1166,7 +1199,7 @@ static int pwc_video_close(struct file *file) { struct video_device *vdev = file->private_data; struct pwc_device *pdev; - int i; + int i, hint; PWC_DEBUG_OPEN(">> video_close called(vdev = 0x%p).\n", vdev); @@ -1201,6 +1234,12 @@ static int pwc_video_close(struct file *file) } pdev->vopen--; PWC_DEBUG_OPEN("<< video_close() vopen=%d\n", pdev->vopen); + } else { + pwc_cleanup(pdev); + /* search device_hint[] table if we occupy a slot, by any chance */ + for (hint = 0; hint < MAX_DEV_HINTS; hint++) + if (device_hint[hint].pdev == pdev) + device_hint[hint].pdev = NULL; } return 0; @@ -1676,12 +1715,19 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id init_waitqueue_head(&pdev->frameq); pdev->vcompression = pwc_preferred_compression; - /* Init video_device structure */ - memcpy(&pdev->vdev, &pwc_template, sizeof(pwc_template)); - pdev->vdev.parent = &intf->dev; - pdev->vdev.lock = &pdev->modlock; - strcpy(pdev->vdev.name, name); - video_set_drvdata(&pdev->vdev, pdev); + /* Allocate video_device structure */ + pdev->vdev = video_device_alloc(); + if (!pdev->vdev) { + PWC_ERROR("Err, cannot allocate video_device struture. Failing probe."); + rc = -ENOMEM; + goto err_free_mem; + } + memcpy(pdev->vdev, &pwc_template, sizeof(pwc_template)); + pdev->vdev->parent = &intf->dev; + pdev->vdev->lock = &pdev->modlock; + pdev->vdev->ioctl_ops = &pwc_ioctl_ops; + strcpy(pdev->vdev->name, name); + video_set_drvdata(pdev->vdev, pdev); pdev->release = le16_to_cpu(udev->descriptor.bcdDevice); PWC_DEBUG_PROBE("Release: %04x\n", pdev->release); @@ -1700,6 +1746,8 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id } } + pdev->vdev->release = video_device_release; + /* occupy slot */ if (hint < MAX_DEV_HINTS) device_hint[hint].pdev = pdev; @@ -1711,16 +1759,16 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id pwc_set_leds(pdev, 0, 0); pwc_camera_power(pdev, 0); - rc = video_register_device(&pdev->vdev, VFL_TYPE_GRABBER, video_nr); + rc = video_register_device(pdev->vdev, VFL_TYPE_GRABBER, video_nr); if (rc < 0) { PWC_ERROR("Failed to register as video device (%d).\n", rc); - goto err_free_mem; + goto err_video_release; } - rc = pwc_create_sysfs_files(pdev); + rc = pwc_create_sysfs_files(pdev->vdev); if (rc) goto err_video_unreg; - PWC_INFO("Registered as %s.\n", video_device_node_name(&pdev->vdev)); + PWC_INFO("Registered as %s.\n", video_device_node_name(pdev->vdev)); #ifdef CONFIG_USB_PWC_INPUT_EVDEV /* register webcam snapshot button input device */ @@ -1728,7 +1776,7 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id if (!pdev->button_dev) { PWC_ERROR("Err, insufficient memory for webcam snapshot button device."); rc = -ENOMEM; - pwc_remove_sysfs_files(pdev); + pwc_remove_sysfs_files(pdev->vdev); goto err_video_unreg; } @@ -1746,7 +1794,7 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id if (rc) { input_free_device(pdev->button_dev); pdev->button_dev = NULL; - pwc_remove_sysfs_files(pdev); + pwc_remove_sysfs_files(pdev->vdev); goto err_video_unreg; } #endif @@ -1756,7 +1804,10 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id err_video_unreg: if (hint < MAX_DEV_HINTS) device_hint[hint].pdev = NULL; - video_unregister_device(&pdev->vdev); + video_unregister_device(pdev->vdev); + pdev->vdev = NULL; /* So we don't try to release it below */ +err_video_release: + video_device_release(pdev->vdev); err_free_mem: kfree(pdev); return rc; @@ -1765,8 +1816,10 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id /* The user yanked out the cable... */ static void usb_pwc_disconnect(struct usb_interface *intf) { - struct pwc_device *pdev = usb_get_intfdata(intf); + struct pwc_device *pdev; + int hint; + pdev = usb_get_intfdata (intf); mutex_lock(&pdev->modlock); usb_set_intfdata (intf, NULL); if (pdev == NULL) { @@ -1783,25 +1836,30 @@ static void usb_pwc_disconnect(struct usb_interface *intf) } /* We got unplugged; this is signalled by an EPIPE error code */ - pdev->error_status = EPIPE; - pdev->unplugged = 1; + if (pdev->vopen) { + PWC_INFO("Disconnected while webcam is in use!\n"); + pdev->error_status = EPIPE; + } /* Alert waiting processes */ wake_up_interruptible(&pdev->frameq); - - /* No need to keep the urbs around after disconnection */ - pwc_isoc_cleanup(pdev); + /* Wait until device is closed */ + if (pdev->vopen) { + pdev->unplugged = 1; + pwc_iso_stop(pdev); + } else { + /* Device is closed, so we can safely unregister it */ + PWC_DEBUG_PROBE("Unregistering video device in disconnect().\n"); disconnect_out: - mutex_unlock(&pdev->modlock); - - pwc_remove_sysfs_files(pdev); - video_unregister_device(&pdev->vdev); + /* search device_hint[] table if we occupy a slot, by any chance */ + for (hint = 0; hint < MAX_DEV_HINTS; hint++) + if (device_hint[hint].pdev == pdev) + device_hint[hint].pdev = NULL; + } -#ifdef CONFIG_USB_PWC_INPUT_EVDEV - if (pdev->button_dev) - input_unregister_device(pdev->button_dev); -#endif + mutex_unlock(&pdev->modlock); + pwc_cleanup(pdev); } diff --git a/trunk/drivers/media/video/pwc/pwc.h b/trunk/drivers/media/video/pwc/pwc.h index 083f8b15df73..e947766337d6 100644 --- a/trunk/drivers/media/video/pwc/pwc.h +++ b/trunk/drivers/media/video/pwc/pwc.h @@ -162,9 +162,9 @@ struct pwc_imgbuf struct pwc_device { - struct video_device vdev; + struct video_device *vdev; - /* Pointer to our usb_device, may be NULL after unplug */ + /* Pointer to our usb_device */ struct usb_device *udev; int type; /* type of cam (645, 646, 675, 680, 690, 720, 730, 740, 750) */ diff --git a/trunk/drivers/media/video/s5p-fimc/fimc-capture.c b/trunk/drivers/media/video/s5p-fimc/fimc-capture.c index 81b4a826ee5e..d142b40ea64e 100644 --- a/trunk/drivers/media/video/s5p-fimc/fimc-capture.c +++ b/trunk/drivers/media/video/s5p-fimc/fimc-capture.c @@ -1,7 +1,7 @@ /* - * Samsung S5P/EXYNOS4 SoC series camera interface (camera capture) driver + * Samsung S5P SoC series camera interface (camera capture) driver * - * Copyright (C) 2010 - 2011 Samsung Electronics Co., Ltd. + * Copyright (c) 2010 Samsung Electronics Co., Ltd * Author: Sylwester Nawrocki, * * This program is free software; you can redistribute it and/or modify @@ -262,7 +262,12 @@ static unsigned int get_plane_size(struct fimc_frame *fr, unsigned int plane) { if (!fr || plane >= fr->fmt->memplanes) return 0; + + dbg("%s: w: %d. h: %d. depth[%d]: %d", + __func__, fr->width, fr->height, plane, fr->fmt->depth[plane]); + return fr->f_width * fr->f_height * fr->fmt->depth[plane] / 8; + } static int queue_setup(struct vb2_queue *vq, unsigned int *num_buffers, @@ -278,14 +283,24 @@ static int queue_setup(struct vb2_queue *vq, unsigned int *num_buffers, *num_planes = fmt->memplanes; + dbg("%s, buffer count=%d, plane count=%d", + __func__, *num_buffers, *num_planes); + for (i = 0; i < fmt->memplanes; i++) { sizes[i] = get_plane_size(&ctx->d_frame, i); + dbg("plane: %u, plane_size: %lu", i, sizes[i]); allocators[i] = ctx->fimc_dev->alloc_ctx; } return 0; } +static int buffer_init(struct vb2_buffer *vb) +{ + /* TODO: */ + return 0; +} + static int buffer_prepare(struct vb2_buffer *vb) { struct vb2_queue *vq = vb->vb2_queue; @@ -365,6 +380,7 @@ static struct vb2_ops fimc_capture_qops = { .queue_setup = queue_setup, .buf_prepare = buffer_prepare, .buf_queue = buffer_queue, + .buf_init = buffer_init, .wait_prepare = fimc_unlock, .wait_finish = fimc_lock, .start_streaming = start_streaming, @@ -887,7 +903,6 @@ int fimc_register_capture_device(struct fimc_dev *fimc) err_v4l2_reg: v4l2_device_unregister(v4l2_dev); err_info: - kfree(ctx); dev_err(&fimc->pdev->dev, "failed to install\n"); return ret; } diff --git a/trunk/drivers/media/video/s5p-fimc/fimc-core.c b/trunk/drivers/media/video/s5p-fimc/fimc-core.c index bdf19ada9172..dc91a8511af6 100644 --- a/trunk/drivers/media/video/s5p-fimc/fimc-core.c +++ b/trunk/drivers/media/video/s5p-fimc/fimc-core.c @@ -1,8 +1,9 @@ /* - * Samsung S5P/EXYNOS4 SoC series camera interface (video postprocessor) driver + * S5P camera interface (video postprocessor) driver * - * Copyright (C) 2010-2011 Samsung Electronics Co., Ltd. - * Contact: Sylwester Nawrocki, + * Copyright (c) 2010 Samsung Electronics Co., Ltd + * + * Sylwester Nawrocki, * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -41,6 +42,7 @@ static struct fimc_fmt fimc_formats[] = { .color = S5P_FIMC_RGB565, .memplanes = 1, .colplanes = 1, + .mbus_code = V4L2_MBUS_FMT_RGB565_2X8_BE, .flags = FMT_FLAGS_M2M, }, { .name = "BGR666", @@ -230,7 +232,11 @@ static int fimc_get_scaler_factor(u32 src, u32 tar, u32 *ratio, u32 *shift) return 0; } } + *shift = 0, *ratio = 1; + + dbg("s: %d, t: %d, shift: %d, ratio: %d", + src, tar, *shift, *ratio); return 0; } @@ -262,8 +268,10 @@ int fimc_set_scaler_info(struct fimc_ctx *ctx) err("invalid source size: %d x %d", sx, sy); return -EINVAL; } + sc->real_width = sx; sc->real_height = sy; + dbg("sx= %d, sy= %d, tx= %d, ty= %d", sx, sy, tx, ty); ret = fimc_get_scaler_factor(sx, tx, &sc->pre_hratio, &sc->hfactor); if (ret) @@ -703,18 +711,22 @@ static int fimc_queue_setup(struct vb2_queue *vq, unsigned int *num_buffers, f = ctx_get_frame(ctx, vq->type); if (IS_ERR(f)) return PTR_ERR(f); + /* * Return number of non-contigous planes (plane buffers) * depending on the configured color format. */ - if (!f->fmt) - return -EINVAL; + if (f->fmt) + *num_planes = f->fmt->memplanes; - *num_planes = f->fmt->memplanes; for (i = 0; i < f->fmt->memplanes; i++) { - sizes[i] = (f->f_width * f->f_height * f->fmt->depth[i]) / 8; + sizes[i] = (f->width * f->height * f->fmt->depth[i]) >> 3; allocators[i] = ctx->fimc_dev->alloc_ctx; } + + if (*num_buffers == 0) + *num_buffers = 1; + return 0; } @@ -840,7 +852,7 @@ struct fimc_fmt *find_format(struct v4l2_format *f, unsigned int mask) for (i = 0; i < ARRAY_SIZE(fimc_formats); ++i) { fmt = &fimc_formats[i]; - if (fmt->fourcc == f->fmt.pix_mp.pixelformat && + if (fmt->fourcc == f->fmt.pix.pixelformat && (fmt->flags & mask)) break; } diff --git a/trunk/drivers/media/video/s5p-fimc/fimc-core.h b/trunk/drivers/media/video/s5p-fimc/fimc-core.h index 1f70772daaf0..3beb1e5320ce 100644 --- a/trunk/drivers/media/video/s5p-fimc/fimc-core.h +++ b/trunk/drivers/media/video/s5p-fimc/fimc-core.h @@ -1,5 +1,7 @@ /* - * Copyright (C) 2010 - 2011 Samsung Electronics Co., Ltd. + * Copyright (c) 2010 Samsung Electronics + * + * Sylwester Nawrocki, * * 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 @@ -133,10 +135,9 @@ enum fimc_color_fmt { * @name: format description * @fourcc: the fourcc code for this format, 0 if not applicable * @color: the corresponding fimc_color_fmt + * @depth: per plane driver's private 'number of bits per pixel' * @memplanes: number of physically non-contiguous data planes * @colplanes: number of physically contiguous data planes - * @depth: per plane driver's private 'number of bits per pixel' - * @flags: flags indicating which operation mode format applies to */ struct fimc_fmt { enum v4l2_mbus_pixelcode mbus_code; @@ -170,7 +171,7 @@ struct fimc_dma_offset { }; /** - * struct fimc_effect - color effect information + * struct fimc_effect - the configuration data for the "Arbitrary" image effect * @type: effect type * @pat_cb: cr value when type is "arbitrary" * @pat_cr: cr value when type is "arbitrary" @@ -183,6 +184,7 @@ struct fimc_effect { /** * struct fimc_scaler - the configuration data for FIMC inetrnal scaler + * * @scaleup_h: flag indicating scaling up horizontally * @scaleup_v: flag indicating scaling up vertically * @copy_mode: flag indicating transparent DMA transfer (no scaling @@ -218,6 +220,7 @@ struct fimc_scaler { /** * struct fimc_addr - the FIMC physical address set for DMA + * * @y: luminance plane physical address * @cb: Cb plane physical address * @cr: Cr plane physical address @@ -231,7 +234,6 @@ struct fimc_addr { /** * struct fimc_vid_buffer - the driver's video buffer * @vb: v4l videobuf buffer - * @list: linked list structure for buffer queue * @paddr: precalculated physical address set * @index: buffer index for the output DMA engine */ @@ -252,10 +254,11 @@ struct fimc_vid_buffer { * @offs_v: image vertical pixel offset * @width: image pixel width * @height: image pixel weight - * @payload: image size in bytes (w x h x bpp) * @paddr: image frame buffer physical addresses + * @buf_cnt: number of buffers depending on a color format + * @payload: image size in bytes (w x h x bpp) + * @color: color format * @dma_offset: DMA offset in bytes - * @fmt: fimc color format pointer */ struct fimc_frame { u32 f_width; @@ -387,22 +390,21 @@ struct fimc_ctx; /** * struct fimc_dev - abstraction for FIMC entity + * * @slock: the spinlock protecting this data structure * @lock: the mutex protecting this data structure * @pdev: pointer to the FIMC platform device * @pdata: pointer to the device platform data - * @variant: the IP variant information * @id: FIMC device index (0..FIMC_MAX_DEVS) * @num_clocks: the number of clocks managed by this device instance - * @clock: clocks required for FIMC operation + * @clock[]: the clocks required for FIMC operation * @regs: the mapped hardware registers * @regs_res: the resource claimed for IO registers - * @irq: FIMC interrupt number - * @irq_queue: interrupt handler waitqueue + * @irq: interrupt number of the FIMC subdevice + * @irq_queue: * @m2m: memory-to-memory V4L2 device information * @vid_cap: camera capture device information * @state: flags used to synchronize m2m and capture mode operation - * @alloc_ctx: videobuf2 memory allocator context */ struct fimc_dev { spinlock_t slock; @@ -425,7 +427,8 @@ struct fimc_dev { /** * fimc_ctx - the device context data - * @slock: spinlock protecting this data structure + * + * @lock: mutex protecting this data structure * @s_frame: source frame properties * @d_frame: destination frame properties * @out_order_1p: output 1-plane YCBCR order diff --git a/trunk/drivers/media/video/saa7134/saa7134-input.c b/trunk/drivers/media/video/saa7134/saa7134-input.c index d4ee24bf6928..ff6c0e97563e 100644 --- a/trunk/drivers/media/video/saa7134/saa7134-input.c +++ b/trunk/drivers/media/video/saa7134/saa7134-input.c @@ -963,7 +963,7 @@ static int saa7134_raw_decode_irq(struct saa7134_dev *dev) * to work with other protocols. */ if (!ir->active) { - timeout = jiffies + msecs_to_jiffies(15); + timeout = jiffies + jiffies_to_msecs(15); mod_timer(&ir->timer, timeout); ir->active = true; } diff --git a/trunk/drivers/media/video/tuner-core.c b/trunk/drivers/media/video/tuner-core.c index cfa9f7efe93d..9363ed91a4cb 100644 --- a/trunk/drivers/media/video/tuner-core.c +++ b/trunk/drivers/media/video/tuner-core.c @@ -724,15 +724,19 @@ static inline int check_mode(struct tuner *t, enum v4l2_tuner_type mode) } /** - * set_mode - Switch tuner to other mode. + * set_mode_freq - Switch tuner to other mode. + * @client: struct i2c_client pointer * @t: a pointer to the module's internal struct_tuner * @mode: enum v4l2_type (radio or TV) + * @freq: frequency to set (0 means to use the previous one) * * If tuner doesn't support the needed mode (radio or TV), prints a * debug message and returns -EINVAL, changing its state to standby. - * Otherwise, changes the mode and returns 0. + * Otherwise, changes the state and sets frequency to the last value, if + * the tuner can sleep or if it supports both Radio and TV. */ -static int set_mode(struct tuner *t, enum v4l2_tuner_type mode) +static int set_mode_freq(struct i2c_client *client, struct tuner *t, + enum v4l2_tuner_type mode, unsigned int freq) { struct analog_demod_ops *analog_ops = &t->fe.ops.analog_ops; @@ -748,27 +752,17 @@ static int set_mode(struct tuner *t, enum v4l2_tuner_type mode) t->mode = mode; tuner_dbg("Changing to mode %d\n", mode); } - return 0; -} - -/** - * set_freq - Set the tuner to the desired frequency. - * @t: a pointer to the module's internal struct_tuner - * @freq: frequency to set (0 means to use the current frequency) - */ -static void set_freq(struct tuner *t, unsigned int freq) -{ - struct i2c_client *client = v4l2_get_subdevdata(&t->sd); - if (t->mode == V4L2_TUNER_RADIO) { - if (!freq) - freq = t->radio_freq; - set_radio_freq(client, freq); + if (freq) + t->radio_freq = freq; + set_radio_freq(client, t->radio_freq); } else { - if (!freq) - freq = t->tv_freq; - set_tv_freq(client, freq); + if (freq) + t->tv_freq = freq; + set_tv_freq(client, t->tv_freq); } + + return 0; } /* @@ -823,8 +817,7 @@ static void set_tv_freq(struct i2c_client *c, unsigned int freq) /** * tuner_fixup_std - force a given video standard variant * - * @t: tuner internal struct - * @std: TV standard + * @t: tuner internal struct * * A few devices or drivers have problem to detect some standard variations. * On other operational systems, the drivers generally have a per-country @@ -834,39 +827,57 @@ static void set_tv_freq(struct i2c_client *c, unsigned int freq) * to distinguish all video standard variations, a modprobe parameter can * be used to force a video standard match. */ -static v4l2_std_id tuner_fixup_std(struct tuner *t, v4l2_std_id std) +static int tuner_fixup_std(struct tuner *t) { - if (pal[0] != '-' && (std & V4L2_STD_PAL) == V4L2_STD_PAL) { + if ((t->std & V4L2_STD_PAL) == V4L2_STD_PAL) { switch (pal[0]) { case '6': - return V4L2_STD_PAL_60; + tuner_dbg("insmod fixup: PAL => PAL-60\n"); + t->std = V4L2_STD_PAL_60; + break; case 'b': case 'B': case 'g': case 'G': - return V4L2_STD_PAL_BG; + tuner_dbg("insmod fixup: PAL => PAL-BG\n"); + t->std = V4L2_STD_PAL_BG; + break; case 'i': case 'I': - return V4L2_STD_PAL_I; + tuner_dbg("insmod fixup: PAL => PAL-I\n"); + t->std = V4L2_STD_PAL_I; + break; case 'd': case 'D': case 'k': case 'K': - return V4L2_STD_PAL_DK; + tuner_dbg("insmod fixup: PAL => PAL-DK\n"); + t->std = V4L2_STD_PAL_DK; + break; case 'M': case 'm': - return V4L2_STD_PAL_M; + tuner_dbg("insmod fixup: PAL => PAL-M\n"); + t->std = V4L2_STD_PAL_M; + break; case 'N': case 'n': - if (pal[1] == 'c' || pal[1] == 'C') - return V4L2_STD_PAL_Nc; - return V4L2_STD_PAL_N; + if (pal[1] == 'c' || pal[1] == 'C') { + tuner_dbg("insmod fixup: PAL => PAL-Nc\n"); + t->std = V4L2_STD_PAL_Nc; + } else { + tuner_dbg("insmod fixup: PAL => PAL-N\n"); + t->std = V4L2_STD_PAL_N; + } + break; + case '-': + /* default parameter, do nothing */ + break; default: tuner_warn("pal= argument not recognised\n"); break; } } - if (secam[0] != '-' && (std & V4L2_STD_SECAM) == V4L2_STD_SECAM) { + if ((t->std & V4L2_STD_SECAM) == V4L2_STD_SECAM) { switch (secam[0]) { case 'b': case 'B': @@ -874,42 +885,63 @@ static v4l2_std_id tuner_fixup_std(struct tuner *t, v4l2_std_id std) case 'G': case 'h': case 'H': - return V4L2_STD_SECAM_B | - V4L2_STD_SECAM_G | - V4L2_STD_SECAM_H; + tuner_dbg("insmod fixup: SECAM => SECAM-BGH\n"); + t->std = V4L2_STD_SECAM_B | + V4L2_STD_SECAM_G | + V4L2_STD_SECAM_H; + break; case 'd': case 'D': case 'k': case 'K': - return V4L2_STD_SECAM_DK; + tuner_dbg("insmod fixup: SECAM => SECAM-DK\n"); + t->std = V4L2_STD_SECAM_DK; + break; case 'l': case 'L': - if ((secam[1] == 'C') || (secam[1] == 'c')) - return V4L2_STD_SECAM_LC; - return V4L2_STD_SECAM_L; + if ((secam[1] == 'C') || (secam[1] == 'c')) { + tuner_dbg("insmod fixup: SECAM => SECAM-L'\n"); + t->std = V4L2_STD_SECAM_LC; + } else { + tuner_dbg("insmod fixup: SECAM => SECAM-L\n"); + t->std = V4L2_STD_SECAM_L; + } + break; + case '-': + /* default parameter, do nothing */ + break; default: tuner_warn("secam= argument not recognised\n"); break; } } - if (ntsc[0] != '-' && (std & V4L2_STD_NTSC) == V4L2_STD_NTSC) { + if ((t->std & V4L2_STD_NTSC) == V4L2_STD_NTSC) { switch (ntsc[0]) { case 'm': case 'M': - return V4L2_STD_NTSC_M; + tuner_dbg("insmod fixup: NTSC => NTSC-M\n"); + t->std = V4L2_STD_NTSC_M; + break; case 'j': case 'J': - return V4L2_STD_NTSC_M_JP; + tuner_dbg("insmod fixup: NTSC => NTSC_M_JP\n"); + t->std = V4L2_STD_NTSC_M_JP; + break; case 'k': case 'K': - return V4L2_STD_NTSC_M_KR; + tuner_dbg("insmod fixup: NTSC => NTSC_M_KR\n"); + t->std = V4L2_STD_NTSC_M_KR; + break; + case '-': + /* default parameter, do nothing */ + break; default: tuner_info("ntsc= argument not recognised\n"); break; } } - return std; + return 0; } /* @@ -1026,9 +1058,10 @@ static void tuner_status(struct dvb_frontend *fe) static int tuner_s_radio(struct v4l2_subdev *sd) { struct tuner *t = to_tuner(sd); + struct i2c_client *client = v4l2_get_subdevdata(sd); - if (set_mode(t, V4L2_TUNER_RADIO) == 0) - set_freq(t, 0); + if (set_mode_freq(client, t, V4L2_TUNER_RADIO, 0) == -EINVAL) + return 0; return 0; } @@ -1039,20 +1072,16 @@ static int tuner_s_radio(struct v4l2_subdev *sd) /** * tuner_s_power - controls the power state of the tuner * @sd: pointer to struct v4l2_subdev - * @on: a zero value puts the tuner to sleep, non-zero wakes it up + * @on: a zero value puts the tuner to sleep */ static int tuner_s_power(struct v4l2_subdev *sd, int on) { struct tuner *t = to_tuner(sd); struct analog_demod_ops *analog_ops = &t->fe.ops.analog_ops; - if (on) { - if (t->standby && set_mode(t, t->mode) == 0) { - tuner_dbg("Waking up tuner\n"); - set_freq(t, 0); - } + /* FIXME: Why this function don't wake the tuner if on != 0 ? */ + if (on) return 0; - } tuner_dbg("Putting tuner to sleep\n"); t->standby = true; @@ -1064,36 +1093,28 @@ static int tuner_s_power(struct v4l2_subdev *sd, int on) static int tuner_s_std(struct v4l2_subdev *sd, v4l2_std_id std) { struct tuner *t = to_tuner(sd); + struct i2c_client *client = v4l2_get_subdevdata(sd); - if (set_mode(t, V4L2_TUNER_ANALOG_TV)) + if (set_mode_freq(client, t, V4L2_TUNER_ANALOG_TV, 0) == -EINVAL) return 0; - t->std = tuner_fixup_std(t, std); - if (t->std != std) - tuner_dbg("Fixup standard %llx to %llx\n", std, t->std); - set_freq(t, 0); + t->std = std; + tuner_fixup_std(t); + return 0; } static int tuner_s_frequency(struct v4l2_subdev *sd, struct v4l2_frequency *f) { struct tuner *t = to_tuner(sd); + struct i2c_client *client = v4l2_get_subdevdata(sd); + + if (set_mode_freq(client, t, f->type, f->frequency) == -EINVAL) + return 0; - if (set_mode(t, f->type) == 0) - set_freq(t, f->frequency); return 0; } -/** - * tuner_g_frequency - Get the tuned frequency for the tuner - * @sd: pointer to struct v4l2_subdev - * @f: pointer to struct v4l2_frequency - * - * At return, the structure f will be filled with tuner frequency - * if the tuner matches the f->type. - * Note: f->type should be initialized before calling it. - * This is done by either video_ioctl2 or by the bridge driver. - */ static int tuner_g_frequency(struct v4l2_subdev *sd, struct v4l2_frequency *f) { struct tuner *t = to_tuner(sd); @@ -1101,7 +1122,8 @@ static int tuner_g_frequency(struct v4l2_subdev *sd, struct v4l2_frequency *f) if (check_mode(t, f->type) == -EINVAL) return 0; - if (f->type == t->mode && fe_tuner_ops->get_frequency && !t->standby) { + f->type = t->mode; + if (fe_tuner_ops->get_frequency && !t->standby) { u32 abs_freq; fe_tuner_ops->get_frequency(&t->fe, &abs_freq); @@ -1109,22 +1131,12 @@ static int tuner_g_frequency(struct v4l2_subdev *sd, struct v4l2_frequency *f) DIV_ROUND_CLOSEST(abs_freq * 2, 125) : DIV_ROUND_CLOSEST(abs_freq, 62500); } else { - f->frequency = (V4L2_TUNER_RADIO == f->type) ? + f->frequency = (V4L2_TUNER_RADIO == t->mode) ? t->radio_freq : t->tv_freq; } return 0; } -/** - * tuner_g_tuner - Fill in tuner information - * @sd: pointer to struct v4l2_subdev - * @vt: pointer to struct v4l2_tuner - * - * At return, the structure vt will be filled with tuner information - * if the tuner matches vt->type. - * Note: vt->type should be initialized before calling it. - * This is done by either video_ioctl2 or by the bridge driver. - */ static int tuner_g_tuner(struct v4l2_subdev *sd, struct v4l2_tuner *vt) { struct tuner *t = to_tuner(sd); @@ -1133,58 +1145,48 @@ static int tuner_g_tuner(struct v4l2_subdev *sd, struct v4l2_tuner *vt) if (check_mode(t, vt->type) == -EINVAL) return 0; - if (vt->type == t->mode && analog_ops->get_afc) + vt->type = t->mode; + if (analog_ops->get_afc) vt->afc = analog_ops->get_afc(&t->fe); - if (vt->type == V4L2_TUNER_ANALOG_TV) + if (t->mode == V4L2_TUNER_ANALOG_TV) vt->capability |= V4L2_TUNER_CAP_NORM; - if (vt->type != V4L2_TUNER_RADIO) { + if (t->mode != V4L2_TUNER_RADIO) { vt->rangelow = tv_range[0] * 16; vt->rangehigh = tv_range[1] * 16; return 0; } /* radio mode */ - if (vt->type == t->mode) { - vt->rxsubchans = V4L2_TUNER_SUB_MONO | V4L2_TUNER_SUB_STEREO; - if (fe_tuner_ops->get_status) { - u32 tuner_status; - - fe_tuner_ops->get_status(&t->fe, &tuner_status); - vt->rxsubchans = - (tuner_status & TUNER_STATUS_STEREO) ? - V4L2_TUNER_SUB_STEREO : - V4L2_TUNER_SUB_MONO; - } - if (analog_ops->has_signal) - vt->signal = analog_ops->has_signal(&t->fe); - vt->audmode = t->audmode; + vt->rxsubchans = V4L2_TUNER_SUB_MONO | V4L2_TUNER_SUB_STEREO; + if (fe_tuner_ops->get_status) { + u32 tuner_status; + + fe_tuner_ops->get_status(&t->fe, &tuner_status); + vt->rxsubchans = + (tuner_status & TUNER_STATUS_STEREO) ? + V4L2_TUNER_SUB_STEREO : + V4L2_TUNER_SUB_MONO; } + if (analog_ops->has_signal) + vt->signal = analog_ops->has_signal(&t->fe); vt->capability |= V4L2_TUNER_CAP_LOW | V4L2_TUNER_CAP_STEREO; + vt->audmode = t->audmode; vt->rangelow = radio_range[0] * 16000; vt->rangehigh = radio_range[1] * 16000; return 0; } -/** - * tuner_s_tuner - Set the tuner's audio mode - * @sd: pointer to struct v4l2_subdev - * @vt: pointer to struct v4l2_tuner - * - * Sets the audio mode if the tuner matches vt->type. - * Note: vt->type should be initialized before calling it. - * This is done by either video_ioctl2 or by the bridge driver. - */ static int tuner_s_tuner(struct v4l2_subdev *sd, struct v4l2_tuner *vt) { struct tuner *t = to_tuner(sd); + struct i2c_client *client = v4l2_get_subdevdata(sd); - if (set_mode(t, vt->type)) + if (set_mode_freq(client, t, vt->type, 0) == -EINVAL) return 0; if (t->mode == V4L2_TUNER_RADIO) t->audmode = vt->audmode; - set_freq(t, 0); return 0; } @@ -1219,8 +1221,7 @@ static int tuner_resume(struct i2c_client *c) tuner_dbg("resume\n"); if (!t->standby) - if (set_mode(t, t->mode) == 0) - set_freq(t, 0); + set_mode_freq(c, t, t->type, 0); return 0; } diff --git a/trunk/drivers/media/video/uvc/uvc_entity.c b/trunk/drivers/media/video/uvc/uvc_entity.c index 48fea373c25a..c3ab0c813be2 100644 --- a/trunk/drivers/media/video/uvc/uvc_entity.c +++ b/trunk/drivers/media/video/uvc/uvc_entity.c @@ -27,20 +27,14 @@ static int uvc_mc_register_entity(struct uvc_video_chain *chain, struct uvc_entity *entity) { const u32 flags = MEDIA_LNK_FL_ENABLED | MEDIA_LNK_FL_IMMUTABLE; - struct media_entity *sink; + struct uvc_entity *remote; unsigned int i; - int ret; - - sink = (UVC_ENTITY_TYPE(entity) == UVC_TT_STREAMING) - ? (entity->vdev ? &entity->vdev->entity : NULL) - : &entity->subdev.entity; - if (sink == NULL) - return 0; + u8 remote_pad; + int ret = 0; for (i = 0; i < entity->num_pads; ++i) { struct media_entity *source; - struct uvc_entity *remote; - u8 remote_pad; + struct media_entity *sink; if (!(entity->pads[i].flags & MEDIA_PAD_FL_SINK)) continue; @@ -49,11 +43,10 @@ static int uvc_mc_register_entity(struct uvc_video_chain *chain, if (remote == NULL) return -EINVAL; - source = (UVC_ENTITY_TYPE(remote) != UVC_TT_STREAMING) - ? (remote->vdev ? &remote->vdev->entity : NULL) - : &remote->subdev.entity; - if (source == NULL) - continue; + source = (UVC_ENTITY_TYPE(remote) == UVC_TT_STREAMING) + ? &remote->vdev->entity : &remote->subdev.entity; + sink = (UVC_ENTITY_TYPE(entity) == UVC_TT_STREAMING) + ? &entity->vdev->entity : &entity->subdev.entity; remote_pad = remote->num_pads - 1; ret = media_entity_create_link(source, remote_pad, @@ -62,10 +55,11 @@ static int uvc_mc_register_entity(struct uvc_video_chain *chain, return ret; } - if (UVC_ENTITY_TYPE(entity) == UVC_TT_STREAMING) - return 0; + if (UVC_ENTITY_TYPE(entity) != UVC_TT_STREAMING) + ret = v4l2_device_register_subdev(&chain->dev->vdev, + &entity->subdev); - return v4l2_device_register_subdev(&chain->dev->vdev, &entity->subdev); + return ret; } static struct v4l2_subdev_ops uvc_subdev_ops = { @@ -90,11 +84,9 @@ static int uvc_mc_init_entity(struct uvc_entity *entity) ret = media_entity_init(&entity->subdev.entity, entity->num_pads, entity->pads, 0); - } else if (entity->vdev != NULL) { + } else ret = media_entity_init(&entity->vdev->entity, entity->num_pads, entity->pads, 0); - } else - ret = 0; return ret; } diff --git a/trunk/drivers/media/video/uvc/uvc_queue.c b/trunk/drivers/media/video/uvc/uvc_queue.c index f90ce9fce539..109a06384a8f 100644 --- a/trunk/drivers/media/video/uvc/uvc_queue.c +++ b/trunk/drivers/media/video/uvc/uvc_queue.c @@ -104,8 +104,6 @@ static int __uvc_free_buffers(struct uvc_video_queue *queue) } if (queue->count) { - uvc_queue_cancel(queue, 0); - INIT_LIST_HEAD(&queue->mainqueue); vfree(queue->mem); queue->count = 0; } diff --git a/trunk/drivers/media/video/uvc/uvc_video.c b/trunk/drivers/media/video/uvc/uvc_video.c index 49994793cc77..fc766b9f24c5 100644 --- a/trunk/drivers/media/video/uvc/uvc_video.c +++ b/trunk/drivers/media/video/uvc/uvc_video.c @@ -1255,10 +1255,8 @@ int uvc_video_enable(struct uvc_streaming *stream, int enable) /* Commit the streaming parameters. */ ret = uvc_commit_video(stream, &stream->ctrl); - if (ret < 0) { - uvc_queue_enable(&stream->queue, 0); + if (ret < 0) return ret; - } return uvc_init_video(stream, GFP_KERNEL); } diff --git a/trunk/drivers/media/video/v4l2-dev.c b/trunk/drivers/media/video/v4l2-dev.c index 06f14008b346..19d5ae293780 100644 --- a/trunk/drivers/media/video/v4l2-dev.c +++ b/trunk/drivers/media/video/v4l2-dev.c @@ -167,12 +167,6 @@ static void v4l2_device_release(struct device *cd) mutex_unlock(&videodev_lock); -#if defined(CONFIG_MEDIA_CONTROLLER) - if (vdev->v4l2_dev && vdev->v4l2_dev->mdev && - vdev->vfl_type != VFL_TYPE_SUBDEV) - media_device_unregister_entity(&vdev->entity); -#endif - /* Release video_device and perform other cleanups as needed. */ vdev->release(vdev); @@ -395,6 +389,9 @@ static int v4l2_mmap(struct file *filp, struct vm_area_struct *vm) static int v4l2_open(struct inode *inode, struct file *filp) { struct video_device *vdev; +#if defined(CONFIG_MEDIA_CONTROLLER) + struct media_entity *entity = NULL; +#endif int ret = 0; /* Check if the video device is available */ @@ -408,6 +405,17 @@ static int v4l2_open(struct inode *inode, struct file *filp) /* and increase the device refcount */ video_get(vdev); mutex_unlock(&videodev_lock); +#if defined(CONFIG_MEDIA_CONTROLLER) + if (vdev->v4l2_dev && vdev->v4l2_dev->mdev && + vdev->vfl_type != VFL_TYPE_SUBDEV) { + entity = media_entity_get(&vdev->entity); + if (!entity) { + ret = -EBUSY; + video_put(vdev); + return ret; + } + } +#endif if (vdev->fops->open) { if (vdev->lock && mutex_lock_interruptible(vdev->lock)) { ret = -ERESTARTSYS; @@ -423,8 +431,14 @@ static int v4l2_open(struct inode *inode, struct file *filp) err: /* decrease the refcount in case of an error */ - if (ret) + if (ret) { +#if defined(CONFIG_MEDIA_CONTROLLER) + if (vdev->v4l2_dev && vdev->v4l2_dev->mdev && + vdev->vfl_type != VFL_TYPE_SUBDEV) + media_entity_put(entity); +#endif video_put(vdev); + } return ret; } @@ -441,6 +455,11 @@ static int v4l2_release(struct inode *inode, struct file *filp) if (vdev->lock) mutex_unlock(vdev->lock); } +#if defined(CONFIG_MEDIA_CONTROLLER) + if (vdev->v4l2_dev && vdev->v4l2_dev->mdev && + vdev->vfl_type != VFL_TYPE_SUBDEV) + media_entity_put(&vdev->entity); +#endif /* decrease the refcount unconditionally since the release() return value is ignored. */ video_put(vdev); @@ -735,6 +754,12 @@ void video_unregister_device(struct video_device *vdev) if (!vdev || !video_is_registered(vdev)) return; +#if defined(CONFIG_MEDIA_CONTROLLER) + if (vdev->v4l2_dev && vdev->v4l2_dev->mdev && + vdev->vfl_type != VFL_TYPE_SUBDEV) + media_device_unregister_entity(&vdev->entity); +#endif + mutex_lock(&videodev_lock); /* This must be in a critical section to prevent a race with v4l2_open. * Once this bit has been cleared video_get may never be called again. diff --git a/trunk/drivers/media/video/v4l2-ioctl.c b/trunk/drivers/media/video/v4l2-ioctl.c index 69e8c6ffcc49..506edcc2ddeb 100644 --- a/trunk/drivers/media/video/v4l2-ioctl.c +++ b/trunk/drivers/media/video/v4l2-ioctl.c @@ -1822,8 +1822,6 @@ static long __video_do_ioctl(struct file *file, if (!ops->vidioc_g_tuner) break; - p->type = (vfd->vfl_type == VFL_TYPE_RADIO) ? - V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; ret = ops->vidioc_g_tuner(file, fh, p); if (!ret) dbgarg(cmd, "index=%d, name=%s, type=%d, " @@ -1842,8 +1840,6 @@ static long __video_do_ioctl(struct file *file, if (!ops->vidioc_s_tuner) break; - p->type = (vfd->vfl_type == VFL_TYPE_RADIO) ? - V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; dbgarg(cmd, "index=%d, name=%s, type=%d, " "capability=0x%x, rangelow=%d, " "rangehigh=%d, signal=%d, afc=%d, " @@ -1862,8 +1858,6 @@ static long __video_do_ioctl(struct file *file, if (!ops->vidioc_g_frequency) break; - p->type = (vfd->vfl_type == VFL_TYPE_RADIO) ? - V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; ret = ops->vidioc_g_frequency(file, fh, p); if (!ret) dbgarg(cmd, "tuner=%d, type=%d, frequency=%d\n", @@ -1946,19 +1940,13 @@ static long __video_do_ioctl(struct file *file, case VIDIOC_S_HW_FREQ_SEEK: { struct v4l2_hw_freq_seek *p = arg; - enum v4l2_tuner_type type; if (!ops->vidioc_s_hw_freq_seek) break; - type = (vfd->vfl_type == VFL_TYPE_RADIO) ? - V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; dbgarg(cmd, - "tuner=%u, type=%u, seek_upward=%u, wrap_around=%u, spacing=%u\n", - p->tuner, p->type, p->seek_upward, p->wrap_around, p->spacing); - if (p->type != type) - ret = -EINVAL; - else - ret = ops->vidioc_s_hw_freq_seek(file, fh, p); + "tuner=%d, type=%d, seek_upward=%d, wrap_around=%d\n", + p->tuner, p->type, p->seek_upward, p->wrap_around); + ret = ops->vidioc_s_hw_freq_seek(file, fh, p); break; } case VIDIOC_ENUM_FRAMESIZES: diff --git a/trunk/drivers/media/video/videobuf2-core.c b/trunk/drivers/media/video/videobuf2-core.c index 3015e6000946..6ba1461d51ef 100644 --- a/trunk/drivers/media/video/videobuf2-core.c +++ b/trunk/drivers/media/video/videobuf2-core.c @@ -492,6 +492,13 @@ int vb2_reqbufs(struct vb2_queue *q, struct v4l2_requestbuffers *req) return -EINVAL; } + /* + * If the same number of buffers and memory access method is requested + * then return immediately. + */ + if (q->memory == req->memory && req->count == q->num_buffers) + return 0; + if (req->count == 0 || q->num_buffers != 0 || q->memory != req->memory) { /* * We already have buffers allocated, so first check if they @@ -532,9 +539,9 @@ int vb2_reqbufs(struct vb2_queue *q, struct v4l2_requestbuffers *req) /* Finally, allocate buffers and video memory */ ret = __vb2_queue_alloc(q, req->memory, num_buffers, num_planes, plane_sizes); - if (ret == 0) { - dprintk(1, "Memory allocation failed\n"); - return -ENOMEM; + if (ret < 0) { + dprintk(1, "Memory allocation failed with error: %d\n", ret); + return ret; } /* @@ -1189,7 +1196,6 @@ static void __vb2_queue_cancel(struct vb2_queue *q) * has not already dequeued before initiating cancel. */ INIT_LIST_HEAD(&q->done_list); - atomic_set(&q->queued_count, 0); wake_up_all(&q->done_wq); /* diff --git a/trunk/drivers/media/video/videobuf2-dma-sg.c b/trunk/drivers/media/video/videobuf2-dma-sg.c index 10a20d9509d9..b2d9485aac75 100644 --- a/trunk/drivers/media/video/videobuf2-dma-sg.c +++ b/trunk/drivers/media/video/videobuf2-dma-sg.c @@ -62,7 +62,7 @@ static void *vb2_dma_sg_alloc(void *alloc_ctx, unsigned long size) goto fail_pages_array_alloc; for (i = 0; i < buf->sg_desc.num_pages; ++i) { - buf->pages[i] = alloc_page(GFP_KERNEL | __GFP_ZERO | __GFP_NOWARN); + buf->pages[i] = alloc_page(GFP_KERNEL | __GFP_ZERO); if (NULL == buf->pages[i]) goto fail_pages_alloc; sg_set_page(&buf->sg_desc.sglist[i], diff --git a/trunk/drivers/mfd/Kconfig b/trunk/drivers/mfd/Kconfig index 6ca938a6bf94..0f09c057e796 100644 --- a/trunk/drivers/mfd/Kconfig +++ b/trunk/drivers/mfd/Kconfig @@ -728,9 +728,6 @@ config MFD_TPS65910 if you say yes here you get support for the TPS65910 series of Power Management chips. -config TPS65911_COMPARATOR - tristate - endif # MFD_SUPPORT menu "Multimedia Capabilities Port drivers" diff --git a/trunk/drivers/mfd/Makefile b/trunk/drivers/mfd/Makefile index d7d47d2a4c76..efe3cc33ed92 100644 --- a/trunk/drivers/mfd/Makefile +++ b/trunk/drivers/mfd/Makefile @@ -94,4 +94,3 @@ obj-$(CONFIG_MFD_OMAP_USB_HOST) += omap-usb-host.o obj-$(CONFIG_MFD_PM8921_CORE) += pm8921-core.o obj-$(CONFIG_MFD_PM8XXX_IRQ) += pm8xxx-irq.o obj-$(CONFIG_MFD_TPS65910) += tps65910.o tps65910-irq.o -obj-$(CONFIG_TPS65911_COMPARATOR) += tps65911-comparator.o diff --git a/trunk/drivers/mfd/asic3.c b/trunk/drivers/mfd/asic3.c index c71ae09430c5..c27fd1fc3b86 100644 --- a/trunk/drivers/mfd/asic3.c +++ b/trunk/drivers/mfd/asic3.c @@ -619,7 +619,6 @@ static void asic3_clk_disable(struct asic3 *asic, struct asic3_clk *clk) /* MFD cells (SPI, PWM, LED, DS1WM, MMC) */ static struct ds1wm_driver_data ds1wm_pdata = { .active_high = 1, - .reset_recover_delay = 1, }; static struct resource ds1wm_resources[] = { diff --git a/trunk/drivers/mfd/htc-pasic3.c b/trunk/drivers/mfd/htc-pasic3.c index 04c7093d6499..2808bd125d13 100644 --- a/trunk/drivers/mfd/htc-pasic3.c +++ b/trunk/drivers/mfd/htc-pasic3.c @@ -99,7 +99,6 @@ static int ds1wm_disable(struct platform_device *pdev) static struct ds1wm_driver_data ds1wm_pdata = { .active_high = 0, - .reset_recover_delay = 1, }; static struct resource ds1wm_resources[] __initdata = { diff --git a/trunk/drivers/mfd/omap-usb-host.c b/trunk/drivers/mfd/omap-usb-host.c index 1717144fe7f4..855219526ccb 100644 --- a/trunk/drivers/mfd/omap-usb-host.c +++ b/trunk/drivers/mfd/omap-usb-host.c @@ -26,6 +26,7 @@ #include #include #include +#include #define USBHS_DRIVER_NAME "usbhs-omap" #define OMAP_EHCI_DEVICE "ehci-omap" @@ -146,9 +147,6 @@ struct usbhs_hcd_omap { - struct clk *usbhost_ick; - struct clk *usbhost_hs_fck; - struct clk *usbhost_fs_fck; struct clk *xclk60mhsp1_ck; struct clk *xclk60mhsp2_ck; struct clk *utmi_p1_fck; @@ -158,8 +156,6 @@ struct usbhs_hcd_omap { struct clk *usbhost_p2_fck; struct clk *usbtll_p2_fck; struct clk *init_60m_fclk; - struct clk *usbtll_fck; - struct clk *usbtll_ick; void __iomem *uhh_base; void __iomem *tll_base; @@ -353,46 +349,13 @@ static int __devinit usbhs_omap_probe(struct platform_device *pdev) omap->platdata.ehci_data = pdata->ehci_data; omap->platdata.ohci_data = pdata->ohci_data; - omap->usbhost_ick = clk_get(dev, "usbhost_ick"); - if (IS_ERR(omap->usbhost_ick)) { - ret = PTR_ERR(omap->usbhost_ick); - dev_err(dev, "usbhost_ick failed error:%d\n", ret); - goto err_end; - } - - omap->usbhost_hs_fck = clk_get(dev, "hs_fck"); - if (IS_ERR(omap->usbhost_hs_fck)) { - ret = PTR_ERR(omap->usbhost_hs_fck); - dev_err(dev, "usbhost_hs_fck failed error:%d\n", ret); - goto err_usbhost_ick; - } - - omap->usbhost_fs_fck = clk_get(dev, "fs_fck"); - if (IS_ERR(omap->usbhost_fs_fck)) { - ret = PTR_ERR(omap->usbhost_fs_fck); - dev_err(dev, "usbhost_fs_fck failed error:%d\n", ret); - goto err_usbhost_hs_fck; - } - - omap->usbtll_fck = clk_get(dev, "usbtll_fck"); - if (IS_ERR(omap->usbtll_fck)) { - ret = PTR_ERR(omap->usbtll_fck); - dev_err(dev, "usbtll_fck failed error:%d\n", ret); - goto err_usbhost_fs_fck; - } - - omap->usbtll_ick = clk_get(dev, "usbtll_ick"); - if (IS_ERR(omap->usbtll_ick)) { - ret = PTR_ERR(omap->usbtll_ick); - dev_err(dev, "usbtll_ick failed error:%d\n", ret); - goto err_usbtll_fck; - } + pm_runtime_enable(&pdev->dev); omap->utmi_p1_fck = clk_get(dev, "utmi_p1_gfclk"); if (IS_ERR(omap->utmi_p1_fck)) { ret = PTR_ERR(omap->utmi_p1_fck); dev_err(dev, "utmi_p1_gfclk failed error:%d\n", ret); - goto err_usbtll_ick; + goto err_end; } omap->xclk60mhsp1_ck = clk_get(dev, "xclk60mhsp1_ck"); @@ -522,22 +485,8 @@ static int __devinit usbhs_omap_probe(struct platform_device *pdev) err_utmi_p1_fck: clk_put(omap->utmi_p1_fck); -err_usbtll_ick: - clk_put(omap->usbtll_ick); - -err_usbtll_fck: - clk_put(omap->usbtll_fck); - -err_usbhost_fs_fck: - clk_put(omap->usbhost_fs_fck); - -err_usbhost_hs_fck: - clk_put(omap->usbhost_hs_fck); - -err_usbhost_ick: - clk_put(omap->usbhost_ick); - err_end: + pm_runtime_disable(&pdev->dev); kfree(omap); end_probe: @@ -571,11 +520,7 @@ static int __devexit usbhs_omap_remove(struct platform_device *pdev) clk_put(omap->utmi_p2_fck); clk_put(omap->xclk60mhsp1_ck); clk_put(omap->utmi_p1_fck); - clk_put(omap->usbtll_ick); - clk_put(omap->usbtll_fck); - clk_put(omap->usbhost_fs_fck); - clk_put(omap->usbhost_hs_fck); - clk_put(omap->usbhost_ick); + pm_runtime_disable(&pdev->dev); kfree(omap); return 0; @@ -695,7 +640,6 @@ static int usbhs_enable(struct device *dev) struct usbhs_omap_platform_data *pdata = &omap->platdata; unsigned long flags = 0; int ret = 0; - unsigned long timeout; unsigned reg; dev_dbg(dev, "starting TI HSUSB Controller\n"); @@ -708,11 +652,7 @@ static int usbhs_enable(struct device *dev) if (omap->count > 0) goto end_count; - clk_enable(omap->usbhost_ick); - clk_enable(omap->usbhost_hs_fck); - clk_enable(omap->usbhost_fs_fck); - clk_enable(omap->usbtll_fck); - clk_enable(omap->usbtll_ick); + pm_runtime_get_sync(dev); if (pdata->ehci_data->phy_reset) { if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[0])) { @@ -736,50 +676,6 @@ static int usbhs_enable(struct device *dev) omap->usbhs_rev = usbhs_read(omap->uhh_base, OMAP_UHH_REVISION); dev_dbg(dev, "OMAP UHH_REVISION 0x%x\n", omap->usbhs_rev); - /* perform TLL soft reset, and wait until reset is complete */ - usbhs_write(omap->tll_base, OMAP_USBTLL_SYSCONFIG, - OMAP_USBTLL_SYSCONFIG_SOFTRESET); - - /* Wait for TLL reset to complete */ - timeout = jiffies + msecs_to_jiffies(1000); - while (!(usbhs_read(omap->tll_base, OMAP_USBTLL_SYSSTATUS) - & OMAP_USBTLL_SYSSTATUS_RESETDONE)) { - cpu_relax(); - - if (time_after(jiffies, timeout)) { - dev_dbg(dev, "operation timed out\n"); - ret = -EINVAL; - goto err_tll; - } - } - - dev_dbg(dev, "TLL RESET DONE\n"); - - /* (1<<3) = no idle mode only for initial debugging */ - usbhs_write(omap->tll_base, OMAP_USBTLL_SYSCONFIG, - OMAP_USBTLL_SYSCONFIG_ENAWAKEUP | - OMAP_USBTLL_SYSCONFIG_SIDLEMODE | - OMAP_USBTLL_SYSCONFIG_AUTOIDLE); - - /* Put UHH in NoIdle/NoStandby mode */ - reg = usbhs_read(omap->uhh_base, OMAP_UHH_SYSCONFIG); - if (is_omap_usbhs_rev1(omap)) { - reg |= (OMAP_UHH_SYSCONFIG_ENAWAKEUP - | OMAP_UHH_SYSCONFIG_SIDLEMODE - | OMAP_UHH_SYSCONFIG_CACTIVITY - | OMAP_UHH_SYSCONFIG_MIDLEMODE); - reg &= ~OMAP_UHH_SYSCONFIG_AUTOIDLE; - - - } else if (is_omap_usbhs_rev2(omap)) { - reg &= ~OMAP4_UHH_SYSCONFIG_IDLEMODE_CLEAR; - reg |= OMAP4_UHH_SYSCONFIG_NOIDLE; - reg &= ~OMAP4_UHH_SYSCONFIG_STDBYMODE_CLEAR; - reg |= OMAP4_UHH_SYSCONFIG_NOSTDBY; - } - - usbhs_write(omap->uhh_base, OMAP_UHH_SYSCONFIG, reg); - reg = usbhs_read(omap->uhh_base, OMAP_UHH_HOSTCONFIG); /* setup ULPI bypass and burst configurations */ reg |= (OMAP_UHH_HOSTCONFIG_INCR4_BURST_EN @@ -919,6 +815,8 @@ static int usbhs_enable(struct device *dev) return 0; err_tll: + pm_runtime_put_sync(dev); + spin_unlock_irqrestore(&omap->lock, flags); if (pdata->ehci_data->phy_reset) { if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[0])) gpio_free(pdata->ehci_data->reset_gpio_port[0]); @@ -926,13 +824,6 @@ static int usbhs_enable(struct device *dev) if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[1])) gpio_free(pdata->ehci_data->reset_gpio_port[1]); } - - clk_disable(omap->usbtll_ick); - clk_disable(omap->usbtll_fck); - clk_disable(omap->usbhost_fs_fck); - clk_disable(omap->usbhost_hs_fck); - clk_disable(omap->usbhost_ick); - spin_unlock_irqrestore(&omap->lock, flags); return ret; } @@ -1005,11 +896,7 @@ static void usbhs_disable(struct device *dev) clk_disable(omap->utmi_p1_fck); } - clk_disable(omap->usbtll_ick); - clk_disable(omap->usbtll_fck); - clk_disable(omap->usbhost_fs_fck); - clk_disable(omap->usbhost_hs_fck); - clk_disable(omap->usbhost_ick); + pm_runtime_put_sync(dev); /* The gpio_free migh sleep; so unlock the spinlock */ spin_unlock_irqrestore(&omap->lock, flags); diff --git a/trunk/drivers/mfd/tps65911-comparator.c b/trunk/drivers/mfd/tps65911-comparator.c index 283ac6759757..3d2dc56a3d40 100644 --- a/trunk/drivers/mfd/tps65911-comparator.c +++ b/trunk/drivers/mfd/tps65911-comparator.c @@ -125,7 +125,7 @@ static DEVICE_ATTR(comp2_threshold, S_IRUGO, comp_threshold_show, NULL); static __devinit int tps65911_comparator_probe(struct platform_device *pdev) { struct tps65910 *tps65910 = dev_get_drvdata(pdev->dev.parent); - struct tps65910_board *pdata = dev_get_platdata(tps65910->dev); + struct tps65910_platform_data *pdata = dev_get_platdata(tps65910->dev); int ret; ret = comp_threshold_set(tps65910, COMP1, pdata->vmbch_threshold); diff --git a/trunk/drivers/misc/cb710/sgbuf2.c b/trunk/drivers/misc/cb710/sgbuf2.c index 2a40d0efdff5..d019746551f3 100644 --- a/trunk/drivers/misc/cb710/sgbuf2.c +++ b/trunk/drivers/misc/cb710/sgbuf2.c @@ -47,7 +47,7 @@ static uint32_t sg_dwiter_read_buffer(struct sg_mapping_iter *miter) static inline bool needs_unaligned_copy(const void *ptr) { -#ifdef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS +#ifdef HAVE_EFFICIENT_UNALIGNED_ACCESS return false; #else return ((ptr - NULL) & 3) != 0; diff --git a/trunk/drivers/misc/ioc4.c b/trunk/drivers/misc/ioc4.c index df03dd3bd0e2..668d41e594a9 100644 --- a/trunk/drivers/misc/ioc4.c +++ b/trunk/drivers/misc/ioc4.c @@ -270,7 +270,7 @@ ioc4_variant(struct ioc4_driver_data *idd) return IOC4_VARIANT_PCI_RT; } -static void +static void __devinit ioc4_load_modules(struct work_struct *work) { request_module("sgiioc4"); diff --git a/trunk/drivers/misc/lkdtm.c b/trunk/drivers/misc/lkdtm.c index 150cd7061b80..81d7fa4ec0db 100644 --- a/trunk/drivers/misc/lkdtm.c +++ b/trunk/drivers/misc/lkdtm.c @@ -120,7 +120,6 @@ static int recur_count = REC_NUM_DEFAULT; static enum cname cpoint = CN_INVALID; static enum ctype cptype = CT_NONE; static int count = DEFAULT_COUNT; -static DEFINE_SPINLOCK(count_lock); module_param(recur_count, int, 0644); MODULE_PARM_DESC(recur_count, " Recursion level for the stack overflow test, "\ @@ -231,14 +230,11 @@ static const char *cp_name_to_str(enum cname name) static int lkdtm_parse_commandline(void) { int i; - unsigned long flags; if (cpoint_count < 1 || recur_count < 1) return -EINVAL; - spin_lock_irqsave(&count_lock, flags); count = cpoint_count; - spin_unlock_irqrestore(&count_lock, flags); /* No special parameters */ if (!cpoint_type && !cpoint_name) @@ -353,9 +349,6 @@ static void lkdtm_do_action(enum ctype which) static void lkdtm_handler(void) { - unsigned long flags; - - spin_lock_irqsave(&count_lock, flags); count--; printk(KERN_INFO "lkdtm: Crash point %s of type %s hit, trigger in %d rounds\n", cp_name_to_str(cpoint), cp_type_to_str(cptype), count); @@ -364,7 +357,6 @@ static void lkdtm_handler(void) lkdtm_do_action(cptype); count = cpoint_count; } - spin_unlock_irqrestore(&count_lock, flags); } static int lkdtm_register_cpoint(enum cname which) diff --git a/trunk/drivers/misc/pti.c b/trunk/drivers/misc/pti.c index 374dfcfccd07..bb6f9255c17c 100644 --- a/trunk/drivers/misc/pti.c +++ b/trunk/drivers/misc/pti.c @@ -317,8 +317,7 @@ EXPORT_SYMBOL_GPL(pti_request_masterchannel); * a master, channel ID address * used to write to PTI HW. * - * @mc: master, channel apeture ID address to be released. This - * will de-allocate the structure via kfree(). + * @mc: master, channel apeture ID address to be released. */ void pti_release_masterchannel(struct pti_masterchannel *mc) { @@ -476,10 +475,8 @@ static int pti_tty_install(struct tty_driver *driver, struct tty_struct *tty) else pti_tty_data->mc = pti_request_masterchannel(2); - if (pti_tty_data->mc == NULL) { - kfree(pti_tty_data); + if (pti_tty_data->mc == NULL) return -ENXIO; - } tty->driver_data = pti_tty_data; } @@ -498,7 +495,7 @@ static void pti_tty_cleanup(struct tty_struct *tty) if (pti_tty_data == NULL) return; pti_release_masterchannel(pti_tty_data->mc); - kfree(pti_tty_data); + kfree(tty->driver_data); tty->driver_data = NULL; } @@ -584,7 +581,7 @@ static int pti_char_open(struct inode *inode, struct file *filp) static int pti_char_release(struct inode *inode, struct file *filp) { pti_release_masterchannel(filp->private_data); - filp->private_data = NULL; + kfree(filp->private_data); return 0; } diff --git a/trunk/drivers/misc/ti-st/st_core.c b/trunk/drivers/misc/ti-st/st_core.c index 54c91ffe4a91..f91f82eabda7 100644 --- a/trunk/drivers/misc/ti-st/st_core.c +++ b/trunk/drivers/misc/ti-st/st_core.c @@ -605,7 +605,7 @@ long st_unregister(struct st_proto_s *proto) pr_debug("%s: %d ", __func__, proto->chnl_id); st_kim_ref(&st_gdata, 0); - if (!st_gdata || proto->chnl_id >= ST_MAX_CHANNELS) { + if (proto->chnl_id >= ST_MAX_CHANNELS) { pr_err(" chnl_id %d not supported", proto->chnl_id); return -EPROTONOSUPPORT; } diff --git a/trunk/drivers/misc/ti-st/st_kim.c b/trunk/drivers/misc/ti-st/st_kim.c index 38fd2f04c07e..5da93ee6f6be 100644 --- a/trunk/drivers/misc/ti-st/st_kim.c +++ b/trunk/drivers/misc/ti-st/st_kim.c @@ -245,9 +245,9 @@ void skip_change_remote_baud(unsigned char **ptr, long *len) pr_err("invalid action after change remote baud command"); } else { *ptr = *ptr + sizeof(struct bts_action) + - ((struct bts_action *)cur_action)->size; + ((struct bts_action *)nxt_action)->size; *len = *len - (sizeof(struct bts_action) + - ((struct bts_action *)cur_action)->size); + ((struct bts_action *)nxt_action)->size); /* warn user on not commenting these in firmware */ pr_warn("skipping the wait event of change remote baud"); } @@ -604,10 +604,6 @@ void st_kim_ref(struct st_data_s **core_data, int id) struct kim_data_s *kim_gdata; /* get kim_gdata reference from platform device */ pdev = st_get_plat_device(id); - if (!pdev) { - *core_data = NULL; - return; - } kim_gdata = dev_get_drvdata(&pdev->dev); *core_data = kim_gdata->core_data; } diff --git a/trunk/drivers/mmc/card/block.c b/trunk/drivers/mmc/card/block.c index f85e42224559..71da5641e258 100644 --- a/trunk/drivers/mmc/card/block.c +++ b/trunk/drivers/mmc/card/block.c @@ -1024,7 +1024,7 @@ static struct mmc_blk_data *mmc_blk_alloc_req(struct mmc_card *card, INIT_LIST_HEAD(&md->part); md->usage = 1; - ret = mmc_init_queue(&md->queue, card, &md->lock, subname); + ret = mmc_init_queue(&md->queue, card, &md->lock); if (ret) goto err_putdisk; @@ -1297,9 +1297,6 @@ static void mmc_blk_remove(struct mmc_card *card) struct mmc_blk_data *md = mmc_get_drvdata(card); mmc_blk_remove_parts(card, md); - mmc_claim_host(card->host); - mmc_blk_part_switch(card, md); - mmc_release_host(card->host); mmc_blk_remove_req(md); mmc_set_drvdata(card, NULL); } diff --git a/trunk/drivers/mmc/card/queue.c b/trunk/drivers/mmc/card/queue.c index 6413afa318d2..c07322c2658c 100644 --- a/trunk/drivers/mmc/card/queue.c +++ b/trunk/drivers/mmc/card/queue.c @@ -106,12 +106,10 @@ static void mmc_request(struct request_queue *q) * @mq: mmc queue * @card: mmc card to attach this queue * @lock: queue lock - * @subname: partition subname * * Initialise a MMC card request queue. */ -int mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card, - spinlock_t *lock, const char *subname) +int mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card, spinlock_t *lock) { struct mmc_host *host = card->host; u64 limit = BLK_BOUNCE_HIGH; @@ -135,7 +133,12 @@ int mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card, mq->queue->limits.max_discard_sectors = UINT_MAX; if (card->erased_byte == 0) mq->queue->limits.discard_zeroes_data = 1; - mq->queue->limits.discard_granularity = card->pref_erase << 9; + if (!mmc_can_trim(card) && is_power_of_2(card->erase_size)) { + mq->queue->limits.discard_granularity = + card->erase_size << 9; + mq->queue->limits.discard_alignment = + card->erase_size << 9; + } if (mmc_can_secure_erase_trim(card)) queue_flag_set_unlocked(QUEUE_FLAG_SECDISCARD, mq->queue); @@ -206,8 +209,8 @@ int mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card, sema_init(&mq->thread_sem, 1); - mq->thread = kthread_run(mmc_queue_thread, mq, "mmcqd/%d%s", - host->index, subname ? subname : ""); + mq->thread = kthread_run(mmc_queue_thread, mq, "mmcqd/%d", + host->index); if (IS_ERR(mq->thread)) { ret = PTR_ERR(mq->thread); diff --git a/trunk/drivers/mmc/card/queue.h b/trunk/drivers/mmc/card/queue.h index 6223ef8dc9cd..64e66e0d4994 100644 --- a/trunk/drivers/mmc/card/queue.h +++ b/trunk/drivers/mmc/card/queue.h @@ -19,8 +19,7 @@ struct mmc_queue { unsigned int bounce_sg_len; }; -extern int mmc_init_queue(struct mmc_queue *, struct mmc_card *, spinlock_t *, - const char *); +extern int mmc_init_queue(struct mmc_queue *, struct mmc_card *, spinlock_t *); extern void mmc_cleanup_queue(struct mmc_queue *); extern void mmc_queue_suspend(struct mmc_queue *); extern void mmc_queue_resume(struct mmc_queue *); diff --git a/trunk/drivers/mmc/core/core.c b/trunk/drivers/mmc/core/core.c index 7843efe22359..68091dda3f31 100644 --- a/trunk/drivers/mmc/core/core.c +++ b/trunk/drivers/mmc/core/core.c @@ -1245,7 +1245,7 @@ static unsigned int mmc_mmc_erase_timeout(struct mmc_card *card, */ timeout_clks <<= 1; timeout_us += (timeout_clks * 1000) / - (mmc_host_clk_rate(card->host) / 1000); + (card->host->ios.clock / 1000); erase_timeout = timeout_us / 1000; diff --git a/trunk/drivers/mmc/core/mmc.c b/trunk/drivers/mmc/core/mmc.c index aa7d1d79b8c5..2a7e43bc796d 100644 --- a/trunk/drivers/mmc/core/mmc.c +++ b/trunk/drivers/mmc/core/mmc.c @@ -247,12 +247,12 @@ static int mmc_read_ext_csd(struct mmc_card *card, u8 *ext_csd) return 0; /* Version is coded in the CSD_STRUCTURE byte in the EXT_CSD register */ - card->ext_csd.raw_ext_csd_structure = ext_csd[EXT_CSD_STRUCTURE]; if (card->csd.structure == 3) { - if (card->ext_csd.raw_ext_csd_structure > 2) { + int ext_csd_struct = ext_csd[EXT_CSD_STRUCTURE]; + if (ext_csd_struct > 2) { printk(KERN_ERR "%s: unrecognised EXT_CSD structure " "version %d\n", mmc_hostname(card->host), - card->ext_csd.raw_ext_csd_structure); + ext_csd_struct); err = -EINVAL; goto out; } @@ -266,10 +266,6 @@ static int mmc_read_ext_csd(struct mmc_card *card, u8 *ext_csd) goto out; } - card->ext_csd.raw_sectors[0] = ext_csd[EXT_CSD_SEC_CNT + 0]; - card->ext_csd.raw_sectors[1] = ext_csd[EXT_CSD_SEC_CNT + 1]; - card->ext_csd.raw_sectors[2] = ext_csd[EXT_CSD_SEC_CNT + 2]; - card->ext_csd.raw_sectors[3] = ext_csd[EXT_CSD_SEC_CNT + 3]; if (card->ext_csd.rev >= 2) { card->ext_csd.sectors = ext_csd[EXT_CSD_SEC_CNT + 0] << 0 | @@ -281,7 +277,7 @@ static int mmc_read_ext_csd(struct mmc_card *card, u8 *ext_csd) if (card->ext_csd.sectors > (2u * 1024 * 1024 * 1024) / 512) mmc_card_set_blockaddr(card); } - card->ext_csd.raw_card_type = ext_csd[EXT_CSD_CARD_TYPE]; + switch (ext_csd[EXT_CSD_CARD_TYPE] & EXT_CSD_CARD_TYPE_MASK) { case EXT_CSD_CARD_TYPE_DDR_52 | EXT_CSD_CARD_TYPE_52 | EXT_CSD_CARD_TYPE_26: @@ -311,11 +307,6 @@ static int mmc_read_ext_csd(struct mmc_card *card, u8 *ext_csd) mmc_hostname(card->host)); } - card->ext_csd.raw_s_a_timeout = ext_csd[EXT_CSD_S_A_TIMEOUT]; - card->ext_csd.raw_erase_timeout_mult = - ext_csd[EXT_CSD_ERASE_TIMEOUT_MULT]; - card->ext_csd.raw_hc_erase_grp_size = - ext_csd[EXT_CSD_HC_ERASE_GRP_SIZE]; if (card->ext_csd.rev >= 3) { u8 sa_shift = ext_csd[EXT_CSD_S_A_TIMEOUT]; card->ext_csd.part_config = ext_csd[EXT_CSD_PART_CONFIG]; @@ -343,16 +334,6 @@ static int mmc_read_ext_csd(struct mmc_card *card, u8 *ext_csd) card->ext_csd.boot_size = ext_csd[EXT_CSD_BOOT_MULT] << 17; } - card->ext_csd.raw_hc_erase_gap_size = - ext_csd[EXT_CSD_PARTITION_ATTRIBUTE]; - card->ext_csd.raw_sec_trim_mult = - ext_csd[EXT_CSD_SEC_TRIM_MULT]; - card->ext_csd.raw_sec_erase_mult = - ext_csd[EXT_CSD_SEC_ERASE_MULT]; - card->ext_csd.raw_sec_feature_support = - ext_csd[EXT_CSD_SEC_FEATURE_SUPPORT]; - card->ext_csd.raw_trim_mult = - ext_csd[EXT_CSD_TRIM_MULT]; if (card->ext_csd.rev >= 4) { /* * Enhanced area feature support -- check whether the eMMC @@ -360,7 +341,7 @@ static int mmc_read_ext_csd(struct mmc_card *card, u8 *ext_csd) * area offset and size to user by adding sysfs interface. */ if ((ext_csd[EXT_CSD_PARTITION_SUPPORT] & 0x2) && - (ext_csd[EXT_CSD_PARTITION_ATTRIBUTE] & 0x1)) { + (ext_csd[EXT_CSD_PARTITION_ATTRIBUTE] & 0x1)) { u8 hc_erase_grp_sz = ext_csd[EXT_CSD_HC_ERASE_GRP_SIZE]; u8 hc_wp_grp_sz = @@ -420,17 +401,17 @@ static inline void mmc_free_ext_csd(u8 *ext_csd) } -static int mmc_compare_ext_csds(struct mmc_card *card, unsigned bus_width) +static int mmc_compare_ext_csds(struct mmc_card *card, u8 *ext_csd, + unsigned bus_width) { u8 *bw_ext_csd; int err; - if (bus_width == MMC_BUS_WIDTH_1) - return 0; - err = mmc_get_ext_csd(card, &bw_ext_csd); + if (err) + return err; - if (err || bw_ext_csd == NULL) { + if ((ext_csd == NULL || bw_ext_csd == NULL)) { if (bus_width != MMC_BUS_WIDTH_1) err = -EINVAL; goto out; @@ -440,40 +421,35 @@ static int mmc_compare_ext_csds(struct mmc_card *card, unsigned bus_width) goto out; /* only compare read only fields */ - err = (!(card->ext_csd.raw_partition_support == + err = (!(ext_csd[EXT_CSD_PARTITION_SUPPORT] == bw_ext_csd[EXT_CSD_PARTITION_SUPPORT]) && - (card->ext_csd.raw_erased_mem_count == + (ext_csd[EXT_CSD_ERASED_MEM_CONT] == bw_ext_csd[EXT_CSD_ERASED_MEM_CONT]) && - (card->ext_csd.rev == + (ext_csd[EXT_CSD_REV] == bw_ext_csd[EXT_CSD_REV]) && - (card->ext_csd.raw_ext_csd_structure == + (ext_csd[EXT_CSD_STRUCTURE] == bw_ext_csd[EXT_CSD_STRUCTURE]) && - (card->ext_csd.raw_card_type == + (ext_csd[EXT_CSD_CARD_TYPE] == bw_ext_csd[EXT_CSD_CARD_TYPE]) && - (card->ext_csd.raw_s_a_timeout == + (ext_csd[EXT_CSD_S_A_TIMEOUT] == bw_ext_csd[EXT_CSD_S_A_TIMEOUT]) && - (card->ext_csd.raw_hc_erase_gap_size == + (ext_csd[EXT_CSD_HC_WP_GRP_SIZE] == bw_ext_csd[EXT_CSD_HC_WP_GRP_SIZE]) && - (card->ext_csd.raw_erase_timeout_mult == + (ext_csd[EXT_CSD_ERASE_TIMEOUT_MULT] == bw_ext_csd[EXT_CSD_ERASE_TIMEOUT_MULT]) && - (card->ext_csd.raw_hc_erase_grp_size == + (ext_csd[EXT_CSD_HC_ERASE_GRP_SIZE] == bw_ext_csd[EXT_CSD_HC_ERASE_GRP_SIZE]) && - (card->ext_csd.raw_sec_trim_mult == + (ext_csd[EXT_CSD_SEC_TRIM_MULT] == bw_ext_csd[EXT_CSD_SEC_TRIM_MULT]) && - (card->ext_csd.raw_sec_erase_mult == + (ext_csd[EXT_CSD_SEC_ERASE_MULT] == bw_ext_csd[EXT_CSD_SEC_ERASE_MULT]) && - (card->ext_csd.raw_sec_feature_support == + (ext_csd[EXT_CSD_SEC_FEATURE_SUPPORT] == bw_ext_csd[EXT_CSD_SEC_FEATURE_SUPPORT]) && - (card->ext_csd.raw_trim_mult == + (ext_csd[EXT_CSD_TRIM_MULT] == bw_ext_csd[EXT_CSD_TRIM_MULT]) && - (card->ext_csd.raw_sectors[0] == - bw_ext_csd[EXT_CSD_SEC_CNT + 0]) && - (card->ext_csd.raw_sectors[1] == - bw_ext_csd[EXT_CSD_SEC_CNT + 1]) && - (card->ext_csd.raw_sectors[2] == - bw_ext_csd[EXT_CSD_SEC_CNT + 2]) && - (card->ext_csd.raw_sectors[3] == - bw_ext_csd[EXT_CSD_SEC_CNT + 3])); + memcmp(&ext_csd[EXT_CSD_SEC_CNT], + &bw_ext_csd[EXT_CSD_SEC_CNT], + 4) != 0); if (err) err = -EINVAL; @@ -794,6 +770,7 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr, */ if (!(host->caps & MMC_CAP_BUS_WIDTH_TEST)) err = mmc_compare_ext_csds(card, + ext_csd, bus_width); else err = mmc_bus_test(card, bus_width); diff --git a/trunk/drivers/mmc/core/sdio.c b/trunk/drivers/mmc/core/sdio.c index 262fff019177..4d0c15bfa514 100644 --- a/trunk/drivers/mmc/core/sdio.c +++ b/trunk/drivers/mmc/core/sdio.c @@ -691,54 +691,15 @@ static int mmc_sdio_resume(struct mmc_host *host) static int mmc_sdio_power_restore(struct mmc_host *host) { int ret; - u32 ocr; BUG_ON(!host); BUG_ON(!host->card); mmc_claim_host(host); - - /* - * Reset the card by performing the same steps that are taken by - * mmc_rescan_try_freq() and mmc_attach_sdio() during a "normal" probe. - * - * sdio_reset() is technically not needed. Having just powered up the - * hardware, it should already be in reset state. However, some - * platforms (such as SD8686 on OLPC) do not instantly cut power, - * meaning that a reset is required when restoring power soon after - * powering off. It is harmless in other cases. - * - * The CMD5 reset (mmc_send_io_op_cond()), according to the SDIO spec, - * is not necessary for non-removable cards. However, it is required - * for OLPC SD8686 (which expects a [CMD5,5,3,7] init sequence), and - * harmless in other situations. - * - * With these steps taken, mmc_select_voltage() is also required to - * restore the correct voltage setting of the card. - */ - sdio_reset(host); - mmc_go_idle(host); - mmc_send_if_cond(host, host->ocr_avail); - - ret = mmc_send_io_op_cond(host, 0, &ocr); - if (ret) - goto out; - - if (host->ocr_avail_sdio) - host->ocr_avail = host->ocr_avail_sdio; - - host->ocr = mmc_select_voltage(host, ocr & ~0x7F); - if (!host->ocr) { - ret = -EINVAL; - goto out; - } - ret = mmc_sdio_init_card(host, host->ocr, host->card, mmc_card_keep_power(host)); if (!ret && host->sdio_irqs) mmc_signal_sdio_irq(host); - -out: mmc_release_host(host); return ret; diff --git a/trunk/drivers/mmc/core/sdio_bus.c b/trunk/drivers/mmc/core/sdio_bus.c index d2565df8a7fb..d29b9c36919a 100644 --- a/trunk/drivers/mmc/core/sdio_bus.c +++ b/trunk/drivers/mmc/core/sdio_bus.c @@ -189,7 +189,7 @@ static int sdio_bus_remove(struct device *dev) /* Then undo the runtime PM settings in sdio_bus_probe() */ if (func->card->host->caps & MMC_CAP_POWER_OFF_CARD) - pm_runtime_put_sync(dev); + pm_runtime_put_noidle(dev); out: return ret; diff --git a/trunk/drivers/mmc/host/mmci.c b/trunk/drivers/mmc/host/mmci.c index fe140724a02e..7721de942c69 100644 --- a/trunk/drivers/mmc/host/mmci.c +++ b/trunk/drivers/mmc/host/mmci.c @@ -582,8 +582,6 @@ mmci_data_irq(struct mmci_host *host, struct mmc_data *data, data->error = -EILSEQ; } else if (status & MCI_DATATIMEOUT) { data->error = -ETIMEDOUT; - } else if (status & MCI_STARTBITERR) { - data->error = -ECOMM; } else if (status & MCI_TXUNDERRUN) { data->error = -EIO; } else if (status & MCI_RXOVERRUN) { diff --git a/trunk/drivers/mmc/host/mmci.h b/trunk/drivers/mmc/host/mmci.h index 2164e8c6476c..bb32e21c09db 100644 --- a/trunk/drivers/mmc/host/mmci.h +++ b/trunk/drivers/mmc/host/mmci.h @@ -86,7 +86,6 @@ #define MCI_CMDRESPEND (1 << 6) #define MCI_CMDSENT (1 << 7) #define MCI_DATAEND (1 << 8) -#define MCI_STARTBITERR (1 << 9) #define MCI_DATABLOCKEND (1 << 10) #define MCI_CMDACTIVE (1 << 11) #define MCI_TXACTIVE (1 << 12) @@ -113,7 +112,6 @@ #define MCI_CMDRESPENDCLR (1 << 6) #define MCI_CMDSENTCLR (1 << 7) #define MCI_DATAENDCLR (1 << 8) -#define MCI_STARTBITERRCLR (1 << 9) #define MCI_DATABLOCKENDCLR (1 << 10) /* Extended status bits for the ST Micro variants */ #define MCI_ST_SDIOITC (1 << 22) @@ -129,7 +127,6 @@ #define MCI_CMDRESPENDMASK (1 << 6) #define MCI_CMDSENTMASK (1 << 7) #define MCI_DATAENDMASK (1 << 8) -#define MCI_STARTBITERRMASK (1 << 9) #define MCI_DATABLOCKENDMASK (1 << 10) #define MCI_CMDACTIVEMASK (1 << 11) #define MCI_TXACTIVEMASK (1 << 12) @@ -153,7 +150,7 @@ #define MCI_IRQENABLE \ (MCI_CMDCRCFAILMASK|MCI_DATACRCFAILMASK|MCI_CMDTIMEOUTMASK| \ MCI_DATATIMEOUTMASK|MCI_TXUNDERRUNMASK|MCI_RXOVERRUNMASK| \ - MCI_CMDRESPENDMASK|MCI_CMDSENTMASK|MCI_STARTBITERRMASK) + MCI_CMDRESPENDMASK|MCI_CMDSENTMASK) /* These interrupts are directed to IRQ1 when two IRQ lines are available */ #define MCI_IRQ1MASK \ diff --git a/trunk/drivers/mmc/host/of_mmc_spi.c b/trunk/drivers/mmc/host/of_mmc_spi.c index ab66f2454dc4..e2aecb7f1d5c 100644 --- a/trunk/drivers/mmc/host/of_mmc_spi.c +++ b/trunk/drivers/mmc/host/of_mmc_spi.c @@ -25,11 +25,6 @@ #include #include -/* For archs that don't support NO_IRQ (such as mips), provide a dummy value */ -#ifndef NO_IRQ -#define NO_IRQ 0 -#endif - MODULE_LICENSE("GPL"); enum { diff --git a/trunk/drivers/mmc/host/omap_hsmmc.c b/trunk/drivers/mmc/host/omap_hsmmc.c index dedf3dab8a3b..5b2e2155b413 100644 --- a/trunk/drivers/mmc/host/omap_hsmmc.c +++ b/trunk/drivers/mmc/host/omap_hsmmc.c @@ -429,6 +429,7 @@ static int omap_hsmmc_reg_get(struct omap_hsmmc_host *host) return -EINVAL; } } + mmc_slot(host).ocr_mask = mmc_regulator_get_ocrmask(reg); /* Allow an aux regulator */ reg = regulator_get(host->dev, "vmmc_aux"); @@ -961,8 +962,7 @@ static void omap_hsmmc_dma_cleanup(struct omap_hsmmc_host *host, int errno) spin_unlock(&host->irq_lock); if (host->use_dma && dma_ch != -1) { - dma_unmap_sg(mmc_dev(host->mmc), host->data->sg, - host->data->sg_len, + dma_unmap_sg(mmc_dev(host->mmc), host->data->sg, host->dma_len, omap_hsmmc_get_dma_dir(host, host->data)); omap_free_dma(dma_ch); } @@ -1346,7 +1346,7 @@ static void omap_hsmmc_dma_cb(int lch, u16 ch_status, void *cb_data) return; } - dma_unmap_sg(mmc_dev(host->mmc), data->sg, data->sg_len, + dma_unmap_sg(mmc_dev(host->mmc), data->sg, host->dma_len, omap_hsmmc_get_dma_dir(host, data)); req_in_progress = host->req_in_progress; diff --git a/trunk/drivers/mmc/host/sh_mobile_sdhi.c b/trunk/drivers/mmc/host/sh_mobile_sdhi.c index ce500f03df85..b3654293017b 100644 --- a/trunk/drivers/mmc/host/sh_mobile_sdhi.c +++ b/trunk/drivers/mmc/host/sh_mobile_sdhi.c @@ -92,7 +92,7 @@ static int __devinit sh_mobile_sdhi_probe(struct platform_device *pdev) mmc_data->ocr_mask = p->tmio_ocr_mask; mmc_data->capabilities |= p->tmio_caps; - if (p->dma_slave_tx > 0 && p->dma_slave_rx > 0) { + if (p->dma_slave_tx >= 0 && p->dma_slave_rx >= 0) { priv->param_tx.slave_id = p->dma_slave_tx; priv->param_rx.slave_id = p->dma_slave_rx; priv->dma_priv.chan_priv_tx = &priv->param_tx; @@ -165,14 +165,13 @@ static int sh_mobile_sdhi_remove(struct platform_device *pdev) p->pdata = NULL; - tmio_mmc_host_remove(host); - for (i = 0; i < 3; i++) { irq = platform_get_irq(pdev, i); if (irq >= 0) free_irq(irq, host); } + tmio_mmc_host_remove(host); clk_disable(priv->clk); clk_put(priv->clk); kfree(priv); diff --git a/trunk/drivers/mmc/host/tmio_mmc_pio.c b/trunk/drivers/mmc/host/tmio_mmc_pio.c index 0b09e8239aa0..ad6347bb02dd 100644 --- a/trunk/drivers/mmc/host/tmio_mmc_pio.c +++ b/trunk/drivers/mmc/host/tmio_mmc_pio.c @@ -824,8 +824,8 @@ static int tmio_mmc_get_ro(struct mmc_host *mmc) struct tmio_mmc_host *host = mmc_priv(mmc); struct tmio_mmc_data *pdata = host->pdata; - return !((pdata->flags & TMIO_MMC_WRPROTECT_DISABLE) || - (sd_ctrl_read32(host, CTL_STATUS) & TMIO_STAT_WRPROTECT)); + return ((pdata->flags & TMIO_MMC_WRPROTECT_DISABLE) || + !(sd_ctrl_read32(host, CTL_STATUS) & TMIO_STAT_WRPROTECT)); } static int tmio_mmc_get_cd(struct mmc_host *mmc) diff --git a/trunk/drivers/mmc/host/vub300.c b/trunk/drivers/mmc/host/vub300.c index d4455ffbefd8..cbb03305b77b 100644 --- a/trunk/drivers/mmc/host/vub300.c +++ b/trunk/drivers/mmc/host/vub300.c @@ -2096,7 +2096,7 @@ static struct mmc_host_ops vub300_mmc_ops = { static int vub300_probe(struct usb_interface *interface, const struct usb_device_id *id) { /* NOT irq */ - struct vub300_mmc_host *vub300; + struct vub300_mmc_host *vub300 = NULL; struct usb_host_interface *iface_desc; struct usb_device *udev = usb_get_dev(interface_to_usbdev(interface)); int i; @@ -2118,20 +2118,23 @@ static int vub300_probe(struct usb_interface *interface, command_out_urb = usb_alloc_urb(0, GFP_KERNEL); if (!command_out_urb) { retval = -ENOMEM; - dev_err(&udev->dev, "not enough memory for command_out_urb\n"); + dev_err(&vub300->udev->dev, + "not enough memory for the command_out_urb\n"); goto error0; } command_res_urb = usb_alloc_urb(0, GFP_KERNEL); if (!command_res_urb) { retval = -ENOMEM; - dev_err(&udev->dev, "not enough memory for command_res_urb\n"); + dev_err(&vub300->udev->dev, + "not enough memory for the command_res_urb\n"); goto error1; } /* this also allocates memory for our VUB300 mmc host device */ mmc = mmc_alloc_host(sizeof(struct vub300_mmc_host), &udev->dev); if (!mmc) { retval = -ENOMEM; - dev_err(&udev->dev, "not enough memory for the mmc_host\n"); + dev_err(&vub300->udev->dev, + "not enough memory for the mmc_host\n"); goto error4; } /* MMC core transfer sizes tunable parameters */ diff --git a/trunk/drivers/mtd/nand/fsl_elbc_nand.c b/trunk/drivers/mtd/nand/fsl_elbc_nand.c index 33d8aad8bba5..0bb254c7d2b1 100644 --- a/trunk/drivers/mtd/nand/fsl_elbc_nand.c +++ b/trunk/drivers/mtd/nand/fsl_elbc_nand.c @@ -339,9 +339,9 @@ static void fsl_elbc_cmdfunc(struct mtd_info *mtd, unsigned int command, (FIR_OP_UA << FIR_OP1_SHIFT) | (FIR_OP_RBW << FIR_OP2_SHIFT)); out_be32(&lbc->fcr, NAND_CMD_READID << FCR_CMD0_SHIFT); - /* nand_get_flash_type() reads 8 bytes of entire ID string */ - out_be32(&lbc->fbcr, 8); - elbc_fcm_ctrl->read_bytes = 8; + /* 5 bytes for manuf, device and exts */ + out_be32(&lbc->fbcr, 5); + elbc_fcm_ctrl->read_bytes = 5; elbc_fcm_ctrl->use_mdr = 1; elbc_fcm_ctrl->mdr = 0; diff --git a/trunk/drivers/net/7990.c b/trunk/drivers/net/7990.c index 60b35fb5f524..903bcb3ef5bd 100644 --- a/trunk/drivers/net/7990.c +++ b/trunk/drivers/net/7990.c @@ -594,6 +594,7 @@ static void lance_load_multicast (struct net_device *dev) volatile struct lance_init_block *ib = lp->init_block; volatile u16 *mcast_table = (u16 *)&ib->filter; struct netdev_hw_addr *ha; + char *addrs; u32 crc; /* set all multicast bits */ @@ -608,7 +609,13 @@ static void lance_load_multicast (struct net_device *dev) /* Add addresses */ netdev_for_each_mc_addr(ha, dev) { - crc = ether_crc_le(6, ha->addr); + addrs = ha->addr; + + /* multicast address? */ + if (!(*addrs & 1)) + continue; + + crc = ether_crc_le(6, addrs); crc = crc >> 26; mcast_table [crc >> 4] |= 1 << (crc & 0xf); } diff --git a/trunk/drivers/net/8139too.c b/trunk/drivers/net/8139too.c index c2672c692d6f..ed6355cc5261 100644 --- a/trunk/drivers/net/8139too.c +++ b/trunk/drivers/net/8139too.c @@ -993,7 +993,6 @@ static int __devinit rtl8139_init_one (struct pci_dev *pdev, * features */ dev->features |= NETIF_F_SG | NETIF_F_HW_CSUM | NETIF_F_HIGHDMA; - dev->vlan_features = dev->features; dev->irq = pdev->irq; diff --git a/trunk/drivers/net/Kconfig b/trunk/drivers/net/Kconfig index 17ed4dda7c04..f5919c28a4b8 100644 --- a/trunk/drivers/net/Kconfig +++ b/trunk/drivers/net/Kconfig @@ -2272,7 +2272,7 @@ config SIS190 will be called sis190. This is recommended. config SKGE - tristate "Marvell Yukon Gigabit Ethernet support" + tristate "New SysKonnect GigaEthernet support" depends on PCI select CRC32 ---help--- @@ -2288,7 +2288,7 @@ config SKGE Linksys EG1032/EG1064, 3Com 3C940/3C940B, SysKonnect SK-9871/9872. It does not support the newer Yukon2 chipset: a separate driver, - sky2, is provided for these adapters. + sky2, is provided for Yukon2-based adapters. To compile this driver as a module, choose M here: the module will be called skge. This is recommended. @@ -2303,17 +2303,8 @@ config SKGE_DEBUG If unsure, say N. -config SKGE_GENESIS - bool "Support for older SysKonnect Genesis boards" - depends on SKGE - help - This enables support for the older and uncommon SysKonnect Genesis - chips, which support MII via an external transceiver, instead of - an internal one. Disabling this option will save some memory - by making code smaller. If unsure say Y. - config SKY2 - tristate "Marvell Yukon 2 support" + tristate "SysKonnect Yukon2 support" depends on PCI select CRC32 ---help--- @@ -2323,7 +2314,7 @@ config SKY2 88E8053/88E8055/88E8061/88E8062, SysKonnect SK-9E21D/SK-9S21 There is companion driver for the older Marvell Yukon and - SysKonnect Genesis based adapters: skge. + Genesis based adapters: skge. To compile this driver as a module, choose M here: the module will be called sky2. This is recommended. @@ -3424,8 +3415,7 @@ config NETCONSOLE config NETCONSOLE_DYNAMIC bool "Dynamic reconfiguration of logging targets" - depends on NETCONSOLE && SYSFS && CONFIGFS_FS && \ - !(NETCONSOLE=y && CONFIGFS_FS=m) + depends on NETCONSOLE && SYSFS && CONFIGFS_FS help This option enables the ability to dynamically reconfigure target parameters (interface, IP addresses, port numbers, MAC addresses) diff --git a/trunk/drivers/net/a2065.c b/trunk/drivers/net/a2065.c index e1e1b07d9b8d..25ea98aacf38 100644 --- a/trunk/drivers/net/a2065.c +++ b/trunk/drivers/net/a2065.c @@ -37,11 +37,6 @@ * both 10BASE-2 (thin coax) and AUI (DB-15) connectors */ -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - -/*#define DEBUG*/ -/*#define TEST_HITS*/ - #include #include #include @@ -63,22 +58,29 @@ #include "a2065.h" -/* Transmit/Receive Ring Definitions */ + + /* + * Transmit/Receive Ring Definitions + */ #define LANCE_LOG_TX_BUFFERS (2) #define LANCE_LOG_RX_BUFFERS (4) -#define TX_RING_SIZE (1 << LANCE_LOG_TX_BUFFERS) -#define RX_RING_SIZE (1 << LANCE_LOG_RX_BUFFERS) +#define TX_RING_SIZE (1<tx_old<=lp->tx_new)?\ + lp->tx_old+lp->tx_ring_mod_mask-lp->tx_new:\ + lp->tx_old - lp->tx_new-1) + + #define LANCE_ADDR(x) ((int)(x) & ~0xff000000) /* Load the CSR registers */ -static void load_csrs(struct lance_private *lp) +static void load_csrs (struct lance_private *lp) { volatile struct lance_regs *ll = lp->ll; volatile struct lance_init_block *aib = lp->lance_init_block; - int leptr = LANCE_ADDR(aib); + int leptr; + + leptr = LANCE_ADDR (aib); ll->rap = LE_CSR1; ll->rdp = (leptr & 0xFFFF); @@ -144,16 +156,19 @@ static void load_csrs(struct lance_private *lp) ll->rap = LE_CSR0; } +#define ZERO 0 + /* Setup the Lance Rx and Tx rings */ -static void lance_init_ring(struct net_device *dev) +static void lance_init_ring (struct net_device *dev) { struct lance_private *lp = netdev_priv(dev); volatile struct lance_init_block *ib = lp->init_block; - volatile struct lance_init_block *aib = lp->lance_init_block; - /* for LANCE_ADDR computations */ + volatile struct lance_init_block *aib; /* for LANCE_ADDR computations */ int leptr; int i; + aib = lp->lance_init_block; + /* Lock out other processes while setting up hardware */ netif_stop_queue(dev); lp->rx_new = lp->tx_new = 0; @@ -164,38 +179,41 @@ static void lance_init_ring(struct net_device *dev) /* Copy the ethernet address to the lance init block * Note that on the sparc you need to swap the ethernet address. */ - ib->phys_addr[0] = dev->dev_addr[1]; - ib->phys_addr[1] = dev->dev_addr[0]; - ib->phys_addr[2] = dev->dev_addr[3]; - ib->phys_addr[3] = dev->dev_addr[2]; - ib->phys_addr[4] = dev->dev_addr[5]; - ib->phys_addr[5] = dev->dev_addr[4]; + ib->phys_addr [0] = dev->dev_addr [1]; + ib->phys_addr [1] = dev->dev_addr [0]; + ib->phys_addr [2] = dev->dev_addr [3]; + ib->phys_addr [3] = dev->dev_addr [2]; + ib->phys_addr [4] = dev->dev_addr [5]; + ib->phys_addr [5] = dev->dev_addr [4]; + + if (ZERO) + printk(KERN_DEBUG "TX rings:\n"); /* Setup the Tx ring entries */ - netdev_dbg(dev, "TX rings:\n"); - for (i = 0; i <= 1 << lp->lance_log_tx_bufs; i++) { + for (i = 0; i <= (1<lance_log_tx_bufs); i++) { leptr = LANCE_ADDR(&aib->tx_buf[i][0]); - ib->btx_ring[i].tmd0 = leptr; - ib->btx_ring[i].tmd1_hadr = leptr >> 16; - ib->btx_ring[i].tmd1_bits = 0; - ib->btx_ring[i].length = 0xf000; /* The ones required by tmd2 */ - ib->btx_ring[i].misc = 0; - if (i < 3) - netdev_dbg(dev, "%d: 0x%08x\n", i, leptr); + ib->btx_ring [i].tmd0 = leptr; + ib->btx_ring [i].tmd1_hadr = leptr >> 16; + ib->btx_ring [i].tmd1_bits = 0; + ib->btx_ring [i].length = 0xf000; /* The ones required by tmd2 */ + ib->btx_ring [i].misc = 0; + if (i < 3 && ZERO) + printk(KERN_DEBUG "%d: 0x%8.8x\n", i, leptr); } /* Setup the Rx ring entries */ - netdev_dbg(dev, "RX rings:\n"); - for (i = 0; i < 1 << lp->lance_log_rx_bufs; i++) { + if (ZERO) + printk(KERN_DEBUG "RX rings:\n"); + for (i = 0; i < (1<lance_log_rx_bufs); i++) { leptr = LANCE_ADDR(&aib->rx_buf[i][0]); - ib->brx_ring[i].rmd0 = leptr; - ib->brx_ring[i].rmd1_hadr = leptr >> 16; - ib->brx_ring[i].rmd1_bits = LE_R1_OWN; - ib->brx_ring[i].length = -RX_BUFF_SIZE | 0xf000; - ib->brx_ring[i].mblength = 0; - if (i < 3) - netdev_dbg(dev, "%d: 0x%08x\n", i, leptr); + ib->brx_ring [i].rmd0 = leptr; + ib->brx_ring [i].rmd1_hadr = leptr >> 16; + ib->brx_ring [i].rmd1_bits = LE_R1_OWN; + ib->brx_ring [i].length = -RX_BUFF_SIZE | 0xf000; + ib->brx_ring [i].mblength = 0; + if (i < 3 && ZERO) + printk(KERN_DEBUG "%d: 0x%8.8x\n", i, leptr); } /* Setup the initialization block */ @@ -204,20 +222,22 @@ static void lance_init_ring(struct net_device *dev) leptr = LANCE_ADDR(&aib->brx_ring); ib->rx_len = (lp->lance_log_rx_bufs << 13) | (leptr >> 16); ib->rx_ptr = leptr; - netdev_dbg(dev, "RX ptr: %08x\n", leptr); + if (ZERO) + printk(KERN_DEBUG "RX ptr: %8.8x\n", leptr); /* Setup tx descriptor pointer */ leptr = LANCE_ADDR(&aib->btx_ring); ib->tx_len = (lp->lance_log_tx_bufs << 13) | (leptr >> 16); ib->tx_ptr = leptr; - netdev_dbg(dev, "TX ptr: %08x\n", leptr); + if (ZERO) + printk(KERN_DEBUG "TX ptr: %8.8x\n", leptr); /* Clear the multicast filter */ - ib->filter[0] = 0; - ib->filter[1] = 0; + ib->filter [0] = 0; + ib->filter [1] = 0; } -static int init_restart_lance(struct lance_private *lp) +static int init_restart_lance (struct lance_private *lp) { volatile struct lance_regs *ll = lp->ll; int i; @@ -229,7 +249,8 @@ static int init_restart_lance(struct lance_private *lp) for (i = 0; (i < 100) && !(ll->rdp & (LE_C0_ERR | LE_C0_IDON)); i++) barrier(); if ((i == 100) || (ll->rdp & LE_C0_ERR)) { - pr_err("unopened after %d ticks, csr0=%04x\n", i, ll->rdp); + printk(KERN_ERR "LANCE unopened after %d ticks, csr0=%4.4x.\n", + i, ll->rdp); return -EIO; } @@ -240,7 +261,7 @@ static int init_restart_lance(struct lance_private *lp) return 0; } -static int lance_rx(struct net_device *dev) +static int lance_rx (struct net_device *dev) { struct lance_private *lp = netdev_priv(dev); volatile struct lance_init_block *ib = lp->init_block; @@ -250,24 +271,22 @@ static int lance_rx(struct net_device *dev) #ifdef TEST_HITS int i; - char buf[RX_RING_SIZE + 1]; - + printk(KERN_DEBUG "["); for (i = 0; i < RX_RING_SIZE; i++) { - char r1_own = ib->brx_ring[i].rmd1_bits & LE_R1_OWN; if (i == lp->rx_new) - buf[i] = r1_own ? '_' : 'X'; + printk ("%s", + ib->brx_ring [i].rmd1_bits & LE_R1_OWN ? "_" : "X"); else - buf[i] = r1_own ? '.' : '1'; + printk ("%s", + ib->brx_ring [i].rmd1_bits & LE_R1_OWN ? "." : "1"); } - buf[RX_RING_SIZE] = 0; - - pr_debug("RxRing TestHits: [%s]\n", buf); + printk ("]\n"); #endif - ll->rdp = LE_C0_RINT | LE_C0_INEA; - for (rd = &ib->brx_ring[lp->rx_new]; + ll->rdp = LE_C0_RINT|LE_C0_INEA; + for (rd = &ib->brx_ring [lp->rx_new]; !((bits = rd->rmd1_bits) & LE_R1_OWN); - rd = &ib->brx_ring[lp->rx_new]) { + rd = &ib->brx_ring [lp->rx_new]) { /* We got an incomplete frame? */ if ((bits & LE_R1_POK) != LE_R1_POK) { @@ -278,22 +297,18 @@ static int lance_rx(struct net_device *dev) /* Count only the end frame as a rx error, * not the beginning */ - if (bits & LE_R1_BUF) - dev->stats.rx_fifo_errors++; - if (bits & LE_R1_CRC) - dev->stats.rx_crc_errors++; - if (bits & LE_R1_OFL) - dev->stats.rx_over_errors++; - if (bits & LE_R1_FRA) - dev->stats.rx_frame_errors++; - if (bits & LE_R1_EOP) - dev->stats.rx_errors++; + if (bits & LE_R1_BUF) dev->stats.rx_fifo_errors++; + if (bits & LE_R1_CRC) dev->stats.rx_crc_errors++; + if (bits & LE_R1_OFL) dev->stats.rx_over_errors++; + if (bits & LE_R1_FRA) dev->stats.rx_frame_errors++; + if (bits & LE_R1_EOP) dev->stats.rx_errors++; } else { int len = (rd->mblength & 0xfff) - 4; - struct sk_buff *skb = dev_alloc_skb(len + 2); + struct sk_buff *skb = dev_alloc_skb (len+2); if (!skb) { - netdev_warn(dev, "Memory squeeze, deferring packet\n"); + printk(KERN_WARNING "%s: Memory squeeze, " + "deferring packet.\n", dev->name); dev->stats.rx_dropped++; rd->mblength = 0; rd->rmd1_bits = LE_R1_OWN; @@ -301,13 +316,13 @@ static int lance_rx(struct net_device *dev) return 0; } - skb_reserve(skb, 2); /* 16 byte align */ - skb_put(skb, len); /* make room */ + skb_reserve (skb, 2); /* 16 byte align */ + skb_put (skb, len); /* make room */ skb_copy_to_linear_data(skb, - (unsigned char *)&ib->rx_buf[lp->rx_new][0], - len); - skb->protocol = eth_type_trans(skb, dev); - netif_rx(skb); + (unsigned char *)&(ib->rx_buf [lp->rx_new][0]), + len); + skb->protocol = eth_type_trans (skb, dev); + netif_rx (skb); dev->stats.rx_packets++; dev->stats.rx_bytes += len; } @@ -320,7 +335,7 @@ static int lance_rx(struct net_device *dev) return 0; } -static int lance_tx(struct net_device *dev) +static int lance_tx (struct net_device *dev) { struct lance_private *lp = netdev_priv(dev); volatile struct lance_init_block *ib = lp->init_block; @@ -335,7 +350,7 @@ static int lance_tx(struct net_device *dev) j = lp->tx_old; for (i = j; i != lp->tx_new; i = j) { - td = &ib->btx_ring[i]; + td = &ib->btx_ring [i]; /* If we hit a packet not owned by us, stop */ if (td->tmd1_bits & LE_T1_OWN) @@ -345,44 +360,45 @@ static int lance_tx(struct net_device *dev) status = td->misc; dev->stats.tx_errors++; - if (status & LE_T3_RTY) - dev->stats.tx_aborted_errors++; - if (status & LE_T3_LCOL) - dev->stats.tx_window_errors++; + if (status & LE_T3_RTY) dev->stats.tx_aborted_errors++; + if (status & LE_T3_LCOL) dev->stats.tx_window_errors++; if (status & LE_T3_CLOS) { dev->stats.tx_carrier_errors++; if (lp->auto_select) { lp->tpe = 1 - lp->tpe; - netdev_err(dev, "Carrier Lost, trying %s\n", - lp->tpe ? "TPE" : "AUI"); + printk(KERN_ERR "%s: Carrier Lost, " + "trying %s\n", dev->name, + lp->tpe?"TPE":"AUI"); /* Stop the lance */ ll->rap = LE_CSR0; ll->rdp = LE_C0_STOP; - lance_init_ring(dev); - load_csrs(lp); - init_restart_lance(lp); + lance_init_ring (dev); + load_csrs (lp); + init_restart_lance (lp); return 0; } } - /* buffer errors and underflows turn off - * the transmitter, so restart the adapter - */ - if (status & (LE_T3_BUF | LE_T3_UFL)) { + /* buffer errors and underflows turn off the transmitter */ + /* Restart the adapter */ + if (status & (LE_T3_BUF|LE_T3_UFL)) { dev->stats.tx_fifo_errors++; - netdev_err(dev, "Tx: ERR_BUF|ERR_UFL, restarting\n"); + printk(KERN_ERR "%s: Tx: ERR_BUF|ERR_UFL, " + "restarting\n", dev->name); /* Stop the lance */ ll->rap = LE_CSR0; ll->rdp = LE_C0_STOP; - lance_init_ring(dev); - load_csrs(lp); - init_restart_lance(lp); + lance_init_ring (dev); + load_csrs (lp); + init_restart_lance (lp); return 0; } } else if ((td->tmd1_bits & LE_T1_POK) == LE_T1_POK) { - /* So we don't count the packet more than once. */ + /* + * So we don't count the packet more than once. + */ td->tmd1_bits &= ~(LE_T1_POK); /* One collision before packet was sent. */ @@ -403,14 +419,7 @@ static int lance_tx(struct net_device *dev) return 0; } -static int lance_tx_buffs_avail(struct lance_private *lp) -{ - if (lp->tx_old <= lp->tx_new) - return lp->tx_old + lp->tx_ring_mod_mask - lp->tx_new; - return lp->tx_old - lp->tx_new - 1; -} - -static irqreturn_t lance_interrupt(int irq, void *dev_id) +static irqreturn_t lance_interrupt (int irq, void *dev_id) { struct net_device *dev = dev_id; struct lance_private *lp = netdev_priv(dev); @@ -424,19 +433,19 @@ static irqreturn_t lance_interrupt(int irq, void *dev_id) return IRQ_NONE; /* been generated by the Lance. */ /* Acknowledge all the interrupt sources ASAP */ - ll->rdp = csr0 & ~(LE_C0_INEA | LE_C0_TDMD | LE_C0_STOP | LE_C0_STRT | + ll->rdp = csr0 & ~(LE_C0_INEA|LE_C0_TDMD|LE_C0_STOP|LE_C0_STRT| LE_C0_INIT); - if (csr0 & LE_C0_ERR) { + if ((csr0 & LE_C0_ERR)) { /* Clear the error condition */ - ll->rdp = LE_C0_BABL | LE_C0_ERR | LE_C0_MISS | LE_C0_INEA; + ll->rdp = LE_C0_BABL|LE_C0_ERR|LE_C0_MISS|LE_C0_INEA; } if (csr0 & LE_C0_RINT) - lance_rx(dev); + lance_rx (dev); if (csr0 & LE_C0_TINT) - lance_tx(dev); + lance_tx (dev); /* Log misc errors. */ if (csr0 & LE_C0_BABL) @@ -444,22 +453,22 @@ static irqreturn_t lance_interrupt(int irq, void *dev_id) if (csr0 & LE_C0_MISS) dev->stats.rx_errors++; /* Missed a Rx frame. */ if (csr0 & LE_C0_MERR) { - netdev_err(dev, "Bus master arbitration failure, status %04x\n", - csr0); + printk(KERN_ERR "%s: Bus master arbitration failure, status " + "%4.4x.\n", dev->name, csr0); /* Restart the chip. */ ll->rdp = LE_C0_STRT; } - if (netif_queue_stopped(dev) && lance_tx_buffs_avail(lp) > 0) + if (netif_queue_stopped(dev) && TX_BUFFS_AVAIL > 0) netif_wake_queue(dev); ll->rap = LE_CSR0; - ll->rdp = (LE_C0_BABL | LE_C0_CERR | LE_C0_MISS | LE_C0_MERR | - LE_C0_IDON | LE_C0_INEA); + ll->rdp = LE_C0_BABL|LE_C0_CERR|LE_C0_MISS|LE_C0_MERR| + LE_C0_IDON|LE_C0_INEA; return IRQ_HANDLED; } -static int lance_open(struct net_device *dev) +static int lance_open (struct net_device *dev) { struct lance_private *lp = netdev_priv(dev); volatile struct lance_regs *ll = lp->ll; @@ -472,18 +481,17 @@ static int lance_open(struct net_device *dev) /* Install the Interrupt handler */ ret = request_irq(IRQ_AMIGA_PORTS, lance_interrupt, IRQF_SHARED, dev->name, dev); - if (ret) - return ret; + if (ret) return ret; - load_csrs(lp); - lance_init_ring(dev); + load_csrs (lp); + lance_init_ring (dev); netif_start_queue(dev); - return init_restart_lance(lp); + return init_restart_lance (lp); } -static int lance_close(struct net_device *dev) +static int lance_close (struct net_device *dev) { struct lance_private *lp = netdev_priv(dev); volatile struct lance_regs *ll = lp->ll; @@ -499,7 +507,7 @@ static int lance_close(struct net_device *dev) return 0; } -static inline int lance_reset(struct net_device *dev) +static inline int lance_reset (struct net_device *dev) { struct lance_private *lp = netdev_priv(dev); volatile struct lance_regs *ll = lp->ll; @@ -509,15 +517,16 @@ static inline int lance_reset(struct net_device *dev) ll->rap = LE_CSR0; ll->rdp = LE_C0_STOP; - load_csrs(lp); + load_csrs (lp); - lance_init_ring(dev); + lance_init_ring (dev); dev->trans_start = jiffies; /* prevent tx timeout */ netif_start_queue(dev); - status = init_restart_lance(lp); - netdev_dbg(dev, "Lance restart=%d\n", status); - + status = init_restart_lance (lp); +#ifdef DEBUG_DRIVER + printk(KERN_DEBUG "Lance restart=%d\n", status); +#endif return status; } @@ -526,13 +535,14 @@ static void lance_tx_timeout(struct net_device *dev) struct lance_private *lp = netdev_priv(dev); volatile struct lance_regs *ll = lp->ll; - netdev_err(dev, "transmit timed out, status %04x, reset\n", ll->rdp); + printk(KERN_ERR "%s: transmit timed out, status %04x, reset\n", + dev->name, ll->rdp); lance_reset(dev); netif_wake_queue(dev); } -static netdev_tx_t lance_start_xmit(struct sk_buff *skb, - struct net_device *dev) +static netdev_tx_t lance_start_xmit (struct sk_buff *skb, + struct net_device *dev) { struct lance_private *lp = netdev_priv(dev); volatile struct lance_regs *ll = lp->ll; @@ -547,33 +557,33 @@ static netdev_tx_t lance_start_xmit(struct sk_buff *skb, local_irq_save(flags); - if (!lance_tx_buffs_avail(lp)) { + if (!TX_BUFFS_AVAIL){ local_irq_restore(flags); return NETDEV_TX_LOCKED; } -#ifdef DEBUG +#ifdef DEBUG_DRIVER /* dump the packet */ print_hex_dump(KERN_DEBUG, "skb->data: ", DUMP_PREFIX_NONE, 16, 1, skb->data, 64, true); #endif entry = lp->tx_new & lp->tx_ring_mod_mask; - ib->btx_ring[entry].length = (-skblen) | 0xf000; - ib->btx_ring[entry].misc = 0; + ib->btx_ring [entry].length = (-skblen) | 0xf000; + ib->btx_ring [entry].misc = 0; - skb_copy_from_linear_data(skb, (void *)&ib->tx_buf[entry][0], skblen); + skb_copy_from_linear_data(skb, (void *)&ib->tx_buf [entry][0], skblen); /* Now, give the packet to the lance */ - ib->btx_ring[entry].tmd1_bits = (LE_T1_POK | LE_T1_OWN); + ib->btx_ring [entry].tmd1_bits = (LE_T1_POK|LE_T1_OWN); lp->tx_new = (lp->tx_new+1) & lp->tx_ring_mod_mask; dev->stats.tx_bytes += skblen; - if (lance_tx_buffs_avail(lp) <= 0) + if (TX_BUFFS_AVAIL <= 0) netif_stop_queue(dev); /* Kick the lance: transmit now */ ll->rdp = LE_C0_INEA | LE_C0_TDMD; - dev_kfree_skb(skb); + dev_kfree_skb (skb); local_irq_restore(flags); @@ -581,33 +591,40 @@ static netdev_tx_t lance_start_xmit(struct sk_buff *skb, } /* taken from the depca driver */ -static void lance_load_multicast(struct net_device *dev) +static void lance_load_multicast (struct net_device *dev) { struct lance_private *lp = netdev_priv(dev); volatile struct lance_init_block *ib = lp->init_block; volatile u16 *mcast_table = (u16 *)&ib->filter; struct netdev_hw_addr *ha; + char *addrs; u32 crc; /* set all multicast bits */ - if (dev->flags & IFF_ALLMULTI) { - ib->filter[0] = 0xffffffff; - ib->filter[1] = 0xffffffff; + if (dev->flags & IFF_ALLMULTI){ + ib->filter [0] = 0xffffffff; + ib->filter [1] = 0xffffffff; return; } /* clear the multicast filter */ - ib->filter[0] = 0; - ib->filter[1] = 0; + ib->filter [0] = 0; + ib->filter [1] = 0; /* Add addresses */ netdev_for_each_mc_addr(ha, dev) { - crc = ether_crc_le(6, ha->addr); + addrs = ha->addr; + + /* multicast address? */ + if (!(*addrs & 1)) + continue; + + crc = ether_crc_le(6, addrs); crc = crc >> 26; - mcast_table[crc >> 4] |= 1 << (crc & 0xf); + mcast_table [crc >> 4] |= 1 << (crc & 0xf); } } -static void lance_set_multicast(struct net_device *dev) +static void lance_set_multicast (struct net_device *dev) { struct lance_private *lp = netdev_priv(dev); volatile struct lance_init_block *ib = lp->init_block; @@ -626,16 +643,16 @@ static void lance_set_multicast(struct net_device *dev) ll->rap = LE_CSR0; ll->rdp = LE_C0_STOP; - lance_init_ring(dev); + lance_init_ring (dev); if (dev->flags & IFF_PROMISC) { ib->mode |= LE_MO_PROM; } else { ib->mode &= ~LE_MO_PROM; - lance_load_multicast(dev); + lance_load_multicast (dev); } - load_csrs(lp); - init_restart_lance(lp); + load_csrs (lp); + init_restart_lance (lp); netif_wake_queue(dev); } @@ -675,12 +692,14 @@ static int __devinit a2065_init_one(struct zorro_dev *z, { struct net_device *dev; struct lance_private *priv; - unsigned long board = z->resource.start; - unsigned long base_addr = board + A2065_LANCE; - unsigned long mem_start = board + A2065_RAM; + unsigned long board, base_addr, mem_start; struct resource *r1, *r2; int err; + board = z->resource.start; + base_addr = board+A2065_LANCE; + mem_start = board+A2065_RAM; + r1 = request_mem_region(base_addr, sizeof(struct lance_regs), "Am7990"); if (!r1) @@ -711,12 +730,12 @@ static int __devinit a2065_init_one(struct zorro_dev *z, dev->dev_addr[1] = 0x00; dev->dev_addr[2] = 0x9f; } - dev->dev_addr[3] = (z->rom.er_SerialNumber >> 16) & 0xff; - dev->dev_addr[4] = (z->rom.er_SerialNumber >> 8) & 0xff; + dev->dev_addr[3] = (z->rom.er_SerialNumber>>16) & 0xff; + dev->dev_addr[4] = (z->rom.er_SerialNumber>>8) & 0xff; dev->dev_addr[5] = z->rom.er_SerialNumber & 0xff; dev->base_addr = ZTWO_VADDR(base_addr); dev->mem_start = ZTWO_VADDR(mem_start); - dev->mem_end = dev->mem_start + A2065_RAM_SIZE; + dev->mem_end = dev->mem_start+A2065_RAM_SIZE; priv->ll = (volatile struct lance_regs *)dev->base_addr; priv->init_block = (struct lance_init_block *)dev->mem_start; @@ -736,7 +755,7 @@ static int __devinit a2065_init_one(struct zorro_dev *z, init_timer(&priv->multicast_timer); priv->multicast_timer.data = (unsigned long) dev; priv->multicast_timer.function = - (void (*)(unsigned long))lance_set_multicast; + (void (*)(unsigned long)) &lance_set_multicast; err = register_netdev(dev); if (err) { @@ -747,8 +766,8 @@ static int __devinit a2065_init_one(struct zorro_dev *z, } zorro_set_drvdata(z, dev); - netdev_info(dev, "A2065 at 0x%08lx, Ethernet Address %pM\n", - board, dev->dev_addr); + printk(KERN_INFO "%s: A2065 at 0x%08lx, Ethernet Address " + "%pM\n", dev->name, board, dev->dev_addr); return 0; } diff --git a/trunk/drivers/net/ariadne.c b/trunk/drivers/net/ariadne.c index 7ed78f402042..b7f45cd756a2 100644 --- a/trunk/drivers/net/ariadne.c +++ b/trunk/drivers/net/ariadne.c @@ -34,9 +34,6 @@ * - an MC68230 Parallel Interface/Timer configured as 2 parallel ports */ -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt -/*#define DEBUG*/ - #include #include #include @@ -57,734 +54,802 @@ #include "ariadne.h" + #ifdef ARIADNE_DEBUG int ariadne_debug = ARIADNE_DEBUG; #else int ariadne_debug = 1; #endif -/* Macros to Fix Endianness problems */ -/* Swap the Bytes in a WORD */ -#define swapw(x) (((x >> 8) & 0x00ff) | ((x << 8) & 0xff00)) -/* Get the Low BYTE in a WORD */ -#define lowb(x) (x & 0xff) -/* Get the Swapped High WORD in a LONG */ -#define swhighw(x) ((((x) >> 8) & 0xff00) | (((x) >> 24) & 0x00ff)) -/* Get the Swapped Low WORD in a LONG */ -#define swloww(x) ((((x) << 8) & 0xff00) | (((x) >> 8) & 0x00ff)) + /* + * Macros to Fix Endianness problems + */ + + /* Swap the Bytes in a WORD */ +#define swapw(x) (((x>>8)&0x00ff)|((x<<8)&0xff00)) + /* Get the Low BYTE in a WORD */ +#define lowb(x) (x&0xff) + /* Get the Swapped High WORD in a LONG */ +#define swhighw(x) ((((x)>>8)&0xff00)|(((x)>>24)&0x00ff)) + /* Get the Swapped Low WORD in a LONG */ +#define swloww(x) ((((x)<<8)&0xff00)|(((x)>>8)&0x00ff)) -/* Transmit/Receive Ring Definitions */ + + /* + * Transmit/Receive Ring Definitions + */ #define TX_RING_SIZE 5 #define RX_RING_SIZE 16 #define PKT_BUF_SIZE 1520 -/* Private Device Data */ + + /* + * Private Device Data + */ struct ariadne_private { - volatile struct TDRE *tx_ring[TX_RING_SIZE]; - volatile struct RDRE *rx_ring[RX_RING_SIZE]; - volatile u_short *tx_buff[TX_RING_SIZE]; - volatile u_short *rx_buff[RX_RING_SIZE]; - int cur_tx, cur_rx; /* The next free ring entry */ - int dirty_tx; /* The ring entries to be free()ed */ - char tx_full; + volatile struct TDRE *tx_ring[TX_RING_SIZE]; + volatile struct RDRE *rx_ring[RX_RING_SIZE]; + volatile u_short *tx_buff[TX_RING_SIZE]; + volatile u_short *rx_buff[RX_RING_SIZE]; + int cur_tx, cur_rx; /* The next free ring entry */ + int dirty_tx; /* The ring entries to be free()ed. */ + char tx_full; }; -/* Structure Created in the Ariadne's RAM Buffer */ + + /* + * Structure Created in the Ariadne's RAM Buffer + */ struct lancedata { - struct TDRE tx_ring[TX_RING_SIZE]; - struct RDRE rx_ring[RX_RING_SIZE]; - u_short tx_buff[TX_RING_SIZE][PKT_BUF_SIZE / sizeof(u_short)]; - u_short rx_buff[RX_RING_SIZE][PKT_BUF_SIZE / sizeof(u_short)]; + struct TDRE tx_ring[TX_RING_SIZE]; + struct RDRE rx_ring[RX_RING_SIZE]; + u_short tx_buff[TX_RING_SIZE][PKT_BUF_SIZE/sizeof(u_short)]; + u_short rx_buff[RX_RING_SIZE][PKT_BUF_SIZE/sizeof(u_short)]; }; +static int ariadne_open(struct net_device *dev); +static void ariadne_init_ring(struct net_device *dev); +static netdev_tx_t ariadne_start_xmit(struct sk_buff *skb, + struct net_device *dev); +static void ariadne_tx_timeout(struct net_device *dev); +static int ariadne_rx(struct net_device *dev); +static void ariadne_reset(struct net_device *dev); +static irqreturn_t ariadne_interrupt(int irq, void *data); +static int ariadne_close(struct net_device *dev); +static struct net_device_stats *ariadne_get_stats(struct net_device *dev); +static void set_multicast_list(struct net_device *dev); + + static void memcpyw(volatile u_short *dest, u_short *src, int len) { - while (len >= 2) { - *(dest++) = *(src++); - len -= 2; - } - if (len == 1) - *dest = (*(u_char *)src) << 8; + while (len >= 2) { + *(dest++) = *(src++); + len -= 2; + } + if (len == 1) + *dest = (*(u_char *)src)<<8; } -static void ariadne_init_ring(struct net_device *dev) -{ - struct ariadne_private *priv = netdev_priv(dev); - volatile struct lancedata *lancedata = (struct lancedata *)dev->mem_start; - int i; - netif_stop_queue(dev); +static int __devinit ariadne_init_one(struct zorro_dev *z, + const struct zorro_device_id *ent); +static void __devexit ariadne_remove_one(struct zorro_dev *z); - priv->tx_full = 0; - priv->cur_rx = priv->cur_tx = 0; - priv->dirty_tx = 0; - - /* Set up TX Ring */ - for (i = 0; i < TX_RING_SIZE; i++) { - volatile struct TDRE *t = &lancedata->tx_ring[i]; - t->TMD0 = swloww(ARIADNE_RAM + - offsetof(struct lancedata, tx_buff[i])); - t->TMD1 = swhighw(ARIADNE_RAM + - offsetof(struct lancedata, tx_buff[i])) | - TF_STP | TF_ENP; - t->TMD2 = swapw((u_short)-PKT_BUF_SIZE); - t->TMD3 = 0; - priv->tx_ring[i] = &lancedata->tx_ring[i]; - priv->tx_buff[i] = lancedata->tx_buff[i]; - netdev_dbg(dev, "TX Entry %2d at %p, Buf at %p\n", - i, &lancedata->tx_ring[i], lancedata->tx_buff[i]); - } - /* Set up RX Ring */ - for (i = 0; i < RX_RING_SIZE; i++) { - volatile struct RDRE *r = &lancedata->rx_ring[i]; - r->RMD0 = swloww(ARIADNE_RAM + - offsetof(struct lancedata, rx_buff[i])); - r->RMD1 = swhighw(ARIADNE_RAM + - offsetof(struct lancedata, rx_buff[i])) | - RF_OWN; - r->RMD2 = swapw((u_short)-PKT_BUF_SIZE); - r->RMD3 = 0x0000; - priv->rx_ring[i] = &lancedata->rx_ring[i]; - priv->rx_buff[i] = lancedata->rx_buff[i]; - netdev_dbg(dev, "RX Entry %2d at %p, Buf at %p\n", - i, &lancedata->rx_ring[i], lancedata->rx_buff[i]); - } -} - -static int ariadne_rx(struct net_device *dev) -{ - struct ariadne_private *priv = netdev_priv(dev); - int entry = priv->cur_rx % RX_RING_SIZE; - int i; +static struct zorro_device_id ariadne_zorro_tbl[] __devinitdata = { + { ZORRO_PROD_VILLAGE_TRONIC_ARIADNE }, + { 0 } +}; +MODULE_DEVICE_TABLE(zorro, ariadne_zorro_tbl); - /* If we own the next entry, it's a new packet. Send it up */ - while (!(lowb(priv->rx_ring[entry]->RMD1) & RF_OWN)) { - int status = lowb(priv->rx_ring[entry]->RMD1); - - if (status != (RF_STP | RF_ENP)) { /* There was an error */ - /* There is a tricky error noted by - * John Murphy to Russ Nelson: - * Even with full-sized buffers it's possible for a - * jabber packet to use two buffers, with only the - * last correctly noting the error - */ - /* Only count a general error at the end of a packet */ - if (status & RF_ENP) - dev->stats.rx_errors++; - if (status & RF_FRAM) - dev->stats.rx_frame_errors++; - if (status & RF_OFLO) - dev->stats.rx_over_errors++; - if (status & RF_CRC) - dev->stats.rx_crc_errors++; - if (status & RF_BUFF) - dev->stats.rx_fifo_errors++; - priv->rx_ring[entry]->RMD1 &= 0xff00 | RF_STP | RF_ENP; - } else { - /* Malloc up new buffer, compatible with net-3 */ - short pkt_len = swapw(priv->rx_ring[entry]->RMD3); - struct sk_buff *skb; - - skb = dev_alloc_skb(pkt_len + 2); - if (skb == NULL) { - netdev_warn(dev, "Memory squeeze, deferring packet\n"); - for (i = 0; i < RX_RING_SIZE; i++) - if (lowb(priv->rx_ring[(entry + i) % RX_RING_SIZE]->RMD1) & RF_OWN) - break; - - if (i > RX_RING_SIZE - 2) { - dev->stats.rx_dropped++; - priv->rx_ring[entry]->RMD1 |= RF_OWN; - priv->cur_rx++; - } - break; - } - - - skb_reserve(skb, 2); /* 16 byte align */ - skb_put(skb, pkt_len); /* Make room */ - skb_copy_to_linear_data(skb, - (const void *)priv->rx_buff[entry], - pkt_len); - skb->protocol = eth_type_trans(skb, dev); - netdev_dbg(dev, "RX pkt type 0x%04x from %pM to %pM data 0x%08x len %d\n", - ((u_short *)skb->data)[6], - skb->data + 6, skb->data, - (int)skb->data, (int)skb->len); - - netif_rx(skb); - dev->stats.rx_packets++; - dev->stats.rx_bytes += pkt_len; - } +static struct zorro_driver ariadne_driver = { + .name = "ariadne", + .id_table = ariadne_zorro_tbl, + .probe = ariadne_init_one, + .remove = __devexit_p(ariadne_remove_one), +}; - priv->rx_ring[entry]->RMD1 |= RF_OWN; - entry = (++priv->cur_rx) % RX_RING_SIZE; - } +static const struct net_device_ops ariadne_netdev_ops = { + .ndo_open = ariadne_open, + .ndo_stop = ariadne_close, + .ndo_start_xmit = ariadne_start_xmit, + .ndo_tx_timeout = ariadne_tx_timeout, + .ndo_get_stats = ariadne_get_stats, + .ndo_set_multicast_list = set_multicast_list, + .ndo_validate_addr = eth_validate_addr, + .ndo_change_mtu = eth_change_mtu, + .ndo_set_mac_address = eth_mac_addr, +}; - priv->cur_rx = priv->cur_rx % RX_RING_SIZE; +static int __devinit ariadne_init_one(struct zorro_dev *z, + const struct zorro_device_id *ent) +{ + unsigned long board = z->resource.start; + unsigned long base_addr = board+ARIADNE_LANCE; + unsigned long mem_start = board+ARIADNE_RAM; + struct resource *r1, *r2; + struct net_device *dev; + struct ariadne_private *priv; + int err; + + r1 = request_mem_region(base_addr, sizeof(struct Am79C960), "Am79C960"); + if (!r1) + return -EBUSY; + r2 = request_mem_region(mem_start, ARIADNE_RAM_SIZE, "RAM"); + if (!r2) { + release_mem_region(base_addr, sizeof(struct Am79C960)); + return -EBUSY; + } + + dev = alloc_etherdev(sizeof(struct ariadne_private)); + if (dev == NULL) { + release_mem_region(base_addr, sizeof(struct Am79C960)); + release_mem_region(mem_start, ARIADNE_RAM_SIZE); + return -ENOMEM; + } + + priv = netdev_priv(dev); + + r1->name = dev->name; + r2->name = dev->name; + + dev->dev_addr[0] = 0x00; + dev->dev_addr[1] = 0x60; + dev->dev_addr[2] = 0x30; + dev->dev_addr[3] = (z->rom.er_SerialNumber>>16) & 0xff; + dev->dev_addr[4] = (z->rom.er_SerialNumber>>8) & 0xff; + dev->dev_addr[5] = z->rom.er_SerialNumber & 0xff; + dev->base_addr = ZTWO_VADDR(base_addr); + dev->mem_start = ZTWO_VADDR(mem_start); + dev->mem_end = dev->mem_start+ARIADNE_RAM_SIZE; + + dev->netdev_ops = &ariadne_netdev_ops; + dev->watchdog_timeo = 5*HZ; + + err = register_netdev(dev); + if (err) { + release_mem_region(base_addr, sizeof(struct Am79C960)); + release_mem_region(mem_start, ARIADNE_RAM_SIZE); + free_netdev(dev); + return err; + } + zorro_set_drvdata(z, dev); - /* We should check that at least two ring entries are free. - * If not, we should free one and mark stats->rx_dropped++ - */ + printk(KERN_INFO "%s: Ariadne at 0x%08lx, Ethernet Address %pM\n", + dev->name, board, dev->dev_addr); - return 0; + return 0; } -static irqreturn_t ariadne_interrupt(int irq, void *data) + +static int ariadne_open(struct net_device *dev) { - struct net_device *dev = (struct net_device *)data; - volatile struct Am79C960 *lance = (struct Am79C960 *)dev->base_addr; - struct ariadne_private *priv; - int csr0, boguscnt; - int handled = 0; - - lance->RAP = CSR0; /* PCnet-ISA Controller Status */ - - if (!(lance->RDP & INTR)) /* Check if any interrupt has been */ - return IRQ_NONE; /* generated by the board */ - - priv = netdev_priv(dev); - - boguscnt = 10; - while ((csr0 = lance->RDP) & (ERR | RINT | TINT) && --boguscnt >= 0) { - /* Acknowledge all of the current interrupt sources ASAP */ - lance->RDP = csr0 & ~(INEA | TDMD | STOP | STRT | INIT); - -#ifdef DEBUG - if (ariadne_debug > 5) { - netdev_dbg(dev, "interrupt csr0=%#02x new csr=%#02x [", - csr0, lance->RDP); - if (csr0 & INTR) - pr_cont(" INTR"); - if (csr0 & INEA) - pr_cont(" INEA"); - if (csr0 & RXON) - pr_cont(" RXON"); - if (csr0 & TXON) - pr_cont(" TXON"); - if (csr0 & TDMD) - pr_cont(" TDMD"); - if (csr0 & STOP) - pr_cont(" STOP"); - if (csr0 & STRT) - pr_cont(" STRT"); - if (csr0 & INIT) - pr_cont(" INIT"); - if (csr0 & ERR) - pr_cont(" ERR"); - if (csr0 & BABL) - pr_cont(" BABL"); - if (csr0 & CERR) - pr_cont(" CERR"); - if (csr0 & MISS) - pr_cont(" MISS"); - if (csr0 & MERR) - pr_cont(" MERR"); - if (csr0 & RINT) - pr_cont(" RINT"); - if (csr0 & TINT) - pr_cont(" TINT"); - if (csr0 & IDON) - pr_cont(" IDON"); - pr_cont(" ]\n"); - } + volatile struct Am79C960 *lance = (struct Am79C960*)dev->base_addr; + u_short in; + u_long version; + int i; + + /* Reset the LANCE */ + in = lance->Reset; + + /* Stop the LANCE */ + lance->RAP = CSR0; /* PCnet-ISA Controller Status */ + lance->RDP = STOP; + + /* Check the LANCE version */ + lance->RAP = CSR88; /* Chip ID */ + version = swapw(lance->RDP); + lance->RAP = CSR89; /* Chip ID */ + version |= swapw(lance->RDP)<<16; + if ((version & 0x00000fff) != 0x00000003) { + printk(KERN_WARNING "ariadne_open: Couldn't find AMD Ethernet Chip\n"); + return -EAGAIN; + } + if ((version & 0x0ffff000) != 0x00003000) { + printk(KERN_WARNING "ariadne_open: Couldn't find Am79C960 (Wrong part " + "number = %ld)\n", (version & 0x0ffff000)>>12); + return -EAGAIN; + } +#if 0 + printk(KERN_DEBUG "ariadne_open: Am79C960 (PCnet-ISA) Revision %ld\n", + (version & 0xf0000000)>>28); #endif - if (csr0 & RINT) { /* Rx interrupt */ - handled = 1; - ariadne_rx(dev); - } + ariadne_init_ring(dev); + + /* Miscellaneous Stuff */ + lance->RAP = CSR3; /* Interrupt Masks and Deferral Control */ + lance->RDP = 0x0000; + lance->RAP = CSR4; /* Test and Features Control */ + lance->RDP = DPOLL|APAD_XMT|MFCOM|RCVCCOM|TXSTRTM|JABM; + + /* Set the Multicast Table */ + lance->RAP = CSR8; /* Logical Address Filter, LADRF[15:0] */ + lance->RDP = 0x0000; + lance->RAP = CSR9; /* Logical Address Filter, LADRF[31:16] */ + lance->RDP = 0x0000; + lance->RAP = CSR10; /* Logical Address Filter, LADRF[47:32] */ + lance->RDP = 0x0000; + lance->RAP = CSR11; /* Logical Address Filter, LADRF[63:48] */ + lance->RDP = 0x0000; + + /* Set the Ethernet Hardware Address */ + lance->RAP = CSR12; /* Physical Address Register, PADR[15:0] */ + lance->RDP = ((u_short *)&dev->dev_addr[0])[0]; + lance->RAP = CSR13; /* Physical Address Register, PADR[31:16] */ + lance->RDP = ((u_short *)&dev->dev_addr[0])[1]; + lance->RAP = CSR14; /* Physical Address Register, PADR[47:32] */ + lance->RDP = ((u_short *)&dev->dev_addr[0])[2]; + + /* Set the Init Block Mode */ + lance->RAP = CSR15; /* Mode Register */ + lance->RDP = 0x0000; + + /* Set the Transmit Descriptor Ring Pointer */ + lance->RAP = CSR30; /* Base Address of Transmit Ring */ + lance->RDP = swloww(ARIADNE_RAM+offsetof(struct lancedata, tx_ring)); + lance->RAP = CSR31; /* Base Address of transmit Ring */ + lance->RDP = swhighw(ARIADNE_RAM+offsetof(struct lancedata, tx_ring)); + + /* Set the Receive Descriptor Ring Pointer */ + lance->RAP = CSR24; /* Base Address of Receive Ring */ + lance->RDP = swloww(ARIADNE_RAM+offsetof(struct lancedata, rx_ring)); + lance->RAP = CSR25; /* Base Address of Receive Ring */ + lance->RDP = swhighw(ARIADNE_RAM+offsetof(struct lancedata, rx_ring)); + + /* Set the Number of RX and TX Ring Entries */ + lance->RAP = CSR76; /* Receive Ring Length */ + lance->RDP = swapw(((u_short)-RX_RING_SIZE)); + lance->RAP = CSR78; /* Transmit Ring Length */ + lance->RDP = swapw(((u_short)-TX_RING_SIZE)); + + /* Enable Media Interface Port Auto Select (10BASE-2/10BASE-T) */ + lance->RAP = ISACSR2; /* Miscellaneous Configuration */ + lance->IDP = ASEL; + + /* LED Control */ + lance->RAP = ISACSR5; /* LED1 Status */ + lance->IDP = PSE|XMTE; + lance->RAP = ISACSR6; /* LED2 Status */ + lance->IDP = PSE|COLE; + lance->RAP = ISACSR7; /* LED3 Status */ + lance->IDP = PSE|RCVE; + + netif_start_queue(dev); + + i = request_irq(IRQ_AMIGA_PORTS, ariadne_interrupt, IRQF_SHARED, + dev->name, dev); + if (i) return i; + + lance->RAP = CSR0; /* PCnet-ISA Controller Status */ + lance->RDP = INEA|STRT; + + return 0; +} - if (csr0 & TINT) { /* Tx-done interrupt */ - int dirty_tx = priv->dirty_tx; - - handled = 1; - while (dirty_tx < priv->cur_tx) { - int entry = dirty_tx % TX_RING_SIZE; - int status = lowb(priv->tx_ring[entry]->TMD1); - - if (status & TF_OWN) - break; /* It still hasn't been Txed */ - - priv->tx_ring[entry]->TMD1 &= 0xff00; - - if (status & TF_ERR) { - /* There was an major error, log it */ - int err_status = priv->tx_ring[entry]->TMD3; - dev->stats.tx_errors++; - if (err_status & EF_RTRY) - dev->stats.tx_aborted_errors++; - if (err_status & EF_LCAR) - dev->stats.tx_carrier_errors++; - if (err_status & EF_LCOL) - dev->stats.tx_window_errors++; - if (err_status & EF_UFLO) { - /* Ackk! On FIFO errors the Tx unit is turned off! */ - dev->stats.tx_fifo_errors++; - /* Remove this verbosity later! */ - netdev_err(dev, "Tx FIFO error! Status %04x\n", - csr0); - /* Restart the chip */ - lance->RDP = STRT; - } - } else { - if (status & (TF_MORE | TF_ONE)) - dev->stats.collisions++; - dev->stats.tx_packets++; - } - dirty_tx++; - } -#ifndef final_version - if (priv->cur_tx - dirty_tx >= TX_RING_SIZE) { - netdev_err(dev, "out-of-sync dirty pointer, %d vs. %d, full=%d\n", - dirty_tx, priv->cur_tx, - priv->tx_full); - dirty_tx += TX_RING_SIZE; - } +static void ariadne_init_ring(struct net_device *dev) +{ + struct ariadne_private *priv = netdev_priv(dev); + volatile struct lancedata *lancedata = (struct lancedata *)dev->mem_start; + int i; + + netif_stop_queue(dev); + + priv->tx_full = 0; + priv->cur_rx = priv->cur_tx = 0; + priv->dirty_tx = 0; + + /* Set up TX Ring */ + for (i = 0; i < TX_RING_SIZE; i++) { + volatile struct TDRE *t = &lancedata->tx_ring[i]; + t->TMD0 = swloww(ARIADNE_RAM+offsetof(struct lancedata, tx_buff[i])); + t->TMD1 = swhighw(ARIADNE_RAM+offsetof(struct lancedata, tx_buff[i])) | + TF_STP | TF_ENP; + t->TMD2 = swapw((u_short)-PKT_BUF_SIZE); + t->TMD3 = 0; + priv->tx_ring[i] = &lancedata->tx_ring[i]; + priv->tx_buff[i] = lancedata->tx_buff[i]; +#if 0 + printk(KERN_DEBUG "TX Entry %2d at %p, Buf at %p\n", i, + &lancedata->tx_ring[i], lancedata->tx_buff[i]); +#endif + } + + /* Set up RX Ring */ + for (i = 0; i < RX_RING_SIZE; i++) { + volatile struct RDRE *r = &lancedata->rx_ring[i]; + r->RMD0 = swloww(ARIADNE_RAM+offsetof(struct lancedata, rx_buff[i])); + r->RMD1 = swhighw(ARIADNE_RAM+offsetof(struct lancedata, rx_buff[i])) | + RF_OWN; + r->RMD2 = swapw((u_short)-PKT_BUF_SIZE); + r->RMD3 = 0x0000; + priv->rx_ring[i] = &lancedata->rx_ring[i]; + priv->rx_buff[i] = lancedata->rx_buff[i]; +#if 0 + printk(KERN_DEBUG "RX Entry %2d at %p, Buf at %p\n", i, + &lancedata->rx_ring[i], lancedata->rx_buff[i]); #endif + } +} - if (priv->tx_full && netif_queue_stopped(dev) && - dirty_tx > priv->cur_tx - TX_RING_SIZE + 2) { - /* The ring is no longer full */ - priv->tx_full = 0; - netif_wake_queue(dev); - } - priv->dirty_tx = dirty_tx; - } +static int ariadne_close(struct net_device *dev) +{ + volatile struct Am79C960 *lance = (struct Am79C960*)dev->base_addr; - /* Log misc errors */ - if (csr0 & BABL) { - handled = 1; - dev->stats.tx_errors++; /* Tx babble */ - } - if (csr0 & MISS) { - handled = 1; - dev->stats.rx_errors++; /* Missed a Rx frame */ - } - if (csr0 & MERR) { - handled = 1; - netdev_err(dev, "Bus master arbitration failure, status %04x\n", - csr0); - /* Restart the chip */ - lance->RDP = STRT; - } - } + netif_stop_queue(dev); + + lance->RAP = CSR112; /* Missed Frame Count */ + dev->stats.rx_missed_errors = swapw(lance->RDP); + lance->RAP = CSR0; /* PCnet-ISA Controller Status */ + + if (ariadne_debug > 1) { + printk(KERN_DEBUG "%s: Shutting down ethercard, status was %2.2x.\n", + dev->name, lance->RDP); + printk(KERN_DEBUG "%s: %lu packets missed\n", dev->name, + dev->stats.rx_missed_errors); + } - /* Clear any other interrupt, and set interrupt enable */ - lance->RAP = CSR0; /* PCnet-ISA Controller Status */ - lance->RDP = INEA | BABL | CERR | MISS | MERR | IDON; + /* We stop the LANCE here -- it occasionally polls memory if we don't. */ + lance->RDP = STOP; - if (ariadne_debug > 4) - netdev_dbg(dev, "exiting interrupt, csr%d=%#04x\n", - lance->RAP, lance->RDP); + free_irq(IRQ_AMIGA_PORTS, dev); - return IRQ_RETVAL(handled); + return 0; } -static int ariadne_open(struct net_device *dev) + +static inline void ariadne_reset(struct net_device *dev) { - volatile struct Am79C960 *lance = (struct Am79C960 *)dev->base_addr; - u_short in; - u_long version; - int i; + volatile struct Am79C960 *lance = (struct Am79C960*)dev->base_addr; - /* Reset the LANCE */ - in = lance->Reset; - - /* Stop the LANCE */ - lance->RAP = CSR0; /* PCnet-ISA Controller Status */ - lance->RDP = STOP; - - /* Check the LANCE version */ - lance->RAP = CSR88; /* Chip ID */ - version = swapw(lance->RDP); - lance->RAP = CSR89; /* Chip ID */ - version |= swapw(lance->RDP) << 16; - if ((version & 0x00000fff) != 0x00000003) { - pr_warn("Couldn't find AMD Ethernet Chip\n"); - return -EAGAIN; - } - if ((version & 0x0ffff000) != 0x00003000) { - pr_warn("Couldn't find Am79C960 (Wrong part number = %ld)\n", - (version & 0x0ffff000) >> 12); - return -EAGAIN; - } + lance->RAP = CSR0; /* PCnet-ISA Controller Status */ + lance->RDP = STOP; + ariadne_init_ring(dev); + lance->RDP = INEA|STRT; + netif_start_queue(dev); +} - netdev_dbg(dev, "Am79C960 (PCnet-ISA) Revision %ld\n", - (version & 0xf0000000) >> 28); - ariadne_init_ring(dev); +static irqreturn_t ariadne_interrupt(int irq, void *data) +{ + struct net_device *dev = (struct net_device *)data; + volatile struct Am79C960 *lance = (struct Am79C960*)dev->base_addr; + struct ariadne_private *priv; + int csr0, boguscnt; + int handled = 0; - /* Miscellaneous Stuff */ - lance->RAP = CSR3; /* Interrupt Masks and Deferral Control */ - lance->RDP = 0x0000; - lance->RAP = CSR4; /* Test and Features Control */ - lance->RDP = DPOLL | APAD_XMT | MFCOM | RCVCCOM | TXSTRTM | JABM; + lance->RAP = CSR0; /* PCnet-ISA Controller Status */ - /* Set the Multicast Table */ - lance->RAP = CSR8; /* Logical Address Filter, LADRF[15:0] */ - lance->RDP = 0x0000; - lance->RAP = CSR9; /* Logical Address Filter, LADRF[31:16] */ - lance->RDP = 0x0000; - lance->RAP = CSR10; /* Logical Address Filter, LADRF[47:32] */ - lance->RDP = 0x0000; - lance->RAP = CSR11; /* Logical Address Filter, LADRF[63:48] */ - lance->RDP = 0x0000; + if (!(lance->RDP & INTR)) /* Check if any interrupt has been */ + return IRQ_NONE; /* generated by the board. */ - /* Set the Ethernet Hardware Address */ - lance->RAP = CSR12; /* Physical Address Register, PADR[15:0] */ - lance->RDP = ((u_short *)&dev->dev_addr[0])[0]; - lance->RAP = CSR13; /* Physical Address Register, PADR[31:16] */ - lance->RDP = ((u_short *)&dev->dev_addr[0])[1]; - lance->RAP = CSR14; /* Physical Address Register, PADR[47:32] */ - lance->RDP = ((u_short *)&dev->dev_addr[0])[2]; + priv = netdev_priv(dev); - /* Set the Init Block Mode */ - lance->RAP = CSR15; /* Mode Register */ - lance->RDP = 0x0000; + boguscnt = 10; + while ((csr0 = lance->RDP) & (ERR|RINT|TINT) && --boguscnt >= 0) { + /* Acknowledge all of the current interrupt sources ASAP. */ + lance->RDP = csr0 & ~(INEA|TDMD|STOP|STRT|INIT); - /* Set the Transmit Descriptor Ring Pointer */ - lance->RAP = CSR30; /* Base Address of Transmit Ring */ - lance->RDP = swloww(ARIADNE_RAM + offsetof(struct lancedata, tx_ring)); - lance->RAP = CSR31; /* Base Address of transmit Ring */ - lance->RDP = swhighw(ARIADNE_RAM + offsetof(struct lancedata, tx_ring)); - - /* Set the Receive Descriptor Ring Pointer */ - lance->RAP = CSR24; /* Base Address of Receive Ring */ - lance->RDP = swloww(ARIADNE_RAM + offsetof(struct lancedata, rx_ring)); - lance->RAP = CSR25; /* Base Address of Receive Ring */ - lance->RDP = swhighw(ARIADNE_RAM + offsetof(struct lancedata, rx_ring)); - - /* Set the Number of RX and TX Ring Entries */ - lance->RAP = CSR76; /* Receive Ring Length */ - lance->RDP = swapw(((u_short)-RX_RING_SIZE)); - lance->RAP = CSR78; /* Transmit Ring Length */ - lance->RDP = swapw(((u_short)-TX_RING_SIZE)); - - /* Enable Media Interface Port Auto Select (10BASE-2/10BASE-T) */ - lance->RAP = ISACSR2; /* Miscellaneous Configuration */ - lance->IDP = ASEL; - - /* LED Control */ - lance->RAP = ISACSR5; /* LED1 Status */ - lance->IDP = PSE|XMTE; - lance->RAP = ISACSR6; /* LED2 Status */ - lance->IDP = PSE|COLE; - lance->RAP = ISACSR7; /* LED3 Status */ - lance->IDP = PSE|RCVE; - - netif_start_queue(dev); - - i = request_irq(IRQ_AMIGA_PORTS, ariadne_interrupt, IRQF_SHARED, - dev->name, dev); - if (i) - return i; - - lance->RAP = CSR0; /* PCnet-ISA Controller Status */ - lance->RDP = INEA | STRT; - - return 0; -} +#if 0 + if (ariadne_debug > 5) { + printk(KERN_DEBUG "%s: interrupt csr0=%#2.2x new csr=%#2.2x.", + dev->name, csr0, lance->RDP); + printk("["); + if (csr0 & INTR) + printk(" INTR"); + if (csr0 & INEA) + printk(" INEA"); + if (csr0 & RXON) + printk(" RXON"); + if (csr0 & TXON) + printk(" TXON"); + if (csr0 & TDMD) + printk(" TDMD"); + if (csr0 & STOP) + printk(" STOP"); + if (csr0 & STRT) + printk(" STRT"); + if (csr0 & INIT) + printk(" INIT"); + if (csr0 & ERR) + printk(" ERR"); + if (csr0 & BABL) + printk(" BABL"); + if (csr0 & CERR) + printk(" CERR"); + if (csr0 & MISS) + printk(" MISS"); + if (csr0 & MERR) + printk(" MERR"); + if (csr0 & RINT) + printk(" RINT"); + if (csr0 & TINT) + printk(" TINT"); + if (csr0 & IDON) + printk(" IDON"); + printk(" ]\n"); + } +#endif -static int ariadne_close(struct net_device *dev) -{ - volatile struct Am79C960 *lance = (struct Am79C960 *)dev->base_addr; + if (csr0 & RINT) { /* Rx interrupt */ + handled = 1; + ariadne_rx(dev); + } - netif_stop_queue(dev); + if (csr0 & TINT) { /* Tx-done interrupt */ + int dirty_tx = priv->dirty_tx; + + handled = 1; + while (dirty_tx < priv->cur_tx) { + int entry = dirty_tx % TX_RING_SIZE; + int status = lowb(priv->tx_ring[entry]->TMD1); + + if (status & TF_OWN) + break; /* It still hasn't been Txed */ + + priv->tx_ring[entry]->TMD1 &= 0xff00; + + if (status & TF_ERR) { + /* There was an major error, log it. */ + int err_status = priv->tx_ring[entry]->TMD3; + dev->stats.tx_errors++; + if (err_status & EF_RTRY) + dev->stats.tx_aborted_errors++; + if (err_status & EF_LCAR) + dev->stats.tx_carrier_errors++; + if (err_status & EF_LCOL) + dev->stats.tx_window_errors++; + if (err_status & EF_UFLO) { + /* Ackk! On FIFO errors the Tx unit is turned off! */ + dev->stats.tx_fifo_errors++; + /* Remove this verbosity later! */ + printk(KERN_ERR "%s: Tx FIFO error! Status %4.4x.\n", + dev->name, csr0); + /* Restart the chip. */ + lance->RDP = STRT; + } + } else { + if (status & (TF_MORE|TF_ONE)) + dev->stats.collisions++; + dev->stats.tx_packets++; + } + dirty_tx++; + } + +#ifndef final_version + if (priv->cur_tx - dirty_tx >= TX_RING_SIZE) { + printk(KERN_ERR "out-of-sync dirty pointer, %d vs. %d, " + "full=%d.\n", dirty_tx, priv->cur_tx, priv->tx_full); + dirty_tx += TX_RING_SIZE; + } +#endif - lance->RAP = CSR112; /* Missed Frame Count */ - dev->stats.rx_missed_errors = swapw(lance->RDP); - lance->RAP = CSR0; /* PCnet-ISA Controller Status */ + if (priv->tx_full && netif_queue_stopped(dev) && + dirty_tx > priv->cur_tx - TX_RING_SIZE + 2) { + /* The ring is no longer full. */ + priv->tx_full = 0; + netif_wake_queue(dev); + } - if (ariadne_debug > 1) { - netdev_dbg(dev, "Shutting down ethercard, status was %02x\n", - lance->RDP); - netdev_dbg(dev, "%lu packets missed\n", - dev->stats.rx_missed_errors); + priv->dirty_tx = dirty_tx; } - /* We stop the LANCE here -- it occasionally polls memory if we don't */ - lance->RDP = STOP; + /* Log misc errors. */ + if (csr0 & BABL) { + handled = 1; + dev->stats.tx_errors++; /* Tx babble. */ + } + if (csr0 & MISS) { + handled = 1; + dev->stats.rx_errors++; /* Missed a Rx frame. */ + } + if (csr0 & MERR) { + handled = 1; + printk(KERN_ERR "%s: Bus master arbitration failure, status " + "%4.4x.\n", dev->name, csr0); + /* Restart the chip. */ + lance->RDP = STRT; + } + } - free_irq(IRQ_AMIGA_PORTS, dev); + /* Clear any other interrupt, and set interrupt enable. */ + lance->RAP = CSR0; /* PCnet-ISA Controller Status */ + lance->RDP = INEA|BABL|CERR|MISS|MERR|IDON; - return 0; +#if 0 + if (ariadne_debug > 4) + printk(KERN_DEBUG "%s: exiting interrupt, csr%d=%#4.4x.\n", dev->name, + lance->RAP, lance->RDP); +#endif + return IRQ_RETVAL(handled); } -static inline void ariadne_reset(struct net_device *dev) -{ - volatile struct Am79C960 *lance = (struct Am79C960 *)dev->base_addr; - - lance->RAP = CSR0; /* PCnet-ISA Controller Status */ - lance->RDP = STOP; - ariadne_init_ring(dev); - lance->RDP = INEA | STRT; - netif_start_queue(dev); -} static void ariadne_tx_timeout(struct net_device *dev) { - volatile struct Am79C960 *lance = (struct Am79C960 *)dev->base_addr; + volatile struct Am79C960 *lance = (struct Am79C960*)dev->base_addr; - netdev_err(dev, "transmit timed out, status %04x, resetting\n", - lance->RDP); - ariadne_reset(dev); - netif_wake_queue(dev); + printk(KERN_ERR "%s: transmit timed out, status %4.4x, resetting.\n", + dev->name, lance->RDP); + ariadne_reset(dev); + netif_wake_queue(dev); } + static netdev_tx_t ariadne_start_xmit(struct sk_buff *skb, struct net_device *dev) { - struct ariadne_private *priv = netdev_priv(dev); - volatile struct Am79C960 *lance = (struct Am79C960 *)dev->base_addr; - int entry; - unsigned long flags; - int len = skb->len; + struct ariadne_private *priv = netdev_priv(dev); + volatile struct Am79C960 *lance = (struct Am79C960*)dev->base_addr; + int entry; + unsigned long flags; + int len = skb->len; #if 0 - if (ariadne_debug > 3) { - lance->RAP = CSR0; /* PCnet-ISA Controller Status */ - netdev_dbg(dev, "%s: csr0 %04x\n", __func__, lance->RDP); - lance->RDP = 0x0000; - } + if (ariadne_debug > 3) { + lance->RAP = CSR0; /* PCnet-ISA Controller Status */ + printk(KERN_DEBUG "%s: ariadne_start_xmit() called, csr0 %4.4x.\n", + dev->name, lance->RDP); + lance->RDP = 0x0000; + } #endif - /* FIXME: is the 79C960 new enough to do its own padding right ? */ - if (skb->len < ETH_ZLEN) { - if (skb_padto(skb, ETH_ZLEN)) - return NETDEV_TX_OK; - len = ETH_ZLEN; - } + /* FIXME: is the 79C960 new enough to do its own padding right ? */ + if (skb->len < ETH_ZLEN) + { + if (skb_padto(skb, ETH_ZLEN)) + return NETDEV_TX_OK; + len = ETH_ZLEN; + } - /* Fill in a Tx ring entry */ + /* Fill in a Tx ring entry */ - netdev_dbg(dev, "TX pkt type 0x%04x from %pM to %pM data 0x%08x len %d\n", - ((u_short *)skb->data)[6], - skb->data + 6, skb->data, - (int)skb->data, (int)skb->len); +#if 0 +{ + printk(KERN_DEBUG "TX pkt type 0x%04x from %pM to %pM " + " data 0x%08x len %d\n", + ((u_short *)skb->data)[6], + skb->data + 6, skb->data, + (int)skb->data, (int)skb->len); +} +#endif - local_irq_save(flags); + local_irq_save(flags); - entry = priv->cur_tx % TX_RING_SIZE; + entry = priv->cur_tx % TX_RING_SIZE; - /* Caution: the write order is important here, set the base address with - the "ownership" bits last */ + /* Caution: the write order is important here, set the base address with + the "ownership" bits last. */ - priv->tx_ring[entry]->TMD2 = swapw((u_short)-skb->len); - priv->tx_ring[entry]->TMD3 = 0x0000; - memcpyw(priv->tx_buff[entry], (u_short *)skb->data, len); + priv->tx_ring[entry]->TMD2 = swapw((u_short)-skb->len); + priv->tx_ring[entry]->TMD3 = 0x0000; + memcpyw(priv->tx_buff[entry], (u_short *)skb->data, len); -#ifdef DEBUG - print_hex_dump(KERN_DEBUG, "tx_buff: ", DUMP_PREFIX_OFFSET, 16, 1, - (void *)priv->tx_buff[entry], - skb->len > 64 ? 64 : skb->len, true); +#if 0 + { + int i, len; + + len = skb->len > 64 ? 64 : skb->len; + len >>= 1; + for (i = 0; i < len; i += 8) { + int j; + printk(KERN_DEBUG "%04x:", i); + for (j = 0; (j < 8) && ((i+j) < len); j++) { + if (!(j & 1)) + printk(" "); + printk("%04x", priv->tx_buff[entry][i+j]); + } + printk("\n"); + } + } #endif - priv->tx_ring[entry]->TMD1 = (priv->tx_ring[entry]->TMD1 & 0xff00) - | TF_OWN | TF_STP | TF_ENP; + priv->tx_ring[entry]->TMD1 = (priv->tx_ring[entry]->TMD1&0xff00)|TF_OWN|TF_STP|TF_ENP; - dev_kfree_skb(skb); + dev_kfree_skb(skb); - priv->cur_tx++; - if ((priv->cur_tx >= TX_RING_SIZE) && - (priv->dirty_tx >= TX_RING_SIZE)) { + priv->cur_tx++; + if ((priv->cur_tx >= TX_RING_SIZE) && (priv->dirty_tx >= TX_RING_SIZE)) { - netdev_dbg(dev, "*** Subtracting TX_RING_SIZE from cur_tx (%d) and dirty_tx (%d)\n", - priv->cur_tx, priv->dirty_tx); +#if 0 + printk(KERN_DEBUG "*** Subtracting TX_RING_SIZE from cur_tx (%d) and " + "dirty_tx (%d)\n", priv->cur_tx, priv->dirty_tx); +#endif - priv->cur_tx -= TX_RING_SIZE; - priv->dirty_tx -= TX_RING_SIZE; - } - dev->stats.tx_bytes += len; + priv->cur_tx -= TX_RING_SIZE; + priv->dirty_tx -= TX_RING_SIZE; + } + dev->stats.tx_bytes += len; - /* Trigger an immediate send poll */ - lance->RAP = CSR0; /* PCnet-ISA Controller Status */ - lance->RDP = INEA | TDMD; + /* Trigger an immediate send poll. */ + lance->RAP = CSR0; /* PCnet-ISA Controller Status */ + lance->RDP = INEA|TDMD; - if (lowb(priv->tx_ring[(entry + 1) % TX_RING_SIZE]->TMD1) != 0) { - netif_stop_queue(dev); - priv->tx_full = 1; - } - local_irq_restore(flags); + if (lowb(priv->tx_ring[(entry+1) % TX_RING_SIZE]->TMD1) != 0) { + netif_stop_queue(dev); + priv->tx_full = 1; + } + local_irq_restore(flags); - return NETDEV_TX_OK; + return NETDEV_TX_OK; } -static struct net_device_stats *ariadne_get_stats(struct net_device *dev) -{ - volatile struct Am79C960 *lance = (struct Am79C960 *)dev->base_addr; - short saved_addr; - unsigned long flags; - - local_irq_save(flags); - saved_addr = lance->RAP; - lance->RAP = CSR112; /* Missed Frame Count */ - dev->stats.rx_missed_errors = swapw(lance->RDP); - lance->RAP = saved_addr; - local_irq_restore(flags); - - return &dev->stats; -} -/* Set or clear the multicast filter for this adaptor. - * num_addrs == -1 Promiscuous mode, receive all packets - * num_addrs == 0 Normal mode, clear multicast list - * num_addrs > 0 Multicast mode, receive normal and MC packets, - * and do best-effort filtering. - */ -static void set_multicast_list(struct net_device *dev) +static int ariadne_rx(struct net_device *dev) { - volatile struct Am79C960 *lance = (struct Am79C960 *)dev->base_addr; + struct ariadne_private *priv = netdev_priv(dev); + int entry = priv->cur_rx % RX_RING_SIZE; + int i; + + /* If we own the next entry, it's a new packet. Send it up. */ + while (!(lowb(priv->rx_ring[entry]->RMD1) & RF_OWN)) { + int status = lowb(priv->rx_ring[entry]->RMD1); + + if (status != (RF_STP|RF_ENP)) { /* There was an error. */ + /* There is a tricky error noted by John Murphy, + to Russ Nelson: Even with full-sized + buffers it's possible for a jabber packet to use two + buffers, with only the last correctly noting the error. */ + if (status & RF_ENP) + /* Only count a general error at the end of a packet.*/ + dev->stats.rx_errors++; + if (status & RF_FRAM) + dev->stats.rx_frame_errors++; + if (status & RF_OFLO) + dev->stats.rx_over_errors++; + if (status & RF_CRC) + dev->stats.rx_crc_errors++; + if (status & RF_BUFF) + dev->stats.rx_fifo_errors++; + priv->rx_ring[entry]->RMD1 &= 0xff00|RF_STP|RF_ENP; + } else { + /* Malloc up new buffer, compatible with net-3. */ + short pkt_len = swapw(priv->rx_ring[entry]->RMD3); + struct sk_buff *skb; + + skb = dev_alloc_skb(pkt_len+2); + if (skb == NULL) { + printk(KERN_WARNING "%s: Memory squeeze, deferring packet.\n", + dev->name); + for (i = 0; i < RX_RING_SIZE; i++) + if (lowb(priv->rx_ring[(entry+i) % RX_RING_SIZE]->RMD1) & RF_OWN) + break; + + if (i > RX_RING_SIZE-2) { + dev->stats.rx_dropped++; + priv->rx_ring[entry]->RMD1 |= RF_OWN; + priv->cur_rx++; + } + break; + } - if (!netif_running(dev)) - return; - netif_stop_queue(dev); - - /* We take the simple way out and always enable promiscuous mode */ - lance->RAP = CSR0; /* PCnet-ISA Controller Status */ - lance->RDP = STOP; /* Temporarily stop the lance */ - ariadne_init_ring(dev); + skb_reserve(skb,2); /* 16 byte align */ + skb_put(skb,pkt_len); /* Make room */ + skb_copy_to_linear_data(skb, (char *)priv->rx_buff[entry], pkt_len); + skb->protocol=eth_type_trans(skb,dev); +#if 0 +{ + printk(KERN_DEBUG "RX pkt type 0x%04x from ", + ((u_short *)skb->data)[6]); + { + u_char *ptr = &((u_char *)skb->data)[6]; + printk("%pM", ptr); + } + printk(" to "); + { + u_char *ptr = (u_char *)skb->data; + printk("%pM", ptr); + } + printk(" data 0x%08x len %d\n", (int)skb->data, (int)skb->len); +} +#endif - if (dev->flags & IFF_PROMISC) { - lance->RAP = CSR15; /* Mode Register */ - lance->RDP = PROM; /* Set promiscuous mode */ - } else { - short multicast_table[4]; - int num_addrs = netdev_mc_count(dev); - int i; - /* We don't use the multicast table, - * but rely on upper-layer filtering - */ - memset(multicast_table, (num_addrs == 0) ? 0 : -1, - sizeof(multicast_table)); - for (i = 0; i < 4; i++) { - lance->RAP = CSR8 + (i << 8); - /* Logical Address Filter */ - lance->RDP = swapw(multicast_table[i]); - } - lance->RAP = CSR15; /* Mode Register */ - lance->RDP = 0x0000; /* Unset promiscuous mode */ + netif_rx(skb); + dev->stats.rx_packets++; + dev->stats.rx_bytes += pkt_len; } - lance->RAP = CSR0; /* PCnet-ISA Controller Status */ - lance->RDP = INEA | STRT | IDON;/* Resume normal operation */ + priv->rx_ring[entry]->RMD1 |= RF_OWN; + entry = (++priv->cur_rx) % RX_RING_SIZE; + } + + priv->cur_rx = priv->cur_rx % RX_RING_SIZE; - netif_wake_queue(dev); + /* We should check that at least two ring entries are free. If not, + we should free one and mark stats->rx_dropped++. */ + + return 0; } -static void __devexit ariadne_remove_one(struct zorro_dev *z) +static struct net_device_stats *ariadne_get_stats(struct net_device *dev) { - struct net_device *dev = zorro_get_drvdata(z); - - unregister_netdev(dev); - release_mem_region(ZTWO_PADDR(dev->base_addr), sizeof(struct Am79C960)); - release_mem_region(ZTWO_PADDR(dev->mem_start), ARIADNE_RAM_SIZE); - free_netdev(dev); + volatile struct Am79C960 *lance = (struct Am79C960*)dev->base_addr; + short saved_addr; + unsigned long flags; + + local_irq_save(flags); + saved_addr = lance->RAP; + lance->RAP = CSR112; /* Missed Frame Count */ + dev->stats.rx_missed_errors = swapw(lance->RDP); + lance->RAP = saved_addr; + local_irq_restore(flags); + + return &dev->stats; } -static struct zorro_device_id ariadne_zorro_tbl[] __devinitdata = { - { ZORRO_PROD_VILLAGE_TRONIC_ARIADNE }, - { 0 } -}; -MODULE_DEVICE_TABLE(zorro, ariadne_zorro_tbl); -static const struct net_device_ops ariadne_netdev_ops = { - .ndo_open = ariadne_open, - .ndo_stop = ariadne_close, - .ndo_start_xmit = ariadne_start_xmit, - .ndo_tx_timeout = ariadne_tx_timeout, - .ndo_get_stats = ariadne_get_stats, - .ndo_set_multicast_list = set_multicast_list, - .ndo_validate_addr = eth_validate_addr, - .ndo_change_mtu = eth_change_mtu, - .ndo_set_mac_address = eth_mac_addr, -}; - -static int __devinit ariadne_init_one(struct zorro_dev *z, - const struct zorro_device_id *ent) +/* Set or clear the multicast filter for this adaptor. + num_addrs == -1 Promiscuous mode, receive all packets + num_addrs == 0 Normal mode, clear multicast list + num_addrs > 0 Multicast mode, receive normal and MC packets, and do + best-effort filtering. + */ +static void set_multicast_list(struct net_device *dev) { - unsigned long board = z->resource.start; - unsigned long base_addr = board + ARIADNE_LANCE; - unsigned long mem_start = board + ARIADNE_RAM; - struct resource *r1, *r2; - struct net_device *dev; - struct ariadne_private *priv; - int err; - - r1 = request_mem_region(base_addr, sizeof(struct Am79C960), "Am79C960"); - if (!r1) - return -EBUSY; - r2 = request_mem_region(mem_start, ARIADNE_RAM_SIZE, "RAM"); - if (!r2) { - release_mem_region(base_addr, sizeof(struct Am79C960)); - return -EBUSY; - } + volatile struct Am79C960 *lance = (struct Am79C960*)dev->base_addr; - dev = alloc_etherdev(sizeof(struct ariadne_private)); - if (dev == NULL) { - release_mem_region(base_addr, sizeof(struct Am79C960)); - release_mem_region(mem_start, ARIADNE_RAM_SIZE); - return -ENOMEM; - } + if (!netif_running(dev)) + return; + + netif_stop_queue(dev); - priv = netdev_priv(dev); - - r1->name = dev->name; - r2->name = dev->name; - - dev->dev_addr[0] = 0x00; - dev->dev_addr[1] = 0x60; - dev->dev_addr[2] = 0x30; - dev->dev_addr[3] = (z->rom.er_SerialNumber >> 16) & 0xff; - dev->dev_addr[4] = (z->rom.er_SerialNumber >> 8) & 0xff; - dev->dev_addr[5] = z->rom.er_SerialNumber & 0xff; - dev->base_addr = ZTWO_VADDR(base_addr); - dev->mem_start = ZTWO_VADDR(mem_start); - dev->mem_end = dev->mem_start + ARIADNE_RAM_SIZE; - - dev->netdev_ops = &ariadne_netdev_ops; - dev->watchdog_timeo = 5 * HZ; - - err = register_netdev(dev); - if (err) { - release_mem_region(base_addr, sizeof(struct Am79C960)); - release_mem_region(mem_start, ARIADNE_RAM_SIZE); - free_netdev(dev); - return err; + /* We take the simple way out and always enable promiscuous mode. */ + lance->RAP = CSR0; /* PCnet-ISA Controller Status */ + lance->RDP = STOP; /* Temporarily stop the lance. */ + ariadne_init_ring(dev); + + if (dev->flags & IFF_PROMISC) { + lance->RAP = CSR15; /* Mode Register */ + lance->RDP = PROM; /* Set promiscuous mode */ + } else { + short multicast_table[4]; + int num_addrs = netdev_mc_count(dev); + int i; + /* We don't use the multicast table, but rely on upper-layer filtering. */ + memset(multicast_table, (num_addrs == 0) ? 0 : -1, + sizeof(multicast_table)); + for (i = 0; i < 4; i++) { + lance->RAP = CSR8+(i<<8); /* Logical Address Filter */ + lance->RDP = swapw(multicast_table[i]); } - zorro_set_drvdata(z, dev); + lance->RAP = CSR15; /* Mode Register */ + lance->RDP = 0x0000; /* Unset promiscuous mode */ + } - netdev_info(dev, "Ariadne at 0x%08lx, Ethernet Address %pM\n", - board, dev->dev_addr); + lance->RAP = CSR0; /* PCnet-ISA Controller Status */ + lance->RDP = INEA|STRT|IDON; /* Resume normal operation. */ - return 0; + netif_wake_queue(dev); } -static struct zorro_driver ariadne_driver = { - .name = "ariadne", - .id_table = ariadne_zorro_tbl, - .probe = ariadne_init_one, - .remove = __devexit_p(ariadne_remove_one), -}; + +static void __devexit ariadne_remove_one(struct zorro_dev *z) +{ + struct net_device *dev = zorro_get_drvdata(z); + + unregister_netdev(dev); + release_mem_region(ZTWO_PADDR(dev->base_addr), sizeof(struct Am79C960)); + release_mem_region(ZTWO_PADDR(dev->mem_start), ARIADNE_RAM_SIZE); + free_netdev(dev); +} static int __init ariadne_init_module(void) { - return zorro_register_driver(&ariadne_driver); + return zorro_register_driver(&ariadne_driver); } static void __exit ariadne_cleanup_module(void) { - zorro_unregister_driver(&ariadne_driver); + zorro_unregister_driver(&ariadne_driver); } module_init(ariadne_init_module); diff --git a/trunk/drivers/net/arm/am79c961a.c b/trunk/drivers/net/arm/am79c961a.c index 52fe21e1e2cd..7b3e23f38913 100644 --- a/trunk/drivers/net/arm/am79c961a.c +++ b/trunk/drivers/net/arm/am79c961a.c @@ -199,15 +199,17 @@ am79c961_ramtest(struct net_device *dev, unsigned int val) static void am79c961_mc_hash(char *addr, u16 *hash) { - int idx, bit; - u32 crc; + if (addr[0] & 0x01) { + int idx, bit; + u32 crc; - crc = ether_crc_le(ETH_ALEN, addr); + crc = ether_crc_le(ETH_ALEN, addr); - idx = crc >> 30; - bit = (crc >> 26) & 15; + idx = crc >> 30; + bit = (crc >> 26) & 15; - hash[idx] |= 1 << bit; + hash[idx] |= 1 << bit; + } } static unsigned int am79c961_get_rx_mode(struct net_device *dev, u16 *hash) diff --git a/trunk/drivers/net/atl1c/atl1c.h b/trunk/drivers/net/atl1c/atl1c.h index 0f481b983bcf..dfe4370ccc90 100644 --- a/trunk/drivers/net/atl1c/atl1c.h +++ b/trunk/drivers/net/atl1c/atl1c.h @@ -22,6 +22,7 @@ #ifndef _ATL1C_H_ #define _ATL1C_H_ +#include #include #include #include diff --git a/trunk/drivers/net/atl1e/atl1e.h b/trunk/drivers/net/atl1e/atl1e.h index 8c8181b53286..9ac37e3ec8fb 100644 --- a/trunk/drivers/net/atl1e/atl1e.h +++ b/trunk/drivers/net/atl1e/atl1e.h @@ -23,6 +23,7 @@ #ifndef _ATL1E_H_ #define _ATL1E_H_ +#include #include #include #include diff --git a/trunk/drivers/net/b44.c b/trunk/drivers/net/b44.c index 6c4ef966ca58..085560e1d17a 100644 --- a/trunk/drivers/net/b44.c +++ b/trunk/drivers/net/b44.c @@ -39,7 +39,6 @@ #define DRV_MODULE_NAME "b44" #define DRV_MODULE_VERSION "2.0" -#define DRV_DESCRIPTION "Broadcom 44xx/47xx 10/100 PCI ethernet driver" #define B44_DEF_MSG_ENABLE \ (NETIF_MSG_DRV | \ @@ -92,8 +91,11 @@ #define B44_ETHIPV6UDP_HLEN 62 #define B44_ETHIPV4UDP_HLEN 42 +static char version[] __devinitdata = + DRV_MODULE_NAME ".c:v" DRV_MODULE_VERSION "\n"; + MODULE_AUTHOR("Felix Fietkau, Florian Schirmer, Pekka Pietikainen, David S. Miller"); -MODULE_DESCRIPTION(DRV_DESCRIPTION); +MODULE_DESCRIPTION("Broadcom 44xx/47xx 10/100 PCI ethernet driver"); MODULE_LICENSE("GPL"); MODULE_VERSION(DRV_MODULE_VERSION); @@ -608,7 +610,7 @@ static void b44_tx(struct b44 *bp) skb->len, DMA_TO_DEVICE); rp->skb = NULL; - dev_kfree_skb(skb); + dev_kfree_skb_irq(skb); } bp->tx_cons = cons; @@ -2128,13 +2130,16 @@ static const struct net_device_ops b44_netdev_ops = { static int __devinit b44_init_one(struct ssb_device *sdev, const struct ssb_device_id *ent) { + static int b44_version_printed = 0; struct net_device *dev; struct b44 *bp; int err; instance++; - pr_info_once("%s version %s\n", DRV_DESCRIPTION, DRV_MODULE_VERSION); + if (b44_version_printed++ == 0) + pr_info("%s", version); + dev = alloc_etherdev(sizeof(*bp)); if (!dev) { @@ -2220,7 +2225,8 @@ static int __devinit b44_init_one(struct ssb_device *sdev, if (b44_phy_reset(bp) < 0) bp->phy_addr = B44_PHY_ADDR_NO_PHY; - netdev_info(dev, "%s %pM\n", DRV_DESCRIPTION, dev->dev_addr); + netdev_info(dev, "Broadcom 44xx/47xx 10/100BaseT Ethernet %pM\n", + dev->dev_addr); return 0; @@ -2330,7 +2336,7 @@ static struct ssb_driver b44_ssb_driver = { .resume = b44_resume, }; -static inline int __init b44_pci_init(void) +static inline int b44_pci_init(void) { int err = 0; #ifdef CONFIG_B44_PCI @@ -2339,7 +2345,7 @@ static inline int __init b44_pci_init(void) return err; } -static inline void __exit b44_pci_exit(void) +static inline void b44_pci_exit(void) { #ifdef CONFIG_B44_PCI ssb_pcihost_unregister(&b44_pci_driver); diff --git a/trunk/drivers/net/benet/be.h b/trunk/drivers/net/benet/be.h index c85768cd1b18..a36f5a6a8462 100644 --- a/trunk/drivers/net/benet/be.h +++ b/trunk/drivers/net/benet/be.h @@ -20,6 +20,7 @@ #include #include +#include #include #include #include @@ -199,7 +200,6 @@ struct be_rx_stats { u32 rx_polls; /* number of times NAPI called poll function */ u32 rx_events; /* number of ucast rx completion events */ u32 rx_compl; /* number of rx completion entries processed */ - ulong rx_dropped; /* number of skb allocation errors */ ulong rx_jiffies; u64 rx_bytes; u64 rx_bytes_prev; @@ -333,6 +333,7 @@ struct be_adapter { u8 eq_next_idx; struct be_drv_stats drv_stats; + struct vlan_group *vlan_grp; u16 vlans_added; u16 max_vlans; /* Number of vlans supported */ u8 vlan_tag[VLAN_N_VID]; diff --git a/trunk/drivers/net/benet/be_cmds.c b/trunk/drivers/net/benet/be_cmds.c index f520a5c75032..30719f591fb2 100644 --- a/trunk/drivers/net/benet/be_cmds.c +++ b/trunk/drivers/net/benet/be_cmds.c @@ -106,24 +106,14 @@ static int be_mcc_compl_process(struct be_adapter *adapter, netdev_stats_update(adapter); adapter->stats_cmd_sent = false; } - } else { - if (compl_status == MCC_STATUS_NOT_SUPPORTED || - compl_status == MCC_STATUS_ILLEGAL_REQUEST) - goto done; - - if (compl_status == MCC_STATUS_UNAUTHORIZED_REQUEST) { - dev_warn(&adapter->pdev->dev, "This domain(VM) is not " - "permitted to execute this cmd (opcode %d)\n", - compl->tag0); - } else { - extd_status = (compl->status >> CQE_STATUS_EXTD_SHIFT) & - CQE_STATUS_EXTD_MASK; - dev_err(&adapter->pdev->dev, "Cmd (opcode %d) failed:" - "status %d, extd-status %d\n", - compl->tag0, compl_status, extd_status); - } + } else if ((compl_status != MCC_STATUS_NOT_SUPPORTED) && + (compl->tag0 != OPCODE_COMMON_NTWK_MAC_QUERY)) { + extd_status = (compl->status >> CQE_STATUS_EXTD_SHIFT) & + CQE_STATUS_EXTD_MASK; + dev_warn(&adapter->pdev->dev, + "Error in cmd completion - opcode %d, compl %d, extd %d\n", + compl->tag0, compl_status, extd_status); } -done: return compl_status; } @@ -984,7 +974,7 @@ int be_cmd_txq_create(struct be_adapter *adapter, return status; } -/* Uses MCC */ +/* Uses mbox */ int be_cmd_rxq_create(struct be_adapter *adapter, struct be_queue_info *rxq, u16 cq_id, u16 frag_size, u16 max_frame_size, u32 if_id, u32 rss, u8 *rss_id) @@ -994,13 +984,10 @@ int be_cmd_rxq_create(struct be_adapter *adapter, struct be_dma_mem *q_mem = &rxq->dma_mem; int status; - spin_lock_bh(&adapter->mcc_lock); + if (mutex_lock_interruptible(&adapter->mbox_lock)) + return -1; - wrb = wrb_from_mccq(adapter); - if (!wrb) { - status = -EBUSY; - goto err; - } + wrb = wrb_from_mbox(adapter); req = embedded_payload(wrb); be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0, @@ -1017,7 +1004,7 @@ int be_cmd_rxq_create(struct be_adapter *adapter, req->max_frame_size = cpu_to_le16(max_frame_size); req->rss_queue = cpu_to_le32(rss); - status = be_mcc_notify_wait(adapter); + status = be_mbox_notify_wait(adapter); if (!status) { struct be_cmd_resp_eth_rx_create *resp = embedded_payload(wrb); rxq->id = le16_to_cpu(resp->id); @@ -1025,8 +1012,8 @@ int be_cmd_rxq_create(struct be_adapter *adapter, *rss_id = resp->rss_id; } -err: - spin_unlock_bh(&adapter->mcc_lock); + mutex_unlock(&adapter->mbox_lock); + return status; } @@ -1081,40 +1068,9 @@ int be_cmd_q_destroy(struct be_adapter *adapter, struct be_queue_info *q, req->id = cpu_to_le16(q->id); status = be_mbox_notify_wait(adapter); - if (!status) - q->created = false; mutex_unlock(&adapter->mbox_lock); - return status; -} -/* Uses MCC */ -int be_cmd_rxq_destroy(struct be_adapter *adapter, struct be_queue_info *q) -{ - struct be_mcc_wrb *wrb; - struct be_cmd_req_q_destroy *req; - int status; - - spin_lock_bh(&adapter->mcc_lock); - - wrb = wrb_from_mccq(adapter); - if (!wrb) { - status = -EBUSY; - goto err; - } - req = embedded_payload(wrb); - - be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0, OPCODE_ETH_RX_DESTROY); - be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ETH, OPCODE_ETH_RX_DESTROY, - sizeof(*req)); - req->id = cpu_to_le16(q->id); - - status = be_mcc_notify_wait(adapter); - if (!status) - q->created = false; - -err: - spin_unlock_bh(&adapter->mcc_lock); return status; } diff --git a/trunk/drivers/net/benet/be_cmds.h b/trunk/drivers/net/benet/be_cmds.h index 1151df6b0020..d08289e21f61 100644 --- a/trunk/drivers/net/benet/be_cmds.h +++ b/trunk/drivers/net/benet/be_cmds.h @@ -51,12 +51,17 @@ struct be_mcc_wrb { /* Completion Status */ enum { - MCC_STATUS_SUCCESS = 0, - MCC_STATUS_FAILED = 1, - MCC_STATUS_ILLEGAL_REQUEST = 2, - MCC_STATUS_ILLEGAL_FIELD = 3, - MCC_STATUS_INSUFFICIENT_BUFFER = 4, - MCC_STATUS_UNAUTHORIZED_REQUEST = 5, + MCC_STATUS_SUCCESS = 0x0, +/* The client does not have sufficient privileges to execute the command */ + MCC_STATUS_INSUFFICIENT_PRIVILEGES = 0x1, +/* A parameter in the command was invalid. */ + MCC_STATUS_INVALID_PARAMETER = 0x2, +/* There are insufficient chip resources to execute the command */ + MCC_STATUS_INSUFFICIENT_RESOURCES = 0x3, +/* The command is completing because the queue was getting flushed */ + MCC_STATUS_QUEUE_FLUSHING = 0x4, +/* The command is completing with a DMA error */ + MCC_STATUS_DMA_FAILED = 0x5, MCC_STATUS_NOT_SUPPORTED = 66 }; @@ -1482,8 +1487,6 @@ extern int be_cmd_rxq_create(struct be_adapter *adapter, u32 rss, u8 *rss_id); extern int be_cmd_q_destroy(struct be_adapter *adapter, struct be_queue_info *q, int type); -extern int be_cmd_rxq_destroy(struct be_adapter *adapter, - struct be_queue_info *q); extern int be_cmd_link_status_query(struct be_adapter *adapter, bool *link_up, u8 *mac_speed, u16 *link_speed, u32 dom); extern int be_cmd_reset(struct be_adapter *adapter); diff --git a/trunk/drivers/net/benet/be_ethtool.c b/trunk/drivers/net/benet/be_ethtool.c index 7fd8130d86ea..30c1386027f8 100644 --- a/trunk/drivers/net/benet/be_ethtool.c +++ b/trunk/drivers/net/benet/be_ethtool.c @@ -102,7 +102,6 @@ static const struct be_ethtool_stat et_rx_stats[] = { {DRVSTAT_RX_INFO(rx_compl)}, {DRVSTAT_RX_INFO(rx_mcast_pkts)}, {DRVSTAT_RX_INFO(rx_post_fail)}, - {DRVSTAT_RX_INFO(rx_dropped)}, {ERXSTAT_INFO(rx_drops_no_fragments)} }; #define ETHTOOL_RXSTATS_NUM (ARRAY_SIZE(et_rx_stats)) diff --git a/trunk/drivers/net/benet/be_main.c b/trunk/drivers/net/benet/be_main.c index ae2d2622a18e..c4f564cd745b 100644 --- a/trunk/drivers/net/benet/be_main.c +++ b/trunk/drivers/net/benet/be_main.c @@ -33,6 +33,10 @@ module_param(num_vfs, uint, S_IRUGO); MODULE_PARM_DESC(rx_frag_size, "Size of a fragment that holds rcvd data."); MODULE_PARM_DESC(num_vfs, "Number of PCI VFs to initialize"); +static bool multi_rxq = true; +module_param(multi_rxq, bool, S_IRUGO | S_IWUSR); +MODULE_PARM_DESC(multi_rxq, "Multi Rx Queue support. Enabled by default"); + static DEFINE_PCI_DEVICE_TABLE(be_dev_ids) = { { PCI_DEVICE(BE_VENDOR_ID, BE_DEVICE_ID1) }, { PCI_DEVICE(BE_VENDOR_ID, BE_DEVICE_ID2) }, @@ -44,7 +48,7 @@ static DEFINE_PCI_DEVICE_TABLE(be_dev_ids) = { }; MODULE_DEVICE_TABLE(pci, be_dev_ids); /* UE Status Low CSR */ -static const char * const ue_status_low_desc[] = { +static char *ue_status_low_desc[] = { "CEV", "CTX", "DBUF", @@ -79,7 +83,7 @@ static const char * const ue_status_low_desc[] = { "MPU_INTPEND" }; /* UE Status High CSR */ -static const char * const ue_status_hi_desc[] = { +static char *ue_status_hi_desc[] = { "LPCMEMHOST", "MGMT_MAC", "PCS0ONLINE", @@ -103,7 +107,7 @@ static const char * const ue_status_hi_desc[] = { "HOST7", "HOST8", "HOST9", - "NETC", + "NETC" "Unknown", "Unknown", "Unknown", @@ -424,39 +428,33 @@ void netdev_stats_update(struct be_adapter *adapter) struct net_device_stats *dev_stats = &adapter->netdev->stats; struct be_rx_obj *rxo; struct be_tx_obj *txo; - unsigned long pkts = 0, bytes = 0, mcast = 0, drops = 0; int i; + memset(dev_stats, 0, sizeof(*dev_stats)); for_all_rx_queues(adapter, rxo, i) { - pkts += rx_stats(rxo)->rx_pkts; - bytes += rx_stats(rxo)->rx_bytes; - mcast += rx_stats(rxo)->rx_mcast_pkts; - drops += rx_stats(rxo)->rx_dropped; + dev_stats->rx_packets += rx_stats(rxo)->rx_pkts; + dev_stats->rx_bytes += rx_stats(rxo)->rx_bytes; + dev_stats->multicast += rx_stats(rxo)->rx_mcast_pkts; /* no space in linux buffers: best possible approximation */ if (adapter->generation == BE_GEN3) { if (!(lancer_chip(adapter))) { - struct be_erx_stats_v1 *erx = + struct be_erx_stats_v1 *erx_stats = be_erx_stats_from_cmd(adapter); - drops += erx->rx_drops_no_fragments[rxo->q.id]; + dev_stats->rx_dropped += + erx_stats->rx_drops_no_fragments[rxo->q.id]; } } else { - struct be_erx_stats_v0 *erx = + struct be_erx_stats_v0 *erx_stats = be_erx_stats_from_cmd(adapter); - drops += erx->rx_drops_no_fragments[rxo->q.id]; + dev_stats->rx_dropped += + erx_stats->rx_drops_no_fragments[rxo->q.id]; } } - dev_stats->rx_packets = pkts; - dev_stats->rx_bytes = bytes; - dev_stats->multicast = mcast; - dev_stats->rx_dropped = drops; - pkts = bytes = 0; for_all_tx_queues(adapter, txo, i) { - pkts += tx_stats(txo)->be_tx_pkts; - bytes += tx_stats(txo)->be_tx_bytes; + dev_stats->tx_packets += tx_stats(txo)->be_tx_pkts; + dev_stats->tx_bytes += tx_stats(txo)->be_tx_bytes; } - dev_stats->tx_packets = pkts; - dev_stats->tx_bytes = bytes; /* bad pkts received */ dev_stats->rx_errors = drvs->rx_crc_errors + @@ -654,7 +652,7 @@ static void wrb_fill_hdr(struct be_adapter *adapter, struct be_eth_hdr_wrb *hdr, AMAP_SET_BITS(struct amap_eth_hdr_wrb, udpcs, hdr, 1); } - if (vlan_tx_tag_present(skb)) { + if (adapter->vlan_grp && vlan_tx_tag_present(skb)) { AMAP_SET_BITS(struct amap_eth_hdr_wrb, vlan, hdr, 1); vlan_tag = vlan_tx_tag_get(skb); vlan_prio = (vlan_tag & VLAN_PRIO_MASK) >> VLAN_PRIO_SHIFT; @@ -847,6 +845,13 @@ static int be_vid_config(struct be_adapter *adapter, bool vf, u32 vf_num) return status; } +static void be_vlan_register(struct net_device *netdev, struct vlan_group *grp) +{ + struct be_adapter *adapter = netdev_priv(netdev); + + adapter->vlan_grp = grp; +} + static void be_vlan_add_vid(struct net_device *netdev, u16 vid) { struct be_adapter *adapter = netdev_priv(netdev); @@ -865,6 +870,7 @@ static void be_vlan_rem_vid(struct net_device *netdev, u16 vid) struct be_adapter *adapter = netdev_priv(netdev); adapter->vlans_added--; + vlan_group_set_device(adapter->vlan_grp, vid, NULL); if (!be_physfn(adapter)) return; @@ -1174,7 +1180,8 @@ static void be_rx_compl_process(struct be_adapter *adapter, skb = netdev_alloc_skb_ip_align(netdev, BE_HDR_LEN); if (unlikely(!skb)) { - rxo->stats.rx_dropped++; + if (net_ratelimit()) + dev_warn(&adapter->pdev->dev, "skb alloc failed\n"); be_rx_compl_discard(adapter, rxo, rxcp); return; } @@ -1192,10 +1199,16 @@ static void be_rx_compl_process(struct be_adapter *adapter, skb->rxhash = rxcp->rss_hash; - if (unlikely(rxcp->vlanf)) - __vlan_hwaccel_put_tag(skb, rxcp->vlan_tag); - - netif_receive_skb(skb); + if (unlikely(rxcp->vlanf)) { + if (!adapter->vlan_grp || adapter->vlans_added == 0) { + kfree_skb(skb); + return; + } + vlan_hwaccel_receive_skb(skb, adapter->vlan_grp, + rxcp->vlan_tag); + } else { + netif_receive_skb(skb); + } } /* Process the RX completion indicated by rxcp when GRO is enabled */ @@ -1249,10 +1262,11 @@ static void be_rx_compl_process_gro(struct be_adapter *adapter, if (adapter->netdev->features & NETIF_F_RXHASH) skb->rxhash = rxcp->rss_hash; - if (unlikely(rxcp->vlanf)) - __vlan_hwaccel_put_tag(skb, rxcp->vlan_tag); - - napi_gro_frags(&eq_obj->napi); + if (likely(!rxcp->vlanf)) + napi_gro_frags(&eq_obj->napi); + else + vlan_gro_frags(&eq_obj->napi, adapter->vlan_grp, + rxcp->vlan_tag); } static void be_parse_rx_compl_v1(struct be_adapter *adapter, @@ -1557,7 +1571,6 @@ static void be_rx_q_clean(struct be_adapter *adapter, struct be_rx_obj *rxo) memset(page_info, 0, sizeof(*page_info)); } BUG_ON(atomic_read(&rxq->used)); - rxq->tail = rxq->head = 0; } static void be_tx_compl_clean(struct be_adapter *adapter, @@ -1738,23 +1751,36 @@ static void be_rx_queues_destroy(struct be_adapter *adapter) int i; for_all_rx_queues(adapter, rxo, i) { - be_queue_free(adapter, &rxo->q); + q = &rxo->q; + if (q->created) { + be_cmd_q_destroy(adapter, q, QTYPE_RXQ); + /* After the rxq is invalidated, wait for a grace time + * of 1ms for all dma to end and the flush compl to + * arrive + */ + mdelay(1); + be_rx_q_clean(adapter, rxo); + } + be_queue_free(adapter, q); q = &rxo->cq; if (q->created) be_cmd_q_destroy(adapter, q, QTYPE_CQ); be_queue_free(adapter, q); + /* Clear any residual events */ q = &rxo->rx_eq.q; - if (q->created) + if (q->created) { + be_eq_clean(adapter, &rxo->rx_eq); be_cmd_q_destroy(adapter, q, QTYPE_EQ); + } be_queue_free(adapter, q); } } static u32 be_num_rxqs_want(struct be_adapter *adapter) { - if ((adapter->function_caps & BE_FUNCTION_CAPS_RSS) && + if (multi_rxq && (adapter->function_caps & BE_FUNCTION_CAPS_RSS) && !adapter->sriov_enabled && !(adapter->function_mode & 0x400)) { return 1 + MAX_RSS_QS; /* one default non-RSS queue */ } else { @@ -1806,14 +1832,30 @@ static int be_rx_queues_create(struct be_adapter *adapter) rc = be_cmd_cq_create(adapter, cq, eq, false, false, 3); if (rc) goto err; - - /* Rx Q - will be created in be_open() */ + /* Rx Q */ q = &rxo->q; rc = be_queue_alloc(adapter, q, RX_Q_LEN, sizeof(struct be_eth_rx_d)); if (rc) goto err; + rc = be_cmd_rxq_create(adapter, q, cq->id, rx_frag_size, + BE_MAX_JUMBO_FRAME_SIZE, adapter->if_handle, + (i > 0) ? 1 : 0/* rss enable */, &rxo->rss_id); + if (rc) + goto err; + } + + if (be_multi_rxq(adapter)) { + u8 rsstable[MAX_RSS_QS]; + + for_all_rss_queues(adapter, rxo, i) + rsstable[i] = rxo->rss_id; + + rc = be_cmd_rss_config(adapter, rsstable, + adapter->num_rx_qs - 1); + if (rc) + goto err; } return 0; @@ -2259,31 +2301,6 @@ static void be_irq_unregister(struct be_adapter *adapter) adapter->isr_registered = false; } -static void be_rx_queues_clear(struct be_adapter *adapter) -{ - struct be_queue_info *q; - struct be_rx_obj *rxo; - int i; - - for_all_rx_queues(adapter, rxo, i) { - q = &rxo->q; - if (q->created) { - be_cmd_rxq_destroy(adapter, q); - /* After the rxq is invalidated, wait for a grace time - * of 1ms for all dma to end and the flush compl to - * arrive - */ - mdelay(1); - be_rx_q_clean(adapter, rxo); - } - - /* Clear any residual events */ - q = &rxo->rx_eq.q; - if (q->created) - be_eq_clean(adapter, &rxo->rx_eq); - } -} - static int be_close(struct net_device *netdev) { struct be_adapter *adapter = netdev_priv(netdev); @@ -2332,40 +2349,6 @@ static int be_close(struct net_device *netdev) for_all_tx_queues(adapter, txo, i) be_tx_compl_clean(adapter, txo); - be_rx_queues_clear(adapter); - return 0; -} - -static int be_rx_queues_setup(struct be_adapter *adapter) -{ - struct be_rx_obj *rxo; - int rc, i; - u8 rsstable[MAX_RSS_QS]; - - for_all_rx_queues(adapter, rxo, i) { - rc = be_cmd_rxq_create(adapter, &rxo->q, rxo->cq.id, - rx_frag_size, BE_MAX_JUMBO_FRAME_SIZE, - adapter->if_handle, - (i > 0) ? 1 : 0/* rss enable */, &rxo->rss_id); - if (rc) - return rc; - } - - if (be_multi_rxq(adapter)) { - for_all_rss_queues(adapter, rxo, i) - rsstable[i] = rxo->rss_id; - - rc = be_cmd_rss_config(adapter, rsstable, - adapter->num_rx_qs - 1); - if (rc) - return rc; - } - - /* First time posting */ - for_all_rx_queues(adapter, rxo, i) { - be_post_rx_frags(rxo, GFP_KERNEL); - napi_enable(&rxo->rx_eq.napi); - } return 0; } @@ -2379,10 +2362,10 @@ static int be_open(struct net_device *netdev) u8 mac_speed; u16 link_speed; - status = be_rx_queues_setup(adapter); - if (status) - goto err; - + for_all_rx_queues(adapter, rxo, i) { + be_post_rx_frags(rxo, GFP_KERNEL); + napi_enable(&rxo->rx_eq.napi); + } napi_enable(&tx_eq->napi); be_irq_register(adapter); @@ -2570,9 +2553,6 @@ static int be_setup(struct be_adapter *adapter) if (status != 0) goto tx_qs_destroy; - /* Allow all priorities by default. A GRP5 evt may modify this */ - adapter->vlan_prio_bmap = 0xff; - status = be_mcc_queues_create(adapter); if (status != 0) goto rx_qs_destroy; @@ -2935,6 +2915,7 @@ static struct net_device_ops be_netdev_ops = { .ndo_set_mac_address = be_mac_addr_set, .ndo_change_mtu = be_change_mtu, .ndo_validate_addr = eth_validate_addr, + .ndo_vlan_rx_register = be_vlan_register, .ndo_vlan_rx_add_vid = be_vlan_add_vid, .ndo_vlan_rx_kill_vid = be_vlan_rem_vid, .ndo_set_vf_mac = be_set_vf_mac, @@ -3401,12 +3382,6 @@ static int __devinit be_probe(struct pci_dev *pdev, if (status) goto stats_clean; - /* The INTR bit may be set in the card when probed by a kdump kernel - * after a crash. - */ - if (!lancer_chip(adapter)) - be_intr_set(adapter, false); - be_msix_enable(adapter); INIT_DELAYED_WORK(&adapter->work, be_worker); @@ -3443,6 +3418,10 @@ static int __devinit be_probe(struct pci_dev *pdev, } dev_info(&pdev->dev, "%s port %d\n", nic_name(pdev), adapter->port_num); + /* By default all priorities are enabled. + * Needed in case of no GRP5 evt support + */ + adapter->vlan_prio_bmap = 0xff; schedule_delayed_work(&adapter->work, msecs_to_jiffies(100)); return 0; diff --git a/trunk/drivers/net/bmac.c b/trunk/drivers/net/bmac.c index 45e45e8d3d66..d2e58e2bea78 100644 --- a/trunk/drivers/net/bmac.c +++ b/trunk/drivers/net/bmac.c @@ -1015,6 +1015,7 @@ static void bmac_set_multicast(struct net_device *dev) static void bmac_set_multicast(struct net_device *dev) { struct netdev_hw_addr *ha; + char *addrs; int i; unsigned short rx_cfg; u32 crc; @@ -1038,7 +1039,12 @@ static void bmac_set_multicast(struct net_device *dev) for(i = 0; i < 4; i++) hash_table[i] = 0; netdev_for_each_mc_addr(ha, dev) { - crc = ether_crc_le(6, ha->addr); + addrs = ha->addr; + + if(!(*addrs & 1)) + continue; + + crc = ether_crc_le(6, addrs); crc >>= 26; hash_table[crc >> 4] |= 1 << (crc & 0xf); } diff --git a/trunk/drivers/net/bna/bnad.c b/trunk/drivers/net/bna/bnad.c index 795b93b73b12..7d25a97d33f6 100644 --- a/trunk/drivers/net/bna/bnad.c +++ b/trunk/drivers/net/bna/bnad.c @@ -386,12 +386,14 @@ bnad_alloc_n_post_rxbufs(struct bnad *bnad, struct bna_rcb *rcb) BNA_RXQ_QPGE_PTR_GET(unmap_prod, rcb->sw_qpt, rxent, wi_range); } - skb = netdev_alloc_skb_ip_align(bnad->netdev, - rcb->rxq->buffer_size); + skb = alloc_skb(rcb->rxq->buffer_size + NET_IP_ALIGN, + GFP_ATOMIC); if (unlikely(!skb)) { BNAD_UPDATE_CTR(bnad, rxbuf_alloc_failed); goto finishing; } + skb->dev = bnad->netdev; + skb_reserve(skb, NET_IP_ALIGN); unmap_array[unmap_prod].skb = skb; dma_addr = dma_map_single(&bnad->pcidev->dev, skb->data, rcb->rxq->buffer_size, @@ -1109,7 +1111,7 @@ bnad_mbox_irq_alloc(struct bnad *bnad, struct bna_intr_info *intr_info) { int err = 0; - unsigned long irq_flags = 0, flags; + unsigned long flags; u32 irq; irq_handler_t irq_handler; @@ -1123,17 +1125,18 @@ bnad_mbox_irq_alloc(struct bnad *bnad, if (bnad->cfg_flags & BNAD_CF_MSIX) { irq_handler = (irq_handler_t)bnad_msix_mbox_handler; irq = bnad->msix_table[bnad->msix_num - 1].vector; + flags = 0; intr_info->intr_type = BNA_INTR_T_MSIX; intr_info->idl[0].vector = bnad->msix_num - 1; } else { irq_handler = (irq_handler_t)bnad_isr; irq = bnad->pcidev->irq; - irq_flags = IRQF_SHARED; + flags = IRQF_SHARED; intr_info->intr_type = BNA_INTR_T_INTX; /* intr_info->idl.vector = 0 ? */ } spin_unlock_irqrestore(&bnad->bna_lock, flags); - flags = irq_flags; + sprintf(bnad->mbox_irq_name, "%s", BNAD_NAME); /* diff --git a/trunk/drivers/net/bna/cna.h b/trunk/drivers/net/bna/cna.h index 01b4af733021..3c47dc52b423 100644 --- a/trunk/drivers/net/bna/cna.h +++ b/trunk/drivers/net/bna/cna.h @@ -19,6 +19,7 @@ #ifndef __CNA_H__ #define __CNA_H__ +#include #include #include #include diff --git a/trunk/drivers/net/bnx2.c b/trunk/drivers/net/bnx2.c index 7915d1404572..74580bb175f1 100644 --- a/trunk/drivers/net/bnx2.c +++ b/trunk/drivers/net/bnx2.c @@ -7911,8 +7911,9 @@ bnx2_init_board(struct pci_dev *pdev, struct net_device *dev) bp->chip_id = REG_RD(bp, BNX2_MISC_ID); if (CHIP_NUM(bp) == CHIP_NUM_5709) { - if (!pci_is_pcie(pdev)) { - dev_err(&pdev->dev, "Not PCIE, aborting\n"); + if (pci_find_capability(pdev, PCI_CAP_ID_EXP) == 0) { + dev_err(&pdev->dev, + "Cannot find PCIE capability, aborting\n"); rc = -EIO; goto err_out_unmap; } diff --git a/trunk/drivers/net/bnx2x/bnx2x.h b/trunk/drivers/net/bnx2x/bnx2x.h index 0d4b98126241..eff78a439eeb 100644 --- a/trunk/drivers/net/bnx2x/bnx2x.h +++ b/trunk/drivers/net/bnx2x/bnx2x.h @@ -1156,6 +1156,7 @@ struct bnx2x { #define NO_FCOE(bp) ((bp)->flags & NO_FCOE_FLAG) int pm_cap; + int pcie_cap; int mrrs; struct delayed_work sp_task; diff --git a/trunk/drivers/net/bnx2x/bnx2x_dcb.c b/trunk/drivers/net/bnx2x/bnx2x_dcb.c index 45cf3ceef144..b51a759c1036 100644 --- a/trunk/drivers/net/bnx2x/bnx2x_dcb.c +++ b/trunk/drivers/net/bnx2x/bnx2x_dcb.c @@ -19,14 +19,14 @@ #include #include #include +#ifdef BCM_DCBNL +#include +#endif #include "bnx2x.h" #include "bnx2x_cmn.h" #include "bnx2x_dcb.h" -#ifdef BCM_DCBNL -#include -#endif /* forward declarations of dcbx related functions */ static void bnx2x_dcbx_stop_hw_tx(struct bnx2x *bp); @@ -702,12 +702,6 @@ void bnx2x_dcbx_set_params(struct bnx2x *bp, u32 state) case BNX2X_DCBX_STATE_TX_RELEASED: DP(NETIF_MSG_LINK, "BNX2X_DCBX_STATE_TX_RELEASED\n"); bnx2x_fw_command(bp, DRV_MSG_CODE_DCBX_PMF_DRV_OK, 0); -#ifdef BCM_DCBNL - /** - * Send a notification for the new negotiated parameters - */ - dcbnl_cee_notify(bp->dev, RTM_GETDCB, DCB_CMD_CEE_GET, 0, 0); -#endif return; default: BNX2X_ERR("Unknown DCBX_STATE\n"); diff --git a/trunk/drivers/net/bnx2x/bnx2x_hsi.h b/trunk/drivers/net/bnx2x/bnx2x_hsi.h index 0692d75756df..df5355818c30 100644 --- a/trunk/drivers/net/bnx2x/bnx2x_hsi.h +++ b/trunk/drivers/net/bnx2x/bnx2x_hsi.h @@ -538,13 +538,7 @@ struct port_hw_cfg { /* port 0: 0x12c port 1: 0x2bc */ u32 fcoe_wwn_node_name_upper; u32 fcoe_wwn_node_name_lower; - u32 Reserved1[49]; /* 0x1C0 */ - - /* Enable RJ45 magjack pair swapping on 10GBase-T PHY (0=default), - 84833 only */ - u32 xgbt_phy_cfg; /* 0x284 */ - #define PORT_HW_CFG_RJ45_PAIR_SWAP_MASK 0x000000FF - #define PORT_HW_CFG_RJ45_PAIR_SWAP_SHIFT 0 + u32 Reserved1[50]; /* 0x1C0 */ u32 default_cfg; /* 0x288 */ #define PORT_HW_CFG_GPIO0_CONFIG_MASK 0x00000003 @@ -702,7 +696,7 @@ struct port_hw_cfg { /* port 0: 0x12c port 1: 0x2bc */ #define PORT_HW_CFG_XGXS_EXT_PHY2_TYPE_BCM84823 0x00000b00 #define PORT_HW_CFG_XGXS_EXT_PHY2_TYPE_BCM54640 0x00000c00 #define PORT_HW_CFG_XGXS_EXT_PHY2_TYPE_BCM84833 0x00000d00 - #define PORT_HW_CFG_XGXS_EXT_PHY2_TYPE_BCM54618SE 0x00000e00 + #define PORT_HW_CFG_XGXS_EXT_PHY2_TYPE_BCM54616 0x00000e00 #define PORT_HW_CFG_XGXS_EXT_PHY2_TYPE_BCM8722 0x00000f00 #define PORT_HW_CFG_XGXS_EXT_PHY2_TYPE_FAILURE 0x0000fd00 #define PORT_HW_CFG_XGXS_EXT_PHY2_TYPE_NOT_CONN 0x0000ff00 @@ -757,7 +751,7 @@ struct port_hw_cfg { /* port 0: 0x12c port 1: 0x2bc */ #define PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84823 0x00000b00 #define PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM54640 0x00000c00 #define PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84833 0x00000d00 - #define PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM54618SE 0x00000e00 + #define PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM54616 0x00000e00 #define PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8722 0x00000f00 #define PORT_HW_CFG_XGXS_EXT_PHY_TYPE_DIRECT_WC 0x0000fc00 #define PORT_HW_CFG_XGXS_EXT_PHY_TYPE_FAILURE 0x0000fd00 @@ -1202,8 +1196,6 @@ struct drv_port_mb { #define LINK_STATUS_LINK_PARTNER_10GXFD_CAPABLE 0x00800000 #define LINK_STATUS_LINK_PARTNER_20GXFD_CAPABLE 0x10000000 - #define LINK_STATUS_PFC_ENABLED 0x20000000 - u32 port_stx; u32 stat_nig_timer; @@ -1242,7 +1234,6 @@ struct drv_func_mb { #define REQ_BC_VER_4_VRFY_FIRST_PHY_OPT_MDL 0x00050006 #define DRV_MSG_CODE_VRFY_SPECIFIC_PHY_OPT_MDL 0xa1000000 #define REQ_BC_VER_4_VRFY_SPECIFIC_PHY_OPT_MDL 0x00050234 - #define REQ_BC_VER_4_SFP_TX_DISABLE_SUPPORTED 0x00070014 #define DRV_MSG_CODE_DCBX_ADMIN_PMF_MSG 0xb0000000 #define DRV_MSG_CODE_DCBX_PMF_DRV_OK 0xb2000000 diff --git a/trunk/drivers/net/bnx2x/bnx2x_link.c b/trunk/drivers/net/bnx2x/bnx2x_link.c index bcd8f0038628..836363645daf 100644 --- a/trunk/drivers/net/bnx2x/bnx2x_link.c +++ b/trunk/drivers/net/bnx2x/bnx2x_link.c @@ -1344,21 +1344,28 @@ static void bnx2x_update_pfc_xmac(struct link_params *params, REG_WR(bp, xmac_base + XMAC_REG_PFC_CTRL, pfc0_val); REG_WR(bp, xmac_base + XMAC_REG_PFC_CTRL_HI, pfc1_val); - - /* Set MAC address for source TX Pause/PFC frames */ - REG_WR(bp, xmac_base + XMAC_REG_CTRL_SA_LO, - ((params->mac_addr[2] << 24) | - (params->mac_addr[3] << 16) | - (params->mac_addr[4] << 8) | - (params->mac_addr[5]))); - REG_WR(bp, xmac_base + XMAC_REG_CTRL_SA_HI, - ((params->mac_addr[0] << 8) | - (params->mac_addr[1]))); - udelay(30); } +static void bnx2x_bmac2_get_pfc_stat(struct link_params *params, + u32 pfc_frames_sent[2], + u32 pfc_frames_received[2]) +{ + /* Read pfc statistic */ + struct bnx2x *bp = params->bp; + u32 bmac_addr = params->port ? NIG_REG_INGRESS_BMAC1_MEM : + NIG_REG_INGRESS_BMAC0_MEM; + + DP(NETIF_MSG_LINK, "pfc statistic read from BMAC\n"); + + REG_RD_DMAE(bp, bmac_addr + BIGMAC2_REGISTER_TX_STAT_GTPP, + pfc_frames_sent, 2); + + REG_RD_DMAE(bp, bmac_addr + BIGMAC2_REGISTER_RX_STAT_GRPP, + pfc_frames_received, 2); + +} static void bnx2x_emac_get_pfc_stat(struct link_params *params, u32 pfc_frames_sent[2], u32 pfc_frames_received[2]) @@ -1390,23 +1397,28 @@ static void bnx2x_emac_get_pfc_stat(struct link_params *params, pfc_frames_sent[0] = val_xon + val_xoff; } -/* Read pfc statistic*/ void bnx2x_pfc_statistic(struct link_params *params, struct link_vars *vars, u32 pfc_frames_sent[2], u32 pfc_frames_received[2]) { /* Read pfc statistic */ struct bnx2x *bp = params->bp; - + u32 val = 0; DP(NETIF_MSG_LINK, "pfc statistic\n"); if (!vars->link_up) return; - if (MAC_TYPE_EMAC == vars->mac_type) { - DP(NETIF_MSG_LINK, "About to read PFC stats from EMAC\n"); + val = REG_RD(bp, MISC_REG_RESET_REG_2); + if ((val & (MISC_REGISTERS_RESET_REG_2_RST_BMAC0 << params->port)) + == 0) { + DP(NETIF_MSG_LINK, "About to read stats from EMAC\n"); bnx2x_emac_get_pfc_stat(params, pfc_frames_sent, pfc_frames_received); + } else { + DP(NETIF_MSG_LINK, "About to read stats from BMAC\n"); + bnx2x_bmac2_get_pfc_stat(params, pfc_frames_sent, + pfc_frames_received); } } /******************************************************************/ @@ -1549,16 +1561,6 @@ static void bnx2x_umac_enable(struct link_params *params, REG_WR(bp, umac_base + UMAC_REG_COMMAND_CONFIG, val); udelay(50); - /* Set MAC address for source TX Pause/PFC frames (under SW reset) */ - REG_WR(bp, umac_base + UMAC_REG_MAC_ADDR0, - ((params->mac_addr[2] << 24) | - (params->mac_addr[3] << 16) | - (params->mac_addr[4] << 8) | - (params->mac_addr[5]))); - REG_WR(bp, umac_base + UMAC_REG_MAC_ADDR1, - ((params->mac_addr[0] << 8) | - (params->mac_addr[1]))); - /* Enable RX and TX */ val &= ~UMAC_COMMAND_CONFIG_REG_PAD_EN; val |= UMAC_COMMAND_CONFIG_REG_TX_ENA | @@ -2356,15 +2358,6 @@ int bnx2x_pfc_nig_rx_priority_mask(struct bnx2x *bp, return 0; } -static void bnx2x_update_mng(struct link_params *params, u32 link_status) -{ - struct bnx2x *bp = params->bp; - - REG_WR(bp, params->shmem_base + - offsetof(struct shmem_region, - port_mb[params->port].link_status), link_status); -} - static void bnx2x_update_pfc_nig(struct link_params *params, struct link_vars *vars, struct bnx2x_nig_brb_pfc_port_params *nig_params) @@ -2474,14 +2467,6 @@ int bnx2x_update_pfc(struct link_params *params, struct bnx2x *bp = params->bp; int bnx2x_status = 0; u8 bmac_loopback = (params->loopback_mode == LOOPBACK_BMAC); - - if (params->feature_config_flags & FEATURE_CONFIG_PFC_ENABLED) - vars->link_status |= LINK_STATUS_PFC_ENABLED; - else - vars->link_status &= ~LINK_STATUS_PFC_ENABLED; - - bnx2x_update_mng(params, vars->link_status); - /* update NIG params */ bnx2x_update_pfc_nig(params, vars, pfc_params); @@ -2710,6 +2695,16 @@ static int bnx2x_bmac_enable(struct link_params *params, return rc; } + +static void bnx2x_update_mng(struct link_params *params, u32 link_status) +{ + struct bnx2x *bp = params->bp; + + REG_WR(bp, params->shmem_base + + offsetof(struct shmem_region, + port_mb[params->port].link_status), link_status); +} + static void bnx2x_bmac_rx_disable(struct bnx2x *bp, u8 port) { u32 bmac_addr = port ? NIG_REG_INGRESS_BMAC1_MEM : @@ -3530,7 +3525,7 @@ static u8 bnx2x_ext_phy_resolve_fc(struct bnx2x_phy *phy, vars->flow_ctrl = params->req_fc_auto_adv; else if (vars->link_status & LINK_STATUS_AUTO_NEGOTIATE_COMPLETE) { ret = 1; - if (phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM54618SE) { + if (phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM54616) { bnx2x_cl22_read(bp, phy, 0x4, &ld_pause); bnx2x_cl22_read(bp, phy, @@ -3564,7 +3559,7 @@ static u8 bnx2x_ext_phy_resolve_fc(struct bnx2x_phy *phy, static void bnx2x_warpcore_enable_AN_KR(struct bnx2x_phy *phy, struct link_params *params, struct link_vars *vars) { - u16 val16 = 0, lane, bam37 = 0; + u16 val16 = 0, lane; struct bnx2x *bp = params->bp; DP(NETIF_MSG_LINK, "Enable Auto Negotiation for KR\n"); /* Check adding advertisement for 1G KX */ @@ -3616,18 +3611,6 @@ static void bnx2x_warpcore_enable_AN_KR(struct bnx2x_phy *phy, bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, MDIO_WC_REG_AN_IEEE1BLK_AN_ADVERTISEMENT1, val16); - /* Enable CL37 BAM */ - if (REG_RD(bp, params->shmem_base + - offsetof(struct shmem_region, dev_info. - port_hw_config[params->port].default_cfg)) & - PORT_HW_CFG_ENABLE_BAM_ON_KR_ENABLED) { - bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, - MDIO_WC_REG_DIGITAL6_MP5_NEXTPAGECTRL, &bam37); - bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD, - MDIO_WC_REG_DIGITAL6_MP5_NEXTPAGECTRL, bam37 | 1); - DP(NETIF_MSG_LINK, "Enable CL37 BAM on KR\n"); - } - /* Advertise pause */ bnx2x_ext_phy_set_pause(params, phy, vars); @@ -4470,14 +4453,6 @@ void bnx2x_link_status_update(struct link_params *params, vars->aeu_int_mask = REG_RD(bp, sync_offset); - /* Sync PFC status */ - if (vars->link_status & LINK_STATUS_PFC_ENABLED) - params->feature_config_flags |= - FEATURE_CONFIG_PFC_ENABLED; - else - params->feature_config_flags &= - ~FEATURE_CONFIG_PFC_ENABLED; - DP(NETIF_MSG_LINK, "link_status 0x%x phy_link_up %x int_mask 0x%x\n", vars->link_status, vars->phy_link_up, vars->aeu_int_mask); DP(NETIF_MSG_LINK, "line_speed %x duplex %x flow_ctrl 0x%x\n", @@ -5561,7 +5536,7 @@ static u16 bnx2x_wait_reset_complete(struct bnx2x *bp, u16 cnt, ctrl; /* Wait for soft reset to get cleared up to 1 sec */ for (cnt = 0; cnt < 1000; cnt++) { - if (phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM54618SE) + if (phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM54616) bnx2x_cl22_read(bp, phy, MDIO_PMA_REG_CTRL, &ctrl); else @@ -7195,30 +7170,6 @@ static u8 bnx2x_8705_read_status(struct bnx2x_phy *phy, /******************************************************************/ /* SFP+ module Section */ /******************************************************************/ -static void bnx2x_set_disable_pmd_transmit(struct link_params *params, - struct bnx2x_phy *phy, - u8 pmd_dis) -{ - struct bnx2x *bp = params->bp; - /* - * Disable transmitter only for bootcodes which can enable it afterwards - * (for D3 link) - */ - if (pmd_dis) { - if (params->feature_config_flags & - FEATURE_CONFIG_BC_SUPPORTS_SFP_TX_DISABLED) - DP(NETIF_MSG_LINK, "Disabling PMD transmitter\n"); - else { - DP(NETIF_MSG_LINK, "NOT disabling PMD transmitter\n"); - return; - } - } else - DP(NETIF_MSG_LINK, "Enabling PMD transmitter\n"); - bnx2x_cl45_write(bp, phy, - MDIO_PMA_DEVAD, - MDIO_PMA_REG_TX_DISABLE, pmd_dis); -} - static u8 bnx2x_get_gpio_port(struct link_params *params) { u8 gpio_port; @@ -7928,9 +7879,6 @@ static void bnx2x_warpcore_power_module(struct link_params *params, dev_info.port_hw_config[params->port].e3_sfp_ctrl)) & PORT_HW_CFG_E3_PWR_DIS_MASK) >> PORT_HW_CFG_E3_PWR_DIS_SHIFT; - - if (pin_cfg == PIN_CFG_NA) - return; DP(NETIF_MSG_LINK, "Setting SFP+ module power to %d using pin cfg %d\n", power, pin_cfg); /* @@ -7940,12 +7888,6 @@ static void bnx2x_warpcore_power_module(struct link_params *params, bnx2x_set_cfg_pin(bp, pin_cfg, power ^ 1); } -static void bnx2x_warpcore_hw_reset(struct bnx2x_phy *phy, - struct link_params *params) -{ - bnx2x_warpcore_power_module(params, phy, 0); -} - static void bnx2x_power_sfp_module(struct link_params *params, struct bnx2x_phy *phy, u8 power) @@ -8622,9 +8564,6 @@ static int bnx2x_8727_config_init(struct bnx2x_phy *phy, MDIO_PMA_DEVAD, MDIO_PMA_REG_PHY_IDENTIFIER, mod_abs); - /* Enable/Disable PHY transmitter output */ - bnx2x_set_disable_pmd_transmit(params, phy, 0); - /* Make MOD_ABS give interrupt on change */ bnx2x_cl45_read(bp, phy, MDIO_PMA_DEVAD, MDIO_PMA_REG_8727_PCS_OPT_CTRL, &val); @@ -8999,10 +8938,6 @@ static void bnx2x_8727_link_reset(struct bnx2x_phy *phy, struct link_params *params) { struct bnx2x *bp = params->bp; - - /* Enable/Disable PHY transmitter output */ - bnx2x_set_disable_pmd_transmit(params, phy, 1); - /* Disable Transmitter */ bnx2x_sfp_set_transmitter(params, phy, 0); /* Clear LASI */ @@ -9182,14 +9117,11 @@ static int bnx2x_848xx_cmn_config_init(struct bnx2x_phy *phy, MDIO_AN_DEVAD, MDIO_AN_REG_8481_1000T_CTRL, an_1000_val); - /* set 100 speed advertisement */ + /* set 10 speed advertisement */ if (((phy->req_line_speed == SPEED_AUTO_NEG) && (phy->speed_cap_mask & - (PORT_HW_CFG_SPEED_CAPABILITY_D0_100M_FULL | - PORT_HW_CFG_SPEED_CAPABILITY_D0_100M_HALF)) && - (phy->supported & - (SUPPORTED_100baseT_Half | - SUPPORTED_100baseT_Full)))) { + (PORT_HW_CFG_SPEED_CAPABILITY_D0_100M_FULL | + PORT_HW_CFG_SPEED_CAPABILITY_D0_100M_HALF)))) { an_10_100_val |= (1<<7); /* Enable autoneg and restart autoneg for legacy speeds */ autoneg_val |= (1<<9 | 1<<12); @@ -9200,12 +9132,9 @@ static int bnx2x_848xx_cmn_config_init(struct bnx2x_phy *phy, } /* set 10 speed advertisement */ if (((phy->req_line_speed == SPEED_AUTO_NEG) && - (phy->speed_cap_mask & - (PORT_HW_CFG_SPEED_CAPABILITY_D0_10M_FULL | - PORT_HW_CFG_SPEED_CAPABILITY_D0_10M_HALF)) && - (phy->supported & - (SUPPORTED_10baseT_Half | - SUPPORTED_10baseT_Full)))) { + (phy->speed_cap_mask & + (PORT_HW_CFG_SPEED_CAPABILITY_D0_10M_FULL | + PORT_HW_CFG_SPEED_CAPABILITY_D0_10M_HALF)))) { an_10_100_val |= (1<<5); autoneg_val |= (1<<9 | 1<<12); if (phy->req_duplex == DUPLEX_FULL) @@ -9214,10 +9143,7 @@ static int bnx2x_848xx_cmn_config_init(struct bnx2x_phy *phy, } /* Only 10/100 are allowed to work in FORCE mode */ - if ((phy->req_line_speed == SPEED_100) && - (phy->supported & - (SUPPORTED_100baseT_Half | - SUPPORTED_100baseT_Full))) { + if (phy->req_line_speed == SPEED_100) { autoneg_val |= (1<<13); /* Enabled AUTO-MDIX when autoneg is disabled */ bnx2x_cl45_write(bp, phy, @@ -9225,10 +9151,7 @@ static int bnx2x_848xx_cmn_config_init(struct bnx2x_phy *phy, (1<<15 | 1<<9 | 7<<0)); DP(NETIF_MSG_LINK, "Setting 100M force\n"); } - if ((phy->req_line_speed == SPEED_10) && - (phy->supported & - (SUPPORTED_10baseT_Half | - SUPPORTED_10baseT_Full))) { + if (phy->req_line_speed == SPEED_10) { /* Enabled AUTO-MDIX when autoneg is disabled */ bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, MDIO_AN_REG_8481_AUX_CTRL, @@ -9296,22 +9219,11 @@ static int bnx2x_84833_pair_swap_cfg(struct bnx2x_phy *phy, struct link_vars *vars) { u32 idx; - u32 pair_swap; u16 val; - u16 data; + u16 data = 0x01b1; struct bnx2x *bp = params->bp; /* Do pair swap */ - /* Check for configuration. */ - pair_swap = REG_RD(bp, params->shmem_base + - offsetof(struct shmem_region, - dev_info.port_hw_config[params->port].xgbt_phy_cfg)) & - PORT_HW_CFG_RJ45_PAIR_SWAP_MASK; - - if (pair_swap == 0) - return 0; - - data = (u16)pair_swap; /* Write CMD_OPEN_OVERRIDE to STATUS reg */ bnx2x_cl45_write(bp, phy, MDIO_CTL_DEVAD, @@ -9357,9 +9269,9 @@ static int bnx2x_84833_pair_swap_cfg(struct bnx2x_phy *phy, } -static u8 bnx2x_84833_get_reset_gpios(struct bnx2x *bp, - u32 shmem_base_path[], - u32 chip_id) +static int bnx2x_84833_common_init_phy(struct bnx2x *bp, + u32 shmem_base_path[], + u32 chip_id) { u32 reset_pin[2]; u32 idx; @@ -9392,41 +9304,6 @@ static u8 bnx2x_84833_get_reset_gpios(struct bnx2x *bp, reset_gpios = (u8)(reset_pin[0] | reset_pin[1]); } - return reset_gpios; -} - -static int bnx2x_84833_hw_reset_phy(struct bnx2x_phy *phy, - struct link_params *params) -{ - struct bnx2x *bp = params->bp; - u8 reset_gpios; - u32 other_shmem_base_addr = REG_RD(bp, params->shmem2_base + - offsetof(struct shmem2_region, - other_shmem_base_addr)); - - u32 shmem_base_path[2]; - shmem_base_path[0] = params->shmem_base; - shmem_base_path[1] = other_shmem_base_addr; - - reset_gpios = bnx2x_84833_get_reset_gpios(bp, shmem_base_path, - params->chip_id); - - bnx2x_set_mult_gpio(bp, reset_gpios, MISC_REGISTERS_GPIO_OUTPUT_LOW); - udelay(10); - DP(NETIF_MSG_LINK, "84833 hw reset on pin values 0x%x\n", - reset_gpios); - - return 0; -} - -static int bnx2x_84833_common_init_phy(struct bnx2x *bp, - u32 shmem_base_path[], - u32 chip_id) -{ - u8 reset_gpios; - - reset_gpios = bnx2x_84833_get_reset_gpios(bp, shmem_base_path, chip_id); - bnx2x_set_mult_gpio(bp, reset_gpios, MISC_REGISTERS_GPIO_OUTPUT_LOW); udelay(10); bnx2x_set_mult_gpio(bp, reset_gpios, MISC_REGISTERS_GPIO_OUTPUT_HIGH); @@ -9437,7 +9314,6 @@ static int bnx2x_84833_common_init_phy(struct bnx2x *bp, return 0; } -#define PHY84833_CONSTANT_LATENCY 1193 static int bnx2x_848x3_config_init(struct bnx2x_phy *phy, struct link_params *params, struct link_vars *vars) @@ -9446,7 +9322,7 @@ static int bnx2x_848x3_config_init(struct bnx2x_phy *phy, u8 port, initialize = 1; u16 val; u16 temp; - u32 actual_phy_selection, cms_enable, idx; + u32 actual_phy_selection, cms_enable; int rc = 0; msleep(1); @@ -9461,11 +9337,17 @@ static int bnx2x_848x3_config_init(struct bnx2x_phy *phy, MISC_REGISTERS_GPIO_OUTPUT_HIGH, port); } else { - /* MDIO reset */ bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, MDIO_PMA_REG_CTRL, 0x8000); - /* Bring PHY out of super isolate mode */ + } + + bnx2x_wait_reset_complete(bp, phy, params); + /* Wait for GPHY to come out of reset */ + msleep(50); + + /* Bring PHY out of super isolate mode */ + if (phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84833) { bnx2x_cl45_read(bp, phy, MDIO_CTL_DEVAD, MDIO_84833_TOP_CFG_XGPHY_STRAP1, &val); @@ -9473,13 +9355,9 @@ static int bnx2x_848x3_config_init(struct bnx2x_phy *phy, bnx2x_cl45_write(bp, phy, MDIO_CTL_DEVAD, MDIO_84833_TOP_CFG_XGPHY_STRAP1, val); + bnx2x_wait_reset_complete(bp, phy, params); } - bnx2x_wait_reset_complete(bp, phy, params); - - /* Wait for GPHY to come out of reset */ - msleep(50); - if (phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84833) bnx2x_84833_pair_swap_cfg(phy, params, vars); @@ -9538,86 +9416,24 @@ static int bnx2x_848x3_config_init(struct bnx2x_phy *phy, DP(NETIF_MSG_LINK, "Multi_phy config = 0x%x, Media control = 0x%x\n", params->multi_phy_config, val); - /* AutogrEEEn */ - if (params->feature_config_flags & - FEATURE_CONFIG_AUTOGREEEN_ENABLED) { - /* Ensure that f/w is ready */ - for (idx = 0; idx < PHY84833_HDSHK_WAIT; idx++) { - bnx2x_cl45_read(bp, phy, MDIO_CTL_DEVAD, - MDIO_84833_TOP_CFG_SCRATCH_REG2, &val); - if (val == PHY84833_CMD_OPEN_FOR_CMDS) - break; - usleep_range(1000, 1000); - } - if (idx >= PHY84833_HDSHK_WAIT) { - DP(NETIF_MSG_LINK, "AutogrEEEn: FW not ready.\n"); - return -EINVAL; - } - - /* Select EEE mode */ - bnx2x_cl45_write(bp, phy, MDIO_CTL_DEVAD, - MDIO_84833_TOP_CFG_SCRATCH_REG3, - 0x2); - - /* Set Idle and Latency */ - bnx2x_cl45_write(bp, phy, MDIO_CTL_DEVAD, - MDIO_84833_TOP_CFG_SCRATCH_REG4, - PHY84833_CONSTANT_LATENCY + 1); - - bnx2x_cl45_write(bp, phy, MDIO_CTL_DEVAD, - MDIO_84833_TOP_CFG_DATA3_REG, - PHY84833_CONSTANT_LATENCY + 1); - - bnx2x_cl45_write(bp, phy, MDIO_CTL_DEVAD, - MDIO_84833_TOP_CFG_DATA4_REG, - PHY84833_CONSTANT_LATENCY); - - /* Send EEE instruction to command register */ - bnx2x_cl45_write(bp, phy, MDIO_CTL_DEVAD, - MDIO_84833_TOP_CFG_SCRATCH_REG0, - PHY84833_DIAG_CMD_SET_EEE_MODE); - - /* Ensure that the command has completed */ - for (idx = 0; idx < PHY84833_HDSHK_WAIT; idx++) { - bnx2x_cl45_read(bp, phy, MDIO_CTL_DEVAD, - MDIO_84833_TOP_CFG_SCRATCH_REG2, &val); - if ((val == PHY84833_CMD_COMPLETE_PASS) || - (val == PHY84833_CMD_COMPLETE_ERROR)) - break; - usleep_range(1000, 1000); - } - if ((idx >= PHY84833_HDSHK_WAIT) || - (val == PHY84833_CMD_COMPLETE_ERROR)) { - DP(NETIF_MSG_LINK, "AutogrEEEn: command failed.\n"); - return -EINVAL; - } - - /* Reset command handler */ - bnx2x_cl45_write(bp, phy, MDIO_CTL_DEVAD, - MDIO_84833_TOP_CFG_SCRATCH_REG2, - PHY84833_CMD_CLEAR_COMPLETE); - } - if (initialize) rc = bnx2x_848xx_cmn_config_init(phy, params, vars); else bnx2x_save_848xx_spirom_version(phy, params); - /* 84833 PHY has a better feature and doesn't need to support this. */ - if (phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84823) { - cms_enable = REG_RD(bp, params->shmem_base + + cms_enable = REG_RD(bp, params->shmem_base + offsetof(struct shmem_region, dev_info.port_hw_config[params->port].default_cfg)) & PORT_HW_CFG_ENABLE_CMS_MASK; - bnx2x_cl45_read(bp, phy, MDIO_CTL_DEVAD, - MDIO_CTL_REG_84823_USER_CTRL_REG, &val); - if (cms_enable) - val |= MDIO_CTL_REG_84823_USER_CTRL_CMS; - else - val &= ~MDIO_CTL_REG_84823_USER_CTRL_CMS; - bnx2x_cl45_write(bp, phy, MDIO_CTL_DEVAD, - MDIO_CTL_REG_84823_USER_CTRL_REG, val); - } + bnx2x_cl45_read(bp, phy, MDIO_CTL_DEVAD, + MDIO_CTL_REG_84823_USER_CTRL_REG, &val); + if (cms_enable) + val |= MDIO_CTL_REG_84823_USER_CTRL_CMS; + else + val &= ~MDIO_CTL_REG_84823_USER_CTRL_CMS; + bnx2x_cl45_write(bp, phy, MDIO_CTL_DEVAD, + MDIO_CTL_REG_84823_USER_CTRL_REG, val); + return rc; } @@ -9971,9 +9787,9 @@ static void bnx2x_848xx_set_link_led(struct bnx2x_phy *phy, } /******************************************************************/ -/* 54618SE PHY SECTION */ +/* 54616S PHY SECTION */ /******************************************************************/ -static int bnx2x_54618se_config_init(struct bnx2x_phy *phy, +static int bnx2x_54616s_config_init(struct bnx2x_phy *phy, struct link_params *params, struct link_vars *vars) { @@ -9982,7 +9798,7 @@ static int bnx2x_54618se_config_init(struct bnx2x_phy *phy, u16 autoneg_val, an_1000_val, an_10_100_val, fc_val, temp; u32 cfg_pin; - DP(NETIF_MSG_LINK, "54618SE cfg init\n"); + DP(NETIF_MSG_LINK, "54616S cfg init\n"); usleep_range(1000, 1000); /* This works with E3 only, no need to check the chip @@ -10131,30 +9947,6 @@ static int bnx2x_54618se_config_init(struct bnx2x_phy *phy, DP(NETIF_MSG_LINK, "Setting 10M force\n"); } - /* Check if we should turn on Auto-GrEEEn */ - bnx2x_cl22_read(bp, phy, MDIO_REG_GPHY_PHYID_LSB, &temp); - if (temp == MDIO_REG_GPHY_ID_54618SE) { - if (params->feature_config_flags & - FEATURE_CONFIG_AUTOGREEEN_ENABLED) { - temp = 6; - DP(NETIF_MSG_LINK, "Enabling Auto-GrEEEn\n"); - } else { - temp = 0; - DP(NETIF_MSG_LINK, "Disabling Auto-GrEEEn\n"); - } - bnx2x_cl22_write(bp, phy, - MDIO_REG_GPHY_CL45_ADDR_REG, MDIO_AN_DEVAD); - bnx2x_cl22_write(bp, phy, - MDIO_REG_GPHY_CL45_DATA_REG, - MDIO_REG_GPHY_EEE_ADV); - bnx2x_cl22_write(bp, phy, - MDIO_REG_GPHY_CL45_ADDR_REG, - (0x1 << 14) | MDIO_AN_DEVAD); - bnx2x_cl22_write(bp, phy, - MDIO_REG_GPHY_CL45_DATA_REG, - temp); - } - bnx2x_cl22_write(bp, phy, 0x04, an_10_100_val | fc_val); @@ -10168,11 +9960,11 @@ static int bnx2x_54618se_config_init(struct bnx2x_phy *phy, return 0; } -static void bnx2x_54618se_set_link_led(struct bnx2x_phy *phy, - struct link_params *params, u8 mode) +static void bnx2x_54616s_set_link_led(struct bnx2x_phy *phy, + struct link_params *params, u8 mode) { struct bnx2x *bp = params->bp; - DP(NETIF_MSG_LINK, "54618SE set link led (mode=%x)\n", mode); + DP(NETIF_MSG_LINK, "54616S set link led (mode=%x)\n", mode); switch (mode) { case LED_MODE_FRONT_PANEL_OFF: case LED_MODE_OFF: @@ -10184,8 +9976,8 @@ static void bnx2x_54618se_set_link_led(struct bnx2x_phy *phy, return; } -static void bnx2x_54618se_link_reset(struct bnx2x_phy *phy, - struct link_params *params) +static void bnx2x_54616s_link_reset(struct bnx2x_phy *phy, + struct link_params *params) { struct bnx2x *bp = params->bp; u32 cfg_pin; @@ -10204,9 +9996,9 @@ static void bnx2x_54618se_link_reset(struct bnx2x_phy *phy, bnx2x_set_cfg_pin(bp, cfg_pin, 0); } -static u8 bnx2x_54618se_read_status(struct bnx2x_phy *phy, - struct link_params *params, - struct link_vars *vars) +static u8 bnx2x_54616s_read_status(struct bnx2x_phy *phy, + struct link_params *params, + struct link_vars *vars) { struct bnx2x *bp = params->bp; u16 val; @@ -10217,7 +10009,7 @@ static u8 bnx2x_54618se_read_status(struct bnx2x_phy *phy, bnx2x_cl22_read(bp, phy, 0x19, &legacy_status); - DP(NETIF_MSG_LINK, "54618SE read_status: 0x%x\n", legacy_status); + DP(NETIF_MSG_LINK, "54616S read_status: 0x%x\n", legacy_status); /* Read status to clear the PHY interrupt. */ bnx2x_cl22_read(bp, phy, @@ -10269,45 +10061,21 @@ static u8 bnx2x_54618se_read_status(struct bnx2x_phy *phy, vars->link_status |= LINK_STATUS_PARALLEL_DETECTION_USED; - DP(NETIF_MSG_LINK, "BCM54618SE: link speed is %d\n", + DP(NETIF_MSG_LINK, "BCM54616S: link speed is %d\n", vars->line_speed); - - /* Report whether EEE is resolved. */ - bnx2x_cl22_read(bp, phy, MDIO_REG_GPHY_PHYID_LSB, &val); - if (val == MDIO_REG_GPHY_ID_54618SE) { - if (vars->link_status & - LINK_STATUS_AUTO_NEGOTIATE_COMPLETE) - val = 0; - else { - bnx2x_cl22_write(bp, phy, - MDIO_REG_GPHY_CL45_ADDR_REG, - MDIO_AN_DEVAD); - bnx2x_cl22_write(bp, phy, - MDIO_REG_GPHY_CL45_DATA_REG, - MDIO_REG_GPHY_EEE_RESOLVED); - bnx2x_cl22_write(bp, phy, - MDIO_REG_GPHY_CL45_ADDR_REG, - (0x1 << 14) | MDIO_AN_DEVAD); - bnx2x_cl22_read(bp, phy, - MDIO_REG_GPHY_CL45_DATA_REG, - &val); - } - DP(NETIF_MSG_LINK, "EEE resolution: 0x%x\n", val); - } - bnx2x_ext_phy_resolve_fc(phy, params, vars); } return link_up; } -static void bnx2x_54618se_config_loopback(struct bnx2x_phy *phy, - struct link_params *params) +static void bnx2x_54616s_config_loopback(struct bnx2x_phy *phy, + struct link_params *params) { struct bnx2x *bp = params->bp; u16 val; u32 umac_base = params->port ? GRCBASE_UMAC1 : GRCBASE_UMAC0; - DP(NETIF_MSG_LINK, "2PMA/PMD ext_phy_loopback: 54618se\n"); + DP(NETIF_MSG_LINK, "2PMA/PMD ext_phy_loopback: 54616s\n"); /* Enable master/slave manual mmode and set to master */ /* mii write 9 [bits set 11 12] */ @@ -10631,7 +10399,7 @@ static struct bnx2x_phy phy_warpcore = { .link_reset = (link_reset_t)bnx2x_warpcore_link_reset, .config_loopback = (config_loopback_t)bnx2x_set_warpcore_loopback, .format_fw_ver = (format_fw_ver_t)NULL, - .hw_reset = (hw_reset_t)bnx2x_warpcore_hw_reset, + .hw_reset = (hw_reset_t)NULL, .set_link_led = (set_link_led_t)NULL, .phy_specific_func = (phy_specific_func_t)NULL }; @@ -10897,7 +10665,9 @@ static struct bnx2x_phy phy_84833 = { .rx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, .tx_preemphasis = {0xffff, 0xffff, 0xffff, 0xffff}, .mdio_ctrl = 0, - .supported = (SUPPORTED_100baseT_Half | + .supported = (SUPPORTED_10baseT_Half | + SUPPORTED_10baseT_Full | + SUPPORTED_100baseT_Half | SUPPORTED_100baseT_Full | SUPPORTED_1000baseT_Full | SUPPORTED_10000baseT_Full | @@ -10917,13 +10687,13 @@ static struct bnx2x_phy phy_84833 = { .link_reset = (link_reset_t)bnx2x_848x3_link_reset, .config_loopback = (config_loopback_t)NULL, .format_fw_ver = (format_fw_ver_t)bnx2x_848xx_format_ver, - .hw_reset = (hw_reset_t)bnx2x_84833_hw_reset_phy, + .hw_reset = (hw_reset_t)NULL, .set_link_led = (set_link_led_t)bnx2x_848xx_set_link_led, .phy_specific_func = (phy_specific_func_t)NULL }; -static struct bnx2x_phy phy_54618se = { - .type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM54618SE, +static struct bnx2x_phy phy_54616s = { + .type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM54616, .addr = 0xff, .def_md_devad = 0, .flags = FLAGS_INIT_XGXS_FIRST, @@ -10946,13 +10716,13 @@ static struct bnx2x_phy phy_54618se = { .speed_cap_mask = 0, /* req_duplex = */0, /* rsrv = */0, - .config_init = (config_init_t)bnx2x_54618se_config_init, - .read_status = (read_status_t)bnx2x_54618se_read_status, - .link_reset = (link_reset_t)bnx2x_54618se_link_reset, - .config_loopback = (config_loopback_t)bnx2x_54618se_config_loopback, + .config_init = (config_init_t)bnx2x_54616s_config_init, + .read_status = (read_status_t)bnx2x_54616s_read_status, + .link_reset = (link_reset_t)bnx2x_54616s_link_reset, + .config_loopback = (config_loopback_t)bnx2x_54616s_config_loopback, .format_fw_ver = (format_fw_ver_t)NULL, .hw_reset = (hw_reset_t)NULL, - .set_link_led = (set_link_led_t)bnx2x_54618se_set_link_led, + .set_link_led = (set_link_led_t)bnx2x_54616s_set_link_led, .phy_specific_func = (phy_specific_func_t)NULL }; /*****************************************************************/ @@ -11195,8 +10965,8 @@ static int bnx2x_populate_ext_phy(struct bnx2x *bp, case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84833: *phy = phy_84833; break; - case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM54618SE: - *phy = phy_54618se; + case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM54616: + *phy = phy_54616s; break; case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_SFX7101: *phy = phy_7101; @@ -12034,10 +11804,6 @@ static int bnx2x_8727_common_init_phy(struct bnx2x *bp, if (bnx2x_8073_8727_external_rom_boot(bp, phy_blk[port], port_of_path)) return -EINVAL; - /* Disable PHY transmitter output */ - bnx2x_cl45_write(bp, phy_blk[port], - MDIO_PMA_DEVAD, - MDIO_PMA_REG_TX_DISABLE, 1); } return 0; @@ -12307,15 +12073,7 @@ u8 bnx2x_fan_failure_det_req(struct bnx2x *bp, void bnx2x_hw_reset_phy(struct link_params *params) { u8 phy_index; - struct bnx2x *bp = params->bp; - bnx2x_update_mng(params, 0); - bnx2x_bits_dis(bp, NIG_REG_MASK_INTERRUPT_PORT0 + params->port*4, - (NIG_MASK_XGXS0_LINK_STATUS | - NIG_MASK_XGXS0_LINK10G | - NIG_MASK_SERDES0_LINK_STATUS | - NIG_MASK_MI_INT)); - - for (phy_index = INT_PHY; phy_index < MAX_PHYS; + for (phy_index = EXT_PHY1; phy_index < MAX_PHYS; phy_index++) { if (params->phy[phy_index].hw_reset) { params->phy[phy_index].hw_reset( diff --git a/trunk/drivers/net/bnx2x/bnx2x_link.h b/trunk/drivers/net/bnx2x/bnx2x_link.h index 6a7708d5da37..6f299c2fd3e4 100644 --- a/trunk/drivers/net/bnx2x/bnx2x_link.h +++ b/trunk/drivers/net/bnx2x/bnx2x_link.h @@ -250,8 +250,6 @@ struct link_params { #define FEATURE_CONFIG_PFC_ENABLED (1<<1) #define FEATURE_CONFIG_BC_SUPPORTS_OPT_MDL_VRFY (1<<2) #define FEATURE_CONFIG_BC_SUPPORTS_DUAL_PHY_OPT_MDL_VRFY (1<<3) -#define FEATURE_CONFIG_AUTOGREEEN_ENABLED (1<<9) -#define FEATURE_CONFIG_BC_SUPPORTS_SFP_TX_DISABLED (1<<10) /* Will be populated during common init */ struct bnx2x_phy phy[MAX_PHYS]; diff --git a/trunk/drivers/net/bnx2x/bnx2x_main.c b/trunk/drivers/net/bnx2x/bnx2x_main.c index 5b4a8f34b13c..af5721754f65 100644 --- a/trunk/drivers/net/bnx2x/bnx2x_main.c +++ b/trunk/drivers/net/bnx2x/bnx2x_main.c @@ -50,7 +50,6 @@ #include #include #include -#include #include "bnx2x.h" #include "bnx2x_init.h" @@ -1223,7 +1222,7 @@ static inline u8 bnx2x_is_pcie_pending(struct pci_dev *dev) int pos; u16 status; - pos = pci_pcie_cap(dev); + pos = pci_find_capability(dev, PCI_CAP_ID_EXP); if (!pos) return false; @@ -5153,7 +5152,8 @@ static int bnx2x_gunzip_init(struct bnx2x *bp) if (bp->strm == NULL) goto gunzip_nomem2; - bp->strm->workspace = vmalloc(zlib_inflate_workspacesize()); + bp->strm->workspace = kmalloc(zlib_inflate_workspacesize(), + GFP_KERNEL); if (bp->strm->workspace == NULL) goto gunzip_nomem3; @@ -5177,7 +5177,7 @@ static int bnx2x_gunzip_init(struct bnx2x *bp) static void bnx2x_gunzip_end(struct bnx2x *bp) { if (bp->strm) { - vfree(bp->strm->workspace); + kfree(bp->strm->workspace); kfree(bp->strm); bp->strm = NULL; } @@ -5498,7 +5498,7 @@ static void bnx2x_init_pxp(struct bnx2x *bp) int r_order, w_order; pci_read_config_word(bp->pdev, - bp->pdev->pcie_cap + PCI_EXP_DEVCTL, &devctl); + bp->pcie_cap + PCI_EXP_DEVCTL, &devctl); DP(NETIF_MSG_HW, "read 0x%x from devctl\n", devctl); w_order = ((devctl & PCI_EXP_DEVCTL_PAYLOAD) >> 5); if (bp->mrrs == -1) @@ -8349,10 +8349,6 @@ static void __devinit bnx2x_get_common_hwinfo(struct bnx2x *bp) (val >= REQ_BC_VER_4_VRFY_SPECIFIC_PHY_OPT_MDL) ? FEATURE_CONFIG_BC_SUPPORTS_DUAL_PHY_OPT_MDL_VRFY : 0; - bp->link_params.feature_config_flags |= - (val >= REQ_BC_VER_4_SFP_TX_DISABLE_SUPPORTED) ? - FEATURE_CONFIG_BC_SUPPORTS_SFP_TX_DISABLED : 0; - pci_read_config_word(bp->pdev, bp->pm_cap + PCI_PM_PMC, &pmc); bp->flags |= (pmc & PCI_PM_CAP_PME_D3cold) ? 0 : NO_WOL_FLAG; @@ -9763,8 +9759,10 @@ static int __devinit bnx2x_init_dev(struct pci_dev *pdev, goto err_out_release; } - if (!pci_is_pcie(pdev)) { - dev_err(&bp->pdev->dev, "Not PCI Express, aborting\n"); + bp->pcie_cap = pci_find_capability(pdev, PCI_CAP_ID_EXP); + if (bp->pcie_cap == 0) { + dev_err(&bp->pdev->dev, + "Cannot find PCI Express capability, aborting\n"); rc = -EIO; goto err_out_release; } diff --git a/trunk/drivers/net/bnx2x/bnx2x_reg.h b/trunk/drivers/net/bnx2x/bnx2x_reg.h index 005c05af0905..53da4ef19928 100644 --- a/trunk/drivers/net/bnx2x/bnx2x_reg.h +++ b/trunk/drivers/net/bnx2x/bnx2x_reg.h @@ -4771,12 +4771,6 @@ #define UMAC_COMMAND_CONFIG_REG_SW_RESET (0x1<<13) #define UMAC_COMMAND_CONFIG_REG_TX_ENA (0x1<<0) #define UMAC_REG_COMMAND_CONFIG 0x8 -/* [RW 32] Register Bit 0 refers to Bit 16 of the MAC address; Bit 1 refers - * to bit 17 of the MAC address etc. */ -#define UMAC_REG_MAC_ADDR0 0xc -/* [RW 16] Register Bit 0 refers to Bit 0 of the MAC address; Register Bit 1 - * refers to Bit 1 of the MAC address etc. Bits 16 to 31 are reserved. */ -#define UMAC_REG_MAC_ADDR1 0x10 /* [RW 14] Defines a 14-Bit maximum frame length used by the MAC receive * logic to check frames. */ #define UMAC_REG_MAXFR 0x14 @@ -5306,12 +5300,6 @@ #define XMAC_PFC_CTRL_HI_REG_TX_PFC_EN (0x1<<5) #define XMAC_REG_CLEAR_RX_LSS_STATUS 0x60 #define XMAC_REG_CTRL 0 -/* [RW 16] Upper 48 bits of ctrl_sa register. Used as the SA in PAUSE/PFC - * packets transmitted by the MAC */ -#define XMAC_REG_CTRL_SA_HI 0x2c -/* [RW 32] Lower 48 bits of ctrl_sa register. Used as the SA in PAUSE/PFC - * packets transmitted by the MAC */ -#define XMAC_REG_CTRL_SA_LO 0x28 #define XMAC_REG_PAUSE_CTRL 0x68 #define XMAC_REG_PFC_CTRL 0x70 #define XMAC_REG_PFC_CTRL_HI 0x74 @@ -6618,7 +6606,6 @@ Theotherbitsarereservedandshouldbezero*/ #define MDIO_PMA_REG_CTRL 0x0 #define MDIO_PMA_REG_STATUS 0x1 #define MDIO_PMA_REG_10G_CTRL2 0x7 -#define MDIO_PMA_REG_TX_DISABLE 0x0009 #define MDIO_PMA_REG_RX_SD 0xa /*bcm*/ #define MDIO_PMA_REG_BCM_CTRL 0x0096 @@ -6792,8 +6779,6 @@ Theotherbitsarereservedandshouldbezero*/ #define MDIO_84833_TOP_CFG_SCRATCH_REG2 0x4007 #define MDIO_84833_TOP_CFG_SCRATCH_REG3 0x4008 #define MDIO_84833_TOP_CFG_SCRATCH_REG4 0x4009 -#define MDIO_84833_TOP_CFG_DATA3_REG 0x4011 -#define MDIO_84833_TOP_CFG_DATA4_REG 0x4012 /* Mailbox command set used by 84833. */ #define PHY84833_DIAG_CMD_PAIR_SWAP_CHANGE 0x2 @@ -6808,11 +6793,6 @@ Theotherbitsarereservedandshouldbezero*/ #define PHY84833_CMD_CLEAR_COMPLETE 0x0080 #define PHY84833_CMD_OPEN_OVERRIDE 0xa5a5 - -/* 84833 F/W Feature Commands */ -#define PHY84833_DIAG_CMD_GET_EEE_MODE 0x27 -#define PHY84833_DIAG_CMD_SET_EEE_MODE 0x28 - /* Warpcore clause 45 addressing */ #define MDIO_WC_DEVAD 0x3 #define MDIO_WC_REG_IEEE0BLK_MIICNTL 0x0 @@ -6897,7 +6877,6 @@ Theotherbitsarereservedandshouldbezero*/ #define MDIO_WC_REG_DIGITAL5_MISC6 0x8345 #define MDIO_WC_REG_DIGITAL5_MISC7 0x8349 #define MDIO_WC_REG_DIGITAL5_ACTUAL_SPEED 0x834e -#define MDIO_WC_REG_DIGITAL6_MP5_NEXTPAGECTRL 0x8350 #define MDIO_WC_REG_CL49_USERB0_CTRL 0x8368 #define MDIO_WC_REG_TX66_CONTROL 0x83b0 #define MDIO_WC_REG_RX66_CONTROL 0x83c0 @@ -6928,15 +6907,7 @@ Theotherbitsarereservedandshouldbezero*/ #define DIGITAL5_ACTUAL_SPEED_TX_MASK 0x003f -/* 54618se */ -#define MDIO_REG_GPHY_PHYID_LSB 0x3 -#define MDIO_REG_GPHY_ID_54618SE 0x5cd5 -#define MDIO_REG_GPHY_CL45_ADDR_REG 0xd -#define MDIO_REG_GPHY_CL45_DATA_REG 0xe -#define MDIO_REG_GPHY_EEE_ADV 0x3c -#define MDIO_REG_GPHY_EEE_1G (0x1 << 2) -#define MDIO_REG_GPHY_EEE_100 (0x1 << 1) -#define MDIO_REG_GPHY_EEE_RESOLVED 0x803e +/* 54616s */ #define MDIO_REG_INTR_STATUS 0x1a #define MDIO_REG_INTR_MASK 0x1b #define MDIO_REG_INTR_MASK_LINK_STATUS (0x1 << 1) diff --git a/trunk/drivers/net/bnx2x/bnx2x_sp.c b/trunk/drivers/net/bnx2x/bnx2x_sp.c index f6322a15ed4d..5bdf09459a08 100644 --- a/trunk/drivers/net/bnx2x/bnx2x_sp.c +++ b/trunk/drivers/net/bnx2x/bnx2x_sp.c @@ -16,6 +16,7 @@ * Written by: Vladislav Zolotarov * */ +#include #include #include #include diff --git a/trunk/drivers/net/caif/caif_hsi.c b/trunk/drivers/net/caif/caif_hsi.c index b41c2fced0a7..7a8ce61234a7 100644 --- a/trunk/drivers/net/caif/caif_hsi.c +++ b/trunk/drivers/net/caif/caif_hsi.c @@ -6,6 +6,7 @@ * License terms: GNU General Public License (GPL) version 2. */ +#include #include #include #include @@ -987,7 +988,7 @@ int cfhsi_probe(struct platform_device *pdev) goto err_alloc_rx; } - /* Initialize receive variables. */ + /* Initialize recieve vaiables. */ cfhsi->rx_ptr = cfhsi->rx_buf; cfhsi->rx_len = CFHSI_DESC_SZ; diff --git a/trunk/drivers/net/caif/caif_serial.c b/trunk/drivers/net/caif/caif_serial.c index 23406e62c0b0..1cd0b59d13cb 100644 --- a/trunk/drivers/net/caif/caif_serial.c +++ b/trunk/drivers/net/caif/caif_serial.c @@ -6,6 +6,7 @@ #include #include +#include #include #include #include diff --git a/trunk/drivers/net/caif/caif_shm_u5500.c b/trunk/drivers/net/caif/caif_shm_u5500.c index 89d76b7b325a..5f771ab712c4 100644 --- a/trunk/drivers/net/caif/caif_shm_u5500.c +++ b/trunk/drivers/net/caif/caif_shm_u5500.c @@ -7,6 +7,7 @@ #define pr_fmt(fmt) KBUILD_MODNAME ":" fmt +#include #include #include #include diff --git a/trunk/drivers/net/caif/caif_spi.c b/trunk/drivers/net/caif/caif_spi.c index 0f8defc73307..57e639373815 100644 --- a/trunk/drivers/net/caif/caif_spi.c +++ b/trunk/drivers/net/caif/caif_spi.c @@ -5,6 +5,7 @@ * License terms: GNU General Public License (GPL) version 2. */ +#include #include #include #include diff --git a/trunk/drivers/net/caif/caif_spi_slave.c b/trunk/drivers/net/caif/caif_spi_slave.c index e139e133fc79..b009e03cda9e 100644 --- a/trunk/drivers/net/caif/caif_spi_slave.c +++ b/trunk/drivers/net/caif/caif_spi_slave.c @@ -4,6 +4,7 @@ * Author: Daniel Martensson / Daniel.Martensson@stericsson.com * License terms: GNU General Public License (GPL) version 2. */ +#include #include #include #include diff --git a/trunk/drivers/net/can/Kconfig b/trunk/drivers/net/can/Kconfig index f6c98fb4a517..bbf06f77ee8c 100644 --- a/trunk/drivers/net/can/Kconfig +++ b/trunk/drivers/net/can/Kconfig @@ -4,6 +4,7 @@ menu "CAN Device Drivers" config CAN_VCAN tristate "Virtual Local CAN Interface (vcan)" depends on CAN + default N ---help--- Similar to the network loopback devices, vcan offers a virtual local CAN interface. @@ -14,6 +15,7 @@ config CAN_VCAN config CAN_SLCAN tristate "Serial / USB serial CAN Adaptors (slcan)" depends on CAN + default N ---help--- CAN driver for several 'low cost' CAN interfaces that are attached via serial lines or via USB-to-serial adapters using the LAWICEL @@ -34,7 +36,7 @@ config CAN_SLCAN config CAN_DEV tristate "Platform CAN drivers with Netlink support" depends on CAN - default y + default Y ---help--- Enables the common framework for platform CAN drivers with Netlink support. This is the standard library for CAN drivers. @@ -43,7 +45,7 @@ config CAN_DEV config CAN_CALC_BITTIMING bool "CAN bit-timing calculation" depends on CAN_DEV - default y + default Y ---help--- If enabled, CAN bit-timing parameters will be calculated for the bit-rate specified via Netlink argument "bitrate" when the device @@ -123,6 +125,7 @@ source "drivers/net/can/softing/Kconfig" config CAN_DEBUG_DEVICES bool "CAN devices debugging messages" depends on CAN + default N ---help--- Say Y here if you want the CAN device drivers to produce a bunch of debug messages to the system log. Select this if you are having diff --git a/trunk/drivers/net/can/bfin_can.c b/trunk/drivers/net/can/bfin_can.c index a1c5abc38cd2..b6e890d28366 100644 --- a/trunk/drivers/net/can/bfin_can.c +++ b/trunk/drivers/net/can/bfin_can.c @@ -79,8 +79,8 @@ static int bfin_can_set_bittiming(struct net_device *dev) if (priv->can.ctrlmode & CAN_CTRLMODE_3_SAMPLES) timing |= SAM; - bfin_write(®->clock, clk); - bfin_write(®->timing, timing); + bfin_write16(®->clock, clk); + bfin_write16(®->timing, timing); dev_info(dev->dev.parent, "setting CLOCK=0x%04x TIMING=0x%04x\n", clk, timing); @@ -96,16 +96,16 @@ static void bfin_can_set_reset_mode(struct net_device *dev) int i; /* disable interrupts */ - bfin_write(®->mbim1, 0); - bfin_write(®->mbim2, 0); - bfin_write(®->gim, 0); + bfin_write16(®->mbim1, 0); + bfin_write16(®->mbim2, 0); + bfin_write16(®->gim, 0); /* reset can and enter configuration mode */ - bfin_write(®->control, SRS | CCR); + bfin_write16(®->control, SRS | CCR); SSYNC(); - bfin_write(®->control, CCR); + bfin_write16(®->control, CCR); SSYNC(); - while (!(bfin_read(®->control) & CCA)) { + while (!(bfin_read16(®->control) & CCA)) { udelay(10); if (--timeout == 0) { dev_err(dev->dev.parent, @@ -119,33 +119,33 @@ static void bfin_can_set_reset_mode(struct net_device *dev) * by writing to CAN Mailbox Configuration Registers 1 and 2 * For all bits: 0 - Mailbox disabled, 1 - Mailbox enabled */ - bfin_write(®->mc1, 0); - bfin_write(®->mc2, 0); + bfin_write16(®->mc1, 0); + bfin_write16(®->mc2, 0); /* Set Mailbox Direction */ - bfin_write(®->md1, 0xFFFF); /* mailbox 1-16 are RX */ - bfin_write(®->md2, 0); /* mailbox 17-32 are TX */ + bfin_write16(®->md1, 0xFFFF); /* mailbox 1-16 are RX */ + bfin_write16(®->md2, 0); /* mailbox 17-32 are TX */ /* RECEIVE_STD_CHL */ for (i = 0; i < 2; i++) { - bfin_write(®->chl[RECEIVE_STD_CHL + i].id0, 0); - bfin_write(®->chl[RECEIVE_STD_CHL + i].id1, AME); - bfin_write(®->chl[RECEIVE_STD_CHL + i].dlc, 0); - bfin_write(®->msk[RECEIVE_STD_CHL + i].amh, 0x1FFF); - bfin_write(®->msk[RECEIVE_STD_CHL + i].aml, 0xFFFF); + bfin_write16(®->chl[RECEIVE_STD_CHL + i].id0, 0); + bfin_write16(®->chl[RECEIVE_STD_CHL + i].id1, AME); + bfin_write16(®->chl[RECEIVE_STD_CHL + i].dlc, 0); + bfin_write16(®->msk[RECEIVE_STD_CHL + i].amh, 0x1FFF); + bfin_write16(®->msk[RECEIVE_STD_CHL + i].aml, 0xFFFF); } /* RECEIVE_EXT_CHL */ for (i = 0; i < 2; i++) { - bfin_write(®->chl[RECEIVE_EXT_CHL + i].id0, 0); - bfin_write(®->chl[RECEIVE_EXT_CHL + i].id1, AME | IDE); - bfin_write(®->chl[RECEIVE_EXT_CHL + i].dlc, 0); - bfin_write(®->msk[RECEIVE_EXT_CHL + i].amh, 0x1FFF); - bfin_write(®->msk[RECEIVE_EXT_CHL + i].aml, 0xFFFF); + bfin_write16(®->chl[RECEIVE_EXT_CHL + i].id0, 0); + bfin_write16(®->chl[RECEIVE_EXT_CHL + i].id1, AME | IDE); + bfin_write16(®->chl[RECEIVE_EXT_CHL + i].dlc, 0); + bfin_write16(®->msk[RECEIVE_EXT_CHL + i].amh, 0x1FFF); + bfin_write16(®->msk[RECEIVE_EXT_CHL + i].aml, 0xFFFF); } - bfin_write(®->mc2, BIT(TRANSMIT_CHL - 16)); - bfin_write(®->mc1, BIT(RECEIVE_STD_CHL) + BIT(RECEIVE_EXT_CHL)); + bfin_write16(®->mc2, BIT(TRANSMIT_CHL - 16)); + bfin_write16(®->mc1, BIT(RECEIVE_STD_CHL) + BIT(RECEIVE_EXT_CHL)); SSYNC(); priv->can.state = CAN_STATE_STOPPED; @@ -160,9 +160,9 @@ static void bfin_can_set_normal_mode(struct net_device *dev) /* * leave configuration mode */ - bfin_write(®->control, bfin_read(®->control) & ~CCR); + bfin_write16(®->control, bfin_read16(®->control) & ~CCR); - while (bfin_read(®->status) & CCA) { + while (bfin_read16(®->status) & CCA) { udelay(10); if (--timeout == 0) { dev_err(dev->dev.parent, @@ -174,25 +174,25 @@ static void bfin_can_set_normal_mode(struct net_device *dev) /* * clear _All_ tx and rx interrupts */ - bfin_write(®->mbtif1, 0xFFFF); - bfin_write(®->mbtif2, 0xFFFF); - bfin_write(®->mbrif1, 0xFFFF); - bfin_write(®->mbrif2, 0xFFFF); + bfin_write16(®->mbtif1, 0xFFFF); + bfin_write16(®->mbtif2, 0xFFFF); + bfin_write16(®->mbrif1, 0xFFFF); + bfin_write16(®->mbrif2, 0xFFFF); /* * clear global interrupt status register */ - bfin_write(®->gis, 0x7FF); /* overwrites with '1' */ + bfin_write16(®->gis, 0x7FF); /* overwrites with '1' */ /* * Initialize Interrupts * - set bits in the mailbox interrupt mask register * - global interrupt mask */ - bfin_write(®->mbim1, BIT(RECEIVE_STD_CHL) + BIT(RECEIVE_EXT_CHL)); - bfin_write(®->mbim2, BIT(TRANSMIT_CHL - 16)); + bfin_write16(®->mbim1, BIT(RECEIVE_STD_CHL) + BIT(RECEIVE_EXT_CHL)); + bfin_write16(®->mbim2, BIT(TRANSMIT_CHL - 16)); - bfin_write(®->gim, EPIM | BOIM | RMLIM); + bfin_write16(®->gim, EPIM | BOIM | RMLIM); SSYNC(); } @@ -242,28 +242,37 @@ static int bfin_can_start_xmit(struct sk_buff *skb, struct net_device *dev) /* fill id */ if (id & CAN_EFF_FLAG) { - bfin_write(®->chl[TRANSMIT_CHL].id0, id); - val = ((id & 0x1FFF0000) >> 16) | IDE; - } else - val = (id << 2); - if (id & CAN_RTR_FLAG) - val |= RTR; - bfin_write(®->chl[TRANSMIT_CHL].id1, val | AME); + bfin_write16(®->chl[TRANSMIT_CHL].id0, id); + if (id & CAN_RTR_FLAG) + writew(((id & 0x1FFF0000) >> 16) | IDE | AME | RTR, + ®->chl[TRANSMIT_CHL].id1); + else + writew(((id & 0x1FFF0000) >> 16) | IDE | AME, + ®->chl[TRANSMIT_CHL].id1); + + } else { + if (id & CAN_RTR_FLAG) + writew((id << 2) | AME | RTR, + ®->chl[TRANSMIT_CHL].id1); + else + bfin_write16(®->chl[TRANSMIT_CHL].id1, + (id << 2) | AME); + } /* fill payload */ for (i = 0; i < 8; i += 2) { val = ((7 - i) < dlc ? (data[7 - i]) : 0) + ((6 - i) < dlc ? (data[6 - i] << 8) : 0); - bfin_write(®->chl[TRANSMIT_CHL].data[i], val); + bfin_write16(®->chl[TRANSMIT_CHL].data[i], val); } /* fill data length code */ - bfin_write(®->chl[TRANSMIT_CHL].dlc, dlc); + bfin_write16(®->chl[TRANSMIT_CHL].dlc, dlc); can_put_echo_skb(skb, dev, 0); /* set transmit request */ - bfin_write(®->trs2, BIT(TRANSMIT_CHL - 16)); + bfin_write16(®->trs2, BIT(TRANSMIT_CHL - 16)); return 0; } @@ -286,26 +295,26 @@ static void bfin_can_rx(struct net_device *dev, u16 isrc) /* get id */ if (isrc & BIT(RECEIVE_EXT_CHL)) { /* extended frame format (EFF) */ - cf->can_id = ((bfin_read(®->chl[RECEIVE_EXT_CHL].id1) + cf->can_id = ((bfin_read16(®->chl[RECEIVE_EXT_CHL].id1) & 0x1FFF) << 16) - + bfin_read(®->chl[RECEIVE_EXT_CHL].id0); + + bfin_read16(®->chl[RECEIVE_EXT_CHL].id0); cf->can_id |= CAN_EFF_FLAG; obj = RECEIVE_EXT_CHL; } else { /* standard frame format (SFF) */ - cf->can_id = (bfin_read(®->chl[RECEIVE_STD_CHL].id1) + cf->can_id = (bfin_read16(®->chl[RECEIVE_STD_CHL].id1) & 0x1ffc) >> 2; obj = RECEIVE_STD_CHL; } - if (bfin_read(®->chl[obj].id1) & RTR) + if (bfin_read16(®->chl[obj].id1) & RTR) cf->can_id |= CAN_RTR_FLAG; /* get data length code */ - cf->can_dlc = get_can_dlc(bfin_read(®->chl[obj].dlc) & 0xF); + cf->can_dlc = get_can_dlc(bfin_read16(®->chl[obj].dlc) & 0xF); /* get payload */ for (i = 0; i < 8; i += 2) { - val = bfin_read(®->chl[obj].data[i]); + val = bfin_read16(®->chl[obj].data[i]); cf->data[7 - i] = (7 - i) < cf->can_dlc ? val : 0; cf->data[6 - i] = (6 - i) < cf->can_dlc ? (val >> 8) : 0; } @@ -359,7 +368,7 @@ static int bfin_can_err(struct net_device *dev, u16 isrc, u16 status) if (state != priv->can.state && (state == CAN_STATE_ERROR_WARNING || state == CAN_STATE_ERROR_PASSIVE)) { - u16 cec = bfin_read(®->cec); + u16 cec = bfin_read16(®->cec); u8 rxerr = cec; u8 txerr = cec >> 8; @@ -410,23 +419,23 @@ irqreturn_t bfin_can_interrupt(int irq, void *dev_id) struct net_device_stats *stats = &dev->stats; u16 status, isrc; - if ((irq == priv->tx_irq) && bfin_read(®->mbtif2)) { + if ((irq == priv->tx_irq) && bfin_read16(®->mbtif2)) { /* transmission complete interrupt */ - bfin_write(®->mbtif2, 0xFFFF); + bfin_write16(®->mbtif2, 0xFFFF); stats->tx_packets++; - stats->tx_bytes += bfin_read(®->chl[TRANSMIT_CHL].dlc); + stats->tx_bytes += bfin_read16(®->chl[TRANSMIT_CHL].dlc); can_get_echo_skb(dev, 0); netif_wake_queue(dev); - } else if ((irq == priv->rx_irq) && bfin_read(®->mbrif1)) { + } else if ((irq == priv->rx_irq) && bfin_read16(®->mbrif1)) { /* receive interrupt */ - isrc = bfin_read(®->mbrif1); - bfin_write(®->mbrif1, 0xFFFF); + isrc = bfin_read16(®->mbrif1); + bfin_write16(®->mbrif1, 0xFFFF); bfin_can_rx(dev, isrc); - } else if ((irq == priv->err_irq) && bfin_read(®->gis)) { + } else if ((irq == priv->err_irq) && bfin_read16(®->gis)) { /* error interrupt */ - isrc = bfin_read(®->gis); - status = bfin_read(®->esr); - bfin_write(®->gis, 0x7FF); + isrc = bfin_read16(®->gis); + status = bfin_read16(®->esr); + bfin_write16(®->gis, 0x7FF); bfin_can_err(dev, isrc, status); } else { return IRQ_NONE; @@ -631,9 +640,9 @@ static int bfin_can_suspend(struct platform_device *pdev, pm_message_t mesg) if (netif_running(dev)) { /* enter sleep mode */ - bfin_write(®->control, bfin_read(®->control) | SMR); + bfin_write16(®->control, bfin_read16(®->control) | SMR); SSYNC(); - while (!(bfin_read(®->intr) & SMACK)) { + while (!(bfin_read16(®->intr) & SMACK)) { udelay(10); if (--timeout == 0) { dev_err(dev->dev.parent, @@ -654,7 +663,7 @@ static int bfin_can_resume(struct platform_device *pdev) if (netif_running(dev)) { /* leave sleep mode */ - bfin_write(®->intr, 0); + bfin_write16(®->intr, 0); SSYNC(); } diff --git a/trunk/drivers/net/can/c_can/c_can.c b/trunk/drivers/net/can/c_can/c_can.c index 80adc83f796a..7e5cc0bd913d 100644 --- a/trunk/drivers/net/can/c_can/c_can.c +++ b/trunk/drivers/net/can/c_can/c_can.c @@ -26,6 +26,7 @@ */ #include +#include #include #include #include diff --git a/trunk/drivers/net/can/c_can/c_can_platform.c b/trunk/drivers/net/can/c_can/c_can_platform.c index 0e300cf840b9..cc90824f2c9c 100644 --- a/trunk/drivers/net/can/c_can/c_can_platform.c +++ b/trunk/drivers/net/can/c_can/c_can_platform.c @@ -20,6 +20,7 @@ */ #include +#include #include #include #include diff --git a/trunk/drivers/net/can/sja1000/sja1000_of_platform.c b/trunk/drivers/net/can/sja1000/sja1000_of_platform.c index cee6ba2b8b58..9793df6e3455 100644 --- a/trunk/drivers/net/can/sja1000/sja1000_of_platform.c +++ b/trunk/drivers/net/can/sja1000/sja1000_of_platform.c @@ -38,7 +38,6 @@ #include #include #include -#include #include #include diff --git a/trunk/drivers/net/can/softing/softing_main.c b/trunk/drivers/net/can/softing/softing_main.c index a79925e72d66..954b2959b6b2 100644 --- a/trunk/drivers/net/can/softing/softing_main.c +++ b/trunk/drivers/net/can/softing/softing_main.c @@ -17,6 +17,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include #include #include #include diff --git a/trunk/drivers/net/cxgb3/common.h b/trunk/drivers/net/cxgb3/common.h index df01b6343241..056ee8c831f1 100644 --- a/trunk/drivers/net/cxgb3/common.h +++ b/trunk/drivers/net/cxgb3/common.h @@ -367,6 +367,7 @@ struct vpd_params { struct pci_params { unsigned int vpd_cap_addr; + unsigned int pcie_cap_addr; unsigned short speed; unsigned char width; unsigned char variant; diff --git a/trunk/drivers/net/cxgb3/sge.c b/trunk/drivers/net/cxgb3/sge.c index 76bf5892b962..3f562ba2f0c9 100644 --- a/trunk/drivers/net/cxgb3/sge.c +++ b/trunk/drivers/net/cxgb3/sge.c @@ -2026,7 +2026,7 @@ static void rx_eth(struct adapter *adap, struct sge_rspq *rq, skb->ip_summed = CHECKSUM_UNNECESSARY; } else skb_checksum_none_assert(skb); - skb_record_rx_queue(skb, qs - &adap->sge.qs[pi->first_qset]); + skb_record_rx_queue(skb, qs - &adap->sge.qs[0]); if (unlikely(p->vlan_valid)) { struct vlan_group *grp = pi->vlan_grp; @@ -2145,7 +2145,7 @@ static void lro_add_page(struct adapter *adap, struct sge_qset *qs, if (!complete) return; - skb_record_rx_queue(skb, qs - &adap->sge.qs[pi->first_qset]); + skb_record_rx_queue(skb, qs - &adap->sge.qs[0]); if (unlikely(cpl->vlan_valid)) { struct vlan_group *grp = pi->vlan_grp; diff --git a/trunk/drivers/net/cxgb3/t3_hw.c b/trunk/drivers/net/cxgb3/t3_hw.c index 44ac2f40b644..c688421da9c7 100644 --- a/trunk/drivers/net/cxgb3/t3_hw.c +++ b/trunk/drivers/net/cxgb3/t3_hw.c @@ -3290,20 +3290,22 @@ static void config_pcie(struct adapter *adap) unsigned int fst_trn_rx, fst_trn_tx, acklat, rpllmt; pci_read_config_word(adap->pdev, - adap->pdev->pcie_cap + PCI_EXP_DEVCTL, + adap->params.pci.pcie_cap_addr + PCI_EXP_DEVCTL, &val); pldsize = (val & PCI_EXP_DEVCTL_PAYLOAD) >> 5; pci_read_config_word(adap->pdev, 0x2, &devid); if (devid == 0x37) { pci_write_config_word(adap->pdev, - adap->pdev->pcie_cap + PCI_EXP_DEVCTL, + adap->params.pci.pcie_cap_addr + + PCI_EXP_DEVCTL, val & ~PCI_EXP_DEVCTL_READRQ & ~PCI_EXP_DEVCTL_PAYLOAD); pldsize = 0; } - pci_read_config_word(adap->pdev, adap->pdev->pcie_cap + PCI_EXP_LNKCTL, + pci_read_config_word(adap->pdev, + adap->params.pci.pcie_cap_addr + PCI_EXP_LNKCTL, &val); fst_trn_tx = G_NUMFSTTRNSEQ(t3_read_reg(adap, A_PCIE_PEX_CTRL0)); @@ -3427,11 +3429,12 @@ static void get_pci_mode(struct adapter *adapter, struct pci_params *p) static unsigned short speed_map[] = { 33, 66, 100, 133 }; u32 pci_mode, pcie_cap; - pcie_cap = pci_pcie_cap(adapter->pdev); + pcie_cap = pci_find_capability(adapter->pdev, PCI_CAP_ID_EXP); if (pcie_cap) { u16 val; p->variant = PCI_VARIANT_PCIE; + p->pcie_cap_addr = pcie_cap; pci_read_config_word(adapter->pdev, pcie_cap + PCI_EXP_LNKSTA, &val); p->width = (val >> 4) & 0x3f; diff --git a/trunk/drivers/net/cxgb4vf/cxgb4vf_main.c b/trunk/drivers/net/cxgb4vf/cxgb4vf_main.c index 3942a825b3dd..e71c08e547e4 100644 --- a/trunk/drivers/net/cxgb4vf/cxgb4vf_main.c +++ b/trunk/drivers/net/cxgb4vf/cxgb4vf_main.c @@ -33,6 +33,7 @@ * SOFTWARE. */ +#include #include #include #include @@ -2421,6 +2422,7 @@ static int __devinit enable_msix(struct adapter *adapter) return err; } +#ifdef HAVE_NET_DEVICE_OPS static const struct net_device_ops cxgb4vf_netdev_ops = { .ndo_open = cxgb4vf_open, .ndo_stop = cxgb4vf_stop, @@ -2436,6 +2438,7 @@ static const struct net_device_ops cxgb4vf_netdev_ops = { .ndo_poll_controller = cxgb4vf_poll_controller, #endif }; +#endif /* * "Probe" a device: initialize a device and construct all kernel and driver @@ -2609,7 +2612,22 @@ static int __devinit cxgb4vf_pci_probe(struct pci_dev *pdev, if (pci_using_dac) netdev->features |= NETIF_F_HIGHDMA; +#ifdef HAVE_NET_DEVICE_OPS netdev->netdev_ops = &cxgb4vf_netdev_ops; +#else + netdev->vlan_rx_register = cxgb4vf_vlan_rx_register; + netdev->open = cxgb4vf_open; + netdev->stop = cxgb4vf_stop; + netdev->hard_start_xmit = t4vf_eth_xmit; + netdev->get_stats = cxgb4vf_get_stats; + netdev->set_rx_mode = cxgb4vf_set_rxmode; + netdev->do_ioctl = cxgb4vf_do_ioctl; + netdev->change_mtu = cxgb4vf_change_mtu; + netdev->set_mac_address = cxgb4vf_set_mac_addr; +#ifdef CONFIG_NET_POLL_CONTROLLER + netdev->poll_controller = cxgb4vf_poll_controller; +#endif +#endif SET_ETHTOOL_OPS(netdev, &cxgb4vf_ethtool_ops); /* diff --git a/trunk/drivers/net/cxgb4vf/t4vf_hw.c b/trunk/drivers/net/cxgb4vf/t4vf_hw.c index fe3fd3dad6f7..192db226ec7f 100644 --- a/trunk/drivers/net/cxgb4vf/t4vf_hw.c +++ b/trunk/drivers/net/cxgb4vf/t4vf_hw.c @@ -33,6 +33,7 @@ * SOFTWARE. */ +#include #include #include "t4vf_common.h" diff --git a/trunk/drivers/net/davinci_emac.c b/trunk/drivers/net/davinci_emac.c index acef7e96c9fd..55c8245b0cdc 100644 --- a/trunk/drivers/net/davinci_emac.c +++ b/trunk/drivers/net/davinci_emac.c @@ -48,6 +48,7 @@ #include #include #include +#include #include #include #include diff --git a/trunk/drivers/net/declance.c b/trunk/drivers/net/declance.c index d5598f6584a3..cabd3a542ef0 100644 --- a/trunk/drivers/net/declance.c +++ b/trunk/drivers/net/declance.c @@ -946,6 +946,7 @@ static void lance_load_multicast(struct net_device *dev) struct lance_private *lp = netdev_priv(dev); volatile u16 *ib = (volatile u16 *)dev->mem_start; struct netdev_hw_addr *ha; + char *addrs; u32 crc; /* set all multicast bits */ @@ -964,7 +965,13 @@ static void lance_load_multicast(struct net_device *dev) /* Add addresses */ netdev_for_each_mc_addr(ha, dev) { - crc = ether_crc_le(ETH_ALEN, ha->addr); + addrs = ha->addr; + + /* multicast address? */ + if (!(*addrs & 1)) + continue; + + crc = ether_crc_le(ETH_ALEN, addrs); crc = crc >> 26; *lib_ptr(ib, filter[crc >> 4], lp->type) |= 1 << (crc & 0xf); } diff --git a/trunk/drivers/net/depca.c b/trunk/drivers/net/depca.c index f2015a851977..d54a0e93ba93 100644 --- a/trunk/drivers/net/depca.c +++ b/trunk/drivers/net/depca.c @@ -1073,13 +1073,13 @@ static int depca_rx(struct net_device *dev) i = DEPCA_PKT_STAT_SZ; } } - if (is_multicast_ether_addr(buf)) { - if (is_broadcast_ether_addr(buf)) { + if (buf[0] & 0x01) { /* Multicast/Broadcast */ + if ((*(s16 *) & buf[0] == -1) && (*(s16 *) & buf[2] == -1) && (*(s16 *) & buf[4] == -1)) { lp->pktStats.broadcast++; } else { lp->pktStats.multicast++; } - } else if (compare_ether_addr(buf, dev->dev_addr) == 0) { + } else if ((*(s16 *) & buf[0] == *(s16 *) & dev->dev_addr[0]) && (*(s16 *) & buf[2] == *(s16 *) & dev->dev_addr[2]) && (*(s16 *) & buf[4] == *(s16 *) & dev->dev_addr[4])) { lp->pktStats.unicast++; } @@ -1270,6 +1270,7 @@ static void SetMulticastFilter(struct net_device *dev) { struct depca_private *lp = netdev_priv(dev); struct netdev_hw_addr *ha; + char *addrs; int i, j, bit, byte; u16 hashcode; u32 crc; @@ -1284,15 +1285,19 @@ static void SetMulticastFilter(struct net_device *dev) } /* Add multicast addresses */ netdev_for_each_mc_addr(ha, dev) { - crc = ether_crc(ETH_ALEN, ha->addr); - hashcode = (crc & 1); /* hashcode is 6 LSb of CRC ... */ - for (j = 0; j < 5; j++) { /* ... in reverse order. */ - hashcode = (hashcode << 1) | ((crc >>= 1) & 1); - } + addrs = ha->addr; + if ((*addrs & 0x01) == 1) { /* multicast address? */ + crc = ether_crc(ETH_ALEN, addrs); + hashcode = (crc & 1); /* hashcode is 6 LSb of CRC ... */ + for (j = 0; j < 5; j++) { /* ... in reverse order. */ + hashcode = (hashcode << 1) | ((crc >>= 1) & 1); + } - byte = hashcode >> 3; /* bit[3-5] -> byte in filter */ - bit = 1 << (hashcode & 0x07); /* bit[0-2] -> bit in byte */ - lp->init_block.mcast_table[byte] |= bit; + + byte = hashcode >> 3; /* bit[3-5] -> byte in filter */ + bit = 1 << (hashcode & 0x07); /* bit[0-2] -> bit in byte */ + lp->init_block.mcast_table[byte] |= bit; + } } } } diff --git a/trunk/drivers/net/e1000e/82571.c b/trunk/drivers/net/e1000e/82571.c index 480f2592f8a5..8295f2192439 100644 --- a/trunk/drivers/net/e1000e/82571.c +++ b/trunk/drivers/net/e1000e/82571.c @@ -431,6 +431,8 @@ static s32 e1000_get_variants_82571(struct e1000_adapter *adapter) adapter->flags &= ~FLAG_HAS_WOL; break; case e1000_82573: + case e1000_82574: + case e1000_82583: if (pdev->device == E1000_DEV_ID_82573L) { adapter->flags |= FLAG_HAS_JUMBO_FRAMES; adapter->max_hw_frame_size = DEFAULT_JUMBO; @@ -2102,11 +2104,10 @@ struct e1000_info e1000_82583_info = { | FLAG_RX_CSUM_ENABLED | FLAG_HAS_SMART_POWER_DOWN | FLAG_HAS_AMT - | FLAG_HAS_JUMBO_FRAMES | FLAG_HAS_CTRLEXT_ON_LOAD, .flags2 = FLAG2_DISABLE_ASPM_L0S, .pba = 32, - .max_hw_frame_size = DEFAULT_JUMBO, + .max_hw_frame_size = ETH_FRAME_LEN + ETH_FCS_LEN, .get_variants = e1000_get_variants_82571, .mac_ops = &e82571_mac_ops, .phy_ops = &e82_phy_ops_bm, diff --git a/trunk/drivers/net/e1000e/e1000.h b/trunk/drivers/net/e1000e/e1000.h index 638d175792cf..c1e7f9430546 100644 --- a/trunk/drivers/net/e1000e/e1000.h +++ b/trunk/drivers/net/e1000e/e1000.h @@ -199,6 +199,11 @@ enum e1000_boards { board_pch2lan, }; +struct e1000_queue_stats { + u64 packets; + u64 bytes; +}; + struct e1000_ps_page { struct page *page; u64 dma; /* must be u64 - written to hw */ @@ -252,6 +257,8 @@ struct e1000_ring { int set_itr; struct sk_buff *rx_skb_top; + + struct e1000_queue_stats stats; }; /* PHY register snapshot values */ @@ -334,7 +341,7 @@ struct e1000_adapter { int *work_done, int work_to_do) ____cacheline_aligned_in_smp; void (*alloc_rx_buf) (struct e1000_adapter *adapter, - int cleaned_count, gfp_t gfp); + int cleaned_count); struct e1000_ring *rx_ring; u32 rx_int_delay; diff --git a/trunk/drivers/net/e1000e/lib.c b/trunk/drivers/net/e1000e/lib.c index 65580b405942..dd8ab05b5590 100644 --- a/trunk/drivers/net/e1000e/lib.c +++ b/trunk/drivers/net/e1000e/lib.c @@ -56,7 +56,7 @@ s32 e1000e_get_bus_info_pcie(struct e1000_hw *hw) struct e1000_adapter *adapter = hw->adapter; u16 pcie_link_status, cap_offset; - cap_offset = adapter->pdev->pcie_cap; + cap_offset = pci_find_capability(adapter->pdev, PCI_CAP_ID_EXP); if (!cap_offset) { bus->width = e1000_bus_width_unknown; } else { @@ -220,7 +220,7 @@ s32 e1000_check_alt_mac_addr_generic(struct e1000_hw *hw) } /* if multicast bit is set, the alternate address will not be used */ - if (is_multicast_ether_addr(alt_mac_addr)) { + if (alt_mac_addr[0] & 0x01) { e_dbg("Ignoring Alternate Mac Address with MC bit set\n"); goto out; } diff --git a/trunk/drivers/net/e1000e/netdev.c b/trunk/drivers/net/e1000e/netdev.c index 4353ad56cf16..3bf52499743c 100644 --- a/trunk/drivers/net/e1000e/netdev.c +++ b/trunk/drivers/net/e1000e/netdev.c @@ -523,7 +523,7 @@ static void e1000_rx_checksum(struct e1000_adapter *adapter, u32 status_err, * @adapter: address of board private structure **/ static void e1000_alloc_rx_buffers(struct e1000_adapter *adapter, - int cleaned_count, gfp_t gfp) + int cleaned_count) { struct net_device *netdev = adapter->netdev; struct pci_dev *pdev = adapter->pdev; @@ -544,7 +544,7 @@ static void e1000_alloc_rx_buffers(struct e1000_adapter *adapter, goto map_skb; } - skb = __netdev_alloc_skb_ip_align(netdev, bufsz, gfp); + skb = netdev_alloc_skb_ip_align(netdev, bufsz); if (!skb) { /* Better luck next round */ adapter->alloc_rx_buff_failed++; @@ -589,7 +589,7 @@ static void e1000_alloc_rx_buffers(struct e1000_adapter *adapter, * @adapter: address of board private structure **/ static void e1000_alloc_rx_buffers_ps(struct e1000_adapter *adapter, - int cleaned_count, gfp_t gfp) + int cleaned_count) { struct net_device *netdev = adapter->netdev; struct pci_dev *pdev = adapter->pdev; @@ -615,7 +615,7 @@ static void e1000_alloc_rx_buffers_ps(struct e1000_adapter *adapter, continue; } if (!ps_page->page) { - ps_page->page = alloc_page(gfp); + ps_page->page = alloc_page(GFP_ATOMIC); if (!ps_page->page) { adapter->alloc_rx_buff_failed++; goto no_buffers; @@ -641,9 +641,8 @@ static void e1000_alloc_rx_buffers_ps(struct e1000_adapter *adapter, cpu_to_le64(ps_page->dma); } - skb = __netdev_alloc_skb_ip_align(netdev, - adapter->rx_ps_bsize0, - gfp); + skb = netdev_alloc_skb_ip_align(netdev, + adapter->rx_ps_bsize0); if (!skb) { adapter->alloc_rx_buff_failed++; @@ -693,7 +692,7 @@ static void e1000_alloc_rx_buffers_ps(struct e1000_adapter *adapter, **/ static void e1000_alloc_jumbo_rx_buffers(struct e1000_adapter *adapter, - int cleaned_count, gfp_t gfp) + int cleaned_count) { struct net_device *netdev = adapter->netdev; struct pci_dev *pdev = adapter->pdev; @@ -714,7 +713,7 @@ static void e1000_alloc_jumbo_rx_buffers(struct e1000_adapter *adapter, goto check_page; } - skb = __netdev_alloc_skb_ip_align(netdev, bufsz, gfp); + skb = netdev_alloc_skb_ip_align(netdev, bufsz); if (unlikely(!skb)) { /* Better luck next round */ adapter->alloc_rx_buff_failed++; @@ -725,7 +724,7 @@ static void e1000_alloc_jumbo_rx_buffers(struct e1000_adapter *adapter, check_page: /* allocate a new page if necessary */ if (!buffer_info->page) { - buffer_info->page = alloc_page(gfp); + buffer_info->page = alloc_page(GFP_ATOMIC); if (unlikely(!buffer_info->page)) { adapter->alloc_rx_buff_failed++; break; @@ -889,8 +888,7 @@ static bool e1000_clean_rx_irq(struct e1000_adapter *adapter, /* return some buffers to hardware, one at a time is too slow */ if (cleaned_count >= E1000_RX_BUFFER_WRITE) { - adapter->alloc_rx_buf(adapter, cleaned_count, - GFP_ATOMIC); + adapter->alloc_rx_buf(adapter, cleaned_count); cleaned_count = 0; } @@ -902,7 +900,7 @@ static bool e1000_clean_rx_irq(struct e1000_adapter *adapter, cleaned_count = e1000_desc_unused(rx_ring); if (cleaned_count) - adapter->alloc_rx_buf(adapter, cleaned_count, GFP_ATOMIC); + adapter->alloc_rx_buf(adapter, cleaned_count); adapter->total_rx_bytes += total_rx_bytes; adapter->total_rx_packets += total_rx_packets; @@ -1232,8 +1230,7 @@ static bool e1000_clean_rx_irq_ps(struct e1000_adapter *adapter, /* return some buffers to hardware, one at a time is too slow */ if (cleaned_count >= E1000_RX_BUFFER_WRITE) { - adapter->alloc_rx_buf(adapter, cleaned_count, - GFP_ATOMIC); + adapter->alloc_rx_buf(adapter, cleaned_count); cleaned_count = 0; } @@ -1247,7 +1244,7 @@ static bool e1000_clean_rx_irq_ps(struct e1000_adapter *adapter, cleaned_count = e1000_desc_unused(rx_ring); if (cleaned_count) - adapter->alloc_rx_buf(adapter, cleaned_count, GFP_ATOMIC); + adapter->alloc_rx_buf(adapter, cleaned_count); adapter->total_rx_bytes += total_rx_bytes; adapter->total_rx_packets += total_rx_packets; @@ -1414,8 +1411,7 @@ static bool e1000_clean_jumbo_rx_irq(struct e1000_adapter *adapter, /* return some buffers to hardware, one at a time is too slow */ if (unlikely(cleaned_count >= E1000_RX_BUFFER_WRITE)) { - adapter->alloc_rx_buf(adapter, cleaned_count, - GFP_ATOMIC); + adapter->alloc_rx_buf(adapter, cleaned_count); cleaned_count = 0; } @@ -1427,7 +1423,7 @@ static bool e1000_clean_jumbo_rx_irq(struct e1000_adapter *adapter, cleaned_count = e1000_desc_unused(rx_ring); if (cleaned_count) - adapter->alloc_rx_buf(adapter, cleaned_count, GFP_ATOMIC); + adapter->alloc_rx_buf(adapter, cleaned_count); adapter->total_rx_bytes += total_rx_bytes; adapter->total_rx_packets += total_rx_packets; @@ -3109,8 +3105,7 @@ static void e1000_configure(struct e1000_adapter *adapter) e1000_configure_tx(adapter); e1000_setup_rctl(adapter); e1000_configure_rx(adapter); - adapter->alloc_rx_buf(adapter, e1000_desc_unused(adapter->rx_ring), - GFP_KERNEL); + adapter->alloc_rx_buf(adapter, e1000_desc_unused(adapter->rx_ring)); } /** @@ -5323,7 +5318,7 @@ static void e1000_complete_shutdown(struct pci_dev *pdev, bool sleep, */ if (adapter->flags & FLAG_IS_QUAD_PORT) { struct pci_dev *us_dev = pdev->bus->self; - int pos = pci_pcie_cap(us_dev); + int pos = pci_find_capability(us_dev, PCI_CAP_ID_EXP); u16 devctl; pci_read_config_word(us_dev, pos + PCI_EXP_DEVCTL, &devctl); diff --git a/trunk/drivers/net/enic/enic.h b/trunk/drivers/net/enic/enic.h index f0b062b4a223..f747bceb75b1 100644 --- a/trunk/drivers/net/enic/enic.h +++ b/trunk/drivers/net/enic/enic.h @@ -32,7 +32,7 @@ #define DRV_NAME "enic" #define DRV_DESCRIPTION "Cisco VIC Ethernet NIC Driver" -#define DRV_VERSION "2.1.1.24" +#define DRV_VERSION "2.1.1.20" #define DRV_COPYRIGHT "Copyright 2008-2011 Cisco Systems, Inc" #define ENIC_BARS_MAX 6 diff --git a/trunk/drivers/net/enic/enic_dev.c b/trunk/drivers/net/enic/enic_dev.c index fd6247b3c0ee..90687b14e60f 100644 --- a/trunk/drivers/net/enic/enic_dev.c +++ b/trunk/drivers/net/enic/enic_dev.c @@ -166,17 +166,6 @@ int enic_dev_disable(struct enic *enic) return err; } -int enic_dev_intr_coal_timer_info(struct enic *enic) -{ - int err; - - spin_lock(&enic->devcmd_lock); - err = vnic_dev_intr_coal_timer_info(enic->vdev); - spin_unlock(&enic->devcmd_lock); - - return err; -} - int enic_vnic_dev_deinit(struct enic *enic) { int err; diff --git a/trunk/drivers/net/enic/enic_dev.h b/trunk/drivers/net/enic/enic_dev.h index ff8e87fdfc1d..d5f681337626 100644 --- a/trunk/drivers/net/enic/enic_dev.h +++ b/trunk/drivers/net/enic/enic_dev.h @@ -34,7 +34,6 @@ int enic_dev_hang_notify(struct enic *enic); int enic_dev_set_ig_vlan_rewrite_mode(struct enic *enic); int enic_dev_enable(struct enic *enic); int enic_dev_disable(struct enic *enic); -int enic_dev_intr_coal_timer_info(struct enic *enic); int enic_vnic_dev_deinit(struct enic *enic); int enic_dev_init_prov2(struct enic *enic, struct vic_provinfo *vp); int enic_dev_deinit_done(struct enic *enic, int *status); diff --git a/trunk/drivers/net/enic/enic_main.c b/trunk/drivers/net/enic/enic_main.c index e25800fa96ca..4b3a93a924e8 100644 --- a/trunk/drivers/net/enic/enic_main.c +++ b/trunk/drivers/net/enic/enic_main.c @@ -284,10 +284,12 @@ static int enic_set_coalesce(struct net_device *netdev, u32 rx_coalesce_usecs; unsigned int i, intr; - tx_coalesce_usecs = min_t(u32, ecmd->tx_coalesce_usecs, - vnic_dev_get_intr_coal_timer_max(enic->vdev)); - rx_coalesce_usecs = min_t(u32, ecmd->rx_coalesce_usecs, - vnic_dev_get_intr_coal_timer_max(enic->vdev)); + tx_coalesce_usecs = min_t(u32, + INTR_COALESCE_HW_TO_USEC(VNIC_INTR_TIMER_MAX), + ecmd->tx_coalesce_usecs); + rx_coalesce_usecs = min_t(u32, + INTR_COALESCE_HW_TO_USEC(VNIC_INTR_TIMER_MAX), + ecmd->rx_coalesce_usecs); switch (vnic_dev_get_intr_mode(enic->vdev)) { case VNIC_DEV_INTR_MODE_INTX: @@ -296,26 +298,26 @@ static int enic_set_coalesce(struct net_device *netdev, intr = enic_legacy_io_intr(); vnic_intr_coalescing_timer_set(&enic->intr[intr], - tx_coalesce_usecs); + INTR_COALESCE_USEC_TO_HW(tx_coalesce_usecs)); break; case VNIC_DEV_INTR_MODE_MSI: if (tx_coalesce_usecs != rx_coalesce_usecs) return -EINVAL; vnic_intr_coalescing_timer_set(&enic->intr[0], - tx_coalesce_usecs); + INTR_COALESCE_USEC_TO_HW(tx_coalesce_usecs)); break; case VNIC_DEV_INTR_MODE_MSIX: for (i = 0; i < enic->wq_count; i++) { intr = enic_msix_wq_intr(enic, i); vnic_intr_coalescing_timer_set(&enic->intr[intr], - tx_coalesce_usecs); + INTR_COALESCE_USEC_TO_HW(tx_coalesce_usecs)); } for (i = 0; i < enic->rq_count; i++) { intr = enic_msix_rq_intr(enic, i); vnic_intr_coalescing_timer_set(&enic->intr[intr], - rx_coalesce_usecs); + INTR_COALESCE_USEC_TO_HW(rx_coalesce_usecs)); } break; @@ -2173,14 +2175,6 @@ static int enic_dev_init(struct enic *enic) unsigned int i; int err; - /* Get interrupt coalesce timer info */ - err = enic_dev_intr_coal_timer_info(enic); - if (err) { - dev_warn(dev, "Using default conversion factor for " - "interrupt coalesce timer\n"); - vnic_dev_intr_coal_timer_info_default(enic->vdev); - } - /* Get vNIC configuration */ diff --git a/trunk/drivers/net/enic/enic_res.c b/trunk/drivers/net/enic/enic_res.c index 4a35367de790..34f42072b60c 100644 --- a/trunk/drivers/net/enic/enic_res.c +++ b/trunk/drivers/net/enic/enic_res.c @@ -90,8 +90,9 @@ int enic_get_vnic_config(struct enic *enic) max_t(u16, ENIC_MIN_MTU, c->mtu)); - c->intr_timer_usec = min_t(u32, c->intr_timer_usec, - vnic_dev_get_intr_coal_timer_max(enic->vdev)); + c->intr_timer_usec = min_t(u32, + INTR_COALESCE_HW_TO_USEC(VNIC_INTR_TIMER_MAX), + c->intr_timer_usec); dev_info(enic_get_dev(enic), "vNIC MAC addr %pM wq/rq %d/%d mtu %d\n", @@ -302,7 +303,7 @@ void enic_init_vnic_resources(struct enic *enic) for (i = 0; i < enic->intr_count; i++) { vnic_intr_init(&enic->intr[i], - enic->config.intr_timer_usec, + INTR_COALESCE_USEC_TO_HW(enic->config.intr_timer_usec), enic->config.intr_timer_type, mask_on_assertion); } diff --git a/trunk/drivers/net/enic/vnic_dev.c b/trunk/drivers/net/enic/vnic_dev.c index 8c4c8cf486f6..68f24ae860ae 100644 --- a/trunk/drivers/net/enic/vnic_dev.c +++ b/trunk/drivers/net/enic/vnic_dev.c @@ -40,12 +40,6 @@ struct vnic_res { unsigned int count; }; -struct vnic_intr_coal_timer_info { - u32 mul; - u32 div; - u32 max_usec; -}; - struct vnic_dev { void *priv; struct pci_dev *pdev; @@ -64,7 +58,6 @@ struct vnic_dev { enum vnic_proxy_type proxy; u32 proxy_index; u64 args[VNIC_DEVCMD_NARGS]; - struct vnic_intr_coal_timer_info intr_coal_timer_info; }; #define VNIC_MAX_RES_HDR_SIZE \ @@ -801,42 +794,6 @@ int vnic_dev_deinit(struct vnic_dev *vdev) return vnic_dev_cmd(vdev, CMD_DEINIT, &a0, &a1, wait); } -void vnic_dev_intr_coal_timer_info_default(struct vnic_dev *vdev) -{ - /* Default: hardware intr coal timer is in units of 1.5 usecs */ - vdev->intr_coal_timer_info.mul = 2; - vdev->intr_coal_timer_info.div = 3; - vdev->intr_coal_timer_info.max_usec = - vnic_dev_intr_coal_timer_hw_to_usec(vdev, 0xffff); -} - -int vnic_dev_intr_coal_timer_info(struct vnic_dev *vdev) -{ - int wait = 1000; - int err; - - memset(vdev->args, 0, sizeof(vdev->args)); - - err = _vnic_dev_cmd(vdev, CMD_INTR_COAL_CONVERT, wait); - - /* Use defaults when firmware doesn't support the devcmd at all or - * supports it for only specific hardware - */ - if ((err == ERR_ECMDUNKNOWN) || - (!err && !(vdev->args[0] && vdev->args[1] && vdev->args[2]))) { - pr_warning("Using default conversion factor for " - "interrupt coalesce timer\n"); - vnic_dev_intr_coal_timer_info_default(vdev); - return 0; - } - - vdev->intr_coal_timer_info.mul = (u32) vdev->args[0]; - vdev->intr_coal_timer_info.div = (u32) vdev->args[1]; - vdev->intr_coal_timer_info.max_usec = (u32) vdev->args[2]; - - return err; -} - int vnic_dev_link_status(struct vnic_dev *vdev) { if (!vnic_dev_notify_ready(vdev)) @@ -881,23 +838,6 @@ enum vnic_dev_intr_mode vnic_dev_get_intr_mode( return vdev->intr_mode; } -u32 vnic_dev_intr_coal_timer_usec_to_hw(struct vnic_dev *vdev, u32 usec) -{ - return (usec * vdev->intr_coal_timer_info.mul) / - vdev->intr_coal_timer_info.div; -} - -u32 vnic_dev_intr_coal_timer_hw_to_usec(struct vnic_dev *vdev, u32 hw_cycles) -{ - return (hw_cycles * vdev->intr_coal_timer_info.div) / - vdev->intr_coal_timer_info.mul; -} - -u32 vnic_dev_get_intr_coal_timer_max(struct vnic_dev *vdev) -{ - return vdev->intr_coal_timer_info.max_usec; -} - void vnic_dev_unregister(struct vnic_dev *vdev) { if (vdev) { diff --git a/trunk/drivers/net/enic/vnic_dev.h b/trunk/drivers/net/enic/vnic_dev.h index 852b698fbe7d..cf482a2c9dd9 100644 --- a/trunk/drivers/net/enic/vnic_dev.h +++ b/trunk/drivers/net/enic/vnic_dev.h @@ -109,16 +109,11 @@ int vnic_dev_open(struct vnic_dev *vdev, int arg); int vnic_dev_open_done(struct vnic_dev *vdev, int *done); int vnic_dev_init(struct vnic_dev *vdev, int arg); int vnic_dev_deinit(struct vnic_dev *vdev); -void vnic_dev_intr_coal_timer_info_default(struct vnic_dev *vdev); -int vnic_dev_intr_coal_timer_info(struct vnic_dev *vdev); int vnic_dev_hang_reset(struct vnic_dev *vdev, int arg); int vnic_dev_hang_reset_done(struct vnic_dev *vdev, int *done); void vnic_dev_set_intr_mode(struct vnic_dev *vdev, enum vnic_dev_intr_mode intr_mode); enum vnic_dev_intr_mode vnic_dev_get_intr_mode(struct vnic_dev *vdev); -u32 vnic_dev_intr_coal_timer_usec_to_hw(struct vnic_dev *vdev, u32 usec); -u32 vnic_dev_intr_coal_timer_hw_to_usec(struct vnic_dev *vdev, u32 hw_cycles); -u32 vnic_dev_get_intr_coal_timer_max(struct vnic_dev *vdev); void vnic_dev_unregister(struct vnic_dev *vdev); int vnic_dev_set_ig_vlan_rewrite_mode(struct vnic_dev *vdev, u8 ig_vlan_rewrite_mode); diff --git a/trunk/drivers/net/enic/vnic_devcmd.h b/trunk/drivers/net/enic/vnic_devcmd.h index 8025e8808d61..c5569bfb47ac 100644 --- a/trunk/drivers/net/enic/vnic_devcmd.h +++ b/trunk/drivers/net/enic/vnic_devcmd.h @@ -318,25 +318,6 @@ enum vnic_devcmd_cmd { * ERR_EINPROGRESS - command in a0 is still in progress */ CMD_STATUS = _CMDC(_CMD_DIR_RW, _CMD_VTYPE_ALL, 49), - - /* - * Returns interrupt coalescing timer conversion factors. - * After calling this devcmd, ENIC driver can convert - * interrupt coalescing timer in usec into CPU cycles as follows: - * - * intr_timer_cycles = intr_timer_usec * multiplier / divisor - * - * Interrupt coalescing timer in usecs can be obtained from - * CPU cycles as follows: - * - * intr_timer_usec = intr_timer_cycles * divisor / multiplier - * - * in: none - * out: (u32)a0 = multiplier - * (u32)a1 = divisor - * (u32)a2 = maximum timer value in usec - */ - CMD_INTR_COAL_CONVERT = _CMDC(_CMD_DIR_READ, _CMD_VTYPE_ALL, 50), }; /* CMD_ENABLE2 flags */ diff --git a/trunk/drivers/net/enic/vnic_enet.h b/trunk/drivers/net/enic/vnic_enet.h index 609542848e02..061ad8780796 100644 --- a/trunk/drivers/net/enic/vnic_enet.h +++ b/trunk/drivers/net/enic/vnic_enet.h @@ -20,6 +20,10 @@ #ifndef _VNIC_ENIC_H_ #define _VNIC_ENIC_H_ +/* Hardware intr coalesce timer is in units of 1.5us */ +#define INTR_COALESCE_USEC_TO_HW(usec) ((usec) * 2/3) +#define INTR_COALESCE_HW_TO_USEC(usec) ((usec) * 3/2) + /* Device-specific region: enet configuration */ struct vnic_enet_config { u32 flags; diff --git a/trunk/drivers/net/enic/vnic_intr.c b/trunk/drivers/net/enic/vnic_intr.c index 0ca107f7bc8c..3873771d75cc 100644 --- a/trunk/drivers/net/enic/vnic_intr.c +++ b/trunk/drivers/net/enic/vnic_intr.c @@ -46,7 +46,7 @@ int vnic_intr_alloc(struct vnic_dev *vdev, struct vnic_intr *intr, return 0; } -void vnic_intr_init(struct vnic_intr *intr, u32 coalescing_timer, +void vnic_intr_init(struct vnic_intr *intr, unsigned int coalescing_timer, unsigned int coalescing_type, unsigned int mask_on_assertion) { vnic_intr_coalescing_timer_set(intr, coalescing_timer); @@ -56,10 +56,9 @@ void vnic_intr_init(struct vnic_intr *intr, u32 coalescing_timer, } void vnic_intr_coalescing_timer_set(struct vnic_intr *intr, - u32 coalescing_timer) + unsigned int coalescing_timer) { - iowrite32(vnic_dev_intr_coal_timer_usec_to_hw(intr->vdev, - coalescing_timer), &intr->ctrl->coalescing_timer); + iowrite32(coalescing_timer, &intr->ctrl->coalescing_timer); } void vnic_intr_clean(struct vnic_intr *intr) diff --git a/trunk/drivers/net/enic/vnic_intr.h b/trunk/drivers/net/enic/vnic_intr.h index 2b1636392294..09dc0b73ff46 100644 --- a/trunk/drivers/net/enic/vnic_intr.h +++ b/trunk/drivers/net/enic/vnic_intr.h @@ -24,6 +24,8 @@ #include "vnic_dev.h" +#define VNIC_INTR_TIMER_MAX 0xffff + #define VNIC_INTR_TIMER_TYPE_ABS 0 #define VNIC_INTR_TIMER_TYPE_QUIET 1 @@ -102,10 +104,10 @@ static inline u32 vnic_intr_legacy_pba(u32 __iomem *legacy_pba) void vnic_intr_free(struct vnic_intr *intr); int vnic_intr_alloc(struct vnic_dev *vdev, struct vnic_intr *intr, unsigned int index); -void vnic_intr_init(struct vnic_intr *intr, u32 coalescing_timer, +void vnic_intr_init(struct vnic_intr *intr, unsigned int coalescing_timer, unsigned int coalescing_type, unsigned int mask_on_assertion); void vnic_intr_coalescing_timer_set(struct vnic_intr *intr, - u32 coalescing_timer); + unsigned int coalescing_timer); void vnic_intr_clean(struct vnic_intr *intr); #endif /* _VNIC_INTR_H_ */ diff --git a/trunk/drivers/net/ewrk3.c b/trunk/drivers/net/ewrk3.c index 05a5f71451a7..b5f6173130f4 100644 --- a/trunk/drivers/net/ewrk3.c +++ b/trunk/drivers/net/ewrk3.c @@ -1008,13 +1008,15 @@ static int ewrk3_rx(struct net_device *dev) } } p = skb->data; /* Look at the dest addr */ - if (is_multicast_ether_addr(p)) { - if (is_broadcast_ether_addr(p)) { + if (p[0] & 0x01) { /* Multicast/Broadcast */ + if ((*(s16 *) & p[0] == -1) && (*(s16 *) & p[2] == -1) && (*(s16 *) & p[4] == -1)) { lp->pktStats.broadcast++; } else { lp->pktStats.multicast++; } - } else if (compare_ether_addr(p, dev->dev_addr) == 0) { + } else if ((*(s16 *) & p[0] == *(s16 *) & dev->dev_addr[0]) && + (*(s16 *) & p[2] == *(s16 *) & dev->dev_addr[2]) && + (*(s16 *) & p[4] == *(s16 *) & dev->dev_addr[4])) { lp->pktStats.unicast++; } lp->pktStats.bins[0]++; /* Duplicates stats.rx_packets */ @@ -1169,7 +1171,7 @@ static void SetMulticastFilter(struct net_device *dev) struct netdev_hw_addr *ha; u_long iobase = dev->base_addr; int i; - char bit, byte; + char *addrs, bit, byte; short __iomem *p = lp->mctbl; u16 hashcode; u32 crc; @@ -1211,22 +1213,25 @@ static void SetMulticastFilter(struct net_device *dev) /* Update table */ netdev_for_each_mc_addr(ha, dev) { - crc = ether_crc_le(ETH_ALEN, ha->addr); - hashcode = crc & ((1 << 9) - 1); /* hashcode is 9 LSb of CRC */ + addrs = ha->addr; + if ((*addrs & 0x01) == 1) { /* multicast address? */ + crc = ether_crc_le(ETH_ALEN, addrs); + hashcode = crc & ((1 << 9) - 1); /* hashcode is 9 LSb of CRC */ - byte = hashcode >> 3; /* bit[3-8] -> byte in filter */ - bit = 1 << (hashcode & 0x07); /* bit[0-2] -> bit in byte */ + byte = hashcode >> 3; /* bit[3-8] -> byte in filter */ + bit = 1 << (hashcode & 0x07); /* bit[0-2] -> bit in byte */ - if (lp->shmem_length == IO_ONLY) { - u_char tmp; + if (lp->shmem_length == IO_ONLY) { + u_char tmp; - outw(PAGE0_HTE + byte, EWRK3_PIR1); - tmp = inb(EWRK3_DATA); - tmp |= bit; - outw(PAGE0_HTE + byte, EWRK3_PIR1); - outb(tmp, EWRK3_DATA); - } else { - writeb(readb(lp->mctbl + byte) | bit, lp->mctbl + byte); + outw(PAGE0_HTE + byte, EWRK3_PIR1); + tmp = inb(EWRK3_DATA); + tmp |= bit; + outw(PAGE0_HTE + byte, EWRK3_PIR1); + outb(tmp, EWRK3_DATA); + } else { + writeb(readb(lp->mctbl + byte) | bit, lp->mctbl + byte); + } } } } diff --git a/trunk/drivers/net/fec.c b/trunk/drivers/net/fec.c index 5b631fe74738..7ae3f2814200 100644 --- a/trunk/drivers/net/fec.c +++ b/trunk/drivers/net/fec.c @@ -1227,6 +1227,10 @@ static void set_multicast_list(struct net_device *ndev) writel(0, fep->hwp + FEC_GRP_HASH_TABLE_LOW); netdev_for_each_mc_addr(ha, ndev) { + /* Only support group multicast for now */ + if (!(ha->addr[0] & 1)) + continue; + /* calculate crc32 value of mac address */ crc = 0xffffffff; diff --git a/trunk/drivers/net/gianfar.h b/trunk/drivers/net/gianfar.h index 27499c606a4a..76f14d044470 100644 --- a/trunk/drivers/net/gianfar.h +++ b/trunk/drivers/net/gianfar.h @@ -409,7 +409,6 @@ extern const char gfar_driver_version[]; #define RQFCR_HASHTBL_2 0x00060000 #define RQFCR_HASHTBL_3 0x00080000 #define RQFCR_HASH 0x00010000 -#define RQFCR_QUEUE 0x0000FC00 #define RQFCR_CLE 0x00000200 #define RQFCR_RJE 0x00000100 #define RQFCR_AND 0x00000080 diff --git a/trunk/drivers/net/gianfar_ethtool.c b/trunk/drivers/net/gianfar_ethtool.c index 203369cc1272..2ecdc9a785fa 100644 --- a/trunk/drivers/net/gianfar_ethtool.c +++ b/trunk/drivers/net/gianfar_ethtool.c @@ -40,7 +40,6 @@ #include #include #include -#include #include "gianfar.h" @@ -884,7 +883,7 @@ static void gfar_set_attribute(u32 value, u32 mask, u32 flag, struct filer_table *tab) { switch (flag) { - /* 3bit */ + /* 3bit */ case RQFCR_PID_PRI: if (!(value | mask)) return; @@ -1052,17 +1051,17 @@ static int gfar_convert_to_filer(struct ethtool_rx_flow_spec *rule, vlan_mask = RQFPR_VLN; /* Separate the fields */ - id = rule->h_ext.vlan_tci & VLAN_VID_MASK; - id_mask = rule->m_ext.vlan_tci & VLAN_VID_MASK; - cfi = rule->h_ext.vlan_tci & VLAN_CFI_MASK; - cfi_mask = rule->m_ext.vlan_tci & VLAN_CFI_MASK; - prio = (rule->h_ext.vlan_tci & VLAN_PRIO_MASK) >> VLAN_PRIO_SHIFT; - prio_mask = (rule->m_ext.vlan_tci & VLAN_PRIO_MASK) >> VLAN_PRIO_SHIFT; - - if (cfi == VLAN_TAG_PRESENT && cfi_mask == VLAN_TAG_PRESENT) { + id = rule->h_ext.vlan_tci & 0xFFF; + id_mask = rule->m_ext.vlan_tci & 0xFFF; + cfi = (rule->h_ext.vlan_tci >> 12) & 1; + cfi_mask = (rule->m_ext.vlan_tci >> 12) & 1; + prio = (rule->h_ext.vlan_tci >> 13) & 0x7; + prio_mask = (rule->m_ext.vlan_tci >> 13) & 0x7; + + if (cfi == 1 && cfi_mask == 1) { vlan |= RQFPR_CFI; vlan_mask |= RQFPR_CFI; - } else if (cfi != VLAN_TAG_PRESENT && cfi_mask == VLAN_TAG_PRESENT) { + } else if (cfi == 0 && cfi_mask == 1) { vlan_mask |= RQFPR_CFI; } } @@ -1263,21 +1262,21 @@ static void gfar_cluster_filer(struct filer_table *tab) } } -/* Swaps the masked bits of a1<>a2 and b1<>b2 */ -static void gfar_swap_bits(struct gfar_filer_entry *a1, +/* Swaps the 0xFF80 masked bits of a1<>a2 and b1<>b2 */ +static void gfar_swap_ff80_bits(struct gfar_filer_entry *a1, struct gfar_filer_entry *a2, struct gfar_filer_entry *b1, - struct gfar_filer_entry *b2, u32 mask) + struct gfar_filer_entry *b2) { u32 temp[4]; - temp[0] = a1->ctrl & mask; - temp[1] = a2->ctrl & mask; - temp[2] = b1->ctrl & mask; - temp[3] = b2->ctrl & mask; + temp[0] = a1->ctrl & 0xFF80; + temp[1] = a2->ctrl & 0xFF80; + temp[2] = b1->ctrl & 0xFF80; + temp[3] = b2->ctrl & 0xFF80; - a1->ctrl &= ~mask; - a2->ctrl &= ~mask; - b1->ctrl &= ~mask; - b2->ctrl &= ~mask; + a1->ctrl &= ~0xFF80; + a2->ctrl &= ~0xFF80; + b1->ctrl &= ~0xFF80; + b2->ctrl &= ~0xFF80; a1->ctrl |= temp[1]; a2->ctrl |= temp[0]; @@ -1306,7 +1305,7 @@ static u32 gfar_generate_mask_table(struct gfar_mask_entry *mask_table, mask_table[and_index - 1].end = i - 1; and_index++; } - /* cluster starts and ends will be separated because they should + /* cluster starts will be separated because they should * hold their position */ if (tab->fe[i].ctrl & RQFCR_CLE) block_index++; @@ -1357,13 +1356,10 @@ static void gfar_sort_mask_table(struct gfar_mask_entry *mask_table, new_first = mask_table[start].start + 1; new_last = mask_table[i - 1].end; - gfar_swap_bits(&temp_table->fe[new_first], + gfar_swap_ff80_bits(&temp_table->fe[new_first], &temp_table->fe[old_first], &temp_table->fe[new_last], - &temp_table->fe[old_last], - RQFCR_QUEUE | RQFCR_CLE | - RQFCR_RJE | RQFCR_AND - ); + &temp_table->fe[old_last]); start = i; size = 0; diff --git a/trunk/drivers/net/greth.c b/trunk/drivers/net/greth.c index 16ce45c11934..82c3767ec5f8 100644 --- a/trunk/drivers/net/greth.c +++ b/trunk/drivers/net/greth.c @@ -1017,10 +1017,11 @@ static int greth_set_mac_add(struct net_device *dev, void *p) return -EINVAL; memcpy(dev->dev_addr, addr->sa_data, dev->addr_len); - GRETH_REGSAVE(regs->esa_msb, dev->dev_addr[0] << 8 | dev->dev_addr[1]); - GRETH_REGSAVE(regs->esa_lsb, dev->dev_addr[2] << 24 | dev->dev_addr[3] << 16 | - dev->dev_addr[4] << 8 | dev->dev_addr[5]); + GRETH_REGSAVE(regs->esa_msb, addr->sa_data[0] << 8 | addr->sa_data[1]); + GRETH_REGSAVE(regs->esa_lsb, + addr->sa_data[2] << 24 | addr-> + sa_data[3] << 16 | addr->sa_data[4] << 8 | addr->sa_data[5]); return 0; } diff --git a/trunk/drivers/net/hamradio/6pack.c b/trunk/drivers/net/hamradio/6pack.c index 0d283781bc5e..3e5d0b6b6516 100644 --- a/trunk/drivers/net/hamradio/6pack.c +++ b/trunk/drivers/net/hamradio/6pack.c @@ -692,10 +692,10 @@ static void sixpack_close(struct tty_struct *tty) { struct sixpack *sp; - write_lock_bh(&disc_data_lock); + write_lock(&disc_data_lock); sp = tty->disc_data; tty->disc_data = NULL; - write_unlock_bh(&disc_data_lock); + write_unlock(&disc_data_lock); if (!sp) return; diff --git a/trunk/drivers/net/hamradio/mkiss.c b/trunk/drivers/net/hamradio/mkiss.c index bc02968cee16..4c628393c8b1 100644 --- a/trunk/drivers/net/hamradio/mkiss.c +++ b/trunk/drivers/net/hamradio/mkiss.c @@ -813,10 +813,10 @@ static void mkiss_close(struct tty_struct *tty) { struct mkiss *ax; - write_lock_bh(&disc_data_lock); + write_lock(&disc_data_lock); ax = tty->disc_data; tty->disc_data = NULL; - write_unlock_bh(&disc_data_lock); + write_unlock(&disc_data_lock); if (!ax) return; diff --git a/trunk/drivers/net/hp100.c b/trunk/drivers/net/hp100.c index b6519c1ba7e1..c3ecb118c1df 100644 --- a/trunk/drivers/net/hp100.c +++ b/trunk/drivers/net/hp100.c @@ -2103,18 +2103,20 @@ static void hp100_set_multicast_list(struct net_device *dev) #endif netdev_for_each_mc_addr(ha, dev) { addrs = ha->addr; + if ((*addrs & 0x01) == 0x01) { /* multicast address? */ #ifdef HP100_DEBUG - printk("hp100: %s: multicast = %pM, ", - dev->name, addrs); + printk("hp100: %s: multicast = %pM, ", + dev->name, addrs); #endif - for (i = idx = 0; i < 6; i++) { - idx ^= *addrs++ & 0x3f; - printk(":%02x:", idx); - } + for (i = idx = 0; i < 6; i++) { + idx ^= *addrs++ & 0x3f; + printk(":%02x:", idx); + } #ifdef HP100_DEBUG - printk("idx = %i\n", idx); + printk("idx = %i\n", idx); #endif - lp->hash_bytes[idx >> 3] |= (1 << (idx & 7)); + lp->hash_bytes[idx >> 3] |= (1 << (idx & 7)); + } } } #else diff --git a/trunk/drivers/net/igb/Makefile b/trunk/drivers/net/igb/Makefile index c6e4621b6262..8372cb9a8c1a 100644 --- a/trunk/drivers/net/igb/Makefile +++ b/trunk/drivers/net/igb/Makefile @@ -1,7 +1,7 @@ ################################################################################ # # Intel 82575 PCI-Express Ethernet Linux driver -# Copyright(c) 1999 - 2011 Intel Corporation. +# Copyright(c) 1999 - 2009 Intel Corporation. # # This program is free software; you can redistribute it and/or modify it # under the terms and conditions of the GNU General Public License, diff --git a/trunk/drivers/net/igb/e1000_82575.c b/trunk/drivers/net/igb/e1000_82575.c index c0857bdfb03a..0f563c8c5ffc 100644 --- a/trunk/drivers/net/igb/e1000_82575.c +++ b/trunk/drivers/net/igb/e1000_82575.c @@ -1,7 +1,7 @@ /******************************************************************************* Intel(R) Gigabit Ethernet Linux driver - Copyright(c) 2007-2011 Intel Corporation. + Copyright(c) 2007-2009 Intel Corporation. This program is free software; you can redistribute it and/or modify it under the terms and conditions of the GNU General Public License, @@ -1156,13 +1156,10 @@ static s32 igb_setup_serdes_link_82575(struct e1000_hw *hw) { u32 ctrl_ext, ctrl_reg, reg; bool pcs_autoneg; - s32 ret_val = E1000_SUCCESS; - u16 data; if ((hw->phy.media_type != e1000_media_type_internal_serdes) && !igb_sgmii_active_82575(hw)) - return ret_val; - + return 0; /* * On the 82575, SerDes loopback mode persists until it is @@ -1206,18 +1203,6 @@ static s32 igb_setup_serdes_link_82575(struct e1000_hw *hw) /* disable PCS autoneg and support parallel detect only */ pcs_autoneg = false; default: - if (hw->mac.type == e1000_82575 || - hw->mac.type == e1000_82576) { - ret_val = hw->nvm.ops.read(hw, NVM_COMPAT, 1, &data); - if (ret_val) { - printk(KERN_DEBUG "NVM Read Error\n\n"); - return ret_val; - } - - if (data & E1000_EEPROM_PCS_AUTONEG_DISABLE_BIT) - pcs_autoneg = false; - } - /* * non-SGMII modes only supports a speed of 1000/Full for the * link so it is best to just force the MAC and let the pcs @@ -1265,7 +1250,7 @@ static s32 igb_setup_serdes_link_82575(struct e1000_hw *hw) if (!igb_sgmii_active_82575(hw)) igb_force_mac_fc(hw); - return ret_val; + return 0; } /** @@ -1750,7 +1735,6 @@ static s32 igb_reset_hw_82580(struct e1000_hw *hw) ctrl |= E1000_CTRL_RST; wr32(E1000_CTRL, ctrl); - wrfl(); /* Add delay to insure DEV_RST has time to complete */ if (global_device_reset) diff --git a/trunk/drivers/net/igb/e1000_82575.h b/trunk/drivers/net/igb/e1000_82575.h index 786e110011a3..dd6df3498998 100644 --- a/trunk/drivers/net/igb/e1000_82575.h +++ b/trunk/drivers/net/igb/e1000_82575.h @@ -1,7 +1,7 @@ /******************************************************************************* Intel(R) Gigabit Ethernet Linux driver - Copyright(c) 2007-2011 Intel Corporation. + Copyright(c) 2007-2009 Intel Corporation. This program is free software; you can redistribute it and/or modify it under the terms and conditions of the GNU General Public License, @@ -243,8 +243,6 @@ struct e1000_adv_tx_context_desc { #define E1000_DTXCTL_MDP_EN 0x0020 #define E1000_DTXCTL_SPOOF_INT 0x0040 -#define E1000_EEPROM_PCS_AUTONEG_DISABLE_BIT (1 << 14) - #define ALL_QUEUES 0xFFFF /* RX packet buffer size defines */ diff --git a/trunk/drivers/net/igb/e1000_defines.h b/trunk/drivers/net/igb/e1000_defines.h index 2cd4082c86ca..6b80d40110ca 100644 --- a/trunk/drivers/net/igb/e1000_defines.h +++ b/trunk/drivers/net/igb/e1000_defines.h @@ -1,7 +1,7 @@ /******************************************************************************* Intel(R) Gigabit Ethernet Linux driver - Copyright(c) 2007-2011 Intel Corporation. + Copyright(c) 2007-2009 Intel Corporation. This program is free software; you can redistribute it and/or modify it under the terms and conditions of the GNU General Public License, @@ -437,7 +437,6 @@ #define E1000_RAH_POOL_1 0x00040000 /* Error Codes */ -#define E1000_SUCCESS 0 #define E1000_ERR_NVM 1 #define E1000_ERR_PHY 2 #define E1000_ERR_CONFIG 3 @@ -588,8 +587,8 @@ #define E1000_NVM_POLL_READ 0 /* Flag for polling for read complete */ /* NVM Word Offsets */ -#define NVM_COMPAT 0x0003 -#define NVM_ID_LED_SETTINGS 0x0004 /* SERDES output amplitude */ +#define NVM_ID_LED_SETTINGS 0x0004 +/* For SERDES output amplitude adjustment. */ #define NVM_INIT_CONTROL2_REG 0x000F #define NVM_INIT_CONTROL3_PORT_B 0x0014 #define NVM_INIT_CONTROL3_PORT_A 0x0024 diff --git a/trunk/drivers/net/igb/e1000_hw.h b/trunk/drivers/net/igb/e1000_hw.h index 4519a1367170..27153e8d7b16 100644 --- a/trunk/drivers/net/igb/e1000_hw.h +++ b/trunk/drivers/net/igb/e1000_hw.h @@ -1,7 +1,7 @@ /******************************************************************************* Intel(R) Gigabit Ethernet Linux driver - Copyright(c) 2007-2011 Intel Corporation. + Copyright(c) 2007-2009 Intel Corporation. This program is free software; you can redistribute it and/or modify it under the terms and conditions of the GNU General Public License, diff --git a/trunk/drivers/net/igb/e1000_mac.c b/trunk/drivers/net/igb/e1000_mac.c index 2b5ef761d2ab..ce8255fc3c52 100644 --- a/trunk/drivers/net/igb/e1000_mac.c +++ b/trunk/drivers/net/igb/e1000_mac.c @@ -1,7 +1,7 @@ /******************************************************************************* Intel(R) Gigabit Ethernet Linux driver - Copyright(c) 2007-2011 Intel Corporation. + Copyright(c) 2007-2009 Intel Corporation. This program is free software; you can redistribute it and/or modify it under the terms and conditions of the GNU General Public License, @@ -29,7 +29,6 @@ #include #include #include -#include #include "e1000_mac.h" @@ -218,7 +217,7 @@ s32 igb_check_alt_mac_addr(struct e1000_hw *hw) } /* if multicast bit is set, the alternate address will not be used */ - if (is_multicast_ether_addr(alt_mac_addr)) { + if (alt_mac_addr[0] & 0x01) { hw_dbg("Ignoring Alternate Mac Address with MC bit set\n"); goto out; } diff --git a/trunk/drivers/net/igb/e1000_mac.h b/trunk/drivers/net/igb/e1000_mac.h index 4927f61fbbc8..601be99711c2 100644 --- a/trunk/drivers/net/igb/e1000_mac.h +++ b/trunk/drivers/net/igb/e1000_mac.h @@ -1,7 +1,7 @@ /******************************************************************************* Intel(R) Gigabit Ethernet Linux driver - Copyright(c) 2007-2011 Intel Corporation. + Copyright(c) 2007-2009 Intel Corporation. This program is free software; you can redistribute it and/or modify it under the terms and conditions of the GNU General Public License, diff --git a/trunk/drivers/net/igb/e1000_mbx.c b/trunk/drivers/net/igb/e1000_mbx.c index 74f2f11ac290..78d48c7fa859 100644 --- a/trunk/drivers/net/igb/e1000_mbx.c +++ b/trunk/drivers/net/igb/e1000_mbx.c @@ -1,7 +1,7 @@ /******************************************************************************* Intel(R) Gigabit Ethernet Linux driver - Copyright(c) 2007-2011 Intel Corporation. + Copyright(c) 2007-2009 Intel Corporation. This program is free software; you can redistribute it and/or modify it under the terms and conditions of the GNU General Public License, diff --git a/trunk/drivers/net/igb/e1000_mbx.h b/trunk/drivers/net/igb/e1000_mbx.h index eddb0f83dcea..bb112fb6c3a1 100644 --- a/trunk/drivers/net/igb/e1000_mbx.h +++ b/trunk/drivers/net/igb/e1000_mbx.h @@ -1,7 +1,7 @@ /******************************************************************************* Intel(R) Gigabit Ethernet Linux driver - Copyright(c) 2007-2011 Intel Corporation. + Copyright(c) 2007-2009 Intel Corporation. This program is free software; you can redistribute it and/or modify it under the terms and conditions of the GNU General Public License, diff --git a/trunk/drivers/net/igb/e1000_nvm.c b/trunk/drivers/net/igb/e1000_nvm.c index 7dcd65cede56..75bf36a4baee 100644 --- a/trunk/drivers/net/igb/e1000_nvm.c +++ b/trunk/drivers/net/igb/e1000_nvm.c @@ -1,7 +1,7 @@ /******************************************************************************* Intel(R) Gigabit Ethernet Linux driver - Copyright(c) 2007-2011 Intel Corporation. + Copyright(c) 2007-2009 Intel Corporation. This program is free software; you can redistribute it and/or modify it under the terms and conditions of the GNU General Public License, diff --git a/trunk/drivers/net/igb/e1000_nvm.h b/trunk/drivers/net/igb/e1000_nvm.h index a2a7ca9fa733..7f43564c4bcc 100644 --- a/trunk/drivers/net/igb/e1000_nvm.h +++ b/trunk/drivers/net/igb/e1000_nvm.h @@ -1,7 +1,7 @@ /******************************************************************************* Intel(R) Gigabit Ethernet Linux driver - Copyright(c) 2011 Intel Corporation. + Copyright(c) 2007 Intel Corporation. This program is free software; you can redistribute it and/or modify it under the terms and conditions of the GNU General Public License, diff --git a/trunk/drivers/net/igb/e1000_phy.c b/trunk/drivers/net/igb/e1000_phy.c index e662554c62d6..d639706eb3f6 100644 --- a/trunk/drivers/net/igb/e1000_phy.c +++ b/trunk/drivers/net/igb/e1000_phy.c @@ -1,7 +1,7 @@ /******************************************************************************* Intel(R) Gigabit Ethernet Linux driver - Copyright(c) 2007-2011 Intel Corporation. + Copyright(c) 2007-2009 Intel Corporation. This program is free software; you can redistribute it and/or modify it under the terms and conditions of the GNU General Public License, diff --git a/trunk/drivers/net/igb/e1000_phy.h b/trunk/drivers/net/igb/e1000_phy.h index 8510797b9d81..2cc117705a31 100644 --- a/trunk/drivers/net/igb/e1000_phy.h +++ b/trunk/drivers/net/igb/e1000_phy.h @@ -1,7 +1,7 @@ /******************************************************************************* Intel(R) Gigabit Ethernet Linux driver - Copyright(c) 2007-2011 Intel Corporation. + Copyright(c) 2007-2009 Intel Corporation. This program is free software; you can redistribute it and/or modify it under the terms and conditions of the GNU General Public License, diff --git a/trunk/drivers/net/igb/e1000_regs.h b/trunk/drivers/net/igb/e1000_regs.h index 0990f6d860c7..958ca3bda482 100644 --- a/trunk/drivers/net/igb/e1000_regs.h +++ b/trunk/drivers/net/igb/e1000_regs.h @@ -1,7 +1,7 @@ /******************************************************************************* Intel(R) Gigabit Ethernet Linux driver - Copyright(c) 2007-2011 Intel Corporation. + Copyright(c) 2007-2009 Intel Corporation. This program is free software; you can redistribute it and/or modify it under the terms and conditions of the GNU General Public License, diff --git a/trunk/drivers/net/igb/igb.h b/trunk/drivers/net/igb/igb.h index 0389ff6ea696..f4fa4b1751cf 100644 --- a/trunk/drivers/net/igb/igb.h +++ b/trunk/drivers/net/igb/igb.h @@ -1,7 +1,7 @@ /******************************************************************************* Intel(R) Gigabit Ethernet Linux driver - Copyright(c) 2007-2011 Intel Corporation. + Copyright(c) 2007-2009 Intel Corporation. This program is free software; you can redistribute it and/or modify it under the terms and conditions of the GNU General Public License, diff --git a/trunk/drivers/net/igb/igb_ethtool.c b/trunk/drivers/net/igb/igb_ethtool.c index ed63ff4cf6d6..1862c97508ea 100644 --- a/trunk/drivers/net/igb/igb_ethtool.c +++ b/trunk/drivers/net/igb/igb_ethtool.c @@ -1,7 +1,7 @@ /******************************************************************************* Intel(R) Gigabit Ethernet Linux driver - Copyright(c) 2007-2011 Intel Corporation. + Copyright(c) 2007-2009 Intel Corporation. This program is free software; you can redistribute it and/or modify it under the terms and conditions of the GNU General Public License, diff --git a/trunk/drivers/net/igb/igb_main.c b/trunk/drivers/net/igb/igb_main.c index f4d82b2859da..6e67258c4b4e 100644 --- a/trunk/drivers/net/igb/igb_main.c +++ b/trunk/drivers/net/igb/igb_main.c @@ -1,7 +1,7 @@ /******************************************************************************* Intel(R) Gigabit Ethernet Linux driver - Copyright(c) 2007-2011 Intel Corporation. + Copyright(c) 2007-2009 Intel Corporation. This program is free software; you can redistribute it and/or modify it under the terms and conditions of the GNU General Public License, @@ -6267,7 +6267,7 @@ s32 igb_read_pcie_cap_reg(struct e1000_hw *hw, u32 reg, u16 *value) struct igb_adapter *adapter = hw->back; u16 cap_offset; - cap_offset = adapter->pdev->pcie_cap; + cap_offset = pci_find_capability(adapter->pdev, PCI_CAP_ID_EXP); if (!cap_offset) return -E1000_ERR_CONFIG; @@ -6281,7 +6281,7 @@ s32 igb_write_pcie_cap_reg(struct e1000_hw *hw, u32 reg, u16 *value) struct igb_adapter *adapter = hw->back; u16 cap_offset; - cap_offset = adapter->pdev->pcie_cap; + cap_offset = pci_find_capability(adapter->pdev, PCI_CAP_ID_EXP); if (!cap_offset) return -E1000_ERR_CONFIG; diff --git a/trunk/drivers/net/ioc3-eth.c b/trunk/drivers/net/ioc3-eth.c index a234e4504522..318a25a92310 100644 --- a/trunk/drivers/net/ioc3-eth.c +++ b/trunk/drivers/net/ioc3-eth.c @@ -1664,7 +1664,12 @@ static void ioc3_set_multicast_list(struct net_device *dev) ip->ehar_l = 0xffffffff; } else { netdev_for_each_mc_addr(ha, dev) { - ehar |= (1UL << ioc3_hash(ha->addr)); + char *addr = ha->addr; + + if (!(*addr & 1)) + continue; + + ehar |= (1UL << ioc3_hash(addr)); } ip->ehar_h = ehar >> 32; ip->ehar_l = ehar & 0xffffffff; diff --git a/trunk/drivers/net/iseries_veth.c b/trunk/drivers/net/iseries_veth.c index 53dd39e9130e..b6c296f4b4d5 100644 --- a/trunk/drivers/net/iseries_veth.c +++ b/trunk/drivers/net/iseries_veth.c @@ -964,9 +964,11 @@ static void veth_set_multicast_list(struct net_device *dev) u8 *addr = ha->addr; u64 xaddr = 0; - memcpy(&xaddr, addr, ETH_ALEN); - port->mcast_addr[port->num_mcast] = xaddr; - port->num_mcast++; + if (addr[0] & 0x01) {/* multicast address? */ + memcpy(&xaddr, addr, ETH_ALEN); + port->mcast_addr[port->num_mcast] = xaddr; + port->num_mcast++; + } } } @@ -1182,7 +1184,7 @@ static int veth_start_xmit(struct sk_buff *skb, struct net_device *dev) struct veth_port *port = netdev_priv(dev); HvLpIndexMap lpmask; - if (is_unicast_ether_addr(frame)) { + if (! (frame[0] & 0x01)) { /* unicast packet */ HvLpIndex rlp = frame[5]; diff --git a/trunk/drivers/net/ixgbe/ixgbe.h b/trunk/drivers/net/ixgbe/ixgbe.h index 744b64108130..d6bfb2f6ba86 100644 --- a/trunk/drivers/net/ixgbe/ixgbe.h +++ b/trunk/drivers/net/ixgbe/ixgbe.h @@ -131,13 +131,6 @@ struct vf_macvlans { u8 vf_macvlan[ETH_ALEN]; }; -#define IXGBE_MAX_TXD_PWR 14 -#define IXGBE_MAX_DATA_PER_TXD (1 << IXGBE_MAX_TXD_PWR) - -/* Tx Descriptors needed, worst case */ -#define TXD_USE_COUNT(S) DIV_ROUND_UP((S), IXGBE_MAX_DATA_PER_TXD) -#define DESC_NEEDED ((MAX_SKB_FRAGS * TXD_USE_COUNT(PAGE_SIZE)) + 4) - /* wrapper around a pointer to a socket buffer, * so a DMA handle can be stored along with the buffer */ struct ixgbe_tx_buffer { @@ -313,13 +306,9 @@ struct ixgbe_q_vector { ((_eitr) ? (1000000000 / ((_eitr) * 256)) : 8) #define EITR_REG_TO_INTS_PER_SEC EITR_INTS_PER_SEC_TO_REG -static inline u16 ixgbe_desc_unused(struct ixgbe_ring *ring) -{ - u16 ntc = ring->next_to_clean; - u16 ntu = ring->next_to_use; - - return ((ntc > ntu) ? 0 : ring->count) + ntc - ntu - 1; -} +#define IXGBE_DESC_UNUSED(R) \ + ((((R)->next_to_clean > (R)->next_to_use) ? 0 : (R)->count) + \ + (R)->next_to_clean - (R)->next_to_use - 1) #define IXGBE_RX_DESC_ADV(R, i) \ (&(((union ixgbe_adv_rx_desc *)((R)->desc))[i])) @@ -587,10 +576,10 @@ extern void ixgbe_clear_rscctl(struct ixgbe_adapter *adapter, struct ixgbe_ring *ring); extern void ixgbe_set_rx_mode(struct net_device *netdev); extern int ixgbe_setup_tc(struct net_device *dev, u8 tc); -extern void ixgbe_tx_ctxtdesc(struct ixgbe_ring *, u32, u32, u32, u32); #ifdef IXGBE_FCOE extern void ixgbe_configure_fcoe(struct ixgbe_adapter *adapter); -extern int ixgbe_fso(struct ixgbe_ring *tx_ring, struct sk_buff *skb, +extern int ixgbe_fso(struct ixgbe_adapter *adapter, + struct ixgbe_ring *tx_ring, struct sk_buff *skb, u32 tx_flags, u8 *hdr_len); extern void ixgbe_cleanup_fcoe(struct ixgbe_adapter *adapter); extern int ixgbe_fcoe_ddp(struct ixgbe_adapter *adapter, diff --git a/trunk/drivers/net/ixgbe/ixgbe_dcb_nl.c b/trunk/drivers/net/ixgbe/ixgbe_dcb_nl.c index 0ace6ce1d0b4..bd2d75265389 100644 --- a/trunk/drivers/net/ixgbe/ixgbe_dcb_nl.c +++ b/trunk/drivers/net/ixgbe/ixgbe_dcb_nl.c @@ -330,20 +330,24 @@ static void ixgbe_dcbnl_get_pfc_cfg(struct net_device *netdev, int priority, static u8 ixgbe_dcbnl_set_all(struct net_device *netdev) { struct ixgbe_adapter *adapter = netdev_priv(netdev); - int ret; -#ifdef IXGBE_FCOE struct dcb_app app = { .selector = DCB_APP_IDTYPE_ETHTYPE, .protocol = ETH_P_FCOE, }; u8 up = dcb_getapp(netdev, &app); -#endif + int ret; ret = ixgbe_copy_dcb_cfg(&adapter->temp_dcb_cfg, &adapter->dcb_cfg, MAX_TRAFFIC_CLASS); if (ret) return DCB_NO_HW_CHG; + /* In IEEE mode app data must be parsed into DCBX format for + * hardware routines. + */ + if (adapter->dcbx_cap & DCB_CAP_DCBX_VER_IEEE) + up = (1 << up); + #ifdef IXGBE_FCOE if (up && (up != (1 << adapter->fcoe.up))) adapter->dcb_set_bitmap |= BIT_APP_UPCHG; @@ -357,7 +361,7 @@ static u8 ixgbe_dcbnl_set_all(struct net_device *netdev) while (test_and_set_bit(__IXGBE_RESETTING, &adapter->state)) usleep_range(1000, 2000); - adapter->fcoe.up = ffs(up) - 1; + ixgbe_fcoe_setapp(adapter, up); if (netif_running(netdev)) netdev->netdev_ops->ndo_stop(netdev); @@ -670,73 +674,22 @@ static int ixgbe_dcbnl_ieee_setpfc(struct net_device *dev, return err; } -#ifdef IXGBE_FCOE -static void ixgbe_dcbnl_devreset(struct net_device *dev) -{ - struct ixgbe_adapter *adapter = netdev_priv(dev); - - if (netif_running(dev)) - dev->netdev_ops->ndo_stop(dev); - - ixgbe_clear_interrupt_scheme(adapter); - ixgbe_init_interrupt_scheme(adapter); - - if (netif_running(dev)) - dev->netdev_ops->ndo_open(dev); -} -#endif - static int ixgbe_dcbnl_ieee_setapp(struct net_device *dev, struct dcb_app *app) { struct ixgbe_adapter *adapter = netdev_priv(dev); - int err = -EINVAL; - - if (!(adapter->dcbx_cap & DCB_CAP_DCBX_VER_IEEE)) - return err; - - err = dcb_ieee_setapp(dev, app); - -#ifdef IXGBE_FCOE - if (!err && app->selector == IEEE_8021QAZ_APP_SEL_ETHERTYPE && - app->protocol == ETH_P_FCOE) { - u8 app_mask = dcb_ieee_getapp_mask(dev, app); - - if (app_mask & (1 << adapter->fcoe.up)) - return err; - - adapter->fcoe.up = app->priority; - ixgbe_dcbnl_devreset(dev); - } -#endif - return 0; -} - -static int ixgbe_dcbnl_ieee_delapp(struct net_device *dev, - struct dcb_app *app) -{ - struct ixgbe_adapter *adapter = netdev_priv(dev); - int err; if (!(adapter->dcbx_cap & DCB_CAP_DCBX_VER_IEEE)) return -EINVAL; - err = dcb_ieee_delapp(dev, app); + dcb_setapp(dev, app); #ifdef IXGBE_FCOE - if (!err && app->selector == IEEE_8021QAZ_APP_SEL_ETHERTYPE && - app->protocol == ETH_P_FCOE) { - u8 app_mask = dcb_ieee_getapp_mask(dev, app); - - if (app_mask & (1 << adapter->fcoe.up)) - return err; - - adapter->fcoe.up = app_mask ? - ffs(app_mask) - 1 : IXGBE_FCOE_DEFTC; - ixgbe_dcbnl_devreset(dev); - } + if (app->selector == 1 && app->protocol == ETH_P_FCOE && + adapter->fcoe.tc == app->priority) + ixgbe_dcbnl_set_all(dev); #endif - return err; + return 0; } static u8 ixgbe_dcbnl_getdcbx(struct net_device *dev) @@ -790,7 +743,6 @@ const struct dcbnl_rtnl_ops dcbnl_ops = { .ieee_getpfc = ixgbe_dcbnl_ieee_getpfc, .ieee_setpfc = ixgbe_dcbnl_ieee_setpfc, .ieee_setapp = ixgbe_dcbnl_ieee_setapp, - .ieee_delapp = ixgbe_dcbnl_ieee_delapp, .getstate = ixgbe_dcbnl_get_state, .setstate = ixgbe_dcbnl_set_state, .getpermhwaddr = ixgbe_dcbnl_get_perm_hw_addr, diff --git a/trunk/drivers/net/ixgbe/ixgbe_fcoe.c b/trunk/drivers/net/ixgbe/ixgbe_fcoe.c index f0c1018bbf31..f5f39edb86ab 100644 --- a/trunk/drivers/net/ixgbe/ixgbe_fcoe.c +++ b/trunk/drivers/net/ixgbe/ixgbe_fcoe.c @@ -26,6 +26,9 @@ *******************************************************************************/ #include "ixgbe.h" +#ifdef CONFIG_IXGBE_DCB +#include "ixgbe_dcb_82599.h" +#endif /* CONFIG_IXGBE_DCB */ #include #include #include @@ -471,18 +474,24 @@ int ixgbe_fcoe_ddp(struct ixgbe_adapter *adapter, * * Returns : 0 indicates no FSO, > 0 for FSO, < 0 for error */ -int ixgbe_fso(struct ixgbe_ring *tx_ring, struct sk_buff *skb, +int ixgbe_fso(struct ixgbe_adapter *adapter, + struct ixgbe_ring *tx_ring, struct sk_buff *skb, u32 tx_flags, u8 *hdr_len) { - struct fc_frame_header *fh; + u8 sof, eof; u32 vlan_macip_lens; - u32 fcoe_sof_eof = 0; + u32 fcoe_sof_eof; + u32 type_tucmd; u32 mss_l4len_idx; - u8 sof, eof; + int mss = 0; + unsigned int i; + struct ixgbe_tx_buffer *tx_buffer_info; + struct ixgbe_adv_tx_context_desc *context_desc; + struct fc_frame_header *fh; if (skb_is_gso(skb) && (skb_shinfo(skb)->gso_type != SKB_GSO_FCOE)) { - dev_err(tx_ring->dev, "Wrong gso type %d:expecting SKB_GSO_FCOE\n", - skb_shinfo(skb)->gso_type); + e_err(drv, "Wrong gso type %d:expecting SKB_GSO_FCOE\n", + skb_shinfo(skb)->gso_type); return -EINVAL; } @@ -492,22 +501,23 @@ int ixgbe_fso(struct ixgbe_ring *tx_ring, struct sk_buff *skb, sizeof(struct fcoe_hdr)); /* sets up SOF and ORIS */ + fcoe_sof_eof = 0; sof = ((struct fcoe_hdr *)skb_network_header(skb))->fcoe_sof; switch (sof) { case FC_SOF_I2: - fcoe_sof_eof = IXGBE_ADVTXD_FCOEF_ORIS; + fcoe_sof_eof |= IXGBE_ADVTXD_FCOEF_ORIS; break; case FC_SOF_I3: - fcoe_sof_eof = IXGBE_ADVTXD_FCOEF_SOF | - IXGBE_ADVTXD_FCOEF_ORIS; + fcoe_sof_eof |= IXGBE_ADVTXD_FCOEF_SOF; + fcoe_sof_eof |= IXGBE_ADVTXD_FCOEF_ORIS; break; case FC_SOF_N2: break; case FC_SOF_N3: - fcoe_sof_eof = IXGBE_ADVTXD_FCOEF_SOF; + fcoe_sof_eof |= IXGBE_ADVTXD_FCOEF_SOF; break; default: - dev_warn(tx_ring->dev, "unknown sof = 0x%x\n", sof); + e_warn(drv, "unknown sof = 0x%x\n", sof); return -EINVAL; } @@ -520,11 +530,12 @@ int ixgbe_fso(struct ixgbe_ring *tx_ring, struct sk_buff *skb, break; case FC_EOF_T: /* lso needs ORIE */ - if (skb_is_gso(skb)) - fcoe_sof_eof |= IXGBE_ADVTXD_FCOEF_EOF_N | - IXGBE_ADVTXD_FCOEF_ORIE; - else + if (skb_is_gso(skb)) { + fcoe_sof_eof |= IXGBE_ADVTXD_FCOEF_EOF_N; + fcoe_sof_eof |= IXGBE_ADVTXD_FCOEF_ORIE; + } else { fcoe_sof_eof |= IXGBE_ADVTXD_FCOEF_EOF_T; + } break; case FC_EOF_NI: fcoe_sof_eof |= IXGBE_ADVTXD_FCOEF_EOF_NI; @@ -533,7 +544,7 @@ int ixgbe_fso(struct ixgbe_ring *tx_ring, struct sk_buff *skb, fcoe_sof_eof |= IXGBE_ADVTXD_FCOEF_EOF_A; break; default: - dev_warn(tx_ring->dev, "unknown eof = 0x%x\n", eof); + e_warn(drv, "unknown eof = 0x%x\n", eof); return -EINVAL; } @@ -542,28 +553,43 @@ int ixgbe_fso(struct ixgbe_ring *tx_ring, struct sk_buff *skb, if (fh->fh_f_ctl[2] & FC_FC_REL_OFF) fcoe_sof_eof |= IXGBE_ADVTXD_FCOEF_PARINC; - /* include trailer in headlen as it is replicated per frame */ + /* hdr_len includes fc_hdr if FCoE lso is enabled */ *hdr_len = sizeof(struct fcoe_crc_eof); - - /* hdr_len includes fc_hdr if FCoE LSO is enabled */ if (skb_is_gso(skb)) *hdr_len += (skb_transport_offset(skb) + sizeof(struct fc_frame_header)); - - /* mss_l4len_id: use 1 for FSO as TSO, no need for L4LEN */ - mss_l4len_idx = skb_shinfo(skb)->gso_size << IXGBE_ADVTXD_MSS_SHIFT; - mss_l4len_idx |= 1 << IXGBE_ADVTXD_IDX_SHIFT; - /* vlan_macip_lens: HEADLEN, MACLEN, VLAN tag */ - vlan_macip_lens = skb_transport_offset(skb) + - sizeof(struct fc_frame_header); - vlan_macip_lens |= (skb_transport_offset(skb) - 4) - << IXGBE_ADVTXD_MACLEN_SHIFT; - vlan_macip_lens |= tx_flags & IXGBE_TX_FLAGS_VLAN_MASK; + vlan_macip_lens = (skb_transport_offset(skb) + + sizeof(struct fc_frame_header)); + vlan_macip_lens |= ((skb_transport_offset(skb) - 4) + << IXGBE_ADVTXD_MACLEN_SHIFT); + vlan_macip_lens |= (tx_flags & IXGBE_TX_FLAGS_VLAN_MASK); + + /* type_tycmd and mss: set TUCMD.FCoE to enable offload */ + type_tucmd = IXGBE_TXD_CMD_DEXT | IXGBE_ADVTXD_DTYP_CTXT | + IXGBE_ADVTXT_TUCMD_FCOE; + if (skb_is_gso(skb)) + mss = skb_shinfo(skb)->gso_size; + /* mss_l4len_id: use 1 for FSO as TSO, no need for L4LEN */ + mss_l4len_idx = (mss << IXGBE_ADVTXD_MSS_SHIFT) | + (1 << IXGBE_ADVTXD_IDX_SHIFT); /* write context desc */ - ixgbe_tx_ctxtdesc(tx_ring, vlan_macip_lens, fcoe_sof_eof, - IXGBE_ADVTXT_TUCMD_FCOE, mss_l4len_idx); + i = tx_ring->next_to_use; + context_desc = IXGBE_TX_CTXTDESC_ADV(tx_ring, i); + context_desc->vlan_macip_lens = cpu_to_le32(vlan_macip_lens); + context_desc->seqnum_seed = cpu_to_le32(fcoe_sof_eof); + context_desc->type_tucmd_mlhl = cpu_to_le32(type_tucmd); + context_desc->mss_l4len_idx = cpu_to_le32(mss_l4len_idx); + + tx_buffer_info = &tx_ring->tx_buffer_info[i]; + tx_buffer_info->time_stamp = jiffies; + tx_buffer_info->next_to_watch = i; + + i++; + if (i == tx_ring->count) + i = 0; + tx_ring->next_to_use = i; return skb_is_gso(skb); } @@ -622,6 +648,10 @@ void ixgbe_configure_fcoe(struct ixgbe_adapter *adapter) struct ixgbe_hw *hw = &adapter->hw; struct ixgbe_fcoe *fcoe = &adapter->fcoe; struct ixgbe_ring_feature *f = &adapter->ring_feature[RING_F_FCOE]; +#ifdef CONFIG_IXGBE_DCB + u8 tc; + u32 up2tc; +#endif if (!fcoe->pool) { spin_lock_init(&fcoe->lock); @@ -687,6 +717,18 @@ void ixgbe_configure_fcoe(struct ixgbe_adapter *adapter) IXGBE_FCRXCTRL_FCOELLI | IXGBE_FCRXCTRL_FCCRCBO | (FC_FCOE_VER << IXGBE_FCRXCTRL_FCOEVER_SHIFT)); +#ifdef CONFIG_IXGBE_DCB + up2tc = IXGBE_READ_REG(&adapter->hw, IXGBE_RTTUP2TC); + for (i = 0; i < MAX_USER_PRIORITY; i++) { + tc = (u8)(up2tc >> (i * IXGBE_RTTUP2TC_UP_SHIFT)); + tc &= (MAX_TRAFFIC_CLASS - 1); + if (fcoe->tc == tc) { + fcoe->up = i; + break; + } + } +#endif + return; out_extra_ddp_buffer: @@ -814,6 +856,41 @@ int ixgbe_fcoe_disable(struct net_device *netdev) return rc; } +#ifdef CONFIG_IXGBE_DCB +/** + * ixgbe_fcoe_setapp - sets the user priority bitmap for FCoE + * @adapter : ixgbe adapter + * @up : 802.1p user priority bitmap + * + * Finds out the traffic class from the input user priority + * bitmap for FCoE. + * + * Returns : 0 on success otherwise returns 1 on error + */ +u8 ixgbe_fcoe_setapp(struct ixgbe_adapter *adapter, u8 up) +{ + int i; + u32 up2tc; + + /* valid user priority bitmap must not be 0 */ + if (up) { + /* from user priority to the corresponding traffic class */ + up2tc = IXGBE_READ_REG(&adapter->hw, IXGBE_RTTUP2TC); + for (i = 0; i < MAX_USER_PRIORITY; i++) { + if (up & (1 << i)) { + up2tc >>= (i * IXGBE_RTTUP2TC_UP_SHIFT); + up2tc &= (MAX_TRAFFIC_CLASS - 1); + adapter->fcoe.tc = (u8)up2tc; + adapter->fcoe.up = i; + return 0; + } + } + } + + return 1; +} +#endif /* CONFIG_IXGBE_DCB */ + /** * ixgbe_fcoe_get_wwn - get world wide name for the node or the port * @netdev : ixgbe adapter diff --git a/trunk/drivers/net/ixgbe/ixgbe_fcoe.h b/trunk/drivers/net/ixgbe/ixgbe_fcoe.h index 99de145e290d..d876e7ac2257 100644 --- a/trunk/drivers/net/ixgbe/ixgbe_fcoe.h +++ b/trunk/drivers/net/ixgbe/ixgbe_fcoe.h @@ -74,6 +74,7 @@ struct ixgbe_fcoe { dma_addr_t extra_ddp_buffer_dma; unsigned long mode; #ifdef CONFIG_IXGBE_DCB + u8 tc; u8 up; #endif }; diff --git a/trunk/drivers/net/ixgbe/ixgbe_main.c b/trunk/drivers/net/ixgbe/ixgbe_main.c index de307965dfee..2496a27b5991 100644 --- a/trunk/drivers/net/ixgbe/ixgbe_main.c +++ b/trunk/drivers/net/ixgbe/ixgbe_main.c @@ -35,7 +35,6 @@ #include #include #include -#include #include #include #include @@ -772,6 +771,15 @@ static inline bool ixgbe_check_tx_hang(struct ixgbe_ring *tx_ring) return ret; } +#define IXGBE_MAX_TXD_PWR 14 +#define IXGBE_MAX_DATA_PER_TXD (1 << IXGBE_MAX_TXD_PWR) + +/* Tx Descriptors needed, worst case */ +#define TXD_USE_COUNT(S) (((S) >> IXGBE_MAX_TXD_PWR) + \ + (((S) & (IXGBE_MAX_DATA_PER_TXD - 1)) ? 1 : 0)) +#define DESC_NEEDED (TXD_USE_COUNT(IXGBE_MAX_DATA_PER_TXD) /* skb->data */ + \ + MAX_SKB_FRAGS * TXD_USE_COUNT(PAGE_SIZE) + 1) /* for context */ + /** * ixgbe_tx_timeout_reset - initiate reset due to Tx timeout * @adapter: driver private struct @@ -874,7 +882,7 @@ static bool ixgbe_clean_tx_irq(struct ixgbe_q_vector *q_vector, #define TX_WAKE_THRESHOLD (DESC_NEEDED * 2) if (unlikely(count && netif_carrier_ok(tx_ring->netdev) && - (ixgbe_desc_unused(tx_ring) >= TX_WAKE_THRESHOLD))) { + (IXGBE_DESC_UNUSED(tx_ring) >= TX_WAKE_THRESHOLD))) { /* Make sure that anybody stopping the queue after this * sees the new next_to_clean. */ @@ -1466,7 +1474,7 @@ static void ixgbe_clean_rx_irq(struct ixgbe_q_vector *q_vector, } rx_ring->next_to_clean = i; - cleaned_count = ixgbe_desc_unused(rx_ring); + cleaned_count = IXGBE_DESC_UNUSED(rx_ring); if (cleaned_count) ixgbe_alloc_rx_buffers(rx_ring, cleaned_count); @@ -1872,7 +1880,8 @@ static void ixgbe_check_lsc(struct ixgbe_adapter *adapter) static irqreturn_t ixgbe_msix_lsc(int irq, void *data) { - struct ixgbe_adapter *adapter = data; + struct net_device *netdev = data; + struct ixgbe_adapter *adapter = netdev_priv(netdev); struct ixgbe_hw *hw = &adapter->hw; u32 eicr; @@ -2367,7 +2376,7 @@ static int ixgbe_request_msix_irqs(struct ixgbe_adapter *adapter) sprintf(adapter->lsc_int_name, "%s:lsc", netdev->name); err = request_irq(adapter->msix_entries[vector].vector, - ixgbe_msix_lsc, 0, adapter->lsc_int_name, adapter); + ixgbe_msix_lsc, 0, adapter->lsc_int_name, netdev); if (err) { e_err(probe, "request_irq for msix_lsc failed: %d\n", err); goto free_queue_irqs; @@ -2479,7 +2488,8 @@ static inline void ixgbe_irq_enable(struct ixgbe_adapter *adapter, bool queues, **/ static irqreturn_t ixgbe_intr(int irq, void *data) { - struct ixgbe_adapter *adapter = data; + struct net_device *netdev = data; + struct ixgbe_adapter *adapter = netdev_priv(netdev); struct ixgbe_hw *hw = &adapter->hw; struct ixgbe_q_vector *q_vector = adapter->q_vector[0]; u32 eicr; @@ -2576,10 +2586,10 @@ static int ixgbe_request_irq(struct ixgbe_adapter *adapter) err = ixgbe_request_msix_irqs(adapter); } else if (adapter->flags & IXGBE_FLAG_MSI_ENABLED) { err = request_irq(adapter->pdev->irq, ixgbe_intr, 0, - netdev->name, adapter); + netdev->name, netdev); } else { err = request_irq(adapter->pdev->irq, ixgbe_intr, IRQF_SHARED, - netdev->name, adapter); + netdev->name, netdev); } if (err) @@ -2590,13 +2600,15 @@ static int ixgbe_request_irq(struct ixgbe_adapter *adapter) static void ixgbe_free_irq(struct ixgbe_adapter *adapter) { + struct net_device *netdev = adapter->netdev; + if (adapter->flags & IXGBE_FLAG_MSIX_ENABLED) { int i, q_vectors; q_vectors = adapter->num_msix_vectors; i = q_vectors - 1; - free_irq(adapter->msix_entries[i].vector, adapter); + free_irq(adapter->msix_entries[i].vector, netdev); i--; for (; i >= 0; i--) { @@ -2611,7 +2623,7 @@ static void ixgbe_free_irq(struct ixgbe_adapter *adapter) ixgbe_reset_q_vectors(adapter); } else { - free_irq(adapter->pdev->irq, adapter); + free_irq(adapter->pdev->irq, netdev); } } @@ -3118,7 +3130,7 @@ void ixgbe_configure_rx_ring(struct ixgbe_adapter *adapter, IXGBE_WRITE_REG(hw, IXGBE_RXDCTL(reg_idx), rxdctl); ixgbe_rx_desc_queue_enable(adapter, ring); - ixgbe_alloc_rx_buffers(ring, ixgbe_desc_unused(ring)); + ixgbe_alloc_rx_buffers(ring, IXGBE_DESC_UNUSED(ring)); } static void ixgbe_setup_psrtype(struct ixgbe_adapter *adapter) @@ -5155,6 +5167,8 @@ static int __devinit ixgbe_sw_init(struct ixgbe_adapter *adapter) adapter->flags2 |= IXGBE_FLAG2_RSC_ENABLED; if (hw->device_id == IXGBE_DEV_ID_82599_T3_LOM) adapter->flags2 |= IXGBE_FLAG2_TEMP_SENSOR_CAPABLE; + /* n-tuple support exists, always init our spinlock */ + spin_lock_init(&adapter->fdir_perfect_lock); /* Flow Director hash filters enabled */ adapter->flags |= IXGBE_FLAG_FDIR_HASH_CAPABLE; adapter->atr_sample_rate = 20; @@ -5167,6 +5181,7 @@ static int __devinit ixgbe_sw_init(struct ixgbe_adapter *adapter) adapter->ring_feature[RING_F_FCOE].indices = 0; #ifdef CONFIG_IXGBE_DCB /* Default traffic class to use for FCoE */ + adapter->fcoe.tc = IXGBE_FCOE_DEFTC; adapter->fcoe.up = IXGBE_FCOE_DEFTC; #endif #endif /* IXGBE_FCOE */ @@ -5175,9 +5190,6 @@ static int __devinit ixgbe_sw_init(struct ixgbe_adapter *adapter) break; } - /* n-tuple support exists, always init our spinlock */ - spin_lock_init(&adapter->fdir_perfect_lock); - #ifdef CONFIG_IXGBE_DCB /* Configure DCB traffic classes */ for (j = 0; j < MAX_TRAFFIC_CLASS; j++) { @@ -6345,145 +6357,179 @@ static void ixgbe_service_task(struct work_struct *work) ixgbe_service_event_complete(adapter); } -void ixgbe_tx_ctxtdesc(struct ixgbe_ring *tx_ring, u32 vlan_macip_lens, - u32 fcoe_sof_eof, u32 type_tucmd, u32 mss_l4len_idx) +static int ixgbe_tso(struct ixgbe_adapter *adapter, + struct ixgbe_ring *tx_ring, struct sk_buff *skb, + u32 tx_flags, u8 *hdr_len, __be16 protocol) { struct ixgbe_adv_tx_context_desc *context_desc; - u16 i = tx_ring->next_to_use; + unsigned int i; + int err; + struct ixgbe_tx_buffer *tx_buffer_info; + u32 vlan_macip_lens = 0, type_tucmd_mlhl; + u32 mss_l4len_idx, l4len; - context_desc = IXGBE_TX_CTXTDESC_ADV(tx_ring, i); + if (skb_is_gso(skb)) { + if (skb_header_cloned(skb)) { + err = pskb_expand_head(skb, 0, 0, GFP_ATOMIC); + if (err) + return err; + } + l4len = tcp_hdrlen(skb); + *hdr_len += l4len; + + if (protocol == htons(ETH_P_IP)) { + struct iphdr *iph = ip_hdr(skb); + iph->tot_len = 0; + iph->check = 0; + tcp_hdr(skb)->check = ~csum_tcpudp_magic(iph->saddr, + iph->daddr, 0, + IPPROTO_TCP, + 0); + } else if (skb_is_gso_v6(skb)) { + ipv6_hdr(skb)->payload_len = 0; + tcp_hdr(skb)->check = + ~csum_ipv6_magic(&ipv6_hdr(skb)->saddr, + &ipv6_hdr(skb)->daddr, + 0, IPPROTO_TCP, 0); + } - i++; - tx_ring->next_to_use = (i < tx_ring->count) ? i : 0; + i = tx_ring->next_to_use; - /* set bits to identify this as an advanced context descriptor */ - type_tucmd |= IXGBE_TXD_CMD_DEXT | IXGBE_ADVTXD_DTYP_CTXT; + tx_buffer_info = &tx_ring->tx_buffer_info[i]; + context_desc = IXGBE_TX_CTXTDESC_ADV(tx_ring, i); + + /* VLAN MACLEN IPLEN */ + if (tx_flags & IXGBE_TX_FLAGS_VLAN) + vlan_macip_lens |= + (tx_flags & IXGBE_TX_FLAGS_VLAN_MASK); + vlan_macip_lens |= ((skb_network_offset(skb)) << + IXGBE_ADVTXD_MACLEN_SHIFT); + *hdr_len += skb_network_offset(skb); + vlan_macip_lens |= + (skb_transport_header(skb) - skb_network_header(skb)); + *hdr_len += + (skb_transport_header(skb) - skb_network_header(skb)); + context_desc->vlan_macip_lens = cpu_to_le32(vlan_macip_lens); + context_desc->seqnum_seed = 0; + + /* ADV DTYP TUCMD MKRLOC/ISCSIHEDLEN */ + type_tucmd_mlhl = (IXGBE_TXD_CMD_DEXT | + IXGBE_ADVTXD_DTYP_CTXT); - context_desc->vlan_macip_lens = cpu_to_le32(vlan_macip_lens); - context_desc->seqnum_seed = cpu_to_le32(fcoe_sof_eof); - context_desc->type_tucmd_mlhl = cpu_to_le32(type_tucmd); - context_desc->mss_l4len_idx = cpu_to_le32(mss_l4len_idx); -} + if (protocol == htons(ETH_P_IP)) + type_tucmd_mlhl |= IXGBE_ADVTXD_TUCMD_IPV4; + type_tucmd_mlhl |= IXGBE_ADVTXD_TUCMD_L4T_TCP; + context_desc->type_tucmd_mlhl = cpu_to_le32(type_tucmd_mlhl); + + /* MSS L4LEN IDX */ + mss_l4len_idx = + (skb_shinfo(skb)->gso_size << IXGBE_ADVTXD_MSS_SHIFT); + mss_l4len_idx |= (l4len << IXGBE_ADVTXD_L4LEN_SHIFT); + /* use index 1 for TSO */ + mss_l4len_idx |= (1 << IXGBE_ADVTXD_IDX_SHIFT); + context_desc->mss_l4len_idx = cpu_to_le32(mss_l4len_idx); -static int ixgbe_tso(struct ixgbe_ring *tx_ring, struct sk_buff *skb, - u32 tx_flags, __be16 protocol, u8 *hdr_len) -{ - int err; - u32 vlan_macip_lens, type_tucmd; - u32 mss_l4len_idx, l4len; + tx_buffer_info->time_stamp = jiffies; + tx_buffer_info->next_to_watch = i; - if (!skb_is_gso(skb)) - return 0; + i++; + if (i == tx_ring->count) + i = 0; + tx_ring->next_to_use = i; - if (skb_header_cloned(skb)) { - err = pskb_expand_head(skb, 0, 0, GFP_ATOMIC); - if (err) - return err; + return true; } + return false; +} - /* ADV DTYP TUCMD MKRLOC/ISCSIHEDLEN */ - type_tucmd = IXGBE_ADVTXD_TUCMD_L4T_TCP; - - if (protocol == __constant_htons(ETH_P_IP)) { - struct iphdr *iph = ip_hdr(skb); - iph->tot_len = 0; - iph->check = 0; - tcp_hdr(skb)->check = ~csum_tcpudp_magic(iph->saddr, - iph->daddr, 0, - IPPROTO_TCP, - 0); - type_tucmd |= IXGBE_ADVTXD_TUCMD_IPV4; - } else if (skb_is_gso_v6(skb)) { - ipv6_hdr(skb)->payload_len = 0; - tcp_hdr(skb)->check = - ~csum_ipv6_magic(&ipv6_hdr(skb)->saddr, - &ipv6_hdr(skb)->daddr, - 0, IPPROTO_TCP, 0); - } - - l4len = tcp_hdrlen(skb); - *hdr_len = skb_transport_offset(skb) + l4len; - - /* mss_l4len_id: use 1 as index for TSO */ - mss_l4len_idx = l4len << IXGBE_ADVTXD_L4LEN_SHIFT; - mss_l4len_idx |= skb_shinfo(skb)->gso_size << IXGBE_ADVTXD_MSS_SHIFT; - mss_l4len_idx |= 1 << IXGBE_ADVTXD_IDX_SHIFT; - - /* vlan_macip_lens: HEADLEN, MACLEN, VLAN tag */ - vlan_macip_lens = skb_network_header_len(skb); - vlan_macip_lens |= skb_network_offset(skb) << IXGBE_ADVTXD_MACLEN_SHIFT; - vlan_macip_lens |= tx_flags & IXGBE_TX_FLAGS_VLAN_MASK; - - ixgbe_tx_ctxtdesc(tx_ring, vlan_macip_lens, 0, type_tucmd, - mss_l4len_idx); - - return 1; -} - -static bool ixgbe_tx_csum(struct ixgbe_ring *tx_ring, - struct sk_buff *skb, u32 tx_flags, - __be16 protocol) +static u32 ixgbe_psum(struct ixgbe_adapter *adapter, struct sk_buff *skb, + __be16 protocol) { - u32 vlan_macip_lens = 0; - u32 mss_l4len_idx = 0; - u32 type_tucmd = 0; + u32 rtn = 0; - if (skb->ip_summed != CHECKSUM_PARTIAL) { - if (!(tx_flags & IXGBE_TX_FLAGS_VLAN)) - return false; - } else { - u8 l4_hdr = 0; - switch (protocol) { - case __constant_htons(ETH_P_IP): - vlan_macip_lens |= skb_network_header_len(skb); - type_tucmd |= IXGBE_ADVTXD_TUCMD_IPV4; - l4_hdr = ip_hdr(skb)->protocol; - break; - case __constant_htons(ETH_P_IPV6): - vlan_macip_lens |= skb_network_header_len(skb); - l4_hdr = ipv6_hdr(skb)->nexthdr; + switch (protocol) { + case cpu_to_be16(ETH_P_IP): + rtn |= IXGBE_ADVTXD_TUCMD_IPV4; + switch (ip_hdr(skb)->protocol) { + case IPPROTO_TCP: + rtn |= IXGBE_ADVTXD_TUCMD_L4T_TCP; break; - default: - if (unlikely(net_ratelimit())) { - dev_warn(tx_ring->dev, - "partial checksum but proto=%x!\n", - skb->protocol); - } + case IPPROTO_SCTP: + rtn |= IXGBE_ADVTXD_TUCMD_L4T_SCTP; break; } - - switch (l4_hdr) { + break; + case cpu_to_be16(ETH_P_IPV6): + /* XXX what about other V6 headers?? */ + switch (ipv6_hdr(skb)->nexthdr) { case IPPROTO_TCP: - type_tucmd |= IXGBE_ADVTXD_TUCMD_L4T_TCP; - mss_l4len_idx = tcp_hdrlen(skb) << - IXGBE_ADVTXD_L4LEN_SHIFT; + rtn |= IXGBE_ADVTXD_TUCMD_L4T_TCP; break; case IPPROTO_SCTP: - type_tucmd |= IXGBE_ADVTXD_TUCMD_L4T_SCTP; - mss_l4len_idx = sizeof(struct sctphdr) << - IXGBE_ADVTXD_L4LEN_SHIFT; - break; - case IPPROTO_UDP: - mss_l4len_idx = sizeof(struct udphdr) << - IXGBE_ADVTXD_L4LEN_SHIFT; - break; - default: - if (unlikely(net_ratelimit())) { - dev_warn(tx_ring->dev, - "partial checksum but l4 proto=%x!\n", - skb->protocol); - } + rtn |= IXGBE_ADVTXD_TUCMD_L4T_SCTP; break; } + break; + default: + if (unlikely(net_ratelimit())) + e_warn(probe, "partial checksum but proto=%x!\n", + protocol); + break; } - vlan_macip_lens |= skb_network_offset(skb) << IXGBE_ADVTXD_MACLEN_SHIFT; - vlan_macip_lens |= tx_flags & IXGBE_TX_FLAGS_VLAN_MASK; + return rtn; +} - ixgbe_tx_ctxtdesc(tx_ring, vlan_macip_lens, 0, - type_tucmd, mss_l4len_idx); +static bool ixgbe_tx_csum(struct ixgbe_adapter *adapter, + struct ixgbe_ring *tx_ring, + struct sk_buff *skb, u32 tx_flags, + __be16 protocol) +{ + struct ixgbe_adv_tx_context_desc *context_desc; + unsigned int i; + struct ixgbe_tx_buffer *tx_buffer_info; + u32 vlan_macip_lens = 0, type_tucmd_mlhl = 0; + + if (skb->ip_summed == CHECKSUM_PARTIAL || + (tx_flags & IXGBE_TX_FLAGS_VLAN)) { + i = tx_ring->next_to_use; + tx_buffer_info = &tx_ring->tx_buffer_info[i]; + context_desc = IXGBE_TX_CTXTDESC_ADV(tx_ring, i); + + if (tx_flags & IXGBE_TX_FLAGS_VLAN) + vlan_macip_lens |= + (tx_flags & IXGBE_TX_FLAGS_VLAN_MASK); + vlan_macip_lens |= (skb_network_offset(skb) << + IXGBE_ADVTXD_MACLEN_SHIFT); + if (skb->ip_summed == CHECKSUM_PARTIAL) + vlan_macip_lens |= (skb_transport_header(skb) - + skb_network_header(skb)); + + context_desc->vlan_macip_lens = cpu_to_le32(vlan_macip_lens); + context_desc->seqnum_seed = 0; + + type_tucmd_mlhl |= (IXGBE_TXD_CMD_DEXT | + IXGBE_ADVTXD_DTYP_CTXT); - return (skb->ip_summed == CHECKSUM_PARTIAL); + if (skb->ip_summed == CHECKSUM_PARTIAL) + type_tucmd_mlhl |= ixgbe_psum(adapter, skb, protocol); + + context_desc->type_tucmd_mlhl = cpu_to_le32(type_tucmd_mlhl); + /* use index zero for tx checksum offload */ + context_desc->mss_l4len_idx = 0; + + tx_buffer_info->time_stamp = jiffies; + tx_buffer_info->next_to_watch = i; + + i++; + if (i == tx_ring->count) + i = 0; + tx_ring->next_to_use = i; + + return true; + } + + return false; } static int ixgbe_tx_map(struct ixgbe_adapter *adapter, @@ -6495,12 +6541,11 @@ static int ixgbe_tx_map(struct ixgbe_adapter *adapter, struct ixgbe_tx_buffer *tx_buffer_info; unsigned int len; unsigned int total = skb->len; - unsigned int offset = 0, size, count = 0; + unsigned int offset = 0, size, count = 0, i; unsigned int nr_frags = skb_shinfo(skb)->nr_frags; unsigned int f; unsigned int bytecount = skb->len; u16 gso_segs = 1; - u16 i; i = tx_ring->next_to_use; @@ -6766,7 +6811,7 @@ static void ixgbe_atr(struct ixgbe_ring *ring, struct sk_buff *skb, input, common, ring->queue_index); } -static int __ixgbe_maybe_stop_tx(struct ixgbe_ring *tx_ring, u16 size) +static int __ixgbe_maybe_stop_tx(struct ixgbe_ring *tx_ring, int size) { netif_stop_subqueue(tx_ring->netdev, tx_ring->queue_index); /* Herbert's original patch had: @@ -6776,7 +6821,7 @@ static int __ixgbe_maybe_stop_tx(struct ixgbe_ring *tx_ring, u16 size) /* We need to check again in a case another CPU has just * made room available. */ - if (likely(ixgbe_desc_unused(tx_ring) < size)) + if (likely(IXGBE_DESC_UNUSED(tx_ring) < size)) return -EBUSY; /* A reprieve! - use start_queue because it doesn't call schedule */ @@ -6785,9 +6830,9 @@ static int __ixgbe_maybe_stop_tx(struct ixgbe_ring *tx_ring, u16 size) return 0; } -static int ixgbe_maybe_stop_tx(struct ixgbe_ring *tx_ring, u16 size) +static int ixgbe_maybe_stop_tx(struct ixgbe_ring *tx_ring, int size) { - if (likely(ixgbe_desc_unused(tx_ring) >= size)) + if (likely(IXGBE_DESC_UNUSED(tx_ring) >= size)) return 0; return __ixgbe_maybe_stop_tx(tx_ring, size); } @@ -6823,33 +6868,13 @@ netdev_tx_t ixgbe_xmit_frame_ring(struct sk_buff *skb, struct ixgbe_adapter *adapter, struct ixgbe_ring *tx_ring) { + unsigned int first; + unsigned int tx_flags = 0; + u8 hdr_len = 0; int tso; - u32 tx_flags = 0; -#if PAGE_SIZE > IXGBE_MAX_DATA_PER_TXD - unsigned short f; -#endif - u16 first; - u16 count = TXD_USE_COUNT(skb_headlen(skb)); + int count = 0; + unsigned int f; __be16 protocol; - u8 hdr_len = 0; - - /* - * need: 1 descriptor per page * PAGE_SIZE/IXGBE_MAX_DATA_PER_TXD, - * + 1 desc for skb_head_len/IXGBE_MAX_DATA_PER_TXD, - * + 2 desc gap to keep tail from touching head, - * + 1 desc for context descriptor, - * otherwise try next time - */ -#if PAGE_SIZE > IXGBE_MAX_DATA_PER_TXD - for (f = 0; f < skb_shinfo(skb)->nr_frags; f++) - count += TXD_USE_COUNT(skb_shinfo(skb)->frags[f].size); -#else - count += skb_shinfo(skb)->nr_frags; -#endif - if (ixgbe_maybe_stop_tx(tx_ring, count + 3)) { - tx_ring->tx_stats.tx_busy++; - return NETDEV_TX_BUSY; - } protocol = vlan_get_protocol(skb); @@ -6874,29 +6899,51 @@ netdev_tx_t ixgbe_xmit_frame_ring(struct sk_buff *skb, if (adapter->flags & IXGBE_FLAG_FCOE_ENABLED && (protocol == htons(ETH_P_FCOE))) tx_flags |= IXGBE_TX_FLAGS_FCOE; - #endif - /* record the location of the first descriptor for this packet */ - first = tx_ring->next_to_use; + /* four things can cause us to need a context descriptor */ + if (skb_is_gso(skb) || + (skb->ip_summed == CHECKSUM_PARTIAL) || + (tx_flags & IXGBE_TX_FLAGS_VLAN) || + (tx_flags & IXGBE_TX_FLAGS_FCOE)) + count++; + + count += TXD_USE_COUNT(skb_headlen(skb)); + for (f = 0; f < skb_shinfo(skb)->nr_frags; f++) + count += TXD_USE_COUNT(skb_shinfo(skb)->frags[f].size); + + if (ixgbe_maybe_stop_tx(tx_ring, count)) { + tx_ring->tx_stats.tx_busy++; + return NETDEV_TX_BUSY; + } + + first = tx_ring->next_to_use; if (tx_flags & IXGBE_TX_FLAGS_FCOE) { #ifdef IXGBE_FCOE /* setup tx offload for FCoE */ - tso = ixgbe_fso(tx_ring, skb, tx_flags, &hdr_len); - if (tso < 0) - goto out_drop; - else if (tso) + tso = ixgbe_fso(adapter, tx_ring, skb, tx_flags, &hdr_len); + if (tso < 0) { + dev_kfree_skb_any(skb); + return NETDEV_TX_OK; + } + if (tso) tx_flags |= IXGBE_TX_FLAGS_FSO; #endif /* IXGBE_FCOE */ } else { if (protocol == htons(ETH_P_IP)) tx_flags |= IXGBE_TX_FLAGS_IPV4; - tso = ixgbe_tso(tx_ring, skb, tx_flags, protocol, &hdr_len); - if (tso < 0) - goto out_drop; - else if (tso) + tso = ixgbe_tso(adapter, tx_ring, skb, tx_flags, &hdr_len, + protocol); + if (tso < 0) { + dev_kfree_skb_any(skb); + return NETDEV_TX_OK; + } + + if (tso) tx_flags |= IXGBE_TX_FLAGS_TSO; - else if (ixgbe_tx_csum(tx_ring, skb, tx_flags, protocol)) + else if (ixgbe_tx_csum(adapter, tx_ring, skb, tx_flags, + protocol) && + (skb->ip_summed == CHECKSUM_PARTIAL)) tx_flags |= IXGBE_TX_FLAGS_CSUM; } @@ -6909,16 +6956,12 @@ netdev_tx_t ixgbe_xmit_frame_ring(struct sk_buff *skb, ixgbe_maybe_stop_tx(tx_ring, DESC_NEEDED); } else { + dev_kfree_skb_any(skb); tx_ring->tx_buffer_info[first].time_stamp = 0; tx_ring->next_to_use = first; - goto out_drop; } return NETDEV_TX_OK; - -out_drop: - dev_kfree_skb_any(skb); - return NETDEV_TX_OK; } static netdev_tx_t ixgbe_xmit_frame(struct sk_buff *skb, struct net_device *netdev) diff --git a/trunk/drivers/net/ixgbe/ixgbe_sriov.c b/trunk/drivers/net/ixgbe/ixgbe_sriov.c index d99d01e21326..ac99b0458fe2 100644 --- a/trunk/drivers/net/ixgbe/ixgbe_sriov.c +++ b/trunk/drivers/net/ixgbe/ixgbe_sriov.c @@ -605,22 +605,6 @@ static void ixgbe_set_vf_rate_limit(struct ixgbe_hw *hw, int vf, int tx_rate, } IXGBE_WRITE_REG(hw, IXGBE_RTTDQSEL, 2*vf); /* vf Y uses queue 2*Y */ - /* - * Set global transmit compensation time to the MMW_SIZE in RTTBCNRM - * register. Typically MMW_SIZE=0x014 if 9728-byte jumbo is supported - * and 0x004 otherwise. - */ - switch (hw->mac.type) { - case ixgbe_mac_82599EB: - IXGBE_WRITE_REG(hw, IXGBE_RTTBCNRM, 0x4); - break; - case ixgbe_mac_X540: - IXGBE_WRITE_REG(hw, IXGBE_RTTBCNRM, 0x14); - break; - default: - break; - } - IXGBE_WRITE_REG(hw, IXGBE_RTTBCNRC, bcnrc_val); } diff --git a/trunk/drivers/net/ixgbe/ixgbe_type.h b/trunk/drivers/net/ixgbe/ixgbe_type.h index e0d970ebab7a..1eefc0c68409 100644 --- a/trunk/drivers/net/ixgbe/ixgbe_type.h +++ b/trunk/drivers/net/ixgbe/ixgbe_type.h @@ -534,7 +534,7 @@ #define IXGBE_RTTBCNRC_RF_INT_SHIFT 14 #define IXGBE_RTTBCNRC_RF_INT_MASK \ (IXGBE_RTTBCNRC_RF_DEC_MASK << IXGBE_RTTBCNRC_RF_INT_SHIFT) -#define IXGBE_RTTBCNRM 0x04980 + /* FCoE DMA Context Registers */ #define IXGBE_FCPTRL 0x02410 /* FC User Desc. PTR Low */ diff --git a/trunk/drivers/net/jme.c b/trunk/drivers/net/jme.c index 6b2a5e744255..b5b174a8c149 100644 --- a/trunk/drivers/net/jme.c +++ b/trunk/drivers/net/jme.c @@ -271,7 +271,9 @@ jme_reset_mac_processor(struct jme_adapter *jme) static inline void jme_clear_pm(struct jme_adapter *jme) { - jwrite32(jme, JME_PMCS, PMCS_STMASK | jme->reg_pmcs); + jwrite32(jme, JME_PMCS, 0xFFFF0000 | jme->reg_pmcs); + pci_set_power_state(jme->pdev, PCI_D0); + device_set_wakeup_enable(&jme->pdev->dev, false); } static int @@ -1815,9 +1817,11 @@ jme_powersave_phy(struct jme_adapter *jme) { if (jme->reg_pmcs) { jme_set_100m_half(jme); + if (jme->reg_pmcs & (PMCS_LFEN | PMCS_LREN)) jme_wait_link(jme); - jme_clear_pm(jme); + + jwrite32(jme, JME_PMCS, jme->reg_pmcs); } else { jme_phy_off(jme); } @@ -2525,7 +2529,8 @@ jme_set_wol(struct net_device *netdev, jme->reg_pmcs |= PMCS_MFEN; jwrite32(jme, JME_PMCS, jme->reg_pmcs); - device_set_wakeup_enable(&jme->pdev->dev, !!(jme->reg_pmcs)); + + device_set_wakeup_enable(&jme->pdev->dev, jme->reg_pmcs); return 0; } @@ -3053,9 +3058,6 @@ jme_init_one(struct pci_dev *pdev, jme->mii_if.mdio_write = jme_mdio_write; jme_clear_pm(jme); - pci_set_power_state(jme->pdev, PCI_D0); - device_set_wakeup_enable(&pdev->dev, true); - jme_set_phyfifo_5level(jme); jme->pcirev = pdev->revision; if (!jme->fpgaver) @@ -3133,9 +3135,8 @@ jme_shutdown(struct pci_dev *pdev) pci_pme_active(pdev, true); } -#ifdef CONFIG_PM_SLEEP -static int -jme_suspend(struct device *dev) +#ifdef CONFIG_PM +static int jme_suspend(struct device *dev) { struct pci_dev *pdev = to_pci_dev(dev); struct net_device *netdev = pci_get_drvdata(pdev); @@ -3174,14 +3175,14 @@ jme_suspend(struct device *dev) return 0; } -static int -jme_resume(struct device *dev) +static int jme_resume(struct device *dev) { struct pci_dev *pdev = to_pci_dev(dev); struct net_device *netdev = pci_get_drvdata(pdev); struct jme_adapter *jme = netdev_priv(netdev); - jme_clear_pm(jme); + jwrite32(jme, JME_PMCS, 0xFFFF0000 | jme->reg_pmcs); + jme_phy_on(jme); if (test_bit(JME_FLAG_SSET, &jme->flags)) jme_set_settings(netdev, &jme->old_ecmd); diff --git a/trunk/drivers/net/jme.h b/trunk/drivers/net/jme.h index 1481a62a1f36..0d5da06489d8 100644 --- a/trunk/drivers/net/jme.h +++ b/trunk/drivers/net/jme.h @@ -852,7 +852,6 @@ enum jme_ghc_txmac_clk { * Power management control and status register */ enum jme_pmcs_bit_masks { - PMCS_STMASK = 0xFFFF0000, PMCS_WF7DET = 0x80000000, PMCS_WF6DET = 0x40000000, PMCS_WF5DET = 0x20000000, @@ -864,7 +863,6 @@ enum jme_pmcs_bit_masks { PMCS_LFDET = 0x00040000, PMCS_LRDET = 0x00020000, PMCS_MFDET = 0x00010000, - PMCS_ENMASK = 0x0000FFFF, PMCS_WF7EN = 0x00008000, PMCS_WF6EN = 0x00004000, PMCS_WF5EN = 0x00002000, diff --git a/trunk/drivers/net/korina.c b/trunk/drivers/net/korina.c index 763844c587fd..c7a9bef4dfb0 100644 --- a/trunk/drivers/net/korina.c +++ b/trunk/drivers/net/korina.c @@ -504,7 +504,12 @@ static void korina_multicast_list(struct net_device *dev) hash_table[i] = 0; netdev_for_each_mc_addr(ha, dev) { - crc = ether_crc_le(6, ha->addr); + char *addrs = ha->addr; + + if (!(*addrs & 1)) + continue; + + crc = ether_crc_le(6, addrs); crc >>= 26; hash_table[crc >> 4] |= 1 << (15 - (crc & 0xf)); } diff --git a/trunk/drivers/net/ks8851_mll.c b/trunk/drivers/net/ks8851_mll.c index d19c849059d8..a82378231fc5 100644 --- a/trunk/drivers/net/ks8851_mll.c +++ b/trunk/drivers/net/ks8851_mll.c @@ -1190,6 +1190,8 @@ static void ks_set_rx_mode(struct net_device *netdev) int i = 0; netdev_for_each_mc_addr(ha, netdev) { + if (!(*ha->addr & 1)) + continue; if (i >= MAX_MCAST_LST) break; memcpy(ks->mcast_lst[i++], ha->addr, ETH_ALEN); diff --git a/trunk/drivers/net/ksz884x.c b/trunk/drivers/net/ksz884x.c index 27418d31a09f..2ac6c6c984b3 100644 --- a/trunk/drivers/net/ksz884x.c +++ b/trunk/drivers/net/ksz884x.c @@ -5785,6 +5785,8 @@ static void netdev_set_rx_mode(struct net_device *dev) } netdev_for_each_mc_addr(ha, dev) { + if (!(*ha->addr & 1)) + continue; if (i >= MAX_MULTICAST_LIST) break; memcpy(hw->multi_list[i++], ha->addr, MAC_ADDR_LEN); diff --git a/trunk/drivers/net/lib8390.c b/trunk/drivers/net/lib8390.c index 05ae21435bfd..70eb2077bd22 100644 --- a/trunk/drivers/net/lib8390.c +++ b/trunk/drivers/net/lib8390.c @@ -36,7 +36,7 @@ Paul Gortmaker : tweak ANK's above multicast changes a bit. Paul Gortmaker : update packet statistics for v2.1.x Alan Cox : support arbitrary stupid port mappings on the - 68K Macintosh. Support >16bit I/O spaces + 68K Macintosh. Support >16bit I/O spaces Paul Gortmaker : add kmod support for auto-loading of the 8390 module by all drivers that require it. Alan Cox : Spinlocking work, added 'BUG_83C690' @@ -58,8 +58,8 @@ #include #include #include -#include -#include +#include +#include #include #include #include @@ -108,6 +108,7 @@ int ei_debug = 1; /* Index to functions. */ static void ei_tx_intr(struct net_device *dev); static void ei_tx_err(struct net_device *dev); +void ei_tx_timeout(struct net_device *dev); static void ei_receive(struct net_device *dev); static void ei_rx_overrun(struct net_device *dev); @@ -205,19 +206,19 @@ static int __ei_open(struct net_device *dev) struct ei_device *ei_local = netdev_priv(dev); if (dev->watchdog_timeo <= 0) - dev->watchdog_timeo = TX_TIMEOUT; + dev->watchdog_timeo = TX_TIMEOUT; /* * Grab the page lock so we own the register set, then call * the init function. */ - spin_lock_irqsave(&ei_local->page_lock, flags); + spin_lock_irqsave(&ei_local->page_lock, flags); __NS8390_init(dev, 1); /* Set the flag before we drop the lock, That way the IRQ arrives after its set and we get no silly warnings */ netif_start_queue(dev); - spin_unlock_irqrestore(&ei_local->page_lock, flags); + spin_unlock_irqrestore(&ei_local->page_lock, flags); ei_local->irqlock = 0; return 0; } @@ -237,9 +238,9 @@ static int __ei_close(struct net_device *dev) * Hold the page lock during close */ - spin_lock_irqsave(&ei_local->page_lock, flags); + spin_lock_irqsave(&ei_local->page_lock, flags); __NS8390_init(dev, 0); - spin_unlock_irqrestore(&ei_local->page_lock, flags); + spin_unlock_irqrestore(&ei_local->page_lock, flags); netif_stop_queue(dev); return 0; } @@ -266,12 +267,12 @@ static void __ei_tx_timeout(struct net_device *dev) isr = ei_inb(e8390_base+EN0_ISR); spin_unlock_irqrestore(&ei_local->page_lock, flags); - netdev_dbg(dev, "Tx timed out, %s TSR=%#2x, ISR=%#2x, t=%d\n", - (txsr & ENTSR_ABT) ? "excess collisions." : - (isr) ? "lost interrupt?" : "cable problem?", - txsr, isr, tickssofar); + printk(KERN_DEBUG "%s: Tx timed out, %s TSR=%#2x, ISR=%#2x, t=%d.\n", + dev->name, (txsr & ENTSR_ABT) ? "excess collisions." : + (isr) ? "lost interrupt?" : "cable problem?", txsr, isr, tickssofar); - if (!isr && !dev->stats.tx_packets) { + if (!isr && !dev->stats.tx_packets) + { /* The 8390 probably hasn't gotten on the cable yet. */ ei_local->interface_num ^= 1; /* Try a different xcvr. */ } @@ -343,22 +344,27 @@ static netdev_tx_t __ei_start_xmit(struct sk_buff *skb, * card, leaving a substantial gap between each transmitted packet. */ - if (ei_local->tx1 == 0) { + if (ei_local->tx1 == 0) + { output_page = ei_local->tx_start_page; ei_local->tx1 = send_length; if (ei_debug && ei_local->tx2 > 0) - netdev_dbg(dev, "idle transmitter tx2=%d, lasttx=%d, txing=%d\n", - ei_local->tx2, ei_local->lasttx, ei_local->txing); - } else if (ei_local->tx2 == 0) { + printk(KERN_DEBUG "%s: idle transmitter tx2=%d, lasttx=%d, txing=%d.\n", + dev->name, ei_local->tx2, ei_local->lasttx, ei_local->txing); + } + else if (ei_local->tx2 == 0) + { output_page = ei_local->tx_start_page + TX_PAGES/2; ei_local->tx2 = send_length; if (ei_debug && ei_local->tx1 > 0) - netdev_dbg(dev, "idle transmitter, tx1=%d, lasttx=%d, txing=%d\n", - ei_local->tx1, ei_local->lasttx, ei_local->txing); - } else { /* We should never get here. */ + printk(KERN_DEBUG "%s: idle transmitter, tx1=%d, lasttx=%d, txing=%d.\n", + dev->name, ei_local->tx1, ei_local->lasttx, ei_local->txing); + } + else + { /* We should never get here. */ if (ei_debug) - netdev_dbg(dev, "No Tx buffers free! tx1=%d tx2=%d last=%d\n", - ei_local->tx1, ei_local->tx2, ei_local->lasttx); + printk(KERN_DEBUG "%s: No Tx buffers free! tx1=%d tx2=%d last=%d\n", + dev->name, ei_local->tx1, ei_local->tx2, ei_local->lasttx); ei_local->irqlock = 0; netif_stop_queue(dev); ei_outb_p(ENISR_ALL, e8390_base + EN0_IMR); @@ -376,18 +382,22 @@ static netdev_tx_t __ei_start_xmit(struct sk_buff *skb, ei_block_output(dev, send_length, data, output_page); - if (!ei_local->txing) { + if (! ei_local->txing) + { ei_local->txing = 1; NS8390_trigger_send(dev, send_length, output_page); - if (output_page == ei_local->tx_start_page) { + if (output_page == ei_local->tx_start_page) + { ei_local->tx1 = -1; ei_local->lasttx = -1; - } else { + } + else + { ei_local->tx2 = -1; ei_local->lasttx = -2; } - } else - ei_local->txqueue++; + } + else ei_local->txqueue++; if (ei_local->tx1 && ei_local->tx2) netif_stop_queue(dev); @@ -401,7 +411,7 @@ static netdev_tx_t __ei_start_xmit(struct sk_buff *skb, spin_unlock(&ei_local->page_lock); enable_irq_lockdep_irqrestore(dev->irq, &flags); skb_tx_timestamp(skb); - dev_kfree_skb(skb); + dev_kfree_skb (skb); dev->stats.tx_bytes += send_length; return NETDEV_TX_OK; @@ -432,13 +442,15 @@ static irqreturn_t __ei_interrupt(int irq, void *dev_id) spin_lock(&ei_local->page_lock); - if (ei_local->irqlock) { + if (ei_local->irqlock) + { /* * This might just be an interrupt for a PCI device sharing * this line */ - netdev_err(dev, "Interrupted while interrupts are masked! isr=%#2x imr=%#2x\n", - ei_inb_p(e8390_base + EN0_ISR), + printk("%s: Interrupted while interrupts are masked!" + " isr=%#2x imr=%#2x.\n", + dev->name, ei_inb_p(e8390_base + EN0_ISR), ei_inb_p(e8390_base + EN0_IMR)); spin_unlock(&ei_local->page_lock); return IRQ_NONE; @@ -447,14 +459,15 @@ static irqreturn_t __ei_interrupt(int irq, void *dev_id) /* Change to page 0 and read the intr status reg. */ ei_outb_p(E8390_NODMA+E8390_PAGE0, e8390_base + E8390_CMD); if (ei_debug > 3) - netdev_dbg(dev, "interrupt(isr=%#2.2x)\n", + printk(KERN_DEBUG "%s: interrupt(isr=%#2.2x).\n", dev->name, ei_inb_p(e8390_base + EN0_ISR)); /* !!Assumption!! -- we stay in page 0. Don't break this. */ while ((interrupts = ei_inb_p(e8390_base + EN0_ISR)) != 0 && - ++nr_serviced < MAX_SERVICE) { + ++nr_serviced < MAX_SERVICE) + { if (!netif_running(dev)) { - netdev_warn(dev, "interrupt from stopped card\n"); + printk(KERN_WARNING "%s: interrupt from stopped card\n", dev->name); /* rmk - acknowledge the interrupts */ ei_outb_p(interrupts, e8390_base + EN0_ISR); interrupts = 0; @@ -462,7 +475,8 @@ static irqreturn_t __ei_interrupt(int irq, void *dev_id) } if (interrupts & ENISR_OVER) ei_rx_overrun(dev); - else if (interrupts & (ENISR_RX+ENISR_RX_ERR)) { + else if (interrupts & (ENISR_RX+ENISR_RX_ERR)) + { /* Got a good (?) packet. */ ei_receive(dev); } @@ -472,30 +486,35 @@ static irqreturn_t __ei_interrupt(int irq, void *dev_id) else if (interrupts & ENISR_TX_ERR) ei_tx_err(dev); - if (interrupts & ENISR_COUNTERS) { + if (interrupts & ENISR_COUNTERS) + { dev->stats.rx_frame_errors += ei_inb_p(e8390_base + EN0_COUNTER0); dev->stats.rx_crc_errors += ei_inb_p(e8390_base + EN0_COUNTER1); - dev->stats.rx_missed_errors += ei_inb_p(e8390_base + EN0_COUNTER2); + dev->stats.rx_missed_errors+= ei_inb_p(e8390_base + EN0_COUNTER2); ei_outb_p(ENISR_COUNTERS, e8390_base + EN0_ISR); /* Ack intr. */ } /* Ignore any RDC interrupts that make it back to here. */ if (interrupts & ENISR_RDC) + { ei_outb_p(ENISR_RDC, e8390_base + EN0_ISR); + } ei_outb_p(E8390_NODMA+E8390_PAGE0+E8390_START, e8390_base + E8390_CMD); } - if (interrupts && ei_debug) { + if (interrupts && ei_debug) + { ei_outb_p(E8390_NODMA+E8390_PAGE0+E8390_START, e8390_base + E8390_CMD); - if (nr_serviced >= MAX_SERVICE) { + if (nr_serviced >= MAX_SERVICE) + { /* 0xFF is valid for a card removal */ - if (interrupts != 0xFF) - netdev_warn(dev, "Too much work at interrupt, status %#2.2x\n", - interrupts); + if(interrupts!=0xFF) + printk(KERN_WARNING "%s: Too much work at interrupt, status %#2.2x\n", + dev->name, interrupts); ei_outb_p(ENISR_ALL, e8390_base + EN0_ISR); /* Ack. most intrs. */ } else { - netdev_warn(dev, "unknown interrupt %#2x\n", interrupts); + printk(KERN_WARNING "%s: unknown interrupt %#2x\n", dev->name, interrupts); ei_outb_p(0xff, e8390_base + EN0_ISR); /* Ack. all intrs. */ } } @@ -535,32 +554,30 @@ static void ei_tx_err(struct net_device *dev) unsigned char tx_was_aborted = txsr & (ENTSR_ABT+ENTSR_FU); #ifdef VERBOSE_ERROR_DUMP - netdev_dbg(dev, "transmitter error (%#2x):", txsr); + printk(KERN_DEBUG "%s: transmitter error (%#2x): ", dev->name, txsr); if (txsr & ENTSR_ABT) - pr_cont(" excess-collisions "); + printk("excess-collisions "); if (txsr & ENTSR_ND) - pr_cont(" non-deferral "); + printk("non-deferral "); if (txsr & ENTSR_CRS) - pr_cont(" lost-carrier "); + printk("lost-carrier "); if (txsr & ENTSR_FU) - pr_cont(" FIFO-underrun "); + printk("FIFO-underrun "); if (txsr & ENTSR_CDH) - pr_cont(" lost-heartbeat "); - pr_cont("\n"); + printk("lost-heartbeat "); + printk("\n"); #endif ei_outb_p(ENISR_TX_ERR, e8390_base + EN0_ISR); /* Ack intr. */ if (tx_was_aborted) ei_tx_intr(dev); - else { + else + { dev->stats.tx_errors++; - if (txsr & ENTSR_CRS) - dev->stats.tx_carrier_errors++; - if (txsr & ENTSR_CDH) - dev->stats.tx_heartbeat_errors++; - if (txsr & ENTSR_OWC) - dev->stats.tx_window_errors++; + if (txsr & ENTSR_CRS) dev->stats.tx_carrier_errors++; + if (txsr & ENTSR_CDH) dev->stats.tx_heartbeat_errors++; + if (txsr & ENTSR_OWC) dev->stats.tx_window_errors++; } } @@ -586,45 +603,52 @@ static void ei_tx_intr(struct net_device *dev) */ ei_local->txqueue--; - if (ei_local->tx1 < 0) { + if (ei_local->tx1 < 0) + { if (ei_local->lasttx != 1 && ei_local->lasttx != -1) - pr_err("%s: bogus last_tx_buffer %d, tx1=%d\n", - ei_local->name, ei_local->lasttx, ei_local->tx1); + printk(KERN_ERR "%s: bogus last_tx_buffer %d, tx1=%d.\n", + ei_local->name, ei_local->lasttx, ei_local->tx1); ei_local->tx1 = 0; - if (ei_local->tx2 > 0) { + if (ei_local->tx2 > 0) + { ei_local->txing = 1; NS8390_trigger_send(dev, ei_local->tx2, ei_local->tx_start_page + 6); dev->trans_start = jiffies; ei_local->tx2 = -1, ei_local->lasttx = 2; - } else - ei_local->lasttx = 20, ei_local->txing = 0; - } else if (ei_local->tx2 < 0) { + } + else ei_local->lasttx = 20, ei_local->txing = 0; + } + else if (ei_local->tx2 < 0) + { if (ei_local->lasttx != 2 && ei_local->lasttx != -2) - pr_err("%s: bogus last_tx_buffer %d, tx2=%d\n", - ei_local->name, ei_local->lasttx, ei_local->tx2); + printk("%s: bogus last_tx_buffer %d, tx2=%d.\n", + ei_local->name, ei_local->lasttx, ei_local->tx2); ei_local->tx2 = 0; - if (ei_local->tx1 > 0) { + if (ei_local->tx1 > 0) + { ei_local->txing = 1; NS8390_trigger_send(dev, ei_local->tx1, ei_local->tx_start_page); dev->trans_start = jiffies; ei_local->tx1 = -1; ei_local->lasttx = 1; - } else + } + else ei_local->lasttx = 10, ei_local->txing = 0; - } /* else - netdev_warn(dev, "unexpected TX-done interrupt, lasttx=%d\n", - ei_local->lasttx); -*/ + } +// else printk(KERN_WARNING "%s: unexpected TX-done interrupt, lasttx=%d.\n", +// dev->name, ei_local->lasttx); /* Minimize Tx latency: update the statistics after we restart TXing. */ if (status & ENTSR_COL) dev->stats.collisions++; if (status & ENTSR_PTX) dev->stats.tx_packets++; - else { + else + { dev->stats.tx_errors++; - if (status & ENTSR_ABT) { + if (status & ENTSR_ABT) + { dev->stats.tx_aborted_errors++; dev->stats.collisions += 16; } @@ -658,7 +682,8 @@ static void ei_receive(struct net_device *dev) struct e8390_pkt_hdr rx_frame; int num_rx_pages = ei_local->stop_page-ei_local->rx_start_page; - while (++rx_pkt_count < 10) { + while (++rx_pkt_count < 10) + { int pkt_len, pkt_stat; /* Get the rx page (incoming packet pointer). */ @@ -677,11 +702,9 @@ static void ei_receive(struct net_device *dev) Keep quiet if it looks like a card removal. One problem here is that some clones crash in roughly the same way. */ - if (ei_debug > 0 && - this_frame != ei_local->current_page && - (this_frame != 0x0 || rxing_page != 0xFF)) - netdev_err(dev, "mismatched read page pointers %2x vs %2x\n", - this_frame, ei_local->current_page); + if (ei_debug > 0 && this_frame != ei_local->current_page && (this_frame!=0x0 || rxing_page!=0xFF)) + printk(KERN_ERR "%s: mismatched read page pointers %2x vs %2x.\n", + dev->name, this_frame, ei_local->current_page); if (this_frame == rxing_page) /* Read all the frames? */ break; /* Done for now */ @@ -707,28 +730,34 @@ static void ei_receive(struct net_device *dev) continue; } - if (pkt_len < 60 || pkt_len > 1518) { + if (pkt_len < 60 || pkt_len > 1518) + { if (ei_debug) - netdev_dbg(dev, "bogus packet size: %d, status=%#2x nxpg=%#2x\n", - rx_frame.count, rx_frame.status, + printk(KERN_DEBUG "%s: bogus packet size: %d, status=%#2x nxpg=%#2x.\n", + dev->name, rx_frame.count, rx_frame.status, rx_frame.next); dev->stats.rx_errors++; dev->stats.rx_length_errors++; - } else if ((pkt_stat & 0x0F) == ENRSR_RXOK) { + } + else if ((pkt_stat & 0x0F) == ENRSR_RXOK) + { struct sk_buff *skb; skb = dev_alloc_skb(pkt_len+2); - if (skb == NULL) { + if (skb == NULL) + { if (ei_debug > 1) - netdev_dbg(dev, "Couldn't allocate a sk_buff of size %d\n", - pkt_len); + printk(KERN_DEBUG "%s: Couldn't allocate a sk_buff of size %d.\n", + dev->name, pkt_len); dev->stats.rx_dropped++; break; - } else { - skb_reserve(skb, 2); /* IP headers on 16 byte boundaries */ + } + else + { + skb_reserve(skb,2); /* IP headers on 16 byte boundaries */ skb_put(skb, pkt_len); /* Make room */ ei_block_input(dev, pkt_len, skb, current_offset + sizeof(rx_frame)); - skb->protocol = eth_type_trans(skb, dev); + skb->protocol=eth_type_trans(skb,dev); if (!skb_defer_rx_timestamp(skb)) netif_rx(skb); dev->stats.rx_packets++; @@ -736,10 +765,12 @@ static void ei_receive(struct net_device *dev) if (pkt_stat & ENRSR_PHY) dev->stats.multicast++; } - } else { + } + else + { if (ei_debug) - netdev_dbg(dev, "bogus packet: status=%#2x nxpg=%#2x size=%d\n", - rx_frame.status, rx_frame.next, + printk(KERN_DEBUG "%s: bogus packet: status=%#2x nxpg=%#2x size=%d\n", + dev->name, rx_frame.status, rx_frame.next, rx_frame.count); dev->stats.rx_errors++; /* NB: The NIC counts CRC, frame and missed errors. */ @@ -750,8 +781,8 @@ static void ei_receive(struct net_device *dev) /* This _should_ never happen: it's here for avoiding bad clones. */ if (next_frame >= ei_local->stop_page) { - netdev_notice(dev, "next frame inconsistency, %#2x\n", - next_frame); + printk("%s: next frame inconsistency, %#2x\n", dev->name, + next_frame); next_frame = ei_local->rx_start_page; } ei_local->current_page = next_frame; @@ -791,7 +822,7 @@ static void ei_rx_overrun(struct net_device *dev) ei_outb_p(E8390_NODMA+E8390_PAGE0+E8390_STOP, e8390_base+E8390_CMD); if (ei_debug > 1) - netdev_dbg(dev, "Receiver overrun\n"); + printk(KERN_DEBUG "%s: Receiver overrun.\n", dev->name); dev->stats.rx_over_errors++; /* @@ -814,7 +845,8 @@ static void ei_rx_overrun(struct net_device *dev) * step is vital, and skipping it will cause no end of havoc. */ - if (was_txing) { + if (was_txing) + { unsigned char tx_completed = ei_inb_p(e8390_base+EN0_ISR) & (ENISR_TX+ENISR_TX_ERR); if (!tx_completed) must_resend = 1; @@ -838,7 +870,7 @@ static void ei_rx_overrun(struct net_device *dev) */ ei_outb_p(E8390_TXCONFIG, e8390_base + EN0_TXCR); if (must_resend) - ei_outb_p(E8390_NODMA + E8390_PAGE0 + E8390_START + E8390_TRANS, e8390_base + E8390_CMD); + ei_outb_p(E8390_NODMA + E8390_PAGE0 + E8390_START + E8390_TRANS, e8390_base + E8390_CMD); } /* @@ -855,11 +887,11 @@ static struct net_device_stats *__ei_get_stats(struct net_device *dev) if (!netif_running(dev)) return &dev->stats; - spin_lock_irqsave(&ei_local->page_lock, flags); + spin_lock_irqsave(&ei_local->page_lock,flags); /* Read the counter registers, assuming we are in page 0. */ - dev->stats.rx_frame_errors += ei_inb_p(ioaddr + EN0_COUNTER0); - dev->stats.rx_crc_errors += ei_inb_p(ioaddr + EN0_COUNTER1); - dev->stats.rx_missed_errors += ei_inb_p(ioaddr + EN0_COUNTER2); + dev->stats.rx_frame_errors += ei_inb_p(ioaddr + EN0_COUNTER0); + dev->stats.rx_crc_errors += ei_inb_p(ioaddr + EN0_COUNTER1); + dev->stats.rx_missed_errors+= ei_inb_p(ioaddr + EN0_COUNTER2); spin_unlock_irqrestore(&ei_local->page_lock, flags); return &dev->stats; @@ -898,11 +930,13 @@ static void do_set_multicast_list(struct net_device *dev) int i; struct ei_device *ei_local = netdev_priv(dev); - if (!(dev->flags&(IFF_PROMISC|IFF_ALLMULTI))) { + if (!(dev->flags&(IFF_PROMISC|IFF_ALLMULTI))) + { memset(ei_local->mcfilter, 0, 8); if (!netdev_mc_empty(dev)) make_mc_bits(ei_local->mcfilter, dev); - } else + } + else memset(ei_local->mcfilter, 0xFF, 8); /* mcast set to accept-all */ /* @@ -921,23 +955,23 @@ static void do_set_multicast_list(struct net_device *dev) if (netif_running(dev)) ei_outb_p(E8390_RXCONFIG, e8390_base + EN0_RXCR); ei_outb_p(E8390_NODMA + E8390_PAGE1, e8390_base + E8390_CMD); - for (i = 0; i < 8; i++) { + for(i = 0; i < 8; i++) + { ei_outb_p(ei_local->mcfilter[i], e8390_base + EN1_MULT_SHIFT(i)); #ifndef BUG_83C690 - if (ei_inb_p(e8390_base + EN1_MULT_SHIFT(i)) != ei_local->mcfilter[i]) - netdev_err(dev, "Multicast filter read/write mismap %d\n", - i); + if(ei_inb_p(e8390_base + EN1_MULT_SHIFT(i))!=ei_local->mcfilter[i]) + printk(KERN_ERR "Multicast filter read/write mismap %d\n",i); #endif } ei_outb_p(E8390_NODMA + E8390_PAGE0, e8390_base + E8390_CMD); - if (dev->flags&IFF_PROMISC) - ei_outb_p(E8390_RXCONFIG | 0x18, e8390_base + EN0_RXCR); + if(dev->flags&IFF_PROMISC) + ei_outb_p(E8390_RXCONFIG | 0x18, e8390_base + EN0_RXCR); else if (dev->flags & IFF_ALLMULTI || !netdev_mc_empty(dev)) - ei_outb_p(E8390_RXCONFIG | 0x08, e8390_base + EN0_RXCR); - else - ei_outb_p(E8390_RXCONFIG, e8390_base + EN0_RXCR); -} + ei_outb_p(E8390_RXCONFIG | 0x08, e8390_base + EN0_RXCR); + else + ei_outb_p(E8390_RXCONFIG, e8390_base + EN0_RXCR); + } /* * Called without lock held. This is invoked from user context and may @@ -1009,8 +1043,8 @@ static void __NS8390_init(struct net_device *dev, int startp) ? (0x48 | ENDCFG_WTS | (ei_local->bigendian ? ENDCFG_BOS : 0)) : 0x48; - if (sizeof(struct e8390_pkt_hdr) != 4) - panic("8390.c: header struct mispacked\n"); + if(sizeof(struct e8390_pkt_hdr)!=4) + panic("8390.c: header struct mispacked\n"); /* Follow National Semi's recommendations for initing the DP83902. */ ei_outb_p(E8390_NODMA+E8390_PAGE0+E8390_STOP, e8390_base+E8390_CMD); /* 0x21 */ ei_outb_p(endcfg, e8390_base + EN0_DCFG); /* 0x48 or 0x49 */ @@ -1034,11 +1068,11 @@ static void __NS8390_init(struct net_device *dev, int startp) /* Copy the station address into the DS8390 registers. */ ei_outb_p(E8390_NODMA + E8390_PAGE1 + E8390_STOP, e8390_base+E8390_CMD); /* 0x61 */ - for (i = 0; i < 6; i++) { + for(i = 0; i < 6; i++) + { ei_outb_p(dev->dev_addr[i], e8390_base + EN1_PHYS_SHIFT(i)); - if (ei_debug > 1 && - ei_inb_p(e8390_base + EN1_PHYS_SHIFT(i)) != dev->dev_addr[i]) - netdev_err(dev, "Hw. address read/write mismap %d\n", i); + if (ei_debug > 1 && ei_inb_p(e8390_base + EN1_PHYS_SHIFT(i))!=dev->dev_addr[i]) + printk(KERN_ERR "Hw. address read/write mismap %d\n",i); } ei_outb_p(ei_local->rx_start_page, e8390_base + EN1_CURPAG); @@ -1047,7 +1081,8 @@ static void __NS8390_init(struct net_device *dev, int startp) ei_local->tx1 = ei_local->tx2 = 0; ei_local->txing = 0; - if (startp) { + if (startp) + { ei_outb_p(0xff, e8390_base + EN0_ISR); ei_outb_p(ENISR_ALL, e8390_base + EN0_IMR); ei_outb_p(E8390_NODMA+E8390_PAGE0+E8390_START, e8390_base+E8390_CMD); @@ -1065,12 +1100,14 @@ static void NS8390_trigger_send(struct net_device *dev, unsigned int length, int start_page) { unsigned long e8390_base = dev->base_addr; - struct ei_device *ei_local __attribute((unused)) = netdev_priv(dev); + struct ei_device *ei_local __attribute((unused)) = netdev_priv(dev); ei_outb_p(E8390_NODMA+E8390_PAGE0, e8390_base+E8390_CMD); - if (ei_inb_p(e8390_base + E8390_CMD) & E8390_TRANS) { - netdev_warn(dev, "trigger_send() called with the transmitter busy\n"); + if (ei_inb_p(e8390_base + E8390_CMD) & E8390_TRANS) + { + printk(KERN_WARNING "%s: trigger_send() called with the transmitter busy.\n", + dev->name); return; } ei_outb_p(length & 0xff, e8390_base + EN0_TCNTLO); diff --git a/trunk/drivers/net/ll_temac_main.c b/trunk/drivers/net/ll_temac_main.c index 728fe414147a..e3f19255af28 100644 --- a/trunk/drivers/net/ll_temac_main.c +++ b/trunk/drivers/net/ll_temac_main.c @@ -49,7 +49,6 @@ #include #include #include -#include #include "ll_temac.h" diff --git a/trunk/drivers/net/macvtap.c b/trunk/drivers/net/macvtap.c index ab96c319a240..ecee0fe65a97 100644 --- a/trunk/drivers/net/macvtap.c +++ b/trunk/drivers/net/macvtap.c @@ -60,7 +60,6 @@ static struct proto macvtap_proto = { */ static dev_t macvtap_major; #define MACVTAP_NUM_DEVS 65536 -#define GOODCOPY_LEN 128 static struct class *macvtap_class; static struct cdev macvtap_cdev; @@ -341,7 +340,6 @@ static int macvtap_open(struct inode *inode, struct file *file) { struct net *net = current->nsproxy->net_ns; struct net_device *dev = dev_get_by_index(net, iminor(inode)); - struct macvlan_dev *vlan = netdev_priv(dev); struct macvtap_queue *q; int err; @@ -371,16 +369,6 @@ static int macvtap_open(struct inode *inode, struct file *file) q->flags = IFF_VNET_HDR | IFF_NO_PI | IFF_TAP; q->vnet_hdr_sz = sizeof(struct virtio_net_hdr); - /* - * so far only KVM virtio_net uses macvtap, enable zero copy between - * guest kernel and host kernel when lower device supports zerocopy - */ - if (vlan) { - if ((vlan->lowerdev->features & NETIF_F_HIGHDMA) && - (vlan->lowerdev->features & NETIF_F_SG)) - sock_set_flag(&q->sk, SOCK_ZEROCOPY); - } - err = macvtap_set_queue(dev, file, q); if (err) sock_put(&q->sk); @@ -445,80 +433,6 @@ static inline struct sk_buff *macvtap_alloc_skb(struct sock *sk, size_t prepad, return skb; } -/* set skb frags from iovec, this can move to core network code for reuse */ -static int zerocopy_sg_from_iovec(struct sk_buff *skb, const struct iovec *from, - int offset, size_t count) -{ - int len = iov_length(from, count) - offset; - int copy = skb_headlen(skb); - int size, offset1 = 0; - int i = 0; - skb_frag_t *f; - - /* Skip over from offset */ - while (count && (offset >= from->iov_len)) { - offset -= from->iov_len; - ++from; - --count; - } - - /* copy up to skb headlen */ - while (count && (copy > 0)) { - size = min_t(unsigned int, copy, from->iov_len - offset); - if (copy_from_user(skb->data + offset1, from->iov_base + offset, - size)) - return -EFAULT; - if (copy > size) { - ++from; - --count; - } - copy -= size; - offset1 += size; - offset = 0; - } - - if (len == offset1) - return 0; - - while (count--) { - struct page *page[MAX_SKB_FRAGS]; - int num_pages; - unsigned long base; - - len = from->iov_len - offset1; - if (!len) { - offset1 = 0; - ++from; - continue; - } - base = (unsigned long)from->iov_base + offset1; - size = ((base & ~PAGE_MASK) + len + ~PAGE_MASK) >> PAGE_SHIFT; - num_pages = get_user_pages_fast(base, size, 0, &page[i]); - if ((num_pages != size) || - (num_pages > MAX_SKB_FRAGS - skb_shinfo(skb)->nr_frags)) - /* put_page is in skb free */ - return -EFAULT; - skb->data_len += len; - skb->len += len; - skb->truesize += len; - atomic_add(len, &skb->sk->sk_wmem_alloc); - while (len) { - f = &skb_shinfo(skb)->frags[i]; - f->page = page[i]; - f->page_offset = base & ~PAGE_MASK; - f->size = min_t(int, len, PAGE_SIZE - f->page_offset); - skb_shinfo(skb)->nr_frags++; - /* increase sk_wmem_alloc */ - base += f->size; - len -= f->size; - i++; - } - offset1 = 0; - ++from; - } - return 0; -} - /* * macvtap_skb_from_vnet_hdr and macvtap_skb_to_vnet_hdr should * be shared with the tun/tap driver. @@ -603,18 +517,16 @@ static int macvtap_skb_to_vnet_hdr(const struct sk_buff *skb, /* Get packet from user space buffer */ -static ssize_t macvtap_get_user(struct macvtap_queue *q, struct msghdr *m, - const struct iovec *iv, unsigned long total_len, - size_t count, int noblock) +static ssize_t macvtap_get_user(struct macvtap_queue *q, + const struct iovec *iv, size_t count, + int noblock) { struct sk_buff *skb; struct macvlan_dev *vlan; - unsigned long len = total_len; + size_t len = count; int err; struct virtio_net_hdr vnet_hdr = { 0 }; int vnet_hdr_len = 0; - int copylen; - bool zerocopy = false; if (q->flags & IFF_VNET_HDR) { vnet_hdr_len = q->vnet_hdr_sz; @@ -642,31 +554,12 @@ static ssize_t macvtap_get_user(struct macvtap_queue *q, struct msghdr *m, if (unlikely(len < ETH_HLEN)) goto err; - if (m && m->msg_control && sock_flag(&q->sk, SOCK_ZEROCOPY)) - zerocopy = true; - - if (zerocopy) { - /* There are 256 bytes to be copied in skb, so there is enough - * room for skb expand head in case it is used. - * The rest buffer is mapped from userspace. - */ - copylen = vnet_hdr.hdr_len; - if (!copylen) - copylen = GOODCOPY_LEN; - } else - copylen = len; - - skb = macvtap_alloc_skb(&q->sk, NET_IP_ALIGN, copylen, - vnet_hdr.hdr_len, noblock, &err); + skb = macvtap_alloc_skb(&q->sk, NET_IP_ALIGN, len, vnet_hdr.hdr_len, + noblock, &err); if (!skb) goto err; - if (zerocopy) { - err = zerocopy_sg_from_iovec(skb, iv, vnet_hdr_len, count); - skb_shinfo(skb)->tx_flags |= SKBTX_DEV_ZEROCOPY; - } else - err = skb_copy_datagram_from_iovec(skb, 0, iv, vnet_hdr_len, - len); + err = skb_copy_datagram_from_iovec(skb, 0, iv, vnet_hdr_len, len); if (err) goto err_kfree; @@ -682,16 +575,13 @@ static ssize_t macvtap_get_user(struct macvtap_queue *q, struct msghdr *m, rcu_read_lock_bh(); vlan = rcu_dereference_bh(q->vlan); - /* copy skb_ubuf_info for callback when skb has no error */ - if (zerocopy) - skb_shinfo(skb)->destructor_arg = m->msg_control; if (vlan) macvlan_start_xmit(skb, vlan->dev); else kfree_skb(skb); rcu_read_unlock_bh(); - return total_len; + return count; err_kfree: kfree_skb(skb); @@ -713,8 +603,8 @@ static ssize_t macvtap_aio_write(struct kiocb *iocb, const struct iovec *iv, ssize_t result = -ENOLINK; struct macvtap_queue *q = file->private_data; - result = macvtap_get_user(q, NULL, iv, iov_length(iv, count), count, - file->f_flags & O_NONBLOCK); + result = macvtap_get_user(q, iv, iov_length(iv, count), + file->f_flags & O_NONBLOCK); return result; } @@ -927,7 +817,7 @@ static int macvtap_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *m, size_t total_len) { struct macvtap_queue *q = container_of(sock, struct macvtap_queue, sock); - return macvtap_get_user(q, m, m->msg_iov, total_len, m->msg_iovlen, + return macvtap_get_user(q, m->msg_iov, total_len, m->msg_flags & MSG_DONTWAIT); } diff --git a/trunk/drivers/net/mlx4/main.c b/trunk/drivers/net/mlx4/main.c index 0cb0431ee19c..3814fc9b1145 100644 --- a/trunk/drivers/net/mlx4/main.c +++ b/trunk/drivers/net/mlx4/main.c @@ -1230,11 +1230,11 @@ static int __mlx4_init_one(struct pci_dev *pdev, const struct pci_device_id *id) INIT_LIST_HEAD(&priv->pgdir_list); mutex_init(&priv->pgdir_mutex); + pci_read_config_byte(pdev, PCI_REVISION_ID, &dev->rev_id); + INIT_LIST_HEAD(&priv->bf_list); mutex_init(&priv->bf_mutex); - dev->rev_id = pdev->revision; - /* * Now reset the HCA before we touch the PCI capabilities or * attempt a firmware command, since a boot ROM may have left diff --git a/trunk/drivers/net/mlx4/reset.c b/trunk/drivers/net/mlx4/reset.c index 11e7c1cb99bf..e5741dab3825 100644 --- a/trunk/drivers/net/mlx4/reset.c +++ b/trunk/drivers/net/mlx4/reset.c @@ -77,7 +77,7 @@ int mlx4_reset(struct mlx4_dev *dev) goto out; } - pcie_cap = pci_pcie_cap(dev->pdev); + pcie_cap = pci_find_capability(dev->pdev, PCI_CAP_ID_EXP); for (i = 0; i < 64; ++i) { if (i == 22 || i == 23) diff --git a/trunk/drivers/net/myri10ge/myri10ge.c b/trunk/drivers/net/myri10ge/myri10ge.c index 1d2247554a35..3ed5f3505cea 100644 --- a/trunk/drivers/net/myri10ge/myri10ge.c +++ b/trunk/drivers/net/myri10ge/myri10ge.c @@ -1,7 +1,7 @@ /************************************************************************* * myri10ge.c: Myricom Myri-10G Ethernet driver. * - * Copyright (C) 2005 - 2011 Myricom, Inc. + * Copyright (C) 2005 - 2009 Myricom, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -79,7 +79,7 @@ #include "myri10ge_mcp.h" #include "myri10ge_mcp_gen_header.h" -#define MYRI10GE_VERSION_STR "1.5.3-1.534" +#define MYRI10GE_VERSION_STR "1.5.2-1.459" MODULE_DESCRIPTION("Myricom 10G driver (10GbE)"); MODULE_AUTHOR("Maintainer: help@myri.com"); @@ -193,7 +193,6 @@ struct myri10ge_slice_state { int watchdog_tx_done; int watchdog_tx_req; int watchdog_rx_done; - int stuck; #ifdef CONFIG_MYRI10GE_DCA int cached_dca_tag; int cpu; @@ -1081,14 +1080,11 @@ static int myri10ge_toggle_relaxed(struct pci_dev *pdev, int on) int ret, cap, err; u16 ctl; - cap = pci_pcie_cap(pdev); + cap = pci_find_capability(pdev, PCI_CAP_ID_EXP); if (!cap) return 0; err = pci_read_config_word(pdev, cap + PCI_EXP_DEVCTL, &ctl); - if (err) - return 0; - ret = (ctl & PCI_EXP_DEVCTL_RELAX_EN) >> 4; if (ret != on) { ctl &= ~PCI_EXP_DEVCTL_RELAX_EN; @@ -1143,19 +1139,20 @@ static void myri10ge_setup_dca(struct myri10ge_priv *mgp) mgp->ss[i].cpu = -1; mgp->ss[i].cached_dca_tag = -1; myri10ge_update_dca(&mgp->ss[i]); - } + } } static void myri10ge_teardown_dca(struct myri10ge_priv *mgp) { struct pci_dev *pdev = mgp->pdev; + int err; if (!mgp->dca_enabled) return; mgp->dca_enabled = 0; if (mgp->relaxed_order) myri10ge_toggle_relaxed(pdev, 1); - dca_remove_requester(&pdev->dev); + err = dca_remove_requester(&pdev->dev); } static int myri10ge_notify_dca_device(struct device *dev, void *data) @@ -1316,7 +1313,7 @@ myri10ge_unmap_rx_page(struct pci_dev *pdev, static inline int myri10ge_rx_done(struct myri10ge_slice_state *ss, int len, __wsum csum, - bool lro_enabled) + int lro_enabled) { struct myri10ge_priv *mgp = ss->mgp; struct sk_buff *skb; @@ -1464,8 +1461,7 @@ myri10ge_tx_done(struct myri10ge_slice_state *ss, int mcp_index) /* start the queue if we've stopped it */ if (netif_tx_queue_stopped(dev_queue) && - tx->req - tx->done < (tx->mask >> 1) && - ss->mgp->running == MYRI10GE_ETH_RUNNING) { + tx->req - tx->done < (tx->mask >> 1)) { tx->wake_queue++; netif_tx_wake_queue(dev_queue); } @@ -1476,9 +1472,11 @@ myri10ge_clean_rx_done(struct myri10ge_slice_state *ss, int budget) { struct myri10ge_rx_done *rx_done = &ss->rx_done; struct myri10ge_priv *mgp = ss->mgp; + unsigned long rx_bytes = 0; unsigned long rx_packets = 0; unsigned long rx_ok; + int idx = rx_done->idx; int cnt = rx_done->cnt; int work_done = 0; @@ -1531,14 +1529,16 @@ static inline void myri10ge_check_statblock(struct myri10ge_priv *mgp) mgp->link_state = link_up; if (mgp->link_state == MXGEFW_LINK_UP) { - netif_info(mgp, link, mgp->dev, "link up\n"); + if (netif_msg_link(mgp)) + netdev_info(mgp->dev, "link up\n"); netif_carrier_on(mgp->dev); mgp->link_changes++; } else { - netif_info(mgp, link, mgp->dev, "link %s\n", - (link_up == MXGEFW_LINK_MYRINET ? + if (netif_msg_link(mgp)) + netdev_info(mgp->dev, "link %s\n", + link_up == MXGEFW_LINK_MYRINET ? "mismatch (Myrinet detected)" : - "down")); + "down"); netif_carrier_off(mgp->dev); mgp->link_changes++; } @@ -1619,7 +1619,7 @@ static irqreturn_t myri10ge_intr(int irq, void *arg) if (send_done_count != tx->pkt_done) myri10ge_tx_done(ss, (int)send_done_count); if (unlikely(i > myri10ge_max_irq_loops)) { - netdev_warn(mgp->dev, "irq stuck?\n"); + netdev_err(mgp->dev, "irq stuck?\n"); stats->valid = 0; schedule_work(&mgp->watchdog_work); } @@ -1783,8 +1783,9 @@ static const char myri10ge_gstrings_slice_stats[][ETH_GSTRING_LEN] = { "----------- slice ---------", "tx_pkt_start", "tx_pkt_done", "tx_req", "tx_done", "rx_small_cnt", "rx_big_cnt", - "wake_queue", "stop_queue", "tx_linearized", - "LRO aggregated", "LRO flushed", "LRO avg aggr", "LRO no_desc", + "wake_queue", "stop_queue", "tx_linearized", "LRO aggregated", + "LRO flushed", + "LRO avg aggr", "LRO no_desc" }; #define MYRI10GE_NET_STATS_LEN 21 @@ -1908,60 +1909,6 @@ static u32 myri10ge_get_msglevel(struct net_device *netdev) return mgp->msg_enable; } -/* - * Use a low-level command to change the LED behavior. Rather than - * blinking (which is the normal case), when identify is used, the - * yellow LED turns solid. - */ -static int myri10ge_led(struct myri10ge_priv *mgp, int on) -{ - struct mcp_gen_header *hdr; - struct device *dev = &mgp->pdev->dev; - size_t hdr_off, pattern_off, hdr_len; - u32 pattern = 0xfffffffe; - - /* find running firmware header */ - hdr_off = swab32(readl(mgp->sram + MCP_HEADER_PTR_OFFSET)); - if ((hdr_off & 3) || hdr_off + sizeof(*hdr) > mgp->sram_size) { - dev_err(dev, "Running firmware has bad header offset (%d)\n", - (int)hdr_off); - return -EIO; - } - hdr_len = swab32(readl(mgp->sram + hdr_off + - offsetof(struct mcp_gen_header, header_length))); - pattern_off = hdr_off + offsetof(struct mcp_gen_header, led_pattern); - if (pattern_off >= (hdr_len + hdr_off)) { - dev_info(dev, "Firmware does not support LED identification\n"); - return -EINVAL; - } - if (!on) - pattern = swab32(readl(mgp->sram + pattern_off + 4)); - writel(htonl(pattern), mgp->sram + pattern_off); - return 0; -} - -static int -myri10ge_phys_id(struct net_device *netdev, enum ethtool_phys_id_state state) -{ - struct myri10ge_priv *mgp = netdev_priv(netdev); - int rc; - - switch (state) { - case ETHTOOL_ID_ACTIVE: - rc = myri10ge_led(mgp, 1); - break; - - case ETHTOOL_ID_INACTIVE: - rc = myri10ge_led(mgp, 0); - break; - - default: - rc = -EINVAL; - } - - return rc; -} - static const struct ethtool_ops myri10ge_ethtool_ops = { .get_settings = myri10ge_get_settings, .get_drvinfo = myri10ge_get_drvinfo, @@ -1976,7 +1923,6 @@ static const struct ethtool_ops myri10ge_ethtool_ops = { .get_ethtool_stats = myri10ge_get_ethtool_stats, .set_msglevel = myri10ge_set_msglevel, .get_msglevel = myri10ge_get_msglevel, - .set_phys_id = myri10ge_phys_id, }; static int myri10ge_allocate_rings(struct myri10ge_slice_state *ss) @@ -2056,12 +2002,8 @@ static int myri10ge_allocate_rings(struct myri10ge_slice_state *ss) ss->rx_big.page_offset = MYRI10GE_ALLOC_SIZE; ss->rx_small.watchdog_needed = 0; ss->rx_big.watchdog_needed = 0; - if (mgp->small_bytes == 0) { - ss->rx_small.fill_cnt = ss->rx_small.mask + 1; - } else { - myri10ge_alloc_rx_pages(mgp, &ss->rx_small, - mgp->small_bytes + MXGEFW_PAD, 0); - } + myri10ge_alloc_rx_pages(mgp, &ss->rx_small, + mgp->small_bytes + MXGEFW_PAD, 0); if (ss->rx_small.fill_cnt < ss->rx_small.mask + 1) { netdev_err(dev, "slice-%d: alloced only %d small bufs\n", @@ -2087,8 +2029,6 @@ static int myri10ge_allocate_rings(struct myri10ge_slice_state *ss) } abort_with_rx_small_ring: - if (mgp->small_bytes == 0) - ss->rx_small.fill_cnt = ss->rx_small.cnt; for (i = ss->rx_small.cnt; i < ss->rx_small.fill_cnt; i++) { int idx = i & ss->rx_small.mask; myri10ge_unmap_rx_page(mgp->pdev, &ss->rx_small.info[idx], @@ -2139,8 +2079,6 @@ static void myri10ge_free_rings(struct myri10ge_slice_state *ss) put_page(ss->rx_big.info[idx].page); } - if (mgp->small_bytes == 0) - ss->rx_small.fill_cnt = ss->rx_small.cnt; for (i = ss->rx_small.cnt; i < ss->rx_small.fill_cnt; i++) { idx = i & ss->rx_small.mask; if (i == ss->rx_small.fill_cnt - 1) @@ -2478,7 +2416,7 @@ static int myri10ge_open(struct net_device *dev) mgp->small_bytes = VLAN_ETH_FRAME_LEN; /* Override the small buffer size? */ - if (myri10ge_small_bytes >= 0) + if (myri10ge_small_bytes > 0) mgp->small_bytes = myri10ge_small_bytes; /* Firmware needs the big buff size as a power of 2. Lie and @@ -3188,7 +3126,7 @@ static void myri10ge_enable_ecrc(struct myri10ge_priv *mgp) { struct pci_dev *bridge = mgp->pdev->bus->self; struct device *dev = &mgp->pdev->dev; - int cap; + unsigned cap; unsigned err_cap; u16 val; u8 ext_type; @@ -3198,7 +3136,7 @@ static void myri10ge_enable_ecrc(struct myri10ge_priv *mgp) return; /* check that the bridge is a root port */ - cap = pci_pcie_cap(bridge); + cap = pci_find_capability(bridge, PCI_CAP_ID_EXP); pci_read_config_word(bridge, cap + PCI_CAP_FLAGS, &val); ext_type = (val & PCI_EXP_FLAGS_TYPE) >> 4; if (ext_type != PCI_EXP_TYPE_ROOT_PORT) { @@ -3216,7 +3154,8 @@ static void myri10ge_enable_ecrc(struct myri10ge_priv *mgp) " to force ECRC\n"); return; } - cap = pci_pcie_cap(bridge); + cap = + pci_find_capability(bridge, PCI_CAP_ID_EXP); pci_read_config_word(bridge, cap + PCI_CAP_FLAGS, &val); ext_type = (val & PCI_EXP_FLAGS_TYPE) >> 4; @@ -3326,6 +3265,7 @@ static void myri10ge_firmware_probe(struct myri10ge_priv *mgp) /* fall back to using the unaligned firmware */ mgp->tx_boundary = 2048; set_fw_name(mgp, myri10ge_fw_unaligned, false); + } static void myri10ge_select_firmware(struct myri10ge_priv *mgp) @@ -3336,7 +3276,7 @@ static void myri10ge_select_firmware(struct myri10ge_priv *mgp) int link_width, exp_cap; u16 lnk; - exp_cap = pci_pcie_cap(mgp->pdev); + exp_cap = pci_find_capability(mgp->pdev, PCI_CAP_ID_EXP); pci_read_config_word(mgp->pdev, exp_cap + PCI_EXP_LNKSTA, &lnk); link_width = (lnk >> 4) & 0x3f; @@ -3386,26 +3326,6 @@ static void myri10ge_select_firmware(struct myri10ge_priv *mgp) mgp->fw_name); } -static void myri10ge_mask_surprise_down(struct pci_dev *pdev) -{ - struct pci_dev *bridge = pdev->bus->self; - int cap; - u32 mask; - - if (bridge == NULL) - return; - - cap = pci_find_ext_capability(bridge, PCI_EXT_CAP_ID_ERR); - if (cap) { - /* a sram parity error can cause a surprise link - * down; since we expect and can recover from sram - * parity errors, mask surprise link down events */ - pci_read_config_dword(bridge, cap + PCI_ERR_UNCOR_MASK, &mask); - mask |= 0x20; - pci_write_config_dword(bridge, cap + PCI_ERR_UNCOR_MASK, mask); - } -} - #ifdef CONFIG_PM static int myri10ge_suspend(struct pci_dev *pdev, pm_message_t state) { @@ -3501,42 +3421,6 @@ static u32 myri10ge_read_reboot(struct myri10ge_priv *mgp) return reboot; } -static void -myri10ge_check_slice(struct myri10ge_slice_state *ss, int *reset_needed, - int *busy_slice_cnt, u32 rx_pause_cnt) -{ - struct myri10ge_priv *mgp = ss->mgp; - int slice = ss - mgp->ss; - - if (ss->tx.req != ss->tx.done && - ss->tx.done == ss->watchdog_tx_done && - ss->watchdog_tx_req != ss->watchdog_tx_done) { - /* nic seems like it might be stuck.. */ - if (rx_pause_cnt != mgp->watchdog_pause) { - if (net_ratelimit()) - netdev_warn(mgp->dev, "slice %d: TX paused, " - "check link partner\n", slice); - } else { - netdev_warn(mgp->dev, - "slice %d: TX stuck %d %d %d %d %d %d\n", - slice, ss->tx.queue_active, ss->tx.req, - ss->tx.done, ss->tx.pkt_start, - ss->tx.pkt_done, - (int)ntohl(mgp->ss[slice].fw_stats-> - send_done_count)); - *reset_needed = 1; - ss->stuck = 1; - } - } - if (ss->watchdog_tx_done != ss->tx.done || - ss->watchdog_rx_done != ss->rx_done.cnt) { - *busy_slice_cnt += 1; - } - ss->watchdog_tx_done = ss->tx.done; - ss->watchdog_tx_req = ss->tx.req; - ss->watchdog_rx_done = ss->rx_done.cnt; -} - /* * This watchdog is used to check whether the board has suffered * from a parity error and needs to be recovered. @@ -3545,12 +3429,10 @@ static void myri10ge_watchdog(struct work_struct *work) { struct myri10ge_priv *mgp = container_of(work, struct myri10ge_priv, watchdog_work); - struct myri10ge_slice_state *ss; - u32 reboot, rx_pause_cnt; + struct myri10ge_tx_buf *tx; + u32 reboot; int status, rebooted; int i; - int reset_needed = 0; - int busy_slice_cnt = 0; u16 cmd, vendor; mgp->watchdog_resets++; @@ -3562,7 +3444,8 @@ static void myri10ge_watchdog(struct work_struct *work) * For now, just report it */ reboot = myri10ge_read_reboot(mgp); netdev_err(mgp->dev, "NIC rebooted (0x%x),%s resetting\n", - reboot, myri10ge_reset_recover ? "" : " not"); + reboot, + myri10ge_reset_recover ? "" : " not"); if (myri10ge_reset_recover == 0) return; rtnl_lock(); @@ -3594,24 +3477,23 @@ static void myri10ge_watchdog(struct work_struct *work) return; } } - /* Perhaps it is a software error. See if stuck slice - * has recovered, reset if not */ - rx_pause_cnt = ntohl(mgp->ss[0].fw_stats->dropped_pause); - for (i = 0; i < mgp->num_slices; i++) { - ss = mgp->ss; - if (ss->stuck) { - myri10ge_check_slice(ss, &reset_needed, - &busy_slice_cnt, - rx_pause_cnt); - ss->stuck = 0; - } - } - if (!reset_needed) { - netdev_dbg(mgp->dev, "not resetting\n"); - return; - } + /* Perhaps it is a software error. Try to reset */ netdev_err(mgp->dev, "device timeout, resetting\n"); + for (i = 0; i < mgp->num_slices; i++) { + tx = &mgp->ss[i].tx; + netdev_err(mgp->dev, "(%d): %d %d %d %d %d %d\n", + i, tx->queue_active, tx->req, + tx->done, tx->pkt_start, tx->pkt_done, + (int)ntohl(mgp->ss[i].fw_stats-> + send_done_count)); + msleep(2000); + netdev_info(mgp->dev, "(%d): %d %d %d %d %d %d\n", + i, tx->queue_active, tx->req, + tx->done, tx->pkt_start, tx->pkt_done, + (int)ntohl(mgp->ss[i].fw_stats-> + send_done_count)); + } } if (!rebooted) { @@ -3664,8 +3546,27 @@ static void myri10ge_watchdog_timer(unsigned long arg) myri10ge_fill_thresh) ss->rx_big.watchdog_needed = 0; } - myri10ge_check_slice(ss, &reset_needed, &busy_slice_cnt, - rx_pause_cnt); + + if (ss->tx.req != ss->tx.done && + ss->tx.done == ss->watchdog_tx_done && + ss->watchdog_tx_req != ss->watchdog_tx_done) { + /* nic seems like it might be stuck.. */ + if (rx_pause_cnt != mgp->watchdog_pause) { + if (net_ratelimit()) + netdev_err(mgp->dev, "slice %d: TX paused, check link partner\n", + i); + } else { + netdev_warn(mgp->dev, "slice %d stuck:", i); + reset_needed = 1; + } + } + if (ss->watchdog_tx_done != ss->tx.done || + ss->watchdog_rx_done != ss->rx_done.cnt) { + busy_slice_cnt++; + } + ss->watchdog_tx_done = ss->tx.done; + ss->watchdog_tx_req = ss->tx.req; + ss->watchdog_rx_done = ss->rx_done.cnt; } /* if we've sent or received no traffic, poll the NIC to * ensure it is still there. Otherwise, we risk not noticing @@ -3711,8 +3612,8 @@ static void myri10ge_free_slices(struct myri10ge_priv *mgp) dma_free_coherent(&pdev->dev, bytes, ss->fw_stats, ss->fw_stats_bus); ss->fw_stats = NULL; + netif_napi_del(&ss->napi); } - netif_napi_del(&ss->napi); } kfree(mgp->ss); mgp->ss = NULL; @@ -3943,7 +3844,6 @@ static int myri10ge_probe(struct pci_dev *pdev, const struct pci_device_id *ent) goto abort_with_enabled; } - myri10ge_mask_surprise_down(pdev); pci_set_master(pdev); dac_enabled = 1; status = pci_set_dma_mask(pdev, DMA_BIT_MASK(64)); diff --git a/trunk/drivers/net/myri10ge/myri10ge_mcp_gen_header.h b/trunk/drivers/net/myri10ge/myri10ge_mcp_gen_header.h index 7ec4b864a550..62a1cbab603f 100644 --- a/trunk/drivers/net/myri10ge/myri10ge_mcp_gen_header.h +++ b/trunk/drivers/net/myri10ge/myri10ge_mcp_gen_header.h @@ -45,8 +45,6 @@ struct mcp_gen_header { unsigned bss_addr; /* start of bss */ unsigned features; unsigned ee_hdr_addr; - unsigned led_pattern; - unsigned led_pattern_dflt; /* 8 */ }; diff --git a/trunk/drivers/net/natsemi.c b/trunk/drivers/net/natsemi.c index 60f46bc2bf64..b78be088c4ad 100644 --- a/trunk/drivers/net/natsemi.c +++ b/trunk/drivers/net/natsemi.c @@ -140,7 +140,7 @@ MODULE_LICENSE("GPL"); module_param(mtu, int, 0); module_param(debug, int, 0); module_param(rx_copybreak, int, 0); -module_param(dspcfg_workaround, int, 0); +module_param(dspcfg_workaround, int, 1); module_param_array(options, int, NULL, 0); module_param_array(full_duplex, int, NULL, 0); MODULE_PARM_DESC(mtu, "DP8381x MTU (all boards)"); @@ -2028,8 +2028,8 @@ static void drain_rx(struct net_device *dev) np->rx_ring[i].cmd_status = 0; np->rx_ring[i].addr = cpu_to_le32(0xBADF00D0); /* An invalid address. */ if (np->rx_skbuff[i]) { - pci_unmap_single(np->pci_dev, np->rx_dma[i], - buflen + NATSEMI_PADDING, + pci_unmap_single(np->pci_dev, + np->rx_dma[i], buflen, PCI_DMA_FROMDEVICE); dev_kfree_skb(np->rx_skbuff[i]); } @@ -2360,8 +2360,7 @@ static void netdev_rx(struct net_device *dev, int *work_done, int work_to_do) PCI_DMA_FROMDEVICE); } else { pci_unmap_single(np->pci_dev, np->rx_dma[entry], - buflen + NATSEMI_PADDING, - PCI_DMA_FROMDEVICE); + buflen, PCI_DMA_FROMDEVICE); skb_put(skb = np->rx_skbuff[entry], pkt_len); np->rx_skbuff[entry] = NULL; } diff --git a/trunk/drivers/net/niu.c b/trunk/drivers/net/niu.c index cd6c2317e29e..1c7b790217f9 100644 --- a/trunk/drivers/net/niu.c +++ b/trunk/drivers/net/niu.c @@ -9797,7 +9797,7 @@ static int __devinit niu_pci_init_one(struct pci_dev *pdev, goto err_out_disable_pdev; } - pos = pci_pcie_cap(pdev); + pos = pci_find_capability(pdev, PCI_CAP_ID_EXP); if (pos <= 0) { dev_err(&pdev->dev, "Cannot find PCI Express capability, aborting\n"); goto err_out_free_res; diff --git a/trunk/drivers/net/pcnet32.c b/trunk/drivers/net/pcnet32.c index 8b3090dc4bcd..b48aba9e4227 100644 --- a/trunk/drivers/net/pcnet32.c +++ b/trunk/drivers/net/pcnet32.c @@ -2570,6 +2570,7 @@ static void pcnet32_load_multicast(struct net_device *dev) volatile __le16 *mcast_table = (__le16 *)ib->filter; struct netdev_hw_addr *ha; unsigned long ioaddr = dev->base_addr; + char *addrs; int i; u32 crc; @@ -2589,7 +2590,13 @@ static void pcnet32_load_multicast(struct net_device *dev) /* Add addresses */ netdev_for_each_mc_addr(ha, dev) { - crc = ether_crc_le(6, ha->addr); + addrs = ha->addr; + + /* multicast address? */ + if (!(*addrs & 1)) + continue; + + crc = ether_crc_le(6, addrs); crc = crc >> 26; mcast_table[crc >> 4] |= cpu_to_le16(1 << (crc & 0xf)); } diff --git a/trunk/drivers/net/plip.c b/trunk/drivers/net/plip.c index a9e9ca8a86ed..ca4df7f4cf21 100644 --- a/trunk/drivers/net/plip.c +++ b/trunk/drivers/net/plip.c @@ -152,7 +152,7 @@ static int plip_hard_header(struct sk_buff *skb, struct net_device *dev, unsigned short type, const void *daddr, const void *saddr, unsigned len); static int plip_hard_header_cache(const struct neighbour *neigh, - struct hh_cache *hh, __be16 type); + struct hh_cache *hh); static int plip_open(struct net_device *dev); static int plip_close(struct net_device *dev); static int plip_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd); @@ -1026,11 +1026,11 @@ plip_hard_header(struct sk_buff *skb, struct net_device *dev, } static int plip_hard_header_cache(const struct neighbour *neigh, - struct hh_cache *hh, __be16 type) + struct hh_cache *hh) { int ret; - ret = eth_header_cache(neigh, hh, type); + ret = eth_header_cache(neigh, hh); if (ret == 0) { struct ethhdr *eth; diff --git a/trunk/drivers/net/ppp_deflate.c b/trunk/drivers/net/ppp_deflate.c index 1dbdf82a6dfd..31e9407a0739 100644 --- a/trunk/drivers/net/ppp_deflate.c +++ b/trunk/drivers/net/ppp_deflate.c @@ -305,7 +305,7 @@ static void z_decomp_free(void *arg) if (state) { zlib_inflateEnd(&state->strm); - vfree(state->strm.workspace); + kfree(state->strm.workspace); kfree(state); } } @@ -345,7 +345,8 @@ static void *z_decomp_alloc(unsigned char *options, int opt_len) state->w_size = w_size; state->strm.next_out = NULL; - state->strm.workspace = vmalloc(zlib_inflate_workspacesize()); + state->strm.workspace = kmalloc(zlib_inflate_workspacesize(), + GFP_KERNEL|__GFP_REPEAT); if (state->strm.workspace == NULL) goto out_free; diff --git a/trunk/drivers/net/pptp.c b/trunk/drivers/net/pptp.c index eae542a7e987..1286fe212dc4 100644 --- a/trunk/drivers/net/pptp.c +++ b/trunk/drivers/net/pptp.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include diff --git a/trunk/drivers/net/qlcnic/qlcnic.h b/trunk/drivers/net/qlcnic/qlcnic.h index 9899a7947718..e5454502df6b 100644 --- a/trunk/drivers/net/qlcnic/qlcnic.h +++ b/trunk/drivers/net/qlcnic/qlcnic.h @@ -36,8 +36,8 @@ #define _QLCNIC_LINUX_MAJOR 5 #define _QLCNIC_LINUX_MINOR 0 -#define _QLCNIC_LINUX_SUBVERSION 20 -#define QLCNIC_LINUX_VERSIONID "5.0.20" +#define _QLCNIC_LINUX_SUBVERSION 19 +#define QLCNIC_LINUX_VERSIONID "5.0.19" #define QLCNIC_DRV_IDC_VER 0x01 #define QLCNIC_DRIVER_VERSION ((_QLCNIC_LINUX_MAJOR << 16) |\ (_QLCNIC_LINUX_MINOR << 8) | (_QLCNIC_LINUX_SUBVERSION)) @@ -782,7 +782,6 @@ struct qlcnic_mac_list_s { #define QLCNIC_IP_DOWN 3 #define QLCNIC_ILB_MODE 0x1 -#define QLCNIC_ELB_MODE 0x2 #define QLCNIC_LINKEVENT 0x1 #define QLCNIC_LB_RESPONSE 0x2 diff --git a/trunk/drivers/net/qlcnic/qlcnic_ethtool.c b/trunk/drivers/net/qlcnic/qlcnic_ethtool.c index 3ea04e7da917..743035e4538d 100644 --- a/trunk/drivers/net/qlcnic/qlcnic_ethtool.c +++ b/trunk/drivers/net/qlcnic/qlcnic_ethtool.c @@ -85,8 +85,7 @@ static const char qlcnic_gstrings_test[][ETH_GSTRING_LEN] = { "Register_Test_on_offline", "Link_Test_on_offline", "Interrupt_Test_offline", - "Internal_Loopback_offline", - "External_Loopback_offline" + "Loopback_Test_offline" }; #define QLCNIC_TEST_LEN ARRAY_SIZE(qlcnic_gstrings_test) @@ -710,7 +709,7 @@ int qlcnic_check_loopback_buff(unsigned char *data, u8 mac[]) return memcmp(data, buff, QLCNIC_ILB_PKT_SIZE); } -static int qlcnic_do_lb_test(struct qlcnic_adapter *adapter) +static int qlcnic_do_ilb_test(struct qlcnic_adapter *adapter) { struct qlcnic_recv_context *recv_ctx = adapter->recv_ctx; struct qlcnic_host_sds_ring *sds_ring = &recv_ctx->sds_rings[0]; @@ -736,19 +735,19 @@ static int qlcnic_do_lb_test(struct qlcnic_adapter *adapter) dev_kfree_skb_any(skb); if (!adapter->diag_cnt) - dev_warn(&adapter->pdev->dev, "LB Test: %dth packet" + dev_warn(&adapter->pdev->dev, "ILB Test: %dth packet" " not recevied\n", i + 1); else cnt++; } if (cnt != i) { - dev_warn(&adapter->pdev->dev, "LB Test failed\n"); + dev_warn(&adapter->pdev->dev, "ILB Test failed\n"); return -1; } return 0; } -static int qlcnic_loopback_test(struct net_device *netdev, u8 mode) +static int qlcnic_iloopback_test(struct net_device *netdev) { struct qlcnic_adapter *adapter = netdev_priv(netdev); int max_sds_rings = adapter->max_sds_rings; @@ -756,8 +755,7 @@ static int qlcnic_loopback_test(struct net_device *netdev, u8 mode) int loop = 0; int ret; - netdev_info(netdev, "%s loopback test in progress\n", - mode == QLCNIC_ILB_MODE ? "internal" : "external"); + netdev_info(netdev, "%s: in progress\n", __func__); if (adapter->op_mode == QLCNIC_NON_PRIV_FUNC) { netdev_warn(netdev, "Loopback test not supported for non " "privilege function\n"); @@ -774,7 +772,7 @@ static int qlcnic_loopback_test(struct net_device *netdev, u8 mode) sds_ring = &adapter->recv_ctx->sds_rings[0]; - ret = qlcnic_set_lb_mode(adapter, mode); + ret = qlcnic_set_lb_mode(adapter, QLCNIC_ILB_MODE); if (ret) goto free_res; @@ -792,7 +790,7 @@ static int qlcnic_loopback_test(struct net_device *netdev, u8 mode) goto free_res; } - ret = qlcnic_do_lb_test(adapter); + ret = qlcnic_do_ilb_test(adapter); qlcnic_clear_lb_mode(adapter); @@ -824,16 +822,10 @@ qlcnic_diag_test(struct net_device *dev, struct ethtool_test *eth_test, if (data[2]) eth_test->flags |= ETH_TEST_FL_FAILED; - data[3] = qlcnic_loopback_test(dev, QLCNIC_ILB_MODE); + data[3] = qlcnic_iloopback_test(dev); if (data[3]) eth_test->flags |= ETH_TEST_FL_FAILED; - if (eth_test->flags & ETH_TEST_FL_EXTERNAL_LB) { - data[4] = qlcnic_loopback_test(dev, QLCNIC_ELB_MODE); - if (data[4]) - eth_test->flags |= ETH_TEST_FL_FAILED; - eth_test->flags |= ETH_TEST_FL_EXTERNAL_LB_DONE; - } } } diff --git a/trunk/drivers/net/qlcnic/qlcnic_init.c b/trunk/drivers/net/qlcnic/qlcnic_init.c index 6ec1baa85f6a..9d5bee03a587 100644 --- a/trunk/drivers/net/qlcnic/qlcnic_init.c +++ b/trunk/drivers/net/qlcnic/qlcnic_init.c @@ -1303,8 +1303,7 @@ qlcnic_handle_linkevent(struct qlcnic_adapter *adapter, dev_info(&netdev->dev, "unsupported cable length %d\n", cable_len); - if (!link_status && (lb_status == QLCNIC_ILB_MODE || - lb_status == QLCNIC_ELB_MODE)) + if (!link_status && (lb_status == 1)) adapter->ahw->loopback_state |= QLCNIC_LINKEVENT; qlcnic_advert_link_change(adapter, link_status); diff --git a/trunk/drivers/net/qlge/qlge.h b/trunk/drivers/net/qlge/qlge.h index 794252c0aedd..7d8483f9012e 100644 --- a/trunk/drivers/net/qlge/qlge.h +++ b/trunk/drivers/net/qlge/qlge.h @@ -17,7 +17,7 @@ */ #define DRV_NAME "qlge" #define DRV_STRING "QLogic 10 Gigabit PCI-E Ethernet Driver " -#define DRV_VERSION "v1.00.00.29.00.00-01" +#define DRV_VERSION "v1.00.00.27.00.00-01" #define WQ_ADDR_ALIGN 0x3 /* 4 byte alignment */ @@ -1997,7 +1997,6 @@ enum { QL_LB_LINK_UP = 10, QL_FRC_COREDUMP = 11, QL_EEH_FATAL = 12, - QL_ASIC_RECOVERY = 14, /* We are in ascic recovery. */ }; /* link_status bit definitions */ diff --git a/trunk/drivers/net/qlge/qlge_main.c b/trunk/drivers/net/qlge/qlge_main.c index 68fbfac7a3bf..be89610f16a8 100644 --- a/trunk/drivers/net/qlge/qlge_main.c +++ b/trunk/drivers/net/qlge/qlge_main.c @@ -2152,10 +2152,6 @@ void ql_queue_asic_error(struct ql_adapter *qdev) * thread */ clear_bit(QL_ADAPTER_UP, &qdev->flags); - /* Set asic recovery bit to indicate reset process that we are - * in fatal error recovery process rather than normal close - */ - set_bit(QL_ASIC_RECOVERY, &qdev->flags); queue_delayed_work(qdev->workqueue, &qdev->asic_reset_work, 0); } @@ -2170,20 +2166,23 @@ static void ql_process_chip_ae_intr(struct ql_adapter *qdev, return; case CAM_LOOKUP_ERR_EVENT: - netdev_err(qdev->ndev, "Multiple CAM hits lookup occurred.\n"); - netdev_err(qdev->ndev, "This event shouldn't occur.\n"); + netif_err(qdev, link, qdev->ndev, + "Multiple CAM hits lookup occurred.\n"); + netif_err(qdev, drv, qdev->ndev, + "This event shouldn't occur.\n"); ql_queue_asic_error(qdev); return; case SOFT_ECC_ERROR_EVENT: - netdev_err(qdev->ndev, "Soft ECC error detected.\n"); + netif_err(qdev, rx_err, qdev->ndev, + "Soft ECC error detected.\n"); ql_queue_asic_error(qdev); break; case PCI_ERR_ANON_BUF_RD: - netdev_err(qdev->ndev, "PCI error occurred when reading " - "anonymous buffers from rx_ring %d.\n", - ib_ae_rsp->q_id); + netif_err(qdev, rx_err, qdev->ndev, + "PCI error occurred when reading anonymous buffers from rx_ring %d.\n", + ib_ae_rsp->q_id); ql_queue_asic_error(qdev); break; @@ -2438,10 +2437,11 @@ static irqreturn_t qlge_isr(int irq, void *dev_id) */ if (var & STS_FE) { ql_queue_asic_error(qdev); - netdev_err(qdev->ndev, "Got fatal error, STS = %x.\n", var); + netif_err(qdev, intr, qdev->ndev, + "Got fatal error, STS = %x.\n", var); var = ql_read32(qdev, ERR_STS); - netdev_err(qdev->ndev, "Resetting chip. " - "Error Status Register = 0x%x\n", var); + netif_err(qdev, intr, qdev->ndev, + "Resetting chip. Error Status Register = 0x%x\n", var); return IRQ_HANDLED; } @@ -3818,17 +3818,11 @@ static int ql_adapter_reset(struct ql_adapter *qdev) end_jiffies = jiffies + max((unsigned long)1, usecs_to_jiffies(30)); - /* Check if bit is set then skip the mailbox command and - * clear the bit, else we are in normal reset process. - */ - if (!test_bit(QL_ASIC_RECOVERY, &qdev->flags)) { - /* Stop management traffic. */ - ql_mb_set_mgmnt_traffic_ctl(qdev, MB_SET_MPI_TFK_STOP); + /* Stop management traffic. */ + ql_mb_set_mgmnt_traffic_ctl(qdev, MB_SET_MPI_TFK_STOP); - /* Wait for the NIC and MGMNT FIFOs to empty. */ - ql_wait_fifo_empty(qdev); - } else - clear_bit(QL_ASIC_RECOVERY, &qdev->flags); + /* Wait for the NIC and MGMNT FIFOs to empty. */ + ql_wait_fifo_empty(qdev); ql_write32(qdev, RST_FO, (RST_FO_FR << 16) | RST_FO_FR); diff --git a/trunk/drivers/net/r8169.c b/trunk/drivers/net/r8169.c index ef1a43dd145b..f8c4435afe51 100644 --- a/trunk/drivers/net/r8169.c +++ b/trunk/drivers/net/r8169.c @@ -659,6 +659,7 @@ struct rtl8169_private { unsigned int (*phy_reset_pending)(struct rtl8169_private *tp); unsigned int (*link_ok)(void __iomem *); int (*do_ioctl)(struct rtl8169_private *tp, struct mii_ioctl_data *data, int cmd); + int pcie_cap; struct delayed_work task; unsigned features; @@ -753,7 +754,7 @@ static void rtl8168_oob_notify(struct rtl8169_private *tp, u8 cmd) msleep(2); for (i = 0; i < 5; i++) { udelay(100); - if (!(RTL_R32(ERIAR) & ERIAR_FLAG)) + if (!(RTL_R32(ERIDR) & ERIAR_FLAG)) break; } @@ -3443,8 +3444,9 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) } tp->mmio_addr = ioaddr; - if (!pci_is_pcie(pdev)) - netif_info(tp, probe, dev, "not PCI Express\n"); + tp->pcie_cap = pci_find_capability(pdev, PCI_CAP_ID_EXP); + if (!tp->pcie_cap) + netif_info(tp, probe, dev, "no PCI Express capability\n"); RTL_W16(IntrMask, 0x0000); @@ -3896,7 +3898,9 @@ static void rtl_hw_start_8169(struct net_device *dev) static void rtl_tx_performance_tweak(struct pci_dev *pdev, u16 force) { - int cap = pci_pcie_cap(pdev); + struct net_device *dev = pci_get_drvdata(pdev); + struct rtl8169_private *tp = netdev_priv(dev); + int cap = tp->pcie_cap; if (cap) { u16 ctl; @@ -3944,7 +3948,9 @@ static void rtl_ephy_init(void __iomem *ioaddr, const struct ephy_info *e, int l static void rtl_disable_clock_request(struct pci_dev *pdev) { - int cap = pci_pcie_cap(pdev); + struct net_device *dev = pci_get_drvdata(pdev); + struct rtl8169_private *tp = netdev_priv(dev); + int cap = tp->pcie_cap; if (cap) { u16 ctl; @@ -3957,7 +3963,9 @@ static void rtl_disable_clock_request(struct pci_dev *pdev) static void rtl_enable_clock_request(struct pci_dev *pdev) { - int cap = pci_pcie_cap(pdev); + struct net_device *dev = pci_get_drvdata(pdev); + struct rtl8169_private *tp = netdev_priv(dev); + int cap = tp->pcie_cap; if (cap) { u16 ctl; @@ -4387,7 +4395,7 @@ static void rtl_hw_start_8101(struct net_device *dev) if (tp->mac_version == RTL_GIGA_MAC_VER_13 || tp->mac_version == RTL_GIGA_MAC_VER_16) { - int cap = pci_pcie_cap(pdev); + int cap = tp->pcie_cap; if (cap) { pci_write_config_word(pdev, cap + PCI_EXP_DEVCTL, diff --git a/trunk/drivers/net/rionet.c b/trunk/drivers/net/rionet.c index 86ac38c96bcf..77c5092a6a40 100644 --- a/trunk/drivers/net/rionet.c +++ b/trunk/drivers/net/rionet.c @@ -190,7 +190,7 @@ static int rionet_start_xmit(struct sk_buff *skb, struct net_device *ndev) return NETDEV_TX_BUSY; } - if (is_multicast_ether_addr(eth->h_dest)) { + if (eth->h_dest[0] & 0x01) { for (i = 0; i < RIO_MAX_ROUTE_ENTRIES(rnet->mport->sys_size); i++) if (rionet_active[i]) @@ -378,7 +378,7 @@ static int rionet_close(struct net_device *ndev) static void rionet_remove(struct rio_dev *rdev) { - struct net_device *ndev = rio_get_drvdata(rdev); + struct net_device *ndev = NULL; struct rionet_peer *peer, *tmp; free_pages((unsigned long)rionet_active, rdev->net->hport->sys_size ? @@ -433,12 +433,22 @@ static const struct net_device_ops rionet_netdev_ops = { .ndo_set_mac_address = eth_mac_addr, }; -static int rionet_setup_netdev(struct rio_mport *mport, struct net_device *ndev) +static int rionet_setup_netdev(struct rio_mport *mport) { int rc = 0; + struct net_device *ndev = NULL; struct rionet_private *rnet; u16 device_id; + /* Allocate our net_device structure */ + ndev = alloc_etherdev(sizeof(struct rionet_private)); + if (ndev == NULL) { + printk(KERN_INFO "%s: could not allocate ethernet device.\n", + DRV_NAME); + rc = -ENOMEM; + goto out; + } + rionet_active = (struct rio_dev **)__get_free_pages(GFP_KERNEL, mport->sys_size ? __fls(sizeof(void *)) + 4 : 0); if (!rionet_active) { @@ -494,21 +504,11 @@ static int rionet_probe(struct rio_dev *rdev, const struct rio_device_id *id) int rc = -ENODEV; u32 lpef, lsrc_ops, ldst_ops; struct rionet_peer *peer; - struct net_device *ndev = NULL; /* If local device is not rionet capable, give up quickly */ if (!rionet_capable) goto out; - /* Allocate our net_device structure */ - ndev = alloc_etherdev(sizeof(struct rionet_private)); - if (ndev == NULL) { - printk(KERN_INFO "%s: could not allocate ethernet device.\n", - DRV_NAME); - rc = -ENOMEM; - goto out; - } - /* * First time through, make sure local device is rionet * capable, setup netdev, and set flags so this is skipped @@ -529,7 +529,7 @@ static int rionet_probe(struct rio_dev *rdev, const struct rio_device_id *id) goto out; } - rc = rionet_setup_netdev(rdev->net->hport, ndev); + rc = rionet_setup_netdev(rdev->net->hport); rionet_check = 1; } @@ -546,8 +546,6 @@ static int rionet_probe(struct rio_dev *rdev, const struct rio_device_id *id) list_add_tail(&peer->node, &rionet_peers); } - rio_set_drvdata(rdev, ndev); - out: return rc; } diff --git a/trunk/drivers/net/sfc/filter.c b/trunk/drivers/net/sfc/filter.c index f2fc2587c09d..054f0a3d45a9 100644 --- a/trunk/drivers/net/sfc/filter.c +++ b/trunk/drivers/net/sfc/filter.c @@ -335,28 +335,35 @@ static int efx_filter_search(struct efx_filter_table *table, bool for_insert, int *depth_required) { unsigned hash, incr, filter_idx, depth, depth_max; - struct efx_filter_spec *cmp; hash = efx_filter_hash(key); incr = efx_filter_increment(key); - depth_max = (spec->priority <= EFX_FILTER_PRI_HINT ? - FILTER_CTL_SRCH_HINT_MAX : FILTER_CTL_SRCH_MAX); - - for (depth = 1, filter_idx = hash & (table->size - 1); - depth <= depth_max && test_bit(filter_idx, table->used_bitmap); - ++depth) { - cmp = &table->spec[filter_idx]; - if (efx_filter_equal(spec, cmp)) - goto found; + + filter_idx = hash & (table->size - 1); + depth = 1; + depth_max = (for_insert ? + (spec->priority <= EFX_FILTER_PRI_HINT ? + FILTER_CTL_SRCH_HINT_MAX : FILTER_CTL_SRCH_MAX) : + table->search_depth[spec->type]); + + for (;;) { + /* Return success if entry is used and matches this spec + * or entry is unused and we are trying to insert. + */ + if (test_bit(filter_idx, table->used_bitmap) ? + efx_filter_equal(spec, &table->spec[filter_idx]) : + for_insert) { + *depth_required = depth; + return filter_idx; + } + + /* Return failure if we reached the maximum search depth */ + if (depth == depth_max) + return for_insert ? -EBUSY : -ENOENT; + filter_idx = (filter_idx + incr) & (table->size - 1); + ++depth; } - if (!for_insert) - return -ENOENT; - if (depth > depth_max) - return -EBUSY; -found: - *depth_required = depth; - return filter_idx; } /* Construct/deconstruct external filter IDs */ diff --git a/trunk/drivers/net/sfc/net_driver.h b/trunk/drivers/net/sfc/net_driver.h index 1affbf4d7083..e8d5f03a89fe 100644 --- a/trunk/drivers/net/sfc/net_driver.h +++ b/trunk/drivers/net/sfc/net_driver.h @@ -17,6 +17,7 @@ #define DEBUG #endif +#include #include #include #include diff --git a/trunk/drivers/net/sh_eth.c b/trunk/drivers/net/sh_eth.c index ad35c210b839..8a72a979ee71 100644 --- a/trunk/drivers/net/sh_eth.c +++ b/trunk/drivers/net/sh_eth.c @@ -33,6 +33,7 @@ #include #include #include +#include #include "sh_eth.h" @@ -139,8 +140,6 @@ static struct sh_eth_cpu_data sh_eth_my_cpu_data = { .tpauser = 1, .hw_swap = 1, .no_ade = 1, - .rpadir = 1, - .rpadir_value = 2 << 16, }; #define SH_GIGA_ETH_BASE 0xfee00000 @@ -865,8 +864,6 @@ static int sh_eth_txfree(struct net_device *ndev) break; /* Free the original skb. */ if (mdp->tx_skbuff[entry]) { - dma_unmap_single(&ndev->dev, txdesc->addr, - txdesc->buffer_length, DMA_TO_DEVICE); dev_kfree_skb_irq(mdp->tx_skbuff[entry]); mdp->tx_skbuff[entry] = NULL; freeNum++; @@ -1187,8 +1184,8 @@ static void sh_eth_adjust_link(struct net_device *ndev) mdp->cd->set_rate(ndev); } if (mdp->link == PHY_DOWN) { - sh_eth_write(ndev, - (sh_eth_read(ndev, ECMR) & ~ECMR_TXF), ECMR); + sh_eth_write(ndev, (sh_eth_read(ndev, ECMR) & ~ECMR_TXF) + | ECMR_DM, ECMR); new_state = 1; mdp->link = phydev->link; } @@ -1490,12 +1487,13 @@ static int sh_eth_start_xmit(struct sk_buff *skb, struct net_device *ndev) entry = mdp->cur_tx % TX_RING_SIZE; mdp->tx_skbuff[entry] = skb; txdesc = &mdp->tx_ring[entry]; + txdesc->addr = virt_to_phys(skb->data); /* soft swap. */ if (!mdp->cd->hw_swap) sh_eth_soft_swap(phys_to_virt(ALIGN(txdesc->addr, 4)), skb->len + 2); - txdesc->addr = dma_map_single(&ndev->dev, skb->data, skb->len, - DMA_TO_DEVICE); + /* write back */ + __flush_purge_region(skb->data, skb->len); if (skb->len < ETHERSMALL) txdesc->buffer_length = ETHERSMALL; else @@ -1772,7 +1770,7 @@ static int sh_eth_drv_probe(struct platform_device *pdev) int ret, devno = 0; struct resource *res; struct net_device *ndev = NULL; - struct sh_eth_private *mdp = NULL; + struct sh_eth_private *mdp; struct sh_eth_plat_data *pd; /* get base addr */ @@ -1890,7 +1888,7 @@ static int sh_eth_drv_probe(struct platform_device *pdev) out_release: /* net_dev free */ - if (mdp && mdp->tsu_addr) + if (mdp->tsu_addr) iounmap(mdp->tsu_addr); if (ndev) free_netdev(ndev); diff --git a/trunk/drivers/net/skge.c b/trunk/drivers/net/skge.c index 98ec614c5690..f4be5c78ebfd 100644 --- a/trunk/drivers/net/skge.c +++ b/trunk/drivers/net/skge.c @@ -50,7 +50,7 @@ #include "skge.h" #define DRV_NAME "skge" -#define DRV_VERSION "1.14" +#define DRV_VERSION "1.13" #define DEFAULT_TX_RING_SIZE 128 #define DEFAULT_RX_RING_SIZE 512 @@ -83,20 +83,17 @@ module_param(debug, int, 0); MODULE_PARM_DESC(debug, "Debug level (0=none,...,16=all)"); static DEFINE_PCI_DEVICE_TABLE(skge_id_table) = { - { PCI_DEVICE(PCI_VENDOR_ID_3COM, 0x1700) }, /* 3Com 3C940 */ - { PCI_DEVICE(PCI_VENDOR_ID_3COM, 0x80EB) }, /* 3Com 3C940B */ -#ifdef CONFIG_SKGE_GENESIS - { PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, 0x4300) }, /* SK-9xx */ -#endif - { PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, 0x4320) }, /* SK-98xx V2.0 */ - { PCI_DEVICE(PCI_VENDOR_ID_DLINK, 0x4b01) }, /* D-Link DGE-530T (rev.B) */ - { PCI_DEVICE(PCI_VENDOR_ID_DLINK, 0x4c00) }, /* D-Link DGE-530T */ - { PCI_DEVICE(PCI_VENDOR_ID_DLINK, 0x4302) }, /* D-Link DGE-530T Rev C1 */ - { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4320) }, /* Marvell Yukon 88E8001/8003/8010 */ - { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x5005) }, /* Belkin */ - { PCI_DEVICE(PCI_VENDOR_ID_CNET, 0x434E) }, /* CNet PowerG-2000 */ - { PCI_DEVICE(PCI_VENDOR_ID_LINKSYS, 0x1064) }, /* Linksys EG1064 v2 */ - { PCI_VENDOR_ID_LINKSYS, 0x1032, PCI_ANY_ID, 0x0015 }, /* Linksys EG1032 v2 */ + { PCI_DEVICE(PCI_VENDOR_ID_3COM, PCI_DEVICE_ID_3COM_3C940) }, + { PCI_DEVICE(PCI_VENDOR_ID_3COM, PCI_DEVICE_ID_3COM_3C940B) }, + { PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, PCI_DEVICE_ID_SYSKONNECT_GE) }, + { PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, PCI_DEVICE_ID_SYSKONNECT_YU) }, + { PCI_DEVICE(PCI_VENDOR_ID_DLINK, PCI_DEVICE_ID_DLINK_DGE510T) }, + { PCI_DEVICE(PCI_VENDOR_ID_DLINK, 0x4b01) }, /* DGE-530T */ + { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4320) }, + { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x5005) }, /* Belkin */ + { PCI_DEVICE(PCI_VENDOR_ID_CNET, PCI_DEVICE_ID_CNET_GIGACARD) }, + { PCI_DEVICE(PCI_VENDOR_ID_LINKSYS, PCI_DEVICE_ID_LINKSYS_EG1064) }, + { PCI_VENDOR_ID_LINKSYS, 0x1032, PCI_ANY_ID, 0x0015 }, { 0 } }; MODULE_DEVICE_TABLE(pci, skge_id_table); @@ -122,15 +119,6 @@ static const u32 txirqmask[] = { IS_XA1_F, IS_XA2_F }; static const u32 napimask[] = { IS_R1_F|IS_XA1_F, IS_R2_F|IS_XA2_F }; static const u32 portmask[] = { IS_PORT_1, IS_PORT_2 }; -static inline bool is_genesis(const struct skge_hw *hw) -{ -#ifdef CONFIG_SKGE_GENESIS - return hw->chip_id == CHIP_ID_GENESIS; -#else - return false; -#endif -} - static int skge_get_regs_len(struct net_device *dev) { return 0x4000; @@ -158,7 +146,7 @@ static void skge_get_regs(struct net_device *dev, struct ethtool_regs *regs, /* Wake on Lan only supported on Yukon chips with rev 1 or above */ static u32 wol_supported(const struct skge_hw *hw) { - if (is_genesis(hw)) + if (hw->chip_id == CHIP_ID_GENESIS) return 0; if (hw->chip_id == CHIP_ID_YUKON && hw->chip_rev == 0) @@ -282,7 +270,7 @@ static u32 skge_supported_modes(const struct skge_hw *hw) SUPPORTED_Autoneg | SUPPORTED_TP); - if (is_genesis(hw)) + if (hw->chip_id == CHIP_ID_GENESIS) supported &= ~(SUPPORTED_10baseT_Half | SUPPORTED_10baseT_Full | SUPPORTED_100baseT_Half | @@ -445,7 +433,7 @@ static void skge_get_ethtool_stats(struct net_device *dev, { struct skge_port *skge = netdev_priv(dev); - if (is_genesis(skge->hw)) + if (skge->hw->chip_id == CHIP_ID_GENESIS) genesis_get_stats(skge, data); else yukon_get_stats(skge, data); @@ -460,7 +448,7 @@ static struct net_device_stats *skge_get_stats(struct net_device *dev) struct skge_port *skge = netdev_priv(dev); u64 data[ARRAY_SIZE(skge_stats)]; - if (is_genesis(skge->hw)) + if (skge->hw->chip_id == CHIP_ID_GENESIS) genesis_get_stats(skge, data); else yukon_get_stats(skge, data); @@ -601,7 +589,7 @@ static int skge_set_pauseparam(struct net_device *dev, /* Chip internal frequency for clock calculations */ static inline u32 hwkhz(const struct skge_hw *hw) { - return is_genesis(hw) ? 53125 : 78125; + return (hw->chip_id == CHIP_ID_GENESIS) ? 53125 : 78125; } /* Chip HZ to microseconds */ @@ -686,7 +674,7 @@ static void skge_led(struct skge_port *skge, enum led_mode mode) int port = skge->port; spin_lock_bh(&hw->phy_lock); - if (is_genesis(hw)) { + if (hw->chip_id == CHIP_ID_GENESIS) { switch (mode) { case LED_MODE_OFF: if (hw->phy_type == SK_PHY_BCOM) @@ -1065,6 +1053,7 @@ static void skge_link_down(struct skge_port *skge) netif_info(skge, link, skge->netdev, "Link is down\n"); } + static void xm_link_down(struct skge_hw *hw, int port) { struct net_device *dev = hw->dev[port]; @@ -1183,6 +1172,7 @@ static void genesis_reset(struct skge_hw *hw, int port) xm_write32(hw, port, XM_MODE, reg | XM_MD_FRF); } + /* Convert mode to MII values */ static const u16 phy_pause_map[] = { [FLOW_MODE_NONE] = 0, @@ -2415,7 +2405,7 @@ static void skge_phy_reset(struct skge_port *skge) netif_carrier_off(skge->netdev); spin_lock_bh(&hw->phy_lock); - if (is_genesis(hw)) { + if (hw->chip_id == CHIP_ID_GENESIS) { genesis_reset(hw, port); genesis_mac_init(hw, port); } else { @@ -2446,8 +2436,7 @@ static int skge_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) case SIOCGMIIREG: { u16 val = 0; spin_lock_bh(&hw->phy_lock); - - if (is_genesis(hw)) + if (hw->chip_id == CHIP_ID_GENESIS) err = __xm_phy_read(hw, skge->port, data->reg_num & 0x1f, &val); else err = __gm_phy_read(hw, skge->port, data->reg_num & 0x1f, &val); @@ -2458,7 +2447,7 @@ static int skge_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) case SIOCSMIIREG: spin_lock_bh(&hw->phy_lock); - if (is_genesis(hw)) + if (hw->chip_id == CHIP_ID_GENESIS) err = xm_phy_write(hw, skge->port, data->reg_num & 0x1f, data->val_in); else @@ -2570,7 +2559,7 @@ static int skge_up(struct net_device *dev) /* Initialize MAC */ spin_lock_bh(&hw->phy_lock); - if (is_genesis(hw)) + if (hw->chip_id == CHIP_ID_GENESIS) genesis_mac_init(hw, port); else yukon_mac_init(hw, port); @@ -2632,7 +2621,7 @@ static int skge_down(struct net_device *dev) netif_tx_disable(dev); - if (is_genesis(hw) && hw->phy_type == SK_PHY_XMAC) + if (hw->chip_id == CHIP_ID_GENESIS && hw->phy_type == SK_PHY_XMAC) del_timer_sync(&skge->link_timer); napi_disable(&skge->napi); @@ -2644,7 +2633,7 @@ static int skge_down(struct net_device *dev) spin_unlock_irq(&hw->hw_lock); skge_write8(skge->hw, SK_REG(skge->port, LNK_LED_REG), LED_OFF); - if (is_genesis(hw)) + if (hw->chip_id == CHIP_ID_GENESIS) genesis_stop(skge); else yukon_stop(skge); @@ -2672,7 +2661,7 @@ static int skge_down(struct net_device *dev) skge_rx_stop(hw, port); - if (is_genesis(hw)) { + if (hw->chip_id == CHIP_ID_GENESIS) { skge_write8(hw, SK_REG(port, TX_MFF_CTRL2), MFF_RST_SET); skge_write8(hw, SK_REG(port, RX_MFF_CTRL2), MFF_RST_SET); } else { @@ -2968,7 +2957,7 @@ static void yukon_set_multicast(struct net_device *dev) static inline u16 phy_length(const struct skge_hw *hw, u32 status) { - if (is_genesis(hw)) + if (hw->chip_id == CHIP_ID_GENESIS) return status >> XMR_FS_LEN_SHIFT; else return status >> GMR_FS_LEN_SHIFT; @@ -2976,7 +2965,7 @@ static inline u16 phy_length(const struct skge_hw *hw, u32 status) static inline int bad_phy_status(const struct skge_hw *hw, u32 status) { - if (is_genesis(hw)) + if (hw->chip_id == CHIP_ID_GENESIS) return (status & (XMR_FS_ERR | XMR_FS_2L_VLAN)) != 0; else return (status & GMR_FS_ANY_ERR) || @@ -2986,8 +2975,9 @@ static inline int bad_phy_status(const struct skge_hw *hw, u32 status) static void skge_set_multicast(struct net_device *dev) { struct skge_port *skge = netdev_priv(dev); + struct skge_hw *hw = skge->hw; - if (is_genesis(skge->hw)) + if (hw->chip_id == CHIP_ID_GENESIS) genesis_set_multicast(dev); else yukon_set_multicast(dev); @@ -3067,7 +3057,7 @@ static struct sk_buff *skge_rx_get(struct net_device *dev, "rx err, slot %td control 0x%x status 0x%x\n", e - skge->rx_ring.start, control, status); - if (is_genesis(skge->hw)) { + if (skge->hw->chip_id == CHIP_ID_GENESIS) { if (status & (XMR_FS_RUNT|XMR_FS_LNG_ERR)) dev->stats.rx_length_errors++; if (status & XMR_FS_FRA_ERR) @@ -3181,7 +3171,7 @@ static void skge_mac_parity(struct skge_hw *hw, int port) ++dev->stats.tx_heartbeat_errors; - if (is_genesis(hw)) + if (hw->chip_id == CHIP_ID_GENESIS) skge_write16(hw, SK_REG(port, TX_MFF_CTRL1), MFF_CLR_PERR); else @@ -3193,7 +3183,7 @@ static void skge_mac_parity(struct skge_hw *hw, int port) static void skge_mac_intr(struct skge_hw *hw, int port) { - if (is_genesis(hw)) + if (hw->chip_id == CHIP_ID_GENESIS) genesis_mac_intr(hw, port); else yukon_mac_intr(hw, port); @@ -3205,7 +3195,7 @@ static void skge_error_irq(struct skge_hw *hw) struct pci_dev *pdev = hw->pdev; u32 hwstatus = skge_read32(hw, B0_HWE_ISRC); - if (is_genesis(hw)) { + if (hw->chip_id == CHIP_ID_GENESIS) { /* clear xmac errors */ if (hwstatus & (IS_NO_STAT_M1|IS_NO_TIST_M1)) skge_write16(hw, RX_MFF_CTRL1, MFF_CLR_INSTAT); @@ -3288,7 +3278,7 @@ static void skge_extirq(unsigned long arg) struct skge_port *skge = netdev_priv(dev); spin_lock(&hw->phy_lock); - if (!is_genesis(hw)) + if (hw->chip_id != CHIP_ID_GENESIS) yukon_phy_intr(skge); else if (hw->phy_type == SK_PHY_BCOM) bcom_phy_intr(skge); @@ -3407,7 +3397,7 @@ static int skge_set_mac_address(struct net_device *dev, void *p) memcpy_toio(hw->regs + B2_MAC_1 + port*8, dev->dev_addr, ETH_ALEN); memcpy_toio(hw->regs + B2_MAC_2 + port*8, dev->dev_addr, ETH_ALEN); - if (is_genesis(hw)) + if (hw->chip_id == CHIP_ID_GENESIS) xm_outaddr(hw, port, XM_SA, dev->dev_addr); else { gma_set_addr(hw, port, GM_SRC_ADDR_1L, dev->dev_addr); @@ -3483,7 +3473,6 @@ static int skge_reset(struct skge_hw *hw) switch (hw->chip_id) { case CHIP_ID_GENESIS: -#ifdef CONFIG_SKGE_GENESIS switch (hw->phy_type) { case SK_PHY_XMAC: hw->phy_addr = PHY_ADDR_XMAC; @@ -3497,10 +3486,6 @@ static int skge_reset(struct skge_hw *hw) return -EOPNOTSUPP; } break; -#else - dev_err(&hw->pdev->dev, "Genesis chip detected but not configured\n"); - return -EOPNOTSUPP; -#endif case CHIP_ID_YUKON: case CHIP_ID_YUKON_LITE: @@ -3523,7 +3508,7 @@ static int skge_reset(struct skge_hw *hw) /* read the adapters RAM size */ t8 = skge_read8(hw, B2_E_0); - if (is_genesis(hw)) { + if (hw->chip_id == CHIP_ID_GENESIS) { if (t8 == 3) { /* special case: 4 x 64k x 36, offset = 0x80000 */ hw->ram_size = 0x100000; @@ -3538,10 +3523,10 @@ static int skge_reset(struct skge_hw *hw) hw->intr_mask = IS_HW_ERR; /* Use PHY IRQ for all but fiber based Genesis board */ - if (!(is_genesis(hw) && hw->phy_type == SK_PHY_XMAC)) + if (!(hw->chip_id == CHIP_ID_GENESIS && hw->phy_type == SK_PHY_XMAC)) hw->intr_mask |= IS_EXT_REG; - if (is_genesis(hw)) + if (hw->chip_id == CHIP_ID_GENESIS) genesis_init(hw); else { /* switch power to VCC (WA for VAUX problem) */ @@ -3606,7 +3591,7 @@ static int skge_reset(struct skge_hw *hw) skge_write32(hw, B0_IMSK, hw->intr_mask); for (i = 0; i < hw->ports; i++) { - if (is_genesis(hw)) + if (hw->chip_id == CHIP_ID_GENESIS) genesis_reset(hw, i); else yukon_reset(hw, i); @@ -3817,9 +3802,9 @@ static struct net_device *skge_devinit(struct skge_hw *hw, int port, skge->port = port; /* Only used for Genesis XMAC */ - if (is_genesis(hw)) - setup_timer(&skge->link_timer, xm_link_timer, (unsigned long) skge); - else { + setup_timer(&skge->link_timer, xm_link_timer, (unsigned long) skge); + + if (hw->chip_id != CHIP_ID_GENESIS) { dev->hw_features = NETIF_F_IP_CSUM | NETIF_F_SG | NETIF_F_RXCSUM; dev->features |= dev->hw_features; diff --git a/trunk/drivers/net/sky2.c b/trunk/drivers/net/sky2.c index 57339da76326..d252cb123a5f 100644 --- a/trunk/drivers/net/sky2.c +++ b/trunk/drivers/net/sky2.c @@ -50,7 +50,7 @@ #include "sky2.h" #define DRV_NAME "sky2" -#define DRV_VERSION "1.29" +#define DRV_VERSION "1.28" /* * The Yukon II chipset takes 64 bit command blocks (called list elements) @@ -365,17 +365,6 @@ static void sky2_phy_init(struct sky2_hw *hw, unsigned port) gm_phy_write(hw, port, PHY_MARV_FE_SPEC_2, spec); } } else { - if (hw->chip_id >= CHIP_ID_YUKON_OPT) { - u16 ctrl2 = gm_phy_read(hw, port, PHY_MARV_EXT_CTRL_2); - - /* enable PHY Reverse Auto-Negotiation */ - ctrl2 |= 1u << 13; - - /* Write PHY changes (SW-reset must follow) */ - gm_phy_write(hw, port, PHY_MARV_EXT_CTRL_2, ctrl2); - } - - /* disable energy detect */ ctrl &= ~PHY_M_PC_EN_DET_MSK; @@ -637,63 +626,6 @@ static void sky2_phy_init(struct sky2_hw *hw, unsigned port) if (ledover) gm_phy_write(hw, port, PHY_MARV_LED_OVER, ledover); - } else if (hw->chip_id == CHIP_ID_YUKON_PRM && - (sky2_read8(hw, B2_MAC_CFG) & 0xf) == 0x7) { - int i; - /* This a phy register setup workaround copied from vendor driver. */ - static const struct { - u16 reg, val; - } eee_afe[] = { - { 0x156, 0x58ce }, - { 0x153, 0x99eb }, - { 0x141, 0x8064 }, - /* { 0x155, 0x130b },*/ - { 0x000, 0x0000 }, - { 0x151, 0x8433 }, - { 0x14b, 0x8c44 }, - { 0x14c, 0x0f90 }, - { 0x14f, 0x39aa }, - /* { 0x154, 0x2f39 },*/ - { 0x14d, 0xba33 }, - { 0x144, 0x0048 }, - { 0x152, 0x2010 }, - /* { 0x158, 0x1223 },*/ - { 0x140, 0x4444 }, - { 0x154, 0x2f3b }, - { 0x158, 0xb203 }, - { 0x157, 0x2029 }, - }; - - /* Start Workaround for OptimaEEE Rev.Z0 */ - gm_phy_write(hw, port, PHY_MARV_EXT_ADR, 0x00fb); - - gm_phy_write(hw, port, 1, 0x4099); - gm_phy_write(hw, port, 3, 0x1120); - gm_phy_write(hw, port, 11, 0x113c); - gm_phy_write(hw, port, 14, 0x8100); - gm_phy_write(hw, port, 15, 0x112a); - gm_phy_write(hw, port, 17, 0x1008); - - gm_phy_write(hw, port, PHY_MARV_EXT_ADR, 0x00fc); - gm_phy_write(hw, port, 1, 0x20b0); - - gm_phy_write(hw, port, PHY_MARV_EXT_ADR, 0x00ff); - - for (i = 0; i < ARRAY_SIZE(eee_afe); i++) { - /* apply AFE settings */ - gm_phy_write(hw, port, 17, eee_afe[i].val); - gm_phy_write(hw, port, 16, eee_afe[i].reg | 1u<<13); - } - - /* End Workaround for OptimaEEE */ - gm_phy_write(hw, port, PHY_MARV_EXT_ADR, 0); - - /* Enable 10Base-Te (EEE) */ - if (hw->chip_id >= CHIP_ID_YUKON_PRM) { - reg = gm_phy_read(hw, port, PHY_MARV_EXT_CTRL); - gm_phy_write(hw, port, PHY_MARV_EXT_CTRL, - reg | PHY_M_10B_TE_ENABLE); - } } /* Enable phy interrupt on auto-negotiation complete (or link up) */ @@ -782,20 +714,6 @@ static void sky2_phy_power_down(struct sky2_hw *hw, unsigned port) sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_OFF); } -/* configure IPG according to used link speed */ -static void sky2_set_ipg(struct sky2_port *sky2) -{ - u16 reg; - - reg = gma_read16(sky2->hw, sky2->port, GM_SERIAL_MODE); - reg &= ~GM_SMOD_IPG_MSK; - if (sky2->speed > SPEED_100) - reg |= IPG_DATA_VAL(IPG_DATA_DEF_1000); - else - reg |= IPG_DATA_VAL(IPG_DATA_DEF_10_100); - gma_write16(sky2->hw, sky2->port, GM_SERIAL_MODE, reg); -} - /* Enable Rx/Tx */ static void sky2_enable_rx_tx(struct sky2_port *sky2) { @@ -964,7 +882,7 @@ static void sky2_mac_init(struct sky2_hw *hw, unsigned port) /* serial mode register */ reg = DATA_BLIND_VAL(DATA_BLIND_DEF) | - GM_SMOD_VLAN_ENA | IPG_DATA_VAL(IPG_DATA_DEF_1000); + GM_SMOD_VLAN_ENA | IPG_DATA_VAL(IPG_DATA_DEF); if (hw->dev[port]->mtu > ETH_DATA_LEN) reg |= GM_SMOD_JUMBO_ENA; @@ -1444,14 +1362,13 @@ static inline unsigned sky2_rx_pad(const struct sky2_hw *hw) * Allocate an skb for receiving. If the MTU is large enough * make the skb non-linear with a fragment list of pages. */ -static struct sk_buff *sky2_rx_alloc(struct sky2_port *sky2, gfp_t gfp) +static struct sk_buff *sky2_rx_alloc(struct sky2_port *sky2) { struct sk_buff *skb; int i; - skb = __netdev_alloc_skb(sky2->netdev, - sky2->rx_data_size + sky2_rx_pad(sky2->hw), - gfp); + skb = netdev_alloc_skb(sky2->netdev, + sky2->rx_data_size + sky2_rx_pad(sky2->hw)); if (!skb) goto nomem; @@ -1469,7 +1386,7 @@ static struct sk_buff *sky2_rx_alloc(struct sky2_port *sky2, gfp_t gfp) skb_reserve(skb, NET_IP_ALIGN); for (i = 0; i < sky2->rx_nfrags; i++) { - struct page *page = alloc_page(gfp); + struct page *page = alloc_page(GFP_ATOMIC); if (!page) goto free_partial; @@ -1499,7 +1416,7 @@ static int sky2_alloc_rx_skbs(struct sky2_port *sky2) for (i = 0; i < sky2->rx_pending; i++) { struct rx_ring_info *re = sky2->rx_ring + i; - re->skb = sky2_rx_alloc(sky2, GFP_KERNEL); + re->skb = sky2_rx_alloc(sky2); if (!re->skb) return -ENOMEM; @@ -1532,7 +1449,7 @@ static void sky2_rx_start(struct sky2_port *sky2) sky2_qset(hw, rxq); /* On PCI express lowering the watermark gives better performance */ - if (pci_is_pcie(hw->pdev)) + if (pci_find_capability(hw->pdev, PCI_CAP_ID_EXP)) sky2_write32(hw, Q_ADDR(rxq, Q_WM), BMU_WM_PEX); /* These chips have no ram buffer? @@ -2135,8 +2052,6 @@ static void sky2_link_up(struct sky2_port *sky2) [FC_BOTH] = "both", }; - sky2_set_ipg(sky2); - sky2_enable_rx_tx(sky2); gm_phy_write(hw, port, PHY_MARV_INT_MASK, PHY_M_DEF_MSK); @@ -2374,11 +2289,8 @@ static int sky2_change_mtu(struct net_device *dev, int new_mtu) dev->mtu = new_mtu; netdev_update_features(dev); - mode = DATA_BLIND_VAL(DATA_BLIND_DEF) | GM_SMOD_VLAN_ENA; - if (sky2->speed > SPEED_100) - mode |= IPG_DATA_VAL(IPG_DATA_DEF_1000); - else - mode |= IPG_DATA_VAL(IPG_DATA_DEF_10_100); + mode = DATA_BLIND_VAL(DATA_BLIND_DEF) | + GM_SMOD_VLAN_ENA | IPG_DATA_VAL(IPG_DATA_DEF); if (dev->mtu > ETH_DATA_LEN) mode |= GM_SMOD_JUMBO_ENA; @@ -2472,7 +2384,7 @@ static struct sk_buff *receive_new(struct sky2_port *sky2, struct rx_ring_info nre; unsigned hdr_space = sky2->rx_data_size; - nre.skb = sky2_rx_alloc(sky2, GFP_ATOMIC); + nre.skb = sky2_rx_alloc(sky2); if (unlikely(!nre.skb)) goto nobuf; @@ -3027,8 +2939,6 @@ static u32 sky2_mhz(const struct sky2_hw *hw) case CHIP_ID_YUKON_SUPR: case CHIP_ID_YUKON_UL_2: case CHIP_ID_YUKON_OPT: - case CHIP_ID_YUKON_PRM: - case CHIP_ID_YUKON_OP_2: return 125; case CHIP_ID_YUKON_FE: @@ -3085,8 +2995,7 @@ static int __devinit sky2_init(struct sky2_hw *hw) hw->flags = SKY2_HW_GIGABIT | SKY2_HW_NEWER_PHY | SKY2_HW_NEW_LE - | SKY2_HW_ADV_POWER_CTL - | SKY2_HW_RSS_CHKSUM; + | SKY2_HW_ADV_POWER_CTL; /* New transmit checksum */ if (hw->chip_rev != CHIP_REV_YU_EX_B0) @@ -3114,7 +3023,7 @@ static int __devinit sky2_init(struct sky2_hw *hw) /* The workaround for status conflicts VLAN tag detection. */ if (hw->chip_rev == CHIP_REV_YU_FE2_A0) - hw->flags |= SKY2_HW_VLAN_BROKEN | SKY2_HW_RSS_CHKSUM; + hw->flags |= SKY2_HW_VLAN_BROKEN; break; case CHIP_ID_YUKON_SUPR: @@ -3123,9 +3032,6 @@ static int __devinit sky2_init(struct sky2_hw *hw) | SKY2_HW_NEW_LE | SKY2_HW_AUTO_TX_SUM | SKY2_HW_ADV_POWER_CTL; - - if (hw->chip_rev == CHIP_REV_YU_SU_A0) - hw->flags |= SKY2_HW_RSS_CHKSUM; break; case CHIP_ID_YUKON_UL_2: @@ -3134,8 +3040,6 @@ static int __devinit sky2_init(struct sky2_hw *hw) break; case CHIP_ID_YUKON_OPT: - case CHIP_ID_YUKON_PRM: - case CHIP_ID_YUKON_OP_2: hw->flags = SKY2_HW_GIGABIT | SKY2_HW_NEW_LE | SKY2_HW_ADV_POWER_CTL; @@ -3168,7 +3072,7 @@ static void sky2_reset(struct sky2_hw *hw) { struct pci_dev *pdev = hw->pdev; u16 status; - int i; + int i, cap; u32 hwe_mask = Y2_HWE_ALL_MASK; /* disable ASF */ @@ -3204,7 +3108,8 @@ static void sky2_reset(struct sky2_hw *hw) sky2_write8(hw, B0_CTST, CS_MRST_CLR); - if (pci_is_pcie(pdev)) { + cap = pci_find_capability(pdev, PCI_CAP_ID_EXP); + if (cap) { sky2_write32(hw, Y2_CFG_AER + PCI_ERR_UNCOR_STATUS, 0xfffffffful); @@ -3235,33 +3140,30 @@ static void sky2_reset(struct sky2_hw *hw) sky2_pci_write32(hw, PCI_DEV_REG3, P_CLK_MACSEC_DIS); } - if (hw->chip_id == CHIP_ID_YUKON_OPT || - hw->chip_id == CHIP_ID_YUKON_PRM || - hw->chip_id == CHIP_ID_YUKON_OP_2) { + if (hw->chip_id == CHIP_ID_YUKON_OPT) { u16 reg; u32 msk; - if (hw->chip_id == CHIP_ID_YUKON_OPT && hw->chip_rev == 0) { + if (hw->chip_rev == 0) { /* disable PCI-E PHY power down (set PHY reg 0x80, bit 7 */ sky2_write32(hw, Y2_PEX_PHY_DATA, (0x80UL << 16) | (1 << 7)); /* set PHY Link Detect Timer to 1.1 second (11x 100ms) */ reg = 10; - - /* re-enable PEX PM in PEX PHY debug reg. 8 (clear bit 12) */ - sky2_write32(hw, Y2_PEX_PHY_DATA, PEX_DB_ACCESS | (0x08UL << 16)); } else { /* set PHY Link Detect Timer to 0.4 second (4x 100ms) */ reg = 3; } reg <<= PSM_CONFIG_REG4_TIMER_PHY_LINK_DETECT_BASE; - reg |= PSM_CONFIG_REG4_RST_PHY_LINK_DETECT; /* reset PHY Link Detect */ sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_ON); + sky2_pci_write16(hw, PSM_CONFIG_REG4, + reg | PSM_CONFIG_REG4_RST_PHY_LINK_DETECT); sky2_pci_write16(hw, PSM_CONFIG_REG4, reg); + /* enable PHY Quick Link */ msk = sky2_read32(hw, B0_IMSK); msk |= Y2_IS_PHY_QLNK; @@ -3269,11 +3171,11 @@ static void sky2_reset(struct sky2_hw *hw) /* check if PSMv2 was running before */ reg = sky2_pci_read16(hw, PSM_CONFIG_REG3); - if (reg & PCI_EXP_LNKCTL_ASPMC) + if (reg & PCI_EXP_LNKCTL_ASPMC) { + cap = pci_find_capability(pdev, PCI_CAP_ID_EXP); /* restore the PCIe Link Control register */ - sky2_pci_write16(hw, pdev->pcie_cap + PCI_EXP_LNKCTL, - reg); - + sky2_pci_write16(hw, cap + PCI_EXP_LNKCTL, reg); + } sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_OFF); /* re-enable PEX PM in PEX PHY debug reg. 8 (clear bit 12) */ @@ -4274,18 +4176,8 @@ static u32 sky2_fix_features(struct net_device *dev, u32 features) /* In order to do Jumbo packets on these chips, need to turn off the * transmit store/forward. Therefore checksum offload won't work. */ - if (dev->mtu > ETH_DATA_LEN && hw->chip_id == CHIP_ID_YUKON_EC_U) { - netdev_info(dev, "checksum offload not possible with jumbo frames\n"); + if (dev->mtu > ETH_DATA_LEN && hw->chip_id == CHIP_ID_YUKON_EC_U) features &= ~(NETIF_F_TSO|NETIF_F_SG|NETIF_F_ALL_CSUM); - } - - /* Some hardware requires receive checksum for RSS to work. */ - if ( (features & NETIF_F_RXHASH) && - !(features & NETIF_F_RXCSUM) && - (sky2->hw->flags & SKY2_HW_RSS_CHKSUM)) { - netdev_info(dev, "receive hashing forces receive checksum\n"); - features |= NETIF_F_RXCSUM; - } return features; } @@ -4785,11 +4677,9 @@ static const char *sky2_name(u8 chipid, char *buf, int sz) "UL 2", /* 0xba */ "Unknown", /* 0xbb */ "Optima", /* 0xbc */ - "Optima Prime", /* 0xbd */ - "Optima 2", /* 0xbe */ }; - if (chipid >= CHIP_ID_YUKON_XL && chipid <= CHIP_ID_YUKON_OP_2) + if (chipid >= CHIP_ID_YUKON_XL && chipid <= CHIP_ID_YUKON_OPT) strncpy(buf, name[chipid - CHIP_ID_YUKON_XL], sz); else snprintf(buf, sz, "(chip %#x)", chipid); diff --git a/trunk/drivers/net/sky2.h b/trunk/drivers/net/sky2.h index 0af31b8b5f10..318c9ae7bf91 100644 --- a/trunk/drivers/net/sky2.h +++ b/trunk/drivers/net/sky2.h @@ -412,7 +412,7 @@ enum { Y2_IS_HW_ERR = 1<<31, /* Interrupt HW Error */ Y2_IS_STAT_BMU = 1<<30, /* Status BMU Interrupt */ Y2_IS_ASF = 1<<29, /* ASF subsystem Interrupt */ - Y2_IS_CPU_TO = 1<<28, /* CPU Timeout */ + Y2_IS_POLL_CHK = 1<<27, /* Check IRQ from polling unit */ Y2_IS_TWSI_RDY = 1<<26, /* IRQ on end of TWSI Tx */ Y2_IS_IRQ_SW = 1<<25, /* SW forced IRQ */ @@ -547,8 +547,6 @@ enum { CHIP_ID_YUKON_SUPR = 0xb9, /* YUKON-2 Supreme */ CHIP_ID_YUKON_UL_2 = 0xba, /* YUKON-2 Ultra 2 */ CHIP_ID_YUKON_OPT = 0xbc, /* YUKON-2 Optima */ - CHIP_ID_YUKON_PRM = 0xbd, /* YUKON-2 Optima Prime */ - CHIP_ID_YUKON_OP_2 = 0xbe, /* YUKON-2 Optima 2 */ }; enum yukon_xl_rev { @@ -1422,10 +1420,8 @@ enum { PHY_M_EC_FIB_AN_ENA = 1<<3, /* Fiber Auto-Neg. Enable (88E1011S only) */ PHY_M_EC_DTE_D_ENA = 1<<2, /* DTE Detect Enable (88E1111 only) */ PHY_M_EC_TX_TIM_CT = 1<<1, /* RGMII Tx Timing Control */ - PHY_M_EC_TRANS_DIS = 1<<0, /* Transmitter Disable (88E1111 only) */ + PHY_M_EC_TRANS_DIS = 1<<0, /* Transmitter Disable (88E1111 only) */}; - PHY_M_10B_TE_ENABLE = 1<<7, /* 10Base-Te Enable (88E8079 and above) */ -}; #define PHY_M_EC_M_DSC(x) ((u16)(x)<<10 & PHY_M_EC_M_DSC_MSK) /* 00=1x; 01=2x; 10=3x; 11=4x */ #define PHY_M_EC_S_DSC(x) ((u16)(x)<<8 & PHY_M_EC_S_DSC_MSK) @@ -1811,11 +1807,10 @@ enum { }; #define DATA_BLIND_VAL(x) (((x)<<11) & GM_SMOD_DATABL_MSK) -#define IPG_DATA_VAL(x) (x & GM_SMOD_IPG_MSK) - #define DATA_BLIND_DEF 0x04 -#define IPG_DATA_DEF_1000 0x1e -#define IPG_DATA_DEF_10_100 0x18 + +#define IPG_DATA_VAL(x) (x & GM_SMOD_IPG_MSK) +#define IPG_DATA_DEF 0x1e /* GM_SMI_CTRL 16 bit r/w SMI Control Register */ enum { @@ -2286,7 +2281,6 @@ struct sky2_hw { #define SKY2_HW_ADV_POWER_CTL 0x00000080 /* additional PHY power regs */ #define SKY2_HW_RSS_BROKEN 0x00000100 #define SKY2_HW_VLAN_BROKEN 0x00000200 -#define SKY2_HW_RSS_CHKSUM 0x00000400 /* RSS requires chksum */ u8 chip_id; u8 chip_rev; diff --git a/trunk/drivers/net/slip.c b/trunk/drivers/net/slip.c index 8befe697bd76..8ec1a9a0bb9a 100644 --- a/trunk/drivers/net/slip.c +++ b/trunk/drivers/net/slip.c @@ -182,10 +182,10 @@ static int sl_alloc_bufs(struct slip *sl, int mtu) #ifdef SL_INCLUDE_CSLIP cbuff = xchg(&sl->cbuff, cbuff); slcomp = xchg(&sl->slcomp, slcomp); -#endif #ifdef CONFIG_SLIP_MODE_SLIP6 sl->xdata = 0; sl->xbits = 0; +#endif #endif spin_unlock_bh(&sl->lock); err = 0; @@ -194,7 +194,8 @@ static int sl_alloc_bufs(struct slip *sl, int mtu) err_exit: #ifdef SL_INCLUDE_CSLIP kfree(cbuff); - slhc_free(slcomp); + if (slcomp) + slhc_free(slcomp); #endif kfree(xbuff); kfree(rbuff); @@ -247,7 +248,7 @@ static int sl_realloc_bufs(struct slip *sl, int mtu) #else if (xbuff == NULL || rbuff == NULL) { #endif - if (mtu > sl->mtu) { + if (mtu >= sl->mtu) { printk(KERN_WARNING "%s: unable to grow slip buffers, MTU change cancelled.\n", dev->name); err = -ENOBUFS; @@ -723,10 +724,12 @@ static void sl_sync(void) static struct slip *sl_alloc(dev_t line) { int i; - char name[IFNAMSIZ]; struct net_device *dev = NULL; struct slip *sl; + if (slip_devs == NULL) + return NULL; /* Master array missing ! */ + for (i = 0; i < slip_maxdev; i++) { dev = slip_devs[i]; if (dev == NULL) @@ -736,12 +739,25 @@ static struct slip *sl_alloc(dev_t line) if (i >= slip_maxdev) return NULL; - sprintf(name, "sl%d", i); - dev = alloc_netdev(sizeof(*sl), name, sl_setup); - if (!dev) - return NULL; + if (dev) { + sl = netdev_priv(dev); + if (test_bit(SLF_INUSE, &sl->flags)) { + unregister_netdevice(dev); + dev = NULL; + slip_devs[i] = NULL; + } + } + + if (!dev) { + char name[IFNAMSIZ]; + sprintf(name, "sl%d", i); + + dev = alloc_netdev(sizeof(*sl), name, sl_setup); + if (!dev) + return NULL; + dev->base_addr = i; + } - dev->base_addr = i; sl = netdev_priv(dev); /* Initialize channel control data */ diff --git a/trunk/drivers/net/smc911x.c b/trunk/drivers/net/smc911x.c index a91fe1723020..053863aefb12 100644 --- a/trunk/drivers/net/smc911x.c +++ b/trunk/drivers/net/smc911x.c @@ -1351,6 +1351,11 @@ static void smc911x_set_multicast_list(struct net_device *dev) netdev_for_each_mc_addr(ha, dev) { u32 position; + /* make sure this is a multicast address - + shouldn't this be a given if we have it here ? */ + if (!(*ha->addr & 1)) + continue; + /* upper 6 bits are used as hash index */ position = ether_crc(ETH_ALEN, ha->addr)>>26; diff --git a/trunk/drivers/net/smc9194.c b/trunk/drivers/net/smc9194.c index 5b65ac4b3cef..7486d0908064 100644 --- a/trunk/drivers/net/smc9194.c +++ b/trunk/drivers/net/smc9194.c @@ -447,6 +447,11 @@ static void smc_setmulticast(int ioaddr, struct net_device *dev) netdev_for_each_mc_addr(ha, dev) { int position; + /* make sure this is a multicast address - shouldn't this + be a given if we have it here ? */ + if (!(*ha->addr & 1)) + continue; + /* only use the low order bits */ position = ether_crc_le(6, ha->addr) & 0x3f; diff --git a/trunk/drivers/net/smc91x.c b/trunk/drivers/net/smc91x.c index 2b1d254d59af..f6285748bd3c 100644 --- a/trunk/drivers/net/smc91x.c +++ b/trunk/drivers/net/smc91x.c @@ -1425,6 +1425,11 @@ static void smc_set_multicast_list(struct net_device *dev) netdev_for_each_mc_addr(ha, dev) { int position; + /* make sure this is a multicast address - + shouldn't this be a given if we have it here ? */ + if (!(*ha->addr & 1)) + continue; + /* only use the low order bits */ position = crc32_le(~0, ha->addr, 6) & 0x3f; diff --git a/trunk/drivers/net/sunbmac.c b/trunk/drivers/net/sunbmac.c index 297a4242106b..aa4765803a4c 100644 --- a/trunk/drivers/net/sunbmac.c +++ b/trunk/drivers/net/sunbmac.c @@ -998,6 +998,7 @@ static void bigmac_set_multicast(struct net_device *dev) struct bigmac *bp = netdev_priv(dev); void __iomem *bregs = bp->bregs; struct netdev_hw_addr *ha; + char *addrs; int i; u32 tmp, crc; @@ -1026,7 +1027,12 @@ static void bigmac_set_multicast(struct net_device *dev) hash_table[i] = 0; netdev_for_each_mc_addr(ha, dev) { - crc = ether_crc_le(6, ha->addr); + addrs = ha->addr; + + if (!(*addrs & 1)) + continue; + + crc = ether_crc_le(6, addrs); crc >>= 26; hash_table[crc >> 4] |= 1 << (crc & 0xf); } diff --git a/trunk/drivers/net/sungem.c b/trunk/drivers/net/sungem.c index ade35dde5b51..71d4a0329d02 100644 --- a/trunk/drivers/net/sungem.c +++ b/trunk/drivers/net/sungem.c @@ -1802,7 +1802,12 @@ static u32 gem_setup_multicast(struct gem *gp) memset(hash_table, 0, sizeof(hash_table)); netdev_for_each_mc_addr(ha, gp->dev) { - crc = ether_crc_le(6, ha->addr); + char *addrs = ha->addr; + + if (!(*addrs & 1)) + continue; + + crc = ether_crc_le(6, addrs); crc >>= 24; hash_table[crc >> 4] |= 1 << (15 - (crc & 0xf)); } diff --git a/trunk/drivers/net/sunhme.c b/trunk/drivers/net/sunhme.c index 856e05b9fba3..30aad54b1b3a 100644 --- a/trunk/drivers/net/sunhme.c +++ b/trunk/drivers/net/sunhme.c @@ -1524,11 +1524,17 @@ static int happy_meal_init(struct happy_meal *hp) } else if ((hp->dev->flags & IFF_PROMISC) == 0) { u16 hash_table[4]; struct netdev_hw_addr *ha; + char *addrs; u32 crc; memset(hash_table, 0, sizeof(hash_table)); netdev_for_each_mc_addr(ha, hp->dev) { - crc = ether_crc_le(6, ha->addr); + addrs = ha->addr; + + if (!(*addrs & 1)) + continue; + + crc = ether_crc_le(6, addrs); crc >>= 26; hash_table[crc >> 4] |= 1 << (crc & 0xf); } @@ -2355,6 +2361,7 @@ static void happy_meal_set_multicast(struct net_device *dev) struct happy_meal *hp = netdev_priv(dev); void __iomem *bregs = hp->bigmacregs; struct netdev_hw_addr *ha; + char *addrs; u32 crc; spin_lock_irq(&hp->happy_lock); @@ -2372,7 +2379,12 @@ static void happy_meal_set_multicast(struct net_device *dev) memset(hash_table, 0, sizeof(hash_table)); netdev_for_each_mc_addr(ha, dev) { - crc = ether_crc_le(6, ha->addr); + addrs = ha->addr; + + if (!(*addrs & 1)) + continue; + + crc = ether_crc_le(6, addrs); crc >>= 26; hash_table[crc >> 4] |= 1 << (crc & 0xf); } diff --git a/trunk/drivers/net/sunlance.c b/trunk/drivers/net/sunlance.c index 06f2d4382dc4..32a5c7f63c43 100644 --- a/trunk/drivers/net/sunlance.c +++ b/trunk/drivers/net/sunlance.c @@ -1170,6 +1170,7 @@ static void lance_load_multicast(struct net_device *dev) { struct lance_private *lp = netdev_priv(dev); struct netdev_hw_addr *ha; + char *addrs; u32 crc; u32 val; @@ -1194,7 +1195,12 @@ static void lance_load_multicast(struct net_device *dev) /* Add addresses */ netdev_for_each_mc_addr(ha, dev) { - crc = ether_crc_le(6, ha->addr); + addrs = ha->addr; + + /* multicast address? */ + if (!(*addrs & 1)) + continue; + crc = ether_crc_le(6, addrs); crc = crc >> 26; if (lp->pio_buffer) { struct lance_init_block __iomem *ib = lp->init_block_iomem; diff --git a/trunk/drivers/net/sunqe.c b/trunk/drivers/net/sunqe.c index 209c7f8df003..18ecdc303751 100644 --- a/trunk/drivers/net/sunqe.c +++ b/trunk/drivers/net/sunqe.c @@ -628,6 +628,7 @@ static void qe_set_multicast(struct net_device *dev) struct sunqe *qep = netdev_priv(dev); struct netdev_hw_addr *ha; u8 new_mconfig = qep->mconfig; + char *addrs; int i; u32 crc; @@ -650,7 +651,11 @@ static void qe_set_multicast(struct net_device *dev) memset(hash_table, 0, sizeof(hash_table)); netdev_for_each_mc_addr(ha, dev) { - crc = ether_crc_le(6, ha->addr); + addrs = ha->addr; + + if (!(*addrs & 1)) + continue; + crc = ether_crc_le(6, addrs); crc >>= 26; hash_table[crc >> 4] |= 1 << (crc & 0xf); } diff --git a/trunk/drivers/net/tg3.c b/trunk/drivers/net/tg3.c index a5ff82d3b750..97cd02d08021 100644 --- a/trunk/drivers/net/tg3.c +++ b/trunk/drivers/net/tg3.c @@ -608,7 +608,7 @@ static void tg3_read_mem(struct tg3 *tp, u32 off, u32 *val) static void tg3_ape_lock_init(struct tg3 *tp) { int i; - u32 regbase, bit; + u32 regbase; if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5761) regbase = TG3_APE_LOCK_GRANT; @@ -616,34 +616,20 @@ static void tg3_ape_lock_init(struct tg3 *tp) regbase = TG3_APE_PER_LOCK_GRANT; /* Make sure the driver hasn't any stale locks. */ - for (i = 0; i < 8; i++) { - if (i == TG3_APE_LOCK_GPIO) - continue; + for (i = 0; i < 8; i++) tg3_ape_write32(tp, regbase + 4 * i, APE_LOCK_GRANT_DRIVER); - } - - /* Clear the correct bit of the GPIO lock too. */ - if (!tp->pci_fn) - bit = APE_LOCK_GRANT_DRIVER; - else - bit = 1 << tp->pci_fn; - - tg3_ape_write32(tp, regbase + 4 * TG3_APE_LOCK_GPIO, bit); } static int tg3_ape_lock(struct tg3 *tp, int locknum) { int i, off; int ret = 0; - u32 status, req, gnt, bit; + u32 status, req, gnt; if (!tg3_flag(tp, ENABLE_APE)) return 0; switch (locknum) { - case TG3_APE_LOCK_GPIO: - if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5761) - return 0; case TG3_APE_LOCK_GRC: case TG3_APE_LOCK_MEM: break; @@ -661,24 +647,21 @@ static int tg3_ape_lock(struct tg3 *tp, int locknum) off = 4 * locknum; - if (locknum != TG3_APE_LOCK_GPIO || !tp->pci_fn) - bit = APE_LOCK_REQ_DRIVER; - else - bit = 1 << tp->pci_fn; - - tg3_ape_write32(tp, req + off, bit); + tg3_ape_write32(tp, req + off, APE_LOCK_REQ_DRIVER); /* Wait for up to 1 millisecond to acquire lock. */ for (i = 0; i < 100; i++) { status = tg3_ape_read32(tp, gnt + off); - if (status == bit) + if (status == APE_LOCK_GRANT_DRIVER) break; udelay(10); } - if (status != bit) { + if (status != APE_LOCK_GRANT_DRIVER) { /* Revoke the lock request. */ - tg3_ape_write32(tp, gnt + off, bit); + tg3_ape_write32(tp, gnt + off, + APE_LOCK_GRANT_DRIVER); + ret = -EBUSY; } @@ -687,15 +670,12 @@ static int tg3_ape_lock(struct tg3 *tp, int locknum) static void tg3_ape_unlock(struct tg3 *tp, int locknum) { - u32 gnt, bit; + u32 gnt; if (!tg3_flag(tp, ENABLE_APE)) return; switch (locknum) { - case TG3_APE_LOCK_GPIO: - if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5761) - return; case TG3_APE_LOCK_GRC: case TG3_APE_LOCK_MEM: break; @@ -708,12 +688,7 @@ static void tg3_ape_unlock(struct tg3 *tp, int locknum) else gnt = TG3_APE_PER_LOCK_GRANT; - if (locknum != TG3_APE_LOCK_GPIO || !tp->pci_fn) - bit = APE_LOCK_GRANT_DRIVER; - else - bit = 1 << tp->pci_fn; - - tg3_ape_write32(tp, gnt + 4 * locknum, bit); + tg3_ape_write32(tp, gnt + 4 * locknum, APE_LOCK_GRANT_DRIVER); } static void tg3_disable_ints(struct tg3 *tp) @@ -1195,7 +1170,7 @@ static int tg3_mdio_init(struct tg3 *tp) if (tg3_flag(tp, 5717_PLUS)) { u32 is_serdes; - tp->phy_addr = tp->pci_fn + 1; + tp->phy_addr = PCI_FUNC(tp->pdev->devfn) + 1; if (tp->pci_chip_rev_id != CHIPREV_ID_5717_A0) is_serdes = tr32(SG_DIG_STATUS) & SG_DIG_IS_SERDES; @@ -2192,66 +2167,13 @@ static int tg3_phy_reset(struct tg3 *tp) return 0; } -#define TG3_GPIO_MSG_DRVR_PRES 0x00000001 -#define TG3_GPIO_MSG_NEED_VAUX 0x00000002 -#define TG3_GPIO_MSG_MASK (TG3_GPIO_MSG_DRVR_PRES | \ - TG3_GPIO_MSG_NEED_VAUX) -#define TG3_GPIO_MSG_ALL_DRVR_PRES_MASK \ - ((TG3_GPIO_MSG_DRVR_PRES << 0) | \ - (TG3_GPIO_MSG_DRVR_PRES << 4) | \ - (TG3_GPIO_MSG_DRVR_PRES << 8) | \ - (TG3_GPIO_MSG_DRVR_PRES << 12)) - -#define TG3_GPIO_MSG_ALL_NEED_VAUX_MASK \ - ((TG3_GPIO_MSG_NEED_VAUX << 0) | \ - (TG3_GPIO_MSG_NEED_VAUX << 4) | \ - (TG3_GPIO_MSG_NEED_VAUX << 8) | \ - (TG3_GPIO_MSG_NEED_VAUX << 12)) - -static inline u32 tg3_set_function_status(struct tg3 *tp, u32 newstat) -{ - u32 status, shift; - - if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5717 || - GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5719) - status = tg3_ape_read32(tp, TG3_APE_GPIO_MSG); - else - status = tr32(TG3_CPMU_DRV_STATUS); - - shift = TG3_APE_GPIO_MSG_SHIFT + 4 * tp->pci_fn; - status &= ~(TG3_GPIO_MSG_MASK << shift); - status |= (newstat << shift); - - if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5717 || - GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5719) - tg3_ape_write32(tp, TG3_APE_GPIO_MSG, status); - else - tw32(TG3_CPMU_DRV_STATUS, status); - - return status >> TG3_APE_GPIO_MSG_SHIFT; -} - static inline int tg3_pwrsrc_switch_to_vmain(struct tg3 *tp) { if (!tg3_flag(tp, IS_NIC)) return 0; - if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5717 || - GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5719 || - GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5720) { - if (tg3_ape_lock(tp, TG3_APE_LOCK_GPIO)) - return -EIO; - - tg3_set_function_status(tp, TG3_GPIO_MSG_DRVR_PRES); - - tw32_wait_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl, - TG3_GRC_LCLCTL_PWRSW_DELAY); - - tg3_ape_unlock(tp, TG3_APE_LOCK_GPIO); - } else { - tw32_wait_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl, - TG3_GRC_LCLCTL_PWRSW_DELAY); - } + tw32_wait_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl, + TG3_GRC_LCLCTL_PWRSW_DELAY); return 0; } @@ -2357,49 +2279,21 @@ static void tg3_pwrsrc_switch_to_vaux(struct tg3 *tp) } } -static void tg3_frob_aux_power_5717(struct tg3 *tp, bool wol_enable) -{ - u32 msg = 0; - - /* Serialize power state transitions */ - if (tg3_ape_lock(tp, TG3_APE_LOCK_GPIO)) - return; - - if (tg3_flag(tp, ENABLE_ASF) || tg3_flag(tp, ENABLE_APE) || wol_enable) - msg = TG3_GPIO_MSG_NEED_VAUX; - - msg = tg3_set_function_status(tp, msg); - - if (msg & TG3_GPIO_MSG_ALL_DRVR_PRES_MASK) - goto done; - - if (msg & TG3_GPIO_MSG_ALL_NEED_VAUX_MASK) - tg3_pwrsrc_switch_to_vaux(tp); - else - tg3_pwrsrc_die_with_vmain(tp); - -done: - tg3_ape_unlock(tp, TG3_APE_LOCK_GPIO); -} - -static void tg3_frob_aux_power(struct tg3 *tp, bool include_wol) +static void tg3_frob_aux_power(struct tg3 *tp) { bool need_vaux = false; /* The GPIOs do something completely different on 57765. */ if (!tg3_flag(tp, IS_NIC) || - GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_57765) - return; - - if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5717 || GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5719 || - GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5720) { - tg3_frob_aux_power_5717(tp, include_wol ? - tg3_flag(tp, WOL_ENABLE) != 0 : 0); + GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_57765) return; - } - if (tp->pdev_peer && tp->pdev_peer != tp->pdev) { + if ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704 || + GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5714 || + GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5717 || + GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5720) && + tp->pdev_peer != tp->pdev) { struct net_device *dev_peer; dev_peer = pci_get_drvdata(tp->pdev_peer); @@ -2411,14 +2305,13 @@ static void tg3_frob_aux_power(struct tg3 *tp, bool include_wol) if (tg3_flag(tp_peer, INIT_COMPLETE)) return; - if ((include_wol && tg3_flag(tp_peer, WOL_ENABLE)) || + if (tg3_flag(tp_peer, WOL_ENABLE) || tg3_flag(tp_peer, ENABLE_ASF)) need_vaux = true; } } - if ((include_wol && tg3_flag(tp, WOL_ENABLE)) || - tg3_flag(tp, ENABLE_ASF)) + if (tg3_flag(tp, WOL_ENABLE) || tg3_flag(tp, ENABLE_ASF)) need_vaux = true; if (need_vaux) @@ -2764,19 +2657,14 @@ static void tg3_enable_register_access(struct tg3 *tp) static int tg3_power_up(struct tg3 *tp) { - int err; - tg3_enable_register_access(tp); - err = pci_set_power_state(tp->pdev, PCI_D0); - if (!err) { - /* Switch out of Vaux if it is a NIC */ - tg3_pwrsrc_switch_to_vmain(tp); - } else { - netdev_err(tp->dev, "Transition to D0 failed\n"); - } + pci_set_power_state(tp->pdev, PCI_D0); - return err; + /* Switch out of Vaux if it is a NIC */ + tg3_pwrsrc_switch_to_vmain(tp); + + return 0; } static int tg3_power_down_prepare(struct tg3 *tp) @@ -2791,11 +2679,11 @@ static int tg3_power_down_prepare(struct tg3 *tp) u16 lnkctl; pci_read_config_word(tp->pdev, - pci_pcie_cap(tp->pdev) + PCI_EXP_LNKCTL, + tp->pcie_cap + PCI_EXP_LNKCTL, &lnkctl); lnkctl |= PCI_EXP_LNKCTL_CLKREQ_EN; pci_write_config_word(tp->pdev, - pci_pcie_cap(tp->pdev) + PCI_EXP_LNKCTL, + tp->pcie_cap + PCI_EXP_LNKCTL, lnkctl); } @@ -3001,7 +2889,7 @@ static int tg3_power_down_prepare(struct tg3 *tp) if (!(device_should_wake) && !tg3_flag(tp, ENABLE_ASF)) tg3_power_down_phy(tp, do_low_power); - tg3_frob_aux_power(tp, true); + tg3_frob_aux_power(tp); /* Workaround for unstable PLL clock */ if ((GET_CHIP_REV(tp->pci_chip_rev_id) == CHIPREV_5750_AX) || @@ -3597,7 +3485,7 @@ static int tg3_setup_copper_phy(struct tg3 *tp, int force_reset) u16 oldlnkctl, newlnkctl; pci_read_config_word(tp->pdev, - pci_pcie_cap(tp->pdev) + PCI_EXP_LNKCTL, + tp->pcie_cap + PCI_EXP_LNKCTL, &oldlnkctl); if (tp->link_config.active_speed == SPEED_100 || tp->link_config.active_speed == SPEED_10) @@ -3606,7 +3494,7 @@ static int tg3_setup_copper_phy(struct tg3 *tp, int force_reset) newlnkctl = oldlnkctl | PCI_EXP_LNKCTL_CLKREQ_EN; if (newlnkctl != oldlnkctl) pci_write_config_word(tp->pdev, - pci_pcie_cap(tp->pdev) + PCI_EXP_LNKCTL, + tp->pcie_cap + PCI_EXP_LNKCTL, newlnkctl); } @@ -7338,7 +7226,7 @@ static int tg3_chip_reset(struct tg3 *tp) udelay(120); - if (tg3_flag(tp, PCI_EXPRESS) && pci_pcie_cap(tp->pdev)) { + if (tg3_flag(tp, PCI_EXPRESS) && tp->pcie_cap) { u16 val16; if (tp->pci_chip_rev_id == CHIPREV_ID_5750_A0) { @@ -7356,7 +7244,7 @@ static int tg3_chip_reset(struct tg3 *tp) /* Clear the "no snoop" and "relaxed ordering" bits. */ pci_read_config_word(tp->pdev, - pci_pcie_cap(tp->pdev) + PCI_EXP_DEVCTL, + tp->pcie_cap + PCI_EXP_DEVCTL, &val16); val16 &= ~(PCI_EXP_DEVCTL_RELAX_EN | PCI_EXP_DEVCTL_NOSNOOP_EN); @@ -7367,14 +7255,14 @@ static int tg3_chip_reset(struct tg3 *tp) if (!tg3_flag(tp, CPMU_PRESENT)) val16 &= ~PCI_EXP_DEVCTL_PAYLOAD; pci_write_config_word(tp->pdev, - pci_pcie_cap(tp->pdev) + PCI_EXP_DEVCTL, + tp->pcie_cap + PCI_EXP_DEVCTL, val16); pcie_set_readrq(tp->pdev, tp->pcie_readrq); /* Clear error status */ pci_write_config_word(tp->pdev, - pci_pcie_cap(tp->pdev) + PCI_EXP_DEVSTA, + tp->pcie_cap + PCI_EXP_DEVSTA, PCI_EXP_DEVSTA_CED | PCI_EXP_DEVSTA_NFED | PCI_EXP_DEVSTA_FED | @@ -9557,8 +9445,6 @@ static int tg3_open(struct net_device *dev) err_out1: tg3_ints_fini(tp); - tg3_frob_aux_power(tp, false); - pci_set_power_state(tp->pdev, PCI_D3hot); return err; } @@ -11547,12 +11433,8 @@ static void tg3_self_test(struct net_device *dev, struct ethtool_test *etest, { struct tg3 *tp = netdev_priv(dev); - if ((tp->phy_flags & TG3_PHYFLG_IS_LOW_POWER) && - tg3_power_up(tp)) { - etest->flags |= ETH_TEST_FL_FAILED; - memset(data, 1, sizeof(u64) * TG3_NUM_TEST); - return; - } + if (tp->phy_flags & TG3_PHYFLG_IS_LOW_POWER) + tg3_power_up(tp); memset(data, 0, sizeof(u64) * TG3_NUM_TEST); @@ -12796,6 +12678,29 @@ static struct subsys_tbl_ent * __devinit tg3_lookup_by_subsys(struct tg3 *tp) static void __devinit tg3_get_eeprom_hw_cfg(struct tg3 *tp) { u32 val; + u16 pmcsr; + + /* On some early chips the SRAM cannot be accessed in D3hot state, + * so need make sure we're in D0. + */ + pci_read_config_word(tp->pdev, tp->pm_cap + PCI_PM_CTRL, &pmcsr); + pmcsr &= ~PCI_PM_CTRL_STATE_MASK; + pci_write_config_word(tp->pdev, tp->pm_cap + PCI_PM_CTRL, pmcsr); + msleep(1); + + /* Make sure register accesses (indirect or otherwise) + * will function correctly. + */ + pci_write_config_dword(tp->pdev, TG3PCI_MISC_HOST_CTRL, + tp->misc_host_ctrl); + + /* The memory arbiter has to be enabled in order for SRAM accesses + * to succeed. Normally on powerup the tg3 chip firmware will make + * sure it is enabled, but other entities such as system netboot + * code might disable it. + */ + val = tr32(MEMARB_MODE); + tw32(MEMARB_MODE, val | MEMARB_MODE_ENABLE); tp->phy_id = TG3_PHY_ID_INVALID; tp->led_ctrl = LED_CTRL_MODE_PHY_1; @@ -13541,15 +13446,10 @@ static void __devinit tg3_read_fw_ver(struct tg3 *tp) else return; - if (vpd_vers) + if (!tg3_flag(tp, ENABLE_ASF) || tg3_flag(tp, ENABLE_APE) || vpd_vers) goto done; - if (tg3_flag(tp, ENABLE_APE)) { - if (tg3_flag(tp, ENABLE_ASF)) - tg3_read_dash_ver(tp); - } else if (tg3_flag(tp, ENABLE_ASF)) { - tg3_read_mgmtfw_ver(tp); - } + tg3_read_mgmtfw_ver(tp); done: tp->fw_ver[TG3_VER_SIZE - 1] = 0; @@ -13593,17 +13493,14 @@ static int __devinit tg3_get_invariants(struct tg3 *tp) pci_cmd &= ~PCI_COMMAND_INVALIDATE; pci_write_config_word(tp->pdev, PCI_COMMAND, pci_cmd); - /* Important! -- Make sure register accesses are byteswapped - * correctly. Also, for those chips that require it, make - * sure that indirect register accesses are enabled before - * the first operation. + /* It is absolutely critical that TG3PCI_MISC_HOST_CTRL + * has the register indirect write enable bit set before + * we try to access any of the MMIO registers. It is also + * critical that the PCI-X hw workaround situation is decided + * before that as well. */ pci_read_config_dword(tp->pdev, TG3PCI_MISC_HOST_CTRL, &misc_ctrl_reg); - tp->misc_host_ctrl |= (misc_ctrl_reg & - MISC_HOST_CTRL_CHIPREV); - pci_write_config_dword(tp->pdev, TG3PCI_MISC_HOST_CTRL, - tp->misc_host_ctrl); tp->pci_chip_rev_id = (misc_ctrl_reg >> MISC_HOST_CTRL_CHIPREV_SHIFT); @@ -13759,8 +13656,16 @@ static int __devinit tg3_get_invariants(struct tg3 *tp) } while (bridge); } + /* Initialize misc host control in PCI block. */ + tp->misc_host_ctrl |= (misc_ctrl_reg & + MISC_HOST_CTRL_CHIPREV); + pci_write_config_dword(tp->pdev, TG3PCI_MISC_HOST_CTRL, + tp->misc_host_ctrl); + if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704 || - GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5714) + GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5714 || + GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5717 || + GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5720) tp->pdev_peer = tg3_find_peer(tp); if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5717 || @@ -13872,7 +13777,8 @@ static int __devinit tg3_get_invariants(struct tg3 *tp) pci_read_config_dword(tp->pdev, TG3PCI_PCISTATE, &pci_state_reg); - if (pci_is_pcie(tp->pdev)) { + tp->pcie_cap = pci_find_capability(tp->pdev, PCI_CAP_ID_EXP); + if (tp->pcie_cap != 0) { u16 lnkctl; tg3_flag_set(tp, PCI_EXPRESS); @@ -13885,7 +13791,7 @@ static int __devinit tg3_get_invariants(struct tg3 *tp) pcie_set_readrq(tp->pdev, tp->pcie_readrq); pci_read_config_word(tp->pdev, - pci_pcie_cap(tp->pdev) + PCI_EXP_LNKCTL, + tp->pcie_cap + PCI_EXP_LNKCTL, &lnkctl); if (lnkctl & PCI_EXP_LNKCTL_CLKREQ_EN) { if (GET_ASIC_REV(tp->pci_chip_rev_id) == @@ -13902,10 +13808,6 @@ static int __devinit tg3_get_invariants(struct tg3 *tp) tg3_flag_set(tp, L1PLLPD_EN); } } else if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5785) { - /* BCM5785 devices are effectively PCIe devices, and should - * follow PCIe codepaths, but do not have a PCIe capabilities - * section. - */ tg3_flag_set(tp, PCI_EXPRESS); } else if (!tg3_flag(tp, 5705_PLUS) || tg3_flag(tp, 5780_CLASS)) { @@ -13941,9 +13843,6 @@ static int __devinit tg3_get_invariants(struct tg3 *tp) tp->pci_lat_timer); } - /* Important! -- It is critical that the PCI-X hw workaround - * situation is decided before the first MMIO register access. - */ if (GET_CHIP_REV(tp->pci_chip_rev_id) == CHIPREV_5700_BX) { /* 5700 BX chips need to have their TX producer index * mailboxes written twice to workaround a bug. @@ -14050,22 +13949,6 @@ static int __devinit tg3_get_invariants(struct tg3 *tp) GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5701))) tg3_flag_set(tp, SRAM_USE_CONFIG); - /* The memory arbiter has to be enabled in order for SRAM accesses - * to succeed. Normally on powerup the tg3 chip firmware will make - * sure it is enabled, but other entities such as system netboot - * code might disable it. - */ - val = tr32(MEMARB_MODE); - tw32(MEMARB_MODE, val | MEMARB_MODE_ENABLE); - - if (tg3_flag(tp, PCIX_MODE)) { - pci_read_config_dword(tp->pdev, - tp->pcix_cap + PCI_X_STATUS, &val); - tp->pci_fn = val & 0x7; - } else { - tp->pci_fn = PCI_FUNC(tp->pdev->devfn) & 3; - } - /* Get eeprom hw config before calling tg3_set_power_state(). * In particular, the TG3_FLAG_IS_NIC flag must be * determined before calling tg3_set_power_state() so that @@ -14085,8 +13968,6 @@ static int __devinit tg3_get_invariants(struct tg3 *tp) PCISTATE_ALLOW_APE_PSPACE_WR; pci_write_config_dword(tp->pdev, TG3PCI_PCISTATE, pci_state_reg); - - tg3_ape_lock_init(tp); } if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5784 || @@ -14096,9 +13977,8 @@ static int __devinit tg3_get_invariants(struct tg3 *tp) tg3_flag(tp, 57765_PLUS)) tg3_flag_set(tp, CPMU_PRESENT); - /* Set up tp->grc_local_ctrl before calling - * tg3_pwrsrc_switch_to_vmain(). GPIO1 driven high - * will bring 5700's external PHY out of reset. + /* Set up tp->grc_local_ctrl before calling tg3_power_up(). + * GPIO1 driven high will bring 5700's external PHY out of reset. * It is also used as eeprom write protect on LOMs. */ tp->grc_local_ctrl = GRC_LCLCTRL_INT_ON_ATTN | GRC_LCLCTRL_AUTO_SEEPROM; @@ -14127,8 +14007,12 @@ static int __devinit tg3_get_invariants(struct tg3 *tp) GRC_LCLCTRL_GPIO_OUTPUT0; } - /* Switch out of Vaux if it is a NIC */ - tg3_pwrsrc_switch_to_vmain(tp); + /* Force the chip into D0. */ + err = tg3_power_up(tp); + if (err) { + dev_err(&tp->pdev->dev, "Transition to D0 failed\n"); + return err; + } /* Derive initial jumbo mode from MTU assigned in * ether_setup() via the alloc_etherdev() call @@ -14431,9 +14315,9 @@ static int __devinit tg3_get_device_address(struct tg3 *tp) else tg3_nvram_unlock(tp); } else if (tg3_flag(tp, 5717_PLUS)) { - if (tp->pci_fn & 1) + if (PCI_FUNC(tp->pdev->devfn) & 1) mac_offset = 0xcc; - if (tp->pci_fn > 1) + if (PCI_FUNC(tp->pdev->devfn) > 1) mac_offset += 0x18c; } else if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5906) mac_offset = 0x10; @@ -15143,17 +15027,11 @@ static int __devinit tg3_init_one(struct pci_dev *pdev, goto err_out_free_res; } - err = pci_set_power_state(pdev, PCI_D0); - if (err) { - dev_err(&pdev->dev, "Transition to D0 failed, aborting\n"); - goto err_out_free_res; - } - dev = alloc_etherdev_mq(sizeof(*tp), TG3_IRQ_MAX_VECS); if (!dev) { dev_err(&pdev->dev, "Etherdev alloc failed, aborting\n"); err = -ENOMEM; - goto err_out_power_down; + goto err_out_free_res; } SET_NETDEV_DEV(dev, &pdev->dev); @@ -15202,24 +15080,6 @@ static int __devinit tg3_init_one(struct pci_dev *pdev, goto err_out_free_dev; } - if (tp->pdev->device == PCI_DEVICE_ID_TIGON3_5761 || - tp->pdev->device == PCI_DEVICE_ID_TIGON3_5761E || - tp->pdev->device == TG3PCI_DEVICE_TIGON3_5761S || - tp->pdev->device == TG3PCI_DEVICE_TIGON3_5761SE || - tp->pdev->device == TG3PCI_DEVICE_TIGON3_5717 || - tp->pdev->device == TG3PCI_DEVICE_TIGON3_5718 || - tp->pdev->device == TG3PCI_DEVICE_TIGON3_5719 || - tp->pdev->device == TG3PCI_DEVICE_TIGON3_5720) { - tg3_flag_set(tp, ENABLE_APE); - tp->aperegs = pci_ioremap_bar(pdev, BAR_2); - if (!tp->aperegs) { - dev_err(&pdev->dev, - "Cannot map APE registers, aborting\n"); - err = -ENOMEM; - goto err_out_iounmap; - } - } - tp->rx_pending = TG3_DEF_RX_RING_PENDING; tp->rx_jumbo_pending = TG3_DEF_RX_JUMBO_RING_PENDING; @@ -15232,7 +15092,7 @@ static int __devinit tg3_init_one(struct pci_dev *pdev, if (err) { dev_err(&pdev->dev, "Problem fetching invariants of chip, aborting\n"); - goto err_out_apeunmap; + goto err_out_iounmap; } /* The EPB bridge inside 5714, 5715, and 5780 and any @@ -15261,7 +15121,7 @@ static int __devinit tg3_init_one(struct pci_dev *pdev, if (err < 0) { dev_err(&pdev->dev, "Unable to obtain 64 bit " "DMA for consistent allocations\n"); - goto err_out_apeunmap; + goto err_out_iounmap; } } } @@ -15270,7 +15130,7 @@ static int __devinit tg3_init_one(struct pci_dev *pdev, if (err) { dev_err(&pdev->dev, "No usable DMA configuration, aborting\n"); - goto err_out_apeunmap; + goto err_out_iounmap; } } @@ -15335,7 +15195,22 @@ static int __devinit tg3_init_one(struct pci_dev *pdev, if (err) { dev_err(&pdev->dev, "Could not obtain valid ethernet address, aborting\n"); - goto err_out_apeunmap; + goto err_out_iounmap; + } + + if (tg3_flag(tp, ENABLE_APE)) { + tp->aperegs = pci_ioremap_bar(pdev, BAR_2); + if (!tp->aperegs) { + dev_err(&pdev->dev, + "Cannot map APE registers, aborting\n"); + err = -ENOMEM; + goto err_out_iounmap; + } + + tg3_ape_lock_init(tp); + + if (tg3_flag(tp, ENABLE_ASF)) + tg3_read_dash_ver(tp); } /* @@ -15403,11 +15278,6 @@ static int __devinit tg3_init_one(struct pci_dev *pdev, pci_set_drvdata(pdev, dev); - if (tg3_flag(tp, 5717_PLUS)) { - /* Resume a low-power mode */ - tg3_frob_aux_power(tp, false); - } - err = register_netdev(dev); if (err) { dev_err(&pdev->dev, "Cannot register net device, aborting\n"); @@ -15473,9 +15343,6 @@ static int __devinit tg3_init_one(struct pci_dev *pdev, err_out_free_dev: free_netdev(dev); -err_out_power_down: - pci_set_power_state(pdev, PCI_D3hot); - err_out_free_res: pci_release_regions(pdev); @@ -15700,8 +15567,10 @@ static pci_ers_result_t tg3_io_slot_reset(struct pci_dev *pdev) } err = tg3_power_up(tp); - if (err) + if (err) { + netdev_err(netdev, "Failed to restore register access.\n"); goto done; + } rc = PCI_ERS_RESULT_RECOVERED; diff --git a/trunk/drivers/net/tg3.h b/trunk/drivers/net/tg3.h index 6a43fc51d870..bedc3b4557b5 100644 --- a/trunk/drivers/net/tg3.h +++ b/trunk/drivers/net/tg3.h @@ -1065,8 +1065,6 @@ #define RCVLSC_STATUS_ERROR_ATTN 0x00000004 /* 0x3408 --> 0x3600 unused */ -#define TG3_CPMU_DRV_STATUS 0x0000344c - /* CPMU registers */ #define TG3_CPMU_CTRL 0x00003600 #define CPMU_CTRL_LINK_IDLE_MODE 0x00000200 @@ -2279,8 +2277,6 @@ /* APE registers. Accessible through BAR1 */ -#define TG3_APE_GPIO_MSG 0x0008 -#define TG3_APE_GPIO_MSG_SHIFT 4 #define TG3_APE_EVENT 0x000c #define APE_EVENT_1 0x00000001 #define TG3_APE_LOCK_REQ 0x002c @@ -2343,7 +2339,6 @@ /* APE convenience enumerations. */ #define TG3_APE_LOCK_GRC 1 #define TG3_APE_LOCK_MEM 4 -#define TG3_APE_LOCK_GPIO 7 #define TG3_EEPROM_SB_F1R2_MBA_OFF 0x10 @@ -2862,7 +2857,7 @@ enum TG3_FLAGS { TG3_FLAG_IS_5788, TG3_FLAG_MAX_RXPEND_64, TG3_FLAG_TSO_CAPABLE, - TG3_FLAG_PCI_EXPRESS, /* BCM5785 + pci_is_pcie() */ + TG3_FLAG_PCI_EXPRESS, TG3_FLAG_ASF_NEW_HANDSHAKE, TG3_FLAG_HW_AUTONEG, TG3_FLAG_IS_NIC, @@ -3025,10 +3020,12 @@ struct tg3 { u8 pci_cacheline_sz; u8 pci_lat_timer; - int pci_fn; int pm_cap; int msi_cap; + union { int pcix_cap; + int pcie_cap; + }; int pcie_readrq; struct mii_bus *mdio_bus; diff --git a/trunk/drivers/net/tulip/de4x5.c b/trunk/drivers/net/tulip/de4x5.c index 959b41021a65..efaa1d69b720 100644 --- a/trunk/drivers/net/tulip/de4x5.c +++ b/trunk/drivers/net/tulip/de4x5.c @@ -1868,13 +1868,14 @@ de4x5_local_stats(struct net_device *dev, char *buf, int pkt_len) i = DE4X5_PKT_STAT_SZ; } } - if (is_multicast_ether_addr(buf)) { - if (is_broadcast_ether_addr(buf)) { + if (buf[0] & 0x01) { /* Multicast/Broadcast */ + if ((*(s32 *)&buf[0] == -1) && (*(s16 *)&buf[4] == -1)) { lp->pktStats.broadcast++; } else { lp->pktStats.multicast++; } - } else if (compare_ether_addr(buf, dev->dev_addr) == 0) { + } else if ((*(s32 *)&buf[0] == *(s32 *)&dev->dev_addr[0]) && + (*(s16 *)&buf[4] == *(s16 *)&dev->dev_addr[4])) { lp->pktStats.unicast++; } @@ -1963,7 +1964,9 @@ SetMulticastFilter(struct net_device *dev) omr |= OMR_PM; /* Pass all multicasts */ } else if (lp->setup_f == HASH_PERF) { /* Hash Filtering */ netdev_for_each_mc_addr(ha, dev) { - crc = ether_crc_le(ETH_ALEN, ha->addr); + addrs = ha->addr; + if ((*addrs & 0x01) == 1) { /* multicast address? */ + crc = ether_crc_le(ETH_ALEN, addrs); hashcode = crc & HASH_BITS; /* hashcode is 9 LSb of CRC */ byte = hashcode >> 3; /* bit[3-8] -> byte in filter */ @@ -1974,6 +1977,7 @@ SetMulticastFilter(struct net_device *dev) byte -= 1; } lp->setup_frame[byte] |= bit; + } } } else { /* Perfect filtering */ netdev_for_each_mc_addr(ha, dev) { diff --git a/trunk/drivers/net/ucc_geth.c b/trunk/drivers/net/ucc_geth.c index d3465ab50e56..3127700f348b 100644 --- a/trunk/drivers/net/ucc_geth.c +++ b/trunk/drivers/net/ucc_geth.c @@ -2030,6 +2030,11 @@ static void ucc_geth_set_multi(struct net_device *dev) out_be32(&p_82xx_addr_filt->gaddr_l, 0x0); netdev_for_each_mc_addr(ha, dev) { + /* Only support group multicast for now. + */ + if (!is_multicast_ether_addr(ha->addr)) + continue; + /* Ask CPM to run CRC and set bit in * filter mask. */ diff --git a/trunk/drivers/net/usb/cdc_ncm.c b/trunk/drivers/net/usb/cdc_ncm.c index fd622a66ebbf..f33ca6aa29e9 100644 --- a/trunk/drivers/net/usb/cdc_ncm.c +++ b/trunk/drivers/net/usb/cdc_ncm.c @@ -47,6 +47,7 @@ #include #include #include +#include #include #include #include diff --git a/trunk/drivers/net/usb/hso.c b/trunk/drivers/net/usb/hso.c index 304fe78ff60e..387ca43f26f4 100644 --- a/trunk/drivers/net/usb/hso.c +++ b/trunk/drivers/net/usb/hso.c @@ -2421,8 +2421,10 @@ static void hso_free_net_device(struct hso_device *hso_dev) remove_net_device(hso_net->parent); - if (hso_net->net) + if (hso_net->net) { unregister_netdev(hso_net->net); + free_netdev(hso_net->net); + } /* start freeing */ for (i = 0; i < MUX_BULK_RX_BUF_COUNT; i++) { @@ -2434,9 +2436,6 @@ static void hso_free_net_device(struct hso_device *hso_dev) kfree(hso_net->mux_bulk_tx_buf); hso_net->mux_bulk_tx_buf = NULL; - if (hso_net->net) - free_netdev(hso_net->net); - kfree(hso_dev); } diff --git a/trunk/drivers/net/usb/kalmia.c b/trunk/drivers/net/usb/kalmia.c index 5a6d0f88f43b..d965fb1e013e 100644 --- a/trunk/drivers/net/usb/kalmia.c +++ b/trunk/drivers/net/usb/kalmia.c @@ -100,42 +100,34 @@ kalmia_send_init_packet(struct usbnet *dev, u8 *init_msg, u8 init_msg_len, static int kalmia_init_and_get_ethernet_addr(struct usbnet *dev, u8 *ethernet_addr) { - static const char init_msg_1[] = + char init_msg_1[] = { 0x57, 0x50, 0x04, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00 }; - static const char init_msg_2[] = + char init_msg_2[] = { 0x57, 0x50, 0x04, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0xf4, 0x00, 0x00 }; - static const int buflen = 28; - char *usb_buf; + char receive_buf[28]; int status; - usb_buf = kmalloc(buflen, GFP_DMA | GFP_KERNEL); - if (!usb_buf) - return -ENOMEM; - - memcpy(usb_buf, init_msg_1, 12); - status = kalmia_send_init_packet(dev, usb_buf, sizeof(init_msg_1) - / sizeof(init_msg_1[0]), usb_buf, 24); + status = kalmia_send_init_packet(dev, init_msg_1, sizeof(init_msg_1) + / sizeof(init_msg_1[0]), receive_buf, 24); if (status != 0) return status; - memcpy(usb_buf, init_msg_2, 12); - status = kalmia_send_init_packet(dev, usb_buf, sizeof(init_msg_2) - / sizeof(init_msg_2[0]), usb_buf, 28); + status = kalmia_send_init_packet(dev, init_msg_2, sizeof(init_msg_2) + / sizeof(init_msg_2[0]), receive_buf, 28); if (status != 0) return status; - memcpy(ethernet_addr, usb_buf + 10, ETH_ALEN); + memcpy(ethernet_addr, receive_buf + 10, ETH_ALEN); - kfree(usb_buf); return status; } static int kalmia_bind(struct usbnet *dev, struct usb_interface *intf) { - int status; + u8 status; u8 ethernet_addr[ETH_ALEN]; /* Don't bind to AT command interface */ @@ -198,8 +190,7 @@ kalmia_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags) dev_kfree_skb_any(skb); skb = skb2; -done: - header_start = skb_push(skb, KALMIA_HEADER_LENGTH); + done: header_start = skb_push(skb, KALMIA_HEADER_LENGTH); ether_type_1 = header_start[KALMIA_HEADER_LENGTH + 12]; ether_type_2 = header_start[KALMIA_HEADER_LENGTH + 13]; @@ -210,8 +201,9 @@ kalmia_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags) header_start[0] = 0x57; header_start[1] = 0x44; content_len = skb->len - KALMIA_HEADER_LENGTH; + header_start[2] = (content_len & 0xff); /* low byte */ + header_start[3] = (content_len >> 8); /* high byte */ - put_unaligned_le16(content_len, &header_start[2]); header_start[4] = ether_type_1; header_start[5] = ether_type_2; @@ -239,13 +231,13 @@ kalmia_rx_fixup(struct usbnet *dev, struct sk_buff *skb) * Our task here is to strip off framing, leaving skb with one * data frame for the usbnet framework code to process. */ - static const u8 HEADER_END_OF_USB_PACKET[] = + const u8 HEADER_END_OF_USB_PACKET[] = { 0x57, 0x5a, 0x00, 0x00, 0x08, 0x00 }; - static const u8 EXPECTED_UNKNOWN_HEADER_1[] = + const u8 EXPECTED_UNKNOWN_HEADER_1[] = { 0x57, 0x43, 0x1e, 0x00, 0x15, 0x02 }; - static const u8 EXPECTED_UNKNOWN_HEADER_2[] = + const u8 EXPECTED_UNKNOWN_HEADER_2[] = { 0x57, 0x50, 0x0e, 0x00, 0x00, 0x00 }; - int i = 0; + u8 i = 0; /* incomplete header? */ if (skb->len < KALMIA_HEADER_LENGTH) @@ -293,7 +285,7 @@ kalmia_rx_fixup(struct usbnet *dev, struct sk_buff *skb) /* subtract start header and end header */ usb_packet_length = skb->len - (2 * KALMIA_HEADER_LENGTH); - ether_packet_length = get_unaligned_le16(&header_start[2]); + ether_packet_length = header_start[2] + (header_start[3] << 8); skb_pull(skb, KALMIA_HEADER_LENGTH); /* Some small packets misses end marker */ diff --git a/trunk/drivers/net/usb/zaurus.c b/trunk/drivers/net/usb/zaurus.c index 1a2234c20514..241756e0e86f 100644 --- a/trunk/drivers/net/usb/zaurus.c +++ b/trunk/drivers/net/usb/zaurus.c @@ -331,7 +331,17 @@ static const struct usb_device_id products [] = { ZAURUS_MASTER_INTERFACE, .driver_info = ZAURUS_PXA_INFO, }, + + +/* At least some of the newest PXA units have very different lies about + * their standards support: they claim to be cell phones offering + * direct access to their radios! (No, they don't conform to CDC MDLM.) + */ { + USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_MDLM, + USB_CDC_PROTO_NONE), + .driver_info = (unsigned long) &bogus_mdlm_info, +}, { /* Motorola MOTOMAGX phones */ USB_DEVICE_AND_INTERFACE_INFO(0x22b8, 0x6425, USB_CLASS_COMM, USB_CDC_SUBCLASS_MDLM, USB_CDC_PROTO_NONE), diff --git a/trunk/drivers/net/veth.c b/trunk/drivers/net/veth.c index 7f78db7bd68d..4b6db3b6c5d5 100644 --- a/trunk/drivers/net/veth.c +++ b/trunk/drivers/net/veth.c @@ -30,6 +30,7 @@ struct veth_net_stats { u64 rx_bytes; u64 tx_bytes; u64 rx_dropped; + u64 tx_dropped; struct u64_stats_sync syncp; }; @@ -125,6 +126,9 @@ static netdev_tx_t veth_xmit(struct sk_buff *skb, struct net_device *dev) stats = this_cpu_ptr(priv->stats); rcv_stats = this_cpu_ptr(rcv_priv->stats); + if (!(rcv->flags & IFF_UP)) + goto tx_drop; + /* don't change ip_summed == CHECKSUM_PARTIAL, as that will cause bad checksum on forwarded packets */ if (skb->ip_summed == CHECKSUM_NONE && @@ -147,6 +151,13 @@ static netdev_tx_t veth_xmit(struct sk_buff *skb, struct net_device *dev) return NETDEV_TX_OK; +tx_drop: + kfree_skb(skb); + u64_stats_update_begin(&stats->syncp); + stats->tx_dropped++; + u64_stats_update_end(&stats->syncp); + return NETDEV_TX_OK; + rx_drop: u64_stats_update_begin(&rcv_stats->syncp); rcv_stats->rx_dropped++; @@ -167,7 +178,7 @@ static struct rtnl_link_stats64 *veth_get_stats64(struct net_device *dev, for_each_possible_cpu(cpu) { struct veth_net_stats *stats = per_cpu_ptr(priv->stats, cpu); u64 rx_packets, rx_bytes, rx_dropped; - u64 tx_packets, tx_bytes; + u64 tx_packets, tx_bytes, tx_dropped; unsigned int start; do { @@ -177,12 +188,14 @@ static struct rtnl_link_stats64 *veth_get_stats64(struct net_device *dev, rx_bytes = stats->rx_bytes; tx_bytes = stats->tx_bytes; rx_dropped = stats->rx_dropped; + tx_dropped = stats->tx_dropped; } while (u64_stats_fetch_retry_bh(&stats->syncp, start)); tot->rx_packets += rx_packets; tot->tx_packets += tx_packets; tot->rx_bytes += rx_bytes; tot->tx_bytes += tx_bytes; tot->rx_dropped += rx_dropped; + tot->tx_dropped += tx_dropped; } return tot; diff --git a/trunk/drivers/net/virtio_net.c b/trunk/drivers/net/virtio_net.c index fbea637eb742..be3686a298da 100644 --- a/trunk/drivers/net/virtio_net.c +++ b/trunk/drivers/net/virtio_net.c @@ -40,15 +40,6 @@ module_param(gso, bool, 0444); #define VIRTNET_SEND_COMMAND_SG_MAX 2 -struct virtnet_stats { - struct u64_stats_sync syncp; - u64 tx_bytes; - u64 tx_packets; - - u64 rx_bytes; - u64 rx_packets; -}; - struct virtnet_info { struct virtio_device *vdev; struct virtqueue *rvq, *svq, *cvq; @@ -65,9 +56,6 @@ struct virtnet_info { /* Host will merge rx buffers for big packets (shake it! shake it!) */ bool mergeable_rx_bufs; - /* Active statistics */ - struct virtnet_stats __percpu *stats; - /* Work struct for refilling if we run low on memory. */ struct delayed_work refill; @@ -221,6 +209,7 @@ static int receive_mergeable(struct virtnet_info *vi, struct sk_buff *skb) skb->dev->stats.rx_length_errors++; return -EINVAL; } + page = virtqueue_get_buf(vi->rvq, &len); if (!page) { pr_debug("%s: rx error: %d buffers missing\n", @@ -228,7 +217,6 @@ static int receive_mergeable(struct virtnet_info *vi, struct sk_buff *skb) skb->dev->stats.rx_length_errors++; return -EINVAL; } - if (len > PAGE_SIZE) len = PAGE_SIZE; @@ -242,7 +230,6 @@ static int receive_mergeable(struct virtnet_info *vi, struct sk_buff *skb) static void receive_buf(struct net_device *dev, void *buf, unsigned int len) { struct virtnet_info *vi = netdev_priv(dev); - struct virtnet_stats __percpu *stats = this_cpu_ptr(vi->stats); struct sk_buff *skb; struct page *page; struct skb_vnet_hdr *hdr; @@ -278,11 +265,8 @@ static void receive_buf(struct net_device *dev, void *buf, unsigned int len) hdr = skb_vnet_hdr(skb); skb->truesize += skb->data_len; - - u64_stats_update_begin(&stats->syncp); - stats->rx_bytes += skb->len; - stats->rx_packets++; - u64_stats_update_end(&stats->syncp); + dev->stats.rx_bytes += skb->len; + dev->stats.rx_packets++; if (hdr->hdr.flags & VIRTIO_NET_HDR_F_NEEDS_CSUM) { pr_debug("Needs csum!\n"); @@ -531,16 +515,11 @@ static unsigned int free_old_xmit_skbs(struct virtnet_info *vi) { struct sk_buff *skb; unsigned int len, tot_sgs = 0; - struct virtnet_stats __percpu *stats = this_cpu_ptr(vi->stats); while ((skb = virtqueue_get_buf(vi->svq, &len)) != NULL) { pr_debug("Sent skb %p\n", skb); - - u64_stats_update_begin(&stats->syncp); - stats->tx_bytes += skb->len; - stats->tx_packets++; - u64_stats_update_end(&stats->syncp); - + vi->dev->stats.tx_bytes += skb->len; + vi->dev->stats.tx_packets++; tot_sgs += skb_vnet_hdr(skb)->num_sg; dev_kfree_skb_any(skb); } @@ -662,40 +641,6 @@ static int virtnet_set_mac_address(struct net_device *dev, void *p) return 0; } -static struct rtnl_link_stats64 *virtnet_stats(struct net_device *dev, - struct rtnl_link_stats64 *tot) -{ - struct virtnet_info *vi = netdev_priv(dev); - int cpu; - unsigned int start; - - for_each_possible_cpu(cpu) { - struct virtnet_stats __percpu *stats - = per_cpu_ptr(vi->stats, cpu); - u64 tpackets, tbytes, rpackets, rbytes; - - do { - start = u64_stats_fetch_begin(&stats->syncp); - tpackets = stats->tx_packets; - tbytes = stats->tx_bytes; - rpackets = stats->rx_packets; - rbytes = stats->rx_bytes; - } while (u64_stats_fetch_retry(&stats->syncp, start)); - - tot->rx_packets += rpackets; - tot->tx_packets += tpackets; - tot->rx_bytes += rbytes; - tot->tx_bytes += tbytes; - } - - tot->tx_dropped = dev->stats.tx_dropped; - tot->rx_dropped = dev->stats.rx_dropped; - tot->rx_length_errors = dev->stats.rx_length_errors; - tot->rx_frame_errors = dev->stats.rx_frame_errors; - - return tot; -} - #ifdef CONFIG_NET_POLL_CONTROLLER static void virtnet_netpoll(struct net_device *dev) { @@ -705,14 +650,6 @@ static void virtnet_netpoll(struct net_device *dev) } #endif -static void virtnet_free(struct net_device *dev) -{ - struct virtnet_info *vi = netdev_priv(dev); - - free_percpu(vi->stats); - free_netdev(dev); -} - static int virtnet_open(struct net_device *dev) { struct virtnet_info *vi = netdev_priv(dev); @@ -898,7 +835,6 @@ static const struct net_device_ops virtnet_netdev = { .ndo_set_mac_address = virtnet_set_mac_address, .ndo_set_rx_mode = virtnet_set_rx_mode, .ndo_change_mtu = virtnet_change_mtu, - .ndo_get_stats64 = virtnet_stats, .ndo_vlan_rx_add_vid = virtnet_vlan_rx_add_vid, .ndo_vlan_rx_kill_vid = virtnet_vlan_rx_kill_vid, #ifdef CONFIG_NET_POLL_CONTROLLER @@ -959,8 +895,6 @@ static int virtnet_probe(struct virtio_device *vdev) /* Set up network device as normal. */ dev->netdev_ops = &virtnet_netdev; dev->features = NETIF_F_HIGHDMA; - dev->destructor = virtnet_free; - SET_ETHTOOL_OPS(dev, &virtnet_ethtool_ops); SET_NETDEV_DEV(dev, &vdev->dev); @@ -1005,11 +939,6 @@ static int virtnet_probe(struct virtio_device *vdev) vi->vdev = vdev; vdev->priv = vi; vi->pages = NULL; - vi->stats = alloc_percpu(struct virtnet_stats); - err = -ENOMEM; - if (vi->stats == NULL) - goto free; - INIT_DELAYED_WORK(&vi->refill, refill_work); sg_init_table(vi->rx_sg, ARRAY_SIZE(vi->rx_sg)); sg_init_table(vi->tx_sg, ARRAY_SIZE(vi->tx_sg)); @@ -1029,7 +958,7 @@ static int virtnet_probe(struct virtio_device *vdev) err = vdev->config->find_vqs(vdev, nvqs, vqs, callbacks, names); if (err) - goto free_stats; + goto free; vi->rvq = vqs[0]; vi->svq = vqs[1]; @@ -1074,8 +1003,6 @@ static int virtnet_probe(struct virtio_device *vdev) cancel_delayed_work_sync(&vi->refill); free_vqs: vdev->config->del_vqs(vdev); -free_stats: - free_percpu(vi->stats); free: free_netdev(dev); return err; diff --git a/trunk/drivers/net/vmxnet3/vmxnet3_drv.c b/trunk/drivers/net/vmxnet3/vmxnet3_drv.c index 009277e1084f..33097ec1c514 100644 --- a/trunk/drivers/net/vmxnet3/vmxnet3_drv.c +++ b/trunk/drivers/net/vmxnet3/vmxnet3_drv.c @@ -573,7 +573,7 @@ vmxnet3_rq_alloc_rx_buf(struct vmxnet3_rx_queue *rq, u32 ring_idx, struct vmxnet3_cmd_ring *ring = &rq->rx_ring[ring_idx]; u32 val; - while (num_allocated <= num_to_alloc) { + while (num_allocated < num_to_alloc) { struct vmxnet3_rx_buf_info *rbi; union Vmxnet3_GenericDesc *gd; @@ -619,15 +619,9 @@ vmxnet3_rq_alloc_rx_buf(struct vmxnet3_rx_queue *rq, u32 ring_idx, BUG_ON(rbi->dma_addr == 0); gd->rxd.addr = cpu_to_le64(rbi->dma_addr); - gd->dword[2] = cpu_to_le32((!ring->gen << VMXNET3_RXD_GEN_SHIFT) + gd->dword[2] = cpu_to_le32((ring->gen << VMXNET3_RXD_GEN_SHIFT) | val | rbi->len); - /* Fill the last buffer but dont mark it ready, or else the - * device will think that the queue is full */ - if (num_allocated == num_to_alloc) - break; - - gd->dword[2] |= cpu_to_le32(ring->gen << VMXNET3_RXD_GEN_SHIFT); num_allocated++; vmxnet3_cmd_ring_adv_next2fill(ring); } @@ -924,7 +918,7 @@ vmxnet3_tq_xmit(struct sk_buff *skb, struct vmxnet3_tx_queue *tq, count = VMXNET3_TXD_NEEDED(skb_headlen(skb)) + skb_shinfo(skb)->nr_frags + 1; - ctx.ipv4 = (vlan_get_protocol(skb) == cpu_to_be16(ETH_P_IP)); + ctx.ipv4 = (skb->protocol == cpu_to_be16(ETH_P_IP)); ctx.mss = skb_shinfo(skb)->gso_size; if (ctx.mss) { @@ -1144,7 +1138,6 @@ vmxnet3_rq_rx_complete(struct vmxnet3_rx_queue *rq, VMXNET3_REG_RXPROD, VMXNET3_REG_RXPROD2 }; u32 num_rxd = 0; - bool skip_page_frags = false; struct Vmxnet3_RxCompDesc *rcd; struct vmxnet3_rx_ctx *ctx = &rq->rx_ctx; #ifdef __BIG_ENDIAN_BITFIELD @@ -1155,12 +1148,11 @@ vmxnet3_rq_rx_complete(struct vmxnet3_rx_queue *rq, &rxComp); while (rcd->gen == rq->comp_ring.gen) { struct vmxnet3_rx_buf_info *rbi; - struct sk_buff *skb, *new_skb = NULL; - struct page *new_page = NULL; + struct sk_buff *skb; int num_to_alloc; struct Vmxnet3_RxDesc *rxd; u32 idx, ring_idx; - struct vmxnet3_cmd_ring *ring = NULL; + if (num_rxd >= quota) { /* we may stop even before we see the EOP desc of * the current pkt @@ -1171,7 +1163,6 @@ vmxnet3_rq_rx_complete(struct vmxnet3_rx_queue *rq, BUG_ON(rcd->rqID != rq->qid && rcd->rqID != rq->qid2); idx = rcd->rxdIdx; ring_idx = rcd->rqID < adapter->num_rx_queues ? 0 : 1; - ring = rq->rx_ring + ring_idx; vmxnet3_getRxDesc(rxd, &rq->rx_ring[ring_idx].base[idx].rxd, &rxCmdDesc); rbi = rq->buf_info[ring_idx] + idx; @@ -1200,80 +1191,37 @@ vmxnet3_rq_rx_complete(struct vmxnet3_rx_queue *rq, goto rcd_done; } - skip_page_frags = false; ctx->skb = rbi->skb; - new_skb = dev_alloc_skb(rbi->len + NET_IP_ALIGN); - if (new_skb == NULL) { - /* Skb allocation failed, do not handover this - * skb to stack. Reuse it. Drop the existing pkt - */ - rq->stats.rx_buf_alloc_failure++; - ctx->skb = NULL; - rq->stats.drop_total++; - skip_page_frags = true; - goto rcd_done; - } + rbi->skb = NULL; pci_unmap_single(adapter->pdev, rbi->dma_addr, rbi->len, PCI_DMA_FROMDEVICE); skb_put(ctx->skb, rcd->len); - - /* Immediate refill */ - new_skb->dev = adapter->netdev; - skb_reserve(new_skb, NET_IP_ALIGN); - rbi->skb = new_skb; - rbi->dma_addr = pci_map_single(adapter->pdev, - rbi->skb->data, rbi->len, - PCI_DMA_FROMDEVICE); - rxd->addr = cpu_to_le64(rbi->dma_addr); - rxd->len = rbi->len; - } else { - BUG_ON(ctx->skb == NULL && !skip_page_frags); - + BUG_ON(ctx->skb == NULL); /* non SOP buffer must be type 1 in most cases */ - BUG_ON(rbi->buf_type != VMXNET3_RX_BUF_PAGE); - BUG_ON(rxd->btype != VMXNET3_RXD_BTYPE_BODY); + if (rbi->buf_type == VMXNET3_RX_BUF_PAGE) { + BUG_ON(rxd->btype != VMXNET3_RXD_BTYPE_BODY); - /* If an sop buffer was dropped, skip all - * following non-sop fragments. They will be reused. - */ - if (skip_page_frags) - goto rcd_done; + if (rcd->len) { + pci_unmap_page(adapter->pdev, + rbi->dma_addr, rbi->len, + PCI_DMA_FROMDEVICE); - new_page = alloc_page(GFP_ATOMIC); - if (unlikely(new_page == NULL)) { - /* Replacement page frag could not be allocated. - * Reuse this page. Drop the pkt and free the - * skb which contained this page as a frag. Skip - * processing all the following non-sop frags. + vmxnet3_append_frag(ctx->skb, rcd, rbi); + rbi->page = NULL; + } + } else { + /* + * The only time a non-SOP buffer is type 0 is + * when it's EOP and error flag is raised, which + * has already been handled. */ - rq->stats.rx_buf_alloc_failure++; - dev_kfree_skb(ctx->skb); - ctx->skb = NULL; - skip_page_frags = true; - goto rcd_done; - } - - if (rcd->len) { - pci_unmap_page(adapter->pdev, - rbi->dma_addr, rbi->len, - PCI_DMA_FROMDEVICE); - - vmxnet3_append_frag(ctx->skb, rcd, rbi); + BUG_ON(true); } - - /* Immediate refill */ - rbi->page = new_page; - rbi->dma_addr = pci_map_page(adapter->pdev, rbi->page, - 0, PAGE_SIZE, - PCI_DMA_FROMDEVICE); - rxd->addr = cpu_to_le64(rbi->dma_addr); - rxd->len = rbi->len; } - skb = ctx->skb; if (rcd->eop) { skb->len += skb->data_len; @@ -1283,39 +1231,37 @@ vmxnet3_rq_rx_complete(struct vmxnet3_rx_queue *rq, (union Vmxnet3_GenericDesc *)rcd); skb->protocol = eth_type_trans(skb, adapter->netdev); - if (unlikely(rcd->ts)) - __vlan_hwaccel_put_tag(skb, rcd->tci); - - if (adapter->netdev->features & NETIF_F_LRO) + if (unlikely(adapter->vlan_grp && rcd->ts)) { + vlan_hwaccel_receive_skb(skb, + adapter->vlan_grp, rcd->tci); + } else { netif_receive_skb(skb); - else - napi_gro_receive(&rq->napi, skb); + } ctx->skb = NULL; } rcd_done: - /* device may have skipped some rx descs */ - ring->next2comp = idx; - num_to_alloc = vmxnet3_cmd_ring_desc_avail(ring); - ring = rq->rx_ring + ring_idx; - while (num_to_alloc) { - vmxnet3_getRxDesc(rxd, &ring->base[ring->next2fill].rxd, - &rxCmdDesc); - BUG_ON(!rxd->addr); - - /* Recv desc is ready to be used by the device */ - rxd->gen = ring->gen; - vmxnet3_cmd_ring_adv_next2fill(ring); - num_to_alloc--; - } - - /* if needed, update the register */ - if (unlikely(rq->shared->updateRxProd)) { - VMXNET3_WRITE_BAR0_REG(adapter, - rxprod_reg[ring_idx] + rq->qid * 8, - ring->next2fill); - rq->uncommitted[ring_idx] = 0; + /* device may skip some rx descs */ + rq->rx_ring[ring_idx].next2comp = idx; + VMXNET3_INC_RING_IDX_ONLY(rq->rx_ring[ring_idx].next2comp, + rq->rx_ring[ring_idx].size); + + /* refill rx buffers frequently to avoid starving the h/w */ + num_to_alloc = vmxnet3_cmd_ring_desc_avail(rq->rx_ring + + ring_idx); + if (unlikely(num_to_alloc > VMXNET3_RX_ALLOC_THRESHOLD(rq, + ring_idx, adapter))) { + vmxnet3_rq_alloc_rx_buf(rq, ring_idx, num_to_alloc, + adapter); + + /* if needed, update the register */ + if (unlikely(rq->shared->updateRxProd)) { + VMXNET3_WRITE_BAR0_REG(adapter, + rxprod_reg[ring_idx] + rq->qid * 8, + rq->rx_ring[ring_idx].next2fill); + rq->uncommitted[ring_idx] = 0; + } } vmxnet3_comp_ring_adv_next2proc(&rq->comp_ring); @@ -1910,18 +1856,79 @@ vmxnet3_free_irqs(struct vmxnet3_adapter *adapter) } } - static void -vmxnet3_restore_vlan(struct vmxnet3_adapter *adapter) +vmxnet3_vlan_rx_register(struct net_device *netdev, struct vlan_group *grp) { + struct vmxnet3_adapter *adapter = netdev_priv(netdev); + struct Vmxnet3_DriverShared *shared = adapter->shared; u32 *vfTable = adapter->shared->devRead.rxFilterConf.vfTable; - u16 vid; + unsigned long flags; + + if (grp) { + /* add vlan rx stripping. */ + if (adapter->netdev->features & NETIF_F_HW_VLAN_RX) { + int i; + adapter->vlan_grp = grp; + + /* + * Clear entire vfTable; then enable untagged pkts. + * Note: setting one entry in vfTable to non-zero turns + * on VLAN rx filtering. + */ + for (i = 0; i < VMXNET3_VFT_SIZE; i++) + vfTable[i] = 0; + + VMXNET3_SET_VFTABLE_ENTRY(vfTable, 0); + spin_lock_irqsave(&adapter->cmd_lock, flags); + VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, + VMXNET3_CMD_UPDATE_VLAN_FILTERS); + spin_unlock_irqrestore(&adapter->cmd_lock, flags); + } else { + printk(KERN_ERR "%s: vlan_rx_register when device has " + "no NETIF_F_HW_VLAN_RX\n", netdev->name); + } + } else { + /* remove vlan rx stripping. */ + struct Vmxnet3_DSDevRead *devRead = &shared->devRead; + adapter->vlan_grp = NULL; + + if (devRead->misc.uptFeatures & UPT1_F_RXVLAN) { + int i; + + for (i = 0; i < VMXNET3_VFT_SIZE; i++) { + /* clear entire vfTable; this also disables + * VLAN rx filtering + */ + vfTable[i] = 0; + } + spin_lock_irqsave(&adapter->cmd_lock, flags); + VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, + VMXNET3_CMD_UPDATE_VLAN_FILTERS); + spin_unlock_irqrestore(&adapter->cmd_lock, flags); + } + } +} + - /* allow untagged pkts */ - VMXNET3_SET_VFTABLE_ENTRY(vfTable, 0); +static void +vmxnet3_restore_vlan(struct vmxnet3_adapter *adapter) +{ + if (adapter->vlan_grp) { + u16 vid; + u32 *vfTable = adapter->shared->devRead.rxFilterConf.vfTable; + bool activeVlan = false; - for_each_set_bit(vid, adapter->active_vlans, VLAN_N_VID) - VMXNET3_SET_VFTABLE_ENTRY(vfTable, vid); + for (vid = 0; vid < VLAN_N_VID; vid++) { + if (vlan_group_get_device(adapter->vlan_grp, vid)) { + VMXNET3_SET_VFTABLE_ENTRY(vfTable, vid); + activeVlan = true; + } + } + if (activeVlan) { + /* continue to allow untagged pkts */ + VMXNET3_SET_VFTABLE_ENTRY(vfTable, 0); + } + } } @@ -1937,8 +1944,6 @@ vmxnet3_vlan_rx_add_vid(struct net_device *netdev, u16 vid) VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, VMXNET3_CMD_UPDATE_VLAN_FILTERS); spin_unlock_irqrestore(&adapter->cmd_lock, flags); - - set_bit(vid, adapter->active_vlans); } @@ -1954,8 +1959,6 @@ vmxnet3_vlan_rx_kill_vid(struct net_device *netdev, u16 vid) VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, VMXNET3_CMD_UPDATE_VLAN_FILTERS); spin_unlock_irqrestore(&adapter->cmd_lock, flags); - - clear_bit(vid, adapter->active_vlans); } @@ -1992,14 +1995,8 @@ vmxnet3_set_mc(struct net_device *netdev) u8 *new_table = NULL; u32 new_mode = VMXNET3_RXM_UCAST; - if (netdev->flags & IFF_PROMISC) { - u32 *vfTable = adapter->shared->devRead.rxFilterConf.vfTable; - memset(vfTable, 0, VMXNET3_VFT_SIZE * sizeof(*vfTable)); - + if (netdev->flags & IFF_PROMISC) new_mode |= VMXNET3_RXM_PROMISC; - } else { - vmxnet3_restore_vlan(adapter); - } if (netdev->flags & IFF_BROADCAST) new_mode |= VMXNET3_RXM_BCAST; @@ -2033,8 +2030,6 @@ vmxnet3_set_mc(struct net_device *netdev) rxConf->rxMode = cpu_to_le32(new_mode); VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, VMXNET3_CMD_UPDATE_RX_MODE); - VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, - VMXNET3_CMD_UPDATE_VLAN_FILTERS); } VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, @@ -2644,13 +2639,12 @@ vmxnet3_declare_features(struct vmxnet3_adapter *adapter, bool dma64) netdev->hw_features = NETIF_F_SG | NETIF_F_RXCSUM | NETIF_F_HW_CSUM | NETIF_F_HW_VLAN_TX | - NETIF_F_HW_VLAN_RX | NETIF_F_TSO | NETIF_F_TSO6 | - NETIF_F_LRO; + NETIF_F_TSO | NETIF_F_TSO6 | NETIF_F_LRO; if (dma64) netdev->features |= NETIF_F_HIGHDMA; - netdev->vlan_features = netdev->hw_features & - ~(NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX); - netdev->features = netdev->hw_features | NETIF_F_HW_VLAN_FILTER; + netdev->vlan_features = netdev->hw_features & ~NETIF_F_HW_VLAN_TX; + netdev->features = netdev->hw_features | + NETIF_F_HW_VLAN_RX | NETIF_F_HW_VLAN_FILTER; netdev_info(adapter->netdev, "features: sg csum vlan jf tso tsoIPv6 lro%s\n", @@ -2871,6 +2865,7 @@ vmxnet3_probe_device(struct pci_dev *pdev, .ndo_get_stats64 = vmxnet3_get_stats64, .ndo_tx_timeout = vmxnet3_tx_timeout, .ndo_set_multicast_list = vmxnet3_set_mc, + .ndo_vlan_rx_register = vmxnet3_vlan_rx_register, .ndo_vlan_rx_add_vid = vmxnet3_vlan_rx_add_vid, .ndo_vlan_rx_kill_vid = vmxnet3_vlan_rx_kill_vid, #ifdef CONFIG_NET_POLL_CONTROLLER @@ -2897,7 +2892,6 @@ vmxnet3_probe_device(struct pci_dev *pdev, else #endif num_rx_queues = 1; - num_rx_queues = rounddown_pow_of_two(num_rx_queues); if (enable_mq) num_tx_queues = min(VMXNET3_DEVICE_MAX_TX_QUEUES, @@ -2905,7 +2899,6 @@ vmxnet3_probe_device(struct pci_dev *pdev, else num_tx_queues = 1; - num_tx_queues = rounddown_pow_of_two(num_tx_queues); netdev = alloc_etherdev_mq(sizeof(struct vmxnet3_adapter), max(num_tx_queues, num_rx_queues)); printk(KERN_INFO "# of Tx queues : %d, # of Rx queues : %d\n", @@ -3090,7 +3083,6 @@ vmxnet3_remove_device(struct pci_dev *pdev) else #endif num_rx_queues = 1; - num_rx_queues = rounddown_pow_of_two(num_rx_queues); cancel_work_sync(&adapter->work); diff --git a/trunk/drivers/net/vmxnet3/vmxnet3_ethtool.c b/trunk/drivers/net/vmxnet3/vmxnet3_ethtool.c index 27400edeef55..bba7c15de5b6 100644 --- a/trunk/drivers/net/vmxnet3/vmxnet3_ethtool.c +++ b/trunk/drivers/net/vmxnet3/vmxnet3_ethtool.c @@ -268,7 +268,7 @@ int vmxnet3_set_features(struct net_device *netdev, u32 features) unsigned long flags; u32 changed = features ^ netdev->features; - if (changed & (NETIF_F_RXCSUM | NETIF_F_LRO | NETIF_F_HW_VLAN_RX)) { + if (changed & (NETIF_F_RXCSUM|NETIF_F_LRO)) { if (features & NETIF_F_RXCSUM) adapter->shared->devRead.misc.uptFeatures |= UPT1_F_RXCSUM; @@ -284,13 +284,6 @@ int vmxnet3_set_features(struct net_device *netdev, u32 features) adapter->shared->devRead.misc.uptFeatures &= ~UPT1_F_LRO; - if (features & NETIF_F_HW_VLAN_RX) - adapter->shared->devRead.misc.uptFeatures |= - UPT1_F_RXVLAN; - else - adapter->shared->devRead.misc.uptFeatures &= - ~UPT1_F_RXVLAN; - spin_lock_irqsave(&adapter->cmd_lock, flags); VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, VMXNET3_CMD_UPDATE_FEATURE); diff --git a/trunk/drivers/net/vmxnet3/vmxnet3_int.h b/trunk/drivers/net/vmxnet3/vmxnet3_int.h index b18eac1dccaa..0e567c249d6d 100644 --- a/trunk/drivers/net/vmxnet3/vmxnet3_int.h +++ b/trunk/drivers/net/vmxnet3/vmxnet3_int.h @@ -27,7 +27,6 @@ #ifndef _VMXNET3_INT_H #define _VMXNET3_INT_H -#include #include #include #include @@ -56,7 +55,6 @@ #include #include #include -#include #include "vmxnet3_defs.h" @@ -70,10 +68,10 @@ /* * Version numbers */ -#define VMXNET3_DRIVER_VERSION_STRING "1.1.18.0-k" +#define VMXNET3_DRIVER_VERSION_STRING "1.1.9.0-k" /* a 32-bit int, each byte encode a verion number in VMXNET3_DRIVER_VERSION */ -#define VMXNET3_DRIVER_VERSION_NUM 0x01011200 +#define VMXNET3_DRIVER_VERSION_NUM 0x01010900 #if defined(CONFIG_PCI_MSI) /* RSS only makes sense if MSI-X is supported. */ @@ -317,7 +315,7 @@ struct vmxnet3_intr { struct vmxnet3_adapter { struct vmxnet3_tx_queue tx_queue[VMXNET3_DEVICE_MAX_TX_QUEUES]; struct vmxnet3_rx_queue rx_queue[VMXNET3_DEVICE_MAX_RX_QUEUES]; - unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)]; + struct vlan_group *vlan_grp; struct vmxnet3_intr intr; spinlock_t cmd_lock; struct Vmxnet3_DriverShared *shared; diff --git a/trunk/drivers/net/vxge/vxge-config.c b/trunk/drivers/net/vxge/vxge-config.c index 1520c574cb20..857618afa147 100644 --- a/trunk/drivers/net/vxge/vxge-config.c +++ b/trunk/drivers/net/vxge/vxge-config.c @@ -753,11 +753,12 @@ static void __vxge_hw_device_host_info_get(struct __vxge_hw_device *hldev) static enum vxge_hw_status __vxge_hw_verify_pci_e_info(struct __vxge_hw_device *hldev) { - struct pci_dev *dev = hldev->pdev; + int exp_cap; u16 lnk; /* Get the negotiated link width and speed from PCI config space */ - pci_read_config_word(dev, dev->pcie_cap + PCI_EXP_LNKSTA, &lnk); + exp_cap = pci_find_capability(hldev->pdev, PCI_CAP_ID_EXP); + pci_read_config_word(hldev->pdev, exp_cap + PCI_EXP_LNKSTA, &lnk); if ((lnk & PCI_EXP_LNKSTA_CLS) != 1) return VXGE_HW_ERR_INVALID_PCI_INFO; @@ -1981,11 +1982,13 @@ enum vxge_hw_status vxge_hw_device_setpause_data(struct __vxge_hw_device *hldev, u16 vxge_hw_device_link_width_get(struct __vxge_hw_device *hldev) { - struct pci_dev *dev = hldev->pdev; + int link_width, exp_cap; u16 lnk; - pci_read_config_word(dev, dev->pcie_cap + PCI_EXP_LNKSTA, &lnk); - return (lnk & VXGE_HW_PCI_EXP_LNKCAP_LNK_WIDTH) >> 4; + exp_cap = pci_find_capability(hldev->pdev, PCI_CAP_ID_EXP); + pci_read_config_word(hldev->pdev, exp_cap + PCI_EXP_LNKSTA, &lnk); + link_width = (lnk & VXGE_HW_PCI_EXP_LNKCAP_LNK_WIDTH) >> 4; + return link_width; } /* diff --git a/trunk/drivers/net/vxge/vxge-main.c b/trunk/drivers/net/vxge/vxge-main.c index 15d878b4547c..1c92af392992 100644 --- a/trunk/drivers/net/vxge/vxge-main.c +++ b/trunk/drivers/net/vxge/vxge-main.c @@ -684,7 +684,8 @@ static int vxge_mac_list_add(struct vxge_vpath *vpath, struct macInfo *mac) new_mac_entry->state = mac->state; vpath->mac_addr_cnt++; - if (is_multicast_ether_addr(mac->macaddr)) + /* Is this a multicast address */ + if (0x01 & mac->macaddr[0]) vpath->mcast_addr_cnt++; return TRUE; @@ -698,7 +699,7 @@ vxge_add_mac_addr(struct vxgedev *vdev, struct macInfo *mac) struct vxge_vpath *vpath; enum vxge_hw_vpath_mac_addr_add_mode duplicate_mode; - if (is_multicast_ether_addr(mac->macaddr)) + if (0x01 & mac->macaddr[0]) /* multicast address */ duplicate_mode = VXGE_HW_VPATH_MAC_ADDR_ADD_DUPLICATE; else duplicate_mode = VXGE_HW_VPATH_MAC_ADDR_REPLACE_DUPLICATE; @@ -1077,7 +1078,8 @@ static int vxge_mac_list_del(struct vxge_vpath *vpath, struct macInfo *mac) kfree((struct vxge_mac_addrs *)entry); vpath->mac_addr_cnt--; - if (is_multicast_ether_addr(mac->macaddr)) + /* Is this a multicast address */ + if (0x01 & mac->macaddr[0]) vpath->mcast_addr_cnt--; return TRUE; } @@ -1199,7 +1201,8 @@ static void vxge_set_multicast(struct net_device *dev) mac_address = (u8 *)&mac_entry->macaddr; memcpy(mac_info.macaddr, mac_address, ETH_ALEN); - if (is_multicast_ether_addr(mac_info.macaddr)) { + /* Is this a multicast address */ + if (0x01 & mac_info.macaddr[0]) { for (vpath_idx = 0; vpath_idx < vdev->no_of_vpath; vpath_idx++) { @@ -1241,7 +1244,8 @@ static void vxge_set_multicast(struct net_device *dev) mac_address = (u8 *)&mac_entry->macaddr; memcpy(mac_info.macaddr, mac_address, ETH_ALEN); - if (is_multicast_ether_addr(mac_info.macaddr)) + /* Is this a multicast address */ + if (0x01 & mac_info.macaddr[0]) break; } diff --git a/trunk/drivers/net/wan/c101.c b/trunk/drivers/net/wan/c101.c index 54f995f4a5a3..4ac85a09c5a6 100644 --- a/trunk/drivers/net/wan/c101.c +++ b/trunk/drivers/net/wan/c101.c @@ -14,8 +14,6 @@ * Moxa C101 User's Manual */ -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - #include #include #include @@ -315,44 +313,44 @@ static int __init c101_run(unsigned long irq, unsigned long winbase) int result; if (irq<3 || irq>15 || irq == 6) /* FIXME */ { - pr_err("invalid IRQ value\n"); + printk(KERN_ERR "c101: invalid IRQ value\n"); return -ENODEV; } if (winbase < 0xC0000 || winbase > 0xDFFFF || (winbase & 0x3FFF) !=0) { - pr_err("invalid RAM value\n"); + printk(KERN_ERR "c101: invalid RAM value\n"); return -ENODEV; } card = kzalloc(sizeof(card_t), GFP_KERNEL); if (card == NULL) { - pr_err("unable to allocate memory\n"); + printk(KERN_ERR "c101: unable to allocate memory\n"); return -ENOBUFS; } card->dev = alloc_hdlcdev(card); if (!card->dev) { - pr_err("unable to allocate memory\n"); + printk(KERN_ERR "c101: unable to allocate memory\n"); kfree(card); return -ENOBUFS; } if (request_irq(irq, sca_intr, 0, devname, card)) { - pr_err("could not allocate IRQ\n"); + printk(KERN_ERR "c101: could not allocate IRQ\n"); c101_destroy_card(card); return -EBUSY; } card->irq = irq; if (!request_mem_region(winbase, C101_MAPPED_RAM_SIZE, devname)) { - pr_err("could not request RAM window\n"); + printk(KERN_ERR "c101: could not request RAM window\n"); c101_destroy_card(card); return -EBUSY; } card->phy_winbase = winbase; card->win0base = ioremap(winbase, C101_MAPPED_RAM_SIZE); if (!card->win0base) { - pr_err("could not map I/O address\n"); + printk(KERN_ERR "c101: could not map I/O address\n"); c101_destroy_card(card); return -EFAULT; } @@ -383,7 +381,7 @@ static int __init c101_run(unsigned long irq, unsigned long winbase) result = register_hdlc_device(dev); if (result) { - pr_warn("unable to register hdlc device\n"); + printk(KERN_WARNING "c101: unable to register hdlc device\n"); c101_destroy_card(card); return result; } @@ -391,8 +389,10 @@ static int __init c101_run(unsigned long irq, unsigned long winbase) sca_init_port(card); /* Set up C101 memory */ set_carrier(card); - netdev_info(dev, "Moxa C101 on IRQ%u, using %u TX + %u RX packets rings\n", - card->irq, card->tx_ring_buffers, card->rx_ring_buffers); + printk(KERN_INFO "%s: Moxa C101 on IRQ%u," + " using %u TX + %u RX packets rings\n", + dev->name, card->irq, + card->tx_ring_buffers, card->rx_ring_buffers); *new_card = card; new_card = &card->next_card; @@ -405,12 +405,12 @@ static int __init c101_init(void) { if (hw == NULL) { #ifdef MODULE - pr_info("no card initialized\n"); + printk(KERN_INFO "c101: no card initialized\n"); #endif return -EINVAL; /* no parameters specified, abort */ } - pr_info("%s\n", version); + printk(KERN_INFO "%s\n", version); do { unsigned long irq, ram; @@ -428,7 +428,7 @@ static int __init c101_init(void) return first_card ? 0 : -EINVAL; }while(*hw++ == ':'); - pr_err("invalid hardware parameters\n"); + printk(KERN_ERR "c101: invalid hardware parameters\n"); return first_card ? 0 : -EINVAL; } diff --git a/trunk/drivers/net/wan/cosa.c b/trunk/drivers/net/wan/cosa.c index 6aed238e573e..6fb6f8e667d0 100644 --- a/trunk/drivers/net/wan/cosa.c +++ b/trunk/drivers/net/wan/cosa.c @@ -74,8 +74,6 @@ * The Sync PPP/Cisco HDLC layer (syncppp.c) ported to Linux by Alan Cox */ -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - #include #include #include @@ -363,13 +361,14 @@ static int __init cosa_init(void) if (cosa_major > 0) { if (register_chrdev(cosa_major, "cosa", &cosa_fops)) { - pr_warn("unable to get major %d\n", cosa_major); + printk(KERN_WARNING "cosa: unable to get major %d\n", + cosa_major); err = -EIO; goto out; } } else { if (!(cosa_major=register_chrdev(0, "cosa", &cosa_fops))) { - pr_warn("unable to register chardev\n"); + printk(KERN_WARNING "cosa: unable to register chardev\n"); err = -EIO; goto out; } @@ -379,7 +378,7 @@ static int __init cosa_init(void) for (i=0; io[i] != 0 && i < MAX_CARDS; i++) cosa_probe(io[i], irq[i], dma[i]); if (!nr_cards) { - pr_warn("no devices found\n"); + printk(KERN_WARNING "cosa: no devices found.\n"); unregister_chrdev(cosa_major, "cosa"); err = -ENODEV; goto out; @@ -448,25 +447,26 @@ static int cosa_probe(int base, int irq, int dma) /* Checking validity of parameters: */ /* IRQ should be 2-7 or 10-15; negative IRQ means autoprobe */ if ((irq >= 0 && irq < 2) || irq > 15 || (irq < 10 && irq > 7)) { - pr_info("invalid IRQ %d\n", irq); + printk (KERN_INFO "cosa_probe: invalid IRQ %d\n", irq); return -1; } /* I/O address should be between 0x100 and 0x3ff and should be * multiple of 8. */ if (base < 0x100 || base > 0x3ff || base & 0x7) { - pr_info("invalid I/O address 0x%x\n", base); + printk (KERN_INFO "cosa_probe: invalid I/O address 0x%x\n", + base); return -1; } /* DMA should be 0,1 or 3-7 */ if (dma < 0 || dma == 4 || dma > 7) { - pr_info("invalid DMA %d\n", dma); + printk (KERN_INFO "cosa_probe: invalid DMA %d\n", dma); return -1; } /* and finally, on 16-bit COSA DMA should be 4-7 and * I/O base should not be multiple of 0x10 */ if (((base & 0x8) && dma < 4) || (!(base & 0x8) && dma > 3)) { - pr_info("8/16 bit base and DMA mismatch (base=0x%x, dma=%d)\n", - base, dma); + printk (KERN_INFO "cosa_probe: 8/16 bit base and DMA mismatch" + " (base=0x%x, dma=%d)\n", base, dma); return -1; } @@ -479,7 +479,7 @@ static int cosa_probe(int base, int irq, int dma) return -1; if (cosa_reset_and_read_id(cosa, cosa->id_string) < 0) { - printk(KERN_DEBUG "probe at 0x%x failed.\n", base); + printk(KERN_DEBUG "cosa: probe at 0x%x failed.\n", base); err = -1; goto err_out; } @@ -492,7 +492,8 @@ static int cosa_probe(int base, int irq, int dma) else { /* Print a warning only if we are not autoprobing */ #ifndef COSA_ISA_AUTOPROBE - pr_info("valid signature not found at 0x%x\n", base); + printk(KERN_INFO "cosa: valid signature not found at 0x%x.\n", + base); #endif err = -1; goto err_out; @@ -500,14 +501,14 @@ static int cosa_probe(int base, int irq, int dma) /* Update the name of the region now we know the type of card */ release_region(base, is_8bit(cosa)?2:4); if (!request_region(base, is_8bit(cosa)?2:4, cosa->type)) { - printk(KERN_DEBUG "changing name at 0x%x failed.\n", base); + printk(KERN_DEBUG "cosa: changing name at 0x%x failed.\n", base); return -1; } /* Now do IRQ autoprobe */ if (irq < 0) { unsigned long irqs; -/* pr_info("IRQ autoprobe\n"); */ +/* printk(KERN_INFO "IRQ autoprobe\n"); */ irqs = probe_irq_on(); /* * Enable interrupt on tx buffer empty (it sure is) @@ -525,13 +526,13 @@ static int cosa_probe(int base, int irq, int dma) cosa_getdata8(cosa); if (irq < 0) { - pr_info("multiple interrupts obtained (%d, board at 0x%x)\n", + printk (KERN_INFO "cosa IRQ autoprobe: multiple interrupts obtained (%d, board at 0x%x)\n", irq, cosa->datareg); err = -1; goto err_out; } if (irq == 0) { - pr_info("no interrupt obtained (board at 0x%x)\n", + printk (KERN_INFO "cosa IRQ autoprobe: no interrupt obtained (board at 0x%x)\n", cosa->datareg); /* return -1; */ } @@ -578,7 +579,8 @@ static int cosa_probe(int base, int irq, int dma) /* Register the network interface */ if (!(chan->netdev = alloc_hdlcdev(chan))) { - pr_warn("%s: alloc_hdlcdev failed\n", chan->name); + printk(KERN_WARNING "%s: alloc_hdlcdev failed.\n", + chan->name); goto err_hdlcdev; } dev_to_hdlc(chan->netdev)->attach = cosa_net_attach; @@ -589,14 +591,14 @@ static int cosa_probe(int base, int irq, int dma) chan->netdev->irq = chan->cosa->irq; chan->netdev->dma = chan->cosa->dma; if (register_hdlc_device(chan->netdev)) { - netdev_warn(chan->netdev, - "register_hdlc_device() failed\n"); + printk(KERN_WARNING "%s: register_hdlc_device()" + " failed.\n", chan->netdev->name); free_netdev(chan->netdev); goto err_hdlcdev; } } - pr_info("cosa%d: %s (%s at 0x%x irq %d dma %d), %d channels\n", + printk (KERN_INFO "cosa%d: %s (%s at 0x%x irq %d dma %d), %d channels\n", cosa->num, cosa->id_string, cosa->type, cosa->datareg, cosa->irq, cosa->dma, cosa->nchannels); @@ -616,7 +618,8 @@ static int cosa_probe(int base, int irq, int dma) free_irq(cosa->irq, cosa); err_out: release_region(cosa->datareg,is_8bit(cosa)?2:4); - pr_notice("cosa%d: allocating resources failed\n", cosa->num); + printk(KERN_NOTICE "cosa%d: allocating resources failed\n", + cosa->num); return err; } @@ -638,14 +641,14 @@ static int cosa_net_open(struct net_device *dev) unsigned long flags; if (!(chan->cosa->firmware_status & COSA_FW_START)) { - pr_notice("%s: start the firmware first (status %d)\n", - chan->cosa->name, chan->cosa->firmware_status); + printk(KERN_NOTICE "%s: start the firmware first (status %d)\n", + chan->cosa->name, chan->cosa->firmware_status); return -EPERM; } spin_lock_irqsave(&chan->cosa->lock, flags); if (chan->usage != 0) { - pr_warn("%s: cosa_net_open called with usage count %d\n", - chan->name, chan->usage); + printk(KERN_WARNING "%s: cosa_net_open called with usage count" + " %d\n", chan->name, chan->usage); spin_unlock_irqrestore(&chan->cosa->lock, flags); return -EBUSY; } @@ -733,7 +736,8 @@ static char *cosa_net_setup_rx(struct channel_data *chan, int size) kfree_skb(chan->rx_skb); chan->rx_skb = dev_alloc_skb(size); if (chan->rx_skb == NULL) { - pr_notice("%s: Memory squeeze, dropping packet\n", chan->name); + printk(KERN_NOTICE "%s: Memory squeeze, dropping packet\n", + chan->name); chan->netdev->stats.rx_dropped++; return NULL; } @@ -744,7 +748,8 @@ static char *cosa_net_setup_rx(struct channel_data *chan, int size) static int cosa_net_rx_done(struct channel_data *chan) { if (!chan->rx_skb) { - pr_warn("%s: rx_done with empty skb!\n", chan->name); + printk(KERN_WARNING "%s: rx_done with empty skb!\n", + chan->name); chan->netdev->stats.rx_errors++; chan->netdev->stats.rx_frame_errors++; return 0; @@ -763,7 +768,8 @@ static int cosa_net_rx_done(struct channel_data *chan) static int cosa_net_tx_done(struct channel_data *chan, int size) { if (!chan->tx_skb) { - pr_warn("%s: tx_done with empty skb!\n", chan->name); + printk(KERN_WARNING "%s: tx_done with empty skb!\n", + chan->name); chan->netdev->stats.tx_errors++; chan->netdev->stats.tx_aborted_errors++; return 1; @@ -788,15 +794,15 @@ static ssize_t cosa_read(struct file *file, char *kbuf; if (!(cosa->firmware_status & COSA_FW_START)) { - pr_notice("%s: start the firmware first (status %d)\n", - cosa->name, cosa->firmware_status); + printk(KERN_NOTICE "%s: start the firmware first (status %d)\n", + cosa->name, cosa->firmware_status); return -EPERM; } if (mutex_lock_interruptible(&chan->rlock)) return -ERESTARTSYS; if ((chan->rxdata = kmalloc(COSA_MTU, GFP_DMA|GFP_KERNEL)) == NULL) { - pr_info("%s: cosa_read() - OOM\n", cosa->name); + printk(KERN_INFO "%s: cosa_read() - OOM\n", cosa->name); mutex_unlock(&chan->rlock); return -ENOMEM; } @@ -863,8 +869,8 @@ static ssize_t cosa_write(struct file *file, char *kbuf; if (!(cosa->firmware_status & COSA_FW_START)) { - pr_notice("%s: start the firmware first (status %d)\n", - cosa->name, cosa->firmware_status); + printk(KERN_NOTICE "%s: start the firmware first (status %d)\n", + cosa->name, cosa->firmware_status); return -EPERM; } if (down_interruptible(&chan->wsem)) @@ -875,8 +881,8 @@ static ssize_t cosa_write(struct file *file, /* Allocate the buffer */ if ((kbuf = kmalloc(count, GFP_KERNEL|GFP_DMA)) == NULL) { - pr_notice("%s: cosa_write() OOM - dropping packet\n", - cosa->name); + printk(KERN_NOTICE "%s: cosa_write() OOM - dropping packet\n", + cosa->name); up(&chan->wsem); return -ENOMEM; } @@ -926,7 +932,7 @@ static int chrdev_tx_done(struct channel_data *chan, int size) static unsigned int cosa_poll(struct file *file, poll_table *poll) { - pr_info("cosa_poll is here\n"); + printk(KERN_INFO "cosa_poll is here\n"); return 0; } @@ -1011,14 +1017,15 @@ static inline int cosa_reset(struct cosa_data *cosa) { char idstring[COSA_MAX_ID_STRING]; if (cosa->usage > 1) - pr_info("cosa%d: WARNING: reset requested with cosa->usage > 1 (%d). Odd things may happen.\n", + printk(KERN_INFO "cosa%d: WARNING: reset requested with cosa->usage > 1 (%d). Odd things may happen.\n", cosa->num, cosa->usage); cosa->firmware_status &= ~(COSA_FW_RESET|COSA_FW_START); if (cosa_reset_and_read_id(cosa, idstring) < 0) { - pr_notice("cosa%d: reset failed\n", cosa->num); + printk(KERN_NOTICE "cosa%d: reset failed\n", cosa->num); return -EIO; } - pr_info("cosa%d: resetting device: %s\n", cosa->num, idstring); + printk(KERN_INFO "cosa%d: resetting device: %s\n", cosa->num, + idstring); cosa->firmware_status |= COSA_FW_RESET; return 0; } @@ -1030,11 +1037,11 @@ static inline int cosa_download(struct cosa_data *cosa, void __user *arg) int i; if (cosa->usage > 1) - pr_info("%s: WARNING: download of microcode requested with cosa->usage > 1 (%d). Odd things may happen.\n", + printk(KERN_INFO "%s: WARNING: download of microcode requested with cosa->usage > 1 (%d). Odd things may happen.\n", cosa->name, cosa->usage); if (!(cosa->firmware_status & COSA_FW_RESET)) { - pr_notice("%s: reset the card first (status %d)\n", - cosa->name, cosa->firmware_status); + printk(KERN_NOTICE "%s: reset the card first (status %d).\n", + cosa->name, cosa->firmware_status); return -EPERM; } @@ -1052,11 +1059,11 @@ static inline int cosa_download(struct cosa_data *cosa, void __user *arg) i = download(cosa, d.code, d.len, d.addr); if (i < 0) { - pr_notice("cosa%d: microcode download failed: %d\n", - cosa->num, i); + printk(KERN_NOTICE "cosa%d: microcode download failed: %d\n", + cosa->num, i); return -EIO; } - pr_info("cosa%d: downloading microcode - 0x%04x bytes at 0x%04x\n", + printk(KERN_INFO "cosa%d: downloading microcode - 0x%04x bytes at 0x%04x\n", cosa->num, d.len, d.addr); cosa->firmware_status |= COSA_FW_RESET|COSA_FW_DOWNLOAD; return 0; @@ -1069,11 +1076,12 @@ static inline int cosa_readmem(struct cosa_data *cosa, void __user *arg) int i; if (cosa->usage > 1) - pr_info("cosa%d: WARNING: readmem requested with cosa->usage > 1 (%d). Odd things may happen.\n", + printk(KERN_INFO "cosa%d: WARNING: readmem requested with " + "cosa->usage > 1 (%d). Odd things may happen.\n", cosa->num, cosa->usage); if (!(cosa->firmware_status & COSA_FW_RESET)) { - pr_notice("%s: reset the card first (status %d)\n", - cosa->name, cosa->firmware_status); + printk(KERN_NOTICE "%s: reset the card first (status %d).\n", + cosa->name, cosa->firmware_status); return -EPERM; } @@ -1085,10 +1093,11 @@ static inline int cosa_readmem(struct cosa_data *cosa, void __user *arg) i = readmem(cosa, d.code, d.len, d.addr); if (i < 0) { - pr_notice("cosa%d: reading memory failed: %d\n", cosa->num, i); + printk(KERN_NOTICE "cosa%d: reading memory failed: %d\n", + cosa->num, i); return -EIO; } - pr_info("cosa%d: reading card memory - 0x%04x bytes at 0x%04x\n", + printk(KERN_INFO "cosa%d: reading card memory - 0x%04x bytes at 0x%04x\n", cosa->num, d.len, d.addr); cosa->firmware_status |= COSA_FW_RESET; return 0; @@ -1100,22 +1109,23 @@ static inline int cosa_start(struct cosa_data *cosa, int address) int i; if (cosa->usage > 1) - pr_info("cosa%d: WARNING: start microcode requested with cosa->usage > 1 (%d). Odd things may happen.\n", + printk(KERN_INFO "cosa%d: WARNING: start microcode requested with cosa->usage > 1 (%d). Odd things may happen.\n", cosa->num, cosa->usage); if ((cosa->firmware_status & (COSA_FW_RESET|COSA_FW_DOWNLOAD)) != (COSA_FW_RESET|COSA_FW_DOWNLOAD)) { - pr_notice("%s: download the microcode and/or reset the card first (status %d)\n", - cosa->name, cosa->firmware_status); + printk(KERN_NOTICE "%s: download the microcode and/or reset the card first (status %d).\n", + cosa->name, cosa->firmware_status); return -EPERM; } cosa->firmware_status &= ~COSA_FW_RESET; if ((i=startmicrocode(cosa, address)) < 0) { - pr_notice("cosa%d: start microcode at 0x%04x failed: %d\n", - cosa->num, address, i); + printk(KERN_NOTICE "cosa%d: start microcode at 0x%04x failed: %d\n", + cosa->num, address, i); return -EIO; } - pr_info("cosa%d: starting microcode at 0x%04x\n", cosa->num, address); + printk(KERN_INFO "cosa%d: starting microcode at 0x%04x\n", + cosa->num, address); cosa->startaddr = address; cosa->firmware_status |= COSA_FW_START; return 0; @@ -1245,11 +1255,11 @@ static int cosa_start_tx(struct channel_data *chan, char *buf, int len) #ifdef DEBUG_DATA int i; - pr_info("cosa%dc%d: starting tx(0x%x)", - chan->cosa->num, chan->num, len); + printk(KERN_INFO "cosa%dc%d: starting tx(0x%x)", chan->cosa->num, + chan->num, len); for (i=0; ilock, flags); chan->txbuf = buf; @@ -1343,7 +1353,7 @@ static void cosa_kick(struct cosa_data *cosa) if (test_bit(TXBIT, &cosa->rxtx)) s = "TX DMA"; - pr_info("%s: %s timeout - restarting\n", cosa->name, s); + printk(KERN_INFO "%s: %s timeout - restarting.\n", cosa->name, s); spin_lock_irqsave(&cosa->lock, flags); cosa->rxtx = 0; @@ -1377,7 +1387,7 @@ static int cosa_dma_able(struct channel_data *chan, char *buf, int len) return 0; if ((b^ (b+len)) & 0x10000) { if (count++ < 5) - pr_info("%s: packet spanning a 64k boundary\n", + printk(KERN_INFO "%s: packet spanning a 64k boundary\n", chan->name); return 0; } @@ -1488,7 +1498,8 @@ static int readmem(struct cosa_data *cosa, char __user *microcode, int length, i char c; int i; if ((i=get_wait_data(cosa)) == -1) { - pr_info("0x%04x bytes remaining\n", length); + printk (KERN_INFO "cosa: 0x%04x bytes remaining\n", + length); return -11; } c=i; @@ -1571,15 +1582,14 @@ static int get_wait_data(struct cosa_data *cosa) short r; r = cosa_getdata8(cosa); #if 0 - pr_info("get_wait_data returning after %d retries\n", - 999-retries); + printk(KERN_INFO "cosa: get_wait_data returning after %d retries\n", 999-retries); #endif return r; } /* sleep if not ready to read */ schedule_timeout_interruptible(1); } - pr_info("timeout in get_wait_data (status 0x%x)\n", + printk(KERN_INFO "cosa: timeout in get_wait_data (status 0x%x)\n", cosa_getstatus(cosa)); return -1; } @@ -1597,7 +1607,7 @@ static int put_wait_data(struct cosa_data *cosa, int data) if (cosa_getstatus(cosa) & SR_TX_RDY) { cosa_putdata8(cosa, data); #if 0 - pr_info("Putdata: %d retries\n", 999-retries); + printk(KERN_INFO "Putdata: %d retries\n", 999-retries); #endif return 0; } @@ -1606,7 +1616,7 @@ static int put_wait_data(struct cosa_data *cosa, int data) schedule_timeout_interruptible(1); #endif } - pr_info("cosa%d: timeout in put_wait_data (status 0x%x)\n", + printk(KERN_INFO "cosa%d: timeout in put_wait_data (status 0x%x)\n", cosa->num, cosa_getstatus(cosa)); return -1; } @@ -1626,13 +1636,13 @@ static int puthexnumber(struct cosa_data *cosa, int number) sprintf(temp, "%04X", number); for (i=0; i<4; i++) { if (put_wait_data(cosa, temp[i]) == -1) { - pr_notice("cosa%d: puthexnumber failed to write byte %d\n", - cosa->num, i); + printk(KERN_NOTICE "cosa%d: puthexnumber failed to write byte %d\n", + cosa->num, i); return -1-2*i; } if (get_wait_data(cosa) != temp[i]) { - pr_notice("cosa%d: puthexhumber failed to read echo of byte %d\n", - cosa->num, i); + printk(KERN_NOTICE "cosa%d: puthexhumber failed to read echo of byte %d\n", + cosa->num, i); return -2-2*i; } } @@ -1677,7 +1687,8 @@ static inline void tx_interrupt(struct cosa_data *cosa, int status) { unsigned long flags, flags1; #ifdef DEBUG_IRQS - pr_info("cosa%d: SR_DOWN_REQUEST status=0x%04x\n", cosa->num, status); + printk(KERN_INFO "cosa%d: SR_DOWN_REQUEST status=0x%04x\n", + cosa->num, status); #endif spin_lock_irqsave(&cosa->lock, flags); set_bit(TXBIT, &cosa->rxtx); @@ -1685,7 +1696,8 @@ static inline void tx_interrupt(struct cosa_data *cosa, int status) /* flow control, see the comment above */ int i=0; if (!cosa->txbitmap) { - pr_warn("%s: No channel wants data in TX IRQ. Expect DMA timeout.\n", + printk(KERN_WARNING "%s: No channel wants data " + "in TX IRQ. Expect DMA timeout.", cosa->name); put_driver_status_nolock(cosa); clear_bit(TXBIT, &cosa->rxtx); @@ -1768,14 +1780,14 @@ static inline void tx_interrupt(struct cosa_data *cosa, int status) if (cosa->busmaster) { unsigned long addr = virt_to_bus(cosa->txbuf); int count=0; - pr_info("busmaster IRQ\n"); + printk(KERN_INFO "busmaster IRQ\n"); while (!(cosa_getstatus(cosa)&SR_TX_RDY)) { count++; udelay(10); if (count > 1000) break; } - pr_info("status %x\n", cosa_getstatus(cosa)); - pr_info("ready after %d loops\n", count); + printk(KERN_INFO "status %x\n", cosa_getstatus(cosa)); + printk(KERN_INFO "ready after %d loops\n", count); cosa_putdata16(cosa, (addr >> 16)&0xffff); count = 0; @@ -1784,7 +1796,7 @@ static inline void tx_interrupt(struct cosa_data *cosa, int status) if (count > 1000) break; udelay(10); } - pr_info("ready after %d loops\n", count); + printk(KERN_INFO "ready after %d loops\n", count); cosa_putdata16(cosa, addr &0xffff); flags1 = claim_dma_lock(); set_dma_mode(cosa->dma, DMA_MODE_CASCADE); @@ -1812,7 +1824,7 @@ static inline void rx_interrupt(struct cosa_data *cosa, int status) { unsigned long flags; #ifdef DEBUG_IRQS - pr_info("cosa%d: SR_UP_REQUEST\n", cosa->num); + printk(KERN_INFO "cosa%d: SR_UP_REQUEST\n", cosa->num); #endif spin_lock_irqsave(&cosa->lock, flags); @@ -1835,7 +1847,7 @@ static inline void rx_interrupt(struct cosa_data *cosa, int status) debug_data_in(cosa, cosa->rxsize & 0xff); #endif #if 0 - pr_info("cosa%d: receive rxsize = (0x%04x)\n", + printk(KERN_INFO "cosa%d: receive rxsize = (0x%04x).\n", cosa->num, cosa->rxsize); #endif } @@ -1845,12 +1857,12 @@ static inline void rx_interrupt(struct cosa_data *cosa, int status) debug_data_in(cosa, cosa->rxsize); #endif #if 0 - pr_info("cosa%d: receive rxsize = (0x%04x)\n", + printk(KERN_INFO "cosa%d: receive rxsize = (0x%04x).\n", cosa->num, cosa->rxsize); #endif } if (((cosa->rxsize & 0xe000) >> 13) >= cosa->nchannels) { - pr_warn("%s: rx for unknown channel (0x%04x)\n", + printk(KERN_WARNING "%s: rx for unknown channel (0x%04x)\n", cosa->name, cosa->rxsize); spin_unlock_irqrestore(&cosa->lock, flags); goto reject; @@ -1865,7 +1877,7 @@ static inline void rx_interrupt(struct cosa_data *cosa, int status) if (!cosa->rxbuf) { reject: /* Reject the packet */ - pr_info("cosa%d: rejecting packet on channel %d\n", + printk(KERN_INFO "cosa%d: rejecting packet on channel %d\n", cosa->num, cosa->rxchan->num); cosa->rxbuf = cosa->bouncebuf; } @@ -1912,11 +1924,11 @@ static inline void eot_interrupt(struct cosa_data *cosa, int status) #ifdef DEBUG_DATA { int i; - pr_info("cosa%dc%d: done rx(0x%x)", - cosa->num, cosa->rxchan->num, cosa->rxsize); + printk(KERN_INFO "cosa%dc%d: done rx(0x%x)", cosa->num, + cosa->rxchan->num, cosa->rxsize); for (i=0; irxsize; i++) - pr_cont(" %02x", cosa->rxbuf[i]&0xff); - pr_cont("\n"); + printk (" %02x", cosa->rxbuf[i]&0xff); + printk("\n"); } #endif /* Packet for unknown channel? */ @@ -1928,7 +1940,8 @@ static inline void eot_interrupt(struct cosa_data *cosa, int status) if (cosa->rxchan->rx_done(cosa->rxchan)) clear_bit(cosa->rxchan->num, &cosa->rxbitmap); } else { - pr_notice("cosa%d: unexpected EOT interrupt\n", cosa->num); + printk(KERN_NOTICE "cosa%d: unexpected EOT interrupt\n", + cosa->num); } /* * Clear the RXBIT, TXBIT and IRQBIT (the latest should be @@ -1950,7 +1963,8 @@ static irqreturn_t cosa_interrupt(int irq, void *cosa_) again: status = cosa_getstatus(cosa); #ifdef DEBUG_IRQS - pr_info("cosa%d: got IRQ, status 0x%02x\n", cosa->num, status & 0xff); + printk(KERN_INFO "cosa%d: got IRQ, status 0x%02x\n", cosa->num, + status & 0xff); #endif #ifdef DEBUG_IO debug_status_in(cosa, status); @@ -1971,15 +1985,15 @@ static irqreturn_t cosa_interrupt(int irq, void *cosa_) udelay(100); goto again; } - pr_info("cosa%d: unknown status 0x%02x in IRQ after %d retries\n", + printk(KERN_INFO "cosa%d: unknown status 0x%02x in IRQ after %d retries\n", cosa->num, status & 0xff, count); } #ifdef DEBUG_IRQS if (count) - pr_info("%s: %d-times got unknown status in IRQ\n", + printk(KERN_INFO "%s: %d-times got unknown status in IRQ\n", cosa->name, count); else - pr_info("%s: returning from IRQ\n", cosa->name); + printk(KERN_INFO "%s: returning from IRQ\n", cosa->name); #endif return IRQ_HANDLED; } @@ -2010,41 +2024,41 @@ static void debug_status_in(struct cosa_data *cosa, int status) s = "NO_REQ"; break; } - pr_info("%s: IO: status -> 0x%02x (%s%s%s%s)\n", + printk(KERN_INFO "%s: IO: status -> 0x%02x (%s%s%s%s)\n", cosa->name, status, - status & SR_USR_RQ ? "USR_RQ|" : "", - status & SR_TX_RDY ? "TX_RDY|" : "", - status & SR_RX_RDY ? "RX_RDY|" : "", + status & SR_USR_RQ ? "USR_RQ|":"", + status & SR_TX_RDY ? "TX_RDY|":"", + status & SR_RX_RDY ? "RX_RDY|":"", s); } static void debug_status_out(struct cosa_data *cosa, int status) { - pr_info("%s: IO: status <- 0x%02x (%s%s%s%s%s%s)\n", + printk(KERN_INFO "%s: IO: status <- 0x%02x (%s%s%s%s%s%s)\n", cosa->name, status, - status & SR_RX_DMA_ENA ? "RXDMA|" : "!rxdma|", - status & SR_TX_DMA_ENA ? "TXDMA|" : "!txdma|", - status & SR_RST ? "RESET|" : "", - status & SR_USR_INT_ENA ? "USRINT|" : "!usrint|", - status & SR_TX_INT_ENA ? "TXINT|" : "!txint|", - status & SR_RX_INT_ENA ? "RXINT" : "!rxint"); + status & SR_RX_DMA_ENA ? "RXDMA|":"!rxdma|", + status & SR_TX_DMA_ENA ? "TXDMA|":"!txdma|", + status & SR_RST ? "RESET|":"", + status & SR_USR_INT_ENA ? "USRINT|":"!usrint|", + status & SR_TX_INT_ENA ? "TXINT|":"!txint|", + status & SR_RX_INT_ENA ? "RXINT":"!rxint"); } static void debug_data_in(struct cosa_data *cosa, int data) { - pr_info("%s: IO: data -> 0x%04x\n", cosa->name, data); + printk(KERN_INFO "%s: IO: data -> 0x%04x\n", cosa->name, data); } static void debug_data_out(struct cosa_data *cosa, int data) { - pr_info("%s: IO: data <- 0x%04x\n", cosa->name, data); + printk(KERN_INFO "%s: IO: data <- 0x%04x\n", cosa->name, data); } static void debug_data_cmd(struct cosa_data *cosa, int data) { - pr_info("%s: IO: data <- 0x%04x (%s|%s)\n", + printk(KERN_INFO "%s: IO: data <- 0x%04x (%s|%s)\n", cosa->name, data, data & SR_RDY_RCV ? "RX_RDY" : "!rx_rdy", data & SR_RDY_SND ? "TX_RDY" : "!tx_rdy"); diff --git a/trunk/drivers/net/wan/cycx_drv.c b/trunk/drivers/net/wan/cycx_drv.c index 2a3ecae67a90..164c3624ba89 100644 --- a/trunk/drivers/net/wan/cycx_drv.c +++ b/trunk/drivers/net/wan/cycx_drv.c @@ -48,8 +48,6 @@ * Aug 8, 1998 acme Initial version. */ -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - #include /* __init */ #include #include /* printk(), and other useful stuff */ @@ -83,9 +81,10 @@ static u16 checksum(u8 *buf, u32 len); /* Global Data */ /* private data */ +static const char modname[] = "cycx_drv"; static const char fullname[] = "Cyclom 2X Support Module"; -static const char copyright[] = - "(c) 1998-2003 Arnaldo Carvalho de Melo "; +static const char copyright[] = "(c) 1998-2003 Arnaldo Carvalho de Melo " + ""; /* Hardware configuration options. * These are arrays of configuration options used by verification routines. @@ -111,8 +110,8 @@ static const long cycx_2x_irq_options[] = { 7, 3, 5, 9, 10, 11, 12, 15 }; static int __init cycx_drv_init(void) { - pr_info("%s v%u.%u %s\n", - fullname, MOD_VERSION, MOD_RELEASE, copyright); + printk(KERN_INFO "%s v%u.%u %s\n", fullname, MOD_VERSION, MOD_RELEASE, + copyright); return 0; } @@ -140,16 +139,18 @@ int cycx_setup(struct cycx_hw *hw, void *cfm, u32 len, unsigned long dpmbase) /* Verify IRQ configuration options */ if (!get_option_index(cycx_2x_irq_options, hw->irq)) { - pr_err("IRQ %d is invalid!\n", hw->irq); + printk(KERN_ERR "%s: IRQ %d is invalid!\n", modname, hw->irq); return -EINVAL; } /* Setup adapter dual-port memory window and test memory */ if (!dpmbase) { - pr_err("you must specify the dpm address!\n"); + printk(KERN_ERR "%s: you must specify the dpm address!\n", + modname); return -EINVAL; } else if (!get_option_index(cyc2x_dpmbase_options, dpmbase)) { - pr_err("memory address 0x%lX is invalid!\n", dpmbase); + printk(KERN_ERR "%s: memory address 0x%lX is invalid!\n", + modname, dpmbase); return -EINVAL; } @@ -157,12 +158,13 @@ int cycx_setup(struct cycx_hw *hw, void *cfm, u32 len, unsigned long dpmbase) hw->dpmsize = CYCX_WINDOWSIZE; if (!detect_cyc2x(hw->dpmbase)) { - pr_err("adapter Cyclom 2X not found at address 0x%lX!\n", - dpmbase); + printk(KERN_ERR "%s: adapter Cyclom 2X not found at " + "address 0x%lX!\n", modname, dpmbase); return -EINVAL; } - pr_info("found Cyclom 2X card at address 0x%lX\n", dpmbase); + printk(KERN_INFO "%s: found Cyclom 2X card at address 0x%lX.\n", + modname, dpmbase); /* Load firmware. If loader fails then shut down adapter */ err = load_cyc2x(hw, cfm, len); @@ -337,7 +339,7 @@ static int cycx_data_boot(void __iomem *addr, u8 *code, u32 len) for (i = 0 ; i < len ; i += CFM_LOAD_BUFSZ) if (buffer_load(addr, code + i, min_t(u32, CFM_LOAD_BUFSZ, (len - i))) < 0) { - pr_err("Error !!\n"); + printk(KERN_ERR "%s: Error !!\n", modname); return -1; } @@ -368,7 +370,7 @@ static int cycx_code_boot(void __iomem *addr, u8 *code, u32 len) for (i = 0 ; i < len ; i += CFM_LOAD_BUFSZ) if (buffer_load(addr, code + i, min_t(u32, CFM_LOAD_BUFSZ, (len - i)))) { - pr_err("Error !!\n"); + printk(KERN_ERR "%s: Error !!\n", modname); return -1; } @@ -389,20 +391,23 @@ static int load_cyc2x(struct cycx_hw *hw, struct cycx_firmware *cfm, u32 len) u16 cksum; /* Announce */ - pr_info("firmware signature=\"%s\"\n", cfm->signature); + printk(KERN_INFO "%s: firmware signature=\"%s\"\n", modname, + cfm->signature); /* Verify firmware signature */ if (strcmp(cfm->signature, CFM_SIGNATURE)) { - pr_err("load_cyc2x: not Cyclom-2X firmware!\n"); + printk(KERN_ERR "%s:load_cyc2x: not Cyclom-2X firmware!\n", + modname); return -EINVAL; } - pr_info("firmware version=%u\n", cfm->version); + printk(KERN_INFO "%s: firmware version=%u\n", modname, cfm->version); /* Verify firmware module format version */ if (cfm->version != CFM_VERSION) { - pr_err("%s: firmware format %u rejected! Expecting %u.\n", - __func__, cfm->version, CFM_VERSION); + printk(KERN_ERR "%s:%s: firmware format %u rejected! " + "Expecting %u.\n", + modname, __func__, cfm->version, CFM_VERSION); return -EINVAL; } @@ -414,22 +419,23 @@ static int load_cyc2x(struct cycx_hw *hw, struct cycx_firmware *cfm, u32 len) if (((len - sizeof(struct cycx_firmware) - 1) != cfm->info.codesize) || */ if (cksum != cfm->checksum) { - pr_err("%s: firmware corrupted!\n", __func__); - pr_err(" cdsize = 0x%x (expected 0x%lx)\n", - len - (int)sizeof(struct cycx_firmware) - 1, - cfm->info.codesize); - pr_err(" chksum = 0x%x (expected 0x%x)\n", - cksum, cfm->checksum); + printk(KERN_ERR "%s:%s: firmware corrupted!\n", + modname, __func__); + printk(KERN_ERR " cdsize = 0x%x (expected 0x%lx)\n", + len - (int)sizeof(struct cycx_firmware) - 1, + cfm->info.codesize); + printk(KERN_ERR " chksum = 0x%x (expected 0x%x)\n", + cksum, cfm->checksum); return -EINVAL; } /* If everything is ok, set reset, data and code pointers */ img_hdr = (struct cycx_fw_header *)&cfm->image; #ifdef FIRMWARE_DEBUG - pr_info("%s: image sizes\n", __func__); - pr_info(" reset=%lu\n", img_hdr->reset_size); - pr_info(" data=%lu\n", img_hdr->data_size); - pr_info(" code=%lu\n", img_hdr->code_size); + printk(KERN_INFO "%s:%s: image sizes\n", __func__, modname); + printk(KERN_INFO " reset=%lu\n", img_hdr->reset_size); + printk(KERN_INFO " data=%lu\n", img_hdr->data_size); + printk(KERN_INFO " code=%lu\n", img_hdr->code_size); #endif reset_image = ((u8 *)img_hdr) + sizeof(struct cycx_fw_header); data_image = reset_image + img_hdr->reset_size; @@ -437,14 +443,15 @@ static int load_cyc2x(struct cycx_hw *hw, struct cycx_firmware *cfm, u32 len) /*---- Start load ----*/ /* Announce */ - pr_info("loading firmware %s (ID=%u)...\n", - cfm->descr[0] ? cfm->descr : "unknown firmware", - cfm->info.codeid); + printk(KERN_INFO "%s: loading firmware %s (ID=%u)...\n", modname, + cfm->descr[0] ? cfm->descr : "unknown firmware", + cfm->info.codeid); for (i = 0 ; i < 5 ; i++) { /* Reset Cyclom hardware */ if (!reset_cyc2x(hw->dpmbase)) { - pr_err("dpm problem or board not found\n"); + printk(KERN_ERR "%s: dpm problem or board not found\n", + modname); return -EINVAL; } @@ -461,19 +468,19 @@ static int load_cyc2x(struct cycx_hw *hw, struct cycx_firmware *cfm, u32 len) msleep_interruptible(1 * 1000); } - pr_err("reset not started\n"); + printk(KERN_ERR "%s: reset not started.\n", modname); return -EINVAL; reset_loaded: /* Load data.bin */ if (cycx_data_boot(hw->dpmbase, data_image, img_hdr->data_size)) { - pr_err("cannot load data file\n"); + printk(KERN_ERR "%s: cannot load data file.\n", modname); return -EINVAL; } /* Load code.bin */ if (cycx_code_boot(hw->dpmbase, code_image, img_hdr->code_size)) { - pr_err("cannot load code file\n"); + printk(KERN_ERR "%s: cannot load code file.\n", modname); return -EINVAL; } @@ -486,7 +493,7 @@ static int load_cyc2x(struct cycx_hw *hw, struct cycx_firmware *cfm, u32 len) /* Arthur Ganzert's tip: wait a while after the firmware loading... seg abr 26 17:17:12 EST 1999 - acme */ msleep_interruptible(7 * 1000); - pr_info("firmware loaded!\n"); + printk(KERN_INFO "%s: firmware loaded!\n", modname); /* enable interrupts */ cycx_inten(hw); diff --git a/trunk/drivers/net/wan/cycx_main.c b/trunk/drivers/net/wan/cycx_main.c index 81fbbad406be..a0976d1f97c6 100644 --- a/trunk/drivers/net/wan/cycx_main.c +++ b/trunk/drivers/net/wan/cycx_main.c @@ -40,8 +40,6 @@ * 1998/08/08 acme Initial version. */ -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - #include /* offsetof(), etc. */ #include /* return codes */ #include /* inline memset(), etc. */ @@ -109,7 +107,7 @@ static int __init cycx_init(void) { int cnt, err = -ENOMEM; - pr_info("%s v%u.%u %s\n", + printk(KERN_INFO "%s v%u.%u %s\n", cycx_fullname, CYCX_DRV_VERSION, CYCX_DRV_RELEASE, cycx_copyright); @@ -135,8 +133,9 @@ static int __init cycx_init(void) err = register_wan_device(wandev); if (err) { - pr_err("%s registration failed with error %d!\n", - card->devname, err); + printk(KERN_ERR "%s: %s registration failed with " + "error %d!\n", + cycx_drvname, card->devname, err); break; } } @@ -199,13 +198,14 @@ static int cycx_wan_setup(struct wan_device *wandev, wandev_conf_t *conf) rc = -EINVAL; if (!conf->data_size || !conf->data) { - pr_err("%s: firmware not found in configuration data!\n", - wandev->name); + printk(KERN_ERR "%s: firmware not found in configuration " + "data!\n", wandev->name); goto out; } if (conf->irq <= 0) { - pr_err("%s: can't configure without IRQ!\n", wandev->name); + printk(KERN_ERR "%s: can't configure without IRQ!\n", + wandev->name); goto out; } @@ -213,7 +213,8 @@ static int cycx_wan_setup(struct wan_device *wandev, wandev_conf_t *conf) irq = conf->irq == 2 ? 9 : conf->irq; /* IRQ2 -> IRQ9 */ if (request_irq(irq, cycx_isr, 0, wandev->name, card)) { - pr_err("%s: can't reserve IRQ %d!\n", wandev->name, irq); + printk(KERN_ERR "%s: can't reserve IRQ %d!\n", + wandev->name, irq); goto out; } @@ -245,7 +246,8 @@ static int cycx_wan_setup(struct wan_device *wandev, wandev_conf_t *conf) break; #endif default: - pr_err("%s: this firmware is not supported!\n", wandev->name); + printk(KERN_ERR "%s: this firmware is not supported!\n", + wandev->name); rc = -EINVAL; } @@ -286,7 +288,8 @@ static int cycx_wan_shutdown(struct wan_device *wandev) card = wandev->private; wandev->state = WAN_UNCONFIGURED; cycx_down(&card->hw); - pr_info("%s: irq %d being freed!\n", wandev->name, wandev->irq); + printk(KERN_INFO "%s: irq %d being freed!\n", wandev->name, + wandev->irq); free_irq(wandev->irq, card); out: return ret; } @@ -305,8 +308,8 @@ static irqreturn_t cycx_isr(int irq, void *dev_id) goto out; if (card->in_isr) { - pr_warn("%s: interrupt re-entrancy on IRQ %d!\n", - card->devname, card->wandev.irq); + printk(KERN_WARNING "%s: interrupt re-entrancy on IRQ %d!\n", + card->devname, card->wandev.irq); goto out; } @@ -334,7 +337,7 @@ void cycx_set_state(struct cycx_device *card, int state) string_state = "disconnected!"; break; } - pr_info("%s: link %s\n", card->devname, string_state); + printk(KERN_INFO "%s: link %s\n", card->devname, string_state); card->wandev.state = state; } diff --git a/trunk/drivers/net/wan/cycx_x25.c b/trunk/drivers/net/wan/cycx_x25.c index 06f3f6309e4b..cf9e15fd8d91 100644 --- a/trunk/drivers/net/wan/cycx_x25.c +++ b/trunk/drivers/net/wan/cycx_x25.c @@ -76,8 +76,6 @@ * 1998/08/08 acme Initial version. */ -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - #define CYCLOMX_X25_DEBUG 1 #include /* isdigit() */ @@ -232,8 +230,8 @@ int cycx_x25_wan_init(struct cycx_device *card, wandev_conf_t *conf) /* Verify configuration ID */ if (conf->config_id != WANCONFIG_X25) { - pr_info("%s: invalid configuration ID %u!\n", - card->devname, conf->config_id); + printk(KERN_INFO "%s: invalid configuration ID %u!\n", + card->devname, conf->config_id); return -EINVAL; } @@ -376,7 +374,8 @@ static int cycx_wan_new_if(struct wan_device *wandev, struct net_device *dev, int err = 0; if (!conf->name[0] || strlen(conf->name) > WAN_IFNAME_SZ) { - pr_info("%s: invalid interface name!\n", card->devname); + printk(KERN_INFO "%s: invalid interface name!\n", + card->devname); return -EINVAL; } @@ -399,8 +398,8 @@ static int cycx_wan_new_if(struct wan_device *wandev, struct net_device *dev, if (len) { if (len > WAN_ADDRESS_SZ) { - pr_err("%s: %s local addr too long!\n", - wandev->name, chan->name); + printk(KERN_ERR "%s: %s local addr too long!\n", + wandev->name, chan->name); err = -EINVAL; goto error; } else { @@ -430,14 +429,15 @@ static int cycx_wan_new_if(struct wan_device *wandev, struct net_device *dev, if (lcn >= card->u.x.lo_pvc && lcn <= card->u.x.hi_pvc) chan->lcn = lcn; else { - pr_err("%s: PVC %u is out of range on interface %s!\n", - wandev->name, lcn, chan->name); + printk(KERN_ERR + "%s: PVC %u is out of range on interface %s!\n", + wandev->name, lcn, chan->name); err = -EINVAL; goto error; } } else { - pr_err("%s: invalid media address on interface %s!\n", - wandev->name, chan->name); + printk(KERN_ERR "%s: invalid media address on interface %s!\n", + wandev->name, chan->name); err = -EINVAL; goto error; } @@ -607,8 +607,9 @@ static netdev_tx_t cycx_netdevice_hard_start_xmit(struct sk_buff *skb, ++chan->ifstats.tx_dropped; else if (chan->svc && chan->protocol && chan->protocol != ntohs(skb->protocol)) { - pr_info("%s: unsupported Ethertype 0x%04X on interface %s!\n", - card->devname, ntohs(skb->protocol), dev->name); + printk(KERN_INFO + "%s: unsupported Ethertype 0x%04X on interface %s!\n", + card->devname, ntohs(skb->protocol), dev->name); ++chan->ifstats.tx_errors; } else if (chan->protocol == ETH_P_IP) { switch (chan->state) { @@ -642,8 +643,9 @@ static netdev_tx_t cycx_netdevice_hard_start_xmit(struct sk_buff *skb, cycx_x25_chan_disconnect(dev); goto free_packet; default: - pr_info("%s: unknown %d x25-iface request on %s!\n", - card->devname, skb->data[0], dev->name); + printk(KERN_INFO + "%s: unknown %d x25-iface request on %s!\n", + card->devname, skb->data[0], dev->name); ++chan->ifstats.tx_errors; goto free_packet; } @@ -744,7 +746,8 @@ static void cycx_x25_irq_tx(struct cycx_device *card, struct cycx_x25_cmd *cmd) card->buff_int_mode_unbusy = 1; netif_wake_queue(dev); } else - pr_err("%s:ackvc for inexistent lcn %d\n", card->devname, lcn); + printk(KERN_ERR "%s:ackvc for inexistent lcn %d\n", + card->devname, lcn); } /* Receive interrupt handler. @@ -777,8 +780,8 @@ static void cycx_x25_irq_rx(struct cycx_device *card, struct cycx_x25_cmd *cmd) dev = cycx_x25_get_dev_by_lcn(wandev, lcn); if (!dev) { /* Invalid channel, discard packet */ - pr_info("%s: receiving on orphaned LCN %d!\n", - card->devname, lcn); + printk(KERN_INFO "%s: receiving on orphaned LCN %d!\n", + card->devname, lcn); return; } @@ -799,8 +802,8 @@ static void cycx_x25_irq_rx(struct cycx_device *card, struct cycx_x25_cmd *cmd) if ((skb = dev_alloc_skb((chan->protocol == ETH_P_X25 ? 1 : 0) + bufsize + dev->hard_header_len)) == NULL) { - pr_info("%s: no socket buffers available!\n", - card->devname); + printk(KERN_INFO "%s: no socket buffers available!\n", + card->devname); chan->drop_sequence = 1; ++chan->ifstats.rx_dropped; return; @@ -823,8 +826,8 @@ static void cycx_x25_irq_rx(struct cycx_device *card, struct cycx_x25_cmd *cmd) if (bitm) chan->drop_sequence = 1; - pr_info("%s: unexpectedly long packet sequence on interface %s!\n", - card->devname, dev->name); + printk(KERN_INFO "%s: unexpectedly long packet sequence " + "on interface %s!\n", card->devname, dev->name); ++chan->ifstats.rx_length_errors; return; } @@ -877,8 +880,8 @@ static void cycx_x25_irq_connect(struct cycx_device *card, dev = cycx_x25_get_dev_by_dte_addr(wandev, rem); if (!dev) { /* Invalid channel, discard packet */ - pr_info("%s: connect not expected: remote %s!\n", - card->devname, rem); + printk(KERN_INFO "%s: connect not expected: remote %s!\n", + card->devname, rem); return; } @@ -906,8 +909,8 @@ static void cycx_x25_irq_connect_confirm(struct cycx_device *card, if (!dev) { /* Invalid channel, discard packet */ clear_bit(--key, (void*)&card->u.x.connection_keys); - pr_info("%s: connect confirm not expected: lcn %d, key=%d!\n", - card->devname, lcn, key); + printk(KERN_INFO "%s: connect confirm not expected: lcn %d, " + "key=%d!\n", card->devname, lcn, key); return; } @@ -931,8 +934,8 @@ static void cycx_x25_irq_disconnect_confirm(struct cycx_device *card, dev = cycx_x25_get_dev_by_lcn(wandev, lcn); if (!dev) { /* Invalid channel, discard packet */ - pr_info("%s:disconnect confirm not expected!:lcn %d\n", - card->devname, lcn); + printk(KERN_INFO "%s:disconnect confirm not expected!:lcn %d\n", + card->devname, lcn); return; } @@ -977,13 +980,13 @@ static void cycx_x25_irq_log(struct cycx_device *card, struct cycx_x25_cmd *cmd) cycx_peek(&card->hw, cmd->buf + 10 + toread, &code, 1); cycx_peek(&card->hw, cmd->buf + 10 + toread + 1, &routine, 1); - pr_info("cycx_x25_irq_handler: X25_LOG (0x4500) indic.:\n"); - pr_info("cmd->buf=0x%X\n", cmd->buf); - pr_info("Log message code=0x%X\n", msg_code); - pr_info("Link=%d\n", link); - pr_info("log code=0x%X\n", code); - pr_info("log routine=0x%X\n", routine); - pr_info("Message size=%d\n", size); + printk(KERN_INFO "cycx_x25_irq_handler: X25_LOG (0x4500) indic.:\n"); + printk(KERN_INFO "cmd->buf=0x%X\n", cmd->buf); + printk(KERN_INFO "Log message code=0x%X\n", msg_code); + printk(KERN_INFO "Link=%d\n", link); + printk(KERN_INFO "log code=0x%X\n", code); + printk(KERN_INFO "log routine=0x%X\n", routine); + printk(KERN_INFO "Message size=%d\n", size); hex_dump("Message", bf, toread); #endif } @@ -1006,14 +1009,24 @@ static void cycx_x25_irq_stat(struct cycx_device *card, static void cycx_x25_irq_spurious(struct cycx_device *card, struct cycx_x25_cmd *cmd) { - pr_info("%s: spurious interrupt (0x%X)!\n", - card->devname, cmd->command); + printk(KERN_INFO "%s: spurious interrupt (0x%X)!\n", + card->devname, cmd->command); } #ifdef CYCLOMX_X25_DEBUG static void hex_dump(char *msg, unsigned char *p, int len) { - print_hex_dump(KERN_INFO, msg, DUMP_PREFIX_OFFSET, 16, 1, - p, len, true); + unsigned char hex[1024], + * phex = hex; + + if (len >= (sizeof(hex) / 2)) + len = (sizeof(hex) / 2) - 1; + + while (len--) { + sprintf(phex, "%02x", *p++); + phex += 2; + } + + printk(KERN_INFO "%s: %s\n", msg, hex); } #endif @@ -1190,8 +1203,8 @@ static int x25_place_call(struct cycx_device *card, u8 key; if (card->u.x.connection_keys == ~0U) { - pr_info("%s: too many simultaneous connection requests!\n", - card->devname); + printk(KERN_INFO "%s: too many simultaneous connection " + "requests!\n", card->devname); return -EAGAIN; } @@ -1368,8 +1381,8 @@ static void cycx_x25_chan_timer(unsigned long d) if (chan->state == WAN_CONNECTED) cycx_x25_chan_disconnect(dev); else - pr_err("%s: %s for svc (%s) not connected!\n", - chan->card->devname, __func__, dev->name); + printk(KERN_ERR "%s: %s for svc (%s) not connected!\n", + chan->card->devname, __func__, dev->name); } /* Set logical channel state. */ @@ -1420,8 +1433,8 @@ static void cycx_x25_set_chan_state(struct net_device *dev, u8 state) break; } - pr_info("%s: interface %s %s\n", - card->devname, dev->name, string_state); + printk(KERN_INFO "%s: interface %s %s\n", card->devname, + dev->name, string_state); chan->state = state; } @@ -1475,7 +1488,7 @@ static void cycx_x25_chan_send_event(struct net_device *dev, u8 event) unsigned char *ptr; if ((skb = dev_alloc_skb(1)) == NULL) { - pr_err("%s: out of memory\n", __func__); + printk(KERN_ERR "%s: out of memory\n", __func__); return; } @@ -1544,56 +1557,56 @@ static void reset_timer(struct net_device *dev) #ifdef CYCLOMX_X25_DEBUG static void cycx_x25_dump_config(struct cycx_x25_config *conf) { - pr_info("X.25 configuration\n"); - pr_info("-----------------\n"); - pr_info("link number=%d\n", conf->link); - pr_info("line speed=%d\n", conf->speed); - pr_info("clock=%sternal\n", conf->clock == 8 ? "Ex" : "In"); - pr_info("# level 2 retransm.=%d\n", conf->n2); - pr_info("level 2 window=%d\n", conf->n2win); - pr_info("level 3 window=%d\n", conf->n3win); - pr_info("# logical channels=%d\n", conf->nvc); - pr_info("level 3 pkt len=%d\n", conf->pktlen); - pr_info("my address=%d\n", conf->locaddr); - pr_info("remote address=%d\n", conf->remaddr); - pr_info("t1=%d seconds\n", conf->t1); - pr_info("t2=%d seconds\n", conf->t2); - pr_info("t21=%d seconds\n", conf->t21); - pr_info("# PVCs=%d\n", conf->npvc); - pr_info("t23=%d seconds\n", conf->t23); - pr_info("flags=0x%x\n", conf->flags); + printk(KERN_INFO "X.25 configuration\n"); + printk(KERN_INFO "-----------------\n"); + printk(KERN_INFO "link number=%d\n", conf->link); + printk(KERN_INFO "line speed=%d\n", conf->speed); + printk(KERN_INFO "clock=%sternal\n", conf->clock == 8 ? "Ex" : "In"); + printk(KERN_INFO "# level 2 retransm.=%d\n", conf->n2); + printk(KERN_INFO "level 2 window=%d\n", conf->n2win); + printk(KERN_INFO "level 3 window=%d\n", conf->n3win); + printk(KERN_INFO "# logical channels=%d\n", conf->nvc); + printk(KERN_INFO "level 3 pkt len=%d\n", conf->pktlen); + printk(KERN_INFO "my address=%d\n", conf->locaddr); + printk(KERN_INFO "remote address=%d\n", conf->remaddr); + printk(KERN_INFO "t1=%d seconds\n", conf->t1); + printk(KERN_INFO "t2=%d seconds\n", conf->t2); + printk(KERN_INFO "t21=%d seconds\n", conf->t21); + printk(KERN_INFO "# PVCs=%d\n", conf->npvc); + printk(KERN_INFO "t23=%d seconds\n", conf->t23); + printk(KERN_INFO "flags=0x%x\n", conf->flags); } static void cycx_x25_dump_stats(struct cycx_x25_stats *stats) { - pr_info("X.25 statistics\n"); - pr_info("--------------\n"); - pr_info("rx_crc_errors=%d\n", stats->rx_crc_errors); - pr_info("rx_over_errors=%d\n", stats->rx_over_errors); - pr_info("n2_tx_frames=%d\n", stats->n2_tx_frames); - pr_info("n2_rx_frames=%d\n", stats->n2_rx_frames); - pr_info("tx_timeouts=%d\n", stats->tx_timeouts); - pr_info("rx_timeouts=%d\n", stats->rx_timeouts); - pr_info("n3_tx_packets=%d\n", stats->n3_tx_packets); - pr_info("n3_rx_packets=%d\n", stats->n3_rx_packets); - pr_info("tx_aborts=%d\n", stats->tx_aborts); - pr_info("rx_aborts=%d\n", stats->rx_aborts); + printk(KERN_INFO "X.25 statistics\n"); + printk(KERN_INFO "--------------\n"); + printk(KERN_INFO "rx_crc_errors=%d\n", stats->rx_crc_errors); + printk(KERN_INFO "rx_over_errors=%d\n", stats->rx_over_errors); + printk(KERN_INFO "n2_tx_frames=%d\n", stats->n2_tx_frames); + printk(KERN_INFO "n2_rx_frames=%d\n", stats->n2_rx_frames); + printk(KERN_INFO "tx_timeouts=%d\n", stats->tx_timeouts); + printk(KERN_INFO "rx_timeouts=%d\n", stats->rx_timeouts); + printk(KERN_INFO "n3_tx_packets=%d\n", stats->n3_tx_packets); + printk(KERN_INFO "n3_rx_packets=%d\n", stats->n3_rx_packets); + printk(KERN_INFO "tx_aborts=%d\n", stats->tx_aborts); + printk(KERN_INFO "rx_aborts=%d\n", stats->rx_aborts); } static void cycx_x25_dump_devs(struct wan_device *wandev) { struct net_device *dev = wandev->dev; - pr_info("X.25 dev states\n"); - pr_info("name: addr: txoff: protocol:\n"); - pr_info("---------------------------------------\n"); + printk(KERN_INFO "X.25 dev states\n"); + printk(KERN_INFO "name: addr: txoff: protocol:\n"); + printk(KERN_INFO "---------------------------------------\n"); while(dev) { struct cycx_x25_channel *chan = netdev_priv(dev); - pr_info("%-5.5s %-15.15s %d ETH_P_%s\n", - chan->name, chan->addr, netif_queue_stopped(dev), - chan->protocol == ETH_P_IP ? "IP" : "X25"); + printk(KERN_INFO "%-5.5s %-15.15s %d ETH_P_%s\n", + chan->name, chan->addr, netif_queue_stopped(dev), + chan->protocol == ETH_P_IP ? "IP" : "X25"); dev = chan->slave; } } diff --git a/trunk/drivers/net/wan/dlci.c b/trunk/drivers/net/wan/dlci.c index 48ab38a34c5a..21b104db5a90 100644 --- a/trunk/drivers/net/wan/dlci.c +++ b/trunk/drivers/net/wan/dlci.c @@ -28,8 +28,6 @@ * 2 of the License, or (at your option) any later version. */ -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - #include #include #include @@ -114,7 +112,8 @@ static void dlci_receive(struct sk_buff *skb, struct net_device *dev) dlp = netdev_priv(dev); if (!pskb_may_pull(skb, sizeof(*hdr))) { - netdev_notice(dev, "invalid data no header\n"); + printk(KERN_NOTICE "%s: invalid data no header\n", + dev->name); dev->stats.rx_errors++; kfree_skb(skb); return; @@ -127,8 +126,7 @@ static void dlci_receive(struct sk_buff *skb, struct net_device *dev) if (hdr->control != FRAD_I_UI) { - netdev_notice(dev, "Invalid header flag 0x%02X\n", - hdr->control); + printk(KERN_NOTICE "%s: Invalid header flag 0x%02X.\n", dev->name, hdr->control); dev->stats.rx_errors++; } else @@ -137,18 +135,14 @@ static void dlci_receive(struct sk_buff *skb, struct net_device *dev) case FRAD_P_PADDING: if (hdr->NLPID != FRAD_P_SNAP) { - netdev_notice(dev, "Unsupported NLPID 0x%02X\n", - hdr->NLPID); + printk(KERN_NOTICE "%s: Unsupported NLPID 0x%02X.\n", dev->name, hdr->NLPID); dev->stats.rx_errors++; break; } if (hdr->OUI[0] + hdr->OUI[1] + hdr->OUI[2] != 0) { - netdev_notice(dev, "Unsupported organizationally unique identifier 0x%02X-%02X-%02X\n", - hdr->OUI[0], - hdr->OUI[1], - hdr->OUI[2]); + printk(KERN_NOTICE "%s: Unsupported organizationally unique identifier 0x%02X-%02X-%02X.\n", dev->name, hdr->OUI[0], hdr->OUI[1], hdr->OUI[2]); dev->stats.rx_errors++; break; } @@ -169,14 +163,12 @@ static void dlci_receive(struct sk_buff *skb, struct net_device *dev) case FRAD_P_SNAP: case FRAD_P_Q933: case FRAD_P_CLNP: - netdev_notice(dev, "Unsupported NLPID 0x%02X\n", - hdr->pad); + printk(KERN_NOTICE "%s: Unsupported NLPID 0x%02X.\n", dev->name, hdr->pad); dev->stats.rx_errors++; break; default: - netdev_notice(dev, "Invalid pad byte 0x%02X\n", - hdr->pad); + printk(KERN_NOTICE "%s: Invalid pad byte 0x%02X.\n", dev->name, hdr->pad); dev->stats.rx_errors++; break; } diff --git a/trunk/drivers/net/wan/dscc4.c b/trunk/drivers/net/wan/dscc4.c index 058e1697c174..3590d588327c 100644 --- a/trunk/drivers/net/wan/dscc4.c +++ b/trunk/drivers/net/wan/dscc4.c @@ -80,8 +80,6 @@ * - misc crapectomy. */ -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - #include #include #include @@ -555,7 +553,7 @@ static int dscc4_wait_ack_cec(struct dscc4_dev_priv *dpriv, schedule_timeout_uninterruptible(10); rmb(); } while (++i > 0); - netdev_err(dev, "%s timeout\n", msg); + printk(KERN_ERR "%s: %s timeout\n", dev->name, msg); done: return (i >= 0) ? i : -EAGAIN; } @@ -571,18 +569,18 @@ static int dscc4_do_action(struct net_device *dev, char *msg) u32 state = readl(ioaddr); if (state & ArAck) { - netdev_dbg(dev, "%s ack\n", msg); + printk(KERN_DEBUG "%s: %s ack\n", dev->name, msg); writel(ArAck, ioaddr); goto done; } else if (state & Arf) { - netdev_err(dev, "%s failed\n", msg); + printk(KERN_ERR "%s: %s failed\n", dev->name, msg); writel(Arf, ioaddr); i = -1; goto done; } rmb(); } while (++i > 0); - netdev_err(dev, "%s timeout\n", msg); + printk(KERN_ERR "%s: %s timeout\n", dev->name, msg); done: return i; } @@ -638,7 +636,7 @@ static void dscc4_tx_reset(struct dscc4_dev_priv *dpriv, struct net_device *dev) writel(MTFi|Rdt, dpriv->base_addr + dpriv->dev_id*0x0c + CH0CFG); if (dscc4_do_action(dev, "Rdt") < 0) - netdev_err(dev, "Tx reset failed\n"); + printk(KERN_ERR "%s: Tx reset failed\n", dev->name); } #endif @@ -724,20 +722,22 @@ static int __devinit dscc4_init_one(struct pci_dev *pdev, rc = pci_request_region(pdev, 0, "registers"); if (rc < 0) { - pr_err("can't reserve MMIO region (regs)\n"); + printk(KERN_ERR "%s: can't reserve MMIO region (regs)\n", + DRV_NAME); goto err_disable_0; } rc = pci_request_region(pdev, 1, "LBI interface"); if (rc < 0) { - pr_err("can't reserve MMIO region (lbi)\n"); + printk(KERN_ERR "%s: can't reserve MMIO region (lbi)\n", + DRV_NAME); goto err_free_mmio_region_1; } ioaddr = pci_ioremap_bar(pdev, 0); if (!ioaddr) { - pr_err("cannot remap MMIO region %llx @ %llx\n", - (unsigned long long)pci_resource_len(pdev, 0), - (unsigned long long)pci_resource_start(pdev, 0)); + printk(KERN_ERR "%s: cannot remap MMIO region %llx @ %llx\n", + DRV_NAME, (unsigned long long)pci_resource_len(pdev, 0), + (unsigned long long)pci_resource_start(pdev, 0)); rc = -EIO; goto err_free_mmio_regions_2; } @@ -757,7 +757,7 @@ static int __devinit dscc4_init_one(struct pci_dev *pdev, rc = request_irq(pdev->irq, dscc4_irq, IRQF_SHARED, DRV_NAME, priv->root); if (rc < 0) { - pr_warn("IRQ %d busy\n", pdev->irq); + printk(KERN_WARNING "%s: IRQ %d busy\n", DRV_NAME, pdev->irq); goto err_release_4; } @@ -904,7 +904,7 @@ static int dscc4_found1(struct pci_dev *pdev, void __iomem *ioaddr) root = kcalloc(dev_per_card, sizeof(*root), GFP_KERNEL); if (!root) { - pr_err("can't allocate data\n"); + printk(KERN_ERR "%s: can't allocate data\n", DRV_NAME); goto err_out; } @@ -916,7 +916,7 @@ static int dscc4_found1(struct pci_dev *pdev, void __iomem *ioaddr) ppriv = kzalloc(sizeof(*ppriv), GFP_KERNEL); if (!ppriv) { - pr_err("can't allocate private data\n"); + printk(KERN_ERR "%s: can't allocate private data\n", DRV_NAME); goto err_free_dev; } @@ -952,7 +952,7 @@ static int dscc4_found1(struct pci_dev *pdev, void __iomem *ioaddr) ret = register_hdlc_device(d); if (ret < 0) { - pr_err("unable to register\n"); + printk(KERN_ERR "%s: unable to register\n", DRV_NAME); dscc4_release_ring(dpriv); goto err_unregister; } @@ -1005,7 +1005,7 @@ static int dscc4_loopback_check(struct dscc4_dev_priv *dpriv) if (settings->loopback && (settings->clock_type != CLOCK_INT)) { struct net_device *dev = dscc4_to_dev(dpriv); - netdev_info(dev, "loopback requires clock\n"); + printk(KERN_INFO "%s: loopback requires clock\n", dev->name); return -1; } return 0; @@ -1078,7 +1078,7 @@ static int dscc4_open(struct net_device *dev) scc_patchl(0, PowerUp, dpriv, dev, CCR0); scc_patchl(0, 0x00050000, dpriv, dev, CCR2); scc_writel(EventsMask, dpriv, dev, IMR); - netdev_info(dev, "up again\n"); + printk(KERN_INFO "%s: up again.\n", dev->name); goto done; } @@ -1095,11 +1095,11 @@ static int dscc4_open(struct net_device *dev) * situations. */ if (scc_readl_star(dpriv, dev) & SccBusy) { - netdev_err(dev, "busy - try later\n"); + printk(KERN_ERR "%s busy. Try later\n", dev->name); ret = -EAGAIN; goto err_out; } else - netdev_info(dev, "available - good\n"); + printk(KERN_INFO "%s: available. Good\n", dev->name); scc_writel(EventsMask, dpriv, dev, IMR); @@ -1117,7 +1117,7 @@ static int dscc4_open(struct net_device *dev) * reset is needed. Suggestions anyone ? */ if ((ret = dscc4_xpr_ack(dpriv)) < 0) { - pr_err("XPR timeout\n"); + printk(KERN_ERR "%s: %s timeout\n", DRV_NAME, "XPR"); goto err_disable_scc_events; } @@ -1342,7 +1342,8 @@ static int dscc4_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) return -EPERM; if (dpriv->flags & FakeReset) { - netdev_info(dev, "please reset the device before this command\n"); + printk(KERN_INFO "%s: please reset the device" + " before this command\n", dev->name); return -EPERM; } if (copy_from_user(&dpriv->settings, line, size)) @@ -1505,7 +1506,8 @@ static irqreturn_t dscc4_irq(int irq, void *token) writel(state, ioaddr + GSTAR); if (state & Arf) { - netdev_err(dev, "failure (Arf). Harass the maintainer\n"); + printk(KERN_ERR "%s: failure (Arf). Harass the maintener\n", + dev->name); goto out; } state &= ~ArAck; @@ -1513,7 +1515,7 @@ static irqreturn_t dscc4_irq(int irq, void *token) if (debug > 0) printk(KERN_DEBUG "%s: CfgIV\n", DRV_NAME); if (priv->iqcfg[priv->cfg_cur++%IRQ_RING_SIZE] & cpu_to_le32(Arf)) - netdev_err(dev, "CFG failed\n"); + printk(KERN_ERR "%s: %s failed\n", dev->name, "CFG"); if (!(state &= ~Cfg)) goto out; } @@ -1594,8 +1596,8 @@ static void dscc4_tx_irq(struct dscc4_pci_priv *ppriv, ++dpriv->tx_dirty; } else { if (debug > 1) - netdev_err(dev, "Tx: NULL skb %d\n", - cur); + printk(KERN_ERR "%s Tx: NULL skb %d\n", + dev->name, cur); } /* * If the driver ends sending crap on the wire, it @@ -1614,7 +1616,7 @@ static void dscc4_tx_irq(struct dscc4_pci_priv *ppriv, * Transmit Data Underrun */ if (state & Xdu) { - netdev_err(dev, "Tx Data Underrun. Ask maintainer\n"); + printk(KERN_ERR "%s: XDU. Ask maintainer\n", DRV_NAME); dpriv->flags = NeedIDT; /* Tx reset */ writel(MTFi | Rdt, @@ -1623,13 +1625,13 @@ static void dscc4_tx_irq(struct dscc4_pci_priv *ppriv, return; } if (state & Cts) { - netdev_info(dev, "CTS transition\n"); + printk(KERN_INFO "%s: CTS transition\n", dev->name); if (!(state &= ~Cts)) /* DEBUG */ goto try; } if (state & Xmr) { /* Frame needs to be sent again - FIXME */ - netdev_err(dev, "Tx ReTx. Ask maintainer\n"); + printk(KERN_ERR "%s: Xmr. Ask maintainer\n", DRV_NAME); if (!(state &= ~Xmr)) /* DEBUG */ goto try; } @@ -1647,7 +1649,7 @@ static void dscc4_tx_irq(struct dscc4_pci_priv *ppriv, break; } if (!i) - netdev_info(dev, "busy in irq\n"); + printk(KERN_INFO "%s busy in irq\n", dev->name); scc_addr = dpriv->base_addr + 0x0c*dpriv->dev_id; /* Keep this order: IDT before IDR */ @@ -1684,7 +1686,7 @@ static void dscc4_tx_irq(struct dscc4_pci_priv *ppriv, } if (state & Cd) { if (debug > 0) - netdev_info(dev, "CD transition\n"); + printk(KERN_INFO "%s: CD transition\n", dev->name); if (!(state &= ~Cd)) /* DEBUG */ goto try; } @@ -1693,11 +1695,11 @@ static void dscc4_tx_irq(struct dscc4_pci_priv *ppriv, #ifdef DSCC4_POLLING while (!dscc4_tx_poll(dpriv, dev)); #endif - netdev_info(dev, "Tx Hi\n"); + printk(KERN_INFO "%s: Tx Hi\n", dev->name); state &= ~Hi; } if (state & Err) { - netdev_info(dev, "Tx ERR\n"); + printk(KERN_INFO "%s: Tx ERR\n", dev->name); dev->stats.tx_errors++; state &= ~Err; } @@ -1767,7 +1769,7 @@ static void dscc4_rx_irq(struct dscc4_pci_priv *priv, goto try; } if (state & Hi ) { /* HI bit */ - netdev_info(dev, "Rx Hi\n"); + printk(KERN_INFO "%s: Rx Hi\n", dev->name); state &= ~Hi; goto try; } @@ -1798,7 +1800,7 @@ static void dscc4_rx_irq(struct dscc4_pci_priv *priv, goto try; } if (state & Cts) { - netdev_info(dev, "CTS transition\n"); + printk(KERN_INFO "%s: CTS transition\n", dev->name); if (!(state &= ~Cts)) /* DEBUG */ goto try; } @@ -1857,12 +1859,14 @@ static void dscc4_rx_irq(struct dscc4_pci_priv *priv, sizeof(struct RxFD), scc_addr + CH0BRDA); writel(MTFi|Rdr|Idr, scc_addr + CH0CFG); if (dscc4_do_action(dev, "RDR") < 0) { - netdev_err(dev, "RDO recovery failed(RDR)\n"); + printk(KERN_ERR "%s: RDO recovery failed(%s)\n", + dev->name, "RDR"); goto rdo_end; } writel(MTFi|Idr, scc_addr + CH0CFG); if (dscc4_do_action(dev, "IDR") < 0) { - netdev_err(dev, "RDO recovery failed(IDR)\n"); + printk(KERN_ERR "%s: RDO recovery failed(%s)\n", + dev->name, "IDR"); goto rdo_end; } rdo_end: @@ -1871,7 +1875,7 @@ static void dscc4_rx_irq(struct dscc4_pci_priv *priv, goto try; } if (state & Cd) { - netdev_info(dev, "CD transition\n"); + printk(KERN_INFO "%s: CD transition\n", dev->name); if (!(state &= ~Cd)) /* DEBUG */ goto try; } diff --git a/trunk/drivers/net/wan/farsync.c b/trunk/drivers/net/wan/farsync.c index ebb9f24eefb5..0f27f4c5bb73 100644 --- a/trunk/drivers/net/wan/farsync.c +++ b/trunk/drivers/net/wan/farsync.c @@ -1665,9 +1665,10 @@ check_started_ok(struct fst_card_info *card) * existing firmware etc so we just report it for the moment. */ if (FST_RDL(card, numberOfPorts) != card->nports) { - pr_warn("Port count mismatch on card %d. Firmware thinks %d we say %d\n", - card->card_no, - FST_RDL(card, numberOfPorts), card->nports); + pr_warning("Port count mismatch on card %d. " + "Firmware thinks %d we say %d\n", + card->card_no, + FST_RDL(card, numberOfPorts), card->nports); } } diff --git a/trunk/drivers/net/wan/hd64570.c b/trunk/drivers/net/wan/hd64570.c index 33b67d88fceb..a3ea27ce04f2 100644 --- a/trunk/drivers/net/wan/hd64570.c +++ b/trunk/drivers/net/wan/hd64570.c @@ -582,8 +582,8 @@ static void sca_dump_rings(struct net_device *dev) sca_in(DSR_RX(phy_node(port)), card), port->rxin, sca_in(DSR_RX(phy_node(port)), card) & DSR_DE ? "" : "in"); for (cnt = 0; cnt < port_to_card(port)->rx_ring_buffers; cnt++) - pr_cont(" %02X", readb(&(desc_address(port, cnt, 0)->stat))); - pr_cont("\n"); + printk(" %02X", readb(&(desc_address(port, cnt, 0)->stat))); + printk(KERN_CONT "\n"); printk(KERN_DEBUG "TX ring: CDA=%u EDA=%u DSR=%02X in=%u " "last=%u %sactive", @@ -593,8 +593,8 @@ static void sca_dump_rings(struct net_device *dev) sca_in(DSR_TX(phy_node(port)), card) & DSR_DE ? "" : "in"); for (cnt = 0; cnt < port_to_card(port)->tx_ring_buffers; cnt++) - pr_cont(" %02X", readb(&(desc_address(port, cnt, 1)->stat))); - pr_cont("\n"); + printk(" %02X", readb(&(desc_address(port, cnt, 1)->stat))); + printk("\n"); printk(KERN_DEBUG "MSCI: MD: %02x %02x %02x, ST: %02x %02x %02x %02x," " FST: %02x CST: %02x %02x\n", diff --git a/trunk/drivers/net/wan/hd64572.c b/trunk/drivers/net/wan/hd64572.c index efc0db101183..e305274f83fb 100644 --- a/trunk/drivers/net/wan/hd64572.c +++ b/trunk/drivers/net/wan/hd64572.c @@ -530,8 +530,8 @@ static void sca_dump_rings(struct net_device *dev) sca_in(DSR_RX(port->chan), card), port->rxin, sca_in(DSR_RX(port->chan), card) & DSR_DE ? "" : "in"); for (cnt = 0; cnt < port->card->rx_ring_buffers; cnt++) - pr_cont(" %02X", readb(&(desc_address(port, cnt, 0)->stat))); - pr_cont("\n"); + printk(" %02X", readb(&(desc_address(port, cnt, 0)->stat))); + printk(KERN_CONT "\n"); printk(KERN_DEBUG "TX ring: CDA=%u EDA=%u DSR=%02X in=%u " "last=%u %sactive", @@ -541,8 +541,8 @@ static void sca_dump_rings(struct net_device *dev) sca_in(DSR_TX(port->chan), card) & DSR_DE ? "" : "in"); for (cnt = 0; cnt < port->card->tx_ring_buffers; cnt++) - pr_cont(" %02X", readb(&(desc_address(port, cnt, 1)->stat))); - pr_cont("\n"); + printk(" %02X", readb(&(desc_address(port, cnt, 1)->stat))); + printk("\n"); printk(KERN_DEBUG "MSCI: MD: %02x %02x %02x," " ST: %02x %02x %02x %02x %02x, FST: %02x CST: %02x %02x\n", diff --git a/trunk/drivers/net/wan/hdlc.c b/trunk/drivers/net/wan/hdlc.c index 10cc7df95498..5d4bb615ccce 100644 --- a/trunk/drivers/net/wan/hdlc.c +++ b/trunk/drivers/net/wan/hdlc.c @@ -22,8 +22,6 @@ * - proto->start() and stop() are called with spin_lock_irq held. */ -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - #include #include #include @@ -132,10 +130,10 @@ static int hdlc_device_event(struct notifier_block *this, unsigned long event, goto carrier_exit; if (hdlc->carrier) { - netdev_info(dev, "Carrier detected\n"); + printk(KERN_INFO "%s: Carrier detected\n", dev->name); hdlc_proto_start(dev); } else { - netdev_info(dev, "Carrier lost\n"); + printk(KERN_INFO "%s: Carrier lost\n", dev->name); hdlc_proto_stop(dev); } @@ -167,10 +165,10 @@ int hdlc_open(struct net_device *dev) spin_lock_irq(&hdlc->state_lock); if (hdlc->carrier) { - netdev_info(dev, "Carrier detected\n"); + printk(KERN_INFO "%s: Carrier detected\n", dev->name); hdlc_proto_start(dev); } else - netdev_info(dev, "No carrier\n"); + printk(KERN_INFO "%s: No carrier\n", dev->name); hdlc->open = 1; @@ -283,8 +281,8 @@ int attach_hdlc_protocol(struct net_device *dev, struct hdlc_proto *proto, if (size) if ((dev_to_hdlc(dev)->state = kmalloc(size, GFP_KERNEL)) == NULL) { - netdev_warn(dev, - "Memory squeeze on hdlc_proto_attach()\n"); + printk(KERN_WARNING "Memory squeeze on" + " hdlc_proto_attach()\n"); module_put(proto->module); return -ENOBUFS; } @@ -365,7 +363,7 @@ static int __init hdlc_module_init(void) { int result; - pr_info("%s\n", version); + printk(KERN_INFO "%s\n", version); if ((result = register_netdevice_notifier(&hdlc_notifier)) != 0) return result; dev_add_pack(&hdlc_packet_type); diff --git a/trunk/drivers/net/wan/hdlc_cisco.c b/trunk/drivers/net/wan/hdlc_cisco.c index 3f20808b5ff8..b1e5e5b69c2a 100644 --- a/trunk/drivers/net/wan/hdlc_cisco.c +++ b/trunk/drivers/net/wan/hdlc_cisco.c @@ -103,7 +103,9 @@ static void cisco_keepalive_send(struct net_device *dev, u32 type, skb = dev_alloc_skb(sizeof(struct hdlc_header) + sizeof(struct cisco_packet)); if (!skb) { - netdev_warn(dev, "Memory squeeze on cisco_keepalive_send()\n"); + printk(KERN_WARNING + "%s: Memory squeeze on cisco_keepalive_send()\n", + dev->name); return; } skb_reserve(skb, 4); @@ -179,8 +181,8 @@ static int cisco_rx(struct sk_buff *skb) CISCO_PACKET_LEN) && (skb->len != sizeof(struct hdlc_header) + CISCO_BIG_PACKET_LEN)) { - netdev_info(dev, "Invalid length of Cisco control packet (%d bytes)\n", - skb->len); + printk(KERN_INFO "%s: Invalid length of Cisco control" + " packet (%d bytes)\n", dev->name, skb->len); goto rx_error; } @@ -215,7 +217,8 @@ static int cisco_rx(struct sk_buff *skb) return NET_RX_SUCCESS; case CISCO_ADDR_REPLY: - netdev_info(dev, "Unexpected Cisco IP address reply\n"); + printk(KERN_INFO "%s: Unexpected Cisco IP address " + "reply\n", dev->name); goto rx_error; case CISCO_KEEPALIVE_REQ: @@ -232,8 +235,9 @@ static int cisco_rx(struct sk_buff *skb) min = sec / 60; sec -= min * 60; hrs = min / 60; min -= hrs * 60; days = hrs / 24; hrs -= days * 24; - netdev_info(dev, "Link up (peer uptime %ud%uh%um%us)\n", - days, hrs, min, sec); + printk(KERN_INFO "%s: Link up (peer " + "uptime %ud%uh%um%us)\n", + dev->name, days, hrs, min, sec); netif_dormant_off(dev); st->up = 1; } @@ -245,7 +249,8 @@ static int cisco_rx(struct sk_buff *skb) } /* switch (keepalive type) */ } /* switch (protocol) */ - netdev_info(dev, "Unsupported protocol %x\n", ntohs(data->protocol)); + printk(KERN_INFO "%s: Unsupported protocol %x\n", dev->name, + ntohs(data->protocol)); dev_kfree_skb_any(skb); return NET_RX_DROP; @@ -267,7 +272,7 @@ static void cisco_timer(unsigned long arg) if (st->up && time_after(jiffies, st->last_poll + st->settings.timeout * HZ)) { st->up = 0; - netdev_info(dev, "Link down\n"); + printk(KERN_INFO "%s: Link down\n", dev->name); netif_dormant_on(dev); } diff --git a/trunk/drivers/net/wan/hdlc_fr.c b/trunk/drivers/net/wan/hdlc_fr.c index b25c9229a6a9..fc433f28c047 100644 --- a/trunk/drivers/net/wan/hdlc_fr.c +++ b/trunk/drivers/net/wan/hdlc_fr.c @@ -446,14 +446,15 @@ static netdev_tx_t pvc_xmit(struct sk_buff *skb, struct net_device *dev) static inline void fr_log_dlci_active(pvc_device *pvc) { - netdev_info(pvc->frad, "DLCI %d [%s%s%s]%s %s\n", - pvc->dlci, - pvc->main ? pvc->main->name : "", - pvc->main && pvc->ether ? " " : "", - pvc->ether ? pvc->ether->name : "", - pvc->state.new ? " new" : "", - !pvc->state.exist ? "deleted" : - pvc->state.active ? "active" : "inactive"); + printk(KERN_INFO "%s: DLCI %d [%s%s%s]%s %s\n", + pvc->frad->name, + pvc->dlci, + pvc->main ? pvc->main->name : "", + pvc->main && pvc->ether ? " " : "", + pvc->ether ? pvc->ether->name : "", + pvc->state.new ? " new" : "", + !pvc->state.exist ? "deleted" : + pvc->state.active ? "active" : "inactive"); } @@ -480,14 +481,16 @@ static void fr_lmi_send(struct net_device *dev, int fullrep) if (dce && fullrep) { len += state(hdlc)->dce_pvc_count * (2 + stat_len); if (len > HDLC_MAX_MRU) { - netdev_warn(dev, "Too many PVCs while sending LMI full report\n"); + printk(KERN_WARNING "%s: Too many PVCs while sending " + "LMI full report\n", dev->name); return; } } skb = dev_alloc_skb(len); if (!skb) { - netdev_warn(dev, "Memory squeeze on fr_lmi_send()\n"); + printk(KERN_WARNING "%s: Memory squeeze on fr_lmi_send()\n", + dev->name); return; } memset(skb->data, 0, len); @@ -612,7 +615,8 @@ static void fr_timer(unsigned long arg) state(hdlc)->last_errors <<= 1; /* Shift the list */ if (state(hdlc)->request) { if (state(hdlc)->reliable) - netdev_info(dev, "No LMI status reply received\n"); + printk(KERN_INFO "%s: No LMI status reply " + "received\n", dev->name); state(hdlc)->last_errors |= 1; } @@ -624,7 +628,8 @@ static void fr_timer(unsigned long arg) } if (state(hdlc)->reliable != reliable) { - netdev_info(dev, "Link %sreliable\n", reliable ? "" : "un"); + printk(KERN_INFO "%s: Link %sreliable\n", dev->name, + reliable ? "" : "un"); fr_set_link_state(reliable, dev); } @@ -660,32 +665,33 @@ static int fr_lmi_recv(struct net_device *dev, struct sk_buff *skb) if (skb->len < (lmi == LMI_ANSI ? LMI_ANSI_LENGTH : LMI_CCITT_CISCO_LENGTH)) { - netdev_info(dev, "Short LMI frame\n"); + printk(KERN_INFO "%s: Short LMI frame\n", dev->name); return 1; } if (skb->data[3] != (lmi == LMI_CISCO ? NLPID_CISCO_LMI : NLPID_CCITT_ANSI_LMI)) { - netdev_info(dev, "Received non-LMI frame with LMI DLCI\n"); + printk(KERN_INFO "%s: Received non-LMI frame with LMI DLCI\n", + dev->name); return 1; } if (skb->data[4] != LMI_CALLREF) { - netdev_info(dev, "Invalid LMI Call reference (0x%02X)\n", - skb->data[4]); + printk(KERN_INFO "%s: Invalid LMI Call reference (0x%02X)\n", + dev->name, skb->data[4]); return 1; } if (skb->data[5] != (dce ? LMI_STATUS_ENQUIRY : LMI_STATUS)) { - netdev_info(dev, "Invalid LMI Message type (0x%02X)\n", - skb->data[5]); + printk(KERN_INFO "%s: Invalid LMI Message type (0x%02X)\n", + dev->name, skb->data[5]); return 1; } if (lmi == LMI_ANSI) { if (skb->data[6] != LMI_ANSI_LOCKSHIFT) { - netdev_info(dev, "Not ANSI locking shift in LMI message (0x%02X)\n", - skb->data[6]); + printk(KERN_INFO "%s: Not ANSI locking shift in LMI" + " message (0x%02X)\n", dev->name, skb->data[6]); return 1; } i = 7; @@ -694,34 +700,34 @@ static int fr_lmi_recv(struct net_device *dev, struct sk_buff *skb) if (skb->data[i] != (lmi == LMI_CCITT ? LMI_CCITT_REPTYPE : LMI_ANSI_CISCO_REPTYPE)) { - netdev_info(dev, "Not an LMI Report type IE (0x%02X)\n", - skb->data[i]); + printk(KERN_INFO "%s: Not an LMI Report type IE (0x%02X)\n", + dev->name, skb->data[i]); return 1; } if (skb->data[++i] != LMI_REPT_LEN) { - netdev_info(dev, "Invalid LMI Report type IE length (%u)\n", - skb->data[i]); + printk(KERN_INFO "%s: Invalid LMI Report type IE length" + " (%u)\n", dev->name, skb->data[i]); return 1; } reptype = skb->data[++i]; if (reptype != LMI_INTEGRITY && reptype != LMI_FULLREP) { - netdev_info(dev, "Unsupported LMI Report type (0x%02X)\n", - reptype); + printk(KERN_INFO "%s: Unsupported LMI Report type (0x%02X)\n", + dev->name, reptype); return 1; } if (skb->data[++i] != (lmi == LMI_CCITT ? LMI_CCITT_ALIVE : LMI_ANSI_CISCO_ALIVE)) { - netdev_info(dev, "Not an LMI Link integrity verification IE (0x%02X)\n", - skb->data[i]); + printk(KERN_INFO "%s: Not an LMI Link integrity verification" + " IE (0x%02X)\n", dev->name, skb->data[i]); return 1; } if (skb->data[++i] != LMI_INTEG_LEN) { - netdev_info(dev, "Invalid LMI Link integrity verification IE length (%u)\n", - skb->data[i]); + printk(KERN_INFO "%s: Invalid LMI Link integrity verification" + " IE length (%u)\n", dev->name, skb->data[i]); return 1; } i++; @@ -795,14 +801,14 @@ static int fr_lmi_recv(struct net_device *dev, struct sk_buff *skb) if (skb->data[i] != (lmi == LMI_CCITT ? LMI_CCITT_PVCSTAT : LMI_ANSI_CISCO_PVCSTAT)) { - netdev_info(dev, "Not an LMI PVC status IE (0x%02X)\n", - skb->data[i]); + printk(KERN_INFO "%s: Not an LMI PVC status IE" + " (0x%02X)\n", dev->name, skb->data[i]); return 1; } if (skb->data[++i] != stat_len) { - netdev_info(dev, "Invalid LMI PVC status IE length (%u)\n", - skb->data[i]); + printk(KERN_INFO "%s: Invalid LMI PVC status IE length" + " (%u)\n", dev->name, skb->data[i]); return 1; } i++; @@ -823,7 +829,9 @@ static int fr_lmi_recv(struct net_device *dev, struct sk_buff *skb) pvc = add_pvc(dev, dlci); if (!pvc && !no_ram) { - netdev_warn(dev, "Memory squeeze on fr_lmi_recv()\n"); + printk(KERN_WARNING + "%s: Memory squeeze on fr_lmi_recv()\n", + dev->name); no_ram = 1; } @@ -894,8 +902,8 @@ static int fr_rx(struct sk_buff *skb) pvc = find_pvc(hdlc, dlci); if (!pvc) { #ifdef DEBUG_PKT - netdev_info(frad, "No PVC for received frame's DLCI %d\n", - dlci); + printk(KERN_INFO "%s: No PVC for received frame's DLCI %d\n", + frad->name, dlci); #endif dev_kfree_skb_any(skb); return NET_RX_DROP; @@ -954,14 +962,14 @@ static int fr_rx(struct sk_buff *skb) break; default: - netdev_info(frad, "Unsupported protocol, OUI=%x PID=%x\n", - oui, pid); + printk(KERN_INFO "%s: Unsupported protocol, OUI=%x " + "PID=%x\n", frad->name, oui, pid); dev_kfree_skb_any(skb); return NET_RX_DROP; } } else { - netdev_info(frad, "Unsupported protocol, NLPID=%x length=%i\n", - data[3], skb->len); + printk(KERN_INFO "%s: Unsupported protocol, NLPID=%x " + "length = %i\n", frad->name, data[3], skb->len); dev_kfree_skb_any(skb); return NET_RX_DROP; } @@ -1065,7 +1073,8 @@ static int fr_add_pvc(struct net_device *frad, unsigned int dlci, int type) int used; if ((pvc = add_pvc(frad, dlci)) == NULL) { - netdev_warn(frad, "Memory squeeze on fr_add_pvc()\n"); + printk(KERN_WARNING "%s: Memory squeeze on fr_add_pvc()\n", + frad->name); return -ENOBUFS; } @@ -1080,7 +1089,8 @@ static int fr_add_pvc(struct net_device *frad, unsigned int dlci, int type) dev = alloc_netdev(0, "pvc%d", pvc_setup); if (!dev) { - netdev_warn(frad, "Memory squeeze on fr_pvc()\n"); + printk(KERN_WARNING "%s: Memory squeeze on fr_pvc()\n", + frad->name); delete_unused_pvcs(hdlc); return -ENOBUFS; } diff --git a/trunk/drivers/net/wan/hdlc_ppp.c b/trunk/drivers/net/wan/hdlc_ppp.c index 055a918067e6..941f053e650e 100644 --- a/trunk/drivers/net/wan/hdlc_ppp.c +++ b/trunk/drivers/net/wan/hdlc_ppp.c @@ -223,7 +223,8 @@ static void ppp_tx_cp(struct net_device *dev, u16 pid, u8 code, skb = dev_alloc_skb(sizeof(struct hdlc_header) + sizeof(struct cp_header) + magic_len + len); if (!skb) { - netdev_warn(dev, "out of memory in ppp_tx_cp()\n"); + printk(KERN_WARNING "%s: out of memory in ppp_tx_cp()\n", + dev->name); return; } skb_reserve(skb, sizeof(struct hdlc_header)); @@ -344,7 +345,7 @@ static void ppp_cp_event(struct net_device *dev, u16 pid, u16 event, u8 code, ppp_tx_cp(dev, pid, CP_CODE_REJ, ++ppp->seq, len, data); if (old_state != OPENED && proto->state == OPENED) { - netdev_info(dev, "%s up\n", proto_name(pid)); + printk(KERN_INFO "%s: %s up\n", dev->name, proto_name(pid)); if (pid == PID_LCP) { netif_dormant_off(dev); ppp_cp_event(dev, PID_IPCP, START, 0, 0, 0, NULL); @@ -355,7 +356,7 @@ static void ppp_cp_event(struct net_device *dev, u16 pid, u16 event, u8 code, } } if (old_state == OPENED && proto->state != OPENED) { - netdev_info(dev, "%s down\n", proto_name(pid)); + printk(KERN_INFO "%s: %s down\n", dev->name, proto_name(pid)); if (pid == PID_LCP) { netif_dormant_on(dev); ppp_cp_event(dev, PID_IPCP, STOP, 0, 0, 0, NULL); @@ -584,7 +585,7 @@ static void ppp_timer(unsigned long arg) break; if (time_after(jiffies, ppp->last_pong + ppp->keepalive_timeout * HZ)) { - netdev_info(proto->dev, "Link down\n"); + printk(KERN_INFO "%s: Link down\n", proto->dev->name); ppp_cp_event(proto->dev, PID_LCP, STOP, 0, 0, 0, NULL); ppp_cp_event(proto->dev, PID_LCP, START, 0, 0, 0, NULL); } else { /* send keep-alive packet */ diff --git a/trunk/drivers/net/wan/hdlc_x25.c b/trunk/drivers/net/wan/hdlc_x25.c index 56aeb011cb3d..70527e5a54a2 100644 --- a/trunk/drivers/net/wan/hdlc_x25.c +++ b/trunk/drivers/net/wan/hdlc_x25.c @@ -34,7 +34,7 @@ static void x25_connect_disconnect(struct net_device *dev, int reason, int code) unsigned char *ptr; if ((skb = dev_alloc_skb(1)) == NULL) { - netdev_err(dev, "out of memory\n"); + printk(KERN_ERR "%s: out of memory\n", dev->name); return; } @@ -106,8 +106,9 @@ static netdev_tx_t x25_xmit(struct sk_buff *skb, struct net_device *dev) /* Send connect confirm. msg to level 3 */ x25_connected(dev, 0); else - netdev_err(dev, "LAPB connect request failed, error code = %i\n", - result); + printk(KERN_ERR "%s: LAPB connect request " + "failed, error code = %i\n", + dev->name, result); } break; @@ -117,8 +118,9 @@ static netdev_tx_t x25_xmit(struct sk_buff *skb, struct net_device *dev) /* Send disconnect confirm. msg to level 3 */ x25_disconnected(dev, 0); else - netdev_err(dev, "LAPB disconnect request failed, error code = %i\n", - result); + printk(KERN_ERR "%s: LAPB disconnect request " + "failed, error code = %i\n", + dev->name, result); } break; diff --git a/trunk/drivers/net/wan/hostess_sv11.c b/trunk/drivers/net/wan/hostess_sv11.c index 3d80e4267de8..e817583e6ec5 100644 --- a/trunk/drivers/net/wan/hostess_sv11.c +++ b/trunk/drivers/net/wan/hostess_sv11.c @@ -20,8 +20,6 @@ * Generic HDLC port Copyright (C) 2008 Krzysztof Halasa */ -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - #include #include #include @@ -194,7 +192,8 @@ static struct z8530_dev *sv11_init(int iobase, int irq) */ if (!request_region(iobase, 8, "Comtrol SV11")) { - pr_warn("I/O 0x%X already in use\n", iobase); + printk(KERN_WARNING "hostess: I/O 0x%X already in use.\n", + iobase); return NULL; } @@ -222,7 +221,7 @@ static struct z8530_dev *sv11_init(int iobase, int irq) if (request_irq(irq, z8530_interrupt, IRQF_DISABLED, "Hostess SV11", sv) < 0) { - pr_warn("IRQ %d already in use\n", irq); + printk(KERN_WARNING "hostess: IRQ %d already in use.\n", irq); goto err_irq; } @@ -256,7 +255,7 @@ static struct z8530_dev *sv11_init(int iobase, int irq) */ if (z8530_init(sv)) { - pr_err("Z8530 series device not found\n"); + printk(KERN_ERR "Z8530 series device not found.\n"); enable_irq(irq); goto free_dma; } @@ -283,7 +282,7 @@ static struct z8530_dev *sv11_init(int iobase, int irq) netdev->irq = irq; if (register_hdlc_device(netdev)) { - pr_err("unable to register HDLC device\n"); + printk(KERN_ERR "hostess: unable to register HDLC device.\n"); free_netdev(netdev); goto free_dma; } diff --git a/trunk/drivers/net/wan/ixp4xx_hss.c b/trunk/drivers/net/wan/ixp4xx_hss.c index aaaca9aa2293..f1e1643dc3eb 100644 --- a/trunk/drivers/net/wan/ixp4xx_hss.c +++ b/trunk/drivers/net/wan/ixp4xx_hss.c @@ -8,8 +8,6 @@ * as published by the Free Software Foundation. */ -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - #include #include #include @@ -360,8 +358,9 @@ static void hss_npe_send(struct port *port, struct msg *msg, const char* what) { u32 *val = (u32*)msg; if (npe_send_message(port->npe, msg, what)) { - pr_crit("HSS-%i: unable to send command [%08X:%08X] to %s\n", - port->id, val[0], val[1], npe_name(port->npe)); + printk(KERN_CRIT "HSS-%i: unable to send command [%08X:%08X]" + " to %s\n", port->id, val[0], val[1], + npe_name(port->npe)); BUG(); } } @@ -448,7 +447,8 @@ static void hss_config(struct port *port) if (npe_recv_message(port->npe, &msg, "HSS_LOAD_CONFIG") || /* HSS_LOAD_CONFIG for port #1 returns port_id = #4 */ msg.cmd != PORT_CONFIG_LOAD || msg.data32) { - pr_crit("HSS-%i: HSS_LOAD_CONFIG failed\n", port->id); + printk(KERN_CRIT "HSS-%i: HSS_LOAD_CONFIG failed\n", + port->id); BUG(); } @@ -477,7 +477,8 @@ static u32 hss_get_status(struct port *port) msg.hss_port = port->id; hss_npe_send(port, &msg, "PORT_ERROR_READ"); if (npe_recv_message(port->npe, &msg, "PORT_ERROR_READ")) { - pr_crit("HSS-%i: unable to read HSS status\n", port->id); + printk(KERN_CRIT "HSS-%i: unable to read HSS status\n", + port->id); BUG(); } @@ -735,8 +736,9 @@ static int hss_hdlc_poll(struct napi_struct *napi, int budget) dev->stats.rx_errors++; break; default: /* FIXME - remove printk */ - netdev_err(dev, "hss_hdlc_poll: status 0x%02X errors %u\n", - desc->status, desc->error_count); + printk(KERN_ERR "%s: hss_hdlc_poll: status 0x%02X" + " errors %u\n", dev->name, desc->status, + desc->error_count); dev->stats.rx_errors++; } @@ -1125,8 +1127,8 @@ static int hss_hdlc_close(struct net_device *dev) buffs--; if (buffs) - netdev_crit(dev, "unable to drain RX queue, %i buffer(s) left in NPE\n", - buffs); + printk(KERN_CRIT "%s: unable to drain RX queue, %i buffer(s)" + " left in NPE\n", dev->name, buffs); buffs = TX_DESCS; while (queue_get_desc(queue_ids[port->id].tx, port, 1) >= 0) @@ -1141,8 +1143,8 @@ static int hss_hdlc_close(struct net_device *dev) } while (++i < MAX_CLOSE_WAIT); if (buffs) - netdev_crit(dev, "unable to drain TX queue, %i buffer(s) left in NPE\n", - buffs); + printk(KERN_CRIT "%s: unable to drain TX queue, %i buffer(s) " + "left in NPE\n", dev->name, buffs); #if DEBUG_CLOSE if (!buffs) printk(KERN_DEBUG "Draining TX queues took %i cycles\n", i); @@ -1362,7 +1364,7 @@ static int __devinit hss_init_one(struct platform_device *pdev) platform_set_drvdata(pdev, port); - netdev_info(dev, "HSS-%i\n", port->id); + printk(KERN_INFO "%s: HSS-%i\n", dev->name, port->id); return 0; err_free_netdev: diff --git a/trunk/drivers/net/wan/lapbether.c b/trunk/drivers/net/wan/lapbether.c index a817081737a0..eec463f99c09 100644 --- a/trunk/drivers/net/wan/lapbether.c +++ b/trunk/drivers/net/wan/lapbether.c @@ -20,8 +20,6 @@ * 2000-11-14 Henner Eisen dev_hold/put, NETDEV_GOING_DOWN support */ -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - #include #include #include @@ -167,11 +165,13 @@ static netdev_tx_t lapbeth_xmit(struct sk_buff *skb, break; case X25_IFACE_CONNECT: if ((err = lapb_connect_request(dev)) != LAPB_OK) - pr_err("lapb_connect_request error: %d\n", err); + printk(KERN_ERR "lapbeth: lapb_connect_request " + "error: %d\n", err); goto drop; case X25_IFACE_DISCONNECT: if ((err = lapb_disconnect_request(dev)) != LAPB_OK) - pr_err("lapb_disconnect_request err: %d\n", err); + printk(KERN_ERR "lapbeth: lapb_disconnect_request " + "err: %d\n", err); /* Fall thru */ default: goto drop; @@ -180,7 +180,7 @@ static netdev_tx_t lapbeth_xmit(struct sk_buff *skb, skb_pull(skb, 1); if ((err = lapb_data_request(dev, skb)) != LAPB_OK) { - pr_err("lapb_data_request error - %d\n", err); + printk(KERN_ERR "lapbeth: lapb_data_request error - %d\n", err); goto drop; } out: @@ -220,7 +220,7 @@ static void lapbeth_connected(struct net_device *dev, int reason) struct sk_buff *skb = dev_alloc_skb(1); if (!skb) { - pr_err("out of memory\n"); + printk(KERN_ERR "lapbeth: out of memory\n"); return; } @@ -237,7 +237,7 @@ static void lapbeth_disconnected(struct net_device *dev, int reason) struct sk_buff *skb = dev_alloc_skb(1); if (!skb) { - pr_err("out of memory\n"); + printk(KERN_ERR "lapbeth: out of memory\n"); return; } @@ -277,7 +277,7 @@ static int lapbeth_open(struct net_device *dev) int err; if ((err = lapb_register(dev, &lapbeth_callbacks)) != LAPB_OK) { - pr_err("lapb_register error: %d\n", err); + printk(KERN_ERR "lapbeth: lapb_register error - %d\n", err); return -ENODEV; } @@ -292,7 +292,7 @@ static int lapbeth_close(struct net_device *dev) netif_stop_queue(dev); if ((err = lapb_unregister(dev)) != LAPB_OK) - pr_err("lapb_unregister error: %d\n", err); + printk(KERN_ERR "lapbeth: lapb_unregister error - %d\n", err); return 0; } diff --git a/trunk/drivers/net/wan/n2.c b/trunk/drivers/net/wan/n2.c index 5129ad514d26..17d408fe693f 100644 --- a/trunk/drivers/net/wan/n2.c +++ b/trunk/drivers/net/wan/n2.c @@ -16,8 +16,6 @@ * SDL Inc. PPP/HDLC/CISCO driver */ -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - #include #include #include @@ -343,57 +341,57 @@ static int __init n2_run(unsigned long io, unsigned long irq, int i; if (io < 0x200 || io > 0x3FF || (io % N2_IOPORTS) != 0) { - pr_err("invalid I/O port value\n"); + printk(KERN_ERR "n2: invalid I/O port value\n"); return -ENODEV; } if (irq < 3 || irq > 15 || irq == 6) /* FIXME */ { - pr_err("invalid IRQ value\n"); + printk(KERN_ERR "n2: invalid IRQ value\n"); return -ENODEV; } if (winbase < 0xA0000 || winbase > 0xFFFFF || (winbase & 0xFFF) != 0) { - pr_err("invalid RAM value\n"); + printk(KERN_ERR "n2: invalid RAM value\n"); return -ENODEV; } card = kzalloc(sizeof(card_t), GFP_KERNEL); if (card == NULL) { - pr_err("unable to allocate memory\n"); + printk(KERN_ERR "n2: unable to allocate memory\n"); return -ENOBUFS; } card->ports[0].dev = alloc_hdlcdev(&card->ports[0]); card->ports[1].dev = alloc_hdlcdev(&card->ports[1]); if (!card->ports[0].dev || !card->ports[1].dev) { - pr_err("unable to allocate memory\n"); + printk(KERN_ERR "n2: unable to allocate memory\n"); n2_destroy_card(card); return -ENOMEM; } if (!request_region(io, N2_IOPORTS, devname)) { - pr_err("I/O port region in use\n"); + printk(KERN_ERR "n2: I/O port region in use\n"); n2_destroy_card(card); return -EBUSY; } card->io = io; if (request_irq(irq, sca_intr, 0, devname, card)) { - pr_err("could not allocate IRQ\n"); + printk(KERN_ERR "n2: could not allocate IRQ\n"); n2_destroy_card(card); return -EBUSY; } card->irq = irq; if (!request_mem_region(winbase, USE_WINDOWSIZE, devname)) { - pr_err("could not request RAM window\n"); + printk(KERN_ERR "n2: could not request RAM window\n"); n2_destroy_card(card); return -EBUSY; } card->phy_winbase = winbase; card->winbase = ioremap(winbase, USE_WINDOWSIZE); if (!card->winbase) { - pr_err("ioremap() failed\n"); + printk(KERN_ERR "n2: ioremap() failed\n"); n2_destroy_card(card); return -EFAULT; } @@ -415,7 +413,7 @@ static int __init n2_run(unsigned long io, unsigned long irq, break; default: - pr_err("invalid window size\n"); + printk(KERN_ERR "n2: invalid window size\n"); n2_destroy_card(card); return -ENODEV; } @@ -435,12 +433,12 @@ static int __init n2_run(unsigned long io, unsigned long irq, card->buff_offset = (valid0 + valid1) * sizeof(pkt_desc) * (card->tx_ring_buffers + card->rx_ring_buffers); - pr_info("RISCom/N2 %u KB RAM, IRQ%u, using %u TX + %u RX packets rings\n", - card->ram_size / 1024, card->irq, - card->tx_ring_buffers, card->rx_ring_buffers); + printk(KERN_INFO "n2: RISCom/N2 %u KB RAM, IRQ%u, " + "using %u TX + %u RX packets rings\n", card->ram_size / 1024, + card->irq, card->tx_ring_buffers, card->rx_ring_buffers); if (card->tx_ring_buffers < 1) { - pr_err("RAM test failed\n"); + printk(KERN_ERR "n2: RAM test failed\n"); n2_destroy_card(card); return -EIO; } @@ -476,14 +474,16 @@ static int __init n2_run(unsigned long io, unsigned long irq, port->card = card; if (register_hdlc_device(dev)) { - pr_warn("unable to register hdlc device\n"); + printk(KERN_WARNING "n2: unable to register hdlc " + "device\n"); port->card = NULL; n2_destroy_card(card); return -ENOBUFS; } sca_init_port(port); /* Set up SCA memory */ - netdev_info(dev, "RISCom/N2 node %d\n", port->phy_node); + printk(KERN_INFO "%s: RISCom/N2 node %d\n", + dev->name, port->phy_node); } *new_card = card; @@ -498,12 +498,12 @@ static int __init n2_init(void) { if (hw==NULL) { #ifdef MODULE - pr_info("no card initialized\n"); + printk(KERN_INFO "n2: no card initialized\n"); #endif return -EINVAL; /* no parameters specified, abort */ } - pr_info("%s\n", version); + printk(KERN_INFO "%s\n", version); do { unsigned long io, irq, ram; @@ -541,7 +541,7 @@ static int __init n2_init(void) return first_card ? 0 : -EINVAL; }while(*hw++ == ':'); - pr_err("invalid hardware parameters\n"); + printk(KERN_ERR "n2: invalid hardware parameters\n"); return first_card ? 0 : -EINVAL; } diff --git a/trunk/drivers/net/wan/pc300_drv.c b/trunk/drivers/net/wan/pc300_drv.c index 1eeedd6a10b1..9617d3d0ee39 100644 --- a/trunk/drivers/net/wan/pc300_drv.c +++ b/trunk/drivers/net/wan/pc300_drv.c @@ -212,8 +212,6 @@ static const char rcsid[] = * */ -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - #include #include #include @@ -3244,7 +3242,7 @@ static inline void show_version(void) rcsdate++; tmp = strrchr(rcsdate, ' '); *tmp = '\0'; - pr_info("Cyclades-PC300 driver %s %s\n", rcsvers, rcsdate); + printk(KERN_INFO "Cyclades-PC300 driver %s %s\n", rcsvers, rcsdate); } /* show_version */ static const struct net_device_ops cpc_netdev_ops = { diff --git a/trunk/drivers/net/wan/pc300too.c b/trunk/drivers/net/wan/pc300too.c index c49c1b3c7aad..c7ab3becd261 100644 --- a/trunk/drivers/net/wan/pc300too.c +++ b/trunk/drivers/net/wan/pc300too.c @@ -17,8 +17,6 @@ * PC300/X21 cards. */ -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - #include #include #include @@ -320,7 +318,7 @@ static int __devinit pc300_pci_init_one(struct pci_dev *pdev, card = kzalloc(sizeof(card_t), GFP_KERNEL); if (card == NULL) { - pr_err("unable to allocate memory\n"); + printk(KERN_ERR "pc300: unable to allocate memory\n"); pci_release_regions(pdev); pci_disable_device(pdev); return -ENOBUFS; @@ -330,7 +328,7 @@ static int __devinit pc300_pci_init_one(struct pci_dev *pdev, if (pci_resource_len(pdev, 0) != PC300_PLX_SIZE || pci_resource_len(pdev, 2) != PC300_SCA_SIZE || pci_resource_len(pdev, 3) < 16384) { - pr_err("invalid card EEPROM parameters\n"); + printk(KERN_ERR "pc300: invalid card EEPROM parameters\n"); pc300_pci_remove_one(pdev); return -EFAULT; } @@ -347,7 +345,7 @@ static int __devinit pc300_pci_init_one(struct pci_dev *pdev, if (card->plxbase == NULL || card->scabase == NULL || card->rambase == NULL) { - pr_err("ioremap() failed\n"); + printk(KERN_ERR "pc300: ioremap() failed\n"); pc300_pci_remove_one(pdev); } @@ -372,7 +370,7 @@ static int __devinit pc300_pci_init_one(struct pci_dev *pdev, for (i = 0; i < card->n_ports; i++) if (!(card->ports[i].netdev = alloc_hdlcdev(&card->ports[i]))) { - pr_err("unable to allocate memory\n"); + printk(KERN_ERR "pc300: unable to allocate memory\n"); pc300_pci_remove_one(pdev); return -ENOMEM; } @@ -413,14 +411,15 @@ static int __devinit pc300_pci_init_one(struct pci_dev *pdev, card->buff_offset = card->n_ports * sizeof(pkt_desc) * (card->tx_ring_buffers + card->rx_ring_buffers); - pr_info("PC300/%s, %u KB RAM at 0x%x, IRQ%u, using %u TX + %u RX packets rings\n", - card->type == PC300_X21 ? "X21" : - card->type == PC300_TE ? "TE" : "RSV", - ramsize / 1024, ramphys, pdev->irq, - card->tx_ring_buffers, card->rx_ring_buffers); + printk(KERN_INFO "pc300: PC300/%s, %u KB RAM at 0x%x, IRQ%u, " + "using %u TX + %u RX packets rings\n", + card->type == PC300_X21 ? "X21" : + card->type == PC300_TE ? "TE" : "RSV", + ramsize / 1024, ramphys, pdev->irq, + card->tx_ring_buffers, card->rx_ring_buffers); if (card->tx_ring_buffers < 1) { - pr_err("RAM test failed\n"); + printk(KERN_ERR "pc300: RAM test failed\n"); pc300_pci_remove_one(pdev); return -EFAULT; } @@ -430,7 +429,8 @@ static int __devinit pc300_pci_init_one(struct pci_dev *pdev, /* Allocate IRQ */ if (request_irq(pdev->irq, sca_intr, IRQF_SHARED, "pc300", card)) { - pr_warn("could not allocate IRQ%d\n", pdev->irq); + printk(KERN_WARNING "pc300: could not allocate IRQ%d.\n", + pdev->irq); pc300_pci_remove_one(pdev); return -EBUSY; } @@ -466,13 +466,15 @@ static int __devinit pc300_pci_init_one(struct pci_dev *pdev, sca_init_port(port); if (register_hdlc_device(dev)) { - pr_err("unable to register hdlc device\n"); + printk(KERN_ERR "pc300: unable to register hdlc " + "device\n"); port->card = NULL; pc300_pci_remove_one(pdev); return -ENOBUFS; } - netdev_info(dev, "PC300 channel %d\n", port->chan); + printk(KERN_INFO "%s: PC300 channel %d\n", + dev->name, port->chan); } return 0; } @@ -503,11 +505,11 @@ static struct pci_driver pc300_pci_driver = { static int __init pc300_init_module(void) { if (pci_clock_freq < 1000000 || pci_clock_freq > 80000000) { - pr_err("Invalid PCI clock frequency\n"); + printk(KERN_ERR "pc300: Invalid PCI clock frequency\n"); return -EINVAL; } if (use_crystal_clock != 0 && use_crystal_clock != 1) { - pr_err("Invalid 'use_crystal_clock' value\n"); + printk(KERN_ERR "pc300: Invalid 'use_crystal_clock' value\n"); return -EINVAL; } diff --git a/trunk/drivers/net/wan/pci200syn.c b/trunk/drivers/net/wan/pci200syn.c index 1ce21163c776..fd7375955e41 100644 --- a/trunk/drivers/net/wan/pci200syn.c +++ b/trunk/drivers/net/wan/pci200syn.c @@ -14,8 +14,6 @@ * PLX Technology Inc. PCI9052 Data Book */ -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - #include #include #include @@ -299,7 +297,7 @@ static int __devinit pci200_pci_init_one(struct pci_dev *pdev, card = kzalloc(sizeof(card_t), GFP_KERNEL); if (card == NULL) { - pr_err("unable to allocate memory\n"); + printk(KERN_ERR "pci200syn: unable to allocate memory\n"); pci_release_regions(pdev); pci_disable_device(pdev); return -ENOBUFS; @@ -308,7 +306,7 @@ static int __devinit pci200_pci_init_one(struct pci_dev *pdev, card->ports[0].netdev = alloc_hdlcdev(&card->ports[0]); card->ports[1].netdev = alloc_hdlcdev(&card->ports[1]); if (!card->ports[0].netdev || !card->ports[1].netdev) { - pr_err("unable to allocate memory\n"); + printk(KERN_ERR "pci200syn: unable to allocate memory\n"); pci200_pci_remove_one(pdev); return -ENOMEM; } @@ -316,7 +314,7 @@ static int __devinit pci200_pci_init_one(struct pci_dev *pdev, if (pci_resource_len(pdev, 0) != PCI200SYN_PLX_SIZE || pci_resource_len(pdev, 2) != PCI200SYN_SCA_SIZE || pci_resource_len(pdev, 3) < 16384) { - pr_err("invalid card EEPROM parameters\n"); + printk(KERN_ERR "pci200syn: invalid card EEPROM parameters\n"); pci200_pci_remove_one(pdev); return -EFAULT; } @@ -333,7 +331,7 @@ static int __devinit pci200_pci_init_one(struct pci_dev *pdev, if (card->plxbase == NULL || card->scabase == NULL || card->rambase == NULL) { - pr_err("ioremap() failed\n"); + printk(KERN_ERR "pci200syn: ioremap() failed\n"); pci200_pci_remove_one(pdev); return -EFAULT; } @@ -359,12 +357,12 @@ static int __devinit pci200_pci_init_one(struct pci_dev *pdev, card->buff_offset = 2 * sizeof(pkt_desc) * (card->tx_ring_buffers + card->rx_ring_buffers); - pr_info("%u KB RAM at 0x%x, IRQ%u, using %u TX + %u RX packets rings\n", - ramsize / 1024, ramphys, - pdev->irq, card->tx_ring_buffers, card->rx_ring_buffers); + printk(KERN_INFO "pci200syn: %u KB RAM at 0x%x, IRQ%u, using %u TX +" + " %u RX packets rings\n", ramsize / 1024, ramphys, + pdev->irq, card->tx_ring_buffers, card->rx_ring_buffers); if (card->tx_ring_buffers < 1) { - pr_err("RAM test failed\n"); + printk(KERN_ERR "pci200syn: RAM test failed\n"); pci200_pci_remove_one(pdev); return -EFAULT; } @@ -375,7 +373,8 @@ static int __devinit pci200_pci_init_one(struct pci_dev *pdev, /* Allocate IRQ */ if (request_irq(pdev->irq, sca_intr, IRQF_SHARED, "pci200syn", card)) { - pr_warn("could not allocate IRQ%d\n", pdev->irq); + printk(KERN_WARNING "pci200syn: could not allocate IRQ%d.\n", + pdev->irq); pci200_pci_remove_one(pdev); return -EBUSY; } @@ -401,13 +400,15 @@ static int __devinit pci200_pci_init_one(struct pci_dev *pdev, port->card = card; sca_init_port(port); if (register_hdlc_device(dev)) { - pr_err("unable to register hdlc device\n"); + printk(KERN_ERR "pci200syn: unable to register hdlc " + "device\n"); port->card = NULL; pci200_pci_remove_one(pdev); return -ENOBUFS; } - netdev_info(dev, "PCI200SYN channel %d\n", port->chan); + printk(KERN_INFO "%s: PCI200SYN channel %d\n", + dev->name, port->chan); } sca_flush(card); @@ -434,7 +435,7 @@ static struct pci_driver pci200_pci_driver = { static int __init pci200_init_module(void) { if (pci_clock_freq < 1000000 || pci_clock_freq > 80000000) { - pr_err("Invalid PCI clock frequency\n"); + printk(KERN_ERR "pci200syn: Invalid PCI clock frequency\n"); return -EINVAL; } return pci_register_driver(&pci200_pci_driver); diff --git a/trunk/drivers/net/wan/sbni.c b/trunk/drivers/net/wan/sbni.c index 40e95facdb6c..cff13a9597cd 100644 --- a/trunk/drivers/net/wan/sbni.c +++ b/trunk/drivers/net/wan/sbni.c @@ -37,8 +37,6 @@ * Known problem: this driver wasn't tested on multiprocessor machine. */ -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - #include #include #include @@ -202,8 +200,8 @@ sbni_isa_probe( struct net_device *dev ) return 0; else { - pr_err("base address 0x%lx is busy, or adapter is malfunctional!\n", - dev->base_addr); + printk( KERN_ERR "sbni: base address 0x%lx is busy, or adapter " + "is malfunctional!\n", dev->base_addr ); return -ENODEV; } } @@ -228,6 +226,7 @@ static void __init sbni_devsetup(struct net_device *dev) int __init sbni_probe(int unit) { struct net_device *dev; + static unsigned version_printed __initdata = 0; int err; dev = alloc_netdev(sizeof(struct net_local), "sbni", sbni_devsetup); @@ -251,7 +250,8 @@ int __init sbni_probe(int unit) free_netdev(dev); return err; } - pr_info_once("%s", version); + if( version_printed++ == 0 ) + printk( KERN_INFO "%s", version ); return 0; } @@ -326,9 +326,9 @@ sbni_pci_probe( struct net_device *dev ) } if (pci_irq_line <= 0 || pci_irq_line >= nr_irqs) - pr_warn( -"WARNING: The PCI BIOS assigned this PCI card to IRQ %d, which is unlikely to work!.\n" -"You should use the PCI BIOS setup to assign a valid IRQ line.\n", + printk( KERN_WARNING + " WARNING: The PCI BIOS assigned this PCI card to IRQ %d, which is unlikely to work!.\n" + " You should use the PCI BIOS setup to assign a valid IRQ line.\n", pci_irq_line ); /* avoiding re-enable dual adapters */ @@ -372,7 +372,8 @@ sbni_probe1( struct net_device *dev, unsigned long ioaddr, int irq ) outb( 0, ioaddr + CSR0 ); if( !irq ) { - pr_err("%s: can't detect device irq!\n", dev->name); + printk( KERN_ERR "%s: can't detect device irq!\n", + dev->name ); release_region( ioaddr, SBNI_IO_EXTENT ); return NULL; } @@ -385,7 +386,7 @@ sbni_probe1( struct net_device *dev, unsigned long ioaddr, int irq ) /* Fill in sbni-specific dev fields. */ nl = netdev_priv(dev); if( !nl ) { - pr_err("%s: unable to get memory!\n", dev->name); + printk( KERN_ERR "%s: unable to get memory!\n", dev->name ); release_region( ioaddr, SBNI_IO_EXTENT ); return NULL; } @@ -414,21 +415,21 @@ sbni_probe1( struct net_device *dev, unsigned long ioaddr, int irq ) if( inb( ioaddr + CSR0 ) & 0x01 ) nl->state |= FL_SLOW_MODE; - pr_notice("%s: ioaddr %#lx, irq %d, MAC: 00:ff:01:%02x:%02x:%02x\n", - dev->name, dev->base_addr, dev->irq, - ((u8 *)dev->dev_addr)[3], - ((u8 *)dev->dev_addr)[4], - ((u8 *)dev->dev_addr)[5]); + printk( KERN_NOTICE "%s: ioaddr %#lx, irq %d, " + "MAC: 00:ff:01:%02x:%02x:%02x\n", + dev->name, dev->base_addr, dev->irq, + ((u8 *) dev->dev_addr) [3], + ((u8 *) dev->dev_addr) [4], + ((u8 *) dev->dev_addr) [5] ); - pr_notice("%s: speed %d", - dev->name, - ((nl->state & FL_SLOW_MODE) ? 500000 : 2000000) - / (1 << nl->csr1.rate)); + printk( KERN_NOTICE "%s: speed %d, receive level ", dev->name, + ( (nl->state & FL_SLOW_MODE) ? 500000 : 2000000) + / (1 << nl->csr1.rate) ); if( nl->delta_rxl == 0 ) - pr_cont(", receive level 0x%x (fixed)\n", nl->cur_rxl_index); + printk( "0x%x (fixed)\n", nl->cur_rxl_index ); else - pr_cont(", receive level (auto)\n"); + printk( "(auto)\n"); #ifdef CONFIG_SBNI_MULTILINE nl->master = dev; @@ -567,7 +568,7 @@ handle_channel( struct net_device *dev ) */ csr0 = inb( ioaddr + CSR0 ); if( !(csr0 & TR_RDY) || (csr0 & RC_RDY) ) - netdev_err(dev, "internal error!\n"); + printk( KERN_ERR "%s: internal error!\n", dev->name ); /* if state & FL_NEED_RESEND != 0 then tx_frameno != 0 */ if( req_ans || nl->tx_frameno != 0 ) @@ -850,7 +851,7 @@ prepare_to_send( struct sk_buff *skb, struct net_device *dev ) /* nl->tx_buf_p == NULL here! */ if( nl->tx_buf_p ) - netdev_err(dev, "memory leak!\n"); + printk( KERN_ERR "%s: memory leak!\n", dev->name ); nl->outpos = 0; nl->state &= ~(FL_WAIT_ACK | FL_NEED_RESEND); @@ -1178,15 +1179,16 @@ sbni_open( struct net_device *dev ) ((struct net_local *) (netdev_priv(*p))) ->second = dev; - netdev_notice(dev, "using shared irq with %s\n", - (*p)->name); + printk( KERN_NOTICE "%s: using shared irq " + "with %s\n", dev->name, (*p)->name ); nl->state |= FL_SECONDARY; goto handler_attached; } } if( request_irq(dev->irq, sbni_interrupt, IRQF_SHARED, dev->name, dev) ) { - netdev_err(dev, "unable to get IRQ %d\n", dev->irq); + printk( KERN_ERR "%s: unable to get IRQ %d.\n", + dev->name, dev->irq ); return -EAGAIN; } @@ -1218,8 +1220,8 @@ sbni_close( struct net_device *dev ) struct net_local *nl = netdev_priv(dev); if( nl->second && nl->second->flags & IFF_UP ) { - netdev_notice(dev, "Secondary channel (%s) is active!\n", - nl->second->name); + printk( KERN_NOTICE "Secondary channel (%s) is active!\n", + nl->second->name ); return -EBUSY; } @@ -1361,8 +1363,8 @@ sbni_ioctl( struct net_device *dev, struct ifreq *ifr, int cmd ) return -EFAULT; slave_dev = dev_get_by_name(&init_net, slave_name ); if( !slave_dev || !(slave_dev->flags & IFF_UP) ) { - netdev_err(dev, "trying to enslave non-active device %s\n", - slave_name); + printk( KERN_ERR "%s: trying to enslave non-active " + "device %s\n", dev->name, slave_name ); return -EPERM; } @@ -1415,7 +1417,8 @@ enslave( struct net_device *dev, struct net_device *slave_dev ) spin_unlock( &snl->lock ); spin_unlock( &nl->lock ); - netdev_notice(dev, "slave device (%s) attached\n", slave_dev->name); + printk( KERN_NOTICE "%s: slave device (%s) attached.\n", + dev->name, slave_dev->name ); return 0; } @@ -1544,7 +1547,7 @@ sbni_setup( char *p ) break; } bad_param: - pr_err("Error in sbni kernel parameter!\n"); + printk( KERN_ERR "Error in sbni kernel parameter!\n" ); return 0; } diff --git a/trunk/drivers/net/wan/sdla.c b/trunk/drivers/net/wan/sdla.c index c8531612eea9..3f4e2b5684db 100644 --- a/trunk/drivers/net/wan/sdla.c +++ b/trunk/drivers/net/wan/sdla.c @@ -32,8 +32,6 @@ * 2 of the License, or (at your option) any later version. */ -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - #include #include #include @@ -352,24 +350,24 @@ static void sdla_errors(struct net_device *dev, int cmd, int dlci, int ret, int case SDLA_RET_MODEM: state = data; if (*state & SDLA_MODEM_DCD_LOW) - netdev_info(dev, "Modem DCD unexpectedly low!\n"); + printk(KERN_INFO "%s: Modem DCD unexpectedly low!\n", dev->name); if (*state & SDLA_MODEM_CTS_LOW) - netdev_info(dev, "Modem CTS unexpectedly low!\n"); + printk(KERN_INFO "%s: Modem CTS unexpectedly low!\n", dev->name); /* I should probably do something about this! */ break; case SDLA_RET_CHANNEL_OFF: - netdev_info(dev, "Channel became inoperative!\n"); + printk(KERN_INFO "%s: Channel became inoperative!\n", dev->name); /* same here */ break; case SDLA_RET_CHANNEL_ON: - netdev_info(dev, "Channel became operative!\n"); + printk(KERN_INFO "%s: Channel became operative!\n", dev->name); /* same here */ break; case SDLA_RET_DLCI_STATUS: - netdev_info(dev, "Status change reported by Access Node\n"); + printk(KERN_INFO "%s: Status change reported by Access Node.\n", dev->name); len /= sizeof(struct _dlci_stat); for(pstatus = data, i=0;i < len;i++,pstatus++) { @@ -384,32 +382,29 @@ static void sdla_errors(struct net_device *dev, int cmd, int dlci, int ret, int sprintf(line, "unknown status: %02X", pstatus->flags); state = line; } - netdev_info(dev, "DLCI %i: %s\n", - pstatus->dlci, state); + printk(KERN_INFO "%s: DLCI %i: %s.\n", dev->name, pstatus->dlci, state); /* same here */ } break; case SDLA_RET_DLCI_UNKNOWN: - netdev_info(dev, "Received unknown DLCIs:"); + printk(KERN_INFO "%s: Received unknown DLCIs:", dev->name); len /= sizeof(short); for(pdlci = data,i=0;i < len;i++,pdlci++) - pr_cont(" %i", *pdlci); - pr_cont("\n"); + printk(" %i", *pdlci); + printk("\n"); break; case SDLA_RET_TIMEOUT: - netdev_err(dev, "Command timed out!\n"); + printk(KERN_ERR "%s: Command timed out!\n", dev->name); break; case SDLA_RET_BUF_OVERSIZE: - netdev_info(dev, "Bc/CIR overflow, acceptable size is %i\n", - len); + printk(KERN_INFO "%s: Bc/CIR overflow, acceptable size is %i\n", dev->name, len); break; case SDLA_RET_BUF_TOO_BIG: - netdev_info(dev, "Buffer size over specified max of %i\n", - len); + printk(KERN_INFO "%s: Buffer size over specified max of %i\n", dev->name, len); break; case SDLA_RET_CHANNEL_INACTIVE: @@ -420,8 +415,7 @@ static void sdla_errors(struct net_device *dev, int cmd, int dlci, int ret, int break; default: - netdev_dbg(dev, "Cmd 0x%02X generated return code 0x%02X\n", - cmd, ret); + printk(KERN_DEBUG "%s: Cmd 0x%2.2X generated return code 0x%2.2X\n", dev->name, cmd, ret); /* Further processing could be done here */ break; } @@ -684,14 +678,12 @@ static netdev_tx_t sdla_transmit(struct sk_buff *skb, case ARPHRD_FRAD: if (skb->dev->type != ARPHRD_DLCI) { - netdev_warn(dev, "Non DLCI device, type %i, tried to send on FRAD module\n", - skb->dev->type); + printk(KERN_WARNING "%s: Non DLCI device, type %i, tried to send on FRAD module.\n", dev->name, skb->dev->type); accept = 0; } break; default: - netdev_warn(dev, "unknown firmware type 0x%04X\n", - dev->type); + printk(KERN_WARNING "%s: unknown firmware type 0x%4.4X\n", dev->name, dev->type); accept = 0; break; } @@ -815,8 +807,7 @@ static void sdla_receive(struct net_device *dev) if (i == CONFIG_DLCI_MAX) { - netdev_notice(dev, "Received packet from invalid DLCI %i, ignoring\n", - dlci); + printk(KERN_NOTICE "%s: Received packet from invalid DLCI %i, ignoring.", dev->name, dlci); dev->stats.rx_errors++; success = 0; } @@ -828,7 +819,7 @@ static void sdla_receive(struct net_device *dev) skb = dev_alloc_skb(len + sizeof(struct frhdr)); if (skb == NULL) { - netdev_notice(dev, "Memory squeeze, dropping packet\n"); + printk(KERN_NOTICE "%s: Memory squeeze, dropping packet.\n", dev->name); dev->stats.rx_dropped++; success = 0; } @@ -889,7 +880,8 @@ static irqreturn_t sdla_isr(int dummy, void *dev_id) if (!flp->initialized) { - netdev_warn(dev, "irq %d for uninitialized device\n", dev->irq); + printk(KERN_WARNING "%s: irq %d for uninitialized device.\n", + dev->name, dev->irq); return IRQ_NONE; } @@ -909,7 +901,7 @@ static irqreturn_t sdla_isr(int dummy, void *dev_id) case SDLA_INTR_TX: case SDLA_INTR_COMPLETE: case SDLA_INTR_TIMER: - netdev_warn(dev, "invalid irq flag 0x%02X\n", byte); + printk(KERN_WARNING "%s: invalid irq flag 0x%02X.\n", dev->name, byte); break; } @@ -1355,7 +1347,7 @@ static int sdla_set_config(struct net_device *dev, struct ifmap *map) return -EINVAL; if (!request_region(map->base_addr, SDLA_IO_EXTENTS, dev->name)){ - pr_warn("io-port 0x%04lx in use\n", dev->base_addr); + printk(KERN_WARNING "SDLA: io-port 0x%04lx in use\n", dev->base_addr); return -EINVAL; } base = map->base_addr; @@ -1420,7 +1412,7 @@ static int sdla_set_config(struct net_device *dev, struct ifmap *map) } } - netdev_notice(dev, "Unknown card type\n"); + printk(KERN_NOTICE "%s: Unknown card type\n", dev->name); err = -ENODEV; goto fail; diff --git a/trunk/drivers/net/wan/sealevel.c b/trunk/drivers/net/wan/sealevel.c index 0b4fd05e1508..e91457d6023e 100644 --- a/trunk/drivers/net/wan/sealevel.c +++ b/trunk/drivers/net/wan/sealevel.c @@ -12,8 +12,6 @@ * */ -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - #include #include #include @@ -192,7 +190,7 @@ static int slvl_setup(struct slvl_device *sv, int iobase, int irq) dev->irq = irq; if (register_hdlc_device(dev)) { - pr_err("unable to register HDLC device\n"); + printk(KERN_ERR "sealevel: unable to register HDLC device\n"); free_netdev(dev); return -1; } @@ -217,7 +215,8 @@ static __init struct slvl_board *slvl_init(int iobase, int irq, */ if (!request_region(iobase, 8, "Sealevel 4021")) { - pr_warn("I/O 0x%X already in use\n", iobase); + printk(KERN_WARNING "sealevel: I/O 0x%X already in use.\n", + iobase); return NULL; } @@ -268,7 +267,7 @@ static __init struct slvl_board *slvl_init(int iobase, int irq, if (request_irq(irq, z8530_interrupt, IRQF_DISABLED, "SeaLevel", dev) < 0) { - pr_warn("IRQ %d already in use\n", irq); + printk(KERN_WARNING "sealevel: IRQ %d already in use.\n", irq); goto err_request_irq; } @@ -293,7 +292,7 @@ static __init struct slvl_board *slvl_init(int iobase, int irq, */ if (z8530_init(dev) != 0) { - pr_err("Z8530 series device not found\n"); + printk(KERN_ERR "Z8530 series device not found.\n"); enable_irq(irq); goto free_hw; } diff --git a/trunk/drivers/net/wan/wanxl.c b/trunk/drivers/net/wan/wanxl.c index 44b707197258..4ea89fe0006f 100644 --- a/trunk/drivers/net/wan/wanxl.c +++ b/trunk/drivers/net/wan/wanxl.c @@ -13,8 +13,6 @@ * - wanXL100 will require minor driver modifications, no access to hw */ -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - #include #include #include @@ -104,8 +102,9 @@ static inline dma_addr_t pci_map_single_debug(struct pci_dev *pdev, void *ptr, { dma_addr_t addr = pci_map_single(pdev, ptr, size, direction); if (addr + size > 0x100000000LL) - pr_crit("%s: pci_map_single() returned memory at 0x%llx!\n", - pci_name(pdev), (unsigned long long)addr); + printk(KERN_CRIT "wanXL %s: pci_map_single() returned memory" + " at 0x%LX!\n", pci_name(pdev), + (unsigned long long)addr); return addr; } @@ -148,8 +147,8 @@ static inline void wanxl_cable_intr(port_t *port) } dte = (value & STATUS_CABLE_DCE) ? " DCE" : " DTE"; } - netdev_info(port->dev, "%s%s module, %s cable%s%s\n", - pm, dte, cable, dsr, dcd); + printk(KERN_INFO "%s: %s%s module, %s cable%s%s\n", + port->dev->name, pm, dte, cable, dsr, dcd); if (value & STATUS_CABLE_DCD) netif_carrier_on(port->dev); @@ -199,8 +198,8 @@ static inline void wanxl_rx_intr(card_t *card) while (desc = &card->status->rx_descs[card->rx_in], desc->stat != PACKET_EMPTY) { if ((desc->stat & PACKET_PORT_MASK) > card->n_ports) - pr_crit("%s: received packet for nonexistent port\n", - pci_name(card->pdev)); + printk(KERN_CRIT "wanXL %s: received packet for" + " nonexistent port\n", pci_name(card->pdev)); else { struct sk_buff *skb = card->rx_skbs[card->rx_in]; port_t *port = &card->ports[desc->stat & @@ -284,7 +283,7 @@ static netdev_tx_t wanxl_xmit(struct sk_buff *skb, struct net_device *dev) printk(KERN_DEBUG "%s: transmitter buffer full\n", dev->name); #endif netif_stop_queue(dev); - spin_unlock(&port->lock); + spin_unlock_irq(&port->lock); return NETDEV_TX_BUSY; /* request packet to be queued */ } @@ -398,7 +397,7 @@ static int wanxl_open(struct net_device *dev) int i; if (get_status(port)->open) { - netdev_err(dev, "port already open\n"); + printk(KERN_ERR "%s: port already open\n", dev->name); return -EIO; } if ((i = hdlc_open(dev)) != 0) @@ -418,7 +417,7 @@ static int wanxl_open(struct net_device *dev) } } while (time_after(timeout, jiffies)); - netdev_err(dev, "unable to open port\n"); + printk(KERN_ERR "%s: unable to open port\n", dev->name); /* ask the card to close the port, should it be still alive */ writel(1 << (DOORBELL_TO_CARD_CLOSE_0 + port->node), dbr); return -EFAULT; @@ -444,7 +443,7 @@ static int wanxl_close(struct net_device *dev) } while (time_after(timeout, jiffies)); if (get_status(port)->open) - netdev_err(dev, "unable to close port\n"); + printk(KERN_ERR "%s: unable to close port\n", dev->name); netif_stop_queue(dev); @@ -569,7 +568,11 @@ static int __devinit wanxl_pci_init_one(struct pci_dev *pdev, int i, ports, alloc_size; #ifndef MODULE - pr_info_once("%s\n", version); + static int printed_version; + if (!printed_version) { + printed_version++; + printk(KERN_INFO "%s\n", version); + } #endif i = pci_enable_device(pdev); @@ -585,7 +588,7 @@ static int __devinit wanxl_pci_init_one(struct pci_dev *pdev, work on most platforms */ if (pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(28)) || pci_set_dma_mask(pdev, DMA_BIT_MASK(28))) { - pr_err("No usable DMA configuration\n"); + printk(KERN_ERR "wanXL: No usable DMA configuration\n"); return -EIO; } @@ -604,7 +607,8 @@ static int __devinit wanxl_pci_init_one(struct pci_dev *pdev, alloc_size = sizeof(card_t) + ports * sizeof(port_t); card = kzalloc(alloc_size, GFP_KERNEL); if (card == NULL) { - pr_err("%s: unable to allocate memory\n", pci_name(pdev)); + printk(KERN_ERR "wanXL %s: unable to allocate memory\n", + pci_name(pdev)); pci_release_regions(pdev); pci_disable_device(pdev); return -ENOBUFS; @@ -631,7 +635,7 @@ static int __devinit wanxl_pci_init_one(struct pci_dev *pdev, to indicate the card can do 32-bit DMA addressing */ if (pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32)) || pci_set_dma_mask(pdev, DMA_BIT_MASK(32))) { - pr_err("No usable DMA configuration\n"); + printk(KERN_ERR "wanXL: No usable DMA configuration\n"); wanxl_pci_remove_one(pdev); return -EIO; } @@ -641,7 +645,7 @@ static int __devinit wanxl_pci_init_one(struct pci_dev *pdev, card->plx = ioremap_nocache(plx_phy, 0x70); if (!card->plx) { - pr_err("ioremap() failed\n"); + printk(KERN_ERR "wanxl: ioremap() failed\n"); wanxl_pci_remove_one(pdev); return -EFAULT; } @@ -653,8 +657,8 @@ static int __devinit wanxl_pci_init_one(struct pci_dev *pdev, timeout = jiffies + 20 * HZ; while ((stat = readl(card->plx + PLX_MAILBOX_0)) != 0) { if (time_before(timeout, jiffies)) { - pr_warn("%s: timeout waiting for PUTS to complete\n", - pci_name(pdev)); + printk(KERN_WARNING "wanXL %s: timeout waiting for" + " PUTS to complete\n", pci_name(pdev)); wanxl_pci_remove_one(pdev); return -ENODEV; } @@ -665,8 +669,8 @@ static int __devinit wanxl_pci_init_one(struct pci_dev *pdev, break; default: - pr_warn("%s: PUTS test 0x%X failed\n", - pci_name(pdev), stat & 0x30); + printk(KERN_WARNING "wanXL %s: PUTS test 0x%X" + " failed\n", pci_name(pdev), stat & 0x30); wanxl_pci_remove_one(pdev); return -ENODEV; } @@ -684,16 +688,17 @@ static int __devinit wanxl_pci_init_one(struct pci_dev *pdev, /* sanity check the board's reported memory size */ if (ramsize < BUFFERS_ADDR + (TX_BUFFERS + RX_BUFFERS) * BUFFER_LENGTH * ports) { - pr_warn("%s: no enough on-board RAM (%u bytes detected, %u bytes required)\n", - pci_name(pdev), ramsize, - BUFFERS_ADDR + - (TX_BUFFERS + RX_BUFFERS) * BUFFER_LENGTH * ports); + printk(KERN_WARNING "wanXL %s: no enough on-board RAM" + " (%u bytes detected, %u bytes required)\n", + pci_name(pdev), ramsize, BUFFERS_ADDR + + (TX_BUFFERS + RX_BUFFERS) * BUFFER_LENGTH * ports); wanxl_pci_remove_one(pdev); return -ENODEV; } if (wanxl_puts_command(card, MBX1_CMD_BSWAP)) { - pr_warn("%s: unable to Set Byte Swap Mode\n", pci_name(pdev)); + printk(KERN_WARNING "wanXL %s: unable to Set Byte Swap" + " Mode\n", pci_name(pdev)); wanxl_pci_remove_one(pdev); return -ENODEV; } @@ -710,7 +715,7 @@ static int __devinit wanxl_pci_init_one(struct pci_dev *pdev, mem = ioremap_nocache(mem_phy, PDM_OFFSET + sizeof(firmware)); if (!mem) { - pr_err("ioremap() failed\n"); + printk(KERN_ERR "wanxl: ioremap() failed\n"); wanxl_pci_remove_one(pdev); return -EFAULT; } @@ -729,7 +734,8 @@ static int __devinit wanxl_pci_init_one(struct pci_dev *pdev, writel(0, card->plx + PLX_MAILBOX_5); if (wanxl_puts_command(card, MBX1_CMD_ABORTJ)) { - pr_warn("%s: unable to Abort and Jump\n", pci_name(pdev)); + printk(KERN_WARNING "wanXL %s: unable to Abort and Jump\n", + pci_name(pdev)); wanxl_pci_remove_one(pdev); return -ENODEV; } @@ -743,8 +749,8 @@ static int __devinit wanxl_pci_init_one(struct pci_dev *pdev, }while (time_after(timeout, jiffies)); if (!stat) { - pr_warn("%s: timeout while initializing card firmware\n", - pci_name(pdev)); + printk(KERN_WARNING "wanXL %s: timeout while initializing card " + "firmware\n", pci_name(pdev)); wanxl_pci_remove_one(pdev); return -ENODEV; } @@ -753,13 +759,13 @@ static int __devinit wanxl_pci_init_one(struct pci_dev *pdev, ramsize = stat; #endif - pr_info("%s: at 0x%X, %u KB of RAM at 0x%X, irq %u\n", - pci_name(pdev), plx_phy, ramsize / 1024, mem_phy, pdev->irq); + printk(KERN_INFO "wanXL %s: at 0x%X, %u KB of RAM at 0x%X, irq %u\n", + pci_name(pdev), plx_phy, ramsize / 1024, mem_phy, pdev->irq); /* Allocate IRQ */ if (request_irq(pdev->irq, wanxl_intr, IRQF_SHARED, "wanXL", card)) { - pr_warn("%s: could not allocate IRQ%i\n", - pci_name(pdev), pdev->irq); + printk(KERN_WARNING "wanXL %s: could not allocate IRQ%i.\n", + pci_name(pdev), pdev->irq); wanxl_pci_remove_one(pdev); return -EBUSY; } @@ -770,8 +776,8 @@ static int __devinit wanxl_pci_init_one(struct pci_dev *pdev, port_t *port = &card->ports[i]; struct net_device *dev = alloc_hdlcdev(port); if (!dev) { - pr_err("%s: unable to allocate memory\n", - pci_name(pdev)); + printk(KERN_ERR "wanXL %s: unable to allocate" + " memory\n", pci_name(pdev)); wanxl_pci_remove_one(pdev); return -ENOMEM; } @@ -787,8 +793,8 @@ static int __devinit wanxl_pci_init_one(struct pci_dev *pdev, port->node = i; get_status(port)->clocking = CLOCK_EXT; if (register_hdlc_device(dev)) { - pr_err("%s: unable to register hdlc device\n", - pci_name(pdev)); + printk(KERN_ERR "wanXL %s: unable to register hdlc" + " device\n", pci_name(pdev)); free_netdev(dev); wanxl_pci_remove_one(pdev); return -ENOBUFS; @@ -796,11 +802,11 @@ static int __devinit wanxl_pci_init_one(struct pci_dev *pdev, card->n_ports++; } - pr_info("%s: port", pci_name(pdev)); + printk(KERN_INFO "wanXL %s: port", pci_name(pdev)); for (i = 0; i < ports; i++) - pr_cont("%s #%i: %s", - i ? "," : "", i, card->ports[i].dev->name); - pr_cont("\n"); + printk("%s #%i: %s", i ? "," : "", i, + card->ports[i].dev->name); + printk("\n"); for (i = 0; i < ports; i++) wanxl_cable_intr(&card->ports[i]); /* get carrier status etc.*/ @@ -830,7 +836,7 @@ static struct pci_driver wanxl_pci_driver = { static int __init wanxl_init_module(void) { #ifdef MODULE - pr_info("%s\n", version); + printk(KERN_INFO "%s\n", version); #endif return pci_register_driver(&wanxl_pci_driver); } diff --git a/trunk/drivers/net/wan/x25_asy.c b/trunk/drivers/net/wan/x25_asy.c index 46ceb3ae9073..24297b274cd4 100644 --- a/trunk/drivers/net/wan/x25_asy.c +++ b/trunk/drivers/net/wan/x25_asy.c @@ -14,8 +14,6 @@ * 2000-10-29 Henner Eisen lapb_data_indication() return status. */ -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - #include #include @@ -98,7 +96,7 @@ static struct x25_asy *x25_asy_alloc(void) x25_asy_devs[i] = dev; return sl; } else { - pr_warn("%s(): register_netdev() failure\n", __func__); + printk(KERN_WARNING "x25_asy_alloc() - register_netdev() failure.\n"); free_netdev(dev); } } @@ -116,7 +114,8 @@ static void x25_asy_free(struct x25_asy *sl) sl->xbuff = NULL; if (!test_and_clear_bit(SLF_INUSE, &sl->flags)) - netdev_err(sl->dev, "x25_asy_free for already free unit\n"); + printk(KERN_ERR "%s: x25_asy_free for already free unit.\n", + sl->dev->name); } static int x25_asy_change_mtu(struct net_device *dev, int newmtu) @@ -129,7 +128,8 @@ static int x25_asy_change_mtu(struct net_device *dev, int newmtu) rbuff = kmalloc(len + 4, GFP_ATOMIC); if (xbuff == NULL || rbuff == NULL) { - netdev_warn(dev, "unable to grow X.25 buffers, MTU change cancelled\n"); + printk(KERN_WARNING "%s: unable to grow X.25 buffers, MTU change cancelled.\n", + dev->name); kfree(xbuff); kfree(rbuff); return -ENOMEM; @@ -198,7 +198,8 @@ static void x25_asy_bump(struct x25_asy *sl) skb = dev_alloc_skb(count+1); if (skb == NULL) { - netdev_warn(sl->dev, "memory squeeze, dropping packet\n"); + printk(KERN_WARNING "%s: memory squeeze, dropping packet.\n", + sl->dev->name); dev->stats.rx_dropped++; return; } @@ -286,9 +287,9 @@ static void x25_asy_timeout(struct net_device *dev) /* May be we must check transmitter timeout here ? * 14 Oct 1994 Dmitry Gorodchanin. */ - netdev_warn(dev, "transmit timed out, %s?\n", - (tty_chars_in_buffer(sl->tty) || sl->xleft) ? - "bad line quality" : "driver error"); + printk(KERN_WARNING "%s: transmit timed out, %s?\n", dev->name, + (tty_chars_in_buffer(sl->tty) || sl->xleft) ? + "bad line quality" : "driver error"); sl->xleft = 0; clear_bit(TTY_DO_WRITE_WAKEUP, &sl->tty->flags); x25_asy_unlock(sl); @@ -305,7 +306,8 @@ static netdev_tx_t x25_asy_xmit(struct sk_buff *skb, int err; if (!netif_running(sl->dev)) { - netdev_err(dev, "xmit call when iface is down\n"); + printk(KERN_ERR "%s: xmit call when iface is down\n", + dev->name); kfree_skb(skb); return NETDEV_TX_OK; } @@ -316,15 +318,13 @@ static netdev_tx_t x25_asy_xmit(struct sk_buff *skb, case X25_IFACE_CONNECT: /* Connection request .. do nothing */ err = lapb_connect_request(dev); if (err != LAPB_OK) - netdev_err(dev, "lapb_connect_request error: %d\n", - err); + printk(KERN_ERR "x25_asy: lapb_connect_request error - %d\n", err); kfree_skb(skb); return NETDEV_TX_OK; case X25_IFACE_DISCONNECT: /* do nothing - hang up ?? */ err = lapb_disconnect_request(dev); if (err != LAPB_OK) - netdev_err(dev, "lapb_disconnect_request error: %d\n", - err); + printk(KERN_ERR "x25_asy: lapb_disconnect_request error - %d\n", err); default: kfree_skb(skb); return NETDEV_TX_OK; @@ -343,7 +343,7 @@ static netdev_tx_t x25_asy_xmit(struct sk_buff *skb, err = lapb_data_request(dev, skb); if (err != LAPB_OK) { - netdev_err(dev, "lapb_data_request error: %d\n", err); + printk(KERN_ERR "x25_asy: lapb_data_request error - %d\n", err); kfree_skb(skb); return NETDEV_TX_OK; } @@ -378,7 +378,7 @@ static void x25_asy_data_transmit(struct net_device *dev, struct sk_buff *skb) spin_lock(&sl->lock); if (netif_queue_stopped(sl->dev) || sl->tty == NULL) { spin_unlock(&sl->lock); - netdev_err(dev, "tbusy drop\n"); + printk(KERN_ERR "x25_asy: tbusy drop\n"); kfree_skb(skb); return; } @@ -404,7 +404,7 @@ static void x25_asy_connected(struct net_device *dev, int reason) skb = dev_alloc_skb(1); if (skb == NULL) { - netdev_err(dev, "out of memory\n"); + printk(KERN_ERR "x25_asy: out of memory\n"); return; } @@ -423,7 +423,7 @@ static void x25_asy_disconnected(struct net_device *dev, int reason) skb = dev_alloc_skb(1); if (skb == NULL) { - netdev_err(dev, "out of memory\n"); + printk(KERN_ERR "x25_asy: out of memory\n"); return; } @@ -603,8 +603,8 @@ static void x25_asy_close_tty(struct tty_struct *tty) err = lapb_unregister(sl->dev); if (err != LAPB_OK) - pr_err("x25_asy_close: lapb_unregister error: %d\n", - err); + printk(KERN_ERR "x25_asy_close: lapb_unregister error -%d\n", + err); tty->disc_data = NULL; sl->tty = NULL; @@ -782,13 +782,14 @@ static int __init init_x25_asy(void) if (x25_asy_maxdev < 4) x25_asy_maxdev = 4; /* Sanity */ - pr_info("X.25 async: version 0.00 ALPHA (dynamic channels, max=%d)\n", - x25_asy_maxdev); + printk(KERN_INFO "X.25 async: version 0.00 ALPHA " + "(dynamic channels, max=%d).\n", x25_asy_maxdev); x25_asy_devs = kcalloc(x25_asy_maxdev, sizeof(struct net_device *), GFP_KERNEL); if (!x25_asy_devs) { - pr_warn("Can't allocate x25_asy_ctrls[] array! Uaargh! (-> No X.25 available)\n"); + printk(KERN_WARNING "X25 async: Can't allocate x25_asy_ctrls[] " + "array! Uaargh! (-> No X.25 available)\n"); return -ENOMEM; } diff --git a/trunk/drivers/net/wan/z85230.c b/trunk/drivers/net/wan/z85230.c index 0e5769061702..0806232e0f8f 100644 --- a/trunk/drivers/net/wan/z85230.c +++ b/trunk/drivers/net/wan/z85230.c @@ -36,8 +36,6 @@ * Synchronous mode without DMA is unlikely to pass about 2400 baud. */ -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - #include #include #include @@ -367,7 +365,7 @@ static void z8530_rx(struct z8530_channel *c) c->count=0; if(stat&Rx_OVR) { - pr_warn("%s: overrun\n", c->dev->name); + printk(KERN_WARNING "%s: overrun\n", c->dev->name); c->rx_overrun++; } if(stat&CRC_ERR) @@ -466,12 +464,12 @@ static void z8530_status(struct z8530_channel *chan) if (altered & chan->dcdcheck) { if (status & chan->dcdcheck) { - pr_info("%s: DCD raised\n", chan->dev->name); + printk(KERN_INFO "%s: DCD raised\n", chan->dev->name); write_zsreg(chan, R3, chan->regs[3] | RxENABLE); if (chan->netdevice) netif_carrier_on(chan->netdevice); } else { - pr_info("%s: DCD lost\n", chan->dev->name); + printk(KERN_INFO "%s: DCD lost\n", chan->dev->name); write_zsreg(chan, R3, chan->regs[3] & ~RxENABLE); z8530_flush_fifo(chan); if (chan->netdevice) @@ -540,12 +538,12 @@ static void z8530_dma_tx(struct z8530_channel *chan) { if(!chan->dma_tx) { - pr_warn("Hey who turned the DMA off?\n"); + printk(KERN_WARNING "Hey who turned the DMA off?\n"); z8530_tx(chan); return; } /* This shouldn't occur in DMA mode */ - pr_err("DMA tx - bogus event!\n"); + printk(KERN_ERR "DMA tx - bogus event!\n"); z8530_tx(chan); } @@ -587,12 +585,12 @@ static void z8530_dma_status(struct z8530_channel *chan) if (altered & chan->dcdcheck) { if (status & chan->dcdcheck) { - pr_info("%s: DCD raised\n", chan->dev->name); + printk(KERN_INFO "%s: DCD raised\n", chan->dev->name); write_zsreg(chan, R3, chan->regs[3] | RxENABLE); if (chan->netdevice) netif_carrier_on(chan->netdevice); } else { - pr_info("%s: DCD lost\n", chan->dev->name); + printk(KERN_INFO "%s:DCD lost\n", chan->dev->name); write_zsreg(chan, R3, chan->regs[3] & ~RxENABLE); z8530_flush_fifo(chan); if (chan->netdevice) @@ -714,7 +712,7 @@ irqreturn_t z8530_interrupt(int irq, void *dev_id) if(locker) { - pr_err("IRQ re-enter\n"); + printk(KERN_ERR "IRQ re-enter\n"); return IRQ_NONE; } locker=1; @@ -760,8 +758,7 @@ irqreturn_t z8530_interrupt(int irq, void *dev_id) } spin_unlock(&dev->lock); if(work==5000) - pr_err("%s: interrupt jammed - abort(0x%X)!\n", - dev->name, intr); + printk(KERN_ERR "%s: interrupt jammed - abort(0x%X)!\n", dev->name, intr); /* Ok all done */ locker=0; return IRQ_HANDLED; @@ -1228,7 +1225,7 @@ static const char *z8530_type_name[]={ void z8530_describe(struct z8530_dev *dev, char *mapping, unsigned long io) { - pr_info("%s: %s found at %s 0x%lX, IRQ %d\n", + printk(KERN_INFO "%s: %s found at %s 0x%lX, IRQ %d.\n", dev->name, z8530_type_name[dev->type], mapping, @@ -1624,7 +1621,8 @@ static void z8530_rx_done(struct z8530_channel *c) else /* Can't occur as we dont reenable the DMA irq until after the flip is done */ - netdev_warn(c->netdevice, "DMA flip overrun!\n"); + printk(KERN_WARNING "%s: DMA flip overrun!\n", + c->netdevice->name); release_dma_lock(flags); @@ -1639,7 +1637,8 @@ static void z8530_rx_done(struct z8530_channel *c) skb = dev_alloc_skb(ct); if (skb == NULL) { c->netdevice->stats.rx_dropped++; - netdev_warn(c->netdevice, "Memory squeeze\n"); + printk(KERN_WARNING "%s: Memory squeeze.\n", + c->netdevice->name); } else { skb_put(skb, ct); skb_copy_to_linear_data(skb, rxb, ct); @@ -1679,7 +1678,8 @@ static void z8530_rx_done(struct z8530_channel *c) c->skb2 = dev_alloc_skb(c->mtu); if (c->skb2 == NULL) - netdev_warn(c->netdevice, "memory squeeze\n"); + printk(KERN_WARNING "%s: memory squeeze.\n", + c->netdevice->name); else skb_put(c->skb2, c->mtu); c->netdevice->stats.rx_packets++; @@ -1693,7 +1693,7 @@ static void z8530_rx_done(struct z8530_channel *c) c->rx_function(c, skb); } else { c->netdevice->stats.rx_dropped++; - netdev_err(c->netdevice, "Lost a frame\n"); + printk(KERN_ERR "%s: Lost a frame\n", c->netdevice->name); } } diff --git a/trunk/drivers/net/wireless/ath/ath5k/ahb.c b/trunk/drivers/net/wireless/ath/ath5k/ahb.c index c38e9e848995..ea9982781559 100644 --- a/trunk/drivers/net/wireless/ath/ath5k/ahb.c +++ b/trunk/drivers/net/wireless/ath/ath5k/ahb.c @@ -219,7 +219,6 @@ static int ath_ahb_remove(struct platform_device *pdev) ath5k_deinit_softc(sc); platform_set_drvdata(pdev, NULL); - ieee80211_free_hw(hw); return 0; } diff --git a/trunk/drivers/net/wireless/ath/ath5k/ath5k.h b/trunk/drivers/net/wireless/ath/ath5k/ath5k.h index c4c02d5145c2..bb50700436fe 100644 --- a/trunk/drivers/net/wireless/ath/ath5k/ath5k.h +++ b/trunk/drivers/net/wireless/ath/ath5k/ath5k.h @@ -767,7 +767,6 @@ struct ath5k_athchan_2ghz { */ #define AR5K_KEYCACHE_SIZE 8 -extern int ath5k_modparam_nohwcrypt; /***********************\ HW RELATED DEFINITIONS @@ -1181,8 +1180,8 @@ void ath5k_sysfs_unregister(struct ath5k_softc *sc); struct ath5k_buf; struct ath5k_txq; -void ath5k_set_beacon_filter(struct ieee80211_hw *hw, bool enable); -bool ath5k_any_vif_assoc(struct ath5k_softc *sc); +void set_beacon_filter(struct ieee80211_hw *hw, bool enable); +bool ath_any_vif_assoc(struct ath5k_softc *sc); void ath5k_tx_queue(struct ieee80211_hw *hw, struct sk_buff *skb, struct ath5k_txq *txq); int ath5k_init_hw(struct ath5k_softc *sc); @@ -1254,7 +1253,7 @@ int ath5k_hw_get_frame_duration(struct ath5k_hw *ah, int len, struct ieee80211_rate *rate, bool shortpre); unsigned int ath5k_hw_get_default_slottime(struct ath5k_hw *ah); unsigned int ath5k_hw_get_default_sifs(struct ath5k_hw *ah); -int ath5k_hw_set_opmode(struct ath5k_hw *ah, enum nl80211_iftype opmode); +extern int ath5k_hw_set_opmode(struct ath5k_hw *ah, enum nl80211_iftype opmode); void ath5k_hw_set_coverage_class(struct ath5k_hw *ah, u8 coverage_class); /* RX filter control*/ int ath5k_hw_set_lladdr(struct ath5k_hw *ah, const u8 *mac); diff --git a/trunk/drivers/net/wireless/ath/ath5k/base.c b/trunk/drivers/net/wireless/ath/ath5k/base.c index fb05bf89b8e3..779a1d270243 100644 --- a/trunk/drivers/net/wireless/ath/ath5k/base.c +++ b/trunk/drivers/net/wireless/ath/ath5k/base.c @@ -88,6 +88,8 @@ MODULE_LICENSE("Dual BSD/GPL"); static int ath5k_init(struct ieee80211_hw *hw); static int ath5k_reset(struct ath5k_softc *sc, struct ieee80211_channel *chan, bool skip_pcu); +int ath5k_beacon_update(struct ieee80211_hw *hw, struct ieee80211_vif *vif); +void ath5k_beacon_update_timers(struct ath5k_softc *sc, u64 bc_tsf); /* Known SREVs */ static const struct ath5k_srev_name srev_names[] = { @@ -2160,7 +2162,7 @@ ath5k_schedule_tx(struct ath5k_softc *sc) tasklet_schedule(&sc->txtq); } -static irqreturn_t +irqreturn_t ath5k_intr(int irq, void *dev_id) { struct ath5k_softc *sc = dev_id; @@ -2614,7 +2616,7 @@ ath5k_init_hw(struct ath5k_softc *sc) return ret; } -static void ath5k_stop_tasklets(struct ath5k_softc *sc) +static void stop_tasklets(struct ath5k_softc *sc) { sc->rx_pending = false; sc->tx_pending = false; @@ -2668,7 +2670,7 @@ ath5k_stop_hw(struct ath5k_softc *sc) mmiowb(); mutex_unlock(&sc->lock); - ath5k_stop_tasklets(sc); + stop_tasklets(sc); cancel_delayed_work_sync(&sc->tx_complete_work); @@ -2696,7 +2698,7 @@ ath5k_reset(struct ath5k_softc *sc, struct ieee80211_channel *chan, ath5k_hw_set_imr(ah, 0); synchronize_irq(sc->irq); - ath5k_stop_tasklets(sc); + stop_tasklets(sc); /* Save ani mode and disable ANI during * reset. If we don't we might get false @@ -2961,12 +2963,11 @@ ath5k_deinit_softc(struct ath5k_softc *sc) * state and potentially want to use them. */ ath5k_hw_deinit(sc->ah); - kfree(sc->ah); free_irq(sc->irq, sc); } bool -ath5k_any_vif_assoc(struct ath5k_softc *sc) +ath_any_vif_assoc(struct ath5k_softc *sc) { struct ath5k_vif_iter_data iter_data; iter_data.hw_macaddr = NULL; @@ -2980,7 +2981,7 @@ ath5k_any_vif_assoc(struct ath5k_softc *sc) } void -ath5k_set_beacon_filter(struct ieee80211_hw *hw, bool enable) +set_beacon_filter(struct ieee80211_hw *hw, bool enable) { struct ath5k_softc *sc = hw->priv; struct ath5k_hw *ah = sc->ah; diff --git a/trunk/drivers/net/wireless/ath/ath5k/desc.c b/trunk/drivers/net/wireless/ath/ath5k/desc.c index f82383b3ed30..62172d585723 100644 --- a/trunk/drivers/net/wireless/ath/ath5k/desc.c +++ b/trunk/drivers/net/wireless/ath/ath5k/desc.c @@ -107,13 +107,10 @@ ath5k_hw_setup_2word_tx_desc(struct ath5k_hw *ah, struct ath5k_desc *desc, case AR5K_PKT_TYPE_BEACON: case AR5K_PKT_TYPE_PROBE_RESP: frame_type = AR5K_AR5210_TX_DESC_FRAME_TYPE_NO_DELAY; - break; case AR5K_PKT_TYPE_PIFS: frame_type = AR5K_AR5210_TX_DESC_FRAME_TYPE_PIFS; - break; default: frame_type = type; - break; } tx_ctl->tx_control_0 |= diff --git a/trunk/drivers/net/wireless/ath/ath5k/eeprom.c b/trunk/drivers/net/wireless/ath/ath5k/eeprom.c index 392771f93759..1fef84f87c78 100644 --- a/trunk/drivers/net/wireless/ath/ath5k/eeprom.c +++ b/trunk/drivers/net/wireless/ath/ath5k/eeprom.c @@ -691,12 +691,14 @@ ath5k_eeprom_free_pcal_info(struct ath5k_hw *ah, int mode) if (!chinfo[pier].pd_curves) continue; - for (pdg = 0; pdg < AR5K_EEPROM_N_PD_CURVES; pdg++) { + for (pdg = 0; pdg < ee->ee_pd_gains[mode]; pdg++) { struct ath5k_pdgain_info *pd = &chinfo[pier].pd_curves[pdg]; - kfree(pd->pd_step); - kfree(pd->pd_pwr); + if (pd != NULL) { + kfree(pd->pd_step); + kfree(pd->pd_pwr); + } } kfree(chinfo[pier].pd_curves); diff --git a/trunk/drivers/net/wireless/ath/ath5k/mac80211-ops.c b/trunk/drivers/net/wireless/ath/ath5k/mac80211-ops.c index 493908299bb4..807bd6440169 100644 --- a/trunk/drivers/net/wireless/ath/ath5k/mac80211-ops.c +++ b/trunk/drivers/net/wireless/ath/ath5k/mac80211-ops.c @@ -46,6 +46,8 @@ #include "base.h" #include "reg.h" +extern int ath5k_modparam_nohwcrypt; + /********************\ * Mac80211 functions * \********************/ @@ -294,10 +296,10 @@ ath5k_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif, if (bss_conf->assoc) sc->assoc = bss_conf->assoc; else - sc->assoc = ath5k_any_vif_assoc(sc); + sc->assoc = ath_any_vif_assoc(sc); if (sc->opmode == NL80211_IFTYPE_STATION) - ath5k_set_beacon_filter(hw, sc->assoc); + set_beacon_filter(hw, sc->assoc); ath5k_hw_set_ledstate(sc->ah, sc->assoc ? AR5K_LED_ASSOC : AR5K_LED_INIT); if (bss_conf->assoc) { diff --git a/trunk/drivers/net/wireless/ath/ath5k/pci.c b/trunk/drivers/net/wireless/ath/ath5k/pci.c index f2c0c236392f..296c316a8341 100644 --- a/trunk/drivers/net/wireless/ath/ath5k/pci.c +++ b/trunk/drivers/net/wireless/ath/ath5k/pci.c @@ -297,9 +297,7 @@ ath5k_pci_remove(struct pci_dev *pdev) #ifdef CONFIG_PM_SLEEP static int ath5k_pci_suspend(struct device *dev) { - struct pci_dev *pdev = to_pci_dev(dev); - struct ieee80211_hw *hw = pci_get_drvdata(pdev); - struct ath5k_softc *sc = hw->priv; + struct ath5k_softc *sc = pci_get_drvdata(to_pci_dev(dev)); ath5k_led_off(sc); return 0; @@ -308,8 +306,7 @@ static int ath5k_pci_suspend(struct device *dev) static int ath5k_pci_resume(struct device *dev) { struct pci_dev *pdev = to_pci_dev(dev); - struct ieee80211_hw *hw = pci_get_drvdata(pdev); - struct ath5k_softc *sc = hw->priv; + struct ath5k_softc *sc = pci_get_drvdata(pdev); /* * Suspend/Resume resets the PCI configuration space, so we have to diff --git a/trunk/drivers/net/wireless/ath/ath5k/reset.c b/trunk/drivers/net/wireless/ath/ath5k/reset.c index 1676a3e3dc3d..126a4eab35f3 100644 --- a/trunk/drivers/net/wireless/ath/ath5k/reset.c +++ b/trunk/drivers/net/wireless/ath/ath5k/reset.c @@ -375,19 +375,19 @@ static int ath5k_hw_nic_reset(struct ath5k_hw *ah, u32 val) static int ath5k_hw_wisoc_reset(struct ath5k_hw *ah, u32 flags) { u32 mask = flags ? flags : ~0U; - volatile __iomem u32 *reg; + volatile u32 *reg; u32 regval; u32 val = 0; /* ah->ah_mac_srev is not available at this point yet */ if (ah->ah_sc->devid >= AR5K_SREV_AR2315_R6) { - reg = (u32 __iomem *) AR5K_AR2315_RESET; + reg = (u32 *) AR5K_AR2315_RESET; if (mask & AR5K_RESET_CTL_PCU) val |= AR5K_AR2315_RESET_WMAC; if (mask & AR5K_RESET_CTL_BASEBAND) val |= AR5K_AR2315_RESET_BB_WARM; } else { - reg = (u32 __iomem *) AR5K_AR5312_RESET; + reg = (u32 *) AR5K_AR5312_RESET; if (to_platform_device(ah->ah_sc->dev)->id == 0) { if (mask & AR5K_RESET_CTL_PCU) val |= AR5K_AR5312_RESET_WMAC0; diff --git a/trunk/drivers/net/wireless/ath/ath5k/sysfs.c b/trunk/drivers/net/wireless/ath/ath5k/sysfs.c index a073cdce1f15..929c68cdf8ab 100644 --- a/trunk/drivers/net/wireless/ath/ath5k/sysfs.c +++ b/trunk/drivers/net/wireless/ath/ath5k/sysfs.c @@ -10,8 +10,7 @@ static ssize_t ath5k_attr_show_##name(struct device *dev, \ struct device_attribute *attr, \ char *buf) \ { \ - struct ieee80211_hw *hw = dev_get_drvdata(dev); \ - struct ath5k_softc *sc = hw->priv; \ + struct ath5k_softc *sc = dev_get_drvdata(dev); \ return snprintf(buf, PAGE_SIZE, "%d\n", get); \ } \ \ @@ -19,8 +18,7 @@ static ssize_t ath5k_attr_store_##name(struct device *dev, \ struct device_attribute *attr, \ const char *buf, size_t count) \ { \ - struct ieee80211_hw *hw = dev_get_drvdata(dev); \ - struct ath5k_softc *sc = hw->priv; \ + struct ath5k_softc *sc = dev_get_drvdata(dev); \ int val; \ \ val = (int)simple_strtoul(buf, NULL, 10); \ @@ -35,8 +33,7 @@ static ssize_t ath5k_attr_show_##name(struct device *dev, \ struct device_attribute *attr, \ char *buf) \ { \ - struct ieee80211_hw *hw = dev_get_drvdata(dev); \ - struct ath5k_softc *sc = hw->priv; \ + struct ath5k_softc *sc = dev_get_drvdata(dev); \ return snprintf(buf, PAGE_SIZE, "%d\n", get); \ } \ static DEVICE_ATTR(name, S_IRUGO, ath5k_attr_show_##name, NULL) diff --git a/trunk/drivers/net/wireless/ath/ath9k/ahb.c b/trunk/drivers/net/wireless/ath/ath9k/ahb.c index 0b36fcf8a280..5b49cd03bfdf 100644 --- a/trunk/drivers/net/wireless/ath/ath9k/ahb.c +++ b/trunk/drivers/net/wireless/ath/ath9k/ahb.c @@ -26,10 +26,6 @@ static const struct platform_device_id ath9k_platform_id_table[] = { .name = "ath9k", .driver_data = AR5416_AR9100_DEVID, }, - { - .name = "ar933x_wmac", - .driver_data = AR9300_DEVID_AR9330, - }, { .name = "ar934x_wmac", .driver_data = AR9300_DEVID_AR9340, diff --git a/trunk/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c b/trunk/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c index 1d09f22fee4d..ff8150e46f0e 100644 --- a/trunk/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c +++ b/trunk/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c @@ -1461,7 +1461,7 @@ static const struct ar9300_eeprom ar9300_h112 = { { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } }, { { CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 1) } }, - { { CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 0) } }, + { { CTL(60, 1), CTL(60, 0), CTL(0, 0), CTL(0, 0) } }, { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } }, { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } }, @@ -2616,7 +2616,7 @@ static const struct ar9300_eeprom ar9300_h116 = { { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } }, { { CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 1) } }, - { { CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 0) } }, + { { CTL(60, 1), CTL(60, 0), CTL(0, 0), CTL(0, 0) } }, { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } }, { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } }, @@ -3324,8 +3324,6 @@ static int ar9300_eeprom_restore_internal(struct ath_hw *ah, read = ar9300_read_eeprom; if (AR_SREV_9485(ah)) cptr = AR9300_BASE_ADDR_4K; - else if (AR_SREV_9330(ah)) - cptr = AR9300_BASE_ADDR_512; else cptr = AR9300_BASE_ADDR; ath_dbg(common, ATH_DBG_EEPROM, @@ -3444,7 +3442,7 @@ static void ar9003_hw_xpa_bias_level_apply(struct ath_hw *ah, bool is2ghz) { int bias = ar9003_hw_xpa_bias_level_get(ah, is2ghz); - if (AR_SREV_9485(ah) || AR_SREV_9330(ah) || AR_SREV_9340(ah)) + if (AR_SREV_9485(ah) || AR_SREV_9340(ah)) REG_RMW_FIELD(ah, AR_CH0_TOP2, AR_CH0_TOP2_XPABIASLVL, bias); else { REG_RMW_FIELD(ah, AR_CH0_TOP, AR_CH0_TOP_XPABIASLVL, bias); @@ -3525,7 +3523,7 @@ static void ar9003_hw_ant_ctrl_apply(struct ath_hw *ah, bool is2ghz) } } - if (AR_SREV_9330(ah) || AR_SREV_9485(ah)) { + if (AR_SREV_9485(ah)) { value = ath9k_hw_ar9300_get_eeprom(ah, EEP_ANT_DIV_CTL1); /* * main_lnaconf, alt_lnaconf, main_tb, alt_tb @@ -3712,7 +3710,7 @@ static void ar9003_hw_internal_regulator_apply(struct ath_hw *ah) ath9k_hw_ar9300_get_eeprom(ah, EEP_INTERNAL_REGULATOR); if (internal_regulator) { - if (AR_SREV_9330(ah) || AR_SREV_9485(ah)) { + if (AR_SREV_9485(ah)) { int reg_pmu_set; reg_pmu_set = REG_READ(ah, AR_PHY_PMU2) & ~AR_PHY_PMU2_PGM; @@ -3720,24 +3718,9 @@ static void ar9003_hw_internal_regulator_apply(struct ath_hw *ah) if (!is_pmu_set(ah, AR_PHY_PMU2, reg_pmu_set)) return; - if (AR_SREV_9330(ah)) { - if (ah->is_clk_25mhz) { - reg_pmu_set = (3 << 1) | (8 << 4) | - (3 << 8) | (1 << 14) | - (6 << 17) | (1 << 20) | - (3 << 24); - } else { - reg_pmu_set = (4 << 1) | (7 << 4) | - (3 << 8) | (1 << 14) | - (6 << 17) | (1 << 20) | - (3 << 24); - } - } else { - reg_pmu_set = (5 << 1) | (7 << 4) | - (1 << 8) | (2 << 14) | - (6 << 17) | (1 << 20) | - (3 << 24) | (1 << 28); - } + reg_pmu_set = (5 << 1) | (7 << 4) | (1 << 8) | + (2 << 14) | (6 << 17) | (1 << 20) | + (3 << 24) | (1 << 28); REG_WRITE(ah, AR_PHY_PMU1, reg_pmu_set); if (!is_pmu_set(ah, AR_PHY_PMU1, reg_pmu_set)) @@ -3768,7 +3751,7 @@ static void ar9003_hw_internal_regulator_apply(struct ath_hw *ah) AR_RTC_REG_CONTROL1_SWREG_PROGRAM); } } else { - if (AR_SREV_9330(ah) || AR_SREV_9485(ah)) { + if (AR_SREV_9485(ah)) { REG_RMW_FIELD(ah, AR_PHY_PMU2, AR_PHY_PMU2_PGM, 0); while (REG_READ_FIELD(ah, AR_PHY_PMU2, AR_PHY_PMU2_PGM)) @@ -3812,9 +3795,9 @@ static void ath9k_hw_ar9300_set_board_values(struct ath_hw *ah, ar9003_hw_ant_ctrl_apply(ah, IS_CHAN_2GHZ(chan)); ar9003_hw_drive_strength_apply(ah); ar9003_hw_atten_apply(ah, chan); - if (!AR_SREV_9330(ah) && !AR_SREV_9340(ah)) + if (!AR_SREV_9340(ah)) ar9003_hw_internal_regulator_apply(ah); - if (AR_SREV_9485(ah) || AR_SREV_9330(ah) || AR_SREV_9340(ah)) + if (AR_SREV_9485(ah) || AR_SREV_9340(ah)) ar9003_hw_apply_tuning_caps(ah); } diff --git a/trunk/drivers/net/wireless/ath/ath9k/ar9003_hw.c b/trunk/drivers/net/wireless/ath/ath9k/ar9003_hw.c index 8efdec247c02..392bf0f8ff16 100644 --- a/trunk/drivers/net/wireless/ath/ath9k/ar9003_hw.c +++ b/trunk/drivers/net/wireless/ath/ath9k/ar9003_hw.c @@ -19,8 +19,6 @@ #include "ar9003_2p2_initvals.h" #include "ar9485_initvals.h" #include "ar9340_initvals.h" -#include "ar9330_1p1_initvals.h" -#include "ar9330_1p2_initvals.h" /* General hardware code for the AR9003 hadware family */ @@ -31,113 +29,7 @@ */ static void ar9003_hw_init_mode_regs(struct ath_hw *ah) { - if (AR_SREV_9330_11(ah)) { - /* mac */ - INIT_INI_ARRAY(&ah->iniMac[ATH_INI_PRE], NULL, 0, 0); - INIT_INI_ARRAY(&ah->iniMac[ATH_INI_CORE], - ar9331_1p1_mac_core, - ARRAY_SIZE(ar9331_1p1_mac_core), 2); - INIT_INI_ARRAY(&ah->iniMac[ATH_INI_POST], - ar9331_1p1_mac_postamble, - ARRAY_SIZE(ar9331_1p1_mac_postamble), 5); - - /* bb */ - INIT_INI_ARRAY(&ah->iniBB[ATH_INI_PRE], NULL, 0, 0); - INIT_INI_ARRAY(&ah->iniBB[ATH_INI_CORE], - ar9331_1p1_baseband_core, - ARRAY_SIZE(ar9331_1p1_baseband_core), 2); - INIT_INI_ARRAY(&ah->iniBB[ATH_INI_POST], - ar9331_1p1_baseband_postamble, - ARRAY_SIZE(ar9331_1p1_baseband_postamble), 5); - - /* radio */ - INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_PRE], NULL, 0, 0); - INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_CORE], - ar9331_1p1_radio_core, - ARRAY_SIZE(ar9331_1p1_radio_core), 2); - INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_POST], NULL, 0, 0); - - /* soc */ - INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_PRE], - ar9331_1p1_soc_preamble, - ARRAY_SIZE(ar9331_1p1_soc_preamble), 2); - INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_CORE], NULL, 0, 0); - INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_POST], - ar9331_1p1_soc_postamble, - ARRAY_SIZE(ar9331_1p1_soc_postamble), 2); - - /* rx/tx gain */ - INIT_INI_ARRAY(&ah->iniModesRxGain, - ar9331_common_rx_gain_1p1, - ARRAY_SIZE(ar9331_common_rx_gain_1p1), 2); - INIT_INI_ARRAY(&ah->iniModesTxGain, - ar9331_modes_lowest_ob_db_tx_gain_1p1, - ARRAY_SIZE(ar9331_modes_lowest_ob_db_tx_gain_1p1), - 5); - - /* additional clock settings */ - if (ah->is_clk_25mhz) - INIT_INI_ARRAY(&ah->iniModesAdditional, - ar9331_1p1_xtal_25M, - ARRAY_SIZE(ar9331_1p1_xtal_25M), 2); - else - INIT_INI_ARRAY(&ah->iniModesAdditional, - ar9331_1p1_xtal_40M, - ARRAY_SIZE(ar9331_1p1_xtal_40M), 2); - } else if (AR_SREV_9330_12(ah)) { - /* mac */ - INIT_INI_ARRAY(&ah->iniMac[ATH_INI_PRE], NULL, 0, 0); - INIT_INI_ARRAY(&ah->iniMac[ATH_INI_CORE], - ar9331_1p2_mac_core, - ARRAY_SIZE(ar9331_1p2_mac_core), 2); - INIT_INI_ARRAY(&ah->iniMac[ATH_INI_POST], - ar9331_1p2_mac_postamble, - ARRAY_SIZE(ar9331_1p2_mac_postamble), 5); - - /* bb */ - INIT_INI_ARRAY(&ah->iniBB[ATH_INI_PRE], NULL, 0, 0); - INIT_INI_ARRAY(&ah->iniBB[ATH_INI_CORE], - ar9331_1p2_baseband_core, - ARRAY_SIZE(ar9331_1p2_baseband_core), 2); - INIT_INI_ARRAY(&ah->iniBB[ATH_INI_POST], - ar9331_1p2_baseband_postamble, - ARRAY_SIZE(ar9331_1p2_baseband_postamble), 5); - - /* radio */ - INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_PRE], NULL, 0, 0); - INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_CORE], - ar9331_1p2_radio_core, - ARRAY_SIZE(ar9331_1p2_radio_core), 2); - INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_POST], NULL, 0, 0); - - /* soc */ - INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_PRE], - ar9331_1p2_soc_preamble, - ARRAY_SIZE(ar9331_1p2_soc_preamble), 2); - INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_CORE], NULL, 0, 0); - INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_POST], - ar9331_1p2_soc_postamble, - ARRAY_SIZE(ar9331_1p2_soc_postamble), 2); - - /* rx/tx gain */ - INIT_INI_ARRAY(&ah->iniModesRxGain, - ar9331_common_rx_gain_1p2, - ARRAY_SIZE(ar9331_common_rx_gain_1p2), 2); - INIT_INI_ARRAY(&ah->iniModesTxGain, - ar9331_modes_lowest_ob_db_tx_gain_1p2, - ARRAY_SIZE(ar9331_modes_lowest_ob_db_tx_gain_1p2), - 5); - - /* additional clock settings */ - if (ah->is_clk_25mhz) - INIT_INI_ARRAY(&ah->iniModesAdditional, - ar9331_1p2_xtal_25M, - ARRAY_SIZE(ar9331_1p2_xtal_25M), 2); - else - INIT_INI_ARRAY(&ah->iniModesAdditional, - ar9331_1p2_xtal_40M, - ARRAY_SIZE(ar9331_1p2_xtal_40M), 2); - } else if (AR_SREV_9340(ah)) { + if (AR_SREV_9340(ah)) { /* mac */ INIT_INI_ARRAY(&ah->iniMac[ATH_INI_PRE], NULL, 0, 0); INIT_INI_ARRAY(&ah->iniMac[ATH_INI_CORE], @@ -328,17 +220,7 @@ static void ar9003_tx_gain_table_apply(struct ath_hw *ah) switch (ar9003_hw_get_tx_gain_idx(ah)) { case 0: default: - if (AR_SREV_9330_12(ah)) - INIT_INI_ARRAY(&ah->iniModesTxGain, - ar9331_modes_lowest_ob_db_tx_gain_1p2, - ARRAY_SIZE(ar9331_modes_lowest_ob_db_tx_gain_1p2), - 5); - else if (AR_SREV_9330_11(ah)) - INIT_INI_ARRAY(&ah->iniModesTxGain, - ar9331_modes_lowest_ob_db_tx_gain_1p1, - ARRAY_SIZE(ar9331_modes_lowest_ob_db_tx_gain_1p1), - 5); - else if (AR_SREV_9340(ah)) + if (AR_SREV_9340(ah)) INIT_INI_ARRAY(&ah->iniModesTxGain, ar9340Modes_lowest_ob_db_tx_gain_table_1p0, ARRAY_SIZE(ar9340Modes_lowest_ob_db_tx_gain_table_1p0), @@ -355,17 +237,7 @@ static void ar9003_tx_gain_table_apply(struct ath_hw *ah) 5); break; case 1: - if (AR_SREV_9330_12(ah)) - INIT_INI_ARRAY(&ah->iniModesTxGain, - ar9331_modes_high_ob_db_tx_gain_1p2, - ARRAY_SIZE(ar9331_modes_high_ob_db_tx_gain_1p2), - 5); - else if (AR_SREV_9330_11(ah)) - INIT_INI_ARRAY(&ah->iniModesTxGain, - ar9331_modes_high_ob_db_tx_gain_1p1, - ARRAY_SIZE(ar9331_modes_high_ob_db_tx_gain_1p1), - 5); - else if (AR_SREV_9340(ah)) + if (AR_SREV_9340(ah)) INIT_INI_ARRAY(&ah->iniModesTxGain, ar9340Modes_lowest_ob_db_tx_gain_table_1p0, ARRAY_SIZE(ar9340Modes_lowest_ob_db_tx_gain_table_1p0), @@ -382,17 +254,7 @@ static void ar9003_tx_gain_table_apply(struct ath_hw *ah) 5); break; case 2: - if (AR_SREV_9330_12(ah)) - INIT_INI_ARRAY(&ah->iniModesTxGain, - ar9331_modes_low_ob_db_tx_gain_1p2, - ARRAY_SIZE(ar9331_modes_low_ob_db_tx_gain_1p2), - 5); - else if (AR_SREV_9330_11(ah)) - INIT_INI_ARRAY(&ah->iniModesTxGain, - ar9331_modes_low_ob_db_tx_gain_1p1, - ARRAY_SIZE(ar9331_modes_low_ob_db_tx_gain_1p1), - 5); - else if (AR_SREV_9340(ah)) + if (AR_SREV_9340(ah)) INIT_INI_ARRAY(&ah->iniModesTxGain, ar9340Modes_lowest_ob_db_tx_gain_table_1p0, ARRAY_SIZE(ar9340Modes_lowest_ob_db_tx_gain_table_1p0), @@ -409,17 +271,7 @@ static void ar9003_tx_gain_table_apply(struct ath_hw *ah) 5); break; case 3: - if (AR_SREV_9330_12(ah)) - INIT_INI_ARRAY(&ah->iniModesTxGain, - ar9331_modes_high_power_tx_gain_1p2, - ARRAY_SIZE(ar9331_modes_high_power_tx_gain_1p2), - 5); - else if (AR_SREV_9330_11(ah)) - INIT_INI_ARRAY(&ah->iniModesTxGain, - ar9331_modes_high_power_tx_gain_1p1, - ARRAY_SIZE(ar9331_modes_high_power_tx_gain_1p1), - 5); - else if (AR_SREV_9340(ah)) + if (AR_SREV_9340(ah)) INIT_INI_ARRAY(&ah->iniModesTxGain, ar9340Modes_lowest_ob_db_tx_gain_table_1p0, ARRAY_SIZE(ar9340Modes_lowest_ob_db_tx_gain_table_1p0), @@ -443,17 +295,7 @@ static void ar9003_rx_gain_table_apply(struct ath_hw *ah) switch (ar9003_hw_get_rx_gain_idx(ah)) { case 0: default: - if (AR_SREV_9330_12(ah)) - INIT_INI_ARRAY(&ah->iniModesRxGain, - ar9331_common_rx_gain_1p2, - ARRAY_SIZE(ar9331_common_rx_gain_1p2), - 2); - else if (AR_SREV_9330_11(ah)) - INIT_INI_ARRAY(&ah->iniModesRxGain, - ar9331_common_rx_gain_1p1, - ARRAY_SIZE(ar9331_common_rx_gain_1p1), - 2); - else if (AR_SREV_9340(ah)) + if (AR_SREV_9340(ah)) INIT_INI_ARRAY(&ah->iniModesRxGain, ar9340Common_rx_gain_table_1p0, ARRAY_SIZE(ar9340Common_rx_gain_table_1p0), @@ -470,17 +312,7 @@ static void ar9003_rx_gain_table_apply(struct ath_hw *ah) 2); break; case 1: - if (AR_SREV_9330_12(ah)) - INIT_INI_ARRAY(&ah->iniModesRxGain, - ar9331_common_wo_xlna_rx_gain_1p2, - ARRAY_SIZE(ar9331_common_wo_xlna_rx_gain_1p2), - 2); - else if (AR_SREV_9330_11(ah)) - INIT_INI_ARRAY(&ah->iniModesRxGain, - ar9331_common_wo_xlna_rx_gain_1p1, - ARRAY_SIZE(ar9331_common_wo_xlna_rx_gain_1p1), - 2); - else if (AR_SREV_9340(ah)) + if (AR_SREV_9340(ah)) INIT_INI_ARRAY(&ah->iniModesRxGain, ar9340Common_wo_xlna_rx_gain_table_1p0, ARRAY_SIZE(ar9340Common_wo_xlna_rx_gain_table_1p0), diff --git a/trunk/drivers/net/wireless/ath/ath9k/ar9003_mac.c b/trunk/drivers/net/wireless/ath/ath9k/ar9003_mac.c index 575e185f454f..04e6be04acf9 100644 --- a/trunk/drivers/net/wireless/ath/ath9k/ar9003_mac.c +++ b/trunk/drivers/net/wireless/ath/ath9k/ar9003_mac.c @@ -229,7 +229,6 @@ static void ar9003_hw_fill_txdesc(struct ath_hw *ah, void *ds, u32 seglen, static int ar9003_hw_proc_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_status *ts) { - struct ar9003_txc *txc = (struct ar9003_txc *) ds; struct ar9003_txs *ads; u32 status; @@ -239,11 +238,7 @@ static int ar9003_hw_proc_txdesc(struct ath_hw *ah, void *ds, if ((status & AR_TxDone) == 0) return -EINPROGRESS; - ts->qid = MS(ads->ds_info, AR_TxQcuNum); - if (!txc || (MS(txc->info, AR_TxQcuNum) == ts->qid)) - ah->ts_tail = (ah->ts_tail + 1) % ah->ts_size; - else - return -ENOENT; + ah->ts_tail = (ah->ts_tail + 1) % ah->ts_size; if ((MS(ads->ds_info, AR_DescId) != ATHEROS_VENDOR_ID) || (MS(ads->ds_info, AR_TxRxDesc) != 1)) { @@ -259,6 +254,7 @@ static int ar9003_hw_proc_txdesc(struct ath_hw *ah, void *ds, ts->ts_seqnum = MS(status, AR_SeqNum); ts->tid = MS(status, AR_TxTid); + ts->qid = MS(ads->ds_info, AR_TxQcuNum); ts->desc_id = MS(ads->status1, AR_TxDescId); ts->ts_tstamp = ads->status4; ts->ts_status = 0; diff --git a/trunk/drivers/net/wireless/ath/ath9k/ar9003_paprd.c b/trunk/drivers/net/wireless/ath/ath9k/ar9003_paprd.c index de1972307b0a..2e7f0f2567eb 100644 --- a/trunk/drivers/net/wireless/ath/ath9k/ar9003_paprd.c +++ b/trunk/drivers/net/wireless/ath/ath9k/ar9003_paprd.c @@ -83,23 +83,7 @@ static int ar9003_get_training_power_5g(struct ath_hw *ah) if (delta > scale) return -1; - switch (get_streams(common->tx_chainmask)) { - case 1: - delta = 6; - break; - case 2: - delta = 4; - break; - case 3: - delta = 2; - break; - default: - delta = 0; - ath_dbg(common, ATH_DBG_CALIBRATE, - "Invalid tx-chainmask: %u\n", common->tx_chainmask); - } - - power += delta; + power += 2 * get_streams(common->tx_chainmask); return power; } @@ -236,7 +220,7 @@ static void ar9003_paprd_get_gain_table(struct ath_hw *ah) memset(entry, 0, sizeof(ah->paprd_gain_table_entries)); memset(index, 0, sizeof(ah->paprd_gain_table_index)); - for (i = 0; i < PAPRD_GAIN_TABLE_ENTRIES; i++) { + for (i = 0; i < 32; i++) { entry[i] = REG_READ(ah, reg); index[i] = (entry[i] >> 24) & 0xff; reg += 4; @@ -246,13 +230,13 @@ static void ar9003_paprd_get_gain_table(struct ath_hw *ah) static unsigned int ar9003_get_desired_gain(struct ath_hw *ah, int chain, int target_power) { - int olpc_gain_delta = 0, cl_gain_mod; + int olpc_gain_delta = 0; int alpha_therm, alpha_volt; int therm_cal_value, volt_cal_value; int therm_value, volt_value; int thermal_gain_corr, voltage_gain_corr; int desired_scale, desired_gain = 0; - u32 reg_olpc = 0, reg_cl_gain = 0; + u32 reg; REG_CLR_BIT(ah, AR_PHY_PAPRD_TRAINER_STAT1, AR_PHY_PAPRD_TRAINER_STAT1_PAPRD_TRAIN_DONE); @@ -271,29 +255,15 @@ static unsigned int ar9003_get_desired_gain(struct ath_hw *ah, int chain, volt_value = REG_READ_FIELD(ah, AR_PHY_BB_THERM_ADC_4, AR_PHY_BB_THERM_ADC_4_LATEST_VOLT_VALUE); - switch (chain) { - case 0: - reg_olpc = AR_PHY_TPC_11_B0; - reg_cl_gain = AR_PHY_CL_TAB_0; - break; - case 1: - reg_olpc = AR_PHY_TPC_11_B1; - reg_cl_gain = AR_PHY_CL_TAB_1; - break; - case 2: - reg_olpc = AR_PHY_TPC_11_B2; - reg_cl_gain = AR_PHY_CL_TAB_2; - break; - default: - ath_dbg(ath9k_hw_common(ah), ATH_DBG_CALIBRATE, - "Invalid chainmask: %d\n", chain); - break; - } + if (chain == 0) + reg = AR_PHY_TPC_11_B0; + else if (chain == 1) + reg = AR_PHY_TPC_11_B1; + else + reg = AR_PHY_TPC_11_B2; - olpc_gain_delta = REG_READ_FIELD(ah, reg_olpc, + olpc_gain_delta = REG_READ_FIELD(ah, reg, AR_PHY_TPC_11_OLPC_GAIN_DELTA); - cl_gain_mod = REG_READ_FIELD(ah, reg_cl_gain, - AR_PHY_CL_TAB_CL_GAIN_MOD); if (olpc_gain_delta >= 128) olpc_gain_delta = olpc_gain_delta - 256; @@ -303,7 +273,7 @@ static unsigned int ar9003_get_desired_gain(struct ath_hw *ah, int chain, voltage_gain_corr = (alpha_volt * (volt_value - volt_cal_value) + (128 / 2)) / 128; desired_gain = target_power - olpc_gain_delta - thermal_gain_corr - - voltage_gain_corr + desired_scale + cl_gain_mod; + voltage_gain_corr + desired_scale; return desired_gain; } @@ -741,7 +711,7 @@ int ar9003_paprd_setup_gain_table(struct ath_hw *ah, int chain) desired_gain = ar9003_get_desired_gain(ah, chain, train_power); gain_index = 0; - for (i = 0; i < PAPRD_GAIN_TABLE_ENTRIES; i++) { + for (i = 0; i < 32; i++) { if (ah->paprd_gain_table_index[i] >= desired_gain) break; gain_index++; @@ -815,26 +785,7 @@ EXPORT_SYMBOL(ar9003_paprd_init_table); bool ar9003_paprd_is_done(struct ath_hw *ah) { - int paprd_done, agc2_pwr; - paprd_done = REG_READ_FIELD(ah, AR_PHY_PAPRD_TRAINER_STAT1, + return !!REG_READ_FIELD(ah, AR_PHY_PAPRD_TRAINER_STAT1, AR_PHY_PAPRD_TRAINER_STAT1_PAPRD_TRAIN_DONE); - - if (paprd_done == 0x1) { - agc2_pwr = REG_READ_FIELD(ah, AR_PHY_PAPRD_TRAINER_STAT1, - AR_PHY_PAPRD_TRAINER_STAT1_PAPRD_AGC2_PWR); - - ath_dbg(ath9k_hw_common(ah), ATH_DBG_CALIBRATE, - "AGC2_PWR = 0x%x training done = 0x%x\n", - agc2_pwr, paprd_done); - /* - * agc2_pwr range should not be less than 'IDEAL_AGC2_PWR_CHANGE' - * when the training is completely done, otherwise retraining is - * done to make sure the value is in ideal range - */ - if (agc2_pwr <= PAPRD_IDEAL_AGC2_PWR_RANGE) - paprd_done = 0; - } - - return !!paprd_done; } EXPORT_SYMBOL(ar9003_paprd_is_done); diff --git a/trunk/drivers/net/wireless/ath/ath9k/ar9003_phy.c b/trunk/drivers/net/wireless/ath/ath9k/ar9003_phy.c index 1baca8e4715d..892c48b15434 100644 --- a/trunk/drivers/net/wireless/ath/ath9k/ar9003_phy.c +++ b/trunk/drivers/net/wireless/ath/ath9k/ar9003_phy.c @@ -75,19 +75,7 @@ static int ar9003_hw_set_channel(struct ath_hw *ah, struct ath9k_channel *chan) freq = centers.synth_center; if (freq < 4800) { /* 2 GHz, fractional mode */ - if (AR_SREV_9330(ah)) { - u32 chan_frac; - u32 div; - - if (ah->is_clk_25mhz) - div = 75; - else - div = 120; - - channelSel = (freq * 4) / div; - chan_frac = (((freq * 4) % div) * 0x20000) / div; - channelSel = (channelSel << 17) | chan_frac; - } else if (AR_SREV_9485(ah)) { + if (AR_SREV_9485(ah)) { u32 chan_frac; /* @@ -116,7 +104,7 @@ static int ar9003_hw_set_channel(struct ath_hw *ah, struct ath9k_channel *chan) u32 chan_frac; channelSel = (freq * 2) / 75; - chan_frac = (((freq * 2) % 75) * 0x20000) / 75; + chan_frac = ((freq % 75) * 0x20000) / 75; channelSel = (channelSel << 17) | chan_frac; } else { channelSel = CHANSEL_5G(freq); @@ -180,7 +168,7 @@ static void ar9003_hw_spur_mitigate_mrc_cck(struct ath_hw *ah, * is out-of-band and can be ignored. */ - if (AR_SREV_9485(ah) || AR_SREV_9340(ah) || AR_SREV_9330(ah)) { + if (AR_SREV_9485(ah) || AR_SREV_9340(ah)) { spur_fbin_ptr = ar9003_get_spur_chan_ptr(ah, IS_CHAN_2GHZ(chan)); if (spur_fbin_ptr[0] == 0) /* No spur */ @@ -205,7 +193,7 @@ static void ar9003_hw_spur_mitigate_mrc_cck(struct ath_hw *ah, for (i = 0; i < max_spur_cnts; i++) { negative = 0; - if (AR_SREV_9485(ah) || AR_SREV_9340(ah) || AR_SREV_9330(ah)) + if (AR_SREV_9485(ah) || AR_SREV_9340(ah)) cur_bb_spur = FBIN2FREQ(spur_fbin_ptr[i], IS_CHAN_2GHZ(chan)) - synth_freq; else @@ -671,9 +659,6 @@ static int ar9003_hw_process_ini(struct ath_hw *ah, REG_WRITE_ARRAY(&ah->iniModesAdditional, modesIndex, regWrites); - if (AR_SREV_9300(ah)) - REG_WRITE_ARRAY(&ah->iniModesAdditional, 1, regWrites); - if (AR_SREV_9340(ah) && !ah->is_clk_25mhz) REG_WRITE_ARRAY(&ah->iniModesAdditional_40M, 1, regWrites); @@ -1089,10 +1074,7 @@ static void ar9003_hw_set_nf_limits(struct ath_hw *ah) { ah->nf_2g.max = AR_PHY_CCA_MAX_GOOD_VAL_9300_2GHZ; ah->nf_2g.min = AR_PHY_CCA_MIN_GOOD_VAL_9300_2GHZ; - if (AR_SREV_9330(ah)) - ah->nf_2g.nominal = AR_PHY_CCA_NOM_VAL_9330_2GHZ; - else - ah->nf_2g.nominal = AR_PHY_CCA_NOM_VAL_9300_2GHZ; + ah->nf_2g.nominal = AR_PHY_CCA_NOM_VAL_9300_2GHZ; ah->nf_5g.max = AR_PHY_CCA_MAX_GOOD_VAL_9300_5GHZ; ah->nf_5g.min = AR_PHY_CCA_MIN_GOOD_VAL_9300_5GHZ; ah->nf_5g.nominal = AR_PHY_CCA_NOM_VAL_9300_5GHZ; @@ -1214,17 +1196,8 @@ static void ar9003_hw_antdiv_comb_conf_get(struct ath_hw *ah, AR_PHY_9485_ANT_DIV_ALT_LNACONF_S; antconf->fast_div_bias = (regval & AR_PHY_9485_ANT_FAST_DIV_BIAS) >> AR_PHY_9485_ANT_FAST_DIV_BIAS_S; - - if (AR_SREV_9330_11(ah)) { - antconf->lna1_lna2_delta = -9; - antconf->div_group = 1; - } else if (AR_SREV_9485(ah)) { - antconf->lna1_lna2_delta = -9; - antconf->div_group = 2; - } else { - antconf->lna1_lna2_delta = -3; - antconf->div_group = 0; - } + antconf->lna1_lna2_delta = -9; + antconf->div_group = 2; } static void ar9003_hw_antdiv_comb_conf_set(struct ath_hw *ah, diff --git a/trunk/drivers/net/wireless/ath/ath9k/ar9003_phy.h b/trunk/drivers/net/wireless/ath/ath9k/ar9003_phy.h index 6de3f0bc18e6..443090d278e3 100644 --- a/trunk/drivers/net/wireless/ath/ath9k/ar9003_phy.h +++ b/trunk/drivers/net/wireless/ath/ath9k/ar9003_phy.h @@ -332,8 +332,6 @@ #define AR_PHY_CCA_MAX_GOOD_VAL_9300_2GHZ -95 #define AR_PHY_CCA_MAX_GOOD_VAL_9300_5GHZ -100 -#define AR_PHY_CCA_NOM_VAL_9330_2GHZ -118 - /* * AGC Field Definitions */ @@ -625,11 +623,11 @@ #define AR_PHY_65NM_CH2_RXTX1 0x16900 #define AR_PHY_65NM_CH2_RXTX2 0x16904 -#define AR_CH0_TOP2 (AR_SREV_9300(ah) ? 0x1628c : 0x16284) +#define AR_CH0_TOP2 (AR_SREV_9485(ah) ? 0x00016284 : 0x0001628c) #define AR_CH0_TOP2_XPABIASLVL 0xf000 #define AR_CH0_TOP2_XPABIASLVL_S 12 -#define AR_CH0_XTAL (AR_SREV_9300(ah) ? 0x16294 : 0x16290) +#define AR_CH0_XTAL (AR_SREV_9485(ah) ? 0x16290 : 0x16294) #define AR_CH0_XTAL_CAPINDAC 0x7f000000 #define AR_CH0_XTAL_CAPINDAC_S 24 #define AR_CH0_XTAL_CAPOUTDAC 0x00fe0000 @@ -1121,9 +1119,6 @@ #define AR_PHY_POWERTX_RATE8_POWERTXHT40_5 0x3F00 #define AR_PHY_POWERTX_RATE8_POWERTXHT40_5_S 8 -#define AR_PHY_CL_TAB_CL_GAIN_MOD 0x1f -#define AR_PHY_CL_TAB_CL_GAIN_MOD_S 0 - void ar9003_hw_set_chain_masks(struct ath_hw *ah, u8 rx, u8 tx); #endif /* AR9003_PHY_H */ diff --git a/trunk/drivers/net/wireless/ath/ath9k/ar9330_1p1_initvals.h b/trunk/drivers/net/wireless/ath/ath9k/ar9330_1p1_initvals.h deleted file mode 100644 index f11d9b2677fd..000000000000 --- a/trunk/drivers/net/wireless/ath/ath9k/ar9330_1p1_initvals.h +++ /dev/null @@ -1,1147 +0,0 @@ -/* - * Copyright (c) 2011 Atheros Communications Inc. - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef INITVALS_9330_1P1_H -#define INITVALS_9330_1P1_H - -static const u32 ar9331_1p1_baseband_postamble[][5] = { - /* Addr 5G_HT20 5G_HT40 2G_HT40 2G_HT20 */ - {0x00009810, 0xd00a8005, 0xd00a8005, 0xd00a8005, 0xd00a8005}, - {0x00009820, 0x206a002e, 0x206a002e, 0x206a002e, 0x206a002e}, - {0x00009824, 0x5ac640d0, 0x5ac640d0, 0x5ac640d0, 0x5ac640d0}, - {0x00009828, 0x06903081, 0x06903081, 0x06903881, 0x06903881}, - {0x0000982c, 0x05eea6d4, 0x05eea6d4, 0x05eea6d4, 0x05eea6d4}, - {0x00009830, 0x0000059c, 0x0000059c, 0x0000059c, 0x0000059c}, - {0x00009c00, 0x00000044, 0x00000044, 0x00000044, 0x00000044}, - {0x00009e00, 0x0372161e, 0x0372161e, 0x037216a4, 0x037216a4}, - {0x00009e04, 0x00182020, 0x00182020, 0x00182020, 0x00182020}, - {0x00009e0c, 0x6c4000e2, 0x6d4000e2, 0x6d4000e2, 0x6c4000e2}, - {0x00009e10, 0x7ec80d2e, 0x7ec80d2e, 0x7ec80d2e, 0x7ec80d2e}, - {0x00009e14, 0x31395d5e, 0x3139605e, 0x3139605e, 0x31395d5e}, - {0x00009e18, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x00009e1c, 0x0001cf9c, 0x0001cf9c, 0x00021f9c, 0x00021f9c}, - {0x00009e20, 0x000003b5, 0x000003b5, 0x000003ce, 0x000003ce}, - {0x00009e2c, 0x0000001c, 0x0000001c, 0x00003221, 0x00003221}, - {0x00009e3c, 0xcf946222, 0xcf946222, 0xcf946222, 0xcf946222}, - {0x00009e44, 0x02321e27, 0x02321e27, 0x02282324, 0x02282324}, - {0x00009e48, 0x5030201a, 0x5030201a, 0x50302010, 0x50302010}, - {0x00009fc8, 0x0003f000, 0x0003f000, 0x0001a000, 0x0001a000}, - {0x0000a204, 0x00003fc0, 0x00003fc4, 0x00003fc4, 0x00003fc0}, - {0x0000a208, 0x00000104, 0x00000104, 0x00000004, 0x00000004}, - {0x0000a230, 0x0000000a, 0x00000014, 0x00000016, 0x0000000b}, - {0x0000a234, 0x00000fff, 0x00000fff, 0x10000fff, 0x00000fff}, - {0x0000a238, 0xffb81018, 0xffb81018, 0xffb81018, 0xffb81018}, - {0x0000a250, 0x00000000, 0x00000000, 0x00000210, 0x00000108}, - {0x0000a254, 0x000007d0, 0x00000fa0, 0x00001130, 0x00000898}, - {0x0000a258, 0x02020002, 0x02020002, 0x02020002, 0x02020002}, - {0x0000a25c, 0x01000e0e, 0x01000e0e, 0x01000e0e, 0x01000e0e}, - {0x0000a260, 0x3a021501, 0x3a021501, 0x3a021501, 0x3a021501}, - {0x0000a264, 0x00000e0e, 0x00000e0e, 0x00000e0e, 0x00000e0e}, - {0x0000a280, 0x00000007, 0x00000007, 0x0000000b, 0x0000000b}, - {0x0000a284, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x0000a288, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x0000a28c, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x0000a2c4, 0x00158d18, 0x00158d18, 0x00158d18, 0x00158d18}, - {0x0000a2d0, 0x00071981, 0x00071981, 0x00071981, 0x00071981}, - {0x0000a2d8, 0xf999a83a, 0xf999a83a, 0xf999a83a, 0xf999a83a}, - {0x0000a358, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x0000ae04, 0x00802020, 0x00802020, 0x00802020, 0x00802020}, - {0x0000ae18, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, -}; - -static const u32 ar9331_modes_lowest_ob_db_tx_gain_1p1[][5] = { - /* Addr 5G_HT20 5G_HT40 2G_HT40 2G_HT20 */ - {0x0000a2d8, 0x7999a83a, 0x7999a83a, 0x7999a83a, 0x7999a83a}, - {0x0000a2dc, 0xffff2a52, 0xffff2a52, 0xffff2a52, 0xffff2a52}, - {0x0000a2e0, 0xffffcc84, 0xffffcc84, 0xffffcc84, 0xffffcc84}, - {0x0000a2e4, 0xfffff000, 0xfffff000, 0xfffff000, 0xfffff000}, - {0x0000a2e8, 0xfffe0000, 0xfffe0000, 0xfffe0000, 0xfffe0000}, - {0x0000a410, 0x000050d7, 0x000050d7, 0x000050d0, 0x000050d0}, - {0x0000a500, 0x00022200, 0x00022200, 0x00000000, 0x00000000}, - {0x0000a504, 0x05062002, 0x05062002, 0x04000002, 0x04000002}, - {0x0000a508, 0x0c002e00, 0x0c002e00, 0x08000004, 0x08000004}, - {0x0000a50c, 0x11062202, 0x11062202, 0x0d000200, 0x0d000200}, - {0x0000a510, 0x17022e00, 0x17022e00, 0x11000202, 0x11000202}, - {0x0000a514, 0x1d000ec2, 0x1d000ec2, 0x15000400, 0x15000400}, - {0x0000a518, 0x25020ec0, 0x25020ec0, 0x19000402, 0x19000402}, - {0x0000a51c, 0x2b020ec3, 0x2b020ec3, 0x1d000404, 0x1d000404}, - {0x0000a520, 0x2f001f04, 0x2f001f04, 0x23000a00, 0x23000a00}, - {0x0000a524, 0x35001fc4, 0x35001fc4, 0x27000a02, 0x27000a02}, - {0x0000a528, 0x3c022f04, 0x3c022f04, 0x2b000a04, 0x2b000a04}, - {0x0000a52c, 0x41023e85, 0x41023e85, 0x2d000a20, 0x2d000a20}, - {0x0000a530, 0x48023ec6, 0x48023ec6, 0x31000a22, 0x31000a22}, - {0x0000a534, 0x4d023f01, 0x4d023f01, 0x35000a24, 0x35000a24}, - {0x0000a538, 0x53023f4b, 0x53023f4b, 0x38000a43, 0x38000a43}, - {0x0000a53c, 0x5a027f09, 0x5a027f09, 0x3b000e42, 0x3b000e42}, - {0x0000a540, 0x5f027fc9, 0x5f027fc9, 0x3f000e44, 0x3f000e44}, - {0x0000a544, 0x6502feca, 0x6502feca, 0x42000e64, 0x42000e64}, - {0x0000a548, 0x6b02ff4a, 0x6b02ff4a, 0x46000e66, 0x46000e66}, - {0x0000a54c, 0x7203feca, 0x7203feca, 0x4a000ea6, 0x4a000ea6}, - {0x0000a550, 0x7703ff0b, 0x7703ff0b, 0x4a000ea6, 0x4a000ea6}, - {0x0000a554, 0x7d06ffcb, 0x7d06ffcb, 0x4a000ea6, 0x4a000ea6}, - {0x0000a558, 0x8407ff0b, 0x8407ff0b, 0x4a000ea6, 0x4a000ea6}, - {0x0000a55c, 0x8907ffcb, 0x8907ffcb, 0x4a000ea6, 0x4a000ea6}, - {0x0000a560, 0x900fff0b, 0x900fff0b, 0x4a000ea6, 0x4a000ea6}, - {0x0000a564, 0x960fffcb, 0x960fffcb, 0x4a000ea6, 0x4a000ea6}, - {0x0000a568, 0x9c1fff0b, 0x9c1fff0b, 0x4a000ea6, 0x4a000ea6}, - {0x0000a56c, 0x9c1fff0b, 0x9c1fff0b, 0x4a000ea6, 0x4a000ea6}, - {0x0000a570, 0x9c1fff0b, 0x9c1fff0b, 0x4a000ea6, 0x4a000ea6}, - {0x0000a574, 0x9c1fff0b, 0x9c1fff0b, 0x4a000ea6, 0x4a000ea6}, - {0x0000a578, 0x9c1fff0b, 0x9c1fff0b, 0x4a000ea6, 0x4a000ea6}, - {0x0000a57c, 0x9c1fff0b, 0x9c1fff0b, 0x4a000ea6, 0x4a000ea6}, - {0x0000a580, 0x00022200, 0x00022200, 0x00000000, 0x00000000}, - {0x0000a584, 0x05062002, 0x05062002, 0x04000002, 0x04000002}, - {0x0000a588, 0x0c002e00, 0x0c002e00, 0x08000004, 0x08000004}, - {0x0000a58c, 0x11062202, 0x11062202, 0x0b000200, 0x0b000200}, - {0x0000a590, 0x17022e00, 0x17022e00, 0x0f000202, 0x0f000202}, - {0x0000a594, 0x1d000ec2, 0x1d000ec2, 0x11000400, 0x11000400}, - {0x0000a598, 0x25020ec0, 0x25020ec0, 0x15000402, 0x15000402}, - {0x0000a59c, 0x2b020ec3, 0x2b020ec3, 0x19000404, 0x19000404}, - {0x0000a5a0, 0x2f001f04, 0x2f001f04, 0x1b000603, 0x1b000603}, - {0x0000a5a4, 0x35001fc4, 0x35001fc4, 0x1f000a02, 0x1f000a02}, - {0x0000a5a8, 0x3c022f04, 0x3c022f04, 0x23000a04, 0x23000a04}, - {0x0000a5ac, 0x41023e85, 0x41023e85, 0x26000a20, 0x26000a20}, - {0x0000a5b0, 0x48023ec6, 0x48023ec6, 0x2a000e20, 0x2a000e20}, - {0x0000a5b4, 0x4d023f01, 0x4d023f01, 0x2e000e22, 0x2e000e22}, - {0x0000a5b8, 0x53023f4b, 0x53023f4b, 0x31000e24, 0x31000e24}, - {0x0000a5bc, 0x5a027f09, 0x5a027f09, 0x34001640, 0x34001640}, - {0x0000a5c0, 0x5f027fc9, 0x5f027fc9, 0x38001660, 0x38001660}, - {0x0000a5c4, 0x6502feca, 0x6502feca, 0x3b001861, 0x3b001861}, - {0x0000a5c8, 0x6b02ff4a, 0x6b02ff4a, 0x3e001a81, 0x3e001a81}, - {0x0000a5cc, 0x7203feca, 0x7203feca, 0x42001a83, 0x42001a83}, - {0x0000a5d0, 0x7703ff0b, 0x7703ff0b, 0x44001c84, 0x44001c84}, - {0x0000a5d4, 0x7d06ffcb, 0x7d06ffcb, 0x48001ce3, 0x48001ce3}, - {0x0000a5d8, 0x8407ff0b, 0x8407ff0b, 0x4c001ce5, 0x4c001ce5}, - {0x0000a5dc, 0x8907ffcb, 0x8907ffcb, 0x50001ce9, 0x50001ce9}, - {0x0000a5e0, 0x900fff0b, 0x900fff0b, 0x54001ceb, 0x54001ceb}, - {0x0000a5e4, 0x960fffcb, 0x960fffcb, 0x56001eec, 0x56001eec}, - {0x0000a5e8, 0x9c1fff0b, 0x9c1fff0b, 0x56001eec, 0x56001eec}, - {0x0000a5ec, 0x9c1fff0b, 0x9c1fff0b, 0x56001eec, 0x56001eec}, - {0x0000a5f0, 0x9c1fff0b, 0x9c1fff0b, 0x56001eec, 0x56001eec}, - {0x0000a5f4, 0x9c1fff0b, 0x9c1fff0b, 0x56001eec, 0x56001eec}, - {0x0000a5f8, 0x9c1fff0b, 0x9c1fff0b, 0x56001eec, 0x56001eec}, - {0x0000a5fc, 0x9c1fff0b, 0x9c1fff0b, 0x56001eec, 0x56001eec}, - {0x0000a600, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x0000a604, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x0000a608, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x0000a60c, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x0000a610, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x0000a614, 0x01404000, 0x01404000, 0x01404000, 0x01404000}, - {0x0000a618, 0x01404501, 0x01404501, 0x01404501, 0x01404501}, - {0x0000a61c, 0x02008802, 0x02008802, 0x02008802, 0x02008802}, - {0x0000a620, 0x0280c802, 0x0280c802, 0x0280c802, 0x0280c802}, - {0x0000a624, 0x03010a03, 0x03010a03, 0x03010a03, 0x03010a03}, - {0x0000a628, 0x03010c04, 0x03010c04, 0x03010c04, 0x03010c04}, - {0x0000a62c, 0x03010c04, 0x03010c04, 0x03010c04, 0x03010c04}, - {0x0000a630, 0x03010c04, 0x03010c04, 0x03010c04, 0x03010c04}, - {0x0000a634, 0x03010c04, 0x03010c04, 0x03010c04, 0x03010c04}, - {0x0000a638, 0x03010c04, 0x03010c04, 0x03010c04, 0x03010c04}, - {0x0000a63c, 0x03010c04, 0x03010c04, 0x03010c04, 0x03010c04}, - {0x00016044, 0x034922db, 0x034922db, 0x034922db, 0x034922db}, - {0x00016284, 0x14d3f000, 0x14d3f000, 0x14d3f000, 0x14d3f000}, -}; - -static const u32 ar9331_modes_high_ob_db_tx_gain_1p1[][5] = { - /* Addr 5G_HT20 5G_HT40 2G_HT40 2G_HT20 */ - {0x0000a2d8, 0x7999a83a, 0x7999a83a, 0x7999a83a, 0x7999a83a}, - {0x0000a2dc, 0xffaa9a52, 0xffaa9a52, 0xffaa9a52, 0xffaa9a52}, - {0x0000a2e0, 0xffb31c84, 0xffb31c84, 0xffb31c84, 0xffb31c84}, - {0x0000a2e4, 0xff43e000, 0xff43e000, 0xff43e000, 0xff43e000}, - {0x0000a2e8, 0xfffc0000, 0xfffc0000, 0xfffc0000, 0xfffc0000}, - {0x0000a410, 0x000050d7, 0x000050d7, 0x000050d7, 0x000050d7}, - {0x0000a500, 0x00022200, 0x00022200, 0x00000000, 0x00000000}, - {0x0000a504, 0x05062002, 0x05062002, 0x04000002, 0x04000002}, - {0x0000a508, 0x0c002e00, 0x0c002e00, 0x08000004, 0x08000004}, - {0x0000a50c, 0x11062202, 0x11062202, 0x0d000200, 0x0d000200}, - {0x0000a510, 0x17022e00, 0x17022e00, 0x11000202, 0x11000202}, - {0x0000a514, 0x1d000ec2, 0x1d000ec2, 0x15000400, 0x15000400}, - {0x0000a518, 0x25020ec0, 0x25020ec0, 0x19000402, 0x19000402}, - {0x0000a51c, 0x2b020ec3, 0x2b020ec3, 0x1d000404, 0x1d000404}, - {0x0000a520, 0x2f001f04, 0x2f001f04, 0x23000a00, 0x23000a00}, - {0x0000a524, 0x35001fc4, 0x35001fc4, 0x27000a02, 0x27000a02}, - {0x0000a528, 0x3c022f04, 0x3c022f04, 0x2b000a04, 0x2b000a04}, - {0x0000a52c, 0x41023e85, 0x41023e85, 0x3d001620, 0x3d001620}, - {0x0000a530, 0x48023ec6, 0x48023ec6, 0x3f001621, 0x3f001621}, - {0x0000a534, 0x4d023f01, 0x4d023f01, 0x42001640, 0x42001640}, - {0x0000a538, 0x53023f4b, 0x53023f4b, 0x44001641, 0x44001641}, - {0x0000a53c, 0x5a027f09, 0x5a027f09, 0x46001642, 0x46001642}, - {0x0000a540, 0x5f027fc9, 0x5f027fc9, 0x49001644, 0x49001644}, - {0x0000a544, 0x6502feca, 0x6502feca, 0x4c001a81, 0x4c001a81}, - {0x0000a548, 0x6b02ff4a, 0x6b02ff4a, 0x4f001a83, 0x4f001a83}, - {0x0000a54c, 0x7203feca, 0x7203feca, 0x52001c84, 0x52001c84}, - {0x0000a550, 0x7703ff0b, 0x7703ff0b, 0x55001ce3, 0x55001ce3}, - {0x0000a554, 0x7d06ffcb, 0x7d06ffcb, 0x59001ce5, 0x59001ce5}, - {0x0000a558, 0x8407ff0b, 0x8407ff0b, 0x5d001ce9, 0x5d001ce9}, - {0x0000a55c, 0x8907ffcb, 0x8907ffcb, 0x64001eec, 0x64001eec}, - {0x0000a560, 0x900fff0b, 0x900fff0b, 0x64001eec, 0x64001eec}, - {0x0000a564, 0x960fffcb, 0x960fffcb, 0x64001eec, 0x64001eec}, - {0x0000a568, 0x9c1fff0b, 0x9c1fff0b, 0x64001eec, 0x64001eec}, - {0x0000a56c, 0x9c1fff0b, 0x9c1fff0b, 0x64001eec, 0x64001eec}, - {0x0000a570, 0x9c1fff0b, 0x9c1fff0b, 0x64001eec, 0x64001eec}, - {0x0000a574, 0x9c1fff0b, 0x9c1fff0b, 0x64001eec, 0x64001eec}, - {0x0000a578, 0x9c1fff0b, 0x9c1fff0b, 0x64001eec, 0x64001eec}, - {0x0000a57c, 0x9c1fff0b, 0x9c1fff0b, 0x64001eec, 0x64001eec}, - {0x0000a580, 0x00022200, 0x00022200, 0x00000000, 0x00000000}, - {0x0000a584, 0x05062002, 0x05062002, 0x04000002, 0x04000002}, - {0x0000a588, 0x0c002e00, 0x0c002e00, 0x08000004, 0x08000004}, - {0x0000a58c, 0x11062202, 0x11062202, 0x0b000200, 0x0b000200}, - {0x0000a590, 0x17022e00, 0x17022e00, 0x0f000202, 0x0f000202}, - {0x0000a594, 0x1d000ec2, 0x1d000ec2, 0x11000400, 0x11000400}, - {0x0000a598, 0x25020ec0, 0x25020ec0, 0x15000402, 0x15000402}, - {0x0000a59c, 0x2b020ec3, 0x2b020ec3, 0x19000404, 0x19000404}, - {0x0000a5a0, 0x2f001f04, 0x2f001f04, 0x1b000603, 0x1b000603}, - {0x0000a5a4, 0x35001fc4, 0x35001fc4, 0x1f000a02, 0x1f000a02}, - {0x0000a5a8, 0x3c022f04, 0x3c022f04, 0x23000a04, 0x23000a04}, - {0x0000a5ac, 0x41023e85, 0x41023e85, 0x26000a20, 0x26000a20}, - {0x0000a5b0, 0x48023ec6, 0x48023ec6, 0x2a000e20, 0x2a000e20}, - {0x0000a5b4, 0x4d023f01, 0x4d023f01, 0x2e000e22, 0x2e000e22}, - {0x0000a5b8, 0x53023f4b, 0x53023f4b, 0x31000e24, 0x31000e24}, - {0x0000a5bc, 0x5a027f09, 0x5a027f09, 0x34001640, 0x34001640}, - {0x0000a5c0, 0x5f027fc9, 0x5f027fc9, 0x38001660, 0x38001660}, - {0x0000a5c4, 0x6502feca, 0x6502feca, 0x3b001861, 0x3b001861}, - {0x0000a5c8, 0x6b02ff4a, 0x6b02ff4a, 0x3e001a81, 0x3e001a81}, - {0x0000a5cc, 0x7203feca, 0x7203feca, 0x42001a83, 0x42001a83}, - {0x0000a5d0, 0x7703ff0b, 0x7703ff0b, 0x44001c84, 0x44001c84}, - {0x0000a5d4, 0x7d06ffcb, 0x7d06ffcb, 0x48001ce3, 0x48001ce3}, - {0x0000a5d8, 0x8407ff0b, 0x8407ff0b, 0x4c001ce5, 0x4c001ce5}, - {0x0000a5dc, 0x8907ffcb, 0x8907ffcb, 0x50001ce9, 0x50001ce9}, - {0x0000a5e0, 0x900fff0b, 0x900fff0b, 0x54001ceb, 0x54001ceb}, - {0x0000a5e4, 0x960fffcb, 0x960fffcb, 0x56001eec, 0x56001eec}, - {0x0000a5e8, 0x9c1fff0b, 0x9c1fff0b, 0x56001eec, 0x56001eec}, - {0x0000a5ec, 0x9c1fff0b, 0x9c1fff0b, 0x56001eec, 0x56001eec}, - {0x0000a5f0, 0x9c1fff0b, 0x9c1fff0b, 0x56001eec, 0x56001eec}, - {0x0000a5f4, 0x9c1fff0b, 0x9c1fff0b, 0x56001eec, 0x56001eec}, - {0x0000a5f8, 0x9c1fff0b, 0x9c1fff0b, 0x56001eec, 0x56001eec}, - {0x0000a5fc, 0x9c1fff0b, 0x9c1fff0b, 0x56001eec, 0x56001eec}, - {0x0000a600, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x0000a604, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x0000a608, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x0000a60c, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x0000a610, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x0000a614, 0x01404000, 0x01404000, 0x01404000, 0x01404000}, - {0x0000a618, 0x02008501, 0x02008501, 0x02008501, 0x02008501}, - {0x0000a61c, 0x02008802, 0x02008802, 0x02008802, 0x02008802}, - {0x0000a620, 0x0280c802, 0x0280c802, 0x0280c802, 0x0280c802}, - {0x0000a624, 0x0280ca03, 0x0280ca03, 0x0280ca03, 0x0280ca03}, - {0x0000a628, 0x03010c04, 0x03010c04, 0x03010c04, 0x03010c04}, - {0x0000a62c, 0x04015005, 0x04015005, 0x04015005, 0x04015005}, - {0x0000a630, 0x04015005, 0x04015005, 0x04015005, 0x04015005}, - {0x0000a634, 0x04015005, 0x04015005, 0x04015005, 0x04015005}, - {0x0000a638, 0x04015005, 0x04015005, 0x04015005, 0x04015005}, - {0x0000a63c, 0x04015005, 0x04015005, 0x04015005, 0x04015005}, -}; - -static const u32 ar9331_modes_low_ob_db_tx_gain_1p1[][5] = { - /* Addr 5G_HT20 5G_HT40 2G_HT40 2G_HT20 */ - {0x0000a2d8, 0x7999a83a, 0x7999a83a, 0x7999a83a, 0x7999a83a}, - {0x0000a2dc, 0xffff2a52, 0xffff2a52, 0xffff2a52, 0xffff2a52}, - {0x0000a2e0, 0xffffcc84, 0xffffcc84, 0xffffcc84, 0xffffcc84}, - {0x0000a2e4, 0xfffff000, 0xfffff000, 0xfffff000, 0xfffff000}, - {0x0000a2e8, 0xfffe0000, 0xfffe0000, 0xfffe0000, 0xfffe0000}, - {0x0000a410, 0x000050d7, 0x000050d7, 0x000050d0, 0x000050d0}, - {0x0000a500, 0x00022200, 0x00022200, 0x00000000, 0x00000000}, - {0x0000a504, 0x05062002, 0x05062002, 0x04000002, 0x04000002}, - {0x0000a508, 0x0c002e00, 0x0c002e00, 0x08000004, 0x08000004}, - {0x0000a50c, 0x11062202, 0x11062202, 0x0d000200, 0x0d000200}, - {0x0000a510, 0x17022e00, 0x17022e00, 0x11000202, 0x11000202}, - {0x0000a514, 0x1d000ec2, 0x1d000ec2, 0x15000400, 0x15000400}, - {0x0000a518, 0x25020ec0, 0x25020ec0, 0x19000402, 0x19000402}, - {0x0000a51c, 0x2b020ec3, 0x2b020ec3, 0x1d000404, 0x1d000404}, - {0x0000a520, 0x2f001f04, 0x2f001f04, 0x23000a00, 0x23000a00}, - {0x0000a524, 0x35001fc4, 0x35001fc4, 0x27000a02, 0x27000a02}, - {0x0000a528, 0x3c022f04, 0x3c022f04, 0x2b000a04, 0x2b000a04}, - {0x0000a52c, 0x41023e85, 0x41023e85, 0x2d000a20, 0x2d000a20}, - {0x0000a530, 0x48023ec6, 0x48023ec6, 0x31000a22, 0x31000a22}, - {0x0000a534, 0x4d023f01, 0x4d023f01, 0x35000a24, 0x35000a24}, - {0x0000a538, 0x53023f4b, 0x53023f4b, 0x38000a43, 0x38000a43}, - {0x0000a53c, 0x5a027f09, 0x5a027f09, 0x3b000e42, 0x3b000e42}, - {0x0000a540, 0x5f027fc9, 0x5f027fc9, 0x3f000e44, 0x3f000e44}, - {0x0000a544, 0x6502feca, 0x6502feca, 0x42000e64, 0x42000e64}, - {0x0000a548, 0x6b02ff4a, 0x6b02ff4a, 0x46000e66, 0x46000e66}, - {0x0000a54c, 0x7203feca, 0x7203feca, 0x4a000ea6, 0x4a000ea6}, - {0x0000a550, 0x7703ff0b, 0x7703ff0b, 0x4a000ea6, 0x4a000ea6}, - {0x0000a554, 0x7d06ffcb, 0x7d06ffcb, 0x4a000ea6, 0x4a000ea6}, - {0x0000a558, 0x8407ff0b, 0x8407ff0b, 0x4a000ea6, 0x4a000ea6}, - {0x0000a55c, 0x8907ffcb, 0x8907ffcb, 0x4a000ea6, 0x4a000ea6}, - {0x0000a560, 0x900fff0b, 0x900fff0b, 0x4a000ea6, 0x4a000ea6}, - {0x0000a564, 0x960fffcb, 0x960fffcb, 0x4a000ea6, 0x4a000ea6}, - {0x0000a568, 0x9c1fff0b, 0x9c1fff0b, 0x4a000ea6, 0x4a000ea6}, - {0x0000a56c, 0x9c1fff0b, 0x9c1fff0b, 0x4a000ea6, 0x4a000ea6}, - {0x0000a570, 0x9c1fff0b, 0x9c1fff0b, 0x4a000ea6, 0x4a000ea6}, - {0x0000a574, 0x9c1fff0b, 0x9c1fff0b, 0x4a000ea6, 0x4a000ea6}, - {0x0000a578, 0x9c1fff0b, 0x9c1fff0b, 0x4a000ea6, 0x4a000ea6}, - {0x0000a57c, 0x9c1fff0b, 0x9c1fff0b, 0x4a000ea6, 0x4a000ea6}, - {0x0000a580, 0x00022200, 0x00022200, 0x00000000, 0x00000000}, - {0x0000a584, 0x05062002, 0x05062002, 0x04000002, 0x04000002}, - {0x0000a588, 0x0c002e00, 0x0c002e00, 0x08000004, 0x08000004}, - {0x0000a58c, 0x11062202, 0x11062202, 0x0b000200, 0x0b000200}, - {0x0000a590, 0x17022e00, 0x17022e00, 0x0f000202, 0x0f000202}, - {0x0000a594, 0x1d000ec2, 0x1d000ec2, 0x11000400, 0x11000400}, - {0x0000a598, 0x25020ec0, 0x25020ec0, 0x15000402, 0x15000402}, - {0x0000a59c, 0x2b020ec3, 0x2b020ec3, 0x19000404, 0x19000404}, - {0x0000a5a0, 0x2f001f04, 0x2f001f04, 0x1b000603, 0x1b000603}, - {0x0000a5a4, 0x35001fc4, 0x35001fc4, 0x1f000a02, 0x1f000a02}, - {0x0000a5a8, 0x3c022f04, 0x3c022f04, 0x23000a04, 0x23000a04}, - {0x0000a5ac, 0x41023e85, 0x41023e85, 0x26000a20, 0x26000a20}, - {0x0000a5b0, 0x48023ec6, 0x48023ec6, 0x2a000e20, 0x2a000e20}, - {0x0000a5b4, 0x4d023f01, 0x4d023f01, 0x2e000e22, 0x2e000e22}, - {0x0000a5b8, 0x53023f4b, 0x53023f4b, 0x31000e24, 0x31000e24}, - {0x0000a5bc, 0x5a027f09, 0x5a027f09, 0x34001640, 0x34001640}, - {0x0000a5c0, 0x5f027fc9, 0x5f027fc9, 0x38001660, 0x38001660}, - {0x0000a5c4, 0x6502feca, 0x6502feca, 0x3b001861, 0x3b001861}, - {0x0000a5c8, 0x6b02ff4a, 0x6b02ff4a, 0x3e001a81, 0x3e001a81}, - {0x0000a5cc, 0x7203feca, 0x7203feca, 0x42001a83, 0x42001a83}, - {0x0000a5d0, 0x7703ff0b, 0x7703ff0b, 0x44001c84, 0x44001c84}, - {0x0000a5d4, 0x7d06ffcb, 0x7d06ffcb, 0x48001ce3, 0x48001ce3}, - {0x0000a5d8, 0x8407ff0b, 0x8407ff0b, 0x4c001ce5, 0x4c001ce5}, - {0x0000a5dc, 0x8907ffcb, 0x8907ffcb, 0x50001ce9, 0x50001ce9}, - {0x0000a5e0, 0x900fff0b, 0x900fff0b, 0x54001ceb, 0x54001ceb}, - {0x0000a5e4, 0x960fffcb, 0x960fffcb, 0x56001eec, 0x56001eec}, - {0x0000a5e8, 0x9c1fff0b, 0x9c1fff0b, 0x56001eec, 0x56001eec}, - {0x0000a5ec, 0x9c1fff0b, 0x9c1fff0b, 0x56001eec, 0x56001eec}, - {0x0000a5f0, 0x9c1fff0b, 0x9c1fff0b, 0x56001eec, 0x56001eec}, - {0x0000a5f4, 0x9c1fff0b, 0x9c1fff0b, 0x56001eec, 0x56001eec}, - {0x0000a5f8, 0x9c1fff0b, 0x9c1fff0b, 0x56001eec, 0x56001eec}, - {0x0000a5fc, 0x9c1fff0b, 0x9c1fff0b, 0x56001eec, 0x56001eec}, - {0x0000a600, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x0000a604, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x0000a608, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x0000a60c, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x0000a610, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x0000a614, 0x01404000, 0x01404000, 0x01404000, 0x01404000}, - {0x0000a618, 0x01404501, 0x01404501, 0x01404501, 0x01404501}, - {0x0000a61c, 0x02008802, 0x02008802, 0x02008802, 0x02008802}, - {0x0000a620, 0x0280c802, 0x0280c802, 0x0280c802, 0x0280c802}, - {0x0000a624, 0x03010a03, 0x03010a03, 0x03010a03, 0x03010a03}, - {0x0000a628, 0x03010c04, 0x03010c04, 0x03010c04, 0x03010c04}, - {0x0000a62c, 0x03010c04, 0x03010c04, 0x03010c04, 0x03010c04}, - {0x0000a630, 0x03010c04, 0x03010c04, 0x03010c04, 0x03010c04}, - {0x0000a634, 0x03010c04, 0x03010c04, 0x03010c04, 0x03010c04}, - {0x0000a638, 0x03010c04, 0x03010c04, 0x03010c04, 0x03010c04}, - {0x0000a63c, 0x03010c04, 0x03010c04, 0x03010c04, 0x03010c04}, - {0x00016044, 0x034922db, 0x034922db, 0x034922db, 0x034922db}, - {0x00016284, 0x14d3f000, 0x14d3f000, 0x14d3f000, 0x14d3f000}, -}; - -static const u32 ar9331_1p1_baseband_core_txfir_coeff_japan_2484[][2] = { - /* Addr allmodes */ - {0x0000a398, 0x00000000}, - {0x0000a39c, 0x6f7f0301}, - {0x0000a3a0, 0xca9228ee}, -}; - -static const u32 ar9331_1p1_xtal_25M[][2] = { - /* Addr allmodes */ - {0x00007038, 0x000002f8}, - {0x00008244, 0x0010f3d7}, - {0x0000824c, 0x0001e7ae}, - {0x0001609c, 0x0f508f29}, -}; - -static const u32 ar9331_1p1_radio_core[][2] = { - /* Addr allmodes */ - {0x00016000, 0x36db6db6}, - {0x00016004, 0x6db6db40}, - {0x00016008, 0x73800000}, - {0x0001600c, 0x00000000}, - {0x00016040, 0x7f80fff8}, - {0x00016044, 0x03db62db}, - {0x00016048, 0x6c924268}, - {0x0001604c, 0x000f0278}, - {0x00016050, 0x4db6db8c}, - {0x00016054, 0x6db60000}, - {0x00016080, 0x00080000}, - {0x00016084, 0x0e48048c}, - {0x00016088, 0x14214514}, - {0x0001608c, 0x119f081c}, - {0x00016090, 0x24926490}, - {0x00016098, 0xd411eb84}, - {0x000160a0, 0xc2108ffe}, - {0x000160a4, 0x812fc370}, - {0x000160a8, 0x423c8000}, - {0x000160ac, 0x24651800}, - {0x000160b0, 0x03284f3e}, - {0x000160b4, 0x92480040}, - {0x000160c0, 0x006db6db}, - {0x000160c4, 0x0186db60}, - {0x000160c8, 0x6db6db6c}, - {0x000160cc, 0x6de6c300}, - {0x000160d0, 0x14500820}, - {0x00016100, 0x04cb0001}, - {0x00016104, 0xfff80015}, - {0x00016108, 0x00080010}, - {0x0001610c, 0x00170000}, - {0x00016140, 0x10804000}, - {0x00016144, 0x01884080}, - {0x00016148, 0x000080c0}, - {0x00016280, 0x01000015}, - {0x00016284, 0x14d20000}, - {0x00016288, 0x00318000}, - {0x0001628c, 0x50000000}, - {0x00016290, 0x4b96210f}, - {0x00016380, 0x00000000}, - {0x00016384, 0x00000000}, - {0x00016388, 0x00800700}, - {0x0001638c, 0x00800700}, - {0x00016390, 0x00800700}, - {0x00016394, 0x00000000}, - {0x00016398, 0x00000000}, - {0x0001639c, 0x00000000}, - {0x000163a0, 0x00000001}, - {0x000163a4, 0x00000001}, - {0x000163a8, 0x00000000}, - {0x000163ac, 0x00000000}, - {0x000163b0, 0x00000000}, - {0x000163b4, 0x00000000}, - {0x000163b8, 0x00000000}, - {0x000163bc, 0x00000000}, - {0x000163c0, 0x000000a0}, - {0x000163c4, 0x000c0000}, - {0x000163c8, 0x14021402}, - {0x000163cc, 0x00001402}, - {0x000163d0, 0x00000000}, - {0x000163d4, 0x00000000}, -}; - -static const u32 ar9331_1p1_soc_postamble[][5] = { - /* Addr 5G_HT20 5G_HT40 2G_HT40 2G_HT20 */ - {0x00007010, 0x00000022, 0x00000022, 0x00000022, 0x00000022}, -}; - -static const u32 ar9331_common_wo_xlna_rx_gain_1p1[][2] = { - /* Addr allmodes */ - {0x0000a000, 0x00060005}, - {0x0000a004, 0x00810080}, - {0x0000a008, 0x00830082}, - {0x0000a00c, 0x00850084}, - {0x0000a010, 0x01820181}, - {0x0000a014, 0x01840183}, - {0x0000a018, 0x01880185}, - {0x0000a01c, 0x018a0189}, - {0x0000a020, 0x02850284}, - {0x0000a024, 0x02890288}, - {0x0000a028, 0x028b028a}, - {0x0000a02c, 0x03850384}, - {0x0000a030, 0x03890388}, - {0x0000a034, 0x038b038a}, - {0x0000a038, 0x038d038c}, - {0x0000a03c, 0x03910390}, - {0x0000a040, 0x03930392}, - {0x0000a044, 0x03950394}, - {0x0000a048, 0x00000396}, - {0x0000a04c, 0x00000000}, - {0x0000a050, 0x00000000}, - {0x0000a054, 0x00000000}, - {0x0000a058, 0x00000000}, - {0x0000a05c, 0x00000000}, - {0x0000a060, 0x00000000}, - {0x0000a064, 0x00000000}, - {0x0000a068, 0x00000000}, - {0x0000a06c, 0x00000000}, - {0x0000a070, 0x00000000}, - {0x0000a074, 0x00000000}, - {0x0000a078, 0x00000000}, - {0x0000a07c, 0x00000000}, - {0x0000a080, 0x28282828}, - {0x0000a084, 0x28282828}, - {0x0000a088, 0x28282828}, - {0x0000a08c, 0x28282828}, - {0x0000a090, 0x28282828}, - {0x0000a094, 0x24242428}, - {0x0000a098, 0x171e1e1e}, - {0x0000a09c, 0x02020b0b}, - {0x0000a0a0, 0x02020202}, - {0x0000a0a4, 0x00000000}, - {0x0000a0a8, 0x00000000}, - {0x0000a0ac, 0x00000000}, - {0x0000a0b0, 0x00000000}, - {0x0000a0b4, 0x00000000}, - {0x0000a0b8, 0x00000000}, - {0x0000a0bc, 0x00000000}, - {0x0000a0c0, 0x22072208}, - {0x0000a0c4, 0x22052206}, - {0x0000a0c8, 0x22032204}, - {0x0000a0cc, 0x22012202}, - {0x0000a0d0, 0x221f2200}, - {0x0000a0d4, 0x221d221e}, - {0x0000a0d8, 0x33023303}, - {0x0000a0dc, 0x33003301}, - {0x0000a0e0, 0x331e331f}, - {0x0000a0e4, 0x4402331d}, - {0x0000a0e8, 0x44004401}, - {0x0000a0ec, 0x441e441f}, - {0x0000a0f0, 0x55025503}, - {0x0000a0f4, 0x55005501}, - {0x0000a0f8, 0x551e551f}, - {0x0000a0fc, 0x6602551d}, - {0x0000a100, 0x66006601}, - {0x0000a104, 0x661e661f}, - {0x0000a108, 0x7703661d}, - {0x0000a10c, 0x77017702}, - {0x0000a110, 0x00007700}, - {0x0000a114, 0x00000000}, - {0x0000a118, 0x00000000}, - {0x0000a11c, 0x00000000}, - {0x0000a120, 0x00000000}, - {0x0000a124, 0x00000000}, - {0x0000a128, 0x00000000}, - {0x0000a12c, 0x00000000}, - {0x0000a130, 0x00000000}, - {0x0000a134, 0x00000000}, - {0x0000a138, 0x00000000}, - {0x0000a13c, 0x00000000}, - {0x0000a140, 0x001f0000}, - {0x0000a144, 0x111f1100}, - {0x0000a148, 0x111d111e}, - {0x0000a14c, 0x111b111c}, - {0x0000a150, 0x22032204}, - {0x0000a154, 0x22012202}, - {0x0000a158, 0x221f2200}, - {0x0000a15c, 0x221d221e}, - {0x0000a160, 0x33013302}, - {0x0000a164, 0x331f3300}, - {0x0000a168, 0x4402331e}, - {0x0000a16c, 0x44004401}, - {0x0000a170, 0x441e441f}, - {0x0000a174, 0x55015502}, - {0x0000a178, 0x551f5500}, - {0x0000a17c, 0x6602551e}, - {0x0000a180, 0x66006601}, - {0x0000a184, 0x661e661f}, - {0x0000a188, 0x7703661d}, - {0x0000a18c, 0x77017702}, - {0x0000a190, 0x00007700}, - {0x0000a194, 0x00000000}, - {0x0000a198, 0x00000000}, - {0x0000a19c, 0x00000000}, - {0x0000a1a0, 0x00000000}, - {0x0000a1a4, 0x00000000}, - {0x0000a1a8, 0x00000000}, - {0x0000a1ac, 0x00000000}, - {0x0000a1b0, 0x00000000}, - {0x0000a1b4, 0x00000000}, - {0x0000a1b8, 0x00000000}, - {0x0000a1bc, 0x00000000}, - {0x0000a1c0, 0x00000000}, - {0x0000a1c4, 0x00000000}, - {0x0000a1c8, 0x00000000}, - {0x0000a1cc, 0x00000000}, - {0x0000a1d0, 0x00000000}, - {0x0000a1d4, 0x00000000}, - {0x0000a1d8, 0x00000000}, - {0x0000a1dc, 0x00000000}, - {0x0000a1e0, 0x00000000}, - {0x0000a1e4, 0x00000000}, - {0x0000a1e8, 0x00000000}, - {0x0000a1ec, 0x00000000}, - {0x0000a1f0, 0x00000396}, - {0x0000a1f4, 0x00000396}, - {0x0000a1f8, 0x00000396}, - {0x0000a1fc, 0x00000296}, -}; - -static const u32 ar9331_1p1_baseband_core[][2] = { - /* Addr allmodes */ - {0x00009800, 0xafe68e30}, - {0x00009804, 0xfd14e000}, - {0x00009808, 0x9c0a8f6b}, - {0x0000980c, 0x04800000}, - {0x00009814, 0x9280c00a}, - {0x00009818, 0x00000000}, - {0x0000981c, 0x00020028}, - {0x00009834, 0x5f3ca3de}, - {0x00009838, 0x0108ecff}, - {0x0000983c, 0x14750600}, - {0x00009880, 0x201fff00}, - {0x00009884, 0x00001042}, - {0x000098a4, 0x00200400}, - {0x000098b0, 0x32840bbe}, - {0x000098d0, 0x004b6a8e}, - {0x000098d4, 0x00000820}, - {0x000098dc, 0x00000000}, - {0x000098f0, 0x00000000}, - {0x000098f4, 0x00000000}, - {0x00009c04, 0x00000000}, - {0x00009c08, 0x03200000}, - {0x00009c0c, 0x00000000}, - {0x00009c10, 0x00000000}, - {0x00009c14, 0x00046384}, - {0x00009c18, 0x05b6b440}, - {0x00009c1c, 0x00b6b440}, - {0x00009d00, 0xc080a333}, - {0x00009d04, 0x40206c10}, - {0x00009d08, 0x009c4060}, - {0x00009d0c, 0x1883800a}, - {0x00009d10, 0x01834061}, - {0x00009d14, 0x00c00400}, - {0x00009d18, 0x00000000}, - {0x00009e08, 0x0038233c}, - {0x00009e24, 0x9927b515}, - {0x00009e28, 0x12ef0200}, - {0x00009e30, 0x06336f77}, - {0x00009e34, 0x6af6532f}, - {0x00009e38, 0x0cc80c00}, - {0x00009e40, 0x0d261820}, - {0x00009e4c, 0x00001004}, - {0x00009e50, 0x00ff03f1}, - {0x00009fc0, 0x803e4788}, - {0x00009fc4, 0x0001efb5}, - {0x00009fcc, 0x40000014}, - {0x0000a20c, 0x00000000}, - {0x0000a220, 0x00000000}, - {0x0000a224, 0x00000000}, - {0x0000a228, 0x10002310}, - {0x0000a23c, 0x00000000}, - {0x0000a244, 0x0c000000}, - {0x0000a2a0, 0x00000001}, - {0x0000a2c0, 0x00000001}, - {0x0000a2c8, 0x00000000}, - {0x0000a2cc, 0x18c43433}, - {0x0000a2d4, 0x00000000}, - {0x0000a2dc, 0x00000000}, - {0x0000a2e0, 0x00000000}, - {0x0000a2e4, 0x00000000}, - {0x0000a2e8, 0x00000000}, - {0x0000a2ec, 0x00000000}, - {0x0000a2f0, 0x00000000}, - {0x0000a2f4, 0x00000000}, - {0x0000a2f8, 0x00000000}, - {0x0000a344, 0x00000000}, - {0x0000a34c, 0x00000000}, - {0x0000a350, 0x0000a000}, - {0x0000a364, 0x00000000}, - {0x0000a370, 0x00000000}, - {0x0000a390, 0x00000001}, - {0x0000a394, 0x00000444}, - {0x0000a398, 0x001f0e0f}, - {0x0000a39c, 0x0075393f}, - {0x0000a3a0, 0xb79f6427}, - {0x0000a3a4, 0x00000000}, - {0x0000a3a8, 0xaaaaaaaa}, - {0x0000a3ac, 0x3c466478}, - {0x0000a3c0, 0x20202020}, - {0x0000a3c4, 0x22222220}, - {0x0000a3c8, 0x20200020}, - {0x0000a3cc, 0x20202020}, - {0x0000a3d0, 0x20202020}, - {0x0000a3d4, 0x20202020}, - {0x0000a3d8, 0x20202020}, - {0x0000a3dc, 0x20202020}, - {0x0000a3e0, 0x20202020}, - {0x0000a3e4, 0x20202020}, - {0x0000a3e8, 0x20202020}, - {0x0000a3ec, 0x20202020}, - {0x0000a3f0, 0x00000000}, - {0x0000a3f4, 0x00000006}, - {0x0000a3f8, 0x0cdbd380}, - {0x0000a3fc, 0x000f0f01}, - {0x0000a400, 0x8fa91f01}, - {0x0000a404, 0x00000000}, - {0x0000a408, 0x0e79e5c6}, - {0x0000a40c, 0x00820820}, - {0x0000a414, 0x1ce739ce}, - {0x0000a418, 0x2d001dce}, - {0x0000a41c, 0x1ce739ce}, - {0x0000a420, 0x000001ce}, - {0x0000a424, 0x1ce739ce}, - {0x0000a428, 0x000001ce}, - {0x0000a42c, 0x1ce739ce}, - {0x0000a430, 0x1ce739ce}, - {0x0000a434, 0x00000000}, - {0x0000a438, 0x00001801}, - {0x0000a43c, 0x00000000}, - {0x0000a440, 0x00000000}, - {0x0000a444, 0x00000000}, - {0x0000a448, 0x04000000}, - {0x0000a44c, 0x00000001}, - {0x0000a450, 0x00010000}, - {0x0000a458, 0x00000000}, - {0x0000a640, 0x00000000}, - {0x0000a644, 0x3fad9d74}, - {0x0000a648, 0x0048060a}, - {0x0000a64c, 0x00003c37}, - {0x0000a670, 0x03020100}, - {0x0000a674, 0x09080504}, - {0x0000a678, 0x0d0c0b0a}, - {0x0000a67c, 0x13121110}, - {0x0000a680, 0x31301514}, - {0x0000a684, 0x35343332}, - {0x0000a688, 0x00000036}, - {0x0000a690, 0x00000838}, - {0x0000a7c0, 0x00000000}, - {0x0000a7c4, 0xfffffffc}, - {0x0000a7c8, 0x00000000}, - {0x0000a7cc, 0x00000000}, - {0x0000a7d0, 0x00000000}, - {0x0000a7d4, 0x00000004}, - {0x0000a7dc, 0x00000001}, -}; - -static const u32 ar9331_modes_high_power_tx_gain_1p1[][5] = { - /* Addr 5G_HT20 5G_HT40 2G_HT40 2G_HT20 */ - {0x0000a2d8, 0x7999a83a, 0x7999a83a, 0x7999a83a, 0x7999a83a}, - {0x0000a2dc, 0xffff2a52, 0xffff2a52, 0xffff2a52, 0xffff2a52}, - {0x0000a2e0, 0xffffcc84, 0xffffcc84, 0xffffcc84, 0xffffcc84}, - {0x0000a2e4, 0xfffff000, 0xfffff000, 0xfffff000, 0xfffff000}, - {0x0000a2e8, 0xfffe0000, 0xfffe0000, 0xfffe0000, 0xfffe0000}, - {0x0000a410, 0x000050d7, 0x000050d7, 0x000050d0, 0x000050d0}, - {0x0000a500, 0x00022200, 0x00022200, 0x00000000, 0x00000000}, - {0x0000a504, 0x05062002, 0x05062002, 0x04000002, 0x04000002}, - {0x0000a508, 0x0c002e00, 0x0c002e00, 0x08000004, 0x08000004}, - {0x0000a50c, 0x11062202, 0x11062202, 0x0d000200, 0x0d000200}, - {0x0000a510, 0x17022e00, 0x17022e00, 0x11000202, 0x11000202}, - {0x0000a514, 0x1d000ec2, 0x1d000ec2, 0x15000400, 0x15000400}, - {0x0000a518, 0x25020ec0, 0x25020ec0, 0x19000402, 0x19000402}, - {0x0000a51c, 0x2b020ec3, 0x2b020ec3, 0x1d000404, 0x1d000404}, - {0x0000a520, 0x2f001f04, 0x2f001f04, 0x23000a00, 0x23000a00}, - {0x0000a524, 0x35001fc4, 0x35001fc4, 0x27000a02, 0x27000a02}, - {0x0000a528, 0x3c022f04, 0x3c022f04, 0x2b000a04, 0x2b000a04}, - {0x0000a52c, 0x41023e85, 0x41023e85, 0x2d000a20, 0x2d000a20}, - {0x0000a530, 0x48023ec6, 0x48023ec6, 0x31000a22, 0x31000a22}, - {0x0000a534, 0x4d023f01, 0x4d023f01, 0x35000a24, 0x35000a24}, - {0x0000a538, 0x53023f4b, 0x53023f4b, 0x38000a43, 0x38000a43}, - {0x0000a53c, 0x5a027f09, 0x5a027f09, 0x3b000e42, 0x3b000e42}, - {0x0000a540, 0x5f027fc9, 0x5f027fc9, 0x3f000e44, 0x3f000e44}, - {0x0000a544, 0x6502feca, 0x6502feca, 0x42000e64, 0x42000e64}, - {0x0000a548, 0x6b02ff4a, 0x6b02ff4a, 0x46000e66, 0x46000e66}, - {0x0000a54c, 0x7203feca, 0x7203feca, 0x4a000ea6, 0x4a000ea6}, - {0x0000a550, 0x7703ff0b, 0x7703ff0b, 0x4a000ea6, 0x4a000ea6}, - {0x0000a554, 0x7d06ffcb, 0x7d06ffcb, 0x4a000ea6, 0x4a000ea6}, - {0x0000a558, 0x8407ff0b, 0x8407ff0b, 0x4a000ea6, 0x4a000ea6}, - {0x0000a55c, 0x8907ffcb, 0x8907ffcb, 0x4a000ea6, 0x4a000ea6}, - {0x0000a560, 0x900fff0b, 0x900fff0b, 0x4a000ea6, 0x4a000ea6}, - {0x0000a564, 0x960fffcb, 0x960fffcb, 0x4a000ea6, 0x4a000ea6}, - {0x0000a568, 0x9c1fff0b, 0x9c1fff0b, 0x4a000ea6, 0x4a000ea6}, - {0x0000a56c, 0x9c1fff0b, 0x9c1fff0b, 0x4a000ea6, 0x4a000ea6}, - {0x0000a570, 0x9c1fff0b, 0x9c1fff0b, 0x4a000ea6, 0x4a000ea6}, - {0x0000a574, 0x9c1fff0b, 0x9c1fff0b, 0x4a000ea6, 0x4a000ea6}, - {0x0000a578, 0x9c1fff0b, 0x9c1fff0b, 0x4a000ea6, 0x4a000ea6}, - {0x0000a57c, 0x9c1fff0b, 0x9c1fff0b, 0x4a000ea6, 0x4a000ea6}, - {0x0000a580, 0x00022200, 0x00022200, 0x00000000, 0x00000000}, - {0x0000a584, 0x05062002, 0x05062002, 0x04000002, 0x04000002}, - {0x0000a588, 0x0c002e00, 0x0c002e00, 0x08000004, 0x08000004}, - {0x0000a58c, 0x11062202, 0x11062202, 0x0b000200, 0x0b000200}, - {0x0000a590, 0x17022e00, 0x17022e00, 0x0f000202, 0x0f000202}, - {0x0000a594, 0x1d000ec2, 0x1d000ec2, 0x11000400, 0x11000400}, - {0x0000a598, 0x25020ec0, 0x25020ec0, 0x15000402, 0x15000402}, - {0x0000a59c, 0x2b020ec3, 0x2b020ec3, 0x19000404, 0x19000404}, - {0x0000a5a0, 0x2f001f04, 0x2f001f04, 0x1b000603, 0x1b000603}, - {0x0000a5a4, 0x35001fc4, 0x35001fc4, 0x1f000a02, 0x1f000a02}, - {0x0000a5a8, 0x3c022f04, 0x3c022f04, 0x23000a04, 0x23000a04}, - {0x0000a5ac, 0x41023e85, 0x41023e85, 0x26000a20, 0x26000a20}, - {0x0000a5b0, 0x48023ec6, 0x48023ec6, 0x2a000e20, 0x2a000e20}, - {0x0000a5b4, 0x4d023f01, 0x4d023f01, 0x2e000e22, 0x2e000e22}, - {0x0000a5b8, 0x53023f4b, 0x53023f4b, 0x31000e24, 0x31000e24}, - {0x0000a5bc, 0x5a027f09, 0x5a027f09, 0x34001640, 0x34001640}, - {0x0000a5c0, 0x5f027fc9, 0x5f027fc9, 0x38001660, 0x38001660}, - {0x0000a5c4, 0x6502feca, 0x6502feca, 0x3b001861, 0x3b001861}, - {0x0000a5c8, 0x6b02ff4a, 0x6b02ff4a, 0x3e001a81, 0x3e001a81}, - {0x0000a5cc, 0x7203feca, 0x7203feca, 0x42001a83, 0x42001a83}, - {0x0000a5d0, 0x7703ff0b, 0x7703ff0b, 0x44001c84, 0x44001c84}, - {0x0000a5d4, 0x7d06ffcb, 0x7d06ffcb, 0x48001ce3, 0x48001ce3}, - {0x0000a5d8, 0x8407ff0b, 0x8407ff0b, 0x4c001ce5, 0x4c001ce5}, - {0x0000a5dc, 0x8907ffcb, 0x8907ffcb, 0x50001ce9, 0x50001ce9}, - {0x0000a5e0, 0x900fff0b, 0x900fff0b, 0x54001ceb, 0x54001ceb}, - {0x0000a5e4, 0x960fffcb, 0x960fffcb, 0x56001eec, 0x56001eec}, - {0x0000a5e8, 0x9c1fff0b, 0x9c1fff0b, 0x56001eec, 0x56001eec}, - {0x0000a5ec, 0x9c1fff0b, 0x9c1fff0b, 0x56001eec, 0x56001eec}, - {0x0000a5f0, 0x9c1fff0b, 0x9c1fff0b, 0x56001eec, 0x56001eec}, - {0x0000a5f4, 0x9c1fff0b, 0x9c1fff0b, 0x56001eec, 0x56001eec}, - {0x0000a5f8, 0x9c1fff0b, 0x9c1fff0b, 0x56001eec, 0x56001eec}, - {0x0000a5fc, 0x9c1fff0b, 0x9c1fff0b, 0x56001eec, 0x56001eec}, - {0x0000a600, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x0000a604, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x0000a608, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x0000a60c, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x0000a610, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x0000a614, 0x01404000, 0x01404000, 0x01404000, 0x01404000}, - {0x0000a618, 0x01404501, 0x01404501, 0x01404501, 0x01404501}, - {0x0000a61c, 0x02008802, 0x02008802, 0x02008802, 0x02008802}, - {0x0000a620, 0x0280c802, 0x0280c802, 0x0280c802, 0x0280c802}, - {0x0000a624, 0x03010a03, 0x03010a03, 0x03010a03, 0x03010a03}, - {0x0000a628, 0x03010c04, 0x03010c04, 0x03010c04, 0x03010c04}, - {0x0000a62c, 0x03010c04, 0x03010c04, 0x03010c04, 0x03010c04}, - {0x0000a630, 0x03010c04, 0x03010c04, 0x03010c04, 0x03010c04}, - {0x0000a634, 0x03010c04, 0x03010c04, 0x03010c04, 0x03010c04}, - {0x0000a638, 0x03010c04, 0x03010c04, 0x03010c04, 0x03010c04}, - {0x0000a63c, 0x03010c04, 0x03010c04, 0x03010c04, 0x03010c04}, - {0x00016044, 0x034922db, 0x034922db, 0x034922db, 0x034922db}, - {0x00016284, 0x14d3f000, 0x14d3f000, 0x14d3f000, 0x14d3f000}, -}; - -static const u32 ar9331_1p1_mac_postamble[][5] = { - /* Addr 5G_HT20 5G_HT40 2G_HT40 2G_HT20 */ - {0x00001030, 0x00000230, 0x00000460, 0x000002c0, 0x00000160}, - {0x00001070, 0x00000168, 0x000002d0, 0x00000318, 0x0000018c}, - {0x000010b0, 0x00000e60, 0x00001cc0, 0x00007c70, 0x00003e38}, - {0x00008014, 0x03e803e8, 0x07d007d0, 0x10801600, 0x08400b00}, - {0x0000801c, 0x128d8027, 0x128d804f, 0x12e00057, 0x12e0002b}, - {0x00008120, 0x08f04800, 0x08f04800, 0x08f04810, 0x08f04810}, - {0x000081d0, 0x00003210, 0x00003210, 0x0000320a, 0x0000320a}, - {0x00008318, 0x00003e80, 0x00007d00, 0x00006880, 0x00003440}, -}; - -static const u32 ar9331_1p1_soc_preamble[][2] = { - /* Addr allmodes */ - {0x00007020, 0x00000000}, - {0x00007034, 0x00000002}, - {0x00007038, 0x000002f8}, -}; - -static const u32 ar9331_1p1_xtal_40M[][2] = { - /* Addr allmodes */ - {0x00007038, 0x000004c2}, - {0x00008244, 0x0010f400}, - {0x0000824c, 0x0001e800}, - {0x0001609c, 0x0b283f31}, -}; - -static const u32 ar9331_1p1_mac_core[][2] = { - /* Addr allmodes */ - {0x00000008, 0x00000000}, - {0x00000030, 0x00020085}, - {0x00000034, 0x00000005}, - {0x00000040, 0x00000000}, - {0x00000044, 0x00000000}, - {0x00000048, 0x00000008}, - {0x0000004c, 0x00000010}, - {0x00000050, 0x00000000}, - {0x00001040, 0x002ffc0f}, - {0x00001044, 0x002ffc0f}, - {0x00001048, 0x002ffc0f}, - {0x0000104c, 0x002ffc0f}, - {0x00001050, 0x002ffc0f}, - {0x00001054, 0x002ffc0f}, - {0x00001058, 0x002ffc0f}, - {0x0000105c, 0x002ffc0f}, - {0x00001060, 0x002ffc0f}, - {0x00001064, 0x002ffc0f}, - {0x000010f0, 0x00000100}, - {0x00001270, 0x00000000}, - {0x000012b0, 0x00000000}, - {0x000012f0, 0x00000000}, - {0x0000143c, 0x00000000}, - {0x0000147c, 0x00000000}, - {0x00008000, 0x00000000}, - {0x00008004, 0x00000000}, - {0x00008008, 0x00000000}, - {0x0000800c, 0x00000000}, - {0x00008018, 0x00000000}, - {0x00008020, 0x00000000}, - {0x00008038, 0x00000000}, - {0x0000803c, 0x00000000}, - {0x00008040, 0x00000000}, - {0x00008044, 0x00000000}, - {0x00008048, 0x00000000}, - {0x0000804c, 0xffffffff}, - {0x00008054, 0x00000000}, - {0x00008058, 0x00000000}, - {0x0000805c, 0x000fc78f}, - {0x00008060, 0x0000000f}, - {0x00008064, 0x00000000}, - {0x00008070, 0x00000310}, - {0x00008074, 0x00000020}, - {0x00008078, 0x00000000}, - {0x0000809c, 0x0000000f}, - {0x000080a0, 0x00000000}, - {0x000080a4, 0x02ff0000}, - {0x000080a8, 0x0e070605}, - {0x000080ac, 0x0000000d}, - {0x000080b0, 0x00000000}, - {0x000080b4, 0x00000000}, - {0x000080b8, 0x00000000}, - {0x000080bc, 0x00000000}, - {0x000080c0, 0x2a800000}, - {0x000080c4, 0x06900168}, - {0x000080c8, 0x13881c20}, - {0x000080cc, 0x01f40000}, - {0x000080d0, 0x00252500}, - {0x000080d4, 0x00a00000}, - {0x000080d8, 0x00400000}, - {0x000080dc, 0x00000000}, - {0x000080e0, 0xffffffff}, - {0x000080e4, 0x0000ffff}, - {0x000080e8, 0x3f3f3f3f}, - {0x000080ec, 0x00000000}, - {0x000080f0, 0x00000000}, - {0x000080f4, 0x00000000}, - {0x000080fc, 0x00020000}, - {0x00008100, 0x00000000}, - {0x00008108, 0x00000052}, - {0x0000810c, 0x00000000}, - {0x00008110, 0x00000000}, - {0x00008114, 0x000007ff}, - {0x00008118, 0x000000aa}, - {0x0000811c, 0x00003210}, - {0x00008124, 0x00000000}, - {0x00008128, 0x00000000}, - {0x0000812c, 0x00000000}, - {0x00008130, 0x00000000}, - {0x00008134, 0x00000000}, - {0x00008138, 0x00000000}, - {0x0000813c, 0x0000ffff}, - {0x00008144, 0xffffffff}, - {0x00008168, 0x00000000}, - {0x0000816c, 0x00000000}, - {0x00008170, 0x18486200}, - {0x00008174, 0x33332210}, - {0x00008178, 0x00000000}, - {0x0000817c, 0x00020000}, - {0x000081c0, 0x00000000}, - {0x000081c4, 0x33332210}, - {0x000081c8, 0x00000000}, - {0x000081cc, 0x00000000}, - {0x000081d4, 0x00000000}, - {0x000081ec, 0x00000000}, - {0x000081f0, 0x00000000}, - {0x000081f4, 0x00000000}, - {0x000081f8, 0x00000000}, - {0x000081fc, 0x00000000}, - {0x00008240, 0x00100000}, - {0x00008248, 0x00000800}, - {0x00008250, 0x00000000}, - {0x00008254, 0x00000000}, - {0x00008258, 0x00000000}, - {0x0000825c, 0x40000000}, - {0x00008260, 0x00080922}, - {0x00008264, 0x9d400010}, - {0x00008268, 0xffffffff}, - {0x0000826c, 0x0000ffff}, - {0x00008270, 0x00000000}, - {0x00008274, 0x40000000}, - {0x00008278, 0x003e4180}, - {0x0000827c, 0x00000004}, - {0x00008284, 0x0000002c}, - {0x00008288, 0x0000002c}, - {0x0000828c, 0x000000ff}, - {0x00008294, 0x00000000}, - {0x00008298, 0x00000000}, - {0x0000829c, 0x00000000}, - {0x00008300, 0x00000140}, - {0x00008314, 0x00000000}, - {0x0000831c, 0x0000010d}, - {0x00008328, 0x00000000}, - {0x0000832c, 0x00000007}, - {0x00008330, 0x00000302}, - {0x00008334, 0x00000700}, - {0x00008338, 0x00ff0000}, - {0x0000833c, 0x02400000}, - {0x00008340, 0x000107ff}, - {0x00008344, 0xaa48105b}, - {0x00008348, 0x008f0000}, - {0x0000835c, 0x00000000}, - {0x00008360, 0xffffffff}, - {0x00008364, 0xffffffff}, - {0x00008368, 0x00000000}, - {0x00008370, 0x00000000}, - {0x00008374, 0x000000ff}, - {0x00008378, 0x00000000}, - {0x0000837c, 0x00000000}, - {0x00008380, 0xffffffff}, - {0x00008384, 0xffffffff}, - {0x00008390, 0xffffffff}, - {0x00008394, 0xffffffff}, - {0x00008398, 0x00000000}, - {0x0000839c, 0x00000000}, - {0x000083a0, 0x00000000}, - {0x000083a4, 0x0000fa14}, - {0x000083a8, 0x000f0c00}, - {0x000083ac, 0x33332210}, - {0x000083b0, 0x33332210}, - {0x000083b4, 0x33332210}, - {0x000083b8, 0x33332210}, - {0x000083bc, 0x00000000}, - {0x000083c0, 0x00000000}, - {0x000083c4, 0x00000000}, - {0x000083c8, 0x00000000}, - {0x000083cc, 0x00000200}, - {0x000083d0, 0x000301ff}, -}; - -static const u32 ar9331_common_rx_gain_1p1[][2] = { - /* Addr allmodes */ - {0x0000a000, 0x00010000}, - {0x0000a004, 0x00030002}, - {0x0000a008, 0x00050004}, - {0x0000a00c, 0x00810080}, - {0x0000a010, 0x00830082}, - {0x0000a014, 0x01810180}, - {0x0000a018, 0x01830182}, - {0x0000a01c, 0x01850184}, - {0x0000a020, 0x01890188}, - {0x0000a024, 0x018b018a}, - {0x0000a028, 0x018d018c}, - {0x0000a02c, 0x01910190}, - {0x0000a030, 0x01930192}, - {0x0000a034, 0x01950194}, - {0x0000a038, 0x038a0196}, - {0x0000a03c, 0x038c038b}, - {0x0000a040, 0x0390038d}, - {0x0000a044, 0x03920391}, - {0x0000a048, 0x03940393}, - {0x0000a04c, 0x03960395}, - {0x0000a050, 0x00000000}, - {0x0000a054, 0x00000000}, - {0x0000a058, 0x00000000}, - {0x0000a05c, 0x00000000}, - {0x0000a060, 0x00000000}, - {0x0000a064, 0x00000000}, - {0x0000a068, 0x00000000}, - {0x0000a06c, 0x00000000}, - {0x0000a070, 0x00000000}, - {0x0000a074, 0x00000000}, - {0x0000a078, 0x00000000}, - {0x0000a07c, 0x00000000}, - {0x0000a080, 0x22222229}, - {0x0000a084, 0x1d1d1d1d}, - {0x0000a088, 0x1d1d1d1d}, - {0x0000a08c, 0x1d1d1d1d}, - {0x0000a090, 0x171d1d1d}, - {0x0000a094, 0x11111717}, - {0x0000a098, 0x00030311}, - {0x0000a09c, 0x00000000}, - {0x0000a0a0, 0x00000000}, - {0x0000a0a4, 0x00000000}, - {0x0000a0a8, 0x00000000}, - {0x0000a0ac, 0x00000000}, - {0x0000a0b0, 0x00000000}, - {0x0000a0b4, 0x00000000}, - {0x0000a0b8, 0x00000000}, - {0x0000a0bc, 0x00000000}, - {0x0000a0c0, 0x001f0000}, - {0x0000a0c4, 0x01000101}, - {0x0000a0c8, 0x011e011f}, - {0x0000a0cc, 0x011c011d}, - {0x0000a0d0, 0x02030204}, - {0x0000a0d4, 0x02010202}, - {0x0000a0d8, 0x021f0200}, - {0x0000a0dc, 0x0302021e}, - {0x0000a0e0, 0x03000301}, - {0x0000a0e4, 0x031e031f}, - {0x0000a0e8, 0x0402031d}, - {0x0000a0ec, 0x04000401}, - {0x0000a0f0, 0x041e041f}, - {0x0000a0f4, 0x0502041d}, - {0x0000a0f8, 0x05000501}, - {0x0000a0fc, 0x051e051f}, - {0x0000a100, 0x06010602}, - {0x0000a104, 0x061f0600}, - {0x0000a108, 0x061d061e}, - {0x0000a10c, 0x07020703}, - {0x0000a110, 0x07000701}, - {0x0000a114, 0x00000000}, - {0x0000a118, 0x00000000}, - {0x0000a11c, 0x00000000}, - {0x0000a120, 0x00000000}, - {0x0000a124, 0x00000000}, - {0x0000a128, 0x00000000}, - {0x0000a12c, 0x00000000}, - {0x0000a130, 0x00000000}, - {0x0000a134, 0x00000000}, - {0x0000a138, 0x00000000}, - {0x0000a13c, 0x00000000}, - {0x0000a140, 0x001f0000}, - {0x0000a144, 0x01000101}, - {0x0000a148, 0x011e011f}, - {0x0000a14c, 0x011c011d}, - {0x0000a150, 0x02030204}, - {0x0000a154, 0x02010202}, - {0x0000a158, 0x021f0200}, - {0x0000a15c, 0x0302021e}, - {0x0000a160, 0x03000301}, - {0x0000a164, 0x031e031f}, - {0x0000a168, 0x0402031d}, - {0x0000a16c, 0x04000401}, - {0x0000a170, 0x041e041f}, - {0x0000a174, 0x0502041d}, - {0x0000a178, 0x05000501}, - {0x0000a17c, 0x051e051f}, - {0x0000a180, 0x06010602}, - {0x0000a184, 0x061f0600}, - {0x0000a188, 0x061d061e}, - {0x0000a18c, 0x07020703}, - {0x0000a190, 0x07000701}, - {0x0000a194, 0x00000000}, - {0x0000a198, 0x00000000}, - {0x0000a19c, 0x00000000}, - {0x0000a1a0, 0x00000000}, - {0x0000a1a4, 0x00000000}, - {0x0000a1a8, 0x00000000}, - {0x0000a1ac, 0x00000000}, - {0x0000a1b0, 0x00000000}, - {0x0000a1b4, 0x00000000}, - {0x0000a1b8, 0x00000000}, - {0x0000a1bc, 0x00000000}, - {0x0000a1c0, 0x00000000}, - {0x0000a1c4, 0x00000000}, - {0x0000a1c8, 0x00000000}, - {0x0000a1cc, 0x00000000}, - {0x0000a1d0, 0x00000000}, - {0x0000a1d4, 0x00000000}, - {0x0000a1d8, 0x00000000}, - {0x0000a1dc, 0x00000000}, - {0x0000a1e0, 0x00000000}, - {0x0000a1e4, 0x00000000}, - {0x0000a1e8, 0x00000000}, - {0x0000a1ec, 0x00000000}, - {0x0000a1f0, 0x00000396}, - {0x0000a1f4, 0x00000396}, - {0x0000a1f8, 0x00000396}, - {0x0000a1fc, 0x00000196}, -}; - -static const u32 ar9331_common_tx_gain_offset1_1[][1] = { - {0}, - {3}, - {0}, - {0}, -}; - -static const u32 ar9331_1p1_chansel_xtal_25M[] = { - 0x0101479e, - 0x0101d027, - 0x010258af, - 0x0102e138, - 0x010369c0, - 0x0103f249, - 0x01047ad1, - 0x0105035a, - 0x01058be2, - 0x0106146b, - 0x01069cf3, - 0x0107257c, - 0x0107ae04, - 0x0108f5b2, -}; - -static const u32 ar9331_1p1_chansel_xtal_40M[] = { - 0x00a0ccbe, - 0x00a12213, - 0x00a17769, - 0x00a1ccbe, - 0x00a22213, - 0x00a27769, - 0x00a2ccbe, - 0x00a32213, - 0x00a37769, - 0x00a3ccbe, - 0x00a42213, - 0x00a47769, - 0x00a4ccbe, - 0x00a5998b, -}; - -#endif /* INITVALS_9330_1P1_H */ diff --git a/trunk/drivers/net/wireless/ath/ath9k/ar9330_1p2_initvals.h b/trunk/drivers/net/wireless/ath/ath9k/ar9330_1p2_initvals.h deleted file mode 100644 index 0e6ca0834b34..000000000000 --- a/trunk/drivers/net/wireless/ath/ath9k/ar9330_1p2_initvals.h +++ /dev/null @@ -1,1080 +0,0 @@ -/* - * Copyright (c) 2011 Atheros Communications Inc. - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef INITVALS_9330_1P2_H -#define INITVALS_9330_1P2_H - -static const u32 ar9331_modes_lowest_ob_db_tx_gain_1p2[][5] = { - /* Addr 5G_HT20 5G_HT40 2G_HT40 2G_HT20 */ - {0x0000a410, 0x000050d7, 0x000050d7, 0x000050d7, 0x000050d7}, - {0x0000a500, 0x00022200, 0x00022200, 0x00000000, 0x00000000}, - {0x0000a504, 0x05062002, 0x05062002, 0x04000002, 0x04000002}, - {0x0000a508, 0x0c002e00, 0x0c002e00, 0x08000004, 0x08000004}, - {0x0000a50c, 0x11062202, 0x11062202, 0x0d000200, 0x0d000200}, - {0x0000a510, 0x17022e00, 0x17022e00, 0x11000202, 0x11000202}, - {0x0000a514, 0x1d000ec2, 0x1d000ec2, 0x15000400, 0x15000400}, - {0x0000a518, 0x25020ec0, 0x25020ec0, 0x19000402, 0x19000402}, - {0x0000a51c, 0x2b020ec3, 0x2b020ec3, 0x1d000404, 0x1d000404}, - {0x0000a520, 0x2f001f04, 0x2f001f04, 0x23000a00, 0x23000a00}, - {0x0000a524, 0x35001fc4, 0x35001fc4, 0x27000a02, 0x27000a02}, - {0x0000a528, 0x3c022f04, 0x3c022f04, 0x2b000a04, 0x2b000a04}, - {0x0000a52c, 0x41023e85, 0x41023e85, 0x3f001620, 0x3f001620}, - {0x0000a530, 0x48023ec6, 0x48023ec6, 0x41001621, 0x41001621}, - {0x0000a534, 0x4d023f01, 0x4d023f01, 0x44001640, 0x44001640}, - {0x0000a538, 0x53023f4b, 0x53023f4b, 0x46001641, 0x46001641}, - {0x0000a53c, 0x5a027f09, 0x5a027f09, 0x48001642, 0x48001642}, - {0x0000a540, 0x5f027fc9, 0x5f027fc9, 0x4b001644, 0x4b001644}, - {0x0000a544, 0x6502feca, 0x6502feca, 0x4e001a81, 0x4e001a81}, - {0x0000a548, 0x6b02ff4a, 0x6b02ff4a, 0x51001a83, 0x51001a83}, - {0x0000a54c, 0x7203feca, 0x7203feca, 0x54001c84, 0x54001c84}, - {0x0000a550, 0x7703ff0b, 0x7703ff0b, 0x57001ce3, 0x57001ce3}, - {0x0000a554, 0x7d06ffcb, 0x7d06ffcb, 0x5b001ce5, 0x5b001ce5}, - {0x0000a558, 0x8407ff0b, 0x8407ff0b, 0x5f001ce9, 0x5f001ce9}, - {0x0000a55c, 0x8907ffcb, 0x8907ffcb, 0x66001eec, 0x66001eec}, - {0x0000a560, 0x900fff0b, 0x900fff0b, 0x66001eec, 0x66001eec}, - {0x0000a564, 0x960fffcb, 0x960fffcb, 0x66001eec, 0x66001eec}, - {0x0000a568, 0x9c1fff0b, 0x9c1fff0b, 0x66001eec, 0x66001eec}, - {0x0000a56c, 0x9c1fff0b, 0x9c1fff0b, 0x66001eec, 0x66001eec}, - {0x0000a570, 0x9c1fff0b, 0x9c1fff0b, 0x66001eec, 0x66001eec}, - {0x0000a574, 0x9c1fff0b, 0x9c1fff0b, 0x66001eec, 0x66001eec}, - {0x0000a578, 0x9c1fff0b, 0x9c1fff0b, 0x66001eec, 0x66001eec}, - {0x0000a57c, 0x9c1fff0b, 0x9c1fff0b, 0x66001eec, 0x66001eec}, - {0x0000a580, 0x00022200, 0x00022200, 0x00000000, 0x00000000}, - {0x0000a584, 0x05062002, 0x05062002, 0x04000002, 0x04000002}, - {0x0000a588, 0x0c002e00, 0x0c002e00, 0x08000004, 0x08000004}, - {0x0000a58c, 0x11062202, 0x11062202, 0x0b000200, 0x0b000200}, - {0x0000a590, 0x17022e00, 0x17022e00, 0x0f000202, 0x0f000202}, - {0x0000a594, 0x1d000ec2, 0x1d000ec2, 0x11000400, 0x11000400}, - {0x0000a598, 0x25020ec0, 0x25020ec0, 0x15000402, 0x15000402}, - {0x0000a59c, 0x2b020ec3, 0x2b020ec3, 0x19000404, 0x19000404}, - {0x0000a5a0, 0x2f001f04, 0x2f001f04, 0x1b000603, 0x1b000603}, - {0x0000a5a4, 0x35001fc4, 0x35001fc4, 0x1f000a02, 0x1f000a02}, - {0x0000a5a8, 0x3c022f04, 0x3c022f04, 0x23000a04, 0x23000a04}, - {0x0000a5ac, 0x41023e85, 0x41023e85, 0x26000a20, 0x26000a20}, - {0x0000a5b0, 0x48023ec6, 0x48023ec6, 0x2a000e20, 0x2a000e20}, - {0x0000a5b4, 0x4d023f01, 0x4d023f01, 0x2e000e22, 0x2e000e22}, - {0x0000a5b8, 0x53023f4b, 0x53023f4b, 0x31000e24, 0x31000e24}, - {0x0000a5bc, 0x5a027f09, 0x5a027f09, 0x34001640, 0x34001640}, - {0x0000a5c0, 0x5f027fc9, 0x5f027fc9, 0x38001660, 0x38001660}, - {0x0000a5c4, 0x6502feca, 0x6502feca, 0x3b001861, 0x3b001861}, - {0x0000a5c8, 0x6b02ff4a, 0x6b02ff4a, 0x3e001a81, 0x3e001a81}, - {0x0000a5cc, 0x7203feca, 0x7203feca, 0x42001a83, 0x42001a83}, - {0x0000a5d0, 0x7703ff0b, 0x7703ff0b, 0x44001c84, 0x44001c84}, - {0x0000a5d4, 0x7d06ffcb, 0x7d06ffcb, 0x48001ce3, 0x48001ce3}, - {0x0000a5d8, 0x8407ff0b, 0x8407ff0b, 0x4c001ce5, 0x4c001ce5}, - {0x0000a5dc, 0x8907ffcb, 0x8907ffcb, 0x50001ce9, 0x50001ce9}, - {0x0000a5e0, 0x900fff0b, 0x900fff0b, 0x54001ceb, 0x54001ceb}, - {0x0000a5e4, 0x960fffcb, 0x960fffcb, 0x56001eec, 0x56001eec}, - {0x0000a5e8, 0x9c1fff0b, 0x9c1fff0b, 0x56001eec, 0x56001eec}, - {0x0000a5ec, 0x9c1fff0b, 0x9c1fff0b, 0x56001eec, 0x56001eec}, - {0x0000a5f0, 0x9c1fff0b, 0x9c1fff0b, 0x56001eec, 0x56001eec}, - {0x0000a5f4, 0x9c1fff0b, 0x9c1fff0b, 0x56001eec, 0x56001eec}, - {0x0000a5f8, 0x9c1fff0b, 0x9c1fff0b, 0x56001eec, 0x56001eec}, - {0x0000a5fc, 0x9c1fff0b, 0x9c1fff0b, 0x56001eec, 0x56001eec}, - {0x0000a600, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x0000a604, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x0000a608, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x0000a60c, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x0000a610, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x0000a614, 0x01404000, 0x01404000, 0x01404000, 0x01404000}, - {0x0000a618, 0x02008501, 0x02008501, 0x02008501, 0x02008501}, - {0x0000a61c, 0x02008802, 0x02008802, 0x02008802, 0x02008802}, - {0x0000a620, 0x0300c802, 0x0300c802, 0x0300c802, 0x0300c802}, - {0x0000a624, 0x0300cc03, 0x0300cc03, 0x0300cc03, 0x0300cc03}, - {0x0000a628, 0x04011004, 0x04011004, 0x04011004, 0x04011004}, - {0x0000a62c, 0x04011004, 0x04011004, 0x04011004, 0x04011004}, - {0x0000a630, 0x04011004, 0x04011004, 0x04011004, 0x04011004}, - {0x0000a634, 0x04011004, 0x04011004, 0x04011004, 0x04011004}, - {0x0000a638, 0x04011004, 0x04011004, 0x04011004, 0x04011004}, - {0x0000a63c, 0x04011004, 0x04011004, 0x04011004, 0x04011004}, -}; - -static const u32 ar9331_1p2_baseband_postamble[][5] = { - /* Addr 5G_HT20 5G_HT40 2G_HT40 2G_HT20 */ - {0x00009810, 0xd00a8005, 0xd00a8005, 0xd00a8005, 0xd00a8005}, - {0x00009820, 0x206a002e, 0x206a002e, 0x206a002e, 0x206a002e}, - {0x00009824, 0x5ac640d0, 0x5ac640d0, 0x5ac640d0, 0x5ac640d0}, - {0x00009828, 0x06903081, 0x06903081, 0x06903881, 0x06903881}, - {0x0000982c, 0x05eea6d4, 0x05eea6d4, 0x05eea6d4, 0x05eea6d4}, - {0x00009830, 0x0000059c, 0x0000059c, 0x0000059c, 0x0000059c}, - {0x00009c00, 0x00000044, 0x00000044, 0x00000044, 0x00000044}, - {0x00009e00, 0x0372161e, 0x0372161e, 0x037216a4, 0x037216a4}, - {0x00009e04, 0x00182020, 0x00182020, 0x00182020, 0x00182020}, - {0x00009e0c, 0x6c4000e2, 0x6d4000e2, 0x6d4000e2, 0x6c4000e2}, - {0x00009e10, 0x7ec80d2e, 0x7ec80d2e, 0x7ec80d2e, 0x7ec80d2e}, - {0x00009e14, 0x31395d5e, 0x3139605e, 0x3139605e, 0x31395d5e}, - {0x00009e18, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x00009e1c, 0x0001cf9c, 0x0001cf9c, 0x00021f9c, 0x00021f9c}, - {0x00009e20, 0x000003b5, 0x000003b5, 0x000003ce, 0x000003ce}, - {0x00009e2c, 0x0000001c, 0x0000001c, 0x00003221, 0x00003221}, - {0x00009e3c, 0xcf946222, 0xcf946222, 0xcf946222, 0xcf946222}, - {0x00009e44, 0x02321e27, 0x02321e27, 0x02282324, 0x02282324}, - {0x00009e48, 0x5030201a, 0x5030201a, 0x50302010, 0x50302010}, - {0x00009fc8, 0x0003f000, 0x0003f000, 0x0001a000, 0x0001a000}, - {0x0000a204, 0x00003fc0, 0x00003fc4, 0x00003fc4, 0x00003fc0}, - {0x0000a208, 0x00000104, 0x00000104, 0x00000004, 0x00000004}, - {0x0000a230, 0x0000000a, 0x00000014, 0x00000016, 0x0000000b}, - {0x0000a234, 0x00000fff, 0x00000fff, 0x10000fff, 0x00000fff}, - {0x0000a238, 0xffb81018, 0xffb81018, 0xffb81018, 0xffb81018}, - {0x0000a250, 0x00000000, 0x00000000, 0x00000210, 0x00000108}, - {0x0000a254, 0x000007d0, 0x00000fa0, 0x00001130, 0x00000898}, - {0x0000a258, 0x02020002, 0x02020002, 0x02020002, 0x02020002}, - {0x0000a25c, 0x01000e0e, 0x01000e0e, 0x01000e0e, 0x01000e0e}, - {0x0000a260, 0x3a021501, 0x3a021501, 0x3a021501, 0x3a021501}, - {0x0000a264, 0x00000e0e, 0x00000e0e, 0x00000e0e, 0x00000e0e}, - {0x0000a280, 0x00000007, 0x00000007, 0x0000000b, 0x0000000b}, - {0x0000a284, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x0000a288, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x0000a28c, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x0000a2c4, 0x00158d18, 0x00158d18, 0x00158d18, 0x00158d18}, - {0x0000a2d0, 0x00071981, 0x00071981, 0x00071981, 0x00071981}, - {0x0000a2d8, 0xf999a83a, 0xf999a83a, 0xf999a83a, 0xf999a83a}, - {0x0000a358, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x0000ae04, 0x00802020, 0x00802020, 0x00802020, 0x00802020}, - {0x0000ae18, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, -}; - -static const u32 ar9331_modes_high_ob_db_tx_gain_1p2[][5] = { - /* Addr 5G_HT20 5G_HT40 2G_HT40 2G_HT20 */ - {0x0000a410, 0x000050d7, 0x000050d7, 0x000050d7, 0x000050d7}, - {0x0000a500, 0x00022200, 0x00022200, 0x00000000, 0x00000000}, - {0x0000a504, 0x05062002, 0x05062002, 0x04000002, 0x04000002}, - {0x0000a508, 0x0c002e00, 0x0c002e00, 0x08000004, 0x08000004}, - {0x0000a50c, 0x11062202, 0x11062202, 0x0d000200, 0x0d000200}, - {0x0000a510, 0x17022e00, 0x17022e00, 0x11000202, 0x11000202}, - {0x0000a514, 0x1d000ec2, 0x1d000ec2, 0x15000400, 0x15000400}, - {0x0000a518, 0x25020ec0, 0x25020ec0, 0x19000402, 0x19000402}, - {0x0000a51c, 0x2b020ec3, 0x2b020ec3, 0x1d000404, 0x1d000404}, - {0x0000a520, 0x2f001f04, 0x2f001f04, 0x23000a00, 0x23000a00}, - {0x0000a524, 0x35001fc4, 0x35001fc4, 0x27000a02, 0x27000a02}, - {0x0000a528, 0x3c022f04, 0x3c022f04, 0x2b000a04, 0x2b000a04}, - {0x0000a52c, 0x41023e85, 0x41023e85, 0x3f001620, 0x3f001620}, - {0x0000a530, 0x48023ec6, 0x48023ec6, 0x41001621, 0x41001621}, - {0x0000a534, 0x4d023f01, 0x4d023f01, 0x44001640, 0x44001640}, - {0x0000a538, 0x53023f4b, 0x53023f4b, 0x46001641, 0x46001641}, - {0x0000a53c, 0x5a027f09, 0x5a027f09, 0x48001642, 0x48001642}, - {0x0000a540, 0x5f027fc9, 0x5f027fc9, 0x4b001644, 0x4b001644}, - {0x0000a544, 0x6502feca, 0x6502feca, 0x4e001a81, 0x4e001a81}, - {0x0000a548, 0x6b02ff4a, 0x6b02ff4a, 0x51001a83, 0x51001a83}, - {0x0000a54c, 0x7203feca, 0x7203feca, 0x54001c84, 0x54001c84}, - {0x0000a550, 0x7703ff0b, 0x7703ff0b, 0x57001ce3, 0x57001ce3}, - {0x0000a554, 0x7d06ffcb, 0x7d06ffcb, 0x5b001ce5, 0x5b001ce5}, - {0x0000a558, 0x8407ff0b, 0x8407ff0b, 0x5f001ce9, 0x5f001ce9}, - {0x0000a55c, 0x8907ffcb, 0x8907ffcb, 0x66001eec, 0x66001eec}, - {0x0000a560, 0x900fff0b, 0x900fff0b, 0x66001eec, 0x66001eec}, - {0x0000a564, 0x960fffcb, 0x960fffcb, 0x66001eec, 0x66001eec}, - {0x0000a568, 0x9c1fff0b, 0x9c1fff0b, 0x66001eec, 0x66001eec}, - {0x0000a56c, 0x9c1fff0b, 0x9c1fff0b, 0x66001eec, 0x66001eec}, - {0x0000a570, 0x9c1fff0b, 0x9c1fff0b, 0x66001eec, 0x66001eec}, - {0x0000a574, 0x9c1fff0b, 0x9c1fff0b, 0x66001eec, 0x66001eec}, - {0x0000a578, 0x9c1fff0b, 0x9c1fff0b, 0x66001eec, 0x66001eec}, - {0x0000a57c, 0x9c1fff0b, 0x9c1fff0b, 0x66001eec, 0x66001eec}, - {0x0000a580, 0x00022200, 0x00022200, 0x00000000, 0x00000000}, - {0x0000a584, 0x05062002, 0x05062002, 0x04000002, 0x04000002}, - {0x0000a588, 0x0c002e00, 0x0c002e00, 0x08000004, 0x08000004}, - {0x0000a58c, 0x11062202, 0x11062202, 0x0b000200, 0x0b000200}, - {0x0000a590, 0x17022e00, 0x17022e00, 0x0f000202, 0x0f000202}, - {0x0000a594, 0x1d000ec2, 0x1d000ec2, 0x11000400, 0x11000400}, - {0x0000a598, 0x25020ec0, 0x25020ec0, 0x15000402, 0x15000402}, - {0x0000a59c, 0x2b020ec3, 0x2b020ec3, 0x19000404, 0x19000404}, - {0x0000a5a0, 0x2f001f04, 0x2f001f04, 0x1b000603, 0x1b000603}, - {0x0000a5a4, 0x35001fc4, 0x35001fc4, 0x1f000a02, 0x1f000a02}, - {0x0000a5a8, 0x3c022f04, 0x3c022f04, 0x23000a04, 0x23000a04}, - {0x0000a5ac, 0x41023e85, 0x41023e85, 0x26000a20, 0x26000a20}, - {0x0000a5b0, 0x48023ec6, 0x48023ec6, 0x2a000e20, 0x2a000e20}, - {0x0000a5b4, 0x4d023f01, 0x4d023f01, 0x2e000e22, 0x2e000e22}, - {0x0000a5b8, 0x53023f4b, 0x53023f4b, 0x31000e24, 0x31000e24}, - {0x0000a5bc, 0x5a027f09, 0x5a027f09, 0x34001640, 0x34001640}, - {0x0000a5c0, 0x5f027fc9, 0x5f027fc9, 0x38001660, 0x38001660}, - {0x0000a5c4, 0x6502feca, 0x6502feca, 0x3b001861, 0x3b001861}, - {0x0000a5c8, 0x6b02ff4a, 0x6b02ff4a, 0x3e001a81, 0x3e001a81}, - {0x0000a5cc, 0x7203feca, 0x7203feca, 0x42001a83, 0x42001a83}, - {0x0000a5d0, 0x7703ff0b, 0x7703ff0b, 0x44001c84, 0x44001c84}, - {0x0000a5d4, 0x7d06ffcb, 0x7d06ffcb, 0x48001ce3, 0x48001ce3}, - {0x0000a5d8, 0x8407ff0b, 0x8407ff0b, 0x4c001ce5, 0x4c001ce5}, - {0x0000a5dc, 0x8907ffcb, 0x8907ffcb, 0x50001ce9, 0x50001ce9}, - {0x0000a5e0, 0x900fff0b, 0x900fff0b, 0x54001ceb, 0x54001ceb}, - {0x0000a5e4, 0x960fffcb, 0x960fffcb, 0x56001eec, 0x56001eec}, - {0x0000a5e8, 0x9c1fff0b, 0x9c1fff0b, 0x56001eec, 0x56001eec}, - {0x0000a5ec, 0x9c1fff0b, 0x9c1fff0b, 0x56001eec, 0x56001eec}, - {0x0000a5f0, 0x9c1fff0b, 0x9c1fff0b, 0x56001eec, 0x56001eec}, - {0x0000a5f4, 0x9c1fff0b, 0x9c1fff0b, 0x56001eec, 0x56001eec}, - {0x0000a5f8, 0x9c1fff0b, 0x9c1fff0b, 0x56001eec, 0x56001eec}, - {0x0000a5fc, 0x9c1fff0b, 0x9c1fff0b, 0x56001eec, 0x56001eec}, - {0x0000a600, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x0000a604, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x0000a608, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x0000a60c, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x0000a610, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x0000a614, 0x01404000, 0x01404000, 0x01404000, 0x01404000}, - {0x0000a618, 0x02008501, 0x02008501, 0x02008501, 0x02008501}, - {0x0000a61c, 0x02008802, 0x02008802, 0x02008802, 0x02008802}, - {0x0000a620, 0x0300c802, 0x0300c802, 0x0300c802, 0x0300c802}, - {0x0000a624, 0x0300cc03, 0x0300cc03, 0x0300cc03, 0x0300cc03}, - {0x0000a628, 0x04011004, 0x04011004, 0x04011004, 0x04011004}, - {0x0000a62c, 0x04011004, 0x04011004, 0x04011004, 0x04011004}, - {0x0000a630, 0x04011004, 0x04011004, 0x04011004, 0x04011004}, - {0x0000a634, 0x04011004, 0x04011004, 0x04011004, 0x04011004}, - {0x0000a638, 0x04011004, 0x04011004, 0x04011004, 0x04011004}, - {0x0000a63c, 0x04011004, 0x04011004, 0x04011004, 0x04011004}, -}; - -static const u32 ar9331_modes_low_ob_db_tx_gain_1p2[][5] = { - /* Addr 5G_HT20 5G_HT40 2G_HT40 2G_HT20 */ - {0x0000a410, 0x000050d7, 0x000050d7, 0x000050d7, 0x000050d7}, - {0x0000a500, 0x00022200, 0x00022200, 0x00000000, 0x00000000}, - {0x0000a504, 0x05062002, 0x05062002, 0x04000002, 0x04000002}, - {0x0000a508, 0x0c002e00, 0x0c002e00, 0x08000004, 0x08000004}, - {0x0000a50c, 0x11062202, 0x11062202, 0x0d000200, 0x0d000200}, - {0x0000a510, 0x17022e00, 0x17022e00, 0x11000202, 0x11000202}, - {0x0000a514, 0x1d000ec2, 0x1d000ec2, 0x15000400, 0x15000400}, - {0x0000a518, 0x25020ec0, 0x25020ec0, 0x19000402, 0x19000402}, - {0x0000a51c, 0x2b020ec3, 0x2b020ec3, 0x1d000404, 0x1d000404}, - {0x0000a520, 0x2f001f04, 0x2f001f04, 0x23000a00, 0x23000a00}, - {0x0000a524, 0x35001fc4, 0x35001fc4, 0x27000a02, 0x27000a02}, - {0x0000a528, 0x3c022f04, 0x3c022f04, 0x2b000a04, 0x2b000a04}, - {0x0000a52c, 0x41023e85, 0x41023e85, 0x3f001620, 0x3f001620}, - {0x0000a530, 0x48023ec6, 0x48023ec6, 0x41001621, 0x41001621}, - {0x0000a534, 0x4d023f01, 0x4d023f01, 0x44001640, 0x44001640}, - {0x0000a538, 0x53023f4b, 0x53023f4b, 0x46001641, 0x46001641}, - {0x0000a53c, 0x5a027f09, 0x5a027f09, 0x48001642, 0x48001642}, - {0x0000a540, 0x5f027fc9, 0x5f027fc9, 0x4b001644, 0x4b001644}, - {0x0000a544, 0x6502feca, 0x6502feca, 0x4e001a81, 0x4e001a81}, - {0x0000a548, 0x6b02ff4a, 0x6b02ff4a, 0x51001a83, 0x51001a83}, - {0x0000a54c, 0x7203feca, 0x7203feca, 0x54001c84, 0x54001c84}, - {0x0000a550, 0x7703ff0b, 0x7703ff0b, 0x57001ce3, 0x57001ce3}, - {0x0000a554, 0x7d06ffcb, 0x7d06ffcb, 0x5b001ce5, 0x5b001ce5}, - {0x0000a558, 0x8407ff0b, 0x8407ff0b, 0x5f001ce9, 0x5f001ce9}, - {0x0000a55c, 0x8907ffcb, 0x8907ffcb, 0x66001eec, 0x66001eec}, - {0x0000a560, 0x900fff0b, 0x900fff0b, 0x66001eec, 0x66001eec}, - {0x0000a564, 0x960fffcb, 0x960fffcb, 0x66001eec, 0x66001eec}, - {0x0000a568, 0x9c1fff0b, 0x9c1fff0b, 0x66001eec, 0x66001eec}, - {0x0000a56c, 0x9c1fff0b, 0x9c1fff0b, 0x66001eec, 0x66001eec}, - {0x0000a570, 0x9c1fff0b, 0x9c1fff0b, 0x66001eec, 0x66001eec}, - {0x0000a574, 0x9c1fff0b, 0x9c1fff0b, 0x66001eec, 0x66001eec}, - {0x0000a578, 0x9c1fff0b, 0x9c1fff0b, 0x66001eec, 0x66001eec}, - {0x0000a57c, 0x9c1fff0b, 0x9c1fff0b, 0x66001eec, 0x66001eec}, - {0x0000a580, 0x00022200, 0x00022200, 0x00000000, 0x00000000}, - {0x0000a584, 0x05062002, 0x05062002, 0x04000002, 0x04000002}, - {0x0000a588, 0x0c002e00, 0x0c002e00, 0x08000004, 0x08000004}, - {0x0000a58c, 0x11062202, 0x11062202, 0x0b000200, 0x0b000200}, - {0x0000a590, 0x17022e00, 0x17022e00, 0x0f000202, 0x0f000202}, - {0x0000a594, 0x1d000ec2, 0x1d000ec2, 0x11000400, 0x11000400}, - {0x0000a598, 0x25020ec0, 0x25020ec0, 0x15000402, 0x15000402}, - {0x0000a59c, 0x2b020ec3, 0x2b020ec3, 0x19000404, 0x19000404}, - {0x0000a5a0, 0x2f001f04, 0x2f001f04, 0x1b000603, 0x1b000603}, - {0x0000a5a4, 0x35001fc4, 0x35001fc4, 0x1f000a02, 0x1f000a02}, - {0x0000a5a8, 0x3c022f04, 0x3c022f04, 0x23000a04, 0x23000a04}, - {0x0000a5ac, 0x41023e85, 0x41023e85, 0x26000a20, 0x26000a20}, - {0x0000a5b0, 0x48023ec6, 0x48023ec6, 0x2a000e20, 0x2a000e20}, - {0x0000a5b4, 0x4d023f01, 0x4d023f01, 0x2e000e22, 0x2e000e22}, - {0x0000a5b8, 0x53023f4b, 0x53023f4b, 0x31000e24, 0x31000e24}, - {0x0000a5bc, 0x5a027f09, 0x5a027f09, 0x34001640, 0x34001640}, - {0x0000a5c0, 0x5f027fc9, 0x5f027fc9, 0x38001660, 0x38001660}, - {0x0000a5c4, 0x6502feca, 0x6502feca, 0x3b001861, 0x3b001861}, - {0x0000a5c8, 0x6b02ff4a, 0x6b02ff4a, 0x3e001a81, 0x3e001a81}, - {0x0000a5cc, 0x7203feca, 0x7203feca, 0x42001a83, 0x42001a83}, - {0x0000a5d0, 0x7703ff0b, 0x7703ff0b, 0x44001c84, 0x44001c84}, - {0x0000a5d4, 0x7d06ffcb, 0x7d06ffcb, 0x48001ce3, 0x48001ce3}, - {0x0000a5d8, 0x8407ff0b, 0x8407ff0b, 0x4c001ce5, 0x4c001ce5}, - {0x0000a5dc, 0x8907ffcb, 0x8907ffcb, 0x50001ce9, 0x50001ce9}, - {0x0000a5e0, 0x900fff0b, 0x900fff0b, 0x54001ceb, 0x54001ceb}, - {0x0000a5e4, 0x960fffcb, 0x960fffcb, 0x56001eec, 0x56001eec}, - {0x0000a5e8, 0x9c1fff0b, 0x9c1fff0b, 0x56001eec, 0x56001eec}, - {0x0000a5ec, 0x9c1fff0b, 0x9c1fff0b, 0x56001eec, 0x56001eec}, - {0x0000a5f0, 0x9c1fff0b, 0x9c1fff0b, 0x56001eec, 0x56001eec}, - {0x0000a5f4, 0x9c1fff0b, 0x9c1fff0b, 0x56001eec, 0x56001eec}, - {0x0000a5f8, 0x9c1fff0b, 0x9c1fff0b, 0x56001eec, 0x56001eec}, - {0x0000a5fc, 0x9c1fff0b, 0x9c1fff0b, 0x56001eec, 0x56001eec}, - {0x0000a600, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x0000a604, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x0000a608, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x0000a60c, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x0000a610, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x0000a614, 0x01404000, 0x01404000, 0x01404000, 0x01404000}, - {0x0000a618, 0x02008501, 0x02008501, 0x02008501, 0x02008501}, - {0x0000a61c, 0x02008802, 0x02008802, 0x02008802, 0x02008802}, - {0x0000a620, 0x0300c802, 0x0300c802, 0x0300c802, 0x0300c802}, - {0x0000a624, 0x0300cc03, 0x0300cc03, 0x0300cc03, 0x0300cc03}, - {0x0000a628, 0x04011004, 0x04011004, 0x04011004, 0x04011004}, - {0x0000a62c, 0x04011004, 0x04011004, 0x04011004, 0x04011004}, - {0x0000a630, 0x04011004, 0x04011004, 0x04011004, 0x04011004}, - {0x0000a634, 0x04011004, 0x04011004, 0x04011004, 0x04011004}, - {0x0000a638, 0x04011004, 0x04011004, 0x04011004, 0x04011004}, - {0x0000a63c, 0x04011004, 0x04011004, 0x04011004, 0x04011004}, -}; - -static const u32 ar9331_1p2_baseband_core_txfir_coeff_japan_2484[][2] = { - /* Addr allmodes */ - {0x0000a398, 0x00000000}, - {0x0000a39c, 0x6f7f0301}, - {0x0000a3a0, 0xca9228ee}, -}; - -static const u32 ar9331_1p2_xtal_25M[][2] = { - /* Addr allmodes */ - {0x00007038, 0x000002f8}, - {0x00008244, 0x0010f3d7}, - {0x0000824c, 0x0001e7ae}, - {0x0001609c, 0x0f508f29}, -}; - -static const u32 ar9331_1p2_radio_core[][2] = { - /* Addr allmodes */ - {0x00016000, 0x36db6db6}, - {0x00016004, 0x6db6db40}, - {0x00016008, 0x73800000}, - {0x0001600c, 0x00000000}, - {0x00016040, 0x7f80fff8}, - {0x00016044, 0x03d6d2db}, - {0x00016048, 0x6c924268}, - {0x0001604c, 0x000f0278}, - {0x00016050, 0x4db6db8c}, - {0x00016054, 0x6db60000}, - {0x00016080, 0x00080000}, - {0x00016084, 0x0e48048c}, - {0x00016088, 0x14214514}, - {0x0001608c, 0x119f081c}, - {0x00016090, 0x24926490}, - {0x00016098, 0xd411eb84}, - {0x000160a0, 0xc2108ffe}, - {0x000160a4, 0x812fc370}, - {0x000160a8, 0x423c8000}, - {0x000160ac, 0x24651800}, - {0x000160b0, 0x03284f3e}, - {0x000160b4, 0x92480040}, - {0x000160c0, 0x006db6db}, - {0x000160c4, 0x0186db60}, - {0x000160c8, 0x6db6db6c}, - {0x000160cc, 0x6de6c300}, - {0x000160d0, 0x14500820}, - {0x00016100, 0x04cb0001}, - {0x00016104, 0xfff80015}, - {0x00016108, 0x00080010}, - {0x0001610c, 0x00170000}, - {0x00016140, 0x10804000}, - {0x00016144, 0x01884080}, - {0x00016148, 0x000080c0}, - {0x00016280, 0x01000015}, - {0x00016284, 0x14d20000}, - {0x00016288, 0x00318000}, - {0x0001628c, 0x50000000}, - {0x00016290, 0x4b96210f}, - {0x00016380, 0x00000000}, - {0x00016384, 0x00000000}, - {0x00016388, 0x00800700}, - {0x0001638c, 0x00800700}, - {0x00016390, 0x00800700}, - {0x00016394, 0x00000000}, - {0x00016398, 0x00000000}, - {0x0001639c, 0x00000000}, - {0x000163a0, 0x00000001}, - {0x000163a4, 0x00000001}, - {0x000163a8, 0x00000000}, - {0x000163ac, 0x00000000}, - {0x000163b0, 0x00000000}, - {0x000163b4, 0x00000000}, - {0x000163b8, 0x00000000}, - {0x000163bc, 0x00000000}, - {0x000163c0, 0x000000a0}, - {0x000163c4, 0x000c0000}, - {0x000163c8, 0x14021402}, - {0x000163cc, 0x00001402}, - {0x000163d0, 0x00000000}, - {0x000163d4, 0x00000000}, -}; - -static const u32 ar9331_1p2_soc_postamble[][5] = { - /* Addr 5G_HT20 5G_HT40 2G_HT40 2G_HT20 */ - {0x00007010, 0x00000022, 0x00000022, 0x00000022, 0x00000022}, -}; - -static const u32 ar9331_common_wo_xlna_rx_gain_1p2[][2] = { - /* Addr allmodes */ - {0x0000a000, 0x00060005}, - {0x0000a004, 0x00810080}, - {0x0000a008, 0x00830082}, - {0x0000a00c, 0x00850084}, - {0x0000a010, 0x01820181}, - {0x0000a014, 0x01840183}, - {0x0000a018, 0x01880185}, - {0x0000a01c, 0x018a0189}, - {0x0000a020, 0x02850284}, - {0x0000a024, 0x02890288}, - {0x0000a028, 0x028b028a}, - {0x0000a02c, 0x03850384}, - {0x0000a030, 0x03890388}, - {0x0000a034, 0x038b038a}, - {0x0000a038, 0x038d038c}, - {0x0000a03c, 0x03910390}, - {0x0000a040, 0x03930392}, - {0x0000a044, 0x03950394}, - {0x0000a048, 0x00000396}, - {0x0000a04c, 0x00000000}, - {0x0000a050, 0x00000000}, - {0x0000a054, 0x00000000}, - {0x0000a058, 0x00000000}, - {0x0000a05c, 0x00000000}, - {0x0000a060, 0x00000000}, - {0x0000a064, 0x00000000}, - {0x0000a068, 0x00000000}, - {0x0000a06c, 0x00000000}, - {0x0000a070, 0x00000000}, - {0x0000a074, 0x00000000}, - {0x0000a078, 0x00000000}, - {0x0000a07c, 0x00000000}, - {0x0000a080, 0x28282828}, - {0x0000a084, 0x28282828}, - {0x0000a088, 0x28282828}, - {0x0000a08c, 0x28282828}, - {0x0000a090, 0x28282828}, - {0x0000a094, 0x24242428}, - {0x0000a098, 0x171e1e1e}, - {0x0000a09c, 0x02020b0b}, - {0x0000a0a0, 0x02020202}, - {0x0000a0a4, 0x00000000}, - {0x0000a0a8, 0x00000000}, - {0x0000a0ac, 0x00000000}, - {0x0000a0b0, 0x00000000}, - {0x0000a0b4, 0x00000000}, - {0x0000a0b8, 0x00000000}, - {0x0000a0bc, 0x00000000}, - {0x0000a0c0, 0x22072208}, - {0x0000a0c4, 0x22052206}, - {0x0000a0c8, 0x22032204}, - {0x0000a0cc, 0x22012202}, - {0x0000a0d0, 0x221f2200}, - {0x0000a0d4, 0x221d221e}, - {0x0000a0d8, 0x33023303}, - {0x0000a0dc, 0x33003301}, - {0x0000a0e0, 0x331e331f}, - {0x0000a0e4, 0x4402331d}, - {0x0000a0e8, 0x44004401}, - {0x0000a0ec, 0x441e441f}, - {0x0000a0f0, 0x55025503}, - {0x0000a0f4, 0x55005501}, - {0x0000a0f8, 0x551e551f}, - {0x0000a0fc, 0x6602551d}, - {0x0000a100, 0x66006601}, - {0x0000a104, 0x661e661f}, - {0x0000a108, 0x7703661d}, - {0x0000a10c, 0x77017702}, - {0x0000a110, 0x00007700}, - {0x0000a114, 0x00000000}, - {0x0000a118, 0x00000000}, - {0x0000a11c, 0x00000000}, - {0x0000a120, 0x00000000}, - {0x0000a124, 0x00000000}, - {0x0000a128, 0x00000000}, - {0x0000a12c, 0x00000000}, - {0x0000a130, 0x00000000}, - {0x0000a134, 0x00000000}, - {0x0000a138, 0x00000000}, - {0x0000a13c, 0x00000000}, - {0x0000a140, 0x001f0000}, - {0x0000a144, 0x111f1100}, - {0x0000a148, 0x111d111e}, - {0x0000a14c, 0x111b111c}, - {0x0000a150, 0x22032204}, - {0x0000a154, 0x22012202}, - {0x0000a158, 0x221f2200}, - {0x0000a15c, 0x221d221e}, - {0x0000a160, 0x33013302}, - {0x0000a164, 0x331f3300}, - {0x0000a168, 0x4402331e}, - {0x0000a16c, 0x44004401}, - {0x0000a170, 0x441e441f}, - {0x0000a174, 0x55015502}, - {0x0000a178, 0x551f5500}, - {0x0000a17c, 0x6602551e}, - {0x0000a180, 0x66006601}, - {0x0000a184, 0x661e661f}, - {0x0000a188, 0x7703661d}, - {0x0000a18c, 0x77017702}, - {0x0000a190, 0x00007700}, - {0x0000a194, 0x00000000}, - {0x0000a198, 0x00000000}, - {0x0000a19c, 0x00000000}, - {0x0000a1a0, 0x00000000}, - {0x0000a1a4, 0x00000000}, - {0x0000a1a8, 0x00000000}, - {0x0000a1ac, 0x00000000}, - {0x0000a1b0, 0x00000000}, - {0x0000a1b4, 0x00000000}, - {0x0000a1b8, 0x00000000}, - {0x0000a1bc, 0x00000000}, - {0x0000a1c0, 0x00000000}, - {0x0000a1c4, 0x00000000}, - {0x0000a1c8, 0x00000000}, - {0x0000a1cc, 0x00000000}, - {0x0000a1d0, 0x00000000}, - {0x0000a1d4, 0x00000000}, - {0x0000a1d8, 0x00000000}, - {0x0000a1dc, 0x00000000}, - {0x0000a1e0, 0x00000000}, - {0x0000a1e4, 0x00000000}, - {0x0000a1e8, 0x00000000}, - {0x0000a1ec, 0x00000000}, - {0x0000a1f0, 0x00000396}, - {0x0000a1f4, 0x00000396}, - {0x0000a1f8, 0x00000396}, - {0x0000a1fc, 0x00000296}, -}; - -static const u32 ar9331_1p2_baseband_core[][2] = { - /* Addr allmodes */ - {0x00009800, 0xafe68e30}, - {0x00009804, 0xfd14e000}, - {0x00009808, 0x9c0a8f6b}, - {0x0000980c, 0x04800000}, - {0x00009814, 0x9280c00a}, - {0x00009818, 0x00000000}, - {0x0000981c, 0x00020028}, - {0x00009834, 0x5f3ca3de}, - {0x00009838, 0x0108ecff}, - {0x0000983c, 0x14750600}, - {0x00009880, 0x201fff00}, - {0x00009884, 0x00001042}, - {0x000098a4, 0x00200400}, - {0x000098b0, 0x32840bbe}, - {0x000098d0, 0x004b6a8e}, - {0x000098d4, 0x00000820}, - {0x000098dc, 0x00000000}, - {0x000098f0, 0x00000000}, - {0x000098f4, 0x00000000}, - {0x00009c04, 0x00000000}, - {0x00009c08, 0x03200000}, - {0x00009c0c, 0x00000000}, - {0x00009c10, 0x00000000}, - {0x00009c14, 0x00046384}, - {0x00009c18, 0x05b6b440}, - {0x00009c1c, 0x00b6b440}, - {0x00009d00, 0xc080a333}, - {0x00009d04, 0x40206c10}, - {0x00009d08, 0x009c4060}, - {0x00009d0c, 0x1883800a}, - {0x00009d10, 0x01834061}, - {0x00009d14, 0x00c00400}, - {0x00009d18, 0x00000000}, - {0x00009e08, 0x0038233c}, - {0x00009e24, 0x9927b515}, - {0x00009e28, 0x12ef0200}, - {0x00009e30, 0x06336f77}, - {0x00009e34, 0x6af6532f}, - {0x00009e38, 0x0cc80c00}, - {0x00009e40, 0x0d261820}, - {0x00009e4c, 0x00001004}, - {0x00009e50, 0x00ff03f1}, - {0x00009fc0, 0x803e4788}, - {0x00009fc4, 0x0001efb5}, - {0x00009fcc, 0x40000014}, - {0x0000a20c, 0x00000000}, - {0x0000a220, 0x00000000}, - {0x0000a224, 0x00000000}, - {0x0000a228, 0x10002310}, - {0x0000a23c, 0x00000000}, - {0x0000a244, 0x0c000000}, - {0x0000a2a0, 0x00000001}, - {0x0000a2c0, 0x00000001}, - {0x0000a2c8, 0x00000000}, - {0x0000a2cc, 0x18c43433}, - {0x0000a2d4, 0x00000000}, - {0x0000a2dc, 0x00000000}, - {0x0000a2e0, 0x00000000}, - {0x0000a2e4, 0x00000000}, - {0x0000a2e8, 0x00000000}, - {0x0000a2ec, 0x00000000}, - {0x0000a2f0, 0x00000000}, - {0x0000a2f4, 0x00000000}, - {0x0000a2f8, 0x00000000}, - {0x0000a344, 0x00000000}, - {0x0000a34c, 0x00000000}, - {0x0000a350, 0x0000a000}, - {0x0000a364, 0x00000000}, - {0x0000a370, 0x00000000}, - {0x0000a390, 0x00000001}, - {0x0000a394, 0x00000444}, - {0x0000a398, 0x001f0e0f}, - {0x0000a39c, 0x0075393f}, - {0x0000a3a0, 0xb79f6427}, - {0x0000a3a4, 0x00000000}, - {0x0000a3a8, 0xaaaaaaaa}, - {0x0000a3ac, 0x3c466478}, - {0x0000a3c0, 0x20202020}, - {0x0000a3c4, 0x22222220}, - {0x0000a3c8, 0x20200020}, - {0x0000a3cc, 0x20202020}, - {0x0000a3d0, 0x20202020}, - {0x0000a3d4, 0x20202020}, - {0x0000a3d8, 0x20202020}, - {0x0000a3dc, 0x20202020}, - {0x0000a3e0, 0x20202020}, - {0x0000a3e4, 0x20202020}, - {0x0000a3e8, 0x20202020}, - {0x0000a3ec, 0x20202020}, - {0x0000a3f0, 0x00000000}, - {0x0000a3f4, 0x00000006}, - {0x0000a3f8, 0x0cdbd380}, - {0x0000a3fc, 0x000f0f01}, - {0x0000a400, 0x8fa91f01}, - {0x0000a404, 0x00000000}, - {0x0000a408, 0x0e79e5c6}, - {0x0000a40c, 0x00820820}, - {0x0000a414, 0x1ce739ce}, - {0x0000a418, 0x2d001dce}, - {0x0000a41c, 0x1ce739ce}, - {0x0000a420, 0x000001ce}, - {0x0000a424, 0x1ce739ce}, - {0x0000a428, 0x000001ce}, - {0x0000a42c, 0x1ce739ce}, - {0x0000a430, 0x1ce739ce}, - {0x0000a434, 0x00000000}, - {0x0000a438, 0x00001801}, - {0x0000a43c, 0x00000000}, - {0x0000a440, 0x00000000}, - {0x0000a444, 0x00000000}, - {0x0000a448, 0x04000000}, - {0x0000a44c, 0x00000001}, - {0x0000a450, 0x00010000}, - {0x0000a458, 0x00000000}, - {0x0000a640, 0x00000000}, - {0x0000a644, 0x3fad9d74}, - {0x0000a648, 0x0048060a}, - {0x0000a64c, 0x00003c37}, - {0x0000a670, 0x03020100}, - {0x0000a674, 0x09080504}, - {0x0000a678, 0x0d0c0b0a}, - {0x0000a67c, 0x13121110}, - {0x0000a680, 0x31301514}, - {0x0000a684, 0x35343332}, - {0x0000a688, 0x00000036}, - {0x0000a690, 0x00000838}, - {0x0000a7c0, 0x00000000}, - {0x0000a7c4, 0xfffffffc}, - {0x0000a7c8, 0x00000000}, - {0x0000a7cc, 0x00000000}, - {0x0000a7d0, 0x00000000}, - {0x0000a7d4, 0x00000004}, - {0x0000a7dc, 0x00000001}, -}; - -static const u32 ar9331_modes_high_power_tx_gain_1p2[][5] = { - /* Addr 5G_HT20 5G_HT40 2G_HT40 2G_HT20 */ - {0x0000a410, 0x000050d7, 0x000050d7, 0x000050d7, 0x000050d7}, - {0x0000a500, 0x00022200, 0x00022200, 0x00000000, 0x00000000}, - {0x0000a504, 0x05062002, 0x05062002, 0x04000002, 0x04000002}, - {0x0000a508, 0x0c002e00, 0x0c002e00, 0x08000004, 0x08000004}, - {0x0000a50c, 0x11062202, 0x11062202, 0x0d000200, 0x0d000200}, - {0x0000a510, 0x17022e00, 0x17022e00, 0x11000202, 0x11000202}, - {0x0000a514, 0x1d000ec2, 0x1d000ec2, 0x15000400, 0x15000400}, - {0x0000a518, 0x25020ec0, 0x25020ec0, 0x19000402, 0x19000402}, - {0x0000a51c, 0x2b020ec3, 0x2b020ec3, 0x1d000404, 0x1d000404}, - {0x0000a520, 0x2f001f04, 0x2f001f04, 0x23000a00, 0x23000a00}, - {0x0000a524, 0x35001fc4, 0x35001fc4, 0x27000a02, 0x27000a02}, - {0x0000a528, 0x3c022f04, 0x3c022f04, 0x2b000a04, 0x2b000a04}, - {0x0000a52c, 0x41023e85, 0x41023e85, 0x3f001620, 0x3f001620}, - {0x0000a530, 0x48023ec6, 0x48023ec6, 0x41001621, 0x41001621}, - {0x0000a534, 0x4d023f01, 0x4d023f01, 0x44001640, 0x44001640}, - {0x0000a538, 0x53023f4b, 0x53023f4b, 0x46001641, 0x46001641}, - {0x0000a53c, 0x5a027f09, 0x5a027f09, 0x48001642, 0x48001642}, - {0x0000a540, 0x5f027fc9, 0x5f027fc9, 0x4b001644, 0x4b001644}, - {0x0000a544, 0x6502feca, 0x6502feca, 0x4e001a81, 0x4e001a81}, - {0x0000a548, 0x6b02ff4a, 0x6b02ff4a, 0x51001a83, 0x51001a83}, - {0x0000a54c, 0x7203feca, 0x7203feca, 0x54001c84, 0x54001c84}, - {0x0000a550, 0x7703ff0b, 0x7703ff0b, 0x57001ce3, 0x57001ce3}, - {0x0000a554, 0x7d06ffcb, 0x7d06ffcb, 0x5b001ce5, 0x5b001ce5}, - {0x0000a558, 0x8407ff0b, 0x8407ff0b, 0x5f001ce9, 0x5f001ce9}, - {0x0000a55c, 0x8907ffcb, 0x8907ffcb, 0x66001eec, 0x66001eec}, - {0x0000a560, 0x900fff0b, 0x900fff0b, 0x66001eec, 0x66001eec}, - {0x0000a564, 0x960fffcb, 0x960fffcb, 0x66001eec, 0x66001eec}, - {0x0000a568, 0x9c1fff0b, 0x9c1fff0b, 0x66001eec, 0x66001eec}, - {0x0000a56c, 0x9c1fff0b, 0x9c1fff0b, 0x66001eec, 0x66001eec}, - {0x0000a570, 0x9c1fff0b, 0x9c1fff0b, 0x66001eec, 0x66001eec}, - {0x0000a574, 0x9c1fff0b, 0x9c1fff0b, 0x66001eec, 0x66001eec}, - {0x0000a578, 0x9c1fff0b, 0x9c1fff0b, 0x66001eec, 0x66001eec}, - {0x0000a57c, 0x9c1fff0b, 0x9c1fff0b, 0x66001eec, 0x66001eec}, - {0x0000a580, 0x00022200, 0x00022200, 0x00000000, 0x00000000}, - {0x0000a584, 0x05062002, 0x05062002, 0x04000002, 0x04000002}, - {0x0000a588, 0x0c002e00, 0x0c002e00, 0x08000004, 0x08000004}, - {0x0000a58c, 0x11062202, 0x11062202, 0x0b000200, 0x0b000200}, - {0x0000a590, 0x17022e00, 0x17022e00, 0x0f000202, 0x0f000202}, - {0x0000a594, 0x1d000ec2, 0x1d000ec2, 0x11000400, 0x11000400}, - {0x0000a598, 0x25020ec0, 0x25020ec0, 0x15000402, 0x15000402}, - {0x0000a59c, 0x2b020ec3, 0x2b020ec3, 0x19000404, 0x19000404}, - {0x0000a5a0, 0x2f001f04, 0x2f001f04, 0x1b000603, 0x1b000603}, - {0x0000a5a4, 0x35001fc4, 0x35001fc4, 0x1f000a02, 0x1f000a02}, - {0x0000a5a8, 0x3c022f04, 0x3c022f04, 0x23000a04, 0x23000a04}, - {0x0000a5ac, 0x41023e85, 0x41023e85, 0x26000a20, 0x26000a20}, - {0x0000a5b0, 0x48023ec6, 0x48023ec6, 0x2a000e20, 0x2a000e20}, - {0x0000a5b4, 0x4d023f01, 0x4d023f01, 0x2e000e22, 0x2e000e22}, - {0x0000a5b8, 0x53023f4b, 0x53023f4b, 0x31000e24, 0x31000e24}, - {0x0000a5bc, 0x5a027f09, 0x5a027f09, 0x34001640, 0x34001640}, - {0x0000a5c0, 0x5f027fc9, 0x5f027fc9, 0x38001660, 0x38001660}, - {0x0000a5c4, 0x6502feca, 0x6502feca, 0x3b001861, 0x3b001861}, - {0x0000a5c8, 0x6b02ff4a, 0x6b02ff4a, 0x3e001a81, 0x3e001a81}, - {0x0000a5cc, 0x7203feca, 0x7203feca, 0x42001a83, 0x42001a83}, - {0x0000a5d0, 0x7703ff0b, 0x7703ff0b, 0x44001c84, 0x44001c84}, - {0x0000a5d4, 0x7d06ffcb, 0x7d06ffcb, 0x48001ce3, 0x48001ce3}, - {0x0000a5d8, 0x8407ff0b, 0x8407ff0b, 0x4c001ce5, 0x4c001ce5}, - {0x0000a5dc, 0x8907ffcb, 0x8907ffcb, 0x50001ce9, 0x50001ce9}, - {0x0000a5e0, 0x900fff0b, 0x900fff0b, 0x54001ceb, 0x54001ceb}, - {0x0000a5e4, 0x960fffcb, 0x960fffcb, 0x56001eec, 0x56001eec}, - {0x0000a5e8, 0x9c1fff0b, 0x9c1fff0b, 0x56001eec, 0x56001eec}, - {0x0000a5ec, 0x9c1fff0b, 0x9c1fff0b, 0x56001eec, 0x56001eec}, - {0x0000a5f0, 0x9c1fff0b, 0x9c1fff0b, 0x56001eec, 0x56001eec}, - {0x0000a5f4, 0x9c1fff0b, 0x9c1fff0b, 0x56001eec, 0x56001eec}, - {0x0000a5f8, 0x9c1fff0b, 0x9c1fff0b, 0x56001eec, 0x56001eec}, - {0x0000a5fc, 0x9c1fff0b, 0x9c1fff0b, 0x56001eec, 0x56001eec}, - {0x0000a600, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x0000a604, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x0000a608, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x0000a60c, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x0000a610, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x0000a614, 0x01404000, 0x01404000, 0x01404000, 0x01404000}, - {0x0000a618, 0x02008501, 0x02008501, 0x02008501, 0x02008501}, - {0x0000a61c, 0x02008802, 0x02008802, 0x02008802, 0x02008802}, - {0x0000a620, 0x0300c802, 0x0300c802, 0x0300c802, 0x0300c802}, - {0x0000a624, 0x0300cc03, 0x0300cc03, 0x0300cc03, 0x0300cc03}, - {0x0000a628, 0x04011004, 0x04011004, 0x04011004, 0x04011004}, - {0x0000a62c, 0x04011004, 0x04011004, 0x04011004, 0x04011004}, - {0x0000a630, 0x04011004, 0x04011004, 0x04011004, 0x04011004}, - {0x0000a634, 0x04011004, 0x04011004, 0x04011004, 0x04011004}, - {0x0000a638, 0x04011004, 0x04011004, 0x04011004, 0x04011004}, - {0x0000a63c, 0x04011004, 0x04011004, 0x04011004, 0x04011004}, -}; - -static const u32 ar9331_1p2_mac_postamble[][5] = { - /* Addr 5G_HT20 5G_HT40 2G_HT40 2G_HT20 */ - {0x00001030, 0x00000230, 0x00000460, 0x000002c0, 0x00000160}, - {0x00001070, 0x00000168, 0x000002d0, 0x00000318, 0x0000018c}, - {0x000010b0, 0x00000e60, 0x00001cc0, 0x00007c70, 0x00003e38}, - {0x00008014, 0x03e803e8, 0x07d007d0, 0x10801600, 0x08400b00}, - {0x0000801c, 0x128d8027, 0x128d804f, 0x12e00057, 0x12e0002b}, - {0x00008120, 0x08f04800, 0x08f04800, 0x08f04810, 0x08f04810}, - {0x000081d0, 0x00003210, 0x00003210, 0x0000320a, 0x0000320a}, - {0x00008318, 0x00003e80, 0x00007d00, 0x00006880, 0x00003440}, -}; - -static const u32 ar9331_1p2_soc_preamble[][2] = { - /* Addr allmodes */ - {0x00007020, 0x00000000}, - {0x00007034, 0x00000002}, - {0x00007038, 0x000002f8}, -}; - -static const u32 ar9331_1p2_xtal_40M[][2] = { - /* Addr allmodes */ - {0x00007038, 0x000004c2}, - {0x00008244, 0x0010f400}, - {0x0000824c, 0x0001e800}, - {0x0001609c, 0x0b283f31}, -}; - -static const u32 ar9331_1p2_mac_core[][2] = { - /* Addr allmodes */ - {0x00000008, 0x00000000}, - {0x00000030, 0x00020085}, - {0x00000034, 0x00000005}, - {0x00000040, 0x00000000}, - {0x00000044, 0x00000000}, - {0x00000048, 0x00000008}, - {0x0000004c, 0x00000010}, - {0x00000050, 0x00000000}, - {0x00001040, 0x002ffc0f}, - {0x00001044, 0x002ffc0f}, - {0x00001048, 0x002ffc0f}, - {0x0000104c, 0x002ffc0f}, - {0x00001050, 0x002ffc0f}, - {0x00001054, 0x002ffc0f}, - {0x00001058, 0x002ffc0f}, - {0x0000105c, 0x002ffc0f}, - {0x00001060, 0x002ffc0f}, - {0x00001064, 0x002ffc0f}, - {0x000010f0, 0x00000100}, - {0x00001270, 0x00000000}, - {0x000012b0, 0x00000000}, - {0x000012f0, 0x00000000}, - {0x0000143c, 0x00000000}, - {0x0000147c, 0x00000000}, - {0x00008000, 0x00000000}, - {0x00008004, 0x00000000}, - {0x00008008, 0x00000000}, - {0x0000800c, 0x00000000}, - {0x00008018, 0x00000000}, - {0x00008020, 0x00000000}, - {0x00008038, 0x00000000}, - {0x0000803c, 0x00000000}, - {0x00008040, 0x00000000}, - {0x00008044, 0x00000000}, - {0x00008048, 0x00000000}, - {0x0000804c, 0xffffffff}, - {0x00008054, 0x00000000}, - {0x00008058, 0x00000000}, - {0x0000805c, 0x000fc78f}, - {0x00008060, 0x0000000f}, - {0x00008064, 0x00000000}, - {0x00008070, 0x00000310}, - {0x00008074, 0x00000020}, - {0x00008078, 0x00000000}, - {0x0000809c, 0x0000000f}, - {0x000080a0, 0x00000000}, - {0x000080a4, 0x02ff0000}, - {0x000080a8, 0x0e070605}, - {0x000080ac, 0x0000000d}, - {0x000080b0, 0x00000000}, - {0x000080b4, 0x00000000}, - {0x000080b8, 0x00000000}, - {0x000080bc, 0x00000000}, - {0x000080c0, 0x2a800000}, - {0x000080c4, 0x06900168}, - {0x000080c8, 0x13881c20}, - {0x000080cc, 0x01f40000}, - {0x000080d0, 0x00252500}, - {0x000080d4, 0x00a00000}, - {0x000080d8, 0x00400000}, - {0x000080dc, 0x00000000}, - {0x000080e0, 0xffffffff}, - {0x000080e4, 0x0000ffff}, - {0x000080e8, 0x3f3f3f3f}, - {0x000080ec, 0x00000000}, - {0x000080f0, 0x00000000}, - {0x000080f4, 0x00000000}, - {0x000080fc, 0x00020000}, - {0x00008100, 0x00000000}, - {0x00008108, 0x00000052}, - {0x0000810c, 0x00000000}, - {0x00008110, 0x00000000}, - {0x00008114, 0x000007ff}, - {0x00008118, 0x000000aa}, - {0x0000811c, 0x00003210}, - {0x00008124, 0x00000000}, - {0x00008128, 0x00000000}, - {0x0000812c, 0x00000000}, - {0x00008130, 0x00000000}, - {0x00008134, 0x00000000}, - {0x00008138, 0x00000000}, - {0x0000813c, 0x0000ffff}, - {0x00008144, 0xffffffff}, - {0x00008168, 0x00000000}, - {0x0000816c, 0x00000000}, - {0x00008170, 0x18486200}, - {0x00008174, 0x33332210}, - {0x00008178, 0x00000000}, - {0x0000817c, 0x00020000}, - {0x000081c0, 0x00000000}, - {0x000081c4, 0x33332210}, - {0x000081c8, 0x00000000}, - {0x000081cc, 0x00000000}, - {0x000081d4, 0x00000000}, - {0x000081ec, 0x00000000}, - {0x000081f0, 0x00000000}, - {0x000081f4, 0x00000000}, - {0x000081f8, 0x00000000}, - {0x000081fc, 0x00000000}, - {0x00008240, 0x00100000}, - {0x00008248, 0x00000800}, - {0x00008250, 0x00000000}, - {0x00008254, 0x00000000}, - {0x00008258, 0x00000000}, - {0x0000825c, 0x40000000}, - {0x00008260, 0x00080922}, - {0x00008264, 0x9d400010}, - {0x00008268, 0xffffffff}, - {0x0000826c, 0x0000ffff}, - {0x00008270, 0x00000000}, - {0x00008274, 0x40000000}, - {0x00008278, 0x003e4180}, - {0x0000827c, 0x00000004}, - {0x00008284, 0x0000002c}, - {0x00008288, 0x0000002c}, - {0x0000828c, 0x000000ff}, - {0x00008294, 0x00000000}, - {0x00008298, 0x00000000}, - {0x0000829c, 0x00000000}, - {0x00008300, 0x00000140}, - {0x00008314, 0x00000000}, - {0x0000831c, 0x0000010d}, - {0x00008328, 0x00000000}, - {0x0000832c, 0x00000007}, - {0x00008330, 0x00000302}, - {0x00008334, 0x00000700}, - {0x00008338, 0x00ff0000}, - {0x0000833c, 0x02400000}, - {0x00008340, 0x000107ff}, - {0x00008344, 0xaa48105b}, - {0x00008348, 0x008f0000}, - {0x0000835c, 0x00000000}, - {0x00008360, 0xffffffff}, - {0x00008364, 0xffffffff}, - {0x00008368, 0x00000000}, - {0x00008370, 0x00000000}, - {0x00008374, 0x000000ff}, - {0x00008378, 0x00000000}, - {0x0000837c, 0x00000000}, - {0x00008380, 0xffffffff}, - {0x00008384, 0xffffffff}, - {0x00008390, 0xffffffff}, - {0x00008394, 0xffffffff}, - {0x00008398, 0x00000000}, - {0x0000839c, 0x00000000}, - {0x000083a0, 0x00000000}, - {0x000083a4, 0x0000fa14}, - {0x000083a8, 0x000f0c00}, - {0x000083ac, 0x33332210}, - {0x000083b0, 0x33332210}, - {0x000083b4, 0x33332210}, - {0x000083b8, 0x33332210}, - {0x000083bc, 0x00000000}, - {0x000083c0, 0x00000000}, - {0x000083c4, 0x00000000}, - {0x000083c8, 0x00000000}, - {0x000083cc, 0x00000200}, - {0x000083d0, 0x000301ff}, -}; - -static const u32 ar9331_common_rx_gain_1p2[][2] = { - /* Addr allmodes */ - {0x0000a000, 0x00010000}, - {0x0000a004, 0x00030002}, - {0x0000a008, 0x00050004}, - {0x0000a00c, 0x00810080}, - {0x0000a010, 0x01800082}, - {0x0000a014, 0x01820181}, - {0x0000a018, 0x01840183}, - {0x0000a01c, 0x01880185}, - {0x0000a020, 0x018a0189}, - {0x0000a024, 0x02850284}, - {0x0000a028, 0x02890288}, - {0x0000a02c, 0x03850384}, - {0x0000a030, 0x03890388}, - {0x0000a034, 0x038b038a}, - {0x0000a038, 0x038d038c}, - {0x0000a03c, 0x03910390}, - {0x0000a040, 0x03930392}, - {0x0000a044, 0x03950394}, - {0x0000a048, 0x00000396}, - {0x0000a04c, 0x00000000}, - {0x0000a050, 0x00000000}, - {0x0000a054, 0x00000000}, - {0x0000a058, 0x00000000}, - {0x0000a05c, 0x00000000}, - {0x0000a060, 0x00000000}, - {0x0000a064, 0x00000000}, - {0x0000a068, 0x00000000}, - {0x0000a06c, 0x00000000}, - {0x0000a070, 0x00000000}, - {0x0000a074, 0x00000000}, - {0x0000a078, 0x00000000}, - {0x0000a07c, 0x00000000}, - {0x0000a080, 0x28282828}, - {0x0000a084, 0x28282828}, - {0x0000a088, 0x28282828}, - {0x0000a08c, 0x28282828}, - {0x0000a090, 0x28282828}, - {0x0000a094, 0x21212128}, - {0x0000a098, 0x171c1c1c}, - {0x0000a09c, 0x02020212}, - {0x0000a0a0, 0x00000202}, - {0x0000a0a4, 0x00000000}, - {0x0000a0a8, 0x00000000}, - {0x0000a0ac, 0x00000000}, - {0x0000a0b0, 0x00000000}, - {0x0000a0b4, 0x00000000}, - {0x0000a0b8, 0x00000000}, - {0x0000a0bc, 0x00000000}, - {0x0000a0c0, 0x001f0000}, - {0x0000a0c4, 0x111f1100}, - {0x0000a0c8, 0x111d111e}, - {0x0000a0cc, 0x111b111c}, - {0x0000a0d0, 0x22032204}, - {0x0000a0d4, 0x22012202}, - {0x0000a0d8, 0x221f2200}, - {0x0000a0dc, 0x221d221e}, - {0x0000a0e0, 0x33013302}, - {0x0000a0e4, 0x331f3300}, - {0x0000a0e8, 0x4402331e}, - {0x0000a0ec, 0x44004401}, - {0x0000a0f0, 0x441e441f}, - {0x0000a0f4, 0x55015502}, - {0x0000a0f8, 0x551f5500}, - {0x0000a0fc, 0x6602551e}, - {0x0000a100, 0x66006601}, - {0x0000a104, 0x661e661f}, - {0x0000a108, 0x7703661d}, - {0x0000a10c, 0x77017702}, - {0x0000a110, 0x00007700}, - {0x0000a114, 0x00000000}, - {0x0000a118, 0x00000000}, - {0x0000a11c, 0x00000000}, - {0x0000a120, 0x00000000}, - {0x0000a124, 0x00000000}, - {0x0000a128, 0x00000000}, - {0x0000a12c, 0x00000000}, - {0x0000a130, 0x00000000}, - {0x0000a134, 0x00000000}, - {0x0000a138, 0x00000000}, - {0x0000a13c, 0x00000000}, - {0x0000a140, 0x001f0000}, - {0x0000a144, 0x111f1100}, - {0x0000a148, 0x111d111e}, - {0x0000a14c, 0x111b111c}, - {0x0000a150, 0x22032204}, - {0x0000a154, 0x22012202}, - {0x0000a158, 0x221f2200}, - {0x0000a15c, 0x221d221e}, - {0x0000a160, 0x33013302}, - {0x0000a164, 0x331f3300}, - {0x0000a168, 0x4402331e}, - {0x0000a16c, 0x44004401}, - {0x0000a170, 0x441e441f}, - {0x0000a174, 0x55015502}, - {0x0000a178, 0x551f5500}, - {0x0000a17c, 0x6602551e}, - {0x0000a180, 0x66006601}, - {0x0000a184, 0x661e661f}, - {0x0000a188, 0x7703661d}, - {0x0000a18c, 0x77017702}, - {0x0000a190, 0x00007700}, - {0x0000a194, 0x00000000}, - {0x0000a198, 0x00000000}, - {0x0000a19c, 0x00000000}, - {0x0000a1a0, 0x00000000}, - {0x0000a1a4, 0x00000000}, - {0x0000a1a8, 0x00000000}, - {0x0000a1ac, 0x00000000}, - {0x0000a1b0, 0x00000000}, - {0x0000a1b4, 0x00000000}, - {0x0000a1b8, 0x00000000}, - {0x0000a1bc, 0x00000000}, - {0x0000a1c0, 0x00000000}, - {0x0000a1c4, 0x00000000}, - {0x0000a1c8, 0x00000000}, - {0x0000a1cc, 0x00000000}, - {0x0000a1d0, 0x00000000}, - {0x0000a1d4, 0x00000000}, - {0x0000a1d8, 0x00000000}, - {0x0000a1dc, 0x00000000}, - {0x0000a1e0, 0x00000000}, - {0x0000a1e4, 0x00000000}, - {0x0000a1e8, 0x00000000}, - {0x0000a1ec, 0x00000000}, - {0x0000a1f0, 0x00000396}, - {0x0000a1f4, 0x00000396}, - {0x0000a1f8, 0x00000396}, - {0x0000a1fc, 0x00000296}, -}; - -#endif /* INITVALS_9330_1P2_H */ diff --git a/trunk/drivers/net/wireless/ath/ath9k/ath9k.h b/trunk/drivers/net/wireless/ath/ath9k/ath9k.h index 46393f90f16c..57933db57633 100644 --- a/trunk/drivers/net/wireless/ath/ath9k/ath9k.h +++ b/trunk/drivers/net/wireless/ath/ath9k/ath9k.h @@ -55,6 +55,8 @@ struct ath_node; (_l) &= ((_sz) - 1); \ } while (0) +#define A_MAX(a, b) ((a) > (b) ? (a) : (b)) + #define TSF_TO_TU(_h,_l) \ ((((u32)(_h)) << 22) | (((u32)(_l)) >> 10)) @@ -101,11 +103,6 @@ enum buffer_type { #define ATH_TXSTATUS_RING_SIZE 64 -#define DS2PHYS(_dd, _ds) \ - ((_dd)->dd_desc_paddr + ((caddr_t)(_ds) - (caddr_t)(_dd)->dd_desc)) -#define ATH_DESC_4KB_BOUND_CHECK(_daddr) ((((_daddr) & 0xFFF) > 0xF7F) ? 1 : 0) -#define ATH_DESC_4KB_BOUND_NUM_SKIPPED(_len) ((_len) / 4096) - struct ath_descdma { void *dd_desc; dma_addr_t dd_desc_paddr; @@ -583,7 +580,7 @@ struct ath9k_vif_iter_data { int naps; /* number of AP vifs */ int nmeshes; /* number of mesh vifs */ int nstations; /* number of station vifs */ - int nwds; /* number of WDS vifs */ + int nwds; /* number of nwd vifs */ int nadhocs; /* number of adhoc vifs */ int nothers; /* number of vifs not specified above. */ }; diff --git a/trunk/drivers/net/wireless/ath/ath9k/beacon.c b/trunk/drivers/net/wireless/ath/ath9k/beacon.c index 0d13ff74a68b..4c790b5f7937 100644 --- a/trunk/drivers/net/wireless/ath/ath9k/beacon.c +++ b/trunk/drivers/net/wireless/ath/ath9k/beacon.c @@ -361,7 +361,6 @@ void ath_beacon_tasklet(unsigned long data) struct ath_common *common = ath9k_hw_common(ah); struct ath_buf *bf = NULL; struct ieee80211_vif *vif; - struct ath_tx_status ts; int slot; u32 bfaddr, bc = 0; @@ -386,9 +385,7 @@ void ath_beacon_tasklet(unsigned long data) ath_dbg(common, ATH_DBG_BSTUCK, "beacon is officially stuck\n"); sc->sc_flags |= SC_OP_TSF_RESET; - spin_lock(&sc->sc_pcu_lock); ath_reset(sc, true); - spin_unlock(&sc->sc_pcu_lock); } return; @@ -468,11 +465,6 @@ void ath_beacon_tasklet(unsigned long data) ath9k_hw_txstart(ah, sc->beacon.beaconq); sc->beacon.ast_be_xmit += bc; /* XXX per-vif? */ - if (ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) { - spin_lock_bh(&sc->sc_pcu_lock); - ath9k_hw_txprocdesc(ah, bf->bf_desc, (void *)&ts); - spin_unlock_bh(&sc->sc_pcu_lock); - } } } diff --git a/trunk/drivers/net/wireless/ath/ath9k/hif_usb.c b/trunk/drivers/net/wireless/ath/ath9k/hif_usb.c index 8028fe90f666..260f1f37a60e 100644 --- a/trunk/drivers/net/wireless/ath/ath9k/hif_usb.c +++ b/trunk/drivers/net/wireless/ath/ath9k/hif_usb.c @@ -49,8 +49,6 @@ static struct usb_device_id ath9k_hif_usb_ids[] = { .driver_info = AR9280_USB }, /* Netgear WNDA3200 */ { USB_DEVICE(0x083A, 0xA704), .driver_info = AR9280_USB }, /* SMC Networks */ - { USB_DEVICE(0x0411, 0x017f), - .driver_info = AR9280_USB }, /* Sony UWA-BR100 */ { USB_DEVICE(0x0cf3, 0x20ff), .driver_info = STORAGE_DEVICE }, diff --git a/trunk/drivers/net/wireless/ath/ath9k/hw.c b/trunk/drivers/net/wireless/ath/ath9k/hw.c index 07827b55e84b..6de2655e07dd 100644 --- a/trunk/drivers/net/wireless/ath/ath9k/hw.c +++ b/trunk/drivers/net/wireless/ath/ath9k/hw.c @@ -251,15 +251,6 @@ static void ath9k_hw_read_revisions(struct ath_hw *ah) case AR5416_AR9100_DEVID: ah->hw_version.macVersion = AR_SREV_VERSION_9100; break; - case AR9300_DEVID_AR9330: - ah->hw_version.macVersion = AR_SREV_VERSION_9330; - if (ah->get_mac_revision) { - ah->hw_version.macRev = ah->get_mac_revision(); - } else { - val = REG_READ(ah, AR_SREV); - ah->hw_version.macRev = MS(val, AR_SREV_REVISION2); - } - return; case AR9300_DEVID_AR9340: ah->hw_version.macVersion = AR_SREV_VERSION_9340; val = REG_READ(ah, AR_SREV); @@ -560,7 +551,6 @@ static int __ath9k_hw_init(struct ath_hw *ah) case AR_SREV_VERSION_9287: case AR_SREV_VERSION_9271: case AR_SREV_VERSION_9300: - case AR_SREV_VERSION_9330: case AR_SREV_VERSION_9485: case AR_SREV_VERSION_9340: break; @@ -571,8 +561,7 @@ static int __ath9k_hw_init(struct ath_hw *ah) return -EOPNOTSUPP; } - if (AR_SREV_9271(ah) || AR_SREV_9100(ah) || AR_SREV_9340(ah) || - AR_SREV_9330(ah)) + if (AR_SREV_9271(ah) || AR_SREV_9100(ah) || AR_SREV_9340(ah)) ah->is_pciexpress = false; ah->hw_version.phyRev = REG_READ(ah, AR_PHY_CHIP_ID); @@ -615,10 +604,7 @@ static int __ath9k_hw_init(struct ath_hw *ah) else ah->tx_trig_level = (AR_FTRIG_512B >> AR_FTRIG_S); - if (AR_SREV_9330(ah)) - ah->bb_watchdog_timeout_ms = 85; - else - ah->bb_watchdog_timeout_ms = 25; + ah->bb_watchdog_timeout_ms = 25; common->state = ATH_HW_INITIALIZED; @@ -644,7 +630,6 @@ int ath9k_hw_init(struct ath_hw *ah) case AR2427_DEVID_PCIE: case AR9300_DEVID_PCIE: case AR9300_DEVID_AR9485_PCIE: - case AR9300_DEVID_AR9330: case AR9300_DEVID_AR9340: break; default: @@ -737,39 +722,6 @@ static void ath9k_hw_init_pll(struct ath_hw *ah, REG_RMW_FIELD(ah, AR_CH0_BB_DPLL2, AR_CH0_BB_DPLL2_PLL_PWD, 0x0); udelay(1000); - } else if (AR_SREV_9330(ah)) { - u32 ddr_dpll2, pll_control2, kd; - - if (ah->is_clk_25mhz) { - ddr_dpll2 = 0x18e82f01; - pll_control2 = 0xe04a3d; - kd = 0x1d; - } else { - ddr_dpll2 = 0x19e82f01; - pll_control2 = 0x886666; - kd = 0x3d; - } - - /* program DDR PLL ki and kd value */ - REG_WRITE(ah, AR_CH0_DDR_DPLL2, ddr_dpll2); - - /* program DDR PLL phase_shift */ - REG_RMW_FIELD(ah, AR_CH0_DDR_DPLL3, - AR_CH0_DPLL3_PHASE_SHIFT, 0x1); - - REG_WRITE(ah, AR_RTC_PLL_CONTROL, 0x1142c); - udelay(1000); - - /* program refdiv, nint, frac to RTC register */ - REG_WRITE(ah, AR_RTC_PLL_CONTROL2, pll_control2); - - /* program BB PLL kd and ki value */ - REG_RMW_FIELD(ah, AR_CH0_BB_DPLL2, AR_CH0_DPLL2_KD, kd); - REG_RMW_FIELD(ah, AR_CH0_BB_DPLL2, AR_CH0_DPLL2_KI, 0x06); - - /* program BB PLL phase_shift */ - REG_RMW_FIELD(ah, AR_CH0_BB_DPLL3, - AR_CH0_BB_DPLL3_PHASE_SHIFT, 0x1); } else if (AR_SREV_9340(ah)) { u32 regval, pll2_divint, pll2_divfrac, refdiv; @@ -811,7 +763,7 @@ static void ath9k_hw_init_pll(struct ath_hw *ah, REG_WRITE(ah, AR_RTC_PLL_CONTROL, pll); - if (AR_SREV_9485(ah) || AR_SREV_9340(ah) || AR_SREV_9330(ah)) + if (AR_SREV_9485(ah) || AR_SREV_9340(ah)) udelay(1000); /* Switch the core clock for ar9271 to 117Mhz */ @@ -1162,41 +1114,6 @@ static bool ath9k_hw_set_reset(struct ath_hw *ah, int type) rst_flags |= AR_RTC_RC_MAC_COLD; } - if (AR_SREV_9330(ah)) { - int npend = 0; - int i; - - /* AR9330 WAR: - * call external reset function to reset WMAC if: - * - doing a cold reset - * - we have pending frames in the TX queues - */ - - for (i = 0; i < AR_NUM_QCU; i++) { - npend = ath9k_hw_numtxpending(ah, i); - if (npend) - break; - } - - if (ah->external_reset && - (npend || type == ATH9K_RESET_COLD)) { - int reset_err = 0; - - ath_dbg(ath9k_hw_common(ah), ATH_DBG_RESET, - "reset MAC via external reset\n"); - - reset_err = ah->external_reset(); - if (reset_err) { - ath_err(ath9k_hw_common(ah), - "External reset failed, err=%d\n", - reset_err); - return false; - } - - REG_WRITE(ah, AR_RTC_RESET, 1); - } - } - REG_WRITE(ah, AR_RTC_RC, rst_flags); REGWRITE_BUFFER_FLUSH(ah); @@ -1628,7 +1545,7 @@ int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan, REG_WRITE(ah, AR_CFG, AR_CFG_SWTD | AR_CFG_SWRD); } #ifdef __BIG_ENDIAN - else if (AR_SREV_9330(ah) || AR_SREV_9340(ah)) + else if (AR_SREV_9340(ah)) REG_RMW(ah, AR_CFG, AR_CFG_SWRB | AR_CFG_SWTB, 0); else REG_WRITE(ah, AR_CFG, AR_CFG_SWTD | AR_CFG_SWRD); @@ -2066,7 +1983,7 @@ int ath9k_hw_fill_cap_info(struct ath_hw *ah) if (AR_SREV_9300_20_OR_LATER(ah)) { pCap->hw_caps |= ATH9K_HW_CAP_EDMA | ATH9K_HW_CAP_FASTCLOCK; - if (!AR_SREV_9330(ah) && !AR_SREV_9485(ah)) + if (!AR_SREV_9485(ah)) pCap->hw_caps |= ATH9K_HW_CAP_LDPC; pCap->rx_hp_qdepth = ATH9K_HW_RX_HP_QDEPTH; @@ -2108,7 +2025,7 @@ int ath9k_hw_fill_cap_info(struct ath_hw *ah) } - if (AR_SREV_9330(ah) || AR_SREV_9485(ah)) { + if (AR_SREV_9485(ah)) { ant_div_ctl1 = ah->eep_ops->get_eeprom(ah, EEP_ANT_DIV_CTL1); /* * enable the diversity-combining algorithm only when @@ -2657,7 +2574,6 @@ static struct { { AR_SREV_VERSION_9287, "9287" }, { AR_SREV_VERSION_9271, "9271" }, { AR_SREV_VERSION_9300, "9300" }, - { AR_SREV_VERSION_9330, "9330" }, { AR_SREV_VERSION_9485, "9485" }, }; diff --git a/trunk/drivers/net/wireless/ath/ath9k/hw.h b/trunk/drivers/net/wireless/ath/ath9k/hw.h index 818acdd1ba90..6a6fb5439831 100644 --- a/trunk/drivers/net/wireless/ath/ath9k/hw.h +++ b/trunk/drivers/net/wireless/ath/ath9k/hw.h @@ -45,7 +45,6 @@ #define AR9300_DEVID_PCIE 0x0030 #define AR9300_DEVID_AR9340 0x0031 #define AR9300_DEVID_AR9485_PCIE 0x0032 -#define AR9300_DEVID_AR9330 0x0035 #define AR5416_AR9100_DEVID 0x000b @@ -158,9 +157,8 @@ #define ATH9K_HW_RX_HP_QDEPTH 16 #define ATH9K_HW_RX_LP_QDEPTH 128 -#define PAPRD_GAIN_TABLE_ENTRIES 32 -#define PAPRD_TABLE_SZ 24 -#define PAPRD_IDEAL_AGC2_PWR_RANGE 0xe0 +#define PAPRD_GAIN_TABLE_ENTRIES 32 +#define PAPRD_TABLE_SZ 24 enum ath_hw_txq_subtype { ATH_TXQ_AC_BE = 0, @@ -862,8 +860,6 @@ struct ath_hw { u32 ent_mode; bool is_clk_25mhz; - int (*get_mac_revision)(void); - int (*external_reset)(void); }; struct ath_bus_ops { diff --git a/trunk/drivers/net/wireless/ath/ath9k/init.c b/trunk/drivers/net/wireless/ath/ath9k/init.c index b855fe1adc39..1202bb0a5534 100644 --- a/trunk/drivers/net/wireless/ath/ath9k/init.c +++ b/trunk/drivers/net/wireless/ath/ath9k/init.c @@ -246,7 +246,7 @@ static void setup_ht_cap(struct ath_softc *sc, ht_info->ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K; ht_info->ampdu_density = IEEE80211_HT_MPDU_DENSITY_8; - if (AR_SREV_9330(ah) || AR_SREV_9485(ah)) + if (AR_SREV_9485(ah)) max_streams = 1; else if (AR_SREV_9300_20_OR_LATER(ah)) max_streams = 3; @@ -299,6 +299,10 @@ int ath_descdma_setup(struct ath_softc *sc, struct ath_descdma *dd, struct list_head *head, const char *name, int nbuf, int ndesc, bool is_tx) { +#define DS2PHYS(_dd, _ds) \ + ((_dd)->dd_desc_paddr + ((caddr_t)(_ds) - (caddr_t)(_dd)->dd_desc)) +#define ATH_DESC_4KB_BOUND_CHECK(_daddr) ((((_daddr) & 0xFFF) > 0xF7F) ? 1 : 0) +#define ATH_DESC_4KB_BOUND_NUM_SKIPPED(_len) ((_len) / 4096) struct ath_common *common = ath9k_hw_common(sc->sc_ah); u8 *ds; struct ath_buf *bf; @@ -393,6 +397,9 @@ int ath_descdma_setup(struct ath_softc *sc, struct ath_descdma *dd, fail: memset(dd, 0, sizeof(*dd)); return error; +#undef ATH_DESC_4KB_BOUND_CHECK +#undef ATH_DESC_4KB_BOUND_NUM_SKIPPED +#undef DS2PHYS } void ath9k_init_crypto(struct ath_softc *sc) @@ -568,8 +575,6 @@ static int ath9k_init_softc(u16 devid, struct ath_softc *sc, u16 subsysid, sc->sc_ah->gpio_val = pdata->gpio_val; sc->sc_ah->led_pin = pdata->led_pin; ah->is_clk_25mhz = pdata->is_clk_25mhz; - ah->get_mac_revision = pdata->get_mac_revision; - ah->external_reset = pdata->external_reset; } common = ath9k_hw_common(ah); diff --git a/trunk/drivers/net/wireless/ath/ath9k/main.c b/trunk/drivers/net/wireless/ath/ath9k/main.c index 9098aaad97a9..7f945333e2d8 100644 --- a/trunk/drivers/net/wireless/ath/ath9k/main.c +++ b/trunk/drivers/net/wireless/ath/ath9k/main.c @@ -360,7 +360,7 @@ static bool ath_paprd_send_frame(struct ath_softc *sc, struct sk_buff *skb, int txctl.paprd = BIT(chain); if (ath_tx_start(hw, skb, &txctl) != 0) { - ath_dbg(common, ATH_DBG_CALIBRATE, "PAPRD TX failed\n"); + ath_dbg(common, ATH_DBG_XMIT, "PAPRD TX failed\n"); dev_kfree_skb_any(skb); return false; } @@ -369,7 +369,7 @@ static bool ath_paprd_send_frame(struct ath_softc *sc, struct sk_buff *skb, int msecs_to_jiffies(ATH_PAPRD_TIMEOUT)); if (!time_left) - ath_dbg(common, ATH_DBG_CALIBRATE, + ath_dbg(ath9k_hw_common(sc->sc_ah), ATH_DBG_CALIBRATE, "Timeout waiting for paprd training on TX chain %d\n", chain); @@ -431,18 +431,11 @@ void ath_paprd_calibrate(struct work_struct *work) if (!ath_paprd_send_frame(sc, skb, chain)) goto fail_paprd; - if (!ar9003_paprd_is_done(ah)) { - ath_dbg(common, ATH_DBG_CALIBRATE, - "PAPRD not yet done on chain %d\n", chain); + if (!ar9003_paprd_is_done(ah)) break; - } - if (ar9003_paprd_create_curve(ah, caldata, chain)) { - ath_dbg(common, ATH_DBG_CALIBRATE, - "PAPRD create curve failed on chain %d\n", - chain); + if (ar9003_paprd_create_curve(ah, caldata, chain) != 0) break; - } chain_ok = 1; } @@ -617,11 +610,8 @@ void ath_hw_check(struct work_struct *work) ath_dbg(common, ATH_DBG_RESET, "Possible baseband hang, " "busy=%d (try %d)\n", busy, sc->hw_busy_count + 1); if (busy >= 99) { - if (++sc->hw_busy_count >= 3) { - spin_lock_bh(&sc->sc_pcu_lock); + if (++sc->hw_busy_count >= 3) ath_reset(sc, true); - spin_unlock_bh(&sc->sc_pcu_lock); - } } else if (busy >= 0) sc->hw_busy_count = 0; @@ -640,9 +630,7 @@ static void ath_hw_pll_rx_hang_check(struct ath_softc *sc, u32 pll_sqsum) /* Rx is hung for more than 500ms. Reset it */ ath_dbg(common, ATH_DBG_RESET, "Possible RX hang, resetting"); - spin_lock_bh(&sc->sc_pcu_lock); ath_reset(sc, true); - spin_unlock_bh(&sc->sc_pcu_lock); count = 0; } } else @@ -679,9 +667,7 @@ void ath9k_tasklet(unsigned long data) if ((status & ATH9K_INT_FATAL) || (status & ATH9K_INT_BB_WATCHDOG)) { - spin_lock(&sc->sc_pcu_lock); ath_reset(sc, true); - spin_unlock(&sc->sc_pcu_lock); return; } @@ -987,6 +973,7 @@ int ath_reset(struct ath_softc *sc, bool retry_tx) del_timer_sync(&common->ani.timer); ath9k_ps_wakeup(sc); + spin_lock_bh(&sc->sc_pcu_lock); ieee80211_stop_queues(hw); @@ -1029,6 +1016,7 @@ int ath_reset(struct ath_softc *sc, bool retry_tx) } ieee80211_wake_queues(hw); + spin_unlock_bh(&sc->sc_pcu_lock); /* Start ANI */ if (!common->disable_ani) @@ -1271,6 +1259,7 @@ static void ath9k_stop(struct ieee80211_hw *hw) /* disable HAL and put h/w to sleep */ ath9k_hw_disable(ah); + ath9k_hw_configpcipowersave(ah, 1, 1); spin_unlock_bh(&sc->sc_pcu_lock); @@ -2331,9 +2320,9 @@ static void ath9k_flush(struct ieee80211_hw *hw, bool drop) ath9k_ps_wakeup(sc); spin_lock_bh(&sc->sc_pcu_lock); drain_txq = ath_drain_all_txq(sc, false); + spin_unlock_bh(&sc->sc_pcu_lock); if (!drain_txq) ath_reset(sc, false); - spin_unlock_bh(&sc->sc_pcu_lock); ath9k_ps_restore(sc); ieee80211_wake_queues(hw); diff --git a/trunk/drivers/net/wireless/ath/ath9k/pci.c b/trunk/drivers/net/wireless/ath/ath9k/pci.c index 3bad0b2cf9a3..b8cbfc707213 100644 --- a/trunk/drivers/net/wireless/ath/ath9k/pci.c +++ b/trunk/drivers/net/wireless/ath/ath9k/pci.c @@ -278,12 +278,6 @@ static int ath_pci_suspend(struct device *device) ath9k_hw_set_gpio(sc->sc_ah, sc->sc_ah->led_pin, 1); - /* The device has to be moved to FULLSLEEP forcibly. - * Otherwise the chip never moved to full sleep, - * when no interface is up. - */ - ath9k_hw_setpower(sc->sc_ah, ATH9K_PM_FULL_SLEEP); - return 0; } diff --git a/trunk/drivers/net/wireless/ath/ath9k/rc.c b/trunk/drivers/net/wireless/ath/ath9k/rc.c index e7fe4d9aee79..ba7f36ab0a74 100644 --- a/trunk/drivers/net/wireless/ath/ath9k/rc.c +++ b/trunk/drivers/net/wireless/ath/ath9k/rc.c @@ -533,7 +533,7 @@ static u8 ath_rc_setvalid_rates(struct ath_rate_priv *ath_rc_priv, [valid_rate_count] = j; ath_rc_priv->valid_phy_ratecnt[phy] += 1; ath_rc_set_valid_rate_idx(ath_rc_priv, j, 1); - hi = max(hi, j); + hi = A_MAX(hi, j); } } } @@ -569,7 +569,7 @@ static u8 ath_rc_setvalid_htrates(struct ath_rate_priv *ath_rc_priv, [ath_rc_priv->valid_phy_ratecnt[phy]] = j; ath_rc_priv->valid_phy_ratecnt[phy] += 1; ath_rc_set_valid_rate_idx(ath_rc_priv, j, 1); - hi = max(hi, j); + hi = A_MAX(hi, j); } } @@ -1228,7 +1228,7 @@ static void ath_rc_init(struct ath_softc *sc, ht_mcs, ath_rc_priv->ht_cap); } - hi = max(hi, hthi); + hi = A_MAX(hi, hthi); } ath_rc_priv->rate_table_size = hi + 1; diff --git a/trunk/drivers/net/wireless/ath/ath9k/recv.c b/trunk/drivers/net/wireless/ath/ath9k/recv.c index 70dc8ecdad4d..c4c5d9f455bb 100644 --- a/trunk/drivers/net/wireless/ath/ath9k/recv.c +++ b/trunk/drivers/net/wireless/ath/ath9k/recv.c @@ -40,7 +40,6 @@ static inline bool ath_ant_div_comb_alt_check(u8 div_group, int alt_ratio, result = true; break; case 1: - case 2: if ((((curr_main_set == ATH_ANT_DIV_COMB_LNA2) && (curr_alt_set == ATH_ANT_DIV_COMB_LNA1) && (alt_rssi_avg >= (main_rssi_avg - 5))) || @@ -1077,39 +1076,39 @@ static void ath_lnaconf_alt_good_scan(struct ath_ant_comb *antcomb, antcomb->rssi_lna1 = main_rssi_avg; switch ((ant_conf.main_lna_conf << 4) | ant_conf.alt_lna_conf) { - case 0x10: /* LNA2 A-B */ + case (0x10): /* LNA2 A-B */ antcomb->main_conf = ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2; antcomb->first_quick_scan_conf = ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2; antcomb->second_quick_scan_conf = ATH_ANT_DIV_COMB_LNA1; break; - case 0x20: /* LNA1 A-B */ + case (0x20): /* LNA1 A-B */ antcomb->main_conf = ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2; antcomb->first_quick_scan_conf = ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2; antcomb->second_quick_scan_conf = ATH_ANT_DIV_COMB_LNA2; break; - case 0x21: /* LNA1 LNA2 */ + case (0x21): /* LNA1 LNA2 */ antcomb->main_conf = ATH_ANT_DIV_COMB_LNA2; antcomb->first_quick_scan_conf = ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2; antcomb->second_quick_scan_conf = ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2; break; - case 0x12: /* LNA2 LNA1 */ + case (0x12): /* LNA2 LNA1 */ antcomb->main_conf = ATH_ANT_DIV_COMB_LNA1; antcomb->first_quick_scan_conf = ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2; antcomb->second_quick_scan_conf = ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2; break; - case 0x13: /* LNA2 A+B */ + case (0x13): /* LNA2 A+B */ antcomb->main_conf = ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2; antcomb->first_quick_scan_conf = ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2; antcomb->second_quick_scan_conf = ATH_ANT_DIV_COMB_LNA1; break; - case 0x23: /* LNA1 A+B */ + case (0x23): /* LNA1 A+B */ antcomb->main_conf = ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2; antcomb->first_quick_scan_conf = ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2; @@ -1326,148 +1325,65 @@ static void ath_ant_div_conf_fast_divbias(struct ath_hw_antcomb_conf *ant_conf, /* Adjust the fast_div_bias based on main and alt lna conf */ switch ((ant_conf->main_lna_conf << 4) | ant_conf->alt_lna_conf) { - case 0x01: /* A-B LNA2 */ + case (0x01): /* A-B LNA2 */ ant_conf->fast_div_bias = 0x3b; break; - case 0x02: /* A-B LNA1 */ + case (0x02): /* A-B LNA1 */ ant_conf->fast_div_bias = 0x3d; break; - case 0x03: /* A-B A+B */ + case (0x03): /* A-B A+B */ ant_conf->fast_div_bias = 0x1; break; - case 0x10: /* LNA2 A-B */ + case (0x10): /* LNA2 A-B */ ant_conf->fast_div_bias = 0x7; break; - case 0x12: /* LNA2 LNA1 */ + case (0x12): /* LNA2 LNA1 */ ant_conf->fast_div_bias = 0x2; break; - case 0x13: /* LNA2 A+B */ + case (0x13): /* LNA2 A+B */ ant_conf->fast_div_bias = 0x7; break; - case 0x20: /* LNA1 A-B */ + case (0x20): /* LNA1 A-B */ ant_conf->fast_div_bias = 0x6; break; - case 0x21: /* LNA1 LNA2 */ + case (0x21): /* LNA1 LNA2 */ ant_conf->fast_div_bias = 0x0; break; - case 0x23: /* LNA1 A+B */ + case (0x23): /* LNA1 A+B */ ant_conf->fast_div_bias = 0x6; break; - case 0x30: /* A+B A-B */ + case (0x30): /* A+B A-B */ ant_conf->fast_div_bias = 0x1; break; - case 0x31: /* A+B LNA2 */ + case (0x31): /* A+B LNA2 */ ant_conf->fast_div_bias = 0x3b; break; - case 0x32: /* A+B LNA1 */ + case (0x32): /* A+B LNA1 */ ant_conf->fast_div_bias = 0x3d; break; default: break; } - } else if (ant_conf->div_group == 1) { - /* Adjust the fast_div_bias based on main and alt_lna_conf */ - switch ((ant_conf->main_lna_conf << 4) | - ant_conf->alt_lna_conf) { - case 0x01: /* A-B LNA2 */ - ant_conf->fast_div_bias = 0x1; - ant_conf->main_gaintb = 0; - ant_conf->alt_gaintb = 0; - break; - case 0x02: /* A-B LNA1 */ - ant_conf->fast_div_bias = 0x1; - ant_conf->main_gaintb = 0; - ant_conf->alt_gaintb = 0; - break; - case 0x03: /* A-B A+B */ - ant_conf->fast_div_bias = 0x1; - ant_conf->main_gaintb = 0; - ant_conf->alt_gaintb = 0; - break; - case 0x10: /* LNA2 A-B */ - if (!(antcomb->scan) && - (alt_ratio > ATH_ANT_DIV_COMB_ALT_ANT_RATIO)) - ant_conf->fast_div_bias = 0x3f; - else - ant_conf->fast_div_bias = 0x1; - ant_conf->main_gaintb = 0; - ant_conf->alt_gaintb = 0; - break; - case 0x12: /* LNA2 LNA1 */ - ant_conf->fast_div_bias = 0x1; - ant_conf->main_gaintb = 0; - ant_conf->alt_gaintb = 0; - break; - case 0x13: /* LNA2 A+B */ - if (!(antcomb->scan) && - (alt_ratio > ATH_ANT_DIV_COMB_ALT_ANT_RATIO)) - ant_conf->fast_div_bias = 0x3f; - else - ant_conf->fast_div_bias = 0x1; - ant_conf->main_gaintb = 0; - ant_conf->alt_gaintb = 0; - break; - case 0x20: /* LNA1 A-B */ - if (!(antcomb->scan) && - (alt_ratio > ATH_ANT_DIV_COMB_ALT_ANT_RATIO)) - ant_conf->fast_div_bias = 0x3f; - else - ant_conf->fast_div_bias = 0x1; - ant_conf->main_gaintb = 0; - ant_conf->alt_gaintb = 0; - break; - case 0x21: /* LNA1 LNA2 */ - ant_conf->fast_div_bias = 0x1; - ant_conf->main_gaintb = 0; - ant_conf->alt_gaintb = 0; - break; - case 0x23: /* LNA1 A+B */ - if (!(antcomb->scan) && - (alt_ratio > ATH_ANT_DIV_COMB_ALT_ANT_RATIO)) - ant_conf->fast_div_bias = 0x3f; - else - ant_conf->fast_div_bias = 0x1; - ant_conf->main_gaintb = 0; - ant_conf->alt_gaintb = 0; - break; - case 0x30: /* A+B A-B */ - ant_conf->fast_div_bias = 0x1; - ant_conf->main_gaintb = 0; - ant_conf->alt_gaintb = 0; - break; - case 0x31: /* A+B LNA2 */ - ant_conf->fast_div_bias = 0x1; - ant_conf->main_gaintb = 0; - ant_conf->alt_gaintb = 0; - break; - case 0x32: /* A+B LNA1 */ - ant_conf->fast_div_bias = 0x1; - ant_conf->main_gaintb = 0; - ant_conf->alt_gaintb = 0; - break; - default: - break; - } } else if (ant_conf->div_group == 2) { /* Adjust the fast_div_bias based on main and alt_lna_conf */ switch ((ant_conf->main_lna_conf << 4) | ant_conf->alt_lna_conf) { - case 0x01: /* A-B LNA2 */ + case (0x01): /* A-B LNA2 */ ant_conf->fast_div_bias = 0x1; ant_conf->main_gaintb = 0; ant_conf->alt_gaintb = 0; break; - case 0x02: /* A-B LNA1 */ + case (0x02): /* A-B LNA1 */ ant_conf->fast_div_bias = 0x1; ant_conf->main_gaintb = 0; ant_conf->alt_gaintb = 0; break; - case 0x03: /* A-B A+B */ + case (0x03): /* A-B A+B */ ant_conf->fast_div_bias = 0x1; ant_conf->main_gaintb = 0; ant_conf->alt_gaintb = 0; break; - case 0x10: /* LNA2 A-B */ + case (0x10): /* LNA2 A-B */ if (!(antcomb->scan) && (alt_ratio > ATH_ANT_DIV_COMB_ALT_ANT_RATIO)) ant_conf->fast_div_bias = 0x1; @@ -1476,12 +1392,12 @@ static void ath_ant_div_conf_fast_divbias(struct ath_hw_antcomb_conf *ant_conf, ant_conf->main_gaintb = 0; ant_conf->alt_gaintb = 0; break; - case 0x12: /* LNA2 LNA1 */ + case (0x12): /* LNA2 LNA1 */ ant_conf->fast_div_bias = 0x1; ant_conf->main_gaintb = 0; ant_conf->alt_gaintb = 0; break; - case 0x13: /* LNA2 A+B */ + case (0x13): /* LNA2 A+B */ if (!(antcomb->scan) && (alt_ratio > ATH_ANT_DIV_COMB_ALT_ANT_RATIO)) ant_conf->fast_div_bias = 0x1; @@ -1490,7 +1406,7 @@ static void ath_ant_div_conf_fast_divbias(struct ath_hw_antcomb_conf *ant_conf, ant_conf->main_gaintb = 0; ant_conf->alt_gaintb = 0; break; - case 0x20: /* LNA1 A-B */ + case (0x20): /* LNA1 A-B */ if (!(antcomb->scan) && (alt_ratio > ATH_ANT_DIV_COMB_ALT_ANT_RATIO)) ant_conf->fast_div_bias = 0x1; @@ -1499,12 +1415,12 @@ static void ath_ant_div_conf_fast_divbias(struct ath_hw_antcomb_conf *ant_conf, ant_conf->main_gaintb = 0; ant_conf->alt_gaintb = 0; break; - case 0x21: /* LNA1 LNA2 */ + case (0x21): /* LNA1 LNA2 */ ant_conf->fast_div_bias = 0x1; ant_conf->main_gaintb = 0; ant_conf->alt_gaintb = 0; break; - case 0x23: /* LNA1 A+B */ + case (0x23): /* LNA1 A+B */ if (!(antcomb->scan) && (alt_ratio > ATH_ANT_DIV_COMB_ALT_ANT_RATIO)) ant_conf->fast_div_bias = 0x1; @@ -1513,17 +1429,17 @@ static void ath_ant_div_conf_fast_divbias(struct ath_hw_antcomb_conf *ant_conf, ant_conf->main_gaintb = 0; ant_conf->alt_gaintb = 0; break; - case 0x30: /* A+B A-B */ + case (0x30): /* A+B A-B */ ant_conf->fast_div_bias = 0x1; ant_conf->main_gaintb = 0; ant_conf->alt_gaintb = 0; break; - case 0x31: /* A+B LNA2 */ + case (0x31): /* A+B LNA2 */ ant_conf->fast_div_bias = 0x1; ant_conf->main_gaintb = 0; ant_conf->alt_gaintb = 0; break; - case 0x32: /* A+B LNA1 */ + case (0x32): /* A+B LNA1 */ ant_conf->fast_div_bias = 0x1; ant_conf->main_gaintb = 0; ant_conf->alt_gaintb = 0; @@ -1531,7 +1447,9 @@ static void ath_ant_div_conf_fast_divbias(struct ath_hw_antcomb_conf *ant_conf, default: break; } + } + } /* Antenna diversity and combining */ diff --git a/trunk/drivers/net/wireless/ath/ath9k/reg.h b/trunk/drivers/net/wireless/ath/ath9k/reg.h index a4833880accd..c18ee9921fb1 100644 --- a/trunk/drivers/net/wireless/ath/ath9k/reg.h +++ b/trunk/drivers/net/wireless/ath/ath9k/reg.h @@ -788,10 +788,6 @@ #define AR_SREV_REVISION_9271_11 1 #define AR_SREV_VERSION_9300 0x1c0 #define AR_SREV_REVISION_9300_20 2 /* 2.0 and 2.1 */ -#define AR_SREV_VERSION_9330 0x200 -#define AR_SREV_REVISION_9330_10 0 -#define AR_SREV_REVISION_9330_11 1 -#define AR_SREV_REVISION_9330_12 2 #define AR_SREV_VERSION_9485 0x240 #define AR_SREV_REVISION_9485_10 0 #define AR_SREV_REVISION_9485_11 1 @@ -866,18 +862,6 @@ #define AR_SREV_9300_20_OR_LATER(_ah) \ ((_ah)->hw_version.macVersion >= AR_SREV_VERSION_9300) -#define AR_SREV_9330(_ah) \ - (((_ah)->hw_version.macVersion == AR_SREV_VERSION_9330)) -#define AR_SREV_9330_10(_ah) \ - (AR_SREV_9330((_ah)) && \ - ((_ah)->hw_version.macRev == AR_SREV_REVISION_9330_10)) -#define AR_SREV_9330_11(_ah) \ - (AR_SREV_9330((_ah)) && \ - ((_ah)->hw_version.macRev == AR_SREV_REVISION_9330_11)) -#define AR_SREV_9330_12(_ah) \ - (AR_SREV_9330((_ah)) && \ - ((_ah)->hw_version.macRev == AR_SREV_REVISION_9330_12)) - #define AR_SREV_9485(_ah) \ (((_ah)->hw_version.macVersion == AR_SREV_VERSION_9485)) #define AR_SREV_9485_10(_ah) \ diff --git a/trunk/drivers/net/wireless/ath/ath9k/xmit.c b/trunk/drivers/net/wireless/ath/ath9k/xmit.c index 6eb58b16ab06..7e79bbaf2ba7 100644 --- a/trunk/drivers/net/wireless/ath/ath9k/xmit.c +++ b/trunk/drivers/net/wireless/ath/ath9k/xmit.c @@ -566,8 +566,11 @@ static void ath_tx_complete_aggr(struct ath_softc *sc, struct ath_txq *txq, rcu_read_unlock(); - if (needreset) + if (needreset) { + spin_unlock_bh(&sc->sc_pcu_lock); ath_reset(sc, false); + spin_lock_bh(&sc->sc_pcu_lock); + } } static u32 ath_lookup_rate(struct ath_softc *sc, struct ath_buf *bf, @@ -662,8 +665,7 @@ static int ath_compute_num_delims(struct ath_softc *sc, struct ath_atx_tid *tid, * TODO - this could be improved to be dependent on the rate. * The hardware can keep up at lower rates, but not higher rates */ - if ((fi->keyix != ATH9K_TXKEYIX_INVALID) && - !(sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA)) + if (fi->keyix != ATH9K_TXKEYIX_INVALID) ndelim += ATH_AGGR_ENCRYPTDELIM; /* @@ -2168,9 +2170,7 @@ static void ath_tx_complete_poll_work(struct work_struct *work) if (needreset) { ath_dbg(ath9k_hw_common(sc->sc_ah), ATH_DBG_RESET, "tx hung, resetting the chip\n"); - spin_lock_bh(&sc->sc_pcu_lock); ath_reset(sc, true); - spin_unlock_bh(&sc->sc_pcu_lock); } ieee80211_queue_delayed_work(sc->hw, &sc->tx_complete_work, diff --git a/trunk/drivers/net/wireless/ath/carl9170/carl9170.h b/trunk/drivers/net/wireless/ath/carl9170/carl9170.h index f9a4655ea0b8..4da01a9f5680 100644 --- a/trunk/drivers/net/wireless/ath/carl9170/carl9170.h +++ b/trunk/drivers/net/wireless/ath/carl9170/carl9170.h @@ -67,8 +67,6 @@ #define PAYLOAD_MAX (CARL9170_MAX_CMD_LEN / 4 - 1) -static const u8 ar9170_qmap[__AR9170_NUM_TXQ] = { 3, 2, 1, 0 }; - enum carl9170_rf_init_mode { CARL9170_RFI_NONE, CARL9170_RFI_WARM, @@ -442,6 +440,7 @@ struct ar9170 { enum carl9170_ps_off_override_reasons { PS_OFF_VIF = BIT(0), PS_OFF_BCN = BIT(1), + PS_OFF_5GHZ = BIT(2), }; struct carl9170_ba_stats { diff --git a/trunk/drivers/net/wireless/ath/carl9170/fw.c b/trunk/drivers/net/wireless/ath/carl9170/fw.c index 39ddea5794f7..221957c5d373 100644 --- a/trunk/drivers/net/wireless/ath/carl9170/fw.c +++ b/trunk/drivers/net/wireless/ath/carl9170/fw.c @@ -237,7 +237,7 @@ static int carl9170_fw(struct ar9170 *ar, const __u8 *data, size_t len) ar->disable_offload = true; } - if (SUPP(CARL9170FW_PSM) && SUPP(CARL9170FW_FIXED_5GHZ_PSM)) + if (SUPP(CARL9170FW_PSM)) ar->hw->flags |= IEEE80211_HW_SUPPORTS_PS; if (!SUPP(CARL9170FW_USB_INIT_FIRMWARE)) { diff --git a/trunk/drivers/net/wireless/ath/carl9170/fwcmd.h b/trunk/drivers/net/wireless/ath/carl9170/fwcmd.h index 0a6dec529b59..30449d21b762 100644 --- a/trunk/drivers/net/wireless/ath/carl9170/fwcmd.h +++ b/trunk/drivers/net/wireless/ath/carl9170/fwcmd.h @@ -4,7 +4,7 @@ * Firmware command interface definitions * * Copyright 2008, Johannes Berg - * Copyright 2009-2011 Christian Lamparter + * Copyright 2009, 2010, Christian Lamparter * * 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 @@ -54,7 +54,6 @@ enum carl9170_cmd_oids { CARL9170_CMD_BCN_CTRL = 0x05, CARL9170_CMD_READ_TSF = 0x06, CARL9170_CMD_RX_FILTER = 0x07, - CARL9170_CMD_WOL = 0x08, /* CAM */ CARL9170_CMD_EKEY = 0x10, @@ -181,21 +180,6 @@ struct carl9170_bcn_ctrl_cmd { #define CARL9170_BCN_CTRL_DRAIN 0 #define CARL9170_BCN_CTRL_CAB_TRIGGER 1 -struct carl9170_wol_cmd { - __le32 flags; - u8 mac[6]; - u8 bssid[6]; - __le32 null_interval; - __le32 free_for_use2; - __le32 mask; - u8 pattern[32]; -} __packed; - -#define CARL9170_WOL_CMD_SIZE 60 - -#define CARL9170_WOL_DISCONNECT 1 -#define CARL9170_WOL_MAGIC_PKT 2 - struct carl9170_cmd_head { union { struct { @@ -219,7 +203,6 @@ struct carl9170_cmd { struct carl9170_write_reg wreg; struct carl9170_rf_init rf_init; struct carl9170_psm psm; - struct carl9170_wol_cmd wol; struct carl9170_bcn_ctrl_cmd bcn_ctrl; struct carl9170_rx_filter_cmd rx_filter; u8 data[CARL9170_MAX_CMD_PAYLOAD_LEN]; diff --git a/trunk/drivers/net/wireless/ath/carl9170/fwdesc.h b/trunk/drivers/net/wireless/ath/carl9170/fwdesc.h index 7ba62bb77054..921066822dd5 100644 --- a/trunk/drivers/net/wireless/ath/carl9170/fwdesc.h +++ b/trunk/drivers/net/wireless/ath/carl9170/fwdesc.h @@ -3,7 +3,7 @@ * * Firmware descriptor format * - * Copyright 2009-2011 Christian Lamparter + * Copyright 2009, 2010, Christian Lamparter * * 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 @@ -72,9 +72,6 @@ enum carl9170fw_feature_list { /* Wake up on WLAN */ CARL9170FW_WOL, - /* Firmware supports PSM in the 5GHZ Band */ - CARL9170FW_FIXED_5GHZ_PSM, - /* KEEP LAST */ __CARL9170FW_FEATURE_NUM }; @@ -85,7 +82,6 @@ enum carl9170fw_feature_list { #define DBG_MAGIC "DBG\0" #define CHK_MAGIC "CHK\0" #define TXSQ_MAGIC "TXSQ" -#define WOL_MAGIC "WOL\0" #define LAST_MAGIC "LAST" #define CARL9170FW_SET_DAY(d) (((d) - 1) % 31) @@ -108,7 +104,7 @@ struct carl9170fw_desc_head { (sizeof(struct carl9170fw_desc_head)) #define CARL9170FW_OTUS_DESC_MIN_VER 6 -#define CARL9170FW_OTUS_DESC_CUR_VER 7 +#define CARL9170FW_OTUS_DESC_CUR_VER 6 struct carl9170fw_otus_desc { struct carl9170fw_desc_head head; __le32 feature_set; @@ -190,16 +186,6 @@ struct carl9170fw_txsq_desc { #define CARL9170FW_TXSQ_DESC_SIZE \ (sizeof(struct carl9170fw_txsq_desc)) -#define CARL9170FW_WOL_DESC_MIN_VER 1 -#define CARL9170FW_WOL_DESC_CUR_VER 1 -struct carl9170fw_wol_desc { - struct carl9170fw_desc_head head; - - __le32 supported_triggers; /* CARL9170_WOL_ */ -} __packed; -#define CARL9170FW_WOL_DESC_SIZE \ - (sizeof(struct carl9170fw_wol_desc)) - #define CARL9170FW_LAST_DESC_MIN_VER 1 #define CARL9170FW_LAST_DESC_CUR_VER 2 struct carl9170fw_last_desc { diff --git a/trunk/drivers/net/wireless/ath/carl9170/hw.h b/trunk/drivers/net/wireless/ath/carl9170/hw.h index 261f89351070..4e30762dd903 100644 --- a/trunk/drivers/net/wireless/ath/carl9170/hw.h +++ b/trunk/drivers/net/wireless/ath/carl9170/hw.h @@ -4,7 +4,7 @@ * Register map, hardware-specific definitions * * Copyright 2008, Johannes Berg - * Copyright 2009-2011 Christian Lamparter + * Copyright 2009, 2010, Christian Lamparter * * 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 @@ -357,18 +357,7 @@ #define AR9170_MAC_REG_DMA_WLAN_STATUS (AR9170_MAC_REG_BASE + 0xd38) #define AR9170_MAC_REG_DMA_STATUS (AR9170_MAC_REG_BASE + 0xd3c) -#define AR9170_MAC_REG_DMA_TXQ_LAST_ADDR (AR9170_MAC_REG_BASE + 0xd40) -#define AR9170_MAC_REG_DMA_TXQ0_LAST_ADDR (AR9170_MAC_REG_BASE + 0xd40) -#define AR9170_MAC_REG_DMA_TXQ1_LAST_ADDR (AR9170_MAC_REG_BASE + 0xd44) -#define AR9170_MAC_REG_DMA_TXQ2_LAST_ADDR (AR9170_MAC_REG_BASE + 0xd48) -#define AR9170_MAC_REG_DMA_TXQ3_LAST_ADDR (AR9170_MAC_REG_BASE + 0xd4c) -#define AR9170_MAC_REG_DMA_TXQ4_LAST_ADDR (AR9170_MAC_REG_BASE + 0xd50) -#define AR9170_MAC_REG_DMA_TXQ0Q1_LEN (AR9170_MAC_REG_BASE + 0xd54) -#define AR9170_MAC_REG_DMA_TXQ2Q3_LEN (AR9170_MAC_REG_BASE + 0xd58) -#define AR9170_MAC_REG_DMA_TXQ4_LEN (AR9170_MAC_REG_BASE + 0xd5c) - -#define AR9170_MAC_REG_DMA_TXQX_LAST_ADDR (AR9170_MAC_REG_BASE + 0xd74) -#define AR9170_MAC_REG_DMA_TXQX_FAIL_ADDR (AR9170_MAC_REG_BASE + 0xd78) + #define AR9170_MAC_REG_TXRX_MPI (AR9170_MAC_REG_BASE + 0xd7c) #define AR9170_MAC_TXRX_MPI_TX_MPI_MASK 0x0000000f #define AR9170_MAC_TXRX_MPI_TX_TO_MASK 0x0000fff0 diff --git a/trunk/drivers/net/wireless/ath/carl9170/main.c b/trunk/drivers/net/wireless/ath/carl9170/main.c index d2b9f1256bc8..54d093c2ab44 100644 --- a/trunk/drivers/net/wireless/ath/carl9170/main.c +++ b/trunk/drivers/net/wireless/ath/carl9170/main.c @@ -345,11 +345,11 @@ static int carl9170_op_start(struct ieee80211_hw *hw) carl9170_zap_queues(ar); /* reset QoS defaults */ - CARL9170_FILL_QUEUE(ar->edcf[AR9170_TXQ_VO], 2, 3, 7, 47); - CARL9170_FILL_QUEUE(ar->edcf[AR9170_TXQ_VI], 2, 7, 15, 94); - CARL9170_FILL_QUEUE(ar->edcf[AR9170_TXQ_BE], 3, 15, 1023, 0); - CARL9170_FILL_QUEUE(ar->edcf[AR9170_TXQ_BK], 7, 15, 1023, 0); - CARL9170_FILL_QUEUE(ar->edcf[AR9170_TXQ_SPECIAL], 2, 3, 7, 0); + CARL9170_FILL_QUEUE(ar->edcf[0], 3, 15, 1023, 0); /* BEST EFFORT */ + CARL9170_FILL_QUEUE(ar->edcf[1], 2, 7, 15, 94); /* VIDEO */ + CARL9170_FILL_QUEUE(ar->edcf[2], 2, 3, 7, 47); /* VOICE */ + CARL9170_FILL_QUEUE(ar->edcf[3], 7, 15, 1023, 0); /* BACKGROUND */ + CARL9170_FILL_QUEUE(ar->edcf[4], 2, 3, 7, 0); /* SPECIAL */ ar->current_factor = ar->current_density = -1; /* "The first key is unique." */ @@ -1577,7 +1577,6 @@ void *carl9170_alloc(size_t priv_size) IEEE80211_HW_REPORTS_TX_ACK_STATUS | IEEE80211_HW_SUPPORTS_PS | IEEE80211_HW_PS_NULLFUNC_STACK | - IEEE80211_HW_NEED_DTIM_PERIOD | IEEE80211_HW_SIGNAL_DBM; if (!modparam_noht) { diff --git a/trunk/drivers/net/wireless/ath/carl9170/phy.c b/trunk/drivers/net/wireless/ath/carl9170/phy.c index da1ab962ee48..b6ae0e179c8d 100644 --- a/trunk/drivers/net/wireless/ath/carl9170/phy.c +++ b/trunk/drivers/net/wireless/ath/carl9170/phy.c @@ -1783,6 +1783,12 @@ int carl9170_set_channel(struct ar9170 *ar, struct ieee80211_channel *channel, } } + /* FIXME: PSM does not work in 5GHz Band */ + if (channel->band == IEEE80211_BAND_5GHZ) + ar->ps.off_override |= PS_OFF_5GHZ; + else + ar->ps.off_override &= ~PS_OFF_5GHZ; + ar->channel = channel; ar->ht_settings = new_ht; return 0; diff --git a/trunk/drivers/net/wireless/ath/carl9170/rx.c b/trunk/drivers/net/wireless/ath/carl9170/rx.c index dc99030ea8b6..ec21ea9fd8d5 100644 --- a/trunk/drivers/net/wireless/ath/carl9170/rx.c +++ b/trunk/drivers/net/wireless/ath/carl9170/rx.c @@ -472,7 +472,7 @@ static struct sk_buff *carl9170_rx_copy_data(u8 *buf, int len) u8 *qc = ieee80211_get_qos_ctl(hdr); reserved += NET_IP_ALIGN; - if (*qc & IEEE80211_QOS_CTL_A_MSDU_PRESENT) + if (*qc & IEEE80211_QOS_CONTROL_A_MSDU_PRESENT) reserved += NET_IP_ALIGN; } diff --git a/trunk/drivers/net/wireless/ath/carl9170/usb.c b/trunk/drivers/net/wireless/ath/carl9170/usb.c index 333b69ef2ae2..2fb53d067512 100644 --- a/trunk/drivers/net/wireless/ath/carl9170/usb.c +++ b/trunk/drivers/net/wireless/ath/carl9170/usb.c @@ -112,8 +112,6 @@ static struct usb_device_id carl9170_usb_ids[] = { { USB_DEVICE(0x04bb, 0x093f) }, /* NEC WL300NU-G */ { USB_DEVICE(0x0409, 0x0249) }, - /* NEC WL300NU-AG */ - { USB_DEVICE(0x0409, 0x02b4) }, /* AVM FRITZ!WLAN USB Stick N */ { USB_DEVICE(0x057c, 0x8401) }, /* AVM FRITZ!WLAN USB Stick N 2.4 */ diff --git a/trunk/drivers/net/wireless/ath/carl9170/version.h b/trunk/drivers/net/wireless/ath/carl9170/version.h index 64703778cfea..15095c035169 100644 --- a/trunk/drivers/net/wireless/ath/carl9170/version.h +++ b/trunk/drivers/net/wireless/ath/carl9170/version.h @@ -1,7 +1,7 @@ #ifndef __CARL9170_SHARED_VERSION_H #define __CARL9170_SHARED_VERSION_H #define CARL9170FW_VERSION_YEAR 11 -#define CARL9170FW_VERSION_MONTH 6 -#define CARL9170FW_VERSION_DAY 30 -#define CARL9170FW_VERSION_GIT "1.9.4" +#define CARL9170FW_VERSION_MONTH 1 +#define CARL9170FW_VERSION_DAY 22 +#define CARL9170FW_VERSION_GIT "1.9.2" #endif /* __CARL9170_SHARED_VERSION_H */ diff --git a/trunk/drivers/net/wireless/ath/carl9170/wlan.h b/trunk/drivers/net/wireless/ath/carl9170/wlan.h index ea17995b32f4..9e1324b67e08 100644 --- a/trunk/drivers/net/wireless/ath/carl9170/wlan.h +++ b/trunk/drivers/net/wireless/ath/carl9170/wlan.h @@ -4,7 +4,7 @@ * RX/TX meta descriptor format * * Copyright 2008, Johannes Berg - * Copyright 2009-2011 Christian Lamparter + * Copyright 2009, 2010, Christian Lamparter * * 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 @@ -278,7 +278,7 @@ struct ar9170_tx_frame { struct carl9170_tx_superframe { struct carl9170_tx_superdesc s; struct ar9170_tx_frame f; -} __packed __aligned(4); +} __packed; #endif /* __CARL9170FW__ */ @@ -328,7 +328,7 @@ struct _carl9170_tx_superframe { struct _carl9170_tx_superdesc s; struct _ar9170_tx_hwdesc f; u8 frame_data[0]; -} __packed __aligned(4); +} __packed; #define CARL9170_TX_SUPERDESC_LEN 24 #define AR9170_TX_HWDESC_LEN 8 @@ -404,6 +404,16 @@ static inline u8 ar9170_get_decrypt_type(struct ar9170_rx_macstatus *t) (t->DAidx & 0xc0) >> 6; } +enum ar9170_txq { + AR9170_TXQ_BE, + + AR9170_TXQ_VI, + AR9170_TXQ_VO, + AR9170_TXQ_BK, + + __AR9170_NUM_TXQ, +}; + /* * This is an workaround for several undocumented bugs. * Don't mess with the QoS/AC <-> HW Queue map, if you don't @@ -421,14 +431,7 @@ static inline u8 ar9170_get_decrypt_type(struct ar9170_rx_macstatus *t) * result, this makes the device pretty much useless * for any serious 802.11n setup. */ -enum ar9170_txq { - AR9170_TXQ_BK = 0, /* TXQ0 */ - AR9170_TXQ_BE, /* TXQ1 */ - AR9170_TXQ_VI, /* TXQ2 */ - AR9170_TXQ_VO, /* TXQ3 */ - - __AR9170_NUM_TXQ, -}; +static const u8 ar9170_qmap[__AR9170_NUM_TXQ] = { 2, 1, 0, 3 }; #define AR9170_TXQ_DEPTH 32 diff --git a/trunk/drivers/net/wireless/b43/Kconfig b/trunk/drivers/net/wireless/b43/Kconfig index d5add69aac8f..fe26bf448fdb 100644 --- a/trunk/drivers/net/wireless/b43/Kconfig +++ b/trunk/drivers/net/wireless/b43/Kconfig @@ -31,11 +31,6 @@ config B43_BCMA depends on B43 && BCMA && BROKEN default y -config B43_SSB - bool - depends on B43 && SSB - default y - # Auto-select SSB PCI-HOST support, if possible config B43_PCI_AUTOSELECT bool @@ -117,14 +112,6 @@ config B43_PHY_LP and embedded devices. It supports 802.11a/g (802.11a support is optional, and currently disabled). -config B43_PHY_HT - bool "Support for HT-PHY devices (BROKEN)" - depends on B43 && BROKEN - ---help--- - Support for the HT-PHY. - - Say N, this is BROKEN and crashes driver. - # This config option automatically enables b43 LEDS support, # if it's possible. config B43_LEDS diff --git a/trunk/drivers/net/wireless/b43/Makefile b/trunk/drivers/net/wireless/b43/Makefile index 1b25604be547..95f7c001fda1 100644 --- a/trunk/drivers/net/wireless/b43/Makefile +++ b/trunk/drivers/net/wireless/b43/Makefile @@ -10,9 +10,6 @@ b43-y += phy_a.o b43-$(CONFIG_B43_PHY_N) += phy_n.o b43-$(CONFIG_B43_PHY_LP) += phy_lp.o b43-$(CONFIG_B43_PHY_LP) += tables_lpphy.o -b43-$(CONFIG_B43_PHY_HT) += phy_ht.o -b43-$(CONFIG_B43_PHY_HT) += tables_phy_ht.o -b43-$(CONFIG_B43_PHY_HT) += radio_2059.o b43-y += sysfs.o b43-y += xmit.o b43-y += lo.o diff --git a/trunk/drivers/net/wireless/b43/b43.h b/trunk/drivers/net/wireless/b43/b43.h index 666515e348b5..1cb2ddee9dcf 100644 --- a/trunk/drivers/net/wireless/b43/b43.h +++ b/trunk/drivers/net/wireless/b43/b43.h @@ -92,8 +92,6 @@ #define B43_MMIO_PIO11_BASE4 0x300 #define B43_MMIO_PIO11_BASE5 0x340 -#define B43_MMIO_RADIO24_CONTROL 0x3D8 /* core rev >= 24 only */ -#define B43_MMIO_RADIO24_DATA 0x3DA /* core rev >= 24 only */ #define B43_MMIO_PHY_VER 0x3E0 #define B43_MMIO_PHY_RADIO 0x3E2 #define B43_MMIO_PHY0 0x3E6 @@ -365,10 +363,6 @@ enum { #define B43_PHYTYPE_G 0x02 #define B43_PHYTYPE_N 0x04 #define B43_PHYTYPE_LP 0x05 -#define B43_PHYTYPE_SSLPN 0x06 -#define B43_PHYTYPE_HT 0x07 -#define B43_PHYTYPE_LCN 0x08 -#define B43_PHYTYPE_LCNXN 0x09 /* PHYRegisters */ #define B43_PHY_ILT_A_CTRL 0x0072 diff --git a/trunk/drivers/net/wireless/b43/bus.c b/trunk/drivers/net/wireless/b43/bus.c index 4200713eb597..6c63aecd6ab4 100644 --- a/trunk/drivers/net/wireless/b43/bus.c +++ b/trunk/drivers/net/wireless/b43/bus.c @@ -25,7 +25,7 @@ /* SSB */ -#ifdef CONFIG_B43_SSB + static inline int b43_bus_ssb_bus_may_powerdown(struct b43_bus_dev *dev) { return ssb_bus_may_powerdown(dev->sdev->bus); @@ -83,11 +83,7 @@ void b43_bus_ssb_block_write(struct b43_bus_dev *dev, const void *buffer, struct b43_bus_dev *b43_bus_dev_ssb_init(struct ssb_device *sdev) { - struct b43_bus_dev *dev; - - dev = kzalloc(sizeof(*dev), GFP_KERNEL); - if (!dev) - return NULL; + struct b43_bus_dev *dev = kzalloc(sizeof(*dev), GFP_KERNEL); dev->bus_type = B43_BUS_SSB; dev->sdev = sdev; @@ -124,4 +120,3 @@ struct b43_bus_dev *b43_bus_dev_ssb_init(struct ssb_device *sdev) return dev; } -#endif /* CONFIG_B43_SSB */ diff --git a/trunk/drivers/net/wireless/b43/dma.c b/trunk/drivers/net/wireless/b43/dma.c index 7a09a467339c..d02cf8300e3e 100644 --- a/trunk/drivers/net/wireless/b43/dma.c +++ b/trunk/drivers/net/wireless/b43/dma.c @@ -1600,7 +1600,6 @@ void b43_dma_rx(struct b43_dmaring *ring) dma_rx(ring, &slot); update_max_used_slots(ring, ++used_slots); } - wmb(); ops->set_current_rxslot(ring, slot); ring->current_slot = slot; } diff --git a/trunk/drivers/net/wireless/b43/main.c b/trunk/drivers/net/wireless/b43/main.c index e9a01e3eede7..cae31463ead9 100644 --- a/trunk/drivers/net/wireless/b43/main.c +++ b/trunk/drivers/net/wireless/b43/main.c @@ -123,7 +123,6 @@ static const struct bcma_device_id b43_bcma_tbl[] = { MODULE_DEVICE_TABLE(bcma, b43_bcma_tbl); #endif -#ifdef CONFIG_B43_SSB static const struct ssb_device_id b43_ssb_tbl[] = { SSB_DEVICE(SSB_VENDOR_BROADCOM, SSB_DEV_80211, 5), SSB_DEVICE(SSB_VENDOR_BROADCOM, SSB_DEV_80211, 6), @@ -137,8 +136,8 @@ static const struct ssb_device_id b43_ssb_tbl[] = { SSB_DEVICE(SSB_VENDOR_BROADCOM, SSB_DEV_80211, 16), SSB_DEVTABLE_END }; + MODULE_DEVICE_TABLE(ssb, b43_ssb_tbl); -#endif /* Channel and ratetables are shared for all devices. * They can't be const, because ieee80211 puts some precalculated @@ -4097,12 +4096,6 @@ static int b43_phy_versioning(struct b43_wldev *dev) if (phy_rev > 2) unsupported = 1; break; -#endif -#ifdef CONFIG_B43_PHY_HT - case B43_PHYTYPE_HT: - if (phy_rev > 1) - unsupported = 1; - break; #endif default: unsupported = 1; @@ -4160,10 +4153,6 @@ static int b43_phy_versioning(struct b43_wldev *dev) if (radio_ver != 0x2062 && radio_ver != 0x2063) unsupported = 1; break; - case B43_PHYTYPE_HT: - if (radio_ver != 0x2059) - unsupported = 1; - break; default: B43_WARN_ON(1); } @@ -5027,7 +5016,6 @@ static struct bcma_driver b43_bcma_driver = { }; #endif -#ifdef CONFIG_B43_SSB static int b43_ssb_probe(struct ssb_device *sdev, const struct ssb_device_id *id) { @@ -5037,8 +5025,6 @@ int b43_ssb_probe(struct ssb_device *sdev, const struct ssb_device_id *id) int first = 0; dev = b43_bus_dev_ssb_init(sdev); - if (!dev) - return -ENOMEM; wl = ssb_get_devtypedata(sdev); if (!wl) { @@ -5105,14 +5091,6 @@ static void b43_ssb_remove(struct ssb_device *sdev) } } -static struct ssb_driver b43_ssb_driver = { - .name = KBUILD_MODNAME, - .id_table = b43_ssb_tbl, - .probe = b43_ssb_probe, - .remove = b43_ssb_remove, -}; -#endif /* CONFIG_B43_SSB */ - /* Perform a hardware reset. This can be called from any context. */ void b43_controller_restart(struct b43_wldev *dev, const char *reason) { @@ -5123,6 +5101,13 @@ void b43_controller_restart(struct b43_wldev *dev, const char *reason) ieee80211_queue_work(dev->wl->hw, &dev->restart_work); } +static struct ssb_driver b43_ssb_driver = { + .name = KBUILD_MODNAME, + .id_table = b43_ssb_tbl, + .probe = b43_ssb_probe, + .remove = b43_ssb_remove, +}; + static void b43_print_driverinfo(void) { const char *feat_pci = "", *feat_pcmcia = "", *feat_nphy = "", @@ -5166,18 +5151,14 @@ static int __init b43_init(void) if (err) goto err_sdio_exit; #endif -#ifdef CONFIG_B43_SSB err = ssb_driver_register(&b43_ssb_driver); if (err) goto err_bcma_driver_exit; -#endif b43_print_driverinfo(); return err; -#ifdef CONFIG_B43_SSB err_bcma_driver_exit: -#endif #ifdef CONFIG_B43_BCMA bcma_driver_unregister(&b43_bcma_driver); err_sdio_exit: @@ -5192,9 +5173,7 @@ static int __init b43_init(void) static void __exit b43_exit(void) { -#ifdef CONFIG_B43_SSB ssb_driver_unregister(&b43_ssb_driver); -#endif #ifdef CONFIG_B43_BCMA bcma_driver_unregister(&b43_bcma_driver); #endif diff --git a/trunk/drivers/net/wireless/b43/phy_common.c b/trunk/drivers/net/wireless/b43/phy_common.c index 9705950f059a..425af28ea4e5 100644 --- a/trunk/drivers/net/wireless/b43/phy_common.c +++ b/trunk/drivers/net/wireless/b43/phy_common.c @@ -31,7 +31,6 @@ #include "phy_a.h" #include "phy_n.h" #include "phy_lp.h" -#include "phy_ht.h" #include "b43.h" #include "main.h" @@ -58,11 +57,6 @@ int b43_phy_allocate(struct b43_wldev *dev) case B43_PHYTYPE_LP: #ifdef CONFIG_B43_PHY_LP phy->ops = &b43_phyops_lp; -#endif - break; - case B43_PHYTYPE_HT: -#ifdef CONFIG_B43_PHY_HT - phy->ops = &b43_phyops_ht; #endif break; } diff --git a/trunk/drivers/net/wireless/b43/phy_common.h b/trunk/drivers/net/wireless/b43/phy_common.h index 47dcb800a3c3..2401bee8b081 100644 --- a/trunk/drivers/net/wireless/b43/phy_common.h +++ b/trunk/drivers/net/wireless/b43/phy_common.h @@ -194,7 +194,6 @@ struct b43_phy_a; struct b43_phy_g; struct b43_phy_n; struct b43_phy_lp; -struct b43_phy_ht; struct b43_phy { /* Hardware operation callbacks. */ @@ -217,8 +216,6 @@ struct b43_phy { struct b43_phy_n *n; /* LP-PHY specific information */ struct b43_phy_lp *lp; - /* HT-PHY specific information */ - struct b43_phy_ht *ht; }; /* Band support flags. */ diff --git a/trunk/drivers/net/wireless/b43/phy_ht.c b/trunk/drivers/net/wireless/b43/phy_ht.c deleted file mode 100644 index 30b19c61037d..000000000000 --- a/trunk/drivers/net/wireless/b43/phy_ht.c +++ /dev/null @@ -1,398 +0,0 @@ -/* - - Broadcom B43 wireless driver - IEEE 802.11n HT-PHY support - - 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. - - 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; see the file COPYING. If not, write to - the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor, - Boston, MA 02110-1301, USA. - -*/ - -#include - -#include "b43.h" -#include "phy_ht.h" -#include "tables_phy_ht.h" -#include "radio_2059.h" -#include "main.h" - -/************************************************** - * Radio 2059. - **************************************************/ - -static void b43_radio_2059_channel_setup(struct b43_wldev *dev, - const struct b43_phy_ht_channeltab_e_radio2059 *e) -{ - u8 i; - u16 routing; - - b43_radio_write(dev, 0x16, e->radio_syn16); - b43_radio_write(dev, 0x17, e->radio_syn17); - b43_radio_write(dev, 0x22, e->radio_syn22); - b43_radio_write(dev, 0x25, e->radio_syn25); - b43_radio_write(dev, 0x27, e->radio_syn27); - b43_radio_write(dev, 0x28, e->radio_syn28); - b43_radio_write(dev, 0x29, e->radio_syn29); - b43_radio_write(dev, 0x2c, e->radio_syn2c); - b43_radio_write(dev, 0x2d, e->radio_syn2d); - b43_radio_write(dev, 0x37, e->radio_syn37); - b43_radio_write(dev, 0x41, e->radio_syn41); - b43_radio_write(dev, 0x43, e->radio_syn43); - b43_radio_write(dev, 0x47, e->radio_syn47); - b43_radio_write(dev, 0x4a, e->radio_syn4a); - b43_radio_write(dev, 0x58, e->radio_syn58); - b43_radio_write(dev, 0x5a, e->radio_syn5a); - b43_radio_write(dev, 0x6a, e->radio_syn6a); - b43_radio_write(dev, 0x6d, e->radio_syn6d); - b43_radio_write(dev, 0x6e, e->radio_syn6e); - b43_radio_write(dev, 0x92, e->radio_syn92); - b43_radio_write(dev, 0x98, e->radio_syn98); - - for (i = 0; i < 2; i++) { - routing = i ? R2059_RXRX1 : R2059_TXRX0; - b43_radio_write(dev, routing | 0x4a, e->radio_rxtx4a); - b43_radio_write(dev, routing | 0x58, e->radio_rxtx58); - b43_radio_write(dev, routing | 0x5a, e->radio_rxtx5a); - b43_radio_write(dev, routing | 0x6a, e->radio_rxtx6a); - b43_radio_write(dev, routing | 0x6d, e->radio_rxtx6d); - b43_radio_write(dev, routing | 0x6e, e->radio_rxtx6e); - b43_radio_write(dev, routing | 0x92, e->radio_rxtx92); - b43_radio_write(dev, routing | 0x98, e->radio_rxtx98); - } - - udelay(50); - - /* Calibration */ - b43_radio_mask(dev, 0x2b, ~0x1); - b43_radio_mask(dev, 0x2e, ~0x4); - b43_radio_set(dev, 0x2e, 0x4); - b43_radio_set(dev, 0x2b, 0x1); - - udelay(300); -} - -static void b43_radio_2059_init(struct b43_wldev *dev) -{ - const u16 routing[] = { R2059_SYN, R2059_TXRX0, R2059_RXRX1 }; - const u16 radio_values[3][2] = { - { 0x61, 0xE9 }, { 0x69, 0xD5 }, { 0x73, 0x99 }, - }; - u16 i, j; - - b43_radio_write(dev, R2059_ALL | 0x51, 0x0070); - b43_radio_write(dev, R2059_ALL | 0x5a, 0x0003); - - for (i = 0; i < ARRAY_SIZE(routing); i++) - b43_radio_set(dev, routing[i] | 0x146, 0x3); - - b43_radio_set(dev, 0x2e, 0x0078); - b43_radio_set(dev, 0xc0, 0x0080); - msleep(2); - b43_radio_mask(dev, 0x2e, ~0x0078); - b43_radio_mask(dev, 0xc0, ~0x0080); - - if (1) { /* FIXME */ - b43_radio_set(dev, R2059_RXRX1 | 0x4, 0x1); - udelay(10); - b43_radio_set(dev, R2059_RXRX1 | 0x0BF, 0x1); - b43_radio_maskset(dev, R2059_RXRX1 | 0x19B, 0x3, 0x2); - - b43_radio_set(dev, R2059_RXRX1 | 0x4, 0x2); - udelay(100); - b43_radio_mask(dev, R2059_RXRX1 | 0x4, ~0x2); - - for (i = 0; i < 10000; i++) { - if (b43_radio_read(dev, R2059_RXRX1 | 0x145) & 1) { - i = 0; - break; - } - udelay(100); - } - if (i) - b43err(dev->wl, "radio 0x945 timeout\n"); - - b43_radio_mask(dev, R2059_RXRX1 | 0x4, ~0x1); - b43_radio_set(dev, 0xa, 0x60); - - for (i = 0; i < 3; i++) { - b43_radio_write(dev, 0x17F, radio_values[i][0]); - b43_radio_write(dev, 0x13D, 0x6E); - b43_radio_write(dev, 0x13E, radio_values[i][1]); - b43_radio_write(dev, 0x13C, 0x55); - - for (j = 0; j < 10000; j++) { - if (b43_radio_read(dev, 0x140) & 2) { - j = 0; - break; - } - udelay(500); - } - if (j) - b43err(dev->wl, "radio 0x140 timeout\n"); - - b43_radio_write(dev, 0x13C, 0x15); - } - - b43_radio_mask(dev, 0x17F, ~0x1); - } - - b43_radio_mask(dev, 0x11, 0x0008); -} - -/************************************************** - * Channel switching ops. - **************************************************/ - -static void b43_phy_ht_channel_setup(struct b43_wldev *dev, - const struct b43_phy_ht_channeltab_e_phy *e, - struct ieee80211_channel *new_channel) -{ - bool old_band_5ghz; - u8 i; - - old_band_5ghz = b43_phy_read(dev, B43_PHY_HT_BANDCTL) & 0; /* FIXME */ - if (new_channel->band == IEEE80211_BAND_5GHZ && !old_band_5ghz) { - /* TODO */ - } else if (new_channel->band == IEEE80211_BAND_2GHZ && old_band_5ghz) { - /* TODO */ - } - - b43_phy_write(dev, B43_PHY_HT_BW1, e->bw1); - b43_phy_write(dev, B43_PHY_HT_BW2, e->bw2); - b43_phy_write(dev, B43_PHY_HT_BW3, e->bw3); - b43_phy_write(dev, B43_PHY_HT_BW4, e->bw4); - b43_phy_write(dev, B43_PHY_HT_BW5, e->bw5); - b43_phy_write(dev, B43_PHY_HT_BW6, e->bw6); - - /* TODO: some ops on PHY regs 0x0B0 and 0xC0A */ - - /* TODO: separated function? */ - for (i = 0; i < 3; i++) { - u16 mask; - u32 tmp = b43_httab_read(dev, B43_HTTAB32(26, 0xE8)); - - if (0) /* FIXME */ - mask = 0x2 << (i * 4); - else - mask = 0; - b43_phy_mask(dev, B43_PHY_EXTG(0x108), mask); - - b43_httab_write(dev, B43_HTTAB16(7, 0x110 + i), tmp >> 16); - b43_httab_write(dev, B43_HTTAB8(13, 0x63 + (i * 4)), - tmp & 0xFF); - b43_httab_write(dev, B43_HTTAB8(13, 0x73 + (i * 4)), - tmp & 0xFF); - } - - b43_phy_write(dev, 0x017e, 0x3830); -} - -static int b43_phy_ht_set_channel(struct b43_wldev *dev, - struct ieee80211_channel *channel, - enum nl80211_channel_type channel_type) -{ - struct b43_phy *phy = &dev->phy; - - const struct b43_phy_ht_channeltab_e_radio2059 *chent_r2059 = NULL; - - if (phy->radio_ver == 0x2059) { - chent_r2059 = b43_phy_ht_get_channeltab_e_r2059(dev, - channel->center_freq); - if (!chent_r2059) - return -ESRCH; - } else { - return -ESRCH; - } - - /* TODO: In case of N-PHY some bandwidth switching goes here */ - - if (phy->radio_ver == 0x2059) { - b43_radio_2059_channel_setup(dev, chent_r2059); - b43_phy_ht_channel_setup(dev, &(chent_r2059->phy_regs), - channel); - } else { - return -ESRCH; - } - - return 0; -} - -/************************************************** - * Basic PHY ops. - **************************************************/ - -static int b43_phy_ht_op_allocate(struct b43_wldev *dev) -{ - struct b43_phy_ht *phy_ht; - - phy_ht = kzalloc(sizeof(*phy_ht), GFP_KERNEL); - if (!phy_ht) - return -ENOMEM; - dev->phy.ht = phy_ht; - - return 0; -} - -static void b43_phy_ht_op_prepare_structs(struct b43_wldev *dev) -{ - struct b43_phy *phy = &dev->phy; - struct b43_phy_ht *phy_ht = phy->ht; - - memset(phy_ht, 0, sizeof(*phy_ht)); -} - -static int b43_phy_ht_op_init(struct b43_wldev *dev) -{ - b43_phy_ht_tables_init(dev); - - return 0; -} - -static void b43_phy_ht_op_free(struct b43_wldev *dev) -{ - struct b43_phy *phy = &dev->phy; - struct b43_phy_ht *phy_ht = phy->ht; - - kfree(phy_ht); - phy->ht = NULL; -} - -/* http://bcm-v4.sipsolutions.net/802.11/Radio/Switch%20Radio */ -static void b43_phy_ht_op_software_rfkill(struct b43_wldev *dev, - bool blocked) -{ - if (b43_read32(dev, B43_MMIO_MACCTL) & B43_MACCTL_ENABLED) - b43err(dev->wl, "MAC not suspended\n"); - - if (blocked) { - b43_phy_mask(dev, B43_PHY_HT_RF_CTL1, ~0); - } else { - b43_phy_mask(dev, B43_PHY_HT_RF_CTL1, ~0); - b43_phy_maskset(dev, B43_PHY_HT_RF_CTL1, ~0, 0x1); - b43_phy_mask(dev, B43_PHY_HT_RF_CTL1, ~0); - b43_phy_maskset(dev, B43_PHY_HT_RF_CTL1, ~0, 0x2); - - if (dev->phy.radio_ver == 0x2059) - b43_radio_2059_init(dev); - else - B43_WARN_ON(1); - } -} - -static void b43_phy_ht_op_switch_analog(struct b43_wldev *dev, bool on) -{ - if (on) { - b43_phy_write(dev, B43_PHY_HT_AFE_CTL2, 0x00cd); - b43_phy_write(dev, B43_PHY_HT_AFE_CTL1, 0x0000); - b43_phy_write(dev, B43_PHY_HT_AFE_CTL4, 0x00cd); - b43_phy_write(dev, B43_PHY_HT_AFE_CTL3, 0x0000); - b43_phy_write(dev, B43_PHY_HT_AFE_CTL6, 0x00cd); - b43_phy_write(dev, B43_PHY_HT_AFE_CTL5, 0x0000); - } else { - b43_phy_write(dev, B43_PHY_HT_AFE_CTL1, 0x07ff); - b43_phy_write(dev, B43_PHY_HT_AFE_CTL2, 0x00fd); - b43_phy_write(dev, B43_PHY_HT_AFE_CTL3, 0x07ff); - b43_phy_write(dev, B43_PHY_HT_AFE_CTL4, 0x00fd); - b43_phy_write(dev, B43_PHY_HT_AFE_CTL5, 0x07ff); - b43_phy_write(dev, B43_PHY_HT_AFE_CTL6, 0x00fd); - } -} - -static int b43_phy_ht_op_switch_channel(struct b43_wldev *dev, - unsigned int new_channel) -{ - struct ieee80211_channel *channel = dev->wl->hw->conf.channel; - enum nl80211_channel_type channel_type = dev->wl->hw->conf.channel_type; - - if (b43_current_band(dev->wl) == IEEE80211_BAND_2GHZ) { - if ((new_channel < 1) || (new_channel > 14)) - return -EINVAL; - } else { - return -EINVAL; - } - - return b43_phy_ht_set_channel(dev, channel, channel_type); -} - -static unsigned int b43_phy_ht_op_get_default_chan(struct b43_wldev *dev) -{ - if (b43_current_band(dev->wl) == IEEE80211_BAND_2GHZ) - return 1; - return 36; -} - -/************************************************** - * R/W ops. - **************************************************/ - -static u16 b43_phy_ht_op_read(struct b43_wldev *dev, u16 reg) -{ - b43_write16(dev, B43_MMIO_PHY_CONTROL, reg); - return b43_read16(dev, B43_MMIO_PHY_DATA); -} - -static void b43_phy_ht_op_write(struct b43_wldev *dev, u16 reg, u16 value) -{ - b43_write16(dev, B43_MMIO_PHY_CONTROL, reg); - b43_write16(dev, B43_MMIO_PHY_DATA, value); -} - -static void b43_phy_ht_op_maskset(struct b43_wldev *dev, u16 reg, u16 mask, - u16 set) -{ - b43_write16(dev, B43_MMIO_PHY_CONTROL, reg); - b43_write16(dev, B43_MMIO_PHY_DATA, - (b43_read16(dev, B43_MMIO_PHY_DATA) & mask) | set); -} - -static u16 b43_phy_ht_op_radio_read(struct b43_wldev *dev, u16 reg) -{ - /* HT-PHY needs 0x200 for read access */ - reg |= 0x200; - - b43_write16(dev, B43_MMIO_RADIO24_CONTROL, reg); - return b43_read16(dev, B43_MMIO_RADIO24_DATA); -} - -static void b43_phy_ht_op_radio_write(struct b43_wldev *dev, u16 reg, - u16 value) -{ - b43_write16(dev, B43_MMIO_RADIO24_CONTROL, reg); - b43_write16(dev, B43_MMIO_RADIO24_DATA, value); -} - -/************************************************** - * PHY ops struct. - **************************************************/ - -const struct b43_phy_operations b43_phyops_ht = { - .allocate = b43_phy_ht_op_allocate, - .free = b43_phy_ht_op_free, - .prepare_structs = b43_phy_ht_op_prepare_structs, - .init = b43_phy_ht_op_init, - .phy_read = b43_phy_ht_op_read, - .phy_write = b43_phy_ht_op_write, - .phy_maskset = b43_phy_ht_op_maskset, - .radio_read = b43_phy_ht_op_radio_read, - .radio_write = b43_phy_ht_op_radio_write, - .software_rfkill = b43_phy_ht_op_software_rfkill, - .switch_analog = b43_phy_ht_op_switch_analog, - .switch_channel = b43_phy_ht_op_switch_channel, - .get_default_chan = b43_phy_ht_op_get_default_chan, - /* - .recalc_txpower = b43_phy_ht_op_recalc_txpower, - .adjust_txpower = b43_phy_ht_op_adjust_txpower, - */ -}; diff --git a/trunk/drivers/net/wireless/b43/phy_ht.h b/trunk/drivers/net/wireless/b43/phy_ht.h deleted file mode 100644 index 7ad7affc8df0..000000000000 --- a/trunk/drivers/net/wireless/b43/phy_ht.h +++ /dev/null @@ -1,46 +0,0 @@ -#ifndef B43_PHY_HT_H_ -#define B43_PHY_HT_H_ - -#include "phy_common.h" - - -#define B43_PHY_HT_BANDCTL 0x009 /* Band control */ -#define B43_PHY_HT_TABLE_ADDR 0x072 /* Table address */ -#define B43_PHY_HT_TABLE_DATALO 0x073 /* Table data low */ -#define B43_PHY_HT_TABLE_DATAHI 0x074 /* Table data high */ -#define B43_PHY_HT_BW1 0x1CE -#define B43_PHY_HT_BW2 0x1CF -#define B43_PHY_HT_BW3 0x1D0 -#define B43_PHY_HT_BW4 0x1D1 -#define B43_PHY_HT_BW5 0x1D2 -#define B43_PHY_HT_BW6 0x1D3 - -#define B43_PHY_HT_RF_CTL1 B43_PHY_EXTG(0x010) - -#define B43_PHY_HT_AFE_CTL1 B43_PHY_EXTG(0x110) -#define B43_PHY_HT_AFE_CTL2 B43_PHY_EXTG(0x111) -#define B43_PHY_HT_AFE_CTL3 B43_PHY_EXTG(0x114) -#define B43_PHY_HT_AFE_CTL4 B43_PHY_EXTG(0x115) -#define B43_PHY_HT_AFE_CTL5 B43_PHY_EXTG(0x118) -#define B43_PHY_HT_AFE_CTL6 B43_PHY_EXTG(0x119) - - -/* Values for PHY registers used on channel switching */ -struct b43_phy_ht_channeltab_e_phy { - u16 bw1; - u16 bw2; - u16 bw3; - u16 bw4; - u16 bw5; - u16 bw6; -}; - - -struct b43_phy_ht { -}; - - -struct b43_phy_operations; -extern const struct b43_phy_operations b43_phyops_ht; - -#endif /* B43_PHY_HT_H_ */ diff --git a/trunk/drivers/net/wireless/b43/phy_n.c b/trunk/drivers/net/wireless/b43/phy_n.c index e7dfdac9e4d7..ad14f3b428c5 100644 --- a/trunk/drivers/net/wireless/b43/phy_n.c +++ b/trunk/drivers/net/wireless/b43/phy_n.c @@ -4025,24 +4025,11 @@ static void b43_nphy_op_software_rfkill(struct b43_wldev *dev, /* http://bcm-v4.sipsolutions.net/802.11/PHY/Anacore */ static void b43_nphy_op_switch_analog(struct b43_wldev *dev, bool on) { - u16 override = on ? 0x0 : 0x7FFF; - u16 core = on ? 0xD : 0x00FD; + u16 val = on ? 0 : 0x7FFF; - if (dev->phy.rev >= 3) { - if (on) { - b43_phy_write(dev, B43_NPHY_AFECTL_C1, core); - b43_phy_write(dev, B43_NPHY_AFECTL_OVER1, override); - b43_phy_write(dev, B43_NPHY_AFECTL_C2, core); - b43_phy_write(dev, B43_NPHY_AFECTL_OVER, override); - } else { - b43_phy_write(dev, B43_NPHY_AFECTL_OVER1, override); - b43_phy_write(dev, B43_NPHY_AFECTL_C1, core); - b43_phy_write(dev, B43_NPHY_AFECTL_OVER, override); - b43_phy_write(dev, B43_NPHY_AFECTL_C2, core); - } - } else { - b43_phy_write(dev, B43_NPHY_AFECTL_OVER, override); - } + if (dev->phy.rev >= 3) + b43_phy_write(dev, B43_NPHY_AFECTL_OVER1, val); + b43_phy_write(dev, B43_NPHY_AFECTL_OVER, val); } static int b43_nphy_op_switch_channel(struct b43_wldev *dev, diff --git a/trunk/drivers/net/wireless/b43/radio_2055.h b/trunk/drivers/net/wireless/b43/radio_2055.h index 67f96122f8d8..d9bfa0f21b72 100644 --- a/trunk/drivers/net/wireless/b43/radio_2055.h +++ b/trunk/drivers/net/wireless/b43/radio_2055.h @@ -251,9 +251,4 @@ struct b43_nphy_channeltab_entry_rev2 { void b2055_upload_inittab(struct b43_wldev *dev, bool ghz5, bool ignore_uploadflag); -/* Get the NPHY Channel Switch Table entry for a channel. - * Returns NULL on failure to find an entry. */ -const struct b43_nphy_channeltab_entry_rev2 * -b43_nphy_get_chantabent_rev2(struct b43_wldev *dev, u8 channel); - #endif /* B43_RADIO_2055_H_ */ diff --git a/trunk/drivers/net/wireless/b43/radio_2056.h b/trunk/drivers/net/wireless/b43/radio_2056.h index d52df6be705a..d601f6e7e313 100644 --- a/trunk/drivers/net/wireless/b43/radio_2056.h +++ b/trunk/drivers/net/wireless/b43/radio_2056.h @@ -1117,9 +1117,4 @@ struct b43_nphy_channeltab_entry_rev3 { void b2056_upload_inittabs(struct b43_wldev *dev, bool ghz5, bool ignore_uploadflag); -/* Get the NPHY Channel Switch Table entry for a channel. - * Returns NULL on failure to find an entry. */ -const struct b43_nphy_channeltab_entry_rev3 * -b43_nphy_get_chantabent_rev3(struct b43_wldev *dev, u16 freq); - #endif /* B43_RADIO_2056_H_ */ diff --git a/trunk/drivers/net/wireless/b43/radio_2059.c b/trunk/drivers/net/wireless/b43/radio_2059.c deleted file mode 100644 index 23dea4ba8219..000000000000 --- a/trunk/drivers/net/wireless/b43/radio_2059.c +++ /dev/null @@ -1,165 +0,0 @@ -/* - - Broadcom B43 wireless driver - IEEE 802.11n 2059 radio device data tables - - 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. - - 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; see the file COPYING. If not, write to - the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor, - Boston, MA 02110-1301, USA. - -*/ - -#include "b43.h" -#include "radio_2059.h" - -#define RADIOREGS(r00, r01, r02, r03, r04, r05, r06, r07, r08, r09, \ - r10, r11, r12, r13, r14, r15, r16, r17, r18, r19, \ - r20, r21, r22, r23, r24, r25, r26, r27, r28) \ - .radio_syn16 = r00, \ - .radio_syn17 = r01, \ - .radio_syn22 = r02, \ - .radio_syn25 = r03, \ - .radio_syn27 = r04, \ - .radio_syn28 = r05, \ - .radio_syn29 = r06, \ - .radio_syn2c = r07, \ - .radio_syn2d = r08, \ - .radio_syn37 = r09, \ - .radio_syn41 = r10, \ - .radio_syn43 = r11, \ - .radio_syn47 = r12, \ - .radio_syn4a = r13, \ - .radio_syn58 = r14, \ - .radio_syn5a = r15, \ - .radio_syn6a = r16, \ - .radio_syn6d = r17, \ - .radio_syn6e = r18, \ - .radio_syn92 = r19, \ - .radio_syn98 = r20, \ - .radio_rxtx4a = r21, \ - .radio_rxtx58 = r22, \ - .radio_rxtx5a = r23, \ - .radio_rxtx6a = r24, \ - .radio_rxtx6d = r25, \ - .radio_rxtx6e = r26, \ - .radio_rxtx92 = r27, \ - .radio_rxtx98 = r28 - -#define PHYREGS(r0, r1, r2, r3, r4, r5) \ - .phy_regs.bw1 = r0, \ - .phy_regs.bw2 = r1, \ - .phy_regs.bw3 = r2, \ - .phy_regs.bw4 = r3, \ - .phy_regs.bw5 = r4, \ - .phy_regs.bw6 = r5 - -static const struct b43_phy_ht_channeltab_e_radio2059 b43_phy_ht_channeltab_radio2059[] = { - { .freq = 2412, - RADIOREGS(0x48, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0x6c, - 0x09, 0x0f, 0x0a, 0x00, 0x0a, 0x00, 0x61, 0x03, - 0x00, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x61, 0x03, - 0x00, 0x00, 0x00, 0xf0, 0x00), - PHYREGS(0x03c9, 0x03c5, 0x03c1, 0x043a, 0x043f, 0x0443), - }, - { .freq = 2417, - RADIOREGS(0x4b, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0x71, - 0x09, 0x0f, 0x0a, 0x00, 0x0a, 0x00, 0x61, 0x03, - 0x00, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x61, 0x03, - 0x00, 0x00, 0x00, 0xf0, 0x00), - PHYREGS(0x03cb, 0x03c7, 0x03c3, 0x0438, 0x043d, 0x0441), - }, - { .freq = 2422, - RADIOREGS(0x4e, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0x76, - 0x09, 0x0f, 0x09, 0x00, 0x09, 0x00, 0x61, 0x03, - 0x00, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x61, 0x03, - 0x00, 0x00, 0x00, 0xf0, 0x00), - PHYREGS(0x03cd, 0x03c9, 0x03c5, 0x0436, 0x043a, 0x043f), - }, - { .freq = 2427, - RADIOREGS(0x52, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0x7b, - 0x09, 0x0f, 0x09, 0x00, 0x09, 0x00, 0x61, 0x03, - 0x00, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x61, 0x03, - 0x00, 0x00, 0x00, 0xf0, 0x00), - PHYREGS(0x03cf, 0x03cb, 0x03c7, 0x0434, 0x0438, 0x043d), - }, - { .freq = 2432, - RADIOREGS(0x55, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0x80, - 0x09, 0x0f, 0x08, 0x00, 0x08, 0x00, 0x61, 0x03, - 0x00, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x61, 0x03, - 0x00, 0x00, 0x00, 0xf0, 0x00), - PHYREGS(0x03d1, 0x03cd, 0x03c9, 0x0431, 0x0436, 0x043a), - }, - { .freq = 2437, - RADIOREGS(0x58, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0x85, - 0x09, 0x0f, 0x08, 0x00, 0x08, 0x00, 0x61, 0x03, - 0x00, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x61, 0x03, - 0x00, 0x00, 0x00, 0xf0, 0x00), - PHYREGS(0x03d3, 0x03cf, 0x03cb, 0x042f, 0x0434, 0x0438), - }, - { .freq = 2442, - RADIOREGS(0x5c, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0x8a, - 0x09, 0x0f, 0x07, 0x00, 0x07, 0x00, 0x61, 0x03, - 0x00, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x61, 0x03, - 0x00, 0x00, 0x00, 0xf0, 0x00), - PHYREGS(0x03d5, 0x03d1, 0x03cd, 0x042d, 0x0431, 0x0436), - }, - { .freq = 2447, - RADIOREGS(0x5f, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0x8f, - 0x09, 0x0f, 0x07, 0x00, 0x07, 0x00, 0x61, 0x03, - 0x00, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x61, 0x03, - 0x00, 0x00, 0x00, 0xf0, 0x00), - PHYREGS(0x03d7, 0x03d3, 0x03cf, 0x042b, 0x042f, 0x0434), - }, - { .freq = 2452, - RADIOREGS(0x62, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0x94, - 0x09, 0x0f, 0x07, 0x00, 0x07, 0x00, 0x61, 0x03, - 0x00, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x61, 0x03, - 0x00, 0x00, 0x00, 0xf0, 0x00), - PHYREGS(0x03d9, 0x03d5, 0x03d1, 0x0429, 0x042d, 0x0431), - }, - { .freq = 2457, - RADIOREGS(0x66, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0x99, - 0x09, 0x0f, 0x06, 0x00, 0x06, 0x00, 0x61, 0x03, - 0x00, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x61, 0x03, - 0x00, 0x00, 0x00, 0xf0, 0x00), - PHYREGS(0x03db, 0x03d7, 0x03d3, 0x0427, 0x042b, 0x042f), - }, - { .freq = 2462, - RADIOREGS(0x69, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0x9e, - 0x09, 0x0f, 0x06, 0x00, 0x06, 0x00, 0x61, 0x03, - 0x00, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x61, 0x03, - 0x00, 0x00, 0x00, 0xf0, 0x00), - PHYREGS(0x03dd, 0x03d9, 0x03d5, 0x0424, 0x0429, 0x042d), - }, - { .freq = 2467, - RADIOREGS(0x6c, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0xa3, - 0x09, 0x0f, 0x05, 0x00, 0x05, 0x00, 0x61, 0x03, - 0x00, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x61, 0x03, - 0x00, 0x00, 0x00, 0xf0, 0x00), - PHYREGS(0x03df, 0x03db, 0x03d7, 0x0422, 0x0427, 0x042b), - }, - { .freq = 2472, - RADIOREGS(0x70, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0xa8, - 0x09, 0x0f, 0x05, 0x00, 0x05, 0x00, 0x61, 0x03, - 0x00, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x61, 0x03, - 0x00, 0x00, 0x00, 0xf0, 0x00), - PHYREGS(0x03e1, 0x03dd, 0x03d9, 0x0420, 0x0424, 0x0429), - }, -}; - -const struct b43_phy_ht_channeltab_e_radio2059 -*b43_phy_ht_get_channeltab_e_r2059(struct b43_wldev *dev, u16 freq) -{ - return NULL; -} diff --git a/trunk/drivers/net/wireless/b43/radio_2059.h b/trunk/drivers/net/wireless/b43/radio_2059.h deleted file mode 100644 index e4d69e55e9fe..000000000000 --- a/trunk/drivers/net/wireless/b43/radio_2059.h +++ /dev/null @@ -1,54 +0,0 @@ -#ifndef B43_RADIO_2059_H_ -#define B43_RADIO_2059_H_ - -#include - -#include "phy_ht.h" - -#define R2059_SYN 0x000 -#define R2059_TXRX0 0x400 -#define R2059_RXRX1 0x800 -#define R2059_ALL 0xC00 - -/* Values for various registers uploaded on channel switching */ -struct b43_phy_ht_channeltab_e_radio2059 { - /* The channel frequency in MHz */ - u16 freq; - /* Values for radio registers */ - u8 radio_syn16; - u8 radio_syn17; - u8 radio_syn22; - u8 radio_syn25; - u8 radio_syn27; - u8 radio_syn28; - u8 radio_syn29; - u8 radio_syn2c; - u8 radio_syn2d; - u8 radio_syn37; - u8 radio_syn41; - u8 radio_syn43; - u8 radio_syn47; - u8 radio_syn4a; - u8 radio_syn58; - u8 radio_syn5a; - u8 radio_syn6a; - u8 radio_syn6d; - u8 radio_syn6e; - u8 radio_syn92; - u8 radio_syn98; - u8 radio_rxtx4a; - u8 radio_rxtx58; - u8 radio_rxtx5a; - u8 radio_rxtx6a; - u8 radio_rxtx6d; - u8 radio_rxtx6e; - u8 radio_rxtx92; - u8 radio_rxtx98; - /* Values for PHY registers */ - struct b43_phy_ht_channeltab_e_phy phy_regs; -}; - -const struct b43_phy_ht_channeltab_e_radio2059 -*b43_phy_ht_get_channeltab_e_r2059(struct b43_wldev *dev, u16 freq); - -#endif /* B43_RADIO_2059_H_ */ diff --git a/trunk/drivers/net/wireless/b43/sdio.c b/trunk/drivers/net/wireless/b43/sdio.c index 4fd6775b8c33..e6c733d37c94 100644 --- a/trunk/drivers/net/wireless/b43/sdio.c +++ b/trunk/drivers/net/wireless/b43/sdio.c @@ -93,8 +93,8 @@ void b43_sdio_free_irq(struct b43_wldev *dev) sdio->irq_handler = NULL; } -static int __devinit b43_sdio_probe(struct sdio_func *func, - const struct sdio_device_id *id) +static int b43_sdio_probe(struct sdio_func *func, + const struct sdio_device_id *id) { struct b43_sdio *sdio; struct sdio_func_tuple *tuple; @@ -171,7 +171,7 @@ static int __devinit b43_sdio_probe(struct sdio_func *func, return error; } -static void __devexit b43_sdio_remove(struct sdio_func *func) +static void b43_sdio_remove(struct sdio_func *func) { struct b43_sdio *sdio = sdio_get_drvdata(func); diff --git a/trunk/drivers/net/wireless/b43/tables_nphy.h b/trunk/drivers/net/wireless/b43/tables_nphy.h index a81696bff0ed..18569367ce43 100644 --- a/trunk/drivers/net/wireless/b43/tables_nphy.h +++ b/trunk/drivers/net/wireless/b43/tables_nphy.h @@ -60,8 +60,16 @@ struct nphy_gain_ctl_workaround_entry { struct nphy_gain_ctl_workaround_entry *b43_nphy_get_gain_ctl_workaround_ent( struct b43_wldev *dev, bool ghz5, bool ext_lna); +/* Get the NPHY Channel Switch Table entry for a channel. + * Returns NULL on failure to find an entry. */ +const struct b43_nphy_channeltab_entry_rev2 * +b43_nphy_get_chantabent_rev2(struct b43_wldev *dev, u8 channel); +const struct b43_nphy_channeltab_entry_rev3 * +b43_nphy_get_chantabent_rev3(struct b43_wldev *dev, u16 freq); + /* The N-PHY tables. */ + #define B43_NTAB_TYPEMASK 0xF0000000 #define B43_NTAB_8BIT 0x10000000 #define B43_NTAB_16BIT 0x20000000 diff --git a/trunk/drivers/net/wireless/b43/tables_phy_ht.c b/trunk/drivers/net/wireless/b43/tables_phy_ht.c deleted file mode 100644 index 603938657b15..000000000000 --- a/trunk/drivers/net/wireless/b43/tables_phy_ht.c +++ /dev/null @@ -1,750 +0,0 @@ -/* - - Broadcom B43 wireless driver - IEEE 802.11n HT-PHY data tables - - 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. - - 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; see the file COPYING. If not, write to - the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor, - Boston, MA 02110-1301, USA. - -*/ - -#include "b43.h" -#include "tables_phy_ht.h" -#include "phy_common.h" -#include "phy_ht.h" - -static const u16 b43_httab_0x12[] = { - 0x0000, 0x0008, 0x000a, 0x0010, 0x0012, 0x0019, - 0x001a, 0x001c, 0x0080, 0x0088, 0x008a, 0x0090, - 0x0092, 0x0099, 0x009a, 0x009c, 0x0100, 0x0108, - 0x010a, 0x0110, 0x0112, 0x0119, 0x011a, 0x011c, - 0x0180, 0x0188, 0x018a, 0x0190, 0x0192, 0x0199, - 0x019a, 0x019c, 0x0000, 0x0098, 0x00a0, 0x00a8, - 0x009a, 0x00a2, 0x00aa, 0x0120, 0x0128, 0x0128, - 0x0130, 0x0138, 0x0138, 0x0140, 0x0122, 0x012a, - 0x012a, 0x0132, 0x013a, 0x013a, 0x0142, 0x01a8, - 0x01b0, 0x01b8, 0x01b0, 0x01b8, 0x01c0, 0x01c8, - 0x01c0, 0x01c8, 0x01d0, 0x01d0, 0x01d8, 0x01aa, - 0x01b2, 0x01ba, 0x01b2, 0x01ba, 0x01c2, 0x01ca, - 0x01c2, 0x01ca, 0x01d2, 0x01d2, 0x01da, 0x0001, - 0x0002, 0x0004, 0x0009, 0x000c, 0x0011, 0x0014, - 0x0018, 0x0020, 0x0021, 0x0022, 0x0024, 0x0081, - 0x0082, 0x0084, 0x0089, 0x008c, 0x0091, 0x0094, - 0x0098, 0x00a0, 0x00a1, 0x00a2, 0x00a4, 0x0007, - 0x0007, 0x0007, 0x0007, 0x0007, 0x0007, 0x0007, - 0x0007, 0x0007, 0x0007, 0x0007, 0x0007, 0x0007, - 0x0007, 0x0007, 0x0007, 0x0007, 0x0007, 0x0007, - 0x0007, 0x0007, 0x0007, 0x0007, 0x0007, 0x0007, - 0x0007, 0x0007, -}; - -static const u16 b43_httab_0x27[] = { - 0x0009, 0x000e, 0x0011, 0x0014, 0x0017, 0x001a, - 0x001d, 0x0020, 0x0009, 0x000e, 0x0011, 0x0014, - 0x0017, 0x001a, 0x001d, 0x0020, 0x0009, 0x000e, - 0x0011, 0x0014, 0x0017, 0x001a, 0x001d, 0x0020, - 0x0009, 0x000e, 0x0011, 0x0014, 0x0017, 0x001a, - 0x001d, 0x0020, -}; - -static const u16 b43_httab_0x26[] = { - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, -}; - -static const u32 b43_httab_0x25[] = { - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, -}; - -static const u32 b43_httab_0x2f[] = { - 0x00035700, 0x0002cc9a, 0x00026666, 0x0001581f, - 0x0001581f, 0x0001581f, 0x0001581f, 0x0001581f, - 0x0001581f, 0x0001581f, 0x0001581f, 0x00035700, - 0x0002cc9a, 0x00026666, 0x0001581f, 0x0001581f, - 0x0001581f, 0x0001581f, 0x0001581f, 0x0001581f, - 0x0001581f, 0x0001581f, -}; - -static const u16 b43_httab_0x1a[] = { - 0x0055, 0x0054, 0x0054, 0x0053, 0x0052, 0x0052, - 0x0051, 0x0051, 0x0050, 0x004f, 0x004f, 0x004e, - 0x004e, 0x004d, 0x004c, 0x004c, 0x004b, 0x004a, - 0x0049, 0x0049, 0x0048, 0x0047, 0x0046, 0x0046, - 0x0045, 0x0044, 0x0043, 0x0042, 0x0041, 0x0040, - 0x0040, 0x003f, 0x003e, 0x003d, 0x003c, 0x003a, - 0x0039, 0x0038, 0x0037, 0x0036, 0x0035, 0x0033, - 0x0032, 0x0031, 0x002f, 0x002e, 0x002c, 0x002b, - 0x0029, 0x0027, 0x0025, 0x0023, 0x0021, 0x001f, - 0x001d, 0x001a, 0x0018, 0x0015, 0x0012, 0x000e, - 0x000b, 0x0007, 0x0002, 0x00fd, -}; - -static const u16 b43_httab_0x1b[] = { - 0x0055, 0x0054, 0x0054, 0x0053, 0x0052, 0x0052, - 0x0051, 0x0051, 0x0050, 0x004f, 0x004f, 0x004e, - 0x004e, 0x004d, 0x004c, 0x004c, 0x004b, 0x004a, - 0x0049, 0x0049, 0x0048, 0x0047, 0x0046, 0x0046, - 0x0045, 0x0044, 0x0043, 0x0042, 0x0041, 0x0040, - 0x0040, 0x003f, 0x003e, 0x003d, 0x003c, 0x003a, - 0x0039, 0x0038, 0x0037, 0x0036, 0x0035, 0x0033, - 0x0032, 0x0031, 0x002f, 0x002e, 0x002c, 0x002b, - 0x0029, 0x0027, 0x0025, 0x0023, 0x0021, 0x001f, - 0x001d, 0x001a, 0x0018, 0x0015, 0x0012, 0x000e, - 0x000b, 0x0007, 0x0002, 0x00fd, -}; - -static const u16 b43_httab_0x1c[] = { - 0x0055, 0x0054, 0x0054, 0x0053, 0x0052, 0x0052, - 0x0051, 0x0051, 0x0050, 0x004f, 0x004f, 0x004e, - 0x004e, 0x004d, 0x004c, 0x004c, 0x004b, 0x004a, - 0x0049, 0x0049, 0x0048, 0x0047, 0x0046, 0x0046, - 0x0045, 0x0044, 0x0043, 0x0042, 0x0041, 0x0040, - 0x0040, 0x003f, 0x003e, 0x003d, 0x003c, 0x003a, - 0x0039, 0x0038, 0x0037, 0x0036, 0x0035, 0x0033, - 0x0032, 0x0031, 0x002f, 0x002e, 0x002c, 0x002b, - 0x0029, 0x0027, 0x0025, 0x0023, 0x0021, 0x001f, - 0x001d, 0x001a, 0x0018, 0x0015, 0x0012, 0x000e, - 0x000b, 0x0007, 0x0002, 0x00fd, -}; - -static const u32 b43_httab_0x1a_0xc0[] = { - 0x5bf70044, 0x5bf70042, 0x5bf70040, 0x5bf7003e, - 0x5bf7003c, 0x5bf7003b, 0x5bf70039, 0x5bf70037, - 0x5bf70036, 0x5bf70034, 0x5bf70033, 0x5bf70031, - 0x5bf70030, 0x5ba70044, 0x5ba70042, 0x5ba70040, - 0x5ba7003e, 0x5ba7003c, 0x5ba7003b, 0x5ba70039, - 0x5ba70037, 0x5ba70036, 0x5ba70034, 0x5ba70033, - 0x5b770044, 0x5b770042, 0x5b770040, 0x5b77003e, - 0x5b77003c, 0x5b77003b, 0x5b770039, 0x5b770037, - 0x5b770036, 0x5b770034, 0x5b770033, 0x5b770031, - 0x5b770030, 0x5b77002f, 0x5b77002d, 0x5b77002c, - 0x5b470044, 0x5b470042, 0x5b470040, 0x5b47003e, - 0x5b47003c, 0x5b47003b, 0x5b470039, 0x5b470037, - 0x5b470036, 0x5b470034, 0x5b470033, 0x5b470031, - 0x5b470030, 0x5b47002f, 0x5b47002d, 0x5b47002c, - 0x5b47002b, 0x5b47002a, 0x5b270044, 0x5b270042, - 0x5b270040, 0x5b27003e, 0x5b27003c, 0x5b27003b, - 0x5b270039, 0x5b270037, 0x5b270036, 0x5b270034, - 0x5b270033, 0x5b270031, 0x5b270030, 0x5b27002f, - 0x5b170044, 0x5b170042, 0x5b170040, 0x5b17003e, - 0x5b17003c, 0x5b17003b, 0x5b170039, 0x5b170037, - 0x5b170036, 0x5b170034, 0x5b170033, 0x5b170031, - 0x5b170030, 0x5b17002f, 0x5b17002d, 0x5b17002c, - 0x5b17002b, 0x5b17002a, 0x5b170028, 0x5b170027, - 0x5b170026, 0x5b170025, 0x5b170024, 0x5b170023, - 0x5b070044, 0x5b070042, 0x5b070040, 0x5b07003e, - 0x5b07003c, 0x5b07003b, 0x5b070039, 0x5b070037, - 0x5b070036, 0x5b070034, 0x5b070033, 0x5b070031, - 0x5b070030, 0x5b07002f, 0x5b07002d, 0x5b07002c, - 0x5b07002b, 0x5b07002a, 0x5b070028, 0x5b070027, - 0x5b070026, 0x5b070025, 0x5b070024, 0x5b070023, - 0x5b070022, 0x5b070021, 0x5b070020, 0x5b07001f, - 0x5b07001e, 0x5b07001d, 0x5b07001d, 0x5b07001c, -}; - -static const u32 b43_httab_0x1a_0x140[] = { - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, -}; - -static const u32 b43_httab_0x1b_0x140[] = { - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, -}; - -static const u32 b43_httab_0x1c_0x140[] = { - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, -}; - -static const u16 b43_httab_0x1a_0x1c0[] = { - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, -}; - -static const u16 b43_httab_0x1b_0x1c0[] = { - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, -}; - -static const u16 b43_httab_0x1c_0x1c0[] = { - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, -}; - -static const u16 b43_httab_0x1a_0x240[] = { - 0x0036, 0x0036, 0x0036, 0x0036, 0x0036, 0x0036, - 0x0036, 0x0036, 0x0036, 0x0036, 0x0036, 0x0036, - 0x0036, 0x002a, 0x002a, 0x002a, 0x002a, 0x002a, - 0x002a, 0x002a, 0x002a, 0x002a, 0x002a, 0x002a, - 0x001e, 0x001e, 0x001e, 0x001e, 0x001e, 0x001e, - 0x001e, 0x001e, 0x001e, 0x001e, 0x001e, 0x001e, - 0x001e, 0x001e, 0x001e, 0x001e, 0x000e, 0x000e, - 0x000e, 0x000e, 0x000e, 0x000e, 0x000e, 0x000e, - 0x000e, 0x000e, 0x000e, 0x000e, 0x000e, 0x000e, - 0x000e, 0x000e, 0x000e, 0x000e, 0x01fc, 0x01fc, - 0x01fc, 0x01fc, 0x01fc, 0x01fc, 0x01fc, 0x01fc, - 0x01fc, 0x01fc, 0x01fc, 0x01fc, 0x01fc, 0x01fc, - 0x01ee, 0x01ee, 0x01ee, 0x01ee, 0x01ee, 0x01ee, - 0x01ee, 0x01ee, 0x01ee, 0x01ee, 0x01ee, 0x01ee, - 0x01ee, 0x01ee, 0x01ee, 0x01ee, 0x01ee, 0x01ee, - 0x01ee, 0x01ee, 0x01ee, 0x01ee, 0x01ee, 0x01ee, - 0x01d6, 0x01d6, 0x01d6, 0x01d6, 0x01d6, 0x01d6, - 0x01d6, 0x01d6, 0x01d6, 0x01d6, 0x01d6, 0x01d6, - 0x01d6, 0x01d6, 0x01d6, 0x01d6, 0x01d6, 0x01d6, - 0x01d6, 0x01d6, 0x01d6, 0x01d6, 0x01d6, 0x01d6, - 0x01d6, 0x01d6, 0x01d6, 0x01d6, 0x01d6, 0x01d6, - 0x01d6, 0x01d6, -}; - -static const u16 b43_httab_0x1b_0x240[] = { - 0x0036, 0x0036, 0x0036, 0x0036, 0x0036, 0x0036, - 0x0036, 0x0036, 0x0036, 0x0036, 0x0036, 0x0036, - 0x0036, 0x002a, 0x002a, 0x002a, 0x002a, 0x002a, - 0x002a, 0x002a, 0x002a, 0x002a, 0x002a, 0x002a, - 0x001e, 0x001e, 0x001e, 0x001e, 0x001e, 0x001e, - 0x001e, 0x001e, 0x001e, 0x001e, 0x001e, 0x001e, - 0x001e, 0x001e, 0x001e, 0x001e, 0x000e, 0x000e, - 0x000e, 0x000e, 0x000e, 0x000e, 0x000e, 0x000e, - 0x000e, 0x000e, 0x000e, 0x000e, 0x000e, 0x000e, - 0x000e, 0x000e, 0x000e, 0x000e, 0x01fc, 0x01fc, - 0x01fc, 0x01fc, 0x01fc, 0x01fc, 0x01fc, 0x01fc, - 0x01fc, 0x01fc, 0x01fc, 0x01fc, 0x01fc, 0x01fc, - 0x01ee, 0x01ee, 0x01ee, 0x01ee, 0x01ee, 0x01ee, - 0x01ee, 0x01ee, 0x01ee, 0x01ee, 0x01ee, 0x01ee, - 0x01ee, 0x01ee, 0x01ee, 0x01ee, 0x01ee, 0x01ee, - 0x01ee, 0x01ee, 0x01ee, 0x01ee, 0x01ee, 0x01ee, - 0x01d6, 0x01d6, 0x01d6, 0x01d6, 0x01d6, 0x01d6, - 0x01d6, 0x01d6, 0x01d6, 0x01d6, 0x01d6, 0x01d6, - 0x01d6, 0x01d6, 0x01d6, 0x01d6, 0x01d6, 0x01d6, - 0x01d6, 0x01d6, 0x01d6, 0x01d6, 0x01d6, 0x01d6, - 0x01d6, 0x01d6, 0x01d6, 0x01d6, 0x01d6, 0x01d6, - 0x01d6, 0x01d6, -}; - -static const u16 b43_httab_0x1c_0x240[] = { - 0x0036, 0x0036, 0x0036, 0x0036, 0x0036, 0x0036, - 0x0036, 0x0036, 0x0036, 0x0036, 0x0036, 0x0036, - 0x0036, 0x002a, 0x002a, 0x002a, 0x002a, 0x002a, - 0x002a, 0x002a, 0x002a, 0x002a, 0x002a, 0x002a, - 0x001e, 0x001e, 0x001e, 0x001e, 0x001e, 0x001e, - 0x001e, 0x001e, 0x001e, 0x001e, 0x001e, 0x001e, - 0x001e, 0x001e, 0x001e, 0x001e, 0x000e, 0x000e, - 0x000e, 0x000e, 0x000e, 0x000e, 0x000e, 0x000e, - 0x000e, 0x000e, 0x000e, 0x000e, 0x000e, 0x000e, - 0x000e, 0x000e, 0x000e, 0x000e, 0x01fc, 0x01fc, - 0x01fc, 0x01fc, 0x01fc, 0x01fc, 0x01fc, 0x01fc, - 0x01fc, 0x01fc, 0x01fc, 0x01fc, 0x01fc, 0x01fc, - 0x01ee, 0x01ee, 0x01ee, 0x01ee, 0x01ee, 0x01ee, - 0x01ee, 0x01ee, 0x01ee, 0x01ee, 0x01ee, 0x01ee, - 0x01ee, 0x01ee, 0x01ee, 0x01ee, 0x01ee, 0x01ee, - 0x01ee, 0x01ee, 0x01ee, 0x01ee, 0x01ee, 0x01ee, - 0x01d6, 0x01d6, 0x01d6, 0x01d6, 0x01d6, 0x01d6, - 0x01d6, 0x01d6, 0x01d6, 0x01d6, 0x01d6, 0x01d6, - 0x01d6, 0x01d6, 0x01d6, 0x01d6, 0x01d6, 0x01d6, - 0x01d6, 0x01d6, 0x01d6, 0x01d6, 0x01d6, 0x01d6, - 0x01d6, 0x01d6, 0x01d6, 0x01d6, 0x01d6, 0x01d6, - 0x01d6, 0x01d6, -}; - -static const u32 b43_httab_0x1f[] = { - 0x00000000, 0x00000000, 0x00016023, 0x00006028, - 0x00034036, 0x0003402e, 0x0007203c, 0x0006e037, - 0x00070030, 0x0009401f, 0x0009a00f, 0x000b600d, - 0x000c8007, 0x000ce007, 0x00101fff, 0x00121ff9, - 0x0012e004, 0x0014dffc, 0x0016dff6, 0x0018dfe9, - 0x001b3fe5, 0x001c5fd0, 0x001ddfc2, 0x001f1fb6, - 0x00207fa4, 0x00219f8f, 0x0022ff7d, 0x00247f6c, - 0x0024df5b, 0x00267f4b, 0x0027df3b, 0x0029bf3b, - 0x002b5f2f, 0x002d3f2e, 0x002f5f2a, 0x002fff15, - 0x00315f0b, 0x0032defa, 0x0033beeb, 0x0034fed9, - 0x00353ec5, 0x00361eb0, 0x00363e9b, 0x0036be87, - 0x0036be70, 0x0038fe67, 0x0044beb2, 0x00513ef3, - 0x00595f11, 0x00669f3d, 0x0078dfdf, 0x00a143aa, - 0x01642fff, 0x0162afff, 0x01620fff, 0x0160cfff, - 0x015f0fff, 0x015dafff, 0x015bcfff, 0x015bcfff, - 0x015b4fff, 0x015acfff, 0x01590fff, 0x0156cfff, -}; - -static const u32 b43_httab_0x21[] = { - 0x00000000, 0x00000000, 0x00016023, 0x00006028, - 0x00034036, 0x0003402e, 0x0007203c, 0x0006e037, - 0x00070030, 0x0009401f, 0x0009a00f, 0x000b600d, - 0x000c8007, 0x000ce007, 0x00101fff, 0x00121ff9, - 0x0012e004, 0x0014dffc, 0x0016dff6, 0x0018dfe9, - 0x001b3fe5, 0x001c5fd0, 0x001ddfc2, 0x001f1fb6, - 0x00207fa4, 0x00219f8f, 0x0022ff7d, 0x00247f6c, - 0x0024df5b, 0x00267f4b, 0x0027df3b, 0x0029bf3b, - 0x002b5f2f, 0x002d3f2e, 0x002f5f2a, 0x002fff15, - 0x00315f0b, 0x0032defa, 0x0033beeb, 0x0034fed9, - 0x00353ec5, 0x00361eb0, 0x00363e9b, 0x0036be87, - 0x0036be70, 0x0038fe67, 0x0044beb2, 0x00513ef3, - 0x00595f11, 0x00669f3d, 0x0078dfdf, 0x00a143aa, - 0x01642fff, 0x0162afff, 0x01620fff, 0x0160cfff, - 0x015f0fff, 0x015dafff, 0x015bcfff, 0x015bcfff, - 0x015b4fff, 0x015acfff, 0x01590fff, 0x0156cfff, -}; - -static const u32 b43_httab_0x23[] = { - 0x00000000, 0x00000000, 0x00016023, 0x00006028, - 0x00034036, 0x0003402e, 0x0007203c, 0x0006e037, - 0x00070030, 0x0009401f, 0x0009a00f, 0x000b600d, - 0x000c8007, 0x000ce007, 0x00101fff, 0x00121ff9, - 0x0012e004, 0x0014dffc, 0x0016dff6, 0x0018dfe9, - 0x001b3fe5, 0x001c5fd0, 0x001ddfc2, 0x001f1fb6, - 0x00207fa4, 0x00219f8f, 0x0022ff7d, 0x00247f6c, - 0x0024df5b, 0x00267f4b, 0x0027df3b, 0x0029bf3b, - 0x002b5f2f, 0x002d3f2e, 0x002f5f2a, 0x002fff15, - 0x00315f0b, 0x0032defa, 0x0033beeb, 0x0034fed9, - 0x00353ec5, 0x00361eb0, 0x00363e9b, 0x0036be87, - 0x0036be70, 0x0038fe67, 0x0044beb2, 0x00513ef3, - 0x00595f11, 0x00669f3d, 0x0078dfdf, 0x00a143aa, - 0x01642fff, 0x0162afff, 0x01620fff, 0x0160cfff, - 0x015f0fff, 0x015dafff, 0x015bcfff, 0x015bcfff, - 0x015b4fff, 0x015acfff, 0x01590fff, 0x0156cfff, -}; - -static const u32 b43_httab_0x20[] = { - 0x0b5e002d, 0x0ae2002f, 0x0a3b0032, 0x09a70035, - 0x09220038, 0x08ab003b, 0x081f003f, 0x07a20043, - 0x07340047, 0x06d2004b, 0x067a004f, 0x06170054, - 0x05bf0059, 0x0571005e, 0x051e0064, 0x04d3006a, - 0x04910070, 0x044c0077, 0x040f007e, 0x03d90085, - 0x03a1008d, 0x036f0095, 0x033d009e, 0x030b00a8, - 0x02e000b2, 0x02b900bc, 0x029200c7, 0x026d00d3, - 0x024900e0, 0x022900ed, 0x020a00fb, 0x01ec010a, - 0x01d20119, 0x01b7012a, 0x019e013c, 0x0188014e, - 0x01720162, 0x015d0177, 0x0149018e, 0x013701a5, - 0x012601be, 0x011501d8, 0x010601f4, 0x00f70212, - 0x00e90231, 0x00dc0253, 0x00d00276, 0x00c4029b, - 0x00b902c3, 0x00af02ed, 0x00a50319, 0x009c0348, - 0x0093037a, 0x008b03af, 0x008303e6, 0x007c0422, - 0x00750460, 0x006e04a3, 0x006804e9, 0x00620533, - 0x005d0582, 0x005805d6, 0x0053062e, 0x004e068c, -}; - -static const u32 b43_httab_0x22[] = { - 0x0b5e002d, 0x0ae2002f, 0x0a3b0032, 0x09a70035, - 0x09220038, 0x08ab003b, 0x081f003f, 0x07a20043, - 0x07340047, 0x06d2004b, 0x067a004f, 0x06170054, - 0x05bf0059, 0x0571005e, 0x051e0064, 0x04d3006a, - 0x04910070, 0x044c0077, 0x040f007e, 0x03d90085, - 0x03a1008d, 0x036f0095, 0x033d009e, 0x030b00a8, - 0x02e000b2, 0x02b900bc, 0x029200c7, 0x026d00d3, - 0x024900e0, 0x022900ed, 0x020a00fb, 0x01ec010a, - 0x01d20119, 0x01b7012a, 0x019e013c, 0x0188014e, - 0x01720162, 0x015d0177, 0x0149018e, 0x013701a5, - 0x012601be, 0x011501d8, 0x010601f4, 0x00f70212, - 0x00e90231, 0x00dc0253, 0x00d00276, 0x00c4029b, - 0x00b902c3, 0x00af02ed, 0x00a50319, 0x009c0348, - 0x0093037a, 0x008b03af, 0x008303e6, 0x007c0422, - 0x00750460, 0x006e04a3, 0x006804e9, 0x00620533, - 0x005d0582, 0x005805d6, 0x0053062e, 0x004e068c, -}; - -static const u32 b43_httab_0x24[] = { - 0x0b5e002d, 0x0ae2002f, 0x0a3b0032, 0x09a70035, - 0x09220038, 0x08ab003b, 0x081f003f, 0x07a20043, - 0x07340047, 0x06d2004b, 0x067a004f, 0x06170054, - 0x05bf0059, 0x0571005e, 0x051e0064, 0x04d3006a, - 0x04910070, 0x044c0077, 0x040f007e, 0x03d90085, - 0x03a1008d, 0x036f0095, 0x033d009e, 0x030b00a8, - 0x02e000b2, 0x02b900bc, 0x029200c7, 0x026d00d3, - 0x024900e0, 0x022900ed, 0x020a00fb, 0x01ec010a, - 0x01d20119, 0x01b7012a, 0x019e013c, 0x0188014e, - 0x01720162, 0x015d0177, 0x0149018e, 0x013701a5, - 0x012601be, 0x011501d8, 0x010601f4, 0x00f70212, - 0x00e90231, 0x00dc0253, 0x00d00276, 0x00c4029b, - 0x00b902c3, 0x00af02ed, 0x00a50319, 0x009c0348, - 0x0093037a, 0x008b03af, 0x008303e6, 0x007c0422, - 0x00750460, 0x006e04a3, 0x006804e9, 0x00620533, - 0x005d0582, 0x005805d6, 0x0053062e, 0x004e068c, -}; - -/************************************************** - * R/W ops. - **************************************************/ - -u32 b43_httab_read(struct b43_wldev *dev, u32 offset) -{ - u32 type, value; - - type = offset & B43_HTTAB_TYPEMASK; - offset &= ~B43_HTTAB_TYPEMASK; - B43_WARN_ON(offset > 0xFFFF); - - switch (type) { - case B43_HTTAB_8BIT: - b43_phy_write(dev, B43_PHY_HT_TABLE_ADDR, offset); - value = b43_phy_read(dev, B43_PHY_HT_TABLE_DATALO) & 0xFF; - break; - case B43_HTTAB_16BIT: - b43_phy_write(dev, B43_PHY_HT_TABLE_ADDR, offset); - value = b43_phy_read(dev, B43_PHY_HT_TABLE_DATALO); - break; - case B43_HTTAB_32BIT: - b43_phy_write(dev, B43_PHY_HT_TABLE_ADDR, offset); - value = b43_phy_read(dev, B43_PHY_HT_TABLE_DATAHI); - value <<= 16; - value |= b43_phy_read(dev, B43_PHY_HT_TABLE_DATALO); - break; - default: - B43_WARN_ON(1); - value = 0; - } - - return value; -} - -void b43_httab_read_bulk(struct b43_wldev *dev, u32 offset, - unsigned int nr_elements, void *_data) -{ - u32 type; - u8 *data = _data; - unsigned int i; - - type = offset & B43_HTTAB_TYPEMASK; - offset &= ~B43_HTTAB_TYPEMASK; - B43_WARN_ON(offset > 0xFFFF); - - b43_phy_write(dev, B43_PHY_HT_TABLE_ADDR, offset); - - for (i = 0; i < nr_elements; i++) { - switch (type) { - case B43_HTTAB_8BIT: - *data = b43_phy_read(dev, B43_PHY_HT_TABLE_DATALO) & 0xFF; - data++; - break; - case B43_HTTAB_16BIT: - *((u16 *)data) = b43_phy_read(dev, B43_PHY_HT_TABLE_DATALO); - data += 2; - break; - case B43_HTTAB_32BIT: - *((u32 *)data) = b43_phy_read(dev, B43_PHY_HT_TABLE_DATAHI); - *((u32 *)data) <<= 16; - *((u32 *)data) |= b43_phy_read(dev, B43_PHY_HT_TABLE_DATALO); - data += 4; - break; - default: - B43_WARN_ON(1); - } - } -} - -void b43_httab_write(struct b43_wldev *dev, u32 offset, u32 value) -{ - u32 type; - - type = offset & B43_HTTAB_TYPEMASK; - offset &= 0xFFFF; - - switch (type) { - case B43_HTTAB_8BIT: - B43_WARN_ON(value & ~0xFF); - b43_phy_write(dev, B43_PHY_HT_TABLE_ADDR, offset); - b43_phy_write(dev, B43_PHY_HT_TABLE_DATALO, value); - break; - case B43_HTTAB_16BIT: - B43_WARN_ON(value & ~0xFFFF); - b43_phy_write(dev, B43_PHY_HT_TABLE_ADDR, offset); - b43_phy_write(dev, B43_PHY_HT_TABLE_DATALO, value); - break; - case B43_HTTAB_32BIT: - b43_phy_write(dev, B43_PHY_HT_TABLE_ADDR, offset); - b43_phy_write(dev, B43_PHY_HT_TABLE_DATAHI, value >> 16); - b43_phy_write(dev, B43_PHY_HT_TABLE_DATALO, value & 0xFFFF); - break; - default: - B43_WARN_ON(1); - } - - return; -} - -void b43_httab_write_bulk(struct b43_wldev *dev, u32 offset, - unsigned int nr_elements, const void *_data) -{ - u32 type, value; - const u8 *data = _data; - unsigned int i; - - type = offset & B43_HTTAB_TYPEMASK; - offset &= ~B43_HTTAB_TYPEMASK; - B43_WARN_ON(offset > 0xFFFF); - - b43_phy_write(dev, B43_PHY_HT_TABLE_ADDR, offset); - - for (i = 0; i < nr_elements; i++) { - switch (type) { - case B43_HTTAB_8BIT: - value = *data; - data++; - B43_WARN_ON(value & ~0xFF); - b43_phy_write(dev, B43_PHY_HT_TABLE_DATALO, value); - break; - case B43_HTTAB_16BIT: - value = *((u16 *)data); - data += 2; - B43_WARN_ON(value & ~0xFFFF); - b43_phy_write(dev, B43_PHY_HT_TABLE_DATALO, value); - break; - case B43_HTTAB_32BIT: - value = *((u32 *)data); - data += 4; - b43_phy_write(dev, B43_PHY_HT_TABLE_DATAHI, value >> 16); - b43_phy_write(dev, B43_PHY_HT_TABLE_DATALO, - value & 0xFFFF); - break; - default: - B43_WARN_ON(1); - } - } -} - -/************************************************** - * Tables ops. - **************************************************/ - -#define httab_upload(dev, offset, data) do { \ - b43_httab_write_bulk(dev, offset, ARRAY_SIZE(data), data); \ - } while (0) -void b43_phy_ht_tables_init(struct b43_wldev *dev) -{ - httab_upload(dev, B43_HTTAB16(0x12, 0), b43_httab_0x12); - httab_upload(dev, B43_HTTAB16(0x27, 0), b43_httab_0x27); - httab_upload(dev, B43_HTTAB16(0x26, 0), b43_httab_0x26); - httab_upload(dev, B43_HTTAB32(0x25, 0), b43_httab_0x25); - httab_upload(dev, B43_HTTAB32(0x2f, 0), b43_httab_0x2f); - httab_upload(dev, B43_HTTAB16(0x1a, 0), b43_httab_0x1a); - httab_upload(dev, B43_HTTAB16(0x1b, 0), b43_httab_0x1b); - httab_upload(dev, B43_HTTAB16(0x1c, 0), b43_httab_0x1c); - httab_upload(dev, B43_HTTAB32(0x1a, 0x0c0), b43_httab_0x1a_0xc0); - httab_upload(dev, B43_HTTAB32(0x1a, 0x140), b43_httab_0x1a_0x140); - httab_upload(dev, B43_HTTAB32(0x1b, 0x140), b43_httab_0x1b_0x140); - httab_upload(dev, B43_HTTAB32(0x1c, 0x140), b43_httab_0x1c_0x140); - httab_upload(dev, B43_HTTAB16(0x1a, 0x1c0), b43_httab_0x1a_0x1c0); - httab_upload(dev, B43_HTTAB16(0x1b, 0x1c0), b43_httab_0x1b_0x1c0); - httab_upload(dev, B43_HTTAB16(0x1c, 0x1c0), b43_httab_0x1c_0x1c0); - httab_upload(dev, B43_HTTAB16(0x1a, 0x240), b43_httab_0x1a_0x240); - httab_upload(dev, B43_HTTAB16(0x1b, 0x240), b43_httab_0x1b_0x240); - httab_upload(dev, B43_HTTAB16(0x1c, 0x240), b43_httab_0x1c_0x240); - httab_upload(dev, B43_HTTAB32(0x1f, 0), b43_httab_0x1f); - httab_upload(dev, B43_HTTAB32(0x21, 0), b43_httab_0x21); - httab_upload(dev, B43_HTTAB32(0x23, 0), b43_httab_0x23); - httab_upload(dev, B43_HTTAB32(0x20, 0), b43_httab_0x20); - httab_upload(dev, B43_HTTAB32(0x22, 0), b43_httab_0x22); - httab_upload(dev, B43_HTTAB32(0x24, 0), b43_httab_0x24); -} diff --git a/trunk/drivers/net/wireless/b43/tables_phy_ht.h b/trunk/drivers/net/wireless/b43/tables_phy_ht.h deleted file mode 100644 index ea3be382c894..000000000000 --- a/trunk/drivers/net/wireless/b43/tables_phy_ht.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef B43_TABLES_PHY_HT_H_ -#define B43_TABLES_PHY_HT_H_ - -/* The HT-PHY tables. */ -#define B43_HTTAB_TYPEMASK 0xF0000000 -#define B43_HTTAB_8BIT 0x10000000 -#define B43_HTTAB_16BIT 0x20000000 -#define B43_HTTAB_32BIT 0x30000000 -#define B43_HTTAB8(table, offset) (((table) << 10) | (offset) | B43_HTTAB_8BIT) -#define B43_HTTAB16(table, offset) (((table) << 10) | (offset) | B43_HTTAB_16BIT) -#define B43_HTTAB32(table, offset) (((table) << 10) | (offset) | B43_HTTAB_32BIT) - -u32 b43_httab_read(struct b43_wldev *dev, u32 offset); -void b43_httab_read_bulk(struct b43_wldev *dev, u32 offset, - unsigned int nr_elements, void *_data); -void b43_httab_write(struct b43_wldev *dev, u32 offset, u32 value); -void b43_httab_write_bulk(struct b43_wldev *dev, u32 offset, - unsigned int nr_elements, const void *_data); - -void b43_phy_ht_tables_init(struct b43_wldev *dev); - -#endif /* B43_TABLES_PHY_HT_H_ */ diff --git a/trunk/drivers/net/wireless/ipw2x00/ipw2100.c b/trunk/drivers/net/wireless/ipw2x00/ipw2100.c index 3774dd034746..44307753587d 100644 --- a/trunk/drivers/net/wireless/ipw2x00/ipw2100.c +++ b/trunk/drivers/net/wireless/ipw2x00/ipw2100.c @@ -287,7 +287,7 @@ static const char *command_types[] = { "unused", /* HOST_INTERRUPT_COALESCING */ "undefined", "CARD_DISABLE_PHY_OFF", - "MSDU_TX_RATES", + "MSDU_TX_RATES" "undefined", "undefined", "SET_STATION_STAT_BITS", "CLEAR_STATIONS_STAT_BITS", diff --git a/trunk/drivers/net/wireless/ipw2x00/libipw_rx.c b/trunk/drivers/net/wireless/ipw2x00/libipw_rx.c index 32a9966c3bf6..e5ad76cd77da 100644 --- a/trunk/drivers/net/wireless/ipw2x00/libipw_rx.c +++ b/trunk/drivers/net/wireless/ipw2x00/libipw_rx.c @@ -442,7 +442,7 @@ int libipw_rx(struct libipw_device *ieee, struct sk_buff *skb, * 802.11, but makes it easier to use different keys with * stations that do not support WEP key mapping). */ - if (is_unicast_ether_addr(hdr->addr1) || local->bcrx_sta_key) + if (!(hdr->addr1[0] & 0x01) || local->bcrx_sta_key) (void)hostap_handle_sta_crypto(local, hdr, &crypt, &sta); #endif @@ -772,7 +772,7 @@ int libipw_rx(struct libipw_device *ieee, struct sk_buff *skb, #ifdef NOT_YET if (ieee->iw_mode == IW_MODE_MASTER && !wds && ieee->ap->bridge_packets) { - if (is_multicast_ether_addr(dst)) { + if (dst[0] & 0x01) { /* copy multicast frame both to the higher layers and * to the wireless media */ ieee->ap->bridged_multicast++; diff --git a/trunk/drivers/net/wireless/iwlegacy/iwl-3945.c b/trunk/drivers/net/wireless/iwlegacy/iwl-3945.c index dab67a12d73b..d096dc28204d 100644 --- a/trunk/drivers/net/wireless/iwlegacy/iwl-3945.c +++ b/trunk/drivers/net/wireless/iwlegacy/iwl-3945.c @@ -408,6 +408,7 @@ void iwl3945_hw_rx_statistics(struct iwl_priv *priv, #ifdef CONFIG_IWLWIFI_LEGACY_DEBUGFS iwl3945_accumulative_statistics(priv, (__le32 *)&pkt->u.raw); #endif + iwl_legacy_recover_from_statistics(priv, pkt); memcpy(&priv->_3945.statistics, pkt->u.raw, sizeof(priv->_3945.statistics)); } @@ -2639,6 +2640,7 @@ static struct iwl_lib_ops iwl3945_lib = { .txq_free_tfd = iwl3945_hw_txq_free_tfd, .txq_init = iwl3945_hw_tx_queue_init, .load_ucode = iwl3945_load_bsm, + .dump_nic_event_log = iwl3945_dump_nic_event_log, .dump_nic_error_log = iwl3945_dump_nic_error_log, .apm_ops = { .init = iwl3945_apm_init, @@ -2696,7 +2698,9 @@ static struct iwl_base_params iwl3945_base_params = { .set_l0s = false, .use_bsm = true, .led_compensation = 64, + .plcp_delta_threshold = IWL_MAX_PLCP_ERR_LONG_THRESHOLD_DEF, .wd_timeout = IWL_DEF_WD_TIMEOUT, + .max_event_log_size = 512, }; static struct iwl_cfg iwl3945_bg_cfg = { diff --git a/trunk/drivers/net/wireless/iwlegacy/iwl-4965-lib.c b/trunk/drivers/net/wireless/iwlegacy/iwl-4965-lib.c index 2be6d9e3b019..a7a4739880dc 100644 --- a/trunk/drivers/net/wireless/iwlegacy/iwl-4965-lib.c +++ b/trunk/drivers/net/wireless/iwlegacy/iwl-4965-lib.c @@ -694,6 +694,47 @@ void iwl4965_rx_reply_rx_phy(struct iwl_priv *priv, sizeof(struct iwl_rx_phy_res)); } +static int iwl4965_get_single_channel_for_scan(struct iwl_priv *priv, + struct ieee80211_vif *vif, + enum ieee80211_band band, + struct iwl_scan_channel *scan_ch) +{ + const struct ieee80211_supported_band *sband; + u16 passive_dwell = 0; + u16 active_dwell = 0; + int added = 0; + u16 channel = 0; + + sband = iwl_get_hw_mode(priv, band); + if (!sband) { + IWL_ERR(priv, "invalid band\n"); + return added; + } + + active_dwell = iwl_legacy_get_active_dwell_time(priv, band, 0); + passive_dwell = iwl_legacy_get_passive_dwell_time(priv, band, vif); + + if (passive_dwell <= active_dwell) + passive_dwell = active_dwell + 1; + + channel = iwl_legacy_get_single_channel_number(priv, band); + if (channel) { + scan_ch->channel = cpu_to_le16(channel); + scan_ch->type = SCAN_CHANNEL_TYPE_PASSIVE; + scan_ch->active_dwell = cpu_to_le16(active_dwell); + scan_ch->passive_dwell = cpu_to_le16(passive_dwell); + /* Set txpower levels to defaults */ + scan_ch->dsp_atten = 110; + if (band == IEEE80211_BAND_5GHZ) + scan_ch->tx_gain = ((1 << 5) | (3 << 3)) | 3; + else + scan_ch->tx_gain = ((1 << 5) | (5 << 3)); + added++; + } else + IWL_ERR(priv, "no valid channel found\n"); + return added; +} + static int iwl4965_get_channels_for_scan(struct iwl_priv *priv, struct ieee80211_vif *vif, enum ieee80211_band band, @@ -817,13 +858,16 @@ int iwl4965_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif) scan->quiet_time = IWL_ACTIVE_QUIET_TIME; if (iwl_legacy_is_any_associated(priv)) { - u16 interval; + u16 interval = 0; u32 extra; u32 suspend_time = 100; u32 scan_suspend_time = 100; IWL_DEBUG_INFO(priv, "Scanning while associated...\n"); - interval = vif->bss_conf.beacon_int; + if (priv->is_internal_short_scan) + interval = 0; + else + interval = vif->bss_conf.beacon_int; scan->suspend_time = 0; scan->max_out_time = cpu_to_le32(200 * 1024); @@ -838,7 +882,9 @@ int iwl4965_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif) scan_suspend_time, interval); } - if (priv->scan_request->n_ssids) { + if (priv->is_internal_short_scan) { + IWL_DEBUG_SCAN(priv, "Start internal passive scan.\n"); + } else if (priv->scan_request->n_ssids) { int i, p = 0; IWL_DEBUG_SCAN(priv, "Kicking off active scan\n"); for (i = 0; i < priv->scan_request->n_ssids; i++) { @@ -935,21 +981,38 @@ int iwl4965_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif) rx_chain |= rx_ant << RXON_RX_CHAIN_FORCE_SEL_POS; rx_chain |= 0x1 << RXON_RX_CHAIN_DRIVER_FORCE_POS; scan->rx_chain = cpu_to_le16(rx_chain); - - cmd_len = iwl_legacy_fill_probe_req(priv, + if (!priv->is_internal_short_scan) { + cmd_len = iwl_legacy_fill_probe_req(priv, (struct ieee80211_mgmt *)scan->data, vif->addr, priv->scan_request->ie, priv->scan_request->ie_len, IWL_MAX_SCAN_SIZE - sizeof(*scan)); + } else { + /* use bcast addr, will not be transmitted but must be valid */ + cmd_len = iwl_legacy_fill_probe_req(priv, + (struct ieee80211_mgmt *)scan->data, + iwlegacy_bcast_addr, NULL, 0, + IWL_MAX_SCAN_SIZE - sizeof(*scan)); + + } scan->tx_cmd.len = cpu_to_le16(cmd_len); scan->filter_flags |= (RXON_FILTER_ACCEPT_GRP_MSK | RXON_FILTER_BCON_AWARE_MSK); - scan->channel_count = iwl4965_get_channels_for_scan(priv, vif, band, - is_active, n_probes, - (void *)&scan->data[cmd_len]); + if (priv->is_internal_short_scan) { + scan->channel_count = + iwl4965_get_single_channel_for_scan(priv, vif, band, + (void *)&scan->data[le16_to_cpu( + scan->tx_cmd.len)]); + } else { + scan->channel_count = + iwl4965_get_channels_for_scan(priv, vif, band, + is_active, n_probes, + (void *)&scan->data[le16_to_cpu( + scan->tx_cmd.len)]); + } if (scan->channel_count == 0) { IWL_DEBUG_SCAN(priv, "channel count %d\n", scan->channel_count); return -EIO; diff --git a/trunk/drivers/net/wireless/iwlegacy/iwl-4965-rx.c b/trunk/drivers/net/wireless/iwlegacy/iwl-4965-rx.c index 2b144bbfc3c5..b9fa2f6411a7 100644 --- a/trunk/drivers/net/wireless/iwlegacy/iwl-4965-rx.c +++ b/trunk/drivers/net/wireless/iwlegacy/iwl-4965-rx.c @@ -151,6 +151,81 @@ static void iwl4965_accumulative_statistics(struct iwl_priv *priv, #define REG_RECALIB_PERIOD (60) +/** + * iwl4965_good_plcp_health - checks for plcp error. + * + * When the plcp error is exceeding the thresholds, reset the radio + * to improve the throughput. + */ +bool iwl4965_good_plcp_health(struct iwl_priv *priv, + struct iwl_rx_packet *pkt) +{ + bool rc = true; + int combined_plcp_delta; + unsigned int plcp_msec; + unsigned long plcp_received_jiffies; + + if (priv->cfg->base_params->plcp_delta_threshold == + IWL_MAX_PLCP_ERR_THRESHOLD_DISABLE) { + IWL_DEBUG_RADIO(priv, "plcp_err check disabled\n"); + return rc; + } + + /* + * check for plcp_err and trigger radio reset if it exceeds + * the plcp error threshold plcp_delta. + */ + plcp_received_jiffies = jiffies; + plcp_msec = jiffies_to_msecs((long) plcp_received_jiffies - + (long) priv->plcp_jiffies); + priv->plcp_jiffies = plcp_received_jiffies; + /* + * check to make sure plcp_msec is not 0 to prevent division + * by zero. + */ + if (plcp_msec) { + struct statistics_rx_phy *ofdm; + struct statistics_rx_ht_phy *ofdm_ht; + + ofdm = &pkt->u.stats.rx.ofdm; + ofdm_ht = &pkt->u.stats.rx.ofdm_ht; + combined_plcp_delta = + (le32_to_cpu(ofdm->plcp_err) - + le32_to_cpu(priv->_4965.statistics. + rx.ofdm.plcp_err)) + + (le32_to_cpu(ofdm_ht->plcp_err) - + le32_to_cpu(priv->_4965.statistics. + rx.ofdm_ht.plcp_err)); + + if ((combined_plcp_delta > 0) && + ((combined_plcp_delta * 100) / plcp_msec) > + priv->cfg->base_params->plcp_delta_threshold) { + /* + * if plcp_err exceed the threshold, + * the following data is printed in csv format: + * Text: plcp_err exceeded %d, + * Received ofdm.plcp_err, + * Current ofdm.plcp_err, + * Received ofdm_ht.plcp_err, + * Current ofdm_ht.plcp_err, + * combined_plcp_delta, + * plcp_msec + */ + IWL_DEBUG_RADIO(priv, "plcp_err exceeded %u, " + "%u, %u, %u, %u, %d, %u mSecs\n", + priv->cfg->base_params->plcp_delta_threshold, + le32_to_cpu(ofdm->plcp_err), + le32_to_cpu(ofdm->plcp_err), + le32_to_cpu(ofdm_ht->plcp_err), + le32_to_cpu(ofdm_ht->plcp_err), + combined_plcp_delta, plcp_msec); + + rc = false; + } + } + return rc; +} + void iwl4965_rx_statistics(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb) { @@ -173,7 +248,8 @@ void iwl4965_rx_statistics(struct iwl_priv *priv, iwl4965_accumulative_statistics(priv, (__le32 *)&pkt->u.stats); #endif - /* TODO: reading some of statistics is unneeded */ + iwl_legacy_recover_from_statistics(priv, pkt); + memcpy(&priv->_4965.statistics, &pkt->u.stats, sizeof(priv->_4965.statistics)); diff --git a/trunk/drivers/net/wireless/iwlegacy/iwl-4965.c b/trunk/drivers/net/wireless/iwlegacy/iwl-4965.c index bd4b000733f7..9cf96cb51712 100644 --- a/trunk/drivers/net/wireless/iwlegacy/iwl-4965.c +++ b/trunk/drivers/net/wireless/iwlegacy/iwl-4965.c @@ -2069,6 +2069,7 @@ static struct iwl_lib_ops iwl4965_lib = { .is_valid_rtc_data_addr = iwl4965_hw_valid_rtc_data_addr, .init_alive_start = iwl4965_init_alive_start, .load_ucode = iwl4965_load_bsm, + .dump_nic_event_log = iwl4965_dump_nic_event_log, .dump_nic_error_log = iwl4965_dump_nic_error_log, .dump_fh = iwl4965_dump_fh, .set_channel_switch = iwl4965_hw_channel_switch, @@ -2099,6 +2100,7 @@ static struct iwl_lib_ops iwl4965_lib = { .tx_stats_read = iwl4965_ucode_tx_stats_read, .general_stats_read = iwl4965_ucode_general_stats_read, }, + .check_plcp_health = iwl4965_good_plcp_health, }; static const struct iwl_legacy_ops iwl4965_legacy_ops = { @@ -2148,8 +2150,10 @@ static struct iwl_base_params iwl4965_base_params = { .use_bsm = true, .led_compensation = 61, .chain_noise_num_beacons = IWL4965_CAL_NUM_BEACONS, + .plcp_delta_threshold = IWL_MAX_PLCP_ERR_THRESHOLD_DEF, .wd_timeout = IWL_DEF_WD_TIMEOUT, .temperature_kelvin = true, + .max_event_log_size = 512, .ucode_tracing = true, .sensitivity_calib_by_driver = true, .chain_noise_calib_by_driver = true, diff --git a/trunk/drivers/net/wireless/iwlegacy/iwl-commands.h b/trunk/drivers/net/wireless/iwlegacy/iwl-commands.h index ee21210bea9c..17a1d504348e 100644 --- a/trunk/drivers/net/wireless/iwlegacy/iwl-commands.h +++ b/trunk/drivers/net/wireless/iwlegacy/iwl-commands.h @@ -2297,7 +2297,14 @@ struct iwl_spectrum_notification { #define IWL_POWER_VEC_SIZE 5 #define IWL_POWER_DRIVER_ALLOW_SLEEP_MSK cpu_to_le16(BIT(0)) +#define IWL_POWER_POWER_SAVE_ENA_MSK cpu_to_le16(BIT(0)) +#define IWL_POWER_POWER_MANAGEMENT_ENA_MSK cpu_to_le16(BIT(1)) +#define IWL_POWER_SLEEP_OVER_DTIM_MSK cpu_to_le16(BIT(2)) #define IWL_POWER_PCI_PM_MSK cpu_to_le16(BIT(3)) +#define IWL_POWER_FAST_PD cpu_to_le16(BIT(4)) +#define IWL_POWER_BEACON_FILTERING cpu_to_le16(BIT(5)) +#define IWL_POWER_SHADOW_REG_ENA cpu_to_le16(BIT(6)) +#define IWL_POWER_CT_KILL_SET cpu_to_le16(BIT(7)) struct iwl3945_powertable_cmd { __le16 flags; diff --git a/trunk/drivers/net/wireless/iwlegacy/iwl-core.c b/trunk/drivers/net/wireless/iwlegacy/iwl-core.c index 35cd2537e7fd..3be76bd5499a 100644 --- a/trunk/drivers/net/wireless/iwlegacy/iwl-core.c +++ b/trunk/drivers/net/wireless/iwlegacy/iwl-core.c @@ -931,6 +931,7 @@ void iwl_legacy_irq_handle_error(struct iwl_priv *priv) priv->cfg->ops->lib->dump_nic_error_log(priv); if (priv->cfg->ops->lib->dump_fh) priv->cfg->ops->lib->dump_fh(priv, NULL, false); + priv->cfg->ops->lib->dump_nic_event_log(priv, false, NULL, false); #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG if (iwl_legacy_get_debug_level(priv) & IWL_DL_FW_ERRORS) iwl_legacy_print_rx_config_cmd(priv, @@ -1706,14 +1707,41 @@ iwl_legacy_update_stats(struct iwl_priv *priv, bool is_tx, __le16 fc, u16 len) EXPORT_SYMBOL(iwl_legacy_update_stats); #endif -int iwl_legacy_force_reset(struct iwl_priv *priv, bool external) +static void _iwl_legacy_force_rf_reset(struct iwl_priv *priv) +{ + if (test_bit(STATUS_EXIT_PENDING, &priv->status)) + return; + + if (!iwl_legacy_is_any_associated(priv)) { + IWL_DEBUG_SCAN(priv, "force reset rejected: not associated\n"); + return; + } + /* + * There is no easy and better way to force reset the radio, + * the only known method is switching channel which will force to + * reset and tune the radio. + * Use internal short scan (single channel) operation to should + * achieve this objective. + * Driver should reset the radio when number of consecutive missed + * beacon, or any other uCode error condition detected. + */ + IWL_DEBUG_INFO(priv, "perform radio reset.\n"); + iwl_legacy_internal_short_hw_scan(priv); +} + + +int iwl_legacy_force_reset(struct iwl_priv *priv, int mode, bool external) { struct iwl_force_reset *force_reset; if (test_bit(STATUS_EXIT_PENDING, &priv->status)) return -EINVAL; - force_reset = &priv->force_reset; + if (mode >= IWL_MAX_FORCE_RESET) { + IWL_DEBUG_INFO(priv, "invalid reset request.\n"); + return -EINVAL; + } + force_reset = &priv->force_reset[mode]; force_reset->reset_request_count++; if (!external) { if (force_reset->last_force_reset_jiffies && @@ -1726,34 +1754,37 @@ int iwl_legacy_force_reset(struct iwl_priv *priv, bool external) } force_reset->reset_success_count++; force_reset->last_force_reset_jiffies = jiffies; - - /* - * if the request is from external(ex: debugfs), - * then always perform the request in regardless the module - * parameter setting - * if the request is from internal (uCode error or driver - * detect failure), then fw_restart module parameter - * need to be check before performing firmware reload - */ - - if (!external && !priv->cfg->mod_params->restart_fw) { - IWL_DEBUG_INFO(priv, "Cancel firmware reload based on " - "module parameter setting\n"); - return 0; + IWL_DEBUG_INFO(priv, "perform force reset (%d)\n", mode); + switch (mode) { + case IWL_RF_RESET: + _iwl_legacy_force_rf_reset(priv); + break; + case IWL_FW_RESET: + /* + * if the request is from external(ex: debugfs), + * then always perform the request in regardless the module + * parameter setting + * if the request is from internal (uCode error or driver + * detect failure), then fw_restart module parameter + * need to be check before performing firmware reload + */ + if (!external && !priv->cfg->mod_params->restart_fw) { + IWL_DEBUG_INFO(priv, "Cancel firmware reload based on " + "module parameter setting\n"); + break; + } + IWL_ERR(priv, "On demand firmware reload\n"); + /* Set the FW error flag -- cleared on iwl_down */ + set_bit(STATUS_FW_ERROR, &priv->status); + wake_up_interruptible(&priv->wait_command_queue); + /* + * Keep the restart process from trying to send host + * commands by clearing the INIT status bit + */ + clear_bit(STATUS_READY, &priv->status); + queue_work(priv->workqueue, &priv->restart); + break; } - - IWL_ERR(priv, "On demand firmware reload\n"); - - /* Set the FW error flag -- cleared on iwl_down */ - set_bit(STATUS_FW_ERROR, &priv->status); - wake_up_interruptible(&priv->wait_command_queue); - /* - * Keep the restart process from trying to send host - * commands by clearing the INIT status bit - */ - clear_bit(STATUS_READY, &priv->status); - queue_work(priv->workqueue, &priv->restart); - return 0; } @@ -1848,7 +1879,7 @@ static int iwl_legacy_check_stuck_queue(struct iwl_priv *priv, int cnt) if (time_after(jiffies, timeout)) { IWL_ERR(priv, "Queue %d stuck for %u ms.\n", q->id, priv->cfg->base_params->wd_timeout); - ret = iwl_legacy_force_reset(priv, false); + ret = iwl_legacy_force_reset(priv, IWL_FW_RESET, false); return (ret == -EAGAIN) ? 0 : 1; } diff --git a/trunk/drivers/net/wireless/iwlegacy/iwl-core.h b/trunk/drivers/net/wireless/iwlegacy/iwl-core.h index 84da79376ef8..c5fbda0760de 100644 --- a/trunk/drivers/net/wireless/iwlegacy/iwl-core.h +++ b/trunk/drivers/net/wireless/iwlegacy/iwl-core.h @@ -143,7 +143,8 @@ struct iwl_lib_ops { int (*is_valid_rtc_data_addr)(u32 addr); /* 1st ucode load */ int (*load_ucode)(struct iwl_priv *priv); - + int (*dump_nic_event_log)(struct iwl_priv *priv, + bool full_log, char **buf, bool display); void (*dump_nic_error_log)(struct iwl_priv *priv); int (*dump_fh)(struct iwl_priv *priv, char **buf, bool display); int (*set_channel_switch)(struct iwl_priv *priv, @@ -160,6 +161,9 @@ struct iwl_lib_ops { /* temperature */ struct iwl_temp_ops temp_ops; + /* check for plcp health */ + bool (*check_plcp_health)(struct iwl_priv *priv, + struct iwl_rx_packet *pkt); struct iwl_debugfs_ops debugfs_ops; @@ -203,8 +207,11 @@ struct iwl_mod_params { * to the deviation to achieve the desired led frequency. * The detail algorithm is described in iwl-led.c * @chain_noise_num_beacons: number of beacons used to compute chain noise + * @plcp_delta_threshold: plcp error rate threshold used to trigger + * radio tuning when there is a high receiving plcp error rate * @wd_timeout: TX queues watchdog timeout * @temperature_kelvin: temperature report by uCode in kelvin + * @max_event_log_size: size of event log buffer size for ucode event logging * @ucode_tracing: support ucode continuous tracing * @sensitivity_calib_by_driver: driver has the capability to perform * sensitivity calibration operation @@ -222,8 +229,10 @@ struct iwl_base_params { u16 led_compensation; int chain_noise_num_beacons; + u8 plcp_delta_threshold; unsigned int wd_timeout; bool temperature_kelvin; + u32 max_event_log_size; const bool ucode_tracing; const bool sensitivity_calib_by_driver; const bool chain_noise_calib_by_driver; @@ -432,7 +441,7 @@ int iwl_legacy_mac_hw_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct cfg80211_scan_request *req); void iwl_legacy_internal_short_hw_scan(struct iwl_priv *priv); -int iwl_legacy_force_reset(struct iwl_priv *priv, bool external); +int iwl_legacy_force_reset(struct iwl_priv *priv, int mode, bool external); u16 iwl_legacy_fill_probe_req(struct iwl_priv *priv, struct ieee80211_mgmt *frame, const u8 *ta, const u8 *ie, int ie_len, int left); @@ -484,7 +493,7 @@ static inline u16 iwl_legacy_pcie_link_ctl(struct iwl_priv *priv) { int pos; u16 pci_lnk_ctl; - pos = pci_pcie_cap(priv->pci_dev); + pos = pci_find_capability(priv->pci_dev, PCI_CAP_ID_EXP); pci_read_config_word(priv->pci_dev, pos + PCI_EXP_LNKCTL, &pci_lnk_ctl); return pci_lnk_ctl; } @@ -512,6 +521,8 @@ extern const struct dev_pm_ops iwl_legacy_pm_ops; * Error Handling Debugging ******************************************************/ void iwl4965_dump_nic_error_log(struct iwl_priv *priv); +int iwl4965_dump_nic_event_log(struct iwl_priv *priv, + bool full_log, char **buf, bool display); #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG void iwl_legacy_print_rx_config_cmd(struct iwl_priv *priv, struct iwl_rxon_context *ctx); diff --git a/trunk/drivers/net/wireless/iwlegacy/iwl-debugfs.c b/trunk/drivers/net/wireless/iwlegacy/iwl-debugfs.c index 996996a71657..2d32438b4cb8 100644 --- a/trunk/drivers/net/wireless/iwlegacy/iwl-debugfs.c +++ b/trunk/drivers/net/wireless/iwlegacy/iwl-debugfs.c @@ -391,6 +391,48 @@ static ssize_t iwl_legacy_dbgfs_nvm_read(struct file *file, return ret; } +static ssize_t iwl_legacy_dbgfs_log_event_read(struct file *file, + char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct iwl_priv *priv = file->private_data; + char *buf; + int pos = 0; + ssize_t ret = -ENOMEM; + + ret = pos = priv->cfg->ops->lib->dump_nic_event_log( + priv, true, &buf, true); + if (buf) { + ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); + kfree(buf); + } + return ret; +} + +static ssize_t iwl_legacy_dbgfs_log_event_write(struct file *file, + const char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct iwl_priv *priv = file->private_data; + u32 event_log_flag; + char buf[8]; + int buf_size; + + memset(buf, 0, sizeof(buf)); + buf_size = min(count, sizeof(buf) - 1); + if (copy_from_user(buf, user_buf, buf_size)) + return -EFAULT; + if (sscanf(buf, "%d", &event_log_flag) != 1) + return -EFAULT; + if (event_log_flag == 1) + priv->cfg->ops->lib->dump_nic_event_log(priv, true, + NULL, false); + + return count; +} + + + static ssize_t iwl_legacy_dbgfs_channels_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) @@ -664,6 +706,7 @@ static ssize_t iwl_legacy_dbgfs_disable_ht40_read(struct file *file, } DEBUGFS_READ_WRITE_FILE_OPS(sram); +DEBUGFS_READ_WRITE_FILE_OPS(log_event); DEBUGFS_READ_FILE_OPS(nvm); DEBUGFS_READ_FILE_OPS(stations); DEBUGFS_READ_FILE_OPS(channels); @@ -1055,6 +1098,56 @@ static ssize_t iwl_legacy_dbgfs_clear_ucode_statistics_write(struct file *file, return count; } +static ssize_t iwl_legacy_dbgfs_ucode_tracing_read(struct file *file, + char __user *user_buf, + size_t count, loff_t *ppos) { + + struct iwl_priv *priv = file->private_data; + int pos = 0; + char buf[128]; + const size_t bufsz = sizeof(buf); + + pos += scnprintf(buf + pos, bufsz - pos, "ucode trace timer is %s\n", + priv->event_log.ucode_trace ? "On" : "Off"); + pos += scnprintf(buf + pos, bufsz - pos, "non_wraps_count:\t\t %u\n", + priv->event_log.non_wraps_count); + pos += scnprintf(buf + pos, bufsz - pos, "wraps_once_count:\t\t %u\n", + priv->event_log.wraps_once_count); + pos += scnprintf(buf + pos, bufsz - pos, "wraps_more_count:\t\t %u\n", + priv->event_log.wraps_more_count); + + return simple_read_from_buffer(user_buf, count, ppos, buf, pos); +} + +static ssize_t iwl_legacy_dbgfs_ucode_tracing_write(struct file *file, + const char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct iwl_priv *priv = file->private_data; + char buf[8]; + int buf_size; + int trace; + + memset(buf, 0, sizeof(buf)); + buf_size = min(count, sizeof(buf) - 1); + if (copy_from_user(buf, user_buf, buf_size)) + return -EFAULT; + if (sscanf(buf, "%d", &trace) != 1) + return -EFAULT; + + if (trace) { + priv->event_log.ucode_trace = true; + /* schedule the ucode timer to occur in UCODE_TRACE_PERIOD */ + mod_timer(&priv->ucode_trace, + jiffies + msecs_to_jiffies(UCODE_TRACE_PERIOD)); + } else { + priv->event_log.ucode_trace = false; + del_timer_sync(&priv->ucode_trace); + } + + return count; +} + static ssize_t iwl_legacy_dbgfs_rxon_flags_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { @@ -1143,31 +1236,72 @@ static ssize_t iwl_legacy_dbgfs_missed_beacon_write(struct file *file, return count; } -static ssize_t iwl_legacy_dbgfs_force_reset_read(struct file *file, +static ssize_t iwl_legacy_dbgfs_plcp_delta_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { struct iwl_priv *priv = file->private_data; int pos = 0; - char buf[300]; + char buf[12]; const size_t bufsz = sizeof(buf); - struct iwl_force_reset *force_reset; - force_reset = &priv->force_reset; + pos += scnprintf(buf + pos, bufsz - pos, "%u\n", + priv->cfg->base_params->plcp_delta_threshold); - pos += scnprintf(buf + pos, bufsz - pos, - "\tnumber of reset request: %d\n", - force_reset->reset_request_count); - pos += scnprintf(buf + pos, bufsz - pos, - "\tnumber of reset request success: %d\n", - force_reset->reset_success_count); - pos += scnprintf(buf + pos, bufsz - pos, - "\tnumber of reset request reject: %d\n", - force_reset->reset_reject_count); - pos += scnprintf(buf + pos, bufsz - pos, - "\treset duration: %lu\n", - force_reset->reset_duration); + return simple_read_from_buffer(user_buf, count, ppos, buf, pos); +} + +static ssize_t iwl_legacy_dbgfs_plcp_delta_write(struct file *file, + const char __user *user_buf, + size_t count, loff_t *ppos) { + struct iwl_priv *priv = file->private_data; + char buf[8]; + int buf_size; + int plcp; + + memset(buf, 0, sizeof(buf)); + buf_size = min(count, sizeof(buf) - 1); + if (copy_from_user(buf, user_buf, buf_size)) + return -EFAULT; + if (sscanf(buf, "%d", &plcp) != 1) + return -EINVAL; + if ((plcp < IWL_MAX_PLCP_ERR_THRESHOLD_MIN) || + (plcp > IWL_MAX_PLCP_ERR_THRESHOLD_MAX)) + priv->cfg->base_params->plcp_delta_threshold = + IWL_MAX_PLCP_ERR_THRESHOLD_DISABLE; + else + priv->cfg->base_params->plcp_delta_threshold = plcp; + return count; +} + +static ssize_t iwl_legacy_dbgfs_force_reset_read(struct file *file, + char __user *user_buf, + size_t count, loff_t *ppos) { + + struct iwl_priv *priv = file->private_data; + int i, pos = 0; + char buf[300]; + const size_t bufsz = sizeof(buf); + struct iwl_force_reset *force_reset; + + for (i = 0; i < IWL_MAX_FORCE_RESET; i++) { + force_reset = &priv->force_reset[i]; + pos += scnprintf(buf + pos, bufsz - pos, + "Force reset method %d\n", i); + pos += scnprintf(buf + pos, bufsz - pos, + "\tnumber of reset request: %d\n", + force_reset->reset_request_count); + pos += scnprintf(buf + pos, bufsz - pos, + "\tnumber of reset request success: %d\n", + force_reset->reset_success_count); + pos += scnprintf(buf + pos, bufsz - pos, + "\tnumber of reset request reject: %d\n", + force_reset->reset_reject_count); + pos += scnprintf(buf + pos, bufsz - pos, + "\treset duration: %lu\n", + force_reset->reset_duration); + } return simple_read_from_buffer(user_buf, count, ppos, buf, pos); } @@ -1175,11 +1309,25 @@ static ssize_t iwl_legacy_dbgfs_force_reset_write(struct file *file, const char __user *user_buf, size_t count, loff_t *ppos) { - int ret; struct iwl_priv *priv = file->private_data; + char buf[8]; + int buf_size; + int reset, ret; - ret = iwl_legacy_force_reset(priv, true); - + memset(buf, 0, sizeof(buf)); + buf_size = min(count, sizeof(buf) - 1); + if (copy_from_user(buf, user_buf, buf_size)) + return -EFAULT; + if (sscanf(buf, "%d", &reset) != 1) + return -EINVAL; + switch (reset) { + case IWL_RF_RESET: + case IWL_FW_RESET: + ret = iwl_legacy_force_reset(priv, reset, true); + break; + default: + return -EINVAL; + } return ret ? ret : count; } @@ -1219,8 +1367,10 @@ DEBUGFS_READ_FILE_OPS(chain_noise); DEBUGFS_READ_FILE_OPS(power_save_status); DEBUGFS_WRITE_FILE_OPS(clear_ucode_statistics); DEBUGFS_WRITE_FILE_OPS(clear_traffic_statistics); +DEBUGFS_READ_WRITE_FILE_OPS(ucode_tracing); DEBUGFS_READ_FILE_OPS(fh_reg); DEBUGFS_READ_WRITE_FILE_OPS(missed_beacon); +DEBUGFS_READ_WRITE_FILE_OPS(plcp_delta); DEBUGFS_READ_WRITE_FILE_OPS(force_reset); DEBUGFS_READ_FILE_OPS(rxon_flags); DEBUGFS_READ_FILE_OPS(rxon_filter_flags); @@ -1253,6 +1403,7 @@ int iwl_legacy_dbgfs_register(struct iwl_priv *priv, const char *name) DEBUGFS_ADD_FILE(nvm, dir_data, S_IRUSR); DEBUGFS_ADD_FILE(sram, dir_data, S_IWUSR | S_IRUSR); + DEBUGFS_ADD_FILE(log_event, dir_data, S_IWUSR | S_IRUSR); DEBUGFS_ADD_FILE(stations, dir_data, S_IRUSR); DEBUGFS_ADD_FILE(channels, dir_data, S_IRUSR); DEBUGFS_ADD_FILE(status, dir_data, S_IRUSR); @@ -1269,6 +1420,7 @@ int iwl_legacy_dbgfs_register(struct iwl_priv *priv, const char *name) DEBUGFS_ADD_FILE(clear_traffic_statistics, dir_debug, S_IWUSR); DEBUGFS_ADD_FILE(fh_reg, dir_debug, S_IRUSR); DEBUGFS_ADD_FILE(missed_beacon, dir_debug, S_IWUSR); + DEBUGFS_ADD_FILE(plcp_delta, dir_debug, S_IWUSR | S_IRUSR); DEBUGFS_ADD_FILE(force_reset, dir_debug, S_IWUSR | S_IRUSR); DEBUGFS_ADD_FILE(ucode_rx_stats, dir_debug, S_IRUSR); DEBUGFS_ADD_FILE(ucode_tx_stats, dir_debug, S_IRUSR); @@ -1278,6 +1430,8 @@ int iwl_legacy_dbgfs_register(struct iwl_priv *priv, const char *name) DEBUGFS_ADD_FILE(sensitivity, dir_debug, S_IRUSR); if (priv->cfg->base_params->chain_noise_calib_by_driver) DEBUGFS_ADD_FILE(chain_noise, dir_debug, S_IRUSR); + if (priv->cfg->base_params->ucode_tracing) + DEBUGFS_ADD_FILE(ucode_tracing, dir_debug, S_IWUSR | S_IRUSR); DEBUGFS_ADD_FILE(rxon_flags, dir_debug, S_IWUSR); DEBUGFS_ADD_FILE(rxon_filter_flags, dir_debug, S_IWUSR); DEBUGFS_ADD_FILE(wd_timeout, dir_debug, S_IWUSR); diff --git a/trunk/drivers/net/wireless/iwlegacy/iwl-dev.h b/trunk/drivers/net/wireless/iwlegacy/iwl-dev.h index 9c786edf56fd..0a8d07fdc0e7 100644 --- a/trunk/drivers/net/wireless/iwlegacy/iwl-dev.h +++ b/trunk/drivers/net/wireless/iwlegacy/iwl-dev.h @@ -855,6 +855,32 @@ struct traffic_stats { #endif }; +/* + * schedule the timer to wake up every UCODE_TRACE_PERIOD milliseconds + * to perform continuous uCode event logging operation if enabled + */ +#define UCODE_TRACE_PERIOD (100) + +/* + * iwl_event_log: current uCode event log position + * + * @ucode_trace: enable/disable ucode continuous trace timer + * @num_wraps: how many times the event buffer wraps + * @next_entry: the entry just before the next one that uCode would fill + * @non_wraps_count: counter for no wrap detected when dump ucode events + * @wraps_once_count: counter for wrap once detected when dump ucode events + * @wraps_more_count: counter for wrap more than once detected + * when dump ucode events + */ +struct iwl_event_log { + bool ucode_trace; + u32 num_wraps; + u32 next_entry; + int non_wraps_count; + int wraps_once_count; + int wraps_more_count; +}; + /* * host interrupt timeout value * used with setting interrupt coalescing timer @@ -870,6 +896,18 @@ struct traffic_stats { #define IWL_HOST_INT_CALIB_TIMEOUT_DEF (0x10) #define IWL_HOST_INT_CALIB_TIMEOUT_MIN (0x0) +/* + * This is the threshold value of plcp error rate per 100mSecs. It is + * used to set and check for the validity of plcp_delta. + */ +#define IWL_MAX_PLCP_ERR_THRESHOLD_MIN (1) +#define IWL_MAX_PLCP_ERR_THRESHOLD_DEF (50) +#define IWL_MAX_PLCP_ERR_LONG_THRESHOLD_DEF (100) +#define IWL_MAX_PLCP_ERR_EXT_LONG_THRESHOLD_DEF (200) +#define IWL_MAX_PLCP_ERR_THRESHOLD_MAX (255) +#define IWL_MAX_PLCP_ERR_THRESHOLD_DISABLE (0) + +#define IWL_DELAY_NEXT_FORCE_RF_RESET (HZ*3) #define IWL_DELAY_NEXT_FORCE_FW_RELOAD (HZ*5) /* TX queue watchdog timeouts in mSecs */ @@ -877,6 +915,12 @@ struct traffic_stats { #define IWL_LONG_WD_TIMEOUT (10000) #define IWL_MAX_WD_TIMEOUT (120000) +enum iwl_reset { + IWL_RF_RESET = 0, + IWL_FW_RESET, + IWL_MAX_FORCE_RESET, +}; + struct iwl_force_reset { int reset_request_count; int reset_success_count; @@ -989,8 +1033,11 @@ struct iwl_priv { /* track IBSS manager (last beacon) status */ u32 ibss_manager; + /* storing the jiffies when the plcp error rate is received */ + unsigned long plcp_jiffies; + /* force reset */ - struct iwl_force_reset force_reset; + struct iwl_force_reset force_reset[IWL_MAX_FORCE_RESET]; /* we allocate array of iwl_channel_info for NIC's valid channels. * Access via channel # using indirect index array */ @@ -1011,6 +1058,7 @@ struct iwl_priv { enum ieee80211_band scan_band; struct cfg80211_scan_request *scan_request; struct ieee80211_vif *scan_vif; + bool is_internal_short_scan; u8 scan_tx_ant[IEEE80211_NUM_BANDS]; u8 mgmt_tx_ant; @@ -1165,6 +1213,12 @@ struct iwl_priv { #endif #if defined(CONFIG_IWL4965) || defined(CONFIG_IWL4965_MODULE) struct { + /* + * reporting the number of tids has AGG on. 0 means + * no AGGREGATION + */ + u8 agg_tids_count; + struct iwl_rx_phy_res last_phy_res; bool last_phy_res_valid; @@ -1203,6 +1257,7 @@ struct iwl_priv { struct iwl_rxon_context *beacon_ctx; struct sk_buff *beacon_skb; + struct work_struct start_internal_scan; struct work_struct tx_flush; struct tasklet_struct irq_tasklet; @@ -1239,9 +1294,12 @@ struct iwl_priv { u32 disable_tx_power_cal; struct work_struct run_time_calib_work; struct timer_list statistics_periodic; + struct timer_list ucode_trace; struct timer_list watchdog; bool hw_ready; + struct iwl_event_log event_log; + struct led_classdev led; unsigned long blink_on, blink_off; bool led_registered; diff --git a/trunk/drivers/net/wireless/iwlegacy/iwl-devtrace.c b/trunk/drivers/net/wireless/iwlegacy/iwl-devtrace.c index acec99197ce0..080b852b33bd 100644 --- a/trunk/drivers/net/wireless/iwlegacy/iwl-devtrace.c +++ b/trunk/drivers/net/wireless/iwlegacy/iwl-devtrace.c @@ -38,5 +38,8 @@ EXPORT_TRACEPOINT_SYMBOL(iwlwifi_legacy_dev_ioread32); EXPORT_TRACEPOINT_SYMBOL(iwlwifi_legacy_dev_iowrite32); EXPORT_TRACEPOINT_SYMBOL(iwlwifi_legacy_dev_rx); EXPORT_TRACEPOINT_SYMBOL(iwlwifi_legacy_dev_tx); +EXPORT_TRACEPOINT_SYMBOL(iwlwifi_legacy_dev_ucode_event); EXPORT_TRACEPOINT_SYMBOL(iwlwifi_legacy_dev_ucode_error); +EXPORT_TRACEPOINT_SYMBOL(iwlwifi_legacy_dev_ucode_cont_event); +EXPORT_TRACEPOINT_SYMBOL(iwlwifi_legacy_dev_ucode_wrap_event); #endif diff --git a/trunk/drivers/net/wireless/iwlegacy/iwl-devtrace.h b/trunk/drivers/net/wireless/iwlegacy/iwl-devtrace.h index a443725ba6be..9612aa0f6ec4 100644 --- a/trunk/drivers/net/wireless/iwlegacy/iwl-devtrace.h +++ b/trunk/drivers/net/wireless/iwlegacy/iwl-devtrace.h @@ -96,6 +96,47 @@ TRACE_EVENT(iwlwifi_legacy_dev_iowrite32, #undef TRACE_SYSTEM #define TRACE_SYSTEM iwlwifi_legacy_ucode +TRACE_EVENT(iwlwifi_legacy_dev_ucode_cont_event, + TP_PROTO(struct iwl_priv *priv, u32 time, u32 data, u32 ev), + TP_ARGS(priv, time, data, ev), + TP_STRUCT__entry( + PRIV_ENTRY + + __field(u32, time) + __field(u32, data) + __field(u32, ev) + ), + TP_fast_assign( + PRIV_ASSIGN; + __entry->time = time; + __entry->data = data; + __entry->ev = ev; + ), + TP_printk("[%p] EVT_LOGT:%010u:0x%08x:%04u", + __entry->priv, __entry->time, __entry->data, __entry->ev) +); + +TRACE_EVENT(iwlwifi_legacy_dev_ucode_wrap_event, + TP_PROTO(struct iwl_priv *priv, u32 wraps, u32 n_entry, u32 p_entry), + TP_ARGS(priv, wraps, n_entry, p_entry), + TP_STRUCT__entry( + PRIV_ENTRY + + __field(u32, wraps) + __field(u32, n_entry) + __field(u32, p_entry) + ), + TP_fast_assign( + PRIV_ASSIGN; + __entry->wraps = wraps; + __entry->n_entry = n_entry; + __entry->p_entry = p_entry; + ), + TP_printk("[%p] wraps=#%02d n=0x%X p=0x%X", + __entry->priv, __entry->wraps, __entry->n_entry, + __entry->p_entry) +); + #undef TRACE_SYSTEM #define TRACE_SYSTEM iwlwifi @@ -201,6 +242,25 @@ TRACE_EVENT(iwlwifi_legacy_dev_ucode_error, __entry->blink2, __entry->ilink1, __entry->ilink2) ); +TRACE_EVENT(iwlwifi_legacy_dev_ucode_event, + TP_PROTO(struct iwl_priv *priv, u32 time, u32 data, u32 ev), + TP_ARGS(priv, time, data, ev), + TP_STRUCT__entry( + PRIV_ENTRY + + __field(u32, time) + __field(u32, data) + __field(u32, ev) + ), + TP_fast_assign( + PRIV_ASSIGN; + __entry->time = time; + __entry->data = data; + __entry->ev = ev; + ), + TP_printk("[%p] EVT_LOGT:%010u:0x%08x:%04u", + __entry->priv, __entry->time, __entry->data, __entry->ev) +); #endif /* __IWLWIFI_DEVICE_TRACE */ #undef TRACE_INCLUDE_PATH diff --git a/trunk/drivers/net/wireless/iwlegacy/iwl-helpers.h b/trunk/drivers/net/wireless/iwlegacy/iwl-helpers.h index 5cf23eaecbbb..a6effdae63f9 100644 --- a/trunk/drivers/net/wireless/iwlegacy/iwl-helpers.h +++ b/trunk/drivers/net/wireless/iwlegacy/iwl-helpers.h @@ -132,16 +132,7 @@ static inline void iwl_legacy_stop_queue(struct iwl_priv *priv, ieee80211_stop_queue(priv->hw, ac); } -#ifdef ieee80211_stop_queue -#undef ieee80211_stop_queue -#endif - #define ieee80211_stop_queue DO_NOT_USE_ieee80211_stop_queue - -#ifdef ieee80211_wake_queue -#undef ieee80211_wake_queue -#endif - #define ieee80211_wake_queue DO_NOT_USE_ieee80211_wake_queue static inline void iwl_legacy_disable_interrupts(struct iwl_priv *priv) diff --git a/trunk/drivers/net/wireless/iwlegacy/iwl-rx.c b/trunk/drivers/net/wireless/iwlegacy/iwl-rx.c index 9b5d0abe8be9..654cf233a384 100644 --- a/trunk/drivers/net/wireless/iwlegacy/iwl-rx.c +++ b/trunk/drivers/net/wireless/iwlegacy/iwl-rx.c @@ -227,6 +227,27 @@ void iwl_legacy_rx_spectrum_measure_notif(struct iwl_priv *priv, } EXPORT_SYMBOL(iwl_legacy_rx_spectrum_measure_notif); +void iwl_legacy_recover_from_statistics(struct iwl_priv *priv, + struct iwl_rx_packet *pkt) +{ + if (test_bit(STATUS_EXIT_PENDING, &priv->status)) + return; + if (iwl_legacy_is_any_associated(priv)) { + if (priv->cfg->ops->lib->check_plcp_health) { + if (!priv->cfg->ops->lib->check_plcp_health( + priv, pkt)) { + /* + * high plcp error detected + * reset Radio + */ + iwl_legacy_force_reset(priv, + IWL_RF_RESET, false); + } + } + } +} +EXPORT_SYMBOL(iwl_legacy_recover_from_statistics); + /* * returns non-zero if packet should be dropped */ diff --git a/trunk/drivers/net/wireless/iwlegacy/iwl-scan.c b/trunk/drivers/net/wireless/iwlegacy/iwl-scan.c index a6b5222fc59e..353234a02c6d 100644 --- a/trunk/drivers/net/wireless/iwlegacy/iwl-scan.c +++ b/trunk/drivers/net/wireless/iwlegacy/iwl-scan.c @@ -101,6 +101,7 @@ static void iwl_legacy_complete_scan(struct iwl_priv *priv, bool aborted) ieee80211_scan_completed(priv->hw, aborted); } + priv->is_internal_short_scan = false; priv->scan_vif = NULL; priv->scan_request = NULL; } @@ -328,8 +329,10 @@ void iwl_legacy_init_scan_params(struct iwl_priv *priv) } EXPORT_SYMBOL(iwl_legacy_init_scan_params); -static int iwl_legacy_scan_initiate(struct iwl_priv *priv, - struct ieee80211_vif *vif) +static int __must_check iwl_legacy_scan_initiate(struct iwl_priv *priv, + struct ieee80211_vif *vif, + bool internal, + enum ieee80211_band band) { int ret; @@ -356,14 +359,18 @@ static int iwl_legacy_scan_initiate(struct iwl_priv *priv, return -EBUSY; } - IWL_DEBUG_SCAN(priv, "Starting scan...\n"); + IWL_DEBUG_SCAN(priv, "Starting %sscan...\n", + internal ? "internal short " : ""); set_bit(STATUS_SCANNING, &priv->status); + priv->is_internal_short_scan = internal; priv->scan_start = jiffies; + priv->scan_band = band; ret = priv->cfg->ops->utils->request_scan(priv, vif); if (ret) { clear_bit(STATUS_SCANNING, &priv->status); + priv->is_internal_short_scan = false; return ret; } @@ -387,7 +394,8 @@ int iwl_legacy_mac_hw_scan(struct ieee80211_hw *hw, mutex_lock(&priv->mutex); - if (test_bit(STATUS_SCANNING, &priv->status)) { + if (test_bit(STATUS_SCANNING, &priv->status) && + !priv->is_internal_short_scan) { IWL_DEBUG_SCAN(priv, "Scan already in progress.\n"); ret = -EAGAIN; goto out_unlock; @@ -396,9 +404,17 @@ int iwl_legacy_mac_hw_scan(struct ieee80211_hw *hw, /* mac80211 will only ask for one band at a time */ priv->scan_request = req; priv->scan_vif = vif; - priv->scan_band = req->channels[0]->band; - ret = iwl_legacy_scan_initiate(priv, vif); + /* + * If an internal scan is in progress, just set + * up the scan_request as per above. + */ + if (priv->is_internal_short_scan) { + IWL_DEBUG_SCAN(priv, "SCAN request during internal scan\n"); + ret = 0; + } else + ret = iwl_legacy_scan_initiate(priv, vif, false, + req->channels[0]->band); IWL_DEBUG_MAC80211(priv, "leave\n"); @@ -409,6 +425,40 @@ int iwl_legacy_mac_hw_scan(struct ieee80211_hw *hw, } EXPORT_SYMBOL(iwl_legacy_mac_hw_scan); +/* + * internal short scan, this function should only been called while associated. + * It will reset and tune the radio to prevent possible RF related problem + */ +void iwl_legacy_internal_short_hw_scan(struct iwl_priv *priv) +{ + queue_work(priv->workqueue, &priv->start_internal_scan); +} + +static void iwl_legacy_bg_start_internal_scan(struct work_struct *work) +{ + struct iwl_priv *priv = + container_of(work, struct iwl_priv, start_internal_scan); + + IWL_DEBUG_SCAN(priv, "Start internal scan\n"); + + mutex_lock(&priv->mutex); + + if (priv->is_internal_short_scan == true) { + IWL_DEBUG_SCAN(priv, "Internal scan already in progress\n"); + goto unlock; + } + + if (test_bit(STATUS_SCANNING, &priv->status)) { + IWL_DEBUG_SCAN(priv, "Scan already in progress.\n"); + goto unlock; + } + + if (iwl_legacy_scan_initiate(priv, NULL, true, priv->band)) + IWL_DEBUG_SCAN(priv, "failed to start internal short scan\n"); + unlock: + mutex_unlock(&priv->mutex); +} + static void iwl_legacy_bg_scan_check(struct work_struct *data) { struct iwl_priv *priv = @@ -492,7 +542,8 @@ static void iwl_legacy_bg_scan_completed(struct work_struct *work) container_of(work, struct iwl_priv, scan_completed); bool aborted; - IWL_DEBUG_SCAN(priv, "Completed scan.\n"); + IWL_DEBUG_SCAN(priv, "Completed %sscan.\n", + priv->is_internal_short_scan ? "internal short " : ""); cancel_delayed_work(&priv->scan_check); @@ -507,6 +558,27 @@ static void iwl_legacy_bg_scan_completed(struct work_struct *work) goto out_settings; } + if (priv->is_internal_short_scan && !aborted) { + int err; + + /* Check if mac80211 requested scan during our internal scan */ + if (priv->scan_request == NULL) + goto out_complete; + + /* If so request a new scan */ + err = iwl_legacy_scan_initiate(priv, priv->scan_vif, false, + priv->scan_request->channels[0]->band); + if (err) { + IWL_DEBUG_SCAN(priv, + "failed to initiate pending scan: %d\n", err); + aborted = true; + goto out_complete; + } + + goto out; + } + +out_complete: iwl_legacy_complete_scan(priv, aborted); out_settings: @@ -518,7 +590,8 @@ static void iwl_legacy_bg_scan_completed(struct work_struct *work) * We do not commit power settings while scan is pending, * do it now if the settings changed. */ - iwl_legacy_power_set_mode(priv, &priv->power_data.sleep_cmd_next, false); + iwl_legacy_power_set_mode(priv, &priv->power_data.sleep_cmd_next, + false); iwl_legacy_set_tx_power(priv, priv->tx_power_next, false); priv->cfg->ops->utils->post_scan(priv); @@ -531,12 +604,15 @@ void iwl_legacy_setup_scan_deferred_work(struct iwl_priv *priv) { INIT_WORK(&priv->scan_completed, iwl_legacy_bg_scan_completed); INIT_WORK(&priv->abort_scan, iwl_legacy_bg_abort_scan); + INIT_WORK(&priv->start_internal_scan, + iwl_legacy_bg_start_internal_scan); INIT_DELAYED_WORK(&priv->scan_check, iwl_legacy_bg_scan_check); } EXPORT_SYMBOL(iwl_legacy_setup_scan_deferred_work); void iwl_legacy_cancel_scan_deferred_work(struct iwl_priv *priv) { + cancel_work_sync(&priv->start_internal_scan); cancel_work_sync(&priv->abort_scan); cancel_work_sync(&priv->scan_completed); diff --git a/trunk/drivers/net/wireless/iwlegacy/iwl3945-base.c b/trunk/drivers/net/wireless/iwlegacy/iwl3945-base.c index 795826a014ed..0ee6be6a9c5d 100644 --- a/trunk/drivers/net/wireless/iwlegacy/iwl3945-base.c +++ b/trunk/drivers/net/wireless/iwlegacy/iwl3945-base.c @@ -1409,6 +1409,212 @@ void iwl3945_dump_nic_error_log(struct iwl_priv *priv) } } +#define EVENT_START_OFFSET (6 * sizeof(u32)) + +/** + * iwl3945_print_event_log - Dump error event log to syslog + * + */ +static int iwl3945_print_event_log(struct iwl_priv *priv, u32 start_idx, + u32 num_events, u32 mode, + int pos, char **buf, size_t bufsz) +{ + u32 i; + u32 base; /* SRAM byte address of event log header */ + u32 event_size; /* 2 u32s, or 3 u32s if timestamp recorded */ + u32 ptr; /* SRAM byte address of log data */ + u32 ev, time, data; /* event log data */ + unsigned long reg_flags; + + if (num_events == 0) + return pos; + + base = le32_to_cpu(priv->card_alive.log_event_table_ptr); + + if (mode == 0) + event_size = 2 * sizeof(u32); + else + event_size = 3 * sizeof(u32); + + ptr = base + EVENT_START_OFFSET + (start_idx * event_size); + + /* Make sure device is powered up for SRAM reads */ + spin_lock_irqsave(&priv->reg_lock, reg_flags); + iwl_grab_nic_access(priv); + + /* Set starting address; reads will auto-increment */ + _iwl_legacy_write_direct32(priv, HBUS_TARG_MEM_RADDR, ptr); + rmb(); + + /* "time" is actually "data" for mode 0 (no timestamp). + * place event id # at far right for easier visual parsing. */ + for (i = 0; i < num_events; i++) { + ev = _iwl_legacy_read_direct32(priv, HBUS_TARG_MEM_RDAT); + time = _iwl_legacy_read_direct32(priv, HBUS_TARG_MEM_RDAT); + if (mode == 0) { + /* data, ev */ + if (bufsz) { + pos += scnprintf(*buf + pos, bufsz - pos, + "0x%08x:%04u\n", + time, ev); + } else { + IWL_ERR(priv, "0x%08x\t%04u\n", time, ev); + trace_iwlwifi_legacy_dev_ucode_event(priv, 0, + time, ev); + } + } else { + data = _iwl_legacy_read_direct32(priv, + HBUS_TARG_MEM_RDAT); + if (bufsz) { + pos += scnprintf(*buf + pos, bufsz - pos, + "%010u:0x%08x:%04u\n", + time, data, ev); + } else { + IWL_ERR(priv, "%010u\t0x%08x\t%04u\n", + time, data, ev); + trace_iwlwifi_legacy_dev_ucode_event(priv, time, + data, ev); + } + } + } + + /* Allow device to power down */ + iwl_release_nic_access(priv); + spin_unlock_irqrestore(&priv->reg_lock, reg_flags); + return pos; +} + +/** + * iwl3945_print_last_event_logs - Dump the newest # of event log to syslog + */ +static int iwl3945_print_last_event_logs(struct iwl_priv *priv, u32 capacity, + u32 num_wraps, u32 next_entry, + u32 size, u32 mode, + int pos, char **buf, size_t bufsz) +{ + /* + * display the newest DEFAULT_LOG_ENTRIES entries + * i.e the entries just before the next ont that uCode would fill. + */ + if (num_wraps) { + if (next_entry < size) { + pos = iwl3945_print_event_log(priv, + capacity - (size - next_entry), + size - next_entry, mode, + pos, buf, bufsz); + pos = iwl3945_print_event_log(priv, 0, + next_entry, mode, + pos, buf, bufsz); + } else + pos = iwl3945_print_event_log(priv, next_entry - size, + size, mode, + pos, buf, bufsz); + } else { + if (next_entry < size) + pos = iwl3945_print_event_log(priv, 0, + next_entry, mode, + pos, buf, bufsz); + else + pos = iwl3945_print_event_log(priv, next_entry - size, + size, mode, + pos, buf, bufsz); + } + return pos; +} + +#define DEFAULT_IWL3945_DUMP_EVENT_LOG_ENTRIES (20) + +int iwl3945_dump_nic_event_log(struct iwl_priv *priv, bool full_log, + char **buf, bool display) +{ + u32 base; /* SRAM byte address of event log header */ + u32 capacity; /* event log capacity in # entries */ + u32 mode; /* 0 - no timestamp, 1 - timestamp recorded */ + u32 num_wraps; /* # times uCode wrapped to top of log */ + u32 next_entry; /* index of next entry to be written by uCode */ + u32 size; /* # entries that we'll print */ + int pos = 0; + size_t bufsz = 0; + + base = le32_to_cpu(priv->card_alive.log_event_table_ptr); + if (!iwl3945_hw_valid_rtc_data_addr(base)) { + IWL_ERR(priv, "Invalid event log pointer 0x%08X\n", base); + return -EINVAL; + } + + /* event log header */ + capacity = iwl_legacy_read_targ_mem(priv, base); + mode = iwl_legacy_read_targ_mem(priv, base + (1 * sizeof(u32))); + num_wraps = iwl_legacy_read_targ_mem(priv, base + (2 * sizeof(u32))); + next_entry = iwl_legacy_read_targ_mem(priv, base + (3 * sizeof(u32))); + + if (capacity > priv->cfg->base_params->max_event_log_size) { + IWL_ERR(priv, "Log capacity %d is bogus, limit to %d entries\n", + capacity, priv->cfg->base_params->max_event_log_size); + capacity = priv->cfg->base_params->max_event_log_size; + } + + if (next_entry > priv->cfg->base_params->max_event_log_size) { + IWL_ERR(priv, "Log write index %d is bogus, limit to %d\n", + next_entry, priv->cfg->base_params->max_event_log_size); + next_entry = priv->cfg->base_params->max_event_log_size; + } + + size = num_wraps ? capacity : next_entry; + + /* bail out if nothing in log */ + if (size == 0) { + IWL_ERR(priv, "Start IWL Event Log Dump: nothing in log\n"); + return pos; + } + +#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG + if (!(iwl_legacy_get_debug_level(priv) & IWL_DL_FW_ERRORS) && !full_log) + size = (size > DEFAULT_IWL3945_DUMP_EVENT_LOG_ENTRIES) + ? DEFAULT_IWL3945_DUMP_EVENT_LOG_ENTRIES : size; +#else + size = (size > DEFAULT_IWL3945_DUMP_EVENT_LOG_ENTRIES) + ? DEFAULT_IWL3945_DUMP_EVENT_LOG_ENTRIES : size; +#endif + + IWL_ERR(priv, "Start IWL Event Log Dump: display last %d count\n", + size); + +#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG + if (display) { + if (full_log) + bufsz = capacity * 48; + else + bufsz = size * 48; + *buf = kmalloc(bufsz, GFP_KERNEL); + if (!*buf) + return -ENOMEM; + } + if ((iwl_legacy_get_debug_level(priv) & IWL_DL_FW_ERRORS) || full_log) { + /* if uCode has wrapped back to top of log, + * start at the oldest entry, + * i.e the next one that uCode would fill. + */ + if (num_wraps) + pos = iwl3945_print_event_log(priv, next_entry, + capacity - next_entry, mode, + pos, buf, bufsz); + + /* (then/else) start at top of log */ + pos = iwl3945_print_event_log(priv, 0, next_entry, mode, + pos, buf, bufsz); + } else + pos = iwl3945_print_last_event_logs(priv, capacity, num_wraps, + next_entry, size, mode, + pos, buf, bufsz); +#else + pos = iwl3945_print_last_event_logs(priv, capacity, num_wraps, + next_entry, size, mode, + pos, buf, bufsz); +#endif + return pos; +} + static void iwl3945_irq_tasklet(struct iwl_priv *priv) { u32 inta, handled = 0; @@ -1556,6 +1762,49 @@ static void iwl3945_irq_tasklet(struct iwl_priv *priv) #endif } +static int iwl3945_get_single_channel_for_scan(struct iwl_priv *priv, + struct ieee80211_vif *vif, + enum ieee80211_band band, + struct iwl3945_scan_channel *scan_ch) +{ + const struct ieee80211_supported_band *sband; + u16 passive_dwell = 0; + u16 active_dwell = 0; + int added = 0; + u8 channel = 0; + + sband = iwl_get_hw_mode(priv, band); + if (!sband) { + IWL_ERR(priv, "invalid band\n"); + return added; + } + + active_dwell = iwl_legacy_get_active_dwell_time(priv, band, 0); + passive_dwell = iwl_legacy_get_passive_dwell_time(priv, band, vif); + + if (passive_dwell <= active_dwell) + passive_dwell = active_dwell + 1; + + + channel = iwl_legacy_get_single_channel_number(priv, band); + + if (channel) { + scan_ch->channel = channel; + scan_ch->type = 0; /* passive */ + scan_ch->active_dwell = cpu_to_le16(active_dwell); + scan_ch->passive_dwell = cpu_to_le16(passive_dwell); + /* Set txpower levels to defaults */ + scan_ch->tpc.dsp_atten = 110; + if (band == IEEE80211_BAND_5GHZ) + scan_ch->tpc.tx_gain = ((1 << 5) | (3 << 3)) | 3; + else + scan_ch->tpc.tx_gain = ((1 << 5) | (5 << 3)); + added++; + } else + IWL_ERR(priv, "no valid channel found\n"); + return added; +} + static int iwl3945_get_channels_for_scan(struct iwl_priv *priv, enum ieee80211_band band, u8 is_active, u8 n_probes, @@ -2567,7 +2816,6 @@ int iwl3945_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif) enum ieee80211_band band; bool is_active = false; int ret; - u16 len; lockdep_assert_held(&priv->mutex); @@ -2586,14 +2834,17 @@ int iwl3945_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif) scan->quiet_time = IWL_ACTIVE_QUIET_TIME; if (iwl_legacy_is_associated(priv, IWL_RXON_CTX_BSS)) { - u16 interval; + u16 interval = 0; u32 extra; u32 suspend_time = 100; u32 scan_suspend_time = 100; IWL_DEBUG_INFO(priv, "Scanning while associated...\n"); - interval = vif->bss_conf.beacon_int; + if (priv->is_internal_short_scan) + interval = 0; + else + interval = vif->bss_conf.beacon_int; scan->suspend_time = 0; scan->max_out_time = cpu_to_le32(200 * 1024); @@ -2615,7 +2866,9 @@ int iwl3945_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif) scan_suspend_time, interval); } - if (priv->scan_request->n_ssids) { + if (priv->is_internal_short_scan) { + IWL_DEBUG_SCAN(priv, "Start internal passive scan.\n"); + } else if (priv->scan_request->n_ssids) { int i, p = 0; IWL_DEBUG_SCAN(priv, "Kicking off active scan\n"); for (i = 0; i < priv->scan_request->n_ssids; i++) { @@ -2666,17 +2919,36 @@ int iwl3945_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif) scan->good_CRC_th = is_active ? IWL_GOOD_CRC_TH_DEFAULT : IWL_GOOD_CRC_TH_DISABLED; - len = iwl_legacy_fill_probe_req(priv, (struct ieee80211_mgmt *)scan->data, - vif->addr, priv->scan_request->ie, - priv->scan_request->ie_len, - IWL_MAX_SCAN_SIZE - sizeof(*scan)); - scan->tx_cmd.len = cpu_to_le16(len); - + if (!priv->is_internal_short_scan) { + scan->tx_cmd.len = cpu_to_le16( + iwl_legacy_fill_probe_req(priv, + (struct ieee80211_mgmt *)scan->data, + vif->addr, + priv->scan_request->ie, + priv->scan_request->ie_len, + IWL_MAX_SCAN_SIZE - sizeof(*scan))); + } else { + /* use bcast addr, will not be transmitted but must be valid */ + scan->tx_cmd.len = cpu_to_le16( + iwl_legacy_fill_probe_req(priv, + (struct ieee80211_mgmt *)scan->data, + iwlegacy_bcast_addr, NULL, 0, + IWL_MAX_SCAN_SIZE - sizeof(*scan))); + } /* select Rx antennas */ scan->flags |= iwl3945_get_antenna_flags(priv); - scan->channel_count = iwl3945_get_channels_for_scan(priv, band, is_active, n_probes, - (void *)&scan->data[len], vif); + if (priv->is_internal_short_scan) { + scan->channel_count = + iwl3945_get_single_channel_for_scan(priv, vif, band, + (void *)&scan->data[le16_to_cpu( + scan->tx_cmd.len)]); + } else { + scan->channel_count = + iwl3945_get_channels_for_scan(priv, band, is_active, n_probes, + (void *)&scan->data[le16_to_cpu(scan->tx_cmd.len)], vif); + } + if (scan->channel_count == 0) { IWL_DEBUG_SCAN(priv, "channel count %d\n", scan->channel_count); return -EIO; @@ -3552,7 +3824,10 @@ static int iwl3945_init_drv(struct iwl_priv *priv) priv->missed_beacon_threshold = IWL_MISSED_BEACON_THRESHOLD_DEF; /* initialize force reset */ - priv->force_reset.reset_duration = IWL_DELAY_NEXT_FORCE_FW_RELOAD; + priv->force_reset[IWL_RF_RESET].reset_duration = + IWL_DELAY_NEXT_FORCE_RF_RESET; + priv->force_reset[IWL_FW_RESET].reset_duration = + IWL_DELAY_NEXT_FORCE_FW_RELOAD; if (eeprom->version < EEPROM_3945_EEPROM_VERSION) { IWL_WARN(priv, "Unsupported EEPROM version: 0x%04X\n", diff --git a/trunk/drivers/net/wireless/iwlegacy/iwl4965-base.c b/trunk/drivers/net/wireless/iwlegacy/iwl4965-base.c index 46242d2aa5ad..7157ba529680 100644 --- a/trunk/drivers/net/wireless/iwlegacy/iwl4965-base.c +++ b/trunk/drivers/net/wireless/iwlegacy/iwl4965-base.c @@ -488,6 +488,134 @@ static void iwl4965_bg_statistics_periodic(unsigned long data) iwl_legacy_send_statistics_request(priv, CMD_ASYNC, false); } + +static void iwl4965_print_cont_event_trace(struct iwl_priv *priv, u32 base, + u32 start_idx, u32 num_events, + u32 mode) +{ + u32 i; + u32 ptr; /* SRAM byte address of log data */ + u32 ev, time, data; /* event log data */ + unsigned long reg_flags; + + if (mode == 0) + ptr = base + (4 * sizeof(u32)) + (start_idx * 2 * sizeof(u32)); + else + ptr = base + (4 * sizeof(u32)) + (start_idx * 3 * sizeof(u32)); + + /* Make sure device is powered up for SRAM reads */ + spin_lock_irqsave(&priv->reg_lock, reg_flags); + if (iwl_grab_nic_access(priv)) { + spin_unlock_irqrestore(&priv->reg_lock, reg_flags); + return; + } + + /* Set starting address; reads will auto-increment */ + _iwl_legacy_write_direct32(priv, HBUS_TARG_MEM_RADDR, ptr); + rmb(); + + /* + * "time" is actually "data" for mode 0 (no timestamp). + * place event id # at far right for easier visual parsing. + */ + for (i = 0; i < num_events; i++) { + ev = _iwl_legacy_read_direct32(priv, HBUS_TARG_MEM_RDAT); + time = _iwl_legacy_read_direct32(priv, HBUS_TARG_MEM_RDAT); + if (mode == 0) { + trace_iwlwifi_legacy_dev_ucode_cont_event(priv, + 0, time, ev); + } else { + data = _iwl_legacy_read_direct32(priv, + HBUS_TARG_MEM_RDAT); + trace_iwlwifi_legacy_dev_ucode_cont_event(priv, + time, data, ev); + } + } + /* Allow device to power down */ + iwl_release_nic_access(priv); + spin_unlock_irqrestore(&priv->reg_lock, reg_flags); +} + +static void iwl4965_continuous_event_trace(struct iwl_priv *priv) +{ + u32 capacity; /* event log capacity in # entries */ + u32 base; /* SRAM byte address of event log header */ + u32 mode; /* 0 - no timestamp, 1 - timestamp recorded */ + u32 num_wraps; /* # times uCode wrapped to top of log */ + u32 next_entry; /* index of next entry to be written by uCode */ + + if (priv->ucode_type == UCODE_INIT) + base = le32_to_cpu(priv->card_alive_init.error_event_table_ptr); + else + base = le32_to_cpu(priv->card_alive.log_event_table_ptr); + if (priv->cfg->ops->lib->is_valid_rtc_data_addr(base)) { + capacity = iwl_legacy_read_targ_mem(priv, base); + num_wraps = iwl_legacy_read_targ_mem(priv, + base + (2 * sizeof(u32))); + mode = iwl_legacy_read_targ_mem(priv, base + (1 * sizeof(u32))); + next_entry = iwl_legacy_read_targ_mem(priv, + base + (3 * sizeof(u32))); + } else + return; + + if (num_wraps == priv->event_log.num_wraps) { + iwl4965_print_cont_event_trace(priv, + base, priv->event_log.next_entry, + next_entry - priv->event_log.next_entry, + mode); + priv->event_log.non_wraps_count++; + } else { + if ((num_wraps - priv->event_log.num_wraps) > 1) + priv->event_log.wraps_more_count++; + else + priv->event_log.wraps_once_count++; + trace_iwlwifi_legacy_dev_ucode_wrap_event(priv, + num_wraps - priv->event_log.num_wraps, + next_entry, priv->event_log.next_entry); + if (next_entry < priv->event_log.next_entry) { + iwl4965_print_cont_event_trace(priv, base, + priv->event_log.next_entry, + capacity - priv->event_log.next_entry, + mode); + + iwl4965_print_cont_event_trace(priv, base, 0, + next_entry, mode); + } else { + iwl4965_print_cont_event_trace(priv, base, + next_entry, capacity - next_entry, + mode); + + iwl4965_print_cont_event_trace(priv, base, 0, + next_entry, mode); + } + } + priv->event_log.num_wraps = num_wraps; + priv->event_log.next_entry = next_entry; +} + +/** + * iwl4965_bg_ucode_trace - Timer callback to log ucode event + * + * The timer is continually set to execute every + * UCODE_TRACE_PERIOD milliseconds after the last timer expired + * this function is to perform continuous uCode event logging operation + * if enabled + */ +static void iwl4965_bg_ucode_trace(unsigned long data) +{ + struct iwl_priv *priv = (struct iwl_priv *)data; + + if (test_bit(STATUS_EXIT_PENDING, &priv->status)) + return; + + if (priv->event_log.ucode_trace) { + iwl4965_continuous_event_trace(priv); + /* Reschedule the timer to occur in UCODE_TRACE_PERIOD */ + mod_timer(&priv->ucode_trace, + jiffies + msecs_to_jiffies(UCODE_TRACE_PERIOD)); + } +} + static void iwl4965_rx_beacon_notif(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb) { @@ -1583,6 +1711,209 @@ void iwl4965_dump_nic_error_log(struct iwl_priv *priv) pc, blink1, blink2, ilink1, ilink2, hcmd); } +#define EVENT_START_OFFSET (4 * sizeof(u32)) + +/** + * iwl4965_print_event_log - Dump error event log to syslog + * + */ +static int iwl4965_print_event_log(struct iwl_priv *priv, u32 start_idx, + u32 num_events, u32 mode, + int pos, char **buf, size_t bufsz) +{ + u32 i; + u32 base; /* SRAM byte address of event log header */ + u32 event_size; /* 2 u32s, or 3 u32s if timestamp recorded */ + u32 ptr; /* SRAM byte address of log data */ + u32 ev, time, data; /* event log data */ + unsigned long reg_flags; + + if (num_events == 0) + return pos; + + if (priv->ucode_type == UCODE_INIT) { + base = le32_to_cpu(priv->card_alive_init.log_event_table_ptr); + } else { + base = le32_to_cpu(priv->card_alive.log_event_table_ptr); + } + + if (mode == 0) + event_size = 2 * sizeof(u32); + else + event_size = 3 * sizeof(u32); + + ptr = base + EVENT_START_OFFSET + (start_idx * event_size); + + /* Make sure device is powered up for SRAM reads */ + spin_lock_irqsave(&priv->reg_lock, reg_flags); + iwl_grab_nic_access(priv); + + /* Set starting address; reads will auto-increment */ + _iwl_legacy_write_direct32(priv, HBUS_TARG_MEM_RADDR, ptr); + rmb(); + + /* "time" is actually "data" for mode 0 (no timestamp). + * place event id # at far right for easier visual parsing. */ + for (i = 0; i < num_events; i++) { + ev = _iwl_legacy_read_direct32(priv, HBUS_TARG_MEM_RDAT); + time = _iwl_legacy_read_direct32(priv, HBUS_TARG_MEM_RDAT); + if (mode == 0) { + /* data, ev */ + if (bufsz) { + pos += scnprintf(*buf + pos, bufsz - pos, + "EVT_LOG:0x%08x:%04u\n", + time, ev); + } else { + trace_iwlwifi_legacy_dev_ucode_event(priv, 0, + time, ev); + IWL_ERR(priv, "EVT_LOG:0x%08x:%04u\n", + time, ev); + } + } else { + data = _iwl_legacy_read_direct32(priv, + HBUS_TARG_MEM_RDAT); + if (bufsz) { + pos += scnprintf(*buf + pos, bufsz - pos, + "EVT_LOGT:%010u:0x%08x:%04u\n", + time, data, ev); + } else { + IWL_ERR(priv, "EVT_LOGT:%010u:0x%08x:%04u\n", + time, data, ev); + trace_iwlwifi_legacy_dev_ucode_event(priv, time, + data, ev); + } + } + } + + /* Allow device to power down */ + iwl_release_nic_access(priv); + spin_unlock_irqrestore(&priv->reg_lock, reg_flags); + return pos; +} + +/** + * iwl4965_print_last_event_logs - Dump the newest # of event log to syslog + */ +static int iwl4965_print_last_event_logs(struct iwl_priv *priv, u32 capacity, + u32 num_wraps, u32 next_entry, + u32 size, u32 mode, + int pos, char **buf, size_t bufsz) +{ + /* + * display the newest DEFAULT_LOG_ENTRIES entries + * i.e the entries just before the next ont that uCode would fill. + */ + if (num_wraps) { + if (next_entry < size) { + pos = iwl4965_print_event_log(priv, + capacity - (size - next_entry), + size - next_entry, mode, + pos, buf, bufsz); + pos = iwl4965_print_event_log(priv, 0, + next_entry, mode, + pos, buf, bufsz); + } else + pos = iwl4965_print_event_log(priv, next_entry - size, + size, mode, pos, buf, bufsz); + } else { + if (next_entry < size) { + pos = iwl4965_print_event_log(priv, 0, next_entry, + mode, pos, buf, bufsz); + } else { + pos = iwl4965_print_event_log(priv, next_entry - size, + size, mode, pos, buf, bufsz); + } + } + return pos; +} + +#define DEFAULT_DUMP_EVENT_LOG_ENTRIES (20) + +int iwl4965_dump_nic_event_log(struct iwl_priv *priv, bool full_log, + char **buf, bool display) +{ + u32 base; /* SRAM byte address of event log header */ + u32 capacity; /* event log capacity in # entries */ + u32 mode; /* 0 - no timestamp, 1 - timestamp recorded */ + u32 num_wraps; /* # times uCode wrapped to top of log */ + u32 next_entry; /* index of next entry to be written by uCode */ + u32 size; /* # entries that we'll print */ + int pos = 0; + size_t bufsz = 0; + + if (priv->ucode_type == UCODE_INIT) { + base = le32_to_cpu(priv->card_alive_init.log_event_table_ptr); + } else { + base = le32_to_cpu(priv->card_alive.log_event_table_ptr); + } + + if (!priv->cfg->ops->lib->is_valid_rtc_data_addr(base)) { + IWL_ERR(priv, + "Invalid event log pointer 0x%08X for %s uCode\n", + base, (priv->ucode_type == UCODE_INIT) ? "Init" : "RT"); + return -EINVAL; + } + + /* event log header */ + capacity = iwl_legacy_read_targ_mem(priv, base); + mode = iwl_legacy_read_targ_mem(priv, base + (1 * sizeof(u32))); + num_wraps = iwl_legacy_read_targ_mem(priv, base + (2 * sizeof(u32))); + next_entry = iwl_legacy_read_targ_mem(priv, base + (3 * sizeof(u32))); + + size = num_wraps ? capacity : next_entry; + + /* bail out if nothing in log */ + if (size == 0) { + IWL_ERR(priv, "Start IWL Event Log Dump: nothing in log\n"); + return pos; + } + +#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG + if (!(iwl_legacy_get_debug_level(priv) & IWL_DL_FW_ERRORS) && !full_log) + size = (size > DEFAULT_DUMP_EVENT_LOG_ENTRIES) + ? DEFAULT_DUMP_EVENT_LOG_ENTRIES : size; +#else + size = (size > DEFAULT_DUMP_EVENT_LOG_ENTRIES) + ? DEFAULT_DUMP_EVENT_LOG_ENTRIES : size; +#endif + IWL_ERR(priv, "Start IWL Event Log Dump: display last %u entries\n", + size); + +#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG + if (display) { + if (full_log) + bufsz = capacity * 48; + else + bufsz = size * 48; + *buf = kmalloc(bufsz, GFP_KERNEL); + if (!*buf) + return -ENOMEM; + } + if ((iwl_legacy_get_debug_level(priv) & IWL_DL_FW_ERRORS) || full_log) { + /* + * if uCode has wrapped back to top of log, + * start at the oldest entry, + * i.e the next one that uCode would fill. + */ + if (num_wraps) + pos = iwl4965_print_event_log(priv, next_entry, + capacity - next_entry, mode, + pos, buf, bufsz); + /* (then/else) start at top of log */ + pos = iwl4965_print_event_log(priv, 0, + next_entry, mode, pos, buf, bufsz); + } else + pos = iwl4965_print_last_event_logs(priv, capacity, num_wraps, + next_entry, size, mode, + pos, buf, bufsz); +#else + pos = iwl4965_print_last_event_logs(priv, capacity, num_wraps, + next_entry, size, mode, + pos, buf, bufsz); +#endif + return pos; +} + static void iwl4965_rf_kill_ct_config(struct iwl_priv *priv) { struct iwl_ct_kill_config cmd; @@ -2442,10 +2773,20 @@ int iwl4965_mac_ampdu_action(struct ieee80211_hw *hw, case IEEE80211_AMPDU_TX_START: IWL_DEBUG_HT(priv, "start Tx\n"); ret = iwl4965_tx_agg_start(priv, vif, sta, tid, ssn); + if (ret == 0) { + priv->_4965.agg_tids_count++; + IWL_DEBUG_HT(priv, "priv->_4965.agg_tids_count = %u\n", + priv->_4965.agg_tids_count); + } break; case IEEE80211_AMPDU_TX_STOP: IWL_DEBUG_HT(priv, "stop Tx\n"); ret = iwl4965_tx_agg_stop(priv, vif, sta, tid); + if ((ret == 0) && (priv->_4965.agg_tids_count > 0)) { + priv->_4965.agg_tids_count--; + IWL_DEBUG_HT(priv, "priv->_4965.agg_tids_count = %u\n", + priv->_4965.agg_tids_count); + } if (test_bit(STATUS_EXIT_PENDING, &priv->status)) ret = 0; break; @@ -2510,6 +2851,7 @@ void iwl4965_mac_channel_switch(struct ieee80211_hw *hw, struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; u16 ch; + unsigned long flags = 0; IWL_DEBUG_MAC80211(priv, "enter\n"); @@ -2526,64 +2868,64 @@ void iwl4965_mac_channel_switch(struct ieee80211_hw *hw, if (!iwl_legacy_is_associated_ctx(ctx)) goto out; - if (!priv->cfg->ops->lib->set_channel_switch) - goto out; - - ch = channel->hw_value; - if (le16_to_cpu(ctx->active.channel) == ch) - goto out; - - ch_info = iwl_legacy_get_channel_info(priv, channel->band, ch); - if (!iwl_legacy_is_channel_valid(ch_info)) { - IWL_DEBUG_MAC80211(priv, "invalid channel\n"); - goto out; - } + if (priv->cfg->ops->lib->set_channel_switch) { - spin_lock_irq(&priv->lock); - - priv->current_ht_config.smps = conf->smps_mode; - - /* Configure HT40 channels */ - ctx->ht.enabled = conf_is_ht(conf); - if (ctx->ht.enabled) { - if (conf_is_ht40_minus(conf)) { - ctx->ht.extension_chan_offset = - IEEE80211_HT_PARAM_CHA_SEC_BELOW; - ctx->ht.is_40mhz = true; - } else if (conf_is_ht40_plus(conf)) { - ctx->ht.extension_chan_offset = - IEEE80211_HT_PARAM_CHA_SEC_ABOVE; - ctx->ht.is_40mhz = true; - } else { - ctx->ht.extension_chan_offset = - IEEE80211_HT_PARAM_CHA_SEC_NONE; - ctx->ht.is_40mhz = false; + ch = channel->hw_value; + if (le16_to_cpu(ctx->active.channel) != ch) { + ch_info = iwl_legacy_get_channel_info(priv, + channel->band, + ch); + if (!iwl_legacy_is_channel_valid(ch_info)) { + IWL_DEBUG_MAC80211(priv, "invalid channel\n"); + goto out; + } + spin_lock_irqsave(&priv->lock, flags); + + priv->current_ht_config.smps = conf->smps_mode; + + /* Configure HT40 channels */ + ctx->ht.enabled = conf_is_ht(conf); + if (ctx->ht.enabled) { + if (conf_is_ht40_minus(conf)) { + ctx->ht.extension_chan_offset = + IEEE80211_HT_PARAM_CHA_SEC_BELOW; + ctx->ht.is_40mhz = true; + } else if (conf_is_ht40_plus(conf)) { + ctx->ht.extension_chan_offset = + IEEE80211_HT_PARAM_CHA_SEC_ABOVE; + ctx->ht.is_40mhz = true; + } else { + ctx->ht.extension_chan_offset = + IEEE80211_HT_PARAM_CHA_SEC_NONE; + ctx->ht.is_40mhz = false; + } + } else + ctx->ht.is_40mhz = false; + + if ((le16_to_cpu(ctx->staging.channel) != ch)) + ctx->staging.flags = 0; + + iwl_legacy_set_rxon_channel(priv, channel, ctx); + iwl_legacy_set_rxon_ht(priv, ht_conf); + iwl_legacy_set_flags_for_band(priv, ctx, channel->band, + ctx->vif); + spin_unlock_irqrestore(&priv->lock, flags); + + iwl_legacy_set_rate(priv); + /* + * at this point, staging_rxon has the + * configuration for channel switch + */ + set_bit(STATUS_CHANNEL_SWITCH_PENDING, &priv->status); + priv->switch_channel = cpu_to_le16(ch); + if (priv->cfg->ops->lib->set_channel_switch(priv, ch_switch)) { + clear_bit(STATUS_CHANNEL_SWITCH_PENDING, + &priv->status); + priv->switch_channel = 0; + ieee80211_chswitch_done(ctx->vif, false); + } } - } else - ctx->ht.is_40mhz = false; - - if ((le16_to_cpu(ctx->staging.channel) != ch)) - ctx->staging.flags = 0; - - iwl_legacy_set_rxon_channel(priv, channel, ctx); - iwl_legacy_set_rxon_ht(priv, ht_conf); - iwl_legacy_set_flags_for_band(priv, ctx, channel->band, ctx->vif); - - spin_unlock_irq(&priv->lock); - - iwl_legacy_set_rate(priv); - /* - * at this point, staging_rxon has the - * configuration for channel switch - */ - set_bit(STATUS_CHANNEL_SWITCH_PENDING, &priv->status); - priv->switch_channel = cpu_to_le16(ch); - if (priv->cfg->ops->lib->set_channel_switch(priv, ch_switch)) { - clear_bit(STATUS_CHANNEL_SWITCH_PENDING, &priv->status); - priv->switch_channel = 0; - ieee80211_chswitch_done(ctx->vif, false); } - out: mutex_unlock(&priv->mutex); IWL_DEBUG_MAC80211(priv, "leave\n"); @@ -2692,6 +3034,10 @@ static void iwl4965_setup_deferred_work(struct iwl_priv *priv) priv->statistics_periodic.data = (unsigned long)priv; priv->statistics_periodic.function = iwl4965_bg_statistics_periodic; + init_timer(&priv->ucode_trace); + priv->ucode_trace.data = (unsigned long)priv; + priv->ucode_trace.function = iwl4965_bg_ucode_trace; + init_timer(&priv->watchdog); priv->watchdog.data = (unsigned long)priv; priv->watchdog.function = iwl_legacy_bg_watchdog; @@ -2710,6 +3056,7 @@ static void iwl4965_cancel_deferred_work(struct iwl_priv *priv) iwl_legacy_cancel_scan_deferred_work(priv); del_timer_sync(&priv->statistics_periodic); + del_timer_sync(&priv->ucode_trace); } static void iwl4965_init_hw_rates(struct iwl_priv *priv, @@ -2785,9 +3132,13 @@ static int iwl4965_init_drv(struct iwl_priv *priv) priv->iw_mode = NL80211_IFTYPE_STATION; priv->current_ht_config.smps = IEEE80211_SMPS_STATIC; priv->missed_beacon_threshold = IWL_MISSED_BEACON_THRESHOLD_DEF; + priv->_4965.agg_tids_count = 0; /* initialize force reset */ - priv->force_reset.reset_duration = IWL_DELAY_NEXT_FORCE_FW_RELOAD; + priv->force_reset[IWL_RF_RESET].reset_duration = + IWL_DELAY_NEXT_FORCE_RF_RESET; + priv->force_reset[IWL_FW_RESET].reset_duration = + IWL_DELAY_NEXT_FORCE_FW_RELOAD; /* Choose which receivers/antennas to use */ if (priv->cfg->ops->hcmd->set_rxon_chain) diff --git a/trunk/drivers/net/wireless/iwlwifi/Makefile b/trunk/drivers/net/wireless/iwlwifi/Makefile index 19150398a248..822660483f9f 100644 --- a/trunk/drivers/net/wireless/iwlwifi/Makefile +++ b/trunk/drivers/net/wireless/iwlwifi/Makefile @@ -13,8 +13,6 @@ iwlagn-objs += iwl-5000.o iwlagn-objs += iwl-6000.o iwlagn-objs += iwl-1000.o iwlagn-objs += iwl-2000.o -iwlagn-objs += iwl-pci.o -iwlagn-objs += iwl-trans.o iwlagn-$(CONFIG_IWLWIFI_DEBUGFS) += iwl-debugfs.o iwlagn-$(CONFIG_IWLWIFI_DEVICE_TRACING) += iwl-devtrace.o diff --git a/trunk/drivers/net/wireless/iwlwifi/iwl-1000.c b/trunk/drivers/net/wireless/iwlwifi/iwl-1000.c index cf1449df4f0b..7aa240e6ba1c 100644 --- a/trunk/drivers/net/wireless/iwlwifi/iwl-1000.c +++ b/trunk/drivers/net/wireless/iwlwifi/iwl-1000.c @@ -27,6 +27,8 @@ #include #include #include +#include +#include #include #include #include @@ -34,7 +36,6 @@ #include #include #include -#include #include "iwl-eeprom.h" #include "iwl-dev.h" @@ -54,10 +55,10 @@ #define IWL100_UCODE_API_MIN 5 #define IWL1000_FW_PRE "iwlwifi-1000-" -#define IWL1000_MODULE_FIRMWARE(api) IWL1000_FW_PRE __stringify(api) ".ucode" +#define IWL1000_MODULE_FIRMWARE(api) IWL1000_FW_PRE #api ".ucode" #define IWL100_FW_PRE "iwlwifi-100-" -#define IWL100_MODULE_FIRMWARE(api) IWL100_FW_PRE __stringify(api) ".ucode" +#define IWL100_MODULE_FIRMWARE(api) IWL100_FW_PRE #api ".ucode" /* @@ -138,6 +139,7 @@ static int iwl1000_hw_set_hw_params(struct iwl_priv *priv) priv->hw_params.ht40_channel = BIT(IEEE80211_BAND_2GHZ) | BIT(IEEE80211_BAND_5GHZ); + priv->hw_params.rx_wrt_ptr_reg = FH_RSCSR_CHNL0_WPTR; priv->hw_params.tx_chains_num = num_of_ant(priv->cfg->valid_tx_ant); if (priv->cfg->rx_with_siso_diversity) @@ -192,10 +194,13 @@ static struct iwl_lib_ops iwl1000_lib = { .temp_ops = { .temperature = iwlagn_temperature, }, + .txfifo_flush = iwlagn_txfifo_flush, + .dev_txfifo_flush = iwlagn_dev_txfifo_flush, }; static const struct iwl_ops iwl1000_ops = { .lib = &iwl1000_lib, + .hcmd = &iwlagn_hcmd, .utils = &iwlagn_hcmd_utils, }; diff --git a/trunk/drivers/net/wireless/iwlwifi/iwl-2000.c b/trunk/drivers/net/wireless/iwlwifi/iwl-2000.c index a401113c065a..5484ab712da8 100644 --- a/trunk/drivers/net/wireless/iwlwifi/iwl-2000.c +++ b/trunk/drivers/net/wireless/iwlwifi/iwl-2000.c @@ -27,6 +27,8 @@ #include #include #include +#include +#include #include #include #include @@ -34,7 +36,6 @@ #include #include #include -#include #include "iwl-eeprom.h" #include "iwl-dev.h" @@ -50,25 +51,20 @@ #define IWL2030_UCODE_API_MAX 5 #define IWL2000_UCODE_API_MAX 5 #define IWL105_UCODE_API_MAX 5 -#define IWL135_UCODE_API_MAX 5 /* Lowest firmware API version supported */ #define IWL2030_UCODE_API_MIN 5 #define IWL2000_UCODE_API_MIN 5 #define IWL105_UCODE_API_MIN 5 -#define IWL135_UCODE_API_MIN 5 #define IWL2030_FW_PRE "iwlwifi-2030-" -#define IWL2030_MODULE_FIRMWARE(api) IWL2030_FW_PRE __stringify(api) ".ucode" +#define IWL2030_MODULE_FIRMWARE(api) IWL2030_FW_PRE #api ".ucode" #define IWL2000_FW_PRE "iwlwifi-2000-" -#define IWL2000_MODULE_FIRMWARE(api) IWL2000_FW_PRE __stringify(api) ".ucode" +#define IWL2000_MODULE_FIRMWARE(api) IWL2000_FW_PRE #api ".ucode" #define IWL105_FW_PRE "iwlwifi-105-" -#define IWL105_MODULE_FIRMWARE(api) IWL105_FW_PRE __stringify(api) ".ucode" - -#define IWL135_FW_PRE "iwlwifi-135-" -#define IWL135_MODULE_FIRMWARE(api) IWL135_FW_PRE #api ".ucode" +#define IWL105_MODULE_FIRMWARE(api) IWL105_FW_PRE #api ".ucode" static void iwl2000_set_ct_threshold(struct iwl_priv *priv) { @@ -80,7 +76,21 @@ static void iwl2000_set_ct_threshold(struct iwl_priv *priv) /* NIC configuration for 2000 series */ static void iwl2000_nic_config(struct iwl_priv *priv) { - iwl_rf_config(priv); + u16 radio_cfg; + + radio_cfg = iwl_eeprom_query16(priv, EEPROM_RADIO_CONFIG); + + /* write radio config values to register */ + if (EEPROM_RF_CFG_TYPE_MSK(radio_cfg) <= EEPROM_RF_CONFIG_TYPE_MAX) + iwl_set_bit(priv, CSR_HW_IF_CONFIG_REG, + EEPROM_RF_CFG_TYPE_MSK(radio_cfg) | + EEPROM_RF_CFG_STEP_MSK(radio_cfg) | + EEPROM_RF_CFG_DASH_MSK(radio_cfg)); + + /* set CSR_HW_CONFIG_REG for uCode use */ + iwl_set_bit(priv, CSR_HW_IF_CONFIG_REG, + CSR_HW_IF_CONFIG_REG_BIT_RADIO_SI | + CSR_HW_IF_CONFIG_REG_BIT_MAC_SI); if (priv->cfg->iq_invert) iwl_set_bit(priv, CSR_GP_DRIVER_REG, @@ -136,6 +146,7 @@ static int iwl2000_hw_set_hw_params(struct iwl_priv *priv) priv->hw_params.ht40_channel = BIT(IEEE80211_BAND_2GHZ) | BIT(IEEE80211_BAND_5GHZ); + priv->hw_params.rx_wrt_ptr_reg = FH_RSCSR_CHNL0_WPTR; priv->hw_params.tx_chains_num = num_of_ant(priv->cfg->valid_tx_ant); if (priv->cfg->rx_with_siso_diversity) @@ -193,25 +204,31 @@ static struct iwl_lib_ops iwl2000_lib = { .temp_ops = { .temperature = iwlagn_temperature, }, + .txfifo_flush = iwlagn_txfifo_flush, + .dev_txfifo_flush = iwlagn_dev_txfifo_flush, }; static const struct iwl_ops iwl2000_ops = { .lib = &iwl2000_lib, + .hcmd = &iwlagn_hcmd, .utils = &iwlagn_hcmd_utils, }; static const struct iwl_ops iwl2030_ops = { .lib = &iwl2000_lib, + .hcmd = &iwlagn_bt_hcmd, .utils = &iwlagn_hcmd_utils, }; static const struct iwl_ops iwl105_ops = { .lib = &iwl2000_lib, + .hcmd = &iwlagn_hcmd, .utils = &iwlagn_hcmd_utils, }; static const struct iwl_ops iwl135_ops = { .lib = &iwl2000_lib, + .hcmd = &iwlagn_bt_hcmd, .utils = &iwlagn_hcmd_utils, }; @@ -344,9 +361,9 @@ struct iwl_cfg iwl105_bgn_cfg = { }; #define IWL_DEVICE_135 \ - .fw_name_pre = IWL135_FW_PRE, \ - .ucode_api_max = IWL135_UCODE_API_MAX, \ - .ucode_api_min = IWL135_UCODE_API_MIN, \ + .fw_name_pre = IWL105_FW_PRE, \ + .ucode_api_max = IWL105_UCODE_API_MAX, \ + .ucode_api_min = IWL105_UCODE_API_MIN, \ .eeprom_ver = EEPROM_2000_EEPROM_VERSION, \ .eeprom_calib_ver = EEPROM_2000_TX_POWER_VERSION, \ .ops = &iwl135_ops, \ @@ -359,12 +376,12 @@ struct iwl_cfg iwl105_bgn_cfg = { .rx_with_siso_diversity = true \ struct iwl_cfg iwl135_bg_cfg = { - .name = "135 Series 1x1 BG/BT", + .name = "105 Series 1x1 BG/BT", IWL_DEVICE_135, }; struct iwl_cfg iwl135_bgn_cfg = { - .name = "135 Series 1x1 BGN/BT", + .name = "105 Series 1x1 BGN/BT", IWL_DEVICE_135, .ht_params = &iwl2000_ht_params, }; @@ -372,4 +389,3 @@ struct iwl_cfg iwl135_bgn_cfg = { MODULE_FIRMWARE(IWL2000_MODULE_FIRMWARE(IWL2000_UCODE_API_MAX)); MODULE_FIRMWARE(IWL2030_MODULE_FIRMWARE(IWL2030_UCODE_API_MAX)); MODULE_FIRMWARE(IWL105_MODULE_FIRMWARE(IWL105_UCODE_API_MAX)); -MODULE_FIRMWARE(IWL135_MODULE_FIRMWARE(IWL135_UCODE_API_MAX)); diff --git a/trunk/drivers/net/wireless/iwlwifi/iwl-5000-hw.h b/trunk/drivers/net/wireless/iwlwifi/iwl-5000-hw.h index f9630a3c79fe..05ad47628b63 100644 --- a/trunk/drivers/net/wireless/iwlwifi/iwl-5000-hw.h +++ b/trunk/drivers/net/wireless/iwlwifi/iwl-5000-hw.h @@ -75,7 +75,7 @@ static inline s32 iwl_temp_calib_to_offset(struct iwl_priv *priv) { u16 temperature, voltage; __le16 *temp_calib = - (__le16 *)iwl_eeprom_query_addr(priv, EEPROM_TEMPERATURE); + (__le16 *)iwl_eeprom_query_addr(priv, EEPROM_5000_TEMPERATURE); temperature = le16_to_cpu(temp_calib[0]); voltage = le16_to_cpu(temp_calib[1]); diff --git a/trunk/drivers/net/wireless/iwlwifi/iwl-5000.c b/trunk/drivers/net/wireless/iwlwifi/iwl-5000.c index c55cec853f50..4353a658de25 100644 --- a/trunk/drivers/net/wireless/iwlwifi/iwl-5000.c +++ b/trunk/drivers/net/wireless/iwlwifi/iwl-5000.c @@ -27,6 +27,8 @@ #include #include #include +#include +#include #include #include #include @@ -35,7 +37,6 @@ #include #include #include -#include #include "iwl-eeprom.h" #include "iwl-dev.h" @@ -56,20 +57,33 @@ #define IWL5150_UCODE_API_MIN 1 #define IWL5000_FW_PRE "iwlwifi-5000-" -#define IWL5000_MODULE_FIRMWARE(api) IWL5000_FW_PRE __stringify(api) ".ucode" +#define IWL5000_MODULE_FIRMWARE(api) IWL5000_FW_PRE #api ".ucode" #define IWL5150_FW_PRE "iwlwifi-5150-" -#define IWL5150_MODULE_FIRMWARE(api) IWL5150_FW_PRE __stringify(api) ".ucode" +#define IWL5150_MODULE_FIRMWARE(api) IWL5150_FW_PRE #api ".ucode" /* NIC configuration for 5000 series */ static void iwl5000_nic_config(struct iwl_priv *priv) { unsigned long flags; - - iwl_rf_config(priv); + u16 radio_cfg; spin_lock_irqsave(&priv->lock, flags); + radio_cfg = iwl_eeprom_query16(priv, EEPROM_RADIO_CONFIG); + + /* write radio config values to register */ + if (EEPROM_RF_CFG_TYPE_MSK(radio_cfg) < EEPROM_RF_CONFIG_TYPE_MAX) + iwl_set_bit(priv, CSR_HW_IF_CONFIG_REG, + EEPROM_RF_CFG_TYPE_MSK(radio_cfg) | + EEPROM_RF_CFG_STEP_MSK(radio_cfg) | + EEPROM_RF_CFG_DASH_MSK(radio_cfg)); + + /* set CSR_HW_CONFIG_REG for uCode use */ + iwl_set_bit(priv, CSR_HW_IF_CONFIG_REG, + CSR_HW_IF_CONFIG_REG_BIT_RADIO_SI | + CSR_HW_IF_CONFIG_REG_BIT_MAC_SI); + /* W/A : NIC is stuck in a reset state after Early PCIe power off * (PCIe power is lost before PERST# is asserted), * causing ME FW to lose ownership and not being able to obtain it back. @@ -169,6 +183,7 @@ static int iwl5000_hw_set_hw_params(struct iwl_priv *priv) priv->hw_params.ht40_channel = BIT(IEEE80211_BAND_2GHZ) | BIT(IEEE80211_BAND_5GHZ); + priv->hw_params.rx_wrt_ptr_reg = FH_RSCSR_CHNL0_WPTR; priv->hw_params.tx_chains_num = num_of_ant(priv->cfg->valid_tx_ant); priv->hw_params.rx_chains_num = num_of_ant(priv->cfg->valid_rx_ant); @@ -213,6 +228,7 @@ static int iwl5150_hw_set_hw_params(struct iwl_priv *priv) priv->hw_params.ht40_channel = BIT(IEEE80211_BAND_2GHZ) | BIT(IEEE80211_BAND_5GHZ); + priv->hw_params.rx_wrt_ptr_reg = FH_RSCSR_CHNL0_WPTR; priv->hw_params.tx_chains_num = num_of_ant(priv->cfg->valid_tx_ant); priv->hw_params.rx_chains_num = num_of_ant(priv->cfg->valid_rx_ant); @@ -345,6 +361,8 @@ static struct iwl_lib_ops iwl5000_lib = { .temp_ops = { .temperature = iwlagn_temperature, }, + .txfifo_flush = iwlagn_txfifo_flush, + .dev_txfifo_flush = iwlagn_dev_txfifo_flush, }; static struct iwl_lib_ops iwl5150_lib = { @@ -373,15 +391,19 @@ static struct iwl_lib_ops iwl5150_lib = { .temp_ops = { .temperature = iwl5150_temperature, }, + .txfifo_flush = iwlagn_txfifo_flush, + .dev_txfifo_flush = iwlagn_dev_txfifo_flush, }; static const struct iwl_ops iwl5000_ops = { .lib = &iwl5000_lib, + .hcmd = &iwlagn_hcmd, .utils = &iwlagn_hcmd_utils, }; static const struct iwl_ops iwl5150_ops = { .lib = &iwl5150_lib, + .hcmd = &iwlagn_hcmd, .utils = &iwlagn_hcmd_utils, }; diff --git a/trunk/drivers/net/wireless/iwlwifi/iwl-6000.c b/trunk/drivers/net/wireless/iwlwifi/iwl-6000.c index 965d010794b4..6e5ce4478490 100644 --- a/trunk/drivers/net/wireless/iwlwifi/iwl-6000.c +++ b/trunk/drivers/net/wireless/iwlwifi/iwl-6000.c @@ -27,6 +27,8 @@ #include #include #include +#include +#include #include #include #include @@ -34,7 +36,6 @@ #include #include #include -#include #include "iwl-eeprom.h" #include "iwl-dev.h" @@ -57,16 +58,16 @@ #define IWL6000G2_UCODE_API_MIN 4 #define IWL6000_FW_PRE "iwlwifi-6000-" -#define IWL6000_MODULE_FIRMWARE(api) IWL6000_FW_PRE __stringify(api) ".ucode" +#define IWL6000_MODULE_FIRMWARE(api) IWL6000_FW_PRE #api ".ucode" #define IWL6050_FW_PRE "iwlwifi-6050-" -#define IWL6050_MODULE_FIRMWARE(api) IWL6050_FW_PRE __stringify(api) ".ucode" +#define IWL6050_MODULE_FIRMWARE(api) IWL6050_FW_PRE #api ".ucode" #define IWL6005_FW_PRE "iwlwifi-6000g2a-" -#define IWL6005_MODULE_FIRMWARE(api) IWL6005_FW_PRE __stringify(api) ".ucode" +#define IWL6005_MODULE_FIRMWARE(api) IWL6005_FW_PRE #api ".ucode" #define IWL6030_FW_PRE "iwlwifi-6000g2b-" -#define IWL6030_MODULE_FIRMWARE(api) IWL6030_FW_PRE __stringify(api) ".ucode" +#define IWL6030_MODULE_FIRMWARE(api) IWL6030_FW_PRE #api ".ucode" static void iwl6000_set_ct_threshold(struct iwl_priv *priv) { @@ -96,7 +97,21 @@ static void iwl6150_additional_nic_config(struct iwl_priv *priv) /* NIC configuration for 6000 series */ static void iwl6000_nic_config(struct iwl_priv *priv) { - iwl_rf_config(priv); + u16 radio_cfg; + + radio_cfg = iwl_eeprom_query16(priv, EEPROM_RADIO_CONFIG); + + /* write radio config values to register */ + if (EEPROM_RF_CFG_TYPE_MSK(radio_cfg) <= EEPROM_RF_CONFIG_TYPE_MAX) + iwl_set_bit(priv, CSR_HW_IF_CONFIG_REG, + EEPROM_RF_CFG_TYPE_MSK(radio_cfg) | + EEPROM_RF_CFG_STEP_MSK(radio_cfg) | + EEPROM_RF_CFG_DASH_MSK(radio_cfg)); + + /* set CSR_HW_CONFIG_REG for uCode use */ + iwl_set_bit(priv, CSR_HW_IF_CONFIG_REG, + CSR_HW_IF_CONFIG_REG_BIT_RADIO_SI | + CSR_HW_IF_CONFIG_REG_BIT_MAC_SI); /* no locking required for register write */ if (priv->cfg->pa_type == IWL_PA_INTERNAL) { @@ -157,6 +172,7 @@ static int iwl6000_hw_set_hw_params(struct iwl_priv *priv) priv->hw_params.ht40_channel = BIT(IEEE80211_BAND_2GHZ) | BIT(IEEE80211_BAND_5GHZ); + priv->hw_params.rx_wrt_ptr_reg = FH_RSCSR_CHNL0_WPTR; priv->hw_params.tx_chains_num = num_of_ant(priv->cfg->valid_tx_ant); if (priv->cfg->rx_with_siso_diversity) @@ -285,6 +301,8 @@ static struct iwl_lib_ops iwl6000_lib = { .temp_ops = { .temperature = iwlagn_temperature, }, + .txfifo_flush = iwlagn_txfifo_flush, + .dev_txfifo_flush = iwlagn_dev_txfifo_flush, }; static struct iwl_lib_ops iwl6030_lib = { @@ -315,6 +333,8 @@ static struct iwl_lib_ops iwl6030_lib = { .temp_ops = { .temperature = iwlagn_temperature, }, + .txfifo_flush = iwlagn_txfifo_flush, + .dev_txfifo_flush = iwlagn_dev_txfifo_flush, }; static struct iwl_nic_ops iwl6050_nic_ops = { @@ -327,23 +347,27 @@ static struct iwl_nic_ops iwl6150_nic_ops = { static const struct iwl_ops iwl6000_ops = { .lib = &iwl6000_lib, + .hcmd = &iwlagn_hcmd, .utils = &iwlagn_hcmd_utils, }; static const struct iwl_ops iwl6050_ops = { .lib = &iwl6000_lib, + .hcmd = &iwlagn_hcmd, .utils = &iwlagn_hcmd_utils, .nic = &iwl6050_nic_ops, }; static const struct iwl_ops iwl6150_ops = { .lib = &iwl6000_lib, + .hcmd = &iwlagn_hcmd, .utils = &iwlagn_hcmd_utils, .nic = &iwl6150_nic_ops, }; static const struct iwl_ops iwl6030_ops = { .lib = &iwl6030_lib, + .hcmd = &iwlagn_bt_hcmd, .utils = &iwlagn_hcmd_utils, }; diff --git a/trunk/drivers/net/wireless/iwlwifi/iwl-agn-eeprom.c b/trunk/drivers/net/wireless/iwlwifi/iwl-agn-eeprom.c index 7745816eaff4..2ef9448b1c20 100644 --- a/trunk/drivers/net/wireless/iwlwifi/iwl-agn-eeprom.c +++ b/trunk/drivers/net/wireless/iwlwifi/iwl-agn-eeprom.c @@ -108,16 +108,18 @@ int iwl_eeprom_check_version(struct iwl_priv *priv) int iwl_eeprom_check_sku(struct iwl_priv *priv) { + u16 eeprom_sku; u16 radio_cfg; + eeprom_sku = iwl_eeprom_query16(priv, EEPROM_SKU_CAP); + if (!priv->cfg->sku) { /* not using sku overwrite */ - priv->cfg->sku = iwl_eeprom_query16(priv, EEPROM_SKU_CAP); - if (priv->cfg->sku & EEPROM_SKU_CAP_11N_ENABLE && - !priv->cfg->ht_params) { - IWL_ERR(priv, "Invalid 11n configuration\n"); - return -EINVAL; - } + priv->cfg->sku = + ((eeprom_sku & EEPROM_SKU_CAP_BAND_SELECTION) >> + EEPROM_SKU_CAP_BAND_POS); + if (eeprom_sku & EEPROM_SKU_CAP_11N_ENABLE) + priv->cfg->sku |= IWL_SKU_N; } if (!priv->cfg->sku) { IWL_ERR(priv, "Invalid device sku\n"); diff --git a/trunk/drivers/net/wireless/iwlwifi/iwl-agn-hcmd.c b/trunk/drivers/net/wireless/iwlwifi/iwl-agn-hcmd.c index ce7d4b56d9b2..23eee0ca5b35 100644 --- a/trunk/drivers/net/wireless/iwlwifi/iwl-agn-hcmd.c +++ b/trunk/drivers/net/wireless/iwlwifi/iwl-agn-hcmd.c @@ -111,8 +111,10 @@ static void iwlagn_gain_computation(struct iwl_priv *priv, memset(&cmd, 0, sizeof(cmd)); - iwl_set_calib_hdr(&cmd.hdr, - priv->_agn.phy_calib_chain_noise_gain_cmd); + cmd.hdr.op_code = priv->_agn.phy_calib_chain_noise_gain_cmd; + cmd.hdr.first_group = 0; + cmd.hdr.groups_num = 1; + cmd.hdr.data_valid = 1; cmd.delta_gain_1 = data->delta_gain_code[1]; cmd.delta_gain_2 = data->delta_gain_code[2]; iwl_send_cmd_pdu_async(priv, REPLY_PHY_CALIBRATION_CMD, @@ -142,8 +144,10 @@ static void iwlagn_chain_noise_reset(struct iwl_priv *priv) data->beacon_count = 0; memset(&cmd, 0, sizeof(cmd)); - iwl_set_calib_hdr(&cmd.hdr, - priv->_agn.phy_calib_chain_noise_reset_cmd); + cmd.hdr.op_code = priv->_agn.phy_calib_chain_noise_reset_cmd; + cmd.hdr.first_group = 0; + cmd.hdr.groups_num = 1; + cmd.hdr.data_valid = 1; ret = iwl_send_cmd_pdu(priv, REPLY_PHY_CALIBRATION_CMD, sizeof(cmd), &cmd); if (ret) @@ -205,7 +209,7 @@ static int iwlagn_calc_rssi(struct iwl_priv *priv, return max_rssi - agc - IWLAGN_RSSI_OFFSET; } -int iwlagn_set_pan_params(struct iwl_priv *priv) +static int iwlagn_set_pan_params(struct iwl_priv *priv) { struct iwl_wipan_params_cmd cmd; struct iwl_rxon_context *ctx_bss, *ctx_pan; @@ -297,6 +301,20 @@ int iwlagn_set_pan_params(struct iwl_priv *priv) return ret; } +struct iwl_hcmd_ops iwlagn_hcmd = { + .set_rxon_chain = iwlagn_set_rxon_chain, + .set_tx_ant = iwlagn_send_tx_ant_config, + .send_bt_config = iwl_send_bt_config, + .set_pan_params = iwlagn_set_pan_params, +}; + +struct iwl_hcmd_ops iwlagn_bt_hcmd = { + .set_rxon_chain = iwlagn_set_rxon_chain, + .set_tx_ant = iwlagn_send_tx_ant_config, + .send_bt_config = iwlagn_send_advance_bt_config, + .set_pan_params = iwlagn_set_pan_params, +}; + struct iwl_hcmd_utils_ops iwlagn_hcmd_utils = { .build_addsta_hcmd = iwlagn_build_addsta_hcmd, .gain_computation = iwlagn_gain_computation, diff --git a/trunk/drivers/net/wireless/iwlwifi/iwl-agn-hw.h b/trunk/drivers/net/wireless/iwlwifi/iwl-agn-hw.h index 0e5b842529c4..7bd19f4e66de 100644 --- a/trunk/drivers/net/wireless/iwlwifi/iwl-agn-hw.h +++ b/trunk/drivers/net/wireless/iwlwifi/iwl-agn-hw.h @@ -81,6 +81,13 @@ /* RSSI to dBm */ #define IWLAGN_RSSI_OFFSET 44 +/* PCI registers */ +#define PCI_CFG_RETRY_TIMEOUT 0x041 + +/* PCI register values */ +#define PCI_CFG_LINK_CTRL_VAL_L0S_EN 0x01 +#define PCI_CFG_LINK_CTRL_VAL_L1_EN 0x02 + #define IWLAGN_DEFAULT_TX_RETRY 15 /* Limit range of txpower output target to be between these values */ diff --git a/trunk/drivers/net/wireless/iwlwifi/iwl-agn-ict.c b/trunk/drivers/net/wireless/iwlwifi/iwl-agn-ict.c index f1b40ec1c873..0d5fda44c3a3 100644 --- a/trunk/drivers/net/wireless/iwlwifi/iwl-agn-ict.c +++ b/trunk/drivers/net/wireless/iwlwifi/iwl-agn-ict.c @@ -44,7 +44,7 @@ void iwl_free_isr_ict(struct iwl_priv *priv) { if (priv->_agn.ict_tbl_vir) { - dma_free_coherent(priv->bus.dev, + dma_free_coherent(&priv->pci_dev->dev, (sizeof(u32) * ICT_COUNT) + PAGE_SIZE, priv->_agn.ict_tbl_vir, priv->_agn.ict_tbl_dma); @@ -61,7 +61,7 @@ int iwl_alloc_isr_ict(struct iwl_priv *priv) /* allocate shrared data table */ priv->_agn.ict_tbl_vir = - dma_alloc_coherent(priv->bus.dev, + dma_alloc_coherent(&priv->pci_dev->dev, (sizeof(u32) * ICT_COUNT) + PAGE_SIZE, &priv->_agn.ict_tbl_dma, GFP_KERNEL); if (!priv->_agn.ict_tbl_vir) diff --git a/trunk/drivers/net/wireless/iwlwifi/iwl-agn-lib.c b/trunk/drivers/net/wireless/iwlwifi/iwl-agn-lib.c index 90d366e15d2f..677f73c4c1e3 100644 --- a/trunk/drivers/net/wireless/iwlwifi/iwl-agn-lib.c +++ b/trunk/drivers/net/wireless/iwlwifi/iwl-agn-lib.c @@ -438,7 +438,7 @@ static void iwlagn_rx_reply_tx(struct iwl_priv *priv, if (tx_resp->bt_kill_count && tx_resp->frame_count == 1 && priv->cfg->bt_params && priv->cfg->bt_params->advanced_bt_coexist) { - IWL_DEBUG_COEX(priv, "receive reply tx with bt_kill\n"); + IWL_WARN(priv, "receive reply tx with bt_kill\n"); } iwlagn_tx_status_reply_tx(priv, agg, tx_resp, txq_id, index); @@ -622,12 +622,41 @@ struct iwl_mod_params iwlagn_mod_params = { .amsdu_size_8K = 1, .restart_fw = 1, .plcp_check = true, - .bt_coex_active = true, - .no_sleep_autoadjust = true, - .power_level = IWL_POWER_INDEX_1, /* the rest are 0 by default */ }; +void iwlagn_rx_queue_reset(struct iwl_priv *priv, struct iwl_rx_queue *rxq) +{ + unsigned long flags; + int i; + spin_lock_irqsave(&rxq->lock, flags); + INIT_LIST_HEAD(&rxq->rx_free); + INIT_LIST_HEAD(&rxq->rx_used); + /* Fill the rx_used queue with _all_ of the Rx buffers */ + for (i = 0; i < RX_FREE_BUFFERS + RX_QUEUE_SIZE; i++) { + /* In the reset function, these buffers may have been allocated + * to an SKB, so we need to unmap and free potential storage */ + if (rxq->pool[i].page != NULL) { + pci_unmap_page(priv->pci_dev, rxq->pool[i].page_dma, + PAGE_SIZE << priv->hw_params.rx_page_order, + PCI_DMA_FROMDEVICE); + __iwl_free_pages(priv, rxq->pool[i].page); + rxq->pool[i].page = NULL; + } + list_add_tail(&rxq->pool[i].list, &rxq->rx_used); + } + + for (i = 0; i < RX_QUEUE_SIZE; i++) + rxq->queue[i] = NULL; + + /* Set us so that we have processed and used all buffers, but have + * not restocked the Rx queue with fresh buffers */ + rxq->read = rxq->write = 0; + rxq->write_actual = 0; + rxq->free_count = 0; + spin_unlock_irqrestore(&rxq->lock, flags); +} + int iwlagn_rx_init(struct iwl_priv *priv, struct iwl_rx_queue *rxq) { u32 rb_size; @@ -699,6 +728,7 @@ int iwlagn_hw_nic_init(struct iwl_priv *priv) { unsigned long flags; struct iwl_rx_queue *rxq = &priv->rxq; + int ret; /* nic_init */ spin_lock_irqsave(&priv->lock, flags); @@ -714,7 +744,14 @@ int iwlagn_hw_nic_init(struct iwl_priv *priv) priv->cfg->ops->lib->apm_ops.config(priv); /* Allocate the RX queue, or reset if it is already allocated */ - priv->trans.ops->rx_init(priv); + if (!rxq->bd) { + ret = iwl_rx_queue_alloc(priv); + if (ret) { + IWL_ERR(priv, "Unable to initialize Rx queue\n"); + return -ENOMEM; + } + } else + iwlagn_rx_queue_reset(priv, rxq); iwlagn_rx_replenish(priv); @@ -728,8 +765,12 @@ int iwlagn_hw_nic_init(struct iwl_priv *priv) spin_unlock_irqrestore(&priv->lock, flags); /* Allocate or reset and init all Tx and Command queues */ - if (priv->trans.ops->tx_init(priv)) - return -ENOMEM; + if (!priv->txq) { + ret = iwlagn_txq_ctx_alloc(priv); + if (ret) + return ret; + } else + iwlagn_txq_ctx_reset(priv); if (priv->cfg->base_params->shadow_reg_enable) { /* enable shadow regs in HW */ @@ -870,9 +911,9 @@ void iwlagn_rx_allocate(struct iwl_priv *priv, gfp_t priority) BUG_ON(rxb->page); rxb->page = page; /* Get physical address of the RB */ - rxb->page_dma = dma_map_page(priv->bus.dev, page, 0, + rxb->page_dma = pci_map_page(priv->pci_dev, page, 0, PAGE_SIZE << priv->hw_params.rx_page_order, - DMA_FROM_DEVICE); + PCI_DMA_FROMDEVICE); /* dma address must be no more than 36 bits */ BUG_ON(rxb->page_dma & ~DMA_BIT_MASK(36)); /* and also 256 byte aligned! */ @@ -905,6 +946,32 @@ void iwlagn_rx_replenish_now(struct iwl_priv *priv) iwlagn_rx_queue_restock(priv); } +/* Assumes that the skb field of the buffers in 'pool' is kept accurate. + * If an SKB has been detached, the POOL needs to have its SKB set to NULL + * This free routine walks the list of POOL entries and if SKB is set to + * non NULL it is unmapped and freed + */ +void iwlagn_rx_queue_free(struct iwl_priv *priv, struct iwl_rx_queue *rxq) +{ + int i; + for (i = 0; i < RX_QUEUE_SIZE + RX_FREE_BUFFERS; i++) { + if (rxq->pool[i].page != NULL) { + pci_unmap_page(priv->pci_dev, rxq->pool[i].page_dma, + PAGE_SIZE << priv->hw_params.rx_page_order, + PCI_DMA_FROMDEVICE); + __iwl_free_pages(priv, rxq->pool[i].page); + rxq->pool[i].page = NULL; + } + } + + dma_free_coherent(&priv->pci_dev->dev, 4 * RX_QUEUE_SIZE, rxq->bd, + rxq->bd_dma); + dma_free_coherent(&priv->pci_dev->dev, sizeof(struct iwl_rb_status), + rxq->rb_stts, rxq->rb_stts_dma); + rxq->bd = NULL; + rxq->rb_stts = NULL; +} + int iwlagn_rxq_stop(struct iwl_priv *priv) { @@ -1366,14 +1433,17 @@ int iwlagn_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif) /* set scan bit here for PAN params */ set_bit(STATUS_SCAN_HW, &priv->status); - ret = iwlagn_set_pan_params(priv); - if (ret) - return ret; + if (priv->cfg->ops->hcmd->set_pan_params) { + ret = priv->cfg->ops->hcmd->set_pan_params(priv); + if (ret) + return ret; + } ret = iwl_send_cmd_sync(priv, &cmd); if (ret) { clear_bit(STATUS_SCAN_HW, &priv->status); - iwlagn_set_pan_params(priv); + if (priv->cfg->ops->hcmd->set_pan_params) + priv->cfg->ops->hcmd->set_pan_params(priv); } return ret; @@ -1458,18 +1528,9 @@ int iwlagn_txfifo_flush(struct iwl_priv *priv, u16 flush_control) might_sleep(); memset(&flush_cmd, 0, sizeof(flush_cmd)); - if (flush_control & BIT(IWL_RXON_CTX_BSS)) - flush_cmd.fifo_control = IWL_SCD_VO_MSK | IWL_SCD_VI_MSK | - IWL_SCD_BE_MSK | IWL_SCD_BK_MSK | - IWL_SCD_MGMT_MSK; - if ((flush_control & BIT(IWL_RXON_CTX_PAN)) && - (priv->valid_contexts != BIT(IWL_RXON_CTX_BSS))) - flush_cmd.fifo_control |= IWL_PAN_SCD_VO_MSK | - IWL_PAN_SCD_VI_MSK | IWL_PAN_SCD_BE_MSK | - IWL_PAN_SCD_BK_MSK | IWL_PAN_SCD_MGMT_MSK | - IWL_PAN_SCD_MULTICAST_MSK; - - if (priv->cfg->sku & EEPROM_SKU_CAP_11N_ENABLE) + flush_cmd.fifo_control = IWL_TX_FIFO_VO_MSK | IWL_TX_FIFO_VI_MSK | + IWL_TX_FIFO_BE_MSK | IWL_TX_FIFO_BK_MSK; + if (priv->cfg->sku & IWL_SKU_N) flush_cmd.fifo_control |= IWL_AGG_TX_QUEUE_MSK; IWL_DEBUG_INFO(priv, "fifo queue control: 0X%x\n", @@ -1483,7 +1544,7 @@ void iwlagn_dev_txfifo_flush(struct iwl_priv *priv, u16 flush_control) { mutex_lock(&priv->mutex); ieee80211_stop_queues(priv->hw); - if (iwlagn_txfifo_flush(priv, IWL_DROP_ALL)) { + if (priv->cfg->ops->lib->txfifo_flush(priv, IWL_DROP_ALL)) { IWL_ERR(priv, "flush request fail\n"); goto done; } @@ -1638,8 +1699,7 @@ void iwlagn_send_advance_bt_config(struct iwl_priv *priv) * (might be in monitor mode), or the interface is in * IBSS mode (no proper uCode support for coex then). */ - if (!iwlagn_mod_params.bt_coex_active || - priv->iw_mode == NL80211_IFTYPE_ADHOC) { + if (!bt_coex_active || priv->iw_mode == NL80211_IFTYPE_ADHOC) { basic.flags = IWLAGN_BT_FLAG_COEX_MODE_DISABLED; } else { basic.flags = IWLAGN_BT_FLAG_COEX_MODE_3W << @@ -1650,7 +1710,7 @@ void iwlagn_send_advance_bt_config(struct iwl_priv *priv) if (priv->bt_ch_announce) basic.flags |= IWLAGN_BT_FLAG_CHANNEL_INHIBITION; - IWL_DEBUG_COEX(priv, "BT coex flag: 0X%x\n", basic.flags); + IWL_DEBUG_INFO(priv, "BT coex flag: 0X%x\n", basic.flags); } priv->bt_enable_flag = basic.flags; if (priv->bt_full_concurrent) @@ -1660,7 +1720,7 @@ void iwlagn_send_advance_bt_config(struct iwl_priv *priv) memcpy(basic.bt3_lookup_table, iwlagn_def_3w_lookup, sizeof(iwlagn_def_3w_lookup)); - IWL_DEBUG_COEX(priv, "BT coex %s in %s mode\n", + IWL_DEBUG_INFO(priv, "BT coex %s in %s mode\n", basic.flags ? "active" : "disabled", priv->bt_full_concurrent ? "full concurrency" : "3-wire"); @@ -1698,7 +1758,7 @@ static void iwlagn_bt_traffic_change_work(struct work_struct *work) * coex profile notifications. Ignore that since only bad consequence * can be not matching debug print with actual state. */ - IWL_DEBUG_COEX(priv, "BT traffic load changes: %d\n", + IWL_DEBUG_INFO(priv, "BT traffic load changes: %d\n", priv->bt_traffic_load); switch (priv->bt_traffic_load) { @@ -1750,7 +1810,7 @@ static void iwlagn_bt_traffic_change_work(struct work_struct *work) static void iwlagn_print_uartmsg(struct iwl_priv *priv, struct iwl_bt_uart_msg *uart_msg) { - IWL_DEBUG_COEX(priv, "Message Type = 0x%X, SSN = 0x%X, " + IWL_DEBUG_NOTIF(priv, "Message Type = 0x%X, SSN = 0x%X, " "Update Req = 0x%X", (BT_UART_MSG_FRAME1MSGTYPE_MSK & uart_msg->frame1) >> BT_UART_MSG_FRAME1MSGTYPE_POS, @@ -1759,7 +1819,7 @@ static void iwlagn_print_uartmsg(struct iwl_priv *priv, (BT_UART_MSG_FRAME1UPDATEREQ_MSK & uart_msg->frame1) >> BT_UART_MSG_FRAME1UPDATEREQ_POS); - IWL_DEBUG_COEX(priv, "Open connections = 0x%X, Traffic load = 0x%X, " + IWL_DEBUG_NOTIF(priv, "Open connections = 0x%X, Traffic load = 0x%X, " "Chl_SeqN = 0x%X, In band = 0x%X", (BT_UART_MSG_FRAME2OPENCONNECTIONS_MSK & uart_msg->frame2) >> BT_UART_MSG_FRAME2OPENCONNECTIONS_POS, @@ -1770,7 +1830,7 @@ static void iwlagn_print_uartmsg(struct iwl_priv *priv, (BT_UART_MSG_FRAME2INBAND_MSK & uart_msg->frame2) >> BT_UART_MSG_FRAME2INBAND_POS); - IWL_DEBUG_COEX(priv, "SCO/eSCO = 0x%X, Sniff = 0x%X, A2DP = 0x%X, " + IWL_DEBUG_NOTIF(priv, "SCO/eSCO = 0x%X, Sniff = 0x%X, A2DP = 0x%X, " "ACL = 0x%X, Master = 0x%X, OBEX = 0x%X", (BT_UART_MSG_FRAME3SCOESCO_MSK & uart_msg->frame3) >> BT_UART_MSG_FRAME3SCOESCO_POS, @@ -1785,11 +1845,11 @@ static void iwlagn_print_uartmsg(struct iwl_priv *priv, (BT_UART_MSG_FRAME3OBEX_MSK & uart_msg->frame3) >> BT_UART_MSG_FRAME3OBEX_POS); - IWL_DEBUG_COEX(priv, "Idle duration = 0x%X", + IWL_DEBUG_NOTIF(priv, "Idle duration = 0x%X", (BT_UART_MSG_FRAME4IDLEDURATION_MSK & uart_msg->frame4) >> BT_UART_MSG_FRAME4IDLEDURATION_POS); - IWL_DEBUG_COEX(priv, "Tx Activity = 0x%X, Rx Activity = 0x%X, " + IWL_DEBUG_NOTIF(priv, "Tx Activity = 0x%X, Rx Activity = 0x%X, " "eSCO Retransmissions = 0x%X", (BT_UART_MSG_FRAME5TXACTIVITY_MSK & uart_msg->frame5) >> BT_UART_MSG_FRAME5TXACTIVITY_POS, @@ -1798,13 +1858,13 @@ static void iwlagn_print_uartmsg(struct iwl_priv *priv, (BT_UART_MSG_FRAME5ESCORETRANSMIT_MSK & uart_msg->frame5) >> BT_UART_MSG_FRAME5ESCORETRANSMIT_POS); - IWL_DEBUG_COEX(priv, "Sniff Interval = 0x%X, Discoverable = 0x%X", + IWL_DEBUG_NOTIF(priv, "Sniff Interval = 0x%X, Discoverable = 0x%X", (BT_UART_MSG_FRAME6SNIFFINTERVAL_MSK & uart_msg->frame6) >> BT_UART_MSG_FRAME6SNIFFINTERVAL_POS, (BT_UART_MSG_FRAME6DISCOVERABLE_MSK & uart_msg->frame6) >> BT_UART_MSG_FRAME6DISCOVERABLE_POS); - IWL_DEBUG_COEX(priv, "Sniff Activity = 0x%X, Page = " + IWL_DEBUG_NOTIF(priv, "Sniff Activity = 0x%X, Page = " "0x%X, Inquiry = 0x%X, Connectable = 0x%X", (BT_UART_MSG_FRAME7SNIFFACTIVITY_MSK & uart_msg->frame7) >> BT_UART_MSG_FRAME7SNIFFACTIVITY_POS, @@ -1854,10 +1914,10 @@ void iwlagn_bt_coex_profile_notif(struct iwl_priv *priv, return; } - IWL_DEBUG_COEX(priv, "BT Coex notification:\n"); - IWL_DEBUG_COEX(priv, " status: %d\n", coex->bt_status); - IWL_DEBUG_COEX(priv, " traffic load: %d\n", coex->bt_traffic_load); - IWL_DEBUG_COEX(priv, " CI compliance: %d\n", + IWL_DEBUG_NOTIF(priv, "BT Coex notification:\n"); + IWL_DEBUG_NOTIF(priv, " status: %d\n", coex->bt_status); + IWL_DEBUG_NOTIF(priv, " traffic load: %d\n", coex->bt_traffic_load); + IWL_DEBUG_NOTIF(priv, " CI compliance: %d\n", coex->bt_ci_compliance); iwlagn_print_uartmsg(priv, uart_msg); @@ -2255,8 +2315,7 @@ int iwlagn_start_device(struct iwl_priv *priv) { int ret; - if ((priv->cfg->sku & EEPROM_SKU_CAP_AMT_ENABLE) && - iwl_prepare_card_hw(priv)) { + if (iwl_prepare_card_hw(priv)) { IWL_WARN(priv, "Exit HW not ready\n"); return -EIO; } diff --git a/trunk/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c b/trunk/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c index c6bb73a66d9f..a7c66c4e5f2a 100644 --- a/trunk/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c +++ b/trunk/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c @@ -210,8 +210,6 @@ static int iwlagn_rxon_disconn(struct iwl_priv *priv, * keys, so we have to restore those afterwards. */ iwl_clear_ucode_stations(priv, ctx); - /* update -- might need P2P now */ - iwl_update_bcast_station(priv, ctx); iwl_restore_stations(priv, ctx); ret = iwl_restore_default_wep_keys(priv, ctx); if (ret) { @@ -436,9 +434,11 @@ int iwlagn_commit_rxon(struct iwl_priv *priv, struct iwl_rxon_context *ctx) if (ret) return ret; - ret = iwlagn_set_pan_params(priv); - if (ret) - return ret; + if (priv->cfg->ops->hcmd->set_pan_params) { + ret = priv->cfg->ops->hcmd->set_pan_params(priv); + if (ret) + return ret; + } if (new_assoc) return iwlagn_rxon_connect(priv, ctx); @@ -481,8 +481,9 @@ int iwlagn_mac_config(struct ieee80211_hw *hw, u32 changed) * set up the SM PS mode to OFF if an HT channel is * configured. */ - for_each_context(priv, ctx) - iwlagn_set_rxon_chain(priv, ctx); + if (priv->cfg->ops->hcmd->set_rxon_chain) + for_each_context(priv, ctx) + priv->cfg->ops->hcmd->set_rxon_chain(priv, ctx); } if (changed & IEEE80211_CONF_CHANGE_CHANNEL) { @@ -738,7 +739,8 @@ void iwlagn_bss_info_changed(struct ieee80211_hw *hw, iwl_set_rxon_ht(priv, &priv->current_ht_config); } - iwlagn_set_rxon_chain(priv, ctx); + if (priv->cfg->ops->hcmd->set_rxon_chain) + priv->cfg->ops->hcmd->set_rxon_chain(priv, ctx); if (bss_conf->use_cts_prot && (priv->band != IEEE80211_BAND_5GHZ)) ctx->staging.flags |= RXON_FLG_TGG_PROTECT_MSK; @@ -817,5 +819,6 @@ void iwlagn_post_scan(struct iwl_priv *priv) if (memcmp(&ctx->staging, &ctx->active, sizeof(ctx->staging))) iwlagn_commit_rxon(priv, ctx); - iwlagn_set_pan_params(priv); + if (priv->cfg->ops->hcmd->set_pan_params) + priv->cfg->ops->hcmd->set_pan_params(priv); } diff --git a/trunk/drivers/net/wireless/iwlwifi/iwl-agn-sta.c b/trunk/drivers/net/wireless/iwlwifi/iwl-agn-sta.c index 9b32f83f0b7f..0bd722cee5ae 100644 --- a/trunk/drivers/net/wireless/iwlwifi/iwl-agn-sta.c +++ b/trunk/drivers/net/wireless/iwlwifi/iwl-agn-sta.c @@ -35,7 +35,7 @@ #include "iwl-agn.h" static struct iwl_link_quality_cmd * -iwl_sta_alloc_lq(struct iwl_priv *priv, struct iwl_rxon_context *ctx, u8 sta_id) +iwl_sta_alloc_lq(struct iwl_priv *priv, u8 sta_id) { int i, r; struct iwl_link_quality_cmd *link_cmd; @@ -47,15 +47,10 @@ iwl_sta_alloc_lq(struct iwl_priv *priv, struct iwl_rxon_context *ctx, u8 sta_id) IWL_ERR(priv, "Unable to allocate memory for LQ cmd.\n"); return NULL; } - - lockdep_assert_held(&priv->mutex); - /* Set up the rate scaling to start at selected rate, fall back * all the way down to 1M in IEEE order, and then spin on 1M */ if (priv->band == IEEE80211_BAND_5GHZ) r = IWL_RATE_6M_INDEX; - else if (ctx && ctx->vif && ctx->vif->p2p) - r = IWL_RATE_6M_INDEX; else r = IWL_RATE_1M_INDEX; @@ -120,7 +115,7 @@ int iwlagn_add_bssid_station(struct iwl_priv *priv, struct iwl_rxon_context *ctx spin_unlock_irqrestore(&priv->sta_lock, flags); /* Set up default rate scaling table in device's station table */ - link_cmd = iwl_sta_alloc_lq(priv, ctx, sta_id); + link_cmd = iwl_sta_alloc_lq(priv, sta_id); if (!link_cmd) { IWL_ERR(priv, "Unable to initialize rate scaling for station %pM.\n", addr); @@ -559,7 +554,7 @@ int iwlagn_alloc_bcast_station(struct iwl_priv *priv, priv->stations[sta_id].used |= IWL_STA_BCAST; spin_unlock_irqrestore(&priv->sta_lock, flags); - link_cmd = iwl_sta_alloc_lq(priv, ctx, sta_id); + link_cmd = iwl_sta_alloc_lq(priv, sta_id); if (!link_cmd) { IWL_ERR(priv, "Unable to initialize rate scaling for bcast station.\n"); @@ -579,14 +574,14 @@ int iwlagn_alloc_bcast_station(struct iwl_priv *priv, * Only used by iwlagn. Placed here to have all bcast station management * code together. */ -int iwl_update_bcast_station(struct iwl_priv *priv, - struct iwl_rxon_context *ctx) +static int iwl_update_bcast_station(struct iwl_priv *priv, + struct iwl_rxon_context *ctx) { unsigned long flags; struct iwl_link_quality_cmd *link_cmd; u8 sta_id = ctx->bcast_sta_id; - link_cmd = iwl_sta_alloc_lq(priv, ctx, sta_id); + link_cmd = iwl_sta_alloc_lq(priv, sta_id); if (!link_cmd) { IWL_ERR(priv, "Unable to initialize rate scaling for bcast station.\n"); return -ENOMEM; diff --git a/trunk/drivers/net/wireless/iwlwifi/iwl-agn-tt.c b/trunk/drivers/net/wireless/iwlwifi/iwl-agn-tt.c index f501d742984c..348f74f1c8e8 100644 --- a/trunk/drivers/net/wireless/iwlwifi/iwl-agn-tt.c +++ b/trunk/drivers/net/wireless/iwlwifi/iwl-agn-tt.c @@ -198,7 +198,7 @@ static void iwl_tt_check_exit_ct_kill(unsigned long data) /* Reschedule the ct_kill timer to occur in * CT_KILL_EXIT_DURATION seconds to ensure we get a * thermal update */ - IWL_DEBUG_TEMP(priv, "schedule ct_kill exit timer\n"); + IWL_DEBUG_POWER(priv, "schedule ct_kill exit timer\n"); mod_timer(&priv->thermal_throttle.ct_kill_exit_tm, jiffies + CT_KILL_EXIT_DURATION * HZ); } @@ -208,15 +208,15 @@ static void iwl_perform_ct_kill_task(struct iwl_priv *priv, bool stop) { if (stop) { - IWL_DEBUG_TEMP(priv, "Stop all queues\n"); + IWL_DEBUG_POWER(priv, "Stop all queues\n"); if (priv->mac80211_registered) ieee80211_stop_queues(priv->hw); - IWL_DEBUG_TEMP(priv, + IWL_DEBUG_POWER(priv, "Schedule 5 seconds CT_KILL Timer\n"); mod_timer(&priv->thermal_throttle.ct_kill_exit_tm, jiffies + CT_KILL_EXIT_DURATION * HZ); } else { - IWL_DEBUG_TEMP(priv, "Wake all queues\n"); + IWL_DEBUG_POWER(priv, "Wake all queues\n"); if (priv->mac80211_registered) ieee80211_wake_queues(priv->hw); } @@ -232,7 +232,7 @@ static void iwl_tt_ready_for_ct_kill(unsigned long data) /* temperature timer expired, ready to go into CT_KILL state */ if (tt->state != IWL_TI_CT_KILL) { - IWL_DEBUG_TEMP(priv, "entering CT_KILL state when " + IWL_DEBUG_POWER(priv, "entering CT_KILL state when " "temperature timer expired\n"); tt->state = IWL_TI_CT_KILL; set_bit(STATUS_CT_KILL, &priv->status); @@ -242,7 +242,7 @@ static void iwl_tt_ready_for_ct_kill(unsigned long data) static void iwl_prepare_ct_kill_task(struct iwl_priv *priv) { - IWL_DEBUG_TEMP(priv, "Prepare to enter IWL_TI_CT_KILL\n"); + IWL_DEBUG_POWER(priv, "Prepare to enter IWL_TI_CT_KILL\n"); /* make request to retrieve statistics information */ iwl_send_statistics_request(priv, CMD_SYNC, false); /* Reschedule the ct_kill wait timer */ @@ -273,7 +273,7 @@ static void iwl_legacy_tt_handler(struct iwl_priv *priv, s32 temp, bool force) (temp > tt->tt_previous_temp) && ((temp - tt->tt_previous_temp) > IWL_TT_INCREASE_MARGIN)) { - IWL_DEBUG_TEMP(priv, + IWL_DEBUG_POWER(priv, "Temperature increase %d degree Celsius\n", (temp - tt->tt_previous_temp)); } @@ -338,9 +338,9 @@ static void iwl_legacy_tt_handler(struct iwl_priv *priv, s32 temp, bool force) } else if (old_state == IWL_TI_CT_KILL && tt->state != IWL_TI_CT_KILL) iwl_perform_ct_kill_task(priv, false); - IWL_DEBUG_TEMP(priv, "Temperature state changed %u\n", + IWL_DEBUG_POWER(priv, "Temperature state changed %u\n", tt->state); - IWL_DEBUG_TEMP(priv, "Power Index change to %u\n", + IWL_DEBUG_POWER(priv, "Power Index change to %u\n", tt->tt_power_mode); } mutex_unlock(&priv->mutex); @@ -397,7 +397,7 @@ static void iwl_advance_tt_handler(struct iwl_priv *priv, s32 temp, bool force) (temp > tt->tt_previous_temp) && ((temp - tt->tt_previous_temp) > IWL_TT_INCREASE_MARGIN)) { - IWL_DEBUG_TEMP(priv, + IWL_DEBUG_POWER(priv, "Temperature increase %d " "degree Celsius\n", (temp - tt->tt_previous_temp)); @@ -467,13 +467,13 @@ static void iwl_advance_tt_handler(struct iwl_priv *priv, s32 temp, bool force) set_bit(STATUS_CT_KILL, &priv->status); tt->state = old_state; } else { - IWL_DEBUG_TEMP(priv, + IWL_DEBUG_POWER(priv, "Thermal Throttling to new state: %u\n", tt->state); if (old_state != IWL_TI_CT_KILL && tt->state == IWL_TI_CT_KILL) { if (force) { - IWL_DEBUG_TEMP(priv, + IWL_DEBUG_POWER(priv, "Enter IWL_TI_CT_KILL\n"); set_bit(STATUS_CT_KILL, &priv->status); iwl_perform_ct_kill_task(priv, true); @@ -483,7 +483,7 @@ static void iwl_advance_tt_handler(struct iwl_priv *priv, s32 temp, bool force) } } else if (old_state == IWL_TI_CT_KILL && tt->state != IWL_TI_CT_KILL) { - IWL_DEBUG_TEMP(priv, "Exit IWL_TI_CT_KILL\n"); + IWL_DEBUG_POWER(priv, "Exit IWL_TI_CT_KILL\n"); iwl_perform_ct_kill_task(priv, false); } } @@ -568,7 +568,7 @@ void iwl_tt_enter_ct_kill(struct iwl_priv *priv) if (test_bit(STATUS_EXIT_PENDING, &priv->status)) return; - IWL_DEBUG_TEMP(priv, "Queueing critical temperature enter.\n"); + IWL_DEBUG_POWER(priv, "Queueing critical temperature enter.\n"); queue_work(priv->workqueue, &priv->ct_enter); } @@ -577,7 +577,7 @@ void iwl_tt_exit_ct_kill(struct iwl_priv *priv) if (test_bit(STATUS_EXIT_PENDING, &priv->status)) return; - IWL_DEBUG_TEMP(priv, "Queueing critical temperature exit.\n"); + IWL_DEBUG_POWER(priv, "Queueing critical temperature exit.\n"); queue_work(priv->workqueue, &priv->ct_exit); } @@ -603,7 +603,7 @@ void iwl_tt_handler(struct iwl_priv *priv) if (test_bit(STATUS_EXIT_PENDING, &priv->status)) return; - IWL_DEBUG_TEMP(priv, "Queueing thermal throttling work.\n"); + IWL_DEBUG_POWER(priv, "Queueing thermal throttling work.\n"); queue_work(priv->workqueue, &priv->tt_work); } @@ -618,7 +618,7 @@ void iwl_tt_initialize(struct iwl_priv *priv) int size = sizeof(struct iwl_tt_trans) * (IWL_TI_STATE_MAX - 1); struct iwl_tt_trans *transaction; - IWL_DEBUG_TEMP(priv, "Initialize Thermal Throttling\n"); + IWL_DEBUG_POWER(priv, "Initialize Thermal Throttling\n"); memset(tt, 0, sizeof(struct iwl_tt_mgmt)); @@ -638,7 +638,7 @@ void iwl_tt_initialize(struct iwl_priv *priv) INIT_WORK(&priv->ct_exit, iwl_bg_ct_exit); if (priv->cfg->base_params->adv_thermal_throttle) { - IWL_DEBUG_TEMP(priv, "Advanced Thermal Throttling\n"); + IWL_DEBUG_POWER(priv, "Advanced Thermal Throttling\n"); tt->restriction = kzalloc(sizeof(struct iwl_tt_restriction) * IWL_TI_STATE_MAX, GFP_KERNEL); tt->transaction = kzalloc(sizeof(struct iwl_tt_trans) * @@ -671,7 +671,7 @@ void iwl_tt_initialize(struct iwl_priv *priv) priv->thermal_throttle.advanced_tt = true; } } else { - IWL_DEBUG_TEMP(priv, "Legacy Thermal Throttling\n"); + IWL_DEBUG_POWER(priv, "Legacy Thermal Throttling\n"); priv->thermal_throttle.advanced_tt = false; } } diff --git a/trunk/drivers/net/wireless/iwlwifi/iwl-agn-tx.c b/trunk/drivers/net/wireless/iwlwifi/iwl-agn-tx.c index c05a8d9fbd2e..8bd48f61a9f5 100644 --- a/trunk/drivers/net/wireless/iwlwifi/iwl-agn-tx.c +++ b/trunk/drivers/net/wireless/iwlwifi/iwl-agn-tx.c @@ -716,10 +716,10 @@ int iwlagn_tx_skb(struct iwl_priv *priv, struct sk_buff *skb) /* Physical address of this Tx command's header (not MAC header!), * within command buffer array. */ - txcmd_phys = dma_map_single(priv->bus.dev, + txcmd_phys = pci_map_single(priv->pci_dev, &out_cmd->hdr, firstlen, - DMA_BIDIRECTIONAL); - if (unlikely(dma_mapping_error(priv->bus.dev, txcmd_phys))) + PCI_DMA_BIDIRECTIONAL); + if (unlikely(pci_dma_mapping_error(priv->pci_dev, txcmd_phys))) goto drop_unlock_sta; dma_unmap_addr_set(out_meta, mapping, txcmd_phys); dma_unmap_len_set(out_meta, len, firstlen); @@ -735,13 +735,13 @@ int iwlagn_tx_skb(struct iwl_priv *priv, struct sk_buff *skb) * if any (802.11 null frames have no payload). */ secondlen = skb->len - hdr_len; if (secondlen > 0) { - phys_addr = dma_map_single(priv->bus.dev, skb->data + hdr_len, - secondlen, DMA_TO_DEVICE); - if (unlikely(dma_mapping_error(priv->bus.dev, phys_addr))) { - dma_unmap_single(priv->bus.dev, + phys_addr = pci_map_single(priv->pci_dev, skb->data + hdr_len, + secondlen, PCI_DMA_TODEVICE); + if (unlikely(pci_dma_mapping_error(priv->pci_dev, phys_addr))) { + pci_unmap_single(priv->pci_dev, dma_unmap_addr(out_meta, mapping), dma_unmap_len(out_meta, len), - DMA_BIDIRECTIONAL); + PCI_DMA_BIDIRECTIONAL); goto drop_unlock_sta; } } @@ -764,8 +764,8 @@ int iwlagn_tx_skb(struct iwl_priv *priv, struct sk_buff *skb) offsetof(struct iwl_tx_cmd, scratch); /* take back ownership of DMA buffer to enable update */ - dma_sync_single_for_cpu(priv->bus.dev, txcmd_phys, firstlen, - DMA_BIDIRECTIONAL); + pci_dma_sync_single_for_cpu(priv->pci_dev, txcmd_phys, + firstlen, PCI_DMA_BIDIRECTIONAL); tx_cmd->dram_lsb_ptr = cpu_to_le32(scratch_phys); tx_cmd->dram_msb_ptr = iwl_get_dma_hi_addr(scratch_phys); @@ -780,8 +780,8 @@ int iwlagn_tx_skb(struct iwl_priv *priv, struct sk_buff *skb) iwlagn_txq_update_byte_cnt_tbl(priv, txq, le16_to_cpu(tx_cmd->len)); - dma_sync_single_for_device(priv->bus.dev, txcmd_phys, firstlen, - DMA_BIDIRECTIONAL); + pci_dma_sync_single_for_device(priv->pci_dev, txcmd_phys, + firstlen, PCI_DMA_BIDIRECTIONAL); trace_iwlwifi_dev_tx(priv, &((struct iwl_tfd *)txq->tfds)[txq->q.write_ptr], @@ -834,8 +834,8 @@ int iwlagn_tx_skb(struct iwl_priv *priv, struct sk_buff *skb) static inline int iwlagn_alloc_dma_ptr(struct iwl_priv *priv, struct iwl_dma_ptr *ptr, size_t size) { - ptr->addr = dma_alloc_coherent(priv->bus.dev, size, - &ptr->dma, GFP_KERNEL); + ptr->addr = dma_alloc_coherent(&priv->pci_dev->dev, size, &ptr->dma, + GFP_KERNEL); if (!ptr->addr) return -ENOMEM; ptr->size = size; @@ -848,7 +848,7 @@ static inline void iwlagn_free_dma_ptr(struct iwl_priv *priv, if (unlikely(!ptr->addr)) return; - dma_free_coherent(priv->bus.dev, ptr->size, ptr->addr, ptr->dma); + dma_free_coherent(&priv->pci_dev->dev, ptr->size, ptr->addr, ptr->dma); memset(ptr, 0, sizeof(*ptr)); } @@ -877,6 +877,96 @@ void iwlagn_hw_txq_ctx_free(struct iwl_priv *priv) iwl_free_txq_mem(priv); } +/** + * iwlagn_txq_ctx_alloc - allocate TX queue context + * Allocate all Tx DMA structures and initialize them + * + * @param priv + * @return error code + */ +int iwlagn_txq_ctx_alloc(struct iwl_priv *priv) +{ + int ret; + int txq_id, slots_num; + unsigned long flags; + + /* Free all tx/cmd queues and keep-warm buffer */ + iwlagn_hw_txq_ctx_free(priv); + + ret = iwlagn_alloc_dma_ptr(priv, &priv->scd_bc_tbls, + priv->hw_params.scd_bc_tbls_size); + if (ret) { + IWL_ERR(priv, "Scheduler BC Table allocation failed\n"); + goto error_bc_tbls; + } + /* Alloc keep-warm buffer */ + ret = iwlagn_alloc_dma_ptr(priv, &priv->kw, IWL_KW_SIZE); + if (ret) { + IWL_ERR(priv, "Keep Warm allocation failed\n"); + goto error_kw; + } + + /* allocate tx queue structure */ + ret = iwl_alloc_txq_mem(priv); + if (ret) + goto error; + + spin_lock_irqsave(&priv->lock, flags); + + /* Turn off all Tx DMA fifos */ + iwlagn_txq_set_sched(priv, 0); + + /* Tell NIC where to find the "keep warm" buffer */ + iwl_write_direct32(priv, FH_KW_MEM_ADDR_REG, priv->kw.dma >> 4); + + spin_unlock_irqrestore(&priv->lock, flags); + + /* Alloc and init all Tx queues, including the command queue (#4/#9) */ + for (txq_id = 0; txq_id < priv->hw_params.max_txq_num; txq_id++) { + slots_num = (txq_id == priv->cmd_queue) ? + TFD_CMD_SLOTS : TFD_TX_CMD_SLOTS; + ret = iwl_tx_queue_init(priv, &priv->txq[txq_id], slots_num, + txq_id); + if (ret) { + IWL_ERR(priv, "Tx %d queue init failed\n", txq_id); + goto error; + } + } + + return ret; + + error: + iwlagn_hw_txq_ctx_free(priv); + iwlagn_free_dma_ptr(priv, &priv->kw); + error_kw: + iwlagn_free_dma_ptr(priv, &priv->scd_bc_tbls); + error_bc_tbls: + return ret; +} + +void iwlagn_txq_ctx_reset(struct iwl_priv *priv) +{ + int txq_id, slots_num; + unsigned long flags; + + spin_lock_irqsave(&priv->lock, flags); + + /* Turn off all Tx DMA fifos */ + iwlagn_txq_set_sched(priv, 0); + + /* Tell NIC where to find the "keep warm" buffer */ + iwl_write_direct32(priv, FH_KW_MEM_ADDR_REG, priv->kw.dma >> 4); + + spin_unlock_irqrestore(&priv->lock, flags); + + /* Alloc and init all Tx queues, including the command queue (#4) */ + for (txq_id = 0; txq_id < priv->hw_params.max_txq_num; txq_id++) { + slots_num = txq_id == priv->cmd_queue ? + TFD_CMD_SLOTS : TFD_TX_CMD_SLOTS; + iwl_tx_queue_reset(priv, &priv->txq[txq_id], slots_num, txq_id); + } +} + /** * iwlagn_txq_ctx_stop - Stop all Tx DMA channels */ diff --git a/trunk/drivers/net/wireless/iwlwifi/iwl-agn-ucode.c b/trunk/drivers/net/wireless/iwlwifi/iwl-agn-ucode.c index 2043c8b3139b..97de5d9de67b 100644 --- a/trunk/drivers/net/wireless/iwlwifi/iwl-agn-ucode.c +++ b/trunk/drivers/net/wireless/iwlwifi/iwl-agn-ucode.c @@ -143,7 +143,7 @@ static int iwlagn_load_section(struct iwl_priv *priv, const char *name, FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_DISABLE | FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_ENDTFD); - IWL_DEBUG_FW(priv, "%s uCode section being loaded...\n", name); + IWL_DEBUG_INFO(priv, "%s uCode section being loaded...\n", name); ret = wait_event_interruptible_timeout(priv->wait_command_queue, priv->ucode_write_complete, 5 * HZ); if (ret == -ERESTARTSYS) { @@ -183,7 +183,10 @@ static int iwlagn_set_Xtal_calib(struct iwl_priv *priv) __le16 *xtal_calib = (__le16 *)iwl_eeprom_query_addr(priv, EEPROM_XTAL); - iwl_set_calib_hdr(&cmd.hdr, IWL_PHY_CALIBRATE_CRYSTAL_FRQ_CMD); + cmd.hdr.op_code = IWL_PHY_CALIBRATE_CRYSTAL_FRQ_CMD; + cmd.hdr.first_group = 0; + cmd.hdr.groups_num = 1; + cmd.hdr.data_valid = 1; cmd.cap_pin1 = le16_to_cpu(xtal_calib[0]); cmd.cap_pin2 = le16_to_cpu(xtal_calib[1]); return iwl_calib_set(&priv->calib_results[IWL_CALIB_XTAL], @@ -194,14 +197,15 @@ static int iwlagn_set_temperature_offset_calib(struct iwl_priv *priv) { struct iwl_calib_temperature_offset_cmd cmd; __le16 *offset_calib = - (__le16 *)iwl_eeprom_query_addr(priv, EEPROM_TEMPERATURE); - - memset(&cmd, 0, sizeof(cmd)); - iwl_set_calib_hdr(&cmd.hdr, IWL_PHY_CALIBRATE_TEMP_OFFSET_CMD); + (__le16 *)iwl_eeprom_query_addr(priv, EEPROM_5000_TEMPERATURE); + cmd.hdr.op_code = IWL_PHY_CALIBRATE_TEMP_OFFSET_CMD; + cmd.hdr.first_group = 0; + cmd.hdr.groups_num = 1; + cmd.hdr.data_valid = 1; cmd.radio_sensor_offset = le16_to_cpu(offset_calib[1]); if (!(cmd.radio_sensor_offset)) cmd.radio_sensor_offset = DEFAULT_RADIO_SENSOR_OFFSET; - + cmd.reserved = 0; IWL_DEBUG_CALIB(priv, "Radio sensor offset: %d\n", cmd.radio_sensor_offset); return iwl_calib_set(&priv->calib_results[IWL_CALIB_TEMP_OFFSET], @@ -386,13 +390,11 @@ static int iwlagn_alive_notify(struct iwl_priv *priv) spin_lock_irqsave(&priv->lock, flags); priv->scd_base_addr = iwl_read_prph(priv, IWLAGN_SCD_SRAM_BASE_ADDR); - a = priv->scd_base_addr + IWLAGN_SCD_CONTEXT_MEM_LOWER_BOUND; - /* reset conext data memory */ - for (; a < priv->scd_base_addr + IWLAGN_SCD_CONTEXT_MEM_UPPER_BOUND; + a = priv->scd_base_addr + IWLAGN_SCD_CONTEXT_DATA_OFFSET; + for (; a < priv->scd_base_addr + IWLAGN_SCD_TX_STTS_BITMAP_OFFSET; a += 4) iwl_write_targ_mem(priv, a, 0); - /* reset tx status memory */ - for (; a < priv->scd_base_addr + IWLAGN_SCD_TX_STTS_MEM_UPPER_BOUND; + for (; a < priv->scd_base_addr + IWLAGN_SCD_TRANSLATE_TBL_OFFSET; a += 4) iwl_write_targ_mem(priv, a, 0); for (; a < priv->scd_base_addr + @@ -506,7 +508,7 @@ static int iwlcore_verify_inst_sparse(struct iwl_priv *priv, u32 val; u32 i; - IWL_DEBUG_FW(priv, "ucode inst image size is %u\n", len); + IWL_DEBUG_INFO(priv, "ucode inst image size is %u\n", len); for (i = 0; i < len; i += 100, image += 100/sizeof(u32)) { /* read data comes through single port, auto-incr addr */ @@ -531,7 +533,7 @@ static void iwl_print_mismatch_inst(struct iwl_priv *priv, u32 offs; int errors = 0; - IWL_DEBUG_FW(priv, "ucode inst image size is %u\n", len); + IWL_DEBUG_INFO(priv, "ucode inst image size is %u\n", len); iwl_write_direct32(priv, HBUS_TARG_MEM_RADDR, IWLAGN_RTC_INST_LOWER_BOUND); @@ -557,7 +559,7 @@ static void iwl_print_mismatch_inst(struct iwl_priv *priv, static int iwl_verify_ucode(struct iwl_priv *priv, struct fw_img *img) { if (!iwlcore_verify_inst_sparse(priv, &img->code)) { - IWL_DEBUG_FW(priv, "uCode is good in inst SRAM\n"); + IWL_DEBUG_INFO(priv, "uCode is good in inst SRAM\n"); return 0; } @@ -581,7 +583,7 @@ static void iwlagn_alive_fn(struct iwl_priv *priv, palive = &pkt->u.alive_frame; - IWL_DEBUG_FW(priv, "Alive ucode status 0x%08X revision " + IWL_DEBUG_INFO(priv, "Alive ucode status 0x%08X revision " "0x%01X 0x%01X\n", palive->is_valid, palive->ver_type, palive->ver_subtype); @@ -600,12 +602,12 @@ static void iwlagn_alive_fn(struct iwl_priv *priv, int iwlagn_load_ucode_wait_alive(struct iwl_priv *priv, struct fw_img *image, - enum iwlagn_ucode_type ucode_type) + int subtype, int alternate_subtype) { struct iwl_notification_wait alive_wait; struct iwlagn_alive_data alive_data; int ret; - enum iwlagn_ucode_type old_type; + enum iwlagn_ucode_subtype old_type; ret = iwlagn_start_device(priv); if (ret) @@ -615,7 +617,7 @@ int iwlagn_load_ucode_wait_alive(struct iwl_priv *priv, iwlagn_alive_fn, &alive_data); old_type = priv->ucode_type; - priv->ucode_type = ucode_type; + priv->ucode_type = subtype; ret = iwlagn_load_given_ucode(priv, image); if (ret) { @@ -643,6 +645,15 @@ int iwlagn_load_ucode_wait_alive(struct iwl_priv *priv, return -EIO; } + if (alive_data.subtype != subtype && + alive_data.subtype != alternate_subtype) { + IWL_ERR(priv, + "Loaded ucode is not expected type (got %d, expected %d)!\n", + alive_data.subtype, subtype); + priv->ucode_type = old_type; + return -EIO; + } + ret = iwl_verify_ucode(priv, image); if (ret) { priv->ucode_type = old_type; @@ -674,7 +685,7 @@ int iwlagn_run_init_ucode(struct iwl_priv *priv) if (!priv->ucode_init.code.len) return 0; - if (priv->ucode_type != IWL_UCODE_NONE) + if (priv->ucode_type != UCODE_SUBTYPE_NONE_LOADED) return 0; iwlagn_init_notification_wait(priv, &calib_wait, @@ -683,7 +694,7 @@ int iwlagn_run_init_ucode(struct iwl_priv *priv) /* Will also start the device */ ret = iwlagn_load_ucode_wait_alive(priv, &priv->ucode_init, - IWL_UCODE_INIT); + UCODE_SUBTYPE_INIT, -1); if (ret) goto error; diff --git a/trunk/drivers/net/wireless/iwlwifi/iwl-agn.c b/trunk/drivers/net/wireless/iwlwifi/iwl-agn.c index 7e6c463abbdf..099c2795ec0b 100644 --- a/trunk/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/trunk/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -32,6 +32,8 @@ #include #include #include +#include +#include #include #include #include @@ -47,6 +49,8 @@ #include +#define DRV_NAME "iwlagn" + #include "iwl-eeprom.h" #include "iwl-dev.h" #include "iwl-core.h" @@ -55,8 +59,7 @@ #include "iwl-sta.h" #include "iwl-agn-calib.h" #include "iwl-agn.h" -#include "iwl-pci.h" -#include "iwl-trans.h" + /****************************************************************************** * @@ -90,10 +93,12 @@ void iwl_update_chain_flags(struct iwl_priv *priv) { struct iwl_rxon_context *ctx; - for_each_context(priv, ctx) { - iwlagn_set_rxon_chain(priv, ctx); - if (ctx->active.rx_chain != ctx->staging.rx_chain) - iwlagn_commit_rxon(priv, ctx); + if (priv->cfg->ops->hcmd->set_rxon_chain) { + for_each_context(priv, ctx) { + priv->cfg->ops->hcmd->set_rxon_chain(priv, ctx); + if (ctx->active.rx_chain != ctx->staging.rx_chain) + iwlagn_commit_rxon(priv, ctx); + } } } @@ -130,7 +135,6 @@ int iwlagn_send_beacon_cmd(struct iwl_priv *priv) struct iwl_host_cmd cmd = { .id = REPLY_TX_BEACON, }; - struct ieee80211_tx_info *info; u32 frame_size; u32 rate_flags; u32 rate; @@ -171,31 +175,14 @@ int iwlagn_send_beacon_cmd(struct iwl_priv *priv) frame_size); /* Set up packet rate and flags */ - info = IEEE80211_SKB_CB(priv->beacon_skb); - - /* - * Let's set up the rate at least somewhat correctly; - * it will currently not actually be used by the uCode, - * it uses the broadcast station's rate instead. - */ - if (info->control.rates[0].idx < 0 || - info->control.rates[0].flags & IEEE80211_TX_RC_MCS) - rate = 0; - else - rate = info->control.rates[0].idx; - + rate = iwl_rate_get_lowest_plcp(priv, priv->beacon_ctx); priv->mgmt_tx_ant = iwl_toggle_tx_ant(priv, priv->mgmt_tx_ant, priv->hw_params.valid_tx_ant); rate_flags = iwl_ant_idx_to_flags(priv->mgmt_tx_ant); - - /* In mac80211, rates for 5 GHz start at 0 */ - if (info->band == IEEE80211_BAND_5GHZ) - rate += IWL_FIRST_OFDM_RATE; - else if (rate >= IWL_FIRST_CCK_RATE && rate <= IWL_LAST_CCK_RATE) + if ((rate >= IWL_FIRST_CCK_RATE) && (rate <= IWL_LAST_CCK_RATE)) rate_flags |= RATE_MCS_CCK_MSK; - - tx_beacon_cmd->tx.rate_n_flags = - iwl_hw_set_rate_n_flags(rate, rate_flags); + tx_beacon_cmd->tx.rate_n_flags = iwl_hw_set_rate_n_flags(rate, + rate_flags); /* Submit command */ cmd.len[0] = sizeof(*tx_beacon_cmd); @@ -258,7 +245,7 @@ static void iwl_bg_bt_runtime_config(struct work_struct *work) /* dont send host command if rf-kill is on */ if (!iwl_is_ready_rf(priv)) return; - iwlagn_send_advance_bt_config(priv); + priv->cfg->ops->hcmd->send_bt_config(priv); } static void iwl_bg_bt_full_concurrency(struct work_struct *work) @@ -285,11 +272,12 @@ static void iwl_bg_bt_full_concurrency(struct work_struct *work) * to avoid 3-wire collisions */ for_each_context(priv, ctx) { - iwlagn_set_rxon_chain(priv, ctx); + if (priv->cfg->ops->hcmd->set_rxon_chain) + priv->cfg->ops->hcmd->set_rxon_chain(priv, ctx); iwlagn_commit_rxon(priv, ctx); } - iwlagn_send_advance_bt_config(priv); + priv->cfg->ops->hcmd->send_bt_config(priv); out: mutex_unlock(&priv->mutex); } @@ -452,8 +440,10 @@ static void iwl_bg_tx_flush(struct work_struct *work) if (!iwl_is_ready_rf(priv)) return; - IWL_DEBUG_INFO(priv, "device request: flush all tx frames\n"); - iwlagn_dev_txfifo_flush(priv, IWL_DROP_ALL); + if (priv->cfg->ops->lib->txfifo_flush) { + IWL_DEBUG_INFO(priv, "device request: flush all tx frames\n"); + iwlagn_dev_txfifo_flush(priv, IWL_DROP_ALL); + } } /** @@ -507,9 +497,9 @@ static void iwl_rx_handle(struct iwl_priv *priv) rxq->queue[i] = NULL; - dma_unmap_page(priv->bus.dev, rxb->page_dma, + pci_unmap_page(priv->pci_dev, rxb->page_dma, PAGE_SIZE << priv->hw_params.rx_page_order, - DMA_FROM_DEVICE); + PCI_DMA_FROMDEVICE); pkt = rxb_addr(rxb); len = le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK; @@ -591,9 +581,9 @@ static void iwl_rx_handle(struct iwl_priv *priv) * rx_free list for reuse later. */ spin_lock_irqsave(&rxq->lock, flags); if (rxb->page != NULL) { - rxb->page_dma = dma_map_page(priv->bus.dev, rxb->page, + rxb->page_dma = pci_map_page(priv->pci_dev, rxb->page, 0, PAGE_SIZE << priv->hw_params.rx_page_order, - DMA_FROM_DEVICE); + PCI_DMA_FROMDEVICE); list_add_tail(&rxb->list, &rxq->rx_free); rxq->free_count++; } else @@ -949,28 +939,22 @@ static struct attribute_group iwl_attribute_group = { * ******************************************************************************/ -static void iwl_free_fw_desc(struct iwl_priv *priv, struct fw_desc *desc) +static void iwl_free_fw_desc(struct pci_dev *pci_dev, struct fw_desc *desc) { if (desc->v_addr) - dma_free_coherent(priv->bus.dev, desc->len, + dma_free_coherent(&pci_dev->dev, desc->len, desc->v_addr, desc->p_addr); desc->v_addr = NULL; desc->len = 0; } -static void iwl_free_fw_img(struct iwl_priv *priv, struct fw_img *img) +static void iwl_free_fw_img(struct pci_dev *pci_dev, struct fw_img *img) { - iwl_free_fw_desc(priv, &img->code); - iwl_free_fw_desc(priv, &img->data); + iwl_free_fw_desc(pci_dev, &img->code); + iwl_free_fw_desc(pci_dev, &img->data); } -static void iwl_dealloc_ucode(struct iwl_priv *priv) -{ - iwl_free_fw_img(priv, &priv->ucode_rt); - iwl_free_fw_img(priv, &priv->ucode_init); -} - -static int iwl_alloc_fw_desc(struct iwl_priv *priv, struct fw_desc *desc, +static int iwl_alloc_fw_desc(struct pci_dev *pci_dev, struct fw_desc *desc, const void *data, size_t len) { if (!len) { @@ -978,16 +962,21 @@ static int iwl_alloc_fw_desc(struct iwl_priv *priv, struct fw_desc *desc, return -EINVAL; } - desc->v_addr = dma_alloc_coherent(priv->bus.dev, len, + desc->v_addr = dma_alloc_coherent(&pci_dev->dev, len, &desc->p_addr, GFP_KERNEL); if (!desc->v_addr) return -ENOMEM; - desc->len = len; memcpy(desc->v_addr, data, len); return 0; } +static void iwl_dealloc_ucode_pci(struct iwl_priv *priv) +{ + iwl_free_fw_img(priv->pci_dev, &priv->ucode_rt); + iwl_free_fw_img(priv->pci_dev, &priv->ucode_init); +} + struct iwlagn_ucode_capabilities { u32 max_probe_length; u32 standard_phy_calibration_size; @@ -1032,8 +1021,8 @@ static int __must_check iwl_request_firmware(struct iwl_priv *priv, bool first) priv->firmware_name); return request_firmware_nowait(THIS_MODULE, 1, priv->firmware_name, - priv->bus.dev, - GFP_KERNEL, priv, iwl_ucode_callback); + &priv->pci_dev->dev, GFP_KERNEL, priv, + iwl_ucode_callback); } struct iwlagn_firmware_pieces { @@ -1454,19 +1443,19 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context) /* Runtime instructions and 2 copies of data: * 1) unmodified from disk * 2) backup cache for save/restore during power-downs */ - if (iwl_alloc_fw_desc(priv, &priv->ucode_rt.code, + if (iwl_alloc_fw_desc(priv->pci_dev, &priv->ucode_rt.code, pieces.inst, pieces.inst_size)) goto err_pci_alloc; - if (iwl_alloc_fw_desc(priv, &priv->ucode_rt.data, + if (iwl_alloc_fw_desc(priv->pci_dev, &priv->ucode_rt.data, pieces.data, pieces.data_size)) goto err_pci_alloc; /* Initialization instructions and data */ if (pieces.init_size && pieces.init_data_size) { - if (iwl_alloc_fw_desc(priv, &priv->ucode_init.code, + if (iwl_alloc_fw_desc(priv->pci_dev, &priv->ucode_init.code, pieces.init, pieces.init_size)) goto err_pci_alloc; - if (iwl_alloc_fw_desc(priv, &priv->ucode_init.data, + if (iwl_alloc_fw_desc(priv->pci_dev, &priv->ucode_init.data, pieces.init_data, pieces.init_data_size)) goto err_pci_alloc; } @@ -1496,8 +1485,7 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context) priv->new_scan_threshold_behaviour = !!(ucode_capa.flags & IWL_UCODE_TLV_FLAGS_NEWSCAN); - if ((priv->cfg->sku & EEPROM_SKU_CAP_IPAN_ENABLE) && - (ucode_capa.flags & IWL_UCODE_TLV_FLAGS_PAN)) { + if (ucode_capa.flags & IWL_UCODE_TLV_FLAGS_PAN) { priv->valid_contexts |= BIT(IWL_RXON_CTX_PAN); priv->sta_key_max_num = STA_KEY_MAX_NUM_PAN; } else @@ -1535,7 +1523,7 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context) if (err) IWL_ERR(priv, "failed to create debugfs files. Ignoring error: %d\n", err); - err = sysfs_create_group(&(priv->bus.dev->kobj), + err = sysfs_create_group(&priv->pci_dev->dev.kobj, &iwl_attribute_group); if (err) { IWL_ERR(priv, "failed to create sysfs device attributes\n"); @@ -1556,10 +1544,10 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context) err_pci_alloc: IWL_ERR(priv, "failed to allocate pci memory\n"); - iwl_dealloc_ucode(priv); + iwl_dealloc_ucode_pci(priv); out_unbind: complete(&priv->_agn.firmware_loading_complete); - device_release_driver(priv->bus.dev); + device_release_driver(&priv->pci_dev->dev); release_firmware(ucode_raw); } @@ -1638,7 +1626,7 @@ void iwl_dump_nic_error_log(struct iwl_priv *priv) struct iwl_error_event_table table; base = priv->device_pointers.error_event_table; - if (priv->ucode_type == IWL_UCODE_INIT) { + if (priv->ucode_type == UCODE_SUBTYPE_INIT) { if (!base) base = priv->_agn.init_errlog_ptr; } else { @@ -1650,7 +1638,7 @@ void iwl_dump_nic_error_log(struct iwl_priv *priv) IWL_ERR(priv, "Not valid error log pointer 0x%08X for %s uCode\n", base, - (priv->ucode_type == IWL_UCODE_INIT) + (priv->ucode_type == UCODE_SUBTYPE_INIT) ? "Init" : "RT"); return; } @@ -1714,7 +1702,7 @@ static int iwl_print_event_log(struct iwl_priv *priv, u32 start_idx, return pos; base = priv->device_pointers.log_event_table; - if (priv->ucode_type == IWL_UCODE_INIT) { + if (priv->ucode_type == UCODE_SUBTYPE_INIT) { if (!base) base = priv->_agn.init_evtlog_ptr; } else { @@ -1827,7 +1815,7 @@ int iwl_dump_nic_event_log(struct iwl_priv *priv, bool full_log, size_t bufsz = 0; base = priv->device_pointers.log_event_table; - if (priv->ucode_type == IWL_UCODE_INIT) { + if (priv->ucode_type == UCODE_SUBTYPE_INIT) { logsize = priv->_agn.init_evtlog_size; if (!base) base = priv->_agn.init_evtlog_ptr; @@ -1841,7 +1829,7 @@ int iwl_dump_nic_event_log(struct iwl_priv *priv, bool full_log, IWL_ERR(priv, "Invalid event log pointer 0x%08X for %s uCode\n", base, - (priv->ucode_type == IWL_UCODE_INIT) + (priv->ucode_type == UCODE_SUBTYPE_INIT) ? "Init" : "RT"); return -EINVAL; } @@ -2014,7 +2002,7 @@ int iwl_alive_start(struct iwl_priv *priv) priv->bt_valid = IWLAGN_BT_ALL_VALID_MSK; priv->kill_ack_mask = IWLAGN_BT_KILL_ACK_MASK_DEFAULT; priv->kill_cts_mask = IWLAGN_BT_KILL_CTS_MASK_DEFAULT; - iwlagn_send_advance_bt_config(priv); + priv->cfg->ops->hcmd->send_bt_config(priv); priv->bt_valid = IWLAGN_BT_VALID_ENABLE_FLAGS; iwlagn_send_prio_tbl(priv); @@ -2027,13 +2015,7 @@ int iwl_alive_start(struct iwl_priv *priv) BT_COEX_PRIO_TBL_EVT_INIT_CALIB2); if (ret) return ret; - } else { - /* - * default is 2-wire BT coexexistence support - */ - iwl_send_bt_config(priv); } - if (priv->hw_params.calib_rt_cfg) iwlagn_send_calib_cfg_rt(priv, priv->hw_params.calib_rt_cfg); @@ -2042,7 +2024,8 @@ int iwl_alive_start(struct iwl_priv *priv) priv->active_rate = IWL_RATES_MASK; /* Configure Tx antenna selection based on H/W config */ - iwlagn_send_tx_ant_config(priv, priv->cfg->valid_tx_ant); + if (priv->cfg->ops->hcmd->set_tx_ant) + priv->cfg->ops->hcmd->set_tx_ant(priv, priv->cfg->valid_tx_ant); if (iwl_is_associated_ctx(ctx)) { struct iwl_rxon_cmd *active_rxon = @@ -2056,7 +2039,16 @@ int iwl_alive_start(struct iwl_priv *priv) for_each_context(priv, tmp) iwl_connection_init_rx_config(priv, tmp); - iwlagn_set_rxon_chain(priv, ctx); + if (priv->cfg->ops->hcmd->set_rxon_chain) + priv->cfg->ops->hcmd->set_rxon_chain(priv, ctx); + } + + if (!priv->cfg->bt_params || (priv->cfg->bt_params && + !priv->cfg->bt_params->advanced_bt_coexist)) { + /* + * default is 2-wire BT coexexistence support + */ + priv->cfg->ops->hcmd->send_bt_config(priv); } iwl_reset_run_time_calib(priv); @@ -2218,7 +2210,8 @@ static int __iwl_up(struct iwl_priv *priv) ret = iwlagn_load_ucode_wait_alive(priv, &priv->ucode_rt, - IWL_UCODE_REGULAR); + UCODE_SUBTYPE_REGULAR, + UCODE_SUBTYPE_REGULAR_NEW); if (ret) { IWL_ERR(priv, "Failed to start RT ucode: %d\n", ret); goto error; @@ -2523,7 +2516,7 @@ static int iwl_mac_setup_register(struct iwl_priv *priv, hw->flags |= IEEE80211_HW_SUPPORTS_PS | IEEE80211_HW_SUPPORTS_DYNAMIC_PS; - if (priv->cfg->sku & EEPROM_SKU_CAP_11N_ENABLE) + if (priv->cfg->sku & IWL_SKU_N) hw->flags |= IEEE80211_HW_SUPPORTS_DYNAMIC_SMPS | IEEE80211_HW_SUPPORTS_STATIC_SMPS; @@ -2556,10 +2549,11 @@ static int iwl_mac_setup_register(struct iwl_priv *priv, WIPHY_FLAG_DISABLE_BEACON_HINTS | WIPHY_FLAG_IBSS_RSN; - if (iwlagn_mod_params.power_save) - hw->wiphy->flags |= WIPHY_FLAG_PS_ON_BY_DEFAULT; - else - hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT; + /* + * For now, disable PS by default because it affects + * RX performance significantly. + */ + hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT; hw->wiphy->max_scan_ssids = PROBE_OPTION_MAX; /* we create the 802.11 header and a zero-length SSID element */ @@ -2763,7 +2757,7 @@ static int iwlagn_mac_ampdu_action(struct ieee80211_hw *hw, IWL_DEBUG_HT(priv, "A-MPDU action on addr %pM tid %d\n", sta->addr, tid); - if (!(priv->cfg->sku & EEPROM_SKU_CAP_11N_ENABLE)) + if (!(priv->cfg->sku & IWL_SKU_N)) return -EACCES; mutex_lock(&priv->mutex); @@ -3058,6 +3052,10 @@ static void iwlagn_mac_flush(struct ieee80211_hw *hw, bool drop) mutex_lock(&priv->mutex); IWL_DEBUG_MAC80211(priv, "enter\n"); + /* do not support "flush" */ + if (!priv->cfg->ops->lib->txfifo_flush) + goto done; + if (test_bit(STATUS_EXIT_PENDING, &priv->status)) { IWL_DEBUG_TX(priv, "Aborting flush due to device shutdown\n"); goto done; @@ -3073,7 +3071,7 @@ static void iwlagn_mac_flush(struct ieee80211_hw *hw, bool drop) */ if (drop) { IWL_DEBUG_MAC80211(priv, "send flush command\n"); - if (iwlagn_txfifo_flush(priv, IWL_DROP_ALL)) { + if (priv->cfg->ops->lib->txfifo_flush(priv, IWL_DROP_ALL)) { IWL_ERR(priv, "flush request fail\n"); goto done; } @@ -3281,7 +3279,9 @@ static int iwl_init_drv(struct iwl_priv *priv) priv->rx_statistics_jiffies = jiffies; /* Choose which receivers/antennas to use */ - iwlagn_set_rxon_chain(priv, &priv->contexts[IWL_RXON_CTX_BSS]); + if (priv->cfg->ops->hcmd->set_rxon_chain) + priv->cfg->ops->hcmd->set_rxon_chain(priv, + &priv->contexts[IWL_RXON_CTX_BSS]); iwl_init_scan_params(priv); @@ -3352,11 +3352,14 @@ struct ieee80211_ops iwlagn_hw_ops = { .offchannel_tx = iwl_mac_offchannel_tx, .offchannel_tx_cancel_wait = iwl_mac_offchannel_tx_cancel_wait, CFG80211_TESTMODE_CMD(iwl_testmode_cmd) - CFG80211_TESTMODE_DUMP(iwl_testmode_dump) }; static u32 iwl_hw_detect(struct iwl_priv *priv) { + u8 rev_id; + + pci_read_config_byte(priv->pci_dev, PCI_REVISION_ID, &rev_id); + IWL_DEBUG_INFO(priv, "HW Revision ID = 0x%X\n", rev_id); return iwl_read32(priv, CSR_HW_REV); } @@ -3372,7 +3375,7 @@ static int iwl_set_hw_params(struct iwl_priv *priv) priv->hw_params.max_beacon_itrvl = IWL_MAX_UCODE_BEACON_INTERVAL; if (iwlagn_mod_params.disable_11n) - priv->cfg->sku &= ~EEPROM_SKU_CAP_11N_ENABLE; + priv->cfg->sku &= ~IWL_SKU_N; /* Device-specific setup */ return priv->cfg->ops->lib->set_hw_params(priv); @@ -3422,9 +3425,29 @@ static struct ieee80211_hw *iwl_alloc_all(struct iwl_cfg *cfg) return hw; } -static void iwl_init_context(struct iwl_priv *priv) +static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) { - int i; + int err = 0, i; + struct iwl_priv *priv; + struct ieee80211_hw *hw; + struct iwl_cfg *cfg = (struct iwl_cfg *)(ent->driver_data); + unsigned long flags; + u16 pci_cmd, num_mac; + u32 hw_rev; + + /************************ + * 1. Allocating HW data + ************************/ + + hw = iwl_alloc_all(cfg); + if (!hw) { + err = -ENOMEM; + goto out; + } + priv = hw->priv; + /* At this point both hw and priv are allocated. */ + + priv->ucode_type = UCODE_SUBTYPE_NONE_LOADED; /* * The default context is always valid, @@ -3456,10 +3479,8 @@ static void iwl_init_context(struct iwl_priv *priv) priv->contexts[IWL_RXON_CTX_BSS].unused_devtype = RXON_DEV_TYPE_ESS; priv->contexts[IWL_RXON_CTX_PAN].rxon_cmd = REPLY_WIPAN_RXON; - priv->contexts[IWL_RXON_CTX_PAN].rxon_timing_cmd = - REPLY_WIPAN_RXON_TIMING; - priv->contexts[IWL_RXON_CTX_PAN].rxon_assoc_cmd = - REPLY_WIPAN_RXON_ASSOC; + priv->contexts[IWL_RXON_CTX_PAN].rxon_timing_cmd = REPLY_WIPAN_RXON_TIMING; + priv->contexts[IWL_RXON_CTX_PAN].rxon_assoc_cmd = REPLY_WIPAN_RXON_ASSOC; priv->contexts[IWL_RXON_CTX_PAN].qos_cmd = REPLY_WIPAN_QOS_PARAM; priv->contexts[IWL_RXON_CTX_PAN].ap_sta_id = IWL_AP_ID_PAN; priv->contexts[IWL_RXON_CTX_PAN].wep_key_cmd = REPLY_WIPAN_WEPKEY; @@ -3479,43 +3500,12 @@ static void iwl_init_context(struct iwl_priv *priv) priv->contexts[IWL_RXON_CTX_PAN].unused_devtype = RXON_DEV_TYPE_P2P; BUILD_BUG_ON(NUM_IWL_RXON_CTX != 2); -} -int iwl_probe(void *bus_specific, struct iwl_bus_ops *bus_ops, - struct iwl_cfg *cfg) -{ - int err = 0; - struct iwl_priv *priv; - struct ieee80211_hw *hw; - u16 num_mac; - u32 hw_rev; - - /************************ - * 1. Allocating HW data - ************************/ - hw = iwl_alloc_all(cfg); - if (!hw) { - err = -ENOMEM; - goto out; - } - - priv = hw->priv; - - priv->bus.priv = priv; - priv->bus.bus_specific = bus_specific; - priv->bus.ops = bus_ops; - priv->bus.irq = priv->bus.ops->get_irq(&priv->bus); - priv->bus.ops->set_drv_data(&priv->bus, priv); - priv->bus.dev = priv->bus.ops->get_dev(&priv->bus); - - iwl_trans_register(&priv->trans); - - /* At this point both hw and priv are allocated. */ - - SET_IEEE80211_DEV(hw, priv->bus.dev); + SET_IEEE80211_DEV(hw, &pdev->dev); IWL_DEBUG_INFO(priv, "*** LOAD DRIVER ***\n"); priv->cfg = cfg; + priv->pci_dev = pdev; priv->inta_mask = CSR_INI_SET_MASK; /* is antenna coupling more than 35dB ? */ @@ -3531,6 +3521,52 @@ int iwl_probe(void *bus_specific, struct iwl_bus_ops *bus_ops, if (iwl_alloc_traffic_mem(priv)) IWL_ERR(priv, "Not enough memory to generate traffic log\n"); + /************************** + * 2. Initializing PCI bus + **************************/ + pci_disable_link_state(pdev, PCIE_LINK_STATE_L0S | PCIE_LINK_STATE_L1 | + PCIE_LINK_STATE_CLKPM); + + if (pci_enable_device(pdev)) { + err = -ENODEV; + goto out_ieee80211_free_hw; + } + + pci_set_master(pdev); + + err = pci_set_dma_mask(pdev, DMA_BIT_MASK(36)); + if (!err) + err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(36)); + if (err) { + err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)); + if (!err) + err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32)); + /* both attempts failed: */ + if (err) { + IWL_WARN(priv, "No suitable DMA available.\n"); + goto out_pci_disable_device; + } + } + + err = pci_request_regions(pdev, DRV_NAME); + if (err) + goto out_pci_disable_device; + + pci_set_drvdata(pdev, priv); + + + /*********************** + * 3. Read REV register + ***********************/ + priv->hw_base = pci_iomap(pdev, 0, 0); + if (!priv->hw_base) { + err = -ENODEV; + goto out_pci_release_regions; + } + + IWL_DEBUG_INFO(priv, "pci_resource_len = 0x%08llx\n", + (unsigned long long) pci_resource_len(pdev, 0)); + IWL_DEBUG_INFO(priv, "pci_resource_base = %p\n", priv->hw_base); /* these spin locks will be used in apm_ops.init and EEPROM access * we should init now @@ -3545,17 +3581,17 @@ int iwl_probe(void *bus_specific, struct iwl_bus_ops *bus_ops, */ iwl_write32(priv, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET); - /*********************** - * 3. Read REV register - ***********************/ hw_rev = iwl_hw_detect(priv); IWL_INFO(priv, "Detected %s, REV=0x%X\n", priv->cfg->name, hw_rev); + /* We disable the RETRY_TIMEOUT register (0x41) to keep + * PCI Tx retries from interfering with C3 CPU state */ + pci_write_config_byte(pdev, PCI_CFG_RETRY_TIMEOUT, 0x00); + if (iwl_prepare_card_hw(priv)) { - err = -EIO; IWL_WARN(priv, "Failed, HW not ready\n"); - goto out_free_traffic_mem; + goto out_iounmap; } /***************** @@ -3565,7 +3601,7 @@ int iwl_probe(void *bus_specific, struct iwl_bus_ops *bus_ops, err = iwl_eeprom_init(priv, hw_rev); if (err) { IWL_ERR(priv, "Unable to init EEPROM\n"); - goto out_free_traffic_mem; + goto out_iounmap; } err = iwl_eeprom_check_version(priv); if (err) @@ -3588,14 +3624,10 @@ int iwl_probe(void *bus_specific, struct iwl_bus_ops *bus_ops, priv->hw->wiphy->n_addresses++; } - /* initialize all valid contexts */ - iwl_init_context(priv); - /************************ * 5. Setup HW constants ************************/ if (iwl_set_hw_params(priv)) { - err = -ENOENT; IWL_ERR(priv, "failed to set hw parameters\n"); goto out_free_eeprom; } @@ -3612,13 +3644,19 @@ int iwl_probe(void *bus_specific, struct iwl_bus_ops *bus_ops, /******************** * 7. Setup services ********************/ + spin_lock_irqsave(&priv->lock, flags); + iwl_disable_interrupts(priv); + spin_unlock_irqrestore(&priv->lock, flags); + + pci_enable_msi(priv->pci_dev); + iwl_alloc_isr_ict(priv); - err = request_irq(priv->bus.irq, iwl_isr_ict, IRQF_SHARED, - DRV_NAME, priv); + err = request_irq(priv->pci_dev->irq, iwl_isr_ict, + IRQF_SHARED, DRV_NAME, priv); if (err) { - IWL_ERR(priv, "Error allocating IRQ %d\n", priv->bus.irq); - goto out_uninit_drv; + IWL_ERR(priv, "Error allocating IRQ %d\n", priv->pci_dev->irq); + goto out_disable_msi; } iwl_setup_deferred_work(priv); @@ -3626,9 +3664,16 @@ int iwl_probe(void *bus_specific, struct iwl_bus_ops *bus_ops, iwl_testmode_init(priv); /********************************************* - * 8. Enable interrupts + * 8. Enable interrupts and read RFKILL state *********************************************/ + /* enable rfkill interrupt: hw bug w/a */ + pci_read_config_word(priv->pci_dev, PCI_COMMAND, &pci_cmd); + if (pci_cmd & PCI_COMMAND_INTX_DISABLE) { + pci_cmd &= ~PCI_COMMAND_INTX_DISABLE; + pci_write_config_word(priv->pci_dev, PCI_COMMAND, pci_cmd); + } + iwl_enable_rfkill_int(priv); /* If platform's RF_KILL switch is NOT set to KILL */ @@ -3654,30 +3699,41 @@ int iwl_probe(void *bus_specific, struct iwl_bus_ops *bus_ops, out_destroy_workqueue: destroy_workqueue(priv->workqueue); priv->workqueue = NULL; - free_irq(priv->bus.irq, priv); + free_irq(priv->pci_dev->irq, priv); + out_disable_msi: iwl_free_isr_ict(priv); - out_uninit_drv: + pci_disable_msi(priv->pci_dev); iwl_uninit_drv(priv); out_free_eeprom: iwl_eeprom_free(priv); - out_free_traffic_mem: + out_iounmap: + pci_iounmap(pdev, priv->hw_base); + out_pci_release_regions: + pci_set_drvdata(pdev, NULL); + pci_release_regions(pdev); + out_pci_disable_device: + pci_disable_device(pdev); + out_ieee80211_free_hw: iwl_free_traffic_mem(priv); ieee80211_free_hw(priv->hw); out: return err; } -void __devexit iwl_remove(struct iwl_priv * priv) +static void __devexit iwl_pci_remove(struct pci_dev *pdev) { + struct iwl_priv *priv = pci_get_drvdata(pdev); unsigned long flags; + if (!priv) + return; + wait_for_completion(&priv->_agn.firmware_loading_complete); IWL_DEBUG_INFO(priv, "*** UNLOAD DRIVER ***\n"); iwl_dbgfs_unregister(priv); - sysfs_remove_group(&priv->bus.dev->kobj, - &iwl_attribute_group); + sysfs_remove_group(&pdev->dev.kobj, &iwl_attribute_group); /* ieee80211_unregister_hw call wil cause iwl_mac_stop to * to be called and iwl_down since we are removing the device @@ -3707,9 +3763,10 @@ void __devexit iwl_remove(struct iwl_priv * priv) iwl_synchronize_irq(priv); - iwl_dealloc_ucode(priv); + iwl_dealloc_ucode_pci(priv); - priv->trans.ops->rx_free(priv); + if (priv->rxq.bd) + iwlagn_rx_queue_free(priv, &priv->rxq); iwlagn_hw_txq_ctx_free(priv); iwl_eeprom_free(priv); @@ -3725,8 +3782,12 @@ void __devexit iwl_remove(struct iwl_priv * priv) priv->workqueue = NULL; iwl_free_traffic_mem(priv); - free_irq(priv->bus.irq, priv); - priv->bus.ops->set_drv_data(&priv->bus, NULL); + free_irq(priv->pci_dev->irq, priv); + pci_disable_msi(priv->pci_dev); + pci_iounmap(pdev, priv->hw_base); + pci_release_regions(pdev); + pci_disable_device(pdev); + pci_set_drvdata(pdev, NULL); iwl_uninit_drv(priv); @@ -3743,6 +3804,206 @@ void __devexit iwl_remove(struct iwl_priv * priv) * driver and module entry point * *****************************************************************************/ + +/* Hardware specific file defines the PCI IDs table for that hardware module */ +static DEFINE_PCI_DEVICE_TABLE(iwl_hw_card_ids) = { + {IWL_PCI_DEVICE(0x4232, 0x1201, iwl5100_agn_cfg)}, /* Mini Card */ + {IWL_PCI_DEVICE(0x4232, 0x1301, iwl5100_agn_cfg)}, /* Half Mini Card */ + {IWL_PCI_DEVICE(0x4232, 0x1204, iwl5100_agn_cfg)}, /* Mini Card */ + {IWL_PCI_DEVICE(0x4232, 0x1304, iwl5100_agn_cfg)}, /* Half Mini Card */ + {IWL_PCI_DEVICE(0x4232, 0x1205, iwl5100_bgn_cfg)}, /* Mini Card */ + {IWL_PCI_DEVICE(0x4232, 0x1305, iwl5100_bgn_cfg)}, /* Half Mini Card */ + {IWL_PCI_DEVICE(0x4232, 0x1206, iwl5100_abg_cfg)}, /* Mini Card */ + {IWL_PCI_DEVICE(0x4232, 0x1306, iwl5100_abg_cfg)}, /* Half Mini Card */ + {IWL_PCI_DEVICE(0x4232, 0x1221, iwl5100_agn_cfg)}, /* Mini Card */ + {IWL_PCI_DEVICE(0x4232, 0x1321, iwl5100_agn_cfg)}, /* Half Mini Card */ + {IWL_PCI_DEVICE(0x4232, 0x1224, iwl5100_agn_cfg)}, /* Mini Card */ + {IWL_PCI_DEVICE(0x4232, 0x1324, iwl5100_agn_cfg)}, /* Half Mini Card */ + {IWL_PCI_DEVICE(0x4232, 0x1225, iwl5100_bgn_cfg)}, /* Mini Card */ + {IWL_PCI_DEVICE(0x4232, 0x1325, iwl5100_bgn_cfg)}, /* Half Mini Card */ + {IWL_PCI_DEVICE(0x4232, 0x1226, iwl5100_abg_cfg)}, /* Mini Card */ + {IWL_PCI_DEVICE(0x4232, 0x1326, iwl5100_abg_cfg)}, /* Half Mini Card */ + {IWL_PCI_DEVICE(0x4237, 0x1211, iwl5100_agn_cfg)}, /* Mini Card */ + {IWL_PCI_DEVICE(0x4237, 0x1311, iwl5100_agn_cfg)}, /* Half Mini Card */ + {IWL_PCI_DEVICE(0x4237, 0x1214, iwl5100_agn_cfg)}, /* Mini Card */ + {IWL_PCI_DEVICE(0x4237, 0x1314, iwl5100_agn_cfg)}, /* Half Mini Card */ + {IWL_PCI_DEVICE(0x4237, 0x1215, iwl5100_bgn_cfg)}, /* Mini Card */ + {IWL_PCI_DEVICE(0x4237, 0x1315, iwl5100_bgn_cfg)}, /* Half Mini Card */ + {IWL_PCI_DEVICE(0x4237, 0x1216, iwl5100_abg_cfg)}, /* Mini Card */ + {IWL_PCI_DEVICE(0x4237, 0x1316, iwl5100_abg_cfg)}, /* Half Mini Card */ + +/* 5300 Series WiFi */ + {IWL_PCI_DEVICE(0x4235, 0x1021, iwl5300_agn_cfg)}, /* Mini Card */ + {IWL_PCI_DEVICE(0x4235, 0x1121, iwl5300_agn_cfg)}, /* Half Mini Card */ + {IWL_PCI_DEVICE(0x4235, 0x1024, iwl5300_agn_cfg)}, /* Mini Card */ + {IWL_PCI_DEVICE(0x4235, 0x1124, iwl5300_agn_cfg)}, /* Half Mini Card */ + {IWL_PCI_DEVICE(0x4235, 0x1001, iwl5300_agn_cfg)}, /* Mini Card */ + {IWL_PCI_DEVICE(0x4235, 0x1101, iwl5300_agn_cfg)}, /* Half Mini Card */ + {IWL_PCI_DEVICE(0x4235, 0x1004, iwl5300_agn_cfg)}, /* Mini Card */ + {IWL_PCI_DEVICE(0x4235, 0x1104, iwl5300_agn_cfg)}, /* Half Mini Card */ + {IWL_PCI_DEVICE(0x4236, 0x1011, iwl5300_agn_cfg)}, /* Mini Card */ + {IWL_PCI_DEVICE(0x4236, 0x1111, iwl5300_agn_cfg)}, /* Half Mini Card */ + {IWL_PCI_DEVICE(0x4236, 0x1014, iwl5300_agn_cfg)}, /* Mini Card */ + {IWL_PCI_DEVICE(0x4236, 0x1114, iwl5300_agn_cfg)}, /* Half Mini Card */ + +/* 5350 Series WiFi/WiMax */ + {IWL_PCI_DEVICE(0x423A, 0x1001, iwl5350_agn_cfg)}, /* Mini Card */ + {IWL_PCI_DEVICE(0x423A, 0x1021, iwl5350_agn_cfg)}, /* Mini Card */ + {IWL_PCI_DEVICE(0x423B, 0x1011, iwl5350_agn_cfg)}, /* Mini Card */ + +/* 5150 Series Wifi/WiMax */ + {IWL_PCI_DEVICE(0x423C, 0x1201, iwl5150_agn_cfg)}, /* Mini Card */ + {IWL_PCI_DEVICE(0x423C, 0x1301, iwl5150_agn_cfg)}, /* Half Mini Card */ + {IWL_PCI_DEVICE(0x423C, 0x1206, iwl5150_abg_cfg)}, /* Mini Card */ + {IWL_PCI_DEVICE(0x423C, 0x1306, iwl5150_abg_cfg)}, /* Half Mini Card */ + {IWL_PCI_DEVICE(0x423C, 0x1221, iwl5150_agn_cfg)}, /* Mini Card */ + {IWL_PCI_DEVICE(0x423C, 0x1321, iwl5150_agn_cfg)}, /* Half Mini Card */ + + {IWL_PCI_DEVICE(0x423D, 0x1211, iwl5150_agn_cfg)}, /* Mini Card */ + {IWL_PCI_DEVICE(0x423D, 0x1311, iwl5150_agn_cfg)}, /* Half Mini Card */ + {IWL_PCI_DEVICE(0x423D, 0x1216, iwl5150_abg_cfg)}, /* Mini Card */ + {IWL_PCI_DEVICE(0x423D, 0x1316, iwl5150_abg_cfg)}, /* Half Mini Card */ + +/* 6x00 Series */ + {IWL_PCI_DEVICE(0x422B, 0x1101, iwl6000_3agn_cfg)}, + {IWL_PCI_DEVICE(0x422B, 0x1121, iwl6000_3agn_cfg)}, + {IWL_PCI_DEVICE(0x422C, 0x1301, iwl6000i_2agn_cfg)}, + {IWL_PCI_DEVICE(0x422C, 0x1306, iwl6000i_2abg_cfg)}, + {IWL_PCI_DEVICE(0x422C, 0x1307, iwl6000i_2bg_cfg)}, + {IWL_PCI_DEVICE(0x422C, 0x1321, iwl6000i_2agn_cfg)}, + {IWL_PCI_DEVICE(0x422C, 0x1326, iwl6000i_2abg_cfg)}, + {IWL_PCI_DEVICE(0x4238, 0x1111, iwl6000_3agn_cfg)}, + {IWL_PCI_DEVICE(0x4239, 0x1311, iwl6000i_2agn_cfg)}, + {IWL_PCI_DEVICE(0x4239, 0x1316, iwl6000i_2abg_cfg)}, + +/* 6x05 Series */ + {IWL_PCI_DEVICE(0x0082, 0x1301, iwl6005_2agn_cfg)}, + {IWL_PCI_DEVICE(0x0082, 0x1306, iwl6005_2abg_cfg)}, + {IWL_PCI_DEVICE(0x0082, 0x1307, iwl6005_2bg_cfg)}, + {IWL_PCI_DEVICE(0x0082, 0x1321, iwl6005_2agn_cfg)}, + {IWL_PCI_DEVICE(0x0082, 0x1326, iwl6005_2abg_cfg)}, + {IWL_PCI_DEVICE(0x0085, 0x1311, iwl6005_2agn_cfg)}, + {IWL_PCI_DEVICE(0x0085, 0x1316, iwl6005_2abg_cfg)}, + +/* 6x30 Series */ + {IWL_PCI_DEVICE(0x008A, 0x5305, iwl1030_bgn_cfg)}, + {IWL_PCI_DEVICE(0x008A, 0x5307, iwl1030_bg_cfg)}, + {IWL_PCI_DEVICE(0x008A, 0x5325, iwl1030_bgn_cfg)}, + {IWL_PCI_DEVICE(0x008A, 0x5327, iwl1030_bg_cfg)}, + {IWL_PCI_DEVICE(0x008B, 0x5315, iwl1030_bgn_cfg)}, + {IWL_PCI_DEVICE(0x008B, 0x5317, iwl1030_bg_cfg)}, + {IWL_PCI_DEVICE(0x0090, 0x5211, iwl6030_2agn_cfg)}, + {IWL_PCI_DEVICE(0x0090, 0x5215, iwl6030_2bgn_cfg)}, + {IWL_PCI_DEVICE(0x0090, 0x5216, iwl6030_2abg_cfg)}, + {IWL_PCI_DEVICE(0x0091, 0x5201, iwl6030_2agn_cfg)}, + {IWL_PCI_DEVICE(0x0091, 0x5205, iwl6030_2bgn_cfg)}, + {IWL_PCI_DEVICE(0x0091, 0x5206, iwl6030_2abg_cfg)}, + {IWL_PCI_DEVICE(0x0091, 0x5207, iwl6030_2bg_cfg)}, + {IWL_PCI_DEVICE(0x0091, 0x5221, iwl6030_2agn_cfg)}, + {IWL_PCI_DEVICE(0x0091, 0x5225, iwl6030_2bgn_cfg)}, + {IWL_PCI_DEVICE(0x0091, 0x5226, iwl6030_2abg_cfg)}, + +/* 6x50 WiFi/WiMax Series */ + {IWL_PCI_DEVICE(0x0087, 0x1301, iwl6050_2agn_cfg)}, + {IWL_PCI_DEVICE(0x0087, 0x1306, iwl6050_2abg_cfg)}, + {IWL_PCI_DEVICE(0x0087, 0x1321, iwl6050_2agn_cfg)}, + {IWL_PCI_DEVICE(0x0087, 0x1326, iwl6050_2abg_cfg)}, + {IWL_PCI_DEVICE(0x0089, 0x1311, iwl6050_2agn_cfg)}, + {IWL_PCI_DEVICE(0x0089, 0x1316, iwl6050_2abg_cfg)}, + +/* 6150 WiFi/WiMax Series */ + {IWL_PCI_DEVICE(0x0885, 0x1305, iwl6150_bgn_cfg)}, + {IWL_PCI_DEVICE(0x0885, 0x1307, iwl6150_bg_cfg)}, + {IWL_PCI_DEVICE(0x0885, 0x1325, iwl6150_bgn_cfg)}, + {IWL_PCI_DEVICE(0x0885, 0x1327, iwl6150_bg_cfg)}, + {IWL_PCI_DEVICE(0x0886, 0x1315, iwl6150_bgn_cfg)}, + {IWL_PCI_DEVICE(0x0886, 0x1317, iwl6150_bg_cfg)}, + +/* 1000 Series WiFi */ + {IWL_PCI_DEVICE(0x0083, 0x1205, iwl1000_bgn_cfg)}, + {IWL_PCI_DEVICE(0x0083, 0x1305, iwl1000_bgn_cfg)}, + {IWL_PCI_DEVICE(0x0083, 0x1225, iwl1000_bgn_cfg)}, + {IWL_PCI_DEVICE(0x0083, 0x1325, iwl1000_bgn_cfg)}, + {IWL_PCI_DEVICE(0x0084, 0x1215, iwl1000_bgn_cfg)}, + {IWL_PCI_DEVICE(0x0084, 0x1315, iwl1000_bgn_cfg)}, + {IWL_PCI_DEVICE(0x0083, 0x1206, iwl1000_bg_cfg)}, + {IWL_PCI_DEVICE(0x0083, 0x1306, iwl1000_bg_cfg)}, + {IWL_PCI_DEVICE(0x0083, 0x1226, iwl1000_bg_cfg)}, + {IWL_PCI_DEVICE(0x0083, 0x1326, iwl1000_bg_cfg)}, + {IWL_PCI_DEVICE(0x0084, 0x1216, iwl1000_bg_cfg)}, + {IWL_PCI_DEVICE(0x0084, 0x1316, iwl1000_bg_cfg)}, + +/* 100 Series WiFi */ + {IWL_PCI_DEVICE(0x08AE, 0x1005, iwl100_bgn_cfg)}, + {IWL_PCI_DEVICE(0x08AE, 0x1007, iwl100_bg_cfg)}, + {IWL_PCI_DEVICE(0x08AF, 0x1015, iwl100_bgn_cfg)}, + {IWL_PCI_DEVICE(0x08AF, 0x1017, iwl100_bg_cfg)}, + {IWL_PCI_DEVICE(0x08AE, 0x1025, iwl100_bgn_cfg)}, + {IWL_PCI_DEVICE(0x08AE, 0x1027, iwl100_bg_cfg)}, + +/* 130 Series WiFi */ + {IWL_PCI_DEVICE(0x0896, 0x5005, iwl130_bgn_cfg)}, + {IWL_PCI_DEVICE(0x0896, 0x5007, iwl130_bg_cfg)}, + {IWL_PCI_DEVICE(0x0897, 0x5015, iwl130_bgn_cfg)}, + {IWL_PCI_DEVICE(0x0897, 0x5017, iwl130_bg_cfg)}, + {IWL_PCI_DEVICE(0x0896, 0x5025, iwl130_bgn_cfg)}, + {IWL_PCI_DEVICE(0x0896, 0x5027, iwl130_bg_cfg)}, + +/* 2x00 Series */ + {IWL_PCI_DEVICE(0x0890, 0x4022, iwl2000_2bgn_cfg)}, + {IWL_PCI_DEVICE(0x0891, 0x4222, iwl2000_2bgn_cfg)}, + {IWL_PCI_DEVICE(0x0890, 0x4422, iwl2000_2bgn_cfg)}, + {IWL_PCI_DEVICE(0x0890, 0x4026, iwl2000_2bg_cfg)}, + {IWL_PCI_DEVICE(0x0891, 0x4226, iwl2000_2bg_cfg)}, + {IWL_PCI_DEVICE(0x0890, 0x4426, iwl2000_2bg_cfg)}, + +/* 2x30 Series */ + {IWL_PCI_DEVICE(0x0887, 0x4062, iwl2030_2bgn_cfg)}, + {IWL_PCI_DEVICE(0x0888, 0x4262, iwl2030_2bgn_cfg)}, + {IWL_PCI_DEVICE(0x0887, 0x4462, iwl2030_2bgn_cfg)}, + {IWL_PCI_DEVICE(0x0887, 0x4066, iwl2030_2bg_cfg)}, + {IWL_PCI_DEVICE(0x0888, 0x4266, iwl2030_2bg_cfg)}, + {IWL_PCI_DEVICE(0x0887, 0x4466, iwl2030_2bg_cfg)}, + +/* 6x35 Series */ + {IWL_PCI_DEVICE(0x088E, 0x4060, iwl6035_2agn_cfg)}, + {IWL_PCI_DEVICE(0x088F, 0x4260, iwl6035_2agn_cfg)}, + {IWL_PCI_DEVICE(0x088E, 0x4460, iwl6035_2agn_cfg)}, + {IWL_PCI_DEVICE(0x088E, 0x4064, iwl6035_2abg_cfg)}, + {IWL_PCI_DEVICE(0x088F, 0x4264, iwl6035_2abg_cfg)}, + {IWL_PCI_DEVICE(0x088E, 0x4464, iwl6035_2abg_cfg)}, + {IWL_PCI_DEVICE(0x088E, 0x4066, iwl6035_2bg_cfg)}, + {IWL_PCI_DEVICE(0x088F, 0x4266, iwl6035_2bg_cfg)}, + {IWL_PCI_DEVICE(0x088E, 0x4466, iwl6035_2bg_cfg)}, + +/* 105 Series */ + {IWL_PCI_DEVICE(0x0894, 0x0022, iwl105_bgn_cfg)}, + {IWL_PCI_DEVICE(0x0895, 0x0222, iwl105_bgn_cfg)}, + {IWL_PCI_DEVICE(0x0894, 0x0422, iwl105_bgn_cfg)}, + {IWL_PCI_DEVICE(0x0894, 0x0026, iwl105_bg_cfg)}, + {IWL_PCI_DEVICE(0x0895, 0x0226, iwl105_bg_cfg)}, + {IWL_PCI_DEVICE(0x0894, 0x0426, iwl105_bg_cfg)}, + +/* 135 Series */ + {IWL_PCI_DEVICE(0x0892, 0x0062, iwl135_bgn_cfg)}, + {IWL_PCI_DEVICE(0x0893, 0x0262, iwl135_bgn_cfg)}, + {IWL_PCI_DEVICE(0x0892, 0x0462, iwl135_bgn_cfg)}, + {IWL_PCI_DEVICE(0x0892, 0x0066, iwl135_bg_cfg)}, + {IWL_PCI_DEVICE(0x0893, 0x0266, iwl135_bg_cfg)}, + {IWL_PCI_DEVICE(0x0892, 0x0466, iwl135_bg_cfg)}, + + {0} +}; +MODULE_DEVICE_TABLE(pci, iwl_hw_card_ids); + +static struct pci_driver iwl_driver = { + .name = DRV_NAME, + .id_table = iwl_hw_card_ids, + .probe = iwl_pci_probe, + .remove = __devexit_p(iwl_pci_remove), + .driver.pm = IWL_PM_OPS, +}; + static int __init iwl_init(void) { @@ -3756,10 +4017,12 @@ static int __init iwl_init(void) return ret; } - ret = iwl_pci_register_driver(); - - if (ret) + ret = pci_register_driver(&iwl_driver); + if (ret) { + pr_err("Unable to initialize PCI module\n"); goto error_register; + } + return ret; error_register: @@ -3769,7 +4032,7 @@ static int __init iwl_init(void) static void __exit iwl_exit(void) { - iwl_pci_unregister_driver(); + pci_unregister_driver(&iwl_driver); iwlagn_rate_control_unregister(); } @@ -3811,51 +4074,3 @@ MODULE_PARM_DESC(plcp_check, "Check plcp health (default: 1 [enabled])"); module_param_named(ack_check, iwlagn_mod_params.ack_check, bool, S_IRUGO); MODULE_PARM_DESC(ack_check, "Check ack health (default: 0 [disabled])"); - -module_param_named(wd_disable, iwlagn_mod_params.wd_disable, bool, S_IRUGO); -MODULE_PARM_DESC(wd_disable, - "Disable stuck queue watchdog timer (default: 0 [enabled])"); - -/* - * set bt_coex_active to true, uCode will do kill/defer - * every time the priority line is asserted (BT is sending signals on the - * priority line in the PCIx). - * set bt_coex_active to false, uCode will ignore the BT activity and - * perform the normal operation - * - * User might experience transmit issue on some platform due to WiFi/BT - * co-exist problem. The possible behaviors are: - * Able to scan and finding all the available AP - * Not able to associate with any AP - * On those platforms, WiFi communication can be restored by set - * "bt_coex_active" module parameter to "false" - * - * default: bt_coex_active = true (BT_COEX_ENABLE) - */ -module_param_named(bt_coex_active, iwlagn_mod_params.bt_coex_active, - bool, S_IRUGO); -MODULE_PARM_DESC(bt_coex_active, "enable wifi/bt co-exist (default: enable)"); - -module_param_named(led_mode, iwlagn_mod_params.led_mode, int, S_IRUGO); -MODULE_PARM_DESC(led_mode, "0=system default, " - "1=On(RF On)/Off(RF Off), 2=blinking (default: 0)"); - -module_param_named(power_save, iwlagn_mod_params.power_save, - bool, S_IRUGO); -MODULE_PARM_DESC(power_save, - "enable WiFi power management (default: disable)"); - -module_param_named(power_level, iwlagn_mod_params.power_level, - int, S_IRUGO); -MODULE_PARM_DESC(power_level, - "default power save level (range from 1 - 5, default: 1)"); - -/* - * For now, keep using power level 1 instead of automatically - * adjusting ... - */ -module_param_named(no_sleep_autoadjust, iwlagn_mod_params.no_sleep_autoadjust, - bool, S_IRUGO); -MODULE_PARM_DESC(no_sleep_autoadjust, - "don't automatically adjust sleep level " - "according to maximum network latency (default: true)"); diff --git a/trunk/drivers/net/wireless/iwlwifi/iwl-agn.h b/trunk/drivers/net/wireless/iwlwifi/iwl-agn.h index 4351151e2a91..d1716844002e 100644 --- a/trunk/drivers/net/wireless/iwlwifi/iwl-agn.h +++ b/trunk/drivers/net/wireless/iwlwifi/iwl-agn.h @@ -125,18 +125,10 @@ irqreturn_t iwl_isr_ict(int irq, void *data); static inline void iwl_synchronize_irq(struct iwl_priv *priv) { /* wait to make sure we flush pending tasklet*/ - synchronize_irq(priv->bus.irq); + synchronize_irq(priv->pci_dev->irq); tasklet_kill(&priv->irq_tasklet); } -static inline void iwl_set_calib_hdr(struct iwl_calib_hdr *hdr, u8 cmd) -{ - hdr->op_code = cmd; - hdr->first_group = 0; - hdr->groups_num = 1; - hdr->data_valid = 1; -} - int iwl_prepare_card_hw(struct iwl_priv *priv); int iwlagn_start_device(struct iwl_priv *priv); @@ -169,7 +161,7 @@ void iwlagn_send_prio_tbl(struct iwl_priv *priv); int iwlagn_run_init_ucode(struct iwl_priv *priv); int iwlagn_load_ucode_wait_alive(struct iwl_priv *priv, struct fw_img *image, - enum iwlagn_ucode_type ucode_type); + int subtype, int alternate_subtype); /* lib */ void iwl_check_abort_status(struct iwl_priv *priv, @@ -182,6 +174,7 @@ void iwlagn_temperature(struct iwl_priv *priv); u16 iwlagn_eeprom_calib_version(struct iwl_priv *priv); const u8 *iwlagn_eeprom_query_addr(const struct iwl_priv *priv, size_t offset); +void iwlagn_rx_queue_reset(struct iwl_priv *priv, struct iwl_rx_queue *rxq); int iwlagn_rx_init(struct iwl_priv *priv, struct iwl_rx_queue *rxq); int iwlagn_hw_nic_init(struct iwl_priv *priv); int iwlagn_wait_tx_queue_empty(struct iwl_priv *priv); @@ -193,6 +186,7 @@ void iwlagn_rx_queue_restock(struct iwl_priv *priv); void iwlagn_rx_allocate(struct iwl_priv *priv, gfp_t priority); void iwlagn_rx_replenish(struct iwl_priv *priv); void iwlagn_rx_replenish_now(struct iwl_priv *priv); +void iwlagn_rx_queue_free(struct iwl_priv *priv, struct iwl_rx_queue *rxq); int iwlagn_rxq_stop(struct iwl_priv *priv); int iwlagn_hwrate_to_mac80211_idx(u32 rate_n_flags, enum ieee80211_band band); void iwl_setup_rx_handlers(struct iwl_priv *priv); @@ -218,6 +212,8 @@ void iwlagn_rx_reply_compressed_ba(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb); int iwlagn_tx_queue_reclaim(struct iwl_priv *priv, int txq_id, int index); void iwlagn_hw_txq_ctx_free(struct iwl_priv *priv); +int iwlagn_txq_ctx_alloc(struct iwl_priv *priv); +void iwlagn_txq_ctx_reset(struct iwl_priv *priv); void iwlagn_txq_ctx_stop(struct iwl_priv *priv); static inline u32 iwl_tx_status_to_mac80211(u32 status) @@ -256,7 +252,6 @@ int iwlagn_manage_ibss_station(struct iwl_priv *priv, /* hcmd */ int iwlagn_send_tx_ant_config(struct iwl_priv *priv, u8 valid_tx_ant); int iwlagn_send_beacon_cmd(struct iwl_priv *priv); -int iwlagn_set_pan_params(struct iwl_priv *priv); /* bt coex */ void iwlagn_send_advance_bt_config(struct iwl_priv *priv); @@ -301,8 +296,6 @@ int iwl_sta_rx_agg_start(struct iwl_priv *priv, struct ieee80211_sta *sta, int iwl_sta_rx_agg_stop(struct iwl_priv *priv, struct ieee80211_sta *sta, int tid); void iwl_sta_modify_sleep_tx_count(struct iwl_priv *priv, int sta_id, int cnt); -int iwl_update_bcast_station(struct iwl_priv *priv, - struct iwl_rxon_context *ctx); int iwl_update_bcast_stations(struct iwl_priv *priv); void iwlagn_mac_sta_notify(struct ieee80211_hw *hw, struct ieee80211_vif *vif, @@ -350,9 +343,6 @@ extern int iwl_alive_start(struct iwl_priv *priv); /* svtool */ #ifdef CONFIG_IWLWIFI_DEVICE_SVTOOL extern int iwl_testmode_cmd(struct ieee80211_hw *hw, void *data, int len); -extern int iwl_testmode_dump(struct ieee80211_hw *hw, struct sk_buff *skb, - struct netlink_callback *cb, - void *data, int len); extern void iwl_testmode_init(struct iwl_priv *priv); extern void iwl_testmode_cleanup(struct iwl_priv *priv); #else @@ -362,13 +352,6 @@ int iwl_testmode_cmd(struct ieee80211_hw *hw, void *data, int len) return -ENOSYS; } static inline -int iwl_testmode_dump(struct ieee80211_hw *hw, struct sk_buff *skb, - struct netlink_callback *cb, - void *data, int len) -{ - return -ENOSYS; -} -static inline void iwl_testmode_init(struct iwl_priv *priv) { } @@ -378,8 +361,4 @@ void iwl_testmode_cleanup(struct iwl_priv *priv) } #endif -int iwl_probe(void *bus_specific, struct iwl_bus_ops *bus_ops, - struct iwl_cfg *cfg); -void __devexit iwl_remove(struct iwl_priv * priv); - #endif /* __iwl_agn_h__ */ diff --git a/trunk/drivers/net/wireless/iwlwifi/iwl-commands.h b/trunk/drivers/net/wireless/iwlwifi/iwl-commands.h index 8a2edf8dce32..6ee5f1aa555c 100644 --- a/trunk/drivers/net/wireless/iwlwifi/iwl-commands.h +++ b/trunk/drivers/net/wireless/iwlwifi/iwl-commands.h @@ -384,6 +384,18 @@ struct iwl_tx_ant_config_cmd { #define UCODE_VALID_OK cpu_to_le32(0x1) +enum iwlagn_ucode_subtype { + UCODE_SUBTYPE_REGULAR = 0, + UCODE_SUBTYPE_REGULAR_NEW = 1, + UCODE_SUBTYPE_INIT = 9, + + /* + * Not a valid subtype, the ucode has just a u8, so + * we can use something > 0xff for this value. + */ + UCODE_SUBTYPE_NONE_LOADED = 0x100, +}; + /** * REPLY_ALIVE = 0x1 (response only, not a command) * @@ -972,26 +984,15 @@ struct iwl_rem_sta_cmd { u8 reserved2[2]; } __packed; - -/* WiFi queues mask */ -#define IWL_SCD_BK_MSK cpu_to_le32(BIT(0)) -#define IWL_SCD_BE_MSK cpu_to_le32(BIT(1)) -#define IWL_SCD_VI_MSK cpu_to_le32(BIT(2)) -#define IWL_SCD_VO_MSK cpu_to_le32(BIT(3)) -#define IWL_SCD_MGMT_MSK cpu_to_le32(BIT(3)) - -/* PAN queues mask */ -#define IWL_PAN_SCD_BK_MSK cpu_to_le32(BIT(4)) -#define IWL_PAN_SCD_BE_MSK cpu_to_le32(BIT(5)) -#define IWL_PAN_SCD_VI_MSK cpu_to_le32(BIT(6)) -#define IWL_PAN_SCD_VO_MSK cpu_to_le32(BIT(7)) -#define IWL_PAN_SCD_MGMT_MSK cpu_to_le32(BIT(7)) -#define IWL_PAN_SCD_MULTICAST_MSK cpu_to_le32(BIT(8)) - +#define IWL_TX_FIFO_BK_MSK cpu_to_le32(BIT(0)) +#define IWL_TX_FIFO_BE_MSK cpu_to_le32(BIT(1)) +#define IWL_TX_FIFO_VI_MSK cpu_to_le32(BIT(2)) +#define IWL_TX_FIFO_VO_MSK cpu_to_le32(BIT(3)) #define IWL_AGG_TX_QUEUE_MSK cpu_to_le32(0xffc00) #define IWL_DROP_SINGLE 0 -#define IWL_DROP_ALL (BIT(IWL_RXON_CTX_BSS) | BIT(IWL_RXON_CTX_PAN)) +#define IWL_DROP_SELECTED 1 +#define IWL_DROP_ALL 2 /* * REPLY_TXFIFO_FLUSH = 0x1e(command and response) diff --git a/trunk/drivers/net/wireless/iwlwifi/iwl-core.c b/trunk/drivers/net/wireless/iwlwifi/iwl-core.c index f91e306c2498..5416b12cd931 100644 --- a/trunk/drivers/net/wireless/iwlwifi/iwl-core.c +++ b/trunk/drivers/net/wireless/iwlwifi/iwl-core.c @@ -43,6 +43,27 @@ #include "iwl-helpers.h" #include "iwl-agn.h" + +/* + * set bt_coex_active to true, uCode will do kill/defer + * every time the priority line is asserted (BT is sending signals on the + * priority line in the PCIx). + * set bt_coex_active to false, uCode will ignore the BT activity and + * perform the normal operation + * + * User might experience transmit issue on some platform due to WiFi/BT + * co-exist problem. The possible behaviors are: + * Able to scan and finding all the available AP + * Not able to associate with any AP + * On those platforms, WiFi communication can be restored by set + * "bt_coex_active" module parameter to "false" + * + * default: bt_coex_active = true (BT_COEX_ENABLE) + */ +bool bt_coex_active = true; +module_param(bt_coex_active, bool, S_IRUGO); +MODULE_PARM_DESC(bt_coex_active, "enable wifi/bluetooth co-exist"); + u32 iwl_debug_level; const u8 iwl_bcast_addr[ETH_ALEN] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; @@ -143,7 +164,7 @@ int iwlcore_init_geos(struct iwl_priv *priv) sband->bitrates = &rates[IWL_FIRST_OFDM_RATE]; sband->n_bitrates = IWL_RATE_COUNT_LEGACY - IWL_FIRST_OFDM_RATE; - if (priv->cfg->sku & EEPROM_SKU_CAP_11N_ENABLE) + if (priv->cfg->sku & IWL_SKU_N) iwlcore_init_ht_hw_capab(priv, &sband->ht_cap, IEEE80211_BAND_5GHZ); @@ -153,7 +174,7 @@ int iwlcore_init_geos(struct iwl_priv *priv) sband->bitrates = rates; sband->n_bitrates = IWL_RATE_COUNT_LEGACY; - if (priv->cfg->sku & EEPROM_SKU_CAP_11N_ENABLE) + if (priv->cfg->sku & IWL_SKU_N) iwlcore_init_ht_hw_capab(priv, &sband->ht_cap, IEEE80211_BAND_2GHZ); @@ -208,12 +229,12 @@ int iwlcore_init_geos(struct iwl_priv *priv) priv->tx_power_next = max_tx_power; if ((priv->bands[IEEE80211_BAND_5GHZ].n_channels == 0) && - priv->cfg->sku & EEPROM_SKU_CAP_BAND_52GHZ) { - char buf[32]; - priv->bus.ops->get_hw_id(&priv->bus, buf, sizeof(buf)); + priv->cfg->sku & IWL_SKU_A) { IWL_INFO(priv, "Incorrectly detected BG card as ABG. " - "Please send your %s to maintainer.\n", buf); - priv->cfg->sku &= ~EEPROM_SKU_CAP_BAND_52GHZ; + "Please send your PCI ID 0x%04X:0x%04X to maintainer.\n", + priv->pci_dev->device, + priv->pci_dev->subsystem_device); + priv->cfg->sku &= ~IWL_SKU_A; } IWL_INFO(priv, "Tunable channels: %d 802.11bg, %d 802.11a channels\n", @@ -526,6 +547,19 @@ int iwl_full_rxon_required(struct iwl_priv *priv, return 0; } +u8 iwl_rate_get_lowest_plcp(struct iwl_priv *priv, + struct iwl_rxon_context *ctx) +{ + /* + * Assign the lowest rate -- should really get this from + * the beacon skb from mac80211. + */ + if (ctx->staging.flags & RXON_FLG_BAND_24G_MSK) + return IWL_RATE_1M_PLCP; + else + return IWL_RATE_6M_PLCP; +} + static void _iwl_set_rxon_ht(struct iwl_priv *priv, struct iwl_ht_config *ht_conf, struct iwl_rxon_context *ctx) @@ -585,7 +619,8 @@ static void _iwl_set_rxon_ht(struct iwl_priv *priv, rxon->flags |= RXON_FLG_CHANNEL_MODE_LEGACY; } - iwlagn_set_rxon_chain(priv, ctx); + if (priv->cfg->ops->hcmd->set_rxon_chain) + priv->cfg->ops->hcmd->set_rxon_chain(priv, ctx); IWL_DEBUG_ASSOC(priv, "rxon flags 0x%X operation mode :0x%X " "extension channel offset 0x%x\n", @@ -983,6 +1018,8 @@ void iwl_apm_stop(struct iwl_priv *priv) int iwl_apm_init(struct iwl_priv *priv) { int ret = 0; + u16 lctl; + IWL_DEBUG_INFO(priv, "Init card's basic functions\n"); /* @@ -1011,7 +1048,27 @@ int iwl_apm_init(struct iwl_priv *priv) iwl_set_bit(priv, CSR_HW_IF_CONFIG_REG, CSR_HW_IF_CONFIG_REG_BIT_HAP_WAKE_L1A); - priv->bus.ops->apm_config(&priv->bus); + /* + * HW bug W/A for instability in PCIe bus L0->L0S->L1 transition. + * Check if BIOS (or OS) enabled L1-ASPM on this device. + * If so (likely), disable L0S, so device moves directly L0->L1; + * costs negligible amount of power savings. + * If not (unlikely), enable L0S, so there is at least some + * power savings, even without L1. + */ + lctl = iwl_pcie_link_ctl(priv); + if ((lctl & PCI_CFG_LINK_CTRL_VAL_L1_EN) == + PCI_CFG_LINK_CTRL_VAL_L1_EN) { + /* L1-ASPM enabled; disable(!) L0S */ + iwl_set_bit(priv, CSR_GIO_REG, + CSR_GIO_REG_VAL_L0S_ENABLED); + IWL_DEBUG_POWER(priv, "L1 Enabled; Disabling L0S\n"); + } else { + /* L1-ASPM disabled; enable(!) L0S */ + iwl_clear_bit(priv, CSR_GIO_REG, + CSR_GIO_REG_VAL_L0S_ENABLED); + IWL_DEBUG_POWER(priv, "L1 Disabled; Enabling L0S\n"); + } /* Configure analog phase-lock-loop before activating to D0A */ if (priv->cfg->base_params->pll_cfg_val) @@ -1122,7 +1179,7 @@ void iwl_send_bt_config(struct iwl_priv *priv) .kill_cts_mask = 0, }; - if (!iwlagn_mod_params.bt_coex_active) + if (!bt_coex_active) bt_cmd.flags = BT_COEX_DISABLE; else bt_cmd.flags = BT_COEX_ENABLE; @@ -1215,7 +1272,8 @@ static int iwl_set_mode(struct iwl_priv *priv, struct iwl_rxon_context *ctx) { iwl_connection_init_rx_config(priv, ctx); - iwlagn_set_rxon_chain(priv, ctx); + if (priv->cfg->ops->hcmd->set_rxon_chain) + priv->cfg->ops->hcmd->set_rxon_chain(priv, ctx); return iwlagn_commit_rxon(priv, ctx); } @@ -1370,6 +1428,20 @@ void iwl_mac_remove_interface(struct ieee80211_hw *hw, } +int iwl_alloc_txq_mem(struct iwl_priv *priv) +{ + if (!priv->txq) + priv->txq = kzalloc( + sizeof(struct iwl_tx_queue) * + priv->cfg->base_params->num_of_queues, + GFP_KERNEL); + if (!priv->txq) { + IWL_ERR(priv, "Not enough memory for txq\n"); + return -ENOMEM; + } + return 0; +} + void iwl_free_txq_mem(struct iwl_priv *priv) { kfree(priv->txq); @@ -1688,7 +1760,6 @@ int iwl_mac_change_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct iwl_rxon_context *ctx = iwl_rxon_ctx_from_vif(vif); struct iwl_rxon_context *bss_ctx = &priv->contexts[IWL_RXON_CTX_BSS]; struct iwl_rxon_context *tmp; - enum nl80211_iftype newviftype = newtype; u32 interface_modes; int err; @@ -1744,7 +1815,7 @@ int iwl_mac_change_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif, /* success */ iwl_teardown_interface(priv, vif, true); - vif->type = newviftype; + vif->type = newtype; vif->p2p = newp2p; err = iwl_setup_interface(priv, ctx); WARN_ON(err); @@ -1837,7 +1908,7 @@ void iwl_setup_watchdog(struct iwl_priv *priv) { unsigned int timeout = priv->cfg->base_params->wd_timeout; - if (timeout && !iwlagn_mod_params.wd_disable) + if (timeout) mod_timer(&priv->watchdog, jiffies + msecs_to_jiffies(IWL_WD_TICK(timeout))); else @@ -1898,8 +1969,11 @@ __le32 iwl_add_beacon_time(struct iwl_priv *priv, u32 base, #ifdef CONFIG_PM -int iwl_suspend(struct iwl_priv *priv) +int iwl_pci_suspend(struct device *device) { + struct pci_dev *pdev = to_pci_dev(device); + struct iwl_priv *priv = pci_get_drvdata(pdev); + /* * This function is called when system goes into suspend state * mac80211 will call iwl_mac_stop() from the mac80211 suspend function @@ -1912,10 +1986,18 @@ int iwl_suspend(struct iwl_priv *priv) return 0; } -int iwl_resume(struct iwl_priv *priv) +int iwl_pci_resume(struct device *device) { + struct pci_dev *pdev = to_pci_dev(device); + struct iwl_priv *priv = pci_get_drvdata(pdev); bool hw_rfkill = false; + /* + * We disable the RETRY_TIMEOUT register (0x41) to keep + * PCI Tx retries from interfering with C3 CPU state. + */ + pci_write_config_byte(pdev, PCI_CFG_RETRY_TIMEOUT, 0x00); + iwl_enable_interrupts(priv); if (!(iwl_read32(priv, CSR_GP_CNTRL) & @@ -1932,4 +2014,13 @@ int iwl_resume(struct iwl_priv *priv) return 0; } +const struct dev_pm_ops iwl_pm_ops = { + .suspend = iwl_pci_suspend, + .resume = iwl_pci_resume, + .freeze = iwl_pci_suspend, + .thaw = iwl_pci_resume, + .poweroff = iwl_pci_suspend, + .restore = iwl_pci_resume, +}; + #endif /* CONFIG_PM */ diff --git a/trunk/drivers/net/wireless/iwlwifi/iwl-core.h b/trunk/drivers/net/wireless/iwlwifi/iwl-core.h index 6c21de9f5b60..05ea88aa76e3 100644 --- a/trunk/drivers/net/wireless/iwlwifi/iwl-core.h +++ b/trunk/drivers/net/wireless/iwlwifi/iwl-core.h @@ -76,10 +76,27 @@ struct iwl_cmd; #define DRV_COPYRIGHT "Copyright(c) 2003-2011 Intel Corporation" #define DRV_AUTHOR "" +#define IWL_PCI_DEVICE(dev, subdev, cfg) \ + .vendor = PCI_VENDOR_ID_INTEL, .device = (dev), \ + .subvendor = PCI_ANY_ID, .subdevice = (subdev), \ + .driver_data = (kernel_ulong_t)&(cfg) + #define TIME_UNIT 1024 +#define IWL_SKU_G 0x1 +#define IWL_SKU_A 0x2 +#define IWL_SKU_N 0x8 + #define IWL_CMD(x) case x: return #x +struct iwl_hcmd_ops { + void (*set_rxon_chain)(struct iwl_priv *priv, + struct iwl_rxon_context *ctx); + int (*set_tx_ant)(struct iwl_priv *priv, u8 valid_tx_ant); + void (*send_bt_config)(struct iwl_priv *priv); + int (*set_pan_params)(struct iwl_priv *priv); +}; + struct iwl_hcmd_utils_ops { u16 (*build_addsta_hcmd)(const struct iwl_addsta_cmd *cmd, u8 *data); void (*gain_computation)(struct iwl_priv *priv, @@ -129,6 +146,10 @@ struct iwl_lib_ops { /* temperature */ struct iwl_temp_ops temp_ops; + + int (*txfifo_flush)(struct iwl_priv *priv, u16 flush_control); + void (*dev_txfifo_flush)(struct iwl_priv *priv, u16 flush_control); + }; /* NIC specific ops */ @@ -138,6 +159,7 @@ struct iwl_nic_ops { struct iwl_ops { const struct iwl_lib_ops *lib; + const struct iwl_hcmd_ops *hcmd; const struct iwl_hcmd_utils_ops *utils; const struct iwl_nic_ops *nic; }; @@ -151,12 +173,6 @@ struct iwl_mod_params { int restart_fw; /* def: 1 = restart firmware */ bool plcp_check; /* def: true = enable plcp health check */ bool ack_check; /* def: false = disable ack health check */ - bool wd_disable; /* def: false = enable stuck queue check */ - bool bt_coex_active; /* def: true = enable bt coex */ - int led_mode; /* def: 0 = system default */ - bool no_sleep_autoadjust; /* def: true = disable autoadjust */ - bool power_save; /* def: false = disable power save */ - int power_level; /* def: 1 = power level */ }; /* @@ -273,7 +289,7 @@ struct iwl_cfg { const unsigned int ucode_api_min; u8 valid_tx_ant; u8 valid_rx_ant; - u16 sku; + unsigned int sku; u16 eeprom_ver; u16 eeprom_calib_ver; const struct iwl_ops *ops; @@ -328,6 +344,7 @@ void iwl_mac_remove_interface(struct ieee80211_hw *hw, int iwl_mac_change_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif, enum nl80211_iftype newtype, bool newp2p); +int iwl_alloc_txq_mem(struct iwl_priv *priv); void iwl_free_txq_mem(struct iwl_priv *priv); #ifdef CONFIG_IWLWIFI_DEBUGFS @@ -373,6 +390,7 @@ static inline void iwl_update_stats(struct iwl_priv *priv, bool is_tx, ******************************************************/ void iwl_cmd_queue_free(struct iwl_priv *priv); void iwl_cmd_queue_unmap(struct iwl_priv *priv); +int iwl_rx_queue_alloc(struct iwl_priv *priv); void iwl_rx_queue_update_write_ptr(struct iwl_priv *priv, struct iwl_rx_queue *q); int iwl_rx_queue_space(const struct iwl_rx_queue *q); @@ -386,9 +404,11 @@ void iwl_chswitch_done(struct iwl_priv *priv, bool is_success); * TX ******************************************************/ void iwl_txq_update_write_ptr(struct iwl_priv *priv, struct iwl_tx_queue *txq); +int iwl_tx_queue_init(struct iwl_priv *priv, struct iwl_tx_queue *txq, + int slots_num, u32 txq_id); +void iwl_tx_queue_reset(struct iwl_priv *priv, struct iwl_tx_queue *txq, + int slots_num, u32 txq_id); void iwl_tx_queue_free(struct iwl_priv *priv, int txq_id); -int iwl_queue_init(struct iwl_priv *priv, struct iwl_queue *q, - int count, int slots_num, u32 id); void iwl_tx_queue_unmap(struct iwl_priv *priv, int txq_id); void iwl_setup_watchdog(struct iwl_priv *priv); /***************************************************** @@ -396,6 +416,13 @@ void iwl_setup_watchdog(struct iwl_priv *priv); ****************************************************/ int iwl_set_tx_power(struct iwl_priv *priv, s8 tx_power, bool force); +/******************************************************************************* + * Rate + ******************************************************************************/ + +u8 iwl_rate_get_lowest_plcp(struct iwl_priv *priv, + struct iwl_rxon_context *ctx); + /******************************************************************************* * Scanning ******************************************************************************/ @@ -453,14 +480,36 @@ int iwl_send_cmd_pdu_async(struct iwl_priv *priv, u8 id, u16 len, int iwl_enqueue_hcmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd); + +/***************************************************** + * PCI * + *****************************************************/ + +static inline u16 iwl_pcie_link_ctl(struct iwl_priv *priv) +{ + int pos; + u16 pci_lnk_ctl; + pos = pci_find_capability(priv->pci_dev, PCI_CAP_ID_EXP); + pci_read_config_word(priv->pci_dev, pos + PCI_EXP_LNKCTL, &pci_lnk_ctl); + return pci_lnk_ctl; +} + void iwl_bg_watchdog(unsigned long data); u32 iwl_usecs_to_beacons(struct iwl_priv *priv, u32 usec, u32 beacon_interval); __le32 iwl_add_beacon_time(struct iwl_priv *priv, u32 base, u32 addon, u32 beacon_interval); #ifdef CONFIG_PM -int iwl_suspend(struct iwl_priv *priv); -int iwl_resume(struct iwl_priv *priv); +int iwl_pci_suspend(struct device *device); +int iwl_pci_resume(struct device *device); +extern const struct dev_pm_ops iwl_pm_ops; + +#define IWL_PM_OPS (&iwl_pm_ops) + +#else /* !CONFIG_PM */ + +#define IWL_PM_OPS NULL + #endif /* !CONFIG_PM */ /***************************************************** @@ -575,6 +624,7 @@ static inline bool iwl_advanced_bt_coexist(struct iwl_priv *priv) priv->cfg->bt_params->advanced_bt_coexist; } +extern bool bt_coex_active; extern bool bt_siso_mode; diff --git a/trunk/drivers/net/wireless/iwlwifi/iwl-debug.h b/trunk/drivers/net/wireless/iwlwifi/iwl-debug.h index eb95d1a37487..2824ccbcc1fc 100644 --- a/trunk/drivers/net/wireless/iwlwifi/iwl-debug.h +++ b/trunk/drivers/net/wireless/iwlwifi/iwl-debug.h @@ -32,10 +32,10 @@ struct iwl_priv; extern u32 iwl_debug_level; -#define IWL_ERR(p, f, a...) dev_err(p->bus.ops->get_dev(&p->bus), f, ## a) -#define IWL_WARN(p, f, a...) dev_warn(p->bus.ops->get_dev(&p->bus), f, ## a) -#define IWL_INFO(p, f, a...) dev_info(p->bus.ops->get_dev(&p->bus), f, ## a) -#define IWL_CRIT(p, f, a...) dev_crit(p->bus.ops->get_dev(&p->bus), f, ## a) +#define IWL_ERR(p, f, a...) dev_err(&((p)->pci_dev->dev), f, ## a) +#define IWL_WARN(p, f, a...) dev_warn(&((p)->pci_dev->dev), f, ## a) +#define IWL_INFO(p, f, a...) dev_info(&((p)->pci_dev->dev), f, ## a) +#define IWL_CRIT(p, f, a...) dev_crit(&((p)->pci_dev->dev), f, ## a) #define iwl_print_hex_error(priv, p, len) \ do { \ @@ -125,13 +125,13 @@ static inline void iwl_dbgfs_unregister(struct iwl_priv *priv) /* 0x00000F00 - 0x00000100 */ #define IWL_DL_POWER (1 << 8) #define IWL_DL_TEMP (1 << 9) -/* reserved (1 << 10) */ +#define IWL_DL_NOTIF (1 << 10) #define IWL_DL_SCAN (1 << 11) /* 0x0000F000 - 0x00001000 */ #define IWL_DL_ASSOC (1 << 12) #define IWL_DL_DROP (1 << 13) -/* reserved (1 << 14) */ -#define IWL_DL_COEX (1 << 15) +#define IWL_DL_TXPOWER (1 << 14) +#define IWL_DL_AP (1 << 15) /* 0x000F0000 - 0x00010000 */ #define IWL_DL_FW (1 << 16) #define IWL_DL_RF_KILL (1 << 17) @@ -171,10 +171,12 @@ static inline void iwl_dbgfs_unregister(struct iwl_priv *priv) #define IWL_DEBUG_DROP(p, f, a...) IWL_DEBUG(p, IWL_DL_DROP, f, ## a) #define IWL_DEBUG_DROP_LIMIT(p, f, a...) \ IWL_DEBUG_LIMIT(p, IWL_DL_DROP, f, ## a) -#define IWL_DEBUG_COEX(p, f, a...) IWL_DEBUG(p, IWL_DL_COEX, f, ## a) +#define IWL_DEBUG_AP(p, f, a...) IWL_DEBUG(p, IWL_DL_AP, f, ## a) +#define IWL_DEBUG_TXPOWER(p, f, a...) IWL_DEBUG(p, IWL_DL_TXPOWER, f, ## a) #define IWL_DEBUG_RATE(p, f, a...) IWL_DEBUG(p, IWL_DL_RATE, f, ## a) #define IWL_DEBUG_RATE_LIMIT(p, f, a...) \ IWL_DEBUG_LIMIT(p, IWL_DL_RATE, f, ## a) +#define IWL_DEBUG_NOTIF(p, f, a...) IWL_DEBUG(p, IWL_DL_NOTIF, f, ## a) #define IWL_DEBUG_ASSOC(p, f, a...) \ IWL_DEBUG(p, IWL_DL_ASSOC | IWL_DL_INFO, f, ## a) #define IWL_DEBUG_ASSOC_LIMIT(p, f, a...) \ diff --git a/trunk/drivers/net/wireless/iwlwifi/iwl-debugfs.c b/trunk/drivers/net/wireless/iwlwifi/iwl-debugfs.c index 6f9ebae8ca06..0e6a04b739ad 100644 --- a/trunk/drivers/net/wireless/iwlwifi/iwl-debugfs.c +++ b/trunk/drivers/net/wireless/iwlwifi/iwl-debugfs.c @@ -227,7 +227,7 @@ static ssize_t iwl_dbgfs_sram_read(struct file *file, /* default is to dump the entire data segment */ if (!priv->dbgfs_sram_offset && !priv->dbgfs_sram_len) { priv->dbgfs_sram_offset = 0x800000; - if (priv->ucode_type == IWL_UCODE_INIT) + if (priv->ucode_type == UCODE_SUBTYPE_INIT) priv->dbgfs_sram_len = priv->ucode_init.data.len; else priv->dbgfs_sram_len = priv->ucode_rt.data.len; @@ -2493,7 +2493,7 @@ static ssize_t iwl_dbgfs_txfifo_flush_write(struct file *file, if (iwl_is_rfkill(priv)) return -EFAULT; - iwlagn_dev_txfifo_flush(priv, IWL_DROP_ALL); + priv->cfg->ops->lib->dev_txfifo_flush(priv, IWL_DROP_ALL); return count; } @@ -2693,7 +2693,8 @@ int iwl_dbgfs_register(struct iwl_priv *priv, const char *name) DEBUGFS_ADD_FILE(ucode_rx_stats, dir_debug, S_IRUSR); DEBUGFS_ADD_FILE(ucode_tx_stats, dir_debug, S_IRUSR); DEBUGFS_ADD_FILE(ucode_general_stats, dir_debug, S_IRUSR); - DEBUGFS_ADD_FILE(txfifo_flush, dir_debug, S_IWUSR); + if (priv->cfg->ops->lib->dev_txfifo_flush) + DEBUGFS_ADD_FILE(txfifo_flush, dir_debug, S_IWUSR); DEBUGFS_ADD_FILE(protection_mode, dir_debug, S_IWUSR | S_IRUSR); DEBUGFS_ADD_FILE(sensitivity, dir_debug, S_IRUSR); diff --git a/trunk/drivers/net/wireless/iwlwifi/iwl-dev.h b/trunk/drivers/net/wireless/iwlwifi/iwl-dev.h index c6560e97a62b..7ad98d868954 100644 --- a/trunk/drivers/net/wireless/iwlwifi/iwl-dev.h +++ b/trunk/drivers/net/wireless/iwlwifi/iwl-dev.h @@ -49,8 +49,6 @@ #include "iwl-agn-rs.h" #include "iwl-agn-tt.h" -#define DRV_NAME "iwlagn" - struct iwl_tx_queue; /* CT-KILL constants */ @@ -666,6 +664,7 @@ struct iwl_hw_params { u16 max_rxq_size; u16 max_rxq_log; u32 rx_page_order; + u32 rx_wrt_ptr_reg; u8 max_stations; u8 ht40_channel; u8 max_beacon_itrvl; /* in 1024 ms */ @@ -1170,82 +1169,14 @@ enum iwl_scan_type { IWL_SCAN_OFFCH_TX, }; -enum iwlagn_ucode_type { - IWL_UCODE_NONE, - IWL_UCODE_REGULAR, - IWL_UCODE_INIT, - IWL_UCODE_WOWLAN, -}; - #ifdef CONFIG_IWLWIFI_DEVICE_SVTOOL struct iwl_testmode_trace { - u32 buff_size; - u32 total_size; - u32 num_chunks; u8 *cpu_addr; u8 *trace_addr; dma_addr_t dma_addr; bool trace_enabled; }; #endif - -struct iwl_bus; - -/** - * struct iwl_bus_ops - bus specific operations - - * @get_pm_support: must returns true if the bus can go to sleep - * @apm_config: will be called during the config of the APM configuration - * @set_drv_data: set the priv pointer to the bus layer - * @get_dev: returns the device struct - * @get_irq: returns the irq number - * @get_hw_id: prints the hw_id in the provided buffer - * @write8: write a byte to register at offset ofs - * @write32: write a dword to register at offset ofs - * @wread32: read a dword at register at offset ofs - */ -struct iwl_bus_ops { - bool (*get_pm_support)(struct iwl_bus *bus); - void (*apm_config)(struct iwl_bus *bus); - void (*set_drv_data)(struct iwl_bus *bus, void *priv); - struct device *(*get_dev)(const struct iwl_bus *bus); - unsigned int (*get_irq)(const struct iwl_bus *bus); - void (*get_hw_id)(struct iwl_bus *bus, char buf[], int buf_len); - void (*write8)(struct iwl_bus *bus, u32 ofs, u8 val); - void (*write32)(struct iwl_bus *bus, u32 ofs, u32 val); - u32 (*read32)(struct iwl_bus *bus, u32 ofs); -}; - -struct iwl_bus { - /* pointer to bus specific struct */ - void *bus_specific; - - /* Common data to all buses */ - struct iwl_priv *priv; /* driver's context */ - struct device *dev; - struct iwl_bus_ops *ops; - unsigned int irq; -}; - -struct iwl_trans; - -/** - * struct iwl_trans_ops - transport specific operations - - * @rx_init: inits the rx memory, allocate it if needed - * @rx_free: frees the rx memory - * @tx_init:inits the tx memory, allocate if needed - */ -struct iwl_trans_ops { - int (*rx_init)(struct iwl_priv *priv); - void (*rx_free)(struct iwl_priv *priv); - int (*tx_init)(struct iwl_priv *priv); -}; - -struct iwl_trans { - const struct iwl_trans_ops *ops; -}; - struct iwl_priv { /* ieee device used by generic ieee processing code */ @@ -1313,8 +1244,11 @@ struct iwl_priv { spinlock_t reg_lock; /* protect hw register access */ struct mutex mutex; - struct iwl_bus bus; /* bus specific data */ - struct iwl_trans trans; + /* basic pci-network driver stuff */ + struct pci_dev *pci_dev; + + /* pci hardware address support */ + void __iomem *hw_base; /* microcode/device supports multiple contexts */ u8 valid_contexts; @@ -1337,7 +1271,7 @@ struct iwl_priv { struct fw_img ucode_rt; struct fw_img ucode_init; - enum iwlagn_ucode_type ucode_type; + enum iwlagn_ucode_subtype ucode_type; u8 ucode_write_complete; /* the image write is complete */ char firmware_name[25]; diff --git a/trunk/drivers/net/wireless/iwlwifi/iwl-eeprom.c b/trunk/drivers/net/wireless/iwlwifi/iwl-eeprom.c index 768d0ee276f7..47a56bc1cd12 100644 --- a/trunk/drivers/net/wireless/iwlwifi/iwl-eeprom.c +++ b/trunk/drivers/net/wireless/iwlwifi/iwl-eeprom.c @@ -834,28 +834,3 @@ const struct iwl_channel_info *iwl_get_channel_info(const struct iwl_priv *priv, return NULL; } - -void iwl_rf_config(struct iwl_priv *priv) -{ - u16 radio_cfg; - - radio_cfg = iwl_eeprom_query16(priv, EEPROM_RADIO_CONFIG); - - /* write radio config values to register */ - if (EEPROM_RF_CFG_TYPE_MSK(radio_cfg) <= EEPROM_RF_CONFIG_TYPE_MAX) { - iwl_set_bit(priv, CSR_HW_IF_CONFIG_REG, - EEPROM_RF_CFG_TYPE_MSK(radio_cfg) | - EEPROM_RF_CFG_STEP_MSK(radio_cfg) | - EEPROM_RF_CFG_DASH_MSK(radio_cfg)); - IWL_INFO(priv, "Radio type=0x%x-0x%x-0x%x\n", - EEPROM_RF_CFG_TYPE_MSK(radio_cfg), - EEPROM_RF_CFG_STEP_MSK(radio_cfg), - EEPROM_RF_CFG_DASH_MSK(radio_cfg)); - } else - WARN_ON(1); - - /* set CSR_HW_CONFIG_REG for uCode use */ - iwl_set_bit(priv, CSR_HW_IF_CONFIG_REG, - CSR_HW_IF_CONFIG_REG_BIT_RADIO_SI | - CSR_HW_IF_CONFIG_REG_BIT_MAC_SI); -} diff --git a/trunk/drivers/net/wireless/iwlwifi/iwl-eeprom.h b/trunk/drivers/net/wireless/iwlwifi/iwl-eeprom.h index 804f910c651e..c960c6fa009b 100644 --- a/trunk/drivers/net/wireless/iwlwifi/iwl-eeprom.h +++ b/trunk/drivers/net/wireless/iwlwifi/iwl-eeprom.h @@ -110,10 +110,12 @@ enum { }; /* SKU Capabilities */ -#define EEPROM_SKU_CAP_BAND_24GHZ (1 << 4) -#define EEPROM_SKU_CAP_BAND_52GHZ (1 << 5) +/* 5000 and up */ +#define EEPROM_SKU_CAP_BAND_POS (4) +#define EEPROM_SKU_CAP_BAND_SELECTION \ + (3 << EEPROM_SKU_CAP_BAND_POS) #define EEPROM_SKU_CAP_11N_ENABLE (1 << 6) -#define EEPROM_SKU_CAP_AMT_ENABLE (1 << 7) +#define EEPROM_SKU_CAP_AMT_ENABLE (1 << 7) #define EEPROM_SKU_CAP_IPAN_ENABLE (1 << 8) /* *regulatory* channel data format in eeprom, one for each channel. @@ -162,12 +164,16 @@ struct iwl_eeprom_enhanced_txpwr { s8 mimo3_max; } __packed; -/* calibration */ +/* 5000 Specific */ +#define EEPROM_5000_TX_POWER_VERSION (4) +#define EEPROM_5000_EEPROM_VERSION (0x11A) + +/* 5000 and up calibration */ #define EEPROM_CALIB_ALL (INDIRECT_ADDRESS | INDIRECT_CALIBRATION) #define EEPROM_XTAL ((2*0x128) | EEPROM_CALIB_ALL) -/* temperature */ -#define EEPROM_TEMPERATURE ((2*0x12A) | EEPROM_CALIB_ALL) +/* 5000 temperature */ +#define EEPROM_5000_TEMPERATURE ((2*0x12A) | EEPROM_CALIB_ALL) /* agn links */ #define EEPROM_LINK_HOST (2*0x64) @@ -199,10 +205,6 @@ struct iwl_eeprom_enhanced_txpwr { #define EEPROM_6000_REG_BAND_24_HT40_CHANNELS ((0x80)\ | INDIRECT_ADDRESS | INDIRECT_REGULATORY) /* 14 bytes */ -/* 5000 Specific */ -#define EEPROM_5000_TX_POWER_VERSION (4) -#define EEPROM_5000_EEPROM_VERSION (0x11A) - /* 5050 Specific */ #define EEPROM_5050_TX_POWER_VERSION (4) #define EEPROM_5050_EEPROM_VERSION (0x21E) @@ -268,13 +270,13 @@ extern const u8 iwl_eeprom_band_1[14]; /* General */ #define EEPROM_DEVICE_ID (2*0x08) /* 2 bytes */ -#define EEPROM_SUBSYSTEM_ID (2*0x0A) /* 2 bytes */ #define EEPROM_MAC_ADDRESS (2*0x15) /* 6 bytes */ #define EEPROM_BOARD_REVISION (2*0x35) /* 2 bytes */ #define EEPROM_BOARD_PBA_NUMBER (2*0x3B+1) /* 9 bytes */ #define EEPROM_VERSION (2*0x44) /* 2 bytes */ #define EEPROM_SKU_CAP (2*0x45) /* 2 bytes */ #define EEPROM_OEM_MODE (2*0x46) /* 2 bytes */ +#define EEPROM_WOWLAN_MODE (2*0x47) /* 2 bytes */ #define EEPROM_RADIO_CONFIG (2*0x48) /* 2 bytes */ #define EEPROM_NUM_MAC_ADDRESS (2*0x4C) /* 2 bytes */ @@ -309,6 +311,5 @@ void iwl_free_channel_map(struct iwl_priv *priv); const struct iwl_channel_info *iwl_get_channel_info( const struct iwl_priv *priv, enum ieee80211_band band, u16 channel); -void iwl_rf_config(struct iwl_priv *priv); #endif /* __iwl_eeprom_h__ */ diff --git a/trunk/drivers/net/wireless/iwlwifi/iwl-hcmd.c b/trunk/drivers/net/wireless/iwlwifi/iwl-hcmd.c index 107b38e2ee93..76f996623140 100644 --- a/trunk/drivers/net/wireless/iwlwifi/iwl-hcmd.c +++ b/trunk/drivers/net/wireless/iwlwifi/iwl-hcmd.c @@ -113,7 +113,7 @@ const char *get_cmd_string(u8 cmd) } } -#define HOST_COMPLETE_TIMEOUT (2 * HZ) +#define HOST_COMPLETE_TIMEOUT (HZ / 2) static void iwl_generic_cmd_callback(struct iwl_priv *priv, struct iwl_device_cmd *cmd, @@ -171,8 +171,6 @@ int iwl_send_cmd_sync(struct iwl_priv *priv, struct iwl_host_cmd *cmd) int cmd_idx; int ret; - lockdep_assert_held(&priv->mutex); - if (WARN_ON(cmd->flags & CMD_ASYNC)) return -EINVAL; diff --git a/trunk/drivers/net/wireless/iwlwifi/iwl-helpers.h b/trunk/drivers/net/wireless/iwlwifi/iwl-helpers.h index 9d91552d13c1..41207a3645b8 100644 --- a/trunk/drivers/net/wireless/iwlwifi/iwl-helpers.h +++ b/trunk/drivers/net/wireless/iwlwifi/iwl-helpers.h @@ -120,16 +120,7 @@ static inline void iwl_wake_any_queue(struct iwl_priv *priv, } } -#ifdef ieee80211_stop_queue -#undef ieee80211_stop_queue -#endif - #define ieee80211_stop_queue DO_NOT_USE_ieee80211_stop_queue - -#ifdef ieee80211_wake_queue -#undef ieee80211_wake_queue -#endif - #define ieee80211_wake_queue DO_NOT_USE_ieee80211_wake_queue static inline void iwl_disable_interrupts(struct iwl_priv *priv) diff --git a/trunk/drivers/net/wireless/iwlwifi/iwl-io.h b/trunk/drivers/net/wireless/iwlwifi/iwl-io.h index c56eae74c3cd..869edc580ec6 100644 --- a/trunk/drivers/net/wireless/iwlwifi/iwl-io.h +++ b/trunk/drivers/net/wireless/iwlwifi/iwl-io.h @@ -38,18 +38,18 @@ static inline void iwl_write8(struct iwl_priv *priv, u32 ofs, u8 val) { trace_iwlwifi_dev_iowrite8(priv, ofs, val); - priv->bus.ops->write8(&priv->bus, ofs, val); + iowrite8(val, priv->hw_base + ofs); } static inline void iwl_write32(struct iwl_priv *priv, u32 ofs, u32 val) { trace_iwlwifi_dev_iowrite32(priv, ofs, val); - priv->bus.ops->write32(&priv->bus, ofs, val); + iowrite32(val, priv->hw_base + ofs); } static inline u32 iwl_read32(struct iwl_priv *priv, u32 ofs) { - u32 val = priv->bus.ops->read32(&priv->bus, ofs); + u32 val = ioread32(priv->hw_base + ofs); trace_iwlwifi_dev_ioread32(priv, ofs, val); return val; } diff --git a/trunk/drivers/net/wireless/iwlwifi/iwl-led.c b/trunk/drivers/net/wireless/iwlwifi/iwl-led.c index ff08da099754..7c23beb49d7c 100644 --- a/trunk/drivers/net/wireless/iwlwifi/iwl-led.c +++ b/trunk/drivers/net/wireless/iwlwifi/iwl-led.c @@ -28,6 +28,8 @@ #include #include #include +#include +#include #include #include #include @@ -38,9 +40,14 @@ #include "iwl-dev.h" #include "iwl-core.h" -#include "iwl-agn.h" #include "iwl-io.h" +/* default: IWL_LED_BLINK(0) using blinking index table */ +static int led_mode; +module_param(led_mode, int, S_IRUGO); +MODULE_PARM_DESC(led_mode, "0=system default, " + "1=On(RF On)/Off(RF Off), 2=blinking"); + /* Throughput OFF time(ms) ON time (ms) * >300 25 25 * >200 to 300 40 40 @@ -174,7 +181,7 @@ static int iwl_led_blink_set(struct led_classdev *led_cdev, void iwl_leds_init(struct iwl_priv *priv) { - int mode = iwlagn_mod_params.led_mode; + int mode = led_mode; int ret; if (mode == IWL_LED_DEFAULT) @@ -202,8 +209,7 @@ void iwl_leds_init(struct iwl_priv *priv) break; } - ret = led_classdev_register(priv->bus.dev, - &priv->led); + ret = led_classdev_register(&priv->pci_dev->dev, &priv->led); if (ret) { kfree(priv->led.name); return; diff --git a/trunk/drivers/net/wireless/iwlwifi/iwl-pci.c b/trunk/drivers/net/wireless/iwlwifi/iwl-pci.c deleted file mode 100644 index 74911348a2ee..000000000000 --- a/trunk/drivers/net/wireless/iwlwifi/iwl-pci.c +++ /dev/null @@ -1,560 +0,0 @@ -/****************************************************************************** - * - * This file is provided under a dual BSD/GPLv2 license. When using or - * redistributing this file, you may do so under either license. - * - * GPL LICENSE SUMMARY - * - * Copyright(c) 2007 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110, - * USA - * - * The full GNU General Public License is included in this distribution - * in the file called LICENSE.GPL. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - * - * BSD LICENSE - * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name Intel Corporation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - *****************************************************************************/ -#include -#include - -#include "iwl-pci.h" -#include "iwl-agn.h" -#include "iwl-core.h" -#include "iwl-io.h" -#include "iwl-trans.h" - -/* PCI registers */ -#define PCI_CFG_RETRY_TIMEOUT 0x041 -#define PCI_CFG_LINK_CTRL_VAL_L0S_EN 0x01 -#define PCI_CFG_LINK_CTRL_VAL_L1_EN 0x02 - -struct iwl_pci_bus { - /* basic pci-network driver stuff */ - struct pci_dev *pci_dev; - - /* pci hardware address support */ - void __iomem *hw_base; -}; - -#define IWL_BUS_GET_PCI_BUS(_iwl_bus) \ - ((struct iwl_pci_bus *) ((_iwl_bus)->bus_specific)) - -#define IWL_BUS_GET_PCI_DEV(_iwl_bus) \ - ((IWL_BUS_GET_PCI_BUS(_iwl_bus))->pci_dev) - -static u16 iwl_pciexp_link_ctrl(struct iwl_bus *bus) -{ - int pos; - u16 pci_lnk_ctl; - struct pci_dev *pci_dev = IWL_BUS_GET_PCI_DEV(bus); - - pos = pci_pcie_cap(pci_dev); - pci_read_config_word(pci_dev, pos + PCI_EXP_LNKCTL, &pci_lnk_ctl); - return pci_lnk_ctl; -} - -static bool iwl_pci_is_pm_supported(struct iwl_bus *bus) -{ - u16 lctl = iwl_pciexp_link_ctrl(bus); - - return !(lctl & PCI_CFG_LINK_CTRL_VAL_L0S_EN); -} - -static void iwl_pci_apm_config(struct iwl_bus *bus) -{ - /* - * HW bug W/A for instability in PCIe bus L0S->L1 transition. - * Check if BIOS (or OS) enabled L1-ASPM on this device. - * If so (likely), disable L0S, so device moves directly L0->L1; - * costs negligible amount of power savings. - * If not (unlikely), enable L0S, so there is at least some - * power savings, even without L1. - */ - u16 lctl = iwl_pciexp_link_ctrl(bus); - - if ((lctl & PCI_CFG_LINK_CTRL_VAL_L1_EN) == - PCI_CFG_LINK_CTRL_VAL_L1_EN) { - /* L1-ASPM enabled; disable(!) L0S */ - iwl_set_bit(bus->priv, CSR_GIO_REG, - CSR_GIO_REG_VAL_L0S_ENABLED); - IWL_DEBUG_POWER(bus->priv, "L1 Enabled; Disabling L0S\n"); - } else { - /* L1-ASPM disabled; enable(!) L0S */ - iwl_clear_bit(bus->priv, CSR_GIO_REG, - CSR_GIO_REG_VAL_L0S_ENABLED); - IWL_DEBUG_POWER(bus->priv, "L1 Disabled; Enabling L0S\n"); - } -} - -static void iwl_pci_set_drv_data(struct iwl_bus *bus, void *drv_priv) -{ - pci_set_drvdata(IWL_BUS_GET_PCI_DEV(bus), drv_priv); -} - -static struct device *iwl_pci_get_dev(const struct iwl_bus *bus) -{ - return &(IWL_BUS_GET_PCI_DEV(bus)->dev); -} - -static unsigned int iwl_pci_get_irq(const struct iwl_bus *bus) -{ - return IWL_BUS_GET_PCI_DEV(bus)->irq; -} - -static void iwl_pci_get_hw_id(struct iwl_bus *bus, char buf[], - int buf_len) -{ - struct pci_dev *pci_dev = IWL_BUS_GET_PCI_DEV(bus); - - snprintf(buf, buf_len, "PCI ID: 0x%04X:0x%04X", pci_dev->device, - pci_dev->subsystem_device); -} - -static void iwl_pci_write8(struct iwl_bus *bus, u32 ofs, u8 val) -{ - iowrite8(val, IWL_BUS_GET_PCI_BUS(bus)->hw_base + ofs); -} - -static void iwl_pci_write32(struct iwl_bus *bus, u32 ofs, u32 val) -{ - iowrite32(val, IWL_BUS_GET_PCI_BUS(bus)->hw_base + ofs); -} - -static u32 iwl_pci_read32(struct iwl_bus *bus, u32 ofs) -{ - u32 val = ioread32(IWL_BUS_GET_PCI_BUS(bus)->hw_base + ofs); - return val; -} - -static struct iwl_bus_ops pci_ops = { - .get_pm_support = iwl_pci_is_pm_supported, - .apm_config = iwl_pci_apm_config, - .set_drv_data = iwl_pci_set_drv_data, - .get_dev = iwl_pci_get_dev, - .get_irq = iwl_pci_get_irq, - .get_hw_id = iwl_pci_get_hw_id, - .write8 = iwl_pci_write8, - .write32 = iwl_pci_write32, - .read32 = iwl_pci_read32, -}; - -#define IWL_PCI_DEVICE(dev, subdev, cfg) \ - .vendor = PCI_VENDOR_ID_INTEL, .device = (dev), \ - .subvendor = PCI_ANY_ID, .subdevice = (subdev), \ - .driver_data = (kernel_ulong_t)&(cfg) - -/* Hardware specific file defines the PCI IDs table for that hardware module */ -static DEFINE_PCI_DEVICE_TABLE(iwl_hw_card_ids) = { - {IWL_PCI_DEVICE(0x4232, 0x1201, iwl5100_agn_cfg)}, /* Mini Card */ - {IWL_PCI_DEVICE(0x4232, 0x1301, iwl5100_agn_cfg)}, /* Half Mini Card */ - {IWL_PCI_DEVICE(0x4232, 0x1204, iwl5100_agn_cfg)}, /* Mini Card */ - {IWL_PCI_DEVICE(0x4232, 0x1304, iwl5100_agn_cfg)}, /* Half Mini Card */ - {IWL_PCI_DEVICE(0x4232, 0x1205, iwl5100_bgn_cfg)}, /* Mini Card */ - {IWL_PCI_DEVICE(0x4232, 0x1305, iwl5100_bgn_cfg)}, /* Half Mini Card */ - {IWL_PCI_DEVICE(0x4232, 0x1206, iwl5100_abg_cfg)}, /* Mini Card */ - {IWL_PCI_DEVICE(0x4232, 0x1306, iwl5100_abg_cfg)}, /* Half Mini Card */ - {IWL_PCI_DEVICE(0x4232, 0x1221, iwl5100_agn_cfg)}, /* Mini Card */ - {IWL_PCI_DEVICE(0x4232, 0x1321, iwl5100_agn_cfg)}, /* Half Mini Card */ - {IWL_PCI_DEVICE(0x4232, 0x1224, iwl5100_agn_cfg)}, /* Mini Card */ - {IWL_PCI_DEVICE(0x4232, 0x1324, iwl5100_agn_cfg)}, /* Half Mini Card */ - {IWL_PCI_DEVICE(0x4232, 0x1225, iwl5100_bgn_cfg)}, /* Mini Card */ - {IWL_PCI_DEVICE(0x4232, 0x1325, iwl5100_bgn_cfg)}, /* Half Mini Card */ - {IWL_PCI_DEVICE(0x4232, 0x1226, iwl5100_abg_cfg)}, /* Mini Card */ - {IWL_PCI_DEVICE(0x4232, 0x1326, iwl5100_abg_cfg)}, /* Half Mini Card */ - {IWL_PCI_DEVICE(0x4237, 0x1211, iwl5100_agn_cfg)}, /* Mini Card */ - {IWL_PCI_DEVICE(0x4237, 0x1311, iwl5100_agn_cfg)}, /* Half Mini Card */ - {IWL_PCI_DEVICE(0x4237, 0x1214, iwl5100_agn_cfg)}, /* Mini Card */ - {IWL_PCI_DEVICE(0x4237, 0x1314, iwl5100_agn_cfg)}, /* Half Mini Card */ - {IWL_PCI_DEVICE(0x4237, 0x1215, iwl5100_bgn_cfg)}, /* Mini Card */ - {IWL_PCI_DEVICE(0x4237, 0x1315, iwl5100_bgn_cfg)}, /* Half Mini Card */ - {IWL_PCI_DEVICE(0x4237, 0x1216, iwl5100_abg_cfg)}, /* Mini Card */ - {IWL_PCI_DEVICE(0x4237, 0x1316, iwl5100_abg_cfg)}, /* Half Mini Card */ - -/* 5300 Series WiFi */ - {IWL_PCI_DEVICE(0x4235, 0x1021, iwl5300_agn_cfg)}, /* Mini Card */ - {IWL_PCI_DEVICE(0x4235, 0x1121, iwl5300_agn_cfg)}, /* Half Mini Card */ - {IWL_PCI_DEVICE(0x4235, 0x1024, iwl5300_agn_cfg)}, /* Mini Card */ - {IWL_PCI_DEVICE(0x4235, 0x1124, iwl5300_agn_cfg)}, /* Half Mini Card */ - {IWL_PCI_DEVICE(0x4235, 0x1001, iwl5300_agn_cfg)}, /* Mini Card */ - {IWL_PCI_DEVICE(0x4235, 0x1101, iwl5300_agn_cfg)}, /* Half Mini Card */ - {IWL_PCI_DEVICE(0x4235, 0x1004, iwl5300_agn_cfg)}, /* Mini Card */ - {IWL_PCI_DEVICE(0x4235, 0x1104, iwl5300_agn_cfg)}, /* Half Mini Card */ - {IWL_PCI_DEVICE(0x4236, 0x1011, iwl5300_agn_cfg)}, /* Mini Card */ - {IWL_PCI_DEVICE(0x4236, 0x1111, iwl5300_agn_cfg)}, /* Half Mini Card */ - {IWL_PCI_DEVICE(0x4236, 0x1014, iwl5300_agn_cfg)}, /* Mini Card */ - {IWL_PCI_DEVICE(0x4236, 0x1114, iwl5300_agn_cfg)}, /* Half Mini Card */ - -/* 5350 Series WiFi/WiMax */ - {IWL_PCI_DEVICE(0x423A, 0x1001, iwl5350_agn_cfg)}, /* Mini Card */ - {IWL_PCI_DEVICE(0x423A, 0x1021, iwl5350_agn_cfg)}, /* Mini Card */ - {IWL_PCI_DEVICE(0x423B, 0x1011, iwl5350_agn_cfg)}, /* Mini Card */ - -/* 5150 Series Wifi/WiMax */ - {IWL_PCI_DEVICE(0x423C, 0x1201, iwl5150_agn_cfg)}, /* Mini Card */ - {IWL_PCI_DEVICE(0x423C, 0x1301, iwl5150_agn_cfg)}, /* Half Mini Card */ - {IWL_PCI_DEVICE(0x423C, 0x1206, iwl5150_abg_cfg)}, /* Mini Card */ - {IWL_PCI_DEVICE(0x423C, 0x1306, iwl5150_abg_cfg)}, /* Half Mini Card */ - {IWL_PCI_DEVICE(0x423C, 0x1221, iwl5150_agn_cfg)}, /* Mini Card */ - {IWL_PCI_DEVICE(0x423C, 0x1321, iwl5150_agn_cfg)}, /* Half Mini Card */ - - {IWL_PCI_DEVICE(0x423D, 0x1211, iwl5150_agn_cfg)}, /* Mini Card */ - {IWL_PCI_DEVICE(0x423D, 0x1311, iwl5150_agn_cfg)}, /* Half Mini Card */ - {IWL_PCI_DEVICE(0x423D, 0x1216, iwl5150_abg_cfg)}, /* Mini Card */ - {IWL_PCI_DEVICE(0x423D, 0x1316, iwl5150_abg_cfg)}, /* Half Mini Card */ - -/* 6x00 Series */ - {IWL_PCI_DEVICE(0x422B, 0x1101, iwl6000_3agn_cfg)}, - {IWL_PCI_DEVICE(0x422B, 0x1121, iwl6000_3agn_cfg)}, - {IWL_PCI_DEVICE(0x422C, 0x1301, iwl6000i_2agn_cfg)}, - {IWL_PCI_DEVICE(0x422C, 0x1306, iwl6000i_2abg_cfg)}, - {IWL_PCI_DEVICE(0x422C, 0x1307, iwl6000i_2bg_cfg)}, - {IWL_PCI_DEVICE(0x422C, 0x1321, iwl6000i_2agn_cfg)}, - {IWL_PCI_DEVICE(0x422C, 0x1326, iwl6000i_2abg_cfg)}, - {IWL_PCI_DEVICE(0x4238, 0x1111, iwl6000_3agn_cfg)}, - {IWL_PCI_DEVICE(0x4239, 0x1311, iwl6000i_2agn_cfg)}, - {IWL_PCI_DEVICE(0x4239, 0x1316, iwl6000i_2abg_cfg)}, - -/* 6x05 Series */ - {IWL_PCI_DEVICE(0x0082, 0x1301, iwl6005_2agn_cfg)}, - {IWL_PCI_DEVICE(0x0082, 0x1306, iwl6005_2abg_cfg)}, - {IWL_PCI_DEVICE(0x0082, 0x1307, iwl6005_2bg_cfg)}, - {IWL_PCI_DEVICE(0x0082, 0x1321, iwl6005_2agn_cfg)}, - {IWL_PCI_DEVICE(0x0082, 0x1326, iwl6005_2abg_cfg)}, - {IWL_PCI_DEVICE(0x0085, 0x1311, iwl6005_2agn_cfg)}, - {IWL_PCI_DEVICE(0x0085, 0x1316, iwl6005_2abg_cfg)}, - -/* 6x30 Series */ - {IWL_PCI_DEVICE(0x008A, 0x5305, iwl1030_bgn_cfg)}, - {IWL_PCI_DEVICE(0x008A, 0x5307, iwl1030_bg_cfg)}, - {IWL_PCI_DEVICE(0x008A, 0x5325, iwl1030_bgn_cfg)}, - {IWL_PCI_DEVICE(0x008A, 0x5327, iwl1030_bg_cfg)}, - {IWL_PCI_DEVICE(0x008B, 0x5315, iwl1030_bgn_cfg)}, - {IWL_PCI_DEVICE(0x008B, 0x5317, iwl1030_bg_cfg)}, - {IWL_PCI_DEVICE(0x0090, 0x5211, iwl6030_2agn_cfg)}, - {IWL_PCI_DEVICE(0x0090, 0x5215, iwl6030_2bgn_cfg)}, - {IWL_PCI_DEVICE(0x0090, 0x5216, iwl6030_2abg_cfg)}, - {IWL_PCI_DEVICE(0x0091, 0x5201, iwl6030_2agn_cfg)}, - {IWL_PCI_DEVICE(0x0091, 0x5205, iwl6030_2bgn_cfg)}, - {IWL_PCI_DEVICE(0x0091, 0x5206, iwl6030_2abg_cfg)}, - {IWL_PCI_DEVICE(0x0091, 0x5207, iwl6030_2bg_cfg)}, - {IWL_PCI_DEVICE(0x0091, 0x5221, iwl6030_2agn_cfg)}, - {IWL_PCI_DEVICE(0x0091, 0x5225, iwl6030_2bgn_cfg)}, - {IWL_PCI_DEVICE(0x0091, 0x5226, iwl6030_2abg_cfg)}, - -/* 6x50 WiFi/WiMax Series */ - {IWL_PCI_DEVICE(0x0087, 0x1301, iwl6050_2agn_cfg)}, - {IWL_PCI_DEVICE(0x0087, 0x1306, iwl6050_2abg_cfg)}, - {IWL_PCI_DEVICE(0x0087, 0x1321, iwl6050_2agn_cfg)}, - {IWL_PCI_DEVICE(0x0087, 0x1326, iwl6050_2abg_cfg)}, - {IWL_PCI_DEVICE(0x0089, 0x1311, iwl6050_2agn_cfg)}, - {IWL_PCI_DEVICE(0x0089, 0x1316, iwl6050_2abg_cfg)}, - -/* 6150 WiFi/WiMax Series */ - {IWL_PCI_DEVICE(0x0885, 0x1305, iwl6150_bgn_cfg)}, - {IWL_PCI_DEVICE(0x0885, 0x1307, iwl6150_bg_cfg)}, - {IWL_PCI_DEVICE(0x0885, 0x1325, iwl6150_bgn_cfg)}, - {IWL_PCI_DEVICE(0x0885, 0x1327, iwl6150_bg_cfg)}, - {IWL_PCI_DEVICE(0x0886, 0x1315, iwl6150_bgn_cfg)}, - {IWL_PCI_DEVICE(0x0886, 0x1317, iwl6150_bg_cfg)}, - -/* 1000 Series WiFi */ - {IWL_PCI_DEVICE(0x0083, 0x1205, iwl1000_bgn_cfg)}, - {IWL_PCI_DEVICE(0x0083, 0x1305, iwl1000_bgn_cfg)}, - {IWL_PCI_DEVICE(0x0083, 0x1225, iwl1000_bgn_cfg)}, - {IWL_PCI_DEVICE(0x0083, 0x1325, iwl1000_bgn_cfg)}, - {IWL_PCI_DEVICE(0x0084, 0x1215, iwl1000_bgn_cfg)}, - {IWL_PCI_DEVICE(0x0084, 0x1315, iwl1000_bgn_cfg)}, - {IWL_PCI_DEVICE(0x0083, 0x1206, iwl1000_bg_cfg)}, - {IWL_PCI_DEVICE(0x0083, 0x1306, iwl1000_bg_cfg)}, - {IWL_PCI_DEVICE(0x0083, 0x1226, iwl1000_bg_cfg)}, - {IWL_PCI_DEVICE(0x0083, 0x1326, iwl1000_bg_cfg)}, - {IWL_PCI_DEVICE(0x0084, 0x1216, iwl1000_bg_cfg)}, - {IWL_PCI_DEVICE(0x0084, 0x1316, iwl1000_bg_cfg)}, - -/* 100 Series WiFi */ - {IWL_PCI_DEVICE(0x08AE, 0x1005, iwl100_bgn_cfg)}, - {IWL_PCI_DEVICE(0x08AE, 0x1007, iwl100_bg_cfg)}, - {IWL_PCI_DEVICE(0x08AF, 0x1015, iwl100_bgn_cfg)}, - {IWL_PCI_DEVICE(0x08AF, 0x1017, iwl100_bg_cfg)}, - {IWL_PCI_DEVICE(0x08AE, 0x1025, iwl100_bgn_cfg)}, - {IWL_PCI_DEVICE(0x08AE, 0x1027, iwl100_bg_cfg)}, - -/* 130 Series WiFi */ - {IWL_PCI_DEVICE(0x0896, 0x5005, iwl130_bgn_cfg)}, - {IWL_PCI_DEVICE(0x0896, 0x5007, iwl130_bg_cfg)}, - {IWL_PCI_DEVICE(0x0897, 0x5015, iwl130_bgn_cfg)}, - {IWL_PCI_DEVICE(0x0897, 0x5017, iwl130_bg_cfg)}, - {IWL_PCI_DEVICE(0x0896, 0x5025, iwl130_bgn_cfg)}, - {IWL_PCI_DEVICE(0x0896, 0x5027, iwl130_bg_cfg)}, - -/* 2x00 Series */ - {IWL_PCI_DEVICE(0x0890, 0x4022, iwl2000_2bgn_cfg)}, - {IWL_PCI_DEVICE(0x0891, 0x4222, iwl2000_2bgn_cfg)}, - {IWL_PCI_DEVICE(0x0890, 0x4422, iwl2000_2bgn_cfg)}, - {IWL_PCI_DEVICE(0x0890, 0x4026, iwl2000_2bg_cfg)}, - {IWL_PCI_DEVICE(0x0891, 0x4226, iwl2000_2bg_cfg)}, - {IWL_PCI_DEVICE(0x0890, 0x4426, iwl2000_2bg_cfg)}, - -/* 2x30 Series */ - {IWL_PCI_DEVICE(0x0887, 0x4062, iwl2030_2bgn_cfg)}, - {IWL_PCI_DEVICE(0x0888, 0x4262, iwl2030_2bgn_cfg)}, - {IWL_PCI_DEVICE(0x0887, 0x4462, iwl2030_2bgn_cfg)}, - {IWL_PCI_DEVICE(0x0887, 0x4066, iwl2030_2bg_cfg)}, - {IWL_PCI_DEVICE(0x0888, 0x4266, iwl2030_2bg_cfg)}, - {IWL_PCI_DEVICE(0x0887, 0x4466, iwl2030_2bg_cfg)}, - -/* 6x35 Series */ - {IWL_PCI_DEVICE(0x088E, 0x4060, iwl6035_2agn_cfg)}, - {IWL_PCI_DEVICE(0x088F, 0x4260, iwl6035_2agn_cfg)}, - {IWL_PCI_DEVICE(0x088E, 0x4460, iwl6035_2agn_cfg)}, - {IWL_PCI_DEVICE(0x088E, 0x4064, iwl6035_2abg_cfg)}, - {IWL_PCI_DEVICE(0x088F, 0x4264, iwl6035_2abg_cfg)}, - {IWL_PCI_DEVICE(0x088E, 0x4464, iwl6035_2abg_cfg)}, - {IWL_PCI_DEVICE(0x088E, 0x4066, iwl6035_2bg_cfg)}, - {IWL_PCI_DEVICE(0x088F, 0x4266, iwl6035_2bg_cfg)}, - {IWL_PCI_DEVICE(0x088E, 0x4466, iwl6035_2bg_cfg)}, - -/* 105 Series */ - {IWL_PCI_DEVICE(0x0894, 0x0022, iwl105_bgn_cfg)}, - {IWL_PCI_DEVICE(0x0895, 0x0222, iwl105_bgn_cfg)}, - {IWL_PCI_DEVICE(0x0894, 0x0422, iwl105_bgn_cfg)}, - {IWL_PCI_DEVICE(0x0894, 0x0026, iwl105_bg_cfg)}, - {IWL_PCI_DEVICE(0x0895, 0x0226, iwl105_bg_cfg)}, - {IWL_PCI_DEVICE(0x0894, 0x0426, iwl105_bg_cfg)}, - -/* 135 Series */ - {IWL_PCI_DEVICE(0x0892, 0x0062, iwl135_bgn_cfg)}, - {IWL_PCI_DEVICE(0x0893, 0x0262, iwl135_bgn_cfg)}, - {IWL_PCI_DEVICE(0x0892, 0x0462, iwl135_bgn_cfg)}, - {IWL_PCI_DEVICE(0x0892, 0x0066, iwl135_bg_cfg)}, - {IWL_PCI_DEVICE(0x0893, 0x0266, iwl135_bg_cfg)}, - {IWL_PCI_DEVICE(0x0892, 0x0466, iwl135_bg_cfg)}, - - {0} -}; -MODULE_DEVICE_TABLE(pci, iwl_hw_card_ids); - -static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) -{ - struct iwl_cfg *cfg = (struct iwl_cfg *)(ent->driver_data); - struct iwl_pci_bus *bus; - u16 pci_cmd; - int err; - - bus = kzalloc(sizeof(*bus), GFP_KERNEL); - if (!bus) { - pr_err("Couldn't allocate iwl_pci_bus"); - err = -ENOMEM; - goto out_no_pci; - } - - bus->pci_dev = pdev; - - /* W/A - seems to solve weird behavior. We need to remove this if we - * don't want to stay in L1 all the time. This wastes a lot of power */ - pci_disable_link_state(pdev, PCIE_LINK_STATE_L0S | PCIE_LINK_STATE_L1 | - PCIE_LINK_STATE_CLKPM); - - if (pci_enable_device(pdev)) { - err = -ENODEV; - goto out_no_pci; - } - - pci_set_master(pdev); - - err = pci_set_dma_mask(pdev, DMA_BIT_MASK(36)); - if (!err) - err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(36)); - if (err) { - err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)); - if (!err) - err = pci_set_consistent_dma_mask(pdev, - DMA_BIT_MASK(32)); - /* both attempts failed: */ - if (err) { - pr_err("No suitable DMA available.\n"); - goto out_pci_disable_device; - } - } - - err = pci_request_regions(pdev, DRV_NAME); - if (err) { - pr_err("pci_request_regions failed"); - goto out_pci_disable_device; - } - - bus->hw_base = pci_iomap(pdev, 0, 0); - if (!bus->hw_base) { - pr_err("pci_iomap failed"); - err = -ENODEV; - goto out_pci_release_regions; - } - - pr_info("pci_resource_len = 0x%08llx\n", - (unsigned long long) pci_resource_len(pdev, 0)); - pr_info("pci_resource_base = %p\n", bus->hw_base); - - pr_info("HW Revision ID = 0x%X\n", pdev->revision); - - /* We disable the RETRY_TIMEOUT register (0x41) to keep - * PCI Tx retries from interfering with C3 CPU state */ - pci_write_config_byte(pdev, PCI_CFG_RETRY_TIMEOUT, 0x00); - - err = pci_enable_msi(pdev); - if (err) { - pr_err("pci_enable_msi failed"); - goto out_iounmap; - } - - /* TODO: Move this away, not needed if not MSI */ - /* enable rfkill interrupt: hw bug w/a */ - pci_read_config_word(pdev, PCI_COMMAND, &pci_cmd); - if (pci_cmd & PCI_COMMAND_INTX_DISABLE) { - pci_cmd &= ~PCI_COMMAND_INTX_DISABLE; - pci_write_config_word(pdev, PCI_COMMAND, pci_cmd); - } - - err = iwl_probe((void *) bus, &pci_ops, cfg); - if (err) - goto out_disable_msi; - return 0; - -out_disable_msi: - pci_disable_msi(pdev); -out_iounmap: - pci_iounmap(pdev, bus->hw_base); -out_pci_release_regions: - pci_set_drvdata(pdev, NULL); - pci_release_regions(pdev); -out_pci_disable_device: - pci_disable_device(pdev); -out_no_pci: - kfree(bus); - return err; -} - -static void iwl_pci_down(void *bus) -{ - struct iwl_pci_bus *pci_bus = (struct iwl_pci_bus *) bus; - - pci_disable_msi(pci_bus->pci_dev); - pci_iounmap(pci_bus->pci_dev, pci_bus->hw_base); - pci_release_regions(pci_bus->pci_dev); - pci_disable_device(pci_bus->pci_dev); - pci_set_drvdata(pci_bus->pci_dev, NULL); - - kfree(pci_bus); -} - -static void __devexit iwl_pci_remove(struct pci_dev *pdev) -{ - struct iwl_priv *priv = pci_get_drvdata(pdev); - void *bus_specific = priv->bus.bus_specific; - - iwl_remove(priv); - - iwl_pci_down(bus_specific); -} - -#ifdef CONFIG_PM - -static int iwl_pci_suspend(struct device *device) -{ - struct pci_dev *pdev = to_pci_dev(device); - struct iwl_priv *priv = pci_get_drvdata(pdev); - - return iwl_suspend(priv); -} - -static int iwl_pci_resume(struct device *device) -{ - struct pci_dev *pdev = to_pci_dev(device); - struct iwl_priv *priv = pci_get_drvdata(pdev); - - /* - * We disable the RETRY_TIMEOUT register (0x41) to keep - * PCI Tx retries from interfering with C3 CPU state. - */ - pci_write_config_byte(pdev, PCI_CFG_RETRY_TIMEOUT, 0x00); - - return iwl_resume(priv); -} - -static SIMPLE_DEV_PM_OPS(iwl_dev_pm_ops, iwl_pci_suspend, iwl_pci_resume); - -#define IWL_PM_OPS (&iwl_dev_pm_ops) - -#else - -#define IWL_PM_OPS NULL - -#endif - -static struct pci_driver iwl_pci_driver = { - .name = DRV_NAME, - .id_table = iwl_hw_card_ids, - .probe = iwl_pci_probe, - .remove = __devexit_p(iwl_pci_remove), - .driver.pm = IWL_PM_OPS, -}; - -int __must_check iwl_pci_register_driver(void) -{ - int ret; - ret = pci_register_driver(&iwl_pci_driver); - if (ret) - pr_err("Unable to initialize PCI module\n"); - - return ret; -} - -void iwl_pci_unregister_driver(void) -{ - pci_unregister_driver(&iwl_pci_driver); -} diff --git a/trunk/drivers/net/wireless/iwlwifi/iwl-pci.h b/trunk/drivers/net/wireless/iwlwifi/iwl-pci.h deleted file mode 100644 index 9396c7c8d6a4..000000000000 --- a/trunk/drivers/net/wireless/iwlwifi/iwl-pci.h +++ /dev/null @@ -1,69 +0,0 @@ -/****************************************************************************** - * - * This file is provided under a dual BSD/GPLv2 license. When using or - * redistributing this file, you may do so under either license. - * - * GPL LICENSE SUMMARY - * - * Copyright(c) 2007 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110, - * USA - * - * The full GNU General Public License is included in this distribution - * in the file called LICENSE.GPL. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - * - * BSD LICENSE - * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name Intel Corporation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - *****************************************************************************/ -#ifndef __iwl_pci_h__ -#define __iwl_pci_h__ - -int __must_check iwl_pci_register_driver(void); -void iwl_pci_unregister_driver(void); - -#endif diff --git a/trunk/drivers/net/wireless/iwlwifi/iwl-power.c b/trunk/drivers/net/wireless/iwlwifi/iwl-power.c index 565e57e48be8..595c930b28ae 100644 --- a/trunk/drivers/net/wireless/iwlwifi/iwl-power.c +++ b/trunk/drivers/net/wireless/iwlwifi/iwl-power.c @@ -36,7 +36,6 @@ #include "iwl-eeprom.h" #include "iwl-dev.h" -#include "iwl-agn.h" #include "iwl-core.h" #include "iwl-io.h" #include "iwl-commands.h" @@ -51,6 +50,16 @@ * also use pre-defined power levels. */ +/* + * For now, keep using power level 1 instead of automatically + * adjusting ... + */ +bool no_sleep_autoadjust = true; +module_param(no_sleep_autoadjust, bool, S_IRUGO); +MODULE_PARM_DESC(no_sleep_autoadjust, + "don't automatically adjust sleep level " + "according to maximum network latency"); + /* * This defines the old power levels. They are still used by default * (level 1) and for thermal throttle (levels 3 through 5) @@ -245,7 +254,7 @@ static void iwl_static_sleep_cmd(struct iwl_priv *priv, } } - if (priv->power_data.bus_pm) + if (priv->power_data.pci_pm) cmd->flags |= IWL_POWER_PCI_PM_MSK; else cmd->flags &= ~IWL_POWER_PCI_PM_MSK; @@ -260,7 +269,7 @@ static void iwl_power_sleep_cam_cmd(struct iwl_priv *priv, { memset(cmd, 0, sizeof(*cmd)); - if (priv->power_data.bus_pm) + if (priv->power_data.pci_pm) cmd->flags |= IWL_POWER_PCI_PM_MSK; IWL_DEBUG_POWER(priv, "Sleep command for CAM\n"); @@ -296,7 +305,7 @@ static void iwl_power_fill_sleep_cmd(struct iwl_priv *priv, cmd->flags = IWL_POWER_DRIVER_ALLOW_SLEEP_MSK | IWL_POWER_FAST_PD; /* no use seeing frames for others */ - if (priv->power_data.bus_pm) + if (priv->power_data.pci_pm) cmd->flags |= IWL_POWER_PCI_PM_MSK; if (priv->cfg->base_params->shadow_reg_enable) @@ -358,15 +367,9 @@ static void iwl_power_build_cmd(struct iwl_priv *priv, iwl_static_sleep_cmd(priv, cmd, priv->power_data.debug_sleep_level_override, dtimper); - else if (iwlagn_mod_params.no_sleep_autoadjust) { - if (iwlagn_mod_params.power_level > IWL_POWER_INDEX_1 && - iwlagn_mod_params.power_level <= IWL_POWER_INDEX_5) - iwl_static_sleep_cmd(priv, cmd, - iwlagn_mod_params.power_level, dtimper); - else - iwl_static_sleep_cmd(priv, cmd, - IWL_POWER_INDEX_1, dtimper); - } else + else if (no_sleep_autoadjust) + iwl_static_sleep_cmd(priv, cmd, IWL_POWER_INDEX_1, dtimper); + else iwl_power_fill_sleep_cmd(priv, cmd, priv->hw->conf.dynamic_ps_timeout, priv->hw->conf.max_sleep_period); @@ -431,7 +434,9 @@ int iwl_power_update_mode(struct iwl_priv *priv, bool force) /* initialize to default */ void iwl_power_initialize(struct iwl_priv *priv) { - priv->power_data.bus_pm = priv->bus.ops->get_pm_support(&priv->bus); + u16 lctl = iwl_pcie_link_ctl(priv); + + priv->power_data.pci_pm = !(lctl & PCI_CFG_LINK_CTRL_VAL_L0S_EN); priv->power_data.debug_sleep_level_override = -1; diff --git a/trunk/drivers/net/wireless/iwlwifi/iwl-power.h b/trunk/drivers/net/wireless/iwlwifi/iwl-power.h index 5f7b720cf1a4..59635d784e27 100644 --- a/trunk/drivers/net/wireless/iwlwifi/iwl-power.h +++ b/trunk/drivers/net/wireless/iwlwifi/iwl-power.h @@ -43,7 +43,7 @@ struct iwl_power_mgr { struct iwl_powertable_cmd sleep_cmd; struct iwl_powertable_cmd sleep_cmd_next; int debug_sleep_level_override; - bool bus_pm; + bool pci_pm; }; int iwl_power_set_mode(struct iwl_priv *priv, struct iwl_powertable_cmd *cmd, diff --git a/trunk/drivers/net/wireless/iwlwifi/iwl-prph.h b/trunk/drivers/net/wireless/iwlwifi/iwl-prph.h index 1cc0ed1f488c..f00d188b2cfc 100644 --- a/trunk/drivers/net/wireless/iwlwifi/iwl-prph.h +++ b/trunk/drivers/net/wireless/iwlwifi/iwl-prph.h @@ -168,7 +168,6 @@ * the scheduler (especially for queue #4/#9, the command queue, otherwise * the driver can't issue commands!): */ -#define SCD_MEM_LOWER_BOUND (0x0000) /** * Max Tx window size is the max number of contiguous TFDs that the scheduler @@ -198,23 +197,15 @@ #define IWLAGN_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_POS (16) #define IWLAGN_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_MSK (0x007F0000) -/* Context Data */ -#define IWLAGN_SCD_CONTEXT_MEM_LOWER_BOUND (SCD_MEM_LOWER_BOUND + 0x600) -#define IWLAGN_SCD_CONTEXT_MEM_UPPER_BOUND (SCD_MEM_LOWER_BOUND + 0x6A0) - -/* Tx status */ -#define IWLAGN_SCD_TX_STTS_MEM_LOWER_BOUND (SCD_MEM_LOWER_BOUND + 0x6A0) -#define IWLAGN_SCD_TX_STTS_MEM_UPPER_BOUND (SCD_MEM_LOWER_BOUND + 0x7E0) - -/* Translation Data */ -#define IWLAGN_SCD_TRANS_TBL_MEM_LOWER_BOUND (SCD_MEM_LOWER_BOUND + 0x7E0) -#define IWLAGN_SCD_TRANS_TBL_MEM_UPPER_BOUND (SCD_MEM_LOWER_BOUND + 0x808) +#define IWLAGN_SCD_CONTEXT_DATA_OFFSET (0x600) +#define IWLAGN_SCD_TX_STTS_BITMAP_OFFSET (0x7B1) +#define IWLAGN_SCD_TRANSLATE_TBL_OFFSET (0x7E0) #define IWLAGN_SCD_CONTEXT_QUEUE_OFFSET(x)\ - (IWLAGN_SCD_CONTEXT_MEM_LOWER_BOUND + ((x) * 8)) + (IWLAGN_SCD_CONTEXT_DATA_OFFSET + ((x) * 8)) #define IWLAGN_SCD_TRANSLATE_TBL_OFFSET_QUEUE(x) \ - ((IWLAGN_SCD_TRANS_TBL_MEM_LOWER_BOUND + ((x) * 2)) & 0xfffc) + ((IWLAGN_SCD_TRANSLATE_TBL_OFFSET + ((x) * 2)) & 0xfffc) #define IWLAGN_SCD_QUEUECHAIN_SEL_ALL(priv) \ (((1<<(priv)->hw_params.max_txq_num) - 1) &\ diff --git a/trunk/drivers/net/wireless/iwlwifi/iwl-rx.c b/trunk/drivers/net/wireless/iwlwifi/iwl-rx.c index 87148bb3f628..b774517aa9fa 100644 --- a/trunk/drivers/net/wireless/iwlwifi/iwl-rx.c +++ b/trunk/drivers/net/wireless/iwlwifi/iwl-rx.c @@ -134,6 +134,7 @@ int iwl_rx_queue_space(const struct iwl_rx_queue *q) void iwl_rx_queue_update_write_ptr(struct iwl_priv *priv, struct iwl_rx_queue *q) { unsigned long flags; + u32 rx_wrt_ptr_reg = priv->hw_params.rx_wrt_ptr_reg; u32 reg; spin_lock_irqsave(&q->lock, flags); @@ -145,7 +146,7 @@ void iwl_rx_queue_update_write_ptr(struct iwl_priv *priv, struct iwl_rx_queue *q /* shadow register enabled */ /* Device expects a multiple of 8 */ q->write_actual = (q->write & ~0x7); - iwl_write32(priv, FH_RSCSR_CHNL0_WPTR, q->write_actual); + iwl_write32(priv, rx_wrt_ptr_reg, q->write_actual); } else { /* If power-saving is in use, make sure device is awake */ if (test_bit(STATUS_POWER_PMI, &priv->status)) { @@ -161,14 +162,14 @@ void iwl_rx_queue_update_write_ptr(struct iwl_priv *priv, struct iwl_rx_queue *q } q->write_actual = (q->write & ~0x7); - iwl_write_direct32(priv, FH_RSCSR_CHNL0_WPTR, + iwl_write_direct32(priv, rx_wrt_ptr_reg, q->write_actual); /* Else device is assumed to be awake */ } else { /* Device expects a multiple of 8 */ q->write_actual = (q->write & ~0x7); - iwl_write_direct32(priv, FH_RSCSR_CHNL0_WPTR, + iwl_write_direct32(priv, rx_wrt_ptr_reg, q->write_actual); } } @@ -178,6 +179,46 @@ void iwl_rx_queue_update_write_ptr(struct iwl_priv *priv, struct iwl_rx_queue *q spin_unlock_irqrestore(&q->lock, flags); } +int iwl_rx_queue_alloc(struct iwl_priv *priv) +{ + struct iwl_rx_queue *rxq = &priv->rxq; + struct device *dev = &priv->pci_dev->dev; + int i; + + spin_lock_init(&rxq->lock); + INIT_LIST_HEAD(&rxq->rx_free); + INIT_LIST_HEAD(&rxq->rx_used); + + /* Alloc the circular buffer of Read Buffer Descriptors (RBDs) */ + rxq->bd = dma_alloc_coherent(dev, 4 * RX_QUEUE_SIZE, &rxq->bd_dma, + GFP_KERNEL); + if (!rxq->bd) + goto err_bd; + + rxq->rb_stts = dma_alloc_coherent(dev, sizeof(struct iwl_rb_status), + &rxq->rb_stts_dma, GFP_KERNEL); + if (!rxq->rb_stts) + goto err_rb; + + /* Fill the rx_used queue with _all_ of the Rx buffers */ + for (i = 0; i < RX_FREE_BUFFERS + RX_QUEUE_SIZE; i++) + list_add_tail(&rxq->pool[i].list, &rxq->rx_used); + + /* Set us so that we have processed and used all buffers, but have + * not restocked the Rx queue with fresh buffers */ + rxq->read = rxq->write = 0; + rxq->write_actual = 0; + rxq->free_count = 0; + rxq->need_update = 0; + return 0; + +err_rb: + dma_free_coherent(&priv->pci_dev->dev, 4 * RX_QUEUE_SIZE, rxq->bd, + rxq->bd_dma); +err_bd: + return -ENOMEM; +} + /****************************************************************************** * * Generic RX handler implementations diff --git a/trunk/drivers/net/wireless/iwlwifi/iwl-sv-open.c b/trunk/drivers/net/wireless/iwlwifi/iwl-sv-open.c index c00aa5a1b8b8..69b7e6bf2d6f 100644 --- a/trunk/drivers/net/wireless/iwlwifi/iwl-sv-open.c +++ b/trunk/drivers/net/wireless/iwlwifi/iwl-sv-open.c @@ -69,6 +69,7 @@ #include #include + #include "iwl-dev.h" #include "iwl-core.h" #include "iwl-debug.h" @@ -100,11 +101,9 @@ struct nla_policy iwl_testmode_gnl_msg_policy[IWL_TM_ATTR_MAX] = { [IWL_TM_ATTR_EEPROM] = { .type = NLA_UNSPEC, }, [IWL_TM_ATTR_TRACE_ADDR] = { .type = NLA_UNSPEC, }, - [IWL_TM_ATTR_TRACE_DUMP] = { .type = NLA_UNSPEC, }, - [IWL_TM_ATTR_TRACE_SIZE] = { .type = NLA_U32, }, + [IWL_TM_ATTR_TRACE_DATA] = { .type = NLA_UNSPEC, }, [IWL_TM_ATTR_FIXRATE] = { .type = NLA_U32, }, - }; /* @@ -180,21 +179,19 @@ void iwl_testmode_init(struct iwl_priv *priv) static void iwl_trace_cleanup(struct iwl_priv *priv) { - struct device *dev = priv->bus.dev; + struct device *dev = &priv->pci_dev->dev; if (priv->testmode_trace.trace_enabled) { if (priv->testmode_trace.cpu_addr && priv->testmode_trace.dma_addr) dma_free_coherent(dev, - priv->testmode_trace.total_size, + TRACE_TOTAL_SIZE, priv->testmode_trace.cpu_addr, priv->testmode_trace.dma_addr); priv->testmode_trace.trace_enabled = false; priv->testmode_trace.cpu_addr = NULL; priv->testmode_trace.trace_addr = NULL; priv->testmode_trace.dma_addr = 0; - priv->testmode_trace.buff_size = 0; - priv->testmode_trace.total_size = 0; } } @@ -397,7 +394,7 @@ static int iwl_testmode_driver(struct ieee80211_hw *hw, struct nlattr **tb) case IWL_TM_CMD_APP2DEV_LOAD_INIT_FW: status = iwlagn_load_ucode_wait_alive(priv, &priv->ucode_init, - IWL_UCODE_INIT); + UCODE_SUBTYPE_INIT, -1); if (status) IWL_DEBUG_INFO(priv, "Error loading init ucode: %d\n", status); @@ -411,7 +408,8 @@ static int iwl_testmode_driver(struct ieee80211_hw *hw, struct nlattr **tb) case IWL_TM_CMD_APP2DEV_LOAD_RUNTIME_FW: status = iwlagn_load_ucode_wait_alive(priv, &priv->ucode_rt, - IWL_UCODE_REGULAR); + UCODE_SUBTYPE_REGULAR, + UCODE_SUBTYPE_REGULAR_NEW); if (status) { IWL_DEBUG_INFO(priv, "Error loading runtime ucode: %d\n", status); @@ -484,29 +482,16 @@ static int iwl_testmode_trace(struct ieee80211_hw *hw, struct nlattr **tb) struct iwl_priv *priv = hw->priv; struct sk_buff *skb; int status = 0; - struct device *dev = priv->bus.dev; + struct device *dev = &priv->pci_dev->dev; switch (nla_get_u32(tb[IWL_TM_ATTR_COMMAND])) { case IWL_TM_CMD_APP2DEV_BEGIN_TRACE: if (priv->testmode_trace.trace_enabled) return -EBUSY; - if (!tb[IWL_TM_ATTR_TRACE_SIZE]) - priv->testmode_trace.buff_size = TRACE_BUFF_SIZE_DEF; - else - priv->testmode_trace.buff_size = - nla_get_u32(tb[IWL_TM_ATTR_TRACE_SIZE]); - if (!priv->testmode_trace.buff_size) - return -EINVAL; - if (priv->testmode_trace.buff_size < TRACE_BUFF_SIZE_MIN || - priv->testmode_trace.buff_size > TRACE_BUFF_SIZE_MAX) - return -EINVAL; - - priv->testmode_trace.total_size = - priv->testmode_trace.buff_size + TRACE_BUFF_PADD; priv->testmode_trace.cpu_addr = dma_alloc_coherent(dev, - priv->testmode_trace.total_size, + TRACE_TOTAL_SIZE, &priv->testmode_trace.dma_addr, GFP_KERNEL); if (!priv->testmode_trace.cpu_addr) @@ -515,7 +500,7 @@ static int iwl_testmode_trace(struct ieee80211_hw *hw, struct nlattr **tb) priv->testmode_trace.trace_addr = (u8 *)PTR_ALIGN( priv->testmode_trace.cpu_addr, 0x100); memset(priv->testmode_trace.trace_addr, 0x03B, - priv->testmode_trace.buff_size); + TRACE_BUFF_SIZE); skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy, sizeof(priv->testmode_trace.dma_addr) + 20); if (!skb) { @@ -533,14 +518,34 @@ static int iwl_testmode_trace(struct ieee80211_hw *hw, struct nlattr **tb) "Error sending msg : %d\n", status); } - priv->testmode_trace.num_chunks = - DIV_ROUND_UP(priv->testmode_trace.buff_size, - TRACE_CHUNK_SIZE); break; case IWL_TM_CMD_APP2DEV_END_TRACE: iwl_trace_cleanup(priv); break; + + case IWL_TM_CMD_APP2DEV_READ_TRACE: + if (priv->testmode_trace.trace_enabled && + priv->testmode_trace.trace_addr) { + skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy, + 20 + TRACE_BUFF_SIZE); + if (skb == NULL) { + IWL_DEBUG_INFO(priv, + "Error allocating memory\n"); + return -ENOMEM; + } + NLA_PUT(skb, IWL_TM_ATTR_TRACE_DATA, + TRACE_BUFF_SIZE, + priv->testmode_trace.trace_addr); + status = cfg80211_testmode_reply(skb); + if (status < 0) { + IWL_DEBUG_INFO(priv, + "Error sending msg : %d\n", status); + } + } else + return -EFAULT; + break; + default: IWL_DEBUG_INFO(priv, "Unknown testmode mem command ID\n"); return -ENOSYS; @@ -555,37 +560,6 @@ static int iwl_testmode_trace(struct ieee80211_hw *hw, struct nlattr **tb) return -EMSGSIZE; } -static int iwl_testmode_trace_dump(struct ieee80211_hw *hw, struct nlattr **tb, - struct sk_buff *skb, - struct netlink_callback *cb) -{ - struct iwl_priv *priv = hw->priv; - int idx, length; - - if (priv->testmode_trace.trace_enabled && - priv->testmode_trace.trace_addr) { - idx = cb->args[4]; - if (idx >= priv->testmode_trace.num_chunks) - return -ENOENT; - length = TRACE_CHUNK_SIZE; - if (((idx + 1) == priv->testmode_trace.num_chunks) && - (priv->testmode_trace.buff_size % TRACE_CHUNK_SIZE)) - length = priv->testmode_trace.buff_size % - TRACE_CHUNK_SIZE; - - NLA_PUT(skb, IWL_TM_ATTR_TRACE_DUMP, length, - priv->testmode_trace.trace_addr + - (TRACE_CHUNK_SIZE * idx)); - idx++; - cb->args[4] = idx; - return 0; - } else - return -EFAULT; - - nla_put_failure: - return -ENOBUFS; -} - /* The testmode gnl message handler that takes the gnl message from the * user space and parses it per the policy iwl_testmode_gnl_msg_policy, then * invoke the corresponding handlers. @@ -664,50 +638,3 @@ int iwl_testmode_cmd(struct ieee80211_hw *hw, void *data, int len) mutex_unlock(&priv->mutex); return result; } - -int iwl_testmode_dump(struct ieee80211_hw *hw, struct sk_buff *skb, - struct netlink_callback *cb, - void *data, int len) -{ - struct nlattr *tb[IWL_TM_ATTR_MAX]; - struct iwl_priv *priv = hw->priv; - int result; - u32 cmd; - - if (cb->args[3]) { - /* offset by 1 since commands start at 0 */ - cmd = cb->args[3] - 1; - } else { - result = nla_parse(tb, IWL_TM_ATTR_MAX - 1, data, len, - iwl_testmode_gnl_msg_policy); - if (result) { - IWL_DEBUG_INFO(priv, - "Error parsing the gnl message : %d\n", result); - return result; - } - - /* IWL_TM_ATTR_COMMAND is absolutely mandatory */ - if (!tb[IWL_TM_ATTR_COMMAND]) { - IWL_DEBUG_INFO(priv, - "Error finding testmode command type\n"); - return -ENOMSG; - } - cmd = nla_get_u32(tb[IWL_TM_ATTR_COMMAND]); - cb->args[3] = cmd + 1; - } - - /* in case multiple accesses to the device happens */ - mutex_lock(&priv->mutex); - switch (cmd) { - case IWL_TM_CMD_APP2DEV_READ_TRACE: - IWL_DEBUG_INFO(priv, "uCode trace cmd to driver\n"); - result = iwl_testmode_trace_dump(hw, tb, skb, cb); - break; - default: - result = -EINVAL; - break; - } - - mutex_unlock(&priv->mutex); - return result; -} diff --git a/trunk/drivers/net/wireless/iwlwifi/iwl-testmode.h b/trunk/drivers/net/wireless/iwlwifi/iwl-testmode.h index d825188e5215..a88085e9b361 100644 --- a/trunk/drivers/net/wireless/iwlwifi/iwl-testmode.h +++ b/trunk/drivers/net/wireless/iwlwifi/iwl-testmode.h @@ -66,151 +66,120 @@ #include -/* - * Commands from user space to kernel space(IWL_TM_CMD_ID_APP2DEV_XX) and +/* Commands from user space to kernel space(IWL_TM_CMD_ID_APP2DEV_XX) and * from and kernel space to user space(IWL_TM_CMD_ID_DEV2APP_XX). - * The command ID is carried with IWL_TM_ATTR_COMMAND. - * - * @IWL_TM_CMD_APP2DEV_UCODE: - * commands from user application to the uCode, - * the actual uCode host command ID is carried with - * IWL_TM_ATTR_UCODE_CMD_ID - * - * @IWL_TM_CMD_APP2DEV_REG_READ32: - * @IWL_TM_CMD_APP2DEV_REG_WRITE32: - * @IWL_TM_CMD_APP2DEV_REG_WRITE8: - * commands from user applicaiton to access register - * - * @IWL_TM_CMD_APP2DEV_GET_DEVICENAME: retrieve device name - * @IWL_TM_CMD_APP2DEV_LOAD_INIT_FW: load initial uCode image - * @IWL_TM_CMD_APP2DEV_CFG_INIT_CALIB: perform calibration - * @IWL_TM_CMD_APP2DEV_LOAD_RUNTIME_FW: load runtime uCode image - * @IWL_TM_CMD_APP2DEV_GET_EEPROM: request EEPROM data - * @IWL_TM_CMD_APP2DEV_FIXRATE_REQ: set fix MCS - * commands fom user space for pure driver level operations - * - * @IWL_TM_CMD_APP2DEV_BEGIN_TRACE: - * @IWL_TM_CMD_APP2DEV_END_TRACE: - * @IWL_TM_CMD_APP2DEV_READ_TRACE: - * commands fom user space for uCode trace operations - * - * @IWL_TM_CMD_DEV2APP_SYNC_RSP: - * commands from kernel space to carry the synchronous response - * to user application - * @IWL_TM_CMD_DEV2APP_UCODE_RX_PKT: - * commands from kernel space to multicast the spontaneous messages - * to user application - * @IWL_TM_CMD_DEV2APP_EEPROM_RSP: - * commands from kernel space to carry the eeprom response - * to user application + * The command ID is carried with IWL_TM_ATTR_COMMAND. There are three types of + * of command from user space and two types of command from kernel space. + * See below. */ enum iwl_tm_cmd_t { - IWL_TM_CMD_APP2DEV_UCODE = 1, - IWL_TM_CMD_APP2DEV_REG_READ32 = 2, - IWL_TM_CMD_APP2DEV_REG_WRITE32 = 3, - IWL_TM_CMD_APP2DEV_REG_WRITE8 = 4, - IWL_TM_CMD_APP2DEV_GET_DEVICENAME = 5, - IWL_TM_CMD_APP2DEV_LOAD_INIT_FW = 6, - IWL_TM_CMD_APP2DEV_CFG_INIT_CALIB = 7, - IWL_TM_CMD_APP2DEV_LOAD_RUNTIME_FW = 8, - IWL_TM_CMD_APP2DEV_GET_EEPROM = 9, - IWL_TM_CMD_APP2DEV_FIXRATE_REQ = 10, - IWL_TM_CMD_APP2DEV_BEGIN_TRACE = 11, - IWL_TM_CMD_APP2DEV_END_TRACE = 12, - IWL_TM_CMD_APP2DEV_READ_TRACE = 13, - IWL_TM_CMD_DEV2APP_SYNC_RSP = 14, - IWL_TM_CMD_DEV2APP_UCODE_RX_PKT = 15, - IWL_TM_CMD_DEV2APP_EEPROM_RSP = 16, - IWL_TM_CMD_MAX = 17, + /* commands from user application to the uCode, + * the actual uCode host command ID is carried with + * IWL_TM_ATTR_UCODE_CMD_ID */ + IWL_TM_CMD_APP2DEV_UCODE = 1, + + /* commands from user applicaiton to access register */ + IWL_TM_CMD_APP2DEV_REG_READ32, + IWL_TM_CMD_APP2DEV_REG_WRITE32, + IWL_TM_CMD_APP2DEV_REG_WRITE8, + + /* commands fom user space for pure driver level operations */ + IWL_TM_CMD_APP2DEV_GET_DEVICENAME, + IWL_TM_CMD_APP2DEV_LOAD_INIT_FW, + IWL_TM_CMD_APP2DEV_CFG_INIT_CALIB, + IWL_TM_CMD_APP2DEV_LOAD_RUNTIME_FW, + IWL_TM_CMD_APP2DEV_GET_EEPROM, + IWL_TM_CMD_APP2DEV_FIXRATE_REQ, + /* if there is other new command for the driver layer operation, + * append them here */ + + /* commands fom user space for uCode trace operations */ + IWL_TM_CMD_APP2DEV_BEGIN_TRACE, + IWL_TM_CMD_APP2DEV_END_TRACE, + IWL_TM_CMD_APP2DEV_READ_TRACE, + + /* commands from kernel space to carry the synchronous response + * to user application */ + IWL_TM_CMD_DEV2APP_SYNC_RSP, + + /* commands from kernel space to multicast the spontaneous messages + * to user application */ + IWL_TM_CMD_DEV2APP_UCODE_RX_PKT, + + /* commands from kernel space to carry the eeprom response + * to user application */ + IWL_TM_CMD_DEV2APP_EEPROM_RSP, + + IWL_TM_CMD_MAX, }; -/* - * Atrribute filed in testmode command - * See enum iwl_tm_cmd_t. - * - * @IWL_TM_ATTR_NOT_APPLICABLE: - * The attribute is not applicable or invalid - * @IWL_TM_ATTR_COMMAND: - * From user space to kernel space: - * the command either destines to ucode, driver, or register; - * From kernel space to user space: - * the command either carries synchronous response, - * or the spontaneous message multicast from the device; - * - * @IWL_TM_ATTR_UCODE_CMD_ID: - * @IWL_TM_ATTR_UCODE_CMD_DATA: - * When IWL_TM_ATTR_COMMAND is IWL_TM_CMD_APP2DEV_UCODE, - * The mandatory fields are : - * IWL_TM_ATTR_UCODE_CMD_ID for recognizable command ID; - * IWL_TM_ATTR_COMMAND_FLAG for the flags of the commands; - * The optional fields are: - * IWL_TM_ATTR_UCODE_CMD_DATA for the actual command payload - * to the ucode - * - * @IWL_TM_ATTR_REG_OFFSET: - * @IWL_TM_ATTR_REG_VALUE8: - * @IWL_TM_ATTR_REG_VALUE32: - * When IWL_TM_ATTR_COMMAND is IWL_TM_CMD_APP2DEV_REG_XXX, - * The mandatory fields are: - * IWL_TM_ATTR_REG_OFFSET for the offset of the target register; - * IWL_TM_ATTR_REG_VALUE8 or IWL_TM_ATTR_REG_VALUE32 for value - * - * @IWL_TM_ATTR_SYNC_RSP: - * When IWL_TM_ATTR_COMMAND is IWL_TM_CMD_DEV2APP_SYNC_RSP, - * The mandatory fields are: - * IWL_TM_ATTR_SYNC_RSP for the data content responding to the user - * application command - * - * @IWL_TM_ATTR_UCODE_RX_PKT: - * When IWL_TM_ATTR_COMMAND is IWL_TM_CMD_DEV2APP_UCODE_RX_PKT, - * The mandatory fields are: - * IWL_TM_ATTR_UCODE_RX_PKT for the data content multicast to the user - * application - * - * @IWL_TM_ATTR_EEPROM: - * When IWL_TM_ATTR_COMMAND is IWL_TM_CMD_DEV2APP_EEPROM, - * The mandatory fields are: - * IWL_TM_ATTR_EEPROM for the data content responging to the user - * application - * - * @IWL_TM_ATTR_TRACE_ADDR: - * @IWL_TM_ATTR_TRACE_SIZE: - * @IWL_TM_ATTR_TRACE_DUMP: - * When IWL_TM_ATTR_COMMAND is IWL_TM_CMD_APP2DEV_XXX_TRACE, - * The mandatory fields are: - * IWL_TM_ATTR_MEM_TRACE_ADDR for the trace address - * IWL_TM_ATTR_MEM_TRACE_SIZE for the trace buffer size - * IWL_TM_ATTR_MEM_TRACE_DUMP for the trace dump - * - * @IWL_TM_ATTR_FIXRATE: - * When IWL_TM_ATTR_COMMAND is IWL_TM_CMD_APP2DEV_FIXRATE_REQ, - * The mandatory fields are: - * IWL_TM_ATTR_FIXRATE for the fixed rate - * - */ enum iwl_tm_attr_t { - IWL_TM_ATTR_NOT_APPLICABLE = 0, - IWL_TM_ATTR_COMMAND = 1, - IWL_TM_ATTR_UCODE_CMD_ID = 2, - IWL_TM_ATTR_UCODE_CMD_DATA = 3, - IWL_TM_ATTR_REG_OFFSET = 4, - IWL_TM_ATTR_REG_VALUE8 = 5, - IWL_TM_ATTR_REG_VALUE32 = 6, - IWL_TM_ATTR_SYNC_RSP = 7, - IWL_TM_ATTR_UCODE_RX_PKT = 8, - IWL_TM_ATTR_EEPROM = 9, - IWL_TM_ATTR_TRACE_ADDR = 10, - IWL_TM_ATTR_TRACE_SIZE = 11, - IWL_TM_ATTR_TRACE_DUMP = 12, - IWL_TM_ATTR_FIXRATE = 13, - IWL_TM_ATTR_MAX = 14, + IWL_TM_ATTR_NOT_APPLICABLE = 0, + + /* From user space to kernel space: + * the command either destines to ucode, driver, or register; + * See enum iwl_tm_cmd_t. + * + * From kernel space to user space: + * the command either carries synchronous response, + * or the spontaneous message multicast from the device; + * See enum iwl_tm_cmd_t. */ + IWL_TM_ATTR_COMMAND, + + /* When IWL_TM_ATTR_COMMAND is IWL_TM_CMD_APP2DEV_UCODE, + * The mandatory fields are : + * IWL_TM_ATTR_UCODE_CMD_ID for recognizable command ID; + * IWL_TM_ATTR_COMMAND_FLAG for the flags of the commands; + * The optional fields are: + * IWL_TM_ATTR_UCODE_CMD_DATA for the actual command payload + * to the ucode */ + IWL_TM_ATTR_UCODE_CMD_ID, + IWL_TM_ATTR_UCODE_CMD_DATA, + + /* When IWL_TM_ATTR_COMMAND is IWL_TM_CMD_APP2DEV_REG_XXX, + * The mandatory fields are: + * IWL_TM_ATTR_REG_OFFSET for the offset of the target register; + * IWL_TM_ATTR_REG_VALUE8 or IWL_TM_ATTR_REG_VALUE32 for value */ + IWL_TM_ATTR_REG_OFFSET, + IWL_TM_ATTR_REG_VALUE8, + IWL_TM_ATTR_REG_VALUE32, + + /* When IWL_TM_ATTR_COMMAND is IWL_TM_CMD_DEV2APP_SYNC_RSP, + * The mandatory fields are: + * IWL_TM_ATTR_SYNC_RSP for the data content responding to the user + * application command */ + IWL_TM_ATTR_SYNC_RSP, + /* When IWL_TM_ATTR_COMMAND is IWL_TM_CMD_DEV2APP_UCODE_RX_PKT, + * The mandatory fields are: + * IWL_TM_ATTR_UCODE_RX_PKT for the data content multicast to the user + * application */ + IWL_TM_ATTR_UCODE_RX_PKT, + + /* When IWL_TM_ATTR_COMMAND is IWL_TM_CMD_DEV2APP_EEPROM, + * The mandatory fields are: + * IWL_TM_ATTR_EEPROM for the data content responging to the user + * application */ + IWL_TM_ATTR_EEPROM, + + /* When IWL_TM_ATTR_COMMAND is IWL_TM_CMD_APP2DEV_XXX_TRACE, + * The mandatory fields are: + * IWL_TM_ATTR_MEM_TRACE_ADDR for the trace address + */ + IWL_TM_ATTR_TRACE_ADDR, + IWL_TM_ATTR_TRACE_DATA, + + /* When IWL_TM_ATTR_COMMAND is IWL_TM_CMD_APP2DEV_FIXRATE_REQ, + * The mandatory fields are: + * IWL_TM_ATTR_FIXRATE for the fixed rate + */ + IWL_TM_ATTR_FIXRATE, + + IWL_TM_ATTR_MAX, }; /* uCode trace buffer */ -#define TRACE_BUFF_SIZE_MAX 0x200000 -#define TRACE_BUFF_SIZE_MIN 0x20000 -#define TRACE_BUFF_SIZE_DEF TRACE_BUFF_SIZE_MIN +#define TRACE_BUFF_SIZE 0x20000 #define TRACE_BUFF_PADD 0x2000 -#define TRACE_CHUNK_SIZE (PAGE_SIZE - 1024) +#define TRACE_TOTAL_SIZE (TRACE_BUFF_SIZE + TRACE_BUFF_PADD) #endif diff --git a/trunk/drivers/net/wireless/iwlwifi/iwl-trans.c b/trunk/drivers/net/wireless/iwlwifi/iwl-trans.c deleted file mode 100644 index 7b7b97d8c2e1..000000000000 --- a/trunk/drivers/net/wireless/iwlwifi/iwl-trans.c +++ /dev/null @@ -1,423 +0,0 @@ -/****************************************************************************** - * - * This file is provided under a dual BSD/GPLv2 license. When using or - * redistributing this file, you may do so under either license. - * - * GPL LICENSE SUMMARY - * - * Copyright(c) 2007 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110, - * USA - * - * The full GNU General Public License is included in this distribution - * in the file called LICENSE.GPL. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - * - * BSD LICENSE - * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name Intel Corporation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - *****************************************************************************/ -#include "iwl-dev.h" -#include "iwl-trans.h" -#include "iwl-core.h" -#include "iwl-helpers.h" -/*TODO remove uneeded includes when the transport layer tx_free will be here */ -#include "iwl-agn.h" - -static int iwl_trans_rx_alloc(struct iwl_priv *priv) -{ - struct iwl_rx_queue *rxq = &priv->rxq; - struct device *dev = priv->bus.dev; - - memset(&priv->rxq, 0, sizeof(priv->rxq)); - - spin_lock_init(&rxq->lock); - INIT_LIST_HEAD(&rxq->rx_free); - INIT_LIST_HEAD(&rxq->rx_used); - - if (WARN_ON(rxq->bd || rxq->rb_stts)) - return -EINVAL; - - /* Allocate the circular buffer of Read Buffer Descriptors (RBDs) */ - rxq->bd = dma_alloc_coherent(dev, sizeof(__le32) * RX_QUEUE_SIZE, - &rxq->bd_dma, GFP_KERNEL); - if (!rxq->bd) - goto err_bd; - memset(rxq->bd, 0, sizeof(__le32) * RX_QUEUE_SIZE); - - /*Allocate the driver's pointer to receive buffer status */ - rxq->rb_stts = dma_alloc_coherent(dev, sizeof(*rxq->rb_stts), - &rxq->rb_stts_dma, GFP_KERNEL); - if (!rxq->rb_stts) - goto err_rb_stts; - memset(rxq->rb_stts, 0, sizeof(*rxq->rb_stts)); - - return 0; - -err_rb_stts: - dma_free_coherent(dev, sizeof(__le32) * RX_QUEUE_SIZE, - rxq->bd, rxq->bd_dma); - memset(&rxq->bd_dma, 0, sizeof(rxq->bd_dma)); - rxq->bd = NULL; -err_bd: - return -ENOMEM; -} - -static void iwl_trans_rxq_free_rx_bufs(struct iwl_priv *priv) -{ - struct iwl_rx_queue *rxq = &priv->rxq; - int i; - - /* Fill the rx_used queue with _all_ of the Rx buffers */ - for (i = 0; i < RX_FREE_BUFFERS + RX_QUEUE_SIZE; i++) { - /* In the reset function, these buffers may have been allocated - * to an SKB, so we need to unmap and free potential storage */ - if (rxq->pool[i].page != NULL) { - dma_unmap_page(priv->bus.dev, rxq->pool[i].page_dma, - PAGE_SIZE << priv->hw_params.rx_page_order, - DMA_FROM_DEVICE); - __iwl_free_pages(priv, rxq->pool[i].page); - rxq->pool[i].page = NULL; - } - list_add_tail(&rxq->pool[i].list, &rxq->rx_used); - } -} - -static int iwl_trans_rx_init(struct iwl_priv *priv) -{ - struct iwl_rx_queue *rxq = &priv->rxq; - int i, err; - unsigned long flags; - - if (!rxq->bd) { - err = iwl_trans_rx_alloc(priv); - if (err) - return err; - } - - spin_lock_irqsave(&rxq->lock, flags); - INIT_LIST_HEAD(&rxq->rx_free); - INIT_LIST_HEAD(&rxq->rx_used); - - iwl_trans_rxq_free_rx_bufs(priv); - - for (i = 0; i < RX_QUEUE_SIZE; i++) - rxq->queue[i] = NULL; - - /* Set us so that we have processed and used all buffers, but have - * not restocked the Rx queue with fresh buffers */ - rxq->read = rxq->write = 0; - rxq->write_actual = 0; - rxq->free_count = 0; - spin_unlock_irqrestore(&rxq->lock, flags); - - return 0; -} - -static void iwl_trans_rx_free(struct iwl_priv *priv) -{ - struct iwl_rx_queue *rxq = &priv->rxq; - unsigned long flags; - - /*if rxq->bd is NULL, it means that nothing has been allocated, - * exit now */ - if (!rxq->bd) { - IWL_DEBUG_INFO(priv, "Free NULL rx context\n"); - return; - } - - spin_lock_irqsave(&rxq->lock, flags); - iwl_trans_rxq_free_rx_bufs(priv); - spin_unlock_irqrestore(&rxq->lock, flags); - - dma_free_coherent(priv->bus.dev, sizeof(__le32) * RX_QUEUE_SIZE, - rxq->bd, rxq->bd_dma); - memset(&rxq->bd_dma, 0, sizeof(rxq->bd_dma)); - rxq->bd = NULL; - - if (rxq->rb_stts) - dma_free_coherent(priv->bus.dev, - sizeof(struct iwl_rb_status), - rxq->rb_stts, rxq->rb_stts_dma); - else - IWL_DEBUG_INFO(priv, "Free rxq->rb_stts which is NULL\n"); - memset(&rxq->rb_stts_dma, 0, sizeof(rxq->rb_stts_dma)); - rxq->rb_stts = NULL; -} - -/* TODO:remove this code duplication */ -static inline int iwlagn_alloc_dma_ptr(struct iwl_priv *priv, - struct iwl_dma_ptr *ptr, size_t size) -{ - if (WARN_ON(ptr->addr)) - return -EINVAL; - - ptr->addr = dma_alloc_coherent(priv->bus.dev, size, - &ptr->dma, GFP_KERNEL); - if (!ptr->addr) - return -ENOMEM; - ptr->size = size; - return 0; -} - -static int iwl_trans_txq_alloc(struct iwl_priv *priv, struct iwl_tx_queue *txq, - int slots_num, u32 txq_id) -{ - size_t tfd_sz = priv->hw_params.tfd_size * TFD_QUEUE_SIZE_MAX; - int i; - - if (WARN_ON(txq->meta || txq->cmd || txq->txb || txq->tfds)) - return -EINVAL; - - txq->meta = kzalloc(sizeof(txq->meta[0]) * slots_num, - GFP_KERNEL); - txq->cmd = kzalloc(sizeof(txq->cmd[0]) * slots_num, - GFP_KERNEL); - - if (!txq->meta || !txq->cmd) - goto error; - - for (i = 0; i < slots_num; i++) { - txq->cmd[i] = kmalloc(sizeof(struct iwl_device_cmd), - GFP_KERNEL); - if (!txq->cmd[i]) - goto error; - } - - /* Alloc driver data array and TFD circular buffer */ - /* Driver private data, only for Tx (not command) queues, - * not shared with device. */ - if (txq_id != priv->cmd_queue) { - txq->txb = kzalloc(sizeof(txq->txb[0]) * - TFD_QUEUE_SIZE_MAX, GFP_KERNEL); - if (!txq->txb) { - IWL_ERR(priv, "kmalloc for auxiliary BD " - "structures failed\n"); - goto error; - } - } else { - txq->txb = NULL; - } - - /* Circular buffer of transmit frame descriptors (TFDs), - * shared with device */ - txq->tfds = dma_alloc_coherent(priv->bus.dev, tfd_sz, &txq->q.dma_addr, - GFP_KERNEL); - if (!txq->tfds) { - IWL_ERR(priv, "dma_alloc_coherent(%zd) failed\n", tfd_sz); - goto error; - } - txq->q.id = txq_id; - - return 0; -error: - kfree(txq->txb); - txq->txb = NULL; - /* since txq->cmd has been zeroed, - * all non allocated cmd[i] will be NULL */ - if (txq->cmd) - for (i = 0; i < slots_num; i++) - kfree(txq->cmd[i]); - kfree(txq->meta); - kfree(txq->cmd); - txq->meta = NULL; - txq->cmd = NULL; - - return -ENOMEM; - -} - -static int iwl_trans_txq_init(struct iwl_priv *priv, struct iwl_tx_queue *txq, - int slots_num, u32 txq_id) -{ - int ret; - - txq->need_update = 0; - memset(txq->meta, 0, sizeof(txq->meta[0]) * slots_num); - - /* - * For the default queues 0-3, set up the swq_id - * already -- all others need to get one later - * (if they need one at all). - */ - if (txq_id < 4) - iwl_set_swq_id(txq, txq_id, txq_id); - - /* TFD_QUEUE_SIZE_MAX must be power-of-two size, otherwise - * iwl_queue_inc_wrap and iwl_queue_dec_wrap are broken. */ - BUILD_BUG_ON(TFD_QUEUE_SIZE_MAX & (TFD_QUEUE_SIZE_MAX - 1)); - - /* Initialize queue's high/low-water marks, and head/tail indexes */ - ret = iwl_queue_init(priv, &txq->q, TFD_QUEUE_SIZE_MAX, slots_num, - txq_id); - if (ret) - return ret; - - /* - * Tell nic where to find circular buffer of Tx Frame Descriptors for - * given Tx queue, and enable the DMA channel used for that queue. - * Circular buffer (TFD queue in DRAM) physical base address */ - iwl_write_direct32(priv, FH_MEM_CBBC_QUEUE(txq_id), - txq->q.dma_addr >> 8); - - return 0; -} - -/** - * iwl_trans_tx_alloc - allocate TX context - * Allocate all Tx DMA structures and initialize them - * - * @param priv - * @return error code - */ -static int iwl_trans_tx_alloc(struct iwl_priv *priv) -{ - int ret; - int txq_id, slots_num; - - /*It is not allowed to alloc twice, so warn when this happens. - * We cannot rely on the previous allocation, so free and fail */ - if (WARN_ON(priv->txq)) { - ret = -EINVAL; - goto error; - } - - ret = iwlagn_alloc_dma_ptr(priv, &priv->scd_bc_tbls, - priv->hw_params.scd_bc_tbls_size); - if (ret) { - IWL_ERR(priv, "Scheduler BC Table allocation failed\n"); - goto error; - } - - /* Alloc keep-warm buffer */ - ret = iwlagn_alloc_dma_ptr(priv, &priv->kw, IWL_KW_SIZE); - if (ret) { - IWL_ERR(priv, "Keep Warm allocation failed\n"); - goto error; - } - - priv->txq = kzalloc(sizeof(struct iwl_tx_queue) * - priv->cfg->base_params->num_of_queues, GFP_KERNEL); - if (!priv->txq) { - IWL_ERR(priv, "Not enough memory for txq\n"); - ret = ENOMEM; - goto error; - } - - /* Alloc and init all Tx queues, including the command queue (#4/#9) */ - for (txq_id = 0; txq_id < priv->hw_params.max_txq_num; txq_id++) { - slots_num = (txq_id == priv->cmd_queue) ? - TFD_CMD_SLOTS : TFD_TX_CMD_SLOTS; - ret = iwl_trans_txq_alloc(priv, &priv->txq[txq_id], slots_num, - txq_id); - if (ret) { - IWL_ERR(priv, "Tx %d queue alloc failed\n", txq_id); - goto error; - } - } - - return 0; - -error: - iwlagn_hw_txq_ctx_free(priv); - - return ret; -} -static int iwl_trans_tx_init(struct iwl_priv *priv) -{ - int ret; - int txq_id, slots_num; - unsigned long flags; - bool alloc = false; - - if (!priv->txq) { - ret = iwl_trans_tx_alloc(priv); - if (ret) - goto error; - alloc = true; - } - - spin_lock_irqsave(&priv->lock, flags); - - /* Turn off all Tx DMA fifos */ - iwl_write_prph(priv, IWLAGN_SCD_TXFACT, 0); - - /* Tell NIC where to find the "keep warm" buffer */ - iwl_write_direct32(priv, FH_KW_MEM_ADDR_REG, priv->kw.dma >> 4); - - spin_unlock_irqrestore(&priv->lock, flags); - - /* Alloc and init all Tx queues, including the command queue (#4/#9) */ - for (txq_id = 0; txq_id < priv->hw_params.max_txq_num; txq_id++) { - slots_num = (txq_id == priv->cmd_queue) ? - TFD_CMD_SLOTS : TFD_TX_CMD_SLOTS; - ret = iwl_trans_txq_init(priv, &priv->txq[txq_id], slots_num, - txq_id); - if (ret) { - IWL_ERR(priv, "Tx %d queue init failed\n", txq_id); - goto error; - } - } - - return 0; -error: - /*Upon error, free only if we allocated something */ - if (alloc) - iwlagn_hw_txq_ctx_free(priv); - return ret; -} - -static const struct iwl_trans_ops trans_ops = { - .rx_init = iwl_trans_rx_init, - .rx_free = iwl_trans_rx_free, - - .tx_init = iwl_trans_tx_init, -}; - -void iwl_trans_register(struct iwl_trans *trans) -{ - trans->ops = &trans_ops; -} diff --git a/trunk/drivers/net/wireless/iwlwifi/iwl-trans.h b/trunk/drivers/net/wireless/iwlwifi/iwl-trans.h deleted file mode 100644 index bec494c5a979..000000000000 --- a/trunk/drivers/net/wireless/iwlwifi/iwl-trans.h +++ /dev/null @@ -1,64 +0,0 @@ -/****************************************************************************** - * - * This file is provided under a dual BSD/GPLv2 license. When using or - * redistributing this file, you may do so under either license. - * - * GPL LICENSE SUMMARY - * - * Copyright(c) 2007 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110, - * USA - * - * The full GNU General Public License is included in this distribution - * in the file called LICENSE.GPL. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - * - * BSD LICENSE - * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name Intel Corporation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - *****************************************************************************/ - -void iwl_trans_register(struct iwl_trans *trans); diff --git a/trunk/drivers/net/wireless/iwlwifi/iwl-tx.c b/trunk/drivers/net/wireless/iwlwifi/iwl-tx.c index db5abaa2ff7e..1084fe0e8a86 100644 --- a/trunk/drivers/net/wireless/iwlwifi/iwl-tx.c +++ b/trunk/drivers/net/wireless/iwlwifi/iwl-tx.c @@ -126,8 +126,9 @@ static inline u8 iwl_tfd_get_num_tbs(struct iwl_tfd *tfd) } static void iwlagn_unmap_tfd(struct iwl_priv *priv, struct iwl_cmd_meta *meta, - struct iwl_tfd *tfd, enum dma_data_direction dma_dir) + struct iwl_tfd *tfd) { + struct pci_dev *dev = priv->pci_dev; int i; int num_tbs; @@ -142,15 +143,15 @@ static void iwlagn_unmap_tfd(struct iwl_priv *priv, struct iwl_cmd_meta *meta, /* Unmap tx_cmd */ if (num_tbs) - dma_unmap_single(priv->bus.dev, + pci_unmap_single(dev, dma_unmap_addr(meta, mapping), dma_unmap_len(meta, len), - DMA_BIDIRECTIONAL); + PCI_DMA_BIDIRECTIONAL); /* Unmap chunks, if any. */ for (i = 1; i < num_tbs; i++) - dma_unmap_single(priv->bus.dev, iwl_tfd_tb_get_addr(tfd, i), - iwl_tfd_tb_get_len(tfd, i), dma_dir); + pci_unmap_single(dev, iwl_tfd_tb_get_addr(tfd, i), + iwl_tfd_tb_get_len(tfd, i), PCI_DMA_TODEVICE); } /** @@ -166,8 +167,7 @@ void iwlagn_txq_free_tfd(struct iwl_priv *priv, struct iwl_tx_queue *txq) struct iwl_tfd *tfd_tmp = txq->tfds; int index = txq->q.read_ptr; - iwlagn_unmap_tfd(priv, &txq->meta[index], &tfd_tmp[index], - DMA_TO_DEVICE); + iwlagn_unmap_tfd(priv, &txq->meta[index], &tfd_tmp[index]); /* free SKB */ if (txq->txb) { @@ -220,6 +220,24 @@ int iwlagn_txq_attach_buf_to_tfd(struct iwl_priv *priv, return 0; } +/* + * Tell nic where to find circular buffer of Tx Frame Descriptors for + * given Tx queue, and enable the DMA channel used for that queue. + * + * supports up to 16 Tx queues in DRAM, mapped to up to 8 Tx DMA + * channels supported in hardware. + */ +static int iwlagn_tx_queue_init(struct iwl_priv *priv, struct iwl_tx_queue *txq) +{ + int txq_id = txq->q.id; + + /* Circular buffer (TFD queue in DRAM) physical base address */ + iwl_write_direct32(priv, FH_MEM_CBBC_QUEUE(txq_id), + txq->q.dma_addr >> 8); + + return 0; +} + /** * iwl_tx_queue_unmap - Unmap any remaining DMA mappings and free skb's */ @@ -248,7 +266,7 @@ void iwl_tx_queue_unmap(struct iwl_priv *priv, int txq_id) void iwl_tx_queue_free(struct iwl_priv *priv, int txq_id) { struct iwl_tx_queue *txq = &priv->txq[txq_id]; - struct device *dev = priv->bus.dev; + struct device *dev = &priv->pci_dev->dev; int i; iwl_tx_queue_unmap(priv, txq_id); @@ -292,8 +310,10 @@ void iwl_cmd_queue_unmap(struct iwl_priv *priv) i = get_cmd_index(q, q->read_ptr); if (txq->meta[i].flags & CMD_MAPPED) { - iwlagn_unmap_tfd(priv, &txq->meta[i], &txq->tfds[i], - DMA_BIDIRECTIONAL); + pci_unmap_single(priv->pci_dev, + dma_unmap_addr(&txq->meta[i], mapping), + dma_unmap_len(&txq->meta[i], len), + PCI_DMA_BIDIRECTIONAL); txq->meta[i].flags = 0; } @@ -312,7 +332,7 @@ void iwl_cmd_queue_unmap(struct iwl_priv *priv) void iwl_cmd_queue_free(struct iwl_priv *priv) { struct iwl_tx_queue *txq = &priv->txq[priv->cmd_queue]; - struct device *dev = priv->bus.dev; + struct device *dev = &priv->pci_dev->dev; int i; iwl_cmd_queue_unmap(priv); @@ -374,10 +394,11 @@ int iwl_queue_space(const struct iwl_queue *q) return s; } + /** * iwl_queue_init - Initialize queue's high/low-water and read/write indexes */ -int iwl_queue_init(struct iwl_priv *priv, struct iwl_queue *q, +static int iwl_queue_init(struct iwl_priv *priv, struct iwl_queue *q, int count, int slots_num, u32 id) { q->n_bd = count; @@ -407,6 +428,129 @@ int iwl_queue_init(struct iwl_priv *priv, struct iwl_queue *q, return 0; } +/** + * iwl_tx_queue_alloc - Alloc driver data and TFD CB for one Tx/cmd queue + */ +static int iwl_tx_queue_alloc(struct iwl_priv *priv, + struct iwl_tx_queue *txq, u32 id) +{ + struct device *dev = &priv->pci_dev->dev; + size_t tfd_sz = priv->hw_params.tfd_size * TFD_QUEUE_SIZE_MAX; + + /* Driver private data, only for Tx (not command) queues, + * not shared with device. */ + if (id != priv->cmd_queue) { + txq->txb = kzalloc(sizeof(txq->txb[0]) * + TFD_QUEUE_SIZE_MAX, GFP_KERNEL); + if (!txq->txb) { + IWL_ERR(priv, "kmalloc for auxiliary BD " + "structures failed\n"); + goto error; + } + } else { + txq->txb = NULL; + } + + /* Circular buffer of transmit frame descriptors (TFDs), + * shared with device */ + txq->tfds = dma_alloc_coherent(dev, tfd_sz, &txq->q.dma_addr, + GFP_KERNEL); + if (!txq->tfds) { + IWL_ERR(priv, "pci_alloc_consistent(%zd) failed\n", tfd_sz); + goto error; + } + txq->q.id = id; + + return 0; + + error: + kfree(txq->txb); + txq->txb = NULL; + + return -ENOMEM; +} + +/** + * iwl_tx_queue_init - Allocate and initialize one tx/cmd queue + */ +int iwl_tx_queue_init(struct iwl_priv *priv, struct iwl_tx_queue *txq, + int slots_num, u32 txq_id) +{ + int i, len; + int ret; + + txq->meta = kzalloc(sizeof(struct iwl_cmd_meta) * slots_num, + GFP_KERNEL); + txq->cmd = kzalloc(sizeof(struct iwl_device_cmd *) * slots_num, + GFP_KERNEL); + + if (!txq->meta || !txq->cmd) + goto out_free_arrays; + + len = sizeof(struct iwl_device_cmd); + for (i = 0; i < slots_num; i++) { + txq->cmd[i] = kmalloc(len, GFP_KERNEL); + if (!txq->cmd[i]) + goto err; + } + + /* Alloc driver data array and TFD circular buffer */ + ret = iwl_tx_queue_alloc(priv, txq, txq_id); + if (ret) + goto err; + + txq->need_update = 0; + + /* + * For the default queues 0-3, set up the swq_id + * already -- all others need to get one later + * (if they need one at all). + */ + if (txq_id < 4) + iwl_set_swq_id(txq, txq_id, txq_id); + + /* TFD_QUEUE_SIZE_MAX must be power-of-two size, otherwise + * iwl_queue_inc_wrap and iwl_queue_dec_wrap are broken. */ + BUILD_BUG_ON(TFD_QUEUE_SIZE_MAX & (TFD_QUEUE_SIZE_MAX - 1)); + + /* Initialize queue's high/low-water marks, and head/tail indexes */ + ret = iwl_queue_init(priv, &txq->q, TFD_QUEUE_SIZE_MAX, slots_num, txq_id); + if (ret) + return ret; + + /* Tell device where to find queue */ + iwlagn_tx_queue_init(priv, txq); + + return 0; +err: + for (i = 0; i < slots_num; i++) + kfree(txq->cmd[i]); +out_free_arrays: + kfree(txq->meta); + kfree(txq->cmd); + + return -ENOMEM; +} + +void iwl_tx_queue_reset(struct iwl_priv *priv, struct iwl_tx_queue *txq, + int slots_num, u32 txq_id) +{ + int actual_slots = slots_num; + + if (txq_id == priv->cmd_queue) + actual_slots++; + + memset(txq->meta, 0, sizeof(struct iwl_cmd_meta) * actual_slots); + + txq->need_update = 0; + + /* Initialize queue's high/low-water marks, and head/tail indexes */ + iwl_queue_init(priv, &txq->q, TFD_QUEUE_SIZE_MAX, slots_num, txq_id); + + /* Tell device where to find queue */ + iwlagn_tx_queue_init(priv, txq); +} + /*************** HOST COMMAND QUEUE FUNCTIONS *****/ /** @@ -533,9 +677,9 @@ int iwl_enqueue_hcmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd) le16_to_cpu(out_cmd->hdr.sequence), cmd_size, q->write_ptr, idx, priv->cmd_queue); - phys_addr = dma_map_single(priv->bus.dev, &out_cmd->hdr, copy_size, - DMA_BIDIRECTIONAL); - if (unlikely(dma_mapping_error(priv->bus.dev, phys_addr))) { + phys_addr = pci_map_single(priv->pci_dev, &out_cmd->hdr, + copy_size, PCI_DMA_BIDIRECTIONAL); + if (unlikely(pci_dma_mapping_error(priv->pci_dev, phys_addr))) { idx = -ENOMEM; goto out; } @@ -555,12 +699,11 @@ int iwl_enqueue_hcmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd) continue; if (!(cmd->dataflags[i] & IWL_HCMD_DFL_NOCOPY)) continue; - phys_addr = dma_map_single(priv->bus.dev, (void *)cmd->data[i], - cmd->len[i], DMA_BIDIRECTIONAL); - if (dma_mapping_error(priv->bus.dev, phys_addr)) { + phys_addr = pci_map_single(priv->pci_dev, (void *)cmd->data[i], + cmd->len[i], PCI_DMA_TODEVICE); + if (pci_dma_mapping_error(priv->pci_dev, phys_addr)) { iwlagn_unmap_tfd(priv, out_meta, - &txq->tfds[q->write_ptr], - DMA_BIDIRECTIONAL); + &txq->tfds[q->write_ptr]); idx = -ENOMEM; goto out; } @@ -664,7 +807,7 @@ void iwl_tx_cmd_complete(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb) cmd = txq->cmd[cmd_index]; meta = &txq->meta[cmd_index]; - iwlagn_unmap_tfd(priv, meta, &txq->tfds[index], DMA_BIDIRECTIONAL); + iwlagn_unmap_tfd(priv, meta, &txq->tfds[index]); /* Input error checking is done when commands are added to queue. */ if (meta->flags & CMD_WANT_SKB) { diff --git a/trunk/drivers/net/wireless/libertas/if_sdio.c b/trunk/drivers/net/wireless/libertas/if_sdio.c index 387786e1b394..224e9853c480 100644 --- a/trunk/drivers/net/wireless/libertas/if_sdio.c +++ b/trunk/drivers/net/wireless/libertas/if_sdio.c @@ -892,37 +892,6 @@ static int if_sdio_reset_deep_sleep_wakeup(struct lbs_private *priv) } -static struct mmc_host *reset_host; - -static void if_sdio_reset_card_worker(struct work_struct *work) -{ - /* - * The actual reset operation must be run outside of lbs_thread. This - * is because mmc_remove_host() will cause the device to be instantly - * destroyed, and the libertas driver then needs to end lbs_thread, - * leading to a deadlock. - * - * We run it in a workqueue totally independent from the if_sdio_card - * instance for that reason. - */ - - pr_info("Resetting card..."); - mmc_remove_host(reset_host); - mmc_add_host(reset_host); -} -static DECLARE_WORK(card_reset_work, if_sdio_reset_card_worker); - -static void if_sdio_reset_card(struct lbs_private *priv) -{ - struct if_sdio_card *card = priv->card; - - if (work_pending(&card_reset_work)) - return; - - reset_host = card->func->card->host; - schedule_work(&card_reset_work); -} - /*******************************************************************/ /* SDIO callbacks */ /*******************************************************************/ @@ -1096,7 +1065,6 @@ static int if_sdio_probe(struct sdio_func *func, priv->enter_deep_sleep = if_sdio_enter_deep_sleep; priv->exit_deep_sleep = if_sdio_exit_deep_sleep; priv->reset_deep_sleep_wakeup = if_sdio_reset_deep_sleep_wakeup; - priv->reset_card = if_sdio_reset_card; sdio_claim_host(func); @@ -1333,8 +1301,6 @@ static void __exit if_sdio_exit_module(void) /* Set the flag as user is removing this module. */ user_rmmod = 1; - cancel_work_sync(&card_reset_work); - sdio_unregister_driver(&if_sdio_driver); lbs_deb_leave(LBS_DEB_SDIO); diff --git a/trunk/drivers/net/wireless/libertas/if_spi.c b/trunk/drivers/net/wireless/libertas/if_spi.c index e0286cfbc91d..4fa0be9943f9 100644 --- a/trunk/drivers/net/wireless/libertas/if_spi.c +++ b/trunk/drivers/net/wireless/libertas/if_spi.c @@ -1034,6 +1034,7 @@ static irqreturn_t if_spi_host_interrupt(int irq, void *dev_id) static int if_spi_init_card(struct if_spi_card *card) { struct lbs_private *priv = card->priv; + struct spi_device *spi = card->spi; int err, i; u32 scratch; const struct firmware *helper = NULL; @@ -1081,9 +1082,8 @@ static int if_spi_init_card(struct if_spi_card *card) "attached to SPI bus_num %d, chip_select %d. " "spi->max_speed_hz=%d\n", card->card_id, card->card_rev, - card->spi->master->bus_num, - card->spi->chip_select, - card->spi->max_speed_hz); + spi->master->bus_num, spi->chip_select, + spi->max_speed_hz); err = if_spi_prog_helper_firmware(card, helper); if (err) goto out; diff --git a/trunk/drivers/net/wireless/libertas_tf/main.c b/trunk/drivers/net/wireless/libertas_tf/main.c index acc461aa385e..5beb58142e97 100644 --- a/trunk/drivers/net/wireless/libertas_tf/main.c +++ b/trunk/drivers/net/wireless/libertas_tf/main.c @@ -586,7 +586,7 @@ int lbtf_rx(struct lbtf_private *priv, struct sk_buff *skb) need_padding ^= ieee80211_has_a4(hdr->frame_control); need_padding ^= ieee80211_is_data_qos(hdr->frame_control) && (*ieee80211_get_qos_ctl(hdr) & - IEEE80211_QOS_CTL_A_MSDU_PRESENT); + IEEE80211_QOS_CONTROL_A_MSDU_PRESENT); if (need_padding) { memmove(skb->data + 2, skb->data, skb->len); diff --git a/trunk/drivers/net/wireless/mac80211_hwsim.c b/trunk/drivers/net/wireless/mac80211_hwsim.c index 031cd89b1768..7e1fa9671277 100644 --- a/trunk/drivers/net/wireless/mac80211_hwsim.c +++ b/trunk/drivers/net/wireless/mac80211_hwsim.c @@ -1130,8 +1130,6 @@ static int mac80211_hwsim_hw_scan(struct ieee80211_hw *hw, for (i = 0; i < req->n_channels; i++) printk(KERN_DEBUG "hwsim hw_scan freq %d\n", req->channels[i]->center_freq); - print_hex_dump(KERN_DEBUG, "scan IEs: ", DUMP_PREFIX_OFFSET, - 16, 1, req->ie, req->ie_len, 1); ieee80211_queue_delayed_work(hw, &hsd->w, 2 * HZ); diff --git a/trunk/drivers/net/wireless/mwifiex/11n.c b/trunk/drivers/net/wireless/mwifiex/11n.c index 34bba5234294..916183d39009 100644 --- a/trunk/drivers/net/wireless/mwifiex/11n.c +++ b/trunk/drivers/net/wireless/mwifiex/11n.c @@ -185,12 +185,13 @@ int mwifiex_ret_11n_addba_req(struct mwifiex_private *priv, * * Handling includes changing the header fields into CPU format. */ -int mwifiex_ret_11n_cfg(struct host_cmd_ds_command *resp, - struct mwifiex_ds_11n_tx_cfg *tx_cfg) +int mwifiex_ret_11n_cfg(struct host_cmd_ds_command *resp, void *data_buf) { + struct mwifiex_ds_11n_tx_cfg *tx_cfg; struct host_cmd_ds_11n_cfg *htcfg = &resp->params.htcfg; - if (tx_cfg) { + if (data_buf) { + tx_cfg = (struct mwifiex_ds_11n_tx_cfg *) data_buf; tx_cfg->tx_htcap = le16_to_cpu(htcfg->ht_tx_cap); tx_cfg->tx_htinfo = le16_to_cpu(htcfg->ht_tx_info); } @@ -207,10 +208,11 @@ int mwifiex_ret_11n_cfg(struct host_cmd_ds_command *resp, */ int mwifiex_cmd_recfg_tx_buf(struct mwifiex_private *priv, struct host_cmd_ds_command *cmd, int cmd_action, - u16 *buf_size) + void *data_buf) { struct host_cmd_ds_txbuf_cfg *tx_buf = &cmd->params.tx_buf; u16 action = (u16) cmd_action; + u16 buf_size = *((u16 *) data_buf); cmd->command = cpu_to_le16(HostCmd_CMD_RECONFIGURE_TX_BUFF); cmd->size = @@ -218,8 +220,8 @@ int mwifiex_cmd_recfg_tx_buf(struct mwifiex_private *priv, tx_buf->action = cpu_to_le16(action); switch (action) { case HostCmd_ACT_GEN_SET: - dev_dbg(priv->adapter->dev, "cmd: set tx_buf=%d\n", *buf_size); - tx_buf->buff_size = cpu_to_le16(*buf_size); + dev_dbg(priv->adapter->dev, "cmd: set tx_buf=%d\n", buf_size); + tx_buf->buff_size = cpu_to_le16(buf_size); break; case HostCmd_ACT_GEN_GET: default: @@ -238,12 +240,13 @@ int mwifiex_cmd_recfg_tx_buf(struct mwifiex_private *priv, * - Ensuring correct endian-ness */ int mwifiex_cmd_amsdu_aggr_ctrl(struct host_cmd_ds_command *cmd, - int cmd_action, - struct mwifiex_ds_11n_amsdu_aggr_ctrl *aa_ctrl) + int cmd_action, void *data_buf) { struct host_cmd_ds_amsdu_aggr_ctrl *amsdu_ctrl = &cmd->params.amsdu_aggr_ctrl; u16 action = (u16) cmd_action; + struct mwifiex_ds_11n_amsdu_aggr_ctrl *aa_ctrl = + (struct mwifiex_ds_11n_amsdu_aggr_ctrl *) data_buf; cmd->command = cpu_to_le16(HostCmd_CMD_AMSDU_AGGR_CTRL); cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_amsdu_aggr_ctrl) @@ -269,13 +272,15 @@ int mwifiex_cmd_amsdu_aggr_ctrl(struct host_cmd_ds_command *cmd, * Handling includes changing the header fields into CPU format. */ int mwifiex_ret_amsdu_aggr_ctrl(struct host_cmd_ds_command *resp, - struct mwifiex_ds_11n_amsdu_aggr_ctrl - *amsdu_aggr_ctrl) + void *data_buf) { + struct mwifiex_ds_11n_amsdu_aggr_ctrl *amsdu_aggr_ctrl; struct host_cmd_ds_amsdu_aggr_ctrl *amsdu_ctrl = &resp->params.amsdu_aggr_ctrl; - if (amsdu_aggr_ctrl) { + if (data_buf) { + amsdu_aggr_ctrl = + (struct mwifiex_ds_11n_amsdu_aggr_ctrl *) data_buf; amsdu_aggr_ctrl->enable = le16_to_cpu(amsdu_ctrl->enable); amsdu_aggr_ctrl->curr_buf_size = le16_to_cpu(amsdu_ctrl->curr_buf_size); @@ -291,10 +296,12 @@ int mwifiex_ret_amsdu_aggr_ctrl(struct host_cmd_ds_command *resp, * - Setting HT Tx capability and HT Tx information fields * - Ensuring correct endian-ness */ -int mwifiex_cmd_11n_cfg(struct host_cmd_ds_command *cmd, u16 cmd_action, - struct mwifiex_ds_11n_tx_cfg *txcfg) +int mwifiex_cmd_11n_cfg(struct host_cmd_ds_command *cmd, + u16 cmd_action, void *data_buf) { struct host_cmd_ds_11n_cfg *htcfg = &cmd->params.htcfg; + struct mwifiex_ds_11n_tx_cfg *txcfg = + (struct mwifiex_ds_11n_tx_cfg *) data_buf; cmd->command = cpu_to_le16(HostCmd_CMD_11N_CFG); cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_11n_cfg) + S_DS_GEN); diff --git a/trunk/drivers/net/wireless/mwifiex/11n.h b/trunk/drivers/net/wireless/mwifiex/11n.h index 90b421e343d4..a4390a1a2a9f 100644 --- a/trunk/drivers/net/wireless/mwifiex/11n.h +++ b/trunk/drivers/net/wireless/mwifiex/11n.h @@ -29,9 +29,9 @@ int mwifiex_ret_11n_delba(struct mwifiex_private *priv, int mwifiex_ret_11n_addba_req(struct mwifiex_private *priv, struct host_cmd_ds_command *resp); int mwifiex_ret_11n_cfg(struct host_cmd_ds_command *resp, - struct mwifiex_ds_11n_tx_cfg *tx_cfg); -int mwifiex_cmd_11n_cfg(struct host_cmd_ds_command *cmd, u16 cmd_action, - struct mwifiex_ds_11n_tx_cfg *txcfg); + void *data_buf); +int mwifiex_cmd_11n_cfg(struct host_cmd_ds_command *cmd, + u16 cmd_action, void *data_buf); int mwifiex_cmd_append_11n_tlv(struct mwifiex_private *priv, struct mwifiex_bssdescriptor *bss_desc, @@ -62,14 +62,12 @@ int mwifiex_get_rx_reorder_tbl(struct mwifiex_private *priv, int mwifiex_get_tx_ba_stream_tbl(struct mwifiex_private *priv, struct mwifiex_ds_tx_ba_stream_tbl *buf); int mwifiex_ret_amsdu_aggr_ctrl(struct host_cmd_ds_command *resp, - struct mwifiex_ds_11n_amsdu_aggr_ctrl - *amsdu_aggr_ctrl); + void *data_buf); int mwifiex_cmd_recfg_tx_buf(struct mwifiex_private *priv, struct host_cmd_ds_command *cmd, - int cmd_action, u16 *buf_size); + int cmd_action, void *data_buf); int mwifiex_cmd_amsdu_aggr_ctrl(struct host_cmd_ds_command *cmd, - int cmd_action, - struct mwifiex_ds_11n_amsdu_aggr_ctrl *aa_ctrl); + int cmd_action, void *data_buf); /* * This function checks whether AMPDU is allowed or not for a particular TID. diff --git a/trunk/drivers/net/wireless/mwifiex/11n_rxreorder.c b/trunk/drivers/net/wireless/mwifiex/11n_rxreorder.c index 7aa9aa0ac958..e5dfdc39a921 100644 --- a/trunk/drivers/net/wireless/mwifiex/11n_rxreorder.c +++ b/trunk/drivers/net/wireless/mwifiex/11n_rxreorder.c @@ -328,12 +328,13 @@ int mwifiex_cmd_11n_addba_req(struct host_cmd_ds_command *cmd, void *data_buf) */ int mwifiex_cmd_11n_addba_rsp_gen(struct mwifiex_private *priv, struct host_cmd_ds_command *cmd, - struct host_cmd_ds_11n_addba_req - *cmd_addba_req) + void *data_buf) { struct host_cmd_ds_11n_addba_rsp *add_ba_rsp = (struct host_cmd_ds_11n_addba_rsp *) &cmd->params.add_ba_rsp; + struct host_cmd_ds_11n_addba_req *cmd_addba_req = + (struct host_cmd_ds_11n_addba_req *) data_buf; u8 tid; int win_size; uint16_t block_ack_param_set; diff --git a/trunk/drivers/net/wireless/mwifiex/11n_rxreorder.h b/trunk/drivers/net/wireless/mwifiex/11n_rxreorder.h index 033c8adbdcd4..f3ca8c8c18f9 100644 --- a/trunk/drivers/net/wireless/mwifiex/11n_rxreorder.h +++ b/trunk/drivers/net/wireless/mwifiex/11n_rxreorder.h @@ -52,9 +52,8 @@ int mwifiex_ret_11n_addba_resp(struct mwifiex_private *priv, int mwifiex_cmd_11n_delba(struct host_cmd_ds_command *cmd, void *data_buf); int mwifiex_cmd_11n_addba_rsp_gen(struct mwifiex_private *priv, - struct host_cmd_ds_command *cmd, - struct host_cmd_ds_11n_addba_req - *cmd_addba_req); + struct host_cmd_ds_command + *cmd, void *data_buf); int mwifiex_cmd_11n_addba_req(struct host_cmd_ds_command *cmd, void *data_buf); void mwifiex_11n_cleanup_reorder_tbl(struct mwifiex_private *priv); diff --git a/trunk/drivers/net/wireless/mwifiex/cmdevt.c b/trunk/drivers/net/wireless/mwifiex/cmdevt.c index b5352afb8714..cd89fed206ae 100644 --- a/trunk/drivers/net/wireless/mwifiex/cmdevt.c +++ b/trunk/drivers/net/wireless/mwifiex/cmdevt.c @@ -104,11 +104,13 @@ mwifiex_clean_cmd_node(struct mwifiex_adapter *adapter, * main thread. */ static int mwifiex_cmd_host_cmd(struct mwifiex_private *priv, - struct host_cmd_ds_command *cmd, - struct mwifiex_ds_misc_cmd *pcmd_ptr) + struct host_cmd_ds_command *cmd, void *data_buf) { + struct mwifiex_ds_misc_cmd *pcmd_ptr = + (struct mwifiex_ds_misc_cmd *) data_buf; + /* Copy the HOST command to command buffer */ - memcpy(cmd, pcmd_ptr->cmd, pcmd_ptr->len); + memcpy((void *) cmd, pcmd_ptr->cmd, pcmd_ptr->len); dev_dbg(priv->adapter->dev, "cmd: host cmd size = %d\n", pcmd_ptr->len); return 0; } @@ -705,14 +707,15 @@ int mwifiex_process_cmdresp(struct mwifiex_adapter *adapter) if (adapter->curr_cmd->cmd_flag & CMD_F_HOSTCMD) { /* Copy original response back to response buffer */ - struct mwifiex_ds_misc_cmd *hostcmd; + struct mwifiex_ds_misc_cmd *hostcmd = NULL; uint16_t size = le16_to_cpu(resp->size); dev_dbg(adapter->dev, "info: host cmd resp size = %d\n", size); size = min_t(u16, size, MWIFIEX_SIZE_OF_CMD_BUFFER); if (adapter->curr_cmd->data_buf) { - hostcmd = adapter->curr_cmd->data_buf; + hostcmd = (struct mwifiex_ds_misc_cmd *) + adapter->curr_cmd->data_buf; hostcmd->len = size; - memcpy(hostcmd->cmd, resp, size); + memcpy(hostcmd->cmd, (void *) resp, size); } } orig_cmdresp_no = le16_to_cpu(resp->command); @@ -1152,7 +1155,7 @@ EXPORT_SYMBOL_GPL(mwifiex_process_sleep_confirm_resp); int mwifiex_cmd_enh_power_mode(struct mwifiex_private *priv, struct host_cmd_ds_command *cmd, u16 cmd_action, uint16_t ps_bitmap, - struct mwifiex_ds_auto_ds *auto_ds) + void *data_buf) { struct host_cmd_ds_802_11_ps_mode_enh *psmode_enh = &cmd->params.psmode_enh; @@ -1215,8 +1218,9 @@ int mwifiex_cmd_enh_power_mode(struct mwifiex_private *priv, sizeof(struct mwifiex_ie_types_header)); cmd_size += sizeof(*auto_ds_tlv); tlv += sizeof(*auto_ds_tlv); - if (auto_ds) - idletime = auto_ds->idle_time; + if (data_buf) + idletime = ((struct mwifiex_ds_auto_ds *) + data_buf)->idle_time; dev_dbg(priv->adapter->dev, "cmd: PS Command: Enter Auto Deep Sleep\n"); auto_ds_tlv->deep_sleep_timeout = cpu_to_le16(idletime); @@ -1235,7 +1239,7 @@ int mwifiex_cmd_enh_power_mode(struct mwifiex_private *priv, */ int mwifiex_ret_enh_power_mode(struct mwifiex_private *priv, struct host_cmd_ds_command *resp, - struct mwifiex_ds_pm_cfg *pm_cfg) + void *data_buf) { struct mwifiex_adapter *adapter = priv->adapter; struct host_cmd_ds_802_11_ps_mode_enh *ps_mode = @@ -1278,8 +1282,10 @@ int mwifiex_ret_enh_power_mode(struct mwifiex_private *priv, dev_dbg(adapter->dev, "cmd: ps_bitmap=%#x\n", ps_bitmap); - if (pm_cfg) { + if (data_buf) { /* This section is for get power save mode */ + struct mwifiex_ds_pm_cfg *pm_cfg = + (struct mwifiex_ds_pm_cfg *)data_buf; if (ps_bitmap & BITMAP_STA_PS) pm_cfg->param.ps_mode = 1; else diff --git a/trunk/drivers/net/wireless/mwifiex/join.c b/trunk/drivers/net/wireless/mwifiex/join.c index 644e2e405cb5..5eab3dc29b1c 100644 --- a/trunk/drivers/net/wireless/mwifiex/join.c +++ b/trunk/drivers/net/wireless/mwifiex/join.c @@ -364,9 +364,10 @@ static int mwifiex_append_rsn_ie_wpa_wpa2(struct mwifiex_private *priv, */ int mwifiex_cmd_802_11_associate(struct mwifiex_private *priv, struct host_cmd_ds_command *cmd, - struct mwifiex_bssdescriptor *bss_desc) + void *data_buf) { struct host_cmd_ds_802_11_associate *assoc = &cmd->params.associate; + struct mwifiex_bssdescriptor *bss_desc; struct mwifiex_ie_types_ssid_param_set *ssid_tlv; struct mwifiex_ie_types_phy_param_set *phy_tlv; struct mwifiex_ie_types_ss_param_set *ss_tlv; @@ -379,6 +380,7 @@ int mwifiex_cmd_802_11_associate(struct mwifiex_private *priv, u8 *pos; int rsn_ie_len = 0; + bss_desc = (struct mwifiex_bssdescriptor *) data_buf; pos = (u8 *) assoc; mwifiex_cfg_tx_buf(priv, bss_desc); @@ -746,8 +748,7 @@ int mwifiex_ret_802_11_associate(struct mwifiex_private *priv, */ int mwifiex_cmd_802_11_ad_hoc_start(struct mwifiex_private *priv, - struct host_cmd_ds_command *cmd, - struct mwifiex_802_11_ssid *req_ssid) + struct host_cmd_ds_command *cmd, void *data_buf) { int rsn_ie_len = 0; struct mwifiex_adapter *adapter = priv->adapter; @@ -785,15 +786,20 @@ mwifiex_cmd_802_11_ad_hoc_start(struct mwifiex_private *priv, memset(adhoc_start->ssid, 0, IEEE80211_MAX_SSID_LEN); - memcpy(adhoc_start->ssid, req_ssid->ssid, req_ssid->ssid_len); + memcpy(adhoc_start->ssid, + ((struct mwifiex_802_11_ssid *) data_buf)->ssid, + ((struct mwifiex_802_11_ssid *) data_buf)->ssid_len); dev_dbg(adapter->dev, "info: ADHOC_S_CMD: SSID = %s\n", adhoc_start->ssid); memset(bss_desc->ssid.ssid, 0, IEEE80211_MAX_SSID_LEN); - memcpy(bss_desc->ssid.ssid, req_ssid->ssid, req_ssid->ssid_len); + memcpy(bss_desc->ssid.ssid, + ((struct mwifiex_802_11_ssid *) data_buf)->ssid, + ((struct mwifiex_802_11_ssid *) data_buf)->ssid_len); - bss_desc->ssid.ssid_len = req_ssid->ssid_len; + bss_desc->ssid.ssid_len = + ((struct mwifiex_802_11_ssid *) data_buf)->ssid_len; /* Set the BSS mode */ adhoc_start->bss_mode = HostCmd_BSS_MODE_IBSS; @@ -1030,12 +1036,13 @@ mwifiex_cmd_802_11_ad_hoc_start(struct mwifiex_private *priv, */ int mwifiex_cmd_802_11_ad_hoc_join(struct mwifiex_private *priv, - struct host_cmd_ds_command *cmd, - struct mwifiex_bssdescriptor *bss_desc) + struct host_cmd_ds_command *cmd, void *data_buf) { int rsn_ie_len = 0; struct host_cmd_ds_802_11_ad_hoc_join *adhoc_join = &cmd->params.adhoc_join; + struct mwifiex_bssdescriptor *bss_desc = + (struct mwifiex_bssdescriptor *) data_buf; struct mwifiex_ie_types_chan_list_param_set *chan_tlv; u32 cmd_append_size = 0; u16 tmp_cap; diff --git a/trunk/drivers/net/wireless/mwifiex/main.c b/trunk/drivers/net/wireless/mwifiex/main.c index e5fc53dc6887..4f43443036f4 100644 --- a/trunk/drivers/net/wireless/mwifiex/main.c +++ b/trunk/drivers/net/wireless/mwifiex/main.c @@ -26,6 +26,9 @@ const char driver_version[] = "mwifiex " VERSION " (%s) "; +struct mwifiex_adapter *g_adapter; +EXPORT_SYMBOL_GPL(g_adapter); + static struct mwifiex_bss_attr mwifiex_bss_sta[] = { {MWIFIEX_BSS_TYPE_STA, MWIFIEX_DATA_FRAME_TYPE_ETH_II, true, 0, 0}, }; @@ -57,8 +60,7 @@ static struct mwifiex_drv_mode mwifiex_drv_mode_tbl[] = { * proper cleanup before exiting. */ static int mwifiex_register(void *card, struct mwifiex_if_ops *if_ops, - struct mwifiex_drv_mode *drv_mode_ptr, - void **padapter) + struct mwifiex_drv_mode *drv_mode_ptr) { struct mwifiex_adapter *adapter; int i; @@ -67,7 +69,7 @@ static int mwifiex_register(void *card, struct mwifiex_if_ops *if_ops, if (!adapter) return -ENOMEM; - *padapter = adapter; + g_adapter = adapter; adapter->card = card; /* Save interface specific operations in adapter */ @@ -322,7 +324,7 @@ int mwifiex_main_process(struct mwifiex_adapter *adapter) * and initializing the private structures. */ static int -mwifiex_init_sw(void *card, struct mwifiex_if_ops *if_ops, void **padapter) +mwifiex_init_sw(void *card, struct mwifiex_if_ops *if_ops) { int i; struct mwifiex_drv_mode *drv_mode_ptr; @@ -341,7 +343,7 @@ mwifiex_init_sw(void *card, struct mwifiex_if_ops *if_ops, void **padapter) return -1; } - if (mwifiex_register(card, if_ops, drv_mode_ptr, padapter)) + if (mwifiex_register(card, if_ops, drv_mode_ptr)) return -1; return 0; @@ -553,7 +555,7 @@ static int mwifiex_set_mac_address(struct net_device *dev, void *addr) { struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev); - struct sockaddr *hw_addr = addr; + struct sockaddr *hw_addr = (struct sockaddr *) addr; int ret; memcpy(priv->curr_addr, hw_addr->sa_data, ETH_ALEN); @@ -853,11 +855,13 @@ mwifiex_add_card(void *card, struct semaphore *sem, if (down_interruptible(sem)) goto exit_sem_err; - if (mwifiex_init_sw(card, if_ops, (void **)&adapter)) { + if (mwifiex_init_sw(card, if_ops)) { pr_err("%s: software init failed\n", __func__); goto err_init_sw; } + adapter = g_adapter; + adapter->hw_status = MWIFIEX_HW_STATUS_INITIALIZING; adapter->surprise_removed = false; init_waitqueue_head(&adapter->init_wait_q); diff --git a/trunk/drivers/net/wireless/mwifiex/main.h b/trunk/drivers/net/wireless/mwifiex/main.h index 03691c02a6e8..57b183af72d7 100644 --- a/trunk/drivers/net/wireless/mwifiex/main.h +++ b/trunk/drivers/net/wireless/mwifiex/main.h @@ -39,6 +39,7 @@ #include "fw.h" extern const char driver_version[]; +extern struct mwifiex_adapter *g_adapter; enum { MWIFIEX_ASYNC_CMD, @@ -736,10 +737,10 @@ void mwifiex_process_sleep_confirm_resp(struct mwifiex_adapter *, u8 *, int mwifiex_cmd_enh_power_mode(struct mwifiex_private *priv, struct host_cmd_ds_command *cmd, u16 cmd_action, uint16_t ps_bitmap, - struct mwifiex_ds_auto_ds *auto_ds); + void *data_buf); int mwifiex_ret_enh_power_mode(struct mwifiex_private *priv, struct host_cmd_ds_command *resp, - struct mwifiex_ds_pm_cfg *pm_cfg); + void *data_buf); void mwifiex_process_hs_config(struct mwifiex_adapter *adapter); void mwifiex_hs_activated_event(struct mwifiex_private *priv, u8 activated); @@ -751,7 +752,7 @@ int mwifiex_sta_prepare_cmd(struct mwifiex_private *, uint16_t cmd_no, u16 cmd_action, u32 cmd_oid, void *data_buf, void *cmd_buf); int mwifiex_process_sta_cmdresp(struct mwifiex_private *, u16 cmdresp_no, - struct host_cmd_ds_command *resp); + void *cmd_buf); int mwifiex_process_sta_rx_packet(struct mwifiex_adapter *, struct sk_buff *skb); int mwifiex_process_sta_event(struct mwifiex_private *); @@ -760,7 +761,7 @@ int mwifiex_sta_init_cmd(struct mwifiex_private *, u8 first_sta); int mwifiex_scan_networks(struct mwifiex_private *priv, const struct mwifiex_user_scan_cfg *user_scan_in); int mwifiex_cmd_802_11_scan(struct host_cmd_ds_command *cmd, - struct mwifiex_scan_cmd_config *scan_cfg); + void *data_buf); void mwifiex_queue_scan_cmd(struct mwifiex_private *priv, struct cmd_ctrl_node *cmd_node); int mwifiex_ret_802_11_scan(struct mwifiex_private *priv, @@ -777,8 +778,8 @@ s32 mwifiex_ssid_cmp(struct mwifiex_802_11_ssid *ssid1, int mwifiex_associate(struct mwifiex_private *priv, struct mwifiex_bssdescriptor *bss_desc); int mwifiex_cmd_802_11_associate(struct mwifiex_private *priv, - struct host_cmd_ds_command *cmd, - struct mwifiex_bssdescriptor *bss_desc); + struct host_cmd_ds_command + *cmd, void *data_buf); int mwifiex_ret_802_11_associate(struct mwifiex_private *priv, struct host_cmd_ds_command *resp); void mwifiex_reset_connect_state(struct mwifiex_private *priv); @@ -791,10 +792,10 @@ int mwifiex_adhoc_join(struct mwifiex_private *priv, struct mwifiex_bssdescriptor *bss_desc); int mwifiex_cmd_802_11_ad_hoc_start(struct mwifiex_private *priv, struct host_cmd_ds_command *cmd, - struct mwifiex_802_11_ssid *req_ssid); + void *data_buf); int mwifiex_cmd_802_11_ad_hoc_join(struct mwifiex_private *priv, struct host_cmd_ds_command *cmd, - struct mwifiex_bssdescriptor *bss_desc); + void *data_buf); int mwifiex_ret_802_11_ad_hoc(struct mwifiex_private *priv, struct host_cmd_ds_command *resp); int mwifiex_cmd_802_11_bg_scan_query(struct host_cmd_ds_command *cmd); diff --git a/trunk/drivers/net/wireless/mwifiex/scan.c b/trunk/drivers/net/wireless/mwifiex/scan.c index 6f88c8ab5de5..5c22860fb40a 100644 --- a/trunk/drivers/net/wireless/mwifiex/scan.c +++ b/trunk/drivers/net/wireless/mwifiex/scan.c @@ -2357,10 +2357,12 @@ int mwifiex_scan_networks(struct mwifiex_private *priv, * - Setting command ID, and proper size * - Ensuring correct endian-ness */ -int mwifiex_cmd_802_11_scan(struct host_cmd_ds_command *cmd, - struct mwifiex_scan_cmd_config *scan_cfg) +int mwifiex_cmd_802_11_scan(struct host_cmd_ds_command *cmd, void *data_buf) { struct host_cmd_ds_802_11_scan *scan_cmd = &cmd->params.scan; + struct mwifiex_scan_cmd_config *scan_cfg; + + scan_cfg = (struct mwifiex_scan_cmd_config *) data_buf; /* Set fixed field variables in scan command */ scan_cmd->bss_mode = scan_cfg->bss_mode; diff --git a/trunk/drivers/net/wireless/mwifiex/sdio.c b/trunk/drivers/net/wireless/mwifiex/sdio.c index 711fa689a95c..4327b6d099c8 100644 --- a/trunk/drivers/net/wireless/mwifiex/sdio.c +++ b/trunk/drivers/net/wireless/mwifiex/sdio.c @@ -31,27 +31,10 @@ #define SDIO_VERSION "1.0" -/* The mwifiex_sdio_remove() callback function is called when - * user removes this module from kernel space or ejects - * the card from the slot. The driver handles these 2 cases - * differently. - * If the user is removing the module, the few commands (FUNC_SHUTDOWN, - * HS_CANCEL etc.) are sent to the firmware. - * If the card is removed, there is no need to send these command. - * - * The variable 'user_rmmod' is used to distinguish these two - * scenarios. This flag is initialized as FALSE in case the card - * is removed, and will be set to TRUE for module removal when - * module_exit function is called. - */ -static u8 user_rmmod; - static struct mwifiex_if_ops sdio_ops; static struct semaphore add_remove_card_sem; -static int mwifiex_sdio_resume(struct device *dev); - /* * SDIO probe. * @@ -110,36 +93,17 @@ static void mwifiex_sdio_remove(struct sdio_func *func) { struct sdio_mmc_card *card; - struct mwifiex_adapter *adapter; - int i; pr_debug("info: SDIO func num=%d\n", func->num); - card = sdio_get_drvdata(func); - if (!card) - return; - - adapter = card->adapter; - if (!adapter || !adapter->priv_num) - return; - - if (user_rmmod) { - if (adapter->is_suspended) - mwifiex_sdio_resume(adapter->dev); - - for (i = 0; i < adapter->priv_num; i++) - if ((GET_BSS_ROLE(adapter->priv[i]) == - MWIFIEX_BSS_ROLE_STA) && - adapter->priv[i]->media_connected) - mwifiex_deauthenticate(adapter->priv[i], NULL); - - mwifiex_init_shutdown_fw(mwifiex_get_priv(adapter, - MWIFIEX_BSS_ROLE_ANY), - MWIFIEX_FUNC_SHUTDOWN); + if (func) { + card = sdio_get_drvdata(func); + if (card) { + mwifiex_remove_card(card->adapter, + &add_remove_card_sem); + kfree(card); + } } - - mwifiex_remove_card(card->adapter, &add_remove_card_sem); - kfree(card); } /* @@ -1732,9 +1696,6 @@ mwifiex_sdio_init_module(void) { sema_init(&add_remove_card_sem, 1); - /* Clear the flag in case user removes the card. */ - user_rmmod = 0; - return sdio_register_driver(&mwifiex_sdio); } @@ -1750,12 +1711,32 @@ mwifiex_sdio_init_module(void) static void mwifiex_sdio_cleanup_module(void) { - if (!down_interruptible(&add_remove_card_sem)) - up(&add_remove_card_sem); + struct mwifiex_adapter *adapter = g_adapter; + int i; + + if (down_interruptible(&add_remove_card_sem)) + goto exit_sem_err; + + if (!adapter || !adapter->priv_num) + goto exit; + + if (adapter->is_suspended) + mwifiex_sdio_resume(adapter->dev); + + for (i = 0; i < adapter->priv_num; i++) + if ((GET_BSS_ROLE(adapter->priv[i]) == MWIFIEX_BSS_ROLE_STA) && + adapter->priv[i]->media_connected) + mwifiex_deauthenticate(adapter->priv[i], NULL); + + if (!adapter->surprise_removed) + mwifiex_init_shutdown_fw(mwifiex_get_priv(adapter, + MWIFIEX_BSS_ROLE_ANY), + MWIFIEX_FUNC_SHUTDOWN); - /* Set the flag as user is removing this module. */ - user_rmmod = 1; +exit: + up(&add_remove_card_sem); +exit_sem_err: sdio_unregister_driver(&mwifiex_sdio); } diff --git a/trunk/drivers/net/wireless/mwifiex/sdio.h b/trunk/drivers/net/wireless/mwifiex/sdio.h index 524f78f4ee69..c925376fcaae 100644 --- a/trunk/drivers/net/wireless/mwifiex/sdio.h +++ b/trunk/drivers/net/wireless/mwifiex/sdio.h @@ -54,10 +54,10 @@ #define SDIO_MP_AGGR_DEF_PKT_LIMIT 8 -#define SDIO_MP_TX_AGGR_DEF_BUF_SIZE (8192) /* 8K */ +#define SDIO_MP_TX_AGGR_DEF_BUF_SIZE (4096) /* 4K */ /* Multi port RX aggregation buffer size */ -#define SDIO_MP_RX_AGGR_DEF_BUF_SIZE (16384) /* 16K */ +#define SDIO_MP_RX_AGGR_DEF_BUF_SIZE (4096) /* 4K */ /* Misc. Config Register : Auto Re-enable interrupts */ #define AUTO_RE_ENABLE_INT BIT(4) diff --git a/trunk/drivers/net/wireless/mwifiex/sta_cmd.c b/trunk/drivers/net/wireless/mwifiex/sta_cmd.c index 49b9c1309f7a..8af3a78d2723 100644 --- a/trunk/drivers/net/wireless/mwifiex/sta_cmd.c +++ b/trunk/drivers/net/wireless/mwifiex/sta_cmd.c @@ -67,9 +67,10 @@ mwifiex_cmd_802_11_rssi_info(struct mwifiex_private *priv, */ static int mwifiex_cmd_mac_control(struct mwifiex_private *priv, struct host_cmd_ds_command *cmd, - u16 cmd_action, u16 *action) + u16 cmd_action, void *data_buf) { struct host_cmd_ds_mac_control *mac_ctrl = &cmd->params.mac_ctrl; + u16 action = *((u16 *) data_buf); if (cmd_action != HostCmd_ACT_GEN_SET) { dev_err(priv->adapter->dev, @@ -80,7 +81,7 @@ static int mwifiex_cmd_mac_control(struct mwifiex_private *priv, cmd->command = cpu_to_le16(HostCmd_CMD_MAC_CONTROL); cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_mac_control) + S_DS_GEN); - mac_ctrl->action = cpu_to_le16(*action); + mac_ctrl->action = cpu_to_le16(action); return 0; } @@ -103,9 +104,10 @@ static int mwifiex_cmd_mac_control(struct mwifiex_private *priv, static int mwifiex_cmd_802_11_snmp_mib(struct mwifiex_private *priv, struct host_cmd_ds_command *cmd, u16 cmd_action, u32 cmd_oid, - u32 *ul_temp) + void *data_buf) { struct host_cmd_ds_802_11_snmp_mib *snmp_mib = &cmd->params.smib; + u32 ul_temp; dev_dbg(priv->adapter->dev, "cmd: SNMP_CMD: cmd_oid = 0x%x\n", cmd_oid); cmd->command = cpu_to_le16(HostCmd_CMD_802_11_SNMP_MIB); @@ -125,8 +127,9 @@ static int mwifiex_cmd_802_11_snmp_mib(struct mwifiex_private *priv, if (cmd_action == HostCmd_ACT_GEN_SET) { snmp_mib->query_type = cpu_to_le16(HostCmd_ACT_GEN_SET); snmp_mib->buf_size = cpu_to_le16(sizeof(u16)); + ul_temp = *((u32 *) data_buf); *((__le16 *) (snmp_mib->value)) = - cpu_to_le16((u16) *ul_temp); + cpu_to_le16((u16) ul_temp); cmd->size = cpu_to_le16(le16_to_cpu(cmd->size) + sizeof(u16)); } @@ -136,8 +139,9 @@ static int mwifiex_cmd_802_11_snmp_mib(struct mwifiex_private *priv, if (cmd_action == HostCmd_ACT_GEN_SET) { snmp_mib->query_type = cpu_to_le16(HostCmd_ACT_GEN_SET); snmp_mib->buf_size = cpu_to_le16(sizeof(u16)); + ul_temp = *((u32 *) data_buf); *(__le16 *) (snmp_mib->value) = - cpu_to_le16((u16) *ul_temp); + cpu_to_le16((u16) ul_temp); cmd->size = cpu_to_le16(le16_to_cpu(cmd->size) + sizeof(u16)); } @@ -148,8 +152,9 @@ static int mwifiex_cmd_802_11_snmp_mib(struct mwifiex_private *priv, if (cmd_action == HostCmd_ACT_GEN_SET) { snmp_mib->query_type = cpu_to_le16(HostCmd_ACT_GEN_SET); snmp_mib->buf_size = cpu_to_le16(sizeof(u16)); + ul_temp = (*(u32 *) data_buf); *((__le16 *) (snmp_mib->value)) = - cpu_to_le16((u16) *ul_temp); + cpu_to_le16((u16) ul_temp); cmd->size = cpu_to_le16(le16_to_cpu(cmd->size) + sizeof(u16)); } @@ -159,8 +164,9 @@ static int mwifiex_cmd_802_11_snmp_mib(struct mwifiex_private *priv, if (cmd_action == HostCmd_ACT_GEN_SET) { snmp_mib->query_type = cpu_to_le16(HostCmd_ACT_GEN_SET); snmp_mib->buf_size = cpu_to_le16(sizeof(u16)); + ul_temp = *(u32 *) data_buf; *((__le16 *) (snmp_mib->value)) = - cpu_to_le16((u16) *ul_temp); + cpu_to_le16((u16) ul_temp); cmd->size = cpu_to_le16(le16_to_cpu(cmd->size) + sizeof(u16)); } @@ -203,11 +209,13 @@ mwifiex_cmd_802_11_get_log(struct host_cmd_ds_command *cmd) */ static int mwifiex_cmd_tx_rate_cfg(struct mwifiex_private *priv, struct host_cmd_ds_command *cmd, - u16 cmd_action, u16 *pbitmap_rates) + u16 cmd_action, void *data_buf) { struct host_cmd_ds_tx_rate_cfg *rate_cfg = &cmd->params.tx_rate_cfg; struct mwifiex_rate_scope *rate_scope; struct mwifiex_rate_drop_pattern *rate_drop; + u16 *pbitmap_rates = (u16 *) data_buf; + u32 i; cmd->command = cpu_to_le16(HostCmd_CMD_TX_RATE_CFG); @@ -264,10 +272,10 @@ static int mwifiex_cmd_tx_rate_cfg(struct mwifiex_private *priv, * - Ensuring correct endian-ness */ static int mwifiex_cmd_tx_power_cfg(struct host_cmd_ds_command *cmd, - u16 cmd_action, - struct host_cmd_ds_txpwr_cfg *txp) + u16 cmd_action, void *data_buf) { struct mwifiex_types_power_group *pg_tlv; + struct host_cmd_ds_txpwr_cfg *txp; struct host_cmd_ds_txpwr_cfg *cmd_txp_cfg = &cmd->params.txp_cfg; cmd->command = cpu_to_le16(HostCmd_CMD_TXPWR_CFG); @@ -275,11 +283,12 @@ static int mwifiex_cmd_tx_power_cfg(struct host_cmd_ds_command *cmd, cpu_to_le16(S_DS_GEN + sizeof(struct host_cmd_ds_txpwr_cfg)); switch (cmd_action) { case HostCmd_ACT_GEN_SET: + txp = (struct host_cmd_ds_txpwr_cfg *) data_buf; if (txp->mode) { pg_tlv = (struct mwifiex_types_power_group - *) ((unsigned long) txp + + *) ((unsigned long) data_buf + sizeof(struct host_cmd_ds_txpwr_cfg)); - memmove(cmd_txp_cfg, txp, + memmove(cmd_txp_cfg, data_buf, sizeof(struct host_cmd_ds_txpwr_cfg) + sizeof(struct mwifiex_types_power_group) + pg_tlv->length); @@ -291,7 +300,8 @@ static int mwifiex_cmd_tx_power_cfg(struct host_cmd_ds_command *cmd, sizeof(struct mwifiex_types_power_group) + pg_tlv->length); } else { - memmove(cmd_txp_cfg, txp, sizeof(*txp)); + memmove(cmd_txp_cfg, data_buf, + sizeof(struct host_cmd_ds_txpwr_cfg)); } cmd_txp_cfg->action = cpu_to_le16(cmd_action); break; @@ -312,23 +322,22 @@ static int mwifiex_cmd_tx_power_cfg(struct host_cmd_ds_command *cmd, * (as required) * - Ensuring correct endian-ness */ -static int -mwifiex_cmd_802_11_hs_cfg(struct mwifiex_private *priv, - struct host_cmd_ds_command *cmd, - u16 cmd_action, - struct mwifiex_hs_config_param *hscfg_param) +static int mwifiex_cmd_802_11_hs_cfg(struct mwifiex_private *priv, + struct host_cmd_ds_command *cmd, + u16 cmd_action, + struct mwifiex_hs_config_param *data_buf) { struct mwifiex_adapter *adapter = priv->adapter; struct host_cmd_ds_802_11_hs_cfg_enh *hs_cfg = &cmd->params.opt_hs_cfg; u16 hs_activate = false; - if (!hscfg_param) + if (data_buf == NULL) /* New Activate command */ hs_activate = true; cmd->command = cpu_to_le16(HostCmd_CMD_802_11_HS_CFG_ENH); if (!hs_activate && - (hscfg_param->conditions + (data_buf->conditions != cpu_to_le32(HOST_SLEEP_CFG_CANCEL)) && ((adapter->arp_filter_size > 0) && (adapter->arp_filter_size <= ARP_FILTER_MAX_BUF_SIZE))) { @@ -350,9 +359,9 @@ mwifiex_cmd_802_11_hs_cfg(struct mwifiex_private *priv, hs_cfg->params.hs_activate.resp_ctrl = RESP_NEEDED; } else { hs_cfg->action = cpu_to_le16(HS_CONFIGURE); - hs_cfg->params.hs_config.conditions = hscfg_param->conditions; - hs_cfg->params.hs_config.gpio = hscfg_param->gpio; - hs_cfg->params.hs_config.gap = hscfg_param->gap; + hs_cfg->params.hs_config.conditions = data_buf->conditions; + hs_cfg->params.hs_config.gpio = data_buf->gpio; + hs_cfg->params.hs_config.gap = data_buf->gap; dev_dbg(adapter->dev, "cmd: HS_CFG_CMD: condition:0x%x gpio:0x%x gap:0x%x\n", hs_cfg->params.hs_config.conditions, @@ -396,11 +405,11 @@ static int mwifiex_cmd_802_11_mac_address(struct mwifiex_private *priv, * - Setting MAC multicast address * - Ensuring correct endian-ness */ -static int -mwifiex_cmd_mac_multicast_adr(struct host_cmd_ds_command *cmd, - u16 cmd_action, - struct mwifiex_multicast_list *mcast_list) +static int mwifiex_cmd_mac_multicast_adr(struct host_cmd_ds_command *cmd, + u16 cmd_action, void *data_buf) { + struct mwifiex_multicast_list *mcast_list = + (struct mwifiex_multicast_list *) data_buf; struct host_cmd_ds_mac_multicast_adr *mcast_addr = &cmd->params.mc_addr; cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_mac_multicast_adr) + @@ -426,7 +435,7 @@ mwifiex_cmd_mac_multicast_adr(struct host_cmd_ds_command *cmd, */ static int mwifiex_cmd_802_11_deauthenticate(struct mwifiex_private *priv, struct host_cmd_ds_command *cmd, - u8 *mac) + void *data_buf) { struct host_cmd_ds_802_11_deauthenticate *deauth = &cmd->params.deauth; @@ -435,7 +444,7 @@ static int mwifiex_cmd_802_11_deauthenticate(struct mwifiex_private *priv, + S_DS_GEN); /* Set AP MAC address */ - memcpy(deauth->mac_addr, mac, ETH_ALEN); + memcpy(deauth->mac_addr, (u8 *) data_buf, ETH_ALEN); dev_dbg(priv->adapter->dev, "cmd: Deauth: %pM\n", deauth->mac_addr); @@ -534,14 +543,15 @@ mwifiex_set_keyparamset_wep(struct mwifiex_private *priv, * encryption (TKIP, AES) (as required) * - Ensuring correct endian-ness */ -static int -mwifiex_cmd_802_11_key_material(struct mwifiex_private *priv, - struct host_cmd_ds_command *cmd, - u16 cmd_action, u32 cmd_oid, - struct mwifiex_ds_encrypt_key *enc_key) +static int mwifiex_cmd_802_11_key_material(struct mwifiex_private *priv, + struct host_cmd_ds_command *cmd, + u16 cmd_action, + u32 cmd_oid, void *data_buf) { struct host_cmd_ds_802_11_key_material *key_material = &cmd->params.key_material; + struct mwifiex_ds_encrypt_key *enc_key = + (struct mwifiex_ds_encrypt_key *) data_buf; u16 key_param_len = 0; int ret = 0; const u8 bc_mac[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; @@ -731,7 +741,7 @@ static int mwifiex_cmd_802_11d_domain_info(struct mwifiex_private *priv, */ static int mwifiex_cmd_802_11_rf_channel(struct mwifiex_private *priv, struct host_cmd_ds_command *cmd, - u16 cmd_action, u16 *channel) + u16 cmd_action, void *data_buf) { struct host_cmd_ds_802_11_rf_channel *rf_chan = &cmd->params.rf_channel; @@ -749,7 +759,7 @@ static int mwifiex_cmd_802_11_rf_channel(struct mwifiex_private *priv, rf_type = le16_to_cpu(rf_chan->rf_type); SET_SECONDARYCHAN(rf_type, priv->adapter->chan_offset); - rf_chan->current_channel = cpu_to_le16(*channel); + rf_chan->current_channel = cpu_to_le16(*((u16 *) data_buf)); } rf_chan->action = cpu_to_le16(cmd_action); return 0; @@ -764,10 +774,11 @@ static int mwifiex_cmd_802_11_rf_channel(struct mwifiex_private *priv, * - Ensuring correct endian-ness */ static int mwifiex_cmd_ibss_coalescing_status(struct host_cmd_ds_command *cmd, - u16 cmd_action, u16 *enable) + u16 cmd_action, void *data_buf) { struct host_cmd_ds_802_11_ibss_status *ibss_coal = &(cmd->params.ibss_coalescing); + u16 enable = 0; cmd->command = cpu_to_le16(HostCmd_CMD_802_11_IBSS_COALESCING_STATUS); cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_802_11_ibss_status) + @@ -777,10 +788,9 @@ static int mwifiex_cmd_ibss_coalescing_status(struct host_cmd_ds_command *cmd, switch (cmd_action) { case HostCmd_ACT_GEN_SET: - if (enable) - ibss_coal->enable = cpu_to_le16(*enable); - else - ibss_coal->enable = 0; + if (data_buf != NULL) + enable = *(u16 *) data_buf; + ibss_coal->enable = cpu_to_le16(enable); break; /* In other case.. Nothing to do */ @@ -812,8 +822,9 @@ static int mwifiex_cmd_ibss_coalescing_status(struct host_cmd_ds_command *cmd, static int mwifiex_cmd_reg_access(struct host_cmd_ds_command *cmd, u16 cmd_action, void *data_buf) { - struct mwifiex_ds_reg_rw *reg_rw = data_buf; + struct mwifiex_ds_reg_rw *reg_rw; + reg_rw = (struct mwifiex_ds_reg_rw *) data_buf; switch (le16_to_cpu(cmd->command)) { case HostCmd_CMD_MAC_REG_ACCESS: { @@ -882,7 +893,8 @@ static int mwifiex_cmd_reg_access(struct host_cmd_ds_command *cmd, } case HostCmd_CMD_802_11_EEPROM_ACCESS: { - struct mwifiex_ds_read_eeprom *rd_eeprom = data_buf; + struct mwifiex_ds_read_eeprom *rd_eeprom = + (struct mwifiex_ds_read_eeprom *) data_buf; struct host_cmd_ds_802_11_eeprom_access *cmd_eeprom = (struct host_cmd_ds_802_11_eeprom_access *) &cmd->params.eeprom; @@ -911,7 +923,8 @@ int mwifiex_sta_prepare_cmd(struct mwifiex_private *priv, uint16_t cmd_no, u16 cmd_action, u32 cmd_oid, void *data_buf, void *cmd_buf) { - struct host_cmd_ds_command *cmd_ptr = cmd_buf; + struct host_cmd_ds_command *cmd_ptr = + (struct host_cmd_ds_command *) cmd_buf; int ret = 0; /* Prepare command */ @@ -1168,7 +1181,7 @@ int mwifiex_sta_init_cmd(struct mwifiex_private *priv, u8 first_sta) /* Send request to firmware */ ret = mwifiex_send_cmd_async(priv, HostCmd_CMD_AMSDU_AGGR_CTRL, HostCmd_ACT_GEN_SET, 0, - &amsdu_aggr_ctrl); + (void *) &amsdu_aggr_ctrl); if (ret) return -1; /* MAC Control must be the last command in init_fw */ diff --git a/trunk/drivers/net/wireless/mwifiex/sta_cmdresp.c b/trunk/drivers/net/wireless/mwifiex/sta_cmdresp.c index 6804239d87bd..d08f76429a0a 100644 --- a/trunk/drivers/net/wireless/mwifiex/sta_cmdresp.c +++ b/trunk/drivers/net/wireless/mwifiex/sta_cmdresp.c @@ -120,10 +120,11 @@ mwifiex_process_cmdresp_error(struct mwifiex_private *priv, */ static int mwifiex_ret_802_11_rssi_info(struct mwifiex_private *priv, struct host_cmd_ds_command *resp, - struct mwifiex_ds_get_signal *signal) + void *data_buf) { struct host_cmd_ds_802_11_rssi_info_rsp *rssi_info_rsp = &resp->params.rssi_info_rsp; + struct mwifiex_ds_get_signal *signal; priv->data_rssi_last = le16_to_cpu(rssi_info_rsp->data_rssi_last); priv->data_nf_last = le16_to_cpu(rssi_info_rsp->data_nf_last); @@ -138,8 +139,9 @@ static int mwifiex_ret_802_11_rssi_info(struct mwifiex_private *priv, priv->bcn_nf_avg = le16_to_cpu(rssi_info_rsp->bcn_nf_avg); /* Need to indicate IOCTL complete */ - if (signal) { - memset(signal, 0, sizeof(*signal)); + if (data_buf) { + signal = (struct mwifiex_ds_get_signal *) data_buf; + memset(signal, 0, sizeof(struct mwifiex_ds_get_signal)); signal->selector = ALL_RSSI_INFO_MASK; @@ -183,7 +185,7 @@ static int mwifiex_ret_802_11_rssi_info(struct mwifiex_private *priv, */ static int mwifiex_ret_802_11_snmp_mib(struct mwifiex_private *priv, struct host_cmd_ds_command *resp, - u32 *data_buf) + void *data_buf) { struct host_cmd_ds_802_11_snmp_mib *smib = &resp->params.smib; u16 oid = le16_to_cpu(smib->oid); @@ -196,7 +198,7 @@ static int mwifiex_ret_802_11_snmp_mib(struct mwifiex_private *priv, if (query_type == HostCmd_ACT_GEN_GET) { ul_temp = le16_to_cpu(*((__le16 *) (smib->value))); if (data_buf) - *data_buf = ul_temp; + *(u32 *)data_buf = ul_temp; switch (oid) { case FRAG_THRESH_I: dev_dbg(priv->adapter->dev, @@ -226,12 +228,14 @@ static int mwifiex_ret_802_11_snmp_mib(struct mwifiex_private *priv, */ static int mwifiex_ret_get_log(struct mwifiex_private *priv, struct host_cmd_ds_command *resp, - struct mwifiex_ds_get_stats *stats) + void *data_buf) { struct host_cmd_ds_802_11_get_log *get_log = (struct host_cmd_ds_802_11_get_log *) &resp->params.get_log; + struct mwifiex_ds_get_stats *stats; - if (stats) { + if (data_buf) { + stats = (struct mwifiex_ds_get_stats *) data_buf; stats->mcast_tx_frame = le32_to_cpu(get_log->mcast_tx_frame); stats->failed = le32_to_cpu(get_log->failed); stats->retry = le32_to_cpu(get_log->retry); @@ -274,8 +278,9 @@ static int mwifiex_ret_get_log(struct mwifiex_private *priv, */ static int mwifiex_ret_tx_rate_cfg(struct mwifiex_private *priv, struct host_cmd_ds_command *resp, - struct mwifiex_rate_cfg *ds_rate) + void *data_buf) { + struct mwifiex_rate_cfg *ds_rate; struct host_cmd_ds_tx_rate_cfg *rate_cfg = &resp->params.tx_rate_cfg; struct mwifiex_rate_scope *rate_scope; struct mwifiex_ie_types_header *head; @@ -324,7 +329,8 @@ static int mwifiex_ret_tx_rate_cfg(struct mwifiex_private *priv, HostCmd_CMD_802_11_TX_RATE_QUERY, HostCmd_ACT_GEN_GET, 0, NULL); - if (ds_rate) { + if (data_buf) { + ds_rate = (struct mwifiex_rate_cfg *) data_buf; if (le16_to_cpu(rate_cfg->action) == HostCmd_ACT_GEN_GET) { if (priv->is_data_rate_auto) { ds_rate->is_rate_auto = 1; @@ -407,7 +413,8 @@ static int mwifiex_get_power_level(struct mwifiex_private *priv, void *data_buf) * and saving the current Tx power level in driver. */ static int mwifiex_ret_tx_power_cfg(struct mwifiex_private *priv, - struct host_cmd_ds_command *resp) + struct host_cmd_ds_command *resp, + void *data_buf) { struct mwifiex_adapter *adapter = priv->adapter; struct host_cmd_ds_txpwr_cfg *txp_cfg = &resp->params.txp_cfg; @@ -624,7 +631,7 @@ static int mwifiex_ret_802_11d_domain_info(struct mwifiex_private *priv, */ static int mwifiex_ret_802_11_rf_channel(struct mwifiex_private *priv, struct host_cmd_ds_command *resp, - u16 *data_buf) + void *data_buf) { struct host_cmd_ds_802_11_rf_channel *rf_channel = &resp->params.rf_channel; @@ -637,9 +644,8 @@ static int mwifiex_ret_802_11_rf_channel(struct mwifiex_private *priv, /* Update the channel again */ priv->curr_bss_params.bss_descriptor.channel = new_channel; } - if (data_buf) - *data_buf = new_channel; + *((u16 *)data_buf) = new_channel; return 0; } @@ -652,11 +658,13 @@ static int mwifiex_ret_802_11_rf_channel(struct mwifiex_private *priv, */ static int mwifiex_ret_ver_ext(struct mwifiex_private *priv, struct host_cmd_ds_command *resp, - struct host_cmd_ds_version_ext *version_ext) + void *data_buf) { struct host_cmd_ds_version_ext *ver_ext = &resp->params.verext; + struct host_cmd_ds_version_ext *version_ext; - if (version_ext) { + if (data_buf) { + version_ext = (struct host_cmd_ds_version_ext *)data_buf; version_ext->version_str_sel = ver_ext->version_str_sel; memcpy(version_ext->version_str, ver_ext->version_str, sizeof(char) * 128); @@ -678,8 +686,8 @@ static int mwifiex_ret_reg_access(u16 type, struct host_cmd_ds_command *resp, struct mwifiex_ds_read_eeprom *eeprom; if (data_buf) { - reg_rw = data_buf; - eeprom = data_buf; + reg_rw = (struct mwifiex_ds_reg_rw *) data_buf; + eeprom = (struct mwifiex_ds_read_eeprom *) data_buf; switch (type) { case HostCmd_CMD_MAC_REG_ACCESS: { @@ -817,11 +825,13 @@ static int mwifiex_ret_ibss_coalescing_status(struct mwifiex_private *priv, * This is a generic function, which calls command specific * response handlers based on the command ID. */ -int mwifiex_process_sta_cmdresp(struct mwifiex_private *priv, u16 cmdresp_no, - struct host_cmd_ds_command *resp) +int mwifiex_process_sta_cmdresp(struct mwifiex_private *priv, + u16 cmdresp_no, void *cmd_buf) { int ret = 0; struct mwifiex_adapter *adapter = priv->adapter; + struct host_cmd_ds_command *resp = + (struct host_cmd_ds_command *) cmd_buf; void *data_buf = adapter->curr_cmd->data_buf; /* If the command is not successful, cleanup and return failure */ @@ -855,7 +865,7 @@ int mwifiex_process_sta_cmdresp(struct mwifiex_private *priv, u16 cmdresp_no, "info: CMD_RESP: BG_SCAN result is ready!\n"); break; case HostCmd_CMD_TXPWR_CFG: - ret = mwifiex_ret_tx_power_cfg(priv, resp); + ret = mwifiex_ret_tx_power_cfg(priv, resp, data_buf); break; case HostCmd_CMD_802_11_PS_MODE_ENH: ret = mwifiex_ret_enh_power_mode(priv, resp, data_buf); diff --git a/trunk/drivers/net/wireless/mwifiex/sta_rx.c b/trunk/drivers/net/wireless/mwifiex/sta_rx.c index 27430512f7cd..1fdddece7479 100644 --- a/trunk/drivers/net/wireless/mwifiex/sta_rx.c +++ b/trunk/drivers/net/wireless/mwifiex/sta_rx.c @@ -187,7 +187,7 @@ int mwifiex_process_sta_rx_packet(struct mwifiex_adapter *adapter, ret = mwifiex_11n_rx_reorder_pkt(priv, local_rx_pd->seq_num, local_rx_pd->priority, ta, (u8) local_rx_pd->rx_pkt_type, - skb); + (void *) skb); if (ret || (rx_pkt_type == PKT_TYPE_BAR)) { if (priv && (ret == -1)) diff --git a/trunk/drivers/net/wireless/mwifiex/txrx.c b/trunk/drivers/net/wireless/mwifiex/txrx.c index 6190b2fa57a3..aaa50c074196 100644 --- a/trunk/drivers/net/wireless/mwifiex/txrx.c +++ b/trunk/drivers/net/wireless/mwifiex/txrx.c @@ -71,7 +71,7 @@ int mwifiex_process_tx(struct mwifiex_private *priv, struct sk_buff *skb, u8 *head_ptr; struct txpd *local_tx_pd = NULL; - head_ptr = mwifiex_process_sta_txpd(priv, skb); + head_ptr = (u8 *) mwifiex_process_sta_txpd(priv, skb); if (head_ptr) { if (GET_BSS_ROLE(priv) == MWIFIEX_BSS_ROLE_STA) local_tx_pd = diff --git a/trunk/drivers/net/wireless/rt2x00/rt2400pci.c b/trunk/drivers/net/wireless/rt2x00/rt2400pci.c index 76bcc3547976..937f9e8bf05f 100644 --- a/trunk/drivers/net/wireless/rt2x00/rt2400pci.c +++ b/trunk/drivers/net/wireless/rt2x00/rt2400pci.c @@ -1723,7 +1723,6 @@ static const struct ieee80211_ops rt2400pci_mac80211_ops = { .set_antenna = rt2x00mac_set_antenna, .get_antenna = rt2x00mac_get_antenna, .get_ringparam = rt2x00mac_get_ringparam, - .tx_frames_pending = rt2x00mac_tx_frames_pending, }; static const struct rt2x00lib_ops rt2400pci_rt2x00_ops = { diff --git a/trunk/drivers/net/wireless/rt2x00/rt2500pci.c b/trunk/drivers/net/wireless/rt2x00/rt2500pci.c index c288d951c034..d27d7b8ba3b6 100644 --- a/trunk/drivers/net/wireless/rt2x00/rt2500pci.c +++ b/trunk/drivers/net/wireless/rt2x00/rt2500pci.c @@ -2016,7 +2016,6 @@ static const struct ieee80211_ops rt2500pci_mac80211_ops = { .set_antenna = rt2x00mac_set_antenna, .get_antenna = rt2x00mac_get_antenna, .get_ringparam = rt2x00mac_get_ringparam, - .tx_frames_pending = rt2x00mac_tx_frames_pending, }; static const struct rt2x00lib_ops rt2500pci_rt2x00_ops = { diff --git a/trunk/drivers/net/wireless/rt2x00/rt2500usb.c b/trunk/drivers/net/wireless/rt2x00/rt2500usb.c index 53c5f878f61d..15237c275486 100644 --- a/trunk/drivers/net/wireless/rt2x00/rt2500usb.c +++ b/trunk/drivers/net/wireless/rt2x00/rt2500usb.c @@ -1827,7 +1827,6 @@ static const struct ieee80211_ops rt2500usb_mac80211_ops = { .set_antenna = rt2x00mac_set_antenna, .get_antenna = rt2x00mac_get_antenna, .get_ringparam = rt2x00mac_get_ringparam, - .tx_frames_pending = rt2x00mac_tx_frames_pending, }; static const struct rt2x00lib_ops rt2500usb_rt2x00_ops = { diff --git a/trunk/drivers/net/wireless/rt2x00/rt2800pci.c b/trunk/drivers/net/wireless/rt2x00/rt2800pci.c index ebc17ad61dec..9ccc53733bae 100644 --- a/trunk/drivers/net/wireless/rt2x00/rt2800pci.c +++ b/trunk/drivers/net/wireless/rt2x00/rt2800pci.c @@ -1031,7 +1031,6 @@ static const struct ieee80211_ops rt2800pci_mac80211_ops = { .flush = rt2x00mac_flush, .get_survey = rt2800_get_survey, .get_ringparam = rt2x00mac_get_ringparam, - .tx_frames_pending = rt2x00mac_tx_frames_pending, }; static const struct rt2800_ops rt2800pci_rt2800_ops = { @@ -1161,7 +1160,6 @@ static DEFINE_PCI_DEVICE_TABLE(rt2800pci_device_table) = { #endif #ifdef CONFIG_RT2800PCI_RT53XX { PCI_DEVICE(0x1814, 0x5390) }, - { PCI_DEVICE(0x1814, 0x539f) }, #endif { 0, } }; diff --git a/trunk/drivers/net/wireless/rt2x00/rt2800usb.c b/trunk/drivers/net/wireless/rt2x00/rt2800usb.c index 59e77797c0fa..6e9229830a29 100644 --- a/trunk/drivers/net/wireless/rt2x00/rt2800usb.c +++ b/trunk/drivers/net/wireless/rt2x00/rt2800usb.c @@ -757,7 +757,6 @@ static const struct ieee80211_ops rt2800usb_mac80211_ops = { .flush = rt2x00mac_flush, .get_survey = rt2800_get_survey, .get_ringparam = rt2x00mac_get_ringparam, - .tx_frames_pending = rt2x00mac_tx_frames_pending, }; static const struct rt2800_ops rt2800usb_rt2800_ops = { @@ -1021,7 +1020,6 @@ static struct usb_device_id rt2800usb_device_table[] = { { USB_DEVICE(0x0df6, 0x0048) }, { USB_DEVICE(0x0df6, 0x0051) }, { USB_DEVICE(0x0df6, 0x005f) }, - { USB_DEVICE(0x0df6, 0x0060) }, /* SMC */ { USB_DEVICE(0x083a, 0x6618) }, { USB_DEVICE(0x083a, 0x7511) }, @@ -1078,7 +1076,6 @@ static struct usb_device_id rt2800usb_device_table[] = { { USB_DEVICE(0x148f, 0x3572) }, /* Sitecom */ { USB_DEVICE(0x0df6, 0x0041) }, - { USB_DEVICE(0x0df6, 0x0062) }, /* Toshiba */ { USB_DEVICE(0x0930, 0x0a07) }, /* Zinwell */ @@ -1177,6 +1174,8 @@ static struct usb_device_id rt2800usb_device_table[] = { { USB_DEVICE(0x0df6, 0x004a) }, { USB_DEVICE(0x0df6, 0x004d) }, { USB_DEVICE(0x0df6, 0x0053) }, + { USB_DEVICE(0x0df6, 0x0060) }, + { USB_DEVICE(0x0df6, 0x0062) }, /* SMC */ { USB_DEVICE(0x083a, 0xa512) }, { USB_DEVICE(0x083a, 0xc522) }, diff --git a/trunk/drivers/net/wireless/rt2x00/rt2x00.h b/trunk/drivers/net/wireless/rt2x00/rt2x00.h index f82bfeb79ebb..4efaf886fb89 100644 --- a/trunk/drivers/net/wireless/rt2x00/rt2x00.h +++ b/trunk/drivers/net/wireless/rt2x00/rt2x00.h @@ -1277,7 +1277,6 @@ int rt2x00mac_set_antenna(struct ieee80211_hw *hw, u32 tx_ant, u32 rx_ant); int rt2x00mac_get_antenna(struct ieee80211_hw *hw, u32 *tx_ant, u32 *rx_ant); void rt2x00mac_get_ringparam(struct ieee80211_hw *hw, u32 *tx, u32 *tx_max, u32 *rx, u32 *rx_max); -bool rt2x00mac_tx_frames_pending(struct ieee80211_hw *hw); /* * Driver allocation handlers. diff --git a/trunk/drivers/net/wireless/rt2x00/rt2x00crypto.c b/trunk/drivers/net/wireless/rt2x00/rt2x00crypto.c index 1ca4c7ffc189..1bb9d46077ff 100644 --- a/trunk/drivers/net/wireless/rt2x00/rt2x00crypto.c +++ b/trunk/drivers/net/wireless/rt2x00/rt2x00crypto.c @@ -45,11 +45,11 @@ enum cipher rt2x00crypto_key_to_cipher(struct ieee80211_key_conf *key) } } -void rt2x00crypto_create_tx_descriptor(struct rt2x00_dev *rt2x00dev, - struct sk_buff *skb, +void rt2x00crypto_create_tx_descriptor(struct queue_entry *entry, struct txentry_desc *txdesc) { - struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb); + struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev; + struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(entry->skb); struct ieee80211_key_conf *hw_key = tx_info->control.hw_key; if (!test_bit(CAPABILITY_HW_CRYPTO, &rt2x00dev->cap_flags) || !hw_key) diff --git a/trunk/drivers/net/wireless/rt2x00/rt2x00dev.c b/trunk/drivers/net/wireless/rt2x00/rt2x00dev.c index 0955c941317f..939821b4af2f 100644 --- a/trunk/drivers/net/wireless/rt2x00/rt2x00dev.c +++ b/trunk/drivers/net/wireless/rt2x00/rt2x00dev.c @@ -582,18 +582,6 @@ void rt2x00lib_rxdone(struct queue_entry *entry) memset(&rxdesc, 0, sizeof(rxdesc)); rt2x00dev->ops->lib->fill_rxdone(entry, &rxdesc); - /* - * Check for valid size in case we get corrupted descriptor from - * hardware. - */ - if (unlikely(rxdesc.size == 0 || - rxdesc.size > entry->queue->data_size)) { - WARNING(rt2x00dev, "Wrong frame size %d max %d.\n", - rxdesc.size, entry->queue->data_size); - dev_kfree_skb(entry->skb); - goto renew_skb; - } - /* * The data behind the ieee80211 header must be * aligned on a 4 byte boundary. @@ -654,7 +642,6 @@ void rt2x00lib_rxdone(struct queue_entry *entry) ieee80211_rx_ni(rt2x00dev->hw, entry->skb); -renew_skb: /* * Replace the skb with the freshly allocated one. */ diff --git a/trunk/drivers/net/wireless/rt2x00/rt2x00lib.h b/trunk/drivers/net/wireless/rt2x00/rt2x00lib.h index 15cdc7e57fc4..322cc4f3de5d 100644 --- a/trunk/drivers/net/wireless/rt2x00/rt2x00lib.h +++ b/trunk/drivers/net/wireless/rt2x00/rt2x00lib.h @@ -336,8 +336,7 @@ static inline void rt2x00debug_update_crypto(struct rt2x00_dev *rt2x00dev, */ #ifdef CONFIG_RT2X00_LIB_CRYPTO enum cipher rt2x00crypto_key_to_cipher(struct ieee80211_key_conf *key); -void rt2x00crypto_create_tx_descriptor(struct rt2x00_dev *rt2x00dev, - struct sk_buff *skb, +void rt2x00crypto_create_tx_descriptor(struct queue_entry *entry, struct txentry_desc *txdesc); unsigned int rt2x00crypto_tx_overhead(struct rt2x00_dev *rt2x00dev, struct sk_buff *skb); diff --git a/trunk/drivers/net/wireless/rt2x00/rt2x00mac.c b/trunk/drivers/net/wireless/rt2x00/rt2x00mac.c index 8efab3983528..93bec140e598 100644 --- a/trunk/drivers/net/wireless/rt2x00/rt2x00mac.c +++ b/trunk/drivers/net/wireless/rt2x00/rt2x00mac.c @@ -818,17 +818,3 @@ void rt2x00mac_get_ringparam(struct ieee80211_hw *hw, *rx_max = rt2x00dev->rx->limit; } EXPORT_SYMBOL_GPL(rt2x00mac_get_ringparam); - -bool rt2x00mac_tx_frames_pending(struct ieee80211_hw *hw) -{ - struct rt2x00_dev *rt2x00dev = hw->priv; - struct data_queue *queue; - - tx_queue_for_each(rt2x00dev, queue) { - if (!rt2x00queue_empty(queue)) - return true; - } - - return false; -} -EXPORT_SYMBOL_GPL(rt2x00mac_tx_frames_pending); diff --git a/trunk/drivers/net/wireless/rt2x00/rt2x00queue.c b/trunk/drivers/net/wireless/rt2x00/rt2x00queue.c index 29edb9fbe6f1..c7fc9def6bcf 100644 --- a/trunk/drivers/net/wireless/rt2x00/rt2x00queue.c +++ b/trunk/drivers/net/wireless/rt2x00/rt2x00queue.c @@ -200,12 +200,11 @@ void rt2x00queue_remove_l2pad(struct sk_buff *skb, unsigned int header_length) skb_pull(skb, l2pad); } -static void rt2x00queue_create_tx_descriptor_seq(struct rt2x00_dev *rt2x00dev, - struct sk_buff *skb, +static void rt2x00queue_create_tx_descriptor_seq(struct queue_entry *entry, struct txentry_desc *txdesc) { - struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb); - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; + struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(entry->skb); + struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)entry->skb->data; struct rt2x00_intf *intf = vif_to_intf(tx_info->control.vif); if (!(tx_info->flags & IEEE80211_TX_CTL_ASSIGN_SEQ)) @@ -213,7 +212,7 @@ static void rt2x00queue_create_tx_descriptor_seq(struct rt2x00_dev *rt2x00dev, __set_bit(ENTRY_TXD_GENERATE_SEQ, &txdesc->flags); - if (!test_bit(REQUIRE_SW_SEQNO, &rt2x00dev->cap_flags)) + if (!test_bit(REQUIRE_SW_SEQNO, &entry->queue->rt2x00dev->cap_flags)) return; /* @@ -238,12 +237,12 @@ static void rt2x00queue_create_tx_descriptor_seq(struct rt2x00_dev *rt2x00dev, } -static void rt2x00queue_create_tx_descriptor_plcp(struct rt2x00_dev *rt2x00dev, - struct sk_buff *skb, +static void rt2x00queue_create_tx_descriptor_plcp(struct queue_entry *entry, struct txentry_desc *txdesc, const struct rt2x00_rate *hwrate) { - struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb); + struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev; + struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(entry->skb); struct ieee80211_tx_rate *txrate = &tx_info->control.rates[0]; unsigned int data_length; unsigned int duration; @@ -260,8 +259,8 @@ static void rt2x00queue_create_tx_descriptor_plcp(struct rt2x00_dev *rt2x00dev, txdesc->u.plcp.ifs = IFS_SIFS; /* Data length + CRC + Crypto overhead (IV/EIV/ICV/MIC) */ - data_length = skb->len + 4; - data_length += rt2x00crypto_tx_overhead(rt2x00dev, skb); + data_length = entry->skb->len + 4; + data_length += rt2x00crypto_tx_overhead(rt2x00dev, entry->skb); /* * PLCP setup @@ -302,14 +301,13 @@ static void rt2x00queue_create_tx_descriptor_plcp(struct rt2x00_dev *rt2x00dev, } } -static void rt2x00queue_create_tx_descriptor_ht(struct rt2x00_dev *rt2x00dev, - struct sk_buff *skb, +static void rt2x00queue_create_tx_descriptor_ht(struct queue_entry *entry, struct txentry_desc *txdesc, const struct rt2x00_rate *hwrate) { - struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb); + struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(entry->skb); struct ieee80211_tx_rate *txrate = &tx_info->control.rates[0]; - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; + struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)entry->skb->data; if (tx_info->control.sta) txdesc->u.ht.mpdu_density = @@ -382,12 +380,12 @@ static void rt2x00queue_create_tx_descriptor_ht(struct rt2x00_dev *rt2x00dev, txdesc->u.ht.txop = TXOP_HTTXOP; } -static void rt2x00queue_create_tx_descriptor(struct rt2x00_dev *rt2x00dev, - struct sk_buff *skb, +static void rt2x00queue_create_tx_descriptor(struct queue_entry *entry, struct txentry_desc *txdesc) { - struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb); - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; + struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev; + struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(entry->skb); + struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)entry->skb->data; struct ieee80211_tx_rate *txrate = &tx_info->control.rates[0]; struct ieee80211_rate *rate; const struct rt2x00_rate *hwrate = NULL; @@ -397,8 +395,8 @@ static void rt2x00queue_create_tx_descriptor(struct rt2x00_dev *rt2x00dev, /* * Header and frame information. */ - txdesc->length = skb->len; - txdesc->header_length = ieee80211_get_hdrlen_from_skb(skb); + txdesc->length = entry->skb->len; + txdesc->header_length = ieee80211_get_hdrlen_from_skb(entry->skb); /* * Check whether this frame is to be acked. @@ -473,15 +471,13 @@ static void rt2x00queue_create_tx_descriptor(struct rt2x00_dev *rt2x00dev, /* * Apply TX descriptor handling by components */ - rt2x00crypto_create_tx_descriptor(rt2x00dev, skb, txdesc); - rt2x00queue_create_tx_descriptor_seq(rt2x00dev, skb, txdesc); + rt2x00crypto_create_tx_descriptor(entry, txdesc); + rt2x00queue_create_tx_descriptor_seq(entry, txdesc); if (test_bit(REQUIRE_HT_TX_DESC, &rt2x00dev->cap_flags)) - rt2x00queue_create_tx_descriptor_ht(rt2x00dev, skb, txdesc, - hwrate); + rt2x00queue_create_tx_descriptor_ht(entry, txdesc, hwrate); else - rt2x00queue_create_tx_descriptor_plcp(rt2x00dev, skb, txdesc, - hwrate); + rt2x00queue_create_tx_descriptor_plcp(entry, txdesc, hwrate); } static int rt2x00queue_write_tx_data(struct queue_entry *entry, @@ -559,18 +555,33 @@ int rt2x00queue_write_tx_frame(struct data_queue *queue, struct sk_buff *skb, bool local) { struct ieee80211_tx_info *tx_info; - struct queue_entry *entry; + struct queue_entry *entry = rt2x00queue_get_entry(queue, Q_INDEX); struct txentry_desc txdesc; struct skb_frame_desc *skbdesc; u8 rate_idx, rate_flags; - int ret = 0; + + if (unlikely(rt2x00queue_full(queue))) { + ERROR(queue->rt2x00dev, + "Dropping frame due to full tx queue %d.\n", queue->qid); + return -ENOBUFS; + } + + if (unlikely(test_and_set_bit(ENTRY_OWNER_DEVICE_DATA, + &entry->flags))) { + ERROR(queue->rt2x00dev, + "Arrived at non-free entry in the non-full queue %d.\n" + "Please file bug report to %s.\n", + queue->qid, DRV_PROJECT); + return -EINVAL; + } /* * Copy all TX descriptor information into txdesc, * after that we are free to use the skb->cb array * for our information. */ - rt2x00queue_create_tx_descriptor(queue->rt2x00dev, skb, &txdesc); + entry->skb = skb; + rt2x00queue_create_tx_descriptor(entry, &txdesc); /* * All information is retrieved from the skb->cb array, @@ -582,6 +593,7 @@ int rt2x00queue_write_tx_frame(struct data_queue *queue, struct sk_buff *skb, rate_flags = tx_info->control.rates[0].flags; skbdesc = get_skb_frame_desc(skb); memset(skbdesc, 0, sizeof(*skbdesc)); + skbdesc->entry = entry; skbdesc->tx_rate_idx = rate_idx; skbdesc->tx_rate_flags = rate_flags; @@ -610,33 +622,9 @@ int rt2x00queue_write_tx_frame(struct data_queue *queue, struct sk_buff *skb, * for PCI devices. */ if (test_bit(REQUIRE_L2PAD, &queue->rt2x00dev->cap_flags)) - rt2x00queue_insert_l2pad(skb, txdesc.header_length); + rt2x00queue_insert_l2pad(entry->skb, txdesc.header_length); else if (test_bit(REQUIRE_DMA, &queue->rt2x00dev->cap_flags)) - rt2x00queue_align_frame(skb); - - spin_lock(&queue->tx_lock); - - if (unlikely(rt2x00queue_full(queue))) { - ERROR(queue->rt2x00dev, - "Dropping frame due to full tx queue %d.\n", queue->qid); - ret = -ENOBUFS; - goto out; - } - - entry = rt2x00queue_get_entry(queue, Q_INDEX); - - if (unlikely(test_and_set_bit(ENTRY_OWNER_DEVICE_DATA, - &entry->flags))) { - ERROR(queue->rt2x00dev, - "Arrived at non-free entry in the non-full queue %d.\n" - "Please file bug report to %s.\n", - queue->qid, DRV_PROJECT); - ret = -EINVAL; - goto out; - } - - skbdesc->entry = entry; - entry->skb = skb; + rt2x00queue_align_frame(entry->skb); /* * It could be possible that the queue was corrupted and this @@ -646,8 +634,7 @@ int rt2x00queue_write_tx_frame(struct data_queue *queue, struct sk_buff *skb, if (unlikely(rt2x00queue_write_tx_data(entry, &txdesc))) { clear_bit(ENTRY_OWNER_DEVICE_DATA, &entry->flags); entry->skb = NULL; - ret = -EIO; - goto out; + return -EIO; } set_bit(ENTRY_DATA_PENDING, &entry->flags); @@ -656,9 +643,7 @@ int rt2x00queue_write_tx_frame(struct data_queue *queue, struct sk_buff *skb, rt2x00queue_write_tx_descriptor(entry, &txdesc); rt2x00queue_kick_tx_queue(queue, &txdesc); -out: - spin_unlock(&queue->tx_lock); - return ret; + return 0; } int rt2x00queue_clear_beacon(struct rt2x00_dev *rt2x00dev, @@ -712,7 +697,7 @@ int rt2x00queue_update_beacon_locked(struct rt2x00_dev *rt2x00dev, * after that we are free to use the skb->cb array * for our information. */ - rt2x00queue_create_tx_descriptor(rt2x00dev, intf->beacon->skb, &txdesc); + rt2x00queue_create_tx_descriptor(intf->beacon, &txdesc); /* * Fill in skb descriptor @@ -1199,7 +1184,6 @@ static void rt2x00queue_init(struct rt2x00_dev *rt2x00dev, struct data_queue *queue, enum data_queue_qid qid) { mutex_init(&queue->status_lock); - spin_lock_init(&queue->tx_lock); spin_lock_init(&queue->index_lock); queue->rt2x00dev = rt2x00dev; diff --git a/trunk/drivers/net/wireless/rt2x00/rt2x00queue.h b/trunk/drivers/net/wireless/rt2x00/rt2x00queue.h index f2100f4ddcff..167d45873dca 100644 --- a/trunk/drivers/net/wireless/rt2x00/rt2x00queue.h +++ b/trunk/drivers/net/wireless/rt2x00/rt2x00queue.h @@ -54,7 +54,7 @@ * @QID_RX: RX queue * @QID_OTHER: None of the above (don't use, only present for completeness) * @QID_BEACON: Beacon queue (value unspecified, don't send it to device) - * @QID_ATIM: Atim queue (value unspecified, don't send it to device) + * @QID_ATIM: Atim queue (value unspeficied, don't send it to device) */ enum data_queue_qid { QID_AC_VO = 0, @@ -432,7 +432,6 @@ enum data_queue_flags { * @flags: Entry flags, see &enum queue_entry_flags. * @status_lock: The mutex for protecting the start/stop/flush * handling on this queue. - * @tx_lock: Spinlock to serialize tx operations on this queue. * @index_lock: Spinlock to protect index handling. Whenever @index, @index_done or * @index_crypt needs to be changed this lock should be grabbed to prevent * index corruption due to concurrency. @@ -459,7 +458,6 @@ struct data_queue { unsigned long flags; struct mutex status_lock; - spinlock_t tx_lock; spinlock_t index_lock; unsigned int count; diff --git a/trunk/drivers/net/wireless/rt2x00/rt2x00usb.c b/trunk/drivers/net/wireless/rt2x00/rt2x00usb.c index b6b4542c2460..8f90f6268077 100644 --- a/trunk/drivers/net/wireless/rt2x00/rt2x00usb.c +++ b/trunk/drivers/net/wireless/rt2x00/rt2x00usb.c @@ -802,7 +802,6 @@ int rt2x00usb_probe(struct usb_interface *usb_intf, int retval; usb_dev = usb_get_dev(usb_dev); - usb_reset_device(usb_dev); hw = ieee80211_alloc_hw(sizeof(struct rt2x00_dev), ops->hw); if (!hw) { diff --git a/trunk/drivers/net/wireless/rt2x00/rt61pci.c b/trunk/drivers/net/wireless/rt2x00/rt61pci.c index 53110b83bf6e..9d35ec16a3a5 100644 --- a/trunk/drivers/net/wireless/rt2x00/rt61pci.c +++ b/trunk/drivers/net/wireless/rt2x00/rt61pci.c @@ -2982,7 +2982,6 @@ static const struct ieee80211_ops rt61pci_mac80211_ops = { .set_antenna = rt2x00mac_set_antenna, .get_antenna = rt2x00mac_get_antenna, .get_ringparam = rt2x00mac_get_ringparam, - .tx_frames_pending = rt2x00mac_tx_frames_pending, }; static const struct rt2x00lib_ops rt61pci_rt2x00_ops = { diff --git a/trunk/drivers/net/wireless/rt2x00/rt73usb.c b/trunk/drivers/net/wireless/rt2x00/rt73usb.c index 6a93939f44e8..ad20953cbf05 100644 --- a/trunk/drivers/net/wireless/rt2x00/rt73usb.c +++ b/trunk/drivers/net/wireless/rt2x00/rt73usb.c @@ -2314,7 +2314,6 @@ static const struct ieee80211_ops rt73usb_mac80211_ops = { .set_antenna = rt2x00mac_set_antenna, .get_antenna = rt2x00mac_get_antenna, .get_ringparam = rt2x00mac_get_ringparam, - .tx_frames_pending = rt2x00mac_tx_frames_pending, }; static const struct rt2x00lib_ops rt73usb_rt2x00_ops = { diff --git a/trunk/drivers/net/wireless/rtlwifi/Kconfig b/trunk/drivers/net/wireless/rtlwifi/Kconfig index 45e14760c16e..5aee8b22d74e 100644 --- a/trunk/drivers/net/wireless/rtlwifi/Kconfig +++ b/trunk/drivers/net/wireless/rtlwifi/Kconfig @@ -21,17 +21,6 @@ config RTL8192SE If you choose to build it as a module, it will be called rtl8192se -config RTL8192DE - tristate "Realtek RTL8192DE/RTL8188DE PCIe Wireless Network Adapter" - depends on MAC80211 && EXPERIMENTAL - select FW_LOADER - select RTLWIFI - ---help--- - This is the driver for Realtek RTL8192DE/RTL8188DE 802.11n PCIe - wireless network adapters. - - If you choose to build it as a module, it will be called rtl8192de - config RTL8192CU tristate "Realtek RTL8192CU/RTL8188CU USB Wireless Network Adapter" depends on MAC80211 && USB && EXPERIMENTAL @@ -46,10 +35,10 @@ config RTL8192CU config RTLWIFI tristate - depends on RTL8192CE || RTL8192CU || RTL8192SE || RTL8192DE + depends on RTL8192CE || RTL8192CU || RTL8192SE default m config RTL8192C_COMMON tristate - depends on RTL8192CE || RTL8192CU + depends on RTL8192CE || RTL8192CU || RTL8192SE default m diff --git a/trunk/drivers/net/wireless/rtlwifi/Makefile b/trunk/drivers/net/wireless/rtlwifi/Makefile index 97935c565bab..7acce83c3785 100644 --- a/trunk/drivers/net/wireless/rtlwifi/Makefile +++ b/trunk/drivers/net/wireless/rtlwifi/Makefile @@ -23,6 +23,5 @@ obj-$(CONFIG_RTL8192C_COMMON) += rtl8192c/ obj-$(CONFIG_RTL8192CE) += rtl8192ce/ obj-$(CONFIG_RTL8192CU) += rtl8192cu/ obj-$(CONFIG_RTL8192SE) += rtl8192se/ -obj-$(CONFIG_RTL8192DE) += rtl8192de/ ccflags-y += -D__CHECK_ENDIAN__ diff --git a/trunk/drivers/net/wireless/rtlwifi/base.c b/trunk/drivers/net/wireless/rtlwifi/base.c index bc13533a5418..fb5e43bd7c3c 100644 --- a/trunk/drivers/net/wireless/rtlwifi/base.c +++ b/trunk/drivers/net/wireless/rtlwifi/base.c @@ -523,7 +523,7 @@ static void _rtl_query_shortgi(struct ieee80211_hw *hw, mac->opmode == NL80211_IFTYPE_ADHOC) bw_40 = sta->ht_cap.cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40; - if (bw_40 && sgi_40) + if ((bw_40 == true) && sgi_40) tcb_desc->use_shortgi = true; else if ((bw_40 == false) && sgi_20) tcb_desc->use_shortgi = true; diff --git a/trunk/drivers/net/wireless/rtlwifi/core.c b/trunk/drivers/net/wireless/rtlwifi/core.c index 03ce69660b26..d2ec2535aa3c 100644 --- a/trunk/drivers/net/wireless/rtlwifi/core.c +++ b/trunk/drivers/net/wireless/rtlwifi/core.c @@ -335,8 +335,8 @@ static int rtl_op_config(struct ieee80211_hw *hw, u32 changed) * before going offchannel, or dis-association or delete BA will * happen by AP */ - if (rtlpriv->mac80211.offchan_delay) { - rtlpriv->mac80211.offchan_delay = false; + if (rtlpriv->mac80211.offchan_deley) { + rtlpriv->mac80211.offchan_deley = false; mdelay(50); } rtlphy->current_channel = wide_chan; @@ -443,11 +443,11 @@ static int rtl_op_sta_add(struct ieee80211_hw *hw, sta_entry->wireless_mode = WIRELESS_MODE_G; if (sta->supp_rates[0] <= 0xf) sta_entry->wireless_mode = WIRELESS_MODE_B; - if (sta->ht_cap.ht_supported) + if (sta->ht_cap.ht_supported == true) sta_entry->wireless_mode = WIRELESS_MODE_N_24G; } else if (rtlhal->current_bandtype == BAND_ON_5G) { sta_entry->wireless_mode = WIRELESS_MODE_A; - if (sta->ht_cap.ht_supported) + if (sta->ht_cap.ht_supported == true) sta_entry->wireless_mode = WIRELESS_MODE_N_24G; } @@ -650,7 +650,7 @@ static void rtl_op_bss_info_changed(struct ieee80211_hw *hw, RT_TRACE(rtlpriv, COMP_MAC80211, DBG_TRACE, ("BSS_CHANGED_HT\n")); rcu_read_lock(); - sta = get_sta(hw, vif, bss_conf->bssid); + sta = get_sta(hw, vif, (u8 *)bss_conf->bssid); if (sta) { if (sta->ht_cap.ampdu_density > mac->current_ampdu_density) @@ -685,7 +685,7 @@ static void rtl_op_bss_info_changed(struct ieee80211_hw *hw, rtlpriv->cfg->ops->set_network_type(hw, vif->type); rcu_read_lock(); - sta = get_sta(hw, vif, bss_conf->bssid); + sta = get_sta(hw, vif, (u8 *)bss_conf->bssid); if (!sta) { rcu_read_unlock(); goto out; diff --git a/trunk/drivers/net/wireless/rtlwifi/core.h b/trunk/drivers/net/wireless/rtlwifi/core.h index f02824a3b747..4b247db2861d 100644 --- a/trunk/drivers/net/wireless/rtlwifi/core.h +++ b/trunk/drivers/net/wireless/rtlwifi/core.h @@ -30,8 +30,6 @@ #ifndef __RTL_CORE_H__ #define __RTL_CORE_H__ -#include - #define RTL_SUPPORTED_FILTERS \ (FIF_PROMISC_IN_BSS | \ FIF_ALLMULTI | FIF_CONTROL | \ diff --git a/trunk/drivers/net/wireless/rtlwifi/efuse.c b/trunk/drivers/net/wireless/rtlwifi/efuse.c index 3fc21f60bb04..0b562322f138 100644 --- a/trunk/drivers/net/wireless/rtlwifi/efuse.c +++ b/trunk/drivers/net/wireless/rtlwifi/efuse.c @@ -382,7 +382,7 @@ bool efuse_shadow_update_chk(struct ieee80211_hw *hw) } } - if (wordchanged) + if (wordchanged == true) hdr_num++; } @@ -453,7 +453,7 @@ bool efuse_shadow_update(struct ieee80211_hw *hw) base = offset * 8; for (i = 0; i < 8; i++) { - if (first_pg) { + if (first_pg == true) { word_en &= ~(BIT(i / 2)); @@ -505,7 +505,7 @@ void rtl_efuse_shadow_map_update(struct ieee80211_hw *hw) struct rtl_priv *rtlpriv = rtl_priv(hw); struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw)); - if (rtlefuse->autoload_failflag) + if (rtlefuse->autoload_failflag == true) memset(&rtlefuse->efuse_map[EFUSE_INIT_MAP][0], 0xFF, rtlpriv->cfg->maps[EFUSE_HWSET_MAX_SIZE]); else @@ -690,7 +690,7 @@ static void efuse_read_data_case1(struct ieee80211_hw *hw, u16 *efuse_addr, } } - if (dataempty) { + if (dataempty == true) { *readstate = PG_STATE_DATA; } else { *efuse_addr = *efuse_addr + (word_cnts * 2) + 1; diff --git a/trunk/drivers/net/wireless/rtlwifi/pci.c b/trunk/drivers/net/wireless/rtlwifi/pci.c index 5efd57833489..e502db0532e5 100644 --- a/trunk/drivers/net/wireless/rtlwifi/pci.c +++ b/trunk/drivers/net/wireless/rtlwifi/pci.c @@ -35,10 +35,10 @@ #include "efuse.h" static const u16 pcibridge_vendors[PCI_BRIDGE_VENDOR_MAX] = { - PCI_VENDOR_ID_INTEL, - PCI_VENDOR_ID_ATI, - PCI_VENDOR_ID_AMD, - PCI_VENDOR_ID_SI + INTEL_VENDOR_ID, + ATI_VENDOR_ID, + AMD_VENDOR_ID, + SIS_VENDOR_ID }; static const u8 ac_to_hwq[] = { @@ -390,7 +390,7 @@ static void rtl_pci_parse_configuration(struct pci_dev *pdev, u8 linkctrl_reg; /*Link Control Register */ - pos = pci_pcie_cap(pdev); + pos = pci_find_capability(pdev, PCI_CAP_ID_EXP); pci_read_config_byte(pdev, pos + PCI_EXP_LNKCTL, &linkctrl_reg); pcipriv->ndis_adapter.linkctrl_reg = linkctrl_reg; @@ -581,7 +581,7 @@ static void _rtl_pci_tx_isr(struct ieee80211_hw *hw, int prio) fc = rtl_get_fc(skb); if (ieee80211_is_nullfunc(fc)) { if (ieee80211_has_pm(fc)) { - rtlpriv->mac80211.offchan_delay = true; + rtlpriv->mac80211.offchan_deley = true; rtlpriv->psc.state_inap = 1; } else { rtlpriv->psc.state_inap = 0; @@ -626,56 +626,6 @@ static void _rtl_pci_tx_isr(struct ieee80211_hw *hw, int prio) } } -static void _rtl_receive_one(struct ieee80211_hw *hw, struct sk_buff *skb, - struct ieee80211_rx_status rx_status) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct ieee80211_hdr *hdr = rtl_get_hdr(skb); - __le16 fc = rtl_get_fc(skb); - bool unicast = false; - struct sk_buff *uskb = NULL; - u8 *pdata; - - - memcpy(IEEE80211_SKB_RXCB(skb), &rx_status, sizeof(rx_status)); - - if (is_broadcast_ether_addr(hdr->addr1)) { - ;/*TODO*/ - } else if (is_multicast_ether_addr(hdr->addr1)) { - ;/*TODO*/ - } else { - unicast = true; - rtlpriv->stats.rxbytesunicast += skb->len; - } - - rtl_is_special_data(hw, skb, false); - - if (ieee80211_is_data(fc)) { - rtlpriv->cfg->ops->led_control(hw, LED_CTL_RX); - - if (unicast) - rtlpriv->link_info.num_rx_inperiod++; - } - - /* for sw lps */ - rtl_swlps_beacon(hw, (void *)skb->data, skb->len); - rtl_recognize_peer(hw, (void *)skb->data, skb->len); - if ((rtlpriv->mac80211.opmode == NL80211_IFTYPE_AP) && - (rtlpriv->rtlhal.current_bandtype == BAND_ON_2_4G) && - (ieee80211_is_beacon(fc) || ieee80211_is_probe_resp(fc))) - return; - - if (unlikely(!rtl_action_proc(hw, skb, false))) - return; - - uskb = dev_alloc_skb(skb->len + 128); - memcpy(IEEE80211_SKB_RXCB(uskb), &rx_status, sizeof(rx_status)); - pdata = (u8 *)skb_put(uskb, skb->len); - memcpy(pdata, skb->data, skb->len); - - ieee80211_rx_irqsafe(hw, uskb); -} - static void _rtl_pci_rx_interrupt(struct ieee80211_hw *hw) { struct rtl_priv *rtlpriv = rtl_priv(hw); @@ -687,6 +637,7 @@ static void _rtl_pci_rx_interrupt(struct ieee80211_hw *hw) u8 own; u8 tmp_one; u32 bufferaddress; + bool unicast = false; struct rtl_stats stats = { .signal = 0, @@ -703,63 +654,128 @@ static void _rtl_pci_rx_interrupt(struct ieee80211_hw *hw) /*rx pkt */ struct sk_buff *skb = rtlpci->rx_ring[rx_queue_idx].rx_buf[ index]; - struct sk_buff *new_skb = NULL; own = (u8) rtlpriv->cfg->ops->get_desc((u8 *) pdesc, false, HW_DESC_OWN); - /*wait data to be filled by hardware */ - if (own) + if (own) { + /*wait data to be filled by hardware */ break; + } else { + struct ieee80211_hdr *hdr; + __le16 fc; + struct sk_buff *new_skb = NULL; + + rtlpriv->cfg->ops->query_rx_desc(hw, &stats, + &rx_status, + (u8 *) pdesc, skb); + + new_skb = dev_alloc_skb(rtlpci->rxbuffersize); + if (unlikely(!new_skb)) { + RT_TRACE(rtlpriv, (COMP_INTR | COMP_RECV), + DBG_DMESG, + ("can't alloc skb for rx\n")); + goto done; + } - rtlpriv->cfg->ops->query_rx_desc(hw, &stats, - &rx_status, - (u8 *) pdesc, skb); - - if (stats.crc || stats.hwerror) - goto done; - - new_skb = dev_alloc_skb(rtlpci->rxbuffersize); - if (unlikely(!new_skb)) { - RT_TRACE(rtlpriv, (COMP_INTR | COMP_RECV), - DBG_DMESG, - ("can't alloc skb for rx\n")); - goto done; - } - - pci_unmap_single(rtlpci->pdev, - *((dma_addr_t *) skb->cb), - rtlpci->rxbuffersize, - PCI_DMA_FROMDEVICE); + pci_unmap_single(rtlpci->pdev, + *((dma_addr_t *) skb->cb), + rtlpci->rxbuffersize, + PCI_DMA_FROMDEVICE); - skb_put(skb, rtlpriv->cfg->ops->get_desc((u8 *) pdesc, false, - HW_DESC_RXPKT_LEN)); - skb_reserve(skb, stats.rx_drvinfo_size + stats.rx_bufshift); + skb_put(skb, rtlpriv->cfg->ops->get_desc((u8 *) pdesc, + false, + HW_DESC_RXPKT_LEN)); + skb_reserve(skb, + stats.rx_drvinfo_size + stats.rx_bufshift); - /* - * NOTICE This can not be use for mac80211, - * this is done in mac80211 code, - * if you done here sec DHCP will fail - * skb_trim(skb, skb->len - 4); - */ + /* + *NOTICE This can not be use for mac80211, + *this is done in mac80211 code, + *if you done here sec DHCP will fail + *skb_trim(skb, skb->len - 4); + */ - _rtl_receive_one(hw, skb, rx_status); + hdr = rtl_get_hdr(skb); + fc = rtl_get_fc(skb); + + if (!stats.crc && !stats.hwerror) { + memcpy(IEEE80211_SKB_RXCB(skb), &rx_status, + sizeof(rx_status)); + + if (is_broadcast_ether_addr(hdr->addr1)) { + ;/*TODO*/ + } else if (is_multicast_ether_addr(hdr->addr1)) { + ;/*TODO*/ + } else { + unicast = true; + rtlpriv->stats.rxbytesunicast += + skb->len; + } + + rtl_is_special_data(hw, skb, false); + + if (ieee80211_is_data(fc)) { + rtlpriv->cfg->ops->led_control(hw, + LED_CTL_RX); + + if (unicast) + rtlpriv->link_info. + num_rx_inperiod++; + } + + /* for sw lps */ + rtl_swlps_beacon(hw, (void *)skb->data, + skb->len); + rtl_recognize_peer(hw, (void *)skb->data, + skb->len); + if ((rtlpriv->mac80211.opmode == + NL80211_IFTYPE_AP) && + (rtlpriv->rtlhal.current_bandtype == + BAND_ON_2_4G) && + (ieee80211_is_beacon(fc) || + ieee80211_is_probe_resp(fc))) { + dev_kfree_skb_any(skb); + } else { + if (unlikely(!rtl_action_proc(hw, skb, + false))) { + dev_kfree_skb_any(skb); + } else { + struct sk_buff *uskb = NULL; + u8 *pdata; + uskb = dev_alloc_skb(skb->len + + 128); + memcpy(IEEE80211_SKB_RXCB(uskb), + &rx_status, + sizeof(rx_status)); + pdata = (u8 *)skb_put(uskb, + skb->len); + memcpy(pdata, skb->data, + skb->len); + dev_kfree_skb_any(skb); + + ieee80211_rx_irqsafe(hw, uskb); + } + } + } else { + dev_kfree_skb_any(skb); + } - if (((rtlpriv->link_info.num_rx_inperiod + - rtlpriv->link_info.num_tx_inperiod) > 8) || - (rtlpriv->link_info.num_rx_inperiod > 2)) { - tasklet_schedule(&rtlpriv->works.ips_leave_tasklet); - } + if (((rtlpriv->link_info.num_rx_inperiod + + rtlpriv->link_info.num_tx_inperiod) > 8) || + (rtlpriv->link_info.num_rx_inperiod > 2)) { + tasklet_schedule(&rtlpriv->works.ips_leave_tasklet); + } - dev_kfree_skb_any(skb); - skb = new_skb; + skb = new_skb; - rtlpci->rx_ring[rx_queue_idx].rx_buf[index] = skb; - *((dma_addr_t *) skb->cb) = + rtlpci->rx_ring[rx_queue_idx].rx_buf[index] = skb; + *((dma_addr_t *) skb->cb) = pci_map_single(rtlpci->pdev, skb_tail_pointer(skb), rtlpci->rxbuffersize, PCI_DMA_FROMDEVICE); + } done: bufferaddress = (*((dma_addr_t *)skb->cb)); tmp_one = 1; @@ -788,11 +804,15 @@ static irqreturn_t _rtl_pci_interrupt(int irq, void *dev_id) { struct ieee80211_hw *hw = dev_id; struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); unsigned long flags; u32 inta = 0; u32 intb = 0; + if (rtlpci->irq_enabled == 0) + return IRQ_HANDLED; + spin_lock_irqsave(&rtlpriv->locks.irq_th_lock, flags); /*read ISR: 4/8bytes */ @@ -1611,16 +1631,6 @@ static bool _rtl_pci_find_adapter(struct pci_dev *pdev, pci_read_config_byte(pdev, 0x8, &revisionid); pci_read_config_word(pdev, 0x3C, &irqline); - /* PCI ID 0x10ec:0x8192 occurs for both RTL8192E, which uses - * r8192e_pci, and RTL8192SE, which uses this driver. If the - * revision ID is RTL_PCI_REVISION_ID_8192PCIE (0x01), then - * the correct driver is r8192e_pci, thus this routine should - * return false. - */ - if (deviceid == RTL_PCI_8192SE_DID && - revisionid == RTL_PCI_REVISION_ID_8192PCIE) - return false; - if (deviceid == RTL_PCI_8192_DID || deviceid == RTL_PCI_0044_DID || deviceid == RTL_PCI_0047_DID || @@ -1853,8 +1863,7 @@ int __devinit rtl_pci_probe(struct pci_dev *pdev, pci_write_config_byte(pdev, 0x04, 0x07); /* find adapter */ - if (!_rtl_pci_find_adapter(pdev, hw)) - goto fail3; + _rtl_pci_find_adapter(pdev, hw); /* Init IO handler */ _rtl_pci_io_handler_init(&pdev->dev, hw); diff --git a/trunk/drivers/net/wireless/rtlwifi/pci.h b/trunk/drivers/net/wireless/rtlwifi/pci.h index c53c62046747..671b1f5aa0cf 100644 --- a/trunk/drivers/net/wireless/rtlwifi/pci.h +++ b/trunk/drivers/net/wireless/rtlwifi/pci.h @@ -62,6 +62,12 @@ .subdevice = PCI_ANY_ID,\ .driver_data = (kernel_ulong_t)&(cfg) +#define INTEL_VENDOR_ID 0x8086 +#define SIS_VENDOR_ID 0x1039 +#define ATI_VENDOR_ID 0x1002 +#define ATI_DEVICE_ID 0x7914 +#define AMD_VENDOR_ID 0x1022 + #define PCI_MAX_BRIDGE_NUMBER 255 #define PCI_MAX_DEVICES 32 #define PCI_MAX_FUNCTION 8 @@ -69,6 +75,11 @@ #define PCI_CONF_ADDRESS 0x0CF8 /*PCI Configuration Space Address */ #define PCI_CONF_DATA 0x0CFC /*PCI Configuration Space Data */ +#define PCI_CLASS_BRIDGE_DEV 0x06 +#define PCI_SUBCLASS_BR_PCI_TO_PCI 0x04 +#define PCI_CAPABILITY_ID_PCI_EXPRESS 0x10 +#define PCI_CAP_ID_EXP 0x10 + #define U1DONTCARE 0xFF #define U2DONTCARE 0xFFFF #define U4DONTCARE 0xFFFFFFFF @@ -158,6 +169,7 @@ struct rtl_pci { bool first_init; bool being_init_adapter; bool init_ready; + bool irq_enabled; /*Tx */ struct rtl8192_tx_ring tx_ring[RTL_PCI_MAX_TX_QUEUE_COUNT]; diff --git a/trunk/drivers/net/wireless/rtlwifi/ps.c b/trunk/drivers/net/wireless/rtlwifi/ps.c index a693feffbe72..d14c13d02177 100644 --- a/trunk/drivers/net/wireless/rtlwifi/ps.c +++ b/trunk/drivers/net/wireless/rtlwifi/ps.c @@ -79,18 +79,59 @@ EXPORT_SYMBOL(rtl_ps_disable_nic); bool rtl_ps_set_rf_state(struct ieee80211_hw *hw, enum rf_pwrstate state_toset, - u32 changesource) + u32 changesource, bool protect_or_not) { struct rtl_priv *rtlpriv = rtl_priv(hw); struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); bool actionallowed = false; + u16 rfwait_cnt = 0; + /*protect_or_not = true; */ + + if (protect_or_not) + goto no_protect; + + /* + *Only one thread can change + *the RF state at one time, and others + *should wait to be executed. + */ + while (true) { + spin_lock(&rtlpriv->locks.rf_ps_lock); + if (ppsc->rfchange_inprogress) { + spin_unlock(&rtlpriv->locks.rf_ps_lock); + + RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, + ("RF Change in progress!" + "Wait to set..state_toset(%d).\n", + state_toset)); + + /* Set RF after the previous action is done. */ + while (ppsc->rfchange_inprogress) { + rfwait_cnt++; + mdelay(1); + + /* + *Wait too long, return false to avoid + *to be stuck here. + */ + if (rfwait_cnt > 100) + return false; + } + } else { + ppsc->rfchange_inprogress = true; + spin_unlock(&rtlpriv->locks.rf_ps_lock); + break; + } + } + +no_protect: switch (state_toset) { case ERFON: ppsc->rfoff_reason &= (~changesource); if ((changesource == RF_CHANGE_BY_HW) && - (ppsc->hwradiooff)) { + (ppsc->hwradiooff == true)) { ppsc->hwradiooff = false; } @@ -126,6 +167,12 @@ bool rtl_ps_set_rf_state(struct ieee80211_hw *hw, if (actionallowed) rtlpriv->cfg->ops->set_rf_power_state(hw, state_toset); + if (!protect_or_not) { + spin_lock(&rtlpriv->locks.rf_ps_lock); + ppsc->rfchange_inprogress = false; + spin_unlock(&rtlpriv->locks.rf_ps_lock); + } + return actionallowed; } EXPORT_SYMBOL(rtl_ps_set_rf_state); @@ -148,7 +195,8 @@ static void _rtl_ps_inactive_ps(struct ieee80211_hw *hw) } } - rtl_ps_set_rf_state(hw, ppsc->inactive_pwrstate, RF_CHANGE_BY_IPS); + rtl_ps_set_rf_state(hw, ppsc->inactive_pwrstate, + RF_CHANGE_BY_IPS, false); if (ppsc->inactive_pwrstate == ERFOFF && rtlhal->interface == INTF_PCI) { @@ -539,7 +587,7 @@ void rtl_swlps_rf_awake(struct ieee80211_hw *hw) } spin_lock(&rtlpriv->locks.lps_lock); - rtl_ps_set_rf_state(hw, ERFON, RF_CHANGE_BY_PS); + rtl_ps_set_rf_state(hw, ERFON, RF_CHANGE_BY_PS, false); spin_unlock(&rtlpriv->locks.lps_lock); } @@ -573,8 +621,15 @@ void rtl_swlps_rf_sleep(struct ieee80211_hw *hw) if (rtlpriv->link_info.busytraffic) return; + spin_lock(&rtlpriv->locks.rf_ps_lock); + if (rtlpriv->psc.rfchange_inprogress) { + spin_unlock(&rtlpriv->locks.rf_ps_lock); + return; + } + spin_unlock(&rtlpriv->locks.rf_ps_lock); + spin_lock(&rtlpriv->locks.lps_lock); - rtl_ps_set_rf_state(hw, ERFSLEEP, RF_CHANGE_BY_PS); + rtl_ps_set_rf_state(hw, ERFSLEEP, RF_CHANGE_BY_PS, false); spin_unlock(&rtlpriv->locks.lps_lock); if (ppsc->reg_rfps_level & RT_RF_OFF_LEVL_ASPM && diff --git a/trunk/drivers/net/wireless/rtlwifi/ps.h b/trunk/drivers/net/wireless/rtlwifi/ps.h index 84628e6041c7..e3bf89840370 100644 --- a/trunk/drivers/net/wireless/rtlwifi/ps.h +++ b/trunk/drivers/net/wireless/rtlwifi/ps.h @@ -33,7 +33,8 @@ #define MAX_SW_LPS_SLEEP_INTV 5 bool rtl_ps_set_rf_state(struct ieee80211_hw *hw, - enum rf_pwrstate state_toset, u32 changesource); + enum rf_pwrstate state_toset, u32 changesource, + bool protect_or_not); bool rtl_ps_enable_nic(struct ieee80211_hw *hw); bool rtl_ps_disable_nic(struct ieee80211_hw *hw); void rtl_ips_nic_off(struct ieee80211_hw *hw); diff --git a/trunk/drivers/net/wireless/rtlwifi/rc.c b/trunk/drivers/net/wireless/rtlwifi/rc.c index 539df66dce0a..30da68a77786 100644 --- a/trunk/drivers/net/wireless/rtlwifi/rc.c +++ b/trunk/drivers/net/wireless/rtlwifi/rc.c @@ -200,7 +200,7 @@ static void rtl_tx_status(void *ppriv, if (sta) { /* Check if aggregation has to be enabled for this tid */ sta_entry = (struct rtl_sta_info *) sta->drv_priv; - if ((sta->ht_cap.ht_supported) && + if ((sta->ht_cap.ht_supported == true) && !(skb->protocol == cpu_to_be16(ETH_P_PAE))) { if (ieee80211_is_data_qos(fc)) { u8 tid = rtl_get_tid(skb); diff --git a/trunk/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c b/trunk/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c index a00774e7090d..97183829b9be 100644 --- a/trunk/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c +++ b/trunk/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c @@ -474,7 +474,7 @@ static void rtl92c_dm_ctrl_initgain_by_twoport(struct ieee80211_hw *hw) { struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); - if (mac->act_scanning) + if (mac->act_scanning == true) return; if (mac->link_state >= MAC80211_LINKED) @@ -670,7 +670,7 @@ static void rtl92c_dm_txpower_tracking_callback_thermalmeter(struct ieee80211_hw u8 ofdm_index[2], cck_index = 0, ofdm_index_old[2], cck_index_old = 0; int i; bool is2t = IS_92C_SERIAL(rtlhal->version); - s8 txpwr_level[2] = {0, 0}; + u8 txpwr_level[2] = {0, 0}; u8 ofdm_min_index = 6, rf; rtlpriv->dm.txpower_trackinginit = true; diff --git a/trunk/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c b/trunk/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c index 9e2a9e34a699..944f55e9d316 100644 --- a/trunk/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c +++ b/trunk/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c @@ -488,7 +488,7 @@ void rtl92ce_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val) case HW_VAR_CORRECT_TSF:{ u8 btype_ibss = ((u8 *) (val))[0]; - if (btype_ibss) + if (btype_ibss == true) _rtl92ce_stop_tx_beacon(hw); _rtl92ce_set_bcn_ctrl_reg(hw, 0, BIT(3)); @@ -500,7 +500,7 @@ void rtl92ce_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val) _rtl92ce_set_bcn_ctrl_reg(hw, BIT(3), 0); - if (btype_ibss) + if (btype_ibss == true) _rtl92ce_resume_tx_beacon(hw); break; @@ -1121,7 +1121,7 @@ void rtl92ce_set_check_bssid(struct ieee80211_hw *hw, bool check_bssid) if (rtlpriv->psc.rfpwr_state != ERFON) return; - if (check_bssid) { + if (check_bssid == true) { reg_rcr |= (RCR_CBSSID_DATA | RCR_CBSSID_BCN); rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_RCR, (u8 *) (®_rcr)); @@ -1183,6 +1183,7 @@ void rtl92ce_enable_interrupt(struct ieee80211_hw *hw) rtl_write_dword(rtlpriv, REG_HIMR, rtlpci->irq_mask[0] & 0xFFFFFFFF); rtl_write_dword(rtlpriv, REG_HIMRE, rtlpci->irq_mask[1] & 0xFFFFFFFF); + rtlpci->irq_enabled = true; } void rtl92ce_disable_interrupt(struct ieee80211_hw *hw) @@ -1192,6 +1193,7 @@ void rtl92ce_disable_interrupt(struct ieee80211_hw *hw) rtl_write_dword(rtlpriv, REG_HIMR, IMR8190_DISABLED); rtl_write_dword(rtlpriv, REG_HIMRE, IMR8190_DISABLED); + rtlpci->irq_enabled = false; synchronize_irq(rtlpci->pdev->irq); } @@ -1583,7 +1585,7 @@ static void _rtl92ce_read_adapter_info(struct ieee80211_hw *hw) rtlefuse->autoload_failflag = false; } - if (rtlefuse->autoload_failflag) + if (rtlefuse->autoload_failflag == true) return; for (i = 0; i < 6; i += 2) { @@ -1992,7 +1994,7 @@ bool rtl92ce_gpio_radio_on_off_checking(struct ieee80211_hw *hw, u8 *valid) u1tmp = rtl_read_byte(rtlpriv, REG_GPIO_IO_SEL); e_rfpowerstate_toset = (u1tmp & BIT(3)) ? ERFON : ERFOFF; - if ((ppsc->hwradiooff) && (e_rfpowerstate_toset == ERFON)) { + if ((ppsc->hwradiooff == true) && (e_rfpowerstate_toset == ERFON)) { RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG, ("GPIOChangeRF - HW Radio ON, RF ON\n")); diff --git a/trunk/drivers/net/wireless/rtlwifi/rtl8192ce/led.c b/trunk/drivers/net/wireless/rtlwifi/rtl8192ce/led.c index 28a1a707d09c..9dd1ed7b6422 100644 --- a/trunk/drivers/net/wireless/rtlwifi/rtl8192ce/led.c +++ b/trunk/drivers/net/wireless/rtlwifi/rtl8192ce/led.c @@ -84,7 +84,7 @@ void rtl92ce_sw_led_off(struct ieee80211_hw *hw, struct rtl_led *pled) break; case LED_PIN_LED0: ledcfg &= 0xf0; - if (pcipriv->ledctl.led_opendrain) + if (pcipriv->ledctl.led_opendrain == true) rtl_write_byte(rtlpriv, REG_LEDCFG2, (ledcfg | BIT(1) | BIT(5) | BIT(6))); else diff --git a/trunk/drivers/net/wireless/rtlwifi/rtl8192ce/reg.h b/trunk/drivers/net/wireless/rtlwifi/rtl8192ce/reg.h index 72a3d5497547..598cecc63f41 100644 --- a/trunk/drivers/net/wireless/rtlwifi/rtl8192ce/reg.h +++ b/trunk/drivers/net/wireless/rtlwifi/rtl8192ce/reg.h @@ -1203,9 +1203,7 @@ #define EPROM_CMD_CONFIG 0x3 #define EPROM_CMD_LOAD 1 -#define HWSET_MAX_SIZE 128 #define HWSET_MAX_SIZE_92S HWSET_MAX_SIZE -#define EFUSE_MAX_SECTION 16 #define WL_HWPDN_EN BIT(0) diff --git a/trunk/drivers/net/wireless/rtlwifi/rtl8192ce/rf.c b/trunk/drivers/net/wireless/rtlwifi/rtl8192ce/rf.c index d3b01e6023ba..90d0f2cf3b27 100644 --- a/trunk/drivers/net/wireless/rtlwifi/rtl8192ce/rf.c +++ b/trunk/drivers/net/wireless/rtlwifi/rtl8192ce/rf.c @@ -76,7 +76,7 @@ void rtl92ce_phy_rf6052_set_cck_txpower(struct ieee80211_hw *hw, if (rtlefuse->eeprom_regulatory != 0) turbo_scanoff = true; - if (mac->act_scanning) { + if (mac->act_scanning == true) { tx_agc[RF90_PATH_A] = 0x3f3f3f3f; tx_agc[RF90_PATH_B] = 0x3f3f3f3f; diff --git a/trunk/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c b/trunk/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c index 230bbe900d8d..2492cc234c03 100644 --- a/trunk/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c +++ b/trunk/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c @@ -225,7 +225,7 @@ static void _rtl92ce_query_rxphystatus(struct ieee80211_hw *hw, { struct rtl_priv *rtlpriv = rtl_priv(hw); struct phy_sts_cck_8192s_t *cck_buf; - s8 rx_pwr_all = 0, rx_pwr[4]; + s8 rx_pwr_all, rx_pwr[4]; u8 evm, pwdb_all, rf_rx_num = 0; u8 i, max_spatial_stream; u32 rssi, total_rssi = 0; @@ -678,7 +678,7 @@ bool rtl92ce_rx_query_desc(struct ieee80211_hw *hw, GET_RX_DESC_PAGGR(pdesc)); rx_status->mactime = GET_RX_DESC_TSFL(pdesc); - if (phystatus) { + if (phystatus == true) { p_drvinfo = (struct rx_fwinfo_92c *)(skb->data + stats->rx_bufshift); @@ -927,7 +927,7 @@ void rtl92ce_tx_fill_cmddesc(struct ieee80211_hw *hw, void rtl92ce_set_desc(u8 *pdesc, bool istx, u8 desc_name, u8 *val) { - if (istx) { + if (istx == true) { switch (desc_name) { case HW_DESC_OWN: wmb(); @@ -968,7 +968,7 @@ u32 rtl92ce_get_desc(u8 *p_desc, bool istx, u8 desc_name) { u32 ret = 0; - if (istx) { + if (istx == true) { switch (desc_name) { case HW_DESC_OWN: ret = GET_TX_DESC_OWN(p_desc); diff --git a/trunk/drivers/net/wireless/rtlwifi/rtl8192cu/hw.c b/trunk/drivers/net/wireless/rtlwifi/rtl8192cu/hw.c index 2b34764fbf73..52e2af58c1ed 100644 --- a/trunk/drivers/net/wireless/rtlwifi/rtl8192cu/hw.c +++ b/trunk/drivers/net/wireless/rtlwifi/rtl8192cu/hw.c @@ -520,7 +520,7 @@ static void _rtl92cu_read_adapter_info(struct ieee80211_hw *hw) RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, ("Autoload OK\n")); rtlefuse->autoload_failflag = false; } - if (rtlefuse->autoload_failflag) + if (rtlefuse->autoload_failflag == true) return; for (i = 0; i < 6; i += 2) { usvalue = *(u16 *)&hwinfo[EEPROM_MAC_ADDR + i]; @@ -1594,7 +1594,7 @@ static void _rtl92cu_set_check_bssid(struct ieee80211_hw *hw, default: break; } - if (filterout_non_associated_bssid) { + if (filterout_non_associated_bssid == true) { if (IS_NORMAL_CHIP(rtlhal->version)) { switch (rtlphy->current_io_type) { case IO_CMD_RESUME_DM_BY_SCAN: @@ -2155,7 +2155,7 @@ void rtl92cu_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val) case HW_VAR_CORRECT_TSF:{ u8 btype_ibss = ((u8 *) (val))[0]; - if (btype_ibss) + if (btype_ibss == true) _rtl92cu_stop_tx_beacon(hw); _rtl92cu_set_bcn_ctrl_reg(hw, 0, BIT(3)); rtl_write_dword(rtlpriv, REG_TSFTR, (u32)(mac->tsf & @@ -2163,7 +2163,7 @@ void rtl92cu_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val) rtl_write_dword(rtlpriv, REG_TSFTR + 4, (u32)((mac->tsf >> 32) & 0xffffffff)); _rtl92cu_set_bcn_ctrl_reg(hw, BIT(3), 0); - if (btype_ibss) + if (btype_ibss == true) _rtl92cu_resume_tx_beacon(hw); break; } diff --git a/trunk/drivers/net/wireless/rtlwifi/rtl8192cu/led.c b/trunk/drivers/net/wireless/rtlwifi/rtl8192cu/led.c index 2ff9d8314e7b..332c74348a69 100644 --- a/trunk/drivers/net/wireless/rtlwifi/rtl8192cu/led.c +++ b/trunk/drivers/net/wireless/rtlwifi/rtl8192cu/led.c @@ -82,7 +82,7 @@ void rtl92cu_sw_led_off(struct ieee80211_hw *hw, struct rtl_led *pled) break; case LED_PIN_LED0: ledcfg &= 0xf0; - if (usbpriv->ledctl.led_opendrain) + if (usbpriv->ledctl.led_opendrain == true) rtl_write_byte(rtlpriv, REG_LEDCFG2, (ledcfg | BIT(1) | BIT(5) | BIT(6))); else diff --git a/trunk/drivers/net/wireless/rtlwifi/rtl8192cu/mac.c b/trunk/drivers/net/wireless/rtlwifi/rtl8192cu/mac.c index a90c09b42390..4e057df6f488 100644 --- a/trunk/drivers/net/wireless/rtlwifi/rtl8192cu/mac.c +++ b/trunk/drivers/net/wireless/rtlwifi/rtl8192cu/mac.c @@ -380,11 +380,13 @@ void rtl92c_enable_interrupt(struct ieee80211_hw *hw) 0xFFFFFFFF); rtl_write_dword(rtlpriv, REG_HIMRE, rtlpci->irq_mask[1] & 0xFFFFFFFF); + rtlpci->irq_enabled = true; } else { rtl_write_dword(rtlpriv, REG_HIMR, rtlusb->irq_mask[0] & 0xFFFFFFFF); rtl_write_dword(rtlpriv, REG_HIMRE, rtlusb->irq_mask[1] & 0xFFFFFFFF); + rtlusb->irq_enabled = true; } } @@ -396,9 +398,16 @@ void rtl92c_init_interrupt(struct ieee80211_hw *hw) void rtl92c_disable_interrupt(struct ieee80211_hw *hw) { struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); + struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); + struct rtl_usb *rtlusb = rtl_usbdev(rtl_usbpriv(hw)); rtl_write_dword(rtlpriv, REG_HIMR, IMR8190_DISABLED); rtl_write_dword(rtlpriv, REG_HIMRE, IMR8190_DISABLED); + if (IS_HARDWARE_TYPE_8192CE(rtlhal)) + rtlpci->irq_enabled = false; + else if (IS_HARDWARE_TYPE_8192CU(rtlhal)) + rtlusb->irq_enabled = false; } void rtl92c_set_qos(struct ieee80211_hw *hw, int aci) diff --git a/trunk/drivers/net/wireless/rtlwifi/rtl8192cu/rf.c b/trunk/drivers/net/wireless/rtlwifi/rtl8192cu/rf.c index 1e851aae58db..c7576ec4744e 100644 --- a/trunk/drivers/net/wireless/rtlwifi/rtl8192cu/rf.c +++ b/trunk/drivers/net/wireless/rtlwifi/rtl8192cu/rf.c @@ -82,7 +82,7 @@ void rtl92cu_phy_rf6052_set_cck_txpower(struct ieee80211_hw *hw, (rtlefuse->external_pa)) turbo_scanoff = true; } - if (mac->act_scanning) { + if (mac->act_scanning == true) { tx_agc[RF90_PATH_A] = 0x3f3f3f3f; tx_agc[RF90_PATH_B] = 0x3f3f3f3f; if (turbo_scanoff) { diff --git a/trunk/drivers/net/wireless/rtlwifi/rtl8192cu/sw.c b/trunk/drivers/net/wireless/rtlwifi/rtl8192cu/sw.c index 942f7a3969a7..bee7c1480f63 100644 --- a/trunk/drivers/net/wireless/rtlwifi/rtl8192cu/sw.c +++ b/trunk/drivers/net/wireless/rtlwifi/rtl8192cu/sw.c @@ -53,8 +53,6 @@ MODULE_FIRMWARE("rtlwifi/rtl8192cufw.bin"); static int rtl92cu_init_sw_vars(struct ieee80211_hw *hw) { struct rtl_priv *rtlpriv = rtl_priv(hw); - const struct firmware *firmware; - int err; rtlpriv->dm.dm_initialgain_enable = 1; rtlpriv->dm.dm_flag = 0; @@ -66,24 +64,6 @@ static int rtl92cu_init_sw_vars(struct ieee80211_hw *hw) ("Can't alloc buffer for fw.\n")); return 1; } - /* request fw */ - err = request_firmware(&firmware, rtlpriv->cfg->fw_name, - rtlpriv->io.dev); - if (err) { - RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("Failed to request firmware!\n")); - return 1; - } - if (firmware->size > 0x4000) { - RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("Firmware is too big!\n")); - release_firmware(firmware); - return 1; - } - memcpy(rtlpriv->rtlhal.pfirmware, firmware->data, firmware->size); - rtlpriv->rtlhal.fwsize = firmware->size; - release_firmware(firmware); - return 0; } @@ -298,7 +278,6 @@ static struct usb_device_id rtl8192c_usb_ids[] = { {RTL_USB_DEVICE(0x06f8, 0xe033, rtl92cu_hal_cfg)}, /*Hercules - Edimax*/ {RTL_USB_DEVICE(0x07b8, 0x8188, rtl92cu_hal_cfg)}, /*Abocom - Abocom*/ {RTL_USB_DEVICE(0x07b8, 0x8189, rtl92cu_hal_cfg)}, /*Funai - Abocom*/ - {RTL_USB_DEVICE(0x0846, 0x9041, rtl92cu_hal_cfg)}, /*NetGear WNA1000M*/ {RTL_USB_DEVICE(0x0Df6, 0x0052, rtl92cu_hal_cfg)}, /*Sitecom - Edimax*/ {RTL_USB_DEVICE(0x0eb0, 0x9071, rtl92cu_hal_cfg)}, /*NO Brand - Etop*/ /* HP - Lite-On ,8188CUS Slim Combo */ diff --git a/trunk/drivers/net/wireless/rtlwifi/rtl8192cu/trx.c b/trunk/drivers/net/wireless/rtlwifi/rtl8192cu/trx.c index 906e7aa55bc3..3a92ba3c4a1e 100644 --- a/trunk/drivers/net/wireless/rtlwifi/rtl8192cu/trx.c +++ b/trunk/drivers/net/wireless/rtlwifi/rtl8192cu/trx.c @@ -342,7 +342,7 @@ bool rtl92cu_rx_query_desc(struct ieee80211_hw *hw, (u8)GET_RX_DESC_RX_MCS(pdesc), (bool)GET_RX_DESC_PAGGR(pdesc)); rx_status->mactime = GET_RX_DESC_TSFL(pdesc); - if (phystatus) { + if (phystatus == true) { p_drvinfo = (struct rx_fwinfo_92c *)(pdesc + RTL_RX_DESC_SIZE); rtl92c_translate_rx_signal_stuff(hw, skb, stats, pdesc, p_drvinfo); diff --git a/trunk/drivers/net/wireless/rtlwifi/rtl8192de/Makefile b/trunk/drivers/net/wireless/rtlwifi/rtl8192de/Makefile deleted file mode 100644 index e3213c8264b6..000000000000 --- a/trunk/drivers/net/wireless/rtlwifi/rtl8192de/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -rtl8192de-objs := \ - dm.o \ - fw.o \ - hw.o \ - led.o \ - phy.o \ - rf.o \ - sw.o \ - table.o \ - trx.o - -obj-$(CONFIG_RTL8192DE) += rtl8192de.o - -ccflags-y += -D__CHECK_ENDIAN__ diff --git a/trunk/drivers/net/wireless/rtlwifi/rtl8192de/def.h b/trunk/drivers/net/wireless/rtlwifi/rtl8192de/def.h deleted file mode 100644 index f0f5f9bfbb7b..000000000000 --- a/trunk/drivers/net/wireless/rtlwifi/rtl8192de/def.h +++ /dev/null @@ -1,269 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2009-2010 Realtek Corporation. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * The full GNU General Public License is included in this distribution in the - * file called LICENSE. - * - * Contact Information: - * wlanfae - * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, - * Hsinchu 300, Taiwan. - * - * Larry Finger - * - *****************************************************************************/ - -#ifndef __RTL92D_DEF_H__ -#define __RTL92D_DEF_H__ - -/* Min Spacing related settings. */ -#define MAX_MSS_DENSITY_2T 0x13 -#define MAX_MSS_DENSITY_1T 0x0A - -#define RF6052_MAX_TX_PWR 0x3F -#define RF6052_MAX_REG 0x3F -#define RF6052_MAX_PATH 2 - -#define HAL_RETRY_LIMIT_INFRA 48 -#define HAL_RETRY_LIMIT_AP_ADHOC 7 - -#define PHY_RSSI_SLID_WIN_MAX 100 -#define PHY_LINKQUALITY_SLID_WIN_MAX 20 -#define PHY_BEACON_RSSI_SLID_WIN_MAX 10 - -#define RESET_DELAY_8185 20 - -#define RT_IBSS_INT_MASKS (IMR_BCNINT | IMR_TBDOK | IMR_TBDER) -#define RT_AC_INT_MASKS (IMR_VIDOK | IMR_VODOK | IMR_BEDOK|IMR_BKDOK) - -#define NUM_OF_FIRMWARE_QUEUE 10 -#define NUM_OF_PAGES_IN_FW 0x100 -#define NUM_OF_PAGE_IN_FW_QUEUE_BK 0x07 -#define NUM_OF_PAGE_IN_FW_QUEUE_BE 0x07 -#define NUM_OF_PAGE_IN_FW_QUEUE_VI 0x07 -#define NUM_OF_PAGE_IN_FW_QUEUE_VO 0x07 -#define NUM_OF_PAGE_IN_FW_QUEUE_HCCA 0x0 -#define NUM_OF_PAGE_IN_FW_QUEUE_CMD 0x0 -#define NUM_OF_PAGE_IN_FW_QUEUE_MGNT 0x02 -#define NUM_OF_PAGE_IN_FW_QUEUE_HIGH 0x02 -#define NUM_OF_PAGE_IN_FW_QUEUE_BCN 0x2 -#define NUM_OF_PAGE_IN_FW_QUEUE_PUB 0xA1 - -#define NUM_OF_PAGE_IN_FW_QUEUE_BK_DTM 0x026 -#define NUM_OF_PAGE_IN_FW_QUEUE_BE_DTM 0x048 -#define NUM_OF_PAGE_IN_FW_QUEUE_VI_DTM 0x048 -#define NUM_OF_PAGE_IN_FW_QUEUE_VO_DTM 0x026 -#define NUM_OF_PAGE_IN_FW_QUEUE_PUB_DTM 0x00 - -#define MAX_LINES_HWCONFIG_TXT 1000 -#define MAX_BYTES_LINE_HWCONFIG_TXT 256 - -#define SW_THREE_WIRE 0 -#define HW_THREE_WIRE 2 - -#define BT_DEMO_BOARD 0 -#define BT_QA_BOARD 1 -#define BT_FPGA 2 - -#define RX_SMOOTH_FACTOR 20 - -#define HAL_PRIME_CHNL_OFFSET_DONT_CARE 0 -#define HAL_PRIME_CHNL_OFFSET_LOWER 1 -#define HAL_PRIME_CHNL_OFFSET_UPPER 2 - -#define MAX_H2C_QUEUE_NUM 10 - -#define RX_MPDU_QUEUE 0 -#define RX_CMD_QUEUE 1 -#define RX_MAX_QUEUE 2 - -#define C2H_RX_CMD_HDR_LEN 8 -#define GET_C2H_CMD_CMD_LEN(__prxhdr) \ - LE_BITS_TO_4BYTE((__prxhdr), 0, 16) -#define GET_C2H_CMD_ELEMENT_ID(__prxhdr) \ - LE_BITS_TO_4BYTE((__prxhdr), 16, 8) -#define GET_C2H_CMD_CMD_SEQ(__prxhdr) \ - LE_BITS_TO_4BYTE((__prxhdr), 24, 7) -#define GET_C2H_CMD_CONTINUE(__prxhdr) \ - LE_BITS_TO_4BYTE((__prxhdr), 31, 1) -#define GET_C2H_CMD_CONTENT(__prxhdr) \ - ((u8 *)(__prxhdr) + C2H_RX_CMD_HDR_LEN) - -#define GET_C2H_CMD_FEEDBACK_ELEMENT_ID(__pcmdfbhdr) \ - LE_BITS_TO_4BYTE((__pcmdfbhdr), 0, 8) -#define GET_C2H_CMD_FEEDBACK_CCX_LEN(__pcmdfbhdr) \ - LE_BITS_TO_4BYTE((__pcmdfbhdr), 8, 8) -#define GET_C2H_CMD_FEEDBACK_CCX_CMD_CNT(__pcmdfbhdr) \ - LE_BITS_TO_4BYTE((__pcmdfbhdr), 16, 16) -#define GET_C2H_CMD_FEEDBACK_CCX_MAC_ID(__pcmdfbhdr) \ - LE_BITS_TO_4BYTE(((__pcmdfbhdr) + 4), 0, 5) -#define GET_C2H_CMD_FEEDBACK_CCX_VALID(__pcmdfbhdr) \ - LE_BITS_TO_4BYTE(((__pcmdfbhdr) + 4), 7, 1) -#define GET_C2H_CMD_FEEDBACK_CCX_RETRY_CNT(__pcmdfbhdr) \ - LE_BITS_TO_4BYTE(((__pcmdfbhdr) + 4), 8, 5) -#define GET_C2H_CMD_FEEDBACK_CCX_TOK(__pcmdfbhdr) \ - LE_BITS_TO_4BYTE(((__pcmdfbhdr) + 4), 15, 1) -#define GET_C2H_CMD_FEEDBACK_CCX_QSEL(__pcmdfbhdr) \ - LE_BITS_TO_4BYTE(((__pcmdfbhdr) + 4), 16, 4) -#define GET_C2H_CMD_FEEDBACK_CCX_SEQ(__pcmdfbhdr) \ - LE_BITS_TO_4BYTE(((__pcmdfbhdr) + 4), 20, 12) - -/* - * 92D chip ver: - * BIT8: IS 92D - * BIT9: single phy - * BIT10: C-cut - * BIT11: D-cut - */ - -/* Chip specific */ -#define CHIP_92C BIT(0) -#define CHIP_92C_1T2R BIT(1) -#define CHIP_8723 BIT(2) /* RTL8723 With BT feature */ -#define CHIP_8723_DRV_REV BIT(3) /* RTL8723 Driver Revised */ -#define NORMAL_CHIP BIT(4) -#define CHIP_VENDOR_UMC BIT(5) -#define CHIP_VENDOR_UMC_B_CUT BIT(6) /* Chip version for ECO */ - -/* for 92D */ -#define CHIP_92D BIT(8) -#define CHIP_92D_SINGLEPHY BIT(9) -#define CHIP_92D_C_CUT BIT(10) -#define CHIP_92D_D_CUT BIT(11) - -enum version_8192d { - VERSION_TEST_CHIP_88C = 0x00, - VERSION_TEST_CHIP_92C = 0x01, - VERSION_NORMAL_TSMC_CHIP_88C = 0x10, - VERSION_NORMAL_TSMC_CHIP_92C = 0x11, - VERSION_NORMAL_TSMC_CHIP_92C_1T2R = 0x13, - VERSION_NORMAL_UMC_CHIP_88C_A_CUT = 0x30, - VERSION_NORMAL_UMC_CHIP_92C_A_CUT = 0x31, - VERSION_NORMAL_UMC_CHIP_92C_1T2R_A_CUT = 0x33, - VERSION_NORMA_UMC_CHIP_8723_1T1R_A_CUT = 0x34, - VERSION_NORMA_UMC_CHIP_8723_1T1R_B_CUT = 0x3c, - VERSION_NORMAL_UMC_CHIP_88C_B_CUT = 0x70, - VERSION_NORMAL_UMC_CHIP_92C_B_CUT = 0x71, - VERSION_NORMAL_UMC_CHIP_92C_1T2R_B_CUT = 0x73, - VERSION_TEST_CHIP_92D_SINGLEPHY = 0x300, - VERSION_TEST_CHIP_92D_DUALPHY = 0x100, - VERSION_NORMAL_CHIP_92D_SINGLEPHY = 0x310, - VERSION_NORMAL_CHIP_92D_DUALPHY = 0x110, - VERSION_NORMAL_CHIP_92D_C_CUT_SINGLEPHY = 0x710, - VERSION_NORMAL_CHIP_92D_C_CUT_DUALPHY = 0x510, - VERSION_NORMAL_CHIP_92D_D_CUT_SINGLEPHY = 0xB10, - VERSION_NORMAL_CHIP_92D_D_CUT_DUALPHY = 0x910, -}; - -#define IS_92D_SINGLEPHY(version) \ - ((version & CHIP_92D_SINGLEPHY) ? true : false) -#define IS_92D_C_CUT(version) \ - ((version & CHIP_92D_C_CUT) ? true : false) -#define IS_92D_D_CUT(version) \ - ((version & CHIP_92D_D_CUT) ? true : false) - -enum rf_optype { - RF_OP_BY_SW_3WIRE = 0, - RF_OP_BY_FW, - RF_OP_MAX -}; - -enum rtl_desc_qsel { - QSLT_BK = 0x2, - QSLT_BE = 0x0, - QSLT_VI = 0x5, - QSLT_VO = 0x7, - QSLT_BEACON = 0x10, - QSLT_HIGH = 0x11, - QSLT_MGNT = 0x12, - QSLT_CMD = 0x13, -}; - -enum rtl_desc92d_rate { - DESC92D_RATE1M = 0x00, - DESC92D_RATE2M = 0x01, - DESC92D_RATE5_5M = 0x02, - DESC92D_RATE11M = 0x03, - - DESC92D_RATE6M = 0x04, - DESC92D_RATE9M = 0x05, - DESC92D_RATE12M = 0x06, - DESC92D_RATE18M = 0x07, - DESC92D_RATE24M = 0x08, - DESC92D_RATE36M = 0x09, - DESC92D_RATE48M = 0x0a, - DESC92D_RATE54M = 0x0b, - - DESC92D_RATEMCS0 = 0x0c, - DESC92D_RATEMCS1 = 0x0d, - DESC92D_RATEMCS2 = 0x0e, - DESC92D_RATEMCS3 = 0x0f, - DESC92D_RATEMCS4 = 0x10, - DESC92D_RATEMCS5 = 0x11, - DESC92D_RATEMCS6 = 0x12, - DESC92D_RATEMCS7 = 0x13, - DESC92D_RATEMCS8 = 0x14, - DESC92D_RATEMCS9 = 0x15, - DESC92D_RATEMCS10 = 0x16, - DESC92D_RATEMCS11 = 0x17, - DESC92D_RATEMCS12 = 0x18, - DESC92D_RATEMCS13 = 0x19, - DESC92D_RATEMCS14 = 0x1a, - DESC92D_RATEMCS15 = 0x1b, - DESC92D_RATEMCS15_SG = 0x1c, - DESC92D_RATEMCS32 = 0x20, -}; - -enum channel_plan { - CHPL_FCC = 0, - CHPL_IC = 1, - CHPL_ETSI = 2, - CHPL_SPAIN = 3, - CHPL_FRANCE = 4, - CHPL_MKK = 5, - CHPL_MKK1 = 6, - CHPL_ISRAEL = 7, - CHPL_TELEC = 8, - CHPL_GLOBAL = 9, - CHPL_WORLD = 10, -}; - -struct phy_sts_cck_8192d { - u8 adc_pwdb_X[4]; - u8 sq_rpt; - u8 cck_agc_rpt; -}; - -struct h2c_cmd_8192c { - u8 element_id; - u32 cmd_len; - u8 *p_cmdbuffer; -}; - -struct txpower_info { - u8 cck_index[RF6052_MAX_PATH][CHANNEL_GROUP_MAX]; - u8 ht40_1sindex[RF6052_MAX_PATH][CHANNEL_GROUP_MAX]; - u8 ht40_2sindexdiff[RF6052_MAX_PATH][CHANNEL_GROUP_MAX]; - u8 ht20indexdiff[RF6052_MAX_PATH][CHANNEL_GROUP_MAX]; - u8 ofdmindexdiff[RF6052_MAX_PATH][CHANNEL_GROUP_MAX]; - u8 ht40maxoffset[RF6052_MAX_PATH][CHANNEL_GROUP_MAX]; - u8 ht20maxoffset[RF6052_MAX_PATH][CHANNEL_GROUP_MAX]; - u8 tssi_a[3]; /* 5GL/5GM/5GH */ - u8 tssi_b[3]; -}; - -#endif diff --git a/trunk/drivers/net/wireless/rtlwifi/rtl8192de/dm.c b/trunk/drivers/net/wireless/rtlwifi/rtl8192de/dm.c deleted file mode 100644 index 3cd0736fe8e1..000000000000 --- a/trunk/drivers/net/wireless/rtlwifi/rtl8192de/dm.c +++ /dev/null @@ -1,1355 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2009-2010 Realtek Corporation. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * The full GNU General Public License is included in this distribution in the - * file called LICENSE. - * - * Contact Information: - * wlanfae - * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, - * Hsinchu 300, Taiwan. - * - * Larry Finger - * - *****************************************************************************/ - -#include "../wifi.h" -#include "../base.h" -#include "reg.h" -#include "def.h" -#include "phy.h" -#include "dm.h" -#include "fw.h" - -#define UNDEC_SM_PWDB entry_min_undecoratedsmoothed_pwdb - -struct dig_t de_digtable; - -static const u32 ofdmswing_table[OFDM_TABLE_SIZE_92D] = { - 0x7f8001fe, /* 0, +6.0dB */ - 0x788001e2, /* 1, +5.5dB */ - 0x71c001c7, /* 2, +5.0dB */ - 0x6b8001ae, /* 3, +4.5dB */ - 0x65400195, /* 4, +4.0dB */ - 0x5fc0017f, /* 5, +3.5dB */ - 0x5a400169, /* 6, +3.0dB */ - 0x55400155, /* 7, +2.5dB */ - 0x50800142, /* 8, +2.0dB */ - 0x4c000130, /* 9, +1.5dB */ - 0x47c0011f, /* 10, +1.0dB */ - 0x43c0010f, /* 11, +0.5dB */ - 0x40000100, /* 12, +0dB */ - 0x3c8000f2, /* 13, -0.5dB */ - 0x390000e4, /* 14, -1.0dB */ - 0x35c000d7, /* 15, -1.5dB */ - 0x32c000cb, /* 16, -2.0dB */ - 0x300000c0, /* 17, -2.5dB */ - 0x2d4000b5, /* 18, -3.0dB */ - 0x2ac000ab, /* 19, -3.5dB */ - 0x288000a2, /* 20, -4.0dB */ - 0x26000098, /* 21, -4.5dB */ - 0x24000090, /* 22, -5.0dB */ - 0x22000088, /* 23, -5.5dB */ - 0x20000080, /* 24, -6.0dB */ - 0x1e400079, /* 25, -6.5dB */ - 0x1c800072, /* 26, -7.0dB */ - 0x1b00006c, /* 27. -7.5dB */ - 0x19800066, /* 28, -8.0dB */ - 0x18000060, /* 29, -8.5dB */ - 0x16c0005b, /* 30, -9.0dB */ - 0x15800056, /* 31, -9.5dB */ - 0x14400051, /* 32, -10.0dB */ - 0x1300004c, /* 33, -10.5dB */ - 0x12000048, /* 34, -11.0dB */ - 0x11000044, /* 35, -11.5dB */ - 0x10000040, /* 36, -12.0dB */ - 0x0f00003c, /* 37, -12.5dB */ - 0x0e400039, /* 38, -13.0dB */ - 0x0d800036, /* 39, -13.5dB */ - 0x0cc00033, /* 40, -14.0dB */ - 0x0c000030, /* 41, -14.5dB */ - 0x0b40002d, /* 42, -15.0dB */ -}; - -static const u8 cckswing_table_ch1ch13[CCK_TABLE_SIZE][8] = { - {0x36, 0x35, 0x2e, 0x25, 0x1c, 0x12, 0x09, 0x04}, /* 0, +0dB */ - {0x33, 0x32, 0x2b, 0x23, 0x1a, 0x11, 0x08, 0x04}, /* 1, -0.5dB */ - {0x30, 0x2f, 0x29, 0x21, 0x19, 0x10, 0x08, 0x03}, /* 2, -1.0dB */ - {0x2d, 0x2d, 0x27, 0x1f, 0x18, 0x0f, 0x08, 0x03}, /* 3, -1.5dB */ - {0x2b, 0x2a, 0x25, 0x1e, 0x16, 0x0e, 0x07, 0x03}, /* 4, -2.0dB */ - {0x28, 0x28, 0x22, 0x1c, 0x15, 0x0d, 0x07, 0x03}, /* 5, -2.5dB */ - {0x26, 0x25, 0x21, 0x1b, 0x14, 0x0d, 0x06, 0x03}, /* 6, -3.0dB */ - {0x24, 0x23, 0x1f, 0x19, 0x13, 0x0c, 0x06, 0x03}, /* 7, -3.5dB */ - {0x22, 0x21, 0x1d, 0x18, 0x11, 0x0b, 0x06, 0x02}, /* 8, -4.0dB */ - {0x20, 0x20, 0x1b, 0x16, 0x11, 0x08, 0x05, 0x02}, /* 9, -4.5dB */ - {0x1f, 0x1e, 0x1a, 0x15, 0x10, 0x0a, 0x05, 0x02}, /* 10, -5.0dB */ - {0x1d, 0x1c, 0x18, 0x14, 0x0f, 0x0a, 0x05, 0x02}, /* 11, -5.5dB */ - {0x1b, 0x1a, 0x17, 0x13, 0x0e, 0x09, 0x04, 0x02}, /* 12, -6.0dB */ - {0x1a, 0x19, 0x16, 0x12, 0x0d, 0x09, 0x04, 0x02}, /* 13, -6.5dB */ - {0x18, 0x17, 0x15, 0x11, 0x0c, 0x08, 0x04, 0x02}, /* 14, -7.0dB */ - {0x17, 0x16, 0x13, 0x10, 0x0c, 0x08, 0x04, 0x02}, /* 15, -7.5dB */ - {0x16, 0x15, 0x12, 0x0f, 0x0b, 0x07, 0x04, 0x01}, /* 16, -8.0dB */ - {0x14, 0x14, 0x11, 0x0e, 0x0b, 0x07, 0x03, 0x02}, /* 17, -8.5dB */ - {0x13, 0x13, 0x10, 0x0d, 0x0a, 0x06, 0x03, 0x01}, /* 18, -9.0dB */ - {0x12, 0x12, 0x0f, 0x0c, 0x09, 0x06, 0x03, 0x01}, /* 19, -9.5dB */ - {0x11, 0x11, 0x0f, 0x0c, 0x09, 0x06, 0x03, 0x01}, /* 20, -10.0dB */ - {0x10, 0x10, 0x0e, 0x0b, 0x08, 0x05, 0x03, 0x01}, /* 21, -10.5dB */ - {0x0f, 0x0f, 0x0d, 0x0b, 0x08, 0x05, 0x03, 0x01}, /* 22, -11.0dB */ - {0x0e, 0x0e, 0x0c, 0x0a, 0x08, 0x05, 0x02, 0x01}, /* 23, -11.5dB */ - {0x0d, 0x0d, 0x0c, 0x0a, 0x07, 0x05, 0x02, 0x01}, /* 24, -12.0dB */ - {0x0d, 0x0c, 0x0b, 0x09, 0x07, 0x04, 0x02, 0x01}, /* 25, -12.5dB */ - {0x0c, 0x0c, 0x0a, 0x09, 0x06, 0x04, 0x02, 0x01}, /* 26, -13.0dB */ - {0x0b, 0x0b, 0x0a, 0x08, 0x06, 0x04, 0x02, 0x01}, /* 27, -13.5dB */ - {0x0b, 0x0a, 0x09, 0x08, 0x06, 0x04, 0x02, 0x01}, /* 28, -14.0dB */ - {0x0a, 0x0a, 0x09, 0x07, 0x05, 0x03, 0x02, 0x01}, /* 29, -14.5dB */ - {0x0a, 0x09, 0x08, 0x07, 0x05, 0x03, 0x02, 0x01}, /* 30, -15.0dB */ - {0x09, 0x09, 0x08, 0x06, 0x05, 0x03, 0x01, 0x01}, /* 31, -15.5dB */ - {0x09, 0x08, 0x07, 0x06, 0x04, 0x03, 0x01, 0x01} /* 32, -16.0dB */ -}; - -static const u8 cckswing_table_ch14[CCK_TABLE_SIZE][8] = { - {0x36, 0x35, 0x2e, 0x1b, 0x00, 0x00, 0x00, 0x00}, /* 0, +0dB */ - {0x33, 0x32, 0x2b, 0x19, 0x00, 0x00, 0x00, 0x00}, /* 1, -0.5dB */ - {0x30, 0x2f, 0x29, 0x18, 0x00, 0x00, 0x00, 0x00}, /* 2, -1.0dB */ - {0x2d, 0x2d, 0x17, 0x17, 0x00, 0x00, 0x00, 0x00}, /* 3, -1.5dB */ - {0x2b, 0x2a, 0x25, 0x15, 0x00, 0x00, 0x00, 0x00}, /* 4, -2.0dB */ - {0x28, 0x28, 0x24, 0x14, 0x00, 0x00, 0x00, 0x00}, /* 5, -2.5dB */ - {0x26, 0x25, 0x21, 0x13, 0x00, 0x00, 0x00, 0x00}, /* 6, -3.0dB */ - {0x24, 0x23, 0x1f, 0x12, 0x00, 0x00, 0x00, 0x00}, /* 7, -3.5dB */ - {0x22, 0x21, 0x1d, 0x11, 0x00, 0x00, 0x00, 0x00}, /* 8, -4.0dB */ - {0x20, 0x20, 0x1b, 0x10, 0x00, 0x00, 0x00, 0x00}, /* 9, -4.5dB */ - {0x1f, 0x1e, 0x1a, 0x0f, 0x00, 0x00, 0x00, 0x00}, /* 10, -5.0dB */ - {0x1d, 0x1c, 0x18, 0x0e, 0x00, 0x00, 0x00, 0x00}, /* 11, -5.5dB */ - {0x1b, 0x1a, 0x17, 0x0e, 0x00, 0x00, 0x00, 0x00}, /* 12, -6.0dB */ - {0x1a, 0x19, 0x16, 0x0d, 0x00, 0x00, 0x00, 0x00}, /* 13, -6.5dB */ - {0x18, 0x17, 0x15, 0x0c, 0x00, 0x00, 0x00, 0x00}, /* 14, -7.0dB */ - {0x17, 0x16, 0x13, 0x0b, 0x00, 0x00, 0x00, 0x00}, /* 15, -7.5dB */ - {0x16, 0x15, 0x12, 0x0b, 0x00, 0x00, 0x00, 0x00}, /* 16, -8.0dB */ - {0x14, 0x14, 0x11, 0x0a, 0x00, 0x00, 0x00, 0x00}, /* 17, -8.5dB */ - {0x13, 0x13, 0x10, 0x0a, 0x00, 0x00, 0x00, 0x00}, /* 18, -9.0dB */ - {0x12, 0x12, 0x0f, 0x09, 0x00, 0x00, 0x00, 0x00}, /* 19, -9.5dB */ - {0x11, 0x11, 0x0f, 0x09, 0x00, 0x00, 0x00, 0x00}, /* 20, -10.0dB */ - {0x10, 0x10, 0x0e, 0x08, 0x00, 0x00, 0x00, 0x00}, /* 21, -10.5dB */ - {0x0f, 0x0f, 0x0d, 0x08, 0x00, 0x00, 0x00, 0x00}, /* 22, -11.0dB */ - {0x0e, 0x0e, 0x0c, 0x07, 0x00, 0x00, 0x00, 0x00}, /* 23, -11.5dB */ - {0x0d, 0x0d, 0x0c, 0x07, 0x00, 0x00, 0x00, 0x00}, /* 24, -12.0dB */ - {0x0d, 0x0c, 0x0b, 0x06, 0x00, 0x00, 0x00, 0x00}, /* 25, -12.5dB */ - {0x0c, 0x0c, 0x0a, 0x06, 0x00, 0x00, 0x00, 0x00}, /* 26, -13.0dB */ - {0x0b, 0x0b, 0x0a, 0x06, 0x00, 0x00, 0x00, 0x00}, /* 27, -13.5dB */ - {0x0b, 0x0a, 0x09, 0x05, 0x00, 0x00, 0x00, 0x00}, /* 28, -14.0dB */ - {0x0a, 0x0a, 0x09, 0x05, 0x00, 0x00, 0x00, 0x00}, /* 29, -14.5dB */ - {0x0a, 0x09, 0x08, 0x05, 0x00, 0x00, 0x00, 0x00}, /* 30, -15.0dB */ - {0x09, 0x09, 0x08, 0x05, 0x00, 0x00, 0x00, 0x00}, /* 31, -15.5dB */ - {0x09, 0x08, 0x07, 0x04, 0x00, 0x00, 0x00, 0x00} /* 32, -16.0dB */ -}; - -static void rtl92d_dm_diginit(struct ieee80211_hw *hw) -{ - de_digtable.dig_enable_flag = true; - de_digtable.dig_ext_port_stage = DIG_EXT_PORT_STAGE_MAX; - de_digtable.cur_igvalue = 0x20; - de_digtable.pre_igvalue = 0x0; - de_digtable.cursta_connectctate = DIG_STA_DISCONNECT; - de_digtable.presta_connectstate = DIG_STA_DISCONNECT; - de_digtable.curmultista_connectstate = DIG_MULTISTA_DISCONNECT; - de_digtable.rssi_lowthresh = DM_DIG_THRESH_LOW; - de_digtable.rssi_highthresh = DM_DIG_THRESH_HIGH; - de_digtable.fa_lowthresh = DM_FALSEALARM_THRESH_LOW; - de_digtable.fa_highthresh = DM_FALSEALARM_THRESH_HIGH; - de_digtable.rx_gain_range_max = DM_DIG_FA_UPPER; - de_digtable.rx_gain_range_min = DM_DIG_FA_LOWER; - de_digtable.backoff_val = DM_DIG_BACKOFF_DEFAULT; - de_digtable.backoff_val_range_max = DM_DIG_BACKOFF_MAX; - de_digtable.backoff_val_range_min = DM_DIG_BACKOFF_MIN; - de_digtable.pre_cck_pd_state = CCK_PD_STAGE_LOWRSSI; - de_digtable.cur_cck_pd_state = CCK_PD_STAGE_MAX; - de_digtable.large_fa_hit = 0; - de_digtable.recover_cnt = 0; - de_digtable.forbidden_igi = DM_DIG_FA_LOWER; -} - -static void rtl92d_dm_false_alarm_counter_statistics(struct ieee80211_hw *hw) -{ - u32 ret_value; - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct false_alarm_statistics *falsealm_cnt = &(rtlpriv->falsealm_cnt); - unsigned long flag = 0; - - /* hold ofdm counter */ - rtl_set_bbreg(hw, ROFDM0_LSTF, BIT(31), 1); /* hold page C counter */ - rtl_set_bbreg(hw, ROFDM1_LSTF, BIT(31), 1); /*hold page D counter */ - - ret_value = rtl_get_bbreg(hw, ROFDM0_FRAMESYNC, BMASKDWORD); - falsealm_cnt->cnt_fast_fsync_fail = (ret_value & 0xffff); - falsealm_cnt->cnt_sb_search_fail = ((ret_value & 0xffff0000) >> 16); - ret_value = rtl_get_bbreg(hw, ROFDM_PHYCOUNTER1, BMASKDWORD); - falsealm_cnt->cnt_parity_fail = ((ret_value & 0xffff0000) >> 16); - ret_value = rtl_get_bbreg(hw, ROFDM_PHYCOUNTER2, BMASKDWORD); - falsealm_cnt->cnt_rate_illegal = (ret_value & 0xffff); - falsealm_cnt->cnt_crc8_fail = ((ret_value & 0xffff0000) >> 16); - ret_value = rtl_get_bbreg(hw, ROFDM_PHYCOUNTER3, BMASKDWORD); - falsealm_cnt->cnt_mcs_fail = (ret_value & 0xffff); - falsealm_cnt->cnt_ofdm_fail = falsealm_cnt->cnt_parity_fail + - falsealm_cnt->cnt_rate_illegal + - falsealm_cnt->cnt_crc8_fail + - falsealm_cnt->cnt_mcs_fail + - falsealm_cnt->cnt_fast_fsync_fail + - falsealm_cnt->cnt_sb_search_fail; - - if (rtlpriv->rtlhal.current_bandtype != BAND_ON_5G) { - /* hold cck counter */ - rtl92d_acquire_cckandrw_pagea_ctl(hw, &flag); - ret_value = rtl_get_bbreg(hw, RCCK0_FACOUNTERLOWER, BMASKBYTE0); - falsealm_cnt->cnt_cck_fail = ret_value; - ret_value = rtl_get_bbreg(hw, RCCK0_FACOUNTERUPPER, BMASKBYTE3); - falsealm_cnt->cnt_cck_fail += (ret_value & 0xff) << 8; - rtl92d_release_cckandrw_pagea_ctl(hw, &flag); - } else { - falsealm_cnt->cnt_cck_fail = 0; - } - - /* reset false alarm counter registers */ - falsealm_cnt->cnt_all = falsealm_cnt->cnt_fast_fsync_fail + - falsealm_cnt->cnt_sb_search_fail + - falsealm_cnt->cnt_parity_fail + - falsealm_cnt->cnt_rate_illegal + - falsealm_cnt->cnt_crc8_fail + - falsealm_cnt->cnt_mcs_fail + - falsealm_cnt->cnt_cck_fail; - - rtl_set_bbreg(hw, ROFDM1_LSTF, 0x08000000, 1); - /* update ofdm counter */ - rtl_set_bbreg(hw, ROFDM1_LSTF, 0x08000000, 0); - /* update page C counter */ - rtl_set_bbreg(hw, ROFDM0_LSTF, BIT(31), 0); - /* update page D counter */ - rtl_set_bbreg(hw, ROFDM1_LSTF, BIT(31), 0); - if (rtlpriv->rtlhal.current_bandtype != BAND_ON_5G) { - /* reset cck counter */ - rtl92d_acquire_cckandrw_pagea_ctl(hw, &flag); - rtl_set_bbreg(hw, RCCK0_FALSEALARMREPORT, 0x0000c000, 0); - /* enable cck counter */ - rtl_set_bbreg(hw, RCCK0_FALSEALARMREPORT, 0x0000c000, 2); - rtl92d_release_cckandrw_pagea_ctl(hw, &flag); - } - RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, ("Cnt_Fast_Fsync_fail = %x, " - "Cnt_SB_Search_fail = %x\n", - falsealm_cnt->cnt_fast_fsync_fail, - falsealm_cnt->cnt_sb_search_fail)); - RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, ("Cnt_Parity_Fail = %x, " - "Cnt_Rate_Illegal = %x, Cnt_Crc8_fail = %x, " - "Cnt_Mcs_fail = %x\n", - falsealm_cnt->cnt_parity_fail, - falsealm_cnt->cnt_rate_illegal, - falsealm_cnt->cnt_crc8_fail, - falsealm_cnt->cnt_mcs_fail)); - RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, - ("Cnt_Ofdm_fail = %x, " "Cnt_Cck_fail = %x, " - "Cnt_all = %x\n", - falsealm_cnt->cnt_ofdm_fail, - falsealm_cnt->cnt_cck_fail, - falsealm_cnt->cnt_all)); -} - -static void rtl92d_dm_find_minimum_rssi(struct ieee80211_hw *hw) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_mac *mac = rtl_mac(rtlpriv); - - /* Determine the minimum RSSI */ - if ((mac->link_state < MAC80211_LINKED) && - (rtlpriv->dm.UNDEC_SM_PWDB == 0)) { - de_digtable.min_undecorated_pwdb_for_dm = 0; - RT_TRACE(rtlpriv, COMP_BB_POWERSAVING, DBG_LOUD, - ("Not connected to any\n")); - } - if (mac->link_state >= MAC80211_LINKED) { - if (mac->opmode == NL80211_IFTYPE_AP || - mac->opmode == NL80211_IFTYPE_ADHOC) { - de_digtable.min_undecorated_pwdb_for_dm = - rtlpriv->dm.UNDEC_SM_PWDB; - RT_TRACE(rtlpriv, COMP_BB_POWERSAVING, DBG_LOUD, - ("AP Client PWDB = 0x%lx\n", - rtlpriv->dm.UNDEC_SM_PWDB)); - } else { - de_digtable.min_undecorated_pwdb_for_dm = - rtlpriv->dm.undecorated_smoothed_pwdb; - RT_TRACE(rtlpriv, COMP_BB_POWERSAVING, DBG_LOUD, - ("STA Default Port PWDB = 0x%x\n", - de_digtable.min_undecorated_pwdb_for_dm)); - } - } else { - de_digtable.min_undecorated_pwdb_for_dm = - rtlpriv->dm.UNDEC_SM_PWDB; - RT_TRACE(rtlpriv, COMP_BB_POWERSAVING, DBG_LOUD, - ("AP Ext Port or disconnet PWDB = 0x%x\n", - de_digtable.min_undecorated_pwdb_for_dm)); - } - - RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, ("MinUndecoratedPWDBForDM =%d\n", - de_digtable.min_undecorated_pwdb_for_dm)); -} - -static void rtl92d_dm_cck_packet_detection_thresh(struct ieee80211_hw *hw) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - unsigned long flag = 0; - - if (de_digtable.cursta_connectctate == DIG_STA_CONNECT) { - if (de_digtable.pre_cck_pd_state == CCK_PD_STAGE_LOWRSSI) { - if (de_digtable.min_undecorated_pwdb_for_dm <= 25) - de_digtable.cur_cck_pd_state = - CCK_PD_STAGE_LOWRSSI; - else - de_digtable.cur_cck_pd_state = - CCK_PD_STAGE_HIGHRSSI; - } else { - if (de_digtable.min_undecorated_pwdb_for_dm <= 20) - de_digtable.cur_cck_pd_state = - CCK_PD_STAGE_LOWRSSI; - else - de_digtable.cur_cck_pd_state = - CCK_PD_STAGE_HIGHRSSI; - } - } else { - de_digtable.cur_cck_pd_state = CCK_PD_STAGE_LOWRSSI; - } - if (de_digtable.pre_cck_pd_state != de_digtable.cur_cck_pd_state) { - if (de_digtable.cur_cck_pd_state == CCK_PD_STAGE_LOWRSSI) { - rtl92d_acquire_cckandrw_pagea_ctl(hw, &flag); - rtl_set_bbreg(hw, RCCK0_CCA, BMASKBYTE2, 0x83); - rtl92d_release_cckandrw_pagea_ctl(hw, &flag); - } else { - rtl92d_acquire_cckandrw_pagea_ctl(hw, &flag); - rtl_set_bbreg(hw, RCCK0_CCA, BMASKBYTE2, 0xcd); - rtl92d_release_cckandrw_pagea_ctl(hw, &flag); - } - de_digtable.pre_cck_pd_state = de_digtable.cur_cck_pd_state; - } - RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, ("CurSTAConnectState=%s\n", - (de_digtable.cursta_connectctate == DIG_STA_CONNECT ? - "DIG_STA_CONNECT " : "DIG_STA_DISCONNECT"))); - RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, ("CCKPDStage=%s\n", - (de_digtable.cur_cck_pd_state == CCK_PD_STAGE_LOWRSSI ? - "Low RSSI " : "High RSSI "))); - RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, ("is92d single phy =%x\n", - IS_92D_SINGLEPHY(rtlpriv->rtlhal.version))); - -} - -void rtl92d_dm_write_dig(struct ieee80211_hw *hw) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - - RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, ("cur_igvalue = 0x%x, " - "pre_igvalue = 0x%x, backoff_val = %d\n", - de_digtable.cur_igvalue, de_digtable.pre_igvalue, - de_digtable.backoff_val)); - if (de_digtable.dig_enable_flag == false) { - RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, ("DIG is disabled\n")); - de_digtable.pre_igvalue = 0x17; - return; - } - if (de_digtable.pre_igvalue != de_digtable.cur_igvalue) { - rtl_set_bbreg(hw, ROFDM0_XAAGCCORE1, 0x7f, - de_digtable.cur_igvalue); - rtl_set_bbreg(hw, ROFDM0_XBAGCCORE1, 0x7f, - de_digtable.cur_igvalue); - de_digtable.pre_igvalue = de_digtable.cur_igvalue; - } -} - -static void rtl92d_early_mode_enabled(struct rtl_priv *rtlpriv) -{ - if ((rtlpriv->mac80211.link_state >= MAC80211_LINKED) && - (rtlpriv->mac80211.vendor == PEER_CISCO)) { - RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, - ("IOT_PEER = CISCO\n")); - if (de_digtable.last_min_undecorated_pwdb_for_dm >= 50 - && de_digtable.min_undecorated_pwdb_for_dm < 50) { - rtl_write_byte(rtlpriv, REG_EARLY_MODE_CONTROL, 0x00); - RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, - ("Early Mode Off\n")); - } else if (de_digtable.last_min_undecorated_pwdb_for_dm <= 55 && - de_digtable.min_undecorated_pwdb_for_dm > 55) { - rtl_write_byte(rtlpriv, REG_EARLY_MODE_CONTROL, 0x0f); - RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, - ("Early Mode On\n")); - } - } else if (!(rtl_read_byte(rtlpriv, REG_EARLY_MODE_CONTROL) & 0xf)) { - rtl_write_byte(rtlpriv, REG_EARLY_MODE_CONTROL, 0x0f); - RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, ("Early Mode On\n")); - } -} - -static void rtl92d_dm_dig(struct ieee80211_hw *hw) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - u8 value_igi = de_digtable.cur_igvalue; - struct false_alarm_statistics *falsealm_cnt = &(rtlpriv->falsealm_cnt); - - RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, ("==>\n")); - if (rtlpriv->rtlhal.earlymode_enable) { - rtl92d_early_mode_enabled(rtlpriv); - de_digtable.last_min_undecorated_pwdb_for_dm = - de_digtable.min_undecorated_pwdb_for_dm; - } - if (rtlpriv->dm.dm_initialgain_enable == false) - return; - - /* because we will send data pkt when scanning - * this will cause some ap like gear-3700 wep TP - * lower if we retrun here, this is the diff of - * mac80211 driver vs ieee80211 driver */ - /* if (rtlpriv->mac80211.act_scanning) - * return; */ - - /* Not STA mode return tmp */ - if (rtlpriv->mac80211.opmode != NL80211_IFTYPE_STATION) - return; - RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, ("progress\n")); - /* Decide the current status and if modify initial gain or not */ - if (rtlpriv->mac80211.link_state >= MAC80211_LINKED) - de_digtable.cursta_connectctate = DIG_STA_CONNECT; - else - de_digtable.cursta_connectctate = DIG_STA_DISCONNECT; - - /* adjust initial gain according to false alarm counter */ - if (falsealm_cnt->cnt_all < DM_DIG_FA_TH0) - value_igi--; - else if (falsealm_cnt->cnt_all < DM_DIG_FA_TH1) - value_igi += 0; - else if (falsealm_cnt->cnt_all < DM_DIG_FA_TH2) - value_igi++; - else if (falsealm_cnt->cnt_all >= DM_DIG_FA_TH2) - value_igi += 2; - RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, - ("dm_DIG() Before: large_fa_hit=%d, forbidden_igi=%x\n", - de_digtable.large_fa_hit, de_digtable.forbidden_igi)); - RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, - ("dm_DIG() Before: Recover_cnt=%d, rx_gain_range_min=%x\n", - de_digtable.recover_cnt, de_digtable.rx_gain_range_min)); - - /* deal with abnorally large false alarm */ - if (falsealm_cnt->cnt_all > 10000) { - RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, - ("dm_DIG(): Abnornally false alarm case.\n")); - - de_digtable.large_fa_hit++; - if (de_digtable.forbidden_igi < de_digtable.cur_igvalue) { - de_digtable.forbidden_igi = de_digtable.cur_igvalue; - de_digtable.large_fa_hit = 1; - } - if (de_digtable.large_fa_hit >= 3) { - if ((de_digtable.forbidden_igi + 1) > DM_DIG_MAX) - de_digtable.rx_gain_range_min = DM_DIG_MAX; - else - de_digtable.rx_gain_range_min = - (de_digtable.forbidden_igi + 1); - de_digtable.recover_cnt = 3600; /* 3600=2hr */ - } - } else { - /* Recovery mechanism for IGI lower bound */ - if (de_digtable.recover_cnt != 0) { - de_digtable.recover_cnt--; - } else { - if (de_digtable.large_fa_hit == 0) { - if ((de_digtable.forbidden_igi - 1) < - DM_DIG_FA_LOWER) { - de_digtable.forbidden_igi = - DM_DIG_FA_LOWER; - de_digtable.rx_gain_range_min = - DM_DIG_FA_LOWER; - - } else { - de_digtable.forbidden_igi--; - de_digtable.rx_gain_range_min = - (de_digtable.forbidden_igi + 1); - } - } else if (de_digtable.large_fa_hit == 3) { - de_digtable.large_fa_hit = 0; - } - } - } - RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, - ("dm_DIG() After: large_fa_hit=%d, forbidden_igi=%x\n", - de_digtable.large_fa_hit, de_digtable.forbidden_igi)); - RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, - ("dm_DIG() After: recover_cnt=%d, rx_gain_range_min=%x\n", - de_digtable.recover_cnt, de_digtable.rx_gain_range_min)); - - if (value_igi > DM_DIG_MAX) - value_igi = DM_DIG_MAX; - else if (value_igi < de_digtable.rx_gain_range_min) - value_igi = de_digtable.rx_gain_range_min; - de_digtable.cur_igvalue = value_igi; - rtl92d_dm_write_dig(hw); - if (rtlpriv->rtlhal.current_bandtype != BAND_ON_5G) - rtl92d_dm_cck_packet_detection_thresh(hw); - RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, ("<<==\n")); -} - -static void rtl92d_dm_init_dynamic_txpower(struct ieee80211_hw *hw) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - - rtlpriv->dm.dynamic_txpower_enable = true; - rtlpriv->dm.last_dtp_lvl = TXHIGHPWRLEVEL_NORMAL; - rtlpriv->dm.dynamic_txhighpower_lvl = TXHIGHPWRLEVEL_NORMAL; -} - -static void rtl92d_dm_dynamic_txpower(struct ieee80211_hw *hw) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_phy *rtlphy = &(rtlpriv->phy); - struct rtl_hal *rtlhal = rtl_hal(rtlpriv); - struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); - long undecorated_smoothed_pwdb; - - if ((!rtlpriv->dm.dynamic_txpower_enable) - || rtlpriv->dm.dm_flag & HAL_DM_HIPWR_DISABLE) { - rtlpriv->dm.dynamic_txhighpower_lvl = TXHIGHPWRLEVEL_NORMAL; - return; - } - if ((mac->link_state < MAC80211_LINKED) && - (rtlpriv->dm.UNDEC_SM_PWDB == 0)) { - RT_TRACE(rtlpriv, COMP_POWER, DBG_TRACE, - ("Not connected to any\n")); - rtlpriv->dm.dynamic_txhighpower_lvl = TXHIGHPWRLEVEL_NORMAL; - rtlpriv->dm.last_dtp_lvl = TXHIGHPWRLEVEL_NORMAL; - return; - } - if (mac->link_state >= MAC80211_LINKED) { - if (mac->opmode == NL80211_IFTYPE_ADHOC) { - undecorated_smoothed_pwdb = - rtlpriv->dm.UNDEC_SM_PWDB; - RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, - ("IBSS Client PWDB = 0x%lx\n", - undecorated_smoothed_pwdb)); - } else { - undecorated_smoothed_pwdb = - rtlpriv->dm.undecorated_smoothed_pwdb; - RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, - ("STA Default Port PWDB = 0x%lx\n", - undecorated_smoothed_pwdb)); - } - } else { - undecorated_smoothed_pwdb = - rtlpriv->dm.UNDEC_SM_PWDB; - - RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, - ("AP Ext Port PWDB = 0x%lx\n", - undecorated_smoothed_pwdb)); - } - if (rtlhal->current_bandtype == BAND_ON_5G) { - if (undecorated_smoothed_pwdb >= 0x33) { - rtlpriv->dm.dynamic_txhighpower_lvl = - TXHIGHPWRLEVEL_LEVEL2; - RT_TRACE(rtlpriv, COMP_HIPWR, DBG_LOUD, - ("5G:TxHighPwrLevel_Level2 (TxPwr=0x0)\n")); - } else if ((undecorated_smoothed_pwdb < 0x33) - && (undecorated_smoothed_pwdb >= 0x2b)) { - rtlpriv->dm.dynamic_txhighpower_lvl = - TXHIGHPWRLEVEL_LEVEL1; - RT_TRACE(rtlpriv, COMP_HIPWR, DBG_LOUD, - ("5G:TxHighPwrLevel_Level1 (TxPwr=0x10)\n")); - } else if (undecorated_smoothed_pwdb < 0x2b) { - rtlpriv->dm.dynamic_txhighpower_lvl = - TXHIGHPWRLEVEL_NORMAL; - RT_TRACE(rtlpriv, COMP_HIPWR, DBG_LOUD, - ("5G:TxHighPwrLevel_Normal\n")); - } - } else { - if (undecorated_smoothed_pwdb >= - TX_POWER_NEAR_FIELD_THRESH_LVL2) { - rtlpriv->dm.dynamic_txhighpower_lvl = - TXHIGHPWRLEVEL_LEVEL2; - RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, - ("TXHIGHPWRLEVEL_LEVEL1 (TxPwr=0x0)\n")); - } else - if ((undecorated_smoothed_pwdb < - (TX_POWER_NEAR_FIELD_THRESH_LVL2 - 3)) - && (undecorated_smoothed_pwdb >= - TX_POWER_NEAR_FIELD_THRESH_LVL1)) { - - rtlpriv->dm.dynamic_txhighpower_lvl = - TXHIGHPWRLEVEL_LEVEL1; - RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, - ("TXHIGHPWRLEVEL_LEVEL1 (TxPwr=0x10)\n")); - } else if (undecorated_smoothed_pwdb < - (TX_POWER_NEAR_FIELD_THRESH_LVL1 - 5)) { - rtlpriv->dm.dynamic_txhighpower_lvl = - TXHIGHPWRLEVEL_NORMAL; - RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, - ("TXHIGHPWRLEVEL_NORMAL\n")); - } - } - if ((rtlpriv->dm.dynamic_txhighpower_lvl != rtlpriv->dm.last_dtp_lvl)) { - RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, - ("PHY_SetTxPowerLevel8192S() Channel = %d\n", - rtlphy->current_channel)); - rtl92d_phy_set_txpower_level(hw, rtlphy->current_channel); - } - rtlpriv->dm.last_dtp_lvl = rtlpriv->dm.dynamic_txhighpower_lvl; -} - -static void rtl92d_dm_pwdb_monitor(struct ieee80211_hw *hw) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - - /* AP & ADHOC & MESH will return tmp */ - if (rtlpriv->mac80211.opmode != NL80211_IFTYPE_STATION) - return; - /* Indicate Rx signal strength to FW. */ - if (rtlpriv->dm.useramask) { - u32 temp = rtlpriv->dm.undecorated_smoothed_pwdb; - - temp <<= 16; - temp |= 0x100; - /* fw v12 cmdid 5:use max macid ,for nic , - * default macid is 0 ,max macid is 1 */ - rtl92d_fill_h2c_cmd(hw, H2C_RSSI_REPORT, 3, (u8 *) (&temp)); - } else { - rtl_write_byte(rtlpriv, 0x4fe, - (u8) rtlpriv->dm.undecorated_smoothed_pwdb); - } -} - -void rtl92d_dm_init_edca_turbo(struct ieee80211_hw *hw) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - - rtlpriv->dm.current_turbo_edca = false; - rtlpriv->dm.is_any_nonbepkts = false; - rtlpriv->dm.is_cur_rdlstate = false; -} - -static void rtl92d_dm_check_edca_turbo(struct ieee80211_hw *hw) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); - static u64 last_txok_cnt; - static u64 last_rxok_cnt; - u64 cur_txok_cnt; - u64 cur_rxok_cnt; - u32 edca_be_ul = 0x5ea42b; - u32 edca_be_dl = 0x5ea42b; - - if (mac->link_state != MAC80211_LINKED) { - rtlpriv->dm.current_turbo_edca = false; - goto exit; - } - - /* Enable BEQ TxOP limit configuration in wireless G-mode. */ - /* To check whether we shall force turn on TXOP configuration. */ - if ((!rtlpriv->dm.disable_framebursting) && - (rtlpriv->sec.pairwise_enc_algorithm == WEP40_ENCRYPTION || - rtlpriv->sec.pairwise_enc_algorithm == WEP104_ENCRYPTION || - rtlpriv->sec.pairwise_enc_algorithm == TKIP_ENCRYPTION)) { - /* Force TxOP limit to 0x005e for UL. */ - if (!(edca_be_ul & 0xffff0000)) - edca_be_ul |= 0x005e0000; - /* Force TxOP limit to 0x005e for DL. */ - if (!(edca_be_dl & 0xffff0000)) - edca_be_dl |= 0x005e0000; - } - - if ((!rtlpriv->dm.is_any_nonbepkts) && - (!rtlpriv->dm.disable_framebursting)) { - cur_txok_cnt = rtlpriv->stats.txbytesunicast - last_txok_cnt; - cur_rxok_cnt = rtlpriv->stats.rxbytesunicast - last_rxok_cnt; - if (cur_rxok_cnt > 4 * cur_txok_cnt) { - if (!rtlpriv->dm.is_cur_rdlstate || - !rtlpriv->dm.current_turbo_edca) { - rtl_write_dword(rtlpriv, REG_EDCA_BE_PARAM, - edca_be_dl); - rtlpriv->dm.is_cur_rdlstate = true; - } - } else { - if (rtlpriv->dm.is_cur_rdlstate || - !rtlpriv->dm.current_turbo_edca) { - rtl_write_dword(rtlpriv, REG_EDCA_BE_PARAM, - edca_be_ul); - rtlpriv->dm.is_cur_rdlstate = false; - } - } - rtlpriv->dm.current_turbo_edca = true; - } else { - if (rtlpriv->dm.current_turbo_edca) { - u8 tmp = AC0_BE; - rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_AC_PARAM, - (u8 *) (&tmp)); - rtlpriv->dm.current_turbo_edca = false; - } - } - -exit: - rtlpriv->dm.is_any_nonbepkts = false; - last_txok_cnt = rtlpriv->stats.txbytesunicast; - last_rxok_cnt = rtlpriv->stats.rxbytesunicast; -} - -static void rtl92d_dm_rxgain_tracking_thermalmeter(struct ieee80211_hw *hw) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - u8 index_mapping[RX_INDEX_MAPPING_NUM] = { - 0x0f, 0x0f, 0x0d, 0x0c, 0x0b, - 0x0a, 0x09, 0x08, 0x07, 0x06, - 0x05, 0x04, 0x04, 0x03, 0x02 - }; - int i; - u32 u4tmp; - - u4tmp = (index_mapping[(rtlpriv->efuse.eeprom_thermalmeter - - rtlpriv->dm.thermalvalue_rxgain)]) << 12; - RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, - ("===> Rx Gain %x\n", u4tmp)); - for (i = RF90_PATH_A; i < rtlpriv->phy.num_total_rfpath; i++) - rtl_set_rfreg(hw, i, 0x3C, BRFREGOFFSETMASK, - (rtlpriv->phy.reg_rf3c[i] & (~(0xF000))) | u4tmp); -} - -static void rtl92d_bandtype_2_4G(struct ieee80211_hw *hw, long *temp_cckg, - u8 *cck_index_old) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - int i; - unsigned long flag = 0; - long temp_cck; - - /* Query CCK default setting From 0xa24 */ - rtl92d_acquire_cckandrw_pagea_ctl(hw, &flag); - temp_cck = rtl_get_bbreg(hw, RCCK0_TXFILTER2, - BMASKDWORD) & BMASKCCK; - rtl92d_release_cckandrw_pagea_ctl(hw, &flag); - for (i = 0; i < CCK_TABLE_LENGTH; i++) { - if (rtlpriv->dm.cck_inch14) { - if (!memcmp((void *)&temp_cck, - (void *)&cckswing_table_ch14[i][2], 4)) { - *cck_index_old = (u8) i; - RT_TRACE(rtlpriv, - COMP_POWER_TRACKING, - DBG_LOUD, - ("Initial reg0x%x = 0x%lx, " - "cck_index=0x%x, ch 14 %d\n", - RCCK0_TXFILTER2, - temp_cck, *cck_index_old, - rtlpriv->dm.cck_inch14)); - break; - } - } else { - if (!memcmp((void *) &temp_cck, - &cckswing_table_ch1ch13[i][2], 4)) { - *cck_index_old = (u8) i; - RT_TRACE(rtlpriv, COMP_POWER_TRACKING, - DBG_LOUD, - ("Initial reg0x%x = 0x%lx, " - "cck_index = 0x%x, ch14 %d\n", - RCCK0_TXFILTER2, - temp_cck, *cck_index_old, - rtlpriv->dm.cck_inch14)); - break; - } - } - } - *temp_cckg = temp_cck; -} - -static void rtl92d_bandtype_5G(struct rtl_hal *rtlhal, u8 *ofdm_index, - bool *internal_pa, u8 thermalvalue, u8 delta, - u8 rf, struct rtl_efuse *rtlefuse, - struct rtl_priv *rtlpriv, struct rtl_phy *rtlphy, - u8 index_mapping[5][INDEX_MAPPING_NUM], - u8 index_mapping_pa[8][INDEX_MAPPING_NUM]) -{ - int i; - u8 index; - u8 offset = 0; - - for (i = 0; i < rf; i++) { - if (rtlhal->macphymode == DUALMAC_DUALPHY && - rtlhal->interfaceindex == 1) /* MAC 1 5G */ - *internal_pa = rtlefuse->internal_pa_5g[1]; - else - *internal_pa = rtlefuse->internal_pa_5g[i]; - if (*internal_pa) { - if (rtlhal->interfaceindex == 1 || i == rf) - offset = 4; - else - offset = 0; - if (rtlphy->current_channel >= 100 && - rtlphy->current_channel <= 165) - offset += 2; - } else { - if (rtlhal->interfaceindex == 1 || i == rf) - offset = 2; - else - offset = 0; - } - if (thermalvalue > rtlefuse->eeprom_thermalmeter) - offset++; - if (*internal_pa) { - if (delta > INDEX_MAPPING_NUM - 1) - index = index_mapping_pa[offset] - [INDEX_MAPPING_NUM - 1]; - else - index = - index_mapping_pa[offset][delta]; - } else { - if (delta > INDEX_MAPPING_NUM - 1) - index = - index_mapping[offset][INDEX_MAPPING_NUM - 1]; - else - index = index_mapping[offset][delta]; - } - if (thermalvalue > rtlefuse->eeprom_thermalmeter) { - if (*internal_pa && thermalvalue > 0x12) { - ofdm_index[i] = rtlpriv->dm.ofdm_index[i] - - ((delta / 2) * 3 + (delta % 2)); - } else { - ofdm_index[i] -= index; - } - } else { - ofdm_index[i] += index; - } - } -} - -static void rtl92d_dm_txpower_tracking_callback_thermalmeter( - struct ieee80211_hw *hw) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); - struct rtl_phy *rtlphy = &(rtlpriv->phy); - struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw)); - u8 thermalvalue, delta, delta_lck, delta_iqk, delta_rxgain; - u8 offset, thermalvalue_avg_count = 0; - u32 thermalvalue_avg = 0; - bool internal_pa = false; - long ele_a = 0, ele_d, temp_cck, val_x, value32; - long val_y, ele_c = 0; - u8 ofdm_index[2]; - u8 cck_index = 0; - u8 ofdm_index_old[2]; - u8 cck_index_old = 0; - u8 index; - int i; - bool is2t = IS_92D_SINGLEPHY(rtlhal->version); - u8 ofdm_min_index = 6, ofdm_min_index_internal_pa = 3, rf; - u8 indexforchannel = - rtl92d_get_rightchnlplace_for_iqk(rtlphy->current_channel); - u8 index_mapping[5][INDEX_MAPPING_NUM] = { - /* 5G, path A/MAC 0, decrease power */ - {0, 1, 3, 6, 8, 9, 11, 13, 14, 16, 17, 18, 18}, - /* 5G, path A/MAC 0, increase power */ - {0, 2, 4, 5, 7, 10, 12, 14, 16, 18, 18, 18, 18}, - /* 5G, path B/MAC 1, decrease power */ - {0, 2, 3, 6, 8, 9, 11, 13, 14, 16, 17, 18, 18}, - /* 5G, path B/MAC 1, increase power */ - {0, 2, 4, 5, 7, 10, 13, 16, 16, 18, 18, 18, 18}, - /* 2.4G, for decreas power */ - {0, 1, 2, 3, 4, 5, 6, 7, 7, 8, 9, 10, 10}, - }; - u8 index_mapping_internal_pa[8][INDEX_MAPPING_NUM] = { - /* 5G, path A/MAC 0, ch36-64, decrease power */ - {0, 1, 2, 4, 6, 7, 9, 11, 12, 14, 15, 16, 16}, - /* 5G, path A/MAC 0, ch36-64, increase power */ - {0, 2, 4, 5, 7, 10, 12, 14, 16, 18, 18, 18, 18}, - /* 5G, path A/MAC 0, ch100-165, decrease power */ - {0, 1, 2, 3, 5, 6, 8, 10, 11, 13, 14, 15, 15}, - /* 5G, path A/MAC 0, ch100-165, increase power */ - {0, 2, 4, 5, 7, 10, 12, 14, 16, 18, 18, 18, 18}, - /* 5G, path B/MAC 1, ch36-64, decrease power */ - {0, 1, 2, 4, 6, 7, 9, 11, 12, 14, 15, 16, 16}, - /* 5G, path B/MAC 1, ch36-64, increase power */ - {0, 2, 4, 5, 7, 10, 13, 16, 16, 18, 18, 18, 18}, - /* 5G, path B/MAC 1, ch100-165, decrease power */ - {0, 1, 2, 3, 5, 6, 8, 9, 10, 12, 13, 14, 14}, - /* 5G, path B/MAC 1, ch100-165, increase power */ - {0, 2, 4, 5, 7, 10, 13, 16, 16, 18, 18, 18, 18}, - }; - - rtlpriv->dm.txpower_trackinginit = true; - RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, ("\n")); - thermalvalue = (u8) rtl_get_rfreg(hw, RF90_PATH_A, RF_T_METER, 0xf800); - RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, - ("Readback Thermal Meter = 0x%x pre thermal meter 0x%x " - "eeprom_thermalmeter 0x%x\n", thermalvalue, - rtlpriv->dm.thermalvalue, rtlefuse->eeprom_thermalmeter)); - rtl92d_phy_ap_calibrate(hw, (thermalvalue - - rtlefuse->eeprom_thermalmeter)); - if (is2t) - rf = 2; - else - rf = 1; - if (thermalvalue) { - ele_d = rtl_get_bbreg(hw, ROFDM0_XATxIQIMBALANCE, - BMASKDWORD) & BMASKOFDM_D; - for (i = 0; i < OFDM_TABLE_SIZE_92D; i++) { - if (ele_d == (ofdmswing_table[i] & BMASKOFDM_D)) { - ofdm_index_old[0] = (u8) i; - - RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, - ("Initial pathA ele_d reg0x%x = 0x%lx," - " ofdm_index=0x%x\n", - ROFDM0_XATxIQIMBALANCE, - ele_d, ofdm_index_old[0])); - break; - } - } - if (is2t) { - ele_d = rtl_get_bbreg(hw, ROFDM0_XBTxIQIMBALANCE, - BMASKDWORD) & BMASKOFDM_D; - for (i = 0; i < OFDM_TABLE_SIZE_92D; i++) { - if (ele_d == - (ofdmswing_table[i] & BMASKOFDM_D)) { - ofdm_index_old[1] = (u8) i; - RT_TRACE(rtlpriv, COMP_POWER_TRACKING, - DBG_LOUD, - ("Initial pathB ele_d reg " - "0x%x = 0x%lx, ofdm_index " - "= 0x%x\n", - ROFDM0_XBTxIQIMBALANCE, ele_d, - ofdm_index_old[1])); - break; - } - } - } - if (rtlhal->current_bandtype == BAND_ON_2_4G) { - rtl92d_bandtype_2_4G(hw, &temp_cck, &cck_index_old); - } else { - temp_cck = 0x090e1317; - cck_index_old = 12; - } - - if (!rtlpriv->dm.thermalvalue) { - rtlpriv->dm.thermalvalue = - rtlefuse->eeprom_thermalmeter; - rtlpriv->dm.thermalvalue_lck = thermalvalue; - rtlpriv->dm.thermalvalue_iqk = thermalvalue; - rtlpriv->dm.thermalvalue_rxgain = - rtlefuse->eeprom_thermalmeter; - for (i = 0; i < rf; i++) - rtlpriv->dm.ofdm_index[i] = ofdm_index_old[i]; - rtlpriv->dm.cck_index = cck_index_old; - } - if (rtlhal->reloadtxpowerindex) { - for (i = 0; i < rf; i++) - rtlpriv->dm.ofdm_index[i] = ofdm_index_old[i]; - rtlpriv->dm.cck_index = cck_index_old; - RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, - ("reload ofdm index for band switch\n")); - } - rtlpriv->dm.thermalvalue_avg - [rtlpriv->dm.thermalvalue_avg_index] = thermalvalue; - rtlpriv->dm.thermalvalue_avg_index++; - if (rtlpriv->dm.thermalvalue_avg_index == AVG_THERMAL_NUM) - rtlpriv->dm.thermalvalue_avg_index = 0; - for (i = 0; i < AVG_THERMAL_NUM; i++) { - if (rtlpriv->dm.thermalvalue_avg[i]) { - thermalvalue_avg += - rtlpriv->dm.thermalvalue_avg[i]; - thermalvalue_avg_count++; - } - } - if (thermalvalue_avg_count) - thermalvalue = (u8) (thermalvalue_avg / - thermalvalue_avg_count); - if (rtlhal->reloadtxpowerindex) { - delta = (thermalvalue > rtlefuse->eeprom_thermalmeter) ? - (thermalvalue - rtlefuse->eeprom_thermalmeter) : - (rtlefuse->eeprom_thermalmeter - thermalvalue); - rtlhal->reloadtxpowerindex = false; - rtlpriv->dm.done_txpower = false; - } else if (rtlpriv->dm.done_txpower) { - delta = (thermalvalue > rtlpriv->dm.thermalvalue) ? - (thermalvalue - rtlpriv->dm.thermalvalue) : - (rtlpriv->dm.thermalvalue - thermalvalue); - } else { - delta = (thermalvalue > rtlefuse->eeprom_thermalmeter) ? - (thermalvalue - rtlefuse->eeprom_thermalmeter) : - (rtlefuse->eeprom_thermalmeter - thermalvalue); - } - delta_lck = (thermalvalue > rtlpriv->dm.thermalvalue_lck) ? - (thermalvalue - rtlpriv->dm.thermalvalue_lck) : - (rtlpriv->dm.thermalvalue_lck - thermalvalue); - delta_iqk = (thermalvalue > rtlpriv->dm.thermalvalue_iqk) ? - (thermalvalue - rtlpriv->dm.thermalvalue_iqk) : - (rtlpriv->dm.thermalvalue_iqk - thermalvalue); - delta_rxgain = - (thermalvalue > rtlpriv->dm.thermalvalue_rxgain) ? - (thermalvalue - rtlpriv->dm.thermalvalue_rxgain) : - (rtlpriv->dm.thermalvalue_rxgain - thermalvalue); - RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, - ("Readback Thermal Meter = 0x%x pre thermal meter 0x%x" - " eeprom_thermalmeter 0x%x delta 0x%x " - "delta_lck 0x%x delta_iqk 0x%x\n", - thermalvalue, rtlpriv->dm.thermalvalue, - rtlefuse->eeprom_thermalmeter, delta, delta_lck, - delta_iqk)); - if ((delta_lck > rtlefuse->delta_lck) && - (rtlefuse->delta_lck != 0)) { - rtlpriv->dm.thermalvalue_lck = thermalvalue; - rtl92d_phy_lc_calibrate(hw); - } - if (delta > 0 && rtlpriv->dm.txpower_track_control) { - rtlpriv->dm.done_txpower = true; - delta = (thermalvalue > rtlefuse->eeprom_thermalmeter) ? - (thermalvalue - rtlefuse->eeprom_thermalmeter) : - (rtlefuse->eeprom_thermalmeter - thermalvalue); - if (rtlhal->current_bandtype == BAND_ON_2_4G) { - offset = 4; - if (delta > INDEX_MAPPING_NUM - 1) - index = index_mapping[offset] - [INDEX_MAPPING_NUM - 1]; - else - index = index_mapping[offset][delta]; - if (thermalvalue > rtlpriv->dm.thermalvalue) { - for (i = 0; i < rf; i++) - ofdm_index[i] -= delta; - cck_index -= delta; - } else { - for (i = 0; i < rf; i++) - ofdm_index[i] += index; - cck_index += index; - } - } else if (rtlhal->current_bandtype == BAND_ON_5G) { - rtl92d_bandtype_5G(rtlhal, ofdm_index, - &internal_pa, thermalvalue, - delta, rf, rtlefuse, rtlpriv, - rtlphy, index_mapping, - index_mapping_internal_pa); - } - if (is2t) { - RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, - ("temp OFDM_A_index=0x%x, OFDM_B_index" - " = 0x%x,cck_index=0x%x\n", - rtlpriv->dm.ofdm_index[0], - rtlpriv->dm.ofdm_index[1], - rtlpriv->dm.cck_index)); - } else { - RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, - ("temp OFDM_A_index=0x%x,cck_index = " - "0x%x\n", - rtlpriv->dm.ofdm_index[0], - rtlpriv->dm.cck_index)); - } - for (i = 0; i < rf; i++) { - if (ofdm_index[i] > OFDM_TABLE_SIZE_92D - 1) - ofdm_index[i] = OFDM_TABLE_SIZE_92D - 1; - else if (ofdm_index[i] < ofdm_min_index) - ofdm_index[i] = ofdm_min_index; - } - if (rtlhal->current_bandtype == BAND_ON_2_4G) { - if (cck_index > CCK_TABLE_SIZE - 1) { - cck_index = CCK_TABLE_SIZE - 1; - } else if (internal_pa || - rtlhal->current_bandtype == - BAND_ON_2_4G) { - if (ofdm_index[i] < - ofdm_min_index_internal_pa) - ofdm_index[i] = - ofdm_min_index_internal_pa; - } else if (cck_index < 0) { - cck_index = 0; - } - } - if (is2t) { - RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, - ("new OFDM_A_index=0x%x, OFDM_B_index " - "= 0x%x, cck_index=0x%x\n", - ofdm_index[0], ofdm_index[1], - cck_index)); - } else { - RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, - ("new OFDM_A_index=0x%x,cck_index = " - "0x%x\n", - ofdm_index[0], cck_index)); - } - ele_d = (ofdmswing_table[(u8) ofdm_index[0]] & - 0xFFC00000) >> 22; - val_x = rtlphy->iqk_matrix_regsetting - [indexforchannel].value[0][0]; - val_y = rtlphy->iqk_matrix_regsetting - [indexforchannel].value[0][1]; - if (val_x != 0) { - if ((val_x & 0x00000200) != 0) - val_x = val_x | 0xFFFFFC00; - ele_a = - ((val_x * ele_d) >> 8) & 0x000003FF; - - /* new element C = element D x Y */ - if ((val_y & 0x00000200) != 0) - val_y = val_y | 0xFFFFFC00; - ele_c = ((val_y * ele_d) >> 8) & 0x000003FF; - - /* wirte new elements A, C, D to regC80 and - * regC94, element B is always 0 */ - value32 = (ele_d << 22) | ((ele_c & 0x3F) << - 16) | ele_a; - rtl_set_bbreg(hw, ROFDM0_XATxIQIMBALANCE, - BMASKDWORD, value32); - - value32 = (ele_c & 0x000003C0) >> 6; - rtl_set_bbreg(hw, ROFDM0_XCTxAFE, BMASKH4BITS, - value32); - - value32 = ((val_x * ele_d) >> 7) & 0x01; - rtl_set_bbreg(hw, ROFDM0_ECCATHRESHOLD, BIT(24), - value32); - - } else { - rtl_set_bbreg(hw, ROFDM0_XATxIQIMBALANCE, - BMASKDWORD, - ofdmswing_table - [(u8)ofdm_index[0]]); - rtl_set_bbreg(hw, ROFDM0_XCTxAFE, BMASKH4BITS, - 0x00); - rtl_set_bbreg(hw, ROFDM0_ECCATHRESHOLD, - BIT(24), 0x00); - } - - RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, - ("TxPwrTracking for interface %d path A: X =" - " 0x%lx, Y = 0x%lx ele_A = 0x%lx ele_C = " - "0x%lx ele_D = 0x%lx 0xe94 = 0x%lx 0xe9c = " - "0x%lx\n", rtlhal->interfaceindex, - val_x, val_y, ele_a, ele_c, ele_d, - val_x, val_y)); - - if (rtlhal->current_bandtype == BAND_ON_2_4G) { - /* Adjust CCK according to IQK result */ - if (!rtlpriv->dm.cck_inch14) { - rtl_write_byte(rtlpriv, 0xa22, - cckswing_table_ch1ch13 - [(u8)cck_index][0]); - rtl_write_byte(rtlpriv, 0xa23, - cckswing_table_ch1ch13 - [(u8)cck_index][1]); - rtl_write_byte(rtlpriv, 0xa24, - cckswing_table_ch1ch13 - [(u8)cck_index][2]); - rtl_write_byte(rtlpriv, 0xa25, - cckswing_table_ch1ch13 - [(u8)cck_index][3]); - rtl_write_byte(rtlpriv, 0xa26, - cckswing_table_ch1ch13 - [(u8)cck_index][4]); - rtl_write_byte(rtlpriv, 0xa27, - cckswing_table_ch1ch13 - [(u8)cck_index][5]); - rtl_write_byte(rtlpriv, 0xa28, - cckswing_table_ch1ch13 - [(u8)cck_index][6]); - rtl_write_byte(rtlpriv, 0xa29, - cckswing_table_ch1ch13 - [(u8)cck_index][7]); - } else { - rtl_write_byte(rtlpriv, 0xa22, - cckswing_table_ch14 - [(u8)cck_index][0]); - rtl_write_byte(rtlpriv, 0xa23, - cckswing_table_ch14 - [(u8)cck_index][1]); - rtl_write_byte(rtlpriv, 0xa24, - cckswing_table_ch14 - [(u8)cck_index][2]); - rtl_write_byte(rtlpriv, 0xa25, - cckswing_table_ch14 - [(u8)cck_index][3]); - rtl_write_byte(rtlpriv, 0xa26, - cckswing_table_ch14 - [(u8)cck_index][4]); - rtl_write_byte(rtlpriv, 0xa27, - cckswing_table_ch14 - [(u8)cck_index][5]); - rtl_write_byte(rtlpriv, 0xa28, - cckswing_table_ch14 - [(u8)cck_index][6]); - rtl_write_byte(rtlpriv, 0xa29, - cckswing_table_ch14 - [(u8)cck_index][7]); - } - } - if (is2t) { - ele_d = (ofdmswing_table[(u8) ofdm_index[1]] & - 0xFFC00000) >> 22; - val_x = rtlphy->iqk_matrix_regsetting - [indexforchannel].value[0][4]; - val_y = rtlphy->iqk_matrix_regsetting - [indexforchannel].value[0][5]; - if (val_x != 0) { - if ((val_x & 0x00000200) != 0) - /* consider minus */ - val_x = val_x | 0xFFFFFC00; - ele_a = ((val_x * ele_d) >> 8) & - 0x000003FF; - /* new element C = element D x Y */ - if ((val_y & 0x00000200) != 0) - val_y = - val_y | 0xFFFFFC00; - ele_c = - ((val_y * - ele_d) >> 8) & 0x00003FF; - /* write new elements A, C, D to regC88 - * and regC9C, element B is always 0 - */ - value32 = (ele_d << 22) | - ((ele_c & 0x3F) << 16) | - ele_a; - rtl_set_bbreg(hw, - ROFDM0_XBTxIQIMBALANCE, - BMASKDWORD, value32); - value32 = (ele_c & 0x000003C0) >> 6; - rtl_set_bbreg(hw, ROFDM0_XDTxAFE, - BMASKH4BITS, value32); - value32 = ((val_x * ele_d) >> 7) & 0x01; - rtl_set_bbreg(hw, ROFDM0_ECCATHRESHOLD, - BIT(28), value32); - } else { - rtl_set_bbreg(hw, - ROFDM0_XBTxIQIMBALANCE, - BMASKDWORD, - ofdmswing_table - [(u8) ofdm_index[1]]); - rtl_set_bbreg(hw, ROFDM0_XDTxAFE, - BMASKH4BITS, 0x00); - rtl_set_bbreg(hw, ROFDM0_ECCATHRESHOLD, - BIT(28), 0x00); - } - RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, - ("TxPwrTracking path B: X = 0x%lx, " - "Y = 0x%lx ele_A = 0x%lx ele_C = 0x" - "%lx ele_D = 0x%lx 0xeb4 = 0x%lx " - "0xebc = 0x%lx\n", - val_x, val_y, ele_a, ele_c, - ele_d, val_x, val_y)); - } - RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, - ("TxPwrTracking 0xc80 = 0x%x, 0xc94 = " - "0x%x RF 0x24 = 0x%x\n", - rtl_get_bbreg(hw, 0xc80, BMASKDWORD), - rtl_get_bbreg(hw, 0xc94, BMASKDWORD), - rtl_get_rfreg(hw, RF90_PATH_A, 0x24, - BRFREGOFFSETMASK))); - } - if ((delta_iqk > rtlefuse->delta_iqk) && - (rtlefuse->delta_iqk != 0)) { - rtl92d_phy_reset_iqk_result(hw); - rtlpriv->dm.thermalvalue_iqk = thermalvalue; - rtl92d_phy_iq_calibrate(hw); - } - if (delta_rxgain > 0 && rtlhal->current_bandtype == BAND_ON_5G - && thermalvalue <= rtlefuse->eeprom_thermalmeter) { - rtlpriv->dm.thermalvalue_rxgain = thermalvalue; - rtl92d_dm_rxgain_tracking_thermalmeter(hw); - } - if (rtlpriv->dm.txpower_track_control) - rtlpriv->dm.thermalvalue = thermalvalue; - } - - RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, ("<===\n")); -} - -static void rtl92d_dm_initialize_txpower_tracking(struct ieee80211_hw *hw) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - - rtlpriv->dm.txpower_tracking = true; - rtlpriv->dm.txpower_trackinginit = false; - rtlpriv->dm.txpower_track_control = true; - RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, - ("pMgntInfo->txpower_tracking = %d\n", - rtlpriv->dm.txpower_tracking)); -} - -void rtl92d_dm_check_txpower_tracking_thermal_meter(struct ieee80211_hw *hw) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - static u8 tm_trigger; - - if (!rtlpriv->dm.txpower_tracking) - return; - - if (!tm_trigger) { - rtl_set_rfreg(hw, RF90_PATH_A, RF_T_METER, BIT(17) | - BIT(16), 0x03); - RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, - ("Trigger 92S Thermal Meter!!\n")); - tm_trigger = 1; - return; - } else { - RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, - ("Schedule TxPowerTracking direct call!!\n")); - rtl92d_dm_txpower_tracking_callback_thermalmeter(hw); - tm_trigger = 0; - } -} - -void rtl92d_dm_init_rate_adaptive_mask(struct ieee80211_hw *hw) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rate_adaptive *ra = &(rtlpriv->ra); - - ra->ratr_state = DM_RATR_STA_INIT; - ra->pre_ratr_state = DM_RATR_STA_INIT; - if (rtlpriv->dm.dm_type == DM_TYPE_BYDRIVER) - rtlpriv->dm.useramask = true; - else - rtlpriv->dm.useramask = false; -} - -void rtl92d_dm_init(struct ieee80211_hw *hw) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - - rtlpriv->dm.dm_type = DM_TYPE_BYDRIVER; - rtl92d_dm_diginit(hw); - rtl92d_dm_init_dynamic_txpower(hw); - rtl92d_dm_init_edca_turbo(hw); - rtl92d_dm_init_rate_adaptive_mask(hw); - rtl92d_dm_initialize_txpower_tracking(hw); -} - -void rtl92d_dm_watchdog(struct ieee80211_hw *hw) -{ - struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); - bool fw_current_inpsmode = false; - bool fwps_awake = true; - - /* 1. RF is OFF. (No need to do DM.) - * 2. Fw is under power saving mode for FwLPS. - * (Prevent from SW/FW I/O racing.) - * 3. IPS workitem is scheduled. (Prevent from IPS sequence - * to be swapped with DM. - * 4. RFChangeInProgress is TRUE. - * (Prevent from broken by IPS/HW/SW Rf off.) */ - - if ((ppsc->rfpwr_state == ERFON) && ((!fw_current_inpsmode) && - fwps_awake) && (!ppsc->rfchange_inprogress)) { - rtl92d_dm_pwdb_monitor(hw); - rtl92d_dm_false_alarm_counter_statistics(hw); - rtl92d_dm_find_minimum_rssi(hw); - rtl92d_dm_dig(hw); - /* rtl92d_dm_dynamic_bb_powersaving(hw); */ - rtl92d_dm_dynamic_txpower(hw); - /* rtl92d_dm_check_txpower_tracking_thermal_meter(hw); */ - /* rtl92d_dm_refresh_rate_adaptive_mask(hw); */ - /* rtl92d_dm_interrupt_migration(hw); */ - rtl92d_dm_check_edca_turbo(hw); - } -} diff --git a/trunk/drivers/net/wireless/rtlwifi/rtl8192de/dm.h b/trunk/drivers/net/wireless/rtlwifi/rtl8192de/dm.h deleted file mode 100644 index 69354657f0f5..000000000000 --- a/trunk/drivers/net/wireless/rtlwifi/rtl8192de/dm.h +++ /dev/null @@ -1,212 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2009-2010 Realtek Corporation. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * The full GNU General Public License is included in this distribution in the - * file called LICENSE. - * - * Contact Information: - * wlanfae - * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, - * Hsinchu 300, Taiwan. - * - * Larry Finger - * - *****************************************************************************/ - -#ifndef __RTL92C_DM_H__ -#define __RTL92C_DM_H__ - -#define HAL_DM_DIG_DISABLE BIT(0) -#define HAL_DM_HIPWR_DISABLE BIT(1) - -#define OFDM_TABLE_LENGTH 37 -#define OFDM_TABLE_SIZE_92D 43 -#define CCK_TABLE_LENGTH 33 - -#define CCK_TABLE_SIZE 33 - -#define BW_AUTO_SWITCH_HIGH_LOW 25 -#define BW_AUTO_SWITCH_LOW_HIGH 30 - -#define DM_DIG_THRESH_HIGH 40 -#define DM_DIG_THRESH_LOW 35 - -#define DM_FALSEALARM_THRESH_LOW 400 -#define DM_FALSEALARM_THRESH_HIGH 1000 - -#define DM_DIG_MAX 0x3e -#define DM_DIG_MIN 0x1c - -#define DM_DIG_FA_UPPER 0x32 -#define DM_DIG_FA_LOWER 0x20 -#define DM_DIG_FA_TH0 0x100 -#define DM_DIG_FA_TH1 0x400 -#define DM_DIG_FA_TH2 0x600 - -#define DM_DIG_BACKOFF_MAX 12 -#define DM_DIG_BACKOFF_MIN -4 -#define DM_DIG_BACKOFF_DEFAULT 10 - -#define RXPATHSELECTION_SS_TH_lOW 30 -#define RXPATHSELECTION_DIFF_TH 18 - -#define DM_RATR_STA_INIT 0 -#define DM_RATR_STA_HIGH 1 -#define DM_RATR_STA_MIDDLE 2 -#define DM_RATR_STA_LOW 3 - -#define CTS2SELF_THVAL 30 -#define REGC38_TH 20 - -#define WAIOTTHVAL 25 - -#define TXHIGHPWRLEVEL_NORMAL 0 -#define TXHIGHPWRLEVEL_LEVEL1 1 -#define TXHIGHPWRLEVEL_LEVEL2 2 -#define TXHIGHPWRLEVEL_BT1 3 -#define TXHIGHPWRLEVEL_BT2 4 - -#define DM_TYPE_BYFW 0 -#define DM_TYPE_BYDRIVER 1 - -#define TX_POWER_NEAR_FIELD_THRESH_LVL2 74 -#define TX_POWER_NEAR_FIELD_THRESH_LVL1 67 -#define INDEX_MAPPING_NUM 13 - -struct ps_t { - u8 pre_ccastate; - u8 cur_ccasate; - - u8 pre_rfstate; - u8 cur_rfstate; - - long rssi_val_min; -}; - -struct dig_t { - u8 dig_enable_flag; - u8 dig_ext_port_stage; - - u32 rssi_lowthresh; - u32 rssi_highthresh; - - u32 fa_lowthresh; - u32 fa_highthresh; - - u8 cursta_connectctate; - u8 presta_connectstate; - u8 curmultista_connectstate; - - u8 pre_igvalue; - u8 cur_igvalue; - - char backoff_val; - char backoff_val_range_max; - char backoff_val_range_min; - u8 rx_gain_range_max; - u8 rx_gain_range_min; - u8 min_undecorated_pwdb_for_dm; - long last_min_undecorated_pwdb_for_dm; - - u8 pre_cck_pd_state; - u8 cur_cck_pd_state; - - u8 pre_cck_fa_state; - u8 cur_cck_fa_state; - - u8 pre_ccastate; - u8 cur_ccasate; - - u8 large_fa_hit; - u8 forbidden_igi; - u32 recover_cnt; -}; - -struct swat { - u8 failure_cnt; - u8 try_flag; - u8 stop_trying; - long pre_rssi; - long trying_threshold; - u8 cur_antenna; - u8 pre_antenna; -}; - -enum tag_dynamic_init_gain_operation_type_definition { - DIG_TYPE_THRESH_HIGH = 0, - DIG_TYPE_THRESH_LOW = 1, - DIG_TYPE_BACKOFF = 2, - DIG_TYPE_RX_GAIN_MIN = 3, - DIG_TYPE_RX_GAIN_MAX = 4, - DIG_TYPE_ENABLE = 5, - DIG_TYPE_DISABLE = 6, - DIG_OP_TYPE_MAX -}; - -enum tag_cck_packet_detection_threshold_type_definition { - CCK_PD_STAGE_LOWRSSI = 0, - CCK_PD_STAGE_HIGHRSSI = 1, - CCK_FA_STAGE_LOW = 2, - CCK_FA_STAGE_HIGH = 3, - CCK_PD_STAGE_MAX = 4, -}; - -enum dm_1r_cca { - CCA_1R = 0, - CCA_2R = 1, - CCA_MAX = 2, -}; - -enum dm_rf { - RF_SAVE = 0, - RF_NORMAL = 1, - RF_MAX = 2, -}; - -enum dm_sw_ant_switch { - ANS_ANTENNA_B = 1, - ANS_ANTENNA_A = 2, - ANS_ANTENNA_MAX = 3, -}; - -enum dm_dig_ext_port_alg { - DIG_EXT_PORT_STAGE_0 = 0, - DIG_EXT_PORT_STAGE_1 = 1, - DIG_EXT_PORT_STAGE_2 = 2, - DIG_EXT_PORT_STAGE_3 = 3, - DIG_EXT_PORT_STAGE_MAX = 4, -}; - -enum dm_dig_connect { - DIG_STA_DISCONNECT = 0, - DIG_STA_CONNECT = 1, - DIG_STA_BEFORE_CONNECT = 2, - DIG_MULTISTA_DISCONNECT = 3, - DIG_MULTISTA_CONNECT = 4, - DIG_CONNECT_MAX -}; - -extern struct dig_t de_digtable; - -void rtl92d_dm_init(struct ieee80211_hw *hw); -void rtl92d_dm_watchdog(struct ieee80211_hw *hw); -void rtl92d_dm_init_edca_turbo(struct ieee80211_hw *hw); -void rtl92d_dm_write_dig(struct ieee80211_hw *hw); -void rtl92d_dm_check_txpower_tracking_thermal_meter(struct ieee80211_hw *hw); -void rtl92d_dm_init_rate_adaptive_mask(struct ieee80211_hw *hw); - -#endif diff --git a/trunk/drivers/net/wireless/rtlwifi/rtl8192de/fw.c b/trunk/drivers/net/wireless/rtlwifi/rtl8192de/fw.c deleted file mode 100644 index 82f060bdbc0b..000000000000 --- a/trunk/drivers/net/wireless/rtlwifi/rtl8192de/fw.c +++ /dev/null @@ -1,790 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2009-2010 Realtek Corporation. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * The full GNU General Public License is included in this distribution in the - * file called LICENSE. - * - * Contact Information: - * wlanfae - * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, - * Hsinchu 300, Taiwan. - * - * Larry Finger - * - *****************************************************************************/ - -#include "../wifi.h" -#include "../pci.h" -#include "../base.h" -#include "reg.h" -#include "def.h" -#include "fw.h" -#include "sw.h" - -static bool _rtl92d_is_fw_downloaded(struct rtl_priv *rtlpriv) -{ - return (rtl_read_dword(rtlpriv, REG_MCUFWDL) & MCUFWDL_RDY) ? - true : false; -} - -static void _rtl92d_enable_fw_download(struct ieee80211_hw *hw, bool enable) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - u8 tmp; - - if (enable) { - tmp = rtl_read_byte(rtlpriv, REG_SYS_FUNC_EN + 1); - rtl_write_byte(rtlpriv, REG_SYS_FUNC_EN + 1, tmp | 0x04); - tmp = rtl_read_byte(rtlpriv, REG_MCUFWDL); - rtl_write_byte(rtlpriv, REG_MCUFWDL, tmp | 0x01); - tmp = rtl_read_byte(rtlpriv, REG_MCUFWDL + 2); - rtl_write_byte(rtlpriv, REG_MCUFWDL + 2, tmp & 0xf7); - } else { - tmp = rtl_read_byte(rtlpriv, REG_MCUFWDL); - rtl_write_byte(rtlpriv, REG_MCUFWDL, tmp & 0xfe); - /* Reserved for fw extension. - * 0x81[7] is used for mac0 status , - * so don't write this reg here - * rtl_write_byte(rtlpriv, REG_MCUFWDL + 1, 0x00);*/ - } -} - -static void _rtl92d_fw_block_write(struct ieee80211_hw *hw, - const u8 *buffer, u32 size) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - u32 blocksize = sizeof(u32); - u8 *bufferptr = (u8 *) buffer; - u32 *pu4BytePtr = (u32 *) buffer; - u32 i, offset, blockCount, remainSize; - - blockCount = size / blocksize; - remainSize = size % blocksize; - for (i = 0; i < blockCount; i++) { - offset = i * blocksize; - rtl_write_dword(rtlpriv, (FW_8192D_START_ADDRESS + offset), - *(pu4BytePtr + i)); - } - if (remainSize) { - offset = blockCount * blocksize; - bufferptr += offset; - for (i = 0; i < remainSize; i++) { - rtl_write_byte(rtlpriv, (FW_8192D_START_ADDRESS + - offset + i), *(bufferptr + i)); - } - } -} - -static void _rtl92d_fw_page_write(struct ieee80211_hw *hw, - u32 page, const u8 *buffer, u32 size) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - u8 value8; - u8 u8page = (u8) (page & 0x07); - - value8 = (rtl_read_byte(rtlpriv, REG_MCUFWDL + 2) & 0xF8) | u8page; - rtl_write_byte(rtlpriv, (REG_MCUFWDL + 2), value8); - _rtl92d_fw_block_write(hw, buffer, size); -} - -static void _rtl92d_fill_dummy(u8 *pfwbuf, u32 *pfwlen) -{ - u32 fwlen = *pfwlen; - u8 remain = (u8) (fwlen % 4); - - remain = (remain == 0) ? 0 : (4 - remain); - while (remain > 0) { - pfwbuf[fwlen] = 0; - fwlen++; - remain--; - } - *pfwlen = fwlen; -} - -static void _rtl92d_write_fw(struct ieee80211_hw *hw, - enum version_8192d version, u8 *buffer, u32 size) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); - u8 *bufferPtr = (u8 *) buffer; - u32 pagenums, remainSize; - u32 page, offset; - - RT_TRACE(rtlpriv, COMP_FW, DBG_TRACE, ("FW size is %d bytes,\n", size)); - if (rtlhal->hw_type == HARDWARE_TYPE_RTL8192DE) - _rtl92d_fill_dummy(bufferPtr, &size); - pagenums = size / FW_8192D_PAGE_SIZE; - remainSize = size % FW_8192D_PAGE_SIZE; - if (pagenums > 8) { - RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("Page numbers should not greater then 8\n")); - } - for (page = 0; page < pagenums; page++) { - offset = page * FW_8192D_PAGE_SIZE; - _rtl92d_fw_page_write(hw, page, (bufferPtr + offset), - FW_8192D_PAGE_SIZE); - } - if (remainSize) { - offset = pagenums * FW_8192D_PAGE_SIZE; - page = pagenums; - _rtl92d_fw_page_write(hw, page, (bufferPtr + offset), - remainSize); - } -} - -static int _rtl92d_fw_free_to_go(struct ieee80211_hw *hw) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - u32 counter = 0; - u32 value32; - - do { - value32 = rtl_read_dword(rtlpriv, REG_MCUFWDL); - } while ((counter++ < FW_8192D_POLLING_TIMEOUT_COUNT) && - (!(value32 & FWDL_ChkSum_rpt))); - if (counter >= FW_8192D_POLLING_TIMEOUT_COUNT) { - RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("chksum report faill ! REG_MCUFWDL:0x%08x .\n", - value32)); - return -EIO; - } - RT_TRACE(rtlpriv, COMP_FW, DBG_TRACE, - ("Checksum report OK ! REG_MCUFWDL:0x%08x .\n", value32)); - value32 = rtl_read_dword(rtlpriv, REG_MCUFWDL); - value32 |= MCUFWDL_RDY; - rtl_write_dword(rtlpriv, REG_MCUFWDL, value32); - return 0; -} - -void rtl92d_firmware_selfreset(struct ieee80211_hw *hw) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - u8 u1b_tmp; - u8 delay = 100; - - /* Set (REG_HMETFR + 3) to 0x20 is reset 8051 */ - rtl_write_byte(rtlpriv, REG_HMETFR + 3, 0x20); - u1b_tmp = rtl_read_byte(rtlpriv, REG_SYS_FUNC_EN + 1); - while (u1b_tmp & BIT(2)) { - delay--; - if (delay == 0) - break; - udelay(50); - u1b_tmp = rtl_read_byte(rtlpriv, REG_SYS_FUNC_EN + 1); - } - RT_ASSERT((delay > 0), ("8051 reset failed!\n")); - RT_TRACE(rtlpriv, COMP_FW, DBG_DMESG, - ("=====> 8051 reset success (%d) .\n", delay)); -} - -static int _rtl92d_fw_init(struct ieee80211_hw *hw) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); - u32 counter; - - RT_TRACE(rtlpriv, COMP_FW, DBG_DMESG, ("FW already have download\n")); - /* polling for FW ready */ - counter = 0; - do { - if (rtlhal->interfaceindex == 0) { - if (rtl_read_byte(rtlpriv, FW_MAC0_READY) & - MAC0_READY) { - RT_TRACE(rtlpriv, COMP_FW, DBG_DMESG, - ("Polling FW ready success!! " - "REG_MCUFWDL: 0x%x .\n", - rtl_read_byte(rtlpriv, - FW_MAC0_READY))); - return 0; - } - udelay(5); - } else { - if (rtl_read_byte(rtlpriv, FW_MAC1_READY) & - MAC1_READY) { - RT_TRACE(rtlpriv, COMP_FW, DBG_DMESG, - ("Polling FW ready success!! " - "REG_MCUFWDL: 0x%x .\n", - rtl_read_byte(rtlpriv, - FW_MAC1_READY))); - return 0; - } - udelay(5); - } - } while (counter++ < POLLING_READY_TIMEOUT_COUNT); - - if (rtlhal->interfaceindex == 0) { - RT_TRACE(rtlpriv, COMP_FW, DBG_DMESG, - ("Polling FW ready fail!! MAC0 FW init not ready: " - "0x%x .\n", - rtl_read_byte(rtlpriv, FW_MAC0_READY))); - } else { - RT_TRACE(rtlpriv, COMP_FW, DBG_DMESG, - ("Polling FW ready fail!! MAC1 FW init not ready: " - "0x%x .\n", - rtl_read_byte(rtlpriv, FW_MAC1_READY))); - } - RT_TRACE(rtlpriv, COMP_FW, DBG_DMESG, - ("Polling FW ready fail!! REG_MCUFWDL:0x%08ul .\n", - rtl_read_dword(rtlpriv, REG_MCUFWDL))); - return -1; -} - -int rtl92d_download_fw(struct ieee80211_hw *hw) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); - u8 *pfwheader; - u8 *pfwdata; - u32 fwsize; - int err; - enum version_8192d version = rtlhal->version; - u8 value; - u32 count; - bool fw_downloaded = false, fwdl_in_process = false; - unsigned long flags; - - if (!rtlhal->pfirmware) - return 1; - fwsize = rtlhal->fwsize; - pfwheader = (u8 *) rtlhal->pfirmware; - pfwdata = (u8 *) rtlhal->pfirmware; - rtlhal->fw_version = (u16) GET_FIRMWARE_HDR_VERSION(pfwheader); - rtlhal->fw_subversion = (u16) GET_FIRMWARE_HDR_SUB_VER(pfwheader); - RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, (" FirmwareVersion(%d)," - "FirmwareSubVersion(%d), Signature(%#x)\n", - rtlhal->fw_version, rtlhal->fw_subversion, - GET_FIRMWARE_HDR_SIGNATURE(pfwheader))); - if (IS_FW_HEADER_EXIST(pfwheader)) { - RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, - ("Shift 32 bytes for FW header!!\n")); - pfwdata = pfwdata + 32; - fwsize = fwsize - 32; - } - - spin_lock_irqsave(&globalmutex_for_fwdownload, flags); - fw_downloaded = _rtl92d_is_fw_downloaded(rtlpriv); - if ((rtl_read_byte(rtlpriv, 0x1f) & BIT(5)) == BIT(5)) - fwdl_in_process = true; - else - fwdl_in_process = false; - if (fw_downloaded) { - spin_unlock_irqrestore(&globalmutex_for_fwdownload, flags); - goto exit; - } else if (fwdl_in_process) { - spin_unlock_irqrestore(&globalmutex_for_fwdownload, flags); - for (count = 0; count < 5000; count++) { - udelay(500); - spin_lock_irqsave(&globalmutex_for_fwdownload, flags); - fw_downloaded = _rtl92d_is_fw_downloaded(rtlpriv); - if ((rtl_read_byte(rtlpriv, 0x1f) & BIT(5)) == BIT(5)) - fwdl_in_process = true; - else - fwdl_in_process = false; - spin_unlock_irqrestore(&globalmutex_for_fwdownload, - flags); - if (fw_downloaded) - goto exit; - else if (!fwdl_in_process) - break; - else - RT_TRACE(rtlpriv, COMP_FW, DBG_DMESG, - ("Wait for another mac " - "download fw\n")); - } - spin_lock_irqsave(&globalmutex_for_fwdownload, flags); - value = rtl_read_byte(rtlpriv, 0x1f); - value |= BIT(5); - rtl_write_byte(rtlpriv, 0x1f, value); - spin_unlock_irqrestore(&globalmutex_for_fwdownload, flags); - } else { - value = rtl_read_byte(rtlpriv, 0x1f); - value |= BIT(5); - rtl_write_byte(rtlpriv, 0x1f, value); - spin_unlock_irqrestore(&globalmutex_for_fwdownload, flags); - } - - /* If 8051 is running in RAM code, driver should - * inform Fw to reset by itself, or it will cause - * download Fw fail.*/ - /* 8051 RAM code */ - if (rtl_read_byte(rtlpriv, REG_MCUFWDL) & BIT(7)) { - rtl92d_firmware_selfreset(hw); - rtl_write_byte(rtlpriv, REG_MCUFWDL, 0x00); - } - _rtl92d_enable_fw_download(hw, true); - _rtl92d_write_fw(hw, version, pfwdata, fwsize); - _rtl92d_enable_fw_download(hw, false); - spin_lock_irqsave(&globalmutex_for_fwdownload, flags); - err = _rtl92d_fw_free_to_go(hw); - /* download fw over,clear 0x1f[5] */ - value = rtl_read_byte(rtlpriv, 0x1f); - value &= (~BIT(5)); - rtl_write_byte(rtlpriv, 0x1f, value); - spin_unlock_irqrestore(&globalmutex_for_fwdownload, flags); - if (err) { - RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("fw is not ready to run!\n")); - goto exit; - } else { - RT_TRACE(rtlpriv, COMP_FW, DBG_TRACE, - ("fw is ready to run!\n")); - } -exit: - err = _rtl92d_fw_init(hw); - return err; -} - -static bool _rtl92d_check_fw_read_last_h2c(struct ieee80211_hw *hw, u8 boxnum) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - u8 val_hmetfr; - bool result = false; - - val_hmetfr = rtl_read_byte(rtlpriv, REG_HMETFR); - if (((val_hmetfr >> boxnum) & BIT(0)) == 0) - result = true; - return result; -} - -static void _rtl92d_fill_h2c_command(struct ieee80211_hw *hw, - u8 element_id, u32 cmd_len, u8 *cmdbuffer) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); - struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); - u8 boxnum; - u16 box_reg = 0, box_extreg = 0; - u8 u1b_tmp; - bool isfw_read = false; - u8 buf_index = 0; - bool bwrite_sucess = false; - u8 wait_h2c_limmit = 100; - u8 wait_writeh2c_limmit = 100; - u8 boxcontent[4], boxextcontent[2]; - u32 h2c_waitcounter = 0; - unsigned long flag; - u8 idx; - - if (ppsc->rfpwr_state == ERFOFF || ppsc->inactive_pwrstate == ERFOFF) { - RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, - ("Return as RF is off!!!\n")); - return; - } - RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, ("come in\n")); - while (true) { - spin_lock_irqsave(&rtlpriv->locks.h2c_lock, flag); - if (rtlhal->h2c_setinprogress) { - RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, - ("H2C set in progress! Wait to set.." - "element_id(%d).\n", element_id)); - - while (rtlhal->h2c_setinprogress) { - spin_unlock_irqrestore(&rtlpriv->locks.h2c_lock, - flag); - h2c_waitcounter++; - RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, - ("Wait 100 us (%d times)...\n", - h2c_waitcounter)); - udelay(100); - - if (h2c_waitcounter > 1000) - return; - - spin_lock_irqsave(&rtlpriv->locks.h2c_lock, - flag); - } - spin_unlock_irqrestore(&rtlpriv->locks.h2c_lock, flag); - } else { - rtlhal->h2c_setinprogress = true; - spin_unlock_irqrestore(&rtlpriv->locks.h2c_lock, flag); - break; - } - } - while (!bwrite_sucess) { - wait_writeh2c_limmit--; - if (wait_writeh2c_limmit == 0) { - RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("Write H2C fail because no trigger " - "for FW INT!\n")); - break; - } - boxnum = rtlhal->last_hmeboxnum; - switch (boxnum) { - case 0: - box_reg = REG_HMEBOX_0; - box_extreg = REG_HMEBOX_EXT_0; - break; - case 1: - box_reg = REG_HMEBOX_1; - box_extreg = REG_HMEBOX_EXT_1; - break; - case 2: - box_reg = REG_HMEBOX_2; - box_extreg = REG_HMEBOX_EXT_2; - break; - case 3: - box_reg = REG_HMEBOX_3; - box_extreg = REG_HMEBOX_EXT_3; - break; - default: - RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("switch case not process\n")); - break; - } - isfw_read = _rtl92d_check_fw_read_last_h2c(hw, boxnum); - while (!isfw_read) { - wait_h2c_limmit--; - if (wait_h2c_limmit == 0) { - RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, - ("Wating too long for FW read " - "clear HMEBox(%d)!\n", boxnum)); - break; - } - udelay(10); - isfw_read = _rtl92d_check_fw_read_last_h2c(hw, boxnum); - u1b_tmp = rtl_read_byte(rtlpriv, 0x1BF); - RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, - ("Wating for FW read clear HMEBox(%d)!!! " - "0x1BF = %2x\n", boxnum, u1b_tmp)); - } - if (!isfw_read) { - RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, - ("Write H2C register BOX[%d] fail!!!!! " - "Fw do not read.\n", boxnum)); - break; - } - memset(boxcontent, 0, sizeof(boxcontent)); - memset(boxextcontent, 0, sizeof(boxextcontent)); - boxcontent[0] = element_id; - RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, - ("Write element_id box_reg(%4x) = %2x\n", - box_reg, element_id)); - switch (cmd_len) { - case 1: - boxcontent[0] &= ~(BIT(7)); - memcpy(boxcontent + 1, cmdbuffer + buf_index, 1); - for (idx = 0; idx < 4; idx++) - rtl_write_byte(rtlpriv, box_reg + idx, - boxcontent[idx]); - break; - case 2: - boxcontent[0] &= ~(BIT(7)); - memcpy(boxcontent + 1, cmdbuffer + buf_index, 2); - for (idx = 0; idx < 4; idx++) - rtl_write_byte(rtlpriv, box_reg + idx, - boxcontent[idx]); - break; - case 3: - boxcontent[0] &= ~(BIT(7)); - memcpy(boxcontent + 1, cmdbuffer + buf_index, 3); - for (idx = 0; idx < 4; idx++) - rtl_write_byte(rtlpriv, box_reg + idx, - boxcontent[idx]); - break; - case 4: - boxcontent[0] |= (BIT(7)); - memcpy(boxextcontent, cmdbuffer + buf_index, 2); - memcpy(boxcontent + 1, cmdbuffer + buf_index + 2, 2); - for (idx = 0; idx < 2; idx++) - rtl_write_byte(rtlpriv, box_extreg + idx, - boxextcontent[idx]); - for (idx = 0; idx < 4; idx++) - rtl_write_byte(rtlpriv, box_reg + idx, - boxcontent[idx]); - break; - case 5: - boxcontent[0] |= (BIT(7)); - memcpy(boxextcontent, cmdbuffer + buf_index, 2); - memcpy(boxcontent + 1, cmdbuffer + buf_index + 2, 3); - for (idx = 0; idx < 2; idx++) - rtl_write_byte(rtlpriv, box_extreg + idx, - boxextcontent[idx]); - for (idx = 0; idx < 4; idx++) - rtl_write_byte(rtlpriv, box_reg + idx, - boxcontent[idx]); - break; - default: - RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("switch case not process\n")); - break; - } - bwrite_sucess = true; - rtlhal->last_hmeboxnum = boxnum + 1; - if (rtlhal->last_hmeboxnum == 4) - rtlhal->last_hmeboxnum = 0; - RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, - ("pHalData->last_hmeboxnum = %d\n", - rtlhal->last_hmeboxnum)); - } - spin_lock_irqsave(&rtlpriv->locks.h2c_lock, flag); - rtlhal->h2c_setinprogress = false; - spin_unlock_irqrestore(&rtlpriv->locks.h2c_lock, flag); - RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, ("go out\n")); -} - -void rtl92d_fill_h2c_cmd(struct ieee80211_hw *hw, - u8 element_id, u32 cmd_len, u8 *cmdbuffer) -{ - struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); - u32 tmp_cmdbuf[2]; - - if (rtlhal->fw_ready == false) { - RT_ASSERT(false, ("return H2C cmd because of Fw " - "download fail!!!\n")); - return; - } - memset(tmp_cmdbuf, 0, 8); - memcpy(tmp_cmdbuf, cmdbuffer, cmd_len); - _rtl92d_fill_h2c_command(hw, element_id, cmd_len, (u8 *)&tmp_cmdbuf); - return; -} - -void rtl92d_set_fw_pwrmode_cmd(struct ieee80211_hw *hw, u8 mode) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - u8 u1_h2c_set_pwrmode[3] = { 0 }; - struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); - - RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, ("FW LPS mode = %d\n", mode)); - SET_H2CCMD_PWRMODE_PARM_MODE(u1_h2c_set_pwrmode, mode); - SET_H2CCMD_PWRMODE_PARM_SMART_PS(u1_h2c_set_pwrmode, 1); - SET_H2CCMD_PWRMODE_PARM_BCN_PASS_TIME(u1_h2c_set_pwrmode, - ppsc->reg_max_lps_awakeintvl); - RT_PRINT_DATA(rtlpriv, COMP_CMD, DBG_DMESG, - "rtl92d_set_fw_rsvdpagepkt(): u1_h2c_set_pwrmode\n", - u1_h2c_set_pwrmode, 3); - rtl92d_fill_h2c_cmd(hw, H2C_SETPWRMODE, 3, u1_h2c_set_pwrmode); -} - -static bool _rtl92d_cmd_send_packet(struct ieee80211_hw *hw, - struct sk_buff *skb) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); - struct rtl8192_tx_ring *ring; - struct rtl_tx_desc *pdesc; - u8 idx = 0; - unsigned long flags; - struct sk_buff *pskb; - - ring = &rtlpci->tx_ring[BEACON_QUEUE]; - pskb = __skb_dequeue(&ring->queue); - if (pskb) - kfree_skb(pskb); - spin_lock_irqsave(&rtlpriv->locks.irq_th_lock, flags); - pdesc = &ring->desc[idx]; - /* discard output from call below */ - rtlpriv->cfg->ops->get_desc((u8 *) pdesc, true, HW_DESC_OWN); - rtlpriv->cfg->ops->fill_tx_cmddesc(hw, (u8 *) pdesc, 1, 1, skb); - __skb_queue_tail(&ring->queue, skb); - spin_unlock_irqrestore(&rtlpriv->locks.irq_th_lock, flags); - rtlpriv->cfg->ops->tx_polling(hw, BEACON_QUEUE); - return true; -} - -#define BEACON_PG 0 /*->1 */ -#define PSPOLL_PG 2 -#define NULL_PG 3 -#define PROBERSP_PG 4 /*->5 */ -#define TOTAL_RESERVED_PKT_LEN 768 - -static u8 reserved_page_packet[TOTAL_RESERVED_PKT_LEN] = { - /* page 0 beacon */ - 0x80, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0x00, 0xE0, 0x4C, 0x76, 0x00, 0x42, - 0x00, 0x40, 0x10, 0x10, 0x00, 0x03, 0x50, 0x08, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x64, 0x00, 0x00, 0x04, 0x00, 0x0C, 0x6C, 0x69, - 0x6E, 0x6B, 0x73, 0x79, 0x73, 0x5F, 0x77, 0x6C, - 0x61, 0x6E, 0x01, 0x04, 0x82, 0x84, 0x8B, 0x96, - 0x03, 0x01, 0x01, 0x06, 0x02, 0x00, 0x00, 0x2A, - 0x01, 0x00, 0x32, 0x08, 0x24, 0x30, 0x48, 0x6C, - 0x0C, 0x12, 0x18, 0x60, 0x2D, 0x1A, 0x6C, 0x18, - 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x3D, 0x00, 0xDD, 0x06, 0x00, 0xE0, 0x4C, 0x02, - 0x01, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - - /* page 1 beacon */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x10, 0x00, 0x20, 0x8C, 0x00, 0x12, 0x10, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - - /* page 2 ps-poll */ - 0xA4, 0x10, 0x01, 0xC0, 0x00, 0x40, 0x10, 0x10, - 0x00, 0x03, 0x00, 0xE0, 0x4C, 0x76, 0x00, 0x42, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x18, 0x00, 0x20, 0x8C, 0x00, 0x12, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, - 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - - /* page 3 null */ - 0x48, 0x01, 0x00, 0x00, 0x00, 0x40, 0x10, 0x10, - 0x00, 0x03, 0x00, 0xE0, 0x4C, 0x76, 0x00, 0x42, - 0x00, 0x40, 0x10, 0x10, 0x00, 0x03, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x72, 0x00, 0x20, 0x8C, 0x00, 0x12, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, - 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - - /* page 4 probe_resp */ - 0x50, 0x00, 0x00, 0x00, 0x00, 0x40, 0x10, 0x10, - 0x00, 0x03, 0x00, 0xE0, 0x4C, 0x76, 0x00, 0x42, - 0x00, 0x40, 0x10, 0x10, 0x00, 0x03, 0x00, 0x00, - 0x9E, 0x46, 0x15, 0x32, 0x27, 0xF2, 0x2D, 0x00, - 0x64, 0x00, 0x00, 0x04, 0x00, 0x0C, 0x6C, 0x69, - 0x6E, 0x6B, 0x73, 0x79, 0x73, 0x5F, 0x77, 0x6C, - 0x61, 0x6E, 0x01, 0x04, 0x82, 0x84, 0x8B, 0x96, - 0x03, 0x01, 0x01, 0x06, 0x02, 0x00, 0x00, 0x2A, - 0x01, 0x00, 0x32, 0x08, 0x24, 0x30, 0x48, 0x6C, - 0x0C, 0x12, 0x18, 0x60, 0x2D, 0x1A, 0x6C, 0x18, - 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x3D, 0x00, 0xDD, 0x06, 0x00, 0xE0, 0x4C, 0x02, - 0x01, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - - /* page 5 probe_resp */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -}; - -void rtl92d_set_fw_rsvdpagepkt(struct ieee80211_hw *hw, bool dl_finished) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); - struct sk_buff *skb = NULL; - u32 totalpacketlen; - bool rtstatus; - u8 u1RsvdPageLoc[3] = { 0 }; - bool dlok = false; - u8 *beacon; - u8 *p_pspoll; - u8 *nullfunc; - u8 *p_probersp; - /*--------------------------------------------------------- - (1) beacon - ---------------------------------------------------------*/ - beacon = &reserved_page_packet[BEACON_PG * 128]; - SET_80211_HDR_ADDRESS2(beacon, mac->mac_addr); - SET_80211_HDR_ADDRESS3(beacon, mac->bssid); - /*------------------------------------------------------- - (2) ps-poll - --------------------------------------------------------*/ - p_pspoll = &reserved_page_packet[PSPOLL_PG * 128]; - SET_80211_PS_POLL_AID(p_pspoll, (mac->assoc_id | 0xc000)); - SET_80211_PS_POLL_BSSID(p_pspoll, mac->bssid); - SET_80211_PS_POLL_TA(p_pspoll, mac->mac_addr); - SET_H2CCMD_RSVDPAGE_LOC_PSPOLL(u1RsvdPageLoc, PSPOLL_PG); - /*-------------------------------------------------------- - (3) null data - ---------------------------------------------------------*/ - nullfunc = &reserved_page_packet[NULL_PG * 128]; - SET_80211_HDR_ADDRESS1(nullfunc, mac->bssid); - SET_80211_HDR_ADDRESS2(nullfunc, mac->mac_addr); - SET_80211_HDR_ADDRESS3(nullfunc, mac->bssid); - SET_H2CCMD_RSVDPAGE_LOC_NULL_DATA(u1RsvdPageLoc, NULL_PG); - /*--------------------------------------------------------- - (4) probe response - ----------------------------------------------------------*/ - p_probersp = &reserved_page_packet[PROBERSP_PG * 128]; - SET_80211_HDR_ADDRESS1(p_probersp, mac->bssid); - SET_80211_HDR_ADDRESS2(p_probersp, mac->mac_addr); - SET_80211_HDR_ADDRESS3(p_probersp, mac->bssid); - SET_H2CCMD_RSVDPAGE_LOC_PROBE_RSP(u1RsvdPageLoc, PROBERSP_PG); - totalpacketlen = TOTAL_RESERVED_PKT_LEN; - RT_PRINT_DATA(rtlpriv, COMP_CMD, DBG_LOUD, - "rtl92d_set_fw_rsvdpagepkt(): HW_VAR_SET_TX_CMD: ALL\n", - &reserved_page_packet[0], totalpacketlen); - RT_PRINT_DATA(rtlpriv, COMP_CMD, DBG_DMESG, - "rtl92d_set_fw_rsvdpagepkt(): HW_VAR_SET_TX_CMD: ALL\n", - u1RsvdPageLoc, 3); - skb = dev_alloc_skb(totalpacketlen); - memcpy((u8 *) skb_put(skb, totalpacketlen), &reserved_page_packet, - totalpacketlen); - rtstatus = _rtl92d_cmd_send_packet(hw, skb); - - if (rtstatus) - dlok = true; - if (dlok) { - RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, - ("Set RSVD page location to Fw.\n")); - RT_PRINT_DATA(rtlpriv, COMP_CMD, DBG_DMESG, - "H2C_RSVDPAGE:\n", u1RsvdPageLoc, 3); - rtl92d_fill_h2c_cmd(hw, H2C_RSVDPAGE, - sizeof(u1RsvdPageLoc), u1RsvdPageLoc); - } else - RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, - ("Set RSVD page location to Fw FAIL!!!!!!.\n")); -} - -void rtl92d_set_fw_joinbss_report_cmd(struct ieee80211_hw *hw, u8 mstatus) -{ - u8 u1_joinbssrpt_parm[1] = {0}; - - SET_H2CCMD_JOINBSSRPT_PARM_OPMODE(u1_joinbssrpt_parm, mstatus); - rtl92d_fill_h2c_cmd(hw, H2C_JOINBSSRPT, 1, u1_joinbssrpt_parm); -} diff --git a/trunk/drivers/net/wireless/rtlwifi/rtl8192de/fw.h b/trunk/drivers/net/wireless/rtlwifi/rtl8192de/fw.h deleted file mode 100644 index 0c4d489eaa48..000000000000 --- a/trunk/drivers/net/wireless/rtlwifi/rtl8192de/fw.h +++ /dev/null @@ -1,155 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2009-2010 Realtek Corporation. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * The full GNU General Public License is included in this distribution in the - * file called LICENSE. - * - * Contact Information: - * wlanfae - * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, - * Hsinchu 300, Taiwan. - * - * Larry Finger - * - *****************************************************************************/ - -#ifndef __RTL92D__FW__H__ -#define __RTL92D__FW__H__ - -#define FW_8192D_START_ADDRESS 0x1000 -#define FW_8192D_PAGE_SIZE 4096 -#define FW_8192D_POLLING_TIMEOUT_COUNT 1000 - -#define IS_FW_HEADER_EXIST(_pfwhdr) \ - ((GET_FIRMWARE_HDR_SIGNATURE(_pfwhdr) & 0xFFF0) == 0x92C0 || \ - (GET_FIRMWARE_HDR_SIGNATURE(_pfwhdr) & 0xFFF0) == 0x88C0 || \ - (GET_FIRMWARE_HDR_SIGNATURE(_pfwhdr) & 0xFFFF) == 0x92D0 || \ - (GET_FIRMWARE_HDR_SIGNATURE(_pfwhdr) & 0xFFFF) == 0x92D1 || \ - (GET_FIRMWARE_HDR_SIGNATURE(_pfwhdr) & 0xFFFF) == 0x92D2 || \ - (GET_FIRMWARE_HDR_SIGNATURE(_pfwhdr) & 0xFFFF) == 0x92D3) - -/* Define a macro that takes an le32 word, converts it to host ordering, - * right shifts by a specified count, creates a mask of the specified - * bit count, and extracts that number of bits. - */ - -#define SHIFT_AND_MASK_LE(__pdesc, __shift, __mask) \ - ((le32_to_cpu(*(((__le32 *)(__pdesc)))) >> (__shift)) & \ - BIT_LEN_MASK_32(__mask)) - -/* Firmware Header(8-byte alinment required) */ -/* --- LONG WORD 0 ---- */ -#define GET_FIRMWARE_HDR_SIGNATURE(__fwhdr) \ - SHIFT_AND_MASK_LE(__fwhdr, 0, 16) -#define GET_FIRMWARE_HDR_CATEGORY(__fwhdr) \ - SHIFT_AND_MASK_LE(__fwhdr, 16, 8) -#define GET_FIRMWARE_HDR_FUNCTION(__fwhdr) \ - SHIFT_AND_MASK_LE(__fwhdr, 24, 8) -#define GET_FIRMWARE_HDR_VERSION(__fwhdr) \ - SHIFT_AND_MASK_LE(__fwhdr + 4, 0, 16) -#define GET_FIRMWARE_HDR_SUB_VER(__fwhdr) \ - SHIFT_AND_MASK_LE(__fwhdr + 4, 16, 8) -#define GET_FIRMWARE_HDR_RSVD1(__fwhdr) \ - SHIFT_AND_MASK_LE(__fwhdr + 4, 24, 8) - -/* --- LONG WORD 1 ---- */ -#define GET_FIRMWARE_HDR_MONTH(__fwhdr) \ - SHIFT_AND_MASK_LE(__fwhdr + 8, 0, 8) -#define GET_FIRMWARE_HDR_DATE(__fwhdr) \ - SHIFT_AND_MASK_LE(__fwhdr + 8, 8, 8) -#define GET_FIRMWARE_HDR_HOUR(__fwhdr) \ - SHIFT_AND_MASK_LE(__fwhdr + 8, 16, 8) -#define GET_FIRMWARE_HDR_MINUTE(__fwhdr) \ - SHIFT_AND_MASK_LE(__fwhdr + 8, 24, 8) -#define GET_FIRMWARE_HDR_ROMCODE_SIZE(__fwhdr) \ - SHIFT_AND_MASK_LE(__fwhdr + 12, 0, 16) -#define GET_FIRMWARE_HDR_RSVD2(__fwhdr) \ - SHIFT_AND_MASK_LE(__fwhdr + 12, 16, 16) - -/* --- LONG WORD 2 ---- */ -#define GET_FIRMWARE_HDR_SVN_IDX(__fwhdr) \ - SHIFT_AND_MASK_LE(__fwhdr + 16, 0, 32) -#define GET_FIRMWARE_HDR_RSVD3(__fwhdr) \ - SHIFT_AND_MASK_LE(__fwhdr + 20, 0, 32) - -/* --- LONG WORD 3 ---- */ -#define GET_FIRMWARE_HDR_RSVD4(__fwhdr) \ - SHIFT_AND_MASK_LE(__fwhdr + 24, 0, 32) -#define GET_FIRMWARE_HDR_RSVD5(__fwhdr) \ - SHIFT_AND_MASK_LE(__fwhdr + 28, 0, 32) - -#define pagenum_128(_len) \ - (u32)(((_len) >> 7) + ((_len) & 0x7F ? 1 : 0)) - -#define SET_H2CCMD_PWRMODE_PARM_MODE(__ph2ccmd, __val) \ - SET_BITS_TO_LE_1BYTE(__ph2ccmd, 0, 8, __val) -#define SET_H2CCMD_PWRMODE_PARM_SMART_PS(__ph2ccmd, __val) \ - SET_BITS_TO_LE_1BYTE((__ph2ccmd) + 1, 0, 8, __val) -#define SET_H2CCMD_PWRMODE_PARM_BCN_PASS_TIME(__ph2ccmd, __val) \ - SET_BITS_TO_LE_1BYTE((__ph2ccmd) + 2, 0, 8, __val) -#define SET_H2CCMD_JOINBSSRPT_PARM_OPMODE(__ph2ccmd, __val) \ - SET_BITS_TO_LE_1BYTE(__ph2ccmd, 0, 8, __val) -#define SET_H2CCMD_RSVDPAGE_LOC_PROBE_RSP(__ph2ccmd, __val) \ - SET_BITS_TO_LE_1BYTE(__ph2ccmd, 0, 8, __val) -#define SET_H2CCMD_RSVDPAGE_LOC_PSPOLL(__ph2ccmd, __val) \ - SET_BITS_TO_LE_1BYTE((__ph2ccmd) + 1, 0, 8, __val) -#define SET_H2CCMD_RSVDPAGE_LOC_NULL_DATA(__ph2ccmd, __val) \ - SET_BITS_TO_LE_1BYTE((__ph2ccmd) + 2, 0, 8, __val) - -struct rtl92d_firmware_header { - u16 signature; - u8 category; - u8 function; - u16 version; - u8 subversion; - u8 rsvd1; - - u8 month; - u8 date; - u8 hour; - u8 minute; - u16 ramcodeSize; - u16 rsvd2; - - u32 svnindex; - u32 rsvd3; - - u32 rsvd4; - u32 rsvd5; -}; - -enum rtl8192d_h2c_cmd { - H2C_AP_OFFLOAD = 0, - H2C_SETPWRMODE = 1, - H2C_JOINBSSRPT = 2, - H2C_RSVDPAGE = 3, - H2C_RSSI_REPORT = 5, - H2C_RA_MASK = 6, - H2C_MAC_MODE_SEL = 9, - H2C_PWRM = 15, - MAX_H2CCMD -}; - -int rtl92d_download_fw(struct ieee80211_hw *hw); -void rtl92d_fill_h2c_cmd(struct ieee80211_hw *hw, u8 element_id, - u32 cmd_len, u8 *p_cmdbuffer); -void rtl92d_firmware_selfreset(struct ieee80211_hw *hw); -void rtl92d_set_fw_pwrmode_cmd(struct ieee80211_hw *hw, u8 mode); -void rtl92d_set_fw_rsvdpagepkt(struct ieee80211_hw *hw, bool b_dl_finished); -void rtl92d_set_fw_joinbss_report_cmd(struct ieee80211_hw *hw, u8 mstatus); - -#endif diff --git a/trunk/drivers/net/wireless/rtlwifi/rtl8192de/hw.c b/trunk/drivers/net/wireless/rtlwifi/rtl8192de/hw.c deleted file mode 100644 index 5a65bea4cb8f..000000000000 --- a/trunk/drivers/net/wireless/rtlwifi/rtl8192de/hw.c +++ /dev/null @@ -1,2329 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2009-2010 Realtek Corporation. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * The full GNU General Public License is included in this distribution in the - * file called LICENSE. - * - * Contact Information: - * wlanfae - * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, - * Hsinchu 300, Taiwan. - * - * Larry Finger - * - *****************************************************************************/ - -#include "../wifi.h" -#include "../efuse.h" -#include "../base.h" -#include "../regd.h" -#include "../cam.h" -#include "../ps.h" -#include "../pci.h" -#include "reg.h" -#include "def.h" -#include "phy.h" -#include "dm.h" -#include "fw.h" -#include "led.h" -#include "sw.h" -#include "hw.h" - -u32 rtl92de_read_dword_dbi(struct ieee80211_hw *hw, u16 offset, u8 direct) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - u32 value; - - rtl_write_word(rtlpriv, REG_DBI_CTRL, (offset & 0xFFC)); - rtl_write_byte(rtlpriv, REG_DBI_FLAG, BIT(1) | direct); - udelay(10); - value = rtl_read_dword(rtlpriv, REG_DBI_RDATA); - return value; -} - -void rtl92de_write_dword_dbi(struct ieee80211_hw *hw, - u16 offset, u32 value, u8 direct) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - - rtl_write_word(rtlpriv, REG_DBI_CTRL, ((offset & 0xFFC) | 0xF000)); - rtl_write_dword(rtlpriv, REG_DBI_WDATA, value); - rtl_write_byte(rtlpriv, REG_DBI_FLAG, BIT(0) | direct); -} - -static void _rtl92de_set_bcn_ctrl_reg(struct ieee80211_hw *hw, - u8 set_bits, u8 clear_bits) -{ - struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); - struct rtl_priv *rtlpriv = rtl_priv(hw); - - rtlpci->reg_bcn_ctrl_val |= set_bits; - rtlpci->reg_bcn_ctrl_val &= ~clear_bits; - rtl_write_byte(rtlpriv, REG_BCN_CTRL, (u8) rtlpci->reg_bcn_ctrl_val); -} - -static void _rtl92de_stop_tx_beacon(struct ieee80211_hw *hw) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - u8 tmp1byte; - - tmp1byte = rtl_read_byte(rtlpriv, REG_FWHW_TXQ_CTRL + 2); - rtl_write_byte(rtlpriv, REG_FWHW_TXQ_CTRL + 2, tmp1byte & (~BIT(6))); - rtl_write_byte(rtlpriv, REG_BCN_MAX_ERR, 0xff); - rtl_write_byte(rtlpriv, REG_TBTT_PROHIBIT + 1, 0x64); - tmp1byte = rtl_read_byte(rtlpriv, REG_TBTT_PROHIBIT + 2); - tmp1byte &= ~(BIT(0)); - rtl_write_byte(rtlpriv, REG_TBTT_PROHIBIT + 2, tmp1byte); -} - -static void _rtl92de_resume_tx_beacon(struct ieee80211_hw *hw) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - u8 tmp1byte; - - tmp1byte = rtl_read_byte(rtlpriv, REG_FWHW_TXQ_CTRL + 2); - rtl_write_byte(rtlpriv, REG_FWHW_TXQ_CTRL + 2, tmp1byte | BIT(6)); - rtl_write_byte(rtlpriv, REG_BCN_MAX_ERR, 0x0a); - rtl_write_byte(rtlpriv, REG_TBTT_PROHIBIT + 1, 0xff); - tmp1byte = rtl_read_byte(rtlpriv, REG_TBTT_PROHIBIT + 2); - tmp1byte |= BIT(0); - rtl_write_byte(rtlpriv, REG_TBTT_PROHIBIT + 2, tmp1byte); -} - -static void _rtl92de_enable_bcn_sub_func(struct ieee80211_hw *hw) -{ - _rtl92de_set_bcn_ctrl_reg(hw, 0, BIT(1)); -} - -static void _rtl92de_disable_bcn_sub_func(struct ieee80211_hw *hw) -{ - _rtl92de_set_bcn_ctrl_reg(hw, BIT(1), 0); -} - -void rtl92de_get_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); - struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); - - switch (variable) { - case HW_VAR_RCR: - *((u32 *) (val)) = rtlpci->receive_config; - break; - case HW_VAR_RF_STATE: - *((enum rf_pwrstate *)(val)) = ppsc->rfpwr_state; - break; - case HW_VAR_FWLPS_RF_ON:{ - enum rf_pwrstate rfState; - u32 val_rcr; - - rtlpriv->cfg->ops->get_hw_reg(hw, HW_VAR_RF_STATE, - (u8 *) (&rfState)); - if (rfState == ERFOFF) { - *((bool *) (val)) = true; - } else { - val_rcr = rtl_read_dword(rtlpriv, REG_RCR); - val_rcr &= 0x00070000; - if (val_rcr) - *((bool *) (val)) = false; - else - *((bool *) (val)) = true; - } - break; - } - case HW_VAR_FW_PSMODE_STATUS: - *((bool *) (val)) = ppsc->fw_current_inpsmode; - break; - case HW_VAR_CORRECT_TSF:{ - u64 tsf; - u32 *ptsf_low = (u32 *)&tsf; - u32 *ptsf_high = ((u32 *)&tsf) + 1; - - *ptsf_high = rtl_read_dword(rtlpriv, (REG_TSFTR + 4)); - *ptsf_low = rtl_read_dword(rtlpriv, REG_TSFTR); - *((u64 *) (val)) = tsf; - break; - } - case HW_VAR_INT_MIGRATION: - *((bool *)(val)) = rtlpriv->dm.interrupt_migration; - break; - case HW_VAR_INT_AC: - *((bool *)(val)) = rtlpriv->dm.disable_tx_int; - break; - default: - RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("switch case not process\n")); - break; - } -} - -void rtl92de_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); - struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); - struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); - struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw)); - struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); - u8 idx; - - switch (variable) { - case HW_VAR_ETHER_ADDR: - for (idx = 0; idx < ETH_ALEN; idx++) { - rtl_write_byte(rtlpriv, (REG_MACID + idx), - val[idx]); - } - break; - case HW_VAR_BASIC_RATE: { - u16 rate_cfg = ((u16 *) val)[0]; - u8 rate_index = 0; - - rate_cfg = rate_cfg & 0x15f; - if (mac->vendor == PEER_CISCO && - ((rate_cfg & 0x150) == 0)) - rate_cfg |= 0x01; - rtl_write_byte(rtlpriv, REG_RRSR, rate_cfg & 0xff); - rtl_write_byte(rtlpriv, REG_RRSR + 1, - (rate_cfg >> 8) & 0xff); - while (rate_cfg > 0x1) { - rate_cfg = (rate_cfg >> 1); - rate_index++; - } - if (rtlhal->fw_version > 0xe) - rtl_write_byte(rtlpriv, REG_INIRTS_RATE_SEL, - rate_index); - break; - } - case HW_VAR_BSSID: - for (idx = 0; idx < ETH_ALEN; idx++) { - rtl_write_byte(rtlpriv, (REG_BSSID + idx), - val[idx]); - } - break; - case HW_VAR_SIFS: - rtl_write_byte(rtlpriv, REG_SIFS_CTX + 1, val[0]); - rtl_write_byte(rtlpriv, REG_SIFS_TRX + 1, val[1]); - rtl_write_byte(rtlpriv, REG_SPEC_SIFS + 1, val[0]); - rtl_write_byte(rtlpriv, REG_MAC_SPEC_SIFS + 1, val[0]); - if (!mac->ht_enable) - rtl_write_word(rtlpriv, REG_RESP_SIFS_OFDM, - 0x0e0e); - else - rtl_write_word(rtlpriv, REG_RESP_SIFS_OFDM, - *((u16 *) val)); - break; - case HW_VAR_SLOT_TIME: { - u8 e_aci; - - RT_TRACE(rtlpriv, COMP_MLME, DBG_LOUD, - ("HW_VAR_SLOT_TIME %x\n", val[0])); - rtl_write_byte(rtlpriv, REG_SLOT, val[0]); - for (e_aci = 0; e_aci < AC_MAX; e_aci++) - rtlpriv->cfg->ops->set_hw_reg(hw, - HW_VAR_AC_PARAM, - (u8 *) (&e_aci)); - break; - } - case HW_VAR_ACK_PREAMBLE: { - u8 reg_tmp; - u8 short_preamble = (bool) (*(u8 *) val); - - reg_tmp = (mac->cur_40_prime_sc) << 5; - if (short_preamble) - reg_tmp |= 0x80; - rtl_write_byte(rtlpriv, REG_RRSR + 2, reg_tmp); - break; - } - case HW_VAR_AMPDU_MIN_SPACE: { - u8 min_spacing_to_set; - u8 sec_min_space; - - min_spacing_to_set = *((u8 *) val); - if (min_spacing_to_set <= 7) { - sec_min_space = 0; - if (min_spacing_to_set < sec_min_space) - min_spacing_to_set = sec_min_space; - mac->min_space_cfg = ((mac->min_space_cfg & 0xf8) | - min_spacing_to_set); - *val = min_spacing_to_set; - RT_TRACE(rtlpriv, COMP_MLME, DBG_LOUD, - ("Set HW_VAR_AMPDU_MIN_SPACE: %#x\n", - mac->min_space_cfg)); - rtl_write_byte(rtlpriv, REG_AMPDU_MIN_SPACE, - mac->min_space_cfg); - } - break; - } - case HW_VAR_SHORTGI_DENSITY: { - u8 density_to_set; - - density_to_set = *((u8 *) val); - mac->min_space_cfg = rtlpriv->rtlhal.minspace_cfg; - mac->min_space_cfg |= (density_to_set << 3); - RT_TRACE(rtlpriv, COMP_MLME, DBG_LOUD, - ("Set HW_VAR_SHORTGI_DENSITY: %#x\n", - mac->min_space_cfg)); - rtl_write_byte(rtlpriv, REG_AMPDU_MIN_SPACE, - mac->min_space_cfg); - break; - } - case HW_VAR_AMPDU_FACTOR: { - u8 factor_toset; - u32 regtoSet; - u8 *ptmp_byte = NULL; - u8 index; - - if (rtlhal->macphymode == DUALMAC_DUALPHY) - regtoSet = 0xb9726641; - else if (rtlhal->macphymode == DUALMAC_SINGLEPHY) - regtoSet = 0x66626641; - else - regtoSet = 0xb972a841; - factor_toset = *((u8 *) val); - if (factor_toset <= 3) { - factor_toset = (1 << (factor_toset + 2)); - if (factor_toset > 0xf) - factor_toset = 0xf; - for (index = 0; index < 4; index++) { - ptmp_byte = (u8 *) (®toSet) + index; - if ((*ptmp_byte & 0xf0) > - (factor_toset << 4)) - *ptmp_byte = (*ptmp_byte & 0x0f) - | (factor_toset << 4); - if ((*ptmp_byte & 0x0f) > factor_toset) - *ptmp_byte = (*ptmp_byte & 0xf0) - | (factor_toset); - } - rtl_write_dword(rtlpriv, REG_AGGLEN_LMT, regtoSet); - RT_TRACE(rtlpriv, COMP_MLME, DBG_LOUD, - ("Set HW_VAR_AMPDU_FACTOR: %#x\n", - factor_toset)); - } - break; - } - case HW_VAR_AC_PARAM: { - u8 e_aci = *((u8 *) val); - rtl92d_dm_init_edca_turbo(hw); - if (rtlpci->acm_method != eAcmWay2_SW) - rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_ACM_CTRL, - (u8 *) (&e_aci)); - break; - } - case HW_VAR_ACM_CTRL: { - u8 e_aci = *((u8 *) val); - union aci_aifsn *p_aci_aifsn = - (union aci_aifsn *)(&(mac->ac[0].aifs)); - u8 acm = p_aci_aifsn->f.acm; - u8 acm_ctrl = rtl_read_byte(rtlpriv, REG_ACMHWCTRL); - - acm_ctrl = acm_ctrl | ((rtlpci->acm_method == 2) ? 0x0 : 0x1); - if (acm) { - switch (e_aci) { - case AC0_BE: - acm_ctrl |= ACMHW_BEQEN; - break; - case AC2_VI: - acm_ctrl |= ACMHW_VIQEN; - break; - case AC3_VO: - acm_ctrl |= ACMHW_VOQEN; - break; - default: - RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, - ("HW_VAR_ACM_CTRL acm set " - "failed: eACI is %d\n", acm)); - break; - } - } else { - switch (e_aci) { - case AC0_BE: - acm_ctrl &= (~ACMHW_BEQEN); - break; - case AC2_VI: - acm_ctrl &= (~ACMHW_VIQEN); - break; - case AC3_VO: - acm_ctrl &= (~ACMHW_VOQEN); - break; - default: - RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("switch case not process\n")); - break; - } - } - RT_TRACE(rtlpriv, COMP_QOS, DBG_TRACE, - ("SetHwReg8190pci(): [HW_VAR_ACM_CTRL] " - "Write 0x%X\n", acm_ctrl)); - rtl_write_byte(rtlpriv, REG_ACMHWCTRL, acm_ctrl); - break; - } - case HW_VAR_RCR: - rtl_write_dword(rtlpriv, REG_RCR, ((u32 *) (val))[0]); - rtlpci->receive_config = ((u32 *) (val))[0]; - break; - case HW_VAR_RETRY_LIMIT: { - u8 retry_limit = ((u8 *) (val))[0]; - - rtl_write_word(rtlpriv, REG_RL, - retry_limit << RETRY_LIMIT_SHORT_SHIFT | - retry_limit << RETRY_LIMIT_LONG_SHIFT); - break; - } - case HW_VAR_DUAL_TSF_RST: - rtl_write_byte(rtlpriv, REG_DUAL_TSF_RST, (BIT(0) | BIT(1))); - break; - case HW_VAR_EFUSE_BYTES: - rtlefuse->efuse_usedbytes = *((u16 *) val); - break; - case HW_VAR_EFUSE_USAGE: - rtlefuse->efuse_usedpercentage = *((u8 *) val); - break; - case HW_VAR_IO_CMD: - rtl92d_phy_set_io_cmd(hw, (*(enum io_type *)val)); - break; - case HW_VAR_WPA_CONFIG: - rtl_write_byte(rtlpriv, REG_SECCFG, *((u8 *) val)); - break; - case HW_VAR_SET_RPWM: - rtl92d_fill_h2c_cmd(hw, H2C_PWRM, 1, (u8 *) (val)); - break; - case HW_VAR_H2C_FW_PWRMODE: - break; - case HW_VAR_FW_PSMODE_STATUS: - ppsc->fw_current_inpsmode = *((bool *) val); - break; - case HW_VAR_H2C_FW_JOINBSSRPT: { - u8 mstatus = (*(u8 *) val); - u8 tmp_regcr, tmp_reg422; - bool recover = false; - - if (mstatus == RT_MEDIA_CONNECT) { - rtlpriv->cfg->ops->set_hw_reg(hw, - HW_VAR_AID, NULL); - tmp_regcr = rtl_read_byte(rtlpriv, REG_CR + 1); - rtl_write_byte(rtlpriv, REG_CR + 1, - (tmp_regcr | BIT(0))); - _rtl92de_set_bcn_ctrl_reg(hw, 0, BIT(3)); - _rtl92de_set_bcn_ctrl_reg(hw, BIT(4), 0); - tmp_reg422 = rtl_read_byte(rtlpriv, - REG_FWHW_TXQ_CTRL + 2); - if (tmp_reg422 & BIT(6)) - recover = true; - rtl_write_byte(rtlpriv, REG_FWHW_TXQ_CTRL + 2, - tmp_reg422 & (~BIT(6))); - rtl92d_set_fw_rsvdpagepkt(hw, 0); - _rtl92de_set_bcn_ctrl_reg(hw, BIT(3), 0); - _rtl92de_set_bcn_ctrl_reg(hw, 0, BIT(4)); - if (recover) - rtl_write_byte(rtlpriv, - REG_FWHW_TXQ_CTRL + 2, - tmp_reg422); - rtl_write_byte(rtlpriv, REG_CR + 1, - (tmp_regcr & ~(BIT(0)))); - } - rtl92d_set_fw_joinbss_report_cmd(hw, (*(u8 *) val)); - break; - } - case HW_VAR_AID: { - u16 u2btmp; - u2btmp = rtl_read_word(rtlpriv, REG_BCN_PSR_RPT); - u2btmp &= 0xC000; - rtl_write_word(rtlpriv, REG_BCN_PSR_RPT, (u2btmp | - mac->assoc_id)); - break; - } - case HW_VAR_CORRECT_TSF: { - u8 btype_ibss = ((u8 *) (val))[0]; - - if (btype_ibss) - _rtl92de_stop_tx_beacon(hw); - _rtl92de_set_bcn_ctrl_reg(hw, 0, BIT(3)); - rtl_write_dword(rtlpriv, REG_TSFTR, - (u32) (mac->tsf & 0xffffffff)); - rtl_write_dword(rtlpriv, REG_TSFTR + 4, - (u32) ((mac->tsf >> 32) & 0xffffffff)); - _rtl92de_set_bcn_ctrl_reg(hw, BIT(3), 0); - if (btype_ibss) - _rtl92de_resume_tx_beacon(hw); - - break; - } - case HW_VAR_INT_MIGRATION: { - bool int_migration = *(bool *) (val); - - if (int_migration) { - /* Set interrrupt migration timer and - * corresponging Tx/Rx counter. - * timer 25ns*0xfa0=100us for 0xf packets. - * 0x306:Rx, 0x307:Tx */ - rtl_write_dword(rtlpriv, REG_INT_MIG, 0xfe000fa0); - rtlpriv->dm.interrupt_migration = int_migration; - } else { - /* Reset all interrupt migration settings. */ - rtl_write_dword(rtlpriv, REG_INT_MIG, 0); - rtlpriv->dm.interrupt_migration = int_migration; - } - break; - } - case HW_VAR_INT_AC: { - bool disable_ac_int = *((bool *) val); - - /* Disable four ACs interrupts. */ - if (disable_ac_int) { - /* Disable VO, VI, BE and BK four AC interrupts - * to gain more efficient CPU utilization. - * When extremely highly Rx OK occurs, - * we will disable Tx interrupts. - */ - rtlpriv->cfg->ops->update_interrupt_mask(hw, 0, - RT_AC_INT_MASKS); - rtlpriv->dm.disable_tx_int = disable_ac_int; - /* Enable four ACs interrupts. */ - } else { - rtlpriv->cfg->ops->update_interrupt_mask(hw, - RT_AC_INT_MASKS, 0); - rtlpriv->dm.disable_tx_int = disable_ac_int; - } - break; - } - default: - RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("switch case not process\n")); - break; - } -} - -static bool _rtl92de_llt_write(struct ieee80211_hw *hw, u32 address, u32 data) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - bool status = true; - long count = 0; - u32 value = _LLT_INIT_ADDR(address) | - _LLT_INIT_DATA(data) | _LLT_OP(_LLT_WRITE_ACCESS); - - rtl_write_dword(rtlpriv, REG_LLT_INIT, value); - do { - value = rtl_read_dword(rtlpriv, REG_LLT_INIT); - if (_LLT_NO_ACTIVE == _LLT_OP_VALUE(value)) - break; - if (count > POLLING_LLT_THRESHOLD) { - RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("Failed to polling write LLT done at " - "address %d!\n", address)); - status = false; - break; - } - } while (++count); - return status; -} - -static bool _rtl92de_llt_table_init(struct ieee80211_hw *hw) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - unsigned short i; - u8 txpktbuf_bndy; - u8 maxPage; - bool status; - u32 value32; /* High+low page number */ - u8 value8; /* normal page number */ - - if (rtlpriv->rtlhal.macphymode == SINGLEMAC_SINGLEPHY) { - maxPage = 255; - txpktbuf_bndy = 246; - value8 = 0; - value32 = 0x80bf0d29; - } else if (rtlpriv->rtlhal.macphymode != SINGLEMAC_SINGLEPHY) { - maxPage = 127; - txpktbuf_bndy = 123; - value8 = 0; - value32 = 0x80750005; - } - - /* Set reserved page for each queue */ - /* 11. RQPN 0x200[31:0] = 0x80BD1C1C */ - /* load RQPN */ - rtl_write_byte(rtlpriv, REG_RQPN_NPQ, value8); - rtl_write_dword(rtlpriv, REG_RQPN, value32); - - /* 12. TXRKTBUG_PG_BNDY 0x114[31:0] = 0x27FF00F6 */ - /* TXRKTBUG_PG_BNDY */ - rtl_write_dword(rtlpriv, REG_TRXFF_BNDY, - (rtl_read_word(rtlpriv, REG_TRXFF_BNDY + 2) << 16 | - txpktbuf_bndy)); - - /* 13. TDECTRL[15:8] 0x209[7:0] = 0xF6 */ - /* Beacon Head for TXDMA */ - rtl_write_byte(rtlpriv, REG_TDECTRL + 1, txpktbuf_bndy); - - /* 14. BCNQ_PGBNDY 0x424[7:0] = 0xF6 */ - /* BCNQ_PGBNDY */ - rtl_write_byte(rtlpriv, REG_TXPKTBUF_BCNQ_BDNY, txpktbuf_bndy); - rtl_write_byte(rtlpriv, REG_TXPKTBUF_MGQ_BDNY, txpktbuf_bndy); - - /* 15. WMAC_LBK_BF_HD 0x45D[7:0] = 0xF6 */ - /* WMAC_LBK_BF_HD */ - rtl_write_byte(rtlpriv, 0x45D, txpktbuf_bndy); - - /* Set Tx/Rx page size (Tx must be 128 Bytes, */ - /* Rx can be 64,128,256,512,1024 bytes) */ - /* 16. PBP [7:0] = 0x11 */ - /* TRX page size */ - rtl_write_byte(rtlpriv, REG_PBP, 0x11); - - /* 17. DRV_INFO_SZ = 0x04 */ - rtl_write_byte(rtlpriv, REG_RX_DRVINFO_SZ, 0x4); - - /* 18. LLT_table_init(Adapter); */ - for (i = 0; i < (txpktbuf_bndy - 1); i++) { - status = _rtl92de_llt_write(hw, i, i + 1); - if (true != status) - return status; - } - - /* end of list */ - status = _rtl92de_llt_write(hw, (txpktbuf_bndy - 1), 0xFF); - if (true != status) - return status; - - /* Make the other pages as ring buffer */ - /* This ring buffer is used as beacon buffer if we */ - /* config this MAC as two MAC transfer. */ - /* Otherwise used as local loopback buffer. */ - for (i = txpktbuf_bndy; i < maxPage; i++) { - status = _rtl92de_llt_write(hw, i, (i + 1)); - if (true != status) - return status; - } - - /* Let last entry point to the start entry of ring buffer */ - status = _rtl92de_llt_write(hw, maxPage, txpktbuf_bndy); - if (true != status) - return status; - - return true; -} - -static void _rtl92de_gen_refresh_led_state(struct ieee80211_hw *hw) -{ - struct rtl_pci_priv *pcipriv = rtl_pcipriv(hw); - struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); - struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); - struct rtl_led *pLed0 = &(pcipriv->ledctl.sw_led0); - - if (rtlpci->up_first_time) - return; - if (ppsc->rfoff_reason == RF_CHANGE_BY_IPS) - rtl92de_sw_led_on(hw, pLed0); - else if (ppsc->rfoff_reason == RF_CHANGE_BY_INIT) - rtl92de_sw_led_on(hw, pLed0); - else - rtl92de_sw_led_off(hw, pLed0); -} - -static bool _rtl92de_init_mac(struct ieee80211_hw *hw) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); - unsigned char bytetmp; - unsigned short wordtmp; - u16 retry; - - rtl92d_phy_set_poweron(hw); - /* Add for resume sequence of power domain according - * to power document V11. Chapter V.11.... */ - /* 0. RSV_CTRL 0x1C[7:0] = 0x00 */ - /* unlock ISO/CLK/Power control register */ - rtl_write_byte(rtlpriv, REG_RSV_CTRL, 0x00); - rtl_write_byte(rtlpriv, REG_LDOA15_CTRL, 0x05); - - /* 1. AFE_XTAL_CTRL [7:0] = 0x0F enable XTAL */ - /* 2. SPS0_CTRL 0x11[7:0] = 0x2b enable SPS into PWM mode */ - /* 3. delay (1ms) this is not necessary when initially power on */ - - /* C. Resume Sequence */ - /* a. SPS0_CTRL 0x11[7:0] = 0x2b */ - rtl_write_byte(rtlpriv, REG_SPS0_CTRL, 0x2b); - - /* b. AFE_XTAL_CTRL [7:0] = 0x0F */ - rtl_write_byte(rtlpriv, REG_AFE_XTAL_CTRL, 0x0F); - - /* c. DRV runs power on init flow */ - - /* auto enable WLAN */ - /* 4. APS_FSMCO 0x04[8] = 1; wait till 0x04[8] = 0 */ - /* Power On Reset for MAC Block */ - bytetmp = rtl_read_byte(rtlpriv, REG_APS_FSMCO + 1) | BIT(0); - udelay(2); - rtl_write_byte(rtlpriv, REG_APS_FSMCO + 1, bytetmp); - udelay(2); - - /* 5. Wait while 0x04[8] == 0 goto 2, otherwise goto 1 */ - bytetmp = rtl_read_byte(rtlpriv, REG_APS_FSMCO + 1); - udelay(50); - retry = 0; - while ((bytetmp & BIT(0)) && retry < 1000) { - retry++; - bytetmp = rtl_read_byte(rtlpriv, REG_APS_FSMCO + 1); - udelay(50); - } - - /* Enable Radio off, GPIO, and LED function */ - /* 6. APS_FSMCO 0x04[15:0] = 0x0012 when enable HWPDN */ - rtl_write_word(rtlpriv, REG_APS_FSMCO, 0x1012); - - /* release RF digital isolation */ - /* 7. SYS_ISO_CTRL 0x01[1] = 0x0; */ - /*Set REG_SYS_ISO_CTRL 0x1=0x82 to prevent wake# problem. */ - rtl_write_byte(rtlpriv, REG_SYS_ISO_CTRL + 1, 0x82); - udelay(2); - - /* make sure that BB reset OK. */ - /* rtl_write_byte(rtlpriv, REG_SYS_FUNC_EN, 0xE3); */ - - /* Disable REG_CR before enable it to assure reset */ - rtl_write_word(rtlpriv, REG_CR, 0x0); - - /* Release MAC IO register reset */ - rtl_write_word(rtlpriv, REG_CR, 0x2ff); - - /* clear stopping tx/rx dma */ - rtl_write_byte(rtlpriv, REG_PCIE_CTRL_REG + 1, 0x0); - - /* rtl_write_word(rtlpriv,REG_CR+2, 0x2); */ - - /* System init */ - /* 18. LLT_table_init(Adapter); */ - if (_rtl92de_llt_table_init(hw) == false) - return false; - - /* Clear interrupt and enable interrupt */ - /* 19. HISR 0x124[31:0] = 0xffffffff; */ - /* HISRE 0x12C[7:0] = 0xFF */ - rtl_write_dword(rtlpriv, REG_HISR, 0xffffffff); - rtl_write_byte(rtlpriv, REG_HISRE, 0xff); - - /* 20. HIMR 0x120[31:0] |= [enable INT mask bit map]; */ - /* 21. HIMRE 0x128[7:0] = [enable INT mask bit map] */ - /* The IMR should be enabled later after all init sequence - * is finished. */ - - /* 22. PCIE configuration space configuration */ - /* 23. Ensure PCIe Device 0x80[15:0] = 0x0143 (ASPM+CLKREQ), */ - /* and PCIe gated clock function is enabled. */ - /* PCIE configuration space will be written after - * all init sequence.(Or by BIOS) */ - - rtl92d_phy_config_maccoexist_rfpage(hw); - - /* THe below section is not related to power document Vxx . */ - /* This is only useful for driver and OS setting. */ - /* -------------------Software Relative Setting---------------------- */ - wordtmp = rtl_read_word(rtlpriv, REG_TRXDMA_CTRL); - wordtmp &= 0xf; - wordtmp |= 0xF771; - rtl_write_word(rtlpriv, REG_TRXDMA_CTRL, wordtmp); - - /* Reported Tx status from HW for rate adaptive. */ - /* This should be realtive to power on step 14. But in document V11 */ - /* still not contain the description.!!! */ - rtl_write_byte(rtlpriv, REG_FWHW_TXQ_CTRL + 1, 0x1F); - - /* Set Tx/Rx page size (Tx must be 128 Bytes, - * Rx can be 64,128,256,512,1024 bytes) */ - /* rtl_write_byte(rtlpriv,REG_PBP, 0x11); */ - - /* Set RCR register */ - rtl_write_dword(rtlpriv, REG_RCR, rtlpci->receive_config); - /* rtl_write_byte(rtlpriv,REG_RX_DRVINFO_SZ, 4); */ - - /* Set TCR register */ - rtl_write_dword(rtlpriv, REG_TCR, rtlpci->transmit_config); - - /* disable earlymode */ - rtl_write_byte(rtlpriv, 0x4d0, 0x0); - - /* Set TX/RX descriptor physical address(from OS API). */ - rtl_write_dword(rtlpriv, REG_BCNQ_DESA, - rtlpci->tx_ring[BEACON_QUEUE].dma); - rtl_write_dword(rtlpriv, REG_MGQ_DESA, rtlpci->tx_ring[MGNT_QUEUE].dma); - rtl_write_dword(rtlpriv, REG_VOQ_DESA, rtlpci->tx_ring[VO_QUEUE].dma); - rtl_write_dword(rtlpriv, REG_VIQ_DESA, rtlpci->tx_ring[VI_QUEUE].dma); - rtl_write_dword(rtlpriv, REG_BEQ_DESA, rtlpci->tx_ring[BE_QUEUE].dma); - rtl_write_dword(rtlpriv, REG_BKQ_DESA, rtlpci->tx_ring[BK_QUEUE].dma); - rtl_write_dword(rtlpriv, REG_HQ_DESA, rtlpci->tx_ring[HIGH_QUEUE].dma); - /* Set RX Desc Address */ - rtl_write_dword(rtlpriv, REG_RX_DESA, - rtlpci->rx_ring[RX_MPDU_QUEUE].dma); - - /* if we want to support 64 bit DMA, we should set it here, - * but now we do not support 64 bit DMA*/ - - rtl_write_byte(rtlpriv, REG_PCIE_CTRL_REG + 3, 0x33); - - /* Reset interrupt migration setting when initialization */ - rtl_write_dword(rtlpriv, REG_INT_MIG, 0); - - /* Reconsider when to do this operation after asking HWSD. */ - bytetmp = rtl_read_byte(rtlpriv, REG_APSD_CTRL); - rtl_write_byte(rtlpriv, REG_APSD_CTRL, bytetmp & ~BIT(6)); - do { - retry++; - bytetmp = rtl_read_byte(rtlpriv, REG_APSD_CTRL); - } while ((retry < 200) && !(bytetmp & BIT(7))); - - /* After MACIO reset,we must refresh LED state. */ - _rtl92de_gen_refresh_led_state(hw); - - /* Reset H2C protection register */ - rtl_write_dword(rtlpriv, REG_MCUTST_1, 0x0); - - return true; -} - -static void _rtl92de_hw_configure(struct ieee80211_hw *hw) -{ - struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); - u8 reg_bw_opmode = BW_OPMODE_20MHZ; - u32 reg_rrsr; - - reg_rrsr = RATE_ALL_CCK | RATE_ALL_OFDM_AG; - rtl_write_byte(rtlpriv, REG_INIRTS_RATE_SEL, 0x8); - rtl_write_byte(rtlpriv, REG_BWOPMODE, reg_bw_opmode); - rtl_write_dword(rtlpriv, REG_RRSR, reg_rrsr); - rtl_write_byte(rtlpriv, REG_SLOT, 0x09); - rtl_write_byte(rtlpriv, REG_AMPDU_MIN_SPACE, 0x0); - rtl_write_word(rtlpriv, REG_FWHW_TXQ_CTRL, 0x1F80); - rtl_write_word(rtlpriv, REG_RL, 0x0707); - rtl_write_dword(rtlpriv, REG_BAR_MODE_CTRL, 0x02012802); - rtl_write_byte(rtlpriv, REG_HWSEQ_CTRL, 0xFF); - rtl_write_dword(rtlpriv, REG_DARFRC, 0x01000000); - rtl_write_dword(rtlpriv, REG_DARFRC + 4, 0x07060504); - rtl_write_dword(rtlpriv, REG_RARFRC, 0x01000000); - rtl_write_dword(rtlpriv, REG_RARFRC + 4, 0x07060504); - /* Aggregation threshold */ - if (rtlhal->macphymode == DUALMAC_DUALPHY) - rtl_write_dword(rtlpriv, REG_AGGLEN_LMT, 0xb9726641); - else if (rtlhal->macphymode == DUALMAC_SINGLEPHY) - rtl_write_dword(rtlpriv, REG_AGGLEN_LMT, 0x66626641); - else - rtl_write_dword(rtlpriv, REG_AGGLEN_LMT, 0xb972a841); - rtl_write_byte(rtlpriv, REG_ATIMWND, 0x2); - rtl_write_byte(rtlpriv, REG_BCN_MAX_ERR, 0x0a); - rtlpci->reg_bcn_ctrl_val = 0x1f; - rtl_write_byte(rtlpriv, REG_BCN_CTRL, rtlpci->reg_bcn_ctrl_val); - rtl_write_byte(rtlpriv, REG_TBTT_PROHIBIT + 1, 0xff); - rtl_write_byte(rtlpriv, REG_PIFS, 0x1C); - rtl_write_byte(rtlpriv, REG_AGGR_BREAK_TIME, 0x16); - rtl_write_word(rtlpriv, REG_NAV_PROT_LEN, 0x0020); - /* For throughput */ - rtl_write_word(rtlpriv, REG_FAST_EDCA_CTRL, 0x6666); - /* ACKTO for IOT issue. */ - rtl_write_byte(rtlpriv, REG_ACKTO, 0x40); - /* Set Spec SIFS (used in NAV) */ - rtl_write_word(rtlpriv, REG_SPEC_SIFS, 0x1010); - rtl_write_word(rtlpriv, REG_MAC_SPEC_SIFS, 0x1010); - /* Set SIFS for CCK */ - rtl_write_word(rtlpriv, REG_SIFS_CTX, 0x1010); - /* Set SIFS for OFDM */ - rtl_write_word(rtlpriv, REG_SIFS_TRX, 0x1010); - /* Set Multicast Address. */ - rtl_write_dword(rtlpriv, REG_MAR, 0xffffffff); - rtl_write_dword(rtlpriv, REG_MAR + 4, 0xffffffff); - switch (rtlpriv->phy.rf_type) { - case RF_1T2R: - case RF_1T1R: - rtlhal->minspace_cfg = (MAX_MSS_DENSITY_1T << 3); - break; - case RF_2T2R: - case RF_2T2R_GREEN: - rtlhal->minspace_cfg = (MAX_MSS_DENSITY_2T << 3); - break; - } -} - -static void _rtl92de_enable_aspm_back_door(struct ieee80211_hw *hw) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); - - rtl_write_byte(rtlpriv, 0x34b, 0x93); - rtl_write_word(rtlpriv, 0x350, 0x870c); - rtl_write_byte(rtlpriv, 0x352, 0x1); - if (ppsc->support_backdoor) - rtl_write_byte(rtlpriv, 0x349, 0x1b); - else - rtl_write_byte(rtlpriv, 0x349, 0x03); - rtl_write_word(rtlpriv, 0x350, 0x2718); - rtl_write_byte(rtlpriv, 0x352, 0x1); -} - -void rtl92de_enable_hw_security_config(struct ieee80211_hw *hw) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - u8 sec_reg_value; - - RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, - ("PairwiseEncAlgorithm = %d GroupEncAlgorithm = %d\n", - rtlpriv->sec.pairwise_enc_algorithm, - rtlpriv->sec.group_enc_algorithm)); - if (rtlpriv->cfg->mod_params->sw_crypto || rtlpriv->sec.use_sw_sec) { - RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, - ("not open hw encryption\n")); - return; - } - sec_reg_value = SCR_TXENCENABLE | SCR_RXENCENABLE; - if (rtlpriv->sec.use_defaultkey) { - sec_reg_value |= SCR_TXUSEDK; - sec_reg_value |= SCR_RXUSEDK; - } - sec_reg_value |= (SCR_RXBCUSEDK | SCR_TXBCUSEDK); - rtl_write_byte(rtlpriv, REG_CR + 1, 0x02); - RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD, - ("The SECR-value %x\n", sec_reg_value)); - rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_WPA_CONFIG, &sec_reg_value); -} - -int rtl92de_hw_init(struct ieee80211_hw *hw) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); - struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); - struct rtl_phy *rtlphy = &(rtlpriv->phy); - struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); - struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); - bool rtstatus = true; - u8 tmp_u1b; - int i; - int err; - unsigned long flags; - - rtlpci->being_init_adapter = true; - rtlpci->init_ready = false; - spin_lock_irqsave(&globalmutex_for_power_and_efuse, flags); - /* we should do iqk after disable/enable */ - rtl92d_phy_reset_iqk_result(hw); - /* rtlpriv->intf_ops->disable_aspm(hw); */ - rtstatus = _rtl92de_init_mac(hw); - if (rtstatus != true) { - RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, ("Init MAC failed\n")); - err = 1; - spin_unlock_irqrestore(&globalmutex_for_power_and_efuse, flags); - return err; - } - err = rtl92d_download_fw(hw); - spin_unlock_irqrestore(&globalmutex_for_power_and_efuse, flags); - if (err) { - RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, - ("Failed to download FW. Init HW " - "without FW..\n")); - rtlhal->fw_ready = false; - return 1; - } else { - rtlhal->fw_ready = true; - } - rtlhal->last_hmeboxnum = 0; - rtlpriv->psc.fw_current_inpsmode = false; - - tmp_u1b = rtl_read_byte(rtlpriv, 0x605); - tmp_u1b = tmp_u1b | 0x30; - rtl_write_byte(rtlpriv, 0x605, tmp_u1b); - - if (rtlhal->earlymode_enable) { - RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, - ("EarlyMode Enabled!!!\n")); - - tmp_u1b = rtl_read_byte(rtlpriv, 0x4d0); - tmp_u1b = tmp_u1b | 0x1f; - rtl_write_byte(rtlpriv, 0x4d0, tmp_u1b); - - rtl_write_byte(rtlpriv, 0x4d3, 0x80); - - tmp_u1b = rtl_read_byte(rtlpriv, 0x605); - tmp_u1b = tmp_u1b | 0x40; - rtl_write_byte(rtlpriv, 0x605, tmp_u1b); - } - - if (mac->rdg_en) { - rtl_write_byte(rtlpriv, REG_RD_CTRL, 0xff); - rtl_write_word(rtlpriv, REG_RD_NAV_NXT, 0x200); - rtl_write_byte(rtlpriv, REG_RD_RESP_PKT_TH, 0x05); - } - - rtl92d_phy_mac_config(hw); - /* because last function modify RCR, so we update - * rcr var here, or TP will unstable for receive_config - * is wrong, RX RCR_ACRC32 will cause TP unstabel & Rx - * RCR_APP_ICV will cause mac80211 unassoc for cisco 1252*/ - rtlpci->receive_config = rtl_read_dword(rtlpriv, REG_RCR); - rtlpci->receive_config &= ~(RCR_ACRC32 | RCR_AICV); - - rtl92d_phy_bb_config(hw); - - rtlphy->rf_mode = RF_OP_BY_SW_3WIRE; - /* set before initialize RF */ - rtl_set_bbreg(hw, RFPGA0_ANALOGPARAMETER4, 0x00f00000, 0xf); - - /* config RF */ - rtl92d_phy_rf_config(hw); - - /* After read predefined TXT, we must set BB/MAC/RF - * register as our requirement */ - /* After load BB,RF params,we need do more for 92D. */ - rtl92d_update_bbrf_configuration(hw); - /* set default value after initialize RF, */ - rtl_set_bbreg(hw, RFPGA0_ANALOGPARAMETER4, 0x00f00000, 0); - rtlphy->rfreg_chnlval[0] = rtl_get_rfreg(hw, (enum radio_path)0, - RF_CHNLBW, BRFREGOFFSETMASK); - rtlphy->rfreg_chnlval[1] = rtl_get_rfreg(hw, (enum radio_path)1, - RF_CHNLBW, BRFREGOFFSETMASK); - - /*---- Set CCK and OFDM Block "ON"----*/ - if (rtlhal->current_bandtype == BAND_ON_2_4G) - rtl_set_bbreg(hw, RFPGA0_RFMOD, BCCKEN, 0x1); - rtl_set_bbreg(hw, RFPGA0_RFMOD, BOFDMEN, 0x1); - if (rtlhal->interfaceindex == 0) { - /* RFPGA0_ANALOGPARAMETER2: cck clock select, - * set to 20MHz by default */ - rtl_set_bbreg(hw, RFPGA0_ANALOGPARAMETER2, BIT(10) | - BIT(11), 3); - } else { - /* Mac1 */ - rtl_set_bbreg(hw, RFPGA0_ANALOGPARAMETER2, BIT(11) | - BIT(10), 3); - } - - _rtl92de_hw_configure(hw); - - /* reset hw sec */ - rtl_cam_reset_all_entry(hw); - rtl92de_enable_hw_security_config(hw); - - /* Read EEPROM TX power index and PHY_REG_PG.txt to capture correct */ - /* TX power index for different rate set. */ - rtl92d_phy_get_hw_reg_originalvalue(hw); - rtl92d_phy_set_txpower_level(hw, rtlphy->current_channel); - - ppsc->rfpwr_state = ERFON; - - rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_ETHER_ADDR, mac->mac_addr); - - _rtl92de_enable_aspm_back_door(hw); - /* rtlpriv->intf_ops->enable_aspm(hw); */ - - rtl92d_dm_init(hw); - rtlpci->being_init_adapter = false; - - if (ppsc->rfpwr_state == ERFON) { - rtl92d_phy_lc_calibrate(hw); - /* 5G and 2.4G must wait sometime to let RF LO ready */ - if (rtlhal->macphymode == DUALMAC_DUALPHY) { - u32 tmp_rega; - for (i = 0; i < 10000; i++) { - udelay(MAX_STALL_TIME); - - tmp_rega = rtl_get_rfreg(hw, - (enum radio_path)RF90_PATH_A, - 0x2a, BMASKDWORD); - - if (((tmp_rega & BIT(11)) == BIT(11))) - break; - } - /* check that loop was successful. If not, exit now */ - if (i == 10000) { - rtlpci->init_ready = false; - return 1; - } - } - } - rtlpci->init_ready = true; - return err; -} - -static enum version_8192d _rtl92de_read_chip_version(struct ieee80211_hw *hw) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - enum version_8192d version = VERSION_NORMAL_CHIP_92D_SINGLEPHY; - u32 value32; - - value32 = rtl_read_dword(rtlpriv, REG_SYS_CFG); - if (!(value32 & 0x000f0000)) { - version = VERSION_TEST_CHIP_92D_SINGLEPHY; - RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, ("TEST CHIP!!!\n")); - } else { - version = VERSION_NORMAL_CHIP_92D_SINGLEPHY; - RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, ("Normal CHIP!!!\n")); - } - return version; -} - -static int _rtl92de_set_media_status(struct ieee80211_hw *hw, - enum nl80211_iftype type) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - u8 bt_msr = rtl_read_byte(rtlpriv, MSR); - enum led_ctl_mode ledaction = LED_CTL_NO_LINK; - u8 bcnfunc_enable; - - bt_msr &= 0xfc; - - if (type == NL80211_IFTYPE_UNSPECIFIED || - type == NL80211_IFTYPE_STATION) { - _rtl92de_stop_tx_beacon(hw); - _rtl92de_enable_bcn_sub_func(hw); - } else if (type == NL80211_IFTYPE_ADHOC || - type == NL80211_IFTYPE_AP) { - _rtl92de_resume_tx_beacon(hw); - _rtl92de_disable_bcn_sub_func(hw); - } else { - RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, - ("Set HW_VAR_MEDIA_STATUS: No such media " - "status(%x).\n", type)); - } - bcnfunc_enable = rtl_read_byte(rtlpriv, REG_BCN_CTRL); - switch (type) { - case NL80211_IFTYPE_UNSPECIFIED: - bt_msr |= MSR_NOLINK; - ledaction = LED_CTL_LINK; - bcnfunc_enable &= 0xF7; - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("Set Network type to NO LINK!\n")); - break; - case NL80211_IFTYPE_ADHOC: - bt_msr |= MSR_ADHOC; - bcnfunc_enable |= 0x08; - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("Set Network type to Ad Hoc!\n")); - break; - case NL80211_IFTYPE_STATION: - bt_msr |= MSR_INFRA; - ledaction = LED_CTL_LINK; - bcnfunc_enable &= 0xF7; - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("Set Network type to STA!\n")); - break; - case NL80211_IFTYPE_AP: - bt_msr |= MSR_AP; - bcnfunc_enable |= 0x08; - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("Set Network type to AP!\n")); - break; - default: - RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("Network type %d not support!\n", type)); - return 1; - break; - - } - rtl_write_byte(rtlpriv, REG_CR + 2, bt_msr); - rtlpriv->cfg->ops->led_control(hw, ledaction); - if ((bt_msr & 0xfc) == MSR_AP) - rtl_write_byte(rtlpriv, REG_BCNTCFG + 1, 0x00); - else - rtl_write_byte(rtlpriv, REG_BCNTCFG + 1, 0x66); - return 0; -} - -void rtl92de_set_check_bssid(struct ieee80211_hw *hw, bool check_bssid) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); - u32 reg_rcr = rtlpci->receive_config; - - if (rtlpriv->psc.rfpwr_state != ERFON) - return; - if (check_bssid) { - reg_rcr |= (RCR_CBSSID_DATA | RCR_CBSSID_BCN); - rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_RCR, (u8 *)(®_rcr)); - _rtl92de_set_bcn_ctrl_reg(hw, 0, BIT(4)); - } else if (check_bssid == false) { - reg_rcr &= (~(RCR_CBSSID_DATA | RCR_CBSSID_BCN)); - _rtl92de_set_bcn_ctrl_reg(hw, BIT(4), 0); - rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_RCR, (u8 *)(®_rcr)); - } -} - -int rtl92de_set_network_type(struct ieee80211_hw *hw, enum nl80211_iftype type) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - - if (_rtl92de_set_media_status(hw, type)) - return -EOPNOTSUPP; - - /* check bssid */ - if (rtlpriv->mac80211.link_state == MAC80211_LINKED) { - if (type != NL80211_IFTYPE_AP) - rtl92de_set_check_bssid(hw, true); - } else { - rtl92de_set_check_bssid(hw, false); - } - return 0; -} - -/* do iqk or reload iqk */ -/* windows just rtl92d_phy_reload_iqk_setting in set channel, - * but it's very strict for time sequence so we add - * rtl92d_phy_reload_iqk_setting here */ -void rtl92d_linked_set_reg(struct ieee80211_hw *hw) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_phy *rtlphy = &(rtlpriv->phy); - u8 indexforchannel; - u8 channel = rtlphy->current_channel; - - indexforchannel = rtl92d_get_rightchnlplace_for_iqk(channel); - if (!rtlphy->iqk_matrix_regsetting[indexforchannel].iqk_done) { - RT_TRACE(rtlpriv, COMP_SCAN | COMP_INIT, DBG_DMESG, - ("Do IQK for channel:%d.\n", channel)); - rtl92d_phy_iq_calibrate(hw); - } -} - -/* don't set REG_EDCA_BE_PARAM here because - * mac80211 will send pkt when scan */ -void rtl92de_set_qos(struct ieee80211_hw *hw, int aci) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - rtl92d_dm_init_edca_turbo(hw); - return; - switch (aci) { - case AC1_BK: - rtl_write_dword(rtlpriv, REG_EDCA_BK_PARAM, 0xa44f); - break; - case AC0_BE: - break; - case AC2_VI: - rtl_write_dword(rtlpriv, REG_EDCA_VI_PARAM, 0x5e4322); - break; - case AC3_VO: - rtl_write_dword(rtlpriv, REG_EDCA_VO_PARAM, 0x2f3222); - break; - default: - RT_ASSERT(false, ("invalid aci: %d !\n", aci)); - break; - } -} - -void rtl92de_enable_interrupt(struct ieee80211_hw *hw) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); - - rtl_write_dword(rtlpriv, REG_HIMR, rtlpci->irq_mask[0] & 0xFFFFFFFF); - rtl_write_dword(rtlpriv, REG_HIMRE, rtlpci->irq_mask[1] & 0xFFFFFFFF); -} - -void rtl92de_disable_interrupt(struct ieee80211_hw *hw) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); - - rtl_write_dword(rtlpriv, REG_HIMR, IMR8190_DISABLED); - rtl_write_dword(rtlpriv, REG_HIMRE, IMR8190_DISABLED); - synchronize_irq(rtlpci->pdev->irq); -} - -static void _rtl92de_poweroff_adapter(struct ieee80211_hw *hw) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - u8 u1b_tmp; - unsigned long flags; - - rtlpriv->intf_ops->enable_aspm(hw); - rtl_write_byte(rtlpriv, REG_RF_CTRL, 0x00); - rtl_set_bbreg(hw, RFPGA0_XCD_RFPARAMETER, BIT(3), 0); - rtl_set_bbreg(hw, RFPGA0_XCD_RFPARAMETER, BIT(15), 0); - - /* 0x20:value 05-->04 */ - rtl_write_byte(rtlpriv, REG_LDOA15_CTRL, 0x04); - - /* ==== Reset digital sequence ====== */ - rtl92d_firmware_selfreset(hw); - - /* f. SYS_FUNC_EN 0x03[7:0]=0x51 reset MCU, MAC register, DCORE */ - rtl_write_byte(rtlpriv, REG_SYS_FUNC_EN + 1, 0x51); - - /* g. MCUFWDL 0x80[1:0]=0 reset MCU ready status */ - rtl_write_byte(rtlpriv, REG_MCUFWDL, 0x00); - - /* ==== Pull GPIO PIN to balance level and LED control ====== */ - - /* h. GPIO_PIN_CTRL 0x44[31:0]=0x000 */ - rtl_write_dword(rtlpriv, REG_GPIO_PIN_CTRL, 0x00000000); - - /* i. Value = GPIO_PIN_CTRL[7:0] */ - u1b_tmp = rtl_read_byte(rtlpriv, REG_GPIO_PIN_CTRL); - - /* j. GPIO_PIN_CTRL 0x44[31:0] = 0x00FF0000 | (value <<8); */ - /* write external PIN level */ - rtl_write_dword(rtlpriv, REG_GPIO_PIN_CTRL, - 0x00FF0000 | (u1b_tmp << 8)); - - /* k. GPIO_MUXCFG 0x42 [15:0] = 0x0780 */ - rtl_write_word(rtlpriv, REG_GPIO_IO_SEL, 0x0790); - - /* l. LEDCFG 0x4C[15:0] = 0x8080 */ - rtl_write_word(rtlpriv, REG_LEDCFG0, 0x8080); - - /* ==== Disable analog sequence === */ - - /* m. AFE_PLL_CTRL[7:0] = 0x80 disable PLL */ - rtl_write_byte(rtlpriv, REG_AFE_PLL_CTRL, 0x80); - - /* n. SPS0_CTRL 0x11[7:0] = 0x22 enter PFM mode */ - rtl_write_byte(rtlpriv, REG_SPS0_CTRL, 0x23); - - /* o. AFE_XTAL_CTRL 0x24[7:0] = 0x0E disable XTAL, if No BT COEX */ - rtl_write_byte(rtlpriv, REG_AFE_XTAL_CTRL, 0x0e); - - /* p. RSV_CTRL 0x1C[7:0] = 0x0E lock ISO/CLK/Power control register */ - rtl_write_byte(rtlpriv, REG_RSV_CTRL, 0x0e); - - /* ==== interface into suspend === */ - - /* q. APS_FSMCO[15:8] = 0x58 PCIe suspend mode */ - /* According to power document V11, we need to set this */ - /* value as 0x18. Otherwise, we may not L0s sometimes. */ - /* This indluences power consumption. Bases on SD1's test, */ - /* set as 0x00 do not affect power current. And if it */ - /* is set as 0x18, they had ever met auto load fail problem. */ - rtl_write_byte(rtlpriv, REG_APS_FSMCO + 1, 0x10); - - RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, - ("In PowerOff,reg0x%x=%X\n", REG_SPS0_CTRL, - rtl_read_byte(rtlpriv, REG_SPS0_CTRL))); - /* r. Note: for PCIe interface, PON will not turn */ - /* off m-bias and BandGap in PCIe suspend mode. */ - - /* 0x17[7] 1b': power off in process 0b' : power off over */ - if (rtlpriv->rtlhal.macphymode != SINGLEMAC_SINGLEPHY) { - spin_lock_irqsave(&globalmutex_power, flags); - u1b_tmp = rtl_read_byte(rtlpriv, REG_POWER_OFF_IN_PROCESS); - u1b_tmp &= (~BIT(7)); - rtl_write_byte(rtlpriv, REG_POWER_OFF_IN_PROCESS, u1b_tmp); - spin_unlock_irqrestore(&globalmutex_power, flags); - } - - RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, ("<=======\n")); -} - -void rtl92de_card_disable(struct ieee80211_hw *hw) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); - struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); - struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); - enum nl80211_iftype opmode; - - mac->link_state = MAC80211_NOLINK; - opmode = NL80211_IFTYPE_UNSPECIFIED; - _rtl92de_set_media_status(hw, opmode); - - if (rtlpci->driver_is_goingto_unload || - ppsc->rfoff_reason > RF_CHANGE_BY_PS) - rtlpriv->cfg->ops->led_control(hw, LED_CTL_POWER_OFF); - RT_SET_PS_LEVEL(ppsc, RT_RF_OFF_LEVL_HALT_NIC); - /* Power sequence for each MAC. */ - /* a. stop tx DMA */ - /* b. close RF */ - /* c. clear rx buf */ - /* d. stop rx DMA */ - /* e. reset MAC */ - - /* a. stop tx DMA */ - rtl_write_byte(rtlpriv, REG_PCIE_CTRL_REG + 1, 0xFE); - udelay(50); - - /* b. TXPAUSE 0x522[7:0] = 0xFF Pause MAC TX queue */ - - /* c. ========RF OFF sequence========== */ - /* 0x88c[23:20] = 0xf. */ - rtl_set_bbreg(hw, RFPGA0_ANALOGPARAMETER4, 0x00f00000, 0xf); - rtl_set_rfreg(hw, RF90_PATH_A, 0x00, BRFREGOFFSETMASK, 0x00); - - /* APSD_CTRL 0x600[7:0] = 0x40 */ - rtl_write_byte(rtlpriv, REG_APSD_CTRL, 0x40); - - /* Close antenna 0,0xc04,0xd04 */ - rtl_set_bbreg(hw, ROFDM0_TRXPATHENABLE, BMASKBYTE0, 0); - rtl_set_bbreg(hw, ROFDM1_TRXPATHENABLE, BDWORD, 0); - - /* SYS_FUNC_EN 0x02[7:0] = 0xE2 reset BB state machine */ - rtl_write_byte(rtlpriv, REG_SYS_FUNC_EN, 0xE2); - - /* Mac0 can not do Global reset. Mac1 can do. */ - /* SYS_FUNC_EN 0x02[7:0] = 0xE0 reset BB state machine */ - if (rtlpriv->rtlhal.interfaceindex == 1) - rtl_write_byte(rtlpriv, REG_SYS_FUNC_EN, 0xE0); - udelay(50); - - /* d. stop tx/rx dma before disable REG_CR (0x100) to fix */ - /* dma hang issue when disable/enable device. */ - rtl_write_byte(rtlpriv, REG_PCIE_CTRL_REG + 1, 0xff); - udelay(50); - rtl_write_byte(rtlpriv, REG_CR, 0x0); - RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, ("==> Do power off.......\n")); - if (rtl92d_phy_check_poweroff(hw)) - _rtl92de_poweroff_adapter(hw); - return; -} - -void rtl92de_interrupt_recognized(struct ieee80211_hw *hw, - u32 *p_inta, u32 *p_intb) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); - - *p_inta = rtl_read_dword(rtlpriv, ISR) & rtlpci->irq_mask[0]; - rtl_write_dword(rtlpriv, ISR, *p_inta); - - /* - * *p_intb = rtl_read_dword(rtlpriv, REG_HISRE) & rtlpci->irq_mask[1]; - * rtl_write_dword(rtlpriv, ISR + 4, *p_intb); - */ -} - -void rtl92de_set_beacon_related_registers(struct ieee80211_hw *hw) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); - u16 bcn_interval, atim_window; - - bcn_interval = mac->beacon_interval; - atim_window = 2; - /*rtl92de_disable_interrupt(hw); */ - rtl_write_word(rtlpriv, REG_ATIMWND, atim_window); - rtl_write_word(rtlpriv, REG_BCN_INTERVAL, bcn_interval); - rtl_write_word(rtlpriv, REG_BCNTCFG, 0x660f); - rtl_write_byte(rtlpriv, REG_RXTSF_OFFSET_CCK, 0x20); - if (rtlpriv->rtlhal.current_bandtype == BAND_ON_5G) - rtl_write_byte(rtlpriv, REG_RXTSF_OFFSET_OFDM, 0x30); - else - rtl_write_byte(rtlpriv, REG_RXTSF_OFFSET_OFDM, 0x20); - rtl_write_byte(rtlpriv, 0x606, 0x30); -} - -void rtl92de_set_beacon_interval(struct ieee80211_hw *hw) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); - u16 bcn_interval = mac->beacon_interval; - - RT_TRACE(rtlpriv, COMP_BEACON, DBG_DMESG, - ("beacon_interval:%d\n", bcn_interval)); - /* rtl92de_disable_interrupt(hw); */ - rtl_write_word(rtlpriv, REG_BCN_INTERVAL, bcn_interval); - /* rtl92de_enable_interrupt(hw); */ -} - -void rtl92de_update_interrupt_mask(struct ieee80211_hw *hw, - u32 add_msr, u32 rm_msr) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); - - RT_TRACE(rtlpriv, COMP_INTR, DBG_LOUD, - ("add_msr:%x, rm_msr:%x\n", add_msr, rm_msr)); - if (add_msr) - rtlpci->irq_mask[0] |= add_msr; - if (rm_msr) - rtlpci->irq_mask[0] &= (~rm_msr); - rtl92de_disable_interrupt(hw); - rtl92de_enable_interrupt(hw); -} - -static void _rtl92de_readpowervalue_fromprom(struct txpower_info *pwrinfo, - u8 *rom_content, bool autoLoadfail) -{ - u32 rfpath, eeaddr, group, offset1, offset2; - u8 i; - - memset(pwrinfo, 0, sizeof(struct txpower_info)); - if (autoLoadfail) { - for (group = 0; group < CHANNEL_GROUP_MAX; group++) { - for (rfpath = 0; rfpath < RF6052_MAX_PATH; rfpath++) { - if (group < CHANNEL_GROUP_MAX_2G) { - pwrinfo->cck_index[rfpath][group] = - EEPROM_DEFAULT_TXPOWERLEVEL_2G; - pwrinfo->ht40_1sindex[rfpath][group] = - EEPROM_DEFAULT_TXPOWERLEVEL_2G; - } else { - pwrinfo->ht40_1sindex[rfpath][group] = - EEPROM_DEFAULT_TXPOWERLEVEL_5G; - } - pwrinfo->ht40_2sindexdiff[rfpath][group] = - EEPROM_DEFAULT_HT40_2SDIFF; - pwrinfo->ht20indexdiff[rfpath][group] = - EEPROM_DEFAULT_HT20_DIFF; - pwrinfo->ofdmindexdiff[rfpath][group] = - EEPROM_DEFAULT_LEGACYHTTXPOWERDIFF; - pwrinfo->ht40maxoffset[rfpath][group] = - EEPROM_DEFAULT_HT40_PWRMAXOFFSET; - pwrinfo->ht20maxoffset[rfpath][group] = - EEPROM_DEFAULT_HT20_PWRMAXOFFSET; - } - } - for (i = 0; i < 3; i++) { - pwrinfo->tssi_a[i] = EEPROM_DEFAULT_TSSI; - pwrinfo->tssi_b[i] = EEPROM_DEFAULT_TSSI; - } - return; - } - - /* Maybe autoload OK,buf the tx power index value is not filled. - * If we find it, we set it to default value. */ - for (rfpath = 0; rfpath < RF6052_MAX_PATH; rfpath++) { - for (group = 0; group < CHANNEL_GROUP_MAX_2G; group++) { - eeaddr = EEPROM_CCK_TX_PWR_INX_2G + (rfpath * 3) - + group; - pwrinfo->cck_index[rfpath][group] = - (rom_content[eeaddr] == 0xFF) ? - (eeaddr > 0x7B ? - EEPROM_DEFAULT_TXPOWERLEVEL_5G : - EEPROM_DEFAULT_TXPOWERLEVEL_2G) : - rom_content[eeaddr]; - } - } - for (rfpath = 0; rfpath < RF6052_MAX_PATH; rfpath++) { - for (group = 0; group < CHANNEL_GROUP_MAX; group++) { - offset1 = group / 3; - offset2 = group % 3; - eeaddr = EEPROM_HT40_1S_TX_PWR_INX_2G + (rfpath * 3) + - offset2 + offset1 * 21; - pwrinfo->ht40_1sindex[rfpath][group] = - (rom_content[eeaddr] == 0xFF) ? (eeaddr > 0x7B ? - EEPROM_DEFAULT_TXPOWERLEVEL_5G : - EEPROM_DEFAULT_TXPOWERLEVEL_2G) : - rom_content[eeaddr]; - } - } - /* These just for 92D efuse offset. */ - for (group = 0; group < CHANNEL_GROUP_MAX; group++) { - for (rfpath = 0; rfpath < RF6052_MAX_PATH; rfpath++) { - int base1 = EEPROM_HT40_2S_TX_PWR_INX_DIFF_2G; - - offset1 = group / 3; - offset2 = group % 3; - - if (rom_content[base1 + offset2 + offset1 * 21] != 0xFF) - pwrinfo->ht40_2sindexdiff[rfpath][group] = - (rom_content[base1 + - offset2 + offset1 * 21] >> (rfpath * 4)) - & 0xF; - else - pwrinfo->ht40_2sindexdiff[rfpath][group] = - EEPROM_DEFAULT_HT40_2SDIFF; - if (rom_content[EEPROM_HT20_TX_PWR_INX_DIFF_2G + offset2 - + offset1 * 21] != 0xFF) - pwrinfo->ht20indexdiff[rfpath][group] = - (rom_content[EEPROM_HT20_TX_PWR_INX_DIFF_2G - + offset2 + offset1 * 21] >> (rfpath * 4)) - & 0xF; - else - pwrinfo->ht20indexdiff[rfpath][group] = - EEPROM_DEFAULT_HT20_DIFF; - if (rom_content[EEPROM_OFDM_TX_PWR_INX_DIFF_2G + offset2 - + offset1 * 21] != 0xFF) - pwrinfo->ofdmindexdiff[rfpath][group] = - (rom_content[EEPROM_OFDM_TX_PWR_INX_DIFF_2G - + offset2 + offset1 * 21] >> (rfpath * 4)) - & 0xF; - else - pwrinfo->ofdmindexdiff[rfpath][group] = - EEPROM_DEFAULT_LEGACYHTTXPOWERDIFF; - if (rom_content[EEPROM_HT40_MAX_PWR_OFFSET_2G + offset2 - + offset1 * 21] != 0xFF) - pwrinfo->ht40maxoffset[rfpath][group] = - (rom_content[EEPROM_HT40_MAX_PWR_OFFSET_2G - + offset2 + offset1 * 21] >> (rfpath * 4)) - & 0xF; - else - pwrinfo->ht40maxoffset[rfpath][group] = - EEPROM_DEFAULT_HT40_PWRMAXOFFSET; - if (rom_content[EEPROM_HT20_MAX_PWR_OFFSET_2G + offset2 - + offset1 * 21] != 0xFF) - pwrinfo->ht20maxoffset[rfpath][group] = - (rom_content[EEPROM_HT20_MAX_PWR_OFFSET_2G + - offset2 + offset1 * 21] >> (rfpath * 4)) & - 0xF; - else - pwrinfo->ht20maxoffset[rfpath][group] = - EEPROM_DEFAULT_HT20_PWRMAXOFFSET; - } - } - if (rom_content[EEPROM_TSSI_A_5G] != 0xFF) { - /* 5GL */ - pwrinfo->tssi_a[0] = rom_content[EEPROM_TSSI_A_5G] & 0x3F; - pwrinfo->tssi_b[0] = rom_content[EEPROM_TSSI_B_5G] & 0x3F; - /* 5GM */ - pwrinfo->tssi_a[1] = rom_content[EEPROM_TSSI_AB_5G] & 0x3F; - pwrinfo->tssi_b[1] = - (rom_content[EEPROM_TSSI_AB_5G] & 0xC0) >> 6 | - (rom_content[EEPROM_TSSI_AB_5G + 1] & 0x0F) << 2; - /* 5GH */ - pwrinfo->tssi_a[2] = (rom_content[EEPROM_TSSI_AB_5G + 1] & - 0xF0) >> 4 | - (rom_content[EEPROM_TSSI_AB_5G + 2] & 0x03) << 4; - pwrinfo->tssi_b[2] = (rom_content[EEPROM_TSSI_AB_5G + 2] & - 0xFC) >> 2; - } else { - for (i = 0; i < 3; i++) { - pwrinfo->tssi_a[i] = EEPROM_DEFAULT_TSSI; - pwrinfo->tssi_b[i] = EEPROM_DEFAULT_TSSI; - } - } -} - -static void _rtl92de_read_txpower_info(struct ieee80211_hw *hw, - bool autoload_fail, u8 *hwinfo) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw)); - struct txpower_info pwrinfo; - u8 tempval[2], i, pwr, diff; - u32 ch, rfPath, group; - - _rtl92de_readpowervalue_fromprom(&pwrinfo, hwinfo, autoload_fail); - if (!autoload_fail) { - /* bit0~2 */ - rtlefuse->eeprom_regulatory = (hwinfo[EEPROM_RF_OPT1] & 0x7); - rtlefuse->eeprom_thermalmeter = - hwinfo[EEPROM_THERMAL_METER] & 0x1f; - rtlefuse->crystalcap = hwinfo[EEPROM_XTAL_K]; - tempval[0] = hwinfo[EEPROM_IQK_DELTA] & 0x03; - tempval[1] = (hwinfo[EEPROM_LCK_DELTA] & 0x0C) >> 2; - rtlefuse->txpwr_fromeprom = true; - if (IS_92D_D_CUT(rtlpriv->rtlhal.version)) { - rtlefuse->internal_pa_5g[0] = - !((hwinfo[EEPROM_TSSI_A_5G] & - BIT(6)) >> 6); - rtlefuse->internal_pa_5g[1] = - !((hwinfo[EEPROM_TSSI_B_5G] & - BIT(6)) >> 6); - RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, - ("Is D cut,Internal PA0 %d Internal PA1 %d\n", - rtlefuse->internal_pa_5g[0], - rtlefuse->internal_pa_5g[1])) - } - rtlefuse->eeprom_c9 = hwinfo[EEPROM_RF_OPT6]; - rtlefuse->eeprom_cc = hwinfo[EEPROM_RF_OPT7]; - } else { - rtlefuse->eeprom_regulatory = 0; - rtlefuse->eeprom_thermalmeter = EEPROM_DEFAULT_THERMALMETER; - rtlefuse->crystalcap = EEPROM_DEFAULT_CRYSTALCAP; - tempval[0] = tempval[1] = 3; - } - - /* Use default value to fill parameters if - * efuse is not filled on some place. */ - - /* ThermalMeter from EEPROM */ - if (rtlefuse->eeprom_thermalmeter < 0x06 || - rtlefuse->eeprom_thermalmeter > 0x1c) - rtlefuse->eeprom_thermalmeter = 0x12; - rtlefuse->thermalmeter[0] = rtlefuse->eeprom_thermalmeter; - - /* check XTAL_K */ - if (rtlefuse->crystalcap == 0xFF) - rtlefuse->crystalcap = 0; - if (rtlefuse->eeprom_regulatory > 3) - rtlefuse->eeprom_regulatory = 0; - - for (i = 0; i < 2; i++) { - switch (tempval[i]) { - case 0: - tempval[i] = 5; - break; - case 1: - tempval[i] = 4; - break; - case 2: - tempval[i] = 3; - break; - case 3: - default: - tempval[i] = 0; - break; - } - } - - rtlefuse->delta_iqk = tempval[0]; - if (tempval[1] > 0) - rtlefuse->delta_lck = tempval[1] - 1; - if (rtlefuse->eeprom_c9 == 0xFF) - rtlefuse->eeprom_c9 = 0x00; - RT_TRACE(rtlpriv, COMP_INTR, DBG_LOUD, - ("EEPROMRegulatory = 0x%x\n", rtlefuse->eeprom_regulatory)); - RT_TRACE(rtlpriv, COMP_INTR, DBG_LOUD, - ("ThermalMeter = 0x%x\n", rtlefuse->eeprom_thermalmeter)); - RT_TRACE(rtlpriv, COMP_INTR, DBG_LOUD, - ("CrystalCap = 0x%x\n", rtlefuse->crystalcap)); - RT_TRACE(rtlpriv, COMP_INTR, DBG_LOUD, - ("Delta_IQK = 0x%x Delta_LCK = 0x%x\n", rtlefuse->delta_iqk, - rtlefuse->delta_lck)); - - for (rfPath = 0; rfPath < RF6052_MAX_PATH; rfPath++) { - for (ch = 0; ch < CHANNEL_MAX_NUMBER; ch++) { - group = rtl92d_get_chnlgroup_fromarray((u8) ch); - if (ch < CHANNEL_MAX_NUMBER_2G) - rtlefuse->txpwrlevel_cck[rfPath][ch] = - pwrinfo.cck_index[rfPath][group]; - rtlefuse->txpwrlevel_ht40_1s[rfPath][ch] = - pwrinfo.ht40_1sindex[rfPath][group]; - rtlefuse->txpwr_ht20diff[rfPath][ch] = - pwrinfo.ht20indexdiff[rfPath][group]; - rtlefuse->txpwr_legacyhtdiff[rfPath][ch] = - pwrinfo.ofdmindexdiff[rfPath][group]; - rtlefuse->pwrgroup_ht20[rfPath][ch] = - pwrinfo.ht20maxoffset[rfPath][group]; - rtlefuse->pwrgroup_ht40[rfPath][ch] = - pwrinfo.ht40maxoffset[rfPath][group]; - pwr = pwrinfo.ht40_1sindex[rfPath][group]; - diff = pwrinfo.ht40_2sindexdiff[rfPath][group]; - rtlefuse->txpwrlevel_ht40_2s[rfPath][ch] = - (pwr > diff) ? (pwr - diff) : 0; - } - } -} - -static void _rtl92de_read_macphymode_from_prom(struct ieee80211_hw *hw, - u8 *content) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); - u8 macphy_crvalue = content[EEPROM_MAC_FUNCTION]; - - if (macphy_crvalue & BIT(3)) { - rtlhal->macphymode = SINGLEMAC_SINGLEPHY; - RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, - ("MacPhyMode SINGLEMAC_SINGLEPHY\n")); - } else { - rtlhal->macphymode = DUALMAC_DUALPHY; - RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, - ("MacPhyMode DUALMAC_DUALPHY\n")); - } -} - -static void _rtl92de_read_macphymode_and_bandtype(struct ieee80211_hw *hw, - u8 *content) -{ - _rtl92de_read_macphymode_from_prom(hw, content); - rtl92d_phy_config_macphymode(hw); - rtl92d_phy_config_macphymode_info(hw); -} - -static void _rtl92de_efuse_update_chip_version(struct ieee80211_hw *hw) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - enum version_8192d chipver = rtlpriv->rtlhal.version; - u8 cutvalue[2]; - u16 chipvalue; - - rtlpriv->intf_ops->read_efuse_byte(hw, EEPROME_CHIP_VERSION_H, - &cutvalue[1]); - rtlpriv->intf_ops->read_efuse_byte(hw, EEPROME_CHIP_VERSION_L, - &cutvalue[0]); - chipvalue = (cutvalue[1] << 8) | cutvalue[0]; - switch (chipvalue) { - case 0xAA55: - chipver |= CHIP_92D_C_CUT; - RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, ("C-CUT!!!\n")); - break; - case 0x9966: - chipver |= CHIP_92D_D_CUT; - RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, ("D-CUT!!!\n")); - break; - default: - chipver |= CHIP_92D_D_CUT; - RT_TRACE(rtlpriv, COMP_INIT, DBG_EMERG, ("Unkown CUT!\n")); - break; - } - rtlpriv->rtlhal.version = chipver; -} - -static void _rtl92de_read_adapter_info(struct ieee80211_hw *hw) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw)); - struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); - u16 i, usvalue; - u8 hwinfo[HWSET_MAX_SIZE]; - u16 eeprom_id; - unsigned long flags; - - if (rtlefuse->epromtype == EEPROM_BOOT_EFUSE) { - spin_lock_irqsave(&globalmutex_for_power_and_efuse, flags); - rtl_efuse_shadow_map_update(hw); - _rtl92de_efuse_update_chip_version(hw); - spin_unlock_irqrestore(&globalmutex_for_power_and_efuse, flags); - memcpy((void *)hwinfo, (void *)&rtlefuse->efuse_map - [EFUSE_INIT_MAP][0], - HWSET_MAX_SIZE); - } else if (rtlefuse->epromtype == EEPROM_93C46) { - RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("RTL819X Not boot from eeprom, check it !!")); - } - RT_PRINT_DATA(rtlpriv, COMP_INIT, DBG_DMESG, ("MAP\n"), - hwinfo, HWSET_MAX_SIZE); - - eeprom_id = *((u16 *)&hwinfo[0]); - if (eeprom_id != RTL8190_EEPROM_ID) { - RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, - ("EEPROM ID(%#x) is invalid!!\n", eeprom_id)); - rtlefuse->autoload_failflag = true; - } else { - RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, ("Autoload OK\n")); - rtlefuse->autoload_failflag = false; - } - if (rtlefuse->autoload_failflag) { - RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("RTL819X Not boot from eeprom, check it !!")); - return; - } - rtlefuse->eeprom_oemid = *(u8 *)&hwinfo[EEPROM_CUSTOMER_ID]; - _rtl92de_read_macphymode_and_bandtype(hw, hwinfo); - - /* VID, DID SE 0xA-D */ - rtlefuse->eeprom_vid = *(u16 *)&hwinfo[EEPROM_VID]; - rtlefuse->eeprom_did = *(u16 *)&hwinfo[EEPROM_DID]; - rtlefuse->eeprom_svid = *(u16 *)&hwinfo[EEPROM_SVID]; - rtlefuse->eeprom_smid = *(u16 *)&hwinfo[EEPROM_SMID]; - RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, - ("EEPROMId = 0x%4x\n", eeprom_id)); - RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, - ("EEPROM VID = 0x%4x\n", rtlefuse->eeprom_vid)); - RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, - ("EEPROM DID = 0x%4x\n", rtlefuse->eeprom_did)); - RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, - ("EEPROM SVID = 0x%4x\n", rtlefuse->eeprom_svid)); - RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, - ("EEPROM SMID = 0x%4x\n", rtlefuse->eeprom_smid)); - - /* Read Permanent MAC address */ - if (rtlhal->interfaceindex == 0) { - for (i = 0; i < 6; i += 2) { - usvalue = *(u16 *)&hwinfo[EEPROM_MAC_ADDR_MAC0_92D + i]; - *((u16 *) (&rtlefuse->dev_addr[i])) = usvalue; - } - } else { - for (i = 0; i < 6; i += 2) { - usvalue = *(u16 *)&hwinfo[EEPROM_MAC_ADDR_MAC1_92D + i]; - *((u16 *) (&rtlefuse->dev_addr[i])) = usvalue; - } - } - rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_ETHER_ADDR, - rtlefuse->dev_addr); - RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, - (MAC_FMT "\n", MAC_ARG(rtlefuse->dev_addr))); - _rtl92de_read_txpower_info(hw, rtlefuse->autoload_failflag, hwinfo); - - /* Read Channel Plan */ - switch (rtlhal->bandset) { - case BAND_ON_2_4G: - rtlefuse->channel_plan = COUNTRY_CODE_TELEC; - break; - case BAND_ON_5G: - rtlefuse->channel_plan = COUNTRY_CODE_FCC; - break; - case BAND_ON_BOTH: - rtlefuse->channel_plan = COUNTRY_CODE_FCC; - break; - default: - rtlefuse->channel_plan = COUNTRY_CODE_FCC; - break; - } - rtlefuse->eeprom_version = *(u16 *)&hwinfo[EEPROM_VERSION]; - rtlefuse->txpwr_fromeprom = true; - RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, - ("EEPROM Customer ID: 0x%2x\n", rtlefuse->eeprom_oemid)); -} - -void rtl92de_read_eeprom_info(struct ieee80211_hw *hw) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw)); - struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); - u8 tmp_u1b; - - rtlhal->version = _rtl92de_read_chip_version(hw); - tmp_u1b = rtl_read_byte(rtlpriv, REG_9346CR); - rtlefuse->autoload_status = tmp_u1b; - if (tmp_u1b & BIT(4)) { - RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, ("Boot from EEPROM\n")); - rtlefuse->epromtype = EEPROM_93C46; - } else { - RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, ("Boot from EFUSE\n")); - rtlefuse->epromtype = EEPROM_BOOT_EFUSE; - } - if (tmp_u1b & BIT(5)) { - RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, ("Autoload OK\n")); - - rtlefuse->autoload_failflag = false; - _rtl92de_read_adapter_info(hw); - } else { - RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, ("Autoload ERR!!\n")); - } - return; -} - -static void rtl92de_update_hal_rate_table(struct ieee80211_hw *hw, - struct ieee80211_sta *sta) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_phy *rtlphy = &(rtlpriv->phy); - struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); - struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); - u32 ratr_value; - u8 ratr_index = 0; - u8 nmode = mac->ht_enable; - u8 mimo_ps = IEEE80211_SMPS_OFF; - u16 shortgi_rate; - u32 tmp_ratr_value; - u8 curtxbw_40mhz = mac->bw_40; - u8 curshortgi_40mhz = (sta->ht_cap.cap & IEEE80211_HT_CAP_SGI_40) ? - 1 : 0; - u8 curshortgi_20mhz = (sta->ht_cap.cap & IEEE80211_HT_CAP_SGI_20) ? - 1 : 0; - enum wireless_mode wirelessmode = mac->mode; - - if (rtlhal->current_bandtype == BAND_ON_5G) - ratr_value = sta->supp_rates[1] << 4; - else - ratr_value = sta->supp_rates[0]; - ratr_value |= (sta->ht_cap.mcs.rx_mask[1] << 20 | - sta->ht_cap.mcs.rx_mask[0] << 12); - switch (wirelessmode) { - case WIRELESS_MODE_A: - ratr_value &= 0x00000FF0; - break; - case WIRELESS_MODE_B: - if (ratr_value & 0x0000000c) - ratr_value &= 0x0000000d; - else - ratr_value &= 0x0000000f; - break; - case WIRELESS_MODE_G: - ratr_value &= 0x00000FF5; - break; - case WIRELESS_MODE_N_24G: - case WIRELESS_MODE_N_5G: - nmode = 1; - if (mimo_ps == IEEE80211_SMPS_STATIC) { - ratr_value &= 0x0007F005; - } else { - u32 ratr_mask; - - if (get_rf_type(rtlphy) == RF_1T2R || - get_rf_type(rtlphy) == RF_1T1R) { - ratr_mask = 0x000ff005; - } else { - ratr_mask = 0x0f0ff005; - } - - ratr_value &= ratr_mask; - } - break; - default: - if (rtlphy->rf_type == RF_1T2R) - ratr_value &= 0x000ff0ff; - else - ratr_value &= 0x0f0ff0ff; - - break; - } - ratr_value &= 0x0FFFFFFF; - if (nmode && ((curtxbw_40mhz && curshortgi_40mhz) || - (!curtxbw_40mhz && curshortgi_20mhz))) { - ratr_value |= 0x10000000; - tmp_ratr_value = (ratr_value >> 12); - for (shortgi_rate = 15; shortgi_rate > 0; shortgi_rate--) { - if ((1 << shortgi_rate) & tmp_ratr_value) - break; - } - shortgi_rate = (shortgi_rate << 12) | (shortgi_rate << 8) | - (shortgi_rate << 4) | (shortgi_rate); - } - rtl_write_dword(rtlpriv, REG_ARFR0 + ratr_index * 4, ratr_value); - RT_TRACE(rtlpriv, COMP_RATR, DBG_DMESG, - ("%x\n", rtl_read_dword(rtlpriv, REG_ARFR0))); -} - -static void rtl92de_update_hal_rate_mask(struct ieee80211_hw *hw, - struct ieee80211_sta *sta, u8 rssi_level) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_phy *rtlphy = &(rtlpriv->phy); - struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); - struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); - struct rtl_sta_info *sta_entry = NULL; - u32 ratr_bitmap; - u8 ratr_index; - u8 curtxbw_40mhz = (sta->ht_cap.cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40) - ? 1 : 0; - u8 curshortgi_40mhz = (sta->ht_cap.cap & IEEE80211_HT_CAP_SGI_40) ? - 1 : 0; - u8 curshortgi_20mhz = (sta->ht_cap.cap & IEEE80211_HT_CAP_SGI_20) ? - 1 : 0; - enum wireless_mode wirelessmode = 0; - bool shortgi = false; - u32 value[2]; - u8 macid = 0; - u8 mimo_ps = IEEE80211_SMPS_OFF; - - sta_entry = (struct rtl_sta_info *) sta->drv_priv; - mimo_ps = sta_entry->mimo_ps; - wirelessmode = sta_entry->wireless_mode; - if (mac->opmode == NL80211_IFTYPE_STATION) - curtxbw_40mhz = mac->bw_40; - else if (mac->opmode == NL80211_IFTYPE_AP || - mac->opmode == NL80211_IFTYPE_ADHOC) - macid = sta->aid + 1; - - if (rtlhal->current_bandtype == BAND_ON_5G) - ratr_bitmap = sta->supp_rates[1] << 4; - else - ratr_bitmap = sta->supp_rates[0]; - ratr_bitmap |= (sta->ht_cap.mcs.rx_mask[1] << 20 | - sta->ht_cap.mcs.rx_mask[0] << 12); - switch (wirelessmode) { - case WIRELESS_MODE_B: - ratr_index = RATR_INX_WIRELESS_B; - if (ratr_bitmap & 0x0000000c) - ratr_bitmap &= 0x0000000d; - else - ratr_bitmap &= 0x0000000f; - break; - case WIRELESS_MODE_G: - ratr_index = RATR_INX_WIRELESS_GB; - - if (rssi_level == 1) - ratr_bitmap &= 0x00000f00; - else if (rssi_level == 2) - ratr_bitmap &= 0x00000ff0; - else - ratr_bitmap &= 0x00000ff5; - break; - case WIRELESS_MODE_A: - ratr_index = RATR_INX_WIRELESS_G; - ratr_bitmap &= 0x00000ff0; - break; - case WIRELESS_MODE_N_24G: - case WIRELESS_MODE_N_5G: - if (wirelessmode == WIRELESS_MODE_N_24G) - ratr_index = RATR_INX_WIRELESS_NGB; - else - ratr_index = RATR_INX_WIRELESS_NG; - if (mimo_ps == IEEE80211_SMPS_STATIC) { - if (rssi_level == 1) - ratr_bitmap &= 0x00070000; - else if (rssi_level == 2) - ratr_bitmap &= 0x0007f000; - else - ratr_bitmap &= 0x0007f005; - } else { - if (rtlphy->rf_type == RF_1T2R || - rtlphy->rf_type == RF_1T1R) { - if (curtxbw_40mhz) { - if (rssi_level == 1) - ratr_bitmap &= 0x000f0000; - else if (rssi_level == 2) - ratr_bitmap &= 0x000ff000; - else - ratr_bitmap &= 0x000ff015; - } else { - if (rssi_level == 1) - ratr_bitmap &= 0x000f0000; - else if (rssi_level == 2) - ratr_bitmap &= 0x000ff000; - else - ratr_bitmap &= 0x000ff005; - } - } else { - if (curtxbw_40mhz) { - if (rssi_level == 1) - ratr_bitmap &= 0x0f0f0000; - else if (rssi_level == 2) - ratr_bitmap &= 0x0f0ff000; - else - ratr_bitmap &= 0x0f0ff015; - } else { - if (rssi_level == 1) - ratr_bitmap &= 0x0f0f0000; - else if (rssi_level == 2) - ratr_bitmap &= 0x0f0ff000; - else - ratr_bitmap &= 0x0f0ff005; - } - } - } - if ((curtxbw_40mhz && curshortgi_40mhz) || - (!curtxbw_40mhz && curshortgi_20mhz)) { - - if (macid == 0) - shortgi = true; - else if (macid == 1) - shortgi = false; - } - break; - default: - ratr_index = RATR_INX_WIRELESS_NGB; - - if (rtlphy->rf_type == RF_1T2R) - ratr_bitmap &= 0x000ff0ff; - else - ratr_bitmap &= 0x0f0ff0ff; - break; - } - - value[0] = (ratr_bitmap & 0x0fffffff) | (ratr_index << 28); - value[1] = macid | (shortgi ? 0x20 : 0x00) | 0x80; - RT_TRACE(rtlpriv, COMP_RATR, DBG_DMESG, - ("ratr_bitmap :%x value0:%x value1:%x\n", - ratr_bitmap, value[0], value[1])); - rtl92d_fill_h2c_cmd(hw, H2C_RA_MASK, 5, (u8 *) value); - if (macid != 0) - sta_entry->ratr_index = ratr_index; -} - -void rtl92de_update_hal_rate_tbl(struct ieee80211_hw *hw, - struct ieee80211_sta *sta, u8 rssi_level) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - - if (rtlpriv->dm.useramask) - rtl92de_update_hal_rate_mask(hw, sta, rssi_level); - else - rtl92de_update_hal_rate_table(hw, sta); -} - -void rtl92de_update_channel_access_setting(struct ieee80211_hw *hw) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); - u16 sifs_timer; - - rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_SLOT_TIME, - (u8 *)&mac->slot_time); - if (!mac->ht_enable) - sifs_timer = 0x0a0a; - else - sifs_timer = 0x1010; - rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_SIFS, (u8 *)&sifs_timer); -} - -bool rtl92de_gpio_radio_on_off_checking(struct ieee80211_hw *hw, u8 *valid) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); - struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); - enum rf_pwrstate e_rfpowerstate_toset; - u8 u1tmp; - bool actuallyset = false; - unsigned long flag; - - if (rtlpci->being_init_adapter) - return false; - if (ppsc->swrf_processing) - return false; - spin_lock_irqsave(&rtlpriv->locks.rf_ps_lock, flag); - if (ppsc->rfchange_inprogress) { - spin_unlock_irqrestore(&rtlpriv->locks.rf_ps_lock, flag); - return false; - } else { - ppsc->rfchange_inprogress = true; - spin_unlock_irqrestore(&rtlpriv->locks.rf_ps_lock, flag); - } - rtl_write_byte(rtlpriv, REG_MAC_PINMUX_CFG, rtl_read_byte(rtlpriv, - REG_MAC_PINMUX_CFG) & ~(BIT(3))); - u1tmp = rtl_read_byte(rtlpriv, REG_GPIO_IO_SEL); - e_rfpowerstate_toset = (u1tmp & BIT(3)) ? ERFON : ERFOFF; - if (ppsc->hwradiooff && (e_rfpowerstate_toset == ERFON)) { - RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG, - ("GPIOChangeRF - HW Radio ON, RF ON\n")); - e_rfpowerstate_toset = ERFON; - ppsc->hwradiooff = false; - actuallyset = true; - } else if ((ppsc->hwradiooff == false) - && (e_rfpowerstate_toset == ERFOFF)) { - RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG, - ("GPIOChangeRF - HW Radio OFF, RF OFF\n")); - e_rfpowerstate_toset = ERFOFF; - ppsc->hwradiooff = true; - actuallyset = true; - } - if (actuallyset) { - spin_lock_irqsave(&rtlpriv->locks.rf_ps_lock, flag); - ppsc->rfchange_inprogress = false; - spin_unlock_irqrestore(&rtlpriv->locks.rf_ps_lock, flag); - } else { - if (ppsc->reg_rfps_level & RT_RF_OFF_LEVL_HALT_NIC) - RT_SET_PS_LEVEL(ppsc, RT_RF_OFF_LEVL_HALT_NIC); - spin_lock_irqsave(&rtlpriv->locks.rf_ps_lock, flag); - ppsc->rfchange_inprogress = false; - spin_unlock_irqrestore(&rtlpriv->locks.rf_ps_lock, flag); - } - *valid = 1; - return !ppsc->hwradiooff; -} - -void rtl92de_set_key(struct ieee80211_hw *hw, u32 key_index, - u8 *p_macaddr, bool is_group, u8 enc_algo, - bool is_wepkey, bool clear_all) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); - struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw)); - u8 *macaddr = p_macaddr; - u32 entry_id; - bool is_pairwise = false; - static u8 cam_const_addr[4][6] = { - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x00, 0x01}, - {0x00, 0x00, 0x00, 0x00, 0x00, 0x02}, - {0x00, 0x00, 0x00, 0x00, 0x00, 0x03} - }; - static u8 cam_const_broad[] = { - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff - }; - - if (clear_all) { - u8 idx; - u8 cam_offset = 0; - u8 clear_number = 5; - RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, ("clear_all\n")); - for (idx = 0; idx < clear_number; idx++) { - rtl_cam_mark_invalid(hw, cam_offset + idx); - rtl_cam_empty_entry(hw, cam_offset + idx); - - if (idx < 5) { - memset(rtlpriv->sec.key_buf[idx], 0, - MAX_KEY_LEN); - rtlpriv->sec.key_len[idx] = 0; - } - } - } else { - switch (enc_algo) { - case WEP40_ENCRYPTION: - enc_algo = CAM_WEP40; - break; - case WEP104_ENCRYPTION: - enc_algo = CAM_WEP104; - break; - case TKIP_ENCRYPTION: - enc_algo = CAM_TKIP; - break; - case AESCCMP_ENCRYPTION: - enc_algo = CAM_AES; - break; - default: - RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, ("switch case " - "not process\n")); - enc_algo = CAM_TKIP; - break; - } - if (is_wepkey || rtlpriv->sec.use_defaultkey) { - macaddr = cam_const_addr[key_index]; - entry_id = key_index; - } else { - if (is_group) { - macaddr = cam_const_broad; - entry_id = key_index; - } else { - if (mac->opmode == NL80211_IFTYPE_AP) { - entry_id = rtl_cam_get_free_entry(hw, - p_macaddr); - if (entry_id >= TOTAL_CAM_ENTRY) { - RT_TRACE(rtlpriv, COMP_SEC, - DBG_EMERG, ("Can not " - "find free hw security" - " cam entry\n")); - return; - } - } else { - entry_id = CAM_PAIRWISE_KEY_POSITION; - } - key_index = PAIRWISE_KEYIDX; - is_pairwise = true; - } - } - if (rtlpriv->sec.key_len[key_index] == 0) { - RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, - ("delete one entry, entry_id is %d\n", - entry_id)); - if (mac->opmode == NL80211_IFTYPE_AP) - rtl_cam_del_entry(hw, p_macaddr); - rtl_cam_delete_one_entry(hw, p_macaddr, entry_id); - } else { - RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD, - ("The insert KEY length is %d\n", - rtlpriv->sec.key_len[PAIRWISE_KEYIDX])); - RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD, - ("The insert KEY is %x %x\n", - rtlpriv->sec.key_buf[0][0], - rtlpriv->sec.key_buf[0][1])); - RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, - ("add one entry\n")); - if (is_pairwise) { - RT_PRINT_DATA(rtlpriv, COMP_SEC, DBG_LOUD, - "Pairwiase Key content :", - rtlpriv->sec.pairwise_key, - rtlpriv-> - sec.key_len[PAIRWISE_KEYIDX]); - RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, - ("set Pairwiase key\n")); - rtl_cam_add_one_entry(hw, macaddr, key_index, - entry_id, enc_algo, - CAM_CONFIG_NO_USEDK, - rtlpriv-> - sec.key_buf[key_index]); - } else { - RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, - ("set group key\n")); - if (mac->opmode == NL80211_IFTYPE_ADHOC) { - rtl_cam_add_one_entry(hw, - rtlefuse->dev_addr, - PAIRWISE_KEYIDX, - CAM_PAIRWISE_KEY_POSITION, - enc_algo, CAM_CONFIG_NO_USEDK, - rtlpriv->sec.key_buf[entry_id]); - } - rtl_cam_add_one_entry(hw, macaddr, key_index, - entry_id, enc_algo, - CAM_CONFIG_NO_USEDK, - rtlpriv->sec.key_buf - [entry_id]); - } - } - } -} - -void rtl92de_suspend(struct ieee80211_hw *hw) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - - rtlpriv->rtlhal.macphyctl_reg = rtl_read_byte(rtlpriv, - REG_MAC_PHY_CTRL_NORMAL); -} - -void rtl92de_resume(struct ieee80211_hw *hw) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - - rtl_write_byte(rtlpriv, REG_MAC_PHY_CTRL_NORMAL, - rtlpriv->rtlhal.macphyctl_reg); -} diff --git a/trunk/drivers/net/wireless/rtlwifi/rtl8192de/hw.h b/trunk/drivers/net/wireless/rtlwifi/rtl8192de/hw.h deleted file mode 100644 index ad44ffa520e6..000000000000 --- a/trunk/drivers/net/wireless/rtlwifi/rtl8192de/hw.h +++ /dev/null @@ -1,66 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2009-2010 Realtek Corporation. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * The full GNU General Public License is included in this distribution in the - * file called LICENSE. - * - * Contact Information: - * wlanfae - * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, - * Hsinchu 300, Taiwan. - * - * Larry Finger - * - *****************************************************************************/ - -#ifndef __RTL92DE_HW_H__ -#define __RTL92DE_HW_H__ - -void rtl92de_get_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val); -void rtl92de_read_eeprom_info(struct ieee80211_hw *hw); -void rtl92de_interrupt_recognized(struct ieee80211_hw *hw, - u32 *p_inta, u32 *p_intb); -int rtl92de_hw_init(struct ieee80211_hw *hw); -void rtl92de_card_disable(struct ieee80211_hw *hw); -void rtl92de_enable_interrupt(struct ieee80211_hw *hw); -void rtl92de_disable_interrupt(struct ieee80211_hw *hw); -int rtl92de_set_network_type(struct ieee80211_hw *hw, enum nl80211_iftype type); -void rtl92de_set_check_bssid(struct ieee80211_hw *hw, bool check_bssid); -void rtl92de_set_qos(struct ieee80211_hw *hw, int aci); -void rtl92de_set_beacon_related_registers(struct ieee80211_hw *hw); -void rtl92de_set_beacon_interval(struct ieee80211_hw *hw); -void rtl92de_update_interrupt_mask(struct ieee80211_hw *hw, - u32 add_msr, u32 rm_msr); -void rtl92de_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val); -void rtl92de_update_hal_rate_tbl(struct ieee80211_hw *hw, - struct ieee80211_sta *sta, u8 rssi_level); -void rtl92de_update_channel_access_setting(struct ieee80211_hw *hw); -bool rtl92de_gpio_radio_on_off_checking(struct ieee80211_hw *hw, u8 *valid); -void rtl92de_enable_hw_security_config(struct ieee80211_hw *hw); -void rtl92de_set_key(struct ieee80211_hw *hw, u32 key_index, - u8 *p_macaddr, bool is_group, u8 enc_algo, - bool is_wepkey, bool clear_all); - -extern void rtl92de_write_dword_dbi(struct ieee80211_hw *hw, u16 offset, - u32 value, u8 direct); -extern u32 rtl92de_read_dword_dbi(struct ieee80211_hw *hw, u16 offset, - u8 direct); -void rtl92de_suspend(struct ieee80211_hw *hw); -void rtl92de_resume(struct ieee80211_hw *hw); -void rtl92d_linked_set_reg(struct ieee80211_hw *hw); - -#endif diff --git a/trunk/drivers/net/wireless/rtlwifi/rtl8192de/led.c b/trunk/drivers/net/wireless/rtlwifi/rtl8192de/led.c deleted file mode 100644 index f1552f4df658..000000000000 --- a/trunk/drivers/net/wireless/rtlwifi/rtl8192de/led.c +++ /dev/null @@ -1,159 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2009-2010 Realtek Corporation. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * The full GNU General Public License is included in this distribution in the - * file called LICENSE. - * - * Contact Information: - * wlanfae - * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, - * Hsinchu 300, Taiwan. - * - * Larry Finger - * - *****************************************************************************/ - -#include "../wifi.h" -#include "../pci.h" -#include "reg.h" -#include "led.h" - -static void _rtl92ce_init_led(struct ieee80211_hw *hw, - struct rtl_led *pled, enum rtl_led_pin ledpin) -{ - pled->hw = hw; - pled->ledpin = ledpin; - pled->ledon = false; -} - -void rtl92de_sw_led_on(struct ieee80211_hw *hw, struct rtl_led *pled) -{ - u8 ledcfg; - struct rtl_priv *rtlpriv = rtl_priv(hw); - - RT_TRACE(rtlpriv, COMP_LED, DBG_LOUD, - ("LedAddr:%X ledpin=%d\n", REG_LEDCFG2, pled->ledpin)); - - switch (pled->ledpin) { - case LED_PIN_GPIO0: - break; - case LED_PIN_LED0: - ledcfg = rtl_read_byte(rtlpriv, REG_LEDCFG2); - - if ((rtlpriv->efuse.eeprom_did == 0x8176) || - (rtlpriv->efuse.eeprom_did == 0x8193)) - /* BIT7 of REG_LEDCFG2 should be set to - * make sure we could emit the led2. */ - rtl_write_byte(rtlpriv, REG_LEDCFG2, (ledcfg & 0xf0) | - BIT(7) | BIT(5) | BIT(6)); - else - rtl_write_byte(rtlpriv, REG_LEDCFG2, (ledcfg & 0xf0) | - BIT(7) | BIT(5)); - break; - case LED_PIN_LED1: - ledcfg = rtl_read_byte(rtlpriv, REG_LEDCFG1); - - rtl_write_byte(rtlpriv, REG_LEDCFG2, (ledcfg & 0x0f) | BIT(5)); - break; - default: - RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("switch case not process\n")); - break; - } - pled->ledon = true; -} - -void rtl92de_sw_led_off(struct ieee80211_hw *hw, struct rtl_led *pled) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_pci_priv *pcipriv = rtl_pcipriv(hw); - u8 ledcfg; - - RT_TRACE(rtlpriv, COMP_LED, DBG_LOUD, - ("LedAddr:%X ledpin=%d\n", REG_LEDCFG2, pled->ledpin)); - - ledcfg = rtl_read_byte(rtlpriv, REG_LEDCFG2); - - switch (pled->ledpin) { - case LED_PIN_GPIO0: - break; - case LED_PIN_LED0: - ledcfg &= 0xf0; - if (pcipriv->ledctl.led_opendrain) - rtl_write_byte(rtlpriv, REG_LEDCFG2, - (ledcfg | BIT(1) | BIT(5) | BIT(6))); - else - rtl_write_byte(rtlpriv, REG_LEDCFG2, - (ledcfg | BIT(3) | BIT(5) | BIT(6))); - break; - case LED_PIN_LED1: - ledcfg &= 0x0f; - rtl_write_byte(rtlpriv, REG_LEDCFG2, (ledcfg | BIT(3))); - break; - default: - RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("switch case not process\n")); - break; - } - pled->ledon = false; -} - -void rtl92de_init_sw_leds(struct ieee80211_hw *hw) -{ - struct rtl_pci_priv *pcipriv = rtl_pcipriv(hw); - _rtl92ce_init_led(hw, &(pcipriv->ledctl.sw_led0), LED_PIN_LED0); - _rtl92ce_init_led(hw, &(pcipriv->ledctl.sw_led1), LED_PIN_LED1); -} - -static void _rtl92ce_sw_led_control(struct ieee80211_hw *hw, - enum led_ctl_mode ledaction) -{ - struct rtl_pci_priv *pcipriv = rtl_pcipriv(hw); - struct rtl_led *pLed0 = &(pcipriv->ledctl.sw_led0); - switch (ledaction) { - case LED_CTL_POWER_ON: - case LED_CTL_LINK: - case LED_CTL_NO_LINK: - rtl92de_sw_led_on(hw, pLed0); - break; - case LED_CTL_POWER_OFF: - rtl92de_sw_led_off(hw, pLed0); - break; - default: - break; - } -} - -void rtl92de_led_control(struct ieee80211_hw *hw, enum led_ctl_mode ledaction) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); - - if ((ppsc->rfoff_reason > RF_CHANGE_BY_PS) && - (ledaction == LED_CTL_TX || - ledaction == LED_CTL_RX || - ledaction == LED_CTL_SITE_SURVEY || - ledaction == LED_CTL_LINK || - ledaction == LED_CTL_NO_LINK || - ledaction == LED_CTL_START_TO_LINK || - ledaction == LED_CTL_POWER_ON)) { - return; - } - RT_TRACE(rtlpriv, COMP_LED, DBG_LOUD, ("ledaction %d,\n", ledaction)); - - _rtl92ce_sw_led_control(hw, ledaction); -} diff --git a/trunk/drivers/net/wireless/rtlwifi/rtl8192de/led.h b/trunk/drivers/net/wireless/rtlwifi/rtl8192de/led.h deleted file mode 100644 index 57f4a3c583d4..000000000000 --- a/trunk/drivers/net/wireless/rtlwifi/rtl8192de/led.h +++ /dev/null @@ -1,38 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2009-2010 Realtek Corporation. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * The full GNU General Public License is included in this distribution in the - * file called LICENSE. - * - * Contact Information: - * wlanfae - * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, - * Hsinchu 300, Taiwan. - * - * Larry Finger - * - *****************************************************************************/ - -#ifndef __RTL92CE_LED_H__ -#define __RTL92CE_LED_H__ - -void rtl92de_init_sw_leds(struct ieee80211_hw *hw); -void rtl92de_sw_led_on(struct ieee80211_hw *hw, struct rtl_led *pled); -void rtl92de_sw_led_off(struct ieee80211_hw *hw, struct rtl_led *pled); -void rtl92de_led_control(struct ieee80211_hw *hw, enum led_ctl_mode ledaction); - -#endif diff --git a/trunk/drivers/net/wireless/rtlwifi/rtl8192de/phy.c b/trunk/drivers/net/wireless/rtlwifi/rtl8192de/phy.c deleted file mode 100644 index 3ac7af1c5509..000000000000 --- a/trunk/drivers/net/wireless/rtlwifi/rtl8192de/phy.c +++ /dev/null @@ -1,3831 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2009-2010 Realtek Corporation. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * The full GNU General Public License is included in this distribution in the - * file called LICENSE. - * - * Contact Information: - * wlanfae - * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, - * Hsinchu 300, Taiwan. - * - * Larry Finger - * - *****************************************************************************/ - -#include "../wifi.h" -#include "../pci.h" -#include "../ps.h" -#include "reg.h" -#include "def.h" -#include "phy.h" -#include "rf.h" -#include "dm.h" -#include "table.h" -#include "sw.h" -#include "hw.h" - -#define MAX_RF_IMR_INDEX 12 -#define MAX_RF_IMR_INDEX_NORMAL 13 -#define RF_REG_NUM_FOR_C_CUT_5G 6 -#define RF_REG_NUM_FOR_C_CUT_5G_INTERNALPA 7 -#define RF_REG_NUM_FOR_C_CUT_2G 5 -#define RF_CHNL_NUM_5G 19 -#define RF_CHNL_NUM_5G_40M 17 -#define TARGET_CHNL_NUM_5G 221 -#define TARGET_CHNL_NUM_2G 14 -#define CV_CURVE_CNT 64 - -static u32 rf_reg_for_5g_swchnl_normal[MAX_RF_IMR_INDEX_NORMAL] = { - 0, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x0 -}; - -static u8 rf_reg_for_c_cut_5g[RF_REG_NUM_FOR_C_CUT_5G] = { - RF_SYN_G1, RF_SYN_G2, RF_SYN_G3, RF_SYN_G4, RF_SYN_G5, RF_SYN_G6 -}; - -static u8 rf_reg_for_c_cut_2g[RF_REG_NUM_FOR_C_CUT_2G] = { - RF_SYN_G1, RF_SYN_G2, RF_SYN_G3, RF_SYN_G7, RF_SYN_G8 -}; - -static u8 rf_for_c_cut_5g_internal_pa[RF_REG_NUM_FOR_C_CUT_5G_INTERNALPA] = { - 0x0B, 0x48, 0x49, 0x4B, 0x03, 0x04, 0x0E -}; - -static u32 rf_reg_mask_for_c_cut_2g[RF_REG_NUM_FOR_C_CUT_2G] = { - BIT(19) | BIT(18) | BIT(17) | BIT(14) | BIT(1), - BIT(10) | BIT(9), - BIT(18) | BIT(17) | BIT(16) | BIT(1), - BIT(2) | BIT(1), - BIT(15) | BIT(14) | BIT(13) | BIT(12) | BIT(11) -}; - -static u8 rf_chnl_5g[RF_CHNL_NUM_5G] = { - 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, - 112, 116, 120, 124, 128, 132, 136, 140 -}; - -static u8 rf_chnl_5g_40m[RF_CHNL_NUM_5G_40M] = { - 38, 42, 46, 50, 54, 58, 62, 102, 106, 110, 114, - 118, 122, 126, 130, 134, 138 -}; -static u32 rf_reg_pram_c_5g[5][RF_REG_NUM_FOR_C_CUT_5G] = { - {0xE43BE, 0xFC638, 0x77C0A, 0xDE471, 0xd7110, 0x8EB04}, - {0xE43BE, 0xFC078, 0xF7C1A, 0xE0C71, 0xD7550, 0xAEB04}, - {0xE43BF, 0xFF038, 0xF7C0A, 0xDE471, 0xE5550, 0xAEB04}, - {0xE43BF, 0xFF079, 0xF7C1A, 0xDE471, 0xE5550, 0xAEB04}, - {0xE43BF, 0xFF038, 0xF7C1A, 0xDE471, 0xd7550, 0xAEB04} -}; - -static u32 rf_reg_param_for_c_cut_2g[3][RF_REG_NUM_FOR_C_CUT_2G] = { - {0x643BC, 0xFC038, 0x77C1A, 0x41289, 0x01840}, - {0x643BC, 0xFC038, 0x07C1A, 0x41289, 0x01840}, - {0x243BC, 0xFC438, 0x07C1A, 0x4128B, 0x0FC41} -}; - -static u32 rf_syn_g4_for_c_cut_2g = 0xD1C31 & 0x7FF; - -static u32 rf_pram_c_5g_int_pa[3][RF_REG_NUM_FOR_C_CUT_5G_INTERNALPA] = { - {0x01a00, 0x40443, 0x00eb5, 0x89bec, 0x94a12, 0x94a12, 0x94a12}, - {0x01800, 0xc0443, 0x00730, 0x896ee, 0x94a52, 0x94a52, 0x94a52}, - {0x01800, 0xc0443, 0x00730, 0x896ee, 0x94a12, 0x94a12, 0x94a12} -}; - -/* [mode][patha+b][reg] */ -static u32 rf_imr_param_normal[1][3][MAX_RF_IMR_INDEX_NORMAL] = { - { - /* channel 1-14. */ - { - 0x70000, 0x00ff0, 0x4400f, 0x00ff0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x64888, 0xe266c, 0x00090, 0x22fff - }, - /* path 36-64 */ - { - 0x70000, 0x22880, 0x4470f, 0x55880, 0x00070, 0x88000, - 0x0, 0x88080, 0x70000, 0x64a82, 0xe466c, 0x00090, - 0x32c9a - }, - /* 100 -165 */ - { - 0x70000, 0x44880, 0x4477f, 0x77880, 0x00070, 0x88000, - 0x0, 0x880b0, 0x0, 0x64b82, 0xe466c, 0x00090, 0x32c9a - } - } -}; - -static u32 curveindex_5g[TARGET_CHNL_NUM_5G] = {0}; - -static u32 curveindex_2g[TARGET_CHNL_NUM_2G] = {0}; - -static u32 targetchnl_5g[TARGET_CHNL_NUM_5G] = { - 25141, 25116, 25091, 25066, 25041, - 25016, 24991, 24966, 24941, 24917, - 24892, 24867, 24843, 24818, 24794, - 24770, 24765, 24721, 24697, 24672, - 24648, 24624, 24600, 24576, 24552, - 24528, 24504, 24480, 24457, 24433, - 24409, 24385, 24362, 24338, 24315, - 24291, 24268, 24245, 24221, 24198, - 24175, 24151, 24128, 24105, 24082, - 24059, 24036, 24013, 23990, 23967, - 23945, 23922, 23899, 23876, 23854, - 23831, 23809, 23786, 23764, 23741, - 23719, 23697, 23674, 23652, 23630, - 23608, 23586, 23564, 23541, 23519, - 23498, 23476, 23454, 23432, 23410, - 23388, 23367, 23345, 23323, 23302, - 23280, 23259, 23237, 23216, 23194, - 23173, 23152, 23130, 23109, 23088, - 23067, 23046, 23025, 23003, 22982, - 22962, 22941, 22920, 22899, 22878, - 22857, 22837, 22816, 22795, 22775, - 22754, 22733, 22713, 22692, 22672, - 22652, 22631, 22611, 22591, 22570, - 22550, 22530, 22510, 22490, 22469, - 22449, 22429, 22409, 22390, 22370, - 22350, 22336, 22310, 22290, 22271, - 22251, 22231, 22212, 22192, 22173, - 22153, 22134, 22114, 22095, 22075, - 22056, 22037, 22017, 21998, 21979, - 21960, 21941, 21921, 21902, 21883, - 21864, 21845, 21826, 21807, 21789, - 21770, 21751, 21732, 21713, 21695, - 21676, 21657, 21639, 21620, 21602, - 21583, 21565, 21546, 21528, 21509, - 21491, 21473, 21454, 21436, 21418, - 21400, 21381, 21363, 21345, 21327, - 21309, 21291, 21273, 21255, 21237, - 21219, 21201, 21183, 21166, 21148, - 21130, 21112, 21095, 21077, 21059, - 21042, 21024, 21007, 20989, 20972, - 25679, 25653, 25627, 25601, 25575, - 25549, 25523, 25497, 25471, 25446, - 25420, 25394, 25369, 25343, 25318, - 25292, 25267, 25242, 25216, 25191, - 25166 -}; - -/* channel 1~14 */ -static u32 targetchnl_2g[TARGET_CHNL_NUM_2G] = { - 26084, 26030, 25976, 25923, 25869, 25816, 25764, - 25711, 25658, 25606, 25554, 25502, 25451, 25328 -}; - -static u32 _rtl92d_phy_calculate_bit_shift(u32 bitmask) -{ - u32 i; - - for (i = 0; i <= 31; i++) { - if (((bitmask >> i) & 0x1) == 1) - break; - } - - return i; -} - -u32 rtl92d_phy_query_bb_reg(struct ieee80211_hw *hw, u32 regaddr, u32 bitmask) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_hal *rtlhal = rtl_hal(rtlpriv); - u32 returnvalue, originalvalue, bitshift; - u8 dbi_direct; - - RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, ("regaddr(%#x), " - "bitmask(%#x)\n", regaddr, bitmask)); - if (rtlhal->during_mac1init_radioa || rtlhal->during_mac0init_radiob) { - /* mac1 use phy0 read radio_b. */ - /* mac0 use phy1 read radio_b. */ - if (rtlhal->during_mac1init_radioa) - dbi_direct = BIT(3); - else if (rtlhal->during_mac0init_radiob) - dbi_direct = BIT(3) | BIT(2); - originalvalue = rtl92de_read_dword_dbi(hw, (u16)regaddr, - dbi_direct); - } else { - originalvalue = rtl_read_dword(rtlpriv, regaddr); - } - bitshift = _rtl92d_phy_calculate_bit_shift(bitmask); - returnvalue = (originalvalue & bitmask) >> bitshift; - RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, ("BBR MASK=0x%x " - "Addr[0x%x]=0x%x\n", bitmask, regaddr, originalvalue)); - return returnvalue; -} - -void rtl92d_phy_set_bb_reg(struct ieee80211_hw *hw, - u32 regaddr, u32 bitmask, u32 data) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_hal *rtlhal = rtl_hal(rtlpriv); - u8 dbi_direct = 0; - u32 originalvalue, bitshift; - - RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, ("regaddr(%#x), bitmask(%#x)," - " data(%#x)\n", regaddr, bitmask, data)); - if (rtlhal->during_mac1init_radioa) - dbi_direct = BIT(3); - else if (rtlhal->during_mac0init_radiob) - /* mac0 use phy1 write radio_b. */ - dbi_direct = BIT(3) | BIT(2); - if (bitmask != BMASKDWORD) { - if (rtlhal->during_mac1init_radioa || - rtlhal->during_mac0init_radiob) - originalvalue = rtl92de_read_dword_dbi(hw, - (u16) regaddr, - dbi_direct); - else - originalvalue = rtl_read_dword(rtlpriv, regaddr); - bitshift = _rtl92d_phy_calculate_bit_shift(bitmask); - data = ((originalvalue & (~bitmask)) | (data << bitshift)); - } - if (rtlhal->during_mac1init_radioa || rtlhal->during_mac0init_radiob) - rtl92de_write_dword_dbi(hw, (u16) regaddr, data, dbi_direct); - else - rtl_write_dword(rtlpriv, regaddr, data); - RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, ("regaddr(%#x), bitmask(%#x)," - " data(%#x)\n", regaddr, bitmask, data)); -} - -static u32 _rtl92d_phy_rf_serial_read(struct ieee80211_hw *hw, - enum radio_path rfpath, u32 offset) -{ - - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_phy *rtlphy = &(rtlpriv->phy); - struct bb_reg_def *pphyreg = &rtlphy->phyreg_def[rfpath]; - u32 newoffset; - u32 tmplong, tmplong2; - u8 rfpi_enable = 0; - u32 retvalue; - - newoffset = offset; - tmplong = rtl_get_bbreg(hw, RFPGA0_XA_HSSIPARAMETER2, BMASKDWORD); - if (rfpath == RF90_PATH_A) - tmplong2 = tmplong; - else - tmplong2 = rtl_get_bbreg(hw, pphyreg->rfhssi_para2, BMASKDWORD); - tmplong2 = (tmplong2 & (~BLSSIREADADDRESS)) | - (newoffset << 23) | BLSSIREADEDGE; - rtl_set_bbreg(hw, RFPGA0_XA_HSSIPARAMETER2, BMASKDWORD, - tmplong & (~BLSSIREADEDGE)); - udelay(10); - rtl_set_bbreg(hw, pphyreg->rfhssi_para2, BMASKDWORD, tmplong2); - udelay(50); - udelay(50); - rtl_set_bbreg(hw, RFPGA0_XA_HSSIPARAMETER2, BMASKDWORD, - tmplong | BLSSIREADEDGE); - udelay(10); - if (rfpath == RF90_PATH_A) - rfpi_enable = (u8) rtl_get_bbreg(hw, RFPGA0_XA_HSSIPARAMETER1, - BIT(8)); - else if (rfpath == RF90_PATH_B) - rfpi_enable = (u8) rtl_get_bbreg(hw, RFPGA0_XB_HSSIPARAMETER1, - BIT(8)); - if (rfpi_enable) - retvalue = rtl_get_bbreg(hw, pphyreg->rflssi_readbackpi, - BLSSIREADBACKDATA); - else - retvalue = rtl_get_bbreg(hw, pphyreg->rflssi_readback, - BLSSIREADBACKDATA); - RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, ("RFR-%d Addr[0x%x] = 0x%x\n", - rfpath, pphyreg->rflssi_readback, retvalue)); - return retvalue; -} - -static void _rtl92d_phy_rf_serial_write(struct ieee80211_hw *hw, - enum radio_path rfpath, - u32 offset, u32 data) -{ - u32 data_and_addr; - u32 newoffset; - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_phy *rtlphy = &(rtlpriv->phy); - struct bb_reg_def *pphyreg = &rtlphy->phyreg_def[rfpath]; - - newoffset = offset; - /* T65 RF */ - data_and_addr = ((newoffset << 20) | (data & 0x000fffff)) & 0x0fffffff; - rtl_set_bbreg(hw, pphyreg->rf3wire_offset, BMASKDWORD, data_and_addr); - RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, ("RFW-%d Addr[0x%x]=0x%x\n", - rfpath, pphyreg->rf3wire_offset, data_and_addr)); -} - -u32 rtl92d_phy_query_rf_reg(struct ieee80211_hw *hw, - enum radio_path rfpath, u32 regaddr, u32 bitmask) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - u32 original_value, readback_value, bitshift; - unsigned long flags; - - RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, ("regaddr(%#x), " - "rfpath(%#x), bitmask(%#x)\n", - regaddr, rfpath, bitmask)); - spin_lock_irqsave(&rtlpriv->locks.rf_lock, flags); - original_value = _rtl92d_phy_rf_serial_read(hw, rfpath, regaddr); - bitshift = _rtl92d_phy_calculate_bit_shift(bitmask); - readback_value = (original_value & bitmask) >> bitshift; - spin_unlock_irqrestore(&rtlpriv->locks.rf_lock, flags); - RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, ("regaddr(%#x), rfpath(%#x), " - "bitmask(%#x), original_value(%#x)\n", - regaddr, rfpath, bitmask, original_value)); - return readback_value; -} - -void rtl92d_phy_set_rf_reg(struct ieee80211_hw *hw, enum radio_path rfpath, - u32 regaddr, u32 bitmask, u32 data) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_phy *rtlphy = &(rtlpriv->phy); - u32 original_value, bitshift; - unsigned long flags; - - RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, - ("regaddr(%#x), bitmask(%#x), data(%#x), rfpath(%#x)\n", - regaddr, bitmask, data, rfpath)); - if (bitmask == 0) - return; - spin_lock_irqsave(&rtlpriv->locks.rf_lock, flags); - if (rtlphy->rf_mode != RF_OP_BY_FW) { - if (bitmask != BRFREGOFFSETMASK) { - original_value = _rtl92d_phy_rf_serial_read(hw, - rfpath, regaddr); - bitshift = _rtl92d_phy_calculate_bit_shift(bitmask); - data = ((original_value & (~bitmask)) | - (data << bitshift)); - } - _rtl92d_phy_rf_serial_write(hw, rfpath, regaddr, data); - } - spin_unlock_irqrestore(&rtlpriv->locks.rf_lock, flags); - RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, ("regaddr(%#x), " - "bitmask(%#x), data(%#x), rfpath(%#x)\n", - regaddr, bitmask, data, rfpath)); -} - -bool rtl92d_phy_mac_config(struct ieee80211_hw *hw) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - u32 i; - u32 arraylength; - u32 *ptrarray; - - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, ("Read Rtl819XMACPHY_Array\n")); - arraylength = MAC_2T_ARRAYLENGTH; - ptrarray = rtl8192de_mac_2tarray; - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, ("Img:Rtl819XMAC_Array\n")); - for (i = 0; i < arraylength; i = i + 2) - rtl_write_byte(rtlpriv, ptrarray[i], (u8) ptrarray[i + 1]); - if (rtlpriv->rtlhal.macphymode == SINGLEMAC_SINGLEPHY) { - /* improve 2-stream TX EVM */ - /* rtl_write_byte(rtlpriv, 0x14,0x71); */ - /* AMPDU aggregation number 9 */ - /* rtl_write_word(rtlpriv, REG_MAX_AGGR_NUM, MAX_AGGR_NUM); */ - rtl_write_byte(rtlpriv, REG_MAX_AGGR_NUM, 0x0B); - } else { - /* 92D need to test to decide the num. */ - rtl_write_byte(rtlpriv, REG_MAX_AGGR_NUM, 0x07); - } - return true; -} - -static void _rtl92d_phy_init_bb_rf_register_definition(struct ieee80211_hw *hw) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_phy *rtlphy = &(rtlpriv->phy); - - /* RF Interface Sowrtware Control */ - /* 16 LSBs if read 32-bit from 0x870 */ - rtlphy->phyreg_def[RF90_PATH_A].rfintfs = RFPGA0_XAB_RFINTERFACESW; - /* 16 MSBs if read 32-bit from 0x870 (16-bit for 0x872) */ - rtlphy->phyreg_def[RF90_PATH_B].rfintfs = RFPGA0_XAB_RFINTERFACESW; - /* 16 LSBs if read 32-bit from 0x874 */ - rtlphy->phyreg_def[RF90_PATH_C].rfintfs = RFPGA0_XCD_RFINTERFACESW; - /* 16 MSBs if read 32-bit from 0x874 (16-bit for 0x876) */ - - rtlphy->phyreg_def[RF90_PATH_D].rfintfs = RFPGA0_XCD_RFINTERFACESW; - /* RF Interface Readback Value */ - /* 16 LSBs if read 32-bit from 0x8E0 */ - rtlphy->phyreg_def[RF90_PATH_A].rfintfi = RFPGA0_XAB_RFINTERFACERB; - /* 16 MSBs if read 32-bit from 0x8E0 (16-bit for 0x8E2) */ - rtlphy->phyreg_def[RF90_PATH_B].rfintfi = RFPGA0_XAB_RFINTERFACERB; - /* 16 LSBs if read 32-bit from 0x8E4 */ - rtlphy->phyreg_def[RF90_PATH_C].rfintfi = RFPGA0_XCD_RFINTERFACERB; - /* 16 MSBs if read 32-bit from 0x8E4 (16-bit for 0x8E6) */ - rtlphy->phyreg_def[RF90_PATH_D].rfintfi = RFPGA0_XCD_RFINTERFACERB; - - /* RF Interface Output (and Enable) */ - /* 16 LSBs if read 32-bit from 0x860 */ - rtlphy->phyreg_def[RF90_PATH_A].rfintfo = RFPGA0_XA_RFINTERFACEOE; - /* 16 LSBs if read 32-bit from 0x864 */ - rtlphy->phyreg_def[RF90_PATH_B].rfintfo = RFPGA0_XB_RFINTERFACEOE; - - /* RF Interface (Output and) Enable */ - /* 16 MSBs if read 32-bit from 0x860 (16-bit for 0x862) */ - rtlphy->phyreg_def[RF90_PATH_A].rfintfe = RFPGA0_XA_RFINTERFACEOE; - /* 16 MSBs if read 32-bit from 0x864 (16-bit for 0x866) */ - rtlphy->phyreg_def[RF90_PATH_B].rfintfe = RFPGA0_XB_RFINTERFACEOE; - - /* Addr of LSSI. Wirte RF register by driver */ - /* LSSI Parameter */ - rtlphy->phyreg_def[RF90_PATH_A].rf3wire_offset = - RFPGA0_XA_LSSIPARAMETER; - rtlphy->phyreg_def[RF90_PATH_B].rf3wire_offset = - RFPGA0_XB_LSSIPARAMETER; - - /* RF parameter */ - /* BB Band Select */ - rtlphy->phyreg_def[RF90_PATH_A].rflssi_select = RFPGA0_XAB_RFPARAMETER; - rtlphy->phyreg_def[RF90_PATH_B].rflssi_select = RFPGA0_XAB_RFPARAMETER; - rtlphy->phyreg_def[RF90_PATH_C].rflssi_select = RFPGA0_XCD_RFPARAMETER; - rtlphy->phyreg_def[RF90_PATH_D].rflssi_select = RFPGA0_XCD_RFPARAMETER; - - /* Tx AGC Gain Stage (same for all path. Should we remove this?) */ - /* Tx gain stage */ - rtlphy->phyreg_def[RF90_PATH_A].rftxgain_stage = RFPGA0_TXGAINSTAGE; - /* Tx gain stage */ - rtlphy->phyreg_def[RF90_PATH_B].rftxgain_stage = RFPGA0_TXGAINSTAGE; - /* Tx gain stage */ - rtlphy->phyreg_def[RF90_PATH_C].rftxgain_stage = RFPGA0_TXGAINSTAGE; - /* Tx gain stage */ - rtlphy->phyreg_def[RF90_PATH_D].rftxgain_stage = RFPGA0_TXGAINSTAGE; - - /* Tranceiver A~D HSSI Parameter-1 */ - /* wire control parameter1 */ - rtlphy->phyreg_def[RF90_PATH_A].rfhssi_para1 = RFPGA0_XA_HSSIPARAMETER1; - /* wire control parameter1 */ - rtlphy->phyreg_def[RF90_PATH_B].rfhssi_para1 = RFPGA0_XB_HSSIPARAMETER1; - - /* Tranceiver A~D HSSI Parameter-2 */ - /* wire control parameter2 */ - rtlphy->phyreg_def[RF90_PATH_A].rfhssi_para2 = RFPGA0_XA_HSSIPARAMETER2; - /* wire control parameter2 */ - rtlphy->phyreg_def[RF90_PATH_B].rfhssi_para2 = RFPGA0_XB_HSSIPARAMETER2; - - /* RF switch Control */ - /* TR/Ant switch control */ - rtlphy->phyreg_def[RF90_PATH_A].rfswitch_control = - RFPGA0_XAB_SWITCHCONTROL; - rtlphy->phyreg_def[RF90_PATH_B].rfswitch_control = - RFPGA0_XAB_SWITCHCONTROL; - rtlphy->phyreg_def[RF90_PATH_C].rfswitch_control = - RFPGA0_XCD_SWITCHCONTROL; - rtlphy->phyreg_def[RF90_PATH_D].rfswitch_control = - RFPGA0_XCD_SWITCHCONTROL; - - /* AGC control 1 */ - rtlphy->phyreg_def[RF90_PATH_A].rfagc_control1 = ROFDM0_XAAGCCORE1; - rtlphy->phyreg_def[RF90_PATH_B].rfagc_control1 = ROFDM0_XBAGCCORE1; - rtlphy->phyreg_def[RF90_PATH_C].rfagc_control1 = ROFDM0_XCAGCCORE1; - rtlphy->phyreg_def[RF90_PATH_D].rfagc_control1 = ROFDM0_XDAGCCORE1; - - /* AGC control 2 */ - rtlphy->phyreg_def[RF90_PATH_A].rfagc_control2 = ROFDM0_XAAGCCORE2; - rtlphy->phyreg_def[RF90_PATH_B].rfagc_control2 = ROFDM0_XBAGCCORE2; - rtlphy->phyreg_def[RF90_PATH_C].rfagc_control2 = ROFDM0_XCAGCCORE2; - rtlphy->phyreg_def[RF90_PATH_D].rfagc_control2 = ROFDM0_XDAGCCORE2; - - /* RX AFE control 1 */ - rtlphy->phyreg_def[RF90_PATH_A].rfrxiq_imbalance = - ROFDM0_XARXIQIMBALANCE; - rtlphy->phyreg_def[RF90_PATH_B].rfrxiq_imbalance = - ROFDM0_XBRXIQIMBALANCE; - rtlphy->phyreg_def[RF90_PATH_C].rfrxiq_imbalance = - ROFDM0_XCRXIQIMBALANCE; - rtlphy->phyreg_def[RF90_PATH_D].rfrxiq_imbalance = - ROFDM0_XDRXIQIMBALANCE; - - /*RX AFE control 1 */ - rtlphy->phyreg_def[RF90_PATH_A].rfrx_afe = ROFDM0_XARXAFE; - rtlphy->phyreg_def[RF90_PATH_B].rfrx_afe = ROFDM0_XBRXAFE; - rtlphy->phyreg_def[RF90_PATH_C].rfrx_afe = ROFDM0_XCRXAFE; - rtlphy->phyreg_def[RF90_PATH_D].rfrx_afe = ROFDM0_XDRXAFE; - - /* Tx AFE control 1 */ - rtlphy->phyreg_def[RF90_PATH_A].rftxiq_imbalance = - ROFDM0_XATxIQIMBALANCE; - rtlphy->phyreg_def[RF90_PATH_B].rftxiq_imbalance = - ROFDM0_XBTxIQIMBALANCE; - rtlphy->phyreg_def[RF90_PATH_C].rftxiq_imbalance = - ROFDM0_XCTxIQIMBALANCE; - rtlphy->phyreg_def[RF90_PATH_D].rftxiq_imbalance = - ROFDM0_XDTxIQIMBALANCE; - - /* Tx AFE control 2 */ - rtlphy->phyreg_def[RF90_PATH_A].rftx_afe = ROFDM0_XATxAFE; - rtlphy->phyreg_def[RF90_PATH_B].rftx_afe = ROFDM0_XBTxAFE; - rtlphy->phyreg_def[RF90_PATH_C].rftx_afe = ROFDM0_XCTxAFE; - rtlphy->phyreg_def[RF90_PATH_D].rftx_afe = ROFDM0_XDTxAFE; - - /* Tranceiver LSSI Readback SI mode */ - rtlphy->phyreg_def[RF90_PATH_A].rflssi_readback = - RFPGA0_XA_LSSIREADBACK; - rtlphy->phyreg_def[RF90_PATH_B].rflssi_readback = - RFPGA0_XB_LSSIREADBACK; - rtlphy->phyreg_def[RF90_PATH_C].rflssi_readback = - RFPGA0_XC_LSSIREADBACK; - rtlphy->phyreg_def[RF90_PATH_D].rflssi_readback = - RFPGA0_XD_LSSIREADBACK; - - /* Tranceiver LSSI Readback PI mode */ - rtlphy->phyreg_def[RF90_PATH_A].rflssi_readbackpi = - TRANSCEIVERA_HSPI_READBACK; - rtlphy->phyreg_def[RF90_PATH_B].rflssi_readbackpi = - TRANSCEIVERB_HSPI_READBACK; -} - -static bool _rtl92d_phy_config_bb_with_headerfile(struct ieee80211_hw *hw, - u8 configtype) -{ - int i; - u32 *phy_regarray_table; - u32 *agctab_array_table = NULL; - u32 *agctab_5garray_table; - u16 phy_reg_arraylen, agctab_arraylen = 0, agctab_5garraylen; - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); - - /* Normal chip,Mac0 use AGC_TAB.txt for 2G and 5G band. */ - if (rtlhal->interfaceindex == 0) { - agctab_arraylen = AGCTAB_ARRAYLENGTH; - agctab_array_table = rtl8192de_agctab_array; - RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, - (" ===> phy:MAC0, Rtl819XAGCTAB_Array\n")); - } else { - if (rtlhal->current_bandtype == BAND_ON_2_4G) { - agctab_arraylen = AGCTAB_2G_ARRAYLENGTH; - agctab_array_table = rtl8192de_agctab_2garray; - RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, - (" ===> phy:MAC1, Rtl819XAGCTAB_2GArray\n")); - } else { - agctab_5garraylen = AGCTAB_5G_ARRAYLENGTH; - agctab_5garray_table = rtl8192de_agctab_5garray; - RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, - (" ===> phy:MAC1, Rtl819XAGCTAB_5GArray\n")); - - } - } - phy_reg_arraylen = PHY_REG_2T_ARRAYLENGTH; - phy_regarray_table = rtl8192de_phy_reg_2tarray; - RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, - (" ===> phy:Rtl819XPHY_REG_Array_PG\n")); - if (configtype == BASEBAND_CONFIG_PHY_REG) { - for (i = 0; i < phy_reg_arraylen; i = i + 2) { - if (phy_regarray_table[i] == 0xfe) - mdelay(50); - else if (phy_regarray_table[i] == 0xfd) - mdelay(5); - else if (phy_regarray_table[i] == 0xfc) - mdelay(1); - else if (phy_regarray_table[i] == 0xfb) - udelay(50); - else if (phy_regarray_table[i] == 0xfa) - udelay(5); - else if (phy_regarray_table[i] == 0xf9) - udelay(1); - rtl_set_bbreg(hw, phy_regarray_table[i], BMASKDWORD, - phy_regarray_table[i + 1]); - udelay(1); - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("The phy_regarray_table[0] is %x" - " Rtl819XPHY_REGArray[1] is %x\n", - phy_regarray_table[i], - phy_regarray_table[i + 1])); - } - } else if (configtype == BASEBAND_CONFIG_AGC_TAB) { - if (rtlhal->interfaceindex == 0) { - for (i = 0; i < agctab_arraylen; i = i + 2) { - rtl_set_bbreg(hw, agctab_array_table[i], - BMASKDWORD, - agctab_array_table[i + 1]); - /* Add 1us delay between BB/RF register - * setting. */ - udelay(1); - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("The Rtl819XAGCTAB_Array_" - "Table[0] is %ul " - "Rtl819XPHY_REGArray[1] is %ul\n", - agctab_array_table[i], - agctab_array_table[i + 1])); - } - RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, - ("Normal Chip, MAC0, load " - "Rtl819XAGCTAB_Array\n")); - } else { - if (rtlhal->current_bandtype == BAND_ON_2_4G) { - for (i = 0; i < agctab_arraylen; i = i + 2) { - rtl_set_bbreg(hw, agctab_array_table[i], - BMASKDWORD, - agctab_array_table[i + 1]); - /* Add 1us delay between BB/RF register - * setting. */ - udelay(1); - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("The Rtl819XAGCTAB_Array_" - "Table[0] is %ul Rtl819XPHY_" - "REGArray[1] is %ul\n", - agctab_array_table[i], - agctab_array_table[i + 1])); - } - RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, - ("Load Rtl819XAGCTAB_2GArray\n")); - } else { - for (i = 0; i < agctab_5garraylen; i = i + 2) { - rtl_set_bbreg(hw, - agctab_5garray_table[i], - BMASKDWORD, - agctab_5garray_table[i + 1]); - /* Add 1us delay between BB/RF registeri - * setting. */ - udelay(1); - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("The Rtl819XAGCTAB_5GArray_" - "Table[0] is %ul Rtl819XPHY_" - "REGArray[1] is %ul\n", - agctab_5garray_table[i], - agctab_5garray_table[i + 1])); - } - RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, - ("Load Rtl819XAGCTAB_5GArray\n")); - } - } - } - return true; -} - -static void _rtl92d_store_pwrindex_diffrate_offset(struct ieee80211_hw *hw, - u32 regaddr, u32 bitmask, - u32 data) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_phy *rtlphy = &(rtlpriv->phy); - - if (regaddr == RTXAGC_A_RATE18_06) { - rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][0] = - data; - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("MCSTxPowerLevelOriginalOffset[%d][0] = 0x%ulx\n", - rtlphy->pwrgroup_cnt, - rtlphy->mcs_txpwrlevel_origoffset - [rtlphy->pwrgroup_cnt][0])); - } - if (regaddr == RTXAGC_A_RATE54_24) { - rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][1] = - data; - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("MCSTxPowerLevelOriginalOffset[%d][1] = 0x%ulx\n", - rtlphy->pwrgroup_cnt, - rtlphy->mcs_txpwrlevel_origoffset - [rtlphy->pwrgroup_cnt][1])); - } - if (regaddr == RTXAGC_A_CCK1_MCS32) { - rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][6] = - data; - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("MCSTxPowerLevelOriginalOffset[%d][6] = 0x%ulx\n", - rtlphy->pwrgroup_cnt, - rtlphy->mcs_txpwrlevel_origoffset - [rtlphy->pwrgroup_cnt][6])); - } - if (regaddr == RTXAGC_B_CCK11_A_CCK2_11 && bitmask == 0xffffff00) { - rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][7] = - data; - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("MCSTxPowerLevelOriginalOffset[%d][7] = 0x%ulx\n", - rtlphy->pwrgroup_cnt, - rtlphy->mcs_txpwrlevel_origoffset - [rtlphy->pwrgroup_cnt][7])); - } - if (regaddr == RTXAGC_A_MCS03_MCS00) { - rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][2] = - data; - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("MCSTxPowerLevelOriginalOffset[%d][2] = 0x%ulx\n", - rtlphy->pwrgroup_cnt, - rtlphy->mcs_txpwrlevel_origoffset - [rtlphy->pwrgroup_cnt][2])); - } - if (regaddr == RTXAGC_A_MCS07_MCS04) { - rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][3] = - data; - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("MCSTxPowerLevelOriginalOffset[%d][3] = 0x%ulx\n", - rtlphy->pwrgroup_cnt, - rtlphy->mcs_txpwrlevel_origoffset - [rtlphy->pwrgroup_cnt][3])); - } - if (regaddr == RTXAGC_A_MCS11_MCS08) { - rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][4] = - data; - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("MCSTxPowerLevelOriginalOffset[%d][4] = 0x%ulx\n", - rtlphy->pwrgroup_cnt, - rtlphy->mcs_txpwrlevel_origoffset - [rtlphy->pwrgroup_cnt][4])); - } - if (regaddr == RTXAGC_A_MCS15_MCS12) { - rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][5] = - data; - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("MCSTxPowerLevelOriginalOffset[%d][5] = 0x%ulx\n", - rtlphy->pwrgroup_cnt, - rtlphy->mcs_txpwrlevel_origoffset - [rtlphy->pwrgroup_cnt][5])); - } - if (regaddr == RTXAGC_B_RATE18_06) { - rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][8] = - data; - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("MCSTxPowerLevelOriginalOffset[%d][8] = 0x%ulx\n", - rtlphy->pwrgroup_cnt, - rtlphy->mcs_txpwrlevel_origoffset - [rtlphy->pwrgroup_cnt][8])); - } - if (regaddr == RTXAGC_B_RATE54_24) { - rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][9] = - data; - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("MCSTxPowerLevelOriginalOffset[%d][9] = 0x%ulx\n", - rtlphy->pwrgroup_cnt, - rtlphy->mcs_txpwrlevel_origoffset - [rtlphy->pwrgroup_cnt][9])); - } - if (regaddr == RTXAGC_B_CCK1_55_MCS32) { - rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][14] = - data; - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("MCSTxPowerLevelOriginalOffset[%d][14] = 0x%ulx\n", - rtlphy->pwrgroup_cnt, - rtlphy->mcs_txpwrlevel_origoffset - [rtlphy->pwrgroup_cnt][14])); - } - if (regaddr == RTXAGC_B_CCK11_A_CCK2_11 && bitmask == 0x000000ff) { - rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][15] = - data; - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("MCSTxPowerLevelOriginalOffset[%d][15] = 0x%ulx\n", - rtlphy->pwrgroup_cnt, - rtlphy->mcs_txpwrlevel_origoffset - [rtlphy->pwrgroup_cnt][15])); - } - if (regaddr == RTXAGC_B_MCS03_MCS00) { - rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][10] = - data; - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("MCSTxPowerLevelOriginalOffset[%d][10] = 0x%ulx\n", - rtlphy->pwrgroup_cnt, - rtlphy->mcs_txpwrlevel_origoffset - [rtlphy->pwrgroup_cnt][10])); - } - if (regaddr == RTXAGC_B_MCS07_MCS04) { - rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][11] = - data; - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("MCSTxPowerLevelOriginalOffset[%d][11] = 0x%ulx\n", - rtlphy->pwrgroup_cnt, - rtlphy->mcs_txpwrlevel_origoffset - [rtlphy->pwrgroup_cnt][11])); - } - if (regaddr == RTXAGC_B_MCS11_MCS08) { - rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][12] = - data; - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("MCSTxPowerLevelOriginalOffset[%d][12] = 0x%ulx\n", - rtlphy->pwrgroup_cnt, - rtlphy->mcs_txpwrlevel_origoffset - [rtlphy->pwrgroup_cnt][12])); - } - if (regaddr == RTXAGC_B_MCS15_MCS12) { - rtlphy->mcs_txpwrlevel_origoffset[rtlphy->pwrgroup_cnt][13] = - data; - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("MCSTxPowerLevelOriginalOffset[%d][13] = 0x%ulx\n", - rtlphy->pwrgroup_cnt, - rtlphy->mcs_txpwrlevel_origoffset - [rtlphy->pwrgroup_cnt][13])); - rtlphy->pwrgroup_cnt++; - } -} - -static bool _rtl92d_phy_config_bb_with_pgheaderfile(struct ieee80211_hw *hw, - u8 configtype) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - int i; - u32 *phy_regarray_table_pg; - u16 phy_regarray_pg_len; - - phy_regarray_pg_len = PHY_REG_ARRAY_PG_LENGTH; - phy_regarray_table_pg = rtl8192de_phy_reg_array_pg; - if (configtype == BASEBAND_CONFIG_PHY_REG) { - for (i = 0; i < phy_regarray_pg_len; i = i + 3) { - if (phy_regarray_table_pg[i] == 0xfe) - mdelay(50); - else if (phy_regarray_table_pg[i] == 0xfd) - mdelay(5); - else if (phy_regarray_table_pg[i] == 0xfc) - mdelay(1); - else if (phy_regarray_table_pg[i] == 0xfb) - udelay(50); - else if (phy_regarray_table_pg[i] == 0xfa) - udelay(5); - else if (phy_regarray_table_pg[i] == 0xf9) - udelay(1); - _rtl92d_store_pwrindex_diffrate_offset(hw, - phy_regarray_table_pg[i], - phy_regarray_table_pg[i + 1], - phy_regarray_table_pg[i + 2]); - } - } else { - RT_TRACE(rtlpriv, COMP_SEND, DBG_TRACE, - ("configtype != BaseBand_Config_PHY_REG\n")); - } - return true; -} - -static bool _rtl92d_phy_bb_config(struct ieee80211_hw *hw) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_phy *rtlphy = &(rtlpriv->phy); - struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw)); - bool rtstatus = true; - - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, ("==>\n")); - rtstatus = _rtl92d_phy_config_bb_with_headerfile(hw, - BASEBAND_CONFIG_PHY_REG); - if (rtstatus != true) { - RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, ("Write BB Reg Fail!!")); - return false; - } - - /* if (rtlphy->rf_type == RF_1T2R) { - * _rtl92c_phy_bb_config_1t(hw); - * RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, ("Config to 1T!!\n")); - *} */ - - if (rtlefuse->autoload_failflag == false) { - rtlphy->pwrgroup_cnt = 0; - rtstatus = _rtl92d_phy_config_bb_with_pgheaderfile(hw, - BASEBAND_CONFIG_PHY_REG); - } - if (rtstatus != true) { - RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, ("BB_PG Reg Fail!!")); - return false; - } - rtstatus = _rtl92d_phy_config_bb_with_headerfile(hw, - BASEBAND_CONFIG_AGC_TAB); - if (rtstatus != true) { - RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, ("AGC Table Fail\n")); - return false; - } - rtlphy->cck_high_power = (bool) (rtl_get_bbreg(hw, - RFPGA0_XA_HSSIPARAMETER2, 0x200)); - - return true; -} - -bool rtl92d_phy_bb_config(struct ieee80211_hw *hw) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - u16 regval; - u32 regvaldw; - u8 value; - - _rtl92d_phy_init_bb_rf_register_definition(hw); - regval = rtl_read_word(rtlpriv, REG_SYS_FUNC_EN); - rtl_write_word(rtlpriv, REG_SYS_FUNC_EN, - regval | BIT(13) | BIT(0) | BIT(1)); - rtl_write_byte(rtlpriv, REG_AFE_PLL_CTRL, 0x83); - rtl_write_byte(rtlpriv, REG_AFE_PLL_CTRL + 1, 0xdb); - /* 0x1f bit7 bit6 represent for mac0/mac1 driver ready */ - value = rtl_read_byte(rtlpriv, REG_RF_CTRL); - rtl_write_byte(rtlpriv, REG_RF_CTRL, value | RF_EN | RF_RSTB | - RF_SDMRSTB); - rtl_write_byte(rtlpriv, REG_SYS_FUNC_EN, FEN_PPLL | FEN_PCIEA | - FEN_DIO_PCIE | FEN_BB_GLB_RSTn | FEN_BBRSTB); - rtl_write_byte(rtlpriv, REG_AFE_XTAL_CTRL + 1, 0x80); - if (!(IS_92D_SINGLEPHY(rtlpriv->rtlhal.version))) { - regvaldw = rtl_read_dword(rtlpriv, REG_LEDCFG0); - rtl_write_dword(rtlpriv, REG_LEDCFG0, regvaldw | BIT(23)); - } - - return _rtl92d_phy_bb_config(hw); -} - -bool rtl92d_phy_rf_config(struct ieee80211_hw *hw) -{ - return rtl92d_phy_rf6052_config(hw); -} - -bool rtl92d_phy_config_rf_with_headerfile(struct ieee80211_hw *hw, - enum rf_content content, - enum radio_path rfpath) -{ - int i; - u32 *radioa_array_table; - u32 *radiob_array_table; - u16 radioa_arraylen, radiob_arraylen; - struct rtl_priv *rtlpriv = rtl_priv(hw); - - radioa_arraylen = RADIOA_2T_ARRAYLENGTH; - radioa_array_table = rtl8192de_radioa_2tarray; - radiob_arraylen = RADIOB_2T_ARRAYLENGTH; - radiob_array_table = rtl8192de_radiob_2tarray; - if (rtlpriv->efuse.internal_pa_5g[0]) { - radioa_arraylen = RADIOA_2T_INT_PA_ARRAYLENGTH; - radioa_array_table = rtl8192de_radioa_2t_int_paarray; - } - if (rtlpriv->efuse.internal_pa_5g[1]) { - radiob_arraylen = RADIOB_2T_INT_PA_ARRAYLENGTH; - radiob_array_table = rtl8192de_radiob_2t_int_paarray; - } - RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, - ("PHY_ConfigRFWithHeaderFile() " - "Radio_A:Rtl819XRadioA_1TArray\n")); - RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, - ("PHY_ConfigRFWithHeaderFile() " - "Radio_B:Rtl819XRadioB_1TArray\n")); - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, ("Radio No %x\n", rfpath)); - - /* this only happens when DMDP, mac0 start on 2.4G, - * mac1 start on 5G, mac 0 has to set phy0&phy1 - * pathA or mac1 has to set phy0&phy1 pathA */ - if ((content == radiob_txt) && (rfpath == RF90_PATH_A)) { - RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, - (" ===> althougth Path A, we load radiob.txt\n")); - radioa_arraylen = radiob_arraylen; - radioa_array_table = radiob_array_table; - } - switch (rfpath) { - case RF90_PATH_A: - for (i = 0; i < radioa_arraylen; i = i + 2) { - if (radioa_array_table[i] == 0xfe) { - mdelay(50); - } else if (radioa_array_table[i] == 0xfd) { - /* delay_ms(5); */ - mdelay(5); - } else if (radioa_array_table[i] == 0xfc) { - /* delay_ms(1); */ - mdelay(1); - } else if (radioa_array_table[i] == 0xfb) { - udelay(50); - } else if (radioa_array_table[i] == 0xfa) { - udelay(5); - } else if (radioa_array_table[i] == 0xf9) { - udelay(1); - } else { - rtl_set_rfreg(hw, rfpath, radioa_array_table[i], - BRFREGOFFSETMASK, - radioa_array_table[i + 1]); - /* Add 1us delay between BB/RF register set. */ - udelay(1); - } - } - break; - case RF90_PATH_B: - for (i = 0; i < radiob_arraylen; i = i + 2) { - if (radiob_array_table[i] == 0xfe) { - /* Delay specific ms. Only RF configuration - * requires delay. */ - mdelay(50); - } else if (radiob_array_table[i] == 0xfd) { - /* delay_ms(5); */ - mdelay(5); - } else if (radiob_array_table[i] == 0xfc) { - /* delay_ms(1); */ - mdelay(1); - } else if (radiob_array_table[i] == 0xfb) { - udelay(50); - } else if (radiob_array_table[i] == 0xfa) { - udelay(5); - } else if (radiob_array_table[i] == 0xf9) { - udelay(1); - } else { - rtl_set_rfreg(hw, rfpath, radiob_array_table[i], - BRFREGOFFSETMASK, - radiob_array_table[i + 1]); - /* Add 1us delay between BB/RF register set. */ - udelay(1); - } - } - break; - case RF90_PATH_C: - RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("switch case not process\n")); - break; - case RF90_PATH_D: - RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("switch case not process\n")); - break; - } - return true; -} - -void rtl92d_phy_get_hw_reg_originalvalue(struct ieee80211_hw *hw) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_phy *rtlphy = &(rtlpriv->phy); - - rtlphy->default_initialgain[0] = - (u8) rtl_get_bbreg(hw, ROFDM0_XAAGCCORE1, BMASKBYTE0); - rtlphy->default_initialgain[1] = - (u8) rtl_get_bbreg(hw, ROFDM0_XBAGCCORE1, BMASKBYTE0); - rtlphy->default_initialgain[2] = - (u8) rtl_get_bbreg(hw, ROFDM0_XCAGCCORE1, BMASKBYTE0); - rtlphy->default_initialgain[3] = - (u8) rtl_get_bbreg(hw, ROFDM0_XDAGCCORE1, BMASKBYTE0); - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("Default initial gain (c50=0x%x, " - "c58=0x%x, c60=0x%x, c68=0x%x\n", - rtlphy->default_initialgain[0], - rtlphy->default_initialgain[1], - rtlphy->default_initialgain[2], - rtlphy->default_initialgain[3])); - rtlphy->framesync = (u8)rtl_get_bbreg(hw, ROFDM0_RXDETECTOR3, - BMASKBYTE0); - rtlphy->framesync_c34 = rtl_get_bbreg(hw, ROFDM0_RXDETECTOR2, - BMASKDWORD); - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("Default framesync (0x%x) = 0x%x\n", - ROFDM0_RXDETECTOR3, rtlphy->framesync)); -} - -static void _rtl92d_get_txpower_index(struct ieee80211_hw *hw, u8 channel, - u8 *cckpowerlevel, u8 *ofdmpowerlevel) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_phy *rtlphy = &(rtlpriv->phy); - struct rtl_hal *rtlhal = &(rtlpriv->rtlhal); - struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw)); - u8 index = (channel - 1); - - /* 1. CCK */ - if (rtlhal->current_bandtype == BAND_ON_2_4G) { - /* RF-A */ - cckpowerlevel[RF90_PATH_A] = - rtlefuse->txpwrlevel_cck[RF90_PATH_A][index]; - /* RF-B */ - cckpowerlevel[RF90_PATH_B] = - rtlefuse->txpwrlevel_cck[RF90_PATH_B][index]; - } else { - cckpowerlevel[RF90_PATH_A] = 0; - cckpowerlevel[RF90_PATH_B] = 0; - } - /* 2. OFDM for 1S or 2S */ - if (rtlphy->rf_type == RF_1T2R || rtlphy->rf_type == RF_1T1R) { - /* Read HT 40 OFDM TX power */ - ofdmpowerlevel[RF90_PATH_A] = - rtlefuse->txpwrlevel_ht40_1s[RF90_PATH_A][index]; - ofdmpowerlevel[RF90_PATH_B] = - rtlefuse->txpwrlevel_ht40_1s[RF90_PATH_B][index]; - } else if (rtlphy->rf_type == RF_2T2R) { - /* Read HT 40 OFDM TX power */ - ofdmpowerlevel[RF90_PATH_A] = - rtlefuse->txpwrlevel_ht40_2s[RF90_PATH_A][index]; - ofdmpowerlevel[RF90_PATH_B] = - rtlefuse->txpwrlevel_ht40_2s[RF90_PATH_B][index]; - } -} - -static void _rtl92d_ccxpower_index_check(struct ieee80211_hw *hw, - u8 channel, u8 *cckpowerlevel, u8 *ofdmpowerlevel) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_phy *rtlphy = &(rtlpriv->phy); - - rtlphy->cur_cck_txpwridx = cckpowerlevel[0]; - rtlphy->cur_ofdm24g_txpwridx = ofdmpowerlevel[0]; -} - -static u8 _rtl92c_phy_get_rightchnlplace(u8 chnl) -{ - u8 channel_5g[59] = { - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, - 60, 62, 64, 100, 102, 104, 106, 108, 110, 112, - 114, 116, 118, 120, 122, 124, 126, 128, - 130, 132, 134, 136, 138, 140, 149, 151, - 153, 155, 157, 159, 161, 163, 165 - }; - u8 place = chnl; - - if (chnl > 14) { - for (place = 14; place < sizeof(channel_5g); place++) { - if (channel_5g[place] == chnl) { - place++; - break; - } - } - } - return place; -} - -void rtl92d_phy_set_txpower_level(struct ieee80211_hw *hw, u8 channel) -{ - struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw)); - struct rtl_priv *rtlpriv = rtl_priv(hw); - u8 cckpowerlevel[2], ofdmpowerlevel[2]; - - if (rtlefuse->txpwr_fromeprom == false) - return; - channel = _rtl92c_phy_get_rightchnlplace(channel); - _rtl92d_get_txpower_index(hw, channel, &cckpowerlevel[0], - &ofdmpowerlevel[0]); - if (rtlpriv->rtlhal.current_bandtype == BAND_ON_2_4G) - _rtl92d_ccxpower_index_check(hw, channel, &cckpowerlevel[0], - &ofdmpowerlevel[0]); - if (rtlpriv->rtlhal.current_bandtype == BAND_ON_2_4G) - rtl92d_phy_rf6052_set_cck_txpower(hw, &cckpowerlevel[0]); - rtl92d_phy_rf6052_set_ofdm_txpower(hw, &ofdmpowerlevel[0], channel); -} - -void rtl92d_phy_scan_operation_backup(struct ieee80211_hw *hw, u8 operation) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); - enum io_type iotype; - - if (!is_hal_stop(rtlhal)) { - switch (operation) { - case SCAN_OPT_BACKUP: - rtlhal->current_bandtypebackup = - rtlhal->current_bandtype; - iotype = IO_CMD_PAUSE_DM_BY_SCAN; - rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_IO_CMD, - (u8 *)&iotype); - break; - case SCAN_OPT_RESTORE: - iotype = IO_CMD_RESUME_DM_BY_SCAN; - rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_IO_CMD, - (u8 *)&iotype); - break; - default: - RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("Unknown Scan Backup operation.\n")); - break; - } - } -} - -void rtl92d_phy_set_bw_mode(struct ieee80211_hw *hw, - enum nl80211_channel_type ch_type) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_phy *rtlphy = &(rtlpriv->phy); - struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); - struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); - unsigned long flag = 0; - u8 reg_prsr_rsc; - u8 reg_bw_opmode; - - if (rtlphy->set_bwmode_inprogress) - return; - if ((is_hal_stop(rtlhal)) || (RT_CANNOT_IO(hw))) { - RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, - ("FALSE driver sleep or unload\n")); - return; - } - rtlphy->set_bwmode_inprogress = true; - RT_TRACE(rtlpriv, COMP_SCAN, DBG_TRACE, - ("Switch to %s bandwidth\n", - rtlphy->current_chan_bw == HT_CHANNEL_WIDTH_20 ? - "20MHz" : "40MHz")); - reg_bw_opmode = rtl_read_byte(rtlpriv, REG_BWOPMODE); - reg_prsr_rsc = rtl_read_byte(rtlpriv, REG_RRSR + 2); - switch (rtlphy->current_chan_bw) { - case HT_CHANNEL_WIDTH_20: - reg_bw_opmode |= BW_OPMODE_20MHZ; - rtl_write_byte(rtlpriv, REG_BWOPMODE, reg_bw_opmode); - break; - case HT_CHANNEL_WIDTH_20_40: - reg_bw_opmode &= ~BW_OPMODE_20MHZ; - rtl_write_byte(rtlpriv, REG_BWOPMODE, reg_bw_opmode); - - reg_prsr_rsc = (reg_prsr_rsc & 0x90) | - (mac->cur_40_prime_sc << 5); - rtl_write_byte(rtlpriv, REG_RRSR + 2, reg_prsr_rsc); - break; - default: - RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("unknown bandwidth: %#X\n", rtlphy->current_chan_bw)); - break; - } - switch (rtlphy->current_chan_bw) { - case HT_CHANNEL_WIDTH_20: - rtl_set_bbreg(hw, RFPGA0_RFMOD, BRFMOD, 0x0); - rtl_set_bbreg(hw, RFPGA1_RFMOD, BRFMOD, 0x0); - /* SET BIT10 BIT11 for receive cck */ - rtl_set_bbreg(hw, RFPGA0_ANALOGPARAMETER2, BIT(10) | - BIT(11), 3); - break; - case HT_CHANNEL_WIDTH_20_40: - rtl_set_bbreg(hw, RFPGA0_RFMOD, BRFMOD, 0x1); - rtl_set_bbreg(hw, RFPGA1_RFMOD, BRFMOD, 0x1); - /* Set Control channel to upper or lower. - * These settings are required only for 40MHz */ - if (rtlhal->current_bandtype == BAND_ON_2_4G) { - rtl92d_acquire_cckandrw_pagea_ctl(hw, &flag); - rtl_set_bbreg(hw, RCCK0_SYSTEM, BCCKSIDEBAND, - (mac->cur_40_prime_sc >> 1)); - rtl92d_release_cckandrw_pagea_ctl(hw, &flag); - } - rtl_set_bbreg(hw, ROFDM1_LSTF, 0xC00, mac->cur_40_prime_sc); - /* SET BIT10 BIT11 for receive cck */ - rtl_set_bbreg(hw, RFPGA0_ANALOGPARAMETER2, BIT(10) | - BIT(11), 0); - rtl_set_bbreg(hw, 0x818, (BIT(26) | BIT(27)), - (mac->cur_40_prime_sc == - HAL_PRIME_CHNL_OFFSET_LOWER) ? 2 : 1); - break; - default: - RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("unknown bandwidth: %#X\n", rtlphy->current_chan_bw)); - break; - - } - rtl92d_phy_rf6052_set_bandwidth(hw, rtlphy->current_chan_bw); - rtlphy->set_bwmode_inprogress = false; - RT_TRACE(rtlpriv, COMP_SCAN, DBG_TRACE, ("<==\n")); -} - -static void _rtl92d_phy_stop_trx_before_changeband(struct ieee80211_hw *hw) -{ - rtl_set_bbreg(hw, RFPGA0_RFMOD, BCCKEN, 0); - rtl_set_bbreg(hw, RFPGA0_RFMOD, BOFDMEN, 0); - rtl_set_bbreg(hw, ROFDM0_TRXPATHENABLE, BMASKBYTE0, 0x00); - rtl_set_bbreg(hw, ROFDM1_TRXPATHENABLE, BDWORD, 0x0); -} - -static void rtl92d_phy_switch_wirelessband(struct ieee80211_hw *hw, u8 band) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); - u8 value8; - - RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, ("==>\n")); - rtlhal->bandset = band; - rtlhal->current_bandtype = band; - if (IS_92D_SINGLEPHY(rtlhal->version)) - rtlhal->bandset = BAND_ON_BOTH; - /* stop RX/Tx */ - _rtl92d_phy_stop_trx_before_changeband(hw); - /* reconfig BB/RF according to wireless mode */ - if (rtlhal->current_bandtype == BAND_ON_2_4G) { - /* BB & RF Config */ - RT_TRACE(rtlpriv, COMP_CMD, DBG_DMESG, ("====>2.4G\n")); - if (rtlhal->interfaceindex == 1) - _rtl92d_phy_config_bb_with_headerfile(hw, - BASEBAND_CONFIG_AGC_TAB); - } else { - /* 5G band */ - RT_TRACE(rtlpriv, COMP_CMD, DBG_DMESG, ("====>5G\n")); - if (rtlhal->interfaceindex == 1) - _rtl92d_phy_config_bb_with_headerfile(hw, - BASEBAND_CONFIG_AGC_TAB); - } - rtl92d_update_bbrf_configuration(hw); - if (rtlhal->current_bandtype == BAND_ON_2_4G) - rtl_set_bbreg(hw, RFPGA0_RFMOD, BCCKEN, 0x1); - rtl_set_bbreg(hw, RFPGA0_RFMOD, BOFDMEN, 0x1); - - /* 20M BW. */ - /* rtl_set_bbreg(hw, RFPGA0_ANALOGPARAMETER2, BIT(10), 1); */ - rtlhal->reloadtxpowerindex = true; - /* notice fw know band status 0x81[1]/0x53[1] = 0: 5G, 1: 2G */ - if (rtlhal->current_bandtype == BAND_ON_2_4G) { - value8 = rtl_read_byte(rtlpriv, (rtlhal->interfaceindex == - 0 ? REG_MAC0 : REG_MAC1)); - value8 |= BIT(1); - rtl_write_byte(rtlpriv, (rtlhal->interfaceindex == - 0 ? REG_MAC0 : REG_MAC1), value8); - } else { - value8 = rtl_read_byte(rtlpriv, (rtlhal->interfaceindex == - 0 ? REG_MAC0 : REG_MAC1)); - value8 &= (~BIT(1)); - rtl_write_byte(rtlpriv, (rtlhal->interfaceindex == - 0 ? REG_MAC0 : REG_MAC1), value8); - } - mdelay(1); - RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, ("<==Switch Band OK.\n")); -} - -static void _rtl92d_phy_reload_imr_setting(struct ieee80211_hw *hw, - u8 channel, u8 rfpath) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - u32 imr_num = MAX_RF_IMR_INDEX; - u32 rfmask = BRFREGOFFSETMASK; - u8 group, i; - unsigned long flag = 0; - - RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, ("====>path %d\n", rfpath)); - if (rtlpriv->rtlhal.current_bandtype == BAND_ON_5G) { - RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, ("====>5G\n")); - rtl_set_bbreg(hw, RFPGA0_RFMOD, BIT(25) | BIT(24), 0); - rtl_set_bbreg(hw, RFPGA0_ANALOGPARAMETER4, 0x00f00000, 0xf); - /* fc area 0xd2c */ - if (channel > 99) - rtl_set_bbreg(hw, ROFDM1_CFOTRACKING, BIT(13) | - BIT(14), 2); - else - rtl_set_bbreg(hw, ROFDM1_CFOTRACKING, BIT(13) | - BIT(14), 1); - /* leave 0 for channel1-14. */ - group = channel <= 64 ? 1 : 2; - imr_num = MAX_RF_IMR_INDEX_NORMAL; - for (i = 0; i < imr_num; i++) - rtl_set_rfreg(hw, (enum radio_path)rfpath, - rf_reg_for_5g_swchnl_normal[i], rfmask, - rf_imr_param_normal[0][group][i]); - rtl_set_bbreg(hw, RFPGA0_ANALOGPARAMETER4, 0x00f00000, 0); - rtl_set_bbreg(hw, RFPGA0_RFMOD, BOFDMEN, 1); - } else { - /* G band. */ - RT_TRACE(rtlpriv, COMP_SCAN, DBG_LOUD, - ("Load RF IMR parameters for G band. IMR already " - "setting %d\n", - rtlpriv->rtlhal.load_imrandiqk_setting_for2g)); - RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, ("====>2.4G\n")); - if (!rtlpriv->rtlhal.load_imrandiqk_setting_for2g) { - RT_TRACE(rtlpriv, COMP_SCAN, DBG_LOUD, - ("Load RF IMR parameters " - "for G band. %d\n", rfpath)); - rtl92d_acquire_cckandrw_pagea_ctl(hw, &flag); - rtl_set_bbreg(hw, RFPGA0_RFMOD, BIT(25) | BIT(24), 0); - rtl_set_bbreg(hw, RFPGA0_ANALOGPARAMETER4, - 0x00f00000, 0xf); - imr_num = MAX_RF_IMR_INDEX_NORMAL; - for (i = 0; i < imr_num; i++) { - rtl_set_rfreg(hw, (enum radio_path)rfpath, - rf_reg_for_5g_swchnl_normal[i], - BRFREGOFFSETMASK, - rf_imr_param_normal[0][0][i]); - } - rtl_set_bbreg(hw, RFPGA0_ANALOGPARAMETER4, - 0x00f00000, 0); - rtl_set_bbreg(hw, RFPGA0_RFMOD, BOFDMEN | BCCKEN, 3); - rtl92d_release_cckandrw_pagea_ctl(hw, &flag); - } - } - RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, ("<====\n")); -} - -static void _rtl92d_phy_enable_rf_env(struct ieee80211_hw *hw, - u8 rfpath, u32 *pu4_regval) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_phy *rtlphy = &(rtlpriv->phy); - struct bb_reg_def *pphyreg = &rtlphy->phyreg_def[rfpath]; - - RT_TRACE(rtlpriv, COMP_RF, DBG_LOUD, ("====>\n")); - /*----Store original RFENV control type----*/ - switch (rfpath) { - case RF90_PATH_A: - case RF90_PATH_C: - *pu4_regval = rtl_get_bbreg(hw, pphyreg->rfintfs, BRFSI_RFENV); - break; - case RF90_PATH_B: - case RF90_PATH_D: - *pu4_regval = - rtl_get_bbreg(hw, pphyreg->rfintfs, BRFSI_RFENV << 16); - break; - } - /*----Set RF_ENV enable----*/ - rtl_set_bbreg(hw, pphyreg->rfintfe, BRFSI_RFENV << 16, 0x1); - udelay(1); - /*----Set RF_ENV output high----*/ - rtl_set_bbreg(hw, pphyreg->rfintfo, BRFSI_RFENV, 0x1); - udelay(1); - /* Set bit number of Address and Data for RF register */ - /* Set 1 to 4 bits for 8255 */ - rtl_set_bbreg(hw, pphyreg->rfhssi_para2, B3WIREADDRESSLENGTH, 0x0); - udelay(1); - /*Set 0 to 12 bits for 8255 */ - rtl_set_bbreg(hw, pphyreg->rfhssi_para2, B3WIREDATALENGTH, 0x0); - udelay(1); - RT_TRACE(rtlpriv, COMP_RF, DBG_LOUD, ("<====\n")); -} - -static void _rtl92d_phy_restore_rf_env(struct ieee80211_hw *hw, u8 rfpath, - u32 *pu4_regval) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_phy *rtlphy = &(rtlpriv->phy); - struct bb_reg_def *pphyreg = &rtlphy->phyreg_def[rfpath]; - - RT_TRACE(rtlpriv, COMP_RF, DBG_LOUD, ("=====>\n")); - /*----Restore RFENV control type----*/ ; - switch (rfpath) { - case RF90_PATH_A: - case RF90_PATH_C: - rtl_set_bbreg(hw, pphyreg->rfintfs, BRFSI_RFENV, *pu4_regval); - break; - case RF90_PATH_B: - case RF90_PATH_D: - rtl_set_bbreg(hw, pphyreg->rfintfs, BRFSI_RFENV << 16, - *pu4_regval); - break; - } - RT_TRACE(rtlpriv, COMP_RF, DBG_LOUD, ("<=====\n")); -} - -static void _rtl92d_phy_switch_rf_setting(struct ieee80211_hw *hw, u8 channel) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_phy *rtlphy = &(rtlpriv->phy); - struct rtl_hal *rtlhal = &(rtlpriv->rtlhal); - u8 path = rtlhal->current_bandtype == - BAND_ON_5G ? RF90_PATH_A : RF90_PATH_B; - u8 index = 0, i = 0, rfpath = RF90_PATH_A; - bool need_pwr_down = false, internal_pa = false; - u32 u4regvalue, mask = 0x1C000, value = 0, u4tmp, u4tmp2; - - RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, ("====>\n")); - /* config path A for 5G */ - if (rtlhal->current_bandtype == BAND_ON_5G) { - RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, ("====>5G\n")); - u4tmp = curveindex_5g[channel - 1]; - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("ver 1 set RF-A, 5G, " - "0x28 = 0x%x !!\n", u4tmp)); - for (i = 0; i < RF_CHNL_NUM_5G; i++) { - if (channel == rf_chnl_5g[i] && channel <= 140) - index = 0; - } - for (i = 0; i < RF_CHNL_NUM_5G_40M; i++) { - if (channel == rf_chnl_5g_40m[i] && channel <= 140) - index = 1; - } - if (channel == 149 || channel == 155 || channel == 161) - index = 2; - else if (channel == 151 || channel == 153 || channel == 163 - || channel == 165) - index = 3; - else if (channel == 157 || channel == 159) - index = 4; - - if (rtlhal->macphymode == DUALMAC_DUALPHY - && rtlhal->interfaceindex == 1) { - need_pwr_down = rtl92d_phy_enable_anotherphy(hw, false); - rtlhal->during_mac1init_radioa = true; - /* asume no this case */ - if (need_pwr_down) - _rtl92d_phy_enable_rf_env(hw, path, - &u4regvalue); - } - for (i = 0; i < RF_REG_NUM_FOR_C_CUT_5G; i++) { - if (i == 0 && (rtlhal->macphymode == DUALMAC_DUALPHY)) { - rtl_set_rfreg(hw, (enum radio_path)path, - rf_reg_for_c_cut_5g[i], - BRFREGOFFSETMASK, 0xE439D); - } else if (rf_reg_for_c_cut_5g[i] == RF_SYN_G4) { - u4tmp2 = (rf_reg_pram_c_5g[index][i] & - 0x7FF) | (u4tmp << 11); - if (channel == 36) - u4tmp2 &= ~(BIT(7) | BIT(6)); - rtl_set_rfreg(hw, (enum radio_path)path, - rf_reg_for_c_cut_5g[i], - BRFREGOFFSETMASK, u4tmp2); - } else { - rtl_set_rfreg(hw, (enum radio_path)path, - rf_reg_for_c_cut_5g[i], - BRFREGOFFSETMASK, - rf_reg_pram_c_5g[index][i]); - } - RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, - ("offset 0x%x value 0x%x " - "path %d index %d readback 0x%x\n", - rf_reg_for_c_cut_5g[i], - rf_reg_pram_c_5g[index][i], path, - index, rtl_get_rfreg(hw, (enum radio_path)path, - rf_reg_for_c_cut_5g[i], BRFREGOFFSETMASK))); - } - if (need_pwr_down) - _rtl92d_phy_restore_rf_env(hw, path, &u4regvalue); - if (rtlhal->during_mac1init_radioa) - rtl92d_phy_powerdown_anotherphy(hw, false); - if (channel < 149) - value = 0x07; - else if (channel >= 149) - value = 0x02; - if (channel >= 36 && channel <= 64) - index = 0; - else if (channel >= 100 && channel <= 140) - index = 1; - else - index = 2; - for (rfpath = RF90_PATH_A; rfpath < rtlphy->num_total_rfpath; - rfpath++) { - if (rtlhal->macphymode == DUALMAC_DUALPHY && - rtlhal->interfaceindex == 1) /* MAC 1 5G */ - internal_pa = rtlpriv->efuse.internal_pa_5g[1]; - else - internal_pa = - rtlpriv->efuse.internal_pa_5g[rfpath]; - if (internal_pa) { - for (i = 0; - i < RF_REG_NUM_FOR_C_CUT_5G_INTERNALPA; - i++) { - rtl_set_rfreg(hw, rfpath, - rf_for_c_cut_5g_internal_pa[i], - BRFREGOFFSETMASK, - rf_pram_c_5g_int_pa[index][i]); - RT_TRACE(rtlpriv, COMP_RF, DBG_LOUD, - ("offset 0x%x value 0x%x " - "path %d index %d\n", - rf_for_c_cut_5g_internal_pa[i], - rf_pram_c_5g_int_pa[index][i], - rfpath, index)); - } - } else { - rtl_set_rfreg(hw, (enum radio_path)rfpath, 0x0B, - mask, value); - } - } - } else if (rtlhal->current_bandtype == BAND_ON_2_4G) { - RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, ("====>2.4G\n")); - u4tmp = curveindex_2g[channel - 1]; - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("ver 3 set RF-B, 2G, " - "0x28 = 0x%x !!\n", u4tmp)); - if (channel == 1 || channel == 2 || channel == 4 || channel == 9 - || channel == 10 || channel == 11 || channel == 12) - index = 0; - else if (channel == 3 || channel == 13 || channel == 14) - index = 1; - else if (channel >= 5 && channel <= 8) - index = 2; - if (rtlhal->macphymode == DUALMAC_DUALPHY) { - path = RF90_PATH_A; - if (rtlhal->interfaceindex == 0) { - need_pwr_down = - rtl92d_phy_enable_anotherphy(hw, true); - rtlhal->during_mac0init_radiob = true; - - if (need_pwr_down) - _rtl92d_phy_enable_rf_env(hw, path, - &u4regvalue); - } - } - for (i = 0; i < RF_REG_NUM_FOR_C_CUT_2G; i++) { - if (rf_reg_for_c_cut_2g[i] == RF_SYN_G7) - rtl_set_rfreg(hw, (enum radio_path)path, - rf_reg_for_c_cut_2g[i], - BRFREGOFFSETMASK, - (rf_reg_param_for_c_cut_2g[index][i] | - BIT(17))); - else - rtl_set_rfreg(hw, (enum radio_path)path, - rf_reg_for_c_cut_2g[i], - BRFREGOFFSETMASK, - rf_reg_param_for_c_cut_2g - [index][i]); - RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE, - ("offset 0x%x value 0x%x mak 0x%x path %d " - "index %d readback 0x%x\n", - rf_reg_for_c_cut_2g[i], - rf_reg_param_for_c_cut_2g[index][i], - rf_reg_mask_for_c_cut_2g[i], path, index, - rtl_get_rfreg(hw, (enum radio_path)path, - rf_reg_for_c_cut_2g[i], - BRFREGOFFSETMASK))); - } - RTPRINT(rtlpriv, FINIT, INIT_IQK, - ("cosa ver 3 set RF-B, 2G, 0x28 = 0x%x !!\n", - rf_syn_g4_for_c_cut_2g | (u4tmp << 11))); - - rtl_set_rfreg(hw, (enum radio_path)path, RF_SYN_G4, - BRFREGOFFSETMASK, - rf_syn_g4_for_c_cut_2g | (u4tmp << 11)); - if (need_pwr_down) - _rtl92d_phy_restore_rf_env(hw, path, &u4regvalue); - if (rtlhal->during_mac0init_radiob) - rtl92d_phy_powerdown_anotherphy(hw, true); - } - RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, ("<====\n")); -} - -u8 rtl92d_get_rightchnlplace_for_iqk(u8 chnl) -{ - u8 channel_all[59] = { - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, - 60, 62, 64, 100, 102, 104, 106, 108, 110, 112, - 114, 116, 118, 120, 122, 124, 126, 128, 130, - 132, 134, 136, 138, 140, 149, 151, 153, 155, - 157, 159, 161, 163, 165 - }; - u8 place = chnl; - - if (chnl > 14) { - for (place = 14; place < sizeof(channel_all); place++) { - if (channel_all[place] == chnl) - return place - 13; - } - } - - return 0; -} - -#define MAX_TOLERANCE 5 -#define IQK_DELAY_TIME 1 /* ms */ -#define MAX_TOLERANCE_92D 3 - -/* bit0 = 1 => Tx OK, bit1 = 1 => Rx OK */ -static u8 _rtl92d_phy_patha_iqk(struct ieee80211_hw *hw, bool configpathb) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); - u32 regeac, rege94, rege9c, regea4; - u8 result = 0; - - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("Path A IQK!\n")); - /* path-A IQK setting */ - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("Path-A IQK setting!\n")); - if (rtlhal->interfaceindex == 0) { - rtl_set_bbreg(hw, 0xe30, BMASKDWORD, 0x10008c1f); - rtl_set_bbreg(hw, 0xe34, BMASKDWORD, 0x10008c1f); - } else { - rtl_set_bbreg(hw, 0xe30, BMASKDWORD, 0x10008c22); - rtl_set_bbreg(hw, 0xe34, BMASKDWORD, 0x10008c22); - } - rtl_set_bbreg(hw, 0xe38, BMASKDWORD, 0x82140102); - rtl_set_bbreg(hw, 0xe3c, BMASKDWORD, 0x28160206); - /* path-B IQK setting */ - if (configpathb) { - rtl_set_bbreg(hw, 0xe50, BMASKDWORD, 0x10008c22); - rtl_set_bbreg(hw, 0xe54, BMASKDWORD, 0x10008c22); - rtl_set_bbreg(hw, 0xe58, BMASKDWORD, 0x82140102); - rtl_set_bbreg(hw, 0xe5c, BMASKDWORD, 0x28160206); - } - /* LO calibration setting */ - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("LO calibration setting!\n")); - rtl_set_bbreg(hw, 0xe4c, BMASKDWORD, 0x00462911); - /* One shot, path A LOK & IQK */ - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("One shot, path A LOK & IQK!\n")); - rtl_set_bbreg(hw, 0xe48, BMASKDWORD, 0xf9000000); - rtl_set_bbreg(hw, 0xe48, BMASKDWORD, 0xf8000000); - /* delay x ms */ - RTPRINT(rtlpriv, FINIT, INIT_IQK, - ("Delay %d ms for One shot, path A LOK & IQK.\n", - IQK_DELAY_TIME)); - mdelay(IQK_DELAY_TIME); - /* Check failed */ - regeac = rtl_get_bbreg(hw, 0xeac, BMASKDWORD); - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("0xeac = 0x%x\n", regeac)); - rege94 = rtl_get_bbreg(hw, 0xe94, BMASKDWORD); - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("0xe94 = 0x%x\n", rege94)); - rege9c = rtl_get_bbreg(hw, 0xe9c, BMASKDWORD); - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("0xe9c = 0x%x\n", rege9c)); - regea4 = rtl_get_bbreg(hw, 0xea4, BMASKDWORD); - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("0xea4 = 0x%x\n", regea4)); - if (!(regeac & BIT(28)) && (((rege94 & 0x03FF0000) >> 16) != 0x142) && - (((rege9c & 0x03FF0000) >> 16) != 0x42)) - result |= 0x01; - else /* if Tx not OK, ignore Rx */ - return result; - /* if Tx is OK, check whether Rx is OK */ - if (!(regeac & BIT(27)) && (((regea4 & 0x03FF0000) >> 16) != 0x132) && - (((regeac & 0x03FF0000) >> 16) != 0x36)) - result |= 0x02; - else - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("Path A Rx IQK fail!!\n")); - return result; -} - -/* bit0 = 1 => Tx OK, bit1 = 1 => Rx OK */ -static u8 _rtl92d_phy_patha_iqk_5g_normal(struct ieee80211_hw *hw, - bool configpathb) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); - struct rtl_phy *rtlphy = &(rtlpriv->phy); - u32 regeac, rege94, rege9c, regea4; - u8 result = 0; - u8 i; - u8 retrycount = 2; - u32 TxOKBit = BIT(28), RxOKBit = BIT(27); - - if (rtlhal->interfaceindex == 1) { /* PHY1 */ - TxOKBit = BIT(31); - RxOKBit = BIT(30); - } - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("Path A IQK!\n")); - /* path-A IQK setting */ - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("Path-A IQK setting!\n")); - rtl_set_bbreg(hw, 0xe30, BMASKDWORD, 0x18008c1f); - rtl_set_bbreg(hw, 0xe34, BMASKDWORD, 0x18008c1f); - rtl_set_bbreg(hw, 0xe38, BMASKDWORD, 0x82140307); - rtl_set_bbreg(hw, 0xe3c, BMASKDWORD, 0x68160960); - /* path-B IQK setting */ - if (configpathb) { - rtl_set_bbreg(hw, 0xe50, BMASKDWORD, 0x18008c2f); - rtl_set_bbreg(hw, 0xe54, BMASKDWORD, 0x18008c2f); - rtl_set_bbreg(hw, 0xe58, BMASKDWORD, 0x82110000); - rtl_set_bbreg(hw, 0xe5c, BMASKDWORD, 0x68110000); - } - /* LO calibration setting */ - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("LO calibration setting!\n")); - rtl_set_bbreg(hw, 0xe4c, BMASKDWORD, 0x00462911); - /* path-A PA on */ - rtl_set_bbreg(hw, RFPGA0_XAB_RFINTERFACESW, BMASKDWORD, 0x07000f60); - rtl_set_bbreg(hw, RFPGA0_XA_RFINTERFACEOE, BMASKDWORD, 0x66e60e30); - for (i = 0; i < retrycount; i++) { - /* One shot, path A LOK & IQK */ - RTPRINT(rtlpriv, FINIT, INIT_IQK, - ("One shot, path A LOK & IQK!\n")); - rtl_set_bbreg(hw, 0xe48, BMASKDWORD, 0xf9000000); - rtl_set_bbreg(hw, 0xe48, BMASKDWORD, 0xf8000000); - /* delay x ms */ - RTPRINT(rtlpriv, FINIT, INIT_IQK, - ("Delay %d ms for One shot, path A LOK & IQK.\n", - IQK_DELAY_TIME)); - mdelay(IQK_DELAY_TIME * 10); - /* Check failed */ - regeac = rtl_get_bbreg(hw, 0xeac, BMASKDWORD); - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("0xeac = 0x%x\n", regeac)); - rege94 = rtl_get_bbreg(hw, 0xe94, BMASKDWORD); - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("0xe94 = 0x%x\n", rege94)); - rege9c = rtl_get_bbreg(hw, 0xe9c, BMASKDWORD); - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("0xe9c = 0x%x\n", rege9c)); - regea4 = rtl_get_bbreg(hw, 0xea4, BMASKDWORD); - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("0xea4 = 0x%x\n", regea4)); - if (!(regeac & TxOKBit) && - (((rege94 & 0x03FF0000) >> 16) != 0x142)) { - result |= 0x01; - } else { /* if Tx not OK, ignore Rx */ - RTPRINT(rtlpriv, FINIT, INIT_IQK, - ("Path A Tx IQK fail!!\n")); - continue; - } - - /* if Tx is OK, check whether Rx is OK */ - if (!(regeac & RxOKBit) && - (((regea4 & 0x03FF0000) >> 16) != 0x132)) { - result |= 0x02; - break; - } else { - RTPRINT(rtlpriv, FINIT, INIT_IQK, - ("Path A Rx IQK fail!!\n")); - } - } - /* path A PA off */ - rtl_set_bbreg(hw, RFPGA0_XAB_RFINTERFACESW, BMASKDWORD, - rtlphy->iqk_bb_backup[0]); - rtl_set_bbreg(hw, RFPGA0_XA_RFINTERFACEOE, BMASKDWORD, - rtlphy->iqk_bb_backup[1]); - return result; -} - -/* bit0 = 1 => Tx OK, bit1 = 1 => Rx OK */ -static u8 _rtl92d_phy_pathb_iqk(struct ieee80211_hw *hw) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - u32 regeac, regeb4, regebc, regec4, regecc; - u8 result = 0; - - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("Path B IQK!\n")); - /* One shot, path B LOK & IQK */ - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("One shot, path A LOK & IQK!\n")); - rtl_set_bbreg(hw, 0xe60, BMASKDWORD, 0x00000002); - rtl_set_bbreg(hw, 0xe60, BMASKDWORD, 0x00000000); - /* delay x ms */ - RTPRINT(rtlpriv, FINIT, INIT_IQK, - ("Delay %d ms for One shot, path B LOK & IQK.\n", - IQK_DELAY_TIME)); - mdelay(IQK_DELAY_TIME); - /* Check failed */ - regeac = rtl_get_bbreg(hw, 0xeac, BMASKDWORD); - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("0xeac = 0x%x\n", regeac)); - regeb4 = rtl_get_bbreg(hw, 0xeb4, BMASKDWORD); - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("0xeb4 = 0x%x\n", regeb4)); - regebc = rtl_get_bbreg(hw, 0xebc, BMASKDWORD); - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("0xebc = 0x%x\n", regebc)); - regec4 = rtl_get_bbreg(hw, 0xec4, BMASKDWORD); - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("0xec4 = 0x%x\n", regec4)); - regecc = rtl_get_bbreg(hw, 0xecc, BMASKDWORD); - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("0xecc = 0x%x\n", regecc)); - if (!(regeac & BIT(31)) && (((regeb4 & 0x03FF0000) >> 16) != 0x142) && - (((regebc & 0x03FF0000) >> 16) != 0x42)) - result |= 0x01; - else - return result; - if (!(regeac & BIT(30)) && (((regec4 & 0x03FF0000) >> 16) != 0x132) && - (((regecc & 0x03FF0000) >> 16) != 0x36)) - result |= 0x02; - else - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("Path B Rx IQK fail!!\n")); - return result; -} - -/* bit0 = 1 => Tx OK, bit1 = 1 => Rx OK */ -static u8 _rtl92d_phy_pathb_iqk_5g_normal(struct ieee80211_hw *hw) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_phy *rtlphy = &(rtlpriv->phy); - u32 regeac, regeb4, regebc, regec4, regecc; - u8 result = 0; - u8 i; - u8 retrycount = 2; - - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("Path B IQK!\n")); - /* path-A IQK setting */ - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("Path-A IQK setting!\n")); - rtl_set_bbreg(hw, 0xe30, BMASKDWORD, 0x18008c1f); - rtl_set_bbreg(hw, 0xe34, BMASKDWORD, 0x18008c1f); - rtl_set_bbreg(hw, 0xe38, BMASKDWORD, 0x82110000); - rtl_set_bbreg(hw, 0xe3c, BMASKDWORD, 0x68110000); - - /* path-B IQK setting */ - rtl_set_bbreg(hw, 0xe50, BMASKDWORD, 0x18008c2f); - rtl_set_bbreg(hw, 0xe54, BMASKDWORD, 0x18008c2f); - rtl_set_bbreg(hw, 0xe58, BMASKDWORD, 0x82140307); - rtl_set_bbreg(hw, 0xe5c, BMASKDWORD, 0x68160960); - - /* LO calibration setting */ - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("LO calibration setting!\n")); - rtl_set_bbreg(hw, 0xe4c, BMASKDWORD, 0x00462911); - - /* path-B PA on */ - rtl_set_bbreg(hw, RFPGA0_XAB_RFINTERFACESW, BMASKDWORD, 0x0f600700); - rtl_set_bbreg(hw, RFPGA0_XB_RFINTERFACEOE, BMASKDWORD, 0x061f0d30); - - for (i = 0; i < retrycount; i++) { - /* One shot, path B LOK & IQK */ - RTPRINT(rtlpriv, FINIT, INIT_IQK, - ("One shot, path A LOK & IQK!\n")); - rtl_set_bbreg(hw, 0xe48, BMASKDWORD, 0xfa000000); - rtl_set_bbreg(hw, 0xe48, BMASKDWORD, 0xf8000000); - - /* delay x ms */ - RTPRINT(rtlpriv, FINIT, INIT_IQK, - ("Delay %d ms for One shot, path B LOK & IQK.\n", 10)); - mdelay(IQK_DELAY_TIME * 10); - - /* Check failed */ - regeac = rtl_get_bbreg(hw, 0xeac, BMASKDWORD); - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("0xeac = 0x%x\n", regeac)); - regeb4 = rtl_get_bbreg(hw, 0xeb4, BMASKDWORD); - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("0xeb4 = 0x%x\n", regeb4)); - regebc = rtl_get_bbreg(hw, 0xebc, BMASKDWORD); - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("0xebc = 0x%x\n", regebc)); - regec4 = rtl_get_bbreg(hw, 0xec4, BMASKDWORD); - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("0xec4 = 0x%x\n", regec4)); - regecc = rtl_get_bbreg(hw, 0xecc, BMASKDWORD); - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("0xecc = 0x%x\n", regecc)); - if (!(regeac & BIT(31)) && - (((regeb4 & 0x03FF0000) >> 16) != 0x142)) - result |= 0x01; - else - continue; - if (!(regeac & BIT(30)) && - (((regec4 & 0x03FF0000) >> 16) != 0x132)) { - result |= 0x02; - break; - } else { - RTPRINT(rtlpriv, FINIT, INIT_IQK, - ("Path B Rx IQK fail!!\n")); - } - } - - /* path B PA off */ - rtl_set_bbreg(hw, RFPGA0_XAB_RFINTERFACESW, BMASKDWORD, - rtlphy->iqk_bb_backup[0]); - rtl_set_bbreg(hw, RFPGA0_XB_RFINTERFACEOE, BMASKDWORD, - rtlphy->iqk_bb_backup[2]); - return result; -} - -static void _rtl92d_phy_save_adda_registers(struct ieee80211_hw *hw, - u32 *adda_reg, u32 *adda_backup, - u32 regnum) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - u32 i; - - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("Save ADDA parameters.\n")); - for (i = 0; i < regnum; i++) - adda_backup[i] = rtl_get_bbreg(hw, adda_reg[i], BMASKDWORD); -} - -static void _rtl92d_phy_save_mac_registers(struct ieee80211_hw *hw, - u32 *macreg, u32 *macbackup) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - u32 i; - - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("Save MAC parameters.\n")); - for (i = 0; i < (IQK_MAC_REG_NUM - 1); i++) - macbackup[i] = rtl_read_byte(rtlpriv, macreg[i]); - macbackup[i] = rtl_read_dword(rtlpriv, macreg[i]); -} - -static void _rtl92d_phy_reload_adda_registers(struct ieee80211_hw *hw, - u32 *adda_reg, u32 *adda_backup, - u32 regnum) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - u32 i; - - RTPRINT(rtlpriv, FINIT, INIT_IQK, - ("Reload ADDA power saving parameters !\n")); - for (i = 0; i < regnum; i++) - rtl_set_bbreg(hw, adda_reg[i], BMASKDWORD, adda_backup[i]); -} - -static void _rtl92d_phy_reload_mac_registers(struct ieee80211_hw *hw, - u32 *macreg, u32 *macbackup) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - u32 i; - - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("Reload MAC parameters !\n")); - for (i = 0; i < (IQK_MAC_REG_NUM - 1); i++) - rtl_write_byte(rtlpriv, macreg[i], (u8) macbackup[i]); - rtl_write_byte(rtlpriv, macreg[i], macbackup[i]); -} - -static void _rtl92d_phy_path_adda_on(struct ieee80211_hw *hw, - u32 *adda_reg, bool patha_on, bool is2t) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - u32 pathon; - u32 i; - - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("ADDA ON.\n")); - pathon = patha_on ? 0x04db25a4 : 0x0b1b25a4; - if (patha_on) - pathon = rtlpriv->rtlhal.interfaceindex == 0 ? - 0x04db25a4 : 0x0b1b25a4; - for (i = 0; i < IQK_ADDA_REG_NUM; i++) - rtl_set_bbreg(hw, adda_reg[i], BMASKDWORD, pathon); -} - -static void _rtl92d_phy_mac_setting_calibration(struct ieee80211_hw *hw, - u32 *macreg, u32 *macbackup) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - u32 i; - - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("MAC settings for Calibration.\n")); - rtl_write_byte(rtlpriv, macreg[0], 0x3F); - - for (i = 1; i < (IQK_MAC_REG_NUM - 1); i++) - rtl_write_byte(rtlpriv, macreg[i], (u8)(macbackup[i] & - (~BIT(3)))); - rtl_write_byte(rtlpriv, macreg[i], (u8) (macbackup[i] & (~BIT(5)))); -} - -static void _rtl92d_phy_patha_standby(struct ieee80211_hw *hw) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("Path-A standby mode!\n")); - - rtl_set_bbreg(hw, 0xe28, BMASKDWORD, 0x0); - rtl_set_bbreg(hw, RFPGA0_XA_LSSIPARAMETER, BMASKDWORD, 0x00010000); - rtl_set_bbreg(hw, 0xe28, BMASKDWORD, 0x80800000); -} - -static void _rtl92d_phy_pimode_switch(struct ieee80211_hw *hw, bool pi_mode) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - u32 mode; - - RTPRINT(rtlpriv, FINIT, INIT_IQK, - ("BB Switch to %s mode!\n", (pi_mode ? "PI" : "SI"))); - mode = pi_mode ? 0x01000100 : 0x01000000; - rtl_set_bbreg(hw, 0x820, BMASKDWORD, mode); - rtl_set_bbreg(hw, 0x828, BMASKDWORD, mode); -} - -static void _rtl92d_phy_iq_calibrate(struct ieee80211_hw *hw, long result[][8], - u8 t, bool is2t) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_phy *rtlphy = &(rtlpriv->phy); - u32 i; - u8 patha_ok, pathb_ok; - static u32 adda_reg[IQK_ADDA_REG_NUM] = { - RFPGA0_XCD_SWITCHCONTROL, 0xe6c, 0xe70, 0xe74, - 0xe78, 0xe7c, 0xe80, 0xe84, - 0xe88, 0xe8c, 0xed0, 0xed4, - 0xed8, 0xedc, 0xee0, 0xeec - }; - static u32 iqk_mac_reg[IQK_MAC_REG_NUM] = { - 0x522, 0x550, 0x551, 0x040 - }; - static u32 iqk_bb_reg[IQK_BB_REG_NUM] = { - RFPGA0_XAB_RFINTERFACESW, RFPGA0_XA_RFINTERFACEOE, - RFPGA0_XB_RFINTERFACEOE, ROFDM0_TRMUXPAR, - RFPGA0_XCD_RFINTERFACESW, ROFDM0_TRXPATHENABLE, - RFPGA0_RFMOD, RFPGA0_ANALOGPARAMETER4, - ROFDM0_XAAGCCORE1, ROFDM0_XBAGCCORE1 - }; - const u32 retrycount = 2; - u32 bbvalue; - - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("IQK for 2.4G :Start!!!\n")); - if (t == 0) { - bbvalue = rtl_get_bbreg(hw, RFPGA0_RFMOD, BMASKDWORD); - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("==>0x%08x\n", bbvalue)); - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("IQ Calibration for %s\n", - (is2t ? "2T2R" : "1T1R"))); - - /* Save ADDA parameters, turn Path A ADDA on */ - _rtl92d_phy_save_adda_registers(hw, adda_reg, - rtlphy->adda_backup, IQK_ADDA_REG_NUM); - _rtl92d_phy_save_mac_registers(hw, iqk_mac_reg, - rtlphy->iqk_mac_backup); - _rtl92d_phy_save_adda_registers(hw, iqk_bb_reg, - rtlphy->iqk_bb_backup, IQK_BB_REG_NUM); - } - _rtl92d_phy_path_adda_on(hw, adda_reg, true, is2t); - if (t == 0) - rtlphy->rfpi_enable = (u8) rtl_get_bbreg(hw, - RFPGA0_XA_HSSIPARAMETER1, BIT(8)); - - /* Switch BB to PI mode to do IQ Calibration. */ - if (!rtlphy->rfpi_enable) - _rtl92d_phy_pimode_switch(hw, true); - - rtl_set_bbreg(hw, RFPGA0_RFMOD, BIT(24), 0x00); - rtl_set_bbreg(hw, ROFDM0_TRXPATHENABLE, BMASKDWORD, 0x03a05600); - rtl_set_bbreg(hw, ROFDM0_TRMUXPAR, BMASKDWORD, 0x000800e4); - rtl_set_bbreg(hw, RFPGA0_XCD_RFINTERFACESW, BMASKDWORD, 0x22204000); - rtl_set_bbreg(hw, RFPGA0_ANALOGPARAMETER4, 0xf00000, 0x0f); - if (is2t) { - rtl_set_bbreg(hw, RFPGA0_XA_LSSIPARAMETER, BMASKDWORD, - 0x00010000); - rtl_set_bbreg(hw, RFPGA0_XB_LSSIPARAMETER, BMASKDWORD, - 0x00010000); - } - /* MAC settings */ - _rtl92d_phy_mac_setting_calibration(hw, iqk_mac_reg, - rtlphy->iqk_mac_backup); - /* Page B init */ - rtl_set_bbreg(hw, 0xb68, BMASKDWORD, 0x0f600000); - if (is2t) - rtl_set_bbreg(hw, 0xb6c, BMASKDWORD, 0x0f600000); - /* IQ calibration setting */ - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("IQK setting!\n")); - rtl_set_bbreg(hw, 0xe28, BMASKDWORD, 0x80800000); - rtl_set_bbreg(hw, 0xe40, BMASKDWORD, 0x01007c00); - rtl_set_bbreg(hw, 0xe44, BMASKDWORD, 0x01004800); - for (i = 0; i < retrycount; i++) { - patha_ok = _rtl92d_phy_patha_iqk(hw, is2t); - if (patha_ok == 0x03) { - RTPRINT(rtlpriv, FINIT, INIT_IQK, - ("Path A IQK Success!!\n")); - result[t][0] = (rtl_get_bbreg(hw, 0xe94, BMASKDWORD) & - 0x3FF0000) >> 16; - result[t][1] = (rtl_get_bbreg(hw, 0xe9c, BMASKDWORD) & - 0x3FF0000) >> 16; - result[t][2] = (rtl_get_bbreg(hw, 0xea4, BMASKDWORD) & - 0x3FF0000) >> 16; - result[t][3] = (rtl_get_bbreg(hw, 0xeac, BMASKDWORD) & - 0x3FF0000) >> 16; - break; - } else if (i == (retrycount - 1) && patha_ok == 0x01) { - /* Tx IQK OK */ - RTPRINT(rtlpriv, FINIT, INIT_IQK, - ("Path A IQK Only Tx Success!!\n")); - - result[t][0] = (rtl_get_bbreg(hw, 0xe94, BMASKDWORD) & - 0x3FF0000) >> 16; - result[t][1] = (rtl_get_bbreg(hw, 0xe9c, BMASKDWORD) & - 0x3FF0000) >> 16; - } - } - if (0x00 == patha_ok) - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("Path A IQK failed!!\n")); - if (is2t) { - _rtl92d_phy_patha_standby(hw); - /* Turn Path B ADDA on */ - _rtl92d_phy_path_adda_on(hw, adda_reg, false, is2t); - for (i = 0; i < retrycount; i++) { - pathb_ok = _rtl92d_phy_pathb_iqk(hw); - if (pathb_ok == 0x03) { - RTPRINT(rtlpriv, FINIT, INIT_IQK, - ("Path B IQK Success!!\n")); - result[t][4] = (rtl_get_bbreg(hw, 0xeb4, - BMASKDWORD) & 0x3FF0000) >> 16; - result[t][5] = (rtl_get_bbreg(hw, 0xebc, - BMASKDWORD) & 0x3FF0000) >> 16; - result[t][6] = (rtl_get_bbreg(hw, 0xec4, - BMASKDWORD) & 0x3FF0000) >> 16; - result[t][7] = (rtl_get_bbreg(hw, 0xecc, - BMASKDWORD) & 0x3FF0000) >> 16; - break; - } else if (i == (retrycount - 1) && pathb_ok == 0x01) { - /* Tx IQK OK */ - RTPRINT(rtlpriv, FINIT, INIT_IQK, - ("Path B Only Tx IQK Success!!\n")); - result[t][4] = (rtl_get_bbreg(hw, 0xeb4, - BMASKDWORD) & 0x3FF0000) >> 16; - result[t][5] = (rtl_get_bbreg(hw, 0xebc, - BMASKDWORD) & 0x3FF0000) >> 16; - } - } - if (0x00 == pathb_ok) - RTPRINT(rtlpriv, FINIT, INIT_IQK, - ("Path B IQK failed!!\n")); - } - - /* Back to BB mode, load original value */ - RTPRINT(rtlpriv, FINIT, INIT_IQK, - ("IQK:Back to BB mode, load original value!\n")); - - rtl_set_bbreg(hw, 0xe28, BMASKDWORD, 0); - if (t != 0) { - /* Switch back BB to SI mode after finish IQ Calibration. */ - if (!rtlphy->rfpi_enable) - _rtl92d_phy_pimode_switch(hw, false); - /* Reload ADDA power saving parameters */ - _rtl92d_phy_reload_adda_registers(hw, adda_reg, - rtlphy->adda_backup, IQK_ADDA_REG_NUM); - /* Reload MAC parameters */ - _rtl92d_phy_reload_mac_registers(hw, iqk_mac_reg, - rtlphy->iqk_mac_backup); - if (is2t) - _rtl92d_phy_reload_adda_registers(hw, iqk_bb_reg, - rtlphy->iqk_bb_backup, - IQK_BB_REG_NUM); - else - _rtl92d_phy_reload_adda_registers(hw, iqk_bb_reg, - rtlphy->iqk_bb_backup, - IQK_BB_REG_NUM - 1); - /* load 0xe30 IQC default value */ - rtl_set_bbreg(hw, 0xe30, BMASKDWORD, 0x01008c00); - rtl_set_bbreg(hw, 0xe34, BMASKDWORD, 0x01008c00); - } - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("<==\n")); -} - -static void _rtl92d_phy_iq_calibrate_5g_normal(struct ieee80211_hw *hw, - long result[][8], u8 t) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_phy *rtlphy = &(rtlpriv->phy); - struct rtl_hal *rtlhal = &(rtlpriv->rtlhal); - u8 patha_ok, pathb_ok; - static u32 adda_reg[IQK_ADDA_REG_NUM] = { - RFPGA0_XCD_SWITCHCONTROL, 0xe6c, 0xe70, 0xe74, - 0xe78, 0xe7c, 0xe80, 0xe84, - 0xe88, 0xe8c, 0xed0, 0xed4, - 0xed8, 0xedc, 0xee0, 0xeec - }; - static u32 iqk_mac_reg[IQK_MAC_REG_NUM] = { - 0x522, 0x550, 0x551, 0x040 - }; - static u32 iqk_bb_reg[IQK_BB_REG_NUM] = { - RFPGA0_XAB_RFINTERFACESW, RFPGA0_XA_RFINTERFACEOE, - RFPGA0_XB_RFINTERFACEOE, ROFDM0_TRMUXPAR, - RFPGA0_XCD_RFINTERFACESW, ROFDM0_TRXPATHENABLE, - RFPGA0_RFMOD, RFPGA0_ANALOGPARAMETER4, - ROFDM0_XAAGCCORE1, ROFDM0_XBAGCCORE1 - }; - u32 bbvalue; - bool is2t = IS_92D_SINGLEPHY(rtlhal->version); - - /* Note: IQ calibration must be performed after loading - * PHY_REG.txt , and radio_a, radio_b.txt */ - - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("IQK for 5G NORMAL:Start!!!\n")); - mdelay(IQK_DELAY_TIME * 20); - if (t == 0) { - bbvalue = rtl_get_bbreg(hw, RFPGA0_RFMOD, BMASKDWORD); - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("==>0x%08x\n", bbvalue)); - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("IQ Calibration for %s\n", - (is2t ? "2T2R" : "1T1R"))); - /* Save ADDA parameters, turn Path A ADDA on */ - _rtl92d_phy_save_adda_registers(hw, adda_reg, - rtlphy->adda_backup, - IQK_ADDA_REG_NUM); - _rtl92d_phy_save_mac_registers(hw, iqk_mac_reg, - rtlphy->iqk_mac_backup); - if (is2t) - _rtl92d_phy_save_adda_registers(hw, iqk_bb_reg, - rtlphy->iqk_bb_backup, - IQK_BB_REG_NUM); - else - _rtl92d_phy_save_adda_registers(hw, iqk_bb_reg, - rtlphy->iqk_bb_backup, - IQK_BB_REG_NUM - 1); - } - _rtl92d_phy_path_adda_on(hw, adda_reg, true, is2t); - /* MAC settings */ - _rtl92d_phy_mac_setting_calibration(hw, iqk_mac_reg, - rtlphy->iqk_mac_backup); - if (t == 0) - rtlphy->rfpi_enable = (u8) rtl_get_bbreg(hw, - RFPGA0_XA_HSSIPARAMETER1, BIT(8)); - /* Switch BB to PI mode to do IQ Calibration. */ - if (!rtlphy->rfpi_enable) - _rtl92d_phy_pimode_switch(hw, true); - rtl_set_bbreg(hw, RFPGA0_RFMOD, BIT(24), 0x00); - rtl_set_bbreg(hw, ROFDM0_TRXPATHENABLE, BMASKDWORD, 0x03a05600); - rtl_set_bbreg(hw, ROFDM0_TRMUXPAR, BMASKDWORD, 0x000800e4); - rtl_set_bbreg(hw, RFPGA0_XCD_RFINTERFACESW, BMASKDWORD, 0x22208000); - rtl_set_bbreg(hw, RFPGA0_ANALOGPARAMETER4, 0xf00000, 0x0f); - - /* Page B init */ - rtl_set_bbreg(hw, 0xb68, BMASKDWORD, 0x0f600000); - if (is2t) - rtl_set_bbreg(hw, 0xb6c, BMASKDWORD, 0x0f600000); - /* IQ calibration setting */ - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("IQK setting!\n")); - rtl_set_bbreg(hw, 0xe28, BMASKDWORD, 0x80800000); - rtl_set_bbreg(hw, 0xe40, BMASKDWORD, 0x10007c00); - rtl_set_bbreg(hw, 0xe44, BMASKDWORD, 0x01004800); - patha_ok = _rtl92d_phy_patha_iqk_5g_normal(hw, is2t); - if (patha_ok == 0x03) { - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("Path A IQK Success!!\n")); - result[t][0] = (rtl_get_bbreg(hw, 0xe94, BMASKDWORD) & - 0x3FF0000) >> 16; - result[t][1] = (rtl_get_bbreg(hw, 0xe9c, BMASKDWORD) & - 0x3FF0000) >> 16; - result[t][2] = (rtl_get_bbreg(hw, 0xea4, BMASKDWORD) & - 0x3FF0000) >> 16; - result[t][3] = (rtl_get_bbreg(hw, 0xeac, BMASKDWORD) & - 0x3FF0000) >> 16; - } else if (patha_ok == 0x01) { /* Tx IQK OK */ - RTPRINT(rtlpriv, FINIT, INIT_IQK, - ("Path A IQK Only Tx Success!!\n")); - - result[t][0] = (rtl_get_bbreg(hw, 0xe94, BMASKDWORD) & - 0x3FF0000) >> 16; - result[t][1] = (rtl_get_bbreg(hw, 0xe9c, BMASKDWORD) & - 0x3FF0000) >> 16; - } else { - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("Path A IQK Fail!!\n")); - } - if (is2t) { - /* _rtl92d_phy_patha_standby(hw); */ - /* Turn Path B ADDA on */ - _rtl92d_phy_path_adda_on(hw, adda_reg, false, is2t); - pathb_ok = _rtl92d_phy_pathb_iqk_5g_normal(hw); - if (pathb_ok == 0x03) { - RTPRINT(rtlpriv, FINIT, INIT_IQK, - ("Path B IQK Success!!\n")); - result[t][4] = (rtl_get_bbreg(hw, 0xeb4, BMASKDWORD) & - 0x3FF0000) >> 16; - result[t][5] = (rtl_get_bbreg(hw, 0xebc, BMASKDWORD) & - 0x3FF0000) >> 16; - result[t][6] = (rtl_get_bbreg(hw, 0xec4, BMASKDWORD) & - 0x3FF0000) >> 16; - result[t][7] = (rtl_get_bbreg(hw, 0xecc, BMASKDWORD) & - 0x3FF0000) >> 16; - } else if (pathb_ok == 0x01) { /* Tx IQK OK */ - RTPRINT(rtlpriv, FINIT, INIT_IQK, - ("Path B Only Tx IQK Success!!\n")); - result[t][4] = (rtl_get_bbreg(hw, 0xeb4, BMASKDWORD) & - 0x3FF0000) >> 16; - result[t][5] = (rtl_get_bbreg(hw, 0xebc, BMASKDWORD) & - 0x3FF0000) >> 16; - } else { - RTPRINT(rtlpriv, FINIT, INIT_IQK, - ("Path B IQK failed!!\n")); - } - } - - /* Back to BB mode, load original value */ - RTPRINT(rtlpriv, FINIT, INIT_IQK, - ("IQK:Back to BB mode, load original value!\n")); - rtl_set_bbreg(hw, 0xe28, BMASKDWORD, 0); - if (t != 0) { - if (is2t) - _rtl92d_phy_reload_adda_registers(hw, iqk_bb_reg, - rtlphy->iqk_bb_backup, - IQK_BB_REG_NUM); - else - _rtl92d_phy_reload_adda_registers(hw, iqk_bb_reg, - rtlphy->iqk_bb_backup, - IQK_BB_REG_NUM - 1); - /* Reload MAC parameters */ - _rtl92d_phy_reload_mac_registers(hw, iqk_mac_reg, - rtlphy->iqk_mac_backup); - /* Switch back BB to SI mode after finish IQ Calibration. */ - if (!rtlphy->rfpi_enable) - _rtl92d_phy_pimode_switch(hw, false); - /* Reload ADDA power saving parameters */ - _rtl92d_phy_reload_adda_registers(hw, adda_reg, - rtlphy->adda_backup, - IQK_ADDA_REG_NUM); - } - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("<==\n")); -} - -static bool _rtl92d_phy_simularity_compare(struct ieee80211_hw *hw, - long result[][8], u8 c1, u8 c2) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_hal *rtlhal = &(rtlpriv->rtlhal); - u32 i, j, diff, sim_bitmap, bound; - u8 final_candidate[2] = {0xFF, 0xFF}; /* for path A and path B */ - bool bresult = true; - bool is2t = IS_92D_SINGLEPHY(rtlhal->version); - - if (is2t) - bound = 8; - else - bound = 4; - sim_bitmap = 0; - for (i = 0; i < bound; i++) { - diff = (result[c1][i] > result[c2][i]) ? (result[c1][i] - - result[c2][i]) : (result[c2][i] - result[c1][i]); - if (diff > MAX_TOLERANCE_92D) { - if ((i == 2 || i == 6) && !sim_bitmap) { - if (result[c1][i] + result[c1][i + 1] == 0) - final_candidate[(i / 4)] = c2; - else if (result[c2][i] + result[c2][i + 1] == 0) - final_candidate[(i / 4)] = c1; - else - sim_bitmap = sim_bitmap | (1 << i); - } else { - sim_bitmap = sim_bitmap | (1 << i); - } - } - } - if (sim_bitmap == 0) { - for (i = 0; i < (bound / 4); i++) { - if (final_candidate[i] != 0xFF) { - for (j = i * 4; j < (i + 1) * 4 - 2; j++) - result[3][j] = - result[final_candidate[i]][j]; - bresult = false; - } - } - return bresult; - } - if (!(sim_bitmap & 0x0F)) { /* path A OK */ - for (i = 0; i < 4; i++) - result[3][i] = result[c1][i]; - } else if (!(sim_bitmap & 0x03)) { /* path A, Tx OK */ - for (i = 0; i < 2; i++) - result[3][i] = result[c1][i]; - } - if (!(sim_bitmap & 0xF0) && is2t) { /* path B OK */ - for (i = 4; i < 8; i++) - result[3][i] = result[c1][i]; - } else if (!(sim_bitmap & 0x30)) { /* path B, Tx OK */ - for (i = 4; i < 6; i++) - result[3][i] = result[c1][i]; - } - return false; -} - -static void _rtl92d_phy_patha_fill_iqk_matrix(struct ieee80211_hw *hw, - bool iqk_ok, long result[][8], - u8 final_candidate, bool txonly) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_hal *rtlhal = &(rtlpriv->rtlhal); - u32 oldval_0, val_x, tx0_a, reg; - long val_y, tx0_c; - bool is2t = IS_92D_SINGLEPHY(rtlhal->version) || - rtlhal->macphymode == DUALMAC_DUALPHY; - - RTPRINT(rtlpriv, FINIT, INIT_IQK, - ("Path A IQ Calibration %s !\n", - (iqk_ok) ? "Success" : "Failed")); - if (final_candidate == 0xFF) { - return; - } else if (iqk_ok) { - oldval_0 = (rtl_get_bbreg(hw, ROFDM0_XATxIQIMBALANCE, - BMASKDWORD) >> 22) & 0x3FF; /* OFDM0_D */ - val_x = result[final_candidate][0]; - if ((val_x & 0x00000200) != 0) - val_x = val_x | 0xFFFFFC00; - tx0_a = (val_x * oldval_0) >> 8; - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("X = 0x%x, tx0_a = 0x%x," - " oldval_0 0x%x\n", val_x, tx0_a, oldval_0)); - rtl_set_bbreg(hw, ROFDM0_XATxIQIMBALANCE, 0x3FF, tx0_a); - rtl_set_bbreg(hw, ROFDM0_ECCATHRESHOLD, BIT(24), - ((val_x * oldval_0 >> 7) & 0x1)); - val_y = result[final_candidate][1]; - if ((val_y & 0x00000200) != 0) - val_y = val_y | 0xFFFFFC00; - /* path B IQK result + 3 */ - if (rtlhal->interfaceindex == 1 && - rtlhal->current_bandtype == BAND_ON_5G) - val_y += 3; - tx0_c = (val_y * oldval_0) >> 8; - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("Y = 0x%lx, tx0_c = 0x%lx\n", - val_y, tx0_c)); - rtl_set_bbreg(hw, ROFDM0_XCTxAFE, 0xF0000000, - ((tx0_c & 0x3C0) >> 6)); - rtl_set_bbreg(hw, ROFDM0_XATxIQIMBALANCE, 0x003F0000, - (tx0_c & 0x3F)); - if (is2t) - rtl_set_bbreg(hw, ROFDM0_ECCATHRESHOLD, BIT(26), - ((val_y * oldval_0 >> 7) & 0x1)); - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("0xC80 = 0x%x\n", - rtl_get_bbreg(hw, ROFDM0_XATxIQIMBALANCE, - BMASKDWORD))); - if (txonly) { - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("only Tx OK\n")); - return; - } - reg = result[final_candidate][2]; - rtl_set_bbreg(hw, ROFDM0_XARXIQIMBALANCE, 0x3FF, reg); - reg = result[final_candidate][3] & 0x3F; - rtl_set_bbreg(hw, ROFDM0_XARXIQIMBALANCE, 0xFC00, reg); - reg = (result[final_candidate][3] >> 6) & 0xF; - rtl_set_bbreg(hw, 0xca0, 0xF0000000, reg); - } -} - -static void _rtl92d_phy_pathb_fill_iqk_matrix(struct ieee80211_hw *hw, - bool iqk_ok, long result[][8], u8 final_candidate, bool txonly) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_hal *rtlhal = &(rtlpriv->rtlhal); - u32 oldval_1, val_x, tx1_a, reg; - long val_y, tx1_c; - - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("Path B IQ Calibration %s !\n", - (iqk_ok) ? "Success" : "Failed")); - if (final_candidate == 0xFF) { - return; - } else if (iqk_ok) { - oldval_1 = (rtl_get_bbreg(hw, ROFDM0_XBTxIQIMBALANCE, - BMASKDWORD) >> 22) & 0x3FF; - val_x = result[final_candidate][4]; - if ((val_x & 0x00000200) != 0) - val_x = val_x | 0xFFFFFC00; - tx1_a = (val_x * oldval_1) >> 8; - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("X = 0x%x, tx1_a = 0x%x\n", - val_x, tx1_a)); - rtl_set_bbreg(hw, ROFDM0_XBTxIQIMBALANCE, 0x3FF, tx1_a); - rtl_set_bbreg(hw, ROFDM0_ECCATHRESHOLD, BIT(28), - ((val_x * oldval_1 >> 7) & 0x1)); - val_y = result[final_candidate][5]; - if ((val_y & 0x00000200) != 0) - val_y = val_y | 0xFFFFFC00; - if (rtlhal->current_bandtype == BAND_ON_5G) - val_y += 3; - tx1_c = (val_y * oldval_1) >> 8; - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("Y = 0x%lx, tx1_c = 0x%lx\n", - val_y, tx1_c)); - rtl_set_bbreg(hw, ROFDM0_XDTxAFE, 0xF0000000, - ((tx1_c & 0x3C0) >> 6)); - rtl_set_bbreg(hw, ROFDM0_XBTxIQIMBALANCE, 0x003F0000, - (tx1_c & 0x3F)); - rtl_set_bbreg(hw, ROFDM0_ECCATHRESHOLD, BIT(30), - ((val_y * oldval_1 >> 7) & 0x1)); - if (txonly) - return; - reg = result[final_candidate][6]; - rtl_set_bbreg(hw, ROFDM0_XBRXIQIMBALANCE, 0x3FF, reg); - reg = result[final_candidate][7] & 0x3F; - rtl_set_bbreg(hw, ROFDM0_XBRXIQIMBALANCE, 0xFC00, reg); - reg = (result[final_candidate][7] >> 6) & 0xF; - rtl_set_bbreg(hw, ROFDM0_AGCRSSITABLE, 0x0000F000, reg); - } -} - -void rtl92d_phy_iq_calibrate(struct ieee80211_hw *hw) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_phy *rtlphy = &(rtlpriv->phy); - struct rtl_hal *rtlhal = &(rtlpriv->rtlhal); - long result[4][8]; - u8 i, final_candidate, indexforchannel; - bool patha_ok, pathb_ok; - long rege94, rege9c, regea4, regeac, regeb4; - long regebc, regec4, regecc, regtmp = 0; - bool is12simular, is13simular, is23simular; - unsigned long flag = 0; - - RTPRINT(rtlpriv, FINIT, INIT_IQK, - ("IQK:Start!!!channel %d\n", rtlphy->current_channel)); - for (i = 0; i < 8; i++) { - result[0][i] = 0; - result[1][i] = 0; - result[2][i] = 0; - result[3][i] = 0; - } - final_candidate = 0xff; - patha_ok = false; - pathb_ok = false; - is12simular = false; - is23simular = false; - is13simular = false; - RTPRINT(rtlpriv, FINIT, INIT_IQK, - ("IQK !!!currentband %d\n", rtlhal->current_bandtype)); - rtl92d_acquire_cckandrw_pagea_ctl(hw, &flag); - for (i = 0; i < 3; i++) { - if (rtlhal->current_bandtype == BAND_ON_5G) { - _rtl92d_phy_iq_calibrate_5g_normal(hw, result, i); - } else if (rtlhal->current_bandtype == BAND_ON_2_4G) { - if (IS_92D_SINGLEPHY(rtlhal->version)) - _rtl92d_phy_iq_calibrate(hw, result, i, true); - else - _rtl92d_phy_iq_calibrate(hw, result, i, false); - } - if (i == 1) { - is12simular = _rtl92d_phy_simularity_compare(hw, result, - 0, 1); - if (is12simular) { - final_candidate = 0; - break; - } - } - if (i == 2) { - is13simular = _rtl92d_phy_simularity_compare(hw, result, - 0, 2); - if (is13simular) { - final_candidate = 0; - break; - } - is23simular = _rtl92d_phy_simularity_compare(hw, result, - 1, 2); - if (is23simular) { - final_candidate = 1; - } else { - for (i = 0; i < 8; i++) - regtmp += result[3][i]; - - if (regtmp != 0) - final_candidate = 3; - else - final_candidate = 0xFF; - } - } - } - rtl92d_release_cckandrw_pagea_ctl(hw, &flag); - for (i = 0; i < 4; i++) { - rege94 = result[i][0]; - rege9c = result[i][1]; - regea4 = result[i][2]; - regeac = result[i][3]; - regeb4 = result[i][4]; - regebc = result[i][5]; - regec4 = result[i][6]; - regecc = result[i][7]; - RTPRINT(rtlpriv, FINIT, INIT_IQK, - ("IQK: rege94=%lx rege9c=%lx regea4=%lx regeac=%lx " - "regeb4=%lx regebc=%lx regec4=%lx regecc=%lx\n ", - rege94, rege9c, regea4, regeac, regeb4, regebc, regec4, - regecc)); - } - if (final_candidate != 0xff) { - rtlphy->reg_e94 = rege94 = result[final_candidate][0]; - rtlphy->reg_e9c = rege9c = result[final_candidate][1]; - regea4 = result[final_candidate][2]; - regeac = result[final_candidate][3]; - rtlphy->reg_eb4 = regeb4 = result[final_candidate][4]; - rtlphy->reg_ebc = regebc = result[final_candidate][5]; - regec4 = result[final_candidate][6]; - regecc = result[final_candidate][7]; - RTPRINT(rtlpriv, FINIT, INIT_IQK, - ("IQK: final_candidate is %x\n", final_candidate)); - RTPRINT(rtlpriv, FINIT, INIT_IQK, - ("IQK: rege94=%lx rege9c=%lx regea4=%lx regeac=%lx " - "regeb4=%lx regebc=%lx regec4=%lx regecc=%lx\n ", - rege94, rege9c, regea4, regeac, regeb4, regebc, regec4, - regecc)); - patha_ok = pathb_ok = true; - } else { - rtlphy->reg_e94 = rtlphy->reg_eb4 = 0x100; /* X default value */ - rtlphy->reg_e9c = rtlphy->reg_ebc = 0x0; /* Y default value */ - } - if ((rege94 != 0) /*&&(regea4 != 0) */) - _rtl92d_phy_patha_fill_iqk_matrix(hw, patha_ok, result, - final_candidate, (regea4 == 0)); - if (IS_92D_SINGLEPHY(rtlhal->version)) { - if ((regeb4 != 0) /*&&(regec4 != 0) */) - _rtl92d_phy_pathb_fill_iqk_matrix(hw, pathb_ok, result, - final_candidate, (regec4 == 0)); - } - if (final_candidate != 0xFF) { - indexforchannel = rtl92d_get_rightchnlplace_for_iqk( - rtlphy->current_channel); - - for (i = 0; i < IQK_MATRIX_REG_NUM; i++) - rtlphy->iqk_matrix_regsetting[indexforchannel]. - value[0][i] = result[final_candidate][i]; - rtlphy->iqk_matrix_regsetting[indexforchannel].iqk_done = - true; - - RT_TRACE(rtlpriv, COMP_SCAN | COMP_MLME, DBG_LOUD, - ("\nIQK OK indexforchannel %d.\n", indexforchannel)); - } -} - -void rtl92d_phy_reload_iqk_setting(struct ieee80211_hw *hw, u8 channel) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_phy *rtlphy = &(rtlpriv->phy); - struct rtl_hal *rtlhal = &(rtlpriv->rtlhal); - u8 indexforchannel; - - RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, ("channel %d\n", channel)); - /*------Do IQK for normal chip and test chip 5G band------- */ - indexforchannel = rtl92d_get_rightchnlplace_for_iqk(channel); - RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, - ("indexforchannel %d done %d\n", indexforchannel, - rtlphy->iqk_matrix_regsetting[indexforchannel].iqk_done)); - if (0 && !rtlphy->iqk_matrix_regsetting[indexforchannel].iqk_done && - rtlphy->need_iqk) { - /* Re Do IQK. */ - RT_TRACE(rtlpriv, COMP_SCAN | COMP_INIT, DBG_LOUD, - ("Do IQK Matrix reg for channel:%d....\n", channel)); - rtl92d_phy_iq_calibrate(hw); - } else { - /* Just load the value. */ - /* 2G band just load once. */ - if (((!rtlhal->load_imrandiqk_setting_for2g) && - indexforchannel == 0) || indexforchannel > 0) { - RT_TRACE(rtlpriv, COMP_SCAN, DBG_LOUD, - ("Just Read IQK Matrix reg for channel:%d" - "....\n", channel)); - if ((rtlphy->iqk_matrix_regsetting[indexforchannel]. - value[0] != NULL) - /*&&(regea4 != 0) */) - _rtl92d_phy_patha_fill_iqk_matrix(hw, true, - rtlphy->iqk_matrix_regsetting[ - indexforchannel].value, 0, - (rtlphy->iqk_matrix_regsetting[ - indexforchannel].value[0][2] == 0)); - if (IS_92D_SINGLEPHY(rtlhal->version)) { - if ((rtlphy->iqk_matrix_regsetting[ - indexforchannel].value[0][4] != 0) - /*&&(regec4 != 0) */) - _rtl92d_phy_pathb_fill_iqk_matrix(hw, - true, - rtlphy->iqk_matrix_regsetting[ - indexforchannel].value, 0, - (rtlphy->iqk_matrix_regsetting[ - indexforchannel].value[0][6] - == 0)); - } - } - } - rtlphy->need_iqk = false; - RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, ("<====\n")); -} - -static u32 _rtl92d_phy_get_abs(u32 val1, u32 val2) -{ - u32 ret; - - if (val1 >= val2) - ret = val1 - val2; - else - ret = val2 - val1; - return ret; -} - -static bool _rtl92d_is_legal_5g_channel(struct ieee80211_hw *hw, u8 channel) -{ - - int i; - u8 channel_5g[45] = { - 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, - 60, 62, 64, 100, 102, 104, 106, 108, 110, 112, - 114, 116, 118, 120, 122, 124, 126, 128, 130, 132, - 134, 136, 138, 140, 149, 151, 153, 155, 157, 159, - 161, 163, 165 - }; - - for (i = 0; i < sizeof(channel_5g); i++) - if (channel == channel_5g[i]) - return true; - return false; -} - -static void _rtl92d_phy_calc_curvindex(struct ieee80211_hw *hw, - u32 *targetchnl, u32 * curvecount_val, - bool is5g, u32 *curveindex) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - u32 smallest_abs_val = 0xffffffff, u4tmp; - u8 i, j; - u8 chnl_num = is5g ? TARGET_CHNL_NUM_5G : TARGET_CHNL_NUM_2G; - - for (i = 0; i < chnl_num; i++) { - if (is5g && !_rtl92d_is_legal_5g_channel(hw, i + 1)) - continue; - curveindex[i] = 0; - for (j = 0; j < (CV_CURVE_CNT * 2); j++) { - u4tmp = _rtl92d_phy_get_abs(targetchnl[i], - curvecount_val[j]); - - if (u4tmp < smallest_abs_val) { - curveindex[i] = j; - smallest_abs_val = u4tmp; - } - } - smallest_abs_val = 0xffffffff; - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("curveindex[%d] = %x\n", i, - curveindex[i])); - } -} - -static void _rtl92d_phy_reload_lck_setting(struct ieee80211_hw *hw, - u8 channel) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - u8 erfpath = rtlpriv->rtlhal.current_bandtype == - BAND_ON_5G ? RF90_PATH_A : - IS_92D_SINGLEPHY(rtlpriv->rtlhal.version) ? - RF90_PATH_B : RF90_PATH_A; - u32 u4tmp = 0, u4regvalue = 0; - bool bneed_powerdown_radio = false; - - RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, ("path %d\n", erfpath)); - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("band type = %d\n", - rtlpriv->rtlhal.current_bandtype)); - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("channel = %d\n", channel)); - if (rtlpriv->rtlhal.current_bandtype == BAND_ON_5G) {/* Path-A for 5G */ - u4tmp = curveindex_5g[channel-1]; - RTPRINT(rtlpriv, FINIT, INIT_IQK, - ("ver 1 set RF-A, 5G, 0x28 = 0x%ulx !!\n", u4tmp)); - if (rtlpriv->rtlhal.macphymode == DUALMAC_DUALPHY && - rtlpriv->rtlhal.interfaceindex == 1) { - bneed_powerdown_radio = - rtl92d_phy_enable_anotherphy(hw, false); - rtlpriv->rtlhal.during_mac1init_radioa = true; - /* asume no this case */ - if (bneed_powerdown_radio) - _rtl92d_phy_enable_rf_env(hw, erfpath, - &u4regvalue); - } - rtl_set_rfreg(hw, erfpath, RF_SYN_G4, 0x3f800, u4tmp); - if (bneed_powerdown_radio) - _rtl92d_phy_restore_rf_env(hw, erfpath, &u4regvalue); - if (rtlpriv->rtlhal.during_mac1init_radioa) - rtl92d_phy_powerdown_anotherphy(hw, false); - } else if (rtlpriv->rtlhal.current_bandtype == BAND_ON_2_4G) { - u4tmp = curveindex_2g[channel-1]; - RTPRINT(rtlpriv, FINIT, INIT_IQK, - ("ver 3 set RF-B, 2G, 0x28 = 0x%ulx !!\n", u4tmp)); - if (rtlpriv->rtlhal.macphymode == DUALMAC_DUALPHY && - rtlpriv->rtlhal.interfaceindex == 0) { - bneed_powerdown_radio = - rtl92d_phy_enable_anotherphy(hw, true); - rtlpriv->rtlhal.during_mac0init_radiob = true; - if (bneed_powerdown_radio) - _rtl92d_phy_enable_rf_env(hw, erfpath, - &u4regvalue); - } - rtl_set_rfreg(hw, erfpath, RF_SYN_G4, 0x3f800, u4tmp); - RTPRINT(rtlpriv, FINIT, INIT_IQK, - ("ver 3 set RF-B, 2G, 0x28 = 0x%ulx !!\n", - rtl_get_rfreg(hw, erfpath, RF_SYN_G4, 0x3f800))); - if (bneed_powerdown_radio) - _rtl92d_phy_restore_rf_env(hw, erfpath, &u4regvalue); - if (rtlpriv->rtlhal.during_mac0init_radiob) - rtl92d_phy_powerdown_anotherphy(hw, true); - } - RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, ("<====\n")); -} - -static void _rtl92d_phy_lc_calibrate_sw(struct ieee80211_hw *hw, bool is2t) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_hal *rtlhal = &(rtlpriv->rtlhal); - struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); - u8 tmpreg, index, rf_mode[2]; - u8 path = is2t ? 2 : 1; - u8 i; - u32 u4tmp, offset; - u32 curvecount_val[CV_CURVE_CNT * 2] = {0}; - u16 timeout = 800, timecount = 0; - - /* Check continuous TX and Packet TX */ - tmpreg = rtl_read_byte(rtlpriv, 0xd03); - /* if Deal with contisuous TX case, disable all continuous TX */ - /* if Deal with Packet TX case, block all queues */ - if ((tmpreg & 0x70) != 0) - rtl_write_byte(rtlpriv, 0xd03, tmpreg & 0x8F); - else - rtl_write_byte(rtlpriv, REG_TXPAUSE, 0xFF); - rtl_set_bbreg(hw, RFPGA0_ANALOGPARAMETER4, 0xF00000, 0x0F); - for (index = 0; index < path; index++) { - /* 1. Read original RF mode */ - offset = index == 0 ? ROFDM0_XAAGCCORE1 : ROFDM0_XBAGCCORE1; - rf_mode[index] = rtl_read_byte(rtlpriv, offset); - /* 2. Set RF mode = standby mode */ - rtl_set_rfreg(hw, (enum radio_path)index, RF_AC, - BRFREGOFFSETMASK, 0x010000); - if (rtlpci->init_ready) { - /* switch CV-curve control by LC-calibration */ - rtl_set_rfreg(hw, (enum radio_path)index, RF_SYN_G7, - BIT(17), 0x0); - /* 4. Set LC calibration begin */ - rtl_set_rfreg(hw, (enum radio_path)index, RF_CHNLBW, - 0x08000, 0x01); - } - u4tmp = rtl_get_rfreg(hw, (enum radio_path)index, RF_SYN_G6, - BRFREGOFFSETMASK); - while ((!(u4tmp & BIT(11))) && timecount <= timeout) { - mdelay(50); - timecount += 50; - u4tmp = rtl_get_rfreg(hw, (enum radio_path)index, - RF_SYN_G6, BRFREGOFFSETMASK); - } - RTPRINT(rtlpriv, FINIT, INIT_IQK, - ("PHY_LCK finish delay for %d ms=2\n", timecount)); - u4tmp = rtl_get_rfreg(hw, index, RF_SYN_G4, BRFREGOFFSETMASK); - if (index == 0 && rtlhal->interfaceindex == 0) { - RTPRINT(rtlpriv, FINIT, INIT_IQK, - ("path-A / 5G LCK\n")); - } else { - RTPRINT(rtlpriv, FINIT, INIT_IQK, - ("path-B / 2.4G LCK\n")); - } - memset(&curvecount_val[0], 0, CV_CURVE_CNT * 2); - /* Set LC calibration off */ - rtl_set_rfreg(hw, (enum radio_path)index, RF_CHNLBW, - 0x08000, 0x0); - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("set RF 0x18[15] = 0\n")); - /* save Curve-counting number */ - for (i = 0; i < CV_CURVE_CNT; i++) { - u32 readval = 0, readval2 = 0; - rtl_set_rfreg(hw, (enum radio_path)index, 0x3F, - 0x7f, i); - - rtl_set_rfreg(hw, (enum radio_path)index, 0x4D, - BRFREGOFFSETMASK, 0x0); - readval = rtl_get_rfreg(hw, (enum radio_path)index, - 0x4F, BRFREGOFFSETMASK); - curvecount_val[2 * i + 1] = (readval & 0xfffe0) >> 5; - /* reg 0x4f [4:0] */ - /* reg 0x50 [19:10] */ - readval2 = rtl_get_rfreg(hw, (enum radio_path)index, - 0x50, 0xffc00); - curvecount_val[2 * i] = (((readval & 0x1F) << 10) | - readval2); - } - if (index == 0 && rtlhal->interfaceindex == 0) - _rtl92d_phy_calc_curvindex(hw, targetchnl_5g, - curvecount_val, - true, curveindex_5g); - else - _rtl92d_phy_calc_curvindex(hw, targetchnl_2g, - curvecount_val, - false, curveindex_2g); - /* switch CV-curve control mode */ - rtl_set_rfreg(hw, (enum radio_path)index, RF_SYN_G7, - BIT(17), 0x1); - } - - /* Restore original situation */ - for (index = 0; index < path; index++) { - offset = index == 0 ? ROFDM0_XAAGCCORE1 : ROFDM0_XBAGCCORE1; - rtl_write_byte(rtlpriv, offset, 0x50); - rtl_write_byte(rtlpriv, offset, rf_mode[index]); - } - if ((tmpreg & 0x70) != 0) - rtl_write_byte(rtlpriv, 0xd03, tmpreg); - else /*Deal with Packet TX case */ - rtl_write_byte(rtlpriv, REG_TXPAUSE, 0x00); - rtl_set_bbreg(hw, RFPGA0_ANALOGPARAMETER4, 0xF00000, 0x00); - _rtl92d_phy_reload_lck_setting(hw, rtlpriv->phy.current_channel); -} - -static void _rtl92d_phy_lc_calibrate(struct ieee80211_hw *hw, bool is2t) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("cosa PHY_LCK ver=2\n")); - _rtl92d_phy_lc_calibrate_sw(hw, is2t); -} - -void rtl92d_phy_lc_calibrate(struct ieee80211_hw *hw) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_phy *rtlphy = &(rtlpriv->phy); - struct rtl_hal *rtlhal = &(rtlpriv->rtlhal); - u32 timeout = 2000, timecount = 0; - - while (rtlpriv->mac80211.act_scanning && timecount < timeout) { - udelay(50); - timecount += 50; - } - - rtlphy->lck_inprogress = true; - RTPRINT(rtlpriv, FINIT, INIT_IQK, - ("LCK:Start!!! currentband %x delay %d ms\n", - rtlhal->current_bandtype, timecount)); - if (IS_92D_SINGLEPHY(rtlhal->version)) { - _rtl92d_phy_lc_calibrate(hw, true); - } else { - /* For 1T1R */ - _rtl92d_phy_lc_calibrate(hw, false); - } - rtlphy->lck_inprogress = false; - RTPRINT(rtlpriv, FINIT, INIT_IQK, ("LCK:Finish!!!\n")); -} - -void rtl92d_phy_ap_calibrate(struct ieee80211_hw *hw, char delta) -{ - return; -} - -static bool _rtl92d_phy_set_sw_chnl_cmdarray(struct swchnlcmd *cmdtable, - u32 cmdtableidx, u32 cmdtablesz, enum swchnlcmd_id cmdid, - u32 para1, u32 para2, u32 msdelay) -{ - struct swchnlcmd *pcmd; - - if (cmdtable == NULL) { - RT_ASSERT(false, ("cmdtable cannot be NULL.\n")); - return false; - } - if (cmdtableidx >= cmdtablesz) - return false; - - pcmd = cmdtable + cmdtableidx; - pcmd->cmdid = cmdid; - pcmd->para1 = para1; - pcmd->para2 = para2; - pcmd->msdelay = msdelay; - return true; -} - -void rtl92d_phy_reset_iqk_result(struct ieee80211_hw *hw) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_phy *rtlphy = &(rtlpriv->phy); - u8 i; - - RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, - ("settings regs %d default regs %d\n", - (int)(sizeof(rtlphy->iqk_matrix_regsetting) / - sizeof(struct iqk_matrix_regs)), - IQK_MATRIX_REG_NUM)); - /* 0xe94, 0xe9c, 0xea4, 0xeac, 0xeb4, 0xebc, 0xec4, 0xecc */ - for (i = 0; i < IQK_MATRIX_SETTINGS_NUM; i++) { - rtlphy->iqk_matrix_regsetting[i].value[0][0] = 0x100; - rtlphy->iqk_matrix_regsetting[i].value[0][2] = 0x100; - rtlphy->iqk_matrix_regsetting[i].value[0][4] = 0x100; - rtlphy->iqk_matrix_regsetting[i].value[0][6] = 0x100; - rtlphy->iqk_matrix_regsetting[i].value[0][1] = 0x0; - rtlphy->iqk_matrix_regsetting[i].value[0][3] = 0x0; - rtlphy->iqk_matrix_regsetting[i].value[0][5] = 0x0; - rtlphy->iqk_matrix_regsetting[i].value[0][7] = 0x0; - rtlphy->iqk_matrix_regsetting[i].iqk_done = false; - } -} - -static bool _rtl92d_phy_sw_chnl_step_by_step(struct ieee80211_hw *hw, - u8 channel, u8 *stage, u8 *step, - u32 *delay) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_phy *rtlphy = &(rtlpriv->phy); - struct swchnlcmd precommoncmd[MAX_PRECMD_CNT]; - u32 precommoncmdcnt; - struct swchnlcmd postcommoncmd[MAX_POSTCMD_CNT]; - u32 postcommoncmdcnt; - struct swchnlcmd rfdependcmd[MAX_RFDEPENDCMD_CNT]; - u32 rfdependcmdcnt; - struct swchnlcmd *currentcmd = NULL; - u8 rfpath; - u8 num_total_rfpath = rtlphy->num_total_rfpath; - - precommoncmdcnt = 0; - _rtl92d_phy_set_sw_chnl_cmdarray(precommoncmd, precommoncmdcnt++, - MAX_PRECMD_CNT, - CMDID_SET_TXPOWEROWER_LEVEL, 0, 0, 0); - _rtl92d_phy_set_sw_chnl_cmdarray(precommoncmd, precommoncmdcnt++, - MAX_PRECMD_CNT, CMDID_END, 0, 0, 0); - postcommoncmdcnt = 0; - _rtl92d_phy_set_sw_chnl_cmdarray(postcommoncmd, postcommoncmdcnt++, - MAX_POSTCMD_CNT, CMDID_END, 0, 0, 0); - rfdependcmdcnt = 0; - _rtl92d_phy_set_sw_chnl_cmdarray(rfdependcmd, rfdependcmdcnt++, - MAX_RFDEPENDCMD_CNT, CMDID_RF_WRITEREG, - RF_CHNLBW, channel, 0); - _rtl92d_phy_set_sw_chnl_cmdarray(rfdependcmd, rfdependcmdcnt++, - MAX_RFDEPENDCMD_CNT, CMDID_END, - 0, 0, 0); - - do { - switch (*stage) { - case 0: - currentcmd = &precommoncmd[*step]; - break; - case 1: - currentcmd = &rfdependcmd[*step]; - break; - case 2: - currentcmd = &postcommoncmd[*step]; - break; - } - if (currentcmd->cmdid == CMDID_END) { - if ((*stage) == 2) { - return true; - } else { - (*stage)++; - (*step) = 0; - continue; - } - } - switch (currentcmd->cmdid) { - case CMDID_SET_TXPOWEROWER_LEVEL: - rtl92d_phy_set_txpower_level(hw, channel); - break; - case CMDID_WRITEPORT_ULONG: - rtl_write_dword(rtlpriv, currentcmd->para1, - currentcmd->para2); - break; - case CMDID_WRITEPORT_USHORT: - rtl_write_word(rtlpriv, currentcmd->para1, - (u16)currentcmd->para2); - break; - case CMDID_WRITEPORT_UCHAR: - rtl_write_byte(rtlpriv, currentcmd->para1, - (u8)currentcmd->para2); - break; - case CMDID_RF_WRITEREG: - for (rfpath = 0; rfpath < num_total_rfpath; rfpath++) { - rtlphy->rfreg_chnlval[rfpath] = - ((rtlphy->rfreg_chnlval[rfpath] & - 0xffffff00) | currentcmd->para2); - if (rtlpriv->rtlhal.current_bandtype == - BAND_ON_5G) { - if (currentcmd->para2 > 99) - rtlphy->rfreg_chnlval[rfpath] = - rtlphy->rfreg_chnlval - [rfpath] | (BIT(18)); - else - rtlphy->rfreg_chnlval[rfpath] = - rtlphy->rfreg_chnlval - [rfpath] & (~BIT(18)); - rtlphy->rfreg_chnlval[rfpath] |= - (BIT(16) | BIT(8)); - } else { - rtlphy->rfreg_chnlval[rfpath] &= - ~(BIT(8) | BIT(16) | BIT(18)); - } - rtl_set_rfreg(hw, (enum radio_path)rfpath, - currentcmd->para1, - BRFREGOFFSETMASK, - rtlphy->rfreg_chnlval[rfpath]); - _rtl92d_phy_reload_imr_setting(hw, channel, - rfpath); - } - _rtl92d_phy_switch_rf_setting(hw, channel); - /* do IQK when all parameters are ready */ - rtl92d_phy_reload_iqk_setting(hw, channel); - break; - default: - RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("switch case not process\n")); - break; - } - break; - } while (true); - (*delay) = currentcmd->msdelay; - (*step)++; - return false; -} - -u8 rtl92d_phy_sw_chnl(struct ieee80211_hw *hw) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_phy *rtlphy = &(rtlpriv->phy); - struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); - u32 delay; - u32 timeout = 1000, timecount = 0; - u8 channel = rtlphy->current_channel; - u32 ret_value; - - if (rtlphy->sw_chnl_inprogress) - return 0; - if (rtlphy->set_bwmode_inprogress) - return 0; - - if ((is_hal_stop(rtlhal)) || (RT_CANNOT_IO(hw))) { - RT_TRACE(rtlpriv, COMP_CHAN, DBG_LOUD, - ("sw_chnl_inprogress false driver sleep or unload\n")); - return 0; - } - while (rtlphy->lck_inprogress && timecount < timeout) { - mdelay(50); - timecount += 50; - } - if (rtlhal->macphymode == SINGLEMAC_SINGLEPHY && - rtlhal->bandset == BAND_ON_BOTH) { - ret_value = rtl_get_bbreg(hw, RFPGA0_XAB_RFPARAMETER, - BMASKDWORD); - if (rtlphy->current_channel > 14 && !(ret_value & BIT(0))) - rtl92d_phy_switch_wirelessband(hw, BAND_ON_5G); - else if (rtlphy->current_channel <= 14 && (ret_value & BIT(0))) - rtl92d_phy_switch_wirelessband(hw, BAND_ON_2_4G); - } - switch (rtlhal->current_bandtype) { - case BAND_ON_5G: - /* Get first channel error when change between - * 5G and 2.4G band. */ - if (channel <= 14) - return 0; - RT_ASSERT((channel > 14), ("5G but channel<=14")); - break; - case BAND_ON_2_4G: - /* Get first channel error when change between - * 5G and 2.4G band. */ - if (channel > 14) - return 0; - RT_ASSERT((channel <= 14), ("2G but channel>14")); - break; - default: - RT_ASSERT(false, - ("Invalid WirelessMode(%#x)!!\n", - rtlpriv->mac80211.mode)); - break; - } - rtlphy->sw_chnl_inprogress = true; - if (channel == 0) - channel = 1; - rtlphy->sw_chnl_stage = 0; - rtlphy->sw_chnl_step = 0; - RT_TRACE(rtlpriv, COMP_SCAN, DBG_TRACE, - ("switch to channel%d\n", rtlphy->current_channel)); - - do { - if (!rtlphy->sw_chnl_inprogress) - break; - if (!_rtl92d_phy_sw_chnl_step_by_step(hw, - rtlphy->current_channel, - &rtlphy->sw_chnl_stage, &rtlphy->sw_chnl_step, &delay)) { - if (delay > 0) - mdelay(delay); - else - continue; - } else { - rtlphy->sw_chnl_inprogress = false; - } - break; - } while (true); - RT_TRACE(rtlpriv, COMP_SCAN, DBG_TRACE, ("<==\n")); - rtlphy->sw_chnl_inprogress = false; - return 1; -} - -static void rtl92d_phy_set_io(struct ieee80211_hw *hw) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_phy *rtlphy = &(rtlpriv->phy); - - RT_TRACE(rtlpriv, COMP_CMD, DBG_TRACE, - ("--->Cmd(%#x), set_io_inprogress(%d)\n", - rtlphy->current_io_type, rtlphy->set_io_inprogress)); - switch (rtlphy->current_io_type) { - case IO_CMD_RESUME_DM_BY_SCAN: - de_digtable.cur_igvalue = rtlphy->initgain_backup.xaagccore1; - rtl92d_dm_write_dig(hw); - rtl92d_phy_set_txpower_level(hw, rtlphy->current_channel); - break; - case IO_CMD_PAUSE_DM_BY_SCAN: - rtlphy->initgain_backup.xaagccore1 = de_digtable.cur_igvalue; - de_digtable.cur_igvalue = 0x17; - rtl92d_dm_write_dig(hw); - break; - default: - RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("switch case not process\n")); - break; - } - rtlphy->set_io_inprogress = false; - RT_TRACE(rtlpriv, COMP_CMD, DBG_TRACE, - ("<---(%#x)\n", rtlphy->current_io_type)); -} - -bool rtl92d_phy_set_io_cmd(struct ieee80211_hw *hw, enum io_type iotype) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_phy *rtlphy = &(rtlpriv->phy); - bool postprocessing = false; - - RT_TRACE(rtlpriv, COMP_CMD, DBG_TRACE, - ("-->IO Cmd(%#x), set_io_inprogress(%d)\n", - iotype, rtlphy->set_io_inprogress)); - do { - switch (iotype) { - case IO_CMD_RESUME_DM_BY_SCAN: - RT_TRACE(rtlpriv, COMP_CMD, DBG_TRACE, - ("[IO CMD] Resume DM after scan.\n")); - postprocessing = true; - break; - case IO_CMD_PAUSE_DM_BY_SCAN: - RT_TRACE(rtlpriv, COMP_CMD, DBG_TRACE, - ("[IO CMD] Pause DM before scan.\n")); - postprocessing = true; - break; - default: - RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("switch case not process\n")); - break; - } - } while (false); - if (postprocessing && !rtlphy->set_io_inprogress) { - rtlphy->set_io_inprogress = true; - rtlphy->current_io_type = iotype; - } else { - return false; - } - rtl92d_phy_set_io(hw); - RT_TRACE(rtlpriv, COMP_CMD, DBG_TRACE, ("<--IO Type(%#x)\n", iotype)); - return true; -} - -static void _rtl92d_phy_set_rfon(struct ieee80211_hw *hw) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - - /* a. SYS_CLKR 0x08[11] = 1 restore MAC clock */ - /* b. SPS_CTRL 0x11[7:0] = 0x2b */ - if (rtlpriv->rtlhal.macphymode == SINGLEMAC_SINGLEPHY) - rtl_write_byte(rtlpriv, REG_SPS0_CTRL, 0x2b); - /* c. For PCIE: SYS_FUNC_EN 0x02[7:0] = 0xE3 enable BB TRX function */ - rtl_write_byte(rtlpriv, REG_SYS_FUNC_EN, 0xE3); - /* RF_ON_EXCEP(d~g): */ - /* d. APSD_CTRL 0x600[7:0] = 0x00 */ - rtl_write_byte(rtlpriv, REG_APSD_CTRL, 0x00); - /* e. SYS_FUNC_EN 0x02[7:0] = 0xE2 reset BB TRX function again */ - /* f. SYS_FUNC_EN 0x02[7:0] = 0xE3 enable BB TRX function*/ - rtl_write_byte(rtlpriv, REG_SYS_FUNC_EN, 0xE2); - rtl_write_byte(rtlpriv, REG_SYS_FUNC_EN, 0xE3); - /* g. txpause 0x522[7:0] = 0x00 enable mac tx queue */ - rtl_write_byte(rtlpriv, REG_TXPAUSE, 0x00); -} - -static void _rtl92d_phy_set_rfsleep(struct ieee80211_hw *hw) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - u32 u4btmp; - u8 delay = 5; - - /* a. TXPAUSE 0x522[7:0] = 0xFF Pause MAC TX queue */ - rtl_write_byte(rtlpriv, REG_TXPAUSE, 0xFF); - /* b. RF path 0 offset 0x00 = 0x00 disable RF */ - rtl_set_rfreg(hw, RF90_PATH_A, 0x00, BRFREGOFFSETMASK, 0x00); - /* c. APSD_CTRL 0x600[7:0] = 0x40 */ - rtl_write_byte(rtlpriv, REG_APSD_CTRL, 0x40); - /* d. APSD_CTRL 0x600[7:0] = 0x00 - * APSD_CTRL 0x600[7:0] = 0x00 - * RF path 0 offset 0x00 = 0x00 - * APSD_CTRL 0x600[7:0] = 0x40 - * */ - u4btmp = rtl_get_rfreg(hw, RF90_PATH_A, 0, BRFREGOFFSETMASK); - while (u4btmp != 0 && delay > 0) { - rtl_write_byte(rtlpriv, REG_APSD_CTRL, 0x0); - rtl_set_rfreg(hw, RF90_PATH_A, 0x00, BRFREGOFFSETMASK, 0x00); - rtl_write_byte(rtlpriv, REG_APSD_CTRL, 0x40); - u4btmp = rtl_get_rfreg(hw, RF90_PATH_A, 0, BRFREGOFFSETMASK); - delay--; - } - if (delay == 0) { - /* Jump out the LPS turn off sequence to RF_ON_EXCEP */ - rtl_write_byte(rtlpriv, REG_APSD_CTRL, 0x00); - - rtl_write_byte(rtlpriv, REG_SYS_FUNC_EN, 0xE2); - rtl_write_byte(rtlpriv, REG_SYS_FUNC_EN, 0xE3); - rtl_write_byte(rtlpriv, REG_TXPAUSE, 0x00); - RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, - ("Fail !!! Switch RF timeout.\n")); - return; - } - /* e. For PCIE: SYS_FUNC_EN 0x02[7:0] = 0xE2 reset BB TRX function */ - rtl_write_byte(rtlpriv, REG_SYS_FUNC_EN, 0xE2); - /* f. SPS_CTRL 0x11[7:0] = 0x22 */ - if (rtlpriv->rtlhal.macphymode == SINGLEMAC_SINGLEPHY) - rtl_write_byte(rtlpriv, REG_SPS0_CTRL, 0x22); - /* g. SYS_CLKR 0x08[11] = 0 gated MAC clock */ -} - -bool rtl92d_phy_set_rf_power_state(struct ieee80211_hw *hw, - enum rf_pwrstate rfpwr_state) -{ - - bool bresult = true; - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_pci_priv *pcipriv = rtl_pcipriv(hw); - struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); - struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); - struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); - u8 i, queue_id; - struct rtl8192_tx_ring *ring = NULL; - - if (rfpwr_state == ppsc->rfpwr_state) - return false; - switch (rfpwr_state) { - case ERFON: - if ((ppsc->rfpwr_state == ERFOFF) && - RT_IN_PS_LEVEL(ppsc, RT_RF_OFF_LEVL_HALT_NIC)) { - bool rtstatus; - u32 InitializeCount = 0; - do { - InitializeCount++; - RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG, - ("IPS Set eRf nic enable\n")); - rtstatus = rtl_ps_enable_nic(hw); - } while ((rtstatus != true) && - (InitializeCount < 10)); - - RT_CLEAR_PS_LEVEL(ppsc, - RT_RF_OFF_LEVL_HALT_NIC); - } else { - RT_TRACE(rtlpriv, COMP_POWER, DBG_DMESG, - ("awake, sleeped:%d ms state_" - "inap:%x\n", - jiffies_to_msecs(jiffies - - ppsc->last_sleep_jiffies), - rtlpriv->psc.state_inap)); - ppsc->last_awake_jiffies = jiffies; - _rtl92d_phy_set_rfon(hw); - } - - if (mac->link_state == MAC80211_LINKED) - rtlpriv->cfg->ops->led_control(hw, - LED_CTL_LINK); - else - rtlpriv->cfg->ops->led_control(hw, - LED_CTL_NO_LINK); - break; - case ERFOFF: - if (ppsc->reg_rfps_level & RT_RF_OFF_LEVL_HALT_NIC) { - RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG, - ("IPS Set eRf nic disable\n")); - rtl_ps_disable_nic(hw); - RT_SET_PS_LEVEL(ppsc, RT_RF_OFF_LEVL_HALT_NIC); - } else { - if (ppsc->rfoff_reason == RF_CHANGE_BY_IPS) - rtlpriv->cfg->ops->led_control(hw, - LED_CTL_NO_LINK); - else - rtlpriv->cfg->ops->led_control(hw, - LED_CTL_POWER_OFF); - } - break; - case ERFSLEEP: - if (ppsc->rfpwr_state == ERFOFF) - break; - - for (queue_id = 0, i = 0; - queue_id < RTL_PCI_MAX_TX_QUEUE_COUNT;) { - ring = &pcipriv->dev.tx_ring[queue_id]; - if (skb_queue_len(&ring->queue) == 0 || - queue_id == BEACON_QUEUE) { - queue_id++; - continue; - } else if (rtlpci->pdev->current_state != PCI_D0) { - RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, - ("eRf Off/Sleep: %d times TcbBusyQueu" - "e[%d] !=0 but lower power state!\n", - (i + 1), queue_id)); - break; - } else { - RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, - ("eRf Off/Sleep: %d times TcbBusyQueu" - "e[%d] =%d " - "before doze!\n", (i + 1), queue_id, - skb_queue_len(&ring->queue))); - udelay(10); - i++; - } - - if (i >= MAX_DOZE_WAITING_TIMES_9x) { - RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, - ("\nERFOFF: %d times TcbBusyQueue[%d] " - "= %d !\n", - MAX_DOZE_WAITING_TIMES_9x, queue_id, - skb_queue_len(&ring->queue))); - break; - } - } - RT_TRACE(rtlpriv, COMP_POWER, DBG_DMESG, - ("Set rfsleep awaked:%d ms\n", - jiffies_to_msecs(jiffies - ppsc->last_awake_jiffies))); - RT_TRACE(rtlpriv, COMP_POWER, DBG_DMESG, ("sleep awaked:%d ms " - "state_inap:%x\n", jiffies_to_msecs(jiffies - - ppsc->last_awake_jiffies), rtlpriv->psc.state_inap)); - ppsc->last_sleep_jiffies = jiffies; - _rtl92d_phy_set_rfsleep(hw); - break; - default: - RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("switch case not process\n")); - bresult = false; - break; - } - if (bresult) - ppsc->rfpwr_state = rfpwr_state; - return bresult; -} - -void rtl92d_phy_config_macphymode(struct ieee80211_hw *hw) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); - u8 offset = REG_MAC_PHY_CTRL_NORMAL; - - switch (rtlhal->macphymode) { - case DUALMAC_DUALPHY: - RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, - ("MacPhyMode: DUALMAC_DUALPHY\n")); - rtl_write_byte(rtlpriv, offset, 0xF3); - break; - case SINGLEMAC_SINGLEPHY: - RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, - ("MacPhyMode: SINGLEMAC_SINGLEPHY\n")); - rtl_write_byte(rtlpriv, offset, 0xF4); - break; - case DUALMAC_SINGLEPHY: - RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, - ("MacPhyMode: DUALMAC_SINGLEPHY\n")); - rtl_write_byte(rtlpriv, offset, 0xF1); - break; - } -} - -void rtl92d_phy_config_macphymode_info(struct ieee80211_hw *hw) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); - struct rtl_phy *rtlphy = &(rtlpriv->phy); - - switch (rtlhal->macphymode) { - case DUALMAC_SINGLEPHY: - rtlphy->rf_type = RF_2T2R; - rtlhal->version |= CHIP_92D_SINGLEPHY; - rtlhal->bandset = BAND_ON_BOTH; - rtlhal->current_bandtype = BAND_ON_2_4G; - break; - - case SINGLEMAC_SINGLEPHY: - rtlphy->rf_type = RF_2T2R; - rtlhal->version |= CHIP_92D_SINGLEPHY; - rtlhal->bandset = BAND_ON_BOTH; - rtlhal->current_bandtype = BAND_ON_2_4G; - break; - - case DUALMAC_DUALPHY: - rtlphy->rf_type = RF_1T1R; - rtlhal->version &= (~CHIP_92D_SINGLEPHY); - /* Now we let MAC0 run on 5G band. */ - if (rtlhal->interfaceindex == 0) { - rtlhal->bandset = BAND_ON_5G; - rtlhal->current_bandtype = BAND_ON_5G; - } else { - rtlhal->bandset = BAND_ON_2_4G; - rtlhal->current_bandtype = BAND_ON_2_4G; - } - break; - default: - break; - } -} - -u8 rtl92d_get_chnlgroup_fromarray(u8 chnl) -{ - u8 group; - u8 channel_info[59] = { - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, - 58, 60, 62, 64, 100, 102, 104, 106, 108, - 110, 112, 114, 116, 118, 120, 122, 124, - 126, 128, 130, 132, 134, 136, 138, 140, - 149, 151, 153, 155, 157, 159, 161, 163, - 165 - }; - - if (channel_info[chnl] <= 3) - group = 0; - else if (channel_info[chnl] <= 9) - group = 1; - else if (channel_info[chnl] <= 14) - group = 2; - else if (channel_info[chnl] <= 44) - group = 3; - else if (channel_info[chnl] <= 54) - group = 4; - else if (channel_info[chnl] <= 64) - group = 5; - else if (channel_info[chnl] <= 112) - group = 6; - else if (channel_info[chnl] <= 126) - group = 7; - else if (channel_info[chnl] <= 140) - group = 8; - else if (channel_info[chnl] <= 153) - group = 9; - else if (channel_info[chnl] <= 159) - group = 10; - else - group = 11; - return group; -} - -void rtl92d_phy_set_poweron(struct ieee80211_hw *hw) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); - unsigned long flags; - u8 value8; - u16 i; - u32 mac_reg = (rtlhal->interfaceindex == 0 ? REG_MAC0 : REG_MAC1); - - /* notice fw know band status 0x81[1]/0x53[1] = 0: 5G, 1: 2G */ - if (rtlhal->current_bandtype == BAND_ON_2_4G) { - value8 = rtl_read_byte(rtlpriv, mac_reg); - value8 |= BIT(1); - rtl_write_byte(rtlpriv, mac_reg, value8); - } else { - value8 = rtl_read_byte(rtlpriv, mac_reg); - value8 &= (~BIT(1)); - rtl_write_byte(rtlpriv, mac_reg, value8); - } - - if (rtlhal->macphymode == SINGLEMAC_SINGLEPHY) { - value8 = rtl_read_byte(rtlpriv, REG_MAC0); - rtl_write_byte(rtlpriv, REG_MAC0, value8 | MAC0_ON); - } else { - spin_lock_irqsave(&globalmutex_power, flags); - if (rtlhal->interfaceindex == 0) { - value8 = rtl_read_byte(rtlpriv, REG_MAC0); - rtl_write_byte(rtlpriv, REG_MAC0, value8 | MAC0_ON); - } else { - value8 = rtl_read_byte(rtlpriv, REG_MAC1); - rtl_write_byte(rtlpriv, REG_MAC1, value8 | MAC1_ON); - } - value8 = rtl_read_byte(rtlpriv, REG_POWER_OFF_IN_PROCESS); - spin_unlock_irqrestore(&globalmutex_power, flags); - for (i = 0; i < 200; i++) { - if ((value8 & BIT(7)) == 0) { - break; - } else { - udelay(500); - spin_lock_irqsave(&globalmutex_power, flags); - value8 = rtl_read_byte(rtlpriv, - REG_POWER_OFF_IN_PROCESS); - spin_unlock_irqrestore(&globalmutex_power, - flags); - } - } - if (i == 200) - RT_ASSERT(false, ("Another mac power off over time\n")); - } -} - -void rtl92d_phy_config_maccoexist_rfpage(struct ieee80211_hw *hw) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - - switch (rtlpriv->rtlhal.macphymode) { - case DUALMAC_DUALPHY: - rtl_write_byte(rtlpriv, REG_DMC, 0x0); - rtl_write_byte(rtlpriv, REG_RX_PKT_LIMIT, 0x08); - rtl_write_word(rtlpriv, REG_TRXFF_BNDY + 2, 0x13ff); - break; - case DUALMAC_SINGLEPHY: - rtl_write_byte(rtlpriv, REG_DMC, 0xf8); - rtl_write_byte(rtlpriv, REG_RX_PKT_LIMIT, 0x08); - rtl_write_word(rtlpriv, REG_TRXFF_BNDY + 2, 0x13ff); - break; - case SINGLEMAC_SINGLEPHY: - rtl_write_byte(rtlpriv, REG_DMC, 0x0); - rtl_write_byte(rtlpriv, REG_RX_PKT_LIMIT, 0x10); - rtl_write_word(rtlpriv, (REG_TRXFF_BNDY + 2), 0x27FF); - break; - default: - break; - } -} - -void rtl92d_update_bbrf_configuration(struct ieee80211_hw *hw) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); - struct rtl_phy *rtlphy = &(rtlpriv->phy); - struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw)); - u8 rfpath, i; - - RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, ("==>\n")); - /* r_select_5G for path_A/B 0 for 2.4G, 1 for 5G */ - if (rtlhal->current_bandtype == BAND_ON_2_4G) { - /* r_select_5G for path_A/B,0x878 */ - rtl_set_bbreg(hw, RFPGA0_XAB_RFPARAMETER, BIT(0), 0x0); - rtl_set_bbreg(hw, RFPGA0_XAB_RFPARAMETER, BIT(15), 0x0); - if (rtlhal->macphymode != DUALMAC_DUALPHY) { - rtl_set_bbreg(hw, RFPGA0_XAB_RFPARAMETER, BIT(16), 0x0); - rtl_set_bbreg(hw, RFPGA0_XAB_RFPARAMETER, BIT(31), 0x0); - } - /* rssi_table_select:index 0 for 2.4G.1~3 for 5G,0xc78 */ - rtl_set_bbreg(hw, ROFDM0_AGCRSSITABLE, BIT(6) | BIT(7), 0x0); - /* fc_area 0xd2c */ - rtl_set_bbreg(hw, ROFDM1_CFOTRACKING, BIT(14) | BIT(13), 0x0); - /* 5G LAN ON */ - rtl_set_bbreg(hw, 0xB30, 0x00F00000, 0xa); - /* TX BB gain shift*1,Just for testchip,0xc80,0xc88 */ - rtl_set_bbreg(hw, ROFDM0_XATxIQIMBALANCE, BMASKDWORD, - 0x40000100); - rtl_set_bbreg(hw, ROFDM0_XBTxIQIMBALANCE, BMASKDWORD, - 0x40000100); - if (rtlhal->macphymode == DUALMAC_DUALPHY) { - rtl_set_bbreg(hw, RFPGA0_XAB_RFINTERFACESW, - BIT(10) | BIT(6) | BIT(5), - ((rtlefuse->eeprom_c9 & BIT(3)) >> 3) | - (rtlefuse->eeprom_c9 & BIT(1)) | - ((rtlefuse->eeprom_cc & BIT(1)) << 4)); - rtl_set_bbreg(hw, RFPGA0_XA_RFINTERFACEOE, - BIT(10) | BIT(6) | BIT(5), - ((rtlefuse->eeprom_c9 & BIT(2)) >> 2) | - ((rtlefuse->eeprom_c9 & BIT(0)) << 1) | - ((rtlefuse->eeprom_cc & BIT(0)) << 5)); - rtl_set_bbreg(hw, RFPGA0_XAB_RFPARAMETER, BIT(15), 0); - } else { - rtl_set_bbreg(hw, RFPGA0_XAB_RFINTERFACESW, - BIT(26) | BIT(22) | BIT(21) | BIT(10) | - BIT(6) | BIT(5), - ((rtlefuse->eeprom_c9 & BIT(3)) >> 3) | - (rtlefuse->eeprom_c9 & BIT(1)) | - ((rtlefuse->eeprom_cc & BIT(1)) << 4) | - ((rtlefuse->eeprom_c9 & BIT(7)) << 9) | - ((rtlefuse->eeprom_c9 & BIT(5)) << 12) | - ((rtlefuse->eeprom_cc & BIT(3)) << 18)); - rtl_set_bbreg(hw, RFPGA0_XA_RFINTERFACEOE, - BIT(10) | BIT(6) | BIT(5), - ((rtlefuse->eeprom_c9 & BIT(2)) >> 2) | - ((rtlefuse->eeprom_c9 & BIT(0)) << 1) | - ((rtlefuse->eeprom_cc & BIT(0)) << 5)); - rtl_set_bbreg(hw, RFPGA0_XB_RFINTERFACEOE, - BIT(10) | BIT(6) | BIT(5), - ((rtlefuse->eeprom_c9 & BIT(6)) >> 6) | - ((rtlefuse->eeprom_c9 & BIT(4)) >> 3) | - ((rtlefuse->eeprom_cc & BIT(2)) << 3)); - rtl_set_bbreg(hw, RFPGA0_XAB_RFPARAMETER, - BIT(31) | BIT(15), 0); - } - /* 1.5V_LDO */ - } else { - /* r_select_5G for path_A/B */ - rtl_set_bbreg(hw, RFPGA0_XAB_RFPARAMETER, BIT(0), 0x1); - rtl_set_bbreg(hw, RFPGA0_XAB_RFPARAMETER, BIT(15), 0x1); - if (rtlhal->macphymode != DUALMAC_DUALPHY) { - rtl_set_bbreg(hw, RFPGA0_XAB_RFPARAMETER, BIT(16), 0x1); - rtl_set_bbreg(hw, RFPGA0_XAB_RFPARAMETER, BIT(31), 0x1); - } - /* rssi_table_select:index 0 for 2.4G.1~3 for 5G */ - rtl_set_bbreg(hw, ROFDM0_AGCRSSITABLE, BIT(6) | BIT(7), 0x1); - /* fc_area */ - rtl_set_bbreg(hw, ROFDM1_CFOTRACKING, BIT(14) | BIT(13), 0x1); - /* 5G LAN ON */ - rtl_set_bbreg(hw, 0xB30, 0x00F00000, 0x0); - /* TX BB gain shift,Just for testchip,0xc80,0xc88 */ - if (rtlefuse->internal_pa_5g[0]) - rtl_set_bbreg(hw, ROFDM0_XATxIQIMBALANCE, BMASKDWORD, - 0x2d4000b5); - else - rtl_set_bbreg(hw, ROFDM0_XATxIQIMBALANCE, BMASKDWORD, - 0x20000080); - if (rtlefuse->internal_pa_5g[1]) - rtl_set_bbreg(hw, ROFDM0_XBTxIQIMBALANCE, BMASKDWORD, - 0x2d4000b5); - else - rtl_set_bbreg(hw, ROFDM0_XBTxIQIMBALANCE, BMASKDWORD, - 0x20000080); - if (rtlhal->macphymode == DUALMAC_DUALPHY) { - rtl_set_bbreg(hw, RFPGA0_XAB_RFINTERFACESW, - BIT(10) | BIT(6) | BIT(5), - (rtlefuse->eeprom_cc & BIT(5))); - rtl_set_bbreg(hw, RFPGA0_XA_RFINTERFACEOE, BIT(10), - ((rtlefuse->eeprom_cc & BIT(4)) >> 4)); - rtl_set_bbreg(hw, RFPGA0_XAB_RFPARAMETER, BIT(15), - (rtlefuse->eeprom_cc & BIT(4)) >> 4); - } else { - rtl_set_bbreg(hw, RFPGA0_XAB_RFINTERFACESW, - BIT(26) | BIT(22) | BIT(21) | BIT(10) | - BIT(6) | BIT(5), - (rtlefuse->eeprom_cc & BIT(5)) | - ((rtlefuse->eeprom_cc & BIT(7)) << 14)); - rtl_set_bbreg(hw, RFPGA0_XA_RFINTERFACEOE, BIT(10), - ((rtlefuse->eeprom_cc & BIT(4)) >> 4)); - rtl_set_bbreg(hw, RFPGA0_XB_RFINTERFACEOE, BIT(10), - ((rtlefuse->eeprom_cc & BIT(6)) >> 6)); - rtl_set_bbreg(hw, RFPGA0_XAB_RFPARAMETER, - BIT(31) | BIT(15), - ((rtlefuse->eeprom_cc & BIT(4)) >> 4) | - ((rtlefuse->eeprom_cc & BIT(6)) << 10)); - } - } - /* update IQK related settings */ - rtl_set_bbreg(hw, ROFDM0_XARXIQIMBALANCE, BMASKDWORD, 0x40000100); - rtl_set_bbreg(hw, ROFDM0_XBRXIQIMBALANCE, BMASKDWORD, 0x40000100); - rtl_set_bbreg(hw, ROFDM0_XCTxAFE, 0xF0000000, 0x00); - rtl_set_bbreg(hw, ROFDM0_ECCATHRESHOLD, BIT(30) | BIT(28) | - BIT(26) | BIT(24), 0x00); - rtl_set_bbreg(hw, ROFDM0_XDTxAFE, 0xF0000000, 0x00); - rtl_set_bbreg(hw, 0xca0, 0xF0000000, 0x00); - rtl_set_bbreg(hw, ROFDM0_AGCRSSITABLE, 0x0000F000, 0x00); - - /* Update RF */ - for (rfpath = RF90_PATH_A; rfpath < rtlphy->num_total_rfpath; - rfpath++) { - if (rtlhal->current_bandtype == BAND_ON_2_4G) { - /* MOD_AG for RF paht_A 0x18 BIT8,BIT16 */ - rtl_set_rfreg(hw, rfpath, RF_CHNLBW, BIT(8) | BIT(16) | - BIT(18), 0); - /* RF0x0b[16:14] =3b'111 */ - rtl_set_rfreg(hw, (enum radio_path)rfpath, 0x0B, - 0x1c000, 0x07); - } else { - /* MOD_AG for RF paht_A 0x18 BIT8,BIT16 */ - rtl_set_rfreg(hw, rfpath, RF_CHNLBW, BIT(8) | - BIT(16) | BIT(18), - (BIT(16) | BIT(8)) >> 8); - } - } - /* Update for all band. */ - /* DMDP */ - if (rtlphy->rf_type == RF_1T1R) { - /* Use antenna 0,0xc04,0xd04 */ - rtl_set_bbreg(hw, ROFDM0_TRXPATHENABLE, BMASKBYTE0, 0x11); - rtl_set_bbreg(hw, ROFDM1_TRXPATHENABLE, BDWORD, 0x1); - - /* enable ad/da clock1 for dual-phy reg0x888 */ - if (rtlhal->interfaceindex == 0) { - rtl_set_bbreg(hw, RFPGA0_ADDALLOCKEN, BIT(12) | - BIT(13), 0x3); - } else { - rtl92d_phy_enable_anotherphy(hw, false); - RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, - ("MAC1 use DBI to update 0x888")); - /* 0x888 */ - rtl92de_write_dword_dbi(hw, RFPGA0_ADDALLOCKEN, - rtl92de_read_dword_dbi(hw, - RFPGA0_ADDALLOCKEN, - BIT(3)) | BIT(12) | BIT(13), - BIT(3)); - rtl92d_phy_powerdown_anotherphy(hw, false); - } - } else { - /* Single PHY */ - /* Use antenna 0 & 1,0xc04,0xd04 */ - rtl_set_bbreg(hw, ROFDM0_TRXPATHENABLE, BMASKBYTE0, 0x33); - rtl_set_bbreg(hw, ROFDM1_TRXPATHENABLE, BDWORD, 0x3); - /* disable ad/da clock1,0x888 */ - rtl_set_bbreg(hw, RFPGA0_ADDALLOCKEN, BIT(12) | BIT(13), 0); - } - for (rfpath = RF90_PATH_A; rfpath < rtlphy->num_total_rfpath; - rfpath++) { - rtlphy->rfreg_chnlval[rfpath] = rtl_get_rfreg(hw, rfpath, - RF_CHNLBW, BRFREGOFFSETMASK); - rtlphy->reg_rf3c[rfpath] = rtl_get_rfreg(hw, rfpath, 0x3C, - BRFREGOFFSETMASK); - } - for (i = 0; i < 2; i++) - RT_TRACE(rtlpriv, COMP_RF, DBG_LOUD, ("RF 0x18 = 0x%x\n", - rtlphy->rfreg_chnlval[i])); - RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, ("<==\n")); - -} - -bool rtl92d_phy_check_poweroff(struct ieee80211_hw *hw) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); - u8 u1btmp; - unsigned long flags; - - if (rtlhal->macphymode == SINGLEMAC_SINGLEPHY) { - u1btmp = rtl_read_byte(rtlpriv, REG_MAC0); - rtl_write_byte(rtlpriv, REG_MAC0, u1btmp & (~MAC0_ON)); - return true; - } - spin_lock_irqsave(&globalmutex_power, flags); - if (rtlhal->interfaceindex == 0) { - u1btmp = rtl_read_byte(rtlpriv, REG_MAC0); - rtl_write_byte(rtlpriv, REG_MAC0, u1btmp & (~MAC0_ON)); - u1btmp = rtl_read_byte(rtlpriv, REG_MAC1); - u1btmp &= MAC1_ON; - } else { - u1btmp = rtl_read_byte(rtlpriv, REG_MAC1); - rtl_write_byte(rtlpriv, REG_MAC1, u1btmp & (~MAC1_ON)); - u1btmp = rtl_read_byte(rtlpriv, REG_MAC0); - u1btmp &= MAC0_ON; - } - if (u1btmp) { - spin_unlock_irqrestore(&globalmutex_power, flags); - return false; - } - u1btmp = rtl_read_byte(rtlpriv, REG_POWER_OFF_IN_PROCESS); - u1btmp |= BIT(7); - rtl_write_byte(rtlpriv, REG_POWER_OFF_IN_PROCESS, u1btmp); - spin_unlock_irqrestore(&globalmutex_power, flags); - return true; -} diff --git a/trunk/drivers/net/wireless/rtlwifi/rtl8192de/phy.h b/trunk/drivers/net/wireless/rtlwifi/rtl8192de/phy.h deleted file mode 100644 index a52c824b41e3..000000000000 --- a/trunk/drivers/net/wireless/rtlwifi/rtl8192de/phy.h +++ /dev/null @@ -1,178 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2009-2010 Realtek Corporation. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * The full GNU General Public License is included in this distribution in the - * file called LICENSE. - * - * Contact Information: - * wlanfae - * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, - * Hsinchu 300, Taiwan. - * - * Larry Finger - * - *****************************************************************************/ - -#ifndef __RTL92D_PHY_H__ -#define __RTL92D_PHY_H__ - -#define MAX_PRECMD_CNT 16 -#define MAX_RFDEPENDCMD_CNT 16 -#define MAX_POSTCMD_CNT 16 - -#define MAX_DOZE_WAITING_TIMES_9x 64 - -#define RT_CANNOT_IO(hw) false -#define HIGHPOWER_RADIOA_ARRAYLEN 22 - -#define IQK_ADDA_REG_NUM 16 -#define MAX_TOLERANCE 5 -#define IQK_DELAY_TIME 1 - -#define APK_BB_REG_NUM 5 -#define APK_AFE_REG_NUM 16 -#define APK_CURVE_REG_NUM 4 -#define PATH_NUM 2 - -#define LOOP_LIMIT 5 -#define MAX_STALL_TIME 50 -#define ANTENNA_DIVERSITY_VALUE 0x80 -#define MAX_TXPWR_IDX_NMODE_92S 63 -#define RESET_CNT_LIMIT 3 - -#define IQK_ADDA_REG_NUM 16 -#define IQK_BB_REG_NUM 10 -#define IQK_BB_REG_NUM_test 6 -#define IQK_MAC_REG_NUM 4 -#define RX_INDEX_MAPPING_NUM 15 - -#define IQK_DELAY_TIME 1 - -#define CT_OFFSET_MAC_ADDR 0X16 - -#define CT_OFFSET_CCK_TX_PWR_IDX 0x5A -#define CT_OFFSET_HT401S_TX_PWR_IDX 0x60 -#define CT_OFFSET_HT402S_TX_PWR_IDX_DIFF 0x66 -#define CT_OFFSET_HT20_TX_PWR_IDX_DIFF 0x69 -#define CT_OFFSET_OFDM_TX_PWR_IDX_DIFF 0x6C - -#define CT_OFFSET_HT40_MAX_PWR_OFFSET 0x6F -#define CT_OFFSET_HT20_MAX_PWR_OFFSET 0x72 - -#define CT_OFFSET_CHANNEL_PLAH 0x75 -#define CT_OFFSET_THERMAL_METER 0x78 -#define CT_OFFSET_RF_OPTION 0x79 -#define CT_OFFSET_VERSION 0x7E -#define CT_OFFSET_CUSTOMER_ID 0x7F - -enum swchnlcmd_id { - CMDID_END, - CMDID_SET_TXPOWEROWER_LEVEL, - CMDID_BBREGWRITE10, - CMDID_WRITEPORT_ULONG, - CMDID_WRITEPORT_USHORT, - CMDID_WRITEPORT_UCHAR, - CMDID_RF_WRITEREG, -}; - -struct swchnlcmd { - enum swchnlcmd_id cmdid; - u32 para1; - u32 para2; - u32 msdelay; -}; - -enum baseband_config_type { - BASEBAND_CONFIG_PHY_REG = 0, - BASEBAND_CONFIG_AGC_TAB = 1, -}; - -enum rf_content { - radioa_txt = 0, - radiob_txt = 1, - radioc_txt = 2, - radiod_txt = 3 -}; - -static inline void rtl92d_acquire_cckandrw_pagea_ctl(struct ieee80211_hw *hw, - unsigned long *flag) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - - if (rtlpriv->rtlhal.interfaceindex == 1) - spin_lock_irqsave(&rtlpriv->locks.cck_and_rw_pagea_lock, *flag); -} - -static inline void rtl92d_release_cckandrw_pagea_ctl(struct ieee80211_hw *hw, - unsigned long *flag) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - - if (rtlpriv->rtlhal.interfaceindex == 1) - spin_unlock_irqrestore(&rtlpriv->locks.cck_and_rw_pagea_lock, - *flag); -} - -extern u32 rtl92d_phy_query_bb_reg(struct ieee80211_hw *hw, - u32 regaddr, u32 bitmask); -extern void rtl92d_phy_set_bb_reg(struct ieee80211_hw *hw, - u32 regaddr, u32 bitmask, u32 data); -extern u32 rtl92d_phy_query_rf_reg(struct ieee80211_hw *hw, - enum radio_path rfpath, u32 regaddr, - u32 bitmask); -extern void rtl92d_phy_set_rf_reg(struct ieee80211_hw *hw, - enum radio_path rfpath, u32 regaddr, - u32 bitmask, u32 data); -extern bool rtl92d_phy_mac_config(struct ieee80211_hw *hw); -extern bool rtl92d_phy_bb_config(struct ieee80211_hw *hw); -extern bool rtl92d_phy_rf_config(struct ieee80211_hw *hw); -extern bool rtl92c_phy_config_rf_with_feaderfile(struct ieee80211_hw *hw, - enum radio_path rfpath); -extern void rtl92d_phy_get_hw_reg_originalvalue(struct ieee80211_hw *hw); -extern void rtl92d_phy_set_txpower_level(struct ieee80211_hw *hw, u8 channel); -extern void rtl92d_phy_scan_operation_backup(struct ieee80211_hw *hw, - u8 operation); -extern void rtl92d_phy_set_bw_mode(struct ieee80211_hw *hw, - enum nl80211_channel_type ch_type); -extern u8 rtl92d_phy_sw_chnl(struct ieee80211_hw *hw); -bool rtl92d_phy_config_rf_with_headerfile(struct ieee80211_hw *hw, - enum rf_content content, - enum radio_path rfpath); -bool rtl92d_phy_set_io_cmd(struct ieee80211_hw *hw, enum io_type iotype); -extern bool rtl92d_phy_set_rf_power_state(struct ieee80211_hw *hw, - enum rf_pwrstate rfpwr_state); - -void rtl92d_phy_config_macphymode(struct ieee80211_hw *hw); -void rtl92d_phy_config_macphymode_info(struct ieee80211_hw *hw); -u8 rtl92d_get_chnlgroup_fromarray(u8 chnl); -void rtl92d_phy_set_poweron(struct ieee80211_hw *hw); -void rtl92d_phy_config_maccoexist_rfpage(struct ieee80211_hw *hw); -bool rtl92d_phy_check_poweroff(struct ieee80211_hw *hw); -void rtl92d_phy_lc_calibrate(struct ieee80211_hw *hw); -void rtl92d_update_bbrf_configuration(struct ieee80211_hw *hw); -void rtl92d_phy_ap_calibrate(struct ieee80211_hw *hw, char delta); -void rtl92d_phy_iq_calibrate(struct ieee80211_hw *hw); -void rtl92d_phy_reset_iqk_result(struct ieee80211_hw *hw); -void rtl92d_release_cckandrw_pagea_ctl(struct ieee80211_hw *hw, - unsigned long *flag); -void rtl92d_acquire_cckandrw_pagea_ctl(struct ieee80211_hw *hw, - unsigned long *flag); -u8 rtl92d_get_rightchnlplace_for_iqk(u8 chnl); -void rtl92d_phy_reload_iqk_setting(struct ieee80211_hw *hw, u8 channel); -void rtl92d_phy_iq_calibrate(struct ieee80211_hw *hw); - -#endif diff --git a/trunk/drivers/net/wireless/rtlwifi/rtl8192de/reg.h b/trunk/drivers/net/wireless/rtlwifi/rtl8192de/reg.h deleted file mode 100644 index 131acc306fcc..000000000000 --- a/trunk/drivers/net/wireless/rtlwifi/rtl8192de/reg.h +++ /dev/null @@ -1,1313 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2009-2010 Realtek Corporation. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * The full GNU General Public License is included in this distribution in the - * file called LICENSE. - * - * Contact Information: - * wlanfae - * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, - * Hsinchu 300, Taiwan. - * - * Larry Finger - * - *****************************************************************************/ - -#ifndef __RTL92D_REG_H__ -#define __RTL92D_REG_H__ - -/* ----------------------------------------------------- */ -/* 0x0000h ~ 0x00FFh System Configuration */ -/* ----------------------------------------------------- */ -#define REG_SYS_ISO_CTRL 0x0000 -#define REG_SYS_FUNC_EN 0x0002 -#define REG_APS_FSMCO 0x0004 -#define REG_SYS_CLKR 0x0008 -#define REG_9346CR 0x000A -#define REG_EE_VPD 0x000C -#define REG_AFE_MISC 0x0010 -#define REG_SPS0_CTRL 0x0011 -#define REG_POWER_OFF_IN_PROCESS 0x0017 -#define REG_SPS_OCP_CFG 0x0018 -#define REG_RSV_CTRL 0x001C -#define REG_RF_CTRL 0x001F -#define REG_LDOA15_CTRL 0x0020 -#define REG_LDOV12D_CTRL 0x0021 -#define REG_LDOHCI12_CTRL 0x0022 -#define REG_LPLDO_CTRL 0x0023 -#define REG_AFE_XTAL_CTRL 0x0024 -#define REG_AFE_PLL_CTRL 0x0028 -/* for 92d, DMDP,SMSP,DMSP contrl */ -#define REG_MAC_PHY_CTRL 0x002c -#define REG_EFUSE_CTRL 0x0030 -#define REG_EFUSE_TEST 0x0034 -#define REG_PWR_DATA 0x0038 -#define REG_CAL_TIMER 0x003C -#define REG_ACLK_MON 0x003E -#define REG_GPIO_MUXCFG 0x0040 -#define REG_GPIO_IO_SEL 0x0042 -#define REG_MAC_PINMUX_CFG 0x0043 -#define REG_GPIO_PIN_CTRL 0x0044 -#define REG_GPIO_INTM 0x0048 -#define REG_LEDCFG0 0x004C -#define REG_LEDCFG1 0x004D -#define REG_LEDCFG2 0x004E -#define REG_LEDCFG3 0x004F -#define REG_FSIMR 0x0050 -#define REG_FSISR 0x0054 - -#define REG_MCUFWDL 0x0080 - -#define REG_HMEBOX_EXT_0 0x0088 -#define REG_HMEBOX_EXT_1 0x008A -#define REG_HMEBOX_EXT_2 0x008C -#define REG_HMEBOX_EXT_3 0x008E - -#define REG_BIST_SCAN 0x00D0 -#define REG_BIST_RPT 0x00D4 -#define REG_BIST_ROM_RPT 0x00D8 -#define REG_USB_SIE_INTF 0x00E0 -#define REG_PCIE_MIO_INTF 0x00E4 -#define REG_PCIE_MIO_INTD 0x00E8 -#define REG_HPON_FSM 0x00EC -#define REG_SYS_CFG 0x00F0 -#define REG_MAC_PHY_CTRL_NORMAL 0x00f8 - -#define REG_MAC0 0x0081 -#define REG_MAC1 0x0053 -#define FW_MAC0_READY 0x18 -#define FW_MAC1_READY 0x1A -#define MAC0_ON BIT(7) -#define MAC1_ON BIT(0) -#define MAC0_READY BIT(0) -#define MAC1_READY BIT(0) - -/* ----------------------------------------------------- */ -/* 0x0100h ~ 0x01FFh MACTOP General Configuration */ -/* ----------------------------------------------------- */ -#define REG_CR 0x0100 -#define REG_PBP 0x0104 -#define REG_TRXDMA_CTRL 0x010C -#define REG_TRXFF_BNDY 0x0114 -#define REG_TRXFF_STATUS 0x0118 -#define REG_RXFF_PTR 0x011C -#define REG_HIMR 0x0120 -#define REG_HISR 0x0124 -#define REG_HIMRE 0x0128 -#define REG_HISRE 0x012C -#define REG_CPWM 0x012F -#define REG_FWIMR 0x0130 -#define REG_FWISR 0x0134 -#define REG_PKTBUF_DBG_CTRL 0x0140 -#define REG_PKTBUF_DBG_DATA_L 0x0144 -#define REG_PKTBUF_DBG_DATA_H 0x0148 - -#define REG_TC0_CTRL 0x0150 -#define REG_TC1_CTRL 0x0154 -#define REG_TC2_CTRL 0x0158 -#define REG_TC3_CTRL 0x015C -#define REG_TC4_CTRL 0x0160 -#define REG_TCUNIT_BASE 0x0164 -#define REG_MBIST_START 0x0174 -#define REG_MBIST_DONE 0x0178 -#define REG_MBIST_FAIL 0x017C -#define REG_C2HEVT_MSG_NORMAL 0x01A0 -#define REG_C2HEVT_MSG_TEST 0x01B8 -#define REG_C2HEVT_CLEAR 0x01BF -#define REG_MCUTST_1 0x01c0 -#define REG_FMETHR 0x01C8 -#define REG_HMETFR 0x01CC -#define REG_HMEBOX_0 0x01D0 -#define REG_HMEBOX_1 0x01D4 -#define REG_HMEBOX_2 0x01D8 -#define REG_HMEBOX_3 0x01DC - -#define REG_LLT_INIT 0x01E0 -#define REG_BB_ACCEESS_CTRL 0x01E8 -#define REG_BB_ACCESS_DATA 0x01EC - - -/* ----------------------------------------------------- */ -/* 0x0200h ~ 0x027Fh TXDMA Configuration */ -/* ----------------------------------------------------- */ -#define REG_RQPN 0x0200 -#define REG_FIFOPAGE 0x0204 -#define REG_TDECTRL 0x0208 -#define REG_TXDMA_OFFSET_CHK 0x020C -#define REG_TXDMA_STATUS 0x0210 -#define REG_RQPN_NPQ 0x0214 - -/* ----------------------------------------------------- */ -/* 0x0280h ~ 0x02FFh RXDMA Configuration */ -/* ----------------------------------------------------- */ -#define REG_RXDMA_AGG_PG_TH 0x0280 -#define REG_RXPKT_NUM 0x0284 -#define REG_RXDMA_STATUS 0x0288 - -/* ----------------------------------------------------- */ -/* 0x0300h ~ 0x03FFh PCIe */ -/* ----------------------------------------------------- */ -#define REG_PCIE_CTRL_REG 0x0300 -#define REG_INT_MIG 0x0304 -#define REG_BCNQ_DESA 0x0308 -#define REG_HQ_DESA 0x0310 -#define REG_MGQ_DESA 0x0318 -#define REG_VOQ_DESA 0x0320 -#define REG_VIQ_DESA 0x0328 -#define REG_BEQ_DESA 0x0330 -#define REG_BKQ_DESA 0x0338 -#define REG_RX_DESA 0x0340 -#define REG_DBI 0x0348 -#define REG_DBI_WDATA 0x0348 -#define REG_DBI_RDATA 0x034C -#define REG_DBI_CTRL 0x0350 -#define REG_DBI_FLAG 0x0352 -#define REG_MDIO 0x0354 -#define REG_DBG_SEL 0x0360 -#define REG_PCIE_HRPWM 0x0361 -#define REG_PCIE_HCPWM 0x0363 -#define REG_UART_CTRL 0x0364 -#define REG_UART_TX_DESA 0x0370 -#define REG_UART_RX_DESA 0x0378 - -/* ----------------------------------------------------- */ -/* 0x0400h ~ 0x047Fh Protocol Configuration */ -/* ----------------------------------------------------- */ -#define REG_VOQ_INFORMATION 0x0400 -#define REG_VIQ_INFORMATION 0x0404 -#define REG_BEQ_INFORMATION 0x0408 -#define REG_BKQ_INFORMATION 0x040C -#define REG_MGQ_INFORMATION 0x0410 -#define REG_HGQ_INFORMATION 0x0414 -#define REG_BCNQ_INFORMATION 0x0418 - - -#define REG_CPU_MGQ_INFORMATION 0x041C -#define REG_FWHW_TXQ_CTRL 0x0420 -#define REG_HWSEQ_CTRL 0x0423 -#define REG_TXPKTBUF_BCNQ_BDNY 0x0424 -#define REG_TXPKTBUF_MGQ_BDNY 0x0425 -#define REG_MULTI_BCNQ_EN 0x0426 -#define REG_MULTI_BCNQ_OFFSET 0x0427 -#define REG_SPEC_SIFS 0x0428 -#define REG_RL 0x042A -#define REG_DARFRC 0x0430 -#define REG_RARFRC 0x0438 -#define REG_RRSR 0x0440 -#define REG_ARFR0 0x0444 -#define REG_ARFR1 0x0448 -#define REG_ARFR2 0x044C -#define REG_ARFR3 0x0450 -#define REG_AGGLEN_LMT 0x0458 -#define REG_AMPDU_MIN_SPACE 0x045C -#define REG_TXPKTBUF_WMAC_LBK_BF_HD 0x045D -#define REG_FAST_EDCA_CTRL 0x0460 -#define REG_RD_RESP_PKT_TH 0x0463 -#define REG_INIRTS_RATE_SEL 0x0480 -#define REG_INIDATA_RATE_SEL 0x0484 -#define REG_POWER_STATUS 0x04A4 -#define REG_POWER_STAGE1 0x04B4 -#define REG_POWER_STAGE2 0x04B8 -#define REG_PKT_LIFE_TIME 0x04C0 -#define REG_STBC_SETTING 0x04C4 -#define REG_PROT_MODE_CTRL 0x04C8 -#define REG_MAX_AGGR_NUM 0x04CA -#define REG_RTS_MAX_AGGR_NUM 0x04CB -#define REG_BAR_MODE_CTRL 0x04CC -#define REG_RA_TRY_RATE_AGG_LMT 0x04CF -#define REG_EARLY_MODE_CONTROL 0x4D0 -#define REG_NQOS_SEQ 0x04DC -#define REG_QOS_SEQ 0x04DE -#define REG_NEED_CPU_HANDLE 0x04E0 -#define REG_PKT_LOSE_RPT 0x04E1 -#define REG_PTCL_ERR_STATUS 0x04E2 -#define REG_DUMMY 0x04FC - -/* ----------------------------------------------------- */ -/* 0x0500h ~ 0x05FFh EDCA Configuration */ -/* ----------------------------------------------------- */ -#define REG_EDCA_VO_PARAM 0x0500 -#define REG_EDCA_VI_PARAM 0x0504 -#define REG_EDCA_BE_PARAM 0x0508 -#define REG_EDCA_BK_PARAM 0x050C -#define REG_BCNTCFG 0x0510 -#define REG_PIFS 0x0512 -#define REG_RDG_PIFS 0x0513 -#define REG_SIFS_CTX 0x0514 -#define REG_SIFS_TRX 0x0516 -#define REG_AGGR_BREAK_TIME 0x051A -#define REG_SLOT 0x051B -#define REG_TX_PTCL_CTRL 0x0520 -#define REG_TXPAUSE 0x0522 -#define REG_DIS_TXREQ_CLR 0x0523 -#define REG_RD_CTRL 0x0524 -#define REG_TBTT_PROHIBIT 0x0540 -#define REG_RD_NAV_NXT 0x0544 -#define REG_NAV_PROT_LEN 0x0546 -#define REG_BCN_CTRL 0x0550 -#define REG_USTIME_TSF 0x0551 -#define REG_MBID_NUM 0x0552 -#define REG_DUAL_TSF_RST 0x0553 -#define REG_BCN_INTERVAL 0x0554 -#define REG_MBSSID_BCN_SPACE 0x0554 -#define REG_DRVERLYINT 0x0558 -#define REG_BCNDMATIM 0x0559 -#define REG_ATIMWND 0x055A -#define REG_BCN_MAX_ERR 0x055D -#define REG_RXTSF_OFFSET_CCK 0x055E -#define REG_RXTSF_OFFSET_OFDM 0x055F -#define REG_TSFTR 0x0560 -#define REG_INIT_TSFTR 0x0564 -#define REG_PSTIMER 0x0580 -#define REG_TIMER0 0x0584 -#define REG_TIMER1 0x0588 -#define REG_ACMHWCTRL 0x05C0 -#define REG_ACMRSTCTRL 0x05C1 -#define REG_ACMAVG 0x05C2 -#define REG_VO_ADMTIME 0x05C4 -#define REG_VI_ADMTIME 0x05C6 -#define REG_BE_ADMTIME 0x05C8 -#define REG_EDCA_RANDOM_GEN 0x05CC -#define REG_SCH_TXCMD 0x05D0 - -/* Dual MAC Co-Existence Register */ -#define REG_DMC 0x05F0 - -/* ----------------------------------------------------- */ -/* 0x0600h ~ 0x07FFh WMAC Configuration */ -/* ----------------------------------------------------- */ -#define REG_APSD_CTRL 0x0600 -#define REG_BWOPMODE 0x0603 -#define REG_TCR 0x0604 -#define REG_RCR 0x0608 -#define REG_RX_PKT_LIMIT 0x060C -#define REG_RX_DLK_TIME 0x060D -#define REG_RX_DRVINFO_SZ 0x060F - -#define REG_MACID 0x0610 -#define REG_BSSID 0x0618 -#define REG_MAR 0x0620 -#define REG_MBIDCAMCFG 0x0628 - -#define REG_USTIME_EDCA 0x0638 -#define REG_MAC_SPEC_SIFS 0x063A -#define REG_RESP_SIFS_CCK 0x063C -#define REG_RESP_SIFS_OFDM 0x063E -#define REG_ACKTO 0x0640 -#define REG_CTS2TO 0x0641 -#define REG_EIFS 0x0642 - - -/* WMA, BA, CCX */ -#define REG_NAV_CTRL 0x0650 -#define REG_BACAMCMD 0x0654 -#define REG_BACAMCONTENT 0x0658 -#define REG_LBDLY 0x0660 -#define REG_FWDLY 0x0661 -#define REG_RXERR_RPT 0x0664 -#define REG_WMAC_TRXPTCL_CTL 0x0668 - - -/* Security */ -#define REG_CAMCMD 0x0670 -#define REG_CAMWRITE 0x0674 -#define REG_CAMREAD 0x0678 -#define REG_CAMDBG 0x067C -#define REG_SECCFG 0x0680 - -/* Power */ -#define REG_WOW_CTRL 0x0690 -#define REG_PSSTATUS 0x0691 -#define REG_PS_RX_INFO 0x0692 -#define REG_LPNAV_CTRL 0x0694 -#define REG_WKFMCAM_CMD 0x0698 -#define REG_WKFMCAM_RWD 0x069C -#define REG_RXFLTMAP0 0x06A0 -#define REG_RXFLTMAP1 0x06A2 -#define REG_RXFLTMAP2 0x06A4 -#define REG_BCN_PSR_RPT 0x06A8 -#define REG_CALB32K_CTRL 0x06AC -#define REG_PKT_MON_CTRL 0x06B4 -#define REG_BT_COEX_TABLE 0x06C0 -#define REG_WMAC_RESP_TXINFO 0x06D8 - - -/* ----------------------------------------------------- */ -/* Redifine 8192C register definition for compatibility */ -/* ----------------------------------------------------- */ -#define CR9346 REG_9346CR -#define MSR (REG_CR + 2) -#define ISR REG_HISR -#define TSFR REG_TSFTR - -#define MACIDR0 REG_MACID -#define MACIDR4 (REG_MACID + 4) - -#define PBP REG_PBP - -#define IDR0 MACIDR0 -#define IDR4 MACIDR4 - -/* ----------------------------------------------------- */ -/* 8192C (MSR) Media Status Register(Offset 0x4C, 8 bits)*/ -/* ----------------------------------------------------- */ -#define MSR_NOLINK 0x00 -#define MSR_ADHOC 0x01 -#define MSR_INFRA 0x02 -#define MSR_AP 0x03 - -/* 6. Adaptive Control Registers (Offset: 0x0160 - 0x01CF) */ -/* ----------------------------------------------------- */ -/* 8192C Response Rate Set Register(offset 0x181, 24bits)*/ -/* ----------------------------------------------------- */ -#define RRSR_RSC_OFFSET 21 -#define RRSR_SHORT_OFFSET 23 -#define RRSR_RSC_BW_40M 0x600000 -#define RRSR_RSC_UPSUBCHNL 0x400000 -#define RRSR_RSC_LOWSUBCHNL 0x200000 -#define RRSR_SHORT 0x800000 -#define RRSR_1M BIT0 -#define RRSR_2M BIT1 -#define RRSR_5_5M BIT2 -#define RRSR_11M BIT3 -#define RRSR_6M BIT4 -#define RRSR_9M BIT5 -#define RRSR_12M BIT6 -#define RRSR_18M BIT7 -#define RRSR_24M BIT8 -#define RRSR_36M BIT9 -#define RRSR_48M BIT10 -#define RRSR_54M BIT11 -#define RRSR_MCS0 BIT12 -#define RRSR_MCS1 BIT13 -#define RRSR_MCS2 BIT14 -#define RRSR_MCS3 BIT15 -#define RRSR_MCS4 BIT16 -#define RRSR_MCS5 BIT17 -#define RRSR_MCS6 BIT18 -#define RRSR_MCS7 BIT19 -#define BRSR_ACKSHORTPMB BIT23 - -/* ----------------------------------------------------- */ -/* 8192C Rate Definition */ -/* ----------------------------------------------------- */ -/* CCK */ -#define RATR_1M 0x00000001 -#define RATR_2M 0x00000002 -#define RATR_55M 0x00000004 -#define RATR_11M 0x00000008 -/* OFDM */ -#define RATR_6M 0x00000010 -#define RATR_9M 0x00000020 -#define RATR_12M 0x00000040 -#define RATR_18M 0x00000080 -#define RATR_24M 0x00000100 -#define RATR_36M 0x00000200 -#define RATR_48M 0x00000400 -#define RATR_54M 0x00000800 -/* MCS 1 Spatial Stream */ -#define RATR_MCS0 0x00001000 -#define RATR_MCS1 0x00002000 -#define RATR_MCS2 0x00004000 -#define RATR_MCS3 0x00008000 -#define RATR_MCS4 0x00010000 -#define RATR_MCS5 0x00020000 -#define RATR_MCS6 0x00040000 -#define RATR_MCS7 0x00080000 -/* MCS 2 Spatial Stream */ -#define RATR_MCS8 0x00100000 -#define RATR_MCS9 0x00200000 -#define RATR_MCS10 0x00400000 -#define RATR_MCS11 0x00800000 -#define RATR_MCS12 0x01000000 -#define RATR_MCS13 0x02000000 -#define RATR_MCS14 0x04000000 -#define RATR_MCS15 0x08000000 - -/* CCK */ -#define RATE_1M BIT(0) -#define RATE_2M BIT(1) -#define RATE_5_5M BIT(2) -#define RATE_11M BIT(3) -/* OFDM */ -#define RATE_6M BIT(4) -#define RATE_9M BIT(5) -#define RATE_12M BIT(6) -#define RATE_18M BIT(7) -#define RATE_24M BIT(8) -#define RATE_36M BIT(9) -#define RATE_48M BIT(10) -#define RATE_54M BIT(11) -/* MCS 1 Spatial Stream */ -#define RATE_MCS0 BIT(12) -#define RATE_MCS1 BIT(13) -#define RATE_MCS2 BIT(14) -#define RATE_MCS3 BIT(15) -#define RATE_MCS4 BIT(16) -#define RATE_MCS5 BIT(17) -#define RATE_MCS6 BIT(18) -#define RATE_MCS7 BIT(19) -/* MCS 2 Spatial Stream */ -#define RATE_MCS8 BIT(20) -#define RATE_MCS9 BIT(21) -#define RATE_MCS10 BIT(22) -#define RATE_MCS11 BIT(23) -#define RATE_MCS12 BIT(24) -#define RATE_MCS13 BIT(25) -#define RATE_MCS14 BIT(26) -#define RATE_MCS15 BIT(27) - -/* ALL CCK Rate */ -#define RATE_ALL_CCK (RATR_1M | RATR_2M | RATR_55M | \ - RATR_11M) -#define RATE_ALL_OFDM_AG (RATR_6M | RATR_9M | RATR_12M | \ - RATR_18M | RATR_24M | \ - RATR_36M | RATR_48M | RATR_54M) -#define RATE_ALL_OFDM_1SS (RATR_MCS0 | RATR_MCS1 | RATR_MCS2 | \ - RATR_MCS3 | RATR_MCS4 | RATR_MCS5 | \ - RATR_MCS6 | RATR_MCS7) -#define RATE_ALL_OFDM_2SS (RATR_MCS8 | RATR_MCS9 | RATR_MCS10 | \ - RATR_MCS11 | RATR_MCS12 | RATR_MCS13 | \ - RATR_MCS14 | RATR_MCS15) - -/* ----------------------------------------------------- */ -/* 8192C BW_OPMODE bits (Offset 0x203, 8bit) */ -/* ----------------------------------------------------- */ -#define BW_OPMODE_20MHZ BIT(2) -#define BW_OPMODE_5G BIT(1) -#define BW_OPMODE_11J BIT(0) - - -/* ----------------------------------------------------- */ -/* 8192C CAM Config Setting (offset 0x250, 1 byte) */ -/* ----------------------------------------------------- */ -#define CAM_VALID BIT(15) -#define CAM_NOTVALID 0x0000 -#define CAM_USEDK BIT(5) - -#define CAM_NONE 0x0 -#define CAM_WEP40 0x01 -#define CAM_TKIP 0x02 -#define CAM_AES 0x04 -#define CAM_WEP104 0x05 -#define CAM_SMS4 0x6 - - -#define TOTAL_CAM_ENTRY 32 -#define HALF_CAM_ENTRY 16 - -#define CAM_WRITE BIT(16) -#define CAM_READ 0x00000000 -#define CAM_POLLINIG BIT(31) - -/* 10. Power Save Control Registers (Offset: 0x0260 - 0x02DF) */ -#define WOW_PMEN BIT0 /* Power management Enable. */ -#define WOW_WOMEN BIT1 /* WoW function on or off. */ -#define WOW_MAGIC BIT2 /* Magic packet */ -#define WOW_UWF BIT3 /* Unicast Wakeup frame. */ - -/* 12. Host Interrupt Status Registers (Offset: 0x0300 - 0x030F) */ -/* ----------------------------------------------------- */ -/* 8190 IMR/ISR bits (offset 0xfd, 8bits) */ -/* ----------------------------------------------------- */ -#define IMR8190_DISABLED 0x0 -#define IMR_BCNDMAINT6 BIT(31) -#define IMR_BCNDMAINT5 BIT(30) -#define IMR_BCNDMAINT4 BIT(29) -#define IMR_BCNDMAINT3 BIT(28) -#define IMR_BCNDMAINT2 BIT(27) -#define IMR_BCNDMAINT1 BIT(26) -#define IMR_BCNDOK8 BIT(25) -#define IMR_BCNDOK7 BIT(24) -#define IMR_BCNDOK6 BIT(23) -#define IMR_BCNDOK5 BIT(22) -#define IMR_BCNDOK4 BIT(21) -#define IMR_BCNDOK3 BIT(20) -#define IMR_BCNDOK2 BIT(19) -#define IMR_BCNDOK1 BIT(18) -#define IMR_TIMEOUT2 BIT(17) -#define IMR_TIMEOUT1 BIT(16) -#define IMR_TXFOVW BIT(15) -#define IMR_PSTIMEOUT BIT(14) -#define IMR_BcnInt BIT(13) -#define IMR_RXFOVW BIT(12) -#define IMR_RDU BIT(11) -#define IMR_ATIMEND BIT(10) -#define IMR_BDOK BIT(9) -#define IMR_HIGHDOK BIT(8) -#define IMR_TBDOK BIT(7) -#define IMR_MGNTDOK BIT(6) -#define IMR_TBDER BIT(5) -#define IMR_BKDOK BIT(4) -#define IMR_BEDOK BIT(3) -#define IMR_VIDOK BIT(2) -#define IMR_VODOK BIT(1) -#define IMR_ROK BIT(0) - -#define IMR_TXERR BIT(11) -#define IMR_RXERR BIT(10) -#define IMR_C2HCMD BIT(9) -#define IMR_CPWM BIT(8) -#define IMR_OCPINT BIT(1) -#define IMR_WLANOFF BIT(0) - -/* ----------------------------------------------------- */ -/* 8192C EFUSE */ -/* ----------------------------------------------------- */ -#define HWSET_MAX_SIZE 256 -#define EFUSE_MAX_SECTION 32 -#define EFUSE_REAL_CONTENT_LEN 512 - -/* ----------------------------------------------------- */ -/* 8192C EEPROM/EFUSE share register definition. */ -/* ----------------------------------------------------- */ -#define EEPROM_DEFAULT_TSSI 0x0 -#define EEPROM_DEFAULT_CRYSTALCAP 0x0 -#define EEPROM_DEFAULT_THERMALMETER 0x12 - -#define EEPROM_DEFAULT_TXPOWERLEVEL_2G 0x2C -#define EEPROM_DEFAULT_TXPOWERLEVEL_5G 0x22 - -#define EEPROM_DEFAULT_HT40_2SDIFF 0x0 -/* HT20<->40 default Tx Power Index Difference */ -#define EEPROM_DEFAULT_HT20_DIFF 2 -/* OFDM Tx Power index diff */ -#define EEPROM_DEFAULT_LEGACYHTTXPOWERDIFF 0x4 -#define EEPROM_DEFAULT_HT40_PWRMAXOFFSET 0 -#define EEPROM_DEFAULT_HT20_PWRMAXOFFSET 0 - -#define EEPROM_CHANNEL_PLAN_FCC 0x0 -#define EEPROM_CHANNEL_PLAN_IC 0x1 -#define EEPROM_CHANNEL_PLAN_ETSI 0x2 -#define EEPROM_CHANNEL_PLAN_SPAIN 0x3 -#define EEPROM_CHANNEL_PLAN_FRANCE 0x4 -#define EEPROM_CHANNEL_PLAN_MKK 0x5 -#define EEPROM_CHANNEL_PLAN_MKK1 0x6 -#define EEPROM_CHANNEL_PLAN_ISRAEL 0x7 -#define EEPROM_CHANNEL_PLAN_TELEC 0x8 -#define EEPROM_CHANNEL_PLAN_GLOBAL_DOMAIN 0x9 -#define EEPROM_CHANNEL_PLAN_WORLD_WIDE_13 0xA -#define EEPROM_CHANNEL_PLAN_NCC 0xB -#define EEPROM_CHANNEL_PLAN_BY_HW_MASK 0x80 - -#define EEPROM_CID_DEFAULT 0x0 -#define EEPROM_CID_TOSHIBA 0x4 -#define EEPROM_CID_CCX 0x10 -#define EEPROM_CID_QMI 0x0D -#define EEPROM_CID_WHQL 0xFE - - -#define RTL8192_EEPROM_ID 0x8129 -#define EEPROM_WAPI_SUPPORT 0x78 - - -#define RTL8190_EEPROM_ID 0x8129 /* 0-1 */ -#define EEPROM_HPON 0x02 /* LDO settings.2-5 */ -#define EEPROM_CLK 0x06 /* Clock settings.6-7 */ -#define EEPROM_MAC_FUNCTION 0x08 /* SE Test mode.8 */ - -#define EEPROM_VID 0x28 /* SE Vendor ID.A-B */ -#define EEPROM_DID 0x2A /* SE Device ID. C-D */ -#define EEPROM_SVID 0x2C /* SE Vendor ID.E-F */ -#define EEPROM_SMID 0x2E /* SE PCI Subsystem ID. 10-11 */ - -#define EEPROM_MAC_ADDR 0x16 /* SEMAC Address. 12-17 */ -#define EEPROM_MAC_ADDR_MAC0_92D 0x55 -#define EEPROM_MAC_ADDR_MAC1_92D 0x5B - -/* 2.4G band Tx power index setting */ -#define EEPROM_CCK_TX_PWR_INX_2G 0x61 -#define EEPROM_HT40_1S_TX_PWR_INX_2G 0x67 -#define EEPROM_HT40_2S_TX_PWR_INX_DIFF_2G 0x6D -#define EEPROM_HT20_TX_PWR_INX_DIFF_2G 0x70 -#define EEPROM_OFDM_TX_PWR_INX_DIFF_2G 0x73 -#define EEPROM_HT40_MAX_PWR_OFFSET_2G 0x76 -#define EEPROM_HT20_MAX_PWR_OFFSET_2G 0x79 - -/*5GL channel 32-64 */ -#define EEPROM_HT40_1S_TX_PWR_INX_5GL 0x7C -#define EEPROM_HT40_2S_TX_PWR_INX_DIFF_5GL 0x82 -#define EEPROM_HT20_TX_PWR_INX_DIFF_5GL 0x85 -#define EEPROM_OFDM_TX_PWR_INX_DIFF_5GL 0x88 -#define EEPROM_HT40_MAX_PWR_OFFSET_5GL 0x8B -#define EEPROM_HT20_MAX_PWR_OFFSET_5GL 0x8E - -/* 5GM channel 100-140 */ -#define EEPROM_HT40_1S_TX_PWR_INX_5GM 0x91 -#define EEPROM_HT40_2S_TX_PWR_INX_DIFF_5GM 0x97 -#define EEPROM_HT20_TX_PWR_INX_DIFF_5GM 0x9A -#define EEPROM_OFDM_TX_PWR_INX_DIFF_5GM 0x9D -#define EEPROM_HT40_MAX_PWR_OFFSET_5GM 0xA0 -#define EEPROM_HT20_MAX_PWR_OFFSET_5GM 0xA3 - -/* 5GH channel 149-165 */ -#define EEPROM_HT40_1S_TX_PWR_INX_5GH 0xA6 -#define EEPROM_HT40_2S_TX_PWR_INX_DIFF_5GH 0xAC -#define EEPROM_HT20_TX_PWR_INX_DIFF_5GH 0xAF -#define EEPROM_OFDM_TX_PWR_INX_DIFF_5GH 0xB2 -#define EEPROM_HT40_MAX_PWR_OFFSET_5GH 0xB5 -#define EEPROM_HT20_MAX_PWR_OFFSET_5GH 0xB8 - -/* Map of supported channels. */ -#define EEPROM_CHANNEL_PLAN 0xBB -#define EEPROM_IQK_DELTA 0xBC -#define EEPROM_LCK_DELTA 0xBC -#define EEPROM_XTAL_K 0xBD /* [7:5] */ -#define EEPROM_TSSI_A_5G 0xBE -#define EEPROM_TSSI_B_5G 0xBF -#define EEPROM_TSSI_AB_5G 0xC0 -#define EEPROM_THERMAL_METER 0xC3 /* [4:0] */ -#define EEPROM_RF_OPT1 0xC4 -#define EEPROM_RF_OPT2 0xC5 -#define EEPROM_RF_OPT3 0xC6 -#define EEPROM_RF_OPT4 0xC7 -#define EEPROM_RF_OPT5 0xC8 -#define EEPROM_RF_OPT6 0xC9 -#define EEPROM_VERSION 0xCA -#define EEPROM_CUSTOMER_ID 0xCB -#define EEPROM_RF_OPT7 0xCC - -#define EEPROM_DEF_PART_NO 0x3FD /* Byte */ -#define EEPROME_CHIP_VERSION_L 0x3FF -#define EEPROME_CHIP_VERSION_H 0x3FE - -/* - * Current IOREG MAP - * 0x0000h ~ 0x00FFh System Configuration (256 Bytes) - * 0x0100h ~ 0x01FFh MACTOP General Configuration (256 Bytes) - * 0x0200h ~ 0x027Fh TXDMA Configuration (128 Bytes) - * 0x0280h ~ 0x02FFh RXDMA Configuration (128 Bytes) - * 0x0300h ~ 0x03FFh PCIE EMAC Reserved Region (256 Bytes) - * 0x0400h ~ 0x04FFh Protocol Configuration (256 Bytes) - * 0x0500h ~ 0x05FFh EDCA Configuration (256 Bytes) - * 0x0600h ~ 0x07FFh WMAC Configuration (512 Bytes) - * 0x2000h ~ 0x3FFFh 8051 FW Download Region (8196 Bytes) - */ - -/* ----------------------------------------------------- */ -/* 8192C (RCR) (Offset 0x608, 32 bits) */ -/* ----------------------------------------------------- */ -#define RCR_APPFCS BIT(31) -#define RCR_APP_MIC BIT(30) -#define RCR_APP_ICV BIT(29) -#define RCR_APP_PHYST_RXFF BIT(28) -#define RCR_APP_BA_SSN BIT(27) -#define RCR_ENMBID BIT(24) -#define RCR_LSIGEN BIT(23) -#define RCR_MFBEN BIT(22) -#define RCR_HTC_LOC_CTRL BIT(14) -#define RCR_AMF BIT(13) -#define RCR_ACF BIT(12) -#define RCR_ADF BIT(11) -#define RCR_AICV BIT(9) -#define RCR_ACRC32 BIT(8) -#define RCR_CBSSID_BCN BIT(7) -#define RCR_CBSSID_DATA BIT(6) -#define RCR_APWRMGT BIT(5) -#define RCR_ADD3 BIT(4) -#define RCR_AB BIT(3) -#define RCR_AM BIT(2) -#define RCR_APM BIT(1) -#define RCR_AAP BIT(0) -#define RCR_MXDMA_OFFSET 8 -#define RCR_FIFO_OFFSET 13 - -/* ----------------------------------------------------- */ -/* 8192C Regsiter Bit and Content definition */ -/* ----------------------------------------------------- */ -/* ----------------------------------------------------- */ -/* 0x0000h ~ 0x00FFh System Configuration */ -/* ----------------------------------------------------- */ - -/* SPS0_CTRL */ -#define SW18_FPWM BIT(3) - - -/* SYS_ISO_CTRL */ -#define ISO_MD2PP BIT(0) -#define ISO_UA2USB BIT(1) -#define ISO_UD2CORE BIT(2) -#define ISO_PA2PCIE BIT(3) -#define ISO_PD2CORE BIT(4) -#define ISO_IP2MAC BIT(5) -#define ISO_DIOP BIT(6) -#define ISO_DIOE BIT(7) -#define ISO_EB2CORE BIT(8) -#define ISO_DIOR BIT(9) - -#define PWC_EV25V BIT(14) -#define PWC_EV12V BIT(15) - - -/* SYS_FUNC_EN */ -#define FEN_BBRSTB BIT(0) -#define FEN_BB_GLB_RSTn BIT(1) -#define FEN_USBA BIT(2) -#define FEN_UPLL BIT(3) -#define FEN_USBD BIT(4) -#define FEN_DIO_PCIE BIT(5) -#define FEN_PCIEA BIT(6) -#define FEN_PPLL BIT(7) -#define FEN_PCIED BIT(8) -#define FEN_DIOE BIT(9) -#define FEN_CPUEN BIT(10) -#define FEN_DCORE BIT(11) -#define FEN_ELDR BIT(12) -#define FEN_DIO_RF BIT(13) -#define FEN_HWPDN BIT(14) -#define FEN_MREGEN BIT(15) - -/* APS_FSMCO */ -#define PFM_LDALL BIT(0) -#define PFM_ALDN BIT(1) -#define PFM_LDKP BIT(2) -#define PFM_WOWL BIT(3) -#define EnPDN BIT(4) -#define PDN_PL BIT(5) -#define APFM_ONMAC BIT(8) -#define APFM_OFF BIT(9) -#define APFM_RSM BIT(10) -#define AFSM_HSUS BIT(11) -#define AFSM_PCIE BIT(12) -#define APDM_MAC BIT(13) -#define APDM_HOST BIT(14) -#define APDM_HPDN BIT(15) -#define RDY_MACON BIT(16) -#define SUS_HOST BIT(17) -#define ROP_ALD BIT(20) -#define ROP_PWR BIT(21) -#define ROP_SPS BIT(22) -#define SOP_MRST BIT(25) -#define SOP_FUSE BIT(26) -#define SOP_ABG BIT(27) -#define SOP_AMB BIT(28) -#define SOP_RCK BIT(29) -#define SOP_A8M BIT(30) -#define XOP_BTCK BIT(31) - -/* SYS_CLKR */ -#define ANAD16V_EN BIT(0) -#define ANA8M BIT(1) -#define MACSLP BIT(4) -#define LOADER_CLK_EN BIT(5) -#define _80M_SSC_DIS BIT(7) -#define _80M_SSC_EN_HO BIT(8) -#define PHY_SSC_RSTB BIT(9) -#define SEC_CLK_EN BIT(10) -#define MAC_CLK_EN BIT(11) -#define SYS_CLK_EN BIT(12) -#define RING_CLK_EN BIT(13) - - -/* 9346CR */ -#define BOOT_FROM_EEPROM BIT(4) -#define EEPROM_EN BIT(5) - -/* AFE_MISC */ -#define AFE_BGEN BIT(0) -#define AFE_MBEN BIT(1) -#define MAC_ID_EN BIT(7) - -/* RSV_CTRL */ -#define WLOCK_ALL BIT(0) -#define WLOCK_00 BIT(1) -#define WLOCK_04 BIT(2) -#define WLOCK_08 BIT(3) -#define WLOCK_40 BIT(4) -#define R_DIS_PRST_0 BIT(5) -#define R_DIS_PRST_1 BIT(6) -#define LOCK_ALL_EN BIT(7) - -/* RF_CTRL */ -#define RF_EN BIT(0) -#define RF_RSTB BIT(1) -#define RF_SDMRSTB BIT(2) - - - -/* LDOA15_CTRL */ -#define LDA15_EN BIT(0) -#define LDA15_STBY BIT(1) -#define LDA15_OBUF BIT(2) -#define LDA15_REG_VOS BIT(3) -#define _LDA15_VOADJ(x) (((x) & 0x7) << 4) - - - -/* LDOV12D_CTRL */ -#define LDV12_EN BIT(0) -#define LDV12_SDBY BIT(1) -#define LPLDO_HSM BIT(2) -#define LPLDO_LSM_DIS BIT(3) -#define _LDV12_VADJ(x) (((x) & 0xF) << 4) - - -/* AFE_XTAL_CTRL */ -#define XTAL_EN BIT(0) -#define XTAL_BSEL BIT(1) -#define _XTAL_BOSC(x) (((x) & 0x3) << 2) -#define _XTAL_CADJ(x) (((x) & 0xF) << 4) -#define XTAL_GATE_USB BIT(8) -#define _XTAL_USB_DRV(x) (((x) & 0x3) << 9) -#define XTAL_GATE_AFE BIT(11) -#define _XTAL_AFE_DRV(x) (((x) & 0x3) << 12) -#define XTAL_RF_GATE BIT(14) -#define _XTAL_RF_DRV(x) (((x) & 0x3) << 15) -#define XTAL_GATE_DIG BIT(17) -#define _XTAL_DIG_DRV(x) (((x) & 0x3) << 18) -#define XTAL_BT_GATE BIT(20) -#define _XTAL_BT_DRV(x) (((x) & 0x3) << 21) -#define _XTAL_GPIO(x) (((x) & 0x7) << 23) - - -#define CKDLY_AFE BIT(26) -#define CKDLY_USB BIT(27) -#define CKDLY_DIG BIT(28) -#define CKDLY_BT BIT(29) - - -/* AFE_PLL_CTRL */ -#define APLL_EN BIT(0) -#define APLL_320_EN BIT(1) -#define APLL_FREF_SEL BIT(2) -#define APLL_EDGE_SEL BIT(3) -#define APLL_WDOGB BIT(4) -#define APLL_LPFEN BIT(5) - -#define APLL_REF_CLK_13MHZ 0x1 -#define APLL_REF_CLK_19_2MHZ 0x2 -#define APLL_REF_CLK_20MHZ 0x3 -#define APLL_REF_CLK_25MHZ 0x4 -#define APLL_REF_CLK_26MHZ 0x5 -#define APLL_REF_CLK_38_4MHZ 0x6 -#define APLL_REF_CLK_40MHZ 0x7 - -#define APLL_320EN BIT(14) -#define APLL_80EN BIT(15) -#define APLL_1MEN BIT(24) - - -/* EFUSE_CTRL */ -#define ALD_EN BIT(18) -#define EF_PD BIT(19) -#define EF_FLAG BIT(31) - -/* EFUSE_TEST */ -#define EF_TRPT BIT(7) -#define LDOE25_EN BIT(31) - -/* MCUFWDL */ -#define MCUFWDL_EN BIT(0) -#define MCUFWDL_RDY BIT(1) -#define FWDL_ChkSum_rpt BIT(2) -#define MACINI_RDY BIT(3) -#define BBINI_RDY BIT(4) -#define RFINI_RDY BIT(5) -#define WINTINI_RDY BIT(6) -#define MAC1_WINTINI_RDY BIT(11) -#define CPRST BIT(23) - -/* REG_SYS_CFG */ -#define XCLK_VLD BIT(0) -#define ACLK_VLD BIT(1) -#define UCLK_VLD BIT(2) -#define PCLK_VLD BIT(3) -#define PCIRSTB BIT(4) -#define V15_VLD BIT(5) -#define TRP_B15V_EN BIT(7) -#define SIC_IDLE BIT(8) -#define BD_MAC2 BIT(9) -#define BD_MAC1 BIT(10) -#define IC_MACPHY_MODE BIT(11) -#define PAD_HWPD_IDN BIT(22) -#define TRP_VAUX_EN BIT(23) -#define TRP_BT_EN BIT(24) -#define BD_PKG_SEL BIT(25) -#define BD_HCI_SEL BIT(26) -#define TYPE_ID BIT(27) - -/* LLT_INIT */ -#define _LLT_NO_ACTIVE 0x0 -#define _LLT_WRITE_ACCESS 0x1 -#define _LLT_READ_ACCESS 0x2 - -#define _LLT_INIT_DATA(x) ((x) & 0xFF) -#define _LLT_INIT_ADDR(x) (((x) & 0xFF) << 8) -#define _LLT_OP(x) (((x) & 0x3) << 30) -#define _LLT_OP_VALUE(x) (((x) >> 30) & 0x3) - - -/* ----------------------------------------------------- */ -/* 0x0400h ~ 0x047Fh Protocol Configuration */ -/* ----------------------------------------------------- */ -#define RETRY_LIMIT_SHORT_SHIFT 8 -#define RETRY_LIMIT_LONG_SHIFT 0 - - -/* ----------------------------------------------------- */ -/* 0x0500h ~ 0x05FFh EDCA Configuration */ -/* ----------------------------------------------------- */ -/* EDCA setting */ -#define AC_PARAM_TXOP_LIMIT_OFFSET 16 -#define AC_PARAM_ECW_MAX_OFFSET 12 -#define AC_PARAM_ECW_MIN_OFFSET 8 -#define AC_PARAM_AIFS_OFFSET 0 - -/* ACMHWCTRL */ -#define ACMHW_HWEN BIT(0) -#define ACMHW_BEQEN BIT(1) -#define ACMHW_VIQEN BIT(2) -#define ACMHW_VOQEN BIT(3) - -/* ----------------------------------------------------- */ -/* 0x0600h ~ 0x07FFh WMAC Configuration */ -/* ----------------------------------------------------- */ - -/* TCR */ -#define TSFRST BIT(0) -#define DIS_GCLK BIT(1) -#define PAD_SEL BIT(2) -#define PWR_ST BIT(6) -#define PWRBIT_OW_EN BIT(7) -#define ACRC BIT(8) -#define CFENDFORM BIT(9) -#define ICV BIT(10) - -/* SECCFG */ -#define SCR_TXUSEDK BIT(0) -#define SCR_RXUSEDK BIT(1) -#define SCR_TXENCENABLE BIT(2) -#define SCR_RXENCENABLE BIT(3) -#define SCR_SKBYA2 BIT(4) -#define SCR_NOSKMC BIT(5) -#define SCR_TXBCUSEDK BIT(6) -#define SCR_RXBCUSEDK BIT(7) - -/* General definitions */ -#define MAC_ADDR_LEN 6 -#define LAST_ENTRY_OF_TX_PKT_BUFFER 255 -#define LAST_ENTRY_OF_TX_PKT_BUFFER_DUAL_MAC 127 - -#define POLLING_LLT_THRESHOLD 20 -#define POLLING_READY_TIMEOUT_COUNT 1000 - -/* Min Spacing related settings. */ -#define MAX_MSS_DENSITY_2T 0x13 -#define MAX_MSS_DENSITY_1T 0x0A - - -/* BB-PHY register PMAC 0x100 PHY 0x800 - 0xEFF */ -/* 1. PMAC duplicate register due to connection: */ -/* RF_Mode, TRxRN, NumOf L-STF */ -/* 2. 0x800/0x900/0xA00/0xC00/0xD00/0xE00 */ -/* 3. RF register 0x00-2E */ -/* 4. Bit Mask for BB/RF register */ -/* 5. Other defintion for BB/RF R/W */ - -/* 3. Page8(0x800) */ -#define RFPGA0_RFMOD 0x800 - -#define RFPGA0_TXINFO 0x804 -#define RFPGA0_PSDFUNCTION 0x808 - -#define RFPGA0_TXGAINSTAGE 0x80c - -#define RFPGA0_RFTIMING1 0x810 -#define RFPGA0_RFTIMING2 0x814 - -#define RFPGA0_XA_HSSIPARAMETER1 0x820 -#define RFPGA0_XA_HSSIPARAMETER2 0x824 -#define RFPGA0_XB_HSSIPARAMETER1 0x828 -#define RFPGA0_XB_HSSIPARAMETER2 0x82c - -#define RFPGA0_XA_LSSIPARAMETER 0x840 -#define RFPGA0_XB_LSSIPARAMETER 0x844 - -#define RFPGA0_RFWAkEUPPARAMETER 0x850 -#define RFPGA0_RFSLEEPUPPARAMETER 0x854 - -#define RFPGA0_XAB_SWITCHCONTROL 0x858 -#define RFPGA0_XCD_SWITCHCONTROL 0x85c - -#define RFPGA0_XA_RFINTERFACEOE 0x860 -#define RFPGA0_XB_RFINTERFACEOE 0x864 - -#define RFPGA0_XAB_RFINTERFACESW 0x870 -#define RFPGA0_XCD_RFINTERFACESW 0x874 - -#define RFPGA0_XAB_RFPARAMETER 0x878 -#define RFPGA0_XCD_RFPARAMETER 0x87c - -#define RFPGA0_ANALOGPARAMETER1 0x880 -#define RFPGA0_ANALOGPARAMETER2 0x884 -#define RFPGA0_ANALOGPARAMETER3 0x888 -#define RFPGA0_ADDALLOCKEN 0x888 -#define RFPGA0_ANALOGPARAMETER4 0x88c - -#define RFPGA0_XA_LSSIREADBACK 0x8a0 -#define RFPGA0_XB_LSSIREADBACK 0x8a4 -#define RFPGA0_XC_LSSIREADBACK 0x8a8 -#define RFPGA0_XD_LSSIREADBACK 0x8ac - -#define RFPGA0_PSDREPORT 0x8b4 -#define TRANSCEIVERA_HSPI_READBACK 0x8b8 -#define TRANSCEIVERB_HSPI_READBACK 0x8bc -#define RFPGA0_XAB_RFINTERFACERB 0x8e0 -#define RFPGA0_XCD_RFINTERFACERB 0x8e4 - -/* 4. Page9(0x900) */ -#define RFPGA1_RFMOD 0x900 - -#define RFPGA1_TXBLOCK 0x904 -#define RFPGA1_DEBUGSELECT 0x908 -#define RFPGA1_TXINFO 0x90c - -/* 5. PageA(0xA00) */ -#define RCCK0_SYSTEM 0xa00 - -#define RCCK0_AFESSTTING 0xa04 -#define RCCK0_CCA 0xa08 - -#define RCCK0_RXAGC1 0xa0c -#define RCCK0_RXAGC2 0xa10 - -#define RCCK0_RXHP 0xa14 - -#define RCCK0_DSPPARAMETER1 0xa18 -#define RCCK0_DSPPARAMETER2 0xa1c - -#define RCCK0_TXFILTER1 0xa20 -#define RCCK0_TXFILTER2 0xa24 -#define RCCK0_DEBUGPORT 0xa28 -#define RCCK0_FALSEALARMREPORT 0xa2c -#define RCCK0_TRSSIREPORT 0xa50 -#define RCCK0_RXREPORT 0xa54 -#define RCCK0_FACOUNTERLOWER 0xa5c -#define RCCK0_FACOUNTERUPPER 0xa58 - -/* 6. PageC(0xC00) */ -#define ROFDM0_LSTF 0xc00 - -#define ROFDM0_TRXPATHENABLE 0xc04 -#define ROFDM0_TRMUXPAR 0xc08 -#define ROFDM0_TRSWISOLATION 0xc0c - -#define ROFDM0_XARXAFE 0xc10 -#define ROFDM0_XARXIQIMBALANCE 0xc14 -#define ROFDM0_XBRXAFE 0xc18 -#define ROFDM0_XBRXIQIMBALANCE 0xc1c -#define ROFDM0_XCRXAFE 0xc20 -#define ROFDM0_XCRXIQIMBALANCE 0xc24 -#define ROFDM0_XDRXAFE 0xc28 -#define ROFDM0_XDRXIQIMBALANCE 0xc2c - -#define ROFDM0_RXDETECTOR1 0xc30 -#define ROFDM0_RXDETECTOR2 0xc34 -#define ROFDM0_RXDETECTOR3 0xc38 -#define ROFDM0_RXDETECTOR4 0xc3c - -#define ROFDM0_RXDSP 0xc40 -#define ROFDM0_CFOANDDAGC 0xc44 -#define ROFDM0_CCADROPTHRESHOLD 0xc48 -#define ROFDM0_ECCATHRESHOLD 0xc4c - -#define ROFDM0_XAAGCCORE1 0xc50 -#define ROFDM0_XAAGCCORE2 0xc54 -#define ROFDM0_XBAGCCORE1 0xc58 -#define ROFDM0_XBAGCCORE2 0xc5c -#define ROFDM0_XCAGCCORE1 0xc60 -#define ROFDM0_XCAGCCORE2 0xc64 -#define ROFDM0_XDAGCCORE1 0xc68 -#define ROFDM0_XDAGCCORE2 0xc6c - -#define ROFDM0_AGCPARAMETER1 0xc70 -#define ROFDM0_AGCPARAMETER2 0xc74 -#define ROFDM0_AGCRSSITABLE 0xc78 -#define ROFDM0_HTSTFAGC 0xc7c - -#define ROFDM0_XATxIQIMBALANCE 0xc80 -#define ROFDM0_XATxAFE 0xc84 -#define ROFDM0_XBTxIQIMBALANCE 0xc88 -#define ROFDM0_XBTxAFE 0xc8c -#define ROFDM0_XCTxIQIMBALANCE 0xc90 -#define ROFDM0_XCTxAFE 0xc94 -#define ROFDM0_XDTxIQIMBALANCE 0xc98 -#define ROFDM0_XDTxAFE 0xc9c - -#define ROFDM0_RXHPPARAMETER 0xce0 -#define ROFDM0_TXPSEUDONOISEWGT 0xce4 -#define ROFDM0_FRAMESYNC 0xcf0 -#define ROFDM0_DFSREPORT 0xcf4 -#define ROFDM0_TXCOEFF1 0xca4 -#define ROFDM0_TXCOEFF2 0xca8 -#define ROFDM0_TXCOEFF3 0xcac -#define ROFDM0_TXCOEFF4 0xcb0 -#define ROFDM0_TXCOEFF5 0xcb4 -#define ROFDM0_TXCOEFF6 0xcb8 - -/* 7. PageD(0xD00) */ -#define ROFDM1_LSTF 0xd00 -#define ROFDM1_TRXPATHENABLE 0xd04 - -#define ROFDM1_CFO 0xd08 -#define ROFDM1_CSI1 0xd10 -#define ROFDM1_SBD 0xd14 -#define ROFDM1_CSI2 0xd18 -#define ROFDM1_CFOTRACKING 0xd2c -#define ROFDM1_TRXMESAURE1 0xd34 -#define ROFDM1_INTFDET 0xd3c -#define ROFDM1_PSEUDONOISESTATEAB 0xd50 -#define ROFDM1_PSEUDONOISESTATECD 0xd54 -#define ROFDM1_RXPSEUDONOISEWGT 0xd58 - -#define ROFDM_PHYCOUNTER1 0xda0 -#define ROFDM_PHYCOUNTER2 0xda4 -#define ROFDM_PHYCOUNTER3 0xda8 - -#define ROFDM_SHORTCFOAB 0xdac -#define ROFDM_SHORTCFOCD 0xdb0 -#define ROFDM_LONGCFOAB 0xdb4 -#define ROFDM_LONGCFOCD 0xdb8 -#define ROFDM_TAILCFOAB 0xdbc -#define ROFDM_TAILCFOCD 0xdc0 -#define ROFDM_PWMEASURE1 0xdc4 -#define ROFDM_PWMEASURE2 0xdc8 -#define ROFDM_BWREPORT 0xdcc -#define ROFDM_AGCREPORT 0xdd0 -#define ROFDM_RXSNR 0xdd4 -#define ROFDM_RXEVMCSI 0xdd8 -#define ROFDM_SIGReport 0xddc - -/* 8. PageE(0xE00) */ -#define RTXAGC_A_RATE18_06 0xe00 -#define RTXAGC_A_RATE54_24 0xe04 -#define RTXAGC_A_CCK1_MCS32 0xe08 -#define RTXAGC_A_MCS03_MCS00 0xe10 -#define RTXAGC_A_MCS07_MCS04 0xe14 -#define RTXAGC_A_MCS11_MCS08 0xe18 -#define RTXAGC_A_MCS15_MCS12 0xe1c - -#define RTXAGC_B_RATE18_06 0x830 -#define RTXAGC_B_RATE54_24 0x834 -#define RTXAGC_B_CCK1_55_MCS32 0x838 -#define RTXAGC_B_MCS03_MCS00 0x83c -#define RTXAGC_B_MCS07_MCS04 0x848 -#define RTXAGC_B_MCS11_MCS08 0x84c -#define RTXAGC_B_MCS15_MCS12 0x868 -#define RTXAGC_B_CCK11_A_CCK2_11 0x86c - -/* RL6052 Register definition */ -#define RF_AC 0x00 - -#define RF_IQADJ_G1 0x01 -#define RF_IQADJ_G2 0x02 -#define RF_POW_TRSW 0x05 - -#define RF_GAIN_RX 0x06 -#define RF_GAIN_TX 0x07 - -#define RF_TXM_IDAC 0x08 -#define RF_BS_IQGEN 0x0F - -#define RF_MODE1 0x10 -#define RF_MODE2 0x11 - -#define RF_RX_AGC_HP 0x12 -#define RF_TX_AGC 0x13 -#define RF_BIAS 0x14 -#define RF_IPA 0x15 -#define RF_POW_ABILITY 0x17 -#define RF_MODE_AG 0x18 -#define rRfChannel 0x18 -#define RF_CHNLBW 0x18 -#define RF_TOP 0x19 - -#define RF_RX_G1 0x1A -#define RF_RX_G2 0x1B - -#define RF_RX_BB2 0x1C -#define RF_RX_BB1 0x1D - -#define RF_RCK1 0x1E -#define RF_RCK2 0x1F - -#define RF_TX_G1 0x20 -#define RF_TX_G2 0x21 -#define RF_TX_G3 0x22 - -#define RF_TX_BB1 0x23 - -#define RF_T_METER 0x42 - -#define RF_SYN_G1 0x25 -#define RF_SYN_G2 0x26 -#define RF_SYN_G3 0x27 -#define RF_SYN_G4 0x28 -#define RF_SYN_G5 0x29 -#define RF_SYN_G6 0x2A -#define RF_SYN_G7 0x2B -#define RF_SYN_G8 0x2C - -#define RF_RCK_OS 0x30 - -#define RF_TXPA_G1 0x31 -#define RF_TXPA_G2 0x32 -#define RF_TXPA_G3 0x33 - -/* Bit Mask */ - -/* 2. Page8(0x800) */ -#define BRFMOD 0x1 -#define BCCKTXSC 0x30 -#define BCCKEN 0x1000000 -#define BOFDMEN 0x2000000 - -#define B3WIREDATALENGTH 0x800 -#define B3WIREADDRESSLENGTH 0x400 - -#define BRFSI_RFENV 0x10 - -#define BLSSIREADADDRESS 0x7f800000 -#define BLSSIREADEDGE 0x80000000 -#define BLSSIREADBACKDATA 0xfffff -/* 4. PageA(0xA00) */ -#define BCCKSIDEBAND 0x10 - -/* Other Definition */ -#define BBYTE0 0x1 -#define BBYTE1 0x2 -#define BBYTE2 0x4 -#define BBYTE3 0x8 -#define BWORD0 0x3 -#define BWORD1 0xc -#define BDWORD 0xf - -#define BMASKBYTE0 0xff -#define BMASKBYTE1 0xff00 -#define BMASKBYTE2 0xff0000 -#define BMASKBYTE3 0xff000000 -#define BMASKHWORD 0xffff0000 -#define BMASKLWORD 0x0000ffff -#define BMASKDWORD 0xffffffff -#define BMASK12BITS 0xfff -#define BMASKH4BITS 0xf0000000 -#define BMASKOFDM_D 0xffc00000 -#define BMASKCCK 0x3f3f3f3f - -#define BRFREGOFFSETMASK 0xfffff - -#endif diff --git a/trunk/drivers/net/wireless/rtlwifi/rtl8192de/rf.c b/trunk/drivers/net/wireless/rtlwifi/rtl8192de/rf.c deleted file mode 100644 index db27cebaac2c..000000000000 --- a/trunk/drivers/net/wireless/rtlwifi/rtl8192de/rf.c +++ /dev/null @@ -1,628 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2009-2010 Realtek Corporation. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * The full GNU General Public License is included in this distribution in the - * file called LICENSE. - * - * Contact Information: - * wlanfae - * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, - * Hsinchu 300, Taiwan. - * - * Larry Finger - * - *****************************************************************************/ - -#include "../wifi.h" -#include "reg.h" -#include "def.h" -#include "phy.h" -#include "rf.h" -#include "dm.h" -#include "hw.h" - -void rtl92d_phy_rf6052_set_bandwidth(struct ieee80211_hw *hw, u8 bandwidth) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_phy *rtlphy = &(rtlpriv->phy); - u8 rfpath; - - switch (bandwidth) { - case HT_CHANNEL_WIDTH_20: - for (rfpath = 0; rfpath < rtlphy->num_total_rfpath; rfpath++) { - rtlphy->rfreg_chnlval[rfpath] = ((rtlphy->rfreg_chnlval - [rfpath] & 0xfffff3ff) | 0x0400); - rtl_set_rfreg(hw, rfpath, RF_CHNLBW, BIT(10) | - BIT(11), 0x01); - - RT_TRACE(rtlpriv, COMP_RF, DBG_LOUD, - ("20M RF 0x18 = 0x%x\n", - rtlphy->rfreg_chnlval[rfpath])); - } - - break; - case HT_CHANNEL_WIDTH_20_40: - for (rfpath = 0; rfpath < rtlphy->num_total_rfpath; rfpath++) { - rtlphy->rfreg_chnlval[rfpath] = - ((rtlphy->rfreg_chnlval[rfpath] & 0xfffff3ff)); - rtl_set_rfreg(hw, rfpath, RF_CHNLBW, BIT(10) | BIT(11), - 0x00); - RT_TRACE(rtlpriv, COMP_RF, DBG_LOUD, - ("40M RF 0x18 = 0x%x\n", - rtlphy->rfreg_chnlval[rfpath])); - } - break; - default: - RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("unknown bandwidth: %#X\n", bandwidth)); - break; - } -} - -void rtl92d_phy_rf6052_set_cck_txpower(struct ieee80211_hw *hw, - u8 *ppowerlevel) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_phy *rtlphy = &(rtlpriv->phy); - struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); - struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw)); - u32 tx_agc[2] = {0, 0}, tmpval; - bool turbo_scanoff = false; - u8 idx1, idx2; - u8 *ptr; - - if (rtlefuse->eeprom_regulatory != 0) - turbo_scanoff = true; - if (mac->act_scanning) { - tx_agc[RF90_PATH_A] = 0x3f3f3f3f; - tx_agc[RF90_PATH_B] = 0x3f3f3f3f; - if (turbo_scanoff) { - for (idx1 = RF90_PATH_A; idx1 <= RF90_PATH_B; idx1++) { - tx_agc[idx1] = ppowerlevel[idx1] | - (ppowerlevel[idx1] << 8) | - (ppowerlevel[idx1] << 16) | - (ppowerlevel[idx1] << 24); - } - } - } else { - for (idx1 = RF90_PATH_A; idx1 <= RF90_PATH_B; idx1++) { - tx_agc[idx1] = ppowerlevel[idx1] | - (ppowerlevel[idx1] << 8) | - (ppowerlevel[idx1] << 16) | - (ppowerlevel[idx1] << 24); - } - if (rtlefuse->eeprom_regulatory == 0) { - tmpval = (rtlphy->mcs_txpwrlevel_origoffset[0][6]) + - (rtlphy->mcs_txpwrlevel_origoffset[0][7] << 8); - tx_agc[RF90_PATH_A] += tmpval; - tmpval = (rtlphy->mcs_txpwrlevel_origoffset[0][14]) + - (rtlphy->mcs_txpwrlevel_origoffset[0][15] << 24); - tx_agc[RF90_PATH_B] += tmpval; - } - } - - for (idx1 = RF90_PATH_A; idx1 <= RF90_PATH_B; idx1++) { - ptr = (u8 *) (&(tx_agc[idx1])); - for (idx2 = 0; idx2 < 4; idx2++) { - if (*ptr > RF6052_MAX_TX_PWR) - *ptr = RF6052_MAX_TX_PWR; - ptr++; - } - } - - tmpval = tx_agc[RF90_PATH_A] & 0xff; - rtl_set_bbreg(hw, RTXAGC_A_CCK1_MCS32, BMASKBYTE1, tmpval); - RTPRINT(rtlpriv, FPHY, PHY_TXPWR, - ("CCK PWR 1M (rf-A) = 0x%x (reg 0x%x)\n", tmpval, - RTXAGC_A_CCK1_MCS32)); - tmpval = tx_agc[RF90_PATH_A] >> 8; - rtl_set_bbreg(hw, RTXAGC_B_CCK11_A_CCK2_11, 0xffffff00, tmpval); - RTPRINT(rtlpriv, FPHY, PHY_TXPWR, - ("CCK PWR 2~11M (rf-A) = 0x%x (reg 0x%x)\n", tmpval, - RTXAGC_B_CCK11_A_CCK2_11)); - tmpval = tx_agc[RF90_PATH_B] >> 24; - rtl_set_bbreg(hw, RTXAGC_B_CCK11_A_CCK2_11, BMASKBYTE0, tmpval); - RTPRINT(rtlpriv, FPHY, PHY_TXPWR, - ("CCK PWR 11M (rf-B) = 0x%x (reg 0x%x)\n", tmpval, - RTXAGC_B_CCK11_A_CCK2_11)); - tmpval = tx_agc[RF90_PATH_B] & 0x00ffffff; - rtl_set_bbreg(hw, RTXAGC_B_CCK1_55_MCS32, 0xffffff00, tmpval); - RTPRINT(rtlpriv, FPHY, PHY_TXPWR, - ("CCK PWR 1~5.5M (rf-B) = 0x%x (reg 0x%x)\n", tmpval, - RTXAGC_B_CCK1_55_MCS32)); -} - -static void _rtl92d_phy_get_power_base(struct ieee80211_hw *hw, - u8 *ppowerlevel, u8 channel, - u32 *ofdmbase, u32 *mcsbase) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_phy *rtlphy = &(rtlpriv->phy); - struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw)); - u32 powerbase0, powerbase1; - u8 legacy_pwrdiff, ht20_pwrdiff; - u8 i, powerlevel[2]; - - for (i = 0; i < 2; i++) { - powerlevel[i] = ppowerlevel[i]; - legacy_pwrdiff = rtlefuse->txpwr_legacyhtdiff[i][channel - 1]; - powerbase0 = powerlevel[i] + legacy_pwrdiff; - powerbase0 = (powerbase0 << 24) | (powerbase0 << 16) | - (powerbase0 << 8) | powerbase0; - *(ofdmbase + i) = powerbase0; - RTPRINT(rtlpriv, FPHY, PHY_TXPWR, - (" [OFDM power base index rf(%c) = 0x%x]\n", - ((i == 0) ? 'A' : 'B'), *(ofdmbase + i))); - } - - for (i = 0; i < 2; i++) { - if (rtlphy->current_chan_bw == HT_CHANNEL_WIDTH_20) { - ht20_pwrdiff = rtlefuse->txpwr_ht20diff[i][channel - 1]; - powerlevel[i] += ht20_pwrdiff; - } - powerbase1 = powerlevel[i]; - powerbase1 = (powerbase1 << 24) | (powerbase1 << 16) | - (powerbase1 << 8) | powerbase1; - *(mcsbase + i) = powerbase1; - RTPRINT(rtlpriv, FPHY, PHY_TXPWR, - (" [MCS power base index rf(%c) = 0x%x]\n", - ((i == 0) ? 'A' : 'B'), *(mcsbase + i))); - } -} - -static u8 _rtl92d_phy_get_chnlgroup_bypg(u8 chnlindex) -{ - u8 group; - u8 channel_info[59] = { - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, - 60, 62, 64, 100, 102, 104, 106, 108, 110, 112, - 114, 116, 118, 120, 122, 124, 126, 128, 130, 132, - 134, 136, 138, 140, 149, 151, 153, 155, 157, 159, - 161, 163, 165 - }; - - if (channel_info[chnlindex] <= 3) /* Chanel 1-3 */ - group = 0; - else if (channel_info[chnlindex] <= 9) /* Channel 4-9 */ - group = 1; - else if (channel_info[chnlindex] <= 14) /* Channel 10-14 */ - group = 2; - else if (channel_info[chnlindex] <= 64) - group = 6; - else if (channel_info[chnlindex] <= 140) - group = 7; - else - group = 8; - return group; -} - -static void _rtl92d_get_txpower_writeval_by_regulatory(struct ieee80211_hw *hw, - u8 channel, u8 index, - u32 *powerbase0, - u32 *powerbase1, - u32 *p_outwriteval) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_phy *rtlphy = &(rtlpriv->phy); - struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw)); - u8 i, chnlgroup = 0, pwr_diff_limit[4]; - u32 writeval = 0, customer_limit, rf; - - for (rf = 0; rf < 2; rf++) { - switch (rtlefuse->eeprom_regulatory) { - case 0: - chnlgroup = 0; - writeval = rtlphy->mcs_txpwrlevel_origoffset - [chnlgroup][index + - (rf ? 8 : 0)] + ((index < 2) ? - powerbase0[rf] : - powerbase1[rf]); - RTPRINT(rtlpriv, FPHY, PHY_TXPWR, ("RTK better " - "performance, writeval(%c) = 0x%x\n", - ((rf == 0) ? 'A' : 'B'), writeval)); - break; - case 1: - if (rtlphy->pwrgroup_cnt == 1) - chnlgroup = 0; - if (rtlphy->pwrgroup_cnt >= MAX_PG_GROUP) { - chnlgroup = _rtl92d_phy_get_chnlgroup_bypg( - channel - 1); - if (rtlphy->current_chan_bw == - HT_CHANNEL_WIDTH_20) - chnlgroup++; - else - chnlgroup += 4; - writeval = rtlphy->mcs_txpwrlevel_origoffset - [chnlgroup][index + - (rf ? 8 : 0)] + ((index < 2) ? - powerbase0[rf] : - powerbase1[rf]); - RTPRINT(rtlpriv, FPHY, PHY_TXPWR, - ("Realtek regulatory, " - "20MHz, writeval(%c) = 0x%x\n", - ((rf == 0) ? 'A' : 'B'), - writeval)); - } - break; - case 2: - writeval = ((index < 2) ? powerbase0[rf] : - powerbase1[rf]); - RTPRINT(rtlpriv, FPHY, PHY_TXPWR, ("Better regulatory, " - "writeval(%c) = 0x%x\n", - ((rf == 0) ? 'A' : 'B'), writeval)); - break; - case 3: - chnlgroup = 0; - if (rtlphy->current_chan_bw == HT_CHANNEL_WIDTH_20_40) { - RTPRINT(rtlpriv, FPHY, PHY_TXPWR, - ("customer's limit, 40MHz rf(%c) = " - "0x%x\n", ((rf == 0) ? 'A' : 'B'), - rtlefuse->pwrgroup_ht40[rf] - [channel - 1])); - } else { - RTPRINT(rtlpriv, FPHY, PHY_TXPWR, - ("customer's limit, 20MHz rf(%c) = " - "0x%x\n", ((rf == 0) ? 'A' : 'B'), - rtlefuse->pwrgroup_ht20[rf] - [channel - 1])); - } - for (i = 0; i < 4; i++) { - pwr_diff_limit[i] = - (u8)((rtlphy->mcs_txpwrlevel_origoffset - [chnlgroup][index + (rf ? 8 : 0)] & - (0x7f << (i * 8))) >> (i * 8)); - if (rtlphy->current_chan_bw == - HT_CHANNEL_WIDTH_20_40) { - if (pwr_diff_limit[i] > - rtlefuse->pwrgroup_ht40[rf] - [channel - 1]) - pwr_diff_limit[i] = - rtlefuse->pwrgroup_ht40 - [rf][channel - 1]; - } else { - if (pwr_diff_limit[i] > - rtlefuse->pwrgroup_ht20[rf][ - channel - 1]) - pwr_diff_limit[i] = - rtlefuse->pwrgroup_ht20[rf] - [channel - 1]; - } - } - customer_limit = (pwr_diff_limit[3] << 24) | - (pwr_diff_limit[2] << 16) | - (pwr_diff_limit[1] << 8) | - (pwr_diff_limit[0]); - RTPRINT(rtlpriv, FPHY, PHY_TXPWR, - ("Customer's limit rf(%c) = 0x%x\n", - ((rf == 0) ? 'A' : 'B'), customer_limit)); - writeval = customer_limit + ((index < 2) ? - powerbase0[rf] : powerbase1[rf]); - RTPRINT(rtlpriv, FPHY, PHY_TXPWR, - ("Customer, writeval rf(%c)= 0x%x\n", - ((rf == 0) ? 'A' : 'B'), writeval)); - break; - default: - chnlgroup = 0; - writeval = rtlphy->mcs_txpwrlevel_origoffset - [chnlgroup][index + - (rf ? 8 : 0)] + ((index < 2) ? - powerbase0[rf] : powerbase1[rf]); - RTPRINT(rtlpriv, FPHY, PHY_TXPWR, - ("RTK better performance, writeval " - "rf(%c) = 0x%x\n", - ((rf == 0) ? 'A' : 'B'), writeval)); - break; - } - *(p_outwriteval + rf) = writeval; - } -} - -static void _rtl92d_write_ofdm_power_reg(struct ieee80211_hw *hw, - u8 index, u32 *pvalue) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_phy *rtlphy = &(rtlpriv->phy); - static u16 regoffset_a[6] = { - RTXAGC_A_RATE18_06, RTXAGC_A_RATE54_24, - RTXAGC_A_MCS03_MCS00, RTXAGC_A_MCS07_MCS04, - RTXAGC_A_MCS11_MCS08, RTXAGC_A_MCS15_MCS12 - }; - static u16 regoffset_b[6] = { - RTXAGC_B_RATE18_06, RTXAGC_B_RATE54_24, - RTXAGC_B_MCS03_MCS00, RTXAGC_B_MCS07_MCS04, - RTXAGC_B_MCS11_MCS08, RTXAGC_B_MCS15_MCS12 - }; - u8 i, rf, pwr_val[4]; - u32 writeval; - u16 regoffset; - - for (rf = 0; rf < 2; rf++) { - writeval = pvalue[rf]; - for (i = 0; i < 4; i++) { - pwr_val[i] = (u8) ((writeval & (0x7f << - (i * 8))) >> (i * 8)); - if (pwr_val[i] > RF6052_MAX_TX_PWR) - pwr_val[i] = RF6052_MAX_TX_PWR; - } - writeval = (pwr_val[3] << 24) | (pwr_val[2] << 16) | - (pwr_val[1] << 8) | pwr_val[0]; - if (rf == 0) - regoffset = regoffset_a[index]; - else - regoffset = regoffset_b[index]; - rtl_set_bbreg(hw, regoffset, BMASKDWORD, writeval); - RTPRINT(rtlpriv, FPHY, PHY_TXPWR, - ("Set 0x%x = %08x\n", regoffset, writeval)); - if (((get_rf_type(rtlphy) == RF_2T2R) && - (regoffset == RTXAGC_A_MCS15_MCS12 || - regoffset == RTXAGC_B_MCS15_MCS12)) || - ((get_rf_type(rtlphy) != RF_2T2R) && - (regoffset == RTXAGC_A_MCS07_MCS04 || - regoffset == RTXAGC_B_MCS07_MCS04))) { - writeval = pwr_val[3]; - if (regoffset == RTXAGC_A_MCS15_MCS12 || - regoffset == RTXAGC_A_MCS07_MCS04) - regoffset = 0xc90; - if (regoffset == RTXAGC_B_MCS15_MCS12 || - regoffset == RTXAGC_B_MCS07_MCS04) - regoffset = 0xc98; - for (i = 0; i < 3; i++) { - if (i != 2) - writeval = (writeval > 8) ? - (writeval - 8) : 0; - else - writeval = (writeval > 6) ? - (writeval - 6) : 0; - rtl_write_byte(rtlpriv, (u32) (regoffset + i), - (u8) writeval); - } - } - } -} - -void rtl92d_phy_rf6052_set_ofdm_txpower(struct ieee80211_hw *hw, - u8 *ppowerlevel, u8 channel) -{ - u32 writeval[2], powerbase0[2], powerbase1[2]; - u8 index; - - _rtl92d_phy_get_power_base(hw, ppowerlevel, channel, - &powerbase0[0], &powerbase1[0]); - for (index = 0; index < 6; index++) { - _rtl92d_get_txpower_writeval_by_regulatory(hw, - channel, index, &powerbase0[0], - &powerbase1[0], &writeval[0]); - _rtl92d_write_ofdm_power_reg(hw, index, &writeval[0]); - } -} - -bool rtl92d_phy_enable_anotherphy(struct ieee80211_hw *hw, bool bmac0) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_hal *rtlhal = &(rtlpriv->rtlhal); - u8 u1btmp; - u8 direct = bmac0 ? BIT(3) | BIT(2) : BIT(3); - u8 mac_reg = bmac0 ? REG_MAC1 : REG_MAC0; - u8 mac_on_bit = bmac0 ? MAC1_ON : MAC0_ON; - bool bresult = true; /* true: need to enable BB/RF power */ - - rtlhal->during_mac0init_radiob = false; - rtlhal->during_mac1init_radioa = false; - RT_TRACE(rtlpriv, COMP_RF, DBG_LOUD, ("===>\n")); - /* MAC0 Need PHY1 load radio_b.txt . Driver use DBI to write. */ - u1btmp = rtl_read_byte(rtlpriv, mac_reg); - if (!(u1btmp & mac_on_bit)) { - RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, ("enable BB & RF\n")); - /* Enable BB and RF power */ - rtl92de_write_dword_dbi(hw, REG_SYS_ISO_CTRL, - rtl92de_read_dword_dbi(hw, REG_SYS_ISO_CTRL, direct) | - BIT(29) | BIT(16) | BIT(17), direct); - } else { - /* We think if MAC1 is ON,then radio_a.txt - * and radio_b.txt has been load. */ - bresult = false; - } - RT_TRACE(rtlpriv, COMP_RF, DBG_LOUD, ("<===\n")); - return bresult; - -} - -void rtl92d_phy_powerdown_anotherphy(struct ieee80211_hw *hw, bool bmac0) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_hal *rtlhal = &(rtlpriv->rtlhal); - u8 u1btmp; - u8 direct = bmac0 ? BIT(3) | BIT(2) : BIT(3); - u8 mac_reg = bmac0 ? REG_MAC1 : REG_MAC0; - u8 mac_on_bit = bmac0 ? MAC1_ON : MAC0_ON; - - rtlhal->during_mac0init_radiob = false; - rtlhal->during_mac1init_radioa = false; - RT_TRACE(rtlpriv, COMP_RF, DBG_LOUD, ("====>\n")); - /* check MAC0 enable or not again now, if - * enabled, not power down radio A. */ - u1btmp = rtl_read_byte(rtlpriv, mac_reg); - if (!(u1btmp & mac_on_bit)) { - RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, ("power down\n")); - /* power down RF radio A according to YuNan's advice. */ - rtl92de_write_dword_dbi(hw, RFPGA0_XA_LSSIPARAMETER, - 0x00000000, direct); - } - RT_TRACE(rtlpriv, COMP_RF, DBG_LOUD, ("<====\n")); -} - -bool rtl92d_phy_rf6052_config(struct ieee80211_hw *hw) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_phy *rtlphy = &(rtlpriv->phy); - bool rtstatus = true; - struct rtl_hal *rtlhal = &(rtlpriv->rtlhal); - u32 u4_regvalue = 0; - u8 rfpath; - struct bb_reg_def *pphyreg; - bool mac1_initradioa_first = false, mac0_initradiob_first = false; - bool need_pwrdown_radioa = false, need_pwrdown_radiob = false; - bool true_bpath = false; - - if (rtlphy->rf_type == RF_1T1R) - rtlphy->num_total_rfpath = 1; - else - rtlphy->num_total_rfpath = 2; - - /* Single phy mode: use radio_a radio_b config path_A path_B */ - /* seperately by MAC0, and MAC1 needn't configure RF; */ - /* Dual PHY mode:MAC0 use radio_a config 1st phy path_A, */ - /* MAC1 use radio_b config 2nd PHY path_A. */ - /* DMDP,MAC0 on G band,MAC1 on A band. */ - if (rtlhal->macphymode == DUALMAC_DUALPHY) { - if (rtlhal->current_bandtype == BAND_ON_2_4G && - rtlhal->interfaceindex == 0) { - /* MAC0 needs PHY1 load radio_b.txt. - * Driver use DBI to write. */ - if (rtl92d_phy_enable_anotherphy(hw, true)) { - rtlphy->num_total_rfpath = 2; - mac0_initradiob_first = true; - } else { - /* We think if MAC1 is ON,then radio_a.txt and - * radio_b.txt has been load. */ - return rtstatus; - } - } else if (rtlhal->current_bandtype == BAND_ON_5G && - rtlhal->interfaceindex == 1) { - /* MAC1 needs PHY0 load radio_a.txt. - * Driver use DBI to write. */ - if (rtl92d_phy_enable_anotherphy(hw, false)) { - rtlphy->num_total_rfpath = 2; - mac1_initradioa_first = true; - } else { - /* We think if MAC0 is ON,then radio_a.txt and - * radio_b.txt has been load. */ - return rtstatus; - } - } else if (rtlhal->interfaceindex == 1) { - /* MAC0 enabled, only init radia B. */ - true_bpath = true; - } - } - - for (rfpath = 0; rfpath < rtlphy->num_total_rfpath; rfpath++) { - /* Mac1 use PHY0 write */ - if (mac1_initradioa_first) { - if (rfpath == RF90_PATH_A) { - rtlhal->during_mac1init_radioa = true; - need_pwrdown_radioa = true; - } else if (rfpath == RF90_PATH_B) { - rtlhal->during_mac1init_radioa = false; - mac1_initradioa_first = false; - rfpath = RF90_PATH_A; - true_bpath = true; - rtlphy->num_total_rfpath = 1; - } - } else if (mac0_initradiob_first) { - /* Mac0 use PHY1 write */ - if (rfpath == RF90_PATH_A) - rtlhal->during_mac0init_radiob = false; - if (rfpath == RF90_PATH_B) { - rtlhal->during_mac0init_radiob = true; - mac0_initradiob_first = false; - need_pwrdown_radiob = true; - rfpath = RF90_PATH_A; - true_bpath = true; - rtlphy->num_total_rfpath = 1; - } - } - pphyreg = &rtlphy->phyreg_def[rfpath]; - switch (rfpath) { - case RF90_PATH_A: - case RF90_PATH_C: - u4_regvalue = rtl_get_bbreg(hw, pphyreg->rfintfs, - BRFSI_RFENV); - break; - case RF90_PATH_B: - case RF90_PATH_D: - u4_regvalue = rtl_get_bbreg(hw, pphyreg->rfintfs, - BRFSI_RFENV << 16); - break; - } - rtl_set_bbreg(hw, pphyreg->rfintfe, BRFSI_RFENV << 16, 0x1); - udelay(1); - rtl_set_bbreg(hw, pphyreg->rfintfo, BRFSI_RFENV, 0x1); - udelay(1); - /* Set bit number of Address and Data for RF register */ - /* Set 1 to 4 bits for 8255 */ - rtl_set_bbreg(hw, pphyreg->rfhssi_para2, - B3WIREADDRESSLENGTH, 0x0); - udelay(1); - /* Set 0 to 12 bits for 8255 */ - rtl_set_bbreg(hw, pphyreg->rfhssi_para2, B3WIREDATALENGTH, 0x0); - udelay(1); - switch (rfpath) { - case RF90_PATH_A: - if (true_bpath) - rtstatus = rtl92d_phy_config_rf_with_headerfile( - hw, radiob_txt, - (enum radio_path)rfpath); - else - rtstatus = rtl92d_phy_config_rf_with_headerfile( - hw, radioa_txt, - (enum radio_path)rfpath); - break; - case RF90_PATH_B: - rtstatus = - rtl92d_phy_config_rf_with_headerfile(hw, radiob_txt, - (enum radio_path) rfpath); - break; - case RF90_PATH_C: - break; - case RF90_PATH_D: - break; - } - switch (rfpath) { - case RF90_PATH_A: - case RF90_PATH_C: - rtl_set_bbreg(hw, pphyreg->rfintfs, BRFSI_RFENV, - u4_regvalue); - break; - case RF90_PATH_B: - case RF90_PATH_D: - rtl_set_bbreg(hw, pphyreg->rfintfs, BRFSI_RFENV << 16, - u4_regvalue); - break; - } - if (rtstatus != true) { - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - ("Radio[%d] Fail!!", rfpath)); - goto phy_rf_cfg_fail; - } - - } - - /* check MAC0 enable or not again, if enabled, - * not power down radio A. */ - /* check MAC1 enable or not again, if enabled, - * not power down radio B. */ - if (need_pwrdown_radioa) - rtl92d_phy_powerdown_anotherphy(hw, false); - else if (need_pwrdown_radiob) - rtl92d_phy_powerdown_anotherphy(hw, true); - RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, ("<---\n")); - return rtstatus; - -phy_rf_cfg_fail: - return rtstatus; -} diff --git a/trunk/drivers/net/wireless/rtlwifi/rtl8192de/rf.h b/trunk/drivers/net/wireless/rtlwifi/rtl8192de/rf.h deleted file mode 100644 index 74b9cfc39a83..000000000000 --- a/trunk/drivers/net/wireless/rtlwifi/rtl8192de/rf.h +++ /dev/null @@ -1,44 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2009-2010 Realtek Corporation. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * The full GNU General Public License is included in this distribution in the - * file called LICENSE. - * - * Contact Information: - * wlanfae - * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, - * Hsinchu 300, Taiwan. - * - * Larry Finger - * - *****************************************************************************/ - -#ifndef __RTL92D_RF_H__ -#define __RTL92D_RF_H__ - -extern void rtl92d_phy_rf6052_set_bandwidth(struct ieee80211_hw *hw, - u8 bandwidth); -extern void rtl92d_phy_rf6052_set_cck_txpower(struct ieee80211_hw *hw, - u8 *ppowerlevel); -extern void rtl92d_phy_rf6052_set_ofdm_txpower(struct ieee80211_hw *hw, - u8 *ppowerlevel, u8 channel); -extern bool rtl92d_phy_rf6052_config(struct ieee80211_hw *hw); -extern bool rtl92d_phy_enable_anotherphy(struct ieee80211_hw *hw, bool bmac0); -extern void rtl92d_phy_powerdown_anotherphy(struct ieee80211_hw *hw, - bool bmac0); - -#endif diff --git a/trunk/drivers/net/wireless/rtlwifi/rtl8192de/sw.c b/trunk/drivers/net/wireless/rtlwifi/rtl8192de/sw.c deleted file mode 100644 index 08837744f6f1..000000000000 --- a/trunk/drivers/net/wireless/rtlwifi/rtl8192de/sw.c +++ /dev/null @@ -1,423 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2009-2010 Realtek Corporation. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * The full GNU General Public License is included in this distribution in the - * file called LICENSE. - * - * Contact Information: - * wlanfae - * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, - * Hsinchu 300, Taiwan. - * - * Larry Finger - * - *****************************************************************************/ - -#include - -#include "../wifi.h" -#include "../core.h" -#include "../pci.h" -#include "reg.h" -#include "def.h" -#include "phy.h" -#include "dm.h" -#include "hw.h" -#include "sw.h" -#include "trx.h" -#include "led.h" - -static void rtl92d_init_aspm_vars(struct ieee80211_hw *hw) -{ - struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); - - /*close ASPM for AMD defaultly */ - rtlpci->const_amdpci_aspm = 0; - - /* - * ASPM PS mode. - * 0 - Disable ASPM, - * 1 - Enable ASPM without Clock Req, - * 2 - Enable ASPM with Clock Req, - * 3 - Alwyas Enable ASPM with Clock Req, - * 4 - Always Enable ASPM without Clock Req. - * set defult to RTL8192CE:3 RTL8192E:2 - * */ - rtlpci->const_pci_aspm = 3; - - /*Setting for PCI-E device */ - rtlpci->const_devicepci_aspm_setting = 0x03; - - /*Setting for PCI-E bridge */ - rtlpci->const_hostpci_aspm_setting = 0x02; - - /* - * In Hw/Sw Radio Off situation. - * 0 - Default, - * 1 - From ASPM setting without low Mac Pwr, - * 2 - From ASPM setting with low Mac Pwr, - * 3 - Bus D3 - * set default to RTL8192CE:0 RTL8192SE:2 - */ - rtlpci->const_hwsw_rfoff_d3 = 0; - - /* - * This setting works for those device with - * backdoor ASPM setting such as EPHY setting. - * 0 - Not support ASPM, - * 1 - Support ASPM, - * 2 - According to chipset. - */ - rtlpci->const_support_pciaspm = 1; -} - -static int rtl92d_init_sw_vars(struct ieee80211_hw *hw) -{ - int err; - u8 tid; - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); - const struct firmware *firmware; - static int header_print; - - rtlpriv->dm.dm_initialgain_enable = true; - rtlpriv->dm.dm_flag = 0; - rtlpriv->dm.disable_framebursting = 0; - rtlpriv->dm.thermalvalue = 0; - rtlpriv->dm.useramask = 1; - - /* dual mac */ - if (rtlpriv->rtlhal.current_bandtype == BAND_ON_5G) - rtlpriv->phy.current_channel = 36; - else - rtlpriv->phy.current_channel = 1; - - if (rtlpriv->rtlhal.macphymode != SINGLEMAC_SINGLEPHY) { - rtlpriv->rtlhal.disable_amsdu_8k = true; - /* No long RX - reduce fragmentation */ - rtlpci->rxbuffersize = 4096; - } - - rtlpci->transmit_config = CFENDFORM | BIT(12) | BIT(13); - - rtlpci->receive_config = ( - RCR_APPFCS - | RCR_AMF - | RCR_ADF - | RCR_APP_MIC - | RCR_APP_ICV - | RCR_AICV - | RCR_ACRC32 - | RCR_AB - | RCR_AM - | RCR_APM - | RCR_APP_PHYST_RXFF - | RCR_HTC_LOC_CTRL - ); - - rtlpci->irq_mask[0] = (u32) ( - IMR_ROK - | IMR_VODOK - | IMR_VIDOK - | IMR_BEDOK - | IMR_BKDOK - | IMR_MGNTDOK - | IMR_HIGHDOK - | IMR_BDOK - | IMR_RDU - | IMR_RXFOVW - ); - - rtlpci->irq_mask[1] = (u32) (IMR_CPWM | IMR_C2HCMD); - - /* for LPS & IPS */ - rtlpriv->psc.inactiveps = rtlpriv->cfg->mod_params->inactiveps; - rtlpriv->psc.swctrl_lps = rtlpriv->cfg->mod_params->swctrl_lps; - rtlpriv->psc.fwctrl_lps = rtlpriv->cfg->mod_params->fwctrl_lps; - rtlpriv->psc.reg_fwctrl_lps = 3; - rtlpriv->psc.reg_max_lps_awakeintvl = 5; - /* for ASPM, you can close aspm through - * set const_support_pciaspm = 0 */ - rtl92d_init_aspm_vars(hw); - - if (rtlpriv->psc.reg_fwctrl_lps == 1) - rtlpriv->psc.fwctrl_psmode = FW_PS_MIN_MODE; - else if (rtlpriv->psc.reg_fwctrl_lps == 2) - rtlpriv->psc.fwctrl_psmode = FW_PS_MAX_MODE; - else if (rtlpriv->psc.reg_fwctrl_lps == 3) - rtlpriv->psc.fwctrl_psmode = FW_PS_DTIM_MODE; - - /* for firmware buf */ - rtlpriv->rtlhal.pfirmware = vzalloc(0x8000); - if (!rtlpriv->rtlhal.pfirmware) { - RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("Can't alloc buffer for fw.\n")); - return 1; - } - - if (!header_print) { - printk(KERN_INFO "rtl8192de: Driver for Realtek RTL8192DE" - " WLAN interface"); - printk(KERN_INFO "rtl8192de: Loading firmware file %s\n", - rtlpriv->cfg->fw_name); - header_print++; - } - /* request fw */ - err = request_firmware(&firmware, rtlpriv->cfg->fw_name, - rtlpriv->io.dev); - if (err) { - RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("Failed to request firmware!\n")); - return 1; - } - if (firmware->size > 0x8000) { - RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - ("Firmware is too big!\n")); - release_firmware(firmware); - return 1; - } - memcpy(rtlpriv->rtlhal.pfirmware, firmware->data, firmware->size); - rtlpriv->rtlhal.fwsize = firmware->size; - release_firmware(firmware); - - /* for early mode */ - rtlpriv->rtlhal.earlymode_enable = true; - for (tid = 0; tid < 8; tid++) - skb_queue_head_init(&rtlpriv->mac80211.skb_waitq[tid]); - return 0; -} - -static void rtl92d_deinit_sw_vars(struct ieee80211_hw *hw) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - u8 tid; - - if (rtlpriv->rtlhal.pfirmware) { - vfree(rtlpriv->rtlhal.pfirmware); - rtlpriv->rtlhal.pfirmware = NULL; - } - for (tid = 0; tid < 8; tid++) - skb_queue_purge(&rtlpriv->mac80211.skb_waitq[tid]); -} - -static struct rtl_hal_ops rtl8192de_hal_ops = { - .init_sw_vars = rtl92d_init_sw_vars, - .deinit_sw_vars = rtl92d_deinit_sw_vars, - .read_eeprom_info = rtl92de_read_eeprom_info, - .interrupt_recognized = rtl92de_interrupt_recognized, - .hw_init = rtl92de_hw_init, - .hw_disable = rtl92de_card_disable, - .hw_suspend = rtl92de_suspend, - .hw_resume = rtl92de_resume, - .enable_interrupt = rtl92de_enable_interrupt, - .disable_interrupt = rtl92de_disable_interrupt, - .set_network_type = rtl92de_set_network_type, - .set_chk_bssid = rtl92de_set_check_bssid, - .set_qos = rtl92de_set_qos, - .set_bcn_reg = rtl92de_set_beacon_related_registers, - .set_bcn_intv = rtl92de_set_beacon_interval, - .update_interrupt_mask = rtl92de_update_interrupt_mask, - .get_hw_reg = rtl92de_get_hw_reg, - .set_hw_reg = rtl92de_set_hw_reg, - .update_rate_tbl = rtl92de_update_hal_rate_tbl, - .fill_tx_desc = rtl92de_tx_fill_desc, - .fill_tx_cmddesc = rtl92de_tx_fill_cmddesc, - .query_rx_desc = rtl92de_rx_query_desc, - .set_channel_access = rtl92de_update_channel_access_setting, - .radio_onoff_checking = rtl92de_gpio_radio_on_off_checking, - .set_bw_mode = rtl92d_phy_set_bw_mode, - .switch_channel = rtl92d_phy_sw_chnl, - .dm_watchdog = rtl92d_dm_watchdog, - .scan_operation_backup = rtl92d_phy_scan_operation_backup, - .set_rf_power_state = rtl92d_phy_set_rf_power_state, - .led_control = rtl92de_led_control, - .set_desc = rtl92de_set_desc, - .get_desc = rtl92de_get_desc, - .tx_polling = rtl92de_tx_polling, - .enable_hw_sec = rtl92de_enable_hw_security_config, - .set_key = rtl92de_set_key, - .init_sw_leds = rtl92de_init_sw_leds, - .get_bbreg = rtl92d_phy_query_bb_reg, - .set_bbreg = rtl92d_phy_set_bb_reg, - .get_rfreg = rtl92d_phy_query_rf_reg, - .set_rfreg = rtl92d_phy_set_rf_reg, - .linked_set_reg = rtl92d_linked_set_reg, -}; - -static struct rtl_mod_params rtl92de_mod_params = { - .sw_crypto = false, - .inactiveps = true, - .swctrl_lps = true, - .fwctrl_lps = false, -}; - -static struct rtl_hal_cfg rtl92de_hal_cfg = { - .bar_id = 2, - .write_readback = true, - .name = "rtl8192de", - .fw_name = "rtlwifi/rtl8192defw.bin", - .ops = &rtl8192de_hal_ops, - .mod_params = &rtl92de_mod_params, - - .maps[SYS_ISO_CTRL] = REG_SYS_ISO_CTRL, - .maps[SYS_FUNC_EN] = REG_SYS_FUNC_EN, - .maps[SYS_CLK] = REG_SYS_CLKR, - .maps[MAC_RCR_AM] = RCR_AM, - .maps[MAC_RCR_AB] = RCR_AB, - .maps[MAC_RCR_ACRC32] = RCR_ACRC32, - .maps[MAC_RCR_ACF] = RCR_ACF, - .maps[MAC_RCR_AAP] = RCR_AAP, - - .maps[EFUSE_TEST] = REG_EFUSE_TEST, - .maps[EFUSE_CTRL] = REG_EFUSE_CTRL, - .maps[EFUSE_CLK] = 0, /* just for 92se */ - .maps[EFUSE_CLK_CTRL] = REG_EFUSE_CTRL, - .maps[EFUSE_PWC_EV12V] = PWC_EV12V, - .maps[EFUSE_FEN_ELDR] = FEN_ELDR, - .maps[EFUSE_LOADER_CLK_EN] = LOADER_CLK_EN, - .maps[EFUSE_ANA8M] = 0, /* just for 92se */ - .maps[EFUSE_HWSET_MAX_SIZE] = HWSET_MAX_SIZE, - .maps[EFUSE_MAX_SECTION_MAP] = EFUSE_MAX_SECTION, - .maps[EFUSE_REAL_CONTENT_SIZE] = EFUSE_REAL_CONTENT_LEN, - - .maps[RWCAM] = REG_CAMCMD, - .maps[WCAMI] = REG_CAMWRITE, - .maps[RCAMO] = REG_CAMREAD, - .maps[CAMDBG] = REG_CAMDBG, - .maps[SECR] = REG_SECCFG, - .maps[SEC_CAM_NONE] = CAM_NONE, - .maps[SEC_CAM_WEP40] = CAM_WEP40, - .maps[SEC_CAM_TKIP] = CAM_TKIP, - .maps[SEC_CAM_AES] = CAM_AES, - .maps[SEC_CAM_WEP104] = CAM_WEP104, - - .maps[RTL_IMR_BCNDMAINT6] = IMR_BCNDMAINT6, - .maps[RTL_IMR_BCNDMAINT5] = IMR_BCNDMAINT5, - .maps[RTL_IMR_BCNDMAINT4] = IMR_BCNDMAINT4, - .maps[RTL_IMR_BCNDMAINT3] = IMR_BCNDMAINT3, - .maps[RTL_IMR_BCNDMAINT2] = IMR_BCNDMAINT2, - .maps[RTL_IMR_BCNDMAINT1] = IMR_BCNDMAINT1, - .maps[RTL_IMR_BCNDOK8] = IMR_BCNDOK8, - .maps[RTL_IMR_BCNDOK7] = IMR_BCNDOK7, - .maps[RTL_IMR_BCNDOK6] = IMR_BCNDOK6, - .maps[RTL_IMR_BCNDOK5] = IMR_BCNDOK5, - .maps[RTL_IMR_BCNDOK4] = IMR_BCNDOK4, - .maps[RTL_IMR_BCNDOK3] = IMR_BCNDOK3, - .maps[RTL_IMR_BCNDOK2] = IMR_BCNDOK2, - .maps[RTL_IMR_BCNDOK1] = IMR_BCNDOK1, - .maps[RTL_IMR_TIMEOUT2] = IMR_TIMEOUT2, - .maps[RTL_IMR_TIMEOUT1] = IMR_TIMEOUT1, - - .maps[RTL_IMR_TXFOVW] = IMR_TXFOVW, - .maps[RTL_IMR_PSTIMEOUT] = IMR_PSTIMEOUT, - .maps[RTL_IMR_BcnInt] = IMR_BcnInt, - .maps[RTL_IMR_RXFOVW] = IMR_RXFOVW, - .maps[RTL_IMR_RDU] = IMR_RDU, - .maps[RTL_IMR_ATIMEND] = IMR_ATIMEND, - .maps[RTL_IMR_BDOK] = IMR_BDOK, - .maps[RTL_IMR_MGNTDOK] = IMR_MGNTDOK, - .maps[RTL_IMR_TBDER] = IMR_TBDER, - .maps[RTL_IMR_HIGHDOK] = IMR_HIGHDOK, - .maps[RTL_IMR_TBDOK] = IMR_TBDOK, - .maps[RTL_IMR_BKDOK] = IMR_BKDOK, - .maps[RTL_IMR_BEDOK] = IMR_BEDOK, - .maps[RTL_IMR_VIDOK] = IMR_VIDOK, - .maps[RTL_IMR_VODOK] = IMR_VODOK, - .maps[RTL_IMR_ROK] = IMR_ROK, - .maps[RTL_IBSS_INT_MASKS] = (IMR_BcnInt | IMR_TBDOK | IMR_TBDER), - - .maps[RTL_RC_CCK_RATE1M] = DESC92D_RATE1M, - .maps[RTL_RC_CCK_RATE2M] = DESC92D_RATE2M, - .maps[RTL_RC_CCK_RATE5_5M] = DESC92D_RATE5_5M, - .maps[RTL_RC_CCK_RATE11M] = DESC92D_RATE11M, - .maps[RTL_RC_OFDM_RATE6M] = DESC92D_RATE6M, - .maps[RTL_RC_OFDM_RATE9M] = DESC92D_RATE9M, - .maps[RTL_RC_OFDM_RATE12M] = DESC92D_RATE12M, - .maps[RTL_RC_OFDM_RATE18M] = DESC92D_RATE18M, - .maps[RTL_RC_OFDM_RATE24M] = DESC92D_RATE24M, - .maps[RTL_RC_OFDM_RATE36M] = DESC92D_RATE36M, - .maps[RTL_RC_OFDM_RATE48M] = DESC92D_RATE48M, - .maps[RTL_RC_OFDM_RATE54M] = DESC92D_RATE54M, - - .maps[RTL_RC_HT_RATEMCS7] = DESC92D_RATEMCS7, - .maps[RTL_RC_HT_RATEMCS15] = DESC92D_RATEMCS15, -}; - -static struct pci_device_id rtl92de_pci_ids[] __devinitdata = { - {RTL_PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8193, rtl92de_hal_cfg)}, - {RTL_PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x002B, rtl92de_hal_cfg)}, - {}, -}; - -MODULE_DEVICE_TABLE(pci, rtl92de_pci_ids); - -MODULE_AUTHOR("lizhaoming "); -MODULE_AUTHOR("Realtek WlanFAE "); -MODULE_AUTHOR("Larry Finger "); -MODULE_LICENSE("GPL"); -MODULE_DESCRIPTION("Realtek 8192DE 802.11n Dual Mac PCI wireless"); -MODULE_FIRMWARE("rtlwifi/rtl8192defw.bin"); - -module_param_named(swenc, rtl92de_mod_params.sw_crypto, bool, 0444); -module_param_named(ips, rtl92de_mod_params.inactiveps, bool, 0444); -module_param_named(swlps, rtl92de_mod_params.swctrl_lps, bool, 0444); -module_param_named(fwlps, rtl92de_mod_params.fwctrl_lps, bool, 0444); -MODULE_PARM_DESC(swenc, "using hardware crypto (default 0 [hardware])\n"); -MODULE_PARM_DESC(ips, "using no link power save (default 1 is open)\n"); -MODULE_PARM_DESC(swlps, "using linked sw control power save (default 1" - " is open)\n"); - -static struct pci_driver rtl92de_driver = { - .name = KBUILD_MODNAME, - .id_table = rtl92de_pci_ids, - .probe = rtl_pci_probe, - .remove = rtl_pci_disconnect, - -#ifdef CONFIG_PM - .suspend = rtl_pci_suspend, - .resume = rtl_pci_resume, -#endif - -}; - -/* add global spin lock to solve the problem that - * Dul mac register operation on the same time */ -spinlock_t globalmutex_power; -spinlock_t globalmutex_for_fwdownload; -spinlock_t globalmutex_for_power_and_efuse; - -static int __init rtl92de_module_init(void) -{ - int ret = 0; - - spin_lock_init(&globalmutex_power); - spin_lock_init(&globalmutex_for_fwdownload); - spin_lock_init(&globalmutex_for_power_and_efuse); - - ret = pci_register_driver(&rtl92de_driver); - if (ret) - RT_ASSERT(false, (": No device found\n")); - return ret; -} - -static void __exit rtl92de_module_exit(void) -{ - pci_unregister_driver(&rtl92de_driver); -} - -module_init(rtl92de_module_init); -module_exit(rtl92de_module_exit); diff --git a/trunk/drivers/net/wireless/rtlwifi/rtl8192de/sw.h b/trunk/drivers/net/wireless/rtlwifi/rtl8192de/sw.h deleted file mode 100644 index c95e47de1346..000000000000 --- a/trunk/drivers/net/wireless/rtlwifi/rtl8192de/sw.h +++ /dev/null @@ -1,37 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2009-2010 Realtek Corporation. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * The full GNU General Public License is included in this distribution in the - * file called LICENSE. - * - * Contact Information: - * wlanfae - * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, - * Hsinchu 300, Taiwan. - * - * Larry Finger - * - *****************************************************************************/ - -#ifndef __RTL92DE_SW_H__ -#define __RTL92DE_SW_H__ - -extern spinlock_t globalmutex_power; -extern spinlock_t globalmutex_for_fwdownload; -extern spinlock_t globalmutex_for_power_and_efuse; - -#endif diff --git a/trunk/drivers/net/wireless/rtlwifi/rtl8192de/table.c b/trunk/drivers/net/wireless/rtlwifi/rtl8192de/table.c deleted file mode 100644 index bad7f9449ecf..000000000000 --- a/trunk/drivers/net/wireless/rtlwifi/rtl8192de/table.c +++ /dev/null @@ -1,1690 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2009-2010 Realtek Corporation. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * The full GNU General Public License is included in this distribution in the - * file called LICENSE. - * - * Contact Information: - * wlanfae - * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, - * Hsinchu 300, Taiwan. - * - * Larry Finger - * - * Created on 2010/12/23, 6:38 - *****************************************************************************/ - -#include - -#include "table.h" - -u32 rtl8192de_phy_reg_2tarray[PHY_REG_2T_ARRAYLENGTH] = { - 0x024, 0x0011800d, - 0x028, 0x00ffdb83, - 0x014, 0x088ba955, - 0x010, 0x49022b03, - 0x800, 0x80040002, - 0x804, 0x00000003, - 0x808, 0x0000fc00, - 0x80c, 0x0000000a, - 0x810, 0x80706388, - 0x814, 0x020c3d10, - 0x818, 0x02200385, - 0x81c, 0x00000000, - 0x820, 0x01000100, - 0x824, 0x00390004, - 0x828, 0x01000100, - 0x82c, 0x00390004, - 0x830, 0x27272727, - 0x834, 0x27272727, - 0x838, 0x27272727, - 0x83c, 0x27272727, - 0x840, 0x00010000, - 0x844, 0x00010000, - 0x848, 0x27272727, - 0x84c, 0x27272727, - 0x850, 0x00000000, - 0x854, 0x00000000, - 0x858, 0x569a569a, - 0x85c, 0x0c1b25a4, - 0x860, 0x66e60230, - 0x864, 0x061f0130, - 0x868, 0x27272727, - 0x86c, 0x272b2b2b, - 0x870, 0x07000700, - 0x874, 0x22188000, - 0x878, 0x08080808, - 0x87c, 0x00007ff8, - 0x880, 0xc0083070, - 0x884, 0x00000cd5, - 0x888, 0x00000000, - 0x88c, 0xcc0000c0, - 0x890, 0x00000800, - 0x894, 0xfffffffe, - 0x898, 0x40302010, - 0x89c, 0x00706050, - 0x900, 0x00000000, - 0x904, 0x00000023, - 0x908, 0x00000000, - 0x90c, 0x81121313, - 0xa00, 0x00d047c8, - 0xa04, 0x80ff000c, - 0xa08, 0x8c838300, - 0xa0c, 0x2e68120f, - 0xa10, 0x9500bb78, - 0xa14, 0x11144028, - 0xa18, 0x00881117, - 0xa1c, 0x89140f00, - 0xa20, 0x1a1b0000, - 0xa24, 0x090e1317, - 0xa28, 0x00000204, - 0xa2c, 0x00d30000, - 0xa70, 0x101fbf00, - 0xa74, 0x00000007, - 0xc00, 0x40071d40, - 0xc04, 0x03a05633, - 0xc08, 0x001000e4, - 0xc0c, 0x6c6c6c6c, - 0xc10, 0x08800000, - 0xc14, 0x40000100, - 0xc18, 0x08800000, - 0xc1c, 0x40000100, - 0xc20, 0x00000000, - 0xc24, 0x00000000, - 0xc28, 0x00000000, - 0xc2c, 0x00000000, - 0xc30, 0x69e9ac44, - 0xc34, 0x469652cf, - 0xc38, 0x49795994, - 0xc3c, 0x0a979718, - 0xc40, 0x1f7c403f, - 0xc44, 0x000100b7, - 0xc48, 0xec020107, - 0xc4c, 0x007f037f, - 0xc50, 0x69543420, - 0xc54, 0x43bc009e, - 0xc58, 0x69543420, - 0xc5c, 0x433c00a8, - 0xc60, 0x00000000, - 0xc64, 0x5116848b, - 0xc68, 0x47c00bff, - 0xc6c, 0x00000036, - 0xc70, 0x2c7f000d, - 0xc74, 0x058610db, - 0xc78, 0x0000001f, - 0xc7c, 0x40b95612, - 0xc80, 0x40000100, - 0xc84, 0x20f60000, - 0xc88, 0x40000100, - 0xc8c, 0x20e00000, - 0xc90, 0x00121820, - 0xc94, 0x00000007, - 0xc98, 0x00121820, - 0xc9c, 0x00007f7f, - 0xca0, 0x00000000, - 0xca4, 0x00000080, - 0xca8, 0x00000000, - 0xcac, 0x00000000, - 0xcb0, 0x00000000, - 0xcb4, 0x00000000, - 0xcb8, 0x00000000, - 0xcbc, 0x28000000, - 0xcc0, 0x00000000, - 0xcc4, 0x00000000, - 0xcc8, 0x00000000, - 0xccc, 0x00000000, - 0xcd0, 0x00000000, - 0xcd4, 0x00000000, - 0xcd8, 0x64b11e20, - 0xcdc, 0xe8767533, - 0xce0, 0x00222222, - 0xce4, 0x00000000, - 0xce8, 0x37644302, - 0xcec, 0x2f97d40c, - 0xd00, 0x00080740, - 0xd04, 0x00020403, - 0xd08, 0x0000907f, - 0xd0c, 0x20010201, - 0xd10, 0xa0633333, - 0xd14, 0x3333bc43, - 0xd18, 0x7a8f5b6b, - 0xd2c, 0xcc979975, - 0xd30, 0x00000000, - 0xd34, 0x80608404, - 0xd38, 0x00000000, - 0xd3c, 0x00027293, - 0xd40, 0x00000000, - 0xd44, 0x00000000, - 0xd48, 0x00000000, - 0xd4c, 0x00000000, - 0xd50, 0x6437140a, - 0xd54, 0x00000000, - 0xd58, 0x00000000, - 0xd5c, 0x30032064, - 0xd60, 0x4653de68, - 0xd64, 0x04518a3c, - 0xd68, 0x00002101, - 0xd6c, 0x2a201c16, - 0xd70, 0x1812362e, - 0xd74, 0x322c2220, - 0xd78, 0x000e3c24, - 0xe00, 0x2a2a2a2a, - 0xe04, 0x2a2a2a2a, - 0xe08, 0x03902a2a, - 0xe10, 0x2a2a2a2a, - 0xe14, 0x2a2a2a2a, - 0xe18, 0x2a2a2a2a, - 0xe1c, 0x2a2a2a2a, - 0xe28, 0x00000000, - 0xe30, 0x1000dc1f, - 0xe34, 0x10008c1f, - 0xe38, 0x02140102, - 0xe3c, 0x681604c2, - 0xe40, 0x01007c00, - 0xe44, 0x01004800, - 0xe48, 0xfb000000, - 0xe4c, 0x000028d1, - 0xe50, 0x1000dc1f, - 0xe54, 0x10008c1f, - 0xe58, 0x02140102, - 0xe5c, 0x28160d05, - 0xe60, 0x00000010, - 0xe68, 0x001b25a4, - 0xe6c, 0x63db25a4, - 0xe70, 0x63db25a4, - 0xe74, 0x0c126da4, - 0xe78, 0x0c126da4, - 0xe7c, 0x0c126da4, - 0xe80, 0x0c126da4, - 0xe84, 0x63db25a4, - 0xe88, 0x0c126da4, - 0xe8c, 0x63db25a4, - 0xed0, 0x63db25a4, - 0xed4, 0x63db25a4, - 0xed8, 0x63db25a4, - 0xedc, 0x001b25a4, - 0xee0, 0x001b25a4, - 0xeec, 0x6fdb25a4, - 0xf14, 0x00000003, - 0xf1c, 0x00000064, - 0xf4c, 0x00000004, - 0xf00, 0x00000300, -}; - -u32 rtl8192de_phy_reg_array_pg[PHY_REG_ARRAY_PG_LENGTH] = { - 0xe00, 0xffffffff, 0x07090c0c, - 0xe04, 0xffffffff, 0x01020405, - 0xe08, 0x0000ff00, 0x00000000, - 0x86c, 0xffffff00, 0x00000000, - 0xe10, 0xffffffff, 0x0b0c0c0e, - 0xe14, 0xffffffff, 0x01030506, - 0xe18, 0xffffffff, 0x0b0c0d0e, - 0xe1c, 0xffffffff, 0x01030509, - 0x830, 0xffffffff, 0x07090c0c, - 0x834, 0xffffffff, 0x01020405, - 0x838, 0xffffff00, 0x00000000, - 0x86c, 0x000000ff, 0x00000000, - 0x83c, 0xffffffff, 0x0b0c0c0e, - 0x848, 0xffffffff, 0x01030506, - 0x84c, 0xffffffff, 0x0b0c0d0e, - 0x868, 0xffffffff, 0x01030509, - 0xe00, 0xffffffff, 0x00000000, - 0xe04, 0xffffffff, 0x00000000, - 0xe08, 0x0000ff00, 0x00000000, - 0x86c, 0xffffff00, 0x00000000, - 0xe10, 0xffffffff, 0x00000000, - 0xe14, 0xffffffff, 0x00000000, - 0xe18, 0xffffffff, 0x00000000, - 0xe1c, 0xffffffff, 0x00000000, - 0x830, 0xffffffff, 0x00000000, - 0x834, 0xffffffff, 0x00000000, - 0x838, 0xffffff00, 0x00000000, - 0x86c, 0x000000ff, 0x00000000, - 0x83c, 0xffffffff, 0x00000000, - 0x848, 0xffffffff, 0x00000000, - 0x84c, 0xffffffff, 0x00000000, - 0x868, 0xffffffff, 0x00000000, - 0xe00, 0xffffffff, 0x04040404, - 0xe04, 0xffffffff, 0x00020204, - 0xe08, 0x0000ff00, 0x00000000, - 0x86c, 0xffffff00, 0x00000000, - 0xe10, 0xffffffff, 0x06060606, - 0xe14, 0xffffffff, 0x00020406, - 0xe18, 0xffffffff, 0x00000000, - 0xe1c, 0xffffffff, 0x00000000, - 0x830, 0xffffffff, 0x04040404, - 0x834, 0xffffffff, 0x00020204, - 0x838, 0xffffff00, 0x00000000, - 0x86c, 0x000000ff, 0x00000000, - 0x83c, 0xffffffff, 0x06060606, - 0x848, 0xffffffff, 0x00020406, - 0x84c, 0xffffffff, 0x00000000, - 0x868, 0xffffffff, 0x00000000, - 0xe00, 0xffffffff, 0x00000000, - 0xe04, 0xffffffff, 0x00000000, - 0xe08, 0x0000ff00, 0x00000000, - 0x86c, 0xffffff00, 0x00000000, - 0xe10, 0xffffffff, 0x00000000, - 0xe14, 0xffffffff, 0x00000000, - 0xe18, 0xffffffff, 0x00000000, - 0xe1c, 0xffffffff, 0x00000000, - 0x830, 0xffffffff, 0x00000000, - 0x834, 0xffffffff, 0x00000000, - 0x838, 0xffffff00, 0x00000000, - 0x86c, 0x000000ff, 0x00000000, - 0x83c, 0xffffffff, 0x00000000, - 0x848, 0xffffffff, 0x00000000, - 0x84c, 0xffffffff, 0x00000000, - 0x868, 0xffffffff, 0x00000000, - 0xe00, 0xffffffff, 0x00000000, - 0xe04, 0xffffffff, 0x00000000, - 0xe08, 0x0000ff00, 0x00000000, - 0x86c, 0xffffff00, 0x00000000, - 0xe10, 0xffffffff, 0x00000000, - 0xe14, 0xffffffff, 0x00000000, - 0xe18, 0xffffffff, 0x00000000, - 0xe1c, 0xffffffff, 0x00000000, - 0x830, 0xffffffff, 0x00000000, - 0x834, 0xffffffff, 0x00000000, - 0x838, 0xffffff00, 0x00000000, - 0x86c, 0x000000ff, 0x00000000, - 0x83c, 0xffffffff, 0x00000000, - 0x848, 0xffffffff, 0x00000000, - 0x84c, 0xffffffff, 0x00000000, - 0x868, 0xffffffff, 0x00000000, - 0xe00, 0xffffffff, 0x04040404, - 0xe04, 0xffffffff, 0x00020204, - 0xe08, 0x0000ff00, 0x00000000, - 0x86c, 0xffffff00, 0x00000000, - 0xe10, 0xffffffff, 0x00000000, - 0xe14, 0xffffffff, 0x00000000, - 0xe18, 0xffffffff, 0x00000000, - 0xe1c, 0xffffffff, 0x00000000, - 0x830, 0xffffffff, 0x04040404, - 0x834, 0xffffffff, 0x00020204, - 0x838, 0xffffff00, 0x00000000, - 0x86c, 0x000000ff, 0x00000000, - 0x83c, 0xffffffff, 0x00000000, - 0x848, 0xffffffff, 0x00000000, - 0x84c, 0xffffffff, 0x00000000, - 0x868, 0xffffffff, 0x00000000, - 0xe00, 0xffffffff, 0x00000000, - 0xe04, 0xffffffff, 0x00000000, - 0xe08, 0x0000ff00, 0x00000000, - 0x86c, 0xffffff00, 0x00000000, - 0xe10, 0xffffffff, 0x00000000, - 0xe14, 0xffffffff, 0x00000000, - 0xe18, 0xffffffff, 0x00000000, - 0xe1c, 0xffffffff, 0x00000000, - 0x830, 0xffffffff, 0x00000000, - 0x834, 0xffffffff, 0x00000000, - 0x838, 0xffffff00, 0x00000000, - 0x86c, 0x000000ff, 0x00000000, - 0x83c, 0xffffffff, 0x00000000, - 0x848, 0xffffffff, 0x00000000, - 0x84c, 0xffffffff, 0x00000000, - 0x868, 0xffffffff, 0x00000000, - 0xe00, 0xffffffff, 0x04040404, - 0xe04, 0xffffffff, 0x00020204, - 0xe08, 0x0000ff00, 0x00000000, - 0x86c, 0xffffff00, 0x00000000, - 0xe10, 0xffffffff, 0x08080808, - 0xe14, 0xffffffff, 0x00040408, - 0xe18, 0xffffffff, 0x00000000, - 0xe1c, 0xffffffff, 0x00000000, - 0x830, 0xffffffff, 0x04040404, - 0x834, 0xffffffff, 0x00020204, - 0x838, 0xffffff00, 0x00000000, - 0x86c, 0x000000ff, 0x00000000, - 0x83c, 0xffffffff, 0x08080808, - 0x848, 0xffffffff, 0x00040408, - 0x84c, 0xffffffff, 0x00000000, - 0x868, 0xffffffff, 0x00000000, - 0xe00, 0xffffffff, 0x04040404, - 0xe04, 0xffffffff, 0x00020204, - 0xe08, 0x0000ff00, 0x00000000, - 0x86c, 0xffffff00, 0x00000000, - 0xe10, 0xffffffff, 0x08080808, - 0xe14, 0xffffffff, 0x00040408, - 0xe18, 0xffffffff, 0x00000000, - 0xe1c, 0xffffffff, 0x00000000, - 0x830, 0xffffffff, 0x04040404, - 0x834, 0xffffffff, 0x00020204, - 0x838, 0xffffff00, 0x00000000, - 0x86c, 0x000000ff, 0x00000000, - 0x83c, 0xffffffff, 0x08080808, - 0x848, 0xffffffff, 0x00040408, - 0x84c, 0xffffffff, 0x00000000, - 0x868, 0xffffffff, 0x00000000, - 0xe00, 0xffffffff, 0x04040404, - 0xe04, 0xffffffff, 0x00020204, - 0xe08, 0x0000ff00, 0x00000000, - 0x86c, 0xffffff00, 0x00000000, - 0xe10, 0xffffffff, 0x08080808, - 0xe14, 0xffffffff, 0x00040408, - 0xe18, 0xffffffff, 0x00000000, - 0xe1c, 0xffffffff, 0x00000000, - 0x830, 0xffffffff, 0x04040404, - 0x834, 0xffffffff, 0x00020204, - 0x838, 0xffffff00, 0x00000000, - 0x86c, 0x000000ff, 0x00000000, - 0x83c, 0xffffffff, 0x08080808, - 0x848, 0xffffffff, 0x00040408, - 0x84c, 0xffffffff, 0x00000000, - 0x868, 0xffffffff, 0x00000000, - 0xe00, 0xffffffff, 0x04040404, - 0xe04, 0xffffffff, 0x00020204, - 0xe08, 0x0000ff00, 0x00000000, - 0x86c, 0xffffff00, 0x00000000, - 0xe10, 0xffffffff, 0x08080808, - 0xe14, 0xffffffff, 0x00040408, - 0xe18, 0xffffffff, 0x00000000, - 0xe1c, 0xffffffff, 0x00000000, - 0x830, 0xffffffff, 0x04040404, - 0x834, 0xffffffff, 0x00020204, - 0x838, 0xffffff00, 0x00000000, - 0x86c, 0x000000ff, 0x00000000, - 0x83c, 0xffffffff, 0x08080808, - 0x848, 0xffffffff, 0x00040408, - 0x84c, 0xffffffff, 0x00000000, - 0x868, 0xffffffff, 0x00000000, - 0xe00, 0xffffffff, 0x04040404, - 0xe04, 0xffffffff, 0x00020204, - 0xe08, 0x0000ff00, 0x00000000, - 0x86c, 0xffffff00, 0x00000000, - 0xe10, 0xffffffff, 0x08080808, - 0xe14, 0xffffffff, 0x00040408, - 0xe18, 0xffffffff, 0x00000000, - 0xe1c, 0xffffffff, 0x00000000, - 0x830, 0xffffffff, 0x04040404, - 0x834, 0xffffffff, 0x00020204, - 0x838, 0xffffff00, 0x00000000, - 0x86c, 0x000000ff, 0x00000000, - 0x83c, 0xffffffff, 0x08080808, - 0x848, 0xffffffff, 0x00040408, - 0x84c, 0xffffffff, 0x00000000, - 0x868, 0xffffffff, 0x00000000, - 0xe00, 0xffffffff, 0x04040404, - 0xe04, 0xffffffff, 0x00020204, - 0xe08, 0x0000ff00, 0x00000000, - 0x86c, 0xffffff00, 0x00000000, - 0xe10, 0xffffffff, 0x08080808, - 0xe14, 0xffffffff, 0x00040408, - 0xe18, 0xffffffff, 0x00000000, - 0xe1c, 0xffffffff, 0x00000000, - 0x830, 0xffffffff, 0x04040404, - 0x834, 0xffffffff, 0x00020204, - 0x838, 0xffffff00, 0x00000000, - 0x86c, 0x000000ff, 0x00000000, - 0x83c, 0xffffffff, 0x08080808, - 0x848, 0xffffffff, 0x00040408, - 0x84c, 0xffffffff, 0x00000000, - 0x868, 0xffffffff, 0x00000000, -}; - -u32 rtl8192de_radioa_2tarray[RADIOA_2T_ARRAYLENGTH] = { - 0x000, 0x00030000, - 0x001, 0x00030000, - 0x002, 0x00000000, - 0x003, 0x00018c63, - 0x004, 0x00018c63, - 0x008, 0x00084000, - 0x00b, 0x0001c000, - 0x00e, 0x00018c67, - 0x00f, 0x00000851, - 0x014, 0x00021440, - 0x018, 0x00017524, - 0x019, 0x00000000, - 0x01d, 0x000a1290, - 0x023, 0x00001558, - 0x01a, 0x00030a99, - 0x01b, 0x00040b00, - 0x01c, 0x000fc339, - 0x03a, 0x000a57eb, - 0x03b, 0x00020000, - 0x03c, 0x000ff454, - 0x020, 0x0000aa52, - 0x021, 0x00054000, - 0x040, 0x0000aa52, - 0x041, 0x00014000, - 0x025, 0x000803be, - 0x026, 0x000fc638, - 0x027, 0x00077c18, - 0x028, 0x000de471, - 0x029, 0x000d7110, - 0x02a, 0x0008cb04, - 0x02b, 0x0004128b, - 0x02c, 0x00001840, - 0x043, 0x0002444f, - 0x044, 0x0001adb0, - 0x045, 0x00056467, - 0x046, 0x0008992c, - 0x047, 0x0000452c, - 0x048, 0x000f9c43, - 0x049, 0x00002e0c, - 0x04a, 0x000546eb, - 0x04b, 0x0008966c, - 0x04c, 0x0000dde9, - 0x018, 0x00007401, - 0x000, 0x00070000, - 0x012, 0x000dc000, - 0x012, 0x00090000, - 0x012, 0x00051000, - 0x012, 0x00012000, - 0x013, 0x000287b7, - 0x013, 0x000247ab, - 0x013, 0x0002079f, - 0x013, 0x0001c793, - 0x013, 0x0001839b, - 0x013, 0x00014392, - 0x013, 0x0001019a, - 0x013, 0x0000c191, - 0x013, 0x00008194, - 0x013, 0x000040a0, - 0x013, 0x00000018, - 0x015, 0x0000f424, - 0x015, 0x0004f424, - 0x015, 0x0008f424, - 0x016, 0x000e1330, - 0x016, 0x000a1330, - 0x016, 0x00061330, - 0x016, 0x00021330, - 0x018, 0x00017524, - 0x000, 0x00070000, - 0x012, 0x000cf000, - 0x012, 0x000bc000, - 0x012, 0x00078000, - 0x012, 0x00000000, - 0x013, 0x000287bc, - 0x013, 0x000247b0, - 0x013, 0x000203b4, - 0x013, 0x0001c3a8, - 0x013, 0x000181b4, - 0x013, 0x000141a8, - 0x013, 0x000100b0, - 0x013, 0x0000c0a4, - 0x013, 0x0000b02c, - 0x013, 0x00004020, - 0x013, 0x00000014, - 0x015, 0x0000f4c3, - 0x015, 0x0004f4c3, - 0x015, 0x0008f4c3, - 0x016, 0x000e085f, - 0x016, 0x000a085f, - 0x016, 0x0006085f, - 0x016, 0x0002085f, - 0x018, 0x00037524, - 0x000, 0x00070000, - 0x012, 0x000cf000, - 0x012, 0x000bc000, - 0x012, 0x00078000, - 0x012, 0x00000000, - 0x013, 0x000287bc, - 0x013, 0x000247b0, - 0x013, 0x000203b4, - 0x013, 0x0001c3a8, - 0x013, 0x000181b4, - 0x013, 0x000141a8, - 0x013, 0x000100b0, - 0x013, 0x0000c0a4, - 0x013, 0x0000b02c, - 0x013, 0x00004020, - 0x013, 0x00000014, - 0x015, 0x0000f4c3, - 0x015, 0x0004f4c3, - 0x015, 0x0008f4c3, - 0x016, 0x000e085f, - 0x016, 0x000a085f, - 0x016, 0x0006085f, - 0x016, 0x0002085f, - 0x018, 0x00057568, - 0x000, 0x00070000, - 0x012, 0x000cf000, - 0x012, 0x000bc000, - 0x012, 0x00078000, - 0x012, 0x00000000, - 0x013, 0x000287bc, - 0x013, 0x000247b0, - 0x013, 0x000203b4, - 0x013, 0x0001c3a8, - 0x013, 0x000181b4, - 0x013, 0x000141a8, - 0x013, 0x000100b0, - 0x013, 0x0000c0a4, - 0x013, 0x0000b02c, - 0x013, 0x00004020, - 0x013, 0x00000014, - 0x015, 0x0000f4c3, - 0x015, 0x0004f4c3, - 0x015, 0x0008f4c3, - 0x016, 0x000e085f, - 0x016, 0x000a085f, - 0x016, 0x0006085f, - 0x016, 0x0002085f, - 0x030, 0x0004470f, - 0x031, 0x00044ff0, - 0x032, 0x00000070, - 0x033, 0x000dd480, - 0x034, 0x000ffac0, - 0x035, 0x000b80c0, - 0x036, 0x00077000, - 0x037, 0x00064ff2, - 0x038, 0x000e7661, - 0x039, 0x00000e90, - 0x000, 0x00030000, - 0x018, 0x0000f401, - 0x0fe, 0x00000000, - 0x0fe, 0x00000000, - 0x01e, 0x00088009, - 0x01f, 0x00080003, - 0x0fe, 0x00000000, - 0x01e, 0x00088001, - 0x01f, 0x00080000, - 0x0fe, 0x00000000, - 0x018, 0x00097524, - 0x0fe, 0x00000000, - 0x0fe, 0x00000000, - 0x0fe, 0x00000000, - 0x0fe, 0x00000000, - 0x02b, 0x00041289, - 0x0fe, 0x00000000, - 0x02d, 0x0006aaaa, - 0x02e, 0x000b4d01, - 0x02d, 0x00080000, - 0x02e, 0x00004d02, - 0x02d, 0x00095555, - 0x02e, 0x00054d03, - 0x02d, 0x000aaaaa, - 0x02e, 0x000b4d04, - 0x02d, 0x000c0000, - 0x02e, 0x00004d05, - 0x02d, 0x000d5555, - 0x02e, 0x00054d06, - 0x02d, 0x000eaaaa, - 0x02e, 0x000b4d07, - 0x02d, 0x00000000, - 0x02e, 0x00005108, - 0x02d, 0x00015555, - 0x02e, 0x00055109, - 0x02d, 0x0002aaaa, - 0x02e, 0x000b510a, - 0x02d, 0x00040000, - 0x02e, 0x0000510b, - 0x02d, 0x00055555, - 0x02e, 0x0005510c, -}; - -u32 rtl8192de_radiob_2tarray[RADIOB_2T_ARRAYLENGTH] = { - 0x000, 0x00030000, - 0x001, 0x00030000, - 0x002, 0x00000000, - 0x003, 0x00018c63, - 0x004, 0x00018c63, - 0x008, 0x00084000, - 0x00b, 0x0001c000, - 0x00e, 0x00018c67, - 0x00f, 0x00000851, - 0x014, 0x00021440, - 0x018, 0x00007401, - 0x019, 0x00000060, - 0x01d, 0x000a1290, - 0x023, 0x00001558, - 0x01a, 0x00030a99, - 0x01b, 0x00040b00, - 0x01c, 0x000fc339, - 0x03a, 0x000a57eb, - 0x03b, 0x00020000, - 0x03c, 0x000ff454, - 0x020, 0x0000aa52, - 0x021, 0x00054000, - 0x040, 0x0000aa52, - 0x041, 0x00014000, - 0x025, 0x000803be, - 0x026, 0x000fc638, - 0x027, 0x00077c18, - 0x028, 0x000d1c31, - 0x029, 0x000d7110, - 0x02a, 0x000aeb04, - 0x02b, 0x0004128b, - 0x02c, 0x00001840, - 0x043, 0x0002444f, - 0x044, 0x0001adb0, - 0x045, 0x00056467, - 0x046, 0x0008992c, - 0x047, 0x0000452c, - 0x048, 0x000f9c43, - 0x049, 0x00002e0c, - 0x04a, 0x000546eb, - 0x04b, 0x0008966c, - 0x04c, 0x0000dde9, - 0x018, 0x00007401, - 0x000, 0x00070000, - 0x012, 0x000dc000, - 0x012, 0x00090000, - 0x012, 0x00051000, - 0x012, 0x00012000, - 0x013, 0x000287b7, - 0x013, 0x000247ab, - 0x013, 0x0002079f, - 0x013, 0x0001c793, - 0x013, 0x0001839b, - 0x013, 0x00014392, - 0x013, 0x0001019a, - 0x013, 0x0000c191, - 0x013, 0x00008194, - 0x013, 0x000040a0, - 0x013, 0x00000018, - 0x015, 0x0000f424, - 0x015, 0x0004f424, - 0x015, 0x0008f424, - 0x016, 0x000e1330, - 0x016, 0x000a1330, - 0x016, 0x00061330, - 0x016, 0x00021330, - 0x018, 0x00017524, - 0x000, 0x00070000, - 0x012, 0x000cf000, - 0x012, 0x000bc000, - 0x012, 0x00078000, - 0x012, 0x00000000, - 0x013, 0x000287bc, - 0x013, 0x000247b0, - 0x013, 0x000203b4, - 0x013, 0x0001c3a8, - 0x013, 0x000181b4, - 0x013, 0x000141a8, - 0x013, 0x000100b0, - 0x013, 0x0000c0a4, - 0x013, 0x0000b02c, - 0x013, 0x00004020, - 0x013, 0x00000014, - 0x015, 0x0000f4c3, - 0x015, 0x0004f4c3, - 0x015, 0x0008f4c3, - 0x016, 0x000e085f, - 0x016, 0x000a085f, - 0x016, 0x0006085f, - 0x016, 0x0002085f, - 0x018, 0x00037524, - 0x000, 0x00070000, - 0x012, 0x000cf000, - 0x012, 0x000bc000, - 0x012, 0x00078000, - 0x012, 0x00000000, - 0x013, 0x000287bc, - 0x013, 0x000247b0, - 0x013, 0x000203b4, - 0x013, 0x0001c3a8, - 0x013, 0x000181b4, - 0x013, 0x000141a8, - 0x013, 0x000100b0, - 0x013, 0x0000c0a4, - 0x013, 0x0000b02c, - 0x013, 0x00004020, - 0x013, 0x00000014, - 0x015, 0x0000f4c3, - 0x015, 0x0004f4c3, - 0x015, 0x0008f4c3, - 0x016, 0x000e085f, - 0x016, 0x000a085f, - 0x016, 0x0006085f, - 0x016, 0x0002085f, - 0x018, 0x00057524, - 0x000, 0x00070000, - 0x012, 0x000cf000, - 0x012, 0x000bc000, - 0x012, 0x00078000, - 0x012, 0x00000000, - 0x013, 0x000287bc, - 0x013, 0x000247b0, - 0x013, 0x000203b4, - 0x013, 0x0001c3a8, - 0x013, 0x000181b4, - 0x013, 0x000141a8, - 0x013, 0x000100b0, - 0x013, 0x0000c0a4, - 0x013, 0x0000b02c, - 0x013, 0x00004020, - 0x013, 0x00000014, - 0x015, 0x0000f4c3, - 0x015, 0x0004f4c3, - 0x015, 0x0008f4c3, - 0x016, 0x000e085f, - 0x016, 0x000a085f, - 0x016, 0x0006085f, - 0x016, 0x0002085f, - 0x030, 0x0004470f, - 0x031, 0x00044ff0, - 0x032, 0x00000070, - 0x033, 0x000dd480, - 0x034, 0x000ffac0, - 0x035, 0x000b80c0, - 0x036, 0x00077000, - 0x037, 0x00064ff2, - 0x038, 0x000e7661, - 0x039, 0x00000e90, - 0x000, 0x00030000, - 0x018, 0x0000f401, - 0x0fe, 0x00000000, - 0x0fe, 0x00000000, - 0x01e, 0x00088009, - 0x01f, 0x00080003, - 0x0fe, 0x00000000, - 0x01e, 0x00088001, - 0x01f, 0x00080000, - 0x0fe, 0x00000000, - 0x018, 0x00087401, - 0x0fe, 0x00000000, - 0x0fe, 0x00000000, - 0x0fe, 0x00000000, - 0x02b, 0x00041289, - 0x0fe, 0x00000000, - 0x02d, 0x00066666, - 0x02e, 0x00064001, - 0x02d, 0x00091111, - 0x02e, 0x00014002, - 0x02d, 0x000bbbbb, - 0x02e, 0x000b4003, - 0x02d, 0x000e6666, - 0x02e, 0x00064004, - 0x02d, 0x00088888, - 0x02e, 0x00084005, - 0x02d, 0x0009dddd, - 0x02e, 0x000d4006, - 0x02d, 0x000b3333, - 0x02e, 0x00034007, - 0x02d, 0x00048888, - 0x02e, 0x00084408, - 0x02d, 0x000bbbbb, - 0x02e, 0x000b4409, - 0x02d, 0x000e6666, - 0x02e, 0x0006440a, - 0x02d, 0x00011111, - 0x02e, 0x0001480b, - 0x02d, 0x0003bbbb, - 0x02e, 0x000b480c, - 0x02d, 0x00066666, - 0x02e, 0x0006480d, - 0x02d, 0x000ccccc, - 0x02e, 0x000c480e, -}; - -u32 rtl8192de_radioa_2t_int_paarray[RADIOA_2T_INT_PA_ARRAYLENGTH] = { - 0x000, 0x00030000, - 0x001, 0x00030000, - 0x002, 0x00000000, - 0x003, 0x00018c63, - 0x004, 0x00018c63, - 0x008, 0x00084000, - 0x00b, 0x0001c000, - 0x00e, 0x00018c67, - 0x00f, 0x00000851, - 0x014, 0x00021440, - 0x018, 0x00017524, - 0x019, 0x00000000, - 0x01d, 0x000a1290, - 0x023, 0x00001558, - 0x01a, 0x00030a99, - 0x01b, 0x00040b00, - 0x01c, 0x000fc339, - 0x03a, 0x000a57eb, - 0x03b, 0x00020000, - 0x03c, 0x000ff454, - 0x020, 0x0000aa52, - 0x021, 0x00054000, - 0x040, 0x0000aa52, - 0x041, 0x00014000, - 0x025, 0x000803be, - 0x026, 0x000fc638, - 0x027, 0x00077c18, - 0x028, 0x000de471, - 0x029, 0x000d7110, - 0x02a, 0x0008eb04, - 0x02b, 0x0004128b, - 0x02c, 0x00001840, - 0x043, 0x0002444f, - 0x044, 0x0001adb0, - 0x045, 0x00056467, - 0x046, 0x0008992c, - 0x047, 0x0000452c, - 0x048, 0x000c0443, - 0x049, 0x00000730, - 0x04a, 0x00050f0f, - 0x04b, 0x000896ee, - 0x04c, 0x0000ddee, - 0x018, 0x00007401, - 0x000, 0x00070000, - 0x012, 0x000dc000, - 0x012, 0x00090000, - 0x012, 0x00051000, - 0x012, 0x00012000, - 0x013, 0x000287b7, - 0x013, 0x000247ab, - 0x013, 0x0002079f, - 0x013, 0x0001c793, - 0x013, 0x0001839b, - 0x013, 0x00014392, - 0x013, 0x0001019a, - 0x013, 0x0000c191, - 0x013, 0x00008194, - 0x013, 0x000040a0, - 0x013, 0x00000018, - 0x015, 0x0000f424, - 0x015, 0x0004f424, - 0x015, 0x0008f424, - 0x016, 0x000e1330, - 0x016, 0x000a1330, - 0x016, 0x00061330, - 0x016, 0x00021330, - 0x018, 0x00017524, - 0x000, 0x00070000, - 0x012, 0x000cf000, - 0x012, 0x000bc000, - 0x012, 0x00078000, - 0x012, 0x00000000, - 0x013, 0x000287bf, - 0x013, 0x000247b3, - 0x013, 0x000207a7, - 0x013, 0x0001c79b, - 0x013, 0x0001839f, - 0x013, 0x00014393, - 0x013, 0x00010399, - 0x013, 0x0000c38d, - 0x013, 0x00008199, - 0x013, 0x0000418d, - 0x013, 0x00000099, - 0x015, 0x0000f495, - 0x015, 0x0004f495, - 0x015, 0x0008f495, - 0x016, 0x000e1874, - 0x016, 0x000a1874, - 0x016, 0x00061874, - 0x016, 0x00021874, - 0x018, 0x00037564, - 0x000, 0x00070000, - 0x012, 0x000cf000, - 0x012, 0x000bc000, - 0x012, 0x00078000, - 0x012, 0x00000000, - 0x013, 0x000287bf, - 0x013, 0x000247b3, - 0x013, 0x000207a7, - 0x013, 0x0001c79b, - 0x013, 0x0001839f, - 0x013, 0x00014393, - 0x013, 0x00010399, - 0x013, 0x0000c38d, - 0x013, 0x00008199, - 0x013, 0x0000418d, - 0x013, 0x00000099, - 0x015, 0x0000f495, - 0x015, 0x0004f495, - 0x015, 0x0008f495, - 0x016, 0x000e1874, - 0x016, 0x000a1874, - 0x016, 0x00061874, - 0x016, 0x00021874, - 0x018, 0x00057595, - 0x000, 0x00070000, - 0x012, 0x000cf000, - 0x012, 0x000bc000, - 0x012, 0x00078000, - 0x012, 0x00000000, - 0x013, 0x000287bf, - 0x013, 0x000247b3, - 0x013, 0x000207a7, - 0x013, 0x0001c79b, - 0x013, 0x0001839f, - 0x013, 0x00014393, - 0x013, 0x00010399, - 0x013, 0x0000c38d, - 0x013, 0x00008199, - 0x013, 0x0000418d, - 0x013, 0x00000099, - 0x015, 0x0000f495, - 0x015, 0x0004f495, - 0x015, 0x0008f495, - 0x016, 0x000e1874, - 0x016, 0x000a1874, - 0x016, 0x00061874, - 0x016, 0x00021874, - 0x030, 0x0004470f, - 0x031, 0x00044ff0, - 0x032, 0x00000070, - 0x033, 0x000dd480, - 0x034, 0x000ffac0, - 0x035, 0x000b80c0, - 0x036, 0x00077000, - 0x037, 0x00064ff2, - 0x038, 0x000e7661, - 0x039, 0x00000e90, - 0x000, 0x00030000, - 0x018, 0x0000f401, - 0x0fe, 0x00000000, - 0x0fe, 0x00000000, - 0x01e, 0x00088009, - 0x01f, 0x00080003, - 0x0fe, 0x00000000, - 0x01e, 0x00088001, - 0x01f, 0x00080000, - 0x0fe, 0x00000000, - 0x018, 0x00097524, - 0x0fe, 0x00000000, - 0x0fe, 0x00000000, - 0x0fe, 0x00000000, - 0x0fe, 0x00000000, - 0x02b, 0x00041289, - 0x0fe, 0x00000000, - 0x02d, 0x0006aaaa, - 0x02e, 0x000b4d01, - 0x02d, 0x00080000, - 0x02e, 0x00004d02, - 0x02d, 0x00095555, - 0x02e, 0x00054d03, - 0x02d, 0x000aaaaa, - 0x02e, 0x000b4d04, - 0x02d, 0x000c0000, - 0x02e, 0x00004d05, - 0x02d, 0x000d5555, - 0x02e, 0x00054d06, - 0x02d, 0x000eaaaa, - 0x02e, 0x000b4d07, - 0x02d, 0x00000000, - 0x02e, 0x00005108, - 0x02d, 0x00015555, - 0x02e, 0x00055109, - 0x02d, 0x0002aaaa, - 0x02e, 0x000b510a, - 0x02d, 0x00040000, - 0x02e, 0x0000510b, - 0x02d, 0x00055555, - 0x02e, 0x0005510c, -}; - -u32 rtl8192de_radiob_2t_int_paarray[RADIOB_2T_INT_PA_ARRAYLENGTH] = { - 0x000, 0x00030000, - 0x001, 0x00030000, - 0x002, 0x00000000, - 0x003, 0x00018c63, - 0x004, 0x00018c63, - 0x008, 0x00084000, - 0x00b, 0x0001c000, - 0x00e, 0x00018c67, - 0x00f, 0x00000851, - 0x014, 0x00021440, - 0x018, 0x00007401, - 0x019, 0x00000060, - 0x01d, 0x000a1290, - 0x023, 0x00001558, - 0x01a, 0x00030a99, - 0x01b, 0x00040b00, - 0x01c, 0x000fc339, - 0x03a, 0x000a57eb, - 0x03b, 0x00020000, - 0x03c, 0x000ff454, - 0x020, 0x0000aa52, - 0x021, 0x00054000, - 0x040, 0x0000aa52, - 0x041, 0x00014000, - 0x025, 0x000803be, - 0x026, 0x000fc638, - 0x027, 0x00077c18, - 0x028, 0x000d1c31, - 0x029, 0x000d7110, - 0x02a, 0x000aeb04, - 0x02b, 0x0004128b, - 0x02c, 0x00001840, - 0x043, 0x0002444f, - 0x044, 0x0001adb0, - 0x045, 0x00056467, - 0x046, 0x0008992c, - 0x047, 0x0000452c, - 0x048, 0x000c0443, - 0x049, 0x00000730, - 0x04a, 0x00050f0f, - 0x04b, 0x000896ee, - 0x04c, 0x0000ddee, - 0x018, 0x00007401, - 0x000, 0x00070000, - 0x012, 0x000dc000, - 0x012, 0x00090000, - 0x012, 0x00051000, - 0x012, 0x00012000, - 0x013, 0x000287b7, - 0x013, 0x000247ab, - 0x013, 0x0002079f, - 0x013, 0x0001c793, - 0x013, 0x0001839b, - 0x013, 0x00014392, - 0x013, 0x0001019a, - 0x013, 0x0000c191, - 0x013, 0x00008194, - 0x013, 0x000040a0, - 0x013, 0x00000018, - 0x015, 0x0000f424, - 0x015, 0x0004f424, - 0x015, 0x0008f424, - 0x016, 0x000e1330, - 0x016, 0x000a1330, - 0x016, 0x00061330, - 0x016, 0x00021330, - 0x018, 0x00017524, - 0x000, 0x00070000, - 0x012, 0x000cf000, - 0x012, 0x000bc000, - 0x012, 0x00078000, - 0x012, 0x00000000, - 0x013, 0x000287bf, - 0x013, 0x000247b3, - 0x013, 0x000207a7, - 0x013, 0x0001c79b, - 0x013, 0x0001839f, - 0x013, 0x00014393, - 0x013, 0x00010399, - 0x013, 0x0000c38d, - 0x013, 0x00008199, - 0x013, 0x0000418d, - 0x013, 0x00000099, - 0x015, 0x0000f495, - 0x015, 0x0004f495, - 0x015, 0x0008f495, - 0x016, 0x000e1874, - 0x016, 0x000a1874, - 0x016, 0x00061874, - 0x016, 0x00021874, - 0x018, 0x00037564, - 0x000, 0x00070000, - 0x012, 0x000cf000, - 0x012, 0x000bc000, - 0x012, 0x00078000, - 0x012, 0x00000000, - 0x013, 0x000287bf, - 0x013, 0x000247b3, - 0x013, 0x000207a7, - 0x013, 0x0001c79b, - 0x013, 0x0001839f, - 0x013, 0x00014393, - 0x013, 0x00010399, - 0x013, 0x0000c38d, - 0x013, 0x00008199, - 0x013, 0x0000418d, - 0x013, 0x00000099, - 0x015, 0x0000f495, - 0x015, 0x0004f495, - 0x015, 0x0008f495, - 0x016, 0x000e1874, - 0x016, 0x000a1874, - 0x016, 0x00061874, - 0x016, 0x00021874, - 0x018, 0x00057595, - 0x000, 0x00070000, - 0x012, 0x000cf000, - 0x012, 0x000bc000, - 0x012, 0x00078000, - 0x012, 0x00000000, - 0x013, 0x000287bf, - 0x013, 0x000247b3, - 0x013, 0x000207a7, - 0x013, 0x0001c79b, - 0x013, 0x0001839f, - 0x013, 0x00014393, - 0x013, 0x00010399, - 0x013, 0x0000c38d, - 0x013, 0x00008199, - 0x013, 0x0000418d, - 0x013, 0x00000099, - 0x015, 0x0000f495, - 0x015, 0x0004f495, - 0x015, 0x0008f495, - 0x016, 0x000e1874, - 0x016, 0x000a1874, - 0x016, 0x00061874, - 0x016, 0x00021874, - 0x030, 0x0004470f, - 0x031, 0x00044ff0, - 0x032, 0x00000070, - 0x033, 0x000dd480, - 0x034, 0x000ffac0, - 0x035, 0x000b80c0, - 0x036, 0x00077000, - 0x037, 0x00064ff2, - 0x038, 0x000e7661, - 0x039, 0x00000e90, - 0x000, 0x00030000, - 0x018, 0x0000f401, - 0x0fe, 0x00000000, - 0x0fe, 0x00000000, - 0x01e, 0x00088009, - 0x01f, 0x00080003, - 0x0fe, 0x00000000, - 0x01e, 0x00088001, - 0x01f, 0x00080000, - 0x0fe, 0x00000000, - 0x018, 0x00087401, - 0x0fe, 0x00000000, - 0x0fe, 0x00000000, - 0x0fe, 0x00000000, - 0x02b, 0x00041289, - 0x0fe, 0x00000000, - 0x02d, 0x00066666, - 0x02e, 0x00064001, - 0x02d, 0x00091111, - 0x02e, 0x00014002, - 0x02d, 0x000bbbbb, - 0x02e, 0x000b4003, - 0x02d, 0x000e6666, - 0x02e, 0x00064004, - 0x02d, 0x00088888, - 0x02e, 0x00084005, - 0x02d, 0x0009dddd, - 0x02e, 0x000d4006, - 0x02d, 0x000b3333, - 0x02e, 0x00034007, - 0x02d, 0x00048888, - 0x02e, 0x00084408, - 0x02d, 0x000bbbbb, - 0x02e, 0x000b4409, - 0x02d, 0x000e6666, - 0x02e, 0x0006440a, - 0x02d, 0x00011111, - 0x02e, 0x0001480b, - 0x02d, 0x0003bbbb, - 0x02e, 0x000b480c, - 0x02d, 0x00066666, - 0x02e, 0x0006480d, - 0x02d, 0x000ccccc, - 0x02e, 0x000c480e, -}; - -u32 rtl8192de_mac_2tarray[MAC_2T_ARRAYLENGTH] = { - 0x420, 0x00000080, - 0x423, 0x00000000, - 0x430, 0x00000000, - 0x431, 0x00000000, - 0x432, 0x00000000, - 0x433, 0x00000001, - 0x434, 0x00000004, - 0x435, 0x00000005, - 0x436, 0x00000006, - 0x437, 0x00000007, - 0x438, 0x00000000, - 0x439, 0x00000000, - 0x43a, 0x00000000, - 0x43b, 0x00000001, - 0x43c, 0x00000004, - 0x43d, 0x00000005, - 0x43e, 0x00000006, - 0x43f, 0x00000007, - 0x440, 0x00000050, - 0x441, 0x00000001, - 0x442, 0x00000000, - 0x444, 0x00000015, - 0x445, 0x000000f0, - 0x446, 0x0000000f, - 0x447, 0x00000000, - 0x462, 0x00000008, - 0x463, 0x00000003, - 0x4c8, 0x000000ff, - 0x4c9, 0x00000008, - 0x4cc, 0x000000ff, - 0x4cd, 0x000000ff, - 0x4ce, 0x00000001, - 0x500, 0x00000026, - 0x501, 0x000000a2, - 0x502, 0x0000002f, - 0x503, 0x00000000, - 0x504, 0x00000028, - 0x505, 0x000000a3, - 0x506, 0x0000005e, - 0x507, 0x00000000, - 0x508, 0x0000002b, - 0x509, 0x000000a4, - 0x50a, 0x0000005e, - 0x50b, 0x00000000, - 0x50c, 0x0000004f, - 0x50d, 0x000000a4, - 0x50e, 0x00000000, - 0x50f, 0x00000000, - 0x512, 0x0000001c, - 0x514, 0x0000000a, - 0x515, 0x00000010, - 0x516, 0x0000000a, - 0x517, 0x00000010, - 0x51a, 0x00000016, - 0x524, 0x0000000f, - 0x525, 0x0000004f, - 0x546, 0x00000040, - 0x547, 0x00000000, - 0x550, 0x00000010, - 0x551, 0x00000010, - 0x559, 0x00000002, - 0x55a, 0x00000002, - 0x55d, 0x000000ff, - 0x605, 0x00000030, - 0x608, 0x0000000e, - 0x609, 0x0000002a, - 0x652, 0x00000020, - 0x63c, 0x0000000a, - 0x63d, 0x0000000a, - 0x63e, 0x0000000e, - 0x63f, 0x0000000e, - 0x66e, 0x00000005, - 0x700, 0x00000021, - 0x701, 0x00000043, - 0x702, 0x00000065, - 0x703, 0x00000087, - 0x708, 0x00000021, - 0x709, 0x00000043, - 0x70a, 0x00000065, - 0x70b, 0x00000087, -}; - -u32 rtl8192de_agctab_array[AGCTAB_ARRAYLENGTH] = { - 0xc78, 0x7b000001, - 0xc78, 0x7b010001, - 0xc78, 0x7b020001, - 0xc78, 0x7b030001, - 0xc78, 0x7b040001, - 0xc78, 0x7b050001, - 0xc78, 0x7b060001, - 0xc78, 0x7a070001, - 0xc78, 0x79080001, - 0xc78, 0x78090001, - 0xc78, 0x770a0001, - 0xc78, 0x760b0001, - 0xc78, 0x750c0001, - 0xc78, 0x740d0001, - 0xc78, 0x730e0001, - 0xc78, 0x720f0001, - 0xc78, 0x71100001, - 0xc78, 0x70110001, - 0xc78, 0x6f120001, - 0xc78, 0x6e130001, - 0xc78, 0x6d140001, - 0xc78, 0x6c150001, - 0xc78, 0x6b160001, - 0xc78, 0x6a170001, - 0xc78, 0x69180001, - 0xc78, 0x68190001, - 0xc78, 0x671a0001, - 0xc78, 0x661b0001, - 0xc78, 0x651c0001, - 0xc78, 0x641d0001, - 0xc78, 0x631e0001, - 0xc78, 0x621f0001, - 0xc78, 0x61200001, - 0xc78, 0x60210001, - 0xc78, 0x49220001, - 0xc78, 0x48230001, - 0xc78, 0x47240001, - 0xc78, 0x46250001, - 0xc78, 0x45260001, - 0xc78, 0x44270001, - 0xc78, 0x43280001, - 0xc78, 0x42290001, - 0xc78, 0x412a0001, - 0xc78, 0x402b0001, - 0xc78, 0x262c0001, - 0xc78, 0x252d0001, - 0xc78, 0x242e0001, - 0xc78, 0x232f0001, - 0xc78, 0x22300001, - 0xc78, 0x21310001, - 0xc78, 0x20320001, - 0xc78, 0x06330001, - 0xc78, 0x05340001, - 0xc78, 0x04350001, - 0xc78, 0x03360001, - 0xc78, 0x02370001, - 0xc78, 0x01380001, - 0xc78, 0x00390001, - 0xc78, 0x003a0001, - 0xc78, 0x003b0001, - 0xc78, 0x003c0001, - 0xc78, 0x003d0001, - 0xc78, 0x003e0001, - 0xc78, 0x003f0001, - 0xc78, 0x7b400001, - 0xc78, 0x7b410001, - 0xc78, 0x7a420001, - 0xc78, 0x79430001, - 0xc78, 0x78440001, - 0xc78, 0x77450001, - 0xc78, 0x76460001, - 0xc78, 0x75470001, - 0xc78, 0x74480001, - 0xc78, 0x73490001, - 0xc78, 0x724a0001, - 0xc78, 0x714b0001, - 0xc78, 0x704c0001, - 0xc78, 0x6f4d0001, - 0xc78, 0x6e4e0001, - 0xc78, 0x6d4f0001, - 0xc78, 0x6c500001, - 0xc78, 0x6b510001, - 0xc78, 0x6a520001, - 0xc78, 0x69530001, - 0xc78, 0x68540001, - 0xc78, 0x67550001, - 0xc78, 0x66560001, - 0xc78, 0x65570001, - 0xc78, 0x64580001, - 0xc78, 0x63590001, - 0xc78, 0x625a0001, - 0xc78, 0x615b0001, - 0xc78, 0x605c0001, - 0xc78, 0x485d0001, - 0xc78, 0x475e0001, - 0xc78, 0x465f0001, - 0xc78, 0x45600001, - 0xc78, 0x44610001, - 0xc78, 0x43620001, - 0xc78, 0x42630001, - 0xc78, 0x41640001, - 0xc78, 0x40650001, - 0xc78, 0x27660001, - 0xc78, 0x26670001, - 0xc78, 0x25680001, - 0xc78, 0x24690001, - 0xc78, 0x236a0001, - 0xc78, 0x226b0001, - 0xc78, 0x216c0001, - 0xc78, 0x206d0001, - 0xc78, 0x206e0001, - 0xc78, 0x206f0001, - 0xc78, 0x20700001, - 0xc78, 0x20710001, - 0xc78, 0x20720001, - 0xc78, 0x20730001, - 0xc78, 0x20740001, - 0xc78, 0x20750001, - 0xc78, 0x20760001, - 0xc78, 0x20770001, - 0xc78, 0x20780001, - 0xc78, 0x20790001, - 0xc78, 0x207a0001, - 0xc78, 0x207b0001, - 0xc78, 0x207c0001, - 0xc78, 0x207d0001, - 0xc78, 0x207e0001, - 0xc78, 0x207f0001, - 0xc78, 0x38000002, - 0xc78, 0x38010002, - 0xc78, 0x38020002, - 0xc78, 0x38030002, - 0xc78, 0x38040002, - 0xc78, 0x38050002, - 0xc78, 0x38060002, - 0xc78, 0x38070002, - 0xc78, 0x38080002, - 0xc78, 0x3c090002, - 0xc78, 0x3e0a0002, - 0xc78, 0x400b0002, - 0xc78, 0x440c0002, - 0xc78, 0x480d0002, - 0xc78, 0x4c0e0002, - 0xc78, 0x500f0002, - 0xc78, 0x52100002, - 0xc78, 0x56110002, - 0xc78, 0x5a120002, - 0xc78, 0x5e130002, - 0xc78, 0x60140002, - 0xc78, 0x60150002, - 0xc78, 0x60160002, - 0xc78, 0x62170002, - 0xc78, 0x62180002, - 0xc78, 0x62190002, - 0xc78, 0x621a0002, - 0xc78, 0x621b0002, - 0xc78, 0x621c0002, - 0xc78, 0x621d0002, - 0xc78, 0x621e0002, - 0xc78, 0x621f0002, - 0xc78, 0x32000044, - 0xc78, 0x32010044, - 0xc78, 0x32020044, - 0xc78, 0x32030044, - 0xc78, 0x32040044, - 0xc78, 0x32050044, - 0xc78, 0x32060044, - 0xc78, 0x32070044, - 0xc78, 0x32080044, - 0xc78, 0x34090044, - 0xc78, 0x350a0044, - 0xc78, 0x360b0044, - 0xc78, 0x370c0044, - 0xc78, 0x380d0044, - 0xc78, 0x390e0044, - 0xc78, 0x3a0f0044, - 0xc78, 0x3e100044, - 0xc78, 0x42110044, - 0xc78, 0x44120044, - 0xc78, 0x46130044, - 0xc78, 0x4a140044, - 0xc78, 0x4e150044, - 0xc78, 0x50160044, - 0xc78, 0x55170044, - 0xc78, 0x5a180044, - 0xc78, 0x5e190044, - 0xc78, 0x641a0044, - 0xc78, 0x6e1b0044, - 0xc78, 0x6e1c0044, - 0xc78, 0x6e1d0044, - 0xc78, 0x6e1e0044, - 0xc78, 0x6e1f0044, - 0xc78, 0x6e1f0000, -}; - -u32 rtl8192de_agctab_5garray[AGCTAB_5G_ARRAYLENGTH] = { - 0xc78, 0x7b000001, - 0xc78, 0x7b010001, - 0xc78, 0x7a020001, - 0xc78, 0x79030001, - 0xc78, 0x78040001, - 0xc78, 0x77050001, - 0xc78, 0x76060001, - 0xc78, 0x75070001, - 0xc78, 0x74080001, - 0xc78, 0x73090001, - 0xc78, 0x720a0001, - 0xc78, 0x710b0001, - 0xc78, 0x700c0001, - 0xc78, 0x6f0d0001, - 0xc78, 0x6e0e0001, - 0xc78, 0x6d0f0001, - 0xc78, 0x6c100001, - 0xc78, 0x6b110001, - 0xc78, 0x6a120001, - 0xc78, 0x69130001, - 0xc78, 0x68140001, - 0xc78, 0x67150001, - 0xc78, 0x66160001, - 0xc78, 0x65170001, - 0xc78, 0x64180001, - 0xc78, 0x63190001, - 0xc78, 0x621a0001, - 0xc78, 0x611b0001, - 0xc78, 0x601c0001, - 0xc78, 0x481d0001, - 0xc78, 0x471e0001, - 0xc78, 0x461f0001, - 0xc78, 0x45200001, - 0xc78, 0x44210001, - 0xc78, 0x43220001, - 0xc78, 0x42230001, - 0xc78, 0x41240001, - 0xc78, 0x40250001, - 0xc78, 0x27260001, - 0xc78, 0x26270001, - 0xc78, 0x25280001, - 0xc78, 0x24290001, - 0xc78, 0x232a0001, - 0xc78, 0x222b0001, - 0xc78, 0x212c0001, - 0xc78, 0x202d0001, - 0xc78, 0x202e0001, - 0xc78, 0x202f0001, - 0xc78, 0x20300001, - 0xc78, 0x20310001, - 0xc78, 0x20320001, - 0xc78, 0x20330001, - 0xc78, 0x20340001, - 0xc78, 0x20350001, - 0xc78, 0x20360001, - 0xc78, 0x20370001, - 0xc78, 0x20380001, - 0xc78, 0x20390001, - 0xc78, 0x203a0001, - 0xc78, 0x203b0001, - 0xc78, 0x203c0001, - 0xc78, 0x203d0001, - 0xc78, 0x203e0001, - 0xc78, 0x203f0001, - 0xc78, 0x32000044, - 0xc78, 0x32010044, - 0xc78, 0x32020044, - 0xc78, 0x32030044, - 0xc78, 0x32040044, - 0xc78, 0x32050044, - 0xc78, 0x32060044, - 0xc78, 0x32070044, - 0xc78, 0x32080044, - 0xc78, 0x34090044, - 0xc78, 0x350a0044, - 0xc78, 0x360b0044, - 0xc78, 0x370c0044, - 0xc78, 0x380d0044, - 0xc78, 0x390e0044, - 0xc78, 0x3a0f0044, - 0xc78, 0x3e100044, - 0xc78, 0x42110044, - 0xc78, 0x44120044, - 0xc78, 0x46130044, - 0xc78, 0x4a140044, - 0xc78, 0x4e150044, - 0xc78, 0x50160044, - 0xc78, 0x55170044, - 0xc78, 0x5a180044, - 0xc78, 0x5e190044, - 0xc78, 0x641a0044, - 0xc78, 0x6e1b0044, - 0xc78, 0x6e1c0044, - 0xc78, 0x6e1d0044, - 0xc78, 0x6e1e0044, - 0xc78, 0x6e1f0044, - 0xc78, 0x6e1f0000, -}; - -u32 rtl8192de_agctab_2garray[AGCTAB_2G_ARRAYLENGTH] = { - 0xc78, 0x7b000001, - 0xc78, 0x7b010001, - 0xc78, 0x7b020001, - 0xc78, 0x7b030001, - 0xc78, 0x7b040001, - 0xc78, 0x7b050001, - 0xc78, 0x7b060001, - 0xc78, 0x7a070001, - 0xc78, 0x79080001, - 0xc78, 0x78090001, - 0xc78, 0x770a0001, - 0xc78, 0x760b0001, - 0xc78, 0x750c0001, - 0xc78, 0x740d0001, - 0xc78, 0x730e0001, - 0xc78, 0x720f0001, - 0xc78, 0x71100001, - 0xc78, 0x70110001, - 0xc78, 0x6f120001, - 0xc78, 0x6e130001, - 0xc78, 0x6d140001, - 0xc78, 0x6c150001, - 0xc78, 0x6b160001, - 0xc78, 0x6a170001, - 0xc78, 0x69180001, - 0xc78, 0x68190001, - 0xc78, 0x671a0001, - 0xc78, 0x661b0001, - 0xc78, 0x651c0001, - 0xc78, 0x641d0001, - 0xc78, 0x631e0001, - 0xc78, 0x621f0001, - 0xc78, 0x61200001, - 0xc78, 0x60210001, - 0xc78, 0x49220001, - 0xc78, 0x48230001, - 0xc78, 0x47240001, - 0xc78, 0x46250001, - 0xc78, 0x45260001, - 0xc78, 0x44270001, - 0xc78, 0x43280001, - 0xc78, 0x42290001, - 0xc78, 0x412a0001, - 0xc78, 0x402b0001, - 0xc78, 0x262c0001, - 0xc78, 0x252d0001, - 0xc78, 0x242e0001, - 0xc78, 0x232f0001, - 0xc78, 0x22300001, - 0xc78, 0x21310001, - 0xc78, 0x20320001, - 0xc78, 0x06330001, - 0xc78, 0x05340001, - 0xc78, 0x04350001, - 0xc78, 0x03360001, - 0xc78, 0x02370001, - 0xc78, 0x01380001, - 0xc78, 0x00390001, - 0xc78, 0x003a0001, - 0xc78, 0x003b0001, - 0xc78, 0x003c0001, - 0xc78, 0x003d0001, - 0xc78, 0x003e0001, - 0xc78, 0x003f0001, - 0xc78, 0x38000002, - 0xc78, 0x38010002, - 0xc78, 0x38020002, - 0xc78, 0x38030002, - 0xc78, 0x38040002, - 0xc78, 0x38050002, - 0xc78, 0x38060002, - 0xc78, 0x38070002, - 0xc78, 0x38080002, - 0xc78, 0x3c090002, - 0xc78, 0x3e0a0002, - 0xc78, 0x400b0002, - 0xc78, 0x440c0002, - 0xc78, 0x480d0002, - 0xc78, 0x4c0e0002, - 0xc78, 0x500f0002, - 0xc78, 0x52100002, - 0xc78, 0x56110002, - 0xc78, 0x5a120002, - 0xc78, 0x5e130002, - 0xc78, 0x60140002, - 0xc78, 0x60150002, - 0xc78, 0x60160002, - 0xc78, 0x62170002, - 0xc78, 0x62180002, - 0xc78, 0x62190002, - 0xc78, 0x621a0002, - 0xc78, 0x621b0002, - 0xc78, 0x621c0002, - 0xc78, 0x621d0002, - 0xc78, 0x621e0002, - 0xc78, 0x621f0002, - 0xc78, 0x6e1f0000, -}; diff --git a/trunk/drivers/net/wireless/rtlwifi/rtl8192de/table.h b/trunk/drivers/net/wireless/rtlwifi/rtl8192de/table.h deleted file mode 100644 index 93f30ca62d8f..000000000000 --- a/trunk/drivers/net/wireless/rtlwifi/rtl8192de/table.h +++ /dev/null @@ -1,57 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2009-2010 Realtek Corporation. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * The full GNU General Public License is included in this distribution in the - * file called LICENSE. - * - * Contact Information: - * wlanfae - * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, - * Hsinchu 300, Taiwan. - * - * Larry Finger - * - * Created on 2010/ 5/18, 1:41 - *****************************************************************************/ - -#ifndef __RTL92DE_TABLE__H_ -#define __RTL92DE_TABLE__H_ - -/*Created on 2011/ 1/14, 1:35*/ - -#define PHY_REG_2T_ARRAYLENGTH 380 -extern u32 rtl8192de_phy_reg_2tarray[PHY_REG_2T_ARRAYLENGTH]; -#define PHY_REG_ARRAY_PG_LENGTH 624 -extern u32 rtl8192de_phy_reg_array_pg[PHY_REG_ARRAY_PG_LENGTH]; -#define RADIOA_2T_ARRAYLENGTH 378 -extern u32 rtl8192de_radioa_2tarray[RADIOA_2T_ARRAYLENGTH]; -#define RADIOB_2T_ARRAYLENGTH 384 -extern u32 rtl8192de_radiob_2tarray[RADIOB_2T_ARRAYLENGTH]; -#define RADIOA_2T_INT_PA_ARRAYLENGTH 378 -extern u32 rtl8192de_radioa_2t_int_paarray[RADIOA_2T_INT_PA_ARRAYLENGTH]; -#define RADIOB_2T_INT_PA_ARRAYLENGTH 384 -extern u32 rtl8192de_radiob_2t_int_paarray[RADIOB_2T_INT_PA_ARRAYLENGTH]; -#define MAC_2T_ARRAYLENGTH 160 -extern u32 rtl8192de_mac_2tarray[MAC_2T_ARRAYLENGTH]; -#define AGCTAB_ARRAYLENGTH 386 -extern u32 rtl8192de_agctab_array[AGCTAB_ARRAYLENGTH]; -#define AGCTAB_5G_ARRAYLENGTH 194 -extern u32 rtl8192de_agctab_5garray[AGCTAB_5G_ARRAYLENGTH]; -#define AGCTAB_2G_ARRAYLENGTH 194 -extern u32 rtl8192de_agctab_2garray[AGCTAB_2G_ARRAYLENGTH]; - -#endif diff --git a/trunk/drivers/net/wireless/rtlwifi/rtl8192de/trx.c b/trunk/drivers/net/wireless/rtlwifi/rtl8192de/trx.c deleted file mode 100644 index dc86fcb0b3a3..000000000000 --- a/trunk/drivers/net/wireless/rtlwifi/rtl8192de/trx.c +++ /dev/null @@ -1,959 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2009-2010 Realtek Corporation. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * The full GNU General Public License is included in this distribution in the - * file called LICENSE. - * - * Contact Information: - * wlanfae - * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, - * Hsinchu 300, Taiwan. - * - * Larry Finger - * - *****************************************************************************/ - -#include "../wifi.h" -#include "../pci.h" -#include "../base.h" -#include "reg.h" -#include "def.h" -#include "phy.h" -#include "trx.h" -#include "led.h" - -static u8 _rtl92de_map_hwqueue_to_fwqueue(struct sk_buff *skb, u8 hw_queue) -{ - __le16 fc = rtl_get_fc(skb); - - if (unlikely(ieee80211_is_beacon(fc))) - return QSLT_BEACON; - if (ieee80211_is_mgmt(fc)) - return QSLT_MGNT; - - return skb->priority; -} - -static int _rtl92de_rate_mapping(bool isht, u8 desc_rate) -{ - int rate_idx; - - if (false == isht) { - switch (desc_rate) { - case DESC92D_RATE1M: - rate_idx = 0; - break; - case DESC92D_RATE2M: - rate_idx = 1; - break; - case DESC92D_RATE5_5M: - rate_idx = 2; - break; - case DESC92D_RATE11M: - rate_idx = 3; - break; - case DESC92D_RATE6M: - rate_idx = 4; - break; - case DESC92D_RATE9M: - rate_idx = 5; - break; - case DESC92D_RATE12M: - rate_idx = 6; - break; - case DESC92D_RATE18M: - rate_idx = 7; - break; - case DESC92D_RATE24M: - rate_idx = 8; - break; - case DESC92D_RATE36M: - rate_idx = 9; - break; - case DESC92D_RATE48M: - rate_idx = 10; - break; - case DESC92D_RATE54M: - rate_idx = 11; - break; - default: - rate_idx = 0; - break; - } - return rate_idx; - } else { - switch (desc_rate) { - case DESC92D_RATE1M: - rate_idx = 0; - break; - case DESC92D_RATE2M: - rate_idx = 1; - break; - case DESC92D_RATE5_5M: - rate_idx = 2; - break; - case DESC92D_RATE11M: - rate_idx = 3; - break; - case DESC92D_RATE6M: - rate_idx = 4; - break; - case DESC92D_RATE9M: - rate_idx = 5; - break; - case DESC92D_RATE12M: - rate_idx = 6; - break; - case DESC92D_RATE18M: - rate_idx = 7; - break; - case DESC92D_RATE24M: - rate_idx = 8; - break; - case DESC92D_RATE36M: - rate_idx = 9; - break; - case DESC92D_RATE48M: - rate_idx = 10; - break; - case DESC92D_RATE54M: - rate_idx = 11; - break; - default: - rate_idx = 11; - break; - } - return rate_idx; - } -} - -static u8 _rtl92d_query_rxpwrpercentage(char antpower) -{ - if ((antpower <= -100) || (antpower >= 20)) - return 0; - else if (antpower >= 0) - return 100; - else - return 100 + antpower; -} - -static u8 _rtl92d_evm_db_to_percentage(char value) -{ - char ret_val = value; - - if (ret_val >= 0) - ret_val = 0; - if (ret_val <= -33) - ret_val = -33; - ret_val = 0 - ret_val; - ret_val *= 3; - if (ret_val == 99) - ret_val = 100; - return ret_val; -} - -static long _rtl92de_translate_todbm(struct ieee80211_hw *hw, - u8 signal_strength_index) -{ - long signal_power; - - signal_power = (long)((signal_strength_index + 1) >> 1); - signal_power -= 95; - return signal_power; -} - -static long _rtl92de_signal_scale_mapping(struct ieee80211_hw *hw, long currsig) -{ - long retsig; - - if (currsig >= 61 && currsig <= 100) - retsig = 90 + ((currsig - 60) / 4); - else if (currsig >= 41 && currsig <= 60) - retsig = 78 + ((currsig - 40) / 2); - else if (currsig >= 31 && currsig <= 40) - retsig = 66 + (currsig - 30); - else if (currsig >= 21 && currsig <= 30) - retsig = 54 + (currsig - 20); - else if (currsig >= 5 && currsig <= 20) - retsig = 42 + (((currsig - 5) * 2) / 3); - else if (currsig == 4) - retsig = 36; - else if (currsig == 3) - retsig = 27; - else if (currsig == 2) - retsig = 18; - else if (currsig == 1) - retsig = 9; - else - retsig = currsig; - return retsig; -} - -static void _rtl92de_query_rxphystatus(struct ieee80211_hw *hw, - struct rtl_stats *pstats, - struct rx_desc_92d *pdesc, - struct rx_fwinfo_92d *p_drvinfo, - bool packet_match_bssid, - bool packet_toself, - bool packet_beacon) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_ps_ctl *ppsc = rtl_psc(rtlpriv); - struct phy_sts_cck_8192d *cck_buf; - s8 rx_pwr_all, rx_pwr[4]; - u8 rf_rx_num = 0, evm, pwdb_all; - u8 i, max_spatial_stream; - u32 rssi, total_rssi = 0; - bool is_cck_rate; - - is_cck_rate = RX_HAL_IS_CCK_RATE(pdesc); - pstats->packet_matchbssid = packet_match_bssid; - pstats->packet_toself = packet_toself; - pstats->packet_beacon = packet_beacon; - pstats->is_cck = is_cck_rate; - pstats->rx_mimo_signalquality[0] = -1; - pstats->rx_mimo_signalquality[1] = -1; - - if (is_cck_rate) { - u8 report, cck_highpwr; - cck_buf = (struct phy_sts_cck_8192d *)p_drvinfo; - if (ppsc->rfpwr_state == ERFON) - cck_highpwr = (u8) rtl_get_bbreg(hw, - RFPGA0_XA_HSSIPARAMETER2, - BIT(9)); - else - cck_highpwr = false; - if (!cck_highpwr) { - u8 cck_agc_rpt = cck_buf->cck_agc_rpt; - report = cck_buf->cck_agc_rpt & 0xc0; - report = report >> 6; - switch (report) { - case 0x3: - rx_pwr_all = -46 - (cck_agc_rpt & 0x3e); - break; - case 0x2: - rx_pwr_all = -26 - (cck_agc_rpt & 0x3e); - break; - case 0x1: - rx_pwr_all = -12 - (cck_agc_rpt & 0x3e); - break; - case 0x0: - rx_pwr_all = 16 - (cck_agc_rpt & 0x3e); - break; - } - } else { - u8 cck_agc_rpt = cck_buf->cck_agc_rpt; - report = p_drvinfo->cfosho[0] & 0x60; - report = report >> 5; - switch (report) { - case 0x3: - rx_pwr_all = -46 - ((cck_agc_rpt & 0x1f) << 1); - break; - case 0x2: - rx_pwr_all = -26 - ((cck_agc_rpt & 0x1f) << 1); - break; - case 0x1: - rx_pwr_all = -12 - ((cck_agc_rpt & 0x1f) << 1); - break; - case 0x0: - rx_pwr_all = 16 - ((cck_agc_rpt & 0x1f) << 1); - break; - } - } - pwdb_all = _rtl92d_query_rxpwrpercentage(rx_pwr_all); - /* CCK gain is smaller than OFDM/MCS gain, */ - /* so we add gain diff by experiences, the val is 6 */ - pwdb_all += 6; - if (pwdb_all > 100) - pwdb_all = 100; - /* modify the offset to make the same gain index with OFDM. */ - if (pwdb_all > 34 && pwdb_all <= 42) - pwdb_all -= 2; - else if (pwdb_all > 26 && pwdb_all <= 34) - pwdb_all -= 6; - else if (pwdb_all > 14 && pwdb_all <= 26) - pwdb_all -= 8; - else if (pwdb_all > 4 && pwdb_all <= 14) - pwdb_all -= 4; - pstats->rx_pwdb_all = pwdb_all; - pstats->recvsignalpower = rx_pwr_all; - if (packet_match_bssid) { - u8 sq; - if (pstats->rx_pwdb_all > 40) { - sq = 100; - } else { - sq = cck_buf->sq_rpt; - if (sq > 64) - sq = 0; - else if (sq < 20) - sq = 100; - else - sq = ((64 - sq) * 100) / 44; - } - pstats->signalquality = sq; - pstats->rx_mimo_signalquality[0] = sq; - pstats->rx_mimo_signalquality[1] = -1; - } - } else { - rtlpriv->dm.rfpath_rxenable[0] = true; - rtlpriv->dm.rfpath_rxenable[1] = true; - for (i = RF90_PATH_A; i < RF6052_MAX_PATH; i++) { - if (rtlpriv->dm.rfpath_rxenable[i]) - rf_rx_num++; - rx_pwr[i] = ((p_drvinfo->gain_trsw[i] & 0x3f) * 2) - - 110; - rssi = _rtl92d_query_rxpwrpercentage(rx_pwr[i]); - total_rssi += rssi; - rtlpriv->stats.rx_snr_db[i] = - (long)(p_drvinfo->rxsnr[i] / 2); - if (packet_match_bssid) - pstats->rx_mimo_signalstrength[i] = (u8) rssi; - } - rx_pwr_all = ((p_drvinfo->pwdb_all >> 1) & 0x7f) - 106; - pwdb_all = _rtl92d_query_rxpwrpercentage(rx_pwr_all); - pstats->rx_pwdb_all = pwdb_all; - pstats->rxpower = rx_pwr_all; - pstats->recvsignalpower = rx_pwr_all; - if (pdesc->rxht && pdesc->rxmcs >= DESC92D_RATEMCS8 && - pdesc->rxmcs <= DESC92D_RATEMCS15) - max_spatial_stream = 2; - else - max_spatial_stream = 1; - for (i = 0; i < max_spatial_stream; i++) { - evm = _rtl92d_evm_db_to_percentage(p_drvinfo->rxevm[i]); - if (packet_match_bssid) { - if (i == 0) - pstats->signalquality = - (u8)(evm & 0xff); - pstats->rx_mimo_signalquality[i] = - (u8)(evm & 0xff); - } - } - } - if (is_cck_rate) - pstats->signalstrength = (u8)(_rtl92de_signal_scale_mapping(hw, - pwdb_all)); - else if (rf_rx_num != 0) - pstats->signalstrength = (u8)(_rtl92de_signal_scale_mapping(hw, - total_rssi /= rf_rx_num)); -} - -static void rtl92d_loop_over_paths(struct ieee80211_hw *hw, - struct rtl_stats *pstats) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_phy *rtlphy = &(rtlpriv->phy); - u8 rfpath; - - for (rfpath = RF90_PATH_A; rfpath < rtlphy->num_total_rfpath; - rfpath++) { - if (rtlpriv->stats.rx_rssi_percentage[rfpath] == 0) { - rtlpriv->stats.rx_rssi_percentage[rfpath] = - pstats->rx_mimo_signalstrength[rfpath]; - - } - if (pstats->rx_mimo_signalstrength[rfpath] > - rtlpriv->stats.rx_rssi_percentage[rfpath]) { - rtlpriv->stats.rx_rssi_percentage[rfpath] = - ((rtlpriv->stats.rx_rssi_percentage[rfpath] * - (RX_SMOOTH_FACTOR - 1)) + - (pstats->rx_mimo_signalstrength[rfpath])) / - (RX_SMOOTH_FACTOR); - rtlpriv->stats.rx_rssi_percentage[rfpath] = - rtlpriv->stats.rx_rssi_percentage[rfpath] + 1; - } else { - rtlpriv->stats.rx_rssi_percentage[rfpath] = - ((rtlpriv->stats.rx_rssi_percentage[rfpath] * - (RX_SMOOTH_FACTOR - 1)) + - (pstats->rx_mimo_signalstrength[rfpath])) / - (RX_SMOOTH_FACTOR); - } - } -} - -static void _rtl92de_process_ui_rssi(struct ieee80211_hw *hw, - struct rtl_stats *pstats) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - u32 last_rssi, tmpval; - - if (pstats->packet_toself || pstats->packet_beacon) { - rtlpriv->stats.rssi_calculate_cnt++; - if (rtlpriv->stats.ui_rssi.total_num++ >= - PHY_RSSI_SLID_WIN_MAX) { - rtlpriv->stats.ui_rssi.total_num = - PHY_RSSI_SLID_WIN_MAX; - last_rssi = rtlpriv->stats.ui_rssi.elements[ - rtlpriv->stats.ui_rssi.index]; - rtlpriv->stats.ui_rssi.total_val -= last_rssi; - } - rtlpriv->stats.ui_rssi.total_val += pstats->signalstrength; - rtlpriv->stats.ui_rssi.elements - [rtlpriv->stats.ui_rssi.index++] = - pstats->signalstrength; - if (rtlpriv->stats.ui_rssi.index >= PHY_RSSI_SLID_WIN_MAX) - rtlpriv->stats.ui_rssi.index = 0; - tmpval = rtlpriv->stats.ui_rssi.total_val / - rtlpriv->stats.ui_rssi.total_num; - rtlpriv->stats.signal_strength = _rtl92de_translate_todbm(hw, - (u8) tmpval); - pstats->rssi = rtlpriv->stats.signal_strength; - } - if (!pstats->is_cck && pstats->packet_toself) - rtl92d_loop_over_paths(hw, pstats); -} - -static void _rtl92de_update_rxsignalstatistics(struct ieee80211_hw *hw, - struct rtl_stats *pstats) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - int weighting = 0; - - if (rtlpriv->stats.recv_signal_power == 0) - rtlpriv->stats.recv_signal_power = pstats->recvsignalpower; - if (pstats->recvsignalpower > rtlpriv->stats.recv_signal_power) - weighting = 5; - else if (pstats->recvsignalpower < rtlpriv->stats.recv_signal_power) - weighting = (-5); - rtlpriv->stats.recv_signal_power = (rtlpriv->stats.recv_signal_power * - 5 + pstats->recvsignalpower + weighting) / 6; -} - -static void _rtl92de_process_pwdb(struct ieee80211_hw *hw, - struct rtl_stats *pstats) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); - long undecorated_smoothed_pwdb; - - if (mac->opmode == NL80211_IFTYPE_ADHOC || - mac->opmode == NL80211_IFTYPE_AP) - return; - else - undecorated_smoothed_pwdb = - rtlpriv->dm.undecorated_smoothed_pwdb; - - if (pstats->packet_toself || pstats->packet_beacon) { - if (undecorated_smoothed_pwdb < 0) - undecorated_smoothed_pwdb = pstats->rx_pwdb_all; - if (pstats->rx_pwdb_all > (u32) undecorated_smoothed_pwdb) { - undecorated_smoothed_pwdb = - (((undecorated_smoothed_pwdb) * - (RX_SMOOTH_FACTOR - 1)) + - (pstats->rx_pwdb_all)) / (RX_SMOOTH_FACTOR); - undecorated_smoothed_pwdb = - undecorated_smoothed_pwdb + 1; - } else { - undecorated_smoothed_pwdb = - (((undecorated_smoothed_pwdb) * - (RX_SMOOTH_FACTOR - 1)) + - (pstats->rx_pwdb_all)) / (RX_SMOOTH_FACTOR); - } - rtlpriv->dm.undecorated_smoothed_pwdb = - undecorated_smoothed_pwdb; - _rtl92de_update_rxsignalstatistics(hw, pstats); - } -} - -static void rtl92d_loop_over_streams(struct ieee80211_hw *hw, - struct rtl_stats *pstats) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - int stream; - - for (stream = 0; stream < 2; stream++) { - if (pstats->rx_mimo_signalquality[stream] != -1) { - if (rtlpriv->stats.rx_evm_percentage[stream] == 0) { - rtlpriv->stats.rx_evm_percentage[stream] = - pstats->rx_mimo_signalquality[stream]; - } - rtlpriv->stats.rx_evm_percentage[stream] = - ((rtlpriv->stats.rx_evm_percentage[stream] - * (RX_SMOOTH_FACTOR - 1)) + - (pstats->rx_mimo_signalquality[stream] * 1)) / - (RX_SMOOTH_FACTOR); - } - } -} - -static void _rtl92de_process_ui_link_quality(struct ieee80211_hw *hw, - struct rtl_stats *pstats) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - u32 last_evm, tmpval; - - if (pstats->signalquality == 0) - return; - if (pstats->packet_toself || pstats->packet_beacon) { - if (rtlpriv->stats.ui_link_quality.total_num++ >= - PHY_LINKQUALITY_SLID_WIN_MAX) { - rtlpriv->stats.ui_link_quality.total_num = - PHY_LINKQUALITY_SLID_WIN_MAX; - last_evm = rtlpriv->stats.ui_link_quality.elements[ - rtlpriv->stats.ui_link_quality.index]; - rtlpriv->stats.ui_link_quality.total_val -= last_evm; - } - rtlpriv->stats.ui_link_quality.total_val += - pstats->signalquality; - rtlpriv->stats.ui_link_quality.elements[ - rtlpriv->stats.ui_link_quality.index++] = - pstats->signalquality; - if (rtlpriv->stats.ui_link_quality.index >= - PHY_LINKQUALITY_SLID_WIN_MAX) - rtlpriv->stats.ui_link_quality.index = 0; - tmpval = rtlpriv->stats.ui_link_quality.total_val / - rtlpriv->stats.ui_link_quality.total_num; - rtlpriv->stats.signal_quality = tmpval; - rtlpriv->stats.last_sigstrength_inpercent = tmpval; - rtl92d_loop_over_streams(hw, pstats); - } -} - -static void _rtl92de_process_phyinfo(struct ieee80211_hw *hw, - u8 *buffer, - struct rtl_stats *pcurrent_stats) -{ - - if (!pcurrent_stats->packet_matchbssid && - !pcurrent_stats->packet_beacon) - return; - - _rtl92de_process_ui_rssi(hw, pcurrent_stats); - _rtl92de_process_pwdb(hw, pcurrent_stats); - _rtl92de_process_ui_link_quality(hw, pcurrent_stats); -} - -static void _rtl92de_translate_rx_signal_stuff(struct ieee80211_hw *hw, - struct sk_buff *skb, - struct rtl_stats *pstats, - struct rx_desc_92d *pdesc, - struct rx_fwinfo_92d *p_drvinfo) -{ - struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); - struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw)); - struct ieee80211_hdr *hdr; - u8 *tmp_buf; - u8 *praddr; - u16 type, cfc; - __le16 fc; - bool packet_matchbssid, packet_toself, packet_beacon; - - tmp_buf = skb->data + pstats->rx_drvinfo_size + pstats->rx_bufshift; - hdr = (struct ieee80211_hdr *)tmp_buf; - fc = hdr->frame_control; - cfc = le16_to_cpu(fc); - type = WLAN_FC_GET_TYPE(fc); - praddr = hdr->addr1; - packet_matchbssid = ((IEEE80211_FTYPE_CTL != type) && - (!compare_ether_addr(mac->bssid, (cfc & IEEE80211_FCTL_TODS) ? - hdr->addr1 : (cfc & IEEE80211_FCTL_FROMDS) ? - hdr->addr2 : hdr->addr3)) && (!pstats->hwerror) && - (!pstats->crc) && (!pstats->icv)); - packet_toself = packet_matchbssid && - (!compare_ether_addr(praddr, rtlefuse->dev_addr)); - if (ieee80211_is_beacon(fc)) - packet_beacon = true; - _rtl92de_query_rxphystatus(hw, pstats, pdesc, p_drvinfo, - packet_matchbssid, packet_toself, - packet_beacon); - _rtl92de_process_phyinfo(hw, tmp_buf, pstats); -} - -bool rtl92de_rx_query_desc(struct ieee80211_hw *hw, struct rtl_stats *stats, - struct ieee80211_rx_status *rx_status, - u8 *p_desc, struct sk_buff *skb) -{ - struct rx_fwinfo_92d *p_drvinfo; - struct rx_desc_92d *pdesc = (struct rx_desc_92d *)p_desc; - u32 phystatus = GET_RX_DESC_PHYST(pdesc); - - stats->length = (u16) GET_RX_DESC_PKT_LEN(pdesc); - stats->rx_drvinfo_size = (u8) GET_RX_DESC_DRV_INFO_SIZE(pdesc) * - RX_DRV_INFO_SIZE_UNIT; - stats->rx_bufshift = (u8) (GET_RX_DESC_SHIFT(pdesc) & 0x03); - stats->icv = (u16) GET_RX_DESC_ICV(pdesc); - stats->crc = (u16) GET_RX_DESC_CRC32(pdesc); - stats->hwerror = (stats->crc | stats->icv); - stats->decrypted = !GET_RX_DESC_SWDEC(pdesc); - stats->rate = (u8) GET_RX_DESC_RXMCS(pdesc); - stats->shortpreamble = (u16) GET_RX_DESC_SPLCP(pdesc); - stats->isampdu = (bool) (GET_RX_DESC_PAGGR(pdesc) == 1); - stats->isfirst_ampdu = (bool) ((GET_RX_DESC_PAGGR(pdesc) == 1) - && (GET_RX_DESC_FAGGR(pdesc) == 1)); - stats->timestamp_low = GET_RX_DESC_TSFL(pdesc); - stats->rx_is40Mhzpacket = (bool) GET_RX_DESC_BW(pdesc); - rx_status->freq = hw->conf.channel->center_freq; - rx_status->band = hw->conf.channel->band; - if (GET_RX_DESC_CRC32(pdesc)) - rx_status->flag |= RX_FLAG_FAILED_FCS_CRC; - if (!GET_RX_DESC_SWDEC(pdesc)) - rx_status->flag |= RX_FLAG_DECRYPTED; - if (GET_RX_DESC_BW(pdesc)) - rx_status->flag |= RX_FLAG_40MHZ; - if (GET_RX_DESC_RXHT(pdesc)) - rx_status->flag |= RX_FLAG_HT; - rx_status->flag |= RX_FLAG_MACTIME_MPDU; - if (stats->decrypted) - rx_status->flag |= RX_FLAG_DECRYPTED; - rx_status->rate_idx = _rtl92de_rate_mapping((bool) - GET_RX_DESC_RXHT(pdesc), - (u8) - GET_RX_DESC_RXMCS(pdesc)); - rx_status->mactime = GET_RX_DESC_TSFL(pdesc); - if (phystatus) { - p_drvinfo = (struct rx_fwinfo_92d *)(skb->data + - stats->rx_bufshift); - _rtl92de_translate_rx_signal_stuff(hw, - skb, stats, pdesc, - p_drvinfo); - } - /*rx_status->qual = stats->signal; */ - rx_status->signal = stats->rssi + 10; - /*rx_status->noise = -stats->noise; */ - return true; -} - -static void _rtl92de_insert_emcontent(struct rtl_tcb_desc *ptcb_desc, - u8 *virtualaddress) -{ - memset(virtualaddress, 0, 8); - - SET_EARLYMODE_PKTNUM(virtualaddress, ptcb_desc->empkt_num); - SET_EARLYMODE_LEN0(virtualaddress, ptcb_desc->empkt_len[0]); - SET_EARLYMODE_LEN1(virtualaddress, ptcb_desc->empkt_len[1]); - SET_EARLYMODE_LEN2_1(virtualaddress, ptcb_desc->empkt_len[2] & 0xF); - SET_EARLYMODE_LEN2_2(virtualaddress, ptcb_desc->empkt_len[2] >> 4); - SET_EARLYMODE_LEN3(virtualaddress, ptcb_desc->empkt_len[3]); - SET_EARLYMODE_LEN4(virtualaddress, ptcb_desc->empkt_len[4]); -} - -void rtl92de_tx_fill_desc(struct ieee80211_hw *hw, - struct ieee80211_hdr *hdr, u8 *pdesc_tx, - struct ieee80211_tx_info *info, struct sk_buff *skb, - u8 hw_queue, struct rtl_tcb_desc *ptcb_desc) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); - struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); - struct rtl_hal *rtlhal = rtl_hal(rtlpriv); - struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); - struct ieee80211_sta *sta = info->control.sta; - u8 *pdesc = (u8 *) pdesc_tx; - u16 seq_number; - __le16 fc = hdr->frame_control; - unsigned int buf_len = 0; - unsigned int skb_len = skb->len; - u8 fw_qsel = _rtl92de_map_hwqueue_to_fwqueue(skb, hw_queue); - bool firstseg = ((hdr->seq_ctrl & - cpu_to_le16(IEEE80211_SCTL_FRAG)) == 0); - bool lastseg = ((hdr->frame_control & - cpu_to_le16(IEEE80211_FCTL_MOREFRAGS)) == 0); - dma_addr_t mapping; - u8 bw_40 = 0; - - if (mac->opmode == NL80211_IFTYPE_STATION) { - bw_40 = mac->bw_40; - } else if (mac->opmode == NL80211_IFTYPE_AP || - mac->opmode == NL80211_IFTYPE_ADHOC) { - if (sta) - bw_40 = sta->ht_cap.cap & - IEEE80211_HT_CAP_SUP_WIDTH_20_40; - } - seq_number = (le16_to_cpu(hdr->seq_ctrl) & IEEE80211_SCTL_SEQ) >> 4; - rtl_get_tcb_desc(hw, info, sta, skb, ptcb_desc); - /* reserve 8 byte for AMPDU early mode */ - if (rtlhal->earlymode_enable) { - skb_push(skb, EM_HDR_LEN); - memset(skb->data, 0, EM_HDR_LEN); - } - buf_len = skb->len; - mapping = pci_map_single(rtlpci->pdev, skb->data, skb->len, - PCI_DMA_TODEVICE); - CLEAR_PCI_TX_DESC_CONTENT(pdesc, sizeof(struct tx_desc_92d)); - if (ieee80211_is_nullfunc(fc) || ieee80211_is_ctl(fc)) { - firstseg = true; - lastseg = true; - } - if (firstseg) { - if (rtlhal->earlymode_enable) { - SET_TX_DESC_PKT_OFFSET(pdesc, 1); - SET_TX_DESC_OFFSET(pdesc, USB_HWDESC_HEADER_LEN + - EM_HDR_LEN); - if (ptcb_desc->empkt_num) { - RT_TRACE(rtlpriv, COMP_SEND, DBG_LOUD, - ("Insert 8 byte.pTcb->EMPktNum:%d\n", - ptcb_desc->empkt_num)); - _rtl92de_insert_emcontent(ptcb_desc, - (u8 *)(skb->data)); - } - } else { - SET_TX_DESC_OFFSET(pdesc, USB_HWDESC_HEADER_LEN); - } - /* 5G have no CCK rate */ - if (rtlhal->current_bandtype == BAND_ON_5G) - if (ptcb_desc->hw_rate < DESC92D_RATE6M) - ptcb_desc->hw_rate = DESC92D_RATE6M; - SET_TX_DESC_TX_RATE(pdesc, ptcb_desc->hw_rate); - if (ptcb_desc->use_shortgi || ptcb_desc->use_shortpreamble) - SET_TX_DESC_DATA_SHORTGI(pdesc, 1); - - if (rtlhal->macphymode == DUALMAC_DUALPHY && - ptcb_desc->hw_rate == DESC92D_RATEMCS7) - SET_TX_DESC_DATA_SHORTGI(pdesc, 1); - - if (info->flags & IEEE80211_TX_CTL_AMPDU) { - SET_TX_DESC_AGG_ENABLE(pdesc, 1); - SET_TX_DESC_MAX_AGG_NUM(pdesc, 0x14); - } - SET_TX_DESC_SEQ(pdesc, seq_number); - SET_TX_DESC_RTS_ENABLE(pdesc, ((ptcb_desc->rts_enable && - !ptcb_desc->cts_enable) ? 1 : 0)); - SET_TX_DESC_HW_RTS_ENABLE(pdesc, ((ptcb_desc->rts_enable - || ptcb_desc->cts_enable) ? 1 : 0)); - SET_TX_DESC_CTS2SELF(pdesc, ((ptcb_desc->cts_enable) ? 1 : 0)); - SET_TX_DESC_RTS_STBC(pdesc, ((ptcb_desc->rts_stbc) ? 1 : 0)); - /* 5G have no CCK rate */ - if (rtlhal->current_bandtype == BAND_ON_5G) - if (ptcb_desc->rts_rate < DESC92D_RATE6M) - ptcb_desc->rts_rate = DESC92D_RATE6M; - SET_TX_DESC_RTS_RATE(pdesc, ptcb_desc->rts_rate); - SET_TX_DESC_RTS_BW(pdesc, 0); - SET_TX_DESC_RTS_SC(pdesc, ptcb_desc->rts_sc); - SET_TX_DESC_RTS_SHORT(pdesc, ((ptcb_desc->rts_rate <= - DESC92D_RATE54M) ? - (ptcb_desc->rts_use_shortpreamble ? 1 : 0) : - (ptcb_desc->rts_use_shortgi ? 1 : 0))); - if (bw_40) { - if (ptcb_desc->packet_bw) { - SET_TX_DESC_DATA_BW(pdesc, 1); - SET_TX_DESC_TX_SUB_CARRIER(pdesc, 3); - } else { - SET_TX_DESC_DATA_BW(pdesc, 0); - SET_TX_DESC_TX_SUB_CARRIER(pdesc, - mac->cur_40_prime_sc); - } - } else { - SET_TX_DESC_DATA_BW(pdesc, 0); - SET_TX_DESC_TX_SUB_CARRIER(pdesc, 0); - } - SET_TX_DESC_LINIP(pdesc, 0); - SET_TX_DESC_PKT_SIZE(pdesc, (u16) skb_len); - if (sta) { - u8 ampdu_density = sta->ht_cap.ampdu_density; - SET_TX_DESC_AMPDU_DENSITY(pdesc, ampdu_density); - } - if (info->control.hw_key) { - struct ieee80211_key_conf *keyconf; - - keyconf = info->control.hw_key; - switch (keyconf->cipher) { - case WLAN_CIPHER_SUITE_WEP40: - case WLAN_CIPHER_SUITE_WEP104: - case WLAN_CIPHER_SUITE_TKIP: - SET_TX_DESC_SEC_TYPE(pdesc, 0x1); - break; - case WLAN_CIPHER_SUITE_CCMP: - SET_TX_DESC_SEC_TYPE(pdesc, 0x3); - break; - default: - SET_TX_DESC_SEC_TYPE(pdesc, 0x0); - break; - - } - } - SET_TX_DESC_PKT_ID(pdesc, 0); - SET_TX_DESC_QUEUE_SEL(pdesc, fw_qsel); - SET_TX_DESC_DATA_RATE_FB_LIMIT(pdesc, 0x1F); - SET_TX_DESC_RTS_RATE_FB_LIMIT(pdesc, 0xF); - SET_TX_DESC_DISABLE_FB(pdesc, ptcb_desc->disable_ratefallback ? - 1 : 0); - SET_TX_DESC_USE_RATE(pdesc, ptcb_desc->use_driver_rate ? 1 : 0); - - /* Set TxRate and RTSRate in TxDesc */ - /* This prevent Tx initial rate of new-coming packets */ - /* from being overwritten by retried packet rate.*/ - if (!ptcb_desc->use_driver_rate) { - SET_TX_DESC_RTS_RATE(pdesc, 0x08); - /* SET_TX_DESC_TX_RATE(pdesc, 0x0b); */ - } - if (ieee80211_is_data_qos(fc)) { - if (mac->rdg_en) { - RT_TRACE(rtlpriv, COMP_SEND, DBG_TRACE, - ("Enable RDG function.\n")); - SET_TX_DESC_RDG_ENABLE(pdesc, 1); - SET_TX_DESC_HTC(pdesc, 1); - } - } - } - - SET_TX_DESC_FIRST_SEG(pdesc, (firstseg ? 1 : 0)); - SET_TX_DESC_LAST_SEG(pdesc, (lastseg ? 1 : 0)); - SET_TX_DESC_TX_BUFFER_SIZE(pdesc, (u16) buf_len); - SET_TX_DESC_TX_BUFFER_ADDRESS(pdesc, mapping); - if (rtlpriv->dm.useramask) { - SET_TX_DESC_RATE_ID(pdesc, ptcb_desc->ratr_index); - SET_TX_DESC_MACID(pdesc, ptcb_desc->mac_id); - } else { - SET_TX_DESC_RATE_ID(pdesc, 0xC + ptcb_desc->ratr_index); - SET_TX_DESC_MACID(pdesc, ptcb_desc->ratr_index); - } - if (ieee80211_is_data_qos(fc)) - SET_TX_DESC_QOS(pdesc, 1); - - if ((!ieee80211_is_data_qos(fc)) && ppsc->fwctrl_lps) { - SET_TX_DESC_HWSEQ_EN(pdesc, 1); - SET_TX_DESC_PKT_ID(pdesc, 8); - } - SET_TX_DESC_MORE_FRAG(pdesc, (lastseg ? 0 : 1)); - RT_TRACE(rtlpriv, COMP_SEND, DBG_TRACE, ("\n")); -} - -void rtl92de_tx_fill_cmddesc(struct ieee80211_hw *hw, - u8 *pdesc, bool firstseg, - bool lastseg, struct sk_buff *skb) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); - struct rtl_ps_ctl *ppsc = rtl_psc(rtlpriv); - struct rtl_hal *rtlhal = rtl_hal(rtlpriv); - u8 fw_queue = QSLT_BEACON; - dma_addr_t mapping = pci_map_single(rtlpci->pdev, - skb->data, skb->len, PCI_DMA_TODEVICE); - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)(skb->data); - __le16 fc = hdr->frame_control; - - CLEAR_PCI_TX_DESC_CONTENT(pdesc, TX_DESC_SIZE); - if (firstseg) - SET_TX_DESC_OFFSET(pdesc, USB_HWDESC_HEADER_LEN); - /* 5G have no CCK rate - * Caution: The macros below are multi-line expansions. - * The braces are needed no matter what checkpatch says - */ - if (rtlhal->current_bandtype == BAND_ON_5G) { - SET_TX_DESC_TX_RATE(pdesc, DESC92D_RATE6M); - } else { - SET_TX_DESC_TX_RATE(pdesc, DESC92D_RATE1M); - } - SET_TX_DESC_SEQ(pdesc, 0); - SET_TX_DESC_LINIP(pdesc, 0); - SET_TX_DESC_QUEUE_SEL(pdesc, fw_queue); - SET_TX_DESC_FIRST_SEG(pdesc, 1); - SET_TX_DESC_LAST_SEG(pdesc, 1); - SET_TX_DESC_TX_BUFFER_SIZE(pdesc, (u16) (skb->len)); - SET_TX_DESC_TX_BUFFER_ADDRESS(pdesc, mapping); - SET_TX_DESC_RATE_ID(pdesc, 7); - SET_TX_DESC_MACID(pdesc, 0); - SET_TX_DESC_PKT_SIZE((u8 *) pdesc, (u16) (skb->len)); - SET_TX_DESC_FIRST_SEG(pdesc, 1); - SET_TX_DESC_LAST_SEG(pdesc, 1); - SET_TX_DESC_OFFSET(pdesc, 0x20); - SET_TX_DESC_USE_RATE(pdesc, 1); - - if (!ieee80211_is_data_qos(fc) && ppsc->fwctrl_lps) { - SET_TX_DESC_HWSEQ_EN(pdesc, 1); - SET_TX_DESC_PKT_ID(pdesc, 8); - } - - RT_PRINT_DATA(rtlpriv, COMP_CMD, DBG_LOUD, - "H2C Tx Cmd Content\n", pdesc, TX_DESC_SIZE); - wmb(); - SET_TX_DESC_OWN(pdesc, 1); -} - -void rtl92de_set_desc(u8 *pdesc, bool istx, u8 desc_name, u8 *val) -{ - if (istx) { - switch (desc_name) { - case HW_DESC_OWN: - wmb(); - SET_TX_DESC_OWN(pdesc, 1); - break; - case HW_DESC_TX_NEXTDESC_ADDR: - SET_TX_DESC_NEXT_DESC_ADDRESS(pdesc, *(u32 *) val); - break; - default: - RT_ASSERT(false, ("ERR txdesc :%d" - " not process\n", desc_name)); - break; - } - } else { - switch (desc_name) { - case HW_DESC_RXOWN: - wmb(); - SET_RX_DESC_OWN(pdesc, 1); - break; - case HW_DESC_RXBUFF_ADDR: - SET_RX_DESC_BUFF_ADDR(pdesc, *(u32 *) val); - break; - case HW_DESC_RXPKT_LEN: - SET_RX_DESC_PKT_LEN(pdesc, *(u32 *) val); - break; - case HW_DESC_RXERO: - SET_RX_DESC_EOR(pdesc, 1); - break; - default: - RT_ASSERT(false, ("ERR rxdesc :%d " - "not process\n", desc_name)); - break; - } - } -} - -u32 rtl92de_get_desc(u8 *p_desc, bool istx, u8 desc_name) -{ - u32 ret = 0; - - if (istx) { - switch (desc_name) { - case HW_DESC_OWN: - ret = GET_TX_DESC_OWN(p_desc); - break; - case HW_DESC_TXBUFF_ADDR: - ret = GET_TX_DESC_TX_BUFFER_ADDRESS(p_desc); - break; - default: - RT_ASSERT(false, ("ERR txdesc :%d " - "not process\n", desc_name)); - break; - } - } else { - struct rx_desc_92c *pdesc = (struct rx_desc_92c *)p_desc; - switch (desc_name) { - case HW_DESC_OWN: - ret = GET_RX_DESC_OWN(pdesc); - break; - case HW_DESC_RXPKT_LEN: - ret = GET_RX_DESC_PKT_LEN(pdesc); - break; - default: - RT_ASSERT(false, ("ERR rxdesc :%d " - "not process\n", desc_name)); - break; - } - } - return ret; -} - -void rtl92de_tx_polling(struct ieee80211_hw *hw, u8 hw_queue) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - if (hw_queue == BEACON_QUEUE) - rtl_write_word(rtlpriv, REG_PCIE_CTRL_REG, BIT(4)); - else - rtl_write_word(rtlpriv, REG_PCIE_CTRL_REG, - BIT(0) << (hw_queue)); -} diff --git a/trunk/drivers/net/wireless/rtlwifi/rtl8192de/trx.h b/trunk/drivers/net/wireless/rtlwifi/rtl8192de/trx.h deleted file mode 100644 index 992d6766e667..000000000000 --- a/trunk/drivers/net/wireless/rtlwifi/rtl8192de/trx.h +++ /dev/null @@ -1,756 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2009-2010 Realtek Corporation. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * The full GNU General Public License is included in this distribution in the - * file called LICENSE. - * - * Contact Information: - * wlanfae - * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, - * Hsinchu 300, Taiwan. - * - * Larry Finger - * - *****************************************************************************/ - -#ifndef __RTL92DE_TRX_H__ -#define __RTL92DE_TRX_H__ - -#define TX_DESC_SIZE 64 -#define TX_DESC_AGGR_SUBFRAME_SIZE 32 - -#define RX_DESC_SIZE 32 -#define RX_DRV_INFO_SIZE_UNIT 8 - -#define TX_DESC_NEXT_DESC_OFFSET 40 -#define USB_HWDESC_HEADER_LEN 32 -#define CRCLENGTH 4 - -/* Define a macro that takes a le32 word, converts it to host ordering, - * right shifts by a specified count, creates a mask of the specified - * bit count, and extracts that number of bits. - */ - -#define SHIFT_AND_MASK_LE(__pdesc, __shift, __mask) \ - ((le32_to_cpu(*(((__le32 *)(__pdesc)))) >> (__shift)) & \ - BIT_LEN_MASK_32(__mask)) - -/* Define a macro that clears a bit field in an le32 word and - * sets the specified value into that bit field. The resulting - * value remains in le32 ordering; however, it is properly converted - * to host ordering for the clear and set operations before conversion - * back to le32. - */ - -#define SET_BITS_OFFSET_LE(__pdesc, __shift, __len, __val) \ - (*(__le32 *)(__pdesc) = \ - (cpu_to_le32((le32_to_cpu(*((__le32 *)(__pdesc))) & \ - (~(BIT_OFFSET_LEN_MASK_32((__shift), __len)))) | \ - (((u32)(__val) & BIT_LEN_MASK_32(__len)) << (__shift))))); - -/* macros to read/write various fields in RX or TX descriptors */ - -#define SET_TX_DESC_PKT_SIZE(__pdesc, __val) \ - SET_BITS_OFFSET_LE(__pdesc, 0, 16, __val) -#define SET_TX_DESC_OFFSET(__pdesc, __val) \ - SET_BITS_OFFSET_LE(__pdesc, 16, 8, __val) -#define SET_TX_DESC_BMC(__pdesc, __val) \ - SET_BITS_OFFSET_LE(__pdesc, 24, 1, __val) -#define SET_TX_DESC_HTC(__pdesc, __val) \ - SET_BITS_OFFSET_LE(__pdesc, 25, 1, __val) -#define SET_TX_DESC_LAST_SEG(__pdesc, __val) \ - SET_BITS_OFFSET_LE(__pdesc, 26, 1, __val) -#define SET_TX_DESC_FIRST_SEG(__pdesc, __val) \ - SET_BITS_OFFSET_LE(__pdesc, 27, 1, __val) -#define SET_TX_DESC_LINIP(__pdesc, __val) \ - SET_BITS_OFFSET_LE(__pdesc, 28, 1, __val) -#define SET_TX_DESC_NO_ACM(__pdesc, __val) \ - SET_BITS_OFFSET_LE(__pdesc, 29, 1, __val) -#define SET_TX_DESC_GF(__pdesc, __val) \ - SET_BITS_OFFSET_LE(__pdesc, 30, 1, __val) -#define SET_TX_DESC_OWN(__pdesc, __val) \ - SET_BITS_OFFSET_LE(__pdesc, 31, 1, __val) - -#define GET_TX_DESC_PKT_SIZE(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc, 0, 16) -#define GET_TX_DESC_OFFSET(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc, 16, 8) -#define GET_TX_DESC_BMC(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc, 24, 1) -#define GET_TX_DESC_HTC(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc, 25, 1) -#define GET_TX_DESC_LAST_SEG(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc, 26, 1) -#define GET_TX_DESC_FIRST_SEG(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc, 27, 1) -#define GET_TX_DESC_LINIP(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc, 28, 1) -#define GET_TX_DESC_NO_ACM(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc, 29, 1) -#define GET_TX_DESC_GF(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc, 30, 1) -#define GET_TX_DESC_OWN(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc, 31, 1) - -#define SET_TX_DESC_MACID(__pdesc, __val) \ - SET_BITS_OFFSET_LE(__pdesc+4, 0, 5, __val) -#define SET_TX_DESC_AGG_ENABLE(__pdesc, __val) \ - SET_BITS_OFFSET_LE(__pdesc+4, 5, 1, __val) -#define SET_TX_DESC_BK(__pdesc, __val) \ - SET_BITS_OFFSET_LE(__pdesc+4, 6, 1, __val) -#define SET_TX_DESC_RDG_ENABLE(__pdesc, __val) \ - SET_BITS_OFFSET_LE(__pdesc+4, 7, 1, __val) -#define SET_TX_DESC_QUEUE_SEL(__pdesc, __val) \ - SET_BITS_OFFSET_LE(__pdesc+4, 8, 5, __val) -#define SET_TX_DESC_RDG_NAV_EXT(__pdesc, __val) \ - SET_BITS_OFFSET_LE(__pdesc+4, 13, 1, __val) -#define SET_TX_DESC_LSIG_TXOP_EN(__pdesc, __val) \ - SET_BITS_OFFSET_LE(__pdesc+4, 14, 1, __val) -#define SET_TX_DESC_PIFS(__pdesc, __val) \ - SET_BITS_OFFSET_LE(__pdesc+4, 15, 1, __val) -#define SET_TX_DESC_RATE_ID(__pdesc, __val) \ - SET_BITS_OFFSET_LE(__pdesc+4, 16, 4, __val) -#define SET_TX_DESC_NAV_USE_HDR(__pdesc, __val) \ - SET_BITS_OFFSET_LE(__pdesc+4, 20, 1, __val) -#define SET_TX_DESC_EN_DESC_ID(__pdesc, __val) \ - SET_BITS_OFFSET_LE(__pdesc+4, 21, 1, __val) -#define SET_TX_DESC_SEC_TYPE(__pdesc, __val) \ - SET_BITS_OFFSET_LE(__pdesc+4, 22, 2, __val) -#define SET_TX_DESC_PKT_OFFSET(__pdesc, __val) \ - SET_BITS_OFFSET_LE(__pdesc+4, 26, 8, __val) - -#define GET_TX_DESC_MACID(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+4, 0, 5) -#define GET_TX_DESC_AGG_ENABLE(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+4, 5, 1) -#define GET_TX_DESC_AGG_BREAK(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+4, 6, 1) -#define GET_TX_DESC_RDG_ENABLE(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+4, 7, 1) -#define GET_TX_DESC_QUEUE_SEL(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+4, 8, 5) -#define GET_TX_DESC_RDG_NAV_EXT(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+4, 13, 1) -#define GET_TX_DESC_LSIG_TXOP_EN(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+4, 14, 1) -#define GET_TX_DESC_PIFS(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+4, 15, 1) -#define GET_TX_DESC_RATE_ID(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+4, 16, 4) -#define GET_TX_DESC_NAV_USE_HDR(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+4, 20, 1) -#define GET_TX_DESC_EN_DESC_ID(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+4, 21, 1) -#define GET_TX_DESC_SEC_TYPE(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+4, 22, 2) -#define GET_TX_DESC_PKT_OFFSET(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+4, 24, 8) - -#define SET_TX_DESC_RTS_RC(__pdesc, __val) \ - SET_BITS_OFFSET_LE(__pdesc+8, 0, 6, __val) -#define SET_TX_DESC_DATA_RC(__pdesc, __val) \ - SET_BITS_OFFSET_LE(__pdesc+8, 6, 6, __val) -#define SET_TX_DESC_BAR_RTY_TH(__pdesc, __val) \ - SET_BITS_OFFSET_LE(__pdesc+8, 14, 2, __val) -#define SET_TX_DESC_MORE_FRAG(__pdesc, __val) \ - SET_BITS_OFFSET_LE(__pdesc+8, 17, 1, __val) -#define SET_TX_DESC_RAW(__pdesc, __val) \ - SET_BITS_OFFSET_LE(__pdesc+8, 18, 1, __val) -#define SET_TX_DESC_CCX(__pdesc, __val) \ - SET_BITS_OFFSET_LE(__pdesc+8, 19, 1, __val) -#define SET_TX_DESC_AMPDU_DENSITY(__pdesc, __val) \ - SET_BITS_OFFSET_LE(__pdesc+8, 20, 3, __val) -#define SET_TX_DESC_ANTSEL_A(__pdesc, __val) \ - SET_BITS_OFFSET_LE(__pdesc+8, 24, 1, __val) -#define SET_TX_DESC_ANTSEL_B(__pdesc, __val) \ - SET_BITS_OFFSET_LE(__pdesc+8, 25, 1, __val) -#define SET_TX_DESC_TX_ANT_CCK(__pdesc, __val) \ - SET_BITS_OFFSET_LE(__pdesc+8, 26, 2, __val) -#define SET_TX_DESC_TX_ANTL(__pdesc, __val) \ - SET_BITS_OFFSET_LE(__pdesc+8, 28, 2, __val) -#define SET_TX_DESC_TX_ANT_HT(__pdesc, __val) \ - SET_BITS_OFFSET_LE(__pdesc+8, 30, 2, __val) - -#define GET_TX_DESC_RTS_RC(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+8, 0, 6) -#define GET_TX_DESC_DATA_RC(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+8, 6, 6) -#define GET_TX_DESC_BAR_RTY_TH(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+8, 14, 2) -#define GET_TX_DESC_MORE_FRAG(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+8, 17, 1) -#define GET_TX_DESC_RAW(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+8, 18, 1) -#define GET_TX_DESC_CCX(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+8, 19, 1) -#define GET_TX_DESC_AMPDU_DENSITY(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+8, 20, 3) -#define GET_TX_DESC_ANTSEL_A(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+8, 24, 1) -#define GET_TX_DESC_ANTSEL_B(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+8, 25, 1) -#define GET_TX_DESC_TX_ANT_CCK(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+8, 26, 2) -#define GET_TX_DESC_TX_ANTL(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+8, 28, 2) -#define GET_TX_DESC_TX_ANT_HT(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+8, 30, 2) - -#define SET_TX_DESC_NEXT_HEAP_PAGE(__pdesc, __val) \ - SET_BITS_OFFSET_LE(__pdesc+12, 0, 8, __val) -#define SET_TX_DESC_TAIL_PAGE(__pdesc, __val) \ - SET_BITS_OFFSET_LE(__pdesc+12, 8, 8, __val) -#define SET_TX_DESC_SEQ(__pdesc, __val) \ - SET_BITS_OFFSET_LE(__pdesc+12, 16, 12, __val) -#define SET_TX_DESC_PKT_ID(__pdesc, __val) \ - SET_BITS_OFFSET_LE(__pdesc+12, 28, 4, __val) - -#define GET_TX_DESC_NEXT_HEAP_PAGE(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+12, 0, 8) -#define GET_TX_DESC_TAIL_PAGE(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+12, 8, 8) -#define GET_TX_DESC_SEQ(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+12, 16, 12) -#define GET_TX_DESC_PKT_ID(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+12, 28, 4) - -#define SET_TX_DESC_RTS_RATE(__pdesc, __val) \ - SET_BITS_OFFSET_LE(__pdesc+16, 0, 5, __val) -#define SET_TX_DESC_AP_DCFE(__pdesc, __val) \ - SET_BITS_OFFSET_LE(__pdesc+16, 5, 1, __val) -#define SET_TX_DESC_QOS(__pdesc, __val) \ - SET_BITS_OFFSET_LE(__pdesc+16, 6, 1, __val) -#define SET_TX_DESC_HWSEQ_EN(__pdesc, __val) \ - SET_BITS_OFFSET_LE(__pdesc+16, 7, 1, __val) -#define SET_TX_DESC_USE_RATE(__pdesc, __val) \ - SET_BITS_OFFSET_LE(__pdesc+16, 8, 1, __val) -#define SET_TX_DESC_DISABLE_RTS_FB(__pdesc, __val) \ - SET_BITS_OFFSET_LE(__pdesc+16, 9, 1, __val) -#define SET_TX_DESC_DISABLE_FB(__pdesc, __val) \ - SET_BITS_OFFSET_LE(__pdesc+16, 10, 1, __val) -#define SET_TX_DESC_CTS2SELF(__pdesc, __val) \ - SET_BITS_OFFSET_LE(__pdesc+16, 11, 1, __val) -#define SET_TX_DESC_RTS_ENABLE(__pdesc, __val) \ - SET_BITS_OFFSET_LE(__pdesc+16, 12, 1, __val) -#define SET_TX_DESC_HW_RTS_ENABLE(__pdesc, __val) \ - SET_BITS_OFFSET_LE(__pdesc+16, 13, 1, __val) -#define SET_TX_DESC_PORT_ID(__pdesc, __val) \ - SET_BITS_OFFSET_LE(__pdesc+16, 14, 1, __val) -#define SET_TX_DESC_WAIT_DCTS(__pdesc, __val) \ - SET_BITS_OFFSET_LE(__pdesc+16, 18, 1, __val) -#define SET_TX_DESC_CTS2AP_EN(__pdesc, __val) \ - SET_BITS_OFFSET_LE(__pdesc+16, 19, 1, __val) -#define SET_TX_DESC_TX_SUB_CARRIER(__pdesc, __val) \ - SET_BITS_OFFSET_LE(__pdesc+16, 20, 2, __val) -#define SET_TX_DESC_TX_STBC(__pdesc, __val) \ - SET_BITS_OFFSET_LE(__pdesc+16, 22, 2, __val) -#define SET_TX_DESC_DATA_SHORT(__pdesc, __val) \ - SET_BITS_OFFSET_LE(__pdesc+16, 24, 1, __val) -#define SET_TX_DESC_DATA_BW(__pdesc, __val) \ - SET_BITS_OFFSET_LE(__pdesc+16, 25, 1, __val) -#define SET_TX_DESC_RTS_SHORT(__pdesc, __val) \ - SET_BITS_OFFSET_LE(__pdesc+16, 26, 1, __val) -#define SET_TX_DESC_RTS_BW(__pdesc, __val) \ - SET_BITS_OFFSET_LE(__pdesc+16, 27, 1, __val) -#define SET_TX_DESC_RTS_SC(__pdesc, __val) \ - SET_BITS_OFFSET_LE(__pdesc+16, 28, 2, __val) -#define SET_TX_DESC_RTS_STBC(__pdesc, __val) \ - SET_BITS_OFFSET_LE(__pdesc+16, 30, 2, __val) - -#define GET_TX_DESC_RTS_RATE(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+16, 0, 5) -#define GET_TX_DESC_AP_DCFE(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+16, 5, 1) -#define GET_TX_DESC_QOS(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+16, 6, 1) -#define GET_TX_DESC_HWSEQ_EN(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+16, 7, 1) -#define GET_TX_DESC_USE_RATE(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+16, 8, 1) -#define GET_TX_DESC_DISABLE_RTS_FB(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+16, 9, 1) -#define GET_TX_DESC_DISABLE_FB(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+16, 10, 1) -#define GET_TX_DESC_CTS2SELF(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+16, 11, 1) -#define GET_TX_DESC_RTS_ENABLE(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+16, 12, 1) -#define GET_TX_DESC_HW_RTS_ENABLE(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+16, 13, 1) -#define GET_TX_DESC_PORT_ID(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+16, 14, 1) -#define GET_TX_DESC_WAIT_DCTS(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+16, 18, 1) -#define GET_TX_DESC_CTS2AP_EN(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+16, 19, 1) -#define GET_TX_DESC_TX_SUB_CARRIER(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+16, 20, 2) -#define GET_TX_DESC_TX_STBC(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+16, 22, 2) -#define GET_TX_DESC_DATA_SHORT(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+16, 24, 1) -#define GET_TX_DESC_DATA_BW(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+16, 25, 1) -#define GET_TX_DESC_RTS_SHORT(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+16, 26, 1) -#define GET_TX_DESC_RTS_BW(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+16, 27, 1) -#define GET_TX_DESC_RTS_SC(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+16, 28, 2) -#define GET_TX_DESC_RTS_STBC(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+16, 30, 2) - -#define SET_TX_DESC_TX_RATE(__pdesc, __val) \ - SET_BITS_OFFSET_LE(__pdesc+20, 0, 6, __val) -#define SET_TX_DESC_DATA_SHORTGI(__pdesc, __val) \ - SET_BITS_OFFSET_LE(__pdesc+20, 6, 1, __val) -#define SET_TX_DESC_CCX_TAG(__pdesc, __val) \ - SET_BITS_OFFSET_LE(__pdesc+20, 7, 1, __val) -#define SET_TX_DESC_DATA_RATE_FB_LIMIT(__pdesc, __val) \ - SET_BITS_OFFSET_LE(__pdesc+20, 8, 5, __val) -#define SET_TX_DESC_RTS_RATE_FB_LIMIT(__pdesc, __val) \ - SET_BITS_OFFSET_LE(__pdesc+20, 13, 4, __val) -#define SET_TX_DESC_RETRY_LIMIT_ENABLE(__pdesc, __val) \ - SET_BITS_OFFSET_LE(__pdesc+20, 17, 1, __val) -#define SET_TX_DESC_DATA_RETRY_LIMIT(__pdesc, __val) \ - SET_BITS_OFFSET_LE(__pdesc+20, 18, 6, __val) -#define SET_TX_DESC_USB_TXAGG_NUM(__pdesc, __val) \ - SET_BITS_OFFSET_LE(__pdesc+20, 24, 8, __val) - -#define GET_TX_DESC_TX_RATE(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+20, 0, 6) -#define GET_TX_DESC_DATA_SHORTGI(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+20, 6, 1) -#define GET_TX_DESC_CCX_TAG(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+20, 7, 1) -#define GET_TX_DESC_DATA_RATE_FB_LIMIT(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+20, 8, 5) -#define GET_TX_DESC_RTS_RATE_FB_LIMIT(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+20, 13, 4) -#define GET_TX_DESC_RETRY_LIMIT_ENABLE(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+20, 17, 1) -#define GET_TX_DESC_DATA_RETRY_LIMIT(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+20, 18, 6) -#define GET_TX_DESC_USB_TXAGG_NUM(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+20, 24, 8) - -#define SET_TX_DESC_TXAGC_A(__pdesc, __val) \ - SET_BITS_OFFSET_LE(__pdesc+24, 0, 5, __val) -#define SET_TX_DESC_TXAGC_B(__pdesc, __val) \ - SET_BITS_OFFSET_LE(__pdesc+24, 5, 5, __val) -#define SET_TX_DESC_USE_MAX_LEN(__pdesc, __val) \ - SET_BITS_OFFSET_LE(__pdesc+24, 10, 1, __val) -#define SET_TX_DESC_MAX_AGG_NUM(__pdesc, __val) \ - SET_BITS_OFFSET_LE(__pdesc+24, 11, 5, __val) -#define SET_TX_DESC_MCSG1_MAX_LEN(__pdesc, __val) \ - SET_BITS_OFFSET_LE(__pdesc+24, 16, 4, __val) -#define SET_TX_DESC_MCSG2_MAX_LEN(__pdesc, __val) \ - SET_BITS_OFFSET_LE(__pdesc+24, 20, 4, __val) -#define SET_TX_DESC_MCSG3_MAX_LEN(__pdesc, __val) \ - SET_BITS_OFFSET_LE(__pdesc+24, 24, 4, __val) -#define SET_TX_DESC_MCS7_SGI_MAX_LEN(__pdesc, __val) \ - SET_BITS_OFFSET_LE(__pdesc+24, 28, 4, __val) - -#define GET_TX_DESC_TXAGC_A(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+24, 0, 5) -#define GET_TX_DESC_TXAGC_B(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+24, 5, 5) -#define GET_TX_DESC_USE_MAX_LEN(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+24, 10, 1) -#define GET_TX_DESC_MAX_AGG_NUM(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+24, 11, 5) -#define GET_TX_DESC_MCSG1_MAX_LEN(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+24, 16, 4) -#define GET_TX_DESC_MCSG2_MAX_LEN(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+24, 20, 4) -#define GET_TX_DESC_MCSG3_MAX_LEN(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+24, 24, 4) -#define GET_TX_DESC_MCS7_SGI_MAX_LEN(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+24, 28, 4) - -#define SET_TX_DESC_TX_BUFFER_SIZE(__pdesc, __val) \ - SET_BITS_OFFSET_LE(__pdesc+28, 0, 16, __val) -#define SET_TX_DESC_MCSG4_MAX_LEN(__pdesc, __val) \ - SET_BITS_OFFSET_LE(__pdesc+28, 16, 4, __val) -#define SET_TX_DESC_MCSG5_MAX_LEN(__pdesc, __val) \ - SET_BITS_OFFSET_LE(__pdesc+28, 20, 4, __val) -#define SET_TX_DESC_MCSG6_MAX_LEN(__pdesc, __val) \ - SET_BITS_OFFSET_LE(__pdesc+28, 24, 4, __val) -#define SET_TX_DESC_MCS15_SGI_MAX_LEN(__pdesc, __val) \ - SET_BITS_OFFSET_LE(__pdesc+28, 28, 4, __val) - -#define GET_TX_DESC_TX_BUFFER_SIZE(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+28, 0, 16) -#define GET_TX_DESC_MCSG4_MAX_LEN(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+28, 16, 4) -#define GET_TX_DESC_MCSG5_MAX_LEN(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+28, 20, 4) -#define GET_TX_DESC_MCSG6_MAX_LEN(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+28, 24, 4) -#define GET_TX_DESC_MCS15_SGI_MAX_LEN(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+28, 28, 4) - -#define SET_TX_DESC_TX_BUFFER_ADDRESS(__pdesc, __val) \ - SET_BITS_OFFSET_LE(__pdesc+32, 0, 32, __val) -#define SET_TX_DESC_TX_BUFFER_ADDRESS64(__pdesc, __val) \ - SET_BITS_OFFSET_LE(__pdesc+36, 0, 32, __val) - -#define GET_TX_DESC_TX_BUFFER_ADDRESS(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+32, 0, 32) -#define GET_TX_DESC_TX_BUFFER_ADDRESS64(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+36, 0, 32) - -#define SET_TX_DESC_NEXT_DESC_ADDRESS(__pdesc, __val) \ - SET_BITS_OFFSET_LE(__pdesc+40, 0, 32, __val) -#define SET_TX_DESC_NEXT_DESC_ADDRESS64(__pdesc, __val) \ - SET_BITS_OFFSET_LE(__pdesc+44, 0, 32, __val) - -#define GET_TX_DESC_NEXT_DESC_ADDRESS(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+40, 0, 32) -#define GET_TX_DESC_NEXT_DESC_ADDRESS64(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+44, 0, 32) - -#define GET_RX_DESC_PKT_LEN(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc, 0, 14) -#define GET_RX_DESC_CRC32(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc, 14, 1) -#define GET_RX_DESC_ICV(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc, 15, 1) -#define GET_RX_DESC_DRV_INFO_SIZE(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc, 16, 4) -#define GET_RX_DESC_SECURITY(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc, 20, 3) -#define GET_RX_DESC_QOS(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc, 23, 1) -#define GET_RX_DESC_SHIFT(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc, 24, 2) -#define GET_RX_DESC_PHYST(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc, 26, 1) -#define GET_RX_DESC_SWDEC(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc, 27, 1) -#define GET_RX_DESC_LS(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc, 28, 1) -#define GET_RX_DESC_FS(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc, 29, 1) -#define GET_RX_DESC_EOR(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc, 30, 1) -#define GET_RX_DESC_OWN(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc, 31, 1) - -#define SET_RX_DESC_PKT_LEN(__pdesc, __val) \ - SET_BITS_OFFSET_LE(__pdesc, 0, 14, __val) -#define SET_RX_DESC_EOR(__pdesc, __val) \ - SET_BITS_OFFSET_LE(__pdesc, 30, 1, __val) -#define SET_RX_DESC_OWN(__pdesc, __val) \ - SET_BITS_OFFSET_LE(__pdesc, 31, 1, __val) - -#define GET_RX_DESC_MACID(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+4, 0, 5) -#define GET_RX_DESC_TID(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+4, 5, 4) -#define GET_RX_DESC_HWRSVD(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+4, 9, 5) -#define GET_RX_DESC_PAGGR(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+4, 14, 1) -#define GET_RX_DESC_FAGGR(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+4, 15, 1) -#define GET_RX_DESC_A1_FIT(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+4, 16, 4) -#define GET_RX_DESC_A2_FIT(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+4, 20, 4) -#define GET_RX_DESC_PAM(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+4, 24, 1) -#define GET_RX_DESC_PWR(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+4, 25, 1) -#define GET_RX_DESC_MD(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+4, 26, 1) -#define GET_RX_DESC_MF(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+4, 27, 1) -#define GET_RX_DESC_TYPE(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+4, 28, 2) -#define GET_RX_DESC_MC(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+4, 30, 1) -#define GET_RX_DESC_BC(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+4, 31, 1) -#define GET_RX_DESC_SEQ(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+8, 0, 12) -#define GET_RX_DESC_FRAG(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+8, 12, 4) -#define GET_RX_DESC_NEXT_PKT_LEN(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+8, 16, 14) -#define GET_RX_DESC_NEXT_IND(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+8, 30, 1) -#define GET_RX_DESC_RSVD(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+8, 31, 1) - -#define GET_RX_DESC_RXMCS(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+12, 0, 6) -#define GET_RX_DESC_RXHT(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+12, 6, 1) -#define GET_RX_DESC_SPLCP(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+12, 8, 1) -#define GET_RX_DESC_BW(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+12, 9, 1) -#define GET_RX_DESC_HTC(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+12, 10, 1) -#define GET_RX_DESC_HWPC_ERR(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+12, 14, 1) -#define GET_RX_DESC_HWPC_IND(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+12, 15, 1) -#define GET_RX_DESC_IV0(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+12, 16, 16) - -#define GET_RX_DESC_IV1(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+16, 0, 32) -#define GET_RX_DESC_TSFL(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+20, 0, 32) - -#define GET_RX_DESC_BUFF_ADDR(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+24, 0, 32) -#define GET_RX_DESC_BUFF_ADDR64(__pdesc) \ - SHIFT_AND_MASK_LE(__pdesc+28, 0, 32) - -#define SET_RX_DESC_BUFF_ADDR(__pdesc, __val) \ - SET_BITS_OFFSET_LE(__pdesc+24, 0, 32, __val) -#define SET_RX_DESC_BUFF_ADDR64(__pdesc, __val) \ - SET_BITS_OFFSET_LE(__pdesc+28, 0, 32, __val) - -#define CLEAR_PCI_TX_DESC_CONTENT(__pdesc, _size) \ -do { \ - if (_size > TX_DESC_NEXT_DESC_OFFSET) \ - memset((void *)__pdesc, 0, TX_DESC_NEXT_DESC_OFFSET); \ - else \ - memset((void *)__pdesc, 0, _size); \ -} while (0); - -#define RX_HAL_IS_CCK_RATE(_pdesc)\ - (_pdesc->rxmcs == DESC92D_RATE1M || \ - _pdesc->rxmcs == DESC92D_RATE2M || \ - _pdesc->rxmcs == DESC92D_RATE5_5M || \ - _pdesc->rxmcs == DESC92D_RATE11M) - -/* For 92D early mode */ -#define SET_EARLYMODE_PKTNUM(__paddr, __value) \ - SET_BITS_OFFSET_LE(__paddr, 0, 3, __value) -#define SET_EARLYMODE_LEN0(__paddr, __value) \ - SET_BITS_OFFSET_LE(__paddr, 4, 12, __value) -#define SET_EARLYMODE_LEN1(__paddr, __value) \ - SET_BITS_OFFSET_LE(__paddr, 16, 12, __value) -#define SET_EARLYMODE_LEN2_1(__paddr, __value) \ - SET_BITS_OFFSET_LE(__paddr, 28, 4, __value) -#define SET_EARLYMODE_LEN2_2(__paddr, __value) \ - SET_BITS_OFFSET_LE(__paddr+4, 0, 8, __value) -#define SET_EARLYMODE_LEN3(__paddr, __value) \ - SET_BITS_OFFSET_LE(__paddr+4, 8, 12, __value) -#define SET_EARLYMODE_LEN4(__paddr, __value) \ - SET_BITS_OFFSET_LE(__paddr+4, 20, 12, __value) - -struct rx_fwinfo_92d { - u8 gain_trsw[4]; - u8 pwdb_all; - u8 cfosho[4]; - u8 cfotail[4]; - char rxevm[2]; - char rxsnr[4]; - u8 pdsnr[2]; - u8 csi_current[2]; - u8 csi_target[2]; - u8 sigevm; - u8 max_ex_pwr; - u8 ex_intf_flag:1; - u8 sgi_en:1; - u8 rxsc:2; - u8 reserve:4; -} __packed; - -struct tx_desc_92d { - u32 pktsize:16; - u32 offset:8; - u32 bmc:1; - u32 htc:1; - u32 lastseg:1; - u32 firstseg:1; - u32 linip:1; - u32 noacm:1; - u32 gf:1; - u32 own:1; - - u32 macid:5; - u32 agg_en:1; - u32 bk:1; - u32 rdg_en:1; - u32 queuesel:5; - u32 rd_nav_ext:1; - u32 lsig_txop_en:1; - u32 pifs:1; - u32 rateid:4; - u32 nav_usehdr:1; - u32 en_descid:1; - u32 sectype:2; - u32 pktoffset:8; - - u32 rts_rc:6; - u32 data_rc:6; - u32 rsvd0:2; - u32 bar_retryht:2; - u32 rsvd1:1; - u32 morefrag:1; - u32 raw:1; - u32 ccx:1; - u32 ampdudensity:3; - u32 rsvd2:1; - u32 ant_sela:1; - u32 ant_selb:1; - u32 txant_cck:2; - u32 txant_l:2; - u32 txant_ht:2; - - u32 nextheadpage:8; - u32 tailpage:8; - u32 seq:12; - u32 pktid:4; - - u32 rtsrate:5; - u32 apdcfe:1; - u32 qos:1; - u32 hwseq_enable:1; - u32 userrate:1; - u32 dis_rtsfb:1; - u32 dis_datafb:1; - u32 cts2self:1; - u32 rts_en:1; - u32 hwrts_en:1; - u32 portid:1; - u32 rsvd3:3; - u32 waitdcts:1; - u32 cts2ap_en:1; - u32 txsc:2; - u32 stbc:2; - u32 txshort:1; - u32 txbw:1; - u32 rtsshort:1; - u32 rtsbw:1; - u32 rtssc:2; - u32 rtsstbc:2; - - u32 txrate:6; - u32 shortgi:1; - u32 ccxt:1; - u32 txrate_fb_lmt:5; - u32 rtsrate_fb_lmt:4; - u32 retrylmt_en:1; - u32 txretrylmt:6; - u32 usb_txaggnum:8; - - u32 txagca:5; - u32 txagcb:5; - u32 usemaxlen:1; - u32 maxaggnum:5; - u32 mcsg1maxlen:4; - u32 mcsg2maxlen:4; - u32 mcsg3maxlen:4; - u32 mcs7sgimaxlen:4; - - u32 txbuffersize:16; - u32 mcsg4maxlen:4; - u32 mcsg5maxlen:4; - u32 mcsg6maxlen:4; - u32 mcsg15sgimaxlen:4; - - u32 txbuffaddr; - u32 txbufferaddr64; - u32 nextdescaddress; - u32 nextdescaddress64; - - u32 reserve_pass_pcie_mm_limit[4]; -} __packed; - -struct rx_desc_92d { - u32 length:14; - u32 crc32:1; - u32 icverror:1; - u32 drv_infosize:4; - u32 security:3; - u32 qos:1; - u32 shift:2; - u32 phystatus:1; - u32 swdec:1; - u32 lastseg:1; - u32 firstseg:1; - u32 eor:1; - u32 own:1; - - u32 macid:5; - u32 tid:4; - u32 hwrsvd:5; - u32 paggr:1; - u32 faggr:1; - u32 a1_fit:4; - u32 a2_fit:4; - u32 pam:1; - u32 pwr:1; - u32 moredata:1; - u32 morefrag:1; - u32 type:2; - u32 mc:1; - u32 bc:1; - - u32 seq:12; - u32 frag:4; - u32 nextpktlen:14; - u32 nextind:1; - u32 rsvd:1; - - u32 rxmcs:6; - u32 rxht:1; - u32 amsdu:1; - u32 splcp:1; - u32 bandwidth:1; - u32 htc:1; - u32 tcpchk_rpt:1; - u32 ipcchk_rpt:1; - u32 tcpchk_valid:1; - u32 hwpcerr:1; - u32 hwpcind:1; - u32 iv0:16; - - u32 iv1; - - u32 tsfl; - - u32 bufferaddress; - u32 bufferaddress64; - -} __packed; - -void rtl92de_tx_fill_desc(struct ieee80211_hw *hw, - struct ieee80211_hdr *hdr, - u8 *pdesc, struct ieee80211_tx_info *info, - struct sk_buff *skb, u8 hw_queue, - struct rtl_tcb_desc *ptcb_desc); -bool rtl92de_rx_query_desc(struct ieee80211_hw *hw, - struct rtl_stats *stats, - struct ieee80211_rx_status *rx_status, - u8 *pdesc, struct sk_buff *skb); -void rtl92de_set_desc(u8 *pdesc, bool istx, u8 desc_name, u8 *val); -u32 rtl92de_get_desc(u8 *pdesc, bool istx, u8 desc_name); -void rtl92de_tx_polling(struct ieee80211_hw *hw, u8 hw_queue); -void rtl92de_tx_fill_cmddesc(struct ieee80211_hw *hw, u8 *pdesc, - bool b_firstseg, bool b_lastseg, - struct sk_buff *skb); - -#endif diff --git a/trunk/drivers/net/wireless/rtlwifi/rtl8192se/dm.c b/trunk/drivers/net/wireless/rtlwifi/rtl8192se/dm.c index 4203a8531ca0..609c7ec7e66a 100644 --- a/trunk/drivers/net/wireless/rtlwifi/rtl8192se/dm.c +++ b/trunk/drivers/net/wireless/rtlwifi/rtl8192se/dm.c @@ -452,7 +452,7 @@ static void _rtl92s_dm_initial_gain_sta_beforeconnect(struct ieee80211_hw *hw) if (rtlpriv->psc.rfpwr_state != ERFON) return; - if (digtable.backoff_enable_flag) + if (digtable.backoff_enable_flag == true) rtl92s_backoff_enable_flag(hw); else digtable.backoff_val = DM_DIG_BACKOFF; diff --git a/trunk/drivers/net/wireless/rtlwifi/rtl8192se/hw.c b/trunk/drivers/net/wireless/rtlwifi/rtl8192se/hw.c index b1d0213dc60e..35dd12d0dcf3 100644 --- a/trunk/drivers/net/wireless/rtlwifi/rtl8192se/hw.c +++ b/trunk/drivers/net/wireless/rtlwifi/rtl8192se/hw.c @@ -516,7 +516,7 @@ static u8 _rtl92se_rf_onoff_detect(struct ieee80211_hw *hw) mdelay(10); /* check GPIO3 */ - u1tmp = rtl_read_byte(rtlpriv, GPIO_IN_SE); + u1tmp = rtl_read_byte(rtlpriv, GPIO_IN); retval = (u1tmp & HAL_8192S_HW_GPIO_OFF_BIT) ? ERFON : ERFOFF; return retval; @@ -994,8 +994,7 @@ int rtl92se_hw_init(struct ieee80211_hw *hw) rtlpriv->psc.rfoff_reason = RF_CHANGE_BY_INIT; rtlpriv->psc.rfpwr_state = ERFON; - /* FIXME: check spinlocks if this block is uncommented */ - rtl_ps_set_rf_state(hw, ERFOFF, rfoffreason); + rtl_ps_set_rf_state(hw, ERFOFF, rfoffreason, true); } else { /* gpio radio on/off is out of adapter start */ if (rtlpriv->psc.hwradiooff == false) { @@ -1106,7 +1105,7 @@ void rtl92se_set_check_bssid(struct ieee80211_hw *hw, bool check_bssid) if (rtlpriv->psc.rfpwr_state != ERFON) return; - if (check_bssid) { + if (check_bssid == true) { reg_rcr |= (RCR_CBSSID); rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_RCR, (u8 *)(®_rcr)); } else if (check_bssid == false) { @@ -1214,6 +1213,8 @@ void rtl92se_enable_interrupt(struct ieee80211_hw *hw) rtl_write_dword(rtlpriv, INTA_MASK, rtlpci->irq_mask[0]); /* Support Bit 32-37(Assign as Bit 0-5) interrupt setting now */ rtl_write_dword(rtlpriv, INTA_MASK + 4, rtlpci->irq_mask[1] & 0x3F); + + rtlpci->irq_enabled = true; } void rtl92se_disable_interrupt(struct ieee80211_hw *hw) @@ -1224,6 +1225,7 @@ void rtl92se_disable_interrupt(struct ieee80211_hw *hw) rtl_write_dword(rtlpriv, INTA_MASK, 0); rtl_write_dword(rtlpriv, INTA_MASK + 4, 0); + rtlpci->irq_enabled = false; synchronize_irq(rtlpci->pdev->irq); } @@ -1649,7 +1651,7 @@ static void _rtl92se_read_adapter_info(struct ieee80211_hw *hw) rtlefuse->autoload_failflag = false; } - if (rtlefuse->autoload_failflag) + if (rtlefuse->autoload_failflag == true) return; _rtl8192se_get_IC_Inferiority(hw); @@ -2299,7 +2301,7 @@ bool rtl92se_gpio_radio_on_off_checking(struct ieee80211_hw *hw, u8 *valid) rfpwr_toset = _rtl92se_rf_onoff_detect(hw); - if ((ppsc->hwradiooff) && (rfpwr_toset == ERFON)) { + if ((ppsc->hwradiooff == true) && (rfpwr_toset == ERFON)) { RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG, ("RFKILL-HW Radio ON, RF ON\n")); diff --git a/trunk/drivers/net/wireless/rtlwifi/rtl8192se/led.c b/trunk/drivers/net/wireless/rtlwifi/rtl8192se/led.c index e3fe7c90ebf4..6d4f66616680 100644 --- a/trunk/drivers/net/wireless/rtlwifi/rtl8192se/led.c +++ b/trunk/drivers/net/wireless/rtlwifi/rtl8192se/led.c @@ -90,7 +90,7 @@ void rtl92se_sw_led_off(struct ieee80211_hw *hw, struct rtl_led *pled) break; case LED_PIN_LED0: ledcfg &= 0xf0; - if (pcipriv->ledctl.led_opendrain) + if (pcipriv->ledctl.led_opendrain == true) rtl_write_byte(rtlpriv, LEDCFG, (ledcfg | BIT(1))); else rtl_write_byte(rtlpriv, LEDCFG, (ledcfg | BIT(3))); diff --git a/trunk/drivers/net/wireless/rtlwifi/rtl8192se/phy.c b/trunk/drivers/net/wireless/rtlwifi/rtl8192se/phy.c index 81a5aa4370cf..7ee2daccd7d5 100644 --- a/trunk/drivers/net/wireless/rtlwifi/rtl8192se/phy.c +++ b/trunk/drivers/net/wireless/rtlwifi/rtl8192se/phy.c @@ -1416,7 +1416,7 @@ static void _rtl92s_phy_set_fwcmd_io(struct ieee80211_hw *hw) break; case FW_CMD_HIGH_PWR_ENABLE: if ((rtlpriv->dm.dm_flag & HAL_DM_HIPWR_DISABLE) || - rtlpriv->dm.dynamic_txpower_enable) + (rtlpriv->dm.dynamic_txpower_enable == true)) break; /* CCA threshold */ @@ -1608,7 +1608,7 @@ bool rtl92s_phy_set_fw_cmd(struct ieee80211_hw *hw, enum fwcmd_iotype fw_cmdio) fw_cmdmap &= ~FW_DIG_ENABLE_CTL; if ((rtlpriv->dm.dm_flag & HAL_DM_HIPWR_DISABLE) || - rtlpriv->dm.dynamic_txpower_enable) + (rtlpriv->dm.dynamic_txpower_enable == true)) fw_cmdmap &= ~FW_HIGH_PWR_ENABLE_CTL; if ((digtable.dig_ext_port_stage == diff --git a/trunk/drivers/net/wireless/rtlwifi/rtl8192se/reg.h b/trunk/drivers/net/wireless/rtlwifi/rtl8192se/reg.h index ea32ef2d4098..0116eaddbfac 100644 --- a/trunk/drivers/net/wireless/rtlwifi/rtl8192se/reg.h +++ b/trunk/drivers/net/wireless/rtlwifi/rtl8192se/reg.h @@ -248,8 +248,12 @@ #define PSTIME 0x02E0 #define TIMER0 0x02E4 #define TIMER1 0x02E8 -#define GPIO_IN_SE 0x02EC +#define GPIO_CTRL 0x02EC +#define GPIO_IN 0x02EC +#define GPIO_OUT 0x02ED #define GPIO_IO_SEL 0x02EE +#define GPIO_MOD 0x02EF +#define GPIO_INTCTRL 0x02F0 #define MAC_PINMUX_CFG 0x02F1 #define LEDCFG 0x02F2 #define PHY_REG 0x02F3 diff --git a/trunk/drivers/net/wireless/rtlwifi/rtl8192se/rf.c b/trunk/drivers/net/wireless/rtlwifi/rtl8192se/rf.c index c6e3a4ca42f9..1d3a48330399 100644 --- a/trunk/drivers/net/wireless/rtlwifi/rtl8192se/rf.c +++ b/trunk/drivers/net/wireless/rtlwifi/rtl8192se/rf.c @@ -410,7 +410,7 @@ void rtl92s_phy_rf6052_set_ccktxpower(struct ieee80211_hw *hw, u8 pwrlevel) (rtlefuse->eeprom_regulatory != 0))) dont_inc_cck_or_turboscanoff = true; - if (mac->act_scanning) { + if (mac->act_scanning == true) { txagc = 0x3f; if (dont_inc_cck_or_turboscanoff) txagc = pwrlevel; diff --git a/trunk/drivers/net/wireless/rtlwifi/rtl8192se/trx.c b/trunk/drivers/net/wireless/rtlwifi/rtl8192se/trx.c index cffe30851f79..d509cf6a1e4d 100644 --- a/trunk/drivers/net/wireless/rtlwifi/rtl8192se/trx.c +++ b/trunk/drivers/net/wireless/rtlwifi/rtl8192se/trx.c @@ -661,7 +661,7 @@ bool rtl92se_rx_query_desc(struct ieee80211_hw *hw, struct rtl_stats *stats, rx_status->mactime = GET_RX_STATUS_DESC_TSFL(pdesc); - if (phystatus) { + if (phystatus == true) { p_drvinfo = (struct rx_fwinfo *)(skb->data + stats->rx_bufshift); _rtl92se_translate_rx_signal_stuff(hw, skb, stats, pdesc, @@ -900,7 +900,7 @@ void rtl92se_tx_fill_cmddesc(struct ieee80211_hw *hw, u8 *pdesc, void rtl92se_set_desc(u8 *pdesc, bool istx, u8 desc_name, u8 *val) { - if (istx) { + if (istx == true) { switch (desc_name) { case HW_DESC_OWN: wmb(); @@ -941,7 +941,7 @@ u32 rtl92se_get_desc(u8 *desc, bool istx, u8 desc_name) { u32 ret = 0; - if (istx) { + if (istx == true) { switch (desc_name) { case HW_DESC_OWN: ret = GET_TX_DESC_OWN(desc); diff --git a/trunk/drivers/net/wireless/rtlwifi/wifi.h b/trunk/drivers/net/wireless/rtlwifi/wifi.h index d3c3ffd38984..9d003e0864f5 100644 --- a/trunk/drivers/net/wireless/rtlwifi/wifi.h +++ b/trunk/drivers/net/wireless/rtlwifi/wifi.h @@ -32,6 +32,7 @@ #include #include +#include #include #include #include @@ -302,6 +303,9 @@ enum hw_variables { HW_VAR_DATA_FILTER, }; +#define HWSET_MAX_SIZE 128 +#define EFUSE_MAX_SECTION 16 + enum _RT_MEDIA_STATUS { RT_MEDIA_DISCONNECT = 0, RT_MEDIA_CONNECT = 1 @@ -934,7 +938,7 @@ struct rtl_mac { int n_channels; int n_bitrates; - bool offchan_delay; + bool offchan_deley; /*filters */ u32 rx_conf; @@ -1979,7 +1983,7 @@ static inline u16 rtl_get_tid(struct sk_buff *skb) static inline struct ieee80211_sta *get_sta(struct ieee80211_hw *hw, struct ieee80211_vif *vif, - const u8 *bssid) + u8 *bssid) { return ieee80211_find_sta(vif, bssid); } diff --git a/trunk/drivers/net/wireless/wl12xx/Kconfig b/trunk/drivers/net/wireless/wl12xx/Kconfig index 07bcb1548d8b..35ce7b0f4a60 100644 --- a/trunk/drivers/net/wireless/wl12xx/Kconfig +++ b/trunk/drivers/net/wireless/wl12xx/Kconfig @@ -11,6 +11,7 @@ config WL12XX depends on WL12XX_MENU && GENERIC_HARDIRQS depends on INET select FW_LOADER + select CRC7 ---help--- This module adds support for wireless adapters based on TI wl1271 and TI wl1273 chipsets. This module does *not* include support for wl1251. @@ -32,7 +33,6 @@ config WL12XX_HT config WL12XX_SPI tristate "TI wl12xx SPI support" depends on WL12XX && SPI_MASTER - select CRC7 ---help--- This module adds support for the SPI interface of adapters using TI wl12xx chipsets. Select this if your platform is using diff --git a/trunk/drivers/net/wireless/wl12xx/acx.c b/trunk/drivers/net/wireless/wl12xx/acx.c index 87caa94fd815..c6ee530e5bf7 100644 --- a/trunk/drivers/net/wireless/wl12xx/acx.c +++ b/trunk/drivers/net/wireless/wl12xx/acx.c @@ -25,6 +25,7 @@ #include #include +#include #include #include @@ -1067,7 +1068,6 @@ int wl1271_acx_sta_mem_cfg(struct wl1271 *wl) mem_conf->tx_free_req = mem->min_req_tx_blocks; mem_conf->rx_free_req = mem->min_req_rx_blocks; mem_conf->tx_min = mem->tx_min; - mem_conf->fwlog_blocks = wl->conf.fwlog.mem_blocks; ret = wl1271_cmd_configure(wl, ACX_MEM_CFG, mem_conf, sizeof(*mem_conf)); @@ -1577,53 +1577,6 @@ int wl1271_acx_tsf_info(struct wl1271 *wl, u64 *mactime) return ret; } -int wl1271_acx_ps_rx_streaming(struct wl1271 *wl, bool enable) -{ - struct wl1271_acx_ps_rx_streaming *rx_streaming; - u32 conf_queues, enable_queues; - int i, ret = 0; - - wl1271_debug(DEBUG_ACX, "acx ps rx streaming"); - - rx_streaming = kzalloc(sizeof(*rx_streaming), GFP_KERNEL); - if (!rx_streaming) { - ret = -ENOMEM; - goto out; - } - - conf_queues = wl->conf.rx_streaming.queues; - if (enable) - enable_queues = conf_queues; - else - enable_queues = 0; - - for (i = 0; i < 8; i++) { - /* - * Skip non-changed queues, to avoid redundant acxs. - * this check assumes conf.rx_streaming.queues can't - * be changed while rx_streaming is enabled. - */ - if (!(conf_queues & BIT(i))) - continue; - - rx_streaming->tid = i; - rx_streaming->enable = enable_queues & BIT(i); - rx_streaming->period = wl->conf.rx_streaming.interval; - rx_streaming->timeout = wl->conf.rx_streaming.interval; - - ret = wl1271_cmd_configure(wl, ACX_PS_RX_STREAMING, - rx_streaming, - sizeof(*rx_streaming)); - if (ret < 0) { - wl1271_warning("acx ps rx streaming failed: %d", ret); - goto out; - } - } -out: - kfree(rx_streaming); - return ret; -} - int wl1271_acx_max_tx_retry(struct wl1271 *wl) { struct wl1271_acx_max_tx_retry *acx = NULL; diff --git a/trunk/drivers/net/wireless/wl12xx/acx.h b/trunk/drivers/net/wireless/wl12xx/acx.h index d303265f163a..9a895e3cc613 100644 --- a/trunk/drivers/net/wireless/wl12xx/acx.h +++ b/trunk/drivers/net/wireless/wl12xx/acx.h @@ -828,8 +828,6 @@ struct wl1271_acx_sta_config_memory { u8 tx_free_req; u8 rx_free_req; u8 tx_min; - u8 fwlog_blocks; - u8 padding[3]; } __packed; struct wl1271_acx_mem_map { @@ -1155,19 +1153,6 @@ struct wl1271_acx_fw_tsf_information { u8 padding[3]; } __packed; -struct wl1271_acx_ps_rx_streaming { - struct acx_header header; - - u8 tid; - u8 enable; - - /* interval between triggers (10-100 msec) */ - u8 period; - - /* timeout before first trigger (0-200 msec) */ - u8 timeout; -} __packed; - struct wl1271_acx_max_tx_retry { struct acx_header header; @@ -1399,7 +1384,6 @@ int wl1271_acx_set_ba_session(struct wl1271 *wl, int wl1271_acx_set_ba_receiver_session(struct wl1271 *wl, u8 tid_index, u16 ssn, bool enable); int wl1271_acx_tsf_info(struct wl1271 *wl, u64 *mactime); -int wl1271_acx_ps_rx_streaming(struct wl1271 *wl, bool enable); int wl1271_acx_max_tx_retry(struct wl1271 *wl); int wl1271_acx_config_ps(struct wl1271 *wl); int wl1271_acx_set_inconnection_sta(struct wl1271 *wl, u8 *addr); diff --git a/trunk/drivers/net/wireless/wl12xx/boot.c b/trunk/drivers/net/wireless/wl12xx/boot.c index 101f7e0f6329..7ccec07a600c 100644 --- a/trunk/drivers/net/wireless/wl12xx/boot.c +++ b/trunk/drivers/net/wireless/wl12xx/boot.c @@ -102,33 +102,6 @@ static void wl1271_boot_set_ecpu_ctrl(struct wl1271 *wl, u32 flag) wl1271_write32(wl, ACX_REG_ECPU_CONTROL, cpu_ctrl); } -static unsigned int wl12xx_get_fw_ver_quirks(struct wl1271 *wl) -{ - unsigned int quirks = 0; - unsigned int *fw_ver = wl->chip.fw_ver; - - /* Only for wl127x */ - if ((fw_ver[FW_VER_CHIP] == FW_VER_CHIP_WL127X) && - /* Check STA version */ - (((fw_ver[FW_VER_IF_TYPE] == FW_VER_IF_TYPE_STA) && - (fw_ver[FW_VER_MINOR] < FW_VER_MINOR_1_SPARE_STA_MIN)) || - /* Check AP version */ - ((fw_ver[FW_VER_IF_TYPE] == FW_VER_IF_TYPE_AP) && - (fw_ver[FW_VER_MINOR] < FW_VER_MINOR_1_SPARE_AP_MIN)))) - quirks |= WL12XX_QUIRK_USE_2_SPARE_BLOCKS; - - /* Only new station firmwares support routing fw logs to the host */ - if ((fw_ver[FW_VER_IF_TYPE] == FW_VER_IF_TYPE_STA) && - (fw_ver[FW_VER_MINOR] < FW_VER_MINOR_FWLOG_STA_MIN)) - quirks |= WL12XX_QUIRK_FWLOG_NOT_IMPLEMENTED; - - /* This feature is not yet supported for AP mode */ - if (fw_ver[FW_VER_IF_TYPE] == FW_VER_IF_TYPE_AP) - quirks |= WL12XX_QUIRK_FWLOG_NOT_IMPLEMENTED; - - return quirks; -} - static void wl1271_parse_fw_ver(struct wl1271 *wl) { int ret; @@ -143,9 +116,6 @@ static void wl1271_parse_fw_ver(struct wl1271 *wl) memset(wl->chip.fw_ver, 0, sizeof(wl->chip.fw_ver)); return; } - - /* Check if any quirks are needed with older fw versions */ - wl->quirks |= wl12xx_get_fw_ver_quirks(wl); } static void wl1271_boot_fw_version(struct wl1271 *wl) @@ -779,9 +749,6 @@ int wl1271_load_firmware(struct wl1271 *wl) clk |= (wl->ref_clock << 1) << 4; } - if (wl->quirks & WL12XX_QUIRK_LPD_MODE) - clk |= SCRATCH_ENABLE_LPD; - wl1271_write32(wl, DRPW_SCRATCH_START, clk); wl1271_set_partition(wl, &part_table[PART_WORK]); diff --git a/trunk/drivers/net/wireless/wl12xx/cmd.c b/trunk/drivers/net/wireless/wl12xx/cmd.c index 68972cbc68b4..42935ac72663 100644 --- a/trunk/drivers/net/wireless/wl12xx/cmd.c +++ b/trunk/drivers/net/wireless/wl12xx/cmd.c @@ -23,6 +23,7 @@ #include #include +#include #include #include #include @@ -105,7 +106,7 @@ int wl1271_cmd_send(struct wl1271 *wl, u16 id, void *buf, size_t len, fail: WARN_ON(1); - wl12xx_queue_recovery_work(wl); + ieee80211_queue_work(wl->hw, &wl->recovery_work); return ret; } @@ -134,11 +135,6 @@ int wl1271_cmd_general_parms(struct wl1271 *wl) /* Override the REF CLK from the NVS with the one from platform data */ gen_parms->general_params.ref_clock = wl->ref_clock; - /* LPD mode enable (bits 6-7) in WL1271 AP mode only */ - if (wl->quirks & WL12XX_QUIRK_LPD_MODE) - gen_parms->general_params.general_settings |= - GENERAL_SETTINGS_DRPW_LPD; - ret = wl1271_cmd_test(wl, gen_parms, sizeof(*gen_parms), answer); if (ret < 0) { wl1271_warning("CMD_INI_FILE_GENERAL_PARAM failed"); @@ -356,7 +352,7 @@ static int wl1271_cmd_wait_for_event(struct wl1271 *wl, u32 mask) ret = wl1271_cmd_wait_for_event_or_timeout(wl, mask); if (ret != 0) { - wl12xx_queue_recovery_work(wl); + ieee80211_queue_work(wl->hw, &wl->recovery_work); return ret; } @@ -1171,7 +1167,14 @@ int wl1271_cmd_add_sta(struct wl1271 *wl, struct ieee80211_sta *sta, u8 hlid) cmd->bss_index = WL1271_AP_BSS_INDEX; cmd->aid = sta->aid; cmd->hlid = hlid; - cmd->wmm = sta->wme ? 1 : 0; + + /* + * FIXME: Does STA support QOS? We need to propagate this info from + * hostapd. Currently not that important since this is only used for + * sending the correct flavor of null-data packet in response to a + * trigger. + */ + cmd->wmm = 0; cmd->supported_rates = cpu_to_le32(wl1271_tx_enabled_rates_get(wl, sta->supp_rates[wl->band])); @@ -1227,87 +1230,3 @@ int wl1271_cmd_remove_sta(struct wl1271 *wl, u8 hlid) out: return ret; } - -int wl12xx_cmd_config_fwlog(struct wl1271 *wl) -{ - struct wl12xx_cmd_config_fwlog *cmd; - int ret = 0; - - wl1271_debug(DEBUG_CMD, "cmd config firmware logger"); - - cmd = kzalloc(sizeof(*cmd), GFP_KERNEL); - if (!cmd) { - ret = -ENOMEM; - goto out; - } - - cmd->logger_mode = wl->conf.fwlog.mode; - cmd->log_severity = wl->conf.fwlog.severity; - cmd->timestamp = wl->conf.fwlog.timestamp; - cmd->output = wl->conf.fwlog.output; - cmd->threshold = wl->conf.fwlog.threshold; - - ret = wl1271_cmd_send(wl, CMD_CONFIG_FWLOGGER, cmd, sizeof(*cmd), 0); - if (ret < 0) { - wl1271_error("failed to send config firmware logger command"); - goto out_free; - } - -out_free: - kfree(cmd); - -out: - return ret; -} - -int wl12xx_cmd_start_fwlog(struct wl1271 *wl) -{ - struct wl12xx_cmd_start_fwlog *cmd; - int ret = 0; - - wl1271_debug(DEBUG_CMD, "cmd start firmware logger"); - - cmd = kzalloc(sizeof(*cmd), GFP_KERNEL); - if (!cmd) { - ret = -ENOMEM; - goto out; - } - - ret = wl1271_cmd_send(wl, CMD_START_FWLOGGER, cmd, sizeof(*cmd), 0); - if (ret < 0) { - wl1271_error("failed to send start firmware logger command"); - goto out_free; - } - -out_free: - kfree(cmd); - -out: - return ret; -} - -int wl12xx_cmd_stop_fwlog(struct wl1271 *wl) -{ - struct wl12xx_cmd_stop_fwlog *cmd; - int ret = 0; - - wl1271_debug(DEBUG_CMD, "cmd stop firmware logger"); - - cmd = kzalloc(sizeof(*cmd), GFP_KERNEL); - if (!cmd) { - ret = -ENOMEM; - goto out; - } - - ret = wl1271_cmd_send(wl, CMD_STOP_FWLOGGER, cmd, sizeof(*cmd), 0); - if (ret < 0) { - wl1271_error("failed to send stop firmware logger command"); - goto out_free; - } - -out_free: - kfree(cmd); - -out: - return ret; -} diff --git a/trunk/drivers/net/wireless/wl12xx/cmd.h b/trunk/drivers/net/wireless/wl12xx/cmd.h index 1f7037292c15..5cac95d9480c 100644 --- a/trunk/drivers/net/wireless/wl12xx/cmd.h +++ b/trunk/drivers/net/wireless/wl12xx/cmd.h @@ -70,9 +70,6 @@ int wl1271_cmd_start_bss(struct wl1271 *wl); int wl1271_cmd_stop_bss(struct wl1271 *wl); int wl1271_cmd_add_sta(struct wl1271 *wl, struct ieee80211_sta *sta, u8 hlid); int wl1271_cmd_remove_sta(struct wl1271 *wl, u8 hlid); -int wl12xx_cmd_config_fwlog(struct wl1271 *wl); -int wl12xx_cmd_start_fwlog(struct wl1271 *wl); -int wl12xx_cmd_stop_fwlog(struct wl1271 *wl); enum wl1271_commands { CMD_INTERROGATE = 1, /*use this to read information elements*/ @@ -110,9 +107,6 @@ enum wl1271_commands { CMD_START_PERIODIC_SCAN = 50, CMD_STOP_PERIODIC_SCAN = 51, CMD_SET_STA_STATE = 52, - CMD_CONFIG_FWLOGGER = 53, - CMD_START_FWLOGGER = 54, - CMD_STOP_FWLOGGER = 55, /* AP mode commands */ CMD_BSS_START = 60, @@ -581,60 +575,4 @@ struct wl1271_cmd_remove_sta { u8 padding1; } __packed; -/* - * Continuous mode - packets are transferred to the host periodically - * via the data path. - * On demand - Log messages are stored in a cyclic buffer in the - * firmware, and only transferred to the host when explicitly requested - */ -enum wl12xx_fwlogger_log_mode { - WL12XX_FWLOG_CONTINUOUS, - WL12XX_FWLOG_ON_DEMAND -}; - -/* Include/exclude timestamps from the log messages */ -enum wl12xx_fwlogger_timestamp { - WL12XX_FWLOG_TIMESTAMP_DISABLED, - WL12XX_FWLOG_TIMESTAMP_ENABLED -}; - -/* - * Logs can be routed to the debug pinouts (where available), to the host bus - * (SDIO/SPI), or dropped - */ -enum wl12xx_fwlogger_output { - WL12XX_FWLOG_OUTPUT_NONE, - WL12XX_FWLOG_OUTPUT_DBG_PINS, - WL12XX_FWLOG_OUTPUT_HOST, -}; - -struct wl12xx_cmd_config_fwlog { - struct wl1271_cmd_header header; - - /* See enum wl12xx_fwlogger_log_mode */ - u8 logger_mode; - - /* Minimum log level threshold */ - u8 log_severity; - - /* Include/exclude timestamps from the log messages */ - u8 timestamp; - - /* See enum wl1271_fwlogger_output */ - u8 output; - - /* Regulates the frequency of log messages */ - u8 threshold; - - u8 padding[3]; -} __packed; - -struct wl12xx_cmd_start_fwlog { - struct wl1271_cmd_header header; -} __packed; - -struct wl12xx_cmd_stop_fwlog { - struct wl1271_cmd_header header; -} __packed; - #endif /* __WL1271_CMD_H__ */ diff --git a/trunk/drivers/net/wireless/wl12xx/conf.h b/trunk/drivers/net/wireless/wl12xx/conf.h index b5a7b30afda3..c83fefb6662f 100644 --- a/trunk/drivers/net/wireless/wl12xx/conf.h +++ b/trunk/drivers/net/wireless/wl12xx/conf.h @@ -1248,59 +1248,6 @@ struct conf_fm_coex { u8 swallow_clk_diff; }; -struct conf_rx_streaming_settings { - /* - * RX Streaming duration (in msec) from last tx/rx - * - * Range: u32 - */ - u32 duration; - - /* - * Bitmap of tids to be polled during RX streaming. - * (Note: it doesn't look like it really matters) - * - * Range: 0x1-0xff - */ - u8 queues; - - /* - * RX Streaming interval. - * (Note:this value is also used as the rx streaming timeout) - * Range: 0 (disabled), 10 - 100 - */ - u8 interval; - - /* - * enable rx streaming also when there is no coex activity - */ - u8 always; -}; - -struct conf_fwlog { - /* Continuous or on-demand */ - u8 mode; - - /* - * Number of memory blocks dedicated for the FW logger - * - * Range: 1-3, or 0 to disable the FW logger - */ - u8 mem_blocks; - - /* Minimum log level threshold */ - u8 severity; - - /* Include/exclude timestamps from the log messages */ - u8 timestamp; - - /* See enum wl1271_fwlogger_output */ - u8 output; - - /* Regulates the frequency of log messages */ - u8 threshold; -}; - struct conf_drv_settings { struct conf_sg_settings sg; struct conf_rx_settings rx; @@ -1316,8 +1263,6 @@ struct conf_drv_settings { struct conf_memory_settings mem_wl127x; struct conf_memory_settings mem_wl128x; struct conf_fm_coex fm_coex; - struct conf_rx_streaming_settings rx_streaming; - struct conf_fwlog fwlog; u8 hci_io_ds; }; diff --git a/trunk/drivers/net/wireless/wl12xx/debugfs.c b/trunk/drivers/net/wireless/wl12xx/debugfs.c index da2127018300..f1f8df9b6cd7 100644 --- a/trunk/drivers/net/wireless/wl12xx/debugfs.c +++ b/trunk/drivers/net/wireless/wl12xx/debugfs.c @@ -71,14 +71,6 @@ static const struct file_operations name## _ops = { \ if (!entry || IS_ERR(entry)) \ goto err; \ -#define DEBUGFS_ADD_PREFIX(prefix, name, parent) \ - do { \ - entry = debugfs_create_file(#name, 0400, parent, \ - wl, &prefix## _## name## _ops); \ - if (!entry || IS_ERR(entry)) \ - goto err; \ - } while (0); - #define DEBUGFS_FWSTATS_FILE(sub, name, fmt) \ static ssize_t sub## _ ##name## _read(struct file *file, \ char __user *userbuf, \ @@ -306,7 +298,7 @@ static ssize_t start_recovery_write(struct file *file, struct wl1271 *wl = file->private_data; mutex_lock(&wl->mutex); - wl12xx_queue_recovery_work(wl); + ieee80211_queue_work(wl->hw, &wl->recovery_work); mutex_unlock(&wl->mutex); return count; @@ -535,129 +527,11 @@ static const struct file_operations beacon_interval_ops = { .llseek = default_llseek, }; -static ssize_t rx_streaming_interval_write(struct file *file, - const char __user *user_buf, - size_t count, loff_t *ppos) -{ - struct wl1271 *wl = file->private_data; - char buf[10]; - size_t len; - unsigned long value; - int ret; - - len = min(count, sizeof(buf) - 1); - if (copy_from_user(buf, user_buf, len)) - return -EFAULT; - buf[len] = '\0'; - - ret = kstrtoul(buf, 0, &value); - if (ret < 0) { - wl1271_warning("illegal value in rx_streaming_interval!"); - return -EINVAL; - } - - /* valid values: 0, 10-100 */ - if (value && (value < 10 || value > 100)) { - wl1271_warning("value is not in range!"); - return -ERANGE; - } - - mutex_lock(&wl->mutex); - - wl->conf.rx_streaming.interval = value; - - ret = wl1271_ps_elp_wakeup(wl); - if (ret < 0) - goto out; - - wl1271_recalc_rx_streaming(wl); - - wl1271_ps_elp_sleep(wl); -out: - mutex_unlock(&wl->mutex); - return count; -} - -static ssize_t rx_streaming_interval_read(struct file *file, - char __user *userbuf, - size_t count, loff_t *ppos) -{ - struct wl1271 *wl = file->private_data; - return wl1271_format_buffer(userbuf, count, ppos, - "%d\n", wl->conf.rx_streaming.interval); -} - -static const struct file_operations rx_streaming_interval_ops = { - .read = rx_streaming_interval_read, - .write = rx_streaming_interval_write, - .open = wl1271_open_file_generic, - .llseek = default_llseek, -}; - -static ssize_t rx_streaming_always_write(struct file *file, - const char __user *user_buf, - size_t count, loff_t *ppos) -{ - struct wl1271 *wl = file->private_data; - char buf[10]; - size_t len; - unsigned long value; - int ret; - - len = min(count, sizeof(buf) - 1); - if (copy_from_user(buf, user_buf, len)) - return -EFAULT; - buf[len] = '\0'; - - ret = kstrtoul(buf, 0, &value); - if (ret < 0) { - wl1271_warning("illegal value in rx_streaming_write!"); - return -EINVAL; - } - - /* valid values: 0, 10-100 */ - if (!(value == 0 || value == 1)) { - wl1271_warning("value is not in valid!"); - return -EINVAL; - } - - mutex_lock(&wl->mutex); - - wl->conf.rx_streaming.always = value; - - ret = wl1271_ps_elp_wakeup(wl); - if (ret < 0) - goto out; - - wl1271_recalc_rx_streaming(wl); - - wl1271_ps_elp_sleep(wl); -out: - mutex_unlock(&wl->mutex); - return count; -} - -static ssize_t rx_streaming_always_read(struct file *file, - char __user *userbuf, - size_t count, loff_t *ppos) -{ - struct wl1271 *wl = file->private_data; - return wl1271_format_buffer(userbuf, count, ppos, - "%d\n", wl->conf.rx_streaming.always); -} - -static const struct file_operations rx_streaming_always_ops = { - .read = rx_streaming_always_read, - .write = rx_streaming_always_write, - .open = wl1271_open_file_generic, - .llseek = default_llseek, -}; - static int wl1271_debugfs_add_files(struct wl1271 *wl, struct dentry *rootdir) { int ret = 0; - struct dentry *entry, *stats, *streaming; + struct dentry *entry, *stats; stats = debugfs_create_dir("fw-statistics", rootdir); if (!stats || IS_ERR(stats)) { @@ -766,14 +640,6 @@ static int wl1271_debugfs_add_files(struct wl1271 *wl, DEBUGFS_ADD(dtim_interval, rootdir); DEBUGFS_ADD(beacon_interval, rootdir); - streaming = debugfs_create_dir("rx_streaming", rootdir); - if (!streaming || IS_ERR(streaming)) - goto err; - - DEBUGFS_ADD_PREFIX(rx_streaming, interval, streaming); - DEBUGFS_ADD_PREFIX(rx_streaming, always, streaming); - - return 0; err: diff --git a/trunk/drivers/net/wireless/wl12xx/event.c b/trunk/drivers/net/wireless/wl12xx/event.c index a16dee58a664..94bbd00ec31b 100644 --- a/trunk/drivers/net/wireless/wl12xx/event.c +++ b/trunk/drivers/net/wireless/wl12xx/event.c @@ -133,13 +133,10 @@ static int wl1271_event_ps_report(struct wl1271 *wl, if (ret < 0) break; - /* - * BET has only a minor effect in 5GHz and masks - * channel switch IEs, so we only enable BET on 2.4GHz - */ - if (wl->band == IEEE80211_BAND_2GHZ) - /* enable beacon early termination */ - ret = wl1271_acx_bet_enable(wl, true); + /* enable beacon early termination */ + ret = wl1271_acx_bet_enable(wl, true); + if (ret < 0) + break; if (wl->ps_compl) { complete(wl->ps_compl); @@ -186,21 +183,6 @@ static void wl1271_stop_ba_event(struct wl1271 *wl, u8 ba_allowed) ieee80211_stop_rx_ba_session(wl->vif, wl->ba_rx_bitmap, wl->bssid); } -static void wl12xx_event_soft_gemini_sense(struct wl1271 *wl, - u8 enable) -{ - if (enable) { - /* disable dynamic PS when requested by the firmware */ - ieee80211_disable_dyn_ps(wl->vif); - set_bit(WL1271_FLAG_SOFT_GEMINI, &wl->flags); - } else { - ieee80211_enable_dyn_ps(wl->vif); - clear_bit(WL1271_FLAG_SOFT_GEMINI, &wl->flags); - wl1271_recalc_rx_streaming(wl); - } - -} - static void wl1271_event_mbox_dump(struct event_mailbox *mbox) { wl1271_debug(DEBUG_EVENT, "MBOX DUMP:"); @@ -244,10 +226,14 @@ static int wl1271_event_process(struct wl1271 *wl, struct event_mailbox *mbox) } } + /* disable dynamic PS when requested by the firmware */ if (vector & SOFT_GEMINI_SENSE_EVENT_ID && - wl->bss_type == BSS_TYPE_STA_BSS) - wl12xx_event_soft_gemini_sense(wl, - mbox->soft_gemini_sense_info); + wl->bss_type == BSS_TYPE_STA_BSS) { + if (mbox->soft_gemini_sense_info) + ieee80211_disable_dyn_ps(wl->vif); + else + ieee80211_enable_dyn_ps(wl->vif); + } /* * The BSS_LOSE_EVENT_ID is only needed while psm (and hence beacon diff --git a/trunk/drivers/net/wireless/wl12xx/ini.h b/trunk/drivers/net/wireless/wl12xx/ini.h index 4cf9ecc56212..1420c842b8f1 100644 --- a/trunk/drivers/net/wireless/wl12xx/ini.h +++ b/trunk/drivers/net/wireless/wl12xx/ini.h @@ -24,9 +24,6 @@ #ifndef __INI_H__ #define __INI_H__ -#define GENERAL_SETTINGS_DRPW_LPD 0xc0 -#define SCRATCH_ENABLE_LPD BIT(25) - #define WL1271_INI_MAX_SMART_REFLEX_PARAM 16 struct wl1271_ini_general_params { diff --git a/trunk/drivers/net/wireless/wl12xx/init.c b/trunk/drivers/net/wireless/wl12xx/init.c index cf40ac93cead..f5c2c9e6f84b 100644 --- a/trunk/drivers/net/wireless/wl12xx/init.c +++ b/trunk/drivers/net/wireless/wl12xx/init.c @@ -321,20 +321,6 @@ static int wl1271_init_beacon_broadcast(struct wl1271 *wl) return 0; } -static int wl12xx_init_fwlog(struct wl1271 *wl) -{ - int ret; - - if (wl->quirks & WL12XX_QUIRK_FWLOG_NOT_IMPLEMENTED) - return 0; - - ret = wl12xx_cmd_config_fwlog(wl); - if (ret < 0) - return ret; - - return 0; -} - static int wl1271_sta_hw_init(struct wl1271 *wl) { int ret; @@ -396,11 +382,6 @@ static int wl1271_sta_hw_init(struct wl1271 *wl) if (ret < 0) return ret; - /* Configure the FW logger */ - ret = wl12xx_init_fwlog(wl); - if (ret < 0) - return ret; - return 0; } diff --git a/trunk/drivers/net/wireless/wl12xx/io.c b/trunk/drivers/net/wireless/wl12xx/io.c index c2da66f45046..da5c1ad942a4 100644 --- a/trunk/drivers/net/wireless/wl12xx/io.c +++ b/trunk/drivers/net/wireless/wl12xx/io.c @@ -23,6 +23,7 @@ #include #include +#include #include #include "wl12xx.h" @@ -127,14 +128,12 @@ EXPORT_SYMBOL_GPL(wl1271_set_partition); void wl1271_io_reset(struct wl1271 *wl) { - if (wl->if_ops->reset) - wl->if_ops->reset(wl); + wl->if_ops->reset(wl); } void wl1271_io_init(struct wl1271 *wl) { - if (wl->if_ops->init) - wl->if_ops->init(wl); + wl->if_ops->init(wl); } void wl1271_top_reg_write(struct wl1271 *wl, int addr, u16 val) diff --git a/trunk/drivers/net/wireless/wl12xx/io.h b/trunk/drivers/net/wireless/wl12xx/io.h index a2fe4f506ada..20b00319e444 100644 --- a/trunk/drivers/net/wireless/wl12xx/io.h +++ b/trunk/drivers/net/wireless/wl12xx/io.h @@ -129,20 +129,6 @@ static inline void wl1271_write(struct wl1271 *wl, int addr, void *buf, wl1271_raw_write(wl, physical, buf, len, fixed); } -static inline void wl1271_read_hwaddr(struct wl1271 *wl, int hwaddr, - void *buf, size_t len, bool fixed) -{ - int physical; - int addr; - - /* Addresses are stored internally as addresses to 32 bytes blocks */ - addr = hwaddr << 5; - - physical = wl1271_translate_addr(wl, addr); - - wl1271_raw_read(wl, physical, buf, len, fixed); -} - static inline u32 wl1271_read32(struct wl1271 *wl, int addr) { return wl1271_raw_read32(wl, wl1271_translate_addr(wl, addr)); diff --git a/trunk/drivers/net/wireless/wl12xx/main.c b/trunk/drivers/net/wireless/wl12xx/main.c index a3734bdf5119..f37f0b873c73 100644 --- a/trunk/drivers/net/wireless/wl12xx/main.c +++ b/trunk/drivers/net/wireless/wl12xx/main.c @@ -31,7 +31,6 @@ #include #include #include -#include #include "wl12xx.h" #include "wl12xx_80211.h" @@ -363,25 +362,9 @@ static struct conf_drv_settings default_conf = { .fm_disturbed_band_margin = 0xff, /* default */ .swallow_clk_diff = 0xff, /* default */ }, - .rx_streaming = { - .duration = 150, - .queues = 0x1, - .interval = 20, - .always = 0, - }, - .fwlog = { - .mode = WL12XX_FWLOG_ON_DEMAND, - .mem_blocks = 2, - .severity = 0, - .timestamp = WL12XX_FWLOG_TIMESTAMP_DISABLED, - .output = WL12XX_FWLOG_OUTPUT_HOST, - .threshold = 0, - }, .hci_io_ds = HCI_IO_DS_6MA, }; -static char *fwlog_param; - static void __wl1271_op_remove_interface(struct wl1271 *wl, bool reset_tx_queues); static void wl1271_free_ap_keys(struct wl1271 *wl); @@ -405,22 +388,6 @@ static struct platform_device wl1271_device = { static DEFINE_MUTEX(wl_list_mutex); static LIST_HEAD(wl_list); -static int wl1271_check_operstate(struct wl1271 *wl, unsigned char operstate) -{ - int ret; - if (operstate != IF_OPER_UP) - return 0; - - if (test_and_set_bit(WL1271_FLAG_STA_STATE_SENT, &wl->flags)) - return 0; - - ret = wl1271_cmd_set_sta_state(wl); - if (ret < 0) - return ret; - - wl1271_info("Association completed."); - return 0; -} static int wl1271_dev_notify(struct notifier_block *me, unsigned long what, void *arg) { @@ -470,7 +437,11 @@ static int wl1271_dev_notify(struct notifier_block *me, unsigned long what, if (ret < 0) goto out; - wl1271_check_operstate(wl, dev->operstate); + if ((dev->operstate == IF_OPER_UP) && + !test_and_set_bit(WL1271_FLAG_STA_STATE_SENT, &wl->flags)) { + wl1271_cmd_set_sta_state(wl); + wl1271_info("Association completed."); + } wl1271_ps_elp_sleep(wl); @@ -502,117 +473,6 @@ static int wl1271_reg_notify(struct wiphy *wiphy, return 0; } -static int wl1271_set_rx_streaming(struct wl1271 *wl, bool enable) -{ - int ret = 0; - - /* we should hold wl->mutex */ - ret = wl1271_acx_ps_rx_streaming(wl, enable); - if (ret < 0) - goto out; - - if (enable) - set_bit(WL1271_FLAG_RX_STREAMING_STARTED, &wl->flags); - else - clear_bit(WL1271_FLAG_RX_STREAMING_STARTED, &wl->flags); -out: - return ret; -} - -/* - * this function is being called when the rx_streaming interval - * has beed changed or rx_streaming should be disabled - */ -int wl1271_recalc_rx_streaming(struct wl1271 *wl) -{ - int ret = 0; - int period = wl->conf.rx_streaming.interval; - - /* don't reconfigure if rx_streaming is disabled */ - if (!test_bit(WL1271_FLAG_RX_STREAMING_STARTED, &wl->flags)) - goto out; - - /* reconfigure/disable according to new streaming_period */ - if (period && - test_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags) && - (wl->conf.rx_streaming.always || - test_bit(WL1271_FLAG_SOFT_GEMINI, &wl->flags))) - ret = wl1271_set_rx_streaming(wl, true); - else { - ret = wl1271_set_rx_streaming(wl, false); - /* don't cancel_work_sync since we might deadlock */ - del_timer_sync(&wl->rx_streaming_timer); - } -out: - return ret; -} - -static void wl1271_rx_streaming_enable_work(struct work_struct *work) -{ - int ret; - struct wl1271 *wl = - container_of(work, struct wl1271, rx_streaming_enable_work); - - mutex_lock(&wl->mutex); - - if (test_bit(WL1271_FLAG_RX_STREAMING_STARTED, &wl->flags) || - !test_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags) || - (!wl->conf.rx_streaming.always && - !test_bit(WL1271_FLAG_SOFT_GEMINI, &wl->flags))) - goto out; - - if (!wl->conf.rx_streaming.interval) - goto out; - - ret = wl1271_ps_elp_wakeup(wl); - if (ret < 0) - goto out; - - ret = wl1271_set_rx_streaming(wl, true); - if (ret < 0) - goto out_sleep; - - /* stop it after some time of inactivity */ - mod_timer(&wl->rx_streaming_timer, - jiffies + msecs_to_jiffies(wl->conf.rx_streaming.duration)); - -out_sleep: - wl1271_ps_elp_sleep(wl); -out: - mutex_unlock(&wl->mutex); -} - -static void wl1271_rx_streaming_disable_work(struct work_struct *work) -{ - int ret; - struct wl1271 *wl = - container_of(work, struct wl1271, rx_streaming_disable_work); - - mutex_lock(&wl->mutex); - - if (!test_bit(WL1271_FLAG_RX_STREAMING_STARTED, &wl->flags)) - goto out; - - ret = wl1271_ps_elp_wakeup(wl); - if (ret < 0) - goto out; - - ret = wl1271_set_rx_streaming(wl, false); - if (ret) - goto out_sleep; - -out_sleep: - wl1271_ps_elp_sleep(wl); -out: - mutex_unlock(&wl->mutex); -} - -static void wl1271_rx_streaming_timer(unsigned long data) -{ - struct wl1271 *wl = (struct wl1271 *)data; - ieee80211_queue_work(wl->hw, &wl->rx_streaming_disable_work); -} - static void wl1271_conf_init(struct wl1271 *wl) { @@ -628,25 +488,9 @@ static void wl1271_conf_init(struct wl1271 *wl) /* apply driver default configuration */ memcpy(&wl->conf, &default_conf, sizeof(default_conf)); - - /* Adjust settings according to optional module parameters */ - if (fwlog_param) { - if (!strcmp(fwlog_param, "continuous")) { - wl->conf.fwlog.mode = WL12XX_FWLOG_CONTINUOUS; - } else if (!strcmp(fwlog_param, "ondemand")) { - wl->conf.fwlog.mode = WL12XX_FWLOG_ON_DEMAND; - } else if (!strcmp(fwlog_param, "dbgpins")) { - wl->conf.fwlog.mode = WL12XX_FWLOG_CONTINUOUS; - wl->conf.fwlog.output = WL12XX_FWLOG_OUTPUT_DBG_PINS; - } else if (!strcmp(fwlog_param, "disable")) { - wl->conf.fwlog.mem_blocks = 0; - wl->conf.fwlog.output = WL12XX_FWLOG_OUTPUT_NONE; - } else { - wl1271_error("Unknown fwlog parameter %s", fwlog_param); - } - } } + static int wl1271_plt_init(struct wl1271 *wl) { struct conf_tx_ac_category *conf_ac; @@ -897,7 +741,7 @@ static void wl1271_flush_deferred_work(struct wl1271 *wl) /* Return sent skbs to the network stack */ while ((skb = skb_dequeue(&wl->deferred_tx_queue))) - ieee80211_tx_status_ni(wl->hw, skb); + ieee80211_tx_status(wl->hw, skb); } static void wl1271_netstack_work(struct work_struct *work) @@ -964,7 +808,7 @@ irqreturn_t wl1271_irq(int irq, void *cookie) if (unlikely(intr & WL1271_ACX_INTR_WATCHDOG)) { wl1271_error("watchdog interrupt received! " "starting recovery."); - wl12xx_queue_recovery_work(wl); + ieee80211_queue_work(wl->hw, &wl->recovery_work); /* restarting the chip. ignore any other interrupt. */ goto out; @@ -1126,89 +970,6 @@ static int wl1271_fetch_nvs(struct wl1271 *wl) return ret; } -void wl12xx_queue_recovery_work(struct wl1271 *wl) -{ - if (!test_bit(WL1271_FLAG_RECOVERY_IN_PROGRESS, &wl->flags)) - ieee80211_queue_work(wl->hw, &wl->recovery_work); -} - -size_t wl12xx_copy_fwlog(struct wl1271 *wl, u8 *memblock, size_t maxlen) -{ - size_t len = 0; - - /* The FW log is a length-value list, find where the log end */ - while (len < maxlen) { - if (memblock[len] == 0) - break; - if (len + memblock[len] + 1 > maxlen) - break; - len += memblock[len] + 1; - } - - /* Make sure we have enough room */ - len = min(len, (size_t)(PAGE_SIZE - wl->fwlog_size)); - - /* Fill the FW log file, consumed by the sysfs fwlog entry */ - memcpy(wl->fwlog + wl->fwlog_size, memblock, len); - wl->fwlog_size += len; - - return len; -} - -static void wl12xx_read_fwlog_panic(struct wl1271 *wl) -{ - u32 addr; - u32 first_addr; - u8 *block; - - if ((wl->quirks & WL12XX_QUIRK_FWLOG_NOT_IMPLEMENTED) || - (wl->conf.fwlog.mode != WL12XX_FWLOG_ON_DEMAND) || - (wl->conf.fwlog.mem_blocks == 0)) - return; - - wl1271_info("Reading FW panic log"); - - block = kmalloc(WL12XX_HW_BLOCK_SIZE, GFP_KERNEL); - if (!block) - return; - - /* - * Make sure the chip is awake and the logger isn't active. - * This might fail if the firmware hanged. - */ - if (!wl1271_ps_elp_wakeup(wl)) - wl12xx_cmd_stop_fwlog(wl); - - /* Read the first memory block address */ - wl1271_fw_status(wl, wl->fw_status); - first_addr = __le32_to_cpu(wl->fw_status->sta.log_start_addr); - if (!first_addr) - goto out; - - /* Traverse the memory blocks linked list */ - addr = first_addr; - do { - memset(block, 0, WL12XX_HW_BLOCK_SIZE); - wl1271_read_hwaddr(wl, addr, block, WL12XX_HW_BLOCK_SIZE, - false); - - /* - * Memory blocks are linked to one another. The first 4 bytes - * of each memory block hold the hardware address of the next - * one. The last memory block points to the first one. - */ - addr = __le32_to_cpup((__le32 *)block); - if (!wl12xx_copy_fwlog(wl, block + sizeof(addr), - WL12XX_HW_BLOCK_SIZE - sizeof(addr))) - break; - } while (addr && (addr != first_addr)); - - wake_up_interruptible(&wl->fwlog_waitq); - -out: - kfree(block); -} - static void wl1271_recovery_work(struct work_struct *work) { struct wl1271 *wl = @@ -1219,11 +980,6 @@ static void wl1271_recovery_work(struct work_struct *work) if (wl->state != WL1271_STATE_ON) goto out; - /* Avoid a recursive recovery */ - set_bit(WL1271_FLAG_RECOVERY_IN_PROGRESS, &wl->flags); - - wl12xx_read_fwlog_panic(wl); - wl1271_info("Hardware recovery in progress. FW ver: %s pc: 0x%x", wl->chip.fw_ver_str, wl1271_read32(wl, SCR_PAD4)); @@ -1240,9 +996,6 @@ static void wl1271_recovery_work(struct work_struct *work) /* reboot the chipset */ __wl1271_op_remove_interface(wl, false); - - clear_bit(WL1271_FLAG_RECOVERY_IN_PROGRESS, &wl->flags); - ieee80211_restart_hw(wl->hw); /* @@ -1321,13 +1074,9 @@ static int wl1271_chip_wakeup(struct wl1271 *wl) wl1271_debug(DEBUG_BOOT, "chip id 0x%x (1271 PG20)", wl->chip.id); - /* - * 'end-of-transaction flag' and 'LPD mode flag' - * should be set in wl127x AP mode only - */ + /* end-of-transaction flag should be set in wl127x AP mode */ if (wl->bss_type == BSS_TYPE_AP_BSS) - wl->quirks |= (WL12XX_QUIRK_END_OF_TRANSACTION | - WL12XX_QUIRK_LPD_MODE); + wl->quirks |= WL12XX_QUIRK_END_OF_TRANSACTION; ret = wl1271_setup(wl); if (ret < 0) @@ -1340,7 +1089,6 @@ static int wl1271_chip_wakeup(struct wl1271 *wl) ret = wl1271_setup(wl); if (ret < 0) goto out; - if (wl1271_set_block_size(wl)) wl->quirks |= WL12XX_QUIRK_BLOCKSIZE_ALIGNMENT; break; @@ -1369,6 +1117,24 @@ static int wl1271_chip_wakeup(struct wl1271 *wl) return ret; } +static unsigned int wl1271_get_fw_ver_quirks(struct wl1271 *wl) +{ + unsigned int quirks = 0; + unsigned int *fw_ver = wl->chip.fw_ver; + + /* Only for wl127x */ + if ((fw_ver[FW_VER_CHIP] == FW_VER_CHIP_WL127X) && + /* Check STA version */ + (((fw_ver[FW_VER_IF_TYPE] == FW_VER_IF_TYPE_STA) && + (fw_ver[FW_VER_MINOR] < FW_VER_MINOR_1_SPARE_STA_MIN)) || + /* Check AP version */ + ((fw_ver[FW_VER_IF_TYPE] == FW_VER_IF_TYPE_AP) && + (fw_ver[FW_VER_MINOR] < FW_VER_MINOR_1_SPARE_AP_MIN)))) + quirks |= WL12XX_QUIRK_USE_2_SPARE_BLOCKS; + + return quirks; +} + int wl1271_plt_start(struct wl1271 *wl) { int retries = WL1271_BOOT_RETRIES; @@ -1405,6 +1171,8 @@ int wl1271_plt_start(struct wl1271 *wl) wl1271_notice("firmware booted in PLT mode (%s)", wl->chip.fw_ver_str); + /* Check if any quirks are needed with older fw versions */ + wl->quirks |= wl1271_get_fw_ver_quirks(wl); goto out; irq_disable: @@ -1584,10 +1352,13 @@ static struct notifier_block wl1271_dev_notifier = { }; #ifdef CONFIG_PM -static int wl1271_configure_suspend_sta(struct wl1271 *wl) +static int wl1271_configure_suspend(struct wl1271 *wl) { int ret; + if (wl->bss_type != BSS_TYPE_STA_BSS) + return 0; + mutex_lock(&wl->mutex); ret = wl1271_ps_elp_wakeup(wl); @@ -1632,41 +1403,11 @@ static int wl1271_configure_suspend_sta(struct wl1271 *wl) } -static int wl1271_configure_suspend_ap(struct wl1271 *wl) -{ - int ret; - - mutex_lock(&wl->mutex); - - ret = wl1271_ps_elp_wakeup(wl); - if (ret < 0) - goto out_unlock; - - ret = wl1271_acx_set_ap_beacon_filter(wl, true); - - wl1271_ps_elp_sleep(wl); -out_unlock: - mutex_unlock(&wl->mutex); - return ret; - -} - -static int wl1271_configure_suspend(struct wl1271 *wl) -{ - if (wl->bss_type == BSS_TYPE_STA_BSS) - return wl1271_configure_suspend_sta(wl); - if (wl->bss_type == BSS_TYPE_AP_BSS) - return wl1271_configure_suspend_ap(wl); - return 0; -} - static void wl1271_configure_resume(struct wl1271 *wl) { int ret; - bool is_sta = wl->bss_type == BSS_TYPE_STA_BSS; - bool is_ap = wl->bss_type == BSS_TYPE_AP_BSS; - if (!is_sta && !is_ap) + if (wl->bss_type != BSS_TYPE_STA_BSS) return; mutex_lock(&wl->mutex); @@ -1674,14 +1415,10 @@ static void wl1271_configure_resume(struct wl1271 *wl) if (ret < 0) goto out; - if (is_sta) { - /* exit psm if it wasn't configured */ - if (!test_bit(WL1271_FLAG_PSM_REQUESTED, &wl->flags)) - wl1271_ps_set_mode(wl, STATION_ACTIVE_MODE, - wl->basic_rate, true); - } else if (is_ap) { - wl1271_acx_set_ap_beacon_filter(wl, false); - } + /* exit psm if it wasn't configured */ + if (!test_bit(WL1271_FLAG_PSM_REQUESTED, &wl->flags)) + wl1271_ps_set_mode(wl, STATION_ACTIVE_MODE, + wl->basic_rate, true); wl1271_ps_elp_sleep(wl); out: @@ -1692,69 +1429,69 @@ static int wl1271_op_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wow) { struct wl1271 *wl = hw->priv; - int ret; - wl1271_debug(DEBUG_MAC80211, "mac80211 suspend wow=%d", !!wow); - WARN_ON(!wow || !wow->any); - - wl->wow_enabled = true; - ret = wl1271_configure_suspend(wl); - if (ret < 0) { - wl1271_warning("couldn't prepare device to suspend"); - return ret; - } - /* flush any remaining work */ - wl1271_debug(DEBUG_MAC80211, "flushing remaining works"); - flush_delayed_work(&wl->scan_complete_work); - - /* - * disable and re-enable interrupts in order to flush - * the threaded_irq - */ - wl1271_disable_interrupts(wl); + wl->wow_enabled = !!wow; + if (wl->wow_enabled) { + int ret; + ret = wl1271_configure_suspend(wl); + if (ret < 0) { + wl1271_warning("couldn't prepare device to suspend"); + return ret; + } + /* flush any remaining work */ + wl1271_debug(DEBUG_MAC80211, "flushing remaining works"); + flush_delayed_work(&wl->scan_complete_work); - /* - * set suspended flag to avoid triggering a new threaded_irq - * work. no need for spinlock as interrupts are disabled. - */ - set_bit(WL1271_FLAG_SUSPENDED, &wl->flags); + /* + * disable and re-enable interrupts in order to flush + * the threaded_irq + */ + wl1271_disable_interrupts(wl); - wl1271_enable_interrupts(wl); - flush_work(&wl->tx_work); - flush_delayed_work(&wl->pspoll_work); - flush_delayed_work(&wl->elp_work); + /* + * set suspended flag to avoid triggering a new threaded_irq + * work. no need for spinlock as interrupts are disabled. + */ + set_bit(WL1271_FLAG_SUSPENDED, &wl->flags); + wl1271_enable_interrupts(wl); + flush_work(&wl->tx_work); + flush_delayed_work(&wl->pspoll_work); + flush_delayed_work(&wl->elp_work); + } return 0; } static int wl1271_op_resume(struct ieee80211_hw *hw) { struct wl1271 *wl = hw->priv; - unsigned long flags; - bool run_irq_work = false; - wl1271_debug(DEBUG_MAC80211, "mac80211 resume wow=%d", wl->wow_enabled); - WARN_ON(!wl->wow_enabled); /* * re-enable irq_work enqueuing, and call irq_work directly if * there is a pending work. */ - spin_lock_irqsave(&wl->wl_lock, flags); - clear_bit(WL1271_FLAG_SUSPENDED, &wl->flags); - if (test_and_clear_bit(WL1271_FLAG_PENDING_WORK, &wl->flags)) - run_irq_work = true; - spin_unlock_irqrestore(&wl->wl_lock, flags); + if (wl->wow_enabled) { + struct wl1271 *wl = hw->priv; + unsigned long flags; + bool run_irq_work = false; + + spin_lock_irqsave(&wl->wl_lock, flags); + clear_bit(WL1271_FLAG_SUSPENDED, &wl->flags); + if (test_and_clear_bit(WL1271_FLAG_PENDING_WORK, &wl->flags)) + run_irq_work = true; + spin_unlock_irqrestore(&wl->wl_lock, flags); + + if (run_irq_work) { + wl1271_debug(DEBUG_MAC80211, + "run postponed irq_work directly"); + wl1271_irq(0, wl); + wl1271_enable_interrupts(wl); + } - if (run_irq_work) { - wl1271_debug(DEBUG_MAC80211, - "run postponed irq_work directly"); - wl1271_irq(0, wl); - wl1271_enable_interrupts(wl); + wl1271_configure_resume(wl); } - wl1271_configure_resume(wl); - wl->wow_enabled = false; return 0; } @@ -1892,6 +1629,9 @@ static int wl1271_op_add_interface(struct ieee80211_hw *hw, strncpy(wiphy->fw_version, wl->chip.fw_ver_str, sizeof(wiphy->fw_version)); + /* Check if any quirks are needed with older fw versions */ + wl->quirks |= wl1271_get_fw_ver_quirks(wl); + /* * Now we know if 11a is supported (info from the NVS), so disable * 11a channels if not supported @@ -1954,9 +1694,6 @@ static void __wl1271_op_remove_interface(struct wl1271 *wl, cancel_delayed_work_sync(&wl->scan_complete_work); cancel_work_sync(&wl->netstack_work); cancel_work_sync(&wl->tx_work); - del_timer_sync(&wl->rx_streaming_timer); - cancel_work_sync(&wl->rx_streaming_enable_work); - cancel_work_sync(&wl->rx_streaming_disable_work); cancel_delayed_work_sync(&wl->pspoll_work); cancel_delayed_work_sync(&wl->elp_work); @@ -3043,6 +2780,24 @@ static void wl1271_bss_info_changed_ap(struct wl1271 *wl, } } + if (changed & BSS_CHANGED_IBSS) { + wl1271_debug(DEBUG_ADHOC, "ibss_joined: %d", + bss_conf->ibss_joined); + + if (bss_conf->ibss_joined) { + u32 rates = bss_conf->basic_rates; + wl->basic_rate_set = wl1271_tx_enabled_rates_get(wl, + rates); + wl->basic_rate = wl1271_tx_min_rate_get(wl); + + /* by default, use 11b rates */ + wl->rate_set = CONF_TX_IBSS_DEFAULT_RATES; + ret = wl1271_acx_sta_rate_policies(wl); + if (ret < 0) + goto out; + } + } + ret = wl1271_bss_erp_info_changed(wl, bss_conf, changed); if (ret < 0) goto out; @@ -3268,24 +3023,6 @@ static void wl1271_bss_info_changed_sta(struct wl1271 *wl, } } - if (changed & BSS_CHANGED_IBSS) { - wl1271_debug(DEBUG_ADHOC, "ibss_joined: %d", - bss_conf->ibss_joined); - - if (bss_conf->ibss_joined) { - u32 rates = bss_conf->basic_rates; - wl->basic_rate_set = wl1271_tx_enabled_rates_get(wl, - rates); - wl->basic_rate = wl1271_tx_min_rate_get(wl); - - /* by default, use 11b rates */ - wl->rate_set = CONF_TX_IBSS_DEFAULT_RATES; - ret = wl1271_acx_sta_rate_policies(wl); - if (ret < 0) - goto out; - } - } - ret = wl1271_bss_erp_info_changed(wl, bss_conf, changed); if (ret < 0) goto out; @@ -3324,7 +3061,6 @@ static void wl1271_bss_info_changed_sta(struct wl1271 *wl, wl1271_warning("cmd join failed %d", ret); goto out; } - wl1271_check_operstate(wl, ieee80211_get_operstate(vif)); } out: @@ -4048,69 +3784,6 @@ static ssize_t wl1271_sysfs_show_hw_pg_ver(struct device *dev, static DEVICE_ATTR(hw_pg_ver, S_IRUGO | S_IWUSR, wl1271_sysfs_show_hw_pg_ver, NULL); -static ssize_t wl1271_sysfs_read_fwlog(struct file *filp, struct kobject *kobj, - struct bin_attribute *bin_attr, - char *buffer, loff_t pos, size_t count) -{ - struct device *dev = container_of(kobj, struct device, kobj); - struct wl1271 *wl = dev_get_drvdata(dev); - ssize_t len; - int ret; - - ret = mutex_lock_interruptible(&wl->mutex); - if (ret < 0) - return -ERESTARTSYS; - - /* Let only one thread read the log at a time, blocking others */ - while (wl->fwlog_size == 0) { - DEFINE_WAIT(wait); - - prepare_to_wait_exclusive(&wl->fwlog_waitq, - &wait, - TASK_INTERRUPTIBLE); - - if (wl->fwlog_size != 0) { - finish_wait(&wl->fwlog_waitq, &wait); - break; - } - - mutex_unlock(&wl->mutex); - - schedule(); - finish_wait(&wl->fwlog_waitq, &wait); - - if (signal_pending(current)) - return -ERESTARTSYS; - - ret = mutex_lock_interruptible(&wl->mutex); - if (ret < 0) - return -ERESTARTSYS; - } - - /* Check if the fwlog is still valid */ - if (wl->fwlog_size < 0) { - mutex_unlock(&wl->mutex); - return 0; - } - - /* Seeking is not supported - old logs are not kept. Disregard pos. */ - len = min(count, (size_t)wl->fwlog_size); - wl->fwlog_size -= len; - memcpy(buffer, wl->fwlog, len); - - /* Make room for new messages */ - memmove(wl->fwlog, wl->fwlog + len, wl->fwlog_size); - - mutex_unlock(&wl->mutex); - - return len; -} - -static struct bin_attribute fwlog_attr = { - .attr = {.name = "fwlog", .mode = S_IRUSR}, - .read = wl1271_sysfs_read_fwlog, -}; - int wl1271_register_hw(struct wl1271 *wl) { int ret; @@ -4291,17 +3964,6 @@ struct ieee80211_hw *wl1271_alloc_hw(void) INIT_WORK(&wl->tx_work, wl1271_tx_work); INIT_WORK(&wl->recovery_work, wl1271_recovery_work); INIT_DELAYED_WORK(&wl->scan_complete_work, wl1271_scan_complete_work); - INIT_WORK(&wl->rx_streaming_enable_work, - wl1271_rx_streaming_enable_work); - INIT_WORK(&wl->rx_streaming_disable_work, - wl1271_rx_streaming_disable_work); - - wl->freezable_wq = create_freezable_workqueue("wl12xx_wq"); - if (!wl->freezable_wq) { - ret = -ENOMEM; - goto err_hw; - } - wl->channel = WL1271_DEFAULT_CHANNEL; wl->beacon_int = WL1271_DEFAULT_BEACON_INT; wl->default_key = 0; @@ -4327,10 +3989,6 @@ struct ieee80211_hw *wl1271_alloc_hw(void) wl->quirks = 0; wl->platform_quirks = 0; wl->sched_scanning = false; - setup_timer(&wl->rx_streaming_timer, wl1271_rx_streaming_timer, - (unsigned long) wl); - wl->fwlog_size = 0; - init_waitqueue_head(&wl->fwlog_waitq); memset(wl->tx_frames_map, 0, sizeof(wl->tx_frames_map)); for (i = 0; i < ACX_TX_DESCRIPTORS; i++) @@ -4348,7 +4006,7 @@ struct ieee80211_hw *wl1271_alloc_hw(void) wl->aggr_buf = (u8 *)__get_free_pages(GFP_KERNEL, order); if (!wl->aggr_buf) { ret = -ENOMEM; - goto err_wq; + goto err_hw; } wl->dummy_packet = wl12xx_alloc_dummy_packet(wl); @@ -4357,18 +4015,11 @@ struct ieee80211_hw *wl1271_alloc_hw(void) goto err_aggr; } - /* Allocate one page for the FW log */ - wl->fwlog = (u8 *)get_zeroed_page(GFP_KERNEL); - if (!wl->fwlog) { - ret = -ENOMEM; - goto err_dummy_packet; - } - /* Register platform device */ ret = platform_device_register(wl->plat_dev); if (ret) { wl1271_error("couldn't register platform device"); - goto err_fwlog; + goto err_dummy_packet; } dev_set_drvdata(&wl->plat_dev->dev, wl); @@ -4386,36 +4037,20 @@ struct ieee80211_hw *wl1271_alloc_hw(void) goto err_bt_coex_state; } - /* Create sysfs file for the FW log */ - ret = device_create_bin_file(&wl->plat_dev->dev, &fwlog_attr); - if (ret < 0) { - wl1271_error("failed to create sysfs file fwlog"); - goto err_hw_pg_ver; - } - return hw; -err_hw_pg_ver: - device_remove_file(&wl->plat_dev->dev, &dev_attr_hw_pg_ver); - err_bt_coex_state: device_remove_file(&wl->plat_dev->dev, &dev_attr_bt_coex_state); err_platform: platform_device_unregister(wl->plat_dev); -err_fwlog: - free_page((unsigned long)wl->fwlog); - err_dummy_packet: dev_kfree_skb(wl->dummy_packet); err_aggr: free_pages((unsigned long)wl->aggr_buf, order); -err_wq: - destroy_workqueue(wl->freezable_wq); - err_hw: wl1271_debugfs_exit(wl); kfree(plat_dev); @@ -4431,15 +4066,7 @@ EXPORT_SYMBOL_GPL(wl1271_alloc_hw); int wl1271_free_hw(struct wl1271 *wl) { - /* Unblock any fwlog readers */ - mutex_lock(&wl->mutex); - wl->fwlog_size = -1; - wake_up_interruptible_all(&wl->fwlog_waitq); - mutex_unlock(&wl->mutex); - - device_remove_bin_file(&wl->plat_dev->dev, &fwlog_attr); platform_device_unregister(wl->plat_dev); - free_page((unsigned long)wl->fwlog); dev_kfree_skb(wl->dummy_packet); free_pages((unsigned long)wl->aggr_buf, get_order(WL1271_AGGR_BUFFER_SIZE)); @@ -4454,7 +4081,6 @@ int wl1271_free_hw(struct wl1271 *wl) kfree(wl->fw_status); kfree(wl->tx_res_if); - destroy_workqueue(wl->freezable_wq); ieee80211_free_hw(wl->hw); @@ -4467,10 +4093,6 @@ EXPORT_SYMBOL_GPL(wl12xx_debug_level); module_param_named(debug_level, wl12xx_debug_level, uint, S_IRUSR | S_IWUSR); MODULE_PARM_DESC(debug_level, "wl12xx debugging level"); -module_param_named(fwlog, fwlog_param, charp, 0); -MODULE_PARM_DESC(keymap, - "FW logger options: continuous, ondemand, dbgpins or disable"); - MODULE_LICENSE("GPL"); MODULE_AUTHOR("Luciano Coelho "); MODULE_AUTHOR("Juuso Oikarinen "); diff --git a/trunk/drivers/net/wireless/wl12xx/ps.c b/trunk/drivers/net/wireless/wl12xx/ps.c index 3e68a664c9de..b59b67711a17 100644 --- a/trunk/drivers/net/wireless/wl12xx/ps.c +++ b/trunk/drivers/net/wireless/wl12xx/ps.c @@ -118,7 +118,7 @@ int wl1271_ps_elp_wakeup(struct wl1271 *wl) &compl, msecs_to_jiffies(WL1271_WAKEUP_TIMEOUT)); if (ret == 0) { wl1271_error("ELP wakeup timeout!"); - wl12xx_queue_recovery_work(wl); + ieee80211_queue_work(wl->hw, &wl->recovery_work); ret = -ETIMEDOUT; goto err; } else if (ret < 0) { @@ -169,11 +169,9 @@ int wl1271_ps_set_mode(struct wl1271 *wl, enum wl1271_cmd_ps_mode mode, wl1271_debug(DEBUG_PSM, "leaving psm"); /* disable beacon early termination */ - if (wl->band == IEEE80211_BAND_2GHZ) { - ret = wl1271_acx_bet_enable(wl, false); - if (ret < 0) - return ret; - } + ret = wl1271_acx_bet_enable(wl, false); + if (ret < 0) + return ret; /* disable beacon filtering */ ret = wl1271_acx_beacon_filter_opt(wl, false); @@ -204,7 +202,7 @@ static void wl1271_ps_filter_frames(struct wl1271 *wl, u8 hlid) info = IEEE80211_SKB_CB(skb); info->flags |= IEEE80211_TX_STAT_TX_FILTERED; info->status.rates[0].idx = -1; - ieee80211_tx_status_ni(wl->hw, skb); + ieee80211_tx_status(wl->hw, skb); filtered++; } } diff --git a/trunk/drivers/net/wireless/wl12xx/rx.c b/trunk/drivers/net/wireless/wl12xx/rx.c index 0450fb49dbb1..70091035e019 100644 --- a/trunk/drivers/net/wireless/wl12xx/rx.c +++ b/trunk/drivers/net/wireless/wl12xx/rx.c @@ -22,7 +22,6 @@ */ #include -#include #include "wl12xx.h" #include "acx.h" @@ -96,7 +95,6 @@ static int wl1271_rx_handle_data(struct wl1271 *wl, u8 *data, u32 length) struct ieee80211_hdr *hdr; u8 *buf; u8 beacon = 0; - u8 is_data = 0; /* * In PLT mode we seem to get frames and mac80211 warns about them, @@ -108,13 +106,6 @@ static int wl1271_rx_handle_data(struct wl1271 *wl, u8 *data, u32 length) /* the data read starts with the descriptor */ desc = (struct wl1271_rx_descriptor *) data; - if (desc->packet_class == WL12XX_RX_CLASS_LOGGER) { - size_t len = length - sizeof(*desc); - wl12xx_copy_fwlog(wl, data + sizeof(*desc), len); - wake_up_interruptible(&wl->fwlog_waitq); - return 0; - } - switch (desc->status & WL1271_RX_DESC_STATUS_MASK) { /* discard corrupted packets */ case WL1271_RX_DESC_DRIVER_RX_Q_FAIL: @@ -146,8 +137,6 @@ static int wl1271_rx_handle_data(struct wl1271 *wl, u8 *data, u32 length) hdr = (struct ieee80211_hdr *)skb->data; if (ieee80211_is_beacon(hdr->frame_control)) beacon = 1; - if (ieee80211_is_data_present(hdr->frame_control)) - is_data = 1; wl1271_rx_status(wl, desc, IEEE80211_SKB_RXCB(skb), beacon); @@ -158,9 +147,9 @@ static int wl1271_rx_handle_data(struct wl1271 *wl, u8 *data, u32 length) skb_trim(skb, skb->len - desc->pad_len); skb_queue_tail(&wl->deferred_rx_queue, skb); - queue_work(wl->freezable_wq, &wl->netstack_work); + ieee80211_queue_work(wl->hw, &wl->netstack_work); - return is_data; + return 0; } void wl1271_rx(struct wl1271 *wl, struct wl1271_fw_common_status *status) @@ -173,8 +162,6 @@ void wl1271_rx(struct wl1271 *wl, struct wl1271_fw_common_status *status) u32 mem_block; u32 pkt_length; u32 pkt_offset; - bool is_ap = (wl->bss_type == BSS_TYPE_AP_BSS); - bool had_data = false; while (drv_rx_counter != fw_rx_counter) { buf_size = 0; @@ -227,11 +214,9 @@ void wl1271_rx(struct wl1271 *wl, struct wl1271_fw_common_status *status) * conditions, in that case the received frame will just * be dropped. */ - if (wl1271_rx_handle_data(wl, - wl->aggr_buf + pkt_offset, - pkt_length) == 1) - had_data = true; - + wl1271_rx_handle_data(wl, + wl->aggr_buf + pkt_offset, + pkt_length); wl->rx_counter++; drv_rx_counter++; drv_rx_counter &= NUM_RX_PKT_DESC_MOD_MASK; @@ -245,20 +230,6 @@ void wl1271_rx(struct wl1271 *wl, struct wl1271_fw_common_status *status) */ if (wl->quirks & WL12XX_QUIRK_END_OF_TRANSACTION) wl1271_write32(wl, RX_DRIVER_COUNTER_ADDRESS, wl->rx_counter); - - if (!is_ap && wl->conf.rx_streaming.interval && had_data && - (wl->conf.rx_streaming.always || - test_bit(WL1271_FLAG_SOFT_GEMINI, &wl->flags))) { - u32 timeout = wl->conf.rx_streaming.duration; - - /* restart rx streaming */ - if (!test_bit(WL1271_FLAG_RX_STREAMING_STARTED, &wl->flags)) - ieee80211_queue_work(wl->hw, - &wl->rx_streaming_enable_work); - - mod_timer(&wl->rx_streaming_timer, - jiffies + msecs_to_jiffies(timeout)); - } } void wl1271_set_default_filters(struct wl1271 *wl) diff --git a/trunk/drivers/net/wireless/wl12xx/rx.h b/trunk/drivers/net/wireless/wl12xx/rx.h index c88e3fa1d603..75fabf836491 100644 --- a/trunk/drivers/net/wireless/wl12xx/rx.h +++ b/trunk/drivers/net/wireless/wl12xx/rx.h @@ -97,18 +97,6 @@ #define RX_BUF_SIZE_MASK 0xFFF00 #define RX_BUF_SIZE_SHIFT_DIV 6 -enum { - WL12XX_RX_CLASS_UNKNOWN, - WL12XX_RX_CLASS_MANAGEMENT, - WL12XX_RX_CLASS_DATA, - WL12XX_RX_CLASS_QOS_DATA, - WL12XX_RX_CLASS_BCN_PRBRSP, - WL12XX_RX_CLASS_EAPOL, - WL12XX_RX_CLASS_BA_EVENT, - WL12XX_RX_CLASS_AMSDU, - WL12XX_RX_CLASS_LOGGER, -}; - struct wl1271_rx_descriptor { __le16 length; u8 status; diff --git a/trunk/drivers/net/wireless/wl12xx/scan.c b/trunk/drivers/net/wireless/wl12xx/scan.c index 5e5c66dd06d5..56f76abc754d 100644 --- a/trunk/drivers/net/wireless/wl12xx/scan.c +++ b/trunk/drivers/net/wireless/wl12xx/scan.c @@ -62,7 +62,7 @@ void wl1271_scan_complete_work(struct work_struct *work) if (wl->scan.failed) { wl1271_info("Scan completed due to error."); - wl12xx_queue_recovery_work(wl); + ieee80211_queue_work(wl->hw, &wl->recovery_work); } out: @@ -326,7 +326,7 @@ wl1271_scan_get_sched_scan_channels(struct wl1271 *wl, struct cfg80211_sched_scan_request *req, struct conn_scan_ch_params *channels, u32 band, bool radar, bool passive, - int start, int max_channels) + int start) { struct conf_sched_scan_settings *c = &wl->conf.sched_scan; int i, j; @@ -334,7 +334,7 @@ wl1271_scan_get_sched_scan_channels(struct wl1271 *wl, bool force_passive = !req->n_ssids; for (i = 0, j = start; - i < req->n_channels && j < max_channels; + i < req->n_channels && j < MAX_CHANNELS_ALL_BANDS; i++) { flags = req->channels[i]->flags; @@ -380,42 +380,46 @@ wl1271_scan_get_sched_scan_channels(struct wl1271 *wl, return j - start; } -static bool +static int wl1271_scan_sched_scan_channels(struct wl1271 *wl, struct cfg80211_sched_scan_request *req, struct wl1271_cmd_sched_scan_config *cfg) { + int idx = 0; + cfg->passive[0] = - wl1271_scan_get_sched_scan_channels(wl, req, cfg->channels_2, + wl1271_scan_get_sched_scan_channels(wl, req, cfg->channels, IEEE80211_BAND_2GHZ, - false, true, 0, - MAX_CHANNELS_2GHZ); + false, true, idx); + idx += cfg->passive[0]; + cfg->active[0] = - wl1271_scan_get_sched_scan_channels(wl, req, cfg->channels_2, + wl1271_scan_get_sched_scan_channels(wl, req, cfg->channels, IEEE80211_BAND_2GHZ, - false, false, - cfg->passive[0], - MAX_CHANNELS_2GHZ); + false, false, idx); + /* + * 5GHz channels always start at position 14, not immediately + * after the last 2.4GHz channel + */ + idx = 14; + cfg->passive[1] = - wl1271_scan_get_sched_scan_channels(wl, req, cfg->channels_5, + wl1271_scan_get_sched_scan_channels(wl, req, cfg->channels, IEEE80211_BAND_5GHZ, - false, true, 0, - MAX_CHANNELS_5GHZ); + false, true, idx); + idx += cfg->passive[1]; + cfg->dfs = - wl1271_scan_get_sched_scan_channels(wl, req, cfg->channels_5, + wl1271_scan_get_sched_scan_channels(wl, req, cfg->channels, IEEE80211_BAND_5GHZ, - true, true, - cfg->passive[1], - MAX_CHANNELS_5GHZ); + true, true, idx); + idx += cfg->dfs; + cfg->active[1] = - wl1271_scan_get_sched_scan_channels(wl, req, cfg->channels_5, + wl1271_scan_get_sched_scan_channels(wl, req, cfg->channels, IEEE80211_BAND_5GHZ, - false, false, - cfg->passive[1] + cfg->dfs, - MAX_CHANNELS_5GHZ); - /* 802.11j channels are not supported yet */ - cfg->passive[2] = 0; - cfg->active[2] = 0; + false, false, idx); + idx += cfg->active[1]; wl1271_debug(DEBUG_SCAN, " 2.4GHz: active %d passive %d", cfg->active[0], cfg->passive[0]); @@ -423,9 +427,7 @@ wl1271_scan_sched_scan_channels(struct wl1271 *wl, cfg->active[1], cfg->passive[1]); wl1271_debug(DEBUG_SCAN, " DFS: %d", cfg->dfs); - return cfg->passive[0] || cfg->active[0] || - cfg->passive[1] || cfg->active[1] || cfg->dfs || - cfg->passive[2] || cfg->active[2]; + return idx; } int wl1271_scan_sched_scan_config(struct wl1271 *wl, @@ -434,7 +436,7 @@ int wl1271_scan_sched_scan_config(struct wl1271 *wl, { struct wl1271_cmd_sched_scan_config *cfg = NULL; struct conf_sched_scan_settings *c = &wl->conf.sched_scan; - int i, ret; + int i, total_channels, ret; bool force_passive = !req->n_ssids; wl1271_debug(DEBUG_CMD, "cmd sched_scan scan config"); @@ -469,7 +471,8 @@ int wl1271_scan_sched_scan_config(struct wl1271 *wl, cfg->ssid_len = 0; } - if (!wl1271_scan_sched_scan_channels(wl, req, cfg)) { + total_channels = wl1271_scan_sched_scan_channels(wl, req, cfg); + if (total_channels == 0) { wl1271_error("scan channel list is empty"); ret = -EINVAL; goto out; diff --git a/trunk/drivers/net/wireless/wl12xx/scan.h b/trunk/drivers/net/wireless/wl12xx/scan.h index ca81de20ebef..a0b6c5d67b07 100644 --- a/trunk/drivers/net/wireless/wl12xx/scan.h +++ b/trunk/drivers/net/wireless/wl12xx/scan.h @@ -112,13 +112,18 @@ struct wl1271_cmd_trigger_scan_to { __le32 timeout; } __packed; -#define MAX_CHANNELS_2GHZ 14 -#define MAX_CHANNELS_5GHZ 23 -#define MAX_CHANNELS_4GHZ 4 - +#define MAX_CHANNELS_ALL_BANDS 41 #define SCAN_MAX_CYCLE_INTERVALS 16 #define SCAN_MAX_BANDS 3 +enum { + SCAN_CHANNEL_TYPE_2GHZ_PASSIVE, + SCAN_CHANNEL_TYPE_2GHZ_ACTIVE, + SCAN_CHANNEL_TYPE_5GHZ_PASSIVE, + SCAN_CHANNEL_TYPE_5GHZ_ACTIVE, + SCAN_CHANNEL_TYPE_5GHZ_DFS, +}; + enum { SCAN_SSID_FILTER_ANY = 0, SCAN_SSID_FILTER_SPECIFIC = 1, @@ -177,9 +182,7 @@ struct wl1271_cmd_sched_scan_config { u8 padding[3]; - struct conn_scan_ch_params channels_2[MAX_CHANNELS_2GHZ]; - struct conn_scan_ch_params channels_5[MAX_CHANNELS_5GHZ]; - struct conn_scan_ch_params channels_4[MAX_CHANNELS_4GHZ]; + struct conn_scan_ch_params channels[MAX_CHANNELS_ALL_BANDS]; } __packed; diff --git a/trunk/drivers/net/wireless/wl12xx/sdio.c b/trunk/drivers/net/wireless/wl12xx/sdio.c index 4dc4573b6861..536e5065454b 100644 --- a/trunk/drivers/net/wireless/wl12xx/sdio.c +++ b/trunk/drivers/net/wireless/wl12xx/sdio.c @@ -23,6 +23,7 @@ #include #include +#include #include #include #include @@ -44,7 +45,7 @@ #define SDIO_DEVICE_ID_TI_WL1271 0x4076 #endif -static const struct sdio_device_id wl1271_devices[] __devinitconst = { +static const struct sdio_device_id wl1271_devices[] = { { SDIO_DEVICE(SDIO_VENDOR_ID_TI, SDIO_DEVICE_ID_TI_WL1271) }, {} }; @@ -106,6 +107,14 @@ static void wl1271_sdio_enable_interrupts(struct wl1271 *wl) enable_irq(wl->irq); } +static void wl1271_sdio_reset(struct wl1271 *wl) +{ +} + +static void wl1271_sdio_init(struct wl1271 *wl) +{ +} + static void wl1271_sdio_raw_read(struct wl1271 *wl, int addr, void *buf, size_t len, bool fixed) { @@ -161,12 +170,10 @@ static int wl1271_sdio_power_on(struct wl1271 *wl) struct sdio_func *func = wl_to_func(wl); int ret; - /* If enabled, tell runtime PM not to power off the card */ - if (pm_runtime_enabled(&func->dev)) { - ret = pm_runtime_get_sync(&func->dev); - if (ret) - goto out; - } + /* Make sure the card will not be powered off by runtime PM */ + ret = pm_runtime_get_sync(&func->dev); + if (ret < 0) + goto out; /* Runtime PM might be disabled, so power up the card manually */ ret = mmc_power_restore_host(func->card->host); @@ -193,11 +200,8 @@ static int wl1271_sdio_power_off(struct wl1271 *wl) if (ret < 0) return ret; - /* If enabled, let runtime PM know the card is powered off */ - if (pm_runtime_enabled(&func->dev)) - ret = pm_runtime_put_sync(&func->dev); - - return ret; + /* Let runtime PM know the card is powered off */ + return pm_runtime_put_sync(&func->dev); } static int wl1271_sdio_set_power(struct wl1271 *wl, bool enable) @@ -211,6 +215,8 @@ static int wl1271_sdio_set_power(struct wl1271 *wl, bool enable) static struct wl1271_if_operations sdio_ops = { .read = wl1271_sdio_raw_read, .write = wl1271_sdio_raw_write, + .reset = wl1271_sdio_reset, + .init = wl1271_sdio_init, .power = wl1271_sdio_set_power, .dev = wl1271_sdio_wl_to_dev, .enable_irq = wl1271_sdio_enable_interrupts, @@ -272,20 +278,18 @@ static int __devinit wl1271_probe(struct sdio_func *func, goto out_free; } - ret = enable_irq_wake(wl->irq); - if (!ret) { - wl->irq_wake_enabled = true; - device_init_wakeup(wl1271_sdio_wl_to_dev(wl), 1); - - /* if sdio can keep power while host is suspended, enable wow */ - mmcflags = sdio_get_host_pm_caps(func); - wl1271_debug(DEBUG_SDIO, "sdio PM caps = 0x%x", mmcflags); + enable_irq_wake(wl->irq); + device_init_wakeup(wl1271_sdio_wl_to_dev(wl), 1); - if (mmcflags & MMC_PM_KEEP_POWER) - hw->wiphy->wowlan.flags = WIPHY_WOWLAN_ANY; - } disable_irq(wl->irq); + /* if sdio can keep power while host is suspended, enable wow */ + mmcflags = sdio_get_host_pm_caps(func); + wl1271_debug(DEBUG_SDIO, "sdio PM caps = 0x%x", mmcflags); + + if (mmcflags & MMC_PM_KEEP_POWER) + hw->wiphy->wowlan.flags = WIPHY_WOWLAN_ANY; + ret = wl1271_init_ieee80211(wl); if (ret) goto out_irq; @@ -299,6 +303,8 @@ static int __devinit wl1271_probe(struct sdio_func *func, /* Tell PM core that we don't need the card to be powered now */ pm_runtime_put_noidle(&func->dev); + wl1271_notice("initialized"); + return 0; out_irq: @@ -318,10 +324,8 @@ static void __devexit wl1271_remove(struct sdio_func *func) pm_runtime_get_noresume(&func->dev); wl1271_unregister_hw(wl); - if (wl->irq_wake_enabled) { - device_init_wakeup(wl1271_sdio_wl_to_dev(wl), 0); - disable_irq_wake(wl->irq); - } + device_init_wakeup(wl1271_sdio_wl_to_dev(wl), 0); + disable_irq_wake(wl->irq); free_irq(wl->irq, wl); wl1271_free_hw(wl); } @@ -398,12 +402,23 @@ static struct sdio_driver wl1271_sdio_driver = { static int __init wl1271_init(void) { - return sdio_register_driver(&wl1271_sdio_driver); + int ret; + + ret = sdio_register_driver(&wl1271_sdio_driver); + if (ret < 0) { + wl1271_error("failed to register sdio driver: %d", ret); + goto out; + } + +out: + return ret; } static void __exit wl1271_exit(void) { sdio_unregister_driver(&wl1271_sdio_driver); + + wl1271_notice("unloaded"); } module_init(wl1271_init); diff --git a/trunk/drivers/net/wireless/wl12xx/spi.c b/trunk/drivers/net/wireless/wl12xx/spi.c index e0b3736d7e19..beebf64c5359 100644 --- a/trunk/drivers/net/wireless/wl12xx/spi.c +++ b/trunk/drivers/net/wireless/wl12xx/spi.c @@ -436,6 +436,8 @@ static int __devinit wl1271_probe(struct spi_device *spi) if (ret) goto out_irq; + wl1271_notice("initialized"); + return 0; out_irq: @@ -472,12 +474,23 @@ static struct spi_driver wl1271_spi_driver = { static int __init wl1271_init(void) { - return spi_register_driver(&wl1271_spi_driver); + int ret; + + ret = spi_register_driver(&wl1271_spi_driver); + if (ret < 0) { + wl1271_error("failed to register spi driver: %d", ret); + goto out; + } + +out: + return ret; } static void __exit wl1271_exit(void) { spi_unregister_driver(&wl1271_spi_driver); + + wl1271_notice("unloaded"); } module_init(wl1271_init); diff --git a/trunk/drivers/net/wireless/wl12xx/testmode.c b/trunk/drivers/net/wireless/wl12xx/testmode.c index 5d5e1ef87206..da351d7cd1f2 100644 --- a/trunk/drivers/net/wireless/wl12xx/testmode.c +++ b/trunk/drivers/net/wireless/wl12xx/testmode.c @@ -260,7 +260,7 @@ static int wl1271_tm_cmd_recover(struct wl1271 *wl, struct nlattr *tb[]) { wl1271_debug(DEBUG_TESTMODE, "testmode cmd recover"); - wl12xx_queue_recovery_work(wl); + ieee80211_queue_work(wl->hw, &wl->recovery_work); return 0; } diff --git a/trunk/drivers/net/wireless/wl12xx/tx.c b/trunk/drivers/net/wireless/wl12xx/tx.c index 200590c0d9e3..ca3ab1c1acef 100644 --- a/trunk/drivers/net/wireless/wl12xx/tx.c +++ b/trunk/drivers/net/wireless/wl12xx/tx.c @@ -562,29 +562,17 @@ static void wl1271_skb_queue_head(struct wl1271 *wl, struct sk_buff *skb) spin_unlock_irqrestore(&wl->wl_lock, flags); } -static bool wl1271_tx_is_data_present(struct sk_buff *skb) -{ - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)(skb->data); - - return ieee80211_is_data_present(hdr->frame_control); -} - void wl1271_tx_work_locked(struct wl1271 *wl) { struct sk_buff *skb; u32 buf_offset = 0; bool sent_packets = false; - bool had_data = false; - bool is_ap = (wl->bss_type == BSS_TYPE_AP_BSS); int ret; if (unlikely(wl->state == WL1271_STATE_OFF)) return; while ((skb = wl1271_skb_dequeue(wl))) { - if (wl1271_tx_is_data_present(skb)) - had_data = true; - ret = wl1271_prepare_tx_frame(wl, skb, buf_offset); if (ret == -EAGAIN) { /* @@ -631,19 +619,6 @@ void wl1271_tx_work_locked(struct wl1271 *wl) wl1271_handle_tx_low_watermark(wl); } - if (!is_ap && wl->conf.rx_streaming.interval && had_data && - (wl->conf.rx_streaming.always || - test_bit(WL1271_FLAG_SOFT_GEMINI, &wl->flags))) { - u32 timeout = wl->conf.rx_streaming.duration; - - /* enable rx streaming */ - if (!test_bit(WL1271_FLAG_RX_STREAMING_STARTED, &wl->flags)) - ieee80211_queue_work(wl->hw, - &wl->rx_streaming_enable_work); - - mod_timer(&wl->rx_streaming_timer, - jiffies + msecs_to_jiffies(timeout)); - } } void wl1271_tx_work(struct work_struct *work) @@ -727,7 +702,7 @@ static void wl1271_tx_complete_packet(struct wl1271 *wl, /* return the packet to the stack */ skb_queue_tail(&wl->deferred_tx_queue, skb); - queue_work(wl->freezable_wq, &wl->netstack_work); + ieee80211_queue_work(wl->hw, &wl->netstack_work); wl1271_free_tx_id(wl, result->id); } @@ -782,7 +757,7 @@ void wl1271_tx_reset_link_queues(struct wl1271 *wl, u8 hlid) info = IEEE80211_SKB_CB(skb); info->status.rates[0].idx = -1; info->status.rates[0].count = 0; - ieee80211_tx_status_ni(wl->hw, skb); + ieee80211_tx_status(wl->hw, skb); total++; } } @@ -820,7 +795,7 @@ void wl1271_tx_reset(struct wl1271 *wl, bool reset_tx_queues) info = IEEE80211_SKB_CB(skb); info->status.rates[0].idx = -1; info->status.rates[0].count = 0; - ieee80211_tx_status_ni(wl->hw, skb); + ieee80211_tx_status(wl->hw, skb); } } } @@ -863,7 +838,7 @@ void wl1271_tx_reset(struct wl1271 *wl, bool reset_tx_queues) info->status.rates[0].idx = -1; info->status.rates[0].count = 0; - ieee80211_tx_status_ni(wl->hw, skb); + ieee80211_tx_status(wl->hw, skb); } } } diff --git a/trunk/drivers/net/wireless/wl12xx/wl12xx.h b/trunk/drivers/net/wireless/wl12xx/wl12xx.h index d7db6e77047a..3bc794a1ee75 100644 --- a/trunk/drivers/net/wireless/wl12xx/wl12xx.h +++ b/trunk/drivers/net/wireless/wl12xx/wl12xx.h @@ -226,8 +226,6 @@ enum { #define FW_VER_MINOR_1_SPARE_STA_MIN 58 #define FW_VER_MINOR_1_SPARE_AP_MIN 47 -#define FW_VER_MINOR_FWLOG_STA_MIN 70 - struct wl1271_chip { u32 id; char fw_ver_str[ETHTOOL_BUSINFO_LEN]; @@ -286,7 +284,8 @@ struct wl1271_fw_sta_status { u8 tx_total; u8 reserved1; __le16 reserved2; - __le32 log_start_addr; + /* Total structure size is 68 bytes */ + u32 padding; } __packed; struct wl1271_fw_full_status { @@ -360,9 +359,6 @@ enum wl12xx_flags { WL1271_FLAG_DUMMY_PACKET_PENDING, WL1271_FLAG_SUSPENDED, WL1271_FLAG_PENDING_WORK, - WL1271_FLAG_SOFT_GEMINI, - WL1271_FLAG_RX_STREAMING_STARTED, - WL1271_FLAG_RECOVERY_IN_PROGRESS, }; struct wl1271_link { @@ -447,7 +443,6 @@ struct wl1271 { struct sk_buff_head deferred_tx_queue; struct work_struct tx_work; - struct workqueue_struct *freezable_wq; /* Pending TX frames */ unsigned long tx_frames_map[BITS_TO_LONGS(ACX_TX_DESCRIPTORS)]; @@ -473,15 +468,6 @@ struct wl1271 { /* Network stack work */ struct work_struct netstack_work; - /* FW log buffer */ - u8 *fwlog; - - /* Number of valid bytes in the FW log buffer */ - ssize_t fwlog_size; - - /* Sysfs FW log entry readers wait queue */ - wait_queue_head_t fwlog_waitq; - /* Hardware recovery work */ struct work_struct recovery_work; @@ -522,11 +508,6 @@ struct wl1271 { /* Default key (for WEP) */ u32 default_key; - /* Rx Streaming */ - struct work_struct rx_streaming_enable_work; - struct work_struct rx_streaming_disable_work; - struct timer_list rx_streaming_timer; - unsigned int filters; unsigned int rx_config; unsigned int rx_filter; @@ -592,7 +573,6 @@ struct wl1271 { * (currently, only "ANY" trigger is supported) */ bool wow_enabled; - bool irq_wake_enabled; /* * AP-mode - links indexed by HLID. The global and broadcast links @@ -622,9 +602,6 @@ struct wl1271_station { int wl1271_plt_start(struct wl1271 *wl); int wl1271_plt_stop(struct wl1271 *wl); -int wl1271_recalc_rx_streaming(struct wl1271 *wl); -void wl12xx_queue_recovery_work(struct wl1271 *wl); -size_t wl12xx_copy_fwlog(struct wl1271 *wl, u8 *memblock, size_t maxlen); #define JOIN_TIMEOUT 5000 /* 5000 milliseconds to join */ @@ -660,15 +637,4 @@ size_t wl12xx_copy_fwlog(struct wl1271 *wl, u8 *memblock, size_t maxlen); /* WL128X requires aggregated packets to be aligned to the SDIO block size */ #define WL12XX_QUIRK_BLOCKSIZE_ALIGNMENT BIT(2) -/* - * WL127X AP mode requires Low Power DRPw (LPD) enable to reduce power - * consumption - */ -#define WL12XX_QUIRK_LPD_MODE BIT(3) - -/* Older firmwares did not implement the FW logger over bus feature */ -#define WL12XX_QUIRK_FWLOG_NOT_IMPLEMENTED BIT(4) - -#define WL12XX_HW_BLOCK_SIZE 256 - #endif diff --git a/trunk/drivers/net/wireless/zd1211rw/zd_chip.h b/trunk/drivers/net/wireless/zd1211rw/zd_chip.h index 117c4123943c..4be7c3b5b265 100644 --- a/trunk/drivers/net/wireless/zd1211rw/zd_chip.h +++ b/trunk/drivers/net/wireless/zd1211rw/zd_chip.h @@ -21,8 +21,6 @@ #ifndef _ZD_CHIP_H #define _ZD_CHIP_H -#include - #include "zd_rf.h" #include "zd_usb.h" diff --git a/trunk/drivers/net/wireless/zd1211rw/zd_def.h b/trunk/drivers/net/wireless/zd1211rw/zd_def.h index 9a1b013f81be..5463ca9ebc01 100644 --- a/trunk/drivers/net/wireless/zd1211rw/zd_def.h +++ b/trunk/drivers/net/wireless/zd1211rw/zd_def.h @@ -37,15 +37,9 @@ typedef u16 __nocast zd_addr_t; if (net_ratelimit()) \ dev_printk_f(KERN_DEBUG, dev, fmt, ## args); \ } while (0) -# define dev_dbg_f_cond(dev, cond, fmt, args...) ({ \ - bool __cond = !!(cond); \ - if (unlikely(__cond)) \ - dev_printk_f(KERN_DEBUG, dev, fmt, ## args); \ -}) #else # define dev_dbg_f(dev, fmt, args...) do { (void)(dev); } while (0) # define dev_dbg_f_limit(dev, fmt, args...) do { (void)(dev); } while (0) -# define dev_dbg_f_cond(dev, cond, fmt, args...) do { (void)(dev); } while (0) #endif /* DEBUG */ #ifdef DEBUG diff --git a/trunk/drivers/net/wireless/zd1211rw/zd_mac.c b/trunk/drivers/net/wireless/zd1211rw/zd_mac.c index cabfae1e70b1..5037c8b2b415 100644 --- a/trunk/drivers/net/wireless/zd1211rw/zd_mac.c +++ b/trunk/drivers/net/wireless/zd1211rw/zd_mac.c @@ -143,7 +143,7 @@ static void beacon_enable(struct zd_mac *mac); static void beacon_disable(struct zd_mac *mac); static void set_rts_cts(struct zd_mac *mac, unsigned int short_preamble); static int zd_mac_config_beacon(struct ieee80211_hw *hw, - struct sk_buff *beacon, bool in_intr); + struct sk_buff *beacon); static int zd_reg2alpha2(u8 regdomain, char *alpha2) { @@ -160,22 +160,6 @@ static int zd_reg2alpha2(u8 regdomain, char *alpha2) return 1; } -static int zd_check_signal(struct ieee80211_hw *hw, int signal) -{ - struct zd_mac *mac = zd_hw_mac(hw); - - dev_dbg_f_cond(zd_mac_dev(mac), signal < 0 || signal > 100, - "%s: signal value from device not in range 0..100, " - "but %d.\n", __func__, signal); - - if (signal < 0) - signal = 0; - else if (signal > 100) - signal = 100; - - return signal; -} - int zd_mac_preinit_hw(struct ieee80211_hw *hw) { int r; @@ -403,8 +387,10 @@ int zd_restore_settings(struct zd_mac *mac) mac->type == NL80211_IFTYPE_AP) { if (mac->vif != NULL) { beacon = ieee80211_beacon_get(mac->hw, mac->vif); - if (beacon) - zd_mac_config_beacon(mac->hw, beacon, false); + if (beacon) { + zd_mac_config_beacon(mac->hw, beacon); + kfree_skb(beacon); + } } zd_set_beacon_interval(&mac->chip, beacon_interval, @@ -475,7 +461,7 @@ static void zd_mac_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb, if (istatus.rates[i].idx = -1; /* terminate */ - info->status.ack_signal = zd_check_signal(hw, ackssi); + info->status.ack_signal = ackssi; ieee80211_tx_status_irqsafe(hw, skb); } @@ -678,34 +664,7 @@ static void cs_set_control(struct zd_mac *mac, struct zd_ctrlset *cs, /* FIXME: Management frame? */ } -static bool zd_mac_match_cur_beacon(struct zd_mac *mac, struct sk_buff *beacon) -{ - if (!mac->beacon.cur_beacon) - return false; - - if (mac->beacon.cur_beacon->len != beacon->len) - return false; - - return !memcmp(beacon->data, mac->beacon.cur_beacon->data, beacon->len); -} - -static void zd_mac_free_cur_beacon_locked(struct zd_mac *mac) -{ - ZD_ASSERT(mutex_is_locked(&mac->chip.mutex)); - - kfree_skb(mac->beacon.cur_beacon); - mac->beacon.cur_beacon = NULL; -} - -static void zd_mac_free_cur_beacon(struct zd_mac *mac) -{ - mutex_lock(&mac->chip.mutex); - zd_mac_free_cur_beacon_locked(mac); - mutex_unlock(&mac->chip.mutex); -} - -static int zd_mac_config_beacon(struct ieee80211_hw *hw, struct sk_buff *beacon, - bool in_intr) +static int zd_mac_config_beacon(struct ieee80211_hw *hw, struct sk_buff *beacon) { struct zd_mac *mac = zd_hw_mac(hw); int r, ret, num_cmds, req_pos = 0; @@ -715,21 +674,13 @@ static int zd_mac_config_beacon(struct ieee80211_hw *hw, struct sk_buff *beacon, unsigned long end_jiffies, message_jiffies; struct zd_ioreq32 *ioreqs; - mutex_lock(&mac->chip.mutex); - - /* Check if hw already has this beacon. */ - if (zd_mac_match_cur_beacon(mac, beacon)) { - r = 0; - goto out_nofree; - } - /* Alloc memory for full beacon write at once. */ num_cmds = 1 + zd_chip_is_zd1211b(&mac->chip) + full_len; ioreqs = kmalloc(num_cmds * sizeof(struct zd_ioreq32), GFP_KERNEL); - if (!ioreqs) { - r = -ENOMEM; - goto out_nofree; - } + if (!ioreqs) + return -ENOMEM; + + mutex_lock(&mac->chip.mutex); r = zd_iowrite32_locked(&mac->chip, 0, CR_BCN_FIFO_SEMAPHORE); if (r < 0) @@ -737,10 +688,6 @@ static int zd_mac_config_beacon(struct ieee80211_hw *hw, struct sk_buff *beacon, r = zd_ioread32_locked(&mac->chip, &tmp, CR_BCN_FIFO_SEMAPHORE); if (r < 0) goto release_sema; - if (in_intr && tmp & 0x2) { - r = -EBUSY; - goto release_sema; - } end_jiffies = jiffies + HZ / 2; /*~500ms*/ message_jiffies = jiffies + HZ / 10; /*~100ms*/ @@ -795,7 +742,7 @@ static int zd_mac_config_beacon(struct ieee80211_hw *hw, struct sk_buff *beacon, end_jiffies = jiffies + HZ / 2; /*~500ms*/ ret = zd_iowrite32_locked(&mac->chip, 1, CR_BCN_FIFO_SEMAPHORE); while (ret < 0) { - if (in_intr || time_is_before_eq_jiffies(end_jiffies)) { + if (time_is_before_eq_jiffies(end_jiffies)) { ret = -ETIMEDOUT; break; } @@ -810,19 +757,9 @@ static int zd_mac_config_beacon(struct ieee80211_hw *hw, struct sk_buff *beacon, if (r < 0 || ret < 0) { if (r >= 0) r = ret; - - /* We don't know if beacon was written successfully or not, - * so clear current. */ - zd_mac_free_cur_beacon_locked(mac); - goto out; } - /* Beacon has now been written successfully, update current. */ - zd_mac_free_cur_beacon_locked(mac); - mac->beacon.cur_beacon = beacon; - beacon = NULL; - /* 802.11b/g 2.4G CCK 1Mb * 802.11a, not yet implemented, uses different values (see GPL vendor * driver) @@ -830,17 +767,11 @@ static int zd_mac_config_beacon(struct ieee80211_hw *hw, struct sk_buff *beacon, r = zd_iowrite32_locked(&mac->chip, 0x00000400 | (full_len << 19), CR_BCN_PLCP_CFG); out: - kfree(ioreqs); -out_nofree: - kfree_skb(beacon); mutex_unlock(&mac->chip.mutex); - + kfree(ioreqs); return r; reset_device: - zd_mac_free_cur_beacon_locked(mac); - kfree_skb(beacon); - mutex_unlock(&mac->chip.mutex); kfree(ioreqs); @@ -1051,7 +982,7 @@ int zd_mac_rx(struct ieee80211_hw *hw, const u8 *buffer, unsigned int length) stats.freq = zd_channels[_zd_chip_get_channel(&mac->chip) - 1].center_freq; stats.band = IEEE80211_BAND_2GHZ; - stats.signal = zd_check_signal(hw, status->signal_strength); + stats.signal = status->signal_strength; rate = zd_rx_rate(buffer, status); @@ -1126,8 +1057,6 @@ static void zd_op_remove_interface(struct ieee80211_hw *hw, mac->vif = NULL; zd_set_beacon_interval(&mac->chip, 0, 0, NL80211_IFTYPE_UNSPECIFIED); zd_write_mac_addr(&mac->chip, NULL); - - zd_mac_free_cur_beacon(mac); } static int zd_op_config(struct ieee80211_hw *hw, u32 changed) @@ -1165,8 +1094,10 @@ static void zd_beacon_done(struct zd_mac *mac) * Fetch next beacon so that tim_count is updated. */ beacon = ieee80211_beacon_get(mac->hw, mac->vif); - if (beacon) - zd_mac_config_beacon(mac->hw, beacon, true); + if (beacon) { + zd_mac_config_beacon(mac->hw, beacon); + kfree_skb(beacon); + } spin_lock_irq(&mac->lock); mac->beacon.last_update = jiffies; @@ -1291,8 +1222,9 @@ static void zd_op_bss_info_changed(struct ieee80211_hw *hw, if (beacon) { zd_chip_disable_hwint(&mac->chip); - zd_mac_config_beacon(hw, beacon, false); + zd_mac_config_beacon(hw, beacon); zd_chip_enable_hwint(&mac->chip); + kfree_skb(beacon); } } @@ -1429,8 +1361,7 @@ static void beacon_watchdog_handler(struct work_struct *work) spin_lock_irq(&mac->lock); interval = mac->beacon.interval; period = mac->beacon.period; - timeout = mac->beacon.last_update + - msecs_to_jiffies(interval * 1024 / 1000) * 3; + timeout = mac->beacon.last_update + msecs_to_jiffies(interval) + HZ; spin_unlock_irq(&mac->lock); if (interval > 0 && time_is_before_jiffies(timeout)) { @@ -1443,9 +1374,8 @@ static void beacon_watchdog_handler(struct work_struct *work) beacon = ieee80211_beacon_get(mac->hw, mac->vif); if (beacon) { - zd_mac_free_cur_beacon(mac); - - zd_mac_config_beacon(mac->hw, beacon, false); + zd_mac_config_beacon(mac->hw, beacon); + kfree_skb(beacon); } zd_set_beacon_interval(&mac->chip, interval, period, mac->type); @@ -1480,8 +1410,6 @@ static void beacon_disable(struct zd_mac *mac) { dev_dbg_f(zd_mac_dev(mac), "\n"); cancel_delayed_work_sync(&mac->beacon.watchdog_work); - - zd_mac_free_cur_beacon(mac); } #define LINK_LED_WORK_DELAY HZ diff --git a/trunk/drivers/net/wireless/zd1211rw/zd_mac.h b/trunk/drivers/net/wireless/zd1211rw/zd_mac.h index c01eca859f95..f8c93c3fe755 100644 --- a/trunk/drivers/net/wireless/zd1211rw/zd_mac.h +++ b/trunk/drivers/net/wireless/zd1211rw/zd_mac.h @@ -165,7 +165,6 @@ struct housekeeping { struct beacon { struct delayed_work watchdog_work; - struct sk_buff *cur_beacon; unsigned long last_update; u16 interval; u8 period; diff --git a/trunk/drivers/net/wireless/zd1211rw/zd_usb.c b/trunk/drivers/net/wireless/zd1211rw/zd_usb.c index cf0d69dd7be5..631194d49828 100644 --- a/trunk/drivers/net/wireless/zd1211rw/zd_usb.c +++ b/trunk/drivers/net/wireless/zd1211rw/zd_usb.c @@ -111,9 +111,6 @@ MODULE_DEVICE_TABLE(usb, usb_ids); #define FW_ZD1211_PREFIX "zd1211/zd1211_" #define FW_ZD1211B_PREFIX "zd1211/zd1211b_" -static bool check_read_regs(struct zd_usb *usb, struct usb_req_read_regs *req, - unsigned int count); - /* USB device initialization */ static void int_urb_complete(struct urb *urb); @@ -368,20 +365,6 @@ int zd_usb_read_fw(struct zd_usb *usb, zd_addr_t addr, u8 *data, u16 len) #define urb_dev(urb) (&(urb)->dev->dev) -static inline void handle_regs_int_override(struct urb *urb) -{ - struct zd_usb *usb = urb->context; - struct zd_usb_interrupt *intr = &usb->intr; - - spin_lock(&intr->lock); - if (atomic_read(&intr->read_regs_enabled)) { - atomic_set(&intr->read_regs_enabled, 0); - intr->read_regs_int_overridden = 1; - complete(&intr->read_regs.completion); - } - spin_unlock(&intr->lock); -} - static inline void handle_regs_int(struct urb *urb) { struct zd_usb *usb = urb->context; @@ -400,45 +383,25 @@ static inline void handle_regs_int(struct urb *urb) USB_MAX_EP_INT_BUFFER); spin_unlock(&mac->lock); schedule_work(&mac->process_intr); - } else if (atomic_read(&intr->read_regs_enabled)) { - len = urb->actual_length; - intr->read_regs.length = urb->actual_length; + } else if (intr->read_regs_enabled) { + intr->read_regs.length = len = urb->actual_length; + if (len > sizeof(intr->read_regs.buffer)) len = sizeof(intr->read_regs.buffer); - memcpy(intr->read_regs.buffer, urb->transfer_buffer, len); - - /* Sometimes USB_INT_ID_REGS is not overridden, but comes after - * USB_INT_ID_RETRY_FAILED. Read-reg retry then gets this - * delayed USB_INT_ID_REGS, but leaves USB_INT_ID_REGS of - * retry unhandled. Next read-reg command then might catch - * this wrong USB_INT_ID_REGS. Fix by ignoring wrong reads. - */ - if (!check_read_regs(usb, intr->read_regs.req, - intr->read_regs.req_count)) - goto out; - - atomic_set(&intr->read_regs_enabled, 0); - intr->read_regs_int_overridden = 0; + intr->read_regs_enabled = 0; complete(&intr->read_regs.completion); - goto out; } out: spin_unlock(&intr->lock); - - /* CR_INTERRUPT might override read_reg too. */ - if (int_num == CR_INTERRUPT && atomic_read(&intr->read_regs_enabled)) - handle_regs_int_override(urb); } static void int_urb_complete(struct urb *urb) { int r; struct usb_int_header *hdr; - struct zd_usb *usb; - struct zd_usb_interrupt *intr; switch (urb->status) { case 0: @@ -467,14 +430,6 @@ static void int_urb_complete(struct urb *urb) goto resubmit; } - /* USB_INT_ID_RETRY_FAILED triggered by tx-urb submit can override - * pending USB_INT_ID_REGS causing read command timeout. - */ - usb = urb->context; - intr = &usb->intr; - if (hdr->id != USB_INT_ID_REGS && atomic_read(&intr->read_regs_enabled)) - handle_regs_int_override(urb); - switch (hdr->id) { case USB_INT_ID_REGS: handle_regs_int(urb); @@ -624,8 +579,8 @@ static void handle_rx_packet(struct zd_usb *usb, const u8 *buffer, if (length < sizeof(struct rx_length_info)) { /* It's not a complete packet anyhow. */ - dev_dbg_f(zd_usb_dev(usb), "invalid, small RX packet : %d\n", - length); + printk("%s: invalid, small RX packet : %d\n", + __func__, length); return; } length_info = (struct rx_length_info *) @@ -1174,7 +1129,6 @@ static inline void init_usb_interrupt(struct zd_usb *usb) spin_lock_init(&intr->lock); intr->interval = int_urb_interval(zd_usb_to_usbdev(usb)); init_completion(&intr->read_regs.completion); - atomic_set(&intr->read_regs_enabled, 0); intr->read_regs.cr_int_addr = cpu_to_le16((u16)CR_INTERRUPT); } @@ -1609,16 +1563,12 @@ static int usb_int_regs_length(unsigned int count) return sizeof(struct usb_int_regs) + count * sizeof(struct reg_data); } -static void prepare_read_regs_int(struct zd_usb *usb, - struct usb_req_read_regs *req, - unsigned int count) +static void prepare_read_regs_int(struct zd_usb *usb) { struct zd_usb_interrupt *intr = &usb->intr; spin_lock_irq(&intr->lock); - atomic_set(&intr->read_regs_enabled, 1); - intr->read_regs.req = req; - intr->read_regs.req_count = count; + intr->read_regs_enabled = 1; INIT_COMPLETION(intr->read_regs.completion); spin_unlock_irq(&intr->lock); } @@ -1628,18 +1578,22 @@ static void disable_read_regs_int(struct zd_usb *usb) struct zd_usb_interrupt *intr = &usb->intr; spin_lock_irq(&intr->lock); - atomic_set(&intr->read_regs_enabled, 0); + intr->read_regs_enabled = 0; spin_unlock_irq(&intr->lock); } -static bool check_read_regs(struct zd_usb *usb, struct usb_req_read_regs *req, - unsigned int count) +static int get_results(struct zd_usb *usb, u16 *values, + struct usb_req_read_regs *req, unsigned int count) { + int r; int i; struct zd_usb_interrupt *intr = &usb->intr; struct read_regs_int *rr = &intr->read_regs; struct usb_int_regs *regs = (struct usb_int_regs *)rr->buffer; + spin_lock_irq(&intr->lock); + + r = -EIO; /* The created block size seems to be larger than expected. * However results appear to be correct. */ @@ -1647,14 +1601,13 @@ static bool check_read_regs(struct zd_usb *usb, struct usb_req_read_regs *req, dev_dbg_f(zd_usb_dev(usb), "error: actual length %d less than expected %d\n", rr->length, usb_int_regs_length(count)); - return false; + goto error_unlock; } - if (rr->length > sizeof(rr->buffer)) { dev_dbg_f(zd_usb_dev(usb), "error: actual length %d exceeds buffer size %zu\n", rr->length, sizeof(rr->buffer)); - return false; + goto error_unlock; } for (i = 0; i < count; i++) { @@ -1664,39 +1617,8 @@ static bool check_read_regs(struct zd_usb *usb, struct usb_req_read_regs *req, "rd[%d] addr %#06hx expected %#06hx\n", i, le16_to_cpu(rd->addr), le16_to_cpu(req->addr[i])); - return false; + goto error_unlock; } - } - - return true; -} - -static int get_results(struct zd_usb *usb, u16 *values, - struct usb_req_read_regs *req, unsigned int count, - bool *retry) -{ - int r; - int i; - struct zd_usb_interrupt *intr = &usb->intr; - struct read_regs_int *rr = &intr->read_regs; - struct usb_int_regs *regs = (struct usb_int_regs *)rr->buffer; - - spin_lock_irq(&intr->lock); - - r = -EIO; - - /* Read failed because firmware bug? */ - *retry = !!intr->read_regs_int_overridden; - if (*retry) - goto error_unlock; - - if (!check_read_regs(usb, req, count)) { - dev_dbg_f(zd_usb_dev(usb), "error: invalid read regs\n"); - goto error_unlock; - } - - for (i = 0; i < count; i++) { - struct reg_data *rd = ®s->regs[i]; values[i] = le16_to_cpu(rd->value); } @@ -1709,11 +1631,11 @@ static int get_results(struct zd_usb *usb, u16 *values, int zd_usb_ioread16v(struct zd_usb *usb, u16 *values, const zd_addr_t *addresses, unsigned int count) { - int r, i, req_len, actual_req_len, try_count = 0; + int r; + int i, req_len, actual_req_len; struct usb_device *udev; struct usb_req_read_regs *req = NULL; unsigned long timeout; - bool retry = false; if (count < 1) { dev_dbg_f(zd_usb_dev(usb), "error: count is zero\n"); @@ -1749,10 +1671,8 @@ int zd_usb_ioread16v(struct zd_usb *usb, u16 *values, for (i = 0; i < count; i++) req->addr[i] = cpu_to_le16((u16)addresses[i]); -retry_read: - try_count++; udev = zd_usb_to_usbdev(usb); - prepare_read_regs_int(usb, req, count); + prepare_read_regs_int(usb); r = zd_ep_regs_out_msg(udev, req, req_len, &actual_req_len, 50 /*ms*/); if (r) { dev_dbg_f(zd_usb_dev(usb), @@ -1776,12 +1696,7 @@ int zd_usb_ioread16v(struct zd_usb *usb, u16 *values, goto error; } - r = get_results(usb, values, req, count, &retry); - if (retry && try_count < 20) { - dev_dbg_f(zd_usb_dev(usb), "read retry, tries so far: %d\n", - try_count); - goto retry_read; - } + r = get_results(usb, values, req, count); error: return r; } diff --git a/trunk/drivers/net/wireless/zd1211rw/zd_usb.h b/trunk/drivers/net/wireless/zd1211rw/zd_usb.h index 99193b456a79..bf942843b733 100644 --- a/trunk/drivers/net/wireless/zd1211rw/zd_usb.h +++ b/trunk/drivers/net/wireless/zd1211rw/zd_usb.h @@ -144,8 +144,6 @@ struct usb_int_retry_fail { struct read_regs_int { struct completion completion; - struct usb_req_read_regs *req; - unsigned int req_count; /* Stores the USB int structure and contains the USB address of the * first requested register before request. */ @@ -171,8 +169,7 @@ struct zd_usb_interrupt { void *buffer; dma_addr_t buffer_dma; int interval; - atomic_t read_regs_enabled; - u8 read_regs_int_overridden:1; + u8 read_regs_enabled:1; }; static inline struct usb_int_regs *get_read_regs(struct zd_usb_interrupt *intr) diff --git a/trunk/drivers/net/xen-netback/netback.c b/trunk/drivers/net/xen-netback/netback.c index fd00f25d9850..0e4851b8a773 100644 --- a/trunk/drivers/net/xen-netback/netback.c +++ b/trunk/drivers/net/xen-netback/netback.c @@ -1743,4 +1743,3 @@ static int __init netback_init(void) module_init(netback_init); MODULE_LICENSE("Dual BSD/GPL"); -MODULE_ALIAS("xen-backend:vif"); diff --git a/trunk/drivers/net/zorro8390.c b/trunk/drivers/net/zorro8390.c index 15e7751a273c..8c7c522a056a 100644 --- a/trunk/drivers/net/zorro8390.c +++ b/trunk/drivers/net/zorro8390.c @@ -19,8 +19,6 @@ * Ethernet Controllers. */ -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - #include #include #include @@ -36,242 +34,115 @@ #include #include -#define EI_SHIFT(x) (ei_local->reg_offset[x]) -#define ei_inb(port) in_8(port) -#define ei_outb(val, port) out_8(port, val) -#define ei_inb_p(port) in_8(port) -#define ei_outb_p(val, port) out_8(port, val) +#define EI_SHIFT(x) (ei_local->reg_offset[x]) +#define ei_inb(port) in_8(port) +#define ei_outb(val,port) out_8(port,val) +#define ei_inb_p(port) in_8(port) +#define ei_outb_p(val,port) out_8(port,val) static const char version[] = - "8390.c:v1.10cvs 9/23/94 Donald Becker (becker@cesdis.gsfc.nasa.gov)\n"; + "8390.c:v1.10cvs 9/23/94 Donald Becker (becker@cesdis.gsfc.nasa.gov)\n"; #include "lib8390.c" #define DRV_NAME "zorro8390" #define NE_BASE (dev->base_addr) -#define NE_CMD (0x00 * 2) -#define NE_DATAPORT (0x10 * 2) /* NatSemi-defined port window offset */ -#define NE_RESET (0x1f * 2) /* Issue a read to reset, - * a write to clear. */ -#define NE_IO_EXTENT (0x20 * 2) - -#define NE_EN0_ISR (0x07 * 2) -#define NE_EN0_DCFG (0x0e * 2) - -#define NE_EN0_RSARLO (0x08 * 2) -#define NE_EN0_RSARHI (0x09 * 2) -#define NE_EN0_RCNTLO (0x0a * 2) -#define NE_EN0_RXCR (0x0c * 2) -#define NE_EN0_TXCR (0x0d * 2) -#define NE_EN0_RCNTHI (0x0b * 2) -#define NE_EN0_IMR (0x0f * 2) +#define NE_CMD (0x00*2) +#define NE_DATAPORT (0x10*2) /* NatSemi-defined port window offset. */ +#define NE_RESET (0x1f*2) /* Issue a read to reset, a write to clear. */ +#define NE_IO_EXTENT (0x20*2) + +#define NE_EN0_ISR (0x07*2) +#define NE_EN0_DCFG (0x0e*2) + +#define NE_EN0_RSARLO (0x08*2) +#define NE_EN0_RSARHI (0x09*2) +#define NE_EN0_RCNTLO (0x0a*2) +#define NE_EN0_RXCR (0x0c*2) +#define NE_EN0_TXCR (0x0d*2) +#define NE_EN0_RCNTHI (0x0b*2) +#define NE_EN0_IMR (0x0f*2) #define NESM_START_PG 0x40 /* First page of TX buffer */ #define NESM_STOP_PG 0x80 /* Last page +1 of RX ring */ -#define WORDSWAP(a) ((((a) >> 8) & 0xff) | ((a) << 8)) + +#define WORDSWAP(a) ((((a)>>8)&0xff) | ((a)<<8)) + static struct card_info { - zorro_id id; - const char *name; - unsigned int offset; + zorro_id id; + const char *name; + unsigned int offset; } cards[] __devinitdata = { - { ZORRO_PROD_VILLAGE_TRONIC_ARIADNE2, "Ariadne II", 0x0600 }, - { ZORRO_PROD_INDIVIDUAL_COMPUTERS_X_SURF, "X-Surf", 0x8600 }, + { ZORRO_PROD_VILLAGE_TRONIC_ARIADNE2, "Ariadne II", 0x0600 }, + { ZORRO_PROD_INDIVIDUAL_COMPUTERS_X_SURF, "X-Surf", 0x8600 }, }; -/* Hard reset the card. This used to pause for the same period that a - * 8390 reset command required, but that shouldn't be necessary. - */ -static void zorro8390_reset_8390(struct net_device *dev) -{ - unsigned long reset_start_time = jiffies; - - if (ei_debug > 1) - netdev_dbg(dev, "resetting - t=%ld...\n", jiffies); - - z_writeb(z_readb(NE_BASE + NE_RESET), NE_BASE + NE_RESET); - - ei_status.txing = 0; - ei_status.dmaing = 0; - - /* This check _should_not_ be necessary, omit eventually. */ - while ((z_readb(NE_BASE + NE_EN0_ISR) & ENISR_RESET) == 0) - if (time_after(jiffies, reset_start_time + 2 * HZ / 100)) { - netdev_warn(dev, "%s: did not complete\n", __func__); - break; - } - z_writeb(ENISR_RESET, NE_BASE + NE_EN0_ISR); /* Ack intr */ -} - -/* Grab the 8390 specific header. Similar to the block_input routine, but - * we don't need to be concerned with ring wrap as the header will be at - * the start of a page, so we optimize accordingly. - */ +static int __devinit zorro8390_init_one(struct zorro_dev *z, + const struct zorro_device_id *ent); +static int __devinit zorro8390_init(struct net_device *dev, + unsigned long board, const char *name, + unsigned long ioaddr); +static int zorro8390_open(struct net_device *dev); +static int zorro8390_close(struct net_device *dev); +static void zorro8390_reset_8390(struct net_device *dev); static void zorro8390_get_8390_hdr(struct net_device *dev, - struct e8390_pkt_hdr *hdr, int ring_page) -{ - int nic_base = dev->base_addr; - int cnt; - short *ptrs; - - /* This *shouldn't* happen. - * If it does, it's the last thing you'll see - */ - if (ei_status.dmaing) { - netdev_err(dev, "%s: DMAing conflict [DMAstat:%d][irqlock:%d]\n", - __func__, ei_status.dmaing, ei_status.irqlock); - return; - } - - ei_status.dmaing |= 0x01; - z_writeb(E8390_NODMA + E8390_PAGE0 + E8390_START, nic_base + NE_CMD); - z_writeb(ENISR_RDC, nic_base + NE_EN0_ISR); - z_writeb(sizeof(struct e8390_pkt_hdr), nic_base + NE_EN0_RCNTLO); - z_writeb(0, nic_base + NE_EN0_RCNTHI); - z_writeb(0, nic_base + NE_EN0_RSARLO); /* On page boundary */ - z_writeb(ring_page, nic_base + NE_EN0_RSARHI); - z_writeb(E8390_RREAD+E8390_START, nic_base + NE_CMD); - - ptrs = (short *)hdr; - for (cnt = 0; cnt < sizeof(struct e8390_pkt_hdr) >> 1; cnt++) - *ptrs++ = z_readw(NE_BASE + NE_DATAPORT); - - z_writeb(ENISR_RDC, nic_base + NE_EN0_ISR); /* Ack intr */ - - hdr->count = WORDSWAP(hdr->count); - - ei_status.dmaing &= ~0x01; -} - -/* Block input and output, similar to the Crynwr packet driver. - * If you are porting to a new ethercard, look at the packet driver source - * for hints. The NEx000 doesn't share the on-board packet memory -- - * you have to put the packet out through the "remote DMA" dataport - * using z_writeb. - */ + struct e8390_pkt_hdr *hdr, int ring_page); static void zorro8390_block_input(struct net_device *dev, int count, - struct sk_buff *skb, int ring_offset) -{ - int nic_base = dev->base_addr; - char *buf = skb->data; - short *ptrs; - int cnt; - - /* This *shouldn't* happen. - * If it does, it's the last thing you'll see - */ - if (ei_status.dmaing) { - netdev_err(dev, "%s: DMAing conflict [DMAstat:%d][irqlock:%d]\n", - __func__, ei_status.dmaing, ei_status.irqlock); - return; - } - ei_status.dmaing |= 0x01; - z_writeb(E8390_NODMA + E8390_PAGE0 + E8390_START, nic_base + NE_CMD); - z_writeb(ENISR_RDC, nic_base + NE_EN0_ISR); - z_writeb(count & 0xff, nic_base + NE_EN0_RCNTLO); - z_writeb(count >> 8, nic_base + NE_EN0_RCNTHI); - z_writeb(ring_offset & 0xff, nic_base + NE_EN0_RSARLO); - z_writeb(ring_offset >> 8, nic_base + NE_EN0_RSARHI); - z_writeb(E8390_RREAD+E8390_START, nic_base + NE_CMD); - ptrs = (short *)buf; - for (cnt = 0; cnt < count >> 1; cnt++) - *ptrs++ = z_readw(NE_BASE + NE_DATAPORT); - if (count & 0x01) - buf[count - 1] = z_readb(NE_BASE + NE_DATAPORT); - - z_writeb(ENISR_RDC, nic_base + NE_EN0_ISR); /* Ack intr */ - ei_status.dmaing &= ~0x01; -} - -static void zorro8390_block_output(struct net_device *dev, int count, + struct sk_buff *skb, int ring_offset); +static void zorro8390_block_output(struct net_device *dev, const int count, const unsigned char *buf, - const int start_page) -{ - int nic_base = NE_BASE; - unsigned long dma_start; - short *ptrs; - int cnt; - - /* Round the count up for word writes. Do we need to do this? - * What effect will an odd byte count have on the 8390? - * I should check someday. - */ - if (count & 0x01) - count++; - - /* This *shouldn't* happen. - * If it does, it's the last thing you'll see - */ - if (ei_status.dmaing) { - netdev_err(dev, "%s: DMAing conflict [DMAstat:%d][irqlock:%d]\n", - __func__, ei_status.dmaing, ei_status.irqlock); - return; - } - ei_status.dmaing |= 0x01; - /* We should already be in page 0, but to be safe... */ - z_writeb(E8390_PAGE0+E8390_START+E8390_NODMA, nic_base + NE_CMD); - - z_writeb(ENISR_RDC, nic_base + NE_EN0_ISR); - - /* Now the normal output. */ - z_writeb(count & 0xff, nic_base + NE_EN0_RCNTLO); - z_writeb(count >> 8, nic_base + NE_EN0_RCNTHI); - z_writeb(0x00, nic_base + NE_EN0_RSARLO); - z_writeb(start_page, nic_base + NE_EN0_RSARHI); - - z_writeb(E8390_RWRITE + E8390_START, nic_base + NE_CMD); - ptrs = (short *)buf; - for (cnt = 0; cnt < count >> 1; cnt++) - z_writew(*ptrs++, NE_BASE + NE_DATAPORT); - - dma_start = jiffies; - - while ((z_readb(NE_BASE + NE_EN0_ISR) & ENISR_RDC) == 0) - if (time_after(jiffies, dma_start + 2 * HZ / 100)) { - /* 20ms */ - netdev_err(dev, "timeout waiting for Tx RDC\n"); - zorro8390_reset_8390(dev); - __NS8390_init(dev, 1); - break; - } - - z_writeb(ENISR_RDC, nic_base + NE_EN0_ISR); /* Ack intr */ - ei_status.dmaing &= ~0x01; -} + const int start_page); +static void __devexit zorro8390_remove_one(struct zorro_dev *z); -static int zorro8390_open(struct net_device *dev) -{ - __ei_open(dev); - return 0; -} +static struct zorro_device_id zorro8390_zorro_tbl[] __devinitdata = { + { ZORRO_PROD_VILLAGE_TRONIC_ARIADNE2, }, + { ZORRO_PROD_INDIVIDUAL_COMPUTERS_X_SURF, }, + { 0 } +}; +MODULE_DEVICE_TABLE(zorro, zorro8390_zorro_tbl); -static int zorro8390_close(struct net_device *dev) -{ - if (ei_debug > 1) - netdev_dbg(dev, "Shutting down ethercard\n"); - __ei_close(dev); - return 0; -} +static struct zorro_driver zorro8390_driver = { + .name = "zorro8390", + .id_table = zorro8390_zorro_tbl, + .probe = zorro8390_init_one, + .remove = __devexit_p(zorro8390_remove_one), +}; -static void __devexit zorro8390_remove_one(struct zorro_dev *z) +static int __devinit zorro8390_init_one(struct zorro_dev *z, + const struct zorro_device_id *ent) { - struct net_device *dev = zorro_get_drvdata(z); - - unregister_netdev(dev); - free_irq(IRQ_AMIGA_PORTS, dev); - release_mem_region(ZTWO_PADDR(dev->base_addr), NE_IO_EXTENT * 2); + struct net_device *dev; + unsigned long board, ioaddr; + int err, i; + + for (i = ARRAY_SIZE(cards)-1; i >= 0; i--) + if (z->id == cards[i].id) + break; + if (i < 0) + return -ENODEV; + + board = z->resource.start; + ioaddr = board+cards[i].offset; + dev = ____alloc_ei_netdev(0); + if (!dev) + return -ENOMEM; + if (!request_mem_region(ioaddr, NE_IO_EXTENT*2, DRV_NAME)) { + free_netdev(dev); + return -EBUSY; + } + if ((err = zorro8390_init(dev, board, cards[i].name, + ZTWO_VADDR(ioaddr)))) { + release_mem_region(ioaddr, NE_IO_EXTENT*2); free_netdev(dev); + return err; + } + zorro_set_drvdata(z, dev); + return 0; } -static struct zorro_device_id zorro8390_zorro_tbl[] __devinitdata = { - { ZORRO_PROD_VILLAGE_TRONIC_ARIADNE2, }, - { ZORRO_PROD_INDIVIDUAL_COMPUTERS_X_SURF, }, - { 0 } -}; -MODULE_DEVICE_TABLE(zorro, zorro8390_zorro_tbl); - static const struct net_device_ops zorro8390_netdev_ops = { .ndo_open = zorro8390_open, .ndo_stop = zorro8390_close, @@ -280,7 +151,7 @@ static const struct net_device_ops zorro8390_netdev_ops = { .ndo_get_stats = __ei_get_stats, .ndo_set_multicast_list = __ei_set_multicast_list, .ndo_validate_addr = eth_validate_addr, - .ndo_set_mac_address = eth_mac_addr, + .ndo_set_mac_address = eth_mac_addr, .ndo_change_mtu = eth_change_mtu, #ifdef CONFIG_NET_POLL_CONTROLLER .ndo_poll_controller = __ei_poll, @@ -291,159 +162,295 @@ static int __devinit zorro8390_init(struct net_device *dev, unsigned long board, const char *name, unsigned long ioaddr) { - int i; - int err; - unsigned char SA_prom[32]; - int start_page, stop_page; - static u32 zorro8390_offsets[16] = { - 0x00, 0x02, 0x04, 0x06, 0x08, 0x0a, 0x0c, 0x0e, - 0x10, 0x12, 0x14, 0x16, 0x18, 0x1a, 0x1c, 0x1e, + int i; + int err; + unsigned char SA_prom[32]; + int start_page, stop_page; + static u32 zorro8390_offsets[16] = { + 0x00, 0x02, 0x04, 0x06, 0x08, 0x0a, 0x0c, 0x0e, + 0x10, 0x12, 0x14, 0x16, 0x18, 0x1a, 0x1c, 0x1e, + }; + + /* Reset card. Who knows what dain-bramaged state it was left in. */ + { + unsigned long reset_start_time = jiffies; + + z_writeb(z_readb(ioaddr + NE_RESET), ioaddr + NE_RESET); + + while ((z_readb(ioaddr + NE_EN0_ISR) & ENISR_RESET) == 0) + if (time_after(jiffies, reset_start_time + 2*HZ/100)) { + printk(KERN_WARNING " not found (no reset ack).\n"); + return -ENODEV; + } + + z_writeb(0xff, ioaddr + NE_EN0_ISR); /* Ack all intr. */ + } + + /* Read the 16 bytes of station address PROM. + We must first initialize registers, similar to NS8390_init(eifdev, 0). + We can't reliably read the SAPROM address without this. + (I learned the hard way!). */ + { + struct { + u32 value; + u32 offset; + } program_seq[] = { + {E8390_NODMA+E8390_PAGE0+E8390_STOP, NE_CMD}, /* Select page 0*/ + {0x48, NE_EN0_DCFG}, /* Set byte-wide (0x48) access. */ + {0x00, NE_EN0_RCNTLO}, /* Clear the count regs. */ + {0x00, NE_EN0_RCNTHI}, + {0x00, NE_EN0_IMR}, /* Mask completion irq. */ + {0xFF, NE_EN0_ISR}, + {E8390_RXOFF, NE_EN0_RXCR}, /* 0x20 Set to monitor */ + {E8390_TXOFF, NE_EN0_TXCR}, /* 0x02 and loopback mode. */ + {32, NE_EN0_RCNTLO}, + {0x00, NE_EN0_RCNTHI}, + {0x00, NE_EN0_RSARLO}, /* DMA starting at 0x0000. */ + {0x00, NE_EN0_RSARHI}, + {E8390_RREAD+E8390_START, NE_CMD}, }; + for (i = 0; i < ARRAY_SIZE(program_seq); i++) { + z_writeb(program_seq[i].value, ioaddr + program_seq[i].offset); + } + } + for (i = 0; i < 16; i++) { + SA_prom[i] = z_readb(ioaddr + NE_DATAPORT); + (void)z_readb(ioaddr + NE_DATAPORT); + } - /* Reset card. Who knows what dain-bramaged state it was left in. */ - { - unsigned long reset_start_time = jiffies; + /* We must set the 8390 for word mode. */ + z_writeb(0x49, ioaddr + NE_EN0_DCFG); + start_page = NESM_START_PG; + stop_page = NESM_STOP_PG; - z_writeb(z_readb(ioaddr + NE_RESET), ioaddr + NE_RESET); + dev->base_addr = ioaddr; + dev->irq = IRQ_AMIGA_PORTS; - while ((z_readb(ioaddr + NE_EN0_ISR) & ENISR_RESET) == 0) - if (time_after(jiffies, - reset_start_time + 2 * HZ / 100)) { - netdev_warn(dev, "not found (no reset ack)\n"); - return -ENODEV; - } + /* Install the Interrupt handler */ + i = request_irq(IRQ_AMIGA_PORTS, __ei_interrupt, IRQF_SHARED, DRV_NAME, dev); + if (i) return i; - z_writeb(0xff, ioaddr + NE_EN0_ISR); /* Ack all intr. */ - } + for(i = 0; i < ETHER_ADDR_LEN; i++) + dev->dev_addr[i] = SA_prom[i]; - /* Read the 16 bytes of station address PROM. - * We must first initialize registers, - * similar to NS8390_init(eifdev, 0). - * We can't reliably read the SAPROM address without this. - * (I learned the hard way!). - */ - { - static const struct { - u32 value; - u32 offset; - } program_seq[] = { - {E8390_NODMA + E8390_PAGE0 + E8390_STOP, NE_CMD}, - /* Select page 0 */ - {0x48, NE_EN0_DCFG}, /* 0x48: Set byte-wide access */ - {0x00, NE_EN0_RCNTLO}, /* Clear the count regs */ - {0x00, NE_EN0_RCNTHI}, - {0x00, NE_EN0_IMR}, /* Mask completion irq */ - {0xFF, NE_EN0_ISR}, - {E8390_RXOFF, NE_EN0_RXCR}, /* 0x20 Set to monitor */ - {E8390_TXOFF, NE_EN0_TXCR}, /* 0x02 and loopback mode */ - {32, NE_EN0_RCNTLO}, - {0x00, NE_EN0_RCNTHI}, - {0x00, NE_EN0_RSARLO}, /* DMA starting at 0x0000 */ - {0x00, NE_EN0_RSARHI}, - {E8390_RREAD + E8390_START, NE_CMD}, - }; - for (i = 0; i < ARRAY_SIZE(program_seq); i++) - z_writeb(program_seq[i].value, - ioaddr + program_seq[i].offset); - } - for (i = 0; i < 16; i++) { - SA_prom[i] = z_readb(ioaddr + NE_DATAPORT); - (void)z_readb(ioaddr + NE_DATAPORT); - } +#ifdef DEBUG + printk("%pM", dev->dev_addr); +#endif - /* We must set the 8390 for word mode. */ - z_writeb(0x49, ioaddr + NE_EN0_DCFG); - start_page = NESM_START_PG; - stop_page = NESM_STOP_PG; + ei_status.name = name; + ei_status.tx_start_page = start_page; + ei_status.stop_page = stop_page; + ei_status.word16 = 1; - dev->base_addr = ioaddr; - dev->irq = IRQ_AMIGA_PORTS; + ei_status.rx_start_page = start_page + TX_PAGES; - /* Install the Interrupt handler */ - i = request_irq(IRQ_AMIGA_PORTS, __ei_interrupt, - IRQF_SHARED, DRV_NAME, dev); - if (i) - return i; + ei_status.reset_8390 = &zorro8390_reset_8390; + ei_status.block_input = &zorro8390_block_input; + ei_status.block_output = &zorro8390_block_output; + ei_status.get_8390_hdr = &zorro8390_get_8390_hdr; + ei_status.reg_offset = zorro8390_offsets; - for (i = 0; i < ETHER_ADDR_LEN; i++) - dev->dev_addr[i] = SA_prom[i]; + dev->netdev_ops = &zorro8390_netdev_ops; + __NS8390_init(dev, 0); + err = register_netdev(dev); + if (err) { + free_irq(IRQ_AMIGA_PORTS, dev); + return err; + } - pr_debug("Found ethernet address: %pM\n", dev->dev_addr); + printk(KERN_INFO "%s: %s at 0x%08lx, Ethernet Address %pM\n", + dev->name, name, board, dev->dev_addr); - ei_status.name = name; - ei_status.tx_start_page = start_page; - ei_status.stop_page = stop_page; - ei_status.word16 = 1; + return 0; +} - ei_status.rx_start_page = start_page + TX_PAGES; +static int zorro8390_open(struct net_device *dev) +{ + __ei_open(dev); + return 0; +} - ei_status.reset_8390 = zorro8390_reset_8390; - ei_status.block_input = zorro8390_block_input; - ei_status.block_output = zorro8390_block_output; - ei_status.get_8390_hdr = zorro8390_get_8390_hdr; - ei_status.reg_offset = zorro8390_offsets; +static int zorro8390_close(struct net_device *dev) +{ + if (ei_debug > 1) + printk(KERN_DEBUG "%s: Shutting down ethercard.\n", dev->name); + __ei_close(dev); + return 0; +} + +/* Hard reset the card. This used to pause for the same period that a + 8390 reset command required, but that shouldn't be necessary. */ +static void zorro8390_reset_8390(struct net_device *dev) +{ + unsigned long reset_start_time = jiffies; - dev->netdev_ops = &zorro8390_netdev_ops; - __NS8390_init(dev, 0); - err = register_netdev(dev); - if (err) { - free_irq(IRQ_AMIGA_PORTS, dev); - return err; + if (ei_debug > 1) + printk(KERN_DEBUG "resetting the 8390 t=%ld...\n", jiffies); + + z_writeb(z_readb(NE_BASE + NE_RESET), NE_BASE + NE_RESET); + + ei_status.txing = 0; + ei_status.dmaing = 0; + + /* This check _should_not_ be necessary, omit eventually. */ + while ((z_readb(NE_BASE+NE_EN0_ISR) & ENISR_RESET) == 0) + if (time_after(jiffies, reset_start_time + 2*HZ/100)) { + printk(KERN_WARNING "%s: ne_reset_8390() did not complete.\n", + dev->name); + break; } + z_writeb(ENISR_RESET, NE_BASE + NE_EN0_ISR); /* Ack intr. */ +} - netdev_info(dev, "%s at 0x%08lx, Ethernet Address %pM\n", - name, board, dev->dev_addr); +/* Grab the 8390 specific header. Similar to the block_input routine, but + we don't need to be concerned with ring wrap as the header will be at + the start of a page, so we optimize accordingly. */ - return 0; +static void zorro8390_get_8390_hdr(struct net_device *dev, + struct e8390_pkt_hdr *hdr, int ring_page) +{ + int nic_base = dev->base_addr; + int cnt; + short *ptrs; + + /* This *shouldn't* happen. If it does, it's the last thing you'll see */ + if (ei_status.dmaing) { + printk(KERN_ERR "%s: DMAing conflict in ne_get_8390_hdr " + "[DMAstat:%d][irqlock:%d].\n", dev->name, ei_status.dmaing, + ei_status.irqlock); + return; + } + + ei_status.dmaing |= 0x01; + z_writeb(E8390_NODMA+E8390_PAGE0+E8390_START, nic_base+ NE_CMD); + z_writeb(ENISR_RDC, nic_base + NE_EN0_ISR); + z_writeb(sizeof(struct e8390_pkt_hdr), nic_base + NE_EN0_RCNTLO); + z_writeb(0, nic_base + NE_EN0_RCNTHI); + z_writeb(0, nic_base + NE_EN0_RSARLO); /* On page boundary */ + z_writeb(ring_page, nic_base + NE_EN0_RSARHI); + z_writeb(E8390_RREAD+E8390_START, nic_base + NE_CMD); + + ptrs = (short*)hdr; + for (cnt = 0; cnt < (sizeof(struct e8390_pkt_hdr)>>1); cnt++) + *ptrs++ = z_readw(NE_BASE + NE_DATAPORT); + + z_writeb(ENISR_RDC, nic_base + NE_EN0_ISR); /* Ack intr. */ + + hdr->count = WORDSWAP(hdr->count); + + ei_status.dmaing &= ~0x01; } -static int __devinit zorro8390_init_one(struct zorro_dev *z, - const struct zorro_device_id *ent) +/* Block input and output, similar to the Crynwr packet driver. If you + are porting to a new ethercard, look at the packet driver source for hints. + The NEx000 doesn't share the on-board packet memory -- you have to put + the packet out through the "remote DMA" dataport using z_writeb. */ + +static void zorro8390_block_input(struct net_device *dev, int count, + struct sk_buff *skb, int ring_offset) { - struct net_device *dev; - unsigned long board, ioaddr; - int err, i; - - for (i = ARRAY_SIZE(cards) - 1; i >= 0; i--) - if (z->id == cards[i].id) - break; - if (i < 0) - return -ENODEV; + int nic_base = dev->base_addr; + char *buf = skb->data; + short *ptrs; + int cnt; + + /* This *shouldn't* happen. If it does, it's the last thing you'll see */ + if (ei_status.dmaing) { + printk(KERN_ERR "%s: DMAing conflict in ne_block_input " + "[DMAstat:%d][irqlock:%d].\n", + dev->name, ei_status.dmaing, ei_status.irqlock); + return; + } + ei_status.dmaing |= 0x01; + z_writeb(E8390_NODMA+E8390_PAGE0+E8390_START, nic_base+ NE_CMD); + z_writeb(ENISR_RDC, nic_base + NE_EN0_ISR); + z_writeb(count & 0xff, nic_base + NE_EN0_RCNTLO); + z_writeb(count >> 8, nic_base + NE_EN0_RCNTHI); + z_writeb(ring_offset & 0xff, nic_base + NE_EN0_RSARLO); + z_writeb(ring_offset >> 8, nic_base + NE_EN0_RSARHI); + z_writeb(E8390_RREAD+E8390_START, nic_base + NE_CMD); + ptrs = (short*)buf; + for (cnt = 0; cnt < (count>>1); cnt++) + *ptrs++ = z_readw(NE_BASE + NE_DATAPORT); + if (count & 0x01) + buf[count-1] = z_readb(NE_BASE + NE_DATAPORT); + + z_writeb(ENISR_RDC, nic_base + NE_EN0_ISR); /* Ack intr. */ + ei_status.dmaing &= ~0x01; +} - board = z->resource.start; - ioaddr = board + cards[i].offset; - dev = ____alloc_ei_netdev(0); - if (!dev) - return -ENOMEM; - if (!request_mem_region(ioaddr, NE_IO_EXTENT * 2, DRV_NAME)) { - free_netdev(dev); - return -EBUSY; - } - err = zorro8390_init(dev, board, cards[i].name, ZTWO_VADDR(ioaddr)); - if (err) { - release_mem_region(ioaddr, NE_IO_EXTENT * 2); - free_netdev(dev); - return err; +static void zorro8390_block_output(struct net_device *dev, int count, + const unsigned char *buf, + const int start_page) +{ + int nic_base = NE_BASE; + unsigned long dma_start; + short *ptrs; + int cnt; + + /* Round the count up for word writes. Do we need to do this? + What effect will an odd byte count have on the 8390? + I should check someday. */ + if (count & 0x01) + count++; + + /* This *shouldn't* happen. If it does, it's the last thing you'll see */ + if (ei_status.dmaing) { + printk(KERN_ERR "%s: DMAing conflict in ne_block_output." + "[DMAstat:%d][irqlock:%d]\n", dev->name, ei_status.dmaing, + ei_status.irqlock); + return; + } + ei_status.dmaing |= 0x01; + /* We should already be in page 0, but to be safe... */ + z_writeb(E8390_PAGE0+E8390_START+E8390_NODMA, nic_base + NE_CMD); + + z_writeb(ENISR_RDC, nic_base + NE_EN0_ISR); + + /* Now the normal output. */ + z_writeb(count & 0xff, nic_base + NE_EN0_RCNTLO); + z_writeb(count >> 8, nic_base + NE_EN0_RCNTHI); + z_writeb(0x00, nic_base + NE_EN0_RSARLO); + z_writeb(start_page, nic_base + NE_EN0_RSARHI); + + z_writeb(E8390_RWRITE+E8390_START, nic_base + NE_CMD); + ptrs = (short*)buf; + for (cnt = 0; cnt < count>>1; cnt++) + z_writew(*ptrs++, NE_BASE+NE_DATAPORT); + + dma_start = jiffies; + + while ((z_readb(NE_BASE + NE_EN0_ISR) & ENISR_RDC) == 0) + if (time_after(jiffies, dma_start + 2*HZ/100)) { /* 20ms */ + printk(KERN_ERR "%s: timeout waiting for Tx RDC.\n", + dev->name); + zorro8390_reset_8390(dev); + __NS8390_init(dev,1); + break; } - zorro_set_drvdata(z, dev); - return 0; + + z_writeb(ENISR_RDC, nic_base + NE_EN0_ISR); /* Ack intr. */ + ei_status.dmaing &= ~0x01; } -static struct zorro_driver zorro8390_driver = { - .name = "zorro8390", - .id_table = zorro8390_zorro_tbl, - .probe = zorro8390_init_one, - .remove = __devexit_p(zorro8390_remove_one), -}; +static void __devexit zorro8390_remove_one(struct zorro_dev *z) +{ + struct net_device *dev = zorro_get_drvdata(z); + + unregister_netdev(dev); + free_irq(IRQ_AMIGA_PORTS, dev); + release_mem_region(ZTWO_PADDR(dev->base_addr), NE_IO_EXTENT*2); + free_netdev(dev); +} static int __init zorro8390_init_module(void) { - return zorro_register_driver(&zorro8390_driver); + return zorro_register_driver(&zorro8390_driver); } static void __exit zorro8390_cleanup_module(void) { - zorro_unregister_driver(&zorro8390_driver); + zorro_unregister_driver(&zorro8390_driver); } module_init(zorro8390_init_module); diff --git a/trunk/drivers/nfc/Kconfig b/trunk/drivers/nfc/Kconfig index 2acff4307ca4..ea1580085347 100644 --- a/trunk/drivers/nfc/Kconfig +++ b/trunk/drivers/nfc/Kconfig @@ -2,8 +2,17 @@ # Near Field Communication (NFC) devices # -menu "Near Field Communication (NFC) devices" - depends on NFC +menuconfig NFC_DEVICES + bool "Near Field Communication (NFC) devices" + default n + ---help--- + You'll have to say Y if your computer contains an NFC device that + you want to use under Linux. + + You can say N here if you don't have any Near Field Communication + devices connected to your computer. + +if NFC_DEVICES config PN544_NFC tristate "PN544 NFC driver" @@ -17,14 +26,5 @@ config PN544_NFC To compile this driver as a module, choose m here. The module will be called pn544. -config NFC_PN533 - tristate "NXP PN533 USB driver" - depends on USB - help - NXP PN533 USB driver. - This driver provides support for NFC NXP PN533 devices. - - Say Y here to compile support for PN533 devices into the - kernel or say M to compile it as module (pn533). -endmenu +endif # NFC_DEVICES diff --git a/trunk/drivers/nfc/Makefile b/trunk/drivers/nfc/Makefile index 8ef446d2c1bd..a4efb164ec49 100644 --- a/trunk/drivers/nfc/Makefile +++ b/trunk/drivers/nfc/Makefile @@ -3,6 +3,3 @@ # obj-$(CONFIG_PN544_NFC) += pn544.o -obj-$(CONFIG_NFC_PN533) += pn533.o - -ccflags-$(CONFIG_NFC_DEBUG) := -DDEBUG diff --git a/trunk/drivers/nfc/pn533.c b/trunk/drivers/nfc/pn533.c deleted file mode 100644 index 037231540719..000000000000 --- a/trunk/drivers/nfc/pn533.c +++ /dev/null @@ -1,1632 +0,0 @@ -/* - * Copyright (C) 2011 Instituto Nokia de Tecnologia - * - * Authors: - * Lauro Ramos Venancio - * Aloisio Almeida Jr - * - * 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. - * - * 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., - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#define VERSION "0.1" - -#define PN533_VENDOR_ID 0x4CC -#define PN533_PRODUCT_ID 0x2533 - -#define SCM_VENDOR_ID 0x4E6 -#define SCL3711_PRODUCT_ID 0x5591 - -static const struct usb_device_id pn533_table[] = { - { USB_DEVICE(PN533_VENDOR_ID, PN533_PRODUCT_ID) }, - { USB_DEVICE(SCM_VENDOR_ID, SCL3711_PRODUCT_ID) }, - { } -}; -MODULE_DEVICE_TABLE(usb, pn533_table); - -/* frame definitions */ -#define PN533_FRAME_TAIL_SIZE 2 -#define PN533_FRAME_SIZE(f) (sizeof(struct pn533_frame) + f->datalen + \ - PN533_FRAME_TAIL_SIZE) -#define PN533_FRAME_ACK_SIZE (sizeof(struct pn533_frame) + 1) -#define PN533_FRAME_CHECKSUM(f) (f->data[f->datalen]) -#define PN533_FRAME_POSTAMBLE(f) (f->data[f->datalen + 1]) - -/* start of frame */ -#define PN533_SOF 0x00FF - -/* frame identifier: in/out/error */ -#define PN533_FRAME_IDENTIFIER(f) (f->data[0]) -#define PN533_DIR_OUT 0xD4 -#define PN533_DIR_IN 0xD5 - -/* PN533 Commands */ -#define PN533_FRAME_CMD(f) (f->data[1]) -#define PN533_FRAME_CMD_PARAMS_PTR(f) (&f->data[2]) -#define PN533_FRAME_CMD_PARAMS_LEN(f) (f->datalen - 2) - -#define PN533_CMD_GET_FIRMWARE_VERSION 0x02 -#define PN533_CMD_RF_CONFIGURATION 0x32 -#define PN533_CMD_IN_DATA_EXCHANGE 0x40 -#define PN533_CMD_IN_LIST_PASSIVE_TARGET 0x4A -#define PN533_CMD_IN_ATR 0x50 -#define PN533_CMD_IN_RELEASE 0x52 - -#define PN533_CMD_RESPONSE(cmd) (cmd + 1) - -/* PN533 Return codes */ -#define PN533_CMD_RET_MASK 0x3F -#define PN533_CMD_MI_MASK 0x40 -#define PN533_CMD_RET_SUCCESS 0x00 - -struct pn533; - -typedef int (*pn533_cmd_complete_t) (struct pn533 *dev, void *arg, - u8 *params, int params_len); - -/* structs for pn533 commands */ - -/* PN533_CMD_GET_FIRMWARE_VERSION */ -struct pn533_fw_version { - u8 ic; - u8 ver; - u8 rev; - u8 support; -}; - -/* PN533_CMD_RF_CONFIGURATION */ -#define PN533_CFGITEM_MAX_RETRIES 0x05 - -#define PN533_CONFIG_MAX_RETRIES_NO_RETRY 0x00 -#define PN533_CONFIG_MAX_RETRIES_ENDLESS 0xFF - -struct pn533_config_max_retries { - u8 mx_rty_atr; - u8 mx_rty_psl; - u8 mx_rty_passive_act; -} __packed; - -/* PN533_CMD_IN_LIST_PASSIVE_TARGET */ - -/* felica commands opcode */ -#define PN533_FELICA_OPC_SENSF_REQ 0 -#define PN533_FELICA_OPC_SENSF_RES 1 -/* felica SENSF_REQ parameters */ -#define PN533_FELICA_SENSF_SC_ALL 0xFFFF -#define PN533_FELICA_SENSF_RC_NO_SYSTEM_CODE 0 -#define PN533_FELICA_SENSF_RC_SYSTEM_CODE 1 -#define PN533_FELICA_SENSF_RC_ADVANCED_PROTOCOL 2 - -/* type B initiator_data values */ -#define PN533_TYPE_B_AFI_ALL_FAMILIES 0 -#define PN533_TYPE_B_POLL_METHOD_TIMESLOT 0 -#define PN533_TYPE_B_POLL_METHOD_PROBABILISTIC 1 - -union pn533_cmd_poll_initdata { - struct { - u8 afi; - u8 polling_method; - } __packed type_b; - struct { - u8 opcode; - __be16 sc; - u8 rc; - u8 tsn; - } __packed felica; -}; - -/* Poll modulations */ -enum { - PN533_POLL_MOD_106KBPS_A, - PN533_POLL_MOD_212KBPS_FELICA, - PN533_POLL_MOD_424KBPS_FELICA, - PN533_POLL_MOD_106KBPS_JEWEL, - PN533_POLL_MOD_847KBPS_B, - - __PN533_POLL_MOD_AFTER_LAST, -}; -#define PN533_POLL_MOD_MAX (__PN533_POLL_MOD_AFTER_LAST - 1) - -struct pn533_poll_modulations { - struct { - u8 maxtg; - u8 brty; - union pn533_cmd_poll_initdata initiator_data; - } __packed data; - u8 len; -}; - -const struct pn533_poll_modulations poll_mod[] = { - [PN533_POLL_MOD_106KBPS_A] = { - .data = { - .maxtg = 1, - .brty = 0, - }, - .len = 2, - }, - [PN533_POLL_MOD_212KBPS_FELICA] = { - .data = { - .maxtg = 1, - .brty = 1, - .initiator_data.felica = { - .opcode = PN533_FELICA_OPC_SENSF_REQ, - .sc = PN533_FELICA_SENSF_SC_ALL, - .rc = PN533_FELICA_SENSF_RC_NO_SYSTEM_CODE, - .tsn = 0, - }, - }, - .len = 7, - }, - [PN533_POLL_MOD_424KBPS_FELICA] = { - .data = { - .maxtg = 1, - .brty = 2, - .initiator_data.felica = { - .opcode = PN533_FELICA_OPC_SENSF_REQ, - .sc = PN533_FELICA_SENSF_SC_ALL, - .rc = PN533_FELICA_SENSF_RC_NO_SYSTEM_CODE, - .tsn = 0, - }, - }, - .len = 7, - }, - [PN533_POLL_MOD_106KBPS_JEWEL] = { - .data = { - .maxtg = 1, - .brty = 4, - }, - .len = 2, - }, - [PN533_POLL_MOD_847KBPS_B] = { - .data = { - .maxtg = 1, - .brty = 8, - .initiator_data.type_b = { - .afi = PN533_TYPE_B_AFI_ALL_FAMILIES, - .polling_method = - PN533_TYPE_B_POLL_METHOD_TIMESLOT, - }, - }, - .len = 3, - }, -}; - -/* PN533_CMD_IN_ATR */ - -struct pn533_cmd_activate_param { - u8 tg; - u8 next; -} __packed; - -struct pn533_cmd_activate_response { - u8 status; - u8 nfcid3t[10]; - u8 didt; - u8 bst; - u8 brt; - u8 to; - u8 ppt; - /* optional */ - u8 gt[]; -} __packed; - - -struct pn533 { - struct usb_device *udev; - struct usb_interface *interface; - struct nfc_dev *nfc_dev; - - struct urb *out_urb; - int out_maxlen; - struct pn533_frame *out_frame; - - struct urb *in_urb; - int in_maxlen; - struct pn533_frame *in_frame; - - struct tasklet_struct tasklet; - struct pn533_frame *tklt_in_frame; - int tklt_in_error; - - pn533_cmd_complete_t cmd_complete; - void *cmd_complete_arg; - struct semaphore cmd_lock; - u8 cmd; - - struct pn533_poll_modulations *poll_mod_active[PN533_POLL_MOD_MAX + 1]; - u8 poll_mod_count; - u8 poll_mod_curr; - u32 poll_protocols; - - u8 tgt_available_prots; - u8 tgt_active_prot; -}; - -struct pn533_frame { - u8 preamble; - __be16 start_frame; - u8 datalen; - u8 datalen_checksum; - u8 data[]; -} __packed; - -/* The rule: value + checksum = 0 */ -static inline u8 pn533_checksum(u8 value) -{ - return ~value + 1; -} - -/* The rule: sum(data elements) + checksum = 0 */ -static u8 pn533_data_checksum(u8 *data, int datalen) -{ - u8 sum = 0; - int i; - - for (i = 0; i < datalen; i++) - sum += data[i]; - - return pn533_checksum(sum); -} - -/** - * pn533_tx_frame_ack - create a ack frame - * @frame: The frame to be set as ack - * - * Ack is different type of standard frame. As a standard frame, it has - * preamble and start_frame. However the checksum of this frame must fail, - * i.e. datalen + datalen_checksum must NOT be zero. When the checksum test - * fails and datalen = 0 and datalen_checksum = 0xFF, the frame is a ack. - * After datalen_checksum field, the postamble is placed. - */ -static void pn533_tx_frame_ack(struct pn533_frame *frame) -{ - frame->preamble = 0; - frame->start_frame = cpu_to_be16(PN533_SOF); - frame->datalen = 0; - frame->datalen_checksum = 0xFF; - /* data[0] is used as postamble */ - frame->data[0] = 0; -} - -static void pn533_tx_frame_init(struct pn533_frame *frame, u8 cmd) -{ - frame->preamble = 0; - frame->start_frame = cpu_to_be16(PN533_SOF); - PN533_FRAME_IDENTIFIER(frame) = PN533_DIR_OUT; - PN533_FRAME_CMD(frame) = cmd; - frame->datalen = 2; -} - -static void pn533_tx_frame_finish(struct pn533_frame *frame) -{ - frame->datalen_checksum = pn533_checksum(frame->datalen); - - PN533_FRAME_CHECKSUM(frame) = - pn533_data_checksum(frame->data, frame->datalen); - - PN533_FRAME_POSTAMBLE(frame) = 0; -} - -static bool pn533_rx_frame_is_valid(struct pn533_frame *frame) -{ - u8 checksum; - - if (frame->start_frame != cpu_to_be16(PN533_SOF)) - return false; - - checksum = pn533_checksum(frame->datalen); - if (checksum != frame->datalen_checksum) - return false; - - checksum = pn533_data_checksum(frame->data, frame->datalen); - if (checksum != PN533_FRAME_CHECKSUM(frame)) - return false; - - return true; -} - -static bool pn533_rx_frame_is_ack(struct pn533_frame *frame) -{ - if (frame->start_frame != cpu_to_be16(PN533_SOF)) - return false; - - if (frame->datalen != 0 || frame->datalen_checksum != 0xFF) - return false; - - return true; -} - -static bool pn533_rx_frame_is_cmd_response(struct pn533_frame *frame, u8 cmd) -{ - return (PN533_FRAME_CMD(frame) == PN533_CMD_RESPONSE(cmd)); -} - -static void pn533_tasklet_cmd_complete(unsigned long arg) -{ - struct pn533 *dev = (struct pn533 *) arg; - struct pn533_frame *in_frame = dev->tklt_in_frame; - int rc; - - if (dev->tklt_in_error) - rc = dev->cmd_complete(dev, dev->cmd_complete_arg, NULL, - dev->tklt_in_error); - else - rc = dev->cmd_complete(dev, dev->cmd_complete_arg, - PN533_FRAME_CMD_PARAMS_PTR(in_frame), - PN533_FRAME_CMD_PARAMS_LEN(in_frame)); - - if (rc != -EINPROGRESS) - up(&dev->cmd_lock); -} - -static void pn533_recv_response(struct urb *urb) -{ - struct pn533 *dev = urb->context; - struct pn533_frame *in_frame; - - dev->tklt_in_frame = NULL; - - switch (urb->status) { - case 0: - /* success */ - break; - case -ECONNRESET: - case -ENOENT: - case -ESHUTDOWN: - nfc_dev_dbg(&dev->interface->dev, "Urb shutting down with" - " status: %d", urb->status); - dev->tklt_in_error = urb->status; - goto sched_tasklet; - default: - nfc_dev_err(&dev->interface->dev, "Nonzero urb status received:" - " %d", urb->status); - dev->tklt_in_error = urb->status; - goto sched_tasklet; - } - - in_frame = dev->in_urb->transfer_buffer; - - if (!pn533_rx_frame_is_valid(in_frame)) { - nfc_dev_err(&dev->interface->dev, "Received an invalid frame"); - dev->tklt_in_error = -EIO; - goto sched_tasklet; - } - - if (!pn533_rx_frame_is_cmd_response(in_frame, dev->cmd)) { - nfc_dev_err(&dev->interface->dev, "The received frame is not " - "response to the last command"); - dev->tklt_in_error = -EIO; - goto sched_tasklet; - } - - nfc_dev_dbg(&dev->interface->dev, "Received a valid frame"); - dev->tklt_in_error = 0; - dev->tklt_in_frame = in_frame; - -sched_tasklet: - tasklet_schedule(&dev->tasklet); -} - -static int pn533_submit_urb_for_response(struct pn533 *dev, gfp_t flags) -{ - dev->in_urb->complete = pn533_recv_response; - - return usb_submit_urb(dev->in_urb, flags); -} - -static void pn533_recv_ack(struct urb *urb) -{ - struct pn533 *dev = urb->context; - struct pn533_frame *in_frame; - int rc; - - switch (urb->status) { - case 0: - /* success */ - break; - case -ECONNRESET: - case -ENOENT: - case -ESHUTDOWN: - nfc_dev_dbg(&dev->interface->dev, "Urb shutting down with" - " status: %d", urb->status); - dev->tklt_in_error = urb->status; - goto sched_tasklet; - default: - nfc_dev_err(&dev->interface->dev, "Nonzero urb status received:" - " %d", urb->status); - dev->tklt_in_error = urb->status; - goto sched_tasklet; - } - - in_frame = dev->in_urb->transfer_buffer; - - if (!pn533_rx_frame_is_ack(in_frame)) { - nfc_dev_err(&dev->interface->dev, "Received an invalid ack"); - dev->tklt_in_error = -EIO; - goto sched_tasklet; - } - - nfc_dev_dbg(&dev->interface->dev, "Received a valid ack"); - - rc = pn533_submit_urb_for_response(dev, GFP_ATOMIC); - if (rc) { - nfc_dev_err(&dev->interface->dev, "usb_submit_urb failed with" - " result %d", rc); - dev->tklt_in_error = rc; - goto sched_tasklet; - } - - return; - -sched_tasklet: - dev->tklt_in_frame = NULL; - tasklet_schedule(&dev->tasklet); -} - -static int pn533_submit_urb_for_ack(struct pn533 *dev, gfp_t flags) -{ - dev->in_urb->complete = pn533_recv_ack; - - return usb_submit_urb(dev->in_urb, flags); -} - -static int pn533_send_ack(struct pn533 *dev, gfp_t flags) -{ - int rc; - - nfc_dev_dbg(&dev->interface->dev, "%s", __func__); - - pn533_tx_frame_ack(dev->out_frame); - - dev->out_urb->transfer_buffer = dev->out_frame; - dev->out_urb->transfer_buffer_length = PN533_FRAME_ACK_SIZE; - rc = usb_submit_urb(dev->out_urb, flags); - - return rc; -} - -static int __pn533_send_cmd_frame_async(struct pn533 *dev, - struct pn533_frame *out_frame, - struct pn533_frame *in_frame, - int in_frame_len, - pn533_cmd_complete_t cmd_complete, - void *arg, gfp_t flags) -{ - int rc; - - nfc_dev_dbg(&dev->interface->dev, "Sending command 0x%x", - PN533_FRAME_CMD(out_frame)); - - dev->cmd = PN533_FRAME_CMD(out_frame); - dev->cmd_complete = cmd_complete; - dev->cmd_complete_arg = arg; - - dev->out_urb->transfer_buffer = out_frame; - dev->out_urb->transfer_buffer_length = - PN533_FRAME_SIZE(out_frame); - - dev->in_urb->transfer_buffer = in_frame; - dev->in_urb->transfer_buffer_length = in_frame_len; - - rc = usb_submit_urb(dev->out_urb, flags); - if (rc) - return rc; - - rc = pn533_submit_urb_for_ack(dev, flags); - if (rc) - goto error; - - return 0; - -error: - usb_unlink_urb(dev->out_urb); - return rc; -} - -static int pn533_send_cmd_frame_async(struct pn533 *dev, - struct pn533_frame *out_frame, - struct pn533_frame *in_frame, - int in_frame_len, - pn533_cmd_complete_t cmd_complete, - void *arg, gfp_t flags) -{ - int rc; - - nfc_dev_dbg(&dev->interface->dev, "%s", __func__); - - if (down_trylock(&dev->cmd_lock)) - return -EBUSY; - - rc = __pn533_send_cmd_frame_async(dev, out_frame, in_frame, - in_frame_len, cmd_complete, arg, flags); - if (rc) - goto error; - - return 0; -error: - up(&dev->cmd_lock); - return rc; -} - -struct pn533_sync_cmd_response { - int rc; - struct completion done; -}; - -static int pn533_sync_cmd_complete(struct pn533 *dev, void *_arg, - u8 *params, int params_len) -{ - struct pn533_sync_cmd_response *arg = _arg; - - nfc_dev_dbg(&dev->interface->dev, "%s", __func__); - - arg->rc = 0; - - if (params_len < 0) /* error */ - arg->rc = params_len; - - complete(&arg->done); - - return 0; -} - -static int pn533_send_cmd_frame_sync(struct pn533 *dev, - struct pn533_frame *out_frame, - struct pn533_frame *in_frame, - int in_frame_len) -{ - int rc; - struct pn533_sync_cmd_response arg; - - nfc_dev_dbg(&dev->interface->dev, "%s", __func__); - - init_completion(&arg.done); - - rc = pn533_send_cmd_frame_async(dev, out_frame, in_frame, in_frame_len, - pn533_sync_cmd_complete, &arg, GFP_KERNEL); - if (rc) - return rc; - - wait_for_completion(&arg.done); - - return arg.rc; -} - -static void pn533_send_complete(struct urb *urb) -{ - struct pn533 *dev = urb->context; - - nfc_dev_dbg(&dev->interface->dev, "%s", __func__); - - switch (urb->status) { - case 0: - /* success */ - break; - case -ECONNRESET: - case -ENOENT: - case -ESHUTDOWN: - nfc_dev_dbg(&dev->interface->dev, "Urb shutting down with" - " status: %d", urb->status); - break; - default: - nfc_dev_dbg(&dev->interface->dev, "Nonzero urb status received:" - " %d", urb->status); - } -} - -struct pn533_target_type_a { - __be16 sens_res; - u8 sel_res; - u8 nfcid_len; - u8 nfcid_data[]; -} __packed; - - -#define PN533_TYPE_A_SENS_RES_NFCID1(x) ((u8)((be16_to_cpu(x) & 0x00C0) >> 6)) -#define PN533_TYPE_A_SENS_RES_SSD(x) ((u8)((be16_to_cpu(x) & 0x001F) >> 0)) -#define PN533_TYPE_A_SENS_RES_PLATCONF(x) ((u8)((be16_to_cpu(x) & 0x0F00) >> 8)) - -#define PN533_TYPE_A_SENS_RES_SSD_JEWEL 0x00 -#define PN533_TYPE_A_SENS_RES_PLATCONF_JEWEL 0x0C - -#define PN533_TYPE_A_SEL_PROT(x) (((x) & 0x60) >> 5) -#define PN533_TYPE_A_SEL_CASCADE(x) (((x) & 0x04) >> 2) - -#define PN533_TYPE_A_SEL_PROT_MIFARE 0 -#define PN533_TYPE_A_SEL_PROT_ISO14443 1 -#define PN533_TYPE_A_SEL_PROT_DEP 2 -#define PN533_TYPE_A_SEL_PROT_ISO14443_DEP 3 - -static bool pn533_target_type_a_is_valid(struct pn533_target_type_a *type_a, - int target_data_len) -{ - u8 ssd; - u8 platconf; - - if (target_data_len < sizeof(struct pn533_target_type_a)) - return false; - - /* The lenght check of nfcid[] and ats[] are not being performed because - the values are not being used */ - - /* Requirement 4.6.3.3 from NFC Forum Digital Spec */ - ssd = PN533_TYPE_A_SENS_RES_SSD(type_a->sens_res); - platconf = PN533_TYPE_A_SENS_RES_PLATCONF(type_a->sens_res); - - if ((ssd == PN533_TYPE_A_SENS_RES_SSD_JEWEL && - platconf != PN533_TYPE_A_SENS_RES_PLATCONF_JEWEL) || - (ssd != PN533_TYPE_A_SENS_RES_SSD_JEWEL && - platconf == PN533_TYPE_A_SENS_RES_PLATCONF_JEWEL)) - return false; - - /* Requirements 4.8.2.1, 4.8.2.3, 4.8.2.5 and 4.8.2.7 from NFC Forum */ - if (PN533_TYPE_A_SEL_CASCADE(type_a->sel_res) != 0) - return false; - - return true; -} - -static int pn533_target_found_type_a(struct nfc_target *nfc_tgt, u8 *tgt_data, - int tgt_data_len) -{ - struct pn533_target_type_a *tgt_type_a; - - tgt_type_a = (struct pn533_target_type_a *) tgt_data; - - if (!pn533_target_type_a_is_valid(tgt_type_a, tgt_data_len)) - return -EPROTO; - - switch (PN533_TYPE_A_SEL_PROT(tgt_type_a->sel_res)) { - case PN533_TYPE_A_SEL_PROT_MIFARE: - nfc_tgt->supported_protocols = NFC_PROTO_MIFARE_MASK; - break; - case PN533_TYPE_A_SEL_PROT_ISO14443: - nfc_tgt->supported_protocols = NFC_PROTO_ISO14443_MASK; - break; - case PN533_TYPE_A_SEL_PROT_DEP: - nfc_tgt->supported_protocols = NFC_PROTO_NFC_DEP_MASK; - break; - case PN533_TYPE_A_SEL_PROT_ISO14443_DEP: - nfc_tgt->supported_protocols = NFC_PROTO_ISO14443_MASK | - NFC_PROTO_NFC_DEP_MASK; - break; - } - - nfc_tgt->sens_res = be16_to_cpu(tgt_type_a->sens_res); - nfc_tgt->sel_res = tgt_type_a->sel_res; - - return 0; -} - -struct pn533_target_felica { - u8 pol_res; - u8 opcode; - u8 nfcid2[8]; - u8 pad[8]; - /* optional */ - u8 syst_code[]; -} __packed; - -#define PN533_FELICA_SENSF_NFCID2_DEP_B1 0x01 -#define PN533_FELICA_SENSF_NFCID2_DEP_B2 0xFE - -static bool pn533_target_felica_is_valid(struct pn533_target_felica *felica, - int target_data_len) -{ - if (target_data_len < sizeof(struct pn533_target_felica)) - return false; - - if (felica->opcode != PN533_FELICA_OPC_SENSF_RES) - return false; - - return true; -} - -static int pn533_target_found_felica(struct nfc_target *nfc_tgt, u8 *tgt_data, - int tgt_data_len) -{ - struct pn533_target_felica *tgt_felica; - - tgt_felica = (struct pn533_target_felica *) tgt_data; - - if (!pn533_target_felica_is_valid(tgt_felica, tgt_data_len)) - return -EPROTO; - - if (tgt_felica->nfcid2[0] == PN533_FELICA_SENSF_NFCID2_DEP_B1 && - tgt_felica->nfcid2[1] == - PN533_FELICA_SENSF_NFCID2_DEP_B2) - nfc_tgt->supported_protocols = NFC_PROTO_NFC_DEP_MASK; - else - nfc_tgt->supported_protocols = NFC_PROTO_FELICA_MASK; - - return 0; -} - -struct pn533_target_jewel { - __be16 sens_res; - u8 jewelid[4]; -} __packed; - -static bool pn533_target_jewel_is_valid(struct pn533_target_jewel *jewel, - int target_data_len) -{ - u8 ssd; - u8 platconf; - - if (target_data_len < sizeof(struct pn533_target_jewel)) - return false; - - /* Requirement 4.6.3.3 from NFC Forum Digital Spec */ - ssd = PN533_TYPE_A_SENS_RES_SSD(jewel->sens_res); - platconf = PN533_TYPE_A_SENS_RES_PLATCONF(jewel->sens_res); - - if ((ssd == PN533_TYPE_A_SENS_RES_SSD_JEWEL && - platconf != PN533_TYPE_A_SENS_RES_PLATCONF_JEWEL) || - (ssd != PN533_TYPE_A_SENS_RES_SSD_JEWEL && - platconf == PN533_TYPE_A_SENS_RES_PLATCONF_JEWEL)) - return false; - - return true; -} - -static int pn533_target_found_jewel(struct nfc_target *nfc_tgt, u8 *tgt_data, - int tgt_data_len) -{ - struct pn533_target_jewel *tgt_jewel; - - tgt_jewel = (struct pn533_target_jewel *) tgt_data; - - if (!pn533_target_jewel_is_valid(tgt_jewel, tgt_data_len)) - return -EPROTO; - - nfc_tgt->supported_protocols = NFC_PROTO_JEWEL_MASK; - nfc_tgt->sens_res = be16_to_cpu(tgt_jewel->sens_res); - - return 0; -} - -struct pn533_type_b_prot_info { - u8 bitrate; - u8 fsci_type; - u8 fwi_adc_fo; -} __packed; - -#define PN533_TYPE_B_PROT_FCSI(x) (((x) & 0xF0) >> 4) -#define PN533_TYPE_B_PROT_TYPE(x) (((x) & 0x0F) >> 0) -#define PN533_TYPE_B_PROT_TYPE_RFU_MASK 0x8 - -struct pn533_type_b_sens_res { - u8 opcode; - u8 nfcid[4]; - u8 appdata[4]; - struct pn533_type_b_prot_info prot_info; -} __packed; - -#define PN533_TYPE_B_OPC_SENSB_RES 0x50 - -struct pn533_target_type_b { - struct pn533_type_b_sens_res sensb_res; - u8 attrib_res_len; - u8 attrib_res[]; -} __packed; - -static bool pn533_target_type_b_is_valid(struct pn533_target_type_b *type_b, - int target_data_len) -{ - if (target_data_len < sizeof(struct pn533_target_type_b)) - return false; - - if (type_b->sensb_res.opcode != PN533_TYPE_B_OPC_SENSB_RES) - return false; - - if (PN533_TYPE_B_PROT_TYPE(type_b->sensb_res.prot_info.fsci_type) & - PN533_TYPE_B_PROT_TYPE_RFU_MASK) - return false; - - return true; -} - -static int pn533_target_found_type_b(struct nfc_target *nfc_tgt, u8 *tgt_data, - int tgt_data_len) -{ - struct pn533_target_type_b *tgt_type_b; - - tgt_type_b = (struct pn533_target_type_b *) tgt_data; - - if (!pn533_target_type_b_is_valid(tgt_type_b, tgt_data_len)) - return -EPROTO; - - nfc_tgt->supported_protocols = NFC_PROTO_ISO14443_MASK; - - return 0; -} - -struct pn533_poll_response { - u8 nbtg; - u8 tg; - u8 target_data[]; -} __packed; - -static int pn533_target_found(struct pn533 *dev, - struct pn533_poll_response *resp, int resp_len) -{ - int target_data_len; - struct nfc_target nfc_tgt; - int rc; - - nfc_dev_dbg(&dev->interface->dev, "%s - modulation=%d", __func__, - dev->poll_mod_curr); - - if (resp->tg != 1) - return -EPROTO; - - target_data_len = resp_len - sizeof(struct pn533_poll_response); - - switch (dev->poll_mod_curr) { - case PN533_POLL_MOD_106KBPS_A: - rc = pn533_target_found_type_a(&nfc_tgt, resp->target_data, - target_data_len); - break; - case PN533_POLL_MOD_212KBPS_FELICA: - case PN533_POLL_MOD_424KBPS_FELICA: - rc = pn533_target_found_felica(&nfc_tgt, resp->target_data, - target_data_len); - break; - case PN533_POLL_MOD_106KBPS_JEWEL: - rc = pn533_target_found_jewel(&nfc_tgt, resp->target_data, - target_data_len); - break; - case PN533_POLL_MOD_847KBPS_B: - rc = pn533_target_found_type_b(&nfc_tgt, resp->target_data, - target_data_len); - break; - default: - nfc_dev_err(&dev->interface->dev, "Unknown current poll" - " modulation"); - return -EPROTO; - } - - if (rc) - return rc; - - if (!(nfc_tgt.supported_protocols & dev->poll_protocols)) { - nfc_dev_dbg(&dev->interface->dev, "The target found does not" - " have the desired protocol"); - return -EAGAIN; - } - - nfc_dev_dbg(&dev->interface->dev, "Target found - supported protocols: " - "0x%x", nfc_tgt.supported_protocols); - - dev->tgt_available_prots = nfc_tgt.supported_protocols; - - nfc_targets_found(dev->nfc_dev, &nfc_tgt, 1); - - return 0; -} - -static void pn533_poll_reset_mod_list(struct pn533 *dev) -{ - dev->poll_mod_count = 0; -} - -static void pn533_poll_add_mod(struct pn533 *dev, u8 mod_index) -{ - dev->poll_mod_active[dev->poll_mod_count] = - (struct pn533_poll_modulations *) &poll_mod[mod_index]; - dev->poll_mod_count++; -} - -static void pn533_poll_create_mod_list(struct pn533 *dev, u32 protocols) -{ - pn533_poll_reset_mod_list(dev); - - if (protocols & NFC_PROTO_MIFARE_MASK - || protocols & NFC_PROTO_ISO14443_MASK - || protocols & NFC_PROTO_NFC_DEP_MASK) - pn533_poll_add_mod(dev, PN533_POLL_MOD_106KBPS_A); - - if (protocols & NFC_PROTO_FELICA_MASK - || protocols & NFC_PROTO_NFC_DEP_MASK) { - pn533_poll_add_mod(dev, PN533_POLL_MOD_212KBPS_FELICA); - pn533_poll_add_mod(dev, PN533_POLL_MOD_424KBPS_FELICA); - } - - if (protocols & NFC_PROTO_JEWEL_MASK) - pn533_poll_add_mod(dev, PN533_POLL_MOD_106KBPS_JEWEL); - - if (protocols & NFC_PROTO_ISO14443_MASK) - pn533_poll_add_mod(dev, PN533_POLL_MOD_847KBPS_B); -} - -static void pn533_start_poll_frame(struct pn533_frame *frame, - struct pn533_poll_modulations *mod) -{ - - pn533_tx_frame_init(frame, PN533_CMD_IN_LIST_PASSIVE_TARGET); - - memcpy(PN533_FRAME_CMD_PARAMS_PTR(frame), &mod->data, mod->len); - frame->datalen += mod->len; - - pn533_tx_frame_finish(frame); -} - -static int pn533_start_poll_complete(struct pn533 *dev, void *arg, - u8 *params, int params_len) -{ - struct pn533_poll_response *resp; - struct pn533_poll_modulations *next_mod; - int rc; - - nfc_dev_dbg(&dev->interface->dev, "%s", __func__); - - if (params_len == -ENOENT) { - nfc_dev_dbg(&dev->interface->dev, "Polling operation has been" - " stopped"); - goto stop_poll; - } - - if (params_len < 0) { - nfc_dev_err(&dev->interface->dev, "Error %d when running poll", - params_len); - goto stop_poll; - } - - resp = (struct pn533_poll_response *) params; - if (resp->nbtg) { - rc = pn533_target_found(dev, resp, params_len); - - /* We must stop the poll after a valid target found */ - if (rc == 0) - goto stop_poll; - - if (rc != -EAGAIN) - nfc_dev_err(&dev->interface->dev, "The target found is" - " not valid - continuing to poll"); - } - - dev->poll_mod_curr = (dev->poll_mod_curr + 1) % dev->poll_mod_count; - - next_mod = dev->poll_mod_active[dev->poll_mod_curr]; - - nfc_dev_dbg(&dev->interface->dev, "Polling next modulation (0x%x)", - dev->poll_mod_curr); - - pn533_start_poll_frame(dev->out_frame, next_mod); - - /* Don't need to down the semaphore again */ - rc = __pn533_send_cmd_frame_async(dev, dev->out_frame, dev->in_frame, - dev->in_maxlen, pn533_start_poll_complete, - NULL, GFP_ATOMIC); - - if (rc == -EPERM) { - nfc_dev_dbg(&dev->interface->dev, "Cannot poll next modulation" - " because poll has been stopped"); - goto stop_poll; - } - - if (rc) { - nfc_dev_err(&dev->interface->dev, "Error %d when trying to poll" - " next modulation", rc); - goto stop_poll; - } - - /* Inform caller function to do not up the semaphore */ - return -EINPROGRESS; - -stop_poll: - pn533_poll_reset_mod_list(dev); - dev->poll_protocols = 0; - return 0; -} - -static int pn533_start_poll(struct nfc_dev *nfc_dev, u32 protocols) -{ - struct pn533 *dev = nfc_get_drvdata(nfc_dev); - struct pn533_poll_modulations *start_mod; - int rc; - - nfc_dev_dbg(&dev->interface->dev, "%s - protocols=0x%x", __func__, - protocols); - - if (dev->poll_mod_count) { - nfc_dev_err(&dev->interface->dev, "Polling operation already" - " active"); - return -EBUSY; - } - - if (dev->tgt_active_prot) { - nfc_dev_err(&dev->interface->dev, "Cannot poll with a target" - " already activated"); - return -EBUSY; - } - - pn533_poll_create_mod_list(dev, protocols); - - if (!dev->poll_mod_count) { - nfc_dev_err(&dev->interface->dev, "No valid protocols" - " specified"); - rc = -EINVAL; - goto error; - } - - nfc_dev_dbg(&dev->interface->dev, "It will poll %d modulations types", - dev->poll_mod_count); - - dev->poll_mod_curr = 0; - start_mod = dev->poll_mod_active[dev->poll_mod_curr]; - - pn533_start_poll_frame(dev->out_frame, start_mod); - - rc = pn533_send_cmd_frame_async(dev, dev->out_frame, dev->in_frame, - dev->in_maxlen, pn533_start_poll_complete, - NULL, GFP_KERNEL); - - if (rc) { - nfc_dev_err(&dev->interface->dev, "Error %d when trying to" - " start poll", rc); - goto error; - } - - dev->poll_protocols = protocols; - - return 0; - -error: - pn533_poll_reset_mod_list(dev); - return rc; -} - -static void pn533_stop_poll(struct nfc_dev *nfc_dev) -{ - struct pn533 *dev = nfc_get_drvdata(nfc_dev); - - nfc_dev_dbg(&dev->interface->dev, "%s", __func__); - - if (!dev->poll_mod_count) { - nfc_dev_dbg(&dev->interface->dev, "Polling operation was not" - " running"); - return; - } - - /* An ack will cancel the last issued command (poll) */ - pn533_send_ack(dev, GFP_KERNEL); - - /* prevent pn533_start_poll_complete to issue a new poll meanwhile */ - usb_kill_urb(dev->in_urb); -} - -static int pn533_activate_target_nfcdep(struct pn533 *dev) -{ - struct pn533_cmd_activate_param param; - struct pn533_cmd_activate_response *resp; - int rc; - - nfc_dev_dbg(&dev->interface->dev, "%s", __func__); - - pn533_tx_frame_init(dev->out_frame, PN533_CMD_IN_ATR); - - param.tg = 1; - param.next = 0; - memcpy(PN533_FRAME_CMD_PARAMS_PTR(dev->out_frame), ¶m, - sizeof(struct pn533_cmd_activate_param)); - dev->out_frame->datalen += sizeof(struct pn533_cmd_activate_param); - - pn533_tx_frame_finish(dev->out_frame); - - rc = pn533_send_cmd_frame_sync(dev, dev->out_frame, dev->in_frame, - dev->in_maxlen); - if (rc) - return rc; - - resp = (struct pn533_cmd_activate_response *) - PN533_FRAME_CMD_PARAMS_PTR(dev->in_frame); - rc = resp->status & PN533_CMD_RET_MASK; - if (rc != PN533_CMD_RET_SUCCESS) - return -EIO; - - return 0; -} - -static int pn533_activate_target(struct nfc_dev *nfc_dev, u32 target_idx, - u32 protocol) -{ - struct pn533 *dev = nfc_get_drvdata(nfc_dev); - int rc; - - nfc_dev_dbg(&dev->interface->dev, "%s - protocol=%u", __func__, - protocol); - - if (dev->poll_mod_count) { - nfc_dev_err(&dev->interface->dev, "Cannot activate while" - " polling"); - return -EBUSY; - } - - if (dev->tgt_active_prot) { - nfc_dev_err(&dev->interface->dev, "There is already an active" - " target"); - return -EBUSY; - } - - if (!dev->tgt_available_prots) { - nfc_dev_err(&dev->interface->dev, "There is no available target" - " to activate"); - return -EINVAL; - } - - if (!(dev->tgt_available_prots & (1 << protocol))) { - nfc_dev_err(&dev->interface->dev, "The target does not support" - " the requested protocol %u", protocol); - return -EINVAL; - } - - if (protocol == NFC_PROTO_NFC_DEP) { - rc = pn533_activate_target_nfcdep(dev); - if (rc) { - nfc_dev_err(&dev->interface->dev, "Error %d when" - " activating target with" - " NFC_DEP protocol", rc); - return rc; - } - } - - dev->tgt_active_prot = protocol; - dev->tgt_available_prots = 0; - - return 0; -} - -static void pn533_deactivate_target(struct nfc_dev *nfc_dev, u32 target_idx) -{ - struct pn533 *dev = nfc_get_drvdata(nfc_dev); - u8 tg; - u8 status; - int rc; - - nfc_dev_dbg(&dev->interface->dev, "%s", __func__); - - if (!dev->tgt_active_prot) { - nfc_dev_err(&dev->interface->dev, "There is no active target"); - return; - } - - dev->tgt_active_prot = 0; - - pn533_tx_frame_init(dev->out_frame, PN533_CMD_IN_RELEASE); - - tg = 1; - memcpy(PN533_FRAME_CMD_PARAMS_PTR(dev->out_frame), &tg, sizeof(u8)); - dev->out_frame->datalen += sizeof(u8); - - pn533_tx_frame_finish(dev->out_frame); - - rc = pn533_send_cmd_frame_sync(dev, dev->out_frame, dev->in_frame, - dev->in_maxlen); - if (rc) { - nfc_dev_err(&dev->interface->dev, "Error when sending release" - " command to the controller"); - return; - } - - status = PN533_FRAME_CMD_PARAMS_PTR(dev->in_frame)[0]; - rc = status & PN533_CMD_RET_MASK; - if (rc != PN533_CMD_RET_SUCCESS) - nfc_dev_err(&dev->interface->dev, "Error 0x%x when releasing" - " the target", rc); - - return; -} - -#define PN533_CMD_DATAEXCH_HEAD_LEN (sizeof(struct pn533_frame) + 3) -#define PN533_CMD_DATAEXCH_DATA_MAXLEN 262 - -static int pn533_data_exchange_tx_frame(struct pn533 *dev, struct sk_buff *skb) -{ - int payload_len = skb->len; - struct pn533_frame *out_frame; - struct sk_buff *discarded; - u8 tg; - - nfc_dev_dbg(&dev->interface->dev, "%s - Sending %d bytes", __func__, - payload_len); - - if (payload_len > PN533_CMD_DATAEXCH_DATA_MAXLEN) { - /* TODO: Implement support to multi-part data exchange */ - nfc_dev_err(&dev->interface->dev, "Data length greater than the" - " max allowed: %d", - PN533_CMD_DATAEXCH_DATA_MAXLEN); - return -ENOSYS; - } - - /* Reserving header space */ - if (skb_cow_head(skb, PN533_CMD_DATAEXCH_HEAD_LEN)) { - nfc_dev_err(&dev->interface->dev, "Error to add header data"); - return -ENOMEM; - } - - /* Reserving tail space, see pn533_tx_frame_finish */ - if (skb_cow_data(skb, PN533_FRAME_TAIL_SIZE, &discarded) < 0) { - nfc_dev_err(&dev->interface->dev, "Error to add tail data"); - return -ENOMEM; - } - - skb_push(skb, PN533_CMD_DATAEXCH_HEAD_LEN); - out_frame = (struct pn533_frame *) skb->data; - - pn533_tx_frame_init(out_frame, PN533_CMD_IN_DATA_EXCHANGE); - - tg = 1; - memcpy(PN533_FRAME_CMD_PARAMS_PTR(out_frame), &tg, sizeof(u8)); - out_frame->datalen += sizeof(u8); - - /* The data is already in the out_frame, just update the datalen */ - out_frame->datalen += payload_len; - - pn533_tx_frame_finish(out_frame); - skb_put(skb, PN533_FRAME_TAIL_SIZE); - - return 0; -} - -struct pn533_data_exchange_arg { - struct sk_buff *skb_resp; - struct sk_buff *skb_out; - data_exchange_cb_t cb; - void *cb_context; -}; - -static int pn533_data_exchange_complete(struct pn533 *dev, void *_arg, - u8 *params, int params_len) -{ - struct pn533_data_exchange_arg *arg = _arg; - struct sk_buff *skb_resp = arg->skb_resp; - struct pn533_frame *in_frame = (struct pn533_frame *) skb_resp->data; - int err = 0; - u8 status; - u8 cmd_ret; - - nfc_dev_dbg(&dev->interface->dev, "%s", __func__); - - dev_kfree_skb_irq(arg->skb_out); - - if (params_len < 0) { /* error */ - err = params_len; - goto error; - } - - skb_put(skb_resp, PN533_FRAME_SIZE(in_frame)); - - status = params[0]; - - cmd_ret = status & PN533_CMD_RET_MASK; - if (cmd_ret != PN533_CMD_RET_SUCCESS) { - nfc_dev_err(&dev->interface->dev, "PN533 reported error %d when" - " exchanging data", cmd_ret); - err = -EIO; - goto error; - } - - if (status & PN533_CMD_MI_MASK) { - /* TODO: Implement support to multi-part data exchange */ - nfc_dev_err(&dev->interface->dev, "Multi-part message not yet" - " supported"); - /* Prevent the other messages from controller */ - pn533_send_ack(dev, GFP_ATOMIC); - err = -ENOSYS; - goto error; - } - - skb_pull(skb_resp, PN533_CMD_DATAEXCH_HEAD_LEN); - skb_trim(skb_resp, skb_resp->len - PN533_FRAME_TAIL_SIZE); - - arg->cb(arg->cb_context, skb_resp, 0); - kfree(arg); - return 0; - -error: - dev_kfree_skb_irq(skb_resp); - arg->cb(arg->cb_context, NULL, err); - kfree(arg); - return 0; -} - -int pn533_data_exchange(struct nfc_dev *nfc_dev, u32 target_idx, - struct sk_buff *skb, - data_exchange_cb_t cb, - void *cb_context) -{ - struct pn533 *dev = nfc_get_drvdata(nfc_dev); - struct pn533_frame *out_frame, *in_frame; - struct pn533_data_exchange_arg *arg; - struct sk_buff *skb_resp; - int skb_resp_len; - int rc; - - nfc_dev_dbg(&dev->interface->dev, "%s", __func__); - - if (!dev->tgt_active_prot) { - nfc_dev_err(&dev->interface->dev, "Cannot exchange data if" - " there is no active target"); - rc = -EINVAL; - goto error; - } - - rc = pn533_data_exchange_tx_frame(dev, skb); - if (rc) - goto error; - - skb_resp_len = PN533_CMD_DATAEXCH_HEAD_LEN + - PN533_CMD_DATAEXCH_DATA_MAXLEN + - PN533_FRAME_TAIL_SIZE; - - skb_resp = nfc_alloc_skb(skb_resp_len, GFP_KERNEL); - if (!skb_resp) { - rc = -ENOMEM; - goto error; - } - - in_frame = (struct pn533_frame *) skb_resp->data; - out_frame = (struct pn533_frame *) skb->data; - - arg = kmalloc(sizeof(struct pn533_data_exchange_arg), GFP_KERNEL); - if (!arg) { - rc = -ENOMEM; - goto free_skb_resp; - } - - arg->skb_resp = skb_resp; - arg->skb_out = skb; - arg->cb = cb; - arg->cb_context = cb_context; - - rc = pn533_send_cmd_frame_async(dev, out_frame, in_frame, skb_resp_len, - pn533_data_exchange_complete, arg, - GFP_KERNEL); - if (rc) { - nfc_dev_err(&dev->interface->dev, "Error %d when trying to" - " perform data_exchange", rc); - goto free_arg; - } - - return 0; - -free_arg: - kfree(arg); -free_skb_resp: - kfree_skb(skb_resp); -error: - kfree_skb(skb); - return rc; -} - -static int pn533_set_configuration(struct pn533 *dev, u8 cfgitem, u8 *cfgdata, - u8 cfgdata_len) -{ - int rc; - u8 *params; - - nfc_dev_dbg(&dev->interface->dev, "%s", __func__); - - pn533_tx_frame_init(dev->out_frame, PN533_CMD_RF_CONFIGURATION); - - params = PN533_FRAME_CMD_PARAMS_PTR(dev->out_frame); - params[0] = cfgitem; - memcpy(¶ms[1], cfgdata, cfgdata_len); - dev->out_frame->datalen += (1 + cfgdata_len); - - pn533_tx_frame_finish(dev->out_frame); - - rc = pn533_send_cmd_frame_sync(dev, dev->out_frame, dev->in_frame, - dev->in_maxlen); - - return rc; -} - -struct nfc_ops pn533_nfc_ops = { - .start_poll = pn533_start_poll, - .stop_poll = pn533_stop_poll, - .activate_target = pn533_activate_target, - .deactivate_target = pn533_deactivate_target, - .data_exchange = pn533_data_exchange, -}; - -static int pn533_probe(struct usb_interface *interface, - const struct usb_device_id *id) -{ - struct pn533_fw_version *fw_ver; - struct pn533 *dev; - struct usb_host_interface *iface_desc; - struct usb_endpoint_descriptor *endpoint; - struct pn533_config_max_retries max_retries; - int in_endpoint = 0; - int out_endpoint = 0; - int rc = -ENOMEM; - int i; - u32 protocols; - - dev = kzalloc(sizeof(*dev), GFP_KERNEL); - if (!dev) - return -ENOMEM; - - dev->udev = usb_get_dev(interface_to_usbdev(interface)); - dev->interface = interface; - sema_init(&dev->cmd_lock, 1); - - iface_desc = interface->cur_altsetting; - for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) { - endpoint = &iface_desc->endpoint[i].desc; - - if (!in_endpoint && usb_endpoint_is_bulk_in(endpoint)) { - dev->in_maxlen = le16_to_cpu(endpoint->wMaxPacketSize); - in_endpoint = endpoint->bEndpointAddress; - } - - if (!out_endpoint && usb_endpoint_is_bulk_out(endpoint)) { - dev->out_maxlen = - le16_to_cpu(endpoint->wMaxPacketSize); - out_endpoint = endpoint->bEndpointAddress; - } - } - - if (!in_endpoint || !out_endpoint) { - nfc_dev_err(&interface->dev, "Could not find bulk-in or" - " bulk-out endpoint"); - rc = -ENODEV; - goto error; - } - - dev->in_frame = kmalloc(dev->in_maxlen, GFP_KERNEL); - dev->in_urb = usb_alloc_urb(0, GFP_KERNEL); - dev->out_frame = kmalloc(dev->out_maxlen, GFP_KERNEL); - dev->out_urb = usb_alloc_urb(0, GFP_KERNEL); - - if (!dev->in_frame || !dev->out_frame || - !dev->in_urb || !dev->out_urb) - goto error; - - usb_fill_bulk_urb(dev->in_urb, dev->udev, - usb_rcvbulkpipe(dev->udev, in_endpoint), - NULL, 0, NULL, dev); - usb_fill_bulk_urb(dev->out_urb, dev->udev, - usb_sndbulkpipe(dev->udev, out_endpoint), - NULL, 0, - pn533_send_complete, dev); - - tasklet_init(&dev->tasklet, pn533_tasklet_cmd_complete, (ulong)dev); - - usb_set_intfdata(interface, dev); - - pn533_tx_frame_init(dev->out_frame, PN533_CMD_GET_FIRMWARE_VERSION); - pn533_tx_frame_finish(dev->out_frame); - - rc = pn533_send_cmd_frame_sync(dev, dev->out_frame, dev->in_frame, - dev->in_maxlen); - if (rc) - goto kill_tasklet; - - fw_ver = (struct pn533_fw_version *) - PN533_FRAME_CMD_PARAMS_PTR(dev->in_frame); - nfc_dev_info(&dev->interface->dev, "NXP PN533 firmware ver %d.%d now" - " attached", fw_ver->ver, fw_ver->rev); - - protocols = NFC_PROTO_JEWEL_MASK - | NFC_PROTO_MIFARE_MASK | NFC_PROTO_FELICA_MASK - | NFC_PROTO_ISO14443_MASK - | NFC_PROTO_NFC_DEP_MASK; - - dev->nfc_dev = nfc_allocate_device(&pn533_nfc_ops, protocols); - if (!dev->nfc_dev) - goto kill_tasklet; - - nfc_set_parent_dev(dev->nfc_dev, &interface->dev); - nfc_set_drvdata(dev->nfc_dev, dev); - - rc = nfc_register_device(dev->nfc_dev); - if (rc) - goto free_nfc_dev; - - max_retries.mx_rty_atr = PN533_CONFIG_MAX_RETRIES_ENDLESS; - max_retries.mx_rty_psl = 2; - max_retries.mx_rty_passive_act = PN533_CONFIG_MAX_RETRIES_NO_RETRY; - - rc = pn533_set_configuration(dev, PN533_CFGITEM_MAX_RETRIES, - (u8 *) &max_retries, sizeof(max_retries)); - - if (rc) { - nfc_dev_err(&dev->interface->dev, "Error on setting MAX_RETRIES" - " config"); - goto free_nfc_dev; - } - - return 0; - -free_nfc_dev: - nfc_free_device(dev->nfc_dev); -kill_tasklet: - tasklet_kill(&dev->tasklet); -error: - kfree(dev->in_frame); - usb_free_urb(dev->in_urb); - kfree(dev->out_frame); - usb_free_urb(dev->out_urb); - kfree(dev); - return rc; -} - -static void pn533_disconnect(struct usb_interface *interface) -{ - struct pn533 *dev; - - dev = usb_get_intfdata(interface); - usb_set_intfdata(interface, NULL); - - nfc_unregister_device(dev->nfc_dev); - nfc_free_device(dev->nfc_dev); - - usb_kill_urb(dev->in_urb); - usb_kill_urb(dev->out_urb); - - tasklet_kill(&dev->tasklet); - - kfree(dev->in_frame); - usb_free_urb(dev->in_urb); - kfree(dev->out_frame); - usb_free_urb(dev->out_urb); - kfree(dev); - - nfc_dev_info(&dev->interface->dev, "NXP PN533 NFC device disconnected"); -} - -static struct usb_driver pn533_driver = { - .name = "pn533", - .probe = pn533_probe, - .disconnect = pn533_disconnect, - .id_table = pn533_table, -}; - -static int __init pn533_init(void) -{ - int rc; - - rc = usb_register(&pn533_driver); - if (rc) - err("usb_register failed. Error number %d", rc); - - return rc; -} - -static void __exit pn533_exit(void) -{ - usb_deregister(&pn533_driver); -} - -module_init(pn533_init); -module_exit(pn533_exit); - -MODULE_AUTHOR("Lauro Ramos Venancio ," - " Aloisio Almeida Jr "); -MODULE_DESCRIPTION("PN533 usb driver ver " VERSION); -MODULE_VERSION(VERSION); -MODULE_LICENSE("GPL"); diff --git a/trunk/drivers/pci/pci-driver.c b/trunk/drivers/pci/pci-driver.c index 46767c53917a..135df164a4c1 100644 --- a/trunk/drivers/pci/pci-driver.c +++ b/trunk/drivers/pci/pci-driver.c @@ -624,7 +624,7 @@ static int pci_pm_prepare(struct device *dev) * system from the sleep state, we'll have to prevent it from signaling * wake-up. */ - pm_runtime_get_sync(dev); + pm_runtime_resume(dev); if (drv && drv->pm && drv->pm->prepare) error = drv->pm->prepare(dev); @@ -638,8 +638,6 @@ static void pci_pm_complete(struct device *dev) if (drv && drv->pm && drv->pm->complete) drv->pm->complete(dev); - - pm_runtime_put_sync(dev); } #else /* !CONFIG_PM_SLEEP */ diff --git a/trunk/drivers/pci/pci.c b/trunk/drivers/pci/pci.c index 692671b11667..5f10c23dff94 100644 --- a/trunk/drivers/pci/pci.c +++ b/trunk/drivers/pci/pci.c @@ -3284,7 +3284,7 @@ static int pci_set_vga_state_arch(struct pci_dev *dev, bool decode, * @dev: the PCI device * @decode: true = enable decoding, false = disable decoding * @command_bits: PCI_COMMAND_IO and/or PCI_COMMAND_MEMORY - * @flags: traverse ancestors and change bridges + * @change_bridge_flags: traverse ancestors and change bridges * CHANGE_BRIDGE_ONLY / CHANGE_BRIDGE */ int pci_set_vga_state(struct pci_dev *dev, bool decode, @@ -3483,8 +3483,6 @@ static int __init pci_setup(char *str) pci_no_msi(); } else if (!strcmp(str, "noaer")) { pci_no_aer(); - } else if (!strncmp(str, "realloc", 7)) { - pci_realloc(); } else if (!strcmp(str, "nodomains")) { pci_no_domains(); } else if (!strncmp(str, "cbiosize=", 9)) { diff --git a/trunk/drivers/pci/pci.h b/trunk/drivers/pci/pci.h index 3a39bf1f1e2c..731e20265ace 100644 --- a/trunk/drivers/pci/pci.h +++ b/trunk/drivers/pci/pci.h @@ -146,8 +146,6 @@ static inline void pci_no_msi(void) { } static inline void pci_msi_init_pci_dev(struct pci_dev *dev) { } #endif -extern void pci_realloc(void); - static inline int pci_no_d1d2(struct pci_dev *dev) { unsigned int parent_dstates = 0; diff --git a/trunk/drivers/pci/probe.c b/trunk/drivers/pci/probe.c index bafb3c3d4a89..48849ffdd672 100644 --- a/trunk/drivers/pci/probe.c +++ b/trunk/drivers/pci/probe.c @@ -168,7 +168,7 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type, res->flags |= pci_calc_resource_flags(l) | IORESOURCE_SIZEALIGN; if (type == pci_bar_io) { l &= PCI_BASE_ADDRESS_IO_MASK; - mask = PCI_BASE_ADDRESS_IO_MASK & (u32) IO_SPACE_LIMIT; + mask = PCI_BASE_ADDRESS_IO_MASK & IO_SPACE_LIMIT; } else { l &= PCI_BASE_ADDRESS_MEM_MASK; mask = (u32)PCI_BASE_ADDRESS_MEM_MASK; diff --git a/trunk/drivers/pci/quirks.c b/trunk/drivers/pci/quirks.c index 02145e9697a9..e8a140669f90 100644 --- a/trunk/drivers/pci/quirks.c +++ b/trunk/drivers/pci/quirks.c @@ -2761,8 +2761,6 @@ static void ricoh_mmc_fixup_r5c832(struct pci_dev *dev) } DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_R5C832, ricoh_mmc_fixup_r5c832); DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_R5C832, ricoh_mmc_fixup_r5c832); -DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_R5CE823, ricoh_mmc_fixup_r5c832); -DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_R5CE823, ricoh_mmc_fixup_r5c832); #endif /*CONFIG_MMC_RICOH_MMC*/ #if defined(CONFIG_DMAR) || defined(CONFIG_INTR_REMAP) diff --git a/trunk/drivers/pci/setup-bus.c b/trunk/drivers/pci/setup-bus.c index 9995842e45b5..1e9e5a5b8c81 100644 --- a/trunk/drivers/pci/setup-bus.c +++ b/trunk/drivers/pci/setup-bus.c @@ -47,13 +47,6 @@ struct resource_list_x { (head)->next = NULL; \ } while (0) -int pci_realloc_enable = 0; -#define pci_realloc_enabled() pci_realloc_enable -void pci_realloc(void) -{ - pci_realloc_enable = 1; -} - /** * add_to_list() - add a new resource tracker to the list * @head: Head of the list @@ -1032,7 +1025,6 @@ static int __init pci_get_max_depth(void) return depth; } - /* * first try will not touch pci bridge res * second and later try will clear small leaf bridge res @@ -1076,13 +1068,6 @@ pci_assign_unassigned_resources(void) /* any device complain? */ if (!head.next) goto enable_and_dump; - - /* don't realloc if asked to do so */ - if (!pci_realloc_enabled()) { - free_list(resource_list_x, &head); - goto enable_and_dump; - } - failed_type = 0; for (list = head.next; list;) { failed_type |= list->flags; diff --git a/trunk/drivers/pcmcia/pxa2xx_vpac270.c b/trunk/drivers/pcmcia/pxa2xx_vpac270.c index e956f659089a..712baab3c83d 100644 --- a/trunk/drivers/pcmcia/pxa2xx_vpac270.c +++ b/trunk/drivers/pcmcia/pxa2xx_vpac270.c @@ -76,10 +76,10 @@ static int vpac270_pcmcia_hw_init(struct soc_pcmcia_socket *skt) static void vpac270_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt) { if (skt->nr == 0) - gpio_free_array(vpac270_pcmcia_gpios, + gpio_request_array(vpac270_pcmcia_gpios, ARRAY_SIZE(vpac270_pcmcia_gpios)); else - gpio_free_array(vpac270_cf_gpios, + gpio_request_array(vpac270_cf_gpios, ARRAY_SIZE(vpac270_cf_gpios)); } diff --git a/trunk/drivers/platform/x86/acer-wmi.c b/trunk/drivers/platform/x86/acer-wmi.c index e1c4938b301b..005417bd429e 100644 --- a/trunk/drivers/platform/x86/acer-wmi.c +++ b/trunk/drivers/platform/x86/acer-wmi.c @@ -1156,9 +1156,9 @@ static acpi_status wmid3_set_device_status(u32 value, u16 device) struct wmid3_gds_input_param params = { .function_num = 0x1, .hotkey_number = 0x01, - .devices = ACER_WMID3_GDS_WIRELESS | - ACER_WMID3_GDS_THREEG | - ACER_WMID3_GDS_WIMAX | + .devices = ACER_WMID3_GDS_WIRELESS & + ACER_WMID3_GDS_THREEG & + ACER_WMID3_GDS_WIMAX & ACER_WMID3_GDS_BLUETOOTH, }; struct acpi_buffer input = { @@ -1445,8 +1445,6 @@ static void acer_wmi_notify(u32 value, void *context) union acpi_object *obj; struct event_return_value return_value; acpi_status status; - u16 device_state; - const struct key_entry *key; status = wmi_get_event_data(value, &response); if (status != AE_OK) { @@ -1474,32 +1472,23 @@ static void acer_wmi_notify(u32 value, void *context) switch (return_value.function) { case WMID_HOTKEY_EVENT: - device_state = return_value.device_state; - pr_debug("device state: 0x%x\n", device_state); - - key = sparse_keymap_entry_from_scancode(acer_wmi_input_dev, - return_value.key_num); - if (!key) { + if (return_value.device_state) { + u16 device_state = return_value.device_state; + pr_debug("device state: 0x%x\n", device_state); + if (has_cap(ACER_CAP_WIRELESS)) + rfkill_set_sw_state(wireless_rfkill, + !(device_state & ACER_WMID3_GDS_WIRELESS)); + if (has_cap(ACER_CAP_BLUETOOTH)) + rfkill_set_sw_state(bluetooth_rfkill, + !(device_state & ACER_WMID3_GDS_BLUETOOTH)); + if (has_cap(ACER_CAP_THREEG)) + rfkill_set_sw_state(threeg_rfkill, + !(device_state & ACER_WMID3_GDS_THREEG)); + } + if (!sparse_keymap_report_event(acer_wmi_input_dev, + return_value.key_num, 1, true)) pr_warn("Unknown key number - 0x%x\n", return_value.key_num); - } else { - switch (key->keycode) { - case KEY_WLAN: - case KEY_BLUETOOTH: - if (has_cap(ACER_CAP_WIRELESS)) - rfkill_set_sw_state(wireless_rfkill, - !(device_state & ACER_WMID3_GDS_WIRELESS)); - if (has_cap(ACER_CAP_THREEG)) - rfkill_set_sw_state(threeg_rfkill, - !(device_state & ACER_WMID3_GDS_THREEG)); - if (has_cap(ACER_CAP_BLUETOOTH)) - rfkill_set_sw_state(bluetooth_rfkill, - !(device_state & ACER_WMID3_GDS_BLUETOOTH)); - break; - } - sparse_keymap_report_entry(acer_wmi_input_dev, key, - 1, true); - } break; default: pr_warn("Unknown function number - %d - %d\n", diff --git a/trunk/drivers/platform/x86/asus-wmi.c b/trunk/drivers/platform/x86/asus-wmi.c index 3c7857c71a23..00460cb9587b 100644 --- a/trunk/drivers/platform/x86/asus-wmi.c +++ b/trunk/drivers/platform/x86/asus-wmi.c @@ -1025,7 +1025,6 @@ static int asus_wmi_backlight_init(struct asus_wmi *asus) return power; memset(&props, 0, sizeof(struct backlight_properties)); - props.type = BACKLIGHT_PLATFORM; props.max_brightness = max; bd = backlight_device_register(asus->driver->name, &asus->platform_device->dev, asus, diff --git a/trunk/drivers/platform/x86/compal-laptop.c b/trunk/drivers/platform/x86/compal-laptop.c index 8877b836d27c..3f204fde1b02 100644 --- a/trunk/drivers/platform/x86/compal-laptop.c +++ b/trunk/drivers/platform/x86/compal-laptop.c @@ -1030,10 +1030,8 @@ static int __devinit compal_probe(struct platform_device *pdev) initialize_fan_control_data(data); err = sysfs_create_group(&pdev->dev.kobj, &compal_attribute_group); - if (err) { - kfree(data); + if (err) return err; - } data->hwmon_dev = hwmon_device_register(&pdev->dev); if (IS_ERR(data->hwmon_dev)) { diff --git a/trunk/drivers/platform/x86/dell-laptop.c b/trunk/drivers/platform/x86/dell-laptop.c index e39ab1d3ed87..d3841de6a8cf 100644 --- a/trunk/drivers/platform/x86/dell-laptop.c +++ b/trunk/drivers/platform/x86/dell-laptop.c @@ -292,9 +292,12 @@ static int dell_rfkill_set(void *data, bool blocked) dell_send_request(buffer, 17, 11); /* If the hardware switch controls this radio, and the hardware - switch is disabled, don't allow changing the software state */ + switch is disabled, don't allow changing the software state. + If the hardware switch is reported as not supported, always + fire the SMI to toggle the killswitch. */ if ((hwswitch_state & BIT(hwswitch_bit)) && - !(buffer->output[1] & BIT(16))) { + !(buffer->output[1] & BIT(16)) && + (buffer->output[1] & BIT(0))) { ret = -EINVAL; goto out; } @@ -400,6 +403,23 @@ static const struct file_operations dell_debugfs_fops = { static void dell_update_rfkill(struct work_struct *ignored) { + int status; + + get_buffer(); + dell_send_request(buffer, 17, 11); + status = buffer->output[1]; + release_buffer(); + + /* if hardware rfkill is not supported, set it explicitly */ + if (!(status & BIT(0))) { + if (wifi_rfkill) + dell_rfkill_set((void *)1, !((status & BIT(17)) >> 17)); + if (bluetooth_rfkill) + dell_rfkill_set((void *)2, !((status & BIT(18)) >> 18)); + if (wwan_rfkill) + dell_rfkill_set((void *)3, !((status & BIT(19)) >> 19)); + } + if (wifi_rfkill) dell_rfkill_query(wifi_rfkill, (void *)1); if (bluetooth_rfkill) @@ -540,11 +560,11 @@ static int dell_get_intensity(struct backlight_device *bd) else dell_send_request(buffer, 0, 1); - ret = buffer->output[1]; - out: release_buffer(); - return ret; + if (ret) + return ret; + return buffer->output[1]; } static const struct backlight_ops dell_ops = { diff --git a/trunk/drivers/platform/x86/hp-wmi.c b/trunk/drivers/platform/x86/hp-wmi.c index e2faa3cbb792..f94017bcdd6e 100644 --- a/trunk/drivers/platform/x86/hp-wmi.c +++ b/trunk/drivers/platform/x86/hp-wmi.c @@ -207,7 +207,6 @@ static int hp_wmi_perform_query(int query, int write, void *buffer, }; struct acpi_buffer input = { sizeof(struct bios_args), &args }; struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL }; - u32 rc; if (WARN_ON(insize > sizeof(args.data))) return -EINVAL; @@ -225,13 +224,13 @@ static int hp_wmi_perform_query(int query, int write, void *buffer, } bios_return = (struct bios_return *)obj->buffer.pointer; - rc = bios_return->return_code; - if (rc) { - if (rc != HPWMI_RET_UNKNOWN_CMDTYPE) - pr_warn("query 0x%x returned error 0x%x\n", query, rc); + if (bios_return->return_code) { + if (bios_return->return_code != HPWMI_RET_UNKNOWN_CMDTYPE) + pr_warn("query 0x%x returned error 0x%x\n", + query, bios_return->return_code); kfree(obj); - return rc; + return bios_return->return_code; } if (!outsize) { diff --git a/trunk/drivers/platform/x86/intel_oaktrail.c b/trunk/drivers/platform/x86/intel_oaktrail.c index 7f88c7923fc6..e936364a609d 100644 --- a/trunk/drivers/platform/x86/intel_oaktrail.c +++ b/trunk/drivers/platform/x86/intel_oaktrail.c @@ -250,7 +250,6 @@ static int oaktrail_backlight_init(void) struct backlight_properties props; memset(&props, 0, sizeof(struct backlight_properties)); - props.type = BACKLIGHT_PLATFORM; props.max_brightness = OT_EC_BL_BRIGHTNESS_MAX; bd = backlight_device_register(DRIVER_NAME, &oaktrail_device->dev, NULL, diff --git a/trunk/drivers/platform/x86/thinkpad_acpi.c b/trunk/drivers/platform/x86/thinkpad_acpi.c index 26c5b117df22..77f6e707a2a9 100644 --- a/trunk/drivers/platform/x86/thinkpad_acpi.c +++ b/trunk/drivers/platform/x86/thinkpad_acpi.c @@ -184,10 +184,6 @@ enum tpacpi_hkey_event_t { /* Misc bay events */ TP_HKEY_EV_OPTDRV_EJ = 0x3006, /* opt. drive tray ejected */ - TP_HKEY_EV_HOTPLUG_DOCK = 0x4010, /* docked into hotplug dock - or port replicator */ - TP_HKEY_EV_HOTPLUG_UNDOCK = 0x4011, /* undocked from hotplug - dock or port replicator */ /* User-interface events */ TP_HKEY_EV_LID_CLOSE = 0x5001, /* laptop lid closed */ @@ -198,10 +194,6 @@ enum tpacpi_hkey_event_t { TP_HKEY_EV_PEN_REMOVED = 0x500c, /* tablet pen removed */ TP_HKEY_EV_BRGHT_CHANGED = 0x5010, /* backlight control event */ - /* Key-related user-interface events */ - TP_HKEY_EV_KEY_NUMLOCK = 0x6000, /* NumLock key pressed */ - TP_HKEY_EV_KEY_FN = 0x6005, /* Fn key pressed? E420 */ - /* Thermal events */ TP_HKEY_EV_ALARM_BAT_HOT = 0x6011, /* battery too hot */ TP_HKEY_EV_ALARM_BAT_XHOT = 0x6012, /* battery critically hot */ @@ -209,10 +201,6 @@ enum tpacpi_hkey_event_t { TP_HKEY_EV_ALARM_SENSOR_XHOT = 0x6022, /* sensor critically hot */ TP_HKEY_EV_THM_TABLE_CHANGED = 0x6030, /* thermal table changed */ - TP_HKEY_EV_UNK_6040 = 0x6040, /* Related to AC change? - some sort of APM hint, - W520 */ - /* Misc */ TP_HKEY_EV_RFKILL_CHANGED = 0x7000, /* rfkill switch changed */ }; @@ -3525,34 +3513,6 @@ static bool hotkey_notify_wakeup(const u32 hkey, return true; } -static bool hotkey_notify_dockevent(const u32 hkey, - bool *send_acpi_ev, - bool *ignore_acpi_ev) -{ - /* 0x4000-0x4FFF: dock-related events */ - *send_acpi_ev = true; - *ignore_acpi_ev = false; - - switch (hkey) { - case TP_HKEY_EV_UNDOCK_ACK: - /* ACPI undock operation completed after wakeup */ - hotkey_autosleep_ack = 1; - pr_info("undocked\n"); - hotkey_wakeup_hotunplug_complete_notify_change(); - return true; - - case TP_HKEY_EV_HOTPLUG_DOCK: /* docked to port replicator */ - pr_info("docked into hotplug port replicator\n"); - return true; - case TP_HKEY_EV_HOTPLUG_UNDOCK: /* undocked from port replicator */ - pr_info("undocked from hotplug port replicator\n"); - return true; - - default: - return false; - } -} - static bool hotkey_notify_usrevent(const u32 hkey, bool *send_acpi_ev, bool *ignore_acpi_ev) @@ -3587,13 +3547,13 @@ static bool hotkey_notify_usrevent(const u32 hkey, static void thermal_dump_all_sensors(void); -static bool hotkey_notify_6xxx(const u32 hkey, +static bool hotkey_notify_thermal(const u32 hkey, bool *send_acpi_ev, bool *ignore_acpi_ev) { bool known = true; - /* 0x6000-0x6FFF: thermal alarms/notices and keyboard events */ + /* 0x6000-0x6FFF: thermal alarms */ *send_acpi_ev = true; *ignore_acpi_ev = false; @@ -3622,17 +3582,8 @@ static bool hotkey_notify_6xxx(const u32 hkey, "a sensor reports something is extremely hot!\n"); /* recommended action: immediate sleep/hibernate */ break; - - case TP_HKEY_EV_KEY_NUMLOCK: - case TP_HKEY_EV_KEY_FN: - /* key press events, we just ignore them as long as the EC - * is still reporting them in the normal keyboard stream */ - *send_acpi_ev = false; - *ignore_acpi_ev = true; - return true; - default: - pr_warn("unknown possible thermal alarm or keyboard event received\n"); + pr_alert("THERMAL ALERT: unknown thermal alarm received\n"); known = false; } @@ -3701,9 +3652,15 @@ static void hotkey_notify(struct ibm_struct *ibm, u32 event) } break; case 4: - /* 0x4000-0x4FFF: dock-related events */ - known_ev = hotkey_notify_dockevent(hkey, &send_acpi_ev, - &ignore_acpi_ev); + /* 0x4000-0x4FFF: dock-related wakeups */ + if (hkey == TP_HKEY_EV_UNDOCK_ACK) { + hotkey_autosleep_ack = 1; + pr_info("undocked\n"); + hotkey_wakeup_hotunplug_complete_notify_change(); + known_ev = true; + } else { + known_ev = false; + } break; case 5: /* 0x5000-0x5FFF: human interface helpers */ @@ -3711,9 +3668,8 @@ static void hotkey_notify(struct ibm_struct *ibm, u32 event) &ignore_acpi_ev); break; case 6: - /* 0x6000-0x6FFF: thermal alarms/notices and - * keyboard events */ - known_ev = hotkey_notify_6xxx(hkey, &send_acpi_ev, + /* 0x6000-0x6FFF: thermal alarms */ + known_ev = hotkey_notify_thermal(hkey, &send_acpi_ev, &ignore_acpi_ev); break; case 7: diff --git a/trunk/drivers/regulator/db8500-prcmu.c b/trunk/drivers/regulator/db8500-prcmu.c index 2bb8f451cc06..e5f7b8fe51f4 100644 --- a/trunk/drivers/regulator/db8500-prcmu.c +++ b/trunk/drivers/regulator/db8500-prcmu.c @@ -266,7 +266,7 @@ static struct regulator_ops db8500_regulator_switch_ops = { * Regulator information */ static struct db8500_regulator_info -db8500_regulator_info[DB8500_NUM_REGULATORS] = { + db8500_regulator_info[DB8500_NUM_REGULATORS] = { [DB8500_REGULATOR_VAPE] = { .desc = { .name = "db8500-vape", @@ -492,9 +492,11 @@ static int __devinit db8500_regulator_probe(struct platform_device *pdev) info->desc.name, err); /* if failing, unregister all earlier regulators */ - while (--i >= 0) { + i--; + while (i >= 0) { info = &db8500_regulator_info[i]; regulator_unregister(info->rdev); + i--; } return err; } @@ -534,7 +536,13 @@ static struct platform_driver db8500_regulator_driver = { static int __init db8500_regulator_init(void) { - return platform_driver_register(&db8500_regulator_driver); + int ret; + + ret = platform_driver_register(&db8500_regulator_driver); + if (ret < 0) + return -ENODEV; + + return 0; } static void __exit db8500_regulator_exit(void) diff --git a/trunk/drivers/regulator/max8952.c b/trunk/drivers/regulator/max8952.c index 486ed8141fcd..daff7fd0e95c 100644 --- a/trunk/drivers/regulator/max8952.c +++ b/trunk/drivers/regulator/max8952.c @@ -139,7 +139,7 @@ static int max8952_set_voltage(struct regulator_dev *rdev, s8 vid = -1, i; if (!gpio_is_valid(max8952->pdata->gpio_vid0) || - !gpio_is_valid(max8952->pdata->gpio_vid1)) { + !gpio_is_valid(max8952->pdata->gpio_vid0)) { /* DVS not supported */ return -EPERM; } diff --git a/trunk/drivers/regulator/max8997.c b/trunk/drivers/regulator/max8997.c index ad6628ca94f4..10d5a1d9768e 100644 --- a/trunk/drivers/regulator/max8997.c +++ b/trunk/drivers/regulator/max8997.c @@ -39,28 +39,25 @@ struct max8997_data { struct regulator_dev **rdev; int ramp_delay; /* in mV/us */ - bool buck1_gpiodvs; - bool buck2_gpiodvs; - bool buck5_gpiodvs; u8 buck1_vol[8]; u8 buck2_vol[8]; u8 buck5_vol[8]; - int buck125_gpios[3]; int buck125_gpioindex; - bool ignore_gpiodvs_side_effect; u8 saved_states[MAX8997_REG_MAX]; }; static inline void max8997_set_gpio(struct max8997_data *max8997) { + struct max8997_platform_data *pdata = + dev_get_platdata(max8997->iodev->dev); int set3 = (max8997->buck125_gpioindex) & 0x1; int set2 = ((max8997->buck125_gpioindex) >> 1) & 0x1; int set1 = ((max8997->buck125_gpioindex) >> 2) & 0x1; - gpio_set_value(max8997->buck125_gpios[0], set1); - gpio_set_value(max8997->buck125_gpios[1], set2); - gpio_set_value(max8997->buck125_gpios[2], set3); + gpio_set_value(pdata->buck125_gpios[0], set1); + gpio_set_value(pdata->buck125_gpios[1], set2); + gpio_set_value(pdata->buck125_gpios[2], set3); } struct voltage_map_desc { @@ -383,6 +380,8 @@ static int max8997_get_voltage_register(struct regulator_dev *rdev, static int max8997_get_voltage(struct regulator_dev *rdev) { struct max8997_data *max8997 = rdev_get_drvdata(rdev); + struct max8997_platform_data *pdata = + dev_get_platdata(max8997->iodev->dev); struct i2c_client *i2c = max8997->iodev->i2c; int reg, shift, mask, ret; int rid = max8997_get_rid(rdev); @@ -392,9 +391,9 @@ static int max8997_get_voltage(struct regulator_dev *rdev) if (ret) return ret; - if ((rid == MAX8997_BUCK1 && max8997->buck1_gpiodvs) || - (rid == MAX8997_BUCK2 && max8997->buck2_gpiodvs) || - (rid == MAX8997_BUCK5 && max8997->buck5_gpiodvs)) + if ((rid == MAX8997_BUCK1 && pdata->buck1_gpiodvs) || + (rid == MAX8997_BUCK2 && pdata->buck2_gpiodvs) || + (rid == MAX8997_BUCK5 && pdata->buck5_gpiodvs)) reg += max8997->buck125_gpioindex; ret = max8997_read_reg(i2c, reg, &val); @@ -544,8 +543,7 @@ static int max8997_set_voltage_ldobuck(struct regulator_dev *rdev, rid == MAX8997_BUCK4 || rid == MAX8997_BUCK5) { /* If the voltage is increasing */ if (org < i) - udelay(DIV_ROUND_UP(desc->step * (i - org), - max8997->ramp_delay)); + udelay(desc->step * (i - org) / max8997->ramp_delay); } return ret; @@ -563,6 +561,8 @@ static int max8997_assess_side_effect(struct regulator_dev *rdev, u8 new_val, int *best) { struct max8997_data *max8997 = rdev_get_drvdata(rdev); + struct max8997_platform_data *pdata = + dev_get_platdata(max8997->iodev->dev); int rid = max8997_get_rid(rdev); u8 *buckx_val[3]; bool buckx_gpiodvs[3]; @@ -589,9 +589,9 @@ static int max8997_assess_side_effect(struct regulator_dev *rdev, buckx_val[0] = max8997->buck1_vol; buckx_val[1] = max8997->buck2_vol; buckx_val[2] = max8997->buck5_vol; - buckx_gpiodvs[0] = max8997->buck1_gpiodvs; - buckx_gpiodvs[1] = max8997->buck2_gpiodvs; - buckx_gpiodvs[2] = max8997->buck5_gpiodvs; + buckx_gpiodvs[0] = pdata->buck1_gpiodvs; + buckx_gpiodvs[1] = pdata->buck2_gpiodvs; + buckx_gpiodvs[2] = pdata->buck5_gpiodvs; for (i = 0; i < 8; i++) { int others; @@ -640,6 +640,8 @@ static int max8997_set_voltage_buck(struct regulator_dev *rdev, int min_uV, int max_uV, unsigned *selector) { struct max8997_data *max8997 = rdev_get_drvdata(rdev); + struct max8997_platform_data *pdata = + dev_get_platdata(max8997->iodev->dev); int rid = max8997_get_rid(rdev); const struct voltage_map_desc *desc; int new_val, new_idx, damage, tmp_val, tmp_idx, tmp_dmg; @@ -651,15 +653,15 @@ static int max8997_set_voltage_buck(struct regulator_dev *rdev, switch (rid) { case MAX8997_BUCK1: - if (max8997->buck1_gpiodvs) + if (pdata->buck1_gpiodvs) gpio_dvs_mode = true; break; case MAX8997_BUCK2: - if (max8997->buck2_gpiodvs) + if (pdata->buck2_gpiodvs) gpio_dvs_mode = true; break; case MAX8997_BUCK5: - if (max8997->buck5_gpiodvs) + if (pdata->buck5_gpiodvs) gpio_dvs_mode = true; break; } @@ -693,7 +695,7 @@ static int max8997_set_voltage_buck(struct regulator_dev *rdev, new_idx = tmp_idx; new_val = tmp_val; - if (max8997->ignore_gpiodvs_side_effect == false) + if (pdata->ignore_gpiodvs_side_effect == false) return -EINVAL; dev_warn(&rdev->dev, "MAX8997 GPIO-DVS Side Effect Warning: GPIO SET:" @@ -991,11 +993,6 @@ static __devinit int max8997_pmic_probe(struct platform_device *pdev) i2c = max8997->iodev->i2c; max8997->buck125_gpioindex = pdata->buck125_default_idx; - max8997->buck1_gpiodvs = pdata->buck1_gpiodvs; - max8997->buck2_gpiodvs = pdata->buck2_gpiodvs; - max8997->buck5_gpiodvs = pdata->buck5_gpiodvs; - memcpy(max8997->buck125_gpios, pdata->buck125_gpios, sizeof(int) * 3); - max8997->ignore_gpiodvs_side_effect = pdata->ignore_gpiodvs_side_effect; for (i = 0; i < 8; i++) { max8997->buck1_vol[i] = ret = @@ -1127,10 +1124,6 @@ static __devinit int max8997_pmic_probe(struct platform_device *pdev) 0x3f); } - /* Misc Settings */ - max8997->ramp_delay = 10; /* set 10mV/us, which is the default */ - max8997_write_reg(i2c, MAX8997_REG_BUCKRAMP, (0xf << 4) | 0x9); - for (i = 0; i < pdata->num_regulators; i++) { const struct voltage_map_desc *desc; int id = pdata->regulators[i].id; @@ -1155,6 +1148,10 @@ static __devinit int max8997_pmic_probe(struct platform_device *pdev) } } + /* Misc Settings */ + max8997->ramp_delay = 10; /* set 10mV/us, which is the default */ + max8997_write_reg(i2c, MAX8997_REG_BUCKRAMP, (0xf << 4) | 0x9); + return 0; err: for (i = 0; i < max8997->num_regulators; i++) diff --git a/trunk/drivers/rtc/rtc-ds1307.c b/trunk/drivers/rtc/rtc-ds1307.c index b2005b44e4f7..4724ba3acf1a 100644 --- a/trunk/drivers/rtc/rtc-ds1307.c +++ b/trunk/drivers/rtc/rtc-ds1307.c @@ -149,7 +149,6 @@ static const struct i2c_device_id ds1307_id[] = { { "ds1340", ds_1340 }, { "ds3231", ds_3231 }, { "m41t00", m41t00 }, - { "pt7c4338", ds_1307 }, { "rx8025", rx_8025 }, { } }; diff --git a/trunk/drivers/rtc/rtc-vt8500.c b/trunk/drivers/rtc/rtc-vt8500.c index efd6066b5cd2..b8bc862903ae 100644 --- a/trunk/drivers/rtc/rtc-vt8500.c +++ b/trunk/drivers/rtc/rtc-vt8500.c @@ -78,6 +78,7 @@ struct vt8500_rtc { void __iomem *regbase; struct resource *res; int irq_alarm; + int irq_hz; struct rtc_device *rtc; spinlock_t lock; /* Protects this structure */ }; @@ -99,6 +100,10 @@ static irqreturn_t vt8500_rtc_irq(int irq, void *dev_id) if (isr & 1) events |= RTC_AF | RTC_IRQF; + /* Only second/minute interrupts are supported */ + if (isr & 2) + events |= RTC_UF | RTC_IRQF; + rtc_update_irq(vt8500_rtc->rtc, 1, events); return IRQ_HANDLED; @@ -194,12 +199,27 @@ static int vt8500_alarm_irq_enable(struct device *dev, unsigned int enabled) return 0; } +static int vt8500_update_irq_enable(struct device *dev, unsigned int enabled) +{ + struct vt8500_rtc *vt8500_rtc = dev_get_drvdata(dev); + unsigned long tmp = readl(vt8500_rtc->regbase + VT8500_RTC_CR); + + if (enabled) + tmp |= VT8500_RTC_CR_SM_SEC | VT8500_RTC_CR_SM_ENABLE; + else + tmp &= ~VT8500_RTC_CR_SM_ENABLE; + + writel(tmp, vt8500_rtc->regbase + VT8500_RTC_CR); + return 0; +} + static const struct rtc_class_ops vt8500_rtc_ops = { .read_time = vt8500_rtc_read_time, .set_time = vt8500_rtc_set_time, .read_alarm = vt8500_rtc_read_alarm, .set_alarm = vt8500_rtc_set_alarm, .alarm_irq_enable = vt8500_alarm_irq_enable, + .update_irq_enable = vt8500_update_irq_enable, }; static int __devinit vt8500_rtc_probe(struct platform_device *pdev) @@ -228,6 +248,13 @@ static int __devinit vt8500_rtc_probe(struct platform_device *pdev) goto err_free; } + vt8500_rtc->irq_hz = platform_get_irq(pdev, 1); + if (vt8500_rtc->irq_hz < 0) { + dev_err(&pdev->dev, "No 1Hz IRQ resource defined\n"); + ret = -ENXIO; + goto err_free; + } + vt8500_rtc->res = request_mem_region(vt8500_rtc->res->start, resource_size(vt8500_rtc->res), "vt8500-rtc"); @@ -245,8 +272,9 @@ static int __devinit vt8500_rtc_probe(struct platform_device *pdev) goto err_release; } - /* Enable RTC and set it to 24-hour mode */ - writel(VT8500_RTC_CR_ENABLE | VT8500_RTC_CR_24H, + /* Enable the second/minute interrupt generation and enable RTC */ + writel(VT8500_RTC_CR_ENABLE | VT8500_RTC_CR_24H + | VT8500_RTC_CR_SM_ENABLE | VT8500_RTC_CR_SM_SEC, vt8500_rtc->regbase + VT8500_RTC_CR); vt8500_rtc->rtc = rtc_device_register("vt8500-rtc", &pdev->dev, @@ -258,16 +286,26 @@ static int __devinit vt8500_rtc_probe(struct platform_device *pdev) goto err_unmap; } + ret = request_irq(vt8500_rtc->irq_hz, vt8500_rtc_irq, 0, + "rtc 1Hz", vt8500_rtc); + if (ret < 0) { + dev_err(&pdev->dev, "can't get irq %i, err %d\n", + vt8500_rtc->irq_hz, ret); + goto err_unreg; + } + ret = request_irq(vt8500_rtc->irq_alarm, vt8500_rtc_irq, 0, "rtc alarm", vt8500_rtc); if (ret < 0) { dev_err(&pdev->dev, "can't get irq %i, err %d\n", vt8500_rtc->irq_alarm, ret); - goto err_unreg; + goto err_free_hz; } return 0; +err_free_hz: + free_irq(vt8500_rtc->irq_hz, vt8500_rtc); err_unreg: rtc_device_unregister(vt8500_rtc->rtc); err_unmap: @@ -285,6 +323,7 @@ static int __devexit vt8500_rtc_remove(struct platform_device *pdev) struct vt8500_rtc *vt8500_rtc = platform_get_drvdata(pdev); free_irq(vt8500_rtc->irq_alarm, vt8500_rtc); + free_irq(vt8500_rtc->irq_hz, vt8500_rtc); rtc_device_unregister(vt8500_rtc->rtc); diff --git a/trunk/drivers/scsi/Kconfig b/trunk/drivers/scsi/Kconfig index 8d9dae89f065..4a1f029c4fe9 100644 --- a/trunk/drivers/scsi/Kconfig +++ b/trunk/drivers/scsi/Kconfig @@ -830,19 +830,6 @@ config SCSI_GDTH To compile this driver as a module, choose M here: the module will be called gdth. -config SCSI_ISCI - tristate "Intel(R) C600 Series Chipset SAS Controller" - depends on PCI && SCSI - depends on X86 - # (temporary): known alpha quality driver - depends on EXPERIMENTAL - select SCSI_SAS_LIBSAS - ---help--- - This driver supports the 6Gb/s SAS capabilities of the storage - control unit found in the Intel(R) C600 series chipset. - - The experimental tag will be removed after the driver exits alpha - config SCSI_GENERIC_NCR5380 tristate "Generic NCR5380/53c400 SCSI PIO support" depends on ISA && SCSI diff --git a/trunk/drivers/scsi/Makefile b/trunk/drivers/scsi/Makefile index 3c08f5352b2d..7ad0b8a79ae8 100644 --- a/trunk/drivers/scsi/Makefile +++ b/trunk/drivers/scsi/Makefile @@ -73,7 +73,6 @@ obj-$(CONFIG_SCSI_AACRAID) += aacraid/ obj-$(CONFIG_SCSI_AIC7XXX_OLD) += aic7xxx_old.o obj-$(CONFIG_SCSI_AIC94XX) += aic94xx/ obj-$(CONFIG_SCSI_PM8001) += pm8001/ -obj-$(CONFIG_SCSI_ISCI) += isci/ obj-$(CONFIG_SCSI_IPS) += ips.o obj-$(CONFIG_SCSI_FD_MCS) += fd_mcs.o obj-$(CONFIG_SCSI_FUTURE_DOMAIN)+= fdomain.o diff --git a/trunk/drivers/scsi/hpsa.c b/trunk/drivers/scsi/hpsa.c index 6bba23a26303..c6c0434d8034 100644 --- a/trunk/drivers/scsi/hpsa.c +++ b/trunk/drivers/scsi/hpsa.c @@ -1037,7 +1037,6 @@ static void complete_scsi_command(struct CommandList *cp) unsigned char sense_key; unsigned char asc; /* additional sense code */ unsigned char ascq; /* additional sense code qualifier */ - unsigned long sense_data_size; ei = cp->err_info; cmd = (struct scsi_cmnd *) cp->scsi_cmd; @@ -1052,14 +1051,10 @@ static void complete_scsi_command(struct CommandList *cp) cmd->result |= ei->ScsiStatus; /* copy the sense data whether we need to or not. */ - if (SCSI_SENSE_BUFFERSIZE < sizeof(ei->SenseInfo)) - sense_data_size = SCSI_SENSE_BUFFERSIZE; - else - sense_data_size = sizeof(ei->SenseInfo); - if (ei->SenseLen < sense_data_size) - sense_data_size = ei->SenseLen; - - memcpy(cmd->sense_buffer, ei->SenseInfo, sense_data_size); + memcpy(cmd->sense_buffer, ei->SenseInfo, + ei->SenseLen > SCSI_SENSE_BUFFERSIZE ? + SCSI_SENSE_BUFFERSIZE : + ei->SenseLen); scsi_set_resid(cmd, ei->ResidualCnt); if (ei->CommandStatus == 0) { @@ -2585,8 +2580,7 @@ static int hpsa_passthru_ioctl(struct ctlr_info *h, void __user *argp) c->SG[0].Ext = 0; /* we are not chaining*/ } hpsa_scsi_do_simple_cmd_core(h, c); - if (iocommand.buf_size > 0) - hpsa_pci_unmap(h->pdev, c, 1, PCI_DMA_BIDIRECTIONAL); + hpsa_pci_unmap(h->pdev, c, 1, PCI_DMA_BIDIRECTIONAL); check_ioctl_unit_attention(h, c); /* Copy the error information out */ diff --git a/trunk/drivers/scsi/ibmvscsi/ibmvfc.c b/trunk/drivers/scsi/ibmvscsi/ibmvfc.c index bdfa223a7dbb..b7650613b8c2 100644 --- a/trunk/drivers/scsi/ibmvscsi/ibmvfc.c +++ b/trunk/drivers/scsi/ibmvscsi/ibmvfc.c @@ -4306,8 +4306,8 @@ static void ibmvfc_do_work(struct ibmvfc_host *vhost) spin_lock_irqsave(vhost->host->host_lock, flags); if (rc == H_CLOSED) vio_enable_interrupts(to_vio_dev(vhost->dev)); - if (rc || (rc = ibmvfc_send_crq_init(vhost)) || - (rc = vio_enable_interrupts(to_vio_dev(vhost->dev)))) { + else if (rc || (rc = ibmvfc_send_crq_init(vhost)) || + (rc = vio_enable_interrupts(to_vio_dev(vhost->dev)))) { ibmvfc_link_down(vhost, IBMVFC_LINK_DEAD); dev_err(vhost->dev, "Error after reset (rc=%d)\n", rc); } diff --git a/trunk/drivers/scsi/isci/Makefile b/trunk/drivers/scsi/isci/Makefile deleted file mode 100644 index 3359e10e0d8f..000000000000 --- a/trunk/drivers/scsi/isci/Makefile +++ /dev/null @@ -1,8 +0,0 @@ -obj-$(CONFIG_SCSI_ISCI) += isci.o -isci-objs := init.o phy.o request.o \ - remote_device.o port.o \ - host.o task.o probe_roms.o \ - remote_node_context.o \ - remote_node_table.o \ - unsolicited_frame_control.o \ - port_config.o \ diff --git a/trunk/drivers/scsi/isci/firmware/Makefile b/trunk/drivers/scsi/isci/firmware/Makefile deleted file mode 100644 index 5f54461cabc5..000000000000 --- a/trunk/drivers/scsi/isci/firmware/Makefile +++ /dev/null @@ -1,19 +0,0 @@ -# Makefile for create_fw -# -CC=gcc -CFLAGS=-c -Wall -O2 -g -LDFLAGS= -SOURCES=create_fw.c -OBJECTS=$(SOURCES:.cpp=.o) -EXECUTABLE=create_fw - -all: $(SOURCES) $(EXECUTABLE) - -$(EXECUTABLE): $(OBJECTS) - $(CC) $(LDFLAGS) $(OBJECTS) -o $@ - -.c.o: - $(CC) $(CFLAGS) $< -O $@ - -clean: - rm -f *.o $(EXECUTABLE) diff --git a/trunk/drivers/scsi/isci/firmware/README b/trunk/drivers/scsi/isci/firmware/README deleted file mode 100644 index 8056d2bd233b..000000000000 --- a/trunk/drivers/scsi/isci/firmware/README +++ /dev/null @@ -1,36 +0,0 @@ -This defines the temporary binary blow we are to pass to the SCU -driver to emulate the binary firmware that we will eventually be -able to access via NVRAM on the SCU controller. - -The current size of the binary blob is expected to be 149 bytes or larger - -Header Types: -0x1: Phy Masks -0x2: Phy Gens -0x3: SAS Addrs -0xff: End of Data - -ID string - u8[12]: "#SCU MAGIC#\0" -Version - u8: 1 -SubVersion - u8: 0 - -Header Type - u8: 0x1 -Size - u8: 8 -Phy Mask - u32[8] - -Header Type - u8: 0x2 -Size - u8: 8 -Phy Gen - u32[8] - -Header Type - u8: 0x3 -Size - u8: 8 -Sas Addr - u64[8] - -Header Type - u8: 0xf - - -============================================================================== - -Place isci_firmware.bin in /lib/firmware -Be sure to recreate the initramfs image to include the firmware. - diff --git a/trunk/drivers/scsi/isci/firmware/create_fw.c b/trunk/drivers/scsi/isci/firmware/create_fw.c deleted file mode 100644 index c7a2887a7e95..000000000000 --- a/trunk/drivers/scsi/isci/firmware/create_fw.c +++ /dev/null @@ -1,99 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "create_fw.h" -#include "../probe_roms.h" - -int write_blob(struct isci_orom *isci_orom) -{ - FILE *fd; - int err; - size_t count; - - fd = fopen(blob_name, "w+"); - if (!fd) { - perror("Open file for write failed"); - fclose(fd); - return -EIO; - } - - count = fwrite(isci_orom, sizeof(struct isci_orom), 1, fd); - if (count != 1) { - perror("Write data failed"); - fclose(fd); - return -EIO; - } - - fclose(fd); - - return 0; -} - -void set_binary_values(struct isci_orom *isci_orom) -{ - int ctrl_idx, phy_idx, port_idx; - - /* setting OROM signature */ - strncpy(isci_orom->hdr.signature, sig, strlen(sig)); - isci_orom->hdr.version = version; - isci_orom->hdr.total_block_length = sizeof(struct isci_orom); - isci_orom->hdr.hdr_length = sizeof(struct sci_bios_oem_param_block_hdr); - isci_orom->hdr.num_elements = num_elements; - - for (ctrl_idx = 0; ctrl_idx < 2; ctrl_idx++) { - isci_orom->ctrl[ctrl_idx].controller.mode_type = mode_type; - isci_orom->ctrl[ctrl_idx].controller.max_concurrent_dev_spin_up = - max_num_concurrent_dev_spin_up; - isci_orom->ctrl[ctrl_idx].controller.do_enable_ssc = - enable_ssc; - - for (port_idx = 0; port_idx < 4; port_idx++) - isci_orom->ctrl[ctrl_idx].ports[port_idx].phy_mask = - phy_mask[ctrl_idx][port_idx]; - - for (phy_idx = 0; phy_idx < 4; phy_idx++) { - isci_orom->ctrl[ctrl_idx].phys[phy_idx].sas_address.high = - (__u32)(sas_addr[ctrl_idx][phy_idx] >> 32); - isci_orom->ctrl[ctrl_idx].phys[phy_idx].sas_address.low = - (__u32)(sas_addr[ctrl_idx][phy_idx]); - - isci_orom->ctrl[ctrl_idx].phys[phy_idx].afe_tx_amp_control0 = - afe_tx_amp_control0; - isci_orom->ctrl[ctrl_idx].phys[phy_idx].afe_tx_amp_control1 = - afe_tx_amp_control1; - isci_orom->ctrl[ctrl_idx].phys[phy_idx].afe_tx_amp_control2 = - afe_tx_amp_control2; - isci_orom->ctrl[ctrl_idx].phys[phy_idx].afe_tx_amp_control3 = - afe_tx_amp_control3; - } - } -} - -int main(void) -{ - int err; - struct isci_orom *isci_orom; - - isci_orom = malloc(sizeof(struct isci_orom)); - memset(isci_orom, 0, sizeof(struct isci_orom)); - - set_binary_values(isci_orom); - - err = write_blob(isci_orom); - if (err < 0) { - free(isci_orom); - return err; - } - - free(isci_orom); - return 0; -} diff --git a/trunk/drivers/scsi/isci/firmware/create_fw.h b/trunk/drivers/scsi/isci/firmware/create_fw.h deleted file mode 100644 index 5f298828d22e..000000000000 --- a/trunk/drivers/scsi/isci/firmware/create_fw.h +++ /dev/null @@ -1,77 +0,0 @@ -#ifndef _CREATE_FW_H_ -#define _CREATE_FW_H_ -#include "../probe_roms.h" - - -/* we are configuring for 2 SCUs */ -static const int num_elements = 2; - -/* - * For all defined arrays: - * elements 0-3 are for SCU0, ports 0-3 - * elements 4-7 are for SCU1, ports 0-3 - * - * valid configurations for one SCU are: - * P0 P1 P2 P3 - * ---------------- - * 0xF,0x0,0x0,0x0 # 1 x4 port - * 0x3,0x0,0x4,0x8 # Phys 0 and 1 are a x2 port, phy 2 and phy 3 are each x1 - * # ports - * 0x1,0x2,0xC,0x0 # Phys 0 and 1 are each x1 ports, phy 2 and phy 3 are a x2 - * # port - * 0x3,0x0,0xC,0x0 # Phys 0 and 1 are a x2 port, phy 2 and phy 3 are a x2 port - * 0x1,0x2,0x4,0x8 # Each phy is a x1 port (this is the default configuration) - * - * if there is a port/phy on which you do not wish to override the default - * values, use the value assigned to UNINIT_PARAM (255). - */ - -/* discovery mode type (port auto config mode by default ) */ - -/* - * if there is a port/phy on which you do not wish to override the default - * values, use the value "0000000000000000". SAS address of zero's is - * considered invalid and will not be used. - */ -#ifdef MPC -static const int mode_type = SCIC_PORT_MANUAL_CONFIGURATION_MODE; -static const __u8 phy_mask[2][4] = { {1, 2, 4, 8}, - {1, 2, 4, 8} }; -static const unsigned long long sas_addr[2][4] = { { 0x5FCFFFFFF0000001ULL, - 0x5FCFFFFFF0000002ULL, - 0x5FCFFFFFF0000003ULL, - 0x5FCFFFFFF0000004ULL }, - { 0x5FCFFFFFF0000005ULL, - 0x5FCFFFFFF0000006ULL, - 0x5FCFFFFFF0000007ULL, - 0x5FCFFFFFF0000008ULL } }; -#else /* APC (default) */ -static const int mode_type = SCIC_PORT_AUTOMATIC_CONFIGURATION_MODE; -static const __u8 phy_mask[2][4]; -static const unsigned long long sas_addr[2][4] = { { 0x5FCFFFFF00000001ULL, - 0x5FCFFFFF00000001ULL, - 0x5FCFFFFF00000001ULL, - 0x5FCFFFFF00000001ULL }, - { 0x5FCFFFFF00000002ULL, - 0x5FCFFFFF00000002ULL, - 0x5FCFFFFF00000002ULL, - 0x5FCFFFFF00000002ULL } }; -#endif - -/* Maximum number of concurrent device spin up */ -static const int max_num_concurrent_dev_spin_up = 1; - -/* enable of ssc operation */ -static const int enable_ssc; - -/* AFE_TX_AMP_CONTROL */ -static const unsigned int afe_tx_amp_control0 = 0x000bdd08; -static const unsigned int afe_tx_amp_control1 = 0x000ffc00; -static const unsigned int afe_tx_amp_control2 = 0x000b7c09; -static const unsigned int afe_tx_amp_control3 = 0x000afc6e; - -static const char blob_name[] = "isci_firmware.bin"; -static const char sig[] = "ISCUOEMB"; -static const unsigned char version = 0x10; - -#endif diff --git a/trunk/drivers/scsi/isci/host.c b/trunk/drivers/scsi/isci/host.c deleted file mode 100644 index 26072f1e9852..000000000000 --- a/trunk/drivers/scsi/isci/host.c +++ /dev/null @@ -1,2751 +0,0 @@ -/* - * This file is provided under a dual BSD/GPLv2 license. When using or - * redistributing this file, you may do so under either license. - * - * GPL LICENSE SUMMARY - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License 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., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. - * The full GNU General Public License is included in this distribution - * in the file called LICENSE.GPL. - * - * BSD LICENSE - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Intel Corporation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include -#include -#include -#include "host.h" -#include "isci.h" -#include "port.h" -#include "host.h" -#include "probe_roms.h" -#include "remote_device.h" -#include "request.h" -#include "scu_completion_codes.h" -#include "scu_event_codes.h" -#include "registers.h" -#include "scu_remote_node_context.h" -#include "scu_task_context.h" - -#define SCU_CONTEXT_RAM_INIT_STALL_TIME 200 - -#define smu_max_ports(dcc_value) \ - (\ - (((dcc_value) & SMU_DEVICE_CONTEXT_CAPACITY_MAX_LP_MASK) \ - >> SMU_DEVICE_CONTEXT_CAPACITY_MAX_LP_SHIFT) + 1 \ - ) - -#define smu_max_task_contexts(dcc_value) \ - (\ - (((dcc_value) & SMU_DEVICE_CONTEXT_CAPACITY_MAX_TC_MASK) \ - >> SMU_DEVICE_CONTEXT_CAPACITY_MAX_TC_SHIFT) + 1 \ - ) - -#define smu_max_rncs(dcc_value) \ - (\ - (((dcc_value) & SMU_DEVICE_CONTEXT_CAPACITY_MAX_RNC_MASK) \ - >> SMU_DEVICE_CONTEXT_CAPACITY_MAX_RNC_SHIFT) + 1 \ - ) - -#define SCIC_SDS_CONTROLLER_PHY_START_TIMEOUT 100 - -/** - * - * - * The number of milliseconds to wait while a given phy is consuming power - * before allowing another set of phys to consume power. Ultimately, this will - * be specified by OEM parameter. - */ -#define SCIC_SDS_CONTROLLER_POWER_CONTROL_INTERVAL 500 - -/** - * NORMALIZE_PUT_POINTER() - - * - * This macro will normalize the completion queue put pointer so its value can - * be used as an array inde - */ -#define NORMALIZE_PUT_POINTER(x) \ - ((x) & SMU_COMPLETION_QUEUE_PUT_POINTER_MASK) - - -/** - * NORMALIZE_EVENT_POINTER() - - * - * This macro will normalize the completion queue event entry so its value can - * be used as an index. - */ -#define NORMALIZE_EVENT_POINTER(x) \ - (\ - ((x) & SMU_COMPLETION_QUEUE_GET_EVENT_POINTER_MASK) \ - >> SMU_COMPLETION_QUEUE_GET_EVENT_POINTER_SHIFT \ - ) - -/** - * NORMALIZE_GET_POINTER() - - * - * This macro will normalize the completion queue get pointer so its value can - * be used as an index into an array - */ -#define NORMALIZE_GET_POINTER(x) \ - ((x) & SMU_COMPLETION_QUEUE_GET_POINTER_MASK) - -/** - * NORMALIZE_GET_POINTER_CYCLE_BIT() - - * - * This macro will normalize the completion queue cycle pointer so it matches - * the completion queue cycle bit - */ -#define NORMALIZE_GET_POINTER_CYCLE_BIT(x) \ - ((SMU_CQGR_CYCLE_BIT & (x)) << (31 - SMU_COMPLETION_QUEUE_GET_CYCLE_BIT_SHIFT)) - -/** - * COMPLETION_QUEUE_CYCLE_BIT() - - * - * This macro will return the cycle bit of the completion queue entry - */ -#define COMPLETION_QUEUE_CYCLE_BIT(x) ((x) & 0x80000000) - -/* Init the state machine and call the state entry function (if any) */ -void sci_init_sm(struct sci_base_state_machine *sm, - const struct sci_base_state *state_table, u32 initial_state) -{ - sci_state_transition_t handler; - - sm->initial_state_id = initial_state; - sm->previous_state_id = initial_state; - sm->current_state_id = initial_state; - sm->state_table = state_table; - - handler = sm->state_table[initial_state].enter_state; - if (handler) - handler(sm); -} - -/* Call the state exit fn, update the current state, call the state entry fn */ -void sci_change_state(struct sci_base_state_machine *sm, u32 next_state) -{ - sci_state_transition_t handler; - - handler = sm->state_table[sm->current_state_id].exit_state; - if (handler) - handler(sm); - - sm->previous_state_id = sm->current_state_id; - sm->current_state_id = next_state; - - handler = sm->state_table[sm->current_state_id].enter_state; - if (handler) - handler(sm); -} - -static bool sci_controller_completion_queue_has_entries(struct isci_host *ihost) -{ - u32 get_value = ihost->completion_queue_get; - u32 get_index = get_value & SMU_COMPLETION_QUEUE_GET_POINTER_MASK; - - if (NORMALIZE_GET_POINTER_CYCLE_BIT(get_value) == - COMPLETION_QUEUE_CYCLE_BIT(ihost->completion_queue[get_index])) - return true; - - return false; -} - -static bool sci_controller_isr(struct isci_host *ihost) -{ - if (sci_controller_completion_queue_has_entries(ihost)) { - return true; - } else { - /* - * we have a spurious interrupt it could be that we have already - * emptied the completion queue from a previous interrupt */ - writel(SMU_ISR_COMPLETION, &ihost->smu_registers->interrupt_status); - - /* - * There is a race in the hardware that could cause us not to be notified - * of an interrupt completion if we do not take this step. We will mask - * then unmask the interrupts so if there is another interrupt pending - * the clearing of the interrupt source we get the next interrupt message. */ - writel(0xFF000000, &ihost->smu_registers->interrupt_mask); - writel(0, &ihost->smu_registers->interrupt_mask); - } - - return false; -} - -irqreturn_t isci_msix_isr(int vec, void *data) -{ - struct isci_host *ihost = data; - - if (sci_controller_isr(ihost)) - tasklet_schedule(&ihost->completion_tasklet); - - return IRQ_HANDLED; -} - -static bool sci_controller_error_isr(struct isci_host *ihost) -{ - u32 interrupt_status; - - interrupt_status = - readl(&ihost->smu_registers->interrupt_status); - interrupt_status &= (SMU_ISR_QUEUE_ERROR | SMU_ISR_QUEUE_SUSPEND); - - if (interrupt_status != 0) { - /* - * There is an error interrupt pending so let it through and handle - * in the callback */ - return true; - } - - /* - * There is a race in the hardware that could cause us not to be notified - * of an interrupt completion if we do not take this step. We will mask - * then unmask the error interrupts so if there was another interrupt - * pending we will be notified. - * Could we write the value of (SMU_ISR_QUEUE_ERROR | SMU_ISR_QUEUE_SUSPEND)? */ - writel(0xff, &ihost->smu_registers->interrupt_mask); - writel(0, &ihost->smu_registers->interrupt_mask); - - return false; -} - -static void sci_controller_task_completion(struct isci_host *ihost, u32 ent) -{ - u32 index = SCU_GET_COMPLETION_INDEX(ent); - struct isci_request *ireq = ihost->reqs[index]; - - /* Make sure that we really want to process this IO request */ - if (test_bit(IREQ_ACTIVE, &ireq->flags) && - ireq->io_tag != SCI_CONTROLLER_INVALID_IO_TAG && - ISCI_TAG_SEQ(ireq->io_tag) == ihost->io_request_sequence[index]) - /* Yep this is a valid io request pass it along to the - * io request handler - */ - sci_io_request_tc_completion(ireq, ent); -} - -static void sci_controller_sdma_completion(struct isci_host *ihost, u32 ent) -{ - u32 index; - struct isci_request *ireq; - struct isci_remote_device *idev; - - index = SCU_GET_COMPLETION_INDEX(ent); - - switch (scu_get_command_request_type(ent)) { - case SCU_CONTEXT_COMMAND_REQUEST_TYPE_POST_TC: - case SCU_CONTEXT_COMMAND_REQUEST_TYPE_DUMP_TC: - ireq = ihost->reqs[index]; - dev_warn(&ihost->pdev->dev, "%s: %x for io request %p\n", - __func__, ent, ireq); - /* @todo For a post TC operation we need to fail the IO - * request - */ - break; - case SCU_CONTEXT_COMMAND_REQUEST_TYPE_DUMP_RNC: - case SCU_CONTEXT_COMMAND_REQUEST_TYPE_OTHER_RNC: - case SCU_CONTEXT_COMMAND_REQUEST_TYPE_POST_RNC: - idev = ihost->device_table[index]; - dev_warn(&ihost->pdev->dev, "%s: %x for device %p\n", - __func__, ent, idev); - /* @todo For a port RNC operation we need to fail the - * device - */ - break; - default: - dev_warn(&ihost->pdev->dev, "%s: unknown completion type %x\n", - __func__, ent); - break; - } -} - -static void sci_controller_unsolicited_frame(struct isci_host *ihost, u32 ent) -{ - u32 index; - u32 frame_index; - - struct scu_unsolicited_frame_header *frame_header; - struct isci_phy *iphy; - struct isci_remote_device *idev; - - enum sci_status result = SCI_FAILURE; - - frame_index = SCU_GET_FRAME_INDEX(ent); - - frame_header = ihost->uf_control.buffers.array[frame_index].header; - ihost->uf_control.buffers.array[frame_index].state = UNSOLICITED_FRAME_IN_USE; - - if (SCU_GET_FRAME_ERROR(ent)) { - /* - * / @todo If the IAF frame or SIGNATURE FIS frame has an error will - * / this cause a problem? We expect the phy initialization will - * / fail if there is an error in the frame. */ - sci_controller_release_frame(ihost, frame_index); - return; - } - - if (frame_header->is_address_frame) { - index = SCU_GET_PROTOCOL_ENGINE_INDEX(ent); - iphy = &ihost->phys[index]; - result = sci_phy_frame_handler(iphy, frame_index); - } else { - - index = SCU_GET_COMPLETION_INDEX(ent); - - if (index == SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX) { - /* - * This is a signature fis or a frame from a direct attached SATA - * device that has not yet been created. In either case forwared - * the frame to the PE and let it take care of the frame data. */ - index = SCU_GET_PROTOCOL_ENGINE_INDEX(ent); - iphy = &ihost->phys[index]; - result = sci_phy_frame_handler(iphy, frame_index); - } else { - if (index < ihost->remote_node_entries) - idev = ihost->device_table[index]; - else - idev = NULL; - - if (idev != NULL) - result = sci_remote_device_frame_handler(idev, frame_index); - else - sci_controller_release_frame(ihost, frame_index); - } - } - - if (result != SCI_SUCCESS) { - /* - * / @todo Is there any reason to report some additional error message - * / when we get this failure notifiction? */ - } -} - -static void sci_controller_event_completion(struct isci_host *ihost, u32 ent) -{ - struct isci_remote_device *idev; - struct isci_request *ireq; - struct isci_phy *iphy; - u32 index; - - index = SCU_GET_COMPLETION_INDEX(ent); - - switch (scu_get_event_type(ent)) { - case SCU_EVENT_TYPE_SMU_COMMAND_ERROR: - /* / @todo The driver did something wrong and we need to fix the condtion. */ - dev_err(&ihost->pdev->dev, - "%s: SCIC Controller 0x%p received SMU command error " - "0x%x\n", - __func__, - ihost, - ent); - break; - - case SCU_EVENT_TYPE_SMU_PCQ_ERROR: - case SCU_EVENT_TYPE_SMU_ERROR: - case SCU_EVENT_TYPE_FATAL_MEMORY_ERROR: - /* - * / @todo This is a hardware failure and its likely that we want to - * / reset the controller. */ - dev_err(&ihost->pdev->dev, - "%s: SCIC Controller 0x%p received fatal controller " - "event 0x%x\n", - __func__, - ihost, - ent); - break; - - case SCU_EVENT_TYPE_TRANSPORT_ERROR: - ireq = ihost->reqs[index]; - sci_io_request_event_handler(ireq, ent); - break; - - case SCU_EVENT_TYPE_PTX_SCHEDULE_EVENT: - switch (scu_get_event_specifier(ent)) { - case SCU_EVENT_SPECIFIC_SMP_RESPONSE_NO_PE: - case SCU_EVENT_SPECIFIC_TASK_TIMEOUT: - ireq = ihost->reqs[index]; - if (ireq != NULL) - sci_io_request_event_handler(ireq, ent); - else - dev_warn(&ihost->pdev->dev, - "%s: SCIC Controller 0x%p received " - "event 0x%x for io request object " - "that doesnt exist.\n", - __func__, - ihost, - ent); - - break; - - case SCU_EVENT_SPECIFIC_IT_NEXUS_TIMEOUT: - idev = ihost->device_table[index]; - if (idev != NULL) - sci_remote_device_event_handler(idev, ent); - else - dev_warn(&ihost->pdev->dev, - "%s: SCIC Controller 0x%p received " - "event 0x%x for remote device object " - "that doesnt exist.\n", - __func__, - ihost, - ent); - - break; - } - break; - - case SCU_EVENT_TYPE_BROADCAST_CHANGE: - /* - * direct the broadcast change event to the phy first and then let - * the phy redirect the broadcast change to the port object */ - case SCU_EVENT_TYPE_ERR_CNT_EVENT: - /* - * direct error counter event to the phy object since that is where - * we get the event notification. This is a type 4 event. */ - case SCU_EVENT_TYPE_OSSP_EVENT: - index = SCU_GET_PROTOCOL_ENGINE_INDEX(ent); - iphy = &ihost->phys[index]; - sci_phy_event_handler(iphy, ent); - break; - - case SCU_EVENT_TYPE_RNC_SUSPEND_TX: - case SCU_EVENT_TYPE_RNC_SUSPEND_TX_RX: - case SCU_EVENT_TYPE_RNC_OPS_MISC: - if (index < ihost->remote_node_entries) { - idev = ihost->device_table[index]; - - if (idev != NULL) - sci_remote_device_event_handler(idev, ent); - } else - dev_err(&ihost->pdev->dev, - "%s: SCIC Controller 0x%p received event 0x%x " - "for remote device object 0x%0x that doesnt " - "exist.\n", - __func__, - ihost, - ent, - index); - - break; - - default: - dev_warn(&ihost->pdev->dev, - "%s: SCIC Controller received unknown event code %x\n", - __func__, - ent); - break; - } -} - -static void sci_controller_process_completions(struct isci_host *ihost) -{ - u32 completion_count = 0; - u32 ent; - u32 get_index; - u32 get_cycle; - u32 event_get; - u32 event_cycle; - - dev_dbg(&ihost->pdev->dev, - "%s: completion queue begining get:0x%08x\n", - __func__, - ihost->completion_queue_get); - - /* Get the component parts of the completion queue */ - get_index = NORMALIZE_GET_POINTER(ihost->completion_queue_get); - get_cycle = SMU_CQGR_CYCLE_BIT & ihost->completion_queue_get; - - event_get = NORMALIZE_EVENT_POINTER(ihost->completion_queue_get); - event_cycle = SMU_CQGR_EVENT_CYCLE_BIT & ihost->completion_queue_get; - - while ( - NORMALIZE_GET_POINTER_CYCLE_BIT(get_cycle) - == COMPLETION_QUEUE_CYCLE_BIT(ihost->completion_queue[get_index]) - ) { - completion_count++; - - ent = ihost->completion_queue[get_index]; - - /* increment the get pointer and check for rollover to toggle the cycle bit */ - get_cycle ^= ((get_index+1) & SCU_MAX_COMPLETION_QUEUE_ENTRIES) << - (SMU_COMPLETION_QUEUE_GET_CYCLE_BIT_SHIFT - SCU_MAX_COMPLETION_QUEUE_SHIFT); - get_index = (get_index+1) & (SCU_MAX_COMPLETION_QUEUE_ENTRIES-1); - - dev_dbg(&ihost->pdev->dev, - "%s: completion queue entry:0x%08x\n", - __func__, - ent); - - switch (SCU_GET_COMPLETION_TYPE(ent)) { - case SCU_COMPLETION_TYPE_TASK: - sci_controller_task_completion(ihost, ent); - break; - - case SCU_COMPLETION_TYPE_SDMA: - sci_controller_sdma_completion(ihost, ent); - break; - - case SCU_COMPLETION_TYPE_UFI: - sci_controller_unsolicited_frame(ihost, ent); - break; - - case SCU_COMPLETION_TYPE_EVENT: - case SCU_COMPLETION_TYPE_NOTIFY: { - event_cycle ^= ((event_get+1) & SCU_MAX_EVENTS) << - (SMU_COMPLETION_QUEUE_GET_EVENT_CYCLE_BIT_SHIFT - SCU_MAX_EVENTS_SHIFT); - event_get = (event_get+1) & (SCU_MAX_EVENTS-1); - - sci_controller_event_completion(ihost, ent); - break; - } - default: - dev_warn(&ihost->pdev->dev, - "%s: SCIC Controller received unknown " - "completion type %x\n", - __func__, - ent); - break; - } - } - - /* Update the get register if we completed one or more entries */ - if (completion_count > 0) { - ihost->completion_queue_get = - SMU_CQGR_GEN_BIT(ENABLE) | - SMU_CQGR_GEN_BIT(EVENT_ENABLE) | - event_cycle | - SMU_CQGR_GEN_VAL(EVENT_POINTER, event_get) | - get_cycle | - SMU_CQGR_GEN_VAL(POINTER, get_index); - - writel(ihost->completion_queue_get, - &ihost->smu_registers->completion_queue_get); - - } - - dev_dbg(&ihost->pdev->dev, - "%s: completion queue ending get:0x%08x\n", - __func__, - ihost->completion_queue_get); - -} - -static void sci_controller_error_handler(struct isci_host *ihost) -{ - u32 interrupt_status; - - interrupt_status = - readl(&ihost->smu_registers->interrupt_status); - - if ((interrupt_status & SMU_ISR_QUEUE_SUSPEND) && - sci_controller_completion_queue_has_entries(ihost)) { - - sci_controller_process_completions(ihost); - writel(SMU_ISR_QUEUE_SUSPEND, &ihost->smu_registers->interrupt_status); - } else { - dev_err(&ihost->pdev->dev, "%s: status: %#x\n", __func__, - interrupt_status); - - sci_change_state(&ihost->sm, SCIC_FAILED); - - return; - } - - /* If we dont process any completions I am not sure that we want to do this. - * We are in the middle of a hardware fault and should probably be reset. - */ - writel(0, &ihost->smu_registers->interrupt_mask); -} - -irqreturn_t isci_intx_isr(int vec, void *data) -{ - irqreturn_t ret = IRQ_NONE; - struct isci_host *ihost = data; - - if (sci_controller_isr(ihost)) { - writel(SMU_ISR_COMPLETION, &ihost->smu_registers->interrupt_status); - tasklet_schedule(&ihost->completion_tasklet); - ret = IRQ_HANDLED; - } else if (sci_controller_error_isr(ihost)) { - spin_lock(&ihost->scic_lock); - sci_controller_error_handler(ihost); - spin_unlock(&ihost->scic_lock); - ret = IRQ_HANDLED; - } - - return ret; -} - -irqreturn_t isci_error_isr(int vec, void *data) -{ - struct isci_host *ihost = data; - - if (sci_controller_error_isr(ihost)) - sci_controller_error_handler(ihost); - - return IRQ_HANDLED; -} - -/** - * isci_host_start_complete() - This function is called by the core library, - * through the ISCI Module, to indicate controller start status. - * @isci_host: This parameter specifies the ISCI host object - * @completion_status: This parameter specifies the completion status from the - * core library. - * - */ -static void isci_host_start_complete(struct isci_host *ihost, enum sci_status completion_status) -{ - if (completion_status != SCI_SUCCESS) - dev_info(&ihost->pdev->dev, - "controller start timed out, continuing...\n"); - isci_host_change_state(ihost, isci_ready); - clear_bit(IHOST_START_PENDING, &ihost->flags); - wake_up(&ihost->eventq); -} - -int isci_host_scan_finished(struct Scsi_Host *shost, unsigned long time) -{ - struct isci_host *ihost = SHOST_TO_SAS_HA(shost)->lldd_ha; - - if (test_bit(IHOST_START_PENDING, &ihost->flags)) - return 0; - - /* todo: use sas_flush_discovery once it is upstream */ - scsi_flush_work(shost); - - scsi_flush_work(shost); - - dev_dbg(&ihost->pdev->dev, - "%s: ihost->status = %d, time = %ld\n", - __func__, isci_host_get_state(ihost), time); - - return 1; - -} - -/** - * sci_controller_get_suggested_start_timeout() - This method returns the - * suggested sci_controller_start() timeout amount. The user is free to - * use any timeout value, but this method provides the suggested minimum - * start timeout value. The returned value is based upon empirical - * information determined as a result of interoperability testing. - * @controller: the handle to the controller object for which to return the - * suggested start timeout. - * - * This method returns the number of milliseconds for the suggested start - * operation timeout. - */ -static u32 sci_controller_get_suggested_start_timeout(struct isci_host *ihost) -{ - /* Validate the user supplied parameters. */ - if (!ihost) - return 0; - - /* - * The suggested minimum timeout value for a controller start operation: - * - * Signature FIS Timeout - * + Phy Start Timeout - * + Number of Phy Spin Up Intervals - * --------------------------------- - * Number of milliseconds for the controller start operation. - * - * NOTE: The number of phy spin up intervals will be equivalent - * to the number of phys divided by the number phys allowed - * per interval - 1 (once OEM parameters are supported). - * Currently we assume only 1 phy per interval. */ - - return SCIC_SDS_SIGNATURE_FIS_TIMEOUT - + SCIC_SDS_CONTROLLER_PHY_START_TIMEOUT - + ((SCI_MAX_PHYS - 1) * SCIC_SDS_CONTROLLER_POWER_CONTROL_INTERVAL); -} - -static void sci_controller_enable_interrupts(struct isci_host *ihost) -{ - BUG_ON(ihost->smu_registers == NULL); - writel(0, &ihost->smu_registers->interrupt_mask); -} - -void sci_controller_disable_interrupts(struct isci_host *ihost) -{ - BUG_ON(ihost->smu_registers == NULL); - writel(0xffffffff, &ihost->smu_registers->interrupt_mask); -} - -static void sci_controller_enable_port_task_scheduler(struct isci_host *ihost) -{ - u32 port_task_scheduler_value; - - port_task_scheduler_value = - readl(&ihost->scu_registers->peg0.ptsg.control); - port_task_scheduler_value |= - (SCU_PTSGCR_GEN_BIT(ETM_ENABLE) | - SCU_PTSGCR_GEN_BIT(PTSG_ENABLE)); - writel(port_task_scheduler_value, - &ihost->scu_registers->peg0.ptsg.control); -} - -static void sci_controller_assign_task_entries(struct isci_host *ihost) -{ - u32 task_assignment; - - /* - * Assign all the TCs to function 0 - * TODO: Do we actually need to read this register to write it back? - */ - - task_assignment = - readl(&ihost->smu_registers->task_context_assignment[0]); - - task_assignment |= (SMU_TCA_GEN_VAL(STARTING, 0)) | - (SMU_TCA_GEN_VAL(ENDING, ihost->task_context_entries - 1)) | - (SMU_TCA_GEN_BIT(RANGE_CHECK_ENABLE)); - - writel(task_assignment, - &ihost->smu_registers->task_context_assignment[0]); - -} - -static void sci_controller_initialize_completion_queue(struct isci_host *ihost) -{ - u32 index; - u32 completion_queue_control_value; - u32 completion_queue_get_value; - u32 completion_queue_put_value; - - ihost->completion_queue_get = 0; - - completion_queue_control_value = - (SMU_CQC_QUEUE_LIMIT_SET(SCU_MAX_COMPLETION_QUEUE_ENTRIES - 1) | - SMU_CQC_EVENT_LIMIT_SET(SCU_MAX_EVENTS - 1)); - - writel(completion_queue_control_value, - &ihost->smu_registers->completion_queue_control); - - - /* Set the completion queue get pointer and enable the queue */ - completion_queue_get_value = ( - (SMU_CQGR_GEN_VAL(POINTER, 0)) - | (SMU_CQGR_GEN_VAL(EVENT_POINTER, 0)) - | (SMU_CQGR_GEN_BIT(ENABLE)) - | (SMU_CQGR_GEN_BIT(EVENT_ENABLE)) - ); - - writel(completion_queue_get_value, - &ihost->smu_registers->completion_queue_get); - - /* Set the completion queue put pointer */ - completion_queue_put_value = ( - (SMU_CQPR_GEN_VAL(POINTER, 0)) - | (SMU_CQPR_GEN_VAL(EVENT_POINTER, 0)) - ); - - writel(completion_queue_put_value, - &ihost->smu_registers->completion_queue_put); - - /* Initialize the cycle bit of the completion queue entries */ - for (index = 0; index < SCU_MAX_COMPLETION_QUEUE_ENTRIES; index++) { - /* - * If get.cycle_bit != completion_queue.cycle_bit - * its not a valid completion queue entry - * so at system start all entries are invalid */ - ihost->completion_queue[index] = 0x80000000; - } -} - -static void sci_controller_initialize_unsolicited_frame_queue(struct isci_host *ihost) -{ - u32 frame_queue_control_value; - u32 frame_queue_get_value; - u32 frame_queue_put_value; - - /* Write the queue size */ - frame_queue_control_value = - SCU_UFQC_GEN_VAL(QUEUE_SIZE, SCU_MAX_UNSOLICITED_FRAMES); - - writel(frame_queue_control_value, - &ihost->scu_registers->sdma.unsolicited_frame_queue_control); - - /* Setup the get pointer for the unsolicited frame queue */ - frame_queue_get_value = ( - SCU_UFQGP_GEN_VAL(POINTER, 0) - | SCU_UFQGP_GEN_BIT(ENABLE_BIT) - ); - - writel(frame_queue_get_value, - &ihost->scu_registers->sdma.unsolicited_frame_get_pointer); - /* Setup the put pointer for the unsolicited frame queue */ - frame_queue_put_value = SCU_UFQPP_GEN_VAL(POINTER, 0); - writel(frame_queue_put_value, - &ihost->scu_registers->sdma.unsolicited_frame_put_pointer); -} - -static void sci_controller_transition_to_ready(struct isci_host *ihost, enum sci_status status) -{ - if (ihost->sm.current_state_id == SCIC_STARTING) { - /* - * We move into the ready state, because some of the phys/ports - * may be up and operational. - */ - sci_change_state(&ihost->sm, SCIC_READY); - - isci_host_start_complete(ihost, status); - } -} - -static bool is_phy_starting(struct isci_phy *iphy) -{ - enum sci_phy_states state; - - state = iphy->sm.current_state_id; - switch (state) { - case SCI_PHY_STARTING: - case SCI_PHY_SUB_INITIAL: - case SCI_PHY_SUB_AWAIT_SAS_SPEED_EN: - case SCI_PHY_SUB_AWAIT_IAF_UF: - case SCI_PHY_SUB_AWAIT_SAS_POWER: - case SCI_PHY_SUB_AWAIT_SATA_POWER: - case SCI_PHY_SUB_AWAIT_SATA_PHY_EN: - case SCI_PHY_SUB_AWAIT_SATA_SPEED_EN: - case SCI_PHY_SUB_AWAIT_SIG_FIS_UF: - case SCI_PHY_SUB_FINAL: - return true; - default: - return false; - } -} - -/** - * sci_controller_start_next_phy - start phy - * @scic: controller - * - * If all the phys have been started, then attempt to transition the - * controller to the READY state and inform the user - * (sci_cb_controller_start_complete()). - */ -static enum sci_status sci_controller_start_next_phy(struct isci_host *ihost) -{ - struct sci_oem_params *oem = &ihost->oem_parameters; - struct isci_phy *iphy; - enum sci_status status; - - status = SCI_SUCCESS; - - if (ihost->phy_startup_timer_pending) - return status; - - if (ihost->next_phy_to_start >= SCI_MAX_PHYS) { - bool is_controller_start_complete = true; - u32 state; - u8 index; - - for (index = 0; index < SCI_MAX_PHYS; index++) { - iphy = &ihost->phys[index]; - state = iphy->sm.current_state_id; - - if (!phy_get_non_dummy_port(iphy)) - continue; - - /* The controller start operation is complete iff: - * - all links have been given an opportunity to start - * - have no indication of a connected device - * - have an indication of a connected device and it has - * finished the link training process. - */ - if ((iphy->is_in_link_training == false && state == SCI_PHY_INITIAL) || - (iphy->is_in_link_training == false && state == SCI_PHY_STOPPED) || - (iphy->is_in_link_training == true && is_phy_starting(iphy))) { - is_controller_start_complete = false; - break; - } - } - - /* - * The controller has successfully finished the start process. - * Inform the SCI Core user and transition to the READY state. */ - if (is_controller_start_complete == true) { - sci_controller_transition_to_ready(ihost, SCI_SUCCESS); - sci_del_timer(&ihost->phy_timer); - ihost->phy_startup_timer_pending = false; - } - } else { - iphy = &ihost->phys[ihost->next_phy_to_start]; - - if (oem->controller.mode_type == SCIC_PORT_MANUAL_CONFIGURATION_MODE) { - if (phy_get_non_dummy_port(iphy) == NULL) { - ihost->next_phy_to_start++; - - /* Caution recursion ahead be forwarned - * - * The PHY was never added to a PORT in MPC mode - * so start the next phy in sequence This phy - * will never go link up and will not draw power - * the OEM parameters either configured the phy - * incorrectly for the PORT or it was never - * assigned to a PORT - */ - return sci_controller_start_next_phy(ihost); - } - } - - status = sci_phy_start(iphy); - - if (status == SCI_SUCCESS) { - sci_mod_timer(&ihost->phy_timer, - SCIC_SDS_CONTROLLER_PHY_START_TIMEOUT); - ihost->phy_startup_timer_pending = true; - } else { - dev_warn(&ihost->pdev->dev, - "%s: Controller stop operation failed " - "to stop phy %d because of status " - "%d.\n", - __func__, - ihost->phys[ihost->next_phy_to_start].phy_index, - status); - } - - ihost->next_phy_to_start++; - } - - return status; -} - -static void phy_startup_timeout(unsigned long data) -{ - struct sci_timer *tmr = (struct sci_timer *)data; - struct isci_host *ihost = container_of(tmr, typeof(*ihost), phy_timer); - unsigned long flags; - enum sci_status status; - - spin_lock_irqsave(&ihost->scic_lock, flags); - - if (tmr->cancel) - goto done; - - ihost->phy_startup_timer_pending = false; - - do { - status = sci_controller_start_next_phy(ihost); - } while (status != SCI_SUCCESS); - -done: - spin_unlock_irqrestore(&ihost->scic_lock, flags); -} - -static u16 isci_tci_active(struct isci_host *ihost) -{ - return CIRC_CNT(ihost->tci_head, ihost->tci_tail, SCI_MAX_IO_REQUESTS); -} - -static enum sci_status sci_controller_start(struct isci_host *ihost, - u32 timeout) -{ - enum sci_status result; - u16 index; - - if (ihost->sm.current_state_id != SCIC_INITIALIZED) { - dev_warn(&ihost->pdev->dev, - "SCIC Controller start operation requested in " - "invalid state\n"); - return SCI_FAILURE_INVALID_STATE; - } - - /* Build the TCi free pool */ - BUILD_BUG_ON(SCI_MAX_IO_REQUESTS > 1 << sizeof(ihost->tci_pool[0]) * 8); - ihost->tci_head = 0; - ihost->tci_tail = 0; - for (index = 0; index < ihost->task_context_entries; index++) - isci_tci_free(ihost, index); - - /* Build the RNi free pool */ - sci_remote_node_table_initialize(&ihost->available_remote_nodes, - ihost->remote_node_entries); - - /* - * Before anything else lets make sure we will not be - * interrupted by the hardware. - */ - sci_controller_disable_interrupts(ihost); - - /* Enable the port task scheduler */ - sci_controller_enable_port_task_scheduler(ihost); - - /* Assign all the task entries to ihost physical function */ - sci_controller_assign_task_entries(ihost); - - /* Now initialize the completion queue */ - sci_controller_initialize_completion_queue(ihost); - - /* Initialize the unsolicited frame queue for use */ - sci_controller_initialize_unsolicited_frame_queue(ihost); - - /* Start all of the ports on this controller */ - for (index = 0; index < ihost->logical_port_entries; index++) { - struct isci_port *iport = &ihost->ports[index]; - - result = sci_port_start(iport); - if (result) - return result; - } - - sci_controller_start_next_phy(ihost); - - sci_mod_timer(&ihost->timer, timeout); - - sci_change_state(&ihost->sm, SCIC_STARTING); - - return SCI_SUCCESS; -} - -void isci_host_scan_start(struct Scsi_Host *shost) -{ - struct isci_host *ihost = SHOST_TO_SAS_HA(shost)->lldd_ha; - unsigned long tmo = sci_controller_get_suggested_start_timeout(ihost); - - set_bit(IHOST_START_PENDING, &ihost->flags); - - spin_lock_irq(&ihost->scic_lock); - sci_controller_start(ihost, tmo); - sci_controller_enable_interrupts(ihost); - spin_unlock_irq(&ihost->scic_lock); -} - -static void isci_host_stop_complete(struct isci_host *ihost, enum sci_status completion_status) -{ - isci_host_change_state(ihost, isci_stopped); - sci_controller_disable_interrupts(ihost); - clear_bit(IHOST_STOP_PENDING, &ihost->flags); - wake_up(&ihost->eventq); -} - -static void sci_controller_completion_handler(struct isci_host *ihost) -{ - /* Empty out the completion queue */ - if (sci_controller_completion_queue_has_entries(ihost)) - sci_controller_process_completions(ihost); - - /* Clear the interrupt and enable all interrupts again */ - writel(SMU_ISR_COMPLETION, &ihost->smu_registers->interrupt_status); - /* Could we write the value of SMU_ISR_COMPLETION? */ - writel(0xFF000000, &ihost->smu_registers->interrupt_mask); - writel(0, &ihost->smu_registers->interrupt_mask); -} - -/** - * isci_host_completion_routine() - This function is the delayed service - * routine that calls the sci core library's completion handler. It's - * scheduled as a tasklet from the interrupt service routine when interrupts - * in use, or set as the timeout function in polled mode. - * @data: This parameter specifies the ISCI host object - * - */ -static void isci_host_completion_routine(unsigned long data) -{ - struct isci_host *ihost = (struct isci_host *)data; - struct list_head completed_request_list; - struct list_head errored_request_list; - struct list_head *current_position; - struct list_head *next_position; - struct isci_request *request; - struct isci_request *next_request; - struct sas_task *task; - - INIT_LIST_HEAD(&completed_request_list); - INIT_LIST_HEAD(&errored_request_list); - - spin_lock_irq(&ihost->scic_lock); - - sci_controller_completion_handler(ihost); - - /* Take the lists of completed I/Os from the host. */ - - list_splice_init(&ihost->requests_to_complete, - &completed_request_list); - - /* Take the list of errored I/Os from the host. */ - list_splice_init(&ihost->requests_to_errorback, - &errored_request_list); - - spin_unlock_irq(&ihost->scic_lock); - - /* Process any completions in the lists. */ - list_for_each_safe(current_position, next_position, - &completed_request_list) { - - request = list_entry(current_position, struct isci_request, - completed_node); - task = isci_request_access_task(request); - - /* Normal notification (task_done) */ - dev_dbg(&ihost->pdev->dev, - "%s: Normal - request/task = %p/%p\n", - __func__, - request, - task); - - /* Return the task to libsas */ - if (task != NULL) { - - task->lldd_task = NULL; - if (!(task->task_state_flags & SAS_TASK_STATE_ABORTED)) { - - /* If the task is already in the abort path, - * the task_done callback cannot be called. - */ - task->task_done(task); - } - } - - spin_lock_irq(&ihost->scic_lock); - isci_free_tag(ihost, request->io_tag); - spin_unlock_irq(&ihost->scic_lock); - } - list_for_each_entry_safe(request, next_request, &errored_request_list, - completed_node) { - - task = isci_request_access_task(request); - - /* Use sas_task_abort */ - dev_warn(&ihost->pdev->dev, - "%s: Error - request/task = %p/%p\n", - __func__, - request, - task); - - if (task != NULL) { - - /* Put the task into the abort path if it's not there - * already. - */ - if (!(task->task_state_flags & SAS_TASK_STATE_ABORTED)) - sas_task_abort(task); - - } else { - /* This is a case where the request has completed with a - * status such that it needed further target servicing, - * but the sas_task reference has already been removed - * from the request. Since it was errored, it was not - * being aborted, so there is nothing to do except free - * it. - */ - - spin_lock_irq(&ihost->scic_lock); - /* Remove the request from the remote device's list - * of pending requests. - */ - list_del_init(&request->dev_node); - isci_free_tag(ihost, request->io_tag); - spin_unlock_irq(&ihost->scic_lock); - } - } - -} - -/** - * sci_controller_stop() - This method will stop an individual controller - * object.This method will invoke the associated user callback upon - * completion. The completion callback is called when the following - * conditions are met: -# the method return status is SCI_SUCCESS. -# the - * controller has been quiesced. This method will ensure that all IO - * requests are quiesced, phys are stopped, and all additional operation by - * the hardware is halted. - * @controller: the handle to the controller object to stop. - * @timeout: This parameter specifies the number of milliseconds in which the - * stop operation should complete. - * - * The controller must be in the STARTED or STOPPED state. Indicate if the - * controller stop method succeeded or failed in some way. SCI_SUCCESS if the - * stop operation successfully began. SCI_WARNING_ALREADY_IN_STATE if the - * controller is already in the STOPPED state. SCI_FAILURE_INVALID_STATE if the - * controller is not either in the STARTED or STOPPED states. - */ -static enum sci_status sci_controller_stop(struct isci_host *ihost, u32 timeout) -{ - if (ihost->sm.current_state_id != SCIC_READY) { - dev_warn(&ihost->pdev->dev, - "SCIC Controller stop operation requested in " - "invalid state\n"); - return SCI_FAILURE_INVALID_STATE; - } - - sci_mod_timer(&ihost->timer, timeout); - sci_change_state(&ihost->sm, SCIC_STOPPING); - return SCI_SUCCESS; -} - -/** - * sci_controller_reset() - This method will reset the supplied core - * controller regardless of the state of said controller. This operation is - * considered destructive. In other words, all current operations are wiped - * out. No IO completions for outstanding devices occur. Outstanding IO - * requests are not aborted or completed at the actual remote device. - * @controller: the handle to the controller object to reset. - * - * Indicate if the controller reset method succeeded or failed in some way. - * SCI_SUCCESS if the reset operation successfully started. SCI_FATAL_ERROR if - * the controller reset operation is unable to complete. - */ -static enum sci_status sci_controller_reset(struct isci_host *ihost) -{ - switch (ihost->sm.current_state_id) { - case SCIC_RESET: - case SCIC_READY: - case SCIC_STOPPED: - case SCIC_FAILED: - /* - * The reset operation is not a graceful cleanup, just - * perform the state transition. - */ - sci_change_state(&ihost->sm, SCIC_RESETTING); - return SCI_SUCCESS; - default: - dev_warn(&ihost->pdev->dev, - "SCIC Controller reset operation requested in " - "invalid state\n"); - return SCI_FAILURE_INVALID_STATE; - } -} - -void isci_host_deinit(struct isci_host *ihost) -{ - int i; - - isci_host_change_state(ihost, isci_stopping); - for (i = 0; i < SCI_MAX_PORTS; i++) { - struct isci_port *iport = &ihost->ports[i]; - struct isci_remote_device *idev, *d; - - list_for_each_entry_safe(idev, d, &iport->remote_dev_list, node) { - if (test_bit(IDEV_ALLOCATED, &idev->flags)) - isci_remote_device_stop(ihost, idev); - } - } - - set_bit(IHOST_STOP_PENDING, &ihost->flags); - - spin_lock_irq(&ihost->scic_lock); - sci_controller_stop(ihost, SCIC_CONTROLLER_STOP_TIMEOUT); - spin_unlock_irq(&ihost->scic_lock); - - wait_for_stop(ihost); - sci_controller_reset(ihost); - - /* Cancel any/all outstanding port timers */ - for (i = 0; i < ihost->logical_port_entries; i++) { - struct isci_port *iport = &ihost->ports[i]; - del_timer_sync(&iport->timer.timer); - } - - /* Cancel any/all outstanding phy timers */ - for (i = 0; i < SCI_MAX_PHYS; i++) { - struct isci_phy *iphy = &ihost->phys[i]; - del_timer_sync(&iphy->sata_timer.timer); - } - - del_timer_sync(&ihost->port_agent.timer.timer); - - del_timer_sync(&ihost->power_control.timer.timer); - - del_timer_sync(&ihost->timer.timer); - - del_timer_sync(&ihost->phy_timer.timer); -} - -static void __iomem *scu_base(struct isci_host *isci_host) -{ - struct pci_dev *pdev = isci_host->pdev; - int id = isci_host->id; - - return pcim_iomap_table(pdev)[SCI_SCU_BAR * 2] + SCI_SCU_BAR_SIZE * id; -} - -static void __iomem *smu_base(struct isci_host *isci_host) -{ - struct pci_dev *pdev = isci_host->pdev; - int id = isci_host->id; - - return pcim_iomap_table(pdev)[SCI_SMU_BAR * 2] + SCI_SMU_BAR_SIZE * id; -} - -static void isci_user_parameters_get(struct sci_user_parameters *u) -{ - int i; - - for (i = 0; i < SCI_MAX_PHYS; i++) { - struct sci_phy_user_params *u_phy = &u->phys[i]; - - u_phy->max_speed_generation = phy_gen; - - /* we are not exporting these for now */ - u_phy->align_insertion_frequency = 0x7f; - u_phy->in_connection_align_insertion_frequency = 0xff; - u_phy->notify_enable_spin_up_insertion_frequency = 0x33; - } - - u->stp_inactivity_timeout = stp_inactive_to; - u->ssp_inactivity_timeout = ssp_inactive_to; - u->stp_max_occupancy_timeout = stp_max_occ_to; - u->ssp_max_occupancy_timeout = ssp_max_occ_to; - u->no_outbound_task_timeout = no_outbound_task_to; - u->max_number_concurrent_device_spin_up = max_concurr_spinup; -} - -static void sci_controller_initial_state_enter(struct sci_base_state_machine *sm) -{ - struct isci_host *ihost = container_of(sm, typeof(*ihost), sm); - - sci_change_state(&ihost->sm, SCIC_RESET); -} - -static inline void sci_controller_starting_state_exit(struct sci_base_state_machine *sm) -{ - struct isci_host *ihost = container_of(sm, typeof(*ihost), sm); - - sci_del_timer(&ihost->timer); -} - -#define INTERRUPT_COALESCE_TIMEOUT_BASE_RANGE_LOWER_BOUND_NS 853 -#define INTERRUPT_COALESCE_TIMEOUT_BASE_RANGE_UPPER_BOUND_NS 1280 -#define INTERRUPT_COALESCE_TIMEOUT_MAX_US 2700000 -#define INTERRUPT_COALESCE_NUMBER_MAX 256 -#define INTERRUPT_COALESCE_TIMEOUT_ENCODE_MIN 7 -#define INTERRUPT_COALESCE_TIMEOUT_ENCODE_MAX 28 - -/** - * sci_controller_set_interrupt_coalescence() - This method allows the user to - * configure the interrupt coalescence. - * @controller: This parameter represents the handle to the controller object - * for which its interrupt coalesce register is overridden. - * @coalesce_number: Used to control the number of entries in the Completion - * Queue before an interrupt is generated. If the number of entries exceed - * this number, an interrupt will be generated. The valid range of the input - * is [0, 256]. A setting of 0 results in coalescing being disabled. - * @coalesce_timeout: Timeout value in microseconds. The valid range of the - * input is [0, 2700000] . A setting of 0 is allowed and results in no - * interrupt coalescing timeout. - * - * Indicate if the user successfully set the interrupt coalesce parameters. - * SCI_SUCCESS The user successfully updated the interrutp coalescence. - * SCI_FAILURE_INVALID_PARAMETER_VALUE The user input value is out of range. - */ -static enum sci_status -sci_controller_set_interrupt_coalescence(struct isci_host *ihost, - u32 coalesce_number, - u32 coalesce_timeout) -{ - u8 timeout_encode = 0; - u32 min = 0; - u32 max = 0; - - /* Check if the input parameters fall in the range. */ - if (coalesce_number > INTERRUPT_COALESCE_NUMBER_MAX) - return SCI_FAILURE_INVALID_PARAMETER_VALUE; - - /* - * Defined encoding for interrupt coalescing timeout: - * Value Min Max Units - * ----- --- --- ----- - * 0 - - Disabled - * 1 13.3 20.0 ns - * 2 26.7 40.0 - * 3 53.3 80.0 - * 4 106.7 160.0 - * 5 213.3 320.0 - * 6 426.7 640.0 - * 7 853.3 1280.0 - * 8 1.7 2.6 us - * 9 3.4 5.1 - * 10 6.8 10.2 - * 11 13.7 20.5 - * 12 27.3 41.0 - * 13 54.6 81.9 - * 14 109.2 163.8 - * 15 218.5 327.7 - * 16 436.9 655.4 - * 17 873.8 1310.7 - * 18 1.7 2.6 ms - * 19 3.5 5.2 - * 20 7.0 10.5 - * 21 14.0 21.0 - * 22 28.0 41.9 - * 23 55.9 83.9 - * 24 111.8 167.8 - * 25 223.7 335.5 - * 26 447.4 671.1 - * 27 894.8 1342.2 - * 28 1.8 2.7 s - * Others Undefined */ - - /* - * Use the table above to decide the encode of interrupt coalescing timeout - * value for register writing. */ - if (coalesce_timeout == 0) - timeout_encode = 0; - else{ - /* make the timeout value in unit of (10 ns). */ - coalesce_timeout = coalesce_timeout * 100; - min = INTERRUPT_COALESCE_TIMEOUT_BASE_RANGE_LOWER_BOUND_NS / 10; - max = INTERRUPT_COALESCE_TIMEOUT_BASE_RANGE_UPPER_BOUND_NS / 10; - - /* get the encode of timeout for register writing. */ - for (timeout_encode = INTERRUPT_COALESCE_TIMEOUT_ENCODE_MIN; - timeout_encode <= INTERRUPT_COALESCE_TIMEOUT_ENCODE_MAX; - timeout_encode++) { - if (min <= coalesce_timeout && max > coalesce_timeout) - break; - else if (coalesce_timeout >= max && coalesce_timeout < min * 2 - && coalesce_timeout <= INTERRUPT_COALESCE_TIMEOUT_MAX_US * 100) { - if ((coalesce_timeout - max) < (2 * min - coalesce_timeout)) - break; - else{ - timeout_encode++; - break; - } - } else { - max = max * 2; - min = min * 2; - } - } - - if (timeout_encode == INTERRUPT_COALESCE_TIMEOUT_ENCODE_MAX + 1) - /* the value is out of range. */ - return SCI_FAILURE_INVALID_PARAMETER_VALUE; - } - - writel(SMU_ICC_GEN_VAL(NUMBER, coalesce_number) | - SMU_ICC_GEN_VAL(TIMER, timeout_encode), - &ihost->smu_registers->interrupt_coalesce_control); - - - ihost->interrupt_coalesce_number = (u16)coalesce_number; - ihost->interrupt_coalesce_timeout = coalesce_timeout / 100; - - return SCI_SUCCESS; -} - - -static void sci_controller_ready_state_enter(struct sci_base_state_machine *sm) -{ - struct isci_host *ihost = container_of(sm, typeof(*ihost), sm); - - /* set the default interrupt coalescence number and timeout value. */ - sci_controller_set_interrupt_coalescence(ihost, 0x10, 250); -} - -static void sci_controller_ready_state_exit(struct sci_base_state_machine *sm) -{ - struct isci_host *ihost = container_of(sm, typeof(*ihost), sm); - - /* disable interrupt coalescence. */ - sci_controller_set_interrupt_coalescence(ihost, 0, 0); -} - -static enum sci_status sci_controller_stop_phys(struct isci_host *ihost) -{ - u32 index; - enum sci_status status; - enum sci_status phy_status; - - status = SCI_SUCCESS; - - for (index = 0; index < SCI_MAX_PHYS; index++) { - phy_status = sci_phy_stop(&ihost->phys[index]); - - if (phy_status != SCI_SUCCESS && - phy_status != SCI_FAILURE_INVALID_STATE) { - status = SCI_FAILURE; - - dev_warn(&ihost->pdev->dev, - "%s: Controller stop operation failed to stop " - "phy %d because of status %d.\n", - __func__, - ihost->phys[index].phy_index, phy_status); - } - } - - return status; -} - -static enum sci_status sci_controller_stop_ports(struct isci_host *ihost) -{ - u32 index; - enum sci_status port_status; - enum sci_status status = SCI_SUCCESS; - - for (index = 0; index < ihost->logical_port_entries; index++) { - struct isci_port *iport = &ihost->ports[index]; - - port_status = sci_port_stop(iport); - - if ((port_status != SCI_SUCCESS) && - (port_status != SCI_FAILURE_INVALID_STATE)) { - status = SCI_FAILURE; - - dev_warn(&ihost->pdev->dev, - "%s: Controller stop operation failed to " - "stop port %d because of status %d.\n", - __func__, - iport->logical_port_index, - port_status); - } - } - - return status; -} - -static enum sci_status sci_controller_stop_devices(struct isci_host *ihost) -{ - u32 index; - enum sci_status status; - enum sci_status device_status; - - status = SCI_SUCCESS; - - for (index = 0; index < ihost->remote_node_entries; index++) { - if (ihost->device_table[index] != NULL) { - /* / @todo What timeout value do we want to provide to this request? */ - device_status = sci_remote_device_stop(ihost->device_table[index], 0); - - if ((device_status != SCI_SUCCESS) && - (device_status != SCI_FAILURE_INVALID_STATE)) { - dev_warn(&ihost->pdev->dev, - "%s: Controller stop operation failed " - "to stop device 0x%p because of " - "status %d.\n", - __func__, - ihost->device_table[index], device_status); - } - } - } - - return status; -} - -static void sci_controller_stopping_state_enter(struct sci_base_state_machine *sm) -{ - struct isci_host *ihost = container_of(sm, typeof(*ihost), sm); - - /* Stop all of the components for this controller */ - sci_controller_stop_phys(ihost); - sci_controller_stop_ports(ihost); - sci_controller_stop_devices(ihost); -} - -static void sci_controller_stopping_state_exit(struct sci_base_state_machine *sm) -{ - struct isci_host *ihost = container_of(sm, typeof(*ihost), sm); - - sci_del_timer(&ihost->timer); -} - -static void sci_controller_reset_hardware(struct isci_host *ihost) -{ - /* Disable interrupts so we dont take any spurious interrupts */ - sci_controller_disable_interrupts(ihost); - - /* Reset the SCU */ - writel(0xFFFFFFFF, &ihost->smu_registers->soft_reset_control); - - /* Delay for 1ms to before clearing the CQP and UFQPR. */ - udelay(1000); - - /* The write to the CQGR clears the CQP */ - writel(0x00000000, &ihost->smu_registers->completion_queue_get); - - /* The write to the UFQGP clears the UFQPR */ - writel(0, &ihost->scu_registers->sdma.unsolicited_frame_get_pointer); -} - -static void sci_controller_resetting_state_enter(struct sci_base_state_machine *sm) -{ - struct isci_host *ihost = container_of(sm, typeof(*ihost), sm); - - sci_controller_reset_hardware(ihost); - sci_change_state(&ihost->sm, SCIC_RESET); -} - -static const struct sci_base_state sci_controller_state_table[] = { - [SCIC_INITIAL] = { - .enter_state = sci_controller_initial_state_enter, - }, - [SCIC_RESET] = {}, - [SCIC_INITIALIZING] = {}, - [SCIC_INITIALIZED] = {}, - [SCIC_STARTING] = { - .exit_state = sci_controller_starting_state_exit, - }, - [SCIC_READY] = { - .enter_state = sci_controller_ready_state_enter, - .exit_state = sci_controller_ready_state_exit, - }, - [SCIC_RESETTING] = { - .enter_state = sci_controller_resetting_state_enter, - }, - [SCIC_STOPPING] = { - .enter_state = sci_controller_stopping_state_enter, - .exit_state = sci_controller_stopping_state_exit, - }, - [SCIC_STOPPED] = {}, - [SCIC_FAILED] = {} -}; - -static void sci_controller_set_default_config_parameters(struct isci_host *ihost) -{ - /* these defaults are overridden by the platform / firmware */ - u16 index; - - /* Default to APC mode. */ - ihost->oem_parameters.controller.mode_type = SCIC_PORT_AUTOMATIC_CONFIGURATION_MODE; - - /* Default to APC mode. */ - ihost->oem_parameters.controller.max_concurrent_dev_spin_up = 1; - - /* Default to no SSC operation. */ - ihost->oem_parameters.controller.do_enable_ssc = false; - - /* Initialize all of the port parameter information to narrow ports. */ - for (index = 0; index < SCI_MAX_PORTS; index++) { - ihost->oem_parameters.ports[index].phy_mask = 0; - } - - /* Initialize all of the phy parameter information. */ - for (index = 0; index < SCI_MAX_PHYS; index++) { - /* Default to 6G (i.e. Gen 3) for now. */ - ihost->user_parameters.phys[index].max_speed_generation = 3; - - /* the frequencies cannot be 0 */ - ihost->user_parameters.phys[index].align_insertion_frequency = 0x7f; - ihost->user_parameters.phys[index].in_connection_align_insertion_frequency = 0xff; - ihost->user_parameters.phys[index].notify_enable_spin_up_insertion_frequency = 0x33; - - /* - * Previous Vitesse based expanders had a arbitration issue that - * is worked around by having the upper 32-bits of SAS address - * with a value greater then the Vitesse company identifier. - * Hence, usage of 0x5FCFFFFF. */ - ihost->oem_parameters.phys[index].sas_address.low = 0x1 + ihost->id; - ihost->oem_parameters.phys[index].sas_address.high = 0x5FCFFFFF; - } - - ihost->user_parameters.stp_inactivity_timeout = 5; - ihost->user_parameters.ssp_inactivity_timeout = 5; - ihost->user_parameters.stp_max_occupancy_timeout = 5; - ihost->user_parameters.ssp_max_occupancy_timeout = 20; - ihost->user_parameters.no_outbound_task_timeout = 20; -} - -static void controller_timeout(unsigned long data) -{ - struct sci_timer *tmr = (struct sci_timer *)data; - struct isci_host *ihost = container_of(tmr, typeof(*ihost), timer); - struct sci_base_state_machine *sm = &ihost->sm; - unsigned long flags; - - spin_lock_irqsave(&ihost->scic_lock, flags); - - if (tmr->cancel) - goto done; - - if (sm->current_state_id == SCIC_STARTING) - sci_controller_transition_to_ready(ihost, SCI_FAILURE_TIMEOUT); - else if (sm->current_state_id == SCIC_STOPPING) { - sci_change_state(sm, SCIC_FAILED); - isci_host_stop_complete(ihost, SCI_FAILURE_TIMEOUT); - } else /* / @todo Now what do we want to do in this case? */ - dev_err(&ihost->pdev->dev, - "%s: Controller timer fired when controller was not " - "in a state being timed.\n", - __func__); - -done: - spin_unlock_irqrestore(&ihost->scic_lock, flags); -} - -static enum sci_status sci_controller_construct(struct isci_host *ihost, - void __iomem *scu_base, - void __iomem *smu_base) -{ - u8 i; - - sci_init_sm(&ihost->sm, sci_controller_state_table, SCIC_INITIAL); - - ihost->scu_registers = scu_base; - ihost->smu_registers = smu_base; - - sci_port_configuration_agent_construct(&ihost->port_agent); - - /* Construct the ports for this controller */ - for (i = 0; i < SCI_MAX_PORTS; i++) - sci_port_construct(&ihost->ports[i], i, ihost); - sci_port_construct(&ihost->ports[i], SCIC_SDS_DUMMY_PORT, ihost); - - /* Construct the phys for this controller */ - for (i = 0; i < SCI_MAX_PHYS; i++) { - /* Add all the PHYs to the dummy port */ - sci_phy_construct(&ihost->phys[i], - &ihost->ports[SCI_MAX_PORTS], i); - } - - ihost->invalid_phy_mask = 0; - - sci_init_timer(&ihost->timer, controller_timeout); - - /* Initialize the User and OEM parameters to default values. */ - sci_controller_set_default_config_parameters(ihost); - - return sci_controller_reset(ihost); -} - -int sci_oem_parameters_validate(struct sci_oem_params *oem) -{ - int i; - - for (i = 0; i < SCI_MAX_PORTS; i++) - if (oem->ports[i].phy_mask > SCIC_SDS_PARM_PHY_MASK_MAX) - return -EINVAL; - - for (i = 0; i < SCI_MAX_PHYS; i++) - if (oem->phys[i].sas_address.high == 0 && - oem->phys[i].sas_address.low == 0) - return -EINVAL; - - if (oem->controller.mode_type == SCIC_PORT_AUTOMATIC_CONFIGURATION_MODE) { - for (i = 0; i < SCI_MAX_PHYS; i++) - if (oem->ports[i].phy_mask != 0) - return -EINVAL; - } else if (oem->controller.mode_type == SCIC_PORT_MANUAL_CONFIGURATION_MODE) { - u8 phy_mask = 0; - - for (i = 0; i < SCI_MAX_PHYS; i++) - phy_mask |= oem->ports[i].phy_mask; - - if (phy_mask == 0) - return -EINVAL; - } else - return -EINVAL; - - if (oem->controller.max_concurrent_dev_spin_up > MAX_CONCURRENT_DEVICE_SPIN_UP_COUNT) - return -EINVAL; - - return 0; -} - -static enum sci_status sci_oem_parameters_set(struct isci_host *ihost) -{ - u32 state = ihost->sm.current_state_id; - - if (state == SCIC_RESET || - state == SCIC_INITIALIZING || - state == SCIC_INITIALIZED) { - - if (sci_oem_parameters_validate(&ihost->oem_parameters)) - return SCI_FAILURE_INVALID_PARAMETER_VALUE; - - return SCI_SUCCESS; - } - - return SCI_FAILURE_INVALID_STATE; -} - -static void power_control_timeout(unsigned long data) -{ - struct sci_timer *tmr = (struct sci_timer *)data; - struct isci_host *ihost = container_of(tmr, typeof(*ihost), power_control.timer); - struct isci_phy *iphy; - unsigned long flags; - u8 i; - - spin_lock_irqsave(&ihost->scic_lock, flags); - - if (tmr->cancel) - goto done; - - ihost->power_control.phys_granted_power = 0; - - if (ihost->power_control.phys_waiting == 0) { - ihost->power_control.timer_started = false; - goto done; - } - - for (i = 0; i < SCI_MAX_PHYS; i++) { - - if (ihost->power_control.phys_waiting == 0) - break; - - iphy = ihost->power_control.requesters[i]; - if (iphy == NULL) - continue; - - if (ihost->power_control.phys_granted_power >= - ihost->oem_parameters.controller.max_concurrent_dev_spin_up) - break; - - ihost->power_control.requesters[i] = NULL; - ihost->power_control.phys_waiting--; - ihost->power_control.phys_granted_power++; - sci_phy_consume_power_handler(iphy); - } - - /* - * It doesn't matter if the power list is empty, we need to start the - * timer in case another phy becomes ready. - */ - sci_mod_timer(tmr, SCIC_SDS_CONTROLLER_POWER_CONTROL_INTERVAL); - ihost->power_control.timer_started = true; - -done: - spin_unlock_irqrestore(&ihost->scic_lock, flags); -} - -void sci_controller_power_control_queue_insert(struct isci_host *ihost, - struct isci_phy *iphy) -{ - BUG_ON(iphy == NULL); - - if (ihost->power_control.phys_granted_power < - ihost->oem_parameters.controller.max_concurrent_dev_spin_up) { - ihost->power_control.phys_granted_power++; - sci_phy_consume_power_handler(iphy); - - /* - * stop and start the power_control timer. When the timer fires, the - * no_of_phys_granted_power will be set to 0 - */ - if (ihost->power_control.timer_started) - sci_del_timer(&ihost->power_control.timer); - - sci_mod_timer(&ihost->power_control.timer, - SCIC_SDS_CONTROLLER_POWER_CONTROL_INTERVAL); - ihost->power_control.timer_started = true; - - } else { - /* Add the phy in the waiting list */ - ihost->power_control.requesters[iphy->phy_index] = iphy; - ihost->power_control.phys_waiting++; - } -} - -void sci_controller_power_control_queue_remove(struct isci_host *ihost, - struct isci_phy *iphy) -{ - BUG_ON(iphy == NULL); - - if (ihost->power_control.requesters[iphy->phy_index]) - ihost->power_control.phys_waiting--; - - ihost->power_control.requesters[iphy->phy_index] = NULL; -} - -#define AFE_REGISTER_WRITE_DELAY 10 - -/* Initialize the AFE for this phy index. We need to read the AFE setup from - * the OEM parameters - */ -static void sci_controller_afe_initialization(struct isci_host *ihost) -{ - const struct sci_oem_params *oem = &ihost->oem_parameters; - struct pci_dev *pdev = ihost->pdev; - u32 afe_status; - u32 phy_id; - - /* Clear DFX Status registers */ - writel(0x0081000f, &ihost->scu_registers->afe.afe_dfx_master_control0); - udelay(AFE_REGISTER_WRITE_DELAY); - - if (is_b0(pdev)) { - /* PM Rx Equalization Save, PM SPhy Rx Acknowledgement - * Timer, PM Stagger Timer */ - writel(0x0007BFFF, &ihost->scu_registers->afe.afe_pmsn_master_control2); - udelay(AFE_REGISTER_WRITE_DELAY); - } - - /* Configure bias currents to normal */ - if (is_a2(pdev)) - writel(0x00005A00, &ihost->scu_registers->afe.afe_bias_control); - else if (is_b0(pdev) || is_c0(pdev)) - writel(0x00005F00, &ihost->scu_registers->afe.afe_bias_control); - - udelay(AFE_REGISTER_WRITE_DELAY); - - /* Enable PLL */ - if (is_b0(pdev) || is_c0(pdev)) - writel(0x80040A08, &ihost->scu_registers->afe.afe_pll_control0); - else - writel(0x80040908, &ihost->scu_registers->afe.afe_pll_control0); - - udelay(AFE_REGISTER_WRITE_DELAY); - - /* Wait for the PLL to lock */ - do { - afe_status = readl(&ihost->scu_registers->afe.afe_common_block_status); - udelay(AFE_REGISTER_WRITE_DELAY); - } while ((afe_status & 0x00001000) == 0); - - if (is_a2(pdev)) { - /* Shorten SAS SNW lock time (RxLock timer value from 76 us to 50 us) */ - writel(0x7bcc96ad, &ihost->scu_registers->afe.afe_pmsn_master_control0); - udelay(AFE_REGISTER_WRITE_DELAY); - } - - for (phy_id = 0; phy_id < SCI_MAX_PHYS; phy_id++) { - const struct sci_phy_oem_params *oem_phy = &oem->phys[phy_id]; - - if (is_b0(pdev)) { - /* Configure transmitter SSC parameters */ - writel(0x00030000, &ihost->scu_registers->afe.scu_afe_xcvr[phy_id].afe_tx_ssc_control); - udelay(AFE_REGISTER_WRITE_DELAY); - } else if (is_c0(pdev)) { - /* Configure transmitter SSC parameters */ - writel(0x0003000, &ihost->scu_registers->afe.scu_afe_xcvr[phy_id].afe_tx_ssc_control); - udelay(AFE_REGISTER_WRITE_DELAY); - - /* - * All defaults, except the Receive Word Alignament/Comma Detect - * Enable....(0xe800) */ - writel(0x00004500, &ihost->scu_registers->afe.scu_afe_xcvr[phy_id].afe_xcvr_control0); - udelay(AFE_REGISTER_WRITE_DELAY); - } else { - /* - * All defaults, except the Receive Word Alignament/Comma Detect - * Enable....(0xe800) */ - writel(0x00004512, &ihost->scu_registers->afe.scu_afe_xcvr[phy_id].afe_xcvr_control0); - udelay(AFE_REGISTER_WRITE_DELAY); - - writel(0x0050100F, &ihost->scu_registers->afe.scu_afe_xcvr[phy_id].afe_xcvr_control1); - udelay(AFE_REGISTER_WRITE_DELAY); - } - - /* - * Power up TX and RX out from power down (PWRDNTX and PWRDNRX) - * & increase TX int & ext bias 20%....(0xe85c) */ - if (is_a2(pdev)) - writel(0x000003F0, &ihost->scu_registers->afe.scu_afe_xcvr[phy_id].afe_channel_control); - else if (is_b0(pdev)) { - /* Power down TX and RX (PWRDNTX and PWRDNRX) */ - writel(0x000003D7, &ihost->scu_registers->afe.scu_afe_xcvr[phy_id].afe_channel_control); - udelay(AFE_REGISTER_WRITE_DELAY); - - /* - * Power up TX and RX out from power down (PWRDNTX and PWRDNRX) - * & increase TX int & ext bias 20%....(0xe85c) */ - writel(0x000003D4, &ihost->scu_registers->afe.scu_afe_xcvr[phy_id].afe_channel_control); - } else { - writel(0x000001E7, &ihost->scu_registers->afe.scu_afe_xcvr[phy_id].afe_channel_control); - udelay(AFE_REGISTER_WRITE_DELAY); - - /* - * Power up TX and RX out from power down (PWRDNTX and PWRDNRX) - * & increase TX int & ext bias 20%....(0xe85c) */ - writel(0x000001E4, &ihost->scu_registers->afe.scu_afe_xcvr[phy_id].afe_channel_control); - } - udelay(AFE_REGISTER_WRITE_DELAY); - - if (is_a2(pdev)) { - /* Enable TX equalization (0xe824) */ - writel(0x00040000, &ihost->scu_registers->afe.scu_afe_xcvr[phy_id].afe_tx_control); - udelay(AFE_REGISTER_WRITE_DELAY); - } - - /* - * RDPI=0x0(RX Power On), RXOOBDETPDNC=0x0, TPD=0x0(TX Power On), - * RDD=0x0(RX Detect Enabled) ....(0xe800) */ - writel(0x00004100, &ihost->scu_registers->afe.scu_afe_xcvr[phy_id].afe_xcvr_control0); - udelay(AFE_REGISTER_WRITE_DELAY); - - /* Leave DFE/FFE on */ - if (is_a2(pdev)) - writel(0x3F11103F, &ihost->scu_registers->afe.scu_afe_xcvr[phy_id].afe_rx_ssc_control0); - else if (is_b0(pdev)) { - writel(0x3F11103F, &ihost->scu_registers->afe.scu_afe_xcvr[phy_id].afe_rx_ssc_control0); - udelay(AFE_REGISTER_WRITE_DELAY); - /* Enable TX equalization (0xe824) */ - writel(0x00040000, &ihost->scu_registers->afe.scu_afe_xcvr[phy_id].afe_tx_control); - } else { - writel(0x0140DF0F, &ihost->scu_registers->afe.scu_afe_xcvr[phy_id].afe_rx_ssc_control1); - udelay(AFE_REGISTER_WRITE_DELAY); - - writel(0x3F6F103F, &ihost->scu_registers->afe.scu_afe_xcvr[phy_id].afe_rx_ssc_control0); - udelay(AFE_REGISTER_WRITE_DELAY); - - /* Enable TX equalization (0xe824) */ - writel(0x00040000, &ihost->scu_registers->afe.scu_afe_xcvr[phy_id].afe_tx_control); - } - - udelay(AFE_REGISTER_WRITE_DELAY); - - writel(oem_phy->afe_tx_amp_control0, - &ihost->scu_registers->afe.scu_afe_xcvr[phy_id].afe_tx_amp_control0); - udelay(AFE_REGISTER_WRITE_DELAY); - - writel(oem_phy->afe_tx_amp_control1, - &ihost->scu_registers->afe.scu_afe_xcvr[phy_id].afe_tx_amp_control1); - udelay(AFE_REGISTER_WRITE_DELAY); - - writel(oem_phy->afe_tx_amp_control2, - &ihost->scu_registers->afe.scu_afe_xcvr[phy_id].afe_tx_amp_control2); - udelay(AFE_REGISTER_WRITE_DELAY); - - writel(oem_phy->afe_tx_amp_control3, - &ihost->scu_registers->afe.scu_afe_xcvr[phy_id].afe_tx_amp_control3); - udelay(AFE_REGISTER_WRITE_DELAY); - } - - /* Transfer control to the PEs */ - writel(0x00010f00, &ihost->scu_registers->afe.afe_dfx_master_control0); - udelay(AFE_REGISTER_WRITE_DELAY); -} - -static void sci_controller_initialize_power_control(struct isci_host *ihost) -{ - sci_init_timer(&ihost->power_control.timer, power_control_timeout); - - memset(ihost->power_control.requesters, 0, - sizeof(ihost->power_control.requesters)); - - ihost->power_control.phys_waiting = 0; - ihost->power_control.phys_granted_power = 0; -} - -static enum sci_status sci_controller_initialize(struct isci_host *ihost) -{ - struct sci_base_state_machine *sm = &ihost->sm; - enum sci_status result = SCI_FAILURE; - unsigned long i, state, val; - - if (ihost->sm.current_state_id != SCIC_RESET) { - dev_warn(&ihost->pdev->dev, - "SCIC Controller initialize operation requested " - "in invalid state\n"); - return SCI_FAILURE_INVALID_STATE; - } - - sci_change_state(sm, SCIC_INITIALIZING); - - sci_init_timer(&ihost->phy_timer, phy_startup_timeout); - - ihost->next_phy_to_start = 0; - ihost->phy_startup_timer_pending = false; - - sci_controller_initialize_power_control(ihost); - - /* - * There is nothing to do here for B0 since we do not have to - * program the AFE registers. - * / @todo The AFE settings are supposed to be correct for the B0 but - * / presently they seem to be wrong. */ - sci_controller_afe_initialization(ihost); - - - /* Take the hardware out of reset */ - writel(0, &ihost->smu_registers->soft_reset_control); - - /* - * / @todo Provide meaningfull error code for hardware failure - * result = SCI_FAILURE_CONTROLLER_HARDWARE; */ - for (i = 100; i >= 1; i--) { - u32 status; - - /* Loop until the hardware reports success */ - udelay(SCU_CONTEXT_RAM_INIT_STALL_TIME); - status = readl(&ihost->smu_registers->control_status); - - if ((status & SCU_RAM_INIT_COMPLETED) == SCU_RAM_INIT_COMPLETED) - break; - } - if (i == 0) - goto out; - - /* - * Determine what are the actaul device capacities that the - * hardware will support */ - val = readl(&ihost->smu_registers->device_context_capacity); - - /* Record the smaller of the two capacity values */ - ihost->logical_port_entries = min(smu_max_ports(val), SCI_MAX_PORTS); - ihost->task_context_entries = min(smu_max_task_contexts(val), SCI_MAX_IO_REQUESTS); - ihost->remote_node_entries = min(smu_max_rncs(val), SCI_MAX_REMOTE_DEVICES); - - /* - * Make all PEs that are unassigned match up with the - * logical ports - */ - for (i = 0; i < ihost->logical_port_entries; i++) { - struct scu_port_task_scheduler_group_registers __iomem - *ptsg = &ihost->scu_registers->peg0.ptsg; - - writel(i, &ptsg->protocol_engine[i]); - } - - /* Initialize hardware PCI Relaxed ordering in DMA engines */ - val = readl(&ihost->scu_registers->sdma.pdma_configuration); - val |= SCU_PDMACR_GEN_BIT(PCI_RELAXED_ORDERING_ENABLE); - writel(val, &ihost->scu_registers->sdma.pdma_configuration); - - val = readl(&ihost->scu_registers->sdma.cdma_configuration); - val |= SCU_CDMACR_GEN_BIT(PCI_RELAXED_ORDERING_ENABLE); - writel(val, &ihost->scu_registers->sdma.cdma_configuration); - - /* - * Initialize the PHYs before the PORTs because the PHY registers - * are accessed during the port initialization. - */ - for (i = 0; i < SCI_MAX_PHYS; i++) { - result = sci_phy_initialize(&ihost->phys[i], - &ihost->scu_registers->peg0.pe[i].tl, - &ihost->scu_registers->peg0.pe[i].ll); - if (result != SCI_SUCCESS) - goto out; - } - - for (i = 0; i < ihost->logical_port_entries; i++) { - struct isci_port *iport = &ihost->ports[i]; - - iport->port_task_scheduler_registers = &ihost->scu_registers->peg0.ptsg.port[i]; - iport->port_pe_configuration_register = &ihost->scu_registers->peg0.ptsg.protocol_engine[0]; - iport->viit_registers = &ihost->scu_registers->peg0.viit[i]; - } - - result = sci_port_configuration_agent_initialize(ihost, &ihost->port_agent); - - out: - /* Advance the controller state machine */ - if (result == SCI_SUCCESS) - state = SCIC_INITIALIZED; - else - state = SCIC_FAILED; - sci_change_state(sm, state); - - return result; -} - -static enum sci_status sci_user_parameters_set(struct isci_host *ihost, - struct sci_user_parameters *sci_parms) -{ - u32 state = ihost->sm.current_state_id; - - if (state == SCIC_RESET || - state == SCIC_INITIALIZING || - state == SCIC_INITIALIZED) { - u16 index; - - /* - * Validate the user parameters. If they are not legal, then - * return a failure. - */ - for (index = 0; index < SCI_MAX_PHYS; index++) { - struct sci_phy_user_params *user_phy; - - user_phy = &sci_parms->phys[index]; - - if (!((user_phy->max_speed_generation <= - SCIC_SDS_PARM_MAX_SPEED) && - (user_phy->max_speed_generation > - SCIC_SDS_PARM_NO_SPEED))) - return SCI_FAILURE_INVALID_PARAMETER_VALUE; - - if (user_phy->in_connection_align_insertion_frequency < - 3) - return SCI_FAILURE_INVALID_PARAMETER_VALUE; - - if ((user_phy->in_connection_align_insertion_frequency < - 3) || - (user_phy->align_insertion_frequency == 0) || - (user_phy-> - notify_enable_spin_up_insertion_frequency == - 0)) - return SCI_FAILURE_INVALID_PARAMETER_VALUE; - } - - if ((sci_parms->stp_inactivity_timeout == 0) || - (sci_parms->ssp_inactivity_timeout == 0) || - (sci_parms->stp_max_occupancy_timeout == 0) || - (sci_parms->ssp_max_occupancy_timeout == 0) || - (sci_parms->no_outbound_task_timeout == 0)) - return SCI_FAILURE_INVALID_PARAMETER_VALUE; - - memcpy(&ihost->user_parameters, sci_parms, sizeof(*sci_parms)); - - return SCI_SUCCESS; - } - - return SCI_FAILURE_INVALID_STATE; -} - -static int sci_controller_mem_init(struct isci_host *ihost) -{ - struct device *dev = &ihost->pdev->dev; - dma_addr_t dma; - size_t size; - int err; - - size = SCU_MAX_COMPLETION_QUEUE_ENTRIES * sizeof(u32); - ihost->completion_queue = dmam_alloc_coherent(dev, size, &dma, GFP_KERNEL); - if (!ihost->completion_queue) - return -ENOMEM; - - writel(lower_32_bits(dma), &ihost->smu_registers->completion_queue_lower); - writel(upper_32_bits(dma), &ihost->smu_registers->completion_queue_upper); - - size = ihost->remote_node_entries * sizeof(union scu_remote_node_context); - ihost->remote_node_context_table = dmam_alloc_coherent(dev, size, &dma, - GFP_KERNEL); - if (!ihost->remote_node_context_table) - return -ENOMEM; - - writel(lower_32_bits(dma), &ihost->smu_registers->remote_node_context_lower); - writel(upper_32_bits(dma), &ihost->smu_registers->remote_node_context_upper); - - size = ihost->task_context_entries * sizeof(struct scu_task_context), - ihost->task_context_table = dmam_alloc_coherent(dev, size, &dma, GFP_KERNEL); - if (!ihost->task_context_table) - return -ENOMEM; - - ihost->task_context_dma = dma; - writel(lower_32_bits(dma), &ihost->smu_registers->host_task_table_lower); - writel(upper_32_bits(dma), &ihost->smu_registers->host_task_table_upper); - - err = sci_unsolicited_frame_control_construct(ihost); - if (err) - return err; - - /* - * Inform the silicon as to the location of the UF headers and - * address table. - */ - writel(lower_32_bits(ihost->uf_control.headers.physical_address), - &ihost->scu_registers->sdma.uf_header_base_address_lower); - writel(upper_32_bits(ihost->uf_control.headers.physical_address), - &ihost->scu_registers->sdma.uf_header_base_address_upper); - - writel(lower_32_bits(ihost->uf_control.address_table.physical_address), - &ihost->scu_registers->sdma.uf_address_table_lower); - writel(upper_32_bits(ihost->uf_control.address_table.physical_address), - &ihost->scu_registers->sdma.uf_address_table_upper); - - return 0; -} - -int isci_host_init(struct isci_host *ihost) -{ - int err = 0, i; - enum sci_status status; - struct sci_user_parameters sci_user_params; - struct isci_pci_info *pci_info = to_pci_info(ihost->pdev); - - spin_lock_init(&ihost->state_lock); - spin_lock_init(&ihost->scic_lock); - init_waitqueue_head(&ihost->eventq); - - isci_host_change_state(ihost, isci_starting); - - status = sci_controller_construct(ihost, scu_base(ihost), - smu_base(ihost)); - - if (status != SCI_SUCCESS) { - dev_err(&ihost->pdev->dev, - "%s: sci_controller_construct failed - status = %x\n", - __func__, - status); - return -ENODEV; - } - - ihost->sas_ha.dev = &ihost->pdev->dev; - ihost->sas_ha.lldd_ha = ihost; - - /* - * grab initial values stored in the controller object for OEM and USER - * parameters - */ - isci_user_parameters_get(&sci_user_params); - status = sci_user_parameters_set(ihost, &sci_user_params); - if (status != SCI_SUCCESS) { - dev_warn(&ihost->pdev->dev, - "%s: sci_user_parameters_set failed\n", - __func__); - return -ENODEV; - } - - /* grab any OEM parameters specified in orom */ - if (pci_info->orom) { - status = isci_parse_oem_parameters(&ihost->oem_parameters, - pci_info->orom, - ihost->id); - if (status != SCI_SUCCESS) { - dev_warn(&ihost->pdev->dev, - "parsing firmware oem parameters failed\n"); - return -EINVAL; - } - } - - status = sci_oem_parameters_set(ihost); - if (status != SCI_SUCCESS) { - dev_warn(&ihost->pdev->dev, - "%s: sci_oem_parameters_set failed\n", - __func__); - return -ENODEV; - } - - tasklet_init(&ihost->completion_tasklet, - isci_host_completion_routine, (unsigned long)ihost); - - INIT_LIST_HEAD(&ihost->requests_to_complete); - INIT_LIST_HEAD(&ihost->requests_to_errorback); - - spin_lock_irq(&ihost->scic_lock); - status = sci_controller_initialize(ihost); - spin_unlock_irq(&ihost->scic_lock); - if (status != SCI_SUCCESS) { - dev_warn(&ihost->pdev->dev, - "%s: sci_controller_initialize failed -" - " status = 0x%x\n", - __func__, status); - return -ENODEV; - } - - err = sci_controller_mem_init(ihost); - if (err) - return err; - - for (i = 0; i < SCI_MAX_PORTS; i++) - isci_port_init(&ihost->ports[i], ihost, i); - - for (i = 0; i < SCI_MAX_PHYS; i++) - isci_phy_init(&ihost->phys[i], ihost, i); - - for (i = 0; i < SCI_MAX_REMOTE_DEVICES; i++) { - struct isci_remote_device *idev = &ihost->devices[i]; - - INIT_LIST_HEAD(&idev->reqs_in_process); - INIT_LIST_HEAD(&idev->node); - } - - for (i = 0; i < SCI_MAX_IO_REQUESTS; i++) { - struct isci_request *ireq; - dma_addr_t dma; - - ireq = dmam_alloc_coherent(&ihost->pdev->dev, - sizeof(struct isci_request), &dma, - GFP_KERNEL); - if (!ireq) - return -ENOMEM; - - ireq->tc = &ihost->task_context_table[i]; - ireq->owning_controller = ihost; - spin_lock_init(&ireq->state_lock); - ireq->request_daddr = dma; - ireq->isci_host = ihost; - ihost->reqs[i] = ireq; - } - - return 0; -} - -void sci_controller_link_up(struct isci_host *ihost, struct isci_port *iport, - struct isci_phy *iphy) -{ - switch (ihost->sm.current_state_id) { - case SCIC_STARTING: - sci_del_timer(&ihost->phy_timer); - ihost->phy_startup_timer_pending = false; - ihost->port_agent.link_up_handler(ihost, &ihost->port_agent, - iport, iphy); - sci_controller_start_next_phy(ihost); - break; - case SCIC_READY: - ihost->port_agent.link_up_handler(ihost, &ihost->port_agent, - iport, iphy); - break; - default: - dev_dbg(&ihost->pdev->dev, - "%s: SCIC Controller linkup event from phy %d in " - "unexpected state %d\n", __func__, iphy->phy_index, - ihost->sm.current_state_id); - } -} - -void sci_controller_link_down(struct isci_host *ihost, struct isci_port *iport, - struct isci_phy *iphy) -{ - switch (ihost->sm.current_state_id) { - case SCIC_STARTING: - case SCIC_READY: - ihost->port_agent.link_down_handler(ihost, &ihost->port_agent, - iport, iphy); - break; - default: - dev_dbg(&ihost->pdev->dev, - "%s: SCIC Controller linkdown event from phy %d in " - "unexpected state %d\n", - __func__, - iphy->phy_index, - ihost->sm.current_state_id); - } -} - -static bool sci_controller_has_remote_devices_stopping(struct isci_host *ihost) -{ - u32 index; - - for (index = 0; index < ihost->remote_node_entries; index++) { - if ((ihost->device_table[index] != NULL) && - (ihost->device_table[index]->sm.current_state_id == SCI_DEV_STOPPING)) - return true; - } - - return false; -} - -void sci_controller_remote_device_stopped(struct isci_host *ihost, - struct isci_remote_device *idev) -{ - if (ihost->sm.current_state_id != SCIC_STOPPING) { - dev_dbg(&ihost->pdev->dev, - "SCIC Controller 0x%p remote device stopped event " - "from device 0x%p in unexpected state %d\n", - ihost, idev, - ihost->sm.current_state_id); - return; - } - - if (!sci_controller_has_remote_devices_stopping(ihost)) - sci_change_state(&ihost->sm, SCIC_STOPPED); -} - -void sci_controller_post_request(struct isci_host *ihost, u32 request) -{ - dev_dbg(&ihost->pdev->dev, "%s[%d]: %#x\n", - __func__, ihost->id, request); - - writel(request, &ihost->smu_registers->post_context_port); -} - -struct isci_request *sci_request_by_tag(struct isci_host *ihost, u16 io_tag) -{ - u16 task_index; - u16 task_sequence; - - task_index = ISCI_TAG_TCI(io_tag); - - if (task_index < ihost->task_context_entries) { - struct isci_request *ireq = ihost->reqs[task_index]; - - if (test_bit(IREQ_ACTIVE, &ireq->flags)) { - task_sequence = ISCI_TAG_SEQ(io_tag); - - if (task_sequence == ihost->io_request_sequence[task_index]) - return ireq; - } - } - - return NULL; -} - -/** - * This method allocates remote node index and the reserves the remote node - * context space for use. This method can fail if there are no more remote - * node index available. - * @scic: This is the controller object which contains the set of - * free remote node ids - * @sci_dev: This is the device object which is requesting the a remote node - * id - * @node_id: This is the remote node id that is assinged to the device if one - * is available - * - * enum sci_status SCI_FAILURE_OUT_OF_RESOURCES if there are no available remote - * node index available. - */ -enum sci_status sci_controller_allocate_remote_node_context(struct isci_host *ihost, - struct isci_remote_device *idev, - u16 *node_id) -{ - u16 node_index; - u32 remote_node_count = sci_remote_device_node_count(idev); - - node_index = sci_remote_node_table_allocate_remote_node( - &ihost->available_remote_nodes, remote_node_count - ); - - if (node_index != SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX) { - ihost->device_table[node_index] = idev; - - *node_id = node_index; - - return SCI_SUCCESS; - } - - return SCI_FAILURE_INSUFFICIENT_RESOURCES; -} - -void sci_controller_free_remote_node_context(struct isci_host *ihost, - struct isci_remote_device *idev, - u16 node_id) -{ - u32 remote_node_count = sci_remote_device_node_count(idev); - - if (ihost->device_table[node_id] == idev) { - ihost->device_table[node_id] = NULL; - - sci_remote_node_table_release_remote_node_index( - &ihost->available_remote_nodes, remote_node_count, node_id - ); - } -} - -void sci_controller_copy_sata_response(void *response_buffer, - void *frame_header, - void *frame_buffer) -{ - /* XXX type safety? */ - memcpy(response_buffer, frame_header, sizeof(u32)); - - memcpy(response_buffer + sizeof(u32), - frame_buffer, - sizeof(struct dev_to_host_fis) - sizeof(u32)); -} - -void sci_controller_release_frame(struct isci_host *ihost, u32 frame_index) -{ - if (sci_unsolicited_frame_control_release_frame(&ihost->uf_control, frame_index)) - writel(ihost->uf_control.get, - &ihost->scu_registers->sdma.unsolicited_frame_get_pointer); -} - -void isci_tci_free(struct isci_host *ihost, u16 tci) -{ - u16 tail = ihost->tci_tail & (SCI_MAX_IO_REQUESTS-1); - - ihost->tci_pool[tail] = tci; - ihost->tci_tail = tail + 1; -} - -static u16 isci_tci_alloc(struct isci_host *ihost) -{ - u16 head = ihost->tci_head & (SCI_MAX_IO_REQUESTS-1); - u16 tci = ihost->tci_pool[head]; - - ihost->tci_head = head + 1; - return tci; -} - -static u16 isci_tci_space(struct isci_host *ihost) -{ - return CIRC_SPACE(ihost->tci_head, ihost->tci_tail, SCI_MAX_IO_REQUESTS); -} - -u16 isci_alloc_tag(struct isci_host *ihost) -{ - if (isci_tci_space(ihost)) { - u16 tci = isci_tci_alloc(ihost); - u8 seq = ihost->io_request_sequence[tci]; - - return ISCI_TAG(seq, tci); - } - - return SCI_CONTROLLER_INVALID_IO_TAG; -} - -enum sci_status isci_free_tag(struct isci_host *ihost, u16 io_tag) -{ - u16 tci = ISCI_TAG_TCI(io_tag); - u16 seq = ISCI_TAG_SEQ(io_tag); - - /* prevent tail from passing head */ - if (isci_tci_active(ihost) == 0) - return SCI_FAILURE_INVALID_IO_TAG; - - if (seq == ihost->io_request_sequence[tci]) { - ihost->io_request_sequence[tci] = (seq+1) & (SCI_MAX_SEQ-1); - - isci_tci_free(ihost, tci); - - return SCI_SUCCESS; - } - return SCI_FAILURE_INVALID_IO_TAG; -} - -enum sci_status sci_controller_start_io(struct isci_host *ihost, - struct isci_remote_device *idev, - struct isci_request *ireq) -{ - enum sci_status status; - - if (ihost->sm.current_state_id != SCIC_READY) { - dev_warn(&ihost->pdev->dev, "invalid state to start I/O"); - return SCI_FAILURE_INVALID_STATE; - } - - status = sci_remote_device_start_io(ihost, idev, ireq); - if (status != SCI_SUCCESS) - return status; - - set_bit(IREQ_ACTIVE, &ireq->flags); - sci_controller_post_request(ihost, ireq->post_context); - return SCI_SUCCESS; -} - -enum sci_status sci_controller_terminate_request(struct isci_host *ihost, - struct isci_remote_device *idev, - struct isci_request *ireq) -{ - /* terminate an ongoing (i.e. started) core IO request. This does not - * abort the IO request at the target, but rather removes the IO - * request from the host controller. - */ - enum sci_status status; - - if (ihost->sm.current_state_id != SCIC_READY) { - dev_warn(&ihost->pdev->dev, - "invalid state to terminate request\n"); - return SCI_FAILURE_INVALID_STATE; - } - - status = sci_io_request_terminate(ireq); - if (status != SCI_SUCCESS) - return status; - - /* - * Utilize the original post context command and or in the POST_TC_ABORT - * request sub-type. - */ - sci_controller_post_request(ihost, - ireq->post_context | SCU_CONTEXT_COMMAND_REQUEST_POST_TC_ABORT); - return SCI_SUCCESS; -} - -/** - * sci_controller_complete_io() - This method will perform core specific - * completion operations for an IO request. After this method is invoked, - * the user should consider the IO request as invalid until it is properly - * reused (i.e. re-constructed). - * @ihost: The handle to the controller object for which to complete the - * IO request. - * @idev: The handle to the remote device object for which to complete - * the IO request. - * @ireq: the handle to the io request object to complete. - */ -enum sci_status sci_controller_complete_io(struct isci_host *ihost, - struct isci_remote_device *idev, - struct isci_request *ireq) -{ - enum sci_status status; - u16 index; - - switch (ihost->sm.current_state_id) { - case SCIC_STOPPING: - /* XXX: Implement this function */ - return SCI_FAILURE; - case SCIC_READY: - status = sci_remote_device_complete_io(ihost, idev, ireq); - if (status != SCI_SUCCESS) - return status; - - index = ISCI_TAG_TCI(ireq->io_tag); - clear_bit(IREQ_ACTIVE, &ireq->flags); - return SCI_SUCCESS; - default: - dev_warn(&ihost->pdev->dev, "invalid state to complete I/O"); - return SCI_FAILURE_INVALID_STATE; - } - -} - -enum sci_status sci_controller_continue_io(struct isci_request *ireq) -{ - struct isci_host *ihost = ireq->owning_controller; - - if (ihost->sm.current_state_id != SCIC_READY) { - dev_warn(&ihost->pdev->dev, "invalid state to continue I/O"); - return SCI_FAILURE_INVALID_STATE; - } - - set_bit(IREQ_ACTIVE, &ireq->flags); - sci_controller_post_request(ihost, ireq->post_context); - return SCI_SUCCESS; -} - -/** - * sci_controller_start_task() - This method is called by the SCIC user to - * send/start a framework task management request. - * @controller: the handle to the controller object for which to start the task - * management request. - * @remote_device: the handle to the remote device object for which to start - * the task management request. - * @task_request: the handle to the task request object to start. - */ -enum sci_task_status sci_controller_start_task(struct isci_host *ihost, - struct isci_remote_device *idev, - struct isci_request *ireq) -{ - enum sci_status status; - - if (ihost->sm.current_state_id != SCIC_READY) { - dev_warn(&ihost->pdev->dev, - "%s: SCIC Controller starting task from invalid " - "state\n", - __func__); - return SCI_TASK_FAILURE_INVALID_STATE; - } - - status = sci_remote_device_start_task(ihost, idev, ireq); - switch (status) { - case SCI_FAILURE_RESET_DEVICE_PARTIAL_SUCCESS: - set_bit(IREQ_ACTIVE, &ireq->flags); - - /* - * We will let framework know this task request started successfully, - * although core is still woring on starting the request (to post tc when - * RNC is resumed.) - */ - return SCI_SUCCESS; - case SCI_SUCCESS: - set_bit(IREQ_ACTIVE, &ireq->flags); - sci_controller_post_request(ihost, ireq->post_context); - break; - default: - break; - } - - return status; -} diff --git a/trunk/drivers/scsi/isci/host.h b/trunk/drivers/scsi/isci/host.h deleted file mode 100644 index 062101a39f79..000000000000 --- a/trunk/drivers/scsi/isci/host.h +++ /dev/null @@ -1,542 +0,0 @@ -/* - * This file is provided under a dual BSD/GPLv2 license. When using or - * redistributing this file, you may do so under either license. - * - * GPL LICENSE SUMMARY - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License 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., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. - * The full GNU General Public License is included in this distribution - * in the file called LICENSE.GPL. - * - * BSD LICENSE - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Intel Corporation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#ifndef _SCI_HOST_H_ -#define _SCI_HOST_H_ - -#include "remote_device.h" -#include "phy.h" -#include "isci.h" -#include "remote_node_table.h" -#include "registers.h" -#include "unsolicited_frame_control.h" -#include "probe_roms.h" - -struct isci_request; -struct scu_task_context; - - -/** - * struct sci_power_control - - * - * This structure defines the fields for managing power control for direct - * attached disk devices. - */ -struct sci_power_control { - /** - * This field is set when the power control timer is running and cleared when - * it is not. - */ - bool timer_started; - - /** - * Timer to control when the directed attached disks can consume power. - */ - struct sci_timer timer; - - /** - * This field is used to keep track of how many phys are put into the - * requesters field. - */ - u8 phys_waiting; - - /** - * This field is used to keep track of how many phys have been granted to consume power - */ - u8 phys_granted_power; - - /** - * This field is an array of phys that we are waiting on. The phys are direct - * mapped into requesters via struct sci_phy.phy_index - */ - struct isci_phy *requesters[SCI_MAX_PHYS]; - -}; - -struct sci_port_configuration_agent; -typedef void (*port_config_fn)(struct isci_host *, - struct sci_port_configuration_agent *, - struct isci_port *, struct isci_phy *); - -struct sci_port_configuration_agent { - u16 phy_configured_mask; - u16 phy_ready_mask; - struct { - u8 min_index; - u8 max_index; - } phy_valid_port_range[SCI_MAX_PHYS]; - bool timer_pending; - port_config_fn link_up_handler; - port_config_fn link_down_handler; - struct sci_timer timer; -}; - -/** - * isci_host - primary host/controller object - * @timer: timeout start/stop operations - * @device_table: rni (hw remote node index) to remote device lookup table - * @available_remote_nodes: rni allocator - * @power_control: manage device spin up - * @io_request_sequence: generation number for tci's (task contexts) - * @task_context_table: hw task context table - * @remote_node_context_table: hw remote node context table - * @completion_queue: hw-producer driver-consumer communication ring - * @completion_queue_get: tracks the driver 'head' of the ring to notify hw - * @logical_port_entries: min({driver|silicon}-supported-port-count) - * @remote_node_entries: min({driver|silicon}-supported-node-count) - * @task_context_entries: min({driver|silicon}-supported-task-count) - * @phy_timer: phy startup timer - * @invalid_phy_mask: if an invalid_link_up notification is reported a bit for - * the phy index is set so further notifications are not - * made. Once the phy reports link up and is made part of a - * port then this bit is cleared. - - */ -struct isci_host { - struct sci_base_state_machine sm; - /* XXX can we time this externally */ - struct sci_timer timer; - /* XXX drop reference module params directly */ - struct sci_user_parameters user_parameters; - /* XXX no need to be a union */ - struct sci_oem_params oem_parameters; - struct sci_port_configuration_agent port_agent; - struct isci_remote_device *device_table[SCI_MAX_REMOTE_DEVICES]; - struct sci_remote_node_table available_remote_nodes; - struct sci_power_control power_control; - u8 io_request_sequence[SCI_MAX_IO_REQUESTS]; - struct scu_task_context *task_context_table; - dma_addr_t task_context_dma; - union scu_remote_node_context *remote_node_context_table; - u32 *completion_queue; - u32 completion_queue_get; - u32 logical_port_entries; - u32 remote_node_entries; - u32 task_context_entries; - struct sci_unsolicited_frame_control uf_control; - - /* phy startup */ - struct sci_timer phy_timer; - /* XXX kill */ - bool phy_startup_timer_pending; - u32 next_phy_to_start; - /* XXX convert to unsigned long and use bitops */ - u8 invalid_phy_mask; - - /* TODO attempt dynamic interrupt coalescing scheme */ - u16 interrupt_coalesce_number; - u32 interrupt_coalesce_timeout; - struct smu_registers __iomem *smu_registers; - struct scu_registers __iomem *scu_registers; - - u16 tci_head; - u16 tci_tail; - u16 tci_pool[SCI_MAX_IO_REQUESTS]; - - int id; /* unique within a given pci device */ - struct isci_phy phys[SCI_MAX_PHYS]; - struct isci_port ports[SCI_MAX_PORTS + 1]; /* includes dummy port */ - struct sas_ha_struct sas_ha; - - spinlock_t state_lock; - struct pci_dev *pdev; - enum isci_status status; - #define IHOST_START_PENDING 0 - #define IHOST_STOP_PENDING 1 - unsigned long flags; - wait_queue_head_t eventq; - struct Scsi_Host *shost; - struct tasklet_struct completion_tasklet; - struct list_head requests_to_complete; - struct list_head requests_to_errorback; - spinlock_t scic_lock; - struct isci_request *reqs[SCI_MAX_IO_REQUESTS]; - struct isci_remote_device devices[SCI_MAX_REMOTE_DEVICES]; -}; - -/** - * enum sci_controller_states - This enumeration depicts all the states - * for the common controller state machine. - */ -enum sci_controller_states { - /** - * Simply the initial state for the base controller state machine. - */ - SCIC_INITIAL = 0, - - /** - * This state indicates that the controller is reset. The memory for - * the controller is in it's initial state, but the controller requires - * initialization. - * This state is entered from the INITIAL state. - * This state is entered from the RESETTING state. - */ - SCIC_RESET, - - /** - * This state is typically an action state that indicates the controller - * is in the process of initialization. In this state no new IO operations - * are permitted. - * This state is entered from the RESET state. - */ - SCIC_INITIALIZING, - - /** - * This state indicates that the controller has been successfully - * initialized. In this state no new IO operations are permitted. - * This state is entered from the INITIALIZING state. - */ - SCIC_INITIALIZED, - - /** - * This state indicates the the controller is in the process of becoming - * ready (i.e. starting). In this state no new IO operations are permitted. - * This state is entered from the INITIALIZED state. - */ - SCIC_STARTING, - - /** - * This state indicates the controller is now ready. Thus, the user - * is able to perform IO operations on the controller. - * This state is entered from the STARTING state. - */ - SCIC_READY, - - /** - * This state is typically an action state that indicates the controller - * is in the process of resetting. Thus, the user is unable to perform - * IO operations on the controller. A reset is considered destructive in - * most cases. - * This state is entered from the READY state. - * This state is entered from the FAILED state. - * This state is entered from the STOPPED state. - */ - SCIC_RESETTING, - - /** - * This state indicates that the controller is in the process of stopping. - * In this state no new IO operations are permitted, but existing IO - * operations are allowed to complete. - * This state is entered from the READY state. - */ - SCIC_STOPPING, - - /** - * This state indicates that the controller has successfully been stopped. - * In this state no new IO operations are permitted. - * This state is entered from the STOPPING state. - */ - SCIC_STOPPED, - - /** - * This state indicates that the controller could not successfully be - * initialized. In this state no new IO operations are permitted. - * This state is entered from the INITIALIZING state. - * This state is entered from the STARTING state. - * This state is entered from the STOPPING state. - * This state is entered from the RESETTING state. - */ - SCIC_FAILED, -}; - -/** - * struct isci_pci_info - This class represents the pci function containing the - * controllers. Depending on PCI SKU, there could be up to 2 controllers in - * the PCI function. - */ -#define SCI_MAX_MSIX_INT (SCI_NUM_MSI_X_INT*SCI_MAX_CONTROLLERS) - -struct isci_pci_info { - struct msix_entry msix_entries[SCI_MAX_MSIX_INT]; - struct isci_host *hosts[SCI_MAX_CONTROLLERS]; - struct isci_orom *orom; -}; - -static inline struct isci_pci_info *to_pci_info(struct pci_dev *pdev) -{ - return pci_get_drvdata(pdev); -} - -#define for_each_isci_host(id, ihost, pdev) \ - for (id = 0, ihost = to_pci_info(pdev)->hosts[id]; \ - id < ARRAY_SIZE(to_pci_info(pdev)->hosts) && ihost; \ - ihost = to_pci_info(pdev)->hosts[++id]) - -static inline enum isci_status isci_host_get_state(struct isci_host *isci_host) -{ - return isci_host->status; -} - -static inline void isci_host_change_state(struct isci_host *isci_host, - enum isci_status status) -{ - unsigned long flags; - - dev_dbg(&isci_host->pdev->dev, - "%s: isci_host = %p, state = 0x%x", - __func__, - isci_host, - status); - spin_lock_irqsave(&isci_host->state_lock, flags); - isci_host->status = status; - spin_unlock_irqrestore(&isci_host->state_lock, flags); - -} - -static inline void wait_for_start(struct isci_host *ihost) -{ - wait_event(ihost->eventq, !test_bit(IHOST_START_PENDING, &ihost->flags)); -} - -static inline void wait_for_stop(struct isci_host *ihost) -{ - wait_event(ihost->eventq, !test_bit(IHOST_STOP_PENDING, &ihost->flags)); -} - -static inline void wait_for_device_start(struct isci_host *ihost, struct isci_remote_device *idev) -{ - wait_event(ihost->eventq, !test_bit(IDEV_START_PENDING, &idev->flags)); -} - -static inline void wait_for_device_stop(struct isci_host *ihost, struct isci_remote_device *idev) -{ - wait_event(ihost->eventq, !test_bit(IDEV_STOP_PENDING, &idev->flags)); -} - -static inline struct isci_host *dev_to_ihost(struct domain_device *dev) -{ - return dev->port->ha->lldd_ha; -} - -/* we always use protocol engine group zero */ -#define ISCI_PEG 0 - -/* see sci_controller_io_tag_allocate|free for how seq and tci are built */ -#define ISCI_TAG(seq, tci) (((u16) (seq)) << 12 | tci) - -/* these are returned by the hardware, so sanitize them */ -#define ISCI_TAG_SEQ(tag) (((tag) >> 12) & (SCI_MAX_SEQ-1)) -#define ISCI_TAG_TCI(tag) ((tag) & (SCI_MAX_IO_REQUESTS-1)) - -/* expander attached sata devices require 3 rnc slots */ -static inline int sci_remote_device_node_count(struct isci_remote_device *idev) -{ - struct domain_device *dev = idev->domain_dev; - - if ((dev->dev_type == SATA_DEV || (dev->tproto & SAS_PROTOCOL_STP)) && - !idev->is_direct_attached) - return SCU_STP_REMOTE_NODE_COUNT; - return SCU_SSP_REMOTE_NODE_COUNT; -} - -/** - * sci_controller_clear_invalid_phy() - - * - * This macro will clear the bit in the invalid phy mask for this controller - * object. This is used to control messages reported for invalid link up - * notifications. - */ -#define sci_controller_clear_invalid_phy(controller, phy) \ - ((controller)->invalid_phy_mask &= ~(1 << (phy)->phy_index)) - -static inline struct device *sciphy_to_dev(struct isci_phy *iphy) -{ - - if (!iphy || !iphy->isci_port || !iphy->isci_port->isci_host) - return NULL; - - return &iphy->isci_port->isci_host->pdev->dev; -} - -static inline struct device *sciport_to_dev(struct isci_port *iport) -{ - - if (!iport || !iport->isci_host) - return NULL; - - return &iport->isci_host->pdev->dev; -} - -static inline struct device *scirdev_to_dev(struct isci_remote_device *idev) -{ - if (!idev || !idev->isci_port || !idev->isci_port->isci_host) - return NULL; - - return &idev->isci_port->isci_host->pdev->dev; -} - -static inline bool is_a2(struct pci_dev *pdev) -{ - if (pdev->revision < 4) - return true; - return false; -} - -static inline bool is_b0(struct pci_dev *pdev) -{ - if (pdev->revision == 4) - return true; - return false; -} - -static inline bool is_c0(struct pci_dev *pdev) -{ - if (pdev->revision >= 5) - return true; - return false; -} - -void sci_controller_post_request(struct isci_host *ihost, - u32 request); -void sci_controller_release_frame(struct isci_host *ihost, - u32 frame_index); -void sci_controller_copy_sata_response(void *response_buffer, - void *frame_header, - void *frame_buffer); -enum sci_status sci_controller_allocate_remote_node_context(struct isci_host *ihost, - struct isci_remote_device *idev, - u16 *node_id); -void sci_controller_free_remote_node_context( - struct isci_host *ihost, - struct isci_remote_device *idev, - u16 node_id); - -struct isci_request *sci_request_by_tag(struct isci_host *ihost, - u16 io_tag); - -void sci_controller_power_control_queue_insert( - struct isci_host *ihost, - struct isci_phy *iphy); - -void sci_controller_power_control_queue_remove( - struct isci_host *ihost, - struct isci_phy *iphy); - -void sci_controller_link_up( - struct isci_host *ihost, - struct isci_port *iport, - struct isci_phy *iphy); - -void sci_controller_link_down( - struct isci_host *ihost, - struct isci_port *iport, - struct isci_phy *iphy); - -void sci_controller_remote_device_stopped( - struct isci_host *ihost, - struct isci_remote_device *idev); - -void sci_controller_copy_task_context( - struct isci_host *ihost, - struct isci_request *ireq); - -void sci_controller_register_setup(struct isci_host *ihost); - -enum sci_status sci_controller_continue_io(struct isci_request *ireq); -int isci_host_scan_finished(struct Scsi_Host *, unsigned long); -void isci_host_scan_start(struct Scsi_Host *); -u16 isci_alloc_tag(struct isci_host *ihost); -enum sci_status isci_free_tag(struct isci_host *ihost, u16 io_tag); -void isci_tci_free(struct isci_host *ihost, u16 tci); - -int isci_host_init(struct isci_host *); - -void isci_host_init_controller_names( - struct isci_host *isci_host, - unsigned int controller_idx); - -void isci_host_deinit( - struct isci_host *); - -void isci_host_port_link_up( - struct isci_host *, - struct isci_port *, - struct isci_phy *); -int isci_host_dev_found(struct domain_device *); - -void isci_host_remote_device_start_complete( - struct isci_host *, - struct isci_remote_device *, - enum sci_status); - -void sci_controller_disable_interrupts( - struct isci_host *ihost); - -enum sci_status sci_controller_start_io( - struct isci_host *ihost, - struct isci_remote_device *idev, - struct isci_request *ireq); - -enum sci_task_status sci_controller_start_task( - struct isci_host *ihost, - struct isci_remote_device *idev, - struct isci_request *ireq); - -enum sci_status sci_controller_terminate_request( - struct isci_host *ihost, - struct isci_remote_device *idev, - struct isci_request *ireq); - -enum sci_status sci_controller_complete_io( - struct isci_host *ihost, - struct isci_remote_device *idev, - struct isci_request *ireq); - -void sci_port_configuration_agent_construct( - struct sci_port_configuration_agent *port_agent); - -enum sci_status sci_port_configuration_agent_initialize( - struct isci_host *ihost, - struct sci_port_configuration_agent *port_agent); -#endif diff --git a/trunk/drivers/scsi/isci/init.c b/trunk/drivers/scsi/isci/init.c deleted file mode 100644 index 61e0d09e2b57..000000000000 --- a/trunk/drivers/scsi/isci/init.c +++ /dev/null @@ -1,565 +0,0 @@ -/* - * This file is provided under a dual BSD/GPLv2 license. When using or - * redistributing this file, you may do so under either license. - * - * GPL LICENSE SUMMARY - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License 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., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. - * The full GNU General Public License is included in this distribution - * in the file called LICENSE.GPL. - * - * BSD LICENSE - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Intel Corporation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include -#include -#include "isci.h" -#include "task.h" -#include "probe_roms.h" - -static struct scsi_transport_template *isci_transport_template; - -static DEFINE_PCI_DEVICE_TABLE(isci_id_table) = { - { PCI_VDEVICE(INTEL, 0x1D61),}, - { PCI_VDEVICE(INTEL, 0x1D63),}, - { PCI_VDEVICE(INTEL, 0x1D65),}, - { PCI_VDEVICE(INTEL, 0x1D67),}, - { PCI_VDEVICE(INTEL, 0x1D69),}, - { PCI_VDEVICE(INTEL, 0x1D6B),}, - { PCI_VDEVICE(INTEL, 0x1D60),}, - { PCI_VDEVICE(INTEL, 0x1D62),}, - { PCI_VDEVICE(INTEL, 0x1D64),}, - { PCI_VDEVICE(INTEL, 0x1D66),}, - { PCI_VDEVICE(INTEL, 0x1D68),}, - { PCI_VDEVICE(INTEL, 0x1D6A),}, - {} -}; - -MODULE_DEVICE_TABLE(pci, isci_id_table); - -/* linux isci specific settings */ - -unsigned char no_outbound_task_to = 20; -module_param(no_outbound_task_to, byte, 0); -MODULE_PARM_DESC(no_outbound_task_to, "No Outbound Task Timeout (1us incr)"); - -u16 ssp_max_occ_to = 20; -module_param(ssp_max_occ_to, ushort, 0); -MODULE_PARM_DESC(ssp_max_occ_to, "SSP Max occupancy timeout (100us incr)"); - -u16 stp_max_occ_to = 5; -module_param(stp_max_occ_to, ushort, 0); -MODULE_PARM_DESC(stp_max_occ_to, "STP Max occupancy timeout (100us incr)"); - -u16 ssp_inactive_to = 5; -module_param(ssp_inactive_to, ushort, 0); -MODULE_PARM_DESC(ssp_inactive_to, "SSP inactivity timeout (100us incr)"); - -u16 stp_inactive_to = 5; -module_param(stp_inactive_to, ushort, 0); -MODULE_PARM_DESC(stp_inactive_to, "STP inactivity timeout (100us incr)"); - -unsigned char phy_gen = 3; -module_param(phy_gen, byte, 0); -MODULE_PARM_DESC(phy_gen, "PHY generation (1: 1.5Gbps 2: 3.0Gbps 3: 6.0Gbps)"); - -unsigned char max_concurr_spinup = 1; -module_param(max_concurr_spinup, byte, 0); -MODULE_PARM_DESC(max_concurr_spinup, "Max concurrent device spinup"); - -static struct scsi_host_template isci_sht = { - - .module = THIS_MODULE, - .name = DRV_NAME, - .proc_name = DRV_NAME, - .queuecommand = sas_queuecommand, - .target_alloc = sas_target_alloc, - .slave_configure = sas_slave_configure, - .slave_destroy = sas_slave_destroy, - .scan_finished = isci_host_scan_finished, - .scan_start = isci_host_scan_start, - .change_queue_depth = sas_change_queue_depth, - .change_queue_type = sas_change_queue_type, - .bios_param = sas_bios_param, - .can_queue = ISCI_CAN_QUEUE_VAL, - .cmd_per_lun = 1, - .this_id = -1, - .sg_tablesize = SG_ALL, - .max_sectors = SCSI_DEFAULT_MAX_SECTORS, - .use_clustering = ENABLE_CLUSTERING, - .eh_device_reset_handler = sas_eh_device_reset_handler, - .eh_bus_reset_handler = isci_bus_reset_handler, - .slave_alloc = sas_slave_alloc, - .target_destroy = sas_target_destroy, - .ioctl = sas_ioctl, -}; - -static struct sas_domain_function_template isci_transport_ops = { - - /* The class calls these to notify the LLDD of an event. */ - .lldd_port_formed = isci_port_formed, - .lldd_port_deformed = isci_port_deformed, - - /* The class calls these when a device is found or gone. */ - .lldd_dev_found = isci_remote_device_found, - .lldd_dev_gone = isci_remote_device_gone, - - .lldd_execute_task = isci_task_execute_task, - /* Task Management Functions. Must be called from process context. */ - .lldd_abort_task = isci_task_abort_task, - .lldd_abort_task_set = isci_task_abort_task_set, - .lldd_clear_aca = isci_task_clear_aca, - .lldd_clear_task_set = isci_task_clear_task_set, - .lldd_I_T_nexus_reset = isci_task_I_T_nexus_reset, - .lldd_lu_reset = isci_task_lu_reset, - .lldd_query_task = isci_task_query_task, - - /* Port and Adapter management */ - .lldd_clear_nexus_port = isci_task_clear_nexus_port, - .lldd_clear_nexus_ha = isci_task_clear_nexus_ha, - - /* Phy management */ - .lldd_control_phy = isci_phy_control, -}; - - -/****************************************************************************** -* P R O T E C T E D M E T H O D S -******************************************************************************/ - - - -/** - * isci_register_sas_ha() - This method initializes various lldd - * specific members of the sas_ha struct and calls the libsas - * sas_register_ha() function. - * @isci_host: This parameter specifies the lldd specific wrapper for the - * libsas sas_ha struct. - * - * This method returns an error code indicating sucess or failure. The user - * should check for possible memory allocation error return otherwise, a zero - * indicates success. - */ -static int isci_register_sas_ha(struct isci_host *isci_host) -{ - int i; - struct sas_ha_struct *sas_ha = &(isci_host->sas_ha); - struct asd_sas_phy **sas_phys; - struct asd_sas_port **sas_ports; - - sas_phys = devm_kzalloc(&isci_host->pdev->dev, - SCI_MAX_PHYS * sizeof(void *), - GFP_KERNEL); - if (!sas_phys) - return -ENOMEM; - - sas_ports = devm_kzalloc(&isci_host->pdev->dev, - SCI_MAX_PORTS * sizeof(void *), - GFP_KERNEL); - if (!sas_ports) - return -ENOMEM; - - /*----------------- Libsas Initialization Stuff---------------------- - * Set various fields in the sas_ha struct: - */ - - sas_ha->sas_ha_name = DRV_NAME; - sas_ha->lldd_module = THIS_MODULE; - sas_ha->sas_addr = &isci_host->phys[0].sas_addr[0]; - - /* set the array of phy and port structs. */ - for (i = 0; i < SCI_MAX_PHYS; i++) { - sas_phys[i] = &isci_host->phys[i].sas_phy; - sas_ports[i] = &isci_host->ports[i].sas_port; - } - - sas_ha->sas_phy = sas_phys; - sas_ha->sas_port = sas_ports; - sas_ha->num_phys = SCI_MAX_PHYS; - - sas_ha->lldd_queue_size = ISCI_CAN_QUEUE_VAL; - sas_ha->lldd_max_execute_num = 1; - sas_ha->strict_wide_ports = 1; - - sas_register_ha(sas_ha); - - return 0; -} - -static ssize_t isci_show_id(struct device *dev, struct device_attribute *attr, char *buf) -{ - struct Scsi_Host *shost = container_of(dev, typeof(*shost), shost_dev); - struct sas_ha_struct *sas_ha = SHOST_TO_SAS_HA(shost); - struct isci_host *ihost = container_of(sas_ha, typeof(*ihost), sas_ha); - - return snprintf(buf, PAGE_SIZE, "%d\n", ihost->id); -} - -static DEVICE_ATTR(isci_id, S_IRUGO, isci_show_id, NULL); - -static void isci_unregister(struct isci_host *isci_host) -{ - struct Scsi_Host *shost; - - if (!isci_host) - return; - - shost = isci_host->shost; - device_remove_file(&shost->shost_dev, &dev_attr_isci_id); - - sas_unregister_ha(&isci_host->sas_ha); - - sas_remove_host(isci_host->shost); - scsi_remove_host(isci_host->shost); - scsi_host_put(isci_host->shost); -} - -static int __devinit isci_pci_init(struct pci_dev *pdev) -{ - int err, bar_num, bar_mask = 0; - void __iomem * const *iomap; - - err = pcim_enable_device(pdev); - if (err) { - dev_err(&pdev->dev, - "failed enable PCI device %s!\n", - pci_name(pdev)); - return err; - } - - for (bar_num = 0; bar_num < SCI_PCI_BAR_COUNT; bar_num++) - bar_mask |= 1 << (bar_num * 2); - - err = pcim_iomap_regions(pdev, bar_mask, DRV_NAME); - if (err) - return err; - - iomap = pcim_iomap_table(pdev); - if (!iomap) - return -ENOMEM; - - pci_set_master(pdev); - - err = pci_set_dma_mask(pdev, DMA_BIT_MASK(64)); - if (err) { - err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)); - if (err) - return err; - } - - err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64)); - if (err) { - err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32)); - if (err) - return err; - } - - return 0; -} - -static int num_controllers(struct pci_dev *pdev) -{ - /* bar size alone can tell us if we are running with a dual controller - * part, no need to trust revision ids that might be under broken firmware - * control - */ - resource_size_t scu_bar_size = pci_resource_len(pdev, SCI_SCU_BAR*2); - resource_size_t smu_bar_size = pci_resource_len(pdev, SCI_SMU_BAR*2); - - if (scu_bar_size >= SCI_SCU_BAR_SIZE*SCI_MAX_CONTROLLERS && - smu_bar_size >= SCI_SMU_BAR_SIZE*SCI_MAX_CONTROLLERS) - return SCI_MAX_CONTROLLERS; - else - return 1; -} - -static int isci_setup_interrupts(struct pci_dev *pdev) -{ - int err, i, num_msix; - struct isci_host *ihost; - struct isci_pci_info *pci_info = to_pci_info(pdev); - - /* - * Determine the number of vectors associated with this - * PCI function. - */ - num_msix = num_controllers(pdev) * SCI_NUM_MSI_X_INT; - - for (i = 0; i < num_msix; i++) - pci_info->msix_entries[i].entry = i; - - err = pci_enable_msix(pdev, pci_info->msix_entries, num_msix); - if (err) - goto intx; - - for (i = 0; i < num_msix; i++) { - int id = i / SCI_NUM_MSI_X_INT; - struct msix_entry *msix = &pci_info->msix_entries[i]; - irq_handler_t isr; - - ihost = pci_info->hosts[id]; - /* odd numbered vectors are error interrupts */ - if (i & 1) - isr = isci_error_isr; - else - isr = isci_msix_isr; - - err = devm_request_irq(&pdev->dev, msix->vector, isr, 0, - DRV_NAME"-msix", ihost); - if (!err) - continue; - - dev_info(&pdev->dev, "msix setup failed falling back to intx\n"); - while (i--) { - id = i / SCI_NUM_MSI_X_INT; - ihost = pci_info->hosts[id]; - msix = &pci_info->msix_entries[i]; - devm_free_irq(&pdev->dev, msix->vector, ihost); - } - pci_disable_msix(pdev); - goto intx; - } - return 0; - - intx: - for_each_isci_host(i, ihost, pdev) { - err = devm_request_irq(&pdev->dev, pdev->irq, isci_intx_isr, - IRQF_SHARED, DRV_NAME"-intx", ihost); - if (err) - break; - } - return err; -} - -static struct isci_host *isci_host_alloc(struct pci_dev *pdev, int id) -{ - struct isci_host *isci_host; - struct Scsi_Host *shost; - int err; - - isci_host = devm_kzalloc(&pdev->dev, sizeof(*isci_host), GFP_KERNEL); - if (!isci_host) - return NULL; - - isci_host->pdev = pdev; - isci_host->id = id; - - shost = scsi_host_alloc(&isci_sht, sizeof(void *)); - if (!shost) - return NULL; - isci_host->shost = shost; - - err = isci_host_init(isci_host); - if (err) - goto err_shost; - - SHOST_TO_SAS_HA(shost) = &isci_host->sas_ha; - isci_host->sas_ha.core.shost = shost; - shost->transportt = isci_transport_template; - - shost->max_id = ~0; - shost->max_lun = ~0; - shost->max_cmd_len = MAX_COMMAND_SIZE; - - err = scsi_add_host(shost, &pdev->dev); - if (err) - goto err_shost; - - err = isci_register_sas_ha(isci_host); - if (err) - goto err_shost_remove; - - err = device_create_file(&shost->shost_dev, &dev_attr_isci_id); - if (err) - goto err_unregister_ha; - - return isci_host; - - err_unregister_ha: - sas_unregister_ha(&(isci_host->sas_ha)); - err_shost_remove: - scsi_remove_host(shost); - err_shost: - scsi_host_put(shost); - - return NULL; -} - -static int __devinit isci_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) -{ - struct isci_pci_info *pci_info; - int err, i; - struct isci_host *isci_host; - const struct firmware *fw = NULL; - struct isci_orom *orom = NULL; - char *source = "(platform)"; - - dev_info(&pdev->dev, "driver configured for rev: %d silicon\n", - pdev->revision); - - pci_info = devm_kzalloc(&pdev->dev, sizeof(*pci_info), GFP_KERNEL); - if (!pci_info) - return -ENOMEM; - pci_set_drvdata(pdev, pci_info); - - if (efi_enabled) - orom = isci_get_efi_var(pdev); - - if (!orom) - orom = isci_request_oprom(pdev); - - for (i = 0; orom && i < ARRAY_SIZE(orom->ctrl); i++) { - if (sci_oem_parameters_validate(&orom->ctrl[i])) { - dev_warn(&pdev->dev, - "[%d]: invalid oem parameters detected, falling back to firmware\n", i); - devm_kfree(&pdev->dev, orom); - orom = NULL; - break; - } - } - - if (!orom) { - source = "(firmware)"; - orom = isci_request_firmware(pdev, fw); - if (!orom) { - /* TODO convert this to WARN_TAINT_ONCE once the - * orom/efi parameter support is widely available - */ - dev_warn(&pdev->dev, - "Loading user firmware failed, using default " - "values\n"); - dev_warn(&pdev->dev, - "Default OEM configuration being used: 4 " - "narrow ports, and default SAS Addresses\n"); - } - } - - if (orom) - dev_info(&pdev->dev, - "OEM SAS parameters (version: %u.%u) loaded %s\n", - (orom->hdr.version & 0xf0) >> 4, - (orom->hdr.version & 0xf), source); - - pci_info->orom = orom; - - err = isci_pci_init(pdev); - if (err) - return err; - - for (i = 0; i < num_controllers(pdev); i++) { - struct isci_host *h = isci_host_alloc(pdev, i); - - if (!h) { - err = -ENOMEM; - goto err_host_alloc; - } - pci_info->hosts[i] = h; - } - - err = isci_setup_interrupts(pdev); - if (err) - goto err_host_alloc; - - for_each_isci_host(i, isci_host, pdev) - scsi_scan_host(isci_host->shost); - - return 0; - - err_host_alloc: - for_each_isci_host(i, isci_host, pdev) - isci_unregister(isci_host); - return err; -} - -static void __devexit isci_pci_remove(struct pci_dev *pdev) -{ - struct isci_host *ihost; - int i; - - for_each_isci_host(i, ihost, pdev) { - isci_unregister(ihost); - isci_host_deinit(ihost); - sci_controller_disable_interrupts(ihost); - } -} - -static struct pci_driver isci_pci_driver = { - .name = DRV_NAME, - .id_table = isci_id_table, - .probe = isci_pci_probe, - .remove = __devexit_p(isci_pci_remove), -}; - -static __init int isci_init(void) -{ - int err; - - pr_info("%s: Intel(R) C600 SAS Controller Driver\n", DRV_NAME); - - isci_transport_template = sas_domain_attach_transport(&isci_transport_ops); - if (!isci_transport_template) - return -ENOMEM; - - err = pci_register_driver(&isci_pci_driver); - if (err) - sas_release_transport(isci_transport_template); - - return err; -} - -static __exit void isci_exit(void) -{ - pci_unregister_driver(&isci_pci_driver); - sas_release_transport(isci_transport_template); -} - -MODULE_LICENSE("Dual BSD/GPL"); -MODULE_FIRMWARE(ISCI_FW_NAME); -module_init(isci_init); -module_exit(isci_exit); diff --git a/trunk/drivers/scsi/isci/isci.h b/trunk/drivers/scsi/isci/isci.h deleted file mode 100644 index d1de63312e7f..000000000000 --- a/trunk/drivers/scsi/isci/isci.h +++ /dev/null @@ -1,538 +0,0 @@ -/* - * This file is provided under a dual BSD/GPLv2 license. When using or - * redistributing this file, you may do so under either license. - * - * GPL LICENSE SUMMARY - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License 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., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. - * The full GNU General Public License is included in this distribution - * in the file called LICENSE.GPL. - * - * BSD LICENSE - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Intel Corporation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef __ISCI_H__ -#define __ISCI_H__ - -#include -#include - -#define DRV_NAME "isci" -#define SCI_PCI_BAR_COUNT 2 -#define SCI_NUM_MSI_X_INT 2 -#define SCI_SMU_BAR 0 -#define SCI_SMU_BAR_SIZE (16*1024) -#define SCI_SCU_BAR 1 -#define SCI_SCU_BAR_SIZE (4*1024*1024) -#define SCI_IO_SPACE_BAR0 2 -#define SCI_IO_SPACE_BAR1 3 -#define ISCI_CAN_QUEUE_VAL 250 /* < SCI_MAX_IO_REQUESTS ? */ -#define SCIC_CONTROLLER_STOP_TIMEOUT 5000 - -#define SCI_CONTROLLER_INVALID_IO_TAG 0xFFFF - -#define SCI_MAX_PHYS (4UL) -#define SCI_MAX_PORTS SCI_MAX_PHYS -#define SCI_MAX_SMP_PHYS (384) /* not silicon constrained */ -#define SCI_MAX_REMOTE_DEVICES (256UL) -#define SCI_MAX_IO_REQUESTS (256UL) -#define SCI_MAX_SEQ (16) -#define SCI_MAX_MSIX_MESSAGES (2) -#define SCI_MAX_SCATTER_GATHER_ELEMENTS 130 /* not silicon constrained */ -#define SCI_MAX_CONTROLLERS 2 -#define SCI_MAX_DOMAINS SCI_MAX_PORTS - -#define SCU_MAX_CRITICAL_NOTIFICATIONS (384) -#define SCU_MAX_EVENTS_SHIFT (7) -#define SCU_MAX_EVENTS (1 << SCU_MAX_EVENTS_SHIFT) -#define SCU_MAX_UNSOLICITED_FRAMES (128) -#define SCU_MAX_COMPLETION_QUEUE_SCRATCH (128) -#define SCU_MAX_COMPLETION_QUEUE_ENTRIES (SCU_MAX_CRITICAL_NOTIFICATIONS \ - + SCU_MAX_EVENTS \ - + SCU_MAX_UNSOLICITED_FRAMES \ - + SCI_MAX_IO_REQUESTS \ - + SCU_MAX_COMPLETION_QUEUE_SCRATCH) -#define SCU_MAX_COMPLETION_QUEUE_SHIFT (ilog2(SCU_MAX_COMPLETION_QUEUE_ENTRIES)) - -#define SCU_ABSOLUTE_MAX_UNSOLICITED_FRAMES (4096) -#define SCU_UNSOLICITED_FRAME_BUFFER_SIZE (1024) -#define SCU_INVALID_FRAME_INDEX (0xFFFF) - -#define SCU_IO_REQUEST_MAX_SGE_SIZE (0x00FFFFFF) -#define SCU_IO_REQUEST_MAX_TRANSFER_LENGTH (0x00FFFFFF) - -static inline void check_sizes(void) -{ - BUILD_BUG_ON_NOT_POWER_OF_2(SCU_MAX_EVENTS); - BUILD_BUG_ON(SCU_MAX_UNSOLICITED_FRAMES <= 8); - BUILD_BUG_ON_NOT_POWER_OF_2(SCU_MAX_UNSOLICITED_FRAMES); - BUILD_BUG_ON_NOT_POWER_OF_2(SCU_MAX_COMPLETION_QUEUE_ENTRIES); - BUILD_BUG_ON(SCU_MAX_UNSOLICITED_FRAMES > SCU_ABSOLUTE_MAX_UNSOLICITED_FRAMES); - BUILD_BUG_ON_NOT_POWER_OF_2(SCI_MAX_IO_REQUESTS); - BUILD_BUG_ON_NOT_POWER_OF_2(SCI_MAX_SEQ); -} - -/** - * enum sci_status - This is the general return status enumeration for non-IO, - * non-task management related SCI interface methods. - * - * - */ -enum sci_status { - /** - * This member indicates successful completion. - */ - SCI_SUCCESS = 0, - - /** - * This value indicates that the calling method completed successfully, - * but that the IO may have completed before having it's start method - * invoked. This occurs during SAT translation for requests that do - * not require an IO to the target or for any other requests that may - * be completed without having to submit IO. - */ - SCI_SUCCESS_IO_COMPLETE_BEFORE_START, - - /** - * This Value indicates that the SCU hardware returned an early response - * because the io request specified more data than is returned by the - * target device (mode pages, inquiry data, etc.). The completion routine - * will handle this case to get the actual number of bytes transferred. - */ - SCI_SUCCESS_IO_DONE_EARLY, - - /** - * This member indicates that the object for which a state change is - * being requested is already in said state. - */ - SCI_WARNING_ALREADY_IN_STATE, - - /** - * This member indicates interrupt coalescence timer may cause SAS - * specification compliance issues (i.e. SMP target mode response - * frames must be returned within 1.9 milliseconds). - */ - SCI_WARNING_TIMER_CONFLICT, - - /** - * This field indicates a sequence of action is not completed yet. Mostly, - * this status is used when multiple ATA commands are needed in a SATI translation. - */ - SCI_WARNING_SEQUENCE_INCOMPLETE, - - /** - * This member indicates that there was a general failure. - */ - SCI_FAILURE, - - /** - * This member indicates that the SCI implementation is unable to complete - * an operation due to a critical flaw the prevents any further operation - * (i.e. an invalid pointer). - */ - SCI_FATAL_ERROR, - - /** - * This member indicates the calling function failed, because the state - * of the controller is in a state that prevents successful completion. - */ - SCI_FAILURE_INVALID_STATE, - - /** - * This member indicates the calling function failed, because there is - * insufficient resources/memory to complete the request. - */ - SCI_FAILURE_INSUFFICIENT_RESOURCES, - - /** - * This member indicates the calling function failed, because the - * controller object required for the operation can't be located. - */ - SCI_FAILURE_CONTROLLER_NOT_FOUND, - - /** - * This member indicates the calling function failed, because the - * discovered controller type is not supported by the library. - */ - SCI_FAILURE_UNSUPPORTED_CONTROLLER_TYPE, - - /** - * This member indicates the calling function failed, because the - * requested initialization data version isn't supported. - */ - SCI_FAILURE_UNSUPPORTED_INIT_DATA_VERSION, - - /** - * This member indicates the calling function failed, because the - * requested configuration of SAS Phys into SAS Ports is not supported. - */ - SCI_FAILURE_UNSUPPORTED_PORT_CONFIGURATION, - - /** - * This member indicates the calling function failed, because the - * requested protocol is not supported by the remote device, port, - * or controller. - */ - SCI_FAILURE_UNSUPPORTED_PROTOCOL, - - /** - * This member indicates the calling function failed, because the - * requested information type is not supported by the SCI implementation. - */ - SCI_FAILURE_UNSUPPORTED_INFORMATION_TYPE, - - /** - * This member indicates the calling function failed, because the - * device already exists. - */ - SCI_FAILURE_DEVICE_EXISTS, - - /** - * This member indicates the calling function failed, because adding - * a phy to the object is not possible. - */ - SCI_FAILURE_ADDING_PHY_UNSUPPORTED, - - /** - * This member indicates the calling function failed, because the - * requested information type is not supported by the SCI implementation. - */ - SCI_FAILURE_UNSUPPORTED_INFORMATION_FIELD, - - /** - * This member indicates the calling function failed, because the SCI - * implementation does not support the supplied time limit. - */ - SCI_FAILURE_UNSUPPORTED_TIME_LIMIT, - - /** - * This member indicates the calling method failed, because the SCI - * implementation does not contain the specified Phy. - */ - SCI_FAILURE_INVALID_PHY, - - /** - * This member indicates the calling method failed, because the SCI - * implementation does not contain the specified Port. - */ - SCI_FAILURE_INVALID_PORT, - - /** - * This member indicates the calling method was partly successful - * The port was reset but not all phys in port are operational - */ - SCI_FAILURE_RESET_PORT_PARTIAL_SUCCESS, - - /** - * This member indicates that calling method failed - * The port reset did not complete because none of the phys are operational - */ - SCI_FAILURE_RESET_PORT_FAILURE, - - /** - * This member indicates the calling method failed, because the SCI - * implementation does not contain the specified remote device. - */ - SCI_FAILURE_INVALID_REMOTE_DEVICE, - - /** - * This member indicates the calling method failed, because the remote - * device is in a bad state and requires a reset. - */ - SCI_FAILURE_REMOTE_DEVICE_RESET_REQUIRED, - - /** - * This member indicates the calling method failed, because the SCI - * implementation does not contain or support the specified IO tag. - */ - SCI_FAILURE_INVALID_IO_TAG, - - /** - * This member indicates that the operation failed and the user should - * check the response data associated with the IO. - */ - SCI_FAILURE_IO_RESPONSE_VALID, - - /** - * This member indicates that the operation failed, the failure is - * controller implementation specific, and the response data associated - * with the request is not valid. You can query for the controller - * specific error information via sci_controller_get_request_status() - */ - SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR, - - /** - * This member indicated that the operation failed because the - * user requested this IO to be terminated. - */ - SCI_FAILURE_IO_TERMINATED, - - /** - * This member indicates that the operation failed and the associated - * request requires a SCSI abort task to be sent to the target. - */ - SCI_FAILURE_IO_REQUIRES_SCSI_ABORT, - - /** - * This member indicates that the operation failed because the supplied - * device could not be located. - */ - SCI_FAILURE_DEVICE_NOT_FOUND, - - /** - * This member indicates that the operation failed because the - * objects association is required and is not correctly set. - */ - SCI_FAILURE_INVALID_ASSOCIATION, - - /** - * This member indicates that the operation failed, because a timeout - * occurred. - */ - SCI_FAILURE_TIMEOUT, - - /** - * This member indicates that the operation failed, because the user - * specified a value that is either invalid or not supported. - */ - SCI_FAILURE_INVALID_PARAMETER_VALUE, - - /** - * This value indicates that the operation failed, because the number - * of messages (MSI-X) is not supported. - */ - SCI_FAILURE_UNSUPPORTED_MESSAGE_COUNT, - - /** - * This value indicates that the method failed due to a lack of - * available NCQ tags. - */ - SCI_FAILURE_NO_NCQ_TAG_AVAILABLE, - - /** - * This value indicates that a protocol violation has occurred on the - * link. - */ - SCI_FAILURE_PROTOCOL_VIOLATION, - - /** - * This value indicates a failure condition that retry may help to clear. - */ - SCI_FAILURE_RETRY_REQUIRED, - - /** - * This field indicates the retry limit was reached when a retry is attempted - */ - SCI_FAILURE_RETRY_LIMIT_REACHED, - - /** - * This member indicates the calling method was partly successful. - * Mostly, this status is used when a LUN_RESET issued to an expander attached - * STP device in READY NCQ substate needs to have RNC suspended/resumed - * before posting TC. - */ - SCI_FAILURE_RESET_DEVICE_PARTIAL_SUCCESS, - - /** - * This field indicates an illegal phy connection based on the routing attribute - * of both expander phy attached to each other. - */ - SCI_FAILURE_ILLEGAL_ROUTING_ATTRIBUTE_CONFIGURATION, - - /** - * This field indicates a CONFIG ROUTE INFO command has a response with function result - * INDEX DOES NOT EXIST, usually means exceeding max route index. - */ - SCI_FAILURE_EXCEED_MAX_ROUTE_INDEX, - - /** - * This value indicates that an unsupported PCI device ID has been - * specified. This indicates that attempts to invoke - * sci_library_allocate_controller() will fail. - */ - SCI_FAILURE_UNSUPPORTED_PCI_DEVICE_ID - -}; - -/** - * enum sci_io_status - This enumeration depicts all of the possible IO - * completion status values. Each value in this enumeration maps directly - * to a value in the enum sci_status enumeration. Please refer to that - * enumeration for detailed comments concerning what the status represents. - * - * Add the API to retrieve the SCU status from the core. Check to see that the - * following status are properly handled: - SCI_IO_FAILURE_UNSUPPORTED_PROTOCOL - * - SCI_IO_FAILURE_INVALID_IO_TAG - */ -enum sci_io_status { - SCI_IO_SUCCESS = SCI_SUCCESS, - SCI_IO_FAILURE = SCI_FAILURE, - SCI_IO_SUCCESS_COMPLETE_BEFORE_START = SCI_SUCCESS_IO_COMPLETE_BEFORE_START, - SCI_IO_SUCCESS_IO_DONE_EARLY = SCI_SUCCESS_IO_DONE_EARLY, - SCI_IO_FAILURE_INVALID_STATE = SCI_FAILURE_INVALID_STATE, - SCI_IO_FAILURE_INSUFFICIENT_RESOURCES = SCI_FAILURE_INSUFFICIENT_RESOURCES, - SCI_IO_FAILURE_UNSUPPORTED_PROTOCOL = SCI_FAILURE_UNSUPPORTED_PROTOCOL, - SCI_IO_FAILURE_RESPONSE_VALID = SCI_FAILURE_IO_RESPONSE_VALID, - SCI_IO_FAILURE_CONTROLLER_SPECIFIC_ERR = SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR, - SCI_IO_FAILURE_TERMINATED = SCI_FAILURE_IO_TERMINATED, - SCI_IO_FAILURE_REQUIRES_SCSI_ABORT = SCI_FAILURE_IO_REQUIRES_SCSI_ABORT, - SCI_IO_FAILURE_INVALID_PARAMETER_VALUE = SCI_FAILURE_INVALID_PARAMETER_VALUE, - SCI_IO_FAILURE_NO_NCQ_TAG_AVAILABLE = SCI_FAILURE_NO_NCQ_TAG_AVAILABLE, - SCI_IO_FAILURE_PROTOCOL_VIOLATION = SCI_FAILURE_PROTOCOL_VIOLATION, - - SCI_IO_FAILURE_REMOTE_DEVICE_RESET_REQUIRED = SCI_FAILURE_REMOTE_DEVICE_RESET_REQUIRED, - - SCI_IO_FAILURE_RETRY_REQUIRED = SCI_FAILURE_RETRY_REQUIRED, - SCI_IO_FAILURE_RETRY_LIMIT_REACHED = SCI_FAILURE_RETRY_LIMIT_REACHED, - SCI_IO_FAILURE_INVALID_REMOTE_DEVICE = SCI_FAILURE_INVALID_REMOTE_DEVICE -}; - -/** - * enum sci_task_status - This enumeration depicts all of the possible task - * completion status values. Each value in this enumeration maps directly - * to a value in the enum sci_status enumeration. Please refer to that - * enumeration for detailed comments concerning what the status represents. - * - * Check to see that the following status are properly handled: - */ -enum sci_task_status { - SCI_TASK_SUCCESS = SCI_SUCCESS, - SCI_TASK_FAILURE = SCI_FAILURE, - SCI_TASK_FAILURE_INVALID_STATE = SCI_FAILURE_INVALID_STATE, - SCI_TASK_FAILURE_INSUFFICIENT_RESOURCES = SCI_FAILURE_INSUFFICIENT_RESOURCES, - SCI_TASK_FAILURE_UNSUPPORTED_PROTOCOL = SCI_FAILURE_UNSUPPORTED_PROTOCOL, - SCI_TASK_FAILURE_INVALID_TAG = SCI_FAILURE_INVALID_IO_TAG, - SCI_TASK_FAILURE_RESPONSE_VALID = SCI_FAILURE_IO_RESPONSE_VALID, - SCI_TASK_FAILURE_CONTROLLER_SPECIFIC_ERR = SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR, - SCI_TASK_FAILURE_TERMINATED = SCI_FAILURE_IO_TERMINATED, - SCI_TASK_FAILURE_INVALID_PARAMETER_VALUE = SCI_FAILURE_INVALID_PARAMETER_VALUE, - - SCI_TASK_FAILURE_REMOTE_DEVICE_RESET_REQUIRED = SCI_FAILURE_REMOTE_DEVICE_RESET_REQUIRED, - SCI_TASK_FAILURE_RESET_DEVICE_PARTIAL_SUCCESS = SCI_FAILURE_RESET_DEVICE_PARTIAL_SUCCESS - -}; - -/** - * sci_swab32_cpy - convert between scsi and scu-hardware byte format - * @dest: receive the 4-byte endian swapped version of src - * @src: word aligned source buffer - * - * scu hardware handles SSP/SMP control, response, and unidentified - * frames in "big endian dword" order. Regardless of host endian this - * is always a swab32()-per-dword conversion of the standard definition, - * i.e. single byte fields swapped and multi-byte fields in little- - * endian - */ -static inline void sci_swab32_cpy(void *_dest, void *_src, ssize_t word_cnt) -{ - u32 *dest = _dest, *src = _src; - - while (--word_cnt >= 0) - dest[word_cnt] = swab32(src[word_cnt]); -} - -extern unsigned char no_outbound_task_to; -extern u16 ssp_max_occ_to; -extern u16 stp_max_occ_to; -extern u16 ssp_inactive_to; -extern u16 stp_inactive_to; -extern unsigned char phy_gen; -extern unsigned char max_concurr_spinup; - -irqreturn_t isci_msix_isr(int vec, void *data); -irqreturn_t isci_intx_isr(int vec, void *data); -irqreturn_t isci_error_isr(int vec, void *data); - -/* - * Each timer is associated with a cancellation flag that is set when - * del_timer() is called and checked in the timer callback function. This - * is needed since del_timer_sync() cannot be called with sci_lock held. - * For deinit however, del_timer_sync() is used without holding the lock. - */ -struct sci_timer { - struct timer_list timer; - bool cancel; -}; - -static inline -void sci_init_timer(struct sci_timer *tmr, void (*fn)(unsigned long)) -{ - tmr->timer.function = fn; - tmr->timer.data = (unsigned long) tmr; - tmr->cancel = 0; - init_timer(&tmr->timer); -} - -static inline void sci_mod_timer(struct sci_timer *tmr, unsigned long msec) -{ - tmr->cancel = 0; - mod_timer(&tmr->timer, jiffies + msecs_to_jiffies(msec)); -} - -static inline void sci_del_timer(struct sci_timer *tmr) -{ - tmr->cancel = 1; - del_timer(&tmr->timer); -} - -struct sci_base_state_machine { - const struct sci_base_state *state_table; - u32 initial_state_id; - u32 current_state_id; - u32 previous_state_id; -}; - -typedef void (*sci_state_transition_t)(struct sci_base_state_machine *sm); - -struct sci_base_state { - sci_state_transition_t enter_state; /* Called on state entry */ - sci_state_transition_t exit_state; /* Called on state exit */ -}; - -extern void sci_init_sm(struct sci_base_state_machine *sm, - const struct sci_base_state *state_table, - u32 initial_state); -extern void sci_change_state(struct sci_base_state_machine *sm, u32 next_state); -#endif /* __ISCI_H__ */ diff --git a/trunk/drivers/scsi/isci/phy.c b/trunk/drivers/scsi/isci/phy.c deleted file mode 100644 index 79313a7a2356..000000000000 --- a/trunk/drivers/scsi/isci/phy.c +++ /dev/null @@ -1,1312 +0,0 @@ -/* - * This file is provided under a dual BSD/GPLv2 license. When using or - * redistributing this file, you may do so under either license. - * - * GPL LICENSE SUMMARY - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License 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., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. - * The full GNU General Public License is included in this distribution - * in the file called LICENSE.GPL. - * - * BSD LICENSE - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Intel Corporation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "isci.h" -#include "host.h" -#include "phy.h" -#include "scu_event_codes.h" -#include "probe_roms.h" - -/* Maximum arbitration wait time in micro-seconds */ -#define SCIC_SDS_PHY_MAX_ARBITRATION_WAIT_TIME (700) - -enum sas_linkrate sci_phy_linkrate(struct isci_phy *iphy) -{ - return iphy->max_negotiated_speed; -} - -static enum sci_status -sci_phy_transport_layer_initialization(struct isci_phy *iphy, - struct scu_transport_layer_registers __iomem *reg) -{ - u32 tl_control; - - iphy->transport_layer_registers = reg; - - writel(SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX, - &iphy->transport_layer_registers->stp_rni); - - /* - * Hardware team recommends that we enable the STP prefetch for all - * transports - */ - tl_control = readl(&iphy->transport_layer_registers->control); - tl_control |= SCU_TLCR_GEN_BIT(STP_WRITE_DATA_PREFETCH); - writel(tl_control, &iphy->transport_layer_registers->control); - - return SCI_SUCCESS; -} - -static enum sci_status -sci_phy_link_layer_initialization(struct isci_phy *iphy, - struct scu_link_layer_registers __iomem *reg) -{ - struct isci_host *ihost = iphy->owning_port->owning_controller; - int phy_idx = iphy->phy_index; - struct sci_phy_user_params *phy_user = &ihost->user_parameters.phys[phy_idx]; - struct sci_phy_oem_params *phy_oem = - &ihost->oem_parameters.phys[phy_idx]; - u32 phy_configuration; - struct sci_phy_cap phy_cap; - u32 parity_check = 0; - u32 parity_count = 0; - u32 llctl, link_rate; - u32 clksm_value = 0; - - iphy->link_layer_registers = reg; - - /* Set our IDENTIFY frame data */ - #define SCI_END_DEVICE 0x01 - - writel(SCU_SAS_TIID_GEN_BIT(SMP_INITIATOR) | - SCU_SAS_TIID_GEN_BIT(SSP_INITIATOR) | - SCU_SAS_TIID_GEN_BIT(STP_INITIATOR) | - SCU_SAS_TIID_GEN_BIT(DA_SATA_HOST) | - SCU_SAS_TIID_GEN_VAL(DEVICE_TYPE, SCI_END_DEVICE), - &iphy->link_layer_registers->transmit_identification); - - /* Write the device SAS Address */ - writel(0xFEDCBA98, - &iphy->link_layer_registers->sas_device_name_high); - writel(phy_idx, &iphy->link_layer_registers->sas_device_name_low); - - /* Write the source SAS Address */ - writel(phy_oem->sas_address.high, - &iphy->link_layer_registers->source_sas_address_high); - writel(phy_oem->sas_address.low, - &iphy->link_layer_registers->source_sas_address_low); - - /* Clear and Set the PHY Identifier */ - writel(0, &iphy->link_layer_registers->identify_frame_phy_id); - writel(SCU_SAS_TIPID_GEN_VALUE(ID, phy_idx), - &iphy->link_layer_registers->identify_frame_phy_id); - - /* Change the initial state of the phy configuration register */ - phy_configuration = - readl(&iphy->link_layer_registers->phy_configuration); - - /* Hold OOB state machine in reset */ - phy_configuration |= SCU_SAS_PCFG_GEN_BIT(OOB_RESET); - writel(phy_configuration, - &iphy->link_layer_registers->phy_configuration); - - /* Configure the SNW capabilities */ - phy_cap.all = 0; - phy_cap.start = 1; - phy_cap.gen3_no_ssc = 1; - phy_cap.gen2_no_ssc = 1; - phy_cap.gen1_no_ssc = 1; - if (ihost->oem_parameters.controller.do_enable_ssc == true) { - phy_cap.gen3_ssc = 1; - phy_cap.gen2_ssc = 1; - phy_cap.gen1_ssc = 1; - } - - /* - * The SAS specification indicates that the phy_capabilities that - * are transmitted shall have an even parity. Calculate the parity. */ - parity_check = phy_cap.all; - while (parity_check != 0) { - if (parity_check & 0x1) - parity_count++; - parity_check >>= 1; - } - - /* - * If parity indicates there are an odd number of bits set, then - * set the parity bit to 1 in the phy capabilities. */ - if ((parity_count % 2) != 0) - phy_cap.parity = 1; - - writel(phy_cap.all, &iphy->link_layer_registers->phy_capabilities); - - /* Set the enable spinup period but disable the ability to send - * notify enable spinup - */ - writel(SCU_ENSPINUP_GEN_VAL(COUNT, - phy_user->notify_enable_spin_up_insertion_frequency), - &iphy->link_layer_registers->notify_enable_spinup_control); - - /* Write the ALIGN Insertion Ferequency for connected phy and - * inpendent of connected state - */ - clksm_value = SCU_ALIGN_INSERTION_FREQUENCY_GEN_VAL(CONNECTED, - phy_user->in_connection_align_insertion_frequency); - - clksm_value |= SCU_ALIGN_INSERTION_FREQUENCY_GEN_VAL(GENERAL, - phy_user->align_insertion_frequency); - - writel(clksm_value, &iphy->link_layer_registers->clock_skew_management); - - /* @todo Provide a way to write this register correctly */ - writel(0x02108421, - &iphy->link_layer_registers->afe_lookup_table_control); - - llctl = SCU_SAS_LLCTL_GEN_VAL(NO_OUTBOUND_TASK_TIMEOUT, - (u8)ihost->user_parameters.no_outbound_task_timeout); - - switch (phy_user->max_speed_generation) { - case SCIC_SDS_PARM_GEN3_SPEED: - link_rate = SCU_SAS_LINK_LAYER_CONTROL_MAX_LINK_RATE_GEN3; - break; - case SCIC_SDS_PARM_GEN2_SPEED: - link_rate = SCU_SAS_LINK_LAYER_CONTROL_MAX_LINK_RATE_GEN2; - break; - default: - link_rate = SCU_SAS_LINK_LAYER_CONTROL_MAX_LINK_RATE_GEN1; - break; - } - llctl |= SCU_SAS_LLCTL_GEN_VAL(MAX_LINK_RATE, link_rate); - writel(llctl, &iphy->link_layer_registers->link_layer_control); - - if (is_a2(ihost->pdev)) { - /* Program the max ARB time for the PHY to 700us so we inter-operate with - * the PMC expander which shuts down PHYs if the expander PHY generates too - * many breaks. This time value will guarantee that the initiator PHY will - * generate the break. - */ - writel(SCIC_SDS_PHY_MAX_ARBITRATION_WAIT_TIME, - &iphy->link_layer_registers->maximum_arbitration_wait_timer_timeout); - } - - /* Disable link layer hang detection, rely on the OS timeout for I/O timeouts. */ - writel(0, &iphy->link_layer_registers->link_layer_hang_detection_timeout); - - /* We can exit the initial state to the stopped state */ - sci_change_state(&iphy->sm, SCI_PHY_STOPPED); - - return SCI_SUCCESS; -} - -static void phy_sata_timeout(unsigned long data) -{ - struct sci_timer *tmr = (struct sci_timer *)data; - struct isci_phy *iphy = container_of(tmr, typeof(*iphy), sata_timer); - struct isci_host *ihost = iphy->owning_port->owning_controller; - unsigned long flags; - - spin_lock_irqsave(&ihost->scic_lock, flags); - - if (tmr->cancel) - goto done; - - dev_dbg(sciphy_to_dev(iphy), - "%s: SCIC SDS Phy 0x%p did not receive signature fis before " - "timeout.\n", - __func__, - iphy); - - sci_change_state(&iphy->sm, SCI_PHY_STARTING); -done: - spin_unlock_irqrestore(&ihost->scic_lock, flags); -} - -/** - * This method returns the port currently containing this phy. If the phy is - * currently contained by the dummy port, then the phy is considered to not - * be part of a port. - * @sci_phy: This parameter specifies the phy for which to retrieve the - * containing port. - * - * This method returns a handle to a port that contains the supplied phy. - * NULL This value is returned if the phy is not part of a real - * port (i.e. it's contained in the dummy port). !NULL All other - * values indicate a handle/pointer to the port containing the phy. - */ -struct isci_port *phy_get_non_dummy_port(struct isci_phy *iphy) -{ - struct isci_port *iport = iphy->owning_port; - - if (iport->physical_port_index == SCIC_SDS_DUMMY_PORT) - return NULL; - - return iphy->owning_port; -} - -/** - * This method will assign a port to the phy object. - * @out]: iphy This parameter specifies the phy for which to assign a port - * object. - * - * - */ -void sci_phy_set_port( - struct isci_phy *iphy, - struct isci_port *iport) -{ - iphy->owning_port = iport; - - if (iphy->bcn_received_while_port_unassigned) { - iphy->bcn_received_while_port_unassigned = false; - sci_port_broadcast_change_received(iphy->owning_port, iphy); - } -} - -enum sci_status sci_phy_initialize(struct isci_phy *iphy, - struct scu_transport_layer_registers __iomem *tl, - struct scu_link_layer_registers __iomem *ll) -{ - /* Perfrom the initialization of the TL hardware */ - sci_phy_transport_layer_initialization(iphy, tl); - - /* Perofrm the initialization of the PE hardware */ - sci_phy_link_layer_initialization(iphy, ll); - - /* There is nothing that needs to be done in this state just - * transition to the stopped state - */ - sci_change_state(&iphy->sm, SCI_PHY_STOPPED); - - return SCI_SUCCESS; -} - -/** - * This method assigns the direct attached device ID for this phy. - * - * @iphy The phy for which the direct attached device id is to - * be assigned. - * @device_id The direct attached device ID to assign to the phy. - * This will either be the RNi for the device or an invalid RNi if there - * is no current device assigned to the phy. - */ -void sci_phy_setup_transport(struct isci_phy *iphy, u32 device_id) -{ - u32 tl_control; - - writel(device_id, &iphy->transport_layer_registers->stp_rni); - - /* - * The read should guarantee that the first write gets posted - * before the next write - */ - tl_control = readl(&iphy->transport_layer_registers->control); - tl_control |= SCU_TLCR_GEN_BIT(CLEAR_TCI_NCQ_MAPPING_TABLE); - writel(tl_control, &iphy->transport_layer_registers->control); -} - -static void sci_phy_suspend(struct isci_phy *iphy) -{ - u32 scu_sas_pcfg_value; - - scu_sas_pcfg_value = - readl(&iphy->link_layer_registers->phy_configuration); - scu_sas_pcfg_value |= SCU_SAS_PCFG_GEN_BIT(SUSPEND_PROTOCOL_ENGINE); - writel(scu_sas_pcfg_value, - &iphy->link_layer_registers->phy_configuration); - - sci_phy_setup_transport(iphy, SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX); -} - -void sci_phy_resume(struct isci_phy *iphy) -{ - u32 scu_sas_pcfg_value; - - scu_sas_pcfg_value = - readl(&iphy->link_layer_registers->phy_configuration); - scu_sas_pcfg_value &= ~SCU_SAS_PCFG_GEN_BIT(SUSPEND_PROTOCOL_ENGINE); - writel(scu_sas_pcfg_value, - &iphy->link_layer_registers->phy_configuration); -} - -void sci_phy_get_sas_address(struct isci_phy *iphy, struct sci_sas_address *sas) -{ - sas->high = readl(&iphy->link_layer_registers->source_sas_address_high); - sas->low = readl(&iphy->link_layer_registers->source_sas_address_low); -} - -void sci_phy_get_attached_sas_address(struct isci_phy *iphy, struct sci_sas_address *sas) -{ - struct sas_identify_frame *iaf; - - iaf = &iphy->frame_rcvd.iaf; - memcpy(sas, iaf->sas_addr, SAS_ADDR_SIZE); -} - -void sci_phy_get_protocols(struct isci_phy *iphy, struct sci_phy_proto *proto) -{ - proto->all = readl(&iphy->link_layer_registers->transmit_identification); -} - -enum sci_status sci_phy_start(struct isci_phy *iphy) -{ - enum sci_phy_states state = iphy->sm.current_state_id; - - if (state != SCI_PHY_STOPPED) { - dev_dbg(sciphy_to_dev(iphy), - "%s: in wrong state: %d\n", __func__, state); - return SCI_FAILURE_INVALID_STATE; - } - - sci_change_state(&iphy->sm, SCI_PHY_STARTING); - return SCI_SUCCESS; -} - -enum sci_status sci_phy_stop(struct isci_phy *iphy) -{ - enum sci_phy_states state = iphy->sm.current_state_id; - - switch (state) { - case SCI_PHY_SUB_INITIAL: - case SCI_PHY_SUB_AWAIT_OSSP_EN: - case SCI_PHY_SUB_AWAIT_SAS_SPEED_EN: - case SCI_PHY_SUB_AWAIT_SAS_POWER: - case SCI_PHY_SUB_AWAIT_SATA_POWER: - case SCI_PHY_SUB_AWAIT_SATA_PHY_EN: - case SCI_PHY_SUB_AWAIT_SATA_SPEED_EN: - case SCI_PHY_SUB_AWAIT_SIG_FIS_UF: - case SCI_PHY_SUB_FINAL: - case SCI_PHY_READY: - break; - default: - dev_dbg(sciphy_to_dev(iphy), - "%s: in wrong state: %d\n", __func__, state); - return SCI_FAILURE_INVALID_STATE; - } - - sci_change_state(&iphy->sm, SCI_PHY_STOPPED); - return SCI_SUCCESS; -} - -enum sci_status sci_phy_reset(struct isci_phy *iphy) -{ - enum sci_phy_states state = iphy->sm.current_state_id; - - if (state != SCI_PHY_READY) { - dev_dbg(sciphy_to_dev(iphy), - "%s: in wrong state: %d\n", __func__, state); - return SCI_FAILURE_INVALID_STATE; - } - - sci_change_state(&iphy->sm, SCI_PHY_RESETTING); - return SCI_SUCCESS; -} - -enum sci_status sci_phy_consume_power_handler(struct isci_phy *iphy) -{ - enum sci_phy_states state = iphy->sm.current_state_id; - - switch (state) { - case SCI_PHY_SUB_AWAIT_SAS_POWER: { - u32 enable_spinup; - - enable_spinup = readl(&iphy->link_layer_registers->notify_enable_spinup_control); - enable_spinup |= SCU_ENSPINUP_GEN_BIT(ENABLE); - writel(enable_spinup, &iphy->link_layer_registers->notify_enable_spinup_control); - - /* Change state to the final state this substate machine has run to completion */ - sci_change_state(&iphy->sm, SCI_PHY_SUB_FINAL); - - return SCI_SUCCESS; - } - case SCI_PHY_SUB_AWAIT_SATA_POWER: { - u32 scu_sas_pcfg_value; - - /* Release the spinup hold state and reset the OOB state machine */ - scu_sas_pcfg_value = - readl(&iphy->link_layer_registers->phy_configuration); - scu_sas_pcfg_value &= - ~(SCU_SAS_PCFG_GEN_BIT(SATA_SPINUP_HOLD) | SCU_SAS_PCFG_GEN_BIT(OOB_ENABLE)); - scu_sas_pcfg_value |= SCU_SAS_PCFG_GEN_BIT(OOB_RESET); - writel(scu_sas_pcfg_value, - &iphy->link_layer_registers->phy_configuration); - - /* Now restart the OOB operation */ - scu_sas_pcfg_value &= ~SCU_SAS_PCFG_GEN_BIT(OOB_RESET); - scu_sas_pcfg_value |= SCU_SAS_PCFG_GEN_BIT(OOB_ENABLE); - writel(scu_sas_pcfg_value, - &iphy->link_layer_registers->phy_configuration); - - /* Change state to the final state this substate machine has run to completion */ - sci_change_state(&iphy->sm, SCI_PHY_SUB_AWAIT_SATA_PHY_EN); - - return SCI_SUCCESS; - } - default: - dev_dbg(sciphy_to_dev(iphy), - "%s: in wrong state: %d\n", __func__, state); - return SCI_FAILURE_INVALID_STATE; - } -} - -static void sci_phy_start_sas_link_training(struct isci_phy *iphy) -{ - /* continue the link training for the phy as if it were a SAS PHY - * instead of a SATA PHY. This is done because the completion queue had a SAS - * PHY DETECTED event when the state machine was expecting a SATA PHY event. - */ - u32 phy_control; - - phy_control = readl(&iphy->link_layer_registers->phy_configuration); - phy_control |= SCU_SAS_PCFG_GEN_BIT(SATA_SPINUP_HOLD); - writel(phy_control, - &iphy->link_layer_registers->phy_configuration); - - sci_change_state(&iphy->sm, SCI_PHY_SUB_AWAIT_SAS_SPEED_EN); - - iphy->protocol = SCIC_SDS_PHY_PROTOCOL_SAS; -} - -static void sci_phy_start_sata_link_training(struct isci_phy *iphy) -{ - /* This method continues the link training for the phy as if it were a SATA PHY - * instead of a SAS PHY. This is done because the completion queue had a SATA - * SPINUP HOLD event when the state machine was expecting a SAS PHY event. none - */ - sci_change_state(&iphy->sm, SCI_PHY_SUB_AWAIT_SATA_POWER); - - iphy->protocol = SCIC_SDS_PHY_PROTOCOL_SATA; -} - -/** - * sci_phy_complete_link_training - perform processing common to - * all protocols upon completion of link training. - * @sci_phy: This parameter specifies the phy object for which link training - * has completed. - * @max_link_rate: This parameter specifies the maximum link rate to be - * associated with this phy. - * @next_state: This parameter specifies the next state for the phy's starting - * sub-state machine. - * - */ -static void sci_phy_complete_link_training(struct isci_phy *iphy, - enum sas_linkrate max_link_rate, - u32 next_state) -{ - iphy->max_negotiated_speed = max_link_rate; - - sci_change_state(&iphy->sm, next_state); -} - -enum sci_status sci_phy_event_handler(struct isci_phy *iphy, u32 event_code) -{ - enum sci_phy_states state = iphy->sm.current_state_id; - - switch (state) { - case SCI_PHY_SUB_AWAIT_OSSP_EN: - switch (scu_get_event_code(event_code)) { - case SCU_EVENT_SAS_PHY_DETECTED: - sci_phy_start_sas_link_training(iphy); - iphy->is_in_link_training = true; - break; - case SCU_EVENT_SATA_SPINUP_HOLD: - sci_phy_start_sata_link_training(iphy); - iphy->is_in_link_training = true; - break; - default: - dev_dbg(sciphy_to_dev(iphy), - "%s: PHY starting substate machine received " - "unexpected event_code %x\n", - __func__, - event_code); - return SCI_FAILURE; - } - return SCI_SUCCESS; - case SCI_PHY_SUB_AWAIT_SAS_SPEED_EN: - switch (scu_get_event_code(event_code)) { - case SCU_EVENT_SAS_PHY_DETECTED: - /* - * Why is this being reported again by the controller? - * We would re-enter this state so just stay here */ - break; - case SCU_EVENT_SAS_15: - case SCU_EVENT_SAS_15_SSC: - sci_phy_complete_link_training(iphy, SAS_LINK_RATE_1_5_GBPS, - SCI_PHY_SUB_AWAIT_IAF_UF); - break; - case SCU_EVENT_SAS_30: - case SCU_EVENT_SAS_30_SSC: - sci_phy_complete_link_training(iphy, SAS_LINK_RATE_3_0_GBPS, - SCI_PHY_SUB_AWAIT_IAF_UF); - break; - case SCU_EVENT_SAS_60: - case SCU_EVENT_SAS_60_SSC: - sci_phy_complete_link_training(iphy, SAS_LINK_RATE_6_0_GBPS, - SCI_PHY_SUB_AWAIT_IAF_UF); - break; - case SCU_EVENT_SATA_SPINUP_HOLD: - /* - * We were doing SAS PHY link training and received a SATA PHY event - * continue OOB/SN as if this were a SATA PHY */ - sci_phy_start_sata_link_training(iphy); - break; - case SCU_EVENT_LINK_FAILURE: - /* Link failure change state back to the starting state */ - sci_change_state(&iphy->sm, SCI_PHY_STARTING); - break; - default: - dev_warn(sciphy_to_dev(iphy), - "%s: PHY starting substate machine received " - "unexpected event_code %x\n", - __func__, event_code); - - return SCI_FAILURE; - break; - } - return SCI_SUCCESS; - case SCI_PHY_SUB_AWAIT_IAF_UF: - switch (scu_get_event_code(event_code)) { - case SCU_EVENT_SAS_PHY_DETECTED: - /* Backup the state machine */ - sci_phy_start_sas_link_training(iphy); - break; - case SCU_EVENT_SATA_SPINUP_HOLD: - /* We were doing SAS PHY link training and received a - * SATA PHY event continue OOB/SN as if this were a - * SATA PHY - */ - sci_phy_start_sata_link_training(iphy); - break; - case SCU_EVENT_RECEIVED_IDENTIFY_TIMEOUT: - case SCU_EVENT_LINK_FAILURE: - case SCU_EVENT_HARD_RESET_RECEIVED: - /* Start the oob/sn state machine over again */ - sci_change_state(&iphy->sm, SCI_PHY_STARTING); - break; - default: - dev_warn(sciphy_to_dev(iphy), - "%s: PHY starting substate machine received " - "unexpected event_code %x\n", - __func__, event_code); - return SCI_FAILURE; - } - return SCI_SUCCESS; - case SCI_PHY_SUB_AWAIT_SAS_POWER: - switch (scu_get_event_code(event_code)) { - case SCU_EVENT_LINK_FAILURE: - /* Link failure change state back to the starting state */ - sci_change_state(&iphy->sm, SCI_PHY_STARTING); - break; - default: - dev_warn(sciphy_to_dev(iphy), - "%s: PHY starting substate machine received unexpected " - "event_code %x\n", - __func__, - event_code); - return SCI_FAILURE; - } - return SCI_SUCCESS; - case SCI_PHY_SUB_AWAIT_SATA_POWER: - switch (scu_get_event_code(event_code)) { - case SCU_EVENT_LINK_FAILURE: - /* Link failure change state back to the starting state */ - sci_change_state(&iphy->sm, SCI_PHY_STARTING); - break; - case SCU_EVENT_SATA_SPINUP_HOLD: - /* These events are received every 10ms and are - * expected while in this state - */ - break; - - case SCU_EVENT_SAS_PHY_DETECTED: - /* There has been a change in the phy type before OOB/SN for the - * SATA finished start down the SAS link traning path. - */ - sci_phy_start_sas_link_training(iphy); - break; - - default: - dev_warn(sciphy_to_dev(iphy), - "%s: PHY starting substate machine received " - "unexpected event_code %x\n", - __func__, event_code); - - return SCI_FAILURE; - } - return SCI_SUCCESS; - case SCI_PHY_SUB_AWAIT_SATA_PHY_EN: - switch (scu_get_event_code(event_code)) { - case SCU_EVENT_LINK_FAILURE: - /* Link failure change state back to the starting state */ - sci_change_state(&iphy->sm, SCI_PHY_STARTING); - break; - case SCU_EVENT_SATA_SPINUP_HOLD: - /* These events might be received since we dont know how many may be in - * the completion queue while waiting for power - */ - break; - case SCU_EVENT_SATA_PHY_DETECTED: - iphy->protocol = SCIC_SDS_PHY_PROTOCOL_SATA; - - /* We have received the SATA PHY notification change state */ - sci_change_state(&iphy->sm, SCI_PHY_SUB_AWAIT_SATA_SPEED_EN); - break; - case SCU_EVENT_SAS_PHY_DETECTED: - /* There has been a change in the phy type before OOB/SN for the - * SATA finished start down the SAS link traning path. - */ - sci_phy_start_sas_link_training(iphy); - break; - default: - dev_warn(sciphy_to_dev(iphy), - "%s: PHY starting substate machine received " - "unexpected event_code %x\n", - __func__, - event_code); - - return SCI_FAILURE;; - } - return SCI_SUCCESS; - case SCI_PHY_SUB_AWAIT_SATA_SPEED_EN: - switch (scu_get_event_code(event_code)) { - case SCU_EVENT_SATA_PHY_DETECTED: - /* - * The hardware reports multiple SATA PHY detected events - * ignore the extras */ - break; - case SCU_EVENT_SATA_15: - case SCU_EVENT_SATA_15_SSC: - sci_phy_complete_link_training(iphy, SAS_LINK_RATE_1_5_GBPS, - SCI_PHY_SUB_AWAIT_SIG_FIS_UF); - break; - case SCU_EVENT_SATA_30: - case SCU_EVENT_SATA_30_SSC: - sci_phy_complete_link_training(iphy, SAS_LINK_RATE_3_0_GBPS, - SCI_PHY_SUB_AWAIT_SIG_FIS_UF); - break; - case SCU_EVENT_SATA_60: - case SCU_EVENT_SATA_60_SSC: - sci_phy_complete_link_training(iphy, SAS_LINK_RATE_6_0_GBPS, - SCI_PHY_SUB_AWAIT_SIG_FIS_UF); - break; - case SCU_EVENT_LINK_FAILURE: - /* Link failure change state back to the starting state */ - sci_change_state(&iphy->sm, SCI_PHY_STARTING); - break; - case SCU_EVENT_SAS_PHY_DETECTED: - /* - * There has been a change in the phy type before OOB/SN for the - * SATA finished start down the SAS link traning path. */ - sci_phy_start_sas_link_training(iphy); - break; - default: - dev_warn(sciphy_to_dev(iphy), - "%s: PHY starting substate machine received " - "unexpected event_code %x\n", - __func__, event_code); - - return SCI_FAILURE; - } - - return SCI_SUCCESS; - case SCI_PHY_SUB_AWAIT_SIG_FIS_UF: - switch (scu_get_event_code(event_code)) { - case SCU_EVENT_SATA_PHY_DETECTED: - /* Backup the state machine */ - sci_change_state(&iphy->sm, SCI_PHY_SUB_AWAIT_SATA_SPEED_EN); - break; - - case SCU_EVENT_LINK_FAILURE: - /* Link failure change state back to the starting state */ - sci_change_state(&iphy->sm, SCI_PHY_STARTING); - break; - - default: - dev_warn(sciphy_to_dev(iphy), - "%s: PHY starting substate machine received " - "unexpected event_code %x\n", - __func__, - event_code); - - return SCI_FAILURE; - } - return SCI_SUCCESS; - case SCI_PHY_READY: - switch (scu_get_event_code(event_code)) { - case SCU_EVENT_LINK_FAILURE: - /* Link failure change state back to the starting state */ - sci_change_state(&iphy->sm, SCI_PHY_STARTING); - break; - case SCU_EVENT_BROADCAST_CHANGE: - /* Broadcast change received. Notify the port. */ - if (phy_get_non_dummy_port(iphy) != NULL) - sci_port_broadcast_change_received(iphy->owning_port, iphy); - else - iphy->bcn_received_while_port_unassigned = true; - break; - default: - dev_warn(sciphy_to_dev(iphy), - "%sP SCIC PHY 0x%p ready state machine received " - "unexpected event_code %x\n", - __func__, iphy, event_code); - return SCI_FAILURE_INVALID_STATE; - } - return SCI_SUCCESS; - case SCI_PHY_RESETTING: - switch (scu_get_event_code(event_code)) { - case SCU_EVENT_HARD_RESET_TRANSMITTED: - /* Link failure change state back to the starting state */ - sci_change_state(&iphy->sm, SCI_PHY_STARTING); - break; - default: - dev_warn(sciphy_to_dev(iphy), - "%s: SCIC PHY 0x%p resetting state machine received " - "unexpected event_code %x\n", - __func__, iphy, event_code); - - return SCI_FAILURE_INVALID_STATE; - break; - } - return SCI_SUCCESS; - default: - dev_dbg(sciphy_to_dev(iphy), - "%s: in wrong state: %d\n", __func__, state); - return SCI_FAILURE_INVALID_STATE; - } -} - -enum sci_status sci_phy_frame_handler(struct isci_phy *iphy, u32 frame_index) -{ - enum sci_phy_states state = iphy->sm.current_state_id; - struct isci_host *ihost = iphy->owning_port->owning_controller; - enum sci_status result; - unsigned long flags; - - switch (state) { - case SCI_PHY_SUB_AWAIT_IAF_UF: { - u32 *frame_words; - struct sas_identify_frame iaf; - - result = sci_unsolicited_frame_control_get_header(&ihost->uf_control, - frame_index, - (void **)&frame_words); - - if (result != SCI_SUCCESS) - return result; - - sci_swab32_cpy(&iaf, frame_words, sizeof(iaf) / sizeof(u32)); - if (iaf.frame_type == 0) { - u32 state; - - spin_lock_irqsave(&iphy->sas_phy.frame_rcvd_lock, flags); - memcpy(&iphy->frame_rcvd.iaf, &iaf, sizeof(iaf)); - spin_unlock_irqrestore(&iphy->sas_phy.frame_rcvd_lock, flags); - if (iaf.smp_tport) { - /* We got the IAF for an expander PHY go to the final - * state since there are no power requirements for - * expander phys. - */ - state = SCI_PHY_SUB_FINAL; - } else { - /* We got the IAF we can now go to the await spinup - * semaphore state - */ - state = SCI_PHY_SUB_AWAIT_SAS_POWER; - } - sci_change_state(&iphy->sm, state); - result = SCI_SUCCESS; - } else - dev_warn(sciphy_to_dev(iphy), - "%s: PHY starting substate machine received " - "unexpected frame id %x\n", - __func__, frame_index); - - sci_controller_release_frame(ihost, frame_index); - return result; - } - case SCI_PHY_SUB_AWAIT_SIG_FIS_UF: { - struct dev_to_host_fis *frame_header; - u32 *fis_frame_data; - - result = sci_unsolicited_frame_control_get_header(&ihost->uf_control, - frame_index, - (void **)&frame_header); - - if (result != SCI_SUCCESS) - return result; - - if ((frame_header->fis_type == FIS_REGD2H) && - !(frame_header->status & ATA_BUSY)) { - sci_unsolicited_frame_control_get_buffer(&ihost->uf_control, - frame_index, - (void **)&fis_frame_data); - - spin_lock_irqsave(&iphy->sas_phy.frame_rcvd_lock, flags); - sci_controller_copy_sata_response(&iphy->frame_rcvd.fis, - frame_header, - fis_frame_data); - spin_unlock_irqrestore(&iphy->sas_phy.frame_rcvd_lock, flags); - - /* got IAF we can now go to the await spinup semaphore state */ - sci_change_state(&iphy->sm, SCI_PHY_SUB_FINAL); - - result = SCI_SUCCESS; - } else - dev_warn(sciphy_to_dev(iphy), - "%s: PHY starting substate machine received " - "unexpected frame id %x\n", - __func__, frame_index); - - /* Regardless of the result we are done with this frame with it */ - sci_controller_release_frame(ihost, frame_index); - - return result; - } - default: - dev_dbg(sciphy_to_dev(iphy), - "%s: in wrong state: %d\n", __func__, state); - return SCI_FAILURE_INVALID_STATE; - } - -} - -static void sci_phy_starting_initial_substate_enter(struct sci_base_state_machine *sm) -{ - struct isci_phy *iphy = container_of(sm, typeof(*iphy), sm); - - /* This is just an temporary state go off to the starting state */ - sci_change_state(&iphy->sm, SCI_PHY_SUB_AWAIT_OSSP_EN); -} - -static void sci_phy_starting_await_sas_power_substate_enter(struct sci_base_state_machine *sm) -{ - struct isci_phy *iphy = container_of(sm, typeof(*iphy), sm); - struct isci_host *ihost = iphy->owning_port->owning_controller; - - sci_controller_power_control_queue_insert(ihost, iphy); -} - -static void sci_phy_starting_await_sas_power_substate_exit(struct sci_base_state_machine *sm) -{ - struct isci_phy *iphy = container_of(sm, typeof(*iphy), sm); - struct isci_host *ihost = iphy->owning_port->owning_controller; - - sci_controller_power_control_queue_remove(ihost, iphy); -} - -static void sci_phy_starting_await_sata_power_substate_enter(struct sci_base_state_machine *sm) -{ - struct isci_phy *iphy = container_of(sm, typeof(*iphy), sm); - struct isci_host *ihost = iphy->owning_port->owning_controller; - - sci_controller_power_control_queue_insert(ihost, iphy); -} - -static void sci_phy_starting_await_sata_power_substate_exit(struct sci_base_state_machine *sm) -{ - struct isci_phy *iphy = container_of(sm, typeof(*iphy), sm); - struct isci_host *ihost = iphy->owning_port->owning_controller; - - sci_controller_power_control_queue_remove(ihost, iphy); -} - -static void sci_phy_starting_await_sata_phy_substate_enter(struct sci_base_state_machine *sm) -{ - struct isci_phy *iphy = container_of(sm, typeof(*iphy), sm); - - sci_mod_timer(&iphy->sata_timer, SCIC_SDS_SATA_LINK_TRAINING_TIMEOUT); -} - -static void sci_phy_starting_await_sata_phy_substate_exit(struct sci_base_state_machine *sm) -{ - struct isci_phy *iphy = container_of(sm, typeof(*iphy), sm); - - sci_del_timer(&iphy->sata_timer); -} - -static void sci_phy_starting_await_sata_speed_substate_enter(struct sci_base_state_machine *sm) -{ - struct isci_phy *iphy = container_of(sm, typeof(*iphy), sm); - - sci_mod_timer(&iphy->sata_timer, SCIC_SDS_SATA_LINK_TRAINING_TIMEOUT); -} - -static void sci_phy_starting_await_sata_speed_substate_exit(struct sci_base_state_machine *sm) -{ - struct isci_phy *iphy = container_of(sm, typeof(*iphy), sm); - - sci_del_timer(&iphy->sata_timer); -} - -static void sci_phy_starting_await_sig_fis_uf_substate_enter(struct sci_base_state_machine *sm) -{ - struct isci_phy *iphy = container_of(sm, typeof(*iphy), sm); - - if (sci_port_link_detected(iphy->owning_port, iphy)) { - - /* - * Clear the PE suspend condition so we can actually - * receive SIG FIS - * The hardware will not respond to the XRDY until the PE - * suspend condition is cleared. - */ - sci_phy_resume(iphy); - - sci_mod_timer(&iphy->sata_timer, - SCIC_SDS_SIGNATURE_FIS_TIMEOUT); - } else - iphy->is_in_link_training = false; -} - -static void sci_phy_starting_await_sig_fis_uf_substate_exit(struct sci_base_state_machine *sm) -{ - struct isci_phy *iphy = container_of(sm, typeof(*iphy), sm); - - sci_del_timer(&iphy->sata_timer); -} - -static void sci_phy_starting_final_substate_enter(struct sci_base_state_machine *sm) -{ - struct isci_phy *iphy = container_of(sm, typeof(*iphy), sm); - - /* State machine has run to completion so exit out and change - * the base state machine to the ready state - */ - sci_change_state(&iphy->sm, SCI_PHY_READY); -} - -/** - * - * @sci_phy: This is the struct isci_phy object to stop. - * - * This method will stop the struct isci_phy object. This does not reset the - * protocol engine it just suspends it and places it in a state where it will - * not cause the end device to power up. none - */ -static void scu_link_layer_stop_protocol_engine( - struct isci_phy *iphy) -{ - u32 scu_sas_pcfg_value; - u32 enable_spinup_value; - - /* Suspend the protocol engine and place it in a sata spinup hold state */ - scu_sas_pcfg_value = - readl(&iphy->link_layer_registers->phy_configuration); - scu_sas_pcfg_value |= - (SCU_SAS_PCFG_GEN_BIT(OOB_RESET) | - SCU_SAS_PCFG_GEN_BIT(SUSPEND_PROTOCOL_ENGINE) | - SCU_SAS_PCFG_GEN_BIT(SATA_SPINUP_HOLD)); - writel(scu_sas_pcfg_value, - &iphy->link_layer_registers->phy_configuration); - - /* Disable the notify enable spinup primitives */ - enable_spinup_value = readl(&iphy->link_layer_registers->notify_enable_spinup_control); - enable_spinup_value &= ~SCU_ENSPINUP_GEN_BIT(ENABLE); - writel(enable_spinup_value, &iphy->link_layer_registers->notify_enable_spinup_control); -} - -/** - * - * - * This method will start the OOB/SN state machine for this struct isci_phy object. - */ -static void scu_link_layer_start_oob( - struct isci_phy *iphy) -{ - u32 scu_sas_pcfg_value; - - scu_sas_pcfg_value = - readl(&iphy->link_layer_registers->phy_configuration); - scu_sas_pcfg_value |= SCU_SAS_PCFG_GEN_BIT(OOB_ENABLE); - scu_sas_pcfg_value &= - ~(SCU_SAS_PCFG_GEN_BIT(OOB_RESET) | - SCU_SAS_PCFG_GEN_BIT(HARD_RESET)); - writel(scu_sas_pcfg_value, - &iphy->link_layer_registers->phy_configuration); -} - -/** - * - * - * This method will transmit a hard reset request on the specified phy. The SCU - * hardware requires that we reset the OOB state machine and set the hard reset - * bit in the phy configuration register. We then must start OOB over with the - * hard reset bit set. - */ -static void scu_link_layer_tx_hard_reset( - struct isci_phy *iphy) -{ - u32 phy_configuration_value; - - /* - * SAS Phys must wait for the HARD_RESET_TX event notification to transition - * to the starting state. */ - phy_configuration_value = - readl(&iphy->link_layer_registers->phy_configuration); - phy_configuration_value |= - (SCU_SAS_PCFG_GEN_BIT(HARD_RESET) | - SCU_SAS_PCFG_GEN_BIT(OOB_RESET)); - writel(phy_configuration_value, - &iphy->link_layer_registers->phy_configuration); - - /* Now take the OOB state machine out of reset */ - phy_configuration_value |= SCU_SAS_PCFG_GEN_BIT(OOB_ENABLE); - phy_configuration_value &= ~SCU_SAS_PCFG_GEN_BIT(OOB_RESET); - writel(phy_configuration_value, - &iphy->link_layer_registers->phy_configuration); -} - -static void sci_phy_stopped_state_enter(struct sci_base_state_machine *sm) -{ - struct isci_phy *iphy = container_of(sm, typeof(*iphy), sm); - struct isci_port *iport = iphy->owning_port; - struct isci_host *ihost = iport->owning_controller; - - /* - * @todo We need to get to the controller to place this PE in a - * reset state - */ - sci_del_timer(&iphy->sata_timer); - - scu_link_layer_stop_protocol_engine(iphy); - - if (iphy->sm.previous_state_id != SCI_PHY_INITIAL) - sci_controller_link_down(ihost, phy_get_non_dummy_port(iphy), iphy); -} - -static void sci_phy_starting_state_enter(struct sci_base_state_machine *sm) -{ - struct isci_phy *iphy = container_of(sm, typeof(*iphy), sm); - struct isci_port *iport = iphy->owning_port; - struct isci_host *ihost = iport->owning_controller; - - scu_link_layer_stop_protocol_engine(iphy); - scu_link_layer_start_oob(iphy); - - /* We don't know what kind of phy we are going to be just yet */ - iphy->protocol = SCIC_SDS_PHY_PROTOCOL_UNKNOWN; - iphy->bcn_received_while_port_unassigned = false; - - if (iphy->sm.previous_state_id == SCI_PHY_READY) - sci_controller_link_down(ihost, phy_get_non_dummy_port(iphy), iphy); - - sci_change_state(&iphy->sm, SCI_PHY_SUB_INITIAL); -} - -static void sci_phy_ready_state_enter(struct sci_base_state_machine *sm) -{ - struct isci_phy *iphy = container_of(sm, typeof(*iphy), sm); - struct isci_port *iport = iphy->owning_port; - struct isci_host *ihost = iport->owning_controller; - - sci_controller_link_up(ihost, phy_get_non_dummy_port(iphy), iphy); -} - -static void sci_phy_ready_state_exit(struct sci_base_state_machine *sm) -{ - struct isci_phy *iphy = container_of(sm, typeof(*iphy), sm); - - sci_phy_suspend(iphy); -} - -static void sci_phy_resetting_state_enter(struct sci_base_state_machine *sm) -{ - struct isci_phy *iphy = container_of(sm, typeof(*iphy), sm); - - /* The phy is being reset, therefore deactivate it from the port. In - * the resetting state we don't notify the user regarding link up and - * link down notifications - */ - sci_port_deactivate_phy(iphy->owning_port, iphy, false); - - if (iphy->protocol == SCIC_SDS_PHY_PROTOCOL_SAS) { - scu_link_layer_tx_hard_reset(iphy); - } else { - /* The SCU does not need to have a discrete reset state so - * just go back to the starting state. - */ - sci_change_state(&iphy->sm, SCI_PHY_STARTING); - } -} - -static const struct sci_base_state sci_phy_state_table[] = { - [SCI_PHY_INITIAL] = { }, - [SCI_PHY_STOPPED] = { - .enter_state = sci_phy_stopped_state_enter, - }, - [SCI_PHY_STARTING] = { - .enter_state = sci_phy_starting_state_enter, - }, - [SCI_PHY_SUB_INITIAL] = { - .enter_state = sci_phy_starting_initial_substate_enter, - }, - [SCI_PHY_SUB_AWAIT_OSSP_EN] = { }, - [SCI_PHY_SUB_AWAIT_SAS_SPEED_EN] = { }, - [SCI_PHY_SUB_AWAIT_IAF_UF] = { }, - [SCI_PHY_SUB_AWAIT_SAS_POWER] = { - .enter_state = sci_phy_starting_await_sas_power_substate_enter, - .exit_state = sci_phy_starting_await_sas_power_substate_exit, - }, - [SCI_PHY_SUB_AWAIT_SATA_POWER] = { - .enter_state = sci_phy_starting_await_sata_power_substate_enter, - .exit_state = sci_phy_starting_await_sata_power_substate_exit - }, - [SCI_PHY_SUB_AWAIT_SATA_PHY_EN] = { - .enter_state = sci_phy_starting_await_sata_phy_substate_enter, - .exit_state = sci_phy_starting_await_sata_phy_substate_exit - }, - [SCI_PHY_SUB_AWAIT_SATA_SPEED_EN] = { - .enter_state = sci_phy_starting_await_sata_speed_substate_enter, - .exit_state = sci_phy_starting_await_sata_speed_substate_exit - }, - [SCI_PHY_SUB_AWAIT_SIG_FIS_UF] = { - .enter_state = sci_phy_starting_await_sig_fis_uf_substate_enter, - .exit_state = sci_phy_starting_await_sig_fis_uf_substate_exit - }, - [SCI_PHY_SUB_FINAL] = { - .enter_state = sci_phy_starting_final_substate_enter, - }, - [SCI_PHY_READY] = { - .enter_state = sci_phy_ready_state_enter, - .exit_state = sci_phy_ready_state_exit, - }, - [SCI_PHY_RESETTING] = { - .enter_state = sci_phy_resetting_state_enter, - }, - [SCI_PHY_FINAL] = { }, -}; - -void sci_phy_construct(struct isci_phy *iphy, - struct isci_port *iport, u8 phy_index) -{ - sci_init_sm(&iphy->sm, sci_phy_state_table, SCI_PHY_INITIAL); - - /* Copy the rest of the input data to our locals */ - iphy->owning_port = iport; - iphy->phy_index = phy_index; - iphy->bcn_received_while_port_unassigned = false; - iphy->protocol = SCIC_SDS_PHY_PROTOCOL_UNKNOWN; - iphy->link_layer_registers = NULL; - iphy->max_negotiated_speed = SAS_LINK_RATE_UNKNOWN; - - /* Create the SIGNATURE FIS Timeout timer for this phy */ - sci_init_timer(&iphy->sata_timer, phy_sata_timeout); -} - -void isci_phy_init(struct isci_phy *iphy, struct isci_host *ihost, int index) -{ - struct sci_oem_params *oem = &ihost->oem_parameters; - u64 sci_sas_addr; - __be64 sas_addr; - - sci_sas_addr = oem->phys[index].sas_address.high; - sci_sas_addr <<= 32; - sci_sas_addr |= oem->phys[index].sas_address.low; - sas_addr = cpu_to_be64(sci_sas_addr); - memcpy(iphy->sas_addr, &sas_addr, sizeof(sas_addr)); - - iphy->isci_port = NULL; - iphy->sas_phy.enabled = 0; - iphy->sas_phy.id = index; - iphy->sas_phy.sas_addr = &iphy->sas_addr[0]; - iphy->sas_phy.frame_rcvd = (u8 *)&iphy->frame_rcvd; - iphy->sas_phy.ha = &ihost->sas_ha; - iphy->sas_phy.lldd_phy = iphy; - iphy->sas_phy.enabled = 1; - iphy->sas_phy.class = SAS; - iphy->sas_phy.iproto = SAS_PROTOCOL_ALL; - iphy->sas_phy.tproto = 0; - iphy->sas_phy.type = PHY_TYPE_PHYSICAL; - iphy->sas_phy.role = PHY_ROLE_INITIATOR; - iphy->sas_phy.oob_mode = OOB_NOT_CONNECTED; - iphy->sas_phy.linkrate = SAS_LINK_RATE_UNKNOWN; - memset(&iphy->frame_rcvd, 0, sizeof(iphy->frame_rcvd)); -} - - -/** - * isci_phy_control() - This function is one of the SAS Domain Template - * functions. This is a phy management function. - * @phy: This parameter specifies the sphy being controlled. - * @func: This parameter specifies the phy control function being invoked. - * @buf: This parameter is specific to the phy function being invoked. - * - * status, zero indicates success. - */ -int isci_phy_control(struct asd_sas_phy *sas_phy, - enum phy_func func, - void *buf) -{ - int ret = 0; - struct isci_phy *iphy = sas_phy->lldd_phy; - struct isci_port *iport = iphy->isci_port; - struct isci_host *ihost = sas_phy->ha->lldd_ha; - unsigned long flags; - - dev_dbg(&ihost->pdev->dev, - "%s: phy %p; func %d; buf %p; isci phy %p, port %p\n", - __func__, sas_phy, func, buf, iphy, iport); - - switch (func) { - case PHY_FUNC_DISABLE: - spin_lock_irqsave(&ihost->scic_lock, flags); - sci_phy_stop(iphy); - spin_unlock_irqrestore(&ihost->scic_lock, flags); - break; - - case PHY_FUNC_LINK_RESET: - spin_lock_irqsave(&ihost->scic_lock, flags); - sci_phy_stop(iphy); - sci_phy_start(iphy); - spin_unlock_irqrestore(&ihost->scic_lock, flags); - break; - - case PHY_FUNC_HARD_RESET: - if (!iport) - return -ENODEV; - - /* Perform the port reset. */ - ret = isci_port_perform_hard_reset(ihost, iport, iphy); - - break; - - default: - dev_dbg(&ihost->pdev->dev, - "%s: phy %p; func %d NOT IMPLEMENTED!\n", - __func__, sas_phy, func); - ret = -ENOSYS; - break; - } - return ret; -} diff --git a/trunk/drivers/scsi/isci/phy.h b/trunk/drivers/scsi/isci/phy.h deleted file mode 100644 index 67699c8e321c..000000000000 --- a/trunk/drivers/scsi/isci/phy.h +++ /dev/null @@ -1,504 +0,0 @@ -/* - * This file is provided under a dual BSD/GPLv2 license. When using or - * redistributing this file, you may do so under either license. - * - * GPL LICENSE SUMMARY - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License 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., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. - * The full GNU General Public License is included in this distribution - * in the file called LICENSE.GPL. - * - * BSD LICENSE - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Intel Corporation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#ifndef _ISCI_PHY_H_ -#define _ISCI_PHY_H_ - -#include -#include -#include "isci.h" -#include "sas.h" - -/* This is the timeout value for the SATA phy to wait for a SIGNATURE FIS - * before restarting the starting state machine. Technically, the old parallel - * ATA specification required up to 30 seconds for a device to issue its - * signature FIS as a result of a soft reset. Now we see that devices respond - * generally within 15 seconds, but we'll use 25 for now. - */ -#define SCIC_SDS_SIGNATURE_FIS_TIMEOUT 25000 - -/* This is the timeout for the SATA OOB/SN because the hardware does not - * recognize a hot plug after OOB signal but before the SN signals. We need to - * make sure after a hotplug timeout if we have not received the speed event - * notification from the hardware that we restart the hardware OOB state - * machine. - */ -#define SCIC_SDS_SATA_LINK_TRAINING_TIMEOUT 250 - -enum sci_phy_protocol { - SCIC_SDS_PHY_PROTOCOL_UNKNOWN, - SCIC_SDS_PHY_PROTOCOL_SAS, - SCIC_SDS_PHY_PROTOCOL_SATA, - SCIC_SDS_MAX_PHY_PROTOCOLS -}; - -/** - * isci_phy - hba local phy infrastructure - * @sm: - * @protocol: attached device protocol - * @phy_index: physical index relative to the controller (0-3) - * @bcn_received_while_port_unassigned: bcn to report after port association - * @sata_timer: timeout SATA signature FIS arrival - */ -struct isci_phy { - struct sci_base_state_machine sm; - struct isci_port *owning_port; - enum sas_linkrate max_negotiated_speed; - enum sci_phy_protocol protocol; - u8 phy_index; - bool bcn_received_while_port_unassigned; - bool is_in_link_training; - struct sci_timer sata_timer; - struct scu_transport_layer_registers __iomem *transport_layer_registers; - struct scu_link_layer_registers __iomem *link_layer_registers; - struct asd_sas_phy sas_phy; - struct isci_port *isci_port; - u8 sas_addr[SAS_ADDR_SIZE]; - union { - struct sas_identify_frame iaf; - struct dev_to_host_fis fis; - } frame_rcvd; -}; - -static inline struct isci_phy *to_iphy(struct asd_sas_phy *sas_phy) -{ - struct isci_phy *iphy = container_of(sas_phy, typeof(*iphy), sas_phy); - - return iphy; -} - -struct sci_phy_cap { - union { - struct { - /* - * The SAS specification indicates the start bit shall - * always be set to - * 1. This implementation will have the start bit set - * to 0 if the PHY CAPABILITIES were either not - * received or speed negotiation failed. - */ - u8 start:1; - u8 tx_ssc_type:1; - u8 res1:2; - u8 req_logical_linkrate:4; - - u32 gen1_no_ssc:1; - u32 gen1_ssc:1; - u32 gen2_no_ssc:1; - u32 gen2_ssc:1; - u32 gen3_no_ssc:1; - u32 gen3_ssc:1; - u32 res2:17; - u32 parity:1; - }; - u32 all; - }; -} __packed; - -/* this data structure reflects the link layer transmit identification reg */ -struct sci_phy_proto { - union { - struct { - u16 _r_a:1; - u16 smp_iport:1; - u16 stp_iport:1; - u16 ssp_iport:1; - u16 _r_b:4; - u16 _r_c:1; - u16 smp_tport:1; - u16 stp_tport:1; - u16 ssp_tport:1; - u16 _r_d:4; - }; - u16 all; - }; -} __packed; - - -/** - * struct sci_phy_properties - This structure defines the properties common to - * all phys that can be retrieved. - * - * - */ -struct sci_phy_properties { - /** - * This field specifies the port that currently contains the - * supplied phy. This field may be set to NULL - * if the phy is not currently contained in a port. - */ - struct isci_port *iport; - - /** - * This field specifies the link rate at which the phy is - * currently operating. - */ - enum sas_linkrate negotiated_link_rate; - - /** - * This field specifies the index of the phy in relation to other - * phys within the controller. This index is zero relative. - */ - u8 index; -}; - -/** - * struct sci_sas_phy_properties - This structure defines the properties, - * specific to a SAS phy, that can be retrieved. - * - * - */ -struct sci_sas_phy_properties { - /** - * This field delineates the Identify Address Frame received - * from the remote end point. - */ - struct sas_identify_frame rcvd_iaf; - - /** - * This field delineates the Phy capabilities structure received - * from the remote end point. - */ - struct sci_phy_cap rcvd_cap; - -}; - -/** - * struct sci_sata_phy_properties - This structure defines the properties, - * specific to a SATA phy, that can be retrieved. - * - * - */ -struct sci_sata_phy_properties { - /** - * This field delineates the signature FIS received from the - * attached target. - */ - struct dev_to_host_fis signature_fis; - - /** - * This field specifies to the user if a port selector is connected - * on the specified phy. - */ - bool is_port_selector_present; - -}; - -/** - * enum sci_phy_counter_id - This enumeration depicts the various pieces of - * optional information that can be retrieved for a specific phy. - * - * - */ -enum sci_phy_counter_id { - /** - * This PHY information field tracks the number of frames received. - */ - SCIC_PHY_COUNTER_RECEIVED_FRAME, - - /** - * This PHY information field tracks the number of frames transmitted. - */ - SCIC_PHY_COUNTER_TRANSMITTED_FRAME, - - /** - * This PHY information field tracks the number of DWORDs received. - */ - SCIC_PHY_COUNTER_RECEIVED_FRAME_WORD, - - /** - * This PHY information field tracks the number of DWORDs transmitted. - */ - SCIC_PHY_COUNTER_TRANSMITTED_FRAME_DWORD, - - /** - * This PHY information field tracks the number of times DWORD - * synchronization was lost. - */ - SCIC_PHY_COUNTER_LOSS_OF_SYNC_ERROR, - - /** - * This PHY information field tracks the number of received DWORDs with - * running disparity errors. - */ - SCIC_PHY_COUNTER_RECEIVED_DISPARITY_ERROR, - - /** - * This PHY information field tracks the number of received frames with a - * CRC error (not including short or truncated frames). - */ - SCIC_PHY_COUNTER_RECEIVED_FRAME_CRC_ERROR, - - /** - * This PHY information field tracks the number of DONE (ACK/NAK TIMEOUT) - * primitives received. - */ - SCIC_PHY_COUNTER_RECEIVED_DONE_ACK_NAK_TIMEOUT, - - /** - * This PHY information field tracks the number of DONE (ACK/NAK TIMEOUT) - * primitives transmitted. - */ - SCIC_PHY_COUNTER_TRANSMITTED_DONE_ACK_NAK_TIMEOUT, - - /** - * This PHY information field tracks the number of times the inactivity - * timer for connections on the phy has been utilized. - */ - SCIC_PHY_COUNTER_INACTIVITY_TIMER_EXPIRED, - - /** - * This PHY information field tracks the number of DONE (CREDIT TIMEOUT) - * primitives received. - */ - SCIC_PHY_COUNTER_RECEIVED_DONE_CREDIT_TIMEOUT, - - /** - * This PHY information field tracks the number of DONE (CREDIT TIMEOUT) - * primitives transmitted. - */ - SCIC_PHY_COUNTER_TRANSMITTED_DONE_CREDIT_TIMEOUT, - - /** - * This PHY information field tracks the number of CREDIT BLOCKED - * primitives received. - * @note Depending on remote device implementation, credit blocks - * may occur regularly. - */ - SCIC_PHY_COUNTER_RECEIVED_CREDIT_BLOCKED, - - /** - * This PHY information field contains the number of short frames - * received. A short frame is simply a frame smaller then what is - * allowed by either the SAS or SATA specification. - */ - SCIC_PHY_COUNTER_RECEIVED_SHORT_FRAME, - - /** - * This PHY information field contains the number of frames received after - * credit has been exhausted. - */ - SCIC_PHY_COUNTER_RECEIVED_FRAME_WITHOUT_CREDIT, - - /** - * This PHY information field contains the number of frames received after - * a DONE has been received. - */ - SCIC_PHY_COUNTER_RECEIVED_FRAME_AFTER_DONE, - - /** - * This PHY information field contains the number of times the phy - * failed to achieve DWORD synchronization during speed negotiation. - */ - SCIC_PHY_COUNTER_SN_DWORD_SYNC_ERROR -}; - -enum sci_phy_states { - /** - * Simply the initial state for the base domain state machine. - */ - SCI_PHY_INITIAL, - - /** - * This state indicates that the phy has successfully been stopped. - * In this state no new IO operations are permitted on this phy. - * This state is entered from the INITIAL state. - * This state is entered from the STARTING state. - * This state is entered from the READY state. - * This state is entered from the RESETTING state. - */ - SCI_PHY_STOPPED, - - /** - * This state indicates that the phy is in the process of becomming - * ready. In this state no new IO operations are permitted on this phy. - * This state is entered from the STOPPED state. - * This state is entered from the READY state. - * This state is entered from the RESETTING state. - */ - SCI_PHY_STARTING, - - /** - * Initial state - */ - SCI_PHY_SUB_INITIAL, - - /** - * Wait state for the hardware OSSP event type notification - */ - SCI_PHY_SUB_AWAIT_OSSP_EN, - - /** - * Wait state for the PHY speed notification - */ - SCI_PHY_SUB_AWAIT_SAS_SPEED_EN, - - /** - * Wait state for the IAF Unsolicited frame notification - */ - SCI_PHY_SUB_AWAIT_IAF_UF, - - /** - * Wait state for the request to consume power - */ - SCI_PHY_SUB_AWAIT_SAS_POWER, - - /** - * Wait state for request to consume power - */ - SCI_PHY_SUB_AWAIT_SATA_POWER, - - /** - * Wait state for the SATA PHY notification - */ - SCI_PHY_SUB_AWAIT_SATA_PHY_EN, - - /** - * Wait for the SATA PHY speed notification - */ - SCI_PHY_SUB_AWAIT_SATA_SPEED_EN, - - /** - * Wait state for the SIGNATURE FIS unsolicited frame notification - */ - SCI_PHY_SUB_AWAIT_SIG_FIS_UF, - - /** - * Exit state for this state machine - */ - SCI_PHY_SUB_FINAL, - - /** - * This state indicates the the phy is now ready. Thus, the user - * is able to perform IO operations utilizing this phy as long as it - * is currently part of a valid port. - * This state is entered from the STARTING state. - */ - SCI_PHY_READY, - - /** - * This state indicates that the phy is in the process of being reset. - * In this state no new IO operations are permitted on this phy. - * This state is entered from the READY state. - */ - SCI_PHY_RESETTING, - - /** - * Simply the final state for the base phy state machine. - */ - SCI_PHY_FINAL, -}; - -void sci_phy_construct( - struct isci_phy *iphy, - struct isci_port *iport, - u8 phy_index); - -struct isci_port *phy_get_non_dummy_port(struct isci_phy *iphy); - -void sci_phy_set_port( - struct isci_phy *iphy, - struct isci_port *iport); - -enum sci_status sci_phy_initialize( - struct isci_phy *iphy, - struct scu_transport_layer_registers __iomem *transport_layer_registers, - struct scu_link_layer_registers __iomem *link_layer_registers); - -enum sci_status sci_phy_start( - struct isci_phy *iphy); - -enum sci_status sci_phy_stop( - struct isci_phy *iphy); - -enum sci_status sci_phy_reset( - struct isci_phy *iphy); - -void sci_phy_resume( - struct isci_phy *iphy); - -void sci_phy_setup_transport( - struct isci_phy *iphy, - u32 device_id); - -enum sci_status sci_phy_event_handler( - struct isci_phy *iphy, - u32 event_code); - -enum sci_status sci_phy_frame_handler( - struct isci_phy *iphy, - u32 frame_index); - -enum sci_status sci_phy_consume_power_handler( - struct isci_phy *iphy); - -void sci_phy_get_sas_address( - struct isci_phy *iphy, - struct sci_sas_address *sas_address); - -void sci_phy_get_attached_sas_address( - struct isci_phy *iphy, - struct sci_sas_address *sas_address); - -struct sci_phy_proto; -void sci_phy_get_protocols( - struct isci_phy *iphy, - struct sci_phy_proto *protocols); -enum sas_linkrate sci_phy_linkrate(struct isci_phy *iphy); - -struct isci_host; -void isci_phy_init(struct isci_phy *iphy, struct isci_host *ihost, int index); -int isci_phy_control(struct asd_sas_phy *phy, enum phy_func func, void *buf); - -#endif /* !defined(_ISCI_PHY_H_) */ diff --git a/trunk/drivers/scsi/isci/port.c b/trunk/drivers/scsi/isci/port.c deleted file mode 100644 index 8f6f9b77e41a..000000000000 --- a/trunk/drivers/scsi/isci/port.c +++ /dev/null @@ -1,1757 +0,0 @@ -/* - * This file is provided under a dual BSD/GPLv2 license. When using or - * redistributing this file, you may do so under either license. - * - * GPL LICENSE SUMMARY - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License 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., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. - * The full GNU General Public License is included in this distribution - * in the file called LICENSE.GPL. - * - * BSD LICENSE - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Intel Corporation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "isci.h" -#include "port.h" -#include "request.h" - -#define SCIC_SDS_PORT_HARD_RESET_TIMEOUT (1000) -#define SCU_DUMMY_INDEX (0xFFFF) - -static void isci_port_change_state(struct isci_port *iport, enum isci_status status) -{ - unsigned long flags; - - dev_dbg(&iport->isci_host->pdev->dev, - "%s: iport = %p, state = 0x%x\n", - __func__, iport, status); - - /* XXX pointless lock */ - spin_lock_irqsave(&iport->state_lock, flags); - iport->status = status; - spin_unlock_irqrestore(&iport->state_lock, flags); -} - -static void sci_port_get_protocols(struct isci_port *iport, struct sci_phy_proto *proto) -{ - u8 index; - - proto->all = 0; - for (index = 0; index < SCI_MAX_PHYS; index++) { - struct isci_phy *iphy = iport->phy_table[index]; - - if (!iphy) - continue; - sci_phy_get_protocols(iphy, proto); - } -} - -static u32 sci_port_get_phys(struct isci_port *iport) -{ - u32 index; - u32 mask; - - mask = 0; - for (index = 0; index < SCI_MAX_PHYS; index++) - if (iport->phy_table[index]) - mask |= (1 << index); - - return mask; -} - -/** - * sci_port_get_properties() - This method simply returns the properties - * regarding the port, such as: physical index, protocols, sas address, etc. - * @port: this parameter specifies the port for which to retrieve the physical - * index. - * @properties: This parameter specifies the properties structure into which to - * copy the requested information. - * - * Indicate if the user specified a valid port. SCI_SUCCESS This value is - * returned if the specified port was valid. SCI_FAILURE_INVALID_PORT This - * value is returned if the specified port is not valid. When this value is - * returned, no data is copied to the properties output parameter. - */ -static enum sci_status sci_port_get_properties(struct isci_port *iport, - struct sci_port_properties *prop) -{ - if (!iport || iport->logical_port_index == SCIC_SDS_DUMMY_PORT) - return SCI_FAILURE_INVALID_PORT; - - prop->index = iport->logical_port_index; - prop->phy_mask = sci_port_get_phys(iport); - sci_port_get_sas_address(iport, &prop->local.sas_address); - sci_port_get_protocols(iport, &prop->local.protocols); - sci_port_get_attached_sas_address(iport, &prop->remote.sas_address); - - return SCI_SUCCESS; -} - -static void sci_port_bcn_enable(struct isci_port *iport) -{ - struct isci_phy *iphy; - u32 val; - int i; - - for (i = 0; i < ARRAY_SIZE(iport->phy_table); i++) { - iphy = iport->phy_table[i]; - if (!iphy) - continue; - val = readl(&iphy->link_layer_registers->link_layer_control); - /* clear the bit by writing 1. */ - writel(val, &iphy->link_layer_registers->link_layer_control); - } -} - -/* called under sci_lock to stabilize phy:port associations */ -void isci_port_bcn_enable(struct isci_host *ihost, struct isci_port *iport) -{ - int i; - - clear_bit(IPORT_BCN_BLOCKED, &iport->flags); - wake_up(&ihost->eventq); - - if (!test_and_clear_bit(IPORT_BCN_PENDING, &iport->flags)) - return; - - for (i = 0; i < ARRAY_SIZE(iport->phy_table); i++) { - struct isci_phy *iphy = iport->phy_table[i]; - - if (!iphy) - continue; - - ihost->sas_ha.notify_port_event(&iphy->sas_phy, - PORTE_BROADCAST_RCVD); - break; - } -} - -static void isci_port_bc_change_received(struct isci_host *ihost, - struct isci_port *iport, - struct isci_phy *iphy) -{ - if (iport && test_bit(IPORT_BCN_BLOCKED, &iport->flags)) { - dev_dbg(&ihost->pdev->dev, - "%s: disabled BCN; isci_phy = %p, sas_phy = %p\n", - __func__, iphy, &iphy->sas_phy); - set_bit(IPORT_BCN_PENDING, &iport->flags); - atomic_inc(&iport->event); - wake_up(&ihost->eventq); - } else { - dev_dbg(&ihost->pdev->dev, - "%s: isci_phy = %p, sas_phy = %p\n", - __func__, iphy, &iphy->sas_phy); - - ihost->sas_ha.notify_port_event(&iphy->sas_phy, - PORTE_BROADCAST_RCVD); - } - sci_port_bcn_enable(iport); -} - -static void isci_port_link_up(struct isci_host *isci_host, - struct isci_port *iport, - struct isci_phy *iphy) -{ - unsigned long flags; - struct sci_port_properties properties; - unsigned long success = true; - - BUG_ON(iphy->isci_port != NULL); - - iphy->isci_port = iport; - - dev_dbg(&isci_host->pdev->dev, - "%s: isci_port = %p\n", - __func__, iport); - - spin_lock_irqsave(&iphy->sas_phy.frame_rcvd_lock, flags); - - isci_port_change_state(iphy->isci_port, isci_starting); - - sci_port_get_properties(iport, &properties); - - if (iphy->protocol == SCIC_SDS_PHY_PROTOCOL_SATA) { - u64 attached_sas_address; - - iphy->sas_phy.oob_mode = SATA_OOB_MODE; - iphy->sas_phy.frame_rcvd_size = sizeof(struct dev_to_host_fis); - - /* - * For direct-attached SATA devices, the SCI core will - * automagically assign a SAS address to the end device - * for the purpose of creating a port. This SAS address - * will not be the same as assigned to the PHY and needs - * to be obtained from struct sci_port_properties properties. - */ - attached_sas_address = properties.remote.sas_address.high; - attached_sas_address <<= 32; - attached_sas_address |= properties.remote.sas_address.low; - swab64s(&attached_sas_address); - - memcpy(&iphy->sas_phy.attached_sas_addr, - &attached_sas_address, sizeof(attached_sas_address)); - } else if (iphy->protocol == SCIC_SDS_PHY_PROTOCOL_SAS) { - iphy->sas_phy.oob_mode = SAS_OOB_MODE; - iphy->sas_phy.frame_rcvd_size = sizeof(struct sas_identify_frame); - - /* Copy the attached SAS address from the IAF */ - memcpy(iphy->sas_phy.attached_sas_addr, - iphy->frame_rcvd.iaf.sas_addr, SAS_ADDR_SIZE); - } else { - dev_err(&isci_host->pdev->dev, "%s: unkown target\n", __func__); - success = false; - } - - iphy->sas_phy.phy->negotiated_linkrate = sci_phy_linkrate(iphy); - - spin_unlock_irqrestore(&iphy->sas_phy.frame_rcvd_lock, flags); - - /* Notify libsas that we have an address frame, if indeed - * we've found an SSP, SMP, or STP target */ - if (success) - isci_host->sas_ha.notify_port_event(&iphy->sas_phy, - PORTE_BYTES_DMAED); -} - - -/** - * isci_port_link_down() - This function is called by the sci core when a link - * becomes inactive. - * @isci_host: This parameter specifies the isci host object. - * @phy: This parameter specifies the isci phy with the active link. - * @port: This parameter specifies the isci port with the active link. - * - */ -static void isci_port_link_down(struct isci_host *isci_host, - struct isci_phy *isci_phy, - struct isci_port *isci_port) -{ - struct isci_remote_device *isci_device; - - dev_dbg(&isci_host->pdev->dev, - "%s: isci_port = %p\n", __func__, isci_port); - - if (isci_port) { - - /* check to see if this is the last phy on this port. */ - if (isci_phy->sas_phy.port && - isci_phy->sas_phy.port->num_phys == 1) { - atomic_inc(&isci_port->event); - isci_port_bcn_enable(isci_host, isci_port); - - /* change the state for all devices on this port. The - * next task sent to this device will be returned as - * SAS_TASK_UNDELIVERED, and the scsi mid layer will - * remove the target - */ - list_for_each_entry(isci_device, - &isci_port->remote_dev_list, - node) { - dev_dbg(&isci_host->pdev->dev, - "%s: isci_device = %p\n", - __func__, isci_device); - set_bit(IDEV_GONE, &isci_device->flags); - } - } - isci_port_change_state(isci_port, isci_stopping); - } - - /* Notify libsas of the borken link, this will trigger calls to our - * isci_port_deformed and isci_dev_gone functions. - */ - sas_phy_disconnected(&isci_phy->sas_phy); - isci_host->sas_ha.notify_phy_event(&isci_phy->sas_phy, - PHYE_LOSS_OF_SIGNAL); - - isci_phy->isci_port = NULL; - - dev_dbg(&isci_host->pdev->dev, - "%s: isci_port = %p - Done\n", __func__, isci_port); -} - - -/** - * isci_port_ready() - This function is called by the sci core when a link - * becomes ready. - * @isci_host: This parameter specifies the isci host object. - * @port: This parameter specifies the sci port with the active link. - * - */ -static void isci_port_ready(struct isci_host *isci_host, struct isci_port *isci_port) -{ - dev_dbg(&isci_host->pdev->dev, - "%s: isci_port = %p\n", __func__, isci_port); - - complete_all(&isci_port->start_complete); - isci_port_change_state(isci_port, isci_ready); - return; -} - -/** - * isci_port_not_ready() - This function is called by the sci core when a link - * is not ready. All remote devices on this link will be removed if they are - * in the stopping state. - * @isci_host: This parameter specifies the isci host object. - * @port: This parameter specifies the sci port with the active link. - * - */ -static void isci_port_not_ready(struct isci_host *isci_host, struct isci_port *isci_port) -{ - dev_dbg(&isci_host->pdev->dev, - "%s: isci_port = %p\n", __func__, isci_port); -} - -static void isci_port_stop_complete(struct isci_host *ihost, - struct isci_port *iport, - enum sci_status completion_status) -{ - dev_dbg(&ihost->pdev->dev, "Port stop complete\n"); -} - -/** - * isci_port_hard_reset_complete() - This function is called by the sci core - * when the hard reset complete notification has been received. - * @port: This parameter specifies the sci port with the active link. - * @completion_status: This parameter specifies the core status for the reset - * process. - * - */ -static void isci_port_hard_reset_complete(struct isci_port *isci_port, - enum sci_status completion_status) -{ - dev_dbg(&isci_port->isci_host->pdev->dev, - "%s: isci_port = %p, completion_status=%x\n", - __func__, isci_port, completion_status); - - /* Save the status of the hard reset from the port. */ - isci_port->hard_reset_status = completion_status; - - complete_all(&isci_port->hard_reset_complete); -} - -/* This method will return a true value if the specified phy can be assigned to - * this port The following is a list of phys for each port that are allowed: - - * Port 0 - 3 2 1 0 - Port 1 - 1 - Port 2 - 3 2 - Port 3 - 3 This method - * doesn't preclude all configurations. It merely ensures that a phy is part - * of the allowable set of phy identifiers for that port. For example, one - * could assign phy 3 to port 0 and no other phys. Please refer to - * sci_port_is_phy_mask_valid() for information regarding whether the - * phy_mask for a port can be supported. bool true if this is a valid phy - * assignment for the port false if this is not a valid phy assignment for the - * port - */ -bool sci_port_is_valid_phy_assignment(struct isci_port *iport, u32 phy_index) -{ - struct isci_host *ihost = iport->owning_controller; - struct sci_user_parameters *user = &ihost->user_parameters; - - /* Initialize to invalid value. */ - u32 existing_phy_index = SCI_MAX_PHYS; - u32 index; - - if ((iport->physical_port_index == 1) && (phy_index != 1)) - return false; - - if (iport->physical_port_index == 3 && phy_index != 3) - return false; - - if (iport->physical_port_index == 2 && - (phy_index == 0 || phy_index == 1)) - return false; - - for (index = 0; index < SCI_MAX_PHYS; index++) - if (iport->phy_table[index] && index != phy_index) - existing_phy_index = index; - - /* Ensure that all of the phys in the port are capable of - * operating at the same maximum link rate. - */ - if (existing_phy_index < SCI_MAX_PHYS && - user->phys[phy_index].max_speed_generation != - user->phys[existing_phy_index].max_speed_generation) - return false; - - return true; -} - -/** - * - * @sci_port: This is the port object for which to determine if the phy mask - * can be supported. - * - * This method will return a true value if the port's phy mask can be supported - * by the SCU. The following is a list of valid PHY mask configurations for - * each port: - Port 0 - [[3 2] 1] 0 - Port 1 - [1] - Port 2 - [[3] 2] - * - Port 3 - [3] This method returns a boolean indication specifying if the - * phy mask can be supported. true if this is a valid phy assignment for the - * port false if this is not a valid phy assignment for the port - */ -static bool sci_port_is_phy_mask_valid( - struct isci_port *iport, - u32 phy_mask) -{ - if (iport->physical_port_index == 0) { - if (((phy_mask & 0x0F) == 0x0F) - || ((phy_mask & 0x03) == 0x03) - || ((phy_mask & 0x01) == 0x01) - || (phy_mask == 0)) - return true; - } else if (iport->physical_port_index == 1) { - if (((phy_mask & 0x02) == 0x02) - || (phy_mask == 0)) - return true; - } else if (iport->physical_port_index == 2) { - if (((phy_mask & 0x0C) == 0x0C) - || ((phy_mask & 0x04) == 0x04) - || (phy_mask == 0)) - return true; - } else if (iport->physical_port_index == 3) { - if (((phy_mask & 0x08) == 0x08) - || (phy_mask == 0)) - return true; - } - - return false; -} - -/* - * This method retrieves a currently active (i.e. connected) phy contained in - * the port. Currently, the lowest order phy that is connected is returned. - * This method returns a pointer to a SCIS_SDS_PHY object. NULL This value is - * returned if there are no currently active (i.e. connected to a remote end - * point) phys contained in the port. All other values specify a struct sci_phy - * object that is active in the port. - */ -static struct isci_phy *sci_port_get_a_connected_phy(struct isci_port *iport) -{ - u32 index; - struct isci_phy *iphy; - - for (index = 0; index < SCI_MAX_PHYS; index++) { - /* Ensure that the phy is both part of the port and currently - * connected to the remote end-point. - */ - iphy = iport->phy_table[index]; - if (iphy && sci_port_active_phy(iport, iphy)) - return iphy; - } - - return NULL; -} - -static enum sci_status sci_port_set_phy(struct isci_port *iport, struct isci_phy *iphy) -{ - /* Check to see if we can add this phy to a port - * that means that the phy is not part of a port and that the port does - * not already have a phy assinged to the phy index. - */ - if (!iport->phy_table[iphy->phy_index] && - !phy_get_non_dummy_port(iphy) && - sci_port_is_valid_phy_assignment(iport, iphy->phy_index)) { - /* Phy is being added in the stopped state so we are in MPC mode - * make logical port index = physical port index - */ - iport->logical_port_index = iport->physical_port_index; - iport->phy_table[iphy->phy_index] = iphy; - sci_phy_set_port(iphy, iport); - - return SCI_SUCCESS; - } - - return SCI_FAILURE; -} - -static enum sci_status sci_port_clear_phy(struct isci_port *iport, struct isci_phy *iphy) -{ - /* Make sure that this phy is part of this port */ - if (iport->phy_table[iphy->phy_index] == iphy && - phy_get_non_dummy_port(iphy) == iport) { - struct isci_host *ihost = iport->owning_controller; - - /* Yep it is assigned to this port so remove it */ - sci_phy_set_port(iphy, &ihost->ports[SCI_MAX_PORTS]); - iport->phy_table[iphy->phy_index] = NULL; - return SCI_SUCCESS; - } - - return SCI_FAILURE; -} - -void sci_port_get_sas_address(struct isci_port *iport, struct sci_sas_address *sas) -{ - u32 index; - - sas->high = 0; - sas->low = 0; - for (index = 0; index < SCI_MAX_PHYS; index++) - if (iport->phy_table[index]) - sci_phy_get_sas_address(iport->phy_table[index], sas); -} - -void sci_port_get_attached_sas_address(struct isci_port *iport, struct sci_sas_address *sas) -{ - struct isci_phy *iphy; - - /* - * Ensure that the phy is both part of the port and currently - * connected to the remote end-point. - */ - iphy = sci_port_get_a_connected_phy(iport); - if (iphy) { - if (iphy->protocol != SCIC_SDS_PHY_PROTOCOL_SATA) { - sci_phy_get_attached_sas_address(iphy, sas); - } else { - sci_phy_get_sas_address(iphy, sas); - sas->low += iphy->phy_index; - } - } else { - sas->high = 0; - sas->low = 0; - } -} - -/** - * sci_port_construct_dummy_rnc() - create dummy rnc for si workaround - * - * @sci_port: logical port on which we need to create the remote node context - * @rni: remote node index for this remote node context. - * - * This routine will construct a dummy remote node context data structure - * This structure will be posted to the hardware to work around a scheduler - * error in the hardware. - */ -static void sci_port_construct_dummy_rnc(struct isci_port *iport, u16 rni) -{ - union scu_remote_node_context *rnc; - - rnc = &iport->owning_controller->remote_node_context_table[rni]; - - memset(rnc, 0, sizeof(union scu_remote_node_context)); - - rnc->ssp.remote_sas_address_hi = 0; - rnc->ssp.remote_sas_address_lo = 0; - - rnc->ssp.remote_node_index = rni; - rnc->ssp.remote_node_port_width = 1; - rnc->ssp.logical_port_index = iport->physical_port_index; - - rnc->ssp.nexus_loss_timer_enable = false; - rnc->ssp.check_bit = false; - rnc->ssp.is_valid = true; - rnc->ssp.is_remote_node_context = true; - rnc->ssp.function_number = 0; - rnc->ssp.arbitration_wait_time = 0; -} - -/* - * construct a dummy task context data structure. This - * structure will be posted to the hardwre to work around a scheduler error - * in the hardware. - */ -static void sci_port_construct_dummy_task(struct isci_port *iport, u16 tag) -{ - struct isci_host *ihost = iport->owning_controller; - struct scu_task_context *task_context; - - task_context = &ihost->task_context_table[ISCI_TAG_TCI(tag)]; - memset(task_context, 0, sizeof(struct scu_task_context)); - - task_context->initiator_request = 1; - task_context->connection_rate = 1; - task_context->logical_port_index = iport->physical_port_index; - task_context->protocol_type = SCU_TASK_CONTEXT_PROTOCOL_SSP; - task_context->task_index = ISCI_TAG_TCI(tag); - task_context->valid = SCU_TASK_CONTEXT_VALID; - task_context->context_type = SCU_TASK_CONTEXT_TYPE; - task_context->remote_node_index = iport->reserved_rni; - task_context->do_not_dma_ssp_good_response = 1; - task_context->task_phase = 0x01; -} - -static void sci_port_destroy_dummy_resources(struct isci_port *iport) -{ - struct isci_host *ihost = iport->owning_controller; - - if (iport->reserved_tag != SCI_CONTROLLER_INVALID_IO_TAG) - isci_free_tag(ihost, iport->reserved_tag); - - if (iport->reserved_rni != SCU_DUMMY_INDEX) - sci_remote_node_table_release_remote_node_index(&ihost->available_remote_nodes, - 1, iport->reserved_rni); - - iport->reserved_rni = SCU_DUMMY_INDEX; - iport->reserved_tag = SCI_CONTROLLER_INVALID_IO_TAG; -} - -void sci_port_setup_transports(struct isci_port *iport, u32 device_id) -{ - u8 index; - - for (index = 0; index < SCI_MAX_PHYS; index++) { - if (iport->active_phy_mask & (1 << index)) - sci_phy_setup_transport(iport->phy_table[index], device_id); - } -} - -static void sci_port_activate_phy(struct isci_port *iport, struct isci_phy *iphy, - bool do_notify_user) -{ - struct isci_host *ihost = iport->owning_controller; - - if (iphy->protocol != SCIC_SDS_PHY_PROTOCOL_SATA) - sci_phy_resume(iphy); - - iport->active_phy_mask |= 1 << iphy->phy_index; - - sci_controller_clear_invalid_phy(ihost, iphy); - - if (do_notify_user == true) - isci_port_link_up(ihost, iport, iphy); -} - -void sci_port_deactivate_phy(struct isci_port *iport, struct isci_phy *iphy, - bool do_notify_user) -{ - struct isci_host *ihost = iport->owning_controller; - - iport->active_phy_mask &= ~(1 << iphy->phy_index); - - iphy->max_negotiated_speed = SAS_LINK_RATE_UNKNOWN; - - /* Re-assign the phy back to the LP as if it were a narrow port */ - writel(iphy->phy_index, - &iport->port_pe_configuration_register[iphy->phy_index]); - - if (do_notify_user == true) - isci_port_link_down(ihost, iphy, iport); -} - -static void sci_port_invalid_link_up(struct isci_port *iport, struct isci_phy *iphy) -{ - struct isci_host *ihost = iport->owning_controller; - - /* - * Check to see if we have alreay reported this link as bad and if - * not go ahead and tell the SCI_USER that we have discovered an - * invalid link. - */ - if ((ihost->invalid_phy_mask & (1 << iphy->phy_index)) == 0) { - ihost->invalid_phy_mask |= 1 << iphy->phy_index; - dev_warn(&ihost->pdev->dev, "Invalid link up!\n"); - } -} - -static bool is_port_ready_state(enum sci_port_states state) -{ - switch (state) { - case SCI_PORT_READY: - case SCI_PORT_SUB_WAITING: - case SCI_PORT_SUB_OPERATIONAL: - case SCI_PORT_SUB_CONFIGURING: - return true; - default: - return false; - } -} - -/* flag dummy rnc hanling when exiting a ready state */ -static void port_state_machine_change(struct isci_port *iport, - enum sci_port_states state) -{ - struct sci_base_state_machine *sm = &iport->sm; - enum sci_port_states old_state = sm->current_state_id; - - if (is_port_ready_state(old_state) && !is_port_ready_state(state)) - iport->ready_exit = true; - - sci_change_state(sm, state); - iport->ready_exit = false; -} - -/** - * sci_port_general_link_up_handler - phy can be assigned to port? - * @sci_port: sci_port object for which has a phy that has gone link up. - * @sci_phy: This is the struct isci_phy object that has gone link up. - * @do_notify_user: This parameter specifies whether to inform the user (via - * sci_port_link_up()) as to the fact that a new phy as become ready. - * - * Determine if this phy can be assigned to this - * port . If the phy is not a valid PHY for - * this port then the function will notify the user. A PHY can only be - * part of a port if it's attached SAS ADDRESS is the same as all other PHYs in - * the same port. none - */ -static void sci_port_general_link_up_handler(struct isci_port *iport, - struct isci_phy *iphy, - bool do_notify_user) -{ - struct sci_sas_address port_sas_address; - struct sci_sas_address phy_sas_address; - - sci_port_get_attached_sas_address(iport, &port_sas_address); - sci_phy_get_attached_sas_address(iphy, &phy_sas_address); - - /* If the SAS address of the new phy matches the SAS address of - * other phys in the port OR this is the first phy in the port, - * then activate the phy and allow it to be used for operations - * in this port. - */ - if ((phy_sas_address.high == port_sas_address.high && - phy_sas_address.low == port_sas_address.low) || - iport->active_phy_mask == 0) { - struct sci_base_state_machine *sm = &iport->sm; - - sci_port_activate_phy(iport, iphy, do_notify_user); - if (sm->current_state_id == SCI_PORT_RESETTING) - port_state_machine_change(iport, SCI_PORT_READY); - } else - sci_port_invalid_link_up(iport, iphy); -} - - - -/** - * This method returns false if the port only has a single phy object assigned. - * If there are no phys or more than one phy then the method will return - * true. - * @sci_port: The port for which the wide port condition is to be checked. - * - * bool true Is returned if this is a wide ported port. false Is returned if - * this is a narrow port. - */ -static bool sci_port_is_wide(struct isci_port *iport) -{ - u32 index; - u32 phy_count = 0; - - for (index = 0; index < SCI_MAX_PHYS; index++) { - if (iport->phy_table[index] != NULL) { - phy_count++; - } - } - - return phy_count != 1; -} - -/** - * This method is called by the PHY object when the link is detected. if the - * port wants the PHY to continue on to the link up state then the port - * layer must return true. If the port object returns false the phy object - * must halt its attempt to go link up. - * @sci_port: The port associated with the phy object. - * @sci_phy: The phy object that is trying to go link up. - * - * true if the phy object can continue to the link up condition. true Is - * returned if this phy can continue to the ready state. false Is returned if - * can not continue on to the ready state. This notification is in place for - * wide ports and direct attached phys. Since there are no wide ported SATA - * devices this could become an invalid port configuration. - */ -bool sci_port_link_detected( - struct isci_port *iport, - struct isci_phy *iphy) -{ - if ((iport->logical_port_index != SCIC_SDS_DUMMY_PORT) && - (iphy->protocol == SCIC_SDS_PHY_PROTOCOL_SATA) && - sci_port_is_wide(iport)) { - sci_port_invalid_link_up(iport, iphy); - - return false; - } - - return true; -} - -static void port_timeout(unsigned long data) -{ - struct sci_timer *tmr = (struct sci_timer *)data; - struct isci_port *iport = container_of(tmr, typeof(*iport), timer); - struct isci_host *ihost = iport->owning_controller; - unsigned long flags; - u32 current_state; - - spin_lock_irqsave(&ihost->scic_lock, flags); - - if (tmr->cancel) - goto done; - - current_state = iport->sm.current_state_id; - - if (current_state == SCI_PORT_RESETTING) { - /* if the port is still in the resetting state then the timeout - * fired before the reset completed. - */ - port_state_machine_change(iport, SCI_PORT_FAILED); - } else if (current_state == SCI_PORT_STOPPED) { - /* if the port is stopped then the start request failed In this - * case stay in the stopped state. - */ - dev_err(sciport_to_dev(iport), - "%s: SCIC Port 0x%p failed to stop before tiemout.\n", - __func__, - iport); - } else if (current_state == SCI_PORT_STOPPING) { - /* if the port is still stopping then the stop has not completed */ - isci_port_stop_complete(iport->owning_controller, - iport, - SCI_FAILURE_TIMEOUT); - } else { - /* The port is in the ready state and we have a timer - * reporting a timeout this should not happen. - */ - dev_err(sciport_to_dev(iport), - "%s: SCIC Port 0x%p is processing a timeout operation " - "in state %d.\n", __func__, iport, current_state); - } - -done: - spin_unlock_irqrestore(&ihost->scic_lock, flags); -} - -/* --------------------------------------------------------------------------- */ - -/** - * This function updates the hardwares VIIT entry for this port. - * - * - */ -static void sci_port_update_viit_entry(struct isci_port *iport) -{ - struct sci_sas_address sas_address; - - sci_port_get_sas_address(iport, &sas_address); - - writel(sas_address.high, - &iport->viit_registers->initiator_sas_address_hi); - writel(sas_address.low, - &iport->viit_registers->initiator_sas_address_lo); - - /* This value get cleared just in case its not already cleared */ - writel(0, &iport->viit_registers->reserved); - - /* We are required to update the status register last */ - writel(SCU_VIIT_ENTRY_ID_VIIT | - SCU_VIIT_IPPT_INITIATOR | - ((1 << iport->physical_port_index) << SCU_VIIT_ENTRY_LPVIE_SHIFT) | - SCU_VIIT_STATUS_ALL_VALID, - &iport->viit_registers->status); -} - -enum sas_linkrate sci_port_get_max_allowed_speed(struct isci_port *iport) -{ - u16 index; - struct isci_phy *iphy; - enum sas_linkrate max_allowed_speed = SAS_LINK_RATE_6_0_GBPS; - - /* - * Loop through all of the phys in this port and find the phy with the - * lowest maximum link rate. */ - for (index = 0; index < SCI_MAX_PHYS; index++) { - iphy = iport->phy_table[index]; - if (iphy && sci_port_active_phy(iport, iphy) && - iphy->max_negotiated_speed < max_allowed_speed) - max_allowed_speed = iphy->max_negotiated_speed; - } - - return max_allowed_speed; -} - -static void sci_port_suspend_port_task_scheduler(struct isci_port *iport) -{ - u32 pts_control_value; - - pts_control_value = readl(&iport->port_task_scheduler_registers->control); - pts_control_value |= SCU_PTSxCR_GEN_BIT(SUSPEND); - writel(pts_control_value, &iport->port_task_scheduler_registers->control); -} - -/** - * sci_port_post_dummy_request() - post dummy/workaround request - * @sci_port: port to post task - * - * Prevent the hardware scheduler from posting new requests to the front - * of the scheduler queue causing a starvation problem for currently - * ongoing requests. - * - */ -static void sci_port_post_dummy_request(struct isci_port *iport) -{ - struct isci_host *ihost = iport->owning_controller; - u16 tag = iport->reserved_tag; - struct scu_task_context *tc; - u32 command; - - tc = &ihost->task_context_table[ISCI_TAG_TCI(tag)]; - tc->abort = 0; - - command = SCU_CONTEXT_COMMAND_REQUEST_TYPE_POST_TC | - iport->physical_port_index << SCU_CONTEXT_COMMAND_LOGICAL_PORT_SHIFT | - ISCI_TAG_TCI(tag); - - sci_controller_post_request(ihost, command); -} - -/** - * This routine will abort the dummy request. This will alow the hardware to - * power down parts of the silicon to save power. - * - * @sci_port: The port on which the task must be aborted. - * - */ -static void sci_port_abort_dummy_request(struct isci_port *iport) -{ - struct isci_host *ihost = iport->owning_controller; - u16 tag = iport->reserved_tag; - struct scu_task_context *tc; - u32 command; - - tc = &ihost->task_context_table[ISCI_TAG_TCI(tag)]; - tc->abort = 1; - - command = SCU_CONTEXT_COMMAND_REQUEST_POST_TC_ABORT | - iport->physical_port_index << SCU_CONTEXT_COMMAND_LOGICAL_PORT_SHIFT | - ISCI_TAG_TCI(tag); - - sci_controller_post_request(ihost, command); -} - -/** - * - * @sci_port: This is the struct isci_port object to resume. - * - * This method will resume the port task scheduler for this port object. none - */ -static void -sci_port_resume_port_task_scheduler(struct isci_port *iport) -{ - u32 pts_control_value; - - pts_control_value = readl(&iport->port_task_scheduler_registers->control); - pts_control_value &= ~SCU_PTSxCR_GEN_BIT(SUSPEND); - writel(pts_control_value, &iport->port_task_scheduler_registers->control); -} - -static void sci_port_ready_substate_waiting_enter(struct sci_base_state_machine *sm) -{ - struct isci_port *iport = container_of(sm, typeof(*iport), sm); - - sci_port_suspend_port_task_scheduler(iport); - - iport->not_ready_reason = SCIC_PORT_NOT_READY_NO_ACTIVE_PHYS; - - if (iport->active_phy_mask != 0) { - /* At least one of the phys on the port is ready */ - port_state_machine_change(iport, - SCI_PORT_SUB_OPERATIONAL); - } -} - -static void sci_port_ready_substate_operational_enter(struct sci_base_state_machine *sm) -{ - u32 index; - struct isci_port *iport = container_of(sm, typeof(*iport), sm); - struct isci_host *ihost = iport->owning_controller; - - isci_port_ready(ihost, iport); - - for (index = 0; index < SCI_MAX_PHYS; index++) { - if (iport->phy_table[index]) { - writel(iport->physical_port_index, - &iport->port_pe_configuration_register[ - iport->phy_table[index]->phy_index]); - } - } - - sci_port_update_viit_entry(iport); - - sci_port_resume_port_task_scheduler(iport); - - /* - * Post the dummy task for the port so the hardware can schedule - * io correctly - */ - sci_port_post_dummy_request(iport); -} - -static void sci_port_invalidate_dummy_remote_node(struct isci_port *iport) -{ - struct isci_host *ihost = iport->owning_controller; - u8 phys_index = iport->physical_port_index; - union scu_remote_node_context *rnc; - u16 rni = iport->reserved_rni; - u32 command; - - rnc = &ihost->remote_node_context_table[rni]; - - rnc->ssp.is_valid = false; - - /* ensure the preceding tc abort request has reached the - * controller and give it ample time to act before posting the rnc - * invalidate - */ - readl(&ihost->smu_registers->interrupt_status); /* flush */ - udelay(10); - - command = SCU_CONTEXT_COMMAND_POST_RNC_INVALIDATE | - phys_index << SCU_CONTEXT_COMMAND_LOGICAL_PORT_SHIFT | rni; - - sci_controller_post_request(ihost, command); -} - -/** - * - * @object: This is the object which is cast to a struct isci_port object. - * - * This method will perform the actions required by the struct isci_port on - * exiting the SCI_PORT_SUB_OPERATIONAL. This function reports - * the port not ready and suspends the port task scheduler. none - */ -static void sci_port_ready_substate_operational_exit(struct sci_base_state_machine *sm) -{ - struct isci_port *iport = container_of(sm, typeof(*iport), sm); - struct isci_host *ihost = iport->owning_controller; - - /* - * Kill the dummy task for this port if it has not yet posted - * the hardware will treat this as a NOP and just return abort - * complete. - */ - sci_port_abort_dummy_request(iport); - - isci_port_not_ready(ihost, iport); - - if (iport->ready_exit) - sci_port_invalidate_dummy_remote_node(iport); -} - -static void sci_port_ready_substate_configuring_enter(struct sci_base_state_machine *sm) -{ - struct isci_port *iport = container_of(sm, typeof(*iport), sm); - struct isci_host *ihost = iport->owning_controller; - - if (iport->active_phy_mask == 0) { - isci_port_not_ready(ihost, iport); - - port_state_machine_change(iport, - SCI_PORT_SUB_WAITING); - } else if (iport->started_request_count == 0) - port_state_machine_change(iport, - SCI_PORT_SUB_OPERATIONAL); -} - -static void sci_port_ready_substate_configuring_exit(struct sci_base_state_machine *sm) -{ - struct isci_port *iport = container_of(sm, typeof(*iport), sm); - - sci_port_suspend_port_task_scheduler(iport); - if (iport->ready_exit) - sci_port_invalidate_dummy_remote_node(iport); -} - -enum sci_status sci_port_start(struct isci_port *iport) -{ - struct isci_host *ihost = iport->owning_controller; - enum sci_status status = SCI_SUCCESS; - enum sci_port_states state; - u32 phy_mask; - - state = iport->sm.current_state_id; - if (state != SCI_PORT_STOPPED) { - dev_warn(sciport_to_dev(iport), - "%s: in wrong state: %d\n", __func__, state); - return SCI_FAILURE_INVALID_STATE; - } - - if (iport->assigned_device_count > 0) { - /* TODO This is a start failure operation because - * there are still devices assigned to this port. - * There must be no devices assigned to a port on a - * start operation. - */ - return SCI_FAILURE_UNSUPPORTED_PORT_CONFIGURATION; - } - - if (iport->reserved_rni == SCU_DUMMY_INDEX) { - u16 rni = sci_remote_node_table_allocate_remote_node( - &ihost->available_remote_nodes, 1); - - if (rni != SCU_DUMMY_INDEX) - sci_port_construct_dummy_rnc(iport, rni); - else - status = SCI_FAILURE_INSUFFICIENT_RESOURCES; - iport->reserved_rni = rni; - } - - if (iport->reserved_tag == SCI_CONTROLLER_INVALID_IO_TAG) { - u16 tag; - - tag = isci_alloc_tag(ihost); - if (tag == SCI_CONTROLLER_INVALID_IO_TAG) - status = SCI_FAILURE_INSUFFICIENT_RESOURCES; - else - sci_port_construct_dummy_task(iport, tag); - iport->reserved_tag = tag; - } - - if (status == SCI_SUCCESS) { - phy_mask = sci_port_get_phys(iport); - - /* - * There are one or more phys assigned to this port. Make sure - * the port's phy mask is in fact legal and supported by the - * silicon. - */ - if (sci_port_is_phy_mask_valid(iport, phy_mask) == true) { - port_state_machine_change(iport, - SCI_PORT_READY); - - return SCI_SUCCESS; - } - status = SCI_FAILURE; - } - - if (status != SCI_SUCCESS) - sci_port_destroy_dummy_resources(iport); - - return status; -} - -enum sci_status sci_port_stop(struct isci_port *iport) -{ - enum sci_port_states state; - - state = iport->sm.current_state_id; - switch (state) { - case SCI_PORT_STOPPED: - return SCI_SUCCESS; - case SCI_PORT_SUB_WAITING: - case SCI_PORT_SUB_OPERATIONAL: - case SCI_PORT_SUB_CONFIGURING: - case SCI_PORT_RESETTING: - port_state_machine_change(iport, - SCI_PORT_STOPPING); - return SCI_SUCCESS; - default: - dev_warn(sciport_to_dev(iport), - "%s: in wrong state: %d\n", __func__, state); - return SCI_FAILURE_INVALID_STATE; - } -} - -static enum sci_status sci_port_hard_reset(struct isci_port *iport, u32 timeout) -{ - enum sci_status status = SCI_FAILURE_INVALID_PHY; - struct isci_phy *iphy = NULL; - enum sci_port_states state; - u32 phy_index; - - state = iport->sm.current_state_id; - if (state != SCI_PORT_SUB_OPERATIONAL) { - dev_warn(sciport_to_dev(iport), - "%s: in wrong state: %d\n", __func__, state); - return SCI_FAILURE_INVALID_STATE; - } - - /* Select a phy on which we can send the hard reset request. */ - for (phy_index = 0; phy_index < SCI_MAX_PHYS && !iphy; phy_index++) { - iphy = iport->phy_table[phy_index]; - if (iphy && !sci_port_active_phy(iport, iphy)) { - /* - * We found a phy but it is not ready select - * different phy - */ - iphy = NULL; - } - } - - /* If we have a phy then go ahead and start the reset procedure */ - if (!iphy) - return status; - status = sci_phy_reset(iphy); - - if (status != SCI_SUCCESS) - return status; - - sci_mod_timer(&iport->timer, timeout); - iport->not_ready_reason = SCIC_PORT_NOT_READY_HARD_RESET_REQUESTED; - - port_state_machine_change(iport, SCI_PORT_RESETTING); - return SCI_SUCCESS; -} - -/** - * sci_port_add_phy() - - * @sci_port: This parameter specifies the port in which the phy will be added. - * @sci_phy: This parameter is the phy which is to be added to the port. - * - * This method will add a PHY to the selected port. This method returns an - * enum sci_status. SCI_SUCCESS the phy has been added to the port. Any other - * status is a failure to add the phy to the port. - */ -enum sci_status sci_port_add_phy(struct isci_port *iport, - struct isci_phy *iphy) -{ - enum sci_status status; - enum sci_port_states state; - - state = iport->sm.current_state_id; - switch (state) { - case SCI_PORT_STOPPED: { - struct sci_sas_address port_sas_address; - - /* Read the port assigned SAS Address if there is one */ - sci_port_get_sas_address(iport, &port_sas_address); - - if (port_sas_address.high != 0 && port_sas_address.low != 0) { - struct sci_sas_address phy_sas_address; - - /* Make sure that the PHY SAS Address matches the SAS Address - * for this port - */ - sci_phy_get_sas_address(iphy, &phy_sas_address); - - if (port_sas_address.high != phy_sas_address.high || - port_sas_address.low != phy_sas_address.low) - return SCI_FAILURE_UNSUPPORTED_PORT_CONFIGURATION; - } - return sci_port_set_phy(iport, iphy); - } - case SCI_PORT_SUB_WAITING: - case SCI_PORT_SUB_OPERATIONAL: - status = sci_port_set_phy(iport, iphy); - - if (status != SCI_SUCCESS) - return status; - - sci_port_general_link_up_handler(iport, iphy, true); - iport->not_ready_reason = SCIC_PORT_NOT_READY_RECONFIGURING; - port_state_machine_change(iport, SCI_PORT_SUB_CONFIGURING); - - return status; - case SCI_PORT_SUB_CONFIGURING: - status = sci_port_set_phy(iport, iphy); - - if (status != SCI_SUCCESS) - return status; - sci_port_general_link_up_handler(iport, iphy, true); - - /* Re-enter the configuring state since this may be the last phy in - * the port. - */ - port_state_machine_change(iport, - SCI_PORT_SUB_CONFIGURING); - return SCI_SUCCESS; - default: - dev_warn(sciport_to_dev(iport), - "%s: in wrong state: %d\n", __func__, state); - return SCI_FAILURE_INVALID_STATE; - } -} - -/** - * sci_port_remove_phy() - - * @sci_port: This parameter specifies the port in which the phy will be added. - * @sci_phy: This parameter is the phy which is to be added to the port. - * - * This method will remove the PHY from the selected PORT. This method returns - * an enum sci_status. SCI_SUCCESS the phy has been removed from the port. Any - * other status is a failure to add the phy to the port. - */ -enum sci_status sci_port_remove_phy(struct isci_port *iport, - struct isci_phy *iphy) -{ - enum sci_status status; - enum sci_port_states state; - - state = iport->sm.current_state_id; - - switch (state) { - case SCI_PORT_STOPPED: - return sci_port_clear_phy(iport, iphy); - case SCI_PORT_SUB_OPERATIONAL: - status = sci_port_clear_phy(iport, iphy); - if (status != SCI_SUCCESS) - return status; - - sci_port_deactivate_phy(iport, iphy, true); - iport->not_ready_reason = SCIC_PORT_NOT_READY_RECONFIGURING; - port_state_machine_change(iport, - SCI_PORT_SUB_CONFIGURING); - return SCI_SUCCESS; - case SCI_PORT_SUB_CONFIGURING: - status = sci_port_clear_phy(iport, iphy); - - if (status != SCI_SUCCESS) - return status; - sci_port_deactivate_phy(iport, iphy, true); - - /* Re-enter the configuring state since this may be the last phy in - * the port - */ - port_state_machine_change(iport, - SCI_PORT_SUB_CONFIGURING); - return SCI_SUCCESS; - default: - dev_warn(sciport_to_dev(iport), - "%s: in wrong state: %d\n", __func__, state); - return SCI_FAILURE_INVALID_STATE; - } -} - -enum sci_status sci_port_link_up(struct isci_port *iport, - struct isci_phy *iphy) -{ - enum sci_port_states state; - - state = iport->sm.current_state_id; - switch (state) { - case SCI_PORT_SUB_WAITING: - /* Since this is the first phy going link up for the port we - * can just enable it and continue - */ - sci_port_activate_phy(iport, iphy, true); - - port_state_machine_change(iport, - SCI_PORT_SUB_OPERATIONAL); - return SCI_SUCCESS; - case SCI_PORT_SUB_OPERATIONAL: - sci_port_general_link_up_handler(iport, iphy, true); - return SCI_SUCCESS; - case SCI_PORT_RESETTING: - /* TODO We should make sure that the phy that has gone - * link up is the same one on which we sent the reset. It is - * possible that the phy on which we sent the reset is not the - * one that has gone link up and we want to make sure that - * phy being reset comes back. Consider the case where a - * reset is sent but before the hardware processes the reset it - * get a link up on the port because of a hot plug event. - * because of the reset request this phy will go link down - * almost immediately. - */ - - /* In the resetting state we don't notify the user regarding - * link up and link down notifications. - */ - sci_port_general_link_up_handler(iport, iphy, false); - return SCI_SUCCESS; - default: - dev_warn(sciport_to_dev(iport), - "%s: in wrong state: %d\n", __func__, state); - return SCI_FAILURE_INVALID_STATE; - } -} - -enum sci_status sci_port_link_down(struct isci_port *iport, - struct isci_phy *iphy) -{ - enum sci_port_states state; - - state = iport->sm.current_state_id; - switch (state) { - case SCI_PORT_SUB_OPERATIONAL: - sci_port_deactivate_phy(iport, iphy, true); - - /* If there are no active phys left in the port, then - * transition the port to the WAITING state until such time - * as a phy goes link up - */ - if (iport->active_phy_mask == 0) - port_state_machine_change(iport, - SCI_PORT_SUB_WAITING); - return SCI_SUCCESS; - case SCI_PORT_RESETTING: - /* In the resetting state we don't notify the user regarding - * link up and link down notifications. */ - sci_port_deactivate_phy(iport, iphy, false); - return SCI_SUCCESS; - default: - dev_warn(sciport_to_dev(iport), - "%s: in wrong state: %d\n", __func__, state); - return SCI_FAILURE_INVALID_STATE; - } -} - -enum sci_status sci_port_start_io(struct isci_port *iport, - struct isci_remote_device *idev, - struct isci_request *ireq) -{ - enum sci_port_states state; - - state = iport->sm.current_state_id; - switch (state) { - case SCI_PORT_SUB_WAITING: - return SCI_FAILURE_INVALID_STATE; - case SCI_PORT_SUB_OPERATIONAL: - iport->started_request_count++; - return SCI_SUCCESS; - default: - dev_warn(sciport_to_dev(iport), - "%s: in wrong state: %d\n", __func__, state); - return SCI_FAILURE_INVALID_STATE; - } -} - -enum sci_status sci_port_complete_io(struct isci_port *iport, - struct isci_remote_device *idev, - struct isci_request *ireq) -{ - enum sci_port_states state; - - state = iport->sm.current_state_id; - switch (state) { - case SCI_PORT_STOPPED: - dev_warn(sciport_to_dev(iport), - "%s: in wrong state: %d\n", __func__, state); - return SCI_FAILURE_INVALID_STATE; - case SCI_PORT_STOPPING: - sci_port_decrement_request_count(iport); - - if (iport->started_request_count == 0) - port_state_machine_change(iport, - SCI_PORT_STOPPED); - break; - case SCI_PORT_READY: - case SCI_PORT_RESETTING: - case SCI_PORT_FAILED: - case SCI_PORT_SUB_WAITING: - case SCI_PORT_SUB_OPERATIONAL: - sci_port_decrement_request_count(iport); - break; - case SCI_PORT_SUB_CONFIGURING: - sci_port_decrement_request_count(iport); - if (iport->started_request_count == 0) { - port_state_machine_change(iport, - SCI_PORT_SUB_OPERATIONAL); - } - break; - } - return SCI_SUCCESS; -} - -static void sci_port_enable_port_task_scheduler(struct isci_port *iport) -{ - u32 pts_control_value; - - /* enable the port task scheduler in a suspended state */ - pts_control_value = readl(&iport->port_task_scheduler_registers->control); - pts_control_value |= SCU_PTSxCR_GEN_BIT(ENABLE) | SCU_PTSxCR_GEN_BIT(SUSPEND); - writel(pts_control_value, &iport->port_task_scheduler_registers->control); -} - -static void sci_port_disable_port_task_scheduler(struct isci_port *iport) -{ - u32 pts_control_value; - - pts_control_value = readl(&iport->port_task_scheduler_registers->control); - pts_control_value &= - ~(SCU_PTSxCR_GEN_BIT(ENABLE) | SCU_PTSxCR_GEN_BIT(SUSPEND)); - writel(pts_control_value, &iport->port_task_scheduler_registers->control); -} - -static void sci_port_post_dummy_remote_node(struct isci_port *iport) -{ - struct isci_host *ihost = iport->owning_controller; - u8 phys_index = iport->physical_port_index; - union scu_remote_node_context *rnc; - u16 rni = iport->reserved_rni; - u32 command; - - rnc = &ihost->remote_node_context_table[rni]; - rnc->ssp.is_valid = true; - - command = SCU_CONTEXT_COMMAND_POST_RNC_32 | - phys_index << SCU_CONTEXT_COMMAND_LOGICAL_PORT_SHIFT | rni; - - sci_controller_post_request(ihost, command); - - /* ensure hardware has seen the post rnc command and give it - * ample time to act before sending the suspend - */ - readl(&ihost->smu_registers->interrupt_status); /* flush */ - udelay(10); - - command = SCU_CONTEXT_COMMAND_POST_RNC_SUSPEND_TX_RX | - phys_index << SCU_CONTEXT_COMMAND_LOGICAL_PORT_SHIFT | rni; - - sci_controller_post_request(ihost, command); -} - -static void sci_port_stopped_state_enter(struct sci_base_state_machine *sm) -{ - struct isci_port *iport = container_of(sm, typeof(*iport), sm); - - if (iport->sm.previous_state_id == SCI_PORT_STOPPING) { - /* - * If we enter this state becasuse of a request to stop - * the port then we want to disable the hardwares port - * task scheduler. */ - sci_port_disable_port_task_scheduler(iport); - } -} - -static void sci_port_stopped_state_exit(struct sci_base_state_machine *sm) -{ - struct isci_port *iport = container_of(sm, typeof(*iport), sm); - - /* Enable and suspend the port task scheduler */ - sci_port_enable_port_task_scheduler(iport); -} - -static void sci_port_ready_state_enter(struct sci_base_state_machine *sm) -{ - struct isci_port *iport = container_of(sm, typeof(*iport), sm); - struct isci_host *ihost = iport->owning_controller; - u32 prev_state; - - prev_state = iport->sm.previous_state_id; - if (prev_state == SCI_PORT_RESETTING) - isci_port_hard_reset_complete(iport, SCI_SUCCESS); - else - isci_port_not_ready(ihost, iport); - - /* Post and suspend the dummy remote node context for this port. */ - sci_port_post_dummy_remote_node(iport); - - /* Start the ready substate machine */ - port_state_machine_change(iport, - SCI_PORT_SUB_WAITING); -} - -static void sci_port_resetting_state_exit(struct sci_base_state_machine *sm) -{ - struct isci_port *iport = container_of(sm, typeof(*iport), sm); - - sci_del_timer(&iport->timer); -} - -static void sci_port_stopping_state_exit(struct sci_base_state_machine *sm) -{ - struct isci_port *iport = container_of(sm, typeof(*iport), sm); - - sci_del_timer(&iport->timer); - - sci_port_destroy_dummy_resources(iport); -} - -static void sci_port_failed_state_enter(struct sci_base_state_machine *sm) -{ - struct isci_port *iport = container_of(sm, typeof(*iport), sm); - - isci_port_hard_reset_complete(iport, SCI_FAILURE_TIMEOUT); -} - -/* --------------------------------------------------------------------------- */ - -static const struct sci_base_state sci_port_state_table[] = { - [SCI_PORT_STOPPED] = { - .enter_state = sci_port_stopped_state_enter, - .exit_state = sci_port_stopped_state_exit - }, - [SCI_PORT_STOPPING] = { - .exit_state = sci_port_stopping_state_exit - }, - [SCI_PORT_READY] = { - .enter_state = sci_port_ready_state_enter, - }, - [SCI_PORT_SUB_WAITING] = { - .enter_state = sci_port_ready_substate_waiting_enter, - }, - [SCI_PORT_SUB_OPERATIONAL] = { - .enter_state = sci_port_ready_substate_operational_enter, - .exit_state = sci_port_ready_substate_operational_exit - }, - [SCI_PORT_SUB_CONFIGURING] = { - .enter_state = sci_port_ready_substate_configuring_enter, - .exit_state = sci_port_ready_substate_configuring_exit - }, - [SCI_PORT_RESETTING] = { - .exit_state = sci_port_resetting_state_exit - }, - [SCI_PORT_FAILED] = { - .enter_state = sci_port_failed_state_enter, - } -}; - -void sci_port_construct(struct isci_port *iport, u8 index, - struct isci_host *ihost) -{ - sci_init_sm(&iport->sm, sci_port_state_table, SCI_PORT_STOPPED); - - iport->logical_port_index = SCIC_SDS_DUMMY_PORT; - iport->physical_port_index = index; - iport->active_phy_mask = 0; - iport->ready_exit = false; - - iport->owning_controller = ihost; - - iport->started_request_count = 0; - iport->assigned_device_count = 0; - - iport->reserved_rni = SCU_DUMMY_INDEX; - iport->reserved_tag = SCI_CONTROLLER_INVALID_IO_TAG; - - sci_init_timer(&iport->timer, port_timeout); - - iport->port_task_scheduler_registers = NULL; - - for (index = 0; index < SCI_MAX_PHYS; index++) - iport->phy_table[index] = NULL; -} - -void isci_port_init(struct isci_port *iport, struct isci_host *ihost, int index) -{ - INIT_LIST_HEAD(&iport->remote_dev_list); - INIT_LIST_HEAD(&iport->domain_dev_list); - spin_lock_init(&iport->state_lock); - init_completion(&iport->start_complete); - iport->isci_host = ihost; - isci_port_change_state(iport, isci_freed); - atomic_set(&iport->event, 0); -} - -/** - * isci_port_get_state() - This function gets the status of the port object. - * @isci_port: This parameter points to the isci_port object - * - * status of the object as a isci_status enum. - */ -enum isci_status isci_port_get_state( - struct isci_port *isci_port) -{ - return isci_port->status; -} - -void sci_port_broadcast_change_received(struct isci_port *iport, struct isci_phy *iphy) -{ - struct isci_host *ihost = iport->owning_controller; - - /* notify the user. */ - isci_port_bc_change_received(ihost, iport, iphy); -} - -int isci_port_perform_hard_reset(struct isci_host *ihost, struct isci_port *iport, - struct isci_phy *iphy) -{ - unsigned long flags; - enum sci_status status; - int idx, ret = TMF_RESP_FUNC_COMPLETE; - - dev_dbg(&ihost->pdev->dev, "%s: iport = %p\n", - __func__, iport); - - init_completion(&iport->hard_reset_complete); - - spin_lock_irqsave(&ihost->scic_lock, flags); - - #define ISCI_PORT_RESET_TIMEOUT SCIC_SDS_SIGNATURE_FIS_TIMEOUT - status = sci_port_hard_reset(iport, ISCI_PORT_RESET_TIMEOUT); - - spin_unlock_irqrestore(&ihost->scic_lock, flags); - - if (status == SCI_SUCCESS) { - wait_for_completion(&iport->hard_reset_complete); - - dev_dbg(&ihost->pdev->dev, - "%s: iport = %p; hard reset completion\n", - __func__, iport); - - if (iport->hard_reset_status != SCI_SUCCESS) - ret = TMF_RESP_FUNC_FAILED; - } else { - ret = TMF_RESP_FUNC_FAILED; - - dev_err(&ihost->pdev->dev, - "%s: iport = %p; sci_port_hard_reset call" - " failed 0x%x\n", - __func__, iport, status); - - } - - /* If the hard reset for the port has failed, consider this - * the same as link failures on all phys in the port. - */ - if (ret != TMF_RESP_FUNC_COMPLETE) { - - dev_err(&ihost->pdev->dev, - "%s: iport = %p; hard reset failed " - "(0x%x) - driving explicit link fail for all phys\n", - __func__, iport, iport->hard_reset_status); - - /* Down all phys in the port. */ - spin_lock_irqsave(&ihost->scic_lock, flags); - for (idx = 0; idx < SCI_MAX_PHYS; ++idx) { - struct isci_phy *iphy = iport->phy_table[idx]; - - if (!iphy) - continue; - sci_phy_stop(iphy); - sci_phy_start(iphy); - } - spin_unlock_irqrestore(&ihost->scic_lock, flags); - } - return ret; -} - -/** - * isci_port_deformed() - This function is called by libsas when a port becomes - * inactive. - * @phy: This parameter specifies the libsas phy with the inactive port. - * - */ -void isci_port_deformed(struct asd_sas_phy *phy) -{ - pr_debug("%s: sas_phy = %p\n", __func__, phy); -} - -/** - * isci_port_formed() - This function is called by libsas when a port becomes - * active. - * @phy: This parameter specifies the libsas phy with the active port. - * - */ -void isci_port_formed(struct asd_sas_phy *phy) -{ - pr_debug("%s: sas_phy = %p, sas_port = %p\n", __func__, phy, phy->port); -} diff --git a/trunk/drivers/scsi/isci/port.h b/trunk/drivers/scsi/isci/port.h deleted file mode 100644 index b50ecd4e8f9c..000000000000 --- a/trunk/drivers/scsi/isci/port.h +++ /dev/null @@ -1,306 +0,0 @@ -/* - * This file is provided under a dual BSD/GPLv2 license. When using or - * redistributing this file, you may do so under either license. - * - * GPL LICENSE SUMMARY - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License 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., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. - * The full GNU General Public License is included in this distribution - * in the file called LICENSE.GPL. - * - * BSD LICENSE - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Intel Corporation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _ISCI_PORT_H_ -#define _ISCI_PORT_H_ - -#include -#include "isci.h" -#include "sas.h" -#include "phy.h" - -#define SCIC_SDS_DUMMY_PORT 0xFF - -struct isci_phy; -struct isci_host; - -enum isci_status { - isci_freed = 0x00, - isci_starting = 0x01, - isci_ready = 0x02, - isci_ready_for_io = 0x03, - isci_stopping = 0x04, - isci_stopped = 0x05, -}; - -/** - * struct isci_port - isci direct attached sas port object - * @event: counts bcns and port stop events (for bcn filtering) - * @ready_exit: several states constitute 'ready'. When exiting ready we - * need to take extra port-teardown actions that are - * skipped when exiting to another 'ready' state. - * @logical_port_index: software port index - * @physical_port_index: hardware port index - * @active_phy_mask: identifies phy members - * @reserved_tag: - * @reserved_rni: reserver for port task scheduler workaround - * @started_request_count: reference count for outstanding commands - * @not_ready_reason: set during state transitions and notified - * @timer: timeout start/stop operations - */ -struct isci_port { - enum isci_status status; - #define IPORT_BCN_BLOCKED 0 - #define IPORT_BCN_PENDING 1 - unsigned long flags; - atomic_t event; - struct isci_host *isci_host; - struct asd_sas_port sas_port; - struct list_head remote_dev_list; - spinlock_t state_lock; - struct list_head domain_dev_list; - struct completion start_complete; - struct completion hard_reset_complete; - enum sci_status hard_reset_status; - struct sci_base_state_machine sm; - bool ready_exit; - u8 logical_port_index; - u8 physical_port_index; - u8 active_phy_mask; - u16 reserved_rni; - u16 reserved_tag; - u32 started_request_count; - u32 assigned_device_count; - u32 not_ready_reason; - struct isci_phy *phy_table[SCI_MAX_PHYS]; - struct isci_host *owning_controller; - struct sci_timer timer; - struct scu_port_task_scheduler_registers __iomem *port_task_scheduler_registers; - /* XXX rework: only one register, no need to replicate per-port */ - u32 __iomem *port_pe_configuration_register; - struct scu_viit_entry __iomem *viit_registers; -}; - -enum sci_port_not_ready_reason_code { - SCIC_PORT_NOT_READY_NO_ACTIVE_PHYS, - SCIC_PORT_NOT_READY_HARD_RESET_REQUESTED, - SCIC_PORT_NOT_READY_INVALID_PORT_CONFIGURATION, - SCIC_PORT_NOT_READY_RECONFIGURING, - - SCIC_PORT_NOT_READY_REASON_CODE_MAX -}; - -struct sci_port_end_point_properties { - struct sci_sas_address sas_address; - struct sci_phy_proto protocols; -}; - -struct sci_port_properties { - u32 index; - struct sci_port_end_point_properties local; - struct sci_port_end_point_properties remote; - u32 phy_mask; -}; - -/** - * enum sci_port_states - This enumeration depicts all the states for the - * common port state machine. - * - * - */ -enum sci_port_states { - /** - * This state indicates that the port has successfully been stopped. - * In this state no new IO operations are permitted. - * This state is entered from the STOPPING state. - */ - SCI_PORT_STOPPED, - - /** - * This state indicates that the port is in the process of stopping. - * In this state no new IO operations are permitted, but existing IO - * operations are allowed to complete. - * This state is entered from the READY state. - */ - SCI_PORT_STOPPING, - - /** - * This state indicates the port is now ready. Thus, the user is - * able to perform IO operations on this port. - * This state is entered from the STARTING state. - */ - SCI_PORT_READY, - - /** - * The substate where the port is started and ready but has no - * active phys. - */ - SCI_PORT_SUB_WAITING, - - /** - * The substate where the port is started and ready and there is - * at least one phy operational. - */ - SCI_PORT_SUB_OPERATIONAL, - - /** - * The substate where the port is started and there was an - * add/remove phy event. This state is only used in Automatic - * Port Configuration Mode (APC) - */ - SCI_PORT_SUB_CONFIGURING, - - /** - * This state indicates the port is in the process of performing a hard - * reset. Thus, the user is unable to perform IO operations on this - * port. - * This state is entered from the READY state. - */ - SCI_PORT_RESETTING, - - /** - * This state indicates the port has failed a reset request. This state - * is entered when a port reset request times out. - * This state is entered from the RESETTING state. - */ - SCI_PORT_FAILED, - - -}; - -static inline void sci_port_decrement_request_count(struct isci_port *iport) -{ - if (WARN_ONCE(iport->started_request_count == 0, - "%s: tried to decrement started_request_count past 0!?", - __func__)) - /* pass */; - else - iport->started_request_count--; -} - -#define sci_port_active_phy(port, phy) \ - (((port)->active_phy_mask & (1 << (phy)->phy_index)) != 0) - -void sci_port_construct( - struct isci_port *iport, - u8 port_index, - struct isci_host *ihost); - -enum sci_status sci_port_start(struct isci_port *iport); -enum sci_status sci_port_stop(struct isci_port *iport); - -enum sci_status sci_port_add_phy( - struct isci_port *iport, - struct isci_phy *iphy); - -enum sci_status sci_port_remove_phy( - struct isci_port *iport, - struct isci_phy *iphy); - -void sci_port_setup_transports( - struct isci_port *iport, - u32 device_id); - -void isci_port_bcn_enable(struct isci_host *, struct isci_port *); - -void sci_port_deactivate_phy( - struct isci_port *iport, - struct isci_phy *iphy, - bool do_notify_user); - -bool sci_port_link_detected( - struct isci_port *iport, - struct isci_phy *iphy); - -enum sci_status sci_port_link_up(struct isci_port *iport, - struct isci_phy *iphy); -enum sci_status sci_port_link_down(struct isci_port *iport, - struct isci_phy *iphy); - -struct isci_request; -struct isci_remote_device; -enum sci_status sci_port_start_io( - struct isci_port *iport, - struct isci_remote_device *idev, - struct isci_request *ireq); - -enum sci_status sci_port_complete_io( - struct isci_port *iport, - struct isci_remote_device *idev, - struct isci_request *ireq); - -enum sas_linkrate sci_port_get_max_allowed_speed( - struct isci_port *iport); - -void sci_port_broadcast_change_received( - struct isci_port *iport, - struct isci_phy *iphy); - -bool sci_port_is_valid_phy_assignment( - struct isci_port *iport, - u32 phy_index); - -void sci_port_get_sas_address( - struct isci_port *iport, - struct sci_sas_address *sas_address); - -void sci_port_get_attached_sas_address( - struct isci_port *iport, - struct sci_sas_address *sas_address); - -enum isci_status isci_port_get_state( - struct isci_port *isci_port); - -void isci_port_formed(struct asd_sas_phy *); -void isci_port_deformed(struct asd_sas_phy *); - -void isci_port_init( - struct isci_port *port, - struct isci_host *host, - int index); - -int isci_port_perform_hard_reset(struct isci_host *ihost, struct isci_port *iport, - struct isci_phy *iphy); -#endif /* !defined(_ISCI_PORT_H_) */ diff --git a/trunk/drivers/scsi/isci/port_config.c b/trunk/drivers/scsi/isci/port_config.c deleted file mode 100644 index 486b113c634a..000000000000 --- a/trunk/drivers/scsi/isci/port_config.c +++ /dev/null @@ -1,754 +0,0 @@ -/* - * This file is provided under a dual BSD/GPLv2 license. When using or - * redistributing this file, you may do so under either license. - * - * GPL LICENSE SUMMARY - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License 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., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. - * The full GNU General Public License is included in this distribution - * in the file called LICENSE.GPL. - * - * BSD LICENSE - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Intel Corporation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "host.h" - -#define SCIC_SDS_MPC_RECONFIGURATION_TIMEOUT (10) -#define SCIC_SDS_APC_RECONFIGURATION_TIMEOUT (10) -#define SCIC_SDS_APC_WAIT_LINK_UP_NOTIFICATION (100) - -enum SCIC_SDS_APC_ACTIVITY { - SCIC_SDS_APC_SKIP_PHY, - SCIC_SDS_APC_ADD_PHY, - SCIC_SDS_APC_START_TIMER, - - SCIC_SDS_APC_ACTIVITY_MAX -}; - -/* - * ****************************************************************************** - * General port configuration agent routines - * ****************************************************************************** */ - -/** - * - * @address_one: A SAS Address to be compared. - * @address_two: A SAS Address to be compared. - * - * Compare the two SAS Address and if SAS Address One is greater than SAS - * Address Two then return > 0 else if SAS Address One is less than SAS Address - * Two return < 0 Otherwise they are the same return 0 A signed value of x > 0 - * > y where x is returned for Address One > Address Two y is returned for - * Address One < Address Two 0 is returned ofr Address One = Address Two - */ -static s32 sci_sas_address_compare( - struct sci_sas_address address_one, - struct sci_sas_address address_two) -{ - if (address_one.high > address_two.high) { - return 1; - } else if (address_one.high < address_two.high) { - return -1; - } else if (address_one.low > address_two.low) { - return 1; - } else if (address_one.low < address_two.low) { - return -1; - } - - /* The two SAS Address must be identical */ - return 0; -} - -/** - * - * @controller: The controller object used for the port search. - * @phy: The phy object to match. - * - * This routine will find a matching port for the phy. This means that the - * port and phy both have the same broadcast sas address and same received sas - * address. The port address or the NULL if there is no matching - * port. port address if the port can be found to match the phy. - * NULL if there is no matching port for the phy. - */ -static struct isci_port *sci_port_configuration_agent_find_port( - struct isci_host *ihost, - struct isci_phy *iphy) -{ - u8 i; - struct sci_sas_address port_sas_address; - struct sci_sas_address port_attached_device_address; - struct sci_sas_address phy_sas_address; - struct sci_sas_address phy_attached_device_address; - - /* - * Since this phy can be a member of a wide port check to see if one or - * more phys match the sent and received SAS address as this phy in which - * case it should participate in the same port. - */ - sci_phy_get_sas_address(iphy, &phy_sas_address); - sci_phy_get_attached_sas_address(iphy, &phy_attached_device_address); - - for (i = 0; i < ihost->logical_port_entries; i++) { - struct isci_port *iport = &ihost->ports[i]; - - sci_port_get_sas_address(iport, &port_sas_address); - sci_port_get_attached_sas_address(iport, &port_attached_device_address); - - if (sci_sas_address_compare(port_sas_address, phy_sas_address) == 0 && - sci_sas_address_compare(port_attached_device_address, phy_attached_device_address) == 0) - return iport; - } - - return NULL; -} - -/** - * - * @controller: This is the controller object that contains the port agent - * @port_agent: This is the port configruation agent for the controller. - * - * This routine will validate the port configuration is correct for the SCU - * hardware. The SCU hardware allows for port configurations as follows. LP0 - * -> (PE0), (PE0, PE1), (PE0, PE1, PE2, PE3) LP1 -> (PE1) LP2 -> (PE2), (PE2, - * PE3) LP3 -> (PE3) enum sci_status SCI_SUCCESS the port configuration is valid for - * this port configuration agent. SCI_FAILURE_UNSUPPORTED_PORT_CONFIGURATION - * the port configuration is not valid for this port configuration agent. - */ -static enum sci_status sci_port_configuration_agent_validate_ports( - struct isci_host *ihost, - struct sci_port_configuration_agent *port_agent) -{ - struct sci_sas_address first_address; - struct sci_sas_address second_address; - - /* - * Sanity check the max ranges for all the phys the max index - * is always equal to the port range index */ - if (port_agent->phy_valid_port_range[0].max_index != 0 || - port_agent->phy_valid_port_range[1].max_index != 1 || - port_agent->phy_valid_port_range[2].max_index != 2 || - port_agent->phy_valid_port_range[3].max_index != 3) - return SCI_FAILURE_UNSUPPORTED_PORT_CONFIGURATION; - - /* - * This is a request to configure a single x4 port or at least attempt - * to make all the phys into a single port */ - if (port_agent->phy_valid_port_range[0].min_index == 0 && - port_agent->phy_valid_port_range[1].min_index == 0 && - port_agent->phy_valid_port_range[2].min_index == 0 && - port_agent->phy_valid_port_range[3].min_index == 0) - return SCI_SUCCESS; - - /* - * This is a degenerate case where phy 1 and phy 2 are assigned - * to the same port this is explicitly disallowed by the hardware - * unless they are part of the same x4 port and this condition was - * already checked above. */ - if (port_agent->phy_valid_port_range[2].min_index == 1) { - return SCI_FAILURE_UNSUPPORTED_PORT_CONFIGURATION; - } - - /* - * PE0 and PE3 can never have the same SAS Address unless they - * are part of the same x4 wide port and we have already checked - * for this condition. */ - sci_phy_get_sas_address(&ihost->phys[0], &first_address); - sci_phy_get_sas_address(&ihost->phys[3], &second_address); - - if (sci_sas_address_compare(first_address, second_address) == 0) { - return SCI_FAILURE_UNSUPPORTED_PORT_CONFIGURATION; - } - - /* - * PE0 and PE1 are configured into a 2x1 ports make sure that the - * SAS Address for PE0 and PE2 are different since they can not be - * part of the same port. */ - if (port_agent->phy_valid_port_range[0].min_index == 0 && - port_agent->phy_valid_port_range[1].min_index == 1) { - sci_phy_get_sas_address(&ihost->phys[0], &first_address); - sci_phy_get_sas_address(&ihost->phys[2], &second_address); - - if (sci_sas_address_compare(first_address, second_address) == 0) { - return SCI_FAILURE_UNSUPPORTED_PORT_CONFIGURATION; - } - } - - /* - * PE2 and PE3 are configured into a 2x1 ports make sure that the - * SAS Address for PE1 and PE3 are different since they can not be - * part of the same port. */ - if (port_agent->phy_valid_port_range[2].min_index == 2 && - port_agent->phy_valid_port_range[3].min_index == 3) { - sci_phy_get_sas_address(&ihost->phys[1], &first_address); - sci_phy_get_sas_address(&ihost->phys[3], &second_address); - - if (sci_sas_address_compare(first_address, second_address) == 0) { - return SCI_FAILURE_UNSUPPORTED_PORT_CONFIGURATION; - } - } - - return SCI_SUCCESS; -} - -/* - * ****************************************************************************** - * Manual port configuration agent routines - * ****************************************************************************** */ - -/* verify all of the phys in the same port are using the same SAS address */ -static enum sci_status -sci_mpc_agent_validate_phy_configuration(struct isci_host *ihost, - struct sci_port_configuration_agent *port_agent) -{ - u32 phy_mask; - u32 assigned_phy_mask; - struct sci_sas_address sas_address; - struct sci_sas_address phy_assigned_address; - u8 port_index; - u8 phy_index; - - assigned_phy_mask = 0; - sas_address.high = 0; - sas_address.low = 0; - - for (port_index = 0; port_index < SCI_MAX_PORTS; port_index++) { - phy_mask = ihost->oem_parameters.ports[port_index].phy_mask; - - if (!phy_mask) - continue; - /* - * Make sure that one or more of the phys were not already assinged to - * a different port. */ - if ((phy_mask & ~assigned_phy_mask) == 0) { - return SCI_FAILURE_UNSUPPORTED_PORT_CONFIGURATION; - } - - /* Find the starting phy index for this round through the loop */ - for (phy_index = 0; phy_index < SCI_MAX_PHYS; phy_index++) { - if ((phy_mask & (1 << phy_index)) == 0) - continue; - sci_phy_get_sas_address(&ihost->phys[phy_index], - &sas_address); - - /* - * The phy_index can be used as the starting point for the - * port range since the hardware starts all logical ports - * the same as the PE index. */ - port_agent->phy_valid_port_range[phy_index].min_index = port_index; - port_agent->phy_valid_port_range[phy_index].max_index = phy_index; - - if (phy_index != port_index) { - return SCI_FAILURE_UNSUPPORTED_PORT_CONFIGURATION; - } - - break; - } - - /* - * See how many additional phys are being added to this logical port. - * Note: We have not moved the current phy_index so we will actually - * compare the startting phy with itself. - * This is expected and required to add the phy to the port. */ - while (phy_index < SCI_MAX_PHYS) { - if ((phy_mask & (1 << phy_index)) == 0) - continue; - sci_phy_get_sas_address(&ihost->phys[phy_index], - &phy_assigned_address); - - if (sci_sas_address_compare(sas_address, phy_assigned_address) != 0) { - /* - * The phy mask specified that this phy is part of the same port - * as the starting phy and it is not so fail this configuration */ - return SCI_FAILURE_UNSUPPORTED_PORT_CONFIGURATION; - } - - port_agent->phy_valid_port_range[phy_index].min_index = port_index; - port_agent->phy_valid_port_range[phy_index].max_index = phy_index; - - sci_port_add_phy(&ihost->ports[port_index], - &ihost->phys[phy_index]); - - assigned_phy_mask |= (1 << phy_index); - } - - phy_index++; - } - - return sci_port_configuration_agent_validate_ports(ihost, port_agent); -} - -static void mpc_agent_timeout(unsigned long data) -{ - u8 index; - struct sci_timer *tmr = (struct sci_timer *)data; - struct sci_port_configuration_agent *port_agent; - struct isci_host *ihost; - unsigned long flags; - u16 configure_phy_mask; - - port_agent = container_of(tmr, typeof(*port_agent), timer); - ihost = container_of(port_agent, typeof(*ihost), port_agent); - - spin_lock_irqsave(&ihost->scic_lock, flags); - - if (tmr->cancel) - goto done; - - port_agent->timer_pending = false; - - /* Find the mask of phys that are reported read but as yet unconfigured into a port */ - configure_phy_mask = ~port_agent->phy_configured_mask & port_agent->phy_ready_mask; - - for (index = 0; index < SCI_MAX_PHYS; index++) { - struct isci_phy *iphy = &ihost->phys[index]; - - if (configure_phy_mask & (1 << index)) { - port_agent->link_up_handler(ihost, port_agent, - phy_get_non_dummy_port(iphy), - iphy); - } - } - -done: - spin_unlock_irqrestore(&ihost->scic_lock, flags); -} - -static void sci_mpc_agent_link_up(struct isci_host *ihost, - struct sci_port_configuration_agent *port_agent, - struct isci_port *iport, - struct isci_phy *iphy) -{ - /* If the port is NULL then the phy was not assigned to a port. - * This is because the phy was not given the same SAS Address as - * the other PHYs in the port. - */ - if (!iport) - return; - - port_agent->phy_ready_mask |= (1 << iphy->phy_index); - sci_port_link_up(iport, iphy); - if ((iport->active_phy_mask & (1 << iphy->phy_index))) - port_agent->phy_configured_mask |= (1 << iphy->phy_index); -} - -/** - * - * @controller: This is the controller object that receives the link down - * notification. - * @port: This is the port object associated with the phy. If the is no - * associated port this is an NULL. The port is an invalid - * handle only if the phy was never port of this port. This happens when - * the phy is not broadcasting the same SAS address as the other phys in the - * assigned port. - * @phy: This is the phy object which has gone link down. - * - * This function handles the manual port configuration link down notifications. - * Since all ports and phys are associated at initialization time we just turn - * around and notifiy the port object of the link down event. If this PHY is - * not associated with a port there is no action taken. Is it possible to get a - * link down notification from a phy that has no assocoated port? - */ -static void sci_mpc_agent_link_down( - struct isci_host *ihost, - struct sci_port_configuration_agent *port_agent, - struct isci_port *iport, - struct isci_phy *iphy) -{ - if (iport != NULL) { - /* - * If we can form a new port from the remainder of the phys - * then we want to start the timer to allow the SCI User to - * cleanup old devices and rediscover the port before - * rebuilding the port with the phys that remain in the ready - * state. - */ - port_agent->phy_ready_mask &= ~(1 << iphy->phy_index); - port_agent->phy_configured_mask &= ~(1 << iphy->phy_index); - - /* - * Check to see if there are more phys waiting to be - * configured into a port. If there are allow the SCI User - * to tear down this port, if necessary, and then reconstruct - * the port after the timeout. - */ - if ((port_agent->phy_configured_mask == 0x0000) && - (port_agent->phy_ready_mask != 0x0000) && - !port_agent->timer_pending) { - port_agent->timer_pending = true; - - sci_mod_timer(&port_agent->timer, - SCIC_SDS_MPC_RECONFIGURATION_TIMEOUT); - } - - sci_port_link_down(iport, iphy); - } -} - -/* verify phys are assigned a valid SAS address for automatic port - * configuration mode. - */ -static enum sci_status -sci_apc_agent_validate_phy_configuration(struct isci_host *ihost, - struct sci_port_configuration_agent *port_agent) -{ - u8 phy_index; - u8 port_index; - struct sci_sas_address sas_address; - struct sci_sas_address phy_assigned_address; - - phy_index = 0; - - while (phy_index < SCI_MAX_PHYS) { - port_index = phy_index; - - /* Get the assigned SAS Address for the first PHY on the controller. */ - sci_phy_get_sas_address(&ihost->phys[phy_index], - &sas_address); - - while (++phy_index < SCI_MAX_PHYS) { - sci_phy_get_sas_address(&ihost->phys[phy_index], - &phy_assigned_address); - - /* Verify each of the SAS address are all the same for every PHY */ - if (sci_sas_address_compare(sas_address, phy_assigned_address) == 0) { - port_agent->phy_valid_port_range[phy_index].min_index = port_index; - port_agent->phy_valid_port_range[phy_index].max_index = phy_index; - } else { - port_agent->phy_valid_port_range[phy_index].min_index = phy_index; - port_agent->phy_valid_port_range[phy_index].max_index = phy_index; - break; - } - } - } - - return sci_port_configuration_agent_validate_ports(ihost, port_agent); -} - -static void sci_apc_agent_configure_ports(struct isci_host *ihost, - struct sci_port_configuration_agent *port_agent, - struct isci_phy *iphy, - bool start_timer) -{ - u8 port_index; - enum sci_status status; - struct isci_port *iport; - enum SCIC_SDS_APC_ACTIVITY apc_activity = SCIC_SDS_APC_SKIP_PHY; - - iport = sci_port_configuration_agent_find_port(ihost, iphy); - - if (iport) { - if (sci_port_is_valid_phy_assignment(iport, iphy->phy_index)) - apc_activity = SCIC_SDS_APC_ADD_PHY; - else - apc_activity = SCIC_SDS_APC_SKIP_PHY; - } else { - /* - * There is no matching Port for this PHY so lets search through the - * Ports and see if we can add the PHY to its own port or maybe start - * the timer and wait to see if a wider port can be made. - * - * Note the break when we reach the condition of the port id == phy id */ - for (port_index = port_agent->phy_valid_port_range[iphy->phy_index].min_index; - port_index <= port_agent->phy_valid_port_range[iphy->phy_index].max_index; - port_index++) { - - iport = &ihost->ports[port_index]; - - /* First we must make sure that this PHY can be added to this Port. */ - if (sci_port_is_valid_phy_assignment(iport, iphy->phy_index)) { - /* - * Port contains a PHY with a greater PHY ID than the current - * PHY that has gone link up. This phy can not be part of any - * port so skip it and move on. */ - if (iport->active_phy_mask > (1 << iphy->phy_index)) { - apc_activity = SCIC_SDS_APC_SKIP_PHY; - break; - } - - /* - * We have reached the end of our Port list and have not found - * any reason why we should not either add the PHY to the port - * or wait for more phys to become active. */ - if (iport->physical_port_index == iphy->phy_index) { - /* - * The Port either has no active PHYs. - * Consider that if the port had any active PHYs we would have - * or active PHYs with - * a lower PHY Id than this PHY. */ - if (apc_activity != SCIC_SDS_APC_START_TIMER) { - apc_activity = SCIC_SDS_APC_ADD_PHY; - } - - break; - } - - /* - * The current Port has no active PHYs and this PHY could be part - * of this Port. Since we dont know as yet setup to start the - * timer and see if there is a better configuration. */ - if (iport->active_phy_mask == 0) { - apc_activity = SCIC_SDS_APC_START_TIMER; - } - } else if (iport->active_phy_mask != 0) { - /* - * The Port has an active phy and the current Phy can not - * participate in this port so skip the PHY and see if - * there is a better configuration. */ - apc_activity = SCIC_SDS_APC_SKIP_PHY; - } - } - } - - /* - * Check to see if the start timer operations should instead map to an - * add phy operation. This is caused because we have been waiting to - * add a phy to a port but could not becuase the automatic port - * configuration engine had a choice of possible ports for the phy. - * Since we have gone through a timeout we are going to restrict the - * choice to the smallest possible port. */ - if ( - (start_timer == false) - && (apc_activity == SCIC_SDS_APC_START_TIMER) - ) { - apc_activity = SCIC_SDS_APC_ADD_PHY; - } - - switch (apc_activity) { - case SCIC_SDS_APC_ADD_PHY: - status = sci_port_add_phy(iport, iphy); - - if (status == SCI_SUCCESS) { - port_agent->phy_configured_mask |= (1 << iphy->phy_index); - } - break; - - case SCIC_SDS_APC_START_TIMER: - /* - * This can occur for either a link down event, or a link - * up event where we cannot yet tell the port to which a - * phy belongs. - */ - if (port_agent->timer_pending) - sci_del_timer(&port_agent->timer); - - port_agent->timer_pending = true; - sci_mod_timer(&port_agent->timer, - SCIC_SDS_APC_WAIT_LINK_UP_NOTIFICATION); - break; - - case SCIC_SDS_APC_SKIP_PHY: - default: - /* do nothing the PHY can not be made part of a port at this time. */ - break; - } -} - -/** - * sci_apc_agent_link_up - handle apc link up events - * @scic: This is the controller object that receives the link up - * notification. - * @sci_port: This is the port object associated with the phy. If the is no - * associated port this is an NULL. - * @sci_phy: This is the phy object which has gone link up. - * - * This method handles the automatic port configuration for link up - * notifications. Is it possible to get a link down notification from a phy - * that has no assocoated port? - */ -static void sci_apc_agent_link_up(struct isci_host *ihost, - struct sci_port_configuration_agent *port_agent, - struct isci_port *iport, - struct isci_phy *iphy) -{ - u8 phy_index = iphy->phy_index; - - if (!iport) { - /* the phy is not the part of this port */ - port_agent->phy_ready_mask |= 1 << phy_index; - sci_apc_agent_configure_ports(ihost, port_agent, iphy, true); - } else { - /* the phy is already the part of the port */ - u32 port_state = iport->sm.current_state_id; - - /* if the PORT'S state is resetting then the link up is from - * port hard reset in this case, we need to tell the port - * that link up is recieved - */ - BUG_ON(port_state != SCI_PORT_RESETTING); - port_agent->phy_ready_mask |= 1 << phy_index; - sci_port_link_up(iport, iphy); - } -} - -/** - * - * @controller: This is the controller object that receives the link down - * notification. - * @iport: This is the port object associated with the phy. If the is no - * associated port this is an NULL. - * @iphy: This is the phy object which has gone link down. - * - * This method handles the automatic port configuration link down - * notifications. not associated with a port there is no action taken. Is it - * possible to get a link down notification from a phy that has no assocoated - * port? - */ -static void sci_apc_agent_link_down( - struct isci_host *ihost, - struct sci_port_configuration_agent *port_agent, - struct isci_port *iport, - struct isci_phy *iphy) -{ - port_agent->phy_ready_mask &= ~(1 << iphy->phy_index); - - if (!iport) - return; - if (port_agent->phy_configured_mask & (1 << iphy->phy_index)) { - enum sci_status status; - - status = sci_port_remove_phy(iport, iphy); - - if (status == SCI_SUCCESS) - port_agent->phy_configured_mask &= ~(1 << iphy->phy_index); - } -} - -/* configure the phys into ports when the timer fires */ -static void apc_agent_timeout(unsigned long data) -{ - u32 index; - struct sci_timer *tmr = (struct sci_timer *)data; - struct sci_port_configuration_agent *port_agent; - struct isci_host *ihost; - unsigned long flags; - u16 configure_phy_mask; - - port_agent = container_of(tmr, typeof(*port_agent), timer); - ihost = container_of(port_agent, typeof(*ihost), port_agent); - - spin_lock_irqsave(&ihost->scic_lock, flags); - - if (tmr->cancel) - goto done; - - port_agent->timer_pending = false; - - configure_phy_mask = ~port_agent->phy_configured_mask & port_agent->phy_ready_mask; - - if (!configure_phy_mask) - return; - - for (index = 0; index < SCI_MAX_PHYS; index++) { - if ((configure_phy_mask & (1 << index)) == 0) - continue; - - sci_apc_agent_configure_ports(ihost, port_agent, - &ihost->phys[index], false); - } - -done: - spin_unlock_irqrestore(&ihost->scic_lock, flags); -} - -/* - * ****************************************************************************** - * Public port configuration agent routines - * ****************************************************************************** */ - -/** - * - * - * This method will construct the port configuration agent for operation. This - * call is universal for both manual port configuration and automatic port - * configuration modes. - */ -void sci_port_configuration_agent_construct( - struct sci_port_configuration_agent *port_agent) -{ - u32 index; - - port_agent->phy_configured_mask = 0x00; - port_agent->phy_ready_mask = 0x00; - - port_agent->link_up_handler = NULL; - port_agent->link_down_handler = NULL; - - port_agent->timer_pending = false; - - for (index = 0; index < SCI_MAX_PORTS; index++) { - port_agent->phy_valid_port_range[index].min_index = 0; - port_agent->phy_valid_port_range[index].max_index = 0; - } -} - -enum sci_status sci_port_configuration_agent_initialize( - struct isci_host *ihost, - struct sci_port_configuration_agent *port_agent) -{ - enum sci_status status; - enum sci_port_configuration_mode mode; - - mode = ihost->oem_parameters.controller.mode_type; - - if (mode == SCIC_PORT_MANUAL_CONFIGURATION_MODE) { - status = sci_mpc_agent_validate_phy_configuration( - ihost, port_agent); - - port_agent->link_up_handler = sci_mpc_agent_link_up; - port_agent->link_down_handler = sci_mpc_agent_link_down; - - sci_init_timer(&port_agent->timer, mpc_agent_timeout); - } else { - status = sci_apc_agent_validate_phy_configuration( - ihost, port_agent); - - port_agent->link_up_handler = sci_apc_agent_link_up; - port_agent->link_down_handler = sci_apc_agent_link_down; - - sci_init_timer(&port_agent->timer, apc_agent_timeout); - } - - return status; -} diff --git a/trunk/drivers/scsi/isci/probe_roms.c b/trunk/drivers/scsi/isci/probe_roms.c deleted file mode 100644 index b5f4341de243..000000000000 --- a/trunk/drivers/scsi/isci/probe_roms.c +++ /dev/null @@ -1,243 +0,0 @@ -/* - * This file is provided under a dual BSD/GPLv2 license. When using or - * redistributing this file, you may do so under either license. - * - * GPL LICENSE SUMMARY - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License 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., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. - * The full GNU General Public License is included in this distribution - * in the file called LICENSE.GPL. - */ - -/* probe_roms - scan for oem parameters */ - -#include -#include -#include -#include -#include - -#include "isci.h" -#include "task.h" -#include "probe_roms.h" - -static efi_char16_t isci_efivar_name[] = { - 'R', 's', 't', 'S', 'c', 'u', 'O' -}; - -struct isci_orom *isci_request_oprom(struct pci_dev *pdev) -{ - void __iomem *oprom = pci_map_biosrom(pdev); - struct isci_orom *rom = NULL; - size_t len, i; - int j; - char oem_sig[4]; - struct isci_oem_hdr oem_hdr; - u8 *tmp, sum; - - if (!oprom) - return NULL; - - len = pci_biosrom_size(pdev); - rom = devm_kzalloc(&pdev->dev, sizeof(*rom), GFP_KERNEL); - if (!rom) { - dev_warn(&pdev->dev, - "Unable to allocate memory for orom\n"); - return NULL; - } - - for (i = 0; i < len && rom; i += ISCI_OEM_SIG_SIZE) { - memcpy_fromio(oem_sig, oprom + i, ISCI_OEM_SIG_SIZE); - - /* we think we found the OEM table */ - if (memcmp(oem_sig, ISCI_OEM_SIG, ISCI_OEM_SIG_SIZE) == 0) { - size_t copy_len; - - memcpy_fromio(&oem_hdr, oprom + i, sizeof(oem_hdr)); - - copy_len = min(oem_hdr.len - sizeof(oem_hdr), - sizeof(*rom)); - - memcpy_fromio(rom, - oprom + i + sizeof(oem_hdr), - copy_len); - - /* calculate checksum */ - tmp = (u8 *)&oem_hdr; - for (j = 0, sum = 0; j < sizeof(oem_hdr); j++, tmp++) - sum += *tmp; - - tmp = (u8 *)rom; - for (j = 0; j < sizeof(*rom); j++, tmp++) - sum += *tmp; - - if (sum != 0) { - dev_warn(&pdev->dev, - "OEM table checksum failed\n"); - continue; - } - - /* keep going if that's not the oem param table */ - if (memcmp(rom->hdr.signature, - ISCI_ROM_SIG, - ISCI_ROM_SIG_SIZE) != 0) - continue; - - dev_info(&pdev->dev, - "OEM parameter table found in OROM\n"); - break; - } - } - - if (i >= len) { - dev_err(&pdev->dev, "oprom parse error\n"); - devm_kfree(&pdev->dev, rom); - rom = NULL; - } - pci_unmap_biosrom(oprom); - - return rom; -} - -enum sci_status isci_parse_oem_parameters(struct sci_oem_params *oem, - struct isci_orom *orom, int scu_index) -{ - /* check for valid inputs */ - if (scu_index < 0 || scu_index >= SCI_MAX_CONTROLLERS || - scu_index > orom->hdr.num_elements || !oem) - return -EINVAL; - - *oem = orom->ctrl[scu_index]; - return 0; -} - -struct isci_orom *isci_request_firmware(struct pci_dev *pdev, const struct firmware *fw) -{ - struct isci_orom *orom = NULL, *data; - int i, j; - - if (request_firmware(&fw, ISCI_FW_NAME, &pdev->dev) != 0) - return NULL; - - if (fw->size < sizeof(*orom)) - goto out; - - data = (struct isci_orom *)fw->data; - - if (strncmp(ISCI_ROM_SIG, data->hdr.signature, - strlen(ISCI_ROM_SIG)) != 0) - goto out; - - orom = devm_kzalloc(&pdev->dev, fw->size, GFP_KERNEL); - if (!orom) - goto out; - - memcpy(orom, fw->data, fw->size); - - if (is_c0(pdev)) - goto out; - - /* - * deprecated: override default amp_control for pre-preproduction - * silicon revisions - */ - for (i = 0; i < ARRAY_SIZE(orom->ctrl); i++) - for (j = 0; j < ARRAY_SIZE(orom->ctrl[i].phys); j++) { - orom->ctrl[i].phys[j].afe_tx_amp_control0 = 0xe7c03; - orom->ctrl[i].phys[j].afe_tx_amp_control1 = 0xe7c03; - orom->ctrl[i].phys[j].afe_tx_amp_control2 = 0xe7c03; - orom->ctrl[i].phys[j].afe_tx_amp_control3 = 0xe7c03; - } - out: - release_firmware(fw); - - return orom; -} - -static struct efi *get_efi(void) -{ -#ifdef CONFIG_EFI - return &efi; -#else - return NULL; -#endif -} - -struct isci_orom *isci_get_efi_var(struct pci_dev *pdev) -{ - efi_status_t status; - struct isci_orom *rom; - struct isci_oem_hdr *oem_hdr; - u8 *tmp, sum; - int j; - unsigned long data_len; - u8 *efi_data; - u32 efi_attrib = 0; - - data_len = 1024; - efi_data = devm_kzalloc(&pdev->dev, data_len, GFP_KERNEL); - if (!efi_data) { - dev_warn(&pdev->dev, - "Unable to allocate memory for EFI data\n"); - return NULL; - } - - rom = (struct isci_orom *)(efi_data + sizeof(struct isci_oem_hdr)); - - if (get_efi()) - status = get_efi()->get_variable(isci_efivar_name, - &ISCI_EFI_VENDOR_GUID, - &efi_attrib, - &data_len, - efi_data); - else - status = EFI_NOT_FOUND; - - if (status != EFI_SUCCESS) { - dev_warn(&pdev->dev, - "Unable to obtain EFI var data for OEM parms\n"); - return NULL; - } - - oem_hdr = (struct isci_oem_hdr *)efi_data; - - if (memcmp(oem_hdr->sig, ISCI_OEM_SIG, ISCI_OEM_SIG_SIZE) != 0) { - dev_warn(&pdev->dev, - "Invalid OEM header signature\n"); - return NULL; - } - - /* calculate checksum */ - tmp = (u8 *)efi_data; - for (j = 0, sum = 0; j < (sizeof(*oem_hdr) + sizeof(*rom)); j++, tmp++) - sum += *tmp; - - if (sum != 0) { - dev_warn(&pdev->dev, - "OEM table checksum failed\n"); - return NULL; - } - - if (memcmp(rom->hdr.signature, - ISCI_ROM_SIG, - ISCI_ROM_SIG_SIZE) != 0) { - dev_warn(&pdev->dev, - "Invalid OEM table signature\n"); - return NULL; - } - - return rom; -} diff --git a/trunk/drivers/scsi/isci/probe_roms.h b/trunk/drivers/scsi/isci/probe_roms.h deleted file mode 100644 index dc007e692f4e..000000000000 --- a/trunk/drivers/scsi/isci/probe_roms.h +++ /dev/null @@ -1,249 +0,0 @@ -/* - * This file is provided under a dual BSD/GPLv2 license. When using or - * redistributing this file, you may do so under either license. - * - * GPL LICENSE SUMMARY - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License 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., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. - * The full GNU General Public License is included in this distribution - * in the file called LICENSE.GPL. - * - * BSD LICENSE - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Intel Corporation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#ifndef _ISCI_PROBE_ROMS_H_ -#define _ISCI_PROBE_ROMS_H_ - -#ifdef __KERNEL__ -#include -#include -#include -#include "isci.h" - -#define SCIC_SDS_PARM_NO_SPEED 0 - -/* generation 1 (i.e. 1.5 Gb/s) */ -#define SCIC_SDS_PARM_GEN1_SPEED 1 - -/* generation 2 (i.e. 3.0 Gb/s) */ -#define SCIC_SDS_PARM_GEN2_SPEED 2 - -/* generation 3 (i.e. 6.0 Gb/s) */ -#define SCIC_SDS_PARM_GEN3_SPEED 3 -#define SCIC_SDS_PARM_MAX_SPEED SCIC_SDS_PARM_GEN3_SPEED - -/* parameters that can be set by module parameters */ -struct sci_user_parameters { - struct sci_phy_user_params { - /** - * This field specifies the NOTIFY (ENABLE SPIN UP) primitive - * insertion frequency for this phy index. - */ - u32 notify_enable_spin_up_insertion_frequency; - - /** - * This method specifies the number of transmitted DWORDs within which - * to transmit a single ALIGN primitive. This value applies regardless - * of what type of device is attached or connection state. A value of - * 0 indicates that no ALIGN primitives will be inserted. - */ - u16 align_insertion_frequency; - - /** - * This method specifies the number of transmitted DWORDs within which - * to transmit 2 ALIGN primitives. This applies for SAS connections - * only. A minimum value of 3 is required for this field. - */ - u16 in_connection_align_insertion_frequency; - - /** - * This field indicates the maximum speed generation to be utilized - * by phys in the supplied port. - * - A value of 1 indicates generation 1 (i.e. 1.5 Gb/s). - * - A value of 2 indicates generation 2 (i.e. 3.0 Gb/s). - * - A value of 3 indicates generation 3 (i.e. 6.0 Gb/s). - */ - u8 max_speed_generation; - - } phys[SCI_MAX_PHYS]; - - /** - * This field specifies the maximum number of direct attached devices - * that can have power supplied to them simultaneously. - */ - u8 max_number_concurrent_device_spin_up; - - /** - * This field specifies the number of seconds to allow a phy to consume - * power before yielding to another phy. - * - */ - u8 phy_spin_up_delay_interval; - - /** - * These timer values specifies how long a link will remain open with no - * activity in increments of a microsecond, it can be in increments of - * 100 microseconds if the upper most bit is set. - * - */ - u16 stp_inactivity_timeout; - u16 ssp_inactivity_timeout; - - /** - * These timer values specifies how long a link will remain open in increments - * of 100 microseconds. - * - */ - u16 stp_max_occupancy_timeout; - u16 ssp_max_occupancy_timeout; - - /** - * This timer value specifies how long a link will remain open with no - * outbound traffic in increments of a microsecond. - * - */ - u8 no_outbound_task_timeout; - -}; - -#define SCIC_SDS_PARM_PHY_MASK_MIN 0x0 -#define SCIC_SDS_PARM_PHY_MASK_MAX 0xF -#define MAX_CONCURRENT_DEVICE_SPIN_UP_COUNT 4 - -struct sci_oem_params; -int sci_oem_parameters_validate(struct sci_oem_params *oem); - -struct isci_orom; -struct isci_orom *isci_request_oprom(struct pci_dev *pdev); -enum sci_status isci_parse_oem_parameters(struct sci_oem_params *oem, - struct isci_orom *orom, int scu_index); -struct isci_orom *isci_request_firmware(struct pci_dev *pdev, const struct firmware *fw); -struct isci_orom *isci_get_efi_var(struct pci_dev *pdev); - -struct isci_oem_hdr { - u8 sig[4]; - u8 rev_major; - u8 rev_minor; - u16 len; - u8 checksum; - u8 reserved1; - u16 reserved2; -} __attribute__ ((packed)); - -#else -#define SCI_MAX_PORTS 4 -#define SCI_MAX_PHYS 4 -#define SCI_MAX_CONTROLLERS 2 -#endif - -#define ISCI_FW_NAME "isci/isci_firmware.bin" - -#define ROMSIGNATURE 0xaa55 - -#define ISCI_OEM_SIG "$OEM" -#define ISCI_OEM_SIG_SIZE 4 -#define ISCI_ROM_SIG "ISCUOEMB" -#define ISCI_ROM_SIG_SIZE 8 - -#define ISCI_EFI_VENDOR_GUID \ - EFI_GUID(0x193dfefa, 0xa445, 0x4302, 0x99, 0xd8, 0xef, 0x3a, 0xad, \ - 0x1a, 0x04, 0xc6) -#define ISCI_EFI_VAR_NAME "RstScuO" - -/* Allowed PORT configuration modes APC Automatic PORT configuration mode is - * defined by the OEM configuration parameters providing no PHY_MASK parameters - * for any PORT. i.e. There are no phys assigned to any of the ports at start. - * MPC Manual PORT configuration mode is defined by the OEM configuration - * parameters providing a PHY_MASK value for any PORT. It is assumed that any - * PORT with no PHY_MASK is an invalid port and not all PHYs must be assigned. - * A PORT_PHY mask that assigns just a single PHY to a port and no other PHYs - * being assigned is sufficient to declare manual PORT configuration. - */ -enum sci_port_configuration_mode { - SCIC_PORT_MANUAL_CONFIGURATION_MODE = 0, - SCIC_PORT_AUTOMATIC_CONFIGURATION_MODE = 1 -}; - -struct sci_bios_oem_param_block_hdr { - uint8_t signature[ISCI_ROM_SIG_SIZE]; - uint16_t total_block_length; - uint8_t hdr_length; - uint8_t version; - uint8_t preboot_source; - uint8_t num_elements; - uint16_t element_length; - uint8_t reserved[8]; -} __attribute__ ((packed)); - -struct sci_oem_params { - struct { - uint8_t mode_type; - uint8_t max_concurrent_dev_spin_up; - uint8_t do_enable_ssc; - uint8_t reserved; - } controller; - - struct { - uint8_t phy_mask; - } ports[SCI_MAX_PORTS]; - - struct sci_phy_oem_params { - struct { - uint32_t high; - uint32_t low; - } sas_address; - - uint32_t afe_tx_amp_control0; - uint32_t afe_tx_amp_control1; - uint32_t afe_tx_amp_control2; - uint32_t afe_tx_amp_control3; - } phys[SCI_MAX_PHYS]; -} __attribute__ ((packed)); - -struct isci_orom { - struct sci_bios_oem_param_block_hdr hdr; - struct sci_oem_params ctrl[SCI_MAX_CONTROLLERS]; -} __attribute__ ((packed)); - -#endif diff --git a/trunk/drivers/scsi/isci/registers.h b/trunk/drivers/scsi/isci/registers.h deleted file mode 100644 index 9b266c7428e8..000000000000 --- a/trunk/drivers/scsi/isci/registers.h +++ /dev/null @@ -1,1934 +0,0 @@ -/* - * This file is provided under a dual BSD/GPLv2 license. When using or - * redistributing this file, you may do so under either license. - * - * GPL LICENSE SUMMARY - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License 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., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. - * The full GNU General Public License is included in this distribution - * in the file called LICENSE.GPL. - * - * BSD LICENSE - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Intel Corporation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _SCU_REGISTERS_H_ -#define _SCU_REGISTERS_H_ - -/** - * This file contains the constants and structures for the SCU memory mapped - * registers. - * - * - */ - -#define SCU_VIIT_ENTRY_ID_MASK (0xC0000000) -#define SCU_VIIT_ENTRY_ID_SHIFT (30) - -#define SCU_VIIT_ENTRY_FUNCTION_MASK (0x0FF00000) -#define SCU_VIIT_ENTRY_FUNCTION_SHIFT (20) - -#define SCU_VIIT_ENTRY_IPPTMODE_MASK (0x0001F800) -#define SCU_VIIT_ENTRY_IPPTMODE_SHIFT (12) - -#define SCU_VIIT_ENTRY_LPVIE_MASK (0x00000F00) -#define SCU_VIIT_ENTRY_LPVIE_SHIFT (8) - -#define SCU_VIIT_ENTRY_STATUS_MASK (0x000000FF) -#define SCU_VIIT_ENTRY_STATUS_SHIFT (0) - -#define SCU_VIIT_ENTRY_ID_INVALID (0 << SCU_VIIT_ENTRY_ID_SHIFT) -#define SCU_VIIT_ENTRY_ID_VIIT (1 << SCU_VIIT_ENTRY_ID_SHIFT) -#define SCU_VIIT_ENTRY_ID_IIT (2 << SCU_VIIT_ENTRY_ID_SHIFT) -#define SCU_VIIT_ENTRY_ID_VIRT_EXP (3 << SCU_VIIT_ENTRY_ID_SHIFT) - -#define SCU_VIIT_IPPT_SSP_INITIATOR (0x01 << SCU_VIIT_ENTRY_IPPTMODE_SHIFT) -#define SCU_VIIT_IPPT_SMP_INITIATOR (0x02 << SCU_VIIT_ENTRY_IPPTMODE_SHIFT) -#define SCU_VIIT_IPPT_STP_INITIATOR (0x04 << SCU_VIIT_ENTRY_IPPTMODE_SHIFT) -#define SCU_VIIT_IPPT_INITIATOR \ - (\ - SCU_VIIT_IPPT_SSP_INITIATOR \ - | SCU_VIIT_IPPT_SMP_INITIATOR \ - | SCU_VIIT_IPPT_STP_INITIATOR \ - ) - -#define SCU_VIIT_STATUS_RNC_VALID (0x01 << SCU_VIIT_ENTRY_STATUS_SHIFT) -#define SCU_VIIT_STATUS_ADDRESS_VALID (0x02 << SCU_VIIT_ENTRY_STATUS_SHIFT) -#define SCU_VIIT_STATUS_RNI_VALID (0x04 << SCU_VIIT_ENTRY_STATUS_SHIFT) -#define SCU_VIIT_STATUS_ALL_VALID \ - (\ - SCU_VIIT_STATUS_RNC_VALID \ - | SCU_VIIT_STATUS_ADDRESS_VALID \ - | SCU_VIIT_STATUS_RNI_VALID \ - ) - -#define SCU_VIIT_IPPT_SMP_TARGET (0x10 << SCU_VIIT_ENTRY_IPPTMODE_SHIFT) - -/** - * struct scu_viit_entry - This is the SCU Virtual Initiator Table Entry - * - * - */ -struct scu_viit_entry { - /** - * This must be encoded as to the type of initiator that is being constructed - * for this port. - */ - u32 status; - - /** - * Virtual initiator high SAS Address - */ - u32 initiator_sas_address_hi; - - /** - * Virtual initiator low SAS Address - */ - u32 initiator_sas_address_lo; - - /** - * This must be 0 - */ - u32 reserved; - -}; - - -/* IIT Status Defines */ -#define SCU_IIT_ENTRY_ID_MASK (0xC0000000) -#define SCU_IIT_ENTRY_ID_SHIFT (30) - -#define SCU_IIT_ENTRY_STATUS_UPDATE_MASK (0x20000000) -#define SCU_IIT_ENTRY_STATUS_UPDATE_SHIFT (29) - -#define SCU_IIT_ENTRY_LPI_MASK (0x00000F00) -#define SCU_IIT_ENTRY_LPI_SHIFT (8) - -#define SCU_IIT_ENTRY_STATUS_MASK (0x000000FF) -#define SCU_IIT_ENTRY_STATUS_SHIFT (0) - -/* IIT Remote Initiator Defines */ -#define SCU_IIT_ENTRY_REMOTE_TAG_MASK (0x0000FFFF) -#define SCU_IIT_ENTRY_REMOTE_TAG_SHIFT (0) - -#define SCU_IIT_ENTRY_REMOTE_RNC_MASK (0x0FFF0000) -#define SCU_IIT_ENTRY_REMOTE_RNC_SHIFT (16) - -#define SCU_IIT_ENTRY_ID_INVALID (0 << SCU_IIT_ENTRY_ID_SHIFT) -#define SCU_IIT_ENTRY_ID_VIIT (1 << SCU_IIT_ENTRY_ID_SHIFT) -#define SCU_IIT_ENTRY_ID_IIT (2 << SCU_IIT_ENTRY_ID_SHIFT) -#define SCU_IIT_ENTRY_ID_VIRT_EXP (3 << SCU_IIT_ENTRY_ID_SHIFT) - -/** - * struct scu_iit_entry - This will be implemented later when we support - * virtual functions - * - * - */ -struct scu_iit_entry { - u32 status; - u32 remote_initiator_sas_address_hi; - u32 remote_initiator_sas_address_lo; - u32 remote_initiator; - -}; - -/* Generate a value for an SCU register */ -#define SCU_GEN_VALUE(name, value) \ - (((value) << name ## _SHIFT) & (name ## _MASK)) - -/* - * Generate a bit value for an SCU register - * Make sure that the register MASK is just a single bit */ -#define SCU_GEN_BIT(name) \ - SCU_GEN_VALUE(name, ((u32)1)) - -#define SCU_SET_BIT(name, reg_value) \ - ((reg_value) | SCU_GEN_BIT(name)) - -#define SCU_CLEAR_BIT(name, reg_value) \ - ((reg_value)$ ~(SCU_GEN_BIT(name))) - -/* - * ***************************************************************************** - * Unions for bitfield definitions of SCU Registers - * SMU Post Context Port - * ***************************************************************************** */ -#define SMU_POST_CONTEXT_PORT_CONTEXT_INDEX_SHIFT (0) -#define SMU_POST_CONTEXT_PORT_CONTEXT_INDEX_MASK (0x00000FFF) -#define SMU_POST_CONTEXT_PORT_LOGICAL_PORT_INDEX_SHIFT (12) -#define SMU_POST_CONTEXT_PORT_LOGICAL_PORT_INDEX_MASK (0x0000F000) -#define SMU_POST_CONTEXT_PORT_PROTOCOL_ENGINE_SHIFT (16) -#define SMU_POST_CONTEXT_PORT_PROTOCOL_ENGINE_MASK (0x00030000) -#define SMU_POST_CONTEXT_PORT_COMMAND_CONTEXT_SHIFT (18) -#define SMU_POST_CONTEXT_PORT_COMMAND_CONTEXT_MASK (0x00FC0000) -#define SMU_POST_CONTEXT_PORT_RESERVED_MASK (0xFF000000) - -#define SMU_PCP_GEN_VAL(name, value) \ - SCU_GEN_VALUE(SMU_POST_CONTEXT_PORT_ ## name, value) - -/* ***************************************************************************** */ -#define SMU_INTERRUPT_STATUS_COMPLETION_SHIFT (31) -#define SMU_INTERRUPT_STATUS_COMPLETION_MASK (0x80000000) -#define SMU_INTERRUPT_STATUS_QUEUE_SUSPEND_SHIFT (1) -#define SMU_INTERRUPT_STATUS_QUEUE_SUSPEND_MASK (0x00000002) -#define SMU_INTERRUPT_STATUS_QUEUE_ERROR_SHIFT (0) -#define SMU_INTERRUPT_STATUS_QUEUE_ERROR_MASK (0x00000001) -#define SMU_INTERRUPT_STATUS_RESERVED_MASK (0x7FFFFFFC) - -#define SMU_ISR_GEN_BIT(name) \ - SCU_GEN_BIT(SMU_INTERRUPT_STATUS_ ## name) - -#define SMU_ISR_QUEUE_ERROR SMU_ISR_GEN_BIT(QUEUE_ERROR) -#define SMU_ISR_QUEUE_SUSPEND SMU_ISR_GEN_BIT(QUEUE_SUSPEND) -#define SMU_ISR_COMPLETION SMU_ISR_GEN_BIT(COMPLETION) - -/* ***************************************************************************** */ -#define SMU_INTERRUPT_MASK_COMPLETION_SHIFT (31) -#define SMU_INTERRUPT_MASK_COMPLETION_MASK (0x80000000) -#define SMU_INTERRUPT_MASK_QUEUE_SUSPEND_SHIFT (1) -#define SMU_INTERRUPT_MASK_QUEUE_SUSPEND_MASK (0x00000002) -#define SMU_INTERRUPT_MASK_QUEUE_ERROR_SHIFT (0) -#define SMU_INTERRUPT_MASK_QUEUE_ERROR_MASK (0x00000001) -#define SMU_INTERRUPT_MASK_RESERVED_MASK (0x7FFFFFFC) - -#define SMU_IMR_GEN_BIT(name) \ - SCU_GEN_BIT(SMU_INTERRUPT_MASK_ ## name) - -#define SMU_IMR_QUEUE_ERROR SMU_IMR_GEN_BIT(QUEUE_ERROR) -#define SMU_IMR_QUEUE_SUSPEND SMU_IMR_GEN_BIT(QUEUE_SUSPEND) -#define SMU_IMR_COMPLETION SMU_IMR_GEN_BIT(COMPLETION) - -/* ***************************************************************************** */ -#define SMU_INTERRUPT_COALESCING_CONTROL_TIMER_SHIFT (0) -#define SMU_INTERRUPT_COALESCING_CONTROL_TIMER_MASK (0x0000001F) -#define SMU_INTERRUPT_COALESCING_CONTROL_NUMBER_SHIFT (8) -#define SMU_INTERRUPT_COALESCING_CONTROL_NUMBER_MASK (0x0000FF00) -#define SMU_INTERRUPT_COALESCING_CONTROL_RESERVED_MASK (0xFFFF00E0) - -#define SMU_ICC_GEN_VAL(name, value) \ - SCU_GEN_VALUE(SMU_INTERRUPT_COALESCING_CONTROL_ ## name, value) - -/* ***************************************************************************** */ -#define SMU_TASK_CONTEXT_RANGE_START_SHIFT (0) -#define SMU_TASK_CONTEXT_RANGE_START_MASK (0x00000FFF) -#define SMU_TASK_CONTEXT_RANGE_ENDING_SHIFT (16) -#define SMU_TASK_CONTEXT_RANGE_ENDING_MASK (0x0FFF0000) -#define SMU_TASK_CONTEXT_RANGE_ENABLE_SHIFT (31) -#define SMU_TASK_CONTEXT_RANGE_ENABLE_MASK (0x80000000) -#define SMU_TASK_CONTEXT_RANGE_RESERVED_MASK (0x7000F000) - -#define SMU_TCR_GEN_VAL(name, value) \ - SCU_GEN_VALUE(SMU_TASK_CONTEXT_RANGE_ ## name, value) - -#define SMU_TCR_GEN_BIT(name, value) \ - SCU_GEN_BIT(SMU_TASK_CONTEXT_RANGE_ ## name) - -/* ***************************************************************************** */ - -#define SMU_COMPLETION_QUEUE_PUT_POINTER_SHIFT (0) -#define SMU_COMPLETION_QUEUE_PUT_POINTER_MASK (0x00003FFF) -#define SMU_COMPLETION_QUEUE_PUT_CYCLE_BIT_SHIFT (15) -#define SMU_COMPLETION_QUEUE_PUT_CYCLE_BIT_MASK (0x00008000) -#define SMU_COMPLETION_QUEUE_PUT_EVENT_POINTER_SHIFT (16) -#define SMU_COMPLETION_QUEUE_PUT_EVENT_POINTER_MASK (0x03FF0000) -#define SMU_COMPLETION_QUEUE_PUT_EVENT_CYCLE_BIT_SHIFT (26) -#define SMU_COMPLETION_QUEUE_PUT_EVENT_CYCLE_BIT_MASK (0x04000000) -#define SMU_COMPLETION_QUEUE_PUT_RESERVED_MASK (0xF8004000) - -#define SMU_CQPR_GEN_VAL(name, value) \ - SCU_GEN_VALUE(SMU_COMPLETION_QUEUE_PUT_ ## name, value) - -#define SMU_CQPR_GEN_BIT(name) \ - SCU_GEN_BIT(SMU_COMPLETION_QUEUE_PUT_ ## name) - -/* ***************************************************************************** */ - -#define SMU_COMPLETION_QUEUE_GET_POINTER_SHIFT (0) -#define SMU_COMPLETION_QUEUE_GET_POINTER_MASK (0x00003FFF) -#define SMU_COMPLETION_QUEUE_GET_CYCLE_BIT_SHIFT (15) -#define SMU_COMPLETION_QUEUE_GET_CYCLE_BIT_MASK (0x00008000) -#define SMU_COMPLETION_QUEUE_GET_EVENT_POINTER_SHIFT (16) -#define SMU_COMPLETION_QUEUE_GET_EVENT_POINTER_MASK (0x03FF0000) -#define SMU_COMPLETION_QUEUE_GET_EVENT_CYCLE_BIT_SHIFT (26) -#define SMU_COMPLETION_QUEUE_GET_EVENT_CYCLE_BIT_MASK (0x04000000) -#define SMU_COMPLETION_QUEUE_GET_ENABLE_SHIFT (30) -#define SMU_COMPLETION_QUEUE_GET_ENABLE_MASK (0x40000000) -#define SMU_COMPLETION_QUEUE_GET_EVENT_ENABLE_SHIFT (31) -#define SMU_COMPLETION_QUEUE_GET_EVENT_ENABLE_MASK (0x80000000) -#define SMU_COMPLETION_QUEUE_GET_RESERVED_MASK (0x38004000) - -#define SMU_CQGR_GEN_VAL(name, value) \ - SCU_GEN_VALUE(SMU_COMPLETION_QUEUE_GET_ ## name, value) - -#define SMU_CQGR_GEN_BIT(name) \ - SCU_GEN_BIT(SMU_COMPLETION_QUEUE_GET_ ## name) - -#define SMU_CQGR_CYCLE_BIT \ - SMU_CQGR_GEN_BIT(CYCLE_BIT) - -#define SMU_CQGR_EVENT_CYCLE_BIT \ - SMU_CQGR_GEN_BIT(EVENT_CYCLE_BIT) - -#define SMU_CQGR_GET_POINTER_SET(value) \ - SMU_CQGR_GEN_VAL(POINTER, value) - - -/* ***************************************************************************** */ -#define SMU_COMPLETION_QUEUE_CONTROL_QUEUE_LIMIT_SHIFT (0) -#define SMU_COMPLETION_QUEUE_CONTROL_QUEUE_LIMIT_MASK (0x00003FFF) -#define SMU_COMPLETION_QUEUE_CONTROL_EVENT_LIMIT_SHIFT (16) -#define SMU_COMPLETION_QUEUE_CONTROL_EVENT_LIMIT_MASK (0x03FF0000) -#define SMU_COMPLETION_QUEUE_CONTROL_RESERVED_MASK (0xFC00C000) - -#define SMU_CQC_GEN_VAL(name, value) \ - SCU_GEN_VALUE(SMU_COMPLETION_QUEUE_CONTROL_ ## name, value) - -#define SMU_CQC_QUEUE_LIMIT_SET(value) \ - SMU_CQC_GEN_VAL(QUEUE_LIMIT, value) - -#define SMU_CQC_EVENT_LIMIT_SET(value) \ - SMU_CQC_GEN_VAL(EVENT_LIMIT, value) - - -/* ***************************************************************************** */ -#define SMU_DEVICE_CONTEXT_CAPACITY_MAX_TC_SHIFT (0) -#define SMU_DEVICE_CONTEXT_CAPACITY_MAX_TC_MASK (0x00000FFF) -#define SMU_DEVICE_CONTEXT_CAPACITY_MAX_LP_SHIFT (12) -#define SMU_DEVICE_CONTEXT_CAPACITY_MAX_LP_MASK (0x00007000) -#define SMU_DEVICE_CONTEXT_CAPACITY_MAX_RNC_SHIFT (15) -#define SMU_DEVICE_CONTEXT_CAPACITY_MAX_RNC_MASK (0x07FF8000) -#define SMU_DEVICE_CONTEXT_CAPACITY_MAX_PEG_SHIFT (27) -#define SMU_DEVICE_CONTEXT_CAPACITY_MAX_PEG_MASK (0x08000000) -#define SMU_DEVICE_CONTEXT_CAPACITY_RESERVED_MASK (0xF0000000) - -#define SMU_DCC_GEN_VAL(name, value) \ - SCU_GEN_VALUE(SMU_DEVICE_CONTEXT_CAPACITY_ ## name, value) - -#define SMU_DCC_GET_MAX_PEG(value) \ - (\ - ((value) & SMU_DEVICE_CONTEXT_CAPACITY_MAX_PEG_MASK) \ - >> SMU_DEVICE_CONTEXT_CAPACITY_MAX_LP_SHIFT \ - ) - -#define SMU_DCC_GET_MAX_LP(value) \ - (\ - ((value) & SMU_DEVICE_CONTEXT_CAPACITY_MAX_LP_MASK) \ - >> SMU_DEVICE_CONTEXT_CAPACITY_MAX_LP_SHIFT \ - ) - -#define SMU_DCC_GET_MAX_TC(value) \ - (\ - ((value) & SMU_DEVICE_CONTEXT_CAPACITY_MAX_TC_MASK) \ - >> SMU_DEVICE_CONTEXT_CAPACITY_MAX_TC_SHIFT \ - ) - -#define SMU_DCC_GET_MAX_RNC(value) \ - (\ - ((value) & SMU_DEVICE_CONTEXT_CAPACITY_MAX_RNC_MASK) \ - >> SMU_DEVICE_CONTEXT_CAPACITY_MAX_RNC_SHIFT \ - ) - -/* -------------------------------------------------------------------------- */ - -#define SMU_CONTROL_STATUS_TASK_CONTEXT_RANGE_ENABLE_SHIFT (0) -#define SMU_CONTROL_STATUS_TASK_CONTEXT_RANGE_ENABLE_MASK (0x00000001) -#define SMU_CONTROL_STATUS_COMPLETION_BYTE_SWAP_ENABLE_SHIFT (1) -#define SMU_CONTROL_STATUS_COMPLETION_BYTE_SWAP_ENABLE_MASK (0x00000002) -#define SMU_CONTROL_STATUS_CONTEXT_RAM_INIT_COMPLETED_SHIFT (16) -#define SMU_CONTROL_STATUS_CONTEXT_RAM_INIT_COMPLETED_MASK (0x00010000) -#define SMU_CONTROL_STATUS_SCHEDULER_RAM_INIT_COMPLETED_SHIFT (17) -#define SMU_CONTROL_STATUS_SCHEDULER_RAM_INIT_COMPLETED_MASK (0x00020000) -#define SMU_CONTROL_STATUS_RESERVED_MASK (0xFFFCFFFC) - -#define SMU_SMUCSR_GEN_BIT(name) \ - SCU_GEN_BIT(SMU_CONTROL_STATUS_ ## name) - -#define SMU_SMUCSR_SCHEDULER_RAM_INIT_COMPLETED \ - (SMU_SMUCSR_GEN_BIT(SCHEDULER_RAM_INIT_COMPLETED)) - -#define SMU_SMUCSR_CONTEXT_RAM_INIT_COMPLETED \ - (SMU_SMUCSR_GEN_BIT(CONTEXT_RAM_INIT_COMPLETED)) - -#define SCU_RAM_INIT_COMPLETED \ - (\ - SMU_SMUCSR_CONTEXT_RAM_INIT_COMPLETED \ - | SMU_SMUCSR_SCHEDULER_RAM_INIT_COMPLETED \ - ) - -/* -------------------------------------------------------------------------- */ - -#define SMU_SOFTRESET_CONTROL_RESET_PEG0_PE0_SHIFT (0) -#define SMU_SOFTRESET_CONTROL_RESET_PEG0_PE0_MASK (0x00000001) -#define SMU_SOFTRESET_CONTROL_RESET_PEG0_PE1_SHIFT (1) -#define SMU_SOFTRESET_CONTROL_RESET_PEG0_PE1_MASK (0x00000002) -#define SMU_SOFTRESET_CONTROL_RESET_PEG0_PE2_SHIFT (2) -#define SMU_SOFTRESET_CONTROL_RESET_PEG0_PE2_MASK (0x00000004) -#define SMU_SOFTRESET_CONTROL_RESET_PEG0_PE3_SHIFT (3) -#define SMU_SOFTRESET_CONTROL_RESET_PEG0_PE3_MASK (0x00000008) -#define SMU_SOFTRESET_CONTROL_RESET_PEG1_PE0_SHIFT (8) -#define SMU_SOFTRESET_CONTROL_RESET_PEG1_PE0_MASK (0x00000100) -#define SMU_SOFTRESET_CONTROL_RESET_PEG1_PE1_SHIFT (9) -#define SMU_SOFTRESET_CONTROL_RESET_PEG1_PE1_MASK (0x00000200) -#define SMU_SOFTRESET_CONTROL_RESET_PEG1_PE2_SHIFT (10) -#define SMU_SOFTRESET_CONTROL_RESET_PEG1_PE2_MASK (0x00000400) -#define SMU_SOFTRESET_CONTROL_RESET_PEG1_PE3_SHIFT (11) -#define SMU_SOFTRESET_CONTROL_RESET_PEG1_PE3_MASK (0x00000800) - -#define SMU_RESET_PROTOCOL_ENGINE(peg, pe) \ - ((1 << (pe)) << ((peg) * 8)) - -#define SMU_RESET_PEG_PROTOCOL_ENGINES(peg) \ - (\ - SMU_RESET_PROTOCOL_ENGINE(peg, 0) \ - | SMU_RESET_PROTOCOL_ENGINE(peg, 1) \ - | SMU_RESET_PROTOCOL_ENGINE(peg, 2) \ - | SMU_RESET_PROTOCOL_ENGINE(peg, 3) \ - ) - -#define SMU_RESET_ALL_PROTOCOL_ENGINES() \ - (\ - SMU_RESET_PEG_PROTOCOL_ENGINES(0) \ - | SMU_RESET_PEG_PROTOCOL_ENGINES(1) \ - ) - -#define SMU_SOFTRESET_CONTROL_RESET_WIDE_PORT_PEG0_LP0_SHIFT (16) -#define SMU_SOFTRESET_CONTROL_RESET_WIDE_PORT_PEG0_LP0_MASK (0x00010000) -#define SMU_SOFTRESET_CONTROL_RESET_WIDE_PORT_PEG0_LP2_SHIFT (17) -#define SMU_SOFTRESET_CONTROL_RESET_WIDE_PORT_PEG0_LP2_MASK (0x00020000) -#define SMU_SOFTRESET_CONTROL_RESET_WIDE_PORT_PEG1_LP0_SHIFT (18) -#define SMU_SOFTRESET_CONTROL_RESET_WIDE_PORT_PEG1_LP0_MASK (0x00040000) -#define SMU_SOFTRESET_CONTROL_RESET_WIDE_PORT_PEG1_LP2_SHIFT (19) -#define SMU_SOFTRESET_CONTROL_RESET_WIDE_PORT_PEG1_LP2_MASK (0x00080000) - -#define SMU_RESET_WIDE_PORT_QUEUE(peg, wide_port) \ - ((1 << ((wide_port) / 2)) << ((peg) * 2) << 16) - -#define SMU_SOFTRESET_CONTROL_RESET_PEG0_SHIFT (20) -#define SMU_SOFTRESET_CONTROL_RESET_PEG0_MASK (0x00100000) -#define SMU_SOFTRESET_CONTROL_RESET_PEG1_SHIFT (21) -#define SMU_SOFTRESET_CONTROL_RESET_PEG1_MASK (0x00200000) -#define SMU_SOFTRESET_CONTROL_RESET_SCU_SHIFT (22) -#define SMU_SOFTRESET_CONTROL_RESET_SCU_MASK (0x00400000) - -/* - * It seems to make sense that if you are going to reset the protocol - * engine group that you would also reset all of the protocol engines */ -#define SMU_RESET_PROTOCOL_ENGINE_GROUP(peg) \ - (\ - (1 << ((peg) + 20)) \ - | SMU_RESET_WIDE_PORT_QUEUE(peg, 0) \ - | SMU_RESET_WIDE_PORT_QUEUE(peg, 1) \ - | SMU_RESET_PEG_PROTOCOL_ENGINES(peg) \ - ) - -#define SMU_RESET_ALL_PROTOCOL_ENGINE_GROUPS() \ - (\ - SMU_RESET_PROTOCOL_ENGINE_GROUP(0) \ - | SMU_RESET_PROTOCOL_ENGINE_GROUP(1) \ - ) - -#define SMU_RESET_SCU() (0xFFFFFFFF) - - - -/* ***************************************************************************** */ -#define SMU_TASK_CONTEXT_ASSIGNMENT_STARTING_SHIFT (0) -#define SMU_TASK_CONTEXT_ASSIGNMENT_STARTING_MASK (0x00000FFF) -#define SMU_TASK_CONTEXT_ASSIGNMENT_ENDING_SHIFT (16) -#define SMU_TASK_CONTEXT_ASSIGNMENT_ENDING_MASK (0x0FFF0000) -#define SMU_TASK_CONTEXT_ASSIGNMENT_RANGE_CHECK_ENABLE_SHIFT (31) -#define SMU_TASK_CONTEXT_ASSIGNMENT_RANGE_CHECK_ENABLE_MASK (0x80000000) -#define SMU_TASK_CONTEXT_ASSIGNMENT_RESERVED_MASK (0x7000F000) - -#define SMU_TCA_GEN_VAL(name, value) \ - SCU_GEN_VALUE(SMU_TASK_CONTEXT_ASSIGNMENT_ ## name, value) - -#define SMU_TCA_GEN_BIT(name) \ - SCU_GEN_BIT(SMU_TASK_CONTEXT_ASSIGNMENT_ ## name) - -/* ***************************************************************************** */ -#define SCU_SDMA_UNSOLICITED_FRAME_QUEUE_CONTROL_QUEUE_SIZE_SHIFT (0) -#define SCU_SDMA_UNSOLICITED_FRAME_QUEUE_CONTROL_QUEUE_SIZE_MASK (0x00000FFF) -#define SCU_SDMA_UNSOLICITED_FRAME_QUEUE_CONTROL_RESERVED_MASK (0xFFFFF000) - -#define SCU_UFQC_GEN_VAL(name, value) \ - SCU_GEN_VALUE(SCU_SDMA_UNSOLICITED_FRAME_QUEUE_CONTROL_ ## name, value) - -#define SCU_UFQC_QUEUE_SIZE_SET(value) \ - SCU_UFQC_GEN_VAL(QUEUE_SIZE, value) - -/* ***************************************************************************** */ -#define SCU_SDMA_UNSOLICITED_FRAME_QUEUE_PUT_POINTER_SHIFT (0) -#define SCU_SDMA_UNSOLICITED_FRAME_QUEUE_PUT_POINTER_MASK (0x00000FFF) -#define SCU_SDMA_UNSOLICITED_FRAME_QUEUE_PUT_CYCLE_BIT_SHIFT (12) -#define SCU_SDMA_UNSOLICITED_FRAME_QUEUE_PUT_CYCLE_BIT_MASK (0x00001000) -#define SCU_SDMA_UNSOLICITED_FRAME_QUEUE_PUT_RESERVED_MASK (0xFFFFE000) - -#define SCU_UFQPP_GEN_VAL(name, value) \ - SCU_GEN_VALUE(SCU_SDMA_UNSOLICITED_FRAME_QUEUE_PUT_ ## name, value) - -#define SCU_UFQPP_GEN_BIT(name) \ - SCU_GEN_BIT(SCU_SDMA_UNSOLICITED_FRAME_QUEUE_PUT_ ## name) - -/* - * ***************************************************************************** - * * SDMA Registers - * ***************************************************************************** */ -#define SCU_SDMA_UNSOLICITED_FRAME_QUEUE_GET_POINTER_SHIFT (0) -#define SCU_SDMA_UNSOLICITED_FRAME_QUEUE_GET_POINTER_MASK (0x00000FFF) -#define SCU_SDMA_UNSOLICITED_FRAME_QUEUE_GET_CYCLE_BIT_SHIFT (12) -#define SCU_SDMA_UNSOLICITED_FRAME_QUEUE_GET_CYCLE_BIT_MASK (12) -#define SCU_SDMA_UNSOLICITED_FRAME_QUEUE_GET_ENABLE_BIT_SHIFT (31) -#define SCU_SDMA_UNSOLICITED_FRAME_QUEUE_GET_ENABLE_BIT_MASK (0x80000000) -#define SCU_SDMA_UNSOLICITED_FRAME_QUEUE_GET_RESERVED_MASK (0x7FFFE000) - -#define SCU_UFQGP_GEN_VAL(name, value) \ - SCU_GEN_VALUE(SCU_SDMA_UNSOLICITED_FRAME_QUEUE_GET_ ## name, value) - -#define SCU_UFQGP_GEN_BIT(name) \ - SCU_GEN_BIT(SCU_SDMA_UNSOLICITED_FRAME_QUEUE_GET_ ## name) - -#define SCU_UFQGP_CYCLE_BIT(value) \ - SCU_UFQGP_GEN_BIT(CYCLE_BIT, value) - -#define SCU_UFQGP_GET_POINTER(value) \ - SCU_UFQGP_GEN_VALUE(POINTER, value) - -#define SCU_UFQGP_ENABLE(value) \ - (SCU_UFQGP_GEN_BIT(ENABLE) | value) - -#define SCU_UFQGP_DISABLE(value) \ - (~SCU_UFQGP_GEN_BIT(ENABLE) & value) - -#define SCU_UFQGP_VALUE(bit, value) \ - (SCU_UFQGP_CYCLE_BIT(bit) | SCU_UFQGP_GET_POINTER(value)) - -/* ***************************************************************************** */ -#define SCU_PDMA_CONFIGURATION_ADDRESS_MODIFIER_SHIFT (0) -#define SCU_PDMA_CONFIGURATION_ADDRESS_MODIFIER_MASK (0x0000FFFF) -#define SCU_PDMA_CONFIGURATION_PCI_RELAXED_ORDERING_ENABLE_SHIFT (16) -#define SCU_PDMA_CONFIGURATION_PCI_RELAXED_ORDERING_ENABLE_MASK (0x00010000) -#define SCU_PDMA_CONFIGURATION_PCI_NO_SNOOP_ENABLE_SHIFT (17) -#define SCU_PDMA_CONFIGURATION_PCI_NO_SNOOP_ENABLE_MASK (0x00020000) -#define SCU_PDMA_CONFIGURATION_BIG_ENDIAN_CONTROL_BYTE_SWAP_SHIFT (18) -#define SCU_PDMA_CONFIGURATION_BIG_ENDIAN_CONTROL_BYTE_SWAP_MASK (0x00040000) -#define SCU_PDMA_CONFIGURATION_BIG_ENDIAN_CONTROL_XPI_SGL_FETCH_SHIFT (19) -#define SCU_PDMA_CONFIGURATION_BIG_ENDIAN_CONTROL_XPI_SGL_FETCH_MASK (0x00080000) -#define SCU_PDMA_CONFIGURATION_BIG_ENDIAN_CONTROL_XPI_RX_HEADER_RAM_WRITE_SHIFT (20) -#define SCU_PDMA_CONFIGURATION_BIG_ENDIAN_CONTROL_XPI_RX_HEADER_RAM_WRITE_MASK (0x00100000) -#define SCU_PDMA_CONFIGURATION_BIG_ENDIAN_CONTROL_XPI_UF_ADDRESS_FETCH_SHIFT (21) -#define SCU_PDMA_CONFIGURATION_BIG_ENDIAN_CONTROL_XPI_UF_ADDRESS_FETCH_MASK (0x00200000) -#define SCU_PDMA_CONFIGURATION_ADDRESS_MODIFIER_SELECT_SHIFT (22) -#define SCU_PDMA_CONFIGURATION_ADDRESS_MODIFIER_SELECT_MASK (0x00400000) -#define SCU_PDMA_CONFIGURATION_RESERVED_MASK (0xFF800000) - -#define SCU_PDMACR_GEN_VALUE(name, value) \ - SCU_GEN_VALUE(SCU_PDMA_CONFIGURATION_ ## name, value) - -#define SCU_PDMACR_GEN_BIT(name) \ - SCU_GEN_BIT(SCU_PDMA_CONFIGURATION_ ## name) - -#define SCU_PDMACR_BE_GEN_BIT(name) \ - SCU_PCMACR_GEN_BIT(BIG_ENDIAN_CONTROL_ ## name) - -/* ***************************************************************************** */ -#define SCU_CDMA_CONFIGURATION_PCI_RELAXED_ORDERING_ENABLE_SHIFT (8) -#define SCU_CDMA_CONFIGURATION_PCI_RELAXED_ORDERING_ENABLE_MASK (0x00000100) - -#define SCU_CDMACR_GEN_BIT(name) \ - SCU_GEN_BIT(SCU_CDMA_CONFIGURATION_ ## name) - -/* - * ***************************************************************************** - * * SCU Link Layer Registers - * ***************************************************************************** */ -#define SCU_LINK_LAYER_SPEED_NEGOTIATION_TIMER_VALUES_TIMEOUT_SHIFT (0) -#define SCU_LINK_LAYER_SPEED_NEGOTIATION_TIMER_VALUES_TIMEOUT_MASK (0x000000FF) -#define SCU_LINK_LAYER_SPEED_NEGOTIATION_TIMER_VALUES_LOCK_TIME_SHIFT (8) -#define SCU_LINK_LAYER_SPEED_NEGOTIATION_TIMER_VALUES_LOCK_TIME_MASK (0x0000FF00) -#define SCU_LINK_LAYER_SPEED_NEGOTIATION_TIMER_VALUES_RATE_CHANGE_DELAY_SHIFT (16) -#define SCU_LINK_LAYER_SPEED_NEGOTIATION_TIMER_VALUES_RATE_CHANGE_DELAY_MASK (0x00FF0000) -#define SCU_LINK_LAYER_SPEED_NEGOTIATION_TIMER_VALUES_DWORD_SYNC_TIMEOUT_SHIFT (24) -#define SCU_LINK_LAYER_SPEED_NEGOTIATION_TIMER_VALUES_DWORD_SYNC_TIMEOUT_MASK (0xFF000000) -#define SCU_LINK_LAYER_SPEED_NECGOIATION_TIMER_VALUES_REQUIRED_MASK (0x00000000) -#define SCU_LINK_LAYER_SPEED_NECGOIATION_TIMER_VALUES_DEFAULT_MASK (0x7D00676F) -#define SCU_LINK_LAYER_SPEED_NECGOIATION_TIMER_VALUES_RESERVED_MASK (0x00FF0000) - -#define SCU_SAS_SPDTOV_GEN_VALUE(name, value) \ - SCU_GEN_VALUE(SCU_LINK_LAYER_SPEED_NEGOTIATION_TIMER_VALUES_ ## name, value) - - -#define SCU_LINK_STATUS_DWORD_SYNC_AQUIRED_SHIFT (2) -#define SCU_LINK_STATUS_DWORD_SYNC_AQUIRED_MASK (0x00000004) -#define SCU_LINK_STATUS_TRANSMIT_PORT_SELECTION_DONE_SHIFT (4) -#define SCU_LINK_STATUS_TRANSMIT_PORT_SELECTION_DONE_MASK (0x00000010) -#define SCU_LINK_STATUS_RECEIVER_CREDIT_EXHAUSTED_SHIFT (5) -#define SCU_LINK_STATUS_RECEIVER_CREDIT_EXHAUSTED_MASK (0x00000020) -#define SCU_LINK_STATUS_RESERVED_MASK (0xFFFFFFCD) - -#define SCU_SAS_LLSTA_GEN_BIT(name) \ - SCU_GEN_BIT(SCU_LINK_STATUS_ ## name) - - -/* TODO: Where is the SATA_PSELTOV register? */ - -/* - * ***************************************************************************** - * * SCU SAS Maximum Arbitration Wait Time Timeout Register - * ***************************************************************************** */ -#define SCU_SAS_MAX_ARBITRATION_WAIT_TIME_TIMEOUT_VALUE_SHIFT (0) -#define SCU_SAS_MAX_ARBITRATION_WAIT_TIME_TIMEOUT_VALUE_MASK (0x00007FFF) -#define SCU_SAS_MAX_ARBITRATION_WAIT_TIME_TIMEOUT_SCALE_SHIFT (15) -#define SCU_SAS_MAX_ARBITRATION_WAIT_TIME_TIMEOUT_SCALE_MASK (0x00008000) - -#define SCU_SAS_MAWTTOV_GEN_VALUE(name, value) \ - SCU_GEN_VALUE(SCU_SAS_MAX_ARBITRATION_WAIT_TIME_TIMEOUT_ ## name, value) - -#define SCU_SAS_MAWTTOV_GEN_BIT(name) \ - SCU_GEN_BIT(SCU_SAS_MAX_ARBITRATION_WAIT_TIME_TIMEOUT_ ## name) - - -/* - * TODO: Where is the SAS_LNKTOV regsiter? - * TODO: Where is the SAS_PHYTOV register? */ - -#define SCU_SAS_TRANSMIT_IDENTIFICATION_SMP_TARGET_SHIFT (1) -#define SCU_SAS_TRANSMIT_IDENTIFICATION_SMP_TARGET_MASK (0x00000002) -#define SCU_SAS_TRANSMIT_IDENTIFICATION_STP_TARGET_SHIFT (2) -#define SCU_SAS_TRANSMIT_IDENTIFICATION_STP_TARGET_MASK (0x00000004) -#define SCU_SAS_TRANSMIT_IDENTIFICATION_SSP_TARGET_SHIFT (3) -#define SCU_SAS_TRANSMIT_IDENTIFICATION_SSP_TARGET_MASK (0x00000008) -#define SCU_SAS_TRANSMIT_IDENTIFICATION_DA_SATA_HOST_SHIFT (8) -#define SCU_SAS_TRANSMIT_IDENTIFICATION_DA_SATA_HOST_MASK (0x00000100) -#define SCU_SAS_TRANSMIT_IDENTIFICATION_SMP_INITIATOR_SHIFT (9) -#define SCU_SAS_TRANSMIT_IDENTIFICATION_SMP_INITIATOR_MASK (0x00000200) -#define SCU_SAS_TRANSMIT_IDENTIFICATION_STP_INITIATOR_SHIFT (10) -#define SCU_SAS_TRANSMIT_IDENTIFICATION_STP_INITIATOR_MASK (0x00000400) -#define SCU_SAS_TRANSMIT_IDENTIFICATION_SSP_INITIATOR_SHIFT (11) -#define SCU_SAS_TRANSMIT_IDENTIFICATION_SSP_INITIATOR_MASK (0x00000800) -#define SCU_SAS_TRANSMIT_IDENTIFICATION_REASON_CODE_SHIFT (16) -#define SCU_SAS_TRANSMIT_IDENTIFICATION_REASON_CODE_MASK (0x000F0000) -#define SCU_SAS_TRANSMIT_IDENTIFICATION_ADDRESS_FRAME_TYPE_SHIFT (24) -#define SCU_SAS_TRANSMIT_IDENTIFICATION_ADDRESS_FRAME_TYPE_MASK (0x0F000000) -#define SCU_SAS_TRANSMIT_IDENTIFICATION_DEVICE_TYPE_SHIFT (28) -#define SCU_SAS_TRANSMIT_IDENTIFICATION_DEVICE_TYPE_MASK (0x70000000) -#define SCU_SAS_TRANSMIT_IDENTIFICATION_RESERVED_MASK (0x80F0F1F1) - -#define SCU_SAS_TIID_GEN_VAL(name, value) \ - SCU_GEN_VALUE(SCU_SAS_TRANSMIT_IDENTIFICATION_ ## name, value) - -#define SCU_SAS_TIID_GEN_BIT(name) \ - SCU_GEN_BIT(SCU_SAS_TRANSMIT_IDENTIFICATION_ ## name) - -/* SAS Identify Frame PHY Identifier Register */ -#define SCU_LINK_LAYER_IDENTIFY_FRAME_PHY_IDENTIFIER_BREAK_REPLY_CAPABLE_SHIFT (16) -#define SCU_LINK_LAYER_IDENTIFY_FRAME_PHY_IDENTIFIER_BREAK_REPLY_CAPABLE_MASK (0x00010000) -#define SCU_LINK_LAYER_IDENTIFY_FRAME_PHY_IDENTIFIER_REQUESTED_INSIDE_ZPSDS_SHIFT (17) -#define SCU_LINK_LAYER_IDENTIFY_FRAME_PHY_IDENTIFIER_REQUESTED_INSIDE_ZPSDS_MASK (0x00020000) -#define SCU_LINK_LAYER_IDENTIFY_FRAME_PHY_IDENTIFIER_INSIDE_ZPSDS_PERSISTENT_SHIFT (18) -#define SCU_LINK_LAYER_IDENTIFY_FRAME_PHY_IDENTIFIER_INSIDE_ZPSDS_PERSISTENT_MASK (0x00040000) -#define SCU_LINK_LAYER_IDENTIFY_FRAME_PHY_IDENTIFIER_ID_SHIFT (24) -#define SCU_LINK_LAYER_IDENTIFY_FRAME_PHY_IDENTIFIER_ID_MASK (0xFF000000) -#define SCU_LINK_LAYER_IDENTIFY_FRAME_PHY_IDENTIFIER_RESERVED_MASK (0x00F800FF) - -#define SCU_SAS_TIPID_GEN_VALUE(name, value) \ - SCU_GEN_VALUE(SCU_LINK_LAYER_IDENTIFY_FRAME_PHY_IDENTIFIER_ ## name, value) - -#define SCU_SAS_TIPID_GEN_BIT(name) \ - SCU_GEN_BIT(SCU_LINK_LAYER_IDENTIFY_FRAME_PHY_IDENTIFIER_ ## name) - - -#define SCU_SAS_PHY_CONFIGURATION_TX_PARITY_CHECK_SHIFT (4) -#define SCU_SAS_PHY_CONFIGURATION_TX_PARITY_CHECK_MASK (0x00000010) -#define SCU_SAS_PHY_CONFIGURATION_TX_BAD_CRC_SHIFT (6) -#define SCU_SAS_PHY_CONFIGURATION_TX_BAD_CRC_MASK (0x00000040) -#define SCU_SAS_PHY_CONFIGURATION_DISABLE_SCRAMBLER_SHIFT (7) -#define SCU_SAS_PHY_CONFIGURATION_DISABLE_SCRAMBLER_MASK (0x00000080) -#define SCU_SAS_PHY_CONFIGURATION_DISABLE_DESCRAMBLER_SHIFT (8) -#define SCU_SAS_PHY_CONFIGURATION_DISABLE_DESCRAMBLER_MASK (0x00000100) -#define SCU_SAS_PHY_CONFIGURATION_DISABLE_CREDIT_INSERTION_SHIFT (9) -#define SCU_SAS_PHY_CONFIGURATION_DISABLE_CREDIT_INSERTION_MASK (0x00000200) -#define SCU_SAS_PHY_CONFIGURATION_SUSPEND_PROTOCOL_ENGINE_SHIFT (11) -#define SCU_SAS_PHY_CONFIGURATION_SUSPEND_PROTOCOL_ENGINE_MASK (0x00000800) -#define SCU_SAS_PHY_CONFIGURATION_SATA_SPINUP_HOLD_SHIFT (12) -#define SCU_SAS_PHY_CONFIGURATION_SATA_SPINUP_HOLD_MASK (0x00001000) -#define SCU_SAS_PHY_CONFIGURATION_TRANSMIT_PORT_SELECTION_SIGNAL_SHIFT (13) -#define SCU_SAS_PHY_CONFIGURATION_TRANSMIT_PORT_SELECTION_SIGNAL_MASK (0x00002000) -#define SCU_SAS_PHY_CONFIGURATION_HARD_RESET_SHIFT (14) -#define SCU_SAS_PHY_CONFIGURATION_HARD_RESET_MASK (0x00004000) -#define SCU_SAS_PHY_CONFIGURATION_OOB_ENABLE_SHIFT (15) -#define SCU_SAS_PHY_CONFIGURATION_OOB_ENABLE_MASK (0x00008000) -#define SCU_SAS_PHY_CONFIGURATION_ENABLE_FRAME_TX_INSERT_ALIGN_SHIFT (23) -#define SCU_SAS_PHY_CONFIGURATION_ENABLE_FRAME_TX_INSERT_ALIGN_MASK (0x00800000) -#define SCU_SAS_PHY_CONFIGURATION_FORWARD_IDENTIFY_FRAME_SHIFT (27) -#define SCU_SAS_PHY_CONFIGURATION_FORWARD_IDENTIFY_FRAME_MASK (0x08000000) -#define SCU_SAS_PHY_CONFIGURATION_DISABLE_BYTE_TRANSPOSE_STP_FRAME_SHIFT (28) -#define SCU_SAS_PHY_CONFIGURATION_DISABLE_BYTE_TRANSPOSE_STP_FRAME_MASK (0x10000000) -#define SCU_SAS_PHY_CONFIGURATION_OOB_RESET_SHIFT (29) -#define SCU_SAS_PHY_CONFIGURATION_OOB_RESET_MASK (0x20000000) -#define SCU_SAS_PHY_CONFIGURATION_THREE_IAF_ENABLE_SHIFT (30) -#define SCU_SAS_PHY_CONFIGURATION_THREE_IAF_ENABLE_MASK (0x40000000) -#define SCU_SAS_PHY_CONFIGURATION_OOB_ALIGN0_ENABLE_SHIFT (31) -#define SCU_SAS_PHY_CONFIGURATION_OOB_ALIGN0_ENABLE_MASK (0x80000000) -#define SCU_SAS_PHY_CONFIGURATION_REQUIRED_MASK (0x0100000F) -#define SCU_SAS_PHY_CONFIGURATION_DEFAULT_MASK (0x4180100F) -#define SCU_SAS_PHY_CONFIGURATION_RESERVED_MASK (0x00000000) - -#define SCU_SAS_PCFG_GEN_BIT(name) \ - SCU_GEN_BIT(SCU_SAS_PHY_CONFIGURATION_ ## name) - -#define SCU_LINK_LAYER_ALIGN_INSERTION_FREQUENCY_GENERAL_SHIFT (0) -#define SCU_LINK_LAYER_ALIGN_INSERTION_FREQUENCY_GENERAL_MASK (0x000007FF) -#define SCU_LINK_LAYER_ALIGN_INSERTION_FREQUENCY_CONNECTED_SHIFT (16) -#define SCU_LINK_LAYER_ALIGN_INSERTION_FREQUENCY_CONNECTED_MASK (0x00ff0000) - -#define SCU_ALIGN_INSERTION_FREQUENCY_GEN_VAL(name, value) \ - SCU_GEN_VALUE(SCU_LINK_LAYER_ALIGN_INSERTION_FREQUENCY_##name, value) - -#define SCU_LINK_LAYER_ENABLE_SPINUP_CONTROL_COUNT_SHIFT (0) -#define SCU_LINK_LAYER_ENABLE_SPINUP_CONTROL_COUNT_MASK (0x0003FFFF) -#define SCU_LINK_LAYER_ENABLE_SPINUP_CONTROL_ENABLE_SHIFT (31) -#define SCU_LINK_LAYER_ENABLE_SPINUP_CONTROL_ENABLE_MASK (0x80000000) -#define SCU_LINK_LAYER_ENABLE_SPINUP_CONTROL_RESERVED_MASK (0x7FFC0000) - -#define SCU_ENSPINUP_GEN_VAL(name, value) \ - SCU_GEN_VALUE(SCU_LINK_LAYER_ENABLE_SPINUP_CONTROL_ ## name, value) - -#define SCU_ENSPINUP_GEN_BIT(name) \ - SCU_GEN_BIT(SCU_LINK_LAYER_ENABLE_SPINUP_CONTROL_ ## name) - - -#define SCU_LINK_LAYER_PHY_CAPABILITIES_TXSSCTYPE_SHIFT (1) -#define SCU_LINK_LAYER_PHY_CAPABILITIES_TXSSCTYPE_MASK (0x00000002) -#define SCU_LINK_LAYER_PHY_CAPABILITIES_RLLRATE_SHIFT (4) -#define SCU_LINK_LAYER_PHY_CAPABILITIES_RLLRATE_MASK (0x000000F0) -#define SCU_LINK_LAYER_PHY_CAPABILITIES_SWO15GBPS_SHIFT (8) -#define SCU_LINK_LAYER_PHY_CAPABILITIES_SWO15GBPS_MASK (0x00000100) -#define SCU_LINK_LAYER_PHY_CAPABILITIES_SW15GBPS_SHIFT (9) -#define SCU_LINK_LAYER_PHY_CAPABILITIES_SW15GBPS_MASK (0x00000201) -#define SCU_LINK_LAYER_PHY_CAPABILITIES_SWO30GBPS_SHIFT (10) -#define SCU_LINK_LAYER_PHY_CAPABILITIES_SWO30GBPS_MASK (0x00000401) -#define SCU_LINK_LAYER_PHY_CAPABILITIES_SW30GBPS_SHIFT (11) -#define SCU_LINK_LAYER_PHY_CAPABILITIES_SW30GBPS_MASK (0x00000801) -#define SCU_LINK_LAYER_PHY_CAPABILITIES_SWO60GBPS_SHIFT (12) -#define SCU_LINK_LAYER_PHY_CAPABILITIES_SWO60GBPS_MASK (0x00001001) -#define SCU_LINK_LAYER_PHY_CAPABILITIES_SW60GBPS_SHIFT (13) -#define SCU_LINK_LAYER_PHY_CAPABILITIES_SW60GBPS_MASK (0x00002001) -#define SCU_LINK_LAYER_PHY_CAPABILITIES_EVEN_PARITY_SHIFT (31) -#define SCU_LINK_LAYER_PHY_CAPABILITIES_EVEN_PARITY_MASK (0x80000000) -#define SCU_LINK_LAYER_PHY_CAPABILITIES_DEFAULT_MASK (0x00003F01) -#define SCU_LINK_LAYER_PHY_CAPABILITIES_REQUIRED_MASK (0x00000001) -#define SCU_LINK_LAYER_PHY_CAPABILITIES_RESERVED_MASK (0x7FFFC00D) - -#define SCU_SAS_PHYCAP_GEN_VAL(name, value) \ - SCU_GEN_VALUE(SCU_LINK_LAYER_PHY_CAPABILITIES_ ## name, value) - -#define SCU_SAS_PHYCAP_GEN_BIT(name) \ - SCU_GEN_BIT(SCU_LINK_LAYER_PHY_CAPABILITIES_ ## name) - - -#define SCU_LINK_LAYER_PHY_SOURCE_ZONE_GROUP_CONTROL_VIRTUAL_EXPANDER_PHY_ZONE_GROUP_SHIFT (0) -#define SCU_LINK_LAYER_PHY_SOURCE_ZONE_GROUP_CONTROL_VIRTUAL_EXPANDER_PHY_ZONE_GROUP_MASK (0x000000FF) -#define SCU_LINK_LAYER_PHY_SOURCE_ZONE_GROUP_CONTROL_INSIDE_SOURCE_ZONE_GROUP_SHIFT (31) -#define SCU_LINK_LAYER_PHY_SOURCE_ZONE_GROUP_CONTROL_INSIDE_SOURCE_ZONE_GROUP_MASK (0x80000000) -#define SCU_LINK_LAYER_PHY_SOURCE_ZONE_GROUP_CONTROL_RESERVED_MASK (0x7FFFFF00) - -#define SCU_PSZGCR_GEN_VAL(name, value) \ - SCU_GEN_VALUE(SCU_LINK_LAYER_PHY_SOURCE_ZONE_GROUP_CONTROL_ ## name, value) - -#define SCU_PSZGCR_GEN_BIT(name) \ - SCU_GEN_BIT(SCU_LINK_LAYER_PHY_SOURCE_ZONE_GROUP_CONTROL_ ## name) - -#define SCU_PROTOCOL_ENGINE_GROUP_VIRTUAL_ZONING_EXPANDER_CONTROL_ZONE0_LOCKED_SHIFT (1) -#define SCU_PROTOCOL_ENGINE_GROUP_VIRTUAL_ZONING_EXPANDER_CONTROL_ZONE0_LOCKED_MASK (0x00000002) -#define SCU_PROTOCOL_ENGINE_GROUP_VIRTUAL_ZONING_EXPANDER_CONTROL_ZONE0_UPDATING_SHIFT (2) -#define SCU_PROTOCOL_ENGINE_GROUP_VIRTUAL_ZONING_EXPANDER_CONTROL_ZONE0_UPDATING_MASK (0x00000004) -#define SCU_PROTOCOL_ENGINE_GROUP_VIRTUAL_ZONING_EXPANDER_CONTROL_ZONE1_LOCKED_SHIFT (4) -#define SCU_PROTOCOL_ENGINE_GROUP_VIRTUAL_ZONING_EXPANDER_CONTROL_ZONE1_LOCKED_MASK (0x00000010) -#define SCU_PROTOCOL_ENGINE_GROUP_VIRTUAL_ZONING_EXPANDER_CONTROL_ZONE1_UPDATING_SHIFT (5) -#define SCU_PROTOCOL_ENGINE_GROUP_VIRTUAL_ZONING_EXPANDER_CONTROL_ZONE1_UPDATING_MASK (0x00000020) -#define SCU_PROTOCOL_ENGINE_GROUP_VIRTUAL_ZONING_EXPANDER_CONTROL_ZPT_ASSOCIATION_PE0_SHIFT (16) -#define SCU_PROTOCOL_ENGINE_GROUP_VIRTUAL_ZONING_EXPANDER_CONTROL_ZPT_ASSOCIATION_PE0_MASK (0x00030000) -#define SCU_PROTOCOL_ENGINE_GROUP_VIRTUAL_ZONING_EXPANDER_CONTROL_AIP_ENABLE_PE0_SHIFT (19) -#define SCU_PROTOCOL_ENGINE_GROUP_VIRTUAL_ZONING_EXPANDER_CONTROL_AIP_ENABLE_PE0_MASK (0x00080000) -#define SCU_PROTOCOL_ENGINE_GROUP_VIRTUAL_ZONING_EXPANDER_CONTROL_ZPT_ASSOCIATION_PE1_SHIFT (20) -#define SCU_PROTOCOL_ENGINE_GROUP_VIRTUAL_ZONING_EXPANDER_CONTROL_ZPT_ASSOCIATION_PE1_MASK (0x00300000) -#define SCU_PROTOCOL_ENGINE_GROUP_VIRTUAL_ZONING_EXPANDER_CONTROL_AIP_ENABLE_PE1_SHIFT (23) -#define SCU_PROTOCOL_ENGINE_GROUP_VIRTUAL_ZONING_EXPANDER_CONTROL_AIP_ENABLE_PE1_MASK (0x00800000) -#define SCU_PROTOCOL_ENGINE_GROUP_VIRTUAL_ZONING_EXPANDER_CONTROL_ZPT_ASSOCIATION_PE2_SHIFT (24) -#define SCU_PROTOCOL_ENGINE_GROUP_VIRTUAL_ZONING_EXPANDER_CONTROL_ZPT_ASSOCIATION_PE2_MASK (0x03000000) -#define SCU_PROTOCOL_ENGINE_GROUP_VIRTUAL_ZONING_EXPANDER_CONTROL_AIP_ENABLE_PE2_SHIFT (27) -#define SCU_PROTOCOL_ENGINE_GROUP_VIRTUAL_ZONING_EXPANDER_CONTROL_AIP_ENABLE_PE2_MASK (0x08000000) -#define SCU_PROTOCOL_ENGINE_GROUP_VIRTUAL_ZONING_EXPANDER_CONTROL_ZPT_ASSOCIATION_PE3_SHIFT (28) -#define SCU_PROTOCOL_ENGINE_GROUP_VIRTUAL_ZONING_EXPANDER_CONTROL_ZPT_ASSOCIATION_PE3_MASK (0x30000000) -#define SCU_PROTOCOL_ENGINE_GROUP_VIRTUAL_ZONING_EXPANDER_CONTROL_AIP_ENABLE_PE3_SHIFT (31) -#define SCU_PROTOCOL_ENGINE_GROUP_VIRTUAL_ZONING_EXPANDER_CONTROL_AIP_ENABLE_PE3_MASK (0x80000000) -#define SCU_PROTOCOL_ENGINE_GROUP_VIRTUAL_ZONING_EXPANDER_CONTROL_RESERVED_MASK (0x4444FFC9) - -#define SCU_PEG_SCUVZECR_GEN_VAL(name, val) \ - SCU_GEN_VALUE(SCU_PROTOCOL_ENGINE_GROUP_VIRTUAL_ZONING_EXPANDER_CONTROL_ ## name, val) - -#define SCU_PEG_SCUVZECR_GEN_BIT(name) \ - SCU_GEN_BIT(SCU_PROTOCOL_ENGINE_GROUP_VIRTUAL_ZONING_EXPANDER_CONTROL_ ## name) - - -/* - * ***************************************************************************** - * * Port Task Scheduler registers shift and mask values - * ***************************************************************************** */ -#define SCU_PTSG_CONTROL_IT_NEXUS_TIMEOUT_SHIFT (0) -#define SCU_PTSG_CONTROL_IT_NEXUS_TIMEOUT_MASK (0x0000FFFF) -#define SCU_PTSG_CONTROL_TASK_TIMEOUT_SHIFT (16) -#define SCU_PTSG_CONTROL_TASK_TIMEOUT_MASK (0x00FF0000) -#define SCU_PTSG_CONTROL_PTSG_ENABLE_SHIFT (24) -#define SCU_PTSG_CONTROL_PTSG_ENABLE_MASK (0x01000000) -#define SCU_PTSG_CONTROL_ETM_ENABLE_SHIFT (25) -#define SCU_PTSG_CONTROL_ETM_ENABLE_MASK (0x02000000) -#define SCU_PTSG_CONTROL_DEFAULT_MASK (0x00020002) -#define SCU_PTSG_CONTROL_REQUIRED_MASK (0x00000000) -#define SCU_PTSG_CONTROL_RESERVED_MASK (0xFC000000) - -#define SCU_PTSGCR_GEN_VAL(name, val) \ - SCU_GEN_VALUE(SCU_PTSG_CONTROL_ ## name, val) - -#define SCU_PTSGCR_GEN_BIT(name) \ - SCU_GEN_BIT(SCU_PTSG_CONTROL_ ## name) - - -/* ***************************************************************************** */ -#define SCU_PTSG_REAL_TIME_CLOCK_SHIFT (0) -#define SCU_PTSG_REAL_TIME_CLOCK_MASK (0x0000FFFF) -#define SCU_PTSG_REAL_TIME_CLOCK_RESERVED_MASK (0xFFFF0000) - -#define SCU_RTCR_GEN_VAL(name, val) \ - SCU_GEN_VALUE(SCU_PTSG_ ## name, val) - - -#define SCU_PTSG_REAL_TIME_CLOCK_CONTROL_PRESCALER_VALUE_SHIFT (0) -#define SCU_PTSG_REAL_TIME_CLOCK_CONTROL_PRESCALER_VALUE_MASK (0x00FFFFFF) -#define SCU_PTSG_REAL_TIME_CLOCK_CONTROL_RESERVED_MASK (0xFF000000) - -#define SCU_RTCCR_GEN_VAL(name, val) \ - SCU_GEN_VALUE(SCU_PTSG_REAL_TIME_CLOCK_CONTROL_ ## name, val) - - -#define SCU_PTSG_PORT_TASK_SCHEDULER_CONTROL_SUSPEND_SHIFT (0) -#define SCU_PTSG_PORT_TASK_SCHEDULER_CONTROL_SUSPEND_MASK (0x00000001) -#define SCU_PTSG_PORT_TASK_SCHEDULER_CONTROL_ENABLE_SHIFT (1) -#define SCU_PTSG_PORT_TASK_SCHEDULER_CONTROL_ENABLE_MASK (0x00000002) -#define SCU_PTSG_PORT_TASK_SCHEDULER_CONTROL_RESERVED_MASK (0xFFFFFFFC) - -#define SCU_PTSxCR_GEN_BIT(name) \ - SCU_GEN_BIT(SCU_PTSG_PORT_TASK_SCHEDULER_CONTROL_ ## name) - - -#define SCU_PTSG_PORT_TASK_SCHEDULER_STATUS_NEXT_RN_VALID_SHIFT (0) -#define SCU_PTSG_PORT_TASK_SCHEDULER_STATUS_NEXT_RN_VALID_MASK (0x00000001) -#define SCU_PTSG_PORT_TASK_SCHEDULER_STATUS_ACTIVE_RNSC_LIST_VALID_SHIFT (1) -#define SCU_PTSG_PORT_TASK_SCHEDULER_STATUS_ACTIVE_RNSC_LIST_VALID_MASK (0x00000002) -#define SCU_PTSG_PORT_TASK_SCHEDULER_STATUS_PTS_SUSPENDED_SHIFT (2) -#define SCU_PTSG_PORT_TASK_SCHEDULER_STATUS_PTS_SUSPENDED_MASK (0x00000004) -#define SCU_PTSG_PORT_TASK_SCHEDULER_STATUS_RESERVED_MASK (0xFFFFFFF8) - -#define SCU_PTSxSR_GEN_BIT(name) \ - SCU_GEN_BIT(SCU_PTSG_PORT_TASK_SCHEDULER_STATUS_ ## name) - - -/* - * ***************************************************************************** - * * SGPIO Register shift and mask values - * ***************************************************************************** */ -#define SCU_SGPIO_CONTROL_SGPIO_ENABLE_SHIFT (0) -#define SCU_SGPIO_CONTROL_SGPIO_ENABLE_MASK (0x00000001) -#define SCU_SGPIO_CONTROL_SGPIO_SERIAL_CLOCK_SELECT_SHIFT (1) -#define SCU_SGPIO_CONTROL_SGPIO_SERIAL_CLOCK_SELECT_MASK (0x00000002) -#define SCU_SGPIO_CONTROL_SGPIO_SERIAL_SHIFT_WIDTH_SELECT_SHIFT (2) -#define SCU_SGPIO_CONTROL_SGPIO_SERIAL_SHIFT_WIDTH_SELECT_MASK (0x00000004) -#define SCU_SGPIO_CONTROL_SGPIO_TEST_BIT_SHIFT (15) -#define SCU_SGPIO_CONTROL_SGPIO_TEST_BIT_MASK (0x00008000) -#define SCU_SGPIO_CONTROL_SGPIO_RESERVED_MASK (0xFFFF7FF8) - -#define SCU_SGICRx_GEN_BIT(name) \ - SCU_GEN_BIT(SCU_SGPIO_CONTROL_SGPIO_ ## name) - -#define SCU_SGPIO_PROGRAMMABLE_BLINK_REGISTER_R0_SHIFT (0) -#define SCU_SGPIO_PROGRAMMABLE_BLINK_REGISTER_R0_MASK (0x0000000F) -#define SCU_SGPIO_PROGRAMMABLE_BLINK_REGISTER_R1_SHIFT (4) -#define SCU_SGPIO_PROGRAMMABLE_BLINK_REGISTER_R1_MASK (0x000000F0) -#define SCU_SGPIO_PROGRAMMABLE_BLINK_REGISTER_R2_SHIFT (8) -#define SCU_SGPIO_PROGRAMMABLE_BLINK_REGISTER_R2_MASK (0x00000F00) -#define SCU_SGPIO_PROGRAMMABLE_BLINK_REGISTER_R3_SHIFT (12) -#define SCU_SGPIO_PROGRAMMABLE_BLINK_REGISTER_R3_MASK (0x0000F000) -#define SCU_SGPIO_PROGRAMMABLE_BLINK_REGISTER_RESERVED_MASK (0xFFFF0000) - -#define SCU_SGPBRx_GEN_VAL(name, value) \ - SCU_GEN_VALUE(SCU_SGPIO_PROGRAMMABLE_BLINK_REGISTER_ ## name, value) - -#define SCU_SGPIO_START_DRIVE_LOWER_R0_SHIFT (0) -#define SCU_SGPIO_START_DRIVE_LOWER_R0_MASK (0x00000003) -#define SCU_SGPIO_START_DRIVE_LOWER_R1_SHIFT (4) -#define SCU_SGPIO_START_DRIVE_LOWER_R1_MASK (0x00000030) -#define SCU_SGPIO_START_DRIVE_LOWER_R2_SHIFT (8) -#define SCU_SGPIO_START_DRIVE_LOWER_R2_MASK (0x00000300) -#define SCU_SGPIO_START_DRIVE_LOWER_R3_SHIFT (12) -#define SCU_SGPIO_START_DRIVE_LOWER_R3_MASK (0x00003000) -#define SCU_SGPIO_START_DRIVE_LOWER_RESERVED_MASK (0xFFFF8888) - -#define SCU_SGSDLRx_GEN_VAL(name, value) \ - SCU_GEN_VALUE(SCU_SGPIO_START_DRIVE_LOWER_ ## name, value) - -#define SCU_SGPIO_START_DRIVE_UPPER_R0_SHIFT (0) -#define SCU_SGPIO_START_DRIVE_UPPER_R0_MASK (0x00000003) -#define SCU_SGPIO_START_DRIVE_UPPER_R1_SHIFT (4) -#define SCU_SGPIO_START_DRIVE_UPPER_R1_MASK (0x00000030) -#define SCU_SGPIO_START_DRIVE_UPPER_R2_SHIFT (8) -#define SCU_SGPIO_START_DRIVE_UPPER_R2_MASK (0x00000300) -#define SCU_SGPIO_START_DRIVE_UPPER_R3_SHIFT (12) -#define SCU_SGPIO_START_DRIVE_UPPER_R3_MASK (0x00003000) -#define SCU_SGPIO_START_DRIVE_UPPER_RESERVED_MASK (0xFFFF8888) - -#define SCU_SGSDURx_GEN_VAL(name, value) \ - SCU_GEN_VALUE(SCU_SGPIO_START_DRIVE_LOWER_ ## name, value) - -#define SCU_SGPIO_SERIAL_INPUT_DATA_LOWER_D0_SHIFT (0) -#define SCU_SGPIO_SERIAL_INPUT_DATA_LOWER_D0_MASK (0x00000003) -#define SCU_SGPIO_SERIAL_INPUT_DATA_LOWER_D1_SHIFT (4) -#define SCU_SGPIO_SERIAL_INPUT_DATA_LOWER_D1_MASK (0x00000030) -#define SCU_SGPIO_SERIAL_INPUT_DATA_LOWER_D2_SHIFT (8) -#define SCU_SGPIO_SERIAL_INPUT_DATA_LOWER_D2_MASK (0x00000300) -#define SCU_SGPIO_SERIAL_INPUT_DATA_LOWER_D3_SHIFT (12) -#define SCU_SGPIO_SERIAL_INPUT_DATA_LOWER_D3_MASK (0x00003000) -#define SCU_SGPIO_SERIAL_INPUT_DATA_LOWER_RESERVED_MASK (0xFFFF8888) - -#define SCU_SGSIDLRx_GEN_VAL(name, value) \ - SCU_GEN_VALUE(SCU_SGPIO_SERIAL_INPUT_DATA_LOWER_ ## name, value) - -#define SCU_SGPIO_SERIAL_INPUT_DATA_UPPER_D0_SHIFT (0) -#define SCU_SGPIO_SERIAL_INPUT_DATA_UPPER_D0_MASK (0x00000003) -#define SCU_SGPIO_SERIAL_INPUT_DATA_UPPER_D1_SHIFT (4) -#define SCU_SGPIO_SERIAL_INPUT_DATA_UPPER_D1_MASK (0x00000030) -#define SCU_SGPIO_SERIAL_INPUT_DATA_UPPER_D2_SHIFT (8) -#define SCU_SGPIO_SERIAL_INPUT_DATA_UPPER_D2_MASK (0x00000300) -#define SCU_SGPIO_SERIAL_INPUT_DATA_UPPER_D3_SHIFT (12) -#define SCU_SGPIO_SERIAL_INPUT_DATA_UPPER_D3_MASK (0x00003000) -#define SCU_SGPIO_SERIAL_INPUT_DATA_UPPER_RESERVED_MASK (0xFFFF8888) - -#define SCU_SGSIDURx_GEN_VAL(name, value) \ - SCU_GEN_VALUE(SCU_SGPIO_SERIAL_INPUT_DATA_LOWER_ ## name, value) - -#define SCU_SGPIO_VENDOR_SPECIFIC_CODE_SHIFT (0) -#define SCU_SGPIO_VENDOR_SPECIFIC_CODE_MASK (0x0000000F) -#define SCU_SGPIO_VENDOR_SPECIFIC_CODE_RESERVED_MASK (0xFFFFFFF0) - -#define SCU_SGVSCR_GEN_VAL(value) \ - SCU_GEN_VALUE(SCU_SGPIO_VENDOR_SPECIFIC_CODE ## name, value) - -#define SCU_SGPIO_OUPUT_DATA_SELECT_INPUT_DATA0_SHIFT (0) -#define SCU_SGPIO_OUPUT_DATA_SELECT_INPUT_DATA0_MASK (0x00000003) -#define SCU_SGPIO_OUPUT_DATA_SELECT_INVERT_INPUT_DATA0_SHIFT (2) -#define SCU_SGPIO_OUPUT_DATA_SELECT_INVERT_INPUT_DATA0_MASK (0x00000004) -#define SCU_SGPIO_OUPUT_DATA_SELECT_JOG_ENABLE_DATA0_SHIFT (3) -#define SCU_SGPIO_OUPUT_DATA_SELECT_JOG_ENABLE_DATA0_MASK (0x00000008) -#define SCU_SGPIO_OUPUT_DATA_SELECT_INPUT_DATA1_SHIFT (4) -#define SCU_SGPIO_OUPUT_DATA_SELECT_INPUT_DATA1_MASK (0x00000030) -#define SCU_SGPIO_OUPUT_DATA_SELECT_INVERT_INPUT_DATA1_SHIFT (6) -#define SCU_SGPIO_OUPUT_DATA_SELECT_INVERT_INPUT_DATA1_MASK (0x00000040) -#define SCU_SGPIO_OUPUT_DATA_SELECT_JOG_ENABLE_DATA1_SHIFT (7) -#define SCU_SGPIO_OUPUT_DATA_SELECT_JOG_ENABLE_DATA1_MASK (0x00000080) -#define SCU_SGPIO_OUPUT_DATA_SELECT_INPUT_DATA2_SHIFT (8) -#define SCU_SGPIO_OUPUT_DATA_SELECT_INPUT_DATA2_MASK (0x00000300) -#define SCU_SGPIO_OUPUT_DATA_SELECT_INVERT_INPUT_DATA2_SHIFT (10) -#define SCU_SGPIO_OUPUT_DATA_SELECT_INVERT_INPUT_DATA2_MASK (0x00000400) -#define SCU_SGPIO_OUPUT_DATA_SELECT_JOG_ENABLE_DATA2_SHIFT (11) -#define SCU_SGPIO_OUPUT_DATA_SELECT_JOG_ENABLE_DATA2_MASK (0x00000800) -#define SCU_SGPIO_OUPUT_DATA_SELECT_RESERVED_MASK (0xFFFFF000) - -#define SCU_SGODSR_GEN_VAL(name, value) \ - SCU_GEN_VALUE(SCU_SGPIO_OUPUT_DATA_SELECT_ ## name, value) - -#define SCU_SGODSR_GEN_BIT(name) \ - SCU_GEN_BIT(SCU_SGPIO_OUPUT_DATA_SELECT_ ## name) - -/* - * ***************************************************************************** - * * SMU Registers - * ***************************************************************************** */ - -/* - * ---------------------------------------------------------------------------- - * SMU Registers - * These registers are based off of BAR0 - * - * To calculate the offset for other functions use - * BAR0 + FN# * SystemPageSize * 2 - * - * The TCA is only accessable from FN#0 (Physical Function) and each - * is programmed by (BAR0 + SCU_SMU_TCA_OFFSET + (FN# * 0x04)) or - * TCA0 for FN#0 is at BAR0 + 0x0400 - * TCA1 for FN#1 is at BAR0 + 0x0404 - * etc. - * ---------------------------------------------------------------------------- - * Accessable to all FN#s */ -#define SCU_SMU_PCP_OFFSET 0x0000 -#define SCU_SMU_AMR_OFFSET 0x0004 -#define SCU_SMU_ISR_OFFSET 0x0010 -#define SCU_SMU_IMR_OFFSET 0x0014 -#define SCU_SMU_ICC_OFFSET 0x0018 -#define SCU_SMU_HTTLBAR_OFFSET 0x0020 -#define SCU_SMU_HTTUBAR_OFFSET 0x0024 -#define SCU_SMU_TCR_OFFSET 0x0028 -#define SCU_SMU_CQLBAR_OFFSET 0x0030 -#define SCU_SMU_CQUBAR_OFFSET 0x0034 -#define SCU_SMU_CQPR_OFFSET 0x0040 -#define SCU_SMU_CQGR_OFFSET 0x0044 -#define SCU_SMU_CQC_OFFSET 0x0048 -/* Accessable to FN#0 only */ -#define SCU_SMU_RNCLBAR_OFFSET 0x0080 -#define SCU_SMU_RNCUBAR_OFFSET 0x0084 -#define SCU_SMU_DCC_OFFSET 0x0090 -#define SCU_SMU_DFC_OFFSET 0x0094 -#define SCU_SMU_SMUCSR_OFFSET 0x0098 -#define SCU_SMU_SCUSRCR_OFFSET 0x009C -#define SCU_SMU_SMAW_OFFSET 0x00A0 -#define SCU_SMU_SMDW_OFFSET 0x00A4 -/* Accessable to FN#0 only */ -#define SCU_SMU_TCA_OFFSET 0x0400 -/* Accessable to all FN#s */ -#define SCU_SMU_MT_MLAR0_OFFSET 0x2000 -#define SCU_SMU_MT_MUAR0_OFFSET 0x2004 -#define SCU_SMU_MT_MDR0_OFFSET 0x2008 -#define SCU_SMU_MT_VCR0_OFFSET 0x200C -#define SCU_SMU_MT_MLAR1_OFFSET 0x2010 -#define SCU_SMU_MT_MUAR1_OFFSET 0x2014 -#define SCU_SMU_MT_MDR1_OFFSET 0x2018 -#define SCU_SMU_MT_VCR1_OFFSET 0x201C -#define SCU_SMU_MPBA_OFFSET 0x3000 - -/** - * struct smu_registers - These are the SMU registers - * - * - */ -struct smu_registers { -/* 0x0000 PCP */ - u32 post_context_port; -/* 0x0004 AMR */ - u32 address_modifier; - u32 reserved_08; - u32 reserved_0C; -/* 0x0010 ISR */ - u32 interrupt_status; -/* 0x0014 IMR */ - u32 interrupt_mask; -/* 0x0018 ICC */ - u32 interrupt_coalesce_control; - u32 reserved_1C; -/* 0x0020 HTTLBAR */ - u32 host_task_table_lower; -/* 0x0024 HTTUBAR */ - u32 host_task_table_upper; -/* 0x0028 TCR */ - u32 task_context_range; - u32 reserved_2C; -/* 0x0030 CQLBAR */ - u32 completion_queue_lower; -/* 0x0034 CQUBAR */ - u32 completion_queue_upper; - u32 reserved_38; - u32 reserved_3C; -/* 0x0040 CQPR */ - u32 completion_queue_put; -/* 0x0044 CQGR */ - u32 completion_queue_get; -/* 0x0048 CQC */ - u32 completion_queue_control; - u32 reserved_4C; - u32 reserved_5x[4]; - u32 reserved_6x[4]; - u32 reserved_7x[4]; -/* - * Accessable to FN#0 only - * 0x0080 RNCLBAR */ - u32 remote_node_context_lower; -/* 0x0084 RNCUBAR */ - u32 remote_node_context_upper; - u32 reserved_88; - u32 reserved_8C; -/* 0x0090 DCC */ - u32 device_context_capacity; -/* 0x0094 DFC */ - u32 device_function_capacity; -/* 0x0098 SMUCSR */ - u32 control_status; -/* 0x009C SCUSRCR */ - u32 soft_reset_control; -/* 0x00A0 SMAW */ - u32 mmr_address_window; -/* 0x00A4 SMDW */ - u32 mmr_data_window; - u32 reserved_A8; - u32 reserved_AC; -/* A whole bunch of reserved space */ - u32 reserved_Bx[4]; - u32 reserved_Cx[4]; - u32 reserved_Dx[4]; - u32 reserved_Ex[4]; - u32 reserved_Fx[4]; - u32 reserved_1xx[64]; - u32 reserved_2xx[64]; - u32 reserved_3xx[64]; -/* - * Accessable to FN#0 only - * 0x0400 TCA */ - u32 task_context_assignment[256]; -/* MSI-X registers not included */ -}; - -/* - * ***************************************************************************** - * SDMA Registers - * ***************************************************************************** */ -#define SCU_SDMA_BASE 0x6000 -#define SCU_SDMA_PUFATLHAR_OFFSET 0x0000 -#define SCU_SDMA_PUFATUHAR_OFFSET 0x0004 -#define SCU_SDMA_UFLHBAR_OFFSET 0x0008 -#define SCU_SDMA_UFUHBAR_OFFSET 0x000C -#define SCU_SDMA_UFQC_OFFSET 0x0010 -#define SCU_SDMA_UFQPP_OFFSET 0x0014 -#define SCU_SDMA_UFQGP_OFFSET 0x0018 -#define SCU_SDMA_PDMACR_OFFSET 0x001C -#define SCU_SDMA_CDMACR_OFFSET 0x0080 - -/** - * struct scu_sdma_registers - These are the SCU SDMA Registers - * - * - */ -struct scu_sdma_registers { -/* 0x0000 PUFATLHAR */ - u32 uf_address_table_lower; -/* 0x0004 PUFATUHAR */ - u32 uf_address_table_upper; -/* 0x0008 UFLHBAR */ - u32 uf_header_base_address_lower; -/* 0x000C UFUHBAR */ - u32 uf_header_base_address_upper; -/* 0x0010 UFQC */ - u32 unsolicited_frame_queue_control; -/* 0x0014 UFQPP */ - u32 unsolicited_frame_put_pointer; -/* 0x0018 UFQGP */ - u32 unsolicited_frame_get_pointer; -/* 0x001C PDMACR */ - u32 pdma_configuration; -/* Reserved until offset 0x80 */ - u32 reserved_0020_007C[0x18]; -/* 0x0080 CDMACR */ - u32 cdma_configuration; -/* Remainder SDMA register space */ - u32 reserved_0084_0400[0xDF]; - -}; - -/* - * ***************************************************************************** - * * SCU Link Registers - * ***************************************************************************** */ -#define SCU_PEG0_OFFSET 0x0000 -#define SCU_PEG1_OFFSET 0x8000 - -#define SCU_TL0_OFFSET 0x0000 -#define SCU_TL1_OFFSET 0x0400 -#define SCU_TL2_OFFSET 0x0800 -#define SCU_TL3_OFFSET 0x0C00 - -#define SCU_LL_OFFSET 0x0080 -#define SCU_LL0_OFFSET (SCU_TL0_OFFSET + SCU_LL_OFFSET) -#define SCU_LL1_OFFSET (SCU_TL1_OFFSET + SCU_LL_OFFSET) -#define SCU_LL2_OFFSET (SCU_TL2_OFFSET + SCU_LL_OFFSET) -#define SCU_LL3_OFFSET (SCU_TL3_OFFSET + SCU_LL_OFFSET) - -/* Transport Layer Offsets (PEG + TL) */ -#define SCU_TLCR_OFFSET 0x0000 -#define SCU_TLADTR_OFFSET 0x0004 -#define SCU_TLTTMR_OFFSET 0x0008 -#define SCU_TLEECR0_OFFSET 0x000C -#define SCU_STPTLDARNI_OFFSET 0x0010 - - -#define SCU_TLCR_HASH_SAS_CHECKING_ENABLE_SHIFT (0) -#define SCU_TLCR_HASH_SAS_CHECKING_ENABLE_MASK (0x00000001) -#define SCU_TLCR_CLEAR_TCI_NCQ_MAPPING_TABLE_SHIFT (1) -#define SCU_TLCR_CLEAR_TCI_NCQ_MAPPING_TABLE_MASK (0x00000002) -#define SCU_TLCR_STP_WRITE_DATA_PREFETCH_SHIFT (3) -#define SCU_TLCR_STP_WRITE_DATA_PREFETCH_MASK (0x00000008) -#define SCU_TLCR_CMD_NAK_STATUS_CODE_SHIFT (4) -#define SCU_TLCR_CMD_NAK_STATUS_CODE_MASK (0x00000010) -#define SCU_TLCR_RESERVED_MASK (0xFFFFFFEB) - -#define SCU_TLCR_GEN_BIT(name) \ - SCU_GEN_BIT(SCU_TLCR_ ## name) - -/** - * struct scu_transport_layer_registers - These are the SCU Transport Layer - * registers - * - * - */ -struct scu_transport_layer_registers { - /* 0x0000 TLCR */ - u32 control; - /* 0x0004 TLADTR */ - u32 arbitration_delay_timer; - /* 0x0008 TLTTMR */ - u32 timer_test_mode; - /* 0x000C reserved */ - u32 reserved_0C; - /* 0x0010 STPTLDARNI */ - u32 stp_rni; - /* 0x0014 TLFEWPORCTRL */ - u32 tlfe_wpo_read_control; - /* 0x0018 TLFEWPORDATA */ - u32 tlfe_wpo_read_data; - /* 0x001C RXTLSSCSR1 */ - u32 rxtl_single_step_control_status_1; - /* 0x0020 RXTLSSCSR2 */ - u32 rxtl_single_step_control_status_2; - /* 0x0024 AWTRDDCR */ - u32 tlfe_awt_retry_delay_debug_control; - /* Remainder of TL memory space */ - u32 reserved_0028_007F[0x16]; - -}; - -/* Protocol Engine Group Registers */ -#define SCU_SCUVZECRx_OFFSET 0x1080 - -/* Link Layer Offsets (PEG + TL + LL) */ -#define SCU_SAS_SPDTOV_OFFSET 0x0000 -#define SCU_SAS_LLSTA_OFFSET 0x0004 -#define SCU_SATA_PSELTOV_OFFSET 0x0008 -#define SCU_SAS_TIMETOV_OFFSET 0x0010 -#define SCU_SAS_LOSTOT_OFFSET 0x0014 -#define SCU_SAS_LNKTOV_OFFSET 0x0018 -#define SCU_SAS_PHYTOV_OFFSET 0x001C -#define SCU_SAS_AFERCNT_OFFSET 0x0020 -#define SCU_SAS_WERCNT_OFFSET 0x0024 -#define SCU_SAS_TIID_OFFSET 0x0028 -#define SCU_SAS_TIDNH_OFFSET 0x002C -#define SCU_SAS_TIDNL_OFFSET 0x0030 -#define SCU_SAS_TISSAH_OFFSET 0x0034 -#define SCU_SAS_TISSAL_OFFSET 0x0038 -#define SCU_SAS_TIPID_OFFSET 0x003C -#define SCU_SAS_TIRES2_OFFSET 0x0040 -#define SCU_SAS_ADRSTA_OFFSET 0x0044 -#define SCU_SAS_MAWTTOV_OFFSET 0x0048 -#define SCU_SAS_FRPLDFIL_OFFSET 0x0054 -#define SCU_SAS_RFCNT_OFFSET 0x0060 -#define SCU_SAS_TFCNT_OFFSET 0x0064 -#define SCU_SAS_RFDCNT_OFFSET 0x0068 -#define SCU_SAS_TFDCNT_OFFSET 0x006C -#define SCU_SAS_LERCNT_OFFSET 0x0070 -#define SCU_SAS_RDISERRCNT_OFFSET 0x0074 -#define SCU_SAS_CRERCNT_OFFSET 0x0078 -#define SCU_STPCTL_OFFSET 0x007C -#define SCU_SAS_PCFG_OFFSET 0x0080 -#define SCU_SAS_CLKSM_OFFSET 0x0084 -#define SCU_SAS_TXCOMWAKE_OFFSET 0x0088 -#define SCU_SAS_TXCOMINIT_OFFSET 0x008C -#define SCU_SAS_TXCOMSAS_OFFSET 0x0090 -#define SCU_SAS_COMINIT_OFFSET 0x0094 -#define SCU_SAS_COMWAKE_OFFSET 0x0098 -#define SCU_SAS_COMSAS_OFFSET 0x009C -#define SCU_SAS_SFERCNT_OFFSET 0x00A0 -#define SCU_SAS_CDFERCNT_OFFSET 0x00A4 -#define SCU_SAS_DNFERCNT_OFFSET 0x00A8 -#define SCU_SAS_PRSTERCNT_OFFSET 0x00AC -#define SCU_SAS_CNTCTL_OFFSET 0x00B0 -#define SCU_SAS_SSPTOV_OFFSET 0x00B4 -#define SCU_FTCTL_OFFSET 0x00B8 -#define SCU_FRCTL_OFFSET 0x00BC -#define SCU_FTWMRK_OFFSET 0x00C0 -#define SCU_ENSPINUP_OFFSET 0x00C4 -#define SCU_SAS_TRNTOV_OFFSET 0x00C8 -#define SCU_SAS_PHYCAP_OFFSET 0x00CC -#define SCU_SAS_PHYCTL_OFFSET 0x00D0 -#define SCU_SAS_LLCTL_OFFSET 0x00D8 -#define SCU_AFE_XCVRCR_OFFSET 0x00DC -#define SCU_AFE_LUTCR_OFFSET 0x00E0 - -#define SCU_SAS_LINK_LAYER_CONTROL_MAX_LINK_RATE_SHIFT (0) -#define SCU_SAS_LINK_LAYER_CONTROL_MAX_LINK_RATE_MASK (0x00000003) -#define SCU_SAS_LINK_LAYER_CONTROL_MAX_LINK_RATE_GEN1 (0) -#define SCU_SAS_LINK_LAYER_CONTROL_MAX_LINK_RATE_GEN2 (1) -#define SCU_SAS_LINK_LAYER_CONTROL_MAX_LINK_RATE_GEN3 (2) -#define SCU_SAS_LINK_LAYER_CONTROL_BROADCAST_PRIMITIVE_SHIFT (2) -#define SCU_SAS_LINK_LAYER_CONTROL_BROADCAST_PRIMITIVE_MASK (0x000003FC) -#define SCU_SAS_LINK_LAYER_CONTROL_CLOSE_NO_ACTIVE_TASK_DISABLE_SHIFT (16) -#define SCU_SAS_LINK_LAYER_CONTROL_CLOSE_NO_ACTIVE_TASK_DISABLE_MASK (0x00010000) -#define SCU_SAS_LINK_LAYER_CONTROL_CLOSE_NO_OUTBOUND_TASK_DISABLE_SHIFT (17) -#define SCU_SAS_LINK_LAYER_CONTROL_CLOSE_NO_OUTBOUND_TASK_DISABLE_MASK (0x00020000) -#define SCU_SAS_LINK_LAYER_CONTROL_NO_OUTBOUND_TASK_TIMEOUT_SHIFT (24) -#define SCU_SAS_LINK_LAYER_CONTROL_NO_OUTBOUND_TASK_TIMEOUT_MASK (0xFF000000) -#define SCU_SAS_LINK_LAYER_CONTROL_RESERVED (0x00FCFC00) - -#define SCU_SAS_LLCTL_GEN_VAL(name, value) \ - SCU_GEN_VALUE(SCU_SAS_LINK_LAYER_CONTROL_ ## name, value) - -#define SCU_SAS_LLCTL_GEN_BIT(name) \ - SCU_GEN_BIT(SCU_SAS_LINK_LAYER_CONTROL_ ## name) - - -/* #define SCU_FRXHECR_DCNT_OFFSET 0x00B0 */ -#define SCU_PSZGCR_OFFSET 0x00E4 -#define SCU_SAS_RECPHYCAP_OFFSET 0x00E8 -/* #define SCU_TX_LUTSEL_OFFSET 0x00B8 */ - -#define SCU_SAS_PTxC_OFFSET 0x00D4 /* Same offset as SAS_TCTSTM */ - -/** - * struct scu_link_layer_registers - SCU Link Layer Registers - * - * - */ -struct scu_link_layer_registers { -/* 0x0000 SAS_SPDTOV */ - u32 speed_negotiation_timers; -/* 0x0004 SAS_LLSTA */ - u32 link_layer_status; -/* 0x0008 SATA_PSELTOV */ - u32 port_selector_timeout; - u32 reserved0C; -/* 0x0010 SAS_TIMETOV */ - u32 timeout_unit_value; -/* 0x0014 SAS_RCDTOV */ - u32 rcd_timeout; -/* 0x0018 SAS_LNKTOV */ - u32 link_timer_timeouts; -/* 0x001C SAS_PHYTOV */ - u32 sas_phy_timeouts; -/* 0x0020 SAS_AFERCNT */ - u32 received_address_frame_error_counter; -/* 0x0024 SAS_WERCNT */ - u32 invalid_dword_counter; -/* 0x0028 SAS_TIID */ - u32 transmit_identification; -/* 0x002C SAS_TIDNH */ - u32 sas_device_name_high; -/* 0x0030 SAS_TIDNL */ - u32 sas_device_name_low; -/* 0x0034 SAS_TISSAH */ - u32 source_sas_address_high; -/* 0x0038 SAS_TISSAL */ - u32 source_sas_address_low; -/* 0x003C SAS_TIPID */ - u32 identify_frame_phy_id; -/* 0x0040 SAS_TIRES2 */ - u32 identify_frame_reserved; -/* 0x0044 SAS_ADRSTA */ - u32 received_address_frame; -/* 0x0048 SAS_MAWTTOV */ - u32 maximum_arbitration_wait_timer_timeout; -/* 0x004C SAS_PTxC */ - u32 transmit_primitive; -/* 0x0050 SAS_RORES */ - u32 error_counter_event_notification_control; -/* 0x0054 SAS_FRPLDFIL */ - u32 frxq_payload_fill_threshold; -/* 0x0058 SAS_LLHANG_TOT */ - u32 link_layer_hang_detection_timeout; - u32 reserved_5C; -/* 0x0060 SAS_RFCNT */ - u32 received_frame_count; -/* 0x0064 SAS_TFCNT */ - u32 transmit_frame_count; -/* 0x0068 SAS_RFDCNT */ - u32 received_dword_count; -/* 0x006C SAS_TFDCNT */ - u32 transmit_dword_count; -/* 0x0070 SAS_LERCNT */ - u32 loss_of_sync_error_count; -/* 0x0074 SAS_RDISERRCNT */ - u32 running_disparity_error_count; -/* 0x0078 SAS_CRERCNT */ - u32 received_frame_crc_error_count; -/* 0x007C STPCTL */ - u32 stp_control; -/* 0x0080 SAS_PCFG */ - u32 phy_configuration; -/* 0x0084 SAS_CLKSM */ - u32 clock_skew_management; -/* 0x0088 SAS_TXCOMWAKE */ - u32 transmit_comwake_signal; -/* 0x008C SAS_TXCOMINIT */ - u32 transmit_cominit_signal; -/* 0x0090 SAS_TXCOMSAS */ - u32 transmit_comsas_signal; -/* 0x0094 SAS_COMINIT */ - u32 cominit_control; -/* 0x0098 SAS_COMWAKE */ - u32 comwake_control; -/* 0x009C SAS_COMSAS */ - u32 comsas_control; -/* 0x00A0 SAS_SFERCNT */ - u32 received_short_frame_count; -/* 0x00A4 SAS_CDFERCNT */ - u32 received_frame_without_credit_count; -/* 0x00A8 SAS_DNFERCNT */ - u32 received_frame_after_done_count; -/* 0x00AC SAS_PRSTERCNT */ - u32 phy_reset_problem_count; -/* 0x00B0 SAS_CNTCTL */ - u32 counter_control; -/* 0x00B4 SAS_SSPTOV */ - u32 ssp_timer_timeout_values; -/* 0x00B8 FTCTL */ - u32 ftx_control; -/* 0x00BC FRCTL */ - u32 frx_control; -/* 0x00C0 FTWMRK */ - u32 ftx_watermark; -/* 0x00C4 ENSPINUP */ - u32 notify_enable_spinup_control; -/* 0x00C8 SAS_TRNTOV */ - u32 sas_training_sequence_timer_values; -/* 0x00CC SAS_PHYCAP */ - u32 phy_capabilities; -/* 0x00D0 SAS_PHYCTL */ - u32 phy_control; - u32 reserved_d4; -/* 0x00D8 LLCTL */ - u32 link_layer_control; -/* 0x00DC AFE_XCVRCR */ - u32 afe_xcvr_control; -/* 0x00E0 AFE_LUTCR */ - u32 afe_lookup_table_control; -/* 0x00E4 PSZGCR */ - u32 phy_source_zone_group_control; -/* 0x00E8 SAS_RECPHYCAP */ - u32 receive_phycap; - u32 reserved_ec; -/* 0x00F0 SNAFERXRSTCTL */ - u32 speed_negotiation_afe_rx_reset_control; -/* 0x00F4 SAS_SSIPMCTL */ - u32 power_management_control; -/* 0x00F8 SAS_PSPREQ_PRIM */ - u32 sas_pm_partial_request_primitive; -/* 0x00FC SAS_PSSREQ_PRIM */ - u32 sas_pm_slumber_request_primitive; -/* 0x0100 SAS_PPSACK_PRIM */ - u32 sas_pm_ack_primitive_register; -/* 0x0104 SAS_PSNAK_PRIM */ - u32 sas_pm_nak_primitive_register; -/* 0x0108 SAS_SSIPMTOV */ - u32 sas_primitive_timeout; - u32 reserved_10c; -/* 0x0110 - 0x011C PLAPRDCTRLxREG */ - u32 pla_product_control[4]; -/* 0x0120 PLAPRDSUMREG */ - u32 pla_product_sum; -/* 0x0124 PLACONTROLREG */ - u32 pla_control; -/* Remainder of memory space 896 bytes */ - u32 reserved_0128_037f[0x96]; - -}; - -/* - * 0x00D4 // Same offset as SAS_TCTSTM SAS_PTxC - * u32 primitive_transmit_control; */ - -/* - * ---------------------------------------------------------------------------- - * SGPIO - * ---------------------------------------------------------------------------- */ -#define SCU_SGPIO_OFFSET 0x1400 - -/* #define SCU_SGPIO_OFFSET 0x6000 // later moves to 0x1400 see HSD 652625 */ -#define SCU_SGPIO_SGICR_OFFSET 0x0000 -#define SCU_SGPIO_SGPBR_OFFSET 0x0004 -#define SCU_SGPIO_SGSDLR_OFFSET 0x0008 -#define SCU_SGPIO_SGSDUR_OFFSET 0x000C -#define SCU_SGPIO_SGSIDLR_OFFSET 0x0010 -#define SCU_SGPIO_SGSIDUR_OFFSET 0x0014 -#define SCU_SGPIO_SGVSCR_OFFSET 0x0018 -/* Address from 0x0820 to 0x083C */ -#define SCU_SGPIO_SGODSR_OFFSET 0x0020 - -/** - * struct scu_sgpio_registers - SCU SGPIO Registers - * - * - */ -struct scu_sgpio_registers { -/* 0x0000 SGPIO_SGICR */ - u32 interface_control; -/* 0x0004 SGPIO_SGPBR */ - u32 blink_rate; -/* 0x0008 SGPIO_SGSDLR */ - u32 start_drive_lower; -/* 0x000C SGPIO_SGSDUR */ - u32 start_drive_upper; -/* 0x0010 SGPIO_SGSIDLR */ - u32 serial_input_lower; -/* 0x0014 SGPIO_SGSIDUR */ - u32 serial_input_upper; -/* 0x0018 SGPIO_SGVSCR */ - u32 vendor_specific_code; -/* 0x0020 SGPIO_SGODSR */ - u32 ouput_data_select[8]; -/* Remainder of memory space 256 bytes */ - u32 reserved_1444_14ff[0x31]; - -}; - -/* - * ***************************************************************************** - * * Defines for VIIT entry offsets - * * Access additional entries by SCU_VIIT_BASE + index * 0x10 - * ***************************************************************************** */ -#define SCU_VIIT_BASE 0x1c00 - -struct scu_viit_registers { - u32 registers[256]; -}; - -/* - * ***************************************************************************** - * * SCU PORT TASK SCHEDULER REGISTERS - * ***************************************************************************** */ - -#define SCU_PTSG_BASE 0x1000 - -#define SCU_PTSG_PTSGCR_OFFSET 0x0000 -#define SCU_PTSG_RTCR_OFFSET 0x0004 -#define SCU_PTSG_RTCCR_OFFSET 0x0008 -#define SCU_PTSG_PTS0CR_OFFSET 0x0010 -#define SCU_PTSG_PTS0SR_OFFSET 0x0014 -#define SCU_PTSG_PTS1CR_OFFSET 0x0018 -#define SCU_PTSG_PTS1SR_OFFSET 0x001C -#define SCU_PTSG_PTS2CR_OFFSET 0x0020 -#define SCU_PTSG_PTS2SR_OFFSET 0x0024 -#define SCU_PTSG_PTS3CR_OFFSET 0x0028 -#define SCU_PTSG_PTS3SR_OFFSET 0x002C -#define SCU_PTSG_PCSPE0CR_OFFSET 0x0030 -#define SCU_PTSG_PCSPE1CR_OFFSET 0x0034 -#define SCU_PTSG_PCSPE2CR_OFFSET 0x0038 -#define SCU_PTSG_PCSPE3CR_OFFSET 0x003C -#define SCU_PTSG_ETMTSCCR_OFFSET 0x0040 -#define SCU_PTSG_ETMRNSCCR_OFFSET 0x0044 - -/** - * struct scu_port_task_scheduler_registers - These are the control/stats pairs - * for each Port Task Scheduler. - * - * - */ -struct scu_port_task_scheduler_registers { - u32 control; - u32 status; -}; - -/** - * struct scu_port_task_scheduler_group_registers - These are the PORT Task - * Scheduler registers - * - * - */ -struct scu_port_task_scheduler_group_registers { -/* 0x0000 PTSGCR */ - u32 control; -/* 0x0004 RTCR */ - u32 real_time_clock; -/* 0x0008 RTCCR */ - u32 real_time_clock_control; -/* 0x000C */ - u32 reserved_0C; -/* - * 0x0010 PTS0CR - * 0x0014 PTS0SR - * 0x0018 PTS1CR - * 0x001C PTS1SR - * 0x0020 PTS2CR - * 0x0024 PTS2SR - * 0x0028 PTS3CR - * 0x002C PTS3SR */ - struct scu_port_task_scheduler_registers port[4]; -/* - * 0x0030 PCSPE0CR - * 0x0034 PCSPE1CR - * 0x0038 PCSPE2CR - * 0x003C PCSPE3CR */ - u32 protocol_engine[4]; -/* 0x0040 ETMTSCCR */ - u32 tc_scanning_interval_control; -/* 0x0044 ETMRNSCCR */ - u32 rnc_scanning_interval_control; -/* Remainder of memory space 128 bytes */ - u32 reserved_1048_107f[0x0E]; - -}; - -#define SCU_PTSG_SCUVZECR_OFFSET 0x003C - -/* - * ***************************************************************************** - * * AFE REGISTERS - * ***************************************************************************** */ -#define SCU_AFE_MMR_BASE 0xE000 - -/* - * AFE 0 is at offset 0x0800 - * AFE 1 is at offset 0x0900 - * AFE 2 is at offset 0x0a00 - * AFE 3 is at offset 0x0b00 */ -struct scu_afe_transceiver { - /* 0x0000 AFE_XCVR_CTRL0 */ - u32 afe_xcvr_control0; - /* 0x0004 AFE_XCVR_CTRL1 */ - u32 afe_xcvr_control1; - /* 0x0008 */ - u32 reserved_0008; - /* 0x000c afe_dfx_rx_control0 */ - u32 afe_dfx_rx_control0; - /* 0x0010 AFE_DFX_RX_CTRL1 */ - u32 afe_dfx_rx_control1; - /* 0x0014 */ - u32 reserved_0014; - /* 0x0018 AFE_DFX_RX_STS0 */ - u32 afe_dfx_rx_status0; - /* 0x001c AFE_DFX_RX_STS1 */ - u32 afe_dfx_rx_status1; - /* 0x0020 */ - u32 reserved_0020; - /* 0x0024 AFE_TX_CTRL */ - u32 afe_tx_control; - /* 0x0028 AFE_TX_AMP_CTRL0 */ - u32 afe_tx_amp_control0; - /* 0x002c AFE_TX_AMP_CTRL1 */ - u32 afe_tx_amp_control1; - /* 0x0030 AFE_TX_AMP_CTRL2 */ - u32 afe_tx_amp_control2; - /* 0x0034 AFE_TX_AMP_CTRL3 */ - u32 afe_tx_amp_control3; - /* 0x0038 afe_tx_ssc_control */ - u32 afe_tx_ssc_control; - /* 0x003c */ - u32 reserved_003c; - /* 0x0040 AFE_RX_SSC_CTRL0 */ - u32 afe_rx_ssc_control0; - /* 0x0044 AFE_RX_SSC_CTRL1 */ - u32 afe_rx_ssc_control1; - /* 0x0048 AFE_RX_SSC_CTRL2 */ - u32 afe_rx_ssc_control2; - /* 0x004c AFE_RX_EQ_STS0 */ - u32 afe_rx_eq_status0; - /* 0x0050 AFE_RX_EQ_STS1 */ - u32 afe_rx_eq_status1; - /* 0x0054 AFE_RX_CDR_STS */ - u32 afe_rx_cdr_status; - /* 0x0058 */ - u32 reserved_0058; - /* 0x005c AFE_CHAN_CTRL */ - u32 afe_channel_control; - /* 0x0060-0x006c */ - u32 reserved_0060_006c[0x04]; - /* 0x0070 AFE_XCVR_EC_STS0 */ - u32 afe_xcvr_error_capture_status0; - /* 0x0074 AFE_XCVR_EC_STS1 */ - u32 afe_xcvr_error_capture_status1; - /* 0x0078 AFE_XCVR_EC_STS2 */ - u32 afe_xcvr_error_capture_status2; - /* 0x007c afe_xcvr_ec_status3 */ - u32 afe_xcvr_error_capture_status3; - /* 0x0080 AFE_XCVR_EC_STS4 */ - u32 afe_xcvr_error_capture_status4; - /* 0x0084 AFE_XCVR_EC_STS5 */ - u32 afe_xcvr_error_capture_status5; - /* 0x0088-0x00fc */ - u32 reserved_008c_00fc[0x1e]; -}; - -/** - * struct scu_afe_registers - AFE Regsiters - * - * - */ -/* Uaoa AFE registers */ -struct scu_afe_registers { - /* 0Xe000 AFE_BIAS_CTRL */ - u32 afe_bias_control; - u32 reserved_0004; - /* 0x0008 AFE_PLL_CTRL0 */ - u32 afe_pll_control0; - /* 0x000c AFE_PLL_CTRL1 */ - u32 afe_pll_control1; - /* 0x0010 AFE_PLL_CTRL2 */ - u32 afe_pll_control2; - /* 0x0014 AFE_CB_STS */ - u32 afe_common_block_status; - /* 0x0018-0x007c */ - u32 reserved_18_7c[0x1a]; - /* 0x0080 AFE_PMSN_MCTRL0 */ - u32 afe_pmsn_master_control0; - /* 0x0084 AFE_PMSN_MCTRL1 */ - u32 afe_pmsn_master_control1; - /* 0x0088 AFE_PMSN_MCTRL2 */ - u32 afe_pmsn_master_control2; - /* 0x008C-0x00fc */ - u32 reserved_008c_00fc[0x1D]; - /* 0x0100 AFE_DFX_MST_CTRL0 */ - u32 afe_dfx_master_control0; - /* 0x0104 AFE_DFX_MST_CTRL1 */ - u32 afe_dfx_master_control1; - /* 0x0108 AFE_DFX_DCL_CTRL */ - u32 afe_dfx_dcl_control; - /* 0x010c AFE_DFX_DMON_CTRL */ - u32 afe_dfx_digital_monitor_control; - /* 0x0110 AFE_DFX_AMONP_CTRL */ - u32 afe_dfx_analog_p_monitor_control; - /* 0x0114 AFE_DFX_AMONN_CTRL */ - u32 afe_dfx_analog_n_monitor_control; - /* 0x0118 AFE_DFX_NTL_STS */ - u32 afe_dfx_ntl_status; - /* 0x011c AFE_DFX_FIFO_STS0 */ - u32 afe_dfx_fifo_status0; - /* 0x0120 AFE_DFX_FIFO_STS1 */ - u32 afe_dfx_fifo_status1; - /* 0x0124 AFE_DFX_MPAT_CTRL */ - u32 afe_dfx_master_pattern_control; - /* 0x0128 AFE_DFX_P0_CTRL */ - u32 afe_dfx_p0_control; - /* 0x012c-0x01a8 AFE_DFX_P0_DRx */ - u32 afe_dfx_p0_data[32]; - /* 0x01ac */ - u32 reserved_01ac; - /* 0x01b0-0x020c AFE_DFX_P0_IRx */ - u32 afe_dfx_p0_instruction[24]; - /* 0x0210 */ - u32 reserved_0210; - /* 0x0214 AFE_DFX_P1_CTRL */ - u32 afe_dfx_p1_control; - /* 0x0218-0x245 AFE_DFX_P1_DRx */ - u32 afe_dfx_p1_data[16]; - /* 0x0258-0x029c */ - u32 reserved_0258_029c[0x12]; - /* 0x02a0-0x02bc AFE_DFX_P1_IRx */ - u32 afe_dfx_p1_instruction[8]; - /* 0x02c0-0x2fc */ - u32 reserved_02c0_02fc[0x10]; - /* 0x0300 AFE_DFX_TX_PMSN_CTRL */ - u32 afe_dfx_tx_pmsn_control; - /* 0x0304 AFE_DFX_RX_PMSN_CTRL */ - u32 afe_dfx_rx_pmsn_control; - u32 reserved_0308; - /* 0x030c AFE_DFX_NOA_CTRL0 */ - u32 afe_dfx_noa_control0; - /* 0x0310 AFE_DFX_NOA_CTRL1 */ - u32 afe_dfx_noa_control1; - /* 0x0314 AFE_DFX_NOA_CTRL2 */ - u32 afe_dfx_noa_control2; - /* 0x0318 AFE_DFX_NOA_CTRL3 */ - u32 afe_dfx_noa_control3; - /* 0x031c AFE_DFX_NOA_CTRL4 */ - u32 afe_dfx_noa_control4; - /* 0x0320 AFE_DFX_NOA_CTRL5 */ - u32 afe_dfx_noa_control5; - /* 0x0324 AFE_DFX_NOA_CTRL6 */ - u32 afe_dfx_noa_control6; - /* 0x0328 AFE_DFX_NOA_CTRL7 */ - u32 afe_dfx_noa_control7; - /* 0x032c-0x07fc */ - u32 reserved_032c_07fc[0x135]; - - /* 0x0800-0x0bfc */ - struct scu_afe_transceiver scu_afe_xcvr[4]; - - /* 0x0c00-0x0ffc */ - u32 reserved_0c00_0ffc[0x0100]; -}; - -struct scu_protocol_engine_group_registers { - u32 table[0xE0]; -}; - - -struct scu_viit_iit { - u32 table[256]; -}; - -/** - * Placeholder for the ZONE Partition Table information ZONING will not be - * included in the 1.1 release. - * - * - */ -struct scu_zone_partition_table { - u32 table[2048]; -}; - -/** - * Placeholder for the CRAM register since I am not sure if we need to - * read/write to these registers as yet. - * - * - */ -struct scu_completion_ram { - u32 ram[128]; -}; - -/** - * Placeholder for the FBRAM registers since I am not sure if we need to - * read/write to these registers as yet. - * - * - */ -struct scu_frame_buffer_ram { - u32 ram[128]; -}; - -#define scu_scratch_ram_SIZE_IN_DWORDS 256 - -/** - * Placeholder for the scratch RAM registers. - * - * - */ -struct scu_scratch_ram { - u32 ram[scu_scratch_ram_SIZE_IN_DWORDS]; -}; - -/** - * Placeholder since I am not yet sure what these registers are here for. - * - * - */ -struct noa_protocol_engine_partition { - u32 reserved[64]; -}; - -/** - * Placeholder since I am not yet sure what these registers are here for. - * - * - */ -struct noa_hub_partition { - u32 reserved[64]; -}; - -/** - * Placeholder since I am not yet sure what these registers are here for. - * - * - */ -struct noa_host_interface_partition { - u32 reserved[64]; -}; - -/** - * struct transport_link_layer_pair - The SCU Hardware pairs up the TL - * registers with the LL registers so we must place them adjcent to make the - * array of registers in the PEG. - * - * - */ -struct transport_link_layer_pair { - struct scu_transport_layer_registers tl; - struct scu_link_layer_registers ll; -}; - -/** - * struct scu_peg_registers - SCU Protocol Engine Memory mapped register space. - * These registers are unique to each protocol engine group. There can be - * at most two PEG for a single SCU part. - * - * - */ -struct scu_peg_registers { - struct transport_link_layer_pair pe[4]; - struct scu_port_task_scheduler_group_registers ptsg; - struct scu_protocol_engine_group_registers peg; - struct scu_sgpio_registers sgpio; - u32 reserved_01500_1BFF[0x1C0]; - struct scu_viit_entry viit[64]; - struct scu_zone_partition_table zpt0; - struct scu_zone_partition_table zpt1; -}; - -/** - * struct scu_registers - SCU regsiters including both PEG registers if we turn - * on that compile option. All of these registers are in the memory mapped - * space returned from BAR1. - * - * - */ -struct scu_registers { - /* 0x0000 - PEG 0 */ - struct scu_peg_registers peg0; - - /* 0x6000 - SDMA and Miscellaneous */ - struct scu_sdma_registers sdma; - struct scu_completion_ram cram; - struct scu_frame_buffer_ram fbram; - u32 reserved_6800_69FF[0x80]; - struct noa_protocol_engine_partition noa_pe; - struct noa_hub_partition noa_hub; - struct noa_host_interface_partition noa_if; - u32 reserved_6d00_7fff[0x4c0]; - - /* 0x8000 - PEG 1 */ - struct scu_peg_registers peg1; - - /* 0xE000 - AFE Registers */ - struct scu_afe_registers afe; - - /* 0xF000 - reserved */ - u32 reserved_f000_211fff[0x80c00]; - - /* 0x212000 - scratch RAM */ - struct scu_scratch_ram scratch_ram; -}; - -#endif /* _SCU_REGISTERS_HEADER_ */ diff --git a/trunk/drivers/scsi/isci/remote_device.c b/trunk/drivers/scsi/isci/remote_device.c deleted file mode 100644 index b6e6368c2665..000000000000 --- a/trunk/drivers/scsi/isci/remote_device.c +++ /dev/null @@ -1,1501 +0,0 @@ -/* - * This file is provided under a dual BSD/GPLv2 license. When using or - * redistributing this file, you may do so under either license. - * - * GPL LICENSE SUMMARY - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License 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., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. - * The full GNU General Public License is included in this distribution - * in the file called LICENSE.GPL. - * - * BSD LICENSE - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Intel Corporation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include -#include "isci.h" -#include "port.h" -#include "remote_device.h" -#include "request.h" -#include "remote_node_context.h" -#include "scu_event_codes.h" -#include "task.h" - -/** - * isci_remote_device_not_ready() - This function is called by the ihost when - * the remote device is not ready. We mark the isci device as ready (not - * "ready_for_io") and signal the waiting proccess. - * @isci_host: This parameter specifies the isci host object. - * @isci_device: This parameter specifies the remote device - * - * sci_lock is held on entrance to this function. - */ -static void isci_remote_device_not_ready(struct isci_host *ihost, - struct isci_remote_device *idev, u32 reason) -{ - struct isci_request *ireq; - - dev_dbg(&ihost->pdev->dev, - "%s: isci_device = %p\n", __func__, idev); - - switch (reason) { - case SCIC_REMOTE_DEVICE_NOT_READY_STOP_REQUESTED: - set_bit(IDEV_GONE, &idev->flags); - break; - case SCIC_REMOTE_DEVICE_NOT_READY_SATA_SDB_ERROR_FIS_RECEIVED: - set_bit(IDEV_IO_NCQERROR, &idev->flags); - - /* Kill all outstanding requests for the device. */ - list_for_each_entry(ireq, &idev->reqs_in_process, dev_node) { - - dev_dbg(&ihost->pdev->dev, - "%s: isci_device = %p request = %p\n", - __func__, idev, ireq); - - sci_controller_terminate_request(ihost, - idev, - ireq); - } - /* Fall through into the default case... */ - default: - clear_bit(IDEV_IO_READY, &idev->flags); - break; - } -} - -/** - * isci_remote_device_ready() - This function is called by the ihost when the - * remote device is ready. We mark the isci device as ready and signal the - * waiting proccess. - * @ihost: our valid isci_host - * @idev: remote device - * - */ -static void isci_remote_device_ready(struct isci_host *ihost, struct isci_remote_device *idev) -{ - dev_dbg(&ihost->pdev->dev, - "%s: idev = %p\n", __func__, idev); - - clear_bit(IDEV_IO_NCQERROR, &idev->flags); - set_bit(IDEV_IO_READY, &idev->flags); - if (test_and_clear_bit(IDEV_START_PENDING, &idev->flags)) - wake_up(&ihost->eventq); -} - -/* called once the remote node context is ready to be freed. - * The remote device can now report that its stop operation is complete. none - */ -static void rnc_destruct_done(void *_dev) -{ - struct isci_remote_device *idev = _dev; - - BUG_ON(idev->started_request_count != 0); - sci_change_state(&idev->sm, SCI_DEV_STOPPED); -} - -static enum sci_status sci_remote_device_terminate_requests(struct isci_remote_device *idev) -{ - struct isci_host *ihost = idev->owning_port->owning_controller; - enum sci_status status = SCI_SUCCESS; - u32 i; - - for (i = 0; i < SCI_MAX_IO_REQUESTS; i++) { - struct isci_request *ireq = ihost->reqs[i]; - enum sci_status s; - - if (!test_bit(IREQ_ACTIVE, &ireq->flags) || - ireq->target_device != idev) - continue; - - s = sci_controller_terminate_request(ihost, idev, ireq); - if (s != SCI_SUCCESS) - status = s; - } - - return status; -} - -enum sci_status sci_remote_device_stop(struct isci_remote_device *idev, - u32 timeout) -{ - struct sci_base_state_machine *sm = &idev->sm; - enum sci_remote_device_states state = sm->current_state_id; - - switch (state) { - case SCI_DEV_INITIAL: - case SCI_DEV_FAILED: - case SCI_DEV_FINAL: - default: - dev_warn(scirdev_to_dev(idev), "%s: in wrong state: %d\n", - __func__, state); - return SCI_FAILURE_INVALID_STATE; - case SCI_DEV_STOPPED: - return SCI_SUCCESS; - case SCI_DEV_STARTING: - /* device not started so there had better be no requests */ - BUG_ON(idev->started_request_count != 0); - sci_remote_node_context_destruct(&idev->rnc, - rnc_destruct_done, idev); - /* Transition to the stopping state and wait for the - * remote node to complete being posted and invalidated. - */ - sci_change_state(sm, SCI_DEV_STOPPING); - return SCI_SUCCESS; - case SCI_DEV_READY: - case SCI_STP_DEV_IDLE: - case SCI_STP_DEV_CMD: - case SCI_STP_DEV_NCQ: - case SCI_STP_DEV_NCQ_ERROR: - case SCI_STP_DEV_AWAIT_RESET: - case SCI_SMP_DEV_IDLE: - case SCI_SMP_DEV_CMD: - sci_change_state(sm, SCI_DEV_STOPPING); - if (idev->started_request_count == 0) { - sci_remote_node_context_destruct(&idev->rnc, - rnc_destruct_done, idev); - return SCI_SUCCESS; - } else - return sci_remote_device_terminate_requests(idev); - break; - case SCI_DEV_STOPPING: - /* All requests should have been terminated, but if there is an - * attempt to stop a device already in the stopping state, then - * try again to terminate. - */ - return sci_remote_device_terminate_requests(idev); - case SCI_DEV_RESETTING: - sci_change_state(sm, SCI_DEV_STOPPING); - return SCI_SUCCESS; - } -} - -enum sci_status sci_remote_device_reset(struct isci_remote_device *idev) -{ - struct sci_base_state_machine *sm = &idev->sm; - enum sci_remote_device_states state = sm->current_state_id; - - switch (state) { - case SCI_DEV_INITIAL: - case SCI_DEV_STOPPED: - case SCI_DEV_STARTING: - case SCI_SMP_DEV_IDLE: - case SCI_SMP_DEV_CMD: - case SCI_DEV_STOPPING: - case SCI_DEV_FAILED: - case SCI_DEV_RESETTING: - case SCI_DEV_FINAL: - default: - dev_warn(scirdev_to_dev(idev), "%s: in wrong state: %d\n", - __func__, state); - return SCI_FAILURE_INVALID_STATE; - case SCI_DEV_READY: - case SCI_STP_DEV_IDLE: - case SCI_STP_DEV_CMD: - case SCI_STP_DEV_NCQ: - case SCI_STP_DEV_NCQ_ERROR: - case SCI_STP_DEV_AWAIT_RESET: - sci_change_state(sm, SCI_DEV_RESETTING); - return SCI_SUCCESS; - } -} - -enum sci_status sci_remote_device_reset_complete(struct isci_remote_device *idev) -{ - struct sci_base_state_machine *sm = &idev->sm; - enum sci_remote_device_states state = sm->current_state_id; - - if (state != SCI_DEV_RESETTING) { - dev_warn(scirdev_to_dev(idev), "%s: in wrong state: %d\n", - __func__, state); - return SCI_FAILURE_INVALID_STATE; - } - - sci_change_state(sm, SCI_DEV_READY); - return SCI_SUCCESS; -} - -enum sci_status sci_remote_device_suspend(struct isci_remote_device *idev, - u32 suspend_type) -{ - struct sci_base_state_machine *sm = &idev->sm; - enum sci_remote_device_states state = sm->current_state_id; - - if (state != SCI_STP_DEV_CMD) { - dev_warn(scirdev_to_dev(idev), "%s: in wrong state: %d\n", - __func__, state); - return SCI_FAILURE_INVALID_STATE; - } - - return sci_remote_node_context_suspend(&idev->rnc, - suspend_type, NULL, NULL); -} - -enum sci_status sci_remote_device_frame_handler(struct isci_remote_device *idev, - u32 frame_index) -{ - struct sci_base_state_machine *sm = &idev->sm; - enum sci_remote_device_states state = sm->current_state_id; - struct isci_host *ihost = idev->owning_port->owning_controller; - enum sci_status status; - - switch (state) { - case SCI_DEV_INITIAL: - case SCI_DEV_STOPPED: - case SCI_DEV_STARTING: - case SCI_STP_DEV_IDLE: - case SCI_SMP_DEV_IDLE: - case SCI_DEV_FINAL: - default: - dev_warn(scirdev_to_dev(idev), "%s: in wrong state: %d\n", - __func__, state); - /* Return the frame back to the controller */ - sci_controller_release_frame(ihost, frame_index); - return SCI_FAILURE_INVALID_STATE; - case SCI_DEV_READY: - case SCI_STP_DEV_NCQ_ERROR: - case SCI_STP_DEV_AWAIT_RESET: - case SCI_DEV_STOPPING: - case SCI_DEV_FAILED: - case SCI_DEV_RESETTING: { - struct isci_request *ireq; - struct ssp_frame_hdr hdr; - void *frame_header; - ssize_t word_cnt; - - status = sci_unsolicited_frame_control_get_header(&ihost->uf_control, - frame_index, - &frame_header); - if (status != SCI_SUCCESS) - return status; - - word_cnt = sizeof(hdr) / sizeof(u32); - sci_swab32_cpy(&hdr, frame_header, word_cnt); - - ireq = sci_request_by_tag(ihost, be16_to_cpu(hdr.tag)); - if (ireq && ireq->target_device == idev) { - /* The IO request is now in charge of releasing the frame */ - status = sci_io_request_frame_handler(ireq, frame_index); - } else { - /* We could not map this tag to a valid IO - * request Just toss the frame and continue - */ - sci_controller_release_frame(ihost, frame_index); - } - break; - } - case SCI_STP_DEV_NCQ: { - struct dev_to_host_fis *hdr; - - status = sci_unsolicited_frame_control_get_header(&ihost->uf_control, - frame_index, - (void **)&hdr); - if (status != SCI_SUCCESS) - return status; - - if (hdr->fis_type == FIS_SETDEVBITS && - (hdr->status & ATA_ERR)) { - idev->not_ready_reason = SCIC_REMOTE_DEVICE_NOT_READY_SATA_SDB_ERROR_FIS_RECEIVED; - - /* TODO Check sactive and complete associated IO if any. */ - sci_change_state(sm, SCI_STP_DEV_NCQ_ERROR); - } else if (hdr->fis_type == FIS_REGD2H && - (hdr->status & ATA_ERR)) { - /* - * Some devices return D2H FIS when an NCQ error is detected. - * Treat this like an SDB error FIS ready reason. - */ - idev->not_ready_reason = SCIC_REMOTE_DEVICE_NOT_READY_SATA_SDB_ERROR_FIS_RECEIVED; - sci_change_state(&idev->sm, SCI_STP_DEV_NCQ_ERROR); - } else - status = SCI_FAILURE; - - sci_controller_release_frame(ihost, frame_index); - break; - } - case SCI_STP_DEV_CMD: - case SCI_SMP_DEV_CMD: - /* The device does not process any UF received from the hardware while - * in this state. All unsolicited frames are forwarded to the io request - * object. - */ - status = sci_io_request_frame_handler(idev->working_request, frame_index); - break; - } - - return status; -} - -static bool is_remote_device_ready(struct isci_remote_device *idev) -{ - - struct sci_base_state_machine *sm = &idev->sm; - enum sci_remote_device_states state = sm->current_state_id; - - switch (state) { - case SCI_DEV_READY: - case SCI_STP_DEV_IDLE: - case SCI_STP_DEV_CMD: - case SCI_STP_DEV_NCQ: - case SCI_STP_DEV_NCQ_ERROR: - case SCI_STP_DEV_AWAIT_RESET: - case SCI_SMP_DEV_IDLE: - case SCI_SMP_DEV_CMD: - return true; - default: - return false; - } -} - -enum sci_status sci_remote_device_event_handler(struct isci_remote_device *idev, - u32 event_code) -{ - struct sci_base_state_machine *sm = &idev->sm; - enum sci_remote_device_states state = sm->current_state_id; - enum sci_status status; - - switch (scu_get_event_type(event_code)) { - case SCU_EVENT_TYPE_RNC_OPS_MISC: - case SCU_EVENT_TYPE_RNC_SUSPEND_TX: - case SCU_EVENT_TYPE_RNC_SUSPEND_TX_RX: - status = sci_remote_node_context_event_handler(&idev->rnc, event_code); - break; - case SCU_EVENT_TYPE_PTX_SCHEDULE_EVENT: - if (scu_get_event_code(event_code) == SCU_EVENT_IT_NEXUS_TIMEOUT) { - status = SCI_SUCCESS; - - /* Suspend the associated RNC */ - sci_remote_node_context_suspend(&idev->rnc, - SCI_SOFTWARE_SUSPENSION, - NULL, NULL); - - dev_dbg(scirdev_to_dev(idev), - "%s: device: %p event code: %x: %s\n", - __func__, idev, event_code, - is_remote_device_ready(idev) - ? "I_T_Nexus_Timeout event" - : "I_T_Nexus_Timeout event in wrong state"); - - break; - } - /* Else, fall through and treat as unhandled... */ - default: - dev_dbg(scirdev_to_dev(idev), - "%s: device: %p event code: %x: %s\n", - __func__, idev, event_code, - is_remote_device_ready(idev) - ? "unexpected event" - : "unexpected event in wrong state"); - status = SCI_FAILURE_INVALID_STATE; - break; - } - - if (status != SCI_SUCCESS) - return status; - - if (state == SCI_STP_DEV_IDLE) { - - /* We pick up suspension events to handle specifically to this - * state. We resume the RNC right away. - */ - if (scu_get_event_type(event_code) == SCU_EVENT_TYPE_RNC_SUSPEND_TX || - scu_get_event_type(event_code) == SCU_EVENT_TYPE_RNC_SUSPEND_TX_RX) - status = sci_remote_node_context_resume(&idev->rnc, NULL, NULL); - } - - return status; -} - -static void sci_remote_device_start_request(struct isci_remote_device *idev, - struct isci_request *ireq, - enum sci_status status) -{ - struct isci_port *iport = idev->owning_port; - - /* cleanup requests that failed after starting on the port */ - if (status != SCI_SUCCESS) - sci_port_complete_io(iport, idev, ireq); - else { - kref_get(&idev->kref); - idev->started_request_count++; - } -} - -enum sci_status sci_remote_device_start_io(struct isci_host *ihost, - struct isci_remote_device *idev, - struct isci_request *ireq) -{ - struct sci_base_state_machine *sm = &idev->sm; - enum sci_remote_device_states state = sm->current_state_id; - struct isci_port *iport = idev->owning_port; - enum sci_status status; - - switch (state) { - case SCI_DEV_INITIAL: - case SCI_DEV_STOPPED: - case SCI_DEV_STARTING: - case SCI_STP_DEV_NCQ_ERROR: - case SCI_DEV_STOPPING: - case SCI_DEV_FAILED: - case SCI_DEV_RESETTING: - case SCI_DEV_FINAL: - default: - dev_warn(scirdev_to_dev(idev), "%s: in wrong state: %d\n", - __func__, state); - return SCI_FAILURE_INVALID_STATE; - case SCI_DEV_READY: - /* attempt to start an io request for this device object. The remote - * device object will issue the start request for the io and if - * successful it will start the request for the port object then - * increment its own request count. - */ - status = sci_port_start_io(iport, idev, ireq); - if (status != SCI_SUCCESS) - return status; - - status = sci_remote_node_context_start_io(&idev->rnc, ireq); - if (status != SCI_SUCCESS) - break; - - status = sci_request_start(ireq); - break; - case SCI_STP_DEV_IDLE: { - /* handle the start io operation for a sata device that is in - * the command idle state. - Evalute the type of IO request to - * be started - If its an NCQ request change to NCQ substate - - * If its any other command change to the CMD substate - * - * If this is a softreset we may want to have a different - * substate. - */ - enum sci_remote_device_states new_state; - struct sas_task *task = isci_request_access_task(ireq); - - status = sci_port_start_io(iport, idev, ireq); - if (status != SCI_SUCCESS) - return status; - - status = sci_remote_node_context_start_io(&idev->rnc, ireq); - if (status != SCI_SUCCESS) - break; - - status = sci_request_start(ireq); - if (status != SCI_SUCCESS) - break; - - if (task->ata_task.use_ncq) - new_state = SCI_STP_DEV_NCQ; - else { - idev->working_request = ireq; - new_state = SCI_STP_DEV_CMD; - } - sci_change_state(sm, new_state); - break; - } - case SCI_STP_DEV_NCQ: { - struct sas_task *task = isci_request_access_task(ireq); - - if (task->ata_task.use_ncq) { - status = sci_port_start_io(iport, idev, ireq); - if (status != SCI_SUCCESS) - return status; - - status = sci_remote_node_context_start_io(&idev->rnc, ireq); - if (status != SCI_SUCCESS) - break; - - status = sci_request_start(ireq); - } else - return SCI_FAILURE_INVALID_STATE; - break; - } - case SCI_STP_DEV_AWAIT_RESET: - return SCI_FAILURE_REMOTE_DEVICE_RESET_REQUIRED; - case SCI_SMP_DEV_IDLE: - status = sci_port_start_io(iport, idev, ireq); - if (status != SCI_SUCCESS) - return status; - - status = sci_remote_node_context_start_io(&idev->rnc, ireq); - if (status != SCI_SUCCESS) - break; - - status = sci_request_start(ireq); - if (status != SCI_SUCCESS) - break; - - idev->working_request = ireq; - sci_change_state(&idev->sm, SCI_SMP_DEV_CMD); - break; - case SCI_STP_DEV_CMD: - case SCI_SMP_DEV_CMD: - /* device is already handling a command it can not accept new commands - * until this one is complete. - */ - return SCI_FAILURE_INVALID_STATE; - } - - sci_remote_device_start_request(idev, ireq, status); - return status; -} - -static enum sci_status common_complete_io(struct isci_port *iport, - struct isci_remote_device *idev, - struct isci_request *ireq) -{ - enum sci_status status; - - status = sci_request_complete(ireq); - if (status != SCI_SUCCESS) - return status; - - status = sci_port_complete_io(iport, idev, ireq); - if (status != SCI_SUCCESS) - return status; - - sci_remote_device_decrement_request_count(idev); - return status; -} - -enum sci_status sci_remote_device_complete_io(struct isci_host *ihost, - struct isci_remote_device *idev, - struct isci_request *ireq) -{ - struct sci_base_state_machine *sm = &idev->sm; - enum sci_remote_device_states state = sm->current_state_id; - struct isci_port *iport = idev->owning_port; - enum sci_status status; - - switch (state) { - case SCI_DEV_INITIAL: - case SCI_DEV_STOPPED: - case SCI_DEV_STARTING: - case SCI_STP_DEV_IDLE: - case SCI_SMP_DEV_IDLE: - case SCI_DEV_FAILED: - case SCI_DEV_FINAL: - default: - dev_warn(scirdev_to_dev(idev), "%s: in wrong state: %d\n", - __func__, state); - return SCI_FAILURE_INVALID_STATE; - case SCI_DEV_READY: - case SCI_STP_DEV_AWAIT_RESET: - case SCI_DEV_RESETTING: - status = common_complete_io(iport, idev, ireq); - break; - case SCI_STP_DEV_CMD: - case SCI_STP_DEV_NCQ: - case SCI_STP_DEV_NCQ_ERROR: - status = common_complete_io(iport, idev, ireq); - if (status != SCI_SUCCESS) - break; - - if (ireq->sci_status == SCI_FAILURE_REMOTE_DEVICE_RESET_REQUIRED) { - /* This request causes hardware error, device needs to be Lun Reset. - * So here we force the state machine to IDLE state so the rest IOs - * can reach RNC state handler, these IOs will be completed by RNC with - * status of "DEVICE_RESET_REQUIRED", instead of "INVALID STATE". - */ - sci_change_state(sm, SCI_STP_DEV_AWAIT_RESET); - } else if (idev->started_request_count == 0) - sci_change_state(sm, SCI_STP_DEV_IDLE); - break; - case SCI_SMP_DEV_CMD: - status = common_complete_io(iport, idev, ireq); - if (status != SCI_SUCCESS) - break; - sci_change_state(sm, SCI_SMP_DEV_IDLE); - break; - case SCI_DEV_STOPPING: - status = common_complete_io(iport, idev, ireq); - if (status != SCI_SUCCESS) - break; - - if (idev->started_request_count == 0) - sci_remote_node_context_destruct(&idev->rnc, - rnc_destruct_done, - idev); - break; - } - - if (status != SCI_SUCCESS) - dev_err(scirdev_to_dev(idev), - "%s: Port:0x%p Device:0x%p Request:0x%p Status:0x%x " - "could not complete\n", __func__, iport, - idev, ireq, status); - else - isci_put_device(idev); - - return status; -} - -static void sci_remote_device_continue_request(void *dev) -{ - struct isci_remote_device *idev = dev; - - /* we need to check if this request is still valid to continue. */ - if (idev->working_request) - sci_controller_continue_io(idev->working_request); -} - -enum sci_status sci_remote_device_start_task(struct isci_host *ihost, - struct isci_remote_device *idev, - struct isci_request *ireq) -{ - struct sci_base_state_machine *sm = &idev->sm; - enum sci_remote_device_states state = sm->current_state_id; - struct isci_port *iport = idev->owning_port; - enum sci_status status; - - switch (state) { - case SCI_DEV_INITIAL: - case SCI_DEV_STOPPED: - case SCI_DEV_STARTING: - case SCI_SMP_DEV_IDLE: - case SCI_SMP_DEV_CMD: - case SCI_DEV_STOPPING: - case SCI_DEV_FAILED: - case SCI_DEV_RESETTING: - case SCI_DEV_FINAL: - default: - dev_warn(scirdev_to_dev(idev), "%s: in wrong state: %d\n", - __func__, state); - return SCI_FAILURE_INVALID_STATE; - case SCI_STP_DEV_IDLE: - case SCI_STP_DEV_CMD: - case SCI_STP_DEV_NCQ: - case SCI_STP_DEV_NCQ_ERROR: - case SCI_STP_DEV_AWAIT_RESET: - status = sci_port_start_io(iport, idev, ireq); - if (status != SCI_SUCCESS) - return status; - - status = sci_remote_node_context_start_task(&idev->rnc, ireq); - if (status != SCI_SUCCESS) - goto out; - - status = sci_request_start(ireq); - if (status != SCI_SUCCESS) - goto out; - - /* Note: If the remote device state is not IDLE this will - * replace the request that probably resulted in the task - * management request. - */ - idev->working_request = ireq; - sci_change_state(sm, SCI_STP_DEV_CMD); - - /* The remote node context must cleanup the TCi to NCQ mapping - * table. The only way to do this correctly is to either write - * to the TLCR register or to invalidate and repost the RNC. In - * either case the remote node context state machine will take - * the correct action when the remote node context is suspended - * and later resumed. - */ - sci_remote_node_context_suspend(&idev->rnc, - SCI_SOFTWARE_SUSPENSION, NULL, NULL); - sci_remote_node_context_resume(&idev->rnc, - sci_remote_device_continue_request, - idev); - - out: - sci_remote_device_start_request(idev, ireq, status); - /* We need to let the controller start request handler know that - * it can't post TC yet. We will provide a callback function to - * post TC when RNC gets resumed. - */ - return SCI_FAILURE_RESET_DEVICE_PARTIAL_SUCCESS; - case SCI_DEV_READY: - status = sci_port_start_io(iport, idev, ireq); - if (status != SCI_SUCCESS) - return status; - - status = sci_remote_node_context_start_task(&idev->rnc, ireq); - if (status != SCI_SUCCESS) - break; - - status = sci_request_start(ireq); - break; - } - sci_remote_device_start_request(idev, ireq, status); - - return status; -} - -void sci_remote_device_post_request(struct isci_remote_device *idev, u32 request) -{ - struct isci_port *iport = idev->owning_port; - u32 context; - - context = request | - (ISCI_PEG << SCU_CONTEXT_COMMAND_PROTOCOL_ENGINE_GROUP_SHIFT) | - (iport->physical_port_index << SCU_CONTEXT_COMMAND_LOGICAL_PORT_SHIFT) | - idev->rnc.remote_node_index; - - sci_controller_post_request(iport->owning_controller, context); -} - -/* called once the remote node context has transisitioned to a - * ready state. This is the indication that the remote device object can also - * transition to ready. - */ -static void remote_device_resume_done(void *_dev) -{ - struct isci_remote_device *idev = _dev; - - if (is_remote_device_ready(idev)) - return; - - /* go 'ready' if we are not already in a ready state */ - sci_change_state(&idev->sm, SCI_DEV_READY); -} - -static void sci_stp_remote_device_ready_idle_substate_resume_complete_handler(void *_dev) -{ - struct isci_remote_device *idev = _dev; - struct isci_host *ihost = idev->owning_port->owning_controller; - - /* For NCQ operation we do not issue a isci_remote_device_not_ready(). - * As a result, avoid sending the ready notification. - */ - if (idev->sm.previous_state_id != SCI_STP_DEV_NCQ) - isci_remote_device_ready(ihost, idev); -} - -static void sci_remote_device_initial_state_enter(struct sci_base_state_machine *sm) -{ - struct isci_remote_device *idev = container_of(sm, typeof(*idev), sm); - - /* Initial state is a transitional state to the stopped state */ - sci_change_state(&idev->sm, SCI_DEV_STOPPED); -} - -/** - * sci_remote_device_destruct() - free remote node context and destruct - * @remote_device: This parameter specifies the remote device to be destructed. - * - * Remote device objects are a limited resource. As such, they must be - * protected. Thus calls to construct and destruct are mutually exclusive and - * non-reentrant. The return value shall indicate if the device was - * successfully destructed or if some failure occurred. enum sci_status This value - * is returned if the device is successfully destructed. - * SCI_FAILURE_INVALID_REMOTE_DEVICE This value is returned if the supplied - * device isn't valid (e.g. it's already been destoryed, the handle isn't - * valid, etc.). - */ -static enum sci_status sci_remote_device_destruct(struct isci_remote_device *idev) -{ - struct sci_base_state_machine *sm = &idev->sm; - enum sci_remote_device_states state = sm->current_state_id; - struct isci_host *ihost; - - if (state != SCI_DEV_STOPPED) { - dev_warn(scirdev_to_dev(idev), "%s: in wrong state: %d\n", - __func__, state); - return SCI_FAILURE_INVALID_STATE; - } - - ihost = idev->owning_port->owning_controller; - sci_controller_free_remote_node_context(ihost, idev, - idev->rnc.remote_node_index); - idev->rnc.remote_node_index = SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX; - sci_change_state(sm, SCI_DEV_FINAL); - - return SCI_SUCCESS; -} - -/** - * isci_remote_device_deconstruct() - This function frees an isci_remote_device. - * @ihost: This parameter specifies the isci host object. - * @idev: This parameter specifies the remote device to be freed. - * - */ -static void isci_remote_device_deconstruct(struct isci_host *ihost, struct isci_remote_device *idev) -{ - dev_dbg(&ihost->pdev->dev, - "%s: isci_device = %p\n", __func__, idev); - - /* There should not be any outstanding io's. All paths to - * here should go through isci_remote_device_nuke_requests. - * If we hit this condition, we will need a way to complete - * io requests in process */ - BUG_ON(!list_empty(&idev->reqs_in_process)); - - sci_remote_device_destruct(idev); - list_del_init(&idev->node); - isci_put_device(idev); -} - -static void sci_remote_device_stopped_state_enter(struct sci_base_state_machine *sm) -{ - struct isci_remote_device *idev = container_of(sm, typeof(*idev), sm); - struct isci_host *ihost = idev->owning_port->owning_controller; - u32 prev_state; - - /* If we are entering from the stopping state let the SCI User know that - * the stop operation has completed. - */ - prev_state = idev->sm.previous_state_id; - if (prev_state == SCI_DEV_STOPPING) - isci_remote_device_deconstruct(ihost, idev); - - sci_controller_remote_device_stopped(ihost, idev); -} - -static void sci_remote_device_starting_state_enter(struct sci_base_state_machine *sm) -{ - struct isci_remote_device *idev = container_of(sm, typeof(*idev), sm); - struct isci_host *ihost = idev->owning_port->owning_controller; - - isci_remote_device_not_ready(ihost, idev, - SCIC_REMOTE_DEVICE_NOT_READY_START_REQUESTED); -} - -static void sci_remote_device_ready_state_enter(struct sci_base_state_machine *sm) -{ - struct isci_remote_device *idev = container_of(sm, typeof(*idev), sm); - struct isci_host *ihost = idev->owning_port->owning_controller; - struct domain_device *dev = idev->domain_dev; - - if (dev->dev_type == SATA_DEV || (dev->tproto & SAS_PROTOCOL_SATA)) { - sci_change_state(&idev->sm, SCI_STP_DEV_IDLE); - } else if (dev_is_expander(dev)) { - sci_change_state(&idev->sm, SCI_SMP_DEV_IDLE); - } else - isci_remote_device_ready(ihost, idev); -} - -static void sci_remote_device_ready_state_exit(struct sci_base_state_machine *sm) -{ - struct isci_remote_device *idev = container_of(sm, typeof(*idev), sm); - struct domain_device *dev = idev->domain_dev; - - if (dev->dev_type == SAS_END_DEV) { - struct isci_host *ihost = idev->owning_port->owning_controller; - - isci_remote_device_not_ready(ihost, idev, - SCIC_REMOTE_DEVICE_NOT_READY_STOP_REQUESTED); - } -} - -static void sci_remote_device_resetting_state_enter(struct sci_base_state_machine *sm) -{ - struct isci_remote_device *idev = container_of(sm, typeof(*idev), sm); - - sci_remote_node_context_suspend( - &idev->rnc, SCI_SOFTWARE_SUSPENSION, NULL, NULL); -} - -static void sci_remote_device_resetting_state_exit(struct sci_base_state_machine *sm) -{ - struct isci_remote_device *idev = container_of(sm, typeof(*idev), sm); - - sci_remote_node_context_resume(&idev->rnc, NULL, NULL); -} - -static void sci_stp_remote_device_ready_idle_substate_enter(struct sci_base_state_machine *sm) -{ - struct isci_remote_device *idev = container_of(sm, typeof(*idev), sm); - - idev->working_request = NULL; - if (sci_remote_node_context_is_ready(&idev->rnc)) { - /* - * Since the RNC is ready, it's alright to finish completion - * processing (e.g. signal the remote device is ready). */ - sci_stp_remote_device_ready_idle_substate_resume_complete_handler(idev); - } else { - sci_remote_node_context_resume(&idev->rnc, - sci_stp_remote_device_ready_idle_substate_resume_complete_handler, - idev); - } -} - -static void sci_stp_remote_device_ready_cmd_substate_enter(struct sci_base_state_machine *sm) -{ - struct isci_remote_device *idev = container_of(sm, typeof(*idev), sm); - struct isci_host *ihost = idev->owning_port->owning_controller; - - BUG_ON(idev->working_request == NULL); - - isci_remote_device_not_ready(ihost, idev, - SCIC_REMOTE_DEVICE_NOT_READY_SATA_REQUEST_STARTED); -} - -static void sci_stp_remote_device_ready_ncq_error_substate_enter(struct sci_base_state_machine *sm) -{ - struct isci_remote_device *idev = container_of(sm, typeof(*idev), sm); - struct isci_host *ihost = idev->owning_port->owning_controller; - - if (idev->not_ready_reason == SCIC_REMOTE_DEVICE_NOT_READY_SATA_SDB_ERROR_FIS_RECEIVED) - isci_remote_device_not_ready(ihost, idev, - idev->not_ready_reason); -} - -static void sci_smp_remote_device_ready_idle_substate_enter(struct sci_base_state_machine *sm) -{ - struct isci_remote_device *idev = container_of(sm, typeof(*idev), sm); - struct isci_host *ihost = idev->owning_port->owning_controller; - - isci_remote_device_ready(ihost, idev); -} - -static void sci_smp_remote_device_ready_cmd_substate_enter(struct sci_base_state_machine *sm) -{ - struct isci_remote_device *idev = container_of(sm, typeof(*idev), sm); - struct isci_host *ihost = idev->owning_port->owning_controller; - - BUG_ON(idev->working_request == NULL); - - isci_remote_device_not_ready(ihost, idev, - SCIC_REMOTE_DEVICE_NOT_READY_SMP_REQUEST_STARTED); -} - -static void sci_smp_remote_device_ready_cmd_substate_exit(struct sci_base_state_machine *sm) -{ - struct isci_remote_device *idev = container_of(sm, typeof(*idev), sm); - - idev->working_request = NULL; -} - -static const struct sci_base_state sci_remote_device_state_table[] = { - [SCI_DEV_INITIAL] = { - .enter_state = sci_remote_device_initial_state_enter, - }, - [SCI_DEV_STOPPED] = { - .enter_state = sci_remote_device_stopped_state_enter, - }, - [SCI_DEV_STARTING] = { - .enter_state = sci_remote_device_starting_state_enter, - }, - [SCI_DEV_READY] = { - .enter_state = sci_remote_device_ready_state_enter, - .exit_state = sci_remote_device_ready_state_exit - }, - [SCI_STP_DEV_IDLE] = { - .enter_state = sci_stp_remote_device_ready_idle_substate_enter, - }, - [SCI_STP_DEV_CMD] = { - .enter_state = sci_stp_remote_device_ready_cmd_substate_enter, - }, - [SCI_STP_DEV_NCQ] = { }, - [SCI_STP_DEV_NCQ_ERROR] = { - .enter_state = sci_stp_remote_device_ready_ncq_error_substate_enter, - }, - [SCI_STP_DEV_AWAIT_RESET] = { }, - [SCI_SMP_DEV_IDLE] = { - .enter_state = sci_smp_remote_device_ready_idle_substate_enter, - }, - [SCI_SMP_DEV_CMD] = { - .enter_state = sci_smp_remote_device_ready_cmd_substate_enter, - .exit_state = sci_smp_remote_device_ready_cmd_substate_exit, - }, - [SCI_DEV_STOPPING] = { }, - [SCI_DEV_FAILED] = { }, - [SCI_DEV_RESETTING] = { - .enter_state = sci_remote_device_resetting_state_enter, - .exit_state = sci_remote_device_resetting_state_exit - }, - [SCI_DEV_FINAL] = { }, -}; - -/** - * sci_remote_device_construct() - common construction - * @sci_port: SAS/SATA port through which this device is accessed. - * @sci_dev: remote device to construct - * - * This routine just performs benign initialization and does not - * allocate the remote_node_context which is left to - * sci_remote_device_[de]a_construct(). sci_remote_device_destruct() - * frees the remote_node_context(s) for the device. - */ -static void sci_remote_device_construct(struct isci_port *iport, - struct isci_remote_device *idev) -{ - idev->owning_port = iport; - idev->started_request_count = 0; - - sci_init_sm(&idev->sm, sci_remote_device_state_table, SCI_DEV_INITIAL); - - sci_remote_node_context_construct(&idev->rnc, - SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX); -} - -/** - * sci_remote_device_da_construct() - construct direct attached device. - * - * The information (e.g. IAF, Signature FIS, etc.) necessary to build - * the device is known to the SCI Core since it is contained in the - * sci_phy object. Remote node context(s) is/are a global resource - * allocated by this routine, freed by sci_remote_device_destruct(). - * - * Returns: - * SCI_FAILURE_DEVICE_EXISTS - device has already been constructed. - * SCI_FAILURE_UNSUPPORTED_PROTOCOL - e.g. sas device attached to - * sata-only controller instance. - * SCI_FAILURE_INSUFFICIENT_RESOURCES - remote node contexts exhausted. - */ -static enum sci_status sci_remote_device_da_construct(struct isci_port *iport, - struct isci_remote_device *idev) -{ - enum sci_status status; - struct domain_device *dev = idev->domain_dev; - - sci_remote_device_construct(iport, idev); - - /* - * This information is request to determine how many remote node context - * entries will be needed to store the remote node. - */ - idev->is_direct_attached = true; - status = sci_controller_allocate_remote_node_context(iport->owning_controller, - idev, - &idev->rnc.remote_node_index); - - if (status != SCI_SUCCESS) - return status; - - if (dev->dev_type == SAS_END_DEV || dev->dev_type == SATA_DEV || - (dev->tproto & SAS_PROTOCOL_STP) || dev_is_expander(dev)) - /* pass */; - else - return SCI_FAILURE_UNSUPPORTED_PROTOCOL; - - idev->connection_rate = sci_port_get_max_allowed_speed(iport); - - /* / @todo Should I assign the port width by reading all of the phys on the port? */ - idev->device_port_width = 1; - - return SCI_SUCCESS; -} - -/** - * sci_remote_device_ea_construct() - construct expander attached device - * - * Remote node context(s) is/are a global resource allocated by this - * routine, freed by sci_remote_device_destruct(). - * - * Returns: - * SCI_FAILURE_DEVICE_EXISTS - device has already been constructed. - * SCI_FAILURE_UNSUPPORTED_PROTOCOL - e.g. sas device attached to - * sata-only controller instance. - * SCI_FAILURE_INSUFFICIENT_RESOURCES - remote node contexts exhausted. - */ -static enum sci_status sci_remote_device_ea_construct(struct isci_port *iport, - struct isci_remote_device *idev) -{ - struct domain_device *dev = idev->domain_dev; - enum sci_status status; - - sci_remote_device_construct(iport, idev); - - status = sci_controller_allocate_remote_node_context(iport->owning_controller, - idev, - &idev->rnc.remote_node_index); - if (status != SCI_SUCCESS) - return status; - - if (dev->dev_type == SAS_END_DEV || dev->dev_type == SATA_DEV || - (dev->tproto & SAS_PROTOCOL_STP) || dev_is_expander(dev)) - /* pass */; - else - return SCI_FAILURE_UNSUPPORTED_PROTOCOL; - - /* - * For SAS-2 the physical link rate is actually a logical link - * rate that incorporates multiplexing. The SCU doesn't - * incorporate multiplexing and for the purposes of the - * connection the logical link rate is that same as the - * physical. Furthermore, the SAS-2 and SAS-1.1 fields overlay - * one another, so this code works for both situations. */ - idev->connection_rate = min_t(u16, sci_port_get_max_allowed_speed(iport), - dev->linkrate); - - /* / @todo Should I assign the port width by reading all of the phys on the port? */ - idev->device_port_width = 1; - - return SCI_SUCCESS; -} - -/** - * sci_remote_device_start() - This method will start the supplied remote - * device. This method enables normal IO requests to flow through to the - * remote device. - * @remote_device: This parameter specifies the device to be started. - * @timeout: This parameter specifies the number of milliseconds in which the - * start operation should complete. - * - * An indication of whether the device was successfully started. SCI_SUCCESS - * This value is returned if the device was successfully started. - * SCI_FAILURE_INVALID_PHY This value is returned if the user attempts to start - * the device when there have been no phys added to it. - */ -static enum sci_status sci_remote_device_start(struct isci_remote_device *idev, - u32 timeout) -{ - struct sci_base_state_machine *sm = &idev->sm; - enum sci_remote_device_states state = sm->current_state_id; - enum sci_status status; - - if (state != SCI_DEV_STOPPED) { - dev_warn(scirdev_to_dev(idev), "%s: in wrong state: %d\n", - __func__, state); - return SCI_FAILURE_INVALID_STATE; - } - - status = sci_remote_node_context_resume(&idev->rnc, - remote_device_resume_done, - idev); - if (status != SCI_SUCCESS) - return status; - - sci_change_state(sm, SCI_DEV_STARTING); - - return SCI_SUCCESS; -} - -static enum sci_status isci_remote_device_construct(struct isci_port *iport, - struct isci_remote_device *idev) -{ - struct isci_host *ihost = iport->isci_host; - struct domain_device *dev = idev->domain_dev; - enum sci_status status; - - if (dev->parent && dev_is_expander(dev->parent)) - status = sci_remote_device_ea_construct(iport, idev); - else - status = sci_remote_device_da_construct(iport, idev); - - if (status != SCI_SUCCESS) { - dev_dbg(&ihost->pdev->dev, "%s: construct failed: %d\n", - __func__, status); - - return status; - } - - /* start the device. */ - status = sci_remote_device_start(idev, ISCI_REMOTE_DEVICE_START_TIMEOUT); - - if (status != SCI_SUCCESS) - dev_warn(&ihost->pdev->dev, "remote device start failed: %d\n", - status); - - return status; -} - -void isci_remote_device_nuke_requests(struct isci_host *ihost, struct isci_remote_device *idev) -{ - DECLARE_COMPLETION_ONSTACK(aborted_task_completion); - - dev_dbg(&ihost->pdev->dev, - "%s: idev = %p\n", __func__, idev); - - /* Cleanup all requests pending for this device. */ - isci_terminate_pending_requests(ihost, idev); - - dev_dbg(&ihost->pdev->dev, - "%s: idev = %p, done\n", __func__, idev); -} - -/** - * This function builds the isci_remote_device when a libsas dev_found message - * is received. - * @isci_host: This parameter specifies the isci host object. - * @port: This parameter specifies the isci_port conected to this device. - * - * pointer to new isci_remote_device. - */ -static struct isci_remote_device * -isci_remote_device_alloc(struct isci_host *ihost, struct isci_port *iport) -{ - struct isci_remote_device *idev; - int i; - - for (i = 0; i < SCI_MAX_REMOTE_DEVICES; i++) { - idev = &ihost->devices[i]; - if (!test_and_set_bit(IDEV_ALLOCATED, &idev->flags)) - break; - } - - if (i >= SCI_MAX_REMOTE_DEVICES) { - dev_warn(&ihost->pdev->dev, "%s: failed\n", __func__); - return NULL; - } - - if (WARN_ONCE(!list_empty(&idev->reqs_in_process), "found requests in process\n")) - return NULL; - - if (WARN_ONCE(!list_empty(&idev->node), "found non-idle remote device\n")) - return NULL; - - return idev; -} - -void isci_remote_device_release(struct kref *kref) -{ - struct isci_remote_device *idev = container_of(kref, typeof(*idev), kref); - struct isci_host *ihost = idev->isci_port->isci_host; - - idev->domain_dev = NULL; - idev->isci_port = NULL; - clear_bit(IDEV_START_PENDING, &idev->flags); - clear_bit(IDEV_STOP_PENDING, &idev->flags); - clear_bit(IDEV_IO_READY, &idev->flags); - clear_bit(IDEV_GONE, &idev->flags); - clear_bit(IDEV_EH, &idev->flags); - smp_mb__before_clear_bit(); - clear_bit(IDEV_ALLOCATED, &idev->flags); - wake_up(&ihost->eventq); -} - -/** - * isci_remote_device_stop() - This function is called internally to stop the - * remote device. - * @isci_host: This parameter specifies the isci host object. - * @isci_device: This parameter specifies the remote device. - * - * The status of the ihost request to stop. - */ -enum sci_status isci_remote_device_stop(struct isci_host *ihost, struct isci_remote_device *idev) -{ - enum sci_status status; - unsigned long flags; - - dev_dbg(&ihost->pdev->dev, - "%s: isci_device = %p\n", __func__, idev); - - spin_lock_irqsave(&ihost->scic_lock, flags); - idev->domain_dev->lldd_dev = NULL; /* disable new lookups */ - set_bit(IDEV_GONE, &idev->flags); - spin_unlock_irqrestore(&ihost->scic_lock, flags); - - /* Kill all outstanding requests. */ - isci_remote_device_nuke_requests(ihost, idev); - - set_bit(IDEV_STOP_PENDING, &idev->flags); - - spin_lock_irqsave(&ihost->scic_lock, flags); - status = sci_remote_device_stop(idev, 50); - spin_unlock_irqrestore(&ihost->scic_lock, flags); - - /* Wait for the stop complete callback. */ - if (WARN_ONCE(status != SCI_SUCCESS, "failed to stop device\n")) - /* nothing to wait for */; - else - wait_for_device_stop(ihost, idev); - - return status; -} - -/** - * isci_remote_device_gone() - This function is called by libsas when a domain - * device is removed. - * @domain_device: This parameter specifies the libsas domain device. - * - */ -void isci_remote_device_gone(struct domain_device *dev) -{ - struct isci_host *ihost = dev_to_ihost(dev); - struct isci_remote_device *idev = dev->lldd_dev; - - dev_dbg(&ihost->pdev->dev, - "%s: domain_device = %p, isci_device = %p, isci_port = %p\n", - __func__, dev, idev, idev->isci_port); - - isci_remote_device_stop(ihost, idev); -} - - -/** - * isci_remote_device_found() - This function is called by libsas when a remote - * device is discovered. A remote device object is created and started. the - * function then sleeps until the sci core device started message is - * received. - * @domain_device: This parameter specifies the libsas domain device. - * - * status, zero indicates success. - */ -int isci_remote_device_found(struct domain_device *domain_dev) -{ - struct isci_host *isci_host = dev_to_ihost(domain_dev); - struct isci_port *isci_port; - struct isci_phy *isci_phy; - struct asd_sas_port *sas_port; - struct asd_sas_phy *sas_phy; - struct isci_remote_device *isci_device; - enum sci_status status; - - dev_dbg(&isci_host->pdev->dev, - "%s: domain_device = %p\n", __func__, domain_dev); - - wait_for_start(isci_host); - - sas_port = domain_dev->port; - sas_phy = list_first_entry(&sas_port->phy_list, struct asd_sas_phy, - port_phy_el); - isci_phy = to_iphy(sas_phy); - isci_port = isci_phy->isci_port; - - /* we are being called for a device on this port, - * so it has to come up eventually - */ - wait_for_completion(&isci_port->start_complete); - - if ((isci_stopping == isci_port_get_state(isci_port)) || - (isci_stopped == isci_port_get_state(isci_port))) - return -ENODEV; - - isci_device = isci_remote_device_alloc(isci_host, isci_port); - if (!isci_device) - return -ENODEV; - - kref_init(&isci_device->kref); - INIT_LIST_HEAD(&isci_device->node); - - spin_lock_irq(&isci_host->scic_lock); - isci_device->domain_dev = domain_dev; - isci_device->isci_port = isci_port; - list_add_tail(&isci_device->node, &isci_port->remote_dev_list); - - set_bit(IDEV_START_PENDING, &isci_device->flags); - status = isci_remote_device_construct(isci_port, isci_device); - - dev_dbg(&isci_host->pdev->dev, - "%s: isci_device = %p\n", - __func__, isci_device); - - if (status == SCI_SUCCESS) { - /* device came up, advertise it to the world */ - domain_dev->lldd_dev = isci_device; - } else - isci_put_device(isci_device); - spin_unlock_irq(&isci_host->scic_lock); - - /* wait for the device ready callback. */ - wait_for_device_start(isci_host, isci_device); - - return status == SCI_SUCCESS ? 0 : -ENODEV; -} -/** - * isci_device_is_reset_pending() - This function will check if there is any - * pending reset condition on the device. - * @request: This parameter is the isci_device object. - * - * true if there is a reset pending for the device. - */ -bool isci_device_is_reset_pending( - struct isci_host *isci_host, - struct isci_remote_device *isci_device) -{ - struct isci_request *isci_request; - struct isci_request *tmp_req; - bool reset_is_pending = false; - unsigned long flags; - - dev_dbg(&isci_host->pdev->dev, - "%s: isci_device = %p\n", __func__, isci_device); - - spin_lock_irqsave(&isci_host->scic_lock, flags); - - /* Check for reset on all pending requests. */ - list_for_each_entry_safe(isci_request, tmp_req, - &isci_device->reqs_in_process, dev_node) { - dev_dbg(&isci_host->pdev->dev, - "%s: isci_device = %p request = %p\n", - __func__, isci_device, isci_request); - - if (isci_request->ttype == io_task) { - struct sas_task *task = isci_request_access_task( - isci_request); - - spin_lock(&task->task_state_lock); - if (task->task_state_flags & SAS_TASK_NEED_DEV_RESET) - reset_is_pending = true; - spin_unlock(&task->task_state_lock); - } - } - - spin_unlock_irqrestore(&isci_host->scic_lock, flags); - - dev_dbg(&isci_host->pdev->dev, - "%s: isci_device = %p reset_is_pending = %d\n", - __func__, isci_device, reset_is_pending); - - return reset_is_pending; -} - -/** - * isci_device_clear_reset_pending() - This function will clear if any pending - * reset condition flags on the device. - * @request: This parameter is the isci_device object. - * - * true if there is a reset pending for the device. - */ -void isci_device_clear_reset_pending(struct isci_host *ihost, struct isci_remote_device *idev) -{ - struct isci_request *isci_request; - struct isci_request *tmp_req; - unsigned long flags = 0; - - dev_dbg(&ihost->pdev->dev, "%s: idev=%p, ihost=%p\n", - __func__, idev, ihost); - - spin_lock_irqsave(&ihost->scic_lock, flags); - - /* Clear reset pending on all pending requests. */ - list_for_each_entry_safe(isci_request, tmp_req, - &idev->reqs_in_process, dev_node) { - dev_dbg(&ihost->pdev->dev, "%s: idev = %p request = %p\n", - __func__, idev, isci_request); - - if (isci_request->ttype == io_task) { - - unsigned long flags2; - struct sas_task *task = isci_request_access_task( - isci_request); - - spin_lock_irqsave(&task->task_state_lock, flags2); - task->task_state_flags &= ~SAS_TASK_NEED_DEV_RESET; - spin_unlock_irqrestore(&task->task_state_lock, flags2); - } - } - spin_unlock_irqrestore(&ihost->scic_lock, flags); -} diff --git a/trunk/drivers/scsi/isci/remote_device.h b/trunk/drivers/scsi/isci/remote_device.h deleted file mode 100644 index 57ccfc3d6ad3..000000000000 --- a/trunk/drivers/scsi/isci/remote_device.h +++ /dev/null @@ -1,352 +0,0 @@ -/* - * This file is provided under a dual BSD/GPLv2 license. When using or - * redistributing this file, you may do so under either license. - * - * GPL LICENSE SUMMARY - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License 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., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. - * The full GNU General Public License is included in this distribution - * in the file called LICENSE.GPL. - * - * BSD LICENSE - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Intel Corporation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _ISCI_REMOTE_DEVICE_H_ -#define _ISCI_REMOTE_DEVICE_H_ -#include -#include -#include "scu_remote_node_context.h" -#include "remote_node_context.h" -#include "port.h" - -enum sci_remote_device_not_ready_reason_code { - SCIC_REMOTE_DEVICE_NOT_READY_START_REQUESTED, - SCIC_REMOTE_DEVICE_NOT_READY_STOP_REQUESTED, - SCIC_REMOTE_DEVICE_NOT_READY_SATA_REQUEST_STARTED, - SCIC_REMOTE_DEVICE_NOT_READY_SATA_SDB_ERROR_FIS_RECEIVED, - SCIC_REMOTE_DEVICE_NOT_READY_SMP_REQUEST_STARTED, - SCIC_REMOTE_DEVICE_NOT_READY_REASON_CODE_MAX -}; - -/** - * isci_remote_device - isci representation of a sas expander / end point - * @device_port_width: hw setting for number of simultaneous connections - * @connection_rate: per-taskcontext connection rate for this device - * @working_request: SATA requests have no tag we for unaccelerated - * protocols we need a method to associate unsolicited - * frames with a pending request - */ -struct isci_remote_device { - #define IDEV_START_PENDING 0 - #define IDEV_STOP_PENDING 1 - #define IDEV_ALLOCATED 2 - #define IDEV_EH 3 - #define IDEV_GONE 4 - #define IDEV_IO_READY 5 - #define IDEV_IO_NCQERROR 6 - unsigned long flags; - struct kref kref; - struct isci_port *isci_port; - struct domain_device *domain_dev; - struct list_head node; - struct list_head reqs_in_process; - struct sci_base_state_machine sm; - u32 device_port_width; - enum sas_linkrate connection_rate; - bool is_direct_attached; - struct isci_port *owning_port; - struct sci_remote_node_context rnc; - /* XXX unify with device reference counting and delete */ - u32 started_request_count; - struct isci_request *working_request; - u32 not_ready_reason; -}; - -#define ISCI_REMOTE_DEVICE_START_TIMEOUT 5000 - -/* device reference routines must be called under sci_lock */ -static inline struct isci_remote_device *isci_lookup_device(struct domain_device *dev) -{ - struct isci_remote_device *idev = dev->lldd_dev; - - if (idev && !test_bit(IDEV_GONE, &idev->flags)) { - kref_get(&idev->kref); - return idev; - } - - return NULL; -} - -void isci_remote_device_release(struct kref *kref); -static inline void isci_put_device(struct isci_remote_device *idev) -{ - if (idev) - kref_put(&idev->kref, isci_remote_device_release); -} - -enum sci_status isci_remote_device_stop(struct isci_host *ihost, - struct isci_remote_device *idev); -void isci_remote_device_nuke_requests(struct isci_host *ihost, - struct isci_remote_device *idev); -void isci_remote_device_gone(struct domain_device *domain_dev); -int isci_remote_device_found(struct domain_device *domain_dev); -bool isci_device_is_reset_pending(struct isci_host *ihost, - struct isci_remote_device *idev); -void isci_device_clear_reset_pending(struct isci_host *ihost, - struct isci_remote_device *idev); -/** - * sci_remote_device_stop() - This method will stop both transmission and - * reception of link activity for the supplied remote device. This method - * disables normal IO requests from flowing through to the remote device. - * @remote_device: This parameter specifies the device to be stopped. - * @timeout: This parameter specifies the number of milliseconds in which the - * stop operation should complete. - * - * An indication of whether the device was successfully stopped. SCI_SUCCESS - * This value is returned if the transmission and reception for the device was - * successfully stopped. - */ -enum sci_status sci_remote_device_stop( - struct isci_remote_device *idev, - u32 timeout); - -/** - * sci_remote_device_reset() - This method will reset the device making it - * ready for operation. This method must be called anytime the device is - * reset either through a SMP phy control or a port hard reset request. - * @remote_device: This parameter specifies the device to be reset. - * - * This method does not actually cause the device hardware to be reset. This - * method resets the software object so that it will be operational after a - * device hardware reset completes. An indication of whether the device reset - * was accepted. SCI_SUCCESS This value is returned if the device reset is - * started. - */ -enum sci_status sci_remote_device_reset( - struct isci_remote_device *idev); - -/** - * sci_remote_device_reset_complete() - This method informs the device object - * that the reset operation is complete and the device can resume operation - * again. - * @remote_device: This parameter specifies the device which is to be informed - * of the reset complete operation. - * - * An indication that the device is resuming operation. SCI_SUCCESS the device - * is resuming operation. - */ -enum sci_status sci_remote_device_reset_complete( - struct isci_remote_device *idev); - -/** - * enum sci_remote_device_states - This enumeration depicts all the states - * for the common remote device state machine. - * - * - */ -enum sci_remote_device_states { - /** - * Simply the initial state for the base remote device state machine. - */ - SCI_DEV_INITIAL, - - /** - * This state indicates that the remote device has successfully been - * stopped. In this state no new IO operations are permitted. - * This state is entered from the INITIAL state. - * This state is entered from the STOPPING state. - */ - SCI_DEV_STOPPED, - - /** - * This state indicates the the remote device is in the process of - * becoming ready (i.e. starting). In this state no new IO operations - * are permitted. - * This state is entered from the STOPPED state. - */ - SCI_DEV_STARTING, - - /** - * This state indicates the remote device is now ready. Thus, the user - * is able to perform IO operations on the remote device. - * This state is entered from the STARTING state. - */ - SCI_DEV_READY, - - /** - * This is the idle substate for the stp remote device. When there are no - * active IO for the device it is is in this state. - */ - SCI_STP_DEV_IDLE, - - /** - * This is the command state for for the STP remote device. This state is - * entered when the device is processing a non-NCQ command. The device object - * will fail any new start IO requests until this command is complete. - */ - SCI_STP_DEV_CMD, - - /** - * This is the NCQ state for the STP remote device. This state is entered - * when the device is processing an NCQ reuqest. It will remain in this state - * so long as there is one or more NCQ requests being processed. - */ - SCI_STP_DEV_NCQ, - - /** - * This is the NCQ error state for the STP remote device. This state is - * entered when an SDB error FIS is received by the device object while in the - * NCQ state. The device object will only accept a READ LOG command while in - * this state. - */ - SCI_STP_DEV_NCQ_ERROR, - - /** - * This is the READY substate indicates the device is waiting for the RESET task - * coming to be recovered from certain hardware specific error. - */ - SCI_STP_DEV_AWAIT_RESET, - - /** - * This is the ready operational substate for the remote device. This is the - * normal operational state for a remote device. - */ - SCI_SMP_DEV_IDLE, - - /** - * This is the suspended state for the remote device. This is the state that - * the device is placed in when a RNC suspend is received by the SCU hardware. - */ - SCI_SMP_DEV_CMD, - - /** - * This state indicates that the remote device is in the process of - * stopping. In this state no new IO operations are permitted, but - * existing IO operations are allowed to complete. - * This state is entered from the READY state. - * This state is entered from the FAILED state. - */ - SCI_DEV_STOPPING, - - /** - * This state indicates that the remote device has failed. - * In this state no new IO operations are permitted. - * This state is entered from the INITIALIZING state. - * This state is entered from the READY state. - */ - SCI_DEV_FAILED, - - /** - * This state indicates the device is being reset. - * In this state no new IO operations are permitted. - * This state is entered from the READY state. - */ - SCI_DEV_RESETTING, - - /** - * Simply the final state for the base remote device state machine. - */ - SCI_DEV_FINAL, -}; - -static inline struct isci_remote_device *rnc_to_dev(struct sci_remote_node_context *rnc) -{ - struct isci_remote_device *idev; - - idev = container_of(rnc, typeof(*idev), rnc); - - return idev; -} - -static inline bool dev_is_expander(struct domain_device *dev) -{ - return dev->dev_type == EDGE_DEV || dev->dev_type == FANOUT_DEV; -} - -static inline void sci_remote_device_decrement_request_count(struct isci_remote_device *idev) -{ - /* XXX delete this voodoo when converting to the top-level device - * reference count - */ - if (WARN_ONCE(idev->started_request_count == 0, - "%s: tried to decrement started_request_count past 0!?", - __func__)) - /* pass */; - else - idev->started_request_count--; -} - -enum sci_status sci_remote_device_frame_handler( - struct isci_remote_device *idev, - u32 frame_index); - -enum sci_status sci_remote_device_event_handler( - struct isci_remote_device *idev, - u32 event_code); - -enum sci_status sci_remote_device_start_io( - struct isci_host *ihost, - struct isci_remote_device *idev, - struct isci_request *ireq); - -enum sci_status sci_remote_device_start_task( - struct isci_host *ihost, - struct isci_remote_device *idev, - struct isci_request *ireq); - -enum sci_status sci_remote_device_complete_io( - struct isci_host *ihost, - struct isci_remote_device *idev, - struct isci_request *ireq); - -enum sci_status sci_remote_device_suspend( - struct isci_remote_device *idev, - u32 suspend_type); - -void sci_remote_device_post_request( - struct isci_remote_device *idev, - u32 request); - -#endif /* !defined(_ISCI_REMOTE_DEVICE_H_) */ diff --git a/trunk/drivers/scsi/isci/remote_node_context.c b/trunk/drivers/scsi/isci/remote_node_context.c deleted file mode 100644 index 748e8339d1ec..000000000000 --- a/trunk/drivers/scsi/isci/remote_node_context.c +++ /dev/null @@ -1,627 +0,0 @@ -/* - * This file is provided under a dual BSD/GPLv2 license. When using or - * redistributing this file, you may do so under either license. - * - * GPL LICENSE SUMMARY - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License 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., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. - * The full GNU General Public License is included in this distribution - * in the file called LICENSE.GPL. - * - * BSD LICENSE - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Intel Corporation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "host.h" -#include "isci.h" -#include "remote_device.h" -#include "remote_node_context.h" -#include "scu_event_codes.h" -#include "scu_task_context.h" - - -/** - * - * @sci_rnc: The RNC for which the is posted request is being made. - * - * This method will return true if the RNC is not in the initial state. In all - * other states the RNC is considered active and this will return true. The - * destroy request of the state machine drives the RNC back to the initial - * state. If the state machine changes then this routine will also have to be - * changed. bool true if the state machine is not in the initial state false if - * the state machine is in the initial state - */ - -/** - * - * @sci_rnc: The state of the remote node context object to check. - * - * This method will return true if the remote node context is in a READY state - * otherwise it will return false bool true if the remote node context is in - * the ready state. false if the remote node context is not in the ready state. - */ -bool sci_remote_node_context_is_ready( - struct sci_remote_node_context *sci_rnc) -{ - u32 current_state = sci_rnc->sm.current_state_id; - - if (current_state == SCI_RNC_READY) { - return true; - } - - return false; -} - -static union scu_remote_node_context *sci_rnc_by_id(struct isci_host *ihost, u16 id) -{ - if (id < ihost->remote_node_entries && - ihost->device_table[id]) - return &ihost->remote_node_context_table[id]; - - return NULL; -} - -static void sci_remote_node_context_construct_buffer(struct sci_remote_node_context *sci_rnc) -{ - struct isci_remote_device *idev = rnc_to_dev(sci_rnc); - struct domain_device *dev = idev->domain_dev; - int rni = sci_rnc->remote_node_index; - union scu_remote_node_context *rnc; - struct isci_host *ihost; - __le64 sas_addr; - - ihost = idev->owning_port->owning_controller; - rnc = sci_rnc_by_id(ihost, rni); - - memset(rnc, 0, sizeof(union scu_remote_node_context) - * sci_remote_device_node_count(idev)); - - rnc->ssp.remote_node_index = rni; - rnc->ssp.remote_node_port_width = idev->device_port_width; - rnc->ssp.logical_port_index = idev->owning_port->physical_port_index; - - /* sas address is __be64, context ram format is __le64 */ - sas_addr = cpu_to_le64(SAS_ADDR(dev->sas_addr)); - rnc->ssp.remote_sas_address_hi = upper_32_bits(sas_addr); - rnc->ssp.remote_sas_address_lo = lower_32_bits(sas_addr); - - rnc->ssp.nexus_loss_timer_enable = true; - rnc->ssp.check_bit = false; - rnc->ssp.is_valid = false; - rnc->ssp.is_remote_node_context = true; - rnc->ssp.function_number = 0; - - rnc->ssp.arbitration_wait_time = 0; - - if (dev->dev_type == SATA_DEV || (dev->tproto & SAS_PROTOCOL_STP)) { - rnc->ssp.connection_occupancy_timeout = - ihost->user_parameters.stp_max_occupancy_timeout; - rnc->ssp.connection_inactivity_timeout = - ihost->user_parameters.stp_inactivity_timeout; - } else { - rnc->ssp.connection_occupancy_timeout = - ihost->user_parameters.ssp_max_occupancy_timeout; - rnc->ssp.connection_inactivity_timeout = - ihost->user_parameters.ssp_inactivity_timeout; - } - - rnc->ssp.initial_arbitration_wait_time = 0; - - /* Open Address Frame Parameters */ - rnc->ssp.oaf_connection_rate = idev->connection_rate; - rnc->ssp.oaf_features = 0; - rnc->ssp.oaf_source_zone_group = 0; - rnc->ssp.oaf_more_compatibility_features = 0; -} - -/** - * - * @sci_rnc: - * @callback: - * @callback_parameter: - * - * This method will setup the remote node context object so it will transition - * to its ready state. If the remote node context is already setup to - * transition to its final state then this function does nothing. none - */ -static void sci_remote_node_context_setup_to_resume( - struct sci_remote_node_context *sci_rnc, - scics_sds_remote_node_context_callback callback, - void *callback_parameter) -{ - if (sci_rnc->destination_state != SCIC_SDS_REMOTE_NODE_DESTINATION_STATE_FINAL) { - sci_rnc->destination_state = SCIC_SDS_REMOTE_NODE_DESTINATION_STATE_READY; - sci_rnc->user_callback = callback; - sci_rnc->user_cookie = callback_parameter; - } -} - -static void sci_remote_node_context_setup_to_destory( - struct sci_remote_node_context *sci_rnc, - scics_sds_remote_node_context_callback callback, - void *callback_parameter) -{ - sci_rnc->destination_state = SCIC_SDS_REMOTE_NODE_DESTINATION_STATE_FINAL; - sci_rnc->user_callback = callback; - sci_rnc->user_cookie = callback_parameter; -} - -/** - * - * - * This method just calls the user callback function and then resets the - * callback. - */ -static void sci_remote_node_context_notify_user( - struct sci_remote_node_context *rnc) -{ - if (rnc->user_callback != NULL) { - (*rnc->user_callback)(rnc->user_cookie); - - rnc->user_callback = NULL; - rnc->user_cookie = NULL; - } -} - -static void sci_remote_node_context_continue_state_transitions(struct sci_remote_node_context *rnc) -{ - if (rnc->destination_state == SCIC_SDS_REMOTE_NODE_DESTINATION_STATE_READY) - sci_remote_node_context_resume(rnc, rnc->user_callback, - rnc->user_cookie); -} - -static void sci_remote_node_context_validate_context_buffer(struct sci_remote_node_context *sci_rnc) -{ - union scu_remote_node_context *rnc_buffer; - struct isci_remote_device *idev = rnc_to_dev(sci_rnc); - struct domain_device *dev = idev->domain_dev; - struct isci_host *ihost = idev->owning_port->owning_controller; - - rnc_buffer = sci_rnc_by_id(ihost, sci_rnc->remote_node_index); - - rnc_buffer->ssp.is_valid = true; - - if (!idev->is_direct_attached && - (dev->dev_type == SATA_DEV || (dev->tproto & SAS_PROTOCOL_STP))) { - sci_remote_device_post_request(idev, SCU_CONTEXT_COMMAND_POST_RNC_96); - } else { - sci_remote_device_post_request(idev, SCU_CONTEXT_COMMAND_POST_RNC_32); - - if (idev->is_direct_attached) - sci_port_setup_transports(idev->owning_port, - sci_rnc->remote_node_index); - } -} - -static void sci_remote_node_context_invalidate_context_buffer(struct sci_remote_node_context *sci_rnc) -{ - union scu_remote_node_context *rnc_buffer; - struct isci_remote_device *idev = rnc_to_dev(sci_rnc); - struct isci_host *ihost = idev->owning_port->owning_controller; - - rnc_buffer = sci_rnc_by_id(ihost, sci_rnc->remote_node_index); - - rnc_buffer->ssp.is_valid = false; - - sci_remote_device_post_request(rnc_to_dev(sci_rnc), - SCU_CONTEXT_COMMAND_POST_RNC_INVALIDATE); -} - -static void sci_remote_node_context_initial_state_enter(struct sci_base_state_machine *sm) -{ - struct sci_remote_node_context *rnc = container_of(sm, typeof(*rnc), sm); - - /* Check to see if we have gotten back to the initial state because - * someone requested to destroy the remote node context object. - */ - if (sm->previous_state_id == SCI_RNC_INVALIDATING) { - rnc->destination_state = SCIC_SDS_REMOTE_NODE_DESTINATION_STATE_UNSPECIFIED; - sci_remote_node_context_notify_user(rnc); - } -} - -static void sci_remote_node_context_posting_state_enter(struct sci_base_state_machine *sm) -{ - struct sci_remote_node_context *sci_rnc = container_of(sm, typeof(*sci_rnc), sm); - - sci_remote_node_context_validate_context_buffer(sci_rnc); -} - -static void sci_remote_node_context_invalidating_state_enter(struct sci_base_state_machine *sm) -{ - struct sci_remote_node_context *rnc = container_of(sm, typeof(*rnc), sm); - - sci_remote_node_context_invalidate_context_buffer(rnc); -} - -static void sci_remote_node_context_resuming_state_enter(struct sci_base_state_machine *sm) -{ - struct sci_remote_node_context *rnc = container_of(sm, typeof(*rnc), sm); - struct isci_remote_device *idev; - struct domain_device *dev; - - idev = rnc_to_dev(rnc); - dev = idev->domain_dev; - - /* - * For direct attached SATA devices we need to clear the TLCR - * NCQ to TCi tag mapping on the phy and in cases where we - * resume because of a target reset we also need to update - * the STPTLDARNI register with the RNi of the device - */ - if ((dev->dev_type == SATA_DEV || (dev->tproto & SAS_PROTOCOL_STP)) && - idev->is_direct_attached) - sci_port_setup_transports(idev->owning_port, - rnc->remote_node_index); - - sci_remote_device_post_request(idev, SCU_CONTEXT_COMMAND_POST_RNC_RESUME); -} - -static void sci_remote_node_context_ready_state_enter(struct sci_base_state_machine *sm) -{ - struct sci_remote_node_context *rnc = container_of(sm, typeof(*rnc), sm); - - rnc->destination_state = SCIC_SDS_REMOTE_NODE_DESTINATION_STATE_UNSPECIFIED; - - if (rnc->user_callback) - sci_remote_node_context_notify_user(rnc); -} - -static void sci_remote_node_context_tx_suspended_state_enter(struct sci_base_state_machine *sm) -{ - struct sci_remote_node_context *rnc = container_of(sm, typeof(*rnc), sm); - - sci_remote_node_context_continue_state_transitions(rnc); -} - -static void sci_remote_node_context_tx_rx_suspended_state_enter(struct sci_base_state_machine *sm) -{ - struct sci_remote_node_context *rnc = container_of(sm, typeof(*rnc), sm); - - sci_remote_node_context_continue_state_transitions(rnc); -} - -static const struct sci_base_state sci_remote_node_context_state_table[] = { - [SCI_RNC_INITIAL] = { - .enter_state = sci_remote_node_context_initial_state_enter, - }, - [SCI_RNC_POSTING] = { - .enter_state = sci_remote_node_context_posting_state_enter, - }, - [SCI_RNC_INVALIDATING] = { - .enter_state = sci_remote_node_context_invalidating_state_enter, - }, - [SCI_RNC_RESUMING] = { - .enter_state = sci_remote_node_context_resuming_state_enter, - }, - [SCI_RNC_READY] = { - .enter_state = sci_remote_node_context_ready_state_enter, - }, - [SCI_RNC_TX_SUSPENDED] = { - .enter_state = sci_remote_node_context_tx_suspended_state_enter, - }, - [SCI_RNC_TX_RX_SUSPENDED] = { - .enter_state = sci_remote_node_context_tx_rx_suspended_state_enter, - }, - [SCI_RNC_AWAIT_SUSPENSION] = { }, -}; - -void sci_remote_node_context_construct(struct sci_remote_node_context *rnc, - u16 remote_node_index) -{ - memset(rnc, 0, sizeof(struct sci_remote_node_context)); - - rnc->remote_node_index = remote_node_index; - rnc->destination_state = SCIC_SDS_REMOTE_NODE_DESTINATION_STATE_UNSPECIFIED; - - sci_init_sm(&rnc->sm, sci_remote_node_context_state_table, SCI_RNC_INITIAL); -} - -enum sci_status sci_remote_node_context_event_handler(struct sci_remote_node_context *sci_rnc, - u32 event_code) -{ - enum scis_sds_remote_node_context_states state; - - state = sci_rnc->sm.current_state_id; - switch (state) { - case SCI_RNC_POSTING: - switch (scu_get_event_code(event_code)) { - case SCU_EVENT_POST_RNC_COMPLETE: - sci_change_state(&sci_rnc->sm, SCI_RNC_READY); - break; - default: - goto out; - } - break; - case SCI_RNC_INVALIDATING: - if (scu_get_event_code(event_code) == SCU_EVENT_POST_RNC_INVALIDATE_COMPLETE) { - if (sci_rnc->destination_state == SCIC_SDS_REMOTE_NODE_DESTINATION_STATE_FINAL) - state = SCI_RNC_INITIAL; - else - state = SCI_RNC_POSTING; - sci_change_state(&sci_rnc->sm, state); - } else { - switch (scu_get_event_type(event_code)) { - case SCU_EVENT_TYPE_RNC_SUSPEND_TX: - case SCU_EVENT_TYPE_RNC_SUSPEND_TX_RX: - /* We really dont care if the hardware is going to suspend - * the device since it's being invalidated anyway */ - dev_dbg(scirdev_to_dev(rnc_to_dev(sci_rnc)), - "%s: SCIC Remote Node Context 0x%p was " - "suspeneded by hardware while being " - "invalidated.\n", __func__, sci_rnc); - break; - default: - goto out; - } - } - break; - case SCI_RNC_RESUMING: - if (scu_get_event_code(event_code) == SCU_EVENT_POST_RCN_RELEASE) { - sci_change_state(&sci_rnc->sm, SCI_RNC_READY); - } else { - switch (scu_get_event_type(event_code)) { - case SCU_EVENT_TYPE_RNC_SUSPEND_TX: - case SCU_EVENT_TYPE_RNC_SUSPEND_TX_RX: - /* We really dont care if the hardware is going to suspend - * the device since it's being resumed anyway */ - dev_dbg(scirdev_to_dev(rnc_to_dev(sci_rnc)), - "%s: SCIC Remote Node Context 0x%p was " - "suspeneded by hardware while being resumed.\n", - __func__, sci_rnc); - break; - default: - goto out; - } - } - break; - case SCI_RNC_READY: - switch (scu_get_event_type(event_code)) { - case SCU_EVENT_TL_RNC_SUSPEND_TX: - sci_change_state(&sci_rnc->sm, SCI_RNC_TX_SUSPENDED); - sci_rnc->suspension_code = scu_get_event_specifier(event_code); - break; - case SCU_EVENT_TL_RNC_SUSPEND_TX_RX: - sci_change_state(&sci_rnc->sm, SCI_RNC_TX_RX_SUSPENDED); - sci_rnc->suspension_code = scu_get_event_specifier(event_code); - break; - default: - goto out; - } - break; - case SCI_RNC_AWAIT_SUSPENSION: - switch (scu_get_event_type(event_code)) { - case SCU_EVENT_TL_RNC_SUSPEND_TX: - sci_change_state(&sci_rnc->sm, SCI_RNC_TX_SUSPENDED); - sci_rnc->suspension_code = scu_get_event_specifier(event_code); - break; - case SCU_EVENT_TL_RNC_SUSPEND_TX_RX: - sci_change_state(&sci_rnc->sm, SCI_RNC_TX_RX_SUSPENDED); - sci_rnc->suspension_code = scu_get_event_specifier(event_code); - break; - default: - goto out; - } - break; - default: - dev_warn(scirdev_to_dev(rnc_to_dev(sci_rnc)), - "%s: invalid state %d\n", __func__, state); - return SCI_FAILURE_INVALID_STATE; - } - return SCI_SUCCESS; - - out: - dev_warn(scirdev_to_dev(rnc_to_dev(sci_rnc)), - "%s: code: %#x state: %d\n", __func__, event_code, state); - return SCI_FAILURE; - -} - -enum sci_status sci_remote_node_context_destruct(struct sci_remote_node_context *sci_rnc, - scics_sds_remote_node_context_callback cb_fn, - void *cb_p) -{ - enum scis_sds_remote_node_context_states state; - - state = sci_rnc->sm.current_state_id; - switch (state) { - case SCI_RNC_INVALIDATING: - sci_remote_node_context_setup_to_destory(sci_rnc, cb_fn, cb_p); - return SCI_SUCCESS; - case SCI_RNC_POSTING: - case SCI_RNC_RESUMING: - case SCI_RNC_READY: - case SCI_RNC_TX_SUSPENDED: - case SCI_RNC_TX_RX_SUSPENDED: - case SCI_RNC_AWAIT_SUSPENSION: - sci_remote_node_context_setup_to_destory(sci_rnc, cb_fn, cb_p); - sci_change_state(&sci_rnc->sm, SCI_RNC_INVALIDATING); - return SCI_SUCCESS; - case SCI_RNC_INITIAL: - dev_warn(scirdev_to_dev(rnc_to_dev(sci_rnc)), - "%s: invalid state %d\n", __func__, state); - /* We have decided that the destruct request on the remote node context - * can not fail since it is either in the initial/destroyed state or is - * can be destroyed. - */ - return SCI_SUCCESS; - default: - dev_warn(scirdev_to_dev(rnc_to_dev(sci_rnc)), - "%s: invalid state %d\n", __func__, state); - return SCI_FAILURE_INVALID_STATE; - } -} - -enum sci_status sci_remote_node_context_suspend(struct sci_remote_node_context *sci_rnc, - u32 suspend_type, - scics_sds_remote_node_context_callback cb_fn, - void *cb_p) -{ - enum scis_sds_remote_node_context_states state; - - state = sci_rnc->sm.current_state_id; - if (state != SCI_RNC_READY) { - dev_warn(scirdev_to_dev(rnc_to_dev(sci_rnc)), - "%s: invalid state %d\n", __func__, state); - return SCI_FAILURE_INVALID_STATE; - } - - sci_rnc->user_callback = cb_fn; - sci_rnc->user_cookie = cb_p; - sci_rnc->suspension_code = suspend_type; - - if (suspend_type == SCI_SOFTWARE_SUSPENSION) { - sci_remote_device_post_request(rnc_to_dev(sci_rnc), - SCU_CONTEXT_COMMAND_POST_RNC_SUSPEND_TX); - } - - sci_change_state(&sci_rnc->sm, SCI_RNC_AWAIT_SUSPENSION); - return SCI_SUCCESS; -} - -enum sci_status sci_remote_node_context_resume(struct sci_remote_node_context *sci_rnc, - scics_sds_remote_node_context_callback cb_fn, - void *cb_p) -{ - enum scis_sds_remote_node_context_states state; - - state = sci_rnc->sm.current_state_id; - switch (state) { - case SCI_RNC_INITIAL: - if (sci_rnc->remote_node_index == SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX) - return SCI_FAILURE_INVALID_STATE; - - sci_remote_node_context_setup_to_resume(sci_rnc, cb_fn, cb_p); - sci_remote_node_context_construct_buffer(sci_rnc); - sci_change_state(&sci_rnc->sm, SCI_RNC_POSTING); - return SCI_SUCCESS; - case SCI_RNC_POSTING: - case SCI_RNC_INVALIDATING: - case SCI_RNC_RESUMING: - if (sci_rnc->destination_state != SCIC_SDS_REMOTE_NODE_DESTINATION_STATE_READY) - return SCI_FAILURE_INVALID_STATE; - - sci_rnc->user_callback = cb_fn; - sci_rnc->user_cookie = cb_p; - return SCI_SUCCESS; - case SCI_RNC_TX_SUSPENDED: { - struct isci_remote_device *idev = rnc_to_dev(sci_rnc); - struct domain_device *dev = idev->domain_dev; - - sci_remote_node_context_setup_to_resume(sci_rnc, cb_fn, cb_p); - - /* TODO: consider adding a resume action of NONE, INVALIDATE, WRITE_TLCR */ - if (dev->dev_type == SAS_END_DEV || dev_is_expander(dev)) - sci_change_state(&sci_rnc->sm, SCI_RNC_RESUMING); - else if (dev->dev_type == SATA_DEV || (dev->tproto & SAS_PROTOCOL_STP)) { - if (idev->is_direct_attached) { - /* @todo Fix this since I am being silly in writing to the STPTLDARNI register. */ - sci_change_state(&sci_rnc->sm, SCI_RNC_RESUMING); - } else { - sci_change_state(&sci_rnc->sm, SCI_RNC_INVALIDATING); - } - } else - return SCI_FAILURE; - return SCI_SUCCESS; - } - case SCI_RNC_TX_RX_SUSPENDED: - sci_remote_node_context_setup_to_resume(sci_rnc, cb_fn, cb_p); - sci_change_state(&sci_rnc->sm, SCI_RNC_RESUMING); - return SCI_FAILURE_INVALID_STATE; - case SCI_RNC_AWAIT_SUSPENSION: - sci_remote_node_context_setup_to_resume(sci_rnc, cb_fn, cb_p); - return SCI_SUCCESS; - default: - dev_warn(scirdev_to_dev(rnc_to_dev(sci_rnc)), - "%s: invalid state %d\n", __func__, state); - return SCI_FAILURE_INVALID_STATE; - } -} - -enum sci_status sci_remote_node_context_start_io(struct sci_remote_node_context *sci_rnc, - struct isci_request *ireq) -{ - enum scis_sds_remote_node_context_states state; - - state = sci_rnc->sm.current_state_id; - - switch (state) { - case SCI_RNC_READY: - return SCI_SUCCESS; - case SCI_RNC_TX_SUSPENDED: - case SCI_RNC_TX_RX_SUSPENDED: - case SCI_RNC_AWAIT_SUSPENSION: - dev_warn(scirdev_to_dev(rnc_to_dev(sci_rnc)), - "%s: invalid state %d\n", __func__, state); - return SCI_FAILURE_REMOTE_DEVICE_RESET_REQUIRED; - default: - break; - } - dev_dbg(scirdev_to_dev(rnc_to_dev(sci_rnc)), - "%s: requested to start IO while still resuming, %d\n", - __func__, state); - return SCI_FAILURE_INVALID_STATE; -} - -enum sci_status sci_remote_node_context_start_task(struct sci_remote_node_context *sci_rnc, - struct isci_request *ireq) -{ - enum scis_sds_remote_node_context_states state; - - state = sci_rnc->sm.current_state_id; - switch (state) { - case SCI_RNC_RESUMING: - case SCI_RNC_READY: - case SCI_RNC_AWAIT_SUSPENSION: - return SCI_SUCCESS; - case SCI_RNC_TX_SUSPENDED: - case SCI_RNC_TX_RX_SUSPENDED: - sci_remote_node_context_resume(sci_rnc, NULL, NULL); - return SCI_SUCCESS; - default: - dev_warn(scirdev_to_dev(rnc_to_dev(sci_rnc)), - "%s: invalid state %d\n", __func__, state); - return SCI_FAILURE_INVALID_STATE; - } -} diff --git a/trunk/drivers/scsi/isci/remote_node_context.h b/trunk/drivers/scsi/isci/remote_node_context.h deleted file mode 100644 index 41580ad12520..000000000000 --- a/trunk/drivers/scsi/isci/remote_node_context.h +++ /dev/null @@ -1,224 +0,0 @@ -/* - * This file is provided under a dual BSD/GPLv2 license. When using or - * redistributing this file, you may do so under either license. - * - * GPL LICENSE SUMMARY - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License 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., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. - * The full GNU General Public License is included in this distribution - * in the file called LICENSE.GPL. - * - * BSD LICENSE - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Intel Corporation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _SCIC_SDS_REMOTE_NODE_CONTEXT_H_ -#define _SCIC_SDS_REMOTE_NODE_CONTEXT_H_ - -/** - * This file contains the structures, constants, and prototypes associated with - * the remote node context in the silicon. It exists to model and manage - * the remote node context in the silicon. - * - * - */ - -#include "isci.h" - -/** - * - * - * This constant represents an invalid remote device id, it is used to program - * the STPDARNI register so the driver knows when it has received a SIGNATURE - * FIS from the SCU. - */ -#define SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX 0x0FFF - -#define SCU_HARDWARE_SUSPENSION (0) -#define SCI_SOFTWARE_SUSPENSION (1) - -struct isci_request; -struct isci_remote_device; -struct sci_remote_node_context; - -typedef void (*scics_sds_remote_node_context_callback)(void *); - -/** - * This is the enumeration of the remote node context states. - */ -enum scis_sds_remote_node_context_states { - /** - * This state is the initial state for a remote node context. On a resume - * request the remote node context will transition to the posting state. - */ - SCI_RNC_INITIAL, - - /** - * This is a transition state that posts the RNi to the hardware. Once the RNC - * is posted the remote node context will be made ready. - */ - SCI_RNC_POSTING, - - /** - * This is a transition state that will post an RNC invalidate to the - * hardware. Once the invalidate is complete the remote node context will - * transition to the posting state. - */ - SCI_RNC_INVALIDATING, - - /** - * This is a transition state that will post an RNC resume to the hardare. - * Once the event notification of resume complete is received the remote node - * context will transition to the ready state. - */ - SCI_RNC_RESUMING, - - /** - * This is the state that the remote node context must be in to accept io - * request operations. - */ - SCI_RNC_READY, - - /** - * This is the state that the remote node context transitions to when it gets - * a TX suspend notification from the hardware. - */ - SCI_RNC_TX_SUSPENDED, - - /** - * This is the state that the remote node context transitions to when it gets - * a TX RX suspend notification from the hardware. - */ - SCI_RNC_TX_RX_SUSPENDED, - - /** - * This state is a wait state for the remote node context that waits for a - * suspend notification from the hardware. This state is entered when either - * there is a request to supend the remote node context or when there is a TC - * completion where the remote node will be suspended by the hardware. - */ - SCI_RNC_AWAIT_SUSPENSION -}; - -/** - * - * - * This enumeration is used to define the end destination state for the remote - * node context. - */ -enum sci_remote_node_context_destination_state { - SCIC_SDS_REMOTE_NODE_DESTINATION_STATE_UNSPECIFIED, - SCIC_SDS_REMOTE_NODE_DESTINATION_STATE_READY, - SCIC_SDS_REMOTE_NODE_DESTINATION_STATE_FINAL -}; - -/** - * struct sci_remote_node_context - This structure contains the data - * associated with the remote node context object. The remote node context - * (RNC) object models the the remote device information necessary to manage - * the silicon RNC. - */ -struct sci_remote_node_context { - /** - * This field indicates the remote node index (RNI) associated with - * this RNC. - */ - u16 remote_node_index; - - /** - * This field is the recored suspension code or the reason for the remote node - * context suspension. - */ - u32 suspension_code; - - /** - * This field is true if the remote node context is resuming from its current - * state. This can cause an automatic resume on receiving a suspension - * notification. - */ - enum sci_remote_node_context_destination_state destination_state; - - /** - * This field contains the callback function that the user requested to be - * called when the requested state transition is complete. - */ - scics_sds_remote_node_context_callback user_callback; - - /** - * This field contains the parameter that is called when the user requested - * state transition is completed. - */ - void *user_cookie; - - /** - * This field contains the data for the object's state machine. - */ - struct sci_base_state_machine sm; -}; - -void sci_remote_node_context_construct(struct sci_remote_node_context *rnc, - u16 remote_node_index); - - -bool sci_remote_node_context_is_ready( - struct sci_remote_node_context *sci_rnc); - -enum sci_status sci_remote_node_context_event_handler(struct sci_remote_node_context *sci_rnc, - u32 event_code); -enum sci_status sci_remote_node_context_destruct(struct sci_remote_node_context *sci_rnc, - scics_sds_remote_node_context_callback callback, - void *callback_parameter); -enum sci_status sci_remote_node_context_suspend(struct sci_remote_node_context *sci_rnc, - u32 suspend_type, - scics_sds_remote_node_context_callback cb_fn, - void *cb_p); -enum sci_status sci_remote_node_context_resume(struct sci_remote_node_context *sci_rnc, - scics_sds_remote_node_context_callback cb_fn, - void *cb_p); -enum sci_status sci_remote_node_context_start_task(struct sci_remote_node_context *sci_rnc, - struct isci_request *ireq); -enum sci_status sci_remote_node_context_start_io(struct sci_remote_node_context *sci_rnc, - struct isci_request *ireq); - -#endif /* _SCIC_SDS_REMOTE_NODE_CONTEXT_H_ */ diff --git a/trunk/drivers/scsi/isci/remote_node_table.c b/trunk/drivers/scsi/isci/remote_node_table.c deleted file mode 100644 index 301b3141945e..000000000000 --- a/trunk/drivers/scsi/isci/remote_node_table.c +++ /dev/null @@ -1,598 +0,0 @@ -/* - * This file is provided under a dual BSD/GPLv2 license. When using or - * redistributing this file, you may do so under either license. - * - * GPL LICENSE SUMMARY - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License 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., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. - * The full GNU General Public License is included in this distribution - * in the file called LICENSE.GPL. - * - * BSD LICENSE - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Intel Corporation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * This file contains the implementation of the SCIC_SDS_REMOTE_NODE_TABLE - * public, protected, and private methods. - * - * - */ -#include "remote_node_table.h" -#include "remote_node_context.h" - -/** - * - * @remote_node_table: This is the remote node index table from which the - * selection will be made. - * @group_table_index: This is the index to the group table from which to - * search for an available selection. - * - * This routine will find the bit position in absolute bit terms of the next 32 - * + bit position. If there are available bits in the first u32 then it is - * just bit position. u32 This is the absolute bit position for an available - * group. - */ -static u32 sci_remote_node_table_get_group_index( - struct sci_remote_node_table *remote_node_table, - u32 group_table_index) -{ - u32 dword_index; - u32 *group_table; - u32 bit_index; - - group_table = remote_node_table->remote_node_groups[group_table_index]; - - for (dword_index = 0; dword_index < remote_node_table->group_array_size; dword_index++) { - if (group_table[dword_index] != 0) { - for (bit_index = 0; bit_index < 32; bit_index++) { - if ((group_table[dword_index] & (1 << bit_index)) != 0) { - return (dword_index * 32) + bit_index; - } - } - } - } - - return SCIC_SDS_REMOTE_NODE_TABLE_INVALID_INDEX; -} - -/** - * - * @out]: remote_node_table This the remote node table in which to clear the - * selector. - * @set_index: This is the remote node selector in which the change will be - * made. - * @group_index: This is the bit index in the table to be modified. - * - * This method will clear the group index entry in the specified group index - * table. none - */ -static void sci_remote_node_table_clear_group_index( - struct sci_remote_node_table *remote_node_table, - u32 group_table_index, - u32 group_index) -{ - u32 dword_index; - u32 bit_index; - u32 *group_table; - - BUG_ON(group_table_index >= SCU_STP_REMOTE_NODE_COUNT); - BUG_ON(group_index >= (u32)(remote_node_table->group_array_size * 32)); - - dword_index = group_index / 32; - bit_index = group_index % 32; - group_table = remote_node_table->remote_node_groups[group_table_index]; - - group_table[dword_index] = group_table[dword_index] & ~(1 << bit_index); -} - -/** - * - * @out]: remote_node_table This the remote node table in which to set the - * selector. - * @group_table_index: This is the remote node selector in which the change - * will be made. - * @group_index: This is the bit position in the table to be modified. - * - * This method will set the group index bit entry in the specified gropu index - * table. none - */ -static void sci_remote_node_table_set_group_index( - struct sci_remote_node_table *remote_node_table, - u32 group_table_index, - u32 group_index) -{ - u32 dword_index; - u32 bit_index; - u32 *group_table; - - BUG_ON(group_table_index >= SCU_STP_REMOTE_NODE_COUNT); - BUG_ON(group_index >= (u32)(remote_node_table->group_array_size * 32)); - - dword_index = group_index / 32; - bit_index = group_index % 32; - group_table = remote_node_table->remote_node_groups[group_table_index]; - - group_table[dword_index] = group_table[dword_index] | (1 << bit_index); -} - -/** - * - * @out]: remote_node_table This is the remote node table in which to modify - * the remote node availability. - * @remote_node_index: This is the remote node index that is being returned to - * the table. - * - * This method will set the remote to available in the remote node allocation - * table. none - */ -static void sci_remote_node_table_set_node_index( - struct sci_remote_node_table *remote_node_table, - u32 remote_node_index) -{ - u32 dword_location; - u32 dword_remainder; - u32 slot_normalized; - u32 slot_position; - - BUG_ON( - (remote_node_table->available_nodes_array_size * SCIC_SDS_REMOTE_NODE_SETS_PER_DWORD) - <= (remote_node_index / SCU_STP_REMOTE_NODE_COUNT) - ); - - dword_location = remote_node_index / SCIC_SDS_REMOTE_NODES_PER_DWORD; - dword_remainder = remote_node_index % SCIC_SDS_REMOTE_NODES_PER_DWORD; - slot_normalized = (dword_remainder / SCU_STP_REMOTE_NODE_COUNT) * sizeof(u32); - slot_position = remote_node_index % SCU_STP_REMOTE_NODE_COUNT; - - remote_node_table->available_remote_nodes[dword_location] |= - 1 << (slot_normalized + slot_position); -} - -/** - * - * @out]: remote_node_table This is the remote node table from which to clear - * the available remote node bit. - * @remote_node_index: This is the remote node index which is to be cleared - * from the table. - * - * This method clears the remote node index from the table of available remote - * nodes. none - */ -static void sci_remote_node_table_clear_node_index( - struct sci_remote_node_table *remote_node_table, - u32 remote_node_index) -{ - u32 dword_location; - u32 dword_remainder; - u32 slot_position; - u32 slot_normalized; - - BUG_ON( - (remote_node_table->available_nodes_array_size * SCIC_SDS_REMOTE_NODE_SETS_PER_DWORD) - <= (remote_node_index / SCU_STP_REMOTE_NODE_COUNT) - ); - - dword_location = remote_node_index / SCIC_SDS_REMOTE_NODES_PER_DWORD; - dword_remainder = remote_node_index % SCIC_SDS_REMOTE_NODES_PER_DWORD; - slot_normalized = (dword_remainder / SCU_STP_REMOTE_NODE_COUNT) * sizeof(u32); - slot_position = remote_node_index % SCU_STP_REMOTE_NODE_COUNT; - - remote_node_table->available_remote_nodes[dword_location] &= - ~(1 << (slot_normalized + slot_position)); -} - -/** - * - * @out]: remote_node_table The remote node table from which the slot will be - * cleared. - * @group_index: The index for the slot that is to be cleared. - * - * This method clears the entire table slot at the specified slot index. none - */ -static void sci_remote_node_table_clear_group( - struct sci_remote_node_table *remote_node_table, - u32 group_index) -{ - u32 dword_location; - u32 dword_remainder; - u32 dword_value; - - BUG_ON( - (remote_node_table->available_nodes_array_size * SCIC_SDS_REMOTE_NODE_SETS_PER_DWORD) - <= (group_index / SCU_STP_REMOTE_NODE_COUNT) - ); - - dword_location = group_index / SCIC_SDS_REMOTE_NODE_SETS_PER_DWORD; - dword_remainder = group_index % SCIC_SDS_REMOTE_NODE_SETS_PER_DWORD; - - dword_value = remote_node_table->available_remote_nodes[dword_location]; - dword_value &= ~(SCIC_SDS_REMOTE_NODE_TABLE_FULL_SLOT_VALUE << (dword_remainder * 4)); - remote_node_table->available_remote_nodes[dword_location] = dword_value; -} - -/** - * - * @remote_node_table: - * - * THis method sets an entire remote node group in the remote node table. - */ -static void sci_remote_node_table_set_group( - struct sci_remote_node_table *remote_node_table, - u32 group_index) -{ - u32 dword_location; - u32 dword_remainder; - u32 dword_value; - - BUG_ON( - (remote_node_table->available_nodes_array_size * SCIC_SDS_REMOTE_NODE_SETS_PER_DWORD) - <= (group_index / SCU_STP_REMOTE_NODE_COUNT) - ); - - dword_location = group_index / SCIC_SDS_REMOTE_NODE_SETS_PER_DWORD; - dword_remainder = group_index % SCIC_SDS_REMOTE_NODE_SETS_PER_DWORD; - - dword_value = remote_node_table->available_remote_nodes[dword_location]; - dword_value |= (SCIC_SDS_REMOTE_NODE_TABLE_FULL_SLOT_VALUE << (dword_remainder * 4)); - remote_node_table->available_remote_nodes[dword_location] = dword_value; -} - -/** - * - * @remote_node_table: This is the remote node table that for which the group - * value is to be returned. - * @group_index: This is the group index to use to find the group value. - * - * This method will return the group value for the specified group index. The - * bit values at the specified remote node group index. - */ -static u8 sci_remote_node_table_get_group_value( - struct sci_remote_node_table *remote_node_table, - u32 group_index) -{ - u32 dword_location; - u32 dword_remainder; - u32 dword_value; - - dword_location = group_index / SCIC_SDS_REMOTE_NODE_SETS_PER_DWORD; - dword_remainder = group_index % SCIC_SDS_REMOTE_NODE_SETS_PER_DWORD; - - dword_value = remote_node_table->available_remote_nodes[dword_location]; - dword_value &= (SCIC_SDS_REMOTE_NODE_TABLE_FULL_SLOT_VALUE << (dword_remainder * 4)); - dword_value = dword_value >> (dword_remainder * 4); - - return (u8)dword_value; -} - -/** - * - * @out]: remote_node_table The remote that which is to be initialized. - * @remote_node_entries: The number of entries to put in the table. - * - * This method will initialize the remote node table for use. none - */ -void sci_remote_node_table_initialize( - struct sci_remote_node_table *remote_node_table, - u32 remote_node_entries) -{ - u32 index; - - /* - * Initialize the raw data we could improve the speed by only initializing - * those entries that we are actually going to be used */ - memset( - remote_node_table->available_remote_nodes, - 0x00, - sizeof(remote_node_table->available_remote_nodes) - ); - - memset( - remote_node_table->remote_node_groups, - 0x00, - sizeof(remote_node_table->remote_node_groups) - ); - - /* Initialize the available remote node sets */ - remote_node_table->available_nodes_array_size = (u16) - (remote_node_entries / SCIC_SDS_REMOTE_NODES_PER_DWORD) - + ((remote_node_entries % SCIC_SDS_REMOTE_NODES_PER_DWORD) != 0); - - - /* Initialize each full DWORD to a FULL SET of remote nodes */ - for (index = 0; index < remote_node_entries; index++) { - sci_remote_node_table_set_node_index(remote_node_table, index); - } - - remote_node_table->group_array_size = (u16) - (remote_node_entries / (SCU_STP_REMOTE_NODE_COUNT * 32)) - + ((remote_node_entries % (SCU_STP_REMOTE_NODE_COUNT * 32)) != 0); - - for (index = 0; index < (remote_node_entries / SCU_STP_REMOTE_NODE_COUNT); index++) { - /* - * These are all guaranteed to be full slot values so fill them in the - * available sets of 3 remote nodes */ - sci_remote_node_table_set_group_index(remote_node_table, 2, index); - } - - /* Now fill in any remainders that we may find */ - if ((remote_node_entries % SCU_STP_REMOTE_NODE_COUNT) == 2) { - sci_remote_node_table_set_group_index(remote_node_table, 1, index); - } else if ((remote_node_entries % SCU_STP_REMOTE_NODE_COUNT) == 1) { - sci_remote_node_table_set_group_index(remote_node_table, 0, index); - } -} - -/** - * - * @out]: remote_node_table The remote node table from which to allocate a - * remote node. - * @table_index: The group index that is to be used for the search. - * - * This method will allocate a single RNi from the remote node table. The - * table index will determine from which remote node group table to search. - * This search may fail and another group node table can be specified. The - * function is designed to allow a serach of the available single remote node - * group up to the triple remote node group. If an entry is found in the - * specified table the remote node is removed and the remote node groups are - * updated. The RNi value or an invalid remote node context if an RNi can not - * be found. - */ -static u16 sci_remote_node_table_allocate_single_remote_node( - struct sci_remote_node_table *remote_node_table, - u32 group_table_index) -{ - u8 index; - u8 group_value; - u32 group_index; - u16 remote_node_index = SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX; - - group_index = sci_remote_node_table_get_group_index( - remote_node_table, group_table_index); - - /* We could not find an available slot in the table selector 0 */ - if (group_index != SCIC_SDS_REMOTE_NODE_TABLE_INVALID_INDEX) { - group_value = sci_remote_node_table_get_group_value( - remote_node_table, group_index); - - for (index = 0; index < SCU_STP_REMOTE_NODE_COUNT; index++) { - if (((1 << index) & group_value) != 0) { - /* We have selected a bit now clear it */ - remote_node_index = (u16)(group_index * SCU_STP_REMOTE_NODE_COUNT - + index); - - sci_remote_node_table_clear_group_index( - remote_node_table, group_table_index, group_index - ); - - sci_remote_node_table_clear_node_index( - remote_node_table, remote_node_index - ); - - if (group_table_index > 0) { - sci_remote_node_table_set_group_index( - remote_node_table, group_table_index - 1, group_index - ); - } - - break; - } - } - } - - return remote_node_index; -} - -/** - * - * @remote_node_table: This is the remote node table from which to allocate the - * remote node entries. - * @group_table_index: THis is the group table index which must equal two (2) - * for this operation. - * - * This method will allocate three consecutive remote node context entries. If - * there are no remaining triple entries the function will return a failure. - * The remote node index that represents three consecutive remote node entries - * or an invalid remote node context if none can be found. - */ -static u16 sci_remote_node_table_allocate_triple_remote_node( - struct sci_remote_node_table *remote_node_table, - u32 group_table_index) -{ - u32 group_index; - u16 remote_node_index = SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX; - - group_index = sci_remote_node_table_get_group_index( - remote_node_table, group_table_index); - - if (group_index != SCIC_SDS_REMOTE_NODE_TABLE_INVALID_INDEX) { - remote_node_index = (u16)group_index * SCU_STP_REMOTE_NODE_COUNT; - - sci_remote_node_table_clear_group_index( - remote_node_table, group_table_index, group_index - ); - - sci_remote_node_table_clear_group( - remote_node_table, group_index - ); - } - - return remote_node_index; -} - -/** - * - * @remote_node_table: This is the remote node table from which the remote node - * allocation is to take place. - * @remote_node_count: This is ther remote node count which is one of - * SCU_SSP_REMOTE_NODE_COUNT(1) or SCU_STP_REMOTE_NODE_COUNT(3). - * - * This method will allocate a remote node that mataches the remote node count - * specified by the caller. Valid values for remote node count is - * SCU_SSP_REMOTE_NODE_COUNT(1) or SCU_STP_REMOTE_NODE_COUNT(3). u16 This is - * the remote node index that is returned or an invalid remote node context. - */ -u16 sci_remote_node_table_allocate_remote_node( - struct sci_remote_node_table *remote_node_table, - u32 remote_node_count) -{ - u16 remote_node_index = SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX; - - if (remote_node_count == SCU_SSP_REMOTE_NODE_COUNT) { - remote_node_index = - sci_remote_node_table_allocate_single_remote_node( - remote_node_table, 0); - - if (remote_node_index == SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX) { - remote_node_index = - sci_remote_node_table_allocate_single_remote_node( - remote_node_table, 1); - } - - if (remote_node_index == SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX) { - remote_node_index = - sci_remote_node_table_allocate_single_remote_node( - remote_node_table, 2); - } - } else if (remote_node_count == SCU_STP_REMOTE_NODE_COUNT) { - remote_node_index = - sci_remote_node_table_allocate_triple_remote_node( - remote_node_table, 2); - } - - return remote_node_index; -} - -/** - * - * @remote_node_table: - * - * This method will free a single remote node index back to the remote node - * table. This routine will update the remote node groups - */ -static void sci_remote_node_table_release_single_remote_node( - struct sci_remote_node_table *remote_node_table, - u16 remote_node_index) -{ - u32 group_index; - u8 group_value; - - group_index = remote_node_index / SCU_STP_REMOTE_NODE_COUNT; - - group_value = sci_remote_node_table_get_group_value(remote_node_table, group_index); - - /* - * Assert that we are not trying to add an entry to a slot that is already - * full. */ - BUG_ON(group_value == SCIC_SDS_REMOTE_NODE_TABLE_FULL_SLOT_VALUE); - - if (group_value == 0x00) { - /* - * There are no entries in this slot so it must be added to the single - * slot table. */ - sci_remote_node_table_set_group_index(remote_node_table, 0, group_index); - } else if ((group_value & (group_value - 1)) == 0) { - /* - * There is only one entry in this slot so it must be moved from the - * single slot table to the dual slot table */ - sci_remote_node_table_clear_group_index(remote_node_table, 0, group_index); - sci_remote_node_table_set_group_index(remote_node_table, 1, group_index); - } else { - /* - * There are two entries in the slot so it must be moved from the dual - * slot table to the tripple slot table. */ - sci_remote_node_table_clear_group_index(remote_node_table, 1, group_index); - sci_remote_node_table_set_group_index(remote_node_table, 2, group_index); - } - - sci_remote_node_table_set_node_index(remote_node_table, remote_node_index); -} - -/** - * - * @remote_node_table: This is the remote node table to which the remote node - * index is to be freed. - * - * This method will release a group of three consecutive remote nodes back to - * the free remote nodes. - */ -static void sci_remote_node_table_release_triple_remote_node( - struct sci_remote_node_table *remote_node_table, - u16 remote_node_index) -{ - u32 group_index; - - group_index = remote_node_index / SCU_STP_REMOTE_NODE_COUNT; - - sci_remote_node_table_set_group_index( - remote_node_table, 2, group_index - ); - - sci_remote_node_table_set_group(remote_node_table, group_index); -} - -/** - * - * @remote_node_table: The remote node table to which the remote node index is - * to be freed. - * @remote_node_count: This is the count of consecutive remote nodes that are - * to be freed. - * - * This method will release the remote node index back into the remote node - * table free pool. - */ -void sci_remote_node_table_release_remote_node_index( - struct sci_remote_node_table *remote_node_table, - u32 remote_node_count, - u16 remote_node_index) -{ - if (remote_node_count == SCU_SSP_REMOTE_NODE_COUNT) { - sci_remote_node_table_release_single_remote_node( - remote_node_table, remote_node_index); - } else if (remote_node_count == SCU_STP_REMOTE_NODE_COUNT) { - sci_remote_node_table_release_triple_remote_node( - remote_node_table, remote_node_index); - } -} - diff --git a/trunk/drivers/scsi/isci/remote_node_table.h b/trunk/drivers/scsi/isci/remote_node_table.h deleted file mode 100644 index 721ab982d2ac..000000000000 --- a/trunk/drivers/scsi/isci/remote_node_table.h +++ /dev/null @@ -1,188 +0,0 @@ -/* - * This file is provided under a dual BSD/GPLv2 license. When using or - * redistributing this file, you may do so under either license. - * - * GPL LICENSE SUMMARY - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License 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., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. - * The full GNU General Public License is included in this distribution - * in the file called LICENSE.GPL. - * - * BSD LICENSE - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Intel Corporation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _SCIC_SDS_REMOTE_NODE_TABLE_H_ -#define _SCIC_SDS_REMOTE_NODE_TABLE_H_ - -#include "isci.h" - -/** - * - * - * Remote node sets are sets of remote node index in the remtoe node table The - * SCU hardware requires that STP remote node entries take three consecutive - * remote node index so the table is arranged in sets of three. The bits are - * used as 0111 0111 to make a byte and the bits define the set of three remote - * nodes to use as a sequence. - */ -#define SCIC_SDS_REMOTE_NODE_SETS_PER_BYTE 2 - -/** - * - * - * Since the remote node table is organized as DWORDS take the remote node sets - * in bytes and represent them in DWORDs. The lowest ordered bits are the ones - * used in case full DWORD is not being used. i.e. 0000 0000 0000 0000 0111 - * 0111 0111 0111 // if only a single WORD is in use in the DWORD. - */ -#define SCIC_SDS_REMOTE_NODE_SETS_PER_DWORD \ - (sizeof(u32) * SCIC_SDS_REMOTE_NODE_SETS_PER_BYTE) -/** - * - * - * This is a count of the numeber of remote nodes that can be represented in a - * byte - */ -#define SCIC_SDS_REMOTE_NODES_PER_BYTE \ - (SCU_STP_REMOTE_NODE_COUNT * SCIC_SDS_REMOTE_NODE_SETS_PER_BYTE) - -/** - * - * - * This is a count of the number of remote nodes that can be represented in a - * DWROD - */ -#define SCIC_SDS_REMOTE_NODES_PER_DWORD \ - (sizeof(u32) * SCIC_SDS_REMOTE_NODES_PER_BYTE) - -/** - * - * - * This is the number of bits in a remote node group - */ -#define SCIC_SDS_REMOTE_NODES_BITS_PER_GROUP 4 - -#define SCIC_SDS_REMOTE_NODE_TABLE_INVALID_INDEX (0xFFFFFFFF) -#define SCIC_SDS_REMOTE_NODE_TABLE_FULL_SLOT_VALUE (0x07) -#define SCIC_SDS_REMOTE_NODE_TABLE_EMPTY_SLOT_VALUE (0x00) - -/** - * - * - * Expander attached sata remote node count - */ -#define SCU_STP_REMOTE_NODE_COUNT 3 - -/** - * - * - * Expander or direct attached ssp remote node count - */ -#define SCU_SSP_REMOTE_NODE_COUNT 1 - -/** - * - * - * Direct attached STP remote node count - */ -#define SCU_SATA_REMOTE_NODE_COUNT 1 - -/** - * struct sci_remote_node_table - - * - * - */ -struct sci_remote_node_table { - /** - * This field contains the array size in dwords - */ - u16 available_nodes_array_size; - - /** - * This field contains the array size of the - */ - u16 group_array_size; - - /** - * This field is the array of available remote node entries in bits. - * Because of the way STP remote node data is allocated on the SCU hardware - * the remote nodes must occupy three consecutive remote node context - * entries. For ease of allocation and de-allocation we have broken the - * sets of three into a single nibble. When the STP RNi is allocated all - * of the bits in the nibble are cleared. This math results in a table size - * of MAX_REMOTE_NODES / CONSECUTIVE RNi ENTRIES for STP / 2 entries per byte. - */ - u32 available_remote_nodes[ - (SCI_MAX_REMOTE_DEVICES / SCIC_SDS_REMOTE_NODES_PER_DWORD) - + ((SCI_MAX_REMOTE_DEVICES % SCIC_SDS_REMOTE_NODES_PER_DWORD) != 0)]; - - /** - * This field is the nibble selector for the above table. There are three - * possible selectors each for fast lookup when trying to find one, two or - * three remote node entries. - */ - u32 remote_node_groups[ - SCU_STP_REMOTE_NODE_COUNT][ - (SCI_MAX_REMOTE_DEVICES / (32 * SCU_STP_REMOTE_NODE_COUNT)) - + ((SCI_MAX_REMOTE_DEVICES % (32 * SCU_STP_REMOTE_NODE_COUNT)) != 0)]; - -}; - -/* --------------------------------------------------------------------------- */ - -void sci_remote_node_table_initialize( - struct sci_remote_node_table *remote_node_table, - u32 remote_node_entries); - -u16 sci_remote_node_table_allocate_remote_node( - struct sci_remote_node_table *remote_node_table, - u32 remote_node_count); - -void sci_remote_node_table_release_remote_node_index( - struct sci_remote_node_table *remote_node_table, - u32 remote_node_count, - u16 remote_node_index); - -#endif /* _SCIC_SDS_REMOTE_NODE_TABLE_H_ */ diff --git a/trunk/drivers/scsi/isci/request.c b/trunk/drivers/scsi/isci/request.c deleted file mode 100644 index a46e07ac789f..000000000000 --- a/trunk/drivers/scsi/isci/request.c +++ /dev/null @@ -1,3391 +0,0 @@ -/* - * This file is provided under a dual BSD/GPLv2 license. When using or - * redistributing this file, you may do so under either license. - * - * GPL LICENSE SUMMARY - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License 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., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. - * The full GNU General Public License is included in this distribution - * in the file called LICENSE.GPL. - * - * BSD LICENSE - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Intel Corporation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "isci.h" -#include "task.h" -#include "request.h" -#include "scu_completion_codes.h" -#include "scu_event_codes.h" -#include "sas.h" - -static struct scu_sgl_element_pair *to_sgl_element_pair(struct isci_request *ireq, - int idx) -{ - if (idx == 0) - return &ireq->tc->sgl_pair_ab; - else if (idx == 1) - return &ireq->tc->sgl_pair_cd; - else if (idx < 0) - return NULL; - else - return &ireq->sg_table[idx - 2]; -} - -static dma_addr_t to_sgl_element_pair_dma(struct isci_host *ihost, - struct isci_request *ireq, u32 idx) -{ - u32 offset; - - if (idx == 0) { - offset = (void *) &ireq->tc->sgl_pair_ab - - (void *) &ihost->task_context_table[0]; - return ihost->task_context_dma + offset; - } else if (idx == 1) { - offset = (void *) &ireq->tc->sgl_pair_cd - - (void *) &ihost->task_context_table[0]; - return ihost->task_context_dma + offset; - } - - return sci_io_request_get_dma_addr(ireq, &ireq->sg_table[idx - 2]); -} - -static void init_sgl_element(struct scu_sgl_element *e, struct scatterlist *sg) -{ - e->length = sg_dma_len(sg); - e->address_upper = upper_32_bits(sg_dma_address(sg)); - e->address_lower = lower_32_bits(sg_dma_address(sg)); - e->address_modifier = 0; -} - -static void sci_request_build_sgl(struct isci_request *ireq) -{ - struct isci_host *ihost = ireq->isci_host; - struct sas_task *task = isci_request_access_task(ireq); - struct scatterlist *sg = NULL; - dma_addr_t dma_addr; - u32 sg_idx = 0; - struct scu_sgl_element_pair *scu_sg = NULL; - struct scu_sgl_element_pair *prev_sg = NULL; - - if (task->num_scatter > 0) { - sg = task->scatter; - - while (sg) { - scu_sg = to_sgl_element_pair(ireq, sg_idx); - init_sgl_element(&scu_sg->A, sg); - sg = sg_next(sg); - if (sg) { - init_sgl_element(&scu_sg->B, sg); - sg = sg_next(sg); - } else - memset(&scu_sg->B, 0, sizeof(scu_sg->B)); - - if (prev_sg) { - dma_addr = to_sgl_element_pair_dma(ihost, - ireq, - sg_idx); - - prev_sg->next_pair_upper = - upper_32_bits(dma_addr); - prev_sg->next_pair_lower = - lower_32_bits(dma_addr); - } - - prev_sg = scu_sg; - sg_idx++; - } - } else { /* handle when no sg */ - scu_sg = to_sgl_element_pair(ireq, sg_idx); - - dma_addr = dma_map_single(&ihost->pdev->dev, - task->scatter, - task->total_xfer_len, - task->data_dir); - - ireq->zero_scatter_daddr = dma_addr; - - scu_sg->A.length = task->total_xfer_len; - scu_sg->A.address_upper = upper_32_bits(dma_addr); - scu_sg->A.address_lower = lower_32_bits(dma_addr); - } - - if (scu_sg) { - scu_sg->next_pair_upper = 0; - scu_sg->next_pair_lower = 0; - } -} - -static void sci_io_request_build_ssp_command_iu(struct isci_request *ireq) -{ - struct ssp_cmd_iu *cmd_iu; - struct sas_task *task = isci_request_access_task(ireq); - - cmd_iu = &ireq->ssp.cmd; - - memcpy(cmd_iu->LUN, task->ssp_task.LUN, 8); - cmd_iu->add_cdb_len = 0; - cmd_iu->_r_a = 0; - cmd_iu->_r_b = 0; - cmd_iu->en_fburst = 0; /* unsupported */ - cmd_iu->task_prio = task->ssp_task.task_prio; - cmd_iu->task_attr = task->ssp_task.task_attr; - cmd_iu->_r_c = 0; - - sci_swab32_cpy(&cmd_iu->cdb, task->ssp_task.cdb, - sizeof(task->ssp_task.cdb) / sizeof(u32)); -} - -static void sci_task_request_build_ssp_task_iu(struct isci_request *ireq) -{ - struct ssp_task_iu *task_iu; - struct sas_task *task = isci_request_access_task(ireq); - struct isci_tmf *isci_tmf = isci_request_access_tmf(ireq); - - task_iu = &ireq->ssp.tmf; - - memset(task_iu, 0, sizeof(struct ssp_task_iu)); - - memcpy(task_iu->LUN, task->ssp_task.LUN, 8); - - task_iu->task_func = isci_tmf->tmf_code; - task_iu->task_tag = - (ireq->ttype == tmf_task) ? - isci_tmf->io_tag : - SCI_CONTROLLER_INVALID_IO_TAG; -} - -/** - * This method is will fill in the SCU Task Context for any type of SSP request. - * @sci_req: - * @task_context: - * - */ -static void scu_ssp_reqeust_construct_task_context( - struct isci_request *ireq, - struct scu_task_context *task_context) -{ - dma_addr_t dma_addr; - struct isci_remote_device *idev; - struct isci_port *iport; - - idev = ireq->target_device; - iport = idev->owning_port; - - /* Fill in the TC with the its required data */ - task_context->abort = 0; - task_context->priority = 0; - task_context->initiator_request = 1; - task_context->connection_rate = idev->connection_rate; - task_context->protocol_engine_index = ISCI_PEG; - task_context->logical_port_index = iport->physical_port_index; - task_context->protocol_type = SCU_TASK_CONTEXT_PROTOCOL_SSP; - task_context->valid = SCU_TASK_CONTEXT_VALID; - task_context->context_type = SCU_TASK_CONTEXT_TYPE; - - task_context->remote_node_index = idev->rnc.remote_node_index; - task_context->command_code = 0; - - task_context->link_layer_control = 0; - task_context->do_not_dma_ssp_good_response = 1; - task_context->strict_ordering = 0; - task_context->control_frame = 0; - task_context->timeout_enable = 0; - task_context->block_guard_enable = 0; - - task_context->address_modifier = 0; - - /* task_context->type.ssp.tag = ireq->io_tag; */ - task_context->task_phase = 0x01; - - ireq->post_context = (SCU_CONTEXT_COMMAND_REQUEST_TYPE_POST_TC | - (ISCI_PEG << SCU_CONTEXT_COMMAND_PROTOCOL_ENGINE_GROUP_SHIFT) | - (iport->physical_port_index << - SCU_CONTEXT_COMMAND_LOGICAL_PORT_SHIFT) | - ISCI_TAG_TCI(ireq->io_tag)); - - /* - * Copy the physical address for the command buffer to the - * SCU Task Context - */ - dma_addr = sci_io_request_get_dma_addr(ireq, &ireq->ssp.cmd); - - task_context->command_iu_upper = upper_32_bits(dma_addr); - task_context->command_iu_lower = lower_32_bits(dma_addr); - - /* - * Copy the physical address for the response buffer to the - * SCU Task Context - */ - dma_addr = sci_io_request_get_dma_addr(ireq, &ireq->ssp.rsp); - - task_context->response_iu_upper = upper_32_bits(dma_addr); - task_context->response_iu_lower = lower_32_bits(dma_addr); -} - -/** - * This method is will fill in the SCU Task Context for a SSP IO request. - * @sci_req: - * - */ -static void scu_ssp_io_request_construct_task_context(struct isci_request *ireq, - enum dma_data_direction dir, - u32 len) -{ - struct scu_task_context *task_context = ireq->tc; - - scu_ssp_reqeust_construct_task_context(ireq, task_context); - - task_context->ssp_command_iu_length = - sizeof(struct ssp_cmd_iu) / sizeof(u32); - task_context->type.ssp.frame_type = SSP_COMMAND; - - switch (dir) { - case DMA_FROM_DEVICE: - case DMA_NONE: - default: - task_context->task_type = SCU_TASK_TYPE_IOREAD; - break; - case DMA_TO_DEVICE: - task_context->task_type = SCU_TASK_TYPE_IOWRITE; - break; - } - - task_context->transfer_length_bytes = len; - - if (task_context->transfer_length_bytes > 0) - sci_request_build_sgl(ireq); -} - -/** - * This method will fill in the SCU Task Context for a SSP Task request. The - * following important settings are utilized: -# priority == - * SCU_TASK_PRIORITY_HIGH. This ensures that the task request is issued - * ahead of other task destined for the same Remote Node. -# task_type == - * SCU_TASK_TYPE_IOREAD. This simply indicates that a normal request type - * (i.e. non-raw frame) is being utilized to perform task management. -# - * control_frame == 1. This ensures that the proper endianess is set so - * that the bytes are transmitted in the right order for a task frame. - * @sci_req: This parameter specifies the task request object being - * constructed. - * - */ -static void scu_ssp_task_request_construct_task_context(struct isci_request *ireq) -{ - struct scu_task_context *task_context = ireq->tc; - - scu_ssp_reqeust_construct_task_context(ireq, task_context); - - task_context->control_frame = 1; - task_context->priority = SCU_TASK_PRIORITY_HIGH; - task_context->task_type = SCU_TASK_TYPE_RAW_FRAME; - task_context->transfer_length_bytes = 0; - task_context->type.ssp.frame_type = SSP_TASK; - task_context->ssp_command_iu_length = - sizeof(struct ssp_task_iu) / sizeof(u32); -} - -/** - * This method is will fill in the SCU Task Context for any type of SATA - * request. This is called from the various SATA constructors. - * @sci_req: The general IO request object which is to be used in - * constructing the SCU task context. - * @task_context: The buffer pointer for the SCU task context which is being - * constructed. - * - * The general io request construction is complete. The buffer assignment for - * the command buffer is complete. none Revisit task context construction to - * determine what is common for SSP/SMP/STP task context structures. - */ -static void scu_sata_reqeust_construct_task_context( - struct isci_request *ireq, - struct scu_task_context *task_context) -{ - dma_addr_t dma_addr; - struct isci_remote_device *idev; - struct isci_port *iport; - - idev = ireq->target_device; - iport = idev->owning_port; - - /* Fill in the TC with the its required data */ - task_context->abort = 0; - task_context->priority = SCU_TASK_PRIORITY_NORMAL; - task_context->initiator_request = 1; - task_context->connection_rate = idev->connection_rate; - task_context->protocol_engine_index = ISCI_PEG; - task_context->logical_port_index = iport->physical_port_index; - task_context->protocol_type = SCU_TASK_CONTEXT_PROTOCOL_STP; - task_context->valid = SCU_TASK_CONTEXT_VALID; - task_context->context_type = SCU_TASK_CONTEXT_TYPE; - - task_context->remote_node_index = idev->rnc.remote_node_index; - task_context->command_code = 0; - - task_context->link_layer_control = 0; - task_context->do_not_dma_ssp_good_response = 1; - task_context->strict_ordering = 0; - task_context->control_frame = 0; - task_context->timeout_enable = 0; - task_context->block_guard_enable = 0; - - task_context->address_modifier = 0; - task_context->task_phase = 0x01; - - task_context->ssp_command_iu_length = - (sizeof(struct host_to_dev_fis) - sizeof(u32)) / sizeof(u32); - - /* Set the first word of the H2D REG FIS */ - task_context->type.words[0] = *(u32 *)&ireq->stp.cmd; - - ireq->post_context = (SCU_CONTEXT_COMMAND_REQUEST_TYPE_POST_TC | - (ISCI_PEG << SCU_CONTEXT_COMMAND_PROTOCOL_ENGINE_GROUP_SHIFT) | - (iport->physical_port_index << - SCU_CONTEXT_COMMAND_LOGICAL_PORT_SHIFT) | - ISCI_TAG_TCI(ireq->io_tag)); - /* - * Copy the physical address for the command buffer to the SCU Task - * Context. We must offset the command buffer by 4 bytes because the - * first 4 bytes are transfered in the body of the TC. - */ - dma_addr = sci_io_request_get_dma_addr(ireq, - ((char *) &ireq->stp.cmd) + - sizeof(u32)); - - task_context->command_iu_upper = upper_32_bits(dma_addr); - task_context->command_iu_lower = lower_32_bits(dma_addr); - - /* SATA Requests do not have a response buffer */ - task_context->response_iu_upper = 0; - task_context->response_iu_lower = 0; -} - -static void scu_stp_raw_request_construct_task_context(struct isci_request *ireq) -{ - struct scu_task_context *task_context = ireq->tc; - - scu_sata_reqeust_construct_task_context(ireq, task_context); - - task_context->control_frame = 0; - task_context->priority = SCU_TASK_PRIORITY_NORMAL; - task_context->task_type = SCU_TASK_TYPE_SATA_RAW_FRAME; - task_context->type.stp.fis_type = FIS_REGH2D; - task_context->transfer_length_bytes = sizeof(struct host_to_dev_fis) - sizeof(u32); -} - -static enum sci_status sci_stp_pio_request_construct(struct isci_request *ireq, - bool copy_rx_frame) -{ - struct isci_stp_request *stp_req = &ireq->stp.req; - - scu_stp_raw_request_construct_task_context(ireq); - - stp_req->status = 0; - stp_req->sgl.offset = 0; - stp_req->sgl.set = SCU_SGL_ELEMENT_PAIR_A; - - if (copy_rx_frame) { - sci_request_build_sgl(ireq); - stp_req->sgl.index = 0; - } else { - /* The user does not want the data copied to the SGL buffer location */ - stp_req->sgl.index = -1; - } - - return SCI_SUCCESS; -} - -/** - * - * @sci_req: This parameter specifies the request to be constructed as an - * optimized request. - * @optimized_task_type: This parameter specifies whether the request is to be - * an UDMA request or a NCQ request. - A value of 0 indicates UDMA. - A - * value of 1 indicates NCQ. - * - * This method will perform request construction common to all types of STP - * requests that are optimized by the silicon (i.e. UDMA, NCQ). This method - * returns an indication as to whether the construction was successful. - */ -static void sci_stp_optimized_request_construct(struct isci_request *ireq, - u8 optimized_task_type, - u32 len, - enum dma_data_direction dir) -{ - struct scu_task_context *task_context = ireq->tc; - - /* Build the STP task context structure */ - scu_sata_reqeust_construct_task_context(ireq, task_context); - - /* Copy over the SGL elements */ - sci_request_build_sgl(ireq); - - /* Copy over the number of bytes to be transfered */ - task_context->transfer_length_bytes = len; - - if (dir == DMA_TO_DEVICE) { - /* - * The difference between the DMA IN and DMA OUT request task type - * values are consistent with the difference between FPDMA READ - * and FPDMA WRITE values. Add the supplied task type parameter - * to this difference to set the task type properly for this - * DATA OUT (WRITE) case. */ - task_context->task_type = optimized_task_type + (SCU_TASK_TYPE_DMA_OUT - - SCU_TASK_TYPE_DMA_IN); - } else { - /* - * For the DATA IN (READ) case, simply save the supplied - * optimized task type. */ - task_context->task_type = optimized_task_type; - } -} - - - -static enum sci_status -sci_io_request_construct_sata(struct isci_request *ireq, - u32 len, - enum dma_data_direction dir, - bool copy) -{ - enum sci_status status = SCI_SUCCESS; - struct sas_task *task = isci_request_access_task(ireq); - - /* check for management protocols */ - if (ireq->ttype == tmf_task) { - struct isci_tmf *tmf = isci_request_access_tmf(ireq); - - if (tmf->tmf_code == isci_tmf_sata_srst_high || - tmf->tmf_code == isci_tmf_sata_srst_low) { - scu_stp_raw_request_construct_task_context(ireq); - return SCI_SUCCESS; - } else { - dev_err(&ireq->owning_controller->pdev->dev, - "%s: Request 0x%p received un-handled SAT " - "management protocol 0x%x.\n", - __func__, ireq, tmf->tmf_code); - - return SCI_FAILURE; - } - } - - if (!sas_protocol_ata(task->task_proto)) { - dev_err(&ireq->owning_controller->pdev->dev, - "%s: Non-ATA protocol in SATA path: 0x%x\n", - __func__, - task->task_proto); - return SCI_FAILURE; - - } - - /* non data */ - if (task->data_dir == DMA_NONE) { - scu_stp_raw_request_construct_task_context(ireq); - return SCI_SUCCESS; - } - - /* NCQ */ - if (task->ata_task.use_ncq) { - sci_stp_optimized_request_construct(ireq, - SCU_TASK_TYPE_FPDMAQ_READ, - len, dir); - return SCI_SUCCESS; - } - - /* DMA */ - if (task->ata_task.dma_xfer) { - sci_stp_optimized_request_construct(ireq, - SCU_TASK_TYPE_DMA_IN, - len, dir); - return SCI_SUCCESS; - } else /* PIO */ - return sci_stp_pio_request_construct(ireq, copy); - - return status; -} - -static enum sci_status sci_io_request_construct_basic_ssp(struct isci_request *ireq) -{ - struct sas_task *task = isci_request_access_task(ireq); - - ireq->protocol = SCIC_SSP_PROTOCOL; - - scu_ssp_io_request_construct_task_context(ireq, - task->data_dir, - task->total_xfer_len); - - sci_io_request_build_ssp_command_iu(ireq); - - sci_change_state(&ireq->sm, SCI_REQ_CONSTRUCTED); - - return SCI_SUCCESS; -} - -enum sci_status sci_task_request_construct_ssp( - struct isci_request *ireq) -{ - /* Construct the SSP Task SCU Task Context */ - scu_ssp_task_request_construct_task_context(ireq); - - /* Fill in the SSP Task IU */ - sci_task_request_build_ssp_task_iu(ireq); - - sci_change_state(&ireq->sm, SCI_REQ_CONSTRUCTED); - - return SCI_SUCCESS; -} - -static enum sci_status sci_io_request_construct_basic_sata(struct isci_request *ireq) -{ - enum sci_status status; - bool copy = false; - struct sas_task *task = isci_request_access_task(ireq); - - ireq->protocol = SCIC_STP_PROTOCOL; - - copy = (task->data_dir == DMA_NONE) ? false : true; - - status = sci_io_request_construct_sata(ireq, - task->total_xfer_len, - task->data_dir, - copy); - - if (status == SCI_SUCCESS) - sci_change_state(&ireq->sm, SCI_REQ_CONSTRUCTED); - - return status; -} - -enum sci_status sci_task_request_construct_sata(struct isci_request *ireq) -{ - enum sci_status status = SCI_SUCCESS; - - /* check for management protocols */ - if (ireq->ttype == tmf_task) { - struct isci_tmf *tmf = isci_request_access_tmf(ireq); - - if (tmf->tmf_code == isci_tmf_sata_srst_high || - tmf->tmf_code == isci_tmf_sata_srst_low) { - scu_stp_raw_request_construct_task_context(ireq); - } else { - dev_err(&ireq->owning_controller->pdev->dev, - "%s: Request 0x%p received un-handled SAT " - "Protocol 0x%x.\n", - __func__, ireq, tmf->tmf_code); - - return SCI_FAILURE; - } - } - - if (status != SCI_SUCCESS) - return status; - sci_change_state(&ireq->sm, SCI_REQ_CONSTRUCTED); - - return status; -} - -/** - * sci_req_tx_bytes - bytes transferred when reply underruns request - * @sci_req: request that was terminated early - */ -#define SCU_TASK_CONTEXT_SRAM 0x200000 -static u32 sci_req_tx_bytes(struct isci_request *ireq) -{ - struct isci_host *ihost = ireq->owning_controller; - u32 ret_val = 0; - - if (readl(&ihost->smu_registers->address_modifier) == 0) { - void __iomem *scu_reg_base = ihost->scu_registers; - - /* get the bytes of data from the Address == BAR1 + 20002Ch + (256*TCi) where - * BAR1 is the scu_registers - * 0x20002C = 0x200000 + 0x2c - * = start of task context SRAM + offset of (type.ssp.data_offset) - * TCi is the io_tag of struct sci_request - */ - ret_val = readl(scu_reg_base + - (SCU_TASK_CONTEXT_SRAM + offsetof(struct scu_task_context, type.ssp.data_offset)) + - ((sizeof(struct scu_task_context)) * ISCI_TAG_TCI(ireq->io_tag))); - } - - return ret_val; -} - -enum sci_status sci_request_start(struct isci_request *ireq) -{ - enum sci_base_request_states state; - struct scu_task_context *tc = ireq->tc; - struct isci_host *ihost = ireq->owning_controller; - - state = ireq->sm.current_state_id; - if (state != SCI_REQ_CONSTRUCTED) { - dev_warn(&ihost->pdev->dev, - "%s: SCIC IO Request requested to start while in wrong " - "state %d\n", __func__, state); - return SCI_FAILURE_INVALID_STATE; - } - - tc->task_index = ISCI_TAG_TCI(ireq->io_tag); - - switch (tc->protocol_type) { - case SCU_TASK_CONTEXT_PROTOCOL_SMP: - case SCU_TASK_CONTEXT_PROTOCOL_SSP: - /* SSP/SMP Frame */ - tc->type.ssp.tag = ireq->io_tag; - tc->type.ssp.target_port_transfer_tag = 0xFFFF; - break; - - case SCU_TASK_CONTEXT_PROTOCOL_STP: - /* STP/SATA Frame - * tc->type.stp.ncq_tag = ireq->ncq_tag; - */ - break; - - case SCU_TASK_CONTEXT_PROTOCOL_NONE: - /* / @todo When do we set no protocol type? */ - break; - - default: - /* This should never happen since we build the IO - * requests */ - break; - } - - /* Add to the post_context the io tag value */ - ireq->post_context |= ISCI_TAG_TCI(ireq->io_tag); - - /* Everything is good go ahead and change state */ - sci_change_state(&ireq->sm, SCI_REQ_STARTED); - - return SCI_SUCCESS; -} - -enum sci_status -sci_io_request_terminate(struct isci_request *ireq) -{ - enum sci_base_request_states state; - - state = ireq->sm.current_state_id; - - switch (state) { - case SCI_REQ_CONSTRUCTED: - ireq->scu_status = SCU_TASK_DONE_TASK_ABORT; - ireq->sci_status = SCI_FAILURE_IO_TERMINATED; - sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); - return SCI_SUCCESS; - case SCI_REQ_STARTED: - case SCI_REQ_TASK_WAIT_TC_COMP: - case SCI_REQ_SMP_WAIT_RESP: - case SCI_REQ_SMP_WAIT_TC_COMP: - case SCI_REQ_STP_UDMA_WAIT_TC_COMP: - case SCI_REQ_STP_UDMA_WAIT_D2H: - case SCI_REQ_STP_NON_DATA_WAIT_H2D: - case SCI_REQ_STP_NON_DATA_WAIT_D2H: - case SCI_REQ_STP_PIO_WAIT_H2D: - case SCI_REQ_STP_PIO_WAIT_FRAME: - case SCI_REQ_STP_PIO_DATA_IN: - case SCI_REQ_STP_PIO_DATA_OUT: - case SCI_REQ_STP_SOFT_RESET_WAIT_H2D_ASSERTED: - case SCI_REQ_STP_SOFT_RESET_WAIT_H2D_DIAG: - case SCI_REQ_STP_SOFT_RESET_WAIT_D2H: - sci_change_state(&ireq->sm, SCI_REQ_ABORTING); - return SCI_SUCCESS; - case SCI_REQ_TASK_WAIT_TC_RESP: - sci_change_state(&ireq->sm, SCI_REQ_ABORTING); - sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); - return SCI_SUCCESS; - case SCI_REQ_ABORTING: - sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); - return SCI_SUCCESS; - case SCI_REQ_COMPLETED: - default: - dev_warn(&ireq->owning_controller->pdev->dev, - "%s: SCIC IO Request requested to abort while in wrong " - "state %d\n", - __func__, - ireq->sm.current_state_id); - break; - } - - return SCI_FAILURE_INVALID_STATE; -} - -enum sci_status sci_request_complete(struct isci_request *ireq) -{ - enum sci_base_request_states state; - struct isci_host *ihost = ireq->owning_controller; - - state = ireq->sm.current_state_id; - if (WARN_ONCE(state != SCI_REQ_COMPLETED, - "isci: request completion from wrong state (%d)\n", state)) - return SCI_FAILURE_INVALID_STATE; - - if (ireq->saved_rx_frame_index != SCU_INVALID_FRAME_INDEX) - sci_controller_release_frame(ihost, - ireq->saved_rx_frame_index); - - /* XXX can we just stop the machine and remove the 'final' state? */ - sci_change_state(&ireq->sm, SCI_REQ_FINAL); - return SCI_SUCCESS; -} - -enum sci_status sci_io_request_event_handler(struct isci_request *ireq, - u32 event_code) -{ - enum sci_base_request_states state; - struct isci_host *ihost = ireq->owning_controller; - - state = ireq->sm.current_state_id; - - if (state != SCI_REQ_STP_PIO_DATA_IN) { - dev_warn(&ihost->pdev->dev, "%s: (%x) in wrong state %d\n", - __func__, event_code, state); - - return SCI_FAILURE_INVALID_STATE; - } - - switch (scu_get_event_specifier(event_code)) { - case SCU_TASK_DONE_CRC_ERR << SCU_EVENT_SPECIFIC_CODE_SHIFT: - /* We are waiting for data and the SCU has R_ERR the data frame. - * Go back to waiting for the D2H Register FIS - */ - sci_change_state(&ireq->sm, SCI_REQ_STP_PIO_WAIT_FRAME); - return SCI_SUCCESS; - default: - dev_err(&ihost->pdev->dev, - "%s: pio request unexpected event %#x\n", - __func__, event_code); - - /* TODO Should we fail the PIO request when we get an - * unexpected event? - */ - return SCI_FAILURE; - } -} - -/* - * This function copies response data for requests returning response data - * instead of sense data. - * @sci_req: This parameter specifies the request object for which to copy - * the response data. - */ -static void sci_io_request_copy_response(struct isci_request *ireq) -{ - void *resp_buf; - u32 len; - struct ssp_response_iu *ssp_response; - struct isci_tmf *isci_tmf = isci_request_access_tmf(ireq); - - ssp_response = &ireq->ssp.rsp; - - resp_buf = &isci_tmf->resp.resp_iu; - - len = min_t(u32, - SSP_RESP_IU_MAX_SIZE, - be32_to_cpu(ssp_response->response_data_len)); - - memcpy(resp_buf, ssp_response->resp_data, len); -} - -static enum sci_status -request_started_state_tc_event(struct isci_request *ireq, - u32 completion_code) -{ - struct ssp_response_iu *resp_iu; - u8 datapres; - - /* TODO: Any SDMA return code of other than 0 is bad decode 0x003C0000 - * to determine SDMA status - */ - switch (SCU_GET_COMPLETION_TL_STATUS(completion_code)) { - case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_GOOD): - ireq->scu_status = SCU_TASK_DONE_GOOD; - ireq->sci_status = SCI_SUCCESS; - break; - case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_EARLY_RESP): { - /* There are times when the SCU hardware will return an early - * response because the io request specified more data than is - * returned by the target device (mode pages, inquiry data, - * etc.). We must check the response stats to see if this is - * truly a failed request or a good request that just got - * completed early. - */ - struct ssp_response_iu *resp = &ireq->ssp.rsp; - ssize_t word_cnt = SSP_RESP_IU_MAX_SIZE / sizeof(u32); - - sci_swab32_cpy(&ireq->ssp.rsp, - &ireq->ssp.rsp, - word_cnt); - - if (resp->status == 0) { - ireq->scu_status = SCU_TASK_DONE_GOOD; - ireq->sci_status = SCI_SUCCESS_IO_DONE_EARLY; - } else { - ireq->scu_status = SCU_TASK_DONE_CHECK_RESPONSE; - ireq->sci_status = SCI_FAILURE_IO_RESPONSE_VALID; - } - break; - } - case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_CHECK_RESPONSE): { - ssize_t word_cnt = SSP_RESP_IU_MAX_SIZE / sizeof(u32); - - sci_swab32_cpy(&ireq->ssp.rsp, - &ireq->ssp.rsp, - word_cnt); - - ireq->scu_status = SCU_TASK_DONE_CHECK_RESPONSE; - ireq->sci_status = SCI_FAILURE_IO_RESPONSE_VALID; - break; - } - - case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_RESP_LEN_ERR): - /* TODO With TASK_DONE_RESP_LEN_ERR is the response frame - * guaranteed to be received before this completion status is - * posted? - */ - resp_iu = &ireq->ssp.rsp; - datapres = resp_iu->datapres; - - if (datapres == 1 || datapres == 2) { - ireq->scu_status = SCU_TASK_DONE_CHECK_RESPONSE; - ireq->sci_status = SCI_FAILURE_IO_RESPONSE_VALID; - } else { - ireq->scu_status = SCU_TASK_DONE_GOOD; - ireq->sci_status = SCI_SUCCESS; - } - break; - /* only stp device gets suspended. */ - case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_ACK_NAK_TO): - case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_LL_PERR): - case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_NAK_ERR): - case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_DATA_LEN_ERR): - case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_LL_ABORT_ERR): - case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_XR_WD_LEN): - case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_MAX_PLD_ERR): - case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_UNEXP_RESP): - case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_UNEXP_SDBFIS): - case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_REG_ERR): - case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_SDB_ERR): - if (ireq->protocol == SCIC_STP_PROTOCOL) { - ireq->scu_status = SCU_GET_COMPLETION_TL_STATUS(completion_code) >> - SCU_COMPLETION_TL_STATUS_SHIFT; - ireq->sci_status = SCI_FAILURE_REMOTE_DEVICE_RESET_REQUIRED; - } else { - ireq->scu_status = SCU_GET_COMPLETION_TL_STATUS(completion_code) >> - SCU_COMPLETION_TL_STATUS_SHIFT; - ireq->sci_status = SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR; - } - break; - - /* both stp/ssp device gets suspended */ - case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_LF_ERR): - case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_OPEN_REJECT_WRONG_DESTINATION): - case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_OPEN_REJECT_RESERVED_ABANDON_1): - case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_OPEN_REJECT_RESERVED_ABANDON_2): - case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_OPEN_REJECT_RESERVED_ABANDON_3): - case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_OPEN_REJECT_BAD_DESTINATION): - case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_OPEN_REJECT_ZONE_VIOLATION): - case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_OPEN_REJECT_STP_RESOURCES_BUSY): - case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_OPEN_REJECT_PROTOCOL_NOT_SUPPORTED): - case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_OPEN_REJECT_CONNECTION_RATE_NOT_SUPPORTED): - ireq->scu_status = SCU_GET_COMPLETION_TL_STATUS(completion_code) >> - SCU_COMPLETION_TL_STATUS_SHIFT; - ireq->sci_status = SCI_FAILURE_REMOTE_DEVICE_RESET_REQUIRED; - break; - - /* neither ssp nor stp gets suspended. */ - case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_NAK_CMD_ERR): - case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_UNEXP_XR): - case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_XR_IU_LEN_ERR): - case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_SDMA_ERR): - case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_OFFSET_ERR): - case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_EXCESS_DATA): - case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_SMP_RESP_TO_ERR): - case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_SMP_UFI_ERR): - case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_SMP_FRM_TYPE_ERR): - case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_SMP_LL_RX_ERR): - case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_UNEXP_DATA): - case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_OPEN_FAIL): - case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_VIIT_ENTRY_NV): - case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_IIT_ENTRY_NV): - case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_RNCNV_OUTBOUND): - default: - ireq->scu_status = SCU_GET_COMPLETION_TL_STATUS(completion_code) >> - SCU_COMPLETION_TL_STATUS_SHIFT; - ireq->sci_status = SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR; - break; - } - - /* - * TODO: This is probably wrong for ACK/NAK timeout conditions - */ - - /* In all cases we will treat this as the completion of the IO req. */ - sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); - return SCI_SUCCESS; -} - -static enum sci_status -request_aborting_state_tc_event(struct isci_request *ireq, - u32 completion_code) -{ - switch (SCU_GET_COMPLETION_TL_STATUS(completion_code)) { - case (SCU_TASK_DONE_GOOD << SCU_COMPLETION_TL_STATUS_SHIFT): - case (SCU_TASK_DONE_TASK_ABORT << SCU_COMPLETION_TL_STATUS_SHIFT): - ireq->scu_status = SCU_TASK_DONE_TASK_ABORT; - ireq->sci_status = SCI_FAILURE_IO_TERMINATED; - sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); - break; - - default: - /* Unless we get some strange error wait for the task abort to complete - * TODO: Should there be a state change for this completion? - */ - break; - } - - return SCI_SUCCESS; -} - -static enum sci_status ssp_task_request_await_tc_event(struct isci_request *ireq, - u32 completion_code) -{ - switch (SCU_GET_COMPLETION_TL_STATUS(completion_code)) { - case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_GOOD): - ireq->scu_status = SCU_TASK_DONE_GOOD; - ireq->sci_status = SCI_SUCCESS; - sci_change_state(&ireq->sm, SCI_REQ_TASK_WAIT_TC_RESP); - break; - case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_ACK_NAK_TO): - /* Currently, the decision is to simply allow the task request - * to timeout if the task IU wasn't received successfully. - * There is a potential for receiving multiple task responses if - * we decide to send the task IU again. - */ - dev_warn(&ireq->owning_controller->pdev->dev, - "%s: TaskRequest:0x%p CompletionCode:%x - " - "ACK/NAK timeout\n", __func__, ireq, - completion_code); - - sci_change_state(&ireq->sm, SCI_REQ_TASK_WAIT_TC_RESP); - break; - default: - /* - * All other completion status cause the IO to be complete. - * If a NAK was received, then it is up to the user to retry - * the request. - */ - ireq->scu_status = SCU_NORMALIZE_COMPLETION_STATUS(completion_code); - ireq->sci_status = SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR; - sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); - break; - } - - return SCI_SUCCESS; -} - -static enum sci_status -smp_request_await_response_tc_event(struct isci_request *ireq, - u32 completion_code) -{ - switch (SCU_GET_COMPLETION_TL_STATUS(completion_code)) { - case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_GOOD): - /* In the AWAIT RESPONSE state, any TC completion is - * unexpected. but if the TC has success status, we - * complete the IO anyway. - */ - ireq->scu_status = SCU_TASK_DONE_GOOD; - ireq->sci_status = SCI_SUCCESS; - sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); - break; - case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_SMP_RESP_TO_ERR): - case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_SMP_UFI_ERR): - case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_SMP_FRM_TYPE_ERR): - case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_SMP_LL_RX_ERR): - /* These status has been seen in a specific LSI - * expander, which sometimes is not able to send smp - * response within 2 ms. This causes our hardware break - * the connection and set TC completion with one of - * these SMP_XXX_XX_ERR status. For these type of error, - * we ask ihost user to retry the request. - */ - ireq->scu_status = SCU_TASK_DONE_SMP_RESP_TO_ERR; - ireq->sci_status = SCI_FAILURE_RETRY_REQUIRED; - sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); - break; - default: - /* All other completion status cause the IO to be complete. If a NAK - * was received, then it is up to the user to retry the request - */ - ireq->scu_status = SCU_NORMALIZE_COMPLETION_STATUS(completion_code); - ireq->sci_status = SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR; - sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); - break; - } - - return SCI_SUCCESS; -} - -static enum sci_status -smp_request_await_tc_event(struct isci_request *ireq, - u32 completion_code) -{ - switch (SCU_GET_COMPLETION_TL_STATUS(completion_code)) { - case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_GOOD): - ireq->scu_status = SCU_TASK_DONE_GOOD; - ireq->sci_status = SCI_SUCCESS; - sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); - break; - default: - /* All other completion status cause the IO to be - * complete. If a NAK was received, then it is up to - * the user to retry the request. - */ - ireq->scu_status = SCU_NORMALIZE_COMPLETION_STATUS(completion_code); - ireq->sci_status = SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR; - sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); - break; - } - - return SCI_SUCCESS; -} - -static struct scu_sgl_element *pio_sgl_next(struct isci_stp_request *stp_req) -{ - struct scu_sgl_element *sgl; - struct scu_sgl_element_pair *sgl_pair; - struct isci_request *ireq = to_ireq(stp_req); - struct isci_stp_pio_sgl *pio_sgl = &stp_req->sgl; - - sgl_pair = to_sgl_element_pair(ireq, pio_sgl->index); - if (!sgl_pair) - sgl = NULL; - else if (pio_sgl->set == SCU_SGL_ELEMENT_PAIR_A) { - if (sgl_pair->B.address_lower == 0 && - sgl_pair->B.address_upper == 0) { - sgl = NULL; - } else { - pio_sgl->set = SCU_SGL_ELEMENT_PAIR_B; - sgl = &sgl_pair->B; - } - } else { - if (sgl_pair->next_pair_lower == 0 && - sgl_pair->next_pair_upper == 0) { - sgl = NULL; - } else { - pio_sgl->index++; - pio_sgl->set = SCU_SGL_ELEMENT_PAIR_A; - sgl_pair = to_sgl_element_pair(ireq, pio_sgl->index); - sgl = &sgl_pair->A; - } - } - - return sgl; -} - -static enum sci_status -stp_request_non_data_await_h2d_tc_event(struct isci_request *ireq, - u32 completion_code) -{ - switch (SCU_GET_COMPLETION_TL_STATUS(completion_code)) { - case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_GOOD): - ireq->scu_status = SCU_TASK_DONE_GOOD; - ireq->sci_status = SCI_SUCCESS; - sci_change_state(&ireq->sm, SCI_REQ_STP_NON_DATA_WAIT_D2H); - break; - - default: - /* All other completion status cause the IO to be - * complete. If a NAK was received, then it is up to - * the user to retry the request. - */ - ireq->scu_status = SCU_NORMALIZE_COMPLETION_STATUS(completion_code); - ireq->sci_status = SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR; - sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); - break; - } - - return SCI_SUCCESS; -} - -#define SCU_MAX_FRAME_BUFFER_SIZE 0x400 /* 1K is the maximum SCU frame data payload */ - -/* transmit DATA_FIS from (current sgl + offset) for input - * parameter length. current sgl and offset is alreay stored in the IO request - */ -static enum sci_status sci_stp_request_pio_data_out_trasmit_data_frame( - struct isci_request *ireq, - u32 length) -{ - struct isci_stp_request *stp_req = &ireq->stp.req; - struct scu_task_context *task_context = ireq->tc; - struct scu_sgl_element_pair *sgl_pair; - struct scu_sgl_element *current_sgl; - - /* Recycle the TC and reconstruct it for sending out DATA FIS containing - * for the data from current_sgl+offset for the input length - */ - sgl_pair = to_sgl_element_pair(ireq, stp_req->sgl.index); - if (stp_req->sgl.set == SCU_SGL_ELEMENT_PAIR_A) - current_sgl = &sgl_pair->A; - else - current_sgl = &sgl_pair->B; - - /* update the TC */ - task_context->command_iu_upper = current_sgl->address_upper; - task_context->command_iu_lower = current_sgl->address_lower; - task_context->transfer_length_bytes = length; - task_context->type.stp.fis_type = FIS_DATA; - - /* send the new TC out. */ - return sci_controller_continue_io(ireq); -} - -static enum sci_status sci_stp_request_pio_data_out_transmit_data(struct isci_request *ireq) -{ - struct isci_stp_request *stp_req = &ireq->stp.req; - struct scu_sgl_element_pair *sgl_pair; - struct scu_sgl_element *sgl; - enum sci_status status; - u32 offset; - u32 len = 0; - - offset = stp_req->sgl.offset; - sgl_pair = to_sgl_element_pair(ireq, stp_req->sgl.index); - if (WARN_ONCE(!sgl_pair, "%s: null sgl element", __func__)) - return SCI_FAILURE; - - if (stp_req->sgl.set == SCU_SGL_ELEMENT_PAIR_A) { - sgl = &sgl_pair->A; - len = sgl_pair->A.length - offset; - } else { - sgl = &sgl_pair->B; - len = sgl_pair->B.length - offset; - } - - if (stp_req->pio_len == 0) - return SCI_SUCCESS; - - if (stp_req->pio_len >= len) { - status = sci_stp_request_pio_data_out_trasmit_data_frame(ireq, len); - if (status != SCI_SUCCESS) - return status; - stp_req->pio_len -= len; - - /* update the current sgl, offset and save for future */ - sgl = pio_sgl_next(stp_req); - offset = 0; - } else if (stp_req->pio_len < len) { - sci_stp_request_pio_data_out_trasmit_data_frame(ireq, stp_req->pio_len); - - /* Sgl offset will be adjusted and saved for future */ - offset += stp_req->pio_len; - sgl->address_lower += stp_req->pio_len; - stp_req->pio_len = 0; - } - - stp_req->sgl.offset = offset; - - return status; -} - -/** - * - * @stp_request: The request that is used for the SGL processing. - * @data_buffer: The buffer of data to be copied. - * @length: The length of the data transfer. - * - * Copy the data from the buffer for the length specified to the IO reqeust SGL - * specified data region. enum sci_status - */ -static enum sci_status -sci_stp_request_pio_data_in_copy_data_buffer(struct isci_stp_request *stp_req, - u8 *data_buf, u32 len) -{ - struct isci_request *ireq; - u8 *src_addr; - int copy_len; - struct sas_task *task; - struct scatterlist *sg; - void *kaddr; - int total_len = len; - - ireq = to_ireq(stp_req); - task = isci_request_access_task(ireq); - src_addr = data_buf; - - if (task->num_scatter > 0) { - sg = task->scatter; - - while (total_len > 0) { - struct page *page = sg_page(sg); - - copy_len = min_t(int, total_len, sg_dma_len(sg)); - kaddr = kmap_atomic(page, KM_IRQ0); - memcpy(kaddr + sg->offset, src_addr, copy_len); - kunmap_atomic(kaddr, KM_IRQ0); - total_len -= copy_len; - src_addr += copy_len; - sg = sg_next(sg); - } - } else { - BUG_ON(task->total_xfer_len < total_len); - memcpy(task->scatter, src_addr, total_len); - } - - return SCI_SUCCESS; -} - -/** - * - * @sci_req: The PIO DATA IN request that is to receive the data. - * @data_buffer: The buffer to copy from. - * - * Copy the data buffer to the io request data region. enum sci_status - */ -static enum sci_status sci_stp_request_pio_data_in_copy_data( - struct isci_stp_request *stp_req, - u8 *data_buffer) -{ - enum sci_status status; - - /* - * If there is less than 1K remaining in the transfer request - * copy just the data for the transfer */ - if (stp_req->pio_len < SCU_MAX_FRAME_BUFFER_SIZE) { - status = sci_stp_request_pio_data_in_copy_data_buffer( - stp_req, data_buffer, stp_req->pio_len); - - if (status == SCI_SUCCESS) - stp_req->pio_len = 0; - } else { - /* We are transfering the whole frame so copy */ - status = sci_stp_request_pio_data_in_copy_data_buffer( - stp_req, data_buffer, SCU_MAX_FRAME_BUFFER_SIZE); - - if (status == SCI_SUCCESS) - stp_req->pio_len -= SCU_MAX_FRAME_BUFFER_SIZE; - } - - return status; -} - -static enum sci_status -stp_request_pio_await_h2d_completion_tc_event(struct isci_request *ireq, - u32 completion_code) -{ - enum sci_status status = SCI_SUCCESS; - - switch (SCU_GET_COMPLETION_TL_STATUS(completion_code)) { - case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_GOOD): - ireq->scu_status = SCU_TASK_DONE_GOOD; - ireq->sci_status = SCI_SUCCESS; - sci_change_state(&ireq->sm, SCI_REQ_STP_PIO_WAIT_FRAME); - break; - - default: - /* All other completion status cause the IO to be - * complete. If a NAK was received, then it is up to - * the user to retry the request. - */ - ireq->scu_status = SCU_NORMALIZE_COMPLETION_STATUS(completion_code); - ireq->sci_status = SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR; - sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); - break; - } - - return status; -} - -static enum sci_status -pio_data_out_tx_done_tc_event(struct isci_request *ireq, - u32 completion_code) -{ - enum sci_status status = SCI_SUCCESS; - bool all_frames_transferred = false; - struct isci_stp_request *stp_req = &ireq->stp.req; - - switch (SCU_GET_COMPLETION_TL_STATUS(completion_code)) { - case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_GOOD): - /* Transmit data */ - if (stp_req->pio_len != 0) { - status = sci_stp_request_pio_data_out_transmit_data(ireq); - if (status == SCI_SUCCESS) { - if (stp_req->pio_len == 0) - all_frames_transferred = true; - } - } else if (stp_req->pio_len == 0) { - /* - * this will happen if the all data is written at the - * first time after the pio setup fis is received - */ - all_frames_transferred = true; - } - - /* all data transferred. */ - if (all_frames_transferred) { - /* - * Change the state to SCI_REQ_STP_PIO_DATA_IN - * and wait for PIO_SETUP fis / or D2H REg fis. */ - sci_change_state(&ireq->sm, SCI_REQ_STP_PIO_WAIT_FRAME); - } - break; - - default: - /* - * All other completion status cause the IO to be complete. - * If a NAK was received, then it is up to the user to retry - * the request. - */ - ireq->scu_status = SCU_NORMALIZE_COMPLETION_STATUS(completion_code); - ireq->sci_status = SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR; - sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); - break; - } - - return status; -} - -static enum sci_status sci_stp_request_udma_general_frame_handler(struct isci_request *ireq, - u32 frame_index) -{ - struct isci_host *ihost = ireq->owning_controller; - struct dev_to_host_fis *frame_header; - enum sci_status status; - u32 *frame_buffer; - - status = sci_unsolicited_frame_control_get_header(&ihost->uf_control, - frame_index, - (void **)&frame_header); - - if ((status == SCI_SUCCESS) && - (frame_header->fis_type == FIS_REGD2H)) { - sci_unsolicited_frame_control_get_buffer(&ihost->uf_control, - frame_index, - (void **)&frame_buffer); - - sci_controller_copy_sata_response(&ireq->stp.rsp, - frame_header, - frame_buffer); - } - - sci_controller_release_frame(ihost, frame_index); - - return status; -} - -enum sci_status -sci_io_request_frame_handler(struct isci_request *ireq, - u32 frame_index) -{ - struct isci_host *ihost = ireq->owning_controller; - struct isci_stp_request *stp_req = &ireq->stp.req; - enum sci_base_request_states state; - enum sci_status status; - ssize_t word_cnt; - - state = ireq->sm.current_state_id; - switch (state) { - case SCI_REQ_STARTED: { - struct ssp_frame_hdr ssp_hdr; - void *frame_header; - - sci_unsolicited_frame_control_get_header(&ihost->uf_control, - frame_index, - &frame_header); - - word_cnt = sizeof(struct ssp_frame_hdr) / sizeof(u32); - sci_swab32_cpy(&ssp_hdr, frame_header, word_cnt); - - if (ssp_hdr.frame_type == SSP_RESPONSE) { - struct ssp_response_iu *resp_iu; - ssize_t word_cnt = SSP_RESP_IU_MAX_SIZE / sizeof(u32); - - sci_unsolicited_frame_control_get_buffer(&ihost->uf_control, - frame_index, - (void **)&resp_iu); - - sci_swab32_cpy(&ireq->ssp.rsp, resp_iu, word_cnt); - - resp_iu = &ireq->ssp.rsp; - - if (resp_iu->datapres == 0x01 || - resp_iu->datapres == 0x02) { - ireq->scu_status = SCU_TASK_DONE_CHECK_RESPONSE; - ireq->sci_status = SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR; - } else { - ireq->scu_status = SCU_TASK_DONE_GOOD; - ireq->sci_status = SCI_SUCCESS; - } - } else { - /* not a response frame, why did it get forwarded? */ - dev_err(&ihost->pdev->dev, - "%s: SCIC IO Request 0x%p received unexpected " - "frame %d type 0x%02x\n", __func__, ireq, - frame_index, ssp_hdr.frame_type); - } - - /* - * In any case we are done with this frame buffer return it to - * the controller - */ - sci_controller_release_frame(ihost, frame_index); - - return SCI_SUCCESS; - } - - case SCI_REQ_TASK_WAIT_TC_RESP: - sci_io_request_copy_response(ireq); - sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); - sci_controller_release_frame(ihost, frame_index); - return SCI_SUCCESS; - - case SCI_REQ_SMP_WAIT_RESP: { - struct smp_resp *rsp_hdr = &ireq->smp.rsp; - void *frame_header; - - sci_unsolicited_frame_control_get_header(&ihost->uf_control, - frame_index, - &frame_header); - - /* byte swap the header. */ - word_cnt = SMP_RESP_HDR_SZ / sizeof(u32); - sci_swab32_cpy(rsp_hdr, frame_header, word_cnt); - - if (rsp_hdr->frame_type == SMP_RESPONSE) { - void *smp_resp; - - sci_unsolicited_frame_control_get_buffer(&ihost->uf_control, - frame_index, - &smp_resp); - - word_cnt = (sizeof(struct smp_resp) - SMP_RESP_HDR_SZ) / - sizeof(u32); - - sci_swab32_cpy(((u8 *) rsp_hdr) + SMP_RESP_HDR_SZ, - smp_resp, word_cnt); - - ireq->scu_status = SCU_TASK_DONE_GOOD; - ireq->sci_status = SCI_SUCCESS; - sci_change_state(&ireq->sm, SCI_REQ_SMP_WAIT_TC_COMP); - } else { - /* - * This was not a response frame why did it get - * forwarded? - */ - dev_err(&ihost->pdev->dev, - "%s: SCIC SMP Request 0x%p received unexpected " - "frame %d type 0x%02x\n", - __func__, - ireq, - frame_index, - rsp_hdr->frame_type); - - ireq->scu_status = SCU_TASK_DONE_SMP_FRM_TYPE_ERR; - ireq->sci_status = SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR; - sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); - } - - sci_controller_release_frame(ihost, frame_index); - - return SCI_SUCCESS; - } - - case SCI_REQ_STP_UDMA_WAIT_TC_COMP: - return sci_stp_request_udma_general_frame_handler(ireq, - frame_index); - - case SCI_REQ_STP_UDMA_WAIT_D2H: - /* Use the general frame handler to copy the resposne data */ - status = sci_stp_request_udma_general_frame_handler(ireq, frame_index); - - if (status != SCI_SUCCESS) - return status; - - ireq->scu_status = SCU_TASK_DONE_CHECK_RESPONSE; - ireq->sci_status = SCI_FAILURE_IO_RESPONSE_VALID; - sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); - return SCI_SUCCESS; - - case SCI_REQ_STP_NON_DATA_WAIT_D2H: { - struct dev_to_host_fis *frame_header; - u32 *frame_buffer; - - status = sci_unsolicited_frame_control_get_header(&ihost->uf_control, - frame_index, - (void **)&frame_header); - - if (status != SCI_SUCCESS) { - dev_err(&ihost->pdev->dev, - "%s: SCIC IO Request 0x%p could not get frame " - "header for frame index %d, status %x\n", - __func__, - stp_req, - frame_index, - status); - - return status; - } - - switch (frame_header->fis_type) { - case FIS_REGD2H: - sci_unsolicited_frame_control_get_buffer(&ihost->uf_control, - frame_index, - (void **)&frame_buffer); - - sci_controller_copy_sata_response(&ireq->stp.rsp, - frame_header, - frame_buffer); - - /* The command has completed with error */ - ireq->scu_status = SCU_TASK_DONE_CHECK_RESPONSE; - ireq->sci_status = SCI_FAILURE_IO_RESPONSE_VALID; - break; - - default: - dev_warn(&ihost->pdev->dev, - "%s: IO Request:0x%p Frame Id:%d protocol " - "violation occurred\n", __func__, stp_req, - frame_index); - - ireq->scu_status = SCU_TASK_DONE_UNEXP_FIS; - ireq->sci_status = SCI_FAILURE_PROTOCOL_VIOLATION; - break; - } - - sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); - - /* Frame has been decoded return it to the controller */ - sci_controller_release_frame(ihost, frame_index); - - return status; - } - - case SCI_REQ_STP_PIO_WAIT_FRAME: { - struct sas_task *task = isci_request_access_task(ireq); - struct dev_to_host_fis *frame_header; - u32 *frame_buffer; - - status = sci_unsolicited_frame_control_get_header(&ihost->uf_control, - frame_index, - (void **)&frame_header); - - if (status != SCI_SUCCESS) { - dev_err(&ihost->pdev->dev, - "%s: SCIC IO Request 0x%p could not get frame " - "header for frame index %d, status %x\n", - __func__, stp_req, frame_index, status); - return status; - } - - switch (frame_header->fis_type) { - case FIS_PIO_SETUP: - /* Get from the frame buffer the PIO Setup Data */ - sci_unsolicited_frame_control_get_buffer(&ihost->uf_control, - frame_index, - (void **)&frame_buffer); - - /* Get the data from the PIO Setup The SCU Hardware - * returns first word in the frame_header and the rest - * of the data is in the frame buffer so we need to - * back up one dword - */ - - /* transfer_count: first 16bits in the 4th dword */ - stp_req->pio_len = frame_buffer[3] & 0xffff; - - /* status: 4th byte in the 3rd dword */ - stp_req->status = (frame_buffer[2] >> 24) & 0xff; - - sci_controller_copy_sata_response(&ireq->stp.rsp, - frame_header, - frame_buffer); - - ireq->stp.rsp.status = stp_req->status; - - /* The next state is dependent on whether the - * request was PIO Data-in or Data out - */ - if (task->data_dir == DMA_FROM_DEVICE) { - sci_change_state(&ireq->sm, SCI_REQ_STP_PIO_DATA_IN); - } else if (task->data_dir == DMA_TO_DEVICE) { - /* Transmit data */ - status = sci_stp_request_pio_data_out_transmit_data(ireq); - if (status != SCI_SUCCESS) - break; - sci_change_state(&ireq->sm, SCI_REQ_STP_PIO_DATA_OUT); - } - break; - - case FIS_SETDEVBITS: - sci_change_state(&ireq->sm, SCI_REQ_STP_PIO_WAIT_FRAME); - break; - - case FIS_REGD2H: - if (frame_header->status & ATA_BUSY) { - /* - * Now why is the drive sending a D2H Register - * FIS when it is still busy? Do nothing since - * we are still in the right state. - */ - dev_dbg(&ihost->pdev->dev, - "%s: SCIC PIO Request 0x%p received " - "D2H Register FIS with BSY status " - "0x%x\n", - __func__, - stp_req, - frame_header->status); - break; - } - - sci_unsolicited_frame_control_get_buffer(&ihost->uf_control, - frame_index, - (void **)&frame_buffer); - - sci_controller_copy_sata_response(&ireq->stp.req, - frame_header, - frame_buffer); - - ireq->scu_status = SCU_TASK_DONE_CHECK_RESPONSE; - ireq->sci_status = SCI_FAILURE_IO_RESPONSE_VALID; - sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); - break; - - default: - /* FIXME: what do we do here? */ - break; - } - - /* Frame is decoded return it to the controller */ - sci_controller_release_frame(ihost, frame_index); - - return status; - } - - case SCI_REQ_STP_PIO_DATA_IN: { - struct dev_to_host_fis *frame_header; - struct sata_fis_data *frame_buffer; - - status = sci_unsolicited_frame_control_get_header(&ihost->uf_control, - frame_index, - (void **)&frame_header); - - if (status != SCI_SUCCESS) { - dev_err(&ihost->pdev->dev, - "%s: SCIC IO Request 0x%p could not get frame " - "header for frame index %d, status %x\n", - __func__, - stp_req, - frame_index, - status); - return status; - } - - if (frame_header->fis_type != FIS_DATA) { - dev_err(&ihost->pdev->dev, - "%s: SCIC PIO Request 0x%p received frame %d " - "with fis type 0x%02x when expecting a data " - "fis.\n", - __func__, - stp_req, - frame_index, - frame_header->fis_type); - - ireq->scu_status = SCU_TASK_DONE_GOOD; - ireq->sci_status = SCI_FAILURE_IO_REQUIRES_SCSI_ABORT; - sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); - - /* Frame is decoded return it to the controller */ - sci_controller_release_frame(ihost, frame_index); - return status; - } - - if (stp_req->sgl.index < 0) { - ireq->saved_rx_frame_index = frame_index; - stp_req->pio_len = 0; - } else { - sci_unsolicited_frame_control_get_buffer(&ihost->uf_control, - frame_index, - (void **)&frame_buffer); - - status = sci_stp_request_pio_data_in_copy_data(stp_req, - (u8 *)frame_buffer); - - /* Frame is decoded return it to the controller */ - sci_controller_release_frame(ihost, frame_index); - } - - /* Check for the end of the transfer, are there more - * bytes remaining for this data transfer - */ - if (status != SCI_SUCCESS || stp_req->pio_len != 0) - return status; - - if ((stp_req->status & ATA_BUSY) == 0) { - ireq->scu_status = SCU_TASK_DONE_CHECK_RESPONSE; - ireq->sci_status = SCI_FAILURE_IO_RESPONSE_VALID; - sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); - } else { - sci_change_state(&ireq->sm, SCI_REQ_STP_PIO_WAIT_FRAME); - } - return status; - } - - case SCI_REQ_STP_SOFT_RESET_WAIT_D2H: { - struct dev_to_host_fis *frame_header; - u32 *frame_buffer; - - status = sci_unsolicited_frame_control_get_header(&ihost->uf_control, - frame_index, - (void **)&frame_header); - if (status != SCI_SUCCESS) { - dev_err(&ihost->pdev->dev, - "%s: SCIC IO Request 0x%p could not get frame " - "header for frame index %d, status %x\n", - __func__, - stp_req, - frame_index, - status); - return status; - } - - switch (frame_header->fis_type) { - case FIS_REGD2H: - sci_unsolicited_frame_control_get_buffer(&ihost->uf_control, - frame_index, - (void **)&frame_buffer); - - sci_controller_copy_sata_response(&ireq->stp.rsp, - frame_header, - frame_buffer); - - /* The command has completed with error */ - ireq->scu_status = SCU_TASK_DONE_CHECK_RESPONSE; - ireq->sci_status = SCI_FAILURE_IO_RESPONSE_VALID; - break; - - default: - dev_warn(&ihost->pdev->dev, - "%s: IO Request:0x%p Frame Id:%d protocol " - "violation occurred\n", - __func__, - stp_req, - frame_index); - - ireq->scu_status = SCU_TASK_DONE_UNEXP_FIS; - ireq->sci_status = SCI_FAILURE_PROTOCOL_VIOLATION; - break; - } - - sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); - - /* Frame has been decoded return it to the controller */ - sci_controller_release_frame(ihost, frame_index); - - return status; - } - case SCI_REQ_ABORTING: - /* - * TODO: Is it even possible to get an unsolicited frame in the - * aborting state? - */ - sci_controller_release_frame(ihost, frame_index); - return SCI_SUCCESS; - - default: - dev_warn(&ihost->pdev->dev, - "%s: SCIC IO Request given unexpected frame %x while " - "in state %d\n", - __func__, - frame_index, - state); - - sci_controller_release_frame(ihost, frame_index); - return SCI_FAILURE_INVALID_STATE; - } -} - -static enum sci_status stp_request_udma_await_tc_event(struct isci_request *ireq, - u32 completion_code) -{ - enum sci_status status = SCI_SUCCESS; - - switch (SCU_GET_COMPLETION_TL_STATUS(completion_code)) { - case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_GOOD): - ireq->scu_status = SCU_TASK_DONE_GOOD; - ireq->sci_status = SCI_SUCCESS; - sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); - break; - case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_UNEXP_FIS): - case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_REG_ERR): - /* We must check ther response buffer to see if the D2H - * Register FIS was received before we got the TC - * completion. - */ - if (ireq->stp.rsp.fis_type == FIS_REGD2H) { - sci_remote_device_suspend(ireq->target_device, - SCU_EVENT_SPECIFIC(SCU_NORMALIZE_COMPLETION_STATUS(completion_code))); - - ireq->scu_status = SCU_TASK_DONE_CHECK_RESPONSE; - ireq->sci_status = SCI_FAILURE_IO_RESPONSE_VALID; - sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); - } else { - /* If we have an error completion status for the - * TC then we can expect a D2H register FIS from - * the device so we must change state to wait - * for it - */ - sci_change_state(&ireq->sm, SCI_REQ_STP_UDMA_WAIT_D2H); - } - break; - - /* TODO Check to see if any of these completion status need to - * wait for the device to host register fis. - */ - /* TODO We can retry the command for SCU_TASK_DONE_CMD_LL_R_ERR - * - this comes only for B0 - */ - case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_INV_FIS_LEN): - case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_MAX_PLD_ERR): - case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_LL_R_ERR): - case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_CMD_LL_R_ERR): - case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_CRC_ERR): - sci_remote_device_suspend(ireq->target_device, - SCU_EVENT_SPECIFIC(SCU_NORMALIZE_COMPLETION_STATUS(completion_code))); - /* Fall through to the default case */ - default: - /* All other completion status cause the IO to be complete. */ - ireq->scu_status = SCU_NORMALIZE_COMPLETION_STATUS(completion_code); - ireq->sci_status = SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR; - sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); - break; - } - - return status; -} - -static enum sci_status -stp_request_soft_reset_await_h2d_asserted_tc_event(struct isci_request *ireq, - u32 completion_code) -{ - switch (SCU_GET_COMPLETION_TL_STATUS(completion_code)) { - case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_GOOD): - ireq->scu_status = SCU_TASK_DONE_GOOD; - ireq->sci_status = SCI_SUCCESS; - sci_change_state(&ireq->sm, SCI_REQ_STP_SOFT_RESET_WAIT_H2D_DIAG); - break; - - default: - /* - * All other completion status cause the IO to be complete. - * If a NAK was received, then it is up to the user to retry - * the request. - */ - ireq->scu_status = SCU_NORMALIZE_COMPLETION_STATUS(completion_code); - ireq->sci_status = SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR; - sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); - break; - } - - return SCI_SUCCESS; -} - -static enum sci_status -stp_request_soft_reset_await_h2d_diagnostic_tc_event(struct isci_request *ireq, - u32 completion_code) -{ - switch (SCU_GET_COMPLETION_TL_STATUS(completion_code)) { - case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_GOOD): - ireq->scu_status = SCU_TASK_DONE_GOOD; - ireq->sci_status = SCI_SUCCESS; - sci_change_state(&ireq->sm, SCI_REQ_STP_SOFT_RESET_WAIT_D2H); - break; - - default: - /* All other completion status cause the IO to be complete. If - * a NAK was received, then it is up to the user to retry the - * request. - */ - ireq->scu_status = SCU_NORMALIZE_COMPLETION_STATUS(completion_code); - ireq->sci_status = SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR; - sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); - break; - } - - return SCI_SUCCESS; -} - -enum sci_status -sci_io_request_tc_completion(struct isci_request *ireq, - u32 completion_code) -{ - enum sci_base_request_states state; - struct isci_host *ihost = ireq->owning_controller; - - state = ireq->sm.current_state_id; - - switch (state) { - case SCI_REQ_STARTED: - return request_started_state_tc_event(ireq, completion_code); - - case SCI_REQ_TASK_WAIT_TC_COMP: - return ssp_task_request_await_tc_event(ireq, - completion_code); - - case SCI_REQ_SMP_WAIT_RESP: - return smp_request_await_response_tc_event(ireq, - completion_code); - - case SCI_REQ_SMP_WAIT_TC_COMP: - return smp_request_await_tc_event(ireq, completion_code); - - case SCI_REQ_STP_UDMA_WAIT_TC_COMP: - return stp_request_udma_await_tc_event(ireq, - completion_code); - - case SCI_REQ_STP_NON_DATA_WAIT_H2D: - return stp_request_non_data_await_h2d_tc_event(ireq, - completion_code); - - case SCI_REQ_STP_PIO_WAIT_H2D: - return stp_request_pio_await_h2d_completion_tc_event(ireq, - completion_code); - - case SCI_REQ_STP_PIO_DATA_OUT: - return pio_data_out_tx_done_tc_event(ireq, completion_code); - - case SCI_REQ_STP_SOFT_RESET_WAIT_H2D_ASSERTED: - return stp_request_soft_reset_await_h2d_asserted_tc_event(ireq, - completion_code); - - case SCI_REQ_STP_SOFT_RESET_WAIT_H2D_DIAG: - return stp_request_soft_reset_await_h2d_diagnostic_tc_event(ireq, - completion_code); - - case SCI_REQ_ABORTING: - return request_aborting_state_tc_event(ireq, - completion_code); - - default: - dev_warn(&ihost->pdev->dev, - "%s: SCIC IO Request given task completion " - "notification %x while in wrong state %d\n", - __func__, - completion_code, - state); - return SCI_FAILURE_INVALID_STATE; - } -} - -/** - * isci_request_process_response_iu() - This function sets the status and - * response iu, in the task struct, from the request object for the upper - * layer driver. - * @sas_task: This parameter is the task struct from the upper layer driver. - * @resp_iu: This parameter points to the response iu of the completed request. - * @dev: This parameter specifies the linux device struct. - * - * none. - */ -static void isci_request_process_response_iu( - struct sas_task *task, - struct ssp_response_iu *resp_iu, - struct device *dev) -{ - dev_dbg(dev, - "%s: resp_iu = %p " - "resp_iu->status = 0x%x,\nresp_iu->datapres = %d " - "resp_iu->response_data_len = %x, " - "resp_iu->sense_data_len = %x\nrepsonse data: ", - __func__, - resp_iu, - resp_iu->status, - resp_iu->datapres, - resp_iu->response_data_len, - resp_iu->sense_data_len); - - task->task_status.stat = resp_iu->status; - - /* libsas updates the task status fields based on the response iu. */ - sas_ssp_task_response(dev, task, resp_iu); -} - -/** - * isci_request_set_open_reject_status() - This function prepares the I/O - * completion for OPEN_REJECT conditions. - * @request: This parameter is the completed isci_request object. - * @response_ptr: This parameter specifies the service response for the I/O. - * @status_ptr: This parameter specifies the exec status for the I/O. - * @complete_to_host_ptr: This parameter specifies the action to be taken by - * the LLDD with respect to completing this request or forcing an abort - * condition on the I/O. - * @open_rej_reason: This parameter specifies the encoded reason for the - * abandon-class reject. - * - * none. - */ -static void isci_request_set_open_reject_status( - struct isci_request *request, - struct sas_task *task, - enum service_response *response_ptr, - enum exec_status *status_ptr, - enum isci_completion_selection *complete_to_host_ptr, - enum sas_open_rej_reason open_rej_reason) -{ - /* Task in the target is done. */ - set_bit(IREQ_COMPLETE_IN_TARGET, &request->flags); - *response_ptr = SAS_TASK_UNDELIVERED; - *status_ptr = SAS_OPEN_REJECT; - *complete_to_host_ptr = isci_perform_normal_io_completion; - task->task_status.open_rej_reason = open_rej_reason; -} - -/** - * isci_request_handle_controller_specific_errors() - This function decodes - * controller-specific I/O completion error conditions. - * @request: This parameter is the completed isci_request object. - * @response_ptr: This parameter specifies the service response for the I/O. - * @status_ptr: This parameter specifies the exec status for the I/O. - * @complete_to_host_ptr: This parameter specifies the action to be taken by - * the LLDD with respect to completing this request or forcing an abort - * condition on the I/O. - * - * none. - */ -static void isci_request_handle_controller_specific_errors( - struct isci_remote_device *idev, - struct isci_request *request, - struct sas_task *task, - enum service_response *response_ptr, - enum exec_status *status_ptr, - enum isci_completion_selection *complete_to_host_ptr) -{ - unsigned int cstatus; - - cstatus = request->scu_status; - - dev_dbg(&request->isci_host->pdev->dev, - "%s: %p SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR " - "- controller status = 0x%x\n", - __func__, request, cstatus); - - /* Decode the controller-specific errors; most - * important is to recognize those conditions in which - * the target may still have a task outstanding that - * must be aborted. - * - * Note that there are SCU completion codes being - * named in the decode below for which SCIC has already - * done work to handle them in a way other than as - * a controller-specific completion code; these are left - * in the decode below for completeness sake. - */ - switch (cstatus) { - case SCU_TASK_DONE_DMASETUP_DIRERR: - /* Also SCU_TASK_DONE_SMP_FRM_TYPE_ERR: */ - case SCU_TASK_DONE_XFERCNT_ERR: - /* Also SCU_TASK_DONE_SMP_UFI_ERR: */ - if (task->task_proto == SAS_PROTOCOL_SMP) { - /* SCU_TASK_DONE_SMP_UFI_ERR == Task Done. */ - *response_ptr = SAS_TASK_COMPLETE; - - /* See if the device has been/is being stopped. Note - * that we ignore the quiesce state, since we are - * concerned about the actual device state. - */ - if (!idev) - *status_ptr = SAS_DEVICE_UNKNOWN; - else - *status_ptr = SAS_ABORTED_TASK; - - set_bit(IREQ_COMPLETE_IN_TARGET, &request->flags); - - *complete_to_host_ptr = - isci_perform_normal_io_completion; - } else { - /* Task in the target is not done. */ - *response_ptr = SAS_TASK_UNDELIVERED; - - if (!idev) - *status_ptr = SAS_DEVICE_UNKNOWN; - else - *status_ptr = SAM_STAT_TASK_ABORTED; - - clear_bit(IREQ_COMPLETE_IN_TARGET, &request->flags); - - *complete_to_host_ptr = - isci_perform_error_io_completion; - } - - break; - - case SCU_TASK_DONE_CRC_ERR: - case SCU_TASK_DONE_NAK_CMD_ERR: - case SCU_TASK_DONE_EXCESS_DATA: - case SCU_TASK_DONE_UNEXP_FIS: - /* Also SCU_TASK_DONE_UNEXP_RESP: */ - case SCU_TASK_DONE_VIIT_ENTRY_NV: /* TODO - conditions? */ - case SCU_TASK_DONE_IIT_ENTRY_NV: /* TODO - conditions? */ - case SCU_TASK_DONE_RNCNV_OUTBOUND: /* TODO - conditions? */ - /* These are conditions in which the target - * has completed the task, so that no cleanup - * is necessary. - */ - *response_ptr = SAS_TASK_COMPLETE; - - /* See if the device has been/is being stopped. Note - * that we ignore the quiesce state, since we are - * concerned about the actual device state. - */ - if (!idev) - *status_ptr = SAS_DEVICE_UNKNOWN; - else - *status_ptr = SAS_ABORTED_TASK; - - set_bit(IREQ_COMPLETE_IN_TARGET, &request->flags); - - *complete_to_host_ptr = isci_perform_normal_io_completion; - break; - - - /* Note that the only open reject completion codes seen here will be - * abandon-class codes; all others are automatically retried in the SCU. - */ - case SCU_TASK_OPEN_REJECT_WRONG_DESTINATION: - - isci_request_set_open_reject_status( - request, task, response_ptr, status_ptr, - complete_to_host_ptr, SAS_OREJ_WRONG_DEST); - break; - - case SCU_TASK_OPEN_REJECT_ZONE_VIOLATION: - - /* Note - the return of AB0 will change when - * libsas implements detection of zone violations. - */ - isci_request_set_open_reject_status( - request, task, response_ptr, status_ptr, - complete_to_host_ptr, SAS_OREJ_RESV_AB0); - break; - - case SCU_TASK_OPEN_REJECT_RESERVED_ABANDON_1: - - isci_request_set_open_reject_status( - request, task, response_ptr, status_ptr, - complete_to_host_ptr, SAS_OREJ_RESV_AB1); - break; - - case SCU_TASK_OPEN_REJECT_RESERVED_ABANDON_2: - - isci_request_set_open_reject_status( - request, task, response_ptr, status_ptr, - complete_to_host_ptr, SAS_OREJ_RESV_AB2); - break; - - case SCU_TASK_OPEN_REJECT_RESERVED_ABANDON_3: - - isci_request_set_open_reject_status( - request, task, response_ptr, status_ptr, - complete_to_host_ptr, SAS_OREJ_RESV_AB3); - break; - - case SCU_TASK_OPEN_REJECT_BAD_DESTINATION: - - isci_request_set_open_reject_status( - request, task, response_ptr, status_ptr, - complete_to_host_ptr, SAS_OREJ_BAD_DEST); - break; - - case SCU_TASK_OPEN_REJECT_STP_RESOURCES_BUSY: - - isci_request_set_open_reject_status( - request, task, response_ptr, status_ptr, - complete_to_host_ptr, SAS_OREJ_STP_NORES); - break; - - case SCU_TASK_OPEN_REJECT_PROTOCOL_NOT_SUPPORTED: - - isci_request_set_open_reject_status( - request, task, response_ptr, status_ptr, - complete_to_host_ptr, SAS_OREJ_EPROTO); - break; - - case SCU_TASK_OPEN_REJECT_CONNECTION_RATE_NOT_SUPPORTED: - - isci_request_set_open_reject_status( - request, task, response_ptr, status_ptr, - complete_to_host_ptr, SAS_OREJ_CONN_RATE); - break; - - case SCU_TASK_DONE_LL_R_ERR: - /* Also SCU_TASK_DONE_ACK_NAK_TO: */ - case SCU_TASK_DONE_LL_PERR: - case SCU_TASK_DONE_LL_SY_TERM: - /* Also SCU_TASK_DONE_NAK_ERR:*/ - case SCU_TASK_DONE_LL_LF_TERM: - /* Also SCU_TASK_DONE_DATA_LEN_ERR: */ - case SCU_TASK_DONE_LL_ABORT_ERR: - case SCU_TASK_DONE_SEQ_INV_TYPE: - /* Also SCU_TASK_DONE_UNEXP_XR: */ - case SCU_TASK_DONE_XR_IU_LEN_ERR: - case SCU_TASK_DONE_INV_FIS_LEN: - /* Also SCU_TASK_DONE_XR_WD_LEN: */ - case SCU_TASK_DONE_SDMA_ERR: - case SCU_TASK_DONE_OFFSET_ERR: - case SCU_TASK_DONE_MAX_PLD_ERR: - case SCU_TASK_DONE_LF_ERR: - case SCU_TASK_DONE_SMP_RESP_TO_ERR: /* Escalate to dev reset? */ - case SCU_TASK_DONE_SMP_LL_RX_ERR: - case SCU_TASK_DONE_UNEXP_DATA: - case SCU_TASK_DONE_UNEXP_SDBFIS: - case SCU_TASK_DONE_REG_ERR: - case SCU_TASK_DONE_SDB_ERR: - case SCU_TASK_DONE_TASK_ABORT: - default: - /* Task in the target is not done. */ - *response_ptr = SAS_TASK_UNDELIVERED; - *status_ptr = SAM_STAT_TASK_ABORTED; - - if (task->task_proto == SAS_PROTOCOL_SMP) { - set_bit(IREQ_COMPLETE_IN_TARGET, &request->flags); - - *complete_to_host_ptr = isci_perform_normal_io_completion; - } else { - clear_bit(IREQ_COMPLETE_IN_TARGET, &request->flags); - - *complete_to_host_ptr = isci_perform_error_io_completion; - } - break; - } -} - -/** - * isci_task_save_for_upper_layer_completion() - This function saves the - * request for later completion to the upper layer driver. - * @host: This parameter is a pointer to the host on which the the request - * should be queued (either as an error or success). - * @request: This parameter is the completed request. - * @response: This parameter is the response code for the completed task. - * @status: This parameter is the status code for the completed task. - * - * none. - */ -static void isci_task_save_for_upper_layer_completion( - struct isci_host *host, - struct isci_request *request, - enum service_response response, - enum exec_status status, - enum isci_completion_selection task_notification_selection) -{ - struct sas_task *task = isci_request_access_task(request); - - task_notification_selection - = isci_task_set_completion_status(task, response, status, - task_notification_selection); - - /* Tasks aborted specifically by a call to the lldd_abort_task - * function should not be completed to the host in the regular path. - */ - switch (task_notification_selection) { - - case isci_perform_normal_io_completion: - - /* Normal notification (task_done) */ - dev_dbg(&host->pdev->dev, - "%s: Normal - task = %p, response=%d (%d), status=%d (%d)\n", - __func__, - task, - task->task_status.resp, response, - task->task_status.stat, status); - /* Add to the completed list. */ - list_add(&request->completed_node, - &host->requests_to_complete); - - /* Take the request off the device's pending request list. */ - list_del_init(&request->dev_node); - break; - - case isci_perform_aborted_io_completion: - /* No notification to libsas because this request is - * already in the abort path. - */ - dev_dbg(&host->pdev->dev, - "%s: Aborted - task = %p, response=%d (%d), status=%d (%d)\n", - __func__, - task, - task->task_status.resp, response, - task->task_status.stat, status); - - /* Wake up whatever process was waiting for this - * request to complete. - */ - WARN_ON(request->io_request_completion == NULL); - - if (request->io_request_completion != NULL) { - - /* Signal whoever is waiting that this - * request is complete. - */ - complete(request->io_request_completion); - } - break; - - case isci_perform_error_io_completion: - /* Use sas_task_abort */ - dev_dbg(&host->pdev->dev, - "%s: Error - task = %p, response=%d (%d), status=%d (%d)\n", - __func__, - task, - task->task_status.resp, response, - task->task_status.stat, status); - /* Add to the aborted list. */ - list_add(&request->completed_node, - &host->requests_to_errorback); - break; - - default: - dev_dbg(&host->pdev->dev, - "%s: Unknown - task = %p, response=%d (%d), status=%d (%d)\n", - __func__, - task, - task->task_status.resp, response, - task->task_status.stat, status); - - /* Add to the error to libsas list. */ - list_add(&request->completed_node, - &host->requests_to_errorback); - break; - } -} - -static void isci_request_process_stp_response(struct sas_task *task, - void *response_buffer) -{ - struct dev_to_host_fis *d2h_reg_fis = response_buffer; - struct task_status_struct *ts = &task->task_status; - struct ata_task_resp *resp = (void *)&ts->buf[0]; - - resp->frame_len = le16_to_cpu(*(__le16 *)(response_buffer + 6)); - memcpy(&resp->ending_fis[0], response_buffer + 16, 24); - ts->buf_valid_size = sizeof(*resp); - - /** - * If the device fault bit is set in the status register, then - * set the sense data and return. - */ - if (d2h_reg_fis->status & ATA_DF) - ts->stat = SAS_PROTO_RESPONSE; - else - ts->stat = SAM_STAT_GOOD; - - ts->resp = SAS_TASK_COMPLETE; -} - -static void isci_request_io_request_complete(struct isci_host *ihost, - struct isci_request *request, - enum sci_io_status completion_status) -{ - struct sas_task *task = isci_request_access_task(request); - struct ssp_response_iu *resp_iu; - void *resp_buf; - unsigned long task_flags; - struct isci_remote_device *idev = isci_lookup_device(task->dev); - enum service_response response = SAS_TASK_UNDELIVERED; - enum exec_status status = SAS_ABORTED_TASK; - enum isci_request_status request_status; - enum isci_completion_selection complete_to_host - = isci_perform_normal_io_completion; - - dev_dbg(&ihost->pdev->dev, - "%s: request = %p, task = %p,\n" - "task->data_dir = %d completion_status = 0x%x\n", - __func__, - request, - task, - task->data_dir, - completion_status); - - spin_lock(&request->state_lock); - request_status = request->status; - - /* Decode the request status. Note that if the request has been - * aborted by a task management function, we don't care - * what the status is. - */ - switch (request_status) { - - case aborted: - /* "aborted" indicates that the request was aborted by a task - * management function, since once a task management request is - * perfomed by the device, the request only completes because - * of the subsequent driver terminate. - * - * Aborted also means an external thread is explicitly managing - * this request, so that we do not complete it up the stack. - * - * The target is still there (since the TMF was successful). - */ - set_bit(IREQ_COMPLETE_IN_TARGET, &request->flags); - response = SAS_TASK_COMPLETE; - - /* See if the device has been/is being stopped. Note - * that we ignore the quiesce state, since we are - * concerned about the actual device state. - */ - if (!idev) - status = SAS_DEVICE_UNKNOWN; - else - status = SAS_ABORTED_TASK; - - complete_to_host = isci_perform_aborted_io_completion; - /* This was an aborted request. */ - - spin_unlock(&request->state_lock); - break; - - case aborting: - /* aborting means that the task management function tried and - * failed to abort the request. We need to note the request - * as SAS_TASK_UNDELIVERED, so that the scsi mid layer marks the - * target as down. - * - * Aborting also means an external thread is explicitly managing - * this request, so that we do not complete it up the stack. - */ - set_bit(IREQ_COMPLETE_IN_TARGET, &request->flags); - response = SAS_TASK_UNDELIVERED; - - if (!idev) - /* The device has been /is being stopped. Note that - * we ignore the quiesce state, since we are - * concerned about the actual device state. - */ - status = SAS_DEVICE_UNKNOWN; - else - status = SAS_PHY_DOWN; - - complete_to_host = isci_perform_aborted_io_completion; - - /* This was an aborted request. */ - - spin_unlock(&request->state_lock); - break; - - case terminating: - - /* This was an terminated request. This happens when - * the I/O is being terminated because of an action on - * the device (reset, tear down, etc.), and the I/O needs - * to be completed up the stack. - */ - set_bit(IREQ_COMPLETE_IN_TARGET, &request->flags); - response = SAS_TASK_UNDELIVERED; - - /* See if the device has been/is being stopped. Note - * that we ignore the quiesce state, since we are - * concerned about the actual device state. - */ - if (!idev) - status = SAS_DEVICE_UNKNOWN; - else - status = SAS_ABORTED_TASK; - - complete_to_host = isci_perform_aborted_io_completion; - - /* This was a terminated request. */ - - spin_unlock(&request->state_lock); - break; - - case dead: - /* This was a terminated request that timed-out during the - * termination process. There is no task to complete to - * libsas. - */ - complete_to_host = isci_perform_normal_io_completion; - spin_unlock(&request->state_lock); - break; - - default: - - /* The request is done from an SCU HW perspective. */ - request->status = completed; - - spin_unlock(&request->state_lock); - - /* This is an active request being completed from the core. */ - switch (completion_status) { - - case SCI_IO_FAILURE_RESPONSE_VALID: - dev_dbg(&ihost->pdev->dev, - "%s: SCI_IO_FAILURE_RESPONSE_VALID (%p/%p)\n", - __func__, - request, - task); - - if (sas_protocol_ata(task->task_proto)) { - resp_buf = &request->stp.rsp; - isci_request_process_stp_response(task, - resp_buf); - } else if (SAS_PROTOCOL_SSP == task->task_proto) { - - /* crack the iu response buffer. */ - resp_iu = &request->ssp.rsp; - isci_request_process_response_iu(task, resp_iu, - &ihost->pdev->dev); - - } else if (SAS_PROTOCOL_SMP == task->task_proto) { - - dev_err(&ihost->pdev->dev, - "%s: SCI_IO_FAILURE_RESPONSE_VALID: " - "SAS_PROTOCOL_SMP protocol\n", - __func__); - - } else - dev_err(&ihost->pdev->dev, - "%s: unknown protocol\n", __func__); - - /* use the task status set in the task struct by the - * isci_request_process_response_iu call. - */ - set_bit(IREQ_COMPLETE_IN_TARGET, &request->flags); - response = task->task_status.resp; - status = task->task_status.stat; - break; - - case SCI_IO_SUCCESS: - case SCI_IO_SUCCESS_IO_DONE_EARLY: - - response = SAS_TASK_COMPLETE; - status = SAM_STAT_GOOD; - set_bit(IREQ_COMPLETE_IN_TARGET, &request->flags); - - if (task->task_proto == SAS_PROTOCOL_SMP) { - void *rsp = &request->smp.rsp; - - dev_dbg(&ihost->pdev->dev, - "%s: SMP protocol completion\n", - __func__); - - sg_copy_from_buffer( - &task->smp_task.smp_resp, 1, - rsp, sizeof(struct smp_resp)); - } else if (completion_status - == SCI_IO_SUCCESS_IO_DONE_EARLY) { - - /* This was an SSP / STP / SATA transfer. - * There is a possibility that less data than - * the maximum was transferred. - */ - u32 transferred_length = sci_req_tx_bytes(request); - - task->task_status.residual - = task->total_xfer_len - transferred_length; - - /* If there were residual bytes, call this an - * underrun. - */ - if (task->task_status.residual != 0) - status = SAS_DATA_UNDERRUN; - - dev_dbg(&ihost->pdev->dev, - "%s: SCI_IO_SUCCESS_IO_DONE_EARLY %d\n", - __func__, - status); - - } else - dev_dbg(&ihost->pdev->dev, - "%s: SCI_IO_SUCCESS\n", - __func__); - - break; - - case SCI_IO_FAILURE_TERMINATED: - dev_dbg(&ihost->pdev->dev, - "%s: SCI_IO_FAILURE_TERMINATED (%p/%p)\n", - __func__, - request, - task); - - /* The request was terminated explicitly. No handling - * is needed in the SCSI error handler path. - */ - set_bit(IREQ_COMPLETE_IN_TARGET, &request->flags); - response = SAS_TASK_UNDELIVERED; - - /* See if the device has been/is being stopped. Note - * that we ignore the quiesce state, since we are - * concerned about the actual device state. - */ - if (!idev) - status = SAS_DEVICE_UNKNOWN; - else - status = SAS_ABORTED_TASK; - - complete_to_host = isci_perform_normal_io_completion; - break; - - case SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR: - - isci_request_handle_controller_specific_errors( - idev, request, task, &response, &status, - &complete_to_host); - - break; - - case SCI_IO_FAILURE_REMOTE_DEVICE_RESET_REQUIRED: - /* This is a special case, in that the I/O completion - * is telling us that the device needs a reset. - * In order for the device reset condition to be - * noticed, the I/O has to be handled in the error - * handler. Set the reset flag and cause the - * SCSI error thread to be scheduled. - */ - spin_lock_irqsave(&task->task_state_lock, task_flags); - task->task_state_flags |= SAS_TASK_NEED_DEV_RESET; - spin_unlock_irqrestore(&task->task_state_lock, task_flags); - - /* Fail the I/O. */ - response = SAS_TASK_UNDELIVERED; - status = SAM_STAT_TASK_ABORTED; - - complete_to_host = isci_perform_error_io_completion; - clear_bit(IREQ_COMPLETE_IN_TARGET, &request->flags); - break; - - case SCI_FAILURE_RETRY_REQUIRED: - - /* Fail the I/O so it can be retried. */ - response = SAS_TASK_UNDELIVERED; - if (!idev) - status = SAS_DEVICE_UNKNOWN; - else - status = SAS_ABORTED_TASK; - - complete_to_host = isci_perform_normal_io_completion; - set_bit(IREQ_COMPLETE_IN_TARGET, &request->flags); - break; - - - default: - /* Catch any otherwise unhandled error codes here. */ - dev_dbg(&ihost->pdev->dev, - "%s: invalid completion code: 0x%x - " - "isci_request = %p\n", - __func__, completion_status, request); - - response = SAS_TASK_UNDELIVERED; - - /* See if the device has been/is being stopped. Note - * that we ignore the quiesce state, since we are - * concerned about the actual device state. - */ - if (!idev) - status = SAS_DEVICE_UNKNOWN; - else - status = SAS_ABORTED_TASK; - - if (SAS_PROTOCOL_SMP == task->task_proto) { - set_bit(IREQ_COMPLETE_IN_TARGET, &request->flags); - complete_to_host = isci_perform_normal_io_completion; - } else { - clear_bit(IREQ_COMPLETE_IN_TARGET, &request->flags); - complete_to_host = isci_perform_error_io_completion; - } - break; - } - break; - } - - switch (task->task_proto) { - case SAS_PROTOCOL_SSP: - if (task->data_dir == DMA_NONE) - break; - if (task->num_scatter == 0) - /* 0 indicates a single dma address */ - dma_unmap_single(&ihost->pdev->dev, - request->zero_scatter_daddr, - task->total_xfer_len, task->data_dir); - else /* unmap the sgl dma addresses */ - dma_unmap_sg(&ihost->pdev->dev, task->scatter, - request->num_sg_entries, task->data_dir); - break; - case SAS_PROTOCOL_SMP: { - struct scatterlist *sg = &task->smp_task.smp_req; - struct smp_req *smp_req; - void *kaddr; - - dma_unmap_sg(&ihost->pdev->dev, sg, 1, DMA_TO_DEVICE); - - /* need to swab it back in case the command buffer is re-used */ - kaddr = kmap_atomic(sg_page(sg), KM_IRQ0); - smp_req = kaddr + sg->offset; - sci_swab32_cpy(smp_req, smp_req, sg->length / sizeof(u32)); - kunmap_atomic(kaddr, KM_IRQ0); - break; - } - default: - break; - } - - /* Put the completed request on the correct list */ - isci_task_save_for_upper_layer_completion(ihost, request, response, - status, complete_to_host - ); - - /* complete the io request to the core. */ - sci_controller_complete_io(ihost, request->target_device, request); - isci_put_device(idev); - - /* set terminated handle so it cannot be completed or - * terminated again, and to cause any calls into abort - * task to recognize the already completed case. - */ - set_bit(IREQ_TERMINATED, &request->flags); -} - -static void sci_request_started_state_enter(struct sci_base_state_machine *sm) -{ - struct isci_request *ireq = container_of(sm, typeof(*ireq), sm); - struct domain_device *dev = ireq->target_device->domain_dev; - struct sas_task *task; - - /* XXX as hch said always creating an internal sas_task for tmf - * requests would simplify the driver - */ - task = ireq->ttype == io_task ? isci_request_access_task(ireq) : NULL; - - /* all unaccelerated request types (non ssp or ncq) handled with - * substates - */ - if (!task && dev->dev_type == SAS_END_DEV) { - sci_change_state(sm, SCI_REQ_TASK_WAIT_TC_COMP); - } else if (!task && - (isci_request_access_tmf(ireq)->tmf_code == isci_tmf_sata_srst_high || - isci_request_access_tmf(ireq)->tmf_code == isci_tmf_sata_srst_low)) { - sci_change_state(sm, SCI_REQ_STP_SOFT_RESET_WAIT_H2D_ASSERTED); - } else if (task && task->task_proto == SAS_PROTOCOL_SMP) { - sci_change_state(sm, SCI_REQ_SMP_WAIT_RESP); - } else if (task && sas_protocol_ata(task->task_proto) && - !task->ata_task.use_ncq) { - u32 state; - - if (task->data_dir == DMA_NONE) - state = SCI_REQ_STP_NON_DATA_WAIT_H2D; - else if (task->ata_task.dma_xfer) - state = SCI_REQ_STP_UDMA_WAIT_TC_COMP; - else /* PIO */ - state = SCI_REQ_STP_PIO_WAIT_H2D; - - sci_change_state(sm, state); - } -} - -static void sci_request_completed_state_enter(struct sci_base_state_machine *sm) -{ - struct isci_request *ireq = container_of(sm, typeof(*ireq), sm); - struct isci_host *ihost = ireq->owning_controller; - - /* Tell the SCI_USER that the IO request is complete */ - if (!test_bit(IREQ_TMF, &ireq->flags)) - isci_request_io_request_complete(ihost, ireq, - ireq->sci_status); - else - isci_task_request_complete(ihost, ireq, ireq->sci_status); -} - -static void sci_request_aborting_state_enter(struct sci_base_state_machine *sm) -{ - struct isci_request *ireq = container_of(sm, typeof(*ireq), sm); - - /* Setting the abort bit in the Task Context is required by the silicon. */ - ireq->tc->abort = 1; -} - -static void sci_stp_request_started_non_data_await_h2d_completion_enter(struct sci_base_state_machine *sm) -{ - struct isci_request *ireq = container_of(sm, typeof(*ireq), sm); - - ireq->target_device->working_request = ireq; -} - -static void sci_stp_request_started_pio_await_h2d_completion_enter(struct sci_base_state_machine *sm) -{ - struct isci_request *ireq = container_of(sm, typeof(*ireq), sm); - - ireq->target_device->working_request = ireq; -} - -static void sci_stp_request_started_soft_reset_await_h2d_asserted_completion_enter(struct sci_base_state_machine *sm) -{ - struct isci_request *ireq = container_of(sm, typeof(*ireq), sm); - - ireq->target_device->working_request = ireq; -} - -static void sci_stp_request_started_soft_reset_await_h2d_diagnostic_completion_enter(struct sci_base_state_machine *sm) -{ - struct isci_request *ireq = container_of(sm, typeof(*ireq), sm); - struct scu_task_context *tc = ireq->tc; - struct host_to_dev_fis *h2d_fis; - enum sci_status status; - - /* Clear the SRST bit */ - h2d_fis = &ireq->stp.cmd; - h2d_fis->control = 0; - - /* Clear the TC control bit */ - tc->control_frame = 0; - - status = sci_controller_continue_io(ireq); - WARN_ONCE(status != SCI_SUCCESS, "isci: continue io failure\n"); -} - -static const struct sci_base_state sci_request_state_table[] = { - [SCI_REQ_INIT] = { }, - [SCI_REQ_CONSTRUCTED] = { }, - [SCI_REQ_STARTED] = { - .enter_state = sci_request_started_state_enter, - }, - [SCI_REQ_STP_NON_DATA_WAIT_H2D] = { - .enter_state = sci_stp_request_started_non_data_await_h2d_completion_enter, - }, - [SCI_REQ_STP_NON_DATA_WAIT_D2H] = { }, - [SCI_REQ_STP_PIO_WAIT_H2D] = { - .enter_state = sci_stp_request_started_pio_await_h2d_completion_enter, - }, - [SCI_REQ_STP_PIO_WAIT_FRAME] = { }, - [SCI_REQ_STP_PIO_DATA_IN] = { }, - [SCI_REQ_STP_PIO_DATA_OUT] = { }, - [SCI_REQ_STP_UDMA_WAIT_TC_COMP] = { }, - [SCI_REQ_STP_UDMA_WAIT_D2H] = { }, - [SCI_REQ_STP_SOFT_RESET_WAIT_H2D_ASSERTED] = { - .enter_state = sci_stp_request_started_soft_reset_await_h2d_asserted_completion_enter, - }, - [SCI_REQ_STP_SOFT_RESET_WAIT_H2D_DIAG] = { - .enter_state = sci_stp_request_started_soft_reset_await_h2d_diagnostic_completion_enter, - }, - [SCI_REQ_STP_SOFT_RESET_WAIT_D2H] = { }, - [SCI_REQ_TASK_WAIT_TC_COMP] = { }, - [SCI_REQ_TASK_WAIT_TC_RESP] = { }, - [SCI_REQ_SMP_WAIT_RESP] = { }, - [SCI_REQ_SMP_WAIT_TC_COMP] = { }, - [SCI_REQ_COMPLETED] = { - .enter_state = sci_request_completed_state_enter, - }, - [SCI_REQ_ABORTING] = { - .enter_state = sci_request_aborting_state_enter, - }, - [SCI_REQ_FINAL] = { }, -}; - -static void -sci_general_request_construct(struct isci_host *ihost, - struct isci_remote_device *idev, - struct isci_request *ireq) -{ - sci_init_sm(&ireq->sm, sci_request_state_table, SCI_REQ_INIT); - - ireq->target_device = idev; - ireq->protocol = SCIC_NO_PROTOCOL; - ireq->saved_rx_frame_index = SCU_INVALID_FRAME_INDEX; - - ireq->sci_status = SCI_SUCCESS; - ireq->scu_status = 0; - ireq->post_context = 0xFFFFFFFF; -} - -static enum sci_status -sci_io_request_construct(struct isci_host *ihost, - struct isci_remote_device *idev, - struct isci_request *ireq) -{ - struct domain_device *dev = idev->domain_dev; - enum sci_status status = SCI_SUCCESS; - - /* Build the common part of the request */ - sci_general_request_construct(ihost, idev, ireq); - - if (idev->rnc.remote_node_index == SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX) - return SCI_FAILURE_INVALID_REMOTE_DEVICE; - - if (dev->dev_type == SAS_END_DEV) - /* pass */; - else if (dev->dev_type == SATA_DEV || (dev->tproto & SAS_PROTOCOL_STP)) - memset(&ireq->stp.cmd, 0, sizeof(ireq->stp.cmd)); - else if (dev_is_expander(dev)) - /* pass */; - else - return SCI_FAILURE_UNSUPPORTED_PROTOCOL; - - memset(ireq->tc, 0, offsetof(struct scu_task_context, sgl_pair_ab)); - - return status; -} - -enum sci_status sci_task_request_construct(struct isci_host *ihost, - struct isci_remote_device *idev, - u16 io_tag, struct isci_request *ireq) -{ - struct domain_device *dev = idev->domain_dev; - enum sci_status status = SCI_SUCCESS; - - /* Build the common part of the request */ - sci_general_request_construct(ihost, idev, ireq); - - if (dev->dev_type == SAS_END_DEV || - dev->dev_type == SATA_DEV || (dev->tproto & SAS_PROTOCOL_STP)) { - set_bit(IREQ_TMF, &ireq->flags); - memset(ireq->tc, 0, sizeof(struct scu_task_context)); - } else - status = SCI_FAILURE_UNSUPPORTED_PROTOCOL; - - return status; -} - -static enum sci_status isci_request_ssp_request_construct( - struct isci_request *request) -{ - enum sci_status status; - - dev_dbg(&request->isci_host->pdev->dev, - "%s: request = %p\n", - __func__, - request); - status = sci_io_request_construct_basic_ssp(request); - return status; -} - -static enum sci_status isci_request_stp_request_construct(struct isci_request *ireq) -{ - struct sas_task *task = isci_request_access_task(ireq); - struct host_to_dev_fis *fis = &ireq->stp.cmd; - struct ata_queued_cmd *qc = task->uldd_task; - enum sci_status status; - - dev_dbg(&ireq->isci_host->pdev->dev, - "%s: ireq = %p\n", - __func__, - ireq); - - memcpy(fis, &task->ata_task.fis, sizeof(struct host_to_dev_fis)); - if (!task->ata_task.device_control_reg_update) - fis->flags |= 0x80; - fis->flags &= 0xF0; - - status = sci_io_request_construct_basic_sata(ireq); - - if (qc && (qc->tf.command == ATA_CMD_FPDMA_WRITE || - qc->tf.command == ATA_CMD_FPDMA_READ)) { - fis->sector_count = qc->tag << 3; - ireq->tc->type.stp.ncq_tag = qc->tag; - } - - return status; -} - -static enum sci_status -sci_io_request_construct_smp(struct device *dev, - struct isci_request *ireq, - struct sas_task *task) -{ - struct scatterlist *sg = &task->smp_task.smp_req; - struct isci_remote_device *idev; - struct scu_task_context *task_context; - struct isci_port *iport; - struct smp_req *smp_req; - void *kaddr; - u8 req_len; - u32 cmd; - - kaddr = kmap_atomic(sg_page(sg), KM_IRQ0); - smp_req = kaddr + sg->offset; - /* - * Look at the SMP requests' header fields; for certain SAS 1.x SMP - * functions under SAS 2.0, a zero request length really indicates - * a non-zero default length. - */ - if (smp_req->req_len == 0) { - switch (smp_req->func) { - case SMP_DISCOVER: - case SMP_REPORT_PHY_ERR_LOG: - case SMP_REPORT_PHY_SATA: - case SMP_REPORT_ROUTE_INFO: - smp_req->req_len = 2; - break; - case SMP_CONF_ROUTE_INFO: - case SMP_PHY_CONTROL: - case SMP_PHY_TEST_FUNCTION: - smp_req->req_len = 9; - break; - /* Default - zero is a valid default for 2.0. */ - } - } - req_len = smp_req->req_len; - sci_swab32_cpy(smp_req, smp_req, sg->length / sizeof(u32)); - cmd = *(u32 *) smp_req; - kunmap_atomic(kaddr, KM_IRQ0); - - if (!dma_map_sg(dev, sg, 1, DMA_TO_DEVICE)) - return SCI_FAILURE; - - ireq->protocol = SCIC_SMP_PROTOCOL; - - /* byte swap the smp request. */ - - task_context = ireq->tc; - - idev = ireq->target_device; - iport = idev->owning_port; - - /* - * Fill in the TC with the its required data - * 00h - */ - task_context->priority = 0; - task_context->initiator_request = 1; - task_context->connection_rate = idev->connection_rate; - task_context->protocol_engine_index = ISCI_PEG; - task_context->logical_port_index = iport->physical_port_index; - task_context->protocol_type = SCU_TASK_CONTEXT_PROTOCOL_SMP; - task_context->abort = 0; - task_context->valid = SCU_TASK_CONTEXT_VALID; - task_context->context_type = SCU_TASK_CONTEXT_TYPE; - - /* 04h */ - task_context->remote_node_index = idev->rnc.remote_node_index; - task_context->command_code = 0; - task_context->task_type = SCU_TASK_TYPE_SMP_REQUEST; - - /* 08h */ - task_context->link_layer_control = 0; - task_context->do_not_dma_ssp_good_response = 1; - task_context->strict_ordering = 0; - task_context->control_frame = 1; - task_context->timeout_enable = 0; - task_context->block_guard_enable = 0; - - /* 0ch */ - task_context->address_modifier = 0; - - /* 10h */ - task_context->ssp_command_iu_length = req_len; - - /* 14h */ - task_context->transfer_length_bytes = 0; - - /* - * 18h ~ 30h, protocol specific - * since commandIU has been build by framework at this point, we just - * copy the frist DWord from command IU to this location. */ - memcpy(&task_context->type.smp, &cmd, sizeof(u32)); - - /* - * 40h - * "For SMP you could program it to zero. We would prefer that way - * so that done code will be consistent." - Venki - */ - task_context->task_phase = 0; - - ireq->post_context = (SCU_CONTEXT_COMMAND_REQUEST_TYPE_POST_TC | - (ISCI_PEG << SCU_CONTEXT_COMMAND_PROTOCOL_ENGINE_GROUP_SHIFT) | - (iport->physical_port_index << - SCU_CONTEXT_COMMAND_LOGICAL_PORT_SHIFT) | - ISCI_TAG_TCI(ireq->io_tag)); - /* - * Copy the physical address for the command buffer to the SCU Task - * Context command buffer should not contain command header. - */ - task_context->command_iu_upper = upper_32_bits(sg_dma_address(sg)); - task_context->command_iu_lower = lower_32_bits(sg_dma_address(sg) + sizeof(u32)); - - /* SMP response comes as UF, so no need to set response IU address. */ - task_context->response_iu_upper = 0; - task_context->response_iu_lower = 0; - - sci_change_state(&ireq->sm, SCI_REQ_CONSTRUCTED); - - return SCI_SUCCESS; -} - -/* - * isci_smp_request_build() - This function builds the smp request. - * @ireq: This parameter points to the isci_request allocated in the - * request construct function. - * - * SCI_SUCCESS on successfull completion, or specific failure code. - */ -static enum sci_status isci_smp_request_build(struct isci_request *ireq) -{ - struct sas_task *task = isci_request_access_task(ireq); - struct device *dev = &ireq->isci_host->pdev->dev; - enum sci_status status = SCI_FAILURE; - - status = sci_io_request_construct_smp(dev, ireq, task); - if (status != SCI_SUCCESS) - dev_dbg(&ireq->isci_host->pdev->dev, - "%s: failed with status = %d\n", - __func__, - status); - - return status; -} - -/** - * isci_io_request_build() - This function builds the io request object. - * @ihost: This parameter specifies the ISCI host object - * @request: This parameter points to the isci_request object allocated in the - * request construct function. - * @sci_device: This parameter is the handle for the sci core's remote device - * object that is the destination for this request. - * - * SCI_SUCCESS on successfull completion, or specific failure code. - */ -static enum sci_status isci_io_request_build(struct isci_host *ihost, - struct isci_request *request, - struct isci_remote_device *idev) -{ - enum sci_status status = SCI_SUCCESS; - struct sas_task *task = isci_request_access_task(request); - - dev_dbg(&ihost->pdev->dev, - "%s: idev = 0x%p; request = %p, " - "num_scatter = %d\n", - __func__, - idev, - request, - task->num_scatter); - - /* map the sgl addresses, if present. - * libata does the mapping for sata devices - * before we get the request. - */ - if (task->num_scatter && - !sas_protocol_ata(task->task_proto) && - !(SAS_PROTOCOL_SMP & task->task_proto)) { - - request->num_sg_entries = dma_map_sg( - &ihost->pdev->dev, - task->scatter, - task->num_scatter, - task->data_dir - ); - - if (request->num_sg_entries == 0) - return SCI_FAILURE_INSUFFICIENT_RESOURCES; - } - - status = sci_io_request_construct(ihost, idev, request); - - if (status != SCI_SUCCESS) { - dev_dbg(&ihost->pdev->dev, - "%s: failed request construct\n", - __func__); - return SCI_FAILURE; - } - - switch (task->task_proto) { - case SAS_PROTOCOL_SMP: - status = isci_smp_request_build(request); - break; - case SAS_PROTOCOL_SSP: - status = isci_request_ssp_request_construct(request); - break; - case SAS_PROTOCOL_SATA: - case SAS_PROTOCOL_STP: - case SAS_PROTOCOL_SATA | SAS_PROTOCOL_STP: - status = isci_request_stp_request_construct(request); - break; - default: - dev_dbg(&ihost->pdev->dev, - "%s: unknown protocol\n", __func__); - return SCI_FAILURE; - } - - return SCI_SUCCESS; -} - -static struct isci_request *isci_request_from_tag(struct isci_host *ihost, u16 tag) -{ - struct isci_request *ireq; - - ireq = ihost->reqs[ISCI_TAG_TCI(tag)]; - ireq->io_tag = tag; - ireq->io_request_completion = NULL; - ireq->flags = 0; - ireq->num_sg_entries = 0; - INIT_LIST_HEAD(&ireq->completed_node); - INIT_LIST_HEAD(&ireq->dev_node); - isci_request_change_state(ireq, allocated); - - return ireq; -} - -static struct isci_request *isci_io_request_from_tag(struct isci_host *ihost, - struct sas_task *task, - u16 tag) -{ - struct isci_request *ireq; - - ireq = isci_request_from_tag(ihost, tag); - ireq->ttype_ptr.io_task_ptr = task; - ireq->ttype = io_task; - task->lldd_task = ireq; - - return ireq; -} - -struct isci_request *isci_tmf_request_from_tag(struct isci_host *ihost, - struct isci_tmf *isci_tmf, - u16 tag) -{ - struct isci_request *ireq; - - ireq = isci_request_from_tag(ihost, tag); - ireq->ttype_ptr.tmf_task_ptr = isci_tmf; - ireq->ttype = tmf_task; - - return ireq; -} - -int isci_request_execute(struct isci_host *ihost, struct isci_remote_device *idev, - struct sas_task *task, u16 tag) -{ - enum sci_status status = SCI_FAILURE_UNSUPPORTED_PROTOCOL; - struct isci_request *ireq; - unsigned long flags; - int ret = 0; - - /* do common allocation and init of request object. */ - ireq = isci_io_request_from_tag(ihost, task, tag); - - status = isci_io_request_build(ihost, ireq, idev); - if (status != SCI_SUCCESS) { - dev_dbg(&ihost->pdev->dev, - "%s: request_construct failed - status = 0x%x\n", - __func__, - status); - return status; - } - - spin_lock_irqsave(&ihost->scic_lock, flags); - - if (test_bit(IDEV_IO_NCQERROR, &idev->flags)) { - - if (isci_task_is_ncq_recovery(task)) { - - /* The device is in an NCQ recovery state. Issue the - * request on the task side. Note that it will - * complete on the I/O request side because the - * request was built that way (ie. - * ireq->is_task_management_request is false). - */ - status = sci_controller_start_task(ihost, - idev, - ireq); - } else { - status = SCI_FAILURE; - } - } else { - /* send the request, let the core assign the IO TAG. */ - status = sci_controller_start_io(ihost, idev, - ireq); - } - - if (status != SCI_SUCCESS && - status != SCI_FAILURE_REMOTE_DEVICE_RESET_REQUIRED) { - dev_dbg(&ihost->pdev->dev, - "%s: failed request start (0x%x)\n", - __func__, status); - spin_unlock_irqrestore(&ihost->scic_lock, flags); - return status; - } - - /* Either I/O started OK, or the core has signaled that - * the device needs a target reset. - * - * In either case, hold onto the I/O for later. - * - * Update it's status and add it to the list in the - * remote device object. - */ - list_add(&ireq->dev_node, &idev->reqs_in_process); - - if (status == SCI_SUCCESS) { - isci_request_change_state(ireq, started); - } else { - /* The request did not really start in the - * hardware, so clear the request handle - * here so no terminations will be done. - */ - set_bit(IREQ_TERMINATED, &ireq->flags); - isci_request_change_state(ireq, completed); - } - spin_unlock_irqrestore(&ihost->scic_lock, flags); - - if (status == - SCI_FAILURE_REMOTE_DEVICE_RESET_REQUIRED) { - /* Signal libsas that we need the SCSI error - * handler thread to work on this I/O and that - * we want a device reset. - */ - spin_lock_irqsave(&task->task_state_lock, flags); - task->task_state_flags |= SAS_TASK_NEED_DEV_RESET; - spin_unlock_irqrestore(&task->task_state_lock, flags); - - /* Cause this task to be scheduled in the SCSI error - * handler thread. - */ - isci_execpath_callback(ihost, task, - sas_task_abort); - - /* Change the status, since we are holding - * the I/O until it is managed by the SCSI - * error handler. - */ - status = SCI_SUCCESS; - } - - return ret; -} diff --git a/trunk/drivers/scsi/isci/request.h b/trunk/drivers/scsi/isci/request.h deleted file mode 100644 index 7a1d5a9778eb..000000000000 --- a/trunk/drivers/scsi/isci/request.h +++ /dev/null @@ -1,448 +0,0 @@ -/* - * This file is provided under a dual BSD/GPLv2 license. When using or - * redistributing this file, you may do so under either license. - * - * GPL LICENSE SUMMARY - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License 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., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. - * The full GNU General Public License is included in this distribution - * in the file called LICENSE.GPL. - * - * BSD LICENSE - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Intel Corporation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _ISCI_REQUEST_H_ -#define _ISCI_REQUEST_H_ - -#include "isci.h" -#include "host.h" -#include "scu_task_context.h" - -/** - * struct isci_request_status - This enum defines the possible states of an I/O - * request. - * - * - */ -enum isci_request_status { - unallocated = 0x00, - allocated = 0x01, - started = 0x02, - completed = 0x03, - aborting = 0x04, - aborted = 0x05, - terminating = 0x06, - dead = 0x07 -}; - -enum task_type { - io_task = 0, - tmf_task = 1 -}; - -enum sci_request_protocol { - SCIC_NO_PROTOCOL, - SCIC_SMP_PROTOCOL, - SCIC_SSP_PROTOCOL, - SCIC_STP_PROTOCOL -}; /* XXX remove me, use sas_task.{dev|task_proto} instead */; - -/** - * isci_stp_request - extra request infrastructure to handle pio/atapi protocol - * @pio_len - number of bytes requested at PIO setup - * @status - pio setup ending status value to tell us if we need - * to wait for another fis or if the transfer is complete. Upon - * receipt of a d2h fis this will be the status field of that fis. - * @sgl - track pio transfer progress as we iterate through the sgl - * @device_cdb_len - atapi device advertises it's transfer constraints at setup - */ -struct isci_stp_request { - u32 pio_len; - u8 status; - - struct isci_stp_pio_sgl { - int index; - u8 set; - u32 offset; - } sgl; - u32 device_cdb_len; -}; - -struct isci_request { - enum isci_request_status status; - #define IREQ_COMPLETE_IN_TARGET 0 - #define IREQ_TERMINATED 1 - #define IREQ_TMF 2 - #define IREQ_ACTIVE 3 - unsigned long flags; - /* XXX kill ttype and ttype_ptr, allocate full sas_task */ - enum task_type ttype; - union ttype_ptr_union { - struct sas_task *io_task_ptr; /* When ttype==io_task */ - struct isci_tmf *tmf_task_ptr; /* When ttype==tmf_task */ - } ttype_ptr; - struct isci_host *isci_host; - /* For use in the requests_to_{complete|abort} lists: */ - struct list_head completed_node; - /* For use in the reqs_in_process list: */ - struct list_head dev_node; - spinlock_t state_lock; - dma_addr_t request_daddr; - dma_addr_t zero_scatter_daddr; - unsigned int num_sg_entries; - /* Note: "io_request_completion" is completed in two different ways - * depending on whether this is a TMF or regular request. - * - TMF requests are completed in the thread that started them; - * - regular requests are completed in the request completion callback - * function. - * This difference in operation allows the aborter of a TMF request - * to be sure that once the TMF request completes, the I/O that the - * TMF was aborting is guaranteed to have completed. - * - * XXX kill io_request_completion - */ - struct completion *io_request_completion; - struct sci_base_state_machine sm; - struct isci_host *owning_controller; - struct isci_remote_device *target_device; - u16 io_tag; - enum sci_request_protocol protocol; - u32 scu_status; /* hardware result */ - u32 sci_status; /* upper layer disposition */ - u32 post_context; - struct scu_task_context *tc; - /* could be larger with sg chaining */ - #define SCU_SGL_SIZE ((SCI_MAX_SCATTER_GATHER_ELEMENTS + 1) / 2) - struct scu_sgl_element_pair sg_table[SCU_SGL_SIZE] __attribute__ ((aligned(32))); - /* This field is a pointer to the stored rx frame data. It is used in - * STP internal requests and SMP response frames. If this field is - * non-NULL the saved frame must be released on IO request completion. - */ - u32 saved_rx_frame_index; - - union { - struct { - union { - struct ssp_cmd_iu cmd; - struct ssp_task_iu tmf; - }; - union { - struct ssp_response_iu rsp; - u8 rsp_buf[SSP_RESP_IU_MAX_SIZE]; - }; - } ssp; - struct { - struct smp_resp rsp; - } smp; - struct { - struct isci_stp_request req; - struct host_to_dev_fis cmd; - struct dev_to_host_fis rsp; - } stp; - }; -}; - -static inline struct isci_request *to_ireq(struct isci_stp_request *stp_req) -{ - struct isci_request *ireq; - - ireq = container_of(stp_req, typeof(*ireq), stp.req); - return ireq; -} - -/** - * enum sci_base_request_states - This enumeration depicts all the states for - * the common request state machine. - * - * - */ -enum sci_base_request_states { - /* - * Simply the initial state for the base request state machine. - */ - SCI_REQ_INIT, - - /* - * This state indicates that the request has been constructed. - * This state is entered from the INITIAL state. - */ - SCI_REQ_CONSTRUCTED, - - /* - * This state indicates that the request has been started. This state - * is entered from the CONSTRUCTED state. - */ - SCI_REQ_STARTED, - - SCI_REQ_STP_UDMA_WAIT_TC_COMP, - SCI_REQ_STP_UDMA_WAIT_D2H, - - SCI_REQ_STP_NON_DATA_WAIT_H2D, - SCI_REQ_STP_NON_DATA_WAIT_D2H, - - SCI_REQ_STP_SOFT_RESET_WAIT_H2D_ASSERTED, - SCI_REQ_STP_SOFT_RESET_WAIT_H2D_DIAG, - SCI_REQ_STP_SOFT_RESET_WAIT_D2H, - - /* - * While in this state the IO request object is waiting for the TC - * completion notification for the H2D Register FIS - */ - SCI_REQ_STP_PIO_WAIT_H2D, - - /* - * While in this state the IO request object is waiting for either a - * PIO Setup FIS or a D2H register FIS. The type of frame received is - * based on the result of the prior frame and line conditions. - */ - SCI_REQ_STP_PIO_WAIT_FRAME, - - /* - * While in this state the IO request object is waiting for a DATA - * frame from the device. - */ - SCI_REQ_STP_PIO_DATA_IN, - - /* - * While in this state the IO request object is waiting to transmit - * the next data frame to the device. - */ - SCI_REQ_STP_PIO_DATA_OUT, - - /* - * The AWAIT_TC_COMPLETION sub-state indicates that the started raw - * task management request is waiting for the transmission of the - * initial frame (i.e. command, task, etc.). - */ - SCI_REQ_TASK_WAIT_TC_COMP, - - /* - * This sub-state indicates that the started task management request - * is waiting for the reception of an unsolicited frame - * (i.e. response IU). - */ - SCI_REQ_TASK_WAIT_TC_RESP, - - /* - * This sub-state indicates that the started task management request - * is waiting for the reception of an unsolicited frame - * (i.e. response IU). - */ - SCI_REQ_SMP_WAIT_RESP, - - /* - * The AWAIT_TC_COMPLETION sub-state indicates that the started SMP - * request is waiting for the transmission of the initial frame - * (i.e. command, task, etc.). - */ - SCI_REQ_SMP_WAIT_TC_COMP, - - /* - * This state indicates that the request has completed. - * This state is entered from the STARTED state. This state is entered - * from the ABORTING state. - */ - SCI_REQ_COMPLETED, - - /* - * This state indicates that the request is in the process of being - * terminated/aborted. - * This state is entered from the CONSTRUCTED state. - * This state is entered from the STARTED state. - */ - SCI_REQ_ABORTING, - - /* - * Simply the final state for the base request state machine. - */ - SCI_REQ_FINAL, -}; - -enum sci_status sci_request_start(struct isci_request *ireq); -enum sci_status sci_io_request_terminate(struct isci_request *ireq); -enum sci_status -sci_io_request_event_handler(struct isci_request *ireq, - u32 event_code); -enum sci_status -sci_io_request_frame_handler(struct isci_request *ireq, - u32 frame_index); -enum sci_status -sci_task_request_terminate(struct isci_request *ireq); -extern enum sci_status -sci_request_complete(struct isci_request *ireq); -extern enum sci_status -sci_io_request_tc_completion(struct isci_request *ireq, u32 code); - -/* XXX open code in caller */ -static inline dma_addr_t -sci_io_request_get_dma_addr(struct isci_request *ireq, void *virt_addr) -{ - - char *requested_addr = (char *)virt_addr; - char *base_addr = (char *)ireq; - - BUG_ON(requested_addr < base_addr); - BUG_ON((requested_addr - base_addr) >= sizeof(*ireq)); - - return ireq->request_daddr + (requested_addr - base_addr); -} - -/** - * isci_request_change_state() - This function sets the status of the request - * object. - * @request: This parameter points to the isci_request object - * @status: This Parameter is the new status of the object - * - */ -static inline enum isci_request_status -isci_request_change_state(struct isci_request *isci_request, - enum isci_request_status status) -{ - enum isci_request_status old_state; - unsigned long flags; - - dev_dbg(&isci_request->isci_host->pdev->dev, - "%s: isci_request = %p, state = 0x%x\n", - __func__, - isci_request, - status); - - BUG_ON(isci_request == NULL); - - spin_lock_irqsave(&isci_request->state_lock, flags); - old_state = isci_request->status; - isci_request->status = status; - spin_unlock_irqrestore(&isci_request->state_lock, flags); - - return old_state; -} - -/** - * isci_request_change_started_to_newstate() - This function sets the status of - * the request object. - * @request: This parameter points to the isci_request object - * @status: This Parameter is the new status of the object - * - * state previous to any change. - */ -static inline enum isci_request_status -isci_request_change_started_to_newstate(struct isci_request *isci_request, - struct completion *completion_ptr, - enum isci_request_status newstate) -{ - enum isci_request_status old_state; - unsigned long flags; - - spin_lock_irqsave(&isci_request->state_lock, flags); - - old_state = isci_request->status; - - if (old_state == started || old_state == aborting) { - BUG_ON(isci_request->io_request_completion != NULL); - - isci_request->io_request_completion = completion_ptr; - isci_request->status = newstate; - } - - spin_unlock_irqrestore(&isci_request->state_lock, flags); - - dev_dbg(&isci_request->isci_host->pdev->dev, - "%s: isci_request = %p, old_state = 0x%x\n", - __func__, - isci_request, - old_state); - - return old_state; -} - -/** - * isci_request_change_started_to_aborted() - This function sets the status of - * the request object. - * @request: This parameter points to the isci_request object - * @completion_ptr: This parameter is saved as the kernel completion structure - * signalled when the old request completes. - * - * state previous to any change. - */ -static inline enum isci_request_status -isci_request_change_started_to_aborted(struct isci_request *isci_request, - struct completion *completion_ptr) -{ - return isci_request_change_started_to_newstate(isci_request, - completion_ptr, - aborted); -} - -#define isci_request_access_task(req) ((req)->ttype_ptr.io_task_ptr) - -#define isci_request_access_tmf(req) ((req)->ttype_ptr.tmf_task_ptr) - -struct isci_request *isci_tmf_request_from_tag(struct isci_host *ihost, - struct isci_tmf *isci_tmf, - u16 tag); -int isci_request_execute(struct isci_host *ihost, struct isci_remote_device *idev, - struct sas_task *task, u16 tag); -void isci_terminate_pending_requests(struct isci_host *ihost, - struct isci_remote_device *idev); -enum sci_status -sci_task_request_construct(struct isci_host *ihost, - struct isci_remote_device *idev, - u16 io_tag, - struct isci_request *ireq); -enum sci_status -sci_task_request_construct_ssp(struct isci_request *ireq); -enum sci_status -sci_task_request_construct_sata(struct isci_request *ireq); -void sci_smp_request_copy_response(struct isci_request *ireq); - -static inline int isci_task_is_ncq_recovery(struct sas_task *task) -{ - return (sas_protocol_ata(task->task_proto) && - task->ata_task.fis.command == ATA_CMD_READ_LOG_EXT && - task->ata_task.fis.lbal == ATA_LOG_SATA_NCQ); - -} - -#endif /* !defined(_ISCI_REQUEST_H_) */ diff --git a/trunk/drivers/scsi/isci/sas.h b/trunk/drivers/scsi/isci/sas.h deleted file mode 100644 index 462b15174d3f..000000000000 --- a/trunk/drivers/scsi/isci/sas.h +++ /dev/null @@ -1,219 +0,0 @@ -/* - * This file is provided under a dual BSD/GPLv2 license. When using or - * redistributing this file, you may do so under either license. - * - * GPL LICENSE SUMMARY - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License 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., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. - * The full GNU General Public License is included in this distribution - * in the file called LICENSE.GPL. - * - * BSD LICENSE - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Intel Corporation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _SCI_SAS_H_ -#define _SCI_SAS_H_ - -#include - -/* - * SATA FIS Types These constants depict the various SATA FIS types devined in - * the serial ATA specification. - * XXX: This needs to go into - */ -#define FIS_REGH2D 0x27 -#define FIS_REGD2H 0x34 -#define FIS_SETDEVBITS 0xA1 -#define FIS_DMA_ACTIVATE 0x39 -#define FIS_DMA_SETUP 0x41 -#define FIS_BIST_ACTIVATE 0x58 -#define FIS_PIO_SETUP 0x5F -#define FIS_DATA 0x46 - -/**************************************************************************/ -#define SSP_RESP_IU_MAX_SIZE 280 - -/* - * contents of the SSP COMMAND INFORMATION UNIT. - * For specific information on each of these individual fields please - * reference the SAS specification SSP transport layer section. - * XXX: This needs to go into - */ -struct ssp_cmd_iu { - u8 LUN[8]; - u8 add_cdb_len:6; - u8 _r_a:2; - u8 _r_b; - u8 en_fburst:1; - u8 task_prio:4; - u8 task_attr:3; - u8 _r_c; - - u8 cdb[16]; -} __packed; - -/* - * contents of the SSP TASK INFORMATION UNIT. - * For specific information on each of these individual fields please - * reference the SAS specification SSP transport layer section. - * XXX: This needs to go into - */ -struct ssp_task_iu { - u8 LUN[8]; - u8 _r_a; - u8 task_func; - u8 _r_b[4]; - u16 task_tag; - u8 _r_c[12]; -} __packed; - - -/* - * struct smp_req_phy_id - This structure defines the contents of - * an SMP Request that is comprised of the struct smp_request_header and a - * phy identifier. - * Examples: SMP_REQUEST_DISCOVER, SMP_REQUEST_REPORT_PHY_SATA. - * - * For specific information on each of these individual fields please reference - * the SAS specification. - */ -struct smp_req_phy_id { - u8 _r_a[4]; /* bytes 4-7 */ - - u8 ign_zone_grp:1; /* byte 8 */ - u8 _r_b:7; - - u8 phy_id; /* byte 9 */ - u8 _r_c; /* byte 10 */ - u8 _r_d; /* byte 11 */ -} __packed; - -/* - * struct smp_req_config_route_info - This structure defines the - * contents of an SMP Configure Route Information request. - * - * For specific information on each of these individual fields please reference - * the SAS specification. - */ -struct smp_req_conf_rtinfo { - u16 exp_change_cnt; /* bytes 4-5 */ - u8 exp_rt_idx_hi; /* byte 6 */ - u8 exp_rt_idx; /* byte 7 */ - - u8 _r_a; /* byte 8 */ - u8 phy_id; /* byte 9 */ - u16 _r_b; /* bytes 10-11 */ - - u8 _r_c:7; /* byte 12 */ - u8 dis_rt_entry:1; - u8 _r_d[3]; /* bytes 13-15 */ - - u8 rt_sas_addr[8]; /* bytes 16-23 */ - u8 _r_e[16]; /* bytes 24-39 */ -} __packed; - -/* - * struct smp_req_phycntl - This structure defines the contents of an - * SMP Phy Controller request. - * - * For specific information on each of these individual fields please reference - * the SAS specification. - */ -struct smp_req_phycntl { - u16 exp_change_cnt; /* byte 4-5 */ - - u8 _r_a[3]; /* bytes 6-8 */ - - u8 phy_id; /* byte 9 */ - u8 phy_op; /* byte 10 */ - - u8 upd_pathway:1; /* byte 11 */ - u8 _r_b:7; - - u8 _r_c[12]; /* byte 12-23 */ - - u8 att_dev_name[8]; /* byte 24-31 */ - - u8 _r_d:4; /* byte 32 */ - u8 min_linkrate:4; - - u8 _r_e:4; /* byte 33 */ - u8 max_linkrate:4; - - u8 _r_f[2]; /* byte 34-35 */ - - u8 pathway:4; /* byte 36 */ - u8 _r_g:4; - - u8 _r_h[3]; /* bytes 37-39 */ -} __packed; - -/* - * struct smp_req - This structure simply unionizes the existing request - * structures into a common request type. - * - * XXX: This data structure may need to go to scsi/sas.h - */ -struct smp_req { - u8 type; /* byte 0 */ - u8 func; /* byte 1 */ - u8 alloc_resp_len; /* byte 2 */ - u8 req_len; /* byte 3 */ - u8 req_data[0]; -} __packed; - -#define SMP_RESP_HDR_SZ 4 - -/* - * struct sci_sas_address - This structure depicts how a SAS address is - * represented by SCI. - * XXX convert this to u8 [SAS_ADDR_SIZE] like the rest of libsas - * - */ -struct sci_sas_address { - u32 high; - u32 low; -}; -#endif diff --git a/trunk/drivers/scsi/isci/scu_completion_codes.h b/trunk/drivers/scsi/isci/scu_completion_codes.h deleted file mode 100644 index c8b329c695f9..000000000000 --- a/trunk/drivers/scsi/isci/scu_completion_codes.h +++ /dev/null @@ -1,283 +0,0 @@ -/* - * This file is provided under a dual BSD/GPLv2 license. When using or - * redistributing this file, you may do so under either license. - * - * GPL LICENSE SUMMARY - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License 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., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. - * The full GNU General Public License is included in this distribution - * in the file called LICENSE.GPL. - * - * BSD LICENSE - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Intel Corporation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _SCU_COMPLETION_CODES_HEADER_ -#define _SCU_COMPLETION_CODES_HEADER_ - -/** - * This file contains the constants and macros for the SCU hardware completion - * codes. - * - * - */ - -#define SCU_COMPLETION_TYPE_SHIFT 28 -#define SCU_COMPLETION_TYPE_MASK 0x70000000 - -/** - * SCU_COMPLETION_TYPE() - - * - * This macro constructs an SCU completion type - */ -#define SCU_COMPLETION_TYPE(type) \ - ((u32)(type) << SCU_COMPLETION_TYPE_SHIFT) - -/** - * SCU_COMPLETION_TYPE() - - * - * These macros contain the SCU completion types SCU_COMPLETION_TYPE - */ -#define SCU_COMPLETION_TYPE_TASK SCU_COMPLETION_TYPE(0) -#define SCU_COMPLETION_TYPE_SDMA SCU_COMPLETION_TYPE(1) -#define SCU_COMPLETION_TYPE_UFI SCU_COMPLETION_TYPE(2) -#define SCU_COMPLETION_TYPE_EVENT SCU_COMPLETION_TYPE(3) -#define SCU_COMPLETION_TYPE_NOTIFY SCU_COMPLETION_TYPE(4) - -/** - * - * - * These constants provide the shift and mask values for the various parts of - * an SCU completion code. - */ -#define SCU_COMPLETION_STATUS_MASK 0x0FFC0000 -#define SCU_COMPLETION_TL_STATUS_MASK 0x0FC00000 -#define SCU_COMPLETION_TL_STATUS_SHIFT 22 -#define SCU_COMPLETION_SDMA_STATUS_MASK 0x003C0000 -#define SCU_COMPLETION_PEG_MASK 0x00010000 -#define SCU_COMPLETION_PORT_MASK 0x00007000 -#define SCU_COMPLETION_PE_MASK SCU_COMPLETION_PORT_MASK -#define SCU_COMPLETION_PE_SHIFT 12 -#define SCU_COMPLETION_INDEX_MASK 0x00000FFF - -/** - * SCU_GET_COMPLETION_TYPE() - - * - * This macro returns the SCU completion type. - */ -#define SCU_GET_COMPLETION_TYPE(completion_code) \ - ((completion_code) & SCU_COMPLETION_TYPE_MASK) - -/** - * SCU_GET_COMPLETION_STATUS() - - * - * This macro returns the SCU completion status. - */ -#define SCU_GET_COMPLETION_STATUS(completion_code) \ - ((completion_code) & SCU_COMPLETION_STATUS_MASK) - -/** - * SCU_GET_COMPLETION_TL_STATUS() - - * - * This macro returns the transport layer completion status. - */ -#define SCU_GET_COMPLETION_TL_STATUS(completion_code) \ - ((completion_code) & SCU_COMPLETION_TL_STATUS_MASK) - -/** - * SCU_MAKE_COMPLETION_STATUS() - - * - * This macro takes a completion code and performs the shift and mask - * operations to turn it into a completion code that can be compared to a - * SCU_GET_COMPLETION_TL_STATUS. - */ -#define SCU_MAKE_COMPLETION_STATUS(completion_code) \ - ((u32)(completion_code) << SCU_COMPLETION_TL_STATUS_SHIFT) - -/** - * SCU_NORMALIZE_COMPLETION_STATUS() - - * - * This macro takes a SCU_GET_COMPLETION_TL_STATUS and normalizes it for a - * return code. - */ -#define SCU_NORMALIZE_COMPLETION_STATUS(completion_code) \ - (\ - ((completion_code) & SCU_COMPLETION_TL_STATUS_MASK) \ - >> SCU_COMPLETION_TL_STATUS_SHIFT \ - ) - -/** - * SCU_GET_COMPLETION_SDMA_STATUS() - - * - * This macro returns the SDMA completion status. - */ -#define SCU_GET_COMPLETION_SDMA_STATUS(completion_code) \ - ((completion_code) & SCU_COMPLETION_SDMA_STATUS_MASK) - -/** - * SCU_GET_COMPLETION_PEG() - - * - * This macro returns the Protocol Engine Group from the completion code. - */ -#define SCU_GET_COMPLETION_PEG(completion_code) \ - ((completion_code) & SCU_COMPLETION_PEG_MASK) - -/** - * SCU_GET_COMPLETION_PORT() - - * - * This macro reuturns the logical port index from the completion code. - */ -#define SCU_GET_COMPLETION_PORT(completion_code) \ - ((completion_code) & SCU_COMPLETION_PORT_MASK) - -/** - * SCU_GET_PROTOCOL_ENGINE_INDEX() - - * - * This macro returns the PE index from the completion code. - */ -#define SCU_GET_PROTOCOL_ENGINE_INDEX(completion_code) \ - (((completion_code) & SCU_COMPLETION_PE_MASK) >> SCU_COMPLETION_PE_SHIFT) - -/** - * SCU_GET_COMPLETION_INDEX() - - * - * This macro returns the index of the completion which is either a TCi or an - * RNi depending on the completion type. - */ -#define SCU_GET_COMPLETION_INDEX(completion_code) \ - ((completion_code) & SCU_COMPLETION_INDEX_MASK) - -#define SCU_UNSOLICITED_FRAME_MASK 0x0FFF0000 -#define SCU_UNSOLICITED_FRAME_SHIFT 16 - -/** - * SCU_GET_FRAME_INDEX() - - * - * This macro returns a normalized frame index from an unsolicited frame - * completion. - */ -#define SCU_GET_FRAME_INDEX(completion_code) \ - (\ - ((completion_code) & SCU_UNSOLICITED_FRAME_MASK) \ - >> SCU_UNSOLICITED_FRAME_SHIFT \ - ) - -#define SCU_UNSOLICITED_FRAME_ERROR_MASK 0x00008000 - -/** - * SCU_GET_FRAME_ERROR() - - * - * This macro returns a zero (0) value if there is no frame error otherwise it - * returns non-zero (!0). - */ -#define SCU_GET_FRAME_ERROR(completion_code) \ - ((completion_code) & SCU_UNSOLICITED_FRAME_ERROR_MASK) - -/** - * - * - * These constants represent normalized completion codes which must be shifted - * 18 bits to match it with the hardware completion code. In a 16-bit compiler, - * immediate constants are 16-bit values (the size of an int). If we shift - * those by 18 bits, we completely lose the value. To ensure the value is a - * 32-bit value like we want, each immediate value must be cast to a u32. - */ -#define SCU_TASK_DONE_GOOD ((u32)0x00) -#define SCU_TASK_DONE_CRC_ERR ((u32)0x14) -#define SCU_TASK_DONE_CHECK_RESPONSE ((u32)0x14) -#define SCU_TASK_DONE_GEN_RESPONSE ((u32)0x15) -#define SCU_TASK_DONE_NAK_CMD_ERR ((u32)0x16) -#define SCU_TASK_DONE_CMD_LL_R_ERR ((u32)0x16) -#define SCU_TASK_DONE_LL_R_ERR ((u32)0x17) -#define SCU_TASK_DONE_ACK_NAK_TO ((u32)0x17) -#define SCU_TASK_DONE_LL_PERR ((u32)0x18) -#define SCU_TASK_DONE_LL_SY_TERM ((u32)0x19) -#define SCU_TASK_DONE_NAK_ERR ((u32)0x19) -#define SCU_TASK_DONE_LL_LF_TERM ((u32)0x1A) -#define SCU_TASK_DONE_DATA_LEN_ERR ((u32)0x1A) -#define SCU_TASK_DONE_LL_CL_TERM ((u32)0x1B) -#define SCU_TASK_DONE_LL_ABORT_ERR ((u32)0x1B) -#define SCU_TASK_DONE_SEQ_INV_TYPE ((u32)0x1C) -#define SCU_TASK_DONE_UNEXP_XR ((u32)0x1C) -#define SCU_TASK_DONE_INV_FIS_TYPE ((u32)0x1D) -#define SCU_TASK_DONE_XR_IU_LEN_ERR ((u32)0x1D) -#define SCU_TASK_DONE_INV_FIS_LEN ((u32)0x1E) -#define SCU_TASK_DONE_XR_WD_LEN ((u32)0x1E) -#define SCU_TASK_DONE_SDMA_ERR ((u32)0x1F) -#define SCU_TASK_DONE_OFFSET_ERR ((u32)0x20) -#define SCU_TASK_DONE_MAX_PLD_ERR ((u32)0x21) -#define SCU_TASK_DONE_EXCESS_DATA ((u32)0x22) -#define SCU_TASK_DONE_LF_ERR ((u32)0x23) -#define SCU_TASK_DONE_UNEXP_FIS ((u32)0x24) -#define SCU_TASK_DONE_UNEXP_RESP ((u32)0x24) -#define SCU_TASK_DONE_EARLY_RESP ((u32)0x25) -#define SCU_TASK_DONE_SMP_RESP_TO_ERR ((u32)0x26) -#define SCU_TASK_DONE_DMASETUP_DIRERR ((u32)0x27) -#define SCU_TASK_DONE_SMP_UFI_ERR ((u32)0x27) -#define SCU_TASK_DONE_XFERCNT_ERR ((u32)0x28) -#define SCU_TASK_DONE_SMP_FRM_TYPE_ERR ((u32)0x28) -#define SCU_TASK_DONE_SMP_LL_RX_ERR ((u32)0x29) -#define SCU_TASK_DONE_RESP_LEN_ERR ((u32)0x2A) -#define SCU_TASK_DONE_UNEXP_DATA ((u32)0x2B) -#define SCU_TASK_DONE_OPEN_FAIL ((u32)0x2C) -#define SCU_TASK_DONE_UNEXP_SDBFIS ((u32)0x2D) -#define SCU_TASK_DONE_REG_ERR ((u32)0x2E) -#define SCU_TASK_DONE_SDB_ERR ((u32)0x2F) -#define SCU_TASK_DONE_TASK_ABORT ((u32)0x30) -#define SCU_TASK_DONE_CMD_SDMA_ERR ((U32)0x32) -#define SCU_TASK_DONE_CMD_LL_ABORT_ERR ((U32)0x33) -#define SCU_TASK_OPEN_REJECT_WRONG_DESTINATION ((u32)0x34) -#define SCU_TASK_OPEN_REJECT_RESERVED_ABANDON_1 ((u32)0x35) -#define SCU_TASK_OPEN_REJECT_RESERVED_ABANDON_2 ((u32)0x36) -#define SCU_TASK_OPEN_REJECT_RESERVED_ABANDON_3 ((u32)0x37) -#define SCU_TASK_OPEN_REJECT_BAD_DESTINATION ((u32)0x38) -#define SCU_TASK_OPEN_REJECT_ZONE_VIOLATION ((u32)0x39) -#define SCU_TASK_DONE_VIIT_ENTRY_NV ((u32)0x3A) -#define SCU_TASK_DONE_IIT_ENTRY_NV ((u32)0x3B) -#define SCU_TASK_DONE_RNCNV_OUTBOUND ((u32)0x3C) -#define SCU_TASK_OPEN_REJECT_STP_RESOURCES_BUSY ((u32)0x3D) -#define SCU_TASK_OPEN_REJECT_PROTOCOL_NOT_SUPPORTED ((u32)0x3E) -#define SCU_TASK_OPEN_REJECT_CONNECTION_RATE_NOT_SUPPORTED ((u32)0x3F) - -#endif /* _SCU_COMPLETION_CODES_HEADER_ */ diff --git a/trunk/drivers/scsi/isci/scu_event_codes.h b/trunk/drivers/scsi/isci/scu_event_codes.h deleted file mode 100644 index 36a945ad5722..000000000000 --- a/trunk/drivers/scsi/isci/scu_event_codes.h +++ /dev/null @@ -1,336 +0,0 @@ -/* - * This file is provided under a dual BSD/GPLv2 license. When using or - * redistributing this file, you may do so under either license. - * - * GPL LICENSE SUMMARY - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License 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., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. - * The full GNU General Public License is included in this distribution - * in the file called LICENSE.GPL. - * - * BSD LICENSE - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Intel Corporation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef __SCU_EVENT_CODES_HEADER__ -#define __SCU_EVENT_CODES_HEADER__ - -/** - * This file contains the constants and macros for the SCU event codes. - * - * - */ - -#define SCU_EVENT_TYPE_CODE_SHIFT 24 -#define SCU_EVENT_TYPE_CODE_MASK 0x0F000000 - -#define SCU_EVENT_SPECIFIC_CODE_SHIFT 18 -#define SCU_EVENT_SPECIFIC_CODE_MASK 0x00FC0000 - -#define SCU_EVENT_CODE_MASK \ - (SCU_EVENT_TYPE_CODE_MASK | SCU_EVENT_SPECIFIC_CODE_MASK) - -/** - * SCU_EVENT_TYPE() - - * - * This macro constructs an SCU event type from the type value. - */ -#define SCU_EVENT_TYPE(type) \ - ((u32)(type) << SCU_EVENT_TYPE_CODE_SHIFT) - -/** - * SCU_EVENT_SPECIFIC() - - * - * This macro constructs an SCU event specifier from the code value. - */ -#define SCU_EVENT_SPECIFIC(code) \ - ((u32)(code) << SCU_EVENT_SPECIFIC_CODE_SHIFT) - -/** - * SCU_EVENT_MESSAGE() - - * - * This macro constructs a combines an SCU event type and SCU event specifier - * from the type and code values. - */ -#define SCU_EVENT_MESSAGE(type, code) \ - ((type) | SCU_EVENT_SPECIFIC(code)) - -/** - * SCU_EVENT_TYPE() - - * - * SCU_EVENT_TYPES - */ -#define SCU_EVENT_TYPE_SMU_COMMAND_ERROR SCU_EVENT_TYPE(0x08) -#define SCU_EVENT_TYPE_SMU_PCQ_ERROR SCU_EVENT_TYPE(0x09) -#define SCU_EVENT_TYPE_SMU_ERROR SCU_EVENT_TYPE(0x00) -#define SCU_EVENT_TYPE_TRANSPORT_ERROR SCU_EVENT_TYPE(0x01) -#define SCU_EVENT_TYPE_BROADCAST_CHANGE SCU_EVENT_TYPE(0x02) -#define SCU_EVENT_TYPE_OSSP_EVENT SCU_EVENT_TYPE(0x03) -#define SCU_EVENT_TYPE_FATAL_MEMORY_ERROR SCU_EVENT_TYPE(0x0F) -#define SCU_EVENT_TYPE_RNC_SUSPEND_TX SCU_EVENT_TYPE(0x04) -#define SCU_EVENT_TYPE_RNC_SUSPEND_TX_RX SCU_EVENT_TYPE(0x05) -#define SCU_EVENT_TYPE_RNC_OPS_MISC SCU_EVENT_TYPE(0x06) -#define SCU_EVENT_TYPE_PTX_SCHEDULE_EVENT SCU_EVENT_TYPE(0x07) -#define SCU_EVENT_TYPE_ERR_CNT_EVENT SCU_EVENT_TYPE(0x0A) - -/** - * - * - * SCU_EVENT_SPECIFIERS - */ -#define SCU_EVENT_SPECIFIER_DRIVER_SUSPEND 0x20 -#define SCU_EVENT_SPECIFIER_RNC_RELEASE 0x00 - -/** - * - * - * SMU_COMMAND_EVENTS - */ -#define SCU_EVENT_INVALID_CONTEXT_COMMAND \ - SCU_EVENT_MESSAGE(SCU_EVENT_TYPE_SMU_COMMAND_ERROR, 0x00) - -/** - * - * - * SMU_PCQ_EVENTS - */ -#define SCU_EVENT_UNCORRECTABLE_PCQ_ERROR \ - SCU_EVENT_MESSAGE(SCU_EVENT_TYPE_SMU_PCQ_ERROR, 0x00) - -/** - * - * - * SMU_EVENTS - */ -#define SCU_EVENT_UNCORRECTABLE_REGISTER_WRITE \ - SCU_EVENT_MESSAGE(SCU_EVENT_TYPE_SMU_ERROR, 0x02) -#define SCU_EVENT_UNCORRECTABLE_REGISTER_READ \ - SCU_EVENT_MESSAGE(SCU_EVENT_TYPE_SMU_ERROR, 0x03) -#define SCU_EVENT_PCIE_INTERFACE_ERROR \ - SCU_EVENT_MESSAGE(SCU_EVENT_TYPE_SMU_ERROR, 0x04) -#define SCU_EVENT_FUNCTION_LEVEL_RESET \ - SCU_EVENT_MESSAGE(SCU_EVENT_TYPE_SMU_ERROR, 0x05) - -/** - * - * - * TRANSPORT_LEVEL_ERRORS - */ -#define SCU_EVENT_ACK_NAK_TIMEOUT_ERROR \ - SCU_EVENT_MESSAGE(SCU_EVENT_TYPE_TRANSPORT_ERROR, 0x00) - -/** - * - * - * BROADCAST_CHANGE_EVENTS - */ -#define SCU_EVENT_BROADCAST_CHANGE \ - SCU_EVENT_MESSAGE(SCU_EVENT_TYPE_BROADCAST_CHANGE, 0x01) -#define SCU_EVENT_BROADCAST_RESERVED0 \ - SCU_EVENT_MESSAGE(SCU_EVENT_TYPE_BROADCAST_CHANGE, 0x02) -#define SCU_EVENT_BROADCAST_RESERVED1 \ - SCU_EVENT_MESSAGE(SCU_EVENT_TYPE_BROADCAST_CHANGE, 0x03) -#define SCU_EVENT_BROADCAST_SES \ - SCU_EVENT_MESSAGE(SCU_EVENT_TYPE_BROADCAST_CHANGE, 0x04) -#define SCU_EVENT_BROADCAST_EXPANDER \ - SCU_EVENT_MESSAGE(SCU_EVENT_TYPE_BROADCAST_CHANGE, 0x05) -#define SCU_EVENT_BROADCAST_AEN \ - SCU_EVENT_MESSAGE(SCU_EVENT_TYPE_BROADCAST_CHANGE, 0x06) -#define SCU_EVENT_BROADCAST_RESERVED3 \ - SCU_EVENT_MESSAGE(SCU_EVENT_TYPE_BROADCAST_CHANGE, 0x07) -#define SCU_EVENT_BROADCAST_RESERVED4 \ - SCU_EVENT_MESSAGE(SCU_EVENT_TYPE_BROADCAST_CHANGE, 0x08) -#define SCU_EVENT_PE_SUSPENDED \ - SCU_EVENT_MESSAGE(SCU_EVENT_TYPE_BROADCAST_CHANGE, 0x09) - -/** - * - * - * OSSP_EVENTS - */ -#define SCU_EVENT_PORT_SELECTOR_DETECTED \ - SCU_EVENT_MESSAGE(SCU_EVENT_TYPE_OSSP_EVENT, 0x10) -#define SCU_EVENT_SENT_PORT_SELECTION \ - SCU_EVENT_MESSAGE(SCU_EVENT_TYPE_OSSP_EVENT, 0x11) -#define SCU_EVENT_HARD_RESET_TRANSMITTED \ - SCU_EVENT_MESSAGE(SCU_EVENT_TYPE_OSSP_EVENT, 0x12) -#define SCU_EVENT_HARD_RESET_RECEIVED \ - SCU_EVENT_MESSAGE(SCU_EVENT_TYPE_OSSP_EVENT, 0x13) -#define SCU_EVENT_RECEIVED_IDENTIFY_TIMEOUT \ - SCU_EVENT_MESSAGE(SCU_EVENT_TYPE_OSSP_EVENT, 0x15) -#define SCU_EVENT_LINK_FAILURE \ - SCU_EVENT_MESSAGE(SCU_EVENT_TYPE_OSSP_EVENT, 0x16) -#define SCU_EVENT_SATA_SPINUP_HOLD \ - SCU_EVENT_MESSAGE(SCU_EVENT_TYPE_OSSP_EVENT, 0x17) -#define SCU_EVENT_SAS_15_SSC \ - SCU_EVENT_MESSAGE(SCU_EVENT_TYPE_OSSP_EVENT, 0x18) -#define SCU_EVENT_SAS_15 \ - SCU_EVENT_MESSAGE(SCU_EVENT_TYPE_OSSP_EVENT, 0x19) -#define SCU_EVENT_SAS_30_SSC \ - SCU_EVENT_MESSAGE(SCU_EVENT_TYPE_OSSP_EVENT, 0x1A) -#define SCU_EVENT_SAS_30 \ - SCU_EVENT_MESSAGE(SCU_EVENT_TYPE_OSSP_EVENT, 0x1B) -#define SCU_EVENT_SAS_60_SSC \ - SCU_EVENT_MESSAGE(SCU_EVENT_TYPE_OSSP_EVENT, 0x1C) -#define SCU_EVENT_SAS_60 \ - SCU_EVENT_MESSAGE(SCU_EVENT_TYPE_OSSP_EVENT, 0x1D) -#define SCU_EVENT_SATA_15_SSC \ - SCU_EVENT_MESSAGE(SCU_EVENT_TYPE_OSSP_EVENT, 0x1E) -#define SCU_EVENT_SATA_15 \ - SCU_EVENT_MESSAGE(SCU_EVENT_TYPE_OSSP_EVENT, 0x1F) -#define SCU_EVENT_SATA_30_SSC \ - SCU_EVENT_MESSAGE(SCU_EVENT_TYPE_OSSP_EVENT, 0x20) -#define SCU_EVENT_SATA_30 \ - SCU_EVENT_MESSAGE(SCU_EVENT_TYPE_OSSP_EVENT, 0x21) -#define SCU_EVENT_SATA_60_SSC \ - SCU_EVENT_MESSAGE(SCU_EVENT_TYPE_OSSP_EVENT, 0x22) -#define SCU_EVENT_SATA_60 \ - SCU_EVENT_MESSAGE(SCU_EVENT_TYPE_OSSP_EVENT, 0x23) -#define SCU_EVENT_SAS_PHY_DETECTED \ - SCU_EVENT_MESSAGE(SCU_EVENT_TYPE_OSSP_EVENT, 0x24) -#define SCU_EVENT_SATA_PHY_DETECTED \ - SCU_EVENT_MESSAGE(SCU_EVENT_TYPE_OSSP_EVENT, 0x25) - -/** - * - * - * FATAL_INTERNAL_MEMORY_ERROR_EVENTS - */ -#define SCU_EVENT_TSC_RNSC_UNCORRECTABLE_ERROR \ - SCU_EVENT_MESSAGE(SCU_EVENT_TYPE_FATAL_MEMORY_ERROR, 0x00) -#define SCU_EVENT_TC_RNC_UNCORRECTABLE_ERROR \ - SCU_EVENT_MESSAGE(SCU_EVENT_TYPE_FATAL_MEMORY_ERROR, 0x01) -#define SCU_EVENT_ZPT_UNCORRECTABLE_ERROR \ - SCU_EVENT_MESSAGE(SCU_EVENT_TYPE_FATAL_MEMORY_ERROR, 0x02) - -/** - * - * - * REMOTE_NODE_SUSPEND_EVENTS - */ -#define SCU_EVENT_TL_RNC_SUSPEND_TX \ - SCU_EVENT_MESSAGE(SCU_EVENT_TYPE_RNC_SUSPEND_TX, 0x00) -#define SCU_EVENT_TL_RNC_SUSPEND_TX_RX \ - SCU_EVENT_MESSAGE(SCU_EVENT_TYPE_RNC_SUSPEND_TX_RX, 0x00) -#define SCU_EVENT_DRIVER_POST_RNC_SUSPEND_TX \ - SCU_EVENT_MESSAGE(SCU_EVENT_TYPE_RNC_SUSPEND_TX, 0x20) -#define SCU_EVENT_DRIVER_POST_RNC_SUSPEND_TX_RX \ - SCU_EVENT_MESSAGE(SCU_EVENT_TYPE_RNC_SUSPEND_TX_RX, 0x20) - -/** - * - * - * REMOTE_NODE_MISC_EVENTS - */ -#define SCU_EVENT_POST_RCN_RELEASE \ - SCU_EVENT_MESSAGE(SCU_EVENT_TYPE_RNC_OPS_MISC, SCU_EVENT_SPECIFIER_RNC_RELEASE) -#define SCU_EVENT_POST_IT_NEXUS_LOSS_TIMER_ENABLE \ - SCU_EVENT_MESSAGE(SCU_EVENT_TYPE_RNC_OPS_MISC, 0x01) -#define SCU_EVENT_POST_IT_NEXUS_LOSS_TIMER_DISABLE \ - SCU_EVENT_MESSAGE(SCU_EVENT_TYPE_RNC_OPS_MISC, 0x02) -#define SCU_EVENT_POST_RNC_COMPLETE \ - SCU_EVENT_MESSAGE(SCU_EVENT_TYPE_RNC_OPS_MISC, 0x03) -#define SCU_EVENT_POST_RNC_INVALIDATE_COMPLETE \ - SCU_EVENT_MESSAGE(SCU_EVENT_TYPE_RNC_OPS_MISC, 0x04) - -/** - * - * - * ERROR_COUNT_EVENT - */ -#define SCU_EVENT_RX_CREDIT_BLOCKED_RECEIVED \ - SCU_EVENT_MESSAGE(SCU_EVENT_TYPE_ERR_CNT_EVENT, 0x00) -#define SCU_EVENT_TX_DONE_CREDIT_TIMEOUT \ - SCU_EVENT_MESSAGE(SCU_EVENT_TYPE_ERR_CNT_EVENT, 0x01) -#define SCU_EVENT_RX_DONE_CREDIT_TIMEOUT \ - SCU_EVENT_MESSAGE(SCU_EVENT_TYPE_ERR_CNT_EVENT, 0x02) - -/** - * scu_get_event_type() - - * - * This macro returns the SCU event type from the event code. - */ -#define scu_get_event_type(event_code) \ - ((event_code) & SCU_EVENT_TYPE_CODE_MASK) - -/** - * scu_get_event_specifier() - - * - * This macro returns the SCU event specifier from the event code. - */ -#define scu_get_event_specifier(event_code) \ - ((event_code) & SCU_EVENT_SPECIFIC_CODE_MASK) - -/** - * scu_get_event_code() - - * - * This macro returns the combined SCU event type and SCU event specifier from - * the event code. - */ -#define scu_get_event_code(event_code) \ - ((event_code) & SCU_EVENT_CODE_MASK) - - -/** - * - * - * PTS_SCHEDULE_EVENT - */ -#define SCU_EVENT_SMP_RESPONSE_NO_PE \ - SCU_EVENT_MESSAGE(SCU_EVENT_TYPE_PTX_SCHEDULE_EVENT, 0x00) -#define SCU_EVENT_SPECIFIC_SMP_RESPONSE_NO_PE \ - scu_get_event_specifier(SCU_EVENT_SMP_RESPONSE_NO_PE) - -#define SCU_EVENT_TASK_TIMEOUT \ - SCU_EVENT_MESSAGE(SCU_EVENT_TYPE_PTX_SCHEDULE_EVENT, 0x01) -#define SCU_EVENT_SPECIFIC_TASK_TIMEOUT \ - scu_get_event_specifier(SCU_EVENT_TASK_TIMEOUT) - -#define SCU_EVENT_IT_NEXUS_TIMEOUT \ - SCU_EVENT_MESSAGE(SCU_EVENT_TYPE_PTX_SCHEDULE_EVENT, 0x02) -#define SCU_EVENT_SPECIFIC_IT_NEXUS_TIMEOUT \ - scu_get_event_specifier(SCU_EVENT_IT_NEXUS_TIMEOUT) - - -#endif /* __SCU_EVENT_CODES_HEADER__ */ diff --git a/trunk/drivers/scsi/isci/scu_remote_node_context.h b/trunk/drivers/scsi/isci/scu_remote_node_context.h deleted file mode 100644 index 33745adc826b..000000000000 --- a/trunk/drivers/scsi/isci/scu_remote_node_context.h +++ /dev/null @@ -1,229 +0,0 @@ -/* - * This file is provided under a dual BSD/GPLv2 license. When using or - * redistributing this file, you may do so under either license. - * - * GPL LICENSE SUMMARY - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License 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., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. - * The full GNU General Public License is included in this distribution - * in the file called LICENSE.GPL. - * - * BSD LICENSE - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Intel Corporation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef __SCU_REMOTE_NODE_CONTEXT_HEADER__ -#define __SCU_REMOTE_NODE_CONTEXT_HEADER__ - -/** - * This file contains the structures and constatns used by the SCU hardware to - * describe a remote node context. - * - * - */ - -/** - * struct ssp_remote_node_context - This structure contains the SCU hardware - * definition for an SSP remote node. - * - * - */ -struct ssp_remote_node_context { - /* WORD 0 */ - - /** - * This field is the remote node index assigned for this remote node. All - * remote nodes must have a unique remote node index. The value of the remote - * node index can not exceed the maximum number of remote nodes reported in - * the SCU device context capacity register. - */ - u32 remote_node_index:12; - u32 reserved0_1:4; - - /** - * This field tells the SCU hardware how many simultaneous connections that - * this remote node will support. - */ - u32 remote_node_port_width:4; - - /** - * This field tells the SCU hardware which logical port to associate with this - * remote node. - */ - u32 logical_port_index:3; - u32 reserved0_2:5; - - /** - * This field will enable the I_T nexus loss timer for this remote node. - */ - u32 nexus_loss_timer_enable:1; - - /** - * This field is the for driver debug only and is not used. - */ - u32 check_bit:1; - - /** - * This field must be set to true when the hardware DMAs the remote node - * context to the hardware SRAM. When the remote node is being invalidated - * this field must be set to false. - */ - u32 is_valid:1; - - /** - * This field must be set to true. - */ - u32 is_remote_node_context:1; - - /* WORD 1 - 2 */ - - /** - * This is the low word of the remote device SAS Address - */ - u32 remote_sas_address_lo; - - /** - * This field is the high word of the remote device SAS Address - */ - u32 remote_sas_address_hi; - - /* WORD 3 */ - /** - * This field reprensets the function number assigned to this remote device. - * This value must match the virtual function number that is being used to - * communicate to the device. - */ - u32 function_number:8; - u32 reserved3_1:8; - - /** - * This field provides the driver a way to cheat on the arbitration wait time - * for this remote node. - */ - u32 arbitration_wait_time:16; - - /* WORD 4 */ - /** - * This field tells the SCU hardware how long this device may occupy the - * connection before it must be closed. - */ - u32 connection_occupancy_timeout:16; - - /** - * This field tells the SCU hardware how long to maintain a connection when - * there are no frames being transmitted on the link. - */ - u32 connection_inactivity_timeout:16; - - /* WORD 5 */ - /** - * This field allows the driver to cheat on the arbitration wait time for this - * remote node. - */ - u32 initial_arbitration_wait_time:16; - - /** - * This field is tells the hardware what to program for the connection rate in - * the open address frame. See the SAS spec for valid values. - */ - u32 oaf_connection_rate:4; - - /** - * This field tells the SCU hardware what to program for the features in the - * open address frame. See the SAS spec for valid values. - */ - u32 oaf_features:4; - - /** - * This field tells the SCU hardware what to use for the source zone group in - * the open address frame. See the SAS spec for more details on zoning. - */ - u32 oaf_source_zone_group:8; - - /* WORD 6 */ - /** - * This field tells the SCU hardware what to use as the more capibilities in - * the open address frame. See the SAS Spec for details. - */ - u32 oaf_more_compatibility_features; - - /* WORD 7 */ - u32 reserved7; - -}; - -/** - * struct stp_remote_node_context - This structure contains the SCU hardware - * definition for a STP remote node. - * - * STP Targets are not yet supported so this definition is a placeholder until - * we do support them. - */ -struct stp_remote_node_context { - /** - * Placeholder data for the STP remote node. - */ - u32 data[8]; - -}; - -/** - * This union combines the SAS and SATA remote node definitions. - * - * union scu_remote_node_context - */ -union scu_remote_node_context { - /** - * SSP Remote Node - */ - struct ssp_remote_node_context ssp; - - /** - * STP Remote Node - */ - struct stp_remote_node_context stp; - -}; - -#endif /* __SCU_REMOTE_NODE_CONTEXT_HEADER__ */ diff --git a/trunk/drivers/scsi/isci/scu_task_context.h b/trunk/drivers/scsi/isci/scu_task_context.h deleted file mode 100644 index 7df87d923285..000000000000 --- a/trunk/drivers/scsi/isci/scu_task_context.h +++ /dev/null @@ -1,942 +0,0 @@ -/* - * This file is provided under a dual BSD/GPLv2 license. When using or - * redistributing this file, you may do so under either license. - * - * GPL LICENSE SUMMARY - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License 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., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. - * The full GNU General Public License is included in this distribution - * in the file called LICENSE.GPL. - * - * BSD LICENSE - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Intel Corporation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _SCU_TASK_CONTEXT_H_ -#define _SCU_TASK_CONTEXT_H_ - -/** - * This file contains the structures and constants for the SCU hardware task - * context. - * - * - */ - - -/** - * enum scu_ssp_task_type - This enumberation defines the various SSP task - * types the SCU hardware will accept. The definition for the various task - * types the SCU hardware will accept can be found in the DS specification. - * - * - */ -typedef enum { - SCU_TASK_TYPE_IOREAD, /* /< IO READ direction or no direction */ - SCU_TASK_TYPE_IOWRITE, /* /< IO Write direction */ - SCU_TASK_TYPE_SMP_REQUEST, /* /< SMP Request type */ - SCU_TASK_TYPE_RESPONSE, /* /< Driver generated response frame (targt mode) */ - SCU_TASK_TYPE_RAW_FRAME, /* /< Raw frame request type */ - SCU_TASK_TYPE_PRIMITIVE /* /< Request for a primitive to be transmitted */ -} scu_ssp_task_type; - -/** - * enum scu_sata_task_type - This enumeration defines the various SATA task - * types the SCU hardware will accept. The definition for the various task - * types the SCU hardware will accept can be found in the DS specification. - * - * - */ -typedef enum { - SCU_TASK_TYPE_DMA_IN, /* /< Read request */ - SCU_TASK_TYPE_FPDMAQ_READ, /* /< NCQ read request */ - SCU_TASK_TYPE_PACKET_DMA_IN, /* /< Packet read request */ - SCU_TASK_TYPE_SATA_RAW_FRAME, /* /< Raw frame request */ - RESERVED_4, - RESERVED_5, - RESERVED_6, - RESERVED_7, - SCU_TASK_TYPE_DMA_OUT, /* /< Write request */ - SCU_TASK_TYPE_FPDMAQ_WRITE, /* /< NCQ write Request */ - SCU_TASK_TYPE_PACKET_DMA_OUT /* /< Packet write request */ -} scu_sata_task_type; - - -/** - * - * - * SCU_CONTEXT_TYPE - */ -#define SCU_TASK_CONTEXT_TYPE 0 -#define SCU_RNC_CONTEXT_TYPE 1 - -/** - * - * - * SCU_TASK_CONTEXT_VALIDITY - */ -#define SCU_TASK_CONTEXT_INVALID 0 -#define SCU_TASK_CONTEXT_VALID 1 - -/** - * - * - * SCU_COMMAND_CODE - */ -#define SCU_COMMAND_CODE_INITIATOR_NEW_TASK 0 -#define SCU_COMMAND_CODE_ACTIVE_TASK 1 -#define SCU_COMMAND_CODE_PRIMITIVE_SEQ_TASK 2 -#define SCU_COMMAND_CODE_TARGET_RAW_FRAMES 3 - -/** - * - * - * SCU_TASK_PRIORITY - */ -/** - * - * - * This priority is used when there is no priority request for this request. - */ -#define SCU_TASK_PRIORITY_NORMAL 0 - -/** - * - * - * This priority indicates that the task should be scheduled to the head of the - * queue. The task will NOT be executed if the TX is suspended for the remote - * node. - */ -#define SCU_TASK_PRIORITY_HEAD_OF_Q 1 - -/** - * - * - * This priority indicates that the task will be executed before all - * SCU_TASK_PRIORITY_NORMAL and SCU_TASK_PRIORITY_HEAD_OF_Q tasks. The task - * WILL be executed if the TX is suspended for the remote node. - */ -#define SCU_TASK_PRIORITY_HIGH 2 - -/** - * - * - * This task priority is reserved and should not be used. - */ -#define SCU_TASK_PRIORITY_RESERVED 3 - -#define SCU_TASK_INITIATOR_MODE 1 -#define SCU_TASK_TARGET_MODE 0 - -#define SCU_TASK_REGULAR 0 -#define SCU_TASK_ABORTED 1 - -/* direction bit defintion */ -/** - * - * - * SATA_DIRECTION - */ -#define SCU_SATA_WRITE_DATA_DIRECTION 0 -#define SCU_SATA_READ_DATA_DIRECTION 1 - -/** - * - * - * SCU_COMMAND_CONTEXT_MACROS These macros provide the mask and shift - * operations to construct the various SCU commands - */ -#define SCU_CONTEXT_COMMAND_REQUEST_TYPE_SHIFT 21 -#define SCU_CONTEXT_COMMAND_REQUEST_TYPE_MASK 0x00E00000 -#define scu_get_command_request_type(x) \ - ((x) & SCU_CONTEXT_COMMAND_REQUEST_TYPE_MASK) - -#define SCU_CONTEXT_COMMAND_REQUEST_SUBTYPE_SHIFT 18 -#define SCU_CONTEXT_COMMAND_REQUEST_SUBTYPE_MASK 0x001C0000 -#define scu_get_command_request_subtype(x) \ - ((x) & SCU_CONTEXT_COMMAND_REQUEST_SUBTYPE_MASK) - -#define SCU_CONTEXT_COMMAND_REQUEST_FULLTYPE_MASK \ - (\ - SCU_CONTEXT_COMMAND_REQUEST_TYPE_MASK \ - | SCU_CONTEXT_COMMAND_REQUEST_SUBTYPE_MASK \ - ) -#define scu_get_command_request_full_type(x) \ - ((x) & SCU_CONTEXT_COMMAND_REQUEST_FULLTYPE_MASK) - -#define SCU_CONTEXT_COMMAND_PROTOCOL_ENGINE_GROUP_SHIFT 16 -#define SCU_CONTEXT_COMMAND_PROTOCOL_ENGINE_GROUP_MASK 0x00010000 -#define scu_get_command_protocl_engine_group(x) \ - ((x) & SCU_CONTEXT_COMMAND_PROTOCOL_ENGINE_GROUP_MASK) - -#define SCU_CONTEXT_COMMAND_LOGICAL_PORT_SHIFT 12 -#define SCU_CONTEXT_COMMAND_LOGICAL_PORT_MASK 0x00007000 -#define scu_get_command_reqeust_logical_port(x) \ - ((x) & SCU_CONTEXT_COMMAND_LOGICAL_PORT_MASK) - - -#define MAKE_SCU_CONTEXT_COMMAND_TYPE(type) \ - ((u32)(type) << SCU_CONTEXT_COMMAND_REQUEST_TYPE_SHIFT) - -/** - * MAKE_SCU_CONTEXT_COMMAND_TYPE() - - * - * SCU_COMMAND_TYPES These constants provide the grouping of the different SCU - * command types. - */ -#define SCU_CONTEXT_COMMAND_REQUEST_TYPE_POST_TC MAKE_SCU_CONTEXT_COMMAND_TYPE(0) -#define SCU_CONTEXT_COMMAND_REQUEST_TYPE_DUMP_TC MAKE_SCU_CONTEXT_COMMAND_TYPE(1) -#define SCU_CONTEXT_COMMAND_REQUEST_TYPE_POST_RNC MAKE_SCU_CONTEXT_COMMAND_TYPE(2) -#define SCU_CONTEXT_COMMAND_REQUEST_TYPE_DUMP_RNC MAKE_SCU_CONTEXT_COMMAND_TYPE(3) -#define SCU_CONTEXT_COMMAND_REQUEST_TYPE_OTHER_RNC MAKE_SCU_CONTEXT_COMMAND_TYPE(6) - -#define MAKE_SCU_CONTEXT_COMMAND_REQUEST(type, command) \ - ((type) | ((command) << SCU_CONTEXT_COMMAND_REQUEST_SUBTYPE_SHIFT)) - -/** - * - * - * SCU_REQUEST_TYPES These constants are the various request types that can be - * posted to the SCU hardware. - */ -#define SCU_CONTEXT_COMMAND_REQUST_POST_TC \ - (MAKE_SCU_CONTEXT_COMMAND_REQUEST(SCU_CONTEXT_COMMAND_REQUEST_TYPE_POST_TC, 0)) - -#define SCU_CONTEXT_COMMAND_REQUEST_POST_TC_ABORT \ - (MAKE_SCU_CONTEXT_COMMAND_REQUEST(SCU_CONTEXT_COMMAND_REQUEST_TYPE_POST_TC, 1)) - -#define SCU_CONTEXT_COMMAND_REQUST_DUMP_TC \ - (MAKE_SCU_CONTEXT_COMMAND_REQUEST(SCU_CONTEXT_COMMAND_REQUEST_TYPE_DUMP_TC, 0)) - -#define SCU_CONTEXT_COMMAND_POST_RNC_32 \ - (MAKE_SCU_CONTEXT_COMMAND_REQUEST(SCU_CONTEXT_COMMAND_REQUEST_TYPE_POST_RNC, 0)) - -#define SCU_CONTEXT_COMMAND_POST_RNC_96 \ - (MAKE_SCU_CONTEXT_COMMAND_REQUEST(SCU_CONTEXT_COMMAND_REQUEST_TYPE_POST_RNC, 1)) - -#define SCU_CONTEXT_COMMAND_POST_RNC_INVALIDATE \ - (MAKE_SCU_CONTEXT_COMMAND_REQUEST(SCU_CONTEXT_COMMAND_REQUEST_TYPE_POST_RNC, 2)) - -#define SCU_CONTEXT_COMMAND_DUMP_RNC_32 \ - (MAKE_SCU_CONTEXT_COMMAND_REQUEST(SCU_CONTEXT_COMMAND_REQUEST_TYPE_DUMP_RNC, 0)) - -#define SCU_CONTEXT_COMMAND_DUMP_RNC_96 \ - (MAKE_SCU_CONTEXT_COMMAND_REQUEST(SCU_CONTEXT_COMMAND_REQUEST_TYPE_DUMP_RNC, 1)) - -#define SCU_CONTEXT_COMMAND_POST_RNC_SUSPEND_TX \ - (MAKE_SCU_CONTEXT_COMMAND_REQUEST(SCU_CONTEXT_COMMAND_REQUEST_TYPE_OTHER_RNC, 0)) - -#define SCU_CONTEXT_COMMAND_POST_RNC_SUSPEND_TX_RX \ - (MAKE_SCU_CONTEXT_COMMAND_REQUEST(SCU_CONTEXT_COMMAND_REQUEST_TYPE_OTHER_RNC, 1)) - -#define SCU_CONTEXT_COMMAND_POST_RNC_RESUME \ - (MAKE_SCU_CONTEXT_COMMAND_REQUEST(SCU_CONTEXT_COMMAND_REQUEST_TYPE_OTHER_RNC, 2)) - -#define SCU_CONTEXT_IT_NEXUS_LOSS_TIMER_ENABLE \ - (MAKE_SCU_CONTEXT_COMMAND_REQUEST(SCU_CONTEXT_COMMAND_REQUEST_TYPE_OTHER_RNC, 3)) - -#define SCU_CONTEXT_IT_NEXUS_LOSS_TIMER_DISABLE \ - (MAKE_SCU_CONTEXT_COMMAND_REQUEST(SCU_CONTEXT_COMMAND_REQUEST_TYPE_OTHER_RNC, 4)) - -/** - * - * - * SCU_TASK_CONTEXT_PROTOCOL SCU Task context protocol types this is uesd to - * program the SCU Task context protocol field in word 0x00. - */ -#define SCU_TASK_CONTEXT_PROTOCOL_SMP 0x00 -#define SCU_TASK_CONTEXT_PROTOCOL_SSP 0x01 -#define SCU_TASK_CONTEXT_PROTOCOL_STP 0x02 -#define SCU_TASK_CONTEXT_PROTOCOL_NONE 0x07 - -/** - * struct ssp_task_context - This is the SCU hardware definition for an SSP - * request. - * - * - */ -struct ssp_task_context { - /* OFFSET 0x18 */ - u32 reserved00:24; - u32 frame_type:8; - - /* OFFSET 0x1C */ - u32 reserved01; - - /* OFFSET 0x20 */ - u32 fill_bytes:2; - u32 reserved02:6; - u32 changing_data_pointer:1; - u32 retransmit:1; - u32 retry_data_frame:1; - u32 tlr_control:2; - u32 reserved03:19; - - /* OFFSET 0x24 */ - u32 uiRsvd4; - - /* OFFSET 0x28 */ - u32 target_port_transfer_tag:16; - u32 tag:16; - - /* OFFSET 0x2C */ - u32 data_offset; -}; - -/** - * struct stp_task_context - This is the SCU hardware definition for an STP - * request. - * - * - */ -struct stp_task_context { - /* OFFSET 0x18 */ - u32 fis_type:8; - u32 pm_port:4; - u32 reserved0:3; - u32 control:1; - u32 command:8; - u32 features:8; - - /* OFFSET 0x1C */ - u32 reserved1; - - /* OFFSET 0x20 */ - u32 reserved2; - - /* OFFSET 0x24 */ - u32 reserved3; - - /* OFFSET 0x28 */ - u32 ncq_tag:5; - u32 reserved4:27; - - /* OFFSET 0x2C */ - u32 data_offset; /* TODO: What is this used for? */ -}; - -/** - * struct smp_task_context - This is the SCU hardware definition for an SMP - * request. - * - * - */ -struct smp_task_context { - /* OFFSET 0x18 */ - u32 response_length:8; - u32 function_result:8; - u32 function:8; - u32 frame_type:8; - - /* OFFSET 0x1C */ - u32 smp_response_ufi:12; - u32 reserved1:20; - - /* OFFSET 0x20 */ - u32 reserved2; - - /* OFFSET 0x24 */ - u32 reserved3; - - /* OFFSET 0x28 */ - u32 reserved4; - - /* OFFSET 0x2C */ - u32 reserved5; -}; - -/** - * struct primitive_task_context - This is the SCU hardware definition used - * when the driver wants to send a primitive on the link. - * - * - */ -struct primitive_task_context { - /* OFFSET 0x18 */ - /** - * This field is the control word and it must be 0. - */ - u32 control; /* /< must be set to 0 */ - - /* OFFSET 0x1C */ - /** - * This field specifies the primitive that is to be transmitted. - */ - u32 sequence; - - /* OFFSET 0x20 */ - u32 reserved0; - - /* OFFSET 0x24 */ - u32 reserved1; - - /* OFFSET 0x28 */ - u32 reserved2; - - /* OFFSET 0x2C */ - u32 reserved3; -}; - -/** - * The union of the protocols that can be selected in the SCU task context - * field. - * - * protocol_context - */ -union protocol_context { - struct ssp_task_context ssp; - struct stp_task_context stp; - struct smp_task_context smp; - struct primitive_task_context primitive; - u32 words[6]; -}; - -/** - * struct scu_sgl_element - This structure represents a single SCU defined SGL - * element. SCU SGLs contain a 64 bit address with the maximum data transfer - * being 24 bits in size. The SGL can not cross a 4GB boundary. - * - * struct scu_sgl_element - */ -struct scu_sgl_element { - /** - * This field is the upper 32 bits of the 64 bit physical address. - */ - u32 address_upper; - - /** - * This field is the lower 32 bits of the 64 bit physical address. - */ - u32 address_lower; - - /** - * This field is the number of bytes to transfer. - */ - u32 length:24; - - /** - * This field is the address modifier to be used when a virtual function is - * requesting a data transfer. - */ - u32 address_modifier:8; - -}; - -#define SCU_SGL_ELEMENT_PAIR_A 0 -#define SCU_SGL_ELEMENT_PAIR_B 1 - -/** - * struct scu_sgl_element_pair - This structure is the SCU hardware definition - * of a pair of SGL elements. The SCU hardware always works on SGL pairs. - * They are refered to in the DS specification as SGL A and SGL B. Each SGL - * pair is followed by the address of the next pair. - * - * - */ -struct scu_sgl_element_pair { - /* OFFSET 0x60-0x68 */ - /** - * This field is the SGL element A of the SGL pair. - */ - struct scu_sgl_element A; - - /* OFFSET 0x6C-0x74 */ - /** - * This field is the SGL element B of the SGL pair. - */ - struct scu_sgl_element B; - - /* OFFSET 0x78-0x7C */ - /** - * This field is the upper 32 bits of the 64 bit address to the next SGL - * element pair. - */ - u32 next_pair_upper; - - /** - * This field is the lower 32 bits of the 64 bit address to the next SGL - * element pair. - */ - u32 next_pair_lower; - -}; - -/** - * struct transport_snapshot - This structure is the SCU hardware scratch area - * for the task context. This is set to 0 by the driver but can be read by - * issuing a dump TC request to the SCU. - * - * - */ -struct transport_snapshot { - /* OFFSET 0x48 */ - u32 xfer_rdy_write_data_length; - - /* OFFSET 0x4C */ - u32 data_offset; - - /* OFFSET 0x50 */ - u32 data_transfer_size:24; - u32 reserved_50_0:8; - - /* OFFSET 0x54 */ - u32 next_initiator_write_data_offset; - - /* OFFSET 0x58 */ - u32 next_initiator_write_data_xfer_size:24; - u32 reserved_58_0:8; -}; - -/** - * struct scu_task_context - This structure defines the contents of the SCU - * silicon task context. It lays out all of the fields according to the - * expected order and location for the Storage Controller unit. - * - * - */ -struct scu_task_context { - /* OFFSET 0x00 ------ */ - /** - * This field must be encoded to one of the valid SCU task priority values - * - SCU_TASK_PRIORITY_NORMAL - * - SCU_TASK_PRIORITY_HEAD_OF_Q - * - SCU_TASK_PRIORITY_HIGH - */ - u32 priority:2; - - /** - * This field must be set to true if this is an initiator generated request. - * Until target mode is supported all task requests are initiator requests. - */ - u32 initiator_request:1; - - /** - * This field must be set to one of the valid connection rates valid values - * are 0x8, 0x9, and 0xA. - */ - u32 connection_rate:4; - - /** - * This field muse be programed when generating an SMP response since the SMP - * connection remains open until the SMP response is generated. - */ - u32 protocol_engine_index:3; - - /** - * This field must contain the logical port for the task request. - */ - u32 logical_port_index:3; - - /** - * This field must be set to one of the SCU_TASK_CONTEXT_PROTOCOL values - * - SCU_TASK_CONTEXT_PROTOCOL_SMP - * - SCU_TASK_CONTEXT_PROTOCOL_SSP - * - SCU_TASK_CONTEXT_PROTOCOL_STP - * - SCU_TASK_CONTEXT_PROTOCOL_NONE - */ - u32 protocol_type:3; - - /** - * This filed must be set to the TCi allocated for this task - */ - u32 task_index:12; - - /** - * This field is reserved and must be set to 0x00 - */ - u32 reserved_00_0:1; - - /** - * For a normal task request this must be set to 0. If this is an abort of - * this task request it must be set to 1. - */ - u32 abort:1; - - /** - * This field must be set to true for the SCU hardware to process the task. - */ - u32 valid:1; - - /** - * This field must be set to SCU_TASK_CONTEXT_TYPE - */ - u32 context_type:1; - - /* OFFSET 0x04 */ - /** - * This field contains the RNi that is the target of this request. - */ - u32 remote_node_index:12; - - /** - * This field is programmed if this is a mirrored request, which we are not - * using, in which case it is the RNi for the mirrored target. - */ - u32 mirrored_node_index:12; - - /** - * This field is programmed with the direction of the SATA reqeust - * - SCU_SATA_WRITE_DATA_DIRECTION - * - SCU_SATA_READ_DATA_DIRECTION - */ - u32 sata_direction:1; - - /** - * This field is programmsed with one of the following SCU_COMMAND_CODE - * - SCU_COMMAND_CODE_INITIATOR_NEW_TASK - * - SCU_COMMAND_CODE_ACTIVE_TASK - * - SCU_COMMAND_CODE_PRIMITIVE_SEQ_TASK - * - SCU_COMMAND_CODE_TARGET_RAW_FRAMES - */ - u32 command_code:2; - - /** - * This field is set to true if the remote node should be suspended. - * This bit is only valid for SSP & SMP target devices. - */ - u32 suspend_node:1; - - /** - * This field is programmed with one of the following command type codes - * - * For SAS requests use the scu_ssp_task_type - * - SCU_TASK_TYPE_IOREAD - * - SCU_TASK_TYPE_IOWRITE - * - SCU_TASK_TYPE_SMP_REQUEST - * - SCU_TASK_TYPE_RESPONSE - * - SCU_TASK_TYPE_RAW_FRAME - * - SCU_TASK_TYPE_PRIMITIVE - * - * For SATA requests use the scu_sata_task_type - * - SCU_TASK_TYPE_DMA_IN - * - SCU_TASK_TYPE_FPDMAQ_READ - * - SCU_TASK_TYPE_PACKET_DMA_IN - * - SCU_TASK_TYPE_SATA_RAW_FRAME - * - SCU_TASK_TYPE_DMA_OUT - * - SCU_TASK_TYPE_FPDMAQ_WRITE - * - SCU_TASK_TYPE_PACKET_DMA_OUT - */ - u32 task_type:4; - - /* OFFSET 0x08 */ - /** - * This field is reserved and the must be set to 0x00 - */ - u32 link_layer_control:8; /* presently all reserved */ - - /** - * This field is set to true when TLR is to be enabled - */ - u32 ssp_tlr_enable:1; - - /** - * This is field specifies if the SCU DMAs a response frame to host - * memory for good response frames when operating in target mode. - */ - u32 dma_ssp_target_good_response:1; - - /** - * This field indicates if the SCU should DMA the response frame to - * host memory. - */ - u32 do_not_dma_ssp_good_response:1; - - /** - * This field is set to true when strict ordering is to be enabled - */ - u32 strict_ordering:1; - - /** - * This field indicates the type of endianess to be utilized for the - * frame. command, task, and response frames utilized control_frame - * set to 1. - */ - u32 control_frame:1; - - /** - * This field is reserved and the driver should set to 0x00 - */ - u32 tl_control_reserved:3; - - /** - * This field is set to true when the SCU hardware task timeout control is to - * be enabled - */ - u32 timeout_enable:1; - - /** - * This field is reserved and the driver should set it to 0x00 - */ - u32 pts_control_reserved:7; - - /** - * This field should be set to true when block guard is to be enabled - */ - u32 block_guard_enable:1; - - /** - * This field is reserved and the driver should set to 0x00 - */ - u32 sdma_control_reserved:7; - - /* OFFSET 0x0C */ - /** - * This field is the address modifier for this io request it should be - * programmed with the virtual function that is making the request. - */ - u32 address_modifier:16; - - /** - * @todo What we support mirrored SMP response frame? - */ - u32 mirrored_protocol_engine:3; /* mirrored protocol Engine Index */ - - /** - * If this is a mirrored request the logical port index for the mirrored RNi - * must be programmed. - */ - u32 mirrored_logical_port:4; /* mirrored local port index */ - - /** - * This field is reserved and the driver must set it to 0x00 - */ - u32 reserved_0C_0:8; - - /** - * This field must be set to true if the mirrored request processing is to be - * enabled. - */ - u32 mirror_request_enable:1; /* Mirrored request Enable */ - - /* OFFSET 0x10 */ - /** - * This field is the command iu length in dwords - */ - u32 ssp_command_iu_length:8; - - /** - * This is the target TLR enable bit it must be set to 0 when creatning the - * task context. - */ - u32 xfer_ready_tlr_enable:1; - - /** - * This field is reserved and the driver must set it to 0x00 - */ - u32 reserved_10_0:7; - - /** - * This is the maximum burst size that the SCU hardware will send in one - * connection its value is (N x 512) and N must be a multiple of 2. If the - * value is 0x00 then maximum burst size is disabled. - */ - u32 ssp_max_burst_size:16; - - /* OFFSET 0x14 */ - /** - * This filed is set to the number of bytes to be transfered in the request. - */ - u32 transfer_length_bytes:24; /* In terms of bytes */ - - /** - * This field is reserved and the driver should set it to 0x00 - */ - u32 reserved_14_0:8; - - /* OFFSET 0x18-0x2C */ - /** - * This union provides for the protocol specif part of the SCU Task Context. - */ - union protocol_context type; - - /* OFFSET 0x30-0x34 */ - /** - * This field is the upper 32 bits of the 64 bit physical address of the - * command iu buffer - */ - u32 command_iu_upper; - - /** - * This field is the lower 32 bits of the 64 bit physical address of the - * command iu buffer - */ - u32 command_iu_lower; - - /* OFFSET 0x38-0x3C */ - /** - * This field is the upper 32 bits of the 64 bit physical address of the - * response iu buffer - */ - u32 response_iu_upper; - - /** - * This field is the lower 32 bits of the 64 bit physical address of the - * response iu buffer - */ - u32 response_iu_lower; - - /* OFFSET 0x40 */ - /** - * This field is set to the task phase of the SCU hardware. The driver must - * set this to 0x01 - */ - u32 task_phase:8; - - /** - * This field is set to the transport layer task status. The driver must set - * this to 0x00 - */ - u32 task_status:8; - - /** - * This field is used during initiator write TLR - */ - u32 previous_extended_tag:4; - - /** - * This field is set the maximum number of retries for a STP non-data FIS - */ - u32 stp_retry_count:2; - - /** - * This field is reserved and the driver must set it to 0x00 - */ - u32 reserved_40_1:2; - - /** - * This field is used by the SCU TL to determine when to take a snapshot when - * tranmitting read data frames. - * - 0x00 The entire IO - * - 0x01 32k - * - 0x02 64k - * - 0x04 128k - * - 0x08 256k - */ - u32 ssp_tlr_threshold:4; - - /** - * This field is reserved and the driver must set it to 0x00 - */ - u32 reserved_40_2:4; - - /* OFFSET 0x44 */ - u32 write_data_length; /* read only set to 0 */ - - /* OFFSET 0x48-0x58 */ - struct transport_snapshot snapshot; /* read only set to 0 */ - - /* OFFSET 0x5C */ - u32 block_protection_enable:1; - u32 block_size:2; - u32 block_protection_function:2; - u32 reserved_5C_0:9; - u32 active_sgl_element:2; /* read only set to 0 */ - u32 sgl_exhausted:1; /* read only set to 0 */ - u32 payload_data_transfer_error:4; /* read only set to 0 */ - u32 frame_buffer_offset:11; /* read only set to 0 */ - - /* OFFSET 0x60-0x7C */ - /** - * This field is the first SGL element pair found in the TC data structure. - */ - struct scu_sgl_element_pair sgl_pair_ab; - /* OFFSET 0x80-0x9C */ - /** - * This field is the second SGL element pair found in the TC data structure. - */ - struct scu_sgl_element_pair sgl_pair_cd; - - /* OFFSET 0xA0-BC */ - struct scu_sgl_element_pair sgl_snapshot_ac; - - /* OFFSET 0xC0 */ - u32 active_sgl_element_pair; /* read only set to 0 */ - - /* OFFSET 0xC4-0xCC */ - u32 reserved_C4_CC[3]; - - /* OFFSET 0xD0 */ - u32 intermediate_crc_value:16; - u32 initial_crc_seed:16; - - /* OFFSET 0xD4 */ - u32 application_tag_for_verify:16; - u32 application_tag_for_generate:16; - - /* OFFSET 0xD8 */ - u32 reference_tag_seed_for_verify_function; - - /* OFFSET 0xDC */ - u32 reserved_DC; - - /* OFFSET 0xE0 */ - u32 reserved_E0_0:16; - u32 application_tag_mask_for_generate:16; - - /* OFFSET 0xE4 */ - u32 block_protection_control:16; - u32 application_tag_mask_for_verify:16; - - /* OFFSET 0xE8 */ - u32 block_protection_error:8; - u32 reserved_E8_0:24; - - /* OFFSET 0xEC */ - u32 reference_tag_seed_for_verify; - - /* OFFSET 0xF0 */ - u32 intermediate_crc_valid_snapshot:16; - u32 reserved_F0_0:16; - - /* OFFSET 0xF4 */ - u32 reference_tag_seed_for_verify_function_snapshot; - - /* OFFSET 0xF8 */ - u32 snapshot_of_reserved_dword_DC_of_tc; - - /* OFFSET 0xFC */ - u32 reference_tag_seed_for_generate_function_snapshot; - -}; - -#endif /* _SCU_TASK_CONTEXT_H_ */ diff --git a/trunk/drivers/scsi/isci/task.c b/trunk/drivers/scsi/isci/task.c deleted file mode 100644 index d6bcdd013dc9..000000000000 --- a/trunk/drivers/scsi/isci/task.c +++ /dev/null @@ -1,1676 +0,0 @@ -/* - * This file is provided under a dual BSD/GPLv2 license. When using or - * redistributing this file, you may do so under either license. - * - * GPL LICENSE SUMMARY - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License 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., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. - * The full GNU General Public License is included in this distribution - * in the file called LICENSE.GPL. - * - * BSD LICENSE - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Intel Corporation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include "sas.h" -#include -#include "remote_device.h" -#include "remote_node_context.h" -#include "isci.h" -#include "request.h" -#include "task.h" -#include "host.h" - -/** -* isci_task_refuse() - complete the request to the upper layer driver in -* the case where an I/O needs to be completed back in the submit path. -* @ihost: host on which the the request was queued -* @task: request to complete -* @response: response code for the completed task. -* @status: status code for the completed task. -* -*/ -static void isci_task_refuse(struct isci_host *ihost, struct sas_task *task, - enum service_response response, - enum exec_status status) - -{ - enum isci_completion_selection disposition; - - disposition = isci_perform_normal_io_completion; - disposition = isci_task_set_completion_status(task, response, status, - disposition); - - /* Tasks aborted specifically by a call to the lldd_abort_task - * function should not be completed to the host in the regular path. - */ - switch (disposition) { - case isci_perform_normal_io_completion: - /* Normal notification (task_done) */ - dev_dbg(&ihost->pdev->dev, - "%s: Normal - task = %p, response=%d, " - "status=%d\n", - __func__, task, response, status); - - task->lldd_task = NULL; - - isci_execpath_callback(ihost, task, task->task_done); - break; - - case isci_perform_aborted_io_completion: - /* - * No notification because this request is already in the - * abort path. - */ - dev_dbg(&ihost->pdev->dev, - "%s: Aborted - task = %p, response=%d, " - "status=%d\n", - __func__, task, response, status); - break; - - case isci_perform_error_io_completion: - /* Use sas_task_abort */ - dev_dbg(&ihost->pdev->dev, - "%s: Error - task = %p, response=%d, " - "status=%d\n", - __func__, task, response, status); - - isci_execpath_callback(ihost, task, sas_task_abort); - break; - - default: - dev_dbg(&ihost->pdev->dev, - "%s: isci task notification default case!", - __func__); - sas_task_abort(task); - break; - } -} - -#define for_each_sas_task(num, task) \ - for (; num > 0; num--,\ - task = list_entry(task->list.next, struct sas_task, list)) - - -static inline int isci_device_io_ready(struct isci_remote_device *idev, - struct sas_task *task) -{ - return idev ? test_bit(IDEV_IO_READY, &idev->flags) || - (test_bit(IDEV_IO_NCQERROR, &idev->flags) && - isci_task_is_ncq_recovery(task)) - : 0; -} -/** - * isci_task_execute_task() - This function is one of the SAS Domain Template - * functions. This function is called by libsas to send a task down to - * hardware. - * @task: This parameter specifies the SAS task to send. - * @num: This parameter specifies the number of tasks to queue. - * @gfp_flags: This parameter specifies the context of this call. - * - * status, zero indicates success. - */ -int isci_task_execute_task(struct sas_task *task, int num, gfp_t gfp_flags) -{ - struct isci_host *ihost = dev_to_ihost(task->dev); - struct isci_remote_device *idev; - unsigned long flags; - bool io_ready; - u16 tag; - - dev_dbg(&ihost->pdev->dev, "%s: num=%d\n", __func__, num); - - for_each_sas_task(num, task) { - enum sci_status status = SCI_FAILURE; - - spin_lock_irqsave(&ihost->scic_lock, flags); - idev = isci_lookup_device(task->dev); - io_ready = isci_device_io_ready(idev, task); - tag = isci_alloc_tag(ihost); - spin_unlock_irqrestore(&ihost->scic_lock, flags); - - dev_dbg(&ihost->pdev->dev, - "task: %p, num: %d dev: %p idev: %p:%#lx cmd = %p\n", - task, num, task->dev, idev, idev ? idev->flags : 0, - task->uldd_task); - - if (!idev) { - isci_task_refuse(ihost, task, SAS_TASK_UNDELIVERED, - SAS_DEVICE_UNKNOWN); - } else if (!io_ready || tag == SCI_CONTROLLER_INVALID_IO_TAG) { - /* Indicate QUEUE_FULL so that the scsi midlayer - * retries. - */ - isci_task_refuse(ihost, task, SAS_TASK_COMPLETE, - SAS_QUEUE_FULL); - } else { - /* There is a device and it's ready for I/O. */ - spin_lock_irqsave(&task->task_state_lock, flags); - - if (task->task_state_flags & SAS_TASK_STATE_ABORTED) { - /* The I/O was aborted. */ - spin_unlock_irqrestore(&task->task_state_lock, - flags); - - isci_task_refuse(ihost, task, - SAS_TASK_UNDELIVERED, - SAM_STAT_TASK_ABORTED); - } else { - task->task_state_flags |= SAS_TASK_AT_INITIATOR; - spin_unlock_irqrestore(&task->task_state_lock, flags); - - /* build and send the request. */ - status = isci_request_execute(ihost, idev, task, tag); - - if (status != SCI_SUCCESS) { - - spin_lock_irqsave(&task->task_state_lock, flags); - /* Did not really start this command. */ - task->task_state_flags &= ~SAS_TASK_AT_INITIATOR; - spin_unlock_irqrestore(&task->task_state_lock, flags); - - /* Indicate QUEUE_FULL so that the scsi - * midlayer retries. if the request - * failed for remote device reasons, - * it gets returned as - * SAS_TASK_UNDELIVERED next time - * through. - */ - isci_task_refuse(ihost, task, - SAS_TASK_COMPLETE, - SAS_QUEUE_FULL); - } - } - } - if (status != SCI_SUCCESS && tag != SCI_CONTROLLER_INVALID_IO_TAG) { - spin_lock_irqsave(&ihost->scic_lock, flags); - /* command never hit the device, so just free - * the tci and skip the sequence increment - */ - isci_tci_free(ihost, ISCI_TAG_TCI(tag)); - spin_unlock_irqrestore(&ihost->scic_lock, flags); - } - isci_put_device(idev); - } - return 0; -} - -static enum sci_status isci_sata_management_task_request_build(struct isci_request *ireq) -{ - struct isci_tmf *isci_tmf; - enum sci_status status; - - if (tmf_task != ireq->ttype) - return SCI_FAILURE; - - isci_tmf = isci_request_access_tmf(ireq); - - switch (isci_tmf->tmf_code) { - - case isci_tmf_sata_srst_high: - case isci_tmf_sata_srst_low: { - struct host_to_dev_fis *fis = &ireq->stp.cmd; - - memset(fis, 0, sizeof(*fis)); - - fis->fis_type = 0x27; - fis->flags &= ~0x80; - fis->flags &= 0xF0; - if (isci_tmf->tmf_code == isci_tmf_sata_srst_high) - fis->control |= ATA_SRST; - else - fis->control &= ~ATA_SRST; - break; - } - /* other management commnd go here... */ - default: - return SCI_FAILURE; - } - - /* core builds the protocol specific request - * based on the h2d fis. - */ - status = sci_task_request_construct_sata(ireq); - - return status; -} - -static struct isci_request *isci_task_request_build(struct isci_host *ihost, - struct isci_remote_device *idev, - u16 tag, struct isci_tmf *isci_tmf) -{ - enum sci_status status = SCI_FAILURE; - struct isci_request *ireq = NULL; - struct domain_device *dev; - - dev_dbg(&ihost->pdev->dev, - "%s: isci_tmf = %p\n", __func__, isci_tmf); - - dev = idev->domain_dev; - - /* do common allocation and init of request object. */ - ireq = isci_tmf_request_from_tag(ihost, isci_tmf, tag); - if (!ireq) - return NULL; - - /* let the core do it's construct. */ - status = sci_task_request_construct(ihost, idev, tag, - ireq); - - if (status != SCI_SUCCESS) { - dev_warn(&ihost->pdev->dev, - "%s: sci_task_request_construct failed - " - "status = 0x%x\n", - __func__, - status); - return NULL; - } - - /* XXX convert to get this from task->tproto like other drivers */ - if (dev->dev_type == SAS_END_DEV) { - isci_tmf->proto = SAS_PROTOCOL_SSP; - status = sci_task_request_construct_ssp(ireq); - if (status != SCI_SUCCESS) - return NULL; - } - - if (dev->dev_type == SATA_DEV || (dev->tproto & SAS_PROTOCOL_STP)) { - isci_tmf->proto = SAS_PROTOCOL_SATA; - status = isci_sata_management_task_request_build(ireq); - - if (status != SCI_SUCCESS) - return NULL; - } - return ireq; -} - -static int isci_task_execute_tmf(struct isci_host *ihost, - struct isci_remote_device *idev, - struct isci_tmf *tmf, unsigned long timeout_ms) -{ - DECLARE_COMPLETION_ONSTACK(completion); - enum sci_task_status status = SCI_TASK_FAILURE; - struct isci_request *ireq; - int ret = TMF_RESP_FUNC_FAILED; - unsigned long flags; - unsigned long timeleft; - u16 tag; - - spin_lock_irqsave(&ihost->scic_lock, flags); - tag = isci_alloc_tag(ihost); - spin_unlock_irqrestore(&ihost->scic_lock, flags); - - if (tag == SCI_CONTROLLER_INVALID_IO_TAG) - return ret; - - /* sanity check, return TMF_RESP_FUNC_FAILED - * if the device is not there and ready. - */ - if (!idev || - (!test_bit(IDEV_IO_READY, &idev->flags) && - !test_bit(IDEV_IO_NCQERROR, &idev->flags))) { - dev_dbg(&ihost->pdev->dev, - "%s: idev = %p not ready (%#lx)\n", - __func__, - idev, idev ? idev->flags : 0); - goto err_tci; - } else - dev_dbg(&ihost->pdev->dev, - "%s: idev = %p\n", - __func__, idev); - - /* Assign the pointer to the TMF's completion kernel wait structure. */ - tmf->complete = &completion; - - ireq = isci_task_request_build(ihost, idev, tag, tmf); - if (!ireq) - goto err_tci; - - spin_lock_irqsave(&ihost->scic_lock, flags); - - /* start the TMF io. */ - status = sci_controller_start_task(ihost, idev, ireq); - - if (status != SCI_TASK_SUCCESS) { - dev_dbg(&ihost->pdev->dev, - "%s: start_io failed - status = 0x%x, request = %p\n", - __func__, - status, - ireq); - spin_unlock_irqrestore(&ihost->scic_lock, flags); - goto err_tci; - } - - if (tmf->cb_state_func != NULL) - tmf->cb_state_func(isci_tmf_started, tmf, tmf->cb_data); - - isci_request_change_state(ireq, started); - - /* add the request to the remote device request list. */ - list_add(&ireq->dev_node, &idev->reqs_in_process); - - spin_unlock_irqrestore(&ihost->scic_lock, flags); - - /* Wait for the TMF to complete, or a timeout. */ - timeleft = wait_for_completion_timeout(&completion, - msecs_to_jiffies(timeout_ms)); - - if (timeleft == 0) { - spin_lock_irqsave(&ihost->scic_lock, flags); - - if (tmf->cb_state_func != NULL) - tmf->cb_state_func(isci_tmf_timed_out, tmf, tmf->cb_data); - - sci_controller_terminate_request(ihost, - idev, - ireq); - - spin_unlock_irqrestore(&ihost->scic_lock, flags); - - wait_for_completion(tmf->complete); - } - - isci_print_tmf(tmf); - - if (tmf->status == SCI_SUCCESS) - ret = TMF_RESP_FUNC_COMPLETE; - else if (tmf->status == SCI_FAILURE_IO_RESPONSE_VALID) { - dev_dbg(&ihost->pdev->dev, - "%s: tmf.status == " - "SCI_FAILURE_IO_RESPONSE_VALID\n", - __func__); - ret = TMF_RESP_FUNC_COMPLETE; - } - /* Else - leave the default "failed" status alone. */ - - dev_dbg(&ihost->pdev->dev, - "%s: completed request = %p\n", - __func__, - ireq); - - return ret; - - err_tci: - spin_lock_irqsave(&ihost->scic_lock, flags); - isci_tci_free(ihost, ISCI_TAG_TCI(tag)); - spin_unlock_irqrestore(&ihost->scic_lock, flags); - - return ret; -} - -static void isci_task_build_tmf(struct isci_tmf *tmf, - enum isci_tmf_function_codes code, - void (*tmf_sent_cb)(enum isci_tmf_cb_state, - struct isci_tmf *, - void *), - void *cb_data) -{ - memset(tmf, 0, sizeof(*tmf)); - - tmf->tmf_code = code; - tmf->cb_state_func = tmf_sent_cb; - tmf->cb_data = cb_data; -} - -static void isci_task_build_abort_task_tmf(struct isci_tmf *tmf, - enum isci_tmf_function_codes code, - void (*tmf_sent_cb)(enum isci_tmf_cb_state, - struct isci_tmf *, - void *), - struct isci_request *old_request) -{ - isci_task_build_tmf(tmf, code, tmf_sent_cb, old_request); - tmf->io_tag = old_request->io_tag; -} - -/** - * isci_task_validate_request_to_abort() - This function checks the given I/O - * against the "started" state. If the request is still "started", it's - * state is changed to aborted. NOTE: isci_host->scic_lock MUST BE HELD - * BEFORE CALLING THIS FUNCTION. - * @isci_request: This parameter specifies the request object to control. - * @isci_host: This parameter specifies the ISCI host object - * @isci_device: This is the device to which the request is pending. - * @aborted_io_completion: This is a completion structure that will be added to - * the request in case it is changed to aborting; this completion is - * triggered when the request is fully completed. - * - * Either "started" on successful change of the task status to "aborted", or - * "unallocated" if the task cannot be controlled. - */ -static enum isci_request_status isci_task_validate_request_to_abort( - struct isci_request *isci_request, - struct isci_host *isci_host, - struct isci_remote_device *isci_device, - struct completion *aborted_io_completion) -{ - enum isci_request_status old_state = unallocated; - - /* Only abort the task if it's in the - * device's request_in_process list - */ - if (isci_request && !list_empty(&isci_request->dev_node)) { - old_state = isci_request_change_started_to_aborted( - isci_request, aborted_io_completion); - - } - - return old_state; -} - -/** -* isci_request_cleanup_completed_loiterer() - This function will take care of -* the final cleanup on any request which has been explicitly terminated. -* @isci_host: This parameter specifies the ISCI host object -* @isci_device: This is the device to which the request is pending. -* @isci_request: This parameter specifies the terminated request object. -* @task: This parameter is the libsas I/O request. -*/ -static void isci_request_cleanup_completed_loiterer( - struct isci_host *isci_host, - struct isci_remote_device *isci_device, - struct isci_request *isci_request, - struct sas_task *task) -{ - unsigned long flags; - - dev_dbg(&isci_host->pdev->dev, - "%s: isci_device=%p, request=%p, task=%p\n", - __func__, isci_device, isci_request, task); - - if (task != NULL) { - - spin_lock_irqsave(&task->task_state_lock, flags); - task->lldd_task = NULL; - - task->task_state_flags &= ~SAS_TASK_NEED_DEV_RESET; - - isci_set_task_doneflags(task); - - /* If this task is not in the abort path, call task_done. */ - if (!(task->task_state_flags & SAS_TASK_STATE_ABORTED)) { - - spin_unlock_irqrestore(&task->task_state_lock, flags); - task->task_done(task); - } else - spin_unlock_irqrestore(&task->task_state_lock, flags); - } - - if (isci_request != NULL) { - spin_lock_irqsave(&isci_host->scic_lock, flags); - list_del_init(&isci_request->dev_node); - spin_unlock_irqrestore(&isci_host->scic_lock, flags); - } -} - -/** - * isci_terminate_request_core() - This function will terminate the given - * request, and wait for it to complete. This function must only be called - * from a thread that can wait. Note that the request is terminated and - * completed (back to the host, if started there). - * @ihost: This SCU. - * @idev: The target. - * @isci_request: The I/O request to be terminated. - * - */ -static void isci_terminate_request_core(struct isci_host *ihost, - struct isci_remote_device *idev, - struct isci_request *isci_request) -{ - enum sci_status status = SCI_SUCCESS; - bool was_terminated = false; - bool needs_cleanup_handling = false; - enum isci_request_status request_status; - unsigned long flags; - unsigned long termination_completed = 1; - struct completion *io_request_completion; - struct sas_task *task; - - dev_dbg(&ihost->pdev->dev, - "%s: device = %p; request = %p\n", - __func__, idev, isci_request); - - spin_lock_irqsave(&ihost->scic_lock, flags); - - io_request_completion = isci_request->io_request_completion; - - task = (isci_request->ttype == io_task) - ? isci_request_access_task(isci_request) - : NULL; - - /* Note that we are not going to control - * the target to abort the request. - */ - set_bit(IREQ_COMPLETE_IN_TARGET, &isci_request->flags); - - /* Make sure the request wasn't just sitting around signalling - * device condition (if the request handle is NULL, then the - * request completed but needed additional handling here). - */ - if (!test_bit(IREQ_TERMINATED, &isci_request->flags)) { - was_terminated = true; - needs_cleanup_handling = true; - status = sci_controller_terminate_request(ihost, - idev, - isci_request); - } - spin_unlock_irqrestore(&ihost->scic_lock, flags); - - /* - * The only time the request to terminate will - * fail is when the io request is completed and - * being aborted. - */ - if (status != SCI_SUCCESS) { - dev_dbg(&ihost->pdev->dev, - "%s: sci_controller_terminate_request" - " returned = 0x%x\n", - __func__, status); - - isci_request->io_request_completion = NULL; - - } else { - if (was_terminated) { - dev_dbg(&ihost->pdev->dev, - "%s: before completion wait (%p/%p)\n", - __func__, isci_request, io_request_completion); - - /* Wait here for the request to complete. */ - #define TERMINATION_TIMEOUT_MSEC 500 - termination_completed - = wait_for_completion_timeout( - io_request_completion, - msecs_to_jiffies(TERMINATION_TIMEOUT_MSEC)); - - if (!termination_completed) { - - /* The request to terminate has timed out. */ - spin_lock_irqsave(&ihost->scic_lock, - flags); - - /* Check for state changes. */ - if (!test_bit(IREQ_TERMINATED, &isci_request->flags)) { - - /* The best we can do is to have the - * request die a silent death if it - * ever really completes. - * - * Set the request state to "dead", - * and clear the task pointer so that - * an actual completion event callback - * doesn't do anything. - */ - isci_request->status = dead; - isci_request->io_request_completion - = NULL; - - if (isci_request->ttype == io_task) { - - /* Break links with the - * sas_task. - */ - isci_request->ttype_ptr.io_task_ptr - = NULL; - } - } else - termination_completed = 1; - - spin_unlock_irqrestore(&ihost->scic_lock, - flags); - - if (!termination_completed) { - - dev_dbg(&ihost->pdev->dev, - "%s: *** Timeout waiting for " - "termination(%p/%p)\n", - __func__, io_request_completion, - isci_request); - - /* The request can no longer be referenced - * safely since it may go away if the - * termination every really does complete. - */ - isci_request = NULL; - } - } - if (termination_completed) - dev_dbg(&ihost->pdev->dev, - "%s: after completion wait (%p/%p)\n", - __func__, isci_request, io_request_completion); - } - - if (termination_completed) { - - isci_request->io_request_completion = NULL; - - /* Peek at the status of the request. This will tell - * us if there was special handling on the request such that it - * needs to be detached and freed here. - */ - spin_lock_irqsave(&isci_request->state_lock, flags); - request_status = isci_request->status; - - if ((isci_request->ttype == io_task) /* TMFs are in their own thread */ - && ((request_status == aborted) - || (request_status == aborting) - || (request_status == terminating) - || (request_status == completed) - || (request_status == dead) - ) - ) { - - /* The completion routine won't free a request in - * the aborted/aborting/etc. states, so we do - * it here. - */ - needs_cleanup_handling = true; - } - spin_unlock_irqrestore(&isci_request->state_lock, flags); - - } - if (needs_cleanup_handling) - isci_request_cleanup_completed_loiterer( - ihost, idev, isci_request, task); - } -} - -/** - * isci_terminate_pending_requests() - This function will change the all of the - * requests on the given device's state to "aborting", will terminate the - * requests, and wait for them to complete. This function must only be - * called from a thread that can wait. Note that the requests are all - * terminated and completed (back to the host, if started there). - * @isci_host: This parameter specifies SCU. - * @idev: This parameter specifies the target. - * - */ -void isci_terminate_pending_requests(struct isci_host *ihost, - struct isci_remote_device *idev) -{ - struct completion request_completion; - enum isci_request_status old_state; - unsigned long flags; - LIST_HEAD(list); - - spin_lock_irqsave(&ihost->scic_lock, flags); - list_splice_init(&idev->reqs_in_process, &list); - - /* assumes that isci_terminate_request_core deletes from the list */ - while (!list_empty(&list)) { - struct isci_request *ireq = list_entry(list.next, typeof(*ireq), dev_node); - - /* Change state to "terminating" if it is currently - * "started". - */ - old_state = isci_request_change_started_to_newstate(ireq, - &request_completion, - terminating); - switch (old_state) { - case started: - case completed: - case aborting: - break; - default: - /* termination in progress, or otherwise dispositioned. - * We know the request was on 'list' so should be safe - * to move it back to reqs_in_process - */ - list_move(&ireq->dev_node, &idev->reqs_in_process); - ireq = NULL; - break; - } - - if (!ireq) - continue; - spin_unlock_irqrestore(&ihost->scic_lock, flags); - - init_completion(&request_completion); - - dev_dbg(&ihost->pdev->dev, - "%s: idev=%p request=%p; task=%p old_state=%d\n", - __func__, idev, ireq, - ireq->ttype == io_task ? isci_request_access_task(ireq) : NULL, - old_state); - - /* If the old_state is started: - * This request was not already being aborted. If it had been, - * then the aborting I/O (ie. the TMF request) would not be in - * the aborting state, and thus would be terminated here. Note - * that since the TMF completion's call to the kernel function - * "complete()" does not happen until the pending I/O request - * terminate fully completes, we do not have to implement a - * special wait here for already aborting requests - the - * termination of the TMF request will force the request - * to finish it's already started terminate. - * - * If old_state == completed: - * This request completed from the SCU hardware perspective - * and now just needs cleaning up in terms of freeing the - * request and potentially calling up to libsas. - * - * If old_state == aborting: - * This request has already gone through a TMF timeout, but may - * not have been terminated; needs cleaning up at least. - */ - isci_terminate_request_core(ihost, idev, ireq); - spin_lock_irqsave(&ihost->scic_lock, flags); - } - spin_unlock_irqrestore(&ihost->scic_lock, flags); -} - -/** - * isci_task_send_lu_reset_sas() - This function is called by of the SAS Domain - * Template functions. - * @lun: This parameter specifies the lun to be reset. - * - * status, zero indicates success. - */ -static int isci_task_send_lu_reset_sas( - struct isci_host *isci_host, - struct isci_remote_device *isci_device, - u8 *lun) -{ - struct isci_tmf tmf; - int ret = TMF_RESP_FUNC_FAILED; - - dev_dbg(&isci_host->pdev->dev, - "%s: isci_host = %p, isci_device = %p\n", - __func__, isci_host, isci_device); - /* Send the LUN reset to the target. By the time the call returns, - * the TMF has fully exected in the target (in which case the return - * value is "TMF_RESP_FUNC_COMPLETE", or the request timed-out (or - * was otherwise unable to be executed ("TMF_RESP_FUNC_FAILED"). - */ - isci_task_build_tmf(&tmf, isci_tmf_ssp_lun_reset, NULL, NULL); - - #define ISCI_LU_RESET_TIMEOUT_MS 2000 /* 2 second timeout. */ - ret = isci_task_execute_tmf(isci_host, isci_device, &tmf, ISCI_LU_RESET_TIMEOUT_MS); - - if (ret == TMF_RESP_FUNC_COMPLETE) - dev_dbg(&isci_host->pdev->dev, - "%s: %p: TMF_LU_RESET passed\n", - __func__, isci_device); - else - dev_dbg(&isci_host->pdev->dev, - "%s: %p: TMF_LU_RESET failed (%x)\n", - __func__, isci_device, ret); - - return ret; -} - -static int isci_task_send_lu_reset_sata(struct isci_host *ihost, - struct isci_remote_device *idev, u8 *lun) -{ - int ret = TMF_RESP_FUNC_FAILED; - struct isci_tmf tmf; - - /* Send the soft reset to the target */ - #define ISCI_SRST_TIMEOUT_MS 25000 /* 25 second timeout. */ - isci_task_build_tmf(&tmf, isci_tmf_sata_srst_high, NULL, NULL); - - ret = isci_task_execute_tmf(ihost, idev, &tmf, ISCI_SRST_TIMEOUT_MS); - - if (ret != TMF_RESP_FUNC_COMPLETE) { - dev_dbg(&ihost->pdev->dev, - "%s: Assert SRST failed (%p) = %x", - __func__, idev, ret); - - /* Return the failure so that the LUN reset is escalated - * to a target reset. - */ - } - return ret; -} - -/** - * isci_task_lu_reset() - This function is one of the SAS Domain Template - * functions. This is one of the Task Management functoins called by libsas, - * to reset the given lun. Note the assumption that while this call is - * executing, no I/O will be sent by the host to the device. - * @lun: This parameter specifies the lun to be reset. - * - * status, zero indicates success. - */ -int isci_task_lu_reset(struct domain_device *domain_device, u8 *lun) -{ - struct isci_host *isci_host = dev_to_ihost(domain_device); - struct isci_remote_device *isci_device; - unsigned long flags; - int ret; - - spin_lock_irqsave(&isci_host->scic_lock, flags); - isci_device = isci_lookup_device(domain_device); - spin_unlock_irqrestore(&isci_host->scic_lock, flags); - - dev_dbg(&isci_host->pdev->dev, - "%s: domain_device=%p, isci_host=%p; isci_device=%p\n", - __func__, domain_device, isci_host, isci_device); - - if (isci_device) - set_bit(IDEV_EH, &isci_device->flags); - - /* If there is a device reset pending on any request in the - * device's list, fail this LUN reset request in order to - * escalate to the device reset. - */ - if (!isci_device || - isci_device_is_reset_pending(isci_host, isci_device)) { - dev_dbg(&isci_host->pdev->dev, - "%s: No dev (%p), or " - "RESET PENDING: domain_device=%p\n", - __func__, isci_device, domain_device); - ret = TMF_RESP_FUNC_FAILED; - goto out; - } - - /* Send the task management part of the reset. */ - if (sas_protocol_ata(domain_device->tproto)) { - ret = isci_task_send_lu_reset_sata(isci_host, isci_device, lun); - } else - ret = isci_task_send_lu_reset_sas(isci_host, isci_device, lun); - - /* If the LUN reset worked, all the I/O can now be terminated. */ - if (ret == TMF_RESP_FUNC_COMPLETE) - /* Terminate all I/O now. */ - isci_terminate_pending_requests(isci_host, - isci_device); - - out: - isci_put_device(isci_device); - return ret; -} - - -/* int (*lldd_clear_nexus_port)(struct asd_sas_port *); */ -int isci_task_clear_nexus_port(struct asd_sas_port *port) -{ - return TMF_RESP_FUNC_FAILED; -} - - - -int isci_task_clear_nexus_ha(struct sas_ha_struct *ha) -{ - return TMF_RESP_FUNC_FAILED; -} - -/* Task Management Functions. Must be called from process context. */ - -/** - * isci_abort_task_process_cb() - This is a helper function for the abort task - * TMF command. It manages the request state with respect to the successful - * transmission / completion of the abort task request. - * @cb_state: This parameter specifies when this function was called - after - * the TMF request has been started and after it has timed-out. - * @tmf: This parameter specifies the TMF in progress. - * - * - */ -static void isci_abort_task_process_cb( - enum isci_tmf_cb_state cb_state, - struct isci_tmf *tmf, - void *cb_data) -{ - struct isci_request *old_request; - - old_request = (struct isci_request *)cb_data; - - dev_dbg(&old_request->isci_host->pdev->dev, - "%s: tmf=%p, old_request=%p\n", - __func__, tmf, old_request); - - switch (cb_state) { - - case isci_tmf_started: - /* The TMF has been started. Nothing to do here, since the - * request state was already set to "aborted" by the abort - * task function. - */ - if ((old_request->status != aborted) - && (old_request->status != completed)) - dev_dbg(&old_request->isci_host->pdev->dev, - "%s: Bad request status (%d): tmf=%p, old_request=%p\n", - __func__, old_request->status, tmf, old_request); - break; - - case isci_tmf_timed_out: - - /* Set the task's state to "aborting", since the abort task - * function thread set it to "aborted" (above) in anticipation - * of the task management request working correctly. Since the - * timeout has now fired, the TMF request failed. We set the - * state such that the request completion will indicate the - * device is no longer present. - */ - isci_request_change_state(old_request, aborting); - break; - - default: - dev_dbg(&old_request->isci_host->pdev->dev, - "%s: Bad cb_state (%d): tmf=%p, old_request=%p\n", - __func__, cb_state, tmf, old_request); - break; - } -} - -/** - * isci_task_abort_task() - This function is one of the SAS Domain Template - * functions. This function is called by libsas to abort a specified task. - * @task: This parameter specifies the SAS task to abort. - * - * status, zero indicates success. - */ -int isci_task_abort_task(struct sas_task *task) -{ - struct isci_host *isci_host = dev_to_ihost(task->dev); - DECLARE_COMPLETION_ONSTACK(aborted_io_completion); - struct isci_request *old_request = NULL; - enum isci_request_status old_state; - struct isci_remote_device *isci_device = NULL; - struct isci_tmf tmf; - int ret = TMF_RESP_FUNC_FAILED; - unsigned long flags; - bool any_dev_reset = false; - - /* Get the isci_request reference from the task. Note that - * this check does not depend on the pending request list - * in the device, because tasks driving resets may land here - * after completion in the core. - */ - spin_lock_irqsave(&isci_host->scic_lock, flags); - spin_lock(&task->task_state_lock); - - old_request = task->lldd_task; - - /* If task is already done, the request isn't valid */ - if (!(task->task_state_flags & SAS_TASK_STATE_DONE) && - (task->task_state_flags & SAS_TASK_AT_INITIATOR) && - old_request) - isci_device = isci_lookup_device(task->dev); - - spin_unlock(&task->task_state_lock); - spin_unlock_irqrestore(&isci_host->scic_lock, flags); - - dev_dbg(&isci_host->pdev->dev, - "%s: task = %p\n", __func__, task); - - if (!isci_device || !old_request) - goto out; - - set_bit(IDEV_EH, &isci_device->flags); - - /* This version of the driver will fail abort requests for - * SATA/STP. Failing the abort request this way will cause the - * SCSI error handler thread to escalate to LUN reset - */ - if (sas_protocol_ata(task->task_proto)) { - dev_dbg(&isci_host->pdev->dev, - " task %p is for a STP/SATA device;" - " returning TMF_RESP_FUNC_FAILED\n" - " to cause a LUN reset...\n", task); - goto out; - } - - dev_dbg(&isci_host->pdev->dev, - "%s: old_request == %p\n", __func__, old_request); - - any_dev_reset = isci_device_is_reset_pending(isci_host, isci_device); - - spin_lock_irqsave(&task->task_state_lock, flags); - - any_dev_reset = any_dev_reset || (task->task_state_flags & SAS_TASK_NEED_DEV_RESET); - - /* If the extraction of the request reference from the task - * failed, then the request has been completed (or if there is a - * pending reset then this abort request function must be failed - * in order to escalate to the target reset). - */ - if ((old_request == NULL) || any_dev_reset) { - - /* If the device reset task flag is set, fail the task - * management request. Otherwise, the original request - * has completed. - */ - if (any_dev_reset) { - - /* Turn off the task's DONE to make sure this - * task is escalated to a target reset. - */ - task->task_state_flags &= ~SAS_TASK_STATE_DONE; - - /* Make the reset happen as soon as possible. */ - task->task_state_flags |= SAS_TASK_NEED_DEV_RESET; - - spin_unlock_irqrestore(&task->task_state_lock, flags); - - /* Fail the task management request in order to - * escalate to the target reset. - */ - ret = TMF_RESP_FUNC_FAILED; - - dev_dbg(&isci_host->pdev->dev, - "%s: Failing task abort in order to " - "escalate to target reset because\n" - "SAS_TASK_NEED_DEV_RESET is set for " - "task %p on dev %p\n", - __func__, task, isci_device); - - - } else { - /* The request has already completed and there - * is nothing to do here other than to set the task - * done bit, and indicate that the task abort function - * was sucessful. - */ - isci_set_task_doneflags(task); - - spin_unlock_irqrestore(&task->task_state_lock, flags); - - ret = TMF_RESP_FUNC_COMPLETE; - - dev_dbg(&isci_host->pdev->dev, - "%s: abort task not needed for %p\n", - __func__, task); - } - goto out; - } else { - spin_unlock_irqrestore(&task->task_state_lock, flags); - } - - spin_lock_irqsave(&isci_host->scic_lock, flags); - - /* Check the request status and change to "aborted" if currently - * "starting"; if true then set the I/O kernel completion - * struct that will be triggered when the request completes. - */ - old_state = isci_task_validate_request_to_abort( - old_request, isci_host, isci_device, - &aborted_io_completion); - if ((old_state != started) && - (old_state != completed) && - (old_state != aborting)) { - - spin_unlock_irqrestore(&isci_host->scic_lock, flags); - - /* The request was already being handled by someone else (because - * they got to set the state away from started). - */ - dev_dbg(&isci_host->pdev->dev, - "%s: device = %p; old_request %p already being aborted\n", - __func__, - isci_device, old_request); - ret = TMF_RESP_FUNC_COMPLETE; - goto out; - } - if (task->task_proto == SAS_PROTOCOL_SMP || - test_bit(IREQ_COMPLETE_IN_TARGET, &old_request->flags)) { - - spin_unlock_irqrestore(&isci_host->scic_lock, flags); - - dev_dbg(&isci_host->pdev->dev, - "%s: SMP request (%d)" - " or complete_in_target (%d), thus no TMF\n", - __func__, (task->task_proto == SAS_PROTOCOL_SMP), - test_bit(IREQ_COMPLETE_IN_TARGET, &old_request->flags)); - - /* Set the state on the task. */ - isci_task_all_done(task); - - ret = TMF_RESP_FUNC_COMPLETE; - - /* Stopping and SMP devices are not sent a TMF, and are not - * reset, but the outstanding I/O request is terminated below. - */ - } else { - /* Fill in the tmf stucture */ - isci_task_build_abort_task_tmf(&tmf, isci_tmf_ssp_task_abort, - isci_abort_task_process_cb, - old_request); - - spin_unlock_irqrestore(&isci_host->scic_lock, flags); - - #define ISCI_ABORT_TASK_TIMEOUT_MS 500 /* half second timeout. */ - ret = isci_task_execute_tmf(isci_host, isci_device, &tmf, - ISCI_ABORT_TASK_TIMEOUT_MS); - - if (ret != TMF_RESP_FUNC_COMPLETE) - dev_dbg(&isci_host->pdev->dev, - "%s: isci_task_send_tmf failed\n", - __func__); - } - if (ret == TMF_RESP_FUNC_COMPLETE) { - set_bit(IREQ_COMPLETE_IN_TARGET, &old_request->flags); - - /* Clean up the request on our side, and wait for the aborted - * I/O to complete. - */ - isci_terminate_request_core(isci_host, isci_device, old_request); - } - - /* Make sure we do not leave a reference to aborted_io_completion */ - old_request->io_request_completion = NULL; - out: - isci_put_device(isci_device); - return ret; -} - -/** - * isci_task_abort_task_set() - This function is one of the SAS Domain Template - * functions. This is one of the Task Management functoins called by libsas, - * to abort all task for the given lun. - * @d_device: This parameter specifies the domain device associated with this - * request. - * @lun: This parameter specifies the lun associated with this request. - * - * status, zero indicates success. - */ -int isci_task_abort_task_set( - struct domain_device *d_device, - u8 *lun) -{ - return TMF_RESP_FUNC_FAILED; -} - - -/** - * isci_task_clear_aca() - This function is one of the SAS Domain Template - * functions. This is one of the Task Management functoins called by libsas. - * @d_device: This parameter specifies the domain device associated with this - * request. - * @lun: This parameter specifies the lun associated with this request. - * - * status, zero indicates success. - */ -int isci_task_clear_aca( - struct domain_device *d_device, - u8 *lun) -{ - return TMF_RESP_FUNC_FAILED; -} - - - -/** - * isci_task_clear_task_set() - This function is one of the SAS Domain Template - * functions. This is one of the Task Management functoins called by libsas. - * @d_device: This parameter specifies the domain device associated with this - * request. - * @lun: This parameter specifies the lun associated with this request. - * - * status, zero indicates success. - */ -int isci_task_clear_task_set( - struct domain_device *d_device, - u8 *lun) -{ - return TMF_RESP_FUNC_FAILED; -} - - -/** - * isci_task_query_task() - This function is implemented to cause libsas to - * correctly escalate the failed abort to a LUN or target reset (this is - * because sas_scsi_find_task libsas function does not correctly interpret - * all return codes from the abort task call). When TMF_RESP_FUNC_SUCC is - * returned, libsas turns this into a LUN reset; when FUNC_FAILED is - * returned, libsas will turn this into a target reset - * @task: This parameter specifies the sas task being queried. - * @lun: This parameter specifies the lun associated with this request. - * - * status, zero indicates success. - */ -int isci_task_query_task( - struct sas_task *task) -{ - /* See if there is a pending device reset for this device. */ - if (task->task_state_flags & SAS_TASK_NEED_DEV_RESET) - return TMF_RESP_FUNC_FAILED; - else - return TMF_RESP_FUNC_SUCC; -} - -/* - * isci_task_request_complete() - This function is called by the sci core when - * an task request completes. - * @ihost: This parameter specifies the ISCI host object - * @ireq: This parameter is the completed isci_request object. - * @completion_status: This parameter specifies the completion status from the - * sci core. - * - * none. - */ -void -isci_task_request_complete(struct isci_host *ihost, - struct isci_request *ireq, - enum sci_task_status completion_status) -{ - struct isci_tmf *tmf = isci_request_access_tmf(ireq); - struct completion *tmf_complete; - - dev_dbg(&ihost->pdev->dev, - "%s: request = %p, status=%d\n", - __func__, ireq, completion_status); - - isci_request_change_state(ireq, completed); - - tmf->status = completion_status; - set_bit(IREQ_COMPLETE_IN_TARGET, &ireq->flags); - - if (tmf->proto == SAS_PROTOCOL_SSP) { - memcpy(&tmf->resp.resp_iu, - &ireq->ssp.rsp, - SSP_RESP_IU_MAX_SIZE); - } else if (tmf->proto == SAS_PROTOCOL_SATA) { - memcpy(&tmf->resp.d2h_fis, - &ireq->stp.rsp, - sizeof(struct dev_to_host_fis)); - } - - /* PRINT_TMF( ((struct isci_tmf *)request->task)); */ - tmf_complete = tmf->complete; - - sci_controller_complete_io(ihost, ireq->target_device, ireq); - /* set the 'terminated' flag handle to make sure it cannot be terminated - * or completed again. - */ - set_bit(IREQ_TERMINATED, &ireq->flags); - - isci_request_change_state(ireq, unallocated); - list_del_init(&ireq->dev_node); - - /* The task management part completes last. */ - complete(tmf_complete); -} - -static void isci_smp_task_timedout(unsigned long _task) -{ - struct sas_task *task = (void *) _task; - unsigned long flags; - - spin_lock_irqsave(&task->task_state_lock, flags); - if (!(task->task_state_flags & SAS_TASK_STATE_DONE)) - task->task_state_flags |= SAS_TASK_STATE_ABORTED; - spin_unlock_irqrestore(&task->task_state_lock, flags); - - complete(&task->completion); -} - -static void isci_smp_task_done(struct sas_task *task) -{ - if (!del_timer(&task->timer)) - return; - complete(&task->completion); -} - -static struct sas_task *isci_alloc_task(void) -{ - struct sas_task *task = kzalloc(sizeof(*task), GFP_KERNEL); - - if (task) { - INIT_LIST_HEAD(&task->list); - spin_lock_init(&task->task_state_lock); - task->task_state_flags = SAS_TASK_STATE_PENDING; - init_timer(&task->timer); - init_completion(&task->completion); - } - - return task; -} - -static void isci_free_task(struct isci_host *ihost, struct sas_task *task) -{ - if (task) { - BUG_ON(!list_empty(&task->list)); - kfree(task); - } -} - -static int isci_smp_execute_task(struct isci_host *ihost, - struct domain_device *dev, void *req, - int req_size, void *resp, int resp_size) -{ - int res, retry; - struct sas_task *task = NULL; - - for (retry = 0; retry < 3; retry++) { - task = isci_alloc_task(); - if (!task) - return -ENOMEM; - - task->dev = dev; - task->task_proto = dev->tproto; - sg_init_one(&task->smp_task.smp_req, req, req_size); - sg_init_one(&task->smp_task.smp_resp, resp, resp_size); - - task->task_done = isci_smp_task_done; - - task->timer.data = (unsigned long) task; - task->timer.function = isci_smp_task_timedout; - task->timer.expires = jiffies + 10*HZ; - add_timer(&task->timer); - - res = isci_task_execute_task(task, 1, GFP_KERNEL); - - if (res) { - del_timer(&task->timer); - dev_dbg(&ihost->pdev->dev, - "%s: executing SMP task failed:%d\n", - __func__, res); - goto ex_err; - } - - wait_for_completion(&task->completion); - res = -ECOMM; - if ((task->task_state_flags & SAS_TASK_STATE_ABORTED)) { - dev_dbg(&ihost->pdev->dev, - "%s: smp task timed out or aborted\n", - __func__); - isci_task_abort_task(task); - if (!(task->task_state_flags & SAS_TASK_STATE_DONE)) { - dev_dbg(&ihost->pdev->dev, - "%s: SMP task aborted and not done\n", - __func__); - goto ex_err; - } - } - if (task->task_status.resp == SAS_TASK_COMPLETE && - task->task_status.stat == SAM_STAT_GOOD) { - res = 0; - break; - } - if (task->task_status.resp == SAS_TASK_COMPLETE && - task->task_status.stat == SAS_DATA_UNDERRUN) { - /* no error, but return the number of bytes of - * underrun */ - res = task->task_status.residual; - break; - } - if (task->task_status.resp == SAS_TASK_COMPLETE && - task->task_status.stat == SAS_DATA_OVERRUN) { - res = -EMSGSIZE; - break; - } else { - dev_dbg(&ihost->pdev->dev, - "%s: task to dev %016llx response: 0x%x " - "status 0x%x\n", __func__, - SAS_ADDR(dev->sas_addr), - task->task_status.resp, - task->task_status.stat); - isci_free_task(ihost, task); - task = NULL; - } - } -ex_err: - BUG_ON(retry == 3 && task != NULL); - isci_free_task(ihost, task); - return res; -} - -#define DISCOVER_REQ_SIZE 16 -#define DISCOVER_RESP_SIZE 56 - -int isci_smp_get_phy_attached_dev_type(struct isci_host *ihost, - struct domain_device *dev, - int phy_id, int *adt) -{ - struct smp_resp *disc_resp; - u8 *disc_req; - int res; - - disc_resp = kzalloc(DISCOVER_RESP_SIZE, GFP_KERNEL); - if (!disc_resp) - return -ENOMEM; - - disc_req = kzalloc(DISCOVER_REQ_SIZE, GFP_KERNEL); - if (disc_req) { - disc_req[0] = SMP_REQUEST; - disc_req[1] = SMP_DISCOVER; - disc_req[9] = phy_id; - } else { - kfree(disc_resp); - return -ENOMEM; - } - res = isci_smp_execute_task(ihost, dev, disc_req, DISCOVER_REQ_SIZE, - disc_resp, DISCOVER_RESP_SIZE); - if (!res) { - if (disc_resp->result != SMP_RESP_FUNC_ACC) - res = disc_resp->result; - else - *adt = disc_resp->disc.attached_dev_type; - } - kfree(disc_req); - kfree(disc_resp); - - return res; -} - -static void isci_wait_for_smp_phy_reset(struct isci_remote_device *idev, int phy_num) -{ - struct domain_device *dev = idev->domain_dev; - struct isci_port *iport = idev->isci_port; - struct isci_host *ihost = iport->isci_host; - int res, iteration = 0, attached_device_type; - #define STP_WAIT_MSECS 25000 - unsigned long tmo = msecs_to_jiffies(STP_WAIT_MSECS); - unsigned long deadline = jiffies + tmo; - enum { - SMP_PHYWAIT_PHYDOWN, - SMP_PHYWAIT_PHYUP, - SMP_PHYWAIT_DONE - } phy_state = SMP_PHYWAIT_PHYDOWN; - - /* While there is time, wait for the phy to go away and come back */ - while (time_is_after_jiffies(deadline) && phy_state != SMP_PHYWAIT_DONE) { - int event = atomic_read(&iport->event); - - ++iteration; - - tmo = wait_event_timeout(ihost->eventq, - event != atomic_read(&iport->event) || - !test_bit(IPORT_BCN_BLOCKED, &iport->flags), - tmo); - /* link down, stop polling */ - if (!test_bit(IPORT_BCN_BLOCKED, &iport->flags)) - break; - - dev_dbg(&ihost->pdev->dev, - "%s: iport %p, iteration %d," - " phase %d: time_remaining %lu, bcns = %d\n", - __func__, iport, iteration, phy_state, - tmo, test_bit(IPORT_BCN_PENDING, &iport->flags)); - - res = isci_smp_get_phy_attached_dev_type(ihost, dev, phy_num, - &attached_device_type); - tmo = deadline - jiffies; - - if (res) { - dev_dbg(&ihost->pdev->dev, - "%s: iteration %d, phase %d:" - " SMP error=%d, time_remaining=%lu\n", - __func__, iteration, phy_state, res, tmo); - break; - } - dev_dbg(&ihost->pdev->dev, - "%s: iport %p, iteration %d," - " phase %d: time_remaining %lu, bcns = %d, " - "attdevtype = %x\n", - __func__, iport, iteration, phy_state, - tmo, test_bit(IPORT_BCN_PENDING, &iport->flags), - attached_device_type); - - switch (phy_state) { - case SMP_PHYWAIT_PHYDOWN: - /* Has the device gone away? */ - if (!attached_device_type) - phy_state = SMP_PHYWAIT_PHYUP; - - break; - - case SMP_PHYWAIT_PHYUP: - /* Has the device come back? */ - if (attached_device_type) - phy_state = SMP_PHYWAIT_DONE; - break; - - case SMP_PHYWAIT_DONE: - break; - } - - } - dev_dbg(&ihost->pdev->dev, "%s: done\n", __func__); -} - -static int isci_reset_device(struct isci_host *ihost, - struct isci_remote_device *idev) -{ - struct sas_phy *phy = sas_find_local_phy(idev->domain_dev); - struct isci_port *iport = idev->isci_port; - enum sci_status status; - unsigned long flags; - int rc; - - dev_dbg(&ihost->pdev->dev, "%s: idev %p\n", __func__, idev); - - spin_lock_irqsave(&ihost->scic_lock, flags); - status = sci_remote_device_reset(idev); - if (status != SCI_SUCCESS) { - spin_unlock_irqrestore(&ihost->scic_lock, flags); - - dev_dbg(&ihost->pdev->dev, - "%s: sci_remote_device_reset(%p) returned %d!\n", - __func__, idev, status); - - return TMF_RESP_FUNC_FAILED; - } - spin_unlock_irqrestore(&ihost->scic_lock, flags); - - /* Make sure all pending requests are able to be fully terminated. */ - isci_device_clear_reset_pending(ihost, idev); - - /* If this is a device on an expander, disable BCN processing. */ - if (!scsi_is_sas_phy_local(phy)) - set_bit(IPORT_BCN_BLOCKED, &iport->flags); - - rc = sas_phy_reset(phy, true); - - /* Terminate in-progress I/O now. */ - isci_remote_device_nuke_requests(ihost, idev); - - /* Since all pending TCs have been cleaned, resume the RNC. */ - spin_lock_irqsave(&ihost->scic_lock, flags); - status = sci_remote_device_reset_complete(idev); - spin_unlock_irqrestore(&ihost->scic_lock, flags); - - /* If this is a device on an expander, bring the phy back up. */ - if (!scsi_is_sas_phy_local(phy)) { - /* A phy reset will cause the device to go away then reappear. - * Since libsas will take action on incoming BCNs (eg. remove - * a device going through an SMP phy-control driven reset), - * we need to wait until the phy comes back up before letting - * discovery proceed in libsas. - */ - isci_wait_for_smp_phy_reset(idev, phy->number); - - spin_lock_irqsave(&ihost->scic_lock, flags); - isci_port_bcn_enable(ihost, idev->isci_port); - spin_unlock_irqrestore(&ihost->scic_lock, flags); - } - - if (status != SCI_SUCCESS) { - dev_dbg(&ihost->pdev->dev, - "%s: sci_remote_device_reset_complete(%p) " - "returned %d!\n", __func__, idev, status); - } - - dev_dbg(&ihost->pdev->dev, "%s: idev %p complete.\n", __func__, idev); - - return rc; -} - -int isci_task_I_T_nexus_reset(struct domain_device *dev) -{ - struct isci_host *ihost = dev_to_ihost(dev); - struct isci_remote_device *idev; - unsigned long flags; - int ret; - - spin_lock_irqsave(&ihost->scic_lock, flags); - idev = isci_lookup_device(dev); - spin_unlock_irqrestore(&ihost->scic_lock, flags); - - if (!idev || !test_bit(IDEV_EH, &idev->flags)) { - ret = TMF_RESP_FUNC_COMPLETE; - goto out; - } - - ret = isci_reset_device(ihost, idev); - out: - isci_put_device(idev); - return ret; -} - -int isci_bus_reset_handler(struct scsi_cmnd *cmd) -{ - struct domain_device *dev = sdev_to_domain_dev(cmd->device); - struct isci_host *ihost = dev_to_ihost(dev); - struct isci_remote_device *idev; - unsigned long flags; - int ret; - - spin_lock_irqsave(&ihost->scic_lock, flags); - idev = isci_lookup_device(dev); - spin_unlock_irqrestore(&ihost->scic_lock, flags); - - if (!idev) { - ret = TMF_RESP_FUNC_COMPLETE; - goto out; - } - - ret = isci_reset_device(ihost, idev); - out: - isci_put_device(idev); - return ret; -} diff --git a/trunk/drivers/scsi/isci/task.h b/trunk/drivers/scsi/isci/task.h deleted file mode 100644 index 4a7fa90287ef..000000000000 --- a/trunk/drivers/scsi/isci/task.h +++ /dev/null @@ -1,367 +0,0 @@ -/* - * This file is provided under a dual BSD/GPLv2 license. When using or - * redistributing this file, you may do so under either license. - * - * GPL LICENSE SUMMARY - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License 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., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. - * The full GNU General Public License is included in this distribution - * in the file called LICENSE.GPL. - * - * BSD LICENSE - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Intel Corporation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#ifndef _ISCI_TASK_H_ -#define _ISCI_TASK_H_ - -#include -#include "host.h" - -struct isci_request; - -/** - * enum isci_tmf_cb_state - This enum defines the possible states in which the - * TMF callback function is invoked during the TMF execution process. - * - * - */ -enum isci_tmf_cb_state { - - isci_tmf_init_state = 0, - isci_tmf_started, - isci_tmf_timed_out -}; - -/** - * enum isci_tmf_function_codes - This enum defines the possible preparations - * of task management requests. - * - * - */ -enum isci_tmf_function_codes { - - isci_tmf_func_none = 0, - isci_tmf_ssp_task_abort = TMF_ABORT_TASK, - isci_tmf_ssp_lun_reset = TMF_LU_RESET, - isci_tmf_sata_srst_high = TMF_LU_RESET + 0x100, /* Non SCSI */ - isci_tmf_sata_srst_low = TMF_LU_RESET + 0x101 /* Non SCSI */ -}; -/** - * struct isci_tmf - This class represents the task management object which - * acts as an interface to libsas for processing task management requests - * - * - */ -struct isci_tmf { - - struct completion *complete; - enum sas_protocol proto; - union { - struct ssp_response_iu resp_iu; - struct dev_to_host_fis d2h_fis; - u8 rsp_buf[SSP_RESP_IU_MAX_SIZE]; - } resp; - unsigned char lun[8]; - u16 io_tag; - struct isci_remote_device *device; - enum isci_tmf_function_codes tmf_code; - int status; - - /* The optional callback function allows the user process to - * track the TMF transmit / timeout conditions. - */ - void (*cb_state_func)( - enum isci_tmf_cb_state, - struct isci_tmf *, void *); - void *cb_data; - -}; - -static inline void isci_print_tmf(struct isci_tmf *tmf) -{ - if (SAS_PROTOCOL_SATA == tmf->proto) - dev_dbg(&tmf->device->isci_port->isci_host->pdev->dev, - "%s: status = %x\n" - "tmf->resp.d2h_fis.status = %x\n" - "tmf->resp.d2h_fis.error = %x\n", - __func__, - tmf->status, - tmf->resp.d2h_fis.status, - tmf->resp.d2h_fis.error); - else - dev_dbg(&tmf->device->isci_port->isci_host->pdev->dev, - "%s: status = %x\n" - "tmf->resp.resp_iu.data_present = %x\n" - "tmf->resp.resp_iu.status = %x\n" - "tmf->resp.resp_iu.data_length = %x\n" - "tmf->resp.resp_iu.data[0] = %x\n" - "tmf->resp.resp_iu.data[1] = %x\n" - "tmf->resp.resp_iu.data[2] = %x\n" - "tmf->resp.resp_iu.data[3] = %x\n", - __func__, - tmf->status, - tmf->resp.resp_iu.datapres, - tmf->resp.resp_iu.status, - be32_to_cpu(tmf->resp.resp_iu.response_data_len), - tmf->resp.resp_iu.resp_data[0], - tmf->resp.resp_iu.resp_data[1], - tmf->resp.resp_iu.resp_data[2], - tmf->resp.resp_iu.resp_data[3]); -} - - -int isci_task_execute_task( - struct sas_task *task, - int num, - gfp_t gfp_flags); - -int isci_task_abort_task( - struct sas_task *task); - -int isci_task_abort_task_set( - struct domain_device *d_device, - u8 *lun); - -int isci_task_clear_aca( - struct domain_device *d_device, - u8 *lun); - -int isci_task_clear_task_set( - struct domain_device *d_device, - u8 *lun); - -int isci_task_query_task( - struct sas_task *task); - -int isci_task_lu_reset( - struct domain_device *d_device, - u8 *lun); - -int isci_task_clear_nexus_port( - struct asd_sas_port *port); - -int isci_task_clear_nexus_ha( - struct sas_ha_struct *ha); - -int isci_task_I_T_nexus_reset( - struct domain_device *d_device); - -void isci_task_request_complete( - struct isci_host *isci_host, - struct isci_request *request, - enum sci_task_status completion_status); - -u16 isci_task_ssp_request_get_io_tag_to_manage( - struct isci_request *request); - -u8 isci_task_ssp_request_get_function( - struct isci_request *request); - - -void *isci_task_ssp_request_get_response_data_address( - struct isci_request *request); - -u32 isci_task_ssp_request_get_response_data_length( - struct isci_request *request); - -int isci_queuecommand( - struct scsi_cmnd *scsi_cmd, - void (*donefunc)(struct scsi_cmnd *)); - -int isci_bus_reset_handler(struct scsi_cmnd *cmd); - -/** - * enum isci_completion_selection - This enum defines the possible actions to - * take with respect to a given request's notification back to libsas. - * - * - */ -enum isci_completion_selection { - - isci_perform_normal_io_completion, /* Normal notify (task_done) */ - isci_perform_aborted_io_completion, /* No notification. */ - isci_perform_error_io_completion /* Use sas_task_abort */ -}; - -static inline void isci_set_task_doneflags( - struct sas_task *task) -{ - /* Since no futher action will be taken on this task, - * make sure to mark it complete from the lldd perspective. - */ - task->task_state_flags |= SAS_TASK_STATE_DONE; - task->task_state_flags &= ~SAS_TASK_AT_INITIATOR; - task->task_state_flags &= ~SAS_TASK_STATE_PENDING; -} -/** - * isci_task_all_done() - This function clears the task bits to indicate the - * LLDD is done with the task. - * - * - */ -static inline void isci_task_all_done( - struct sas_task *task) -{ - unsigned long flags; - - /* Since no futher action will be taken on this task, - * make sure to mark it complete from the lldd perspective. - */ - spin_lock_irqsave(&task->task_state_lock, flags); - isci_set_task_doneflags(task); - spin_unlock_irqrestore(&task->task_state_lock, flags); -} - -/** - * isci_task_set_completion_status() - This function sets the completion status - * for the request. - * @task: This parameter is the completed request. - * @response: This parameter is the response code for the completed task. - * @status: This parameter is the status code for the completed task. - * -* @return The new notification mode for the request. -*/ -static inline enum isci_completion_selection -isci_task_set_completion_status( - struct sas_task *task, - enum service_response response, - enum exec_status status, - enum isci_completion_selection task_notification_selection) -{ - unsigned long flags; - - spin_lock_irqsave(&task->task_state_lock, flags); - - /* If a device reset is being indicated, make sure the I/O - * is in the error path. - */ - if (task->task_state_flags & SAS_TASK_NEED_DEV_RESET) { - /* Fail the I/O to make sure it goes into the error path. */ - response = SAS_TASK_UNDELIVERED; - status = SAM_STAT_TASK_ABORTED; - - task_notification_selection = isci_perform_error_io_completion; - } - task->task_status.resp = response; - task->task_status.stat = status; - - switch (task_notification_selection) { - - case isci_perform_error_io_completion: - - if (task->task_proto == SAS_PROTOCOL_SMP) { - /* There is no error escalation in the SMP case. - * Convert to a normal completion to avoid the - * timeout in the discovery path and to let the - * next action take place quickly. - */ - task_notification_selection - = isci_perform_normal_io_completion; - - /* Fall through to the normal case... */ - } else { - /* Use sas_task_abort */ - /* Leave SAS_TASK_STATE_DONE clear - * Leave SAS_TASK_AT_INITIATOR set. - */ - break; - } - - case isci_perform_aborted_io_completion: - /* This path can occur with task-managed requests as well as - * requests terminated because of LUN or device resets. - */ - /* Fall through to the normal case... */ - case isci_perform_normal_io_completion: - /* Normal notification (task_done) */ - isci_set_task_doneflags(task); - break; - default: - WARN_ONCE(1, "unknown task_notification_selection: %d\n", - task_notification_selection); - break; - } - - spin_unlock_irqrestore(&task->task_state_lock, flags); - - return task_notification_selection; - -} -/** -* isci_execpath_callback() - This function is called from the task -* execute path when the task needs to callback libsas about the submit-time -* task failure. The callback occurs either through the task's done function -* or through sas_task_abort. In the case of regular non-discovery SATA/STP I/O -* requests, libsas takes the host lock before calling execute task. Therefore -* in this situation the host lock must be managed before calling the func. -* -* @ihost: This parameter is the controller to which the I/O request was sent. -* @task: This parameter is the I/O request. -* @func: This parameter is the function to call in the correct context. -* @status: This parameter is the status code for the completed task. -* -*/ -static inline void isci_execpath_callback(struct isci_host *ihost, - struct sas_task *task, - void (*func)(struct sas_task *)) -{ - struct domain_device *dev = task->dev; - - if (dev_is_sata(dev) && task->uldd_task) { - unsigned long flags; - - /* Since we are still in the submit path, and since - * libsas takes the host lock on behalf of SATA - * devices before I/O starts (in the non-discovery case), - * we need to unlock before we can call the callback function. - */ - raw_local_irq_save(flags); - spin_unlock(dev->sata_dev.ap->lock); - func(task); - spin_lock(dev->sata_dev.ap->lock); - raw_local_irq_restore(flags); - } else - func(task); -} -#endif /* !defined(_SCI_TASK_H_) */ diff --git a/trunk/drivers/scsi/isci/unsolicited_frame_control.c b/trunk/drivers/scsi/isci/unsolicited_frame_control.c deleted file mode 100644 index e9e1e2abacb9..000000000000 --- a/trunk/drivers/scsi/isci/unsolicited_frame_control.c +++ /dev/null @@ -1,225 +0,0 @@ -/* - * This file is provided under a dual BSD/GPLv2 license. When using or - * redistributing this file, you may do so under either license. - * - * GPL LICENSE SUMMARY - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License 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., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. - * The full GNU General Public License is included in this distribution - * in the file called LICENSE.GPL. - * - * BSD LICENSE - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Intel Corporation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "host.h" -#include "unsolicited_frame_control.h" -#include "registers.h" - -int sci_unsolicited_frame_control_construct(struct isci_host *ihost) -{ - struct sci_unsolicited_frame_control *uf_control = &ihost->uf_control; - struct sci_unsolicited_frame *uf; - u32 buf_len, header_len, i; - dma_addr_t dma; - size_t size; - void *virt; - - /* - * Prepare all of the memory sizes for the UF headers, UF address - * table, and UF buffers themselves. - */ - buf_len = SCU_MAX_UNSOLICITED_FRAMES * SCU_UNSOLICITED_FRAME_BUFFER_SIZE; - header_len = SCU_MAX_UNSOLICITED_FRAMES * sizeof(struct scu_unsolicited_frame_header); - size = buf_len + header_len + SCU_MAX_UNSOLICITED_FRAMES * sizeof(dma_addr_t); - - /* - * The Unsolicited Frame buffers are set at the start of the UF - * memory descriptor entry. The headers and address table will be - * placed after the buffers. - */ - virt = dmam_alloc_coherent(&ihost->pdev->dev, size, &dma, GFP_KERNEL); - if (!virt) - return -ENOMEM; - - /* - * Program the location of the UF header table into the SCU. - * Notes: - * - The address must align on a 64-byte boundary. Guaranteed to be - * on 64-byte boundary already 1KB boundary for unsolicited frames. - * - Program unused header entries to overlap with the last - * unsolicited frame. The silicon will never DMA to these unused - * headers, since we program the UF address table pointers to - * NULL. - */ - uf_control->headers.physical_address = dma + buf_len; - uf_control->headers.array = virt + buf_len; - - /* - * Program the location of the UF address table into the SCU. - * Notes: - * - The address must align on a 64-bit boundary. Guaranteed to be on 64 - * byte boundary already due to above programming headers being on a - * 64-bit boundary and headers are on a 64-bytes in size. - */ - uf_control->address_table.physical_address = dma + buf_len + header_len; - uf_control->address_table.array = virt + buf_len + header_len; - uf_control->get = 0; - - /* - * UF buffer requirements are: - * - The last entry in the UF queue is not NULL. - * - There is a power of 2 number of entries (NULL or not-NULL) - * programmed into the queue. - * - Aligned on a 1KB boundary. */ - - /* - * Program the actual used UF buffers into the UF address table and - * the controller's array of UFs. - */ - for (i = 0; i < SCU_MAX_UNSOLICITED_FRAMES; i++) { - uf = &uf_control->buffers.array[i]; - - uf_control->address_table.array[i] = dma; - - uf->buffer = virt; - uf->header = &uf_control->headers.array[i]; - uf->state = UNSOLICITED_FRAME_EMPTY; - - /* - * Increment the address of the physical and virtual memory - * pointers. Everything is aligned on 1k boundary with an - * increment of 1k. - */ - virt += SCU_UNSOLICITED_FRAME_BUFFER_SIZE; - dma += SCU_UNSOLICITED_FRAME_BUFFER_SIZE; - } - - return 0; -} - -enum sci_status sci_unsolicited_frame_control_get_header(struct sci_unsolicited_frame_control *uf_control, - u32 frame_index, - void **frame_header) -{ - if (frame_index < SCU_MAX_UNSOLICITED_FRAMES) { - /* Skip the first word in the frame since this is a controll word used - * by the hardware. - */ - *frame_header = &uf_control->buffers.array[frame_index].header->data; - - return SCI_SUCCESS; - } - - return SCI_FAILURE_INVALID_PARAMETER_VALUE; -} - -enum sci_status sci_unsolicited_frame_control_get_buffer(struct sci_unsolicited_frame_control *uf_control, - u32 frame_index, - void **frame_buffer) -{ - if (frame_index < SCU_MAX_UNSOLICITED_FRAMES) { - *frame_buffer = uf_control->buffers.array[frame_index].buffer; - - return SCI_SUCCESS; - } - - return SCI_FAILURE_INVALID_PARAMETER_VALUE; -} - -bool sci_unsolicited_frame_control_release_frame(struct sci_unsolicited_frame_control *uf_control, - u32 frame_index) -{ - u32 frame_get; - u32 frame_cycle; - - frame_get = uf_control->get & (SCU_MAX_UNSOLICITED_FRAMES - 1); - frame_cycle = uf_control->get & SCU_MAX_UNSOLICITED_FRAMES; - - /* - * In the event there are NULL entries in the UF table, we need to - * advance the get pointer in order to find out if this frame should - * be released (i.e. update the get pointer) - */ - while (lower_32_bits(uf_control->address_table.array[frame_get]) == 0 && - upper_32_bits(uf_control->address_table.array[frame_get]) == 0 && - frame_get < SCU_MAX_UNSOLICITED_FRAMES) - frame_get++; - - /* - * The table has a NULL entry as it's last element. This is - * illegal. - */ - BUG_ON(frame_get >= SCU_MAX_UNSOLICITED_FRAMES); - if (frame_index >= SCU_MAX_UNSOLICITED_FRAMES) - return false; - - uf_control->buffers.array[frame_index].state = UNSOLICITED_FRAME_RELEASED; - - if (frame_get != frame_index) { - /* - * Frames remain in use until we advance the get pointer - * so there is nothing we can do here - */ - return false; - } - - /* - * The frame index is equal to the current get pointer so we - * can now free up all of the frame entries that - */ - while (uf_control->buffers.array[frame_get].state == UNSOLICITED_FRAME_RELEASED) { - uf_control->buffers.array[frame_get].state = UNSOLICITED_FRAME_EMPTY; - - if (frame_get+1 == SCU_MAX_UNSOLICITED_FRAMES-1) { - frame_cycle ^= SCU_MAX_UNSOLICITED_FRAMES; - frame_get = 0; - } else - frame_get++; - } - - uf_control->get = SCU_UFQGP_GEN_BIT(ENABLE_BIT) | frame_cycle | frame_get; - - return true; -} diff --git a/trunk/drivers/scsi/isci/unsolicited_frame_control.h b/trunk/drivers/scsi/isci/unsolicited_frame_control.h deleted file mode 100644 index 31cb9506f52d..000000000000 --- a/trunk/drivers/scsi/isci/unsolicited_frame_control.h +++ /dev/null @@ -1,278 +0,0 @@ -/* - * This file is provided under a dual BSD/GPLv2 license. When using or - * redistributing this file, you may do so under either license. - * - * GPL LICENSE SUMMARY - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License 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., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. - * The full GNU General Public License is included in this distribution - * in the file called LICENSE.GPL. - * - * BSD LICENSE - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Intel Corporation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _SCIC_SDS_UNSOLICITED_FRAME_CONTROL_H_ -#define _SCIC_SDS_UNSOLICITED_FRAME_CONTROL_H_ - -#include "isci.h" - -#define SCU_UNSOLICITED_FRAME_HEADER_DATA_DWORDS 15 - -/** - * struct scu_unsolicited_frame_header - - * - * This structure delineates the format of an unsolicited frame header. The - * first DWORD are UF attributes defined by the silicon architecture. The data - * depicts actual header information received on the link. - */ -struct scu_unsolicited_frame_header { - /** - * This field indicates if there is an Initiator Index Table entry with - * which this header is associated. - */ - u32 iit_exists:1; - - /** - * This field simply indicates the protocol type (i.e. SSP, STP, SMP). - */ - u32 protocol_type:3; - - /** - * This field indicates if the frame is an address frame (IAF or OAF) - * or if it is a information unit frame. - */ - u32 is_address_frame:1; - - /** - * This field simply indicates the connection rate at which the frame - * was received. - */ - u32 connection_rate:4; - - u32 reserved:23; - - /** - * This field represents the actual header data received on the link. - */ - u32 data[SCU_UNSOLICITED_FRAME_HEADER_DATA_DWORDS]; - -}; - - - -/** - * enum unsolicited_frame_state - - * - * This enumeration represents the current unsolicited frame state. The - * controller object can not updtate the hardware unsolicited frame put pointer - * unless it has already processed the priror unsolicited frames. - */ -enum unsolicited_frame_state { - /** - * This state is when the frame is empty and not in use. It is - * different from the released state in that the hardware could DMA - * data to this frame buffer. - */ - UNSOLICITED_FRAME_EMPTY, - - /** - * This state is set when the frame buffer is in use by by some - * object in the system. - */ - UNSOLICITED_FRAME_IN_USE, - - /** - * This state is set when the frame is returned to the free pool - * but one or more frames prior to this one are still in use. - * Once all of the frame before this one are freed it will go to - * the empty state. - */ - UNSOLICITED_FRAME_RELEASED, - - UNSOLICITED_FRAME_MAX_STATES -}; - -/** - * struct sci_unsolicited_frame - - * - * This is the unsolicited frame data structure it acts as the container for - * the current frame state, frame header and frame buffer. - */ -struct sci_unsolicited_frame { - /** - * This field contains the current frame state - */ - enum unsolicited_frame_state state; - - /** - * This field points to the frame header data. - */ - struct scu_unsolicited_frame_header *header; - - /** - * This field points to the frame buffer data. - */ - void *buffer; - -}; - -/** - * struct sci_uf_header_array - - * - * This structure contains all of the unsolicited frame header information. - */ -struct sci_uf_header_array { - /** - * This field is represents a virtual pointer to the start - * address of the UF address table. The table contains - * 64-bit pointers as required by the hardware. - */ - struct scu_unsolicited_frame_header *array; - - /** - * This field specifies the physical address location for the UF - * buffer array. - */ - dma_addr_t physical_address; - -}; - -/** - * struct sci_uf_buffer_array - - * - * This structure contains all of the unsolicited frame buffer (actual payload) - * information. - */ -struct sci_uf_buffer_array { - /** - * This field is the unsolicited frame data its used to manage - * the data for the unsolicited frame requests. It also represents - * the virtual address location that corresponds to the - * physical_address field. - */ - struct sci_unsolicited_frame array[SCU_MAX_UNSOLICITED_FRAMES]; - - /** - * This field specifies the physical address location for the UF - * buffer array. - */ - dma_addr_t physical_address; -}; - -/** - * struct sci_uf_address_table_array - - * - * This object maintains all of the unsolicited frame address table specific - * data. The address table is a collection of 64-bit pointers that point to - * 1KB buffers into which the silicon will DMA unsolicited frames. - */ -struct sci_uf_address_table_array { - /** - * This field represents a virtual pointer that refers to the - * starting address of the UF address table. - * 64-bit pointers are required by the hardware. - */ - dma_addr_t *array; - - /** - * This field specifies the physical address location for the UF - * address table. - */ - dma_addr_t physical_address; - -}; - -/** - * struct sci_unsolicited_frame_control - - * - * This object contains all of the data necessary to handle unsolicited frames. - */ -struct sci_unsolicited_frame_control { - /** - * This field is the software copy of the unsolicited frame queue - * get pointer. The controller object writes this value to the - * hardware to let the hardware put more unsolicited frame entries. - */ - u32 get; - - /** - * This field contains all of the unsolicited frame header - * specific fields. - */ - struct sci_uf_header_array headers; - - /** - * This field contains all of the unsolicited frame buffer - * specific fields. - */ - struct sci_uf_buffer_array buffers; - - /** - * This field contains all of the unsolicited frame address table - * specific fields. - */ - struct sci_uf_address_table_array address_table; - -}; - -struct isci_host; - -int sci_unsolicited_frame_control_construct(struct isci_host *ihost); - -enum sci_status sci_unsolicited_frame_control_get_header( - struct sci_unsolicited_frame_control *uf_control, - u32 frame_index, - void **frame_header); - -enum sci_status sci_unsolicited_frame_control_get_buffer( - struct sci_unsolicited_frame_control *uf_control, - u32 frame_index, - void **frame_buffer); - -bool sci_unsolicited_frame_control_release_frame( - struct sci_unsolicited_frame_control *uf_control, - u32 frame_index); - -#endif /* _SCIC_SDS_UNSOLICITED_FRAME_CONTROL_H_ */ diff --git a/trunk/drivers/spi/spi_s3c64xx.c b/trunk/drivers/spi/spi_s3c64xx.c index 8945e201e42e..795828b90f45 100644 --- a/trunk/drivers/spi/spi_s3c64xx.c +++ b/trunk/drivers/spi/spi_s3c64xx.c @@ -116,7 +116,9 @@ (((i)->fifo_lvl_mask + 1))) \ ? 1 : 0) -#define S3C64XX_SPI_ST_TX_DONE(v, i) (((v) & (1 << (i)->tx_st_done)) ? 1 : 0) +#define S3C64XX_SPI_ST_TX_DONE(v, i) ((((v) >> (i)->rx_lvl_offset) & \ + (((i)->fifo_lvl_mask + 1) << 1)) \ + ? 1 : 0) #define TX_FIFO_LVL(v, i) (((v) >> 6) & (i)->fifo_lvl_mask) #define RX_FIFO_LVL(v, i) (((v) >> (i)->rx_lvl_offset) & (i)->fifo_lvl_mask) diff --git a/trunk/drivers/ssb/driver_chipcommon_pmu.c b/trunk/drivers/ssb/driver_chipcommon_pmu.c index a7aef47bf739..305ade7825f7 100644 --- a/trunk/drivers/ssb/driver_chipcommon_pmu.c +++ b/trunk/drivers/ssb/driver_chipcommon_pmu.c @@ -417,9 +417,9 @@ static void ssb_pmu_resources_init(struct ssb_chipcommon *cc) u32 min_msk = 0, max_msk = 0; unsigned int i; const struct pmu_res_updown_tab_entry *updown_tab = NULL; - unsigned int updown_tab_size = 0; + unsigned int updown_tab_size; const struct pmu_res_depend_tab_entry *depend_tab = NULL; - unsigned int depend_tab_size = 0; + unsigned int depend_tab_size; switch (bus->chip_id) { case 0x4312: diff --git a/trunk/drivers/ssb/driver_gige.c b/trunk/drivers/ssb/driver_gige.c index d75890909222..5ba92a2719a4 100644 --- a/trunk/drivers/ssb/driver_gige.c +++ b/trunk/drivers/ssb/driver_gige.c @@ -106,9 +106,8 @@ void gige_pcicfg_write32(struct ssb_gige *dev, gige_write32(dev, SSB_GIGE_PCICFG + offset, value); } -static int __devinit ssb_gige_pci_read_config(struct pci_bus *bus, - unsigned int devfn, int reg, - int size, u32 *val) +static int ssb_gige_pci_read_config(struct pci_bus *bus, unsigned int devfn, + int reg, int size, u32 *val) { struct ssb_gige *dev = container_of(bus->ops, struct ssb_gige, pci_ops); unsigned long flags; @@ -137,9 +136,8 @@ static int __devinit ssb_gige_pci_read_config(struct pci_bus *bus, return PCIBIOS_SUCCESSFUL; } -static int __devinit ssb_gige_pci_write_config(struct pci_bus *bus, - unsigned int devfn, int reg, - int size, u32 val) +static int ssb_gige_pci_write_config(struct pci_bus *bus, unsigned int devfn, + int reg, int size, u32 val) { struct ssb_gige *dev = container_of(bus->ops, struct ssb_gige, pci_ops); unsigned long flags; @@ -168,8 +166,7 @@ static int __devinit ssb_gige_pci_write_config(struct pci_bus *bus, return PCIBIOS_SUCCESSFUL; } -static int __devinit ssb_gige_probe(struct ssb_device *sdev, - const struct ssb_device_id *id) +static int ssb_gige_probe(struct ssb_device *sdev, const struct ssb_device_id *id) { struct ssb_gige *dev; u32 base, tmslow, tmshigh; diff --git a/trunk/drivers/ssb/driver_pcicore.c b/trunk/drivers/ssb/driver_pcicore.c index 11d85bfd774e..2a20dabec76d 100644 --- a/trunk/drivers/ssb/driver_pcicore.c +++ b/trunk/drivers/ssb/driver_pcicore.c @@ -314,7 +314,7 @@ int ssb_pcicore_pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin) return ssb_mips_irq(extpci_core->dev) + 2; } -static void __devinit ssb_pcicore_init_hostmode(struct ssb_pcicore *pc) +static void ssb_pcicore_init_hostmode(struct ssb_pcicore *pc) { u32 val; @@ -379,7 +379,7 @@ static void __devinit ssb_pcicore_init_hostmode(struct ssb_pcicore *pc) register_pci_controller(&ssb_pcicore_controller); } -static int __devinit pcicore_is_in_hostmode(struct ssb_pcicore *pc) +static int pcicore_is_in_hostmode(struct ssb_pcicore *pc) { struct ssb_bus *bus = pc->dev->bus; u16 chipid_top; @@ -412,7 +412,7 @@ static int __devinit pcicore_is_in_hostmode(struct ssb_pcicore *pc) * Workarounds. **************************************************/ -static void __devinit ssb_pcicore_fix_sprom_core_index(struct ssb_pcicore *pc) +static void ssb_pcicore_fix_sprom_core_index(struct ssb_pcicore *pc) { u16 tmp = pcicore_read16(pc, SSB_PCICORE_SPROM(0)); if (((tmp & 0xF000) >> 12) != pc->dev->core_index) { @@ -514,22 +514,13 @@ static void ssb_pcicore_pcie_setup_workarounds(struct ssb_pcicore *pc) * Generic and Clientmode operation code. **************************************************/ -static void __devinit ssb_pcicore_init_clientmode(struct ssb_pcicore *pc) +static void ssb_pcicore_init_clientmode(struct ssb_pcicore *pc) { - ssb_pcicore_fix_sprom_core_index(pc); - /* Disable PCI interrupts. */ ssb_write32(pc->dev, SSB_INTVEC, 0); - - /* Additional PCIe always once-executed workarounds */ - if (pc->dev->id.coreid == SSB_DEV_PCIE) { - ssb_pcicore_serdes_workaround(pc); - /* TODO: ASPM */ - /* TODO: Clock Request Update */ - } } -void __devinit ssb_pcicore_init(struct ssb_pcicore *pc) +void ssb_pcicore_init(struct ssb_pcicore *pc) { struct ssb_device *dev = pc->dev; @@ -538,6 +529,8 @@ void __devinit ssb_pcicore_init(struct ssb_pcicore *pc) if (!ssb_device_is_enabled(dev)) ssb_device_enable(dev, 0); + ssb_pcicore_fix_sprom_core_index(pc); + #ifdef CONFIG_SSB_PCICORE_HOSTMODE pc->hostmode = pcicore_is_in_hostmode(pc); if (pc->hostmode) @@ -545,6 +538,13 @@ void __devinit ssb_pcicore_init(struct ssb_pcicore *pc) #endif /* CONFIG_SSB_PCICORE_HOSTMODE */ if (!pc->hostmode) ssb_pcicore_init_clientmode(pc); + + /* Additional PCIe always once-executed workarounds */ + if (dev->id.coreid == SSB_DEV_PCIE) { + ssb_pcicore_serdes_workaround(pc); + /* TODO: ASPM */ + /* TODO: Clock Request Update */ + } } static u32 ssb_pcie_read(struct ssb_pcicore *pc, u32 address) diff --git a/trunk/drivers/ssb/main.c b/trunk/drivers/ssb/main.c index 57b7b6460896..f8a13f863217 100644 --- a/trunk/drivers/ssb/main.c +++ b/trunk/drivers/ssb/main.c @@ -557,7 +557,7 @@ static int ssb_devices_register(struct ssb_bus *bus) } /* Needs ssb_buses_lock() */ -static int __devinit ssb_attach_queued_buses(void) +static int ssb_attach_queued_buses(void) { struct ssb_bus *bus, *n; int err = 0; @@ -768,9 +768,9 @@ static int ssb_fetch_invariants(struct ssb_bus *bus, return err; } -static int __devinit ssb_bus_register(struct ssb_bus *bus, - ssb_invariants_func_t get_invariants, - unsigned long baseaddr) +static int ssb_bus_register(struct ssb_bus *bus, + ssb_invariants_func_t get_invariants, + unsigned long baseaddr) { int err; @@ -851,8 +851,8 @@ static int __devinit ssb_bus_register(struct ssb_bus *bus, } #ifdef CONFIG_SSB_PCIHOST -int __devinit ssb_bus_pcibus_register(struct ssb_bus *bus, - struct pci_dev *host_pci) +int ssb_bus_pcibus_register(struct ssb_bus *bus, + struct pci_dev *host_pci) { int err; @@ -875,9 +875,9 @@ EXPORT_SYMBOL(ssb_bus_pcibus_register); #endif /* CONFIG_SSB_PCIHOST */ #ifdef CONFIG_SSB_PCMCIAHOST -int __devinit ssb_bus_pcmciabus_register(struct ssb_bus *bus, - struct pcmcia_device *pcmcia_dev, - unsigned long baseaddr) +int ssb_bus_pcmciabus_register(struct ssb_bus *bus, + struct pcmcia_device *pcmcia_dev, + unsigned long baseaddr) { int err; @@ -897,9 +897,8 @@ EXPORT_SYMBOL(ssb_bus_pcmciabus_register); #endif /* CONFIG_SSB_PCMCIAHOST */ #ifdef CONFIG_SSB_SDIOHOST -int __devinit ssb_bus_sdiobus_register(struct ssb_bus *bus, - struct sdio_func *func, - unsigned int quirks) +int ssb_bus_sdiobus_register(struct ssb_bus *bus, struct sdio_func *func, + unsigned int quirks) { int err; @@ -919,9 +918,9 @@ int __devinit ssb_bus_sdiobus_register(struct ssb_bus *bus, EXPORT_SYMBOL(ssb_bus_sdiobus_register); #endif /* CONFIG_SSB_PCMCIAHOST */ -int __devinit ssb_bus_ssbbus_register(struct ssb_bus *bus, - unsigned long baseaddr, - ssb_invariants_func_t get_invariants) +int ssb_bus_ssbbus_register(struct ssb_bus *bus, + unsigned long baseaddr, + ssb_invariants_func_t get_invariants) { int err; @@ -1002,8 +1001,8 @@ u32 ssb_calc_clock_rate(u32 plltype, u32 n, u32 m) switch (plltype) { case SSB_PLLTYPE_6: /* 100/200 or 120/240 only */ if (m & SSB_CHIPCO_CLK_T6_MMASK) - return SSB_CHIPCO_CLK_T6_M1; - return SSB_CHIPCO_CLK_T6_M0; + return SSB_CHIPCO_CLK_T6_M0; + return SSB_CHIPCO_CLK_T6_M1; case SSB_PLLTYPE_1: /* 48Mhz base, 3 dividers */ case SSB_PLLTYPE_3: /* 25Mhz, 2 dividers */ case SSB_PLLTYPE_4: /* 48Mhz, 4 dividers */ diff --git a/trunk/drivers/ssb/pci.c b/trunk/drivers/ssb/pci.c index a00b35f03084..7ad48585c5e6 100644 --- a/trunk/drivers/ssb/pci.c +++ b/trunk/drivers/ssb/pci.c @@ -734,9 +734,12 @@ static int ssb_pci_sprom_get(struct ssb_bus *bus, static void ssb_pci_get_boardinfo(struct ssb_bus *bus, struct ssb_boardinfo *bi) { - bi->vendor = bus->host_pci->subsystem_vendor; - bi->type = bus->host_pci->subsystem_device; - bi->rev = bus->host_pci->revision; + pci_read_config_word(bus->host_pci, PCI_SUBSYSTEM_VENDOR_ID, + &bi->vendor); + pci_read_config_word(bus->host_pci, PCI_SUBSYSTEM_ID, + &bi->type); + pci_read_config_word(bus->host_pci, PCI_REVISION_ID, + &bi->rev); } int ssb_pci_get_invariants(struct ssb_bus *bus, diff --git a/trunk/drivers/ssb/pcihost_wrapper.c b/trunk/drivers/ssb/pcihost_wrapper.c index d7a98131ebf3..f6c8c81a0025 100644 --- a/trunk/drivers/ssb/pcihost_wrapper.c +++ b/trunk/drivers/ssb/pcihost_wrapper.c @@ -53,8 +53,8 @@ static int ssb_pcihost_resume(struct pci_dev *dev) # define ssb_pcihost_resume NULL #endif /* CONFIG_PM */ -static int __devinit ssb_pcihost_probe(struct pci_dev *dev, - const struct pci_device_id *id) +static int ssb_pcihost_probe(struct pci_dev *dev, + const struct pci_device_id *id) { struct ssb_bus *ssb; int err = -ENOMEM; @@ -110,7 +110,7 @@ static void ssb_pcihost_remove(struct pci_dev *dev) pci_set_drvdata(dev, NULL); } -int __devinit ssb_pcihost_register(struct pci_driver *driver) +int ssb_pcihost_register(struct pci_driver *driver) { driver->probe = ssb_pcihost_probe; driver->remove = ssb_pcihost_remove; diff --git a/trunk/drivers/ssb/scan.c b/trunk/drivers/ssb/scan.c index 8047f9aaa4b2..45e5babd3961 100644 --- a/trunk/drivers/ssb/scan.c +++ b/trunk/drivers/ssb/scan.c @@ -310,7 +310,8 @@ int ssb_bus_scan(struct ssb_bus *bus, } else { if (bus->bustype == SSB_BUSTYPE_PCI) { bus->chip_id = pcidev_to_chipid(bus->host_pci); - bus->chip_rev = bus->host_pci->revision; + pci_read_config_byte(bus->host_pci, PCI_REVISION_ID, + &bus->chip_rev); bus->chip_package = 0; } else { bus->chip_id = 0x4710; diff --git a/trunk/drivers/staging/brcm80211/Kconfig b/trunk/drivers/staging/brcm80211/Kconfig index 379cf16e89f7..f4cf9b23481e 100644 --- a/trunk/drivers/staging/brcm80211/Kconfig +++ b/trunk/drivers/staging/brcm80211/Kconfig @@ -7,7 +7,6 @@ config BRCMSMAC default n depends on PCI depends on WLAN && MAC80211 - depends on X86 || MIPS select BRCMUTIL select FW_LOADER select CRC_CCITT @@ -21,7 +20,6 @@ config BRCMFMAC default n depends on MMC depends on WLAN && CFG80211 - depends on X86 || MIPS select BRCMUTIL select FW_LOADER select WIRELESS_EXT diff --git a/trunk/drivers/staging/comedi/Kconfig b/trunk/drivers/staging/comedi/Kconfig index 20008a4376e8..1502d80f6f78 100644 --- a/trunk/drivers/staging/comedi/Kconfig +++ b/trunk/drivers/staging/comedi/Kconfig @@ -2,7 +2,6 @@ config COMEDI tristate "Data acquisition support (comedi)" default N depends on m - depends on BROKEN || FRV || M32R || MN10300 || SUPERH || TILE || X86 ---help--- Enable support a wide range of data acquisition devices for Linux. @@ -161,7 +160,6 @@ config COMEDI_PCL730 config COMEDI_PCL812 tristate "Advantech PCL-812/813 and ADlink ACL-8112/8113/8113/8216" - depends on VIRT_TO_BUS default N ---help--- Enable support for Advantech PCL-812/PG, PCL-813/B, ADLink @@ -173,7 +171,6 @@ config COMEDI_PCL812 config COMEDI_PCL816 tristate "Advantech PCL-814 and PCL-816 ISA card support" - depends on VIRT_TO_BUS default N ---help--- Enable support for Advantech PCL-814 and PCL-816 ISA cards @@ -183,7 +180,6 @@ config COMEDI_PCL816 config COMEDI_PCL818 tristate "Advantech PCL-718 and PCL-818 ISA card support" - depends on VIRT_TO_BUS default N ---help--- Enable support for Advantech PCL-818 ISA cards @@ -273,7 +269,6 @@ config COMEDI_DAS800 config COMEDI_DAS1800 tristate "DAS1800 and compatible ISA card support" - depends on VIRT_TO_BUS select COMEDI_FC default N ---help--- @@ -345,7 +340,6 @@ config COMEDI_DT2817 config COMEDI_DT282X tristate "Data Translation DT2821 series and DT-EZ ISA card support" select COMEDI_FC - depends on VIRT_TO_BUS default N ---help--- Enable support for Data Translation DT2821 series including DT-EZ @@ -425,7 +419,6 @@ config COMEDI_ADQ12B config COMEDI_NI_AT_A2150 tristate "NI AT-A2150 ISA card support" depends on COMEDI_NI_COMMON - depends on VIRT_TO_BUS default N ---help--- Enable support for National Instruments AT-A2150 cards @@ -543,7 +536,6 @@ if COMEDI_PCI_DRIVERS && PCI config COMEDI_ADDI_APCI_035 tristate "ADDI-DATA APCI_035 support" - depends on VIRT_TO_BUS default N ---help--- Enable support for ADDI-DATA APCI_035 cards @@ -553,7 +545,6 @@ config COMEDI_ADDI_APCI_035 config COMEDI_ADDI_APCI_1032 tristate "ADDI-DATA APCI_1032 support" - depends on VIRT_TO_BUS default N ---help--- Enable support for ADDI-DATA APCI_1032 cards @@ -563,7 +554,6 @@ config COMEDI_ADDI_APCI_1032 config COMEDI_ADDI_APCI_1500 tristate "ADDI-DATA APCI_1500 support" - depends on VIRT_TO_BUS default N ---help--- Enable support for ADDI-DATA APCI_1500 cards @@ -573,7 +563,6 @@ config COMEDI_ADDI_APCI_1500 config COMEDI_ADDI_APCI_1516 tristate "ADDI-DATA APCI_1516 support" - depends on VIRT_TO_BUS default N ---help--- Enable support for ADDI-DATA APCI_1516 cards @@ -583,7 +572,6 @@ config COMEDI_ADDI_APCI_1516 config COMEDI_ADDI_APCI_1564 tristate "ADDI-DATA APCI_1564 support" - depends on VIRT_TO_BUS default N ---help--- Enable support for ADDI-DATA APCI_1564 cards @@ -593,7 +581,6 @@ config COMEDI_ADDI_APCI_1564 config COMEDI_ADDI_APCI_16XX tristate "ADDI-DATA APCI_16xx support" - depends on VIRT_TO_BUS default N ---help--- Enable support for ADDI-DATA APCI_16xx cards @@ -603,7 +590,6 @@ config COMEDI_ADDI_APCI_16XX config COMEDI_ADDI_APCI_2016 tristate "ADDI-DATA APCI_2016 support" - depends on VIRT_TO_BUS default N ---help--- Enable support for ADDI-DATA APCI_2016 cards @@ -613,7 +599,6 @@ config COMEDI_ADDI_APCI_2016 config COMEDI_ADDI_APCI_2032 tristate "ADDI-DATA APCI_2032 support" - depends on VIRT_TO_BUS default N ---help--- Enable support for ADDI-DATA APCI_2032 cards @@ -623,7 +608,6 @@ config COMEDI_ADDI_APCI_2032 config COMEDI_ADDI_APCI_2200 tristate "ADDI-DATA APCI_2200 support" - depends on VIRT_TO_BUS default N ---help--- Enable support for ADDI-DATA APCI_2200 cards @@ -633,7 +617,6 @@ config COMEDI_ADDI_APCI_2200 config COMEDI_ADDI_APCI_3001 tristate "ADDI-DATA APCI_3001 support" - depends on VIRT_TO_BUS select COMEDI_FC default N ---help--- @@ -644,7 +627,6 @@ config COMEDI_ADDI_APCI_3001 config COMEDI_ADDI_APCI_3120 tristate "ADDI-DATA APCI_3520 support" - depends on VIRT_TO_BUS select COMEDI_FC default N ---help--- @@ -655,7 +637,6 @@ config COMEDI_ADDI_APCI_3120 config COMEDI_ADDI_APCI_3501 tristate "ADDI-DATA APCI_3501 support" - depends on VIRT_TO_BUS default N ---help--- Enable support for ADDI-DATA APCI_3501 cards @@ -665,7 +646,6 @@ config COMEDI_ADDI_APCI_3501 config COMEDI_ADDI_APCI_3XXX tristate "ADDI-DATA APCI_3xxx support" - depends on VIRT_TO_BUS default N ---help--- Enable support for ADDI-DATA APCI_3xxx cards @@ -732,7 +712,6 @@ config COMEDI_ADL_PCI9111 config COMEDI_ADL_PCI9118 tristate "ADLink PCI-9118DG, PCI-9118HG, PCI-9118HR support" select COMEDI_FC - depends on VIRT_TO_BUS default N ---help--- Enable support for ADlink PCI-9118DG, PCI-9118HG, PCI-9118HR cards @@ -1308,7 +1287,6 @@ config COMEDI_NI_LABPC depends on COMEDI_MITE select COMEDI_8255 select COMEDI_FC - depends on VIRT_TO_BUS default N ---help--- Enable support for National Instruments Lab-PC and compatibles diff --git a/trunk/drivers/staging/ft1000/ft1000-usb/ft1000_hw.c b/trunk/drivers/staging/ft1000/ft1000-usb/ft1000_hw.c index 3f303ea14337..b0a4211f43a1 100644 --- a/trunk/drivers/staging/ft1000/ft1000-usb/ft1000_hw.c +++ b/trunk/drivers/staging/ft1000/ft1000-usb/ft1000_hw.c @@ -671,6 +671,7 @@ static int ft1000_reset_card(struct net_device *dev) return TRUE; } +#ifdef HAVE_NET_DEVICE_OPS static const struct net_device_ops ftnet_ops = { .ndo_open = &ft1000_open, @@ -678,6 +679,7 @@ static const struct net_device_ops ftnet_ops = .ndo_start_xmit = &ft1000_start_xmit, .ndo_get_stats = &ft1000_netdev_stats, }; +#endif //--------------------------------------------------------------------------- @@ -762,7 +764,14 @@ int init_ft1000_netdev(struct ft1000_device *ft1000dev) INIT_LIST_HEAD(&pInfo->nodes.list); +#ifdef HAVE_NET_DEVICE_OPS netdev->netdev_ops = &ftnet_ops; +#else + netdev->hard_start_xmit = &ft1000_start_xmit; + netdev->get_stats = &ft1000_netdev_stats; + netdev->open = &ft1000_open; + netdev->stop = &ft1000_close; +#endif ft1000dev->net = netdev; diff --git a/trunk/drivers/staging/iio/Kconfig b/trunk/drivers/staging/iio/Kconfig index d329635fb5c4..f96d5b5d5141 100644 --- a/trunk/drivers/staging/iio/Kconfig +++ b/trunk/drivers/staging/iio/Kconfig @@ -4,7 +4,7 @@ menuconfig IIO tristate "Industrial I/O support" - depends on GENERIC_HARDIRQS + depends on !S390 help The industrial I/O subsystem provides a unified framework for drivers for many different types of embedded sensors using a diff --git a/trunk/drivers/staging/iio/accel/adis16204.h b/trunk/drivers/staging/iio/accel/adis16204.h index 1690c0d15690..5310a4297688 100644 --- a/trunk/drivers/staging/iio/accel/adis16204.h +++ b/trunk/drivers/staging/iio/accel/adis16204.h @@ -84,6 +84,7 @@ struct adis16204_state { int adis16204_set_irq(struct iio_dev *indio_dev, bool enable); +#ifdef CONFIG_IIO_RING_BUFFER enum adis16204_scan { ADIS16204_SCAN_SUPPLY, ADIS16204_SCAN_ACC_X, @@ -92,7 +93,6 @@ enum adis16204_scan { ADIS16204_SCAN_TEMP, }; -#ifdef CONFIG_IIO_RING_BUFFER void adis16204_remove_trigger(struct iio_dev *indio_dev); int adis16204_probe_trigger(struct iio_dev *indio_dev); diff --git a/trunk/drivers/staging/iio/accel/adis16209.h b/trunk/drivers/staging/iio/accel/adis16209.h index 3153cbee0957..58d08db6f9b5 100644 --- a/trunk/drivers/staging/iio/accel/adis16209.h +++ b/trunk/drivers/staging/iio/accel/adis16209.h @@ -121,6 +121,8 @@ struct adis16209_state { int adis16209_set_irq(struct iio_dev *indio_dev, bool enable); +#ifdef CONFIG_IIO_RING_BUFFER + #define ADIS16209_SCAN_SUPPLY 0 #define ADIS16209_SCAN_ACC_X 1 #define ADIS16209_SCAN_ACC_Y 2 @@ -130,8 +132,6 @@ int adis16209_set_irq(struct iio_dev *indio_dev, bool enable); #define ADIS16209_SCAN_INCLI_Y 6 #define ADIS16209_SCAN_ROT 7 -#ifdef CONFIG_IIO_RING_BUFFER - void adis16209_remove_trigger(struct iio_dev *indio_dev); int adis16209_probe_trigger(struct iio_dev *indio_dev); diff --git a/trunk/drivers/staging/iio/gyro/adis16260.h b/trunk/drivers/staging/iio/gyro/adis16260.h index 24bf70e4b29b..702dc982f62f 100644 --- a/trunk/drivers/staging/iio/gyro/adis16260.h +++ b/trunk/drivers/staging/iio/gyro/adis16260.h @@ -104,6 +104,7 @@ struct adis16260_state { int adis16260_set_irq(struct iio_dev *indio_dev, bool enable); +#ifdef CONFIG_IIO_RING_BUFFER /* At the moment triggers are only used for ring buffer * filling. This may change! */ @@ -114,7 +115,6 @@ int adis16260_set_irq(struct iio_dev *indio_dev, bool enable); #define ADIS16260_SCAN_TEMP 3 #define ADIS16260_SCAN_ANGL 4 -#ifdef CONFIG_IIO_RING_BUFFER void adis16260_remove_trigger(struct iio_dev *indio_dev); int adis16260_probe_trigger(struct iio_dev *indio_dev); diff --git a/trunk/drivers/staging/iio/imu/adis16400.h b/trunk/drivers/staging/iio/imu/adis16400.h index e87715b9acc6..db184d11dfc0 100644 --- a/trunk/drivers/staging/iio/imu/adis16400.h +++ b/trunk/drivers/staging/iio/imu/adis16400.h @@ -158,6 +158,7 @@ struct adis16400_state { int adis16400_set_irq(struct iio_dev *indio_dev, bool enable); +#ifdef CONFIG_IIO_RING_BUFFER /* At the moment triggers are only used for ring buffer * filling. This may change! */ @@ -181,7 +182,6 @@ int adis16400_set_irq(struct iio_dev *indio_dev, bool enable); #define ADIS16300_SCAN_INCLI_X 12 #define ADIS16300_SCAN_INCLI_Y 13 -#ifdef CONFIG_IIO_RING_BUFFER void adis16400_remove_trigger(struct iio_dev *indio_dev); int adis16400_probe_trigger(struct iio_dev *indio_dev); diff --git a/trunk/drivers/staging/lirc/lirc_imon.c b/trunk/drivers/staging/lirc/lirc_imon.c index 4a9e563f40fa..4039eda2a15b 100644 --- a/trunk/drivers/staging/lirc/lirc_imon.c +++ b/trunk/drivers/staging/lirc/lirc_imon.c @@ -672,6 +672,8 @@ static void imon_incoming_packet(struct imon_context *context, static void usb_rx_callback(struct urb *urb) { struct imon_context *context; + unsigned char *buf; + int len; int intfnum = 0; if (!urb) @@ -681,6 +683,9 @@ static void usb_rx_callback(struct urb *urb) if (!context) return; + buf = urb->transfer_buffer; + len = urb->actual_length; + switch (urb->status) { case -ENOENT: /* usbcore unlink successful! */ return; @@ -723,6 +728,7 @@ static int imon_probe(struct usb_interface *interface, int ir_ep_found = 0; int alloc_status = 0; int vfd_proto_6p = 0; + int code_length; struct imon_context *context = NULL; int i; u16 vendor, product; @@ -743,6 +749,8 @@ static int imon_probe(struct usb_interface *interface, else context->display = 1; + code_length = BUF_CHUNK_SIZE * 8; + usbdev = usb_get_dev(interface_to_usbdev(interface)); iface_desc = interface->cur_altsetting; num_endpts = iface_desc->desc.bNumEndpoints; @@ -848,7 +856,7 @@ static int imon_probe(struct usb_interface *interface, strcpy(driver->name, MOD_NAME); driver->minor = -1; - driver->code_length = BUF_CHUNK_SIZE * 8; + driver->code_length = sizeof(int) * 8; driver->sample_rate = 0; driver->features = LIRC_CAN_REC_MODE2; driver->data = context; diff --git a/trunk/drivers/staging/lirc/lirc_serial.c b/trunk/drivers/staging/lirc/lirc_serial.c index 805df913bb6e..4a3cca03224a 100644 --- a/trunk/drivers/staging/lirc/lirc_serial.c +++ b/trunk/drivers/staging/lirc/lirc_serial.c @@ -838,23 +838,7 @@ static int hardware_init_port(void) static int init_port(void) { - int i, nlow, nhigh, result; - - result = request_irq(irq, irq_handler, - IRQF_DISABLED | (share_irq ? IRQF_SHARED : 0), - LIRC_DRIVER_NAME, (void *)&hardware); - - switch (result) { - case -EBUSY: - printk(KERN_ERR LIRC_DRIVER_NAME ": IRQ %d busy\n", irq); - return -EBUSY; - case -EINVAL: - printk(KERN_ERR LIRC_DRIVER_NAME - ": Bad irq number or handler\n"); - return -EINVAL; - default: - break; - }; + int i, nlow, nhigh; /* Reserve io region. */ /* @@ -909,17 +893,34 @@ static int init_port(void) printk(KERN_INFO LIRC_DRIVER_NAME ": Manually using active " "%s receiver\n", sense ? "low" : "high"); - dprintk("Interrupt %d, port %04x obtained\n", irq, io); return 0; } static int set_use_inc(void *data) { + int result; unsigned long flags; /* initialize timestamp */ do_gettimeofday(&lasttv); + result = request_irq(irq, irq_handler, + IRQF_DISABLED | (share_irq ? IRQF_SHARED : 0), + LIRC_DRIVER_NAME, (void *)&hardware); + + switch (result) { + case -EBUSY: + printk(KERN_ERR LIRC_DRIVER_NAME ": IRQ %d busy\n", irq); + return -EBUSY; + case -EINVAL: + printk(KERN_ERR LIRC_DRIVER_NAME + ": Bad irq number or handler\n"); + return -EINVAL; + default: + dprintk("Interrupt %d, port %04x obtained\n", irq, io); + break; + } + spin_lock_irqsave(&hardware[type].lock, flags); /* Set DLAB 0. */ @@ -944,6 +945,10 @@ static void set_use_dec(void *data) soutp(UART_IER, sinp(UART_IER) & (~(UART_IER_MSI|UART_IER_RLSI|UART_IER_THRI|UART_IER_RDI))); spin_unlock_irqrestore(&hardware[type].lock, flags); + + free_irq(irq, (void *)&hardware); + + dprintk("freed IRQ %d\n", irq); } static ssize_t lirc_write(struct file *file, const char *buf, @@ -1251,9 +1256,6 @@ static int __init lirc_serial_init_module(void) static void __exit lirc_serial_exit_module(void) { lirc_serial_exit(); - - free_irq(irq, (void *)&hardware); - if (iommap != 0) release_mem_region(iommap, 8 << ioshift); else diff --git a/trunk/drivers/staging/lirc/lirc_sir.c b/trunk/drivers/staging/lirc/lirc_sir.c index 0d3864594b12..a7b46f24f24e 100644 --- a/trunk/drivers/staging/lirc/lirc_sir.c +++ b/trunk/drivers/staging/lirc/lirc_sir.c @@ -739,16 +739,23 @@ static void send_space(unsigned long len) static void send_pulse(unsigned long len) { long bytes_out = len / TIME_CONST; + long time_left; - if (bytes_out == 0) + time_left = (long)len - (long)bytes_out * (long)TIME_CONST; + if (bytes_out == 0) { bytes_out++; - + time_left = 0; + } while (bytes_out--) { outb(PULSE, io + UART_TX); /* FIXME treba seriozne cakanie z char/serial.c */ while (!(inb(io + UART_LSR) & UART_LSR_THRE)) ; } +#if 0 + if (time_left > 0) + safe_udelay(time_left); +#endif } #endif diff --git a/trunk/drivers/staging/lirc/lirc_zilog.c b/trunk/drivers/staging/lirc/lirc_zilog.c index 4e051f6b52db..dd6a57c3c3a3 100644 --- a/trunk/drivers/staging/lirc/lirc_zilog.c +++ b/trunk/drivers/staging/lirc/lirc_zilog.c @@ -475,14 +475,14 @@ static int lirc_thread(void *arg) dprintk("poll thread started\n"); while (!kthread_should_stop()) { - set_current_state(TASK_INTERRUPTIBLE); - /* if device not opened, we can sleep half a second */ if (atomic_read(&ir->open_count) == 0) { schedule_timeout(HZ/2); continue; } + set_current_state(TASK_INTERRUPTIBLE); + /* * This is ~113*2 + 24 + jitter (2*repeat gap + code length). * We use this interval as the chip resets every time you poll diff --git a/trunk/drivers/staging/mei/init.c b/trunk/drivers/staging/mei/init.c index 685fcf639644..d1ffa32cd141 100644 --- a/trunk/drivers/staging/mei/init.c +++ b/trunk/drivers/staging/mei/init.c @@ -189,7 +189,7 @@ int mei_hw_init(struct mei_device *dev) mutex_lock(&dev->device_lock); } - if (err <= 0 && !dev->recvd_msg) { + if (!err && !dev->recvd_msg) { dev->mei_state = MEI_DISABLED; dev_dbg(&dev->pdev->dev, "wait_event_interruptible_timeout failed" diff --git a/trunk/drivers/staging/mei/wd.c b/trunk/drivers/staging/mei/wd.c index fff53d0b5c6e..2564b038636a 100644 --- a/trunk/drivers/staging/mei/wd.c +++ b/trunk/drivers/staging/mei/wd.c @@ -169,15 +169,10 @@ int mei_wd_stop(struct mei_device *dev, bool preserve) ret = wait_event_interruptible_timeout(dev->wait_stop_wd, dev->wd_stopped, 10 * HZ); mutex_lock(&dev->device_lock); - if (dev->wd_stopped) { - dev_dbg(&dev->pdev->dev, "stop wd complete ret=%d.\n", ret); - ret = 0; - } else { - if (!ret) - ret = -ETIMEDOUT; - dev_warn(&dev->pdev->dev, - "stop wd failed to complete ret=%d.\n", ret); - } + if (!dev->wd_stopped) + dev_dbg(&dev->pdev->dev, "stop wd failed to complete.\n"); + else + dev_dbg(&dev->pdev->dev, "stop wd complete.\n"); if (preserve) dev->wd_timeout = wd_timeout; diff --git a/trunk/drivers/staging/wlags49_h2/wl_internal.h b/trunk/drivers/staging/wlags49_h2/wl_internal.h index e86aad53b53d..cd129b3ee6c0 100644 --- a/trunk/drivers/staging/wlags49_h2/wl_internal.h +++ b/trunk/drivers/staging/wlags49_h2/wl_internal.h @@ -990,7 +990,14 @@ struct wl_private #endif // USE_WDS }; // wl_private +#ifdef HAVE_NETDEV_PRIV #define wl_priv(dev) ((struct wl_private *) netdev_priv(dev)) +#else +extern inline struct wl_private *wl_priv(struct net_device *dev) +{ + return dev->priv; +} +#endif /********************************************************************/ /* Locking and synchronization functions */ diff --git a/trunk/drivers/target/loopback/tcm_loop.c b/trunk/drivers/target/loopback/tcm_loop.c index 70c2e7fa6664..dee2a2c909f5 100644 --- a/trunk/drivers/target/loopback/tcm_loop.c +++ b/trunk/drivers/target/loopback/tcm_loop.c @@ -386,7 +386,7 @@ static int tcm_loop_device_reset(struct scsi_cmnd *sc) */ se_cmd->se_tmr_req = core_tmr_alloc_req(se_cmd, (void *)tl_tmr, TMR_LUN_RESET); - if (IS_ERR(se_cmd->se_tmr_req)) + if (!se_cmd->se_tmr_req) goto release; /* * Locate the underlying TCM struct se_lun from sc->device->lun @@ -1017,7 +1017,6 @@ static int tcm_loop_make_nexus( struct se_portal_group *se_tpg; struct tcm_loop_hba *tl_hba = tl_tpg->tl_hba; struct tcm_loop_nexus *tl_nexus; - int ret = -ENOMEM; if (tl_tpg->tl_hba->tl_nexus) { printk(KERN_INFO "tl_tpg->tl_hba->tl_nexus already exists\n"); @@ -1034,10 +1033,8 @@ static int tcm_loop_make_nexus( * Initialize the struct se_session pointer */ tl_nexus->se_sess = transport_init_session(); - if (IS_ERR(tl_nexus->se_sess)) { - ret = PTR_ERR(tl_nexus->se_sess); + if (!tl_nexus->se_sess) goto out; - } /* * Since we are running in 'demo mode' this call with generate a * struct se_node_acl for the tcm_loop struct se_portal_group with the SCSI @@ -1063,7 +1060,7 @@ static int tcm_loop_make_nexus( out: kfree(tl_nexus); - return ret; + return -ENOMEM; } static int tcm_loop_drop_nexus( @@ -1143,7 +1140,7 @@ static ssize_t tcm_loop_tpg_store_nexus( * the fabric protocol_id set in tcm_loop_make_scsi_hba(), and call * tcm_loop_make_nexus() */ - if (strlen(page) >= TL_WWN_ADDR_LEN) { + if (strlen(page) > TL_WWN_ADDR_LEN) { printk(KERN_ERR "Emulated NAA Sas Address: %s, exceeds" " max: %d\n", page, TL_WWN_ADDR_LEN); return -EINVAL; @@ -1324,7 +1321,7 @@ struct se_wwn *tcm_loop_make_scsi_hba( return ERR_PTR(-EINVAL); check_len: - if (strlen(name) >= TL_WWN_ADDR_LEN) { + if (strlen(name) > TL_WWN_ADDR_LEN) { printk(KERN_ERR "Emulated NAA %s Address: %s, exceeds" " max: %d\n", name, tcm_loop_dump_proto_id(tl_hba), TL_WWN_ADDR_LEN); diff --git a/trunk/drivers/target/target_core_configfs.c b/trunk/drivers/target/target_core_configfs.c index 25c1f49a7d8b..ee6fad979b50 100644 --- a/trunk/drivers/target/target_core_configfs.c +++ b/trunk/drivers/target/target_core_configfs.c @@ -304,7 +304,7 @@ struct target_fabric_configfs *target_fabric_configfs_init( printk(KERN_ERR "Unable to locate passed fabric name\n"); return NULL; } - if (strlen(name) >= TARGET_FABRIC_NAME_SIZE) { + if (strlen(name) > TARGET_FABRIC_NAME_SIZE) { printk(KERN_ERR "Passed name: %s exceeds TARGET_FABRIC" "_NAME_SIZE\n", name); return NULL; @@ -312,7 +312,7 @@ struct target_fabric_configfs *target_fabric_configfs_init( tf = kzalloc(sizeof(struct target_fabric_configfs), GFP_KERNEL); if (!(tf)) - return NULL; + return ERR_PTR(-ENOMEM); INIT_LIST_HEAD(&tf->tf_list); atomic_set(&tf->tf_access_cnt, 0); @@ -851,7 +851,7 @@ static ssize_t target_core_dev_wwn_store_attr_vpd_unit_serial( return -EOPNOTSUPP; } - if (strlen(page) >= INQUIRY_VPD_SERIAL_LEN) { + if ((strlen(page) + 1) > INQUIRY_VPD_SERIAL_LEN) { printk(KERN_ERR "Emulated VPD Unit Serial exceeds" " INQUIRY_VPD_SERIAL_LEN: %d\n", INQUIRY_VPD_SERIAL_LEN); return -EOVERFLOW; @@ -917,7 +917,7 @@ static ssize_t target_core_dev_wwn_show_attr_vpd_protocol_identifier( transport_dump_vpd_proto_id(vpd, buf, VPD_TMP_BUF_SIZE); - if ((len + strlen(buf) >= PAGE_SIZE)) + if ((len + strlen(buf) > PAGE_SIZE)) break; len += sprintf(page+len, "%s", buf); @@ -962,19 +962,19 @@ static ssize_t target_core_dev_wwn_show_attr_##_name( \ \ memset(buf, 0, VPD_TMP_BUF_SIZE); \ transport_dump_vpd_assoc(vpd, buf, VPD_TMP_BUF_SIZE); \ - if ((len + strlen(buf) >= PAGE_SIZE)) \ + if ((len + strlen(buf) > PAGE_SIZE)) \ break; \ len += sprintf(page+len, "%s", buf); \ \ memset(buf, 0, VPD_TMP_BUF_SIZE); \ transport_dump_vpd_ident_type(vpd, buf, VPD_TMP_BUF_SIZE); \ - if ((len + strlen(buf) >= PAGE_SIZE)) \ + if ((len + strlen(buf) > PAGE_SIZE)) \ break; \ len += sprintf(page+len, "%s", buf); \ \ memset(buf, 0, VPD_TMP_BUF_SIZE); \ transport_dump_vpd_ident(vpd, buf, VPD_TMP_BUF_SIZE); \ - if ((len + strlen(buf) >= PAGE_SIZE)) \ + if ((len + strlen(buf) > PAGE_SIZE)) \ break; \ len += sprintf(page+len, "%s", buf); \ } \ @@ -1299,7 +1299,7 @@ static ssize_t target_core_dev_pr_show_attr_res_pr_registered_i_pts( &i_buf[0] : "", pr_reg->pr_res_key, pr_reg->pr_res_generation); - if ((len + strlen(buf) >= PAGE_SIZE)) + if ((len + strlen(buf) > PAGE_SIZE)) break; len += sprintf(page+len, "%s", buf); @@ -1496,7 +1496,7 @@ static ssize_t target_core_dev_pr_store_attr_res_aptpl_metadata( ret = -ENOMEM; goto out; } - if (strlen(i_port) >= PR_APTPL_MAX_IPORT_LEN) { + if (strlen(i_port) > PR_APTPL_MAX_IPORT_LEN) { printk(KERN_ERR "APTPL metadata initiator_node=" " exceeds PR_APTPL_MAX_IPORT_LEN: %d\n", PR_APTPL_MAX_IPORT_LEN); @@ -1510,7 +1510,7 @@ static ssize_t target_core_dev_pr_store_attr_res_aptpl_metadata( ret = -ENOMEM; goto out; } - if (strlen(isid) >= PR_REG_ISID_LEN) { + if (strlen(isid) > PR_REG_ISID_LEN) { printk(KERN_ERR "APTPL metadata initiator_isid" "= exceeds PR_REG_ISID_LEN: %d\n", PR_REG_ISID_LEN); @@ -1571,7 +1571,7 @@ static ssize_t target_core_dev_pr_store_attr_res_aptpl_metadata( ret = -ENOMEM; goto out; } - if (strlen(t_port) >= PR_APTPL_MAX_TPORT_LEN) { + if (strlen(t_port) > PR_APTPL_MAX_TPORT_LEN) { printk(KERN_ERR "APTPL metadata target_node=" " exceeds PR_APTPL_MAX_TPORT_LEN: %d\n", PR_APTPL_MAX_TPORT_LEN); @@ -3052,7 +3052,7 @@ static struct config_group *target_core_call_addhbatotarget( int ret; memset(buf, 0, TARGET_CORE_NAME_MAX_LEN); - if (strlen(name) >= TARGET_CORE_NAME_MAX_LEN) { + if (strlen(name) > TARGET_CORE_NAME_MAX_LEN) { printk(KERN_ERR "Passed *name strlen(): %d exceeds" " TARGET_CORE_NAME_MAX_LEN: %d\n", (int)strlen(name), TARGET_CORE_NAME_MAX_LEN); diff --git a/trunk/drivers/target/target_core_device.c b/trunk/drivers/target/target_core_device.c index ba698ea62bb2..8407f9ca2b31 100644 --- a/trunk/drivers/target/target_core_device.c +++ b/trunk/drivers/target/target_core_device.c @@ -192,7 +192,7 @@ int transport_get_lun_for_tmr( &SE_NODE_ACL(se_sess)->device_list[unpacked_lun]; if (deve->lun_flags & TRANSPORT_LUNFLAGS_INITIATOR_ACCESS) { se_lun = se_cmd->se_lun = se_tmr->tmr_lun = deve->se_lun; - dev = se_lun->lun_se_dev; + dev = se_tmr->tmr_dev = se_lun->lun_se_dev; se_cmd->pr_res_key = deve->pr_res_key; se_cmd->orig_fe_lun = unpacked_lun; se_cmd->se_orig_obj_ptr = SE_LUN(se_cmd)->lun_se_dev; @@ -216,7 +216,6 @@ int transport_get_lun_for_tmr( se_cmd->se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION; return -1; } - se_tmr->tmr_dev = dev; spin_lock(&dev->se_tmr_lock); list_add_tail(&se_tmr->tmr_list, &dev->dev_tmr_list); @@ -1431,7 +1430,7 @@ struct se_lun_acl *core_dev_init_initiator_node_lun_acl( struct se_lun_acl *lacl; struct se_node_acl *nacl; - if (strlen(initiatorname) >= TRANSPORT_IQN_LEN) { + if (strlen(initiatorname) > TRANSPORT_IQN_LEN) { printk(KERN_ERR "%s InitiatorName exceeds maximum size.\n", TPG_TFO(tpg)->get_fabric_name()); *ret = -EOVERFLOW; diff --git a/trunk/drivers/target/target_core_pr.c b/trunk/drivers/target/target_core_pr.c index b662db3a320b..a79f518ca6e2 100644 --- a/trunk/drivers/target/target_core_pr.c +++ b/trunk/drivers/target/target_core_pr.c @@ -1916,7 +1916,7 @@ static int __core_scsi3_update_aptpl_buf( pr_reg->pr_res_mapped_lun); } - if ((len + strlen(tmp) >= pr_aptpl_buf_len)) { + if ((len + strlen(tmp) > pr_aptpl_buf_len)) { printk(KERN_ERR "Unable to update renaming" " APTPL metadata\n"); spin_unlock(&T10_RES(su_dev)->registration_lock); @@ -1934,7 +1934,7 @@ static int __core_scsi3_update_aptpl_buf( TPG_TFO(tpg)->tpg_get_tag(tpg), lun->lun_sep->sep_rtpi, lun->unpacked_lun, reg_count); - if ((len + strlen(tmp) >= pr_aptpl_buf_len)) { + if ((len + strlen(tmp) > pr_aptpl_buf_len)) { printk(KERN_ERR "Unable to update renaming" " APTPL metadata\n"); spin_unlock(&T10_RES(su_dev)->registration_lock); @@ -1986,7 +1986,7 @@ static int __core_scsi3_write_aptpl_to_file( memset(iov, 0, sizeof(struct iovec)); memset(path, 0, 512); - if (strlen(&wwn->unit_serial[0]) >= 512) { + if (strlen(&wwn->unit_serial[0]) > 512) { printk(KERN_ERR "WWN value for struct se_device does not fit" " into path buffer\n"); return -1; diff --git a/trunk/drivers/target/target_core_tmr.c b/trunk/drivers/target/target_core_tmr.c index 179063d81cdd..59b8b9c5ad72 100644 --- a/trunk/drivers/target/target_core_tmr.c +++ b/trunk/drivers/target/target_core_tmr.c @@ -75,16 +75,10 @@ void core_tmr_release_req( { struct se_device *dev = tmr->tmr_dev; - if (!dev) { - kmem_cache_free(se_tmr_req_cache, tmr); - return; - } - spin_lock(&dev->se_tmr_lock); list_del(&tmr->tmr_list); - spin_unlock(&dev->se_tmr_lock); - kmem_cache_free(se_tmr_req_cache, tmr); + spin_unlock(&dev->se_tmr_lock); } static void core_tmr_handle_tas_abort( diff --git a/trunk/drivers/target/target_core_transport.c b/trunk/drivers/target/target_core_transport.c index 4b9b7169bdd9..4dafeb8b5638 100644 --- a/trunk/drivers/target/target_core_transport.c +++ b/trunk/drivers/target/target_core_transport.c @@ -536,13 +536,13 @@ EXPORT_SYMBOL(transport_register_session); void transport_deregister_session_configfs(struct se_session *se_sess) { struct se_node_acl *se_nacl; - unsigned long flags; + /* * Used by struct se_node_acl's under ConfigFS to locate active struct se_session */ se_nacl = se_sess->se_node_acl; if ((se_nacl)) { - spin_lock_irqsave(&se_nacl->nacl_sess_lock, flags); + spin_lock_irq(&se_nacl->nacl_sess_lock); list_del(&se_sess->sess_acl_list); /* * If the session list is empty, then clear the pointer. @@ -556,7 +556,7 @@ void transport_deregister_session_configfs(struct se_session *se_sess) se_nacl->acl_sess_list.prev, struct se_session, sess_acl_list); } - spin_unlock_irqrestore(&se_nacl->nacl_sess_lock, flags); + spin_unlock_irq(&se_nacl->nacl_sess_lock); } } EXPORT_SYMBOL(transport_deregister_session_configfs); diff --git a/trunk/drivers/target/tcm_fc/tcm_fc.h b/trunk/drivers/target/tcm_fc/tcm_fc.h index 7b82f1b7fef8..defff32b7880 100644 --- a/trunk/drivers/target/tcm_fc/tcm_fc.h +++ b/trunk/drivers/target/tcm_fc/tcm_fc.h @@ -144,7 +144,7 @@ enum ft_cmd_state { */ struct ft_cmd { enum ft_cmd_state state; - u32 lun; /* LUN from request */ + u16 lun; /* LUN from request */ struct ft_sess *sess; /* session held for cmd */ struct fc_seq *seq; /* sequence in exchange mgr */ struct se_cmd se_cmd; /* Local TCM I/O descriptor */ diff --git a/trunk/drivers/target/tcm_fc/tfc_cmd.c b/trunk/drivers/target/tcm_fc/tfc_cmd.c index b2a106729d49..c056a1132ae1 100644 --- a/trunk/drivers/target/tcm_fc/tfc_cmd.c +++ b/trunk/drivers/target/tcm_fc/tfc_cmd.c @@ -94,6 +94,29 @@ void ft_dump_cmd(struct ft_cmd *cmd, const char *caller) 16, 4, cmd->cdb, MAX_COMMAND_SIZE, 0); } +/* + * Get LUN from CDB. + */ +static int ft_get_lun_for_cmd(struct ft_cmd *cmd, u8 *lunp) +{ + u64 lun; + + lun = lunp[1]; + switch (lunp[0] >> 6) { + case 0: + break; + case 1: + lun |= (lunp[0] & 0x3f) << 8; + break; + default: + return -1; + } + if (lun >= TRANSPORT_MAX_LUNS_PER_TPG) + return -1; + cmd->lun = lun; + return transport_get_lun_for_cmd(&cmd->se_cmd, NULL, lun); +} + static void ft_queue_cmd(struct ft_sess *sess, struct ft_cmd *cmd) { struct se_queue_obj *qobj; @@ -395,7 +418,6 @@ static void ft_send_tm(struct ft_cmd *cmd) { struct se_tmr_req *tmr; struct fcp_cmnd *fcp; - struct ft_sess *sess; u8 tm_func; fcp = fc_frame_payload_get(cmd->req_frame, sizeof(*fcp)); @@ -403,6 +425,13 @@ static void ft_send_tm(struct ft_cmd *cmd) switch (fcp->fc_tm_flags) { case FCP_TMF_LUN_RESET: tm_func = TMR_LUN_RESET; + if (ft_get_lun_for_cmd(cmd, fcp->fc_lun) < 0) { + ft_dump_cmd(cmd, __func__); + transport_send_check_condition_and_sense(&cmd->se_cmd, + cmd->se_cmd.scsi_sense_reason, 0); + ft_sess_put(cmd->sess); + return; + } break; case FCP_TMF_TGT_RESET: tm_func = TMR_TARGET_WARM_RESET; @@ -434,36 +463,6 @@ static void ft_send_tm(struct ft_cmd *cmd) return; } cmd->se_cmd.se_tmr_req = tmr; - - switch (fcp->fc_tm_flags) { - case FCP_TMF_LUN_RESET: - cmd->lun = scsilun_to_int((struct scsi_lun *)fcp->fc_lun); - if (transport_get_lun_for_tmr(&cmd->se_cmd, cmd->lun) < 0) { - /* - * Make sure to clean up newly allocated TMR request - * since "unable to handle TMR request because failed - * to get to LUN" - */ - FT_TM_DBG("Failed to get LUN for TMR func %d, " - "se_cmd %p, unpacked_lun %d\n", - tm_func, &cmd->se_cmd, cmd->lun); - ft_dump_cmd(cmd, __func__); - sess = cmd->sess; - transport_send_check_condition_and_sense(&cmd->se_cmd, - cmd->se_cmd.scsi_sense_reason, 0); - transport_generic_free_cmd(&cmd->se_cmd, 0, 1, 0); - ft_sess_put(sess); - return; - } - break; - case FCP_TMF_TGT_RESET: - case FCP_TMF_CLR_TASK_SET: - case FCP_TMF_ABT_TASK_SET: - case FCP_TMF_CLR_ACA: - break; - default: - return; - } transport_generic_handle_tmr(&cmd->se_cmd); } @@ -636,8 +635,7 @@ static void ft_send_cmd(struct ft_cmd *cmd) fc_seq_exch(cmd->seq)->lp->tt.seq_set_resp(cmd->seq, ft_recv_seq, cmd); - cmd->lun = scsilun_to_int((struct scsi_lun *)fcp->fc_lun); - ret = transport_get_lun_for_cmd(&cmd->se_cmd, NULL, cmd->lun); + ret = ft_get_lun_for_cmd(cmd, fcp->fc_lun); if (ret < 0) { ft_dump_cmd(cmd, __func__); transport_send_check_condition_and_sense(&cmd->se_cmd, diff --git a/trunk/drivers/target/tcm_fc/tfc_io.c b/trunk/drivers/target/tcm_fc/tfc_io.c index 8c4a24077d9d..4c3c0efbe13f 100644 --- a/trunk/drivers/target/tcm_fc/tfc_io.c +++ b/trunk/drivers/target/tcm_fc/tfc_io.c @@ -203,7 +203,7 @@ int ft_queue_data_in(struct se_cmd *se_cmd) /* XXX For now, initiator will retry */ if (printk_ratelimit()) printk(KERN_ERR "%s: Failed to send frame %p, " - "xid <0x%x>, remaining %zu, " + "xid <0x%x>, remaining <0x%x>, " "lso_max <0x%x>\n", __func__, fp, ep->xid, remaining, lport->lso_max); diff --git a/trunk/drivers/target/tcm_fc/tfc_sess.c b/trunk/drivers/target/tcm_fc/tfc_sess.c index 7491e21cc6ae..a3bd57f2ea32 100644 --- a/trunk/drivers/target/tcm_fc/tfc_sess.c +++ b/trunk/drivers/target/tcm_fc/tfc_sess.c @@ -229,7 +229,7 @@ static struct ft_sess *ft_sess_create(struct ft_tport *tport, u32 port_id, return NULL; sess->se_sess = transport_init_session(); - if (IS_ERR(sess->se_sess)) { + if (!sess->se_sess) { kfree(sess); return NULL; } @@ -332,7 +332,7 @@ void ft_sess_close(struct se_session *se_sess) lport = sess->tport->lport; port_id = sess->port_id; if (port_id == -1) { - mutex_unlock(&ft_lport_lock); + mutex_lock(&ft_lport_lock); return; } FT_SESS_DBG("port_id %x\n", port_id); diff --git a/trunk/drivers/tty/n_gsm.c b/trunk/drivers/tty/n_gsm.c index 19b4ae052af8..09e8c7d53af3 100644 --- a/trunk/drivers/tty/n_gsm.c +++ b/trunk/drivers/tty/n_gsm.c @@ -875,8 +875,7 @@ static int gsm_dlci_data_output_framed(struct gsm_mux *gsm, *dp++ = last << 7 | first << 6 | 1; /* EA */ len--; } - memcpy(dp, dlci->skb->data, len); - skb_pull(dlci->skb, len); + memcpy(dp, skb_pull(dlci->skb, len), len); __gsm_data_queue(dlci, msg); if (last) dlci->skb = NULL; @@ -985,22 +984,10 @@ static void gsm_control_reply(struct gsm_mux *gsm, int cmd, u8 *data, */ static void gsm_process_modem(struct tty_struct *tty, struct gsm_dlci *dlci, - u32 modem, int clen) + u32 modem) { int mlines = 0; - u8 brk = 0; - - /* The modem status command can either contain one octet (v.24 signals) - or two octets (v.24 signals + break signals). The length field will - either be 2 or 3 respectively. This is specified in section - 5.4.6.3.7 of the 27.010 mux spec. */ - - if (clen == 2) - modem = modem & 0x7f; - else { - brk = modem & 0x7f; - modem = (modem >> 7) & 0x7f; - }; + u8 brk = modem >> 6; /* Flow control/ready to communicate */ if (modem & MDM_FC) { @@ -1074,7 +1061,7 @@ static void gsm_control_modem(struct gsm_mux *gsm, u8 *data, int clen) return; } tty = tty_port_tty_get(&dlci->port); - gsm_process_modem(tty, dlci, modem, clen); + gsm_process_modem(tty, dlci, modem); if (tty) { tty_wakeup(tty); tty_kref_put(tty); @@ -1495,13 +1482,12 @@ static void gsm_dlci_begin_close(struct gsm_dlci *dlci) * open we shovel the bits down it, if not we drop them. */ -static void gsm_dlci_data(struct gsm_dlci *dlci, u8 *data, int clen) +static void gsm_dlci_data(struct gsm_dlci *dlci, u8 *data, int len) { /* krefs .. */ struct tty_port *port = &dlci->port; struct tty_struct *tty = tty_port_tty_get(port); unsigned int modem = 0; - int len = clen; if (debug & 16) pr_debug("%d bytes for tty %p\n", len, tty); @@ -1521,7 +1507,7 @@ static void gsm_dlci_data(struct gsm_dlci *dlci, u8 *data, int clen) if (len == 0) return; } - gsm_process_modem(tty, dlci, modem, clen); + gsm_process_modem(tty, dlci, modem); /* Line state will go via DLCI 0 controls only */ case 1: default: diff --git a/trunk/drivers/tty/n_tty.c b/trunk/drivers/tty/n_tty.c index c3954fbf6ac4..0ad32888091c 100644 --- a/trunk/drivers/tty/n_tty.c +++ b/trunk/drivers/tty/n_tty.c @@ -1815,7 +1815,6 @@ static ssize_t n_tty_read(struct tty_struct *tty, struct file *file, /* FIXME: does n_tty_set_room need locking ? */ n_tty_set_room(tty); timeout = schedule_timeout(timeout); - BUG_ON(!tty->read_buf); continue; } __set_current_state(TASK_RUNNING); diff --git a/trunk/drivers/tty/serial/8250.c b/trunk/drivers/tty/serial/8250.c index b4129f53fb1b..b40f7b90c81d 100644 --- a/trunk/drivers/tty/serial/8250.c +++ b/trunk/drivers/tty/serial/8250.c @@ -3318,7 +3318,6 @@ void serial8250_unregister_port(int line) uart->port.flags &= ~UPF_BOOT_AUTOCONF; uart->port.type = PORT_UNKNOWN; uart->port.dev = &serial8250_isa_devs->dev; - uart->capabilities = uart_config[uart->port.type].flags; uart_add_one_port(&serial8250_reg, &uart->port); } else { uart->port.dev = NULL; diff --git a/trunk/drivers/tty/serial/8250_pci.c b/trunk/drivers/tty/serial/8250_pci.c index f41b4259ecdd..4b4968a294b2 100644 --- a/trunk/drivers/tty/serial/8250_pci.c +++ b/trunk/drivers/tty/serial/8250_pci.c @@ -973,7 +973,7 @@ ce4100_serial_setup(struct serial_private *priv, static int pci_omegapci_setup(struct serial_private *priv, - const struct pciserial_board *board, + struct pciserial_board *board, struct uart_port *port, int idx) { return setup_port(priv, port, 2, idx * 8, 0); @@ -994,15 +994,6 @@ static int skip_tx_en_setup(struct serial_private *priv, return pci_default_setup(priv, board, port, idx); } -static int pci_eg20t_init(struct pci_dev *dev) -{ -#if defined(CONFIG_SERIAL_PCH_UART) || defined(CONFIG_SERIAL_PCH_UART_MODULE) - return -ENODEV; -#else - return 0; -#endif -} - /* This should be in linux/pci_ids.h */ #define PCI_VENDOR_ID_SBSMODULARIO 0x124B #define PCI_SUBVENDOR_ID_SBSMODULARIO 0x124B @@ -1455,56 +1446,6 @@ static struct pci_serial_quirk pci_serial_quirks[] __refdata = { .init = pci_oxsemi_tornado_init, .setup = pci_default_setup, }, - { - .vendor = PCI_VENDOR_ID_INTEL, - .device = 0x8811, - .init = pci_eg20t_init, - }, - { - .vendor = PCI_VENDOR_ID_INTEL, - .device = 0x8812, - .init = pci_eg20t_init, - }, - { - .vendor = PCI_VENDOR_ID_INTEL, - .device = 0x8813, - .init = pci_eg20t_init, - }, - { - .vendor = PCI_VENDOR_ID_INTEL, - .device = 0x8814, - .init = pci_eg20t_init, - }, - { - .vendor = 0x10DB, - .device = 0x8027, - .init = pci_eg20t_init, - }, - { - .vendor = 0x10DB, - .device = 0x8028, - .init = pci_eg20t_init, - }, - { - .vendor = 0x10DB, - .device = 0x8029, - .init = pci_eg20t_init, - }, - { - .vendor = 0x10DB, - .device = 0x800C, - .init = pci_eg20t_init, - }, - { - .vendor = 0x10DB, - .device = 0x800D, - .init = pci_eg20t_init, - }, - { - .vendor = 0x10DB, - .device = 0x800D, - .init = pci_eg20t_init, - }, /* * Cronyx Omega PCI (PLX-chip based) */ diff --git a/trunk/drivers/tty/serial/amba-pl011.c b/trunk/drivers/tty/serial/amba-pl011.c index f5f6831b0a64..8dc0541feecc 100644 --- a/trunk/drivers/tty/serial/amba-pl011.c +++ b/trunk/drivers/tty/serial/amba-pl011.c @@ -50,7 +50,6 @@ #include #include #include -#include #include #include @@ -66,30 +65,6 @@ #define UART_DR_ERROR (UART011_DR_OE|UART011_DR_BE|UART011_DR_PE|UART011_DR_FE) #define UART_DUMMY_DR_RX (1 << 16) - -#define UART_WA_SAVE_NR 14 - -static void pl011_lockup_wa(unsigned long data); -static const u32 uart_wa_reg[UART_WA_SAVE_NR] = { - ST_UART011_DMAWM, - ST_UART011_TIMEOUT, - ST_UART011_LCRH_RX, - UART011_IBRD, - UART011_FBRD, - ST_UART011_LCRH_TX, - UART011_IFLS, - ST_UART011_XFCR, - ST_UART011_XON1, - ST_UART011_XON2, - ST_UART011_XOFF1, - ST_UART011_XOFF2, - UART011_CR, - UART011_IMSC -}; - -static u32 uart_wa_regdata[UART_WA_SAVE_NR]; -static DECLARE_TASKLET(pl011_lockup_tlet, pl011_lockup_wa, 0); - /* There is by now at least one vendor with differing details, so handle it */ struct vendor_data { unsigned int ifls; @@ -97,7 +72,6 @@ struct vendor_data { unsigned int lcrh_tx; unsigned int lcrh_rx; bool oversampling; - bool interrupt_may_hang; /* vendor-specific */ bool dma_threshold; }; @@ -116,12 +90,9 @@ static struct vendor_data vendor_st = { .lcrh_tx = ST_UART011_LCRH_TX, .lcrh_rx = ST_UART011_LCRH_RX, .oversampling = true, - .interrupt_may_hang = true, .dma_threshold = true, }; -static struct uart_amba_port *amba_ports[UART_NR]; - /* Deals with DMA transactions */ struct pl011_sgbuf { @@ -161,7 +132,6 @@ struct uart_amba_port { unsigned int lcrh_rx; /* vendor-specific */ bool autorts; char type[12]; - bool interrupt_may_hang; /* vendor-specific */ #ifdef CONFIG_DMA_ENGINE /* DMA stuff */ bool using_tx_dma; @@ -1038,68 +1008,6 @@ static inline bool pl011_dma_rx_running(struct uart_amba_port *uap) #endif -/* - * pl011_lockup_wa - * This workaround aims to break the deadlock situation - * when after long transfer over uart in hardware flow - * control, uart interrupt registers cannot be cleared. - * Hence uart transfer gets blocked. - * - * It is seen that during such deadlock condition ICR - * don't get cleared even on multiple write. This leads - * pass_counter to decrease and finally reach zero. This - * can be taken as trigger point to run this UART_BT_WA. - * - */ -static void pl011_lockup_wa(unsigned long data) -{ - struct uart_amba_port *uap = amba_ports[0]; - void __iomem *base = uap->port.membase; - struct circ_buf *xmit = &uap->port.state->xmit; - struct tty_struct *tty = uap->port.state->port.tty; - int buf_empty_retries = 200; - int loop; - - /* Stop HCI layer from submitting data for tx */ - tty->hw_stopped = 1; - while (!uart_circ_empty(xmit)) { - if (buf_empty_retries-- == 0) - break; - udelay(100); - } - - /* Backup registers */ - for (loop = 0; loop < UART_WA_SAVE_NR; loop++) - uart_wa_regdata[loop] = readl(base + uart_wa_reg[loop]); - - /* Disable UART so that FIFO data is flushed out */ - writew(0x00, uap->port.membase + UART011_CR); - - /* Soft reset UART module */ - if (uap->port.dev->platform_data) { - struct amba_pl011_data *plat; - - plat = uap->port.dev->platform_data; - if (plat->reset) - plat->reset(); - } - - /* Restore registers */ - for (loop = 0; loop < UART_WA_SAVE_NR; loop++) - writew(uart_wa_regdata[loop] , - uap->port.membase + uart_wa_reg[loop]); - - /* Initialise the old status of the modem signals */ - uap->old_status = readw(uap->port.membase + UART01x_FR) & - UART01x_FR_MODEM_ANY; - - if (readl(base + UART011_MIS) & 0x2) - printk(KERN_EMERG "UART_BT_WA: ***FAILED***\n"); - - /* Start Tx/Rx */ - tty->hw_stopped = 0; -} - static void pl011_stop_tx(struct uart_port *port) { struct uart_amba_port *uap = (struct uart_amba_port *)port; @@ -1250,11 +1158,8 @@ static irqreturn_t pl011_int(int irq, void *dev_id) if (status & UART011_TXIS) pl011_tx_chars(uap); - if (pass_counter-- == 0) { - if (uap->interrupt_may_hang) - tasklet_schedule(&pl011_lockup_tlet); + if (pass_counter-- == 0) break; - } status = readw(uap->port.membase + UART011_MIS); } while (status != 0); @@ -1434,14 +1339,6 @@ static int pl011_startup(struct uart_port *port) writew(uap->im, uap->port.membase + UART011_IMSC); spin_unlock_irq(&uap->port.lock); - if (uap->port.dev->platform_data) { - struct amba_pl011_data *plat; - - plat = uap->port.dev->platform_data; - if (plat->init) - plat->init(); - } - return 0; clk_dis: @@ -1497,15 +1394,6 @@ static void pl011_shutdown(struct uart_port *port) * Shut down the clock producer */ clk_disable(uap->clk); - - if (uap->port.dev->platform_data) { - struct amba_pl011_data *plat; - - plat = uap->port.dev->platform_data; - if (plat->exit) - plat->exit(); - } - } static void @@ -1812,14 +1700,6 @@ static int __init pl011_console_setup(struct console *co, char *options) if (!uap) return -ENODEV; - if (uap->port.dev->platform_data) { - struct amba_pl011_data *plat; - - plat = uap->port.dev->platform_data; - if (plat->init) - plat->init(); - } - uap->port.uartclk = clk_get_rate(uap->clk); if (options) @@ -1894,7 +1774,6 @@ static int pl011_probe(struct amba_device *dev, const struct amba_id *id) uap->lcrh_rx = vendor->lcrh_rx; uap->lcrh_tx = vendor->lcrh_tx; uap->fifosize = vendor->fifosize; - uap->interrupt_may_hang = vendor->interrupt_may_hang; uap->port.dev = &dev->dev; uap->port.mapbase = dev->res.start; uap->port.membase = base; diff --git a/trunk/drivers/tty/serial/atmel_serial.c b/trunk/drivers/tty/serial/atmel_serial.c index af9b7814965a..6d5d6e679fc7 100644 --- a/trunk/drivers/tty/serial/atmel_serial.c +++ b/trunk/drivers/tty/serial/atmel_serial.c @@ -1709,13 +1709,12 @@ static int atmel_serial_resume(struct platform_device *pdev) static int __devinit atmel_serial_probe(struct platform_device *pdev) { struct atmel_uart_port *port; - struct atmel_uart_data *pdata = pdev->dev.platform_data; void *data; int ret; BUILD_BUG_ON(ATMEL_SERIAL_RINGSIZE & (ATMEL_SERIAL_RINGSIZE - 1)); - port = &atmel_ports[pdata->num]; + port = &atmel_ports[pdev->id]; port->backup_imr = 0; atmel_init_port(port, pdev); diff --git a/trunk/drivers/tty/serial/bcm63xx_uart.c b/trunk/drivers/tty/serial/bcm63xx_uart.c index c0b68b9cad91..a1a0e55d0807 100644 --- a/trunk/drivers/tty/serial/bcm63xx_uart.c +++ b/trunk/drivers/tty/serial/bcm63xx_uart.c @@ -250,20 +250,6 @@ static void bcm_uart_do_rx(struct uart_port *port) /* get overrun/fifo empty information from ier * register */ iestat = bcm_uart_readl(port, UART_IR_REG); - - if (unlikely(iestat & UART_IR_STAT(UART_IR_RXOVER))) { - unsigned int val; - - /* fifo reset is required to clear - * interrupt */ - val = bcm_uart_readl(port, UART_CTL_REG); - val |= UART_CTL_RSTRXFIFO_MASK; - bcm_uart_writel(port, val, UART_CTL_REG); - - port->icount.overrun++; - tty_insert_flip_char(tty, 0, TTY_OVERRUN); - } - if (!(iestat & UART_IR_STAT(UART_IR_RXNOTEMPTY))) break; @@ -298,6 +284,10 @@ static void bcm_uart_do_rx(struct uart_port *port) if (uart_handle_sysrq_char(port, c)) continue; + if (unlikely(iestat & UART_IR_STAT(UART_IR_RXOVER))) { + port->icount.overrun++; + tty_insert_flip_char(tty, 0, TTY_OVERRUN); + } if ((cstat & port->ignore_status_mask) == 0) tty_insert_flip_char(tty, c, flag); diff --git a/trunk/drivers/tty/serial/jsm/jsm_driver.c b/trunk/drivers/tty/serial/jsm/jsm_driver.c index 96da17868cf3..18f548449c63 100644 --- a/trunk/drivers/tty/serial/jsm/jsm_driver.c +++ b/trunk/drivers/tty/serial/jsm/jsm_driver.c @@ -125,7 +125,7 @@ static int __devinit jsm_probe_one(struct pci_dev *pdev, const struct pci_device brd->bd_uart_offset = 0x200; brd->bd_dividend = 921600; - brd->re_map_membase = ioremap(brd->membase, pci_resource_len(pdev, 0)); + brd->re_map_membase = ioremap(brd->membase, 0x1000); if (!brd->re_map_membase) { dev_err(&pdev->dev, "card has no PCI Memory resources, " diff --git a/trunk/drivers/tty/serial/mrst_max3110.c b/trunk/drivers/tty/serial/mrst_max3110.c index a764bf99743b..1bd28450ca40 100644 --- a/trunk/drivers/tty/serial/mrst_max3110.c +++ b/trunk/drivers/tty/serial/mrst_max3110.c @@ -421,6 +421,7 @@ static int max3110_main_thread(void *_max) int ret = 0; struct circ_buf *xmit = &max->con_xmit; + init_waitqueue_head(wq); pr_info(PR_FMT "start main thread\n"); do { @@ -822,7 +823,7 @@ static int __devinit serial_m3110_probe(struct spi_device *spi) res = RC_TAG; ret = max3110_write_then_read(max, (u8 *)&res, (u8 *)&res, 2, 0); if (ret < 0 || res == 0 || res == 0xffff) { - dev_dbg(&spi->dev, "MAX3111 deemed not present (conf reg %04x)", + printk(KERN_ERR "MAX3111 deemed not present (conf reg %04x)", res); ret = -ENODEV; goto err_get_page; @@ -837,8 +838,6 @@ static int __devinit serial_m3110_probe(struct spi_device *spi) max->con_xmit.head = 0; max->con_xmit.tail = 0; - init_waitqueue_head(&max->wq); - max->main_thread = kthread_run(max3110_main_thread, max, "max3110_main"); if (IS_ERR(max->main_thread)) { diff --git a/trunk/drivers/tty/serial/s5pv210.c b/trunk/drivers/tty/serial/s5pv210.c index dd194dc80ee9..fb2619f93d84 100644 --- a/trunk/drivers/tty/serial/s5pv210.c +++ b/trunk/drivers/tty/serial/s5pv210.c @@ -30,7 +30,7 @@ static int s5pv210_serial_setsource(struct uart_port *port, struct s3c2410_uartcfg *cfg = port->dev->platform_data; unsigned long ucon = rd_regl(port, S3C2410_UCON); - if (cfg->flags & NO_NEED_CHECK_CLKSRC) + if ((cfg->clocks_size) == 1) return 0; if (strcmp(clk->name, "pclk") == 0) @@ -55,7 +55,7 @@ static int s5pv210_serial_getsource(struct uart_port *port, clk->divisor = 1; - if (cfg->flags & NO_NEED_CHECK_CLKSRC) + if ((cfg->clocks_size) == 1) return 0; switch (ucon & S5PV210_UCON_CLKMASK) { diff --git a/trunk/drivers/tty/tty_ldisc.c b/trunk/drivers/tty/tty_ldisc.c index ef925d581713..5d01d32e2cf0 100644 --- a/trunk/drivers/tty/tty_ldisc.c +++ b/trunk/drivers/tty/tty_ldisc.c @@ -555,7 +555,7 @@ static void tty_ldisc_flush_works(struct tty_struct *tty) static int tty_ldisc_wait_idle(struct tty_struct *tty) { int ret; - ret = wait_event_timeout(tty_ldisc_idle, + ret = wait_event_interruptible_timeout(tty_ldisc_idle, atomic_read(&tty->ldisc->users) == 1, 5 * HZ); if (ret < 0) return ret; @@ -763,8 +763,6 @@ static int tty_ldisc_reinit(struct tty_struct *tty, int ldisc) if (IS_ERR(ld)) return -1; - WARN_ON_ONCE(tty_ldisc_wait_idle(tty)); - tty_ldisc_close(tty, tty->ldisc); tty_ldisc_put(tty->ldisc); tty->ldisc = NULL; diff --git a/trunk/drivers/usb/core/driver.c b/trunk/drivers/usb/core/driver.c index 34e3da5aa72a..e35a17687c05 100644 --- a/trunk/drivers/usb/core/driver.c +++ b/trunk/drivers/usb/core/driver.c @@ -375,7 +375,7 @@ static int usb_unbind_interface(struct device *dev) * Just re-enable it without affecting the endpoint toggles. */ usb_enable_interface(udev, intf, false); - } else if (!error && !intf->dev.power.is_prepared) { + } else if (!error && !intf->dev.power.in_suspend) { r = usb_set_interface(udev, intf->altsetting[0]. desc.bInterfaceNumber, 0); if (r < 0) @@ -960,7 +960,7 @@ void usb_rebind_intf(struct usb_interface *intf) } /* Try to rebind the interface */ - if (!intf->dev.power.is_prepared) { + if (!intf->dev.power.in_suspend) { intf->needs_binding = 0; rc = device_attach(&intf->dev); if (rc < 0) @@ -1107,7 +1107,7 @@ static int usb_resume_interface(struct usb_device *udev, if (intf->condition == USB_INTERFACE_UNBOUND) { /* Carry out a deferred switch to altsetting 0 */ - if (intf->needs_altsetting0 && !intf->dev.power.is_prepared) { + if (intf->needs_altsetting0 && !intf->dev.power.in_suspend) { usb_set_interface(udev, intf->altsetting[0]. desc.bInterfaceNumber, 0); intf->needs_altsetting0 = 0; @@ -1187,22 +1187,13 @@ static int usb_suspend_both(struct usb_device *udev, pm_message_t msg) for (i = n - 1; i >= 0; --i) { intf = udev->actconfig->interface[i]; status = usb_suspend_interface(udev, intf, msg); - - /* Ignore errors during system sleep transitions */ - if (!(msg.event & PM_EVENT_AUTO)) - status = 0; if (status != 0) break; } } - if (status == 0) { + if (status == 0) status = usb_suspend_device(udev, msg); - /* Again, ignore errors during system sleep transitions */ - if (!(msg.event & PM_EVENT_AUTO)) - status = 0; - } - /* If the suspend failed, resume interfaces that did get suspended */ if (status != 0) { msg.event ^= (PM_EVENT_SUSPEND | PM_EVENT_RESUME); diff --git a/trunk/drivers/usb/core/hub.c b/trunk/drivers/usb/core/hub.c index a428aa080a36..90ae1753dda1 100644 --- a/trunk/drivers/usb/core/hub.c +++ b/trunk/drivers/usb/core/hub.c @@ -1634,7 +1634,6 @@ void usb_disconnect(struct usb_device **pdev) { struct usb_device *udev = *pdev; int i; - struct usb_hcd *hcd = bus_to_hcd(udev->bus); if (!udev) { pr_debug ("%s nodev\n", __func__); @@ -1662,9 +1661,7 @@ void usb_disconnect(struct usb_device **pdev) * so that the hardware is now fully quiesced. */ dev_dbg (&udev->dev, "unregistering device\n"); - mutex_lock(hcd->bandwidth_mutex); usb_disable_device(udev, 0); - mutex_unlock(hcd->bandwidth_mutex); usb_hcd_synchronize_unlinks(udev); usb_remove_ep_devs(&udev->ep0); @@ -2365,10 +2362,6 @@ int usb_port_suspend(struct usb_device *udev, pm_message_t msg) USB_DEVICE_REMOTE_WAKEUP, 0, NULL, 0, USB_CTRL_SET_TIMEOUT); - - /* System sleep transitions should never fail */ - if (!(msg.event & PM_EVENT_AUTO)) - status = 0; } else { /* device has up to 10 msec to fully suspend */ dev_dbg(&udev->dev, "usb %ssuspend\n", @@ -2618,15 +2611,16 @@ static int hub_suspend(struct usb_interface *intf, pm_message_t msg) struct usb_device *hdev = hub->hdev; unsigned port1; - /* Warn if children aren't already suspended */ + /* fail if children aren't already suspended */ for (port1 = 1; port1 <= hdev->maxchild; port1++) { struct usb_device *udev; udev = hdev->children [port1-1]; if (udev && udev->can_submit) { - dev_warn(&intf->dev, "port %d nyet suspended\n", port1); - if (msg.event & PM_EVENT_AUTO) - return -EBUSY; + if (!(msg.event & PM_EVENT_AUTO)) + dev_dbg(&intf->dev, "port %d nyet suspended\n", + port1); + return -EBUSY; } } diff --git a/trunk/drivers/usb/core/message.c b/trunk/drivers/usb/core/message.c index 0b5ec234c787..5701e857392b 100644 --- a/trunk/drivers/usb/core/message.c +++ b/trunk/drivers/usb/core/message.c @@ -1135,26 +1135,15 @@ void usb_disable_interface(struct usb_device *dev, struct usb_interface *intf, * Deallocates hcd/hardware state for the endpoints (nuking all or most * pending urbs) and usbcore state for the interfaces, so that usbcore * must usb_set_configuration() before any interfaces could be used. - * - * Must be called with hcd->bandwidth_mutex held. */ void usb_disable_device(struct usb_device *dev, int skip_ep0) { int i; - struct usb_hcd *hcd = bus_to_hcd(dev->bus); /* getting rid of interfaces will disconnect * any drivers bound to them (a key side effect) */ if (dev->actconfig) { - /* - * FIXME: In order to avoid self-deadlock involving the - * bandwidth_mutex, we have to mark all the interfaces - * before unregistering any of them. - */ - for (i = 0; i < dev->actconfig->desc.bNumInterfaces; i++) - dev->actconfig->interface[i]->unregistering = 1; - for (i = 0; i < dev->actconfig->desc.bNumInterfaces; i++) { struct usb_interface *interface; @@ -1164,6 +1153,7 @@ void usb_disable_device(struct usb_device *dev, int skip_ep0) continue; dev_dbg(&dev->dev, "unregistering interface %s\n", dev_name(&interface->dev)); + interface->unregistering = 1; remove_intf_ep_devs(interface); device_del(&interface->dev); } @@ -1182,16 +1172,6 @@ void usb_disable_device(struct usb_device *dev, int skip_ep0) dev_dbg(&dev->dev, "%s nuking %s URBs\n", __func__, skip_ep0 ? "non-ep0" : "all"); - if (hcd->driver->check_bandwidth) { - /* First pass: Cancel URBs, leave endpoint pointers intact. */ - for (i = skip_ep0; i < 16; ++i) { - usb_disable_endpoint(dev, i, false); - usb_disable_endpoint(dev, i + USB_DIR_IN, false); - } - /* Remove endpoints from the host controller internal state */ - usb_hcd_alloc_bandwidth(dev, NULL, NULL, NULL); - /* Second pass: remove endpoint pointers */ - } for (i = skip_ep0; i < 16; ++i) { usb_disable_endpoint(dev, i, true); usb_disable_endpoint(dev, i + USB_DIR_IN, true); @@ -1293,8 +1273,6 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate) interface); return -EINVAL; } - if (iface->unregistering) - return -ENODEV; alt = usb_altnum_to_altsetting(iface, alternate); if (!alt) { @@ -1749,7 +1727,6 @@ int usb_set_configuration(struct usb_device *dev, int configuration) /* if it's already configured, clear out old state first. * getting rid of old interfaces means unbinding their drivers. */ - mutex_lock(hcd->bandwidth_mutex); if (dev->state != USB_STATE_ADDRESS) usb_disable_device(dev, 1); /* Skip ep0 */ @@ -1762,6 +1739,7 @@ int usb_set_configuration(struct usb_device *dev, int configuration) * host controller will not allow submissions to dropped endpoints. If * this call fails, the device state is unchanged. */ + mutex_lock(hcd->bandwidth_mutex); ret = usb_hcd_alloc_bandwidth(dev, cp, NULL, NULL); if (ret < 0) { mutex_unlock(hcd->bandwidth_mutex); diff --git a/trunk/drivers/usb/gadget/fsl_udc_core.c b/trunk/drivers/usb/gadget/fsl_udc_core.c index 4e4833168087..2cd9a60c7f3a 100644 --- a/trunk/drivers/usb/gadget/fsl_udc_core.c +++ b/trunk/drivers/usb/gadget/fsl_udc_core.c @@ -46,6 +46,7 @@ #include #include #include +#include #include "fsl_usb2_udc.h" @@ -117,17 +118,6 @@ static void (*_fsl_writel)(u32 v, unsigned __iomem *p); #define fsl_readl(p) (*_fsl_readl)((p)) #define fsl_writel(v, p) (*_fsl_writel)((v), (p)) -static inline void fsl_set_accessors(struct fsl_usb2_platform_data *pdata) -{ - if (pdata->big_endian_mmio) { - _fsl_readl = _fsl_readl_be; - _fsl_writel = _fsl_writel_be; - } else { - _fsl_readl = _fsl_readl_le; - _fsl_writel = _fsl_writel_le; - } -} - static inline u32 cpu_to_hc32(const u32 x) { return udc_controller->pdata->big_endian_desc @@ -142,8 +132,6 @@ static inline u32 hc32_to_cpu(const u32 x) : le32_to_cpu((__force __le32)x); } #else /* !CONFIG_PPC32 */ -static inline void fsl_set_accessors(struct fsl_usb2_platform_data *pdata) {} - #define fsl_readl(addr) readl(addr) #define fsl_writel(val32, addr) writel(val32, addr) #define cpu_to_hc32(x) cpu_to_le32(x) @@ -1289,11 +1277,6 @@ static int ep0_prime_status(struct fsl_udc *udc, int direction) req->req.complete = NULL; req->dtd_count = 0; - req->req.dma = dma_map_single(ep->udc->gadget.dev.parent, - req->req.buf, req->req.length, - ep_is_in(ep) ? DMA_TO_DEVICE : DMA_FROM_DEVICE); - req->mapped = 1; - if (fsl_req_to_dtd(req) == 0) fsl_queue_td(ep, req); else @@ -1365,6 +1348,9 @@ static void ch9getstatus(struct fsl_udc *udc, u8 request_type, u16 value, /* Fill in the reqest structure */ *((u16 *) req->req.buf) = cpu_to_le16(tmp); + /* flush cache for the req buffer */ + flush_dcache_range((u32)req->req.buf, (u32)req->req.buf + 8); + req->ep = ep; req->req.length = 2; req->req.status = -EINPROGRESS; @@ -1372,11 +1358,6 @@ static void ch9getstatus(struct fsl_udc *udc, u8 request_type, u16 value, req->req.complete = NULL; req->dtd_count = 0; - req->req.dma = dma_map_single(ep->udc->gadget.dev.parent, - req->req.buf, req->req.length, - ep_is_in(ep) ? DMA_TO_DEVICE : DMA_FROM_DEVICE); - req->mapped = 1; - /* prime the data phase */ if ((fsl_req_to_dtd(req) == 0)) fsl_queue_td(ep, req); @@ -2373,6 +2354,7 @@ static int __init struct_udc_setup(struct fsl_udc *udc, struct fsl_req, req); /* allocate a small amount of memory to get valid address */ udc->status_req->req.buf = kmalloc(8, GFP_KERNEL); + udc->status_req->req.dma = virt_to_phys(udc->status_req->req.buf); udc->resume_state = USB_STATE_NOTATTACHED; udc->usb_state = USB_STATE_POWERED; @@ -2488,7 +2470,13 @@ static int __init fsl_udc_probe(struct platform_device *pdev) } /* Set accessors only after pdata->init() ! */ - fsl_set_accessors(pdata); + if (pdata->big_endian_mmio) { + _fsl_readl = _fsl_readl_be; + _fsl_writel = _fsl_writel_be; + } else { + _fsl_readl = _fsl_readl_le; + _fsl_writel = _fsl_writel_le; + } #ifndef CONFIG_ARCH_MXC if (pdata->have_sysif_regs) diff --git a/trunk/drivers/usb/host/ehci-ath79.c b/trunk/drivers/usb/host/ehci-ath79.c index aa248c2f2c60..98cc8a13169c 100644 --- a/trunk/drivers/usb/host/ehci-ath79.c +++ b/trunk/drivers/usb/host/ehci-ath79.c @@ -44,6 +44,7 @@ static int ehci_ath79_init(struct usb_hcd *hcd) struct ehci_hcd *ehci = hcd_to_ehci(hcd); struct platform_device *pdev = to_platform_device(hcd->self.controller); const struct platform_device_id *id; + int hclength; int ret; id = platform_get_device_id(pdev); @@ -52,23 +53,20 @@ static int ehci_ath79_init(struct usb_hcd *hcd) return -EINVAL; } + hclength = HC_LENGTH(ehci, ehci_readl(ehci, &ehci->caps->hc_capbase)); switch (id->driver_data) { case EHCI_ATH79_IP_V1: ehci->has_synopsys_hc_bug = 1; ehci->caps = hcd->regs; - ehci->regs = hcd->regs + - HC_LENGTH(ehci, - ehci_readl(ehci, &ehci->caps->hc_capbase)); + ehci->regs = hcd->regs + hclength; break; case EHCI_ATH79_IP_V2: hcd->has_tt = 1; ehci->caps = hcd->regs + 0x100; - ehci->regs = hcd->regs + 0x100 + - HC_LENGTH(ehci, - ehci_readl(ehci, &ehci->caps->hc_capbase)); + ehci->regs = hcd->regs + 0x100 + hclength; break; default: diff --git a/trunk/drivers/usb/host/ehci-hcd.c b/trunk/drivers/usb/host/ehci-hcd.c index f8030ee928e8..b435ed67dd5c 100644 --- a/trunk/drivers/usb/host/ehci-hcd.c +++ b/trunk/drivers/usb/host/ehci-hcd.c @@ -1,8 +1,4 @@ /* - * Enhanced Host Controller Interface (EHCI) driver for USB. - * - * Maintainer: Alan Stern - * * Copyright (c) 2000-2004 by David Brownell * * This program is free software; you can redistribute it and/or modify it diff --git a/trunk/drivers/usb/host/isp1760-hcd.c b/trunk/drivers/usb/host/isp1760-hcd.c index 55d3d5859ac5..c9e6e454c625 100644 --- a/trunk/drivers/usb/host/isp1760-hcd.c +++ b/trunk/drivers/usb/host/isp1760-hcd.c @@ -1555,7 +1555,7 @@ static void kill_transfer(struct usb_hcd *hcd, struct urb *urb, /* We need to forcefully reclaim the slot since some transfers never return, e.g. interrupt transfers and NAKed bulk transfers. */ - if (usb_pipecontrol(urb->pipe) || usb_pipebulk(urb->pipe)) { + if (usb_pipebulk(urb->pipe)) { skip_map = reg_read32(hcd->regs, HC_ATL_PTD_SKIPMAP_REG); skip_map |= (1 << qh->slot); reg_write32(hcd->regs, HC_ATL_PTD_SKIPMAP_REG, skip_map); diff --git a/trunk/drivers/usb/host/ohci-hcd.c b/trunk/drivers/usb/host/ohci-hcd.c index f9cf3f04b742..9aa10bdf3918 100644 --- a/trunk/drivers/usb/host/ohci-hcd.c +++ b/trunk/drivers/usb/host/ohci-hcd.c @@ -1,7 +1,5 @@ /* - * Open Host Controller Interface (OHCI) driver for USB. - * - * Maintainer: Alan Stern + * OHCI HCD (Host Controller Driver) for USB. * * (C) Copyright 1999 Roman Weissgaerber * (C) Copyright 2000-2004 David Brownell diff --git a/trunk/drivers/usb/host/r8a66597-hcd.c b/trunk/drivers/usb/host/r8a66597-hcd.c index 4586369dda00..db6f8b9c19b6 100644 --- a/trunk/drivers/usb/host/r8a66597-hcd.c +++ b/trunk/drivers/usb/host/r8a66597-hcd.c @@ -2517,7 +2517,6 @@ static int __devinit r8a66597_probe(struct platform_device *pdev) INIT_LIST_HEAD(&r8a66597->child_device); hcd->rsrc_start = res->start; - hcd->has_tt = 1; ret = usb_add_hcd(hcd, irq, IRQF_DISABLED | irq_trigger); if (ret != 0) { diff --git a/trunk/drivers/usb/host/xhci-mem.c b/trunk/drivers/usb/host/xhci-mem.c index fcb7f7efc86d..0f8e1d29a858 100644 --- a/trunk/drivers/usb/host/xhci-mem.c +++ b/trunk/drivers/usb/host/xhci-mem.c @@ -1215,6 +1215,8 @@ int xhci_endpoint_init(struct xhci_hcd *xhci, ep_ctx->ep_info2 |= cpu_to_le32(MAX_PACKET(max_packet)); /* dig out max burst from ep companion desc */ max_packet = ep->ss_ep_comp.bMaxBurst; + if (!max_packet) + xhci_warn(xhci, "WARN no SS endpoint bMaxBurst\n"); ep_ctx->ep_info2 |= cpu_to_le32(MAX_BURST(max_packet)); break; case USB_SPEED_HIGH: diff --git a/trunk/drivers/usb/host/xhci-pci.c b/trunk/drivers/usb/host/xhci-pci.c index cb16de213f64..17541d09eabb 100644 --- a/trunk/drivers/usb/host/xhci-pci.c +++ b/trunk/drivers/usb/host/xhci-pci.c @@ -29,9 +29,6 @@ #define PCI_VENDOR_ID_FRESCO_LOGIC 0x1b73 #define PCI_DEVICE_ID_FRESCO_LOGIC_PDK 0x1000 -#define PCI_VENDOR_ID_ETRON 0x1b6f -#define PCI_DEVICE_ID_ASROCK_P67 0x7023 - static const char hcd_name[] = "xhci_hcd"; /* called after powerup, by probe or system-pm "wakeup" */ @@ -137,11 +134,6 @@ static int xhci_pci_setup(struct usb_hcd *hcd) xhci->quirks |= XHCI_EP_LIMIT_QUIRK; xhci->limit_active_eps = 64; } - if (pdev->vendor == PCI_VENDOR_ID_ETRON && - pdev->device == PCI_DEVICE_ID_ASROCK_P67) { - xhci->quirks |= XHCI_RESET_ON_RESUME; - xhci_dbg(xhci, "QUIRK: Resetting on resume\n"); - } /* Make sure the HC is halted. */ retval = xhci_halt(xhci); diff --git a/trunk/drivers/usb/host/xhci-ring.c b/trunk/drivers/usb/host/xhci-ring.c index 70cacbbe7fb9..800f417c7309 100644 --- a/trunk/drivers/usb/host/xhci-ring.c +++ b/trunk/drivers/usb/host/xhci-ring.c @@ -1733,7 +1733,6 @@ static int process_isoc_td(struct xhci_hcd *xhci, struct xhci_td *td, frame->status = -EOVERFLOW; skip_td = true; break; - case COMP_DEV_ERR: case COMP_STALL: frame->status = -EPROTO; skip_td = true; @@ -1768,6 +1767,9 @@ static int process_isoc_td(struct xhci_hcd *xhci, struct xhci_td *td, } } + if ((idx == urb_priv->length - 1) && *status == -EINPROGRESS) + *status = 0; + return finish_td(xhci, td, event_trb, event, ep, status, false); } @@ -1785,7 +1787,8 @@ static int skip_isoc_td(struct xhci_hcd *xhci, struct xhci_td *td, idx = urb_priv->td_cnt; frame = &td->urb->iso_frame_desc[idx]; - /* The transfer is partly done. */ + /* The transfer is partly done */ + *status = -EXDEV; frame->status = -EXDEV; /* calc actual length */ @@ -2013,10 +2016,6 @@ static int handle_tx_event(struct xhci_hcd *xhci, TRB_TO_SLOT_ID(le32_to_cpu(event->flags)), ep_index); goto cleanup; - case COMP_DEV_ERR: - xhci_warn(xhci, "WARN: detect an incompatible device"); - status = -EPROTO; - break; case COMP_MISSED_INT: /* * When encounter missed service error, one or more isoc tds @@ -2064,20 +2063,6 @@ static int handle_tx_event(struct xhci_hcd *xhci, /* Is this a TRB in the currently executing TD? */ event_seg = trb_in_td(ep_ring->deq_seg, ep_ring->dequeue, td->last_trb, event_dma); - - /* - * Skip the Force Stopped Event. The event_trb(event_dma) of FSE - * is not in the current TD pointed by ep_ring->dequeue because - * that the hardware dequeue pointer still at the previous TRB - * of the current TD. The previous TRB maybe a Link TD or the - * last TRB of the previous TD. The command completion handle - * will take care the rest. - */ - if (!event_seg && trb_comp_code == COMP_STOP_INVAL) { - ret = 0; - goto cleanup; - } - if (!event_seg) { if (!ep->skip || !usb_endpoint_xfer_isoc(&td->urb->ep->desc)) { @@ -2173,11 +2158,6 @@ static int handle_tx_event(struct xhci_hcd *xhci, urb->transfer_buffer_length, status); spin_unlock(&xhci->lock); - /* EHCI, UHCI, and OHCI always unconditionally set the - * urb->status of an isochronous endpoint to 0. - */ - if (usb_pipetype(urb->pipe) == PIPE_ISOCHRONOUS) - status = 0; usb_hcd_giveback_urb(bus_to_hcd(urb->dev->bus), urb, status); spin_lock(&xhci->lock); } diff --git a/trunk/drivers/usb/host/xhci.c b/trunk/drivers/usb/host/xhci.c index f5fe1ac301ab..06e7023258d0 100644 --- a/trunk/drivers/usb/host/xhci.c +++ b/trunk/drivers/usb/host/xhci.c @@ -759,8 +759,6 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated) msleep(100); spin_lock_irq(&xhci->lock); - if (xhci->quirks & XHCI_RESET_ON_RESUME) - hibernated = true; if (!hibernated) { /* step 1: restore register */ @@ -1403,7 +1401,6 @@ int xhci_add_endpoint(struct usb_hcd *hcd, struct usb_device *udev, u32 added_ctxs; unsigned int last_ctx; u32 new_add_flags, new_drop_flags, new_slot_info; - struct xhci_virt_device *virt_dev; int ret = 0; ret = xhci_check_args(hcd, udev, ep, 1, true, __func__); @@ -1428,25 +1425,11 @@ int xhci_add_endpoint(struct usb_hcd *hcd, struct usb_device *udev, return 0; } - virt_dev = xhci->devs[udev->slot_id]; - in_ctx = virt_dev->in_ctx; - out_ctx = virt_dev->out_ctx; + in_ctx = xhci->devs[udev->slot_id]->in_ctx; + out_ctx = xhci->devs[udev->slot_id]->out_ctx; ctrl_ctx = xhci_get_input_control_ctx(xhci, in_ctx); ep_index = xhci_get_endpoint_index(&ep->desc); ep_ctx = xhci_get_ep_ctx(xhci, out_ctx, ep_index); - - /* If this endpoint is already in use, and the upper layers are trying - * to add it again without dropping it, reject the addition. - */ - if (virt_dev->eps[ep_index].ring && - !(le32_to_cpu(ctrl_ctx->drop_flags) & - xhci_get_endpoint_flag(&ep->desc))) { - xhci_warn(xhci, "Trying to add endpoint 0x%x " - "without dropping it.\n", - (unsigned int) ep->desc.bEndpointAddress); - return -EINVAL; - } - /* If the HCD has already noted the endpoint is enabled, * ignore this request. */ @@ -1462,7 +1445,8 @@ int xhci_add_endpoint(struct usb_hcd *hcd, struct usb_device *udev, * process context, not interrupt context (or so documenation * for usb_set_interface() and usb_set_configuration() claim). */ - if (xhci_endpoint_init(xhci, virt_dev, udev, ep, GFP_NOIO) < 0) { + if (xhci_endpoint_init(xhci, xhci->devs[udev->slot_id], + udev, ep, GFP_NOIO) < 0) { dev_dbg(&udev->dev, "%s - could not initialize ep %#x\n", __func__, ep->desc.bEndpointAddress); return -ENOMEM; @@ -1553,11 +1537,6 @@ static int xhci_configure_endpoint_result(struct xhci_hcd *xhci, "and endpoint is not disabled.\n"); ret = -EINVAL; break; - case COMP_DEV_ERR: - dev_warn(&udev->dev, "ERROR: Incompatible device for endpoint " - "configure command.\n"); - ret = -ENODEV; - break; case COMP_SUCCESS: dev_dbg(&udev->dev, "Successful Endpoint Configure command\n"); ret = 0; @@ -1592,11 +1571,6 @@ static int xhci_evaluate_context_result(struct xhci_hcd *xhci, xhci_dbg_ctx(xhci, virt_dev->out_ctx, 1); ret = -EINVAL; break; - case COMP_DEV_ERR: - dev_warn(&udev->dev, "ERROR: Incompatible device for evaluate " - "context command.\n"); - ret = -ENODEV; - break; case COMP_MEL_ERR: /* Max Exit Latency too large error */ dev_warn(&udev->dev, "WARN: Max Exit Latency too large\n"); @@ -2879,11 +2853,6 @@ int xhci_address_device(struct usb_hcd *hcd, struct usb_device *udev) dev_warn(&udev->dev, "Device not responding to set address.\n"); ret = -EPROTO; break; - case COMP_DEV_ERR: - dev_warn(&udev->dev, "ERROR: Incompatible device for address " - "device command.\n"); - ret = -ENODEV; - break; case COMP_SUCCESS: xhci_dbg(xhci, "Successful Address Device command\n"); break; diff --git a/trunk/drivers/usb/host/xhci.h b/trunk/drivers/usb/host/xhci.h index d8bbf5ccb10d..7d1ea3bf5e1f 100644 --- a/trunk/drivers/usb/host/xhci.h +++ b/trunk/drivers/usb/host/xhci.h @@ -874,8 +874,6 @@ struct xhci_transfer_event { #define COMP_PING_ERR 20 /* Event Ring is full */ #define COMP_ER_FULL 21 -/* Incompatible Device Error */ -#define COMP_DEV_ERR 22 /* Missed Service Error - HC couldn't service an isoc ep within interval */ #define COMP_MISSED_INT 23 /* Successfully stopped command ring */ @@ -1310,7 +1308,6 @@ struct xhci_hcd { */ #define XHCI_EP_LIMIT_QUIRK (1 << 5) #define XHCI_BROKEN_MSI (1 << 6) -#define XHCI_RESET_ON_RESUME (1 << 7) unsigned int num_active_eps; unsigned int limit_active_eps; /* There are two roothubs to keep track of bus suspend info for */ diff --git a/trunk/drivers/usb/musb/musb_gadget.c b/trunk/drivers/usb/musb/musb_gadget.c index 6aeb363e63e7..0a50a35e1853 100644 --- a/trunk/drivers/usb/musb/musb_gadget.c +++ b/trunk/drivers/usb/musb/musb_gadget.c @@ -1524,12 +1524,6 @@ static void musb_gadget_fifo_flush(struct usb_ep *ep) csr = musb_readw(epio, MUSB_TXCSR); if (csr & MUSB_TXCSR_FIFONOTEMPTY) { csr |= MUSB_TXCSR_FLUSHFIFO | MUSB_TXCSR_P_WZC_BITS; - /* - * Setting both TXPKTRDY and FLUSHFIFO makes controller - * to interrupt current FIFO loading, but not flushing - * the already loaded ones. - */ - csr &= ~MUSB_TXCSR_TXPKTRDY; musb_writew(epio, MUSB_TXCSR, csr); /* REVISIT may be inappropriate w/o FIFONOTEMPTY ... */ musb_writew(epio, MUSB_TXCSR, csr); diff --git a/trunk/drivers/usb/musb/musb_host.c b/trunk/drivers/usb/musb/musb_host.c index 8b2473fa0f47..7295e316bdfc 100644 --- a/trunk/drivers/usb/musb/musb_host.c +++ b/trunk/drivers/usb/musb/musb_host.c @@ -1575,7 +1575,7 @@ void musb_host_rx(struct musb *musb, u8 epnum) /* even if there was an error, we did the dma * for iso_frame_desc->length */ - if (d->status != -EILSEQ && d->status != -EOVERFLOW) + if (d->status != EILSEQ && d->status != -EOVERFLOW) d->status = 0; if (++qh->iso_idx >= urb->number_of_packets) diff --git a/trunk/drivers/usb/serial/ftdi_sio.c b/trunk/drivers/usb/serial/ftdi_sio.c index 2e06b90aa1f8..162728977553 100644 --- a/trunk/drivers/usb/serial/ftdi_sio.c +++ b/trunk/drivers/usb/serial/ftdi_sio.c @@ -179,7 +179,6 @@ static struct usb_device_id id_table_combined [] = { { USB_DEVICE(FTDI_VID, FTDI_232RL_PID) }, { USB_DEVICE(FTDI_VID, FTDI_8U2232C_PID) }, { USB_DEVICE(FTDI_VID, FTDI_4232H_PID) }, - { USB_DEVICE(FTDI_VID, FTDI_232H_PID) }, { USB_DEVICE(FTDI_VID, FTDI_MICRO_CHAMELEON_PID) }, { USB_DEVICE(FTDI_VID, FTDI_RELAIS_PID) }, { USB_DEVICE(FTDI_VID, FTDI_OPENDCC_PID) }, @@ -849,8 +848,7 @@ static const char *ftdi_chip_name[] = { [FT2232C] = "FT2232C", [FT232RL] = "FT232RL", [FT2232H] = "FT2232H", - [FT4232H] = "FT4232H", - [FT232H] = "FT232H" + [FT4232H] = "FT4232H" }; @@ -1170,7 +1168,6 @@ static __u32 get_ftdi_divisor(struct tty_struct *tty, break; case FT2232H: /* FT2232H chip */ case FT4232H: /* FT4232H chip */ - case FT232H: /* FT232H chip */ if ((baud <= 12000000) & (baud >= 1200)) { div_value = ftdi_2232h_baud_to_divisor(baud); } else if (baud < 1200) { @@ -1432,12 +1429,9 @@ static void ftdi_determine_type(struct usb_serial_port *port) } else if (version < 0x600) { /* Assume it's an FT232BM (or FT245BM) */ priv->chip_type = FT232BM; - } else if (version < 0x900) { - /* Assume it's an FT232RL */ - priv->chip_type = FT232RL; } else { - /* Assume it's an FT232H */ - priv->chip_type = FT232H; + /* Assume it's an FT232R */ + priv->chip_type = FT232RL; } dev_info(&udev->dev, "Detected %s\n", ftdi_chip_name[priv->chip_type]); } @@ -1565,8 +1559,7 @@ static int create_sysfs_attrs(struct usb_serial_port *port) priv->chip_type == FT2232C || priv->chip_type == FT232RL || priv->chip_type == FT2232H || - priv->chip_type == FT4232H || - priv->chip_type == FT232H)) { + priv->chip_type == FT4232H)) { retval = device_create_file(&port->dev, &dev_attr_latency_timer); } @@ -1587,8 +1580,7 @@ static void remove_sysfs_attrs(struct usb_serial_port *port) priv->chip_type == FT2232C || priv->chip_type == FT232RL || priv->chip_type == FT2232H || - priv->chip_type == FT4232H || - priv->chip_type == FT232H) { + priv->chip_type == FT4232H) { device_remove_file(&port->dev, &dev_attr_latency_timer); } } @@ -2220,7 +2212,6 @@ static int ftdi_tiocmget(struct tty_struct *tty) case FT232RL: case FT2232H: case FT4232H: - case FT232H: len = 2; break; default: diff --git a/trunk/drivers/usb/serial/ftdi_sio.h b/trunk/drivers/usb/serial/ftdi_sio.h index 19584faa86f9..213fe3d61282 100644 --- a/trunk/drivers/usb/serial/ftdi_sio.h +++ b/trunk/drivers/usb/serial/ftdi_sio.h @@ -156,8 +156,7 @@ enum ftdi_chip_type { FT2232C = 4, FT232RL = 5, FT2232H = 6, - FT4232H = 7, - FT232H = 8 + FT4232H = 7 }; enum ftdi_sio_baudrate { diff --git a/trunk/drivers/usb/serial/ftdi_sio_ids.h b/trunk/drivers/usb/serial/ftdi_sio_ids.h index 19156d1049fe..ab1fcdf3c378 100644 --- a/trunk/drivers/usb/serial/ftdi_sio_ids.h +++ b/trunk/drivers/usb/serial/ftdi_sio_ids.h @@ -22,7 +22,6 @@ #define FTDI_8U232AM_ALT_PID 0x6006 /* FTDI's alternate PID for above */ #define FTDI_8U2232C_PID 0x6010 /* Dual channel device */ #define FTDI_4232H_PID 0x6011 /* Quad channel hi-speed device */ -#define FTDI_232H_PID 0x6014 /* Single channel hi-speed device */ #define FTDI_SIO_PID 0x8372 /* Product Id SIO application of 8U100AX */ #define FTDI_232RL_PID 0xFBFA /* Product ID for FT232RL */ diff --git a/trunk/drivers/usb/serial/ti_usb_3410_5052.c b/trunk/drivers/usb/serial/ti_usb_3410_5052.c index ea8445689c85..c6d92a530086 100644 --- a/trunk/drivers/usb/serial/ti_usb_3410_5052.c +++ b/trunk/drivers/usb/serial/ti_usb_3410_5052.c @@ -1745,7 +1745,6 @@ static int ti_download_firmware(struct ti_device *tdev) } if (fw_p->size > TI_FIRMWARE_BUF_SIZE) { dev_err(&dev->dev, "%s - firmware too large %zu\n", __func__, fw_p->size); - release_firmware(fw_p); return -ENOENT; } diff --git a/trunk/drivers/video/amba-clcd.c b/trunk/drivers/video/amba-clcd.c index cf03ad067147..5fc983c5b92c 100644 --- a/trunk/drivers/video/amba-clcd.c +++ b/trunk/drivers/video/amba-clcd.c @@ -447,8 +447,6 @@ static int clcdfb_register(struct clcd_fb *fb) goto out; } - fb->fb.device = &fb->dev->dev; - fb->fb.fix.mmio_start = fb->dev->res.start; fb->fb.fix.mmio_len = resource_size(&fb->dev->res); diff --git a/trunk/drivers/video/fsl-diu-fb.c b/trunk/drivers/video/fsl-diu-fb.c index 0acc7d65aeaa..bedf5be27f05 100644 --- a/trunk/drivers/video/fsl-diu-fb.c +++ b/trunk/drivers/video/fsl-diu-fb.c @@ -555,6 +555,8 @@ static void adjust_aoi_size_position(struct fb_var_screeninfo *var, static int fsl_diu_check_var(struct fb_var_screeninfo *var, struct fb_info *info) { + unsigned long htotal, vtotal; + pr_debug("check_var xres: %d\n", var->xres); pr_debug("check_var yres: %d\n", var->yres); @@ -633,6 +635,20 @@ static int fsl_diu_check_var(struct fb_var_screeninfo *var, break; } + /* If the pixclock is below the minimum spec'd value then set to + * refresh rate for 60Hz since this is supported by most monitors. + * Refer to Documentation/fb/ for calculations. + */ + if ((var->pixclock < MIN_PIX_CLK) || (var->pixclock > MAX_PIX_CLK)) { + htotal = var->xres + var->right_margin + var->hsync_len + + var->left_margin; + vtotal = var->yres + var->lower_margin + var->vsync_len + + var->upper_margin; + var->pixclock = (vtotal * htotal * 6UL) / 100UL; + var->pixclock = KHZ2PICOS(var->pixclock); + pr_debug("pixclock set for 60Hz refresh = %u ps\n", + var->pixclock); + } var->height = -1; var->width = -1; diff --git a/trunk/drivers/video/geode/gx1fb_core.c b/trunk/drivers/video/geode/gx1fb_core.c index 5a5d0928df33..c6b554f72c6d 100644 --- a/trunk/drivers/video/geode/gx1fb_core.c +++ b/trunk/drivers/video/geode/gx1fb_core.c @@ -29,7 +29,7 @@ static int crt_option = 1; static char panel_option[32] = ""; /* Modes relevant to the GX1 (taken from modedb.c) */ -static const struct fb_videomode __devinitdata gx1_modedb[] = { +static const struct fb_videomode __initdata gx1_modedb[] = { /* 640x480-60 VESA */ { NULL, 60, 640, 480, 39682, 48, 16, 33, 10, 96, 2, 0, FB_VMODE_NONINTERLACED, FB_MODE_IS_VESA }, @@ -195,7 +195,7 @@ static int gx1fb_blank(int blank_mode, struct fb_info *info) return par->vid_ops->blank_display(info, blank_mode); } -static int __devinit gx1fb_map_video_memory(struct fb_info *info, struct pci_dev *dev) +static int __init gx1fb_map_video_memory(struct fb_info *info, struct pci_dev *dev) { struct geodefb_par *par = info->par; unsigned gx_base; @@ -268,7 +268,7 @@ static struct fb_ops gx1fb_ops = { .fb_imageblit = cfb_imageblit, }; -static struct fb_info * __devinit gx1fb_init_fbinfo(struct device *dev) +static struct fb_info * __init gx1fb_init_fbinfo(struct device *dev) { struct geodefb_par *par; struct fb_info *info; @@ -318,7 +318,7 @@ static struct fb_info * __devinit gx1fb_init_fbinfo(struct device *dev) return info; } -static int __devinit gx1fb_probe(struct pci_dev *pdev, const struct pci_device_id *id) +static int __init gx1fb_probe(struct pci_dev *pdev, const struct pci_device_id *id) { struct geodefb_par *par; struct fb_info *info; @@ -382,7 +382,7 @@ static int __devinit gx1fb_probe(struct pci_dev *pdev, const struct pci_device_i return ret; } -static void __devexit gx1fb_remove(struct pci_dev *pdev) +static void gx1fb_remove(struct pci_dev *pdev) { struct fb_info *info = pci_get_drvdata(pdev); struct geodefb_par *par = info->par; @@ -441,7 +441,7 @@ static struct pci_driver gx1fb_driver = { .name = "gx1fb", .id_table = gx1fb_id_table, .probe = gx1fb_probe, - .remove = __devexit_p(gx1fb_remove), + .remove = gx1fb_remove, }; static int __init gx1fb_init(void) @@ -456,7 +456,7 @@ static int __init gx1fb_init(void) return pci_register_driver(&gx1fb_driver); } -static void __devexit gx1fb_cleanup(void) +static void __exit gx1fb_cleanup(void) { pci_unregister_driver(&gx1fb_driver); } diff --git a/trunk/drivers/video/hecubafb.c b/trunk/drivers/video/hecubafb.c index 614251a9af91..fbef15f7a218 100644 --- a/trunk/drivers/video/hecubafb.c +++ b/trunk/drivers/video/hecubafb.c @@ -233,7 +233,7 @@ static int __devinit hecubafb_probe(struct platform_device *dev) videomemory = vzalloc(videomemorysize); if (!videomemory) - goto err_videomem_alloc; + return retval; info = framebuffer_alloc(sizeof(struct hecubafb_par), &dev->dev); if (!info) @@ -275,7 +275,6 @@ static int __devinit hecubafb_probe(struct platform_device *dev) framebuffer_release(info); err_fballoc: vfree(videomemory); -err_videomem_alloc: module_put(board->owner); return retval; } diff --git a/trunk/drivers/video/sh_mobile_meram.c b/trunk/drivers/video/sh_mobile_meram.c index cc7d7329dc15..9170c82b495c 100644 --- a/trunk/drivers/video/sh_mobile_meram.c +++ b/trunk/drivers/video/sh_mobile_meram.c @@ -218,7 +218,7 @@ static inline void meram_get_next_icb_addr(struct sh_mobile_meram_info *pdata, icb_offset = 0xc0000000 | (cfg->current_reg << 23); *icb_addr_y = icb_offset | (cfg->icb[0].marker_icb << 24); - if (is_nvcolor(cfg->pixelformat)) + if ((*icb_addr_c) && is_nvcolor(cfg->pixelformat)) *icb_addr_c = icb_offset | (cfg->icb[1].marker_icb << 24); } diff --git a/trunk/drivers/video/sm501fb.c b/trunk/drivers/video/sm501fb.c index 6294dca95500..87f0be1e78b5 100644 --- a/trunk/drivers/video/sm501fb.c +++ b/trunk/drivers/video/sm501fb.c @@ -1664,7 +1664,7 @@ static void sm501fb_stop(struct sm501fb_info *info) resource_size(info->regs_res)); } -static int __devinit sm501fb_init_fb(struct fb_info *fb, +static int sm501fb_init_fb(struct fb_info *fb, enum sm501_controller head, const char *fbname) { diff --git a/trunk/drivers/video/udlfb.c b/trunk/drivers/video/udlfb.c index 816a4fda04f5..52b0f3e8ccac 100644 --- a/trunk/drivers/video/udlfb.c +++ b/trunk/drivers/video/udlfb.c @@ -1233,12 +1233,8 @@ static int dlfb_setup_modes(struct dlfb_data *dev, if (dlfb_is_valid_mode(&info->monspecs.modedb[i], info)) fb_add_videomode(&info->monspecs.modedb[i], &info->modelist); - else { - if (i == 0) - /* if we've removed top/best mode */ - info->monspecs.misc - &= ~FB_MISC_1ST_DETAIL; - } + else /* if we've removed top/best mode */ + info->monspecs.misc &= ~FB_MISC_1ST_DETAIL; } default_vmode = fb_find_best_display(&info->monspecs, diff --git a/trunk/drivers/video/vesafb.c b/trunk/drivers/video/vesafb.c index 501b3406c6d5..a99bbe86db13 100644 --- a/trunk/drivers/video/vesafb.c +++ b/trunk/drivers/video/vesafb.c @@ -175,7 +175,6 @@ static int vesafb_setcolreg(unsigned regno, unsigned red, unsigned green, static void vesafb_destroy(struct fb_info *info) { - fb_dealloc_cmap(&info->cmap); if (info->screen_base) iounmap(info->screen_base); release_mem_region(info->apertures->ranges[0].base, info->apertures->ranges[0].size); diff --git a/trunk/drivers/w1/masters/ds1wm.c b/trunk/drivers/w1/masters/ds1wm.c index a0c8965c1a79..ad57593d224a 100644 --- a/trunk/drivers/w1/masters/ds1wm.c +++ b/trunk/drivers/w1/masters/ds1wm.c @@ -109,7 +109,6 @@ struct ds1wm_data { /* byte to write that makes all intr disabled, */ /* considering active_state (IAS) (optimization) */ u8 int_en_reg_none; - unsigned int reset_recover_delay; /* see ds1wm.h */ }; static inline void ds1wm_write_register(struct ds1wm_data *ds1wm_data, u32 reg, @@ -188,9 +187,6 @@ static int ds1wm_reset(struct ds1wm_data *ds1wm_data) return 1; } - if (ds1wm_data->reset_recover_delay) - msleep(ds1wm_data->reset_recover_delay); - return 0; } @@ -494,7 +490,6 @@ static int ds1wm_probe(struct platform_device *pdev) } ds1wm_data->irq = res->start; ds1wm_data->int_en_reg_none = (plat->active_high ? DS1WM_INTEN_IAS : 0); - ds1wm_data->reset_recover_delay = plat->reset_recover_delay; if (res->flags & IORESOURCE_IRQ_HIGHEDGE) irq_set_irq_type(ds1wm_data->irq, IRQ_TYPE_EDGE_RISING); diff --git a/trunk/drivers/watchdog/Kconfig b/trunk/drivers/watchdog/Kconfig index 9536d386bb38..022f9eb0b7bf 100644 --- a/trunk/drivers/watchdog/Kconfig +++ b/trunk/drivers/watchdog/Kconfig @@ -535,7 +535,8 @@ config I6300ESB_WDT config INTEL_SCU_WATCHDOG bool "Intel SCU Watchdog for Mobile Platforms" - depends on X86_MRST + depends on WATCHDOG + depends on INTEL_SCU_IPC ---help--- Hardware driver for the watchdog time built into the Intel SCU for Intel Mobile Platforms. diff --git a/trunk/drivers/watchdog/at32ap700x_wdt.c b/trunk/drivers/watchdog/at32ap700x_wdt.c index 4ca5d40304b2..750bc5281d79 100644 --- a/trunk/drivers/watchdog/at32ap700x_wdt.c +++ b/trunk/drivers/watchdog/at32ap700x_wdt.c @@ -448,7 +448,7 @@ static void __exit at32_wdt_exit(void) } module_exit(at32_wdt_exit); -MODULE_AUTHOR("Hans-Christian Egtvedt "); +MODULE_AUTHOR("Hans-Christian Egtvedt "); MODULE_DESCRIPTION("Watchdog driver for Atmel AT32AP700X"); MODULE_LICENSE("GPL"); MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); diff --git a/trunk/drivers/watchdog/gef_wdt.c b/trunk/drivers/watchdog/gef_wdt.c index b146082bd85a..29a7cd4b90c8 100644 --- a/trunk/drivers/watchdog/gef_wdt.c +++ b/trunk/drivers/watchdog/gef_wdt.c @@ -329,4 +329,4 @@ MODULE_AUTHOR("Martyn Welch "); MODULE_DESCRIPTION("GE watchdog driver"); MODULE_LICENSE("GPL"); MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); -MODULE_ALIAS("platform:gef_wdt"); +MODULE_ALIAS("platform: gef_wdt"); diff --git a/trunk/drivers/watchdog/intel_scu_watchdog.c b/trunk/drivers/watchdog/intel_scu_watchdog.c index ba4386066a42..919bdd16136f 100644 --- a/trunk/drivers/watchdog/intel_scu_watchdog.c +++ b/trunk/drivers/watchdog/intel_scu_watchdog.c @@ -42,6 +42,7 @@ #include #include #include +#include #include #include #include diff --git a/trunk/drivers/watchdog/mtx-1_wdt.c b/trunk/drivers/watchdog/mtx-1_wdt.c index 0430e093b1a0..1479dc4d6129 100644 --- a/trunk/drivers/watchdog/mtx-1_wdt.c +++ b/trunk/drivers/watchdog/mtx-1_wdt.c @@ -66,18 +66,23 @@ static struct { int default_ticks; unsigned long inuse; unsigned gpio; - unsigned int gstate; + int gstate; } mtx1_wdt_device; static void mtx1_wdt_trigger(unsigned long unused) { + u32 tmp; + spin_lock(&mtx1_wdt_device.lock); if (mtx1_wdt_device.running) ticks--; /* toggle wdt gpio */ - mtx1_wdt_device.gstate = !mtx1_wdt_device.gstate; - gpio_set_value(mtx1_wdt_device.gpio, mtx1_wdt_device.gstate); + mtx1_wdt_device.gstate = ~mtx1_wdt_device.gstate; + if (mtx1_wdt_device.gstate) + gpio_direction_output(mtx1_wdt_device.gpio, 1); + else + gpio_direction_input(mtx1_wdt_device.gpio); if (mtx1_wdt_device.queue && ticks) mod_timer(&mtx1_wdt_device.timer, jiffies + MTX1_WDT_INTERVAL); @@ -100,7 +105,7 @@ static void mtx1_wdt_start(void) if (!mtx1_wdt_device.queue) { mtx1_wdt_device.queue = 1; mtx1_wdt_device.gstate = 1; - gpio_set_value(mtx1_wdt_device.gpio, 1); + gpio_direction_output(mtx1_wdt_device.gpio, 1); mod_timer(&mtx1_wdt_device.timer, jiffies + MTX1_WDT_INTERVAL); } mtx1_wdt_device.running++; @@ -115,7 +120,7 @@ static int mtx1_wdt_stop(void) if (mtx1_wdt_device.queue) { mtx1_wdt_device.queue = 0; mtx1_wdt_device.gstate = 0; - gpio_set_value(mtx1_wdt_device.gpio, 0); + gpio_direction_output(mtx1_wdt_device.gpio, 0); } ticks = mtx1_wdt_device.default_ticks; spin_unlock_irqrestore(&mtx1_wdt_device.lock, flags); @@ -209,12 +214,6 @@ static int __devinit mtx1_wdt_probe(struct platform_device *pdev) int ret; mtx1_wdt_device.gpio = pdev->resource[0].start; - ret = gpio_request_one(mtx1_wdt_device.gpio, - GPIOF_OUT_INIT_HIGH, "mtx1-wdt"); - if (ret < 0) { - dev_err(&pdev->dev, "failed to request gpio"); - return ret; - } spin_lock_init(&mtx1_wdt_device.lock); init_completion(&mtx1_wdt_device.stop); @@ -240,13 +239,11 @@ static int __devexit mtx1_wdt_remove(struct platform_device *pdev) mtx1_wdt_device.queue = 0; wait_for_completion(&mtx1_wdt_device.stop); } - - gpio_free(mtx1_wdt_device.gpio); misc_deregister(&mtx1_wdt_misc); return 0; } -static struct platform_driver mtx1_wdt_driver = { +static struct platform_driver mtx1_wdt = { .probe = mtx1_wdt_probe, .remove = __devexit_p(mtx1_wdt_remove), .driver.name = "mtx1-wdt", @@ -255,12 +252,12 @@ static struct platform_driver mtx1_wdt_driver = { static int __init mtx1_wdt_init(void) { - return platform_driver_register(&mtx1_wdt_driver); + return platform_driver_register(&mtx1_wdt); } static void __exit mtx1_wdt_exit(void) { - platform_driver_unregister(&mtx1_wdt_driver); + platform_driver_unregister(&mtx1_wdt); } module_init(mtx1_wdt_init); diff --git a/trunk/drivers/watchdog/wm831x_wdt.c b/trunk/drivers/watchdog/wm831x_wdt.c index 871caea4e1c6..8c4b2d5bb7da 100644 --- a/trunk/drivers/watchdog/wm831x_wdt.c +++ b/trunk/drivers/watchdog/wm831x_wdt.c @@ -320,11 +320,6 @@ static int __devinit wm831x_wdt_probe(struct platform_device *pdev) struct wm831x_watchdog_pdata *pdata; int reg, ret; - if (wm831x) { - dev_err(&pdev->dev, "wm831x watchdog already registered\n"); - return -EBUSY; - } - wm831x = dev_get_drvdata(pdev->dev.parent); ret = wm831x_reg_read(wm831x, WM831X_WATCHDOG); diff --git a/trunk/firmware/Makefile b/trunk/firmware/Makefile index 5f43bfba3c7a..0d15a3d113a2 100644 --- a/trunk/firmware/Makefile +++ b/trunk/firmware/Makefile @@ -82,7 +82,6 @@ fw-shipped-$(CONFIG_SERIAL_8250_CS) += cis/MT5634ZLX.cis cis/RS-COM-2P.cis \ fw-shipped-$(CONFIG_PCMCIA_SMC91C92) += ositech/Xilinx7OD.bin fw-shipped-$(CONFIG_SCSI_ADVANSYS) += advansys/mcode.bin advansys/38C1600.bin \ advansys/3550.bin advansys/38C0800.bin -fw-shipped-$(CONFIG_SCSI_ISCI) += isci/isci_firmware.bin fw-shipped-$(CONFIG_SCSI_QLOGIC_1280) += qlogic/1040.bin qlogic/1280.bin \ qlogic/12160.bin fw-shipped-$(CONFIG_SCSI_QLOGICPTI) += qlogic/isp1000.bin diff --git a/trunk/firmware/isci/isci_firmware.bin.ihex b/trunk/firmware/isci/isci_firmware.bin.ihex deleted file mode 100644 index 2e6619570072..000000000000 --- a/trunk/firmware/isci/isci_firmware.bin.ihex +++ /dev/null @@ -1,16 +0,0 @@ -:10000000495343554F454D42E80018100002000087 -:1000100000000000000000000101000000000000DE -:10002000FFFFCF5F0100000008DD0B0000FC0F00A8 -:10003000097C0B006EFC0A00FFFFCF5F010000008F -:1000400008DD0B0000FC0F00097C0B006EFC0A00B1 -:10005000FFFFCF5F0100000008DD0B0000FC0F0078 -:10006000097C0B006EFC0A00FFFFCF5F010000005F -:1000700008DD0B0000FC0F00097C0B006EFC0A0081 -:100080000101000000000000FFFFCF5F0200000040 -:1000900008DD0B0000FC0F00097C0B006EFC0A0061 -:1000A000FFFFCF5F0200000008DD0B0000FC0F0027 -:1000B000097C0B006EFC0A00FFFFCF5F020000000E -:1000C00008DD0B0000FC0F00097C0B006EFC0A0031 -:1000D000FFFFCF5F0200000008DD0B0000FC0F00F7 -:0800E000097C0B006EFC0A0014 -:00000001FF diff --git a/trunk/fs/binfmt_elf_fdpic.c b/trunk/fs/binfmt_elf_fdpic.c index 2bc5dc644b4c..63039ed9576f 100644 --- a/trunk/fs/binfmt_elf_fdpic.c +++ b/trunk/fs/binfmt_elf_fdpic.c @@ -1864,7 +1864,6 @@ static int elf_fdpic_core_dump(struct coredump_params *cprm) kfree(psinfo); kfree(notes); kfree(fpu); - kfree(shdr4extnum); #ifdef ELF_CORE_COPY_XFPREGS kfree(xfpu); #endif diff --git a/trunk/fs/block_dev.c b/trunk/fs/block_dev.c index 610e8e0b04b8..1a2421f908f0 100644 --- a/trunk/fs/block_dev.c +++ b/trunk/fs/block_dev.c @@ -762,19 +762,7 @@ static struct block_device *bd_start_claiming(struct block_device *bdev, if (!disk) return ERR_PTR(-ENXIO); - /* - * Normally, @bdev should equal what's returned from bdget_disk() - * if partno is 0; however, some drivers (floppy) use multiple - * bdev's for the same physical device and @bdev may be one of the - * aliases. Keep @bdev if partno is 0. This means claimer - * tracking is broken for those devices but it has always been that - * way. - */ - if (partno) - whole = bdget_disk(disk, 0); - else - whole = bdgrab(bdev); - + whole = bdget_disk(disk, 0); module_put(disk->fops->owner); put_disk(disk); if (!whole) diff --git a/trunk/fs/btrfs/ctree.h b/trunk/fs/btrfs/ctree.h index 3b859a3e6a0e..300628795fdb 100644 --- a/trunk/fs/btrfs/ctree.h +++ b/trunk/fs/btrfs/ctree.h @@ -19,6 +19,7 @@ #ifndef __BTRFS_CTREE__ #define __BTRFS_CTREE__ +#include #include #include #include @@ -1335,11 +1336,6 @@ struct btrfs_ioctl_defrag_range_args { */ #define BTRFS_STRING_ITEM_KEY 253 -/* - * Flags for mount options. - * - * Note: don't forget to add new options to btrfs_show_options() - */ #define BTRFS_MOUNT_NODATASUM (1 << 0) #define BTRFS_MOUNT_NODATACOW (1 << 1) #define BTRFS_MOUNT_NOBARRIER (1 << 2) diff --git a/trunk/fs/btrfs/delayed-inode.c b/trunk/fs/btrfs/delayed-inode.c index 98c68e658a9b..f1cbd028f7b3 100644 --- a/trunk/fs/btrfs/delayed-inode.c +++ b/trunk/fs/btrfs/delayed-inode.c @@ -82,16 +82,19 @@ static inline struct btrfs_delayed_root *btrfs_get_delayed_root( return root->fs_info->delayed_root; } -static struct btrfs_delayed_node *btrfs_get_delayed_node(struct inode *inode) +static struct btrfs_delayed_node *btrfs_get_or_create_delayed_node( + struct inode *inode) { + struct btrfs_delayed_node *node; struct btrfs_inode *btrfs_inode = BTRFS_I(inode); struct btrfs_root *root = btrfs_inode->root; u64 ino = btrfs_ino(inode); - struct btrfs_delayed_node *node; + int ret; +again: node = ACCESS_ONCE(btrfs_inode->delayed_node); if (node) { - atomic_inc(&node->refs); + atomic_inc(&node->refs); /* can be accessed */ return node; } @@ -99,10 +102,8 @@ static struct btrfs_delayed_node *btrfs_get_delayed_node(struct inode *inode) node = radix_tree_lookup(&root->delayed_nodes_tree, ino); if (node) { if (btrfs_inode->delayed_node) { - atomic_inc(&node->refs); /* can be accessed */ - BUG_ON(btrfs_inode->delayed_node != node); spin_unlock(&root->inode_lock); - return node; + goto again; } btrfs_inode->delayed_node = node; atomic_inc(&node->refs); /* can be accessed */ @@ -112,23 +113,6 @@ static struct btrfs_delayed_node *btrfs_get_delayed_node(struct inode *inode) } spin_unlock(&root->inode_lock); - return NULL; -} - -static struct btrfs_delayed_node *btrfs_get_or_create_delayed_node( - struct inode *inode) -{ - struct btrfs_delayed_node *node; - struct btrfs_inode *btrfs_inode = BTRFS_I(inode); - struct btrfs_root *root = btrfs_inode->root; - u64 ino = btrfs_ino(inode); - int ret; - -again: - node = btrfs_get_delayed_node(inode); - if (node) - return node; - node = kmem_cache_alloc(delayed_node_cache, GFP_NOFS); if (!node) return ERR_PTR(-ENOMEM); @@ -564,6 +548,19 @@ struct btrfs_delayed_item *__btrfs_next_delayed_item( return next; } +static inline struct btrfs_delayed_node *btrfs_get_delayed_node( + struct inode *inode) +{ + struct btrfs_inode *btrfs_inode = BTRFS_I(inode); + struct btrfs_delayed_node *delayed_node; + + delayed_node = btrfs_inode->delayed_node; + if (delayed_node) + atomic_inc(&delayed_node->refs); + + return delayed_node; +} + static inline struct btrfs_root *btrfs_get_fs_root(struct btrfs_root *root, u64 root_id) { @@ -1407,7 +1404,8 @@ int btrfs_delete_delayed_dir_index(struct btrfs_trans_handle *trans, int btrfs_inode_delayed_dir_index_count(struct inode *inode) { - struct btrfs_delayed_node *delayed_node = btrfs_get_delayed_node(inode); + struct btrfs_delayed_node *delayed_node = BTRFS_I(inode)->delayed_node; + int ret = 0; if (!delayed_node) return -ENOENT; @@ -1417,14 +1415,11 @@ int btrfs_inode_delayed_dir_index_count(struct inode *inode) * a new directory index is added into the delayed node and index_cnt * is updated now. So we needn't lock the delayed node. */ - if (!delayed_node->index_cnt) { - btrfs_release_delayed_node(delayed_node); + if (!delayed_node->index_cnt) return -EINVAL; - } BTRFS_I(inode)->index_cnt = delayed_node->index_cnt; - btrfs_release_delayed_node(delayed_node); - return 0; + return ret; } void btrfs_get_delayed_items(struct inode *inode, struct list_head *ins_list, @@ -1618,57 +1613,6 @@ static void fill_stack_inode_item(struct btrfs_trans_handle *trans, inode->i_ctime.tv_nsec); } -int btrfs_fill_inode(struct inode *inode, u32 *rdev) -{ - struct btrfs_delayed_node *delayed_node; - struct btrfs_inode_item *inode_item; - struct btrfs_timespec *tspec; - - delayed_node = btrfs_get_delayed_node(inode); - if (!delayed_node) - return -ENOENT; - - mutex_lock(&delayed_node->mutex); - if (!delayed_node->inode_dirty) { - mutex_unlock(&delayed_node->mutex); - btrfs_release_delayed_node(delayed_node); - return -ENOENT; - } - - inode_item = &delayed_node->inode_item; - - inode->i_uid = btrfs_stack_inode_uid(inode_item); - inode->i_gid = btrfs_stack_inode_gid(inode_item); - btrfs_i_size_write(inode, btrfs_stack_inode_size(inode_item)); - inode->i_mode = btrfs_stack_inode_mode(inode_item); - inode->i_nlink = btrfs_stack_inode_nlink(inode_item); - inode_set_bytes(inode, btrfs_stack_inode_nbytes(inode_item)); - BTRFS_I(inode)->generation = btrfs_stack_inode_generation(inode_item); - BTRFS_I(inode)->sequence = btrfs_stack_inode_sequence(inode_item); - inode->i_rdev = 0; - *rdev = btrfs_stack_inode_rdev(inode_item); - BTRFS_I(inode)->flags = btrfs_stack_inode_flags(inode_item); - - tspec = btrfs_inode_atime(inode_item); - inode->i_atime.tv_sec = btrfs_stack_timespec_sec(tspec); - inode->i_atime.tv_nsec = btrfs_stack_timespec_nsec(tspec); - - tspec = btrfs_inode_mtime(inode_item); - inode->i_mtime.tv_sec = btrfs_stack_timespec_sec(tspec); - inode->i_mtime.tv_nsec = btrfs_stack_timespec_nsec(tspec); - - tspec = btrfs_inode_ctime(inode_item); - inode->i_ctime.tv_sec = btrfs_stack_timespec_sec(tspec); - inode->i_ctime.tv_nsec = btrfs_stack_timespec_nsec(tspec); - - inode->i_generation = BTRFS_I(inode)->generation; - BTRFS_I(inode)->index_cnt = (u64)-1; - - mutex_unlock(&delayed_node->mutex); - btrfs_release_delayed_node(delayed_node); - return 0; -} - int btrfs_delayed_update_inode(struct btrfs_trans_handle *trans, struct btrfs_root *root, struct inode *inode) { diff --git a/trunk/fs/btrfs/delayed-inode.h b/trunk/fs/btrfs/delayed-inode.h index 8d27af4bd8b9..d1a6a2915c66 100644 --- a/trunk/fs/btrfs/delayed-inode.h +++ b/trunk/fs/btrfs/delayed-inode.h @@ -119,7 +119,6 @@ void btrfs_kill_delayed_inode_items(struct inode *inode); int btrfs_delayed_update_inode(struct btrfs_trans_handle *trans, struct btrfs_root *root, struct inode *inode); -int btrfs_fill_inode(struct inode *inode, u32 *rdev); /* Used for drop dead root */ void btrfs_kill_all_delayed_nodes(struct btrfs_root *root); diff --git a/trunk/fs/btrfs/extent-tree.c b/trunk/fs/btrfs/extent-tree.c index 71cd456fdb60..1f61bf5b4960 100644 --- a/trunk/fs/btrfs/extent-tree.c +++ b/trunk/fs/btrfs/extent-tree.c @@ -4842,7 +4842,7 @@ static noinline int find_free_extent(struct btrfs_trans_handle *trans, u64 num_bytes, u64 empty_size, u64 search_start, u64 search_end, u64 hint_byte, struct btrfs_key *ins, - u64 data) + int data) { int ret = 0; struct btrfs_root *root = orig_root->fs_info->extent_root; @@ -4869,7 +4869,7 @@ static noinline int find_free_extent(struct btrfs_trans_handle *trans, space_info = __find_space_info(root->fs_info, data); if (!space_info) { - printk(KERN_ERR "No space info for %llu\n", data); + printk(KERN_ERR "No space info for %d\n", data); return -ENOSPC; } diff --git a/trunk/fs/btrfs/free-space-cache.c b/trunk/fs/btrfs/free-space-cache.c index bf0d61567f3d..9f985a429877 100644 --- a/trunk/fs/btrfs/free-space-cache.c +++ b/trunk/fs/btrfs/free-space-cache.c @@ -1893,12 +1893,9 @@ void __btrfs_remove_free_space_cache_locked(struct btrfs_free_space_ctl *ctl) while ((node = rb_last(&ctl->free_space_offset)) != NULL) { info = rb_entry(node, struct btrfs_free_space, offset_index); - if (!info->bitmap) { - unlink_free_space(ctl, info); - kmem_cache_free(btrfs_free_space_cachep, info); - } else { - free_bitmap(ctl, info); - } + unlink_free_space(ctl, info); + kfree(info->bitmap); + kmem_cache_free(btrfs_free_space_cachep, info); if (need_resched()) { spin_unlock(&ctl->tree_lock); cond_resched(); diff --git a/trunk/fs/btrfs/inode.c b/trunk/fs/btrfs/inode.c index 3601f0aebddf..0a9b10c5b0a7 100644 --- a/trunk/fs/btrfs/inode.c +++ b/trunk/fs/btrfs/inode.c @@ -2509,11 +2509,6 @@ static void btrfs_read_locked_inode(struct inode *inode) int maybe_acls; u32 rdev; int ret; - bool filled = false; - - ret = btrfs_fill_inode(inode, &rdev); - if (!ret) - filled = true; path = btrfs_alloc_path(); BUG_ON(!path); @@ -2525,10 +2520,6 @@ static void btrfs_read_locked_inode(struct inode *inode) goto make_bad; leaf = path->nodes[0]; - - if (filled) - goto cache_acl; - inode_item = btrfs_item_ptr(leaf, path->slots[0], struct btrfs_inode_item); if (!leaf->map_token) @@ -2565,7 +2556,7 @@ static void btrfs_read_locked_inode(struct inode *inode) BTRFS_I(inode)->index_cnt = (u64)-1; BTRFS_I(inode)->flags = btrfs_inode_flags(leaf, inode_item); -cache_acl: + /* * try to precache a NULL acl entry for files that don't have * any xattrs or acls @@ -2581,6 +2572,7 @@ static void btrfs_read_locked_inode(struct inode *inode) } btrfs_free_path(path); + inode_item = NULL; switch (inode->i_mode & S_IFMT) { case S_IFREG: @@ -2678,14 +2670,12 @@ noinline int btrfs_update_inode(struct btrfs_trans_handle *trans, int ret; /* - * If the inode is a free space inode, we can deadlock during commit - * if we put it into the delayed code. - * - * The data relocation inode should also be directly updated - * without delay + * If root is tree root, it means this inode is used to + * store free space information. And these inodes are updated + * when committing the transaction, so they needn't delaye to + * be updated, or deadlock will occured. */ - if (!is_free_space_inode(root, inode) - && root->root_key.objectid != BTRFS_DATA_RELOC_TREE_OBJECTID) { + if (!is_free_space_inode(root, inode)) { ret = btrfs_delayed_update_inode(trans, root, inode); if (!ret) btrfs_set_inode_last_trans(trans, inode); @@ -4530,7 +4520,6 @@ static struct inode *btrfs_new_inode(struct btrfs_trans_handle *trans, inode_tree_add(inode); trace_btrfs_inode_new(inode); - btrfs_set_inode_last_trans(trans, inode); return inode; fail: diff --git a/trunk/fs/btrfs/super.c b/trunk/fs/btrfs/super.c index 15634d4648d7..0bb4ebbb71b7 100644 --- a/trunk/fs/btrfs/super.c +++ b/trunk/fs/btrfs/super.c @@ -723,12 +723,6 @@ static int btrfs_show_options(struct seq_file *seq, struct vfsmount *vfs) seq_puts(seq, ",clear_cache"); if (btrfs_test_opt(root, USER_SUBVOL_RM_ALLOWED)) seq_puts(seq, ",user_subvol_rm_allowed"); - if (btrfs_test_opt(root, ENOSPC_DEBUG)) - seq_puts(seq, ",enospc_debug"); - if (btrfs_test_opt(root, AUTO_DEFRAG)) - seq_puts(seq, ",autodefrag"); - if (btrfs_test_opt(root, INODE_MAP_CACHE)) - seq_puts(seq, ",inode_cache"); return 0; } diff --git a/trunk/fs/btrfs/volumes.c b/trunk/fs/btrfs/volumes.c index 19450bc53632..1efa56e18f9b 100644 --- a/trunk/fs/btrfs/volumes.c +++ b/trunk/fs/btrfs/volumes.c @@ -2098,8 +2098,7 @@ int btrfs_balance(struct btrfs_root *dev_root) chunk_root->root_key.objectid, found_key.objectid, found_key.offset); - if (ret && ret != -ENOSPC) - goto error; + BUG_ON(ret && ret != -ENOSPC); key.offset = found_key.offset - 1; } ret = 0; diff --git a/trunk/fs/ceph/file.c b/trunk/fs/ceph/file.c index 4698a5c553dc..9542f07d0b93 100644 --- a/trunk/fs/ceph/file.c +++ b/trunk/fs/ceph/file.c @@ -290,6 +290,7 @@ static int striped_read(struct inode *inode, struct ceph_inode_info *ci = ceph_inode(inode); u64 pos, this_len; int io_align, page_align; + int page_off = off & ~PAGE_CACHE_MASK; /* first byte's offset in page */ int left, pages_left; int read; struct page **page_pos; @@ -325,11 +326,12 @@ static int striped_read(struct inode *inode, ret, hit_stripe ? " HITSTRIPE" : "", was_short ? " SHORT" : ""); if (ret > 0) { - int didpages = (page_align + ret) >> PAGE_CACHE_SHIFT; + int didpages = + ((pos & ~PAGE_CACHE_MASK) + ret) >> PAGE_CACHE_SHIFT; if (read < pos - off) { dout(" zero gap %llu to %llu\n", off + read, pos); - ceph_zero_page_vector_range(page_align + read, + ceph_zero_page_vector_range(page_off + read, pos - off - read, pages); } pos += ret; @@ -354,7 +356,7 @@ static int striped_read(struct inode *inode, left = inode->i_size - pos; dout("zero tail %d\n", left); - ceph_zero_page_vector_range(page_align + read, left, + ceph_zero_page_vector_range(page_off + read, left, pages); read += left; } @@ -476,6 +478,9 @@ static ssize_t ceph_sync_write(struct file *file, const char __user *data, else pos = *offset; + io_align = pos & ~PAGE_MASK; + buf_align = (unsigned long)data & ~PAGE_MASK; + ret = filemap_write_and_wait_range(inode->i_mapping, pos, pos + left); if (ret < 0) return ret; @@ -499,8 +504,6 @@ static ssize_t ceph_sync_write(struct file *file, const char __user *data, * boundary. this isn't atomic, unfortunately. :( */ more: - io_align = pos & ~PAGE_MASK; - buf_align = (unsigned long)data & ~PAGE_MASK; len = left; if (file->f_flags & O_DIRECT) { /* write from beginning of first page, regardless of @@ -590,7 +593,6 @@ static ssize_t ceph_sync_write(struct file *file, const char __user *data, pos += len; written += len; left -= len; - data += written; if (left) goto more; diff --git a/trunk/fs/cifs/Kconfig b/trunk/fs/cifs/Kconfig index f66cc1625150..53ed1ad2c112 100644 --- a/trunk/fs/cifs/Kconfig +++ b/trunk/fs/cifs/Kconfig @@ -156,6 +156,6 @@ config CIFS_ACL config CIFS_NFSD_EXPORT bool "Allow nfsd to export CIFS file system (EXPERIMENTAL)" - depends on CIFS && EXPERIMENTAL && BROKEN + depends on CIFS && EXPERIMENTAL help Allows NFS server to export a CIFS mounted share (nfsd over cifs) diff --git a/trunk/fs/cifs/cifs_fs_sb.h b/trunk/fs/cifs/cifs_fs_sb.h index 7260e11e21f8..ffb1459dc6ec 100644 --- a/trunk/fs/cifs/cifs_fs_sb.h +++ b/trunk/fs/cifs/cifs_fs_sb.h @@ -42,7 +42,6 @@ #define CIFS_MOUNT_MULTIUSER 0x20000 /* multiuser mount */ #define CIFS_MOUNT_STRICT_IO 0x40000 /* strict cache mode */ #define CIFS_MOUNT_RWPIDFORWARD 0x80000 /* use pid forwarding for rw */ -#define CIFS_MOUNT_POSIXACL 0x100000 /* mirror of MS_POSIXACL in mnt_cifs_flags */ struct cifs_sb_info { struct rb_root tlink_tree; diff --git a/trunk/fs/cifs/cifsfs.c b/trunk/fs/cifs/cifsfs.c index 3e2989976297..2f0c58646c10 100644 --- a/trunk/fs/cifs/cifsfs.c +++ b/trunk/fs/cifs/cifsfs.c @@ -104,7 +104,8 @@ cifs_sb_deactive(struct super_block *sb) } static int -cifs_read_super(struct super_block *sb) +cifs_read_super(struct super_block *sb, struct smb_vol *volume_info, + const char *devname, int silent) { struct inode *inode; struct cifs_sb_info *cifs_sb; @@ -112,16 +113,22 @@ cifs_read_super(struct super_block *sb) cifs_sb = CIFS_SB(sb); - if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIXACL) - sb->s_flags |= MS_POSIXACL; + spin_lock_init(&cifs_sb->tlink_tree_lock); + cifs_sb->tlink_tree = RB_ROOT; - if (cifs_sb_master_tcon(cifs_sb)->ses->capabilities & CAP_LARGE_FILES) - sb->s_maxbytes = MAX_LFS_FILESIZE; - else - sb->s_maxbytes = MAX_NON_LFS; + rc = bdi_setup_and_register(&cifs_sb->bdi, "cifs", BDI_CAP_MAP_COPY); + if (rc) + return rc; + + cifs_sb->bdi.ra_pages = default_backing_dev_info.ra_pages; - /* BB FIXME fix time_gran to be larger for LANMAN sessions */ - sb->s_time_gran = 100; + rc = cifs_mount(sb, cifs_sb, volume_info, devname); + + if (rc) { + if (!silent) + cERROR(1, "cifs_mount failed w/return code = %d", rc); + goto out_mount_failed; + } sb->s_magic = CIFS_MAGIC_NUMBER; sb->s_op = &cifs_super_ops; @@ -163,14 +170,37 @@ cifs_read_super(struct super_block *sb) if (inode) iput(inode); + cifs_umount(sb, cifs_sb); + +out_mount_failed: + bdi_destroy(&cifs_sb->bdi); return rc; } -static void cifs_kill_sb(struct super_block *sb) +static void +cifs_put_super(struct super_block *sb) { - struct cifs_sb_info *cifs_sb = CIFS_SB(sb); - kill_anon_super(sb); - cifs_umount(cifs_sb); + int rc = 0; + struct cifs_sb_info *cifs_sb; + + cFYI(1, "In cifs_put_super"); + cifs_sb = CIFS_SB(sb); + if (cifs_sb == NULL) { + cFYI(1, "Empty cifs superblock info passed to unmount"); + return; + } + + rc = cifs_umount(sb, cifs_sb); + if (rc) + cERROR(1, "cifs_umount failed with return code %d", rc); + if (cifs_sb->mountdata) { + kfree(cifs_sb->mountdata); + cifs_sb->mountdata = NULL; + } + + unload_nls(cifs_sb->local_nls); + bdi_destroy(&cifs_sb->bdi); + kfree(cifs_sb); } static int @@ -518,6 +548,7 @@ static int cifs_drop_inode(struct inode *inode) } static const struct super_operations cifs_super_ops = { + .put_super = cifs_put_super, .statfs = cifs_statfs, .alloc_inode = cifs_alloc_inode, .destroy_inode = cifs_destroy_inode, @@ -554,7 +585,7 @@ cifs_get_root(struct smb_vol *vol, struct super_block *sb) full_path = cifs_build_path_to_root(vol, cifs_sb, cifs_sb_master_tcon(cifs_sb)); if (full_path == NULL) - return ERR_PTR(-ENOMEM); + return NULL; cFYI(1, "Get root dentry for %s", full_path); @@ -583,7 +614,7 @@ cifs_get_root(struct smb_vol *vol, struct super_block *sb) dchild = d_alloc(dparent, &name); if (dchild == NULL) { dput(dparent); - dparent = ERR_PTR(-ENOMEM); + dparent = NULL; goto out; } } @@ -601,7 +632,7 @@ cifs_get_root(struct smb_vol *vol, struct super_block *sb) if (rc) { dput(dchild); dput(dparent); - dparent = ERR_PTR(rc); + dparent = NULL; goto out; } alias = d_materialise_unique(dchild, inode); @@ -609,7 +640,7 @@ cifs_get_root(struct smb_vol *vol, struct super_block *sb) dput(dchild); if (IS_ERR(alias)) { dput(dparent); - dparent = ERR_PTR(-EINVAL); /* XXX */ + dparent = NULL; goto out; } dchild = alias; @@ -629,13 +660,6 @@ cifs_get_root(struct smb_vol *vol, struct super_block *sb) return dparent; } -static int cifs_set_super(struct super_block *sb, void *data) -{ - struct cifs_mnt_data *mnt_data = data; - sb->s_fs_info = mnt_data->cifs_sb; - return set_anon_super(sb, NULL); -} - static struct dentry * cifs_do_mount(struct file_system_type *fs_type, int flags, const char *dev_name, void *data) @@ -649,80 +673,82 @@ cifs_do_mount(struct file_system_type *fs_type, cFYI(1, "Devname: %s flags: %d ", dev_name, flags); - volume_info = cifs_get_volume_info((char *)data, dev_name); - if (IS_ERR(volume_info)) - return ERR_CAST(volume_info); + rc = cifs_setup_volume_info(&volume_info, (char *)data, dev_name); + if (rc) + return ERR_PTR(rc); cifs_sb = kzalloc(sizeof(struct cifs_sb_info), GFP_KERNEL); if (cifs_sb == NULL) { root = ERR_PTR(-ENOMEM); - goto out_nls; - } - - cifs_sb->mountdata = kstrndup(data, PAGE_SIZE, GFP_KERNEL); - if (cifs_sb->mountdata == NULL) { - root = ERR_PTR(-ENOMEM); - goto out_cifs_sb; + goto out; } cifs_setup_cifs_sb(volume_info, cifs_sb); - rc = cifs_mount(cifs_sb, volume_info); - if (rc) { - if (!(flags & MS_SILENT)) - cERROR(1, "cifs_mount failed w/return code = %d", rc); - root = ERR_PTR(rc); - goto out_mountdata; - } - mnt_data.vol = volume_info; mnt_data.cifs_sb = cifs_sb; mnt_data.flags = flags; - sb = sget(fs_type, cifs_match_super, cifs_set_super, &mnt_data); + sb = sget(fs_type, cifs_match_super, set_anon_super, &mnt_data); if (IS_ERR(sb)) { root = ERR_CAST(sb); - cifs_umount(cifs_sb); - goto out; + goto out_cifs_sb; } - if (sb->s_root) { + if (sb->s_fs_info) { cFYI(1, "Use existing superblock"); - cifs_umount(cifs_sb); - } else { - sb->s_flags = flags; - /* BB should we make this contingent on mount parm? */ - sb->s_flags |= MS_NODIRATIME | MS_NOATIME; - - rc = cifs_read_super(sb); - if (rc) { - root = ERR_PTR(rc); - goto out_super; - } + goto out_shared; + } + + /* + * Copy mount params for use in submounts. Better to do + * the copy here and deal with the error before cleanup gets + * complicated post-mount. + */ + cifs_sb->mountdata = kstrndup(data, PAGE_SIZE, GFP_KERNEL); + if (cifs_sb->mountdata == NULL) { + root = ERR_PTR(-ENOMEM); + goto out_super; + } + + sb->s_flags = flags; + /* BB should we make this contingent on mount parm? */ + sb->s_flags |= MS_NODIRATIME | MS_NOATIME; + sb->s_fs_info = cifs_sb; - sb->s_flags |= MS_ACTIVE; + rc = cifs_read_super(sb, volume_info, dev_name, + flags & MS_SILENT ? 1 : 0); + if (rc) { + root = ERR_PTR(rc); + goto out_super; } + sb->s_flags |= MS_ACTIVE; + root = cifs_get_root(volume_info, sb); - if (IS_ERR(root)) + if (root == NULL) goto out_super; cFYI(1, "dentry root is: %p", root); goto out; +out_shared: + root = cifs_get_root(volume_info, sb); + if (root) + cFYI(1, "dentry root is: %p", root); + goto out; + out_super: + kfree(cifs_sb->mountdata); deactivate_locked_super(sb); -out: - cifs_cleanup_volume_info(volume_info); - return root; -out_mountdata: - kfree(cifs_sb->mountdata); out_cifs_sb: + unload_nls(cifs_sb->local_nls); kfree(cifs_sb); -out_nls: - unload_nls(volume_info->local_nls); - goto out; + +out: + cifs_cleanup_volume_info(&volume_info); + return root; } static ssize_t cifs_file_aio_write(struct kiocb *iocb, const struct iovec *iov, @@ -811,7 +837,7 @@ struct file_system_type cifs_fs_type = { .owner = THIS_MODULE, .name = "cifs", .mount = cifs_do_mount, - .kill_sb = cifs_kill_sb, + .kill_sb = kill_anon_super, /* .fs_flags */ }; const struct inode_operations cifs_dir_inode_ops = { diff --git a/trunk/fs/cifs/cifsproto.h b/trunk/fs/cifs/cifsproto.h index 8df28e925e5b..953f84413c77 100644 --- a/trunk/fs/cifs/cifsproto.h +++ b/trunk/fs/cifs/cifsproto.h @@ -154,11 +154,12 @@ extern int set_cifs_acl(struct cifs_ntsd *, __u32, struct inode *, extern void cifs_setup_cifs_sb(struct smb_vol *pvolume_info, struct cifs_sb_info *cifs_sb); extern int cifs_match_super(struct super_block *, void *); -extern void cifs_cleanup_volume_info(struct smb_vol *pvolume_info); -extern struct smb_vol *cifs_get_volume_info(char *mount_data, - const char *devname); -extern int cifs_mount(struct cifs_sb_info *, struct smb_vol *); -extern void cifs_umount(struct cifs_sb_info *); +extern void cifs_cleanup_volume_info(struct smb_vol **pvolume_info); +extern int cifs_setup_volume_info(struct smb_vol **pvolume_info, + char *mount_data, const char *devname); +extern int cifs_mount(struct super_block *, struct cifs_sb_info *, + struct smb_vol *, const char *); +extern int cifs_umount(struct super_block *, struct cifs_sb_info *); extern void cifs_dfs_release_automount_timer(void); void cifs_proc_init(void); void cifs_proc_clean(void); @@ -217,8 +218,7 @@ extern int get_dfs_path(int xid, struct cifs_ses *pSesInfo, struct dfs_info3_param **preferrals, int remap); extern void reset_cifs_unix_caps(int xid, struct cifs_tcon *tcon, - struct cifs_sb_info *cifs_sb, - struct smb_vol *vol); + struct super_block *sb, struct smb_vol *vol); extern int CIFSSMBQFSInfo(const int xid, struct cifs_tcon *tcon, struct kstatfs *FSData); extern int SMBOldQFSInfo(const int xid, struct cifs_tcon *tcon, diff --git a/trunk/fs/cifs/connect.c b/trunk/fs/cifs/connect.c index dbd669cc5bc7..12cf72dd0c42 100644 --- a/trunk/fs/cifs/connect.c +++ b/trunk/fs/cifs/connect.c @@ -65,8 +65,6 @@ static int ip_connect(struct TCP_Server_Info *server); static int generic_ip_connect(struct TCP_Server_Info *server); static void tlink_rb_insert(struct rb_root *root, struct tcon_link *new_tlink); static void cifs_prune_tlinks(struct work_struct *work); -static int cifs_setup_volume_info(struct smb_vol *volume_info, char *mount_data, - const char *devname); /* * cifs tcp session reconnection @@ -2242,8 +2240,8 @@ cifs_match_super(struct super_block *sb, void *data) rc = compare_mount_options(sb, mnt_data); out: - spin_unlock(&cifs_tcp_ses_lock); cifs_put_tlink(tlink); + spin_unlock(&cifs_tcp_ses_lock); return rc; } @@ -2476,6 +2474,14 @@ generic_ip_connect(struct TCP_Server_Info *server) if (rc < 0) return rc; + rc = socket->ops->connect(socket, saddr, slen, 0); + if (rc < 0) { + cFYI(1, "Error %d connecting to server", rc); + sock_release(socket); + server->ssocket = NULL; + return rc; + } + /* * Eventually check for other socket options to change from * the default. sock_setsockopt not used because it expects @@ -2504,14 +2510,6 @@ generic_ip_connect(struct TCP_Server_Info *server) socket->sk->sk_sndbuf, socket->sk->sk_rcvbuf, socket->sk->sk_rcvtimeo); - rc = socket->ops->connect(socket, saddr, slen, 0); - if (rc < 0) { - cFYI(1, "Error %d connecting to server", rc); - sock_release(socket); - server->ssocket = NULL; - return rc; - } - if (sport == htons(RFC1001_PORT)) rc = ip_rfc1001_connect(server); @@ -2548,7 +2546,7 @@ ip_connect(struct TCP_Server_Info *server) } void reset_cifs_unix_caps(int xid, struct cifs_tcon *tcon, - struct cifs_sb_info *cifs_sb, struct smb_vol *vol_info) + struct super_block *sb, struct smb_vol *vol_info) { /* if we are reconnecting then should we check to see if * any requested capabilities changed locally e.g. via @@ -2602,23 +2600,22 @@ void reset_cifs_unix_caps(int xid, struct cifs_tcon *tcon, cap &= ~CIFS_UNIX_POSIX_ACL_CAP; else if (CIFS_UNIX_POSIX_ACL_CAP & cap) { cFYI(1, "negotiated posix acl support"); - if (cifs_sb) - cifs_sb->mnt_cifs_flags |= - CIFS_MOUNT_POSIXACL; + if (sb) + sb->s_flags |= MS_POSIXACL; } if (vol_info && vol_info->posix_paths == 0) cap &= ~CIFS_UNIX_POSIX_PATHNAMES_CAP; else if (cap & CIFS_UNIX_POSIX_PATHNAMES_CAP) { cFYI(1, "negotiate posix pathnames"); - if (cifs_sb) - cifs_sb->mnt_cifs_flags |= + if (sb) + CIFS_SB(sb)->mnt_cifs_flags |= CIFS_MOUNT_POSIX_PATHS; } - if (cifs_sb && (cifs_sb->rsize > 127 * 1024)) { + if (sb && (CIFS_SB(sb)->rsize > 127 * 1024)) { if ((cap & CIFS_UNIX_LARGE_READ_CAP) == 0) { - cifs_sb->rsize = 127 * 1024; + CIFS_SB(sb)->rsize = 127 * 1024; cFYI(DBG2, "larger reads not supported by srv"); } } @@ -2665,9 +2662,6 @@ void cifs_setup_cifs_sb(struct smb_vol *pvolume_info, { INIT_DELAYED_WORK(&cifs_sb->prune_tlinks, cifs_prune_tlinks); - spin_lock_init(&cifs_sb->tlink_tree_lock); - cifs_sb->tlink_tree = RB_ROOT; - if (pvolume_info->rsize > CIFSMaxBufSize) { cERROR(1, "rsize %d too large, using MaxBufSize", pvolume_info->rsize); @@ -2756,21 +2750,21 @@ void cifs_setup_cifs_sb(struct smb_vol *pvolume_info, /* * When the server supports very large writes via POSIX extensions, we can - * allow up to 2^24-1, minus the size of a WRITE_AND_X header, not including - * the RFC1001 length. + * allow up to 2^24 - PAGE_CACHE_SIZE. * * Note that this might make for "interesting" allocation problems during - * writeback however as we have to allocate an array of pointers for the - * pages. A 16M write means ~32kb page array with PAGE_CACHE_SIZE == 4096. + * writeback however (as we have to allocate an array of pointers for the + * pages). A 16M write means ~32kb page array with PAGE_CACHE_SIZE == 4096. */ -#define CIFS_MAX_WSIZE ((1<<24) - 1 - sizeof(WRITE_REQ) + 4) +#define CIFS_MAX_WSIZE ((1<<24) - PAGE_CACHE_SIZE) /* - * When the server doesn't allow large posix writes, only allow a wsize of - * 128k minus the size of the WRITE_AND_X header. That allows for a write up - * to the maximum size described by RFC1002. + * When the server doesn't allow large posix writes, default to a wsize of + * 128k - PAGE_CACHE_SIZE -- one page less than the largest frame size + * described in RFC1001. This allows space for the header without going over + * that by default. */ -#define CIFS_MAX_RFC1002_WSIZE (128 * 1024 - sizeof(WRITE_REQ) + 4) +#define CIFS_MAX_RFC1001_WSIZE (128 * 1024 - PAGE_CACHE_SIZE) /* * The default wsize is 1M. find_get_pages seems to return a maximum of 256 @@ -2789,18 +2783,11 @@ cifs_negotiate_wsize(struct cifs_tcon *tcon, struct smb_vol *pvolume_info) /* can server support 24-bit write sizes? (via UNIX extensions) */ if (!tcon->unix_ext || !(unix_cap & CIFS_UNIX_LARGE_WRITE_CAP)) - wsize = min_t(unsigned int, wsize, CIFS_MAX_RFC1002_WSIZE); + wsize = min_t(unsigned int, wsize, CIFS_MAX_RFC1001_WSIZE); - /* - * no CAP_LARGE_WRITE_X or is signing enabled without CAP_UNIX set? - * Limit it to max buffer offered by the server, minus the size of the - * WRITEX header, not including the 4 byte RFC1001 length. - */ - if (!(server->capabilities & CAP_LARGE_WRITE_X) || - (!(server->capabilities & CAP_UNIX) && - (server->sec_mode & (SECMODE_SIGN_ENABLED|SECMODE_SIGN_REQUIRED)))) - wsize = min_t(unsigned int, wsize, - server->maxBuf - sizeof(WRITE_REQ) + 4); + /* no CAP_LARGE_WRITE_X? Limit it to 16 bits */ + if (!(server->capabilities & CAP_LARGE_WRITE_X)) + wsize = min_t(unsigned int, wsize, USHRT_MAX); /* hard limit of CIFS_MAX_WSIZE */ wsize = min_t(unsigned int, wsize, CIFS_MAX_WSIZE); @@ -2832,9 +2819,15 @@ is_path_accessible(int xid, struct cifs_tcon *tcon, return rc; } -static void -cleanup_volume_info_contents(struct smb_vol *volume_info) +void +cifs_cleanup_volume_info(struct smb_vol **pvolume_info) { + struct smb_vol *volume_info; + + if (!pvolume_info || !*pvolume_info) + return; + + volume_info = *pvolume_info; kfree(volume_info->username); kzfree(volume_info->password); kfree(volume_info->UNC); @@ -2842,44 +2835,28 @@ cleanup_volume_info_contents(struct smb_vol *volume_info) kfree(volume_info->domainname); kfree(volume_info->iocharset); kfree(volume_info->prepath); -} - -void -cifs_cleanup_volume_info(struct smb_vol *volume_info) -{ - if (!volume_info) - return; - cleanup_volume_info_contents(volume_info); kfree(volume_info); + *pvolume_info = NULL; + return; } - #ifdef CONFIG_CIFS_DFS_UPCALL /* build_path_to_root returns full path to root when * we do not have an exiting connection (tcon) */ static char * -build_unc_path_to_root(const struct smb_vol *vol, +build_unc_path_to_root(const struct smb_vol *volume_info, const struct cifs_sb_info *cifs_sb) { - char *full_path, *pos; - unsigned int pplen = vol->prepath ? strlen(vol->prepath) : 0; - unsigned int unc_len = strnlen(vol->UNC, MAX_TREE_SIZE + 1); + char *full_path; - full_path = kmalloc(unc_len + pplen + 1, GFP_KERNEL); + int unc_len = strnlen(volume_info->UNC, MAX_TREE_SIZE + 1); + full_path = kmalloc(unc_len + 1, GFP_KERNEL); if (full_path == NULL) return ERR_PTR(-ENOMEM); - strncpy(full_path, vol->UNC, unc_len); - pos = full_path + unc_len; - - if (pplen) { - strncpy(pos, vol->prepath, pplen); - pos += pplen; - } - - *pos = '\0'; /* add trailing null */ + strncpy(full_path, volume_info->UNC, unc_len); + full_path[unc_len] = 0; /* add trailing null */ convert_delimiter(full_path, CIFS_DIR_SEP(cifs_sb)); - cFYI(1, "%s: full_path=%s", __func__, full_path); return full_path; } @@ -2922,18 +2899,15 @@ expand_dfs_referral(int xid, struct cifs_ses *pSesInfo, &fake_devname); free_dfs_info_array(referrals, num_referrals); + kfree(fake_devname); + + if (cifs_sb->mountdata != NULL) + kfree(cifs_sb->mountdata); if (IS_ERR(mdata)) { rc = PTR_ERR(mdata); mdata = NULL; - } else { - cleanup_volume_info_contents(volume_info); - memset(volume_info, '\0', sizeof(*volume_info)); - rc = cifs_setup_volume_info(volume_info, mdata, - fake_devname); } - kfree(fake_devname); - kfree(cifs_sb->mountdata); cifs_sb->mountdata = mdata; } kfree(full_path); @@ -2941,20 +2915,29 @@ expand_dfs_referral(int xid, struct cifs_ses *pSesInfo, } #endif -static int -cifs_setup_volume_info(struct smb_vol *volume_info, char *mount_data, - const char *devname) +int cifs_setup_volume_info(struct smb_vol **pvolume_info, char *mount_data, + const char *devname) { + struct smb_vol *volume_info; int rc = 0; - if (cifs_parse_mount_options(mount_data, devname, volume_info)) - return -EINVAL; + *pvolume_info = NULL; + + volume_info = kzalloc(sizeof(struct smb_vol), GFP_KERNEL); + if (!volume_info) { + rc = -ENOMEM; + goto out; + } + + if (cifs_parse_mount_options(mount_data, devname, + volume_info)) { + rc = -EINVAL; + goto out; + } if (volume_info->nullauth) { cFYI(1, "null user"); - volume_info->username = kzalloc(1, GFP_KERNEL); - if (volume_info->username == NULL) - return -ENOMEM; + volume_info->username = ""; } else if (volume_info->username) { /* BB fixme parse for domain name here */ cFYI(1, "Username: %s", volume_info->username); @@ -2962,7 +2945,8 @@ cifs_setup_volume_info(struct smb_vol *volume_info, char *mount_data, cifserror("No username specified"); /* In userspace mount helper we can get user name from alternate locations such as env variables and files on disk */ - return -EINVAL; + rc = -EINVAL; + goto out; } /* this is needed for ASCII cp to Unicode converts */ @@ -2974,34 +2958,21 @@ cifs_setup_volume_info(struct smb_vol *volume_info, char *mount_data, if (volume_info->local_nls == NULL) { cERROR(1, "CIFS mount error: iocharset %s not found", volume_info->iocharset); - return -ELIBACC; + rc = -ELIBACC; + goto out; } } + *pvolume_info = volume_info; + return rc; +out: + cifs_cleanup_volume_info(&volume_info); return rc; -} - -struct smb_vol * -cifs_get_volume_info(char *mount_data, const char *devname) -{ - int rc; - struct smb_vol *volume_info; - - volume_info = kzalloc(sizeof(struct smb_vol), GFP_KERNEL); - if (!volume_info) - return ERR_PTR(-ENOMEM); - - rc = cifs_setup_volume_info(volume_info, mount_data, devname); - if (rc) { - cifs_cleanup_volume_info(volume_info); - volume_info = ERR_PTR(rc); - } - - return volume_info; } int -cifs_mount(struct cifs_sb_info *cifs_sb, struct smb_vol *volume_info) +cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, + struct smb_vol *volume_info, const char *devname) { int rc = 0; int xid; @@ -3012,15 +2983,6 @@ cifs_mount(struct cifs_sb_info *cifs_sb, struct smb_vol *volume_info) struct tcon_link *tlink; #ifdef CONFIG_CIFS_DFS_UPCALL int referral_walks_count = 0; -#endif - - rc = bdi_setup_and_register(&cifs_sb->bdi, "cifs", BDI_CAP_MAP_COPY); - if (rc) - return rc; - - cifs_sb->bdi.ra_pages = default_backing_dev_info.ra_pages; - -#ifdef CONFIG_CIFS_DFS_UPCALL try_mount_again: /* cleanup activities if we're chasing a referral */ if (referral_walks_count) { @@ -3029,6 +2991,7 @@ cifs_mount(struct cifs_sb_info *cifs_sb, struct smb_vol *volume_info) else if (pSesInfo) cifs_put_smb_ses(pSesInfo); + cifs_cleanup_volume_info(&volume_info); FreeXid(xid); } #endif @@ -3044,7 +3007,6 @@ cifs_mount(struct cifs_sb_info *cifs_sb, struct smb_vol *volume_info) srvTcp = cifs_get_tcp_session(volume_info); if (IS_ERR(srvTcp)) { rc = PTR_ERR(srvTcp); - bdi_destroy(&cifs_sb->bdi); goto out; } @@ -3056,6 +3018,14 @@ cifs_mount(struct cifs_sb_info *cifs_sb, struct smb_vol *volume_info) goto mount_fail_check; } + if (pSesInfo->capabilities & CAP_LARGE_FILES) + sb->s_maxbytes = MAX_LFS_FILESIZE; + else + sb->s_maxbytes = MAX_NON_LFS; + + /* BB FIXME fix time_gran to be larger for LANMAN sessions */ + sb->s_time_gran = 100; + /* search for existing tcon to this server share */ tcon = cifs_get_tcon(pSesInfo, volume_info); if (IS_ERR(tcon)) { @@ -3068,7 +3038,7 @@ cifs_mount(struct cifs_sb_info *cifs_sb, struct smb_vol *volume_info) if (tcon->ses->capabilities & CAP_UNIX) { /* reset of caps checks mount to see if unix extensions disabled for just this mount */ - reset_cifs_unix_caps(xid, tcon, cifs_sb, volume_info); + reset_cifs_unix_caps(xid, tcon, sb, volume_info); if ((tcon->ses->server->tcpStatus == CifsNeedReconnect) && (le64_to_cpu(tcon->fsUnixInfo.Capability) & CIFS_UNIX_TRANSPORT_ENCRYPTION_MANDATORY_CAP)) { @@ -3191,7 +3161,6 @@ cifs_mount(struct cifs_sb_info *cifs_sb, struct smb_vol *volume_info) cifs_put_smb_ses(pSesInfo); else cifs_put_tcp_session(srvTcp); - bdi_destroy(&cifs_sb->bdi); goto out; } @@ -3366,8 +3335,8 @@ CIFSTCon(unsigned int xid, struct cifs_ses *ses, return rc; } -void -cifs_umount(struct cifs_sb_info *cifs_sb) +int +cifs_umount(struct super_block *sb, struct cifs_sb_info *cifs_sb) { struct rb_root *root = &cifs_sb->tlink_tree; struct rb_node *node; @@ -3388,10 +3357,7 @@ cifs_umount(struct cifs_sb_info *cifs_sb) } spin_unlock(&cifs_sb->tlink_tree_lock); - bdi_destroy(&cifs_sb->bdi); - kfree(cifs_sb->mountdata); - unload_nls(cifs_sb->local_nls); - kfree(cifs_sb); + return 0; } int cifs_negotiate_protocol(unsigned int xid, struct cifs_ses *ses) diff --git a/trunk/fs/cifs/fscache.c b/trunk/fs/cifs/fscache.c index 42e5363b4102..816696621ec9 100644 --- a/trunk/fs/cifs/fscache.c +++ b/trunk/fs/cifs/fscache.c @@ -92,7 +92,6 @@ static void cifs_fscache_disable_inode_cookie(struct inode *inode) if (cifsi->fscache) { cFYI(1, "%s: (0x%p)", __func__, cifsi->fscache); - fscache_uncache_all_inode_pages(cifsi->fscache, inode); fscache_relinquish_cookie(cifsi->fscache, 1); cifsi->fscache = NULL; } diff --git a/trunk/fs/cifs/smbencrypt.c b/trunk/fs/cifs/smbencrypt.c index 1c5b770c3141..1525d5e662b6 100644 --- a/trunk/fs/cifs/smbencrypt.c +++ b/trunk/fs/cifs/smbencrypt.c @@ -90,10 +90,12 @@ smbhash(unsigned char *out, const unsigned char *in, unsigned char *key) sg_init_one(&sgout, out, 8); rc = crypto_blkcipher_encrypt(&desc, &sgout, &sgin, 8); - if (rc) + if (rc) { cERROR(1, "could not encrypt crypt key rc: %d\n", rc); + crypto_free_blkcipher(tfm_des); + goto smbhash_err; + } - crypto_free_blkcipher(tfm_des); smbhash_err: return rc; } diff --git a/trunk/fs/ext4/ext4_extents.h b/trunk/fs/ext4/ext4_extents.h index 095c36f3b612..2e29abb30f76 100644 --- a/trunk/fs/ext4/ext4_extents.h +++ b/trunk/fs/ext4/ext4_extents.h @@ -125,7 +125,7 @@ struct ext4_ext_path { * positive retcode - signal for ext4_ext_walk_space(), see below * callback must return valid extent (passed or newly created) */ -typedef int (*ext_prepare_callback)(struct inode *, ext4_lblk_t, +typedef int (*ext_prepare_callback)(struct inode *, struct ext4_ext_path *, struct ext4_ext_cache *, struct ext4_extent *, void *); @@ -133,11 +133,8 @@ typedef int (*ext_prepare_callback)(struct inode *, ext4_lblk_t, #define EXT_BREAK 1 #define EXT_REPEAT 2 -/* - * Maximum number of logical blocks in a file; ext4_extent's ee_block is - * __le32. - */ -#define EXT_MAX_BLOCKS 0xffffffff +/* Maximum logical block in a file; ext4_extent's ee_block is __le32 */ +#define EXT_MAX_BLOCK 0xffffffff /* * EXT_INIT_MAX_LEN is the maximum number of blocks we can have in an diff --git a/trunk/fs/ext4/extents.c b/trunk/fs/ext4/extents.c index f815cc81e7a2..5199bac7fc62 100644 --- a/trunk/fs/ext4/extents.c +++ b/trunk/fs/ext4/extents.c @@ -1408,7 +1408,7 @@ static int ext4_ext_search_right(struct inode *inode, /* * ext4_ext_next_allocated_block: - * returns allocated block in subsequent extent or EXT_MAX_BLOCKS. + * returns allocated block in subsequent extent or EXT_MAX_BLOCK. * NOTE: it considers block number from index entry as * allocated block. Thus, index entries have to be consistent * with leaves. @@ -1422,7 +1422,7 @@ ext4_ext_next_allocated_block(struct ext4_ext_path *path) depth = path->p_depth; if (depth == 0 && path->p_ext == NULL) - return EXT_MAX_BLOCKS; + return EXT_MAX_BLOCK; while (depth >= 0) { if (depth == path->p_depth) { @@ -1439,12 +1439,12 @@ ext4_ext_next_allocated_block(struct ext4_ext_path *path) depth--; } - return EXT_MAX_BLOCKS; + return EXT_MAX_BLOCK; } /* * ext4_ext_next_leaf_block: - * returns first allocated block from next leaf or EXT_MAX_BLOCKS + * returns first allocated block from next leaf or EXT_MAX_BLOCK */ static ext4_lblk_t ext4_ext_next_leaf_block(struct inode *inode, struct ext4_ext_path *path) @@ -1456,7 +1456,7 @@ static ext4_lblk_t ext4_ext_next_leaf_block(struct inode *inode, /* zero-tree has no leaf blocks at all */ if (depth == 0) - return EXT_MAX_BLOCKS; + return EXT_MAX_BLOCK; /* go to index block */ depth--; @@ -1469,7 +1469,7 @@ static ext4_lblk_t ext4_ext_next_leaf_block(struct inode *inode, depth--; } - return EXT_MAX_BLOCKS; + return EXT_MAX_BLOCK; } /* @@ -1677,13 +1677,13 @@ static unsigned int ext4_ext_check_overlap(struct inode *inode, */ if (b2 < b1) { b2 = ext4_ext_next_allocated_block(path); - if (b2 == EXT_MAX_BLOCKS) + if (b2 == EXT_MAX_BLOCK) goto out; } /* check for wrap through zero on extent logical start block*/ if (b1 + len1 < b1) { - len1 = EXT_MAX_BLOCKS - b1; + len1 = EXT_MAX_BLOCK - b1; newext->ee_len = cpu_to_le16(len1); ret = 1; } @@ -1767,7 +1767,7 @@ int ext4_ext_insert_extent(handle_t *handle, struct inode *inode, fex = EXT_LAST_EXTENT(eh); next = ext4_ext_next_leaf_block(inode, path); if (le32_to_cpu(newext->ee_block) > le32_to_cpu(fex->ee_block) - && next != EXT_MAX_BLOCKS) { + && next != EXT_MAX_BLOCK) { ext_debug("next leaf block - %d\n", next); BUG_ON(npath != NULL); npath = ext4_ext_find_extent(inode, next, NULL); @@ -1887,7 +1887,7 @@ static int ext4_ext_walk_space(struct inode *inode, ext4_lblk_t block, BUG_ON(func == NULL); BUG_ON(inode == NULL); - while (block < last && block != EXT_MAX_BLOCKS) { + while (block < last && block != EXT_MAX_BLOCK) { num = last - block; /* find extent for this block */ down_read(&EXT4_I(inode)->i_data_sem); @@ -1958,7 +1958,7 @@ static int ext4_ext_walk_space(struct inode *inode, ext4_lblk_t block, err = -EIO; break; } - err = func(inode, next, &cbex, ex, cbdata); + err = func(inode, path, &cbex, ex, cbdata); ext4_ext_drop_refs(path); if (err < 0) @@ -2020,7 +2020,7 @@ ext4_ext_put_gap_in_cache(struct inode *inode, struct ext4_ext_path *path, if (ex == NULL) { /* there is no extent yet, so gap is [0;-] */ lblock = 0; - len = EXT_MAX_BLOCKS; + len = EXT_MAX_BLOCK; ext_debug("cache gap(whole file):"); } else if (block < le32_to_cpu(ex->ee_block)) { lblock = block; @@ -2350,7 +2350,7 @@ ext4_ext_rm_leaf(handle_t *handle, struct inode *inode, * never happen because at least one of the end points * needs to be on the edge of the extent. */ - if (end == EXT_MAX_BLOCKS - 1) { + if (end == EXT_MAX_BLOCK) { ext_debug(" bad truncate %u:%u\n", start, end); block = 0; @@ -2398,7 +2398,7 @@ ext4_ext_rm_leaf(handle_t *handle, struct inode *inode, * If this is a truncate, this condition * should never happen */ - if (end == EXT_MAX_BLOCKS - 1) { + if (end == EXT_MAX_BLOCK) { ext_debug(" bad truncate %u:%u\n", start, end); err = -EIO; @@ -2478,7 +2478,7 @@ ext4_ext_rm_leaf(handle_t *handle, struct inode *inode, * we need to remove it from the leaf */ if (num == 0) { - if (end != EXT_MAX_BLOCKS - 1) { + if (end != EXT_MAX_BLOCK) { /* * For hole punching, we need to scoot all the * extents up when an extent is removed so that @@ -3699,7 +3699,7 @@ void ext4_ext_truncate(struct inode *inode) last_block = (inode->i_size + sb->s_blocksize - 1) >> EXT4_BLOCK_SIZE_BITS(sb); - err = ext4_ext_remove_space(inode, last_block, EXT_MAX_BLOCKS - 1); + err = ext4_ext_remove_space(inode, last_block, EXT_MAX_BLOCK); /* In a multi-transaction truncate, we only make the final * transaction synchronous. @@ -3914,13 +3914,14 @@ int ext4_convert_unwritten_extents(struct inode *inode, loff_t offset, /* * Callback function called for each extent to gather FIEMAP information. */ -static int ext4_ext_fiemap_cb(struct inode *inode, ext4_lblk_t next, +static int ext4_ext_fiemap_cb(struct inode *inode, struct ext4_ext_path *path, struct ext4_ext_cache *newex, struct ext4_extent *ex, void *data) { __u64 logical; __u64 physical; __u64 length; + loff_t size; __u32 flags = 0; int ret = 0; struct fiemap_extent_info *fieinfo = data; @@ -4102,7 +4103,8 @@ static int ext4_ext_fiemap_cb(struct inode *inode, ext4_lblk_t next, if (ex && ext4_ext_is_uninitialized(ex)) flags |= FIEMAP_EXTENT_UNWRITTEN; - if (next == EXT_MAX_BLOCKS) + size = i_size_read(inode); + if (logical + length >= size) flags |= FIEMAP_EXTENT_LAST; ret = fiemap_fill_next_extent(fieinfo, logical, physical, @@ -4345,8 +4347,8 @@ int ext4_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, start_blk = start >> inode->i_sb->s_blocksize_bits; last_blk = (start + len - 1) >> inode->i_sb->s_blocksize_bits; - if (last_blk >= EXT_MAX_BLOCKS) - last_blk = EXT_MAX_BLOCKS-1; + if (last_blk >= EXT_MAX_BLOCK) + last_blk = EXT_MAX_BLOCK-1; len_blks = ((ext4_lblk_t) last_blk) - start_blk + 1; /* diff --git a/trunk/fs/ext4/inode.c b/trunk/fs/ext4/inode.c index e3126c051006..a5763e3505ba 100644 --- a/trunk/fs/ext4/inode.c +++ b/trunk/fs/ext4/inode.c @@ -2634,7 +2634,7 @@ static int ext4_writepage(struct page *page, struct buffer_head *page_bufs = NULL; struct inode *inode = page->mapping->host; - trace_ext4_writepage(page); + trace_ext4_writepage(inode, page); size = i_size_read(inode); if (page->index == size >> PAGE_CACHE_SHIFT) len = size & ~PAGE_CACHE_MASK; diff --git a/trunk/fs/ext4/mballoc.c b/trunk/fs/ext4/mballoc.c index 6ed859d56850..859f2ae8864e 100644 --- a/trunk/fs/ext4/mballoc.c +++ b/trunk/fs/ext4/mballoc.c @@ -3578,8 +3578,8 @@ ext4_mb_release_inode_pa(struct ext4_buddy *e4b, struct buffer_head *bitmap_bh, free += next - bit; trace_ext4_mballoc_discard(sb, NULL, group, bit, next - bit); - trace_ext4_mb_release_inode_pa(pa, grp_blk_start + bit, - next - bit); + trace_ext4_mb_release_inode_pa(sb, pa->pa_inode, pa, + grp_blk_start + bit, next - bit); mb_free_blocks(pa->pa_inode, e4b, bit, next - bit); bit = next + 1; } @@ -3608,7 +3608,7 @@ ext4_mb_release_group_pa(struct ext4_buddy *e4b, ext4_group_t group; ext4_grpblk_t bit; - trace_ext4_mb_release_group_pa(pa); + trace_ext4_mb_release_group_pa(sb, pa); BUG_ON(pa->pa_deleted == 0); ext4_get_group_no_and_offset(sb, pa->pa_pstart, &group, &bit); BUG_ON(group != e4b->bd_group && pa->pa_len != 0); @@ -4448,7 +4448,7 @@ ext4_mb_free_metadata(handle_t *handle, struct ext4_buddy *e4b, * @inode: inode * @block: start physical block to free * @count: number of blocks to count - * @flags: flags used by ext4_free_blocks + * @metadata: Are these metadata blocks */ void ext4_free_blocks(handle_t *handle, struct inode *inode, struct buffer_head *bh, ext4_fsblk_t block, diff --git a/trunk/fs/ext4/move_extent.c b/trunk/fs/ext4/move_extent.c index f57455a1b1b2..2b8304bf3c50 100644 --- a/trunk/fs/ext4/move_extent.c +++ b/trunk/fs/ext4/move_extent.c @@ -1002,12 +1002,12 @@ mext_check_arguments(struct inode *orig_inode, return -EINVAL; } - if ((orig_start >= EXT_MAX_BLOCKS) || - (donor_start >= EXT_MAX_BLOCKS) || - (*len > EXT_MAX_BLOCKS) || - (orig_start + *len >= EXT_MAX_BLOCKS)) { + if ((orig_start > EXT_MAX_BLOCK) || + (donor_start > EXT_MAX_BLOCK) || + (*len > EXT_MAX_BLOCK) || + (orig_start + *len > EXT_MAX_BLOCK)) { ext4_debug("ext4 move extent: Can't handle over [%u] blocks " - "[ino:orig %lu, donor %lu]\n", EXT_MAX_BLOCKS, + "[ino:orig %lu, donor %lu]\n", EXT_MAX_BLOCK, orig_inode->i_ino, donor_inode->i_ino); return -EINVAL; } diff --git a/trunk/fs/ext4/super.c b/trunk/fs/ext4/super.c index 9ea71aa864b3..cc5c157aa11d 100644 --- a/trunk/fs/ext4/super.c +++ b/trunk/fs/ext4/super.c @@ -2243,12 +2243,6 @@ static void ext4_orphan_cleanup(struct super_block *sb, * in the vfs. ext4 inode has 48 bits of i_block in fsblock units, * so that won't be a limiting factor. * - * However there is other limiting factor. We do store extents in the form - * of starting block and length, hence the resulting length of the extent - * covering maximum file size must fit into on-disk format containers as - * well. Given that length is always by 1 unit bigger than max unit (because - * we count 0 as well) we have to lower the s_maxbytes by one fs block. - * * Note, this does *not* consider any metadata overhead for vfs i_blocks. */ static loff_t ext4_max_size(int blkbits, int has_huge_files) @@ -2270,13 +2264,10 @@ static loff_t ext4_max_size(int blkbits, int has_huge_files) upper_limit <<= blkbits; } - /* - * 32-bit extent-start container, ee_block. We lower the maxbytes - * by one fs block, so ee_len can cover the extent of maximum file - * size - */ - res = (1LL << 32) - 1; + /* 32-bit extent-start container, ee_block */ + res = 1LL << 32; res <<= blkbits; + res -= 1; /* Sanity check against vm- & vfs- imposed limits */ if (res > upper_limit) diff --git a/trunk/fs/fscache/page.c b/trunk/fs/fscache/page.c index 2f343b4d7a7d..a2a5d19ece6a 100644 --- a/trunk/fs/fscache/page.c +++ b/trunk/fs/fscache/page.c @@ -954,47 +954,3 @@ void fscache_mark_pages_cached(struct fscache_retrieval *op, pagevec_reinit(pagevec); } EXPORT_SYMBOL(fscache_mark_pages_cached); - -/* - * Uncache all the pages in an inode that are marked PG_fscache, assuming them - * to be associated with the given cookie. - */ -void __fscache_uncache_all_inode_pages(struct fscache_cookie *cookie, - struct inode *inode) -{ - struct address_space *mapping = inode->i_mapping; - struct pagevec pvec; - pgoff_t next; - int i; - - _enter("%p,%p", cookie, inode); - - if (!mapping || mapping->nrpages == 0) { - _leave(" [no pages]"); - return; - } - - pagevec_init(&pvec, 0); - next = 0; - while (next <= (loff_t)-1 && - pagevec_lookup(&pvec, mapping, next, PAGEVEC_SIZE) - ) { - for (i = 0; i < pagevec_count(&pvec); i++) { - struct page *page = pvec.pages[i]; - pgoff_t page_index = page->index; - - ASSERTCMP(page_index, >=, next); - next = page_index + 1; - - if (PageFsCache(page)) { - __fscache_wait_on_page_write(cookie, page); - __fscache_uncache_page(cookie, page); - } - } - pagevec_release(&pvec); - cond_resched(); - } - - _leave(""); -} -EXPORT_SYMBOL(__fscache_uncache_all_inode_pages); diff --git a/trunk/fs/hfsplus/super.c b/trunk/fs/hfsplus/super.c index 84a47b709f51..b49b55584c84 100644 --- a/trunk/fs/hfsplus/super.c +++ b/trunk/fs/hfsplus/super.c @@ -500,7 +500,7 @@ static int hfsplus_fill_super(struct super_block *sb, void *data, int silent) out_put_hidden_dir: iput(sbi->hidden_dir); out_put_root: - iput(root); + iput(sbi->alloc_file); out_put_alloc_file: iput(sbi->alloc_file); out_close_cat_tree: diff --git a/trunk/fs/hfsplus/wrapper.c b/trunk/fs/hfsplus/wrapper.c index 4ac88ff79aa6..3031d81f5f0f 100644 --- a/trunk/fs/hfsplus/wrapper.c +++ b/trunk/fs/hfsplus/wrapper.c @@ -36,7 +36,6 @@ int hfsplus_submit_bio(struct block_device *bdev, sector_t sector, { DECLARE_COMPLETION_ONSTACK(wait); struct bio *bio; - int ret = 0; bio = bio_alloc(GFP_NOIO, 1); bio->bi_sector = sector; @@ -55,10 +54,8 @@ int hfsplus_submit_bio(struct block_device *bdev, sector_t sector, wait_for_completion(&wait); if (!bio_flagged(bio, BIO_UPTODATE)) - ret = -EIO; - - bio_put(bio); - return ret; + return -EIO; + return 0; } static int hfsplus_read_mdb(void *bufptr, struct hfsplus_wd *wd) diff --git a/trunk/fs/inode.c b/trunk/fs/inode.c index 43566d17d1b8..0f7e88a7803f 100644 --- a/trunk/fs/inode.c +++ b/trunk/fs/inode.c @@ -423,14 +423,7 @@ EXPORT_SYMBOL(remove_inode_hash); void end_writeback(struct inode *inode) { might_sleep(); - /* - * We have to cycle tree_lock here because reclaim can be still in the - * process of removing the last page (in __delete_from_page_cache()) - * and we must not free mapping under it. - */ - spin_lock_irq(&inode->i_data.tree_lock); BUG_ON(inode->i_data.nrpages); - spin_unlock_irq(&inode->i_data.tree_lock); BUG_ON(!list_empty(&inode->i_data.private_list)); BUG_ON(!(inode->i_state & I_FREEING)); BUG_ON(inode->i_state & I_CLEAR); diff --git a/trunk/fs/jbd2/checkpoint.c b/trunk/fs/jbd2/checkpoint.c index 2c62c5aae82f..6a79fd0a1a32 100644 --- a/trunk/fs/jbd2/checkpoint.c +++ b/trunk/fs/jbd2/checkpoint.c @@ -97,14 +97,10 @@ static int __try_to_free_cp_buf(struct journal_head *jh) if (jh->b_jlist == BJ_None && !buffer_locked(bh) && !buffer_dirty(bh) && !buffer_write_io_error(bh)) { - /* - * Get our reference so that bh cannot be freed before - * we unlock it - */ - get_bh(bh); JBUFFER_TRACE(jh, "remove from checkpoint list"); ret = __jbd2_journal_remove_checkpoint(jh) + 1; jbd_unlock_bh_state(bh); + jbd2_journal_remove_journal_head(bh); BUFFER_TRACE(bh, "release"); __brelse(bh); } else { @@ -227,8 +223,8 @@ static int __wait_cp_io(journal_t *journal, transaction_t *transaction) spin_lock(&journal->j_list_lock); goto restart; } - get_bh(bh); if (buffer_locked(bh)) { + atomic_inc(&bh->b_count); spin_unlock(&journal->j_list_lock); jbd_unlock_bh_state(bh); wait_on_buffer(bh); @@ -247,6 +243,7 @@ static int __wait_cp_io(journal_t *journal, transaction_t *transaction) */ released = __jbd2_journal_remove_checkpoint(jh); jbd_unlock_bh_state(bh); + jbd2_journal_remove_journal_head(bh); __brelse(bh); } @@ -287,7 +284,7 @@ static int __process_buffer(journal_t *journal, struct journal_head *jh, int ret = 0; if (buffer_locked(bh)) { - get_bh(bh); + atomic_inc(&bh->b_count); spin_unlock(&journal->j_list_lock); jbd_unlock_bh_state(bh); wait_on_buffer(bh); @@ -319,12 +316,12 @@ static int __process_buffer(journal_t *journal, struct journal_head *jh, ret = 1; if (unlikely(buffer_write_io_error(bh))) ret = -EIO; - get_bh(bh); J_ASSERT_JH(jh, !buffer_jbddirty(bh)); BUFFER_TRACE(bh, "remove from checkpoint"); __jbd2_journal_remove_checkpoint(jh); spin_unlock(&journal->j_list_lock); jbd_unlock_bh_state(bh); + jbd2_journal_remove_journal_head(bh); __brelse(bh); } else { /* @@ -557,8 +554,7 @@ int jbd2_cleanup_journal_tail(journal_t *journal) /* * journal_clean_one_cp_list * - * Find all the written-back checkpoint buffers in the given list and - * release them. + * Find all the written-back checkpoint buffers in the given list and release them. * * Called with the journal locked. * Called with j_list_lock held. @@ -667,8 +663,8 @@ int __jbd2_journal_clean_checkpoint_list(journal_t *journal) * checkpoint lists. * * The function returns 1 if it frees the transaction, 0 otherwise. - * The function can free jh and bh. * + * This function is called with the journal locked. * This function is called with j_list_lock held. * This function is called with jbd_lock_bh_state(jh2bh(jh)) */ @@ -688,14 +684,13 @@ int __jbd2_journal_remove_checkpoint(struct journal_head *jh) } journal = transaction->t_journal; - JBUFFER_TRACE(jh, "removing from transaction"); __buffer_unlink(jh); jh->b_cp_transaction = NULL; - jbd2_journal_put_journal_head(jh); if (transaction->t_checkpoint_list != NULL || transaction->t_checkpoint_io_list != NULL) goto out; + JBUFFER_TRACE(jh, "transaction has no more buffers"); /* * There is one special case to worry about: if we have just pulled the @@ -706,8 +701,10 @@ int __jbd2_journal_remove_checkpoint(struct journal_head *jh) * The locking here around t_state is a bit sleazy. * See the comment at the end of jbd2_journal_commit_transaction(). */ - if (transaction->t_state != T_FINISHED) + if (transaction->t_state != T_FINISHED) { + JBUFFER_TRACE(jh, "belongs to running/committing transaction"); goto out; + } /* OK, that was the last buffer for the transaction: we can now safely remove this transaction from the log */ @@ -726,6 +723,7 @@ int __jbd2_journal_remove_checkpoint(struct journal_head *jh) wake_up(&journal->j_wait_logspace); ret = 1; out: + JBUFFER_TRACE(jh, "exit"); return ret; } @@ -744,8 +742,6 @@ void __jbd2_journal_insert_checkpoint(struct journal_head *jh, J_ASSERT_JH(jh, buffer_dirty(jh2bh(jh)) || buffer_jbddirty(jh2bh(jh))); J_ASSERT_JH(jh, jh->b_cp_transaction == NULL); - /* Get reference for checkpointing transaction */ - jbd2_journal_grab_journal_head(jh2bh(jh)); jh->b_cp_transaction = transaction; if (!transaction->t_checkpoint_list) { diff --git a/trunk/fs/jbd2/commit.c b/trunk/fs/jbd2/commit.c index eef6979821a4..7f21cf3aaf92 100644 --- a/trunk/fs/jbd2/commit.c +++ b/trunk/fs/jbd2/commit.c @@ -848,16 +848,10 @@ void jbd2_journal_commit_transaction(journal_t *journal) while (commit_transaction->t_forget) { transaction_t *cp_transaction; struct buffer_head *bh; - int try_to_free = 0; jh = commit_transaction->t_forget; spin_unlock(&journal->j_list_lock); bh = jh2bh(jh); - /* - * Get a reference so that bh cannot be freed before we are - * done with it. - */ - get_bh(bh); jbd_lock_bh_state(bh); J_ASSERT_JH(jh, jh->b_transaction == commit_transaction); @@ -920,27 +914,28 @@ void jbd2_journal_commit_transaction(journal_t *journal) __jbd2_journal_insert_checkpoint(jh, commit_transaction); if (is_journal_aborted(journal)) clear_buffer_jbddirty(bh); + JBUFFER_TRACE(jh, "refile for checkpoint writeback"); + __jbd2_journal_refile_buffer(jh); + jbd_unlock_bh_state(bh); } else { J_ASSERT_BH(bh, !buffer_dirty(bh)); - /* - * The buffer on BJ_Forget list and not jbddirty means + /* The buffer on BJ_Forget list and not jbddirty means * it has been freed by this transaction and hence it * could not have been reallocated until this * transaction has committed. *BUT* it could be * reallocated once we have written all the data to * disk and before we process the buffer on BJ_Forget - * list. - */ - if (!jh->b_next_transaction) - try_to_free = 1; + * list. */ + JBUFFER_TRACE(jh, "refile or unfile freed buffer"); + __jbd2_journal_refile_buffer(jh); + if (!jh->b_transaction) { + jbd_unlock_bh_state(bh); + /* needs a brelse */ + jbd2_journal_remove_journal_head(bh); + release_buffer_page(bh); + } else + jbd_unlock_bh_state(bh); } - JBUFFER_TRACE(jh, "refile or unfile buffer"); - __jbd2_journal_refile_buffer(jh); - jbd_unlock_bh_state(bh); - if (try_to_free) - release_buffer_page(bh); /* Drops bh reference */ - else - __brelse(bh); cond_resched_lock(&journal->j_list_lock); } spin_unlock(&journal->j_list_lock); diff --git a/trunk/fs/jbd2/journal.c b/trunk/fs/jbd2/journal.c index 0dfa5b598e68..9a7826990304 100644 --- a/trunk/fs/jbd2/journal.c +++ b/trunk/fs/jbd2/journal.c @@ -2078,9 +2078,10 @@ static void journal_free_journal_head(struct journal_head *jh) * When a buffer has its BH_JBD bit set it is immune from being released by * core kernel code, mainly via ->b_count. * - * A journal_head is detached from its buffer_head when the journal_head's - * b_jcount reaches zero. Running transaction (b_transaction) and checkpoint - * transaction (b_cp_transaction) hold their references to b_jcount. + * A journal_head may be detached from its buffer_head when the journal_head's + * b_transaction, b_cp_transaction and b_next_transaction pointers are NULL. + * Various places in JBD call jbd2_journal_remove_journal_head() to indicate that the + * journal_head can be dropped if needed. * * Various places in the kernel want to attach a journal_head to a buffer_head * _before_ attaching the journal_head to a transaction. To protect the @@ -2093,16 +2094,17 @@ static void journal_free_journal_head(struct journal_head *jh) * (Attach a journal_head if needed. Increments b_jcount) * struct journal_head *jh = jbd2_journal_add_journal_head(bh); * ... - * (Get another reference for transaction) - * jbd2_journal_grab_journal_head(bh); * jh->b_transaction = xxx; - * (Put original reference) * jbd2_journal_put_journal_head(jh); + * + * Now, the journal_head's b_jcount is zero, but it is safe from being released + * because it has a non-zero b_transaction. */ /* * Give a buffer_head a journal_head. * + * Doesn't need the journal lock. * May sleep. */ struct journal_head *jbd2_journal_add_journal_head(struct buffer_head *bh) @@ -2166,29 +2168,61 @@ static void __journal_remove_journal_head(struct buffer_head *bh) struct journal_head *jh = bh2jh(bh); J_ASSERT_JH(jh, jh->b_jcount >= 0); - J_ASSERT_JH(jh, jh->b_transaction == NULL); - J_ASSERT_JH(jh, jh->b_next_transaction == NULL); - J_ASSERT_JH(jh, jh->b_cp_transaction == NULL); - J_ASSERT_JH(jh, jh->b_jlist == BJ_None); - J_ASSERT_BH(bh, buffer_jbd(bh)); - J_ASSERT_BH(bh, jh2bh(jh) == bh); - BUFFER_TRACE(bh, "remove journal_head"); - if (jh->b_frozen_data) { - printk(KERN_WARNING "%s: freeing b_frozen_data\n", __func__); - jbd2_free(jh->b_frozen_data, bh->b_size); - } - if (jh->b_committed_data) { - printk(KERN_WARNING "%s: freeing b_committed_data\n", __func__); - jbd2_free(jh->b_committed_data, bh->b_size); + + get_bh(bh); + if (jh->b_jcount == 0) { + if (jh->b_transaction == NULL && + jh->b_next_transaction == NULL && + jh->b_cp_transaction == NULL) { + J_ASSERT_JH(jh, jh->b_jlist == BJ_None); + J_ASSERT_BH(bh, buffer_jbd(bh)); + J_ASSERT_BH(bh, jh2bh(jh) == bh); + BUFFER_TRACE(bh, "remove journal_head"); + if (jh->b_frozen_data) { + printk(KERN_WARNING "%s: freeing " + "b_frozen_data\n", + __func__); + jbd2_free(jh->b_frozen_data, bh->b_size); + } + if (jh->b_committed_data) { + printk(KERN_WARNING "%s: freeing " + "b_committed_data\n", + __func__); + jbd2_free(jh->b_committed_data, bh->b_size); + } + bh->b_private = NULL; + jh->b_bh = NULL; /* debug, really */ + clear_buffer_jbd(bh); + __brelse(bh); + journal_free_journal_head(jh); + } else { + BUFFER_TRACE(bh, "journal_head was locked"); + } } - bh->b_private = NULL; - jh->b_bh = NULL; /* debug, really */ - clear_buffer_jbd(bh); - journal_free_journal_head(jh); } /* - * Drop a reference on the passed journal_head. If it fell to zero then + * jbd2_journal_remove_journal_head(): if the buffer isn't attached to a transaction + * and has a zero b_jcount then remove and release its journal_head. If we did + * see that the buffer is not used by any transaction we also "logically" + * decrement ->b_count. + * + * We in fact take an additional increment on ->b_count as a convenience, + * because the caller usually wants to do additional things with the bh + * after calling here. + * The caller of jbd2_journal_remove_journal_head() *must* run __brelse(bh) at some + * time. Once the caller has run __brelse(), the buffer is eligible for + * reaping by try_to_free_buffers(). + */ +void jbd2_journal_remove_journal_head(struct buffer_head *bh) +{ + jbd_lock_bh_journal_head(bh); + __journal_remove_journal_head(bh); + jbd_unlock_bh_journal_head(bh); +} + +/* + * Drop a reference on the passed journal_head. If it fell to zero then try to * release the journal_head from the buffer_head. */ void jbd2_journal_put_journal_head(struct journal_head *jh) @@ -2198,12 +2232,11 @@ void jbd2_journal_put_journal_head(struct journal_head *jh) jbd_lock_bh_journal_head(bh); J_ASSERT_JH(jh, jh->b_jcount > 0); --jh->b_jcount; - if (!jh->b_jcount) { + if (!jh->b_jcount && !jh->b_transaction) { __journal_remove_journal_head(bh); - jbd_unlock_bh_journal_head(bh); __brelse(bh); - } else - jbd_unlock_bh_journal_head(bh); + } + jbd_unlock_bh_journal_head(bh); } /* diff --git a/trunk/fs/jbd2/transaction.c b/trunk/fs/jbd2/transaction.c index 2d7109414cdd..3eec82d32fd4 100644 --- a/trunk/fs/jbd2/transaction.c +++ b/trunk/fs/jbd2/transaction.c @@ -30,7 +30,6 @@ #include static void __jbd2_journal_temp_unlink_buffer(struct journal_head *jh); -static void __jbd2_journal_unfile_buffer(struct journal_head *jh); /* * jbd2_get_transaction: obtain a new transaction_t object. @@ -765,6 +764,7 @@ do_get_write_access(handle_t *handle, struct journal_head *jh, if (!jh->b_transaction) { JBUFFER_TRACE(jh, "no transaction"); J_ASSERT_JH(jh, !jh->b_next_transaction); + jh->b_transaction = transaction; JBUFFER_TRACE(jh, "file as BJ_Reserved"); spin_lock(&journal->j_list_lock); __jbd2_journal_file_buffer(jh, transaction, BJ_Reserved); @@ -814,6 +814,7 @@ do_get_write_access(handle_t *handle, struct journal_head *jh, * int jbd2_journal_get_write_access() - notify intent to modify a buffer for metadata (not data) update. * @handle: transaction to add buffer modifications to * @bh: bh to be used for metadata writes + * @credits: variable that will receive credits for the buffer * * Returns an error code or 0 on success. * @@ -895,6 +896,8 @@ int jbd2_journal_get_create_access(handle_t *handle, struct buffer_head *bh) * committed and so it's safe to clear the dirty bit. */ clear_buffer_dirty(jh2bh(jh)); + jh->b_transaction = transaction; + /* first access by this transaction */ jh->b_modified = 0; @@ -929,6 +932,7 @@ int jbd2_journal_get_create_access(handle_t *handle, struct buffer_head *bh) * non-rewindable consequences * @handle: transaction * @bh: buffer to undo + * @credits: store the number of taken credits here (if not NULL) * * Sometimes there is a need to distinguish between metadata which has * been committed to disk and that which has not. The ext3fs code uses @@ -1228,6 +1232,8 @@ int jbd2_journal_forget (handle_t *handle, struct buffer_head *bh) __jbd2_journal_file_buffer(jh, transaction, BJ_Forget); } else { __jbd2_journal_unfile_buffer(jh); + jbd2_journal_remove_journal_head(bh); + __brelse(bh); if (!buffer_jbd(bh)) { spin_unlock(&journal->j_list_lock); jbd_unlock_bh_state(bh); @@ -1550,32 +1556,19 @@ void __jbd2_journal_temp_unlink_buffer(struct journal_head *jh) mark_buffer_dirty(bh); /* Expose it to the VM */ } -/* - * Remove buffer from all transactions. - * - * Called with bh_state lock and j_list_lock - * - * jh and bh may be already freed when this function returns. - */ -static void __jbd2_journal_unfile_buffer(struct journal_head *jh) +void __jbd2_journal_unfile_buffer(struct journal_head *jh) { __jbd2_journal_temp_unlink_buffer(jh); jh->b_transaction = NULL; - jbd2_journal_put_journal_head(jh); } void jbd2_journal_unfile_buffer(journal_t *journal, struct journal_head *jh) { - struct buffer_head *bh = jh2bh(jh); - - /* Get reference so that buffer cannot be freed before we unlock it */ - get_bh(bh); - jbd_lock_bh_state(bh); + jbd_lock_bh_state(jh2bh(jh)); spin_lock(&journal->j_list_lock); __jbd2_journal_unfile_buffer(jh); spin_unlock(&journal->j_list_lock); - jbd_unlock_bh_state(bh); - __brelse(bh); + jbd_unlock_bh_state(jh2bh(jh)); } /* @@ -1602,6 +1595,8 @@ __journal_try_to_free_buffer(journal_t *journal, struct buffer_head *bh) if (jh->b_jlist == BJ_None) { JBUFFER_TRACE(jh, "remove from checkpoint list"); __jbd2_journal_remove_checkpoint(jh); + jbd2_journal_remove_journal_head(bh); + __brelse(bh); } } spin_unlock(&journal->j_list_lock); @@ -1664,6 +1659,7 @@ int jbd2_journal_try_to_free_buffers(journal_t *journal, /* * We take our own ref against the journal_head here to avoid * having to add tons of locking around each instance of + * jbd2_journal_remove_journal_head() and * jbd2_journal_put_journal_head(). */ jh = jbd2_journal_grab_journal_head(bh); @@ -1701,9 +1697,10 @@ static int __dispose_buffer(struct journal_head *jh, transaction_t *transaction) int may_free = 1; struct buffer_head *bh = jh2bh(jh); + __jbd2_journal_unfile_buffer(jh); + if (jh->b_cp_transaction) { JBUFFER_TRACE(jh, "on running+cp transaction"); - __jbd2_journal_temp_unlink_buffer(jh); /* * We don't want to write the buffer anymore, clear the * bit so that we don't confuse checks in @@ -1714,7 +1711,8 @@ static int __dispose_buffer(struct journal_head *jh, transaction_t *transaction) may_free = 0; } else { JBUFFER_TRACE(jh, "on running transaction"); - __jbd2_journal_unfile_buffer(jh); + jbd2_journal_remove_journal_head(bh); + __brelse(bh); } return may_free; } @@ -1992,8 +1990,6 @@ void __jbd2_journal_file_buffer(struct journal_head *jh, if (jh->b_transaction) __jbd2_journal_temp_unlink_buffer(jh); - else - jbd2_journal_grab_journal_head(bh); jh->b_transaction = transaction; switch (jlist) { @@ -2045,10 +2041,9 @@ void jbd2_journal_file_buffer(struct journal_head *jh, * already started to be used by a subsequent transaction, refile the * buffer on that transaction's metadata list. * - * Called under j_list_lock - * Called under jbd_lock_bh_state(jh2bh(jh)) + * Called under journal->j_list_lock * - * jh and bh may be already free when this function returns + * Called under jbd_lock_bh_state(jh2bh(jh)) */ void __jbd2_journal_refile_buffer(struct journal_head *jh) { @@ -2072,11 +2067,6 @@ void __jbd2_journal_refile_buffer(struct journal_head *jh) was_dirty = test_clear_buffer_jbddirty(bh); __jbd2_journal_temp_unlink_buffer(jh); - /* - * We set b_transaction here because b_next_transaction will inherit - * our jh reference and thus __jbd2_journal_file_buffer() must not - * take a new one. - */ jh->b_transaction = jh->b_next_transaction; jh->b_next_transaction = NULL; if (buffer_freed(bh)) @@ -2093,21 +2083,30 @@ void __jbd2_journal_refile_buffer(struct journal_head *jh) } /* - * __jbd2_journal_refile_buffer() with necessary locking added. We take our - * bh reference so that we can safely unlock bh. - * - * The jh and bh may be freed by this call. + * For the unlocked version of this call, also make sure that any + * hanging journal_head is cleaned up if necessary. + * + * __jbd2_journal_refile_buffer is usually called as part of a single locked + * operation on a buffer_head, in which the caller is probably going to + * be hooking the journal_head onto other lists. In that case it is up + * to the caller to remove the journal_head if necessary. For the + * unlocked jbd2_journal_refile_buffer call, the caller isn't going to be + * doing anything else to the buffer so we need to do the cleanup + * ourselves to avoid a jh leak. + * + * *** The journal_head may be freed by this call! *** */ void jbd2_journal_refile_buffer(journal_t *journal, struct journal_head *jh) { struct buffer_head *bh = jh2bh(jh); - /* Get reference so that buffer cannot be freed before we unlock it */ - get_bh(bh); jbd_lock_bh_state(bh); spin_lock(&journal->j_list_lock); + __jbd2_journal_refile_buffer(jh); jbd_unlock_bh_state(bh); + jbd2_journal_remove_journal_head(bh); + spin_unlock(&journal->j_list_lock); __brelse(bh); } diff --git a/trunk/fs/jfs/file.c b/trunk/fs/jfs/file.c index 2f3f531f3606..c5ce6c1d1ff4 100644 --- a/trunk/fs/jfs/file.c +++ b/trunk/fs/jfs/file.c @@ -66,9 +66,9 @@ static int jfs_open(struct inode *inode, struct file *file) struct jfs_inode_info *ji = JFS_IP(inode); spin_lock_irq(&ji->ag_lock); if (ji->active_ag == -1) { - struct jfs_sb_info *jfs_sb = JFS_SBI(inode->i_sb); - ji->active_ag = BLKTOAG(addressPXD(&ji->ixpxd), jfs_sb); - atomic_inc( &jfs_sb->bmap->db_active[ji->active_ag]); + ji->active_ag = ji->agno; + atomic_inc( + &JFS_SBI(inode->i_sb)->bmap->db_active[ji->agno]); } spin_unlock_irq(&ji->ag_lock); } diff --git a/trunk/fs/jfs/jfs_imap.c b/trunk/fs/jfs/jfs_imap.c index b78b2f978f04..ed53a4740168 100644 --- a/trunk/fs/jfs/jfs_imap.c +++ b/trunk/fs/jfs/jfs_imap.c @@ -397,7 +397,7 @@ int diRead(struct inode *ip) release_metapage(mp); /* set the ag for the inode */ - JFS_IP(ip)->agstart = agstart; + JFS_IP(ip)->agno = BLKTOAG(agstart, sbi); JFS_IP(ip)->active_ag = -1; return (rc); @@ -901,7 +901,7 @@ int diFree(struct inode *ip) /* get the allocation group for this ino. */ - agno = BLKTOAG(JFS_IP(ip)->agstart, JFS_SBI(ip->i_sb)); + agno = JFS_IP(ip)->agno; /* Lock the AG specific inode map information */ @@ -1315,11 +1315,12 @@ int diFree(struct inode *ip) static inline void diInitInode(struct inode *ip, int iagno, int ino, int extno, struct iag * iagp) { + struct jfs_sb_info *sbi = JFS_SBI(ip->i_sb); struct jfs_inode_info *jfs_ip = JFS_IP(ip); ip->i_ino = (iagno << L2INOSPERIAG) + ino; jfs_ip->ixpxd = iagp->inoext[extno]; - jfs_ip->agstart = le64_to_cpu(iagp->agstart); + jfs_ip->agno = BLKTOAG(le64_to_cpu(iagp->agstart), sbi); jfs_ip->active_ag = -1; } @@ -1378,7 +1379,7 @@ int diAlloc(struct inode *pip, bool dir, struct inode *ip) */ /* get the ag number of this iag */ - agno = BLKTOAG(JFS_IP(pip)->agstart, JFS_SBI(pip->i_sb)); + agno = JFS_IP(pip)->agno; if (atomic_read(&JFS_SBI(pip->i_sb)->bmap->db_active[agno])) { /* @@ -2920,9 +2921,10 @@ int diExtendFS(struct inode *ipimap, struct inode *ipbmap) continue; } + /* agstart that computes to the same ag is treated as same; */ agstart = le64_to_cpu(iagp->agstart); + /* iagp->agstart = agstart & ~(mp->db_agsize - 1); */ n = agstart >> mp->db_agl2size; - iagp->agstart = cpu_to_le64((s64)n << mp->db_agl2size); /* compute backed inodes */ numinos = (EXTSPERIAG - le32_to_cpu(iagp->nfreeexts)) diff --git a/trunk/fs/jfs/jfs_incore.h b/trunk/fs/jfs/jfs_incore.h index 584a4a1a6e81..1439f119ec83 100644 --- a/trunk/fs/jfs/jfs_incore.h +++ b/trunk/fs/jfs/jfs_incore.h @@ -50,9 +50,8 @@ struct jfs_inode_info { short btindex; /* btpage entry index*/ struct inode *ipimap; /* inode map */ unsigned long cflag; /* commit flags */ - u64 agstart; /* agstart of the containing IAG */ u16 bxflag; /* xflag of pseudo buffer? */ - unchar pad; + unchar agno; /* ag number */ signed char active_ag; /* ag currently allocating from */ lid_t blid; /* lid of pseudo buffer? */ lid_t atlhead; /* anonymous tlock list head */ diff --git a/trunk/fs/jfs/resize.c b/trunk/fs/jfs/resize.c index 8d0c1c7c0820..8ea5efb5a34e 100644 --- a/trunk/fs/jfs/resize.c +++ b/trunk/fs/jfs/resize.c @@ -80,7 +80,7 @@ int jfs_extendfs(struct super_block *sb, s64 newLVSize, int newLogSize) int log_formatted = 0; struct inode *iplist[1]; struct jfs_superblock *j_sb, *j_sb2; - s64 old_agsize; + uint old_agsize; int agsizechanged = 0; struct buffer_head *bh, *bh2; diff --git a/trunk/fs/lockd/clntproc.c b/trunk/fs/lockd/clntproc.c index e374050a911c..adb45ec9038c 100644 --- a/trunk/fs/lockd/clntproc.c +++ b/trunk/fs/lockd/clntproc.c @@ -708,13 +708,7 @@ static void nlmclnt_unlock_callback(struct rpc_task *task, void *data) if (task->tk_status < 0) { dprintk("lockd: unlock failed (err = %d)\n", -task->tk_status); - switch (task->tk_status) { - case -EACCES: - case -EIO: - goto die; - default: - goto retry_rebind; - } + goto retry_rebind; } if (status == NLM_LCK_DENIED_GRACE_PERIOD) { rpc_delay(task, NLMCLNT_GRACE_WAIT); diff --git a/trunk/fs/locks.c b/trunk/fs/locks.c index b286539d547a..0a4f50dfadfb 100644 --- a/trunk/fs/locks.c +++ b/trunk/fs/locks.c @@ -160,28 +160,10 @@ EXPORT_SYMBOL_GPL(unlock_flocks); static struct kmem_cache *filelock_cache __read_mostly; -static void locks_init_lock_always(struct file_lock *fl) -{ - fl->fl_next = NULL; - fl->fl_fasync = NULL; - fl->fl_owner = NULL; - fl->fl_pid = 0; - fl->fl_nspid = NULL; - fl->fl_file = NULL; - fl->fl_flags = 0; - fl->fl_type = 0; - fl->fl_start = fl->fl_end = 0; -} - /* Allocate an empty lock structure. */ struct file_lock *locks_alloc_lock(void) { - struct file_lock *fl = kmem_cache_alloc(filelock_cache, GFP_KERNEL); - - if (fl) - locks_init_lock_always(fl); - - return fl; + return kmem_cache_alloc(filelock_cache, GFP_KERNEL); } EXPORT_SYMBOL_GPL(locks_alloc_lock); @@ -218,9 +200,17 @@ void locks_init_lock(struct file_lock *fl) INIT_LIST_HEAD(&fl->fl_link); INIT_LIST_HEAD(&fl->fl_block); init_waitqueue_head(&fl->fl_wait); + fl->fl_next = NULL; + fl->fl_fasync = NULL; + fl->fl_owner = NULL; + fl->fl_pid = 0; + fl->fl_nspid = NULL; + fl->fl_file = NULL; + fl->fl_flags = 0; + fl->fl_type = 0; + fl->fl_start = fl->fl_end = 0; fl->fl_ops = NULL; fl->fl_lmops = NULL; - locks_init_lock_always(fl); } EXPORT_SYMBOL(locks_init_lock); diff --git a/trunk/fs/nfs/fscache.c b/trunk/fs/nfs/fscache.c index 419119c371bf..ce153a6b3aec 100644 --- a/trunk/fs/nfs/fscache.c +++ b/trunk/fs/nfs/fscache.c @@ -259,10 +259,12 @@ static void nfs_fscache_disable_inode_cookie(struct inode *inode) dfprintk(FSCACHE, "NFS: nfsi 0x%p turning cache off\n", NFS_I(inode)); - /* Need to uncache any pages attached to this inode that - * fscache knows about before turning off the cache. + /* Need to invalidate any mapped pages that were read in before + * turning off the cache. */ - fscache_uncache_all_inode_pages(NFS_I(inode)->fscache, inode); + if (inode->i_mapping && inode->i_mapping->nrpages) + invalidate_inode_pages2(inode->i_mapping); + nfs_fscache_zap_inode_cookie(inode); } } diff --git a/trunk/fs/nfs/inode.c b/trunk/fs/nfs/inode.c index 6f4850deb272..144f2a3c7185 100644 --- a/trunk/fs/nfs/inode.c +++ b/trunk/fs/nfs/inode.c @@ -256,8 +256,7 @@ nfs_fhget(struct super_block *sb, struct nfs_fh *fh, struct nfs_fattr *fattr) nfs_attr_check_mountpoint(sb, fattr); - if (((fattr->valid & NFS_ATTR_FATTR_FILEID) == 0) && - !nfs_attr_use_mounted_on_fileid(fattr)) + if ((fattr->valid & NFS_ATTR_FATTR_FILEID) == 0 && (fattr->valid & NFS_ATTR_FATTR_MOUNTPOINT) == 0) goto out_no_inode; if ((fattr->valid & NFS_ATTR_FATTR_TYPE) == 0) goto out_no_inode; @@ -1295,8 +1294,7 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr) if (new_isize != cur_isize) { /* Do we perhaps have any outstanding writes, or has * the file grown beyond our last write? */ - if ((nfsi->npages == 0 && !test_bit(NFS_INO_LAYOUTCOMMIT, &nfsi->flags)) || - new_isize > cur_isize) { + if (nfsi->npages == 0 || new_isize > cur_isize) { i_size_write(inode, new_isize); invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_DATA; } diff --git a/trunk/fs/nfs/internal.h b/trunk/fs/nfs/internal.h index 2a55347a2daa..b9056cbe68d6 100644 --- a/trunk/fs/nfs/internal.h +++ b/trunk/fs/nfs/internal.h @@ -45,17 +45,6 @@ static inline void nfs_attr_check_mountpoint(struct super_block *parent, struct fattr->valid |= NFS_ATTR_FATTR_MOUNTPOINT; } -static inline int nfs_attr_use_mounted_on_fileid(struct nfs_fattr *fattr) -{ - if (((fattr->valid & NFS_ATTR_FATTR_MOUNTED_ON_FILEID) == 0) || - (((fattr->valid & NFS_ATTR_FATTR_MOUNTPOINT) == 0) && - ((fattr->valid & NFS_ATTR_FATTR_V4_REFERRAL) == 0))) - return 0; - - fattr->fileid = fattr->mounted_on_fileid; - return 1; -} - struct nfs_clone_mount { const struct super_block *sb; const struct dentry *dentry; diff --git a/trunk/fs/nfs/nfs4filelayout.c b/trunk/fs/nfs/nfs4filelayout.c index f9d03abcd04c..426908809c97 100644 --- a/trunk/fs/nfs/nfs4filelayout.c +++ b/trunk/fs/nfs/nfs4filelayout.c @@ -30,7 +30,6 @@ */ #include -#include #include "internal.h" #include "nfs4filelayout.h" @@ -398,6 +397,7 @@ filelayout_write_pagelist(struct nfs_write_data *data, int sync) * this offset and save the original offset. */ data->args.offset = filelayout_get_dserver_offset(lseg, offset); + data->mds_offset = offset; /* Perform an asynchronous write */ status = nfs_initiate_write(data, ds->ds_clp->cl_rpcclient, @@ -552,18 +552,13 @@ filelayout_decode_layout(struct pnfs_layout_hdr *flo, __func__, nfl_util, fl->num_fh, fl->first_stripe_index, fl->pattern_offset); - /* Note that a zero value for num_fh is legal for STRIPE_SPARSE. - * Futher checking is done in filelayout_check_layout */ - if (fl->num_fh < 0 || fl->num_fh > - max(NFS4_PNFS_MAX_STRIPE_CNT, NFS4_PNFS_MAX_MULTI_CNT)) + if (!fl->num_fh) goto out_err; - if (fl->num_fh > 0) { - fl->fh_array = kzalloc(fl->num_fh * sizeof(struct nfs_fh *), - gfp_flags); - if (!fl->fh_array) - goto out_err; - } + fl->fh_array = kzalloc(fl->num_fh * sizeof(struct nfs_fh *), + gfp_flags); + if (!fl->fh_array) + goto out_err; for (i = 0; i < fl->num_fh; i++) { /* Do we want to use a mempool here? */ @@ -666,9 +661,8 @@ filelayout_pg_test(struct nfs_pageio_descriptor *pgio, struct nfs_page *prev, u64 p_stripe, r_stripe; u32 stripe_unit; - if (!pnfs_generic_pg_test(pgio, prev, req) || - !nfs_generic_pg_test(pgio, prev, req)) - return false; + if (!pnfs_generic_pg_test(pgio, prev, req)) + return 0; if (!pgio->pg_lseg) return 1; diff --git a/trunk/fs/nfs/nfs4proc.c b/trunk/fs/nfs/nfs4proc.c index 5879b23e0c99..d2c4b59c896d 100644 --- a/trunk/fs/nfs/nfs4proc.c +++ b/trunk/fs/nfs/nfs4proc.c @@ -2265,14 +2265,12 @@ static int nfs4_proc_get_root(struct nfs_server *server, struct nfs_fh *fhandle, return nfs4_map_errors(status); } -static void nfs_fixup_referral_attributes(struct nfs_fattr *fattr); /* * Get locations and (maybe) other attributes of a referral. * Note that we'll actually follow the referral later when * we detect fsid mismatch in inode revalidation */ -static int nfs4_get_referral(struct inode *dir, const struct qstr *name, - struct nfs_fattr *fattr, struct nfs_fh *fhandle) +static int nfs4_get_referral(struct inode *dir, const struct qstr *name, struct nfs_fattr *fattr, struct nfs_fh *fhandle) { int status = -ENOMEM; struct page *page = NULL; @@ -2290,16 +2288,15 @@ static int nfs4_get_referral(struct inode *dir, const struct qstr *name, goto out; /* Make sure server returned a different fsid for the referral */ if (nfs_fsid_equal(&NFS_SERVER(dir)->fsid, &locations->fattr.fsid)) { - dprintk("%s: server did not return a different fsid for" - " a referral at %s\n", __func__, name->name); + dprintk("%s: server did not return a different fsid for a referral at %s\n", __func__, name->name); status = -EIO; goto out; } - /* Fixup attributes for the nfs_lookup() call to nfs_fhget() */ - nfs_fixup_referral_attributes(&locations->fattr); - /* replace the lookup nfs_fattr with the locations nfs_fattr */ memcpy(fattr, &locations->fattr, sizeof(struct nfs_fattr)); + fattr->valid |= NFS_ATTR_FATTR_V4_REFERRAL; + if (!fattr->mode) + fattr->mode = S_IFDIR; memset(fhandle, 0, sizeof(struct nfs_fh)); out: if (page) @@ -4670,15 +4667,11 @@ static size_t nfs4_xattr_list_nfs4_acl(struct dentry *dentry, char *list, return len; } -/* - * nfs_fhget will use either the mounted_on_fileid or the fileid - */ static void nfs_fixup_referral_attributes(struct nfs_fattr *fattr) { - if (!(((fattr->valid & NFS_ATTR_FATTR_MOUNTED_ON_FILEID) || - (fattr->valid & NFS_ATTR_FATTR_FILEID)) && - (fattr->valid & NFS_ATTR_FATTR_FSID) && - (fattr->valid & NFS_ATTR_FATTR_V4_REFERRAL))) + if (!((fattr->valid & NFS_ATTR_FATTR_FILEID) && + (fattr->valid & NFS_ATTR_FATTR_FSID) && + (fattr->valid & NFS_ATTR_FATTR_V4_REFERRAL))) return; fattr->valid |= NFS_ATTR_FATTR_TYPE | NFS_ATTR_FATTR_MODE | @@ -4693,6 +4686,7 @@ int nfs4_proc_fs_locations(struct inode *dir, const struct qstr *name, struct nfs_server *server = NFS_SERVER(dir); u32 bitmask[2] = { [0] = FATTR4_WORD0_FSID | FATTR4_WORD0_FS_LOCATIONS, + [1] = FATTR4_WORD1_MOUNTED_ON_FILEID, }; struct nfs4_fs_locations_arg args = { .dir_fh = NFS_FH(dir), @@ -4711,18 +4705,11 @@ int nfs4_proc_fs_locations(struct inode *dir, const struct qstr *name, int status; dprintk("%s: start\n", __func__); - - /* Ask for the fileid of the absent filesystem if mounted_on_fileid - * is not supported */ - if (NFS_SERVER(dir)->attr_bitmask[1] & FATTR4_WORD1_MOUNTED_ON_FILEID) - bitmask[1] |= FATTR4_WORD1_MOUNTED_ON_FILEID; - else - bitmask[0] |= FATTR4_WORD0_FILEID; - nfs_fattr_init(&fs_locations->fattr); fs_locations->server = server; fs_locations->nlocations = 0; status = nfs4_call_sync(server->client, server, &msg, &args.seq_args, &res.seq_res, 0); + nfs_fixup_referral_attributes(&fs_locations->fattr); dprintk("%s: returned status = %d\n", __func__, status); return status; } @@ -5111,6 +5098,7 @@ static void nfs4_init_channel_attrs(struct nfs41_create_session_args *args) if (mxresp_sz == 0) mxresp_sz = NFS_MAX_FILE_IO_SIZE; /* Fore channel attributes */ + args->fc_attrs.headerpadsz = 0; args->fc_attrs.max_rqst_sz = mxrqst_sz; args->fc_attrs.max_resp_sz = mxresp_sz; args->fc_attrs.max_ops = NFS4_MAX_OPS; @@ -5123,6 +5111,7 @@ static void nfs4_init_channel_attrs(struct nfs41_create_session_args *args) args->fc_attrs.max_ops, args->fc_attrs.max_reqs); /* Back channel attributes */ + args->bc_attrs.headerpadsz = 0; args->bc_attrs.max_rqst_sz = PAGE_SIZE; args->bc_attrs.max_resp_sz = PAGE_SIZE; args->bc_attrs.max_resp_sz_cached = 0; @@ -5142,6 +5131,8 @@ static int nfs4_verify_fore_channel_attrs(struct nfs41_create_session_args *args struct nfs4_channel_attrs *sent = &args->fc_attrs; struct nfs4_channel_attrs *rcvd = &session->fc_attrs; + if (rcvd->headerpadsz > sent->headerpadsz) + return -EINVAL; if (rcvd->max_resp_sz > sent->max_resp_sz) return -EINVAL; /* @@ -5706,7 +5697,6 @@ static void nfs4_layoutreturn_done(struct rpc_task *task, void *calldata) { struct nfs4_layoutreturn *lrp = calldata; struct nfs_server *server; - struct pnfs_layout_hdr *lo = NFS_I(lrp->args.inode)->layout; dprintk("--> %s\n", __func__); @@ -5718,15 +5708,16 @@ static void nfs4_layoutreturn_done(struct rpc_task *task, void *calldata) nfs_restart_rpc(task, lrp->clp); return; } - spin_lock(&lo->plh_inode->i_lock); if (task->tk_status == 0) { + struct pnfs_layout_hdr *lo = NFS_I(lrp->args.inode)->layout; + if (lrp->res.lrs_present) { + spin_lock(&lo->plh_inode->i_lock); pnfs_set_layout_stateid(lo, &lrp->res.stateid, true); + spin_unlock(&lo->plh_inode->i_lock); } else BUG_ON(!list_empty(&lo->plh_segs)); } - lo->plh_block_lgets--; - spin_unlock(&lo->plh_inode->i_lock); dprintk("<-- %s\n", __func__); } diff --git a/trunk/fs/nfs/nfs4xdr.c b/trunk/fs/nfs/nfs4xdr.c index e6e8f3b9a1de..d869a5e5464b 100644 --- a/trunk/fs/nfs/nfs4xdr.c +++ b/trunk/fs/nfs/nfs4xdr.c @@ -91,7 +91,7 @@ static int nfs4_stat_to_errno(int); #define encode_getfh_maxsz (op_encode_hdr_maxsz) #define decode_getfh_maxsz (op_decode_hdr_maxsz + 1 + \ ((3+NFS4_FHSIZE) >> 2)) -#define nfs4_fattr_bitmap_maxsz 4 +#define nfs4_fattr_bitmap_maxsz 3 #define encode_getattr_maxsz (op_encode_hdr_maxsz + nfs4_fattr_bitmap_maxsz) #define nfs4_name_maxsz (1 + ((3 + NFS4_MAXNAMLEN) >> 2)) #define nfs4_path_maxsz (1 + ((3 + NFS4_MAXPATHLEN) >> 2)) @@ -255,7 +255,7 @@ static int nfs4_stat_to_errno(int); #define decode_fs_locations_maxsz \ (0) #define encode_secinfo_maxsz (op_encode_hdr_maxsz + nfs4_name_maxsz) -#define decode_secinfo_maxsz (op_decode_hdr_maxsz + 1 + ((NFS_MAX_SECFLAVORS * (16 + GSS_OID_MAX_LEN)) / 4)) +#define decode_secinfo_maxsz (op_decode_hdr_maxsz + 4 + (NFS_MAX_SECFLAVORS * (16 + GSS_OID_MAX_LEN))) #if defined(CONFIG_NFS_V4_1) #define NFS4_MAX_MACHINE_NAME_LEN (64) @@ -1725,7 +1725,7 @@ static void encode_create_session(struct xdr_stream *xdr, *p++ = cpu_to_be32(args->flags); /*flags */ /* Fore Channel */ - *p++ = cpu_to_be32(0); /* header padding size */ + *p++ = cpu_to_be32(args->fc_attrs.headerpadsz); /* header padding size */ *p++ = cpu_to_be32(args->fc_attrs.max_rqst_sz); /* max req size */ *p++ = cpu_to_be32(args->fc_attrs.max_resp_sz); /* max resp size */ *p++ = cpu_to_be32(max_resp_sz_cached); /* Max resp sz cached */ @@ -1734,7 +1734,7 @@ static void encode_create_session(struct xdr_stream *xdr, *p++ = cpu_to_be32(0); /* rdmachannel_attrs */ /* Back Channel */ - *p++ = cpu_to_be32(0); /* header padding size */ + *p++ = cpu_to_be32(args->fc_attrs.headerpadsz); /* header padding size */ *p++ = cpu_to_be32(args->bc_attrs.max_rqst_sz); /* max req size */ *p++ = cpu_to_be32(args->bc_attrs.max_resp_sz); /* max resp size */ *p++ = cpu_to_be32(args->bc_attrs.max_resp_sz_cached); /* Max resp sz cached */ @@ -3098,7 +3098,7 @@ static int decode_attr_lease_time(struct xdr_stream *xdr, uint32_t *bitmap, uint return -EIO; } -static int decode_attr_error(struct xdr_stream *xdr, uint32_t *bitmap, int32_t *res) +static int decode_attr_error(struct xdr_stream *xdr, uint32_t *bitmap) { __be32 *p; @@ -3109,7 +3109,7 @@ static int decode_attr_error(struct xdr_stream *xdr, uint32_t *bitmap, int32_t * if (unlikely(!p)) goto out_overflow; bitmap[0] &= ~FATTR4_WORD0_RDATTR_ERROR; - *res = -be32_to_cpup(p); + return -be32_to_cpup(p); } return 0; out_overflow: @@ -4070,7 +4070,6 @@ static int decode_getfattr_attrs(struct xdr_stream *xdr, uint32_t *bitmap, int status; umode_t fmode = 0; uint32_t type; - int32_t err; status = decode_attr_type(xdr, bitmap, &type); if (status < 0) @@ -4096,12 +4095,13 @@ static int decode_getfattr_attrs(struct xdr_stream *xdr, uint32_t *bitmap, goto xdr_error; fattr->valid |= status; - err = 0; - status = decode_attr_error(xdr, bitmap, &err); + status = decode_attr_error(xdr, bitmap); + if (status == -NFS4ERR_WRONGSEC) { + nfs_fixup_secinfo_attributes(fattr, fh); + status = 0; + } if (status < 0) goto xdr_error; - if (err == -NFS4ERR_WRONGSEC) - nfs_fixup_secinfo_attributes(fattr, fh); status = decode_attr_filehandle(xdr, bitmap, fh); if (status < 0) @@ -4997,14 +4997,12 @@ static int decode_chan_attrs(struct xdr_stream *xdr, struct nfs4_channel_attrs *attrs) { __be32 *p; - u32 nr_attrs, val; + u32 nr_attrs; p = xdr_inline_decode(xdr, 28); if (unlikely(!p)) goto out_overflow; - val = be32_to_cpup(p++); /* headerpadsz */ - if (val) - return -EINVAL; /* no support for header padding yet */ + attrs->headerpadsz = be32_to_cpup(p++); attrs->max_rqst_sz = be32_to_cpup(p++); attrs->max_resp_sz = be32_to_cpup(p++); attrs->max_resp_sz_cached = be32_to_cpup(p++); diff --git a/trunk/fs/nfs/objlayout/objio_osd.c b/trunk/fs/nfs/objlayout/objio_osd.c index 8ff2ea3f10ef..9cf208df1f25 100644 --- a/trunk/fs/nfs/objlayout/objio_osd.c +++ b/trunk/fs/nfs/objlayout/objio_osd.c @@ -108,6 +108,7 @@ _dev_list_add(const struct nfs_server *nfss, de = n; } + atomic_inc(&de->id_node.ref); return de; } @@ -1000,9 +1001,6 @@ static bool objio_pg_test(struct nfs_pageio_descriptor *pgio, if (!pnfs_generic_pg_test(pgio, prev, req)) return false; - if (pgio->pg_lseg == NULL) - return true; - return pgio->pg_count + req->wb_bytes <= OBJIO_LSEG(pgio->pg_lseg)->max_io_size; } diff --git a/trunk/fs/nfs/objlayout/objlayout.c b/trunk/fs/nfs/objlayout/objlayout.c index 1d06f8e2adea..dc3956c0de80 100644 --- a/trunk/fs/nfs/objlayout/objlayout.c +++ b/trunk/fs/nfs/objlayout/objlayout.c @@ -291,7 +291,7 @@ objlayout_read_done(struct objlayout_io_state *state, ssize_t status, bool sync) struct nfs_read_data *rdata; state->status = status; - dprintk("%s: Begin status=%zd eof=%d\n", __func__, status, eof); + dprintk("%s: Begin status=%ld eof=%d\n", __func__, status, eof); rdata = state->rpcdata; rdata->task.tk_status = status; if (status >= 0) { diff --git a/trunk/fs/nfs/pagelist.c b/trunk/fs/nfs/pagelist.c index 009855716286..7913961aff22 100644 --- a/trunk/fs/nfs/pagelist.c +++ b/trunk/fs/nfs/pagelist.c @@ -204,7 +204,7 @@ nfs_wait_on_request(struct nfs_page *req) TASK_UNINTERRUPTIBLE); } -bool nfs_generic_pg_test(struct nfs_pageio_descriptor *desc, struct nfs_page *prev, struct nfs_page *req) +static bool nfs_generic_pg_test(struct nfs_pageio_descriptor *desc, struct nfs_page *prev, struct nfs_page *req) { /* * FIXME: ideally we should be able to coalesce all requests @@ -218,7 +218,6 @@ bool nfs_generic_pg_test(struct nfs_pageio_descriptor *desc, struct nfs_page *pr return desc->pg_count + req->wb_bytes <= desc->pg_bsize; } -EXPORT_SYMBOL_GPL(nfs_generic_pg_test); /** * nfs_pageio_init - initialise a page io descriptor diff --git a/trunk/fs/nfs/pnfs.c b/trunk/fs/nfs/pnfs.c index 29c0ca7fc347..8c1309d852a6 100644 --- a/trunk/fs/nfs/pnfs.c +++ b/trunk/fs/nfs/pnfs.c @@ -634,16 +634,14 @@ _pnfs_return_layout(struct inode *ino) spin_lock(&ino->i_lock); lo = nfsi->layout; - if (!lo) { + if (!lo || !mark_matching_lsegs_invalid(lo, &tmp_list, NULL)) { spin_unlock(&ino->i_lock); - dprintk("%s: no layout to return\n", __func__); - return status; + dprintk("%s: no layout segments to return\n", __func__); + goto out; } stateid = nfsi->layout->plh_stateid; /* Reference matched in nfs4_layoutreturn_release */ get_layout_hdr(lo); - mark_matching_lsegs_invalid(lo, &tmp_list, NULL); - lo->plh_block_lgets++; spin_unlock(&ino->i_lock); pnfs_free_lseg_list(&tmp_list); @@ -652,9 +650,6 @@ _pnfs_return_layout(struct inode *ino) lrp = kzalloc(sizeof(*lrp), GFP_KERNEL); if (unlikely(lrp == NULL)) { status = -ENOMEM; - set_bit(NFS_LAYOUT_RW_FAILED, &lo->plh_flags); - set_bit(NFS_LAYOUT_RO_FAILED, &lo->plh_flags); - put_layout_hdr(lo); goto out; } @@ -892,7 +887,7 @@ pnfs_find_lseg(struct pnfs_layout_hdr *lo, ret = get_lseg(lseg); break; } - if (lseg->pls_range.offset > range->offset) + if (cmp_layout(range, &lseg->pls_range) > 0) break; } @@ -1064,36 +1059,23 @@ pnfs_generic_pg_test(struct nfs_pageio_descriptor *pgio, struct nfs_page *prev, gfp_flags = GFP_NOFS; } - if (pgio->pg_lseg == NULL) { - if (pgio->pg_count != prev->wb_bytes) - return true; + if (pgio->pg_count == prev->wb_bytes) { /* This is first coelesce call for a series of nfs_pages */ pgio->pg_lseg = pnfs_update_layout(pgio->pg_inode, prev->wb_context, - req_offset(prev), + req_offset(req), pgio->pg_count, access_type, gfp_flags); - if (pgio->pg_lseg == NULL) - return true; + return true; } - /* - * Test if a nfs_page is fully contained in the pnfs_layout_range. - * Note that this test makes several assumptions: - * - that the previous nfs_page in the struct nfs_pageio_descriptor - * is known to lie within the range. - * - that the nfs_page being tested is known to be contiguous with the - * previous nfs_page. - * - Layout ranges are page aligned, so we only have to test the - * start offset of the request. - * - * Please also note that 'end_offset' is actually the offset of the - * first byte that lies outside the pnfs_layout_range. FIXME? - * - */ - return req_offset(req) < end_offset(pgio->pg_lseg->pls_range.offset, - pgio->pg_lseg->pls_range.length); + if (pgio->pg_lseg && + req_offset(req) > end_offset(pgio->pg_lseg->pls_range.offset, + pgio->pg_lseg->pls_range.length)) + return false; + + return true; } EXPORT_SYMBOL_GPL(pnfs_generic_pg_test); diff --git a/trunk/fs/nfs/pnfs.h b/trunk/fs/nfs/pnfs.h index 96bf4e6f45be..48d0a8e4d062 100644 --- a/trunk/fs/nfs/pnfs.h +++ b/trunk/fs/nfs/pnfs.h @@ -186,7 +186,6 @@ int pnfs_ld_read_done(struct nfs_read_data *); /* pnfs_dev.c */ struct nfs4_deviceid_node { struct hlist_node node; - struct hlist_node tmpnode; const struct pnfs_layoutdriver_type *ld; const struct nfs_client *nfs_client; struct nfs4_deviceid deviceid; diff --git a/trunk/fs/nfs/pnfs_dev.c b/trunk/fs/nfs/pnfs_dev.c index f0f8e1e22f6c..c65e133ce9c0 100644 --- a/trunk/fs/nfs/pnfs_dev.c +++ b/trunk/fs/nfs/pnfs_dev.c @@ -174,7 +174,6 @@ nfs4_init_deviceid_node(struct nfs4_deviceid_node *d, const struct nfs4_deviceid *id) { INIT_HLIST_NODE(&d->node); - INIT_HLIST_NODE(&d->tmpnode); d->ld = ld; d->nfs_client = nfs_client; d->deviceid = *id; @@ -209,7 +208,6 @@ nfs4_insert_deviceid_node(struct nfs4_deviceid_node *new) hlist_add_head_rcu(&new->node, &nfs4_deviceid_cache[hash]); spin_unlock(&nfs4_deviceid_lock); - atomic_inc(&new->ref); return new; } @@ -240,29 +238,24 @@ static void _deviceid_purge_client(const struct nfs_client *clp, long hash) { struct nfs4_deviceid_node *d; - struct hlist_node *n; + struct hlist_node *n, *next; HLIST_HEAD(tmp); - spin_lock(&nfs4_deviceid_lock); rcu_read_lock(); hlist_for_each_entry_rcu(d, n, &nfs4_deviceid_cache[hash], node) if (d->nfs_client == clp && atomic_read(&d->ref)) { hlist_del_init_rcu(&d->node); - hlist_add_head(&d->tmpnode, &tmp); + hlist_add_head(&d->node, &tmp); } rcu_read_unlock(); - spin_unlock(&nfs4_deviceid_lock); if (hlist_empty(&tmp)) return; synchronize_rcu(); - while (!hlist_empty(&tmp)) { - d = hlist_entry(tmp.first, struct nfs4_deviceid_node, tmpnode); - hlist_del(&d->tmpnode); + hlist_for_each_entry_safe(d, n, next, &tmp, node) if (atomic_dec_and_test(&d->ref)) d->ld->free_deviceid_node(d); - } } void @@ -270,8 +263,8 @@ nfs4_deviceid_purge_client(const struct nfs_client *clp) { long h; - if (!(clp->cl_exchange_flags & EXCHGID4_FLAG_USE_PNFS_MDS)) - return; + spin_lock(&nfs4_deviceid_lock); for (h = 0; h < NFS4_DEVICE_ID_HASH_SIZE; h++) _deviceid_purge_client(clp, h); + spin_unlock(&nfs4_deviceid_lock); } diff --git a/trunk/fs/nfs/write.c b/trunk/fs/nfs/write.c index 727168059684..e268e3b23497 100644 --- a/trunk/fs/nfs/write.c +++ b/trunk/fs/nfs/write.c @@ -864,8 +864,6 @@ static int nfs_write_rpcsetup(struct nfs_page *req, data->args.fh = NFS_FH(inode); data->args.offset = req_offset(req) + offset; - /* pnfs_set_layoutcommit needs this */ - data->mds_offset = data->args.offset; data->args.pgbase = req->wb_pgbase + offset; data->args.pages = data->pagevec; data->args.count = count; diff --git a/trunk/fs/omfs/file.c b/trunk/fs/omfs/file.c index 2c6d95257a4d..d738a7e493dd 100644 --- a/trunk/fs/omfs/file.c +++ b/trunk/fs/omfs/file.c @@ -4,6 +4,7 @@ * Released under GPL v2. */ +#include #include #include #include diff --git a/trunk/fs/proc/base.c b/trunk/fs/proc/base.c index fc5bc2767692..8a84210ca080 100644 --- a/trunk/fs/proc/base.c +++ b/trunk/fs/proc/base.c @@ -2708,9 +2708,6 @@ static int do_io_accounting(struct task_struct *task, char *buffer, int whole) struct task_io_accounting acct = task->ioac; unsigned long flags; - if (!ptrace_may_access(task, PTRACE_MODE_READ)) - return -EACCES; - if (whole && lock_task_sighand(task, &flags)) { struct task_struct *t = task; @@ -2842,7 +2839,7 @@ static const struct pid_entry tgid_base_stuff[] = { REG("coredump_filter", S_IRUGO|S_IWUSR, proc_coredump_filter_operations), #endif #ifdef CONFIG_TASK_IO_ACCOUNTING - INF("io", S_IRUSR, proc_tgid_io_accounting), + INF("io", S_IRUGO, proc_tgid_io_accounting), #endif #ifdef CONFIG_HARDWALL INF("hardwall", S_IRUGO, proc_pid_hardwall), @@ -3184,7 +3181,7 @@ static const struct pid_entry tid_base_stuff[] = { REG("make-it-fail", S_IRUGO|S_IWUSR, proc_fault_inject_operations), #endif #ifdef CONFIG_TASK_IO_ACCOUNTING - INF("io", S_IRUSR, proc_tid_io_accounting), + INF("io", S_IRUGO, proc_tid_io_accounting), #endif #ifdef CONFIG_HARDWALL INF("hardwall", S_IRUGO, proc_pid_hardwall), diff --git a/trunk/fs/romfs/mmap-nommu.c b/trunk/fs/romfs/mmap-nommu.c index eed99428f104..f0511e816967 100644 --- a/trunk/fs/romfs/mmap-nommu.c +++ b/trunk/fs/romfs/mmap-nommu.c @@ -27,18 +27,14 @@ static unsigned long romfs_get_unmapped_area(struct file *file, { struct inode *inode = file->f_mapping->host; struct mtd_info *mtd = inode->i_sb->s_mtd; - unsigned long isize, offset, maxpages, lpages; + unsigned long isize, offset; if (!mtd) goto cant_map_directly; - /* the mapping mustn't extend beyond the EOF */ - lpages = (len + PAGE_SIZE - 1) >> PAGE_SHIFT; isize = i_size_read(inode); offset = pgoff << PAGE_SHIFT; - - maxpages = (isize + PAGE_SIZE - 1) >> PAGE_SHIFT; - if ((pgoff >= maxpages) || (maxpages - pgoff < lpages)) + if (offset > isize || len > isize || offset > isize - len) return (unsigned long) -EINVAL; /* we need to call down to the MTD layer to do the actual mapping */ diff --git a/trunk/fs/xfs/xfs_attr.c b/trunk/fs/xfs/xfs_attr.c index 01d2072fb6d4..c86375378810 100644 --- a/trunk/fs/xfs/xfs_attr.c +++ b/trunk/fs/xfs/xfs_attr.c @@ -489,13 +489,6 @@ xfs_attr_remove_int(xfs_inode_t *dp, struct xfs_name *name, int flags) args.total = 0; args.whichfork = XFS_ATTR_FORK; - /* - * we have no control over the attribute names that userspace passes us - * to remove, so we have to allow the name lookup prior to attribute - * removal to fail. - */ - args.op_flags = XFS_DA_OP_OKNOENT; - /* * Attach the dquots to the inode. */ diff --git a/trunk/fs/xfs/xfs_iget.c b/trunk/fs/xfs/xfs_iget.c index 3631783b2b53..cb9b6d1469f7 100644 --- a/trunk/fs/xfs/xfs_iget.c +++ b/trunk/fs/xfs/xfs_iget.c @@ -253,21 +253,16 @@ xfs_iget_cache_hit( rcu_read_lock(); spin_lock(&ip->i_flags_lock); - ip->i_flags &= ~(XFS_INEW | XFS_IRECLAIM); - ASSERT(ip->i_flags & XFS_IRECLAIMABLE); + ip->i_flags &= ~XFS_INEW; + ip->i_flags |= XFS_IRECLAIMABLE; + __xfs_inode_set_reclaim_tag(pag, ip); trace_xfs_iget_reclaim_fail(ip); goto out_error; } spin_lock(&pag->pag_ici_lock); spin_lock(&ip->i_flags_lock); - - /* - * Clear the per-lifetime state in the inode as we are now - * effectively a new inode and need to return to the initial - * state before reuse occurs. - */ - ip->i_flags &= ~XFS_IRECLAIM_RESET_FLAGS; + ip->i_flags &= ~(XFS_IRECLAIMABLE | XFS_IRECLAIM); ip->i_flags |= XFS_INEW; __xfs_inode_clear_reclaim_tag(mp, pag, ip); inode->i_state = I_NEW; diff --git a/trunk/fs/xfs/xfs_inode.h b/trunk/fs/xfs/xfs_inode.h index 964cfea77686..3ae6d58e5473 100644 --- a/trunk/fs/xfs/xfs_inode.h +++ b/trunk/fs/xfs/xfs_inode.h @@ -383,16 +383,6 @@ static inline void xfs_ifunlock(xfs_inode_t *ip) #define XFS_ITRUNCATED 0x0020 /* truncated down so flush-on-close */ #define XFS_IDIRTY_RELEASE 0x0040 /* dirty release already seen */ -/* - * Per-lifetime flags need to be reset when re-using a reclaimable inode during - * inode lookup. Thi prevents unintended behaviour on the new inode from - * ocurring. - */ -#define XFS_IRECLAIM_RESET_FLAGS \ - (XFS_IRECLAIMABLE | XFS_IRECLAIM | \ - XFS_IDIRTY_RELEASE | XFS_ITRUNCATED | \ - XFS_IFILESTREAM); - /* * Flags for inode locking. * Bit ranges: 1<<1 - 1<<16-1 -- iolock/ilock modes (bitfield) diff --git a/trunk/fs/xfs/xfs_inode_item.c b/trunk/fs/xfs/xfs_inode_item.c index b1e88d56069c..09983a3344a5 100644 --- a/trunk/fs/xfs/xfs_inode_item.c +++ b/trunk/fs/xfs/xfs_inode_item.c @@ -681,15 +681,15 @@ xfs_inode_item_unlock( * where the cluster buffer may be unpinned before the inode is inserted into * the AIL during transaction committed processing. If the buffer is unpinned * before the inode item has been committed and inserted, then it is possible - * for the buffer to be written and IO completes before the inode is inserted + * for the buffer to be written and IO completions before the inode is inserted * into the AIL. In that case, we'd be inserting a clean, stale inode into the * AIL which will never get removed. It will, however, get reclaimed which * triggers an assert in xfs_inode_free() complaining about freein an inode * still in the AIL. * - * To avoid this, just unpin the inode directly and return a LSN of -1 so the - * transaction committed code knows that it does not need to do any further - * processing on the item. + * To avoid this, return a lower LSN than the one passed in so that the + * transaction committed code will not move the inode forward in the AIL but + * will still unpin it properly. */ STATIC xfs_lsn_t xfs_inode_item_committed( @@ -699,10 +699,8 @@ xfs_inode_item_committed( struct xfs_inode_log_item *iip = INODE_ITEM(lip); struct xfs_inode *ip = iip->ili_inode; - if (xfs_iflags_test(ip, XFS_ISTALE)) { - xfs_inode_item_unpin(lip, 0); - return -1; - } + if (xfs_iflags_test(ip, XFS_ISTALE)) + return lsn - 1; return lsn; } diff --git a/trunk/fs/xfs/xfs_trans.c b/trunk/fs/xfs/xfs_trans.c index c83f63b33aae..7c7bc2b786bd 100644 --- a/trunk/fs/xfs/xfs_trans.c +++ b/trunk/fs/xfs/xfs_trans.c @@ -1361,7 +1361,7 @@ xfs_trans_item_committed( lip->li_flags |= XFS_LI_ABORTED; item_lsn = IOP_COMMITTED(lip, commit_lsn); - /* item_lsn of -1 means the item needs no further processing */ + /* If the committed routine returns -1, item has been freed. */ if (XFS_LSN_CMP(item_lsn, (xfs_lsn_t)-1) == 0) return; @@ -1474,7 +1474,7 @@ xfs_trans_committed_bulk( lip->li_flags |= XFS_LI_ABORTED; item_lsn = IOP_COMMITTED(lip, commit_lsn); - /* item_lsn of -1 means the item needs no further processing */ + /* item_lsn of -1 means the item was freed */ if (XFS_LSN_CMP(item_lsn, (xfs_lsn_t)-1) == 0) continue; diff --git a/trunk/fs/xfs/xfs_vnodeops.c b/trunk/fs/xfs/xfs_vnodeops.c index 619720705bc6..b7a5fe7c52c8 100644 --- a/trunk/fs/xfs/xfs_vnodeops.c +++ b/trunk/fs/xfs/xfs_vnodeops.c @@ -960,11 +960,8 @@ xfs_release( * be exposed to that problem. */ truncated = xfs_iflags_test_and_clear(ip, XFS_ITRUNCATED); - if (truncated) { - xfs_iflags_clear(ip, XFS_IDIRTY_RELEASE); - if (VN_DIRTY(VFS_I(ip)) && ip->i_delayed_blks > 0) - xfs_flush_pages(ip, 0, -1, XBF_ASYNC, FI_NONE); - } + if (truncated && VN_DIRTY(VFS_I(ip)) && ip->i_delayed_blks > 0) + xfs_flush_pages(ip, 0, -1, XBF_ASYNC, FI_NONE); } if (ip->i_d.di_nlink == 0) diff --git a/trunk/include/linux/amba/serial.h b/trunk/include/linux/amba/serial.h index 514ed45c462e..5479fdc849e9 100644 --- a/trunk/include/linux/amba/serial.h +++ b/trunk/include/linux/amba/serial.h @@ -201,9 +201,6 @@ struct amba_pl011_data { bool (*dma_filter)(struct dma_chan *chan, void *filter_param); void *dma_rx_param; void *dma_tx_param; - void (*init) (void); - void (*exit) (void); - void (*reset) (void); }; #endif diff --git a/trunk/include/linux/ath9k_platform.h b/trunk/include/linux/ath9k_platform.h index 6e3f54f37844..60a7c49dcb49 100644 --- a/trunk/include/linux/ath9k_platform.h +++ b/trunk/include/linux/ath9k_platform.h @@ -30,8 +30,6 @@ struct ath9k_platform_data { u32 gpio_val; bool is_clk_25mhz; - int (*get_mac_revision)(void); - int (*external_reset)(void); }; #endif /* _LINUX_ATH9K_PLATFORM_H */ diff --git a/trunk/include/linux/bcma/bcma.h b/trunk/include/linux/bcma/bcma.h index 3895aeb494a3..6ff080eac0b2 100644 --- a/trunk/include/linux/bcma/bcma.h +++ b/trunk/include/linux/bcma/bcma.h @@ -244,7 +244,6 @@ void bcma_awrite32(struct bcma_device *core, u16 offset, u32 value) } extern bool bcma_core_is_enabled(struct bcma_device *core); -extern void bcma_core_disable(struct bcma_device *core, u32 flags); extern int bcma_core_enable(struct bcma_device *core, u32 flags); #endif /* LINUX_BCMA_H_ */ diff --git a/trunk/include/linux/bcma/bcma_driver_pci.h b/trunk/include/linux/bcma/bcma_driver_pci.h index 3871b668caf9..b7e191cf00ec 100644 --- a/trunk/include/linux/bcma/bcma_driver_pci.h +++ b/trunk/include/linux/bcma/bcma_driver_pci.h @@ -85,7 +85,5 @@ struct bcma_drv_pci { #define pcicore_write32(pc, offset, val) bcma_write32((pc)->core, offset, val) extern void bcma_core_pci_init(struct bcma_drv_pci *pc); -extern int bcma_core_pci_irq_ctl(struct bcma_drv_pci *pc, - struct bcma_device *core, bool enable); #endif /* LINUX_BCMA_DRIVER_PCI_H_ */ diff --git a/trunk/include/linux/blk_types.h b/trunk/include/linux/blk_types.h index 6395692b2e7a..2a7cea53ca0d 100644 --- a/trunk/include/linux/blk_types.h +++ b/trunk/include/linux/blk_types.h @@ -167,7 +167,7 @@ enum rq_flag_bits { (REQ_FAILFAST_DEV | REQ_FAILFAST_TRANSPORT | REQ_FAILFAST_DRIVER) #define REQ_COMMON_MASK \ (REQ_WRITE | REQ_FAILFAST_MASK | REQ_SYNC | REQ_META | REQ_DISCARD | \ - REQ_NOIDLE | REQ_FLUSH | REQ_FUA | REQ_SECURE) + REQ_NOIDLE | REQ_FLUSH | REQ_FUA) #define REQ_CLONE_MASK REQ_COMMON_MASK #define REQ_RAHEAD (1 << __REQ_RAHEAD) diff --git a/trunk/include/linux/blktrace_api.h b/trunk/include/linux/blktrace_api.h index 8c7c2de7631a..b22fb0d3db0f 100644 --- a/trunk/include/linux/blktrace_api.h +++ b/trunk/include/linux/blktrace_api.h @@ -169,8 +169,7 @@ extern void blk_trace_shutdown(struct request_queue *); extern int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev, struct block_device *bdev, struct blk_user_trace_setup *buts); -extern __attribute__((format(printf, 2, 3))) -void __trace_note_message(struct blk_trace *, const char *fmt, ...); +extern void __trace_note_message(struct blk_trace *, const char *fmt, ...); /** * blk_add_trace_msg - Add a (simple) message to the blktrace stream diff --git a/trunk/include/linux/compat.h b/trunk/include/linux/compat.h index 846bb1792572..ddcb7db38e67 100644 --- a/trunk/include/linux/compat.h +++ b/trunk/include/linux/compat.h @@ -467,8 +467,6 @@ asmlinkage long compat_sys_setsockopt(int fd, int level, int optname, char __user *optval, unsigned int optlen); asmlinkage long compat_sys_sendmsg(int fd, struct compat_msghdr __user *msg, unsigned flags); -asmlinkage long compat_sys_sendmmsg(int fd, struct compat_mmsghdr __user *mmsg, - unsigned vlen, unsigned int flags); asmlinkage long compat_sys_recvmsg(int fd, struct compat_msghdr __user *msg, unsigned int flags); asmlinkage long compat_sys_recv(int fd, void __user *buf, size_t len, diff --git a/trunk/include/linux/connector.h b/trunk/include/linux/connector.h index f696bccd48cb..7c60d0942adb 100644 --- a/trunk/include/linux/connector.h +++ b/trunk/include/linux/connector.h @@ -44,7 +44,7 @@ #define CN_VAL_DRBD 0x1 #define CN_KVP_IDX 0x9 /* HyperV KVP */ -#define CN_NETLINK_USERS 10 /* Highest index + 1 */ +#define CN_NETLINK_USERS 9 /* * Maximum connector's message size. diff --git a/trunk/include/linux/dcbnl.h b/trunk/include/linux/dcbnl.h index 65a2562f66b4..66a67235e729 100644 --- a/trunk/include/linux/dcbnl.h +++ b/trunk/include/linux/dcbnl.h @@ -333,30 +333,18 @@ enum ieee_attrs_app { #define DCB_ATTR_IEEE_APP_MAX (__DCB_ATTR_IEEE_APP_MAX - 1) /** - * enum cee_attrs - CEE DCBX get attributes. + * enum cee_attrs - CEE DCBX get attributes * * @DCB_ATTR_CEE_UNSPEC: unspecified * @DCB_ATTR_CEE_PEER_PG: peer PG configuration - get only * @DCB_ATTR_CEE_PEER_PFC: peer PFC configuration - get only - * @DCB_ATTR_CEE_PEER_APP_TABLE: peer APP tlv - get only - * @DCB_ATTR_CEE_TX_PG: TX PG configuration (DCB_CMD_PGTX_GCFG) - * @DCB_ATTR_CEE_RX_PG: RX PG configuration (DCB_CMD_PGRX_GCFG) - * @DCB_ATTR_CEE_PFC: PFC configuration (DCB_CMD_PFC_GCFG) - * @DCB_ATTR_CEE_APP_TABLE: APP configuration (multi DCB_CMD_GAPP) - * @DCB_ATTR_CEE_FEAT: DCBX features flags (DCB_CMD_GFEATCFG) - * - * An aggregated collection of the cee std negotiated parameters. + * @DCB_ATTR_CEE_PEER_APP: peer APP tlv - get only */ enum cee_attrs { DCB_ATTR_CEE_UNSPEC, DCB_ATTR_CEE_PEER_PG, DCB_ATTR_CEE_PEER_PFC, DCB_ATTR_CEE_PEER_APP_TABLE, - DCB_ATTR_CEE_TX_PG, - DCB_ATTR_CEE_RX_PG, - DCB_ATTR_CEE_PFC, - DCB_ATTR_CEE_APP_TABLE, - DCB_ATTR_CEE_FEAT, __DCB_ATTR_CEE_MAX }; #define DCB_ATTR_CEE_MAX (__DCB_ATTR_CEE_MAX - 1) @@ -369,13 +357,6 @@ enum peer_app_attr { }; #define DCB_ATTR_CEE_PEER_APP_MAX (__DCB_ATTR_CEE_PEER_APP_MAX - 1) -enum cee_attrs_app { - DCB_ATTR_CEE_APP_UNSPEC, - DCB_ATTR_CEE_APP, - __DCB_ATTR_CEE_APP_MAX -}; -#define DCB_ATTR_CEE_APP_MAX (__DCB_ATTR_CEE_APP_MAX - 1) - /** * enum dcbnl_pfc_attrs - DCB Priority Flow Control user priority nested attrs * diff --git a/trunk/include/linux/device.h b/trunk/include/linux/device.h index e4f62d8896b7..c66111affca9 100644 --- a/trunk/include/linux/device.h +++ b/trunk/include/linux/device.h @@ -530,6 +530,7 @@ struct device_dma_parameters { * @dma_mem: Internal for coherent mem override. * @archdata: For arch-specific additions. * @of_node: Associated device tree node. + * @of_match: Matching of_device_id from driver. * @devt: For creating the sysfs "dev". * @devres_lock: Spinlock to protect the resource of the device. * @devres_head: The resources list of the device. @@ -653,13 +654,13 @@ static inline int device_is_registered(struct device *dev) static inline void device_enable_async_suspend(struct device *dev) { - if (!dev->power.is_prepared) + if (!dev->power.in_suspend) dev->power.async_suspend = true; } static inline void device_disable_async_suspend(struct device *dev) { - if (!dev->power.is_prepared) + if (!dev->power.in_suspend) dev->power.async_suspend = false; } diff --git a/trunk/include/linux/drbd_limits.h b/trunk/include/linux/drbd_limits.h index 447c36752385..246f576c981d 100644 --- a/trunk/include/linux/drbd_limits.h +++ b/trunk/include/linux/drbd_limits.h @@ -117,10 +117,10 @@ /* drbdsetup XY resize -d Z * you are free to reduce the device size to nothing, if you want to. * the upper limit with 64bit kernel, enough ram and flexible meta data - * is 1 PiB, currently. */ + * is 16 TB, currently. */ /* DRBD_MAX_SECTORS */ #define DRBD_DISK_SIZE_SECT_MIN 0 -#define DRBD_DISK_SIZE_SECT_MAX (1 * (2LLU << 40)) +#define DRBD_DISK_SIZE_SECT_MAX (16 * (2LLU << 30)) #define DRBD_DISK_SIZE_SECT_DEF 0 /* = disabled = no user size... */ #define DRBD_ON_IO_ERROR_DEF EP_PASS_ON diff --git a/trunk/include/linux/etherdevice.h b/trunk/include/linux/etherdevice.h index 05955cf09937..ab68f785fd19 100644 --- a/trunk/include/linux/etherdevice.h +++ b/trunk/include/linux/etherdevice.h @@ -38,7 +38,7 @@ extern int eth_header(struct sk_buff *skb, struct net_device *dev, const void *daddr, const void *saddr, unsigned len); extern int eth_rebuild_header(struct sk_buff *skb); extern int eth_header_parse(const struct sk_buff *skb, unsigned char *haddr); -extern int eth_header_cache(const struct neighbour *neigh, struct hh_cache *hh, __be16 type); +extern int eth_header_cache(const struct neighbour *neigh, struct hh_cache *hh); extern void eth_header_cache_update(struct hh_cache *hh, const struct net_device *dev, const unsigned char *haddr); diff --git a/trunk/include/linux/ethtool.h b/trunk/include/linux/ethtool.h index c6e427ab65fe..048d0fa38d03 100644 --- a/trunk/include/linux/ethtool.h +++ b/trunk/include/linux/ethtool.h @@ -310,21 +310,9 @@ struct ethtool_sset_info { __u32's, etc. */ }; -/** - * enum ethtool_test_flags - flags definition of ethtool_test - * @ETH_TEST_FL_OFFLINE: if set perform online and offline tests, otherwise - * only online tests. - * @ETH_TEST_FL_FAILED: Driver set this flag if test fails. - * @ETH_TEST_FL_EXTERNAL_LB: Application request to perform external loopback - * test. - * @ETH_TEST_FL_EXTERNAL_LB_DONE: Driver performed the external loopback test - */ - enum ethtool_test_flags { - ETH_TEST_FL_OFFLINE = (1 << 0), - ETH_TEST_FL_FAILED = (1 << 1), - ETH_TEST_FL_EXTERNAL_LB = (1 << 2), - ETH_TEST_FL_EXTERNAL_LB_DONE = (1 << 3), + ETH_TEST_FL_OFFLINE = (1 << 0), /* online / offline */ + ETH_TEST_FL_FAILED = (1 << 1), /* test passed / failed */ }; /* for requesting NIC test and getting results*/ diff --git a/trunk/include/linux/fs.h b/trunk/include/linux/fs.h index b5b979247863..6e73e2e9ae33 100644 --- a/trunk/include/linux/fs.h +++ b/trunk/include/linux/fs.h @@ -639,7 +639,6 @@ struct address_space { struct prio_tree_root i_mmap; /* tree of private and shared mappings */ struct list_head i_mmap_nonlinear;/*list VM_NONLINEAR mappings */ struct mutex i_mmap_mutex; /* protect tree, count, list */ - /* Protected by tree_lock together with the radix tree */ unsigned long nrpages; /* number of total pages */ pgoff_t writeback_index;/* writeback starts here */ const struct address_space_operations *a_ops; /* methods */ diff --git a/trunk/include/linux/fscache.h b/trunk/include/linux/fscache.h index 9ec20dec3353..7c4d72f5581f 100644 --- a/trunk/include/linux/fscache.h +++ b/trunk/include/linux/fscache.h @@ -204,8 +204,6 @@ extern bool __fscache_check_page_write(struct fscache_cookie *, struct page *); extern void __fscache_wait_on_page_write(struct fscache_cookie *, struct page *); extern bool __fscache_maybe_release_page(struct fscache_cookie *, struct page *, gfp_t); -extern void __fscache_uncache_all_inode_pages(struct fscache_cookie *, - struct inode *); /** * fscache_register_netfs - Register a filesystem as desiring caching services @@ -645,23 +643,4 @@ bool fscache_maybe_release_page(struct fscache_cookie *cookie, return false; } -/** - * fscache_uncache_all_inode_pages - Uncache all an inode's pages - * @cookie: The cookie representing the inode's cache object. - * @inode: The inode to uncache pages from. - * - * Uncache all the pages in an inode that are marked PG_fscache, assuming them - * to be associated with the given cookie. - * - * This function may sleep. It will wait for pages that are being written out - * and will wait whilst the PG_fscache mark is removed by the cache. - */ -static inline -void fscache_uncache_all_inode_pages(struct fscache_cookie *cookie, - struct inode *inode) -{ - if (fscache_cookie_valid(cookie)) - __fscache_uncache_all_inode_pages(cookie, inode); -} - #endif /* _LINUX_FSCACHE_H */ diff --git a/trunk/include/linux/fsl-diu-fb.h b/trunk/include/linux/fsl-diu-fb.h index daa9952d2174..781d4671415f 100644 --- a/trunk/include/linux/fsl-diu-fb.h +++ b/trunk/include/linux/fsl-diu-fb.h @@ -24,6 +24,12 @@ * See mpc8610fb_set_par(), map_video_memory(), and unmap_video_memory() */ #define MEM_ALLOC_THRESHOLD (1024*768*4+32) +/* Minimum value that the pixel clock can be set to in pico seconds + * This is determined by platform clock/3 where the minimum platform + * clock is 533MHz. This gives 5629 pico seconds. + */ +#define MIN_PIX_CLK 5629 +#define MAX_PIX_CLK 96096 #include diff --git a/trunk/include/linux/hrtimer.h b/trunk/include/linux/hrtimer.h index fd0dc30c9f15..51932e5acf7c 100644 --- a/trunk/include/linux/hrtimer.h +++ b/trunk/include/linux/hrtimer.h @@ -135,7 +135,6 @@ struct hrtimer_sleeper { * @cpu_base: per cpu clock base * @index: clock type index for per_cpu support when moving a * timer to a base on another cpu. - * @clockid: clock id for per_cpu support * @active: red black tree root node for the active timers * @resolution: the resolution of the clock, in nanoseconds * @get_time: function to retrieve the current time of the clock diff --git a/trunk/include/linux/ieee80211.h b/trunk/include/linux/ieee80211.h index a26108e4d924..bf56b6f78270 100644 --- a/trunk/include/linux/ieee80211.h +++ b/trunk/include/linux/ieee80211.h @@ -117,19 +117,8 @@ #define IEEE80211_MAX_MESH_ID_LEN 32 #define IEEE80211_QOS_CTL_LEN 2 -/* 1d tag mask */ -#define IEEE80211_QOS_CTL_TAG1D_MASK 0x0007 -/* TID mask */ -#define IEEE80211_QOS_CTL_TID_MASK 0x000f -/* EOSP */ -#define IEEE80211_QOS_CTL_EOSP 0x0010 -/* ACK policy */ -#define IEEE80211_QOS_CTL_ACK_POLICY_NORMAL 0x0000 -#define IEEE80211_QOS_CTL_ACK_POLICY_NOACK 0x0020 -#define IEEE80211_QOS_CTL_ACK_POLICY_NO_EXPL 0x0040 -#define IEEE80211_QOS_CTL_ACK_POLICY_BLOCKACK 0x0060 -/* A-MSDU 802.11n */ -#define IEEE80211_QOS_CTL_A_MSDU_PRESENT 0x0080 +#define IEEE80211_QOS_CTL_TID_MASK 0x000F +#define IEEE80211_QOS_CTL_TAG1D_MASK 0x0007 /* U-APSD queue for WMM IEs sent by AP */ #define IEEE80211_WMM_IE_AP_QOSINFO_UAPSD (1<<7) @@ -1434,6 +1423,9 @@ enum ieee80211_sa_query_action { }; +/* A-MSDU 802.11n */ +#define IEEE80211_QOS_CONTROL_A_MSDU_PRESENT 0x0080 + /* cipher suite selectors */ #define WLAN_CIPHER_SUITE_USE_GROUP 0x000FAC00 #define WLAN_CIPHER_SUITE_WEP40 0x000FAC01 diff --git a/trunk/include/linux/if_packet.h b/trunk/include/linux/if_packet.h index c1486060f5ed..7b318630139f 100644 --- a/trunk/include/linux/if_packet.h +++ b/trunk/include/linux/if_packet.h @@ -49,12 +49,6 @@ struct sockaddr_ll { #define PACKET_VNET_HDR 15 #define PACKET_TX_TIMESTAMP 16 #define PACKET_TIMESTAMP 17 -#define PACKET_FANOUT 18 - -#define PACKET_FANOUT_HASH 0 -#define PACKET_FANOUT_LB 1 -#define PACKET_FANOUT_CPU 2 -#define PACKET_FANOUT_FLAG_DEFRAG 0x8000 struct tpacket_stats { unsigned int tp_packets; diff --git a/trunk/include/linux/irq.h b/trunk/include/linux/irq.h index baa397eb9c33..8b4538446636 100644 --- a/trunk/include/linux/irq.h +++ b/trunk/include/linux/irq.h @@ -676,8 +676,7 @@ void irq_gc_mask_disable_reg(struct irq_data *d); void irq_gc_mask_set_bit(struct irq_data *d); void irq_gc_mask_clr_bit(struct irq_data *d); void irq_gc_unmask_enable_reg(struct irq_data *d); -void irq_gc_ack_set_bit(struct irq_data *d); -void irq_gc_ack_clr_bit(struct irq_data *d); +void irq_gc_ack(struct irq_data *d); void irq_gc_mask_disable_reg_and_ack(struct irq_data *d); void irq_gc_eoi(struct irq_data *d); int irq_gc_set_wake(struct irq_data *d, unsigned int on); diff --git a/trunk/include/linux/jbd2.h b/trunk/include/linux/jbd2.h index d087c2e7b2aa..4ecb7b16b278 100644 --- a/trunk/include/linux/jbd2.h +++ b/trunk/include/linux/jbd2.h @@ -1024,6 +1024,7 @@ struct journal_s /* Filing buffers */ extern void jbd2_journal_unfile_buffer(journal_t *, struct journal_head *); +extern void __jbd2_journal_unfile_buffer(struct journal_head *); extern void __jbd2_journal_refile_buffer(struct journal_head *); extern void jbd2_journal_refile_buffer(journal_t *, struct journal_head *); extern void __jbd2_journal_file_buffer(struct journal_head *, transaction_t *, int); @@ -1164,6 +1165,7 @@ extern void jbd2_journal_release_jbd_inode(journal_t *journal, struct jbd2_in */ struct journal_head *jbd2_journal_add_journal_head(struct buffer_head *bh); struct journal_head *jbd2_journal_grab_journal_head(struct buffer_head *bh); +void jbd2_journal_remove_journal_head(struct buffer_head *bh); void jbd2_journal_put_journal_head(struct journal_head *jh); /* diff --git a/trunk/include/linux/memory.h b/trunk/include/linux/memory.h index 935699b30b7c..e1e3b2b84f85 100644 --- a/trunk/include/linux/memory.h +++ b/trunk/include/linux/memory.h @@ -20,8 +20,6 @@ #include #include -#define MIN_MEMORY_BLOCK_SIZE (1 << SECTION_SIZE_BITS) - struct memory_block { unsigned long start_section_nr; unsigned long end_section_nr; diff --git a/trunk/include/linux/mfd/ds1wm.h b/trunk/include/linux/mfd/ds1wm.h index 38a372a0e285..be469a357cbb 100644 --- a/trunk/include/linux/mfd/ds1wm.h +++ b/trunk/include/linux/mfd/ds1wm.h @@ -3,11 +3,4 @@ struct ds1wm_driver_data { int active_high; int clock_rate; - /* in milliseconds, the amount of time to */ - /* sleep following a reset pulse. Zero */ - /* should work if your bus devices recover*/ - /* time respects the 1-wire spec since the*/ - /* ds1wm implements the precise timings of*/ - /* a reset pulse/presence detect sequence.*/ - unsigned int reset_recover_delay; }; diff --git a/trunk/include/linux/mmc/card.h b/trunk/include/linux/mmc/card.h index 6ad43554ac05..c6927a4d157f 100644 --- a/trunk/include/linux/mmc/card.h +++ b/trunk/include/linux/mmc/card.h @@ -64,19 +64,6 @@ struct mmc_ext_csd { unsigned long long enhanced_area_offset; /* Units: Byte */ unsigned int enhanced_area_size; /* Units: KB */ unsigned int boot_size; /* in bytes */ - u8 raw_partition_support; /* 160 */ - u8 raw_erased_mem_count; /* 181 */ - u8 raw_ext_csd_structure; /* 194 */ - u8 raw_card_type; /* 196 */ - u8 raw_s_a_timeout; /* 217 */ - u8 raw_hc_erase_gap_size; /* 221 */ - u8 raw_erase_timeout_mult; /* 223 */ - u8 raw_hc_erase_grp_size; /* 224 */ - u8 raw_sec_trim_mult; /* 229 */ - u8 raw_sec_erase_mult; /* 230 */ - u8 raw_sec_feature_support;/* 231 */ - u8 raw_trim_mult; /* 232 */ - u8 raw_sectors[4]; /* 212 - 4 bytes */ }; struct sd_scr { diff --git a/trunk/include/linux/mmzone.h b/trunk/include/linux/mmzone.h index 9f7c3ebcbbad..c928dac6cad0 100644 --- a/trunk/include/linux/mmzone.h +++ b/trunk/include/linux/mmzone.h @@ -647,13 +647,6 @@ typedef struct pglist_data { #endif #define nid_page_nr(nid, pagenr) pgdat_page_nr(NODE_DATA(nid),(pagenr)) -#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn) - -#define node_end_pfn(nid) ({\ - pg_data_t *__pgdat = NODE_DATA(nid);\ - __pgdat->node_start_pfn + __pgdat->node_spanned_pages;\ -}) - #include extern struct mutex zonelists_mutex; diff --git a/trunk/include/linux/netdevice.h b/trunk/include/linux/netdevice.h index 5ccc0cb8352b..011eb89e9582 100644 --- a/trunk/include/linux/netdevice.h +++ b/trunk/include/linux/netdevice.h @@ -60,6 +60,11 @@ struct wireless_dev; #define SET_ETHTOOL_OPS(netdev,ops) \ ( (netdev)->ethtool_ops = (ops) ) +#define HAVE_ALLOC_NETDEV /* feature macro: alloc_xxxdev + functions are available. */ +#define HAVE_FREE_NETDEV /* free_netdev() */ +#define HAVE_NETDEV_PRIV /* netdev_priv() */ + /* hardware address assignment types */ #define NET_ADDR_PERM 0 /* address is permanent (default) */ #define NET_ADDR_RANDOM 1 /* address is generated randomly */ @@ -252,8 +257,20 @@ struct netdev_hw_addr_list { netdev_hw_addr_list_for_each(ha, &(dev)->mc) struct hh_cache { - u16 hh_len; - u16 __pad; + struct hh_cache *hh_next; /* Next entry */ + atomic_t hh_refcnt; /* number of users */ +/* + * We want hh_output, hh_len, hh_lock and hh_data be a in a separate + * cache line on SMP. + * They are mostly read, but hh_refcnt may be changed quite frequently, + * incurring cache line ping pongs. + */ + __be16 hh_type ____cacheline_aligned_in_smp; + /* protocol identifier, f.e ETH_P_IP + * NOTE: For VLANs, this will be the + * encapuslated type. --BLG + */ + u16 hh_len; /* length of header */ int (*hh_output)(struct sk_buff *skb); seqlock_t hh_lock; @@ -266,6 +283,12 @@ struct hh_cache { unsigned long hh_data[HH_DATA_ALIGN(LL_MAX_HEADER) / sizeof(long)]; }; +static inline void hh_cache_put(struct hh_cache *hh) +{ + if (atomic_dec_and_test(&hh->hh_refcnt)) + kfree(hh); +} + /* Reserve HH_DATA_MOD byte aligned hard_header_len, but at least that much. * Alternative is: * dev->hard_header_len ? (dev->hard_header_len + @@ -290,7 +313,8 @@ struct header_ops { const void *saddr, unsigned len); int (*parse)(const struct sk_buff *skb, unsigned char *haddr); int (*rebuild)(struct sk_buff *skb); - int (*cache)(const struct neighbour *neigh, struct hh_cache *hh, __be16 type); +#define HAVE_HEADER_CACHE + int (*cache)(const struct neighbour *neigh, struct hh_cache *hh); void (*cache_update)(struct hh_cache *hh, const struct net_device *dev, const unsigned char *haddr); @@ -863,6 +887,7 @@ struct netdev_tc_txq { * Must return >0 or -errno if it changed dev->features itself. * */ +#define HAVE_NET_DEVICE_OPS struct net_device_ops { int (*ndo_init)(struct net_device *dev); void (*ndo_uninit)(struct net_device *dev); @@ -1756,6 +1781,8 @@ static inline void input_queue_tail_incr_save(struct softnet_data *sd, DECLARE_PER_CPU_ALIGNED(struct softnet_data, softnet_data); +#define HAVE_NETIF_QUEUE + extern void __netif_schedule(struct Qdisc *q); static inline void netif_schedule_queue(struct netdev_queue *txq) @@ -2031,8 +2058,10 @@ extern void dev_kfree_skb_irq(struct sk_buff *skb); */ extern void dev_kfree_skb_any(struct sk_buff *skb); +#define HAVE_NETIF_RX 1 extern int netif_rx(struct sk_buff *skb); extern int netif_rx_ni(struct sk_buff *skb); +#define HAVE_NETIF_RECEIVE_SKB 1 extern int netif_receive_skb(struct sk_buff *skb); extern gro_result_t dev_gro_receive(struct napi_struct *napi, struct sk_buff *skb); @@ -2212,6 +2241,7 @@ extern void netif_device_attach(struct net_device *dev); /* * Network interface message level settings */ +#define HAVE_NETIF_MSG 1 enum { NETIF_MSG_DRV = 0x0001, diff --git a/trunk/include/linux/netlink.h b/trunk/include/linux/netlink.h index 2e17c5dbdcb8..fdd0188a167e 100644 --- a/trunk/include/linux/netlink.h +++ b/trunk/include/linux/netlink.h @@ -49,7 +49,6 @@ struct nlmsghdr { #define NLM_F_MULTI 2 /* Multipart message, terminated by NLMSG_DONE */ #define NLM_F_ACK 4 /* Reply with ack, with zero or error code */ #define NLM_F_ECHO 8 /* Echo this request */ -#define NLM_F_DUMP_INTR 16 /* Dump was inconsistent due to sequence change */ /* Modifiers to GET request */ #define NLM_F_ROOT 0x100 /* specify tree root */ @@ -224,7 +223,6 @@ struct netlink_callback { int (*done)(struct netlink_callback *cb); u16 family; u16 min_dump_alloc; - unsigned int prev_seq, seq; long args[6]; }; diff --git a/trunk/include/linux/netpoll.h b/trunk/include/linux/netpoll.h index 5dfa091c3347..79358bb712c6 100644 --- a/trunk/include/linux/netpoll.h +++ b/trunk/include/linux/netpoll.h @@ -40,6 +40,8 @@ struct netpoll_info { struct netpoll *netpoll; }; +void netpoll_poll_dev(struct net_device *dev); +void netpoll_poll(struct netpoll *np); void netpoll_send_udp(struct netpoll *np, const char *msg, int len); void netpoll_print_options(struct netpoll *np); int netpoll_parse_options(struct netpoll *np, char *opt); diff --git a/trunk/include/linux/nfc.h b/trunk/include/linux/nfc.h deleted file mode 100644 index 330a4c5db588..000000000000 --- a/trunk/include/linux/nfc.h +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright (C) 2011 Instituto Nokia de Tecnologia - * - * Authors: - * Lauro Ramos Venancio - * Aloisio Almeida Jr - * - * 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. - * - * 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., - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef __LINUX_NFC_H -#define __LINUX_NFC_H - -#include -#include - -#define NFC_GENL_NAME "nfc" -#define NFC_GENL_VERSION 1 - -#define NFC_GENL_MCAST_EVENT_NAME "events" - -/** - * enum nfc_commands - supported nfc commands - * - * @NFC_CMD_UNSPEC: unspecified command - * - * @NFC_CMD_GET_DEVICE: request information about a device (requires - * %NFC_ATTR_DEVICE_INDEX) or dump request to get a list of all nfc devices - * @NFC_CMD_START_POLL: start polling for targets using the given protocols - * (requires %NFC_ATTR_DEVICE_INDEX and %NFC_ATTR_PROTOCOLS) - * @NFC_CMD_STOP_POLL: stop polling for targets (requires - * %NFC_ATTR_DEVICE_INDEX) - * @NFC_CMD_GET_TARGET: dump all targets found by the previous poll (requires - * %NFC_ATTR_DEVICE_INDEX) - * @NFC_EVENT_TARGETS_FOUND: event emitted when a new target is found - * (it sends %NFC_ATTR_DEVICE_INDEX) - * @NFC_EVENT_DEVICE_ADDED: event emitted when a new device is registred - * (it sends %NFC_ATTR_DEVICE_NAME, %NFC_ATTR_DEVICE_INDEX and - * %NFC_ATTR_PROTOCOLS) - * @NFC_EVENT_DEVICE_REMOVED: event emitted when a device is removed - * (it sends %NFC_ATTR_DEVICE_INDEX) - */ -enum nfc_commands { - NFC_CMD_UNSPEC, - NFC_CMD_GET_DEVICE, - NFC_CMD_START_POLL, - NFC_CMD_STOP_POLL, - NFC_CMD_GET_TARGET, - NFC_EVENT_TARGETS_FOUND, - NFC_EVENT_DEVICE_ADDED, - NFC_EVENT_DEVICE_REMOVED, -/* private: internal use only */ - __NFC_CMD_AFTER_LAST -}; -#define NFC_CMD_MAX (__NFC_CMD_AFTER_LAST - 1) - -/** - * enum nfc_attrs - supported nfc attributes - * - * @NFC_ATTR_UNSPEC: unspecified attribute - * - * @NFC_ATTR_DEVICE_INDEX: index of nfc device - * @NFC_ATTR_DEVICE_NAME: device name, max 8 chars - * @NFC_ATTR_PROTOCOLS: nfc protocols - bitwise or-ed combination from - * NFC_PROTO_*_MASK constants - * @NFC_ATTR_TARGET_INDEX: index of the nfc target - * @NFC_ATTR_TARGET_SENS_RES: NFC-A targets extra information such as NFCID - * @NFC_ATTR_TARGET_SEL_RES: NFC-A targets extra information (useful if the - * target is not NFC-Forum compliant) - */ -enum nfc_attrs { - NFC_ATTR_UNSPEC, - NFC_ATTR_DEVICE_INDEX, - NFC_ATTR_DEVICE_NAME, - NFC_ATTR_PROTOCOLS, - NFC_ATTR_TARGET_INDEX, - NFC_ATTR_TARGET_SENS_RES, - NFC_ATTR_TARGET_SEL_RES, -/* private: internal use only */ - __NFC_ATTR_AFTER_LAST -}; -#define NFC_ATTR_MAX (__NFC_ATTR_AFTER_LAST - 1) - -#define NFC_DEVICE_NAME_MAXSIZE 8 - -/* NFC protocols */ -#define NFC_PROTO_JEWEL 1 -#define NFC_PROTO_MIFARE 2 -#define NFC_PROTO_FELICA 3 -#define NFC_PROTO_ISO14443 4 -#define NFC_PROTO_NFC_DEP 5 - -#define NFC_PROTO_MAX 6 - -/* NFC protocols masks used in bitsets */ -#define NFC_PROTO_JEWEL_MASK (1 << NFC_PROTO_JEWEL) -#define NFC_PROTO_MIFARE_MASK (1 << NFC_PROTO_MIFARE) -#define NFC_PROTO_FELICA_MASK (1 << NFC_PROTO_FELICA) -#define NFC_PROTO_ISO14443_MASK (1 << NFC_PROTO_ISO14443) -#define NFC_PROTO_NFC_DEP_MASK (1 << NFC_PROTO_NFC_DEP) - -struct sockaddr_nfc { - sa_family_t sa_family; - __u32 dev_idx; - __u32 target_idx; - __u32 nfc_protocol; -}; - -/* NFC socket protocols */ -#define NFC_SOCKPROTO_RAW 0 -#define NFC_SOCKPROTO_MAX 1 - -#endif /*__LINUX_NFC_H */ diff --git a/trunk/include/linux/nfs_page.h b/trunk/include/linux/nfs_page.h index 25311b3bedf8..3a34e80ae92f 100644 --- a/trunk/include/linux/nfs_page.h +++ b/trunk/include/linux/nfs_page.h @@ -92,9 +92,6 @@ extern int nfs_pageio_add_request(struct nfs_pageio_descriptor *, struct nfs_page *); extern void nfs_pageio_complete(struct nfs_pageio_descriptor *desc); extern void nfs_pageio_cond_complete(struct nfs_pageio_descriptor *, pgoff_t); -extern bool nfs_generic_pg_test(struct nfs_pageio_descriptor *desc, - struct nfs_page *prev, - struct nfs_page *req); extern int nfs_wait_on_request(struct nfs_page *); extern void nfs_unlock_request(struct nfs_page *req); extern int nfs_set_page_tag_locked(struct nfs_page *req); diff --git a/trunk/include/linux/nfs_xdr.h b/trunk/include/linux/nfs_xdr.h index 00848d86ffb2..5e8444a11adf 100644 --- a/trunk/include/linux/nfs_xdr.h +++ b/trunk/include/linux/nfs_xdr.h @@ -158,6 +158,7 @@ struct nfs_seqid; /* nfs41 sessions channel attributes */ struct nfs4_channel_attrs { + u32 headerpadsz; u32 max_rqst_sz; u32 max_resp_sz; u32 max_resp_sz_cached; diff --git a/trunk/include/linux/nl80211.h b/trunk/include/linux/nl80211.h index 3ec2f949bf7a..c7ccaae15af6 100644 --- a/trunk/include/linux/nl80211.h +++ b/trunk/include/linux/nl80211.h @@ -483,14 +483,6 @@ * more background information, see * http://wireless.kernel.org/en/users/Documentation/WoWLAN. * - * @NL80211_CMD_SET_REKEY_OFFLOAD: This command is used give the driver - * the necessary information for supporting GTK rekey offload. This - * feature is typically used during WoWLAN. The configuration data - * is contained in %NL80211_ATTR_REKEY_DATA (which is nested and - * contains the data in sub-attributes). After rekeying happened, - * this command may also be sent by the driver as an MLME event to - * inform userspace of the new replay counter. - * * @NL80211_CMD_MAX: highest used command number * @__NL80211_CMD_AFTER_LAST: internal use */ @@ -613,8 +605,6 @@ enum nl80211_commands { NL80211_CMD_SCHED_SCAN_RESULTS, NL80211_CMD_SCHED_SCAN_STOPPED, - NL80211_CMD_SET_REKEY_OFFLOAD, - /* add new commands above here */ /* used to define NL80211_CMD_MAX below */ @@ -1006,9 +996,6 @@ enum nl80211_commands { * are managed in software: interfaces of these types aren't subject to * any restrictions in their number or combinations. * - * @%NL80211_ATTR_REKEY_DATA: nested attribute containing the information - * necessary for GTK rekeying in the device, see &enum nl80211_rekey_data. - * * @NL80211_ATTR_MAX: highest attribute number currently defined * @__NL80211_ATTR_AFTER_LAST: internal use */ @@ -1207,8 +1194,6 @@ enum nl80211_attrs { NL80211_ATTR_INTERFACE_COMBINATIONS, NL80211_ATTR_SOFTWARE_IFTYPES, - NL80211_ATTR_REKEY_DATA, - /* add attributes here, update the policy in nl80211.c */ __NL80211_ATTR_AFTER_LAST, @@ -2376,28 +2361,4 @@ enum nl80211_plink_state { MAX_NL80211_PLINK_STATES = NUM_NL80211_PLINK_STATES - 1 }; -#define NL80211_KCK_LEN 16 -#define NL80211_KEK_LEN 16 -#define NL80211_REPLAY_CTR_LEN 8 - -/** - * enum nl80211_rekey_data - attributes for GTK rekey offload - * @__NL80211_REKEY_DATA_INVALID: invalid number for nested attributes - * @NL80211_REKEY_DATA_KEK: key encryption key (binary) - * @NL80211_REKEY_DATA_KCK: key confirmation key (binary) - * @NL80211_REKEY_DATA_REPLAY_CTR: replay counter (binary) - * @NUM_NL80211_REKEY_DATA: number of rekey attributes (internal) - * @MAX_NL80211_REKEY_DATA: highest rekey attribute (internal) - */ -enum nl80211_rekey_data { - __NL80211_REKEY_DATA_INVALID, - NL80211_REKEY_DATA_KEK, - NL80211_REKEY_DATA_KCK, - NL80211_REKEY_DATA_REPLAY_CTR, - - /* keep last */ - NUM_NL80211_REKEY_DATA, - MAX_NL80211_REKEY_DATA = NUM_NL80211_REKEY_DATA - 1 -}; - #endif /* __LINUX_NL80211_H */ diff --git a/trunk/include/linux/pci_ids.h b/trunk/include/linux/pci_ids.h index 057093043067..d76bd9e4c784 100644 --- a/trunk/include/linux/pci_ids.h +++ b/trunk/include/linux/pci_ids.h @@ -1537,7 +1537,6 @@ #define PCI_DEVICE_ID_RICOH_RL5C476 0x0476 #define PCI_DEVICE_ID_RICOH_RL5C478 0x0478 #define PCI_DEVICE_ID_RICOH_R5C822 0x0822 -#define PCI_DEVICE_ID_RICOH_R5CE823 0xe823 #define PCI_DEVICE_ID_RICOH_R5C832 0x0832 #define PCI_DEVICE_ID_RICOH_R5C843 0x0843 diff --git a/trunk/include/linux/pm.h b/trunk/include/linux/pm.h index 411e4f4be52b..3160648ccdda 100644 --- a/trunk/include/linux/pm.h +++ b/trunk/include/linux/pm.h @@ -425,8 +425,7 @@ struct dev_pm_info { pm_message_t power_state; unsigned int can_wakeup:1; unsigned int async_suspend:1; - bool is_prepared:1; /* Owned by the PM core */ - bool is_suspended:1; /* Ditto */ + unsigned int in_suspend:1; /* Owned by the PM core */ spinlock_t lock; #ifdef CONFIG_PM_SLEEP struct list_head entry; diff --git a/trunk/include/linux/sched.h b/trunk/include/linux/sched.h index 496770a96487..a837b20ba190 100644 --- a/trunk/include/linux/sched.h +++ b/trunk/include/linux/sched.h @@ -808,7 +808,7 @@ enum cpu_idle_type { * when BITS_PER_LONG <= 32 are pretty high and the returns do not justify the * increased costs. */ -#if 0 /* BITS_PER_LONG > 32 -- currently broken: it increases power usage under light load */ +#if BITS_PER_LONG > 32 # define SCHED_LOAD_RESOLUTION 10 # define scale_load(w) ((w) << SCHED_LOAD_RESOLUTION) # define scale_load_down(w) ((w) >> SCHED_LOAD_RESOLUTION) diff --git a/trunk/include/linux/shmem_fs.h b/trunk/include/linux/shmem_fs.h index aa08fa8fd79b..2b7fec840517 100644 --- a/trunk/include/linux/shmem_fs.h +++ b/trunk/include/linux/shmem_fs.h @@ -3,7 +3,6 @@ #include #include -#include #include /* inode in-kernel data */ @@ -46,27 +45,7 @@ static inline struct shmem_inode_info *SHMEM_I(struct inode *inode) return container_of(inode, struct shmem_inode_info, vfs_inode); } -/* - * Functions in mm/shmem.c called directly from elsewhere: - */ extern int init_tmpfs(void); extern int shmem_fill_super(struct super_block *sb, void *data, int silent); -extern struct file *shmem_file_setup(const char *name, - loff_t size, unsigned long flags); -extern int shmem_zero_setup(struct vm_area_struct *); -extern int shmem_lock(struct file *file, int lock, struct user_struct *user); -extern struct page *shmem_read_mapping_page_gfp(struct address_space *mapping, - pgoff_t index, gfp_t gfp_mask); -extern void shmem_truncate_range(struct inode *inode, loff_t start, loff_t end); -extern int shmem_unuse(swp_entry_t entry, struct page *page); -extern void mem_cgroup_get_shmem_target(struct inode *inode, pgoff_t pgoff, - struct page **pagep, swp_entry_t *ent); - -static inline struct page *shmem_read_mapping_page( - struct address_space *mapping, pgoff_t index) -{ - return shmem_read_mapping_page_gfp(mapping, index, - mapping_gfp_mask(mapping)); -} #endif diff --git a/trunk/include/linux/skbuff.h b/trunk/include/linux/skbuff.h index a24218c9c84b..3e543371254e 100644 --- a/trunk/include/linux/skbuff.h +++ b/trunk/include/linux/skbuff.h @@ -187,20 +187,6 @@ enum { /* ensure the originating sk reference is available on driver level */ SKBTX_DRV_NEEDS_SK_REF = 1 << 3, - - /* device driver supports TX zero-copy buffers */ - SKBTX_DEV_ZEROCOPY = 1 << 4, -}; - -/* - * The callback notifies userspace to release buffers when skb DMA is done in - * lower device, the skb last reference should be 0 when calling this. - * The desc is used to track userspace buffer index. - */ -struct ubuf_info { - void (*callback)(void *); - void *arg; - unsigned long desc; }; /* This data is invariant across clones and lives at @@ -225,7 +211,6 @@ struct skb_shared_info { /* Intermediate layers must ensure that destructor_arg * remains valid until skb destructor */ void * destructor_arg; - /* must be last field, see pskb_expand_head() */ skb_frag_t frags[MAX_SKB_FRAGS]; }; @@ -285,12 +270,15 @@ typedef unsigned char *sk_buff_data_t; * struct sk_buff - socket buffer * @next: Next buffer in list * @prev: Previous buffer in list - * @tstamp: Time we arrived * @sk: Socket we are owned by + * @tstamp: Time we arrived * @dev: Device we arrived on/are leaving by - * @cb: Control buffer. Free for use by every layer. Put private vars here + * @transport_header: Transport layer header + * @network_header: Network layer header + * @mac_header: Link layer header * @_skb_refdst: destination entry (with norefcount bit) * @sp: the security path, used for xfrm + * @cb: Control buffer. Free for use by every layer. Put private vars here * @len: Length of actual data * @data_len: Data length * @mac_len: Length of link layer header @@ -298,45 +286,40 @@ typedef unsigned char *sk_buff_data_t; * @csum: Checksum (must include start/offset pair) * @csum_start: Offset from skb->head where checksumming should start * @csum_offset: Offset from csum_start where checksum should be stored - * @priority: Packet queueing priority * @local_df: allow local fragmentation * @cloned: Head may be cloned (check refcnt to be sure) - * @ip_summed: Driver fed us an IP checksum * @nohdr: Payload reference only, must not modify header - * @nfctinfo: Relationship of this skb to the connection * @pkt_type: Packet class * @fclone: skbuff clone status + * @ip_summed: Driver fed us an IP checksum + * @priority: Packet queueing priority + * @users: User count - see {datagram,tcp}.c + * @protocol: Packet protocol from driver + * @truesize: Buffer size + * @head: Head of buffer + * @data: Data head pointer + * @tail: Tail pointer + * @end: End pointer + * @destructor: Destruct function + * @mark: Generic packet mark + * @nfct: Associated connection, if any * @ipvs_property: skbuff is owned by ipvs * @peeked: this packet has been seen already, so stats have been * done for it, don't do them again * @nf_trace: netfilter packet trace flag - * @protocol: Packet protocol from driver - * @destructor: Destruct function - * @nfct: Associated connection, if any + * @nfctinfo: Relationship of this skb to the connection * @nfct_reasm: netfilter conntrack re-assembly pointer * @nf_bridge: Saved data about a bridged frame - see br_netfilter.c * @skb_iif: ifindex of device we arrived on - * @tc_index: Traffic control index - * @tc_verd: traffic control verdict * @rxhash: the packet hash computed on receive * @queue_mapping: Queue mapping for multiqueue devices + * @tc_index: Traffic control index + * @tc_verd: traffic control verdict * @ndisc_nodetype: router type (from link layer) - * @ooo_okay: allow the mapping of a socket to a queue to be changed * @dma_cookie: a cookie to one of several possible DMA operations * done by skb DMA functions * @secmark: security marking - * @mark: Generic packet mark - * @dropcount: total number of sk_receive_queue overflows * @vlan_tci: vlan tag control information - * @transport_header: Transport layer header - * @network_header: Network layer header - * @mac_header: Link layer header - * @tail: Tail pointer - * @end: End pointer - * @head: Head of buffer - * @data: Data head pointer - * @truesize: Buffer size - * @users: User count - see {datagram,tcp}.c */ struct sk_buff { @@ -1579,22 +1562,16 @@ static inline struct sk_buff *netdev_alloc_skb(struct net_device *dev, return __netdev_alloc_skb(dev, length, GFP_ATOMIC); } -static inline struct sk_buff *__netdev_alloc_skb_ip_align(struct net_device *dev, - unsigned int length, gfp_t gfp) +static inline struct sk_buff *netdev_alloc_skb_ip_align(struct net_device *dev, + unsigned int length) { - struct sk_buff *skb = __netdev_alloc_skb(dev, length + NET_IP_ALIGN, gfp); + struct sk_buff *skb = netdev_alloc_skb(dev, length + NET_IP_ALIGN); if (NET_IP_ALIGN && skb) skb_reserve(skb, NET_IP_ALIGN); return skb; } -static inline struct sk_buff *netdev_alloc_skb_ip_align(struct net_device *dev, - unsigned int length) -{ - return __netdev_alloc_skb_ip_align(dev, length, GFP_ATOMIC); -} - /** * __netdev_alloc_page - allocate a page for ps-rx on a specific device * @dev: network device to receive on @@ -2288,6 +2265,5 @@ static inline void skb_checksum_none_assert(struct sk_buff *skb) } bool skb_partial_csum_set(struct sk_buff *skb, u16 start, u16 off); - #endif /* __KERNEL__ */ #endif /* _LINUX_SKBUFF_H */ diff --git a/trunk/include/linux/socket.h b/trunk/include/linux/socket.h index e17f82266639..4ef98e422fde 100644 --- a/trunk/include/linux/socket.h +++ b/trunk/include/linux/socket.h @@ -192,8 +192,7 @@ struct ucred { #define AF_IEEE802154 36 /* IEEE802154 sockets */ #define AF_CAIF 37 /* CAIF sockets */ #define AF_ALG 38 /* Algorithm sockets */ -#define AF_NFC 39 /* NFC sockets */ -#define AF_MAX 40 /* For now.. */ +#define AF_MAX 39 /* For now.. */ /* Protocol families, same as address families. */ #define PF_UNSPEC AF_UNSPEC @@ -235,7 +234,6 @@ struct ucred { #define PF_IEEE802154 AF_IEEE802154 #define PF_CAIF AF_CAIF #define PF_ALG AF_ALG -#define PF_NFC AF_NFC #define PF_MAX AF_MAX /* Maximum queue length specifiable by listen. */ diff --git a/trunk/include/linux/ssb/ssb.h b/trunk/include/linux/ssb/ssb.h index b0928c10111b..252e44821787 100644 --- a/trunk/include/linux/ssb/ssb.h +++ b/trunk/include/linux/ssb/ssb.h @@ -99,7 +99,7 @@ struct ssb_sprom { struct ssb_boardinfo { u16 vendor; u16 type; - u8 rev; + u16 rev; }; diff --git a/trunk/include/linux/sunrpc/sched.h b/trunk/include/linux/sunrpc/sched.h index fe2d8e6b923b..f73c482ec9c6 100644 --- a/trunk/include/linux/sunrpc/sched.h +++ b/trunk/include/linux/sunrpc/sched.h @@ -84,8 +84,7 @@ struct rpc_task { #endif unsigned char tk_priority : 2,/* Task priority */ tk_garb_retry : 2, - tk_cred_retry : 2, - tk_rebind_retry : 2; + tk_cred_retry : 2; }; #define tk_xprt tk_client->cl_xprt diff --git a/trunk/include/linux/swap.h b/trunk/include/linux/swap.h index a273468f8285..e70564647039 100644 --- a/trunk/include/linux/swap.h +++ b/trunk/include/linux/swap.h @@ -300,6 +300,16 @@ static inline void scan_unevictable_unregister_node(struct node *node) extern int kswapd_run(int nid); extern void kswapd_stop(int nid); +#ifdef CONFIG_MMU +/* linux/mm/shmem.c */ +extern int shmem_unuse(swp_entry_t entry, struct page *page); +#endif /* CONFIG_MMU */ + +#ifdef CONFIG_CGROUP_MEM_RES_CTLR +extern void mem_cgroup_get_shmem_target(struct inode *inode, pgoff_t pgoff, + struct page **pagep, swp_entry_t *ent); +#endif + #ifdef CONFIG_SWAP /* linux/mm/page_io.c */ extern int swap_readpage(struct page *); diff --git a/trunk/include/media/lirc_dev.h b/trunk/include/media/lirc_dev.h index 168dd0b1bae2..630e702c9511 100644 --- a/trunk/include/media/lirc_dev.h +++ b/trunk/include/media/lirc_dev.h @@ -9,7 +9,7 @@ #ifndef _LINUX_LIRC_DEV_H #define _LINUX_LIRC_DEV_H -#define MAX_IRCTL_DEVICES 8 +#define MAX_IRCTL_DEVICES 4 #define BUFLEN 16 #define mod(n, div) ((n) % (div)) diff --git a/trunk/include/media/m5mols.h b/trunk/include/media/m5mols.h index aac2c0e06d5e..2d7e7ca2313d 100644 --- a/trunk/include/media/m5mols.h +++ b/trunk/include/media/m5mols.h @@ -2,10 +2,10 @@ * Driver header for M-5MOLS 8M Pixel camera sensor with ISP * * Copyright (C) 2011 Samsung Electronics Co., Ltd. - * Author: HeungJun Kim + * Author: HeungJun Kim, riverful.kim@samsung.com * * Copyright (C) 2009 Samsung Electronics Co., Ltd. - * Author: Dongsoo Nathaniel Kim + * Author: Dongsoo Nathaniel Kim, dongsoo45.kim@samsung.com * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/trunk/include/media/v4l2-subdev.h b/trunk/include/media/v4l2-subdev.h index 2884e3e69cb1..1562c4ff3a65 100644 --- a/trunk/include/media/v4l2-subdev.h +++ b/trunk/include/media/v4l2-subdev.h @@ -173,20 +173,16 @@ struct v4l2_subdev_core_ops { struct v4l2_event_subscription *sub); }; -/* s_radio: v4l device was opened in radio mode. +/* s_mode: switch the tuner to a specific tuner mode. Replacement of s_radio. - g_frequency: freq->type must be filled in. Normally done by video_ioctl2 - or the bridge driver. - - g_tuner: - s_tuner: vt->type must be filled in. Normally done by video_ioctl2 or the - bridge driver. + s_radio: v4l device was opened in Radio mode, to be replaced by s_mode. s_type_addr: sets tuner type and its I2C addr. s_config: sets tda9887 specific stuff, like port1, port2 and qss */ struct v4l2_subdev_tuner_ops { + int (*s_mode)(struct v4l2_subdev *sd, enum v4l2_tuner_type); int (*s_radio)(struct v4l2_subdev *sd); int (*s_frequency)(struct v4l2_subdev *sd, struct v4l2_frequency *freq); int (*g_frequency)(struct v4l2_subdev *sd, struct v4l2_frequency *freq); diff --git a/trunk/include/net/act_api.h b/trunk/include/net/act_api.h index c739531e1564..bab385f13ac3 100644 --- a/trunk/include/net/act_api.h +++ b/trunk/include/net/act_api.h @@ -72,7 +72,7 @@ struct tcf_act_hdr { struct tc_action { void *priv; - const struct tc_action_ops *ops; + struct tc_action_ops *ops; __u32 type; /* for backward compat(TCA_OLD_COMPAT) */ __u32 order; struct tc_action *next; @@ -86,7 +86,7 @@ struct tc_action_ops { __u32 type; /* TBD to match kind */ __u32 capab; /* capabilities includes 4 bit version */ struct module *owner; - int (*act)(struct sk_buff *, const struct tc_action *, struct tcf_result *); + int (*act)(struct sk_buff *, struct tc_action *, struct tcf_result *); int (*get_stats)(struct sk_buff *, struct tc_action *); int (*dump)(struct sk_buff *, struct tc_action *, int, int); int (*cleanup)(struct tc_action *, int bind); @@ -115,7 +115,7 @@ extern void tcf_hash_insert(struct tcf_common *p, struct tcf_hashinfo *hinfo); extern int tcf_register_action(struct tc_action_ops *a); extern int tcf_unregister_action(struct tc_action_ops *a); extern void tcf_action_destroy(struct tc_action *a, int bind); -extern int tcf_action_exec(struct sk_buff *skb, const struct tc_action *a, struct tcf_result *res); +extern int tcf_action_exec(struct sk_buff *skb, struct tc_action *a, struct tcf_result *res); extern struct tc_action *tcf_action_init(struct nlattr *nla, struct nlattr *est, char *n, int ovr, int bind); extern struct tc_action *tcf_action_init_1(struct nlattr *nla, struct nlattr *est, char *n, int ovr, int bind); extern int tcf_action_dump(struct sk_buff *skb, struct tc_action *a, int, int); diff --git a/trunk/include/net/arp.h b/trunk/include/net/arp.h index 5e669e6ffb42..91f0568a04ef 100644 --- a/trunk/include/net/arp.h +++ b/trunk/include/net/arp.h @@ -8,45 +8,6 @@ extern struct neigh_table arp_tbl; -static inline u32 arp_hashfn(u32 key, const struct net_device *dev, u32 hash_rnd) -{ - u32 val = key ^ dev->ifindex; - - return val * hash_rnd; -} - -static inline struct neighbour *__ipv4_neigh_lookup(struct neigh_table *tbl, struct net_device *dev, u32 key) -{ - struct neigh_hash_table *nht; - struct neighbour *n; - u32 hash_val; - - rcu_read_lock_bh(); - nht = rcu_dereference_bh(tbl->nht); - hash_val = arp_hashfn(key, dev, nht->hash_rnd) >> (32 - nht->hash_shift); - for (n = rcu_dereference_bh(nht->hash_buckets[hash_val]); - n != NULL; - n = rcu_dereference_bh(n->next)) { - if (n->dev == dev && *(u32 *)n->primary_key == key) { - if (!atomic_inc_not_zero(&n->refcnt)) - n = NULL; - break; - } - } - rcu_read_unlock_bh(); - - return n; -} - -static inline struct neighbour *ipv4_neigh_lookup(struct neigh_table *tbl, struct net_device *dev, const __be32 *pkey) -{ - struct neighbour *n = __ipv4_neigh_lookup(tbl, dev, - *(__force u32 *)pkey); - if (n) - return n; - return neigh_create(tbl, pkey, dev); -} - extern void arp_init(void); extern int arp_find(unsigned char *haddr, struct sk_buff *skb); extern int arp_ioctl(struct net *net, unsigned int cmd, void __user *arg); @@ -54,6 +15,7 @@ extern void arp_send(int type, int ptype, __be32 dest_ip, struct net_device *dev, __be32 src_ip, const unsigned char *dest_hw, const unsigned char *src_hw, const unsigned char *th); +extern int arp_bind_neighbour(struct dst_entry *dst); extern int arp_mc_map(__be32 addr, u8 *haddr, struct net_device *dev, int dir); extern void arp_ifdown(struct net_device *dev); diff --git a/trunk/include/net/bluetooth/bluetooth.h b/trunk/include/net/bluetooth/bluetooth.h index 7bccaf921cab..43750439c521 100644 --- a/trunk/include/net/bluetooth/bluetooth.h +++ b/trunk/include/net/bluetooth/bluetooth.h @@ -69,13 +69,6 @@ struct bt_security { #define BT_FLUSHABLE_OFF 0 #define BT_FLUSHABLE_ON 1 -#define BT_POWER 9 -struct bt_power { - __u8 force_active; -}; -#define BT_POWER_FORCE_ACTIVE_OFF 0 -#define BT_POWER_FORCE_ACTIVE_ON 1 - #define BT_INFO(fmt, arg...) printk(KERN_INFO "Bluetooth: " fmt "\n" , ## arg) #define BT_ERR(fmt, arg...) printk(KERN_ERR "%s: " fmt "\n" , __func__ , ## arg) #define BT_DBG(fmt, arg...) pr_debug("%s: " fmt "\n" , __func__ , ## arg) @@ -137,8 +130,7 @@ int bt_sock_register(int proto, const struct net_proto_family *ops); int bt_sock_unregister(int proto); void bt_sock_link(struct bt_sock_list *l, struct sock *s); void bt_sock_unlink(struct bt_sock_list *l, struct sock *s); -int bt_sock_recvmsg(struct kiocb *iocb, struct socket *sock, - struct msghdr *msg, size_t len, int flags); +int bt_sock_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, size_t len, int flags); int bt_sock_stream_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, size_t len, int flags); uint bt_sock_poll(struct file * file, struct socket *sock, poll_table *wait); @@ -158,7 +150,6 @@ struct bt_skb_cb { __u8 retries; __u8 sar; unsigned short channel; - __u8 force_active; }; #define bt_cb(skb) ((struct bt_skb_cb *)((skb)->cb)) @@ -173,8 +164,8 @@ static inline struct sk_buff *bt_skb_alloc(unsigned int len, gfp_t how) return skb; } -static inline struct sk_buff *bt_skb_send_alloc(struct sock *sk, - unsigned long len, int nb, int *err) +static inline struct sk_buff *bt_skb_send_alloc(struct sock *sk, unsigned long len, + int nb, int *err) { struct sk_buff *skb; diff --git a/trunk/include/net/bluetooth/hci.h b/trunk/include/net/bluetooth/hci.h index 65345cd215be..0c20227e57f6 100644 --- a/trunk/include/net/bluetooth/hci.h +++ b/trunk/include/net/bluetooth/hci.h @@ -710,12 +710,6 @@ struct hci_rp_le_read_buffer_size { __u8 le_max_pkt; } __packed; -#define HCI_OP_LE_SET_SCAN_ENABLE 0x200c -struct hci_cp_le_set_scan_enable { - __u8 enable; - __u8 filter_dup; -} __packed; - #define HCI_OP_LE_CREATE_CONN 0x200d struct hci_cp_le_create_conn { __le16 scan_interval; @@ -745,33 +739,6 @@ struct hci_cp_le_conn_update { __le16 max_ce_len; } __packed; -#define HCI_OP_LE_START_ENC 0x2019 -struct hci_cp_le_start_enc { - __le16 handle; - __u8 rand[8]; - __le16 ediv; - __u8 ltk[16]; -} __packed; - -#define HCI_OP_LE_LTK_REPLY 0x201a -struct hci_cp_le_ltk_reply { - __le16 handle; - __u8 ltk[16]; -} __packed; -struct hci_rp_le_ltk_reply { - __u8 status; - __le16 handle; -} __packed; - -#define HCI_OP_LE_LTK_NEG_REPLY 0x201b -struct hci_cp_le_ltk_neg_reply { - __le16 handle; -} __packed; -struct hci_rp_le_ltk_neg_reply { - __u8 status; - __le16 handle; -} __packed; - /* ---- HCI Events ---- */ #define HCI_EV_INQUIRY_COMPLETE 0x01 @@ -1062,32 +1029,6 @@ struct hci_ev_le_conn_complete { __u8 clk_accurancy; } __packed; -#define HCI_EV_LE_LTK_REQ 0x05 -struct hci_ev_le_ltk_req { - __le16 handle; - __u8 random[8]; - __le16 ediv; -} __packed; - -/* Advertising report event types */ -#define ADV_IND 0x00 -#define ADV_DIRECT_IND 0x01 -#define ADV_SCAN_IND 0x02 -#define ADV_NONCONN_IND 0x03 -#define ADV_SCAN_RSP 0x04 - -#define ADDR_LE_DEV_PUBLIC 0x00 -#define ADDR_LE_DEV_RANDOM 0x01 - -#define HCI_EV_LE_ADVERTISING_REPORT 0x02 -struct hci_ev_le_advertising_info { - __u8 evt_type; - __u8 bdaddr_type; - bdaddr_t bdaddr; - __u8 length; - __u8 data[0]; -} __packed; - /* Internal events generated by Bluetooth stack */ #define HCI_EV_STACK_INTERNAL 0xfd struct hci_ev_stack_internal { diff --git a/trunk/include/net/bluetooth/hci_core.h b/trunk/include/net/bluetooth/hci_core.h index 19639df80e67..7851c05833e2 100644 --- a/trunk/include/net/bluetooth/hci_core.h +++ b/trunk/include/net/bluetooth/hci_core.h @@ -90,12 +90,6 @@ struct oob_data { u8 randomizer[16]; }; -struct adv_entry { - struct list_head list; - bdaddr_t bdaddr; - u8 bdaddr_type; -}; - #define NUM_REASSEMBLY 4 struct hci_dev { struct list_head list; @@ -178,8 +172,6 @@ struct hci_dev { __u16 init_last_cmd; - struct crypto_blkcipher *tfm; - struct inquiry_cache inq_cache; struct hci_conn_hash conn_hash; struct list_head blacklist; @@ -190,9 +182,6 @@ struct hci_dev { struct list_head remote_oob_data; - struct list_head adv_entries; - struct timer_list adv_timer; - struct hci_dev_stats stat; struct sk_buff_head driver_init; @@ -227,7 +216,6 @@ struct hci_conn { spinlock_t lock; bdaddr_t dst; - __u8 dst_type; __u16 handle; __u16 state; __u8 mode; @@ -250,7 +238,6 @@ struct hci_conn { __u8 power_save; __u16 disc_timeout; unsigned long pend; - __u8 ltk[16]; __u8 remote_cap; __u8 remote_oob; @@ -321,14 +308,12 @@ static inline long inquiry_entry_age(struct inquiry_entry *e) return jiffies - e->timestamp; } -struct inquiry_entry *hci_inquiry_cache_lookup(struct hci_dev *hdev, - bdaddr_t *bdaddr); +struct inquiry_entry *hci_inquiry_cache_lookup(struct hci_dev *hdev, bdaddr_t *bdaddr); void hci_inquiry_cache_update(struct hci_dev *hdev, struct inquiry_data *data); /* ----- HCI Connections ----- */ enum { HCI_CONN_AUTH_PEND, - HCI_CONN_REAUTH_PEND, HCI_CONN_ENCRYPT_PEND, HCI_CONN_RSWITCH_PEND, HCI_CONN_MODE_CHANGE_PEND, @@ -436,15 +421,14 @@ int hci_conn_del(struct hci_conn *conn); void hci_conn_hash_flush(struct hci_dev *hdev); void hci_conn_check_pending(struct hci_dev *hdev); -struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst, - __u8 sec_level, __u8 auth_type); +struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst, __u8 sec_level, __u8 auth_type); int hci_conn_check_link_mode(struct hci_conn *conn); int hci_conn_check_secure(struct hci_conn *conn, __u8 sec_level); int hci_conn_security(struct hci_conn *conn, __u8 sec_level, __u8 auth_type); int hci_conn_change_link_key(struct hci_conn *conn); int hci_conn_switch_role(struct hci_conn *conn, __u8 role); -void hci_conn_enter_active_mode(struct hci_conn *conn, __u8 force_active); +void hci_conn_enter_active_mode(struct hci_conn *conn); void hci_conn_enter_sniff_mode(struct hci_conn *conn); void hci_conn_hold_device(struct hci_conn *conn); @@ -466,12 +450,10 @@ static inline void hci_conn_put(struct hci_conn *conn) timeo = msecs_to_jiffies(conn->disc_timeout); if (!conn->out) timeo *= 2; - } else { + } else timeo = msecs_to_jiffies(10); - } - } else { + } else timeo = msecs_to_jiffies(10); - } mod_timer(&conn->disc_timer, jiffies + timeo); } } @@ -530,8 +512,6 @@ int hci_inquiry(void __user *arg); struct bdaddr_list *hci_blacklist_lookup(struct hci_dev *hdev, bdaddr_t *bdaddr); int hci_blacklist_clear(struct hci_dev *hdev); -int hci_blacklist_add(struct hci_dev *hdev, bdaddr_t *bdaddr); -int hci_blacklist_del(struct hci_dev *hdev, bdaddr_t *bdaddr); int hci_uuids_clear(struct hci_dev *hdev); @@ -548,12 +528,6 @@ int hci_add_remote_oob_data(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 *hash, u8 *randomizer); int hci_remove_remote_oob_data(struct hci_dev *hdev, bdaddr_t *bdaddr); -#define ADV_CLEAR_TIMEOUT (3*60*HZ) /* Three minutes */ -int hci_adv_entries_clear(struct hci_dev *hdev); -struct adv_entry *hci_find_adv_entry(struct hci_dev *hdev, bdaddr_t *bdaddr); -int hci_add_adv_entry(struct hci_dev *hdev, - struct hci_ev_le_advertising_info *ev); - void hci_del_off_timer(struct hci_dev *hdev); void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb); @@ -588,20 +562,16 @@ struct hci_proto { void *priv; - int (*connect_ind) (struct hci_dev *hdev, bdaddr_t *bdaddr, - __u8 type); + int (*connect_ind) (struct hci_dev *hdev, bdaddr_t *bdaddr, __u8 type); int (*connect_cfm) (struct hci_conn *conn, __u8 status); int (*disconn_ind) (struct hci_conn *conn); int (*disconn_cfm) (struct hci_conn *conn, __u8 reason); - int (*recv_acldata) (struct hci_conn *conn, struct sk_buff *skb, - __u16 flags); + int (*recv_acldata) (struct hci_conn *conn, struct sk_buff *skb, __u16 flags); int (*recv_scodata) (struct hci_conn *conn, struct sk_buff *skb); - int (*security_cfm) (struct hci_conn *conn, __u8 status, - __u8 encrypt); + int (*security_cfm) (struct hci_conn *conn, __u8 status, __u8 encrypt); }; -static inline int hci_proto_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr, - __u8 type) +static inline int hci_proto_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr, __u8 type) { register struct hci_proto *hp; int mask = 0; @@ -687,8 +657,7 @@ static inline void hci_proto_auth_cfm(struct hci_conn *conn, __u8 status) conn->security_cfm_cb(conn, status); } -static inline void hci_proto_encrypt_cfm(struct hci_conn *conn, __u8 status, - __u8 encrypt) +static inline void hci_proto_encrypt_cfm(struct hci_conn *conn, __u8 status, __u8 encrypt) { register struct hci_proto *hp; @@ -713,8 +682,7 @@ struct hci_cb { char *name; - void (*security_cfm) (struct hci_conn *conn, __u8 status, - __u8 encrypt); + void (*security_cfm) (struct hci_conn *conn, __u8 status, __u8 encrypt); void (*key_change_cfm) (struct hci_conn *conn, __u8 status); void (*role_switch_cfm) (struct hci_conn *conn, __u8 status, __u8 role); }; @@ -740,17 +708,13 @@ static inline void hci_auth_cfm(struct hci_conn *conn, __u8 status) read_unlock_bh(&hci_cb_list_lock); } -static inline void hci_encrypt_cfm(struct hci_conn *conn, __u8 status, - __u8 encrypt) +static inline void hci_encrypt_cfm(struct hci_conn *conn, __u8 status, __u8 encrypt) { struct list_head *p; if (conn->sec_level == BT_SECURITY_SDP) conn->sec_level = BT_SECURITY_LOW; - if (conn->pending_sec_level > conn->sec_level) - conn->sec_level = conn->pending_sec_level; - hci_proto_encrypt_cfm(conn, status, encrypt); read_lock_bh(&hci_cb_list_lock); @@ -775,8 +739,7 @@ static inline void hci_key_change_cfm(struct hci_conn *conn, __u8 status) read_unlock_bh(&hci_cb_list_lock); } -static inline void hci_role_switch_cfm(struct hci_conn *conn, __u8 status, - __u8 role) +static inline void hci_role_switch_cfm(struct hci_conn *conn, __u8 status, __u8 role) { struct list_head *p; @@ -868,9 +831,4 @@ void hci_req_complete(struct hci_dev *hdev, __u16 cmd, int result); void hci_le_conn_update(struct hci_conn *conn, u16 min, u16 max, u16 latency, u16 to_multiplier); -void hci_le_start_enc(struct hci_conn *conn, __le16 ediv, __u8 rand[8], - __u8 ltk[16]); -void hci_le_ltk_reply(struct hci_conn *conn, u8 ltk[16]); -void hci_le_ltk_neg_reply(struct hci_conn *conn); - #endif /* __HCI_CORE_H */ diff --git a/trunk/include/net/bluetooth/l2cap.h b/trunk/include/net/bluetooth/l2cap.h index 9c18e555b6ed..d09c9b1118e3 100644 --- a/trunk/include/net/bluetooth/l2cap.h +++ b/trunk/include/net/bluetooth/l2cap.h @@ -287,10 +287,6 @@ struct l2cap_chan { struct l2cap_conn *conn; - __u8 state; - - atomic_t refcnt; - __le16 psm; __u16 dcid; __u16 scid; @@ -299,7 +295,6 @@ struct l2cap_chan { __u16 omtu; __u16 flush_to; __u8 mode; - __u8 chan_type; __le16 sport; @@ -307,7 +302,6 @@ struct l2cap_chan { __u8 role_switch; __u8 force_reliable; __u8 flushable; - __u8 force_active; __u8 ident; @@ -324,8 +318,8 @@ struct l2cap_chan { __u16 monitor_timeout; __u16 mps; - unsigned long conf_state; - unsigned long conn_state; + __u8 conf_state; + __u16 conn_state; __u8 next_tx_seq; __u8 expected_ack_seq; @@ -345,7 +339,6 @@ struct l2cap_chan { __u8 remote_max_tx; __u16 remote_mps; - struct timer_list chan_timer; struct timer_list retrans_timer; struct timer_list monitor_timer; struct timer_list ack_timer; @@ -358,18 +351,6 @@ struct l2cap_chan { struct list_head list; struct list_head global_l; - - void *data; - struct l2cap_ops *ops; -}; - -struct l2cap_ops { - char *name; - - struct l2cap_chan *(*new_connection) (void *data); - int (*recv) (void *data, struct sk_buff *skb); - void (*close) (void *data); - void (*state_change) (void *data, int state); }; struct l2cap_conn { @@ -395,15 +376,6 @@ struct l2cap_conn { __u8 disc_reason; - __u8 preq[7]; /* SMP Pairing Request */ - __u8 prsp[7]; /* SMP Pairing Response */ - __u8 prnd[16]; /* SMP Pairing Random */ - __u8 pcnf[16]; /* SMP Pairing Confirm */ - __u8 tk[16]; /* SMP Temporary Key */ - __u8 smp_key_size; - - struct timer_list security_timer; - struct list_head chan_l; rwlock_t chan_lock; }; @@ -412,10 +384,6 @@ struct l2cap_conn { #define L2CAP_INFO_FEAT_MASK_REQ_SENT 0x04 #define L2CAP_INFO_FEAT_MASK_REQ_DONE 0x08 -#define L2CAP_CHAN_RAW 1 -#define L2CAP_CHAN_CONN_LESS 2 -#define L2CAP_CHAN_CONN_ORIENTED 3 - /* ----- L2CAP socket info ----- */ #define l2cap_pi(sk) ((struct l2cap_pinfo *) sk) @@ -424,45 +392,36 @@ struct l2cap_pinfo { struct l2cap_chan *chan; }; -enum { - CONF_REQ_SENT, - CONF_INPUT_DONE, - CONF_OUTPUT_DONE, - CONF_MTU_DONE, - CONF_MODE_DONE, - CONF_CONNECT_PEND, - CONF_NO_FCS_RECV, - CONF_STATE2_DEVICE, -}; +#define L2CAP_CONF_REQ_SENT 0x01 +#define L2CAP_CONF_INPUT_DONE 0x02 +#define L2CAP_CONF_OUTPUT_DONE 0x04 +#define L2CAP_CONF_MTU_DONE 0x08 +#define L2CAP_CONF_MODE_DONE 0x10 +#define L2CAP_CONF_CONNECT_PEND 0x20 +#define L2CAP_CONF_NO_FCS_RECV 0x40 +#define L2CAP_CONF_STATE2_DEVICE 0x80 #define L2CAP_CONF_MAX_CONF_REQ 2 #define L2CAP_CONF_MAX_CONF_RSP 2 -enum { - CONN_SAR_SDU, - CONN_SREJ_SENT, - CONN_WAIT_F, - CONN_SREJ_ACT, - CONN_SEND_PBIT, - CONN_REMOTE_BUSY, - CONN_LOCAL_BUSY, - CONN_REJ_ACT, - CONN_SEND_FBIT, - CONN_RNR_SENT, - CONN_SAR_RETRY, -}; - -#define __set_chan_timer(c, t) l2cap_set_timer(c, &c->chan_timer, (t)) -#define __clear_chan_timer(c) l2cap_clear_timer(c, &c->chan_timer) -#define __set_retrans_timer(c) l2cap_set_timer(c, &c->retrans_timer, \ - L2CAP_DEFAULT_RETRANS_TO); -#define __clear_retrans_timer(c) l2cap_clear_timer(c, &c->retrans_timer) -#define __set_monitor_timer(c) l2cap_set_timer(c, &c->monitor_timer, \ - L2CAP_DEFAULT_MONITOR_TO); -#define __clear_monitor_timer(c) l2cap_clear_timer(c, &c->monitor_timer) -#define __set_ack_timer(c) l2cap_set_timer(c, &chan->ack_timer, \ - L2CAP_DEFAULT_ACK_TO); -#define __clear_ack_timer(c) l2cap_clear_timer(c, &c->ack_timer) +#define L2CAP_CONN_SAR_SDU 0x0001 +#define L2CAP_CONN_SREJ_SENT 0x0002 +#define L2CAP_CONN_WAIT_F 0x0004 +#define L2CAP_CONN_SREJ_ACT 0x0008 +#define L2CAP_CONN_SEND_PBIT 0x0010 +#define L2CAP_CONN_REMOTE_BUSY 0x0020 +#define L2CAP_CONN_LOCAL_BUSY 0x0040 +#define L2CAP_CONN_REJ_ACT 0x0080 +#define L2CAP_CONN_SEND_FBIT 0x0100 +#define L2CAP_CONN_RNR_SENT 0x0200 +#define L2CAP_CONN_SAR_RETRY 0x0400 + +#define __mod_retrans_timer() mod_timer(&chan->retrans_timer, \ + jiffies + msecs_to_jiffies(L2CAP_DEFAULT_RETRANS_TO)); +#define __mod_monitor_timer() mod_timer(&chan->monitor_timer, \ + jiffies + msecs_to_jiffies(L2CAP_DEFAULT_MONITOR_TO)); +#define __mod_ack_timer() mod_timer(&chan->ack_timer, \ + jiffies + msecs_to_jiffies(L2CAP_DEFAULT_ACK_TO)); static inline int l2cap_tx_window_full(struct l2cap_chan *ch) { @@ -487,16 +446,32 @@ extern int disable_ertm; int l2cap_init_sockets(void); void l2cap_cleanup_sockets(void); +void l2cap_send_cmd(struct l2cap_conn *conn, u8 ident, u8 code, u16 len, void *data); void __l2cap_connect_rsp_defer(struct l2cap_chan *chan); int __l2cap_wait_ack(struct sock *sk); +struct sk_buff *l2cap_create_connless_pdu(struct l2cap_chan *chan, struct msghdr *msg, size_t len); +struct sk_buff *l2cap_create_basic_pdu(struct l2cap_chan *chan, struct msghdr *msg, size_t len); +struct sk_buff *l2cap_create_iframe_pdu(struct l2cap_chan *chan, struct msghdr *msg, size_t len, u16 control, u16 sdulen); +int l2cap_sar_segment_sdu(struct l2cap_chan *chan, struct msghdr *msg, size_t len); +void l2cap_do_send(struct l2cap_chan *chan, struct sk_buff *skb); +void l2cap_streaming_send(struct l2cap_chan *chan); +int l2cap_ertm_send(struct l2cap_chan *chan); + int l2cap_add_psm(struct l2cap_chan *chan, bdaddr_t *src, __le16 psm); int l2cap_add_scid(struct l2cap_chan *chan, __u16 scid); +void l2cap_sock_set_timer(struct sock *sk, long timeout); +void l2cap_sock_clear_timer(struct sock *sk); +void __l2cap_sock_close(struct sock *sk, int reason); +void l2cap_sock_kill(struct sock *sk); +void l2cap_sock_init(struct sock *sk, struct sock *parent); +struct sock *l2cap_sock_alloc(struct net *net, struct socket *sock, + int proto, gfp_t prio); +void l2cap_send_disconn_req(struct l2cap_conn *conn, struct l2cap_chan *chan, int err); struct l2cap_chan *l2cap_chan_create(struct sock *sk); -void l2cap_chan_close(struct l2cap_chan *chan, int reason); +void l2cap_chan_del(struct l2cap_chan *chan, int err); void l2cap_chan_destroy(struct l2cap_chan *chan); int l2cap_chan_connect(struct l2cap_chan *chan); -int l2cap_chan_send(struct l2cap_chan *chan, struct msghdr *msg, size_t len); #endif /* __L2CAP_H */ diff --git a/trunk/include/net/bluetooth/mgmt.h b/trunk/include/net/bluetooth/mgmt.h index 45bea25d737f..4899286ed4e4 100644 --- a/trunk/include/net/bluetooth/mgmt.h +++ b/trunk/include/net/bluetooth/mgmt.h @@ -199,16 +199,6 @@ struct mgmt_cp_remove_remote_oob_data { #define MGMT_OP_STOP_DISCOVERY 0x001C -#define MGMT_OP_BLOCK_DEVICE 0x001D -struct mgmt_cp_block_device { - bdaddr_t bdaddr; -} __packed; - -#define MGMT_OP_UNBLOCK_DEVICE 0x001E -struct mgmt_cp_unblock_device { - bdaddr_t bdaddr; -} __packed; - #define MGMT_EV_CMD_COMPLETE 0x0001 struct mgmt_ev_cmd_complete { __le16 opcode; diff --git a/trunk/include/net/bluetooth/rfcomm.h b/trunk/include/net/bluetooth/rfcomm.h index d5eee2093b1e..6eac4a760c3b 100644 --- a/trunk/include/net/bluetooth/rfcomm.h +++ b/trunk/include/net/bluetooth/rfcomm.h @@ -234,8 +234,7 @@ int rfcomm_send_rpn(struct rfcomm_session *s, int cr, u8 dlci, /* ---- RFCOMM DLCs (channels) ---- */ struct rfcomm_dlc *rfcomm_dlc_alloc(gfp_t prio); void rfcomm_dlc_free(struct rfcomm_dlc *d); -int rfcomm_dlc_open(struct rfcomm_dlc *d, bdaddr_t *src, bdaddr_t *dst, - u8 channel); +int rfcomm_dlc_open(struct rfcomm_dlc *d, bdaddr_t *src, bdaddr_t *dst, u8 channel); int rfcomm_dlc_close(struct rfcomm_dlc *d, int reason); int rfcomm_dlc_send(struct rfcomm_dlc *d, struct sk_buff *skb); int rfcomm_dlc_set_modem_status(struct rfcomm_dlc *d, u8 v24_sig); @@ -272,8 +271,7 @@ static inline void rfcomm_dlc_unthrottle(struct rfcomm_dlc *d) } /* ---- RFCOMM sessions ---- */ -void rfcomm_session_getaddr(struct rfcomm_session *s, bdaddr_t *src, - bdaddr_t *dst); +void rfcomm_session_getaddr(struct rfcomm_session *s, bdaddr_t *src, bdaddr_t *dst); static inline void rfcomm_session_hold(struct rfcomm_session *s) { @@ -314,8 +312,7 @@ struct rfcomm_pinfo { int rfcomm_init_sockets(void); void rfcomm_cleanup_sockets(void); -int rfcomm_connect_ind(struct rfcomm_session *s, u8 channel, - struct rfcomm_dlc **d); +int rfcomm_connect_ind(struct rfcomm_session *s, u8 channel, struct rfcomm_dlc **d); /* ---- RFCOMM TTY ---- */ #define RFCOMM_MAX_DEV 256 diff --git a/trunk/include/net/bluetooth/smp.h b/trunk/include/net/bluetooth/smp.h index 4fb7d198a876..8f2edbf979dc 100644 --- a/trunk/include/net/bluetooth/smp.h +++ b/trunk/include/net/bluetooth/smp.h @@ -1,25 +1,3 @@ -/* - BlueZ - Bluetooth protocol stack for Linux - Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). - - 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; - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. - IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY - CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - - ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, - COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS - SOFTWARE IS DISCLAIMED. -*/ - #ifndef __SMP_H #define __SMP_H @@ -38,23 +16,6 @@ struct smp_cmd_pairing { __u8 resp_key_dist; } __packed; -#define SMP_IO_DISPLAY_ONLY 0x00 -#define SMP_IO_DISPLAY_YESNO 0x01 -#define SMP_IO_KEYBOARD_ONLY 0x02 -#define SMP_IO_NO_INPUT_OUTPUT 0x03 -#define SMP_IO_KEYBOARD_DISPLAY 0x04 - -#define SMP_OOB_NOT_PRESENT 0x00 -#define SMP_OOB_PRESENT 0x01 - -#define SMP_DIST_ENC_KEY 0x01 -#define SMP_DIST_ID_KEY 0x02 -#define SMP_DIST_SIGN 0x04 - -#define SMP_AUTH_NONE 0x00 -#define SMP_AUTH_BONDING 0x01 -#define SMP_AUTH_MITM 0x04 - #define SMP_CMD_PAIRING_CONFIRM 0x03 struct smp_cmd_pairing_confirm { __u8 confirm_val[16]; @@ -112,11 +73,4 @@ struct smp_cmd_security_req { #define SMP_UNSPECIFIED 0x08 #define SMP_REPEATED_ATTEMPTS 0x09 -#define SMP_MIN_ENC_KEY_SIZE 7 -#define SMP_MAX_ENC_KEY_SIZE 16 - -/* SMP Commands */ -int smp_conn_security(struct l2cap_conn *conn, __u8 sec_level); -int smp_sig_channel(struct l2cap_conn *conn, struct sk_buff *skb); - #endif /* __SMP_H */ diff --git a/trunk/include/net/cfg80211.h b/trunk/include/net/cfg80211.h index 4bf101bada4e..6cb2543a2ee1 100644 --- a/trunk/include/net/cfg80211.h +++ b/trunk/include/net/cfg80211.h @@ -1153,18 +1153,6 @@ struct cfg80211_wowlan { int n_patterns; }; -/** - * struct cfg80211_gtk_rekey_data - rekey data - * @kek: key encryption key - * @kck: key confirmation key - * @replay_ctr: replay counter - */ -struct cfg80211_gtk_rekey_data { - u8 kek[NL80211_KEK_LEN]; - u8 kck[NL80211_KCK_LEN]; - u8 replay_ctr[NL80211_REPLAY_CTR_LEN]; -}; - /** * struct cfg80211_ops - backend description for wireless configuration * @@ -1209,8 +1197,6 @@ struct cfg80211_gtk_rekey_data { * * @set_default_mgmt_key: set the default management frame key on an interface * - * @set_rekey_data: give the data necessary for GTK rekeying to the driver - * * @add_beacon: Add a beacon with given parameters, @head, @interval * and @dtim_period will be valid, @tail is optional. * @set_beacon: Change the beacon parameters for an access point mode @@ -1513,9 +1499,6 @@ struct cfg80211_ops { struct net_device *dev, struct cfg80211_sched_scan_request *request); int (*sched_scan_stop)(struct wiphy *wiphy, struct net_device *dev); - - int (*set_rekey_data)(struct wiphy *wiphy, struct net_device *dev, - struct cfg80211_gtk_rekey_data *data); }; /* @@ -2714,7 +2697,7 @@ void cfg80211_send_unprot_disassoc(struct net_device *dev, const u8 *buf, * @dev: network device * @addr: The source MAC address of the frame * @key_type: The key type that the received frame used - * @key_id: Key identifier (0..3). Can be -1 if missing. + * @key_id: Key identifier (0..3) * @tsc: The TSC value of the frame that generated the MIC failure (6 octets) * @gfp: allocation flags * @@ -3050,15 +3033,6 @@ void cfg80211_cqm_rssi_notify(struct net_device *dev, void cfg80211_cqm_pktloss_notify(struct net_device *dev, const u8 *peer, u32 num_packets, gfp_t gfp); -/** - * cfg80211_gtk_rekey_notify - notify userspace about driver rekeying - * @dev: network device - * @bssid: BSSID of AP (to avoid races) - * @replay_ctr: new replay counter - */ -void cfg80211_gtk_rekey_notify(struct net_device *dev, const u8 *bssid, - const u8 *replay_ctr, gfp_t gfp); - /* Logging, debugging and troubleshooting/diagnostic helpers. */ /* wiphy_printk helpers, similar to dev_printk */ diff --git a/trunk/include/net/dcbnl.h b/trunk/include/net/dcbnl.h index f5aa39997f0b..d5bbb7977577 100644 --- a/trunk/include/net/dcbnl.h +++ b/trunk/include/net/dcbnl.h @@ -34,10 +34,7 @@ int dcb_ieee_setapp(struct net_device *, struct dcb_app *); int dcb_ieee_delapp(struct net_device *, struct dcb_app *); u8 dcb_ieee_getapp_mask(struct net_device *, struct dcb_app *); -int dcbnl_ieee_notify(struct net_device *dev, int event, int cmd, - u32 seq, u32 pid); -int dcbnl_cee_notify(struct net_device *dev, int event, int cmd, - u32 seq, u32 pid); +int dcbnl_notify(struct net_device *dev, int event, int cmd, u32 seq, u32 pid); /* * Ops struct for the netlink callbacks. Used by DCB-enabled drivers through diff --git a/trunk/include/net/dst.h b/trunk/include/net/dst.h index 0dd7ccbc0dd5..7d15d238b6ec 100644 --- a/trunk/include/net/dst.h +++ b/trunk/include/net/dst.h @@ -38,6 +38,7 @@ struct dst_entry { unsigned long expires; struct dst_entry *path; struct neighbour *neighbour; + struct hh_cache *hh; #ifdef CONFIG_XFRM struct xfrm_state *xfrm; #else @@ -46,14 +47,6 @@ struct dst_entry { int (*input)(struct sk_buff*); int (*output)(struct sk_buff*); - int flags; -#define DST_HOST 0x0001 -#define DST_NOXFRM 0x0002 -#define DST_NOPOLICY 0x0004 -#define DST_NOHASH 0x0008 -#define DST_NOCACHE 0x0010 -#define DST_NOCOUNT 0x0020 - short error; short obsolete; unsigned short header_len; /* more space at head required */ @@ -69,7 +62,7 @@ struct dst_entry { * (L1_CACHE_SIZE would be too much) */ #ifdef CONFIG_64BIT - long __pad_to_align_refcnt[2]; + long __pad_to_align_refcnt[1]; #endif /* * __refcnt wants to be on a different cache line from @@ -78,6 +71,12 @@ struct dst_entry { atomic_t __refcnt; /* client references */ int __use; unsigned long lastuse; + int flags; +#define DST_HOST 0x0001 +#define DST_NOXFRM 0x0002 +#define DST_NOPOLICY 0x0004 +#define DST_NOHASH 0x0008 +#define DST_NOCACHE 0x0010 union { struct dst_entry *next; struct rtable __rcu *rt_next; diff --git a/trunk/include/net/genetlink.h b/trunk/include/net/genetlink.h index 82d8d09faa44..d420f28b6d60 100644 --- a/trunk/include/net/genetlink.h +++ b/trunk/include/net/genetlink.h @@ -159,38 +159,6 @@ static inline void *genlmsg_put(struct sk_buff *skb, u32 pid, u32 seq, return (char *) hdr + GENL_HDRLEN; } -/** - * genlmsg_nlhdr - Obtain netlink header from user specified header - * @user_hdr: user header as returned from genlmsg_put() - * @family: generic netlink family - * - * Returns pointer to netlink header. - */ -static inline struct nlmsghdr *genlmsg_nlhdr(void *user_hdr, - struct genl_family *family) -{ - return (struct nlmsghdr *)((char *)user_hdr - - family->hdrsize - - GENL_HDRLEN - - NLMSG_HDRLEN); -} - -/** - * genl_dump_check_consistent - check if sequence is consistent and advertise if not - * @cb: netlink callback structure that stores the sequence number - * @user_hdr: user header as returned from genlmsg_put() - * @family: generic netlink family - * - * Cf. nl_dump_check_consistent(), this just provides a wrapper to make it - * simpler to use with generic netlink. - */ -static inline void genl_dump_check_consistent(struct netlink_callback *cb, - void *user_hdr, - struct genl_family *family) -{ - nl_dump_check_consistent(cb, genlmsg_nlhdr(user_hdr, family)); -} - /** * genlmsg_put_reply - Add generic netlink header to a reply message * @skb: socket buffer holding the message diff --git a/trunk/include/net/ip.h b/trunk/include/net/ip.h index aa76c7a4d9c3..9fa9416d14d7 100644 --- a/trunk/include/net/ip.h +++ b/trunk/include/net/ip.h @@ -404,8 +404,7 @@ enum ip_defrag_users { __IP_DEFRAG_CONNTRACK_BRIDGE_IN = IP_DEFRAG_CONNTRACK_BRIDGE_IN + USHRT_MAX, IP_DEFRAG_VS_IN, IP_DEFRAG_VS_OUT, - IP_DEFRAG_VS_FWD, - IP_DEFRAG_AF_PACKET, + IP_DEFRAG_VS_FWD }; int ip_defrag(struct sk_buff *skb, u32 user); diff --git a/trunk/include/net/mac80211.h b/trunk/include/net/mac80211.h index 2474019f47d3..3b31ec95dd8e 100644 --- a/trunk/include/net/mac80211.h +++ b/trunk/include/net/mac80211.h @@ -933,7 +933,6 @@ enum set_key_cmd { * @aid: AID we assigned to the station if we're an AP * @supp_rates: Bitmap of supported rates (per band) * @ht_cap: HT capabilities of this STA; restricted to our own TX capabilities - * @wme: indicates whether the STA supports WME. Only valid during AP-mode. * @drv_priv: data area for driver use, will always be aligned to * sizeof(void *), size is determined in hw information. */ @@ -942,7 +941,6 @@ struct ieee80211_sta { u8 addr[ETH_ALEN]; u16 aid; struct ieee80211_sta_ht_cap ht_cap; - bool wme; /* must be last */ u8 drv_priv[0] __attribute__((__aligned__(sizeof(void *)))); @@ -1628,10 +1626,6 @@ enum ieee80211_ampdu_mlme_action { * ask the device to suspend. This is only invoked when WoWLAN is * configured, otherwise the device is deconfigured completely and * reconfigured at resume time. - * The driver may also impose special conditions under which it - * wants to use the "normal" suspend (deconfigure), say if it only - * supports WoWLAN when the device is associated. In this case, it - * must return 1 from this function. * * @resume: If WoWLAN was configured, this indicates that mac80211 is * now resuming its operation, after this the device must be fully @@ -1700,12 +1694,6 @@ enum ieee80211_ampdu_mlme_action { * which set IEEE80211_KEY_FLAG_TKIP_REQ_RX_P1_KEY. * The callback must be atomic. * - * @set_rekey_data: If the device supports GTK rekeying, for example while the - * host is suspended, it can assign this callback to retrieve the data - * necessary to do GTK rekeying, this is the KEK, KCK and replay counter. - * After rekeying was done it should (for example during resume) notify - * userspace of the new replay counter using ieee80211_gtk_rekey_notify(). - * * @hw_scan: Ask the hardware to service the scan request, no need to start * the scan state machine in stack. The scan must honour the channel * configuration done by the regulatory agent in the wiphy's @@ -1720,14 +1708,6 @@ enum ieee80211_ampdu_mlme_action { * any error unless this callback returned a negative error code. * The callback can sleep. * - * @cancel_hw_scan: Ask the low-level tp cancel the active hw scan. - * The driver should ask the hardware to cancel the scan (if possible), - * but the scan will be completed only after the driver will call - * ieee80211_scan_completed(). - * This callback is needed for wowlan, to prevent enqueueing a new - * scan_work after the low-level driver was already suspended. - * The callback can sleep. - * * @sched_scan_start: Ask the hardware to start scanning repeatedly at * specific intervals. The driver must call the * ieee80211_sched_scan_results() function whenever it finds results. @@ -1918,13 +1898,8 @@ struct ieee80211_ops { struct ieee80211_key_conf *conf, struct ieee80211_sta *sta, u32 iv32, u16 *phase1key); - void (*set_rekey_data)(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - struct cfg80211_gtk_rekey_data *data); int (*hw_scan)(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct cfg80211_scan_request *req); - void (*cancel_hw_scan)(struct ieee80211_hw *hw, - struct ieee80211_vif *vif); int (*sched_scan_start)(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct cfg80211_sched_scan_request *req, @@ -2594,17 +2569,6 @@ ieee80211_get_buffered_bc(struct ieee80211_hw *hw, struct ieee80211_vif *vif); void ieee80211_get_tkip_key(struct ieee80211_key_conf *keyconf, struct sk_buff *skb, enum ieee80211_tkip_key_type type, u8 *key); - -/** - * ieee80211_gtk_rekey_notify - notify userspace supplicant of rekeying - * @vif: virtual interface the rekeying was done on - * @bssid: The BSSID of the AP, for checking association - * @replay_ctr: the new replay counter after GTK rekeying - * @gfp: allocation flags - */ -void ieee80211_gtk_rekey_notify(struct ieee80211_vif *vif, const u8 *bssid, - const u8 *replay_ctr, gfp_t gfp); - /** * ieee80211_wake_queue - wake specific queue * @hw: pointer as obtained from ieee80211_alloc_hw(). @@ -2869,29 +2833,6 @@ struct ieee80211_sta *ieee80211_find_sta_by_ifaddr(struct ieee80211_hw *hw, void ieee80211_sta_block_awake(struct ieee80211_hw *hw, struct ieee80211_sta *pubsta, bool block); -/** - * ieee80211_iter_keys - iterate keys programmed into the device - * @hw: pointer obtained from ieee80211_alloc_hw() - * @vif: virtual interface to iterate, may be %NULL for all - * @iter: iterator function that will be called for each key - * @iter_data: custom data to pass to the iterator function - * - * This function can be used to iterate all the keys known to - * mac80211, even those that weren't previously programmed into - * the device. This is intended for use in WoWLAN if the device - * needs reprogramming of the keys during suspend. Note that due - * to locking reasons, it is also only safe to call this at few - * spots since it must hold the RTNL and be able to sleep. - */ -void ieee80211_iter_keys(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - void (*iter)(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - struct ieee80211_sta *sta, - struct ieee80211_key_conf *key, - void *data), - void *iter_data); - /** * ieee80211_ap_probereq_get - retrieve a Probe Request template * @hw: pointer obtained from ieee80211_alloc_hw(). @@ -2978,16 +2919,6 @@ void ieee80211_cqm_rssi_notify(struct ieee80211_vif *vif, enum nl80211_cqm_rssi_threshold_event rssi_event, gfp_t gfp); -/** - * ieee80211_get_operstate - get the operstate of the vif - * - * @vif: &struct ieee80211_vif pointer from the add_interface callback. - * - * The driver might need to know the operstate of the net_device - * (specifically, whether the link is IF_OPER_UP after resume) - */ -unsigned char ieee80211_get_operstate(struct ieee80211_vif *vif); - /** * ieee80211_chswitch_done - Complete channel switch process * @vif: &struct ieee80211_vif pointer from the add_interface callback. diff --git a/trunk/include/net/neighbour.h b/trunk/include/net/neighbour.h index bd8f9f09ab5c..4014b623880c 100644 --- a/trunk/include/net/neighbour.h +++ b/trunk/include/net/neighbour.h @@ -108,7 +108,7 @@ struct neighbour { __u8 dead; seqlock_t ha_lock; unsigned char ha[ALIGN(MAX_ADDR_LEN, sizeof(unsigned long))]; - struct hh_cache hh; + struct hh_cache *hh; int (*output)(struct sk_buff *skb); const struct neigh_ops *ops; struct rcu_head rcu; @@ -142,7 +142,7 @@ struct pneigh_entry { struct neigh_hash_table { struct neighbour __rcu **hash_buckets; - unsigned int hash_shift; + unsigned int hash_mask; __u32 hash_rnd; struct rcu_head rcu; }; diff --git a/trunk/include/net/net_namespace.h b/trunk/include/net/net_namespace.h index 1ab1aec209ac..aef430d779bd 100644 --- a/trunk/include/net/net_namespace.h +++ b/trunk/include/net/net_namespace.h @@ -65,7 +65,6 @@ struct net { struct list_head dev_base_head; struct hlist_head *dev_name_head; struct hlist_head *dev_index_head; - unsigned int dev_base_seq; /* protected by rtnl_mutex */ /* core fib_rules */ struct list_head rules_ops; diff --git a/trunk/include/net/netlink.h b/trunk/include/net/netlink.h index 98c185441bee..02740a94f108 100644 --- a/trunk/include/net/netlink.h +++ b/trunk/include/net/netlink.h @@ -638,30 +638,6 @@ static inline int nlmsg_unicast(struct sock *sk, struct sk_buff *skb, u32 pid) nlmsg_ok(pos, rem); \ pos = nlmsg_next(pos, &(rem))) -/** - * nl_dump_check_consistent - check if sequence is consistent and advertise if not - * @cb: netlink callback structure that stores the sequence number - * @nlh: netlink message header to write the flag to - * - * This function checks if the sequence (generation) number changed during dump - * and if it did, advertises it in the netlink message header. - * - * The correct way to use it is to set cb->seq to the generation counter when - * all locks for dumping have been acquired, and then call this function for - * each message that is generated. - * - * Note that due to initialisation concerns, 0 is an invalid sequence number - * and must not be used by code that uses this functionality. - */ -static inline void -nl_dump_check_consistent(struct netlink_callback *cb, - struct nlmsghdr *nlh) -{ - if (cb->prev_seq && cb->seq != cb->prev_seq) - nlh->nlmsg_flags |= NLM_F_DUMP_INTR; - cb->prev_seq = cb->seq; -} - /************************************************************************** * Netlink Attributes **************************************************************************/ diff --git a/trunk/include/net/nfc.h b/trunk/include/net/nfc.h deleted file mode 100644 index cc0130312f70..000000000000 --- a/trunk/include/net/nfc.h +++ /dev/null @@ -1,156 +0,0 @@ -/* - * Copyright (C) 2011 Instituto Nokia de Tecnologia - * - * Authors: - * Lauro Ramos Venancio - * Aloisio Almeida Jr - * - * 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. - * - * 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., - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef __NET_NFC_H -#define __NET_NFC_H - -#include -#include - -#define nfc_dev_info(dev, fmt, arg...) dev_info((dev), "NFC: " fmt "\n", ## arg) -#define nfc_dev_err(dev, fmt, arg...) dev_err((dev), "NFC: " fmt "\n", ## arg) -#define nfc_dev_dbg(dev, fmt, arg...) dev_dbg((dev), fmt "\n", ## arg) - -struct nfc_dev; - -/** - * data_exchange_cb_t - Definition of nfc_data_exchange callback - * - * @context: nfc_data_exchange cb_context parameter - * @skb: response data - * @err: If an error has occurred during data exchange, it is the - * error number. Zero means no error. - * - * When a rx or tx package is lost or corrupted or the target gets out - * of the operating field, err is -EIO. - */ -typedef void (*data_exchange_cb_t)(void *context, struct sk_buff *skb, - int err); - -struct nfc_ops { - int (*start_poll)(struct nfc_dev *dev, u32 protocols); - void (*stop_poll)(struct nfc_dev *dev); - int (*activate_target)(struct nfc_dev *dev, u32 target_idx, - u32 protocol); - void (*deactivate_target)(struct nfc_dev *dev, u32 target_idx); - int (*data_exchange)(struct nfc_dev *dev, u32 target_idx, - struct sk_buff *skb, data_exchange_cb_t cb, - void *cb_context); -}; - -struct nfc_target { - u32 idx; - u32 supported_protocols; - u16 sens_res; - u8 sel_res; -}; - -struct nfc_genl_data { - u32 poll_req_pid; - struct mutex genl_data_mutex; -}; - -struct nfc_dev { - unsigned idx; - unsigned target_idx; - struct nfc_target *targets; - int n_targets; - int targets_generation; - spinlock_t targets_lock; - struct device dev; - bool polling; - struct nfc_genl_data genl_data; - u32 supported_protocols; - - struct nfc_ops *ops; -}; -#define to_nfc_dev(_dev) container_of(_dev, struct nfc_dev, dev) - -extern struct class nfc_class; - -struct nfc_dev *nfc_allocate_device(struct nfc_ops *ops, - u32 supported_protocols); - -/** - * nfc_free_device - free nfc device - * - * @dev: The nfc device to free - */ -static inline void nfc_free_device(struct nfc_dev *dev) -{ - put_device(&dev->dev); -} - -int nfc_register_device(struct nfc_dev *dev); - -void nfc_unregister_device(struct nfc_dev *dev); - -/** - * nfc_set_parent_dev - set the parent device - * - * @nfc_dev: The nfc device whose parent is being set - * @dev: The parent device - */ -static inline void nfc_set_parent_dev(struct nfc_dev *nfc_dev, - struct device *dev) -{ - nfc_dev->dev.parent = dev; -} - -/** - * nfc_set_drvdata - set driver specifc data - * - * @dev: The nfc device - * @data: Pointer to driver specifc data - */ -static inline void nfc_set_drvdata(struct nfc_dev *dev, void *data) -{ - dev_set_drvdata(&dev->dev, data); -} - -/** - * nfc_get_drvdata - get driver specifc data - * - * @dev: The nfc device - */ -static inline void *nfc_get_drvdata(struct nfc_dev *dev) -{ - return dev_get_drvdata(&dev->dev); -} - -/** - * nfc_device_name - get the nfc device name - * - * @dev: The nfc device whose name to return - */ -static inline const char *nfc_device_name(struct nfc_dev *dev) -{ - return dev_name(&dev->dev); -} - -struct sk_buff *nfc_alloc_skb(unsigned int size, gfp_t gfp); - -int nfc_targets_found(struct nfc_dev *dev, struct nfc_target *targets, - int ntargets); - -#endif /* __NET_NFC_H */ diff --git a/trunk/include/net/pkt_sched.h b/trunk/include/net/pkt_sched.h index fffdc603f4c8..65afc4966204 100644 --- a/trunk/include/net/pkt_sched.h +++ b/trunk/include/net/pkt_sched.h @@ -99,9 +99,9 @@ static inline void qdisc_run(struct Qdisc *q) __qdisc_run(q); } -extern int tc_classify_compat(struct sk_buff *skb, const struct tcf_proto *tp, +extern int tc_classify_compat(struct sk_buff *skb, struct tcf_proto *tp, struct tcf_result *res); -extern int tc_classify(struct sk_buff *skb, const struct tcf_proto *tp, +extern int tc_classify(struct sk_buff *skb, struct tcf_proto *tp, struct tcf_result *res); /* Calculate maximal size of packet seen by hard_start_xmit diff --git a/trunk/include/net/sch_generic.h b/trunk/include/net/sch_generic.h index 4fc88f3ccd5f..b931f021d7ab 100644 --- a/trunk/include/net/sch_generic.h +++ b/trunk/include/net/sch_generic.h @@ -181,9 +181,8 @@ struct tcf_proto_ops { struct tcf_proto_ops *next; char kind[IFNAMSIZ]; - int (*classify)(struct sk_buff *, - const struct tcf_proto *, - struct tcf_result *); + int (*classify)(struct sk_buff*, struct tcf_proto*, + struct tcf_result *); int (*init)(struct tcf_proto*); void (*destroy)(struct tcf_proto*); @@ -206,9 +205,8 @@ struct tcf_proto { /* Fast access part */ struct tcf_proto *next; void *root; - int (*classify)(struct sk_buff *, - const struct tcf_proto *, - struct tcf_result *); + int (*classify)(struct sk_buff*, struct tcf_proto*, + struct tcf_result *); __be16 protocol; /* All the rest */ @@ -216,7 +214,7 @@ struct tcf_proto { u32 classid; struct Qdisc *q; void *data; - const struct tcf_proto_ops *ops; + struct tcf_proto_ops *ops; }; struct qdisc_skb_cb { diff --git a/trunk/include/net/sctp/command.h b/trunk/include/net/sctp/command.h index 6506458ccd33..dd6847e5d6e4 100644 --- a/trunk/include/net/sctp/command.h +++ b/trunk/include/net/sctp/command.h @@ -63,7 +63,6 @@ typedef enum { SCTP_CMD_ECN_ECNE, /* Do delayed ECNE processing. */ SCTP_CMD_ECN_CWR, /* Do delayed CWR processing. */ SCTP_CMD_TIMER_START, /* Start a timer. */ - SCTP_CMD_TIMER_START_ONCE, /* Start a timer once */ SCTP_CMD_TIMER_RESTART, /* Restart a timer. */ SCTP_CMD_TIMER_STOP, /* Stop a timer. */ SCTP_CMD_INIT_CHOOSE_TRANSPORT, /* Choose transport for an INIT. */ diff --git a/trunk/include/net/sctp/ulpevent.h b/trunk/include/net/sctp/ulpevent.h index ca4693b4e09e..99b027b2adce 100644 --- a/trunk/include/net/sctp/ulpevent.h +++ b/trunk/include/net/sctp/ulpevent.h @@ -80,7 +80,7 @@ static inline struct sctp_ulpevent *sctp_skb2event(struct sk_buff *skb) void sctp_ulpevent_free(struct sctp_ulpevent *); int sctp_ulpevent_is_notification(const struct sctp_ulpevent *); -unsigned int sctp_queue_purge_ulpevents(struct sk_buff_head *list); +void sctp_queue_purge_ulpevents(struct sk_buff_head *list); struct sctp_ulpevent *sctp_ulpevent_make_assoc_change( const struct sctp_association *asoc, diff --git a/trunk/include/net/sock.h b/trunk/include/net/sock.h index 396f735e0cd5..ebbc0bafe661 100644 --- a/trunk/include/net/sock.h +++ b/trunk/include/net/sock.h @@ -179,6 +179,7 @@ struct sock_common { * @sk_dst_cache: destination cache * @sk_dst_lock: destination cache lock * @sk_policy: flow policy + * @sk_rmem_alloc: receive queue bytes committed * @sk_receive_queue: incoming packets * @sk_wmem_alloc: transmit queue bytes committed * @sk_write_queue: Packet sending queue @@ -563,7 +564,6 @@ enum sock_flags { SOCK_TIMESTAMPING_SYS_HARDWARE, /* %SOF_TIMESTAMPING_SYS_HARDWARE */ SOCK_FASYNC, /* fasync() active */ SOCK_RXQ_OVFL, - SOCK_ZEROCOPY, /* buffers from userspace */ }; static inline void sock_copy_flags(struct sock *nsk, struct sock *osk) diff --git a/trunk/include/net/wimax.h b/trunk/include/net/wimax.h index 322ff4fbdb4a..7328d5019d88 100644 --- a/trunk/include/net/wimax.h +++ b/trunk/include/net/wimax.h @@ -423,6 +423,7 @@ struct wimax_dev { int (*op_reset)(struct wimax_dev *wimax_dev); struct rfkill *rfkill; + struct input_dev *rfkill_input; unsigned rf_hw; unsigned rf_sw; char name[32]; diff --git a/trunk/include/sound/sb16_csp.h b/trunk/include/sound/sb16_csp.h index af1b49e982df..736eac71d053 100644 --- a/trunk/include/sound/sb16_csp.h +++ b/trunk/include/sound/sb16_csp.h @@ -99,14 +99,7 @@ struct snd_sb_csp_info { /* get CSP information */ #define SNDRV_SB_CSP_IOCTL_INFO _IOR('H', 0x10, struct snd_sb_csp_info) /* load microcode to CSP */ -/* NOTE: struct snd_sb_csp_microcode overflows the max size (13 bits) - * defined for some architectures like MIPS, and it leads to build errors. - * (x86 and co have 14-bit size, thus it's valid, though.) - * As a workaround for skipping the size-limit check, here we don't use the - * normal _IOW() macro but _IOC() with the manual argument. - */ -#define SNDRV_SB_CSP_IOCTL_LOAD_CODE \ - _IOC(_IOC_WRITE, 'H', 0x11, sizeof(struct snd_sb_csp_microcode)) +#define SNDRV_SB_CSP_IOCTL_LOAD_CODE _IOW('H', 0x11, struct snd_sb_csp_microcode) /* unload microcode from CSP */ #define SNDRV_SB_CSP_IOCTL_UNLOAD_CODE _IO('H', 0x12) /* start CSP */ diff --git a/trunk/include/sound/soc.h b/trunk/include/sound/soc.h index 3a4bd3a3c68d..f1de3e0c75bc 100644 --- a/trunk/include/sound/soc.h +++ b/trunk/include/sound/soc.h @@ -248,7 +248,8 @@ typedef int (*hw_write_t)(void *,const char* ,int); extern struct snd_ac97_bus_ops soc_ac97_ops; enum snd_soc_control_type { - SND_SOC_I2C = 1, + SND_SOC_CUSTOM = 1, + SND_SOC_I2C, SND_SOC_SPI, }; diff --git a/trunk/include/trace/events/ext4.h b/trunk/include/trace/events/ext4.h index 5ce2b2f5f524..e09592d2f916 100644 --- a/trunk/include/trace/events/ext4.h +++ b/trunk/include/trace/events/ext4.h @@ -26,7 +26,7 @@ TRACE_EVENT(ext4_free_inode, __field( umode_t, mode ) __field( uid_t, uid ) __field( gid_t, gid ) - __field( __u64, blocks ) + __field( blkcnt_t, blocks ) ), TP_fast_assign( @@ -40,8 +40,9 @@ TRACE_EVENT(ext4_free_inode, TP_printk("dev %d,%d ino %lu mode 0%o uid %u gid %u blocks %llu", MAJOR(__entry->dev), MINOR(__entry->dev), - (unsigned long) __entry->ino, __entry->mode, - __entry->uid, __entry->gid, __entry->blocks) + (unsigned long) __entry->ino, + __entry->mode, __entry->uid, __entry->gid, + (unsigned long long) __entry->blocks) ); TRACE_EVENT(ext4_request_inode, @@ -177,7 +178,7 @@ TRACE_EVENT(ext4_begin_ordered_truncate, TP_printk("dev %d,%d ino %lu new_size %lld", MAJOR(__entry->dev), MINOR(__entry->dev), (unsigned long) __entry->ino, - __entry->new_size) + (long long) __entry->new_size) ); DECLARE_EVENT_CLASS(ext4__write_begin, @@ -203,7 +204,7 @@ DECLARE_EVENT_CLASS(ext4__write_begin, __entry->flags = flags; ), - TP_printk("dev %d,%d ino %lu pos %lld len %u flags %u", + TP_printk("dev %d,%d ino %lu pos %llu len %u flags %u", MAJOR(__entry->dev), MINOR(__entry->dev), (unsigned long) __entry->ino, __entry->pos, __entry->len, __entry->flags) @@ -247,7 +248,7 @@ DECLARE_EVENT_CLASS(ext4__write_end, __entry->copied = copied; ), - TP_printk("dev %d,%d ino %lu pos %lld len %u copied %u", + TP_printk("dev %d,%d ino %lu pos %llu len %u copied %u", MAJOR(__entry->dev), MINOR(__entry->dev), (unsigned long) __entry->ino, __entry->pos, __entry->len, __entry->copied) @@ -285,6 +286,29 @@ DEFINE_EVENT(ext4__write_end, ext4_da_write_end, TP_ARGS(inode, pos, len, copied) ); +TRACE_EVENT(ext4_writepage, + TP_PROTO(struct inode *inode, struct page *page), + + TP_ARGS(inode, page), + + TP_STRUCT__entry( + __field( dev_t, dev ) + __field( ino_t, ino ) + __field( pgoff_t, index ) + + ), + + TP_fast_assign( + __entry->dev = inode->i_sb->s_dev; + __entry->ino = inode->i_ino; + __entry->index = page->index; + ), + + TP_printk("dev %d,%d ino %lu page_index %lu", + MAJOR(__entry->dev), MINOR(__entry->dev), + (unsigned long) __entry->ino, __entry->index) +); + TRACE_EVENT(ext4_da_writepages, TP_PROTO(struct inode *inode, struct writeback_control *wbc), @@ -317,7 +341,7 @@ TRACE_EVENT(ext4_da_writepages, ), TP_printk("dev %d,%d ino %lu nr_to_write %ld pages_skipped %ld " - "range_start %lld range_end %lld sync_mode %d" + "range_start %llu range_end %llu sync_mode %d" "for_kupdate %d range_cyclic %d writeback_index %lu", MAJOR(__entry->dev), MINOR(__entry->dev), (unsigned long) __entry->ino, __entry->nr_to_write, @@ -425,14 +449,7 @@ DECLARE_EVENT_CLASS(ext4__page_op, TP_printk("dev %d,%d ino %lu page_index %lu", MAJOR(__entry->dev), MINOR(__entry->dev), (unsigned long) __entry->ino, - (unsigned long) __entry->index) -); - -DEFINE_EVENT(ext4__page_op, ext4_writepage, - - TP_PROTO(struct page *page), - - TP_ARGS(page) + __entry->index) ); DEFINE_EVENT(ext4__page_op, ext4_readpage, @@ -472,7 +489,7 @@ TRACE_EVENT(ext4_invalidatepage, TP_printk("dev %d,%d ino %lu page_index %lu offset %lu", MAJOR(__entry->dev), MINOR(__entry->dev), (unsigned long) __entry->ino, - (unsigned long) __entry->index, __entry->offset) + __entry->index, __entry->offset) ); TRACE_EVENT(ext4_discard_blocks, @@ -545,10 +562,12 @@ DEFINE_EVENT(ext4__mb_new_pa, ext4_mb_new_group_pa, ); TRACE_EVENT(ext4_mb_release_inode_pa, - TP_PROTO(struct ext4_prealloc_space *pa, + TP_PROTO(struct super_block *sb, + struct inode *inode, + struct ext4_prealloc_space *pa, unsigned long long block, unsigned int count), - TP_ARGS(pa, block, count), + TP_ARGS(sb, inode, pa, block, count), TP_STRUCT__entry( __field( dev_t, dev ) @@ -559,8 +578,8 @@ TRACE_EVENT(ext4_mb_release_inode_pa, ), TP_fast_assign( - __entry->dev = pa->pa_inode->i_sb->s_dev; - __entry->ino = pa->pa_inode->i_ino; + __entry->dev = sb->s_dev; + __entry->ino = inode->i_ino; __entry->block = block; __entry->count = count; ), @@ -572,9 +591,10 @@ TRACE_EVENT(ext4_mb_release_inode_pa, ); TRACE_EVENT(ext4_mb_release_group_pa, - TP_PROTO(struct ext4_prealloc_space *pa), + TP_PROTO(struct super_block *sb, + struct ext4_prealloc_space *pa), - TP_ARGS(pa), + TP_ARGS(sb, pa), TP_STRUCT__entry( __field( dev_t, dev ) @@ -584,7 +604,7 @@ TRACE_EVENT(ext4_mb_release_group_pa, ), TP_fast_assign( - __entry->dev = pa->pa_inode->i_sb->s_dev; + __entry->dev = sb->s_dev; __entry->pa_pstart = pa->pa_pstart; __entry->pa_len = pa->pa_len; ), @@ -646,10 +666,10 @@ TRACE_EVENT(ext4_request_blocks, __field( ino_t, ino ) __field( unsigned int, flags ) __field( unsigned int, len ) - __field( __u32, logical ) - __field( __u32, lleft ) - __field( __u32, lright ) + __field( __u64, logical ) __field( __u64, goal ) + __field( __u64, lleft ) + __field( __u64, lright ) __field( __u64, pleft ) __field( __u64, pright ) ), @@ -667,13 +687,17 @@ TRACE_EVENT(ext4_request_blocks, __entry->pright = ar->pright; ), - TP_printk("dev %d,%d ino %lu flags %u len %u lblk %u goal %llu " - "lleft %u lright %u pleft %llu pright %llu ", + TP_printk("dev %d,%d ino %lu flags %u len %u lblk %llu goal %llu " + "lleft %llu lright %llu pleft %llu pright %llu ", MAJOR(__entry->dev), MINOR(__entry->dev), - (unsigned long) __entry->ino, __entry->flags, - __entry->len, __entry->logical, __entry->goal, - __entry->lleft, __entry->lright, __entry->pleft, - __entry->pright) + (unsigned long) __entry->ino, + __entry->flags, __entry->len, + (unsigned long long) __entry->logical, + (unsigned long long) __entry->goal, + (unsigned long long) __entry->lleft, + (unsigned long long) __entry->lright, + (unsigned long long) __entry->pleft, + (unsigned long long) __entry->pright) ); TRACE_EVENT(ext4_allocate_blocks, @@ -687,10 +711,10 @@ TRACE_EVENT(ext4_allocate_blocks, __field( __u64, block ) __field( unsigned int, flags ) __field( unsigned int, len ) - __field( __u32, logical ) - __field( __u32, lleft ) - __field( __u32, lright ) + __field( __u64, logical ) __field( __u64, goal ) + __field( __u64, lleft ) + __field( __u64, lright ) __field( __u64, pleft ) __field( __u64, pright ) ), @@ -709,13 +733,17 @@ TRACE_EVENT(ext4_allocate_blocks, __entry->pright = ar->pright; ), - TP_printk("dev %d,%d ino %lu flags %u len %u block %llu lblk %u " - "goal %llu lleft %u lright %u pleft %llu pright %llu", + TP_printk("dev %d,%d ino %lu flags %u len %u block %llu lblk %llu " + "goal %llu lleft %llu lright %llu pleft %llu pright %llu", MAJOR(__entry->dev), MINOR(__entry->dev), - (unsigned long) __entry->ino, __entry->flags, - __entry->len, __entry->block, __entry->logical, - __entry->goal, __entry->lleft, __entry->lright, - __entry->pleft, __entry->pright) + (unsigned long) __entry->ino, + __entry->flags, __entry->len, __entry->block, + (unsigned long long) __entry->logical, + (unsigned long long) __entry->goal, + (unsigned long long) __entry->lleft, + (unsigned long long) __entry->lright, + (unsigned long long) __entry->pleft, + (unsigned long long) __entry->pright) ); TRACE_EVENT(ext4_free_blocks, @@ -727,10 +755,10 @@ TRACE_EVENT(ext4_free_blocks, TP_STRUCT__entry( __field( dev_t, dev ) __field( ino_t, ino ) - __field( umode_t, mode ) + __field( umode_t, mode ) __field( __u64, block ) __field( unsigned long, count ) - __field( int, flags ) + __field( int, flags ) ), TP_fast_assign( @@ -770,7 +798,7 @@ TRACE_EVENT(ext4_sync_file_enter, __entry->parent = dentry->d_parent->d_inode->i_ino; ), - TP_printk("dev %d,%d ino %lu parent %lu datasync %d ", + TP_printk("dev %d,%d ino %ld parent %ld datasync %d ", MAJOR(__entry->dev), MINOR(__entry->dev), (unsigned long) __entry->ino, (unsigned long) __entry->parent, __entry->datasync) @@ -793,7 +821,7 @@ TRACE_EVENT(ext4_sync_file_exit, __entry->dev = inode->i_sb->s_dev; ), - TP_printk("dev %d,%d ino %lu ret %d", + TP_printk("dev %d,%d ino %ld ret %d", MAJOR(__entry->dev), MINOR(__entry->dev), (unsigned long) __entry->ino, __entry->ret) @@ -977,7 +1005,7 @@ DECLARE_EVENT_CLASS(ext4__mballoc, __entry->result_len = len; ), - TP_printk("dev %d,%d inode %lu extent %u/%d/%d ", + TP_printk("dev %d,%d inode %lu extent %u/%d/%u ", MAJOR(__entry->dev), MINOR(__entry->dev), (unsigned long) __entry->ino, __entry->result_group, __entry->result_start, @@ -1065,7 +1093,7 @@ TRACE_EVENT(ext4_da_update_reserve_space, "allocated_meta_blocks %d", MAJOR(__entry->dev), MINOR(__entry->dev), (unsigned long) __entry->ino, - __entry->mode, __entry->i_blocks, + __entry->mode, (unsigned long long) __entry->i_blocks, __entry->used_blocks, __entry->reserved_data_blocks, __entry->reserved_meta_blocks, __entry->allocated_meta_blocks) ); @@ -1099,7 +1127,7 @@ TRACE_EVENT(ext4_da_reserve_space, "reserved_data_blocks %d reserved_meta_blocks %d", MAJOR(__entry->dev), MINOR(__entry->dev), (unsigned long) __entry->ino, - __entry->mode, __entry->i_blocks, + __entry->mode, (unsigned long long) __entry->i_blocks, __entry->md_needed, __entry->reserved_data_blocks, __entry->reserved_meta_blocks) ); @@ -1136,7 +1164,7 @@ TRACE_EVENT(ext4_da_release_space, "allocated_meta_blocks %d", MAJOR(__entry->dev), MINOR(__entry->dev), (unsigned long) __entry->ino, - __entry->mode, __entry->i_blocks, + __entry->mode, (unsigned long long) __entry->i_blocks, __entry->freed_blocks, __entry->reserved_data_blocks, __entry->reserved_meta_blocks, __entry->allocated_meta_blocks) ); @@ -1211,15 +1239,14 @@ TRACE_EVENT(ext4_direct_IO_enter, __entry->rw = rw; ), - TP_printk("dev %d,%d ino %lu pos %lld len %lu rw %d", + TP_printk("dev %d,%d ino %lu pos %llu len %lu rw %d", MAJOR(__entry->dev), MINOR(__entry->dev), (unsigned long) __entry->ino, - __entry->pos, __entry->len, __entry->rw) + (unsigned long long) __entry->pos, __entry->len, __entry->rw) ); TRACE_EVENT(ext4_direct_IO_exit, - TP_PROTO(struct inode *inode, loff_t offset, unsigned long len, - int rw, int ret), + TP_PROTO(struct inode *inode, loff_t offset, unsigned long len, int rw, int ret), TP_ARGS(inode, offset, len, rw, ret), @@ -1241,10 +1268,10 @@ TRACE_EVENT(ext4_direct_IO_exit, __entry->ret = ret; ), - TP_printk("dev %d,%d ino %lu pos %lld len %lu rw %d ret %d", + TP_printk("dev %d,%d ino %lu pos %llu len %lu rw %d ret %d", MAJOR(__entry->dev), MINOR(__entry->dev), (unsigned long) __entry->ino, - __entry->pos, __entry->len, + (unsigned long long) __entry->pos, __entry->len, __entry->rw, __entry->ret) ); @@ -1269,15 +1296,15 @@ TRACE_EVENT(ext4_fallocate_enter, __entry->mode = mode; ), - TP_printk("dev %d,%d ino %lu pos %lld len %lld mode %d", + TP_printk("dev %d,%d ino %ld pos %llu len %llu mode %d", MAJOR(__entry->dev), MINOR(__entry->dev), - (unsigned long) __entry->ino, __entry->pos, - __entry->len, __entry->mode) + (unsigned long) __entry->ino, + (unsigned long long) __entry->pos, + (unsigned long long) __entry->len, __entry->mode) ); TRACE_EVENT(ext4_fallocate_exit, - TP_PROTO(struct inode *inode, loff_t offset, - unsigned int max_blocks, int ret), + TP_PROTO(struct inode *inode, loff_t offset, unsigned int max_blocks, int ret), TP_ARGS(inode, offset, max_blocks, ret), @@ -1285,7 +1312,7 @@ TRACE_EVENT(ext4_fallocate_exit, __field( ino_t, ino ) __field( dev_t, dev ) __field( loff_t, pos ) - __field( unsigned int, blocks ) + __field( unsigned, blocks ) __field( int, ret ) ), @@ -1297,10 +1324,10 @@ TRACE_EVENT(ext4_fallocate_exit, __entry->ret = ret; ), - TP_printk("dev %d,%d ino %lu pos %lld blocks %u ret %d", + TP_printk("dev %d,%d ino %ld pos %llu blocks %d ret %d", MAJOR(__entry->dev), MINOR(__entry->dev), (unsigned long) __entry->ino, - __entry->pos, __entry->blocks, + (unsigned long long) __entry->pos, __entry->blocks, __entry->ret) ); @@ -1323,7 +1350,7 @@ TRACE_EVENT(ext4_unlink_enter, __entry->dev = dentry->d_inode->i_sb->s_dev; ), - TP_printk("dev %d,%d ino %lu size %lld parent %lu", + TP_printk("dev %d,%d ino %ld size %lld parent %ld", MAJOR(__entry->dev), MINOR(__entry->dev), (unsigned long) __entry->ino, __entry->size, (unsigned long) __entry->parent) @@ -1346,7 +1373,7 @@ TRACE_EVENT(ext4_unlink_exit, __entry->ret = ret; ), - TP_printk("dev %d,%d ino %lu ret %d", + TP_printk("dev %d,%d ino %ld ret %d", MAJOR(__entry->dev), MINOR(__entry->dev), (unsigned long) __entry->ino, __entry->ret) @@ -1360,7 +1387,7 @@ DECLARE_EVENT_CLASS(ext4__truncate, TP_STRUCT__entry( __field( ino_t, ino ) __field( dev_t, dev ) - __field( __u64, blocks ) + __field( blkcnt_t, blocks ) ), TP_fast_assign( @@ -1369,9 +1396,9 @@ DECLARE_EVENT_CLASS(ext4__truncate, __entry->blocks = inode->i_blocks; ), - TP_printk("dev %d,%d ino %lu blocks %llu", + TP_printk("dev %d,%d ino %lu blocks %lu", MAJOR(__entry->dev), MINOR(__entry->dev), - (unsigned long) __entry->ino, __entry->blocks) + (unsigned long) __entry->ino, (unsigned long) __entry->blocks) ); DEFINE_EVENT(ext4__truncate, ext4_truncate_enter, @@ -1390,7 +1417,7 @@ DEFINE_EVENT(ext4__truncate, ext4_truncate_exit, DECLARE_EVENT_CLASS(ext4__map_blocks_enter, TP_PROTO(struct inode *inode, ext4_lblk_t lblk, - unsigned int len, unsigned int flags), + unsigned len, unsigned flags), TP_ARGS(inode, lblk, len, flags), @@ -1398,8 +1425,8 @@ DECLARE_EVENT_CLASS(ext4__map_blocks_enter, __field( ino_t, ino ) __field( dev_t, dev ) __field( ext4_lblk_t, lblk ) - __field( unsigned int, len ) - __field( unsigned int, flags ) + __field( unsigned, len ) + __field( unsigned, flags ) ), TP_fast_assign( @@ -1413,7 +1440,7 @@ DECLARE_EVENT_CLASS(ext4__map_blocks_enter, TP_printk("dev %d,%d ino %lu lblk %u len %u flags %u", MAJOR(__entry->dev), MINOR(__entry->dev), (unsigned long) __entry->ino, - __entry->lblk, __entry->len, __entry->flags) + (unsigned) __entry->lblk, __entry->len, __entry->flags) ); DEFINE_EVENT(ext4__map_blocks_enter, ext4_ext_map_blocks_enter, @@ -1432,7 +1459,7 @@ DEFINE_EVENT(ext4__map_blocks_enter, ext4_ind_map_blocks_enter, DECLARE_EVENT_CLASS(ext4__map_blocks_exit, TP_PROTO(struct inode *inode, ext4_lblk_t lblk, - ext4_fsblk_t pblk, unsigned int len, int ret), + ext4_fsblk_t pblk, unsigned len, int ret), TP_ARGS(inode, lblk, pblk, len, ret), @@ -1441,7 +1468,7 @@ DECLARE_EVENT_CLASS(ext4__map_blocks_exit, __field( dev_t, dev ) __field( ext4_lblk_t, lblk ) __field( ext4_fsblk_t, pblk ) - __field( unsigned int, len ) + __field( unsigned, len ) __field( int, ret ) ), @@ -1457,7 +1484,7 @@ DECLARE_EVENT_CLASS(ext4__map_blocks_exit, TP_printk("dev %d,%d ino %lu lblk %u pblk %llu len %u ret %d", MAJOR(__entry->dev), MINOR(__entry->dev), (unsigned long) __entry->ino, - __entry->lblk, __entry->pblk, + (unsigned) __entry->lblk, (unsigned long long) __entry->pblk, __entry->len, __entry->ret) ); @@ -1497,7 +1524,7 @@ TRACE_EVENT(ext4_ext_load_extent, TP_printk("dev %d,%d ino %lu lblk %u pblk %llu", MAJOR(__entry->dev), MINOR(__entry->dev), (unsigned long) __entry->ino, - __entry->lblk, __entry->pblk) + (unsigned) __entry->lblk, (unsigned long long) __entry->pblk) ); TRACE_EVENT(ext4_load_inode, diff --git a/trunk/init/calibrate.c b/trunk/init/calibrate.c index aae2f40fea4c..2568d22a304e 100644 --- a/trunk/init/calibrate.c +++ b/trunk/init/calibrate.c @@ -245,32 +245,30 @@ static unsigned long __cpuinit calibrate_delay_converge(void) void __cpuinit calibrate_delay(void) { - unsigned long lpj; static bool printed; if (preset_lpj) { - lpj = preset_lpj; + loops_per_jiffy = preset_lpj; if (!printed) pr_info("Calibrating delay loop (skipped) " "preset value.. "); } else if ((!printed) && lpj_fine) { - lpj = lpj_fine; + loops_per_jiffy = lpj_fine; pr_info("Calibrating delay loop (skipped), " "value calculated using timer frequency.. "); - } else if ((lpj = calibrate_delay_direct()) != 0) { + } else if ((loops_per_jiffy = calibrate_delay_direct()) != 0) { if (!printed) pr_info("Calibrating delay using timer " "specific routine.. "); } else { if (!printed) pr_info("Calibrating delay loop... "); - lpj = calibrate_delay_converge(); + loops_per_jiffy = calibrate_delay_converge(); } if (!printed) pr_cont("%lu.%02lu BogoMIPS (lpj=%lu)\n", - lpj/(500000/HZ), - (lpj/(5000/HZ)) % 100, lpj); + loops_per_jiffy/(500000/HZ), + (loops_per_jiffy/(5000/HZ)) % 100, loops_per_jiffy); - loops_per_jiffy = lpj; printed = true; } diff --git a/trunk/kernel/irq/generic-chip.c b/trunk/kernel/irq/generic-chip.c index 3a2cab407b93..31a9db711906 100644 --- a/trunk/kernel/irq/generic-chip.c +++ b/trunk/kernel/irq/generic-chip.c @@ -101,10 +101,10 @@ void irq_gc_unmask_enable_reg(struct irq_data *d) } /** - * irq_gc_ack_set_bit - Ack pending interrupt via setting bit + * irq_gc_ack - Ack pending interrupt * @d: irq_data */ -void irq_gc_ack_set_bit(struct irq_data *d) +void irq_gc_ack(struct irq_data *d) { struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d); u32 mask = 1 << (d->irq - gc->irq_base); @@ -114,20 +114,6 @@ void irq_gc_ack_set_bit(struct irq_data *d) irq_gc_unlock(gc); } -/** - * irq_gc_ack_clr_bit - Ack pending interrupt via clearing bit - * @d: irq_data - */ -void irq_gc_ack_clr_bit(struct irq_data *d) -{ - struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d); - u32 mask = ~(1 << (d->irq - gc->irq_base)); - - irq_gc_lock(gc); - irq_reg_writel(mask, gc->reg_base + cur_regs(d)->ack); - irq_gc_unlock(gc); -} - /** * irq_gc_mask_disable_reg_and_ack- Mask and ack pending interrupt * @d: irq_data diff --git a/trunk/kernel/jump_label.c b/trunk/kernel/jump_label.c index a8ce45097f3d..fa27e750dbc0 100644 --- a/trunk/kernel/jump_label.c +++ b/trunk/kernel/jump_label.c @@ -375,19 +375,15 @@ int jump_label_text_reserved(void *start, void *end) static void jump_label_update(struct jump_label_key *key, int enable) { - struct jump_entry *entry = key->entries, *stop = __stop___jump_table; + struct jump_entry *entry = key->entries; -#ifdef CONFIG_MODULES - struct module *mod = __module_address((jump_label_t)key); + /* if there are no users, entry can be NULL */ + if (entry) + __jump_label_update(key, entry, __stop___jump_table, enable); +#ifdef CONFIG_MODULES __jump_label_mod_update(key, enable); - - if (mod) - stop = mod->jump_entries + mod->num_jump_entries; #endif - /* if there are no users, entry can be NULL */ - if (entry) - __jump_label_update(key, entry, stop, enable); } #endif diff --git a/trunk/kernel/power/snapshot.c b/trunk/kernel/power/snapshot.c index 06efa54f93d6..ace55889f702 100644 --- a/trunk/kernel/power/snapshot.c +++ b/trunk/kernel/power/snapshot.c @@ -1211,11 +1211,7 @@ static void free_unnecessary_pages(void) to_free_highmem = alloc_highmem - save; } else { to_free_highmem = 0; - save -= alloc_highmem; - if (to_free_normal > save) - to_free_normal -= save; - else - to_free_normal = 0; + to_free_normal -= save - alloc_highmem; } memory_bm_position_reset(©_bm); diff --git a/trunk/kernel/power/user.c b/trunk/kernel/power/user.c index 42ddbc6f0de6..7d02d33be699 100644 --- a/trunk/kernel/power/user.c +++ b/trunk/kernel/power/user.c @@ -113,10 +113,8 @@ static int snapshot_open(struct inode *inode, struct file *filp) if (error) pm_notifier_call_chain(PM_POST_RESTORE); } - if (error) { - free_basic_memory_bitmaps(); + if (error) atomic_inc(&snapshot_device_available); - } data->frozen = 0; data->ready = 0; data->platform_support = 0; diff --git a/trunk/kernel/resource.c b/trunk/kernel/resource.c index 3ff40178dce7..798e2fae2a06 100644 --- a/trunk/kernel/resource.c +++ b/trunk/kernel/resource.c @@ -38,14 +38,6 @@ struct resource iomem_resource = { }; EXPORT_SYMBOL(iomem_resource); -/* constraints to be met while allocating resources */ -struct resource_constraint { - resource_size_t min, max, align; - resource_size_t (*alignf)(void *, const struct resource *, - resource_size_t, resource_size_t); - void *alignf_data; -}; - static DEFINE_RWLOCK(resource_lock); static void *r_next(struct seq_file *m, void *v, loff_t *pos) @@ -392,13 +384,16 @@ static bool resource_contains(struct resource *res1, struct resource *res2) } /* - * Find empty slot in the resource tree with the given range and - * alignment constraints + * Find empty slot in the resource tree given range and alignment. */ -static int __find_resource(struct resource *root, struct resource *old, - struct resource *new, - resource_size_t size, - struct resource_constraint *constraint) +static int find_resource(struct resource *root, struct resource *new, + resource_size_t size, resource_size_t min, + resource_size_t max, resource_size_t align, + resource_size_t (*alignf)(void *, + const struct resource *, + resource_size_t, + resource_size_t), + void *alignf_data) { struct resource *this = root->child; struct resource tmp = *new, avail, alloc; @@ -409,26 +404,25 @@ static int __find_resource(struct resource *root, struct resource *old, * Skip past an allocated resource that starts at 0, since the assignment * of this->start - 1 to tmp->end below would cause an underflow. */ - if (this && this->start == root->start) { - tmp.start = (this == old) ? old->start : this->end + 1; + if (this && this->start == 0) { + tmp.start = this->end + 1; this = this->sibling; } for(;;) { if (this) - tmp.end = (this == old) ? this->end : this->start - 1; + tmp.end = this->start - 1; else tmp.end = root->end; - resource_clip(&tmp, constraint->min, constraint->max); + resource_clip(&tmp, min, max); arch_remove_reservations(&tmp); /* Check for overflow after ALIGN() */ avail = *new; - avail.start = ALIGN(tmp.start, constraint->align); + avail.start = ALIGN(tmp.start, align); avail.end = tmp.end; if (avail.start >= tmp.start) { - alloc.start = constraint->alignf(constraint->alignf_data, &avail, - size, constraint->align); + alloc.start = alignf(alignf_data, &avail, size, align); alloc.end = alloc.start + size - 1; if (resource_contains(&avail, &alloc)) { new->start = alloc.start; @@ -438,75 +432,14 @@ static int __find_resource(struct resource *root, struct resource *old, } if (!this) break; - if (this != old) - tmp.start = this->end + 1; + tmp.start = this->end + 1; this = this->sibling; } return -EBUSY; } -/* - * Find empty slot in the resource tree given range and alignment. - */ -static int find_resource(struct resource *root, struct resource *new, - resource_size_t size, - struct resource_constraint *constraint) -{ - return __find_resource(root, NULL, new, size, constraint); -} - /** - * reallocate_resource - allocate a slot in the resource tree given range & alignment. - * The resource will be relocated if the new size cannot be reallocated in the - * current location. - * - * @root: root resource descriptor - * @old: resource descriptor desired by caller - * @newsize: new size of the resource descriptor - * @constraint: the size and alignment constraints to be met. - */ -int reallocate_resource(struct resource *root, struct resource *old, - resource_size_t newsize, - struct resource_constraint *constraint) -{ - int err=0; - struct resource new = *old; - struct resource *conflict; - - write_lock(&resource_lock); - - if ((err = __find_resource(root, old, &new, newsize, constraint))) - goto out; - - if (resource_contains(&new, old)) { - old->start = new.start; - old->end = new.end; - goto out; - } - - if (old->child) { - err = -EBUSY; - goto out; - } - - if (resource_contains(old, &new)) { - old->start = new.start; - old->end = new.end; - } else { - __release_resource(old); - *old = new; - conflict = __request_resource(root, old); - BUG_ON(conflict); - } -out: - write_unlock(&resource_lock); - return err; -} - - -/** - * allocate_resource - allocate empty slot in the resource tree given range & alignment. - * The resource will be reallocated with a new size if it was already allocated + * allocate_resource - allocate empty slot in the resource tree given range & alignment * @root: root resource descriptor * @new: resource descriptor desired by caller * @size: requested resource region size @@ -526,25 +459,12 @@ int allocate_resource(struct resource *root, struct resource *new, void *alignf_data) { int err; - struct resource_constraint constraint; if (!alignf) alignf = simple_align_resource; - constraint.min = min; - constraint.max = max; - constraint.align = align; - constraint.alignf = alignf; - constraint.alignf_data = alignf_data; - - if ( new->parent ) { - /* resource is already allocated, try reallocating with - the new constraints */ - return reallocate_resource(root, new, size, &constraint); - } - write_lock(&resource_lock); - err = find_resource(root, new, size, &constraint); + err = find_resource(root, new, size, min, max, align, alignf, alignf_data); if (err >= 0 && __request_resource(root, new)) err = -EBUSY; write_unlock(&resource_lock); diff --git a/trunk/kernel/sched.c b/trunk/kernel/sched.c index 9769c756ad66..3f2e502d609b 100644 --- a/trunk/kernel/sched.c +++ b/trunk/kernel/sched.c @@ -292,8 +292,8 @@ static DEFINE_SPINLOCK(task_group_lock); * (The default weight is 1024 - so there's no practical * limitation from this.) */ -#define MIN_SHARES (1UL << 1) -#define MAX_SHARES (1UL << 18) +#define MIN_SHARES 2 +#define MAX_SHARES (1UL << (18 + SCHED_LOAD_RESOLUTION)) static int root_task_group_load = ROOT_TASK_GROUP_LOAD; #endif @@ -8450,7 +8450,10 @@ int sched_group_set_shares(struct task_group *tg, unsigned long shares) if (!tg->se[0]) return -EINVAL; - shares = clamp(shares, scale_load(MIN_SHARES), scale_load(MAX_SHARES)); + if (shares < MIN_SHARES) + shares = MIN_SHARES; + else if (shares > MAX_SHARES) + shares = MAX_SHARES; mutex_lock(&shares_mutex); if (tg->shares == shares) diff --git a/trunk/kernel/taskstats.c b/trunk/kernel/taskstats.c index fc0f22005417..9ffea360a778 100644 --- a/trunk/kernel/taskstats.c +++ b/trunk/kernel/taskstats.c @@ -285,18 +285,16 @@ static void fill_tgid_exit(struct task_struct *tsk) static int add_del_listener(pid_t pid, const struct cpumask *mask, int isadd) { struct listener_list *listeners; - struct listener *s, *tmp, *s2; + struct listener *s, *tmp; unsigned int cpu; if (!cpumask_subset(mask, cpu_possible_mask)) return -EINVAL; - s = NULL; if (isadd == REGISTER) { for_each_cpu(cpu, mask) { - if (!s) - s = kmalloc_node(sizeof(struct listener), - GFP_KERNEL, cpu_to_node(cpu)); + s = kmalloc_node(sizeof(struct listener), GFP_KERNEL, + cpu_to_node(cpu)); if (!s) goto cleanup; s->pid = pid; @@ -305,16 +303,9 @@ static int add_del_listener(pid_t pid, const struct cpumask *mask, int isadd) listeners = &per_cpu(listener_array, cpu); down_write(&listeners->sem); - list_for_each_entry_safe(s2, tmp, &listeners->list, list) { - if (s2->pid == pid) - goto next_cpu; - } list_add(&s->list, &listeners->list); - s = NULL; -next_cpu: up_write(&listeners->sem); } - kfree(s); return 0; } diff --git a/trunk/kernel/time/alarmtimer.c b/trunk/kernel/time/alarmtimer.c index 59f369f98a04..2d966244ea60 100644 --- a/trunk/kernel/time/alarmtimer.c +++ b/trunk/kernel/time/alarmtimer.c @@ -42,76 +42,16 @@ static struct alarm_base { clockid_t base_clockid; } alarm_bases[ALARM_NUMTYPE]; -/* freezer delta & lock used to handle clock_nanosleep triggered wakeups */ -static ktime_t freezer_delta; -static DEFINE_SPINLOCK(freezer_delta_lock); - #ifdef CONFIG_RTC_CLASS /* rtc timer and device for setting alarm wakeups at suspend */ static struct rtc_timer rtctimer; static struct rtc_device *rtcdev; -static DEFINE_SPINLOCK(rtcdev_lock); - -/** - * has_wakealarm - check rtc device has wakealarm ability - * @dev: current device - * @name_ptr: name to be returned - * - * This helper function checks to see if the rtc device can wake - * from suspend. - */ -static int has_wakealarm(struct device *dev, void *name_ptr) -{ - struct rtc_device *candidate = to_rtc_device(dev); - - if (!candidate->ops->set_alarm) - return 0; - if (!device_may_wakeup(candidate->dev.parent)) - return 0; - - *(const char **)name_ptr = dev_name(dev); - return 1; -} - -/** - * alarmtimer_get_rtcdev - Return selected rtcdevice - * - * This function returns the rtc device to use for wakealarms. - * If one has not already been chosen, it checks to see if a - * functional rtc device is available. - */ -static struct rtc_device *alarmtimer_get_rtcdev(void) -{ - struct device *dev; - char *str; - unsigned long flags; - struct rtc_device *ret; - - spin_lock_irqsave(&rtcdev_lock, flags); - if (!rtcdev) { - /* Find an rtc device and init the rtc_timer */ - dev = class_find_device(rtc_class, NULL, &str, has_wakealarm); - /* If we have a device then str is valid. See has_wakealarm() */ - if (dev) { - rtcdev = rtc_class_open(str); - /* - * Drop the reference we got in class_find_device, - * rtc_open takes its own. - */ - put_device(dev); - rtc_timer_init(&rtctimer, NULL, NULL); - } - } - ret = rtcdev; - spin_unlock_irqrestore(&rtcdev_lock, flags); - - return ret; -} -#else -#define alarmtimer_get_rtcdev() (0) -#define rtcdev (0) #endif +/* freezer delta & lock used to handle clock_nanosleep triggered wakeups */ +static ktime_t freezer_delta; +static DEFINE_SPINLOCK(freezer_delta_lock); + /** * alarmtimer_enqueue - Adds an alarm timer to an alarm_base timerqueue @@ -226,7 +166,6 @@ static int alarmtimer_suspend(struct device *dev) struct rtc_time tm; ktime_t min, now; unsigned long flags; - struct rtc_device *rtc; int i; spin_lock_irqsave(&freezer_delta_lock, flags); @@ -234,9 +173,8 @@ static int alarmtimer_suspend(struct device *dev) freezer_delta = ktime_set(0, 0); spin_unlock_irqrestore(&freezer_delta_lock, flags); - rtc = rtcdev; /* If we have no rtcdev, just return */ - if (!rtc) + if (!rtcdev) return 0; /* Find the soonest timer to expire*/ @@ -261,12 +199,12 @@ static int alarmtimer_suspend(struct device *dev) WARN_ON(min.tv64 < NSEC_PER_SEC); /* Setup an rtc timer to fire that far in the future */ - rtc_timer_cancel(rtc, &rtctimer); - rtc_read_time(rtc, &tm); + rtc_timer_cancel(rtcdev, &rtctimer); + rtc_read_time(rtcdev, &tm); now = rtc_tm_to_ktime(tm); now = ktime_add(now, min); - rtc_timer_start(rtc, &rtctimer, now, ktime_set(0, 0)); + rtc_timer_start(rtcdev, &rtctimer, now, ktime_set(0, 0)); return 0; } @@ -384,9 +322,6 @@ static int alarm_clock_getres(const clockid_t which_clock, struct timespec *tp) { clockid_t baseid = alarm_bases[clock2alarm(which_clock)].base_clockid; - if (!alarmtimer_get_rtcdev()) - return -ENOTSUPP; - return hrtimer_get_res(baseid, tp); } @@ -401,9 +336,6 @@ static int alarm_clock_get(clockid_t which_clock, struct timespec *tp) { struct alarm_base *base = &alarm_bases[clock2alarm(which_clock)]; - if (!alarmtimer_get_rtcdev()) - return -ENOTSUPP; - *tp = ktime_to_timespec(base->gettime()); return 0; } @@ -419,9 +351,6 @@ static int alarm_timer_create(struct k_itimer *new_timer) enum alarmtimer_type type; struct alarm_base *base; - if (!alarmtimer_get_rtcdev()) - return -ENOTSUPP; - if (!capable(CAP_WAKE_ALARM)) return -EPERM; @@ -456,9 +385,6 @@ static void alarm_timer_get(struct k_itimer *timr, */ static int alarm_timer_del(struct k_itimer *timr) { - if (!rtcdev) - return -ENOTSUPP; - alarm_cancel(&timr->it.alarmtimer); return 0; } @@ -476,9 +402,6 @@ static int alarm_timer_set(struct k_itimer *timr, int flags, struct itimerspec *new_setting, struct itimerspec *old_setting) { - if (!rtcdev) - return -ENOTSUPP; - /* Save old values */ old_setting->it_interval = ktime_to_timespec(timr->it.alarmtimer.period); @@ -618,9 +541,6 @@ static int alarm_timer_nsleep(const clockid_t which_clock, int flags, int ret = 0; struct restart_block *restart; - if (!alarmtimer_get_rtcdev()) - return -ENOTSUPP; - if (!capable(CAP_WAKE_ALARM)) return -EPERM; @@ -718,3 +638,65 @@ static int __init alarmtimer_init(void) } device_initcall(alarmtimer_init); +#ifdef CONFIG_RTC_CLASS +/** + * has_wakealarm - check rtc device has wakealarm ability + * @dev: current device + * @name_ptr: name to be returned + * + * This helper function checks to see if the rtc device can wake + * from suspend. + */ +static int __init has_wakealarm(struct device *dev, void *name_ptr) +{ + struct rtc_device *candidate = to_rtc_device(dev); + + if (!candidate->ops->set_alarm) + return 0; + if (!device_may_wakeup(candidate->dev.parent)) + return 0; + + *(const char **)name_ptr = dev_name(dev); + return 1; +} + +/** + * alarmtimer_init_late - Late initializing of alarmtimer code + * + * This function locates a rtc device to use for wakealarms. + * Run as late_initcall to make sure rtc devices have been + * registered. + */ +static int __init alarmtimer_init_late(void) +{ + struct device *dev; + char *str; + + /* Find an rtc device and init the rtc_timer */ + dev = class_find_device(rtc_class, NULL, &str, has_wakealarm); + /* If we have a device then str is valid. See has_wakealarm() */ + if (dev) { + rtcdev = rtc_class_open(str); + /* + * Drop the reference we got in class_find_device, + * rtc_open takes its own. + */ + put_device(dev); + } + if (!rtcdev) { + printk(KERN_WARNING "No RTC device found, ALARM timers will" + " not wake from suspend"); + } + rtc_timer_init(&rtctimer, NULL, NULL); + + return 0; +} +#else +static int __init alarmtimer_init_late(void) +{ + printk(KERN_WARNING "Kernel not built with RTC support, ALARM timers" + " will not wake from suspend"); + return 0; +} +#endif +late_initcall(alarmtimer_init_late); diff --git a/trunk/lib/checksum.c b/trunk/lib/checksum.c index 8df2f91e6d98..097508732f34 100644 --- a/trunk/lib/checksum.c +++ b/trunk/lib/checksum.c @@ -49,7 +49,7 @@ static inline unsigned short from32to16(unsigned int x) static unsigned int do_csum(const unsigned char *buff, int len) { - int odd; + int odd, count; unsigned int result = 0; if (len <= 0) @@ -64,22 +64,25 @@ static unsigned int do_csum(const unsigned char *buff, int len) len--; buff++; } - if (len >= 2) { + count = len >> 1; /* nr of 16-bit words.. */ + if (count) { if (2 & (unsigned long) buff) { result += *(unsigned short *) buff; + count--; len -= 2; buff += 2; } - if (len >= 4) { - const unsigned char *end = buff + ((unsigned)len & ~3); + count >>= 1; /* nr of 32-bit words.. */ + if (count) { unsigned int carry = 0; do { unsigned int w = *(unsigned int *) buff; + count--; buff += 4; result += carry; result += w; carry = (w > result); - } while (buff < end); + } while (count); result += carry; result = (result & 0xffff) + (result >> 16); } diff --git a/trunk/lib/debugobjects.c b/trunk/lib/debugobjects.c index a78b7c6e042c..9d86e45086f5 100644 --- a/trunk/lib/debugobjects.c +++ b/trunk/lib/debugobjects.c @@ -198,7 +198,7 @@ static void free_object(struct debug_obj *obj) * initialized: */ if (obj_pool_free > ODEBUG_POOL_SIZE && obj_cache) - sched = keventd_up() && !work_pending(&debug_obj_work); + sched = !work_pending(&debug_obj_work); hlist_add_head(&obj->node, &obj_pool); obj_pool_free++; obj_pool_used--; diff --git a/trunk/mm/memcontrol.c b/trunk/mm/memcontrol.c index e013b8e57d25..cf7d027a8844 100644 --- a/trunk/mm/memcontrol.c +++ b/trunk/mm/memcontrol.c @@ -35,7 +35,6 @@ #include #include #include -#include #include #include #include @@ -108,12 +107,10 @@ enum mem_cgroup_events_index { enum mem_cgroup_events_target { MEM_CGROUP_TARGET_THRESH, MEM_CGROUP_TARGET_SOFTLIMIT, - MEM_CGROUP_TARGET_NUMAINFO, MEM_CGROUP_NTARGETS, }; #define THRESHOLDS_EVENTS_TARGET (128) #define SOFTLIMIT_EVENTS_TARGET (1024) -#define NUMAINFO_EVENTS_TARGET (1024) struct mem_cgroup_stat_cpu { long count[MEM_CGROUP_STAT_NSTATS]; @@ -239,8 +236,7 @@ struct mem_cgroup { int last_scanned_node; #if MAX_NUMNODES > 1 nodemask_t scan_nodes; - atomic_t numainfo_events; - atomic_t numainfo_updating; + unsigned long next_scan_node_update; #endif /* * Should the accounting and control be hierarchical, per subtree? @@ -580,6 +576,15 @@ static long mem_cgroup_read_stat(struct mem_cgroup *mem, return val; } +static long mem_cgroup_local_usage(struct mem_cgroup *mem) +{ + long ret; + + ret = mem_cgroup_read_stat(mem, MEM_CGROUP_STAT_RSS); + ret += mem_cgroup_read_stat(mem, MEM_CGROUP_STAT_CACHE); + return ret; +} + static void mem_cgroup_swap_statistics(struct mem_cgroup *mem, bool charge) { @@ -683,9 +688,6 @@ static void __mem_cgroup_target_update(struct mem_cgroup *mem, int target) case MEM_CGROUP_TARGET_SOFTLIMIT: next = val + SOFTLIMIT_EVENTS_TARGET; break; - case MEM_CGROUP_TARGET_NUMAINFO: - next = val + NUMAINFO_EVENTS_TARGET; - break; default: return; } @@ -704,19 +706,11 @@ static void memcg_check_events(struct mem_cgroup *mem, struct page *page) mem_cgroup_threshold(mem); __mem_cgroup_target_update(mem, MEM_CGROUP_TARGET_THRESH); if (unlikely(__memcg_event_check(mem, - MEM_CGROUP_TARGET_SOFTLIMIT))) { + MEM_CGROUP_TARGET_SOFTLIMIT))){ mem_cgroup_update_tree(mem, page); __mem_cgroup_target_update(mem, - MEM_CGROUP_TARGET_SOFTLIMIT); - } -#if MAX_NUMNODES > 1 - if (unlikely(__memcg_event_check(mem, - MEM_CGROUP_TARGET_NUMAINFO))) { - atomic_inc(&mem->numainfo_events); - __mem_cgroup_target_update(mem, - MEM_CGROUP_TARGET_NUMAINFO); + MEM_CGROUP_TARGET_SOFTLIMIT); } -#endif } } @@ -1134,6 +1128,7 @@ unsigned long mem_cgroup_zone_nr_lru_pages(struct mem_cgroup *memcg, return MEM_CGROUP_ZSTAT(mz, lru); } +#ifdef CONFIG_NUMA static unsigned long mem_cgroup_node_nr_file_lru_pages(struct mem_cgroup *memcg, int nid) { @@ -1145,17 +1140,6 @@ static unsigned long mem_cgroup_node_nr_file_lru_pages(struct mem_cgroup *memcg, return ret; } -static unsigned long mem_cgroup_node_nr_anon_lru_pages(struct mem_cgroup *memcg, - int nid) -{ - unsigned long ret; - - ret = mem_cgroup_get_zonestat_node(memcg, nid, LRU_INACTIVE_ANON) + - mem_cgroup_get_zonestat_node(memcg, nid, LRU_ACTIVE_ANON); - return ret; -} - -#if MAX_NUMNODES > 1 static unsigned long mem_cgroup_nr_file_lru_pages(struct mem_cgroup *memcg) { u64 total = 0; @@ -1167,6 +1151,17 @@ static unsigned long mem_cgroup_nr_file_lru_pages(struct mem_cgroup *memcg) return total; } +static unsigned long mem_cgroup_node_nr_anon_lru_pages(struct mem_cgroup *memcg, + int nid) +{ + unsigned long ret; + + ret = mem_cgroup_get_zonestat_node(memcg, nid, LRU_INACTIVE_ANON) + + mem_cgroup_get_zonestat_node(memcg, nid, LRU_ACTIVE_ANON); + + return ret; +} + static unsigned long mem_cgroup_nr_anon_lru_pages(struct mem_cgroup *memcg) { u64 total = 0; @@ -1563,28 +1558,6 @@ mem_cgroup_select_victim(struct mem_cgroup *root_mem) return ret; } -/** - * test_mem_cgroup_node_reclaimable - * @mem: the target memcg - * @nid: the node ID to be checked. - * @noswap : specify true here if the user wants flle only information. - * - * This function returns whether the specified memcg contains any - * reclaimable pages on a node. Returns true if there are any reclaimable - * pages in the node. - */ -static bool test_mem_cgroup_node_reclaimable(struct mem_cgroup *mem, - int nid, bool noswap) -{ - if (mem_cgroup_node_nr_file_lru_pages(mem, nid)) - return true; - if (noswap || !total_swap_pages) - return false; - if (mem_cgroup_node_nr_anon_lru_pages(mem, nid)) - return true; - return false; - -} #if MAX_NUMNODES > 1 /* @@ -1596,26 +1569,26 @@ static bool test_mem_cgroup_node_reclaimable(struct mem_cgroup *mem, static void mem_cgroup_may_update_nodemask(struct mem_cgroup *mem) { int nid; - /* - * numainfo_events > 0 means there was at least NUMAINFO_EVENTS_TARGET - * pagein/pageout changes since the last update. - */ - if (!atomic_read(&mem->numainfo_events)) - return; - if (atomic_inc_return(&mem->numainfo_updating) > 1) + + if (time_after(mem->next_scan_node_update, jiffies)) return; + mem->next_scan_node_update = jiffies + 10*HZ; /* make a nodemask where this memcg uses memory from */ mem->scan_nodes = node_states[N_HIGH_MEMORY]; for_each_node_mask(nid, node_states[N_HIGH_MEMORY]) { - if (!test_mem_cgroup_node_reclaimable(mem, nid, false)) - node_clear(nid, mem->scan_nodes); - } + if (mem_cgroup_get_zonestat_node(mem, nid, LRU_INACTIVE_FILE) || + mem_cgroup_get_zonestat_node(mem, nid, LRU_ACTIVE_FILE)) + continue; - atomic_set(&mem->numainfo_events, 0); - atomic_set(&mem->numainfo_updating, 0); + if (total_swap_pages && + (mem_cgroup_get_zonestat_node(mem, nid, LRU_INACTIVE_ANON) || + mem_cgroup_get_zonestat_node(mem, nid, LRU_ACTIVE_ANON))) + continue; + node_clear(nid, mem->scan_nodes); + } } /* @@ -1653,51 +1626,11 @@ int mem_cgroup_select_victim_node(struct mem_cgroup *mem) return node; } -/* - * Check all nodes whether it contains reclaimable pages or not. - * For quick scan, we make use of scan_nodes. This will allow us to skip - * unused nodes. But scan_nodes is lazily updated and may not cotain - * enough new information. We need to do double check. - */ -bool mem_cgroup_reclaimable(struct mem_cgroup *mem, bool noswap) -{ - int nid; - - /* - * quick check...making use of scan_node. - * We can skip unused nodes. - */ - if (!nodes_empty(mem->scan_nodes)) { - for (nid = first_node(mem->scan_nodes); - nid < MAX_NUMNODES; - nid = next_node(nid, mem->scan_nodes)) { - - if (test_mem_cgroup_node_reclaimable(mem, nid, noswap)) - return true; - } - } - /* - * Check rest of nodes. - */ - for_each_node_state(nid, N_HIGH_MEMORY) { - if (node_isset(nid, mem->scan_nodes)) - continue; - if (test_mem_cgroup_node_reclaimable(mem, nid, noswap)) - return true; - } - return false; -} - #else int mem_cgroup_select_victim_node(struct mem_cgroup *mem) { return 0; } - -bool mem_cgroup_reclaimable(struct mem_cgroup *mem, bool noswap) -{ - return test_mem_cgroup_node_reclaimable(mem, 0, noswap); -} #endif /* @@ -1768,7 +1701,7 @@ static int mem_cgroup_hierarchical_reclaim(struct mem_cgroup *root_mem, } } } - if (!mem_cgroup_reclaimable(victim, noswap)) { + if (!mem_cgroup_local_usage(victim)) { /* this cgroup's local usage == 0 */ css_put(&victim->css); continue; diff --git a/trunk/mm/memory-failure.c b/trunk/mm/memory-failure.c index 740c4f52059c..eac0ba561491 100644 --- a/trunk/mm/memory-failure.c +++ b/trunk/mm/memory-failure.c @@ -391,11 +391,10 @@ static void collect_procs_anon(struct page *page, struct list_head *to_kill, struct task_struct *tsk; struct anon_vma *av; + read_lock(&tasklist_lock); av = page_lock_anon_vma(page); if (av == NULL) /* Not actually mapped anymore */ - return; - - read_lock(&tasklist_lock); + goto out; for_each_process (tsk) { struct anon_vma_chain *vmac; @@ -409,8 +408,9 @@ static void collect_procs_anon(struct page *page, struct list_head *to_kill, add_to_kill(tsk, page, vma, to_kill, tkc); } } - read_unlock(&tasklist_lock); page_unlock_anon_vma(av); +out: + read_unlock(&tasklist_lock); } /* @@ -424,8 +424,17 @@ static void collect_procs_file(struct page *page, struct list_head *to_kill, struct prio_tree_iter iter; struct address_space *mapping = page->mapping; - mutex_lock(&mapping->i_mmap_mutex); + /* + * A note on the locking order between the two locks. + * We don't rely on this particular order. + * If you have some other code that needs a different order + * feel free to switch them around. Or add a reverse link + * from mm_struct to task_struct, then this could be all + * done without taking tasklist_lock and looping over all tasks. + */ + read_lock(&tasklist_lock); + mutex_lock(&mapping->i_mmap_mutex); for_each_process(tsk) { pgoff_t pgoff = page->index << (PAGE_CACHE_SHIFT - PAGE_SHIFT); @@ -445,8 +454,8 @@ static void collect_procs_file(struct page *page, struct list_head *to_kill, add_to_kill(tsk, page, vma, to_kill, tkc); } } - read_unlock(&tasklist_lock); mutex_unlock(&mapping->i_mmap_mutex); + read_unlock(&tasklist_lock); } /* diff --git a/trunk/mm/memory.c b/trunk/mm/memory.c index 9b8a01d941cb..87d935333f0d 100644 --- a/trunk/mm/memory.c +++ b/trunk/mm/memory.c @@ -305,7 +305,6 @@ int __tlb_remove_page(struct mmu_gather *tlb, struct page *page) if (batch->nr == batch->max) { if (!tlb_next_batch(tlb)) return 0; - batch = tlb->active; } VM_BUG_ON(batch->nr > batch->max); @@ -2799,6 +2798,30 @@ void unmap_mapping_range(struct address_space *mapping, } EXPORT_SYMBOL(unmap_mapping_range); +int vmtruncate_range(struct inode *inode, loff_t offset, loff_t end) +{ + struct address_space *mapping = inode->i_mapping; + + /* + * If the underlying filesystem is not going to provide + * a way to truncate a range of blocks (punch a hole) - + * we should return failure right now. + */ + if (!inode->i_op->truncate_range) + return -ENOSYS; + + mutex_lock(&inode->i_mutex); + down_write(&inode->i_alloc_sem); + unmap_mapping_range(mapping, offset, (end - offset), 1); + truncate_inode_pages_range(mapping, offset, end); + unmap_mapping_range(mapping, offset, (end - offset), 1); + inode->i_op->truncate_range(inode, offset, end); + up_write(&inode->i_alloc_sem); + mutex_unlock(&inode->i_mutex); + + return 0; +} + /* * We enter with non-exclusive mmap_sem (to exclude vma changes, * but allow concurrent faults), and pte mapped but not yet locked. diff --git a/trunk/mm/memory_hotplug.c b/trunk/mm/memory_hotplug.c index c46887b5a11e..02159c755136 100644 --- a/trunk/mm/memory_hotplug.c +++ b/trunk/mm/memory_hotplug.c @@ -498,9 +498,7 @@ static pg_data_t __ref *hotadd_new_pgdat(int nid, u64 start) * The node we allocated has no zone fallback lists. For avoiding * to access not-initialized zonelist, build here. */ - mutex_lock(&zonelists_mutex); build_all_zonelists(NULL); - mutex_unlock(&zonelists_mutex); return pgdat; } @@ -523,7 +521,7 @@ int mem_online_node(int nid) lock_memory_hotplug(); pgdat = hotadd_new_pgdat(nid, 0); - if (!pgdat) { + if (pgdat) { ret = -ENOMEM; goto out; } diff --git a/trunk/mm/nommu.c b/trunk/mm/nommu.c index 9edc897a3970..1fd0c51b10a6 100644 --- a/trunk/mm/nommu.c +++ b/trunk/mm/nommu.c @@ -1813,13 +1813,10 @@ struct page *follow_page(struct vm_area_struct *vma, unsigned long address, return NULL; } -int remap_pfn_range(struct vm_area_struct *vma, unsigned long addr, - unsigned long pfn, unsigned long size, pgprot_t prot) +int remap_pfn_range(struct vm_area_struct *vma, unsigned long from, + unsigned long to, unsigned long size, pgprot_t prot) { - if (addr != (pfn << PAGE_SHIFT)) - return -EINVAL; - - vma->vm_flags |= VM_IO | VM_RESERVED | VM_PFNMAP; + vma->vm_start = vma->vm_pgoff << PAGE_SHIFT; return 0; } EXPORT_SYMBOL(remap_pfn_range); diff --git a/trunk/mm/rmap.c b/trunk/mm/rmap.c index 23295f65ae43..27dfd3b82b0f 100644 --- a/trunk/mm/rmap.c +++ b/trunk/mm/rmap.c @@ -38,8 +38,9 @@ * in arch-dependent flush_dcache_mmap_lock, * within inode_wb_list_lock in __sync_single_inode) * - * anon_vma->mutex,mapping->i_mutex (memory_failure, collect_procs_anon) - * ->tasklist_lock + * (code doesn't rely on that order so it could be switched around) + * ->tasklist_lock + * anon_vma->mutex (memory_failure, collect_procs_anon) * pte map lock */ diff --git a/trunk/mm/shmem.c b/trunk/mm/shmem.c index fcedf5464eb7..d221a1cfd7b1 100644 --- a/trunk/mm/shmem.c +++ b/trunk/mm/shmem.c @@ -539,7 +539,7 @@ static void shmem_free_pages(struct list_head *next) } while (next); } -void shmem_truncate_range(struct inode *inode, loff_t start, loff_t end) +static void shmem_truncate_range(struct inode *inode, loff_t start, loff_t end) { struct shmem_inode_info *info = SHMEM_I(inode); unsigned long idx; @@ -562,8 +562,6 @@ void shmem_truncate_range(struct inode *inode, loff_t start, loff_t end) spinlock_t *punch_lock; unsigned long upper_limit; - truncate_inode_pages_range(inode->i_mapping, start, end); - inode->i_ctime = inode->i_mtime = CURRENT_TIME; idx = (start + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT; if (idx >= info->next_index) @@ -740,8 +738,16 @@ void shmem_truncate_range(struct inode *inode, loff_t start, loff_t end) * lowered next_index. Also, though shmem_getpage checks * i_size before adding to cache, no recheck after: so fix the * narrow window there too. + * + * Recalling truncate_inode_pages_range and unmap_mapping_range + * every time for punch_hole (which never got a chance to clear + * SHMEM_PAGEIN at the start of vmtruncate_range) is expensive, + * yet hardly ever necessary: try to optimize them out later. */ truncate_inode_pages_range(inode->i_mapping, start, end); + if (punch_hole) + unmap_mapping_range(inode->i_mapping, start, + end - start, 1); } spin_lock(&info->lock); @@ -760,23 +766,22 @@ void shmem_truncate_range(struct inode *inode, loff_t start, loff_t end) shmem_free_pages(pages_to_free.next); } } -EXPORT_SYMBOL_GPL(shmem_truncate_range); -static int shmem_setattr(struct dentry *dentry, struct iattr *attr) +static int shmem_notify_change(struct dentry *dentry, struct iattr *attr) { struct inode *inode = dentry->d_inode; + loff_t newsize = attr->ia_size; int error; error = inode_change_ok(inode, attr); if (error) return error; - if (S_ISREG(inode->i_mode) && (attr->ia_valid & ATTR_SIZE)) { - loff_t oldsize = inode->i_size; - loff_t newsize = attr->ia_size; + if (S_ISREG(inode->i_mode) && (attr->ia_valid & ATTR_SIZE) + && newsize != inode->i_size) { struct page *page = NULL; - if (newsize < oldsize) { + if (newsize < inode->i_size) { /* * If truncating down to a partial page, then * if that page is already allocated, hold it @@ -805,19 +810,12 @@ static int shmem_setattr(struct dentry *dentry, struct iattr *attr) spin_unlock(&info->lock); } } - if (newsize != oldsize) { - i_size_write(inode, newsize); - inode->i_ctime = inode->i_mtime = CURRENT_TIME; - } - if (newsize < oldsize) { - loff_t holebegin = round_up(newsize, PAGE_SIZE); - unmap_mapping_range(inode->i_mapping, holebegin, 0, 1); - shmem_truncate_range(inode, newsize, (loff_t)-1); - /* unmap again to remove racily COWed private pages */ - unmap_mapping_range(inode->i_mapping, holebegin, 0, 1); - } + + /* XXX(truncate): truncate_setsize should be called last */ + truncate_setsize(inode, newsize); if (page) page_cache_release(page); + shmem_truncate_range(inode, newsize, (loff_t)-1); } setattr_copy(inode, attr); @@ -834,6 +832,7 @@ static void shmem_evict_inode(struct inode *inode) struct shmem_xattr *xattr, *nxattr; if (inode->i_mapping->a_ops == &shmem_aops) { + truncate_inode_pages(inode->i_mapping, 0); shmem_unacct_size(info->flags, inode->i_size); inode->i_size = 0; shmem_truncate_range(inode, 0, (loff_t)-1); @@ -2707,7 +2706,7 @@ static const struct file_operations shmem_file_operations = { }; static const struct inode_operations shmem_inode_operations = { - .setattr = shmem_setattr, + .setattr = shmem_notify_change, .truncate_range = shmem_truncate_range, #ifdef CONFIG_TMPFS_XATTR .setxattr = shmem_setxattr, @@ -2740,7 +2739,7 @@ static const struct inode_operations shmem_dir_inode_operations = { .removexattr = shmem_removexattr, #endif #ifdef CONFIG_TMPFS_POSIX_ACL - .setattr = shmem_setattr, + .setattr = shmem_notify_change, .check_acl = generic_check_acl, #endif }; @@ -2753,7 +2752,7 @@ static const struct inode_operations shmem_special_inode_operations = { .removexattr = shmem_removexattr, #endif #ifdef CONFIG_TMPFS_POSIX_ACL - .setattr = shmem_setattr, + .setattr = shmem_notify_change, .check_acl = generic_check_acl, #endif }; @@ -2909,12 +2908,6 @@ int shmem_lock(struct file *file, int lock, struct user_struct *user) return 0; } -void shmem_truncate_range(struct inode *inode, loff_t start, loff_t end) -{ - truncate_inode_pages_range(inode->i_mapping, start, end); -} -EXPORT_SYMBOL_GPL(shmem_truncate_range); - #ifdef CONFIG_CGROUP_MEM_RES_CTLR /** * mem_cgroup_get_shmem_target - find a page or entry assigned to the shmem file @@ -3035,26 +3028,3 @@ int shmem_zero_setup(struct vm_area_struct *vma) vma->vm_flags |= VM_CAN_NONLINEAR; return 0; } - -/** - * shmem_read_mapping_page_gfp - read into page cache, using specified page allocation flags. - * @mapping: the page's address_space - * @index: the page index - * @gfp: the page allocator flags to use if allocating - * - * This behaves as a tmpfs "read_cache_page_gfp(mapping, index, gfp)", - * with any new page allocations done using the specified allocation flags. - * But read_cache_page_gfp() uses the ->readpage() method: which does not - * suit tmpfs, since it may have pages in swapcache, and needs to find those - * for itself; although drivers/gpu/drm i915 and ttm rely upon this support. - * - * Provide a stub for those callers to start using now, then later - * flesh it out to call shmem_getpage() with additional gfp mask, when - * shmem_file_splice_read() is added and shmem_readpage() is removed. - */ -struct page *shmem_read_mapping_page_gfp(struct address_space *mapping, - pgoff_t index, gfp_t gfp) -{ - return read_cache_page_gfp(mapping, index, gfp); -} -EXPORT_SYMBOL_GPL(shmem_read_mapping_page_gfp); diff --git a/trunk/mm/swapfile.c b/trunk/mm/swapfile.c index ff8dc1a18cb4..d537d29e9b7b 100644 --- a/trunk/mm/swapfile.c +++ b/trunk/mm/swapfile.c @@ -14,7 +14,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/trunk/mm/truncate.c b/trunk/mm/truncate.c index e13f22efaad7..3a29a6180212 100644 --- a/trunk/mm/truncate.c +++ b/trunk/mm/truncate.c @@ -304,11 +304,6 @@ EXPORT_SYMBOL(truncate_inode_pages_range); * @lstart: offset from which to truncate * * Called under (and serialised by) inode->i_mutex. - * - * Note: When this function returns, there can be a page in the process of - * deletion (inside __delete_from_page_cache()) in the specified range. Thus - * mapping->nrpages can be non-zero when this function returns even after - * truncation of the whole mapping. */ void truncate_inode_pages(struct address_space *mapping, loff_t lstart) { @@ -608,27 +603,3 @@ int vmtruncate(struct inode *inode, loff_t offset) return 0; } EXPORT_SYMBOL(vmtruncate); - -int vmtruncate_range(struct inode *inode, loff_t offset, loff_t end) -{ - struct address_space *mapping = inode->i_mapping; - - /* - * If the underlying filesystem is not going to provide - * a way to truncate a range of blocks (punch a hole) - - * we should return failure right now. - */ - if (!inode->i_op->truncate_range) - return -ENOSYS; - - mutex_lock(&inode->i_mutex); - down_write(&inode->i_alloc_sem); - unmap_mapping_range(mapping, offset, (end - offset), 1); - inode->i_op->truncate_range(inode, offset, end); - /* unmap again to remove racily COWed private pages */ - unmap_mapping_range(mapping, offset, (end - offset), 1); - up_write(&inode->i_alloc_sem); - mutex_unlock(&inode->i_mutex); - - return 0; -} diff --git a/trunk/mm/vmscan.c b/trunk/mm/vmscan.c index 5ed24b94c5e6..8ff834e19c24 100644 --- a/trunk/mm/vmscan.c +++ b/trunk/mm/vmscan.c @@ -1995,13 +1995,14 @@ static void shrink_zone(int priority, struct zone *zone, * If a zone is deemed to be full of pinned pages then just give it a light * scan then give up on it. */ -static void shrink_zones(int priority, struct zonelist *zonelist, +static unsigned long shrink_zones(int priority, struct zonelist *zonelist, struct scan_control *sc) { struct zoneref *z; struct zone *zone; unsigned long nr_soft_reclaimed; unsigned long nr_soft_scanned; + unsigned long total_scanned = 0; for_each_zone_zonelist_nodemask(zone, z, zonelist, gfp_zone(sc->gfp_mask), sc->nodemask) { @@ -2016,23 +2017,19 @@ static void shrink_zones(int priority, struct zonelist *zonelist, continue; if (zone->all_unreclaimable && priority != DEF_PRIORITY) continue; /* Let kswapd poll it */ - /* - * This steals pages from memory cgroups over softlimit - * and returns the number of reclaimed pages and - * scanned pages. This works for global memory pressure - * and balancing, not for a memcg's limit. - */ - nr_soft_scanned = 0; - nr_soft_reclaimed = mem_cgroup_soft_limit_reclaim(zone, - sc->order, sc->gfp_mask, - &nr_soft_scanned); - sc->nr_reclaimed += nr_soft_reclaimed; - sc->nr_scanned += nr_soft_scanned; - /* need some check for avoid more shrink_zone() */ } + nr_soft_scanned = 0; + nr_soft_reclaimed = mem_cgroup_soft_limit_reclaim(zone, + sc->order, sc->gfp_mask, + &nr_soft_scanned); + sc->nr_reclaimed += nr_soft_reclaimed; + total_scanned += nr_soft_scanned; + shrink_zone(priority, zone, sc); } + + return total_scanned; } static bool zone_reclaimable(struct zone *zone) @@ -2097,7 +2094,7 @@ static unsigned long do_try_to_free_pages(struct zonelist *zonelist, sc->nr_scanned = 0; if (!priority) disable_swap_token(sc->mem_cgroup); - shrink_zones(priority, zonelist, sc); + total_scanned += shrink_zones(priority, zonelist, sc); /* * Don't shrink slabs when reclaiming memory from * over limit cgroups @@ -2326,7 +2323,7 @@ static bool sleeping_prematurely(pg_data_t *pgdat, int order, long remaining, return true; /* Check the watermark levels */ - for (i = 0; i <= classzone_idx; i++) { + for (i = 0; i < pgdat->nr_zones; i++) { struct zone *zone = pgdat->node_zones + i; if (!populated_zone(zone)) @@ -2344,7 +2341,7 @@ static bool sleeping_prematurely(pg_data_t *pgdat, int order, long remaining, } if (!zone_watermark_ok_safe(zone, order, high_wmark_pages(zone), - i, 0)) + classzone_idx, 0)) all_zones_ok = false; else balanced += zone->present_pages; @@ -2451,6 +2448,7 @@ static unsigned long balance_pgdat(pg_data_t *pgdat, int order, if (!zone_watermark_ok_safe(zone, order, high_wmark_pages(zone), 0, 0)) { end_zone = i; + *classzone_idx = i; break; } } @@ -2509,18 +2507,18 @@ static unsigned long balance_pgdat(pg_data_t *pgdat, int order, KSWAPD_ZONE_BALANCE_GAP_RATIO); if (!zone_watermark_ok_safe(zone, order, high_wmark_pages(zone) + balance_gap, - end_zone, 0)) { + end_zone, 0)) shrink_zone(priority, zone, &sc); + reclaim_state->reclaimed_slab = 0; + nr_slab = shrink_slab(&shrink, sc.nr_scanned, lru_pages); + sc.nr_reclaimed += reclaim_state->reclaimed_slab; + total_scanned += sc.nr_scanned; - reclaim_state->reclaimed_slab = 0; - nr_slab = shrink_slab(&shrink, sc.nr_scanned, lru_pages); - sc.nr_reclaimed += reclaim_state->reclaimed_slab; - total_scanned += sc.nr_scanned; - - if (nr_slab == 0 && !zone_reclaimable(zone)) - zone->all_unreclaimable = 1; - } - + if (zone->all_unreclaimable) + continue; + if (nr_slab == 0 && + !zone_reclaimable(zone)) + zone->all_unreclaimable = 1; /* * If we've done a decent amount of scanning and * the reclaim ratio is low, start doing writepage @@ -2530,12 +2528,6 @@ static unsigned long balance_pgdat(pg_data_t *pgdat, int order, total_scanned > sc.nr_reclaimed + sc.nr_reclaimed / 2) sc.may_writepage = 1; - if (zone->all_unreclaimable) { - if (end_zone && end_zone == i) - end_zone--; - continue; - } - if (!zone_watermark_ok_safe(zone, order, high_wmark_pages(zone), end_zone, 0)) { all_zones_ok = 0; @@ -2714,8 +2706,8 @@ static void kswapd_try_to_sleep(pg_data_t *pgdat, int order, int classzone_idx) */ static int kswapd(void *p) { - unsigned long order, new_order; - int classzone_idx, new_classzone_idx; + unsigned long order; + int classzone_idx; pg_data_t *pgdat = (pg_data_t*)p; struct task_struct *tsk = current; @@ -2745,23 +2737,17 @@ static int kswapd(void *p) tsk->flags |= PF_MEMALLOC | PF_SWAPWRITE | PF_KSWAPD; set_freezable(); - order = new_order = 0; - classzone_idx = new_classzone_idx = pgdat->nr_zones - 1; + order = 0; + classzone_idx = MAX_NR_ZONES - 1; for ( ; ; ) { + unsigned long new_order; + int new_classzone_idx; int ret; - /* - * If the last balance_pgdat was unsuccessful it's unlikely a - * new request of a similar or harder type will succeed soon - * so consider going to sleep on the basis we reclaimed at - */ - if (classzone_idx >= new_classzone_idx && order == new_order) { - new_order = pgdat->kswapd_max_order; - new_classzone_idx = pgdat->classzone_idx; - pgdat->kswapd_max_order = 0; - pgdat->classzone_idx = pgdat->nr_zones - 1; - } - + new_order = pgdat->kswapd_max_order; + new_classzone_idx = pgdat->classzone_idx; + pgdat->kswapd_max_order = 0; + pgdat->classzone_idx = MAX_NR_ZONES - 1; if (order < new_order || classzone_idx > new_classzone_idx) { /* * Don't sleep if someone wants a larger 'order' @@ -2774,7 +2760,7 @@ static int kswapd(void *p) order = pgdat->kswapd_max_order; classzone_idx = pgdat->classzone_idx; pgdat->kswapd_max_order = 0; - pgdat->classzone_idx = pgdat->nr_zones - 1; + pgdat->classzone_idx = MAX_NR_ZONES - 1; } ret = try_to_freeze(); diff --git a/trunk/net/8021q/vlan_dev.c b/trunk/net/8021q/vlan_dev.c index d8f45ba718b5..1c9aa8c6a77d 100644 --- a/trunk/net/8021q/vlan_dev.c +++ b/trunk/net/8021q/vlan_dev.c @@ -588,14 +588,9 @@ static void vlan_dev_uninit(struct net_device *dev) static u32 vlan_dev_fix_features(struct net_device *dev, u32 features) { struct net_device *real_dev = vlan_dev_info(dev)->real_dev; - u32 old_features = features; features &= real_dev->features; features &= real_dev->vlan_features; - - if (old_features & NETIF_F_SOFT_FEATURES) - features |= old_features & NETIF_F_SOFT_FEATURES; - if (dev_ethtool_get_rx_csum(real_dev)) features |= NETIF_F_RXCSUM; features |= NETIF_F_LLTX; diff --git a/trunk/net/Kconfig b/trunk/net/Kconfig index a07314844238..878151c772c9 100644 --- a/trunk/net/Kconfig +++ b/trunk/net/Kconfig @@ -322,7 +322,6 @@ source "net/rfkill/Kconfig" source "net/9p/Kconfig" source "net/caif/Kconfig" source "net/ceph/Kconfig" -source "net/nfc/Kconfig" endif # if NET diff --git a/trunk/net/Makefile b/trunk/net/Makefile index acdde4950de4..a51d9465e628 100644 --- a/trunk/net/Makefile +++ b/trunk/net/Makefile @@ -68,4 +68,3 @@ obj-$(CONFIG_WIMAX) += wimax/ obj-$(CONFIG_DNS_RESOLVER) += dns_resolver/ obj-$(CONFIG_CEPH_LIB) += ceph/ obj-$(CONFIG_BATMAN_ADV) += batman-adv/ -obj-$(CONFIG_NFC) += nfc/ diff --git a/trunk/net/TUNABLE b/trunk/net/TUNABLE new file mode 100644 index 000000000000..9913211f07a7 --- /dev/null +++ b/trunk/net/TUNABLE @@ -0,0 +1,50 @@ +The following parameters should be tunable at compile time. Some of them +exist as sysctls too. + +This is far from complete + +Item Description +---------------------------------------------------------------------------- +MAX_LINKS Maximum number of netlink minor devices. (1-32) +RIF_TABLE_SIZE Token ring RIF cache size (tunable) +AARP_HASH_SIZE Size of Appletalk hash table (tunable) +AX25_DEF_T1 AX.25 parameters. These are all tunable via +AX25_DEF_T2 SIOCAX25SETPARMS +AX25_DEF_T3 T1-T3,N2 have the meanings in the specification +AX25_DEF_N2 +AX25_DEF_AXDEFMODE 8 = normal 128 is PE1CHL extended +AX25_DEF_IPDEFMODE 'D' - datagram 'V' - virtual connection +AX25_DEF_BACKOFF 'E'xponential 'L'inear +AX25_DEF_NETROM Allow netrom 1=Y +AX25_DF_TEXT Allow PID=Text 1=Y +AX25_DEF_WINDOW Window for normal mode +AX25_DEF_EWINDOW Window for PE1CHL mode +AX25_DEF_DIGI 1 for inband 2 for cross band 3 for both +AX25_DEF_CONMODE Allow connected modes 1=Yes +AX25_ROUTE_MAX AX.25 route cache size - no currently tunable +Unnamed (16) Number of protocol hash slots (tunable) +DEV_NUMBUFFS Number of priority levels (not easily tunable) +Unnamed (300) Maximum packet backlog queue (tunable) +MAX_IOVEC Maximum number of iovecs in a message (tunable) +MIN_WINDOW Offered minimum window (tunable) +MAX_WINDOW Offered maximum window (tunable) +MAX_HEADER Largest physical header (tunable) +MAX_ADDR_LEN Largest physical address (tunable) +SOCK_ARRAY_SIZE IP socket array hash size (tunable) +IP_MAX_MEMBERSHIPS Largest number of groups per socket (BSD style) (tunable) +16 Hard coded constant for amount of room allowed for + cache align and faster forwarding (tunable) +IP_FRAG_TIME Time we hold a fragment for. (tunable) +PORT_MASQ_BEGIN First port reserved for masquerade (tunable) +PORT_MASQ_END Last port used for masquerade (tunable) +MASQUERADE_EXPIRE_TCP_FIN Time we keep a masquerade for after a FIN +MASQUERADE_EXPIRE_UDP Time we keep a UDP masquerade for (tunable) +MAXVIFS Maximum mrouted vifs (1-32) +MFC_LINES Lines in the multicast router cache (tunable) + +NetROM parameters are tunable via an ioctl passing a struct + +4000 Size a Unix domain socket malloc falls back to + (tunable) should be 8K - a bit for 8K machines like + the ALPHA + diff --git a/trunk/net/appletalk/aarp.c b/trunk/net/appletalk/aarp.c index 1acc69576df8..50dce7981321 100644 --- a/trunk/net/appletalk/aarp.c +++ b/trunk/net/appletalk/aarp.c @@ -779,87 +779,87 @@ static int aarp_rcv(struct sk_buff *skb, struct net_device *dev, } switch (function) { - case AARP_REPLY: - if (!unresolved_count) /* Speed up */ - break; - - /* Find the entry. */ - a = __aarp_find_entry(unresolved[hash], dev, &sa); - if (!a || dev != a->dev) - break; - - /* We can fill one in - this is good. */ - memcpy(a->hwaddr, ea->hw_src, ETH_ALEN); - __aarp_resolved(&unresolved[hash], a, hash); - if (!unresolved_count) - mod_timer(&aarp_timer, - jiffies + sysctl_aarp_expiry_time); - break; + case AARP_REPLY: + if (!unresolved_count) /* Speed up */ + break; - case AARP_REQUEST: - case AARP_PROBE: + /* Find the entry. */ + a = __aarp_find_entry(unresolved[hash], dev, &sa); + if (!a || dev != a->dev) + break; - /* - * If it is my address set ma to my address and reply. - * We can treat probe and request the same. Probe - * simply means we shouldn't cache the querying host, - * as in a probe they are proposing an address not - * using one. - * - * Support for proxy-AARP added. We check if the - * address is one of our proxies before we toss the - * packet out. - */ + /* We can fill one in - this is good. */ + memcpy(a->hwaddr, ea->hw_src, ETH_ALEN); + __aarp_resolved(&unresolved[hash], a, hash); + if (!unresolved_count) + mod_timer(&aarp_timer, + jiffies + sysctl_aarp_expiry_time); + break; - sa.s_node = ea->pa_dst_node; - sa.s_net = ea->pa_dst_net; - - /* See if we have a matching proxy. */ - ma = __aarp_proxy_find(dev, &sa); - if (!ma) - ma = &ifa->address; - else { /* We need to make a copy of the entry. */ - da.s_node = sa.s_node; - da.s_net = sa.s_net; - ma = &da; - } + case AARP_REQUEST: + case AARP_PROBE: - if (function == AARP_PROBE) { /* - * A probe implies someone trying to get an - * address. So as a precaution flush any - * entries we have for this address. + * If it is my address set ma to my address and reply. + * We can treat probe and request the same. Probe + * simply means we shouldn't cache the querying host, + * as in a probe they are proposing an address not + * using one. + * + * Support for proxy-AARP added. We check if the + * address is one of our proxies before we toss the + * packet out. */ - a = __aarp_find_entry(resolved[sa.s_node % - (AARP_HASH_SIZE - 1)], - skb->dev, &sa); - /* - * Make it expire next tick - that avoids us - * getting into a probe/flush/learn/probe/ - * flush/learn cycle during probing of a slow - * to respond host addr. - */ - if (a) { - a->expires_at = jiffies - 1; - mod_timer(&aarp_timer, jiffies + - sysctl_aarp_tick_time); + sa.s_node = ea->pa_dst_node; + sa.s_net = ea->pa_dst_net; + + /* See if we have a matching proxy. */ + ma = __aarp_proxy_find(dev, &sa); + if (!ma) + ma = &ifa->address; + else { /* We need to make a copy of the entry. */ + da.s_node = sa.s_node; + da.s_net = sa.s_net; + ma = &da; } - } - if (sa.s_node != ma->s_node) - break; + if (function == AARP_PROBE) { + /* + * A probe implies someone trying to get an + * address. So as a precaution flush any + * entries we have for this address. + */ + a = __aarp_find_entry(resolved[sa.s_node % + (AARP_HASH_SIZE - 1)], + skb->dev, &sa); + + /* + * Make it expire next tick - that avoids us + * getting into a probe/flush/learn/probe/ + * flush/learn cycle during probing of a slow + * to respond host addr. + */ + if (a) { + a->expires_at = jiffies - 1; + mod_timer(&aarp_timer, jiffies + + sysctl_aarp_tick_time); + } + } - if (sa.s_net && ma->s_net && sa.s_net != ma->s_net) - break; + if (sa.s_node != ma->s_node) + break; - sa.s_node = ea->pa_src_node; - sa.s_net = ea->pa_src_net; + if (sa.s_net && ma->s_net && sa.s_net != ma->s_net) + break; - /* aarp_my_address has found the address to use for us. - */ - aarp_send_reply(dev, ma, &sa, ea->hw_src); - break; + sa.s_node = ea->pa_src_node; + sa.s_net = ea->pa_src_net; + + /* aarp_my_address has found the address to use for us. + */ + aarp_send_reply(dev, ma, &sa, ea->hw_src); + break; } unlock: diff --git a/trunk/net/appletalk/ddp.c b/trunk/net/appletalk/ddp.c index b1fe7c35e8d1..956a5302002a 100644 --- a/trunk/net/appletalk/ddp.c +++ b/trunk/net/appletalk/ddp.c @@ -684,192 +684,192 @@ static int atif_ioctl(int cmd, void __user *arg) atif = atalk_find_dev(dev); switch (cmd) { - case SIOCSIFADDR: - if (!capable(CAP_NET_ADMIN)) - return -EPERM; - if (sa->sat_family != AF_APPLETALK) - return -EINVAL; - if (dev->type != ARPHRD_ETHER && - dev->type != ARPHRD_LOOPBACK && - dev->type != ARPHRD_LOCALTLK && - dev->type != ARPHRD_PPP) - return -EPROTONOSUPPORT; - - nr = (struct atalk_netrange *)&sa->sat_zero[0]; - add_route = 1; + case SIOCSIFADDR: + if (!capable(CAP_NET_ADMIN)) + return -EPERM; + if (sa->sat_family != AF_APPLETALK) + return -EINVAL; + if (dev->type != ARPHRD_ETHER && + dev->type != ARPHRD_LOOPBACK && + dev->type != ARPHRD_LOCALTLK && + dev->type != ARPHRD_PPP) + return -EPROTONOSUPPORT; - /* - * if this is a point-to-point iface, and we already - * have an iface for this AppleTalk address, then we - * should not add a route - */ - if ((dev->flags & IFF_POINTOPOINT) && - atalk_find_interface(sa->sat_addr.s_net, - sa->sat_addr.s_node)) { - printk(KERN_DEBUG "AppleTalk: point-to-point " - "interface added with " - "existing address\n"); - add_route = 0; - } + nr = (struct atalk_netrange *)&sa->sat_zero[0]; + add_route = 1; - /* - * Phase 1 is fine on LocalTalk but we don't do - * EtherTalk phase 1. Anyone wanting to add it go ahead. - */ - if (dev->type == ARPHRD_ETHER && nr->nr_phase != 2) - return -EPROTONOSUPPORT; - if (sa->sat_addr.s_node == ATADDR_BCAST || - sa->sat_addr.s_node == 254) - return -EINVAL; - if (atif) { - /* Already setting address */ - if (atif->status & ATIF_PROBE) - return -EBUSY; - - atif->address.s_net = sa->sat_addr.s_net; - atif->address.s_node = sa->sat_addr.s_node; - atrtr_device_down(dev); /* Flush old routes */ - } else { - atif = atif_add_device(dev, &sa->sat_addr); + /* + * if this is a point-to-point iface, and we already + * have an iface for this AppleTalk address, then we + * should not add a route + */ + if ((dev->flags & IFF_POINTOPOINT) && + atalk_find_interface(sa->sat_addr.s_net, + sa->sat_addr.s_node)) { + printk(KERN_DEBUG "AppleTalk: point-to-point " + "interface added with " + "existing address\n"); + add_route = 0; + } + + /* + * Phase 1 is fine on LocalTalk but we don't do + * EtherTalk phase 1. Anyone wanting to add it go ahead. + */ + if (dev->type == ARPHRD_ETHER && nr->nr_phase != 2) + return -EPROTONOSUPPORT; + if (sa->sat_addr.s_node == ATADDR_BCAST || + sa->sat_addr.s_node == 254) + return -EINVAL; + if (atif) { + /* Already setting address */ + if (atif->status & ATIF_PROBE) + return -EBUSY; + + atif->address.s_net = sa->sat_addr.s_net; + atif->address.s_node = sa->sat_addr.s_node; + atrtr_device_down(dev); /* Flush old routes */ + } else { + atif = atif_add_device(dev, &sa->sat_addr); + if (!atif) + return -ENOMEM; + } + atif->nets = *nr; + + /* + * Check if the chosen address is used. If so we + * error and atalkd will try another. + */ + + if (!(dev->flags & IFF_LOOPBACK) && + !(dev->flags & IFF_POINTOPOINT) && + atif_probe_device(atif) < 0) { + atif_drop_device(dev); + return -EADDRINUSE; + } + + /* Hey it worked - add the direct routes */ + sa = (struct sockaddr_at *)&rtdef.rt_gateway; + sa->sat_family = AF_APPLETALK; + sa->sat_addr.s_net = atif->address.s_net; + sa->sat_addr.s_node = atif->address.s_node; + sa = (struct sockaddr_at *)&rtdef.rt_dst; + rtdef.rt_flags = RTF_UP; + sa->sat_family = AF_APPLETALK; + sa->sat_addr.s_node = ATADDR_ANYNODE; + if (dev->flags & IFF_LOOPBACK || + dev->flags & IFF_POINTOPOINT) + rtdef.rt_flags |= RTF_HOST; + + /* Routerless initial state */ + if (nr->nr_firstnet == htons(0) && + nr->nr_lastnet == htons(0xFFFE)) { + sa->sat_addr.s_net = atif->address.s_net; + atrtr_create(&rtdef, dev); + atrtr_set_default(dev); + } else { + limit = ntohs(nr->nr_lastnet); + if (limit - ntohs(nr->nr_firstnet) > 4096) { + printk(KERN_WARNING "Too many routes/" + "iface.\n"); + return -EINVAL; + } + if (add_route) + for (ct = ntohs(nr->nr_firstnet); + ct <= limit; ct++) { + sa->sat_addr.s_net = htons(ct); + atrtr_create(&rtdef, dev); + } + } + dev_mc_add_global(dev, aarp_mcast); + return 0; + + case SIOCGIFADDR: if (!atif) - return -ENOMEM; - } - atif->nets = *nr; + return -EADDRNOTAVAIL; - /* - * Check if the chosen address is used. If so we - * error and atalkd will try another. - */ + sa->sat_family = AF_APPLETALK; + sa->sat_addr = atif->address; + break; - if (!(dev->flags & IFF_LOOPBACK) && - !(dev->flags & IFF_POINTOPOINT) && - atif_probe_device(atif) < 0) { - atif_drop_device(dev); - return -EADDRINUSE; - } + case SIOCGIFBRDADDR: + if (!atif) + return -EADDRNOTAVAIL; - /* Hey it worked - add the direct routes */ - sa = (struct sockaddr_at *)&rtdef.rt_gateway; - sa->sat_family = AF_APPLETALK; - sa->sat_addr.s_net = atif->address.s_net; - sa->sat_addr.s_node = atif->address.s_node; - sa = (struct sockaddr_at *)&rtdef.rt_dst; - rtdef.rt_flags = RTF_UP; - sa->sat_family = AF_APPLETALK; - sa->sat_addr.s_node = ATADDR_ANYNODE; - if (dev->flags & IFF_LOOPBACK || - dev->flags & IFF_POINTOPOINT) - rtdef.rt_flags |= RTF_HOST; - - /* Routerless initial state */ - if (nr->nr_firstnet == htons(0) && - nr->nr_lastnet == htons(0xFFFE)) { + sa->sat_family = AF_APPLETALK; sa->sat_addr.s_net = atif->address.s_net; - atrtr_create(&rtdef, dev); - atrtr_set_default(dev); - } else { - limit = ntohs(nr->nr_lastnet); - if (limit - ntohs(nr->nr_firstnet) > 4096) { - printk(KERN_WARNING "Too many routes/" - "iface.\n"); + sa->sat_addr.s_node = ATADDR_BCAST; + break; + + case SIOCATALKDIFADDR: + case SIOCDIFADDR: + if (!capable(CAP_NET_ADMIN)) + return -EPERM; + if (sa->sat_family != AF_APPLETALK) return -EINVAL; - } - if (add_route) - for (ct = ntohs(nr->nr_firstnet); - ct <= limit; ct++) { - sa->sat_addr.s_net = htons(ct); - atrtr_create(&rtdef, dev); - } - } - dev_mc_add_global(dev, aarp_mcast); - return 0; - - case SIOCGIFADDR: - if (!atif) - return -EADDRNOTAVAIL; - - sa->sat_family = AF_APPLETALK; - sa->sat_addr = atif->address; - break; - - case SIOCGIFBRDADDR: - if (!atif) - return -EADDRNOTAVAIL; - - sa->sat_family = AF_APPLETALK; - sa->sat_addr.s_net = atif->address.s_net; - sa->sat_addr.s_node = ATADDR_BCAST; - break; - - case SIOCATALKDIFADDR: - case SIOCDIFADDR: - if (!capable(CAP_NET_ADMIN)) - return -EPERM; - if (sa->sat_family != AF_APPLETALK) - return -EINVAL; - atalk_dev_down(dev); - break; + atalk_dev_down(dev); + break; - case SIOCSARP: - if (!capable(CAP_NET_ADMIN)) - return -EPERM; - if (sa->sat_family != AF_APPLETALK) - return -EINVAL; - /* - * for now, we only support proxy AARP on ELAP; - * we should be able to do it for LocalTalk, too. - */ - if (dev->type != ARPHRD_ETHER) - return -EPROTONOSUPPORT; + case SIOCSARP: + if (!capable(CAP_NET_ADMIN)) + return -EPERM; + if (sa->sat_family != AF_APPLETALK) + return -EINVAL; + /* + * for now, we only support proxy AARP on ELAP; + * we should be able to do it for LocalTalk, too. + */ + if (dev->type != ARPHRD_ETHER) + return -EPROTONOSUPPORT; - /* - * atif points to the current interface on this network; - * we aren't concerned about its current status (at - * least for now), but it has all the settings about - * the network we're going to probe. Consequently, it - * must exist. - */ - if (!atif) - return -EADDRNOTAVAIL; + /* + * atif points to the current interface on this network; + * we aren't concerned about its current status (at + * least for now), but it has all the settings about + * the network we're going to probe. Consequently, it + * must exist. + */ + if (!atif) + return -EADDRNOTAVAIL; - nr = (struct atalk_netrange *)&(atif->nets); - /* - * Phase 1 is fine on Localtalk but we don't do - * Ethertalk phase 1. Anyone wanting to add it go ahead. - */ - if (dev->type == ARPHRD_ETHER && nr->nr_phase != 2) - return -EPROTONOSUPPORT; + nr = (struct atalk_netrange *)&(atif->nets); + /* + * Phase 1 is fine on Localtalk but we don't do + * Ethertalk phase 1. Anyone wanting to add it go ahead. + */ + if (dev->type == ARPHRD_ETHER && nr->nr_phase != 2) + return -EPROTONOSUPPORT; - if (sa->sat_addr.s_node == ATADDR_BCAST || - sa->sat_addr.s_node == 254) - return -EINVAL; + if (sa->sat_addr.s_node == ATADDR_BCAST || + sa->sat_addr.s_node == 254) + return -EINVAL; - /* - * Check if the chosen address is used. If so we - * error and ATCP will try another. - */ - if (atif_proxy_probe_device(atif, &(sa->sat_addr)) < 0) - return -EADDRINUSE; + /* + * Check if the chosen address is used. If so we + * error and ATCP will try another. + */ + if (atif_proxy_probe_device(atif, &(sa->sat_addr)) < 0) + return -EADDRINUSE; - /* - * We now have an address on the local network, and - * the AARP code will defend it for us until we take it - * down. We don't set up any routes right now, because - * ATCP will install them manually via SIOCADDRT. - */ - break; - - case SIOCDARP: - if (!capable(CAP_NET_ADMIN)) - return -EPERM; - if (sa->sat_family != AF_APPLETALK) - return -EINVAL; - if (!atif) - return -EADDRNOTAVAIL; - - /* give to aarp module to remove proxy entry */ - aarp_proxy_remove(atif->dev, &(sa->sat_addr)); - return 0; + /* + * We now have an address on the local network, and + * the AARP code will defend it for us until we take it + * down. We don't set up any routes right now, because + * ATCP will install them manually via SIOCADDRT. + */ + break; + + case SIOCDARP: + if (!capable(CAP_NET_ADMIN)) + return -EPERM; + if (sa->sat_family != AF_APPLETALK) + return -EINVAL; + if (!atif) + return -EADDRNOTAVAIL; + + /* give to aarp module to remove proxy entry */ + aarp_proxy_remove(atif->dev, &(sa->sat_addr)); + return 0; } return copy_to_user(arg, &atreq, sizeof(atreq)) ? -EFAULT : 0; @@ -884,25 +884,25 @@ static int atrtr_ioctl(unsigned int cmd, void __user *arg) return -EFAULT; switch (cmd) { - case SIOCDELRT: - if (rt.rt_dst.sa_family != AF_APPLETALK) - return -EINVAL; - return atrtr_delete(&((struct sockaddr_at *) - &rt.rt_dst)->sat_addr); - - case SIOCADDRT: { - struct net_device *dev = NULL; - if (rt.rt_dev) { - char name[IFNAMSIZ]; - if (copy_from_user(name, rt.rt_dev, IFNAMSIZ-1)) - return -EFAULT; - name[IFNAMSIZ-1] = '\0'; - dev = __dev_get_by_name(&init_net, name); - if (!dev) - return -ENODEV; + case SIOCDELRT: + if (rt.rt_dst.sa_family != AF_APPLETALK) + return -EINVAL; + return atrtr_delete(&((struct sockaddr_at *) + &rt.rt_dst)->sat_addr); + + case SIOCADDRT: { + struct net_device *dev = NULL; + if (rt.rt_dev) { + char name[IFNAMSIZ]; + if (copy_from_user(name, rt.rt_dev, IFNAMSIZ-1)) + return -EFAULT; + name[IFNAMSIZ-1] = '\0'; + dev = __dev_get_by_name(&init_net, name); + if (!dev) + return -ENODEV; + } + return atrtr_create(&rt, dev); } - return atrtr_create(&rt, dev); - } } return -EINVAL; } diff --git a/trunk/net/batman-adv/aggregation.c b/trunk/net/batman-adv/aggregation.c index 69467fe71ff2..c583e049f421 100644 --- a/trunk/net/batman-adv/aggregation.c +++ b/trunk/net/batman-adv/aggregation.c @@ -28,7 +28,6 @@ /* return true if new_packet can be aggregated with forw_packet */ static bool can_aggregate_with(const struct batman_packet *new_batman_packet, - struct bat_priv *bat_priv, int packet_len, unsigned long send_time, bool directlink, @@ -38,8 +37,6 @@ static bool can_aggregate_with(const struct batman_packet *new_batman_packet, struct batman_packet *batman_packet = (struct batman_packet *)forw_packet->skb->data; int aggregated_bytes = forw_packet->packet_len + packet_len; - struct hard_iface *primary_if = NULL; - bool res = false; /** * we can aggregate the current packet to this aggregated packet @@ -64,10 +61,6 @@ static bool can_aggregate_with(const struct batman_packet *new_batman_packet, * packet */ - primary_if = primary_if_get_selected(bat_priv); - if (!primary_if) - goto out; - /* packets without direct link flag and high TTL * are flooded through the net */ if ((!directlink) && @@ -77,10 +70,8 @@ static bool can_aggregate_with(const struct batman_packet *new_batman_packet, /* own packets originating non-primary * interfaces leave only that interface */ ((!forw_packet->own) || - (forw_packet->if_incoming == primary_if))) { - res = true; - goto out; - } + (forw_packet->if_incoming->if_num == 0))) + return true; /* if the incoming packet is sent via this one * interface only - we still can aggregate */ @@ -93,16 +84,11 @@ static bool can_aggregate_with(const struct batman_packet *new_batman_packet, * (= secondary interface packets in general) */ (batman_packet->flags & DIRECTLINK || (forw_packet->own && - forw_packet->if_incoming != primary_if))) { - res = true; - goto out; - } + forw_packet->if_incoming->if_num != 0))) + return true; } -out: - if (primary_if) - hardif_free_ref(primary_if); - return res; + return false; } /* create a new aggregated packet and add this packet to it */ @@ -224,7 +210,6 @@ void add_bat_packet_to_list(struct bat_priv *bat_priv, hlist_for_each_entry(forw_packet_pos, tmp_node, &bat_priv->forw_bat_list, list) { if (can_aggregate_with(batman_packet, - bat_priv, packet_len, send_time, direct_link, diff --git a/trunk/net/batman-adv/gateway_client.c b/trunk/net/batman-adv/gateway_client.c index 056180ef9e1a..8b25b52a4764 100644 --- a/trunk/net/batman-adv/gateway_client.c +++ b/trunk/net/batman-adv/gateway_client.c @@ -487,9 +487,10 @@ int gw_client_seq_print_text(struct seq_file *seq, void *offset) } seq_printf(seq, " %-12s (%s/%i) %17s [%10s]: gw_class ... " - "[B.A.T.M.A.N. adv %s, MainIF/MAC: %s/%pM (%s)]\n", + "[B.A.T.M.A.N. adv %s%s, MainIF/MAC: %s/%pM (%s)]\n", "Gateway", "#", TQ_MAX_VALUE, "Nexthop", - "outgoingIF", SOURCE_VERSION, primary_if->net_dev->name, + "outgoingIF", SOURCE_VERSION, REVISION_VERSION_STR, + primary_if->net_dev->name, primary_if->net_dev->dev_addr, net_dev->name); rcu_read_lock(); diff --git a/trunk/net/batman-adv/main.c b/trunk/net/batman-adv/main.c index b0f9068ade57..e367e690a9f6 100644 --- a/trunk/net/batman-adv/main.c +++ b/trunk/net/batman-adv/main.c @@ -58,8 +58,9 @@ static int __init batman_init(void) register_netdevice_notifier(&hard_if_notifier); - pr_info("B.A.T.M.A.N. advanced %s (compatibility version %i) " - "loaded\n", SOURCE_VERSION, COMPAT_VERSION); + pr_info("B.A.T.M.A.N. advanced %s%s (compatibility version %i) " + "loaded\n", SOURCE_VERSION, REVISION_VERSION_STR, + COMPAT_VERSION); return 0; } @@ -183,4 +184,8 @@ MODULE_LICENSE("GPL"); MODULE_AUTHOR(DRIVER_AUTHOR); MODULE_DESCRIPTION(DRIVER_DESC); MODULE_SUPPORTED_DEVICE(DRIVER_DEVICE); +#ifdef REVISION_VERSION +MODULE_VERSION(SOURCE_VERSION "-" REVISION_VERSION); +#else MODULE_VERSION(SOURCE_VERSION); +#endif diff --git a/trunk/net/batman-adv/main.h b/trunk/net/batman-adv/main.h index a6df61a6933b..4f293b594475 100644 --- a/trunk/net/batman-adv/main.h +++ b/trunk/net/batman-adv/main.h @@ -27,9 +27,8 @@ #define DRIVER_DESC "B.A.T.M.A.N. advanced" #define DRIVER_DEVICE "batman-adv" -#ifndef SOURCE_VERSION -#define SOURCE_VERSION "2011.3.0" -#endif +#define SOURCE_VERSION "next" + /* B.A.T.M.A.N. parameters */ @@ -145,6 +144,12 @@ enum dbg_level { #include #include "types.h" +#ifndef REVISION_VERSION +#define REVISION_VERSION_STR "" +#else +#define REVISION_VERSION_STR " "REVISION_VERSION +#endif + extern struct list_head hardif_list; extern unsigned char broadcast_addr[]; diff --git a/trunk/net/batman-adv/originator.c b/trunk/net/batman-adv/originator.c index f3c3f620d195..338b3c597e4a 100644 --- a/trunk/net/batman-adv/originator.c +++ b/trunk/net/batman-adv/originator.c @@ -223,8 +223,6 @@ struct orig_node *get_orig_node(struct bat_priv *bat_priv, const uint8_t *addr) orig_node->bat_priv = bat_priv; memcpy(orig_node->orig, addr, ETH_ALEN); orig_node->router = NULL; - orig_node->tt_crc = 0; - atomic_set(&orig_node->last_ttvn, 0); orig_node->tt_buff = NULL; orig_node->tt_buff_len = 0; atomic_set(&orig_node->tt_size, 0); @@ -432,8 +430,9 @@ int orig_seq_print_text(struct seq_file *seq, void *offset) goto out; } - seq_printf(seq, "[B.A.T.M.A.N. adv %s, MainIF/MAC: %s/%pM (%s)]\n", - SOURCE_VERSION, primary_if->net_dev->name, + seq_printf(seq, "[B.A.T.M.A.N. adv %s%s, MainIF/MAC: %s/%pM (%s)]\n", + SOURCE_VERSION, REVISION_VERSION_STR, + primary_if->net_dev->name, primary_if->net_dev->dev_addr, net_dev->name); seq_printf(seq, " %-15s %s (%s/%i) %17s [%10s]: %20s ...\n", "Originator", "last-seen", "#", TQ_MAX_VALUE, "Nexthop", diff --git a/trunk/net/batman-adv/packet.h b/trunk/net/batman-adv/packet.h index b76b4be10b92..c5f081dfc6d1 100644 --- a/trunk/net/batman-adv/packet.h +++ b/trunk/net/batman-adv/packet.h @@ -78,15 +78,10 @@ enum tt_query_flags { TT_FULL_TABLE = 1 << 2 }; -/* TT_CLIENT flags. - * Flags from 1 to 1 << 7 are sent on the wire, while flags from 1 << 8 to - * 1 << 15 are used for local computation only */ -enum tt_client_flags { - TT_CLIENT_DEL = 1 << 0, - TT_CLIENT_ROAM = 1 << 1, - TT_CLIENT_NOPURGE = 1 << 8, - TT_CLIENT_NEW = 1 << 9, - TT_CLIENT_PENDING = 1 << 10 +/* TT_CHANGE flags */ +enum tt_change_flags { + TT_CHANGE_DEL = 0x01, + TT_CLIENT_ROAM = 0x02 }; struct batman_packet { diff --git a/trunk/net/batman-adv/routing.c b/trunk/net/batman-adv/routing.c index 0f32c818874d..0ce090c9fe86 100644 --- a/trunk/net/batman-adv/routing.c +++ b/trunk/net/batman-adv/routing.c @@ -91,18 +91,6 @@ static void update_transtable(struct bat_priv *bat_priv, * to recompute it to spot any possible inconsistency * in the global table */ orig_node->tt_crc = tt_global_crc(bat_priv, orig_node); - - /* The ttvn alone is not enough to guarantee consistency - * because a single value could repesent different states - * (due to the wrap around). Thus a node has to check whether - * the resulting table (after applying the changes) is still - * consistent or not. E.g. a node could disconnect while its - * ttvn is X and reconnect on ttvn = X + TTVN_MAX: in this case - * checking the CRC value is mandatory to detect the - * inconsistency */ - if (orig_node->tt_crc != tt_crc) - goto request_table; - /* Roaming phase is over: tables are in sync again. I can * unset the flag */ orig_node->tt_poss_change = false; @@ -1689,7 +1677,7 @@ int recv_bcast_packet(struct sk_buff *skb, struct hard_iface *recv_if) spin_unlock_bh(&orig_node->bcast_seqno_lock); /* rebroadcast packet */ - add_bcast_packet_to_list(bat_priv, skb, 1); + add_bcast_packet_to_list(bat_priv, skb); /* broadcast for me */ interface_rx(recv_if->soft_iface, skb, recv_if, hdr_size); diff --git a/trunk/net/batman-adv/send.c b/trunk/net/batman-adv/send.c index 58d14472068c..7a2f0823f1c2 100644 --- a/trunk/net/batman-adv/send.c +++ b/trunk/net/batman-adv/send.c @@ -163,7 +163,6 @@ static void send_packet(struct forw_packet *forw_packet) struct hard_iface *hard_iface; struct net_device *soft_iface; struct bat_priv *bat_priv; - struct hard_iface *primary_if = NULL; struct batman_packet *batman_packet = (struct batman_packet *)(forw_packet->skb->data); int directlink = (batman_packet->flags & DIRECTLINK ? 1 : 0); @@ -171,23 +170,19 @@ static void send_packet(struct forw_packet *forw_packet) if (!forw_packet->if_incoming) { pr_err("Error - can't forward packet: incoming iface not " "specified\n"); - goto out; + return; } soft_iface = forw_packet->if_incoming->soft_iface; bat_priv = netdev_priv(soft_iface); if (forw_packet->if_incoming->if_status != IF_ACTIVE) - goto out; - - primary_if = primary_if_get_selected(bat_priv); - if (!primary_if) - goto out; + return; /* multihomed peer assumed */ /* non-primary OGMs are only broadcasted on their interface */ if ((directlink && (batman_packet->ttl == 1)) || - (forw_packet->own && (forw_packet->if_incoming != primary_if))) { + (forw_packet->own && (forw_packet->if_incoming->if_num > 0))) { /* FIXME: what about aggregated packets ? */ bat_dbg(DBG_BATMAN, bat_priv, @@ -204,7 +199,7 @@ static void send_packet(struct forw_packet *forw_packet) broadcast_addr); forw_packet->skb = NULL; - goto out; + return; } /* broadcast on every interface */ @@ -216,10 +211,6 @@ static void send_packet(struct forw_packet *forw_packet) send_packet_to_if(forw_packet, hard_iface); } rcu_read_unlock(); - -out: - if (primary_if) - hardif_free_ref(primary_if); } static void realloc_packet_buffer(struct hard_iface *hard_iface, @@ -309,8 +300,10 @@ void schedule_own_packet(struct hard_iface *hard_iface) if (hard_iface == primary_if) { /* if at least one change happened */ if (atomic_read(&bat_priv->tt_local_changes) > 0) { - tt_commit_changes(bat_priv); prepare_packet_buffer(bat_priv, hard_iface); + /* Increment the TTVN only once per OGM interval */ + atomic_inc(&bat_priv->ttvn); + bat_priv->tt_poss_change = false; } /* if the changes have been sent enough times */ @@ -462,7 +455,7 @@ static void _add_bcast_packet_to_list(struct bat_priv *bat_priv, * The skb is not consumed, so the caller should make sure that the * skb is freed. */ int add_bcast_packet_to_list(struct bat_priv *bat_priv, - const struct sk_buff *skb, unsigned long delay) + const struct sk_buff *skb) { struct hard_iface *primary_if = NULL; struct forw_packet *forw_packet; @@ -499,7 +492,7 @@ int add_bcast_packet_to_list(struct bat_priv *bat_priv, /* how often did we send the bcast packet ? */ forw_packet->num_packets = 0; - _add_bcast_packet_to_list(bat_priv, forw_packet, delay); + _add_bcast_packet_to_list(bat_priv, forw_packet, 1); return NETDEV_TX_OK; packet_free: diff --git a/trunk/net/batman-adv/send.h b/trunk/net/batman-adv/send.h index 1f2d1e877663..633224ab028a 100644 --- a/trunk/net/batman-adv/send.h +++ b/trunk/net/batman-adv/send.h @@ -31,7 +31,7 @@ void schedule_forward_packet(struct orig_node *orig_node, int directlink, struct hard_iface *if_outgoing); int add_bcast_packet_to_list(struct bat_priv *bat_priv, - const struct sk_buff *skb, unsigned long delay); + const struct sk_buff *skb); void send_outstanding_bat_packet(struct work_struct *work); void purge_outstanding_packets(struct bat_priv *bat_priv, const struct hard_iface *hard_iface); diff --git a/trunk/net/batman-adv/soft-interface.c b/trunk/net/batman-adv/soft-interface.c index 3e2f91ffa4e2..2dcdbb7a236c 100644 --- a/trunk/net/batman-adv/soft-interface.c +++ b/trunk/net/batman-adv/soft-interface.c @@ -634,7 +634,7 @@ static int interface_tx(struct sk_buff *skb, struct net_device *soft_iface) bcast_packet->seqno = htonl(atomic_inc_return(&bat_priv->bcast_seqno)); - add_bcast_packet_to_list(bat_priv, skb, 1); + add_bcast_packet_to_list(bat_priv, skb); /* a copy is stored in the bcast list, therefore removing * the original skb. */ @@ -750,6 +750,7 @@ void interface_rx(struct net_device *soft_iface, return; } +#ifdef HAVE_NET_DEVICE_OPS static const struct net_device_ops bat_netdev_ops = { .ndo_open = interface_open, .ndo_stop = interface_release, @@ -759,6 +760,7 @@ static const struct net_device_ops bat_netdev_ops = { .ndo_start_xmit = interface_tx, .ndo_validate_addr = eth_validate_addr }; +#endif static void interface_setup(struct net_device *dev) { @@ -767,7 +769,16 @@ static void interface_setup(struct net_device *dev) ether_setup(dev); +#ifdef HAVE_NET_DEVICE_OPS dev->netdev_ops = &bat_netdev_ops; +#else + dev->open = interface_open; + dev->stop = interface_release; + dev->get_stats = interface_stats; + dev->set_mac_address = interface_set_mac_addr; + dev->change_mtu = interface_change_mtu; + dev->hard_start_xmit = interface_tx; +#endif dev->destructor = free_netdev; dev->tx_queue_len = 0; @@ -874,8 +885,13 @@ void softif_destroy(struct net_device *soft_iface) int softif_is_valid(const struct net_device *net_dev) { +#ifdef HAVE_NET_DEVICE_OPS if (net_dev->netdev_ops->ndo_start_xmit == interface_tx) return 1; +#else + if (net_dev->hard_start_xmit == interface_tx) + return 1; +#endif return 0; } diff --git a/trunk/net/batman-adv/translation-table.c b/trunk/net/batman-adv/translation-table.c index fb6931d00cd7..5f1fcd573633 100644 --- a/trunk/net/batman-adv/translation-table.c +++ b/trunk/net/batman-adv/translation-table.c @@ -143,8 +143,8 @@ static void tt_global_entry_free_ref(struct tt_global_entry *tt_global_entry) kfree_rcu(tt_global_entry, rcu); } -static void tt_local_event(struct bat_priv *bat_priv, const uint8_t *addr, - uint8_t flags) +static void tt_local_event(struct bat_priv *bat_priv, uint8_t op, + const uint8_t *addr, bool roaming) { struct tt_change_node *tt_change_node; @@ -153,7 +153,10 @@ static void tt_local_event(struct bat_priv *bat_priv, const uint8_t *addr, if (!tt_change_node) return; - tt_change_node->change.flags = flags; + tt_change_node->change.flags = op; + if (roaming) + tt_change_node->change.flags |= TT_CLIENT_ROAM; + memcpy(tt_change_node->change.addr, addr, ETH_ALEN); spin_lock_bh(&bat_priv->tt_changes_list_lock); @@ -200,29 +203,27 @@ void tt_local_add(struct net_device *soft_iface, const uint8_t *addr) if (!tt_local_entry) goto out; + tt_local_event(bat_priv, NO_FLAGS, addr, false); + bat_dbg(DBG_TT, bat_priv, "Creating new local tt entry: %pM (ttvn: %d)\n", addr, (uint8_t)atomic_read(&bat_priv->ttvn)); memcpy(tt_local_entry->addr, addr, ETH_ALEN); tt_local_entry->last_seen = jiffies; - tt_local_entry->flags = NO_FLAGS; atomic_set(&tt_local_entry->refcount, 2); /* the batman interface mac address should never be purged */ if (compare_eth(addr, soft_iface->dev_addr)) - tt_local_entry->flags |= TT_CLIENT_NOPURGE; - - tt_local_event(bat_priv, addr, tt_local_entry->flags); - - /* The local entry has to be marked as NEW to avoid to send it in - * a full table response going out before the next ttvn increment - * (consistency check) */ - tt_local_entry->flags |= TT_CLIENT_NEW; + tt_local_entry->never_purge = 1; + else + tt_local_entry->never_purge = 0; hash_add(bat_priv->tt_local_hash, compare_ltt, choose_orig, tt_local_entry, &tt_local_entry->hash_entry); + atomic_inc(&bat_priv->num_local_tt); + /* remove address from global hash if present */ tt_global_entry = tt_global_hash_find(bat_priv, addr); @@ -230,9 +231,8 @@ void tt_local_add(struct net_device *soft_iface, const uint8_t *addr) if (tt_global_entry) { /* This node is probably going to update its tt table */ tt_global_entry->orig_node->tt_poss_change = true; - /* The global entry has to be marked as PENDING and has to be - * kept for consistency purpose */ - tt_global_entry->flags |= TT_CLIENT_PENDING; + _tt_global_del(bat_priv, tt_global_entry, + "local tt received"); send_roam_adv(bat_priv, tt_global_entry->addr, tt_global_entry->orig_node); } @@ -362,17 +362,19 @@ int tt_local_seq_print_text(struct seq_file *seq, void *offset) return ret; } -static void tt_local_set_pending(struct bat_priv *bat_priv, - struct tt_local_entry *tt_local_entry, - uint16_t flags) +static void tt_local_del(struct bat_priv *bat_priv, + struct tt_local_entry *tt_local_entry, + const char *message) { - tt_local_event(bat_priv, tt_local_entry->addr, - tt_local_entry->flags | flags); + bat_dbg(DBG_TT, bat_priv, "Deleting local tt entry (%pM): %s\n", + tt_local_entry->addr, message); - /* The local client has to be merked as "pending to be removed" but has - * to be kept in the table in order to send it in an full tables - * response issued before the net ttvn increment (consistency check) */ - tt_local_entry->flags |= TT_CLIENT_PENDING; + atomic_dec(&bat_priv->num_local_tt); + + hash_remove(bat_priv->tt_local_hash, compare_ltt, choose_orig, + tt_local_entry->addr); + + tt_local_entry_free_ref(tt_local_entry); } void tt_local_remove(struct bat_priv *bat_priv, const uint8_t *addr, @@ -381,14 +383,12 @@ void tt_local_remove(struct bat_priv *bat_priv, const uint8_t *addr, struct tt_local_entry *tt_local_entry = NULL; tt_local_entry = tt_local_hash_find(bat_priv, addr); + if (!tt_local_entry) goto out; - tt_local_set_pending(bat_priv, tt_local_entry, TT_CLIENT_DEL | - (roaming ? TT_CLIENT_ROAM : NO_FLAGS)); - - bat_dbg(DBG_TT, bat_priv, "Local tt entry (%pM) pending to be removed: " - "%s\n", tt_local_entry->addr, message); + tt_local_event(bat_priv, TT_CHANGE_DEL, tt_local_entry->addr, roaming); + tt_local_del(bat_priv, tt_local_entry, message); out: if (tt_local_entry) tt_local_entry_free_ref(tt_local_entry); @@ -410,22 +410,21 @@ static void tt_local_purge(struct bat_priv *bat_priv) spin_lock_bh(list_lock); hlist_for_each_entry_safe(tt_local_entry, node, node_tmp, head, hash_entry) { - if (tt_local_entry->flags & TT_CLIENT_NOPURGE) - continue; - - /* entry already marked for deletion */ - if (tt_local_entry->flags & TT_CLIENT_PENDING) + if (tt_local_entry->never_purge) continue; if (!is_out_of_time(tt_local_entry->last_seen, TT_LOCAL_TIMEOUT * 1000)) continue; - tt_local_set_pending(bat_priv, tt_local_entry, - TT_CLIENT_DEL); - bat_dbg(DBG_TT, bat_priv, "Local tt entry (%pM) " - "pending to be removed: timed out\n", + tt_local_event(bat_priv, TT_CHANGE_DEL, + tt_local_entry->addr, false); + atomic_dec(&bat_priv->num_local_tt); + bat_dbg(DBG_TT, bat_priv, "Deleting local " + "tt entry (%pM): timed out\n", tt_local_entry->addr); + hlist_del_rcu(node); + tt_local_entry_free_ref(tt_local_entry); } spin_unlock_bh(list_lock); } @@ -788,11 +787,6 @@ struct orig_node *transtable_search(struct bat_priv *bat_priv, if (!atomic_inc_not_zero(&tt_global_entry->orig_node->refcount)) goto free_tt; - /* A global client marked as PENDING has already moved from that - * originator */ - if (tt_global_entry->flags & TT_CLIENT_PENDING) - goto free_tt; - orig_node = tt_global_entry->orig_node; free_tt: @@ -854,10 +848,6 @@ uint16_t tt_local_crc(struct bat_priv *bat_priv) rcu_read_lock(); hlist_for_each_entry_rcu(tt_local_entry, node, head, hash_entry) { - /* not yet committed clients have not to be taken into - * account while computing the CRC */ - if (tt_local_entry->flags & TT_CLIENT_NEW) - continue; total_one = 0; for (j = 0; j < ETH_ALEN; j++) total_one = crc16_byte(total_one, @@ -947,16 +937,6 @@ static struct tt_req_node *new_tt_req_node(struct bat_priv *bat_priv, return tt_req_node; } -/* data_ptr is useless here, but has to be kept to respect the prototype */ -static int tt_local_valid_entry(const void *entry_ptr, const void *data_ptr) -{ - const struct tt_local_entry *tt_local_entry = entry_ptr; - - if (tt_local_entry->flags & TT_CLIENT_NEW) - return 0; - return 1; -} - static int tt_global_valid_entry(const void *entry_ptr, const void *data_ptr) { const struct tt_global_entry *tt_global_entry = entry_ptr; @@ -1297,8 +1277,7 @@ static bool send_my_tt_response(struct bat_priv *bat_priv, skb = tt_response_fill_table(tt_len, ttvn, bat_priv->tt_local_hash, - primary_if, tt_local_valid_entry, - NULL); + primary_if, NULL, NULL); if (!skb) goto out; @@ -1356,7 +1335,7 @@ static void _tt_update_changes(struct bat_priv *bat_priv, int i; for (i = 0; i < tt_num_changes; i++) { - if ((tt_change + i)->flags & TT_CLIENT_DEL) + if ((tt_change + i)->flags & TT_CHANGE_DEL) tt_global_del(bat_priv, orig_node, (tt_change + i)->addr, "tt removed by changes", @@ -1423,10 +1402,6 @@ bool is_my_client(struct bat_priv *bat_priv, const uint8_t *addr) tt_local_entry = tt_local_hash_find(bat_priv, addr); if (!tt_local_entry) goto out; - /* Check if the client has been logically deleted (but is kept for - * consistency purpose) */ - if (tt_local_entry->flags & TT_CLIENT_PENDING) - goto out; ret = true; out: if (tt_local_entry) @@ -1647,76 +1622,3 @@ void tt_free(struct bat_priv *bat_priv) kfree(bat_priv->tt_buff); } - -/* This function will reset the specified flags from all the entries in - * the given hash table and will increment num_local_tt for each involved - * entry */ -static void tt_local_reset_flags(struct bat_priv *bat_priv, uint16_t flags) -{ - int i; - struct hashtable_t *hash = bat_priv->tt_local_hash; - struct hlist_head *head; - struct hlist_node *node; - struct tt_local_entry *tt_local_entry; - - if (!hash) - return; - - for (i = 0; i < hash->size; i++) { - head = &hash->table[i]; - - rcu_read_lock(); - hlist_for_each_entry_rcu(tt_local_entry, node, - head, hash_entry) { - tt_local_entry->flags &= ~flags; - atomic_inc(&bat_priv->num_local_tt); - } - rcu_read_unlock(); - } - -} - -/* Purge out all the tt local entries marked with TT_CLIENT_PENDING */ -static void tt_local_purge_pending_clients(struct bat_priv *bat_priv) -{ - struct hashtable_t *hash = bat_priv->tt_local_hash; - struct tt_local_entry *tt_local_entry; - struct hlist_node *node, *node_tmp; - struct hlist_head *head; - spinlock_t *list_lock; /* protects write access to the hash lists */ - int i; - - if (!hash) - return; - - for (i = 0; i < hash->size; i++) { - head = &hash->table[i]; - list_lock = &hash->list_locks[i]; - - spin_lock_bh(list_lock); - hlist_for_each_entry_safe(tt_local_entry, node, node_tmp, - head, hash_entry) { - if (!(tt_local_entry->flags & TT_CLIENT_PENDING)) - continue; - - bat_dbg(DBG_TT, bat_priv, "Deleting local tt entry " - "(%pM): pending\n", tt_local_entry->addr); - - atomic_dec(&bat_priv->num_local_tt); - hlist_del_rcu(node); - tt_local_entry_free_ref(tt_local_entry); - } - spin_unlock_bh(list_lock); - } - -} - -void tt_commit_changes(struct bat_priv *bat_priv) -{ - tt_local_reset_flags(bat_priv, TT_CLIENT_NEW); - tt_local_purge_pending_clients(bat_priv); - - /* Increment the TTVN only once per OGM interval */ - atomic_inc(&bat_priv->ttvn); - bat_priv->tt_poss_change = false; -} diff --git a/trunk/net/batman-adv/translation-table.h b/trunk/net/batman-adv/translation-table.h index d4122cba53b8..1cd2d39529fe 100644 --- a/trunk/net/batman-adv/translation-table.h +++ b/trunk/net/batman-adv/translation-table.h @@ -30,7 +30,8 @@ void tt_local_add(struct net_device *soft_iface, const uint8_t *addr); void tt_local_remove(struct bat_priv *bat_priv, const uint8_t *addr, const char *message, bool roaming); int tt_local_seq_print_text(struct seq_file *seq, void *offset); -void tt_global_add_orig(struct bat_priv *bat_priv, struct orig_node *orig_node, +void tt_global_add_orig(struct bat_priv *bat_priv, + struct orig_node *orig_node, const unsigned char *tt_buff, int tt_buff_len); int tt_global_add(struct bat_priv *bat_priv, struct orig_node *orig_node, const unsigned char *addr, @@ -61,6 +62,5 @@ void handle_tt_response(struct bat_priv *bat_priv, struct tt_query_packet *tt_response); void send_roam_adv(struct bat_priv *bat_priv, uint8_t *client, struct orig_node *orig_node); -void tt_commit_changes(struct bat_priv *bat_priv); #endif /* _NET_BATMAN_ADV_TRANSLATION_TABLE_H_ */ diff --git a/trunk/net/batman-adv/types.h b/trunk/net/batman-adv/types.h index 25bd1db35370..85cf1224881e 100644 --- a/trunk/net/batman-adv/types.h +++ b/trunk/net/batman-adv/types.h @@ -224,7 +224,7 @@ struct socket_packet { struct tt_local_entry { uint8_t addr[ETH_ALEN]; unsigned long last_seen; - uint16_t flags; + char never_purge; atomic_t refcount; struct rcu_head rcu; struct hlist_node hash_entry; @@ -234,7 +234,7 @@ struct tt_global_entry { uint8_t addr[ETH_ALEN]; struct orig_node *orig_node; uint8_t ttvn; - uint16_t flags; /* only TT_GLOBAL_ROAM is used */ + uint8_t flags; /* only TT_GLOBAL_ROAM is used */ unsigned long roam_at; /* time at which TT_GLOBAL_ROAM was set */ atomic_t refcount; struct rcu_head rcu; diff --git a/trunk/net/bluetooth/Kconfig b/trunk/net/bluetooth/Kconfig index bfb3dc03c9de..6ae5ec508587 100644 --- a/trunk/net/bluetooth/Kconfig +++ b/trunk/net/bluetooth/Kconfig @@ -6,7 +6,6 @@ menuconfig BT tristate "Bluetooth subsystem support" depends on NET && !S390 depends on RFKILL || !RFKILL - select CRYPTO help Bluetooth is low-cost, low-power, short-range wireless technology. It was designed as a replacement for cables and other short-range @@ -23,7 +22,6 @@ menuconfig BT BNEP Module (Bluetooth Network Encapsulation Protocol) CMTP Module (CAPI Message Transport Protocol) HIDP Module (Human Interface Device Protocol) - SMP Module (Security Manager Protocol) Say Y here to compile Bluetooth support into the kernel or say M to compile it as module (bluetooth). @@ -38,18 +36,11 @@ if BT != n config BT_L2CAP bool "L2CAP protocol support" select CRC16 - select CRYPTO - select CRYPTO_BLKCIPHER - select CRYPTO_AES - select CRYPTO_ECB help L2CAP (Logical Link Control and Adaptation Protocol) provides connection oriented and connection-less data transport. L2CAP support is required for most Bluetooth applications. - Also included is support for SMP (Security Manager Protocol) which - is the security layer on top of LE (Low Energy) links. - config BT_SCO bool "SCO links support" help diff --git a/trunk/net/bluetooth/Makefile b/trunk/net/bluetooth/Makefile index 9b67f3d08fa4..f04fe9a9d634 100644 --- a/trunk/net/bluetooth/Makefile +++ b/trunk/net/bluetooth/Makefile @@ -9,5 +9,5 @@ obj-$(CONFIG_BT_CMTP) += cmtp/ obj-$(CONFIG_BT_HIDP) += hidp/ bluetooth-y := af_bluetooth.o hci_core.o hci_conn.o hci_event.o mgmt.o hci_sock.o hci_sysfs.o lib.o -bluetooth-$(CONFIG_BT_L2CAP) += l2cap_core.o l2cap_sock.o smp.o +bluetooth-$(CONFIG_BT_L2CAP) += l2cap_core.o l2cap_sock.o bluetooth-$(CONFIG_BT_SCO) += sco.o diff --git a/trunk/net/bluetooth/cmtp/capi.c b/trunk/net/bluetooth/cmtp/capi.c index 040f67b12978..744233cba244 100644 --- a/trunk/net/bluetooth/cmtp/capi.c +++ b/trunk/net/bluetooth/cmtp/capi.c @@ -326,7 +326,7 @@ void cmtp_recv_capimsg(struct cmtp_session *session, struct sk_buff *skb) { struct capi_ctr *ctrl = &session->ctrl; struct cmtp_application *application; - __u16 appl; + __u16 cmd, appl; __u32 contr; BT_DBG("session %p skb %p len %d", session, skb, skb->len); @@ -344,6 +344,7 @@ void cmtp_recv_capimsg(struct cmtp_session *session, struct sk_buff *skb) return; } + cmd = CAPICMD(CAPIMSG_COMMAND(skb->data), CAPIMSG_SUBCOMMAND(skb->data)); appl = CAPIMSG_APPID(skb->data); contr = CAPIMSG_CONTROL(skb->data); diff --git a/trunk/net/bluetooth/hci_conn.c b/trunk/net/bluetooth/hci_conn.c index ea7f031f3b04..3163330cd4f1 100644 --- a/trunk/net/bluetooth/hci_conn.c +++ b/trunk/net/bluetooth/hci_conn.c @@ -53,13 +53,11 @@ static void hci_le_connect(struct hci_conn *conn) conn->state = BT_CONNECT; conn->out = 1; conn->link_mode |= HCI_LM_MASTER; - conn->sec_level = BT_SECURITY_LOW; memset(&cp, 0, sizeof(cp)); cp.scan_interval = cpu_to_le16(0x0004); cp.scan_window = cpu_to_le16(0x0004); bacpy(&cp.peer_addr, &conn->dst); - cp.peer_addr_type = conn->dst_type; cp.conn_interval_min = cpu_to_le16(0x0008); cp.conn_interval_max = cpu_to_le16(0x0100); cp.supervision_timeout = cpu_to_le16(0x0064); @@ -205,55 +203,6 @@ void hci_le_conn_update(struct hci_conn *conn, u16 min, u16 max, } EXPORT_SYMBOL(hci_le_conn_update); -void hci_le_start_enc(struct hci_conn *conn, __le16 ediv, __u8 rand[8], - __u8 ltk[16]) -{ - struct hci_dev *hdev = conn->hdev; - struct hci_cp_le_start_enc cp; - - BT_DBG("%p", conn); - - memset(&cp, 0, sizeof(cp)); - - cp.handle = cpu_to_le16(conn->handle); - memcpy(cp.ltk, ltk, sizeof(cp.ltk)); - cp.ediv = ediv; - memcpy(cp.rand, rand, sizeof(rand)); - - hci_send_cmd(hdev, HCI_OP_LE_START_ENC, sizeof(cp), &cp); -} -EXPORT_SYMBOL(hci_le_start_enc); - -void hci_le_ltk_reply(struct hci_conn *conn, u8 ltk[16]) -{ - struct hci_dev *hdev = conn->hdev; - struct hci_cp_le_ltk_reply cp; - - BT_DBG("%p", conn); - - memset(&cp, 0, sizeof(cp)); - - cp.handle = cpu_to_le16(conn->handle); - memcpy(cp.ltk, ltk, sizeof(ltk)); - - hci_send_cmd(hdev, HCI_OP_LE_LTK_REPLY, sizeof(cp), &cp); -} -EXPORT_SYMBOL(hci_le_ltk_reply); - -void hci_le_ltk_neg_reply(struct hci_conn *conn) -{ - struct hci_dev *hdev = conn->hdev; - struct hci_cp_le_ltk_neg_reply cp; - - BT_DBG("%p", conn); - - memset(&cp, 0, sizeof(cp)); - - cp.handle = cpu_to_le16(conn->handle); - - hci_send_cmd(hdev, HCI_OP_LE_LTK_NEG_REPLY, sizeof(cp), &cp); -} - /* Device _must_ be locked */ void hci_sco_setup(struct hci_conn *conn, __u8 status) { @@ -444,9 +393,6 @@ int hci_conn_del(struct hci_conn *conn) hci_dev_put(hdev); - if (conn->handle == 0) - kfree(conn); - return 0; } @@ -501,23 +447,14 @@ struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst, __u8 BT_DBG("%s dst %s", hdev->name, batostr(dst)); if (type == LE_LINK) { - struct adv_entry *entry; - le = hci_conn_hash_lookup_ba(hdev, LE_LINK, dst); if (le) return ERR_PTR(-EBUSY); - - entry = hci_find_adv_entry(hdev, dst); - if (!entry) - return ERR_PTR(-EHOSTUNREACH); - le = hci_conn_add(hdev, LE_LINK, dst); if (!le) return ERR_PTR(-ENOMEM); - - le->dst_type = entry->bdaddr_type; - - hci_le_connect(le); + if (le->state == BT_OPEN) + hci_le_connect(le); hci_conn_hold(le); @@ -560,7 +497,7 @@ struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst, __u8 if (acl->state == BT_CONNECTED && (sco->state == BT_OPEN || sco->state == BT_CLOSED)) { acl->power_save = 1; - hci_conn_enter_active_mode(acl, BT_POWER_FORCE_ACTIVE_ON); + hci_conn_enter_active_mode(acl); if (test_bit(HCI_CONN_MODE_CHANGE_PEND, &acl->pend)) { /* defer SCO setup until mode change completed */ @@ -611,8 +548,6 @@ static int hci_conn_auth(struct hci_conn *conn, __u8 sec_level, __u8 auth_type) cp.handle = cpu_to_le16(conn->handle); hci_send_cmd(conn->hdev, HCI_OP_AUTH_REQUESTED, sizeof(cp), &cp); - if (conn->key_type != 0xff) - set_bit(HCI_CONN_REAUTH_PEND, &conn->pend); } return 0; @@ -673,11 +608,11 @@ int hci_conn_security(struct hci_conn *conn, __u8 sec_level, __u8 auth_type) goto encrypt; auth: - if (test_bit(HCI_CONN_ENCRYPT_PEND, &conn->pend)) + if (test_and_set_bit(HCI_CONN_ENCRYPT_PEND, &conn->pend)) return 0; - if (!hci_conn_auth(conn, sec_level, auth_type)) - return 0; + hci_conn_auth(conn, sec_level, auth_type); + return 0; encrypt: if (conn->link_mode & HCI_LM_ENCRYPT) @@ -696,7 +631,9 @@ int hci_conn_check_secure(struct hci_conn *conn, __u8 sec_level) if (sec_level != BT_SECURITY_HIGH) return 1; /* Accept if non-secure is required */ - if (conn->sec_level == BT_SECURITY_HIGH) + if (conn->key_type == HCI_LK_AUTH_COMBINATION || + (conn->key_type == HCI_LK_COMBINATION && + conn->pin_length == 16)) return 1; return 0; /* Reject not secure link */ @@ -739,7 +676,7 @@ int hci_conn_switch_role(struct hci_conn *conn, __u8 role) EXPORT_SYMBOL(hci_conn_switch_role); /* Enter active mode */ -void hci_conn_enter_active_mode(struct hci_conn *conn, __u8 force_active) +void hci_conn_enter_active_mode(struct hci_conn *conn) { struct hci_dev *hdev = conn->hdev; @@ -748,10 +685,7 @@ void hci_conn_enter_active_mode(struct hci_conn *conn, __u8 force_active) if (test_bit(HCI_RAW, &hdev->flags)) return; - if (conn->mode != HCI_CM_SNIFF) - goto timer; - - if (!conn->power_save && !force_active) + if (conn->mode != HCI_CM_SNIFF || !conn->power_save) goto timer; if (!test_and_set_bit(HCI_CONN_MODE_CHANGE_PEND, &conn->pend)) { diff --git a/trunk/net/bluetooth/hci_core.c b/trunk/net/bluetooth/hci_core.c index b18db5628275..e937adab3683 100644 --- a/trunk/net/bluetooth/hci_core.c +++ b/trunk/net/bluetooth/hci_core.c @@ -42,7 +42,6 @@ #include #include #include -#include #include #include @@ -60,8 +59,6 @@ static void hci_tx_task(unsigned long arg); static DEFINE_RWLOCK(hci_task_lock); -static int enable_smp; - /* HCI device list */ LIST_HEAD(hci_dev_list); DEFINE_RWLOCK(hci_dev_list_lock); @@ -1205,177 +1202,6 @@ int hci_add_remote_oob_data(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 *hash, return 0; } -struct bdaddr_list *hci_blacklist_lookup(struct hci_dev *hdev, - bdaddr_t *bdaddr) -{ - struct list_head *p; - - list_for_each(p, &hdev->blacklist) { - struct bdaddr_list *b; - - b = list_entry(p, struct bdaddr_list, list); - - if (bacmp(bdaddr, &b->bdaddr) == 0) - return b; - } - - return NULL; -} - -int hci_blacklist_clear(struct hci_dev *hdev) -{ - struct list_head *p, *n; - - list_for_each_safe(p, n, &hdev->blacklist) { - struct bdaddr_list *b; - - b = list_entry(p, struct bdaddr_list, list); - - list_del(p); - kfree(b); - } - - return 0; -} - -int hci_blacklist_add(struct hci_dev *hdev, bdaddr_t *bdaddr) -{ - struct bdaddr_list *entry; - int err; - - if (bacmp(bdaddr, BDADDR_ANY) == 0) - return -EBADF; - - hci_dev_lock(hdev); - - if (hci_blacklist_lookup(hdev, bdaddr)) { - err = -EEXIST; - goto err; - } - - entry = kzalloc(sizeof(struct bdaddr_list), GFP_KERNEL); - if (!entry) { - return -ENOMEM; - goto err; - } - - bacpy(&entry->bdaddr, bdaddr); - - list_add(&entry->list, &hdev->blacklist); - - err = 0; - -err: - hci_dev_unlock(hdev); - return err; -} - -int hci_blacklist_del(struct hci_dev *hdev, bdaddr_t *bdaddr) -{ - struct bdaddr_list *entry; - int err = 0; - - hci_dev_lock(hdev); - - if (bacmp(bdaddr, BDADDR_ANY) == 0) { - hci_blacklist_clear(hdev); - goto done; - } - - entry = hci_blacklist_lookup(hdev, bdaddr); - if (!entry) { - err = -ENOENT; - goto done; - } - - list_del(&entry->list); - kfree(entry); - -done: - hci_dev_unlock(hdev); - return err; -} - -static void hci_clear_adv_cache(unsigned long arg) -{ - struct hci_dev *hdev = (void *) arg; - - hci_dev_lock(hdev); - - hci_adv_entries_clear(hdev); - - hci_dev_unlock(hdev); -} - -int hci_adv_entries_clear(struct hci_dev *hdev) -{ - struct adv_entry *entry, *tmp; - - list_for_each_entry_safe(entry, tmp, &hdev->adv_entries, list) { - list_del(&entry->list); - kfree(entry); - } - - BT_DBG("%s adv cache cleared", hdev->name); - - return 0; -} - -struct adv_entry *hci_find_adv_entry(struct hci_dev *hdev, bdaddr_t *bdaddr) -{ - struct adv_entry *entry; - - list_for_each_entry(entry, &hdev->adv_entries, list) - if (bacmp(bdaddr, &entry->bdaddr) == 0) - return entry; - - return NULL; -} - -static inline int is_connectable_adv(u8 evt_type) -{ - if (evt_type == ADV_IND || evt_type == ADV_DIRECT_IND) - return 1; - - return 0; -} - -int hci_add_adv_entry(struct hci_dev *hdev, - struct hci_ev_le_advertising_info *ev) -{ - struct adv_entry *entry; - - if (!is_connectable_adv(ev->evt_type)) - return -EINVAL; - - /* Only new entries should be added to adv_entries. So, if - * bdaddr was found, don't add it. */ - if (hci_find_adv_entry(hdev, &ev->bdaddr)) - return 0; - - entry = kzalloc(sizeof(*entry), GFP_ATOMIC); - if (!entry) - return -ENOMEM; - - bacpy(&entry->bdaddr, &ev->bdaddr); - entry->bdaddr_type = ev->bdaddr_type; - - list_add(&entry->list, &hdev->adv_entries); - - BT_DBG("%s adv entry added: address %s type %u", hdev->name, - batostr(&entry->bdaddr), entry->bdaddr_type); - - return 0; -} - -static struct crypto_blkcipher *alloc_cypher(void) -{ - if (enable_smp) - return crypto_alloc_blkcipher("ecb(aes)", 0, CRYPTO_ALG_ASYNC); - - return ERR_PTR(-ENOTSUPP); -} - /* Register HCI device */ int hci_register_dev(struct hci_dev *hdev) { @@ -1442,10 +1268,6 @@ int hci_register_dev(struct hci_dev *hdev) INIT_LIST_HEAD(&hdev->remote_oob_data); - INIT_LIST_HEAD(&hdev->adv_entries); - setup_timer(&hdev->adv_timer, hci_clear_adv_cache, - (unsigned long) hdev); - INIT_WORK(&hdev->power_on, hci_power_on); INIT_WORK(&hdev->power_off, hci_power_off); setup_timer(&hdev->off_timer, hci_auto_off, (unsigned long) hdev); @@ -1460,11 +1282,6 @@ int hci_register_dev(struct hci_dev *hdev) if (!hdev->workqueue) goto nomem; - hdev->tfm = alloc_cypher(); - if (IS_ERR(hdev->tfm)) - BT_INFO("Failed to load transform for ecb(aes): %ld", - PTR_ERR(hdev->tfm)); - hci_register_sysfs(hdev); hdev->rfkill = rfkill_alloc(hdev->name, &hdev->dev, @@ -1513,9 +1330,6 @@ int hci_unregister_dev(struct hci_dev *hdev) !test_bit(HCI_SETUP, &hdev->flags)) mgmt_index_removed(hdev->id); - if (!IS_ERR(hdev->tfm)) - crypto_free_blkcipher(hdev->tfm); - hci_notify(hdev, HCI_DEV_UNREG); if (hdev->rfkill) { @@ -1526,7 +1340,6 @@ int hci_unregister_dev(struct hci_dev *hdev) hci_unregister_sysfs(hdev); hci_del_off_timer(hdev); - del_timer(&hdev->adv_timer); destroy_workqueue(hdev->workqueue); @@ -1535,7 +1348,6 @@ int hci_unregister_dev(struct hci_dev *hdev) hci_uuids_clear(hdev); hci_link_keys_clear(hdev); hci_remote_oob_data_clear(hdev); - hci_adv_entries_clear(hdev); hci_dev_unlock_bh(hdev); __hci_dev_put(hdev); @@ -2079,7 +1891,7 @@ static inline void hci_sched_acl(struct hci_dev *hdev) while (quote-- && (skb = skb_dequeue(&conn->data_q))) { BT_DBG("skb %p len %d", skb, skb->len); - hci_conn_enter_active_mode(conn, bt_cb(skb)->force_active); + hci_conn_enter_active_mode(conn); hci_send_frame(skb); hdev->acl_last_tx = jiffies; @@ -2218,7 +2030,7 @@ static inline void hci_acldata_packet(struct hci_dev *hdev, struct sk_buff *skb) if (conn) { register struct hci_proto *hp; - hci_conn_enter_active_mode(conn, bt_cb(skb)->force_active); + hci_conn_enter_active_mode(conn); /* Send to upper protocol */ hp = hci_proto[HCI_PROTO_L2CAP]; @@ -2352,6 +2164,3 @@ static void hci_cmd_task(unsigned long arg) } } } - -module_param(enable_smp, bool, 0644); -MODULE_PARM_DESC(enable_smp, "Enable SMP support (LE only)"); diff --git a/trunk/net/bluetooth/hci_event.c b/trunk/net/bluetooth/hci_event.c index ac2c5e89617c..77930aa522e3 100644 --- a/trunk/net/bluetooth/hci_event.c +++ b/trunk/net/bluetooth/hci_event.c @@ -841,57 +841,6 @@ static void hci_cc_read_local_oob_data_reply(struct hci_dev *hdev, rp->randomizer, rp->status); } -static void hci_cc_le_set_scan_enable(struct hci_dev *hdev, - struct sk_buff *skb) -{ - struct hci_cp_le_set_scan_enable *cp; - __u8 status = *((__u8 *) skb->data); - - BT_DBG("%s status 0x%x", hdev->name, status); - - if (status) - return; - - cp = hci_sent_cmd_data(hdev, HCI_OP_LE_SET_SCAN_ENABLE); - if (!cp) - return; - - hci_dev_lock(hdev); - - if (cp->enable == 0x01) { - del_timer(&hdev->adv_timer); - hci_adv_entries_clear(hdev); - } else if (cp->enable == 0x00) { - mod_timer(&hdev->adv_timer, jiffies + ADV_CLEAR_TIMEOUT); - } - - hci_dev_unlock(hdev); -} - -static void hci_cc_le_ltk_reply(struct hci_dev *hdev, struct sk_buff *skb) -{ - struct hci_rp_le_ltk_reply *rp = (void *) skb->data; - - BT_DBG("%s status 0x%x", hdev->name, rp->status); - - if (rp->status) - return; - - hci_req_complete(hdev, HCI_OP_LE_LTK_REPLY, rp->status); -} - -static void hci_cc_le_ltk_neg_reply(struct hci_dev *hdev, struct sk_buff *skb) -{ - struct hci_rp_le_ltk_neg_reply *rp = (void *) skb->data; - - BT_DBG("%s status 0x%x", hdev->name, rp->status); - - if (rp->status) - return; - - hci_req_complete(hdev, HCI_OP_LE_LTK_NEG_REPLY, rp->status); -} - static inline void hci_cs_inquiry(struct hci_dev *hdev, __u8 status) { BT_DBG("%s status 0x%x", hdev->name, status); @@ -1260,23 +1209,16 @@ static void hci_cs_le_create_conn(struct hci_dev *hdev, __u8 status) } else { if (!conn) { conn = hci_conn_add(hdev, LE_LINK, &cp->peer_addr); - if (conn) { - conn->dst_type = cp->peer_addr_type; + if (conn) conn->out = 1; - } else { + else BT_ERR("No memory for new connection"); - } } } hci_dev_unlock(hdev); } -static void hci_cs_le_start_enc(struct hci_dev *hdev, u8 status) -{ - BT_DBG("%s status 0x%x", hdev->name, status); -} - static inline void hci_inquiry_complete_evt(struct hci_dev *hdev, struct sk_buff *skb) { __u8 status = *((__u8 *) skb->data); @@ -1520,58 +1462,51 @@ static inline void hci_auth_complete_evt(struct hci_dev *hdev, struct sk_buff *s hci_dev_lock(hdev); conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); - if (!conn) - goto unlock; - - if (!ev->status) { - if (!(conn->ssp_mode > 0 && hdev->ssp_mode > 0) && - test_bit(HCI_CONN_REAUTH_PEND, &conn->pend)) { - BT_INFO("re-auth of legacy device is not possible."); - } else { + if (conn) { + if (!ev->status) { conn->link_mode |= HCI_LM_AUTH; conn->sec_level = conn->pending_sec_level; + } else { + mgmt_auth_failed(hdev->id, &conn->dst, ev->status); } - } else { - mgmt_auth_failed(hdev->id, &conn->dst, ev->status); - } - clear_bit(HCI_CONN_AUTH_PEND, &conn->pend); - clear_bit(HCI_CONN_REAUTH_PEND, &conn->pend); + clear_bit(HCI_CONN_AUTH_PEND, &conn->pend); - if (conn->state == BT_CONFIG) { - if (!ev->status && hdev->ssp_mode > 0 && conn->ssp_mode > 0) { - struct hci_cp_set_conn_encrypt cp; - cp.handle = ev->handle; - cp.encrypt = 0x01; - hci_send_cmd(hdev, HCI_OP_SET_CONN_ENCRYPT, sizeof(cp), - &cp); + if (conn->state == BT_CONFIG) { + if (!ev->status && hdev->ssp_mode > 0 && + conn->ssp_mode > 0) { + struct hci_cp_set_conn_encrypt cp; + cp.handle = ev->handle; + cp.encrypt = 0x01; + hci_send_cmd(hdev, HCI_OP_SET_CONN_ENCRYPT, + sizeof(cp), &cp); + } else { + conn->state = BT_CONNECTED; + hci_proto_connect_cfm(conn, ev->status); + hci_conn_put(conn); + } } else { - conn->state = BT_CONNECTED; - hci_proto_connect_cfm(conn, ev->status); + hci_auth_cfm(conn, ev->status); + + hci_conn_hold(conn); + conn->disc_timeout = HCI_DISCONN_TIMEOUT; hci_conn_put(conn); } - } else { - hci_auth_cfm(conn, ev->status); - hci_conn_hold(conn); - conn->disc_timeout = HCI_DISCONN_TIMEOUT; - hci_conn_put(conn); - } - - if (test_bit(HCI_CONN_ENCRYPT_PEND, &conn->pend)) { - if (!ev->status) { - struct hci_cp_set_conn_encrypt cp; - cp.handle = ev->handle; - cp.encrypt = 0x01; - hci_send_cmd(hdev, HCI_OP_SET_CONN_ENCRYPT, sizeof(cp), - &cp); - } else { - clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->pend); - hci_encrypt_cfm(conn, ev->status, 0x00); + if (test_bit(HCI_CONN_ENCRYPT_PEND, &conn->pend)) { + if (!ev->status) { + struct hci_cp_set_conn_encrypt cp; + cp.handle = ev->handle; + cp.encrypt = 0x01; + hci_send_cmd(hdev, HCI_OP_SET_CONN_ENCRYPT, + sizeof(cp), &cp); + } else { + clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->pend); + hci_encrypt_cfm(conn, ev->status, 0x00); + } } } -unlock: hci_dev_unlock(hdev); } @@ -1622,7 +1557,6 @@ static inline void hci_encrypt_change_evt(struct hci_dev *hdev, struct sk_buff * /* Encryption implies authentication */ conn->link_mode |= HCI_LM_AUTH; conn->link_mode |= HCI_LM_ENCRYPT; - conn->sec_level = conn->pending_sec_level; } else conn->link_mode &= ~HCI_LM_ENCRYPT; } @@ -1882,18 +1816,6 @@ static inline void hci_cmd_complete_evt(struct hci_dev *hdev, struct sk_buff *sk hci_cc_user_confirm_neg_reply(hdev, skb); break; - case HCI_OP_LE_SET_SCAN_ENABLE: - hci_cc_le_set_scan_enable(hdev, skb); - break; - - case HCI_OP_LE_LTK_REPLY: - hci_cc_le_ltk_reply(hdev, skb); - break; - - case HCI_OP_LE_LTK_NEG_REPLY: - hci_cc_le_ltk_neg_reply(hdev, skb); - break; - default: BT_DBG("%s opcode 0x%x", hdev->name, opcode); break; @@ -1972,10 +1894,6 @@ static inline void hci_cmd_status_evt(struct hci_dev *hdev, struct sk_buff *skb) hci_cs_le_create_conn(hdev, ev->status); break; - case HCI_OP_LE_START_ENC: - hci_cs_le_start_enc(hdev, ev->status); - break; - default: BT_DBG("%s opcode 0x%x", hdev->name, opcode); break; @@ -2740,8 +2658,6 @@ static inline void hci_le_conn_complete_evt(struct hci_dev *hdev, struct sk_buff hci_dev_unlock(hdev); return; } - - conn->dst_type = ev->bdaddr_type; } if (ev->status) { @@ -2754,7 +2670,6 @@ static inline void hci_le_conn_complete_evt(struct hci_dev *hdev, struct sk_buff mgmt_connected(hdev->id, &ev->bdaddr); - conn->sec_level = BT_SECURITY_LOW; conn->handle = __le16_to_cpu(ev->handle); conn->state = BT_CONNECTED; @@ -2767,49 +2682,6 @@ static inline void hci_le_conn_complete_evt(struct hci_dev *hdev, struct sk_buff hci_dev_unlock(hdev); } -static inline void hci_le_adv_report_evt(struct hci_dev *hdev, - struct sk_buff *skb) -{ - struct hci_ev_le_advertising_info *ev; - u8 num_reports; - - num_reports = skb->data[0]; - ev = (void *) &skb->data[1]; - - hci_dev_lock(hdev); - - hci_add_adv_entry(hdev, ev); - - while (--num_reports) { - ev = (void *) (ev->data + ev->length + 1); - hci_add_adv_entry(hdev, ev); - } - - hci_dev_unlock(hdev); -} - -static inline void hci_le_ltk_request_evt(struct hci_dev *hdev, - struct sk_buff *skb) -{ - struct hci_ev_le_ltk_req *ev = (void *) skb->data; - struct hci_cp_le_ltk_reply cp; - struct hci_conn *conn; - - BT_DBG("%s handle %d", hdev->name, cpu_to_le16(ev->handle)); - - hci_dev_lock(hdev); - - conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); - - memset(&cp, 0, sizeof(cp)); - cp.handle = cpu_to_le16(conn->handle); - memcpy(cp.ltk, conn->ltk, sizeof(conn->ltk)); - - hci_send_cmd(hdev, HCI_OP_LE_LTK_REPLY, sizeof(cp), &cp); - - hci_dev_unlock(hdev); -} - static inline void hci_le_meta_evt(struct hci_dev *hdev, struct sk_buff *skb) { struct hci_ev_le_meta *le_ev = (void *) skb->data; @@ -2821,14 +2693,6 @@ static inline void hci_le_meta_evt(struct hci_dev *hdev, struct sk_buff *skb) hci_le_conn_complete_evt(hdev, skb); break; - case HCI_EV_LE_ADVERTISING_REPORT: - hci_le_adv_report_evt(hdev, skb); - break; - - case HCI_EV_LE_LTK_REQ: - hci_le_ltk_request_evt(hdev, skb); - break; - default: break; } diff --git a/trunk/net/bluetooth/hci_sock.c b/trunk/net/bluetooth/hci_sock.c index ff02cf5e77cc..295e4a88fff8 100644 --- a/trunk/net/bluetooth/hci_sock.c +++ b/trunk/net/bluetooth/hci_sock.c @@ -180,24 +180,82 @@ static int hci_sock_release(struct socket *sock) return 0; } -static int hci_sock_blacklist_add(struct hci_dev *hdev, void __user *arg) +struct bdaddr_list *hci_blacklist_lookup(struct hci_dev *hdev, bdaddr_t *bdaddr) +{ + struct list_head *p; + + list_for_each(p, &hdev->blacklist) { + struct bdaddr_list *b; + + b = list_entry(p, struct bdaddr_list, list); + + if (bacmp(bdaddr, &b->bdaddr) == 0) + return b; + } + + return NULL; +} + +static int hci_blacklist_add(struct hci_dev *hdev, void __user *arg) { bdaddr_t bdaddr; + struct bdaddr_list *entry; if (copy_from_user(&bdaddr, arg, sizeof(bdaddr))) return -EFAULT; - return hci_blacklist_add(hdev, &bdaddr); + if (bacmp(&bdaddr, BDADDR_ANY) == 0) + return -EBADF; + + if (hci_blacklist_lookup(hdev, &bdaddr)) + return -EEXIST; + + entry = kzalloc(sizeof(struct bdaddr_list), GFP_KERNEL); + if (!entry) + return -ENOMEM; + + bacpy(&entry->bdaddr, &bdaddr); + + list_add(&entry->list, &hdev->blacklist); + + return 0; +} + +int hci_blacklist_clear(struct hci_dev *hdev) +{ + struct list_head *p, *n; + + list_for_each_safe(p, n, &hdev->blacklist) { + struct bdaddr_list *b; + + b = list_entry(p, struct bdaddr_list, list); + + list_del(p); + kfree(b); + } + + return 0; } -static int hci_sock_blacklist_del(struct hci_dev *hdev, void __user *arg) +static int hci_blacklist_del(struct hci_dev *hdev, void __user *arg) { bdaddr_t bdaddr; + struct bdaddr_list *entry; if (copy_from_user(&bdaddr, arg, sizeof(bdaddr))) return -EFAULT; - return hci_blacklist_del(hdev, &bdaddr); + if (bacmp(&bdaddr, BDADDR_ANY) == 0) + return hci_blacklist_clear(hdev); + + entry = hci_blacklist_lookup(hdev, &bdaddr); + if (!entry) + return -ENOENT; + + list_del(&entry->list); + kfree(entry); + + return 0; } /* Ioctls that require bound socket */ @@ -232,12 +290,12 @@ static inline int hci_sock_bound_ioctl(struct sock *sk, unsigned int cmd, unsign case HCIBLOCKADDR: if (!capable(CAP_NET_ADMIN)) return -EACCES; - return hci_sock_blacklist_add(hdev, (void __user *) arg); + return hci_blacklist_add(hdev, (void __user *) arg); case HCIUNBLOCKADDR: if (!capable(CAP_NET_ADMIN)) return -EACCES; - return hci_sock_blacklist_del(hdev, (void __user *) arg); + return hci_blacklist_del(hdev, (void __user *) arg); default: if (hdev->ioctl) diff --git a/trunk/net/bluetooth/hidp/core.c b/trunk/net/bluetooth/hidp/core.c index 43b4c2deb7cc..c405a954a603 100644 --- a/trunk/net/bluetooth/hidp/core.c +++ b/trunk/net/bluetooth/hidp/core.c @@ -464,8 +464,7 @@ static void hidp_idle_timeout(unsigned long arg) { struct hidp_session *session = (struct hidp_session *) arg; - atomic_inc(&session->terminate); - wake_up_process(session->task); + kthread_stop(session->task); } static void hidp_set_timer(struct hidp_session *session) @@ -536,8 +535,7 @@ static void hidp_process_hid_control(struct hidp_session *session, skb_queue_purge(&session->ctrl_transmit); skb_queue_purge(&session->intr_transmit); - atomic_inc(&session->terminate); - wake_up_process(current); + kthread_stop(session->task); } } @@ -708,8 +706,9 @@ static int hidp_session(void *arg) add_wait_queue(sk_sleep(intr_sk), &intr_wait); session->waiting_for_startup = 0; wake_up_interruptible(&session->startup_queue); - set_current_state(TASK_INTERRUPTIBLE); - while (!atomic_read(&session->terminate)) { + while (!kthread_should_stop()) { + set_current_state(TASK_INTERRUPTIBLE); + if (ctrl_sk->sk_state != BT_CONNECTED || intr_sk->sk_state != BT_CONNECTED) break; @@ -727,7 +726,6 @@ static int hidp_session(void *arg) hidp_process_transmit(session); schedule(); - set_current_state(TASK_INTERRUPTIBLE); } set_current_state(TASK_RUNNING); remove_wait_queue(sk_sleep(intr_sk), &intr_wait); @@ -1062,8 +1060,7 @@ int hidp_add_connection(struct hidp_connadd_req *req, struct socket *ctrl_sock, err_add_device: hid_destroy_device(session->hid); session->hid = NULL; - atomic_inc(&session->terminate); - wake_up_process(session->task); + kthread_stop(session->task); unlink: hidp_del_timer(session); @@ -1114,8 +1111,7 @@ int hidp_del_connection(struct hidp_conndel_req *req) skb_queue_purge(&session->ctrl_transmit); skb_queue_purge(&session->intr_transmit); - atomic_inc(&session->terminate); - wake_up_process(session->task); + kthread_stop(session->task); } } else err = -ENOENT; diff --git a/trunk/net/bluetooth/hidp/hidp.h b/trunk/net/bluetooth/hidp/hidp.h index af1bcc823f26..19e95004b286 100644 --- a/trunk/net/bluetooth/hidp/hidp.h +++ b/trunk/net/bluetooth/hidp/hidp.h @@ -142,7 +142,6 @@ struct hidp_session { uint ctrl_mtu; uint intr_mtu; - atomic_t terminate; struct task_struct *task; unsigned char keys[8]; diff --git a/trunk/net/bluetooth/l2cap_core.c b/trunk/net/bluetooth/l2cap_core.c index fc219ec28711..e64a1c2df238 100644 --- a/trunk/net/bluetooth/l2cap_core.c +++ b/trunk/net/bluetooth/l2cap_core.c @@ -54,7 +54,6 @@ #include #include #include -#include int disable_ertm; @@ -63,34 +62,18 @@ static u8 l2cap_fixed_chan[8] = { 0x02, }; static struct workqueue_struct *_busy_wq; -static LIST_HEAD(chan_list); -static DEFINE_RWLOCK(chan_list_lock); +LIST_HEAD(chan_list); +DEFINE_RWLOCK(chan_list_lock); static void l2cap_busy_work(struct work_struct *work); static struct sk_buff *l2cap_build_cmd(struct l2cap_conn *conn, u8 code, u8 ident, u16 dlen, void *data); -static void l2cap_send_cmd(struct l2cap_conn *conn, u8 ident, u8 code, u16 len, - void *data); static int l2cap_build_conf_req(struct l2cap_chan *chan, void *data); -static void l2cap_send_disconn_req(struct l2cap_conn *conn, - struct l2cap_chan *chan, int err); static int l2cap_ertm_data_rcv(struct sock *sk, struct sk_buff *skb); /* ---- L2CAP channels ---- */ - -static inline void chan_hold(struct l2cap_chan *c) -{ - atomic_inc(&c->refcnt); -} - -static inline void chan_put(struct l2cap_chan *c) -{ - if (atomic_dec_and_test(&c->refcnt)) - kfree(c); -} - static struct l2cap_chan *__l2cap_get_chan_by_dcid(struct l2cap_conn *conn, u16 cid) { struct l2cap_chan *c; @@ -221,62 +204,6 @@ static u16 l2cap_alloc_cid(struct l2cap_conn *conn) return 0; } -static void l2cap_set_timer(struct l2cap_chan *chan, struct timer_list *timer, long timeout) -{ - BT_DBG("chan %p state %d timeout %ld", chan->sk, chan->state, timeout); - - if (!mod_timer(timer, jiffies + timeout)) - chan_hold(chan); -} - -static void l2cap_clear_timer(struct l2cap_chan *chan, struct timer_list *timer) -{ - BT_DBG("chan %p state %d", chan, chan->state); - - if (timer_pending(timer) && del_timer(timer)) - chan_put(chan); -} - -static void l2cap_state_change(struct l2cap_chan *chan, int state) -{ - chan->state = state; - chan->ops->state_change(chan->data, state); -} - -static void l2cap_chan_timeout(unsigned long arg) -{ - struct l2cap_chan *chan = (struct l2cap_chan *) arg; - struct sock *sk = chan->sk; - int reason; - - BT_DBG("chan %p state %d", chan, chan->state); - - bh_lock_sock(sk); - - if (sock_owned_by_user(sk)) { - /* sk is owned by user. Try again later */ - __set_chan_timer(chan, HZ / 5); - bh_unlock_sock(sk); - chan_put(chan); - return; - } - - if (chan->state == BT_CONNECTED || chan->state == BT_CONFIG) - reason = ECONNREFUSED; - else if (chan->state == BT_CONNECT && - chan->sec_level != BT_SECURITY_SDP) - reason = ECONNREFUSED; - else - reason = ETIMEDOUT; - - l2cap_chan_close(chan, reason); - - bh_unlock_sock(sk); - - chan->ops->close(chan->data); - chan_put(chan); -} - struct l2cap_chan *l2cap_chan_create(struct sock *sk) { struct l2cap_chan *chan; @@ -291,12 +218,6 @@ struct l2cap_chan *l2cap_chan_create(struct sock *sk) list_add(&chan->global_l, &chan_list); write_unlock_bh(&chan_list_lock); - setup_timer(&chan->chan_timer, l2cap_chan_timeout, (unsigned long) chan); - - chan->state = BT_OPEN; - - atomic_set(&chan->refcnt, 1); - return chan; } @@ -306,11 +227,13 @@ void l2cap_chan_destroy(struct l2cap_chan *chan) list_del(&chan->global_l); write_unlock_bh(&chan_list_lock); - chan_put(chan); + kfree(chan); } static void __l2cap_chan_add(struct l2cap_conn *conn, struct l2cap_chan *chan) { + struct sock *sk = chan->sk; + BT_DBG("conn %p, psm 0x%2.2x, dcid 0x%4.4x", conn, chan->psm, chan->dcid); @@ -318,7 +241,7 @@ static void __l2cap_chan_add(struct l2cap_conn *conn, struct l2cap_chan *chan) chan->conn = conn; - if (chan->chan_type == L2CAP_CHAN_CONN_ORIENTED) { + if (sk->sk_type == SOCK_SEQPACKET || sk->sk_type == SOCK_STREAM) { if (conn->hcon->type == LE_LINK) { /* LE connection */ chan->omtu = L2CAP_LE_DEFAULT_MTU; @@ -329,7 +252,7 @@ static void __l2cap_chan_add(struct l2cap_conn *conn, struct l2cap_chan *chan) chan->scid = l2cap_alloc_cid(conn); chan->omtu = L2CAP_DEFAULT_MTU; } - } else if (chan->chan_type == L2CAP_CHAN_CONN_LESS) { + } else if (sk->sk_type == SOCK_DGRAM) { /* Connectionless socket */ chan->scid = L2CAP_CID_CONN_LESS; chan->dcid = L2CAP_CID_CONN_LESS; @@ -341,20 +264,20 @@ static void __l2cap_chan_add(struct l2cap_conn *conn, struct l2cap_chan *chan) chan->omtu = L2CAP_DEFAULT_MTU; } - chan_hold(chan); + sock_hold(sk); list_add(&chan->list, &conn->chan_l); } /* Delete channel. * Must be called on the locked socket. */ -static void l2cap_chan_del(struct l2cap_chan *chan, int err) +void l2cap_chan_del(struct l2cap_chan *chan, int err) { struct sock *sk = chan->sk; struct l2cap_conn *conn = chan->conn; struct sock *parent = bt_sk(sk)->parent; - __clear_chan_timer(chan); + l2cap_sock_clear_timer(sk); BT_DBG("chan %p, conn %p, err %d", chan, conn, err); @@ -363,13 +286,13 @@ static void l2cap_chan_del(struct l2cap_chan *chan, int err) write_lock_bh(&conn->chan_lock); list_del(&chan->list); write_unlock_bh(&conn->chan_lock); - chan_put(chan); + __sock_put(sk); chan->conn = NULL; hci_conn_put(conn->hcon); } - l2cap_state_change(chan, BT_CLOSED); + sk->sk_state = BT_CLOSED; sock_set_flag(sk, SOCK_ZAPPED); if (err) @@ -381,8 +304,8 @@ static void l2cap_chan_del(struct l2cap_chan *chan, int err) } else sk->sk_state_change(sk); - if (!(test_bit(CONF_OUTPUT_DONE, &chan->conf_state) && - test_bit(CONF_INPUT_DONE, &chan->conf_state))) + if (!(chan->conf_state & L2CAP_CONF_OUTPUT_DONE && + chan->conf_state & L2CAP_CONF_INPUT_DONE)) return; skb_queue_purge(&chan->tx_q); @@ -390,9 +313,9 @@ static void l2cap_chan_del(struct l2cap_chan *chan, int err) if (chan->mode == L2CAP_MODE_ERTM) { struct srej_list *l, *tmp; - __clear_retrans_timer(chan); - __clear_monitor_timer(chan); - __clear_ack_timer(chan); + del_timer(&chan->retrans_timer); + del_timer(&chan->monitor_timer); + del_timer(&chan->ack_timer); skb_queue_purge(&chan->srej_q); skb_queue_purge(&chan->busy_q); @@ -404,86 +327,11 @@ static void l2cap_chan_del(struct l2cap_chan *chan, int err) } } -static void l2cap_chan_cleanup_listen(struct sock *parent) -{ - struct sock *sk; - - BT_DBG("parent %p", parent); - - /* Close not yet accepted channels */ - while ((sk = bt_accept_dequeue(parent, NULL))) { - struct l2cap_chan *chan = l2cap_pi(sk)->chan; - __clear_chan_timer(chan); - lock_sock(sk); - l2cap_chan_close(chan, ECONNRESET); - release_sock(sk); - chan->ops->close(chan->data); - } -} - -void l2cap_chan_close(struct l2cap_chan *chan, int reason) +static inline u8 l2cap_get_auth_type(struct l2cap_chan *chan) { - struct l2cap_conn *conn = chan->conn; struct sock *sk = chan->sk; - BT_DBG("chan %p state %d socket %p", chan, chan->state, sk->sk_socket); - - switch (chan->state) { - case BT_LISTEN: - l2cap_chan_cleanup_listen(sk); - - l2cap_state_change(chan, BT_CLOSED); - sock_set_flag(sk, SOCK_ZAPPED); - break; - - case BT_CONNECTED: - case BT_CONFIG: - if (chan->chan_type == L2CAP_CHAN_CONN_ORIENTED && - conn->hcon->type == ACL_LINK) { - __clear_chan_timer(chan); - __set_chan_timer(chan, sk->sk_sndtimeo); - l2cap_send_disconn_req(conn, chan, reason); - } else - l2cap_chan_del(chan, reason); - break; - - case BT_CONNECT2: - if (chan->chan_type == L2CAP_CHAN_CONN_ORIENTED && - conn->hcon->type == ACL_LINK) { - struct l2cap_conn_rsp rsp; - __u16 result; - - if (bt_sk(sk)->defer_setup) - result = L2CAP_CR_SEC_BLOCK; - else - result = L2CAP_CR_BAD_PSM; - l2cap_state_change(chan, BT_DISCONN); - - rsp.scid = cpu_to_le16(chan->dcid); - rsp.dcid = cpu_to_le16(chan->scid); - rsp.result = cpu_to_le16(result); - rsp.status = cpu_to_le16(L2CAP_CS_NO_INFO); - l2cap_send_cmd(conn, chan->ident, L2CAP_CONN_RSP, - sizeof(rsp), &rsp); - } - - l2cap_chan_del(chan, reason); - break; - - case BT_CONNECT: - case BT_DISCONN: - l2cap_chan_del(chan, reason); - break; - - default: - sock_set_flag(sk, SOCK_ZAPPED); - break; - } -} - -static inline u8 l2cap_get_auth_type(struct l2cap_chan *chan) -{ - if (chan->chan_type == L2CAP_CHAN_RAW) { + if (sk->sk_type == SOCK_RAW) { switch (chan->sec_level) { case BT_SECURITY_HIGH: return HCI_AT_DEDICATED_BONDING_MITM; @@ -523,7 +371,7 @@ static inline int l2cap_check_security(struct l2cap_chan *chan) return hci_conn_security(conn->hcon, chan->sec_level, auth_type); } -static u8 l2cap_get_ident(struct l2cap_conn *conn) +u8 l2cap_get_ident(struct l2cap_conn *conn) { u8 id; @@ -545,7 +393,7 @@ static u8 l2cap_get_ident(struct l2cap_conn *conn) return id; } -static void l2cap_send_cmd(struct l2cap_conn *conn, u8 ident, u8 code, u16 len, void *data) +void l2cap_send_cmd(struct l2cap_conn *conn, u8 ident, u8 code, u16 len, void *data) { struct sk_buff *skb = l2cap_build_cmd(conn, code, ident, len, data); u8 flags; @@ -560,8 +408,6 @@ static void l2cap_send_cmd(struct l2cap_conn *conn, u8 ident, u8 code, u16 len, else flags = ACL_START; - bt_cb(skb)->force_active = BT_POWER_FORCE_ACTIVE_ON; - hci_send_acl(conn->hcon, skb, flags); } @@ -569,11 +415,13 @@ static inline void l2cap_send_sframe(struct l2cap_chan *chan, u16 control) { struct sk_buff *skb; struct l2cap_hdr *lh; + struct l2cap_pinfo *pi = l2cap_pi(chan->sk); struct l2cap_conn *conn = chan->conn; + struct sock *sk = (struct sock *)pi; int count, hlen = L2CAP_HDR_SIZE + 2; u8 flags; - if (chan->state != BT_CONNECTED) + if (sk->sk_state != BT_CONNECTED) return; if (chan->fcs == L2CAP_FCS_CRC16) @@ -584,11 +432,15 @@ static inline void l2cap_send_sframe(struct l2cap_chan *chan, u16 control) count = min_t(unsigned int, conn->mtu, hlen); control |= L2CAP_CTRL_FRAME_TYPE; - if (test_and_clear_bit(CONN_SEND_FBIT, &chan->conn_state)) + if (chan->conn_state & L2CAP_CONN_SEND_FBIT) { control |= L2CAP_CTRL_FINAL; + chan->conn_state &= ~L2CAP_CONN_SEND_FBIT; + } - if (test_and_clear_bit(CONN_SEND_PBIT, &chan->conn_state)) + if (chan->conn_state & L2CAP_CONN_SEND_PBIT) { control |= L2CAP_CTRL_POLL; + chan->conn_state &= ~L2CAP_CONN_SEND_PBIT; + } skb = bt_skb_alloc(count, GFP_ATOMIC); if (!skb) @@ -609,16 +461,14 @@ static inline void l2cap_send_sframe(struct l2cap_chan *chan, u16 control) else flags = ACL_START; - bt_cb(skb)->force_active = chan->force_active; - hci_send_acl(chan->conn->hcon, skb, flags); } static inline void l2cap_send_rr_or_rnr(struct l2cap_chan *chan, u16 control) { - if (test_bit(CONN_LOCAL_BUSY, &chan->conn_state)) { + if (chan->conn_state & L2CAP_CONN_LOCAL_BUSY) { control |= L2CAP_SUPER_RCV_NOT_READY; - set_bit(CONN_RNR_SENT, &chan->conn_state); + chan->conn_state |= L2CAP_CONN_RNR_SENT; } else control |= L2CAP_SUPER_RCV_READY; @@ -629,7 +479,7 @@ static inline void l2cap_send_rr_or_rnr(struct l2cap_chan *chan, u16 control) static inline int __l2cap_no_conn_pending(struct l2cap_chan *chan) { - return !test_bit(CONF_CONNECT_PEND, &chan->conf_state); + return !(chan->conf_state & L2CAP_CONF_CONNECT_PEND); } static void l2cap_do_start(struct l2cap_chan *chan) @@ -647,7 +497,7 @@ static void l2cap_do_start(struct l2cap_chan *chan) req.psm = chan->psm; chan->ident = l2cap_get_ident(conn); - set_bit(CONF_CONNECT_PEND, &chan->conf_state); + chan->conf_state |= L2CAP_CONF_CONNECT_PEND; l2cap_send_cmd(conn, chan->ident, L2CAP_CONN_REQ, sizeof(req), &req); @@ -683,7 +533,7 @@ static inline int l2cap_mode_supported(__u8 mode, __u32 feat_mask) } } -static void l2cap_send_disconn_req(struct l2cap_conn *conn, struct l2cap_chan *chan, int err) +void l2cap_send_disconn_req(struct l2cap_conn *conn, struct l2cap_chan *chan, int err) { struct sock *sk; struct l2cap_disconn_req req; @@ -694,9 +544,9 @@ static void l2cap_send_disconn_req(struct l2cap_conn *conn, struct l2cap_chan *c sk = chan->sk; if (chan->mode == L2CAP_MODE_ERTM) { - __clear_retrans_timer(chan); - __clear_monitor_timer(chan); - __clear_ack_timer(chan); + del_timer(&chan->retrans_timer); + del_timer(&chan->monitor_timer); + del_timer(&chan->ack_timer); } req.dcid = cpu_to_le16(chan->dcid); @@ -704,7 +554,7 @@ static void l2cap_send_disconn_req(struct l2cap_conn *conn, struct l2cap_chan *c l2cap_send_cmd(conn, l2cap_get_ident(conn), L2CAP_DISCONN_REQ, sizeof(req), &req); - l2cap_state_change(chan, BT_DISCONN); + sk->sk_state = BT_DISCONN; sk->sk_err = err; } @@ -722,12 +572,13 @@ static void l2cap_conn_start(struct l2cap_conn *conn) bh_lock_sock(sk); - if (chan->chan_type != L2CAP_CHAN_CONN_ORIENTED) { + if (sk->sk_type != SOCK_SEQPACKET && + sk->sk_type != SOCK_STREAM) { bh_unlock_sock(sk); continue; } - if (chan->state == BT_CONNECT) { + if (sk->sk_state == BT_CONNECT) { struct l2cap_conn_req req; if (!l2cap_check_security(chan) || @@ -736,13 +587,14 @@ static void l2cap_conn_start(struct l2cap_conn *conn) continue; } - if (!l2cap_mode_supported(chan->mode, conn->feat_mask) - && test_bit(CONF_STATE2_DEVICE, - &chan->conf_state)) { - /* l2cap_chan_close() calls list_del(chan) + if (!l2cap_mode_supported(chan->mode, + conn->feat_mask) + && chan->conf_state & + L2CAP_CONF_STATE2_DEVICE) { + /* __l2cap_sock_close() calls list_del(chan) * so release the lock */ read_unlock_bh(&conn->chan_lock); - l2cap_chan_close(chan, ECONNRESET); + __l2cap_sock_close(sk, ECONNRESET); read_lock_bh(&conn->chan_lock); bh_unlock_sock(sk); continue; @@ -752,12 +604,12 @@ static void l2cap_conn_start(struct l2cap_conn *conn) req.psm = chan->psm; chan->ident = l2cap_get_ident(conn); - set_bit(CONF_CONNECT_PEND, &chan->conf_state); + chan->conf_state |= L2CAP_CONF_CONNECT_PEND; l2cap_send_cmd(conn, chan->ident, L2CAP_CONN_REQ, sizeof(req), &req); - } else if (chan->state == BT_CONNECT2) { + } else if (sk->sk_state == BT_CONNECT2) { struct l2cap_conn_rsp rsp; char buf[128]; rsp.scid = cpu_to_le16(chan->dcid); @@ -771,7 +623,7 @@ static void l2cap_conn_start(struct l2cap_conn *conn) parent->sk_data_ready(parent, 0); } else { - l2cap_state_change(chan, BT_CONFIG); + sk->sk_state = BT_CONFIG; rsp.result = cpu_to_le16(L2CAP_CR_SUCCESS); rsp.status = cpu_to_le16(L2CAP_CS_NO_INFO); } @@ -783,13 +635,13 @@ static void l2cap_conn_start(struct l2cap_conn *conn) l2cap_send_cmd(conn, chan->ident, L2CAP_CONN_RSP, sizeof(rsp), &rsp); - if (test_bit(CONF_REQ_SENT, &chan->conf_state) || + if (chan->conf_state & L2CAP_CONF_REQ_SENT || rsp.result != L2CAP_CR_SUCCESS) { bh_unlock_sock(sk); continue; } - set_bit(CONF_REQ_SENT, &chan->conf_state); + chan->conf_state |= L2CAP_CONF_REQ_SENT; l2cap_send_cmd(conn, l2cap_get_ident(conn), L2CAP_CONF_REQ, l2cap_build_conf_req(chan, buf), buf); chan->num_conf_req++; @@ -813,7 +665,7 @@ static struct l2cap_chan *l2cap_global_chan_by_scid(int state, __le16 cid, bdadd list_for_each_entry(c, &chan_list, global_l) { struct sock *sk = c->sk; - if (state && c->state != state) + if (state && sk->sk_state != state) continue; if (c->scid == cid) { @@ -857,16 +709,24 @@ static void l2cap_le_conn_ready(struct l2cap_conn *conn) goto clean; } - chan = pchan->ops->new_connection(pchan->data); - if (!chan) + sk = l2cap_sock_alloc(sock_net(parent), NULL, BTPROTO_L2CAP, GFP_ATOMIC); + if (!sk) goto clean; - sk = chan->sk; + chan = l2cap_chan_create(sk); + if (!chan) { + l2cap_sock_kill(sk); + goto clean; + } + + l2cap_pi(sk)->chan = chan; write_lock_bh(&conn->chan_lock); hci_conn_hold(conn->hcon); + l2cap_sock_init(sk, parent); + bacpy(&bt_sk(sk)->src, conn->src); bacpy(&bt_sk(sk)->dst, conn->dst); @@ -874,9 +734,9 @@ static void l2cap_le_conn_ready(struct l2cap_conn *conn) __l2cap_chan_add(conn, chan); - __set_chan_timer(chan, sk->sk_sndtimeo); + l2cap_sock_set_timer(sk, sk->sk_sndtimeo); - l2cap_state_change(chan, BT_CONNECTED); + sk->sk_state = BT_CONNECTED; parent->sk_data_ready(parent, 0); write_unlock_bh(&conn->chan_lock); @@ -885,23 +745,6 @@ static void l2cap_le_conn_ready(struct l2cap_conn *conn) bh_unlock_sock(parent); } -static void l2cap_chan_ready(struct sock *sk) -{ - struct l2cap_chan *chan = l2cap_pi(sk)->chan; - struct sock *parent = bt_sk(sk)->parent; - - BT_DBG("sk %p, parent %p", sk, parent); - - chan->conf_state = 0; - __clear_chan_timer(chan); - - l2cap_state_change(chan, BT_CONNECTED); - sk->sk_state_change(sk); - - if (parent) - parent->sk_data_ready(parent, 0); -} - static void l2cap_conn_ready(struct l2cap_conn *conn) { struct l2cap_chan *chan; @@ -919,15 +762,17 @@ static void l2cap_conn_ready(struct l2cap_conn *conn) bh_lock_sock(sk); if (conn->hcon->type == LE_LINK) { - if (smp_conn_security(conn, chan->sec_level)) - l2cap_chan_ready(sk); - - } else if (chan->chan_type != L2CAP_CHAN_CONN_ORIENTED) { - __clear_chan_timer(chan); - l2cap_state_change(chan, BT_CONNECTED); + l2cap_sock_clear_timer(sk); + sk->sk_state = BT_CONNECTED; sk->sk_state_change(sk); + } - } else if (chan->state == BT_CONNECT) + if (sk->sk_type != SOCK_SEQPACKET && + sk->sk_type != SOCK_STREAM) { + l2cap_sock_clear_timer(sk); + sk->sk_state = BT_CONNECTED; + sk->sk_state_change(sk); + } else if (sk->sk_state == BT_CONNECT) l2cap_do_start(chan); bh_unlock_sock(sk); @@ -965,45 +810,6 @@ static void l2cap_info_timeout(unsigned long arg) l2cap_conn_start(conn); } -static void l2cap_conn_del(struct hci_conn *hcon, int err) -{ - struct l2cap_conn *conn = hcon->l2cap_data; - struct l2cap_chan *chan, *l; - struct sock *sk; - - if (!conn) - return; - - BT_DBG("hcon %p conn %p, err %d", hcon, conn, err); - - kfree_skb(conn->rx_skb); - - /* Kill channels */ - list_for_each_entry_safe(chan, l, &conn->chan_l, list) { - sk = chan->sk; - bh_lock_sock(sk); - l2cap_chan_del(chan, err); - bh_unlock_sock(sk); - chan->ops->close(chan->data); - } - - if (conn->info_state & L2CAP_INFO_FEAT_MASK_REQ_SENT) - del_timer_sync(&conn->info_timer); - - if (test_bit(HCI_CONN_ENCRYPT_PEND, &hcon->pend)) - del_timer(&conn->security_timer); - - hcon->l2cap_data = NULL; - kfree(conn); -} - -static void security_timeout(unsigned long arg) -{ - struct l2cap_conn *conn = (void *) arg; - - l2cap_conn_del(conn->hcon, ETIMEDOUT); -} - static struct l2cap_conn *l2cap_conn_add(struct hci_conn *hcon, u8 status) { struct l2cap_conn *conn = hcon->l2cap_data; @@ -1035,10 +841,7 @@ static struct l2cap_conn *l2cap_conn_add(struct hci_conn *hcon, u8 status) INIT_LIST_HEAD(&conn->chan_l); - if (hcon->type == LE_LINK) - setup_timer(&conn->security_timer, security_timeout, - (unsigned long) conn); - else + if (hcon->type != LE_LINK) setup_timer(&conn->info_timer, l2cap_info_timeout, (unsigned long) conn); @@ -1047,6 +850,35 @@ static struct l2cap_conn *l2cap_conn_add(struct hci_conn *hcon, u8 status) return conn; } +static void l2cap_conn_del(struct hci_conn *hcon, int err) +{ + struct l2cap_conn *conn = hcon->l2cap_data; + struct l2cap_chan *chan, *l; + struct sock *sk; + + if (!conn) + return; + + BT_DBG("hcon %p conn %p, err %d", hcon, conn, err); + + kfree_skb(conn->rx_skb); + + /* Kill channels */ + list_for_each_entry_safe(chan, l, &conn->chan_l, list) { + sk = chan->sk; + bh_lock_sock(sk); + l2cap_chan_del(chan, err); + bh_unlock_sock(sk); + l2cap_sock_kill(sk); + } + + if (conn->info_state & L2CAP_INFO_FEAT_MASK_REQ_SENT) + del_timer_sync(&conn->info_timer); + + hcon->l2cap_data = NULL; + kfree(conn); +} + static inline void l2cap_chan_add(struct l2cap_conn *conn, struct l2cap_chan *chan) { write_lock_bh(&conn->chan_lock); @@ -1068,7 +900,7 @@ static struct l2cap_chan *l2cap_global_chan_by_psm(int state, __le16 psm, bdaddr list_for_each_entry(c, &chan_list, global_l) { struct sock *sk = c->sk; - if (state && c->state != state) + if (state && sk->sk_state != state) continue; if (c->psm == psm) { @@ -1135,14 +967,15 @@ int l2cap_chan_connect(struct l2cap_chan *chan) l2cap_chan_add(conn, chan); - l2cap_state_change(chan, BT_CONNECT); - __set_chan_timer(chan, sk->sk_sndtimeo); + sk->sk_state = BT_CONNECT; + l2cap_sock_set_timer(sk, sk->sk_sndtimeo); if (hcon->state == BT_CONNECTED) { - if (chan->chan_type != L2CAP_CHAN_CONN_ORIENTED) { - __clear_chan_timer(chan); + if (sk->sk_type != SOCK_SEQPACKET && + sk->sk_type != SOCK_STREAM) { + l2cap_sock_clear_timer(sk); if (l2cap_check_security(chan)) - l2cap_state_change(chan, BT_CONNECTED); + sk->sk_state = BT_CONNECTED; } else l2cap_do_start(chan); } @@ -1202,7 +1035,7 @@ static void l2cap_monitor_timeout(unsigned long arg) } chan->retry_count++; - __set_monitor_timer(chan); + __mod_monitor_timer(); l2cap_send_rr_or_rnr(chan, L2CAP_CTRL_POLL); bh_unlock_sock(sk); @@ -1217,9 +1050,9 @@ static void l2cap_retrans_timeout(unsigned long arg) bh_lock_sock(sk); chan->retry_count = 1; - __set_monitor_timer(chan); + __mod_monitor_timer(); - set_bit(CONN_WAIT_F, &chan->conn_state); + chan->conn_state |= L2CAP_CONN_WAIT_F; l2cap_send_rr_or_rnr(chan, L2CAP_CTRL_POLL); bh_unlock_sock(sk); @@ -1241,7 +1074,7 @@ static void l2cap_drop_acked_frames(struct l2cap_chan *chan) } if (!chan->unacked_frames) - __clear_retrans_timer(chan); + del_timer(&chan->retrans_timer); } void l2cap_do_send(struct l2cap_chan *chan, struct sk_buff *skb) @@ -1256,7 +1089,6 @@ void l2cap_do_send(struct l2cap_chan *chan, struct sk_buff *skb) else flags = ACL_START; - bt_cb(skb)->force_active = chan->force_active; hci_send_acl(hcon, skb, flags); } @@ -1310,8 +1142,10 @@ static void l2cap_retransmit_one_frame(struct l2cap_chan *chan, u8 tx_seq) control = get_unaligned_le16(tx_skb->data + L2CAP_HDR_SIZE); control &= L2CAP_CTRL_SAR; - if (test_and_clear_bit(CONN_SEND_FBIT, &chan->conn_state)) + if (chan->conn_state & L2CAP_CONN_SEND_FBIT) { control |= L2CAP_CTRL_FINAL; + chan->conn_state &= ~L2CAP_CONN_SEND_FBIT; + } control |= (chan->buffer_seq << L2CAP_CTRL_REQSEQ_SHIFT) | (tx_seq << L2CAP_CTRL_TXSEQ_SHIFT); @@ -1329,10 +1163,11 @@ static void l2cap_retransmit_one_frame(struct l2cap_chan *chan, u8 tx_seq) int l2cap_ertm_send(struct l2cap_chan *chan) { struct sk_buff *skb, *tx_skb; + struct sock *sk = chan->sk; u16 control, fcs; int nsent = 0; - if (chan->state != BT_CONNECTED) + if (sk->sk_state != BT_CONNECTED) return -ENOTCONN; while ((skb = chan->tx_send_head) && (!l2cap_tx_window_full(chan))) { @@ -1350,9 +1185,10 @@ int l2cap_ertm_send(struct l2cap_chan *chan) control = get_unaligned_le16(tx_skb->data + L2CAP_HDR_SIZE); control &= L2CAP_CTRL_SAR; - if (test_and_clear_bit(CONN_SEND_FBIT, &chan->conn_state)) + if (chan->conn_state & L2CAP_CONN_SEND_FBIT) { control |= L2CAP_CTRL_FINAL; - + chan->conn_state &= ~L2CAP_CONN_SEND_FBIT; + } control |= (chan->buffer_seq << L2CAP_CTRL_REQSEQ_SHIFT) | (chan->next_tx_seq << L2CAP_CTRL_TXSEQ_SHIFT); put_unaligned_le16(control, tx_skb->data + L2CAP_HDR_SIZE); @@ -1365,7 +1201,7 @@ int l2cap_ertm_send(struct l2cap_chan *chan) l2cap_do_send(chan, tx_skb); - __set_retrans_timer(chan); + __mod_retrans_timer(); bt_cb(skb)->tx_seq = chan->next_tx_seq; chan->next_tx_seq = (chan->next_tx_seq + 1) % 64; @@ -1404,9 +1240,9 @@ static void l2cap_send_ack(struct l2cap_chan *chan) control |= chan->buffer_seq << L2CAP_CTRL_REQSEQ_SHIFT; - if (test_bit(CONN_LOCAL_BUSY, &chan->conn_state)) { + if (chan->conn_state & L2CAP_CONN_LOCAL_BUSY) { control |= L2CAP_SUPER_RCV_NOT_READY; - set_bit(CONN_RNR_SENT, &chan->conn_state); + chan->conn_state |= L2CAP_CONN_RNR_SENT; l2cap_send_sframe(chan, control); return; } @@ -1614,83 +1450,28 @@ int l2cap_sar_segment_sdu(struct l2cap_chan *chan, struct msghdr *msg, size_t le return size; } -int l2cap_chan_send(struct l2cap_chan *chan, struct msghdr *msg, size_t len) +static void l2cap_chan_ready(struct sock *sk) { - struct sk_buff *skb; - u16 control; - int err; - - /* Connectionless channel */ - if (chan->chan_type == L2CAP_CHAN_CONN_LESS) { - skb = l2cap_create_connless_pdu(chan, msg, len); - if (IS_ERR(skb)) - return PTR_ERR(skb); - - l2cap_do_send(chan, skb); - return len; - } - - switch (chan->mode) { - case L2CAP_MODE_BASIC: - /* Check outgoing MTU */ - if (len > chan->omtu) - return -EMSGSIZE; - - /* Create a basic PDU */ - skb = l2cap_create_basic_pdu(chan, msg, len); - if (IS_ERR(skb)) - return PTR_ERR(skb); - - l2cap_do_send(chan, skb); - err = len; - break; - - case L2CAP_MODE_ERTM: - case L2CAP_MODE_STREAMING: - /* Entire SDU fits into one PDU */ - if (len <= chan->remote_mps) { - control = L2CAP_SDU_UNSEGMENTED; - skb = l2cap_create_iframe_pdu(chan, msg, len, control, - 0); - if (IS_ERR(skb)) - return PTR_ERR(skb); - - __skb_queue_tail(&chan->tx_q, skb); - - if (chan->tx_send_head == NULL) - chan->tx_send_head = skb; - - } else { - /* Segment SDU into multiples PDUs */ - err = l2cap_sar_segment_sdu(chan, msg, len); - if (err < 0) - return err; - } - - if (chan->mode == L2CAP_MODE_STREAMING) { - l2cap_streaming_send(chan); - err = len; - break; - } - - if (test_bit(CONN_REMOTE_BUSY, &chan->conn_state) && - test_bit(CONN_WAIT_F, &chan->conn_state)) { - err = len; - break; - } + struct sock *parent = bt_sk(sk)->parent; + struct l2cap_chan *chan = l2cap_pi(sk)->chan; - err = l2cap_ertm_send(chan); - if (err >= 0) - err = len; + BT_DBG("sk %p, parent %p", sk, parent); - break; + chan->conf_state = 0; + l2cap_sock_clear_timer(sk); - default: - BT_DBG("bad state %1.1x", chan->mode); - err = -EBADFD; + if (!parent) { + /* Outgoing channel. + * Wake up socket sleeping on connect. + */ + sk->sk_state = BT_CONNECTED; + sk->sk_state_change(sk); + } else { + /* Incoming channel. + * Wake up socket sleeping on accept. + */ + parent->sk_data_ready(parent, 0); } - - return err; } /* Copy frame to all raw sockets on that connection */ @@ -1704,7 +1485,7 @@ static void l2cap_raw_recv(struct l2cap_conn *conn, struct sk_buff *skb) read_lock(&conn->chan_lock); list_for_each_entry(chan, &conn->chan_l, list) { struct sock *sk = chan->sk; - if (chan->chan_type != L2CAP_CHAN_RAW) + if (sk->sk_type != SOCK_RAW) continue; /* Don't send frame to the socket it came from */ @@ -1714,7 +1495,7 @@ static void l2cap_raw_recv(struct l2cap_conn *conn, struct sk_buff *skb) if (!nskb) continue; - if (chan->ops->recv(chan->data, nskb)) + if (sock_queue_rcv_skb(sk, nskb)) kfree_skb(nskb); } read_unlock(&conn->chan_lock); @@ -1909,7 +1690,7 @@ static int l2cap_build_conf_req(struct l2cap_chan *chan, void *data) switch (chan->mode) { case L2CAP_MODE_STREAMING: case L2CAP_MODE_ERTM: - if (test_bit(CONF_STATE2_DEVICE, &chan->conf_state)) + if (chan->conf_state & L2CAP_CONF_STATE2_DEVICE) break; /* fall through */ @@ -1956,7 +1737,7 @@ static int l2cap_build_conf_req(struct l2cap_chan *chan, void *data) break; if (chan->fcs == L2CAP_FCS_NONE || - test_bit(CONF_NO_FCS_RECV, &chan->conf_state)) { + chan->conf_state & L2CAP_CONF_NO_FCS_RECV) { chan->fcs = L2CAP_FCS_NONE; l2cap_add_conf_opt(&ptr, L2CAP_CONF_FCS, 1, chan->fcs); } @@ -1979,7 +1760,7 @@ static int l2cap_build_conf_req(struct l2cap_chan *chan, void *data) break; if (chan->fcs == L2CAP_FCS_NONE || - test_bit(CONF_NO_FCS_RECV, &chan->conf_state)) { + chan->conf_state & L2CAP_CONF_NO_FCS_RECV) { chan->fcs = L2CAP_FCS_NONE; l2cap_add_conf_opt(&ptr, L2CAP_CONF_FCS, 1, chan->fcs); } @@ -2031,7 +1812,7 @@ static int l2cap_parse_conf_req(struct l2cap_chan *chan, void *data) case L2CAP_CONF_FCS: if (val == L2CAP_FCS_NONE) - set_bit(CONF_NO_FCS_RECV, &chan->conf_state); + chan->conf_state |= L2CAP_CONF_NO_FCS_RECV; break; @@ -2051,7 +1832,7 @@ static int l2cap_parse_conf_req(struct l2cap_chan *chan, void *data) switch (chan->mode) { case L2CAP_MODE_STREAMING: case L2CAP_MODE_ERTM: - if (!test_bit(CONF_STATE2_DEVICE, &chan->conf_state)) { + if (!(chan->conf_state & L2CAP_CONF_STATE2_DEVICE)) { chan->mode = l2cap_select_mode(rfc.mode, chan->conn->feat_mask); break; @@ -2084,14 +1865,14 @@ static int l2cap_parse_conf_req(struct l2cap_chan *chan, void *data) result = L2CAP_CONF_UNACCEPT; else { chan->omtu = mtu; - set_bit(CONF_MTU_DONE, &chan->conf_state); + chan->conf_state |= L2CAP_CONF_MTU_DONE; } l2cap_add_conf_opt(&ptr, L2CAP_CONF_MTU, 2, chan->omtu); switch (rfc.mode) { case L2CAP_MODE_BASIC: chan->fcs = L2CAP_FCS_NONE; - set_bit(CONF_MODE_DONE, &chan->conf_state); + chan->conf_state |= L2CAP_CONF_MODE_DONE; break; case L2CAP_MODE_ERTM: @@ -2108,7 +1889,7 @@ static int l2cap_parse_conf_req(struct l2cap_chan *chan, void *data) rfc.monitor_timeout = le16_to_cpu(L2CAP_DEFAULT_MONITOR_TO); - set_bit(CONF_MODE_DONE, &chan->conf_state); + chan->conf_state |= L2CAP_CONF_MODE_DONE; l2cap_add_conf_opt(&ptr, L2CAP_CONF_RFC, sizeof(rfc), (unsigned long) &rfc); @@ -2121,7 +1902,7 @@ static int l2cap_parse_conf_req(struct l2cap_chan *chan, void *data) chan->remote_mps = le16_to_cpu(rfc.max_pdu_size); - set_bit(CONF_MODE_DONE, &chan->conf_state); + chan->conf_state |= L2CAP_CONF_MODE_DONE; l2cap_add_conf_opt(&ptr, L2CAP_CONF_RFC, sizeof(rfc), (unsigned long) &rfc); @@ -2136,7 +1917,7 @@ static int l2cap_parse_conf_req(struct l2cap_chan *chan, void *data) } if (result == L2CAP_CONF_SUCCESS) - set_bit(CONF_OUTPUT_DONE, &chan->conf_state); + chan->conf_state |= L2CAP_CONF_OUTPUT_DONE; } rsp->scid = cpu_to_le16(chan->dcid); rsp->result = cpu_to_le16(result); @@ -2178,7 +1959,7 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len, voi if (olen == sizeof(rfc)) memcpy(&rfc, (void *)val, olen); - if (test_bit(CONF_STATE2_DEVICE, &chan->conf_state) && + if ((chan->conf_state & L2CAP_CONF_STATE2_DEVICE) && rfc.mode != chan->mode) return -ECONNREFUSED; @@ -2240,9 +2021,10 @@ void __l2cap_connect_rsp_defer(struct l2cap_chan *chan) l2cap_send_cmd(conn, chan->ident, L2CAP_CONN_RSP, sizeof(rsp), &rsp); - if (test_and_set_bit(CONF_REQ_SENT, &chan->conf_state)) + if (chan->conf_state & L2CAP_CONF_REQ_SENT) return; + chan->conf_state |= L2CAP_CONF_REQ_SENT; l2cap_send_cmd(conn, l2cap_get_ident(conn), L2CAP_CONF_REQ, l2cap_build_conf_req(chan, buf), buf); chan->num_conf_req++; @@ -2342,11 +2124,17 @@ static inline int l2cap_connect_req(struct l2cap_conn *conn, struct l2cap_cmd_hd goto response; } - chan = pchan->ops->new_connection(pchan->data); - if (!chan) + sk = l2cap_sock_alloc(sock_net(parent), NULL, BTPROTO_L2CAP, GFP_ATOMIC); + if (!sk) goto response; - sk = chan->sk; + chan = l2cap_chan_create(sk); + if (!chan) { + l2cap_sock_kill(sk); + goto response; + } + + l2cap_pi(sk)->chan = chan; write_lock_bh(&conn->chan_lock); @@ -2354,12 +2142,13 @@ static inline int l2cap_connect_req(struct l2cap_conn *conn, struct l2cap_cmd_hd if (__l2cap_get_chan_by_dcid(conn, scid)) { write_unlock_bh(&conn->chan_lock); sock_set_flag(sk, SOCK_ZAPPED); - chan->ops->close(chan->data); + l2cap_sock_kill(sk); goto response; } hci_conn_hold(conn->hcon); + l2cap_sock_init(sk, parent); bacpy(&bt_sk(sk)->src, conn->src); bacpy(&bt_sk(sk)->dst, conn->dst); chan->psm = psm; @@ -2371,29 +2160,29 @@ static inline int l2cap_connect_req(struct l2cap_conn *conn, struct l2cap_cmd_hd dcid = chan->scid; - __set_chan_timer(chan, sk->sk_sndtimeo); + l2cap_sock_set_timer(sk, sk->sk_sndtimeo); chan->ident = cmd->ident; if (conn->info_state & L2CAP_INFO_FEAT_MASK_REQ_DONE) { if (l2cap_check_security(chan)) { if (bt_sk(sk)->defer_setup) { - l2cap_state_change(chan, BT_CONNECT2); + sk->sk_state = BT_CONNECT2; result = L2CAP_CR_PEND; status = L2CAP_CS_AUTHOR_PEND; parent->sk_data_ready(parent, 0); } else { - l2cap_state_change(chan, BT_CONFIG); + sk->sk_state = BT_CONFIG; result = L2CAP_CR_SUCCESS; status = L2CAP_CS_NO_INFO; } } else { - l2cap_state_change(chan, BT_CONNECT2); + sk->sk_state = BT_CONNECT2; result = L2CAP_CR_PEND; status = L2CAP_CS_AUTHEN_PEND; } } else { - l2cap_state_change(chan, BT_CONNECT2); + sk->sk_state = BT_CONNECT2; result = L2CAP_CR_PEND; status = L2CAP_CS_NO_INFO; } @@ -2424,10 +2213,10 @@ static inline int l2cap_connect_req(struct l2cap_conn *conn, struct l2cap_cmd_hd L2CAP_INFO_REQ, sizeof(info), &info); } - if (chan && !test_bit(CONF_REQ_SENT, &chan->conf_state) && + if (chan && !(chan->conf_state & L2CAP_CONF_REQ_SENT) && result == L2CAP_CR_SUCCESS) { u8 buf[128]; - set_bit(CONF_REQ_SENT, &chan->conf_state); + chan->conf_state |= L2CAP_CONF_REQ_SENT; l2cap_send_cmd(conn, l2cap_get_ident(conn), L2CAP_CONF_REQ, l2cap_build_conf_req(chan, buf), buf); chan->num_conf_req++; @@ -2465,29 +2254,31 @@ static inline int l2cap_connect_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hd switch (result) { case L2CAP_CR_SUCCESS: - l2cap_state_change(chan, BT_CONFIG); + sk->sk_state = BT_CONFIG; chan->ident = 0; chan->dcid = dcid; - clear_bit(CONF_CONNECT_PEND, &chan->conf_state); + chan->conf_state &= ~L2CAP_CONF_CONNECT_PEND; - if (test_and_set_bit(CONF_REQ_SENT, &chan->conf_state)) + if (chan->conf_state & L2CAP_CONF_REQ_SENT) break; + chan->conf_state |= L2CAP_CONF_REQ_SENT; + l2cap_send_cmd(conn, l2cap_get_ident(conn), L2CAP_CONF_REQ, l2cap_build_conf_req(chan, req), req); chan->num_conf_req++; break; case L2CAP_CR_PEND: - set_bit(CONF_CONNECT_PEND, &chan->conf_state); + chan->conf_state |= L2CAP_CONF_CONNECT_PEND; break; default: /* don't delete l2cap channel if sk is owned by user */ if (sock_owned_by_user(sk)) { - l2cap_state_change(chan, BT_DISCONN); - __clear_chan_timer(chan); - __set_chan_timer(chan, HZ / 5); + sk->sk_state = BT_DISCONN; + l2cap_sock_clear_timer(sk); + l2cap_sock_set_timer(sk, HZ / 5); break; } @@ -2501,12 +2292,14 @@ static inline int l2cap_connect_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hd static inline void set_default_fcs(struct l2cap_chan *chan) { + struct l2cap_pinfo *pi = l2cap_pi(chan->sk); + /* FCS is enabled only in ERTM or streaming mode, if one or both * sides request it. */ if (chan->mode != L2CAP_MODE_ERTM && chan->mode != L2CAP_MODE_STREAMING) chan->fcs = L2CAP_FCS_NONE; - else if (!test_bit(CONF_NO_FCS_RECV, &chan->conf_state)) + else if (!(pi->chan->conf_state & L2CAP_CONF_NO_FCS_RECV)) chan->fcs = L2CAP_FCS_CRC16; } @@ -2530,8 +2323,7 @@ static inline int l2cap_config_req(struct l2cap_conn *conn, struct l2cap_cmd_hdr sk = chan->sk; - if ((bt_sk(sk)->defer_setup && chan->state != BT_CONNECT2) || - (!bt_sk(sk)->defer_setup && chan->state != BT_CONFIG)) { + if (sk->sk_state != BT_CONFIG) { struct l2cap_cmd_rej rej; rej.reason = cpu_to_le16(0x0002); @@ -2542,7 +2334,7 @@ static inline int l2cap_config_req(struct l2cap_conn *conn, struct l2cap_cmd_hdr /* Reject if config buffer is too small. */ len = cmd_len - sizeof(*req); - if (len < 0 || chan->conf_len + len > sizeof(chan->conf_req)) { + if (chan->conf_len + len > sizeof(chan->conf_req)) { l2cap_send_cmd(conn, cmd->ident, L2CAP_CONF_RSP, l2cap_build_conf_rsp(chan, rsp, L2CAP_CONF_REJECT, flags), rsp); @@ -2574,13 +2366,13 @@ static inline int l2cap_config_req(struct l2cap_conn *conn, struct l2cap_cmd_hdr /* Reset config buffer. */ chan->conf_len = 0; - if (!test_bit(CONF_OUTPUT_DONE, &chan->conf_state)) + if (!(chan->conf_state & L2CAP_CONF_OUTPUT_DONE)) goto unlock; - if (test_bit(CONF_INPUT_DONE, &chan->conf_state)) { + if (chan->conf_state & L2CAP_CONF_INPUT_DONE) { set_default_fcs(chan); - l2cap_state_change(chan, BT_CONNECTED); + sk->sk_state = BT_CONNECTED; chan->next_tx_seq = 0; chan->expected_tx_seq = 0; @@ -2592,8 +2384,9 @@ static inline int l2cap_config_req(struct l2cap_conn *conn, struct l2cap_cmd_hdr goto unlock; } - if (!test_and_set_bit(CONF_REQ_SENT, &chan->conf_state)) { + if (!(chan->conf_state & L2CAP_CONF_REQ_SENT)) { u8 buf[64]; + chan->conf_state |= L2CAP_CONF_REQ_SENT; l2cap_send_cmd(conn, l2cap_get_ident(conn), L2CAP_CONF_REQ, l2cap_build_conf_req(chan, buf), buf); chan->num_conf_req++; @@ -2658,7 +2451,7 @@ static inline int l2cap_config_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hdr default: sk->sk_err = ECONNRESET; - __set_chan_timer(chan, HZ * 5); + l2cap_sock_set_timer(sk, HZ * 5); l2cap_send_disconn_req(conn, chan, ECONNRESET); goto done; } @@ -2666,12 +2459,12 @@ static inline int l2cap_config_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hdr if (flags & 0x01) goto done; - set_bit(CONF_INPUT_DONE, &chan->conf_state); + chan->conf_state |= L2CAP_CONF_INPUT_DONE; - if (test_bit(CONF_OUTPUT_DONE, &chan->conf_state)) { + if (chan->conf_state & L2CAP_CONF_OUTPUT_DONE) { set_default_fcs(chan); - l2cap_state_change(chan, BT_CONNECTED); + sk->sk_state = BT_CONNECTED; chan->next_tx_seq = 0; chan->expected_tx_seq = 0; skb_queue_head_init(&chan->tx_q); @@ -2713,9 +2506,9 @@ static inline int l2cap_disconnect_req(struct l2cap_conn *conn, struct l2cap_cmd /* don't delete l2cap channel if sk is owned by user */ if (sock_owned_by_user(sk)) { - l2cap_state_change(chan, BT_DISCONN); - __clear_chan_timer(chan); - __set_chan_timer(chan, HZ / 5); + sk->sk_state = BT_DISCONN; + l2cap_sock_clear_timer(sk); + l2cap_sock_set_timer(sk, HZ / 5); bh_unlock_sock(sk); return 0; } @@ -2723,7 +2516,7 @@ static inline int l2cap_disconnect_req(struct l2cap_conn *conn, struct l2cap_cmd l2cap_chan_del(chan, ECONNRESET); bh_unlock_sock(sk); - chan->ops->close(chan->data); + l2cap_sock_kill(sk); return 0; } @@ -2747,9 +2540,9 @@ static inline int l2cap_disconnect_rsp(struct l2cap_conn *conn, struct l2cap_cmd /* don't delete l2cap channel if sk is owned by user */ if (sock_owned_by_user(sk)) { - l2cap_state_change(chan,BT_DISCONN); - __clear_chan_timer(chan); - __set_chan_timer(chan, HZ / 5); + sk->sk_state = BT_DISCONN; + l2cap_sock_clear_timer(sk); + l2cap_sock_set_timer(sk, HZ / 5); bh_unlock_sock(sk); return 0; } @@ -2757,7 +2550,7 @@ static inline int l2cap_disconnect_rsp(struct l2cap_conn *conn, struct l2cap_cmd l2cap_chan_del(chan, 0); bh_unlock_sock(sk); - chan->ops->close(chan->data); + l2cap_sock_kill(sk); return 0; } @@ -3065,18 +2858,18 @@ static inline void l2cap_send_i_or_rr_or_rnr(struct l2cap_chan *chan) control |= chan->buffer_seq << L2CAP_CTRL_REQSEQ_SHIFT; - if (test_bit(CONN_LOCAL_BUSY, &chan->conn_state)) { + if (chan->conn_state & L2CAP_CONN_LOCAL_BUSY) { control |= L2CAP_SUPER_RCV_NOT_READY; l2cap_send_sframe(chan, control); - set_bit(CONN_RNR_SENT, &chan->conn_state); + chan->conn_state |= L2CAP_CONN_RNR_SENT; } - if (test_bit(CONN_REMOTE_BUSY, &chan->conn_state)) + if (chan->conn_state & L2CAP_CONN_REMOTE_BUSY) l2cap_retransmit_frames(chan); l2cap_ertm_send(chan); - if (!test_bit(CONN_LOCAL_BUSY, &chan->conn_state) && + if (!(chan->conn_state & L2CAP_CONN_LOCAL_BUSY) && chan->frames_sent == 0) { control |= L2CAP_SUPER_RCV_READY; l2cap_send_sframe(chan, control); @@ -3132,13 +2925,17 @@ static int l2cap_ertm_reassembly_sdu(struct l2cap_chan *chan, struct sk_buff *sk switch (control & L2CAP_CTRL_SAR) { case L2CAP_SDU_UNSEGMENTED: - if (test_bit(CONN_SAR_SDU, &chan->conn_state)) + if (chan->conn_state & L2CAP_CONN_SAR_SDU) goto drop; - return chan->ops->recv(chan->data, skb); + err = sock_queue_rcv_skb(chan->sk, skb); + if (!err) + return err; + + break; case L2CAP_SDU_START: - if (test_bit(CONN_SAR_SDU, &chan->conn_state)) + if (chan->conn_state & L2CAP_CONN_SAR_SDU) goto drop; chan->sdu_len = get_unaligned_le16(skb->data); @@ -3157,12 +2954,12 @@ static int l2cap_ertm_reassembly_sdu(struct l2cap_chan *chan, struct sk_buff *sk memcpy(skb_put(chan->sdu, skb->len), skb->data, skb->len); - set_bit(CONN_SAR_SDU, &chan->conn_state); + chan->conn_state |= L2CAP_CONN_SAR_SDU; chan->partial_sdu_len = skb->len; break; case L2CAP_SDU_CONTINUE: - if (!test_bit(CONN_SAR_SDU, &chan->conn_state)) + if (!(chan->conn_state & L2CAP_CONN_SAR_SDU)) goto disconnect; if (!chan->sdu) @@ -3177,13 +2974,13 @@ static int l2cap_ertm_reassembly_sdu(struct l2cap_chan *chan, struct sk_buff *sk break; case L2CAP_SDU_END: - if (!test_bit(CONN_SAR_SDU, &chan->conn_state)) + if (!(chan->conn_state & L2CAP_CONN_SAR_SDU)) goto disconnect; if (!chan->sdu) goto disconnect; - if (!test_bit(CONN_SAR_RETRY, &chan->conn_state)) { + if (!(chan->conn_state & L2CAP_CONN_SAR_RETRY)) { chan->partial_sdu_len += skb->len; if (chan->partial_sdu_len > chan->imtu) @@ -3197,19 +2994,19 @@ static int l2cap_ertm_reassembly_sdu(struct l2cap_chan *chan, struct sk_buff *sk _skb = skb_clone(chan->sdu, GFP_ATOMIC); if (!_skb) { - set_bit(CONN_SAR_RETRY, &chan->conn_state); + chan->conn_state |= L2CAP_CONN_SAR_RETRY; return -ENOMEM; } - err = chan->ops->recv(chan->data, _skb); + err = sock_queue_rcv_skb(chan->sk, _skb); if (err < 0) { kfree_skb(_skb); - set_bit(CONN_SAR_RETRY, &chan->conn_state); + chan->conn_state |= L2CAP_CONN_SAR_RETRY; return err; } - clear_bit(CONN_SAR_RETRY, &chan->conn_state); - clear_bit(CONN_SAR_SDU, &chan->conn_state); + chan->conn_state &= ~L2CAP_CONN_SAR_RETRY; + chan->conn_state &= ~L2CAP_CONN_SAR_SDU; kfree_skb(chan->sdu); break; @@ -3245,7 +3042,7 @@ static int l2cap_try_push_rx_skb(struct l2cap_chan *chan) chan->buffer_seq = (chan->buffer_seq + 1) % 64; } - if (!test_bit(CONN_RNR_SENT, &chan->conn_state)) + if (!(chan->conn_state & L2CAP_CONN_RNR_SENT)) goto done; control = chan->buffer_seq << L2CAP_CTRL_REQSEQ_SHIFT; @@ -3253,14 +3050,14 @@ static int l2cap_try_push_rx_skb(struct l2cap_chan *chan) l2cap_send_sframe(chan, control); chan->retry_count = 1; - __clear_retrans_timer(chan); - __set_monitor_timer(chan); + del_timer(&chan->retrans_timer); + __mod_monitor_timer(); - set_bit(CONN_WAIT_F, &chan->conn_state); + chan->conn_state |= L2CAP_CONN_WAIT_F; done: - clear_bit(CONN_LOCAL_BUSY, &chan->conn_state); - clear_bit(CONN_RNR_SENT, &chan->conn_state); + chan->conn_state &= ~L2CAP_CONN_LOCAL_BUSY; + chan->conn_state &= ~L2CAP_CONN_RNR_SENT; BT_DBG("chan %p, Exit local busy", chan); @@ -3318,7 +3115,7 @@ static int l2cap_push_rx_skb(struct l2cap_chan *chan, struct sk_buff *skb, u16 c { int sctrl, err; - if (test_bit(CONN_LOCAL_BUSY, &chan->conn_state)) { + if (chan->conn_state & L2CAP_CONN_LOCAL_BUSY) { bt_cb(skb)->sar = control >> L2CAP_CTRL_SAR_SHIFT; __skb_queue_tail(&chan->busy_q, skb); return l2cap_try_push_rx_skb(chan); @@ -3335,7 +3132,7 @@ static int l2cap_push_rx_skb(struct l2cap_chan *chan, struct sk_buff *skb, u16 c /* Busy Condition */ BT_DBG("chan %p, Enter local busy", chan); - set_bit(CONN_LOCAL_BUSY, &chan->conn_state); + chan->conn_state |= L2CAP_CONN_LOCAL_BUSY; bt_cb(skb)->sar = control >> L2CAP_CTRL_SAR_SHIFT; __skb_queue_tail(&chan->busy_q, skb); @@ -3343,9 +3140,9 @@ static int l2cap_push_rx_skb(struct l2cap_chan *chan, struct sk_buff *skb, u16 c sctrl |= L2CAP_SUPER_RCV_NOT_READY; l2cap_send_sframe(chan, sctrl); - set_bit(CONN_RNR_SENT, &chan->conn_state); + chan->conn_state |= L2CAP_CONN_RNR_SENT; - __clear_ack_timer(chan); + del_timer(&chan->ack_timer); queue_work(_busy_wq, &chan->busy_work); @@ -3364,19 +3161,19 @@ static int l2cap_streaming_reassembly_sdu(struct l2cap_chan *chan, struct sk_buf switch (control & L2CAP_CTRL_SAR) { case L2CAP_SDU_UNSEGMENTED: - if (test_bit(CONN_SAR_SDU, &chan->conn_state)) { + if (chan->conn_state & L2CAP_CONN_SAR_SDU) { kfree_skb(chan->sdu); break; } - err = chan->ops->recv(chan->data, skb); + err = sock_queue_rcv_skb(chan->sk, skb); if (!err) return 0; break; case L2CAP_SDU_START: - if (test_bit(CONN_SAR_SDU, &chan->conn_state)) { + if (chan->conn_state & L2CAP_CONN_SAR_SDU) { kfree_skb(chan->sdu); break; } @@ -3397,13 +3194,13 @@ static int l2cap_streaming_reassembly_sdu(struct l2cap_chan *chan, struct sk_buf memcpy(skb_put(chan->sdu, skb->len), skb->data, skb->len); - set_bit(CONN_SAR_SDU, &chan->conn_state); + chan->conn_state |= L2CAP_CONN_SAR_SDU; chan->partial_sdu_len = skb->len; err = 0; break; case L2CAP_SDU_CONTINUE: - if (!test_bit(CONN_SAR_SDU, &chan->conn_state)) + if (!(chan->conn_state & L2CAP_CONN_SAR_SDU)) break; memcpy(skb_put(chan->sdu, skb->len), skb->data, skb->len); @@ -3417,12 +3214,12 @@ static int l2cap_streaming_reassembly_sdu(struct l2cap_chan *chan, struct sk_buf break; case L2CAP_SDU_END: - if (!test_bit(CONN_SAR_SDU, &chan->conn_state)) + if (!(chan->conn_state & L2CAP_CONN_SAR_SDU)) break; memcpy(skb_put(chan->sdu, skb->len), skb->data, skb->len); - clear_bit(CONN_SAR_SDU, &chan->conn_state); + chan->conn_state &= ~L2CAP_CONN_SAR_SDU; chan->partial_sdu_len += skb->len; if (chan->partial_sdu_len > chan->imtu) @@ -3430,7 +3227,7 @@ static int l2cap_streaming_reassembly_sdu(struct l2cap_chan *chan, struct sk_buf if (chan->partial_sdu_len == chan->sdu_len) { _skb = skb_clone(chan->sdu, GFP_ATOMIC); - err = chan->ops->recv(chan->data, _skb); + err = sock_queue_rcv_skb(chan->sk, _skb); if (err < 0) kfree_skb(_skb); } @@ -3513,11 +3310,11 @@ static inline int l2cap_data_channel_iframe(struct l2cap_chan *chan, u16 rx_cont tx_seq, rx_control); if (L2CAP_CTRL_FINAL & rx_control && - test_bit(CONN_WAIT_F, &chan->conn_state)) { - __clear_monitor_timer(chan); + chan->conn_state & L2CAP_CONN_WAIT_F) { + del_timer(&chan->monitor_timer); if (chan->unacked_frames > 0) - __set_retrans_timer(chan); - clear_bit(CONN_WAIT_F, &chan->conn_state); + __mod_retrans_timer(); + chan->conn_state &= ~L2CAP_CONN_WAIT_F; } chan->expected_ack_seq = req_seq; @@ -3536,10 +3333,10 @@ static inline int l2cap_data_channel_iframe(struct l2cap_chan *chan, u16 rx_cont goto drop; } - if (test_bit(CONN_LOCAL_BUSY, &chan->conn_state)) + if (chan->conn_state == L2CAP_CONN_LOCAL_BUSY) goto drop; - if (test_bit(CONN_SREJ_SENT, &chan->conn_state)) { + if (chan->conn_state & L2CAP_CONN_SREJ_SENT) { struct srej_list *first; first = list_first_entry(&chan->srej_l, @@ -3553,7 +3350,7 @@ static inline int l2cap_data_channel_iframe(struct l2cap_chan *chan, u16 rx_cont if (list_empty(&chan->srej_l)) { chan->buffer_seq = chan->buffer_seq_srej; - clear_bit(CONN_SREJ_SENT, &chan->conn_state); + chan->conn_state &= ~L2CAP_CONN_SREJ_SENT; l2cap_send_ack(chan); BT_DBG("chan %p, Exit SREJ_SENT", chan); } @@ -3582,7 +3379,7 @@ static inline int l2cap_data_channel_iframe(struct l2cap_chan *chan, u16 rx_cont if (tx_seq_offset < expected_tx_seq_offset) goto drop; - set_bit(CONN_SREJ_SENT, &chan->conn_state); + chan->conn_state |= L2CAP_CONN_SREJ_SENT; BT_DBG("chan %p, Enter SREJ", chan); @@ -3593,18 +3390,18 @@ static inline int l2cap_data_channel_iframe(struct l2cap_chan *chan, u16 rx_cont __skb_queue_head_init(&chan->busy_q); l2cap_add_to_srej_queue(chan, skb, tx_seq, sar); - set_bit(CONN_SEND_PBIT, &chan->conn_state); + chan->conn_state |= L2CAP_CONN_SEND_PBIT; l2cap_send_srejframe(chan, tx_seq); - __clear_ack_timer(chan); + del_timer(&chan->ack_timer); } return 0; expected: chan->expected_tx_seq = (chan->expected_tx_seq + 1) % 64; - if (test_bit(CONN_SREJ_SENT, &chan->conn_state)) { + if (chan->conn_state & L2CAP_CONN_SREJ_SENT) { bt_cb(skb)->tx_seq = tx_seq; bt_cb(skb)->sar = sar; __skb_queue_tail(&chan->srej_q, skb); @@ -3616,11 +3413,13 @@ static inline int l2cap_data_channel_iframe(struct l2cap_chan *chan, u16 rx_cont return 0; if (rx_control & L2CAP_CTRL_FINAL) { - if (!test_and_clear_bit(CONN_REJ_ACT, &chan->conn_state)) + if (chan->conn_state & L2CAP_CONN_REJ_ACT) + chan->conn_state &= ~L2CAP_CONN_REJ_ACT; + else l2cap_retransmit_frames(chan); } - __set_ack_timer(chan); + __mod_ack_timer(); chan->num_acked = (chan->num_acked + 1) % num_to_ack; if (chan->num_acked == num_to_ack - 1) @@ -3642,31 +3441,33 @@ static inline void l2cap_data_channel_rrframe(struct l2cap_chan *chan, u16 rx_co l2cap_drop_acked_frames(chan); if (rx_control & L2CAP_CTRL_POLL) { - set_bit(CONN_SEND_FBIT, &chan->conn_state); - if (test_bit(CONN_SREJ_SENT, &chan->conn_state)) { - if (test_bit(CONN_REMOTE_BUSY, &chan->conn_state) && + chan->conn_state |= L2CAP_CONN_SEND_FBIT; + if (chan->conn_state & L2CAP_CONN_SREJ_SENT) { + if ((chan->conn_state & L2CAP_CONN_REMOTE_BUSY) && (chan->unacked_frames > 0)) - __set_retrans_timer(chan); + __mod_retrans_timer(); - clear_bit(CONN_REMOTE_BUSY, &chan->conn_state); + chan->conn_state &= ~L2CAP_CONN_REMOTE_BUSY; l2cap_send_srejtail(chan); } else { l2cap_send_i_or_rr_or_rnr(chan); } } else if (rx_control & L2CAP_CTRL_FINAL) { - clear_bit(CONN_REMOTE_BUSY, &chan->conn_state); + chan->conn_state &= ~L2CAP_CONN_REMOTE_BUSY; - if (!test_and_clear_bit(CONN_REJ_ACT, &chan->conn_state)) + if (chan->conn_state & L2CAP_CONN_REJ_ACT) + chan->conn_state &= ~L2CAP_CONN_REJ_ACT; + else l2cap_retransmit_frames(chan); } else { - if (test_bit(CONN_REMOTE_BUSY, &chan->conn_state) && + if ((chan->conn_state & L2CAP_CONN_REMOTE_BUSY) && (chan->unacked_frames > 0)) - __set_retrans_timer(chan); + __mod_retrans_timer(); - clear_bit(CONN_REMOTE_BUSY, &chan->conn_state); - if (test_bit(CONN_SREJ_SENT, &chan->conn_state)) + chan->conn_state &= ~L2CAP_CONN_REMOTE_BUSY; + if (chan->conn_state & L2CAP_CONN_SREJ_SENT) l2cap_send_ack(chan); else l2cap_ertm_send(chan); @@ -3679,19 +3480,21 @@ static inline void l2cap_data_channel_rejframe(struct l2cap_chan *chan, u16 rx_c BT_DBG("chan %p, req_seq %d ctrl 0x%4.4x", chan, tx_seq, rx_control); - clear_bit(CONN_REMOTE_BUSY, &chan->conn_state); + chan->conn_state &= ~L2CAP_CONN_REMOTE_BUSY; chan->expected_ack_seq = tx_seq; l2cap_drop_acked_frames(chan); if (rx_control & L2CAP_CTRL_FINAL) { - if (!test_and_clear_bit(CONN_REJ_ACT, &chan->conn_state)) + if (chan->conn_state & L2CAP_CONN_REJ_ACT) + chan->conn_state &= ~L2CAP_CONN_REJ_ACT; + else l2cap_retransmit_frames(chan); } else { l2cap_retransmit_frames(chan); - if (test_bit(CONN_WAIT_F, &chan->conn_state)) - set_bit(CONN_REJ_ACT, &chan->conn_state); + if (chan->conn_state & L2CAP_CONN_WAIT_F) + chan->conn_state |= L2CAP_CONN_REJ_ACT; } } static inline void l2cap_data_channel_srejframe(struct l2cap_chan *chan, u16 rx_control) @@ -3700,32 +3503,32 @@ static inline void l2cap_data_channel_srejframe(struct l2cap_chan *chan, u16 rx_ BT_DBG("chan %p, req_seq %d ctrl 0x%4.4x", chan, tx_seq, rx_control); - clear_bit(CONN_REMOTE_BUSY, &chan->conn_state); + chan->conn_state &= ~L2CAP_CONN_REMOTE_BUSY; if (rx_control & L2CAP_CTRL_POLL) { chan->expected_ack_seq = tx_seq; l2cap_drop_acked_frames(chan); - set_bit(CONN_SEND_FBIT, &chan->conn_state); + chan->conn_state |= L2CAP_CONN_SEND_FBIT; l2cap_retransmit_one_frame(chan, tx_seq); l2cap_ertm_send(chan); - if (test_bit(CONN_WAIT_F, &chan->conn_state)) { + if (chan->conn_state & L2CAP_CONN_WAIT_F) { chan->srej_save_reqseq = tx_seq; - set_bit(CONN_SREJ_ACT, &chan->conn_state); + chan->conn_state |= L2CAP_CONN_SREJ_ACT; } } else if (rx_control & L2CAP_CTRL_FINAL) { - if (test_bit(CONN_SREJ_ACT, &chan->conn_state) && + if ((chan->conn_state & L2CAP_CONN_SREJ_ACT) && chan->srej_save_reqseq == tx_seq) - clear_bit(CONN_SREJ_ACT, &chan->conn_state); + chan->conn_state &= ~L2CAP_CONN_SREJ_ACT; else l2cap_retransmit_one_frame(chan, tx_seq); } else { l2cap_retransmit_one_frame(chan, tx_seq); - if (test_bit(CONN_WAIT_F, &chan->conn_state)) { + if (chan->conn_state & L2CAP_CONN_WAIT_F) { chan->srej_save_reqseq = tx_seq; - set_bit(CONN_SREJ_ACT, &chan->conn_state); + chan->conn_state |= L2CAP_CONN_SREJ_ACT; } } } @@ -3736,15 +3539,15 @@ static inline void l2cap_data_channel_rnrframe(struct l2cap_chan *chan, u16 rx_c BT_DBG("chan %p, req_seq %d ctrl 0x%4.4x", chan, tx_seq, rx_control); - set_bit(CONN_REMOTE_BUSY, &chan->conn_state); + chan->conn_state |= L2CAP_CONN_REMOTE_BUSY; chan->expected_ack_seq = tx_seq; l2cap_drop_acked_frames(chan); if (rx_control & L2CAP_CTRL_POLL) - set_bit(CONN_SEND_FBIT, &chan->conn_state); + chan->conn_state |= L2CAP_CONN_SEND_FBIT; - if (!test_bit(CONN_SREJ_SENT, &chan->conn_state)) { - __clear_retrans_timer(chan); + if (!(chan->conn_state & L2CAP_CONN_SREJ_SENT)) { + del_timer(&chan->retrans_timer); if (rx_control & L2CAP_CTRL_POLL) l2cap_send_rr_or_rnr(chan, L2CAP_CTRL_FINAL); return; @@ -3761,11 +3564,11 @@ static inline int l2cap_data_channel_sframe(struct l2cap_chan *chan, u16 rx_cont BT_DBG("chan %p rx_control 0x%4.4x len %d", chan, rx_control, skb->len); if (L2CAP_CTRL_FINAL & rx_control && - test_bit(CONN_WAIT_F, &chan->conn_state)) { - __clear_monitor_timer(chan); + chan->conn_state & L2CAP_CONN_WAIT_F) { + del_timer(&chan->monitor_timer); if (chan->unacked_frames > 0) - __set_retrans_timer(chan); - clear_bit(CONN_WAIT_F, &chan->conn_state); + __mod_retrans_timer(); + chan->conn_state &= ~L2CAP_CONN_WAIT_F; } switch (rx_control & L2CAP_CTRL_SUPERVISE) { @@ -3864,6 +3667,7 @@ static inline int l2cap_data_channel(struct l2cap_conn *conn, u16 cid, struct sk { struct l2cap_chan *chan; struct sock *sk = NULL; + struct l2cap_pinfo *pi; u16 control; u8 tx_seq; int len; @@ -3875,10 +3679,11 @@ static inline int l2cap_data_channel(struct l2cap_conn *conn, u16 cid, struct sk } sk = chan->sk; + pi = l2cap_pi(sk); BT_DBG("chan %p, len %d", chan, skb->len); - if (chan->state != BT_CONNECTED) + if (sk->sk_state != BT_CONNECTED) goto drop; switch (chan->mode) { @@ -3891,7 +3696,7 @@ static inline int l2cap_data_channel(struct l2cap_conn *conn, u16 cid, struct sk if (chan->imtu < skb->len) goto drop; - if (!chan->ops->recv(chan->data, skb)) + if (!sock_queue_rcv_skb(sk, skb)) goto done; break; @@ -3963,13 +3768,13 @@ static inline int l2cap_conless_channel(struct l2cap_conn *conn, __le16 psm, str BT_DBG("sk %p, len %d", sk, skb->len); - if (chan->state != BT_BOUND && chan->state != BT_CONNECTED) + if (sk->sk_state != BT_BOUND && sk->sk_state != BT_CONNECTED) goto drop; - if (chan->imtu < skb->len) + if (l2cap_pi(sk)->chan->imtu < skb->len) goto drop; - if (!chan->ops->recv(chan->data, skb)) + if (!sock_queue_rcv_skb(sk, skb)) goto done; drop: @@ -3996,13 +3801,13 @@ static inline int l2cap_att_channel(struct l2cap_conn *conn, __le16 cid, struct BT_DBG("sk %p, len %d", sk, skb->len); - if (chan->state != BT_BOUND && chan->state != BT_CONNECTED) + if (sk->sk_state != BT_BOUND && sk->sk_state != BT_CONNECTED) goto drop; - if (chan->imtu < skb->len) + if (l2cap_pi(sk)->chan->imtu < skb->len) goto drop; - if (!chan->ops->recv(chan->data, skb)) + if (!sock_queue_rcv_skb(sk, skb)) goto done; drop: @@ -4047,11 +3852,6 @@ static void l2cap_recv_frame(struct l2cap_conn *conn, struct sk_buff *skb) l2cap_att_channel(conn, cid, skb); break; - case L2CAP_CID_SMP: - if (smp_sig_channel(conn, skb)) - l2cap_conn_del(conn->hcon, EACCES); - break; - default: l2cap_data_channel(conn, cid, skb); break; @@ -4075,7 +3875,7 @@ static int l2cap_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type) list_for_each_entry(c, &chan_list, global_l) { struct sock *sk = c->sk; - if (c->state != BT_LISTEN) + if (sk->sk_state != BT_LISTEN) continue; if (!bacmp(&bt_sk(sk)->src, &hdev->bdaddr)) { @@ -4119,7 +3919,7 @@ static int l2cap_disconn_ind(struct hci_conn *hcon) BT_DBG("hcon %p", hcon); - if ((hcon->type != ACL_LINK && hcon->type != LE_LINK) || !conn) + if (hcon->type != ACL_LINK || !conn) return 0x13; return conn->disc_reason; @@ -4139,18 +3939,20 @@ static int l2cap_disconn_cfm(struct hci_conn *hcon, u8 reason) static inline void l2cap_check_encryption(struct l2cap_chan *chan, u8 encrypt) { - if (chan->chan_type != L2CAP_CHAN_CONN_ORIENTED) + struct sock *sk = chan->sk; + + if (sk->sk_type != SOCK_SEQPACKET && sk->sk_type != SOCK_STREAM) return; if (encrypt == 0x00) { if (chan->sec_level == BT_SECURITY_MEDIUM) { - __clear_chan_timer(chan); - __set_chan_timer(chan, HZ * 5); + l2cap_sock_clear_timer(sk); + l2cap_sock_set_timer(sk, HZ * 5); } else if (chan->sec_level == BT_SECURITY_HIGH) - l2cap_chan_close(chan, ECONNREFUSED); + __l2cap_sock_close(sk, ECONNREFUSED); } else { if (chan->sec_level == BT_SECURITY_MEDIUM) - __clear_chan_timer(chan); + l2cap_sock_clear_timer(sk); } } @@ -4171,72 +3973,50 @@ static int l2cap_security_cfm(struct hci_conn *hcon, u8 status, u8 encrypt) bh_lock_sock(sk); - BT_DBG("chan->scid %d", chan->scid); - - if (chan->scid == L2CAP_CID_LE_DATA) { - if (!status && encrypt) { - chan->sec_level = hcon->sec_level; - del_timer(&conn->security_timer); - l2cap_chan_ready(sk); - } - + if (chan->conf_state & L2CAP_CONF_CONNECT_PEND) { bh_unlock_sock(sk); continue; } - if (test_bit(CONF_CONNECT_PEND, &chan->conf_state)) { - bh_unlock_sock(sk); - continue; - } - - if (!status && (chan->state == BT_CONNECTED || - chan->state == BT_CONFIG)) { + if (!status && (sk->sk_state == BT_CONNECTED || + sk->sk_state == BT_CONFIG)) { l2cap_check_encryption(chan, encrypt); bh_unlock_sock(sk); continue; } - if (chan->state == BT_CONNECT) { + if (sk->sk_state == BT_CONNECT) { if (!status) { struct l2cap_conn_req req; req.scid = cpu_to_le16(chan->scid); req.psm = chan->psm; chan->ident = l2cap_get_ident(conn); - set_bit(CONF_CONNECT_PEND, &chan->conf_state); + chan->conf_state |= L2CAP_CONF_CONNECT_PEND; l2cap_send_cmd(conn, chan->ident, L2CAP_CONN_REQ, sizeof(req), &req); } else { - __clear_chan_timer(chan); - __set_chan_timer(chan, HZ / 10); + l2cap_sock_clear_timer(sk); + l2cap_sock_set_timer(sk, HZ / 10); } - } else if (chan->state == BT_CONNECT2) { + } else if (sk->sk_state == BT_CONNECT2) { struct l2cap_conn_rsp rsp; - __u16 res, stat; + __u16 result; if (!status) { - if (bt_sk(sk)->defer_setup) { - struct sock *parent = bt_sk(sk)->parent; - res = L2CAP_CR_PEND; - stat = L2CAP_CS_AUTHOR_PEND; - parent->sk_data_ready(parent, 0); - } else { - l2cap_state_change(chan, BT_CONFIG); - res = L2CAP_CR_SUCCESS; - stat = L2CAP_CS_NO_INFO; - } + sk->sk_state = BT_CONFIG; + result = L2CAP_CR_SUCCESS; } else { - l2cap_state_change(chan, BT_DISCONN); - __set_chan_timer(chan, HZ / 10); - res = L2CAP_CR_SEC_BLOCK; - stat = L2CAP_CS_NO_INFO; + sk->sk_state = BT_DISCONN; + l2cap_sock_set_timer(sk, HZ / 10); + result = L2CAP_CR_SEC_BLOCK; } rsp.scid = cpu_to_le16(chan->dcid); rsp.dcid = cpu_to_le16(chan->scid); - rsp.result = cpu_to_le16(res); - rsp.status = cpu_to_le16(stat); + rsp.result = cpu_to_le16(result); + rsp.status = cpu_to_le16(L2CAP_CS_NO_INFO); l2cap_send_cmd(conn, chan->ident, L2CAP_CONN_RSP, sizeof(rsp), &rsp); } @@ -4372,10 +4152,10 @@ static int l2cap_debugfs_show(struct seq_file *f, void *p) seq_printf(f, "%s %s %d %d 0x%4.4x 0x%4.4x %d %d %d %d\n", batostr(&bt_sk(sk)->src), batostr(&bt_sk(sk)->dst), - c->state, __le16_to_cpu(c->psm), + sk->sk_state, __le16_to_cpu(c->psm), c->scid, c->dcid, c->imtu, c->omtu, c->sec_level, c->mode); -} + } read_unlock_bh(&chan_list_lock); diff --git a/trunk/net/bluetooth/l2cap_sock.c b/trunk/net/bluetooth/l2cap_sock.c index 39082d4e77ce..8248303f44e8 100644 --- a/trunk/net/bluetooth/l2cap_sock.c +++ b/trunk/net/bluetooth/l2cap_sock.c @@ -29,11 +29,54 @@ #include #include #include -#include static const struct proto_ops l2cap_sock_ops; -static void l2cap_sock_init(struct sock *sk, struct sock *parent); -static struct sock *l2cap_sock_alloc(struct net *net, struct socket *sock, int proto, gfp_t prio); + +/* ---- L2CAP timers ---- */ +static void l2cap_sock_timeout(unsigned long arg) +{ + struct sock *sk = (struct sock *) arg; + int reason; + + BT_DBG("sock %p state %d", sk, sk->sk_state); + + bh_lock_sock(sk); + + if (sock_owned_by_user(sk)) { + /* sk is owned by user. Try again later */ + l2cap_sock_set_timer(sk, HZ / 5); + bh_unlock_sock(sk); + sock_put(sk); + return; + } + + if (sk->sk_state == BT_CONNECTED || sk->sk_state == BT_CONFIG) + reason = ECONNREFUSED; + else if (sk->sk_state == BT_CONNECT && + l2cap_pi(sk)->chan->sec_level != BT_SECURITY_SDP) + reason = ECONNREFUSED; + else + reason = ETIMEDOUT; + + __l2cap_sock_close(sk, reason); + + bh_unlock_sock(sk); + + l2cap_sock_kill(sk); + sock_put(sk); +} + +void l2cap_sock_set_timer(struct sock *sk, long timeout) +{ + BT_DBG("sk %p state %d timeout %ld", sk, sk->sk_state, timeout); + sk_reset_timer(sk, &sk->sk_timer, jiffies + timeout); +} + +void l2cap_sock_clear_timer(struct sock *sk) +{ + BT_DBG("sock %p state %d", sk, sk->sk_state); + sk_stop_timer(sk, &sk->sk_timer); +} static int l2cap_sock_bind(struct socket *sock, struct sockaddr *addr, int alen) { @@ -90,8 +133,6 @@ static int l2cap_sock_bind(struct socket *sock, struct sockaddr *addr, int alen) chan->sec_level = BT_SECURITY_SDP; bacpy(&bt_sk(sk)->src, &la.l2_bdaddr); - - chan->state = BT_BOUND; sk->sk_state = BT_BOUND; done: @@ -121,7 +162,7 @@ static int l2cap_sock_connect(struct socket *sock, struct sockaddr *addr, int al lock_sock(sk); - if (chan->chan_type == L2CAP_CHAN_CONN_ORIENTED + if ((sk->sk_type == SOCK_SEQPACKET || sk->sk_type == SOCK_STREAM) && !(la.l2_psm || la.l2_cid)) { err = -EINVAL; goto done; @@ -163,8 +204,8 @@ static int l2cap_sock_connect(struct socket *sock, struct sockaddr *addr, int al } /* PSM must be odd and lsb of upper byte must be 0 */ - if ((__le16_to_cpu(la.l2_psm) & 0x0101) != 0x0001 && !la.l2_cid && - chan->chan_type != L2CAP_CHAN_RAW) { + if ((__le16_to_cpu(la.l2_psm) & 0x0101) != 0x0001 && + sk->sk_type != SOCK_RAW && !la.l2_cid) { err = -EINVAL; goto done; } @@ -217,8 +258,6 @@ static int l2cap_sock_listen(struct socket *sock, int backlog) sk->sk_max_ack_backlog = backlog; sk->sk_ack_backlog = 0; - - chan->state = BT_LISTEN; sk->sk_state = BT_LISTEN; done: @@ -398,7 +437,6 @@ static int l2cap_sock_getsockopt(struct socket *sock, int level, int optname, ch struct sock *sk = sock->sk; struct l2cap_chan *chan = l2cap_pi(sk)->chan; struct bt_security sec; - struct bt_power pwr; int len, err = 0; BT_DBG("sk %p", sk); @@ -416,8 +454,8 @@ static int l2cap_sock_getsockopt(struct socket *sock, int level, int optname, ch switch (optname) { case BT_SECURITY: - if (chan->chan_type != L2CAP_CHAN_CONN_ORIENTED && - chan->chan_type != L2CAP_CHAN_RAW) { + if (sk->sk_type != SOCK_SEQPACKET && sk->sk_type != SOCK_STREAM + && sk->sk_type != SOCK_RAW) { err = -EINVAL; break; } @@ -447,21 +485,6 @@ static int l2cap_sock_getsockopt(struct socket *sock, int level, int optname, ch break; - case BT_POWER: - if (sk->sk_type != SOCK_SEQPACKET && sk->sk_type != SOCK_STREAM - && sk->sk_type != SOCK_RAW) { - err = -EINVAL; - break; - } - - pwr.force_active = chan->force_active; - - len = min_t(unsigned int, len, sizeof(pwr)); - if (copy_to_user(optval, (char *) &pwr, len)) - err = -EFAULT; - - break; - default: err = -ENOPROTOOPT; break; @@ -512,7 +535,7 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname, char __us chan->mode = opts.mode; switch (chan->mode) { case L2CAP_MODE_BASIC: - clear_bit(CONF_STATE2_DEVICE, &chan->conf_state); + chan->conf_state &= ~L2CAP_CONF_STATE2_DEVICE; break; case L2CAP_MODE_ERTM: case L2CAP_MODE_STREAMING: @@ -562,8 +585,6 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, ch struct sock *sk = sock->sk; struct l2cap_chan *chan = l2cap_pi(sk)->chan; struct bt_security sec; - struct bt_power pwr; - struct l2cap_conn *conn; int len, err = 0; u32 opt; @@ -579,8 +600,8 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, ch switch (optname) { case BT_SECURITY: - if (chan->chan_type != L2CAP_CHAN_CONN_ORIENTED && - chan->chan_type != L2CAP_CHAN_RAW) { + if (sk->sk_type != SOCK_SEQPACKET && sk->sk_type != SOCK_STREAM + && sk->sk_type != SOCK_RAW) { err = -EINVAL; break; } @@ -600,20 +621,6 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, ch } chan->sec_level = sec.level; - - conn = chan->conn; - if (conn && chan->scid == L2CAP_CID_LE_DATA) { - if (!conn->hcon->out) { - err = -EINVAL; - break; - } - - if (smp_conn_security(conn, sec.level)) - break; - - err = 0; - sk->sk_state = BT_CONFIG; - } break; case BT_DEFER_SETUP: @@ -654,23 +661,6 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, ch chan->flushable = opt; break; - case BT_POWER: - if (chan->chan_type != L2CAP_CHAN_CONN_ORIENTED && - chan->chan_type != L2CAP_CHAN_RAW) { - err = -EINVAL; - break; - } - - pwr.force_active = BT_POWER_FORCE_ACTIVE_ON; - - len = min_t(unsigned int, sizeof(pwr), optlen); - if (copy_from_user((char *) &pwr, optval, len)) { - err = -EFAULT; - break; - } - chan->force_active = pwr.force_active; - break; - default: err = -ENOPROTOOPT; break; @@ -684,6 +674,8 @@ static int l2cap_sock_sendmsg(struct kiocb *iocb, struct socket *sock, struct ms { struct sock *sk = sock->sk; struct l2cap_chan *chan = l2cap_pi(sk)->chan; + struct sk_buff *skb; + u16 control; int err; BT_DBG("sock %p, sk %p", sock, sk); @@ -698,12 +690,87 @@ static int l2cap_sock_sendmsg(struct kiocb *iocb, struct socket *sock, struct ms lock_sock(sk); if (sk->sk_state != BT_CONNECTED) { - release_sock(sk); - return -ENOTCONN; + err = -ENOTCONN; + goto done; } - err = l2cap_chan_send(chan, msg, len); + /* Connectionless channel */ + if (sk->sk_type == SOCK_DGRAM) { + skb = l2cap_create_connless_pdu(chan, msg, len); + if (IS_ERR(skb)) { + err = PTR_ERR(skb); + } else { + l2cap_do_send(chan, skb); + err = len; + } + goto done; + } + + switch (chan->mode) { + case L2CAP_MODE_BASIC: + /* Check outgoing MTU */ + if (len > chan->omtu) { + err = -EMSGSIZE; + goto done; + } + + /* Create a basic PDU */ + skb = l2cap_create_basic_pdu(chan, msg, len); + if (IS_ERR(skb)) { + err = PTR_ERR(skb); + goto done; + } + + l2cap_do_send(chan, skb); + err = len; + break; + + case L2CAP_MODE_ERTM: + case L2CAP_MODE_STREAMING: + /* Entire SDU fits into one PDU */ + if (len <= chan->remote_mps) { + control = L2CAP_SDU_UNSEGMENTED; + skb = l2cap_create_iframe_pdu(chan, msg, len, control, + 0); + if (IS_ERR(skb)) { + err = PTR_ERR(skb); + goto done; + } + __skb_queue_tail(&chan->tx_q, skb); + + if (chan->tx_send_head == NULL) + chan->tx_send_head = skb; + + } else { + /* Segment SDU into multiples PDUs */ + err = l2cap_sar_segment_sdu(chan, msg, len); + if (err < 0) + goto done; + } + + if (chan->mode == L2CAP_MODE_STREAMING) { + l2cap_streaming_send(chan); + err = len; + break; + } + + if ((chan->conn_state & L2CAP_CONN_REMOTE_BUSY) && + (chan->conn_state & L2CAP_CONN_WAIT_F)) { + err = len; + break; + } + err = l2cap_ertm_send(chan); + + if (err >= 0) + err = len; + break; + + default: + BT_DBG("bad state %1.1x", chan->mode); + err = -EBADFD; + } +done: release_sock(sk); return err; } @@ -733,7 +800,7 @@ static int l2cap_sock_recvmsg(struct kiocb *iocb, struct socket *sock, struct ms /* Kill socket (only if zapped and orphan) * Must be called on unlocked socket. */ -static void l2cap_sock_kill(struct sock *sk) +void l2cap_sock_kill(struct sock *sk) { if (!sock_flag(sk, SOCK_ZAPPED) || sk->sk_socket) return; @@ -747,6 +814,87 @@ static void l2cap_sock_kill(struct sock *sk) sock_put(sk); } +/* Must be called on unlocked socket. */ +static void l2cap_sock_close(struct sock *sk) +{ + l2cap_sock_clear_timer(sk); + lock_sock(sk); + __l2cap_sock_close(sk, ECONNRESET); + release_sock(sk); + l2cap_sock_kill(sk); +} + +static void l2cap_sock_cleanup_listen(struct sock *parent) +{ + struct sock *sk; + + BT_DBG("parent %p", parent); + + /* Close not yet accepted channels */ + while ((sk = bt_accept_dequeue(parent, NULL))) + l2cap_sock_close(sk); + + parent->sk_state = BT_CLOSED; + sock_set_flag(parent, SOCK_ZAPPED); +} + +void __l2cap_sock_close(struct sock *sk, int reason) +{ + struct l2cap_chan *chan = l2cap_pi(sk)->chan; + struct l2cap_conn *conn = chan->conn; + + BT_DBG("sk %p state %d socket %p", sk, sk->sk_state, sk->sk_socket); + + switch (sk->sk_state) { + case BT_LISTEN: + l2cap_sock_cleanup_listen(sk); + break; + + case BT_CONNECTED: + case BT_CONFIG: + if ((sk->sk_type == SOCK_SEQPACKET || + sk->sk_type == SOCK_STREAM) && + conn->hcon->type == ACL_LINK) { + l2cap_sock_set_timer(sk, sk->sk_sndtimeo); + l2cap_send_disconn_req(conn, chan, reason); + } else + l2cap_chan_del(chan, reason); + break; + + case BT_CONNECT2: + if ((sk->sk_type == SOCK_SEQPACKET || + sk->sk_type == SOCK_STREAM) && + conn->hcon->type == ACL_LINK) { + struct l2cap_conn_rsp rsp; + __u16 result; + + if (bt_sk(sk)->defer_setup) + result = L2CAP_CR_SEC_BLOCK; + else + result = L2CAP_CR_BAD_PSM; + + rsp.scid = cpu_to_le16(chan->dcid); + rsp.dcid = cpu_to_le16(chan->scid); + rsp.result = cpu_to_le16(result); + rsp.status = cpu_to_le16(L2CAP_CS_NO_INFO); + l2cap_send_cmd(conn, chan->ident, L2CAP_CONN_RSP, + sizeof(rsp), &rsp); + } + + l2cap_chan_del(chan, reason); + break; + + case BT_CONNECT: + case BT_DISCONN: + l2cap_chan_del(chan, reason); + break; + + default: + sock_set_flag(sk, SOCK_ZAPPED); + break; + } +} + static int l2cap_sock_shutdown(struct socket *sock, int how) { struct sock *sk = sock->sk; @@ -764,7 +912,8 @@ static int l2cap_sock_shutdown(struct socket *sock, int how) err = __l2cap_wait_ack(sk); sk->sk_shutdown = SHUTDOWN_MASK; - l2cap_chan_close(chan, 0); + l2cap_sock_clear_timer(sk); + __l2cap_sock_close(sk, 0); if (sock_flag(sk, SOCK_LINGER) && sk->sk_lingertime) err = bt_sock_wait_state(sk, BT_CLOSED, @@ -795,49 +944,6 @@ static int l2cap_sock_release(struct socket *sock) return err; } -static struct l2cap_chan *l2cap_sock_new_connection_cb(void *data) -{ - struct sock *sk, *parent = data; - - sk = l2cap_sock_alloc(sock_net(parent), NULL, BTPROTO_L2CAP, - GFP_ATOMIC); - if (!sk) - return NULL; - - l2cap_sock_init(sk, parent); - - return l2cap_pi(sk)->chan; -} - -static int l2cap_sock_recv_cb(void *data, struct sk_buff *skb) -{ - struct sock *sk = data; - - return sock_queue_rcv_skb(sk, skb); -} - -static void l2cap_sock_close_cb(void *data) -{ - struct sock *sk = data; - - l2cap_sock_kill(sk); -} - -static void l2cap_sock_state_change_cb(void *data, int state) -{ - struct sock *sk = data; - - sk->sk_state = state; -} - -static struct l2cap_ops l2cap_chan_ops = { - .name = "L2CAP Socket Interface", - .new_connection = l2cap_sock_new_connection_cb, - .recv = l2cap_sock_recv_cb, - .close = l2cap_sock_close_cb, - .state_change = l2cap_sock_state_change_cb, -}; - static void l2cap_sock_destruct(struct sock *sk) { BT_DBG("sk %p", sk); @@ -846,7 +952,7 @@ static void l2cap_sock_destruct(struct sock *sk) skb_queue_purge(&sk->sk_write_queue); } -static void l2cap_sock_init(struct sock *sk, struct sock *parent) +void l2cap_sock_init(struct sock *sk, struct sock *parent) { struct l2cap_pinfo *pi = l2cap_pi(sk); struct l2cap_chan *chan = pi->chan; @@ -859,7 +965,6 @@ static void l2cap_sock_init(struct sock *sk, struct sock *parent) sk->sk_type = parent->sk_type; bt_sk(sk)->defer_setup = bt_sk(parent)->defer_setup; - chan->chan_type = pchan->chan_type; chan->imtu = pchan->imtu; chan->omtu = pchan->omtu; chan->conf_state = pchan->conf_state; @@ -871,27 +976,12 @@ static void l2cap_sock_init(struct sock *sk, struct sock *parent) chan->role_switch = pchan->role_switch; chan->force_reliable = pchan->force_reliable; chan->flushable = pchan->flushable; - chan->force_active = pchan->force_active; } else { - - switch (sk->sk_type) { - case SOCK_RAW: - chan->chan_type = L2CAP_CHAN_RAW; - break; - case SOCK_DGRAM: - chan->chan_type = L2CAP_CHAN_CONN_LESS; - break; - case SOCK_SEQPACKET: - case SOCK_STREAM: - chan->chan_type = L2CAP_CHAN_CONN_ORIENTED; - break; - } - chan->imtu = L2CAP_DEFAULT_MTU; chan->omtu = 0; if (!disable_ertm && sk->sk_type == SOCK_STREAM) { chan->mode = L2CAP_MODE_ERTM; - set_bit(CONF_STATE2_DEVICE, &chan->conf_state); + chan->conf_state |= L2CAP_CONF_STATE2_DEVICE; } else { chan->mode = L2CAP_MODE_BASIC; } @@ -902,15 +992,10 @@ static void l2cap_sock_init(struct sock *sk, struct sock *parent) chan->role_switch = 0; chan->force_reliable = 0; chan->flushable = BT_FLUSHABLE_OFF; - chan->force_active = BT_POWER_FORCE_ACTIVE_ON; - } /* Default config options */ chan->flush_to = L2CAP_DEFAULT_FLUSH_TO; - - chan->data = sk; - chan->ops = &l2cap_chan_ops; } static struct proto l2cap_proto = { @@ -919,10 +1004,9 @@ static struct proto l2cap_proto = { .obj_size = sizeof(struct l2cap_pinfo) }; -static struct sock *l2cap_sock_alloc(struct net *net, struct socket *sock, int proto, gfp_t prio) +struct sock *l2cap_sock_alloc(struct net *net, struct socket *sock, int proto, gfp_t prio) { struct sock *sk; - struct l2cap_chan *chan; sk = sk_alloc(net, PF_BLUETOOTH, prio, &l2cap_proto); if (!sk) @@ -939,13 +1023,7 @@ static struct sock *l2cap_sock_alloc(struct net *net, struct socket *sock, int p sk->sk_protocol = proto; sk->sk_state = BT_OPEN; - chan = l2cap_chan_create(sk); - if (!chan) { - l2cap_sock_kill(sk); - return NULL; - } - - l2cap_pi(sk)->chan = chan; + setup_timer(&sk->sk_timer, l2cap_sock_timeout, (unsigned long) sk); return sk; } @@ -954,6 +1032,7 @@ static int l2cap_sock_create(struct net *net, struct socket *sock, int protocol, int kern) { struct sock *sk; + struct l2cap_chan *chan; BT_DBG("sock %p", sock); @@ -972,6 +1051,14 @@ static int l2cap_sock_create(struct net *net, struct socket *sock, int protocol, if (!sk) return -ENOMEM; + chan = l2cap_chan_create(sk); + if (!chan) { + l2cap_sock_kill(sk); + return -ENOMEM; + } + + l2cap_pi(sk)->chan = chan; + l2cap_sock_init(sk, NULL); return 0; } diff --git a/trunk/net/bluetooth/mgmt.c b/trunk/net/bluetooth/mgmt.c index 64c0418a6221..dae382ce7020 100644 --- a/trunk/net/bluetooth/mgmt.c +++ b/trunk/net/bluetooth/mgmt.c @@ -41,7 +41,7 @@ struct pending_cmd { void *user_data; }; -static LIST_HEAD(cmd_list); +LIST_HEAD(cmd_list); static int cmd_status(struct sock *sk, u16 index, u16 cmd, u8 status) { @@ -990,7 +990,7 @@ static int remove_key(struct sock *sk, u16 index, unsigned char *data, u16 len) put_unaligned_le16(conn->handle, &dc.handle); dc.reason = 0x13; /* Remote User Terminated Connection */ - err = hci_send_cmd(hdev, HCI_OP_DISCONNECT, sizeof(dc), &dc); + err = hci_send_cmd(hdev, HCI_OP_DISCONNECT, 0, NULL); } unlock: @@ -1092,6 +1092,8 @@ static int get_connections(struct sock *sk, u16 index) put_unaligned_le16(count, &rp->conn_count); + read_lock(&hci_dev_list_lock); + i = 0; list_for_each(p, &hdev->conn_hash.list) { struct hci_conn *c = list_entry(p, struct hci_conn, list); @@ -1099,6 +1101,8 @@ static int get_connections(struct sock *sk, u16 index) bacpy(&rp->conn[i++], &c->dst); } + read_unlock(&hci_dev_list_lock); + err = cmd_complete(sk, index, MGMT_OP_GET_CONNECTIONS, rp, rp_len); unlock: @@ -1108,32 +1112,11 @@ static int get_connections(struct sock *sk, u16 index) return err; } -static int send_pin_code_neg_reply(struct sock *sk, u16 index, - struct hci_dev *hdev, struct mgmt_cp_pin_code_neg_reply *cp) -{ - struct pending_cmd *cmd; - int err; - - cmd = mgmt_pending_add(sk, MGMT_OP_PIN_CODE_NEG_REPLY, index, cp, - sizeof(*cp)); - if (!cmd) - return -ENOMEM; - - err = hci_send_cmd(hdev, HCI_OP_PIN_CODE_NEG_REPLY, sizeof(cp->bdaddr), - &cp->bdaddr); - if (err < 0) - mgmt_pending_remove(cmd); - - return err; -} - static int pin_code_reply(struct sock *sk, u16 index, unsigned char *data, u16 len) { struct hci_dev *hdev; - struct hci_conn *conn; struct mgmt_cp_pin_code_reply *cp; - struct mgmt_cp_pin_code_neg_reply ncp; struct hci_cp_pin_code_reply reply; struct pending_cmd *cmd; int err; @@ -1156,25 +1139,6 @@ static int pin_code_reply(struct sock *sk, u16 index, unsigned char *data, goto failed; } - conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr); - if (!conn) { - err = cmd_status(sk, index, MGMT_OP_PIN_CODE_REPLY, ENOTCONN); - goto failed; - } - - if (conn->pending_sec_level == BT_SECURITY_HIGH && cp->pin_len != 16) { - bacpy(&ncp.bdaddr, &cp->bdaddr); - - BT_ERR("PIN code is not 16 bytes long"); - - err = send_pin_code_neg_reply(sk, index, hdev, &ncp); - if (err >= 0) - err = cmd_status(sk, index, MGMT_OP_PIN_CODE_REPLY, - EINVAL); - - goto failed; - } - cmd = mgmt_pending_add(sk, MGMT_OP_PIN_CODE_REPLY, index, data, len); if (!cmd) { err = -ENOMEM; @@ -1183,7 +1147,7 @@ static int pin_code_reply(struct sock *sk, u16 index, unsigned char *data, bacpy(&reply.bdaddr, &cp->bdaddr); reply.pin_len = cp->pin_len; - memcpy(reply.pin_code, cp->pin_code, sizeof(reply.pin_code)); + memcpy(reply.pin_code, cp->pin_code, 16); err = hci_send_cmd(hdev, HCI_OP_PIN_CODE_REPLY, sizeof(reply), &reply); if (err < 0) @@ -1201,6 +1165,7 @@ static int pin_code_neg_reply(struct sock *sk, u16 index, unsigned char *data, { struct hci_dev *hdev; struct mgmt_cp_pin_code_neg_reply *cp; + struct pending_cmd *cmd; int err; BT_DBG(""); @@ -1224,7 +1189,17 @@ static int pin_code_neg_reply(struct sock *sk, u16 index, unsigned char *data, goto failed; } - err = send_pin_code_neg_reply(sk, index, hdev, cp); + cmd = mgmt_pending_add(sk, MGMT_OP_PIN_CODE_NEG_REPLY, index, + data, len); + if (!cmd) { + err = -ENOMEM; + goto failed; + } + + err = hci_send_cmd(hdev, HCI_OP_PIN_CODE_NEG_REPLY, sizeof(cp->bdaddr), + &cp->bdaddr); + if (err < 0) + mgmt_pending_remove(cmd); failed: hci_dev_unlock(hdev); @@ -1666,70 +1641,6 @@ static int stop_discovery(struct sock *sk, u16 index) return err; } -static int block_device(struct sock *sk, u16 index, unsigned char *data, - u16 len) -{ - struct hci_dev *hdev; - struct mgmt_cp_block_device *cp; - int err; - - BT_DBG("hci%u", index); - - cp = (void *) data; - - if (len != sizeof(*cp)) - return cmd_status(sk, index, MGMT_OP_BLOCK_DEVICE, - EINVAL); - - hdev = hci_dev_get(index); - if (!hdev) - return cmd_status(sk, index, MGMT_OP_BLOCK_DEVICE, - ENODEV); - - err = hci_blacklist_add(hdev, &cp->bdaddr); - - if (err < 0) - err = cmd_status(sk, index, MGMT_OP_BLOCK_DEVICE, -err); - else - err = cmd_complete(sk, index, MGMT_OP_BLOCK_DEVICE, - NULL, 0); - hci_dev_put(hdev); - - return err; -} - -static int unblock_device(struct sock *sk, u16 index, unsigned char *data, - u16 len) -{ - struct hci_dev *hdev; - struct mgmt_cp_unblock_device *cp; - int err; - - BT_DBG("hci%u", index); - - cp = (void *) data; - - if (len != sizeof(*cp)) - return cmd_status(sk, index, MGMT_OP_UNBLOCK_DEVICE, - EINVAL); - - hdev = hci_dev_get(index); - if (!hdev) - return cmd_status(sk, index, MGMT_OP_UNBLOCK_DEVICE, - ENODEV); - - err = hci_blacklist_del(hdev, &cp->bdaddr); - - if (err < 0) - err = cmd_status(sk, index, MGMT_OP_UNBLOCK_DEVICE, -err); - else - err = cmd_complete(sk, index, MGMT_OP_UNBLOCK_DEVICE, - NULL, 0); - hci_dev_put(hdev); - - return err; -} - int mgmt_control(struct sock *sk, struct msghdr *msg, size_t msglen) { unsigned char *buf; @@ -1844,12 +1755,6 @@ int mgmt_control(struct sock *sk, struct msghdr *msg, size_t msglen) case MGMT_OP_STOP_DISCOVERY: err = stop_discovery(sk, index); break; - case MGMT_OP_BLOCK_DEVICE: - err = block_device(sk, index, buf + sizeof(*hdr), len); - break; - case MGMT_OP_UNBLOCK_DEVICE: - err = unblock_device(sk, index, buf + sizeof(*hdr), len); - break; default: BT_DBG("Unknown op %u", opcode); err = cmd_status(sk, index, opcode, 0x01); diff --git a/trunk/net/bluetooth/rfcomm/sock.c b/trunk/net/bluetooth/rfcomm/sock.c index 8f01e6b11a70..1b10727ce523 100644 --- a/trunk/net/bluetooth/rfcomm/sock.c +++ b/trunk/net/bluetooth/rfcomm/sock.c @@ -679,8 +679,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c { struct sock *sk = sock->sk; struct bt_security sec; - int err = 0; - size_t len; + int len, err = 0; u32 opt; BT_DBG("sk %p", sk); @@ -742,6 +741,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c static int rfcomm_sock_getsockopt_old(struct socket *sock, int optname, char __user *optval, int __user *optlen) { struct sock *sk = sock->sk; + struct sock *l2cap_sk; struct rfcomm_conninfo cinfo; struct l2cap_conn *conn = l2cap_pi(sk)->chan->conn; int len, err = 0; @@ -786,6 +786,8 @@ static int rfcomm_sock_getsockopt_old(struct socket *sock, int optname, char __u break; } + l2cap_sk = rfcomm_pi(sk)->dlc->session->sock->sk; + memset(&cinfo, 0, sizeof(cinfo)); cinfo.hci_handle = conn->hcon->handle; memcpy(cinfo.dev_class, conn->hcon->dev_class, 3); diff --git a/trunk/net/bluetooth/smp.c b/trunk/net/bluetooth/smp.c deleted file mode 100644 index a36f8707d964..000000000000 --- a/trunk/net/bluetooth/smp.c +++ /dev/null @@ -1,534 +0,0 @@ -/* - BlueZ - Bluetooth protocol stack for Linux - Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). - - 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; - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. - IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY - CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - - ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, - COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS - SOFTWARE IS DISCLAIMED. -*/ - -#include -#include -#include -#include -#include -#include -#include - -#define SMP_TIMEOUT 30000 /* 30 seconds */ - -static inline void swap128(u8 src[16], u8 dst[16]) -{ - int i; - for (i = 0; i < 16; i++) - dst[15 - i] = src[i]; -} - -static inline void swap56(u8 src[7], u8 dst[7]) -{ - int i; - for (i = 0; i < 7; i++) - dst[6 - i] = src[i]; -} - -static int smp_e(struct crypto_blkcipher *tfm, const u8 *k, u8 *r) -{ - struct blkcipher_desc desc; - struct scatterlist sg; - int err, iv_len; - unsigned char iv[128]; - - if (tfm == NULL) { - BT_ERR("tfm %p", tfm); - return -EINVAL; - } - - desc.tfm = tfm; - desc.flags = 0; - - err = crypto_blkcipher_setkey(tfm, k, 16); - if (err) { - BT_ERR("cipher setkey failed: %d", err); - return err; - } - - sg_init_one(&sg, r, 16); - - iv_len = crypto_blkcipher_ivsize(tfm); - if (iv_len) { - memset(&iv, 0xff, iv_len); - crypto_blkcipher_set_iv(tfm, iv, iv_len); - } - - err = crypto_blkcipher_encrypt(&desc, &sg, &sg, 16); - if (err) - BT_ERR("Encrypt data error %d", err); - - return err; -} - -static int smp_c1(struct crypto_blkcipher *tfm, u8 k[16], u8 r[16], - u8 preq[7], u8 pres[7], u8 _iat, bdaddr_t *ia, - u8 _rat, bdaddr_t *ra, u8 res[16]) -{ - u8 p1[16], p2[16]; - int err; - - memset(p1, 0, 16); - - /* p1 = pres || preq || _rat || _iat */ - swap56(pres, p1); - swap56(preq, p1 + 7); - p1[14] = _rat; - p1[15] = _iat; - - memset(p2, 0, 16); - - /* p2 = padding || ia || ra */ - baswap((bdaddr_t *) (p2 + 4), ia); - baswap((bdaddr_t *) (p2 + 10), ra); - - /* res = r XOR p1 */ - u128_xor((u128 *) res, (u128 *) r, (u128 *) p1); - - /* res = e(k, res) */ - err = smp_e(tfm, k, res); - if (err) { - BT_ERR("Encrypt data error"); - return err; - } - - /* res = res XOR p2 */ - u128_xor((u128 *) res, (u128 *) res, (u128 *) p2); - - /* res = e(k, res) */ - err = smp_e(tfm, k, res); - if (err) - BT_ERR("Encrypt data error"); - - return err; -} - -static int smp_s1(struct crypto_blkcipher *tfm, u8 k[16], - u8 r1[16], u8 r2[16], u8 _r[16]) -{ - int err; - - /* Just least significant octets from r1 and r2 are considered */ - memcpy(_r, r1 + 8, 8); - memcpy(_r + 8, r2 + 8, 8); - - err = smp_e(tfm, k, _r); - if (err) - BT_ERR("Encrypt data error"); - - return err; -} - -static int smp_rand(u8 *buf) -{ - get_random_bytes(buf, 16); - - return 0; -} - -static struct sk_buff *smp_build_cmd(struct l2cap_conn *conn, u8 code, - u16 dlen, void *data) -{ - struct sk_buff *skb; - struct l2cap_hdr *lh; - int len; - - len = L2CAP_HDR_SIZE + sizeof(code) + dlen; - - if (len > conn->mtu) - return NULL; - - skb = bt_skb_alloc(len, GFP_ATOMIC); - if (!skb) - return NULL; - - lh = (struct l2cap_hdr *) skb_put(skb, L2CAP_HDR_SIZE); - lh->len = cpu_to_le16(sizeof(code) + dlen); - lh->cid = cpu_to_le16(L2CAP_CID_SMP); - - memcpy(skb_put(skb, sizeof(code)), &code, sizeof(code)); - - memcpy(skb_put(skb, dlen), data, dlen); - - return skb; -} - -static void smp_send_cmd(struct l2cap_conn *conn, u8 code, u16 len, void *data) -{ - struct sk_buff *skb = smp_build_cmd(conn, code, len, data); - - BT_DBG("code 0x%2.2x", code); - - if (!skb) - return; - - hci_send_acl(conn->hcon, skb, 0); -} - -static __u8 seclevel_to_authreq(__u8 level) -{ - switch (level) { - case BT_SECURITY_HIGH: - /* Right now we don't support bonding */ - return SMP_AUTH_MITM; - - default: - return SMP_AUTH_NONE; - } -} - -static void build_pairing_cmd(struct l2cap_conn *conn, - struct smp_cmd_pairing *cmd, __u8 authreq) -{ - cmd->io_capability = conn->hcon->io_capability; - cmd->oob_flag = SMP_OOB_NOT_PRESENT; - cmd->max_key_size = SMP_MAX_ENC_KEY_SIZE; - cmd->init_key_dist = 0x00; - cmd->resp_key_dist = 0x00; - cmd->auth_req = authreq; -} - -static u8 check_enc_key_size(struct l2cap_conn *conn, __u8 max_key_size) -{ - if ((max_key_size > SMP_MAX_ENC_KEY_SIZE) || - (max_key_size < SMP_MIN_ENC_KEY_SIZE)) - return SMP_ENC_KEY_SIZE; - - conn->smp_key_size = max_key_size; - - return 0; -} - -static u8 smp_cmd_pairing_req(struct l2cap_conn *conn, struct sk_buff *skb) -{ - struct smp_cmd_pairing rsp, *req = (void *) skb->data; - u8 key_size; - - BT_DBG("conn %p", conn); - - conn->preq[0] = SMP_CMD_PAIRING_REQ; - memcpy(&conn->preq[1], req, sizeof(*req)); - skb_pull(skb, sizeof(*req)); - - if (req->oob_flag) - return SMP_OOB_NOT_AVAIL; - - /* We didn't start the pairing, so no requirements */ - build_pairing_cmd(conn, &rsp, SMP_AUTH_NONE); - - key_size = min(req->max_key_size, rsp.max_key_size); - if (check_enc_key_size(conn, key_size)) - return SMP_ENC_KEY_SIZE; - - /* Just works */ - memset(conn->tk, 0, sizeof(conn->tk)); - - conn->prsp[0] = SMP_CMD_PAIRING_RSP; - memcpy(&conn->prsp[1], &rsp, sizeof(rsp)); - - smp_send_cmd(conn, SMP_CMD_PAIRING_RSP, sizeof(rsp), &rsp); - - mod_timer(&conn->security_timer, jiffies + - msecs_to_jiffies(SMP_TIMEOUT)); - - return 0; -} - -static u8 smp_cmd_pairing_rsp(struct l2cap_conn *conn, struct sk_buff *skb) -{ - struct smp_cmd_pairing *req, *rsp = (void *) skb->data; - struct smp_cmd_pairing_confirm cp; - struct crypto_blkcipher *tfm = conn->hcon->hdev->tfm; - int ret; - u8 res[16], key_size; - - BT_DBG("conn %p", conn); - - skb_pull(skb, sizeof(*rsp)); - - req = (void *) &conn->preq[1]; - - key_size = min(req->max_key_size, rsp->max_key_size); - if (check_enc_key_size(conn, key_size)) - return SMP_ENC_KEY_SIZE; - - if (rsp->oob_flag) - return SMP_OOB_NOT_AVAIL; - - /* Just works */ - memset(conn->tk, 0, sizeof(conn->tk)); - - conn->prsp[0] = SMP_CMD_PAIRING_RSP; - memcpy(&conn->prsp[1], rsp, sizeof(*rsp)); - - ret = smp_rand(conn->prnd); - if (ret) - return SMP_UNSPECIFIED; - - ret = smp_c1(tfm, conn->tk, conn->prnd, conn->preq, conn->prsp, 0, - conn->src, conn->hcon->dst_type, conn->dst, res); - if (ret) - return SMP_UNSPECIFIED; - - swap128(res, cp.confirm_val); - - smp_send_cmd(conn, SMP_CMD_PAIRING_CONFIRM, sizeof(cp), &cp); - - return 0; -} - -static u8 smp_cmd_pairing_confirm(struct l2cap_conn *conn, struct sk_buff *skb) -{ - struct crypto_blkcipher *tfm = conn->hcon->hdev->tfm; - - BT_DBG("conn %p %s", conn, conn->hcon->out ? "master" : "slave"); - - memcpy(conn->pcnf, skb->data, sizeof(conn->pcnf)); - skb_pull(skb, sizeof(conn->pcnf)); - - if (conn->hcon->out) { - u8 random[16]; - - swap128(conn->prnd, random); - smp_send_cmd(conn, SMP_CMD_PAIRING_RANDOM, sizeof(random), - random); - } else { - struct smp_cmd_pairing_confirm cp; - int ret; - u8 res[16]; - - ret = smp_rand(conn->prnd); - if (ret) - return SMP_UNSPECIFIED; - - ret = smp_c1(tfm, conn->tk, conn->prnd, conn->preq, conn->prsp, - conn->hcon->dst_type, conn->dst, - 0, conn->src, res); - if (ret) - return SMP_CONFIRM_FAILED; - - swap128(res, cp.confirm_val); - - smp_send_cmd(conn, SMP_CMD_PAIRING_CONFIRM, sizeof(cp), &cp); - } - - mod_timer(&conn->security_timer, jiffies + - msecs_to_jiffies(SMP_TIMEOUT)); - - return 0; -} - -static u8 smp_cmd_pairing_random(struct l2cap_conn *conn, struct sk_buff *skb) -{ - struct hci_conn *hcon = conn->hcon; - struct crypto_blkcipher *tfm = hcon->hdev->tfm; - int ret; - u8 key[16], res[16], random[16], confirm[16]; - - swap128(skb->data, random); - skb_pull(skb, sizeof(random)); - - memset(hcon->ltk, 0, sizeof(hcon->ltk)); - - if (conn->hcon->out) - ret = smp_c1(tfm, conn->tk, random, conn->preq, conn->prsp, 0, - conn->src, conn->hcon->dst_type, conn->dst, - res); - else - ret = smp_c1(tfm, conn->tk, random, conn->preq, conn->prsp, - conn->hcon->dst_type, conn->dst, 0, conn->src, - res); - if (ret) - return SMP_UNSPECIFIED; - - BT_DBG("conn %p %s", conn, conn->hcon->out ? "master" : "slave"); - - swap128(res, confirm); - - if (memcmp(conn->pcnf, confirm, sizeof(conn->pcnf)) != 0) { - BT_ERR("Pairing failed (confirmation values mismatch)"); - return SMP_CONFIRM_FAILED; - } - - if (conn->hcon->out) { - __le16 ediv; - u8 rand[8]; - - smp_s1(tfm, conn->tk, random, conn->prnd, key); - swap128(key, hcon->ltk); - - memset(hcon->ltk + conn->smp_key_size, 0, - SMP_MAX_ENC_KEY_SIZE - conn->smp_key_size); - - memset(rand, 0, sizeof(rand)); - ediv = 0; - hci_le_start_enc(hcon, ediv, rand, hcon->ltk); - } else { - u8 r[16]; - - swap128(conn->prnd, r); - smp_send_cmd(conn, SMP_CMD_PAIRING_RANDOM, sizeof(r), r); - - smp_s1(tfm, conn->tk, conn->prnd, random, key); - swap128(key, hcon->ltk); - - memset(hcon->ltk + conn->smp_key_size, 0, - SMP_MAX_ENC_KEY_SIZE - conn->smp_key_size); - } - - return 0; -} - -static u8 smp_cmd_security_req(struct l2cap_conn *conn, struct sk_buff *skb) -{ - struct smp_cmd_security_req *rp = (void *) skb->data; - struct smp_cmd_pairing cp; - struct hci_conn *hcon = conn->hcon; - - BT_DBG("conn %p", conn); - - if (test_bit(HCI_CONN_ENCRYPT_PEND, &hcon->pend)) - return 0; - - skb_pull(skb, sizeof(*rp)); - - memset(&cp, 0, sizeof(cp)); - build_pairing_cmd(conn, &cp, rp->auth_req); - - conn->preq[0] = SMP_CMD_PAIRING_REQ; - memcpy(&conn->preq[1], &cp, sizeof(cp)); - - smp_send_cmd(conn, SMP_CMD_PAIRING_REQ, sizeof(cp), &cp); - - mod_timer(&conn->security_timer, jiffies + - msecs_to_jiffies(SMP_TIMEOUT)); - - set_bit(HCI_CONN_ENCRYPT_PEND, &hcon->pend); - - return 0; -} - -int smp_conn_security(struct l2cap_conn *conn, __u8 sec_level) -{ - struct hci_conn *hcon = conn->hcon; - __u8 authreq; - - BT_DBG("conn %p hcon %p level 0x%2.2x", conn, hcon, sec_level); - - if (IS_ERR(hcon->hdev->tfm)) - return 1; - - if (test_bit(HCI_CONN_ENCRYPT_PEND, &hcon->pend)) - return 0; - - if (sec_level == BT_SECURITY_LOW) - return 1; - - if (hcon->sec_level >= sec_level) - return 1; - - authreq = seclevel_to_authreq(sec_level); - - if (hcon->link_mode & HCI_LM_MASTER) { - struct smp_cmd_pairing cp; - - build_pairing_cmd(conn, &cp, authreq); - conn->preq[0] = SMP_CMD_PAIRING_REQ; - memcpy(&conn->preq[1], &cp, sizeof(cp)); - - mod_timer(&conn->security_timer, jiffies + - msecs_to_jiffies(SMP_TIMEOUT)); - - smp_send_cmd(conn, SMP_CMD_PAIRING_REQ, sizeof(cp), &cp); - } else { - struct smp_cmd_security_req cp; - cp.auth_req = authreq; - smp_send_cmd(conn, SMP_CMD_SECURITY_REQ, sizeof(cp), &cp); - } - - hcon->pending_sec_level = sec_level; - set_bit(HCI_CONN_ENCRYPT_PEND, &hcon->pend); - - return 0; -} - -int smp_sig_channel(struct l2cap_conn *conn, struct sk_buff *skb) -{ - __u8 code = skb->data[0]; - __u8 reason; - int err = 0; - - if (IS_ERR(conn->hcon->hdev->tfm)) { - err = PTR_ERR(conn->hcon->hdev->tfm); - reason = SMP_PAIRING_NOTSUPP; - goto done; - } - - skb_pull(skb, sizeof(code)); - - switch (code) { - case SMP_CMD_PAIRING_REQ: - reason = smp_cmd_pairing_req(conn, skb); - break; - - case SMP_CMD_PAIRING_FAIL: - reason = 0; - err = -EPERM; - break; - - case SMP_CMD_PAIRING_RSP: - reason = smp_cmd_pairing_rsp(conn, skb); - break; - - case SMP_CMD_SECURITY_REQ: - reason = smp_cmd_security_req(conn, skb); - break; - - case SMP_CMD_PAIRING_CONFIRM: - reason = smp_cmd_pairing_confirm(conn, skb); - break; - - case SMP_CMD_PAIRING_RANDOM: - reason = smp_cmd_pairing_random(conn, skb); - break; - - case SMP_CMD_ENCRYPT_INFO: - case SMP_CMD_MASTER_IDENT: - case SMP_CMD_IDENT_INFO: - case SMP_CMD_IDENT_ADDR_INFO: - case SMP_CMD_SIGN_INFO: - default: - BT_DBG("Unknown command code 0x%2.2x", code); - - reason = SMP_CMD_NOTSUPP; - err = -EOPNOTSUPP; - goto done; - } - -done: - if (reason) - smp_send_cmd(conn, SMP_CMD_PAIRING_FAIL, sizeof(reason), - &reason); - - kfree_skb(skb); - return err; -} diff --git a/trunk/net/bridge/br_device.c b/trunk/net/bridge/br_device.c index 32b8f9f7f79e..c188c803c09c 100644 --- a/trunk/net/bridge/br_device.c +++ b/trunk/net/bridge/br_device.c @@ -49,9 +49,7 @@ netdev_tx_t br_dev_xmit(struct sk_buff *skb, struct net_device *dev) skb_pull(skb, ETH_HLEN); rcu_read_lock(); - if (is_broadcast_ether_addr(dest)) - br_flood_deliver(br, skb); - else if (is_multicast_ether_addr(dest)) { + if (is_multicast_ether_addr(dest)) { if (unlikely(netpoll_tx_running(dev))) { br_flood_deliver(br, skb); goto out; diff --git a/trunk/net/bridge/br_input.c b/trunk/net/bridge/br_input.c index f06ee39c73fd..f3ac1e858ee1 100644 --- a/trunk/net/bridge/br_input.c +++ b/trunk/net/bridge/br_input.c @@ -60,7 +60,7 @@ int br_handle_frame_finish(struct sk_buff *skb) br = p->br; br_fdb_update(br, p, eth_hdr(skb)->h_source); - if (!is_broadcast_ether_addr(dest) && is_multicast_ether_addr(dest) && + if (is_multicast_ether_addr(dest) && br_multicast_rcv(br, p, skb)) goto drop; @@ -77,9 +77,7 @@ int br_handle_frame_finish(struct sk_buff *skb) dst = NULL; - if (is_broadcast_ether_addr(dest)) - skb2 = skb; - else if (is_multicast_ether_addr(dest)) { + if (is_multicast_ether_addr(dest)) { mdst = br_mdb_get(br, skb); if (mdst || BR_INPUT_SKB_CB_MROUTERS_ONLY(skb)) { if ((mdst && mdst->mglist) || diff --git a/trunk/net/bridge/br_multicast.c b/trunk/net/bridge/br_multicast.c index 2d85ca7111d3..29b9812c8da0 100644 --- a/trunk/net/bridge/br_multicast.c +++ b/trunk/net/bridge/br_multicast.c @@ -1379,11 +1379,8 @@ static int br_multicast_ipv4_rcv(struct net_bridge *br, if (unlikely(ip_fast_csum((u8 *)iph, iph->ihl))) return -EINVAL; - if (iph->protocol != IPPROTO_IGMP) { - if ((iph->daddr & IGMP_LOCAL_GROUP_MASK) != IGMP_LOCAL_GROUP) - BR_INPUT_SKB_CB(skb)->mrouters_only = 1; + if (iph->protocol != IPPROTO_IGMP) return 0; - } len = ntohs(iph->tot_len); if (skb->len < len || len < ip_hdrlen(skb)) diff --git a/trunk/net/bridge/br_netfilter.c b/trunk/net/bridge/br_netfilter.c index 75ee421917c7..56149ec36d7f 100644 --- a/trunk/net/bridge/br_netfilter.c +++ b/trunk/net/bridge/br_netfilter.c @@ -343,16 +343,14 @@ static int br_nf_pre_routing_finish_ipv6(struct sk_buff *skb) static int br_nf_pre_routing_finish_bridge(struct sk_buff *skb) { struct nf_bridge_info *nf_bridge = skb->nf_bridge; - struct neighbour *neigh; struct dst_entry *dst; skb->dev = bridge_parent(skb->dev); if (!skb->dev) goto free_skb; dst = skb_dst(skb); - neigh = dst->neighbour; - if (neigh->hh.hh_len) { - neigh_hh_bridge(&neigh->hh, skb); + if (dst->hh) { + neigh_hh_bridge(dst->hh, skb); skb->dev = nf_bridge->physindev; return br_handle_frame_finish(skb); } else if (dst->neighbour) { diff --git a/trunk/net/ceph/osd_client.c b/trunk/net/ceph/osd_client.c index 7330c2757c0c..9cb627a4073a 100644 --- a/trunk/net/ceph/osd_client.c +++ b/trunk/net/ceph/osd_client.c @@ -477,9 +477,8 @@ struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *osdc, calc_layout(osdc, vino, layout, off, plen, req, ops); req->r_file_layout = *layout; /* keep a copy */ - /* in case it differs from natural (file) alignment that - calc_layout filled in for us */ - req->r_num_pages = calc_pages_for(page_align, *plen); + /* in case it differs from natural alignment that calc_layout + filled in for us */ req->r_page_alignment = page_align; ceph_osdc_build_request(req, off, plen, ops, @@ -2028,9 +2027,8 @@ static struct ceph_msg *get_reply(struct ceph_connection *con, int want = calc_pages_for(req->r_page_alignment, data_len); if (unlikely(req->r_num_pages < want)) { - pr_warning("tid %lld reply has %d bytes %d pages, we" - " had only %d pages ready\n", tid, data_len, - want, req->r_num_pages); + pr_warning("tid %lld reply %d > expected %d pages\n", + tid, want, m->nr_pages); *skip = 1; ceph_msg_put(m); m = NULL; diff --git a/trunk/net/core/dev.c b/trunk/net/core/dev.c index 9ca15142d823..6b6ef14b42f2 100644 --- a/trunk/net/core/dev.c +++ b/trunk/net/core/dev.c @@ -199,11 +199,6 @@ static struct list_head ptype_all __read_mostly; /* Taps */ DEFINE_RWLOCK(dev_base_lock); EXPORT_SYMBOL(dev_base_lock); -static inline void dev_base_seq_inc(struct net *net) -{ - while (++net->dev_base_seq == 0); -} - static inline struct hlist_head *dev_name_hash(struct net *net, const char *name) { unsigned hash = full_name_hash(name, strnlen(name, IFNAMSIZ)); @@ -242,9 +237,6 @@ static int list_netdevice(struct net_device *dev) hlist_add_head_rcu(&dev->index_hlist, dev_index_hash(net, dev->ifindex)); write_unlock_bh(&dev_base_lock); - - dev_base_seq_inc(net); - return 0; } @@ -261,8 +253,6 @@ static void unlist_netdevice(struct net_device *dev) hlist_del_rcu(&dev->name_hlist); hlist_del_rcu(&dev->index_hlist); write_unlock_bh(&dev_base_lock); - - dev_base_seq_inc(dev_net(dev)); } /* @@ -5488,12 +5478,11 @@ int register_netdevice(struct net_device *dev) dev->features |= NETIF_F_NOCACHE_COPY; } - /* Enable GSO, GRO and NETIF_F_HIGHDMA for vlans by default, - * vlan_dev_fix_features() will do the features check, - * so NETIF_F_HIGHDMA feature is enabled only if supported - * by underlying device. + /* Enable GRO and NETIF_F_HIGHDMA for vlans by default, + * vlan_dev_init() will do the dev->features check, so these features + * are enabled only if supported by underlying device. */ - dev->vlan_features |= (NETIF_F_SOFT_FEATURES | NETIF_F_HIGHDMA); + dev->vlan_features |= (NETIF_F_GRO | NETIF_F_HIGHDMA); ret = call_netdevice_notifiers(NETDEV_POST_INIT, dev); ret = notifier_to_errno(ret); diff --git a/trunk/net/core/dst.c b/trunk/net/core/dst.c index 4aacc14936a0..9ccca038444f 100644 --- a/trunk/net/core/dst.c +++ b/trunk/net/core/dst.c @@ -172,6 +172,7 @@ void *dst_alloc(struct dst_ops *ops, struct net_device *dev, dst->expires = 0UL; dst->path = dst; dst->neighbour = NULL; + dst->hh = NULL; #ifdef CONFIG_XFRM dst->xfrm = NULL; #endif @@ -189,8 +190,7 @@ void *dst_alloc(struct dst_ops *ops, struct net_device *dev, dst->lastuse = jiffies; dst->flags = flags; dst->next = NULL; - if (!(flags & DST_NOCOUNT)) - dst_entries_add(ops, 1); + dst_entries_add(ops, 1); return dst; } EXPORT_SYMBOL(dst_alloc); @@ -225,20 +225,25 @@ struct dst_entry *dst_destroy(struct dst_entry * dst) { struct dst_entry *child; struct neighbour *neigh; + struct hh_cache *hh; smp_rmb(); again: neigh = dst->neighbour; + hh = dst->hh; child = dst->child; + dst->hh = NULL; + if (hh) + hh_cache_put(hh); + if (neigh) { dst->neighbour = NULL; neigh_release(neigh); } - if (!(dst->flags & DST_NOCOUNT)) - dst_entries_add(dst->ops, -1); + dst_entries_add(dst->ops, -1); if (dst->ops->destroy) dst->ops->destroy(dst); diff --git a/trunk/net/core/neighbour.c b/trunk/net/core/neighbour.c index 77a399f2ad03..ceb505b1507c 100644 --- a/trunk/net/core/neighbour.c +++ b/trunk/net/core/neighbour.c @@ -137,7 +137,7 @@ static int neigh_forced_gc(struct neigh_table *tbl) write_lock_bh(&tbl->lock); nht = rcu_dereference_protected(tbl->nht, lockdep_is_held(&tbl->lock)); - for (i = 0; i < (1 << nht->hash_shift); i++) { + for (i = 0; i <= nht->hash_mask; i++) { struct neighbour *n; struct neighbour __rcu **np; @@ -210,7 +210,7 @@ static void neigh_flush_dev(struct neigh_table *tbl, struct net_device *dev) nht = rcu_dereference_protected(tbl->nht, lockdep_is_held(&tbl->lock)); - for (i = 0; i < (1 << nht->hash_shift); i++) { + for (i = 0; i <= nht->hash_mask; i++) { struct neighbour *n; struct neighbour __rcu **np = &nht->hash_buckets[i]; @@ -297,7 +297,6 @@ static struct neighbour *neigh_alloc(struct neigh_table *tbl) n->updated = n->used = now; n->nud_state = NUD_NONE; n->output = neigh_blackhole; - seqlock_init(&n->hh.hh_lock); n->parms = neigh_parms_clone(&tbl->parms); setup_timer(&n->timer, neigh_timer_handler, (unsigned long)n); @@ -313,9 +312,9 @@ static struct neighbour *neigh_alloc(struct neigh_table *tbl) goto out; } -static struct neigh_hash_table *neigh_hash_alloc(unsigned int shift) +static struct neigh_hash_table *neigh_hash_alloc(unsigned int entries) { - size_t size = (1 << shift) * sizeof(struct neighbour *); + size_t size = entries * sizeof(struct neighbour *); struct neigh_hash_table *ret; struct neighbour __rcu **buckets; @@ -333,9 +332,8 @@ static struct neigh_hash_table *neigh_hash_alloc(unsigned int shift) return NULL; } ret->hash_buckets = buckets; - ret->hash_shift = shift; + ret->hash_mask = entries - 1; get_random_bytes(&ret->hash_rnd, sizeof(ret->hash_rnd)); - ret->hash_rnd |= 1; return ret; } @@ -344,7 +342,7 @@ static void neigh_hash_free_rcu(struct rcu_head *head) struct neigh_hash_table *nht = container_of(head, struct neigh_hash_table, rcu); - size_t size = (1 << nht->hash_shift) * sizeof(struct neighbour *); + size_t size = (nht->hash_mask + 1) * sizeof(struct neighbour *); struct neighbour __rcu **buckets = nht->hash_buckets; if (size <= PAGE_SIZE) @@ -355,20 +353,21 @@ static void neigh_hash_free_rcu(struct rcu_head *head) } static struct neigh_hash_table *neigh_hash_grow(struct neigh_table *tbl, - unsigned long new_shift) + unsigned long new_entries) { unsigned int i, hash; struct neigh_hash_table *new_nht, *old_nht; NEIGH_CACHE_STAT_INC(tbl, hash_grows); + BUG_ON(!is_power_of_2(new_entries)); old_nht = rcu_dereference_protected(tbl->nht, lockdep_is_held(&tbl->lock)); - new_nht = neigh_hash_alloc(new_shift); + new_nht = neigh_hash_alloc(new_entries); if (!new_nht) return old_nht; - for (i = 0; i < (1 << old_nht->hash_shift); i++) { + for (i = 0; i <= old_nht->hash_mask; i++) { struct neighbour *n, *next; for (n = rcu_dereference_protected(old_nht->hash_buckets[i], @@ -378,7 +377,7 @@ static struct neigh_hash_table *neigh_hash_grow(struct neigh_table *tbl, hash = tbl->hash(n->primary_key, n->dev, new_nht->hash_rnd); - hash >>= (32 - new_nht->hash_shift); + hash &= new_nht->hash_mask; next = rcu_dereference_protected(n->next, lockdep_is_held(&tbl->lock)); @@ -407,7 +406,7 @@ struct neighbour *neigh_lookup(struct neigh_table *tbl, const void *pkey, rcu_read_lock_bh(); nht = rcu_dereference_bh(tbl->nht); - hash_val = tbl->hash(pkey, dev, nht->hash_rnd) >> (32 - nht->hash_shift); + hash_val = tbl->hash(pkey, dev, nht->hash_rnd) & nht->hash_mask; for (n = rcu_dereference_bh(nht->hash_buckets[hash_val]); n != NULL; @@ -437,7 +436,7 @@ struct neighbour *neigh_lookup_nodev(struct neigh_table *tbl, struct net *net, rcu_read_lock_bh(); nht = rcu_dereference_bh(tbl->nht); - hash_val = tbl->hash(pkey, NULL, nht->hash_rnd) >> (32 - nht->hash_shift); + hash_val = tbl->hash(pkey, NULL, nht->hash_rnd) & nht->hash_mask; for (n = rcu_dereference_bh(nht->hash_buckets[hash_val]); n != NULL; @@ -493,10 +492,10 @@ struct neighbour *neigh_create(struct neigh_table *tbl, const void *pkey, nht = rcu_dereference_protected(tbl->nht, lockdep_is_held(&tbl->lock)); - if (atomic_read(&tbl->entries) > (1 << nht->hash_shift)) - nht = neigh_hash_grow(tbl, nht->hash_shift + 1); + if (atomic_read(&tbl->entries) > (nht->hash_mask + 1)) + nht = neigh_hash_grow(tbl, (nht->hash_mask + 1) << 1); - hash_val = tbl->hash(pkey, dev, nht->hash_rnd) >> (32 - nht->hash_shift); + hash_val = tbl->hash(pkey, dev, nht->hash_rnd) & nht->hash_mask; if (n->parms->dead) { rc = ERR_PTR(-EINVAL); @@ -703,11 +702,14 @@ void neigh_destroy(struct neighbour *neigh) if (neigh_del_timer(neigh)) printk(KERN_WARNING "Impossible event.\n"); - hh = &neigh->hh; - if (hh->hh_len) { + while ((hh = neigh->hh) != NULL) { + neigh->hh = hh->hh_next; + hh->hh_next = NULL; + write_seqlock_bh(&hh->hh_lock); hh->hh_output = neigh_blackhole; write_sequnlock_bh(&hh->hh_lock); + hh_cache_put(hh); } skb_queue_purge(&neigh->arp_queue); @@ -735,8 +737,7 @@ static void neigh_suspect(struct neighbour *neigh) neigh->output = neigh->ops->output; - hh = &neigh->hh; - if (hh->hh_len) + for (hh = neigh->hh; hh; hh = hh->hh_next) hh->hh_output = neigh->ops->output; } @@ -753,8 +754,7 @@ static void neigh_connect(struct neighbour *neigh) neigh->output = neigh->ops->connected_output; - hh = &neigh->hh; - if (hh->hh_len) + for (hh = neigh->hh; hh; hh = hh->hh_next) hh->hh_output = neigh->ops->hh_output; } @@ -784,7 +784,7 @@ static void neigh_periodic_work(struct work_struct *work) neigh_rand_reach_time(p->base_reachable_time); } - for (i = 0 ; i < (1 << nht->hash_shift); i++) { + for (i = 0 ; i <= nht->hash_mask; i++) { np = &nht->hash_buckets[i]; while ((n = rcu_dereference_protected(*np, @@ -1015,7 +1015,7 @@ int __neigh_event_send(struct neighbour *neigh, struct sk_buff *skb) } EXPORT_SYMBOL(__neigh_event_send); -static void neigh_update_hhs(struct neighbour *neigh) +static void neigh_update_hhs(const struct neighbour *neigh) { struct hh_cache *hh; void (*update)(struct hh_cache*, const struct net_device*, const unsigned char *) @@ -1025,8 +1025,7 @@ static void neigh_update_hhs(struct neighbour *neigh) update = neigh->dev->header_ops->cache_update; if (update) { - hh = &neigh->hh; - if (hh->hh_len) { + for (hh = neigh->hh; hh; hh = hh->hh_next) { write_seqlock_bh(&hh->hh_lock); update(hh, neigh->dev, neigh->ha); write_sequnlock_bh(&hh->hh_lock); @@ -1212,29 +1211,66 @@ struct neighbour *neigh_event_ns(struct neigh_table *tbl, } EXPORT_SYMBOL(neigh_event_ns); +static inline bool neigh_hh_lookup(struct neighbour *n, struct dst_entry *dst, + __be16 protocol) +{ + struct hh_cache *hh; + + smp_rmb(); /* paired with smp_wmb() in neigh_hh_init() */ + for (hh = n->hh; hh; hh = hh->hh_next) { + if (hh->hh_type == protocol) { + atomic_inc(&hh->hh_refcnt); + if (unlikely(cmpxchg(&dst->hh, NULL, hh) != NULL)) + hh_cache_put(hh); + return true; + } + } + return false; +} + /* called with read_lock_bh(&n->lock); */ -static void neigh_hh_init(struct neighbour *n, struct dst_entry *dst) +static void neigh_hh_init(struct neighbour *n, struct dst_entry *dst, + __be16 protocol) { + struct hh_cache *hh; struct net_device *dev = dst->dev; - __be16 prot = dst->ops->protocol; - struct hh_cache *hh = &n->hh; - write_lock_bh(&n->lock); + if (likely(neigh_hh_lookup(n, dst, protocol))) + return; - /* Only one thread can come in here and initialize the - * hh_cache entry. - */ - if (hh->hh_len) - goto end; + /* slow path */ + hh = kzalloc(sizeof(*hh), GFP_ATOMIC); + if (!hh) + return; + + seqlock_init(&hh->hh_lock); + hh->hh_type = protocol; + atomic_set(&hh->hh_refcnt, 2); + + if (dev->header_ops->cache(n, hh)) { + kfree(hh); + return; + } + + write_lock_bh(&n->lock); - if (dev->header_ops->cache(n, hh, prot)) + /* must check if another thread already did the insert */ + if (neigh_hh_lookup(n, dst, protocol)) { + kfree(hh); goto end; + } if (n->nud_state & NUD_CONNECTED) hh->hh_output = n->ops->hh_output; else hh->hh_output = n->ops->output; + hh->hh_next = n->hh; + smp_wmb(); /* paired with smp_rmb() in neigh_hh_lookup() */ + n->hh = hh; + + if (unlikely(cmpxchg(&dst->hh, NULL, hh) != NULL)) + hh_cache_put(hh); end: write_unlock_bh(&n->lock); } @@ -1277,8 +1313,10 @@ int neigh_resolve_output(struct sk_buff *skb) struct net_device *dev = neigh->dev; unsigned int seq; - if (dev->header_ops->cache && !neigh->hh.hh_len) - neigh_hh_init(neigh, dst); + if (dev->header_ops->cache && + !dst->hh && + !(dst->flags & DST_NOCACHE)) + neigh_hh_init(neigh, dst, dst->ops->protocol); do { seq = read_seqbegin(&neigh->ha_lock); @@ -1502,7 +1540,7 @@ void neigh_table_init_no_netlink(struct neigh_table *tbl) panic("cannot create neighbour proc dir entry"); #endif - RCU_INIT_POINTER(tbl->nht, neigh_hash_alloc(3)); + RCU_INIT_POINTER(tbl->nht, neigh_hash_alloc(8)); phsize = (PNEIGH_HASHMASK + 1) * sizeof(struct pneigh_entry *); tbl->phash_buckets = kzalloc(phsize, GFP_KERNEL); @@ -1819,7 +1857,7 @@ static int neightbl_fill_info(struct sk_buff *skb, struct neigh_table *tbl, rcu_read_lock_bh(); nht = rcu_dereference_bh(tbl->nht); ndc.ndtc_hash_rnd = nht->hash_rnd; - ndc.ndtc_hash_mask = ((1 << nht->hash_shift) - 1); + ndc.ndtc_hash_mask = nht->hash_mask; rcu_read_unlock_bh(); NLA_PUT(skb, NDTA_CONFIG, sizeof(ndc), &ndc); @@ -2162,7 +2200,7 @@ static int neigh_dump_table(struct neigh_table *tbl, struct sk_buff *skb, rcu_read_lock_bh(); nht = rcu_dereference_bh(tbl->nht); - for (h = 0; h < (1 << nht->hash_shift); h++) { + for (h = 0; h <= nht->hash_mask; h++) { if (h < s_h) continue; if (h > s_h) @@ -2226,7 +2264,7 @@ void neigh_for_each(struct neigh_table *tbl, void (*cb)(struct neighbour *, void nht = rcu_dereference_bh(tbl->nht); read_lock(&tbl->lock); /* avoid resizes */ - for (chain = 0; chain < (1 << nht->hash_shift); chain++) { + for (chain = 0; chain <= nht->hash_mask; chain++) { struct neighbour *n; for (n = rcu_dereference_bh(nht->hash_buckets[chain]); @@ -2248,7 +2286,7 @@ void __neigh_for_each_release(struct neigh_table *tbl, nht = rcu_dereference_protected(tbl->nht, lockdep_is_held(&tbl->lock)); - for (chain = 0; chain < (1 << nht->hash_shift); chain++) { + for (chain = 0; chain <= nht->hash_mask; chain++) { struct neighbour *n; struct neighbour __rcu **np; @@ -2285,7 +2323,7 @@ static struct neighbour *neigh_get_first(struct seq_file *seq) int bucket = state->bucket; state->flags &= ~NEIGH_SEQ_IS_PNEIGH; - for (bucket = 0; bucket < (1 << nht->hash_shift); bucket++) { + for (bucket = 0; bucket <= nht->hash_mask; bucket++) { n = rcu_dereference_bh(nht->hash_buckets[bucket]); while (n) { @@ -2352,7 +2390,7 @@ static struct neighbour *neigh_get_next(struct seq_file *seq, if (n) break; - if (++state->bucket >= (1 << nht->hash_shift)) + if (++state->bucket > nht->hash_mask) break; n = rcu_dereference_bh(nht->hash_buckets[state->bucket]); diff --git a/trunk/net/core/net_namespace.c b/trunk/net/core/net_namespace.c index 5bbdbf0d3664..ea489db1bc23 100644 --- a/trunk/net/core/net_namespace.c +++ b/trunk/net/core/net_namespace.c @@ -129,7 +129,6 @@ static __net_init int setup_net(struct net *net) atomic_set(&net->count, 1); atomic_set(&net->passive, 1); - net->dev_base_seq = 1; #ifdef NETNS_REFCNT_DEBUG atomic_set(&net->use_count, 0); diff --git a/trunk/net/core/netpoll.c b/trunk/net/core/netpoll.c index adf84dd8c7b5..18d9cbda3a39 100644 --- a/trunk/net/core/netpoll.c +++ b/trunk/net/core/netpoll.c @@ -177,7 +177,7 @@ static void service_arp_queue(struct netpoll_info *npi) } } -static void netpoll_poll_dev(struct net_device *dev) +void netpoll_poll_dev(struct net_device *dev) { const struct net_device_ops *ops; @@ -208,6 +208,13 @@ static void netpoll_poll_dev(struct net_device *dev) zap_completion_queue(); } +EXPORT_SYMBOL(netpoll_poll_dev); + +void netpoll_poll(struct netpoll *np) +{ + netpoll_poll_dev(np->dev); +} +EXPORT_SYMBOL(netpoll_poll); static void refill_skbs(void) { @@ -268,7 +275,7 @@ static struct sk_buff *find_skb(struct netpoll *np, int len, int reserve) if (!skb) { if (++count < 10) { - netpoll_poll_dev(np->dev); + netpoll_poll(np); goto repeat; } return NULL; @@ -329,7 +336,7 @@ void netpoll_send_skb_on_dev(struct netpoll *np, struct sk_buff *skb, } /* tickle device maybe there is some cleanup */ - netpoll_poll_dev(np->dev); + netpoll_poll(np); udelay(USEC_PER_POLL); } diff --git a/trunk/net/core/rtnetlink.c b/trunk/net/core/rtnetlink.c index 99d9e953fe39..a798fc6f2aa1 100644 --- a/trunk/net/core/rtnetlink.c +++ b/trunk/net/core/rtnetlink.c @@ -1032,8 +1032,6 @@ static int rtnl_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb) s_idx = cb->args[1]; rcu_read_lock(); - cb->seq = net->dev_base_seq; - for (h = s_h; h < NETDEV_HASHENTRIES; h++, s_idx = 0) { idx = 0; head = &net->dev_index_head[h]; @@ -1045,8 +1043,6 @@ static int rtnl_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb) cb->nlh->nlmsg_seq, 0, NLM_F_MULTI) <= 0) goto out; - - nl_dump_check_consistent(cb, nlmsg_hdr(skb)); cont: idx++; } diff --git a/trunk/net/core/skbuff.c b/trunk/net/core/skbuff.c index d220119f13ab..46cbd28f40f9 100644 --- a/trunk/net/core/skbuff.c +++ b/trunk/net/core/skbuff.c @@ -329,18 +329,6 @@ static void skb_release_data(struct sk_buff *skb) put_page(skb_shinfo(skb)->frags[i].page); } - /* - * If skb buf is from userspace, we need to notify the caller - * the lower device DMA has done; - */ - if (skb_shinfo(skb)->tx_flags & SKBTX_DEV_ZEROCOPY) { - struct ubuf_info *uarg; - - uarg = skb_shinfo(skb)->destructor_arg; - if (uarg->callback) - uarg->callback(uarg); - } - if (skb_has_frag_list(skb)) skb_drop_fraglist(skb); @@ -493,9 +481,6 @@ bool skb_recycle_check(struct sk_buff *skb, int skb_size) if (irqs_disabled()) return false; - if (skb_shinfo(skb)->tx_flags & SKBTX_DEV_ZEROCOPY) - return false; - if (skb_is_nonlinear(skb) || skb->fclone != SKB_FCLONE_UNAVAILABLE) return false; @@ -611,51 +596,6 @@ struct sk_buff *skb_morph(struct sk_buff *dst, struct sk_buff *src) } EXPORT_SYMBOL_GPL(skb_morph); -/* skb frags copy userspace buffers to kernel */ -static int skb_copy_ubufs(struct sk_buff *skb, gfp_t gfp_mask) -{ - int i; - int num_frags = skb_shinfo(skb)->nr_frags; - struct page *page, *head = NULL; - struct ubuf_info *uarg = skb_shinfo(skb)->destructor_arg; - - for (i = 0; i < num_frags; i++) { - u8 *vaddr; - skb_frag_t *f = &skb_shinfo(skb)->frags[i]; - - page = alloc_page(GFP_ATOMIC); - if (!page) { - while (head) { - struct page *next = (struct page *)head->private; - put_page(head); - head = next; - } - return -ENOMEM; - } - vaddr = kmap_skb_frag(&skb_shinfo(skb)->frags[i]); - memcpy(page_address(page), - vaddr + f->page_offset, f->size); - kunmap_skb_frag(vaddr); - page->private = (unsigned long)head; - head = page; - } - - /* skb frags release userspace buffers */ - for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) - put_page(skb_shinfo(skb)->frags[i].page); - - uarg->callback(uarg); - - /* skb frags point to kernel buffers */ - for (i = skb_shinfo(skb)->nr_frags; i > 0; i--) { - skb_shinfo(skb)->frags[i - 1].page_offset = 0; - skb_shinfo(skb)->frags[i - 1].page = head; - head = (struct page *)head->private; - } - return 0; -} - - /** * skb_clone - duplicate an sk_buff * @skb: buffer to clone @@ -674,12 +614,6 @@ struct sk_buff *skb_clone(struct sk_buff *skb, gfp_t gfp_mask) { struct sk_buff *n; - if (skb_shinfo(skb)->tx_flags & SKBTX_DEV_ZEROCOPY) { - if (skb_copy_ubufs(skb, gfp_mask)) - return NULL; - skb_shinfo(skb)->tx_flags &= ~SKBTX_DEV_ZEROCOPY; - } - n = skb + 1; if (skb->fclone == SKB_FCLONE_ORIG && n->fclone == SKB_FCLONE_UNAVAILABLE) { @@ -797,13 +731,6 @@ struct sk_buff *pskb_copy(struct sk_buff *skb, gfp_t gfp_mask) if (skb_shinfo(skb)->nr_frags) { int i; - if (skb_shinfo(skb)->tx_flags & SKBTX_DEV_ZEROCOPY) { - if (skb_copy_ubufs(skb, gfp_mask)) { - kfree(n); - goto out; - } - skb_shinfo(skb)->tx_flags &= ~SKBTX_DEV_ZEROCOPY; - } for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { skb_shinfo(n)->frags[i] = skb_shinfo(skb)->frags[i]; get_page(skb_shinfo(n)->frags[i].page); @@ -861,6 +788,7 @@ int pskb_expand_head(struct sk_buff *skb, int nhead, int ntail, fastpath = true; else { int delta = skb->nohdr ? (1 << SKB_DATAREF_SHIFT) + 1 : 1; + fastpath = atomic_read(&skb_shinfo(skb)->dataref) == delta; } @@ -891,12 +819,6 @@ int pskb_expand_head(struct sk_buff *skb, int nhead, int ntail, if (fastpath) { kfree(skb->head); } else { - /* copy this zero copy skb frags */ - if (skb_shinfo(skb)->tx_flags & SKBTX_DEV_ZEROCOPY) { - if (skb_copy_ubufs(skb, gfp_mask)) - goto nofrags; - skb_shinfo(skb)->tx_flags &= ~SKBTX_DEV_ZEROCOPY; - } for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) get_page(skb_shinfo(skb)->frags[i].page); @@ -931,8 +853,6 @@ int pskb_expand_head(struct sk_buff *skb, int nhead, int ntail, atomic_set(&skb_shinfo(skb)->dataref, 1); return 0; -nofrags: - kfree(data); nodata: return -ENOMEM; } @@ -1434,7 +1354,6 @@ int skb_copy_bits(const struct sk_buff *skb, int offset, void *to, int len) } start = end; } - if (!len) return 0; diff --git a/trunk/net/core/sock.c b/trunk/net/core/sock.c index bc745d00ea4d..76c403146750 100644 --- a/trunk/net/core/sock.c +++ b/trunk/net/core/sock.c @@ -160,7 +160,7 @@ static const char *const af_family_key_strings[AF_MAX+1] = { "sk_lock-AF_TIPC" , "sk_lock-AF_BLUETOOTH", "sk_lock-IUCV" , "sk_lock-AF_RXRPC" , "sk_lock-AF_ISDN" , "sk_lock-AF_PHONET" , "sk_lock-AF_IEEE802154", "sk_lock-AF_CAIF" , "sk_lock-AF_ALG" , - "sk_lock-AF_NFC" , "sk_lock-AF_MAX" + "sk_lock-AF_MAX" }; static const char *const af_family_slock_key_strings[AF_MAX+1] = { "slock-AF_UNSPEC", "slock-AF_UNIX" , "slock-AF_INET" , @@ -176,7 +176,7 @@ static const char *const af_family_slock_key_strings[AF_MAX+1] = { "slock-AF_TIPC" , "slock-AF_BLUETOOTH", "slock-AF_IUCV" , "slock-AF_RXRPC" , "slock-AF_ISDN" , "slock-AF_PHONET" , "slock-AF_IEEE802154", "slock-AF_CAIF" , "slock-AF_ALG" , - "slock-AF_NFC" , "slock-AF_MAX" + "slock-AF_MAX" }; static const char *const af_family_clock_key_strings[AF_MAX+1] = { "clock-AF_UNSPEC", "clock-AF_UNIX" , "clock-AF_INET" , @@ -192,7 +192,7 @@ static const char *const af_family_clock_key_strings[AF_MAX+1] = { "clock-AF_TIPC" , "clock-AF_BLUETOOTH", "clock-AF_IUCV" , "clock-AF_RXRPC" , "clock-AF_ISDN" , "clock-AF_PHONET" , "clock-AF_IEEE802154", "clock-AF_CAIF" , "clock-AF_ALG" , - "clock-AF_NFC" , "clock-AF_MAX" + "clock-AF_MAX" }; /* diff --git a/trunk/net/dcb/dcbnl.c b/trunk/net/dcb/dcbnl.c index 3cb56af4e13c..fc56e8546261 100644 --- a/trunk/net/dcb/dcbnl.c +++ b/trunk/net/dcb/dcbnl.c @@ -1310,196 +1310,8 @@ static int dcbnl_ieee_fill(struct sk_buff *skb, struct net_device *netdev) return err; } -static int dcbnl_cee_pg_fill(struct sk_buff *skb, struct net_device *dev, - int dir) -{ - u8 pgid, up_map, prio, tc_pct; - const struct dcbnl_rtnl_ops *ops = dev->dcbnl_ops; - int i = dir ? DCB_ATTR_CEE_TX_PG : DCB_ATTR_CEE_RX_PG; - struct nlattr *pg = nla_nest_start(skb, i); - - if (!pg) - goto nla_put_failure; - - for (i = DCB_PG_ATTR_TC_0; i <= DCB_PG_ATTR_TC_7; i++) { - struct nlattr *tc_nest = nla_nest_start(skb, i); - - if (!tc_nest) - goto nla_put_failure; - - pgid = DCB_ATTR_VALUE_UNDEFINED; - prio = DCB_ATTR_VALUE_UNDEFINED; - tc_pct = DCB_ATTR_VALUE_UNDEFINED; - up_map = DCB_ATTR_VALUE_UNDEFINED; - - if (!dir) - ops->getpgtccfgrx(dev, i - DCB_PG_ATTR_TC_0, - &prio, &pgid, &tc_pct, &up_map); - else - ops->getpgtccfgtx(dev, i - DCB_PG_ATTR_TC_0, - &prio, &pgid, &tc_pct, &up_map); - - NLA_PUT_U8(skb, DCB_TC_ATTR_PARAM_PGID, pgid); - NLA_PUT_U8(skb, DCB_TC_ATTR_PARAM_UP_MAPPING, up_map); - NLA_PUT_U8(skb, DCB_TC_ATTR_PARAM_STRICT_PRIO, prio); - NLA_PUT_U8(skb, DCB_TC_ATTR_PARAM_BW_PCT, tc_pct); - nla_nest_end(skb, tc_nest); - } - - for (i = DCB_PG_ATTR_BW_ID_0; i <= DCB_PG_ATTR_BW_ID_7; i++) { - tc_pct = DCB_ATTR_VALUE_UNDEFINED; - - if (!dir) - ops->getpgbwgcfgrx(dev, i - DCB_PG_ATTR_BW_ID_0, - &tc_pct); - else - ops->getpgbwgcfgtx(dev, i - DCB_PG_ATTR_BW_ID_0, - &tc_pct); - NLA_PUT_U8(skb, i, tc_pct); - } - nla_nest_end(skb, pg); - return 0; - -nla_put_failure: - return -EMSGSIZE; -} - -static int dcbnl_cee_fill(struct sk_buff *skb, struct net_device *netdev) -{ - struct nlattr *cee, *app; - struct dcb_app_type *itr; - const struct dcbnl_rtnl_ops *ops = netdev->dcbnl_ops; - int dcbx, i, err = -EMSGSIZE; - u8 value; - - NLA_PUT_STRING(skb, DCB_ATTR_IFNAME, netdev->name); - - cee = nla_nest_start(skb, DCB_ATTR_CEE); - if (!cee) - goto nla_put_failure; - - /* local pg */ - if (ops->getpgtccfgtx && ops->getpgbwgcfgtx) { - err = dcbnl_cee_pg_fill(skb, netdev, 1); - if (err) - goto nla_put_failure; - } - - if (ops->getpgtccfgrx && ops->getpgbwgcfgrx) { - err = dcbnl_cee_pg_fill(skb, netdev, 0); - if (err) - goto nla_put_failure; - } - - /* local pfc */ - if (ops->getpfccfg) { - struct nlattr *pfc_nest = nla_nest_start(skb, DCB_ATTR_CEE_PFC); - - if (!pfc_nest) - goto nla_put_failure; - - for (i = DCB_PFC_UP_ATTR_0; i <= DCB_PFC_UP_ATTR_7; i++) { - ops->getpfccfg(netdev, i - DCB_PFC_UP_ATTR_0, &value); - NLA_PUT_U8(skb, i, value); - } - nla_nest_end(skb, pfc_nest); - } - - /* local app */ - spin_lock(&dcb_lock); - app = nla_nest_start(skb, DCB_ATTR_CEE_APP_TABLE); - if (!app) - goto dcb_unlock; - - list_for_each_entry(itr, &dcb_app_list, list) { - if (strncmp(itr->name, netdev->name, IFNAMSIZ) == 0) { - struct nlattr *app_nest = nla_nest_start(skb, - DCB_ATTR_APP); - if (!app_nest) - goto dcb_unlock; - - err = nla_put_u8(skb, DCB_APP_ATTR_IDTYPE, - itr->app.selector); - if (err) - goto dcb_unlock; - - err = nla_put_u16(skb, DCB_APP_ATTR_ID, - itr->app.protocol); - if (err) - goto dcb_unlock; - - err = nla_put_u8(skb, DCB_APP_ATTR_PRIORITY, - itr->app.priority); - if (err) - goto dcb_unlock; - - nla_nest_end(skb, app_nest); - } - } - nla_nest_end(skb, app); - - if (netdev->dcbnl_ops->getdcbx) - dcbx = netdev->dcbnl_ops->getdcbx(netdev); - else - dcbx = -EOPNOTSUPP; - - spin_unlock(&dcb_lock); - - /* features flags */ - if (ops->getfeatcfg) { - struct nlattr *feat = nla_nest_start(skb, DCB_ATTR_CEE_FEAT); - if (!feat) - goto nla_put_failure; - - for (i = DCB_FEATCFG_ATTR_ALL + 1; i <= DCB_FEATCFG_ATTR_MAX; - i++) - if (!ops->getfeatcfg(netdev, i, &value)) - NLA_PUT_U8(skb, i, value); - - nla_nest_end(skb, feat); - } - - /* peer info if available */ - if (ops->cee_peer_getpg) { - struct cee_pg pg; - err = ops->cee_peer_getpg(netdev, &pg); - if (!err) - NLA_PUT(skb, DCB_ATTR_CEE_PEER_PG, sizeof(pg), &pg); - } - - if (ops->cee_peer_getpfc) { - struct cee_pfc pfc; - err = ops->cee_peer_getpfc(netdev, &pfc); - if (!err) - NLA_PUT(skb, DCB_ATTR_CEE_PEER_PFC, sizeof(pfc), &pfc); - } - - if (ops->peer_getappinfo && ops->peer_getapptable) { - err = dcbnl_build_peer_app(netdev, skb, - DCB_ATTR_CEE_PEER_APP_TABLE, - DCB_ATTR_CEE_PEER_APP_INFO, - DCB_ATTR_CEE_PEER_APP); - if (err) - goto nla_put_failure; - } - nla_nest_end(skb, cee); - - /* DCBX state */ - if (dcbx >= 0) { - err = nla_put_u8(skb, DCB_ATTR_DCBX, dcbx); - if (err) - goto nla_put_failure; - } - return 0; - -dcb_unlock: - spin_unlock(&dcb_lock); -nla_put_failure: - return err; -} - -static int dcbnl_notify(struct net_device *dev, int event, int cmd, - u32 seq, u32 pid, int dcbx_ver) +int dcbnl_notify(struct net_device *dev, int event, int cmd, + u32 seq, u32 pid) { struct net *net = dev_net(dev); struct sk_buff *skb; @@ -1525,11 +1337,7 @@ static int dcbnl_notify(struct net_device *dev, int event, int cmd, dcb->dcb_family = AF_UNSPEC; dcb->cmd = cmd; - if (dcbx_ver == DCB_CAP_DCBX_VER_IEEE) - err = dcbnl_ieee_fill(skb, dev); - else - err = dcbnl_cee_fill(skb, dev); - + err = dcbnl_ieee_fill(skb, dev); if (err < 0) { /* Report error to broadcast listeners */ nlmsg_cancel(skb, nlh); @@ -1543,20 +1351,7 @@ static int dcbnl_notify(struct net_device *dev, int event, int cmd, return err; } - -int dcbnl_ieee_notify(struct net_device *dev, int event, int cmd, - u32 seq, u32 pid) -{ - return dcbnl_notify(dev, event, cmd, seq, pid, DCB_CAP_DCBX_VER_IEEE); -} -EXPORT_SYMBOL(dcbnl_ieee_notify); - -int dcbnl_cee_notify(struct net_device *dev, int event, int cmd, - u32 seq, u32 pid) -{ - return dcbnl_notify(dev, event, cmd, seq, pid, DCB_CAP_DCBX_VER_CEE); -} -EXPORT_SYMBOL(dcbnl_cee_notify); +EXPORT_SYMBOL(dcbnl_notify); /* Handle IEEE 802.1Qaz SET commands. If any requested operation can not * be completed the entire msg is aborted and error value is returned. @@ -1616,7 +1411,7 @@ static int dcbnl_ieee_set(struct net_device *netdev, struct nlattr **tb, err: dcbnl_reply(err, RTM_SETDCB, DCB_CMD_IEEE_SET, DCB_ATTR_IEEE, pid, seq, flags); - dcbnl_ieee_notify(netdev, RTM_SETDCB, DCB_CMD_IEEE_SET, seq, 0); + dcbnl_notify(netdev, RTM_SETDCB, DCB_CMD_IEEE_SET, seq, 0); return err; } @@ -1700,7 +1495,7 @@ static int dcbnl_ieee_del(struct net_device *netdev, struct nlattr **tb, err: dcbnl_reply(err, RTM_SETDCB, DCB_CMD_IEEE_DEL, DCB_ATTR_IEEE, pid, seq, flags); - dcbnl_ieee_notify(netdev, RTM_SETDCB, DCB_CMD_IEEE_DEL, seq, 0); + dcbnl_notify(netdev, RTM_SETDCB, DCB_CMD_IEEE_DEL, seq, 0); return err; } @@ -1851,10 +1646,10 @@ static int dcbnl_setfeatcfg(struct net_device *netdev, struct nlattr **tb, static int dcbnl_cee_get(struct net_device *netdev, struct nlattr **tb, u32 pid, u32 seq, u16 flags) { - struct net *net = dev_net(netdev); struct sk_buff *skb; struct nlmsghdr *nlh; struct dcbmsg *dcb; + struct nlattr *cee; const struct dcbnl_rtnl_ops *ops = netdev->dcbnl_ops; int err; @@ -1865,26 +1660,51 @@ static int dcbnl_cee_get(struct net_device *netdev, struct nlattr **tb, if (!skb) return -ENOBUFS; - nlh = nlmsg_put(skb, pid, seq, RTM_GETDCB, sizeof(*dcb), flags); - if (nlh == NULL) { - nlmsg_free(skb); - return -EMSGSIZE; - } + nlh = NLMSG_NEW(skb, pid, seq, RTM_GETDCB, sizeof(*dcb), flags); dcb = NLMSG_DATA(nlh); dcb->dcb_family = AF_UNSPEC; dcb->cmd = DCB_CMD_CEE_GET; - err = dcbnl_cee_fill(skb, netdev); + NLA_PUT_STRING(skb, DCB_ATTR_IFNAME, netdev->name); - if (err < 0) { - nlmsg_cancel(skb, nlh); - nlmsg_free(skb); - } else { - nlmsg_end(skb, nlh); - err = rtnl_unicast(skb, net, pid); + cee = nla_nest_start(skb, DCB_ATTR_CEE); + if (!cee) + goto nla_put_failure; + + /* get peer info if available */ + if (ops->cee_peer_getpg) { + struct cee_pg pg; + err = ops->cee_peer_getpg(netdev, &pg); + if (!err) + NLA_PUT(skb, DCB_ATTR_CEE_PEER_PG, sizeof(pg), &pg); } - return err; + + if (ops->cee_peer_getpfc) { + struct cee_pfc pfc; + err = ops->cee_peer_getpfc(netdev, &pfc); + if (!err) + NLA_PUT(skb, DCB_ATTR_CEE_PEER_PFC, sizeof(pfc), &pfc); + } + + if (ops->peer_getappinfo && ops->peer_getapptable) { + err = dcbnl_build_peer_app(netdev, skb, + DCB_ATTR_CEE_PEER_APP_TABLE, + DCB_ATTR_CEE_PEER_APP_INFO, + DCB_ATTR_CEE_PEER_APP); + if (err) + goto nla_put_failure; + } + + nla_nest_end(skb, cee); + nlmsg_end(skb, nlh); + + return rtnl_unicast(skb, &init_net, pid); +nla_put_failure: + nlmsg_cancel(skb, nlh); +nlmsg_failure: + kfree_skb(skb); + return -1; } static int dcb_doit(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg) diff --git a/trunk/net/dccp/ccid.c b/trunk/net/dccp/ccid.c index 48b585a5cba7..36479ca61e03 100644 --- a/trunk/net/dccp/ccid.c +++ b/trunk/net/dccp/ccid.c @@ -118,7 +118,7 @@ static int ccid_activate(struct ccid_operations *ccid_ops) if (ccid_ops->ccid_hc_tx_slab == NULL) goto out_free_rx_slab; - pr_info("DCCP: Activated CCID %d (%s)\n", + pr_info("CCID: Activated CCID %d (%s)\n", ccid_ops->ccid_id, ccid_ops->ccid_name); err = 0; out: @@ -136,7 +136,7 @@ static void ccid_deactivate(struct ccid_operations *ccid_ops) ccid_kmem_cache_destroy(ccid_ops->ccid_hc_rx_slab); ccid_ops->ccid_hc_rx_slab = NULL; - pr_info("DCCP: Deactivated CCID %d (%s)\n", + pr_info("CCID: Deactivated CCID %d (%s)\n", ccid_ops->ccid_id, ccid_ops->ccid_name); } diff --git a/trunk/net/dccp/ccids/ccid2.c b/trunk/net/dccp/ccids/ccid2.c index 0462040fc818..fadecd20d75b 100644 --- a/trunk/net/dccp/ccids/ccid2.c +++ b/trunk/net/dccp/ccids/ccid2.c @@ -153,93 +153,17 @@ static void ccid2_hc_tx_rto_expire(unsigned long data) sock_put(sk); } -/* - * Congestion window validation (RFC 2861). - */ -static int ccid2_do_cwv = 1; -module_param(ccid2_do_cwv, bool, 0644); -MODULE_PARM_DESC(ccid2_do_cwv, "Perform RFC2861 Congestion Window Validation"); - -/** - * ccid2_update_used_window - Track how much of cwnd is actually used - * This is done in addition to CWV. The sender needs to have an idea of how many - * packets may be in flight, to set the local Sequence Window value accordingly - * (RFC 4340, 7.5.2). The CWV mechanism is exploited to keep track of the - * maximum-used window. We use an EWMA low-pass filter to filter out noise. - */ -static void ccid2_update_used_window(struct ccid2_hc_tx_sock *hc, u32 new_wnd) -{ - hc->tx_expected_wnd = (3 * hc->tx_expected_wnd + new_wnd) / 4; -} - -/* This borrows the code of tcp_cwnd_application_limited() */ -static void ccid2_cwnd_application_limited(struct sock *sk, const u32 now) -{ - struct ccid2_hc_tx_sock *hc = ccid2_hc_tx_sk(sk); - /* don't reduce cwnd below the initial window (IW) */ - u32 init_win = rfc3390_bytes_to_packets(dccp_sk(sk)->dccps_mss_cache), - win_used = max(hc->tx_cwnd_used, init_win); - - if (win_used < hc->tx_cwnd) { - hc->tx_ssthresh = max(hc->tx_ssthresh, - (hc->tx_cwnd >> 1) + (hc->tx_cwnd >> 2)); - hc->tx_cwnd = (hc->tx_cwnd + win_used) >> 1; - } - hc->tx_cwnd_used = 0; - hc->tx_cwnd_stamp = now; -} - -/* This borrows the code of tcp_cwnd_restart() */ -static void ccid2_cwnd_restart(struct sock *sk, const u32 now) -{ - struct ccid2_hc_tx_sock *hc = ccid2_hc_tx_sk(sk); - u32 cwnd = hc->tx_cwnd, restart_cwnd, - iwnd = rfc3390_bytes_to_packets(dccp_sk(sk)->dccps_mss_cache); - - hc->tx_ssthresh = max(hc->tx_ssthresh, (cwnd >> 1) + (cwnd >> 2)); - - /* don't reduce cwnd below the initial window (IW) */ - restart_cwnd = min(cwnd, iwnd); - cwnd >>= (now - hc->tx_lsndtime) / hc->tx_rto; - hc->tx_cwnd = max(cwnd, restart_cwnd); - - hc->tx_cwnd_stamp = now; - hc->tx_cwnd_used = 0; -} - static void ccid2_hc_tx_packet_sent(struct sock *sk, unsigned int len) { struct dccp_sock *dp = dccp_sk(sk); struct ccid2_hc_tx_sock *hc = ccid2_hc_tx_sk(sk); - const u32 now = ccid2_time_stamp; struct ccid2_seq *next; - /* slow-start after idle periods (RFC 2581, RFC 2861) */ - if (ccid2_do_cwv && !hc->tx_pipe && - (s32)(now - hc->tx_lsndtime) >= hc->tx_rto) - ccid2_cwnd_restart(sk, now); - - hc->tx_lsndtime = now; - hc->tx_pipe += 1; - - /* see whether cwnd was fully used (RFC 2861), update expected window */ - if (ccid2_cwnd_network_limited(hc)) { - ccid2_update_used_window(hc, hc->tx_cwnd); - hc->tx_cwnd_used = 0; - hc->tx_cwnd_stamp = now; - } else { - if (hc->tx_pipe > hc->tx_cwnd_used) - hc->tx_cwnd_used = hc->tx_pipe; - - ccid2_update_used_window(hc, hc->tx_cwnd_used); - - if (ccid2_do_cwv && (s32)(now - hc->tx_cwnd_stamp) >= hc->tx_rto) - ccid2_cwnd_application_limited(sk, now); - } + hc->tx_pipe++; hc->tx_seqh->ccid2s_seq = dp->dccps_gss; hc->tx_seqh->ccid2s_acked = 0; - hc->tx_seqh->ccid2s_sent = now; + hc->tx_seqh->ccid2s_sent = ccid2_time_stamp; next = hc->tx_seqh->ccid2s_next; /* check if we need to alloc more space */ @@ -659,6 +583,15 @@ static void ccid2_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb) dccp_ackvec_parsed_cleanup(&hc->tx_av_chunks); } +/* + * Convert RFC 3390 larger initial window into an equivalent number of packets. + * This is based on the numbers specified in RFC 5681, 3.1. + */ +static inline u32 rfc3390_bytes_to_packets(const u32 smss) +{ + return smss <= 1095 ? 4 : (smss > 2190 ? 2 : 3); +} + static int ccid2_hc_tx_init(struct ccid *ccid, struct sock *sk) { struct ccid2_hc_tx_sock *hc = ccid_priv(ccid); @@ -670,7 +603,6 @@ static int ccid2_hc_tx_init(struct ccid *ccid, struct sock *sk) /* Use larger initial windows (RFC 4341, section 5). */ hc->tx_cwnd = rfc3390_bytes_to_packets(dp->dccps_mss_cache); - hc->tx_expected_wnd = hc->tx_cwnd; /* Make sure that Ack Ratio is enabled and within bounds. */ max_ratio = DIV_ROUND_UP(hc->tx_cwnd, 2); @@ -683,8 +615,7 @@ static int ccid2_hc_tx_init(struct ccid *ccid, struct sock *sk) hc->tx_rto = DCCP_TIMEOUT_INIT; hc->tx_rpdupack = -1; - hc->tx_last_cong = hc->tx_lsndtime = hc->tx_cwnd_stamp = ccid2_time_stamp; - hc->tx_cwnd_used = 0; + hc->tx_last_cong = ccid2_time_stamp; setup_timer(&hc->tx_rtotimer, ccid2_hc_tx_rto_expire, (unsigned long)sk); INIT_LIST_HEAD(&hc->tx_av_chunks); @@ -705,14 +636,18 @@ static void ccid2_hc_tx_exit(struct sock *sk) static void ccid2_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb) { + const struct dccp_sock *dp = dccp_sk(sk); struct ccid2_hc_rx_sock *hc = ccid2_hc_rx_sk(sk); - if (!dccp_data_packet(skb)) - return; - - if (++hc->rx_num_data_pkts >= dccp_sk(sk)->dccps_r_ack_ratio) { - dccp_send_ack(sk); - hc->rx_num_data_pkts = 0; + switch (DCCP_SKB_CB(skb)->dccpd_type) { + case DCCP_PKT_DATA: + case DCCP_PKT_DATAACK: + hc->rx_data++; + if (hc->rx_data >= dp->dccps_r_ack_ratio) { + dccp_send_ack(sk); + hc->rx_data = 0; + } + break; } } diff --git a/trunk/net/dccp/ccids/ccid2.h b/trunk/net/dccp/ccids/ccid2.h index f585d330e1e5..e9985dafc2c7 100644 --- a/trunk/net/dccp/ccids/ccid2.h +++ b/trunk/net/dccp/ccids/ccid2.h @@ -53,10 +53,6 @@ struct ccid2_seq { * @tx_rttvar: moving average/maximum of @mdev_max * @tx_rto: RTO value deriving from SRTT and RTTVAR (RFC 2988) * @tx_rtt_seq: to decay RTTVAR at most once per flight - * @tx_cwnd_used: actually used cwnd, W_used of RFC 2861 - * @tx_expected_wnd: moving average of @tx_cwnd_used - * @tx_cwnd_stamp: to track idle periods in CWV - * @tx_lsndtime: last time (in jiffies) a data packet was sent * @tx_rpseq: last consecutive seqno * @tx_rpdupack: dupacks since rpseq * @tx_av_chunks: list of Ack Vectors received on current skb @@ -80,12 +76,6 @@ struct ccid2_hc_tx_sock { u64 tx_rtt_seq:48; struct timer_list tx_rtotimer; - /* Congestion Window validation (optional, RFC 2861) */ - u32 tx_cwnd_used, - tx_expected_wnd, - tx_cwnd_stamp, - tx_lsndtime; - u64 tx_rpseq; int tx_rpdupack; u32 tx_last_cong; @@ -98,21 +88,8 @@ static inline bool ccid2_cwnd_network_limited(struct ccid2_hc_tx_sock *hc) return hc->tx_pipe >= hc->tx_cwnd; } -/* - * Convert RFC 3390 larger initial window into an equivalent number of packets. - * This is based on the numbers specified in RFC 5681, 3.1. - */ -static inline u32 rfc3390_bytes_to_packets(const u32 smss) -{ - return smss <= 1095 ? 4 : (smss > 2190 ? 2 : 3); -} - -/** - * struct ccid2_hc_rx_sock - Receiving end of CCID-2 half-connection - * @rx_num_data_pkts: number of data packets received since last feedback - */ struct ccid2_hc_rx_sock { - u32 rx_num_data_pkts; + int rx_data; }; static inline struct ccid2_hc_tx_sock *ccid2_hc_tx_sk(const struct sock *sk) diff --git a/trunk/net/dccp/input.c b/trunk/net/dccp/input.c index 51d5fe5fffba..4222e7a654b0 100644 --- a/trunk/net/dccp/input.c +++ b/trunk/net/dccp/input.c @@ -619,30 +619,19 @@ int dccp_rcv_state_process(struct sock *sk, struct sk_buff *skb, return 1; } - /* Step 6: Check sequence numbers (omitted in LISTEN/REQUEST state) */ - if (sk->sk_state != DCCP_REQUESTING && dccp_check_seqno(sk, skb)) - goto discard; + if (sk->sk_state != DCCP_REQUESTING && sk->sk_state != DCCP_RESPOND) { + if (dccp_check_seqno(sk, skb)) + goto discard; - /* - * Step 7: Check for unexpected packet types - * If (S.is_server and P.type == Response) - * or (S.is_client and P.type == Request) - * or (S.state == RESPOND and P.type == Data), - * Send Sync packet acknowledging P.seqno - * Drop packet and return - */ - if ((dp->dccps_role != DCCP_ROLE_CLIENT && - dh->dccph_type == DCCP_PKT_RESPONSE) || - (dp->dccps_role == DCCP_ROLE_CLIENT && - dh->dccph_type == DCCP_PKT_REQUEST) || - (sk->sk_state == DCCP_RESPOND && dh->dccph_type == DCCP_PKT_DATA)) { - dccp_send_sync(sk, dcb->dccpd_seq, DCCP_PKT_SYNC); - goto discard; - } + /* + * Step 8: Process options and mark acknowledgeable + */ + if (dccp_parse_options(sk, NULL, skb)) + return 1; - /* Step 8: Process options */ - if (dccp_parse_options(sk, NULL, skb)) - return 1; + dccp_handle_ackvec_processing(sk, skb); + dccp_deliver_input_to_ccids(sk, skb); + } /* * Step 9: Process Reset @@ -651,15 +640,31 @@ int dccp_rcv_state_process(struct sock *sk, struct sk_buff *skb, * S.state := TIMEWAIT * Set TIMEWAIT timer * Drop packet and return - */ + */ if (dh->dccph_type == DCCP_PKT_RESET) { dccp_rcv_reset(sk, skb); return 0; - } else if (dh->dccph_type == DCCP_PKT_CLOSEREQ) { /* Step 13 */ + /* + * Step 7: Check for unexpected packet types + * If (S.is_server and P.type == Response) + * or (S.is_client and P.type == Request) + * or (S.state == RESPOND and P.type == Data), + * Send Sync packet acknowledging P.seqno + * Drop packet and return + */ + } else if ((dp->dccps_role != DCCP_ROLE_CLIENT && + dh->dccph_type == DCCP_PKT_RESPONSE) || + (dp->dccps_role == DCCP_ROLE_CLIENT && + dh->dccph_type == DCCP_PKT_REQUEST) || + (sk->sk_state == DCCP_RESPOND && + dh->dccph_type == DCCP_PKT_DATA)) { + dccp_send_sync(sk, dcb->dccpd_seq, DCCP_PKT_SYNC); + goto discard; + } else if (dh->dccph_type == DCCP_PKT_CLOSEREQ) { if (dccp_rcv_closereq(sk, skb)) return 0; goto discard; - } else if (dh->dccph_type == DCCP_PKT_CLOSE) { /* Step 14 */ + } else if (dh->dccph_type == DCCP_PKT_CLOSE) { if (dccp_rcv_close(sk, skb)) return 0; goto discard; @@ -674,12 +679,8 @@ int dccp_rcv_state_process(struct sock *sk, struct sk_buff *skb, __kfree_skb(skb); return 0; - case DCCP_PARTOPEN: - /* Step 8: if using Ack Vectors, mark packet acknowledgeable */ - dccp_handle_ackvec_processing(sk, skb); - dccp_deliver_input_to_ccids(sk, skb); - /* fall through */ case DCCP_RESPOND: + case DCCP_PARTOPEN: queued = dccp_rcv_respond_partopen_state_process(sk, skb, dh, len); break; diff --git a/trunk/net/dccp/output.c b/trunk/net/dccp/output.c index dede3edb8849..fab108e51e5a 100644 --- a/trunk/net/dccp/output.c +++ b/trunk/net/dccp/output.c @@ -27,13 +27,11 @@ static inline void dccp_event_ack_sent(struct sock *sk) inet_csk_clear_xmit_timer(sk, ICSK_TIME_DACK); } -/* enqueue @skb on sk_send_head for retransmission, return clone to send now */ -static struct sk_buff *dccp_skb_entail(struct sock *sk, struct sk_buff *skb) +static void dccp_skb_entail(struct sock *sk, struct sk_buff *skb) { skb_set_owner_w(skb, sk); WARN_ON(sk->sk_send_head); sk->sk_send_head = skb; - return skb_clone(sk->sk_send_head, gfp_any()); } /* @@ -554,7 +552,8 @@ int dccp_connect(struct sock *sk) DCCP_SKB_CB(skb)->dccpd_type = DCCP_PKT_REQUEST; - dccp_transmit_skb(sk, dccp_skb_entail(sk, skb)); + dccp_skb_entail(sk, skb); + dccp_transmit_skb(sk, skb_clone(skb, GFP_KERNEL)); DCCP_INC_STATS(DCCP_MIB_ACTIVEOPENS); /* Timer for repeating the REQUEST until an answer. */ @@ -679,7 +678,8 @@ void dccp_send_close(struct sock *sk, const int active) DCCP_SKB_CB(skb)->dccpd_type = DCCP_PKT_CLOSE; if (active) { - skb = dccp_skb_entail(sk, skb); + dccp_skb_entail(sk, skb); + dccp_transmit_skb(sk, skb_clone(skb, prio)); /* * Retransmission timer for active-close: RFC 4340, 8.3 requires * to retransmit the Close/CloseReq until the CLOSING/CLOSEREQ @@ -692,6 +692,6 @@ void dccp_send_close(struct sock *sk, const int active) */ inet_csk_reset_xmit_timer(sk, ICSK_TIME_RETRANS, DCCP_TIMEOUT_INIT, DCCP_RTO_MAX); - } - dccp_transmit_skb(sk, skb); + } else + dccp_transmit_skb(sk, skb); } diff --git a/trunk/net/decnet/af_decnet.c b/trunk/net/decnet/af_decnet.c index 19acd00a6382..ea3b6ee21fc9 100644 --- a/trunk/net/decnet/af_decnet.c +++ b/trunk/net/decnet/af_decnet.c @@ -291,23 +291,23 @@ int dn_sockaddr2username(struct sockaddr_dn *sdn, unsigned char *buf, unsigned c *buf++ = type; - switch (type) { - case 0: - *buf++ = sdn->sdn_objnum; - break; - case 1: - *buf++ = 0; - *buf++ = le16_to_cpu(sdn->sdn_objnamel); - memcpy(buf, sdn->sdn_objname, le16_to_cpu(sdn->sdn_objnamel)); - len = 3 + le16_to_cpu(sdn->sdn_objnamel); - break; - case 2: - memset(buf, 0, 5); - buf += 5; - *buf++ = le16_to_cpu(sdn->sdn_objnamel); - memcpy(buf, sdn->sdn_objname, le16_to_cpu(sdn->sdn_objnamel)); - len = 7 + le16_to_cpu(sdn->sdn_objnamel); - break; + switch(type) { + case 0: + *buf++ = sdn->sdn_objnum; + break; + case 1: + *buf++ = 0; + *buf++ = le16_to_cpu(sdn->sdn_objnamel); + memcpy(buf, sdn->sdn_objname, le16_to_cpu(sdn->sdn_objnamel)); + len = 3 + le16_to_cpu(sdn->sdn_objnamel); + break; + case 2: + memset(buf, 0, 5); + buf += 5; + *buf++ = le16_to_cpu(sdn->sdn_objnamel); + memcpy(buf, sdn->sdn_objname, le16_to_cpu(sdn->sdn_objnamel)); + len = 7 + le16_to_cpu(sdn->sdn_objnamel); + break; } return len; @@ -337,23 +337,23 @@ int dn_username2sockaddr(unsigned char *data, int len, struct sockaddr_dn *sdn, *fmt = *data++; type = *data++; - switch (*fmt) { - case 0: - sdn->sdn_objnum = type; - return 2; - case 1: - namel = 16; - break; - case 2: - len -= 4; - data += 4; - break; - case 4: - len -= 8; - data += 8; - break; - default: - return -1; + switch(*fmt) { + case 0: + sdn->sdn_objnum = type; + return 2; + case 1: + namel = 16; + break; + case 2: + len -= 4; + data += 4; + break; + case 4: + len -= 8; + data += 8; + break; + default: + return -1; } len -= 1; @@ -575,26 +575,25 @@ int dn_destroy_timer(struct sock *sk) scp->persist = dn_nsp_persist(sk); - switch (scp->state) { - case DN_DI: - dn_nsp_send_disc(sk, NSP_DISCINIT, 0, GFP_ATOMIC); - if (scp->nsp_rxtshift >= decnet_di_count) - scp->state = DN_CN; - return 0; - - case DN_DR: - dn_nsp_send_disc(sk, NSP_DISCINIT, 0, GFP_ATOMIC); - if (scp->nsp_rxtshift >= decnet_dr_count) - scp->state = DN_DRC; - return 0; + switch(scp->state) { + case DN_DI: + dn_nsp_send_disc(sk, NSP_DISCINIT, 0, GFP_ATOMIC); + if (scp->nsp_rxtshift >= decnet_di_count) + scp->state = DN_CN; + return 0; - case DN_DN: - if (scp->nsp_rxtshift < decnet_dn_count) { - /* printk(KERN_DEBUG "dn_destroy_timer: DN\n"); */ - dn_nsp_send_disc(sk, NSP_DISCCONF, NSP_REASON_DC, - GFP_ATOMIC); + case DN_DR: + dn_nsp_send_disc(sk, NSP_DISCINIT, 0, GFP_ATOMIC); + if (scp->nsp_rxtshift >= decnet_dr_count) + scp->state = DN_DRC; return 0; - } + + case DN_DN: + if (scp->nsp_rxtshift < decnet_dn_count) { + /* printk(KERN_DEBUG "dn_destroy_timer: DN\n"); */ + dn_nsp_send_disc(sk, NSP_DISCCONF, NSP_REASON_DC, GFP_ATOMIC); + return 0; + } } scp->persist = (HZ * decnet_time_wait); @@ -624,42 +623,42 @@ static void dn_destroy_sock(struct sock *sk) sk->sk_state = TCP_CLOSE; - switch (scp->state) { - case DN_DN: - dn_nsp_send_disc(sk, NSP_DISCCONF, NSP_REASON_DC, - sk->sk_allocation); - scp->persist_fxn = dn_destroy_timer; - scp->persist = dn_nsp_persist(sk); - break; - case DN_CR: - scp->state = DN_DR; - goto disc_reject; - case DN_RUN: - scp->state = DN_DI; - case DN_DI: - case DN_DR: + switch(scp->state) { + case DN_DN: + dn_nsp_send_disc(sk, NSP_DISCCONF, NSP_REASON_DC, + sk->sk_allocation); + scp->persist_fxn = dn_destroy_timer; + scp->persist = dn_nsp_persist(sk); + break; + case DN_CR: + scp->state = DN_DR; + goto disc_reject; + case DN_RUN: + scp->state = DN_DI; + case DN_DI: + case DN_DR: disc_reject: - dn_nsp_send_disc(sk, NSP_DISCINIT, 0, sk->sk_allocation); - case DN_NC: - case DN_NR: - case DN_RJ: - case DN_DIC: - case DN_CN: - case DN_DRC: - case DN_CI: - case DN_CD: - scp->persist_fxn = dn_destroy_timer; - scp->persist = dn_nsp_persist(sk); - break; - default: - printk(KERN_DEBUG "DECnet: dn_destroy_sock passed socket in invalid state\n"); - case DN_O: - dn_stop_slow_timer(sk); + dn_nsp_send_disc(sk, NSP_DISCINIT, 0, sk->sk_allocation); + case DN_NC: + case DN_NR: + case DN_RJ: + case DN_DIC: + case DN_CN: + case DN_DRC: + case DN_CI: + case DN_CD: + scp->persist_fxn = dn_destroy_timer; + scp->persist = dn_nsp_persist(sk); + break; + default: + printk(KERN_DEBUG "DECnet: dn_destroy_sock passed socket in invalid state\n"); + case DN_O: + dn_stop_slow_timer(sk); - dn_unhash_sock_bh(sk); - sock_put(sk); + dn_unhash_sock_bh(sk); + sock_put(sk); - break; + break; } } @@ -684,15 +683,15 @@ static int dn_create(struct net *net, struct socket *sock, int protocol, if (!net_eq(net, &init_net)) return -EAFNOSUPPORT; - switch (sock->type) { - case SOCK_SEQPACKET: - if (protocol != DNPROTO_NSP) - return -EPROTONOSUPPORT; - break; - case SOCK_STREAM: - break; - default: - return -ESOCKTNOSUPPORT; + switch(sock->type) { + case SOCK_SEQPACKET: + if (protocol != DNPROTO_NSP) + return -EPROTONOSUPPORT; + break; + case SOCK_STREAM: + break; + default: + return -ESOCKTNOSUPPORT; } @@ -988,16 +987,16 @@ static inline int dn_check_state(struct sock *sk, struct sockaddr_dn *addr, int { struct dn_scp *scp = DN_SK(sk); - switch (scp->state) { - case DN_RUN: - return 0; - case DN_CR: - return dn_confirm_accept(sk, timeo, sk->sk_allocation); - case DN_CI: - case DN_CC: - return dn_wait_run(sk, timeo); - case DN_O: - return __dn_connect(sk, addr, addrlen, timeo, flags); + switch(scp->state) { + case DN_RUN: + return 0; + case DN_CR: + return dn_confirm_accept(sk, timeo, sk->sk_allocation); + case DN_CI: + case DN_CC: + return dn_wait_run(sk, timeo); + case DN_O: + return __dn_connect(sk, addr, addrlen, timeo, flags); } return -EINVAL; @@ -1364,140 +1363,141 @@ static int __dn_setsockopt(struct socket *sock, int level,int optname, char __us if (copy_from_user(&u, optval, optlen)) return -EFAULT; - switch (optname) { - case DSO_CONDATA: - if (sock->state == SS_CONNECTED) - return -EISCONN; - if ((scp->state != DN_O) && (scp->state != DN_CR)) - return -EINVAL; + switch(optname) { + case DSO_CONDATA: + if (sock->state == SS_CONNECTED) + return -EISCONN; + if ((scp->state != DN_O) && (scp->state != DN_CR)) + return -EINVAL; - if (optlen != sizeof(struct optdata_dn)) - return -EINVAL; + if (optlen != sizeof(struct optdata_dn)) + return -EINVAL; - if (le16_to_cpu(u.opt.opt_optl) > 16) - return -EINVAL; + if (le16_to_cpu(u.opt.opt_optl) > 16) + return -EINVAL; - memcpy(&scp->conndata_out, &u.opt, optlen); - break; + memcpy(&scp->conndata_out, &u.opt, optlen); + break; - case DSO_DISDATA: - if (sock->state != SS_CONNECTED && - scp->accept_mode == ACC_IMMED) - return -ENOTCONN; + case DSO_DISDATA: + if (sock->state != SS_CONNECTED && scp->accept_mode == ACC_IMMED) + return -ENOTCONN; - if (optlen != sizeof(struct optdata_dn)) - return -EINVAL; + if (optlen != sizeof(struct optdata_dn)) + return -EINVAL; - if (le16_to_cpu(u.opt.opt_optl) > 16) - return -EINVAL; + if (le16_to_cpu(u.opt.opt_optl) > 16) + return -EINVAL; - memcpy(&scp->discdata_out, &u.opt, optlen); - break; + memcpy(&scp->discdata_out, &u.opt, optlen); + break; - case DSO_CONACCESS: - if (sock->state == SS_CONNECTED) - return -EISCONN; - if (scp->state != DN_O) - return -EINVAL; + case DSO_CONACCESS: + if (sock->state == SS_CONNECTED) + return -EISCONN; + if (scp->state != DN_O) + return -EINVAL; - if (optlen != sizeof(struct accessdata_dn)) - return -EINVAL; + if (optlen != sizeof(struct accessdata_dn)) + return -EINVAL; - if ((u.acc.acc_accl > DN_MAXACCL) || - (u.acc.acc_passl > DN_MAXACCL) || - (u.acc.acc_userl > DN_MAXACCL)) - return -EINVAL; + if ((u.acc.acc_accl > DN_MAXACCL) || + (u.acc.acc_passl > DN_MAXACCL) || + (u.acc.acc_userl > DN_MAXACCL)) + return -EINVAL; - memcpy(&scp->accessdata, &u.acc, optlen); - break; + memcpy(&scp->accessdata, &u.acc, optlen); + break; - case DSO_ACCEPTMODE: - if (sock->state == SS_CONNECTED) - return -EISCONN; - if (scp->state != DN_O) - return -EINVAL; + case DSO_ACCEPTMODE: + if (sock->state == SS_CONNECTED) + return -EISCONN; + if (scp->state != DN_O) + return -EINVAL; - if (optlen != sizeof(int)) - return -EINVAL; + if (optlen != sizeof(int)) + return -EINVAL; - if ((u.mode != ACC_IMMED) && (u.mode != ACC_DEFER)) - return -EINVAL; + if ((u.mode != ACC_IMMED) && (u.mode != ACC_DEFER)) + return -EINVAL; - scp->accept_mode = (unsigned char)u.mode; - break; + scp->accept_mode = (unsigned char)u.mode; + break; - case DSO_CONACCEPT: - if (scp->state != DN_CR) - return -EINVAL; - timeo = sock_rcvtimeo(sk, 0); - err = dn_confirm_accept(sk, &timeo, sk->sk_allocation); - return err; + case DSO_CONACCEPT: - case DSO_CONREJECT: - if (scp->state != DN_CR) - return -EINVAL; + if (scp->state != DN_CR) + return -EINVAL; + timeo = sock_rcvtimeo(sk, 0); + err = dn_confirm_accept(sk, &timeo, sk->sk_allocation); + return err; - scp->state = DN_DR; - sk->sk_shutdown = SHUTDOWN_MASK; - dn_nsp_send_disc(sk, 0x38, 0, sk->sk_allocation); - break; + case DSO_CONREJECT: - default: + if (scp->state != DN_CR) + return -EINVAL; + + scp->state = DN_DR; + sk->sk_shutdown = SHUTDOWN_MASK; + dn_nsp_send_disc(sk, 0x38, 0, sk->sk_allocation); + break; + + default: #ifdef CONFIG_NETFILTER return nf_setsockopt(sk, PF_DECnet, optname, optval, optlen); #endif - case DSO_LINKINFO: - case DSO_STREAM: - case DSO_SEQPACKET: - return -ENOPROTOOPT; - - case DSO_MAXWINDOW: - if (optlen != sizeof(unsigned long)) - return -EINVAL; - if (u.win > NSP_MAX_WINDOW) - u.win = NSP_MAX_WINDOW; - if (u.win == 0) - return -EINVAL; - scp->max_window = u.win; - if (scp->snd_window > u.win) - scp->snd_window = u.win; - break; + case DSO_LINKINFO: + case DSO_STREAM: + case DSO_SEQPACKET: + return -ENOPROTOOPT; + + case DSO_MAXWINDOW: + if (optlen != sizeof(unsigned long)) + return -EINVAL; + if (u.win > NSP_MAX_WINDOW) + u.win = NSP_MAX_WINDOW; + if (u.win == 0) + return -EINVAL; + scp->max_window = u.win; + if (scp->snd_window > u.win) + scp->snd_window = u.win; + break; - case DSO_NODELAY: - if (optlen != sizeof(int)) - return -EINVAL; - if (scp->nonagle == 2) - return -EINVAL; - scp->nonagle = (u.val == 0) ? 0 : 1; - /* if (scp->nonagle == 1) { Push pending frames } */ - break; + case DSO_NODELAY: + if (optlen != sizeof(int)) + return -EINVAL; + if (scp->nonagle == 2) + return -EINVAL; + scp->nonagle = (u.val == 0) ? 0 : 1; + /* if (scp->nonagle == 1) { Push pending frames } */ + break; - case DSO_CORK: - if (optlen != sizeof(int)) - return -EINVAL; - if (scp->nonagle == 1) - return -EINVAL; - scp->nonagle = (u.val == 0) ? 0 : 2; - /* if (scp->nonagle == 0) { Push pending frames } */ - break; + case DSO_CORK: + if (optlen != sizeof(int)) + return -EINVAL; + if (scp->nonagle == 1) + return -EINVAL; + scp->nonagle = (u.val == 0) ? 0 : 2; + /* if (scp->nonagle == 0) { Push pending frames } */ + break; - case DSO_SERVICES: - if (optlen != sizeof(unsigned char)) - return -EINVAL; - if ((u.services & ~NSP_FC_MASK) != 0x01) - return -EINVAL; - if ((u.services & NSP_FC_MASK) == NSP_FC_MASK) - return -EINVAL; - scp->services_loc = u.services; - break; + case DSO_SERVICES: + if (optlen != sizeof(unsigned char)) + return -EINVAL; + if ((u.services & ~NSP_FC_MASK) != 0x01) + return -EINVAL; + if ((u.services & NSP_FC_MASK) == NSP_FC_MASK) + return -EINVAL; + scp->services_loc = u.services; + break; - case DSO_INFO: - if (optlen != sizeof(unsigned char)) - return -EINVAL; - if (u.info & 0xfc) - return -EINVAL; - scp->info_loc = u.info; - break; + case DSO_INFO: + if (optlen != sizeof(unsigned char)) + return -EINVAL; + if (u.info & 0xfc) + return -EINVAL; + scp->info_loc = u.info; + break; } return 0; @@ -1527,106 +1527,107 @@ static int __dn_getsockopt(struct socket *sock, int level,int optname, char __us if(get_user(r_len , optlen)) return -EFAULT; - switch (optname) { - case DSO_CONDATA: - if (r_len > sizeof(struct optdata_dn)) - r_len = sizeof(struct optdata_dn); - r_data = &scp->conndata_in; - break; + switch(optname) { + case DSO_CONDATA: + if (r_len > sizeof(struct optdata_dn)) + r_len = sizeof(struct optdata_dn); + r_data = &scp->conndata_in; + break; - case DSO_DISDATA: - if (r_len > sizeof(struct optdata_dn)) - r_len = sizeof(struct optdata_dn); - r_data = &scp->discdata_in; - break; + case DSO_DISDATA: + if (r_len > sizeof(struct optdata_dn)) + r_len = sizeof(struct optdata_dn); + r_data = &scp->discdata_in; + break; - case DSO_CONACCESS: - if (r_len > sizeof(struct accessdata_dn)) - r_len = sizeof(struct accessdata_dn); - r_data = &scp->accessdata; - break; + case DSO_CONACCESS: + if (r_len > sizeof(struct accessdata_dn)) + r_len = sizeof(struct accessdata_dn); + r_data = &scp->accessdata; + break; - case DSO_ACCEPTMODE: - if (r_len > sizeof(unsigned char)) - r_len = sizeof(unsigned char); - r_data = &scp->accept_mode; - break; + case DSO_ACCEPTMODE: + if (r_len > sizeof(unsigned char)) + r_len = sizeof(unsigned char); + r_data = &scp->accept_mode; + break; - case DSO_LINKINFO: - if (r_len > sizeof(struct linkinfo_dn)) - r_len = sizeof(struct linkinfo_dn); + case DSO_LINKINFO: + if (r_len > sizeof(struct linkinfo_dn)) + r_len = sizeof(struct linkinfo_dn); - memset(&link, 0, sizeof(link)); + memset(&link, 0, sizeof(link)); - switch (sock->state) { - case SS_CONNECTING: - link.idn_linkstate = LL_CONNECTING; - break; - case SS_DISCONNECTING: - link.idn_linkstate = LL_DISCONNECTING; - break; - case SS_CONNECTED: - link.idn_linkstate = LL_RUNNING; - break; - default: - link.idn_linkstate = LL_INACTIVE; - } + switch(sock->state) { + case SS_CONNECTING: + link.idn_linkstate = LL_CONNECTING; + break; + case SS_DISCONNECTING: + link.idn_linkstate = LL_DISCONNECTING; + break; + case SS_CONNECTED: + link.idn_linkstate = LL_RUNNING; + break; + default: + link.idn_linkstate = LL_INACTIVE; + } - link.idn_segsize = scp->segsize_rem; - r_data = &link; - break; + link.idn_segsize = scp->segsize_rem; + r_data = &link; + break; - default: + default: #ifdef CONFIG_NETFILTER - { - int ret, len; + { + int ret, len; - if (get_user(len, optlen)) - return -EFAULT; + if(get_user(len, optlen)) + return -EFAULT; - ret = nf_getsockopt(sk, PF_DECnet, optname, optval, &len); - if (ret >= 0) - ret = put_user(len, optlen); - return ret; - } + ret = nf_getsockopt(sk, PF_DECnet, optname, + optval, &len); + if (ret >= 0) + ret = put_user(len, optlen); + return ret; + } #endif - case DSO_STREAM: - case DSO_SEQPACKET: - case DSO_CONACCEPT: - case DSO_CONREJECT: - return -ENOPROTOOPT; - - case DSO_MAXWINDOW: - if (r_len > sizeof(unsigned long)) - r_len = sizeof(unsigned long); - r_data = &scp->max_window; - break; + case DSO_STREAM: + case DSO_SEQPACKET: + case DSO_CONACCEPT: + case DSO_CONREJECT: + return -ENOPROTOOPT; + + case DSO_MAXWINDOW: + if (r_len > sizeof(unsigned long)) + r_len = sizeof(unsigned long); + r_data = &scp->max_window; + break; - case DSO_NODELAY: - if (r_len > sizeof(int)) - r_len = sizeof(int); - val = (scp->nonagle == 1); - r_data = &val; - break; + case DSO_NODELAY: + if (r_len > sizeof(int)) + r_len = sizeof(int); + val = (scp->nonagle == 1); + r_data = &val; + break; - case DSO_CORK: - if (r_len > sizeof(int)) - r_len = sizeof(int); - val = (scp->nonagle == 2); - r_data = &val; - break; + case DSO_CORK: + if (r_len > sizeof(int)) + r_len = sizeof(int); + val = (scp->nonagle == 2); + r_data = &val; + break; - case DSO_SERVICES: - if (r_len > sizeof(unsigned char)) - r_len = sizeof(unsigned char); - r_data = &scp->services_rem; - break; + case DSO_SERVICES: + if (r_len > sizeof(unsigned char)) + r_len = sizeof(unsigned char); + r_data = &scp->services_rem; + break; - case DSO_INFO: - if (r_len > sizeof(unsigned char)) - r_len = sizeof(unsigned char); - r_data = &scp->info_rem; - break; + case DSO_INFO: + if (r_len > sizeof(unsigned char)) + r_len = sizeof(unsigned char); + r_data = &scp->info_rem; + break; } if (r_data) { @@ -2087,15 +2088,15 @@ static int dn_device_event(struct notifier_block *this, unsigned long event, if (!net_eq(dev_net(dev), &init_net)) return NOTIFY_DONE; - switch (event) { - case NETDEV_UP: - dn_dev_up(dev); - break; - case NETDEV_DOWN: - dn_dev_down(dev); - break; - default: - break; + switch(event) { + case NETDEV_UP: + dn_dev_up(dev); + break; + case NETDEV_DOWN: + dn_dev_down(dev); + break; + default: + break; } return NOTIFY_DONE; @@ -2208,54 +2209,54 @@ static void dn_printable_object(struct sockaddr_dn *dn, unsigned char *buf) int i; switch (le16_to_cpu(dn->sdn_objnamel)) { - case 0: - sprintf(buf, "%d", dn->sdn_objnum); - break; - default: - for (i = 0; i < le16_to_cpu(dn->sdn_objnamel); i++) { - buf[i] = dn->sdn_objname[i]; - if (IS_NOT_PRINTABLE(buf[i])) - buf[i] = '.'; - } - buf[i] = 0; + case 0: + sprintf(buf, "%d", dn->sdn_objnum); + break; + default: + for (i = 0; i < le16_to_cpu(dn->sdn_objnamel); i++) { + buf[i] = dn->sdn_objname[i]; + if (IS_NOT_PRINTABLE(buf[i])) + buf[i] = '.'; + } + buf[i] = 0; } } static char *dn_state2asc(unsigned char state) { - switch (state) { - case DN_O: - return "OPEN"; - case DN_CR: - return " CR"; - case DN_DR: - return " DR"; - case DN_DRC: - return " DRC"; - case DN_CC: - return " CC"; - case DN_CI: - return " CI"; - case DN_NR: - return " NR"; - case DN_NC: - return " NC"; - case DN_CD: - return " CD"; - case DN_RJ: - return " RJ"; - case DN_RUN: - return " RUN"; - case DN_DI: - return " DI"; - case DN_DIC: - return " DIC"; - case DN_DN: - return " DN"; - case DN_CL: - return " CL"; - case DN_CN: - return " CN"; + switch(state) { + case DN_O: + return "OPEN"; + case DN_CR: + return " CR"; + case DN_DR: + return " DR"; + case DN_DRC: + return " DRC"; + case DN_CC: + return " CC"; + case DN_CI: + return " CI"; + case DN_NR: + return " NR"; + case DN_NC: + return " NC"; + case DN_CD: + return " CD"; + case DN_RJ: + return " RJ"; + case DN_RUN: + return " RUN"; + case DN_DI: + return " DI"; + case DN_DIC: + return " DIC"; + case DN_DN: + return " DN"; + case DN_CL: + return " CL"; + case DN_CN: + return " CN"; } return "????"; diff --git a/trunk/net/decnet/dn_dev.c b/trunk/net/decnet/dn_dev.c index ba4faceec405..48530b454395 100644 --- a/trunk/net/decnet/dn_dev.c +++ b/trunk/net/decnet/dn_dev.c @@ -437,17 +437,17 @@ int dn_dev_ioctl(unsigned int cmd, void __user *arg) dev_load(&init_net, ifr->ifr_name); - switch (cmd) { - case SIOCGIFADDR: - break; - case SIOCSIFADDR: - if (!capable(CAP_NET_ADMIN)) - return -EACCES; - if (sdn->sdn_family != AF_DECnet) + switch(cmd) { + case SIOCGIFADDR: + break; + case SIOCSIFADDR: + if (!capable(CAP_NET_ADMIN)) + return -EACCES; + if (sdn->sdn_family != AF_DECnet) + return -EINVAL; + break; + default: return -EINVAL; - break; - default: - return -EINVAL; } rtnl_lock(); @@ -470,27 +470,27 @@ int dn_dev_ioctl(unsigned int cmd, void __user *arg) goto done; } - switch (cmd) { - case SIOCGIFADDR: - *((__le16 *)sdn->sdn_nodeaddr) = ifa->ifa_local; - goto rarok; - - case SIOCSIFADDR: - if (!ifa) { - if ((ifa = dn_dev_alloc_ifa()) == NULL) { - ret = -ENOBUFS; - break; + switch(cmd) { + case SIOCGIFADDR: + *((__le16 *)sdn->sdn_nodeaddr) = ifa->ifa_local; + goto rarok; + + case SIOCSIFADDR: + if (!ifa) { + if ((ifa = dn_dev_alloc_ifa()) == NULL) { + ret = -ENOBUFS; + break; + } + memcpy(ifa->ifa_label, dev->name, IFNAMSIZ); + } else { + if (ifa->ifa_local == dn_saddr2dn(sdn)) + break; + dn_dev_del_ifa(dn_db, ifap, 0); } - memcpy(ifa->ifa_label, dev->name, IFNAMSIZ); - } else { - if (ifa->ifa_local == dn_saddr2dn(sdn)) - break; - dn_dev_del_ifa(dn_db, ifap, 0); - } - ifa->ifa_local = ifa->ifa_address = dn_saddr2dn(sdn); + ifa->ifa_local = ifa->ifa_address = dn_saddr2dn(sdn); - ret = dn_dev_set_ifa(dev, ifa); + ret = dn_dev_set_ifa(dev, ifa); } done: rtnl_unlock(); @@ -1335,13 +1335,13 @@ static void dn_dev_seq_stop(struct seq_file *seq, void *v) static char *dn_type2asc(char type) { - switch (type) { - case DN_DEV_BCAST: - return "B"; - case DN_DEV_UCAST: - return "U"; - case DN_DEV_MPOINT: - return "M"; + switch(type) { + case DN_DEV_BCAST: + return "B"; + case DN_DEV_UCAST: + return "U"; + case DN_DEV_MPOINT: + return "M"; } return "?"; diff --git a/trunk/net/decnet/dn_fib.c b/trunk/net/decnet/dn_fib.c index 2bd8e53d7774..104324d6d535 100644 --- a/trunk/net/decnet/dn_fib.c +++ b/trunk/net/decnet/dn_fib.c @@ -414,34 +414,33 @@ int dn_fib_semantic_match(int type, struct dn_fib_info *fi, const struct flowidn res->fi = fi; - switch (type) { - case RTN_NAT: - DN_FIB_RES_RESET(*res); - atomic_inc(&fi->fib_clntref); - return 0; - case RTN_UNICAST: - case RTN_LOCAL: - for_nexthops(fi) { - if (nh->nh_flags & RTNH_F_DEAD) - continue; - if (!fld->flowidn_oif || - fld->flowidn_oif == nh->nh_oif) - break; - } - if (nhsel < fi->fib_nhs) { - res->nh_sel = nhsel; + switch(type) { + case RTN_NAT: + DN_FIB_RES_RESET(*res); atomic_inc(&fi->fib_clntref); return 0; - } - endfor_nexthops(fi); - res->fi = NULL; - return 1; - default: - if (net_ratelimit()) - printk("DECnet: impossible routing event : dn_fib_semantic_match type=%d\n", - type); - res->fi = NULL; - return -EINVAL; + case RTN_UNICAST: + case RTN_LOCAL: + for_nexthops(fi) { + if (nh->nh_flags & RTNH_F_DEAD) + continue; + if (!fld->flowidn_oif || + fld->flowidn_oif == nh->nh_oif) + break; + } + if (nhsel < fi->fib_nhs) { + res->nh_sel = nhsel; + atomic_inc(&fi->fib_clntref); + return 0; + } + endfor_nexthops(fi); + res->fi = NULL; + return 1; + default: + if (net_ratelimit()) + printk("DECnet: impossible routing event : dn_fib_semantic_match type=%d\n", type); + res->fi = NULL; + return -EINVAL; } } return err; @@ -648,20 +647,20 @@ static int dn_fib_dnaddr_event(struct notifier_block *this, unsigned long event, { struct dn_ifaddr *ifa = (struct dn_ifaddr *)ptr; - switch (event) { - case NETDEV_UP: - dn_fib_add_ifaddr(ifa); - dn_fib_sync_up(ifa->ifa_dev->dev); - dn_rt_cache_flush(-1); - break; - case NETDEV_DOWN: - dn_fib_del_ifaddr(ifa); - if (ifa->ifa_dev && ifa->ifa_dev->ifa_list == NULL) { - dn_fib_disable_addr(ifa->ifa_dev->dev, 1); - } else { + switch(event) { + case NETDEV_UP: + dn_fib_add_ifaddr(ifa); + dn_fib_sync_up(ifa->ifa_dev->dev); dn_rt_cache_flush(-1); - } - break; + break; + case NETDEV_DOWN: + dn_fib_del_ifaddr(ifa); + if (ifa->ifa_dev && ifa->ifa_dev->ifa_list == NULL) { + dn_fib_disable_addr(ifa->ifa_dev->dev, 1); + } else { + dn_rt_cache_flush(-1); + } + break; } return NOTIFY_DONE; } diff --git a/trunk/net/decnet/dn_neigh.c b/trunk/net/decnet/dn_neigh.c index 03eb22611801..602dade7e9a3 100644 --- a/trunk/net/decnet/dn_neigh.c +++ b/trunk/net/decnet/dn_neigh.c @@ -404,13 +404,13 @@ int dn_neigh_router_hello(struct sk_buff *skb) dn->flags &= ~DN_NDFLAG_P3; - switch (msg->iinfo & DN_RT_INFO_TYPE) { - case DN_RT_INFO_L1RT: - dn->flags &=~DN_NDFLAG_R2; - dn->flags |= DN_NDFLAG_R1; - break; - case DN_RT_INFO_L2RT: - dn->flags |= DN_NDFLAG_R2; + switch(msg->iinfo & DN_RT_INFO_TYPE) { + case DN_RT_INFO_L1RT: + dn->flags &=~DN_NDFLAG_R2; + dn->flags |= DN_NDFLAG_R1; + break; + case DN_RT_INFO_L2RT: + dn->flags |= DN_NDFLAG_R2; } } diff --git a/trunk/net/decnet/dn_nsp_in.c b/trunk/net/decnet/dn_nsp_in.c index 73fa268fe2e8..b430549e2b91 100644 --- a/trunk/net/decnet/dn_nsp_in.c +++ b/trunk/net/decnet/dn_nsp_in.c @@ -101,27 +101,23 @@ static void dn_ack(struct sock *sk, struct sk_buff *skb, unsigned short ack) unsigned short type = ((ack >> 12) & 0x0003); int wakeup = 0; - switch (type) { - case 0: /* ACK - Data */ - if (dn_after(ack, scp->ackrcv_dat)) { - scp->ackrcv_dat = ack & 0x0fff; - wakeup |= dn_nsp_check_xmit_queue(sk, skb, - &scp->data_xmit_queue, - ack); - } - break; - case 1: /* NAK - Data */ - break; - case 2: /* ACK - OtherData */ - if (dn_after(ack, scp->ackrcv_oth)) { - scp->ackrcv_oth = ack & 0x0fff; - wakeup |= dn_nsp_check_xmit_queue(sk, skb, - &scp->other_xmit_queue, - ack); - } - break; - case 3: /* NAK - OtherData */ - break; + switch(type) { + case 0: /* ACK - Data */ + if (dn_after(ack, scp->ackrcv_dat)) { + scp->ackrcv_dat = ack & 0x0fff; + wakeup |= dn_nsp_check_xmit_queue(sk, skb, &scp->data_xmit_queue, ack); + } + break; + case 1: /* NAK - Data */ + break; + case 2: /* ACK - OtherData */ + if (dn_after(ack, scp->ackrcv_oth)) { + scp->ackrcv_oth = ack & 0x0fff; + wakeup |= dn_nsp_check_xmit_queue(sk, skb, &scp->other_xmit_queue, ack); + } + break; + case 3: /* NAK - OtherData */ + break; } if (wakeup && !sock_flag(sk, SOCK_DEAD)) @@ -421,19 +417,19 @@ static void dn_nsp_disc_init(struct sock *sk, struct sk_buff *skb) scp->addrrem = cb->src_port; sk->sk_state = TCP_CLOSE; - switch (scp->state) { - case DN_CI: - case DN_CD: - scp->state = DN_RJ; - sk->sk_err = ECONNREFUSED; - break; - case DN_RUN: - sk->sk_shutdown |= SHUTDOWN_MASK; - scp->state = DN_DN; - break; - case DN_DI: - scp->state = DN_DIC; - break; + switch(scp->state) { + case DN_CI: + case DN_CD: + scp->state = DN_RJ; + sk->sk_err = ECONNREFUSED; + break; + case DN_RUN: + sk->sk_shutdown |= SHUTDOWN_MASK; + scp->state = DN_DN; + break; + case DN_DI: + scp->state = DN_DIC; + break; } if (!sock_flag(sk, SOCK_DEAD)) { @@ -474,23 +470,23 @@ static void dn_nsp_disc_conf(struct sock *sk, struct sk_buff *skb) sk->sk_state = TCP_CLOSE; - switch (scp->state) { - case DN_CI: - scp->state = DN_NR; - break; - case DN_DR: - if (reason == NSP_REASON_DC) - scp->state = DN_DRC; - if (reason == NSP_REASON_NL) + switch(scp->state) { + case DN_CI: + scp->state = DN_NR; + break; + case DN_DR: + if (reason == NSP_REASON_DC) + scp->state = DN_DRC; + if (reason == NSP_REASON_NL) + scp->state = DN_CN; + break; + case DN_DI: + scp->state = DN_DIC; + break; + case DN_RUN: + sk->sk_shutdown |= SHUTDOWN_MASK; + case DN_CC: scp->state = DN_CN; - break; - case DN_DI: - scp->state = DN_DIC; - break; - case DN_RUN: - sk->sk_shutdown |= SHUTDOWN_MASK; - case DN_CC: - scp->state = DN_CN; } if (!sock_flag(sk, SOCK_DEAD)) { @@ -696,16 +692,16 @@ static int dn_nsp_no_socket(struct sk_buff *skb, unsigned short reason) goto out; if ((reason != NSP_REASON_OK) && ((cb->nsp_flags & 0x0c) == 0x08)) { - switch (cb->nsp_flags & 0x70) { - case 0x10: - case 0x60: /* (Retransmitted) Connect Init */ - dn_nsp_return_disc(skb, NSP_DISCINIT, reason); - ret = NET_RX_SUCCESS; - break; - case 0x20: /* Connect Confirm */ - dn_nsp_return_disc(skb, NSP_DISCCONF, reason); - ret = NET_RX_SUCCESS; - break; + switch(cb->nsp_flags & 0x70) { + case 0x10: + case 0x60: /* (Retransmitted) Connect Init */ + dn_nsp_return_disc(skb, NSP_DISCINIT, reason); + ret = NET_RX_SUCCESS; + break; + case 0x20: /* Connect Confirm */ + dn_nsp_return_disc(skb, NSP_DISCCONF, reason); + ret = NET_RX_SUCCESS; + break; } } @@ -737,17 +733,17 @@ static int dn_nsp_rx_packet(struct sk_buff *skb) * Filter out conninits and useless packet types */ if ((cb->nsp_flags & 0x0c) == 0x08) { - switch (cb->nsp_flags & 0x70) { - case 0x00: /* NOP */ - case 0x70: /* Reserved */ - case 0x50: /* Reserved, Phase II node init */ - goto free_out; - case 0x10: - case 0x60: - if (unlikely(cb->rt_flags & DN_RT_F_RTS)) + switch(cb->nsp_flags & 0x70) { + case 0x00: /* NOP */ + case 0x70: /* Reserved */ + case 0x50: /* Reserved, Phase II node init */ goto free_out; - sk = dn_find_listener(skb, &reason); - goto got_it; + case 0x10: + case 0x60: + if (unlikely(cb->rt_flags & DN_RT_F_RTS)) + goto free_out; + sk = dn_find_listener(skb, &reason); + goto got_it; } } @@ -840,20 +836,20 @@ int dn_nsp_backlog_rcv(struct sock *sk, struct sk_buff *skb) * Control packet. */ if ((cb->nsp_flags & 0x0c) == 0x08) { - switch (cb->nsp_flags & 0x70) { - case 0x10: - case 0x60: - dn_nsp_conn_init(sk, skb); - break; - case 0x20: - dn_nsp_conn_conf(sk, skb); - break; - case 0x30: - dn_nsp_disc_init(sk, skb); - break; - case 0x40: - dn_nsp_disc_conf(sk, skb); - break; + switch(cb->nsp_flags & 0x70) { + case 0x10: + case 0x60: + dn_nsp_conn_init(sk, skb); + break; + case 0x20: + dn_nsp_conn_conf(sk, skb); + break; + case 0x30: + dn_nsp_disc_init(sk, skb); + break; + case 0x40: + dn_nsp_disc_conf(sk, skb); + break; } } else if (cb->nsp_flags == 0x24) { @@ -894,15 +890,15 @@ int dn_nsp_backlog_rcv(struct sock *sk, struct sk_buff *skb) if (scp->state != DN_RUN) goto free_out; - switch (cb->nsp_flags) { - case 0x10: /* LS */ - dn_nsp_linkservice(sk, skb); - break; - case 0x30: /* OD */ - dn_nsp_otherdata(sk, skb); - break; - default: - dn_nsp_data(sk, skb); + switch(cb->nsp_flags) { + case 0x10: /* LS */ + dn_nsp_linkservice(sk, skb); + break; + case 0x30: /* OD */ + dn_nsp_otherdata(sk, skb); + break; + default: + dn_nsp_data(sk, skb); } } else { /* Ack, chuck it out here */ diff --git a/trunk/net/decnet/dn_route.c b/trunk/net/decnet/dn_route.c index fceb86ca0116..2949ca474ede 100644 --- a/trunk/net/decnet/dn_route.c +++ b/trunk/net/decnet/dn_route.c @@ -495,11 +495,11 @@ static int dn_route_rx_packet(struct sk_buff *skb) } if ((skb->pkt_type == PACKET_HOST) && (cb->rt_flags & DN_RT_F_RQR)) { - switch (cb->rt_flags & DN_RT_PKT_MSK) { - case DN_RT_PKT_SHORT: - return dn_return_short(skb); - case DN_RT_PKT_LONG: - return dn_return_long(skb); + switch(cb->rt_flags & DN_RT_PKT_MSK) { + case DN_RT_PKT_SHORT: + return dn_return_short(skb); + case DN_RT_PKT_LONG: + return dn_return_long(skb); } } @@ -652,38 +652,38 @@ int dn_route_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type if (unlikely(skb_linearize(skb))) goto dump_it; - switch (flags & DN_RT_CNTL_MSK) { - case DN_RT_PKT_INIT: - dn_dev_init_pkt(skb); - break; - case DN_RT_PKT_VERI: - dn_dev_veri_pkt(skb); - break; + switch(flags & DN_RT_CNTL_MSK) { + case DN_RT_PKT_INIT: + dn_dev_init_pkt(skb); + break; + case DN_RT_PKT_VERI: + dn_dev_veri_pkt(skb); + break; } if (dn->parms.state != DN_DEV_S_RU) goto dump_it; - switch (flags & DN_RT_CNTL_MSK) { - case DN_RT_PKT_HELO: - return NF_HOOK(NFPROTO_DECNET, NF_DN_HELLO, - skb, skb->dev, NULL, - dn_route_ptp_hello); - - case DN_RT_PKT_L1RT: - case DN_RT_PKT_L2RT: - return NF_HOOK(NFPROTO_DECNET, NF_DN_ROUTE, - skb, skb->dev, NULL, - dn_route_discard); - case DN_RT_PKT_ERTH: - return NF_HOOK(NFPROTO_DECNET, NF_DN_HELLO, - skb, skb->dev, NULL, - dn_neigh_router_hello); - - case DN_RT_PKT_EEDH: - return NF_HOOK(NFPROTO_DECNET, NF_DN_HELLO, - skb, skb->dev, NULL, - dn_neigh_endnode_hello); + switch(flags & DN_RT_CNTL_MSK) { + case DN_RT_PKT_HELO: + return NF_HOOK(NFPROTO_DECNET, NF_DN_HELLO, + skb, skb->dev, NULL, + dn_route_ptp_hello); + + case DN_RT_PKT_L1RT: + case DN_RT_PKT_L2RT: + return NF_HOOK(NFPROTO_DECNET, NF_DN_ROUTE, + skb, skb->dev, NULL, + dn_route_discard); + case DN_RT_PKT_ERTH: + return NF_HOOK(NFPROTO_DECNET, NF_DN_HELLO, + skb, skb->dev, NULL, + dn_neigh_router_hello); + + case DN_RT_PKT_EEDH: + return NF_HOOK(NFPROTO_DECNET, NF_DN_HELLO, + skb, skb->dev, NULL, + dn_neigh_endnode_hello); } } else { if (dn->parms.state != DN_DEV_S_RU) @@ -691,11 +691,11 @@ int dn_route_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type skb_pull(skb, 1); /* Pull flags */ - switch (flags & DN_RT_PKT_MSK) { - case DN_RT_PKT_LONG: - return dn_route_rx_long(skb); - case DN_RT_PKT_SHORT: - return dn_route_rx_short(skb); + switch(flags & DN_RT_PKT_MSK) { + case DN_RT_PKT_LONG: + return dn_route_rx_long(skb); + case DN_RT_PKT_SHORT: + return dn_route_rx_short(skb); } } @@ -1419,20 +1419,20 @@ static int dn_route_input_slow(struct sk_buff *skb) rt->dst.neighbour = neigh; rt->dst.lastuse = jiffies; rt->dst.output = dn_rt_bug; - switch (res.type) { - case RTN_UNICAST: - rt->dst.input = dn_forward; - break; - case RTN_LOCAL: - rt->dst.output = dn_output; - rt->dst.input = dn_nsp_rx; - rt->dst.dev = in_dev; - flags |= RTCF_LOCAL; - break; - default: - case RTN_UNREACHABLE: - case RTN_BLACKHOLE: - rt->dst.input = dst_discard; + switch(res.type) { + case RTN_UNICAST: + rt->dst.input = dn_forward; + break; + case RTN_LOCAL: + rt->dst.output = dn_output; + rt->dst.input = dn_nsp_rx; + rt->dst.dev = in_dev; + flags |= RTCF_LOCAL; + break; + default: + case RTN_UNREACHABLE: + case RTN_BLACKHOLE: + rt->dst.input = dst_discard; } rt->rt_flags = flags; diff --git a/trunk/net/decnet/dn_table.c b/trunk/net/decnet/dn_table.c index cd0354e9bdb3..bd0a52dd1d40 100644 --- a/trunk/net/decnet/dn_table.c +++ b/trunk/net/decnet/dn_table.c @@ -147,18 +147,17 @@ static void dn_rehash_zone(struct dn_zone *dz) old_divisor = dz->dz_divisor; - switch (old_divisor) { - case 16: - new_divisor = 256; - new_hashmask = 0xFF; - break; - default: - printk(KERN_DEBUG "DECnet: dn_rehash_zone: BUG! %d\n", - old_divisor); - case 256: - new_divisor = 1024; - new_hashmask = 0x3FF; - break; + switch(old_divisor) { + case 16: + new_divisor = 256; + new_hashmask = 0xFF; + break; + default: + printk(KERN_DEBUG "DECnet: dn_rehash_zone: BUG! %d\n", old_divisor); + case 256: + new_divisor = 1024; + new_hashmask = 0x3FF; + break; } ht = kcalloc(new_divisor, sizeof(struct dn_fib_node*), GFP_KERNEL); diff --git a/trunk/net/decnet/netfilter/dn_rtmsg.c b/trunk/net/decnet/netfilter/dn_rtmsg.c index 69975e0bcdea..64a7f39e069f 100644 --- a/trunk/net/decnet/netfilter/dn_rtmsg.c +++ b/trunk/net/decnet/netfilter/dn_rtmsg.c @@ -69,15 +69,15 @@ static void dnrmg_send_peer(struct sk_buff *skb) int group = 0; unsigned char flags = *skb->data; - switch (flags & DN_RT_CNTL_MSK) { - case DN_RT_PKT_L1RT: - group = DNRNG_NLGRP_L1; - break; - case DN_RT_PKT_L2RT: - group = DNRNG_NLGRP_L2; - break; - default: - return; + switch(flags & DN_RT_CNTL_MSK) { + case DN_RT_PKT_L1RT: + group = DNRNG_NLGRP_L1; + break; + case DN_RT_PKT_L2RT: + group = DNRNG_NLGRP_L2; + break; + default: + return; } skb2 = dnrmg_build_message(skb, &status); diff --git a/trunk/net/decnet/sysctl_net_decnet.c b/trunk/net/decnet/sysctl_net_decnet.c index 02e75d11cfbb..28f8b5e5f73b 100644 --- a/trunk/net/decnet/sysctl_net_decnet.c +++ b/trunk/net/decnet/sysctl_net_decnet.c @@ -68,15 +68,14 @@ static struct ctl_table_header *dn_table_header = NULL; static void strip_it(char *str) { for(;;) { - switch (*str) { - case ' ': - case '\n': - case '\r': - case ':': - *str = 0; - /* Fallthrough */ - case 0: - return; + switch(*str) { + case ' ': + case '\n': + case '\r': + case ':': + *str = 0; + case 0: + return; } str++; } diff --git a/trunk/net/dsa/mv88e6131.c b/trunk/net/dsa/mv88e6131.c index 9bd1061fa4ee..45f7411e90ba 100644 --- a/trunk/net/dsa/mv88e6131.c +++ b/trunk/net/dsa/mv88e6131.c @@ -118,14 +118,10 @@ static int mv88e6131_setup_global(struct dsa_switch *ds) REG_WRITE(REG_GLOBAL, 0x1a, (dsa_upstream_port(ds) * 0x1100) | 0x00f0); /* - * Disable cascade port functionality unless this device - * is used in a cascade configuration, and set the switch's + * Disable cascade port functionality, and set the switch's * DSA device number. */ - if (ds->dst->pd->nr_chips > 1) - REG_WRITE(REG_GLOBAL, 0x1c, 0xf000 | (ds->index & 0x1f)); - else - REG_WRITE(REG_GLOBAL, 0x1c, 0xe000 | (ds->index & 0x1f)); + REG_WRITE(REG_GLOBAL, 0x1c, 0xe000 | (ds->index & 0x1f)); /* * Send all frames with destination addresses matching diff --git a/trunk/net/econet/af_econet.c b/trunk/net/econet/af_econet.c index 1c1f26c5d672..a1d9f3787dd5 100644 --- a/trunk/net/econet/af_econet.c +++ b/trunk/net/econet/af_econet.c @@ -9,8 +9,6 @@ * */ -#define pr_fmt(fmt) fmt - #include #include @@ -46,7 +44,7 @@ #include #include -#include +#include #include static const struct proto_ops econet_ops; @@ -65,7 +63,9 @@ static DEFINE_SPINLOCK(aun_queue_lock); static struct socket *udpsock; #define AUN_PORT 0x8000 -struct aunhdr { + +struct aunhdr +{ unsigned char code; /* AUN magic protocol byte */ unsigned char port; unsigned char cb; @@ -82,7 +82,8 @@ static struct timer_list ab_cleanup_timer; #endif /* CONFIG_ECONET_AUNUDP */ /* Per-packet information */ -struct ec_cb { +struct ec_cb +{ struct sockaddr_ec sec; unsigned long cookie; /* Supplied by user. */ #ifdef CONFIG_ECONET_AUNUDP @@ -136,7 +137,7 @@ static int econet_recvmsg(struct kiocb *iocb, struct socket *sock, * but then it will block. */ - skb = skb_recv_datagram(sk, flags, flags & MSG_DONTWAIT, &err); + skb=skb_recv_datagram(sk,flags,flags&MSG_DONTWAIT,&err); /* * An error occurred so return it. Because skb_recv_datagram() @@ -144,7 +145,7 @@ static int econet_recvmsg(struct kiocb *iocb, struct socket *sock, * retries. */ - if (skb == NULL) + if(skb==NULL) goto out; /* @@ -153,9 +154,10 @@ static int econet_recvmsg(struct kiocb *iocb, struct socket *sock, */ copied = skb->len; - if (copied > len) { - copied = len; - msg->msg_flags |= MSG_TRUNC; + if (copied > len) + { + copied=len; + msg->msg_flags|=MSG_TRUNC; } /* We can't use skb_copy_datagram here */ @@ -184,8 +186,7 @@ static int econet_recvmsg(struct kiocb *iocb, struct socket *sock, * Bind an Econet socket. */ -static int econet_bind(struct socket *sock, struct sockaddr *uaddr, - int addr_len) +static int econet_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) { struct sockaddr_ec *sec = (struct sockaddr_ec *)uaddr; struct sock *sk; @@ -225,8 +226,9 @@ static void tx_result(struct sock *sk, unsigned long cookie, int result) struct ec_cb *eb; struct sockaddr_ec *sec; - if (skb == NULL) { - pr_debug("econet: memory squeeze, transmit result dropped\n"); + if (skb == NULL) + { + printk(KERN_DEBUG "ec: memory squeeze, transmit result dropped.\n"); return; } @@ -263,7 +265,7 @@ static void ec_tx_done(struct sk_buff *skb, int result) static int econet_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, size_t len) { - struct sockaddr_ec *saddr = (struct sockaddr_ec *)msg->msg_name; + struct sockaddr_ec *saddr=(struct sockaddr_ec *)msg->msg_name; struct net_device *dev; struct ec_addr addr; int err; @@ -296,14 +298,14 @@ static int econet_sendmsg(struct kiocb *iocb, struct socket *sock, mutex_lock(&econet_mutex); - if (saddr == NULL || msg->msg_namelen < sizeof(struct sockaddr_ec)) { - mutex_unlock(&econet_mutex); - return -EINVAL; - } - addr.station = saddr->addr.station; - addr.net = saddr->addr.net; - port = saddr->port; - cb = saddr->cb; + if (saddr == NULL || msg->msg_namelen < sizeof(struct sockaddr_ec)) { + mutex_unlock(&econet_mutex); + return -EINVAL; + } + addr.station = saddr->addr.station; + addr.net = saddr->addr.net; + port = saddr->port; + cb = saddr->cb; /* Look for a device with the right network number. */ dev = net2dev_map[addr.net]; @@ -331,9 +333,9 @@ static int econet_sendmsg(struct kiocb *iocb, struct socket *sock, dev_hold(dev); - skb = sock_alloc_send_skb(sk, len + LL_ALLOCATED_SPACE(dev), + skb = sock_alloc_send_skb(sk, len+LL_ALLOCATED_SPACE(dev), msg->msg_flags & MSG_DONTWAIT, &err); - if (skb == NULL) + if (skb==NULL) goto out_unlock; skb_reserve(skb, LL_RESERVED_SPACE(dev)); @@ -353,7 +355,7 @@ static int econet_sendmsg(struct kiocb *iocb, struct socket *sock, struct ec_framehdr *fh; /* Poke in our control byte and port number. Hack, hack. */ - fh = (struct ec_framehdr *)skb->data; + fh = (struct ec_framehdr *)(skb->data); fh->cb = cb; fh->port = port; if (sock->type != SOCK_DGRAM) { @@ -363,7 +365,7 @@ static int econet_sendmsg(struct kiocb *iocb, struct socket *sock, } /* Copy the data. Returns -EFAULT on error */ - err = memcpy_fromiovec(skb_put(skb, len), msg->msg_iov, len); + err = memcpy_fromiovec(skb_put(skb,len), msg->msg_iov, len); skb->protocol = proto; skb->dev = dev; skb->priority = sk->sk_priority; @@ -383,9 +385,9 @@ static int econet_sendmsg(struct kiocb *iocb, struct socket *sock, mutex_unlock(&econet_mutex); return len; -out_free: + out_free: kfree_skb(skb); -out_unlock: + out_unlock: if (dev) dev_put(dev); #else @@ -456,14 +458,15 @@ static int econet_sendmsg(struct kiocb *iocb, struct socket *sock, goto error_free_buf; /* Get a skbuff (no data, just holds our cb information) */ - skb = sock_alloc_send_skb(sk, 0, msg->msg_flags & MSG_DONTWAIT, &err); - if (skb == NULL) + if ((skb = sock_alloc_send_skb(sk, 0, + msg->msg_flags & MSG_DONTWAIT, + &err)) == NULL) goto error_free_buf; eb = (struct ec_cb *)&skb->cb; eb->cookie = saddr->cookie; - eb->timeout = 5 * HZ; + eb->timeout = (5*HZ); eb->start = jiffies; ah.handle = aun_seq; eb->seq = (aun_seq++); @@ -477,10 +480,9 @@ static int econet_sendmsg(struct kiocb *iocb, struct socket *sock, udpmsg.msg_iovlen = 2; udpmsg.msg_control = NULL; udpmsg.msg_controllen = 0; - udpmsg.msg_flags = 0; + udpmsg.msg_flags=0; - oldfs = get_fs(); - set_fs(KERNEL_DS); /* More privs :-) */ + oldfs = get_fs(); set_fs(KERNEL_DS); /* More privs :-) */ err = sock_sendmsg(udpsock, &udpmsg, size); set_fs(oldfs); @@ -528,7 +530,7 @@ static int econet_getname(struct socket *sock, struct sockaddr *uaddr, static void econet_destroy_timer(unsigned long data) { - struct sock *sk = (struct sock *)data; + struct sock *sk=(struct sock *)data; if (!sk_has_allocations(sk)) { sk_free(sk); @@ -537,7 +539,7 @@ static void econet_destroy_timer(unsigned long data) sk->sk_timer.expires = jiffies + 10 * HZ; add_timer(&sk->sk_timer); - pr_debug("econet: socket destroy delayed\n"); + printk(KERN_DEBUG "econet socket destroy delayed\n"); } /* @@ -649,8 +651,7 @@ static int ec_dev_ioctl(struct socket *sock, unsigned int cmd, void __user *arg) if (copy_from_user(&ifr, arg, sizeof(struct ifreq))) return -EFAULT; - dev = dev_get_by_name(&init_net, ifr.ifr_name); - if (dev == NULL) + if ((dev = dev_get_by_name(&init_net, ifr.ifr_name)) == NULL) return -ENODEV; sec = (struct sockaddr_ec *)&ifr.ifr_addr; @@ -714,26 +715,28 @@ static int ec_dev_ioctl(struct socket *sock, unsigned int cmd, void __user *arg) * Handle generic ioctls */ -static int econet_ioctl(struct socket *sock, unsigned int cmd, - unsigned long arg) +static int econet_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) { struct sock *sk = sock->sk; void __user *argp = (void __user *)arg; - switch (cmd) { - case SIOCGSTAMP: - return sock_get_timestamp(sk, argp); + switch(cmd) { + case SIOCGSTAMP: + return sock_get_timestamp(sk, argp); - case SIOCGSTAMPNS: - return sock_get_timestampns(sk, argp); + case SIOCGSTAMPNS: + return sock_get_timestampns(sk, argp); - case SIOCSIFADDR: - case SIOCGIFADDR: - return ec_dev_ioctl(sock, cmd, argp); + case SIOCSIFADDR: + case SIOCGIFADDR: + return ec_dev_ioctl(sock, cmd, argp); + break; + default: + return -ENOIOCTLCMD; } - - return -ENOIOCTLCMD; + /*NOTREACHED*/ + return 0; } static const struct net_proto_family econet_family_ops = { @@ -833,7 +836,7 @@ static void aun_send_response(__u32 addr, unsigned long seq, int code, int cb) udpmsg.msg_namelen = sizeof(sin); udpmsg.msg_control = NULL; udpmsg.msg_controllen = 0; - udpmsg.msg_flags = 0; + udpmsg.msg_flags=0; kernel_sendmsg(udpsock, &udpmsg, &iov, 1, sizeof(ah)); } @@ -856,25 +859,26 @@ static void aun_incoming(struct sk_buff *skb, struct aunhdr *ah, size_t len) if (dst) edev = dst->dev->ec_ptr; - if (!edev) + if (! edev) goto bad; - sk = ec_listening_socket(ah->port, stn, edev->net); - if (sk == NULL) + if ((sk = ec_listening_socket(ah->port, stn, edev->net)) == NULL) goto bad; /* Nobody wants it */ newskb = alloc_skb((len - sizeof(struct aunhdr) + 15) & ~15, GFP_ATOMIC); - if (newskb == NULL) { - pr_debug("AUN: memory squeeze, dropping packet\n"); + if (newskb == NULL) + { + printk(KERN_DEBUG "AUN: memory squeeze, dropping packet.\n"); /* Send nack and hope sender tries again */ goto bad; } - memcpy(skb_put(newskb, len - sizeof(struct aunhdr)), (void *)(ah + 1), + memcpy(skb_put(newskb, len - sizeof(struct aunhdr)), (void *)(ah+1), len - sizeof(struct aunhdr)); - if (ec_queue_packet(sk, newskb, stn, edev->net, ah->cb, ah->port)) { + if (ec_queue_packet(sk, newskb, stn, edev->net, ah->cb, ah->port)) + { /* Socket is bankrupt. */ kfree_skb(newskb); goto bad; @@ -910,7 +914,7 @@ static void aun_tx_ack(unsigned long seq, int result) goto foundit; } spin_unlock_irqrestore(&aun_queue_lock, flags); - pr_debug("AUN: unknown sequence %ld\n", seq); + printk(KERN_DEBUG "AUN: unknown sequence %ld\n", seq); return; foundit: @@ -935,17 +939,18 @@ static void aun_data_available(struct sock *sk, int slen) while ((skb = skb_recv_datagram(sk, 0, 1, &err)) == NULL) { if (err == -EAGAIN) { - pr_err("AUN: no data available?!\n"); + printk(KERN_ERR "AUN: no data available?!"); return; } - pr_debug("AUN: recvfrom() error %d\n", -err); + printk(KERN_DEBUG "AUN: recvfrom() error %d\n", -err); } data = skb_transport_header(skb) + sizeof(struct udphdr); ah = (struct aunhdr *)data; len = skb->len - sizeof(struct udphdr); - switch (ah->code) { + switch (ah->code) + { case 2: aun_incoming(skb, ah, len); break; @@ -956,7 +961,7 @@ static void aun_data_available(struct sock *sk, int slen) aun_tx_ack(ah->handle, ECTYPE_TRANSMIT_NOT_LISTENING); break; default: - pr_debug("AUN: unknown packet type: %d\n", data[0]); + printk(KERN_DEBUG "unknown AUN packet (type %d)\n", data[0]); } skb_free_datagram(sk, skb); @@ -986,7 +991,7 @@ static void ab_cleanup(unsigned long h) } spin_unlock_irqrestore(&aun_queue_lock, flags); - mod_timer(&ab_cleanup_timer, jiffies + (HZ * 2)); + mod_timer(&ab_cleanup_timer, jiffies + (HZ*2)); } static int __init aun_udp_initialise(void) @@ -996,7 +1001,7 @@ static int __init aun_udp_initialise(void) skb_queue_head_init(&aun_queue); setup_timer(&ab_cleanup_timer, ab_cleanup, 0); - ab_cleanup_timer.expires = jiffies + (HZ * 2); + ab_cleanup_timer.expires = jiffies + (HZ*2); add_timer(&ab_cleanup_timer); memset(&sin, 0, sizeof(sin)); @@ -1004,9 +1009,9 @@ static int __init aun_udp_initialise(void) /* We can count ourselves lucky Acorn machines are too dim to speak IPv6. :-) */ - error = sock_create_kern(PF_INET, SOCK_DGRAM, 0, &udpsock); - if (error < 0) { - pr_err("AUN: socket error %d\n", -error); + if ((error = sock_create_kern(PF_INET, SOCK_DGRAM, 0, &udpsock)) < 0) + { + printk("AUN: socket error %d\n", -error); return error; } @@ -1015,9 +1020,10 @@ static int __init aun_udp_initialise(void) from interrupts */ error = udpsock->ops->bind(udpsock, (struct sockaddr *)&sin, - sizeof(sin)); - if (error < 0) { - pr_err("AUN: bind error %d\n", -error); + sizeof(sin)); + if (error < 0) + { + printk("AUN: bind error %d\n", -error); goto release; } @@ -1038,8 +1044,7 @@ static int __init aun_udp_initialise(void) * Receive an Econet frame from a device. */ -static int econet_rcv(struct sk_buff *skb, struct net_device *dev, - struct packet_type *pt, struct net_device *orig_dev) +static int econet_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt, struct net_device *orig_dev) { struct ec_framehdr *hdr; struct sock *sk = NULL; @@ -1054,14 +1059,13 @@ static int econet_rcv(struct sk_buff *skb, struct net_device *dev, if (!edev) goto drop; - skb = skb_share_check(skb, GFP_ATOMIC); - if (skb == NULL) + if ((skb = skb_share_check(skb, GFP_ATOMIC)) == NULL) return NET_RX_DROP; if (!pskb_may_pull(skb, sizeof(struct ec_framehdr))) goto drop; - hdr = (struct ec_framehdr *)skb->data; + hdr = (struct ec_framehdr *) skb->data; /* First check for encapsulated IP */ if (hdr->port == EC_PORT_IP) { @@ -1089,8 +1093,8 @@ static int econet_rcv(struct sk_buff *skb, struct net_device *dev, } static struct packet_type econet_packet_type __read_mostly = { - .type = cpu_to_be16(ETH_P_ECONET), - .func = econet_rcv, + .type = cpu_to_be16(ETH_P_ECONET), + .func = econet_rcv, }; static void econet_hw_initialise(void) @@ -1100,10 +1104,9 @@ static void econet_hw_initialise(void) #endif -static int econet_notifier(struct notifier_block *this, unsigned long msg, - void *data) +static int econet_notifier(struct notifier_block *this, unsigned long msg, void *data) { - struct net_device *dev = data; + struct net_device *dev = (struct net_device *)data; struct ec_device *edev; if (!net_eq(dev_net(dev), &init_net)) @@ -1113,7 +1116,8 @@ static int econet_notifier(struct notifier_block *this, unsigned long msg, case NETDEV_UNREGISTER: /* A device has gone down - kill any data we hold for it. */ edev = dev->ec_ptr; - if (edev) { + if (edev) + { if (net2dev_map[0] == dev) net2dev_map[0] = NULL; net2dev_map[edev->net] = NULL; @@ -1127,7 +1131,7 @@ static int econet_notifier(struct notifier_block *this, unsigned long msg, } static struct notifier_block econet_netdev_notifier = { - .notifier_call = econet_notifier, + .notifier_call =econet_notifier, }; static void __exit econet_proto_exit(void) diff --git a/trunk/net/ethernet/eth.c b/trunk/net/ethernet/eth.c index 5cffb63f481a..44d2b42fda56 100644 --- a/trunk/net/ethernet/eth.c +++ b/trunk/net/ethernet/eth.c @@ -233,8 +233,9 @@ EXPORT_SYMBOL(eth_header_parse); * @hh: destination cache entry * Create an Ethernet header template from the neighbour. */ -int eth_header_cache(const struct neighbour *neigh, struct hh_cache *hh, __be16 type) +int eth_header_cache(const struct neighbour *neigh, struct hh_cache *hh) { + __be16 type = hh->hh_type; struct ethhdr *eth; const struct net_device *dev = neigh->dev; diff --git a/trunk/net/ieee802154/af_ieee802154.c b/trunk/net/ieee802154/af_ieee802154.c index 40e606f3788f..6df6ecf49708 100644 --- a/trunk/net/ieee802154/af_ieee802154.c +++ b/trunk/net/ieee802154/af_ieee802154.c @@ -302,7 +302,7 @@ static int ieee802154_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt, struct net_device *orig_dev) { if (!netif_running(dev)) - goto drop; + return -ENODEV; pr_debug("got frame, type %d, dev %p\n", dev->type, dev); #ifdef DEBUG print_hex_dump_bytes("ieee802154_rcv ", DUMP_PREFIX_NONE, skb->data, skb->len); diff --git a/trunk/net/ieee802154/dgram.c b/trunk/net/ieee802154/dgram.c index faecf648123f..1a3334c2609a 100644 --- a/trunk/net/ieee802154/dgram.c +++ b/trunk/net/ieee802154/dgram.c @@ -1,5 +1,5 @@ /* - * IEEE 802.15.4 dgram socket interface + * ZigBee socket interface * * Copyright 2007, 2008 Siemens AG * diff --git a/trunk/net/ieee802154/nl-phy.c b/trunk/net/ieee802154/nl-phy.c index c64a38d57aa3..02548b292b53 100644 --- a/trunk/net/ieee802154/nl-phy.c +++ b/trunk/net/ieee802154/nl-phy.c @@ -24,7 +24,6 @@ #include #include -#include #include #include #include @@ -214,37 +213,12 @@ static int ieee802154_add_iface(struct sk_buff *skb, goto nla_put_failure; } - if (info->attrs[IEEE802154_ATTR_HW_ADDR] && - nla_len(info->attrs[IEEE802154_ATTR_HW_ADDR]) != - IEEE802154_ADDR_LEN) { - rc = -EINVAL; - goto nla_put_failure; - } - dev = phy->add_iface(phy, devname); if (IS_ERR(dev)) { rc = PTR_ERR(dev); goto nla_put_failure; } - if (info->attrs[IEEE802154_ATTR_HW_ADDR]) { - struct sockaddr addr; - - addr.sa_family = ARPHRD_IEEE802154; - nla_memcpy(&addr.sa_data, info->attrs[IEEE802154_ATTR_HW_ADDR], - IEEE802154_ADDR_LEN); - - /* - * strangely enough, some callbacks (inetdev_event) from - * dev_set_mac_address require RTNL_LOCK - */ - rtnl_lock(); - rc = dev_set_mac_address(dev, &addr); - rtnl_unlock(); - if (rc) - goto dev_unregister; - } - NLA_PUT_STRING(msg, IEEE802154_ATTR_PHY_NAME, wpan_phy_name(phy)); NLA_PUT_STRING(msg, IEEE802154_ATTR_DEV_NAME, dev->name); @@ -254,11 +228,6 @@ static int ieee802154_add_iface(struct sk_buff *skb, return ieee802154_nl_reply(msg, info); -dev_unregister: - rtnl_lock(); /* del_iface must be called with RTNL lock */ - phy->del_iface(phy, dev); - dev_put(dev); - rtnl_unlock(); nla_put_failure: nlmsg_free(msg); out_dev: diff --git a/trunk/net/ipv4/af_inet.c b/trunk/net/ipv4/af_inet.c index 1b745d412cf6..0600f0fbe325 100644 --- a/trunk/net/ipv4/af_inet.c +++ b/trunk/net/ipv4/af_inet.c @@ -465,10 +465,8 @@ int inet_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) if (addr_len < sizeof(struct sockaddr_in)) goto out; - if (addr->sin_family != AF_INET) { - err = -EAFNOSUPPORT; + if (addr->sin_family != AF_INET) goto out; - } chk_addr_ret = inet_addr_type(sock_net(sk), addr->sin_addr.s_addr); diff --git a/trunk/net/ipv4/arp.c b/trunk/net/ipv4/arp.c index 3e5545675ccf..1b74d3b64371 100644 --- a/trunk/net/ipv4/arp.c +++ b/trunk/net/ipv4/arp.c @@ -97,6 +97,7 @@ #include #include #include +#include #include #ifdef CONFIG_SYSCTL #include @@ -231,7 +232,7 @@ static u32 arp_hash(const void *pkey, const struct net_device *dev, __u32 hash_rnd) { - return arp_hashfn(*(u32 *)pkey, dev, hash_rnd); + return jhash_2words(*(u32 *)pkey, dev->ifindex, hash_rnd); } static int arp_constructor(struct neighbour *neigh) @@ -517,6 +518,30 @@ EXPORT_SYMBOL(arp_find); /* END OF OBSOLETE FUNCTIONS */ +int arp_bind_neighbour(struct dst_entry *dst) +{ + struct net_device *dev = dst->dev; + struct neighbour *n = dst->neighbour; + + if (dev == NULL) + return -EINVAL; + if (n == NULL) { + __be32 nexthop = ((struct rtable *)dst)->rt_gateway; + if (dev->flags & (IFF_LOOPBACK | IFF_POINTOPOINT)) + nexthop = 0; + n = __neigh_lookup_errno( +#if defined(CONFIG_ATM_CLIP) || defined(CONFIG_ATM_CLIP_MODULE) + dev->type == ARPHRD_ATM ? + clip_tbl_hook : +#endif + &arp_tbl, &nexthop, dev); + if (IS_ERR(n)) + return PTR_ERR(n); + dst->neighbour = n; + } + return 0; +} + /* * Check if we can use proxy ARP for this path */ diff --git a/trunk/net/ipv4/inetpeer.c b/trunk/net/ipv4/inetpeer.c index 90c5f0d1bcf3..dafbf2c98b28 100644 --- a/trunk/net/ipv4/inetpeer.c +++ b/trunk/net/ipv4/inetpeer.c @@ -373,14 +373,11 @@ static int inet_peer_gc(struct inet_peer_base *base, while (stackptr > stack) { stackptr--; p = rcu_deref_locked(**stackptr, base); - if (atomic_read(&p->refcnt) == 0) { - smp_rmb(); - delta = (__u32)jiffies - p->dtime; - if (delta >= ttl && - atomic_cmpxchg(&p->refcnt, 0, -1) == 0) { - p->gc_next = gchead; - gchead = p; - } + delta = (__u32)jiffies - p->dtime; + if (atomic_read(&p->refcnt) == 0 && delta >= ttl && + atomic_cmpxchg(&p->refcnt, 0, -1) == 0) { + p->gc_next = gchead; + gchead = p; } } while ((p = gchead) != NULL) { @@ -459,7 +456,6 @@ EXPORT_SYMBOL_GPL(inet_getpeer); void inet_putpeer(struct inet_peer *p) { p->dtime = (__u32)jiffies; - smp_mb__before_atomic_dec(); atomic_dec(&p->refcnt); } EXPORT_SYMBOL_GPL(inet_putpeer); diff --git a/trunk/net/ipv4/ip_fragment.c b/trunk/net/ipv4/ip_fragment.c index 0e0ab98abc6f..0ad6035f6366 100644 --- a/trunk/net/ipv4/ip_fragment.c +++ b/trunk/net/ipv4/ip_fragment.c @@ -261,9 +261,8 @@ static void ip_expire(unsigned long arg) * Only an end host needs to send an ICMP * "Fragment Reassembly Timeout" message, per RFC792. */ - if (qp->user == IP_DEFRAG_AF_PACKET || - (qp->user == IP_DEFRAG_CONNTRACK_IN && - skb_rtable(head)->rt_type != RTN_LOCAL)) + if (qp->user == IP_DEFRAG_CONNTRACK_IN && + skb_rtable(head)->rt_type != RTN_LOCAL) goto out_rcu_unlock; diff --git a/trunk/net/ipv4/ip_output.c b/trunk/net/ipv4/ip_output.c index a621b96aed15..167da8ba416a 100644 --- a/trunk/net/ipv4/ip_output.c +++ b/trunk/net/ipv4/ip_output.c @@ -182,7 +182,6 @@ static inline int ip_finish_output2(struct sk_buff *skb) struct rtable *rt = (struct rtable *)dst; struct net_device *dev = dst->dev; unsigned int hh_len = LL_RESERVED_SPACE(dev); - struct neighbour *neigh; if (rt->rt_type == RTN_MULTICAST) { IP_UPD_PO_STATS(dev_net(dev), IPSTATS_MIB_OUTMCAST, skb->len); @@ -204,14 +203,11 @@ static inline int ip_finish_output2(struct sk_buff *skb) skb = skb2; } - neigh = dst->neighbour; - if (neigh) { - struct hh_cache *hh = &neigh->hh; - if (hh->hh_len) - return neigh_hh_output(hh, skb); - else - return dst->neighbour->output(skb); - } + if (dst->hh) + return neigh_hh_output(dst->hh, skb); + else if (dst->neighbour) + return dst->neighbour->output(skb); + if (net_ratelimit()) printk(KERN_DEBUG "ip_finish_output2: No header cache and no neighbour!\n"); kfree_skb(skb); @@ -806,6 +802,8 @@ static int __ip_append_data(struct sock *sk, skb = skb_peek_tail(queue); exthdrlen = !skb ? rt->dst.header_len : 0; + length += exthdrlen; + transhdrlen += exthdrlen; mtu = cork->fragsize; hh_len = LL_RESERVED_SPACE(rt->dst.dev); @@ -832,7 +830,7 @@ static int __ip_append_data(struct sock *sk, cork->length += length; if (((length > mtu) || (skb && skb_is_gso(skb))) && (sk->sk_protocol == IPPROTO_UDP) && - (rt->dst.dev->features & NETIF_F_UFO) && !rt->dst.header_len) { + (rt->dst.dev->features & NETIF_F_UFO)) { err = ip_ufo_append_data(sk, queue, getfrag, from, length, hh_len, fragheaderlen, transhdrlen, mtu, flags); @@ -885,16 +883,17 @@ static int __ip_append_data(struct sock *sk, else alloclen = fraglen; - alloclen += exthdrlen; - /* The last fragment gets additional space at tail. * Note, with MSG_MORE we overallocate on fragments, * because we have no idea what fragment will be * the last. */ - if (datalen == length + fraggap) + if (datalen == length + fraggap) { alloclen += rt->dst.trailer_len; - + /* make sure mtu is not reached */ + if (datalen > mtu - fragheaderlen - rt->dst.trailer_len) + datalen -= ALIGN(rt->dst.trailer_len, 8); + } if (transhdrlen) { skb = sock_alloc_send_skb(sk, alloclen + hh_len + 15, @@ -927,11 +926,11 @@ static int __ip_append_data(struct sock *sk, /* * Find where to start putting bytes. */ - data = skb_put(skb, fraglen + exthdrlen); + data = skb_put(skb, fraglen); skb_set_network_header(skb, exthdrlen); skb->transport_header = (skb->network_header + fragheaderlen); - data += fragheaderlen + exthdrlen; + data += fragheaderlen; if (fraggap) { skb->csum = skb_copy_and_csum_bits( @@ -1065,7 +1064,7 @@ static int ip_setup_cork(struct sock *sk, struct inet_cork *cork, */ *rtp = NULL; cork->fragsize = inet->pmtudisc == IP_PMTUDISC_PROBE ? - rt->dst.dev->mtu : dst_mtu(&rt->dst); + rt->dst.dev->mtu : dst_mtu(rt->dst.path); cork->dst = &rt->dst; cork->length = 0; cork->tx_flags = ipc->tx_flags; diff --git a/trunk/net/ipv4/ipconfig.c b/trunk/net/ipv4/ipconfig.c index 472a8c4f1dc0..ae93dd5ef401 100644 --- a/trunk/net/ipv4/ipconfig.c +++ b/trunk/net/ipv4/ipconfig.c @@ -861,44 +861,41 @@ static void __init ic_do_bootp_ext(u8 *ext) #endif switch (*ext++) { - case 1: /* Subnet mask */ - if (ic_netmask == NONE) - memcpy(&ic_netmask, ext+1, 4); - break; - case 3: /* Default gateway */ - if (ic_gateway == NONE) - memcpy(&ic_gateway, ext+1, 4); - break; - case 6: /* DNS server */ - servers= *ext/4; - if (servers > CONF_NAMESERVERS_MAX) - servers = CONF_NAMESERVERS_MAX; - for (i = 0; i < servers; i++) { - if (ic_nameservers[i] == NONE) - memcpy(&ic_nameservers[i], ext+1+4*i, 4); - } - break; - case 12: /* Host name */ - ic_bootp_string(utsname()->nodename, ext+1, *ext, - __NEW_UTS_LEN); - ic_host_name_set = 1; - break; - case 15: /* Domain name (DNS) */ - ic_bootp_string(ic_domain, ext+1, *ext, sizeof(ic_domain)); - break; - case 17: /* Root path */ - if (!root_server_path[0]) - ic_bootp_string(root_server_path, ext+1, *ext, - sizeof(root_server_path)); - break; - case 26: /* Interface MTU */ - memcpy(&mtu, ext+1, sizeof(mtu)); - ic_dev_mtu = ntohs(mtu); - break; - case 40: /* NIS Domain name (_not_ DNS) */ - ic_bootp_string(utsname()->domainname, ext+1, *ext, - __NEW_UTS_LEN); - break; + case 1: /* Subnet mask */ + if (ic_netmask == NONE) + memcpy(&ic_netmask, ext+1, 4); + break; + case 3: /* Default gateway */ + if (ic_gateway == NONE) + memcpy(&ic_gateway, ext+1, 4); + break; + case 6: /* DNS server */ + servers= *ext/4; + if (servers > CONF_NAMESERVERS_MAX) + servers = CONF_NAMESERVERS_MAX; + for (i = 0; i < servers; i++) { + if (ic_nameservers[i] == NONE) + memcpy(&ic_nameservers[i], ext+1+4*i, 4); + } + break; + case 12: /* Host name */ + ic_bootp_string(utsname()->nodename, ext+1, *ext, __NEW_UTS_LEN); + ic_host_name_set = 1; + break; + case 15: /* Domain name (DNS) */ + ic_bootp_string(ic_domain, ext+1, *ext, sizeof(ic_domain)); + break; + case 17: /* Root path */ + if (!root_server_path[0]) + ic_bootp_string(root_server_path, ext+1, *ext, sizeof(root_server_path)); + break; + case 26: /* Interface MTU */ + memcpy(&mtu, ext+1, sizeof(mtu)); + ic_dev_mtu = ntohs(mtu); + break; + case 40: /* NIS Domain name (_not_ DNS) */ + ic_bootp_string(utsname()->domainname, ext+1, *ext, __NEW_UTS_LEN); + break; } } diff --git a/trunk/net/ipv4/netfilter.c b/trunk/net/ipv4/netfilter.c index 2e97e3ec1eb7..4614babdc45f 100644 --- a/trunk/net/ipv4/netfilter.c +++ b/trunk/net/ipv4/netfilter.c @@ -17,35 +17,51 @@ int ip_route_me_harder(struct sk_buff *skb, unsigned addr_type) const struct iphdr *iph = ip_hdr(skb); struct rtable *rt; struct flowi4 fl4 = {}; - __be32 saddr = iph->saddr; - __u8 flags = 0; + unsigned long orefdst; unsigned int hh_len; + unsigned int type; - if (!skb->sk && addr_type != RTN_LOCAL) { - if (addr_type == RTN_UNSPEC) - addr_type = inet_addr_type(net, saddr); - if (addr_type == RTN_LOCAL || addr_type == RTN_UNICAST) - flags |= FLOWI_FLAG_ANYSRC; - else - saddr = 0; - } + type = inet_addr_type(net, iph->saddr); + if (skb->sk && inet_sk(skb->sk)->transparent) + type = RTN_LOCAL; + if (addr_type == RTN_UNSPEC) + addr_type = type; /* some non-standard hacks like ipt_REJECT.c:send_reset() can cause * packets with foreign saddr to appear on the NF_INET_LOCAL_OUT hook. */ - fl4.daddr = iph->daddr; - fl4.saddr = saddr; - fl4.flowi4_tos = RT_TOS(iph->tos); - fl4.flowi4_oif = skb->sk ? skb->sk->sk_bound_dev_if : 0; - fl4.flowi4_mark = skb->mark; - fl4.flowi4_flags = skb->sk ? inet_sk_flowi_flags(skb->sk) : flags; - rt = ip_route_output_key(net, &fl4); - if (IS_ERR(rt)) - return -1; + if (addr_type == RTN_LOCAL) { + fl4.daddr = iph->daddr; + if (type == RTN_LOCAL) + fl4.saddr = iph->saddr; + fl4.flowi4_tos = RT_TOS(iph->tos); + fl4.flowi4_oif = skb->sk ? skb->sk->sk_bound_dev_if : 0; + fl4.flowi4_mark = skb->mark; + fl4.flowi4_flags = skb->sk ? inet_sk_flowi_flags(skb->sk) : 0; + rt = ip_route_output_key(net, &fl4); + if (IS_ERR(rt)) + return -1; - /* Drop old route. */ - skb_dst_drop(skb); - skb_dst_set(skb, &rt->dst); + /* Drop old route. */ + skb_dst_drop(skb); + skb_dst_set(skb, &rt->dst); + } else { + /* non-local src, find valid iif to satisfy + * rp-filter when calling ip_route_input. */ + fl4.daddr = iph->saddr; + rt = ip_route_output_key(net, &fl4); + if (IS_ERR(rt)) + return -1; + + orefdst = skb->_skb_refdst; + if (ip_route_input(skb, iph->daddr, iph->saddr, + RT_TOS(iph->tos), rt->dst.dev) != 0) { + dst_release(&rt->dst); + return -1; + } + dst_release(&rt->dst); + refdst_drop(orefdst); + } if (skb_dst(skb)->error) return -1; diff --git a/trunk/net/ipv4/netfilter/ipt_CLUSTERIP.c b/trunk/net/ipv4/netfilter/ipt_CLUSTERIP.c index db8d22db425f..5c9e97c79017 100644 --- a/trunk/net/ipv4/netfilter/ipt_CLUSTERIP.c +++ b/trunk/net/ipv4/netfilter/ipt_CLUSTERIP.c @@ -317,19 +317,19 @@ clusterip_tg(struct sk_buff *skb, const struct xt_action_param *par) hash = clusterip_hashfn(skb, cipinfo->config); switch (ctinfo) { - case IP_CT_NEW: - ct->mark = hash; - break; - case IP_CT_RELATED: - case IP_CT_RELATED_REPLY: - /* FIXME: we don't handle expectations at the moment. - * They can arrive on a different node than - * the master connection (e.g. FTP passive mode) */ - case IP_CT_ESTABLISHED: - case IP_CT_ESTABLISHED_REPLY: - break; - default: /* Prevent gcc warnings */ - break; + case IP_CT_NEW: + ct->mark = hash; + break; + case IP_CT_RELATED: + case IP_CT_RELATED_REPLY: + /* FIXME: we don't handle expectations at the + * moment. they can arrive on a different node than + * the master connection (e.g. FTP passive mode) */ + case IP_CT_ESTABLISHED: + case IP_CT_ESTABLISHED_REPLY: + break; + default: + break; } #ifdef DEBUG diff --git a/trunk/net/ipv4/netfilter/ipt_REJECT.c b/trunk/net/ipv4/netfilter/ipt_REJECT.c index 51f13f8ec724..1ff79e557f96 100644 --- a/trunk/net/ipv4/netfilter/ipt_REJECT.c +++ b/trunk/net/ipv4/netfilter/ipt_REJECT.c @@ -40,6 +40,7 @@ static void send_reset(struct sk_buff *oldskb, int hook) struct iphdr *niph; const struct tcphdr *oth; struct tcphdr _otcph, *tcph; + unsigned int addr_type; /* IP header checks: fragment. */ if (ip_hdr(oldskb)->frag_off & htons(IP_OFFSET)) @@ -54,9 +55,6 @@ static void send_reset(struct sk_buff *oldskb, int hook) if (oth->rst) return; - if (skb_rtable(oldskb)->rt_flags & (RTCF_BROADCAST | RTCF_MULTICAST)) - return; - /* Check checksum */ if (nf_ip_checksum(oldskb, hook, ip_hdrlen(oldskb), IPPROTO_TCP)) return; @@ -103,11 +101,19 @@ static void send_reset(struct sk_buff *oldskb, int hook) nskb->csum_start = (unsigned char *)tcph - nskb->head; nskb->csum_offset = offsetof(struct tcphdr, check); + addr_type = RTN_UNSPEC; + if (hook != NF_INET_FORWARD +#ifdef CONFIG_BRIDGE_NETFILTER + || (nskb->nf_bridge && nskb->nf_bridge->mask & BRNF_BRIDGED) +#endif + ) + addr_type = RTN_LOCAL; + /* ip_route_me_harder expects skb->dst to be set */ skb_dst_set_noref(nskb, skb_dst(oldskb)); nskb->protocol = htons(ETH_P_IP); - if (ip_route_me_harder(nskb, RTN_UNSPEC)) + if (ip_route_me_harder(nskb, addr_type)) goto free_nskb; niph->ttl = ip4_dst_hoplimit(skb_dst(nskb)); diff --git a/trunk/net/ipv4/netfilter/nf_nat_snmp_basic.c b/trunk/net/ipv4/netfilter/nf_nat_snmp_basic.c index 076b7c8c4aa4..8812a02078ab 100644 --- a/trunk/net/ipv4/netfilter/nf_nat_snmp_basic.c +++ b/trunk/net/ipv4/netfilter/nf_nat_snmp_basic.c @@ -719,115 +719,117 @@ static unsigned char snmp_object_decode(struct asn1_ctx *ctx, l = 0; switch (type) { - case SNMP_INTEGER: - len = sizeof(long); - if (!asn1_long_decode(ctx, end, &l)) { - kfree(id); - return 0; - } - *obj = kmalloc(sizeof(struct snmp_object) + len, GFP_ATOMIC); - if (*obj == NULL) { - kfree(id); - if (net_ratelimit()) - pr_notice("OOM in bsalg (%d)\n", __LINE__); - return 0; - } - (*obj)->syntax.l[0] = l; - break; - case SNMP_OCTETSTR: - case SNMP_OPAQUE: - if (!asn1_octets_decode(ctx, end, &p, &len)) { - kfree(id); - return 0; - } - *obj = kmalloc(sizeof(struct snmp_object) + len, GFP_ATOMIC); - if (*obj == NULL) { + case SNMP_INTEGER: + len = sizeof(long); + if (!asn1_long_decode(ctx, end, &l)) { + kfree(id); + return 0; + } + *obj = kmalloc(sizeof(struct snmp_object) + len, + GFP_ATOMIC); + if (*obj == NULL) { + kfree(id); + if (net_ratelimit()) + pr_notice("OOM in bsalg (%d)\n", __LINE__); + return 0; + } + (*obj)->syntax.l[0] = l; + break; + case SNMP_OCTETSTR: + case SNMP_OPAQUE: + if (!asn1_octets_decode(ctx, end, &p, &len)) { + kfree(id); + return 0; + } + *obj = kmalloc(sizeof(struct snmp_object) + len, + GFP_ATOMIC); + if (*obj == NULL) { + kfree(p); + kfree(id); + if (net_ratelimit()) + pr_notice("OOM in bsalg (%d)\n", __LINE__); + return 0; + } + memcpy((*obj)->syntax.c, p, len); kfree(p); - kfree(id); - if (net_ratelimit()) - pr_notice("OOM in bsalg (%d)\n", __LINE__); - return 0; - } - memcpy((*obj)->syntax.c, p, len); - kfree(p); - break; - case SNMP_NULL: - case SNMP_NOSUCHOBJECT: - case SNMP_NOSUCHINSTANCE: - case SNMP_ENDOFMIBVIEW: - len = 0; - *obj = kmalloc(sizeof(struct snmp_object), GFP_ATOMIC); - if (*obj == NULL) { - kfree(id); - if (net_ratelimit()) - pr_notice("OOM in bsalg (%d)\n", __LINE__); - return 0; - } - if (!asn1_null_decode(ctx, end)) { - kfree(id); - kfree(*obj); - *obj = NULL; - return 0; - } - break; - case SNMP_OBJECTID: - if (!asn1_oid_decode(ctx, end, (unsigned long **)&lp, &len)) { - kfree(id); - return 0; - } - len *= sizeof(unsigned long); - *obj = kmalloc(sizeof(struct snmp_object) + len, GFP_ATOMIC); - if (*obj == NULL) { + break; + case SNMP_NULL: + case SNMP_NOSUCHOBJECT: + case SNMP_NOSUCHINSTANCE: + case SNMP_ENDOFMIBVIEW: + len = 0; + *obj = kmalloc(sizeof(struct snmp_object), GFP_ATOMIC); + if (*obj == NULL) { + kfree(id); + if (net_ratelimit()) + pr_notice("OOM in bsalg (%d)\n", __LINE__); + return 0; + } + if (!asn1_null_decode(ctx, end)) { + kfree(id); + kfree(*obj); + *obj = NULL; + return 0; + } + break; + case SNMP_OBJECTID: + if (!asn1_oid_decode(ctx, end, (unsigned long **)&lp, &len)) { + kfree(id); + return 0; + } + len *= sizeof(unsigned long); + *obj = kmalloc(sizeof(struct snmp_object) + len, GFP_ATOMIC); + if (*obj == NULL) { + kfree(lp); + kfree(id); + if (net_ratelimit()) + pr_notice("OOM in bsalg (%d)\n", __LINE__); + return 0; + } + memcpy((*obj)->syntax.ul, lp, len); kfree(lp); - kfree(id); - if (net_ratelimit()) - pr_notice("OOM in bsalg (%d)\n", __LINE__); - return 0; - } - memcpy((*obj)->syntax.ul, lp, len); - kfree(lp); - break; - case SNMP_IPADDR: - if (!asn1_octets_decode(ctx, end, &p, &len)) { - kfree(id); - return 0; - } - if (len != 4) { - kfree(p); - kfree(id); - return 0; - } - *obj = kmalloc(sizeof(struct snmp_object) + len, GFP_ATOMIC); - if (*obj == NULL) { + break; + case SNMP_IPADDR: + if (!asn1_octets_decode(ctx, end, &p, &len)) { + kfree(id); + return 0; + } + if (len != 4) { + kfree(p); + kfree(id); + return 0; + } + *obj = kmalloc(sizeof(struct snmp_object) + len, GFP_ATOMIC); + if (*obj == NULL) { + kfree(p); + kfree(id); + if (net_ratelimit()) + pr_notice("OOM in bsalg (%d)\n", __LINE__); + return 0; + } + memcpy((*obj)->syntax.uc, p, len); kfree(p); + break; + case SNMP_COUNTER: + case SNMP_GAUGE: + case SNMP_TIMETICKS: + len = sizeof(unsigned long); + if (!asn1_ulong_decode(ctx, end, &ul)) { + kfree(id); + return 0; + } + *obj = kmalloc(sizeof(struct snmp_object) + len, GFP_ATOMIC); + if (*obj == NULL) { + kfree(id); + if (net_ratelimit()) + pr_notice("OOM in bsalg (%d)\n", __LINE__); + return 0; + } + (*obj)->syntax.ul[0] = ul; + break; + default: kfree(id); - if (net_ratelimit()) - pr_notice("OOM in bsalg (%d)\n", __LINE__); - return 0; - } - memcpy((*obj)->syntax.uc, p, len); - kfree(p); - break; - case SNMP_COUNTER: - case SNMP_GAUGE: - case SNMP_TIMETICKS: - len = sizeof(unsigned long); - if (!asn1_ulong_decode(ctx, end, &ul)) { - kfree(id); - return 0; - } - *obj = kmalloc(sizeof(struct snmp_object) + len, GFP_ATOMIC); - if (*obj == NULL) { - kfree(id); - if (net_ratelimit()) - pr_notice("OOM in bsalg (%d)\n", __LINE__); return 0; - } - (*obj)->syntax.ul[0] = ul; - break; - default: - kfree(id); - return 0; } (*obj)->syntax_len = len; diff --git a/trunk/net/ipv4/raw.c b/trunk/net/ipv4/raw.c index 08526786dc39..c9893d43242e 100644 --- a/trunk/net/ipv4/raw.c +++ b/trunk/net/ipv4/raw.c @@ -825,28 +825,28 @@ static int compat_raw_getsockopt(struct sock *sk, int level, int optname, static int raw_ioctl(struct sock *sk, int cmd, unsigned long arg) { switch (cmd) { - case SIOCOUTQ: { - int amount = sk_wmem_alloc_get(sk); + case SIOCOUTQ: { + int amount = sk_wmem_alloc_get(sk); - return put_user(amount, (int __user *)arg); - } - case SIOCINQ: { - struct sk_buff *skb; - int amount = 0; - - spin_lock_bh(&sk->sk_receive_queue.lock); - skb = skb_peek(&sk->sk_receive_queue); - if (skb != NULL) - amount = skb->len; - spin_unlock_bh(&sk->sk_receive_queue.lock); - return put_user(amount, (int __user *)arg); - } + return put_user(amount, (int __user *)arg); + } + case SIOCINQ: { + struct sk_buff *skb; + int amount = 0; + + spin_lock_bh(&sk->sk_receive_queue.lock); + skb = skb_peek(&sk->sk_receive_queue); + if (skb != NULL) + amount = skb->len; + spin_unlock_bh(&sk->sk_receive_queue.lock); + return put_user(amount, (int __user *)arg); + } - default: + default: #ifdef CONFIG_IP_MROUTE - return ipmr_ioctl(sk, cmd, (void __user *)arg); + return ipmr_ioctl(sk, cmd, (void __user *)arg); #else - return -ENOIOCTLCMD; + return -ENOIOCTLCMD; #endif } } diff --git a/trunk/net/ipv4/route.c b/trunk/net/ipv4/route.c index a52bb74d2612..f24c3359e5d0 100644 --- a/trunk/net/ipv4/route.c +++ b/trunk/net/ipv4/route.c @@ -108,7 +108,6 @@ #ifdef CONFIG_SYSCTL #include #endif -#include #define RT_FL_TOS(oldflp4) \ ((u32)(oldflp4->flowi4_tos & (IPTOS_RT_MASK | RTO_ONLINK))) @@ -426,10 +425,9 @@ static int rt_cache_seq_show(struct seq_file *seq, void *v) (int)((dst_metric(&r->dst, RTAX_RTT) >> 3) + dst_metric(&r->dst, RTAX_RTTVAR)), r->rt_key_tos, - -1, - (r->dst.neighbour ? - (r->dst.neighbour->hh.hh_output == - dev_queue_xmit) : 0), + r->dst.hh ? atomic_read(&r->dst.hh->hh_refcnt) : -1, + r->dst.hh ? (r->dst.hh->hh_output == + dev_queue_xmit) : 0, r->rt_spec_dst, &len); seq_printf(seq, "%*s\n", 127 - len, ""); @@ -1008,29 +1006,6 @@ static int slow_chain_length(const struct rtable *head) return length >> FRACT_BITS; } -static int rt_bind_neighbour(struct rtable *rt) -{ - static const __be32 inaddr_any = 0; - struct net_device *dev = rt->dst.dev; - struct neigh_table *tbl = &arp_tbl; - const __be32 *nexthop; - struct neighbour *n; - -#if defined(CONFIG_ATM_CLIP) || defined(CONFIG_ATM_CLIP_MODULE) - if (dev->type == ARPHRD_ATM) - tbl = clip_tbl_hook; -#endif - nexthop = &rt->rt_gateway; - if (dev->flags & (IFF_LOOPBACK | IFF_POINTOPOINT)) - nexthop = &inaddr_any; - n = ipv4_neigh_lookup(tbl, dev, nexthop); - if (IS_ERR(n)) - return PTR_ERR(n); - rt->dst.neighbour = n; - - return 0; -} - static struct rtable *rt_intern_hash(unsigned hash, struct rtable *rt, struct sk_buff *skb, int ifindex) { @@ -1067,7 +1042,7 @@ static struct rtable *rt_intern_hash(unsigned hash, struct rtable *rt, rt->dst.flags |= DST_NOCACHE; if (rt->rt_type == RTN_UNICAST || rt_is_output_route(rt)) { - int err = rt_bind_neighbour(rt); + int err = arp_bind_neighbour(&rt->dst); if (err) { if (net_ratelimit()) printk(KERN_WARNING @@ -1163,7 +1138,7 @@ static struct rtable *rt_intern_hash(unsigned hash, struct rtable *rt, route or unicast forwarding path. */ if (rt->rt_type == RTN_UNICAST || rt_is_output_route(rt)) { - int err = rt_bind_neighbour(rt); + int err = arp_bind_neighbour(&rt->dst); if (err) { spin_unlock_bh(rt_hash_lock_addr(hash)); @@ -1464,20 +1439,20 @@ static int ip_error(struct sk_buff *skb) int code; switch (rt->dst.error) { - case EINVAL: - default: - goto out; - case EHOSTUNREACH: - code = ICMP_HOST_UNREACH; - break; - case ENETUNREACH: - code = ICMP_NET_UNREACH; - IP_INC_STATS_BH(dev_net(rt->dst.dev), - IPSTATS_MIB_INNOROUTES); - break; - case EACCES: - code = ICMP_PKT_FILTERED; - break; + case EINVAL: + default: + goto out; + case EHOSTUNREACH: + code = ICMP_HOST_UNREACH; + break; + case ENETUNREACH: + code = ICMP_NET_UNREACH; + IP_INC_STATS_BH(dev_net(rt->dst.dev), + IPSTATS_MIB_INNOROUTES); + break; + case EACCES: + code = ICMP_PKT_FILTERED; + break; } if (!rt->peer) @@ -1624,7 +1599,7 @@ static int check_peer_redir(struct dst_entry *dst, struct inet_peer *peer) rt->dst.neighbour = NULL; rt->rt_gateway = peer->redirect_learned.a4; - if (rt_bind_neighbour(rt) || + if (arp_bind_neighbour(&rt->dst) || !(rt->dst.neighbour->nud_state & NUD_VALID)) { if (rt->dst.neighbour) neigh_event_send(rt->dst.neighbour, NULL); diff --git a/trunk/net/ipv4/tcp.c b/trunk/net/ipv4/tcp.c index 46febcacb729..054a59d21eb0 100644 --- a/trunk/net/ipv4/tcp.c +++ b/trunk/net/ipv4/tcp.c @@ -3220,7 +3220,7 @@ __setup("thash_entries=", set_thash_entries); void __init tcp_init(void) { struct sk_buff *skb = NULL; - unsigned long limit; + unsigned long nr_pages, limit; int i, max_share, cnt; unsigned long jiffy = jiffies; @@ -3277,7 +3277,13 @@ void __init tcp_init(void) sysctl_tcp_max_orphans = cnt / 2; sysctl_max_syn_backlog = max(128, cnt / 256); - limit = nr_free_buffer_pages() / 8; + /* Set the pressure threshold to be a fraction of global memory that + * is up to 1/2 at 256 MB, decreasing toward zero with the amount of + * memory, with a floor of 128 pages. + */ + nr_pages = totalram_pages - totalhigh_pages; + limit = min(nr_pages, 1UL<<(28-PAGE_SHIFT)) >> (20-PAGE_SHIFT); + limit = (limit * (nr_pages >> (20-PAGE_SHIFT))) >> (PAGE_SHIFT-11); limit = max(limit, 128UL); sysctl_tcp_mem[0] = limit / 4 * 3; sysctl_tcp_mem[1] = limit; diff --git a/trunk/net/ipv4/udp.c b/trunk/net/ipv4/udp.c index 1b5a19340a95..37aa9bf8d382 100644 --- a/trunk/net/ipv4/udp.c +++ b/trunk/net/ipv4/udp.c @@ -1250,9 +1250,6 @@ int udp_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, if (noblock) return -EAGAIN; - - /* starting over for a new packet */ - msg->msg_flags &= ~MSG_TRUNC; goto try_again; } @@ -2211,10 +2208,16 @@ void __init udp_table_init(struct udp_table *table, const char *name) void __init udp_init(void) { - unsigned long limit; + unsigned long nr_pages, limit; udp_table_init(&udp_table, "UDP"); - limit = nr_free_buffer_pages() / 8; + /* Set the pressure threshold up by the same strategy of TCP. It is a + * fraction of global memory that is up to 1/2 at 256 MB, decreasing + * toward zero with the amount of memory, with a floor of 128 pages. + */ + nr_pages = totalram_pages - totalhigh_pages; + limit = min(nr_pages, 1UL<<(28-PAGE_SHIFT)) >> (20-PAGE_SHIFT); + limit = (limit * (nr_pages >> (20-PAGE_SHIFT))) >> (PAGE_SHIFT-11); limit = max(limit, 128UL); sysctl_udp_mem[0] = limit / 4 * 3; sysctl_udp_mem[1] = limit; diff --git a/trunk/net/ipv4/xfrm4_output.c b/trunk/net/ipv4/xfrm4_output.c index 327a617d594c..2d51840e53a1 100644 --- a/trunk/net/ipv4/xfrm4_output.c +++ b/trunk/net/ipv4/xfrm4_output.c @@ -32,12 +32,7 @@ static int xfrm4_tunnel_check_size(struct sk_buff *skb) dst = skb_dst(skb); mtu = dst_mtu(dst); if (skb->len > mtu) { - if (skb->sk) - ip_local_error(skb->sk, EMSGSIZE, ip_hdr(skb)->daddr, - inet_sk(skb->sk)->inet_dport, mtu); - else - icmp_send(skb, ICMP_DEST_UNREACH, - ICMP_FRAG_NEEDED, htonl(mtu)); + icmp_send(skb, ICMP_DEST_UNREACH, ICMP_FRAG_NEEDED, htonl(mtu)); ret = -EMSGSIZE; } out: diff --git a/trunk/net/ipv6/addrconf.c b/trunk/net/ipv6/addrconf.c index fc6d37723664..05838c7fcf64 100644 --- a/trunk/net/ipv6/addrconf.c +++ b/trunk/net/ipv6/addrconf.c @@ -1470,8 +1470,6 @@ void addrconf_leave_solict(struct inet6_dev *idev, const struct in6_addr *addr) static void addrconf_join_anycast(struct inet6_ifaddr *ifp) { struct in6_addr addr; - if (ifp->prefix_len == 127) /* RFC 6164 */ - return; ipv6_addr_prefix(&addr, &ifp->addr, ifp->prefix_len); if (ipv6_addr_any(&addr)) return; diff --git a/trunk/net/ipv6/af_inet6.c b/trunk/net/ipv6/af_inet6.c index 3b5669a2582d..d450a2f9fc06 100644 --- a/trunk/net/ipv6/af_inet6.c +++ b/trunk/net/ipv6/af_inet6.c @@ -274,7 +274,7 @@ int inet6_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) return -EINVAL; if (addr->sin6_family != AF_INET6) - return -EAFNOSUPPORT; + return -EINVAL; addr_type = ipv6_addr_type(&addr->sin6_addr); if ((addr_type & IPV6_ADDR_MULTICAST) && sock->type == SOCK_STREAM) diff --git a/trunk/net/ipv6/ip6_output.c b/trunk/net/ipv6/ip6_output.c index f0f144cac0bd..9d4b165837d6 100644 --- a/trunk/net/ipv6/ip6_output.c +++ b/trunk/net/ipv6/ip6_output.c @@ -100,7 +100,6 @@ static int ip6_finish_output2(struct sk_buff *skb) { struct dst_entry *dst = skb_dst(skb); struct net_device *dev = dst->dev; - struct neighbour *neigh; skb->protocol = htons(ETH_P_IPV6); skb->dev = dev; @@ -135,14 +134,11 @@ static int ip6_finish_output2(struct sk_buff *skb) skb->len); } - neigh = dst->neighbour; - if (neigh) { - struct hh_cache *hh = &neigh->hh; - if (hh->hh_len) - return neigh_hh_output(hh, skb); - else - return dst->neighbour->output(skb); - } + if (dst->hh) + return neigh_hh_output(dst->hh, skb); + else if (dst->neighbour) + return dst->neighbour->output(skb); + IP6_INC_STATS_BH(dev_net(dst->dev), ip6_dst_idev(dst), IPSTATS_MIB_OUTNOROUTES); kfree_skb(skb); diff --git a/trunk/net/ipv6/raw.c b/trunk/net/ipv6/raw.c index 6a79f3081bdb..cc7313b8f7ea 100644 --- a/trunk/net/ipv6/raw.c +++ b/trunk/net/ipv6/raw.c @@ -959,54 +959,57 @@ static int do_rawv6_setsockopt(struct sock *sk, int level, int optname, return -EFAULT; switch (optname) { - case IPV6_CHECKSUM: - if (inet_sk(sk)->inet_num == IPPROTO_ICMPV6 && - level == IPPROTO_IPV6) { - /* - * RFC3542 tells that IPV6_CHECKSUM socket - * option in the IPPROTO_IPV6 level is not - * allowed on ICMPv6 sockets. - * If you want to set it, use IPPROTO_RAW - * level IPV6_CHECKSUM socket option - * (Linux extension). - */ - return -EINVAL; - } + case IPV6_CHECKSUM: + if (inet_sk(sk)->inet_num == IPPROTO_ICMPV6 && + level == IPPROTO_IPV6) { + /* + * RFC3542 tells that IPV6_CHECKSUM socket + * option in the IPPROTO_IPV6 level is not + * allowed on ICMPv6 sockets. + * If you want to set it, use IPPROTO_RAW + * level IPV6_CHECKSUM socket option + * (Linux extension). + */ + return -EINVAL; + } - /* You may get strange result with a positive odd offset; - RFC2292bis agrees with me. */ - if (val > 0 && (val&1)) - return -EINVAL; - if (val < 0) { - rp->checksum = 0; - } else { - rp->checksum = 1; - rp->offset = val; - } + /* You may get strange result with a positive odd offset; + RFC2292bis agrees with me. */ + if (val > 0 && (val&1)) + return -EINVAL; + if (val < 0) { + rp->checksum = 0; + } else { + rp->checksum = 1; + rp->offset = val; + } - return 0; + return 0; + break; - default: - return -ENOPROTOOPT; + default: + return -ENOPROTOOPT; } } static int rawv6_setsockopt(struct sock *sk, int level, int optname, char __user *optval, unsigned int optlen) { - switch (level) { - case SOL_RAW: - break; - - case SOL_ICMPV6: - if (inet_sk(sk)->inet_num != IPPROTO_ICMPV6) - return -EOPNOTSUPP; - return rawv6_seticmpfilter(sk, level, optname, optval, optlen); - case SOL_IPV6: - if (optname == IPV6_CHECKSUM) + switch(level) { + case SOL_RAW: break; - default: - return ipv6_setsockopt(sk, level, optname, optval, optlen); + + case SOL_ICMPV6: + if (inet_sk(sk)->inet_num != IPPROTO_ICMPV6) + return -EOPNOTSUPP; + return rawv6_seticmpfilter(sk, level, optname, optval, + optlen); + case SOL_IPV6: + if (optname == IPV6_CHECKSUM) + break; + default: + return ipv6_setsockopt(sk, level, optname, optval, + optlen); } return do_rawv6_setsockopt(sk, level, optname, optval, optlen); @@ -1072,19 +1075,21 @@ static int do_rawv6_getsockopt(struct sock *sk, int level, int optname, static int rawv6_getsockopt(struct sock *sk, int level, int optname, char __user *optval, int __user *optlen) { - switch (level) { - case SOL_RAW: - break; - - case SOL_ICMPV6: - if (inet_sk(sk)->inet_num != IPPROTO_ICMPV6) - return -EOPNOTSUPP; - return rawv6_geticmpfilter(sk, level, optname, optval, optlen); - case SOL_IPV6: - if (optname == IPV6_CHECKSUM) + switch(level) { + case SOL_RAW: break; - default: - return ipv6_getsockopt(sk, level, optname, optval, optlen); + + case SOL_ICMPV6: + if (inet_sk(sk)->inet_num != IPPROTO_ICMPV6) + return -EOPNOTSUPP; + return rawv6_geticmpfilter(sk, level, optname, optval, + optlen); + case SOL_IPV6: + if (optname == IPV6_CHECKSUM) + break; + default: + return ipv6_getsockopt(sk, level, optname, optval, + optlen); } return do_rawv6_getsockopt(sk, level, optname, optval, optlen); @@ -1114,29 +1119,31 @@ static int compat_rawv6_getsockopt(struct sock *sk, int level, int optname, static int rawv6_ioctl(struct sock *sk, int cmd, unsigned long arg) { - switch (cmd) { - case SIOCOUTQ: { - int amount = sk_wmem_alloc_get(sk); + switch(cmd) { + case SIOCOUTQ: + { + int amount = sk_wmem_alloc_get(sk); - return put_user(amount, (int __user *)arg); - } - case SIOCINQ: { - struct sk_buff *skb; - int amount = 0; - - spin_lock_bh(&sk->sk_receive_queue.lock); - skb = skb_peek(&sk->sk_receive_queue); - if (skb != NULL) - amount = skb->tail - skb->transport_header; - spin_unlock_bh(&sk->sk_receive_queue.lock); - return put_user(amount, (int __user *)arg); - } + return put_user(amount, (int __user *)arg); + } + case SIOCINQ: + { + struct sk_buff *skb; + int amount = 0; + + spin_lock_bh(&sk->sk_receive_queue.lock); + skb = skb_peek(&sk->sk_receive_queue); + if (skb != NULL) + amount = skb->tail - skb->transport_header; + spin_unlock_bh(&sk->sk_receive_queue.lock); + return put_user(amount, (int __user *)arg); + } - default: + default: #ifdef CONFIG_IPV6_MROUTE - return ip6mr_ioctl(sk, cmd, (void __user *)arg); + return ip6mr_ioctl(sk, cmd, (void __user *)arg); #else - return -ENOIOCTLCMD; + return -ENOIOCTLCMD; #endif } } diff --git a/trunk/net/ipv6/route.c b/trunk/net/ipv6/route.c index f032d7700943..216ff31a0cc9 100644 --- a/trunk/net/ipv6/route.c +++ b/trunk/net/ipv6/route.c @@ -228,10 +228,9 @@ static struct rt6_info ip6_blk_hole_entry_template = { /* allocate dst with ip6_dst_ops */ static inline struct rt6_info *ip6_dst_alloc(struct dst_ops *ops, - struct net_device *dev, - int flags) + struct net_device *dev) { - struct rt6_info *rt = dst_alloc(ops, dev, 0, 0, flags); + struct rt6_info *rt = dst_alloc(ops, dev, 0, 0, 0); memset(&rt->rt6i_table, 0, sizeof(*rt) - sizeof(struct dst_entry)); @@ -1043,7 +1042,7 @@ struct dst_entry *icmp6_dst_alloc(struct net_device *dev, if (unlikely(idev == NULL)) return NULL; - rt = ip6_dst_alloc(&net->ipv6.ip6_dst_ops, dev, 0); + rt = ip6_dst_alloc(&net->ipv6.ip6_dst_ops, dev); if (unlikely(rt == NULL)) { in6_dev_put(idev); goto out; @@ -1063,6 +1062,14 @@ struct dst_entry *icmp6_dst_alloc(struct net_device *dev, dst_metric_set(&rt->dst, RTAX_HOPLIMIT, 255); rt->dst.output = ip6_output; +#if 0 /* there's no chance to use these for ndisc */ + rt->dst.flags = ipv6_addr_type(addr) & IPV6_ADDR_UNICAST + ? DST_HOST + : 0; + ipv6_addr_copy(&rt->rt6i_dst.addr, addr); + rt->rt6i_dst.plen = 128; +#endif + spin_lock_bh(&icmp6_dst_lock); rt->dst.next = icmp6_dst_gc_list; icmp6_dst_gc_list = &rt->dst; @@ -1207,7 +1214,7 @@ int ip6_route_add(struct fib6_config *cfg) goto out; } - rt = ip6_dst_alloc(&net->ipv6.ip6_dst_ops, NULL, DST_NOCOUNT); + rt = ip6_dst_alloc(&net->ipv6.ip6_dst_ops, NULL); if (rt == NULL) { err = -ENOMEM; @@ -1237,7 +1244,7 @@ int ip6_route_add(struct fib6_config *cfg) ipv6_addr_prefix(&rt->rt6i_dst.addr, &cfg->fc_dst, cfg->fc_dst_len); rt->rt6i_dst.plen = cfg->fc_dst_len; if (rt->rt6i_dst.plen == 128) - rt->dst.flags |= DST_HOST; + rt->dst.flags = DST_HOST; #ifdef CONFIG_IPV6_SUBTREES ipv6_addr_prefix(&rt->rt6i_src.addr, &cfg->fc_src, cfg->fc_src_len); @@ -1727,7 +1734,7 @@ static struct rt6_info * ip6_rt_copy(struct rt6_info *ort) { struct net *net = dev_net(ort->rt6i_dev); struct rt6_info *rt = ip6_dst_alloc(&net->ipv6.ip6_dst_ops, - ort->dst.dev, 0); + ort->dst.dev); if (rt) { rt->dst.input = ort->dst.input; @@ -2006,7 +2013,7 @@ struct rt6_info *addrconf_dst_alloc(struct inet6_dev *idev, { struct net *net = dev_net(idev->dev); struct rt6_info *rt = ip6_dst_alloc(&net->ipv6.ip6_dst_ops, - net->loopback_dev, 0); + net->loopback_dev); struct neighbour *neigh; if (rt == NULL) { @@ -2018,7 +2025,7 @@ struct rt6_info *addrconf_dst_alloc(struct inet6_dev *idev, in6_dev_hold(idev); - rt->dst.flags |= DST_HOST; + rt->dst.flags = DST_HOST; rt->dst.input = ip6_input; rt->dst.output = ip6_output; rt->rt6i_idev = idev; diff --git a/trunk/net/ipv6/udp.c b/trunk/net/ipv6/udp.c index 328985c40883..41f8c9c08dba 100644 --- a/trunk/net/ipv6/udp.c +++ b/trunk/net/ipv6/udp.c @@ -453,11 +453,8 @@ int udpv6_recvmsg(struct kiocb *iocb, struct sock *sk, } unlock_sock_fast(sk, slow); - if (noblock) + if (flags & MSG_DONTWAIT) return -EAGAIN; - - /* starting over for a new packet */ - msg->msg_flags &= ~MSG_TRUNC; goto try_again; } diff --git a/trunk/net/lapb/lapb_iface.c b/trunk/net/lapb/lapb_iface.c index 956b7e47dc52..d5d8d555c410 100644 --- a/trunk/net/lapb/lapb_iface.c +++ b/trunk/net/lapb/lapb_iface.c @@ -300,26 +300,26 @@ int lapb_disconnect_request(struct net_device *dev) goto out; switch (lapb->state) { - case LAPB_STATE_0: - rc = LAPB_NOTCONNECTED; - goto out_put; + case LAPB_STATE_0: + rc = LAPB_NOTCONNECTED; + goto out_put; - case LAPB_STATE_1: + case LAPB_STATE_1: #if LAPB_DEBUG > 1 - printk(KERN_DEBUG "lapb: (%p) S1 TX DISC(1)\n", lapb->dev); + printk(KERN_DEBUG "lapb: (%p) S1 TX DISC(1)\n", lapb->dev); #endif #if LAPB_DEBUG > 0 - printk(KERN_DEBUG "lapb: (%p) S1 -> S0\n", lapb->dev); + printk(KERN_DEBUG "lapb: (%p) S1 -> S0\n", lapb->dev); #endif - lapb_send_control(lapb, LAPB_DISC, LAPB_POLLON, LAPB_COMMAND); - lapb->state = LAPB_STATE_0; - lapb_start_t1timer(lapb); - rc = LAPB_NOTCONNECTED; - goto out_put; - - case LAPB_STATE_2: - rc = LAPB_OK; - goto out_put; + lapb_send_control(lapb, LAPB_DISC, LAPB_POLLON, LAPB_COMMAND); + lapb->state = LAPB_STATE_0; + lapb_start_t1timer(lapb); + rc = LAPB_NOTCONNECTED; + goto out_put; + + case LAPB_STATE_2: + rc = LAPB_OK; + goto out_put; } lapb_clear_queues(lapb); diff --git a/trunk/net/lapb/lapb_in.c b/trunk/net/lapb/lapb_in.c index 2ec1af5c36cc..21904a002449 100644 --- a/trunk/net/lapb/lapb_in.c +++ b/trunk/net/lapb/lapb_in.c @@ -44,86 +44,89 @@ static void lapb_state0_machine(struct lapb_cb *lapb, struct sk_buff *skb, struct lapb_frame *frame) { switch (frame->type) { - case LAPB_SABM: + case LAPB_SABM: #if LAPB_DEBUG > 1 - printk(KERN_DEBUG "lapb: (%p) S0 RX SABM(%d)\n", - lapb->dev, frame->pf); + printk(KERN_DEBUG "lapb: (%p) S0 RX SABM(%d)\n", + lapb->dev, frame->pf); #endif - if (lapb->mode & LAPB_EXTENDED) { + if (lapb->mode & LAPB_EXTENDED) { #if LAPB_DEBUG > 1 - printk(KERN_DEBUG "lapb: (%p) S0 TX DM(%d)\n", - lapb->dev, frame->pf); + printk(KERN_DEBUG "lapb: (%p) S0 TX DM(%d)\n", + lapb->dev, frame->pf); #endif - lapb_send_control(lapb, LAPB_DM, frame->pf, - LAPB_RESPONSE); - } else { + lapb_send_control(lapb, LAPB_DM, frame->pf, + LAPB_RESPONSE); + } else { #if LAPB_DEBUG > 1 - printk(KERN_DEBUG "lapb: (%p) S0 TX UA(%d)\n", - lapb->dev, frame->pf); + printk(KERN_DEBUG "lapb: (%p) S0 TX UA(%d)\n", + lapb->dev, frame->pf); #endif #if LAPB_DEBUG > 0 - printk(KERN_DEBUG "lapb: (%p) S0 -> S3\n", lapb->dev); + printk(KERN_DEBUG "lapb: (%p) S0 -> S3\n", + lapb->dev); #endif - lapb_send_control(lapb, LAPB_UA, frame->pf, - LAPB_RESPONSE); - lapb_stop_t1timer(lapb); - lapb_stop_t2timer(lapb); - lapb->state = LAPB_STATE_3; - lapb->condition = 0x00; - lapb->n2count = 0; - lapb->vs = 0; - lapb->vr = 0; - lapb->va = 0; - lapb_connect_indication(lapb, LAPB_OK); - } - break; + lapb_send_control(lapb, LAPB_UA, frame->pf, + LAPB_RESPONSE); + lapb_stop_t1timer(lapb); + lapb_stop_t2timer(lapb); + lapb->state = LAPB_STATE_3; + lapb->condition = 0x00; + lapb->n2count = 0; + lapb->vs = 0; + lapb->vr = 0; + lapb->va = 0; + lapb_connect_indication(lapb, LAPB_OK); + } + break; - case LAPB_SABME: + case LAPB_SABME: #if LAPB_DEBUG > 1 - printk(KERN_DEBUG "lapb: (%p) S0 RX SABME(%d)\n", - lapb->dev, frame->pf); + printk(KERN_DEBUG "lapb: (%p) S0 RX SABME(%d)\n", + lapb->dev, frame->pf); #endif - if (lapb->mode & LAPB_EXTENDED) { + if (lapb->mode & LAPB_EXTENDED) { #if LAPB_DEBUG > 1 - printk(KERN_DEBUG "lapb: (%p) S0 TX UA(%d)\n", - lapb->dev, frame->pf); + printk(KERN_DEBUG "lapb: (%p) S0 TX UA(%d)\n", + lapb->dev, frame->pf); #endif #if LAPB_DEBUG > 0 - printk(KERN_DEBUG "lapb: (%p) S0 -> S3\n", lapb->dev); + printk(KERN_DEBUG "lapb: (%p) S0 -> S3\n", + lapb->dev); #endif - lapb_send_control(lapb, LAPB_UA, frame->pf, - LAPB_RESPONSE); - lapb_stop_t1timer(lapb); - lapb_stop_t2timer(lapb); - lapb->state = LAPB_STATE_3; - lapb->condition = 0x00; - lapb->n2count = 0; - lapb->vs = 0; - lapb->vr = 0; - lapb->va = 0; - lapb_connect_indication(lapb, LAPB_OK); - } else { -#if LAPB_DEBUG > 1 - printk(KERN_DEBUG "lapb: (%p) S0 TX DM(%d)\n", - lapb->dev, frame->pf); + lapb_send_control(lapb, LAPB_UA, frame->pf, + LAPB_RESPONSE); + lapb_stop_t1timer(lapb); + lapb_stop_t2timer(lapb); + lapb->state = LAPB_STATE_3; + lapb->condition = 0x00; + lapb->n2count = 0; + lapb->vs = 0; + lapb->vr = 0; + lapb->va = 0; + lapb_connect_indication(lapb, LAPB_OK); + } else { +#if LAPB_DEBUG > 1 + printk(KERN_DEBUG "lapb: (%p) S0 TX DM(%d)\n", + lapb->dev, frame->pf); #endif - lapb_send_control(lapb, LAPB_DM, frame->pf, - LAPB_RESPONSE); - } - break; + lapb_send_control(lapb, LAPB_DM, frame->pf, + LAPB_RESPONSE); + } + break; - case LAPB_DISC: + case LAPB_DISC: #if LAPB_DEBUG > 1 - printk(KERN_DEBUG "lapb: (%p) S0 RX DISC(%d)\n", - lapb->dev, frame->pf); - printk(KERN_DEBUG "lapb: (%p) S0 TX UA(%d)\n", - lapb->dev, frame->pf); + printk(KERN_DEBUG "lapb: (%p) S0 RX DISC(%d)\n", + lapb->dev, frame->pf); + printk(KERN_DEBUG "lapb: (%p) S0 TX UA(%d)\n", + lapb->dev, frame->pf); #endif - lapb_send_control(lapb, LAPB_UA, frame->pf, LAPB_RESPONSE); - break; + lapb_send_control(lapb, LAPB_UA, frame->pf, + LAPB_RESPONSE); + break; - default: - break; + default: + break; } kfree_skb(skb); @@ -137,97 +140,100 @@ static void lapb_state1_machine(struct lapb_cb *lapb, struct sk_buff *skb, struct lapb_frame *frame) { switch (frame->type) { - case LAPB_SABM: + case LAPB_SABM: #if LAPB_DEBUG > 1 - printk(KERN_DEBUG "lapb: (%p) S1 RX SABM(%d)\n", - lapb->dev, frame->pf); + printk(KERN_DEBUG "lapb: (%p) S1 RX SABM(%d)\n", + lapb->dev, frame->pf); #endif - if (lapb->mode & LAPB_EXTENDED) { + if (lapb->mode & LAPB_EXTENDED) { #if LAPB_DEBUG > 1 - printk(KERN_DEBUG "lapb: (%p) S1 TX DM(%d)\n", - lapb->dev, frame->pf); + printk(KERN_DEBUG "lapb: (%p) S1 TX DM(%d)\n", + lapb->dev, frame->pf); #endif - lapb_send_control(lapb, LAPB_DM, frame->pf, - LAPB_RESPONSE); - } else { + lapb_send_control(lapb, LAPB_DM, frame->pf, + LAPB_RESPONSE); + } else { #if LAPB_DEBUG > 1 - printk(KERN_DEBUG "lapb: (%p) S1 TX UA(%d)\n", - lapb->dev, frame->pf); + printk(KERN_DEBUG "lapb: (%p) S1 TX UA(%d)\n", + lapb->dev, frame->pf); #endif - lapb_send_control(lapb, LAPB_UA, frame->pf, - LAPB_RESPONSE); - } - break; + lapb_send_control(lapb, LAPB_UA, frame->pf, + LAPB_RESPONSE); + } + break; - case LAPB_SABME: + case LAPB_SABME: #if LAPB_DEBUG > 1 - printk(KERN_DEBUG "lapb: (%p) S1 RX SABME(%d)\n", - lapb->dev, frame->pf); + printk(KERN_DEBUG "lapb: (%p) S1 RX SABME(%d)\n", + lapb->dev, frame->pf); #endif - if (lapb->mode & LAPB_EXTENDED) { + if (lapb->mode & LAPB_EXTENDED) { #if LAPB_DEBUG > 1 - printk(KERN_DEBUG "lapb: (%p) S1 TX UA(%d)\n", - lapb->dev, frame->pf); + printk(KERN_DEBUG "lapb: (%p) S1 TX UA(%d)\n", + lapb->dev, frame->pf); #endif - lapb_send_control(lapb, LAPB_UA, frame->pf, - LAPB_RESPONSE); - } else { + lapb_send_control(lapb, LAPB_UA, frame->pf, + LAPB_RESPONSE); + } else { +#if LAPB_DEBUG > 1 + printk(KERN_DEBUG "lapb: (%p) S1 TX DM(%d)\n", + lapb->dev, frame->pf); +#endif + lapb_send_control(lapb, LAPB_DM, frame->pf, + LAPB_RESPONSE); + } + break; + + case LAPB_DISC: #if LAPB_DEBUG > 1 + printk(KERN_DEBUG "lapb: (%p) S1 RX DISC(%d)\n", + lapb->dev, frame->pf); printk(KERN_DEBUG "lapb: (%p) S1 TX DM(%d)\n", lapb->dev, frame->pf); #endif lapb_send_control(lapb, LAPB_DM, frame->pf, LAPB_RESPONSE); - } - break; + break; - case LAPB_DISC: + case LAPB_UA: #if LAPB_DEBUG > 1 - printk(KERN_DEBUG "lapb: (%p) S1 RX DISC(%d)\n", - lapb->dev, frame->pf); - printk(KERN_DEBUG "lapb: (%p) S1 TX DM(%d)\n", - lapb->dev, frame->pf); + printk(KERN_DEBUG "lapb: (%p) S1 RX UA(%d)\n", + lapb->dev, frame->pf); #endif - lapb_send_control(lapb, LAPB_DM, frame->pf, LAPB_RESPONSE); - break; + if (frame->pf) { +#if LAPB_DEBUG > 0 + printk(KERN_DEBUG "lapb: (%p) S1 -> S3\n", + lapb->dev); +#endif + lapb_stop_t1timer(lapb); + lapb_stop_t2timer(lapb); + lapb->state = LAPB_STATE_3; + lapb->condition = 0x00; + lapb->n2count = 0; + lapb->vs = 0; + lapb->vr = 0; + lapb->va = 0; + lapb_connect_confirmation(lapb, LAPB_OK); + } + break; - case LAPB_UA: + case LAPB_DM: #if LAPB_DEBUG > 1 - printk(KERN_DEBUG "lapb: (%p) S1 RX UA(%d)\n", - lapb->dev, frame->pf); -#endif - if (frame->pf) { -#if LAPB_DEBUG > 0 - printk(KERN_DEBUG "lapb: (%p) S1 -> S3\n", lapb->dev); + printk(KERN_DEBUG "lapb: (%p) S1 RX DM(%d)\n", + lapb->dev, frame->pf); #endif - lapb_stop_t1timer(lapb); - lapb_stop_t2timer(lapb); - lapb->state = LAPB_STATE_3; - lapb->condition = 0x00; - lapb->n2count = 0; - lapb->vs = 0; - lapb->vr = 0; - lapb->va = 0; - lapb_connect_confirmation(lapb, LAPB_OK); - } - break; - - case LAPB_DM: -#if LAPB_DEBUG > 1 - printk(KERN_DEBUG "lapb: (%p) S1 RX DM(%d)\n", - lapb->dev, frame->pf); -#endif - if (frame->pf) { + if (frame->pf) { #if LAPB_DEBUG > 0 - printk(KERN_DEBUG "lapb: (%p) S1 -> S0\n", lapb->dev); -#endif - lapb_clear_queues(lapb); - lapb->state = LAPB_STATE_0; - lapb_start_t1timer(lapb); - lapb_stop_t2timer(lapb); - lapb_disconnect_indication(lapb, LAPB_REFUSED); - } - break; + printk(KERN_DEBUG "lapb: (%p) S1 -> S0\n", + lapb->dev); +#endif + lapb_clear_queues(lapb); + lapb->state = LAPB_STATE_0; + lapb_start_t1timer(lapb); + lapb_stop_t2timer(lapb); + lapb_disconnect_indication(lapb, LAPB_REFUSED); + } + break; } kfree_skb(skb); @@ -241,73 +247,78 @@ static void lapb_state2_machine(struct lapb_cb *lapb, struct sk_buff *skb, struct lapb_frame *frame) { switch (frame->type) { - case LAPB_SABM: - case LAPB_SABME: + case LAPB_SABM: + case LAPB_SABME: #if LAPB_DEBUG > 1 - printk(KERN_DEBUG "lapb: (%p) S2 RX {SABM,SABME}(%d)\n", - lapb->dev, frame->pf); - printk(KERN_DEBUG "lapb: (%p) S2 TX DM(%d)\n", - lapb->dev, frame->pf); + printk(KERN_DEBUG "lapb: (%p) S2 RX {SABM,SABME}(%d)\n", + lapb->dev, frame->pf); + printk(KERN_DEBUG "lapb: (%p) S2 TX DM(%d)\n", + lapb->dev, frame->pf); #endif - lapb_send_control(lapb, LAPB_DM, frame->pf, LAPB_RESPONSE); - break; + lapb_send_control(lapb, LAPB_DM, frame->pf, + LAPB_RESPONSE); + break; - case LAPB_DISC: + case LAPB_DISC: #if LAPB_DEBUG > 1 - printk(KERN_DEBUG "lapb: (%p) S2 RX DISC(%d)\n", - lapb->dev, frame->pf); - printk(KERN_DEBUG "lapb: (%p) S2 TX UA(%d)\n", - lapb->dev, frame->pf); + printk(KERN_DEBUG "lapb: (%p) S2 RX DISC(%d)\n", + lapb->dev, frame->pf); + printk(KERN_DEBUG "lapb: (%p) S2 TX UA(%d)\n", + lapb->dev, frame->pf); #endif - lapb_send_control(lapb, LAPB_UA, frame->pf, LAPB_RESPONSE); - break; + lapb_send_control(lapb, LAPB_UA, frame->pf, + LAPB_RESPONSE); + break; - case LAPB_UA: + case LAPB_UA: #if LAPB_DEBUG > 1 - printk(KERN_DEBUG "lapb: (%p) S2 RX UA(%d)\n", - lapb->dev, frame->pf); + printk(KERN_DEBUG "lapb: (%p) S2 RX UA(%d)\n", + lapb->dev, frame->pf); #endif - if (frame->pf) { + if (frame->pf) { #if LAPB_DEBUG > 0 - printk(KERN_DEBUG "lapb: (%p) S2 -> S0\n", lapb->dev); + printk(KERN_DEBUG "lapb: (%p) S2 -> S0\n", + lapb->dev); #endif - lapb->state = LAPB_STATE_0; - lapb_start_t1timer(lapb); - lapb_stop_t2timer(lapb); - lapb_disconnect_confirmation(lapb, LAPB_OK); - } - break; + lapb->state = LAPB_STATE_0; + lapb_start_t1timer(lapb); + lapb_stop_t2timer(lapb); + lapb_disconnect_confirmation(lapb, LAPB_OK); + } + break; - case LAPB_DM: + case LAPB_DM: #if LAPB_DEBUG > 1 - printk(KERN_DEBUG "lapb: (%p) S2 RX DM(%d)\n", - lapb->dev, frame->pf); + printk(KERN_DEBUG "lapb: (%p) S2 RX DM(%d)\n", + lapb->dev, frame->pf); #endif - if (frame->pf) { + if (frame->pf) { #if LAPB_DEBUG > 0 - printk(KERN_DEBUG "lapb: (%p) S2 -> S0\n", lapb->dev); -#endif - lapb->state = LAPB_STATE_0; - lapb_start_t1timer(lapb); - lapb_stop_t2timer(lapb); - lapb_disconnect_confirmation(lapb, LAPB_NOTCONNECTED); - } - break; + printk(KERN_DEBUG "lapb: (%p) S2 -> S0\n", + lapb->dev); +#endif + lapb->state = LAPB_STATE_0; + lapb_start_t1timer(lapb); + lapb_stop_t2timer(lapb); + lapb_disconnect_confirmation(lapb, + LAPB_NOTCONNECTED); + } + break; - case LAPB_I: - case LAPB_REJ: - case LAPB_RNR: - case LAPB_RR: + case LAPB_I: + case LAPB_REJ: + case LAPB_RNR: + case LAPB_RR: #if LAPB_DEBUG > 1 - printk(KERN_DEBUG "lapb: (%p) S2 RX {I,REJ,RNR,RR}(%d)\n", - lapb->dev, frame->pf); - printk(KERN_DEBUG "lapb: (%p) S2 RX DM(%d)\n", - lapb->dev, frame->pf); + printk(KERN_DEBUG "lapb: (%p) S2 RX {I,REJ,RNR,RR}" + "(%d)\n", lapb->dev, frame->pf); + printk(KERN_DEBUG "lapb: (%p) S2 RX DM(%d)\n", + lapb->dev, frame->pf); #endif - if (frame->pf) - lapb_send_control(lapb, LAPB_DM, frame->pf, - LAPB_RESPONSE); - break; + if (frame->pf) + lapb_send_control(lapb, LAPB_DM, frame->pf, + LAPB_RESPONSE); + break; } kfree_skb(skb); @@ -325,267 +336,277 @@ static void lapb_state3_machine(struct lapb_cb *lapb, struct sk_buff *skb, LAPB_SMODULUS; switch (frame->type) { - case LAPB_SABM: + case LAPB_SABM: #if LAPB_DEBUG > 1 - printk(KERN_DEBUG "lapb: (%p) S3 RX SABM(%d)\n", - lapb->dev, frame->pf); + printk(KERN_DEBUG "lapb: (%p) S3 RX SABM(%d)\n", + lapb->dev, frame->pf); #endif - if (lapb->mode & LAPB_EXTENDED) { + if (lapb->mode & LAPB_EXTENDED) { #if LAPB_DEBUG > 1 - printk(KERN_DEBUG "lapb: (%p) S3 TX DM(%d)\n", - lapb->dev, frame->pf); + printk(KERN_DEBUG "lapb: (%p) S3 TX DM(%d)\n", + lapb->dev, frame->pf); #endif - lapb_send_control(lapb, LAPB_DM, frame->pf, - LAPB_RESPONSE); - } else { + lapb_send_control(lapb, LAPB_DM, frame->pf, + LAPB_RESPONSE); + } else { #if LAPB_DEBUG > 1 - printk(KERN_DEBUG "lapb: (%p) S3 TX UA(%d)\n", - lapb->dev, frame->pf); + printk(KERN_DEBUG "lapb: (%p) S3 TX UA(%d)\n", + lapb->dev, frame->pf); #endif - lapb_send_control(lapb, LAPB_UA, frame->pf, - LAPB_RESPONSE); - lapb_stop_t1timer(lapb); - lapb_stop_t2timer(lapb); - lapb->condition = 0x00; - lapb->n2count = 0; - lapb->vs = 0; - lapb->vr = 0; - lapb->va = 0; - lapb_requeue_frames(lapb); - } - break; + lapb_send_control(lapb, LAPB_UA, frame->pf, + LAPB_RESPONSE); + lapb_stop_t1timer(lapb); + lapb_stop_t2timer(lapb); + lapb->condition = 0x00; + lapb->n2count = 0; + lapb->vs = 0; + lapb->vr = 0; + lapb->va = 0; + lapb_requeue_frames(lapb); + } + break; - case LAPB_SABME: + case LAPB_SABME: #if LAPB_DEBUG > 1 - printk(KERN_DEBUG "lapb: (%p) S3 RX SABME(%d)\n", - lapb->dev, frame->pf); + printk(KERN_DEBUG "lapb: (%p) S3 RX SABME(%d)\n", + lapb->dev, frame->pf); #endif - if (lapb->mode & LAPB_EXTENDED) { + if (lapb->mode & LAPB_EXTENDED) { #if LAPB_DEBUG > 1 - printk(KERN_DEBUG "lapb: (%p) S3 TX UA(%d)\n", - lapb->dev, frame->pf); + printk(KERN_DEBUG "lapb: (%p) S3 TX UA(%d)\n", + lapb->dev, frame->pf); #endif - lapb_send_control(lapb, LAPB_UA, frame->pf, - LAPB_RESPONSE); - lapb_stop_t1timer(lapb); - lapb_stop_t2timer(lapb); - lapb->condition = 0x00; - lapb->n2count = 0; - lapb->vs = 0; - lapb->vr = 0; - lapb->va = 0; - lapb_requeue_frames(lapb); - } else { + lapb_send_control(lapb, LAPB_UA, frame->pf, + LAPB_RESPONSE); + lapb_stop_t1timer(lapb); + lapb_stop_t2timer(lapb); + lapb->condition = 0x00; + lapb->n2count = 0; + lapb->vs = 0; + lapb->vr = 0; + lapb->va = 0; + lapb_requeue_frames(lapb); + } else { #if LAPB_DEBUG > 1 - printk(KERN_DEBUG "lapb: (%p) S3 TX DM(%d)\n", - lapb->dev, frame->pf); + printk(KERN_DEBUG "lapb: (%p) S3 TX DM(%d)\n", + lapb->dev, frame->pf); #endif - lapb_send_control(lapb, LAPB_DM, frame->pf, - LAPB_RESPONSE); - } - break; + lapb_send_control(lapb, LAPB_DM, frame->pf, + LAPB_RESPONSE); + } + break; - case LAPB_DISC: + case LAPB_DISC: #if LAPB_DEBUG > 1 - printk(KERN_DEBUG "lapb: (%p) S3 RX DISC(%d)\n", - lapb->dev, frame->pf); + printk(KERN_DEBUG "lapb: (%p) S3 RX DISC(%d)\n", + lapb->dev, frame->pf); #endif #if LAPB_DEBUG > 0 - printk(KERN_DEBUG "lapb: (%p) S3 -> S0\n", lapb->dev); + printk(KERN_DEBUG "lapb: (%p) S3 -> S0\n", + lapb->dev); #endif - lapb_clear_queues(lapb); - lapb_send_control(lapb, LAPB_UA, frame->pf, LAPB_RESPONSE); - lapb_start_t1timer(lapb); - lapb_stop_t2timer(lapb); - lapb->state = LAPB_STATE_0; - lapb_disconnect_indication(lapb, LAPB_OK); - break; + lapb_clear_queues(lapb); + lapb_send_control(lapb, LAPB_UA, frame->pf, + LAPB_RESPONSE); + lapb_start_t1timer(lapb); + lapb_stop_t2timer(lapb); + lapb->state = LAPB_STATE_0; + lapb_disconnect_indication(lapb, LAPB_OK); + break; - case LAPB_DM: + case LAPB_DM: #if LAPB_DEBUG > 1 - printk(KERN_DEBUG "lapb: (%p) S3 RX DM(%d)\n", - lapb->dev, frame->pf); + printk(KERN_DEBUG "lapb: (%p) S3 RX DM(%d)\n", + lapb->dev, frame->pf); #endif #if LAPB_DEBUG > 0 - printk(KERN_DEBUG "lapb: (%p) S3 -> S0\n", lapb->dev); + printk(KERN_DEBUG "lapb: (%p) S3 -> S0\n", + lapb->dev); #endif - lapb_clear_queues(lapb); - lapb->state = LAPB_STATE_0; - lapb_start_t1timer(lapb); - lapb_stop_t2timer(lapb); - lapb_disconnect_indication(lapb, LAPB_NOTCONNECTED); - break; + lapb_clear_queues(lapb); + lapb->state = LAPB_STATE_0; + lapb_start_t1timer(lapb); + lapb_stop_t2timer(lapb); + lapb_disconnect_indication(lapb, LAPB_NOTCONNECTED); + break; - case LAPB_RNR: + case LAPB_RNR: #if LAPB_DEBUG > 1 - printk(KERN_DEBUG "lapb: (%p) S3 RX RNR(%d) R%d\n", - lapb->dev, frame->pf, frame->nr); + printk(KERN_DEBUG "lapb: (%p) S3 RX RNR(%d) R%d\n", + lapb->dev, frame->pf, frame->nr); #endif - lapb->condition |= LAPB_PEER_RX_BUSY_CONDITION; - lapb_check_need_response(lapb, frame->cr, frame->pf); - if (lapb_validate_nr(lapb, frame->nr)) { - lapb_check_iframes_acked(lapb, frame->nr); - } else { - lapb->frmr_data = *frame; - lapb->frmr_type = LAPB_FRMR_Z; - lapb_transmit_frmr(lapb); + lapb->condition |= LAPB_PEER_RX_BUSY_CONDITION; + lapb_check_need_response(lapb, frame->cr, frame->pf); + if (lapb_validate_nr(lapb, frame->nr)) { + lapb_check_iframes_acked(lapb, frame->nr); + } else { + lapb->frmr_data = *frame; + lapb->frmr_type = LAPB_FRMR_Z; + lapb_transmit_frmr(lapb); #if LAPB_DEBUG > 0 - printk(KERN_DEBUG "lapb: (%p) S3 -> S4\n", lapb->dev); + printk(KERN_DEBUG "lapb: (%p) S3 -> S4\n", + lapb->dev); #endif - lapb_start_t1timer(lapb); - lapb_stop_t2timer(lapb); - lapb->state = LAPB_STATE_4; - lapb->n2count = 0; - } - break; + lapb_start_t1timer(lapb); + lapb_stop_t2timer(lapb); + lapb->state = LAPB_STATE_4; + lapb->n2count = 0; + } + break; - case LAPB_RR: + case LAPB_RR: #if LAPB_DEBUG > 1 - printk(KERN_DEBUG "lapb: (%p) S3 RX RR(%d) R%d\n", - lapb->dev, frame->pf, frame->nr); + printk(KERN_DEBUG "lapb: (%p) S3 RX RR(%d) R%d\n", + lapb->dev, frame->pf, frame->nr); #endif - lapb->condition &= ~LAPB_PEER_RX_BUSY_CONDITION; - lapb_check_need_response(lapb, frame->cr, frame->pf); - if (lapb_validate_nr(lapb, frame->nr)) { - lapb_check_iframes_acked(lapb, frame->nr); - } else { - lapb->frmr_data = *frame; - lapb->frmr_type = LAPB_FRMR_Z; - lapb_transmit_frmr(lapb); + lapb->condition &= ~LAPB_PEER_RX_BUSY_CONDITION; + lapb_check_need_response(lapb, frame->cr, frame->pf); + if (lapb_validate_nr(lapb, frame->nr)) { + lapb_check_iframes_acked(lapb, frame->nr); + } else { + lapb->frmr_data = *frame; + lapb->frmr_type = LAPB_FRMR_Z; + lapb_transmit_frmr(lapb); #if LAPB_DEBUG > 0 - printk(KERN_DEBUG "lapb: (%p) S3 -> S4\n", lapb->dev); + printk(KERN_DEBUG "lapb: (%p) S3 -> S4\n", + lapb->dev); #endif - lapb_start_t1timer(lapb); - lapb_stop_t2timer(lapb); - lapb->state = LAPB_STATE_4; - lapb->n2count = 0; - } - break; + lapb_start_t1timer(lapb); + lapb_stop_t2timer(lapb); + lapb->state = LAPB_STATE_4; + lapb->n2count = 0; + } + break; - case LAPB_REJ: + case LAPB_REJ: #if LAPB_DEBUG > 1 - printk(KERN_DEBUG "lapb: (%p) S3 RX REJ(%d) R%d\n", - lapb->dev, frame->pf, frame->nr); + printk(KERN_DEBUG "lapb: (%p) S3 RX REJ(%d) R%d\n", + lapb->dev, frame->pf, frame->nr); #endif - lapb->condition &= ~LAPB_PEER_RX_BUSY_CONDITION; - lapb_check_need_response(lapb, frame->cr, frame->pf); - if (lapb_validate_nr(lapb, frame->nr)) { - lapb_frames_acked(lapb, frame->nr); - lapb_stop_t1timer(lapb); - lapb->n2count = 0; - lapb_requeue_frames(lapb); - } else { - lapb->frmr_data = *frame; - lapb->frmr_type = LAPB_FRMR_Z; - lapb_transmit_frmr(lapb); + lapb->condition &= ~LAPB_PEER_RX_BUSY_CONDITION; + lapb_check_need_response(lapb, frame->cr, frame->pf); + if (lapb_validate_nr(lapb, frame->nr)) { + lapb_frames_acked(lapb, frame->nr); + lapb_stop_t1timer(lapb); + lapb->n2count = 0; + lapb_requeue_frames(lapb); + } else { + lapb->frmr_data = *frame; + lapb->frmr_type = LAPB_FRMR_Z; + lapb_transmit_frmr(lapb); #if LAPB_DEBUG > 0 - printk(KERN_DEBUG "lapb: (%p) S3 -> S4\n", lapb->dev); + printk(KERN_DEBUG "lapb: (%p) S3 -> S4\n", + lapb->dev); #endif - lapb_start_t1timer(lapb); - lapb_stop_t2timer(lapb); - lapb->state = LAPB_STATE_4; - lapb->n2count = 0; - } - break; + lapb_start_t1timer(lapb); + lapb_stop_t2timer(lapb); + lapb->state = LAPB_STATE_4; + lapb->n2count = 0; + } + break; - case LAPB_I: + case LAPB_I: #if LAPB_DEBUG > 1 - printk(KERN_DEBUG "lapb: (%p) S3 RX I(%d) S%d R%d\n", - lapb->dev, frame->pf, frame->ns, frame->nr); + printk(KERN_DEBUG "lapb: (%p) S3 RX I(%d) S%d R%d\n", + lapb->dev, frame->pf, frame->ns, frame->nr); #endif - if (!lapb_validate_nr(lapb, frame->nr)) { - lapb->frmr_data = *frame; - lapb->frmr_type = LAPB_FRMR_Z; - lapb_transmit_frmr(lapb); + if (!lapb_validate_nr(lapb, frame->nr)) { + lapb->frmr_data = *frame; + lapb->frmr_type = LAPB_FRMR_Z; + lapb_transmit_frmr(lapb); #if LAPB_DEBUG > 0 - printk(KERN_DEBUG "lapb: (%p) S3 -> S4\n", lapb->dev); + printk(KERN_DEBUG "lapb: (%p) S3 -> S4\n", + lapb->dev); #endif - lapb_start_t1timer(lapb); - lapb_stop_t2timer(lapb); - lapb->state = LAPB_STATE_4; - lapb->n2count = 0; - break; - } - if (lapb->condition & LAPB_PEER_RX_BUSY_CONDITION) - lapb_frames_acked(lapb, frame->nr); - else - lapb_check_iframes_acked(lapb, frame->nr); - - if (frame->ns == lapb->vr) { - int cn; - cn = lapb_data_indication(lapb, skb); - queued = 1; - /* - * If upper layer has dropped the frame, we - * basically ignore any further protocol - * processing. This will cause the peer - * to re-transmit the frame later like - * a frame lost on the wire. - */ - if (cn == NET_RX_DROP) { - printk(KERN_DEBUG "LAPB: rx congestion\n"); + lapb_start_t1timer(lapb); + lapb_stop_t2timer(lapb); + lapb->state = LAPB_STATE_4; + lapb->n2count = 0; break; } - lapb->vr = (lapb->vr + 1) % modulus; - lapb->condition &= ~LAPB_REJECT_CONDITION; - if (frame->pf) - lapb_enquiry_response(lapb); - else { - if (!(lapb->condition & - LAPB_ACK_PENDING_CONDITION)) { - lapb->condition |= LAPB_ACK_PENDING_CONDITION; - lapb_start_t2timer(lapb); + if (lapb->condition & LAPB_PEER_RX_BUSY_CONDITION) + lapb_frames_acked(lapb, frame->nr); + else + lapb_check_iframes_acked(lapb, frame->nr); + + if (frame->ns == lapb->vr) { + int cn; + cn = lapb_data_indication(lapb, skb); + queued = 1; + /* + * If upper layer has dropped the frame, we + * basically ignore any further protocol + * processing. This will cause the peer + * to re-transmit the frame later like + * a frame lost on the wire. + */ + if (cn == NET_RX_DROP) { + printk(KERN_DEBUG + "LAPB: rx congestion\n"); + break; } - } - } else { - if (lapb->condition & LAPB_REJECT_CONDITION) { + lapb->vr = (lapb->vr + 1) % modulus; + lapb->condition &= ~LAPB_REJECT_CONDITION; if (frame->pf) lapb_enquiry_response(lapb); + else { + if (!(lapb->condition & + LAPB_ACK_PENDING_CONDITION)) { + lapb->condition |= LAPB_ACK_PENDING_CONDITION; + lapb_start_t2timer(lapb); + } + } } else { -#if LAPB_DEBUG > 1 - printk(KERN_DEBUG - "lapb: (%p) S3 TX REJ(%d) R%d\n", - lapb->dev, frame->pf, lapb->vr); -#endif - lapb->condition |= LAPB_REJECT_CONDITION; - lapb_send_control(lapb, LAPB_REJ, frame->pf, - LAPB_RESPONSE); - lapb->condition &= ~LAPB_ACK_PENDING_CONDITION; + if (lapb->condition & LAPB_REJECT_CONDITION) { + if (frame->pf) + lapb_enquiry_response(lapb); + } else { +#if LAPB_DEBUG > 1 + printk(KERN_DEBUG + "lapb: (%p) S3 TX REJ(%d) R%d\n", + lapb->dev, frame->pf, lapb->vr); +#endif + lapb->condition |= LAPB_REJECT_CONDITION; + lapb_send_control(lapb, LAPB_REJ, + frame->pf, + LAPB_RESPONSE); + lapb->condition &= ~LAPB_ACK_PENDING_CONDITION; + } } - } - break; + break; - case LAPB_FRMR: + case LAPB_FRMR: #if LAPB_DEBUG > 1 - printk(KERN_DEBUG "lapb: (%p) S3 RX FRMR(%d) %02X " - "%02X %02X %02X %02X\n", lapb->dev, frame->pf, - skb->data[0], skb->data[1], skb->data[2], - skb->data[3], skb->data[4]); + printk(KERN_DEBUG "lapb: (%p) S3 RX FRMR(%d) %02X " + "%02X %02X %02X %02X\n", lapb->dev, frame->pf, + skb->data[0], skb->data[1], skb->data[2], + skb->data[3], skb->data[4]); #endif - lapb_establish_data_link(lapb); + lapb_establish_data_link(lapb); #if LAPB_DEBUG > 0 - printk(KERN_DEBUG "lapb: (%p) S3 -> S1\n", lapb->dev); + printk(KERN_DEBUG "lapb: (%p) S3 -> S1\n", + lapb->dev); #endif - lapb_requeue_frames(lapb); - lapb->state = LAPB_STATE_1; - break; + lapb_requeue_frames(lapb); + lapb->state = LAPB_STATE_1; + break; - case LAPB_ILLEGAL: + case LAPB_ILLEGAL: #if LAPB_DEBUG > 1 - printk(KERN_DEBUG "lapb: (%p) S3 RX ILLEGAL(%d)\n", - lapb->dev, frame->pf); + printk(KERN_DEBUG "lapb: (%p) S3 RX ILLEGAL(%d)\n", + lapb->dev, frame->pf); #endif - lapb->frmr_data = *frame; - lapb->frmr_type = LAPB_FRMR_W; - lapb_transmit_frmr(lapb); + lapb->frmr_data = *frame; + lapb->frmr_type = LAPB_FRMR_W; + lapb_transmit_frmr(lapb); #if LAPB_DEBUG > 0 - printk(KERN_DEBUG "lapb: (%p) S3 -> S4\n", lapb->dev); + printk(KERN_DEBUG "lapb: (%p) S3 -> S4\n", lapb->dev); #endif - lapb_start_t1timer(lapb); - lapb_stop_t2timer(lapb); - lapb->state = LAPB_STATE_4; - lapb->n2count = 0; - break; + lapb_start_t1timer(lapb); + lapb_stop_t2timer(lapb); + lapb->state = LAPB_STATE_4; + lapb->n2count = 0; + break; } if (!queued) @@ -600,73 +621,75 @@ static void lapb_state4_machine(struct lapb_cb *lapb, struct sk_buff *skb, struct lapb_frame *frame) { switch (frame->type) { - case LAPB_SABM: + case LAPB_SABM: #if LAPB_DEBUG > 1 - printk(KERN_DEBUG "lapb: (%p) S4 RX SABM(%d)\n", - lapb->dev, frame->pf); + printk(KERN_DEBUG "lapb: (%p) S4 RX SABM(%d)\n", + lapb->dev, frame->pf); #endif - if (lapb->mode & LAPB_EXTENDED) { + if (lapb->mode & LAPB_EXTENDED) { #if LAPB_DEBUG > 1 - printk(KERN_DEBUG "lapb: (%p) S4 TX DM(%d)\n", - lapb->dev, frame->pf); + printk(KERN_DEBUG "lapb: (%p) S4 TX DM(%d)\n", + lapb->dev, frame->pf); #endif - lapb_send_control(lapb, LAPB_DM, frame->pf, - LAPB_RESPONSE); - } else { + lapb_send_control(lapb, LAPB_DM, frame->pf, + LAPB_RESPONSE); + } else { #if LAPB_DEBUG > 1 - printk(KERN_DEBUG "lapb: (%p) S4 TX UA(%d)\n", - lapb->dev, frame->pf); + printk(KERN_DEBUG "lapb: (%p) S4 TX UA(%d)\n", + lapb->dev, frame->pf); #endif #if LAPB_DEBUG > 0 - printk(KERN_DEBUG "lapb: (%p) S4 -> S3\n", lapb->dev); + printk(KERN_DEBUG "lapb: (%p) S4 -> S3\n", + lapb->dev); #endif - lapb_send_control(lapb, LAPB_UA, frame->pf, - LAPB_RESPONSE); - lapb_stop_t1timer(lapb); - lapb_stop_t2timer(lapb); - lapb->state = LAPB_STATE_3; - lapb->condition = 0x00; - lapb->n2count = 0; - lapb->vs = 0; - lapb->vr = 0; - lapb->va = 0; - lapb_connect_indication(lapb, LAPB_OK); - } - break; + lapb_send_control(lapb, LAPB_UA, frame->pf, + LAPB_RESPONSE); + lapb_stop_t1timer(lapb); + lapb_stop_t2timer(lapb); + lapb->state = LAPB_STATE_3; + lapb->condition = 0x00; + lapb->n2count = 0; + lapb->vs = 0; + lapb->vr = 0; + lapb->va = 0; + lapb_connect_indication(lapb, LAPB_OK); + } + break; - case LAPB_SABME: + case LAPB_SABME: #if LAPB_DEBUG > 1 - printk(KERN_DEBUG "lapb: (%p) S4 RX SABME(%d)\n", - lapb->dev, frame->pf); + printk(KERN_DEBUG "lapb: (%p) S4 RX SABME(%d)\n", + lapb->dev, frame->pf); #endif - if (lapb->mode & LAPB_EXTENDED) { + if (lapb->mode & LAPB_EXTENDED) { #if LAPB_DEBUG > 1 - printk(KERN_DEBUG "lapb: (%p) S4 TX UA(%d)\n", - lapb->dev, frame->pf); + printk(KERN_DEBUG "lapb: (%p) S4 TX UA(%d)\n", + lapb->dev, frame->pf); #endif #if LAPB_DEBUG > 0 - printk(KERN_DEBUG "lapb: (%p) S4 -> S3\n", lapb->dev); + printk(KERN_DEBUG "lapb: (%p) S4 -> S3\n", + lapb->dev); #endif - lapb_send_control(lapb, LAPB_UA, frame->pf, - LAPB_RESPONSE); - lapb_stop_t1timer(lapb); - lapb_stop_t2timer(lapb); - lapb->state = LAPB_STATE_3; - lapb->condition = 0x00; - lapb->n2count = 0; - lapb->vs = 0; - lapb->vr = 0; - lapb->va = 0; - lapb_connect_indication(lapb, LAPB_OK); - } else { -#if LAPB_DEBUG > 1 - printk(KERN_DEBUG "lapb: (%p) S4 TX DM(%d)\n", - lapb->dev, frame->pf); + lapb_send_control(lapb, LAPB_UA, frame->pf, + LAPB_RESPONSE); + lapb_stop_t1timer(lapb); + lapb_stop_t2timer(lapb); + lapb->state = LAPB_STATE_3; + lapb->condition = 0x00; + lapb->n2count = 0; + lapb->vs = 0; + lapb->vr = 0; + lapb->va = 0; + lapb_connect_indication(lapb, LAPB_OK); + } else { +#if LAPB_DEBUG > 1 + printk(KERN_DEBUG "lapb: (%p) S4 TX DM(%d)\n", + lapb->dev, frame->pf); #endif - lapb_send_control(lapb, LAPB_DM, frame->pf, - LAPB_RESPONSE); - } - break; + lapb_send_control(lapb, LAPB_DM, frame->pf, + LAPB_RESPONSE); + } + break; } kfree_skb(skb); diff --git a/trunk/net/mac80211/agg-rx.c b/trunk/net/mac80211/agg-rx.c index ebadb9ac9a7e..89b0b2ca6db6 100644 --- a/trunk/net/mac80211/agg-rx.c +++ b/trunk/net/mac80211/agg-rx.c @@ -262,11 +262,7 @@ void ieee80211_process_addba_request(struct ieee80211_local *local, "%pM on tid %u\n", mgmt->sa, tid); #endif /* CONFIG_MAC80211_HT_DEBUG */ - - /* delete existing Rx BA session on the same tid */ - ___ieee80211_stop_rx_ba_session(sta, tid, WLAN_BACK_RECIPIENT, - WLAN_STATUS_UNSPECIFIED_QOS, - false); + goto end; } /* prepare A-MPDU MLME for Rx aggregation */ diff --git a/trunk/net/mac80211/cfg.c b/trunk/net/mac80211/cfg.c index 295ab747663f..6e56c6ee7ccd 100644 --- a/trunk/net/mac80211/cfg.c +++ b/trunk/net/mac80211/cfg.c @@ -674,11 +674,8 @@ static void sta_apply_parameters(struct ieee80211_local *local, if (mask & BIT(NL80211_STA_FLAG_WME)) { sta->flags &= ~WLAN_STA_WME; - sta->sta.wme = false; - if (set & BIT(NL80211_STA_FLAG_WME)) { + if (set & BIT(NL80211_STA_FLAG_WME)) sta->flags |= WLAN_STA_WME; - sta->sta.wme = true; - } } if (mask & BIT(NL80211_STA_FLAG_MFP)) { @@ -2101,21 +2098,6 @@ static void ieee80211_get_ringparam(struct wiphy *wiphy, drv_get_ringparam(local, tx, tx_max, rx, rx_max); } -static int ieee80211_set_rekey_data(struct wiphy *wiphy, - struct net_device *dev, - struct cfg80211_gtk_rekey_data *data) -{ - struct ieee80211_local *local = wiphy_priv(wiphy); - struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); - - if (!local->ops->set_rekey_data) - return -EOPNOTSUPP; - - drv_set_rekey_data(local, sdata, data); - - return 0; -} - struct cfg80211_ops mac80211_config_ops = { .add_virtual_intf = ieee80211_add_iface, .del_virtual_intf = ieee80211_del_iface, @@ -2178,5 +2160,4 @@ struct cfg80211_ops mac80211_config_ops = { .get_antenna = ieee80211_get_antenna, .set_ringparam = ieee80211_set_ringparam, .get_ringparam = ieee80211_get_ringparam, - .set_rekey_data = ieee80211_set_rekey_data, }; diff --git a/trunk/net/mac80211/driver-ops.h b/trunk/net/mac80211/driver-ops.h index edd2dd79c9be..eebf7a67daf7 100644 --- a/trunk/net/mac80211/driver-ops.h +++ b/trunk/net/mac80211/driver-ops.h @@ -218,16 +218,6 @@ static inline int drv_hw_scan(struct ieee80211_local *local, return ret; } -static inline void drv_cancel_hw_scan(struct ieee80211_local *local, - struct ieee80211_sub_if_data *sdata) -{ - might_sleep(); - - trace_drv_cancel_hw_scan(local, sdata); - local->ops->cancel_hw_scan(&local->hw, &sdata->vif); - trace_drv_return_void(local); -} - static inline int drv_sched_scan_start(struct ieee80211_local *local, struct ieee80211_sub_if_data *sdata, @@ -647,14 +637,4 @@ static inline int drv_set_bitrate_mask(struct ieee80211_local *local, return ret; } -static inline void drv_set_rekey_data(struct ieee80211_local *local, - struct ieee80211_sub_if_data *sdata, - struct cfg80211_gtk_rekey_data *data) -{ - trace_drv_set_rekey_data(local, sdata, data); - if (local->ops->set_rekey_data) - local->ops->set_rekey_data(&local->hw, &sdata->vif, data); - trace_drv_return_void(local); -} - #endif /* __MAC80211_DRIVER_OPS */ diff --git a/trunk/net/mac80211/driver-trace.h b/trunk/net/mac80211/driver-trace.h index 31a9dfa81f65..ed9edcbd9aa5 100644 --- a/trunk/net/mac80211/driver-trace.h +++ b/trunk/net/mac80211/driver-trace.h @@ -460,12 +460,6 @@ DEFINE_EVENT(local_sdata_evt, drv_hw_scan, TP_ARGS(local, sdata) ); -DEFINE_EVENT(local_sdata_evt, drv_cancel_hw_scan, - TP_PROTO(struct ieee80211_local *local, - struct ieee80211_sub_if_data *sdata), - TP_ARGS(local, sdata) -); - DEFINE_EVENT(local_sdata_evt, drv_sched_scan_start, TP_PROTO(struct ieee80211_local *local, struct ieee80211_sub_if_data *sdata), @@ -1024,34 +1018,6 @@ TRACE_EVENT(drv_set_bitrate_mask, ) ); -TRACE_EVENT(drv_set_rekey_data, - TP_PROTO(struct ieee80211_local *local, - struct ieee80211_sub_if_data *sdata, - struct cfg80211_gtk_rekey_data *data), - - TP_ARGS(local, sdata, data), - - TP_STRUCT__entry( - LOCAL_ENTRY - VIF_ENTRY - __array(u8, kek, NL80211_KEK_LEN) - __array(u8, kck, NL80211_KCK_LEN) - __array(u8, replay_ctr, NL80211_REPLAY_CTR_LEN) - ), - - TP_fast_assign( - LOCAL_ASSIGN; - VIF_ASSIGN; - memcpy(__entry->kek, data->kek, NL80211_KEK_LEN); - memcpy(__entry->kck, data->kck, NL80211_KCK_LEN); - memcpy(__entry->replay_ctr, data->replay_ctr, - NL80211_REPLAY_CTR_LEN); - ), - - TP_printk(LOCAL_PR_FMT VIF_PR_FMT, - LOCAL_PR_ARG, VIF_PR_ARG) -); - /* * Tracing for API calls that drivers call. */ @@ -1321,27 +1287,6 @@ DEFINE_EVENT(local_only_evt, api_remain_on_channel_expired, TP_ARGS(local) ); -TRACE_EVENT(api_gtk_rekey_notify, - TP_PROTO(struct ieee80211_sub_if_data *sdata, - const u8 *bssid, const u8 *replay_ctr), - - TP_ARGS(sdata, bssid, replay_ctr), - - TP_STRUCT__entry( - VIF_ENTRY - __array(u8, bssid, ETH_ALEN) - __array(u8, replay_ctr, NL80211_REPLAY_CTR_LEN) - ), - - TP_fast_assign( - VIF_ASSIGN; - memcpy(__entry->bssid, bssid, ETH_ALEN); - memcpy(__entry->replay_ctr, replay_ctr, NL80211_REPLAY_CTR_LEN); - ), - - TP_printk(VIF_PR_FMT, VIF_PR_ARG) -); - /* * Tracing for internal functions * (which may also be called in response to driver calls) diff --git a/trunk/net/mac80211/ieee80211_i.h b/trunk/net/mac80211/ieee80211_i.h index 4f2e424e8b1b..090b0ec1e056 100644 --- a/trunk/net/mac80211/ieee80211_i.h +++ b/trunk/net/mac80211/ieee80211_i.h @@ -544,9 +544,6 @@ struct ieee80211_sub_if_data { /* keys */ struct list_head key_list; - /* count for keys needing tailroom space allocation */ - int crypto_tx_tailroom_needed_cnt; - struct net_device *dev; struct ieee80211_local *local; @@ -1353,12 +1350,10 @@ int ieee80211_build_preq_ies(struct ieee80211_local *local, u8 *buffer, struct sk_buff *ieee80211_build_probe_req(struct ieee80211_sub_if_data *sdata, u8 *dst, const u8 *ssid, size_t ssid_len, - const u8 *ie, size_t ie_len, - bool directed); + const u8 *ie, size_t ie_len); void ieee80211_send_probe_req(struct ieee80211_sub_if_data *sdata, u8 *dst, const u8 *ssid, size_t ssid_len, - const u8 *ie, size_t ie_len, - bool directed); + const u8 *ie, size_t ie_len); void ieee80211_sta_def_wmm_params(struct ieee80211_sub_if_data *sdata, const size_t supp_rates_len, diff --git a/trunk/net/mac80211/key.c b/trunk/net/mac80211/key.c index 1208a7878bfd..f825e2f0a57e 100644 --- a/trunk/net/mac80211/key.c +++ b/trunk/net/mac80211/key.c @@ -61,36 +61,6 @@ static struct ieee80211_sta *get_sta_for_key(struct ieee80211_key *key) return NULL; } -static void increment_tailroom_need_count(struct ieee80211_sub_if_data *sdata) -{ - /* - * When this count is zero, SKB resizing for allocating tailroom - * for IV or MMIC is skipped. But, this check has created two race - * cases in xmit path while transiting from zero count to one: - * - * 1. SKB resize was skipped because no key was added but just before - * the xmit key is added and SW encryption kicks off. - * - * 2. SKB resize was skipped because all the keys were hw planted but - * just before xmit one of the key is deleted and SW encryption kicks - * off. - * - * In both the above case SW encryption will find not enough space for - * tailroom and exits with WARN_ON. (See WARN_ONs at wpa.c) - * - * Solution has been explained at - * http://mid.gmane.org/1308590980.4322.19.camel@jlt3.sipsolutions.net - */ - - if (!sdata->crypto_tx_tailroom_needed_cnt++) { - /* - * Flush all XMIT packets currently using HW encryption or no - * encryption at all if the count transition is from 0 -> 1. - */ - synchronize_net(); - } -} - static int ieee80211_key_enable_hw_accel(struct ieee80211_key *key) { struct ieee80211_sub_if_data *sdata; @@ -131,11 +101,6 @@ static int ieee80211_key_enable_hw_accel(struct ieee80211_key *key) if (!ret) { key->flags |= KEY_FLAG_UPLOADED_TO_HARDWARE; - - if (!((key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_MMIC) || - (key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV))) - sdata->crypto_tx_tailroom_needed_cnt--; - return 0; } @@ -177,10 +142,6 @@ static void ieee80211_key_disable_hw_accel(struct ieee80211_key *key) sta = get_sta_for_key(key); sdata = key->sdata; - if (!((key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_MMIC) || - (key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV))) - increment_tailroom_need_count(sdata); - if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) sdata = container_of(sdata->bss, struct ieee80211_sub_if_data, @@ -433,10 +394,8 @@ static void __ieee80211_key_destroy(struct ieee80211_key *key) ieee80211_aes_key_free(key->u.ccmp.tfm); if (key->conf.cipher == WLAN_CIPHER_SUITE_AES_CMAC) ieee80211_aes_cmac_key_free(key->u.aes_cmac.tfm); - if (key->local) { + if (key->local) ieee80211_debugfs_key_remove(key); - key->sdata->crypto_tx_tailroom_needed_cnt--; - } kfree(key); } @@ -493,8 +452,6 @@ int ieee80211_key_link(struct ieee80211_key *key, else old_key = key_mtx_dereference(sdata->local, sdata->keys[idx]); - increment_tailroom_need_count(sdata); - __ieee80211_key_replace(sdata, sta, pairwise, old_key, key); __ieee80211_key_destroy(old_key); @@ -541,49 +498,12 @@ void ieee80211_enable_keys(struct ieee80211_sub_if_data *sdata) mutex_lock(&sdata->local->key_mtx); - sdata->crypto_tx_tailroom_needed_cnt = 0; - - list_for_each_entry(key, &sdata->key_list, list) { - increment_tailroom_need_count(sdata); + list_for_each_entry(key, &sdata->key_list, list) ieee80211_key_enable_hw_accel(key); - } mutex_unlock(&sdata->local->key_mtx); } -void ieee80211_iter_keys(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - void (*iter)(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - struct ieee80211_sta *sta, - struct ieee80211_key_conf *key, - void *data), - void *iter_data) -{ - struct ieee80211_local *local = hw_to_local(hw); - struct ieee80211_key *key; - struct ieee80211_sub_if_data *sdata; - - ASSERT_RTNL(); - - mutex_lock(&local->key_mtx); - if (vif) { - sdata = vif_to_sdata(vif); - list_for_each_entry(key, &sdata->key_list, list) - iter(hw, &sdata->vif, - key->sta ? &key->sta->sta : NULL, - &key->conf, iter_data); - } else { - list_for_each_entry(sdata, &local->interfaces, list) - list_for_each_entry(key, &sdata->key_list, list) - iter(hw, &sdata->vif, - key->sta ? &key->sta->sta : NULL, - &key->conf, iter_data); - } - mutex_unlock(&local->key_mtx); -} -EXPORT_SYMBOL(ieee80211_iter_keys); - void ieee80211_disable_keys(struct ieee80211_sub_if_data *sdata) { struct ieee80211_key *key; @@ -613,15 +533,3 @@ void ieee80211_free_keys(struct ieee80211_sub_if_data *sdata) mutex_unlock(&sdata->local->key_mtx); } - - -void ieee80211_gtk_rekey_notify(struct ieee80211_vif *vif, const u8 *bssid, - const u8 *replay_ctr, gfp_t gfp) -{ - struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif); - - trace_api_gtk_rekey_notify(sdata, bssid, replay_ctr); - - cfg80211_gtk_rekey_notify(sdata->dev, bssid, replay_ctr, gfp); -} -EXPORT_SYMBOL_GPL(ieee80211_gtk_rekey_notify); diff --git a/trunk/net/mac80211/mesh_pathtbl.c b/trunk/net/mac80211/mesh_pathtbl.c index 068ee6518254..0d2faacc3e87 100644 --- a/trunk/net/mac80211/mesh_pathtbl.c +++ b/trunk/net/mac80211/mesh_pathtbl.c @@ -647,12 +647,12 @@ int mesh_path_del(u8 *addr, struct ieee80211_sub_if_data *sdata) mpath = node->mpath; if (mpath->sdata == sdata && memcmp(addr, mpath->dst, ETH_ALEN) == 0) { - spin_lock(&mpath->state_lock); + spin_lock_bh(&mpath->state_lock); mpath->flags |= MESH_PATH_RESOLVING; hlist_del_rcu(&node->list); call_rcu(&node->rcu, mesh_path_node_reclaim); atomic_dec(&tbl->entries); - spin_unlock(&mpath->state_lock); + spin_unlock_bh(&mpath->state_lock); goto enddel; } } diff --git a/trunk/net/mac80211/mlme.c b/trunk/net/mac80211/mlme.c index 182cda66ebef..d595265d6c22 100644 --- a/trunk/net/mac80211/mlme.c +++ b/trunk/net/mac80211/mlme.c @@ -749,7 +749,7 @@ void ieee80211_dynamic_ps_enable_work(struct work_struct *work) container_of(work, struct ieee80211_local, dynamic_ps_enable_work); struct ieee80211_sub_if_data *sdata = local->ps_sdata; - struct ieee80211_if_managed *ifmgd; + struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; unsigned long flags; int q; @@ -757,39 +757,26 @@ void ieee80211_dynamic_ps_enable_work(struct work_struct *work) if (!sdata) return; - ifmgd = &sdata->u.mgd; - if (local->hw.conf.flags & IEEE80211_CONF_PS) return; - if (!local->disable_dynamic_ps && - local->hw.conf.dynamic_ps_timeout > 0) { - /* don't enter PS if TX frames are pending */ - if (drv_tx_frames_pending(local)) { + /* + * transmission can be stopped by others which leads to + * dynamic_ps_timer expiry. Postpond the ps timer if it + * is not the actual idle state. + */ + spin_lock_irqsave(&local->queue_stop_reason_lock, flags); + for (q = 0; q < local->hw.queues; q++) { + if (local->queue_stop_reasons[q]) { + spin_unlock_irqrestore(&local->queue_stop_reason_lock, + flags); mod_timer(&local->dynamic_ps_timer, jiffies + msecs_to_jiffies( local->hw.conf.dynamic_ps_timeout)); return; } - - /* - * transmission can be stopped by others which leads to - * dynamic_ps_timer expiry. Postpone the ps timer if it - * is not the actual idle state. - */ - spin_lock_irqsave(&local->queue_stop_reason_lock, flags); - for (q = 0; q < local->hw.queues; q++) { - if (local->queue_stop_reasons[q]) { - spin_unlock_irqrestore(&local->queue_stop_reason_lock, - flags); - mod_timer(&local->dynamic_ps_timer, jiffies + - msecs_to_jiffies( - local->hw.conf.dynamic_ps_timeout)); - return; - } - } - spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); } + spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); if ((local->hw.flags & IEEE80211_HW_PS_NULLFUNC_STACK) && (!(ifmgd->flags & IEEE80211_STA_NULLFUNC_ACKED))) { @@ -814,8 +801,7 @@ void ieee80211_dynamic_ps_enable_work(struct work_struct *work) ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS); } - if (local->hw.flags & IEEE80211_HW_PS_NULLFUNC_STACK) - netif_tx_wake_all_queues(sdata->dev); + netif_tx_wake_all_queues(sdata->dev); } void ieee80211_dynamic_ps_timer(unsigned long data) @@ -1218,8 +1204,7 @@ static void ieee80211_mgd_probe_ap_send(struct ieee80211_sub_if_data *sdata) ieee80211_send_nullfunc(sdata->local, sdata, 0); } else { ssid = ieee80211_bss_get_ie(ifmgd->associated, WLAN_EID_SSID); - ieee80211_send_probe_req(sdata, dst, ssid + 2, ssid[1], NULL, 0, - true); + ieee80211_send_probe_req(sdata, dst, ssid + 2, ssid[1], NULL, 0); } ifmgd->probe_send_count++; @@ -1304,7 +1289,7 @@ struct sk_buff *ieee80211_ap_probereq_get(struct ieee80211_hw *hw, ssid = ieee80211_bss_get_ie(ifmgd->associated, WLAN_EID_SSID); skb = ieee80211_build_probe_req(sdata, ifmgd->associated->bssid, - ssid + 2, ssid[1], NULL, 0, true); + ssid + 2, ssid[1], NULL, 0); return skb; } @@ -2221,7 +2206,6 @@ void ieee80211_sta_restart(struct ieee80211_sub_if_data *sdata) add_timer(&ifmgd->chswitch_timer); ieee80211_sta_reset_beacon_monitor(sdata); ieee80211_restart_sta_timer(sdata); - ieee80211_queue_work(&sdata->local->hw, &sdata->u.mgd.monitor_work); } #endif @@ -2668,10 +2652,3 @@ void ieee80211_cqm_rssi_notify(struct ieee80211_vif *vif, cfg80211_cqm_rssi_notify(sdata->dev, rssi_event, gfp); } EXPORT_SYMBOL(ieee80211_cqm_rssi_notify); - -unsigned char ieee80211_get_operstate(struct ieee80211_vif *vif) -{ - struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif); - return sdata->dev->operstate; -} -EXPORT_SYMBOL(ieee80211_get_operstate); diff --git a/trunk/net/mac80211/pm.c b/trunk/net/mac80211/pm.c index f87e993e713b..730778a2c90c 100644 --- a/trunk/net/mac80211/pm.c +++ b/trunk/net/mac80211/pm.c @@ -6,28 +6,6 @@ #include "driver-ops.h" #include "led.h" -/* return value indicates whether the driver should be further notified */ -static bool ieee80211_quiesce(struct ieee80211_sub_if_data *sdata) -{ - switch (sdata->vif.type) { - case NL80211_IFTYPE_STATION: - ieee80211_sta_quiesce(sdata); - return true; - case NL80211_IFTYPE_ADHOC: - ieee80211_ibss_quiesce(sdata); - return true; - case NL80211_IFTYPE_MESH_POINT: - ieee80211_mesh_quiesce(sdata); - return true; - case NL80211_IFTYPE_AP_VLAN: - case NL80211_IFTYPE_MONITOR: - /* don't tell driver about this */ - return false; - default: - return true; - } -} - int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan) { struct ieee80211_local *local = hw_to_local(hw); @@ -72,19 +50,11 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan) local->wowlan = wowlan && local->open_count; if (local->wowlan) { int err = drv_suspend(local, wowlan); - if (err < 0) { + if (err) { local->quiescing = false; return err; - } else if (err > 0) { - WARN_ON(err != 1); - local->wowlan = false; - } else { - list_for_each_entry(sdata, &local->interfaces, list) { - cancel_work_sync(&sdata->work); - ieee80211_quiesce(sdata); - } - goto suspend; } + goto suspend; } /* disable keys */ @@ -112,8 +82,23 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan) list_for_each_entry(sdata, &local->interfaces, list) { cancel_work_sync(&sdata->work); - if (!ieee80211_quiesce(sdata)) + switch(sdata->vif.type) { + case NL80211_IFTYPE_STATION: + ieee80211_sta_quiesce(sdata); + break; + case NL80211_IFTYPE_ADHOC: + ieee80211_ibss_quiesce(sdata); + break; + case NL80211_IFTYPE_MESH_POINT: + ieee80211_mesh_quiesce(sdata); + break; + case NL80211_IFTYPE_AP_VLAN: + case NL80211_IFTYPE_MONITOR: + /* don't tell driver about this */ continue; + default: + break; + } if (!ieee80211_sdata_running(sdata)) continue; diff --git a/trunk/net/mac80211/rx.c b/trunk/net/mac80211/rx.c index b5493ecd1e93..7fa8c6be7bf0 100644 --- a/trunk/net/mac80211/rx.c +++ b/trunk/net/mac80211/rx.c @@ -338,7 +338,7 @@ static void ieee80211_parse_qos(struct ieee80211_rx_data *rx) u8 *qc = ieee80211_get_qos_ctl(hdr); /* frame has qos control */ tid = *qc & IEEE80211_QOS_CTL_TID_MASK; - if (*qc & IEEE80211_QOS_CTL_A_MSDU_PRESENT) + if (*qc & IEEE80211_QOS_CONTROL_A_MSDU_PRESENT) status->rx_flags |= IEEE80211_RX_AMSDU; } else { /* diff --git a/trunk/net/mac80211/scan.c b/trunk/net/mac80211/scan.c index 08a45ac3d6f8..58ffa7d069c7 100644 --- a/trunk/net/mac80211/scan.c +++ b/trunk/net/mac80211/scan.c @@ -228,7 +228,6 @@ ieee80211_scan_rx(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb) static bool ieee80211_prep_hw_scan(struct ieee80211_local *local) { struct cfg80211_scan_request *req = local->scan_req; - struct ieee80211_sub_if_data *sdata = local->scan_sdata; enum ieee80211_band band; int i, ielen, n_chans; @@ -252,8 +251,8 @@ static bool ieee80211_prep_hw_scan(struct ieee80211_local *local) local->hw_scan_req->n_channels = n_chans; ielen = ieee80211_build_preq_ies(local, (u8 *)local->hw_scan_req->ie, - req->ie, req->ie_len, band, - sdata->rc_rateidx_mask[band], 0); + req->ie, req->ie_len, band, (u32) -1, + 0); local->hw_scan_req->ie_len = ielen; return true; @@ -659,8 +658,7 @@ static void ieee80211_scan_state_send_probe(struct ieee80211_local *local, sdata, NULL, local->scan_req->ssids[i].ssid, local->scan_req->ssids[i].ssid_len, - local->scan_req->ie, local->scan_req->ie_len, - false); + local->scan_req->ie, local->scan_req->ie_len); /* * After sending probe requests, wait for probe responses @@ -823,8 +821,10 @@ int ieee80211_request_internal_scan(struct ieee80211_sub_if_data *sdata, */ void ieee80211_scan_cancel(struct ieee80211_local *local) { + bool abortscan; + /* - * We are canceling software scan, or deferred scan that was not + * We are only canceling software scan, or deferred scan that was not * yet really started (see __ieee80211_start_scan ). * * Regarding hardware scan: @@ -836,30 +836,23 @@ void ieee80211_scan_cancel(struct ieee80211_local *local) * - we can not cancel scan_work since driver can schedule it * by ieee80211_scan_completed(..., true) to finish scan * - * Hence we only call the cancel_hw_scan() callback, but the low-level - * driver is still responsible for calling ieee80211_scan_completed() - * after the scan was completed/aborted. + * Hence low lever driver is responsible for canceling HW scan. */ mutex_lock(&local->mtx); - if (!local->scan_req) - goto out; - - if (test_bit(SCAN_HW_SCANNING, &local->scanning)) { - if (local->ops->cancel_hw_scan) - drv_cancel_hw_scan(local, local->scan_sdata); - goto out; + abortscan = local->scan_req && !test_bit(SCAN_HW_SCANNING, &local->scanning); + if (abortscan) { + /* + * The scan is canceled, but stop work from being pending. + * + * If the work is currently running, it must be blocked on + * the mutex, but we'll set scan_sdata = NULL and it'll + * simply exit once it acquires the mutex. + */ + cancel_delayed_work(&local->scan_work); + /* and clean up */ + __ieee80211_scan_completed(&local->hw, true, false); } - - /* - * If the work is currently running, it must be blocked on - * the mutex, but we'll set scan_sdata = NULL and it'll - * simply exit once it acquires the mutex. - */ - cancel_delayed_work(&local->scan_work); - /* and clean up */ - __ieee80211_scan_completed(&local->hw, true, false); -out: mutex_unlock(&local->mtx); } @@ -884,8 +877,7 @@ int ieee80211_request_sched_scan_start(struct ieee80211_sub_if_data *sdata, for (i = 0; i < IEEE80211_NUM_BANDS; i++) { local->sched_scan_ies.ie[i] = kzalloc(2 + IEEE80211_MAX_SSID_LEN + - local->scan_ies_len + - req->ie_len, + local->scan_ies_len, GFP_KERNEL); if (!local->sched_scan_ies.ie[i]) { ret = -ENOMEM; diff --git a/trunk/net/mac80211/tx.c b/trunk/net/mac80211/tx.c index e8d0d2d22665..3104c844b544 100644 --- a/trunk/net/mac80211/tx.c +++ b/trunk/net/mac80211/tx.c @@ -1474,14 +1474,18 @@ static bool ieee80211_tx(struct ieee80211_sub_if_data *sdata, /* device xmit handlers */ -static int ieee80211_skb_resize(struct ieee80211_sub_if_data *sdata, +static int ieee80211_skb_resize(struct ieee80211_local *local, struct sk_buff *skb, int head_need, bool may_encrypt) { - struct ieee80211_local *local = sdata->local; int tail_need = 0; - if (may_encrypt && sdata->crypto_tx_tailroom_needed_cnt) { + /* + * This could be optimised, devices that do full hardware + * crypto (including TKIP MMIC) need no tailroom... But we + * have no drivers for such devices currently. + */ + if (may_encrypt) { tail_need = IEEE80211_ENCRYPT_TAILROOM; tail_need -= skb_tailroom(skb); tail_need = max_t(int, tail_need, 0); @@ -1574,7 +1578,7 @@ static void ieee80211_xmit(struct ieee80211_sub_if_data *sdata, headroom -= skb_headroom(skb); headroom = max_t(int, 0, headroom); - if (ieee80211_skb_resize(sdata, skb, headroom, may_encrypt)) { + if (ieee80211_skb_resize(local, skb, headroom, may_encrypt)) { dev_kfree_skb(skb); rcu_read_unlock(); return; @@ -1941,7 +1945,7 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb, head_need += IEEE80211_ENCRYPT_HEADROOM; head_need += local->tx_headroom; head_need = max_t(int, 0, head_need); - if (ieee80211_skb_resize(sdata, skb, head_need, true)) + if (ieee80211_skb_resize(local, skb, head_need, true)) goto fail; } diff --git a/trunk/net/mac80211/util.c b/trunk/net/mac80211/util.c index 652e5695225a..d3fe2d237485 100644 --- a/trunk/net/mac80211/util.c +++ b/trunk/net/mac80211/util.c @@ -1018,8 +1018,7 @@ int ieee80211_build_preq_ies(struct ieee80211_local *local, u8 *buffer, struct sk_buff *ieee80211_build_probe_req(struct ieee80211_sub_if_data *sdata, u8 *dst, const u8 *ssid, size_t ssid_len, - const u8 *ie, size_t ie_len, - bool directed) + const u8 *ie, size_t ie_len) { struct ieee80211_local *local = sdata->local; struct sk_buff *skb; @@ -1036,16 +1035,8 @@ struct sk_buff *ieee80211_build_probe_req(struct ieee80211_sub_if_data *sdata, return NULL; } - /* - * Do not send DS Channel parameter for directed probe requests - * in order to maximize the chance that we get a response. Some - * badly-behaved APs don't respond when this parameter is included. - */ - if (directed) - chan = 0; - else - chan = ieee80211_frequency_to_channel( - local->hw.conf.channel->center_freq); + chan = ieee80211_frequency_to_channel( + local->hw.conf.channel->center_freq); buf_len = ieee80211_build_preq_ies(local, buf, ie, ie_len, local->hw.conf.channel->band, @@ -1071,13 +1062,11 @@ struct sk_buff *ieee80211_build_probe_req(struct ieee80211_sub_if_data *sdata, void ieee80211_send_probe_req(struct ieee80211_sub_if_data *sdata, u8 *dst, const u8 *ssid, size_t ssid_len, - const u8 *ie, size_t ie_len, - bool directed) + const u8 *ie, size_t ie_len) { struct sk_buff *skb; - skb = ieee80211_build_probe_req(sdata, dst, ssid, ssid_len, ie, ie_len, - directed); + skb = ieee80211_build_probe_req(sdata, dst, ssid, ssid_len, ie, ie_len); if (skb) ieee80211_tx_skb(sdata, skb); } @@ -1287,9 +1276,7 @@ int ieee80211_reconfig(struct ieee80211_local *local) if (ieee80211_sdata_running(sdata)) ieee80211_enable_keys(sdata); -#ifdef CONFIG_PM wake_up: -#endif ieee80211_wake_queues_by_reason(hw, IEEE80211_QUEUE_STOP_REASON_SUSPEND); diff --git a/trunk/net/mac80211/wme.c b/trunk/net/mac80211/wme.c index 7a49532f14cb..28bc084dbfb9 100644 --- a/trunk/net/mac80211/wme.c +++ b/trunk/net/mac80211/wme.c @@ -151,7 +151,8 @@ void ieee80211_set_qos_hdr(struct ieee80211_local *local, struct sk_buff *skb) tid = skb->priority & IEEE80211_QOS_CTL_TAG1D_MASK; if (unlikely(local->wifi_wme_noack_test)) - ack_policy |= IEEE80211_QOS_CTL_ACK_POLICY_NOACK; + ack_policy |= QOS_CONTROL_ACK_POLICY_NOACK << + QOS_CONTROL_ACK_POLICY_SHIFT; /* qos header is 2 bytes, second reserved */ *p++ = ack_policy | tid; *p = 0; diff --git a/trunk/net/mac80211/wme.h b/trunk/net/mac80211/wme.h index faead6d02026..6053b1c9feee 100644 --- a/trunk/net/mac80211/wme.h +++ b/trunk/net/mac80211/wme.h @@ -13,6 +13,11 @@ #include #include "ieee80211_i.h" +#define QOS_CONTROL_ACK_POLICY_NORMAL 0 +#define QOS_CONTROL_ACK_POLICY_NOACK 1 + +#define QOS_CONTROL_ACK_POLICY_SHIFT 5 + extern const int ieee802_1d_to_ac[8]; u16 ieee80211_select_queue(struct ieee80211_sub_if_data *sdata, diff --git a/trunk/net/mac80211/work.c b/trunk/net/mac80211/work.c index edf8583280c9..d2e7f0e86677 100644 --- a/trunk/net/mac80211/work.c +++ b/trunk/net/mac80211/work.c @@ -450,7 +450,7 @@ ieee80211_direct_probe(struct ieee80211_work *wk) * will not answer to direct packet in unassociated state. */ ieee80211_send_probe_req(sdata, NULL, wk->probe_auth.ssid, - wk->probe_auth.ssid_len, NULL, 0, true); + wk->probe_auth.ssid_len, NULL, 0); wk->timeout = jiffies + IEEE80211_AUTH_TIMEOUT; run_again(local, wk->timeout); diff --git a/trunk/net/mac80211/wpa.c b/trunk/net/mac80211/wpa.c index 8f6a302d2ac3..9dc3b5f26e80 100644 --- a/trunk/net/mac80211/wpa.c +++ b/trunk/net/mac80211/wpa.c @@ -86,11 +86,6 @@ ieee80211_rx_h_michael_mic_verify(struct ieee80211_rx_data *rx) struct sk_buff *skb = rx->skb; struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb); struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; - int queue = rx->queue; - - /* otherwise, TKIP is vulnerable to TID 0 vs. non-QoS replays */ - if (rx->queue == NUM_RX_DATA_QUEUES - 1) - queue = 0; /* * it makes no sense to check for MIC errors on anything other @@ -153,19 +148,13 @@ ieee80211_rx_h_michael_mic_verify(struct ieee80211_rx_data *rx) update_iv: /* update IV in key information to be able to detect replays */ - rx->key->u.tkip.rx[queue].iv32 = rx->tkip_iv32; - rx->key->u.tkip.rx[queue].iv16 = rx->tkip_iv16; + rx->key->u.tkip.rx[rx->queue].iv32 = rx->tkip_iv32; + rx->key->u.tkip.rx[rx->queue].iv16 = rx->tkip_iv16; return RX_CONTINUE; mic_fail: - /* - * In some cases the key can be unset - e.g. a multicast packet, in - * a driver that supports HW encryption. Send up the key idx only if - * the key is set. - */ - mac80211_ev_michael_mic_failure(rx->sdata, - rx->key ? rx->key->conf.keyidx : -1, + mac80211_ev_michael_mic_failure(rx->sdata, rx->key->conf.keyidx, (void *) skb->data, NULL, GFP_ATOMIC); return RX_DROP_UNUSABLE; } @@ -246,11 +235,6 @@ ieee80211_crypto_tkip_decrypt(struct ieee80211_rx_data *rx) struct ieee80211_key *key = rx->key; struct sk_buff *skb = rx->skb; struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb); - int queue = rx->queue; - - /* otherwise, TKIP is vulnerable to TID 0 vs. non-QoS replays */ - if (rx->queue == NUM_RX_DATA_QUEUES - 1) - queue = 0; hdrlen = ieee80211_hdrlen(hdr->frame_control); @@ -271,7 +255,7 @@ ieee80211_crypto_tkip_decrypt(struct ieee80211_rx_data *rx) res = ieee80211_tkip_decrypt_data(rx->local->wep_rx_tfm, key, skb->data + hdrlen, skb->len - hdrlen, rx->sta->sta.addr, - hdr->addr1, hwaccel, queue, + hdr->addr1, hwaccel, rx->queue, &rx->tkip_iv32, &rx->tkip_iv16); if (res != TKIP_DECRYPT_OK) diff --git a/trunk/net/netfilter/xt_HL.c b/trunk/net/netfilter/xt_HL.c index 1535e87ed9bd..95b084800fcc 100644 --- a/trunk/net/netfilter/xt_HL.c +++ b/trunk/net/netfilter/xt_HL.c @@ -38,22 +38,22 @@ ttl_tg(struct sk_buff *skb, const struct xt_action_param *par) iph = ip_hdr(skb); switch (info->mode) { - case IPT_TTL_SET: - new_ttl = info->ttl; - break; - case IPT_TTL_INC: - new_ttl = iph->ttl + info->ttl; - if (new_ttl > 255) - new_ttl = 255; - break; - case IPT_TTL_DEC: - new_ttl = iph->ttl - info->ttl; - if (new_ttl < 0) - new_ttl = 0; - break; - default: - new_ttl = iph->ttl; - break; + case IPT_TTL_SET: + new_ttl = info->ttl; + break; + case IPT_TTL_INC: + new_ttl = iph->ttl + info->ttl; + if (new_ttl > 255) + new_ttl = 255; + break; + case IPT_TTL_DEC: + new_ttl = iph->ttl - info->ttl; + if (new_ttl < 0) + new_ttl = 0; + break; + default: + new_ttl = iph->ttl; + break; } if (new_ttl != iph->ttl) { @@ -78,22 +78,22 @@ hl_tg6(struct sk_buff *skb, const struct xt_action_param *par) ip6h = ipv6_hdr(skb); switch (info->mode) { - case IP6T_HL_SET: - new_hl = info->hop_limit; - break; - case IP6T_HL_INC: - new_hl = ip6h->hop_limit + info->hop_limit; - if (new_hl > 255) - new_hl = 255; - break; - case IP6T_HL_DEC: - new_hl = ip6h->hop_limit - info->hop_limit; - if (new_hl < 0) - new_hl = 0; - break; - default: - new_hl = ip6h->hop_limit; - break; + case IP6T_HL_SET: + new_hl = info->hop_limit; + break; + case IP6T_HL_INC: + new_hl = ip6h->hop_limit + info->hop_limit; + if (new_hl > 255) + new_hl = 255; + break; + case IP6T_HL_DEC: + new_hl = ip6h->hop_limit - info->hop_limit; + if (new_hl < 0) + new_hl = 0; + break; + default: + new_hl = ip6h->hop_limit; + break; } ip6h->hop_limit = new_hl; diff --git a/trunk/net/netfilter/xt_hl.c b/trunk/net/netfilter/xt_hl.c index 003951149c9e..7d12221ead89 100644 --- a/trunk/net/netfilter/xt_hl.c +++ b/trunk/net/netfilter/xt_hl.c @@ -31,14 +31,14 @@ static bool ttl_mt(const struct sk_buff *skb, struct xt_action_param *par) const u8 ttl = ip_hdr(skb)->ttl; switch (info->mode) { - case IPT_TTL_EQ: - return ttl == info->ttl; - case IPT_TTL_NE: - return ttl != info->ttl; - case IPT_TTL_LT: - return ttl < info->ttl; - case IPT_TTL_GT: - return ttl > info->ttl; + case IPT_TTL_EQ: + return ttl == info->ttl; + case IPT_TTL_NE: + return ttl != info->ttl; + case IPT_TTL_LT: + return ttl < info->ttl; + case IPT_TTL_GT: + return ttl > info->ttl; } return false; @@ -50,14 +50,14 @@ static bool hl_mt6(const struct sk_buff *skb, struct xt_action_param *par) const struct ipv6hdr *ip6h = ipv6_hdr(skb); switch (info->mode) { - case IP6T_HL_EQ: - return ip6h->hop_limit == info->hop_limit; - case IP6T_HL_NE: - return ip6h->hop_limit != info->hop_limit; - case IP6T_HL_LT: - return ip6h->hop_limit < info->hop_limit; - case IP6T_HL_GT: - return ip6h->hop_limit > info->hop_limit; + case IP6T_HL_EQ: + return ip6h->hop_limit == info->hop_limit; + case IP6T_HL_NE: + return ip6h->hop_limit != info->hop_limit; + case IP6T_HL_LT: + return ip6h->hop_limit < info->hop_limit; + case IP6T_HL_GT: + return ip6h->hop_limit > info->hop_limit; } return false; diff --git a/trunk/net/netlink/af_netlink.c b/trunk/net/netlink/af_netlink.c index 0a4db0211da0..ca5276c51804 100644 --- a/trunk/net/netlink/af_netlink.c +++ b/trunk/net/netlink/af_netlink.c @@ -1696,8 +1696,6 @@ static int netlink_dump(struct sock *sk) if (!nlh) goto errout_skb; - nl_dump_check_consistent(cb, nlh); - memcpy(nlmsg_data(nlh), &len, sizeof(len)); if (sk_filter(sk, skb)) diff --git a/trunk/net/netrom/nr_route.c b/trunk/net/netrom/nr_route.c index cd5ddb2ebc43..44059d0c8dd1 100644 --- a/trunk/net/netrom/nr_route.c +++ b/trunk/net/netrom/nr_route.c @@ -257,12 +257,9 @@ static int __must_check nr_add_node(ax25_address *nr, const char *mnemonic, case 3: if (nr_node->routes[1].quality > nr_node->routes[0].quality) { switch (nr_node->which) { - case 0: - nr_node->which = 1; - break; - case 1: - nr_node->which = 0; - break; + case 0: nr_node->which = 1; break; + case 1: nr_node->which = 0; break; + default: break; } nr_route = nr_node->routes[0]; nr_node->routes[0] = nr_node->routes[1]; @@ -508,13 +505,12 @@ static int nr_dec_obs(void) s->count--; switch (i) { - case 0: - s->routes[0] = s->routes[1]; - /* Fallthrough */ - case 1: - s->routes[1] = s->routes[2]; - case 2: - break; + case 0: + s->routes[0] = s->routes[1]; + case 1: + s->routes[1] = s->routes[2]; + case 2: + break; } break; diff --git a/trunk/net/nfc/Kconfig b/trunk/net/nfc/Kconfig deleted file mode 100644 index 33e095b124b3..000000000000 --- a/trunk/net/nfc/Kconfig +++ /dev/null @@ -1,16 +0,0 @@ -# -# NFC sybsystem configuration -# - -menuconfig NFC - depends on NET && EXPERIMENTAL - tristate "NFC subsystem support (EXPERIMENTAL)" - default n - help - Say Y here if you want to build support for NFC (Near field - communication) devices. - - To compile this support as a module, choose M here: the module will - be called nfc. - -source "drivers/nfc/Kconfig" diff --git a/trunk/net/nfc/Makefile b/trunk/net/nfc/Makefile deleted file mode 100644 index 16250c353851..000000000000 --- a/trunk/net/nfc/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -# -# Makefile for the Linux NFC subsystem. -# - -obj-$(CONFIG_NFC) += nfc.o - -nfc-objs := core.o netlink.o af_nfc.o rawsock.o diff --git a/trunk/net/nfc/af_nfc.c b/trunk/net/nfc/af_nfc.c deleted file mode 100644 index e982cef8f49d..000000000000 --- a/trunk/net/nfc/af_nfc.c +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (C) 2011 Instituto Nokia de Tecnologia - * - * Authors: - * Aloisio Almeida Jr - * Lauro Ramos Venancio - * - * 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. - * - * 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., - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include - -#include "nfc.h" - -static DEFINE_RWLOCK(proto_tab_lock); -static const struct nfc_protocol *proto_tab[NFC_SOCKPROTO_MAX]; - -static int nfc_sock_create(struct net *net, struct socket *sock, int proto, - int kern) -{ - int rc = -EPROTONOSUPPORT; - - if (net != &init_net) - return -EAFNOSUPPORT; - - if (proto < 0 || proto >= NFC_SOCKPROTO_MAX) - return -EINVAL; - - read_lock(&proto_tab_lock); - if (proto_tab[proto] && try_module_get(proto_tab[proto]->owner)) { - rc = proto_tab[proto]->create(net, sock, proto_tab[proto]); - module_put(proto_tab[proto]->owner); - } - read_unlock(&proto_tab_lock); - - return rc; -} - -static struct net_proto_family nfc_sock_family_ops = { - .owner = THIS_MODULE, - .family = PF_NFC, - .create = nfc_sock_create, -}; - -int nfc_proto_register(const struct nfc_protocol *nfc_proto) -{ - int rc; - - if (nfc_proto->id < 0 || nfc_proto->id >= NFC_SOCKPROTO_MAX) - return -EINVAL; - - rc = proto_register(nfc_proto->proto, 0); - if (rc) - return rc; - - write_lock(&proto_tab_lock); - if (proto_tab[nfc_proto->id]) - rc = -EBUSY; - else - proto_tab[nfc_proto->id] = nfc_proto; - write_unlock(&proto_tab_lock); - - return rc; -} -EXPORT_SYMBOL(nfc_proto_register); - -void nfc_proto_unregister(const struct nfc_protocol *nfc_proto) -{ - write_lock(&proto_tab_lock); - proto_tab[nfc_proto->id] = NULL; - write_unlock(&proto_tab_lock); - - proto_unregister(nfc_proto->proto); -} -EXPORT_SYMBOL(nfc_proto_unregister); - -int __init af_nfc_init(void) -{ - return sock_register(&nfc_sock_family_ops); -} - -void af_nfc_exit(void) -{ - sock_unregister(PF_NFC); -} diff --git a/trunk/net/nfc/core.c b/trunk/net/nfc/core.c deleted file mode 100644 index b6fd4e1f2057..000000000000 --- a/trunk/net/nfc/core.c +++ /dev/null @@ -1,468 +0,0 @@ -/* - * Copyright (C) 2011 Instituto Nokia de Tecnologia - * - * Authors: - * Lauro Ramos Venancio - * Aloisio Almeida Jr - * - * 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. - * - * 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., - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include -#include -#include -#include - -#include "nfc.h" - -#define VERSION "0.1" - -int nfc_devlist_generation; -DEFINE_MUTEX(nfc_devlist_mutex); - -int nfc_printk(const char *level, const char *format, ...) -{ - struct va_format vaf; - va_list args; - int r; - - va_start(args, format); - - vaf.fmt = format; - vaf.va = &args; - - r = printk("%sNFC: %pV\n", level, &vaf); - - va_end(args); - - return r; -} -EXPORT_SYMBOL(nfc_printk); - -/** - * nfc_start_poll - start polling for nfc targets - * - * @dev: The nfc device that must start polling - * @protocols: bitset of nfc protocols that must be used for polling - * - * The device remains polling for targets until a target is found or - * the nfc_stop_poll function is called. - */ -int nfc_start_poll(struct nfc_dev *dev, u32 protocols) -{ - int rc; - - nfc_dbg("dev_name=%s protocols=0x%x", dev_name(&dev->dev), protocols); - - if (!protocols) - return -EINVAL; - - device_lock(&dev->dev); - - if (!device_is_registered(&dev->dev)) { - rc = -ENODEV; - goto error; - } - - if (dev->polling) { - rc = -EBUSY; - goto error; - } - - rc = dev->ops->start_poll(dev, protocols); - if (!rc) - dev->polling = true; - -error: - device_unlock(&dev->dev); - return rc; -} - -/** - * nfc_stop_poll - stop polling for nfc targets - * - * @dev: The nfc device that must stop polling - */ -int nfc_stop_poll(struct nfc_dev *dev) -{ - int rc = 0; - - nfc_dbg("dev_name=%s", dev_name(&dev->dev)); - - device_lock(&dev->dev); - - if (!device_is_registered(&dev->dev)) { - rc = -ENODEV; - goto error; - } - - if (!dev->polling) { - rc = -EINVAL; - goto error; - } - - dev->ops->stop_poll(dev); - dev->polling = false; - -error: - device_unlock(&dev->dev); - return rc; -} - -/** - * nfc_activate_target - prepare the target for data exchange - * - * @dev: The nfc device that found the target - * @target_idx: index of the target that must be activated - * @protocol: nfc protocol that will be used for data exchange - */ -int nfc_activate_target(struct nfc_dev *dev, u32 target_idx, u32 protocol) -{ - int rc; - - nfc_dbg("dev_name=%s target_idx=%u protocol=%u", dev_name(&dev->dev), - target_idx, protocol); - - device_lock(&dev->dev); - - if (!device_is_registered(&dev->dev)) { - rc = -ENODEV; - goto error; - } - - rc = dev->ops->activate_target(dev, target_idx, protocol); - -error: - device_unlock(&dev->dev); - return rc; -} - -/** - * nfc_deactivate_target - deactivate a nfc target - * - * @dev: The nfc device that found the target - * @target_idx: index of the target that must be deactivated - */ -int nfc_deactivate_target(struct nfc_dev *dev, u32 target_idx) -{ - int rc = 0; - - nfc_dbg("dev_name=%s target_idx=%u", dev_name(&dev->dev), target_idx); - - device_lock(&dev->dev); - - if (!device_is_registered(&dev->dev)) { - rc = -ENODEV; - goto error; - } - - dev->ops->deactivate_target(dev, target_idx); - -error: - device_unlock(&dev->dev); - return rc; -} - -/** - * nfc_data_exchange - transceive data - * - * @dev: The nfc device that found the target - * @target_idx: index of the target - * @skb: data to be sent - * @cb: callback called when the response is received - * @cb_context: parameter for the callback function - * - * The user must wait for the callback before calling this function again. - */ -int nfc_data_exchange(struct nfc_dev *dev, u32 target_idx, - struct sk_buff *skb, - data_exchange_cb_t cb, - void *cb_context) -{ - int rc; - - nfc_dbg("dev_name=%s target_idx=%u skb->len=%u", dev_name(&dev->dev), - target_idx, skb->len); - - device_lock(&dev->dev); - - if (!device_is_registered(&dev->dev)) { - rc = -ENODEV; - kfree_skb(skb); - goto error; - } - - rc = dev->ops->data_exchange(dev, target_idx, skb, cb, cb_context); - -error: - device_unlock(&dev->dev); - return rc; -} - -/** - * nfc_alloc_skb - allocate a skb for data exchange responses - * - * @size: size to allocate - * @gfp: gfp flags - */ -struct sk_buff *nfc_alloc_skb(unsigned int size, gfp_t gfp) -{ - struct sk_buff *skb; - unsigned int total_size; - - total_size = size + 1; - skb = alloc_skb(total_size, gfp); - - if (skb) - skb_reserve(skb, 1); - - return skb; -} -EXPORT_SYMBOL(nfc_alloc_skb); - -/** - * nfc_targets_found - inform that targets were found - * - * @dev: The nfc device that found the targets - * @targets: array of nfc targets found - * @ntargets: targets array size - * - * The device driver must call this function when one or many nfc targets - * are found. After calling this function, the device driver must stop - * polling for targets. - */ -int nfc_targets_found(struct nfc_dev *dev, struct nfc_target *targets, - int n_targets) -{ - int i; - - nfc_dbg("dev_name=%s n_targets=%d", dev_name(&dev->dev), n_targets); - - dev->polling = false; - - for (i = 0; i < n_targets; i++) - targets[i].idx = dev->target_idx++; - - spin_lock_bh(&dev->targets_lock); - - dev->targets_generation++; - - kfree(dev->targets); - dev->targets = kmemdup(targets, n_targets * sizeof(struct nfc_target), - GFP_ATOMIC); - - if (!dev->targets) { - dev->n_targets = 0; - spin_unlock_bh(&dev->targets_lock); - return -ENOMEM; - } - - dev->n_targets = n_targets; - spin_unlock_bh(&dev->targets_lock); - - nfc_genl_targets_found(dev); - - return 0; -} -EXPORT_SYMBOL(nfc_targets_found); - -static void nfc_release(struct device *d) -{ - struct nfc_dev *dev = to_nfc_dev(d); - - nfc_dbg("dev_name=%s", dev_name(&dev->dev)); - - nfc_genl_data_exit(&dev->genl_data); - kfree(dev->targets); - kfree(dev); -} - -struct class nfc_class = { - .name = "nfc", - .dev_release = nfc_release, -}; -EXPORT_SYMBOL(nfc_class); - -static int match_idx(struct device *d, void *data) -{ - struct nfc_dev *dev = to_nfc_dev(d); - unsigned *idx = data; - - return dev->idx == *idx; -} - -struct nfc_dev *nfc_get_device(unsigned idx) -{ - struct device *d; - - d = class_find_device(&nfc_class, NULL, &idx, match_idx); - if (!d) - return NULL; - - return to_nfc_dev(d); -} - -/** - * nfc_allocate_device - allocate a new nfc device - * - * @ops: device operations - * @supported_protocols: NFC protocols supported by the device - */ -struct nfc_dev *nfc_allocate_device(struct nfc_ops *ops, - u32 supported_protocols) -{ - static atomic_t dev_no = ATOMIC_INIT(0); - struct nfc_dev *dev; - - if (!ops->start_poll || !ops->stop_poll || !ops->activate_target || - !ops->deactivate_target || !ops->data_exchange) - return NULL; - - if (!supported_protocols) - return NULL; - - dev = kzalloc(sizeof(struct nfc_dev), GFP_KERNEL); - if (!dev) - return NULL; - - dev->dev.class = &nfc_class; - dev->idx = atomic_inc_return(&dev_no) - 1; - dev_set_name(&dev->dev, "nfc%d", dev->idx); - device_initialize(&dev->dev); - - dev->ops = ops; - dev->supported_protocols = supported_protocols; - - spin_lock_init(&dev->targets_lock); - nfc_genl_data_init(&dev->genl_data); - - /* first generation must not be 0 */ - dev->targets_generation = 1; - - return dev; -} -EXPORT_SYMBOL(nfc_allocate_device); - -/** - * nfc_register_device - register a nfc device in the nfc subsystem - * - * @dev: The nfc device to register - */ -int nfc_register_device(struct nfc_dev *dev) -{ - int rc; - - nfc_dbg("dev_name=%s", dev_name(&dev->dev)); - - mutex_lock(&nfc_devlist_mutex); - nfc_devlist_generation++; - rc = device_add(&dev->dev); - mutex_unlock(&nfc_devlist_mutex); - - if (rc < 0) - return rc; - - rc = nfc_genl_device_added(dev); - if (rc) - nfc_dbg("The userspace won't be notified that the device %s was" - " added", dev_name(&dev->dev)); - - - return 0; -} -EXPORT_SYMBOL(nfc_register_device); - -/** - * nfc_unregister_device - unregister a nfc device in the nfc subsystem - * - * @dev: The nfc device to unregister - */ -void nfc_unregister_device(struct nfc_dev *dev) -{ - int rc; - - nfc_dbg("dev_name=%s", dev_name(&dev->dev)); - - mutex_lock(&nfc_devlist_mutex); - nfc_devlist_generation++; - - /* lock to avoid unregistering a device while an operation - is in progress */ - device_lock(&dev->dev); - device_del(&dev->dev); - device_unlock(&dev->dev); - - mutex_unlock(&nfc_devlist_mutex); - - rc = nfc_genl_device_removed(dev); - if (rc) - nfc_dbg("The userspace won't be notified that the device %s" - " was removed", dev_name(&dev->dev)); - -} -EXPORT_SYMBOL(nfc_unregister_device); - -static int __init nfc_init(void) -{ - int rc; - - nfc_info("NFC Core ver %s", VERSION); - - rc = class_register(&nfc_class); - if (rc) - return rc; - - rc = nfc_genl_init(); - if (rc) - goto err_genl; - - /* the first generation must not be 0 */ - nfc_devlist_generation = 1; - - rc = rawsock_init(); - if (rc) - goto err_rawsock; - - rc = af_nfc_init(); - if (rc) - goto err_af_nfc; - - return 0; - -err_af_nfc: - rawsock_exit(); -err_rawsock: - nfc_genl_exit(); -err_genl: - class_unregister(&nfc_class); - return rc; -} - -static void __exit nfc_exit(void) -{ - af_nfc_exit(); - rawsock_exit(); - nfc_genl_exit(); - class_unregister(&nfc_class); -} - -subsys_initcall(nfc_init); -module_exit(nfc_exit); - -MODULE_AUTHOR("Lauro Ramos Venancio "); -MODULE_DESCRIPTION("NFC Core ver " VERSION); -MODULE_VERSION(VERSION); -MODULE_LICENSE("GPL"); diff --git a/trunk/net/nfc/netlink.c b/trunk/net/nfc/netlink.c deleted file mode 100644 index ccdff7953f7d..000000000000 --- a/trunk/net/nfc/netlink.c +++ /dev/null @@ -1,537 +0,0 @@ -/* - * Copyright (C) 2011 Instituto Nokia de Tecnologia - * - * Authors: - * Lauro Ramos Venancio - * Aloisio Almeida Jr - * - * 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. - * - * 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., - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include -#include -#include - -#include "nfc.h" - -static struct genl_multicast_group nfc_genl_event_mcgrp = { - .name = NFC_GENL_MCAST_EVENT_NAME, -}; - -struct genl_family nfc_genl_family = { - .id = GENL_ID_GENERATE, - .hdrsize = 0, - .name = NFC_GENL_NAME, - .version = NFC_GENL_VERSION, - .maxattr = NFC_ATTR_MAX, -}; - -static const struct nla_policy nfc_genl_policy[NFC_ATTR_MAX + 1] = { - [NFC_ATTR_DEVICE_INDEX] = { .type = NLA_U32 }, - [NFC_ATTR_DEVICE_NAME] = { .type = NLA_STRING, - .len = NFC_DEVICE_NAME_MAXSIZE }, - [NFC_ATTR_PROTOCOLS] = { .type = NLA_U32 }, -}; - -static int nfc_genl_send_target(struct sk_buff *msg, struct nfc_target *target, - struct netlink_callback *cb, int flags) -{ - void *hdr; - - nfc_dbg("entry"); - - hdr = genlmsg_put(msg, NETLINK_CB(cb->skb).pid, cb->nlh->nlmsg_seq, - &nfc_genl_family, flags, NFC_CMD_GET_TARGET); - if (!hdr) - return -EMSGSIZE; - - genl_dump_check_consistent(cb, hdr, &nfc_genl_family); - - NLA_PUT_U32(msg, NFC_ATTR_TARGET_INDEX, target->idx); - NLA_PUT_U32(msg, NFC_ATTR_PROTOCOLS, - target->supported_protocols); - NLA_PUT_U16(msg, NFC_ATTR_TARGET_SENS_RES, target->sens_res); - NLA_PUT_U8(msg, NFC_ATTR_TARGET_SEL_RES, target->sel_res); - - return genlmsg_end(msg, hdr); - -nla_put_failure: - genlmsg_cancel(msg, hdr); - return -EMSGSIZE; -} - -static struct nfc_dev *__get_device_from_cb(struct netlink_callback *cb) -{ - struct nfc_dev *dev; - int rc; - u32 idx; - - rc = nlmsg_parse(cb->nlh, GENL_HDRLEN + nfc_genl_family.hdrsize, - nfc_genl_family.attrbuf, - nfc_genl_family.maxattr, - nfc_genl_policy); - if (rc < 0) - return ERR_PTR(rc); - - if (!nfc_genl_family.attrbuf[NFC_ATTR_DEVICE_INDEX]) - return ERR_PTR(-EINVAL); - - idx = nla_get_u32(nfc_genl_family.attrbuf[NFC_ATTR_DEVICE_INDEX]); - - dev = nfc_get_device(idx); - if (!dev) - return ERR_PTR(-ENODEV); - - return dev; -} - -static int nfc_genl_dump_targets(struct sk_buff *skb, - struct netlink_callback *cb) -{ - int i = cb->args[0]; - struct nfc_dev *dev = (struct nfc_dev *) cb->args[1]; - int rc; - - nfc_dbg("entry"); - - if (!dev) { - dev = __get_device_from_cb(cb); - if (IS_ERR(dev)) - return PTR_ERR(dev); - - cb->args[1] = (long) dev; - } - - spin_lock_bh(&dev->targets_lock); - - cb->seq = dev->targets_generation; - - while (i < dev->n_targets) { - rc = nfc_genl_send_target(skb, &dev->targets[i], cb, - NLM_F_MULTI); - if (rc < 0) - break; - - i++; - } - - spin_unlock_bh(&dev->targets_lock); - - cb->args[0] = i; - - return skb->len; -} - -static int nfc_genl_dump_targets_done(struct netlink_callback *cb) -{ - struct nfc_dev *dev = (struct nfc_dev *) cb->args[1]; - - nfc_dbg("entry"); - - if (dev) - nfc_put_device(dev); - - return 0; -} - -int nfc_genl_targets_found(struct nfc_dev *dev) -{ - struct sk_buff *msg; - void *hdr; - - nfc_dbg("entry"); - - dev->genl_data.poll_req_pid = 0; - - msg = nlmsg_new(NLMSG_GOODSIZE, GFP_ATOMIC); - if (!msg) - return -ENOMEM; - - hdr = genlmsg_put(msg, 0, 0, &nfc_genl_family, 0, - NFC_EVENT_TARGETS_FOUND); - if (!hdr) - goto free_msg; - - NLA_PUT_U32(msg, NFC_ATTR_DEVICE_INDEX, dev->idx); - - genlmsg_end(msg, hdr); - - return genlmsg_multicast(msg, 0, nfc_genl_event_mcgrp.id, GFP_ATOMIC); - -nla_put_failure: - genlmsg_cancel(msg, hdr); -free_msg: - nlmsg_free(msg); - return -EMSGSIZE; -} - -int nfc_genl_device_added(struct nfc_dev *dev) -{ - struct sk_buff *msg; - void *hdr; - - nfc_dbg("entry"); - - msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); - if (!msg) - return -ENOMEM; - - hdr = genlmsg_put(msg, 0, 0, &nfc_genl_family, 0, - NFC_EVENT_DEVICE_ADDED); - if (!hdr) - goto free_msg; - - NLA_PUT_STRING(msg, NFC_ATTR_DEVICE_NAME, nfc_device_name(dev)); - NLA_PUT_U32(msg, NFC_ATTR_DEVICE_INDEX, dev->idx); - NLA_PUT_U32(msg, NFC_ATTR_PROTOCOLS, dev->supported_protocols); - - genlmsg_end(msg, hdr); - - genlmsg_multicast(msg, 0, nfc_genl_event_mcgrp.id, GFP_KERNEL); - - return 0; - -nla_put_failure: - genlmsg_cancel(msg, hdr); -free_msg: - nlmsg_free(msg); - return -EMSGSIZE; -} - -int nfc_genl_device_removed(struct nfc_dev *dev) -{ - struct sk_buff *msg; - void *hdr; - - nfc_dbg("entry"); - - msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); - if (!msg) - return -ENOMEM; - - hdr = genlmsg_put(msg, 0, 0, &nfc_genl_family, 0, - NFC_EVENT_DEVICE_REMOVED); - if (!hdr) - goto free_msg; - - NLA_PUT_U32(msg, NFC_ATTR_DEVICE_INDEX, dev->idx); - - genlmsg_end(msg, hdr); - - genlmsg_multicast(msg, 0, nfc_genl_event_mcgrp.id, GFP_KERNEL); - - return 0; - -nla_put_failure: - genlmsg_cancel(msg, hdr); -free_msg: - nlmsg_free(msg); - return -EMSGSIZE; -} - -static int nfc_genl_send_device(struct sk_buff *msg, struct nfc_dev *dev, - u32 pid, u32 seq, - struct netlink_callback *cb, - int flags) -{ - void *hdr; - - nfc_dbg("entry"); - - hdr = genlmsg_put(msg, pid, seq, &nfc_genl_family, flags, - NFC_CMD_GET_DEVICE); - if (!hdr) - return -EMSGSIZE; - - if (cb) - genl_dump_check_consistent(cb, hdr, &nfc_genl_family); - - NLA_PUT_STRING(msg, NFC_ATTR_DEVICE_NAME, nfc_device_name(dev)); - NLA_PUT_U32(msg, NFC_ATTR_DEVICE_INDEX, dev->idx); - NLA_PUT_U32(msg, NFC_ATTR_PROTOCOLS, dev->supported_protocols); - - return genlmsg_end(msg, hdr); - -nla_put_failure: - genlmsg_cancel(msg, hdr); - return -EMSGSIZE; -} - -static int nfc_genl_dump_devices(struct sk_buff *skb, - struct netlink_callback *cb) -{ - struct class_dev_iter *iter = (struct class_dev_iter *) cb->args[0]; - struct nfc_dev *dev = (struct nfc_dev *) cb->args[1]; - bool first_call = false; - - nfc_dbg("entry"); - - if (!iter) { - first_call = true; - iter = kmalloc(sizeof(struct class_dev_iter), GFP_KERNEL); - if (!iter) - return -ENOMEM; - cb->args[0] = (long) iter; - } - - mutex_lock(&nfc_devlist_mutex); - - cb->seq = nfc_devlist_generation; - - if (first_call) { - nfc_device_iter_init(iter); - dev = nfc_device_iter_next(iter); - } - - while (dev) { - int rc; - - rc = nfc_genl_send_device(skb, dev, NETLINK_CB(cb->skb).pid, - cb->nlh->nlmsg_seq, - cb, NLM_F_MULTI); - if (rc < 0) - break; - - dev = nfc_device_iter_next(iter); - } - - mutex_unlock(&nfc_devlist_mutex); - - cb->args[1] = (long) dev; - - return skb->len; -} - -static int nfc_genl_dump_devices_done(struct netlink_callback *cb) -{ - struct class_dev_iter *iter = (struct class_dev_iter *) cb->args[0]; - - nfc_dbg("entry"); - - nfc_device_iter_exit(iter); - kfree(iter); - - return 0; -} - -static int nfc_genl_get_device(struct sk_buff *skb, struct genl_info *info) -{ - struct sk_buff *msg; - struct nfc_dev *dev; - u32 idx; - int rc = -ENOBUFS; - - nfc_dbg("entry"); - - if (!info->attrs[NFC_ATTR_DEVICE_INDEX]) - return -EINVAL; - - idx = nla_get_u32(info->attrs[NFC_ATTR_DEVICE_INDEX]); - - dev = nfc_get_device(idx); - if (!dev) - return -ENODEV; - - msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); - if (!msg) { - rc = -ENOMEM; - goto out_putdev; - } - - rc = nfc_genl_send_device(msg, dev, info->snd_pid, info->snd_seq, - NULL, 0); - if (rc < 0) - goto out_free; - - nfc_put_device(dev); - - return genlmsg_reply(msg, info); - -out_free: - nlmsg_free(msg); -out_putdev: - nfc_put_device(dev); - return rc; -} - -static int nfc_genl_start_poll(struct sk_buff *skb, struct genl_info *info) -{ - struct nfc_dev *dev; - int rc; - u32 idx; - u32 protocols; - - nfc_dbg("entry"); - - if (!info->attrs[NFC_ATTR_DEVICE_INDEX] || - !info->attrs[NFC_ATTR_PROTOCOLS]) - return -EINVAL; - - idx = nla_get_u32(info->attrs[NFC_ATTR_DEVICE_INDEX]); - protocols = nla_get_u32(info->attrs[NFC_ATTR_PROTOCOLS]); - - dev = nfc_get_device(idx); - if (!dev) - return -ENODEV; - - mutex_lock(&dev->genl_data.genl_data_mutex); - - rc = nfc_start_poll(dev, protocols); - if (!rc) - dev->genl_data.poll_req_pid = info->snd_pid; - - mutex_unlock(&dev->genl_data.genl_data_mutex); - - nfc_put_device(dev); - return rc; -} - -static int nfc_genl_stop_poll(struct sk_buff *skb, struct genl_info *info) -{ - struct nfc_dev *dev; - int rc; - u32 idx; - - nfc_dbg("entry"); - - if (!info->attrs[NFC_ATTR_DEVICE_INDEX]) - return -EINVAL; - - idx = nla_get_u32(info->attrs[NFC_ATTR_DEVICE_INDEX]); - - dev = nfc_get_device(idx); - if (!dev) - return -ENODEV; - - mutex_lock(&dev->genl_data.genl_data_mutex); - - if (dev->genl_data.poll_req_pid != info->snd_pid) { - rc = -EBUSY; - goto out; - } - - rc = nfc_stop_poll(dev); - dev->genl_data.poll_req_pid = 0; - -out: - mutex_unlock(&dev->genl_data.genl_data_mutex); - nfc_put_device(dev); - return rc; -} - -static struct genl_ops nfc_genl_ops[] = { - { - .cmd = NFC_CMD_GET_DEVICE, - .doit = nfc_genl_get_device, - .dumpit = nfc_genl_dump_devices, - .done = nfc_genl_dump_devices_done, - .policy = nfc_genl_policy, - }, - { - .cmd = NFC_CMD_START_POLL, - .doit = nfc_genl_start_poll, - .policy = nfc_genl_policy, - }, - { - .cmd = NFC_CMD_STOP_POLL, - .doit = nfc_genl_stop_poll, - .policy = nfc_genl_policy, - }, - { - .cmd = NFC_CMD_GET_TARGET, - .dumpit = nfc_genl_dump_targets, - .done = nfc_genl_dump_targets_done, - .policy = nfc_genl_policy, - }, -}; - -static int nfc_genl_rcv_nl_event(struct notifier_block *this, - unsigned long event, void *ptr) -{ - struct netlink_notify *n = ptr; - struct class_dev_iter iter; - struct nfc_dev *dev; - - if (event != NETLINK_URELEASE || n->protocol != NETLINK_GENERIC) - goto out; - - nfc_dbg("NETLINK_URELEASE event from id %d", n->pid); - - nfc_device_iter_init(&iter); - dev = nfc_device_iter_next(&iter); - - while (dev) { - mutex_lock(&dev->genl_data.genl_data_mutex); - if (dev->genl_data.poll_req_pid == n->pid) { - nfc_stop_poll(dev); - dev->genl_data.poll_req_pid = 0; - } - mutex_unlock(&dev->genl_data.genl_data_mutex); - dev = nfc_device_iter_next(&iter); - } - - nfc_device_iter_exit(&iter); - -out: - return NOTIFY_DONE; -} - -void nfc_genl_data_init(struct nfc_genl_data *genl_data) -{ - genl_data->poll_req_pid = 0; - mutex_init(&genl_data->genl_data_mutex); -} - -void nfc_genl_data_exit(struct nfc_genl_data *genl_data) -{ - mutex_destroy(&genl_data->genl_data_mutex); -} - -static struct notifier_block nl_notifier = { - .notifier_call = nfc_genl_rcv_nl_event, -}; - -/** - * nfc_genl_init() - Initialize netlink interface - * - * This initialization function registers the nfc netlink family. - */ -int __init nfc_genl_init(void) -{ - int rc; - - rc = genl_register_family_with_ops(&nfc_genl_family, nfc_genl_ops, - ARRAY_SIZE(nfc_genl_ops)); - if (rc) - return rc; - - rc = genl_register_mc_group(&nfc_genl_family, &nfc_genl_event_mcgrp); - - netlink_register_notifier(&nl_notifier); - - return rc; -} - -/** - * nfc_genl_exit() - Deinitialize netlink interface - * - * This exit function unregisters the nfc netlink family. - */ -void nfc_genl_exit(void) -{ - netlink_unregister_notifier(&nl_notifier); - genl_unregister_family(&nfc_genl_family); -} diff --git a/trunk/net/nfc/nfc.h b/trunk/net/nfc/nfc.h deleted file mode 100644 index aaf9832298f3..000000000000 --- a/trunk/net/nfc/nfc.h +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright (C) 2011 Instituto Nokia de Tecnologia - * - * Authors: - * Lauro Ramos Venancio - * Aloisio Almeida Jr - * - * 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. - * - * 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., - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef __LOCAL_NFC_H -#define __LOCAL_NFC_H - -#include -#include - -__attribute__((format (printf, 2, 3))) -int nfc_printk(const char *level, const char *fmt, ...); - -#define nfc_info(fmt, arg...) nfc_printk(KERN_INFO, fmt, ##arg) -#define nfc_err(fmt, arg...) nfc_printk(KERN_ERR, fmt, ##arg) -#define nfc_dbg(fmt, arg...) pr_debug(fmt "\n", ##arg) - -struct nfc_protocol { - int id; - struct proto *proto; - struct module *owner; - int (*create)(struct net *net, struct socket *sock, - const struct nfc_protocol *nfc_proto); -}; - -struct nfc_rawsock { - struct sock sk; - struct nfc_dev *dev; - u32 target_idx; - struct work_struct tx_work; - bool tx_work_scheduled; -}; -#define nfc_rawsock(sk) ((struct nfc_rawsock *) sk) -#define to_rawsock_sk(_tx_work) \ - ((struct sock *) container_of(_tx_work, struct nfc_rawsock, tx_work)) - -int __init rawsock_init(void); -void rawsock_exit(void); - -int __init af_nfc_init(void); -void af_nfc_exit(void); -int nfc_proto_register(const struct nfc_protocol *nfc_proto); -void nfc_proto_unregister(const struct nfc_protocol *nfc_proto); - -extern int nfc_devlist_generation; -extern struct mutex nfc_devlist_mutex; - -int __init nfc_genl_init(void); -void nfc_genl_exit(void); - -void nfc_genl_data_init(struct nfc_genl_data *genl_data); -void nfc_genl_data_exit(struct nfc_genl_data *genl_data); - -int nfc_genl_targets_found(struct nfc_dev *dev); - -int nfc_genl_device_added(struct nfc_dev *dev); -int nfc_genl_device_removed(struct nfc_dev *dev); - -struct nfc_dev *nfc_get_device(unsigned idx); - -static inline void nfc_put_device(struct nfc_dev *dev) -{ - put_device(&dev->dev); -} - -static inline void nfc_device_iter_init(struct class_dev_iter *iter) -{ - class_dev_iter_init(iter, &nfc_class, NULL, NULL); -} - -static inline struct nfc_dev *nfc_device_iter_next(struct class_dev_iter *iter) -{ - struct device *d = class_dev_iter_next(iter); - if (!d) - return NULL; - - return to_nfc_dev(d); -} - -static inline void nfc_device_iter_exit(struct class_dev_iter *iter) -{ - class_dev_iter_exit(iter); -} - -int nfc_start_poll(struct nfc_dev *dev, u32 protocols); - -int nfc_stop_poll(struct nfc_dev *dev); - -int nfc_activate_target(struct nfc_dev *dev, u32 target_idx, u32 protocol); - -int nfc_deactivate_target(struct nfc_dev *dev, u32 target_idx); - -int nfc_data_exchange(struct nfc_dev *dev, u32 target_idx, - struct sk_buff *skb, - data_exchange_cb_t cb, - void *cb_context); - -#endif /* __LOCAL_NFC_H */ diff --git a/trunk/net/nfc/rawsock.c b/trunk/net/nfc/rawsock.c deleted file mode 100644 index 52de84a55115..000000000000 --- a/trunk/net/nfc/rawsock.c +++ /dev/null @@ -1,354 +0,0 @@ -/* - * Copyright (C) 2011 Instituto Nokia de Tecnologia - * - * Authors: - * Aloisio Almeida Jr - * Lauro Ramos Venancio - * - * 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. - * - * 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., - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include -#include - -#include "nfc.h" - -static void rawsock_write_queue_purge(struct sock *sk) -{ - nfc_dbg("sk=%p", sk); - - spin_lock_bh(&sk->sk_write_queue.lock); - __skb_queue_purge(&sk->sk_write_queue); - nfc_rawsock(sk)->tx_work_scheduled = false; - spin_unlock_bh(&sk->sk_write_queue.lock); -} - -static void rawsock_report_error(struct sock *sk, int err) -{ - nfc_dbg("sk=%p err=%d", sk, err); - - sk->sk_shutdown = SHUTDOWN_MASK; - sk->sk_err = -err; - sk->sk_error_report(sk); - - rawsock_write_queue_purge(sk); -} - -static int rawsock_release(struct socket *sock) -{ - struct sock *sk = sock->sk; - - nfc_dbg("sock=%p", sock); - - sock_orphan(sk); - sock_put(sk); - - return 0; -} - -static int rawsock_connect(struct socket *sock, struct sockaddr *_addr, - int len, int flags) -{ - struct sock *sk = sock->sk; - struct sockaddr_nfc *addr = (struct sockaddr_nfc *)_addr; - struct nfc_dev *dev; - int rc = 0; - - nfc_dbg("sock=%p sk=%p flags=%d", sock, sk, flags); - - if (!addr || len < sizeof(struct sockaddr_nfc) || - addr->sa_family != AF_NFC) - return -EINVAL; - - nfc_dbg("addr dev_idx=%u target_idx=%u protocol=%u", addr->dev_idx, - addr->target_idx, addr->nfc_protocol); - - lock_sock(sk); - - if (sock->state == SS_CONNECTED) { - rc = -EISCONN; - goto error; - } - - dev = nfc_get_device(addr->dev_idx); - if (!dev) { - rc = -ENODEV; - goto error; - } - - if (addr->target_idx > dev->target_idx - 1 || - addr->target_idx < dev->target_idx - dev->n_targets) { - rc = -EINVAL; - goto error; - } - - if (addr->target_idx > dev->target_idx - 1 || - addr->target_idx < dev->target_idx - dev->n_targets) { - rc = -EINVAL; - goto error; - } - - rc = nfc_activate_target(dev, addr->target_idx, addr->nfc_protocol); - if (rc) - goto put_dev; - - nfc_rawsock(sk)->dev = dev; - nfc_rawsock(sk)->target_idx = addr->target_idx; - sock->state = SS_CONNECTED; - sk->sk_state = TCP_ESTABLISHED; - sk->sk_state_change(sk); - - release_sock(sk); - return 0; - -put_dev: - nfc_put_device(dev); -error: - release_sock(sk); - return rc; -} - -static int rawsock_add_header(struct sk_buff *skb) -{ - - if (skb_cow_head(skb, 1)) - return -ENOMEM; - - *skb_push(skb, 1) = 0; - - return 0; -} - -static void rawsock_data_exchange_complete(void *context, struct sk_buff *skb, - int err) -{ - struct sock *sk = (struct sock *) context; - - BUG_ON(in_irq()); - - nfc_dbg("sk=%p err=%d", sk, err); - - if (err) - goto error; - - err = rawsock_add_header(skb); - if (err) - goto error; - - err = sock_queue_rcv_skb(sk, skb); - if (err) - goto error; - - spin_lock_bh(&sk->sk_write_queue.lock); - if (!skb_queue_empty(&sk->sk_write_queue)) - schedule_work(&nfc_rawsock(sk)->tx_work); - else - nfc_rawsock(sk)->tx_work_scheduled = false; - spin_unlock_bh(&sk->sk_write_queue.lock); - - sock_put(sk); - return; - -error: - rawsock_report_error(sk, err); - sock_put(sk); -} - -static void rawsock_tx_work(struct work_struct *work) -{ - struct sock *sk = to_rawsock_sk(work); - struct nfc_dev *dev = nfc_rawsock(sk)->dev; - u32 target_idx = nfc_rawsock(sk)->target_idx; - struct sk_buff *skb; - int rc; - - nfc_dbg("sk=%p target_idx=%u", sk, target_idx); - - if (sk->sk_shutdown & SEND_SHUTDOWN) { - rawsock_write_queue_purge(sk); - return; - } - - skb = skb_dequeue(&sk->sk_write_queue); - - sock_hold(sk); - rc = nfc_data_exchange(dev, target_idx, skb, - rawsock_data_exchange_complete, sk); - if (rc) { - rawsock_report_error(sk, rc); - sock_put(sk); - } -} - -static int rawsock_sendmsg(struct kiocb *iocb, struct socket *sock, - struct msghdr *msg, size_t len) -{ - struct sock *sk = sock->sk; - struct sk_buff *skb; - int rc; - - nfc_dbg("sock=%p sk=%p len=%zu", sock, sk, len); - - if (msg->msg_namelen) - return -EOPNOTSUPP; - - if (sock->state != SS_CONNECTED) - return -ENOTCONN; - - skb = sock_alloc_send_skb(sk, len, msg->msg_flags & MSG_DONTWAIT, - &rc); - if (!skb) - return rc; - - rc = memcpy_fromiovec(skb_put(skb, len), msg->msg_iov, len); - if (rc < 0) { - kfree_skb(skb); - return rc; - } - - spin_lock_bh(&sk->sk_write_queue.lock); - __skb_queue_tail(&sk->sk_write_queue, skb); - if (!nfc_rawsock(sk)->tx_work_scheduled) { - schedule_work(&nfc_rawsock(sk)->tx_work); - nfc_rawsock(sk)->tx_work_scheduled = true; - } - spin_unlock_bh(&sk->sk_write_queue.lock); - - return len; -} - -static int rawsock_recvmsg(struct kiocb *iocb, struct socket *sock, - struct msghdr *msg, size_t len, int flags) -{ - int noblock = flags & MSG_DONTWAIT; - struct sock *sk = sock->sk; - struct sk_buff *skb; - int copied; - int rc; - - nfc_dbg("sock=%p sk=%p len=%zu flags=%d", sock, sk, len, flags); - - skb = skb_recv_datagram(sk, flags, noblock, &rc); - if (!skb) - return rc; - - msg->msg_namelen = 0; - - copied = skb->len; - if (len < copied) { - msg->msg_flags |= MSG_TRUNC; - copied = len; - } - - rc = skb_copy_datagram_iovec(skb, 0, msg->msg_iov, copied); - - skb_free_datagram(sk, skb); - - return rc ? : copied; -} - - -static const struct proto_ops rawsock_ops = { - .family = PF_NFC, - .owner = THIS_MODULE, - .release = rawsock_release, - .bind = sock_no_bind, - .connect = rawsock_connect, - .socketpair = sock_no_socketpair, - .accept = sock_no_accept, - .getname = sock_no_getname, - .poll = datagram_poll, - .ioctl = sock_no_ioctl, - .listen = sock_no_listen, - .shutdown = sock_no_shutdown, - .setsockopt = sock_no_setsockopt, - .getsockopt = sock_no_getsockopt, - .sendmsg = rawsock_sendmsg, - .recvmsg = rawsock_recvmsg, - .mmap = sock_no_mmap, -}; - -static void rawsock_destruct(struct sock *sk) -{ - nfc_dbg("sk=%p", sk); - - if (sk->sk_state == TCP_ESTABLISHED) { - nfc_deactivate_target(nfc_rawsock(sk)->dev, - nfc_rawsock(sk)->target_idx); - nfc_put_device(nfc_rawsock(sk)->dev); - } - - skb_queue_purge(&sk->sk_receive_queue); - - if (!sock_flag(sk, SOCK_DEAD)) { - nfc_err("Freeing alive NFC raw socket %p", sk); - return; - } -} - -static int rawsock_create(struct net *net, struct socket *sock, - const struct nfc_protocol *nfc_proto) -{ - struct sock *sk; - - nfc_dbg("sock=%p", sock); - - if (sock->type != SOCK_SEQPACKET) - return -ESOCKTNOSUPPORT; - - sock->ops = &rawsock_ops; - - sk = sk_alloc(net, PF_NFC, GFP_KERNEL, nfc_proto->proto); - if (!sk) - return -ENOMEM; - - sock_init_data(sock, sk); - sk->sk_protocol = nfc_proto->id; - sk->sk_destruct = rawsock_destruct; - sock->state = SS_UNCONNECTED; - - INIT_WORK(&nfc_rawsock(sk)->tx_work, rawsock_tx_work); - nfc_rawsock(sk)->tx_work_scheduled = false; - - return 0; -} - -static struct proto rawsock_proto = { - .name = "NFC_RAW", - .owner = THIS_MODULE, - .obj_size = sizeof(struct nfc_rawsock), -}; - -static const struct nfc_protocol rawsock_nfc_proto = { - .id = NFC_SOCKPROTO_RAW, - .proto = &rawsock_proto, - .owner = THIS_MODULE, - .create = rawsock_create -}; - -int __init rawsock_init(void) -{ - int rc; - - rc = nfc_proto_register(&rawsock_nfc_proto); - - return rc; -} - -void rawsock_exit(void) -{ - nfc_proto_unregister(&rawsock_nfc_proto); -} diff --git a/trunk/net/packet/af_packet.c b/trunk/net/packet/af_packet.c index c698cec0a445..461b16fa1c52 100644 --- a/trunk/net/packet/af_packet.c +++ b/trunk/net/packet/af_packet.c @@ -187,11 +187,9 @@ static int tpacket_snd(struct packet_sock *po, struct msghdr *msg); static void packet_flush_mclist(struct sock *sk); -struct packet_fanout; struct packet_sock { /* struct sock has to be the first member of packet_sock */ struct sock sk; - struct packet_fanout *fanout; struct tpacket_stats stats; struct packet_ring_buffer rx_ring; struct packet_ring_buffer tx_ring; @@ -214,24 +212,6 @@ struct packet_sock { struct packet_type prot_hook ____cacheline_aligned_in_smp; }; -#define PACKET_FANOUT_MAX 256 - -struct packet_fanout { -#ifdef CONFIG_NET_NS - struct net *net; -#endif - unsigned int num_members; - u16 id; - u8 type; - u8 defrag; - atomic_t rr_cur; - struct list_head list; - struct sock *arr[PACKET_FANOUT_MAX]; - spinlock_t lock; - atomic_t sk_ref; - struct packet_type prot_hook ____cacheline_aligned_in_smp; -}; - struct packet_skb_cb { unsigned int origlen; union { @@ -242,64 +222,6 @@ struct packet_skb_cb { #define PACKET_SKB_CB(__skb) ((struct packet_skb_cb *)((__skb)->cb)) -static inline struct packet_sock *pkt_sk(struct sock *sk) -{ - return (struct packet_sock *)sk; -} - -static void __fanout_unlink(struct sock *sk, struct packet_sock *po); -static void __fanout_link(struct sock *sk, struct packet_sock *po); - -/* register_prot_hook must be invoked with the po->bind_lock held, - * or from a context in which asynchronous accesses to the packet - * socket is not possible (packet_create()). - */ -static void register_prot_hook(struct sock *sk) -{ - struct packet_sock *po = pkt_sk(sk); - if (!po->running) { - if (po->fanout) - __fanout_link(sk, po); - else - dev_add_pack(&po->prot_hook); - sock_hold(sk); - po->running = 1; - } -} - -/* {,__}unregister_prot_hook() must be invoked with the po->bind_lock - * held. If the sync parameter is true, we will temporarily drop - * the po->bind_lock and do a synchronize_net to make sure no - * asynchronous packet processing paths still refer to the elements - * of po->prot_hook. If the sync parameter is false, it is the - * callers responsibility to take care of this. - */ -static void __unregister_prot_hook(struct sock *sk, bool sync) -{ - struct packet_sock *po = pkt_sk(sk); - - po->running = 0; - if (po->fanout) - __fanout_unlink(sk, po); - else - __dev_remove_pack(&po->prot_hook); - __sock_put(sk); - - if (sync) { - spin_unlock(&po->bind_lock); - synchronize_net(); - spin_lock(&po->bind_lock); - } -} - -static void unregister_prot_hook(struct sock *sk, bool sync) -{ - struct packet_sock *po = pkt_sk(sk); - - if (po->running) - __unregister_prot_hook(sk, sync); -} - static inline __pure struct page *pgv_to_page(void *addr) { if (is_vmalloc_addr(addr)) @@ -402,6 +324,11 @@ static inline void packet_increment_head(struct packet_ring_buffer *buff) buff->head = buff->head != buff->frame_max ? buff->head+1 : 0; } +static inline struct packet_sock *pkt_sk(struct sock *sk) +{ + return (struct packet_sock *)sk; +} + static void packet_sock_destruct(struct sock *sk) { skb_queue_purge(&sk->sk_error_queue); @@ -417,240 +344,6 @@ static void packet_sock_destruct(struct sock *sk) sk_refcnt_debug_dec(sk); } -static int fanout_rr_next(struct packet_fanout *f, unsigned int num) -{ - int x = atomic_read(&f->rr_cur) + 1; - - if (x >= num) - x = 0; - - return x; -} - -static struct sock *fanout_demux_hash(struct packet_fanout *f, struct sk_buff *skb, unsigned int num) -{ - u32 idx, hash = skb->rxhash; - - idx = ((u64)hash * num) >> 32; - - return f->arr[idx]; -} - -static struct sock *fanout_demux_lb(struct packet_fanout *f, struct sk_buff *skb, unsigned int num) -{ - int cur, old; - - cur = atomic_read(&f->rr_cur); - while ((old = atomic_cmpxchg(&f->rr_cur, cur, - fanout_rr_next(f, num))) != cur) - cur = old; - return f->arr[cur]; -} - -static struct sock *fanout_demux_cpu(struct packet_fanout *f, struct sk_buff *skb, unsigned int num) -{ - unsigned int cpu = smp_processor_id(); - - return f->arr[cpu % num]; -} - -static struct sk_buff *fanout_check_defrag(struct sk_buff *skb) -{ -#ifdef CONFIG_INET - const struct iphdr *iph; - u32 len; - - if (skb->protocol != htons(ETH_P_IP)) - return skb; - - if (!pskb_may_pull(skb, sizeof(struct iphdr))) - return skb; - - iph = ip_hdr(skb); - if (iph->ihl < 5 || iph->version != 4) - return skb; - if (!pskb_may_pull(skb, iph->ihl*4)) - return skb; - iph = ip_hdr(skb); - len = ntohs(iph->tot_len); - if (skb->len < len || len < (iph->ihl * 4)) - return skb; - - if (ip_is_fragment(ip_hdr(skb))) { - skb = skb_share_check(skb, GFP_ATOMIC); - if (skb) { - if (pskb_trim_rcsum(skb, len)) - return skb; - memset(IPCB(skb), 0, sizeof(struct inet_skb_parm)); - if (ip_defrag(skb, IP_DEFRAG_AF_PACKET)) - return NULL; - skb->rxhash = 0; - } - } -#endif - return skb; -} - -static int packet_rcv_fanout(struct sk_buff *skb, struct net_device *dev, - struct packet_type *pt, struct net_device *orig_dev) -{ - struct packet_fanout *f = pt->af_packet_priv; - unsigned int num = f->num_members; - struct packet_sock *po; - struct sock *sk; - - if (!net_eq(dev_net(dev), read_pnet(&f->net)) || - !num) { - kfree_skb(skb); - return 0; - } - - switch (f->type) { - case PACKET_FANOUT_HASH: - default: - if (f->defrag) { - skb = fanout_check_defrag(skb); - if (!skb) - return 0; - } - skb_get_rxhash(skb); - sk = fanout_demux_hash(f, skb, num); - break; - case PACKET_FANOUT_LB: - sk = fanout_demux_lb(f, skb, num); - break; - case PACKET_FANOUT_CPU: - sk = fanout_demux_cpu(f, skb, num); - break; - } - - po = pkt_sk(sk); - - return po->prot_hook.func(skb, dev, &po->prot_hook, orig_dev); -} - -static DEFINE_MUTEX(fanout_mutex); -static LIST_HEAD(fanout_list); - -static void __fanout_link(struct sock *sk, struct packet_sock *po) -{ - struct packet_fanout *f = po->fanout; - - spin_lock(&f->lock); - f->arr[f->num_members] = sk; - smp_wmb(); - f->num_members++; - spin_unlock(&f->lock); -} - -static void __fanout_unlink(struct sock *sk, struct packet_sock *po) -{ - struct packet_fanout *f = po->fanout; - int i; - - spin_lock(&f->lock); - for (i = 0; i < f->num_members; i++) { - if (f->arr[i] == sk) - break; - } - BUG_ON(i >= f->num_members); - f->arr[i] = f->arr[f->num_members - 1]; - f->num_members--; - spin_unlock(&f->lock); -} - -static int fanout_add(struct sock *sk, u16 id, u16 type_flags) -{ - struct packet_sock *po = pkt_sk(sk); - struct packet_fanout *f, *match; - u8 type = type_flags & 0xff; - u8 defrag = (type_flags & PACKET_FANOUT_FLAG_DEFRAG) ? 1 : 0; - int err; - - switch (type) { - case PACKET_FANOUT_HASH: - case PACKET_FANOUT_LB: - case PACKET_FANOUT_CPU: - break; - default: - return -EINVAL; - } - - if (!po->running) - return -EINVAL; - - if (po->fanout) - return -EALREADY; - - mutex_lock(&fanout_mutex); - match = NULL; - list_for_each_entry(f, &fanout_list, list) { - if (f->id == id && - read_pnet(&f->net) == sock_net(sk)) { - match = f; - break; - } - } - err = -EINVAL; - if (match && match->defrag != defrag) - goto out; - if (!match) { - err = -ENOMEM; - match = kzalloc(sizeof(*match), GFP_KERNEL); - if (!match) - goto out; - write_pnet(&match->net, sock_net(sk)); - match->id = id; - match->type = type; - match->defrag = defrag; - atomic_set(&match->rr_cur, 0); - INIT_LIST_HEAD(&match->list); - spin_lock_init(&match->lock); - atomic_set(&match->sk_ref, 0); - match->prot_hook.type = po->prot_hook.type; - match->prot_hook.dev = po->prot_hook.dev; - match->prot_hook.func = packet_rcv_fanout; - match->prot_hook.af_packet_priv = match; - dev_add_pack(&match->prot_hook); - list_add(&match->list, &fanout_list); - } - err = -EINVAL; - if (match->type == type && - match->prot_hook.type == po->prot_hook.type && - match->prot_hook.dev == po->prot_hook.dev) { - err = -ENOSPC; - if (atomic_read(&match->sk_ref) < PACKET_FANOUT_MAX) { - __dev_remove_pack(&po->prot_hook); - po->fanout = match; - atomic_inc(&match->sk_ref); - __fanout_link(sk, po); - err = 0; - } - } -out: - mutex_unlock(&fanout_mutex); - return err; -} - -static void fanout_release(struct sock *sk) -{ - struct packet_sock *po = pkt_sk(sk); - struct packet_fanout *f; - - f = po->fanout; - if (!f) - return; - - po->fanout = NULL; - - mutex_lock(&fanout_mutex); - if (atomic_dec_and_test(&f->sk_ref)) { - list_del(&f->list); - dev_remove_pack(&f->prot_hook); - kfree(f); - } - mutex_unlock(&fanout_mutex); -} static const struct proto_ops packet_ops; @@ -1129,6 +822,7 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev, else sll->sll_ifindex = dev->ifindex; + __packet_set_status(po, h.raw, status); smp_mb(); #if ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE == 1 { @@ -1137,10 +831,8 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev, end = (u8 *)PAGE_ALIGN((unsigned long)h.raw + macoff + snaplen); for (start = h.raw; start < end; start += PAGE_SIZE) flush_dcache_page(pgv_to_page(start)); - smp_wmb(); } #endif - __packet_set_status(po, h.raw, status); sk->sk_data_ready(sk, 0); @@ -1645,7 +1337,15 @@ static int packet_release(struct socket *sock) spin_unlock_bh(&net->packet.sklist_lock); spin_lock(&po->bind_lock); - unregister_prot_hook(sk, false); + if (po->running) { + /* + * Remove from protocol table + */ + po->running = 0; + po->num = 0; + __dev_remove_pack(&po->prot_hook); + __sock_put(sk); + } if (po->prot_hook.dev) { dev_put(po->prot_hook.dev); po->prot_hook.dev = NULL; @@ -1662,8 +1362,6 @@ static int packet_release(struct socket *sock) if (po->tx_ring.pg_vec) packet_set_ring(sk, &req, 1, 1); - fanout_release(sk); - synchronize_net(); /* * Now the socket is dead. No more input will appear. @@ -1687,14 +1385,22 @@ static int packet_release(struct socket *sock) static int packet_do_bind(struct sock *sk, struct net_device *dev, __be16 protocol) { struct packet_sock *po = pkt_sk(sk); - - if (po->fanout) - return -EINVAL; + /* + * Detach an existing hook if present. + */ lock_sock(sk); spin_lock(&po->bind_lock); - unregister_prot_hook(sk, true); + if (po->running) { + __sock_put(sk); + po->running = 0; + po->num = 0; + spin_unlock(&po->bind_lock); + dev_remove_pack(&po->prot_hook); + spin_lock(&po->bind_lock); + } + po->num = protocol; po->prot_hook.type = protocol; if (po->prot_hook.dev) @@ -1707,7 +1413,9 @@ static int packet_do_bind(struct sock *sk, struct net_device *dev, __be16 protoc goto out_unlock; if (!dev || (dev->flags & IFF_UP)) { - register_prot_hook(sk); + dev_add_pack(&po->prot_hook); + sock_hold(sk); + po->running = 1; } else { sk->sk_err = ENETDOWN; if (!sock_flag(sk, SOCK_DEAD)) @@ -1834,7 +1542,9 @@ static int packet_create(struct net *net, struct socket *sock, int protocol, if (proto) { po->prot_hook.type = proto; - register_prot_hook(sk); + dev_add_pack(&po->prot_hook); + sock_hold(sk); + po->running = 1; } spin_lock_bh(&net->packet.sklist_lock); @@ -2399,17 +2109,6 @@ packet_setsockopt(struct socket *sock, int level, int optname, char __user *optv po->tp_tstamp = val; return 0; } - case PACKET_FANOUT: - { - int val; - - if (optlen != sizeof(val)) - return -EINVAL; - if (copy_from_user(&val, optval, sizeof(val))) - return -EFAULT; - - return fanout_add(sk, val & 0xffff, val >> 16); - } default: return -ENOPROTOOPT; } @@ -2508,15 +2207,6 @@ static int packet_getsockopt(struct socket *sock, int level, int optname, val = po->tp_tstamp; data = &val; break; - case PACKET_FANOUT: - if (len > sizeof(int)) - len = sizeof(int); - val = (po->fanout ? - ((u32)po->fanout->id | - ((u32)po->fanout->type << 16)) : - 0); - data = &val; - break; default: return -ENOPROTOOPT; } @@ -2550,7 +2240,9 @@ static int packet_notifier(struct notifier_block *this, unsigned long msg, void if (dev->ifindex == po->ifindex) { spin_lock(&po->bind_lock); if (po->running) { - __unregister_prot_hook(sk, false); + __dev_remove_pack(&po->prot_hook); + __sock_put(sk); + po->running = 0; sk->sk_err = ENETDOWN; if (!sock_flag(sk, SOCK_DEAD)) sk->sk_error_report(sk); @@ -2567,8 +2259,11 @@ static int packet_notifier(struct notifier_block *this, unsigned long msg, void case NETDEV_UP: if (dev->ifindex == po->ifindex) { spin_lock(&po->bind_lock); - if (po->num) - register_prot_hook(sk); + if (po->num && !po->running) { + dev_add_pack(&po->prot_hook); + sock_hold(sk); + po->running = 1; + } spin_unlock(&po->bind_lock); } break; @@ -2835,8 +2530,10 @@ static int packet_set_ring(struct sock *sk, struct tpacket_req *req, was_running = po->running; num = po->num; if (was_running) { + __dev_remove_pack(&po->prot_hook); po->num = 0; - __unregister_prot_hook(sk, false); + po->running = 0; + __sock_put(sk); } spin_unlock(&po->bind_lock); @@ -2867,9 +2564,11 @@ static int packet_set_ring(struct sock *sk, struct tpacket_req *req, mutex_unlock(&po->pg_vec_lock); spin_lock(&po->bind_lock); - if (was_running) { + if (was_running && !po->running) { + sock_hold(sk); + po->running = 1; po->num = num; - register_prot_hook(sk); + dev_add_pack(&po->prot_hook); } spin_unlock(&po->bind_lock); diff --git a/trunk/net/rds/tcp_stats.c b/trunk/net/rds/tcp_stats.c index f8a7954f1f59..d5898d03cd68 100644 --- a/trunk/net/rds/tcp_stats.c +++ b/trunk/net/rds/tcp_stats.c @@ -40,7 +40,7 @@ DEFINE_PER_CPU(struct rds_tcp_statistics, rds_tcp_stats) ____cacheline_aligned; -static const char * const rds_tcp_stat_names[] = { +static const char const *rds_tcp_stat_names[] = { "tcp_data_ready_calls", "tcp_write_space_calls", "tcp_sndbuf_full", diff --git a/trunk/net/rose/rose_link.c b/trunk/net/rose/rose_link.c index 7a02bd1cc5a0..fa5f5641a2c2 100644 --- a/trunk/net/rose/rose_link.c +++ b/trunk/net/rose/rose_link.c @@ -266,6 +266,13 @@ void rose_transmit_link(struct sk_buff *skb, struct rose_neigh *neigh) { unsigned char *dptr; +#if 0 + if (call_fw_firewall(PF_ROSE, skb->dev, skb->data, NULL, &skb) != FW_ACCEPT) { + kfree_skb(skb); + return; + } +#endif + if (neigh->loopback) { rose_loopback_queue(skb, neigh); return; diff --git a/trunk/net/rose/rose_route.c b/trunk/net/rose/rose_route.c index d389de197089..479cae57d187 100644 --- a/trunk/net/rose/rose_route.c +++ b/trunk/net/rose/rose_route.c @@ -864,6 +864,11 @@ int rose_route_frame(struct sk_buff *skb, ax25_cb *ax25) int res = 0; char buf[11]; +#if 0 + if (call_in_firewall(PF_ROSE, skb->dev, skb->data, NULL, &skb) != FW_ACCEPT) + return res; +#endif + if (skb->len < ROSE_MIN_LEN) return res; frametype = skb->data[2]; diff --git a/trunk/net/sched/act_api.c b/trunk/net/sched/act_api.c index f2fb67e701a3..2f64262ab5d2 100644 --- a/trunk/net/sched/act_api.c +++ b/trunk/net/sched/act_api.c @@ -365,10 +365,10 @@ static struct tc_action_ops *tc_lookup_action_id(u32 type) } #endif -int tcf_action_exec(struct sk_buff *skb, const struct tc_action *act, +int tcf_action_exec(struct sk_buff *skb, struct tc_action *act, struct tcf_result *res) { - const struct tc_action *a; + struct tc_action *a; int ret = -1; if (skb->tc_verd & TC_NCLS) { diff --git a/trunk/net/sched/act_csum.c b/trunk/net/sched/act_csum.c index 453a73431ac4..6cdf9abe475f 100644 --- a/trunk/net/sched/act_csum.c +++ b/trunk/net/sched/act_csum.c @@ -500,7 +500,7 @@ static int tcf_csum_ipv6(struct sk_buff *skb, u32 update_flags) } static int tcf_csum(struct sk_buff *skb, - const struct tc_action *a, struct tcf_result *res) + struct tc_action *a, struct tcf_result *res) { struct tcf_csum *p = a->priv; int action; diff --git a/trunk/net/sched/act_gact.c b/trunk/net/sched/act_gact.c index b77f5a06a658..2b4ab4b05ce8 100644 --- a/trunk/net/sched/act_gact.c +++ b/trunk/net/sched/act_gact.c @@ -125,8 +125,7 @@ static int tcf_gact_cleanup(struct tc_action *a, int bind) return 0; } -static int tcf_gact(struct sk_buff *skb, const struct tc_action *a, - struct tcf_result *res) +static int tcf_gact(struct sk_buff *skb, struct tc_action *a, struct tcf_result *res) { struct tcf_gact *gact = a->priv; int action = TC_ACT_SHOT; diff --git a/trunk/net/sched/act_ipt.c b/trunk/net/sched/act_ipt.c index 60f8f616e8fa..9fc211a1b20e 100644 --- a/trunk/net/sched/act_ipt.c +++ b/trunk/net/sched/act_ipt.c @@ -195,7 +195,7 @@ static int tcf_ipt_cleanup(struct tc_action *a, int bind) return tcf_ipt_release(ipt, bind); } -static int tcf_ipt(struct sk_buff *skb, const struct tc_action *a, +static int tcf_ipt(struct sk_buff *skb, struct tc_action *a, struct tcf_result *res) { int ret = 0, result = 0; diff --git a/trunk/net/sched/act_mirred.c b/trunk/net/sched/act_mirred.c index 102fc212cd64..961386e2f2c0 100644 --- a/trunk/net/sched/act_mirred.c +++ b/trunk/net/sched/act_mirred.c @@ -154,7 +154,7 @@ static int tcf_mirred_cleanup(struct tc_action *a, int bind) return 0; } -static int tcf_mirred(struct sk_buff *skb, const struct tc_action *a, +static int tcf_mirred(struct sk_buff *skb, struct tc_action *a, struct tcf_result *res) { struct tcf_mirred *m = a->priv; diff --git a/trunk/net/sched/act_nat.c b/trunk/net/sched/act_nat.c index 001d1b354869..762b027650a9 100644 --- a/trunk/net/sched/act_nat.c +++ b/trunk/net/sched/act_nat.c @@ -102,7 +102,7 @@ static int tcf_nat_cleanup(struct tc_action *a, int bind) return tcf_hash_release(&p->common, bind, &nat_hash_info); } -static int tcf_nat(struct sk_buff *skb, const struct tc_action *a, +static int tcf_nat(struct sk_buff *skb, struct tc_action *a, struct tcf_result *res) { struct tcf_nat *p = a->priv; diff --git a/trunk/net/sched/act_pedit.c b/trunk/net/sched/act_pedit.c index 10d3aed86560..7affe9a92757 100644 --- a/trunk/net/sched/act_pedit.c +++ b/trunk/net/sched/act_pedit.c @@ -120,7 +120,7 @@ static int tcf_pedit_cleanup(struct tc_action *a, int bind) return 0; } -static int tcf_pedit(struct sk_buff *skb, const struct tc_action *a, +static int tcf_pedit(struct sk_buff *skb, struct tc_action *a, struct tcf_result *res) { struct tcf_pedit *p = a->priv; diff --git a/trunk/net/sched/act_police.c b/trunk/net/sched/act_police.c index 6fb3f5af0f85..b3b9b32f4e00 100644 --- a/trunk/net/sched/act_police.c +++ b/trunk/net/sched/act_police.c @@ -282,7 +282,7 @@ static int tcf_act_police_cleanup(struct tc_action *a, int bind) return ret; } -static int tcf_act_police(struct sk_buff *skb, const struct tc_action *a, +static int tcf_act_police(struct sk_buff *skb, struct tc_action *a, struct tcf_result *res) { struct tcf_police *police = a->priv; diff --git a/trunk/net/sched/act_simple.c b/trunk/net/sched/act_simple.c index 73e0a3ab4d55..a34a22de60b3 100644 --- a/trunk/net/sched/act_simple.c +++ b/trunk/net/sched/act_simple.c @@ -36,8 +36,7 @@ static struct tcf_hashinfo simp_hash_info = { }; #define SIMP_MAX_DATA 32 -static int tcf_simp(struct sk_buff *skb, const struct tc_action *a, - struct tcf_result *res) +static int tcf_simp(struct sk_buff *skb, struct tc_action *a, struct tcf_result *res) { struct tcf_defact *d = a->priv; diff --git a/trunk/net/sched/act_skbedit.c b/trunk/net/sched/act_skbedit.c index 35dbbe91027e..5f6f0c7c3905 100644 --- a/trunk/net/sched/act_skbedit.c +++ b/trunk/net/sched/act_skbedit.c @@ -39,7 +39,7 @@ static struct tcf_hashinfo skbedit_hash_info = { .lock = &skbedit_lock, }; -static int tcf_skbedit(struct sk_buff *skb, const struct tc_action *a, +static int tcf_skbedit(struct sk_buff *skb, struct tc_action *a, struct tcf_result *res) { struct tcf_skbedit *d = a->priv; diff --git a/trunk/net/sched/cls_api.c b/trunk/net/sched/cls_api.c index a69d44f1dac5..9563887f219f 100644 --- a/trunk/net/sched/cls_api.c +++ b/trunk/net/sched/cls_api.c @@ -40,9 +40,9 @@ static DEFINE_RWLOCK(cls_mod_lock); /* Find classifier type by string name */ -static const struct tcf_proto_ops *tcf_proto_lookup_ops(struct nlattr *kind) +static struct tcf_proto_ops *tcf_proto_lookup_ops(struct nlattr *kind) { - const struct tcf_proto_ops *t = NULL; + struct tcf_proto_ops *t = NULL; if (kind) { read_lock(&cls_mod_lock); @@ -132,7 +132,7 @@ static int tc_ctl_tfilter(struct sk_buff *skb, struct nlmsghdr *n, void *arg) struct Qdisc *q; struct tcf_proto **back, **chain; struct tcf_proto *tp; - const struct tcf_proto_ops *tp_ops; + struct tcf_proto_ops *tp_ops; const struct Qdisc_class_ops *cops; unsigned long cl; unsigned long fh; diff --git a/trunk/net/sched/cls_basic.c b/trunk/net/sched/cls_basic.c index ea1f70b5a5f4..8be8872dd571 100644 --- a/trunk/net/sched/cls_basic.c +++ b/trunk/net/sched/cls_basic.c @@ -39,7 +39,7 @@ static const struct tcf_ext_map basic_ext_map = { .police = TCA_BASIC_POLICE }; -static int basic_classify(struct sk_buff *skb, const struct tcf_proto *tp, +static int basic_classify(struct sk_buff *skb, struct tcf_proto *tp, struct tcf_result *res) { int r; diff --git a/trunk/net/sched/cls_cgroup.c b/trunk/net/sched/cls_cgroup.c index f84fdc3a7f27..32a335194ca5 100644 --- a/trunk/net/sched/cls_cgroup.c +++ b/trunk/net/sched/cls_cgroup.c @@ -101,7 +101,7 @@ struct cls_cgroup_head { struct tcf_ematch_tree ematches; }; -static int cls_cgroup_classify(struct sk_buff *skb, const struct tcf_proto *tp, +static int cls_cgroup_classify(struct sk_buff *skb, struct tcf_proto *tp, struct tcf_result *res) { struct cls_cgroup_head *head = tp->root; diff --git a/trunk/net/sched/cls_flow.c b/trunk/net/sched/cls_flow.c index 6994214db8f8..34533a5d1b3a 100644 --- a/trunk/net/sched/cls_flow.c +++ b/trunk/net/sched/cls_flow.c @@ -356,7 +356,7 @@ static u32 flow_key_get(struct sk_buff *skb, int key) } } -static int flow_classify(struct sk_buff *skb, const struct tcf_proto *tp, +static int flow_classify(struct sk_buff *skb, struct tcf_proto *tp, struct tcf_result *res) { struct flow_head *head = tp->root; diff --git a/trunk/net/sched/cls_fw.c b/trunk/net/sched/cls_fw.c index 389af152ec45..26e7bc4ffb79 100644 --- a/trunk/net/sched/cls_fw.c +++ b/trunk/net/sched/cls_fw.c @@ -77,7 +77,7 @@ static inline int fw_hash(u32 handle) return handle & (HTSIZE - 1); } -static int fw_classify(struct sk_buff *skb, const struct tcf_proto *tp, +static int fw_classify(struct sk_buff *skb, struct tcf_proto *tp, struct tcf_result *res) { struct fw_head *head = (struct fw_head *)tp->root; diff --git a/trunk/net/sched/cls_route.c b/trunk/net/sched/cls_route.c index 13ab66e9df58..a907905376df 100644 --- a/trunk/net/sched/cls_route.c +++ b/trunk/net/sched/cls_route.c @@ -125,7 +125,7 @@ static inline int route4_hash_wild(void) return 0; \ } -static int route4_classify(struct sk_buff *skb, const struct tcf_proto *tp, +static int route4_classify(struct sk_buff *skb, struct tcf_proto *tp, struct tcf_result *res) { struct route4_head *head = (struct route4_head *)tp->root; diff --git a/trunk/net/sched/cls_rsvp.h b/trunk/net/sched/cls_rsvp.h index be4505ee67a9..ed691b148384 100644 --- a/trunk/net/sched/cls_rsvp.h +++ b/trunk/net/sched/cls_rsvp.h @@ -130,7 +130,7 @@ static struct tcf_ext_map rsvp_ext_map = { return r; \ } -static int rsvp_classify(struct sk_buff *skb, const struct tcf_proto *tp, +static int rsvp_classify(struct sk_buff *skb, struct tcf_proto *tp, struct tcf_result *res) { struct rsvp_session **sht = ((struct rsvp_head *)tp->root)->ht; diff --git a/trunk/net/sched/cls_tcindex.c b/trunk/net/sched/cls_tcindex.c index dbe199234c63..36667fa64237 100644 --- a/trunk/net/sched/cls_tcindex.c +++ b/trunk/net/sched/cls_tcindex.c @@ -79,7 +79,7 @@ tcindex_lookup(struct tcindex_data *p, u16 key) } -static int tcindex_classify(struct sk_buff *skb, const struct tcf_proto *tp, +static int tcindex_classify(struct sk_buff *skb, struct tcf_proto *tp, struct tcf_result *res) { struct tcindex_data *p = PRIV(tp); diff --git a/trunk/net/sched/cls_u32.c b/trunk/net/sched/cls_u32.c index 939b627b4795..3b93fc0c8955 100644 --- a/trunk/net/sched/cls_u32.c +++ b/trunk/net/sched/cls_u32.c @@ -93,7 +93,7 @@ static inline unsigned int u32_hash_fold(__be32 key, return h; } -static int u32_classify(struct sk_buff *skb, const struct tcf_proto *tp, struct tcf_result *res) +static int u32_classify(struct sk_buff *skb, struct tcf_proto *tp, struct tcf_result *res) { struct { struct tc_u_knode *knode; diff --git a/trunk/net/sched/sch_api.c b/trunk/net/sched/sch_api.c index dca6c1a576f7..8182aefafb02 100644 --- a/trunk/net/sched/sch_api.c +++ b/trunk/net/sched/sch_api.c @@ -1644,7 +1644,7 @@ static int tc_dump_tclass(struct sk_buff *skb, struct netlink_callback *cb) * to this qdisc, (optionally) tests for protocol and asks * specific classifiers. */ -int tc_classify_compat(struct sk_buff *skb, const struct tcf_proto *tp, +int tc_classify_compat(struct sk_buff *skb, struct tcf_proto *tp, struct tcf_result *res) { __be16 protocol = skb->protocol; @@ -1668,12 +1668,12 @@ int tc_classify_compat(struct sk_buff *skb, const struct tcf_proto *tp, } EXPORT_SYMBOL(tc_classify_compat); -int tc_classify(struct sk_buff *skb, const struct tcf_proto *tp, +int tc_classify(struct sk_buff *skb, struct tcf_proto *tp, struct tcf_result *res) { int err = 0; #ifdef CONFIG_NET_CLS_ACT - const struct tcf_proto *otp = tp; + struct tcf_proto *otp = tp; reclassify: #endif diff --git a/trunk/net/sched/sch_generic.c b/trunk/net/sched/sch_generic.c index d253c16a314c..b4c680900d7a 100644 --- a/trunk/net/sched/sch_generic.c +++ b/trunk/net/sched/sch_generic.c @@ -189,17 +189,15 @@ static inline int qdisc_restart(struct Qdisc *q) void __qdisc_run(struct Qdisc *q) { - int quota = weight_p; - int work = 0; + unsigned long start_time = jiffies; while (qdisc_restart(q)) { - work++; /* - * Ordered by possible occurrence: Postpone processing if - * 1. we've exceeded packet quota - * 2. another process needs the CPU; + * Postpone processing if + * 1. another process needs the CPU; + * 2. we've been doing it for too long. */ - if (work >= quota || need_resched()) { + if (need_resched() || jiffies != start_time) { __netif_schedule(q); break; } diff --git a/trunk/net/sctp/outqueue.c b/trunk/net/sctp/outqueue.c index a6d27bf563a5..edc753297a49 100644 --- a/trunk/net/sctp/outqueue.c +++ b/trunk/net/sctp/outqueue.c @@ -1595,8 +1595,6 @@ static void sctp_check_transmitted(struct sctp_outq *q, #endif /* SCTP_DEBUG */ if (transport) { if (bytes_acked) { - struct sctp_association *asoc = transport->asoc; - /* We may have counted DATA that was migrated * to this transport due to DEL-IP operation. * Subtract those bytes, since the were never @@ -1615,17 +1613,6 @@ static void sctp_check_transmitted(struct sctp_outq *q, transport->error_count = 0; transport->asoc->overall_error_count = 0; - /* - * While in SHUTDOWN PENDING, we may have started - * the T5 shutdown guard timer after reaching the - * retransmission limit. Stop that timer as soon - * as the receiver acknowledged any data. - */ - if (asoc->state == SCTP_STATE_SHUTDOWN_PENDING && - del_timer(&asoc->timers - [SCTP_EVENT_TIMEOUT_T5_SHUTDOWN_GUARD])) - sctp_association_put(asoc); - /* Mark the destination transport address as * active if it is not so marked. */ @@ -1655,15 +1642,10 @@ static void sctp_check_transmitted(struct sctp_outq *q, * A sender is doing zero window probing when the * receiver's advertised window is zero, and there is * only one data chunk in flight to the receiver. - * - * Allow the association to timeout while in SHUTDOWN - * PENDING or SHUTDOWN RECEIVED in case the receiver - * stays in zero window mode forever. */ if (!q->asoc->peer.rwnd && !list_empty(&tlist) && - (sack_ctsn+2 == q->asoc->next_tsn) && - q->asoc->state < SCTP_STATE_SHUTDOWN_PENDING) { + (sack_ctsn+2 == q->asoc->next_tsn)) { SCTP_DEBUG_PRINTK("%s: SACK received for zero " "window probe: %u\n", __func__, sack_ctsn); diff --git a/trunk/net/sctp/protocol.c b/trunk/net/sctp/protocol.c index 91784f44a2e2..ab5ded2c58de 100644 --- a/trunk/net/sctp/protocol.c +++ b/trunk/net/sctp/protocol.c @@ -1199,6 +1199,7 @@ SCTP_STATIC __init int sctp_init(void) int status = -EINVAL; unsigned long goal; unsigned long limit; + unsigned long nr_pages; int max_share; int order; @@ -1288,7 +1289,15 @@ SCTP_STATIC __init int sctp_init(void) /* Initialize handle used for association ids. */ idr_init(&sctp_assocs_id); - limit = nr_free_buffer_pages() / 8; + /* Set the pressure threshold to be a fraction of global memory that + * is up to 1/2 at 256 MB, decreasing toward zero with the amount of + * memory, with a floor of 128 pages. + * Note this initializes the data in sctpv6_prot too + * Unabashedly stolen from tcp_init + */ + nr_pages = totalram_pages - totalhigh_pages; + limit = min(nr_pages, 1UL<<(28-PAGE_SHIFT)) >> (20-PAGE_SHIFT); + limit = (limit * (nr_pages >> (20-PAGE_SHIFT))) >> (PAGE_SHIFT-11); limit = max(limit, 128UL); sysctl_sctp_mem[0] = limit / 4 * 3; sysctl_sctp_mem[1] = limit; diff --git a/trunk/net/sctp/sm_sideeffect.c b/trunk/net/sctp/sm_sideeffect.c index 167c880cf8da..1b2bb6487342 100644 --- a/trunk/net/sctp/sm_sideeffect.c +++ b/trunk/net/sctp/sm_sideeffect.c @@ -670,19 +670,10 @@ static void sctp_cmd_transport_on(sctp_cmd_seq_t *cmds, /* 8.3 Upon the receipt of the HEARTBEAT ACK, the sender of the * HEARTBEAT should clear the error counter of the destination * transport address to which the HEARTBEAT was sent. + * The association's overall error count is also cleared. */ t->error_count = 0; - - /* - * Although RFC4960 specifies that the overall error count must - * be cleared when a HEARTBEAT ACK is received, we make an - * exception while in SHUTDOWN PENDING. If the peer keeps its - * window shut forever, we may never be able to transmit our - * outstanding data and rely on the retransmission limit be reached - * to shutdown the association. - */ - if (t->asoc->state != SCTP_STATE_SHUTDOWN_PENDING) - t->asoc->overall_error_count = 0; + t->asoc->overall_error_count = 0; /* Clear the hb_sent flag to signal that we had a good * acknowledgement. @@ -1446,13 +1437,6 @@ static int sctp_cmd_interpreter(sctp_event_t event_type, sctp_cmd_setup_t2(commands, asoc, cmd->obj.ptr); break; - case SCTP_CMD_TIMER_START_ONCE: - timer = &asoc->timers[cmd->obj.to]; - - if (timer_pending(timer)) - break; - /* fall through */ - case SCTP_CMD_TIMER_START: timer = &asoc->timers[cmd->obj.to]; timeout = asoc->timeouts[cmd->obj.to]; diff --git a/trunk/net/sctp/sm_statefuns.c b/trunk/net/sctp/sm_statefuns.c index 49b847b00f99..a297283154d5 100644 --- a/trunk/net/sctp/sm_statefuns.c +++ b/trunk/net/sctp/sm_statefuns.c @@ -4008,32 +4008,31 @@ sctp_disposition_t sctp_sf_eat_auth(const struct sctp_endpoint *ep, auth_hdr = (struct sctp_authhdr *)chunk->skb->data; error = sctp_sf_authenticate(ep, asoc, type, chunk); switch (error) { - case SCTP_IERROR_AUTH_BAD_HMAC: - /* Generate the ERROR chunk and discard the rest - * of the packet - */ - err_chunk = sctp_make_op_error(asoc, chunk, - SCTP_ERROR_UNSUP_HMAC, - &auth_hdr->hmac_id, - sizeof(__u16), 0); - if (err_chunk) { - sctp_add_cmd_sf(commands, SCTP_CMD_REPLY, - SCTP_CHUNK(err_chunk)); - } - /* Fall Through */ - case SCTP_IERROR_AUTH_BAD_KEYID: - case SCTP_IERROR_BAD_SIG: - return sctp_sf_pdiscard(ep, asoc, type, arg, commands); - - case SCTP_IERROR_PROTO_VIOLATION: - return sctp_sf_violation_chunklen(ep, asoc, type, arg, - commands); - - case SCTP_IERROR_NOMEM: - return SCTP_DISPOSITION_NOMEM; - - default: /* Prevent gcc warnings */ - break; + case SCTP_IERROR_AUTH_BAD_HMAC: + /* Generate the ERROR chunk and discard the rest + * of the packet + */ + err_chunk = sctp_make_op_error(asoc, chunk, + SCTP_ERROR_UNSUP_HMAC, + &auth_hdr->hmac_id, + sizeof(__u16), 0); + if (err_chunk) { + sctp_add_cmd_sf(commands, SCTP_CMD_REPLY, + SCTP_CHUNK(err_chunk)); + } + /* Fall Through */ + case SCTP_IERROR_AUTH_BAD_KEYID: + case SCTP_IERROR_BAD_SIG: + return sctp_sf_pdiscard(ep, asoc, type, arg, commands); + break; + case SCTP_IERROR_PROTO_VIOLATION: + return sctp_sf_violation_chunklen(ep, asoc, type, arg, + commands); + break; + case SCTP_IERROR_NOMEM: + return SCTP_DISPOSITION_NOMEM; + default: + break; } if (asoc->active_key_id != ntohs(auth_hdr->shkey_id)) { @@ -5155,7 +5154,7 @@ sctp_disposition_t sctp_sf_do_9_2_start_shutdown( * The sender of the SHUTDOWN MAY also start an overall guard timer * 'T5-shutdown-guard' to bound the overall time for shutdown sequence. */ - sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_RESTART, + sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_START, SCTP_TO(SCTP_EVENT_TIMEOUT_T5_SHUTDOWN_GUARD)); if (asoc->autoclose) @@ -5300,28 +5299,14 @@ sctp_disposition_t sctp_sf_do_6_3_3_rtx(const struct sctp_endpoint *ep, SCTP_INC_STATS(SCTP_MIB_T3_RTX_EXPIREDS); if (asoc->overall_error_count >= asoc->max_retrans) { - if (asoc->state == SCTP_STATE_SHUTDOWN_PENDING) { - /* - * We are here likely because the receiver had its rwnd - * closed for a while and we have not been able to - * transmit the locally queued data within the maximum - * retransmission attempts limit. Start the T5 - * shutdown guard timer to give the receiver one last - * chance and some additional time to recover before - * aborting. - */ - sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_START_ONCE, - SCTP_TO(SCTP_EVENT_TIMEOUT_T5_SHUTDOWN_GUARD)); - } else { - sctp_add_cmd_sf(commands, SCTP_CMD_SET_SK_ERR, - SCTP_ERROR(ETIMEDOUT)); - /* CMD_ASSOC_FAILED calls CMD_DELETE_TCB. */ - sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED, - SCTP_PERR(SCTP_ERROR_NO_ERROR)); - SCTP_INC_STATS(SCTP_MIB_ABORTEDS); - SCTP_DEC_STATS(SCTP_MIB_CURRESTAB); - return SCTP_DISPOSITION_DELETE_TCB; - } + sctp_add_cmd_sf(commands, SCTP_CMD_SET_SK_ERR, + SCTP_ERROR(ETIMEDOUT)); + /* CMD_ASSOC_FAILED calls CMD_DELETE_TCB. */ + sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED, + SCTP_PERR(SCTP_ERROR_NO_ERROR)); + SCTP_INC_STATS(SCTP_MIB_ABORTEDS); + SCTP_DEC_STATS(SCTP_MIB_CURRESTAB); + return SCTP_DISPOSITION_DELETE_TCB; } /* E1) For the destination address for which the timer diff --git a/trunk/net/sctp/sm_statetable.c b/trunk/net/sctp/sm_statetable.c index 7c211a7f90f4..0338dc6fdc9d 100644 --- a/trunk/net/sctp/sm_statetable.c +++ b/trunk/net/sctp/sm_statetable.c @@ -827,7 +827,7 @@ static const sctp_sm_table_entry_t other_event_table[SCTP_NUM_OTHER_TYPES][SCTP_ /* SCTP_STATE_ESTABLISHED */ \ TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \ /* SCTP_STATE_SHUTDOWN_PENDING */ \ - TYPE_SCTP_FUNC(sctp_sf_t5_timer_expire), \ + TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \ /* SCTP_STATE_SHUTDOWN_SENT */ \ TYPE_SCTP_FUNC(sctp_sf_t5_timer_expire), \ /* SCTP_STATE_SHUTDOWN_RECEIVED */ \ diff --git a/trunk/net/sctp/socket.c b/trunk/net/sctp/socket.c index 836aa63ee121..fd31b3616a33 100644 --- a/trunk/net/sctp/socket.c +++ b/trunk/net/sctp/socket.c @@ -1454,7 +1454,6 @@ SCTP_STATIC void sctp_close(struct sock *sk, long timeout) struct sctp_endpoint *ep; struct sctp_association *asoc; struct list_head *pos, *temp; - unsigned int data_was_unread; SCTP_DEBUG_PRINTK("sctp_close(sk: 0x%p, timeout:%ld)\n", sk, timeout); @@ -1464,10 +1463,6 @@ SCTP_STATIC void sctp_close(struct sock *sk, long timeout) ep = sctp_sk(sk)->ep; - /* Clean up any skbs sitting on the receive queue. */ - data_was_unread = sctp_queue_purge_ulpevents(&sk->sk_receive_queue); - data_was_unread += sctp_queue_purge_ulpevents(&sctp_sk(sk)->pd_lobby); - /* Walk all associations on an endpoint. */ list_for_each_safe(pos, temp, &ep->asocs) { asoc = list_entry(pos, struct sctp_association, asocs); @@ -1485,9 +1480,7 @@ SCTP_STATIC void sctp_close(struct sock *sk, long timeout) } } - if (data_was_unread || !skb_queue_empty(&asoc->ulpq.lobby) || - !skb_queue_empty(&asoc->ulpq.reasm) || - (sock_flag(sk, SOCK_LINGER) && !sk->sk_lingertime)) { + if (sock_flag(sk, SOCK_LINGER) && !sk->sk_lingertime) { struct sctp_chunk *chunk; chunk = sctp_make_abort_user(asoc, NULL, 0); @@ -1497,6 +1490,10 @@ SCTP_STATIC void sctp_close(struct sock *sk, long timeout) sctp_primitive_SHUTDOWN(asoc, NULL); } + /* Clean up any skbs sitting on the receive queue. */ + sctp_queue_purge_ulpevents(&sk->sk_receive_queue); + sctp_queue_purge_ulpevents(&sctp_sk(sk)->pd_lobby); + /* On a TCP-style socket, block for at most linger_time if set. */ if (sctp_style(sk, TCP) && timeout) sctp_wait_for_close(sk, timeout); @@ -2146,33 +2143,10 @@ static int sctp_setsockopt_disable_fragments(struct sock *sk, static int sctp_setsockopt_events(struct sock *sk, char __user *optval, unsigned int optlen) { - struct sctp_association *asoc; - struct sctp_ulpevent *event; - if (optlen > sizeof(struct sctp_event_subscribe)) return -EINVAL; if (copy_from_user(&sctp_sk(sk)->subscribe, optval, optlen)) return -EFAULT; - - /* - * At the time when a user app subscribes to SCTP_SENDER_DRY_EVENT, - * if there is no data to be sent or retransmit, the stack will - * immediately send up this notification. - */ - if (sctp_ulpevent_type_enabled(SCTP_SENDER_DRY_EVENT, - &sctp_sk(sk)->subscribe)) { - asoc = sctp_id2assoc(sk, 0); - - if (asoc && sctp_outq_is_empty(&asoc->outqueue)) { - event = sctp_ulpevent_make_sender_dry_event(asoc, - GFP_ATOMIC); - if (!event) - return -ENOMEM; - - sctp_ulpq_tail_event(&asoc->ulpq, event); - } - } - return 0; } @@ -3283,11 +3257,11 @@ static int sctp_setsockopt_auth_chunk(struct sock *sk, return -EFAULT; switch (val.sauth_chunk) { - case SCTP_CID_INIT: - case SCTP_CID_INIT_ACK: - case SCTP_CID_SHUTDOWN_COMPLETE: - case SCTP_CID_AUTH: - return -EINVAL; + case SCTP_CID_INIT: + case SCTP_CID_INIT_ACK: + case SCTP_CID_SHUTDOWN_COMPLETE: + case SCTP_CID_AUTH: + return -EINVAL; } /* add this chunk id to the endpoint */ diff --git a/trunk/net/sctp/ulpevent.c b/trunk/net/sctp/ulpevent.c index 8a84017834c2..e70e5fc87890 100644 --- a/trunk/net/sctp/ulpevent.c +++ b/trunk/net/sctp/ulpevent.c @@ -1081,19 +1081,9 @@ void sctp_ulpevent_free(struct sctp_ulpevent *event) } /* Purge the skb lists holding ulpevents. */ -unsigned int sctp_queue_purge_ulpevents(struct sk_buff_head *list) +void sctp_queue_purge_ulpevents(struct sk_buff_head *list) { struct sk_buff *skb; - unsigned int data_unread = 0; - - while ((skb = skb_dequeue(list)) != NULL) { - struct sctp_ulpevent *event = sctp_skb2event(skb); - - if (!sctp_ulpevent_is_notification(event)) - data_unread += skb->len; - - sctp_ulpevent_free(event); - } - - return data_unread; + while ((skb = skb_dequeue(list)) != NULL) + sctp_ulpevent_free(sctp_skb2event(skb)); } diff --git a/trunk/net/sunrpc/auth_gss/auth_gss.c b/trunk/net/sunrpc/auth_gss/auth_gss.c index 364eb45e989d..339ba64cce1e 100644 --- a/trunk/net/sunrpc/auth_gss/auth_gss.c +++ b/trunk/net/sunrpc/auth_gss/auth_gss.c @@ -577,13 +577,13 @@ gss_create_upcall(struct gss_auth *gss_auth, struct gss_cred *gss_cred) } inode = &gss_msg->inode->vfs_inode; for (;;) { - prepare_to_wait(&gss_msg->waitqueue, &wait, TASK_KILLABLE); + prepare_to_wait(&gss_msg->waitqueue, &wait, TASK_INTERRUPTIBLE); spin_lock(&inode->i_lock); if (gss_msg->ctx != NULL || gss_msg->msg.errno < 0) { break; } spin_unlock(&inode->i_lock); - if (fatal_signal_pending(current)) { + if (signalled()) { err = -ERESTARTSYS; goto out_intr; } @@ -1421,16 +1421,18 @@ gss_wrap_req(struct rpc_task *task, goto out; } switch (gss_cred->gc_service) { - case RPC_GSS_SVC_NONE: - gss_wrap_req_encode(encode, rqstp, p, obj); - status = 0; - break; - case RPC_GSS_SVC_INTEGRITY: - status = gss_wrap_req_integ(cred, ctx, encode, rqstp, p, obj); - break; - case RPC_GSS_SVC_PRIVACY: - status = gss_wrap_req_priv(cred, ctx, encode, rqstp, p, obj); - break; + case RPC_GSS_SVC_NONE: + gss_wrap_req_encode(encode, rqstp, p, obj); + status = 0; + break; + case RPC_GSS_SVC_INTEGRITY: + status = gss_wrap_req_integ(cred, ctx, encode, + rqstp, p, obj); + break; + case RPC_GSS_SVC_PRIVACY: + status = gss_wrap_req_priv(cred, ctx, encode, + rqstp, p, obj); + break; } out: gss_put_ctx(ctx); @@ -1529,18 +1531,18 @@ gss_unwrap_resp(struct rpc_task *task, if (ctx->gc_proc != RPC_GSS_PROC_DATA) goto out_decode; switch (gss_cred->gc_service) { - case RPC_GSS_SVC_NONE: - break; - case RPC_GSS_SVC_INTEGRITY: - status = gss_unwrap_resp_integ(cred, ctx, rqstp, &p); - if (status) - goto out; - break; - case RPC_GSS_SVC_PRIVACY: - status = gss_unwrap_resp_priv(cred, ctx, rqstp, &p); - if (status) - goto out; - break; + case RPC_GSS_SVC_NONE: + break; + case RPC_GSS_SVC_INTEGRITY: + status = gss_unwrap_resp_integ(cred, ctx, rqstp, &p); + if (status) + goto out; + break; + case RPC_GSS_SVC_PRIVACY: + status = gss_unwrap_resp_priv(cred, ctx, rqstp, &p); + if (status) + goto out; + break; } /* take into account extra slack for integrity and privacy cases: */ cred->cr_auth->au_rslack = cred->cr_auth->au_verfsize + (p - savedp) diff --git a/trunk/net/sunrpc/clnt.c b/trunk/net/sunrpc/clnt.c index 7389b7da3a8d..b84d7395535e 100644 --- a/trunk/net/sunrpc/clnt.c +++ b/trunk/net/sunrpc/clnt.c @@ -1061,7 +1061,7 @@ call_allocate(struct rpc_task *task) dprintk("RPC: %5u rpc_buffer allocation failed\n", task->tk_pid); - if (RPC_IS_ASYNC(task) || !fatal_signal_pending(current)) { + if (RPC_IS_ASYNC(task) || !signalled()) { task->tk_action = call_allocate; rpc_delay(task, HZ>>4); return; @@ -1175,9 +1175,6 @@ call_bind_status(struct rpc_task *task) status = -EOPNOTSUPP; break; } - if (task->tk_rebind_retry == 0) - break; - task->tk_rebind_retry--; rpc_delay(task, 3*HZ); goto retry_timeout; case -ETIMEDOUT: @@ -1666,18 +1663,19 @@ rpc_verify_header(struct rpc_task *task) if (--len < 0) goto out_overflow; switch ((n = ntohl(*p++))) { - case RPC_AUTH_ERROR: - break; - case RPC_MISMATCH: - dprintk("RPC: %5u %s: RPC call version mismatch!\n", - task->tk_pid, __func__); - error = -EPROTONOSUPPORT; - goto out_err; - default: - dprintk("RPC: %5u %s: RPC call rejected, " - "unknown error: %x\n", - task->tk_pid, __func__, n); - goto out_eio; + case RPC_AUTH_ERROR: + break; + case RPC_MISMATCH: + dprintk("RPC: %5u %s: RPC call version " + "mismatch!\n", + task->tk_pid, __func__); + error = -EPROTONOSUPPORT; + goto out_err; + default: + dprintk("RPC: %5u %s: RPC call rejected, " + "unknown error: %x\n", + task->tk_pid, __func__, n); + goto out_eio; } if (--len < 0) goto out_overflow; diff --git a/trunk/net/sunrpc/rpc_pipe.c b/trunk/net/sunrpc/rpc_pipe.c index b181e3441323..72bc53683965 100644 --- a/trunk/net/sunrpc/rpc_pipe.c +++ b/trunk/net/sunrpc/rpc_pipe.c @@ -456,13 +456,13 @@ rpc_get_inode(struct super_block *sb, umode_t mode) inode->i_ino = get_next_ino(); inode->i_mode = mode; inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; - switch (mode & S_IFMT) { - case S_IFDIR: - inode->i_fop = &simple_dir_operations; - inode->i_op = &simple_dir_inode_operations; - inc_nlink(inode); - default: - break; + switch(mode & S_IFMT) { + case S_IFDIR: + inode->i_fop = &simple_dir_operations; + inode->i_op = &simple_dir_inode_operations; + inc_nlink(inode); + default: + break; } return inode; } diff --git a/trunk/net/sunrpc/rpcb_clnt.c b/trunk/net/sunrpc/rpcb_clnt.c index e45d2fbbe5a8..9a80a922c527 100644 --- a/trunk/net/sunrpc/rpcb_clnt.c +++ b/trunk/net/sunrpc/rpcb_clnt.c @@ -597,7 +597,7 @@ void rpcb_getport_async(struct rpc_task *task) u32 bind_version; struct rpc_xprt *xprt; struct rpc_clnt *rpcb_clnt; - struct rpcbind_args *map; + static struct rpcbind_args *map; struct rpc_task *child; struct sockaddr_storage addr; struct sockaddr *sap = (struct sockaddr *)&addr; diff --git a/trunk/net/sunrpc/sched.c b/trunk/net/sunrpc/sched.c index 4814e246a874..6b43ee7221d5 100644 --- a/trunk/net/sunrpc/sched.c +++ b/trunk/net/sunrpc/sched.c @@ -616,25 +616,30 @@ static void __rpc_execute(struct rpc_task *task) BUG_ON(RPC_IS_QUEUED(task)); for (;;) { - void (*do_action)(struct rpc_task *); /* - * Execute any pending callback first. + * Execute any pending callback. */ - do_action = task->tk_callback; - task->tk_callback = NULL; - if (do_action == NULL) { + if (task->tk_callback) { + void (*save_callback)(struct rpc_task *); + + /* + * We set tk_callback to NULL before calling it, + * in case it sets the tk_callback field itself: + */ + save_callback = task->tk_callback; + task->tk_callback = NULL; + save_callback(task); + } else { /* * Perform the next FSM step. - * tk_action may be NULL if the task has been killed. - * In particular, note that rpc_killall_tasks may - * do this at any time, so beware when dereferencing. + * tk_action may be NULL when the task has been killed + * by someone else. */ - do_action = task->tk_action; - if (do_action == NULL) + if (task->tk_action == NULL) break; + task->tk_action(task); } - do_action(task); /* * Lockless check for whether task is sleeping or not. @@ -787,7 +792,6 @@ static void rpc_init_task(struct rpc_task *task, const struct rpc_task_setup *ta /* Initialize retry counters */ task->tk_garb_retry = 2; task->tk_cred_retry = 2; - task->tk_rebind_retry = 2; task->tk_priority = task_setup_data->priority - RPC_PRIORITY_LOW; task->tk_owner = current->tgid; diff --git a/trunk/net/tipc/bcast.c b/trunk/net/tipc/bcast.c index 759b318b5ffb..fa68d1e9ff4b 100644 --- a/trunk/net/tipc/bcast.c +++ b/trunk/net/tipc/bcast.c @@ -552,16 +552,12 @@ static int tipc_bcbearer_send(struct sk_buff *buf, if (likely(!msg_non_seq(buf_msg(buf)))) { struct tipc_msg *msg; + assert(tipc_bcast_nmap.count != 0); bcbuf_set_acks(buf, tipc_bcast_nmap.count); msg = buf_msg(buf); msg_set_non_seq(msg, 1); msg_set_mc_netid(msg, tipc_net_id); bcl->stats.sent_info++; - - if (WARN_ON(!tipc_bcast_nmap.count)) { - dump_stack(); - return 0; - } } /* Send buffer over bearers until all targets reached */ diff --git a/trunk/net/tipc/bearer.c b/trunk/net/tipc/bearer.c index 85eba9c08ee9..85209eadfae6 100644 --- a/trunk/net/tipc/bearer.c +++ b/trunk/net/tipc/bearer.c @@ -402,6 +402,7 @@ void tipc_bearer_lock_push(struct tipc_bearer *b_ptr) void tipc_continue(struct tipc_bearer *b_ptr) { spin_lock_bh(&b_ptr->lock); + b_ptr->continue_count++; if (!list_empty(&b_ptr->cong_links)) tipc_k_signal((Handler)tipc_bearer_lock_push, (unsigned long)b_ptr); b_ptr->blocked = 0; diff --git a/trunk/net/tipc/bearer.h b/trunk/net/tipc/bearer.h index 5ad70eff1ebf..31d6172b20fd 100644 --- a/trunk/net/tipc/bearer.h +++ b/trunk/net/tipc/bearer.h @@ -107,6 +107,7 @@ struct media { * @link_req: ptr to (optional) structure making periodic link setup requests * @links: list of non-congested links associated with bearer * @cong_links: list of congested links associated with bearer + * @continue_count: # of times bearer has resumed after congestion or blocking * @active: non-zero if bearer structure is represents a bearer * @net_plane: network plane ('A' through 'H') currently associated with bearer * @nodes: indicates which nodes in cluster can be reached through bearer @@ -128,6 +129,7 @@ struct tipc_bearer { struct link_req *link_req; struct list_head links; struct list_head cong_links; + u32 continue_count; int active; char net_plane; struct tipc_node_map nodes; diff --git a/trunk/net/tipc/core.h b/trunk/net/tipc/core.h index d234a98a460a..436dda1159d2 100644 --- a/trunk/net/tipc/core.h +++ b/trunk/net/tipc/core.h @@ -61,6 +61,12 @@ struct tipc_msg; /* msg.h */ struct print_buf; /* log.h */ +/* + * TIPC sanity test macros + */ + +#define assert(i) BUG_ON(!(i)) + /* * TIPC system monitoring code */ diff --git a/trunk/net/tipc/link.c b/trunk/net/tipc/link.c index f89570c54f54..5ed4b4f7452d 100644 --- a/trunk/net/tipc/link.c +++ b/trunk/net/tipc/link.c @@ -1572,7 +1572,7 @@ static struct sk_buff *link_insert_deferred_queue(struct link *l_ptr, static int link_recv_buf_validate(struct sk_buff *buf) { static u32 min_data_hdr_size[8] = { - SHORT_H_SIZE, MCAST_H_SIZE, NAMED_H_SIZE, BASIC_H_SIZE, + SHORT_H_SIZE, MCAST_H_SIZE, LONG_H_SIZE, DIR_MSG_H_SIZE, MAX_H_SIZE, MAX_H_SIZE, MAX_H_SIZE, MAX_H_SIZE }; @@ -2553,7 +2553,7 @@ int tipc_link_recv_fragment(struct sk_buff **pending, struct sk_buff **fb, u32 msg_sz = msg_size(imsg); u32 fragm_sz = msg_data_sz(fragm); u32 exp_fragm_cnt = msg_sz/fragm_sz + !!(msg_sz % fragm_sz); - u32 max = TIPC_MAX_USER_MSG_SIZE + NAMED_H_SIZE; + u32 max = TIPC_MAX_USER_MSG_SIZE + LONG_H_SIZE; if (msg_type(imsg) == TIPC_MCAST_MSG) max = TIPC_MAX_USER_MSG_SIZE + MCAST_H_SIZE; if (msg_size(imsg) > max) { @@ -2882,7 +2882,7 @@ static int tipc_link_stats(const char *name, char *buf, const u32 buf_size) profile_total = 1; tipc_printf(&pb, " TX profile sample:%u packets average:%u octets\n" " 0-64:%u%% -256:%u%% -1024:%u%% -4096:%u%% " - "-16384:%u%% -32768:%u%% -66000:%u%%\n", + "-16354:%u%% -32768:%u%% -66000:%u%%\n", l_ptr->stats.msg_length_counts, l_ptr->stats.msg_lengths_total / profile_total, percent(l_ptr->stats.msg_length_profile[0], profile_total), diff --git a/trunk/net/tipc/msg.c b/trunk/net/tipc/msg.c index 83d50967910c..03e57bf92c73 100644 --- a/trunk/net/tipc/msg.c +++ b/trunk/net/tipc/msg.c @@ -61,8 +61,10 @@ void tipc_msg_init(struct tipc_msg *m, u32 user, u32 type, msg_set_size(m, hsize); msg_set_prevnode(m, tipc_own_addr); msg_set_type(m, type); - msg_set_orignode(m, tipc_own_addr); - msg_set_destnode(m, destnode); + if (!msg_short(m)) { + msg_set_orignode(m, tipc_own_addr); + msg_set_destnode(m, destnode); + } } /** diff --git a/trunk/net/tipc/msg.h b/trunk/net/tipc/msg.h index d93178f2e852..8452454731fa 100644 --- a/trunk/net/tipc/msg.h +++ b/trunk/net/tipc/msg.h @@ -68,10 +68,10 @@ * Message header sizes */ -#define SHORT_H_SIZE 24 /* In-cluster basic payload message */ -#define BASIC_H_SIZE 32 /* Basic payload message */ -#define NAMED_H_SIZE 40 /* Named payload message */ -#define MCAST_H_SIZE 44 /* Multicast payload message */ +#define SHORT_H_SIZE 24 /* Connected, in-cluster messages */ +#define DIR_MSG_H_SIZE 32 /* Directly addressed messages */ +#define LONG_H_SIZE 40 /* Named messages */ +#define MCAST_H_SIZE 44 /* Multicast messages */ #define INT_H_SIZE 40 /* Internal messages */ #define MIN_H_SIZE 24 /* Smallest legal TIPC header size */ #define MAX_H_SIZE 60 /* Largest possible TIPC header size */ @@ -310,6 +310,26 @@ static inline void msg_set_seqno(struct tipc_msg *m, u32 n) msg_set_bits(m, 2, 0, 0xffff, n); } +/* + * TIPC may utilize the "link ack #" and "link seq #" fields of a short + * message header to hold the destination node for the message, since the + * normal "dest node" field isn't present. This cache is only referenced + * when required, so populating the cache of a longer message header is + * harmless (as long as the header has the two link sequence fields present). + * + * Note: Host byte order is OK here, since the info never goes off-card. + */ + +static inline u32 msg_destnode_cache(struct tipc_msg *m) +{ + return m->hdr[2]; +} + +static inline void msg_set_destnode_cache(struct tipc_msg *m, u32 dnode) +{ + m->hdr[2] = dnode; +} + /* * Words 3-10 */ @@ -357,7 +377,7 @@ static inline void msg_set_mc_netid(struct tipc_msg *m, u32 p) static inline int msg_short(struct tipc_msg *m) { - return msg_hdr_sz(m) == SHORT_H_SIZE; + return msg_hdr_sz(m) == 24; } static inline u32 msg_orignode(struct tipc_msg *m) @@ -615,7 +635,7 @@ static inline u32 msg_link_selector(struct tipc_msg *m) static inline void msg_set_link_selector(struct tipc_msg *m, u32 n) { - msg_set_bits(m, 4, 0, 1, n); + msg_set_bits(m, 4, 0, 1, (n & 1)); } /* @@ -639,7 +659,7 @@ static inline u32 msg_probe(struct tipc_msg *m) static inline void msg_set_probe(struct tipc_msg *m, u32 val) { - msg_set_bits(m, 5, 0, 1, val); + msg_set_bits(m, 5, 0, 1, (val & 1)); } static inline char msg_net_plane(struct tipc_msg *m) diff --git a/trunk/net/tipc/name_distr.c b/trunk/net/tipc/name_distr.c index cd356e504332..80025a1b3bfd 100644 --- a/trunk/net/tipc/name_distr.c +++ b/trunk/net/tipc/name_distr.c @@ -94,13 +94,13 @@ static void publ_to_item(struct distr_item *i, struct publication *p) static struct sk_buff *named_prepare_buf(u32 type, u32 size, u32 dest) { - struct sk_buff *buf = tipc_buf_acquire(INT_H_SIZE + size); + struct sk_buff *buf = tipc_buf_acquire(LONG_H_SIZE + size); struct tipc_msg *msg; if (buf != NULL) { msg = buf_msg(buf); - tipc_msg_init(msg, NAME_DISTRIBUTOR, type, INT_H_SIZE, dest); - msg_set_size(msg, INT_H_SIZE + size); + tipc_msg_init(msg, NAME_DISTRIBUTOR, type, LONG_H_SIZE, dest); + msg_set_size(msg, LONG_H_SIZE + size); } return buf; } diff --git a/trunk/net/tipc/name_table.c b/trunk/net/tipc/name_table.c index 46e6b6c2ecc9..205ed4a4e186 100644 --- a/trunk/net/tipc/name_table.c +++ b/trunk/net/tipc/name_table.c @@ -2,7 +2,7 @@ * net/tipc/name_table.c: TIPC name table code * * Copyright (c) 2000-2006, Ericsson AB - * Copyright (c) 2004-2008, 2010-2011, Wind River Systems + * Copyright (c) 2004-2008, Wind River Systems * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -44,7 +44,9 @@ static int tipc_nametbl_size = 1024; /* must be a power of 2 */ /** - * struct name_info - name sequence publication info + * struct sub_seq - container for all published instances of a name sequence + * @lower: name sequence lower bound + * @upper: name sequence upper bound * @node_list: circular list of publications made by own node * @cluster_list: circular list of publications made by own cluster * @zone_list: circular list of publications made by own zone @@ -57,26 +59,15 @@ static int tipc_nametbl_size = 1024; /* must be a power of 2 */ * (The cluster and node lists may be empty.) */ -struct name_info { - struct list_head node_list; - struct list_head cluster_list; - struct list_head zone_list; - u32 node_list_size; - u32 cluster_list_size; - u32 zone_list_size; -}; - -/** - * struct sub_seq - container for all published instances of a name sequence - * @lower: name sequence lower bound - * @upper: name sequence upper bound - * @info: pointer to name sequence publication info - */ - struct sub_seq { u32 lower; u32 upper; - struct name_info *info; + struct publication *node_list; + struct publication *cluster_list; + struct publication *zone_list; + u32 node_list_size; + u32 cluster_list_size; + u32 zone_list_size; }; /** @@ -255,7 +246,6 @@ static struct publication *tipc_nameseq_insert_publ(struct name_seq *nseq, struct subscription *st; struct publication *publ; struct sub_seq *sseq; - struct name_info *info; int created_subseq = 0; sseq = nameseq_find_subseq(nseq, lower); @@ -268,8 +258,6 @@ static struct publication *tipc_nameseq_insert_publ(struct name_seq *nseq, type, lower, upper); return NULL; } - - info = sseq->info; } else { u32 inspos; struct sub_seq *freesseq; @@ -304,17 +292,6 @@ static struct publication *tipc_nameseq_insert_publ(struct name_seq *nseq, nseq->alloc *= 2; } - info = kzalloc(sizeof(*info), GFP_ATOMIC); - if (!info) { - warn("Cannot publish {%u,%u,%u}, no memory\n", - type, lower, upper); - return NULL; - } - - INIT_LIST_HEAD(&info->node_list); - INIT_LIST_HEAD(&info->cluster_list); - INIT_LIST_HEAD(&info->zone_list); - /* Insert new sub-sequence */ sseq = &nseq->sseqs[inspos]; @@ -324,7 +301,6 @@ static struct publication *tipc_nameseq_insert_publ(struct name_seq *nseq, nseq->first_free++; sseq->lower = lower; sseq->upper = upper; - sseq->info = info; created_subseq = 1; } @@ -334,17 +310,33 @@ static struct publication *tipc_nameseq_insert_publ(struct name_seq *nseq, if (!publ) return NULL; - list_add(&publ->zone_list, &info->zone_list); - info->zone_list_size++; + sseq->zone_list_size++; + if (!sseq->zone_list) + sseq->zone_list = publ->zone_list_next = publ; + else { + publ->zone_list_next = sseq->zone_list->zone_list_next; + sseq->zone_list->zone_list_next = publ; + } if (in_own_cluster(node)) { - list_add(&publ->cluster_list, &info->cluster_list); - info->cluster_list_size++; + sseq->cluster_list_size++; + if (!sseq->cluster_list) + sseq->cluster_list = publ->cluster_list_next = publ; + else { + publ->cluster_list_next = + sseq->cluster_list->cluster_list_next; + sseq->cluster_list->cluster_list_next = publ; + } } if (node == tipc_own_addr) { - list_add(&publ->node_list, &info->node_list); - info->node_list_size++; + sseq->node_list_size++; + if (!sseq->node_list) + sseq->node_list = publ->node_list_next = publ; + else { + publ->node_list_next = sseq->node_list->node_list_next; + sseq->node_list->node_list_next = publ; + } } /* @@ -378,8 +370,9 @@ static struct publication *tipc_nameseq_remove_publ(struct name_seq *nseq, u32 i u32 node, u32 ref, u32 key) { struct publication *publ; + struct publication *curr; + struct publication *prev; struct sub_seq *sseq = nameseq_find_subseq(nseq, inst); - struct name_info *info; struct sub_seq *free; struct subscription *s, *st; int removed_subseq = 0; @@ -387,41 +380,96 @@ static struct publication *tipc_nameseq_remove_publ(struct name_seq *nseq, u32 i if (!sseq) return NULL; - info = sseq->info; - - /* Locate publication, if it exists */ + /* Remove publication from zone scope list */ - list_for_each_entry(publ, &info->zone_list, zone_list) { - if ((publ->key == key) && (publ->ref == ref) && - (!publ->node || (publ->node == node))) - goto found; - } - return NULL; + prev = sseq->zone_list; + publ = sseq->zone_list->zone_list_next; + while ((publ->key != key) || (publ->ref != ref) || + (publ->node && (publ->node != node))) { + prev = publ; + publ = publ->zone_list_next; + if (prev == sseq->zone_list) { -found: - /* Remove publication from zone scope list */ + /* Prevent endless loop if publication not found */ - list_del(&publ->zone_list); - info->zone_list_size--; + return NULL; + } + } + if (publ != sseq->zone_list) + prev->zone_list_next = publ->zone_list_next; + else if (publ->zone_list_next != publ) { + prev->zone_list_next = publ->zone_list_next; + sseq->zone_list = publ->zone_list_next; + } else { + sseq->zone_list = NULL; + } + sseq->zone_list_size--; /* Remove publication from cluster scope list, if present */ if (in_own_cluster(node)) { - list_del(&publ->cluster_list); - info->cluster_list_size--; + prev = sseq->cluster_list; + curr = sseq->cluster_list->cluster_list_next; + while (curr != publ) { + prev = curr; + curr = curr->cluster_list_next; + if (prev == sseq->cluster_list) { + + /* Prevent endless loop for malformed list */ + + err("Unable to de-list cluster publication\n" + "{%u%u}, node=0x%x, ref=%u, key=%u)\n", + publ->type, publ->lower, publ->node, + publ->ref, publ->key); + goto end_cluster; + } + } + if (publ != sseq->cluster_list) + prev->cluster_list_next = publ->cluster_list_next; + else if (publ->cluster_list_next != publ) { + prev->cluster_list_next = publ->cluster_list_next; + sseq->cluster_list = publ->cluster_list_next; + } else { + sseq->cluster_list = NULL; + } + sseq->cluster_list_size--; } +end_cluster: /* Remove publication from node scope list, if present */ if (node == tipc_own_addr) { - list_del(&publ->node_list); - info->node_list_size--; + prev = sseq->node_list; + curr = sseq->node_list->node_list_next; + while (curr != publ) { + prev = curr; + curr = curr->node_list_next; + if (prev == sseq->node_list) { + + /* Prevent endless loop for malformed list */ + + err("Unable to de-list node publication\n" + "{%u%u}, node=0x%x, ref=%u, key=%u)\n", + publ->type, publ->lower, publ->node, + publ->ref, publ->key); + goto end_node; + } + } + if (publ != sseq->node_list) + prev->node_list_next = publ->node_list_next; + else if (publ->node_list_next != publ) { + prev->node_list_next = publ->node_list_next; + sseq->node_list = publ->node_list_next; + } else { + sseq->node_list = NULL; + } + sseq->node_list_size--; } +end_node: /* Contract subseq list if no more publications for that subseq */ - if (list_empty(&info->zone_list)) { - kfree(info); + if (!sseq->zone_list) { free = &nseq->sseqs[nseq->first_free--]; memmove(sseq, sseq + 1, (free - (sseq + 1)) * sizeof(*sseq)); removed_subseq = 1; @@ -458,12 +506,12 @@ static void tipc_nameseq_subscribe(struct name_seq *nseq, struct subscription *s return; while (sseq != &nseq->sseqs[nseq->first_free]) { - if (tipc_subscr_overlap(s, sseq->lower, sseq->upper)) { - struct publication *crs; - struct name_info *info = sseq->info; + struct publication *zl = sseq->zone_list; + if (zl && tipc_subscr_overlap(s, sseq->lower, sseq->upper)) { + struct publication *crs = zl; int must_report = 1; - list_for_each_entry(crs, &info->zone_list, zone_list) { + do { tipc_subscr_report_overlap(s, sseq->lower, sseq->upper, @@ -472,7 +520,8 @@ static void tipc_nameseq_subscribe(struct name_seq *nseq, struct subscription *s crs->node, must_report); must_report = 0; - } + crs = crs->zone_list_next; + } while (crs != zl); } sseq++; } @@ -542,10 +591,9 @@ struct publication *tipc_nametbl_remove_publ(u32 type, u32 lower, u32 tipc_nametbl_translate(u32 type, u32 instance, u32 *destnode) { struct sub_seq *sseq; - struct name_info *info; - struct publication *publ; + struct publication *publ = NULL; struct name_seq *seq; - u32 ref = 0; + u32 ref; if (!tipc_in_scope(*destnode, tipc_own_addr)) return 0; @@ -558,57 +606,55 @@ u32 tipc_nametbl_translate(u32 type, u32 instance, u32 *destnode) if (unlikely(!sseq)) goto not_found; spin_lock_bh(&seq->lock); - info = sseq->info; /* Closest-First Algorithm: */ if (likely(!*destnode)) { - if (!list_empty(&info->node_list)) { - publ = list_first_entry(&info->node_list, - struct publication, - node_list); - list_move_tail(&publ->node_list, - &info->node_list); - } else if (!list_empty(&info->cluster_list)) { - publ = list_first_entry(&info->cluster_list, - struct publication, - cluster_list); - list_move_tail(&publ->cluster_list, - &info->cluster_list); - } else { - publ = list_first_entry(&info->zone_list, - struct publication, - zone_list); - list_move_tail(&publ->zone_list, - &info->zone_list); + publ = sseq->node_list; + if (publ) { + sseq->node_list = publ->node_list_next; +found: + ref = publ->ref; + *destnode = publ->node; + spin_unlock_bh(&seq->lock); + read_unlock_bh(&tipc_nametbl_lock); + return ref; + } + publ = sseq->cluster_list; + if (publ) { + sseq->cluster_list = publ->cluster_list_next; + goto found; + } + publ = sseq->zone_list; + if (publ) { + sseq->zone_list = publ->zone_list_next; + goto found; } } /* Round-Robin Algorithm: */ else if (*destnode == tipc_own_addr) { - if (list_empty(&info->node_list)) - goto no_match; - publ = list_first_entry(&info->node_list, struct publication, - node_list); - list_move_tail(&publ->node_list, &info->node_list); + publ = sseq->node_list; + if (publ) { + sseq->node_list = publ->node_list_next; + goto found; + } } else if (in_own_cluster(*destnode)) { - if (list_empty(&info->cluster_list)) - goto no_match; - publ = list_first_entry(&info->cluster_list, struct publication, - cluster_list); - list_move_tail(&publ->cluster_list, &info->cluster_list); + publ = sseq->cluster_list; + if (publ) { + sseq->cluster_list = publ->cluster_list_next; + goto found; + } } else { - publ = list_first_entry(&info->zone_list, struct publication, - zone_list); - list_move_tail(&publ->zone_list, &info->zone_list); + publ = sseq->zone_list; + if (publ) { + sseq->zone_list = publ->zone_list_next; + goto found; + } } - - ref = publ->ref; - *destnode = publ->node; -no_match: spin_unlock_bh(&seq->lock); not_found: read_unlock_bh(&tipc_nametbl_lock); - return ref; + return 0; } /** @@ -630,7 +676,6 @@ int tipc_nametbl_mc_translate(u32 type, u32 lower, u32 upper, u32 limit, struct name_seq *seq; struct sub_seq *sseq; struct sub_seq *sseq_stop; - struct name_info *info; int res = 0; read_lock_bh(&tipc_nametbl_lock); @@ -648,13 +693,16 @@ int tipc_nametbl_mc_translate(u32 type, u32 lower, u32 upper, u32 limit, if (sseq->lower > upper) break; - info = sseq->info; - list_for_each_entry(publ, &info->node_list, node_list) { - if (publ->scope <= limit) - tipc_port_list_add(dports, publ->ref); + publ = sseq->node_list; + if (publ) { + do { + if (publ->scope <= limit) + tipc_port_list_add(dports, publ->ref); + publ = publ->node_list_next; + } while (publ != sseq->node_list); } - if (info->cluster_list_size != info->node_list_size) + if (sseq->cluster_list_size != sseq->node_list_size) res = 1; } @@ -792,19 +840,16 @@ static void subseq_list(struct sub_seq *sseq, struct print_buf *buf, u32 depth, { char portIdStr[27]; const char *scope_str[] = {"", " zone", " cluster", " node"}; - struct publication *publ; - struct name_info *info; + struct publication *publ = sseq->zone_list; tipc_printf(buf, "%-10u %-10u ", sseq->lower, sseq->upper); - if (depth == 2) { + if (depth == 2 || !publ) { tipc_printf(buf, "\n"); return; } - info = sseq->info; - - list_for_each_entry(publ, &info->zone_list, zone_list) { + do { sprintf(portIdStr, "<%u.%u.%u:%u>", tipc_zone(publ->node), tipc_cluster(publ->node), tipc_node(publ->node), publ->ref); @@ -813,9 +858,13 @@ static void subseq_list(struct sub_seq *sseq, struct print_buf *buf, u32 depth, tipc_printf(buf, "%-10u %s", publ->key, scope_str[publ->scope]); } - if (!list_is_last(&publ->zone_list, &info->zone_list)) - tipc_printf(buf, "\n%33s", " "); - }; + + publ = publ->zone_list_next; + if (publ == sseq->zone_list) + break; + + tipc_printf(buf, "\n%33s", " "); + } while (1); tipc_printf(buf, "\n"); } diff --git a/trunk/net/tipc/name_table.h b/trunk/net/tipc/name_table.h index 62d77e5e902e..d228bd682655 100644 --- a/trunk/net/tipc/name_table.h +++ b/trunk/net/tipc/name_table.h @@ -2,7 +2,7 @@ * net/tipc/name_table.h: Include file for TIPC name table code * * Copyright (c) 2000-2006, Ericsson AB - * Copyright (c) 2004-2005, 2010-2011, Wind River Systems + * Copyright (c) 2004-2005, Wind River Systems * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -61,9 +61,9 @@ struct port_list; * @subscr: subscription to "node down" event (for off-node publications only) * @local_list: adjacent entries in list of publications made by this node * @pport_list: adjacent entries in list of publications made by this port - * @node_list: adjacent matching name seq publications with >= node scope - * @cluster_list: adjacent matching name seq publications with >= cluster scope - * @zone_list: adjacent matching name seq publications with >= zone scope + * @node_list: next matching name seq publication with >= node scope + * @cluster_list: next matching name seq publication with >= cluster scope + * @zone_list: next matching name seq publication with >= zone scope * * Note that the node list, cluster list, and zone list are circular lists. */ @@ -79,9 +79,9 @@ struct publication { struct tipc_node_subscr subscr; struct list_head local_list; struct list_head pport_list; - struct list_head node_list; - struct list_head cluster_list; - struct list_head zone_list; + struct publication *node_list_next; + struct publication *cluster_list_next; + struct publication *zone_list_next; }; diff --git a/trunk/net/tipc/port.c b/trunk/net/tipc/port.c index 54d812a5a4d9..c68dc956a423 100644 --- a/trunk/net/tipc/port.c +++ b/trunk/net/tipc/port.c @@ -222,7 +222,7 @@ struct tipc_port *tipc_createport_raw(void *usr_handle, p_ptr->max_pkt = MAX_PKT_DEFAULT; p_ptr->ref = ref; msg = &p_ptr->phdr; - tipc_msg_init(msg, importance, TIPC_NAMED_MSG, NAMED_H_SIZE, 0); + tipc_msg_init(msg, importance, TIPC_NAMED_MSG, LONG_H_SIZE, 0); msg_set_origport(msg, ref); INIT_LIST_HEAD(&p_ptr->wait_list); INIT_LIST_HEAD(&p_ptr->subscription.nodesub_list); @@ -327,23 +327,26 @@ int tipc_set_portunreturnable(u32 ref, unsigned int isunrejectable) } /* - * port_build_proto_msg(): create connection protocol message for port - * - * On entry the port must be locked and connected. + * port_build_proto_msg(): build a port level protocol + * or a connection abortion message. Called with + * tipc_port lock on. */ -static struct sk_buff *port_build_proto_msg(struct tipc_port *p_ptr, - u32 type, u32 ack) +static struct sk_buff *port_build_proto_msg(u32 destport, u32 destnode, + u32 origport, u32 orignode, + u32 usr, u32 type, u32 err, + u32 ack) { struct sk_buff *buf; struct tipc_msg *msg; - buf = tipc_buf_acquire(INT_H_SIZE); + buf = tipc_buf_acquire(LONG_H_SIZE); if (buf) { msg = buf_msg(buf); - tipc_msg_init(msg, CONN_MANAGER, type, INT_H_SIZE, - port_peernode(p_ptr)); - msg_set_destport(msg, port_peerport(p_ptr)); - msg_set_origport(msg, p_ptr->ref); + tipc_msg_init(msg, usr, type, LONG_H_SIZE, destnode); + msg_set_errcode(msg, err); + msg_set_destport(msg, destport); + msg_set_origport(msg, origport); + msg_set_orignode(msg, orignode); msg_set_msgcnt(msg, ack); } return buf; @@ -355,48 +358,45 @@ int tipc_reject_msg(struct sk_buff *buf, u32 err) struct sk_buff *rbuf; struct tipc_msg *rmsg; int hdr_sz; - u32 imp; + u32 imp = msg_importance(msg); u32 data_sz = msg_data_sz(msg); - u32 src_node; - u32 rmsg_sz; - /* discard rejected message if it shouldn't be returned to sender */ + if (data_sz > MAX_REJECT_SIZE) + data_sz = MAX_REJECT_SIZE; + if (msg_connected(msg) && (imp < TIPC_CRITICAL_IMPORTANCE)) + imp++; - if (WARN(!msg_isdata(msg), - "attempt to reject message with user=%u", msg_user(msg))) { - dump_stack(); - goto exit; + /* discard rejected message if it shouldn't be returned to sender */ + if (msg_errcode(msg) || msg_dest_droppable(msg)) { + buf_discard(buf); + return data_sz; } - if (msg_errcode(msg) || msg_dest_droppable(msg)) - goto exit; - - /* - * construct returned message by copying rejected message header and - * data (or subset), then updating header fields that need adjusting - */ - hdr_sz = msg_hdr_sz(msg); - rmsg_sz = hdr_sz + min_t(u32, data_sz, MAX_REJECT_SIZE); - - rbuf = tipc_buf_acquire(rmsg_sz); - if (rbuf == NULL) - goto exit; - - rmsg = buf_msg(rbuf); - skb_copy_to_linear_data(rbuf, msg, rmsg_sz); - - if (msg_connected(rmsg)) { - imp = msg_importance(rmsg); - if (imp < TIPC_CRITICAL_IMPORTANCE) - msg_set_importance(rmsg, ++imp); + /* construct rejected message */ + if (msg_mcast(msg)) + hdr_sz = MCAST_H_SIZE; + else + hdr_sz = LONG_H_SIZE; + rbuf = tipc_buf_acquire(data_sz + hdr_sz); + if (rbuf == NULL) { + buf_discard(buf); + return data_sz; } - msg_set_non_seq(rmsg, 0); - msg_set_size(rmsg, rmsg_sz); + rmsg = buf_msg(rbuf); + tipc_msg_init(rmsg, imp, msg_type(msg), hdr_sz, msg_orignode(msg)); msg_set_errcode(rmsg, err); - msg_set_prevnode(rmsg, tipc_own_addr); - msg_swap_words(rmsg, 4, 5); - if (!msg_short(rmsg)) - msg_swap_words(rmsg, 6, 7); + msg_set_destport(rmsg, msg_origport(msg)); + msg_set_origport(rmsg, msg_destport(msg)); + if (msg_short(msg)) { + msg_set_orignode(rmsg, tipc_own_addr); + /* leave name type & instance as zeroes */ + } else { + msg_set_orignode(rmsg, msg_destnode(msg)); + msg_set_nametype(rmsg, msg_nametype(msg)); + msg_set_nameinst(rmsg, msg_nameinst(msg)); + } + msg_set_size(rmsg, data_sz + hdr_sz); + skb_copy_to_linear_data_offset(rbuf, hdr_sz, msg_data(msg), data_sz); /* send self-abort message when rejecting on a connected port */ if (msg_connected(msg)) { @@ -411,15 +411,9 @@ int tipc_reject_msg(struct sk_buff *buf, u32 err) tipc_net_route_msg(abuf); } - /* send returned message & dispose of rejected message */ - - src_node = msg_prevnode(msg); - if (src_node == tipc_own_addr) - tipc_port_recv_msg(rbuf); - else - tipc_link_send(rbuf, src_node, msg_link_selector(rmsg)); -exit: + /* send rejected message */ buf_discard(buf); + tipc_net_route_msg(rbuf); return data_sz; } @@ -455,7 +449,14 @@ static void port_timeout(unsigned long ref) if (p_ptr->probing_state == PROBING) { buf = port_build_self_abort_msg(p_ptr, TIPC_ERR_NO_PORT); } else { - buf = port_build_proto_msg(p_ptr, CONN_PROBE, 0); + buf = port_build_proto_msg(port_peerport(p_ptr), + port_peernode(p_ptr), + p_ptr->ref, + tipc_own_addr, + CONN_MANAGER, + CONN_PROBE, + TIPC_OK, + 0); p_ptr->probing_state = PROBING; k_start_timer(&p_ptr->timer, p_ptr->probing_interval); } @@ -479,94 +480,100 @@ static void port_handle_node_down(unsigned long ref) static struct sk_buff *port_build_self_abort_msg(struct tipc_port *p_ptr, u32 err) { - struct sk_buff *buf = port_build_peer_abort_msg(p_ptr, err); + u32 imp = msg_importance(&p_ptr->phdr); - if (buf) { - struct tipc_msg *msg = buf_msg(buf); - msg_swap_words(msg, 4, 5); - msg_swap_words(msg, 6, 7); - } - return buf; + if (!p_ptr->connected) + return NULL; + if (imp < TIPC_CRITICAL_IMPORTANCE) + imp++; + return port_build_proto_msg(p_ptr->ref, + tipc_own_addr, + port_peerport(p_ptr), + port_peernode(p_ptr), + imp, + TIPC_CONN_MSG, + err, + 0); } static struct sk_buff *port_build_peer_abort_msg(struct tipc_port *p_ptr, u32 err) { - struct sk_buff *buf; - struct tipc_msg *msg; - u32 imp; + u32 imp = msg_importance(&p_ptr->phdr); if (!p_ptr->connected) return NULL; - - buf = tipc_buf_acquire(BASIC_H_SIZE); - if (buf) { - msg = buf_msg(buf); - memcpy(msg, &p_ptr->phdr, BASIC_H_SIZE); - msg_set_hdr_sz(msg, BASIC_H_SIZE); - msg_set_size(msg, BASIC_H_SIZE); - imp = msg_importance(msg); - if (imp < TIPC_CRITICAL_IMPORTANCE) - msg_set_importance(msg, ++imp); - msg_set_errcode(msg, err); - } - return buf; + if (imp < TIPC_CRITICAL_IMPORTANCE) + imp++; + return port_build_proto_msg(port_peerport(p_ptr), + port_peernode(p_ptr), + p_ptr->ref, + tipc_own_addr, + imp, + TIPC_CONN_MSG, + err, + 0); } void tipc_port_recv_proto_msg(struct sk_buff *buf) { struct tipc_msg *msg = buf_msg(buf); - struct tipc_port *p_ptr; + struct tipc_port *p_ptr = tipc_port_lock(msg_destport(msg)); + u32 err = TIPC_OK; struct sk_buff *r_buf = NULL; - u32 orignode = msg_orignode(msg); - u32 origport = msg_origport(msg); - u32 destport = msg_destport(msg); - int wakeable; - - /* Validate connection */ - - p_ptr = tipc_port_lock(destport); - if (!p_ptr || !p_ptr->connected || - (port_peernode(p_ptr) != orignode) || - (port_peerport(p_ptr) != origport)) { - r_buf = tipc_buf_acquire(BASIC_H_SIZE); - if (r_buf) { - msg = buf_msg(r_buf); - tipc_msg_init(msg, TIPC_HIGH_IMPORTANCE, TIPC_CONN_MSG, - BASIC_H_SIZE, orignode); - msg_set_errcode(msg, TIPC_ERR_NO_PORT); - msg_set_origport(msg, destport); - msg_set_destport(msg, origport); + struct sk_buff *abort_buf = NULL; + + if (!p_ptr) { + err = TIPC_ERR_NO_PORT; + } else if (p_ptr->connected) { + if ((port_peernode(p_ptr) != msg_orignode(msg)) || + (port_peerport(p_ptr) != msg_origport(msg))) { + err = TIPC_ERR_NO_PORT; + } else if (msg_type(msg) == CONN_ACK) { + int wakeup = tipc_port_congested(p_ptr) && + p_ptr->congested && + p_ptr->wakeup; + p_ptr->acked += msg_msgcnt(msg); + if (tipc_port_congested(p_ptr)) + goto exit; + p_ptr->congested = 0; + if (!wakeup) + goto exit; + p_ptr->wakeup(p_ptr); + goto exit; } - if (p_ptr) - tipc_port_unlock(p_ptr); + } else if (p_ptr->published) { + err = TIPC_ERR_NO_PORT; + } + if (err) { + r_buf = port_build_proto_msg(msg_origport(msg), + msg_orignode(msg), + msg_destport(msg), + tipc_own_addr, + TIPC_HIGH_IMPORTANCE, + TIPC_CONN_MSG, + err, + 0); goto exit; } - /* Process protocol message sent by peer */ - - switch (msg_type(msg)) { - case CONN_ACK: - wakeable = tipc_port_congested(p_ptr) && p_ptr->congested && - p_ptr->wakeup; - p_ptr->acked += msg_msgcnt(msg); - if (!tipc_port_congested(p_ptr)) { - p_ptr->congested = 0; - if (wakeable) - p_ptr->wakeup(p_ptr); - } - break; - case CONN_PROBE: - r_buf = port_build_proto_msg(p_ptr, CONN_PROBE_REPLY, 0); - break; - default: - /* CONN_PROBE_REPLY or unrecognized - no action required */ - break; + /* All is fine */ + if (msg_type(msg) == CONN_PROBE) { + r_buf = port_build_proto_msg(msg_origport(msg), + msg_orignode(msg), + msg_destport(msg), + tipc_own_addr, + CONN_MANAGER, + CONN_PROBE_REPLY, + TIPC_OK, + 0); } p_ptr->probing_state = CONFIRMED; - tipc_port_unlock(p_ptr); exit: + if (p_ptr) + tipc_port_unlock(p_ptr); tipc_net_route_msg(r_buf); + tipc_net_route_msg(abort_buf); buf_discard(buf); } @@ -882,7 +889,14 @@ void tipc_acknowledge(u32 ref, u32 ack) return; if (p_ptr->connected) { p_ptr->conn_unacked -= ack; - buf = port_build_proto_msg(p_ptr, CONN_ACK, ack); + buf = port_build_proto_msg(port_peerport(p_ptr), + port_peernode(p_ptr), + ref, + tipc_own_addr, + CONN_MANAGER, + CONN_ACK, + TIPC_OK, + ack); } tipc_port_unlock(p_ptr); tipc_net_route_msg(buf); @@ -1126,7 +1140,19 @@ int tipc_shutdown(u32 ref) if (!p_ptr) return -EINVAL; - buf = port_build_peer_abort_msg(p_ptr, TIPC_CONN_SHUTDOWN); + if (p_ptr->connected) { + u32 imp = msg_importance(&p_ptr->phdr); + if (imp < TIPC_CRITICAL_IMPORTANCE) + imp++; + buf = port_build_proto_msg(port_peerport(p_ptr), + port_peernode(p_ptr), + ref, + tipc_own_addr, + imp, + TIPC_CONN_MSG, + TIPC_CONN_SHUTDOWN, + 0); + } tipc_port_unlock(p_ptr); tipc_net_route_msg(buf); return tipc_disconnect(ref); @@ -1212,7 +1238,7 @@ int tipc_send2name(u32 ref, struct tipc_name const *name, unsigned int domain, msg_set_type(msg, TIPC_NAMED_MSG); msg_set_orignode(msg, tipc_own_addr); msg_set_origport(msg, ref); - msg_set_hdr_sz(msg, NAMED_H_SIZE); + msg_set_hdr_sz(msg, LONG_H_SIZE); msg_set_nametype(msg, name->type); msg_set_nameinst(msg, name->instance); msg_set_lookup_scope(msg, tipc_addr_scope(domain)); @@ -1265,7 +1291,7 @@ int tipc_send2port(u32 ref, struct tipc_portid const *dest, msg_set_origport(msg, ref); msg_set_destnode(msg, dest->node); msg_set_destport(msg, dest->ref); - msg_set_hdr_sz(msg, BASIC_H_SIZE); + msg_set_hdr_sz(msg, DIR_MSG_H_SIZE); if (dest->node == tipc_own_addr) res = tipc_port_recv_sections(p_ptr, num_sect, msg_sect, @@ -1305,13 +1331,13 @@ int tipc_send_buf2port(u32 ref, struct tipc_portid const *dest, msg_set_origport(msg, ref); msg_set_destnode(msg, dest->node); msg_set_destport(msg, dest->ref); - msg_set_hdr_sz(msg, BASIC_H_SIZE); - msg_set_size(msg, BASIC_H_SIZE + dsz); - if (skb_cow(buf, BASIC_H_SIZE)) + msg_set_hdr_sz(msg, DIR_MSG_H_SIZE); + msg_set_size(msg, DIR_MSG_H_SIZE + dsz); + if (skb_cow(buf, DIR_MSG_H_SIZE)) return -ENOMEM; - skb_push(buf, BASIC_H_SIZE); - skb_copy_to_linear_data(buf, msg, BASIC_H_SIZE); + skb_push(buf, DIR_MSG_H_SIZE); + skb_copy_to_linear_data(buf, msg, DIR_MSG_H_SIZE); if (dest->node == tipc_own_addr) res = tipc_port_recv_msg(buf); diff --git a/trunk/net/tipc/socket.c b/trunk/net/tipc/socket.c index adb2eff4a102..338837396642 100644 --- a/trunk/net/tipc/socket.c +++ b/trunk/net/tipc/socket.c @@ -36,6 +36,9 @@ #include +#include +#include + #include "core.h" #include "port.h" diff --git a/trunk/net/wireless/core.c b/trunk/net/wireless/core.c index 880dbe2e6f94..c22ef3492ee6 100644 --- a/trunk/net/wireless/core.c +++ b/trunk/net/wireless/core.c @@ -366,7 +366,6 @@ struct wiphy *wiphy_new(const struct cfg80211_ops *ops, int sizeof_priv) mutex_init(&rdev->mtx); mutex_init(&rdev->devlist_mtx); - mutex_init(&rdev->sched_scan_mtx); INIT_LIST_HEAD(&rdev->netdev_list); spin_lock_init(&rdev->bss_lock); INIT_LIST_HEAD(&rdev->bss_list); @@ -702,7 +701,6 @@ void cfg80211_dev_free(struct cfg80211_registered_device *rdev) rfkill_destroy(rdev->rfkill); mutex_destroy(&rdev->mtx); mutex_destroy(&rdev->devlist_mtx); - mutex_destroy(&rdev->sched_scan_mtx); list_for_each_entry_safe(scan, tmp, &rdev->bss_list, list) cfg80211_put_bss(&scan->pub); cfg80211_rdev_free_wowlan(rdev); @@ -739,16 +737,12 @@ static void wdev_cleanup_work(struct work_struct *work) ___cfg80211_scan_done(rdev, true); } - cfg80211_unlock_rdev(rdev); - - mutex_lock(&rdev->sched_scan_mtx); - if (WARN_ON(rdev->sched_scan_req && rdev->sched_scan_req->dev == wdev->netdev)) { __cfg80211_stop_sched_scan(rdev, false); } - mutex_unlock(&rdev->sched_scan_mtx); + cfg80211_unlock_rdev(rdev); mutex_lock(&rdev->devlist_mtx); rdev->opencount--; @@ -836,9 +830,9 @@ static int cfg80211_netdev_notifier_call(struct notifier_block * nb, break; case NL80211_IFTYPE_P2P_CLIENT: case NL80211_IFTYPE_STATION: - mutex_lock(&rdev->sched_scan_mtx); + cfg80211_lock_rdev(rdev); __cfg80211_stop_sched_scan(rdev, false); - mutex_unlock(&rdev->sched_scan_mtx); + cfg80211_unlock_rdev(rdev); wdev_lock(wdev); #ifdef CONFIG_CFG80211_WEXT diff --git a/trunk/net/wireless/core.h b/trunk/net/wireless/core.h index a570ff9214ec..3dce1f167eba 100644 --- a/trunk/net/wireless/core.h +++ b/trunk/net/wireless/core.h @@ -65,8 +65,6 @@ struct cfg80211_registered_device { struct work_struct scan_done_wk; struct work_struct sched_scan_results_wk; - struct mutex sched_scan_mtx; - #ifdef CONFIG_NL80211_TESTMODE struct genl_info *testmode_info; #endif diff --git a/trunk/net/wireless/mlme.c b/trunk/net/wireless/mlme.c index 832f6574e4ed..493b939970cd 100644 --- a/trunk/net/wireless/mlme.c +++ b/trunk/net/wireless/mlme.c @@ -170,9 +170,7 @@ void __cfg80211_send_deauth(struct net_device *dev, break; } if (wdev->authtry_bsses[i] && - memcmp(wdev->authtry_bsses[i]->pub.bssid, bssid, - ETH_ALEN) == 0 && - memcmp(mgmt->sa, dev->dev_addr, ETH_ALEN) == 0) { + memcmp(wdev->authtry_bsses[i]->pub.bssid, bssid, ETH_ALEN) == 0) { cfg80211_unhold_bss(wdev->authtry_bsses[i]); cfg80211_put_bss(&wdev->authtry_bsses[i]->pub); wdev->authtry_bsses[i] = NULL; @@ -1084,14 +1082,3 @@ void cfg80211_cqm_pktloss_notify(struct net_device *dev, nl80211_send_cqm_pktloss_notify(rdev, dev, peer, num_packets, gfp); } EXPORT_SYMBOL(cfg80211_cqm_pktloss_notify); - -void cfg80211_gtk_rekey_notify(struct net_device *dev, const u8 *bssid, - const u8 *replay_ctr, gfp_t gfp) -{ - struct wireless_dev *wdev = dev->ieee80211_ptr; - struct wiphy *wiphy = wdev->wiphy; - struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); - - nl80211_gtk_rekey_notify(rdev, dev, bssid, replay_ctr, gfp); -} -EXPORT_SYMBOL(cfg80211_gtk_rekey_notify); diff --git a/trunk/net/wireless/nl80211.c b/trunk/net/wireless/nl80211.c index 6a82c898f831..10823e2b60ce 100644 --- a/trunk/net/wireless/nl80211.c +++ b/trunk/net/wireless/nl80211.c @@ -176,7 +176,6 @@ static const struct nla_policy nl80211_policy[NL80211_ATTR_MAX+1] = { [NL80211_ATTR_WOWLAN_TRIGGERS] = { .type = NLA_NESTED }, [NL80211_ATTR_STA_PLINK_STATE] = { .type = NLA_U8 }, [NL80211_ATTR_SCHED_SCAN_INTERVAL] = { .type = NLA_U32 }, - [NL80211_ATTR_REKEY_DATA] = { .type = NLA_NESTED }, }; /* policy for the key attributes */ @@ -207,14 +206,6 @@ nl80211_wowlan_policy[NUM_NL80211_WOWLAN_TRIG] = { [NL80211_WOWLAN_TRIG_PKT_PATTERN] = { .type = NLA_NESTED }, }; -/* policy for GTK rekey offload attributes */ -static const struct nla_policy -nl80211_rekey_policy[NUM_NL80211_REKEY_DATA] = { - [NL80211_REKEY_DATA_KEK] = { .len = NL80211_KEK_LEN }, - [NL80211_REKEY_DATA_KCK] = { .len = NL80211_KCK_LEN }, - [NL80211_REKEY_DATA_REPLAY_CTR] = { .len = NL80211_REPLAY_CTR_LEN }, -}; - /* ifidx get helper */ static int nl80211_get_ifidx(struct netlink_callback *cb) { @@ -3470,6 +3461,9 @@ static int nl80211_start_sched_scan(struct sk_buff *skb, if (!is_valid_ie_attr(info->attrs[NL80211_ATTR_IE])) return -EINVAL; + if (rdev->sched_scan_req) + return -EINPROGRESS; + if (!info->attrs[NL80211_ATTR_SCHED_SCAN_INTERVAL]) return -EINVAL; @@ -3508,21 +3502,12 @@ static int nl80211_start_sched_scan(struct sk_buff *skb, if (ie_len > wiphy->max_scan_ie_len) return -EINVAL; - mutex_lock(&rdev->sched_scan_mtx); - - if (rdev->sched_scan_req) { - err = -EINPROGRESS; - goto out; - } - request = kzalloc(sizeof(*request) + sizeof(*request->ssids) * n_ssids + sizeof(*request->channels) * n_channels + ie_len, GFP_KERNEL); - if (!request) { - err = -ENOMEM; - goto out; - } + if (!request) + return -ENOMEM; if (n_ssids) request->ssids = (void *)&request->channels[n_channels]; @@ -3620,7 +3605,6 @@ static int nl80211_start_sched_scan(struct sk_buff *skb, out_free: kfree(request); out: - mutex_unlock(&rdev->sched_scan_mtx); return err; } @@ -3628,21 +3612,15 @@ static int nl80211_stop_sched_scan(struct sk_buff *skb, struct genl_info *info) { struct cfg80211_registered_device *rdev = info->user_ptr[0]; - int err; if (!(rdev->wiphy.flags & WIPHY_FLAG_SUPPORTS_SCHED_SCAN) || !rdev->ops->sched_scan_stop) return -EOPNOTSUPP; - mutex_lock(&rdev->sched_scan_mtx); - err = __cfg80211_stop_sched_scan(rdev, false); - mutex_unlock(&rdev->sched_scan_mtx); - - return err; + return __cfg80211_stop_sched_scan(rdev, false); } -static int nl80211_send_bss(struct sk_buff *msg, struct netlink_callback *cb, - u32 seq, int flags, +static int nl80211_send_bss(struct sk_buff *msg, u32 pid, u32 seq, int flags, struct cfg80211_registered_device *rdev, struct wireless_dev *wdev, struct cfg80211_internal_bss *intbss) @@ -3654,13 +3632,11 @@ static int nl80211_send_bss(struct sk_buff *msg, struct netlink_callback *cb, ASSERT_WDEV_LOCK(wdev); - hdr = nl80211hdr_put(msg, NETLINK_CB(cb->skb).pid, seq, flags, + hdr = nl80211hdr_put(msg, pid, seq, flags, NL80211_CMD_NEW_SCAN_RESULTS); if (!hdr) return -1; - genl_dump_check_consistent(cb, hdr, &nl80211_fam); - NLA_PUT_U32(msg, NL80211_ATTR_GENERATION, rdev->bss_generation); NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, wdev->netdev->ifindex); @@ -3749,12 +3725,11 @@ static int nl80211_dump_scan(struct sk_buff *skb, spin_lock_bh(&rdev->bss_lock); cfg80211_bss_expire(rdev); - cb->seq = rdev->bss_generation; - list_for_each_entry(scan, &rdev->bss_list, list) { if (++idx <= start) continue; - if (nl80211_send_bss(skb, cb, + if (nl80211_send_bss(skb, + NETLINK_CB(cb->skb).pid, cb->nlh->nlmsg_seq, NLM_F_MULTI, rdev, wdev, scan) < 0) { idx--; @@ -5429,57 +5404,6 @@ static int nl80211_set_wowlan(struct sk_buff *skb, struct genl_info *info) return err; } -static int nl80211_set_rekey_data(struct sk_buff *skb, struct genl_info *info) -{ - struct cfg80211_registered_device *rdev = info->user_ptr[0]; - struct net_device *dev = info->user_ptr[1]; - struct wireless_dev *wdev = dev->ieee80211_ptr; - struct nlattr *tb[NUM_NL80211_REKEY_DATA]; - struct cfg80211_gtk_rekey_data rekey_data; - int err; - - if (!info->attrs[NL80211_ATTR_REKEY_DATA]) - return -EINVAL; - - err = nla_parse(tb, MAX_NL80211_REKEY_DATA, - nla_data(info->attrs[NL80211_ATTR_REKEY_DATA]), - nla_len(info->attrs[NL80211_ATTR_REKEY_DATA]), - nl80211_rekey_policy); - if (err) - return err; - - if (nla_len(tb[NL80211_REKEY_DATA_REPLAY_CTR]) != NL80211_REPLAY_CTR_LEN) - return -ERANGE; - if (nla_len(tb[NL80211_REKEY_DATA_KEK]) != NL80211_KEK_LEN) - return -ERANGE; - if (nla_len(tb[NL80211_REKEY_DATA_KCK]) != NL80211_KCK_LEN) - return -ERANGE; - - memcpy(rekey_data.kek, nla_data(tb[NL80211_REKEY_DATA_KEK]), - NL80211_KEK_LEN); - memcpy(rekey_data.kck, nla_data(tb[NL80211_REKEY_DATA_KCK]), - NL80211_KCK_LEN); - memcpy(rekey_data.replay_ctr, - nla_data(tb[NL80211_REKEY_DATA_REPLAY_CTR]), - NL80211_REPLAY_CTR_LEN); - - wdev_lock(wdev); - if (!wdev->current_bss) { - err = -ENOTCONN; - goto out; - } - - if (!rdev->ops->set_rekey_data) { - err = -EOPNOTSUPP; - goto out; - } - - err = rdev->ops->set_rekey_data(&rdev->wiphy, dev, &rekey_data); - out: - wdev_unlock(wdev); - return err; -} - #define NL80211_FLAG_NEED_WIPHY 0x01 #define NL80211_FLAG_NEED_NETDEV 0x02 #define NL80211_FLAG_NEED_RTNL 0x04 @@ -6011,14 +5935,6 @@ static struct genl_ops nl80211_ops[] = { .internal_flags = NL80211_FLAG_NEED_WIPHY | NL80211_FLAG_NEED_RTNL, }, - { - .cmd = NL80211_CMD_SET_REKEY_OFFLOAD, - .doit = nl80211_set_rekey_data, - .policy = nl80211_policy, - .flags = GENL_ADMIN_PERM, - .internal_flags = NL80211_FLAG_NEED_NETDEV_UP | - NL80211_FLAG_NEED_RTNL, - }, }; static struct genl_multicast_group nl80211_mlme_mcgrp = { @@ -6646,8 +6562,7 @@ void nl80211_michael_mic_failure(struct cfg80211_registered_device *rdev, if (addr) NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, addr); NLA_PUT_U32(msg, NL80211_ATTR_KEY_TYPE, key_type); - if (key_id != -1) - NLA_PUT_U8(msg, NL80211_ATTR_KEY_IDX, key_id); + NLA_PUT_U8(msg, NL80211_ATTR_KEY_IDX, key_id); if (tsc) NLA_PUT(msg, NL80211_ATTR_KEY_SEQ, 6, tsc); @@ -6963,51 +6878,6 @@ nl80211_send_cqm_rssi_notify(struct cfg80211_registered_device *rdev, nlmsg_free(msg); } -void nl80211_gtk_rekey_notify(struct cfg80211_registered_device *rdev, - struct net_device *netdev, const u8 *bssid, - const u8 *replay_ctr, gfp_t gfp) -{ - struct sk_buff *msg; - struct nlattr *rekey_attr; - void *hdr; - - msg = nlmsg_new(NLMSG_GOODSIZE, gfp); - if (!msg) - return; - - hdr = nl80211hdr_put(msg, 0, 0, 0, NL80211_CMD_SET_REKEY_OFFLOAD); - if (!hdr) { - nlmsg_free(msg); - return; - } - - NLA_PUT_U32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx); - NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex); - NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, bssid); - - rekey_attr = nla_nest_start(msg, NL80211_ATTR_REKEY_DATA); - if (!rekey_attr) - goto nla_put_failure; - - NLA_PUT(msg, NL80211_REKEY_DATA_REPLAY_CTR, - NL80211_REPLAY_CTR_LEN, replay_ctr); - - nla_nest_end(msg, rekey_attr); - - if (genlmsg_end(msg, hdr) < 0) { - nlmsg_free(msg); - return; - } - - genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, - nl80211_mlme_mcgrp.id, gfp); - return; - - nla_put_failure: - genlmsg_cancel(msg, hdr); - nlmsg_free(msg); -} - void nl80211_send_cqm_pktloss_notify(struct cfg80211_registered_device *rdev, struct net_device *netdev, const u8 *peer, diff --git a/trunk/net/wireless/nl80211.h b/trunk/net/wireless/nl80211.h index 5d69c56400ae..2f1bfb87a651 100644 --- a/trunk/net/wireless/nl80211.h +++ b/trunk/net/wireless/nl80211.h @@ -109,8 +109,4 @@ nl80211_send_cqm_pktloss_notify(struct cfg80211_registered_device *rdev, struct net_device *netdev, const u8 *peer, u32 num_packets, gfp_t gfp); -void nl80211_gtk_rekey_notify(struct cfg80211_registered_device *rdev, - struct net_device *netdev, const u8 *bssid, - const u8 *replay_ctr, gfp_t gfp); - #endif /* __NET_WIRELESS_NL80211_H */ diff --git a/trunk/net/wireless/scan.c b/trunk/net/wireless/scan.c index 2cc9d4ab5578..7a6c67667d70 100644 --- a/trunk/net/wireless/scan.c +++ b/trunk/net/wireless/scan.c @@ -100,14 +100,14 @@ void __cfg80211_sched_scan_results(struct work_struct *wk) rdev = container_of(wk, struct cfg80211_registered_device, sched_scan_results_wk); - mutex_lock(&rdev->sched_scan_mtx); + cfg80211_lock_rdev(rdev); /* we don't have sched_scan_req anymore if the scan is stopping */ if (rdev->sched_scan_req) nl80211_send_sched_scan_results(rdev, rdev->sched_scan_req->dev); - mutex_unlock(&rdev->sched_scan_mtx); + cfg80211_unlock_rdev(rdev); } void cfg80211_sched_scan_results(struct wiphy *wiphy) @@ -123,18 +123,19 @@ void cfg80211_sched_scan_stopped(struct wiphy *wiphy) { struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); - mutex_lock(&rdev->sched_scan_mtx); + cfg80211_lock_rdev(rdev); __cfg80211_stop_sched_scan(rdev, true); - mutex_unlock(&rdev->sched_scan_mtx); + cfg80211_unlock_rdev(rdev); } EXPORT_SYMBOL(cfg80211_sched_scan_stopped); int __cfg80211_stop_sched_scan(struct cfg80211_registered_device *rdev, bool driver_initiated) { + int err; struct net_device *dev; - lockdep_assert_held(&rdev->sched_scan_mtx); + ASSERT_RDEV_LOCK(rdev); if (!rdev->sched_scan_req) return 0; @@ -142,7 +143,7 @@ int __cfg80211_stop_sched_scan(struct cfg80211_registered_device *rdev, dev = rdev->sched_scan_req->dev; if (!driver_initiated) { - int err = rdev->ops->sched_scan_stop(&rdev->wiphy, dev); + err = rdev->ops->sched_scan_stop(&rdev->wiphy, dev); if (err) return err; } @@ -152,7 +153,7 @@ int __cfg80211_stop_sched_scan(struct cfg80211_registered_device *rdev, kfree(rdev->sched_scan_req); rdev->sched_scan_req = NULL; - return 0; + return err; } static void bss_release(struct kref *ref) diff --git a/trunk/net/x25/af_x25.c b/trunk/net/x25/af_x25.c index d30615419b4d..4680b1e4c79c 100644 --- a/trunk/net/x25/af_x25.c +++ b/trunk/net/x25/af_x25.c @@ -237,21 +237,21 @@ static int x25_device_event(struct notifier_block *this, unsigned long event, #endif ) { switch (event) { - case NETDEV_UP: - x25_link_device_up(dev); - break; - case NETDEV_GOING_DOWN: - nb = x25_get_neigh(dev); - if (nb) { - x25_terminate_link(nb); - x25_neigh_put(nb); - } - break; - case NETDEV_DOWN: - x25_kill_by_device(dev); - x25_route_device_down(dev); - x25_link_device_down(dev); - break; + case NETDEV_UP: + x25_link_device_up(dev); + break; + case NETDEV_GOING_DOWN: + nb = x25_get_neigh(dev); + if (nb) { + x25_terminate_link(nb); + x25_neigh_put(nb); + } + break; + case NETDEV_DOWN: + x25_kill_by_device(dev); + x25_route_device_down(dev); + x25_link_device_down(dev); + break; } } @@ -1336,253 +1336,256 @@ static int x25_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) int rc; switch (cmd) { - case TIOCOUTQ: { - int amount; + case TIOCOUTQ: { + int amount; - amount = sk->sk_sndbuf - sk_wmem_alloc_get(sk); - if (amount < 0) - amount = 0; - rc = put_user(amount, (unsigned int __user *)argp); - break; - } + amount = sk->sk_sndbuf - sk_wmem_alloc_get(sk); + if (amount < 0) + amount = 0; + rc = put_user(amount, (unsigned int __user *)argp); + break; + } - case TIOCINQ: { - struct sk_buff *skb; - int amount = 0; - /* - * These two are safe on a single CPU system as - * only user tasks fiddle here - */ - lock_sock(sk); - if ((skb = skb_peek(&sk->sk_receive_queue)) != NULL) - amount = skb->len; - release_sock(sk); - rc = put_user(amount, (unsigned int __user *)argp); - break; - } + case TIOCINQ: { + struct sk_buff *skb; + int amount = 0; + /* + * These two are safe on a single CPU system as + * only user tasks fiddle here + */ + lock_sock(sk); + if ((skb = skb_peek(&sk->sk_receive_queue)) != NULL) + amount = skb->len; + release_sock(sk); + rc = put_user(amount, (unsigned int __user *)argp); + break; + } - case SIOCGSTAMP: - rc = -EINVAL; - if (sk) - rc = sock_get_timestamp(sk, + case SIOCGSTAMP: + rc = -EINVAL; + if (sk) + rc = sock_get_timestamp(sk, (struct timeval __user *)argp); - break; - case SIOCGSTAMPNS: - rc = -EINVAL; - if (sk) - rc = sock_get_timestampns(sk, - (struct timespec __user *)argp); - break; - case SIOCGIFADDR: - case SIOCSIFADDR: - case SIOCGIFDSTADDR: - case SIOCSIFDSTADDR: - case SIOCGIFBRDADDR: - case SIOCSIFBRDADDR: - case SIOCGIFNETMASK: - case SIOCSIFNETMASK: - case SIOCGIFMETRIC: - case SIOCSIFMETRIC: - rc = -EINVAL; - break; - case SIOCADDRT: - case SIOCDELRT: - rc = -EPERM; - if (!capable(CAP_NET_ADMIN)) break; - rc = x25_route_ioctl(cmd, argp); - break; - case SIOCX25GSUBSCRIP: - rc = x25_subscr_ioctl(cmd, argp); - break; - case SIOCX25SSUBSCRIP: - rc = -EPERM; - if (!capable(CAP_NET_ADMIN)) + case SIOCGSTAMPNS: + rc = -EINVAL; + if (sk) + rc = sock_get_timestampns(sk, + (struct timespec __user *)argp); break; - rc = x25_subscr_ioctl(cmd, argp); - break; - case SIOCX25GFACILITIES: { - lock_sock(sk); - rc = copy_to_user(argp, &x25->facilities, - sizeof(x25->facilities)) - ? -EFAULT : 0; - release_sock(sk); - break; - } - - case SIOCX25SFACILITIES: { - struct x25_facilities facilities; - rc = -EFAULT; - if (copy_from_user(&facilities, argp, sizeof(facilities))) + case SIOCGIFADDR: + case SIOCSIFADDR: + case SIOCGIFDSTADDR: + case SIOCSIFDSTADDR: + case SIOCGIFBRDADDR: + case SIOCSIFBRDADDR: + case SIOCGIFNETMASK: + case SIOCSIFNETMASK: + case SIOCGIFMETRIC: + case SIOCSIFMETRIC: + rc = -EINVAL; + break; + case SIOCADDRT: + case SIOCDELRT: + rc = -EPERM; + if (!capable(CAP_NET_ADMIN)) + break; + rc = x25_route_ioctl(cmd, argp); + break; + case SIOCX25GSUBSCRIP: + rc = x25_subscr_ioctl(cmd, argp); + break; + case SIOCX25SSUBSCRIP: + rc = -EPERM; + if (!capable(CAP_NET_ADMIN)) + break; + rc = x25_subscr_ioctl(cmd, argp); + break; + case SIOCX25GFACILITIES: { + lock_sock(sk); + rc = copy_to_user(argp, &x25->facilities, + sizeof(x25->facilities)) + ? -EFAULT : 0; + release_sock(sk); break; - rc = -EINVAL; - lock_sock(sk); - if (sk->sk_state != TCP_LISTEN && - sk->sk_state != TCP_CLOSE) - goto out_fac_release; - if (facilities.pacsize_in < X25_PS16 || - facilities.pacsize_in > X25_PS4096) - goto out_fac_release; - if (facilities.pacsize_out < X25_PS16 || - facilities.pacsize_out > X25_PS4096) - goto out_fac_release; - if (facilities.winsize_in < 1 || - facilities.winsize_in > 127) - goto out_fac_release; - if (facilities.throughput) { - int out = facilities.throughput & 0xf0; - int in = facilities.throughput & 0x0f; - if (!out) - facilities.throughput |= - X25_DEFAULT_THROUGHPUT << 4; - else if (out < 0x30 || out > 0xD0) - goto out_fac_release; - if (!in) - facilities.throughput |= - X25_DEFAULT_THROUGHPUT; - else if (in < 0x03 || in > 0x0D) - goto out_fac_release; } - if (facilities.reverse && - (facilities.reverse & 0x81) != 0x81) - goto out_fac_release; - x25->facilities = facilities; - rc = 0; -out_fac_release: - release_sock(sk); - break; - } - case SIOCX25GDTEFACILITIES: { - lock_sock(sk); - rc = copy_to_user(argp, &x25->dte_facilities, - sizeof(x25->dte_facilities)); - release_sock(sk); - if (rc) + case SIOCX25SFACILITIES: { + struct x25_facilities facilities; rc = -EFAULT; - break; - } + if (copy_from_user(&facilities, argp, + sizeof(facilities))) + break; + rc = -EINVAL; + lock_sock(sk); + if (sk->sk_state != TCP_LISTEN && + sk->sk_state != TCP_CLOSE) + goto out_fac_release; + if (facilities.pacsize_in < X25_PS16 || + facilities.pacsize_in > X25_PS4096) + goto out_fac_release; + if (facilities.pacsize_out < X25_PS16 || + facilities.pacsize_out > X25_PS4096) + goto out_fac_release; + if (facilities.winsize_in < 1 || + facilities.winsize_in > 127) + goto out_fac_release; + if (facilities.throughput) { + int out = facilities.throughput & 0xf0; + int in = facilities.throughput & 0x0f; + if (!out) + facilities.throughput |= + X25_DEFAULT_THROUGHPUT << 4; + else if (out < 0x30 || out > 0xD0) + goto out_fac_release; + if (!in) + facilities.throughput |= + X25_DEFAULT_THROUGHPUT; + else if (in < 0x03 || in > 0x0D) + goto out_fac_release; + } + if (facilities.reverse && + (facilities.reverse & 0x81) != 0x81) + goto out_fac_release; + x25->facilities = facilities; + rc = 0; +out_fac_release: + release_sock(sk); + break; + } - case SIOCX25SDTEFACILITIES: { - struct x25_dte_facilities dtefacs; - rc = -EFAULT; - if (copy_from_user(&dtefacs, argp, sizeof(dtefacs))) + case SIOCX25GDTEFACILITIES: { + lock_sock(sk); + rc = copy_to_user(argp, &x25->dte_facilities, + sizeof(x25->dte_facilities)); + release_sock(sk); + if (rc) + rc = -EFAULT; break; - rc = -EINVAL; - lock_sock(sk); - if (sk->sk_state != TCP_LISTEN && - sk->sk_state != TCP_CLOSE) - goto out_dtefac_release; - if (dtefacs.calling_len > X25_MAX_AE_LEN) - goto out_dtefac_release; - if (dtefacs.calling_ae == NULL) - goto out_dtefac_release; - if (dtefacs.called_len > X25_MAX_AE_LEN) - goto out_dtefac_release; - if (dtefacs.called_ae == NULL) - goto out_dtefac_release; - x25->dte_facilities = dtefacs; - rc = 0; + } + + case SIOCX25SDTEFACILITIES: { + struct x25_dte_facilities dtefacs; + rc = -EFAULT; + if (copy_from_user(&dtefacs, argp, sizeof(dtefacs))) + break; + rc = -EINVAL; + lock_sock(sk); + if (sk->sk_state != TCP_LISTEN && + sk->sk_state != TCP_CLOSE) + goto out_dtefac_release; + if (dtefacs.calling_len > X25_MAX_AE_LEN) + goto out_dtefac_release; + if (dtefacs.calling_ae == NULL) + goto out_dtefac_release; + if (dtefacs.called_len > X25_MAX_AE_LEN) + goto out_dtefac_release; + if (dtefacs.called_ae == NULL) + goto out_dtefac_release; + x25->dte_facilities = dtefacs; + rc = 0; out_dtefac_release: - release_sock(sk); - break; - } + release_sock(sk); + break; + } - case SIOCX25GCALLUSERDATA: { - lock_sock(sk); - rc = copy_to_user(argp, &x25->calluserdata, - sizeof(x25->calluserdata)) - ? -EFAULT : 0; - release_sock(sk); - break; - } + case SIOCX25GCALLUSERDATA: { + lock_sock(sk); + rc = copy_to_user(argp, &x25->calluserdata, + sizeof(x25->calluserdata)) + ? -EFAULT : 0; + release_sock(sk); + break; + } - case SIOCX25SCALLUSERDATA: { - struct x25_calluserdata calluserdata; + case SIOCX25SCALLUSERDATA: { + struct x25_calluserdata calluserdata; - rc = -EFAULT; - if (copy_from_user(&calluserdata, argp, sizeof(calluserdata))) - break; - rc = -EINVAL; - if (calluserdata.cudlength > X25_MAX_CUD_LEN) + rc = -EFAULT; + if (copy_from_user(&calluserdata, argp, + sizeof(calluserdata))) + break; + rc = -EINVAL; + if (calluserdata.cudlength > X25_MAX_CUD_LEN) + break; + lock_sock(sk); + x25->calluserdata = calluserdata; + release_sock(sk); + rc = 0; break; - lock_sock(sk); - x25->calluserdata = calluserdata; - release_sock(sk); - rc = 0; - break; - } + } - case SIOCX25GCAUSEDIAG: { - lock_sock(sk); - rc = copy_to_user(argp, &x25->causediag, sizeof(x25->causediag)) - ? -EFAULT : 0; - release_sock(sk); - break; - } + case SIOCX25GCAUSEDIAG: { + lock_sock(sk); + rc = copy_to_user(argp, &x25->causediag, + sizeof(x25->causediag)) + ? -EFAULT : 0; + release_sock(sk); + break; + } - case SIOCX25SCAUSEDIAG: { - struct x25_causediag causediag; - rc = -EFAULT; - if (copy_from_user(&causediag, argp, sizeof(causediag))) + case SIOCX25SCAUSEDIAG: { + struct x25_causediag causediag; + rc = -EFAULT; + if (copy_from_user(&causediag, argp, sizeof(causediag))) + break; + lock_sock(sk); + x25->causediag = causediag; + release_sock(sk); + rc = 0; break; - lock_sock(sk); - x25->causediag = causediag; - release_sock(sk); - rc = 0; - break; - } + } - case SIOCX25SCUDMATCHLEN: { - struct x25_subaddr sub_addr; - rc = -EINVAL; - lock_sock(sk); - if(sk->sk_state != TCP_CLOSE) - goto out_cud_release; - rc = -EFAULT; - if (copy_from_user(&sub_addr, argp, - sizeof(sub_addr))) - goto out_cud_release; - rc = -EINVAL; - if (sub_addr.cudmatchlength > X25_MAX_CUD_LEN) - goto out_cud_release; - x25->cudmatchlength = sub_addr.cudmatchlength; - rc = 0; + case SIOCX25SCUDMATCHLEN: { + struct x25_subaddr sub_addr; + rc = -EINVAL; + lock_sock(sk); + if(sk->sk_state != TCP_CLOSE) + goto out_cud_release; + rc = -EFAULT; + if (copy_from_user(&sub_addr, argp, + sizeof(sub_addr))) + goto out_cud_release; + rc = -EINVAL; + if(sub_addr.cudmatchlength > X25_MAX_CUD_LEN) + goto out_cud_release; + x25->cudmatchlength = sub_addr.cudmatchlength; + rc = 0; out_cud_release: - release_sock(sk); - break; - } - - case SIOCX25CALLACCPTAPPRV: { - rc = -EINVAL; - lock_sock(sk); - if (sk->sk_state != TCP_CLOSE) + release_sock(sk); break; - clear_bit(X25_ACCPT_APPRV_FLAG, &x25->flags); - release_sock(sk); - rc = 0; - break; - } + } - case SIOCX25SENDCALLACCPT: { - rc = -EINVAL; - lock_sock(sk); - if (sk->sk_state != TCP_ESTABLISHED) + case SIOCX25CALLACCPTAPPRV: { + rc = -EINVAL; + lock_sock(sk); + if (sk->sk_state != TCP_CLOSE) + break; + clear_bit(X25_ACCPT_APPRV_FLAG, &x25->flags); + release_sock(sk); + rc = 0; break; - /* must call accptapprv above */ - if (test_bit(X25_ACCPT_APPRV_FLAG, &x25->flags)) + } + + case SIOCX25SENDCALLACCPT: { + rc = -EINVAL; + lock_sock(sk); + if (sk->sk_state != TCP_ESTABLISHED) + break; + /* must call accptapprv above */ + if (test_bit(X25_ACCPT_APPRV_FLAG, &x25->flags)) + break; + x25_write_internal(sk, X25_CALL_ACCEPTED); + x25->state = X25_STATE_3; + release_sock(sk); + rc = 0; break; - x25_write_internal(sk, X25_CALL_ACCEPTED); - x25->state = X25_STATE_3; - release_sock(sk); - rc = 0; - break; - } + } - default: - rc = -ENOIOCTLCMD; - break; + default: + rc = -ENOIOCTLCMD; + break; } return rc; diff --git a/trunk/net/x25/x25_dev.c b/trunk/net/x25/x25_dev.c index e547ca1578c3..9005f6daeab5 100644 --- a/trunk/net/x25/x25_dev.c +++ b/trunk/net/x25/x25_dev.c @@ -146,21 +146,21 @@ void x25_establish_link(struct x25_neigh *nb) unsigned char *ptr; switch (nb->dev->type) { - case ARPHRD_X25: - if ((skb = alloc_skb(1, GFP_ATOMIC)) == NULL) { - printk(KERN_ERR "x25_dev: out of memory\n"); - return; - } - ptr = skb_put(skb, 1); - *ptr = X25_IFACE_CONNECT; - break; + case ARPHRD_X25: + if ((skb = alloc_skb(1, GFP_ATOMIC)) == NULL) { + printk(KERN_ERR "x25_dev: out of memory\n"); + return; + } + ptr = skb_put(skb, 1); + *ptr = X25_IFACE_CONNECT; + break; #if defined(CONFIG_LLC) || defined(CONFIG_LLC_MODULE) - case ARPHRD_ETHER: - return; + case ARPHRD_ETHER: + return; #endif - default: - return; + default: + return; } skb->protocol = htons(ETH_P_X25); @@ -202,19 +202,19 @@ void x25_send_frame(struct sk_buff *skb, struct x25_neigh *nb) skb_reset_network_header(skb); switch (nb->dev->type) { - case ARPHRD_X25: - dptr = skb_push(skb, 1); - *dptr = X25_IFACE_DATA; - break; + case ARPHRD_X25: + dptr = skb_push(skb, 1); + *dptr = X25_IFACE_DATA; + break; #if defined(CONFIG_LLC) || defined(CONFIG_LLC_MODULE) - case ARPHRD_ETHER: - kfree_skb(skb); - return; + case ARPHRD_ETHER: + kfree_skb(skb); + return; #endif - default: - kfree_skb(skb); - return; + default: + kfree_skb(skb); + return; } skb->protocol = htons(ETH_P_X25); diff --git a/trunk/net/x25/x25_in.c b/trunk/net/x25/x25_in.c index 0b073b51b183..15de65f04719 100644 --- a/trunk/net/x25/x25_in.c +++ b/trunk/net/x25/x25_in.c @@ -94,55 +94,55 @@ static int x25_state1_machine(struct sock *sk, struct sk_buff *skb, int frametyp struct x25_sock *x25 = x25_sk(sk); switch (frametype) { - case X25_CALL_ACCEPTED: { - - x25_stop_timer(sk); - x25->condition = 0x00; - x25->vs = 0; - x25->va = 0; - x25->vr = 0; - x25->vl = 0; - x25->state = X25_STATE_3; - sk->sk_state = TCP_ESTABLISHED; - /* - * Parse the data in the frame. - */ - skb_pull(skb, X25_STD_MIN_LEN); - - len = x25_parse_address_block(skb, &source_addr, - &dest_addr); - if (len > 0) - skb_pull(skb, len); - else if (len < 0) - goto out_clear; - - len = x25_parse_facilities(skb, &x25->facilities, - &x25->dte_facilities, - &x25->vc_facil_mask); - if (len > 0) - skb_pull(skb, len); - else if (len < 0) - goto out_clear; - /* - * Copy any Call User Data. - */ - if (skb->len > 0) { - skb_copy_from_linear_data(skb, - x25->calluserdata.cuddata, - skb->len); - x25->calluserdata.cudlength = skb->len; + case X25_CALL_ACCEPTED: { + + x25_stop_timer(sk); + x25->condition = 0x00; + x25->vs = 0; + x25->va = 0; + x25->vr = 0; + x25->vl = 0; + x25->state = X25_STATE_3; + sk->sk_state = TCP_ESTABLISHED; + /* + * Parse the data in the frame. + */ + skb_pull(skb, X25_STD_MIN_LEN); + + len = x25_parse_address_block(skb, &source_addr, + &dest_addr); + if (len > 0) + skb_pull(skb, len); + else if (len < 0) + goto out_clear; + + len = x25_parse_facilities(skb, &x25->facilities, + &x25->dte_facilities, + &x25->vc_facil_mask); + if (len > 0) + skb_pull(skb, len); + else if (len < 0) + goto out_clear; + /* + * Copy any Call User Data. + */ + if (skb->len > 0) { + skb_copy_from_linear_data(skb, + x25->calluserdata.cuddata, + skb->len); + x25->calluserdata.cudlength = skb->len; + } + if (!sock_flag(sk, SOCK_DEAD)) + sk->sk_state_change(sk); + break; } - if (!sock_flag(sk, SOCK_DEAD)) - sk->sk_state_change(sk); - break; - } - case X25_CLEAR_REQUEST: - x25_write_internal(sk, X25_CLEAR_CONFIRMATION); - x25_disconnect(sk, ECONNREFUSED, skb->data[3], skb->data[4]); - break; + case X25_CLEAR_REQUEST: + x25_write_internal(sk, X25_CLEAR_CONFIRMATION); + x25_disconnect(sk, ECONNREFUSED, skb->data[3], skb->data[4]); + break; - default: - break; + default: + break; } return 0; @@ -354,18 +354,18 @@ int x25_process_rx_frame(struct sock *sk, struct sk_buff *skb) frametype = x25_decode(sk, skb, &ns, &nr, &q, &d, &m); switch (x25->state) { - case X25_STATE_1: - queued = x25_state1_machine(sk, skb, frametype); - break; - case X25_STATE_2: - queued = x25_state2_machine(sk, skb, frametype); - break; - case X25_STATE_3: - queued = x25_state3_machine(sk, skb, frametype, ns, nr, q, d, m); - break; - case X25_STATE_4: - queued = x25_state4_machine(sk, skb, frametype); - break; + case X25_STATE_1: + queued = x25_state1_machine(sk, skb, frametype); + break; + case X25_STATE_2: + queued = x25_state2_machine(sk, skb, frametype); + break; + case X25_STATE_3: + queued = x25_state3_machine(sk, skb, frametype, ns, nr, q, d, m); + break; + case X25_STATE_4: + queued = x25_state4_machine(sk, skb, frametype); + break; } x25_kick(sk); diff --git a/trunk/net/x25/x25_link.c b/trunk/net/x25/x25_link.c index 037958ff8eed..21306928d47f 100644 --- a/trunk/net/x25/x25_link.c +++ b/trunk/net/x25/x25_link.c @@ -76,29 +76,30 @@ void x25_link_control(struct sk_buff *skb, struct x25_neigh *nb, int confirm; switch (frametype) { - case X25_RESTART_REQUEST: - confirm = !x25_t20timer_pending(nb); - x25_stop_t20timer(nb); - nb->state = X25_LINK_STATE_3; - if (confirm) - x25_transmit_restart_confirmation(nb); - break; - - case X25_RESTART_CONFIRMATION: - x25_stop_t20timer(nb); - nb->state = X25_LINK_STATE_3; - break; - - case X25_DIAGNOSTIC: - printk(KERN_WARNING "x25: diagnostic #%d - %02X %02X %02X\n", - skb->data[3], skb->data[4], - skb->data[5], skb->data[6]); - break; - - default: - printk(KERN_WARNING "x25: received unknown %02X with LCI 000\n", - frametype); - break; + case X25_RESTART_REQUEST: + confirm = !x25_t20timer_pending(nb); + x25_stop_t20timer(nb); + nb->state = X25_LINK_STATE_3; + if (confirm) + x25_transmit_restart_confirmation(nb); + break; + + case X25_RESTART_CONFIRMATION: + x25_stop_t20timer(nb); + nb->state = X25_LINK_STATE_3; + break; + + case X25_DIAGNOSTIC: + printk(KERN_WARNING "x25: diagnostic #%d - " + "%02X %02X %02X\n", + skb->data[3], skb->data[4], + skb->data[5], skb->data[6]); + break; + + default: + printk(KERN_WARNING "x25: received unknown %02X " + "with LCI 000\n", frametype); + break; } if (nb->state == X25_LINK_STATE_3) @@ -192,18 +193,18 @@ void x25_transmit_clear_request(struct x25_neigh *nb, unsigned int lci, void x25_transmit_link(struct sk_buff *skb, struct x25_neigh *nb) { switch (nb->state) { - case X25_LINK_STATE_0: - skb_queue_tail(&nb->queue, skb); - nb->state = X25_LINK_STATE_1; - x25_establish_link(nb); - break; - case X25_LINK_STATE_1: - case X25_LINK_STATE_2: - skb_queue_tail(&nb->queue, skb); - break; - case X25_LINK_STATE_3: - x25_send_frame(skb, nb); - break; + case X25_LINK_STATE_0: + skb_queue_tail(&nb->queue, skb); + nb->state = X25_LINK_STATE_1; + x25_establish_link(nb); + break; + case X25_LINK_STATE_1: + case X25_LINK_STATE_2: + skb_queue_tail(&nb->queue, skb); + break; + case X25_LINK_STATE_3: + x25_send_frame(skb, nb); + break; } } @@ -213,14 +214,14 @@ void x25_transmit_link(struct sk_buff *skb, struct x25_neigh *nb) void x25_link_established(struct x25_neigh *nb) { switch (nb->state) { - case X25_LINK_STATE_0: - nb->state = X25_LINK_STATE_2; - break; - case X25_LINK_STATE_1: - x25_transmit_restart_request(nb); - nb->state = X25_LINK_STATE_2; - x25_start_t20timer(nb); - break; + case X25_LINK_STATE_0: + nb->state = X25_LINK_STATE_2; + break; + case X25_LINK_STATE_1: + x25_transmit_restart_request(nb); + nb->state = X25_LINK_STATE_2; + x25_start_t20timer(nb); + break; } } diff --git a/trunk/net/x25/x25_subr.c b/trunk/net/x25/x25_subr.c index 24a342ebc7f5..dc20cf12f39b 100644 --- a/trunk/net/x25/x25_subr.c +++ b/trunk/net/x25/x25_subr.c @@ -126,30 +126,32 @@ void x25_write_internal(struct sock *sk, int frametype) * Adjust frame size. */ switch (frametype) { - case X25_CALL_REQUEST: - len += 1 + X25_ADDR_LEN + X25_MAX_FAC_LEN + X25_MAX_CUD_LEN; - break; - case X25_CALL_ACCEPTED: /* fast sel with no restr on resp */ - if (x25->facilities.reverse & 0x80) { - len += 1 + X25_MAX_FAC_LEN + X25_MAX_CUD_LEN; - } else { - len += 1 + X25_MAX_FAC_LEN; - } - break; - case X25_CLEAR_REQUEST: - case X25_RESET_REQUEST: - len += 2; - break; - case X25_RR: - case X25_RNR: - case X25_REJ: - case X25_CLEAR_CONFIRMATION: - case X25_INTERRUPT_CONFIRMATION: - case X25_RESET_CONFIRMATION: - break; - default: - printk(KERN_ERR "X.25: invalid frame type %02X\n", frametype); - return; + case X25_CALL_REQUEST: + len += 1 + X25_ADDR_LEN + X25_MAX_FAC_LEN + + X25_MAX_CUD_LEN; + break; + case X25_CALL_ACCEPTED: /* fast sel with no restr on resp */ + if(x25->facilities.reverse & 0x80) { + len += 1 + X25_MAX_FAC_LEN + X25_MAX_CUD_LEN; + } else { + len += 1 + X25_MAX_FAC_LEN; + } + break; + case X25_CLEAR_REQUEST: + case X25_RESET_REQUEST: + len += 2; + break; + case X25_RR: + case X25_RNR: + case X25_REJ: + case X25_CLEAR_CONFIRMATION: + case X25_INTERRUPT_CONFIRMATION: + case X25_RESET_CONFIRMATION: + break; + default: + printk(KERN_ERR "X.25: invalid frame type %02X\n", + frametype); + return; } if ((skb = alloc_skb(len, GFP_ATOMIC)) == NULL) @@ -274,20 +276,20 @@ int x25_decode(struct sock *sk, struct sk_buff *skb, int *ns, int *nr, int *q, *ns = *nr = *q = *d = *m = 0; switch (frame[2]) { - case X25_CALL_REQUEST: - case X25_CALL_ACCEPTED: - case X25_CLEAR_REQUEST: - case X25_CLEAR_CONFIRMATION: - case X25_INTERRUPT: - case X25_INTERRUPT_CONFIRMATION: - case X25_RESET_REQUEST: - case X25_RESET_CONFIRMATION: - case X25_RESTART_REQUEST: - case X25_RESTART_CONFIRMATION: - case X25_REGISTRATION_REQUEST: - case X25_REGISTRATION_CONFIRMATION: - case X25_DIAGNOSTIC: - return frame[2]; + case X25_CALL_REQUEST: + case X25_CALL_ACCEPTED: + case X25_CLEAR_REQUEST: + case X25_CLEAR_CONFIRMATION: + case X25_INTERRUPT: + case X25_INTERRUPT_CONFIRMATION: + case X25_RESET_REQUEST: + case X25_RESET_CONFIRMATION: + case X25_RESTART_REQUEST: + case X25_RESTART_CONFIRMATION: + case X25_REGISTRATION_REQUEST: + case X25_REGISTRATION_CONFIRMATION: + case X25_DIAGNOSTIC: + return frame[2]; } if (x25->neighbour->extended) { diff --git a/trunk/net/xfrm/xfrm_policy.c b/trunk/net/xfrm/xfrm_policy.c index 5ce74a385525..9bec2e8a838c 100644 --- a/trunk/net/xfrm/xfrm_policy.c +++ b/trunk/net/xfrm/xfrm_policy.c @@ -50,7 +50,7 @@ static struct xfrm_policy_afinfo *xfrm_policy_get_afinfo(unsigned short family); static void xfrm_policy_put_afinfo(struct xfrm_policy_afinfo *afinfo); static void xfrm_init_pmtu(struct dst_entry *dst); static int stale_bundle(struct dst_entry *dst); -static int xfrm_bundle_ok(struct xfrm_dst *xdst); +static int xfrm_bundle_ok(struct xfrm_dst *xdst, int family); static struct xfrm_policy *__xfrm_policy_unlink(struct xfrm_policy *pol, @@ -2241,7 +2241,7 @@ static struct dst_entry *xfrm_dst_check(struct dst_entry *dst, u32 cookie) static int stale_bundle(struct dst_entry *dst) { - return !xfrm_bundle_ok((struct xfrm_dst *)dst); + return !xfrm_bundle_ok((struct xfrm_dst *)dst, AF_UNSPEC); } void xfrm_dst_ifdown(struct dst_entry *dst, struct net_device *dev) @@ -2313,7 +2313,7 @@ static void xfrm_init_pmtu(struct dst_entry *dst) * still valid. */ -static int xfrm_bundle_ok(struct xfrm_dst *first) +static int xfrm_bundle_ok(struct xfrm_dst *first, int family) { struct dst_entry *dst = &first->u.dst; struct xfrm_dst *last; diff --git a/trunk/net/xfrm/xfrm_state.c b/trunk/net/xfrm/xfrm_state.c index 9414b9c5b1e4..d70f85eb7864 100644 --- a/trunk/net/xfrm/xfrm_state.c +++ b/trunk/net/xfrm/xfrm_state.c @@ -1345,8 +1345,6 @@ int xfrm_state_update(struct xfrm_state *x) xfrm_state_check_expire(x1); err = 0; - x->km.state = XFRM_STATE_DEAD; - __xfrm_state_put(x); } spin_unlock_bh(&x1->lock); diff --git a/trunk/scripts/depmod.sh b/trunk/scripts/depmod.sh index a27235685949..3b029cba2baf 100755 --- a/trunk/scripts/depmod.sh +++ b/trunk/scripts/depmod.sh @@ -21,15 +21,13 @@ fi # older versions of depmod require the version string to start with three # numbers, so we cheat with a symlink here depmod_hack_needed=true -tmp_dir=$(mktemp -d ${TMPDIR:-/tmp}/depmod.XXXXXX) -mkdir -p "$tmp_dir/lib/modules/$KERNELRELEASE" -if "$DEPMOD" -b "$tmp_dir" $KERNELRELEASE 2>/dev/null; then - if test -e "$tmp_dir/lib/modules/$KERNELRELEASE/modules.dep" -o \ - -e "$tmp_dir/lib/modules/$KERNELRELEASE/modules.dep.bin"; then +mkdir -p .tmp_depmod/lib/modules/$KERNELRELEASE +if "$DEPMOD" -b .tmp_depmod $KERNELRELEASE 2>/dev/null; then + if test -e .tmp_depmod/lib/modules/$KERNELRELEASE/modules.dep -o \ + -e .tmp_depmod/lib/modules/$KERNELRELEASE/modules.dep.bin; then depmod_hack_needed=false fi fi -rm -rf "$tmp_dir" if $depmod_hack_needed; then symlink="$INSTALL_MOD_PATH/lib/modules/99.98.$KERNELRELEASE" ln -s "$KERNELRELEASE" "$symlink" diff --git a/trunk/security/keys/request_key.c b/trunk/security/keys/request_key.c index 82465328c39b..8e319a416eec 100644 --- a/trunk/security/keys/request_key.c +++ b/trunk/security/keys/request_key.c @@ -469,7 +469,7 @@ static struct key *construct_key_and_link(struct key_type *type, } else if (ret == -EINPROGRESS) { ret = 0; } else { - goto couldnt_alloc_key; + key = ERR_PTR(ret); } key_put(dest_keyring); @@ -479,7 +479,6 @@ static struct key *construct_key_and_link(struct key_type *type, construction_failed: key_negate_and_link(key, key_negative_timeout, NULL, NULL); key_put(key); -couldnt_alloc_key: key_put(dest_keyring); kleave(" = %d", ret); return ERR_PTR(ret); diff --git a/trunk/sound/atmel/abdac.c b/trunk/sound/atmel/abdac.c index bfee60c4d4c0..6e2409181895 100644 --- a/trunk/sound/atmel/abdac.c +++ b/trunk/sound/atmel/abdac.c @@ -599,4 +599,4 @@ module_exit(atmel_abdac_exit); MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("Driver for Atmel Audio Bitstream DAC (ABDAC)"); -MODULE_AUTHOR("Hans-Christian Egtvedt "); +MODULE_AUTHOR("Hans-Christian Egtvedt "); diff --git a/trunk/sound/atmel/ac97c.c b/trunk/sound/atmel/ac97c.c index ac35222ad0dd..b310702c646e 100644 --- a/trunk/sound/atmel/ac97c.c +++ b/trunk/sound/atmel/ac97c.c @@ -1199,4 +1199,4 @@ module_exit(atmel_ac97c_exit); MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("Driver for Atmel AC97 controller"); -MODULE_AUTHOR("Hans-Christian Egtvedt "); +MODULE_AUTHOR("Hans-Christian Egtvedt "); diff --git a/trunk/sound/pci/asihpi/asihpi.c b/trunk/sound/pci/asihpi/asihpi.c index e3569bdd3b64..2ca6f4f85b41 100644 --- a/trunk/sound/pci/asihpi/asihpi.c +++ b/trunk/sound/pci/asihpi/asihpi.c @@ -27,6 +27,7 @@ #include "hpioctl.h" #include +#include #include #include #include diff --git a/trunk/sound/pci/cs5535audio/cs5535audio_pcm.c b/trunk/sound/pci/cs5535audio/cs5535audio_pcm.c index e083122ca55a..f16bc8aad6ed 100644 --- a/trunk/sound/pci/cs5535audio/cs5535audio_pcm.c +++ b/trunk/sound/pci/cs5535audio/cs5535audio_pcm.c @@ -149,7 +149,7 @@ static int cs5535audio_build_dma_packets(struct cs5535audio *cs5535au, &((struct cs5535audio_dma_desc *) dma->desc_buf.area)[i]; desc->addr = cpu_to_le32(addr); desc->size = cpu_to_le32(period_bytes); - desc->ctlreserved = cpu_to_le16(PRD_EOP); + desc->ctlreserved = cpu_to_le32(PRD_EOP); desc_addr += sizeof(struct cs5535audio_dma_desc); addr += period_bytes; } @@ -157,7 +157,7 @@ static int cs5535audio_build_dma_packets(struct cs5535audio *cs5535au, lastdesc = &((struct cs5535audio_dma_desc *) dma->desc_buf.area)[periods]; lastdesc->addr = cpu_to_le32((u32) dma->desc_buf.addr); lastdesc->size = 0; - lastdesc->ctlreserved = cpu_to_le16(PRD_JMP); + lastdesc->ctlreserved = cpu_to_le32(PRD_JMP); jmpprd_addr = cpu_to_le32(lastdesc->addr + (sizeof(struct cs5535audio_dma_desc)*periods)); diff --git a/trunk/sound/pci/hda/hda_eld.c b/trunk/sound/pci/hda/hda_eld.c index e3e853153d14..b05f7be9dc1b 100644 --- a/trunk/sound/pci/hda/hda_eld.c +++ b/trunk/sound/pci/hda/hda_eld.c @@ -294,7 +294,7 @@ static int hdmi_update_eld(struct hdmi_eld *e, snd_printd(KERN_INFO "HDMI: out of range MNL %d\n", mnl); goto out_fail; } else - strlcpy(e->monitor_name, buf + ELD_FIXED_BYTES, mnl + 1); + strlcpy(e->monitor_name, buf + ELD_FIXED_BYTES, mnl); for (i = 0; i < e->sad_count; i++) { if (ELD_FIXED_BYTES + mnl + 3 * (i + 1) > size) { diff --git a/trunk/sound/pci/hda/patch_conexant.c b/trunk/sound/pci/hda/patch_conexant.c index 7bbc5f237a5e..694b9daf691f 100644 --- a/trunk/sound/pci/hda/patch_conexant.c +++ b/trunk/sound/pci/hda/patch_conexant.c @@ -3074,7 +3074,6 @@ static const char * const cxt5066_models[CXT5066_MODELS] = { }; static const struct snd_pci_quirk cxt5066_cfg_tbl[] = { - SND_PCI_QUIRK(0x1025, 0x054c, "Acer Aspire 3830TG", CXT5066_AUTO), SND_PCI_QUIRK_MASK(0x1025, 0xff00, 0x0400, "Acer", CXT5066_IDEAPAD), SND_PCI_QUIRK(0x1028, 0x02d8, "Dell Vostro", CXT5066_DELL_VOSTRO), SND_PCI_QUIRK(0x1028, 0x02f5, "Dell Vostro 320", CXT5066_IDEAPAD), @@ -4390,8 +4389,6 @@ static const struct hda_codec_preset snd_hda_preset_conexant[] = { .patch = patch_cxt5066 }, { .id = 0x14f15069, .name = "CX20585", .patch = patch_cxt5066 }, - { .id = 0x14f1506c, .name = "CX20588", - .patch = patch_cxt5066 }, { .id = 0x14f1506e, .name = "CX20590", .patch = patch_cxt5066 }, { .id = 0x14f15097, .name = "CX20631", @@ -4420,7 +4417,6 @@ MODULE_ALIAS("snd-hda-codec-id:14f15066"); MODULE_ALIAS("snd-hda-codec-id:14f15067"); MODULE_ALIAS("snd-hda-codec-id:14f15068"); MODULE_ALIAS("snd-hda-codec-id:14f15069"); -MODULE_ALIAS("snd-hda-codec-id:14f1506c"); MODULE_ALIAS("snd-hda-codec-id:14f1506e"); MODULE_ALIAS("snd-hda-codec-id:14f15097"); MODULE_ALIAS("snd-hda-codec-id:14f15098"); diff --git a/trunk/sound/pci/hda/patch_realtek.c b/trunk/sound/pci/hda/patch_realtek.c index b48fb43b5448..61a774b3d3cb 100644 --- a/trunk/sound/pci/hda/patch_realtek.c +++ b/trunk/sound/pci/hda/patch_realtek.c @@ -2715,30 +2715,17 @@ typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol, static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol, - getput_call_t func, bool check_adc_switch) + getput_call_t func) { struct hda_codec *codec = snd_kcontrol_chip(kcontrol); struct alc_spec *spec = codec->spec; - int i, err = 0; + unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); + int err; mutex_lock(&codec->control_mutex); - if (check_adc_switch && spec->dual_adc_switch) { - for (i = 0; i < spec->num_adc_nids; i++) { - kcontrol->private_value = - HDA_COMPOSE_AMP_VAL(spec->adc_nids[i], - 3, 0, HDA_INPUT); - err = func(kcontrol, ucontrol); - if (err < 0) - goto error; - } - } else { - i = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); - kcontrol->private_value = - HDA_COMPOSE_AMP_VAL(spec->adc_nids[i], - 3, 0, HDA_INPUT); - err = func(kcontrol, ucontrol); - } - error: + kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx], + 3, 0, HDA_INPUT); + err = func(kcontrol, ucontrol); mutex_unlock(&codec->control_mutex); return err; } @@ -2747,14 +2734,14 @@ static int alc_cap_vol_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { return alc_cap_getput_caller(kcontrol, ucontrol, - snd_hda_mixer_amp_volume_get, false); + snd_hda_mixer_amp_volume_get); } static int alc_cap_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { return alc_cap_getput_caller(kcontrol, ucontrol, - snd_hda_mixer_amp_volume_put, true); + snd_hda_mixer_amp_volume_put); } /* capture mixer elements */ @@ -2764,14 +2751,14 @@ static int alc_cap_sw_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { return alc_cap_getput_caller(kcontrol, ucontrol, - snd_hda_mixer_amp_switch_get, false); + snd_hda_mixer_amp_switch_get); } static int alc_cap_sw_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { return alc_cap_getput_caller(kcontrol, ucontrol, - snd_hda_mixer_amp_switch_put, true); + snd_hda_mixer_amp_switch_put); } #define _DEFINE_CAPMIX(num) \ @@ -4896,6 +4883,7 @@ static const struct snd_pci_quirk alc880_cfg_tbl[] = { SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG), SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST), SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG), + SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST), SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V), SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG), SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG), @@ -12612,7 +12600,6 @@ static const struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = { */ enum { PINFIX_FSC_H270, - PINFIX_HP_Z200, }; static const struct alc_fixup alc262_fixups[] = { @@ -12625,17 +12612,9 @@ static const struct alc_fixup alc262_fixups[] = { { } } }, - [PINFIX_HP_Z200] = { - .type = ALC_FIXUP_PINS, - .v.pins = (const struct alc_pincfg[]) { - { 0x16, 0x99130120 }, /* internal speaker */ - { } - } - }, }; static const struct snd_pci_quirk alc262_fixup_tbl[] = { - SND_PCI_QUIRK(0x103c, 0x170b, "HP Z200", PINFIX_HP_Z200), SND_PCI_QUIRK(0x1734, 0x1147, "FSC Celsius H270", PINFIX_FSC_H270), {} }; @@ -12752,8 +12731,6 @@ static const struct snd_pci_quirk alc262_cfg_tbl[] = { ALC262_HP_BPC), SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1500, "HP z series", ALC262_HP_BPC), - SND_PCI_QUIRK(0x103c, 0x170b, "HP Z200", - ALC262_AUTO), SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series", ALC262_HP_BPC), SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL), @@ -13895,6 +13872,7 @@ static const struct snd_pci_quirk alc268_cfg_tbl[] = { SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST), SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO), SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA), + SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER), SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1), {} }; diff --git a/trunk/sound/pci/hda/patch_via.c b/trunk/sound/pci/hda/patch_via.c index f43bb0eaed8b..c952582fb218 100644 --- a/trunk/sound/pci/hda/patch_via.c +++ b/trunk/sound/pci/hda/patch_via.c @@ -745,23 +745,12 @@ static int via_independent_hp_put(struct snd_kcontrol *kcontrol, struct via_spec *spec = codec->spec; hda_nid_t nid = kcontrol->private_value; unsigned int pinsel = ucontrol->value.enumerated.item[0]; - unsigned int parm0, parm1; /* Get Independent Mode index of headphone pin widget */ spec->hp_independent_mode = spec->hp_independent_mode_index == pinsel ? 1 : 0; - if (spec->codec_type == VT1718S) { + if (spec->codec_type == VT1718S) snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, pinsel ? 2 : 0); - /* Set correct mute switch for MW3 */ - parm0 = spec->hp_independent_mode ? - AMP_IN_UNMUTE(0) : AMP_IN_MUTE(0); - parm1 = spec->hp_independent_mode ? - AMP_IN_MUTE(1) : AMP_IN_UNMUTE(1); - snd_hda_codec_write(codec, 0x1b, 0, - AC_VERB_SET_AMP_GAIN_MUTE, parm0); - snd_hda_codec_write(codec, 0x1b, 0, - AC_VERB_SET_AMP_GAIN_MUTE, parm1); - } else snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, pinsel); @@ -4294,6 +4283,9 @@ static const struct hda_verb vt1718S_volume_init_verbs[] = { {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)}, + + /* Setup default input of Front HP to MW9 */ + {0x28, AC_VERB_SET_CONNECT_SEL, 0x1}, /* PW9 PW10 Output enable */ {0x2d, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_OUT_EN}, {0x2e, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_OUT_EN}, @@ -4302,10 +4294,10 @@ static const struct hda_verb vt1718S_volume_init_verbs[] = { /* Enable Boost Volume backdoor */ {0x1, 0xf88, 0x8}, /* MW0/1/2/3/4: un-mute index 0 (AOWx), mute index 1 (MW9) */ - {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, + {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, - {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, + {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, @@ -4315,6 +4307,8 @@ static const struct hda_verb vt1718S_volume_init_verbs[] = { /* set MUX1 = 2 (AOW4), MUX2 = 1 (AOW3) */ {0x34, AC_VERB_SET_CONNECT_SEL, 0x2}, {0x35, AC_VERB_SET_CONNECT_SEL, 0x1}, + /* Unmute MW4's index 0 */ + {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, { } }; @@ -4462,19 +4456,6 @@ static int vt1718S_auto_create_multi_out_ctls(struct via_spec *spec, if (err < 0) return err; } else if (i == AUTO_SEQ_FRONT) { - /* add control to mixer index 0 */ - err = via_add_control(spec, VIA_CTL_WIDGET_VOL, - "Master Front Playback Volume", - HDA_COMPOSE_AMP_VAL(0x21, 3, 5, - HDA_INPUT)); - if (err < 0) - return err; - err = via_add_control(spec, VIA_CTL_WIDGET_MUTE, - "Master Front Playback Switch", - HDA_COMPOSE_AMP_VAL(0x21, 3, 5, - HDA_INPUT)); - if (err < 0) - return err; /* Front */ sprintf(name, "%s Playback Volume", chname[i]); err = via_add_control( diff --git a/trunk/sound/pci/rme9652/hdspm.c b/trunk/sound/pci/rme9652/hdspm.c index c8e402fc3782..3f08afc0f0d3 100644 --- a/trunk/sound/pci/rme9652/hdspm.c +++ b/trunk/sound/pci/rme9652/hdspm.c @@ -896,11 +896,11 @@ struct hdspm { unsigned char max_channels_in; unsigned char max_channels_out; - signed char *channel_map_in; - signed char *channel_map_out; + char *channel_map_in; + char *channel_map_out; - signed char *channel_map_in_ss, *channel_map_in_ds, *channel_map_in_qs; - signed char *channel_map_out_ss, *channel_map_out_ds, *channel_map_out_qs; + char *channel_map_in_ss, *channel_map_in_ds, *channel_map_in_qs; + char *channel_map_out_ss, *channel_map_out_ds, *channel_map_out_qs; char **port_names_in; char **port_names_out; diff --git a/trunk/sound/soc/blackfin/bf5xx-i2s-pcm.c b/trunk/sound/soc/blackfin/bf5xx-i2s-pcm.c index f1fd95bb6416..b5101efd1c87 100644 --- a/trunk/sound/soc/blackfin/bf5xx-i2s-pcm.c +++ b/trunk/sound/soc/blackfin/bf5xx-i2s-pcm.c @@ -138,20 +138,11 @@ static snd_pcm_uframes_t bf5xx_pcm_pointer(struct snd_pcm_substream *substream) pr_debug("%s enter\n", __func__); if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { diff = sport_curr_offset_tx(sport); + frames = bytes_to_frames(substream->runtime, diff); } else { diff = sport_curr_offset_rx(sport); + frames = bytes_to_frames(substream->runtime, diff); } - - /* - * TX at least can report one frame beyond the end of the - * buffer if we hit the wraparound case - clamp to within the - * buffer as the ALSA APIs require. - */ - if (diff == snd_pcm_lib_buffer_bytes(substream)) - diff = 0; - - frames = bytes_to_frames(substream->runtime, diff); - return frames; } diff --git a/trunk/sound/soc/codecs/ak4642.c b/trunk/sound/soc/codecs/ak4642.c index 65f46047b1cb..4be0570e3f1f 100644 --- a/trunk/sound/soc/codecs/ak4642.c +++ b/trunk/sound/soc/codecs/ak4642.c @@ -357,7 +357,7 @@ static int ak4642_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) default: return -EINVAL; } - snd_soc_update_bits(codec, PW_MGMT2, MS | MCKO | PMPLL, data); + snd_soc_update_bits(codec, PW_MGMT2, MS, data); snd_soc_update_bits(codec, MD_CTL1, BCKO_MASK, bcko); /* format type */ diff --git a/trunk/sound/soc/codecs/tlv320aic26.c b/trunk/sound/soc/codecs/tlv320aic26.c index 7859bdcc93db..e2a7608d3944 100644 --- a/trunk/sound/soc/codecs/tlv320aic26.c +++ b/trunk/sound/soc/codecs/tlv320aic26.c @@ -161,18 +161,10 @@ static int aic26_hw_params(struct snd_pcm_substream *substream, dev_dbg(&aic26->spi->dev, "bad format\n"); return -EINVAL; } - /** - * Configure PLL - * fsref = (mclk * PLLM) / 2048 - * where PLLM = J.DDDD (DDDD register ranges from 0 to 9999, decimal) - */ + /* Configure PLL */ pval = 1; - /* compute J portion of multiplier */ - jval = fsref / (aic26->mclk / 2048); - /* compute fractional DDDD component of multiplier */ - dval = fsref - (jval * (aic26->mclk / 2048)); - dval = (10000 * dval) / (aic26->mclk / 2048); - dev_dbg(&aic26->spi->dev, "Setting PLLM to %d.%04d\n", jval, dval); + jval = (fsref == 44100) ? 7 : 8; + dval = (fsref == 44100) ? 5264 : 1920; qval = 0; reg = 0x8000 | qval << 11 | pval << 8 | jval << 2; aic26_reg_write(codec, AIC26_REG_PLL_PROG1, reg); diff --git a/trunk/sound/soc/codecs/tlv320aic3x.c b/trunk/sound/soc/codecs/tlv320aic3x.c index 789453d44ec5..c3d96fc8c267 100644 --- a/trunk/sound/soc/codecs/tlv320aic3x.c +++ b/trunk/sound/soc/codecs/tlv320aic3x.c @@ -1114,19 +1114,12 @@ static int aic3x_set_power(struct snd_soc_codec *codec, int power) /* Sync reg_cache with the hardware */ codec->cache_only = 0; - for (i = AIC3X_SAMPLE_RATE_SEL_REG; i < ARRAY_SIZE(aic3x_reg); i++) + for (i = 0; i < ARRAY_SIZE(aic3x_reg); i++) snd_soc_write(codec, i, cache[i]); if (aic3x->model == AIC3X_MODEL_3007) aic3x_init_3007(codec); codec->cache_sync = 0; } else { - /* - * Do soft reset to this codec instance in order to clear - * possible VDD leakage currents in case the supply regulators - * remain on - */ - snd_soc_write(codec, AIC3X_RESET, SOFT_RESET); - codec->cache_sync = 1; aic3x->power = 0; /* HW writes are needless when bias is off */ codec->cache_only = 1; diff --git a/trunk/sound/soc/codecs/wm8731.c b/trunk/sound/soc/codecs/wm8731.c index 76b4361e9b80..2dc964b55e4f 100644 --- a/trunk/sound/soc/codecs/wm8731.c +++ b/trunk/sound/soc/codecs/wm8731.c @@ -175,7 +175,6 @@ static const struct snd_kcontrol_new wm8731_input_mux_controls = SOC_DAPM_ENUM("Input Select", wm8731_insel_enum); static const struct snd_soc_dapm_widget wm8731_dapm_widgets[] = { -SND_SOC_DAPM_SUPPLY("ACTIVE",WM8731_ACTIVE, 0, 0, NULL, 0), SND_SOC_DAPM_SUPPLY("OSC", WM8731_PWR, 5, 1, NULL, 0), SND_SOC_DAPM_MIXER("Output Mixer", WM8731_PWR, 4, 1, &wm8731_output_mixer_controls[0], @@ -205,8 +204,6 @@ static int wm8731_check_osc(struct snd_soc_dapm_widget *source, static const struct snd_soc_dapm_route wm8731_intercon[] = { {"DAC", NULL, "OSC", wm8731_check_osc}, {"ADC", NULL, "OSC", wm8731_check_osc}, - {"DAC", NULL, "ACTIVE"}, - {"ADC", NULL, "ACTIVE"}, /* output mixer */ {"Output Mixer", "Line Bypass Switch", "Line Input"}, @@ -318,6 +315,29 @@ static int wm8731_hw_params(struct snd_pcm_substream *substream, return 0; } +static int wm8731_pcm_prepare(struct snd_pcm_substream *substream, + struct snd_soc_dai *dai) +{ + struct snd_soc_codec *codec = dai->codec; + + /* set active */ + snd_soc_write(codec, WM8731_ACTIVE, 0x0001); + + return 0; +} + +static void wm8731_shutdown(struct snd_pcm_substream *substream, + struct snd_soc_dai *dai) +{ + struct snd_soc_codec *codec = dai->codec; + + /* deactivate */ + if (!codec->active) { + udelay(50); + snd_soc_write(codec, WM8731_ACTIVE, 0x0); + } +} + static int wm8731_mute(struct snd_soc_dai *dai, int mute) { struct snd_soc_codec *codec = dai->codec; @@ -460,6 +480,7 @@ static int wm8731_set_bias_level(struct snd_soc_codec *codec, snd_soc_write(codec, WM8731_PWR, reg | 0x0040); break; case SND_SOC_BIAS_OFF: + snd_soc_write(codec, WM8731_ACTIVE, 0x0); snd_soc_write(codec, WM8731_PWR, 0xffff); regulator_bulk_disable(ARRAY_SIZE(wm8731->supplies), wm8731->supplies); @@ -475,7 +496,9 @@ static int wm8731_set_bias_level(struct snd_soc_codec *codec, SNDRV_PCM_FMTBIT_S24_LE) static struct snd_soc_dai_ops wm8731_dai_ops = { + .prepare = wm8731_pcm_prepare, .hw_params = wm8731_hw_params, + .shutdown = wm8731_shutdown, .digital_mute = wm8731_mute, .set_sysclk = wm8731_set_dai_sysclk, .set_fmt = wm8731_set_dai_fmt, diff --git a/trunk/sound/soc/codecs/wm8991.c b/trunk/sound/soc/codecs/wm8991.c index 6af23d06870f..3c2ee1bb73cd 100644 --- a/trunk/sound/soc/codecs/wm8991.c +++ b/trunk/sound/soc/codecs/wm8991.c @@ -13,6 +13,7 @@ #include #include +#include #include #include #include diff --git a/trunk/sound/soc/codecs/wm8994.c b/trunk/sound/soc/codecs/wm8994.c index c2fc0356c2a4..970a95c5360b 100644 --- a/trunk/sound/soc/codecs/wm8994.c +++ b/trunk/sound/soc/codecs/wm8994.c @@ -1713,8 +1713,6 @@ static int _wm8994_set_fll(struct snd_soc_codec *codec, int id, int src, snd_soc_update_bits(codec, WM8994_FLL1_CONTROL_1 + reg_offset, WM8994_FLL1_ENA | WM8994_FLL1_FRAC, reg); - - msleep(5); } wm8994->fll[id].in = freq_in; diff --git a/trunk/sound/soc/imx/Kconfig b/trunk/sound/soc/imx/Kconfig index bb699bb55a50..d8f130d39dd9 100644 --- a/trunk/sound/soc/imx/Kconfig +++ b/trunk/sound/soc/imx/Kconfig @@ -11,6 +11,9 @@ menuconfig SND_IMX_SOC if SND_IMX_SOC +config SND_MXC_SOC_SSI + tristate + config SND_MXC_SOC_FIQ tristate @@ -21,6 +24,7 @@ config SND_MXC_SOC_WM1133_EV1 tristate "Audio on the the i.MX31ADS with WM1133-EV1 fitted" depends on MACH_MX31ADS_WM1133_EV1 && EXPERIMENTAL select SND_SOC_WM8350 + select SND_MXC_SOC_SSI select SND_MXC_SOC_FIQ help Enable support for audio on the i.MX31ADS with the WM1133-EV1 @@ -30,6 +34,7 @@ config SND_SOC_MX27VIS_AIC32X4 tristate "SoC audio support for Visstrim M10 boards" depends on MACH_IMX27_VISSTRIM_M10 select SND_SOC_TVL320AIC32X4 + select SND_MXC_SOC_SSI select SND_MXC_SOC_MX2 help Say Y if you want to add support for SoC audio on Visstrim SM10 @@ -39,6 +44,7 @@ config SND_SOC_PHYCORE_AC97 tristate "SoC Audio support for Phytec phyCORE (and phyCARD) boards" depends on MACH_PCM043 || MACH_PCA100 select SND_SOC_WM9712 + select SND_MXC_SOC_SSI select SND_MXC_SOC_FIQ help Say Y if you want to add support for SoC audio on Phytec phyCORE @@ -51,6 +57,7 @@ config SND_SOC_EUKREA_TLV320 || MACH_EUKREA_MBIMXSD35_BASEBOARD \ || MACH_EUKREA_MBIMXSD51_BASEBOARD select SND_SOC_TLV320AIC23 + select SND_MXC_SOC_SSI select SND_MXC_SOC_FIQ help Enable I2S based access to the TLV320AIC23B codec attached diff --git a/trunk/sound/soc/imx/imx-pcm-dma-mx2.c b/trunk/sound/soc/imx/imx-pcm-dma-mx2.c index 4173b3d87f97..aab7765f401a 100644 --- a/trunk/sound/soc/imx/imx-pcm-dma-mx2.c +++ b/trunk/sound/soc/imx/imx-pcm-dma-mx2.c @@ -337,5 +337,3 @@ static void __exit snd_imx_pcm_exit(void) platform_driver_unregister(&imx_pcm_driver); } module_exit(snd_imx_pcm_exit); -MODULE_LICENSE("GPL"); -MODULE_ALIAS("platform:imx-pcm-audio"); diff --git a/trunk/sound/soc/imx/imx-ssi.c b/trunk/sound/soc/imx/imx-ssi.c index 61fceb09cdb5..5b13feca7537 100644 --- a/trunk/sound/soc/imx/imx-ssi.c +++ b/trunk/sound/soc/imx/imx-ssi.c @@ -774,4 +774,4 @@ module_exit(imx_ssi_exit); MODULE_AUTHOR("Sascha Hauer, "); MODULE_DESCRIPTION("i.MX I2S/ac97 SoC Interface"); MODULE_LICENSE("GPL"); -MODULE_ALIAS("platform:imx-ssi"); + diff --git a/trunk/sound/soc/pxa/pxa2xx-pcm.c b/trunk/sound/soc/pxa/pxa2xx-pcm.c index fab20a54e863..2ce0b2d891d5 100644 --- a/trunk/sound/soc/pxa/pxa2xx-pcm.c +++ b/trunk/sound/soc/pxa/pxa2xx-pcm.c @@ -95,14 +95,14 @@ static int pxa2xx_soc_pcm_new(struct snd_card *card, struct snd_soc_dai *dai, if (!card->dev->coherent_dma_mask) card->dev->coherent_dma_mask = DMA_BIT_MASK(32); - if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) { + if (dai->driver->playback.channels_min) { ret = pxa2xx_pcm_preallocate_dma_buffer(pcm, SNDRV_PCM_STREAM_PLAYBACK); if (ret) goto out; } - if (pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream) { + if (dai->driver->capture.channels_min) { ret = pxa2xx_pcm_preallocate_dma_buffer(pcm, SNDRV_PCM_STREAM_CAPTURE); if (ret) diff --git a/trunk/sound/soc/soc-cache.c b/trunk/sound/soc/soc-cache.c index 039b9532b270..c005ceb70c9d 100644 --- a/trunk/sound/soc/soc-cache.c +++ b/trunk/sound/soc/soc-cache.c @@ -409,6 +409,9 @@ int snd_soc_codec_set_cache_io(struct snd_soc_codec *codec, codec->bulk_write_raw = snd_soc_hw_bulk_write_raw; switch (control) { + case SND_SOC_CUSTOM: + break; + case SND_SOC_I2C: #if defined(CONFIG_I2C) || (defined(CONFIG_I2C_MODULE) && defined(MODULE)) codec->hw_write = (hw_write_t)i2c_master_send; diff --git a/trunk/sound/soc/soc-core.c b/trunk/sound/soc/soc-core.c index b194be09e74d..d75043ed7fc0 100644 --- a/trunk/sound/soc/soc-core.c +++ b/trunk/sound/soc/soc-core.c @@ -1929,9 +1929,8 @@ static void snd_soc_instantiate_card(struct snd_soc_card *card) "%s", card->name); snprintf(card->snd_card->longname, sizeof(card->snd_card->longname), "%s", card->long_name ? card->long_name : card->name); - if (card->driver_name) - strlcpy(card->snd_card->driver, card->driver_name, - sizeof(card->snd_card->driver)); + snprintf(card->snd_card->driver, sizeof(card->snd_card->driver), + "%s", card->driver_name ? card->driver_name : card->name); if (card->late_probe) { ret = card->late_probe(card); diff --git a/trunk/sound/soc/tegra/tegra_i2s.c b/trunk/sound/soc/tegra/tegra_i2s.c index 95f03c10b4f7..6b817e20548c 100644 --- a/trunk/sound/soc/tegra/tegra_i2s.c +++ b/trunk/sound/soc/tegra/tegra_i2s.c @@ -222,18 +222,12 @@ static int tegra_i2s_hw_params(struct snd_pcm_substream *substream, if (i2sclock % (2 * srate)) reg |= TEGRA_I2S_TIMING_NON_SYM_ENABLE; - if (!i2s->clk_refs) - clk_enable(i2s->clk_i2s); - tegra_i2s_write(i2s, TEGRA_I2S_TIMING, reg); tegra_i2s_write(i2s, TEGRA_I2S_FIFO_SCR, TEGRA_I2S_FIFO_SCR_FIFO2_ATN_LVL_FOUR_SLOTS | TEGRA_I2S_FIFO_SCR_FIFO1_ATN_LVL_FOUR_SLOTS); - if (!i2s->clk_refs) - clk_disable(i2s->clk_i2s); - return 0; } diff --git a/trunk/sound/spi/at73c213.c b/trunk/sound/spi/at73c213.c index 4dd051bdf4fd..337a00241a1f 100644 --- a/trunk/sound/spi/at73c213.c +++ b/trunk/sound/spi/at73c213.c @@ -1124,6 +1124,6 @@ static void __exit at73c213_exit(void) } module_exit(at73c213_exit); -MODULE_AUTHOR("Hans-Christian Egtvedt "); +MODULE_AUTHOR("Hans-Christian Egtvedt "); MODULE_DESCRIPTION("Sound driver for AT73C213 with Atmel SSC"); MODULE_LICENSE("GPL");