summaryrefslogtreecommitdiffstats
path: root/src/vnet/devices/af_packet/af_packet_api.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/vnet/devices/af_packet/af_packet_api.c')
-rw-r--r--src/vnet/devices/af_packet/af_packet_api.c60
1 files changed, 60 insertions, 0 deletions
diff --git a/src/vnet/devices/af_packet/af_packet_api.c b/src/vnet/devices/af_packet/af_packet_api.c
index d991a2e6852..21f2c381809 100644
--- a/src/vnet/devices/af_packet/af_packet_api.c
+++ b/src/vnet/devices/af_packet/af_packet_api.c
@@ -94,6 +94,66 @@ vl_api_af_packet_create_v2_t_handler (vl_api_af_packet_create_v2_t *mp)
}
static void
+vl_api_af_packet_create_v3_t_handler (vl_api_af_packet_create_v3_t *mp)
+{
+ af_packet_create_if_arg_t _arg, *arg = &_arg;
+ vl_api_af_packet_create_v3_reply_t *rmp;
+ int rv = 0;
+
+ clib_memset (arg, 0, sizeof (*arg));
+
+ arg->host_if_name = format (0, "%s", mp->host_if_name);
+ vec_add1 (arg->host_if_name, 0);
+
+ // Default number of rx/tx queue(s)
+ arg->num_rxqs = 1;
+ arg->num_txqs = 1;
+ arg->rx_frame_size = clib_net_to_host_u32 (mp->rx_frame_size);
+ arg->tx_frame_size = clib_net_to_host_u32 (mp->tx_frame_size);
+ arg->rx_frames_per_block = clib_net_to_host_u32 (mp->rx_frames_per_block);
+ arg->tx_frames_per_block = clib_net_to_host_u32 (mp->tx_frames_per_block);
+ arg->hw_addr = mp->use_random_hw_addr ? 0 : mp->hw_addr;
+
+ switch (clib_net_to_host_u32 (mp->mode))
+ {
+ case AF_PACKET_API_MODE_ETHERNET:
+ arg->mode = AF_PACKET_IF_MODE_ETHERNET;
+ break;
+ case AF_PACKET_API_MODE_IP:
+ arg->mode = AF_PACKET_IF_MODE_IP;
+ break;
+ default:
+ arg->sw_if_index = ~0;
+ rv = VNET_ERR_INVALID_VALUE;
+ goto error;
+ }
+
+ STATIC_ASSERT (((int) AF_PACKET_API_FLAG_QDISC_BYPASS ==
+ (int) AF_PACKET_IF_FLAGS_QDISC_BYPASS),
+ "af-packet qdisc-bypass api flag mismatch");
+ STATIC_ASSERT (
+ ((int) AF_PACKET_API_FLAG_CKSUM_GSO == (int) AF_PACKET_IF_FLAGS_CKSUM_GSO),
+ "af-packet checksum/gso offload api flag mismatch");
+
+ // Default flags
+ arg->flags = clib_net_to_host_u32 (mp->flags);
+
+ if (clib_net_to_host_u16 (mp->num_rx_queues) > 1)
+ arg->num_rxqs = clib_net_to_host_u16 (mp->num_rx_queues);
+
+ if (clib_net_to_host_u16 (mp->num_tx_queues) > 1)
+ arg->num_txqs = clib_net_to_host_u16 (mp->num_tx_queues);
+
+ rv = af_packet_create_if (arg);
+
+error:
+ vec_free (arg->host_if_name);
+ REPLY_MACRO2 (VL_API_AF_PACKET_CREATE_V3_REPLY, ({
+ rmp->sw_if_index = clib_host_to_net_u32 (arg->sw_if_index);
+ }));
+}
+
+static void
vl_api_af_packet_delete_t_handler (vl_api_af_packet_delete_t * mp)
{
vl_api_af_packet_delete_reply_t *rmp;