devices: add cli support for checksum and gso disable
Type: improvement
Signed-off-by: Mohsin Kazmi <sykazmi@cisco.com>
Change-Id: I33a29cf11998736347eca5016eee112619d847c1
diff --git a/src/vnet/devices/af_packet/af_packet.c b/src/vnet/devices/af_packet/af_packet.c
index a8ab944..fd2f6fc 100644
--- a/src/vnet/devices/af_packet/af_packet.c
+++ b/src/vnet/devices/af_packet/af_packet.c
@@ -191,7 +191,7 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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;