summaryrefslogtreecommitdiffstats
path: root/src/vnet/devices/af_packet/device.c
diff options
context:
space:
mode:
authorMohsin KAZMI <sykazmi@cisco.com>2017-01-18 11:59:45 +0100
committerDamjan Marion <dmarion.lists@gmail.com>2017-01-19 11:00:11 +0000
commitcf751ec70df21affb19c77b2c51e3c231b8202ad (patch)
treee880e3fa0f7147ce609c0c3592596d120c2ab57f /src/vnet/devices/af_packet/device.c
parent07c39da547141f59b37a320cde5616ca652e7cff (diff)
af_packet: multithreading support
This patch adds multithreading support for af_packet interfaces. Change-Id: Ief5d1117e7ffeaa59dbc2831e583d5d8e8d4fa7a Signed-off-by: Mohsin KAZMI <sykazmi@cisco.com>
Diffstat (limited to 'src/vnet/devices/af_packet/device.c')
-rw-r--r--src/vnet/devices/af_packet/device.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/vnet/devices/af_packet/device.c b/src/vnet/devices/af_packet/device.c
index 1fb4000f6e6..e3bf9bbc51b 100644
--- a/src/vnet/devices/af_packet/device.c
+++ b/src/vnet/devices/af_packet/device.c
@@ -92,6 +92,12 @@ af_packet_interface_tx (vlib_main_t * vm,
struct tpacket2_hdr *tph;
u32 frame_not_ready = 0;
+ if (PREDICT_FALSE (apif->lockp != 0))
+ {
+ while (__sync_lock_test_and_set (apif->lockp, 1))
+ ;
+ }
+
while (n_left > 0)
{
u32 len;
@@ -152,6 +158,9 @@ af_packet_interface_tx (vlib_main_t * vm,
}
}
+ if (PREDICT_FALSE (apif->lockp != 0))
+ *apif->lockp = 0;
+
if (PREDICT_FALSE (frame_not_ready))
vlib_error_count (vm, node->node_index,
AF_PACKET_TX_ERROR_FRAME_NOT_READY, frame_not_ready);