Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright 2025 Yunsilicon Technology Co., Ltd.
3 : : */
4 : :
5 : : #include <rte_bitmap.h>
6 : : #include <rte_malloc.h>
7 : :
8 : : #include "xsc_log.h"
9 : : #include "xsc_defs.h"
10 : : #include "xsc_np.h"
11 : : #include "xsc_cmd.h"
12 : : #include "xsc_dev.h"
13 : :
14 : : #define XSC_RSS_HASH_FUNC_TOPELIZ 0x1
15 : : #define XSC_LOGIC_PORT_MASK 0x07FF
16 : :
17 : : #define XSC_DEV_DEF_PCT_IDX_MIN 128
18 : : #define XSC_DEV_DEF_PCT_IDX_MAX 138
19 : :
20 : : /* Each board has a PCT manager*/
21 : : static struct xsc_dev_pct_mgr xsc_pct_mgr;
22 : :
23 : : enum xsc_np_type {
24 : : XSC_NP_IPAT = 0,
25 : : XSC_NP_PCT_V4 = 4,
26 : : XSC_NP_EPAT = 19,
27 : : XSC_NP_VFOS = 31,
28 : : XSC_NP_PG_QP_SET_ID = 41,
29 : : XSC_NP_MAX
30 : : };
31 : :
32 : : enum xsc_np_opcode {
33 : : XSC_NP_OP_ADD,
34 : : XSC_NP_OP_DEL,
35 : : XSC_NP_OP_GET,
36 : : XSC_NP_OP_CLR,
37 : : XSC_NP_OP_MOD,
38 : : XSC_NP_OP_MAX
39 : : };
40 : :
41 : : struct xsc_np_mbox_in {
42 : : struct xsc_cmd_inbox_hdr hdr;
43 : : rte_be16_t len;
44 : : rte_be16_t rsvd;
45 : : uint8_t data[];
46 : : };
47 : :
48 : : struct xsc_np_mbox_out {
49 : : struct xsc_cmd_outbox_hdr hdr;
50 : : rte_be32_t error;
51 : : rte_be16_t len;
52 : : rte_be16_t rsvd;
53 : : uint8_t data[];
54 : : };
55 : :
56 : : struct xsc_np_data_tl {
57 : : uint16_t table;
58 : : uint16_t opmod;
59 : : uint16_t length;
60 : : uint16_t rsvd;
61 : : };
62 : :
63 : : enum xsc_hash_tmpl {
64 : : XSC_HASH_TMPL_IDX_IP_PORTS_IP6_PORTS = 0,
65 : : XSC_HASH_TMPL_IDX_IP_IP6,
66 : : XSC_HASH_TMPL_IDX_IP_PORTS_IP6,
67 : : XSC_HASH_TMPL_IDX_IP_IP6_PORTS,
68 : : XSC_HASH_TMPL_IDX_MAX,
69 : : };
70 : :
71 : : static const int xsc_rss_hash_tmplate[XSC_HASH_TMPL_IDX_MAX] = {
72 : : XSC_RSS_HASH_BIT_IPV4_SIP | XSC_RSS_HASH_BIT_IPV4_DIP |
73 : : XSC_RSS_HASH_BIT_IPV6_SIP | XSC_RSS_HASH_BIT_IPV6_DIP |
74 : : XSC_RSS_HASH_BIT_IPV4_SPORT | XSC_RSS_HASH_BIT_IPV4_DPORT |
75 : : XSC_RSS_HASH_BIT_IPV6_SPORT | XSC_RSS_HASH_BIT_IPV6_DPORT,
76 : :
77 : : XSC_RSS_HASH_BIT_IPV4_SIP | XSC_RSS_HASH_BIT_IPV4_DIP |
78 : : XSC_RSS_HASH_BIT_IPV6_SIP | XSC_RSS_HASH_BIT_IPV6_DIP,
79 : :
80 : : XSC_RSS_HASH_BIT_IPV4_SIP | XSC_RSS_HASH_BIT_IPV4_DIP |
81 : : XSC_RSS_HASH_BIT_IPV6_SIP | XSC_RSS_HASH_BIT_IPV6_DIP |
82 : : XSC_RSS_HASH_BIT_IPV4_SPORT | XSC_RSS_HASH_BIT_IPV4_DPORT,
83 : :
84 : : XSC_RSS_HASH_BIT_IPV4_SIP | XSC_RSS_HASH_BIT_IPV4_DIP |
85 : : XSC_RSS_HASH_BIT_IPV6_SIP | XSC_RSS_HASH_BIT_IPV6_DIP |
86 : : XSC_RSS_HASH_BIT_IPV6_SPORT | XSC_RSS_HASH_BIT_IPV6_DPORT,
87 : : };
88 : :
89 : : static uint8_t
90 : 0 : xsc_rss_hash_template_get(struct rte_eth_rss_conf *rss_conf)
91 : : {
92 : : int rss_hf = 0;
93 : : int i = 0;
94 : : uint8_t idx = 0;
95 : : uint8_t outer = 1;
96 : :
97 [ # # ]: 0 : if (rss_conf->rss_hf & RTE_ETH_RSS_IP) {
98 : : rss_hf |= XSC_RSS_HASH_BIT_IPV4_SIP;
99 : : rss_hf |= XSC_RSS_HASH_BIT_IPV4_DIP;
100 : : rss_hf |= XSC_RSS_HASH_BIT_IPV6_SIP;
101 : : rss_hf |= XSC_RSS_HASH_BIT_IPV6_DIP;
102 : : }
103 : :
104 [ # # ]: 0 : if ((rss_conf->rss_hf & RTE_ETH_RSS_UDP) ||
105 : : (rss_conf->rss_hf & RTE_ETH_RSS_TCP)) {
106 : : rss_hf |= XSC_RSS_HASH_BIT_IPV4_SPORT;
107 : : rss_hf |= XSC_RSS_HASH_BIT_IPV4_DPORT;
108 : : rss_hf |= XSC_RSS_HASH_BIT_IPV6_SPORT;
109 : 0 : rss_hf |= XSC_RSS_HASH_BIT_IPV6_DPORT;
110 : : }
111 : :
112 [ # # ]: 0 : if (rss_conf->rss_hf & RTE_ETH_RSS_L3_SRC_ONLY) {
113 : : rss_hf |= XSC_RSS_HASH_BIT_IPV4_SIP;
114 : : rss_hf |= XSC_RSS_HASH_BIT_IPV6_SIP;
115 : : rss_hf &= ~XSC_RSS_HASH_BIT_IPV4_DIP;
116 : 0 : rss_hf &= ~XSC_RSS_HASH_BIT_IPV6_DIP;
117 : : }
118 : :
119 [ # # ]: 0 : if (rss_conf->rss_hf & RTE_ETH_RSS_L3_DST_ONLY) {
120 : : rss_hf |= XSC_RSS_HASH_BIT_IPV4_DIP;
121 : : rss_hf |= XSC_RSS_HASH_BIT_IPV6_DIP;
122 : : rss_hf &= ~XSC_RSS_HASH_BIT_IPV4_SIP;
123 : 0 : rss_hf &= ~XSC_RSS_HASH_BIT_IPV6_SIP;
124 : : }
125 : :
126 [ # # ]: 0 : if (rss_conf->rss_hf & RTE_ETH_RSS_L4_SRC_ONLY) {
127 : : rss_hf |= XSC_RSS_HASH_BIT_IPV4_SPORT;
128 : : rss_hf |= XSC_RSS_HASH_BIT_IPV6_SPORT;
129 : : rss_hf &= ~XSC_RSS_HASH_BIT_IPV4_DPORT;
130 : 0 : rss_hf &= ~XSC_RSS_HASH_BIT_IPV6_DPORT;
131 : : }
132 : :
133 [ # # ]: 0 : if (rss_conf->rss_hf & RTE_ETH_RSS_L4_DST_ONLY) {
134 : : rss_hf |= XSC_RSS_HASH_BIT_IPV4_DPORT;
135 : : rss_hf |= XSC_RSS_HASH_BIT_IPV6_DPORT;
136 : : rss_hf &= ~XSC_RSS_HASH_BIT_IPV4_SPORT;
137 : 0 : rss_hf &= ~XSC_RSS_HASH_BIT_IPV6_SPORT;
138 : : }
139 : :
140 [ # # ]: 0 : if (rss_conf->rss_hf & RTE_ETH_RSS_LEVEL_INNERMOST)
141 : : outer = 0;
142 : :
143 [ # # ]: 0 : for (i = 0; i < XSC_HASH_TMPL_IDX_MAX; i++) {
144 [ # # ]: 0 : if (xsc_rss_hash_tmplate[i] == rss_hf) {
145 : 0 : idx = i;
146 : 0 : break;
147 : : }
148 : : }
149 : :
150 : 0 : idx = (idx << 1) | outer;
151 : 0 : return idx;
152 : : }
153 : :
154 : : static int
155 : 0 : xsc_dev_np_exec(struct xsc_dev *xdev, void *cmd, int len, int table, int opmod)
156 : : {
157 : : struct xsc_np_data_tl *tl;
158 : : struct xsc_np_mbox_in *in;
159 : : struct xsc_np_mbox_out *out;
160 : : int in_len;
161 : : int out_len;
162 : : int data_len;
163 : : int cmd_len;
164 : : int ret;
165 : : void *cmd_buf;
166 : :
167 : 0 : data_len = sizeof(struct xsc_np_data_tl) + len;
168 : 0 : in_len = sizeof(struct xsc_np_mbox_in) + data_len;
169 : 0 : out_len = sizeof(struct xsc_np_mbox_out) + data_len;
170 : 0 : cmd_len = RTE_MAX(in_len, out_len);
171 : 0 : cmd_buf = malloc(cmd_len);
172 [ # # ]: 0 : if (cmd_buf == NULL) {
173 : 0 : rte_errno = ENOMEM;
174 : 0 : PMD_DRV_LOG(ERR, "Failed to alloc np cmd memory");
175 : 0 : return -rte_errno;
176 : : }
177 : :
178 : : in = cmd_buf;
179 : : memset(in, 0, cmd_len);
180 : 0 : in->hdr.opcode = rte_cpu_to_be_16(XSC_CMD_OP_EXEC_NP);
181 [ # # ]: 0 : in->len = rte_cpu_to_be_16(data_len);
182 : :
183 : : tl = (struct xsc_np_data_tl *)in->data;
184 : 0 : tl->length = len;
185 : 0 : tl->table = table;
186 : 0 : tl->opmod = opmod;
187 [ # # ]: 0 : if (cmd && len)
188 : 0 : memcpy(tl + 1, cmd, len);
189 : :
190 : : out = cmd_buf;
191 : 0 : ret = xsc_dev_mailbox_exec(xdev, in, in_len, out, out_len);
192 : :
193 : 0 : free(cmd_buf);
194 : 0 : return ret;
195 : : }
196 : :
197 : : int
198 : 0 : xsc_dev_create_pct(struct xsc_dev *xdev, int repr_id,
199 : : uint16_t logical_in_port, uint16_t dst_info)
200 : : {
201 : : int ret;
202 : : struct xsc_np_pct_v4_add add;
203 : 0 : struct xsc_repr_port *repr = &xdev->repr_ports[repr_id];
204 : 0 : struct xsc_dev_pct_list *pct_list = &repr->def_pct_list;
205 : :
206 : : memset(&add, 0, sizeof(add));
207 : 0 : add.key.logical_in_port = logical_in_port & XSC_LOGIC_PORT_MASK;
208 : 0 : add.mask.logical_in_port = XSC_LOGIC_PORT_MASK;
209 : 0 : add.action.dst_info = dst_info;
210 : 0 : add.pct_idx = xsc_dev_pct_idx_alloc();
211 [ # # ]: 0 : if (add.pct_idx == XSC_DEV_PCT_IDX_INVALID)
212 : : return -1;
213 : :
214 : 0 : ret = xsc_dev_np_exec(xdev, &add, sizeof(add), XSC_NP_PCT_V4, XSC_NP_OP_ADD);
215 [ # # ]: 0 : if (unlikely(ret != 0)) {
216 : 0 : xsc_dev_pct_idx_free(add.pct_idx);
217 : 0 : return -1;
218 : : }
219 : :
220 : 0 : xsc_dev_pct_entry_insert(pct_list, add.key.logical_in_port, add.pct_idx);
221 : 0 : return 0;
222 : : }
223 : :
224 : : int
225 : 0 : xsc_dev_destroy_pct(struct xsc_dev *xdev, uint16_t logical_in_port, uint32_t pct_idx)
226 : : {
227 : : struct xsc_np_pct_v4_del del;
228 : :
229 : : memset(&del, 0, sizeof(del));
230 : 0 : del.key.logical_in_port = logical_in_port & XSC_LOGIC_PORT_MASK;
231 : 0 : del.mask.logical_in_port = XSC_LOGIC_PORT_MASK;
232 : 0 : del.pct_idx = pct_idx;
233 : 0 : return xsc_dev_np_exec(xdev, &del, sizeof(del), XSC_NP_PCT_V4, XSC_NP_OP_DEL);
234 : : }
235 : :
236 : : void
237 : 0 : xsc_dev_clear_pct(struct xsc_dev *xdev, int repr_id)
238 : : {
239 : : struct xsc_repr_port *repr;
240 : : struct xsc_dev_pct_entry *pct_entry;
241 : : struct xsc_dev_pct_list *pct_list;
242 : :
243 [ # # ]: 0 : if (repr_id == XSC_DEV_REPR_ID_INVALID)
244 : : return;
245 : :
246 : 0 : repr = &xdev->repr_ports[repr_id];
247 : 0 : pct_list = &repr->def_pct_list;
248 : :
249 [ # # ]: 0 : while ((pct_entry = xsc_dev_pct_first_get(pct_list)) != NULL) {
250 : 0 : xsc_dev_destroy_pct(xdev, pct_entry->logic_port, pct_entry->pct_idx);
251 : 0 : xsc_dev_pct_entry_remove(pct_entry);
252 : : }
253 : : }
254 : :
255 : : int
256 : 0 : xsc_dev_create_ipat(struct xsc_dev *xdev, uint16_t logic_in_port, uint16_t dst_info)
257 : : {
258 : : struct xsc_np_ipat add;
259 : :
260 : : memset(&add, 0, sizeof(add));
261 : 0 : add.key.logical_in_port = logic_in_port;
262 : 0 : add.action.dst_info = dst_info;
263 : 0 : add.action.vld = 1;
264 : 0 : return xsc_dev_np_exec(xdev, &add, sizeof(add), XSC_NP_IPAT, XSC_NP_OP_ADD);
265 : : }
266 : :
267 : : int
268 : 0 : xsc_dev_get_ipat_vld(struct xsc_dev *xdev, uint16_t logic_in_port)
269 : : {
270 : : int ret;
271 : : struct xsc_np_ipat get;
272 : :
273 : : memset(&get, 0, sizeof(get));
274 : 0 : get.key.logical_in_port = logic_in_port;
275 : :
276 : 0 : ret = xsc_dev_np_exec(xdev, &get, sizeof(get), XSC_NP_IPAT, XSC_NP_OP_GET);
277 [ # # ]: 0 : if (ret != 0)
278 : 0 : PMD_DRV_LOG(ERR, "Get ipat vld failed, logic in port=%u", logic_in_port);
279 : :
280 : 0 : return get.action.vld;
281 : : }
282 : :
283 : : int
284 : 0 : xsc_dev_destroy_ipat(struct xsc_dev *xdev, uint16_t logic_in_port)
285 : : {
286 : : struct xsc_ipat_key del;
287 : :
288 : : memset(&del, 0, sizeof(del));
289 : 0 : del.logical_in_port = logic_in_port;
290 : 0 : return xsc_dev_np_exec(xdev, &del, sizeof(del), XSC_NP_IPAT, XSC_NP_OP_DEL);
291 : : }
292 : :
293 : : int
294 : 0 : xsc_dev_create_epat(struct xsc_dev *xdev, uint16_t dst_info, uint8_t dst_port,
295 : : uint16_t qpn_ofst, uint8_t qp_num, struct rte_eth_rss_conf *rss_conf)
296 : : {
297 : : struct xsc_np_epat_add add;
298 : :
299 : : memset(&add, 0, sizeof(add));
300 : 0 : add.key.dst_info = dst_info;
301 : 0 : add.action.dst_port = dst_port;
302 : 0 : add.action.vld = 1;
303 : 0 : add.action.rx_qp_id_ofst = qpn_ofst;
304 : 0 : add.action.qp_num = qp_num - 1;
305 : 0 : add.action.rss_en = 1;
306 : 0 : add.action.rss_hash_func = XSC_RSS_HASH_FUNC_TOPELIZ;
307 : 0 : add.action.rss_hash_template = xsc_rss_hash_template_get(rss_conf);
308 : :
309 : 0 : return xsc_dev_np_exec(xdev, &add, sizeof(add), XSC_NP_EPAT, XSC_NP_OP_ADD);
310 : : }
311 : :
312 : : int
313 : 0 : xsc_dev_vf_modify_epat(struct xsc_dev *xdev, uint16_t dst_info, uint16_t qpn_ofst,
314 : : uint8_t qp_num, struct rte_eth_rss_conf *rss_conf)
315 : : {
316 : : struct xsc_np_epat_mod mod;
317 : :
318 : : memset(&mod, 0, sizeof(mod));
319 : 0 : mod.flags = XSC_EPAT_VLD_FLAG | XSC_EPAT_RX_QP_ID_OFST_FLAG |
320 : : XSC_EPAT_QP_NUM_FLAG | XSC_EPAT_HAS_PPH_FLAG |
321 : : XSC_EPAT_RSS_EN_FLAG | XSC_EPAT_RSS_HASH_TEMPLATE_FLAG |
322 : : XSC_EPAT_RSS_HASH_FUNC_FLAG;
323 : :
324 : 0 : mod.key.dst_info = dst_info;
325 : 0 : mod.action.vld = 1;
326 : 0 : mod.action.rx_qp_id_ofst = qpn_ofst;
327 : 0 : mod.action.qp_num = qp_num - 1;
328 : 0 : mod.action.rss_en = 1;
329 : 0 : mod.action.rss_hash_func = XSC_RSS_HASH_FUNC_TOPELIZ;
330 : 0 : mod.action.rss_hash_template = xsc_rss_hash_template_get(rss_conf);
331 : :
332 : 0 : return xsc_dev_np_exec(xdev, &mod, sizeof(mod), XSC_NP_EPAT, XSC_NP_OP_MOD);
333 : : }
334 : :
335 : : int
336 : 0 : xsc_dev_set_qpsetid(struct xsc_dev *xdev, uint32_t txqpn, uint16_t qp_set_id)
337 : : {
338 : : int ret;
339 : : struct xsc_pg_set_id add;
340 : 0 : uint16_t qp_id_base = xdev->hwinfo.raw_qp_id_base;
341 : :
342 : : memset(&add, 0, sizeof(add));
343 : 0 : add.key.qp_id = txqpn - qp_id_base;
344 : 0 : add.action.qp_set_id = qp_set_id;
345 : :
346 : 0 : ret = xsc_dev_np_exec(xdev, &add, sizeof(add), XSC_NP_PG_QP_SET_ID, XSC_NP_OP_ADD);
347 [ # # ]: 0 : if (ret != 0)
348 : 0 : PMD_DRV_LOG(ERR, "Failed to set qp %u setid %u", txqpn, qp_set_id);
349 : :
350 : 0 : return ret;
351 : : }
352 : :
353 : : int
354 : 0 : xsc_dev_destroy_epat(struct xsc_dev *xdev, uint16_t dst_info)
355 : : {
356 : : struct xsc_epat_key del;
357 : :
358 : : memset(&del, 0, sizeof(del));
359 : :
360 : 0 : del.dst_info = dst_info;
361 : 0 : return xsc_dev_np_exec(xdev, &del, sizeof(del), XSC_NP_EPAT, XSC_NP_OP_DEL);
362 : : }
363 : :
364 : : int
365 : 0 : xsc_dev_create_vfos_baselp(struct xsc_dev *xdev)
366 : : {
367 : : int ret;
368 : : struct xsc_np_vfso add;
369 : :
370 : : memset(&add, 0, sizeof(add));
371 : 0 : add.key.src_port = xdev->vfrep_offset;
372 : 0 : add.action.ofst = xdev->vfos_logical_in_port;
373 : :
374 : 0 : ret = xsc_dev_np_exec(xdev, &add, sizeof(add), XSC_NP_VFOS, XSC_NP_OP_ADD);
375 [ # # ]: 0 : if (ret != 0)
376 : 0 : PMD_DRV_LOG(ERR, "Failed to set vfos, port=%u, offset=%u",
377 : : add.key.src_port, add.action.ofst);
378 : :
379 : 0 : return ret;
380 : : }
381 : :
382 : : void
383 : 0 : xsc_dev_pct_uninit(void)
384 : : {
385 : 0 : rte_free(xsc_pct_mgr.bmp_mem);
386 : 0 : xsc_pct_mgr.bmp_mem = NULL;
387 : 0 : }
388 : :
389 : : int
390 : 0 : xsc_dev_pct_init(void)
391 : : {
392 : : int ret;
393 : : uint8_t *bmp_mem;
394 : : uint32_t pos, pct_sz, bmp_sz;
395 : :
396 [ # # ]: 0 : if (xsc_pct_mgr.bmp_mem != NULL)
397 : : return 0;
398 : :
399 : : pct_sz = XSC_DEV_DEF_PCT_IDX_MAX - XSC_DEV_DEF_PCT_IDX_MIN + 1;
400 : 0 : bmp_sz = rte_bitmap_get_memory_footprint(pct_sz);
401 : 0 : bmp_mem = rte_zmalloc(NULL, bmp_sz, RTE_CACHE_LINE_SIZE);
402 [ # # ]: 0 : if (bmp_mem == NULL) {
403 : 0 : PMD_DRV_LOG(ERR, "Failed to alloc pct bitmap memory");
404 : : ret = -ENOMEM;
405 : 0 : goto pct_init_fail;
406 : : }
407 : :
408 : 0 : xsc_pct_mgr.bmp_mem = bmp_mem;
409 : 0 : xsc_pct_mgr.bmp_pct = rte_bitmap_init(pct_sz, bmp_mem, bmp_sz);
410 [ # # ]: 0 : if (xsc_pct_mgr.bmp_pct == NULL) {
411 : 0 : PMD_DRV_LOG(ERR, "Failed to init pct bitmap");
412 : : ret = -EINVAL;
413 : 0 : goto pct_init_fail;
414 : : }
415 : :
416 : : /* Mark all pct bitmap available */
417 [ # # ]: 0 : for (pos = 0; pos < pct_sz; pos++)
418 : 0 : rte_bitmap_set(xsc_pct_mgr.bmp_pct, pos);
419 : :
420 : : return 0;
421 : :
422 : 0 : pct_init_fail:
423 : 0 : xsc_dev_pct_uninit();
424 : 0 : return ret;
425 : : }
426 : :
427 : : uint32_t
428 : 0 : xsc_dev_pct_idx_alloc(void)
429 : : {
430 : : int ret;
431 : 0 : uint64_t slab = 0;
432 : 0 : uint32_t pos = 0;
433 : :
434 : 0 : ret = rte_bitmap_scan(xsc_pct_mgr.bmp_pct, &pos, &slab);
435 [ # # ]: 0 : if (ret != 0) {
436 : 0 : pos += rte_bsf64(slab);
437 : 0 : rte_bitmap_clear(xsc_pct_mgr.bmp_pct, pos);
438 : 0 : return (pos + XSC_DEV_DEF_PCT_IDX_MIN);
439 : : }
440 : :
441 : 0 : PMD_DRV_LOG(ERR, "Failed to alloc xsc pct idx");
442 : 0 : return XSC_DEV_PCT_IDX_INVALID;
443 : : }
444 : :
445 : : void
446 : 0 : xsc_dev_pct_idx_free(uint32_t pct_idx)
447 : : {
448 : 0 : rte_bitmap_set(xsc_pct_mgr.bmp_pct, pct_idx - XSC_DEV_DEF_PCT_IDX_MIN);
449 : 0 : }
450 : :
451 : : int
452 : 0 : xsc_dev_pct_entry_insert(struct xsc_dev_pct_list *pct_list,
453 : : uint32_t logic_port, uint32_t pct_idx)
454 : : {
455 : : struct xsc_dev_pct_entry *pct_entry;
456 : :
457 : 0 : pct_entry = rte_zmalloc(NULL, sizeof(struct xsc_dev_pct_entry), RTE_CACHE_LINE_SIZE);
458 [ # # ]: 0 : if (pct_entry == NULL) {
459 : 0 : PMD_DRV_LOG(ERR, "Failed to alloc pct entry memory");
460 : 0 : return -ENOMEM;
461 : : }
462 : :
463 : 0 : pct_entry->logic_port = logic_port;
464 : 0 : pct_entry->pct_idx = pct_idx;
465 [ # # ]: 0 : LIST_INSERT_HEAD(pct_list, pct_entry, next);
466 : :
467 : 0 : return 0;
468 : : }
469 : :
470 : : struct xsc_dev_pct_entry *
471 : 0 : xsc_dev_pct_first_get(struct xsc_dev_pct_list *pct_list)
472 : : {
473 : : struct xsc_dev_pct_entry *pct_entry;
474 : :
475 : 0 : pct_entry = LIST_FIRST(pct_list);
476 : 0 : return pct_entry;
477 : : }
478 : :
479 : : int
480 : 0 : xsc_dev_pct_entry_remove(struct xsc_dev_pct_entry *pct_entry)
481 : : {
482 [ # # ]: 0 : if (pct_entry == NULL)
483 : : return -1;
484 : :
485 : 0 : xsc_dev_pct_idx_free(pct_entry->pct_idx);
486 [ # # ]: 0 : LIST_REMOVE(pct_entry, next);
487 : 0 : rte_free(pct_entry);
488 : :
489 : 0 : return 0;
490 : : }
|