@@ -5657,8 +5657,6 @@ int hci_iso_handle(struct net_buf *buf, struct net_buf **evt)
5657
5657
struct bt_hci_iso_data_hdr * iso_data_hdr ;
5658
5658
struct isoal_sdu_tx sdu_frag_tx ;
5659
5659
struct bt_hci_iso_hdr * iso_hdr ;
5660
- struct ll_iso_datapath * dp_in ;
5661
- struct ll_iso_stream_hdr * hdr ;
5662
5660
uint32_t * time_stamp ;
5663
5661
uint16_t handle ;
5664
5662
uint8_t pb_flag ;
@@ -5668,8 +5666,6 @@ int hci_iso_handle(struct net_buf *buf, struct net_buf **evt)
5668
5666
5669
5667
iso_data_hdr = NULL ;
5670
5668
* evt = NULL ;
5671
- hdr = NULL ;
5672
- dp_in = NULL ;
5673
5669
5674
5670
if (buf -> len < sizeof (* iso_hdr )) {
5675
5671
LOG_ERR ("No HCI ISO header" );
@@ -5747,16 +5743,49 @@ int hci_iso_handle(struct net_buf *buf, struct net_buf **evt)
5747
5743
* data path
5748
5744
*/
5749
5745
} else if (IS_CIS_HANDLE (handle )) {
5750
- struct ll_conn_iso_stream * cis =
5751
- ll_iso_stream_connected_get (handle );
5746
+ struct ll_conn_iso_stream * cis ;
5747
+ struct ll_conn_iso_group * cig ;
5748
+ struct ll_iso_stream_hdr * hdr ;
5749
+ struct ll_iso_datapath * dp_in ;
5750
+
5751
+ cis = ll_iso_stream_connected_get (handle );
5752
5752
if (!cis ) {
5753
5753
return - EINVAL ;
5754
5754
}
5755
5755
5756
- struct ll_conn_iso_group * cig = cis -> group ;
5757
- uint8_t event_offset ;
5756
+ cig = cis -> group ;
5758
5757
5759
- hdr = & (cis -> hdr );
5758
+ #if defined(CONFIG_BT_CTLR_ISOAL_PSN_IGNORE )
5759
+ uint64_t event_count ;
5760
+ uint64_t pkt_seq_num ;
5761
+
5762
+ /* Catch up local pkt_seq_num with internal pkt_seq_num */
5763
+ event_count = cis -> lll .event_count ;
5764
+ pkt_seq_num = event_count + 1U ;
5765
+ if (!(pb_flag & 0x01 ) &&
5766
+ (((pkt_seq_num - cis -> pkt_seq_num ) &
5767
+ BIT64_MASK (39 )) <= BIT64_MASK (38 ))) {
5768
+ cis -> pkt_seq_num = pkt_seq_num ;
5769
+ } else {
5770
+ pkt_seq_num = cis -> pkt_seq_num ;
5771
+ }
5772
+
5773
+ /* Pre-increment, for next ISO data packet seq num comparison */
5774
+ if (pb_flag & 0x10 ) {
5775
+ cis -> pkt_seq_num ++ ;
5776
+ }
5777
+
5778
+ /* Target next event to avoid overlapping with current event */
5779
+ pkt_seq_num ++ ;
5780
+ sdu_frag_tx .target_event = pkt_seq_num ;
5781
+ sdu_frag_tx .grp_ref_point =
5782
+ isoal_get_wrapped_time_us (cig -> cig_ref_point ,
5783
+ ((pkt_seq_num - event_count ) *
5784
+ cig -> iso_interval *
5785
+ ISO_INT_UNIT_US ));
5786
+
5787
+ #else /* !CONFIG_BT_CTLR_ISOAL_PSN_IGNORE */
5788
+ uint8_t event_offset ;
5760
5789
5761
5790
/* We must ensure sufficient time for ISO-AL to fragment SDU and
5762
5791
* deliver PDUs to the TX queue. By checking ull_ref_get, we
@@ -5780,11 +5809,15 @@ int hci_iso_handle(struct net_buf *buf, struct net_buf **evt)
5780
5809
}
5781
5810
5782
5811
sdu_frag_tx .target_event = cis -> lll .event_count + event_offset ;
5783
- sdu_frag_tx .grp_ref_point = isoal_get_wrapped_time_us (cig -> cig_ref_point ,
5784
- (event_offset * cig -> iso_interval *
5785
- ISO_INT_UNIT_US ));
5812
+ sdu_frag_tx .grp_ref_point =
5813
+ isoal_get_wrapped_time_us (cig -> cig_ref_point ,
5814
+ (event_offset *
5815
+ cig -> iso_interval *
5816
+ ISO_INT_UNIT_US ));
5817
+ #endif /* !CONFIG_BT_CTLR_ISOAL_PSN_IGNORE */
5786
5818
5787
5819
/* Get controller's input data path for CIS */
5820
+ hdr = & (cis -> hdr );
5788
5821
dp_in = hdr -> datapath_in ;
5789
5822
if (!dp_in || dp_in -> path_id != BT_HCI_DATAPATH_ID_HCI ) {
5790
5823
LOG_ERR ("Input data path not set for HCI" );
@@ -5817,8 +5850,6 @@ int hci_iso_handle(struct net_buf *buf, struct net_buf **evt)
5817
5850
struct ll_adv_iso_set * adv_iso ;
5818
5851
struct lll_adv_iso * lll_iso ;
5819
5852
uint16_t stream_handle ;
5820
- uint8_t target_event ;
5821
- uint8_t event_offset ;
5822
5853
uint16_t slen ;
5823
5854
5824
5855
/* FIXME: Code only expects header present */
@@ -5844,6 +5875,53 @@ int hci_iso_handle(struct net_buf *buf, struct net_buf **evt)
5844
5875
return - EINVAL ;
5845
5876
}
5846
5877
5878
+ lll_iso = & adv_iso -> lll ;
5879
+
5880
+ #if defined(CONFIG_BT_CTLR_ISOAL_PSN_IGNORE )
5881
+ uint64_t event_count ;
5882
+ uint64_t pkt_seq_num ;
5883
+
5884
+ /* Catch up local pkt_seq_num with internal pkt_seq_num */
5885
+ event_count = lll_iso -> payload_count / lll_iso -> bn ;
5886
+ pkt_seq_num = event_count ;
5887
+ if (!(pb_flag & 0x01 ) &&
5888
+ (((pkt_seq_num - stream -> pkt_seq_num ) &
5889
+ BIT64_MASK (39 )) <= BIT64_MASK (38 ))) {
5890
+ stream -> pkt_seq_num = pkt_seq_num ;
5891
+ } else {
5892
+ pkt_seq_num = stream -> pkt_seq_num ;
5893
+ }
5894
+
5895
+ /* Pre-increment, for next ISO data packet seq num comparison */
5896
+ if (pb_flag & 0x10 ) {
5897
+ stream -> pkt_seq_num ++ ;
5898
+ }
5899
+
5900
+ /* Target next event to avoid overlapping with current event */
5901
+ /* FIXME: Implement ISO Tx ack generation early in done compared
5902
+ * to currently only in prepare. I.e. to ensure upper
5903
+ * layer has the number of completed packet before the
5904
+ * next BIG event, so as to supply new ISO data packets.
5905
+ * Without which upper layers need extra buffers to
5906
+ * buffer next ISO data packet.
5907
+ *
5908
+ * Enable below increment once early Tx ack is
5909
+ * implemented.
5910
+ *
5911
+ * pkt_seq_num++;
5912
+ */
5913
+ sdu_frag_tx .target_event = pkt_seq_num ;
5914
+ sdu_frag_tx .grp_ref_point =
5915
+ isoal_get_wrapped_time_us (adv_iso -> big_ref_point ,
5916
+ (((pkt_seq_num + 1U ) -
5917
+ event_count ) *
5918
+ lll_iso -> iso_interval *
5919
+ ISO_INT_UNIT_US ));
5920
+
5921
+ #else /* !CONFIG_BT_CTLR_ISOAL_PSN_IGNORE */
5922
+ uint8_t target_event ;
5923
+ uint8_t event_offset ;
5924
+
5847
5925
/* Determine the target event and the first event offset after
5848
5926
* datapath setup.
5849
5927
* event_offset mitigates the possibility of first SDU being
@@ -5861,7 +5939,6 @@ int hci_iso_handle(struct net_buf *buf, struct net_buf **evt)
5861
5939
* BIG event by incrementing the previous elapsed big_ref_point
5862
5940
* by one additional ISO interval.
5863
5941
*/
5864
- lll_iso = & adv_iso -> lll ;
5865
5942
target_event = lll_iso -> payload_count / lll_iso -> bn ;
5866
5943
event_offset = ull_ref_get (& adv_iso -> ull ) ? 0U : 1U ;
5867
5944
event_offset += lll_iso -> latency_prepare ;
@@ -5872,6 +5949,7 @@ int hci_iso_handle(struct net_buf *buf, struct net_buf **evt)
5872
5949
((event_offset + 1U ) *
5873
5950
lll_iso -> iso_interval *
5874
5951
ISO_INT_UNIT_US ));
5952
+ #endif /* !CONFIG_BT_CTLR_ISOAL_PSN_IGNORE */
5875
5953
5876
5954
/* Start Fragmentation */
5877
5955
/* FIXME: need to ensure ISO-AL returns proper isoal_status.
0 commit comments