Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause 2 : : * Copyright(c) 2016 Cavium, Inc 3 : : */ 4 : : 5 : : #include <assert.h> 6 : : #include <stddef.h> 7 : : 8 : : #include <rte_debug.h> 9 : : #include <rte_malloc.h> 10 : : 11 : : #include "base/nicvf_bsvf.h" 12 : : 13 : : #include "nicvf_svf.h" 14 : : 15 : : void 16 : 0 : nicvf_svf_push(struct nicvf *vf) 17 : : { 18 : : struct svf_entry *entry = NULL; 19 : : 20 [ # # ]: 0 : assert(vf != NULL); 21 : : 22 : 0 : entry = rte_zmalloc("nicvf", sizeof(*entry), RTE_CACHE_LINE_SIZE); 23 [ # # ]: 0 : if (entry == NULL) 24 : 0 : rte_panic("Cannot allocate memory for svf_entry\n"); 25 : : 26 : 0 : entry->vf = vf; 27 : : 28 : 0 : nicvf_bsvf_push(entry); 29 : 0 : } 30 : : 31 : : struct nicvf * 32 : 0 : nicvf_svf_pop(void) 33 : : { 34 : : struct nicvf *vf; 35 : : struct svf_entry *entry; 36 : : 37 : 0 : entry = nicvf_bsvf_pop(); 38 : : 39 : 0 : vf = entry->vf; 40 : : 41 : 0 : rte_free(entry); 42 : : 43 : 0 : return vf; 44 : : } 45 : : 46 : : int 47 : 0 : nicvf_svf_empty(void) 48 : : { 49 : 0 : return nicvf_bsvf_empty(); 50 : : }