Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1 | /* |
| 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: |
| 6 | * |
| 7 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | * |
| 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. |
| 14 | */ |
| 15 | #include <vnet/vnet.h> |
| 16 | #include <vppinfra/vec.h> |
| 17 | #include <vppinfra/format.h> |
| 18 | #include <vlib/unix/cj.h> |
Shesha Sreenivasamurthy | b8f45b3 | 2016-02-03 09:38:36 -0800 | [diff] [blame] | 19 | #include <assert.h> |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 20 | |
| 21 | #include <vnet/ethernet/ethernet.h> |
| 22 | #include <vnet/devices/dpdk/dpdk.h> |
| 23 | |
| 24 | #include "dpdk_priv.h" |
| 25 | #include <vppinfra/error.h> |
| 26 | |
| 27 | #define foreach_dpdk_tx_func_error \ |
| 28 | _(BAD_RETVAL, "DPDK tx function returned an error") \ |
| 29 | _(RING_FULL, "Tx packet drops (ring full)") \ |
| 30 | _(PKT_DROP, "Tx packet drops (dpdk tx failure)") \ |
| 31 | _(REPL_FAIL, "Tx packet drops (replication failure)") |
| 32 | |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 33 | typedef enum |
| 34 | { |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 35 | #define _(f,s) DPDK_TX_FUNC_ERROR_##f, |
| 36 | foreach_dpdk_tx_func_error |
| 37 | #undef _ |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 38 | DPDK_TX_FUNC_N_ERROR, |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 39 | } dpdk_tx_func_error_t; |
| 40 | |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 41 | static char *dpdk_tx_func_error_strings[] = { |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 42 | #define _(n,s) s, |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 43 | foreach_dpdk_tx_func_error |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 44 | #undef _ |
| 45 | }; |
| 46 | |
Christian Dechamplain | 2073cfe | 2016-02-19 12:26:57 -0500 | [diff] [blame] | 47 | clib_error_t * |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 48 | dpdk_set_mac_address (vnet_hw_interface_t * hi, char *address) |
Christian Dechamplain | 2073cfe | 2016-02-19 12:26:57 -0500 | [diff] [blame] | 49 | { |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 50 | int error; |
| 51 | dpdk_main_t *dm = &dpdk_main; |
| 52 | dpdk_device_t *xd = vec_elt_at_index (dm->devices, hi->dev_instance); |
Christian Dechamplain | 2073cfe | 2016-02-19 12:26:57 -0500 | [diff] [blame] | 53 | |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 54 | error = rte_eth_dev_default_mac_addr_set (xd->device_index, |
| 55 | (struct ether_addr *) address); |
Christian Dechamplain | 2073cfe | 2016-02-19 12:26:57 -0500 | [diff] [blame] | 56 | |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 57 | if (error) |
| 58 | { |
| 59 | return clib_error_return (0, "mac address set failed: %d", error); |
| 60 | } |
| 61 | else |
| 62 | { |
Pavel Kotucek | 50132fa | 2017-01-23 15:24:49 +0100 | [diff] [blame] | 63 | vec_reset_length (xd->default_mac_address); |
| 64 | vec_add (xd->default_mac_address, address, sizeof (address)); |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 65 | return NULL; |
| 66 | } |
Christian Dechamplain | 2073cfe | 2016-02-19 12:26:57 -0500 | [diff] [blame] | 67 | } |
| 68 | |
| 69 | clib_error_t * |
| 70 | dpdk_set_mc_filter (vnet_hw_interface_t * hi, |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 71 | struct ether_addr mc_addr_vec[], int naddr) |
Christian Dechamplain | 2073cfe | 2016-02-19 12:26:57 -0500 | [diff] [blame] | 72 | { |
| 73 | int error; |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 74 | dpdk_main_t *dm = &dpdk_main; |
| 75 | dpdk_device_t *xd = vec_elt_at_index (dm->devices, hi->dev_instance); |
Christian Dechamplain | 2073cfe | 2016-02-19 12:26:57 -0500 | [diff] [blame] | 76 | |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 77 | error = rte_eth_dev_set_mc_addr_list (xd->device_index, mc_addr_vec, naddr); |
Christian Dechamplain | 2073cfe | 2016-02-19 12:26:57 -0500 | [diff] [blame] | 78 | |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 79 | if (error) |
| 80 | { |
| 81 | return clib_error_return (0, "mc addr list failed: %d", error); |
| 82 | } |
| 83 | else |
| 84 | { |
| 85 | return NULL; |
| 86 | } |
Christian Dechamplain | 2073cfe | 2016-02-19 12:26:57 -0500 | [diff] [blame] | 87 | } |
| 88 | |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 89 | struct rte_mbuf * |
| 90 | dpdk_replicate_packet_mb (vlib_buffer_t * b) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 91 | { |
Damjan Marion | 878c609 | 2017-01-04 13:19:27 +0100 | [diff] [blame] | 92 | dpdk_main_t *dm = &dpdk_main; |
Damjan Marion | 22766b8 | 2016-11-15 12:50:28 +0100 | [diff] [blame] | 93 | struct rte_mbuf **mbufs = 0, *s, *d; |
| 94 | u8 nb_segs; |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 95 | unsigned socket_id = rte_socket_id (); |
Damjan Marion | 22766b8 | 2016-11-15 12:50:28 +0100 | [diff] [blame] | 96 | int i; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 97 | |
Damjan Marion | 878c609 | 2017-01-04 13:19:27 +0100 | [diff] [blame] | 98 | ASSERT (dm->pktmbuf_pools[socket_id]); |
Damjan Marion | 22766b8 | 2016-11-15 12:50:28 +0100 | [diff] [blame] | 99 | s = rte_mbuf_from_vlib_buffer (b); |
| 100 | nb_segs = s->nb_segs; |
| 101 | vec_validate (mbufs, nb_segs - 1); |
| 102 | |
Damjan Marion | 878c609 | 2017-01-04 13:19:27 +0100 | [diff] [blame] | 103 | if (rte_pktmbuf_alloc_bulk (dm->pktmbuf_pools[socket_id], mbufs, nb_segs)) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 104 | { |
Damjan Marion | 22766b8 | 2016-11-15 12:50:28 +0100 | [diff] [blame] | 105 | vec_free (mbufs); |
| 106 | return 0; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 107 | } |
| 108 | |
Damjan Marion | 22766b8 | 2016-11-15 12:50:28 +0100 | [diff] [blame] | 109 | d = mbufs[0]; |
| 110 | d->nb_segs = s->nb_segs; |
| 111 | d->data_len = s->data_len; |
| 112 | d->pkt_len = s->pkt_len; |
| 113 | d->data_off = s->data_off; |
| 114 | clib_memcpy (d->buf_addr, s->buf_addr, RTE_PKTMBUF_HEADROOM + s->data_len); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 115 | |
Damjan Marion | 22766b8 | 2016-11-15 12:50:28 +0100 | [diff] [blame] | 116 | for (i = 1; i < nb_segs; i++) |
Keith Burns (alagalah) | 52fc44d | 2016-03-25 09:38:50 -0700 | [diff] [blame] | 117 | { |
Damjan Marion | 22766b8 | 2016-11-15 12:50:28 +0100 | [diff] [blame] | 118 | d->next = mbufs[i]; |
| 119 | d = mbufs[i]; |
| 120 | s = s->next; |
| 121 | d->data_len = s->data_len; |
| 122 | clib_memcpy (d->buf_addr, s->buf_addr, |
| 123 | RTE_PKTMBUF_HEADROOM + s->data_len); |
Keith Burns (alagalah) | 52fc44d | 2016-03-25 09:38:50 -0700 | [diff] [blame] | 124 | } |
| 125 | |
Damjan Marion | 22766b8 | 2016-11-15 12:50:28 +0100 | [diff] [blame] | 126 | d = mbufs[0]; |
| 127 | vec_free (mbufs); |
| 128 | return d; |
Keith Burns (alagalah) | 52fc44d | 2016-03-25 09:38:50 -0700 | [diff] [blame] | 129 | } |
| 130 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 131 | static void |
| 132 | dpdk_tx_trace_buffer (dpdk_main_t * dm, |
| 133 | vlib_node_runtime_t * node, |
| 134 | dpdk_device_t * xd, |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 135 | u16 queue_id, u32 buffer_index, vlib_buffer_t * buffer) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 136 | { |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 137 | vlib_main_t *vm = vlib_get_main (); |
| 138 | dpdk_tx_dma_trace_t *t0; |
| 139 | struct rte_mbuf *mb; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 140 | |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 141 | mb = rte_mbuf_from_vlib_buffer (buffer); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 142 | |
| 143 | t0 = vlib_add_trace (vm, node, buffer, sizeof (t0[0])); |
| 144 | t0->queue_index = queue_id; |
| 145 | t0->device_index = xd->device_index; |
| 146 | t0->buffer_index = buffer_index; |
Damjan Marion | f1213b8 | 2016-03-13 02:22:06 +0100 | [diff] [blame] | 147 | clib_memcpy (&t0->mb, mb, sizeof (t0->mb)); |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 148 | clib_memcpy (&t0->buffer, buffer, |
| 149 | sizeof (buffer[0]) - sizeof (buffer->pre_data)); |
Damjan Marion | f1213b8 | 2016-03-13 02:22:06 +0100 | [diff] [blame] | 150 | clib_memcpy (t0->buffer.pre_data, buffer->data + buffer->current_data, |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 151 | sizeof (t0->buffer.pre_data)); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 152 | } |
| 153 | |
Damjan Marion | 22766b8 | 2016-11-15 12:50:28 +0100 | [diff] [blame] | 154 | static_always_inline void |
| 155 | dpdk_validate_rte_mbuf (vlib_main_t * vm, vlib_buffer_t * b, |
| 156 | int maybe_multiseg) |
| 157 | { |
| 158 | struct rte_mbuf *mb, *first_mb, *last_mb; |
| 159 | |
| 160 | /* buffer is coming from non-dpdk source so we need to init |
| 161 | rte_mbuf header */ |
| 162 | if (PREDICT_FALSE ((b->flags & VNET_BUFFER_RTE_MBUF_VALID) == 0)) |
| 163 | { |
Pierre Pfister | 58290ea | 2016-12-02 10:55:13 +0000 | [diff] [blame] | 164 | vlib_buffer_t *b2 = b; |
| 165 | last_mb = mb = rte_mbuf_from_vlib_buffer (b2); |
Damjan Marion | 22766b8 | 2016-11-15 12:50:28 +0100 | [diff] [blame] | 166 | rte_pktmbuf_reset (mb); |
Pierre Pfister | 58290ea | 2016-12-02 10:55:13 +0000 | [diff] [blame] | 167 | while (maybe_multiseg && (b2->flags & VLIB_BUFFER_NEXT_PRESENT)) |
Damjan Marion | 22766b8 | 2016-11-15 12:50:28 +0100 | [diff] [blame] | 168 | { |
Pierre Pfister | 58290ea | 2016-12-02 10:55:13 +0000 | [diff] [blame] | 169 | b2 = vlib_get_buffer (vm, b2->next_buffer); |
| 170 | mb = rte_mbuf_from_vlib_buffer (b2); |
Damjan Marion | 22766b8 | 2016-11-15 12:50:28 +0100 | [diff] [blame] | 171 | last_mb->next = mb; |
| 172 | last_mb = mb; |
| 173 | rte_pktmbuf_reset (mb); |
| 174 | } |
| 175 | } |
| 176 | |
| 177 | first_mb = mb = rte_mbuf_from_vlib_buffer (b); |
| 178 | first_mb->nb_segs = 1; |
| 179 | mb->data_len = b->current_length; |
| 180 | mb->pkt_len = maybe_multiseg ? vlib_buffer_length_in_chain (vm, b) : |
| 181 | b->current_length; |
| 182 | mb->data_off = VLIB_BUFFER_PRE_DATA_SIZE + b->current_data; |
| 183 | |
| 184 | while (maybe_multiseg && (b->flags & VLIB_BUFFER_NEXT_PRESENT)) |
| 185 | { |
| 186 | b = vlib_get_buffer (vm, b->next_buffer); |
| 187 | mb = rte_mbuf_from_vlib_buffer (b); |
| 188 | mb->data_len = b->current_length; |
| 189 | mb->pkt_len = b->current_length; |
| 190 | mb->data_off = VLIB_BUFFER_PRE_DATA_SIZE + b->current_data; |
| 191 | first_mb->nb_segs++; |
| 192 | } |
| 193 | } |
| 194 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 195 | /* |
| 196 | * This function calls the dpdk's tx_burst function to transmit the packets |
| 197 | * on the tx_vector. It manages a lock per-device if the device does not |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 198 | * support multiple queues. It returns the number of packets untransmitted |
| 199 | * on the tx_vector. If all packets are transmitted (the normal case), the |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 200 | * function returns 0. |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 201 | * |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 202 | * The function assumes there is at least one packet on the tx_vector. |
| 203 | */ |
| 204 | static_always_inline |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 205 | u32 tx_burst_vector_internal (vlib_main_t * vm, |
| 206 | dpdk_device_t * xd, |
| 207 | struct rte_mbuf **tx_vector) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 208 | { |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 209 | dpdk_main_t *dm = &dpdk_main; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 210 | u32 n_packets; |
| 211 | u32 tx_head; |
| 212 | u32 tx_tail; |
| 213 | u32 n_retry; |
| 214 | int rv; |
| 215 | int queue_id; |
| 216 | tx_ring_hdr_t *ring; |
| 217 | |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 218 | ring = vec_header (tx_vector, sizeof (*ring)); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 219 | |
| 220 | n_packets = ring->tx_head - ring->tx_tail; |
| 221 | |
Damjan Marion | b58598b | 2016-09-19 13:44:37 +0200 | [diff] [blame] | 222 | tx_head = ring->tx_head % xd->nb_tx_desc; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 223 | |
| 224 | /* |
| 225 | * Ensure rte_eth_tx_burst is not called with 0 packets, which can lead to |
| 226 | * unpredictable results. |
| 227 | */ |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 228 | ASSERT (n_packets > 0); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 229 | |
| 230 | /* |
| 231 | * Check for tx_vector overflow. If this fails it is a system configuration |
| 232 | * error. The ring should be sized big enough to handle the largest un-flowed |
| 233 | * off burst from a traffic manager. A larger size also helps performance |
| 234 | * a bit because it decreases the probability of having to issue two tx_burst |
| 235 | * calls due to a ring wrap. |
| 236 | */ |
Damjan Marion | b58598b | 2016-09-19 13:44:37 +0200 | [diff] [blame] | 237 | ASSERT (n_packets < xd->nb_tx_desc); |
Damjan Marion | 4ee3a65 | 2016-11-15 19:47:58 +0100 | [diff] [blame] | 238 | ASSERT (ring->tx_tail == 0); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 239 | |
Damjan Marion | 4ee3a65 | 2016-11-15 19:47:58 +0100 | [diff] [blame] | 240 | n_retry = 16; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 241 | queue_id = vm->cpu_index; |
| 242 | |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 243 | do |
| 244 | { |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 245 | /* start the burst at the tail */ |
Damjan Marion | b58598b | 2016-09-19 13:44:37 +0200 | [diff] [blame] | 246 | tx_tail = ring->tx_tail % xd->nb_tx_desc; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 247 | |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 248 | /* |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 249 | * This device only supports one TX queue, |
| 250 | * and we're running multi-threaded... |
| 251 | */ |
Damjan Marion | f530a55 | 2016-10-25 18:53:41 +0200 | [diff] [blame] | 252 | if (PREDICT_FALSE (xd->lockp != 0)) |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 253 | { |
| 254 | queue_id = queue_id % xd->tx_q_used; |
| 255 | while (__sync_lock_test_and_set (xd->lockp[queue_id], 1)) |
| 256 | /* zzzz */ |
| 257 | queue_id = (queue_id + 1) % xd->tx_q_used; |
| 258 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 259 | |
Damjan Marion | 4ee3a65 | 2016-11-15 19:47:58 +0100 | [diff] [blame] | 260 | if (PREDICT_FALSE (xd->flags & DPDK_DEVICE_FLAG_HQOS)) /* HQoS ON */ |
Jasvinder Singh | 85ecc81 | 2016-07-21 17:02:19 +0100 | [diff] [blame] | 261 | { |
Damjan Marion | 4ee3a65 | 2016-11-15 19:47:58 +0100 | [diff] [blame] | 262 | /* no wrap, transmit in one burst */ |
| 263 | dpdk_device_hqos_per_worker_thread_t *hqos = |
| 264 | &xd->hqos_wt[vm->cpu_index]; |
Jasvinder Singh | 85ecc81 | 2016-07-21 17:02:19 +0100 | [diff] [blame] | 265 | |
Jasvinder Singh | 199ca9c | 2016-12-08 13:52:47 +0000 | [diff] [blame] | 266 | ASSERT (hqos->swq != NULL); |
| 267 | |
Damjan Marion | 4ee3a65 | 2016-11-15 19:47:58 +0100 | [diff] [blame] | 268 | dpdk_hqos_metadata_set (hqos, |
| 269 | &tx_vector[tx_tail], tx_head - tx_tail); |
| 270 | rv = rte_ring_sp_enqueue_burst (hqos->swq, |
| 271 | (void **) &tx_vector[tx_tail], |
| 272 | (uint16_t) (tx_head - tx_tail)); |
Jasvinder Singh | 85ecc81 | 2016-07-21 17:02:19 +0100 | [diff] [blame] | 273 | } |
| 274 | else if (PREDICT_TRUE (xd->flags & DPDK_DEVICE_FLAG_PMD)) |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 275 | { |
Damjan Marion | 4ee3a65 | 2016-11-15 19:47:58 +0100 | [diff] [blame] | 276 | /* no wrap, transmit in one burst */ |
| 277 | rv = rte_eth_tx_burst (xd->device_index, |
| 278 | (uint16_t) queue_id, |
| 279 | &tx_vector[tx_tail], |
| 280 | (uint16_t) (tx_head - tx_tail)); |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 281 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 282 | else |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 283 | { |
| 284 | ASSERT (0); |
| 285 | rv = 0; |
| 286 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 287 | |
Damjan Marion | f530a55 | 2016-10-25 18:53:41 +0200 | [diff] [blame] | 288 | if (PREDICT_FALSE (xd->lockp != 0)) |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 289 | *xd->lockp[queue_id] = 0; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 290 | |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 291 | if (PREDICT_FALSE (rv < 0)) |
| 292 | { |
| 293 | // emit non-fatal message, bump counter |
| 294 | vnet_main_t *vnm = dm->vnet_main; |
| 295 | vnet_interface_main_t *im = &vnm->interface_main; |
| 296 | u32 node_index; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 297 | |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 298 | node_index = vec_elt_at_index (im->hw_interfaces, |
| 299 | xd->vlib_hw_if_index)->tx_node_index; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 300 | |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 301 | vlib_error_count (vm, node_index, DPDK_TX_FUNC_ERROR_BAD_RETVAL, 1); |
| 302 | clib_warning ("rte_eth_tx_burst[%d]: error %d", xd->device_index, |
| 303 | rv); |
| 304 | return n_packets; // untransmitted packets |
| 305 | } |
| 306 | ring->tx_tail += (u16) rv; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 307 | n_packets -= (uint16_t) rv; |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 308 | } |
| 309 | while (rv && n_packets && (n_retry > 0)); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 310 | |
| 311 | return n_packets; |
| 312 | } |
| 313 | |
Damjan Marion | 22766b8 | 2016-11-15 12:50:28 +0100 | [diff] [blame] | 314 | static_always_inline void |
| 315 | dpdk_prefetch_buffer_by_index (vlib_main_t * vm, u32 bi) |
| 316 | { |
| 317 | vlib_buffer_t *b; |
| 318 | struct rte_mbuf *mb; |
| 319 | b = vlib_get_buffer (vm, bi); |
| 320 | mb = rte_mbuf_from_vlib_buffer (b); |
| 321 | CLIB_PREFETCH (mb, CLIB_CACHE_LINE_BYTES, LOAD); |
| 322 | CLIB_PREFETCH (b, CLIB_CACHE_LINE_BYTES, LOAD); |
| 323 | } |
| 324 | |
| 325 | static_always_inline void |
| 326 | dpdk_buffer_recycle (vlib_main_t * vm, vlib_node_runtime_t * node, |
| 327 | vlib_buffer_t * b, u32 bi, struct rte_mbuf **mbp) |
| 328 | { |
| 329 | dpdk_main_t *dm = &dpdk_main; |
Dave Barach | 971158e | 2016-11-23 08:57:37 -0500 | [diff] [blame] | 330 | u32 my_cpu = vm->cpu_index; |
Damjan Marion | 22766b8 | 2016-11-15 12:50:28 +0100 | [diff] [blame] | 331 | struct rte_mbuf *mb_new; |
| 332 | |
| 333 | if (PREDICT_FALSE (b->flags & VLIB_BUFFER_RECYCLE) == 0) |
| 334 | return; |
| 335 | |
| 336 | mb_new = dpdk_replicate_packet_mb (b); |
| 337 | if (PREDICT_FALSE (mb_new == 0)) |
| 338 | { |
| 339 | vlib_error_count (vm, node->node_index, |
| 340 | DPDK_TX_FUNC_ERROR_REPL_FAIL, 1); |
| 341 | b->flags |= VLIB_BUFFER_REPL_FAIL; |
| 342 | } |
| 343 | else |
| 344 | *mbp = mb_new; |
| 345 | |
| 346 | vec_add1 (dm->recycle[my_cpu], bi); |
| 347 | } |
| 348 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 349 | /* |
| 350 | * Transmits the packets on the frame to the interface associated with the |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 351 | * node. It first copies packets on the frame to a tx_vector containing the |
| 352 | * rte_mbuf pointers. It then passes this vector to tx_burst_vector_internal |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 353 | * which calls the dpdk tx_burst function. |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 354 | */ |
| 355 | static uword |
| 356 | dpdk_interface_tx (vlib_main_t * vm, |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 357 | vlib_node_runtime_t * node, vlib_frame_t * f) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 358 | { |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 359 | dpdk_main_t *dm = &dpdk_main; |
| 360 | vnet_interface_output_runtime_t *rd = (void *) node->runtime_data; |
| 361 | dpdk_device_t *xd = vec_elt_at_index (dm->devices, rd->dev_instance); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 362 | u32 n_packets = f->n_vectors; |
| 363 | u32 n_left; |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 364 | u32 *from; |
| 365 | struct rte_mbuf **tx_vector; |
Damjan Marion | 22766b8 | 2016-11-15 12:50:28 +0100 | [diff] [blame] | 366 | u16 i; |
| 367 | u16 nb_tx_desc = xd->nb_tx_desc; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 368 | int queue_id; |
| 369 | u32 my_cpu; |
| 370 | u32 tx_pkts = 0; |
| 371 | tx_ring_hdr_t *ring; |
| 372 | u32 n_on_ring; |
| 373 | |
| 374 | my_cpu = vm->cpu_index; |
| 375 | |
| 376 | queue_id = my_cpu; |
| 377 | |
| 378 | tx_vector = xd->tx_vectors[queue_id]; |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 379 | ring = vec_header (tx_vector, sizeof (*ring)); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 380 | |
| 381 | n_on_ring = ring->tx_head - ring->tx_tail; |
| 382 | from = vlib_frame_vector_args (f); |
| 383 | |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 384 | ASSERT (n_packets <= VLIB_FRAME_SIZE); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 385 | |
Damjan Marion | 22766b8 | 2016-11-15 12:50:28 +0100 | [diff] [blame] | 386 | if (PREDICT_FALSE (n_on_ring + n_packets > nb_tx_desc)) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 387 | { |
| 388 | /* |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 389 | * Overflowing the ring should never happen. |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 390 | * If it does then drop the whole frame. |
| 391 | */ |
| 392 | vlib_error_count (vm, node->node_index, DPDK_TX_FUNC_ERROR_RING_FULL, |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 393 | n_packets); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 394 | |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 395 | while (n_packets--) |
| 396 | { |
| 397 | u32 bi0 = from[n_packets]; |
| 398 | vlib_buffer_t *b0 = vlib_get_buffer (vm, bi0); |
| 399 | struct rte_mbuf *mb0 = rte_mbuf_from_vlib_buffer (b0); |
| 400 | rte_pktmbuf_free (mb0); |
| 401 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 402 | return n_on_ring; |
| 403 | } |
| 404 | |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 405 | if (PREDICT_FALSE (dm->tx_pcap_enable)) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 406 | { |
| 407 | n_left = n_packets; |
| 408 | while (n_left > 0) |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 409 | { |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 410 | u32 bi0 = from[0]; |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 411 | vlib_buffer_t *b0 = vlib_get_buffer (vm, bi0); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 412 | if (dm->pcap_sw_if_index == 0 || |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 413 | dm->pcap_sw_if_index == vnet_buffer (b0)->sw_if_index[VLIB_TX]) |
| 414 | pcap_add_buffer (&dm->pcap_main, vm, bi0, 512); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 415 | from++; |
| 416 | n_left--; |
| 417 | } |
| 418 | } |
| 419 | |
| 420 | from = vlib_frame_vector_args (f); |
| 421 | n_left = n_packets; |
Damjan Marion | 22766b8 | 2016-11-15 12:50:28 +0100 | [diff] [blame] | 422 | i = ring->tx_head % nb_tx_desc; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 423 | |
Damjan Marion | 22766b8 | 2016-11-15 12:50:28 +0100 | [diff] [blame] | 424 | while (n_left >= 8) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 425 | { |
Damjan Marion | 22766b8 | 2016-11-15 12:50:28 +0100 | [diff] [blame] | 426 | u32 bi0, bi1, bi2, bi3; |
| 427 | struct rte_mbuf *mb0, *mb1, *mb2, *mb3; |
| 428 | vlib_buffer_t *b0, *b1, *b2, *b3; |
| 429 | u32 or_flags; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 430 | |
Damjan Marion | 22766b8 | 2016-11-15 12:50:28 +0100 | [diff] [blame] | 431 | dpdk_prefetch_buffer_by_index (vm, from[4]); |
| 432 | dpdk_prefetch_buffer_by_index (vm, from[5]); |
| 433 | dpdk_prefetch_buffer_by_index (vm, from[6]); |
| 434 | dpdk_prefetch_buffer_by_index (vm, from[7]); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 435 | |
| 436 | bi0 = from[0]; |
| 437 | bi1 = from[1]; |
Damjan Marion | 22766b8 | 2016-11-15 12:50:28 +0100 | [diff] [blame] | 438 | bi2 = from[2]; |
| 439 | bi3 = from[3]; |
| 440 | from += 4; |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 441 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 442 | b0 = vlib_get_buffer (vm, bi0); |
| 443 | b1 = vlib_get_buffer (vm, bi1); |
Damjan Marion | 22766b8 | 2016-11-15 12:50:28 +0100 | [diff] [blame] | 444 | b2 = vlib_get_buffer (vm, bi2); |
| 445 | b3 = vlib_get_buffer (vm, bi3); |
| 446 | |
| 447 | or_flags = b0->flags | b1->flags | b2->flags | b3->flags; |
| 448 | |
| 449 | if (or_flags & VLIB_BUFFER_NEXT_PRESENT) |
| 450 | { |
| 451 | dpdk_validate_rte_mbuf (vm, b0, 1); |
| 452 | dpdk_validate_rte_mbuf (vm, b1, 1); |
| 453 | dpdk_validate_rte_mbuf (vm, b2, 1); |
| 454 | dpdk_validate_rte_mbuf (vm, b3, 1); |
| 455 | } |
| 456 | else |
| 457 | { |
| 458 | dpdk_validate_rte_mbuf (vm, b0, 0); |
| 459 | dpdk_validate_rte_mbuf (vm, b1, 0); |
| 460 | dpdk_validate_rte_mbuf (vm, b2, 0); |
| 461 | dpdk_validate_rte_mbuf (vm, b3, 0); |
| 462 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 463 | |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 464 | mb0 = rte_mbuf_from_vlib_buffer (b0); |
| 465 | mb1 = rte_mbuf_from_vlib_buffer (b1); |
Damjan Marion | 22766b8 | 2016-11-15 12:50:28 +0100 | [diff] [blame] | 466 | mb2 = rte_mbuf_from_vlib_buffer (b2); |
| 467 | mb3 = rte_mbuf_from_vlib_buffer (b3); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 468 | |
Damjan Marion | 22766b8 | 2016-11-15 12:50:28 +0100 | [diff] [blame] | 469 | if (PREDICT_FALSE (or_flags & VLIB_BUFFER_RECYCLE)) |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 470 | { |
Damjan Marion | 22766b8 | 2016-11-15 12:50:28 +0100 | [diff] [blame] | 471 | dpdk_buffer_recycle (vm, node, b0, bi0, &mb0); |
| 472 | dpdk_buffer_recycle (vm, node, b1, bi1, &mb1); |
| 473 | dpdk_buffer_recycle (vm, node, b2, bi2, &mb2); |
| 474 | dpdk_buffer_recycle (vm, node, b3, bi3, &mb3); |
| 475 | |
| 476 | /* dont enqueue packets if replication failed as they must |
| 477 | be sent back to recycle */ |
| 478 | if (PREDICT_TRUE ((b0->flags & VLIB_BUFFER_REPL_FAIL) == 0)) |
| 479 | tx_vector[i++ % nb_tx_desc] = mb0; |
| 480 | if (PREDICT_TRUE ((b1->flags & VLIB_BUFFER_REPL_FAIL) == 0)) |
| 481 | tx_vector[i++ % nb_tx_desc] = mb1; |
| 482 | if (PREDICT_TRUE ((b2->flags & VLIB_BUFFER_REPL_FAIL) == 0)) |
| 483 | tx_vector[i++ % nb_tx_desc] = mb2; |
| 484 | if (PREDICT_TRUE ((b3->flags & VLIB_BUFFER_REPL_FAIL) == 0)) |
| 485 | tx_vector[i++ % nb_tx_desc] = mb3; |
| 486 | } |
| 487 | else |
| 488 | { |
| 489 | if (PREDICT_FALSE (i + 3 >= nb_tx_desc)) |
Keith Burns (alagalah) | c02f02d | 2016-04-19 12:54:12 -0700 | [diff] [blame] | 490 | { |
Damjan Marion | 22766b8 | 2016-11-15 12:50:28 +0100 | [diff] [blame] | 491 | tx_vector[i++ % nb_tx_desc] = mb0; |
| 492 | tx_vector[i++ % nb_tx_desc] = mb1; |
| 493 | tx_vector[i++ % nb_tx_desc] = mb2; |
| 494 | tx_vector[i++ % nb_tx_desc] = mb3; |
| 495 | i %= nb_tx_desc; |
Keith Burns (alagalah) | c02f02d | 2016-04-19 12:54:12 -0700 | [diff] [blame] | 496 | } |
Damjan Marion | 22766b8 | 2016-11-15 12:50:28 +0100 | [diff] [blame] | 497 | else |
Keith Burns (alagalah) | c02f02d | 2016-04-19 12:54:12 -0700 | [diff] [blame] | 498 | { |
Damjan Marion | 22766b8 | 2016-11-15 12:50:28 +0100 | [diff] [blame] | 499 | tx_vector[i++] = mb0; |
| 500 | tx_vector[i++] = mb1; |
| 501 | tx_vector[i++] = mb2; |
| 502 | tx_vector[i++] = mb3; |
Keith Burns (alagalah) | c02f02d | 2016-04-19 12:54:12 -0700 | [diff] [blame] | 503 | } |
| 504 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 505 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 506 | |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 507 | if (PREDICT_FALSE (node->flags & VLIB_NODE_FLAG_TRACE)) |
Keith Burns (alagalah) | c02f02d | 2016-04-19 12:54:12 -0700 | [diff] [blame] | 508 | { |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 509 | if (b0->flags & VLIB_BUFFER_IS_TRACED) |
Keith Burns (alagalah) | c02f02d | 2016-04-19 12:54:12 -0700 | [diff] [blame] | 510 | dpdk_tx_trace_buffer (dm, node, xd, queue_id, bi0, b0); |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 511 | if (b1->flags & VLIB_BUFFER_IS_TRACED) |
Keith Burns (alagalah) | c02f02d | 2016-04-19 12:54:12 -0700 | [diff] [blame] | 512 | dpdk_tx_trace_buffer (dm, node, xd, queue_id, bi1, b1); |
Damjan Marion | 22766b8 | 2016-11-15 12:50:28 +0100 | [diff] [blame] | 513 | if (b2->flags & VLIB_BUFFER_IS_TRACED) |
| 514 | dpdk_tx_trace_buffer (dm, node, xd, queue_id, bi2, b2); |
| 515 | if (b3->flags & VLIB_BUFFER_IS_TRACED) |
| 516 | dpdk_tx_trace_buffer (dm, node, xd, queue_id, bi3, b3); |
Keith Burns (alagalah) | c02f02d | 2016-04-19 12:54:12 -0700 | [diff] [blame] | 517 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 518 | |
Damjan Marion | 22766b8 | 2016-11-15 12:50:28 +0100 | [diff] [blame] | 519 | n_left -= 4; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 520 | } |
| 521 | while (n_left > 0) |
| 522 | { |
| 523 | u32 bi0; |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 524 | struct rte_mbuf *mb0; |
| 525 | vlib_buffer_t *b0; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 526 | |
| 527 | bi0 = from[0]; |
| 528 | from++; |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 529 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 530 | b0 = vlib_get_buffer (vm, bi0); |
| 531 | |
Damjan Marion | 22766b8 | 2016-11-15 12:50:28 +0100 | [diff] [blame] | 532 | dpdk_validate_rte_mbuf (vm, b0, 1); |
| 533 | |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 534 | mb0 = rte_mbuf_from_vlib_buffer (b0); |
Damjan Marion | 22766b8 | 2016-11-15 12:50:28 +0100 | [diff] [blame] | 535 | dpdk_buffer_recycle (vm, node, b0, bi0, &mb0); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 536 | |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 537 | if (PREDICT_FALSE (node->flags & VLIB_NODE_FLAG_TRACE)) |
Keith Burns (alagalah) | c02f02d | 2016-04-19 12:54:12 -0700 | [diff] [blame] | 538 | if (b0->flags & VLIB_BUFFER_IS_TRACED) |
| 539 | dpdk_tx_trace_buffer (dm, node, xd, queue_id, bi0, b0); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 540 | |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 541 | if (PREDICT_TRUE ((b0->flags & VLIB_BUFFER_REPL_FAIL) == 0)) |
| 542 | { |
Damjan Marion | 22766b8 | 2016-11-15 12:50:28 +0100 | [diff] [blame] | 543 | tx_vector[i % nb_tx_desc] = mb0; |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 544 | i++; |
| 545 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 546 | n_left--; |
| 547 | } |
| 548 | |
| 549 | /* account for additional packets in the ring */ |
| 550 | ring->tx_head += n_packets; |
| 551 | n_on_ring = ring->tx_head - ring->tx_tail; |
| 552 | |
| 553 | /* transmit as many packets as possible */ |
| 554 | n_packets = tx_burst_vector_internal (vm, xd, tx_vector); |
| 555 | |
| 556 | /* |
| 557 | * tx_pkts is the number of packets successfully transmitted |
| 558 | * This is the number originally on ring minus the number remaining on ring |
| 559 | */ |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 560 | tx_pkts = n_on_ring - n_packets; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 561 | |
Damjan Marion | 4ee3a65 | 2016-11-15 19:47:58 +0100 | [diff] [blame] | 562 | { |
| 563 | /* If there is no callback then drop any non-transmitted packets */ |
| 564 | if (PREDICT_FALSE (n_packets)) |
| 565 | { |
| 566 | vlib_simple_counter_main_t *cm; |
| 567 | vnet_main_t *vnm = vnet_get_main (); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 568 | |
Damjan Marion | 4ee3a65 | 2016-11-15 19:47:58 +0100 | [diff] [blame] | 569 | cm = vec_elt_at_index (vnm->interface_main.sw_if_counters, |
| 570 | VNET_INTERFACE_COUNTER_TX_ERROR); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 571 | |
Damjan Marion | 4ee3a65 | 2016-11-15 19:47:58 +0100 | [diff] [blame] | 572 | vlib_increment_simple_counter (cm, my_cpu, xd->vlib_sw_if_index, |
| 573 | n_packets); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 574 | |
Damjan Marion | 4ee3a65 | 2016-11-15 19:47:58 +0100 | [diff] [blame] | 575 | vlib_error_count (vm, node->node_index, DPDK_TX_FUNC_ERROR_PKT_DROP, |
| 576 | n_packets); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 577 | |
Damjan Marion | 4ee3a65 | 2016-11-15 19:47:58 +0100 | [diff] [blame] | 578 | while (n_packets--) |
| 579 | rte_pktmbuf_free (tx_vector[ring->tx_tail + n_packets]); |
| 580 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 581 | |
Damjan Marion | 4ee3a65 | 2016-11-15 19:47:58 +0100 | [diff] [blame] | 582 | /* Reset head/tail to avoid unnecessary wrap */ |
| 583 | ring->tx_head = 0; |
| 584 | ring->tx_tail = 0; |
| 585 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 586 | |
| 587 | /* Recycle replicated buffers */ |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 588 | if (PREDICT_FALSE (vec_len (dm->recycle[my_cpu]))) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 589 | { |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 590 | vlib_buffer_free (vm, dm->recycle[my_cpu], |
| 591 | vec_len (dm->recycle[my_cpu])); |
| 592 | _vec_len (dm->recycle[my_cpu]) = 0; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 593 | } |
| 594 | |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 595 | ASSERT (ring->tx_head >= ring->tx_tail); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 596 | |
| 597 | return tx_pkts; |
| 598 | } |
| 599 | |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 600 | static void |
| 601 | dpdk_clear_hw_interface_counters (u32 instance) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 602 | { |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 603 | dpdk_main_t *dm = &dpdk_main; |
| 604 | dpdk_device_t *xd = vec_elt_at_index (dm->devices, instance); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 605 | |
| 606 | /* |
Damjan Marion | b28e498 | 2016-08-22 22:34:38 +0200 | [diff] [blame] | 607 | * Set the "last_cleared_stats" to the current stats, so that |
| 608 | * things appear to clear from a display perspective. |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 609 | */ |
Damjan Marion | b28e498 | 2016-08-22 22:34:38 +0200 | [diff] [blame] | 610 | dpdk_update_counters (xd, vlib_time_now (dm->vlib_main)); |
Sean Hope | a4f16a0 | 2016-03-28 13:11:31 -0400 | [diff] [blame] | 611 | |
Damjan Marion | b28e498 | 2016-08-22 22:34:38 +0200 | [diff] [blame] | 612 | clib_memcpy (&xd->last_cleared_stats, &xd->stats, sizeof (xd->stats)); |
| 613 | clib_memcpy (xd->last_cleared_xstats, xd->xstats, |
| 614 | vec_len (xd->last_cleared_xstats) * |
| 615 | sizeof (xd->last_cleared_xstats[0])); |
Shesha Sreenivasamurthy | 9455084 | 2016-03-02 10:33:26 -0800 | [diff] [blame] | 616 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 617 | } |
| 618 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 619 | static clib_error_t * |
| 620 | dpdk_interface_admin_up_down (vnet_main_t * vnm, u32 hw_if_index, u32 flags) |
| 621 | { |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 622 | vnet_hw_interface_t *hif = vnet_get_hw_interface (vnm, hw_if_index); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 623 | uword is_up = (flags & VNET_SW_INTERFACE_FLAG_ADMIN_UP) != 0; |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 624 | dpdk_main_t *dm = &dpdk_main; |
| 625 | dpdk_device_t *xd = vec_elt_at_index (dm->devices, hif->dev_instance); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 626 | int rv = 0; |
| 627 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 628 | if (is_up) |
| 629 | { |
| 630 | f64 now = vlib_time_now (dm->vlib_main); |
| 631 | |
Damjan Marion | b28e498 | 2016-08-22 22:34:38 +0200 | [diff] [blame] | 632 | if ((xd->flags & DPDK_DEVICE_FLAG_ADMIN_UP) == 0) |
Pavel Kotucek | 50132fa | 2017-01-23 15:24:49 +0100 | [diff] [blame] | 633 | { |
| 634 | rv = rte_eth_dev_start (xd->device_index); |
| 635 | if (!rv && xd->default_mac_address) |
| 636 | rv = rte_eth_dev_default_mac_addr_set (xd->device_index, |
| 637 | (struct ether_addr *) |
| 638 | xd->default_mac_address); |
| 639 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 640 | |
Damjan Marion | b28e498 | 2016-08-22 22:34:38 +0200 | [diff] [blame] | 641 | if (xd->flags & DPDK_DEVICE_FLAG_PROMISC) |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 642 | rte_eth_promiscuous_enable (xd->device_index); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 643 | else |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 644 | rte_eth_promiscuous_disable (xd->device_index); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 645 | |
| 646 | rte_eth_allmulticast_enable (xd->device_index); |
Damjan Marion | b28e498 | 2016-08-22 22:34:38 +0200 | [diff] [blame] | 647 | xd->flags |= DPDK_DEVICE_FLAG_ADMIN_UP; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 648 | dpdk_update_counters (xd, now); |
| 649 | dpdk_update_link_state (xd, now); |
| 650 | } |
| 651 | else |
| 652 | { |
Damjan Marion | b28e498 | 2016-08-22 22:34:38 +0200 | [diff] [blame] | 653 | xd->flags &= ~DPDK_DEVICE_FLAG_ADMIN_UP; |
Georgi Savov | 3a03598 | 2016-02-25 12:56:03 -0500 | [diff] [blame] | 654 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 655 | rte_eth_allmulticast_disable (xd->device_index); |
| 656 | vnet_hw_interface_set_flags (vnm, xd->vlib_hw_if_index, 0); |
Damjan Marion | b28e498 | 2016-08-22 22:34:38 +0200 | [diff] [blame] | 657 | rte_eth_dev_stop (xd->device_index); |
John Lo | 3b2944d | 2016-07-18 18:06:14 -0400 | [diff] [blame] | 658 | |
| 659 | /* For bonded interface, stop slave links */ |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 660 | if (xd->pmd == VNET_DPDK_PMD_BOND) |
| 661 | { |
| 662 | u8 slink[16]; |
| 663 | int nlink = rte_eth_bond_slaves_get (xd->device_index, slink, 16); |
| 664 | while (nlink >= 1) |
John Lo | 3b2944d | 2016-07-18 18:06:14 -0400 | [diff] [blame] | 665 | { |
| 666 | u8 dpdk_port = slink[--nlink]; |
| 667 | rte_eth_dev_stop (dpdk_port); |
| 668 | } |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 669 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 670 | } |
| 671 | |
| 672 | if (rv < 0) |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 673 | clib_warning ("rte_eth_dev_%s error: %d", is_up ? "start" : "stop", rv); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 674 | |
| 675 | return /* no error */ 0; |
| 676 | } |
| 677 | |
| 678 | /* |
| 679 | * Dynamically redirect all pkts from a specific interface |
| 680 | * to the specified node |
| 681 | */ |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 682 | static void |
| 683 | dpdk_set_interface_next_node (vnet_main_t * vnm, u32 hw_if_index, |
| 684 | u32 node_index) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 685 | { |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 686 | dpdk_main_t *xm = &dpdk_main; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 687 | vnet_hw_interface_t *hw = vnet_get_hw_interface (vnm, hw_if_index); |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 688 | dpdk_device_t *xd = vec_elt_at_index (xm->devices, hw->dev_instance); |
| 689 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 690 | /* Shut off redirection */ |
| 691 | if (node_index == ~0) |
| 692 | { |
| 693 | xd->per_interface_next_index = node_index; |
| 694 | return; |
| 695 | } |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 696 | |
| 697 | xd->per_interface_next_index = |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 698 | vlib_node_add_next (xm->vlib_main, dpdk_input_node.index, node_index); |
| 699 | } |
| 700 | |
| 701 | |
| 702 | static clib_error_t * |
| 703 | dpdk_subif_add_del_function (vnet_main_t * vnm, |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 704 | u32 hw_if_index, |
| 705 | struct vnet_sw_interface_t *st, int is_add) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 706 | { |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 707 | dpdk_main_t *xm = &dpdk_main; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 708 | vnet_hw_interface_t *hw = vnet_get_hw_interface (vnm, hw_if_index); |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 709 | dpdk_device_t *xd = vec_elt_at_index (xm->devices, hw->dev_instance); |
| 710 | vnet_sw_interface_t *t = (vnet_sw_interface_t *) st; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 711 | int r, vlan_offload; |
Damjan Marion | a7cc447 | 2016-09-19 13:31:49 +0200 | [diff] [blame] | 712 | u32 prev_subifs = xd->num_subifs; |
| 713 | clib_error_t *err = 0; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 714 | |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 715 | if (is_add) |
Damjan Marion | a7cc447 | 2016-09-19 13:31:49 +0200 | [diff] [blame] | 716 | xd->num_subifs++; |
| 717 | else if (xd->num_subifs) |
| 718 | xd->num_subifs--; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 719 | |
Damjan Marion | 5643170 | 2016-09-19 13:18:09 +0200 | [diff] [blame] | 720 | if ((xd->flags & DPDK_DEVICE_FLAG_PMD) == 0) |
Damjan Marion | a7cc447 | 2016-09-19 13:31:49 +0200 | [diff] [blame] | 721 | goto done; |
Todd Foggoa (tfoggoa) | ad8b472 | 2016-03-28 13:52:32 -0400 | [diff] [blame] | 722 | |
| 723 | /* currently we program VLANS only for IXGBE VF and I40E VF */ |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 724 | if ((xd->pmd != VNET_DPDK_PMD_IXGBEVF) && (xd->pmd != VNET_DPDK_PMD_I40EVF)) |
Damjan Marion | a7cc447 | 2016-09-19 13:31:49 +0200 | [diff] [blame] | 725 | goto done; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 726 | |
| 727 | if (t->sub.eth.flags.no_tags == 1) |
Damjan Marion | a7cc447 | 2016-09-19 13:31:49 +0200 | [diff] [blame] | 728 | goto done; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 729 | |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 730 | if ((t->sub.eth.flags.one_tag != 1) || (t->sub.eth.flags.exact_match != 1)) |
| 731 | { |
Damjan Marion | a7cc447 | 2016-09-19 13:31:49 +0200 | [diff] [blame] | 732 | xd->num_subifs = prev_subifs; |
| 733 | err = clib_error_return (0, "unsupported VLAN setup"); |
| 734 | goto done; |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 735 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 736 | |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 737 | vlan_offload = rte_eth_dev_get_vlan_offload (xd->device_index); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 738 | vlan_offload |= ETH_VLAN_FILTER_OFFLOAD; |
| 739 | |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 740 | if ((r = rte_eth_dev_set_vlan_offload (xd->device_index, vlan_offload))) |
| 741 | { |
Damjan Marion | a7cc447 | 2016-09-19 13:31:49 +0200 | [diff] [blame] | 742 | xd->num_subifs = prev_subifs; |
| 743 | err = clib_error_return (0, "rte_eth_dev_set_vlan_offload[%d]: err %d", |
| 744 | xd->device_index, r); |
| 745 | goto done; |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 746 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 747 | |
| 748 | |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 749 | if ((r = |
| 750 | rte_eth_dev_vlan_filter (xd->device_index, t->sub.eth.outer_vlan_id, |
| 751 | is_add))) |
| 752 | { |
Damjan Marion | a7cc447 | 2016-09-19 13:31:49 +0200 | [diff] [blame] | 753 | xd->num_subifs = prev_subifs; |
| 754 | err = clib_error_return (0, "rte_eth_dev_vlan_filter[%d]: err %d", |
| 755 | xd->device_index, r); |
| 756 | goto done; |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 757 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 758 | |
Damjan Marion | a7cc447 | 2016-09-19 13:31:49 +0200 | [diff] [blame] | 759 | done: |
| 760 | if (xd->num_subifs) |
| 761 | xd->flags |= DPDK_DEVICE_FLAG_HAVE_SUBIF; |
| 762 | else |
| 763 | xd->flags &= ~DPDK_DEVICE_FLAG_HAVE_SUBIF; |
| 764 | |
| 765 | return err; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 766 | } |
| 767 | |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 768 | /* *INDENT-OFF* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 769 | VNET_DEVICE_CLASS (dpdk_device_class) = { |
| 770 | .name = "dpdk", |
| 771 | .tx_function = dpdk_interface_tx, |
| 772 | .tx_function_n_errors = DPDK_TX_FUNC_N_ERROR, |
| 773 | .tx_function_error_strings = dpdk_tx_func_error_strings, |
| 774 | .format_device_name = format_dpdk_device_name, |
| 775 | .format_device = format_dpdk_device, |
| 776 | .format_tx_trace = format_dpdk_tx_dma_trace, |
| 777 | .clear_counters = dpdk_clear_hw_interface_counters, |
| 778 | .admin_up_down_function = dpdk_interface_admin_up_down, |
| 779 | .subif_add_del_function = dpdk_subif_add_del_function, |
| 780 | .rx_redirect_to_node = dpdk_set_interface_next_node, |
Pavel Kotucek | c631f2d | 2016-09-26 10:40:02 +0200 | [diff] [blame] | 781 | .mac_addr_change_function = dpdk_set_mac_address, |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 782 | }; |
| 783 | |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 784 | VLIB_DEVICE_TX_FUNCTION_MULTIARCH (dpdk_device_class, dpdk_interface_tx) |
| 785 | /* *INDENT-ON* */ |
Damjan Marion | 1c80e83 | 2016-05-11 23:07:18 +0200 | [diff] [blame] | 786 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 787 | #define UP_DOWN_FLAG_EVENT 1 |
| 788 | |
Todd Foggoa | e3eefff | 2016-05-20 22:10:34 -0400 | [diff] [blame] | 789 | uword |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 790 | admin_up_down_process (vlib_main_t * vm, |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 791 | vlib_node_runtime_t * rt, vlib_frame_t * f) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 792 | { |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 793 | clib_error_t *error = 0; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 794 | uword event_type; |
| 795 | uword *event_data = 0; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 796 | u32 sw_if_index; |
| 797 | u32 flags; |
| 798 | |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 799 | while (1) |
| 800 | { |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 801 | vlib_process_wait_for_event (vm); |
| 802 | |
| 803 | event_type = vlib_process_get_events (vm, &event_data); |
| 804 | |
| 805 | dpdk_main.admin_up_down_in_progress = 1; |
| 806 | |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 807 | switch (event_type) |
| 808 | { |
| 809 | case UP_DOWN_FLAG_EVENT: |
| 810 | { |
| 811 | if (vec_len (event_data) == 2) |
| 812 | { |
| 813 | sw_if_index = event_data[0]; |
| 814 | flags = event_data[1]; |
| 815 | error = |
| 816 | vnet_sw_interface_set_flags (vnet_get_main (), sw_if_index, |
| 817 | flags); |
| 818 | clib_error_report (error); |
| 819 | } |
| 820 | } |
| 821 | break; |
| 822 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 823 | |
| 824 | vec_reset_length (event_data); |
| 825 | |
| 826 | dpdk_main.admin_up_down_in_progress = 0; |
| 827 | |
| 828 | } |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 829 | return 0; /* or not */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 830 | } |
| 831 | |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 832 | /* *INDENT-OFF* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 833 | VLIB_REGISTER_NODE (admin_up_down_process_node,static) = { |
| 834 | .function = admin_up_down_process, |
| 835 | .type = VLIB_NODE_TYPE_PROCESS, |
| 836 | .name = "admin-up-down-process", |
| 837 | .process_log2_n_stack_bytes = 17, // 256KB |
| 838 | }; |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 839 | /* *INDENT-ON* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 840 | |
| 841 | /* |
Damjan Marion | 2566567 | 2016-08-16 18:56:08 +0200 | [diff] [blame] | 842 | * fd.io coding-style-patch-verification: ON |
| 843 | * |
| 844 | * Local Variables: |
| 845 | * eval: (c-set-style "gnu") |
| 846 | * End: |
| 847 | */ |