summaryrefslogtreecommitdiff
path: root/net/bluetooth/mgmt.c
AgeCommit message (Collapse)Author
2012-01-03Bluetooth: Fix mgmt_stop_discovery_failed()Andre Guedes
Stop Discovery Command Status Event should use mgmt status code. Signed-off-by: Andre Guedes <andre.guedes@openbossa.org> Acked-by: Johan Hedberg <johan.hedberg@intel.com> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
2012-01-02Bluetooth: Rename extfeaturesAndre Guedes
This patch renames hdev->extfeatures to hdev->host_features since it holds the extended features Page 1 (aka host features). Signed-off-by: Andre Guedes <aguedespe@gmail.com> Acked-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
2011-12-22Bluetooth: Add SMP to User Passkey and ConfirmBrian Gix
Low Energy pairing is performed through the SMP (Security Manager Protocol) mechanism rather than HCI. Signed-off-by: Brian Gix <bgix@codeaurora.org> Acked-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
2011-12-19Merge branch 'master' of ↵John W. Linville
git://git.kernel.org/pub/scm/linux/kernel/git/padovan/bluetooth-next
2011-12-18Bluetooth: Use correct struct for user_confirm_neg_replyJohan Hedberg
This patch fixes user_confirm_neg_reply to use the appropriate struct for accessing the call parameters. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Acked-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
2011-12-18Bluetooth: Add timer for automatically disabling the service cacheJohan Hedberg
We do not want the service cache to be enabled indefinitely after mgmt_read_info is called. To solve this a timer is added which will automatically disable the cache if mgmt_set_dev_class isn't called within 5 seconds of calling mgmt_read_info. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Acked-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
2011-12-18Bluetooth: Move EIR and CoD update functions to a better positionJohan Hedberg
Due to the upcoming addition of a service cache timer the functions to update the EIR and CoD need to be higher up in mgmt.c in order to avoid unnecessary forward-declarations. This patch simply moves code around without any other changes in order to make subsequent patches more readable. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Acked-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
2011-12-18Bluetooth: Remove mgmt_set_service_cacheJohan Hedberg
Instead of having an explicit service cache command we can make the mgmt API simpler by implicitly enabling the cache when mgmt_read_info is called for the first time and disabling it when mgmt_set_dev_class is called. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Acked-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
2011-12-18Bluetooth: Move mgmt_set_fast_connectable to the right locationJohan Hedberg
Fast connectable is logically after the connectable property so that's where it should show up in the code as well (it's also after connectable in the settings bitfield). Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Acked-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
2011-12-18Bluetooth: Update mgmt_read_info and related mgmt messagesJohan Hedberg
This patch updates the mgmt_read_info and related messages to the latest management API which uses a bitfield of settings instead of individual boolean values. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Acked-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
2011-12-18Bluetooth: Use system workqueue to schedule power_onGustavo F. Padovan
hdev->workqueue should be only for rx/tx, so move this one out. Acked-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
2011-12-18Bluetooth: move power_off to system workqueueGustavo F. Padovan
hdev->workqueue will be only for for rx/tx/cmd processing, all other small works should go to the system workqueue for now. Acked-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
2011-12-18Bluetooth: Replace spin_lock by mutex in hci_devGustavo F. Padovan
Now we run everything in HCI in process context, so it's a better idea use mutex instead spin_lock. The macro remains hci_dev_lock() (and I got rid of hci_dev_lock_bh()), of course. Acked-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
2011-12-06Merge branch 'master' of ↵John W. Linville
git://git.kernel.org/pub/scm/linux/kernel/git/padovan/bluetooth-next
2011-12-01Bluetooth: Add User Passkey Response handlingBrian Gix
For some MITM protection pairing scenarios, the user is required to enter or accept a 6 digit passkey. Signed-off-by: Brian Gix <bgix@codeaurora.org> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
2011-11-22Merge branch 'master' of ↵John W. Linville
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux Conflicts: drivers/net/wireless/iwlegacy/iwl-debugfs.c drivers/net/wireless/iwlegacy/iwl-rx.c drivers/net/wireless/iwlegacy/iwl-scan.c drivers/net/wireless/iwlegacy/iwl-tx.c include/net/bluetooth/bluetooth.h
2011-11-21Bluetooth: Differentiate LE User Pairing ResponsesBrian Gix
Low Energy (LE) pairing responses must be recognized and handled differently from BR/EDR pairing responses. BR/EDR responses are handled via HCI commands by the LMP layer, and LE responses are handled by the Host. Signed-off-by: Brian Gix <bgix@codeaurora.org> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
2011-11-21Bluetooth: User Pairing Response restructuringBrian Gix
There are 4 possible User Responses to pairing requests, and they all share the same checks and handling. This restructures the handling of the two Confirm responses in preperation for the second two. Signed-off-by: Brian Gix <bgix@codeaurora.org> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
2011-11-16Bluetooth: Pass all message parameters to mgmt_start_discoveryJohan Hedberg
The mgmt_start_discovery command contains the type of discovery that should be started so this should be passed to the start_discovery function. This patch doesn't yet add any action depending on the type of the requested discovery. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Acked-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
2011-11-16Bluetooth: Add missing cmd_complete for mgmt_load_link_keysJohan Hedberg
The command complete event was completely missing for this command. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
2011-11-16Bluetooth: Create a unique mgmt error code hierarchyJohan Hedberg
The management protocol uses a single byte for error codes (aka command status). In some places this value is directly copied from HCI and in other a POSIX error number is used. This makes it impossible for user-space to uniquily decipher the meaning of an error. To solve this issue a new mgmt-specific set of error codes is added along with a conversion table for HCI status values. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
2011-11-16Bluetooth: Return success instead of EALREADY for mgmt commandsJohan Hedberg
When the adapter state is already what is requested it's more friendly to user-space to simply report success than to send a EALREADY error message. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
2011-11-16Bluetooth: Fix mgmt_pair_device imediate error responsesJohan Hedberg
When possible cmd_complete should be returned instead of cmd_status since it contains the remote address (this helps user-space track what exactly failed). Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
2011-11-16Bluetooth: Add address type to mgmt_pair_deviceJohan Hedberg
The kernel needs to know whether it should connect to a device over BR/EDR or over LE. This is particularly important in the future when dual-mode device may be connectable also over LE. It is also important if/when we decide to move the LE advertisement cache from the kernel into user-space. Adding the type to the mgmt command also ensures conformance with the latest mgmt API spec. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
2011-11-16Bluetooth: mgmt_stop_discovery_failed()Andre Guedes
This patches creates mgmt_stop_discovery_failed() which removes pending MGMT_OP_STOP_DISCOVERY commands and sends proper command status events. This patch also fixes the MGMT_OP_STOP_DISCOVERY command leak in case cancel inquiry fails. Signed-off-by: Andre Guedes <andre.guedes@openbossa.org> Acked-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
2011-11-16Bluetooth: Rename mgmt_inquiry_failed()Andre Guedes
This patch renames the function mgmt_inquiry_failed() to mgmt_start_discovery_failed(). This function is more related to MGMT_OP_START_DISCOVERY command handling than to inquiry. Besides, this functions will be reused by LE based discovery procedures in case of failure. Signed-off-by: Andre Guedes <andre.guedes@openbossa.org> Acked-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
2011-11-10Bluetooth: Add status parameter to mgmt_disconnect responseJohan Hedberg
Since disconnecting may fail the status needs to be communicated to user space. This also updates the implementation to match the latest mgmt API specification. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
2011-11-10Bluetooth: Add proper response to mgmt_remove_keys commandJohan Hedberg
Since the command can fail we need to have a proper response with the remote address and a failure status for it. This also updates it to conform to the latest mgmt API spec. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
2011-11-10Bluetooth: Fix deadlock with mgmt_pair_deviceJohan Hedberg
The hci_conn callbacks are called with the hci_dev lock already held so no locking should be attempted in them. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
2011-11-10Bluetooth: Add public/random LE address information to mgmt messagesJohan Hedberg
It's necessary to know the distinction between public and random LE addresses so the mgmt interface also needs to distinguish between them. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
2011-11-09Bluetooth: Remove redundant hci_dev comparisons in mgmt lookupsJohan Hedberg
Now that pending commands are hci_dev specific there's no need to check whether a command matches hci_dev when iterating through them. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Acked-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
2011-11-09Bluetooth: Fix consistency with u16 integer type in mgmt pending_cmdJohan Hedberg
For consistency the integer type should be u16 and not __u16. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Acked-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
2011-11-09Bluetooth: Fix cancel_delayed_work_sync usage with locksJohan Hedberg
The cancel_delayed_work_sync function should not be used if we hold any locks. Luckily all places where this is the case it is also safe to use the non-sync version. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Acked-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
2011-11-09Bluetooth: Add missing hci_dev locking when calling mgmt functionsJohan Hedberg
Now that the pending commands are within struct hci_dev we can properly control access to them throught the hci_dev locking mechanism. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Acked-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
2011-11-09Bluetooth: Move pending management command list into struct hci_devJohan Hedberg
This patch moves the pending management command list (previously global to mgmt.c) into struct hci_dev. This makes it possible to do proper locking when accessing it (through the existing hci_dev locks) and thereby avoid race conditions. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Acked-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
2011-11-09Bluetooth: Pass full hci_dev struct to mgmt callbacksJohan Hedberg
The current global pending command list in mgmt.c is racy. Possibly the simplest way to fix it is to have per-hci dev lists instead of a global one (all commands that need a pending struct are hci_dev specific). This way the list can be protected using the already existing per-hci dev lock. To enable this refactoring the first thing that needs to be done is to ensure that the mgmt functions have access to the hci_dev struct (instead of just the dev id). Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Acked-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
2011-11-08Bluetooth: Add address type fields to mgmt messages that need themJohan Hedberg
This patch adds address type info (typically BR/EDR vs LE) to management messages that need this. This also ensures conformance to the latest management API specification. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
2011-11-08Bluetooth: Update link key mgmt APIs to match latest spec.Johan Hedberg
BR/EDR link keys have their own commands and events (separate from SMP) and the remove_keys command (previously remove_key) removes keys of any kind for the specified remote address. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
2011-11-08Bluetooth: Fix response for mgmt_start_discovery when powered offJohan Hedberg
We should return a ENETDOWN status response if the adapter is powered off (i.e. the HCI_UP flag isn't set). Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
2011-11-08Bluetooth: Remove redundant code from mgmt_block & mgmt_unblockJohan Hedberg
There's no need to deal with mgmt_pending_cmd when blocking and unblocking devices since these actions are synchronous. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
2011-11-08Bluetooth: Convert power off mechanism to use delayed_workJohan Hedberg
The power off code doesn't need to use its own custom timer since the delayed_work API provides the exact same functionality. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
2011-11-08Bluetooth: Fix mgmt response when HCI_Write_Scan_Enable failsJohan Hedberg
A proper mgmt_command_status should be returned to user-space if either discoverable or connectable enabling fails. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
2011-11-08Bluetooth: Add timeout field to mgmt_set_discoverableJohan Hedberg
Based on the revised mgmt API set_discoverable has a timeout parameter to specify how long the adapter will remain discoverable. A value of 0 means "indefinitively". Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
2011-11-08Bluetooth: Create hci_cancel_inquiry()Andre Guedes
This patch adds a function to hci_core to cancel an ongoing inquiry. According to the Bluetooth spec, the inquiry cancel command should only be issued after the inquiry command has been issued, a command status event has been received for the inquiry command, and before the inquiry complete event occurs. As HCI_INQUIRY flag is only set just after an inquiry command status event occurs and it is cleared just after an inquiry complete event occurs, the inquiry cancel command should be issued only if HCI_INQUIRY flag is set. Additionally, cancel inquiry related code from stop_discovery() were replaced by a hci_cancel_inquiry() call. Signed-off-by: Andre Guedes <andre.guedes@openbossa.org> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
2011-11-08Bluetooth: Create hci_do_inquiry()Andre Guedes
This patch adds a function to hci_core to carry out inquiry. All inquiry code from start_discovery() were replaced by a hci_do_inquiry() call. Signed-off-by: Andre Guedes <andre.guedes@openbossa.org> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
2011-11-07Bluetooth: Fix mgmt response when adapter goes down or is removedJohan Hedberg
When an adapter gets powered off or is removed any pending commands should receive a ENETDOWN or ENODEV status response. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
2011-11-07Bluetooth: Set HCI_MGMT flag only in read_controller_infoJohan Hedberg
The HCI_MGMT flag should only be set when user space requests the full controller information. This way we avoid potential issues with setting change events ariving before the actual read_controller_info command finishes. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
2011-11-07Bluetooth: Fix command complete/status for discovery commandsJohan Hedberg
This patch adds the necessary code to send proper command status or command complete events to the start/stop discovery management commands. Before this patch these events were completely missing. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
2011-11-07Bluetooth: replace list_for_each with list_for_each_entry whenever possibleLuiz Augusto von Dentz
When all items in the list have the same type there is no much of a point to use list_for_each except if you want to use the list pointer itself. Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
2011-11-07Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/netLinus Torvalds
* git://git.kernel.org/pub/scm/linux/kernel/git/davem/net: (47 commits) forcedeth: fix a few sparse warnings (variable shadowing) forcedeth: Improve stats counters forcedeth: remove unneeded stats updates forcedeth: Acknowledge only interrupts that are being processed forcedeth: fix race when unloading module MAINTAINERS/rds: update maintainer wanrouter: Remove kernel_lock annotations usbnet: fix oops in usbnet_start_xmit ixgbe: Fix compile for kernel without CONFIG_PCI_IOV defined etherh: Add MAINTAINERS entry for etherh bonding: comparing a u8 with -1 is always false sky2: fix regression on Yukon Optima netlink: clarify attribute length check documentation netlink: validate NLA_MSECS length i825xx:xscale:8390:freescale: Fix Kconfig dependancies macvlan: receive multicast with local address tg3: Update version to 3.121 tg3: Eliminate timer race with reset_task tg3: Schedule at most one tg3_reset_task run tg3: Obtain PCI function number from device ...