diff options
author | Damjan Marion <damarion@cisco.com> | 2024-10-08 23:14:49 +0200 |
---|---|---|
committer | Florin Coras <florin.coras@gmail.com> | 2024-10-08 23:33:02 +0000 |
commit | cda500bddc758da5b4289b259b7ac70bbb5f3039 (patch) | |
tree | fc5879193c42b50f071ae45890ae5fa4ed452450 /src/vnet/dev | |
parent | 623147bfdaf55ea14569209d14d429d675f56a5f (diff) |
dev: add helper functions
Type: improvement
Change-Id: I7c9e882b1cdf141b34e84dbfed46b392624d1f62
Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/vnet/dev')
-rw-r--r-- | src/vnet/dev/dev_funcs.h | 40 | ||||
-rw-r--r-- | src/vnet/dev/port.c | 2 |
2 files changed, 33 insertions, 9 deletions
diff --git a/src/vnet/dev/dev_funcs.h b/src/vnet/dev/dev_funcs.h index 521157abbec..5a3cd00ec88 100644 --- a/src/vnet/dev/dev_funcs.h +++ b/src/vnet/dev/dev_funcs.h @@ -74,6 +74,24 @@ vnet_dev_get_port_from_hw_if_index (u32 hw_if_index) return port; } +static_always_inline u32 +vnet_dev_get_rx_queue_if_sw_if_index (vnet_dev_rx_queue_t *rxq) +{ + return rxq->port->intf.sw_if_index; +} + +static_always_inline u32 +vnet_dev_get_rx_queue_if_hw_if_index (vnet_dev_rx_queue_t *rxq) +{ + return rxq->port->intf.hw_if_index; +} + +static_always_inline u32 +vnet_dev_get_port_rx_node_idex (vnet_dev_port_t *port) +{ + return port->intf.rx_node_index; +} + static_always_inline vnet_dev_t * vnet_dev_by_index (u32 index) { @@ -128,12 +146,6 @@ vnet_dev_port_validate (vlib_main_t *vm, vnet_dev_port_t *port) ASSERT (vm->thread_index == 0); } -static_always_inline u32 -vnet_dev_port_get_sw_if_index (vnet_dev_port_t *port) -{ - return port->intf.sw_if_index; -} - static_always_inline vnet_dev_port_t * vnet_dev_get_port_by_id (vnet_dev_t *dev, vnet_dev_port_id_t port_id) { @@ -144,7 +156,7 @@ vnet_dev_get_port_by_id (vnet_dev_t *dev, vnet_dev_port_id_t port_id) } static_always_inline vnet_dev_rx_queue_t * -vnet_dev_port_get_rx_queue_by_id (vnet_dev_port_t *port, +vnet_dev_get_port_rx_queue_by_id (vnet_dev_port_t *port, vnet_dev_queue_id_t queue_id) { foreach_vnet_dev_port_rx_queue (q, port) @@ -154,7 +166,7 @@ vnet_dev_port_get_rx_queue_by_id (vnet_dev_port_t *port, } static_always_inline vnet_dev_tx_queue_t * -vnet_dev_port_get_tx_queue_by_id (vnet_dev_port_t *port, +vnet_dev_get_port_tx_queue_by_id (vnet_dev_port_t *port, vnet_dev_queue_id_t queue_id) { foreach_vnet_dev_port_tx_queue (q, port) @@ -199,6 +211,18 @@ vnet_dev_tx_queue_unlock_if_needed (vnet_dev_tx_queue_t *txq) __atomic_store_n (&txq->lock, 0, __ATOMIC_RELEASE); } +static_always_inline vlib_buffer_template_t +vnet_dev_get_rx_queue_if_buffer_template (vnet_dev_rx_queue_t *rxq) +{ + return rxq->buffer_template; +} + +static_always_inline u16 +vnet_dev_get_rx_queue_if_next_index (vnet_dev_rx_queue_t *rxq) +{ + return rxq->next_index; +} + static_always_inline u8 vnet_dev_get_rx_queue_buffer_pool_index (vnet_dev_rx_queue_t *rxq) { diff --git a/src/vnet/dev/port.c b/src/vnet/dev/port.c index df7805c1ff2..0ebe3c4690d 100644 --- a/src/vnet/dev/port.c +++ b/src/vnet/dev/port.c @@ -371,7 +371,7 @@ vnet_dev_port_cfg_change (vlib_main_t *vm, vnet_dev_port_t *port, { if (req->all_queues == 0) { - rxq = vnet_dev_port_get_rx_queue_by_id (port, req->queue_id); + rxq = vnet_dev_get_port_rx_queue_by_id (port, req->queue_id); if (rxq == 0) return VNET_DEV_ERR_BUG; } |