1 /* 2 * Copyright (c) 2020 Demant 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #include <zephyr/sys/slist.h> 8 9 #include "ull_tx_queue.h" 10 ull_tx_q_init(struct ull_tx_q * queue)11void ull_tx_q_init(struct ull_tx_q *queue) 12 { 13 queue->pause_data = 0U; 14 sys_slist_init(&queue->tx_list); 15 sys_slist_init(&queue->data_list); 16 } 17 ull_tx_q_pause_data(struct ull_tx_q * queue)18void ull_tx_q_pause_data(struct ull_tx_q *queue) 19 { 20 queue->pause_data++; 21 } 22 ull_tx_q_resume_data(struct ull_tx_q * queue)23void ull_tx_q_resume_data(struct ull_tx_q *queue) 24 { 25 if (queue->pause_data > 0) { 26 queue->pause_data--; 27 } 28 29 /* move all paused data to the tail of tx list, only if not empty and no longer paused */ 30 if (!queue->pause_data && !sys_slist_is_empty(&queue->data_list)) { 31 sys_slist_merge_slist(&queue->tx_list, &queue->data_list); 32 } 33 } 34 ull_tx_q_enqueue_data(struct ull_tx_q * queue,struct node_tx * tx)35void ull_tx_q_enqueue_data(struct ull_tx_q *queue, struct node_tx *tx) 36 { 37 sys_slist_t *list; 38 39 if (queue->pause_data) { 40 /* enqueue data pdu into paused data wait list */ 41 list = &queue->data_list; 42 } else { 43 /* enqueue data pdu into tx list */ 44 list = &queue->tx_list; 45 } 46 47 sys_slist_append(list, (sys_snode_t *)tx); 48 } 49 ull_tx_q_enqueue_ctrl(struct ull_tx_q * queue,struct node_tx * tx)50void ull_tx_q_enqueue_ctrl(struct ull_tx_q *queue, struct node_tx *tx) 51 { 52 /* enqueue ctrl pdu into tx list */ 53 sys_slist_append(&queue->tx_list, (sys_snode_t *)tx); 54 } 55 ull_tx_q_peek(struct ull_tx_q * queue)56struct node_tx *ull_tx_q_peek(struct ull_tx_q *queue) 57 { 58 struct node_tx *tx; 59 60 tx = (struct node_tx *)sys_slist_peek_head(&queue->tx_list); 61 62 return tx; 63 } 64 ull_tx_q_dequeue(struct ull_tx_q * queue)65struct node_tx *ull_tx_q_dequeue(struct ull_tx_q *queue) 66 { 67 struct node_tx *tx; 68 69 tx = (struct node_tx *)sys_slist_get(&queue->tx_list); 70 71 return tx; 72 } 73