aboutsummaryrefslogtreecommitdiffstats
path: root/src/vlib
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2018-12-30 18:09:59 +0100
committerDave Barach <openvpp@barachs.net>2019-01-01 14:57:54 +0000
commit671e60e65635b8d030bf303c88411192c747b59e (patch)
tree6659aef772f2f0b1d475a4cb0b2a4da67d5b87a1 /src/vlib
parentb0f662fe93f1db0098f7b50306c2f084644788b1 (diff)
buffers: remove unused code
Change-Id: If2bbfbc52994f5de0879763e0b7a7864498debb6 Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/vlib')
-rw-r--r--src/vlib/CMakeLists.txt1
-rw-r--r--src/vlib/buffer.c64
-rw-r--r--src/vlib/buffer.h61
-rw-r--r--src/vlib/buffer_funcs.h79
-rw-r--r--src/vlib/buffer_serialize.c248
5 files changed, 4 insertions, 449 deletions
diff --git a/src/vlib/CMakeLists.txt b/src/vlib/CMakeLists.txt
index 2209923547a..86fc965ba97 100644
--- a/src/vlib/CMakeLists.txt
+++ b/src/vlib/CMakeLists.txt
@@ -47,7 +47,6 @@ endif()
add_vpp_library(vlib
SOURCES
buffer.c
- buffer_serialize.c
cli.c
counter.c
error.c
diff --git a/src/vlib/buffer.c b/src/vlib/buffer.c
index 3c117c1523f..d024aba1e0f 100644
--- a/src/vlib/buffer.c
+++ b/src/vlib/buffer.c
@@ -661,26 +661,6 @@ vlib_buffer_free_no_next_internal (vlib_main_t * vm, u32 * buffers,
0);
}
-/* Copy template packet data into buffers as they are allocated. */
-static void __attribute__ ((unused))
-vlib_packet_template_buffer_init (vlib_main_t * vm,
- vlib_buffer_free_list_t * fl,
- u32 * buffers, u32 n_buffers)
-{
- vlib_packet_template_t *t =
- uword_to_pointer (fl->buffer_init_function_opaque,
- vlib_packet_template_t *);
- uword i;
-
- for (i = 0; i < n_buffers; i++)
- {
- vlib_buffer_t *b = vlib_get_buffer (vm, buffers[i]);
- ASSERT (b->current_length == vec_len (t->packet_data));
- clib_memcpy_fast (vlib_buffer_get_current (b), t->packet_data,
- b->current_length);
- }
-}
-
void
vlib_packet_template_init (vlib_main_t * vm,
vlib_packet_template_t * t,
@@ -688,20 +668,12 @@ vlib_packet_template_init (vlib_main_t * vm,
uword n_packet_data_bytes,
uword min_n_buffers_each_alloc, char *fmt, ...)
{
- vlib_buffer_main_t *bm = &buffer_main;
va_list va;
- u8 *name;
- vlib_buffer_free_list_t *fl;
va_start (va, fmt);
- name = va_format (0, fmt, &va);
+ t->name = va_format (0, fmt, &va);
va_end (va);
- if (bm->cb.vlib_packet_template_init_cb)
- bm->cb.vlib_packet_template_init_cb (vm, (void *) t, packet_data,
- n_packet_data_bytes,
- min_n_buffers_each_alloc, name);
-
vlib_worker_thread_barrier_sync (vm);
clib_memset (t, 0, sizeof (t[0]));
@@ -709,23 +681,6 @@ vlib_packet_template_init (vlib_main_t * vm,
vec_add (t->packet_data, packet_data, n_packet_data_bytes);
t->min_n_buffers_each_alloc = min_n_buffers_each_alloc;
- t->free_list_index = vlib_buffer_create_free_list_helper
- (vm, n_packet_data_bytes,
- /* is_public */ 1,
- /* is_default */ 0,
- name);
-
- ASSERT (t->free_list_index != 0);
- fl = vlib_buffer_get_free_list (vm, t->free_list_index);
- fl->min_n_buffers_each_alloc = t->min_n_buffers_each_alloc;
-
- fl->buffer_init_function = vlib_packet_template_buffer_init;
- fl->buffer_init_function_opaque = pointer_to_uword (t);
-
- fl->buffer_init_template.current_data = 0;
- fl->buffer_init_template.current_length = n_packet_data_bytes;
- fl->buffer_init_template.flags = 0;
- fl->buffer_init_template.n_add_refs = 0;
vlib_worker_thread_barrier_release (vm);
}
@@ -749,23 +704,6 @@ vlib_packet_template_get_packet (vlib_main_t * vm,
return b->data;
}
-void
-vlib_packet_template_get_packet_helper (vlib_main_t * vm,
- vlib_packet_template_t * t)
-{
- word n = t->min_n_buffers_each_alloc;
- word l = vec_len (t->packet_data);
- word n_alloc;
-
- ASSERT (l > 0);
- ASSERT (vec_len (t->free_buffers) == 0);
-
- vec_validate (t->free_buffers, n - 1);
- n_alloc = vlib_buffer_alloc_from_free_list (vm, t->free_buffers,
- n, t->free_list_index);
- _vec_len (t->free_buffers) = n_alloc;
-}
-
/* Append given data to end of buffer, possibly allocating new buffers. */
u32
vlib_buffer_add_data (vlib_main_t * vm,
diff --git a/src/vlib/buffer.h b/src/vlib/buffer.h
index ceab94f25fd..2c8d5a046a7 100644
--- a/src/vlib/buffer.h
+++ b/src/vlib/buffer.h
@@ -407,12 +407,6 @@ typedef struct
vlib_buffer_fill_free_list_cb_t *vlib_buffer_fill_free_list_cb;
vlib_buffer_free_cb_t *vlib_buffer_free_cb;
vlib_buffer_free_no_next_cb_t *vlib_buffer_free_no_next_cb;
- void (*vlib_packet_template_init_cb) (struct vlib_main_t * vm, void *t,
- void *packet_data,
- uword n_packet_data_bytes,
- uword
- min_n_buffers_each_physmem_alloc,
- u8 * name);
void (*vlib_buffer_delete_free_list_cb) (struct vlib_main_t * vm,
vlib_buffer_free_list_index_t
free_list_index);
@@ -478,61 +472,8 @@ u8 vlib_buffer_register_physmem_map (struct vlib_main_t * vm,
clib_error_t *vlib_buffer_main_init (struct vlib_main_t *vm);
-typedef struct
-{
- struct vlib_main_t *vlib_main;
-
- u32 first_buffer, last_buffer;
-
- union
- {
- struct
- {
- /* Total accumulated bytes in chain starting with first_buffer. */
- u32 n_total_data_bytes;
-
- /* Max number of bytes to accumulate in chain starting with first_buffer.
- As this limit is reached buffers are enqueued to next node. */
- u32 max_n_data_bytes_per_chain;
-
- /* Next node to enqueue buffers to relative to current process node. */
- u32 next_index;
-
- /* Free list to use to allocate new buffers. */
- vlib_buffer_free_list_index_t free_list_index;
- } tx;
-
- struct
- {
- /* CLIB fifo of buffer indices waiting to be unserialized. */
- u32 *buffer_fifo;
-
- /* Event type used to signal that RX buffers have been added to fifo. */
- uword ready_one_time_event;
- } rx;
- };
-} vlib_serialize_buffer_main_t;
-
-void serialize_open_vlib_buffer (serialize_main_t * m, struct vlib_main_t *vm,
- vlib_serialize_buffer_main_t * sm);
-void unserialize_open_vlib_buffer (serialize_main_t * m,
- struct vlib_main_t *vm,
- vlib_serialize_buffer_main_t * sm);
-
-u32 serialize_close_vlib_buffer (serialize_main_t * m);
-void unserialize_close_vlib_buffer (serialize_main_t * m);
-void *vlib_set_buffer_free_callback (struct vlib_main_t *vm, void *fp);
-always_inline u32
-serialize_vlib_buffer_n_bytes (serialize_main_t * m)
-{
- serialize_stream_t *s = &m->stream;
- vlib_serialize_buffer_main_t *sm
- = uword_to_pointer (m->stream.data_function_opaque,
- vlib_serialize_buffer_main_t *);
- return sm->tx.n_total_data_bytes + s->current_buffer_index +
- vec_len (s->overflow_buffer);
-}
+void *vlib_set_buffer_free_callback (struct vlib_main_t *vm, void *fp);
/*
*/
diff --git a/src/vlib/buffer_funcs.h b/src/vlib/buffer_funcs.h
index c201fd672a5..54fc1f61598 100644
--- a/src/vlib/buffer_funcs.h
+++ b/src/vlib/buffer_funcs.h
@@ -340,28 +340,6 @@ vlib_buffer_get_current_pa (vlib_main_t * vm, vlib_buffer_t * b)
vlib_prefetch_buffer_header (_b, type); \
} while (0)
-#if 0
-/* Iterate over known allocated vlib bufs. You probably do not want
- * to do this!
- @param vm the vlib_main_t
- @param bi found allocated buffer index
- @param body operation to perform on buffer index
- function executes body for each allocated buffer index
- */
-#define vlib_buffer_foreach_allocated(vm,bi,body) \
-do { \
- vlib_main_t * _vmain = (vm); \
- vlib_buffer_main_t * _bmain = &_vmain->buffer_main; \
- hash_pair_t * _vbpair; \
- hash_foreach_pair(_vbpair, _bmain->buffer_known_hash, ({ \
- if (VLIB_BUFFER_KNOWN_ALLOCATED == _vbpair->value[0]) { \
- (bi) = _vbpair->key; \
- body; \
- } \
- })); \
-} while (0)
-#endif
-
typedef enum
{
/* Index is unknown. */
@@ -693,31 +671,6 @@ vlib_buffer_free_list_buffer_size (vlib_main_t * vm,
return f->n_data_bytes;
}
-void vlib_aligned_memcpy (void *_dst, void *_src, int n_bytes);
-
-/* Reasonably fast buffer copy routine. */
-always_inline void
-vlib_copy_buffers (u32 * dst, u32 * src, u32 n)
-{
- while (n >= 4)
- {
- dst[0] = src[0];
- dst[1] = src[1];
- dst[2] = src[2];
- dst[3] = src[3];
- dst += 4;
- src += 4;
- n -= 4;
- }
- while (n > 0)
- {
- dst[0] = src[0];
- dst += 1;
- src += 1;
- n -= 1;
- }
-}
-
/* Append given data to end of buffer, possibly allocating new buffers. */
u32 vlib_buffer_add_data (vlib_main_t * vm,
vlib_buffer_free_list_index_t free_list_index,
@@ -1017,6 +970,8 @@ typedef struct
vlib_buffer_free_list_index_t free_list_index;
u32 *free_buffers;
+
+ u8 *name;
} vlib_packet_template_t;
void vlib_packet_template_get_packet_helper (vlib_main_t * vm,
@@ -1039,36 +994,6 @@ vlib_packet_template_free (vlib_main_t * vm, vlib_packet_template_t * t)
vec_free (t->packet_data);
}
-always_inline u32
-unserialize_vlib_buffer_n_bytes (serialize_main_t * m)
-{
- serialize_stream_t *s = &m->stream;
- vlib_serialize_buffer_main_t *sm
- = uword_to_pointer (m->stream.data_function_opaque,
- vlib_serialize_buffer_main_t *);
- vlib_main_t *vm = sm->vlib_main;
- u32 n, *f;
-
- n = s->n_buffer_bytes - s->current_buffer_index;
- if (sm->last_buffer != ~0)
- {
- vlib_buffer_t *b = vlib_get_buffer (vm, sm->last_buffer);
- while (b->flags & VLIB_BUFFER_NEXT_PRESENT)
- {
- b = vlib_get_buffer (vm, b->next_buffer);
- n += b->current_length;
- }
- }
-
- /* *INDENT-OFF* */
- clib_fifo_foreach (f, sm->rx.buffer_fifo, ({
- n += vlib_buffer_index_length_in_chain (vm, f[0]);
- }));
-/* *INDENT-ON* */
-
- return n;
-}
-
/* Set a buffer quickly into "uninitialized" state. We want this to
be extremely cheap and arrange for all fields that need to be
initialized to be in the first 128 bits of the buffer. */
diff --git a/src/vlib/buffer_serialize.c b/src/vlib/buffer_serialize.c
deleted file mode 100644
index 5696882ae0d..00000000000
--- a/src/vlib/buffer_serialize.c
+++ /dev/null
@@ -1,248 +0,0 @@
-/*
- * Copyright (c) 2015 Cisco and/or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/*
- * buffer.c: allocate/free network buffers.
- *
- * Copyright (c) 2008 Eliot Dresselhaus
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-#include <vlib/vlib.h>
-
-static void
-vlib_serialize_tx (serialize_main_header_t * m, serialize_stream_t * s)
-{
- vlib_main_t *vm;
- vlib_serialize_buffer_main_t *sm;
- uword n, n_bytes_to_write;
- vlib_buffer_t *last;
-
- n_bytes_to_write = s->current_buffer_index;
- sm =
- uword_to_pointer (s->data_function_opaque,
- vlib_serialize_buffer_main_t *);
- vm = sm->vlib_main;
-
- ASSERT (sm->tx.max_n_data_bytes_per_chain > 0);
- if (serialize_stream_is_end_of_stream (s)
- || sm->tx.n_total_data_bytes + n_bytes_to_write >
- sm->tx.max_n_data_bytes_per_chain)
- {
- vlib_process_t *p = vlib_get_current_process (vm);
-
- last = vlib_get_buffer (vm, sm->last_buffer);
- last->current_length = n_bytes_to_write;
-
- vlib_set_next_frame_buffer (vm, &p->node_runtime, sm->tx.next_index,
- sm->first_buffer);
-
- sm->first_buffer = sm->last_buffer = ~0;
- sm->tx.n_total_data_bytes = 0;
- }
-
- else if (n_bytes_to_write == 0 && s->n_buffer_bytes == 0)
- {
- ASSERT (sm->first_buffer == ~0);
- ASSERT (sm->last_buffer == ~0);
- n =
- vlib_buffer_alloc_from_free_list (vm, &sm->first_buffer, 1,
- sm->tx.free_list_index);
- if (n != 1)
- serialize_error (m,
- clib_error_create
- ("vlib_buffer_alloc_from_free_list fails"));
- sm->last_buffer = sm->first_buffer;
- s->n_buffer_bytes =
- vlib_buffer_free_list_buffer_size (vm, sm->tx.free_list_index);
- }
-
- if (n_bytes_to_write > 0)
- {
- vlib_buffer_t *prev = vlib_get_buffer (vm, sm->last_buffer);
- n =
- vlib_buffer_alloc_from_free_list (vm, &sm->last_buffer, 1,
- sm->tx.free_list_index);
- if (n != 1)
- serialize_error (m,
- clib_error_create
- ("vlib_buffer_alloc_from_free_list fails"));
- sm->tx.n_total_data_bytes += n_bytes_to_write;
- prev->current_length = n_bytes_to_write;
- prev->next_buffer = sm->last_buffer;
- prev->flags |= VLIB_BUFFER_NEXT_PRESENT;
- }
-
- if (sm->last_buffer != ~0)
- {
- last = vlib_get_buffer (vm, sm->last_buffer);
- s->buffer = vlib_buffer_get_current (last);
- s->current_buffer_index = 0;
- ASSERT (last->current_data == s->current_buffer_index);
- }
-}
-
-static void
-vlib_serialize_rx (serialize_main_header_t * m, serialize_stream_t * s)
-{
- vlib_main_t *vm;
- vlib_serialize_buffer_main_t *sm;
- vlib_buffer_t *last;
-
- sm =
- uword_to_pointer (s->data_function_opaque,
- vlib_serialize_buffer_main_t *);
- vm = sm->vlib_main;
-
- if (serialize_stream_is_end_of_stream (s))
- return;
-
- if (sm->last_buffer != ~0)
- {
- last = vlib_get_buffer (vm, sm->last_buffer);
-
- if (last->flags & VLIB_BUFFER_NEXT_PRESENT)
- sm->last_buffer = last->next_buffer;
- else
- {
- vlib_buffer_free (vm, &sm->first_buffer, /* count */ 1);
- sm->first_buffer = sm->last_buffer = ~0;
- }
- }
-
- if (sm->last_buffer == ~0)
- {
- while (clib_fifo_elts (sm->rx.buffer_fifo) == 0)
- {
- sm->rx.ready_one_time_event =
- vlib_process_create_one_time_event (vm, vlib_current_process (vm),
- ~0);
- vlib_process_wait_for_one_time_event (vm, /* no event data */ 0,
- sm->rx.ready_one_time_event);
- }
-
- clib_fifo_sub1 (sm->rx.buffer_fifo, sm->first_buffer);
- sm->last_buffer = sm->first_buffer;
- }
-
- ASSERT (sm->last_buffer != ~0);
-
- last = vlib_get_buffer (vm, sm->last_buffer);
- s->current_buffer_index = 0;
- s->buffer = vlib_buffer_get_current (last);
- s->n_buffer_bytes = last->current_length;
-}
-
-static void
-serialize_open_vlib_helper (serialize_main_t * m,
- vlib_main_t * vm,
- vlib_serialize_buffer_main_t * sm, uword is_read)
-{
- /* Initialize serialize main but save overflow buffer for re-use between calls. */
- {
- u8 *save = m->stream.overflow_buffer;
- clib_memset (m, 0, sizeof (m[0]));
- m->stream.overflow_buffer = save;
- if (save)
- _vec_len (save) = 0;
- }
-
- sm->first_buffer = sm->last_buffer = ~0;
- if (is_read)
- clib_fifo_reset (sm->rx.buffer_fifo);
- else
- sm->tx.n_total_data_bytes = 0;
- sm->vlib_main = vm;
- m->header.data_function = is_read ? vlib_serialize_rx : vlib_serialize_tx;
- m->stream.data_function_opaque = pointer_to_uword (sm);
-}
-
-void
-serialize_open_vlib_buffer (serialize_main_t * m, vlib_main_t * vm,
- vlib_serialize_buffer_main_t * sm)
-{
- serialize_open_vlib_helper (m, vm, sm, /* is_read */ 0);
-}
-
-void
-unserialize_open_vlib_buffer (serialize_main_t * m, vlib_main_t * vm,
- vlib_serialize_buffer_main_t * sm)
-{
- serialize_open_vlib_helper (m, vm, sm, /* is_read */ 1);
-}
-
-u32
-serialize_close_vlib_buffer (serialize_main_t * m)
-{
- vlib_serialize_buffer_main_t *sm
- = uword_to_pointer (m->stream.data_function_opaque,
- vlib_serialize_buffer_main_t *);
- vlib_buffer_t *last;
- serialize_stream_t *s = &m->stream;
-
- last = vlib_get_buffer (sm->vlib_main, sm->last_buffer);
- last->current_length = s->current_buffer_index;
-
- if (vec_len (s->overflow_buffer) > 0)
- {
- sm->last_buffer
- = vlib_buffer_add_data (sm->vlib_main, sm->tx.free_list_index,
- sm->last_buffer,
- s->overflow_buffer,
- vec_len (s->overflow_buffer));
- _vec_len (s->overflow_buffer) = 0;
- }
-
- return sm->first_buffer;
-}
-
-void
-unserialize_close_vlib_buffer (serialize_main_t * m)
-{
- vlib_serialize_buffer_main_t *sm
- = uword_to_pointer (m->stream.data_function_opaque,
- vlib_serialize_buffer_main_t *);
- if (sm->first_buffer != ~0)
- vlib_buffer_free_one (sm->vlib_main, sm->first_buffer);
- clib_fifo_reset (sm->rx.buffer_fifo);
- if (m->stream.overflow_buffer)
- _vec_len (m->stream.overflow_buffer) = 0;
-}
-
-/** @endcond */
-/*
- * fd.io coding-style-patch-verification: ON
- *
- * Local Variables:
- * eval: (c-set-style "gnu")
- * End:
- */