summaryrefslogtreecommitdiffstats
path: root/drivers/net/thunderx/base/nicvf_bsvf.c
blob: df8c016a46f04f39a5e28b8d326d5ea5c85e495f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/* SPDX-License-Identifier: BSD-3-Clause
 * Copyright(c) 2016 Cavium, Inc
 */

#include <assert.h>
#include <stddef.h>
#include <err.h>

#include "nicvf_bsvf.h"
#include "nicvf_plat.h"

static STAILQ_HEAD(, svf_entry) head = STAILQ_HEAD_INITIALIZER(head);

void
nicvf_bsvf_push(struct svf_entry *entry)
{
	assert(entry != NULL);
	assert(entry->vf != NULL);

	STAILQ_INSERT_TAIL(&head, entry, next);
}

struct svf_entry *
nicvf_bsvf_pop(void)
{
	struct svf_entry *entry;

	assert(!STAILQ_EMPTY(&head));

	entry = STAILQ_FIRST(&head);

	assert(entry != NULL);
	assert(entry->vf != NULL);

	STAILQ_REMOVE_HEAD(&head, next);

	return entry;
}

int
nicvf_bsvf_empty(void)
{
	return STAILQ_EMPTY(&head);
}