xref: /dpdk/examples/pipeline/obj.h (revision 8f1d23ece06adff5eae9f1b4365bdbbd3abee2b2)
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_mempool.h>
12 #include <rte_swx_pipeline.h>
13 #include <rte_swx_ctl.h>
14 
15 #ifndef NAME_SIZE
16 #define NAME_SIZE 64
17 #endif
18 
19 /*
20  * obj
21  */
22 struct obj;
23 
24 struct obj *
25 obj_init(void);
26 
27 /*
28  * mempool
29  */
30 struct mempool_params {
31 	uint32_t buffer_size;
32 	uint32_t pool_size;
33 	uint32_t cache_size;
34 	uint32_t cpu_id;
35 };
36 
37 struct mempool {
38 	TAILQ_ENTRY(mempool) node;
39 	char name[NAME_SIZE];
40 	struct rte_mempool *m;
41 	uint32_t buffer_size;
42 };
43 
44 struct mempool *
45 mempool_create(struct obj *obj,
46 	       const char *name,
47 	       struct mempool_params *params);
48 
49 struct mempool *
50 mempool_find(struct obj *obj,
51 	     const char *name);
52 
53 /*
54  * link
55  */
56 #ifndef LINK_RXQ_RSS_MAX
57 #define LINK_RXQ_RSS_MAX                                   16
58 #endif
59 
60 struct link_params_rss {
61 	uint32_t queue_id[LINK_RXQ_RSS_MAX];
62 	uint32_t n_queues;
63 };
64 
65 struct link_params {
66 	struct {
67 		uint32_t n_queues;
68 		uint32_t queue_size;
69 		const char *mempool_name;
70 		struct link_params_rss *rss;
71 	} rx;
72 
73 	struct {
74 		uint32_t n_queues;
75 		uint32_t queue_size;
76 	} tx;
77 
78 	int promiscuous;
79 };
80 
81 struct link {
82 	TAILQ_ENTRY(link) node;
83 	char name[NAME_SIZE];
84 	uint16_t port_id;
85 	uint32_t n_rxq;
86 	uint32_t n_txq;
87 };
88 
89 struct link *
90 link_create(struct obj *obj,
91 	    const char *name,
92 	    struct link_params *params);
93 
94 int
95 link_is_up(struct obj *obj, const char *name);
96 
97 struct link *
98 link_find(struct obj *obj, const char *name);
99 
100 struct link *
101 link_next(struct obj *obj, struct link *link);
102 
103 /*
104  * ring
105  */
106 struct ring_params {
107 	uint32_t size;
108 	uint32_t numa_node;
109 };
110 
111 struct ring {
112 	TAILQ_ENTRY(ring) node;
113 	char name[NAME_SIZE];
114 };
115 
116 struct ring *
117 ring_create(struct obj *obj,
118 	   const char *name,
119 	   struct ring_params *params);
120 
121 struct ring *
122 ring_find(struct obj *obj, const char *name);
123 
124 #endif /* _INCLUDE_OBJ_H_ */
125