@@ -1601,7 +1601,7 @@ int __hci_req_setup_ext_adv_instance(struct hci_request *req, u8 instance)
1601
1601
cp .own_addr_type = own_addr_type ;
1602
1602
cp .channel_map = hdev -> le_adv_channel_map ;
1603
1603
cp .tx_power = 127 ;
1604
- cp .handle = 0 ;
1604
+ cp .handle = instance ;
1605
1605
1606
1606
if (flags & MGMT_ADV_FLAG_SEC_2M ) {
1607
1607
cp .primary_phy = HCI_ADV_PHY_1M ;
@@ -1643,11 +1643,21 @@ int __hci_req_setup_ext_adv_instance(struct hci_request *req, u8 instance)
1643
1643
return 0 ;
1644
1644
}
1645
1645
1646
- void __hci_req_enable_ext_advertising (struct hci_request * req )
1646
+ int __hci_req_enable_ext_advertising (struct hci_request * req , u8 instance )
1647
1647
{
1648
+ struct hci_dev * hdev = req -> hdev ;
1648
1649
struct hci_cp_le_set_ext_adv_enable * cp ;
1649
1650
struct hci_cp_ext_adv_set * adv_set ;
1650
1651
u8 data [sizeof (* cp ) + sizeof (* adv_set ) * 1 ];
1652
+ struct adv_info * adv_instance ;
1653
+
1654
+ if (instance > 0 ) {
1655
+ adv_instance = hci_find_adv_instance (hdev , instance );
1656
+ if (!adv_instance )
1657
+ return - EINVAL ;
1658
+ } else {
1659
+ adv_instance = NULL ;
1660
+ }
1651
1661
1652
1662
cp = (void * ) data ;
1653
1663
adv_set = (void * ) cp -> data ;
@@ -1659,11 +1669,23 @@ void __hci_req_enable_ext_advertising(struct hci_request *req)
1659
1669
1660
1670
memset (adv_set , 0 , sizeof (* adv_set ));
1661
1671
1662
- adv_set -> handle = 0 ;
1672
+ adv_set -> handle = instance ;
1673
+
1674
+ /* Set duration per instance since controller is responsible for
1675
+ * scheduling it.
1676
+ */
1677
+ if (adv_instance && adv_instance -> duration ) {
1678
+ u16 duration = adv_instance -> duration * MSEC_PER_SEC ;
1679
+
1680
+ /* Time = N * 10 ms */
1681
+ adv_set -> duration = cpu_to_le16 (duration / 10 );
1682
+ }
1663
1683
1664
1684
hci_req_add (req , HCI_OP_LE_SET_EXT_ADV_ENABLE ,
1665
1685
sizeof (* cp ) + sizeof (* adv_set ) * cp -> num_of_sets ,
1666
1686
data );
1687
+
1688
+ return 0 ;
1667
1689
}
1668
1690
1669
1691
int __hci_req_start_ext_adv (struct hci_request * req , u8 instance )
@@ -1679,7 +1701,7 @@ int __hci_req_start_ext_adv(struct hci_request *req, u8 instance)
1679
1701
return err ;
1680
1702
1681
1703
__hci_req_update_scan_rsp_data (req , instance );
1682
- __hci_req_enable_ext_advertising (req );
1704
+ __hci_req_enable_ext_advertising (req , instance );
1683
1705
1684
1706
return 0 ;
1685
1707
}
@@ -1723,10 +1745,13 @@ int __hci_req_schedule_adv_instance(struct hci_request *req, u8 instance,
1723
1745
adv_instance -> remaining_time =
1724
1746
adv_instance -> remaining_time - timeout ;
1725
1747
1726
- hdev -> adv_instance_timeout = timeout ;
1727
- queue_delayed_work (hdev -> req_workqueue ,
1748
+ /* Only use work for scheduling instances with legacy advertising */
1749
+ if (!ext_adv_capable (hdev )) {
1750
+ hdev -> adv_instance_timeout = timeout ;
1751
+ queue_delayed_work (hdev -> req_workqueue ,
1728
1752
& hdev -> adv_instance_expire ,
1729
1753
msecs_to_jiffies (timeout * 1000 ));
1754
+ }
1730
1755
1731
1756
/* If we're just re-scheduling the same instance again then do not
1732
1757
* execute any HCI commands. This happens when a single instance is
@@ -2744,7 +2769,8 @@ static int powered_update_hci(struct hci_request *req, unsigned long opt)
2744
2769
if (!ext_adv_capable (hdev ))
2745
2770
__hci_req_enable_advertising (req );
2746
2771
else if (!err )
2747
- __hci_req_enable_ext_advertising (req );
2772
+ __hci_req_enable_ext_advertising (req ,
2773
+ 0x00 );
2748
2774
}
2749
2775
} else if (!list_empty (& hdev -> adv_instances )) {
2750
2776
struct adv_info * adv_instance ;
0 commit comments