aboutsummaryrefslogtreecommitdiff
path: root/platform/linux-generic/include/odp_pkt_queue_internal.h
blob: 3c6ac72308e7af0cc35ae6b4f0026f1fe8565789 (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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/* SPDX-License-Identifier: BSD-3-Clause
 * Copyright (c) 2015 EZchip Semiconductor Ltd.
 * Copyright (c) 2015-2018 Linaro Limited
 */

#ifndef _ODP_INT_PKT_QUEUE_H_
#define _ODP_INT_PKT_QUEUE_H_

#ifdef __cplusplus
extern "C" {
#endif

#include <odp/api/packet.h>

#include <stdint.h>

typedef uint64_t _odp_int_queue_pool_t;
typedef uint32_t _odp_int_pkt_queue_t;

#define _ODP_INT_QUEUE_POOL_INVALID  0
#define _ODP_INT_PKT_QUEUE_INVALID   0

/* None of the functions in this file do any locking.  Thats because the
 * expected usage model is that each TM system will create its own
 * _odp_int_queue_pool, and then only call _odp_int_pkt_queue_append and
 * _odp_int_pkt_queue_remove from a single thread associated/dedicated to this
 * same TM system/_odp_int_queue_pool.  The main difficulty that this file
 * tries to deal with is the possibility of a huge number of queues (e.g. 16
 * million), where each such queue could have a huge range in the number of
 * pkts queued (say 0 to > 1,000) - yet the total "peak" number of pkts queued
 * is many orders of magnitude smaller than the product of max_num_queues
 * times max_queue_cnt.  In particular, it is assumed that even at peak usage,
 * only a small fraction of max_num_queues will be "active" - i.e. have any
 * pkts queued, yet over time it is expected that most every queue will have
 * some sort of backlog.
 */

/* max_num_queues must be <= 16 * 1024 * 1024. */
_odp_int_queue_pool_t _odp_queue_pool_create(uint32_t max_num_queues,
					     uint32_t max_queued_pkts);

_odp_int_pkt_queue_t _odp_pkt_queue_create(_odp_int_queue_pool_t queue_pool);

void _odp_pkt_queue_destroy(_odp_int_queue_pool_t queue_pool,
			    _odp_int_pkt_queue_t  pkt_queue);

int _odp_pkt_queue_append(_odp_int_queue_pool_t queue_pool,
			  _odp_int_pkt_queue_t  pkt_queue,
			  odp_packet_t          pkt);

int _odp_pkt_queue_remove(_odp_int_queue_pool_t queue_pool,
			  _odp_int_pkt_queue_t  pkt_queue,
			  odp_packet_t         *pkt);

void _odp_pkt_queue_stats_print(_odp_int_queue_pool_t queue_pool);

void _odp_queue_pool_destroy(_odp_int_queue_pool_t queue_pool);

#ifdef __cplusplus
}
#endif

#endif