2 * Copyright (c) 2015 Cisco and/or its affiliates.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
15 #ifndef __included_ssvm_eth_h__
16 #define __included_ssvm_eth_h__
18 #include <vnet/vnet.h>
20 #include <vppinfra/elog.h>
21 #include <vppinfra/error.h>
22 #include <vppinfra/format.h>
23 #include <vppinfra/hash.h>
24 #include <vppinfra/vec.h>
25 #include <vppinfra/elog.h>
26 #include <vlib/vlib.h>
27 #include <vnet/ethernet/ethernet.h>
28 #include <vnet/ip/ip.h>
29 #include <vnet/pg/pg.h>
30 #include <vlibmemory/unix_shared_memory_queue.h>
34 extern vnet_device_class_t ssvm_eth_device_class;
35 extern vlib_node_registration_t ssvm_eth_input_node;
37 #define SSVM_BUFFER_SIZE \
38 (VLIB_BUFFER_DATA_SIZE + VLIB_BUFFER_PRE_DATA_SIZE)
39 #define SSVM_PACKET_TYPE 1
43 /* Type of queue element */
46 #define SSVM_BUFFER_NEXT_PRESENT (1<<0)
49 i16 current_data_hint;
50 u16 length_this_buffer;
51 u16 total_length_not_including_first_buffer;
55 u8 data[SSVM_BUFFER_SIZE];
56 /* pad to an even multiple of 64 octets */
57 u8 pad2[CLIB_CACHE_LINE_BYTES - 16];
58 } ssvm_eth_queue_elt_t;
62 /* vector of point-to-point connections */
63 ssvm_private_t *intfcs;
68 /* Configurable parameters */
69 /* base address for next placement */
79 vlib_main_t *vlib_main;
80 vnet_main_t *vnet_main;
81 elog_main_t *elog_main;
84 ssvm_eth_main_t ssvm_eth_main;
88 CHUNK_POOL_FREELIST_INDEX = 0,
93 MASTER_ADMIN_STATE_INDEX,
94 SLAVE_ADMIN_STATE_INDEX,
95 } ssvm_eth_opaque_index_t;
101 ssvm_eth_validate_freelists (int need_lock)
104 ssvm_eth_main_t *em = &ssvm_eth_main;
105 ssvm_private_t *intfc;
106 ssvm_shared_header_t *sh;
111 for (i = 0; i < vec_len (em->intfcs); i++)
113 intfc = em->intfcs + i;
115 u32 my_pid = intfc->my_pid;
118 ssvm_lock (sh, my_pid, 15);
120 elt_indices = (u32 *) (sh->opaque[CHUNK_POOL_FREELIST_INDEX]);
121 n_available = (u32) (uword) (sh->opaque[CHUNK_POOL_NFREE]);
123 for (i = 0; i < n_available; i++)
124 ASSERT (elt_indices[i] < 2048);
132 #endif /* __included_ssvm_eth_h__ */
135 * fd.io coding-style-patch-verification: ON
138 * eval: (c-set-style "gnu")