netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/1] Bluetooth: Add actions to set wakeable in add device
@ 2020-03-26  5:45 Abhishek Pandit-Subedi
  2020-03-26  5:45 ` [PATCH v2 1/1] Bluetooth: Update add_device with wakeable actions Abhishek Pandit-Subedi
  2020-03-27  2:59 ` [PATCH v2 0/1] Bluetooth: Add actions to set wakeable in add device Abhishek Pandit-Subedi
  0 siblings, 2 replies; 4+ messages in thread
From: Abhishek Pandit-Subedi @ 2020-03-26  5:45 UTC (permalink / raw)
  To: marcel
  Cc: linux-bluetooth, chromeos-bluetooth-upstreaming,
	Abhishek Pandit-Subedi, David S. Miller, Johan Hedberg, netdev,
	linux-kernel, Jakub Kicinski


Hi Marcel,

As suggested, I've updated add device to accept action 0x3 and 0x4 to
set and remove the wakeable property.

Thanks
Abhishek


Changes in v2:
* Added missing goto unlock

Abhishek Pandit-Subedi (1):
  Bluetooth: Update add_device with wakeable actions

 net/bluetooth/mgmt.c | 57 ++++++++++++++++++++++++++++++++++++--------
 1 file changed, 47 insertions(+), 10 deletions(-)

-- 
2.25.1.696.g5e7596f4ac-goog


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2 1/1] Bluetooth: Update add_device with wakeable actions
  2020-03-26  5:45 [PATCH v2 0/1] Bluetooth: Add actions to set wakeable in add device Abhishek Pandit-Subedi
@ 2020-03-26  5:45 ` Abhishek Pandit-Subedi
  2020-04-06 18:04   ` Marcel Holtmann
  2020-03-27  2:59 ` [PATCH v2 0/1] Bluetooth: Add actions to set wakeable in add device Abhishek Pandit-Subedi
  1 sibling, 1 reply; 4+ messages in thread
From: Abhishek Pandit-Subedi @ 2020-03-26  5:45 UTC (permalink / raw)
  To: marcel
  Cc: linux-bluetooth, chromeos-bluetooth-upstreaming,
	Abhishek Pandit-Subedi, David S. Miller, Johan Hedberg, netdev,
	linux-kernel, Jakub Kicinski

Add new actions to add_device to allow it to set or unset a device as
wakeable. When the set wakeable and unset wakeable actions are used, the
autoconnect property is not updated and the device is not added to the
whitelist (if BR/EDR).

Signed-off-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org>
---

Changes in v2:
* Added missing goto unlock

 net/bluetooth/mgmt.c | 57 ++++++++++++++++++++++++++++++++++++--------
 1 file changed, 47 insertions(+), 10 deletions(-)

diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 6552003a170e..8643089e758f 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -5775,6 +5775,7 @@ static int add_device(struct sock *sk, struct hci_dev *hdev,
 		      void *data, u16 len)
 {
 	struct mgmt_cp_add_device *cp = data;
+	struct hci_conn_params *params;
 	u8 auto_conn, addr_type;
 	int err;
 
@@ -5786,7 +5787,7 @@ static int add_device(struct sock *sk, struct hci_dev *hdev,
 					 MGMT_STATUS_INVALID_PARAMS,
 					 &cp->addr, sizeof(cp->addr));
 
-	if (cp->action != 0x00 && cp->action != 0x01 && cp->action != 0x02)
+	if (cp->action > 0x04)
 		return mgmt_cmd_complete(sk, hdev->id, MGMT_OP_ADD_DEVICE,
 					 MGMT_STATUS_INVALID_PARAMS,
 					 &cp->addr, sizeof(cp->addr));
@@ -5794,8 +5795,35 @@ static int add_device(struct sock *sk, struct hci_dev *hdev,
 	hci_dev_lock(hdev);
 
 	if (cp->addr.type == BDADDR_BREDR) {
-		/* Only incoming connections action is supported for now */
-		if (cp->action != 0x01) {
+		switch (cp->action) {
+		case 0x3:
+			/* Set wakeable */
+			err = hci_bdaddr_list_add(&hdev->wakeable,
+						  &cp->addr.bdaddr,
+						  cp->addr.type);
+			if (err && err != -EEXIST)
+				goto unlock;
+			break;
+		case 0x4:
+			/* Remove wakeable */
+			err = hci_bdaddr_list_del(&hdev->wakeable,
+						  &cp->addr.bdaddr,
+						  cp->addr.type);
+			if (err)
+				goto unlock;
+
+			break;
+		case 0x1:
+			/* Allow incoming connection */
+			err = hci_bdaddr_list_add(&hdev->whitelist,
+						  &cp->addr.bdaddr,
+						  cp->addr.type);
+			if (err && err != -EEXIST)
+				goto unlock;
+
+			hci_req_update_scan(hdev);
+			break;
+		default:
 			err = mgmt_cmd_complete(sk, hdev->id,
 						MGMT_OP_ADD_DEVICE,
 						MGMT_STATUS_INVALID_PARAMS,
@@ -5803,13 +5831,6 @@ static int add_device(struct sock *sk, struct hci_dev *hdev,
 			goto unlock;
 		}
 
-		err = hci_bdaddr_list_add(&hdev->whitelist, &cp->addr.bdaddr,
-					  cp->addr.type);
-		if (err)
-			goto unlock;
-
-		hci_req_update_scan(hdev);
-
 		goto added;
 	}
 
@@ -5834,6 +5855,22 @@ static int add_device(struct sock *sk, struct hci_dev *hdev,
 		goto unlock;
 	}
 
+	/* Only allow wakeable property to be set/unset on existing device */
+	if (cp->action == 0x03 || cp->action == 0x04) {
+		params = hci_conn_params_lookup(hdev, &cp->addr.bdaddr,
+						addr_type);
+		if (!params) {
+			err = mgmt_cmd_complete(sk, hdev->id,
+						MGMT_OP_ADD_DEVICE,
+						MGMT_STATUS_FAILED, &cp->addr,
+						sizeof(cp->addr));
+			goto unlock;
+		}
+
+		params->wakeable = cp->action == 0x03;
+		goto added;
+	}
+
 	/* If the connection parameters don't exist for this device,
 	 * they will be created and configured with defaults.
 	 */
-- 
2.25.1.696.g5e7596f4ac-goog


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 0/1] Bluetooth: Add actions to set wakeable in add device
  2020-03-26  5:45 [PATCH v2 0/1] Bluetooth: Add actions to set wakeable in add device Abhishek Pandit-Subedi
  2020-03-26  5:45 ` [PATCH v2 1/1] Bluetooth: Update add_device with wakeable actions Abhishek Pandit-Subedi
