X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvnet%2Fdevices%2Faf_packet%2Faf_packet.c;h=d0a241e2a2e912ea81d696d284afaa9702163ed5;hb=71612d61930e57e7c8ebf9e5647b15a4b23720b2;hp=e7e6921421bed0872f08a5d5e2ce910c564c2272;hpb=3b64d6334b4e8d0759cff043a55042f88d1ccb0e;p=vpp.git diff --git a/src/vnet/devices/af_packet/af_packet.c b/src/vnet/devices/af_packet/af_packet.c index e7e6921421b..d0a241e2a2e 100644 --- a/src/vnet/devices/af_packet/af_packet.c +++ b/src/vnet/devices/af_packet/af_packet.c @@ -24,14 +24,16 @@ #include #include +#include #include #include -#include #include #include #include +af_packet_main_t af_packet_main; + #define AF_PACKET_DEBUG_SOCKET 0 #define AF_PACKET_TX_FRAMES_PER_BLOCK 1024 @@ -75,7 +77,7 @@ af_packet_eth_flag_change (vnet_main_t * vnm, vnet_hw_interface_t * hi, { s = format (0, "/sys/class/net/%s/mtu%c", apif->host_if_name, 0); - error = vlib_sysfs_write ((char *) s, "%d", hi->max_packet_bytes); + error = clib_sysfs_write ((char *) s, "%d", hi->max_packet_bytes); vec_free (s); if (error) @@ -89,7 +91,7 @@ af_packet_eth_flag_change (vnet_main_t * vnm, vnet_hw_interface_t * hi, } static clib_error_t * -af_packet_fd_read_ready (unix_file_t * uf) +af_packet_fd_read_ready (clib_file_t * uf) { af_packet_main_t *apm = &af_packet_main; vnet_main_t *vnm = vnet_get_main (); @@ -281,12 +283,12 @@ af_packet_create_if (vlib_main_t * vm, u8 * host_if_name, u8 * hw_addr_set, clib_spinlock_init (&apif->lockp); { - unix_file_t template = { 0 }; + clib_file_t template = { 0 }; template.read_function = af_packet_fd_read_ready; template.file_descriptor = fd; template.private_data = if_index; template.flags = UNIX_FILE_EVENT_EDGE_TRIGGERED; - apif->unix_file_index = unix_file_add (&unix_main, &template); + apif->clib_file_index = clib_file_add (&file_main, &template); } /*use configured or generate random MAC address */ @@ -371,10 +373,10 @@ af_packet_delete_if (vlib_main_t * vm, u8 * host_if_name) vnet_hw_interface_unassign_rx_thread (vnm, apif->hw_if_index, 0); /* clean up */ - if (apif->unix_file_index != ~0) + if (apif->clib_file_index != ~0) { - unix_file_del (&unix_main, unix_main.file_pool + apif->unix_file_index); - apif->unix_file_index = ~0; + clib_file_del (&file_main, file_main.file_pool + apif->clib_file_index); + apif->clib_file_index = ~0; } else close (apif->fd); @@ -406,6 +408,22 @@ af_packet_delete_if (vlib_main_t * vm, u8 * host_if_name) return 0; } +int +af_packet_set_l4_cksum_offload (vlib_main_t * vm, u32 sw_if_index, u8 set) +{ + vnet_main_t *vnm = vnet_get_main (); + vnet_hw_interface_t *hw; + + hw = vnet_get_sup_hw_interface (vnm, sw_if_index); + + if (set) + hw->flags &= ~VNET_HW_INTERFACE_FLAG_SUPPORTS_TX_L4_CKSUM_OFFLOAD; + else + hw->flags |= VNET_HW_INTERFACE_FLAG_SUPPORTS_TX_L4_CKSUM_OFFLOAD; + + return 0; +} + static clib_error_t * af_packet_init (vlib_main_t * vm) {