blob: 8fcf7c336a86fa51e18c17fc7850218ae5a92afe [file] [log] [blame]
Damjan Marion1bd6cbb2021-04-15 13:12:51 +02001/* SPDX-License-Identifier: Apache-2.0
2 * Copyright(c) 2021 Cisco Systems, Inc.
3 */
4
5#include <vnet/vnet.h>
6
7/* funciton declarations */
8
9u32 vnet_hw_if_get_tx_queue_index_by_id (vnet_main_t *vnm, u32 hw_if_index,
10 u32 queue_id);
11u32 vnet_hw_if_register_tx_queue (vnet_main_t *vnm, u32 hw_if_index,
12 u32 queue_id);
13void vnet_hw_if_unregister_tx_queue (vnet_main_t *vnm, u32 queue_index);
14void vnet_hw_if_unregister_all_tx_queues (vnet_main_t *vnm, u32 hw_if_index);
15void vnet_hw_if_tx_queue_assign_thread (vnet_main_t *vnm, u32 queue_index,
16 u32 thread_index);
17void vnet_hw_if_tx_queue_unassign_thread (vnet_main_t *vnm, u32 queue_index,
18 u32 thread_index);
19
20/* inline functions */
21
22static_always_inline vnet_hw_if_tx_queue_t *
23vnet_hw_if_get_tx_queue (vnet_main_t *vnm, u32 queue_index)
24{
25 vnet_interface_main_t *im = &vnm->interface_main;
26 if (pool_is_free_index (im->hw_if_tx_queues, queue_index))
27 return 0;
28 return pool_elt_at_index (im->hw_if_tx_queues, queue_index);
29}
Mohsin Kazmi0d05c0d2021-11-09 17:44:10 +000030
31static_always_inline int
32vnet_hw_if_txq_cmp_cli_api (vnet_hw_if_tx_queue_t **a,
33 vnet_hw_if_tx_queue_t **b)
34{
35 if (*a == *b)
36 return 0;
37
38 if (a[0]->hw_if_index != b[0]->hw_if_index)
39 return 2 * (a[0]->hw_if_index > b[0]->hw_if_index) - 1;
40
41 if (a[0]->queue_id != b[0]->queue_id)
42 return 2 * (a[0]->queue_id > b[0]->queue_id) - 1;
43
44 ASSERT (0);
45 return ~0;
46}