@ 2020-03-27  2:59 ` Abhishek Pandit-Subedi
  1 sibling, 0 replies; 4+ messages in thread
From: Abhishek Pandit-Subedi @ 2020-03-27  2:59 UTC (permalink / raw)
  To: Marcel Holtmann
  Cc: Bluez mailing list, ChromeOS Bluetooth Upstreaming,
	David S. Miller, Johan Hedberg, netdev, LKML, Jakub Kicinski

Hi Marcel,

Does this look ok? I'm working on the accompanying Bluez changes as
well and will send a new patch if the mgmt changes look ok.

Thanks
Abhishek

On Wed, Mar 25, 2020 at 10:45 PM Abhishek Pandit-Subedi
<abhishekpandit@chromium.org> wrote:
>
>
> Hi Marcel,
>
> As suggested, I've updated add device to accept action 0x3 and 0x4 to
> set and remove the wakeable property.
>
> Thanks
> Abhishek
>
>
> Changes in v2:
> * Added missing goto unlock
>
> Abhishek Pandit-Subedi (1):
>   Bluetooth: Update add_device with wakeable actions
>
>  net/bluetooth/mgmt.c | 57 ++++++++++++++++++++++++++++++++++++--------
>  1 file changed, 47 insertions(+), 10 deletions(-)
>
> --
> 2.25.1.696.g5e7596f4ac-goog
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 1/1] Bluetooth: Update add_device with wakeable actions
  2020-03-26  5:45 ` [PATCH v2 1/1] Bluetooth: Update add_device with wakeable actions Abhishek Pandit-Subedi
@ 2020-04-06 18:04   ` Marcel Holtmann
  0 siblings, 0 replies; 4+ messages in thread
From: Marcel Holtmann @ 2020-04-06 18:04 UTC (permalink / raw)
  To: Abhishek Pandit-Subedi
  Cc: Bluez mailing list, ChromeOS Bluetooth Upstreaming,
	David S. Miller, Johan Hedberg, netdev, LKML, Jakub Kicinski

Hi Abhishek,

> Add new actions to add_device to allow it to set or unset a device as
> wakeable. When the set wakeable and unset wakeable actions are used, the
> autoconnect property is not updated and the device is not added to the
> whitelist (if BR/EDR).

I am currently preferring to go with Device Flags for this. See my mgmt-api.txt proposal that I just send a few minutes ago.

Regards

Marcel


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-04-06 18:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-26  5:45 [PATCH v2 0/1] Bluetooth: Add actions to set wakeable in add device Abhishek Pandit-Subedi
2020-03-26  5:45 ` [PATCH v2 1/1] Bluetooth: Update add_device with wakeable actions Abhishek Pandit-Subedi
2020-04-06 18:04   ` Marcel Holtmann
2020-03-27  2:59 ` [PATCH v2 0/1] Bluetooth: Add actions to set wakeable in add device Abhishek Pandit-Subedi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).