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 const char *dev_name; 67 uint16_t port_id; /**< Valid only when *dev_name* is NULL. */ 68 69 struct { 70 uint32_t n_queues; 71 uint32_t queue_size; 72 const char *mempool_name; 73 struct link_params_rss *rss; 74 } rx; 75 76 struct { 77 uint32_t n_queues; 78 uint32_t queue_size; 79 } tx; 80 81 int promiscuous; 82 }; 83 84 struct link { 85 TAILQ_ENTRY(link) node; 86 char name[NAME_SIZE]; 87 char dev_name[NAME_SIZE]; 88 uint16_t port_id; 89 uint32_t n_rxq; 90 uint32_t n_txq; 91 }; 92 93 struct link * 94 link_create(struct obj *obj, 95 const char *name, 96 struct link_params *params); 97 98 int 99 link_is_up(struct obj *obj, const char *name); 100 101 struct link * 102 link_find(struct obj *obj, const char *name); 103 104 struct link * 105 link_next(struct obj *obj, struct link *link); 106 107 /* 108 * ring 109 */ 110 struct ring_params { 111 uint32_t size; 112 uint32_t numa_node; 113 }; 114 115 struct ring { 116 TAILQ_ENTRY(ring) node; 117 char name[NAME_SIZE]; 118 }; 119 120 struct ring * 121 ring_create(struct obj *obj, 122 const char *name, 123 struct ring_params *params); 124 125 struct ring * 126 ring_find(struct obj *obj, const char *name); 127 128 /* 129 * pipeline 130 */ 131 struct pipeline { 132 TAILQ_ENTRY(pipeline) node; 133 char name[NAME_SIZE]; 134 135 struct rte_swx_pipeline *p; 136 struct rte_swx_ctl_pipeline *ctl; 137 138 uint32_t timer_period_ms; 139 int enabled; 140 uint32_t thread_id; 141 uint32_t cpu_id; 142 }; 143 144 struct pipeline * 145 pipeline_create(struct obj *obj, 146 const char *name, 147 int numa_node); 148 149 struct pipeline * 150 pipeline_find(struct obj *obj, const char *name); 151 152 #endif /* _INCLUDE_OBJ_H_ */ 153