diff options
Diffstat (limited to 'src/host/virt_phy/src/virt_l1_sched_simple.c')
-rw-r--r-- | src/host/virt_phy/src/virt_l1_sched_simple.c | 76 |
1 files changed, 45 insertions, 31 deletions
diff --git a/src/host/virt_phy/src/virt_l1_sched_simple.c b/src/host/virt_phy/src/virt_l1_sched_simple.c index d3975ee1..40bc57a1 100644 --- a/src/host/virt_phy/src/virt_l1_sched_simple.c +++ b/src/host/virt_phy/src/virt_l1_sched_simple.c @@ -1,3 +1,22 @@ +/* (C) 2016 by Sebastian Stumpf <sebastian.stumpf87@googlemail.com> + * + * All Rights Reserved + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + #include <virtphy/virt_l1_sched.h> #include <osmocom/core/linuxlist.h> #include <virtphy/virt_l1_model.h> @@ -14,7 +33,7 @@ static uint32_t last_exec_fn = 0; /** * @brief Initialize schedulers data structures. */ -void virt_l1_sched_init(struct l1_model_ms * model) +void virt_l1_sched_init(struct l1_model_ms *model) { l1_model_ms = model; } @@ -53,11 +72,10 @@ void virt_l1_sched_stop() struct virt_l1_sched_mframe_item *mi_next, *mi_tmp; /* Empty tdma and mframe sched items lists */ - llist_for_each_entry_safe(mi_next, mi_tmp, &mframe_item_list, mframe_item_entry) - { + llist_for_each_entry_safe(mi_next, mi_tmp, &mframe_item_list, mframe_item_entry) { struct virt_l1_sched_tdma_item *ti_next, *ti_tmp; - llist_for_each_entry_safe(ti_next, ti_tmp, &mi_next->tdma_item_list, tdma_item_entry) - { + + llist_for_each_entry_safe(ti_next, ti_tmp, &mi_next->tdma_item_list, tdma_item_entry) { talloc_free(ti_next->msg); llist_del(&ti_next->tdma_item_entry); } @@ -74,32 +92,31 @@ void virt_l1_sched_execute(uint32_t fn) struct virt_l1_sched_mframe_item *mi_next, *mi_tmp; uint8_t hyperframe_restart = fn < last_exec_fn; - llist_for_each_entry_safe(mi_next, mi_tmp, &mframe_item_list, mframe_item_entry) - { + llist_for_each_entry_safe(mi_next, mi_tmp, &mframe_item_list, mframe_item_entry) { /* execute all registered handler for current mf sched item */ uint8_t exec_now = mi_next->fn <= fn || (hyperframe_restart && mi_next->fn > last_exec_fn); /* break loop, as we have an ordered list in case the hyperframe had not been reset */ uint8_t break_now = mi_next->fn > fn && !hyperframe_restart; - if(exec_now) { + if (exec_now) { struct virt_l1_sched_tdma_item *ti_next, *ti_tmp; - // run through all scheduled tdma sched items for that frame number - llist_for_each_entry_safe(ti_next, ti_tmp, &mi_next->tdma_item_list, tdma_item_entry) - { - // exec tdma sched item's handler callback - // TODO: we do not have a tdma scheduler currently and execute alle scheduled tdma items here at once + /* run through all scheduled tdma sched items for that frame number */ + llist_for_each_entry_safe(ti_next, ti_tmp, &mi_next->tdma_item_list, + tdma_item_entry) { + /* exec tdma sched item's handler callback */ + /* TODO: we do not have a TDMA scheduler currently and execute + * all scheduled tdma items here at once */ ti_next->handler_cb(mi_next->fn, ti_next->msg); - // remove handled tdma sched item + /* remove handled tdma sched item */ llist_del(&ti_next->tdma_item_entry); } - // remove handled mframe sched item + /* remove handled mframe sched item */ llist_del(&mi_next->mframe_item_entry); talloc_free(mi_next); } - if(break_now) { + if (break_now) break; - } } last_exec_fn = fn; } @@ -110,36 +127,33 @@ void virt_l1_sched_execute(uint32_t fn) void virt_l1_sched_schedule(struct msgb * msg, uint32_t fn, uint8_t ts, virt_l1_sched_cb * handler_cb) { - struct virt_l1_sched_mframe_item *mi_next = NULL, *mi_tmp = NULL, - *mi_fn = NULL; + struct virt_l1_sched_mframe_item *mi_next = NULL, *mi_tmp = NULL, *mi_fn = NULL; struct virt_l1_sched_tdma_item *ti_new = NULL; - llist_for_each_entry_safe(mi_next, mi_tmp, &mframe_item_list, mframe_item_entry) - { + llist_for_each_entry_safe(mi_next, mi_tmp, &mframe_item_list, mframe_item_entry) { if (mi_next->fn == fn) { mi_fn = mi_next; break; - } else if (mi_next->fn > fn) { + } else if (mi_next->fn > fn) break; - } } if (!mi_fn) { - // list did not contain mframe item with needed fn + /* list did not contain mframe item with needed fn */ mi_fn = talloc_zero(NULL, struct virt_l1_sched_mframe_item); mi_fn->fn = fn; - // need to manually init the struct content.... no so happy + /* need to manually init the struct content.... no so happy */ mi_fn->tdma_item_list.prev = &mi_fn->tdma_item_list; mi_fn->tdma_item_list.next = &mi_fn->tdma_item_list; - // TODO: check if we get an error if list is empty... - llist_add(&mi_fn->mframe_item_entry, - mi_next->mframe_item_entry.prev); - + /* TODO: check if we get an error if list is empty... */ + llist_add(&mi_fn->mframe_item_entry, mi_next->mframe_item_entry.prev); } + ti_new = talloc_zero(mi_fn, struct virt_l1_sched_tdma_item); ti_new->msg = msg; ti_new->handler_cb = handler_cb; ti_new->ts = ts; - // simply add at end, no ordering for tdma sched items currently - llist_add_tail(&ti_new->tdma_item_entry, &mi_fn->tdma_item_list); // TODO: ordered insert needed if tdma scheduler should be implemented + /* simply add at end, no ordering for tdma sched items currently */ + llist_add_tail(&ti_new->tdma_item_entry, &mi_fn->tdma_item_list); + /* TODO: ordered insert needed if tdma scheduler should be implemented */ } |