From 676554935a576db9f512b8b2ef81ba6723bb7ad6 Mon Sep 17 00:00:00 2001 From: Damjan Marion Date: Tue, 15 Nov 2016 12:50:28 +0100 Subject: dpdk: remove rte_mbuf modifications at many places in the code It is sole responsibility of dpdk tx function to fill/update rte_mbuf prior to sending packet do PMD. Change-Id: I8ca1dba3e7bef41034d36e3525831849f7ac4ac0 Signed-off-by: Damjan Marion --- vnet/vnet/buffer.h | 3 ++ vnet/vnet/devices/af_packet/node.c | 16 ----------- vnet/vnet/devices/netmap/node.c | 16 ----------- vnet/vnet/devices/ssvm/node.c | 4 --- vnet/vnet/devices/ssvm/ssvm_eth.h | 1 + vnet/vnet/devices/virtio/vhost-user.h | 4 --- vnet/vnet/ip/ip.h | 35 ----------------------- vnet/vnet/ip/ip6_forward.c | 30 -------------------- vnet/vnet/ip/ip6_neighbor.c | 12 -------- vnet/vnet/ipsec/esp.h | 3 -- vnet/vnet/ipsec/ipsec.h | 17 ++---------- vnet/vnet/l2/l2_output.c | 6 ---- vnet/vnet/pg/input.c | 52 ----------------------------------- vnet/vnet/unix/tapcli.c | 7 ----- vnet/vnet/unix/tuntap.c | 40 +-------------------------- 15 files changed, 7 insertions(+), 239 deletions(-) (limited to 'vnet') diff --git a/vnet/vnet/buffer.h b/vnet/vnet/buffer.h index d3ad86442cd..2ae4f1ccb70 100644 --- a/vnet/vnet/buffer.h +++ b/vnet/vnet/buffer.h @@ -67,6 +67,9 @@ #define LOG2_BUFFER_HANDOFF_NEXT_VALID LOG2_VLIB_BUFFER_FLAG_USER(6) #define BUFFER_HANDOFF_NEXT_VALID (1 << LOG2_BUFFER_HANDOFF_NEXT_VALID) +#define LOG2_VNET_BUFFER_RTE_MBUF_IS_VALID LOG2_VLIB_BUFFER_FLAG_USER(7) +#define VNET_BUFFER_RTE_MBUF_IS_VALID (1 << LOG2_VNET_BUFFER_RTE_MBUF_IS_VALID) + #define foreach_buffer_opaque_union_subtype \ _(ethernet) \ _(ip) \ diff --git a/vnet/vnet/devices/af_packet/node.c b/vnet/vnet/devices/af_packet/node.c index 083c5581c2d..72004320c67 100644 --- a/vnet/vnet/devices/af_packet/node.c +++ b/vnet/vnet/devices/af_packet/node.c @@ -104,17 +104,6 @@ buffer_add_to_chain (vlib_main_t * vm, u32 bi, u32 first_bi, u32 prev_bi) /* update current buffer */ b->next_buffer = 0; - -#if DPDK > 0 - struct rte_mbuf *mbuf = rte_mbuf_from_vlib_buffer (b); - struct rte_mbuf *first_mbuf = rte_mbuf_from_vlib_buffer (first_b); - struct rte_mbuf *prev_mbuf = rte_mbuf_from_vlib_buffer (prev_b); - first_mbuf->nb_segs++; - prev_mbuf->next = mbuf; - mbuf->data_len = b->current_length; - mbuf->data_off = RTE_PKTMBUF_HEADROOM + b->current_data; - mbuf->next = 0; -#endif } always_inline uword @@ -194,11 +183,6 @@ af_packet_device_input_fn (vlib_main_t * vm, vlib_node_runtime_t * node, if (offset == 0) { -#if DPDK > 0 - struct rte_mbuf *mb = rte_mbuf_from_vlib_buffer (b0); - rte_pktmbuf_data_len (mb) = b0->current_length; - rte_pktmbuf_pkt_len (mb) = b0->current_length; -#endif b0->total_length_not_including_first_buffer = 0; b0->flags = VLIB_BUFFER_TOTAL_LENGTH_VALID; vnet_buffer (b0)->sw_if_index[VLIB_RX] = apif->sw_if_index; diff --git a/vnet/vnet/devices/netmap/node.c b/vnet/vnet/devices/netmap/node.c index b96bada5f37..19895e4754a 100644 --- a/vnet/vnet/devices/netmap/node.c +++ b/vnet/vnet/devices/netmap/node.c @@ -83,17 +83,6 @@ buffer_add_to_chain (vlib_main_t * vm, u32 bi, u32 first_bi, u32 prev_bi) /* update current buffer */ b->next_buffer = 0; - -#if DPDK > 0 - struct rte_mbuf *mbuf = rte_mbuf_from_vlib_buffer (b); - struct rte_mbuf *first_mbuf = rte_mbuf_from_vlib_buffer (first_b); - struct rte_mbuf *prev_mbuf = rte_mbuf_from_vlib_buffer (prev_b); - first_mbuf->nb_segs++; - prev_mbuf->next = mbuf; - mbuf->data_len = b->current_length; - mbuf->data_off = RTE_PKTMBUF_HEADROOM + b->current_data; - mbuf->next = 0; -#endif } always_inline uword @@ -195,11 +184,6 @@ netmap_device_input_fn (vlib_main_t * vm, vlib_node_runtime_t * node, if (offset == 0) { -#if DPDK > 0 - struct rte_mbuf *mb = rte_mbuf_from_vlib_buffer (b0); - rte_pktmbuf_data_len (mb) = b0->current_length; - rte_pktmbuf_pkt_len (mb) = b0->current_length; -#endif b0->total_length_not_including_first_buffer = 0; b0->flags = VLIB_BUFFER_TOTAL_LENGTH_VALID; vnet_buffer (b0)->sw_if_index[VLIB_RX] = diff --git a/vnet/vnet/devices/ssvm/node.c b/vnet/vnet/devices/ssvm/node.c index 5ecccd376c0..3a695b1d8c0 100644 --- a/vnet/vnet/devices/ssvm/node.c +++ b/vnet/vnet/devices/ssvm/node.c @@ -77,11 +77,7 @@ ssvm_eth_device_input (ssvm_eth_main_t * em, int rx_queue_index; u32 n_to_alloc = VLIB_FRAME_SIZE * 2; u32 n_allocated, n_present_in_cache; -#if DPDK > 0 u32 next_index = VNET_DEVICE_INPUT_NEXT_ETHERNET_INPUT; -#else - u32 next_index = 0; -#endif vlib_buffer_free_list_t *fl; u32 n_left_to_next, *to_next; u32 next0; diff --git a/vnet/vnet/devices/ssvm/ssvm_eth.h b/vnet/vnet/devices/ssvm/ssvm_eth.h index f4156e3ae70..ac611f4edb6 100644 --- a/vnet/vnet/devices/ssvm/ssvm_eth.h +++ b/vnet/vnet/devices/ssvm/ssvm_eth.h @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include diff --git a/vnet/vnet/devices/virtio/vhost-user.h b/vnet/vnet/devices/virtio/vhost-user.h index 0495991d02c..4ce0830963f 100644 --- a/vnet/vnet/devices/virtio/vhost-user.h +++ b/vnet/vnet/devices/virtio/vhost-user.h @@ -32,10 +32,6 @@ #define VHOST_VRING_F_LOG 0 #define VHOST_USER_F_PROTOCOL_FEATURES 30 -#if DPDK == 0 -#define RTE_VERSION_NUM(a,b,c,d) 1 -#define RTE_VERSION 0 -#endif #define VHOST_USER_PROTOCOL_FEATURES ((1ULL << VHOST_USER_PROTOCOL_F_MQ) | \ (1ULL << VHOST_USER_PROTOCOL_F_LOG_SHMFD)) diff --git a/vnet/vnet/ip/ip.h b/vnet/vnet/ip/ip.h index c9a82930a67..f50662b2acf 100644 --- a/vnet/vnet/ip/ip.h +++ b/vnet/vnet/ip/ip.h @@ -63,11 +63,6 @@ #include #include #include - -#if DPDK > 0 -#include -#endif - #include /* Per protocol info. */ @@ -155,35 +150,6 @@ ip_incremental_checksum_buffer (vlib_main_t * vm, vlib_buffer_t * first_buffer, u32 first_buffer_offset, u32 n_bytes_to_checksum, ip_csum_t sum) -#if DPDK > 0 -{ - u32 n_bytes_left = n_bytes_to_checksum; - struct rte_mbuf * mb = rte_mbuf_from_vlib_buffer(first_buffer); - u8 nb_segs = mb->nb_segs; - ASSERT(mb->data_len >= first_buffer_offset); - void * h; - u32 n; - - n = clib_min (n_bytes_left, mb->data_len); - h = vlib_buffer_get_current (first_buffer) + first_buffer_offset; - while (n_bytes_left) - { - sum = ip_incremental_checksum (sum, h, n); - n_bytes_left -= n; - nb_segs--; - mb = mb->next; - if ((nb_segs == 0) || (mb == 0)) - break; - - n = clib_min (n_bytes_left, mb->data_len); - h = rte_ctrlmbuf_data(mb); - } - - ASSERT(n_bytes_left == 0); - ASSERT(nb_segs == 0); - return sum; -} -#else { vlib_buffer_t * b = first_buffer; u32 n_bytes_left = n_bytes_to_checksum; @@ -210,7 +176,6 @@ ip_incremental_checksum_buffer (vlib_main_t * vm, vlib_buffer_t * first_buffer, return sum; } -#endif /* DPDK */ void ip_del_all_interface_addresses (vlib_main_t *vm, u32 sw_if_index); diff --git a/vnet/vnet/ip/ip6_forward.c b/vnet/vnet/ip/ip6_forward.c index 14dd9dfbdf0..f3cd640a841 100644 --- a/vnet/vnet/ip/ip6_forward.c +++ b/vnet/vnet/ip/ip6_forward.c @@ -1177,35 +1177,6 @@ u16 ip6_tcp_udp_icmp_compute_checksum (vlib_main_t * vm, vlib_buffer_t * p0, ip6 } n_bytes_left = n_this_buffer = payload_length_host_byte_order; -#if DPDK > 0 - if (p0 && n_this_buffer + headers_size > p0->current_length) - { - struct rte_mbuf *mb = rte_mbuf_from_vlib_buffer(p0); - u8 nb_segs = mb->nb_segs; - - n_this_buffer = (p0->current_length > headers_size ? - p0->current_length - headers_size : 0); - while (n_bytes_left) - { - sum0 = ip_incremental_checksum (sum0, data_this_buffer, n_this_buffer); - n_bytes_left -= n_this_buffer; - - mb = mb->next; - nb_segs--; - if ((nb_segs == 0) || (mb == 0)) - break; - - data_this_buffer = rte_ctrlmbuf_data(mb); - n_this_buffer = mb->data_len; - } - if (n_bytes_left || nb_segs) - { - *bogus_lengthp = 1; - return 0xfefe; - } - } - else sum0 = ip_incremental_checksum (sum0, data_this_buffer, n_this_buffer); -#else if (p0 && n_this_buffer + headers_size > p0->current_length) n_this_buffer = p0->current_length > headers_size ? p0->current_length - headers_size : 0; while (1) @@ -1224,7 +1195,6 @@ u16 ip6_tcp_udp_icmp_compute_checksum (vlib_main_t * vm, vlib_buffer_t * p0, ip6 data_this_buffer = vlib_buffer_get_current (p0); n_this_buffer = p0->current_length; } -#endif /* DPDK */ sum16 = ~ ip_csum_fold (sum0); diff --git a/vnet/vnet/ip/ip6_neighbor.c b/vnet/vnet/ip/ip6_neighbor.c index af852a2be86..cc176306969 100644 --- a/vnet/vnet/ip/ip6_neighbor.c +++ b/vnet/vnet/ip/ip6_neighbor.c @@ -23,10 +23,6 @@ #include #include -#if DPDK==1 -#include -#endif - /** * @file * @brief IPv6 Neighbor Adjacency and Neighbor Discovery. @@ -317,7 +313,6 @@ typedef struct { ip6_address_t addr; } ip6_neighbor_set_unset_rpc_args_t; -#if DPDK > 0 static void ip6_neighbor_set_unset_rpc_callback ( ip6_neighbor_set_unset_rpc_args_t * a); @@ -340,7 +335,6 @@ static void set_unset_ip6_neighbor_rpc vl_api_rpc_call_main_thread (ip6_neighbor_set_unset_rpc_callback, (u8 *) &args, sizeof (args)); } -#endif static void ip6_nbr_probe (ip_adjacency_t *adj) @@ -538,14 +532,12 @@ vnet_set_ip6_ethernet_neighbor (vlib_main_t * vm, u32 next_index; pending_resolution_t * pr, * mc; -#if DPDK > 0 if (os_get_cpu_number()) { set_unset_ip6_neighbor_rpc (vm, sw_if_index, a, link_layer_address, 1 /* set new neighbor */, is_static); return 0; } -#endif k.sw_if_index = sw_if_index; k.ip6_address = a[0]; @@ -687,14 +679,12 @@ vnet_unset_ip6_ethernet_neighbor (vlib_main_t * vm, uword * p; int rv = 0; -#if DPDK > 0 if (os_get_cpu_number()) { set_unset_ip6_neighbor_rpc (vm, sw_if_index, a, link_layer_address, 0 /* unset */, 0); return 0; } -#endif k.sw_if_index = sw_if_index; k.ip6_address = a[0]; @@ -722,7 +712,6 @@ vnet_unset_ip6_ethernet_neighbor (vlib_main_t * vm, return rv; } -#if DPDK > 0 static void ip6_neighbor_set_unset_rpc_callback ( ip6_neighbor_set_unset_rpc_args_t * a) { @@ -734,7 +723,6 @@ static void ip6_neighbor_set_unset_rpc_callback vnet_unset_ip6_ethernet_neighbor (vm, a->sw_if_index, &a->addr, a->link_layer_address, 6); } -#endif static int ip6_neighbor_sort (void *a1, void *a2) diff --git a/vnet/vnet/ipsec/esp.h b/vnet/vnet/ipsec/esp.h index 505d34ad859..b9feacbb322 100644 --- a/vnet/vnet/ipsec/esp.h +++ b/vnet/vnet/ipsec/esp.h @@ -12,9 +12,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#if DPDK==1 -#include -#endif #include #include diff --git a/vnet/vnet/ipsec/ipsec.h b/vnet/vnet/ipsec/ipsec.h index dbbb928fc30..d33df383669 100644 --- a/vnet/vnet/ipsec/ipsec.h +++ b/vnet/vnet/ipsec/ipsec.h @@ -12,10 +12,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#if DPDK==1 -#include -#endif - #define IPSEC_FLAG_IPSEC_GRE_TUNNEL (1 << 0) #define foreach_ipsec_policy_action \ @@ -280,12 +276,6 @@ int ipsec_set_interface_key (vnet_main_t * vnm, u32 hw_if_index, always_inline void ipsec_alloc_empty_buffers (vlib_main_t * vm, ipsec_main_t * im) { -#if DPDK==1 - dpdk_main_t *dm = &dpdk_main; - u32 free_list_index = dm->vlib_buffer_free_list_index; -#else - u32 free_list_index = VLIB_BUFFER_DEFAULT_FREE_LIST_INDEX; -#endif u32 cpu_index = os_get_cpu_number (); uword l = vec_len (im->empty_buffers[cpu_index]); uword n_alloc = 0; @@ -297,11 +287,8 @@ ipsec_alloc_empty_buffers (vlib_main_t * vm, ipsec_main_t * im) vec_alloc (im->empty_buffers[cpu_index], 2 * VLIB_FRAME_SIZE); } - n_alloc = vlib_buffer_alloc_from_free_list (vm, - im->empty_buffers[cpu_index] - + l, - 2 * VLIB_FRAME_SIZE - l, - free_list_index); + n_alloc = vlib_buffer_alloc (vm, im->empty_buffers[cpu_index] + l, + 2 * VLIB_FRAME_SIZE - l); _vec_len (im->empty_buffers[cpu_index]) = l + n_alloc; } diff --git a/vnet/vnet/l2/l2_output.c b/vnet/vnet/l2/l2_output.c index f8ebe146000..22ce663b899 100644 --- a/vnet/vnet/l2/l2_output.c +++ b/vnet/vnet/l2/l2_output.c @@ -614,7 +614,6 @@ typedef struct u32 sw_if_index; } output_node_mapping_rpc_args_t; -#if DPDK > 0 static void output_node_rpc_callback (output_node_mapping_rpc_args_t * a); static void @@ -629,7 +628,6 @@ output_node_mapping_send_rpc (u32 node_index, u32 sw_if_index) vl_api_rpc_call_main_thread (output_node_rpc_callback, (u8 *) & args, sizeof (args)); } -#endif /** Create a mapping in the next node mapping table for the given sw_if_index. */ @@ -645,7 +643,6 @@ l2output_create_output_node_mapping (vlib_main_t * vlib_main, vnet_main_t * vnet hw0 = vnet_get_sup_hw_interface (vnet_main, sw_if_index); -#if DPDK > 0 uword cpu_number; cpu_number = os_get_cpu_number (); @@ -663,7 +660,6 @@ l2output_create_output_node_mapping (vlib_main_t * vlib_main, vnet_main_t * vnet output_node_mapping_send_rpc (node_index, sw_if_index); return L2OUTPUT_NEXT_DROP; } -#endif /* dynamically create graph node arc */ next = vlib_node_add_next (vlib_main, node_index, hw0->output_node_index); @@ -679,7 +675,6 @@ l2output_create_output_node_mapping (vlib_main_t * vlib_main, vnet_main_t * vnet return next; } -#if DPDK > 0 void output_node_rpc_callback (output_node_mapping_rpc_args_t * a) { @@ -691,7 +686,6 @@ output_node_rpc_callback (output_node_mapping_rpc_args_t * a) (vm, vnm, a->node_index, mp->next_nodes.output_node_index_vec, a->sw_if_index); } -#endif /* Get a pointer to the config for the given interface */ l2_output_config_t * diff --git a/vnet/vnet/pg/input.c b/vnet/vnet/pg/input.c index 54687d51190..77b56f528fc 100644 --- a/vnet/vnet/pg/input.c +++ b/vnet/vnet/pg/input.c @@ -43,39 +43,6 @@ #include #include -#if DPDK==1 -#include -#endif - -static inline void -pg_set_mbuf_metadata (pg_main_t * pg, u32 * buffers, u32 n_alloc) -{ -#if DPDK == 1 - vlib_main_t *vm = vlib_get_main (); - vlib_buffer_t *b; - struct rte_mbuf *mb; - i16 delta; - u16 new_data_len; - u16 new_pkt_len; - - int i; - - for (i = 0; i < n_alloc; i++) - { - b = vlib_get_buffer (vm, buffers[i]); - mb = rte_mbuf_from_vlib_buffer (b); - - delta = vlib_buffer_length_in_chain (vm, b) - (i16) mb->pkt_len; - new_data_len = (u16) ((i16) mb->data_len + delta); - new_pkt_len = (u16) ((i16) mb->pkt_len + delta); - - mb->data_len = new_data_len; - mb->pkt_len = new_pkt_len; - mb->data_off = (u16) ((RTE_PKTMBUF_HEADROOM) + b->current_data); - } -#endif -} - static int validate_buffer_data2 (vlib_buffer_t * b, pg_stream_t * s, u32 data_offset, u32 n_bytes) @@ -930,7 +897,6 @@ pg_generate_set_lengths (pg_main_t * pg, si->sw_if_index, n_buffers, length_sum); } - pg_set_mbuf_metadata (pg, buffers, n_buffers); } static void @@ -1398,24 +1364,6 @@ pg_stream_fill (pg_main_t * pg, pg_stream_t * s, u32 n_buffers) last_start = start; /* Verify that pkts in the fifo are properly allocated */ -#if DPDK == 1 - if (CLIB_DEBUG > 0) - { - u32 *bi0; - vlib_main_t *vm = vlib_get_main (); - /* *INDENT-OFF* */ - clib_fifo_foreach (bi0, bi->buffer_fifo, - ({ - vlib_buffer_t * b; - struct rte_mbuf *mb; - - b = vlib_get_buffer(vm, bi0[0]); - mb = rte_mbuf_from_vlib_buffer(b); - ASSERT(rte_mbuf_refcnt_read(mb) == 1); - })); - /* *INDENT-ON* */ - } -#endif } return n_in_fifo + n_added; diff --git a/vnet/vnet/unix/tapcli.c b/vnet/vnet/unix/tapcli.c index d23e6fea64f..db634f710fe 100644 --- a/vnet/vnet/unix/tapcli.c +++ b/vnet/vnet/unix/tapcli.c @@ -39,10 +39,6 @@ #include -#if DPDK == 1 -#include -#endif - #include #include #include @@ -343,9 +339,6 @@ static uword tapcli_rx_iface(vlib_main_t * vm, (n_bytes_in_packet > buffer_size) ? n_bytes_in_packet - buffer_size : 0; b_first->flags |= VLIB_BUFFER_TOTAL_LENGTH_VALID; - /* Ensure mbufs are updated */ - vlib_buffer_chain_validate(vm, b_first); - VLIB_BUFFER_TRACE_TRAJECTORY_INIT(b_first); vnet_buffer (b_first)->sw_if_index[VLIB_RX] = ti->sw_if_index; diff --git a/vnet/vnet/unix/tuntap.c b/vnet/vnet/unix/tuntap.c index dbb6f309045..4a5dd676a68 100644 --- a/vnet/vnet/unix/tuntap.c +++ b/vnet/vnet/unix/tuntap.c @@ -50,10 +50,6 @@ #include #include -#if DPDK == 1 -#include -#endif - static vnet_device_class_t tuntap_dev_class; static vnet_hw_interface_class_t tuntap_interface_class; @@ -233,13 +229,6 @@ tuntap_rx (vlib_main_t * vm, vlib_buffer_t * b; u32 bi; const uword buffer_size = VLIB_BUFFER_DATA_SIZE; -#if DPDK == 0 - u32 free_list_index = VLIB_BUFFER_DEFAULT_FREE_LIST_INDEX; -#else - dpdk_main_t * dm = &dpdk_main; - u32 free_list_index = dm->vlib_buffer_free_list_index; - struct rte_mbuf *first_mb = NULL, *prev_mb = NULL; -#endif /** Make sure we have some RX buffers. */ { @@ -251,9 +240,7 @@ tuntap_rx (vlib_main_t * vm, if (! tm->rx_buffers) vec_alloc (tm->rx_buffers, VLIB_FRAME_SIZE); - n_alloc = vlib_buffer_alloc_from_free_list - (vm, tm->rx_buffers + n_left, VLIB_FRAME_SIZE - n_left, - free_list_index); + n_alloc = vlib_buffer_alloc (vm, tm->rx_buffers + n_left, VLIB_FRAME_SIZE - n_left); _vec_len (tm->rx_buffers) = n_left + n_alloc; } } @@ -289,46 +276,21 @@ tuntap_rx (vlib_main_t * vm, while (1) { -#if DPDK == 1 - struct rte_mbuf * mb; -#endif b = vlib_get_buffer (vm, tm->rx_buffers[i_rx]); -#if DPDK == 1 - mb = rte_mbuf_from_vlib_buffer(b); - - if (first_mb == NULL) - first_mb = mb; - - if (prev_mb != NULL) - { - prev_mb->next = mb; - first_mb->nb_segs++; - } -#endif b->flags = 0; b->current_data = 0; b->current_length = n_bytes_left < buffer_size ? n_bytes_left : buffer_size; n_bytes_left -= buffer_size; -#if DPDK == 1 - rte_pktmbuf_data_len (mb) = b->current_length; - mb->data_off = RTE_PKTMBUF_HEADROOM + b->current_data; -#endif if (n_bytes_left <= 0) { -#if DPDK == 1 - rte_pktmbuf_pkt_len (first_mb) = n_bytes_in_packet; -#endif break; } i_rx--; b->flags |= VLIB_BUFFER_NEXT_PRESENT; b->next_buffer = tm->rx_buffers[i_rx]; -#if DPDK == 1 - prev_mb = mb; -#endif } /** Interface counters for tuntap interface. */ -- cgit 1.2.3-korg