1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright(c) 2016 Cavium, Inc 3 */ 4 5 #include <assert.h> 6 #include <stddef.h> 7 #include <err.h> 8 9 #include "nicvf_bsvf.h" 10 #include "nicvf_plat.h" 11 12 static STAILQ_HEAD(, svf_entry) head = STAILQ_HEAD_INITIALIZER(head); 13 14 void nicvf_bsvf_push(struct svf_entry * entry)15nicvf_bsvf_push(struct svf_entry *entry) 16 { 17 assert(entry != NULL); 18 assert(entry->vf != NULL); 19 20 STAILQ_INSERT_TAIL(&head, entry, next); 21 } 22 23 struct svf_entry * nicvf_bsvf_pop(void)24nicvf_bsvf_pop(void) 25 { 26 struct svf_entry *entry; 27 28 assert(!STAILQ_EMPTY(&head)); 29 30 entry = STAILQ_FIRST(&head); 31 32 assert(entry != NULL); 33 assert(entry->vf != NULL); 34 35 STAILQ_REMOVE_HEAD(&head, next); 36 37 return entry; 38 } 39 40 int nicvf_bsvf_empty(void)41nicvf_bsvf_empty(void) 42 { 43 return STAILQ_EMPTY(&head); 44 } 45