dev: add helper functions 95/41695/2
authorDamjan Marion <damarion@cisco.com>
Tue, 8 Oct 2024 21:14:49 +0000 (23:14 +0200)
committerFlorin Coras <florin.coras@gmail.com>
Tue, 8 Oct 2024 23:33:02 +0000 (23:33 +0000)
Type: improvement
Change-Id: I7c9e882b1cdf141b34e84dbfed46b392624d1f62
Signed-off-by: Damjan Marion <damarion@cisco.com>
src/plugins/dev_ena/rx_node.c
src/plugins/dev_iavf/port.c
src/plugins/dev_iavf/rx_node.c
src/vnet/dev/dev_funcs.h
src/vnet/dev/port.c

index 41fc5b8..51c6dbc 100644 (file)
@@ -251,7 +251,6 @@ ena_device_input_inline (vlib_main_t *vm, vlib_node_runtime_t *node,
                         vnet_dev_rx_queue_t *rxq)
 {
   ena_rxq_t *q = vnet_dev_get_rx_queue_data (rxq);
-  vnet_dev_port_t *port = rxq->port;
   vnet_main_t *vnm = vnet_get_main ();
   vlib_buffer_t *buffers[VLIB_FRAME_SIZE], **b;
   ena_rx_cdesc_status_t statuses[VLIB_FRAME_SIZE + 8];
@@ -260,13 +259,13 @@ ena_device_input_inline (vlib_main_t *vm, vlib_node_runtime_t *node,
   u16 *csi;
   uword n_rx_packets = 0, n_rx_bytes = 0;
   vlib_frame_bitmap_t head_bmp = {};
-  u32 sw_if_index = port->intf.sw_if_index;
-  u32 hw_if_index = port->intf.hw_if_index;
+  u32 sw_if_index = vnet_dev_get_rx_queue_if_sw_if_index (rxq);
+  u32 hw_if_index = vnet_dev_get_rx_queue_if_hw_if_index (rxq);
   u32 n_trace, n_deq, n_left;
   u32 cq_next = q->cq_next;
-  u32 next_index = rxq->next_index;
+  u32 next_index = vnet_dev_get_rx_queue_if_next_index (rxq);
   vlib_frame_t *next_frame;
-  vlib_buffer_template_t bt = rxq->buffer_template;
+  vlib_buffer_template_t bt = vnet_dev_get_rx_queue_if_buffer_template (rxq);
   u32 *bi;
   int maybe_chained;
 
index f1578fc..54f5f1d 100644 (file)
@@ -263,7 +263,7 @@ avf_msix_n_handler (vlib_main_t *vm, vnet_dev_t *dev, u16 line)
 
   iavf_reg_write (ad, IAVF_VFINT_DYN_CTLN (line), dyn_ctln_enabled.as_u32);
   vlib_node_set_interrupt_pending (vlib_get_main_by_index (line),
-                                  port->intf.rx_node_index);
+                                  vnet_dev_get_port_rx_node_idex (port));
 }
 
 vnet_dev_rv_t
index ee6d7e8..bf650f9 100644 (file)
@@ -249,14 +249,14 @@ iavf_device_input_inline (vlib_main_t *vm, vlib_node_runtime_t *node,
   u32 thr_idx = vlib_get_thread_index ();
   iavf_rt_data_t *rtd = vnet_dev_get_rt_temp_space (vm);
   iavf_rxq_t *arq = vnet_dev_get_rx_queue_data (rxq);
-  vlib_buffer_template_t bt = rxq->buffer_template;
+  vlib_buffer_template_t bt = vnet_dev_get_rx_queue_if_buffer_template (rxq);
   u32 n_trace, n_rx_packets = 0, n_rx_bytes = 0;
   u16 n_tail_desc = 0;
   u64 or_qw1 = 0;
   u32 *bi, *to_next, n_left_to_next;
-  u32 next_index = rxq->next_index;
-  u32 sw_if_index = port->intf.sw_if_index;
-  u32 hw_if_index = port->intf.hw_if_index;
+  u32 next_index = vnet_dev_get_rx_queue_if_next_index (rxq);
+  u32 sw_if_index = vnet_dev_get_rx_queue_if_sw_if_index (rxq);
+  u32 hw_if_index = vnet_dev_get_rx_queue_if_hw_if_index (rxq);
   u16 next = arq->next;
   u16 size = rxq->size;
   u16 mask = size - 1;
index 521157a..5a3cd00 100644 (file)
@@ -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)
 {
index df7805c..0ebe3c4 100644 (file)
@@ -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;
        }