xref: /dpdk/examples/pipeline/obj.h (revision 02d36ef6a9528e0f4a3403956e66bcea5fadbf8c)
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2020 Intel Corporation
3  */
4 
5 #ifndef _INCLUDE_OBJ_H_
6 #define _INCLUDE_OBJ_H_
7 
8 #include <stdint.h>
9 #include <sys/queue.h>
10 
11 #include <rte_swx_pipeline.h>
12 #include <rte_swx_ctl.h>
13 
14 #ifndef NAME_SIZE
15 #define NAME_SIZE 64
16 #endif
17 
18 /*
19  * obj
20  */
21 struct obj;
22 
23 struct obj *
24 obj_init(void);
25 
26 /*
27  * link
28  */
29 #ifndef LINK_RXQ_RSS_MAX
30 #define LINK_RXQ_RSS_MAX                                   16
31 #endif
32 
33 struct link_params_rss {
34 	uint32_t queue_id[LINK_RXQ_RSS_MAX];
35 	uint32_t n_queues;
36 };
37 
38 struct link_params {
39 	struct {
40 		uint32_t n_queues;
41 		uint32_t queue_size;
42 		const char *mempool_name;
43 		struct link_params_rss *rss;
44 	} rx;
45 
46 	struct {
47 		uint32_t n_queues;
48 		uint32_t queue_size;
49 	} tx;
50 
51 	int promiscuous;
52 };
53 
54 struct link {
55 	TAILQ_ENTRY(link) node;
56 	char name[NAME_SIZE];
57 	uint16_t port_id;
58 	uint32_t n_rxq;
59 	uint32_t n_txq;
60 };
61 
62 struct link *
63 link_create(struct obj *obj,
64 	    const char *name,
65 	    struct link_params *params);
66 
67 int
68 link_is_up(struct obj *obj, const char *name);
69 
70 struct link *
71 link_find(struct obj *obj, const char *name);
72 
73 struct link *
74 link_next(struct obj *obj, struct link *link);
75 
76 /*
77  * ring
78  */
79 struct ring_params {
80 	uint32_t size;
81 	uint32_t numa_node;
82 };
83 
84 struct ring {
85 	TAILQ_ENTRY(ring) node;
86 	char name[NAME_SIZE];
87 };
88 
89 struct ring *
90 ring_create(struct obj *obj,
91 	   const char *name,
92 	   struct ring_params *params);
93 
94 struct ring *
95 ring_find(struct obj *obj, const char *name);
96 
97 #endif /* _INCLUDE_OBJ_H_ */
98