@@ -83,18 +83,6 @@ enum {
8383 ATT_NUM_FLAGS ,
8484};
8585
86- struct bt_att_tx_meta_data {
87- struct bt_att_chan * att_chan ;
88- uint16_t attr_count ;
89- bt_gatt_complete_func_t func ;
90- void * user_data ;
91- enum bt_att_chan_opt chan_opt ;
92- };
93-
94- struct bt_att_tx_meta {
95- struct bt_att_tx_meta_data * data ;
96- };
97-
9886/* ATT channel specific data */
9987struct bt_att_chan {
10088 /* Connection this channel is associated with */
@@ -103,7 +91,6 @@ struct bt_att_chan {
10391 ATOMIC_DEFINE (flags , ATT_NUM_FLAGS );
10492 struct bt_att_req * req ;
10593 struct k_fifo tx_queue ;
106- struct bt_att_tx_meta_data rsp_meta ;
10794 struct k_work_delayable timeout_work ;
10895 sys_snode_t node ;
10996};
@@ -172,6 +159,18 @@ static struct bt_att_req cancel;
172159 */
173160static k_tid_t att_handle_rsp_thread ;
174161
162+ struct bt_att_tx_meta_data {
163+ struct bt_att_chan * att_chan ;
164+ uint16_t attr_count ;
165+ bt_gatt_complete_func_t func ;
166+ void * user_data ;
167+ enum bt_att_chan_opt chan_opt ;
168+ };
169+
170+ struct bt_att_tx_meta {
171+ struct bt_att_tx_meta_data * data ;
172+ };
173+
175174#define bt_att_tx_meta_data (buf ) (((struct bt_att_tx_meta *)net_buf_user_data(buf))->data)
176175
177176static struct bt_att_tx_meta_data tx_meta_data [CONFIG_BT_CONN_TX_MAX ];
@@ -193,22 +192,9 @@ static struct bt_att_tx_meta_data *tx_meta_data_alloc(k_timeout_t timeout)
193192static inline void tx_meta_data_free (struct bt_att_tx_meta_data * data )
194193{
195194 __ASSERT_NO_MSG (data );
196- bool alloc_from_global = PART_OF_ARRAY (tx_meta_data , data );
197-
198- if (data == & data -> att_chan -> rsp_meta ) {
199- /* "Free-ness" is kept by remote: There can only ever be one
200- * transaction per-bearer.
201- */
202- __ASSERT_NO_MSG (!alloc_from_global );
203- } else {
204- __ASSERT_NO_MSG (alloc_from_global );
205- }
206195
207196 (void )memset (data , 0 , sizeof (* data ));
208-
209- if (alloc_from_global ) {
210- k_fifo_put (& free_att_tx_meta_data , data );
211- }
197+ k_fifo_put (& free_att_tx_meta_data , data );
212198}
213199
214200static int bt_att_chan_send (struct bt_att_chan * chan , struct net_buf * buf );
@@ -659,7 +645,6 @@ static struct net_buf *bt_att_chan_create_pdu(struct bt_att_chan *chan, uint8_t
659645 struct net_buf * buf ;
660646 struct bt_att_tx_meta_data * data ;
661647 k_timeout_t timeout ;
662- bool is_rsp = false;
663648
664649 if (len + sizeof (op ) > bt_att_mtu (chan )) {
665650 LOG_WRN ("ATT MTU exceeded, max %u, wanted %zu" , bt_att_mtu (chan ),
@@ -672,7 +657,6 @@ static struct net_buf *bt_att_chan_create_pdu(struct bt_att_chan *chan, uint8_t
672657 case ATT_CONFIRMATION :
673658 /* Use a timeout only when responding/confirming */
674659 timeout = BT_ATT_TIMEOUT ;
675- is_rsp = true;
676660 break ;
677661 default :
678662 timeout = K_FOREVER ;
@@ -684,31 +668,11 @@ static struct net_buf *bt_att_chan_create_pdu(struct bt_att_chan *chan, uint8_t
684668 return NULL ;
685669 }
686670
687- if (is_rsp ) {
688- /* There can only ever be one transaction at a time on a
689- * bearer/channel. Use a dedicated channel meta-data to ensure
690- * we can always queue an (error) RSP for each REQ. The ATT
691- * module can then reschedule the RSP if it is not able to send
692- * it immediately.
693- */
694- if (chan -> rsp_meta .att_chan ) {
695- /* Returning a NULL here will trigger an ATT timeout.
696- * This is better than an assert as an assert would
697- * allow a peer to DoS us.
698- */
699- LOG_ERR ("already processing a transaction on chan %p" , chan );
700-
701- return NULL ;
702- }
703- data = & chan -> rsp_meta ;
704- LOG_INF ("alloc rsp meta" );
705- } else {
706- data = tx_meta_data_alloc (timeout );
707- if (!data ) {
708- LOG_WRN ("Unable to allocate ATT TX meta" );
709- net_buf_unref (buf );
710- return NULL ;
711- }
671+ data = tx_meta_data_alloc (timeout );
672+ if (!data ) {
673+ LOG_WRN ("Unable to allocate ATT TX meta" );
674+ net_buf_unref (buf );
675+ return NULL ;
712676 }
713677
714678 if (IS_ENABLED (CONFIG_BT_EATT )) {
0 commit comments