@@ -263,6 +263,14 @@ static void hci_init_req(struct hci_dev *hdev, unsigned long opt)
263263 hci_send_cmd (hdev , HCI_OP_DELETE_STORED_LINK_KEY , sizeof (cp ), & cp );
264264}
265265
266+ static void hci_le_init_req (struct hci_dev * hdev , unsigned long opt )
267+ {
268+ BT_DBG ("%s" , hdev -> name );
269+
270+ /* Read LE buffer size */
271+ hci_send_cmd (hdev , HCI_OP_LE_READ_BUFFER_SIZE , 0 , NULL );
272+ }
273+
266274static void hci_scan_req (struct hci_dev * hdev , unsigned long opt )
267275{
268276 __u8 scan = opt ;
@@ -529,6 +537,10 @@ int hci_dev_open(__u16 dev)
529537 ret = __hci_request (hdev , hci_init_req , 0 ,
530538 msecs_to_jiffies (HCI_INIT_TIMEOUT ));
531539
540+ if (lmp_le_capable (hdev ))
541+ ret = __hci_request (hdev , hci_le_init_req , 0 ,
542+ msecs_to_jiffies (HCI_INIT_TIMEOUT ));
543+
532544 clear_bit (HCI_INIT , & hdev -> flags );
533545 }
534546
@@ -671,7 +683,7 @@ int hci_dev_reset(__u16 dev)
671683 hdev -> flush (hdev );
672684
673685 atomic_set (& hdev -> cmd_cnt , 1 );
674- hdev -> acl_cnt = 0 ; hdev -> sco_cnt = 0 ;
686+ hdev -> acl_cnt = 0 ; hdev -> sco_cnt = 0 ; hdev -> le_cnt = 0 ;
675687
676688 if (!test_bit (HCI_RAW , & hdev -> flags ))
677689 ret = __hci_request (hdev , hci_reset_req , 0 ,
@@ -1672,8 +1684,25 @@ static inline struct hci_conn *hci_low_sent(struct hci_dev *hdev, __u8 type, int
16721684 }
16731685
16741686 if (conn ) {
1675- int cnt = (type == ACL_LINK ? hdev -> acl_cnt : hdev -> sco_cnt );
1676- int q = cnt / num ;
1687+ int cnt , q ;
1688+
1689+ switch (conn -> type ) {
1690+ case ACL_LINK :
1691+ cnt = hdev -> acl_cnt ;
1692+ break ;
1693+ case SCO_LINK :
1694+ case ESCO_LINK :
1695+ cnt = hdev -> sco_cnt ;
1696+ break ;
1697+ case LE_LINK :
1698+ cnt = hdev -> le_mtu ? hdev -> le_cnt : hdev -> acl_cnt ;
1699+ break ;
1700+ default :
1701+ cnt = 0 ;
1702+ BT_ERR ("Unknown link type" );
1703+ }
1704+
1705+ q = cnt / num ;
16771706 * quote = q ? q : 1 ;
16781707 } else
16791708 * quote = 0 ;
@@ -1772,14 +1801,49 @@ static inline void hci_sched_esco(struct hci_dev *hdev)
17721801 }
17731802}
17741803
1804+ static inline void hci_sched_le (struct hci_dev * hdev )
1805+ {
1806+ struct hci_conn * conn ;
1807+ struct sk_buff * skb ;
1808+ int quote , cnt ;
1809+
1810+ BT_DBG ("%s" , hdev -> name );
1811+
1812+ if (!test_bit (HCI_RAW , & hdev -> flags )) {
1813+ /* LE tx timeout must be longer than maximum
1814+ * link supervision timeout (40.9 seconds) */
1815+ if (!hdev -> le_cnt &&
1816+ time_after (jiffies , hdev -> le_last_tx + HZ * 45 ))
1817+ hci_acl_tx_to (hdev );
1818+ }
1819+
1820+ cnt = hdev -> le_pkts ? hdev -> le_cnt : hdev -> acl_cnt ;
1821+ while (cnt && (conn = hci_low_sent (hdev , LE_LINK , & quote ))) {
1822+ while (quote -- && (skb = skb_dequeue (& conn -> data_q ))) {
1823+ BT_DBG ("skb %p len %d" , skb , skb -> len );
1824+
1825+ hci_send_frame (skb );
1826+ hdev -> le_last_tx = jiffies ;
1827+
1828+ cnt -- ;
1829+ conn -> sent ++ ;
1830+ }
1831+ }
1832+ if (hdev -> le_pkts )
1833+ hdev -> le_cnt = cnt ;
1834+ else
1835+ hdev -> acl_cnt = cnt ;
1836+ }
1837+
17751838static void hci_tx_task (unsigned long arg )
17761839{
17771840 struct hci_dev * hdev = (struct hci_dev * ) arg ;
17781841 struct sk_buff * skb ;
17791842
17801843 read_lock (& hci_task_lock );
17811844
1782- BT_DBG ("%s acl %d sco %d" , hdev -> name , hdev -> acl_cnt , hdev -> sco_cnt );
1845+ BT_DBG ("%s acl %d sco %d le %d" , hdev -> name , hdev -> acl_cnt ,
1846+ hdev -> sco_cnt , hdev -> le_cnt );
17831847
17841848 /* Schedule queues and send stuff to HCI driver */
17851849
@@ -1789,6 +1853,8 @@ static void hci_tx_task(unsigned long arg)
17891853
17901854 hci_sched_esco (hdev );
17911855
1856+ hci_sched_le (hdev );
1857+
17921858 /* Send next queued raw (unknown type) packet */
17931859 while ((skb = skb_dequeue (& hdev -> raw_q )))
17941860 hci_send_frame (skb );
0 commit comments