aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2020-09-11 14:11:11 +0200
committerAndrew Yourtchenko <ayourtch@gmail.com>2020-09-16 11:14:42 +0000
commit97109b1ad8548d04f149c516297c36314227e8c6 (patch)
tree647bbaeb9f404e32c852fccfba07b1d63f5d1e0d
parent6efd393965317d7c27fbd0a7f0046a7b29d37a9e (diff)
avf: add assert to ensure that adminq is used only from avf process
Type: improvement Change-Id: Ib64c9b8207776986656e5a26c13a221edc6cc950 Signed-off-by: Damjan Marion <damarion@cisco.com> (cherry picked from commit 698eeb126d01427313949241b961c27347db8c72)
-rw-r--r--src/plugins/avf/device.c5
-rw-r--r--src/vlib/node_funcs.h7
2 files changed, 12 insertions, 0 deletions
diff --git a/src/plugins/avf/device.c b/src/plugins/avf/device.c
index 62a18cc3c5c..8a7d74abc74 100644
--- a/src/plugins/avf/device.c
+++ b/src/plugins/avf/device.c
@@ -399,6 +399,11 @@ avf_send_to_pf (vlib_main_t * vm, avf_device_t * ad, virtchnl_ops_t op,
u32 head;
f64 t0, suspend_time = AVF_SEND_TO_PF_SUSPEND_TIME;
+ /* adminq operations should be only done from process node after device
+ * is initialized */
+ ASSERT ((ad->flags & AVF_DEVICE_F_INITIALIZED) == 0 ||
+ vlib_get_current_process_node_index (vm) == avf_process_node.index);
+
/* suppress interrupt in the next adminq receive slot
as we are going to wait for response
we only need interrupts when event is received */
diff --git a/src/vlib/node_funcs.h b/src/vlib/node_funcs.h
index dfeba17ab09..33bdc795816 100644
--- a/src/vlib/node_funcs.h
+++ b/src/vlib/node_funcs.h
@@ -455,6 +455,13 @@ vlib_current_process (vlib_main_t * vm)
return vlib_get_current_process (vm)->node_runtime.node_index;
}
+always_inline u32
+vlib_get_current_process_node_index (vlib_main_t * vm)
+{
+ vlib_process_t *process = vlib_get_current_process (vm);
+ return process->node_runtime.node_index;
+}
+
/** Returns TRUE if a process suspend time is less than 10us
@param dt - remaining poll time in seconds
@returns 1 if dt < 10e-6, 0 otherwise