Damjan Marion | 1bd6cbb | 2021-04-15 13:12:51 +0200 | [diff] [blame] | 1 | /* 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 | |
| 9 | u32 vnet_hw_if_get_tx_queue_index_by_id (vnet_main_t *vnm, u32 hw_if_index, |
| 10 | u32 queue_id); |
| 11 | u32 vnet_hw_if_register_tx_queue (vnet_main_t *vnm, u32 hw_if_index, |
| 12 | u32 queue_id); |
| 13 | void vnet_hw_if_unregister_tx_queue (vnet_main_t *vnm, u32 queue_index); |
| 14 | void vnet_hw_if_unregister_all_tx_queues (vnet_main_t *vnm, u32 hw_if_index); |
| 15 | void vnet_hw_if_tx_queue_assign_thread (vnet_main_t *vnm, u32 queue_index, |
| 16 | u32 thread_index); |
| 17 | void vnet_hw_if_tx_queue_unassign_thread (vnet_main_t *vnm, u32 queue_index, |
| 18 | u32 thread_index); |
| 19 | |
| 20 | /* inline functions */ |
| 21 | |
| 22 | static_always_inline vnet_hw_if_tx_queue_t * |
| 23 | vnet_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 Kazmi | 0d05c0d | 2021-11-09 17:44:10 +0000 | [diff] [blame] | 30 | |
| 31 | static_always_inline int |
| 32 | vnet_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 | } |