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 * pipeline 109 */ 110 struct pipeline { 111 TAILQ_ENTRY(pipeline) node; 112 char name[NAME_SIZE]; 113 114 struct rte_swx_pipeline *p; 115 struct rte_swx_ctl_pipeline *ctl; 116 117 uint32_t timer_period_ms; 118 int enabled; 119 uint32_t thread_id; 120 uint32_t cpu_id; 121 }; 122 123 struct pipeline * 124 pipeline_create(struct obj *obj, 125 const char *name, 126 int numa_node); 127 128 struct pipeline * 129 pipeline_find(struct obj *obj, const char *name); 130 131 #endif /* _INCLUDE_OBJ_H_ */ 132