File: rte_stack_lf.c

package info (click to toggle)
dpdk 25.11-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 127,892 kB
  • sloc: ansic: 2,358,479; python: 16,426; sh: 4,474; makefile: 1,713; awk: 70
file content (31 lines) | stat: -rw-r--r-- 676 bytes parent folder | download | duplicates (10)
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
/* SPDX-License-Identifier: BSD-3-Clause
 * Copyright(c) 2019 Intel Corporation
 */

#include "rte_stack.h"

void
rte_stack_lf_init(struct rte_stack *s, unsigned int count)
{
	struct rte_stack_lf_elem *elems = s->stack_lf.elems;
	unsigned int i;

	for (i = 0; i < count; i++)
		__rte_stack_lf_push_elems(&s->stack_lf.free,
					  &elems[i], &elems[i], 1);
}

ssize_t
rte_stack_lf_get_memsize(unsigned int count)
{
	ssize_t sz = sizeof(struct rte_stack);

	sz += RTE_CACHE_LINE_ROUNDUP(count * sizeof(struct rte_stack_lf_elem));

	/* Add padding to avoid false sharing conflicts caused by
	 * next-line hardware prefetchers.
	 */
	sz += 2 * RTE_CACHE_LINE_SIZE;

	return sz;
}