Skip to content

Commit cba6b75

Browse files
Vudentzholtmann
authored andcommitted
Bluetooth: hci_sync: Make use of hci_cmd_sync_queue set 2
This make use of hci_cmd_sync_queue for the following MGMT commands: Add Advertising Remove Advertising Add Extended Advertising Parameters Add Extended Advertising Data mgmt-tester -s "Add Advertising" Test Summary ------------ Add Advertising - Failure: LE off Passed Add Advertising - Invalid Params 1 (AD too long) Passed Add Advertising - Invalid Params 2 (Malformed len) Passed Add Advertising - Invalid Params 3 (Malformed len) Passed Add Advertising - Invalid Params 4 (Malformed len) Passed Add Advertising - Invalid Params 5 (AD too long) Passed Add Advertising - Invalid Params 6 (ScRsp too long) Passed Add Advertising - Invalid Params 7 (Malformed len) Passed Add Advertising - Invalid Params 8 (Malformed len) Passed Add Advertising - Invalid Params 9 (Malformed len) Passed Add Advertising - Invalid Params 10 (ScRsp too long) Passed Add Advertising - Rejected (Timeout, !Powered) Passed Add Advertising - Success 1 (Powered, Add Adv Inst) Passed Add Advertising - Success 2 (!Powered, Add Adv Inst) Passed Add Advertising - Success 3 (!Powered, Adv Enable) Passed Add Advertising - Success 4 (Set Adv on override) Passed Add Advertising - Success 5 (Set Adv off override) Passed Add Advertising - Success 6 (Scan Rsp Dta, Adv ok) Passed Add Advertising - Success 7 (Scan Rsp Dta, Scan ok) Passed Add Advertising - Success 8 (Connectable Flag) Passed Add Advertising - Success 9 (General Discov Flag) Passed Add Advertising - Success 10 (Limited Discov Flag) Passed Add Advertising - Success 11 (Managed Flags) Passed Add Advertising - Success 12 (TX Power Flag) Passed Add Advertising - Success 13 (ADV_SCAN_IND) Passed Add Advertising - Success 14 (ADV_NONCONN_IND) Passed Add Advertising - Success 15 (ADV_IND) Passed Add Advertising - Success 16 (Connectable -> on) Passed Add Advertising - Success 17 (Connectable -> off) Passed Add Advertising - Success 18 (Power -> off, Remove) Passed Add Advertising - Success 19 (Power -> off, Keep) Passed Add Advertising - Success 20 (Add Adv override) Passed Add Advertising - Success 21 (Timeout expires) Passed Add Advertising - Success 22 (LE -> off, Remove) Passed Add Advertising - Success (Empty ScRsp) Passed Add Advertising - Success (ScRsp only) Passed Add Advertising - Invalid Params (ScRsp too long) Passed Add Advertising - Success (ScRsp appear) Passed Add Advertising - Invalid Params (ScRsp appear long) Passed Add Advertising - Success (Appear is null) Passed Add Advertising - Success (Name is null) Passed Add Advertising - Success (Complete name) Passed Add Advertising - Success (Shortened name) Passed Add Advertising - Success (Short name) Passed Add Advertising - Success (Name + data) Passed Add Advertising - Invalid Params (Name + data) Passed Add Advertising - Success (Name+data+appear) Passed Total: 47, Passed: 47 (100.0%), Failed: 0, Not Run: 0 Overall execution time: 2.17 seconds mgmt-tester -s "Remove Advertising" Test Summary ------------ Remove Advertising - Invalid Params 1 Passed Remove Advertising - Success 1 Passed Remove Advertising - Success 2 Passed Total: 3, Passed: 3 (100.0%), Failed: 0, Not Run: 0 Overall execution time: 0.0585 seconds mgmt-tester -s "Ext Adv MGMT Params" Test Summary: ------------ Ext Adv MGMT Params - Unpowered Passed Ext Adv MGMT Params - Invalid parameters Passed Ext Adv MGMT Params - Success Passed Ext Adv MGMT Params - (5.0) Success Passed Total: 4, Passed: 4 (100.0%), Failed: 0, Not Run: 0 Overall execution time: 0.0746 seconds mgmt-tester -s "Ext Adv MGMT -" Test Summary ------------ Ext Adv MGMT - Data set without Params Passed Ext Adv MGMT - AD Data (5.0) Invalid parameters Passed Ext Adv MGMT - AD Data (5.0) Success Passed Ext Adv MGMT - AD Scan Response (5.0) Success Passed Total: 4, Passed: 4 (100.0%), Failed: 0, Not Run: 0 Overall execution time: 0.0805 seconds Signed-off-by: Luiz Augusto von Dentz <[email protected]> Signed-off-by: Marcel Holtmann <[email protected]>
1 parent 161510c commit cba6b75

File tree

5 files changed

+1158
-202
lines changed

5 files changed

+1158
-202
lines changed

