summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndreas Eversberg2011-06-25 22:46:24 +0200
committerSylvain Munaut2011-06-25 22:46:24 +0200
commitbd3629e4e6fe8d5ef958031178c22829c93d1491 (patch)
treea3360acf776af8dd2c53cd529d45e2068f2d7eb4 /src
parentfw/sercomm: Additional locking needed in drv_pull (diff)
downloadosmocom-bd3629e4e6fe8d5ef958031178c22829c93d1491.tar.gz
osmocom-bd3629e4e6fe8d5ef958031178c22829c93d1491.tar.xz
osmocom-bd3629e4e6fe8d5ef958031178c22829c93d1491.zip
fw/l1a: Add a message to safely count the length of a txqueue
(that is by locking) Written-by: Andreas Eversberg <jolly@eversberg.eu> Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Diffstat (limited to 'src')
-rw-r--r--src/target/firmware/include/layer1/async.h3
-rw-r--r--src/target/firmware/layer1/async.c15
2 files changed, 18 insertions, 0 deletions
diff --git a/src/target/firmware/include/layer1/async.h b/src/target/firmware/include/layer1/async.h
index 93c5077..301625c 100644
--- a/src/target/firmware/include/layer1/async.h
+++ b/src/target/firmware/include/layer1/async.h
@@ -26,6 +26,9 @@ static inline void l1a_unlock_sync(void)
void l1a_txq_msgb_enq(struct llist_head *queue, struct msgb *msg);
void l1a_meas_msgb_set(struct msgb *msg);
+/* safely count messages in the L1S TX queue */
+int l1a_txq_msgb_count(struct llist_head *queue);
+
/* flush all pending msgb */
void l1a_txq_msgb_flush(struct llist_head *queue);
diff --git a/src/target/firmware/layer1/async.c b/src/target/firmware/layer1/async.c
index e5c80c7..c07b0b5 100644
--- a/src/target/firmware/layer1/async.c
+++ b/src/target/firmware/layer1/async.c
@@ -59,6 +59,21 @@ void l1a_meas_msgb_set(struct msgb *msg)
local_irq_restore(flags);
}
+/* safely count messages in the L1S TX queue */
+int l1a_txq_msgb_count(struct llist_head *queue)
+{
+ unsigned long flags;
+ int num = 0;
+ struct llist_head *le;
+
+ local_firq_save(flags);
+ llist_for_each(le, queue)
+ num++;
+ local_irq_restore(flags);
+
+ return num;
+}
+
/* safely flush all pending msgb */
void l1a_txq_msgb_flush(struct llist_head *queue)
{