From 788676b211cf5a3e54bac1f564f069941562437e Mon Sep 17 00:00:00 2001 From: Mohsin Kazmi Date: Tue, 5 Apr 2022 12:43:13 +0000 Subject: devices: add cli support for checksum and gso disable Type: improvement Signed-off-by: Mohsin Kazmi Change-Id: I33a29cf11998736347eca5016eee112619d847c1 --- src/vnet/devices/af_packet/af_packet.c | 36 +++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 16 deletions(-) (limited to 'src/vnet/devices/af_packet/af_packet.c') diff --git a/src/vnet/devices/af_packet/af_packet.c b/src/vnet/devices/af_packet/af_packet.c index a8ab944a513..fd2f6fc9a57 100644 --- a/src/vnet/devices/af_packet/af_packet.c +++ b/src/vnet/devices/af_packet/af_packet.c @@ -191,7 +191,7 @@ af_packet_set_tx_queues (vlib_main_t *vm, af_packet_if_t *apif) static int create_packet_v3_sock (int host_if_index, tpacket_req3_t *rx_req, tpacket_req3_t *tx_req, int *fd, af_packet_ring_t *ring, - u8 *is_cksum_gso_enabled, u32 fanout_id, u8 is_fanout, + u32 fanout_id, u8 is_fanout, af_packet_if_flags_t *flags) { af_packet_main_t *apm = &af_packet_main; @@ -250,16 +250,21 @@ create_packet_v3_sock (int host_if_index, tpacket_req3_t *rx_req, goto error; } - int opt2 = 1; - if (setsockopt (*fd, SOL_PACKET, PACKET_VNET_HDR, &opt2, sizeof (opt2)) < 0) + if (*flags & AF_PACKET_IF_FLAGS_CKSUM_GSO) { - vlib_log_debug ( - apm->log_class, - "Failed to set packet vnet hdr error handling option: %s (errno %d)", - strerror (errno), errno); + + int opt2 = 1; + if (setsockopt (*fd, SOL_PACKET, PACKET_VNET_HDR, &opt2, sizeof (opt2)) < + 0) + { + // remove the flag + *flags &= ~AF_PACKET_IF_FLAGS_CKSUM_GSO; + vlib_log_debug (apm->log_class, + "Failed to set packet vnet hdr error handling " + "option: %s (errno %d)", + strerror (errno), errno); + } } - else - *is_cksum_gso_enabled = 1; #if defined(PACKET_QDISC_BYPASS) if (*flags & AF_PACKET_IF_FLAGS_QDISC_BYPASS) @@ -347,7 +352,6 @@ af_packet_queue_init (vlib_main_t *vm, af_packet_if_t *apif, u32 rx_frames_per_block, tx_frames_per_block; u32 rx_frame_size, tx_frame_size; u32 i = 0; - u8 is_cksum_gso_enabled = 0; if (rx_queue) { @@ -391,9 +395,9 @@ af_packet_queue_init (vlib_main_t *vm, af_packet_if_t *apif, if (rx_queue || tx_queue) { - ret = create_packet_v3_sock (apif->host_if_index, rx_req, tx_req, &fd, - &ring, &is_cksum_gso_enabled, - apif->dev_instance, is_fanout, &arg->flags); + ret = + create_packet_v3_sock (apif->host_if_index, rx_req, tx_req, &fd, &ring, + apif->dev_instance, is_fanout, &arg->flags); if (ret != 0) goto error; @@ -434,9 +438,6 @@ af_packet_queue_init (vlib_main_t *vm, af_packet_if_t *apif, clib_spinlock_init (&tx_queue->lockp); } - if (queue_id == 0) - apif->is_cksum_gso_enabled = is_cksum_gso_enabled; - return 0; error: vlib_log_err (apm->log_class, "Failed to set queue %u error", queue_id); @@ -648,6 +649,9 @@ af_packet_create_if (af_packet_create_if_arg_t *arg) apif->is_qdisc_bypass_enabled = (arg->flags & AF_PACKET_IF_FLAGS_QDISC_BYPASS); + if (arg->flags & AF_PACKET_IF_FLAGS_CKSUM_GSO) + apif->is_cksum_gso_enabled = 1; + if (apif->is_cksum_gso_enabled) caps |= VNET_HW_IF_CAP_TCP_GSO | VNET_HW_IF_CAP_TX_IP4_CKSUM | VNET_HW_IF_CAP_TX_TCP_CKSUM | VNET_HW_IF_CAP_TX_UDP_CKSUM; -- cgit 1.2.3-korg