xref: /dpdk/drivers/event/dlb2/rte_pmd_dlb2.c (revision 2518704288342eb855a9e43dc3abd41ba1b9c98f)
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2020 Intel Corporation
3  */
4 
5 #include <rte_eventdev.h>
6 #include <eventdev_pmd.h>
7 
8 #include "rte_pmd_dlb2.h"
9 #include "dlb2_priv.h"
10 #include "dlb2_inline_fns.h"
11 
12 int
rte_pmd_dlb2_set_token_pop_mode(uint8_t dev_id,uint8_t port_id,enum dlb2_token_pop_mode mode)13 rte_pmd_dlb2_set_token_pop_mode(uint8_t dev_id,
14 				uint8_t port_id,
15 				enum dlb2_token_pop_mode mode)
16 {
17 	struct dlb2_eventdev *dlb2;
18 	struct rte_eventdev *dev;
19 
20 	RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
21 	dev = &rte_eventdevs[dev_id];
22 
23 	dlb2 = dlb2_pmd_priv(dev);
24 
25 	if (mode >= NUM_TOKEN_POP_MODES)
26 		return -EINVAL;
27 
28 	/* The event device must be configured, but not yet started */
29 	if (!dlb2->configured || dlb2->run_state != DLB2_RUN_STATE_STOPPED)
30 		return -EINVAL;
31 
32 	/* The token pop mode must be set before configuring the port */
33 	if (port_id >= dlb2->num_ports || dlb2->ev_ports[port_id].setup_done)
34 		return -EINVAL;
35 
36 	dlb2->ev_ports[port_id].qm_port.token_pop_mode = mode;
37 
38 	return 0;
39 }
40