diff options
Diffstat (limited to 'vnet')
-rw-r--r-- | vnet/vnet/devices/af_packet/node.c | 8 | ||||
-rw-r--r-- | vnet/vnet/devices/dpdk/device.c | 20 | ||||
-rw-r--r-- | vnet/vnet/devices/dpdk/dpdk.h | 1 | ||||
-rw-r--r-- | vnet/vnet/devices/dpdk/init.c | 4 | ||||
-rw-r--r-- | vnet/vnet/devices/dpdk/node.c | 32 | ||||
-rw-r--r-- | vnet/vnet/devices/ssvm/ssvm_eth.h | 2 | ||||
-rw-r--r-- | vnet/vnet/dpdk_replication.h | 6 | ||||
-rw-r--r-- | vnet/vnet/ip/ip.h | 2 | ||||
-rw-r--r-- | vnet/vnet/ip/ip6_forward.c | 2 | ||||
-rw-r--r-- | vnet/vnet/pg/input.c | 6 | ||||
-rw-r--r-- | vnet/vnet/unix/tapcli.c | 4 | ||||
-rw-r--r-- | vnet/vnet/unix/tuntap.c | 12 |
12 files changed, 45 insertions, 54 deletions
diff --git a/vnet/vnet/devices/af_packet/node.c b/vnet/vnet/devices/af_packet/node.c index 15a96f442f9..efe0e1c2586 100644 --- a/vnet/vnet/devices/af_packet/node.c +++ b/vnet/vnet/devices/af_packet/node.c @@ -94,11 +94,6 @@ buffer_add_to_chain(vlib_main_t *vm, u32 bi, u32 first_bi, u32 prev_bi) vlib_buffer_t * b = vlib_get_buffer (vm, bi); vlib_buffer_t * first_b = vlib_get_buffer (vm, first_bi); vlib_buffer_t * prev_b = vlib_get_buffer (vm, prev_bi); -#if DPDK > 0 - struct rte_mbuf * mbuf = ((struct rte_mbuf *) b) - 1; - struct rte_mbuf * first_mbuf = ((struct rte_mbuf *) first_b) - 1; - struct rte_mbuf * prev_mbuf = ((struct rte_mbuf *) prev_b) - 1; -#endif /* update first buffer */ first_b->total_length_not_including_first_buffer += b->current_length; @@ -111,6 +106,9 @@ buffer_add_to_chain(vlib_main_t *vm, u32 bi, u32 first_bi, u32 prev_bi) 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; diff --git a/vnet/vnet/devices/dpdk/device.c b/vnet/vnet/devices/dpdk/device.c index 02703cc59b2..dcf95803c84 100644 --- a/vnet/vnet/devices/dpdk/device.c +++ b/vnet/vnet/devices/dpdk/device.c @@ -87,7 +87,7 @@ static struct rte_mbuf * dpdk_replicate_packet_mb (vlib_buffer_t * b) unsigned socket_id = rte_socket_id(); ASSERT (bm->pktmbuf_pools[socket_id]); - pkt_mb = ((struct rte_mbuf *)b)-1; + pkt_mb = rte_mbuf_from_vlib_buffer(b); nb_segs = pkt_mb->nb_segs; for (nb_segs_left = nb_segs; nb_segs_left; nb_segs_left--) { @@ -159,7 +159,7 @@ dpdk_tx_trace_buffer (dpdk_main_t * dm, dpdk_tx_dma_trace_t * t0; struct rte_mbuf * mb; - mb = ((struct rte_mbuf *)buffer)-1; + mb = rte_mbuf_from_vlib_buffer(buffer); t0 = vlib_add_trace (vm, node, buffer, sizeof (t0[0])); t0->queue_index = queue_id; @@ -541,7 +541,7 @@ dpdk_interface_tx (vlib_main_t * vm, { u32 bi0 = from[n_packets]; vlib_buffer_t *b0 = vlib_get_buffer (vm, bi0); - struct rte_mbuf *mb0 = ((struct rte_mbuf *)b0) - 1; + struct rte_mbuf *mb0 = rte_mbuf_from_vlib_buffer(b0); rte_pktmbuf_free (mb0); } return n_on_ring; @@ -584,9 +584,9 @@ dpdk_interface_tx (vlib_main_t * vm, pref0 = vlib_get_buffer (vm, pi0); pref1 = vlib_get_buffer (vm, pi1); - prefmb0 = ((struct rte_mbuf *)pref0) - 1; - prefmb1 = ((struct rte_mbuf *)pref1) - 1; - + prefmb0 = rte_mbuf_from_vlib_buffer(pref0); + prefmb1 = rte_mbuf_from_vlib_buffer(pref1); + CLIB_PREFETCH(prefmb0, CLIB_CACHE_LINE_BYTES, LOAD); CLIB_PREFETCH(pref0, CLIB_CACHE_LINE_BYTES, LOAD); CLIB_PREFETCH(prefmb1, CLIB_CACHE_LINE_BYTES, LOAD); @@ -599,8 +599,8 @@ dpdk_interface_tx (vlib_main_t * vm, b0 = vlib_get_buffer (vm, bi0); b1 = vlib_get_buffer (vm, bi1); - mb0 = ((struct rte_mbuf *)b0) - 1; - mb1 = ((struct rte_mbuf *)b1) - 1; + mb0 = rte_mbuf_from_vlib_buffer(b0); + mb1 = rte_mbuf_from_vlib_buffer(b1); any_clone = b0->clone_count | b1->clone_count; if (PREDICT_FALSE(any_clone != 0)) @@ -701,7 +701,7 @@ dpdk_interface_tx (vlib_main_t * vm, b0 = vlib_get_buffer (vm, bi0); - mb0 = ((struct rte_mbuf *)b0) - 1; + mb0 = rte_mbuf_from_vlib_buffer(b0); if (PREDICT_FALSE(b0->clone_count != 0)) { struct rte_mbuf * mb0_new = dpdk_replicate_packet_mb (b0); @@ -921,7 +921,7 @@ dpdk_interface_admin_up_down (vnet_main_t * vnm, u32 hw_if_index, u32 flags) vlib_buffer_main_t * bm = vm->buffer_main; memset(&conf, 0, sizeof(conf)); snprintf(conf.name, RTE_KNI_NAMESIZE, "vpp%u", xd->kni_port_id); - conf.mbuf_size = MBUF_SIZE; + conf.mbuf_size = VLIB_BUFFER_DATA_SIZE; memset(&ops, 0, sizeof(ops)); ops.port_id = xd->kni_port_id; ops.change_mtu = kni_change_mtu; diff --git a/vnet/vnet/devices/dpdk/dpdk.h b/vnet/vnet/devices/dpdk/dpdk.h index 656f39ea681..14f7b3e8518 100644 --- a/vnet/vnet/devices/dpdk/dpdk.h +++ b/vnet/vnet/devices/dpdk/dpdk.h @@ -62,7 +62,6 @@ #define always_inline static inline __attribute__ ((__always_inline__)) #endif -#define MBUF_SIZE (2048 + sizeof(struct rte_mbuf) + RTE_PKTMBUF_HEADROOM) #define NB_MBUF (32<<10) extern vnet_device_class_t dpdk_device_class; diff --git a/vnet/vnet/devices/dpdk/init.c b/vnet/vnet/devices/dpdk/init.c index 8fe95ae5f09..8bb253a3a66 100644 --- a/vnet/vnet/devices/dpdk/init.c +++ b/vnet/vnet/devices/dpdk/init.c @@ -1405,13 +1405,13 @@ dpdk_config (vlib_main_t * vm, unformat_input_t * input) rte_dump_physmem_layout(stdout); /* main thread 1st */ - error = vlib_buffer_pool_create(vm, dm->num_mbufs, MBUF_SIZE, rte_socket_id()); + error = vlib_buffer_pool_create(vm, dm->num_mbufs, rte_socket_id()); if (error) return error; for (i = 0; i < RTE_MAX_LCORE; i++) { - error = vlib_buffer_pool_create(vm, dm->num_mbufs, MBUF_SIZE, + error = vlib_buffer_pool_create(vm, dm->num_mbufs, rte_lcore_to_socket_id(i)); if (error) return error; diff --git a/vnet/vnet/devices/dpdk/node.c b/vnet/vnet/devices/dpdk/node.c index 72d564ba8b2..4f5a84ae29a 100644 --- a/vnet/vnet/devices/dpdk/node.c +++ b/vnet/vnet/devices/dpdk/node.c @@ -366,7 +366,7 @@ void dpdk_rx_trace (dpdk_main_t * dm, n_left -= 1; b0 = vlib_get_buffer (vm, bi0); - mb = ((struct rte_mbuf *)b0) - 1; + mb = rte_mbuf_from_vlib_buffer(b0); dpdk_rx_next_and_error_from_mb_flags_x1 (xd, mb, b0, &next0, &error0); vlib_trace_buffer (vm, node, next0, b0, /* follow_chain */ 0); @@ -602,20 +602,20 @@ static inline u32 dpdk_device_input ( dpdk_main_t * dm, if (PREDICT_TRUE(n_buffers > 2)) { struct rte_mbuf *pfmb = xd->rx_vectors[queue_id][mb_index+2]; - vlib_buffer_t *bp = (vlib_buffer_t *)(pfmb+1); + vlib_buffer_t *bp = vlib_buffer_from_rte_mbuf(pfmb); CLIB_PREFETCH (pfmb, CLIB_CACHE_LINE_BYTES, STORE); CLIB_PREFETCH (bp, CLIB_CACHE_LINE_BYTES, STORE); } ASSERT(mb); - b0 = (vlib_buffer_t *)(mb+1); + b0 = vlib_buffer_from_rte_mbuf(mb); /* check whether EFD is looking for packets to discard */ if (PREDICT_FALSE(efd_discard_burst)) { vlib_thread_main_t * tm = vlib_get_thread_main(); - + if (PREDICT_TRUE(cntr_type = is_efd_discardable(tm, b0, mb))) { rte_pktmbuf_free(mb); @@ -633,7 +633,7 @@ static inline u32 dpdk_device_input ( dpdk_main_t * dm, if (PREDICT_FALSE(mb->nb_segs > 1)) { struct rte_mbuf *pfmb = mb->next; - vlib_buffer_t *bp = (vlib_buffer_t *)(pfmb+1); + vlib_buffer_t *bp = vlib_buffer_from_rte_mbuf(pfmb); CLIB_PREFETCH (pfmb, CLIB_CACHE_LINE_BYTES, LOAD); CLIB_PREFETCH (bp, CLIB_CACHE_LINE_BYTES, STORE); b_chain = b0; @@ -693,7 +693,7 @@ static inline u32 dpdk_device_input ( dpdk_main_t * dm, { ASSERT(mb_seg != 0); - b_seg = (vlib_buffer_t *)(mb_seg+1); + b_seg = vlib_buffer_from_rte_mbuf(mb_seg); vlib_buffer_init_for_free_list (b_seg, fl); b_seg->clone_count = 0; @@ -1280,13 +1280,13 @@ void dpdk_io_thread (vlib_worker_thread_t * w, if (PREDICT_TRUE(n_buffers > 1)) { struct rte_mbuf *pfmb = xd->rx_vectors[queue_id][mb_index+2]; - vlib_buffer_t *bp = (vlib_buffer_t *)(pfmb+1); + vlib_buffer_t *bp = vlib_buffer_from_rte_mbuf(pfmb); CLIB_PREFETCH (pfmb, CLIB_CACHE_LINE_BYTES, LOAD); CLIB_PREFETCH (bp, CLIB_CACHE_LINE_BYTES, STORE); CLIB_PREFETCH (bp->data, CLIB_CACHE_LINE_BYTES, LOAD); } - b0 = (vlib_buffer_t *)(mb+1); + b0 = vlib_buffer_from_rte_mbuf(mb); /* check whether EFD is looking for packets to discard */ if (PREDICT_FALSE(efd_discard_burst)) @@ -1310,7 +1310,7 @@ void dpdk_io_thread (vlib_worker_thread_t * w, if (PREDICT_FALSE(mb->nb_segs > 1)) { struct rte_mbuf *pfmb = mb->next; - vlib_buffer_t *bp = (vlib_buffer_t *)(pfmb+1); + vlib_buffer_t *bp = vlib_buffer_from_rte_mbuf(pfmb); CLIB_PREFETCH (pfmb, CLIB_CACHE_LINE_BYTES, LOAD); CLIB_PREFETCH (bp, CLIB_CACHE_LINE_BYTES, STORE); b_chain = b0; @@ -1361,7 +1361,7 @@ void dpdk_io_thread (vlib_worker_thread_t * w, { ASSERT(mb_seg != 0); - b_seg = (vlib_buffer_t *)(mb_seg+1); + b_seg = vlib_buffer_from_rte_mbuf(mb_seg); vlib_buffer_init_for_free_list (b_seg, fl); b_seg->clone_count = 0; @@ -1681,14 +1681,14 @@ dpdk_io_input (vlib_main_t * vm, if (PREDICT_TRUE(n_buffers > 1)) { struct rte_mbuf *pfmb = xd->rx_vectors[queue_id][mb_index+2]; - vlib_buffer_t *bp = (vlib_buffer_t *)(pfmb+1); + vlib_buffer_t *bp = vlib_buffer_from_rte_mbuf(pfmb); CLIB_PREFETCH (pfmb, CLIB_CACHE_LINE_BYTES, LOAD); CLIB_PREFETCH (bp, CLIB_CACHE_LINE_BYTES, STORE); CLIB_PREFETCH (bp->data, CLIB_CACHE_LINE_BYTES, LOAD); } - - b0 = (vlib_buffer_t *)(mb+1); - + + b0 = vlib_buffer_from_rte_mbuf(mb); + /* check whether EFD is looking for packets to discard */ if (PREDICT_FALSE(efd_discard_burst)) { @@ -1711,7 +1711,7 @@ dpdk_io_input (vlib_main_t * vm, if (PREDICT_FALSE(mb->nb_segs > 1)) { struct rte_mbuf *pfmb = mb->next; - vlib_buffer_t *bp = (vlib_buffer_t *)(pfmb+1); + vlib_buffer_t *bp = vlib_buffer_from_rte_mbuf(pfmb); CLIB_PREFETCH (pfmb, CLIB_CACHE_LINE_BYTES, LOAD); CLIB_PREFETCH (bp, CLIB_CACHE_LINE_BYTES, STORE); b_chain = b0; @@ -1762,7 +1762,7 @@ dpdk_io_input (vlib_main_t * vm, { ASSERT(mb_seg != 0); - b_seg = (vlib_buffer_t *)(mb_seg+1); + b_seg = vlib_buffer_from_rte_mbuf(mb_seg); vlib_buffer_init_for_free_list (b_seg, fl); b_seg->clone_count = 0; diff --git a/vnet/vnet/devices/ssvm/ssvm_eth.h b/vnet/vnet/devices/ssvm/ssvm_eth.h index 70d895b9ad4..8f1f88964c2 100644 --- a/vnet/vnet/devices/ssvm/ssvm_eth.h +++ b/vnet/vnet/devices/ssvm/ssvm_eth.h @@ -35,7 +35,7 @@ extern vnet_device_class_t ssvm_eth_device_class; extern vlib_node_registration_t ssvm_eth_input_node; #define SSVM_BUFFER_SIZE \ - (VLIB_BUFFER_DEFAULT_FREE_LIST_BYTES + VLIB_BUFFER_PRE_DATA_SIZE) + (VLIB_BUFFER_DATA_SIZE + VLIB_BUFFER_PRE_DATA_SIZE) #define SSVM_PACKET_TYPE 1 typedef struct { diff --git a/vnet/vnet/dpdk_replication.h b/vnet/vnet/dpdk_replication.h index b25558f9b89..6259c449af0 100644 --- a/vnet/vnet/dpdk_replication.h +++ b/vnet/vnet/dpdk_replication.h @@ -49,7 +49,7 @@ vlib_dpdk_clone_buffer (vlib_main_t * vm, vlib_buffer_t * b) return 0; src_buf = b; - rv = dst_buf = (vlib_buffer_t *)(rte_mbufs[0] + 1); + rv = dst_buf = vlib_buffer_from_rte_mbuf(rte_mbufs[0]); vlib_buffer_init_for_free_list (dst_buf, fl); copy_src = b->data + src_buf->current_data; copy_dst = dst_buf->data + src_buf->current_data; @@ -75,7 +75,7 @@ vlib_dpdk_clone_buffer (vlib_main_t * vm, vlib_buffer_t * b) if (i < new_buffers_needed - 1) { src_buf = vlib_get_buffer (vm, src_buf->next_buffer); - dst_buf = (vlib_buffer_t *)(rte_mbufs[i+1] + 1); + dst_buf = vlib_buffer_from_rte_mbuf(rte_mbufs[i+1]); vlib_buffer_init_for_free_list (dst_buf, fl); copy_src = src_buf->data; copy_dst = dst_buf->data; @@ -87,7 +87,7 @@ vlib_dpdk_clone_buffer (vlib_main_t * vm, vlib_buffer_t * b) if (rte_mempool_get_bulk (rmp, (void **)rte_mbufs, 1) < 0) return 0; - rv = (vlib_buffer_t *)(rte_mbufs[0] + 1); + rv = vlib_buffer_from_rte_mbuf(rte_mbufs[0]); vlib_buffer_init_for_free_list (rv, fl); memcpy(rv->data + b->current_data, b->data + b->current_data, diff --git a/vnet/vnet/ip/ip.h b/vnet/vnet/ip/ip.h index 76a2552ffa4..de46ad38c5f 100644 --- a/vnet/vnet/ip/ip.h +++ b/vnet/vnet/ip/ip.h @@ -162,7 +162,7 @@ ip_incremental_checksum_buffer (vlib_main_t * vm, vlib_buffer_t * first_buffer, #if DPDK > 0 { u32 n_bytes_left = n_bytes_to_checksum; - struct rte_mbuf * mb = ((struct rte_mbuf *)first_buffer)-1; + 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; diff --git a/vnet/vnet/ip/ip6_forward.c b/vnet/vnet/ip/ip6_forward.c index 1d0e21e528c..a478bab5fc4 100644 --- a/vnet/vnet/ip/ip6_forward.c +++ b/vnet/vnet/ip/ip6_forward.c @@ -1445,7 +1445,7 @@ u16 ip6_tcp_udp_icmp_compute_checksum (vlib_main_t * vm, vlib_buffer_t * p0, ip6 #if DPDK > 0 if (p0) { - struct rte_mbuf *mb = ((struct rte_mbuf *)p0)-1; + struct rte_mbuf *mb = rte_mbuf_from_vlib_buffer(p0); u8 nb_segs = mb->nb_segs; n_this_buffer = (p0->current_length > headers_size ? diff --git a/vnet/vnet/pg/input.c b/vnet/vnet/pg/input.c index 4ec61ca7b96..38402c2e989 100644 --- a/vnet/vnet/pg/input.c +++ b/vnet/vnet/pg/input.c @@ -61,7 +61,7 @@ pg_set_mbuf_metadata (pg_main_t * pg, u32 * buffers, u32 n_alloc) for (i = 0; i < n_alloc; i++) { b = vlib_get_buffer (vm, buffers[i]); - mb = ((struct rte_mbuf *)b) - 1; + 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); @@ -1473,9 +1473,9 @@ pg_stream_fill (pg_main_t * pg, pg_stream_t * s, u32 n_buffers) ({ vlib_buffer_t * b; struct rte_mbuf *mb; - + b = vlib_get_buffer(vm, bi0[0]); - mb = (struct rte_mbuf *)b - 1; + mb = rte_mbuf_from_vlib_buffer(b); ASSERT(rte_mbuf_refcnt_read(mb) == 1); })); } diff --git a/vnet/vnet/unix/tapcli.c b/vnet/vnet/unix/tapcli.c index 5b0ac9378ee..7776b9ee837 100644 --- a/vnet/vnet/unix/tapcli.c +++ b/vnet/vnet/unix/tapcli.c @@ -220,7 +220,7 @@ static uword tapcli_rx_iface(vlib_main_t * vm, tapcli_interface_t * ti) { tapcli_main_t * tm = &tapcli_main; - const uword buffer_size = VLIB_BUFFER_DEFAULT_FREE_LIST_BYTES; + const uword buffer_size = VLIB_BUFFER_DATA_SIZE; u32 n_trace = vlib_get_trace_count (vm, node); u8 set_trace = 0; @@ -434,7 +434,7 @@ static clib_error_t * tapcli_config (vlib_main_t * vm, unformat_input_t * input) { tapcli_main_t *tm = &tapcli_main; - const uword buffer_size = VLIB_BUFFER_DEFAULT_FREE_LIST_BYTES; + const uword buffer_size = VLIB_BUFFER_DATA_SIZE; while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) { diff --git a/vnet/vnet/unix/tuntap.c b/vnet/vnet/unix/tuntap.c index 77c60fd6ee2..7ea0b70348d 100644 --- a/vnet/vnet/unix/tuntap.c +++ b/vnet/vnet/unix/tuntap.c @@ -200,12 +200,11 @@ tuntap_rx (vlib_main_t * vm, tuntap_main_t * tm = &tuntap_main; vlib_buffer_t * b; u32 bi; + const uword buffer_size = VLIB_BUFFER_DATA_SIZE; #if DPDK == 0 - const uword buffer_size = VLIB_BUFFER_DEFAULT_FREE_LIST_BYTES; u32 free_list_index = VLIB_BUFFER_DEFAULT_FREE_LIST_INDEX; #else dpdk_main_t * dm = &dpdk_main; - const uword buffer_size = MBUF_SIZE; u32 free_list_index = dm->vlib_buffer_free_list_index; #endif @@ -262,7 +261,7 @@ tuntap_rx (vlib_main_t * vm, #endif b = vlib_get_buffer (vm, tm->rx_buffers[i_rx]); #if DPDK == 1 - mb = (((struct rte_mbuf *)b)-1); + mb = rte_mbuf_from_vlib_buffer(b); #endif b->flags = 0; b->current_data = 0; @@ -445,12 +444,7 @@ tuntap_config (vlib_main_t * vm, unformat_input_t * input) u8 * name; int flags = IFF_TUN | IFF_NO_PI; int is_enabled = 0, is_ether = 0, have_normal_interface = 0; -#if DPDK == 0 - const uword buffer_size = VLIB_BUFFER_DEFAULT_FREE_LIST_BYTES; -#else - const uword buffer_size = MBUF_SIZE; -#endif - + const uword buffer_size = VLIB_BUFFER_DATA_SIZE; while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) { |