aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2022-01-04 20:15:59 +0100
committerOle Tr�an <otroan@employees.org>2022-01-05 10:42:58 +0000
commit70e808b1bfc25d1664ddb917457040b419e123c8 (patch)
treeb5d34b718052c905a91ac77656de8287d5c69f0a /src/plugins
parent7dc6f7fb497e9c9eac96057b2528fb072225a809 (diff)
dpdk: remove "convenience" vars
It is actually longer and slower... Type: refactor Change-Id: I0f126d4cdb13ecc60a2d370409f23820d7f7eb72 Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/dpdk/device/cli.c8
-rw-r--r--src/plugins/dpdk/device/common.c3
-rw-r--r--src/plugins/dpdk/device/device.c7
-rw-r--r--src/plugins/dpdk/device/dpdk.h3
-rw-r--r--src/plugins/dpdk/device/flow.c5
-rw-r--r--src/plugins/dpdk/device/format.c3
-rw-r--r--src/plugins/dpdk/device/init.c35
-rw-r--r--src/plugins/dpdk/main.c4
8 files changed, 29 insertions, 39 deletions
diff --git a/src/plugins/dpdk/device/cli.c b/src/plugins/dpdk/device/cli.c
index ba922e29a54..2487fc12252 100644
--- a/src/plugins/dpdk/device/cli.c
+++ b/src/plugins/dpdk/device/cli.c
@@ -265,6 +265,7 @@ set_dpdk_if_desc (vlib_main_t * vm, unformat_input_t * input,
{
unformat_input_t _line_input, *line_input = &_line_input;
dpdk_main_t *dm = &dpdk_main;
+ vnet_main_t *vnm = vnet_get_main ();
vnet_hw_interface_t *hw;
dpdk_device_t *xd;
u32 hw_if_index = (u32) ~ 0;
@@ -277,9 +278,8 @@ set_dpdk_if_desc (vlib_main_t * vm, unformat_input_t * input,
while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
{
- if (unformat
- (line_input, "%U", unformat_vnet_hw_interface, dm->vnet_main,
- &hw_if_index))
+ if (unformat (line_input, "%U", unformat_vnet_hw_interface, vnm,
+ &hw_if_index))
;
else if (unformat (line_input, "tx %d", &nb_tx_desc))
;
@@ -299,7 +299,7 @@ set_dpdk_if_desc (vlib_main_t * vm, unformat_input_t * input,
goto done;
}
- hw = vnet_get_hw_interface (dm->vnet_main, hw_if_index);
+ hw = vnet_get_hw_interface (vnm, hw_if_index);
xd = vec_elt_at_index (dm->devices, hw->dev_instance);
if ((xd->flags & DPDK_DEVICE_FLAG_PMD) == 0)
diff --git a/src/plugins/dpdk/device/common.c b/src/plugins/dpdk/device/common.c
index 89046d1a8c0..b3de5cf652c 100644
--- a/src/plugins/dpdk/device/common.c
+++ b/src/plugins/dpdk/device/common.c
@@ -41,7 +41,6 @@ dpdk_device_error (dpdk_device_t * xd, char *str, int rv)
void
dpdk_device_setup (dpdk_device_t * xd)
{
- dpdk_main_t *dm = &dpdk_main;
vlib_main_t *vm = vlib_get_main ();
vnet_main_t *vnm = vnet_get_main ();
vlib_thread_main_t *tm = vlib_get_thread_main ();
@@ -59,7 +58,7 @@ dpdk_device_setup (dpdk_device_t * xd)
if (xd->flags & DPDK_DEVICE_FLAG_ADMIN_UP)
{
- vnet_hw_interface_set_flags (dm->vnet_main, xd->hw_if_index, 0);
+ vnet_hw_interface_set_flags (vnm, xd->hw_if_index, 0);
dpdk_device_stop (xd);
}
diff --git a/src/plugins/dpdk/device/device.c b/src/plugins/dpdk/device/device.c
index 893dc41a488..336167b86f8 100644
--- a/src/plugins/dpdk/device/device.c
+++ b/src/plugins/dpdk/device/device.c
@@ -158,7 +158,6 @@ static_always_inline
dpdk_device_t * xd,
struct rte_mbuf **mb, u32 n_left)
{
- dpdk_main_t *dm = &dpdk_main;
dpdk_tx_queue_t *txq;
u32 n_retry;
int n_sent = 0;
@@ -189,7 +188,7 @@ static_always_inline
if (PREDICT_FALSE (n_sent < 0))
{
// emit non-fatal message, bump counter
- vnet_main_t *vnm = dm->vnet_main;
+ vnet_main_t *vnm = vnet_get_main ();
vnet_interface_main_t *im = &vnm->interface_main;
u32 node_index;
@@ -495,7 +494,7 @@ dpdk_interface_admin_up_down (vnet_main_t * vnm, u32 hw_if_index, u32 flags)
if (vec_len (xd->errors))
return clib_error_create ("Interface start failed");
xd->flags |= DPDK_DEVICE_FLAG_ADMIN_UP;
- f64 now = vlib_time_now (dm->vlib_main);
+ f64 now = vlib_time_now (vlib_get_main ());
dpdk_update_counters (xd, now);
dpdk_update_link_state (xd, now);
}
@@ -531,7 +530,7 @@ dpdk_set_interface_next_node (vnet_main_t * vnm, u32 hw_if_index,
}
xd->per_interface_next_index =
- vlib_node_add_next (xm->vlib_main, dpdk_input_node.index, node_index);
+ vlib_node_add_next (vlib_get_main (), dpdk_input_node.index, node_index);
}
diff --git a/src/plugins/dpdk/device/dpdk.h b/src/plugins/dpdk/device/dpdk.h
index cc7305dbdc4..64a2330a378 100644
--- a/src/plugins/dpdk/device/dpdk.h
+++ b/src/plugins/dpdk/device/dpdk.h
@@ -352,9 +352,6 @@ typedef struct
f64 link_state_poll_interval;
f64 stat_poll_interval;
- /* convenience */
- vlib_main_t *vlib_main;
- vnet_main_t *vnet_main;
dpdk_config_main_t *conf;
/* API message ID base */
diff --git a/src/plugins/dpdk/device/flow.c b/src/plugins/dpdk/device/flow.c
index 850476b87c1..19d504e5514 100644
--- a/src/plugins/dpdk/device/flow.c
+++ b/src/plugins/dpdk/device/flow.c
@@ -555,6 +555,7 @@ int
dpdk_flow_ops_fn (vnet_main_t * vnm, vnet_flow_dev_op_t op, u32 dev_instance,
u32 flow_index, uword * private_data)
{
+ vlib_main_t *vm = vlib_get_main ();
dpdk_main_t *dm = &dpdk_main;
vnet_flow_t *flow = vnet_get_flow (flow_index);
dpdk_device_t *xd = vec_elt_at_index (dm->devices, dev_instance);
@@ -565,7 +566,7 @@ dpdk_flow_ops_fn (vnet_main_t * vnm, vnet_flow_dev_op_t op, u32 dev_instance,
/* recycle old flow lookup entries only after the main loop counter
increases - i.e. previously DMA'ed packets were handled */
if (vec_len (xd->parked_lookup_indexes) > 0 &&
- xd->parked_loop_count != dm->vlib_main->main_loop_count)
+ xd->parked_loop_count != vm->main_loop_count)
{
u32 *fl_index;
@@ -588,7 +589,7 @@ dpdk_flow_ops_fn (vnet_main_t * vnm, vnet_flow_dev_op_t op, u32 dev_instance,
fle = pool_elt_at_index (xd->flow_lookup_entries, fe->mark);
clib_memset (fle, -1, sizeof (*fle));
vec_add1 (xd->parked_lookup_indexes, fe->mark);
- xd->parked_loop_count = dm->vlib_main->main_loop_count;
+ xd->parked_loop_count = vm->main_loop_count;
}
clib_memset (fe, 0, sizeof (*fe));
diff --git a/src/plugins/dpdk/device/format.c b/src/plugins/dpdk/device/format.c
index eb98730113d..430ab392594 100644
--- a/src/plugins/dpdk/device/format.c
+++ b/src/plugins/dpdk/device/format.c
@@ -555,9 +555,10 @@ format_dpdk_device (u8 * s, va_list * args)
u32 dev_instance = va_arg (*args, u32);
int verbose = va_arg (*args, int);
dpdk_main_t *dm = &dpdk_main;
+ vlib_main_t *vm = vlib_get_main ();
dpdk_device_t *xd = vec_elt_at_index (dm->devices, dev_instance);
u32 indent = format_get_indent (s);
- f64 now = vlib_time_now (dm->vlib_main);
+ f64 now = vlib_time_now (vm);
struct rte_eth_dev_info di;
struct rte_eth_burst_mode mode;
diff --git a/src/plugins/dpdk/device/init.c b/src/plugins/dpdk/device/init.c
index 04d6f89ac7b..3dbee38e960 100644
--- a/src/plugins/dpdk/device/init.c
+++ b/src/plugins/dpdk/device/init.c
@@ -204,6 +204,7 @@ dpdk_enable_l4_csum_offload (dpdk_device_t * xd)
static clib_error_t *
dpdk_lib_init (dpdk_main_t * dm)
{
+ vnet_main_t *vnm = vnet_get_main ();
u32 nports;
u32 mtu, max_rx_frame;
int i;
@@ -714,10 +715,9 @@ dpdk_lib_init (dpdk_main_t * dm)
/* assign interface to input thread */
int q;
- error = ethernet_register_interface
- (dm->vnet_main, dpdk_device_class.index, xd->device_index,
- /* ethernet address */ addr,
- &xd->hw_if_index, dpdk_flag_change);
+ error = ethernet_register_interface (
+ vnm, dpdk_device_class.index, xd->device_index,
+ /* ethernet address */ addr, &xd->hw_if_index, dpdk_flag_change);
if (error)
return error;
@@ -796,34 +796,33 @@ dpdk_lib_init (dpdk_main_t * dm)
/*Set port rxmode config */
xd->port_conf.rxmode.max_rx_pkt_len = max_rx_frame;
- sw = vnet_get_hw_sw_interface (dm->vnet_main, xd->hw_if_index);
+ sw = vnet_get_hw_sw_interface (vnm, xd->hw_if_index);
xd->sw_if_index = sw->sw_if_index;
- vnet_hw_if_set_input_node (dm->vnet_main, xd->hw_if_index,
- dpdk_input_node.index);
+ vnet_hw_if_set_input_node (vnm, xd->hw_if_index, dpdk_input_node.index);
if (devconf->workers)
{
- int i;
+ int j;
q = 0;
- clib_bitmap_foreach (i, devconf->workers) {
+ clib_bitmap_foreach (j, devconf->workers)
+ {
dpdk_rx_queue_t *rxq = vec_elt_at_index (xd->rx_queues, q);
rxq->queue_index = vnet_hw_if_register_rx_queue (
- dm->vnet_main, xd->hw_if_index, q++,
- vdm->first_worker_thread_index + i);
- }
+ vnm, xd->hw_if_index, q++, vdm->first_worker_thread_index + j);
+ }
}
else
for (q = 0; q < xd->rx_q_used; q++)
{
dpdk_rx_queue_t *rxq = vec_elt_at_index (xd->rx_queues, q);
rxq->queue_index = vnet_hw_if_register_rx_queue (
- dm->vnet_main, xd->hw_if_index, q, VNET_HW_IF_RXQ_THREAD_ANY);
+ vnm, xd->hw_if_index, q, VNET_HW_IF_RXQ_THREAD_ANY);
}
- vnet_hw_if_update_runtime_data (dm->vnet_main, xd->hw_if_index);
+ vnet_hw_if_update_runtime_data (vnm, xd->hw_if_index);
/*Get vnet hardware interface */
- hi = vnet_get_hw_interface (dm->vnet_main, xd->hw_if_index);
+ hi = vnet_get_hw_interface (vnm, xd->hw_if_index);
/*Override default max_packet_bytes and max_supported_bytes set in
* ethernet_register_interface() above*/
@@ -836,8 +835,8 @@ dpdk_lib_init (dpdk_main_t * dm)
/* Indicate ability to support L3 DMAC filtering and
* initialize interface to L3 non-promisc mode */
hi->caps |= VNET_HW_INTERFACE_CAP_SUPPORTS_MAC_FILTER;
- ethernet_set_flags (dm->vnet_main, xd->hw_if_index,
- ETHERNET_INTERFACE_FLAG_DEFAULT_L3);
+ ethernet_set_flags (vnm, xd->hw_if_index,
+ ETHERNET_INTERFACE_FLAG_DEFAULT_L3);
}
if (dm->conf->no_tx_checksum_offload == 0)
@@ -1938,8 +1937,6 @@ dpdk_init (vlib_main_t * vm)
dpdk_cli_reference ();
- dm->vlib_main = vm;
- dm->vnet_main = vnet_get_main ();
dm->conf = &dpdk_config_main;
vec_add1 (dm->conf->eal_init_args, (u8 *) "vnet");
diff --git a/src/plugins/dpdk/main.c b/src/plugins/dpdk/main.c
index 413a0f0df9d..ec0e8fb7ffe 100644
--- a/src/plugins/dpdk/main.c
+++ b/src/plugins/dpdk/main.c
@@ -79,12 +79,8 @@ rte_delay_us_override_cb (unsigned us)
static clib_error_t * dpdk_main_init (vlib_main_t * vm)
{
- dpdk_main_t * dm = &dpdk_main;
clib_error_t * error = 0;
- dm->vlib_main = vm;
- dm->vnet_main = vnet_get_main ();
-
/* register custom delay function */
rte_delay_us_callback_register (rte_delay_us_override_cb);