@@ -83,18 +83,6 @@ enum {
83
83
ATT_NUM_FLAGS ,
84
84
};
85
85
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
-
98
86
/* ATT channel specific data */
99
87
struct bt_att_chan {
100
88
/* Connection this channel is associated with */
@@ -103,7 +91,6 @@ struct bt_att_chan {
103
91
ATOMIC_DEFINE (flags , ATT_NUM_FLAGS );
104
92
struct bt_att_req * req ;
105
93
struct k_fifo tx_queue ;
106
- struct bt_att_tx_meta_data rsp_meta ;
107
94
struct k_work_delayable timeout_work ;
108
95
sys_snode_t node ;
109
96
};
@@ -172,6 +159,18 @@ static struct bt_att_req cancel;
172
159
*/
173
160
static k_tid_t att_handle_rsp_thread ;
174
161
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
+
175
174
#define bt_att_tx_meta_data (buf ) (((struct bt_att_tx_meta *)net_buf_user_data(buf))->data)
176
175
177
176
static 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)
193
192
static inline void tx_meta_data_free (struct bt_att_tx_meta_data * data )
194
193
{
195
194
__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
- }
206
195
207
196
(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 );
212
198
}
213
199
214
200
static 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
659
645
struct net_buf * buf ;
660
646
struct bt_att_tx_meta_data * data ;
661
647
k_timeout_t timeout ;
662
- bool is_rsp = false;
663
648
664
649
if (len + sizeof (op ) > bt_att_mtu (chan )) {
665
650
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
672
657
case ATT_CONFIRMATION :
673
658
/* Use a timeout only when responding/confirming */
674
659
timeout = BT_ATT_TIMEOUT ;
675
- is_rsp = true;
676
660
break ;
677
661
default :
678
662
timeout = K_FOREVER ;
@@ -684,31 +668,11 @@ static struct net_buf *bt_att_chan_create_pdu(struct bt_att_chan *chan, uint8_t
684
668
return NULL ;
685
669
}
686
670
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 ;
712
676
}
713
677
714
678
if (IS_ENABLED (CONFIG_BT_EATT )) {
0 commit comments