include/net/bluetooth/bluetooth.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,7 @@ typedef void (*hci_req_complete_skb_t)(struct hci_dev *hdev, u8 status,
380380
#define HCI_REQ_SKB BIT(1)
381381

382382
struct hci_ctrl {
383+
struct sock *sk;
383384
u16 opcode;
384385
u8 req_flags;
385386
u8 req_event;
@@ -405,6 +406,7 @@ struct bt_skb_cb {
405406
#define hci_skb_pkt_type(skb) bt_cb((skb))->pkt_type
406407
#define hci_skb_expect(skb) bt_cb((skb))->expect
407408
#define hci_skb_opcode(skb) bt_cb((skb))->hci.opcode
409+
#define hci_skb_sk(skb) bt_cb((skb))->hci.sk
408410

409411
static inline struct sk_buff *bt_skb_alloc(unsigned int len, gfp_t how)
410412
{

include/net/bluetooth/hci_sync.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,23 @@ int hci_cmd_sync_queue(struct hci_dev *hdev, hci_cmd_sync_work_func_t func,
4343

4444
int hci_update_eir_sync(struct hci_dev *hdev);
4545
int hci_update_class_sync(struct hci_dev *hdev);
46+
47+
int hci_update_eir_sync(struct hci_dev *hdev);
48+
int hci_update_class_sync(struct hci_dev *hdev);
49+
50+
int hci_update_random_address_sync(struct hci_dev *hdev, bool require_privacy,
51+
bool rpa, u8 *own_addr_type);
52+
53+
int hci_update_scan_rsp_data_sync(struct hci_dev *hdev, u8 instance);
54+
int hci_update_adv_data_sync(struct hci_dev *hdev, u8 instance);
55+
int hci_schedule_adv_instance_sync(struct hci_dev *hdev, u8 instance,
56+
bool force);
57+
58+
int hci_setup_ext_adv_instance_sync(struct hci_dev *hdev, u8 instance);
59+
int hci_start_ext_adv_sync(struct hci_dev *hdev, u8 instance);
60+
int hci_enable_ext_advertising_sync(struct hci_dev *hdev, u8 instance);
61+
int hci_enable_advertising_sync(struct hci_dev *hdev);
62+
63+
int hci_remove_advertising_sync(struct hci_dev *hdev, struct sock *sk,
64+
u8 instance, bool force);
65+
int hci_disable_advertising_sync(struct hci_dev *hdev);

net/bluetooth/hci_event.c

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1239,6 +1239,55 @@ static void hci_cc_le_set_adv_set_random_addr(struct hci_dev *hdev,
12391239
hci_dev_unlock(hdev);
12401240
}
12411241

1242+
static void hci_cc_le_remove_adv_set(struct hci_dev *hdev, struct sk_buff *skb)
1243+
{
1244+
__u8 status = *((__u8 *)skb->data);
1245+
u8 *instance;
1246+
int err;
1247+
1248+
if (status)
1249+
return;
1250+
1251+
instance = hci_sent_cmd_data(hdev, HCI_OP_LE_REMOVE_ADV_SET);
1252+
if (!instance)
1253+
return;
1254+
1255+
hci_dev_lock(hdev);
1256+
1257+
err = hci_remove_adv_instance(hdev, *instance);
1258+
if (!err)
1259+
mgmt_advertising_removed(hci_skb_sk(hdev->sent_cmd), hdev,
1260+
*instance);
1261+
1262+
hci_dev_unlock(hdev);
1263+
}
1264+
1265+
static void hci_cc_le_clear_adv_sets(struct hci_dev *hdev, struct sk_buff *skb)
1266+
{
1267+
__u8 status = *((__u8 *)skb->data);
1268+
struct adv_info *adv, *n;
1269+
int err;
1270+
1271+
if (status)
1272+
return;
1273+
1274+
if (!hci_sent_cmd_data(hdev, HCI_OP_LE_CLEAR_ADV_SETS))
1275+
return;
1276+
1277+
hci_dev_lock(hdev);
1278+
1279+
list_for_each_entry_safe(adv, n, &hdev->adv_instances, list) {
1280+
u8 instance = adv->instance;
1281+
1282+
err = hci_remove_adv_instance(hdev, instance);
1283+
if (!err)
1284+
mgmt_advertising_removed(hci_skb_sk(hdev->sent_cmd),
1285+
hdev, instance);
1286+
}
1287+
1288+
hci_dev_unlock(hdev);
1289+
}
1290+
12421291
static void hci_cc_le_read_transmit_power(struct hci_dev *hdev,
12431292
struct sk_buff *skb)
12441293
{
@@ -3725,6 +3774,14 @@ static void hci_cmd_complete_evt(struct hci_dev *hdev, struct sk_buff *skb,
37253774
hci_cc_le_set_adv_set_random_addr(hdev, skb);
37263775
break;
37273776

3777+
case HCI_OP_LE_REMOVE_ADV_SET:
3778+
hci_cc_le_remove_adv_set(hdev, skb);
3779+
break;
3780+
3781+
case HCI_OP_LE_CLEAR_ADV_SETS:
3782+
hci_cc_le_clear_adv_sets(hdev, skb);
3783+
break;
3784+
37283785
case HCI_OP_LE_READ_TRANSMIT_POWER:
37293786
hci_cc_le_read_transmit_power(hdev, skb);
37303787
break;

0 commit comments

Comments
 (0)