linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] Bluetooth: Report extended adv capabilities to userspace
@ 2020-08-25 23:31 Daniel Winkler
  2020-08-25 23:31 ` [PATCH 1/2] bluetooth: Report num supported adv instances for hw offloading Daniel Winkler
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Daniel Winkler @ 2020-08-25 23:31 UTC (permalink / raw)
  To: linux-bluetooth
  Cc: chromeos-bluetooth-upstreaming, Daniel Winkler, David S. Miller,
	Jakub Kicinski, Johan Hedberg, Marcel Holtmann, linux-kernel,
	netdev


Hi Maintainers,

This series improves the kernel/controller support that is reported
to userspace for the following extended advertising features:

1. If extended advertising is available, the number of hardware slots
is used and reported, rather than the fixed default of 5. If no hardware
support is available, default is used as before for software rotation.

2. New flags indicating general hardware offloading and ability to
set tx power level. These are kept as two separate flags because in
the future vendor commands may allow tx power to be set without
hardware offloading support.


Daniel Winkler (2):
  bluetooth: Report num supported adv instances for hw offloading
  bluetooth: Add MGMT capability flags for tx power and ext advertising

 include/net/bluetooth/mgmt.h | 2 ++
 net/bluetooth/hci_core.c     | 2 +-
 net/bluetooth/mgmt.c         | 8 +++++---
 3 files changed, 8 insertions(+), 4 deletions(-)

-- 
2.28.0.297.g1956fa8f8d-goog


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

* [PATCH 1/2] bluetooth: Report num supported adv instances for hw offloading
  2020-08-25 23:31 [PATCH 0/2] Bluetooth: Report extended adv capabilities to userspace Daniel Winkler
@ 2020-08-25 23:31 ` Daniel Winkler
  2020-08-25 23:31 ` [PATCH 2/2] bluetooth: Add MGMT capability flags for tx power and ext advertising Daniel Winkler
  2020-09-11  7:18 ` [PATCH 0/2] Bluetooth: Report extended adv capabilities to userspace Marcel Holtmann
  2 siblings, 0 replies; 4+ messages in thread
From: Daniel Winkler @ 2020-08-25 23:31 UTC (permalink / raw)
  To: linux-bluetooth
  Cc: chromeos-bluetooth-upstreaming, Daniel Winkler, David S. Miller,
	Jakub Kicinski, Johan Hedberg, Marcel Holtmann, linux-kernel,
	netdev

Here we make sure we properly report the number of supported
advertising slots when we are using hardware offloading. If no
hardware offloading is available, we default this value to
HCI_MAX_ADV_INSTANCES for use in software rotation as before.

This change has been tested on kukui (no ext adv) and hatch (ext adv)
chromebooks by verifying "SupportedInstances" shows 5 (the default) and
6 (slots supported by controller), respectively.

