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