Signed-off-by: Daniel Winkler <danielwinkler@google.com>
---

 net/bluetooth/hci_core.c | 2 +-
 net/bluetooth/mgmt.c     | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 68bfe57b66250f..500ab478769508 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -2963,7 +2963,7 @@ int hci_add_adv_instance(struct hci_dev *hdev, u8 instance, u32 flags,
 		       sizeof(adv_instance->scan_rsp_data));
 	} else {
 		if (hdev->adv_instance_cnt >= hdev->le_num_of_adv_sets ||
-		    instance < 1 || instance > HCI_MAX_ADV_INSTANCES)
+		    instance < 1 || instance > hdev->le_num_of_adv_sets)
 			return -EOVERFLOW;
 
 		adv_instance = kzalloc(sizeof(*adv_instance), GFP_KERNEL);
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 5bbe71002fb950..8041c9cebd5cf6 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -7250,7 +7250,7 @@ static int read_adv_features(struct sock *sk, struct hci_dev *hdev,
 	rp->supported_flags = cpu_to_le32(supported_flags);
 	rp->max_adv_data_len = HCI_MAX_AD_LENGTH;
 	rp->max_scan_rsp_len = HCI_MAX_AD_LENGTH;
-	rp->max_instances = HCI_MAX_ADV_INSTANCES;
+	rp->max_instances = hdev->le_num_of_adv_sets;
 	rp->num_instances = hdev->adv_instance_cnt;
 
 	instance = rp->instance;
@@ -7446,7 +7446,7 @@ static int add_advertising(struct sock *sk, struct hci_dev *hdev,
 		return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_ADVERTISING,
 				       MGMT_STATUS_NOT_SUPPORTED);
 
-	if (cp->instance < 1 || cp->instance > HCI_MAX_ADV_INSTANCES)
+	if (cp->instance < 1 || cp->instance > hdev->le_num_of_adv_sets)
 		return mgmt_cmd_status(sk, hdev->id, MGMT_OP_ADD_ADVERTISING,
 				       MGMT_STATUS_INVALID_PARAMS);
 
@@ -7699,7 +7699,7 @@ static int get_adv_size_info(struct sock *sk, struct hci_dev *hdev,
 		return mgmt_cmd_status(sk, hdev->id, MGMT_OP_GET_ADV_SIZE_INFO,
 				       MGMT_STATUS_REJECTED);
 
-	if (cp->instance < 1 || cp->instance > HCI_MAX_ADV_INSTANCES)
+	if (cp->instance < 1 || cp->instance > hdev->le_num_of_adv_sets)
 		return mgmt_cmd_status(sk, hdev->id, MGMT_OP_GET_ADV_SIZE_INFO,
 				       MGMT_STATUS_INVALID_PARAMS);
 
-- 
2.28.0.297.g1956fa8f8d-goog


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

* [PATCH 2/2] bluetooth: Add MGMT capability flags for tx power and ext advertising
  2020-08-25 23:31 [PATCH 0/2] Bluetooth: Report extended adv capabilities to userspace Daniel Winkler
  2020-08-25 23:31 ` [PATCH 1/2] bluetooth: Report num supported adv instances for hw offloading Daniel Winkler
@ 2020-08-25 23:31 ` Daniel Winkler
  2020-09-11  7:18 ` [PATCH 0/2] Bluetooth: Report extended adv capabilities to userspace Marcel Holtmann
  2 siblings, 0 replies; 4+ messages in thread
From: Daniel Winkler @ 2020-08-25 23:31 UTC (permalink / raw)
  To: linux-bluetooth
  Cc: chromeos-bluetooth-upstreaming, Daniel Winkler, David S. Miller,
	Jakub Kicinski, Johan Hedberg, Marcel Holtmann, linux-kernel,
	netdev

For new advertising features, it will be important for userspace to
know the capabilities of the controller and kernel. If the controller
and kernel support extended advertising, we include flags indicating
hardware offloading support and support for setting tx power of adv
instances.

In the future, vendor-specific commands may allow the setting of tx
power in advertising instances, but for now this feature is only
marked available if extended advertising is supported.

This change is manually verified in userspace by ensuring the
advertising manager's supported_flags field is updated with new flags on
hatch chromebook (ext advertising supported).

Signed-off-by: Daniel Winkler <danielwinkler@google.com>
---

 include/net/bluetooth/mgmt.h | 2 ++
 net/bluetooth/mgmt.c         | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h
index beae5c3980f03b..9ad505b9e694e4 100644
--- a/include/net/bluetooth/mgmt.h
+++ b/include/net/bluetooth/mgmt.h
@@ -572,6 +572,8 @@ struct mgmt_rp_add_advertising {
 #define MGMT_ADV_FLAG_SEC_1M 		BIT(7)
 #define MGMT_ADV_FLAG_SEC_2M 		BIT(8)
 #define MGMT_ADV_FLAG_SEC_CODED 	BIT(9)
+#define MGMT_ADV_FLAG_CAN_SET_TX_POWER	BIT(10)
+#define MGMT_ADV_FLAG_HW_OFFLOAD	BIT(11)
 
 #define MGMT_ADV_FLAG_SEC_MASK	(MGMT_ADV_FLAG_SEC_1M | MGMT_ADV_FLAG_SEC_2M | \
 				 MGMT_ADV_FLAG_SEC_CODED)
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 8041c9cebd5cf6..c5d128f331c6dc 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -7202,6 +7202,8 @@ static u32 get_supported_adv_flags(struct hci_dev *hdev)
 
 	if (ext_adv_capable(hdev)) {
 		flags |= MGMT_ADV_FLAG_SEC_1M;
+		flags |= MGMT_ADV_FLAG_HW_OFFLOAD;
+		flags |= MGMT_ADV_FLAG_CAN_SET_TX_POWER;
 
 		if (hdev->le_features[1] & HCI_LE_PHY_2M)
 			flags |= MGMT_ADV_FLAG_SEC_2M;
-- 
2.28.0.297.g1956fa8f8d-goog


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

* Re: [PATCH 0/2] Bluetooth: Report extended adv capabilities to userspace
  2020-08-25 23:31 [PATCH 0/2] Bluetooth: Report extended adv capabilities to userspace Daniel Winkler
  2020-08-25 23:31 ` [PATCH 1/2] bluetooth: Report num supported adv instances for hw offloading Daniel Winkler
  2020-08-25 23:31 ` [PATCH 2/2] bluetooth: Add MGMT capability flags for tx power and ext advertising Daniel Winkler
@ 2020-09-11  7:18 ` Marcel Holtmann
  2 siblings, 0 replies; 4+ messages in thread
From: Marcel Holtmann @ 2020-09-11  7:18 UTC (permalink / raw)
  To: Daniel Winkler
  Cc: linux-bluetooth, CrosBT Upstreaming, David S. Miller,
	Jakub Kicinski, Johan Hedberg, open list, netdev

Hi Daniel,

> This series improves the kernel/controller support that is reported
> to userspace for the following extended advertising features:
> 
> 1. If extended advertising is available, the number of hardware slots
> is used and reported, rather than the fixed default of 5. If no hardware
> support is available, default is used as before for software rotation.
> 
> 2. New flags indicating general hardware offloading and ability to
> set tx power level. These are kept as two separate flags because in
> the future vendor commands may allow tx power to be set without
> hardware offloading support.
> 
> 
> Daniel Winkler (2):
>  bluetooth: Report num supported adv instances for hw offloading
>  bluetooth: Add MGMT capability flags for tx power and ext advertising
> 
> include/net/bluetooth/mgmt.h | 2 ++
> net/bluetooth/hci_core.c     | 2 +-
> net/bluetooth/mgmt.c         | 8 +++++---
> 3 files changed, 8 insertions(+), 4 deletions(-)

both patches have been applied to bluetooth-next tree.

Regards

Marcel


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

end of thread, other threads:[~2020-09-11  7:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-25 23:31 [PATCH 0/2] Bluetooth: Report extended adv capabilities to userspace Daniel Winkler
2020-08-25 23:31 ` [PATCH 1/2] bluetooth: Report num supported adv instances for hw offloading Daniel Winkler
2020-08-25 23:31 ` [PATCH 2/2] bluetooth: Add MGMT capability flags for tx power and ext advertising Daniel Winkler
2020-09-11  7:18 ` [PATCH 0/2] Bluetooth: Report extended adv capabilities to userspace Marcel Holtmann

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).