Damjan Marion | c517020 | 2017-10-11 14:15:47 +0200 | [diff] [blame] | 1 | /* |
| 2 | *------------------------------------------------------------------ |
Damjan Marion | 83243a0 | 2016-02-29 13:09:30 +0100 | [diff] [blame] | 3 | * af_packet.c - linux kernel packet interface |
| 4 | * |
| 5 | * Copyright (c) 2016 Cisco and/or its affiliates. |
| 6 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | * you may not use this file except in compliance with the License. |
| 8 | * You may obtain a copy of the License at: |
| 9 | * |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, software |
| 13 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | * See the License for the specific language governing permissions and |
| 16 | * limitations under the License. |
| 17 | *------------------------------------------------------------------ |
| 18 | */ |
| 19 | |
| 20 | #include <linux/if_packet.h> |
| 21 | |
| 22 | #include <vlib/vlib.h> |
| 23 | #include <vlib/unix/unix.h> |
| 24 | #include <vnet/ip/ip.h> |
| 25 | #include <vnet/ethernet/ethernet.h> |
Mohammed Hawari | 85c1943 | 2020-12-18 16:29:45 +0100 | [diff] [blame] | 26 | #include <vnet/interface/rx_queue_funcs.h> |
Damjan Marion | 2231150 | 2016-10-28 20:30:15 +0200 | [diff] [blame] | 27 | #include <vnet/feature/feature.h> |
Jakub Grajciar | 92b0275 | 2017-10-20 13:37:28 +0200 | [diff] [blame] | 28 | #include <vnet/ethernet/packet.h> |
Damjan Marion | 83243a0 | 2016-02-29 13:09:30 +0100 | [diff] [blame] | 29 | |
| 30 | #include <vnet/devices/af_packet/af_packet.h> |
Mohsin Kazmi | c1fd17b | 2022-03-22 21:40:04 +0000 | [diff] [blame] | 31 | #include <vnet/devices/virtio/virtio_std.h> |
Damjan Marion | 83243a0 | 2016-02-29 13:09:30 +0100 | [diff] [blame] | 32 | |
Mohsin Kazmi | 5a7aa51 | 2022-03-25 14:27:45 +0000 | [diff] [blame] | 33 | #define foreach_af_packet_input_error \ |
| 34 | _ (PARTIAL_PKT, "partial packet") \ |
| 35 | _ (TIMEDOUT_BLK, "timed out block") \ |
| 36 | _ (TOTAL_RECV_BLK, "total received block") |
Damjan Marion | 00a9dca | 2016-08-17 17:05:46 +0200 | [diff] [blame] | 37 | typedef enum |
| 38 | { |
Damjan Marion | 83243a0 | 2016-02-29 13:09:30 +0100 | [diff] [blame] | 39 | #define _(f,s) AF_PACKET_INPUT_ERROR_##f, |
| 40 | foreach_af_packet_input_error |
| 41 | #undef _ |
Damjan Marion | 00a9dca | 2016-08-17 17:05:46 +0200 | [diff] [blame] | 42 | AF_PACKET_INPUT_N_ERROR, |
Damjan Marion | 83243a0 | 2016-02-29 13:09:30 +0100 | [diff] [blame] | 43 | } af_packet_input_error_t; |
| 44 | |
Damjan Marion | 00a9dca | 2016-08-17 17:05:46 +0200 | [diff] [blame] | 45 | static char *af_packet_input_error_strings[] = { |
Damjan Marion | 83243a0 | 2016-02-29 13:09:30 +0100 | [diff] [blame] | 46 | #define _(n,s) s, |
Damjan Marion | 00a9dca | 2016-08-17 17:05:46 +0200 | [diff] [blame] | 47 | foreach_af_packet_input_error |
Damjan Marion | 83243a0 | 2016-02-29 13:09:30 +0100 | [diff] [blame] | 48 | #undef _ |
| 49 | }; |
| 50 | |
Damjan Marion | 00a9dca | 2016-08-17 17:05:46 +0200 | [diff] [blame] | 51 | typedef struct |
| 52 | { |
Damjan Marion | 83243a0 | 2016-02-29 13:09:30 +0100 | [diff] [blame] | 53 | u32 next_index; |
| 54 | u32 hw_if_index; |
Mohsin Kazmi | 5a7aa51 | 2022-03-25 14:27:45 +0000 | [diff] [blame] | 55 | u16 queue_id; |
Damjan Marion | 83243a0 | 2016-02-29 13:09:30 +0100 | [diff] [blame] | 56 | int block; |
Mohsin Kazmi | c1fd17b | 2022-03-22 21:40:04 +0000 | [diff] [blame] | 57 | u32 pkt_num; |
Mohsin Kazmi | 219cbcb | 2022-03-18 16:58:31 +0000 | [diff] [blame] | 58 | void *block_start; |
| 59 | block_desc_t bd; |
| 60 | tpacket3_hdr_t tph; |
Mohsin Kazmi | c1fd17b | 2022-03-22 21:40:04 +0000 | [diff] [blame] | 61 | vnet_virtio_net_hdr_t vnet_hdr; |
Damjan Marion | 83243a0 | 2016-02-29 13:09:30 +0100 | [diff] [blame] | 62 | } af_packet_input_trace_t; |
| 63 | |
Damjan Marion | 00a9dca | 2016-08-17 17:05:46 +0200 | [diff] [blame] | 64 | static u8 * |
| 65 | format_af_packet_input_trace (u8 * s, va_list * args) |
Damjan Marion | 83243a0 | 2016-02-29 13:09:30 +0100 | [diff] [blame] | 66 | { |
| 67 | CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *); |
| 68 | CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *); |
Damjan Marion | 00a9dca | 2016-08-17 17:05:46 +0200 | [diff] [blame] | 69 | af_packet_input_trace_t *t = va_arg (*args, af_packet_input_trace_t *); |
Christophe Fontaine | d3c008d | 2017-10-02 18:10:54 +0200 | [diff] [blame] | 70 | u32 indent = format_get_indent (s); |
Damjan Marion | 83243a0 | 2016-02-29 13:09:30 +0100 | [diff] [blame] | 71 | |
Mohsin Kazmi | 5a7aa51 | 2022-03-25 14:27:45 +0000 | [diff] [blame] | 72 | s = format (s, "af_packet: hw_if_index %d rx-queue %u next-index %d", |
| 73 | t->hw_if_index, t->queue_id, t->next_index); |
Damjan Marion | 83243a0 | 2016-02-29 13:09:30 +0100 | [diff] [blame] | 74 | |
Mohsin Kazmi | c1fd17b | 2022-03-22 21:40:04 +0000 | [diff] [blame] | 75 | s = format ( |
| 76 | s, "\n%Ublock %u:\n%Uaddress %p version %u seq_num %lu pkt_num %u", |
| 77 | format_white_space, indent + 2, t->block, format_white_space, indent + 4, |
| 78 | t->block_start, t->bd.version, t->bd.hdr.bh1.seq_num, t->pkt_num); |
Damjan Marion | 00a9dca | 2016-08-17 17:05:46 +0200 | [diff] [blame] | 79 | s = |
| 80 | format (s, |
Mohsin Kazmi | 219cbcb | 2022-03-18 16:58:31 +0000 | [diff] [blame] | 81 | "\n%Utpacket3_hdr:\n%Ustatus 0x%x len %u snaplen %u mac %u net %u" |
Damjan Marion | 00a9dca | 2016-08-17 17:05:46 +0200 | [diff] [blame] | 82 | "\n%Usec 0x%x nsec 0x%x vlan %U" |
Damjan Marion | 83243a0 | 2016-02-29 13:09:30 +0100 | [diff] [blame] | 83 | #ifdef TP_STATUS_VLAN_TPID_VALID |
Damjan Marion | 00a9dca | 2016-08-17 17:05:46 +0200 | [diff] [blame] | 84 | " vlan_tpid %u" |
Damjan Marion | 83243a0 | 2016-02-29 13:09:30 +0100 | [diff] [blame] | 85 | #endif |
Damjan Marion | 00a9dca | 2016-08-17 17:05:46 +0200 | [diff] [blame] | 86 | , |
Mohsin Kazmi | 219cbcb | 2022-03-18 16:58:31 +0000 | [diff] [blame] | 87 | format_white_space, indent + 2, format_white_space, indent + 4, |
| 88 | t->tph.tp_status, t->tph.tp_len, t->tph.tp_snaplen, t->tph.tp_mac, |
| 89 | t->tph.tp_net, format_white_space, indent + 4, t->tph.tp_sec, |
| 90 | t->tph.tp_nsec, format_ethernet_vlan_tci, t->tph.hv1.tp_vlan_tci |
Damjan Marion | 83243a0 | 2016-02-29 13:09:30 +0100 | [diff] [blame] | 91 | #ifdef TP_STATUS_VLAN_TPID_VALID |
Mohsin Kazmi | 219cbcb | 2022-03-18 16:58:31 +0000 | [diff] [blame] | 92 | , |
| 93 | t->tph.hv1.tp_vlan_tpid |
Damjan Marion | 83243a0 | 2016-02-29 13:09:30 +0100 | [diff] [blame] | 94 | #endif |
Damjan Marion | 00a9dca | 2016-08-17 17:05:46 +0200 | [diff] [blame] | 95 | ); |
Mohsin Kazmi | c1fd17b | 2022-03-22 21:40:04 +0000 | [diff] [blame] | 96 | |
| 97 | s = format (s, |
| 98 | "\n%Uvnet-hdr:\n%Uflags 0x%02x gso_type 0x%02x hdr_len %u" |
| 99 | "\n%Ugso_size %u csum_start %u csum_offset %u", |
| 100 | format_white_space, indent + 2, format_white_space, indent + 4, |
| 101 | t->vnet_hdr.flags, t->vnet_hdr.gso_type, t->vnet_hdr.hdr_len, |
| 102 | format_white_space, indent + 4, t->vnet_hdr.gso_size, |
| 103 | t->vnet_hdr.csum_start, t->vnet_hdr.csum_offset); |
Damjan Marion | 83243a0 | 2016-02-29 13:09:30 +0100 | [diff] [blame] | 104 | return s; |
| 105 | } |
| 106 | |
| 107 | always_inline void |
Mohsin Kazmi | c1fd17b | 2022-03-22 21:40:04 +0000 | [diff] [blame] | 108 | buffer_add_to_chain (vlib_buffer_t *b, vlib_buffer_t *first_b, |
| 109 | vlib_buffer_t *prev_b, u32 bi) |
Damjan Marion | 83243a0 | 2016-02-29 13:09:30 +0100 | [diff] [blame] | 110 | { |
Damjan Marion | 83243a0 | 2016-02-29 13:09:30 +0100 | [diff] [blame] | 111 | /* update first buffer */ |
Damjan Marion | 00a9dca | 2016-08-17 17:05:46 +0200 | [diff] [blame] | 112 | first_b->total_length_not_including_first_buffer += b->current_length; |
Damjan Marion | 83243a0 | 2016-02-29 13:09:30 +0100 | [diff] [blame] | 113 | |
| 114 | /* update previous buffer */ |
| 115 | prev_b->next_buffer = bi; |
| 116 | prev_b->flags |= VLIB_BUFFER_NEXT_PRESENT; |
| 117 | |
| 118 | /* update current buffer */ |
Mohsin Kazmi | c1fd17b | 2022-03-22 21:40:04 +0000 | [diff] [blame] | 119 | b->next_buffer = ~0; |
Damjan Marion | 83243a0 | 2016-02-29 13:09:30 +0100 | [diff] [blame] | 120 | } |
| 121 | |
Jakub Grajciar | 92b0275 | 2017-10-20 13:37:28 +0200 | [diff] [blame] | 122 | static_always_inline void |
Mohsin Kazmi | c1fd17b | 2022-03-22 21:40:04 +0000 | [diff] [blame] | 123 | fill_gso_offload (vlib_buffer_t *b, u32 gso_size, u8 l4_hdr_sz) |
Nathan Skrzypczak | ffc6bdc | 2021-02-01 17:13:59 +0100 | [diff] [blame] | 124 | { |
| 125 | b->flags |= VNET_BUFFER_F_GSO; |
| 126 | vnet_buffer2 (b)->gso_size = gso_size; |
| 127 | vnet_buffer2 (b)->gso_l4_hdr_sz = l4_hdr_sz; |
| 128 | } |
| 129 | |
| 130 | static_always_inline void |
Mohsin Kazmi | c1fd17b | 2022-03-22 21:40:04 +0000 | [diff] [blame] | 131 | fill_cksum_offload (vlib_buffer_t *b, u8 *l4_hdr_sz, u8 is_ip) |
Jakub Grajciar | 92b0275 | 2017-10-20 13:37:28 +0200 | [diff] [blame] | 132 | { |
Mohsin Kazmi | 36f7a6a | 2021-05-05 14:26:38 +0200 | [diff] [blame] | 133 | vnet_buffer_oflags_t oflags = 0; |
Mohsin Kazmi | c1fd17b | 2022-03-22 21:40:04 +0000 | [diff] [blame] | 134 | u16 l2hdr_sz = 0; |
| 135 | u16 ethertype = 0; |
| 136 | u8 l4_proto = 0; |
| 137 | |
| 138 | if (is_ip) |
Jakub Grajciar | 92b0275 | 2017-10-20 13:37:28 +0200 | [diff] [blame] | 139 | { |
Mohsin Kazmi | c1fd17b | 2022-03-22 21:40:04 +0000 | [diff] [blame] | 140 | switch (b->data[0] & 0xf0) |
Jakub Grajciar | 92b0275 | 2017-10-20 13:37:28 +0200 | [diff] [blame] | 141 | { |
Mohsin Kazmi | c1fd17b | 2022-03-22 21:40:04 +0000 | [diff] [blame] | 142 | case 0x40: |
| 143 | ethertype = ETHERNET_TYPE_IP4; |
| 144 | break; |
| 145 | case 0x60: |
| 146 | ethertype = ETHERNET_TYPE_IP6; |
| 147 | break; |
Jakub Grajciar | 92b0275 | 2017-10-20 13:37:28 +0200 | [diff] [blame] | 148 | } |
Jakub Grajciar | 92b0275 | 2017-10-20 13:37:28 +0200 | [diff] [blame] | 149 | } |
Mohsin Kazmi | c1fd17b | 2022-03-22 21:40:04 +0000 | [diff] [blame] | 150 | else |
Jakub Grajciar | 92b0275 | 2017-10-20 13:37:28 +0200 | [diff] [blame] | 151 | { |
Mohsin Kazmi | e0c8755 | 2022-04-11 12:52:28 +0000 | [diff] [blame] | 152 | ethernet_header_t *eth = (ethernet_header_t *) b->data; |
Mohsin Kazmi | c1fd17b | 2022-03-22 21:40:04 +0000 | [diff] [blame] | 153 | ethertype = clib_net_to_host_u16 (eth->type); |
| 154 | l2hdr_sz = sizeof (ethernet_header_t); |
| 155 | if (ethernet_frame_is_tagged (ethertype)) |
| 156 | { |
| 157 | ethernet_vlan_header_t *vlan = (ethernet_vlan_header_t *) (eth + 1); |
| 158 | |
| 159 | ethertype = clib_net_to_host_u16 (vlan->type); |
| 160 | l2hdr_sz += sizeof (*vlan); |
| 161 | if (ethertype == ETHERNET_TYPE_VLAN) |
| 162 | { |
| 163 | vlan++; |
| 164 | ethertype = clib_net_to_host_u16 (vlan->type); |
| 165 | l2hdr_sz += sizeof (*vlan); |
| 166 | } |
| 167 | } |
| 168 | } |
| 169 | |
| 170 | vnet_buffer (b)->l2_hdr_offset = 0; |
| 171 | vnet_buffer (b)->l3_hdr_offset = l2hdr_sz; |
| 172 | |
| 173 | if (ethertype == ETHERNET_TYPE_IP4) |
| 174 | { |
Mohsin Kazmi | e0c8755 | 2022-04-11 12:52:28 +0000 | [diff] [blame] | 175 | ip4_header_t *ip4 = (ip4_header_t *) (b->data + l2hdr_sz); |
Mohsin Kazmi | c1fd17b | 2022-03-22 21:40:04 +0000 | [diff] [blame] | 176 | vnet_buffer (b)->l4_hdr_offset = l2hdr_sz + ip4_header_bytes (ip4); |
| 177 | b->flags |= (VNET_BUFFER_F_IS_IP4 | VNET_BUFFER_F_L2_HDR_OFFSET_VALID | |
| 178 | VNET_BUFFER_F_L3_HDR_OFFSET_VALID | |
| 179 | VNET_BUFFER_F_L4_HDR_OFFSET_VALID); |
| 180 | |
| 181 | l4_proto = ip4->protocol; |
| 182 | } |
| 183 | else if (ethertype == ETHERNET_TYPE_IP6) |
| 184 | { |
Mohsin Kazmi | e0c8755 | 2022-04-11 12:52:28 +0000 | [diff] [blame] | 185 | ip6_header_t *ip6 = (ip6_header_t *) (b->data + l2hdr_sz); |
Mohsin Kazmi | c1fd17b | 2022-03-22 21:40:04 +0000 | [diff] [blame] | 186 | b->flags |= (VNET_BUFFER_F_IS_IP6 | VNET_BUFFER_F_L2_HDR_OFFSET_VALID | |
| 187 | VNET_BUFFER_F_L3_HDR_OFFSET_VALID | |
| 188 | VNET_BUFFER_F_L4_HDR_OFFSET_VALID); |
Jakub Grajciar | 92b0275 | 2017-10-20 13:37:28 +0200 | [diff] [blame] | 189 | u16 ip6_hdr_len = sizeof (ip6_header_t); |
Mohsin Kazmi | c1fd17b | 2022-03-22 21:40:04 +0000 | [diff] [blame] | 190 | |
Jakub Grajciar | 92b0275 | 2017-10-20 13:37:28 +0200 | [diff] [blame] | 191 | if (ip6_ext_hdr (ip6->protocol)) |
| 192 | { |
| 193 | ip6_ext_header_t *p = (void *) (ip6 + 1); |
| 194 | ip6_hdr_len += ip6_ext_header_len (p); |
| 195 | while (ip6_ext_hdr (p->next_hdr)) |
| 196 | { |
| 197 | ip6_hdr_len += ip6_ext_header_len (p); |
| 198 | p = ip6_ext_next_header (p); |
| 199 | } |
Mohsin Kazmi | c1fd17b | 2022-03-22 21:40:04 +0000 | [diff] [blame] | 200 | l4_proto = p->next_hdr; |
Jakub Grajciar | 92b0275 | 2017-10-20 13:37:28 +0200 | [diff] [blame] | 201 | } |
Mohsin Kazmi | c1fd17b | 2022-03-22 21:40:04 +0000 | [diff] [blame] | 202 | else |
| 203 | l4_proto = ip6->protocol; |
| 204 | vnet_buffer (b)->l4_hdr_offset = l2hdr_sz + ip6_hdr_len; |
Jakub Grajciar | 92b0275 | 2017-10-20 13:37:28 +0200 | [diff] [blame] | 205 | } |
Mohsin Kazmi | c1fd17b | 2022-03-22 21:40:04 +0000 | [diff] [blame] | 206 | |
| 207 | if (l4_proto == IP_PROTOCOL_TCP) |
| 208 | { |
| 209 | oflags |= VNET_BUFFER_OFFLOAD_F_TCP_CKSUM; |
Mohsin Kazmi | e0c8755 | 2022-04-11 12:52:28 +0000 | [diff] [blame] | 210 | tcp_header_t *tcp = |
| 211 | (tcp_header_t *) (b->data + vnet_buffer (b)->l4_hdr_offset); |
Mohsin Kazmi | c1fd17b | 2022-03-22 21:40:04 +0000 | [diff] [blame] | 212 | *l4_hdr_sz = tcp_header_bytes (tcp); |
| 213 | } |
| 214 | else if (l4_proto == IP_PROTOCOL_UDP) |
| 215 | { |
| 216 | oflags |= VNET_BUFFER_OFFLOAD_F_UDP_CKSUM; |
| 217 | *l4_hdr_sz = sizeof (udp_header_t); |
| 218 | } |
| 219 | |
| 220 | if (oflags) |
| 221 | vnet_buffer_offload_flags_set (b, oflags); |
Jakub Grajciar | 92b0275 | 2017-10-20 13:37:28 +0200 | [diff] [blame] | 222 | } |
| 223 | |
Damjan Marion | 83243a0 | 2016-02-29 13:09:30 +0100 | [diff] [blame] | 224 | always_inline uword |
Mohsin Kazmi | c1fd17b | 2022-03-22 21:40:04 +0000 | [diff] [blame] | 225 | af_packet_device_input_fn (vlib_main_t *vm, vlib_node_runtime_t *node, |
| 226 | vlib_frame_t *frame, af_packet_if_t *apif, |
Mohsin Kazmi | 5a7aa51 | 2022-03-25 14:27:45 +0000 | [diff] [blame] | 227 | u16 queue_id, u8 is_cksum_gso_enabled) |
Damjan Marion | 83243a0 | 2016-02-29 13:09:30 +0100 | [diff] [blame] | 228 | { |
Damjan Marion | 00a9dca | 2016-08-17 17:05:46 +0200 | [diff] [blame] | 229 | af_packet_main_t *apm = &af_packet_main; |
Mohsin Kazmi | 5a7aa51 | 2022-03-25 14:27:45 +0000 | [diff] [blame] | 230 | af_packet_queue_t *rx_queue = vec_elt_at_index (apif->rx_queues, queue_id); |
Mohsin Kazmi | 219cbcb | 2022-03-18 16:58:31 +0000 | [diff] [blame] | 231 | tpacket3_hdr_t *tph; |
Mohsin Kazmi | cae84fa | 2021-10-08 15:10:49 +0000 | [diff] [blame] | 232 | u32 next_index; |
Damjan Marion | 83243a0 | 2016-02-29 13:09:30 +0100 | [diff] [blame] | 233 | u32 n_free_bufs; |
| 234 | u32 n_rx_packets = 0; |
| 235 | u32 n_rx_bytes = 0; |
Mohsin Kazmi | 5a7aa51 | 2022-03-25 14:27:45 +0000 | [diff] [blame] | 236 | u32 timedout_blk = 0; |
| 237 | u32 total = 0; |
Damjan Marion | 00a9dca | 2016-08-17 17:05:46 +0200 | [diff] [blame] | 238 | u32 *to_next = 0; |
Mohsin Kazmi | 5a7aa51 | 2022-03-25 14:27:45 +0000 | [diff] [blame] | 239 | u32 block = rx_queue->next_rx_block; |
| 240 | u32 block_nr = rx_queue->rx_req->tp_block_nr; |
Mohsin Kazmi | 219cbcb | 2022-03-18 16:58:31 +0000 | [diff] [blame] | 241 | u8 *block_start = 0; |
Damjan Marion | 83243a0 | 2016-02-29 13:09:30 +0100 | [diff] [blame] | 242 | uword n_trace = vlib_get_trace_count (vm, node); |
Damjan Marion | 067cd62 | 2018-07-11 12:47:43 +0200 | [diff] [blame] | 243 | u32 thread_index = vm->thread_index; |
Damjan Marion | 8934a04 | 2019-02-09 23:29:26 +0100 | [diff] [blame] | 244 | u32 n_buffer_bytes = vlib_buffer_get_default_data_size (vm); |
Mohsin Kazmi | 5a7aa51 | 2022-03-25 14:27:45 +0000 | [diff] [blame] | 245 | u32 min_bufs = rx_queue->rx_req->tp_frame_size / n_buffer_bytes; |
Mohsin Kazmi | 219cbcb | 2022-03-18 16:58:31 +0000 | [diff] [blame] | 246 | u32 num_pkts = 0; |
| 247 | u32 rx_frame_offset = 0; |
| 248 | block_desc_t *bd = 0; |
Mohsin Kazmi | 6556a99 | 2022-08-31 11:14:28 +0000 | [diff] [blame^] | 249 | vlib_buffer_t bt = {}; |
Mohsin Kazmi | c1fd17b | 2022-03-22 21:40:04 +0000 | [diff] [blame] | 250 | u8 is_ip = (apif->mode == AF_PACKET_IF_MODE_IP); |
Mohsin Kazmi | cae84fa | 2021-10-08 15:10:49 +0000 | [diff] [blame] | 251 | |
Mohsin Kazmi | c1fd17b | 2022-03-22 21:40:04 +0000 | [diff] [blame] | 252 | if (is_ip) |
| 253 | next_index = VNET_DEVICE_INPUT_NEXT_IP4_INPUT; |
Mohsin Kazmi | cae84fa | 2021-10-08 15:10:49 +0000 | [diff] [blame] | 254 | else |
| 255 | { |
| 256 | next_index = VNET_DEVICE_INPUT_NEXT_ETHERNET_INPUT; |
| 257 | if (PREDICT_FALSE (apif->per_interface_next_index != ~0)) |
| 258 | next_index = apif->per_interface_next_index; |
| 259 | |
| 260 | /* redirect if feature path enabled */ |
| 261 | vnet_feature_start_device_input_x1 (apif->sw_if_index, &next_index, &bt); |
| 262 | } |
Damjan Marion | 83243a0 | 2016-02-29 13:09:30 +0100 | [diff] [blame] | 263 | |
Mohsin Kazmi | 5a7aa51 | 2022-03-25 14:27:45 +0000 | [diff] [blame] | 264 | if ((((block_desc_t *) (block_start = rx_queue->rx_ring[block])) |
Mohsin Kazmi | 89d74bd | 2022-03-25 00:33:27 +0000 | [diff] [blame] | 265 | ->hdr.bh1.block_status & |
| 266 | TP_STATUS_USER) != 0) |
Damjan Marion | 83243a0 | 2016-02-29 13:09:30 +0100 | [diff] [blame] | 267 | { |
Mohsin Kazmi | 219cbcb | 2022-03-18 16:58:31 +0000 | [diff] [blame] | 268 | u32 n_required = 0; |
Mohsin Kazmi | 89d74bd | 2022-03-25 00:33:27 +0000 | [diff] [blame] | 269 | bd = (block_desc_t *) block_start; |
Damjan Marion | 83243a0 | 2016-02-29 13:09:30 +0100 | [diff] [blame] | 270 | |
Mohsin Kazmi | 5a7aa51 | 2022-03-25 14:27:45 +0000 | [diff] [blame] | 271 | if (PREDICT_FALSE (rx_queue->is_rx_pending)) |
Damjan Marion | 83243a0 | 2016-02-29 13:09:30 +0100 | [diff] [blame] | 272 | { |
Mohsin Kazmi | 5a7aa51 | 2022-03-25 14:27:45 +0000 | [diff] [blame] | 273 | num_pkts = rx_queue->num_rx_pkts; |
| 274 | rx_frame_offset = rx_queue->rx_frame_offset; |
| 275 | rx_queue->is_rx_pending = 0; |
Mohsin Kazmi | 89d74bd | 2022-03-25 00:33:27 +0000 | [diff] [blame] | 276 | } |
| 277 | else |
| 278 | { |
Mohsin Kazmi | 219cbcb | 2022-03-18 16:58:31 +0000 | [diff] [blame] | 279 | num_pkts = bd->hdr.bh1.num_pkts; |
| 280 | rx_frame_offset = sizeof (block_desc_t); |
Mohsin Kazmi | a94563e | 2022-04-05 11:23:17 +0000 | [diff] [blame] | 281 | total++; |
| 282 | |
| 283 | if (TP_STATUS_BLK_TMO & bd->hdr.bh1.block_status) |
| 284 | timedout_blk++; |
Damjan Marion | 83243a0 | 2016-02-29 13:09:30 +0100 | [diff] [blame] | 285 | } |
| 286 | |
Mohsin Kazmi | 219cbcb | 2022-03-18 16:58:31 +0000 | [diff] [blame] | 287 | n_required = clib_max (num_pkts, VLIB_FRAME_SIZE); |
| 288 | n_free_bufs = vec_len (apm->rx_buffers[thread_index]); |
| 289 | if (PREDICT_FALSE (n_free_bufs < n_required)) |
| 290 | { |
| 291 | vec_validate (apm->rx_buffers[thread_index], |
| 292 | n_required + n_free_bufs - 1); |
| 293 | n_free_bufs += vlib_buffer_alloc ( |
| 294 | vm, &apm->rx_buffers[thread_index][n_free_bufs], n_required); |
Damjan Marion | 8bea589 | 2022-04-04 22:40:45 +0200 | [diff] [blame] | 295 | vec_set_len (apm->rx_buffers[thread_index], n_free_bufs); |
Mohsin Kazmi | 219cbcb | 2022-03-18 16:58:31 +0000 | [diff] [blame] | 296 | } |
| 297 | |
Mohsin Kazmi | 89d74bd | 2022-03-25 00:33:27 +0000 | [diff] [blame] | 298 | while (num_pkts && (n_free_bufs >= min_bufs)) |
Mohsin Kazmi | 219cbcb | 2022-03-18 16:58:31 +0000 | [diff] [blame] | 299 | { |
Mohsin Kazmi | 219cbcb | 2022-03-18 16:58:31 +0000 | [diff] [blame] | 300 | u32 next0 = next_index; |
| 301 | u32 n_left_to_next; |
Mohsin Kazmi | c1fd17b | 2022-03-22 21:40:04 +0000 | [diff] [blame] | 302 | |
Mohsin Kazmi | 219cbcb | 2022-03-18 16:58:31 +0000 | [diff] [blame] | 303 | vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next); |
Mohsin Kazmi | c1fd17b | 2022-03-22 21:40:04 +0000 | [diff] [blame] | 304 | |
Mohsin Kazmi | 89d74bd | 2022-03-25 00:33:27 +0000 | [diff] [blame] | 305 | while (num_pkts && n_left_to_next && (n_free_bufs >= min_bufs)) |
Mohsin Kazmi | 219cbcb | 2022-03-18 16:58:31 +0000 | [diff] [blame] | 306 | { |
| 307 | tph = (tpacket3_hdr_t *) (block_start + rx_frame_offset); |
| 308 | |
| 309 | if (num_pkts > 1) |
| 310 | CLIB_PREFETCH (block_start + rx_frame_offset + |
| 311 | tph->tp_next_offset, |
| 312 | 2 * CLIB_CACHE_LINE_BYTES, LOAD); |
Mohsin Kazmi | c1fd17b | 2022-03-22 21:40:04 +0000 | [diff] [blame] | 313 | |
| 314 | vlib_buffer_t *b0 = 0, *first_b0 = 0, *prev_b0 = 0; |
| 315 | vnet_virtio_net_hdr_t *vnet_hdr = 0; |
Mohsin Kazmi | 219cbcb | 2022-03-18 16:58:31 +0000 | [diff] [blame] | 316 | u32 data_len = tph->tp_snaplen; |
| 317 | u32 offset = 0; |
Mohsin Kazmi | c1fd17b | 2022-03-22 21:40:04 +0000 | [diff] [blame] | 318 | u32 bi0 = ~0, first_bi0 = ~0; |
Mohsin Kazmi | 219cbcb | 2022-03-18 16:58:31 +0000 | [diff] [blame] | 319 | u8 l4_hdr_sz = 0; |
| 320 | |
Mohsin Kazmi | c1fd17b | 2022-03-22 21:40:04 +0000 | [diff] [blame] | 321 | if (is_cksum_gso_enabled) |
| 322 | vnet_hdr = |
| 323 | (vnet_virtio_net_hdr_t *) ((u8 *) tph + tph->tp_mac - |
| 324 | sizeof (vnet_virtio_net_hdr_t)); |
| 325 | |
Mohsin Kazmi | 89d74bd | 2022-03-25 00:33:27 +0000 | [diff] [blame] | 326 | // save current state and return |
Mohsin Kazmi | c1fd17b | 2022-03-22 21:40:04 +0000 | [diff] [blame] | 327 | if (PREDICT_FALSE (((data_len / n_buffer_bytes) + 1) > |
| 328 | vec_len (apm->rx_buffers[thread_index]))) |
| 329 | { |
Mohsin Kazmi | 5a7aa51 | 2022-03-25 14:27:45 +0000 | [diff] [blame] | 330 | rx_queue->rx_frame_offset = rx_frame_offset; |
| 331 | rx_queue->num_rx_pkts = num_pkts; |
| 332 | rx_queue->is_rx_pending = 1; |
Mohsin Kazmi | 89d74bd | 2022-03-25 00:33:27 +0000 | [diff] [blame] | 333 | vlib_put_next_frame (vm, node, next_index, n_left_to_next); |
| 334 | goto done; |
Mohsin Kazmi | c1fd17b | 2022-03-22 21:40:04 +0000 | [diff] [blame] | 335 | } |
| 336 | |
Mohsin Kazmi | 219cbcb | 2022-03-18 16:58:31 +0000 | [diff] [blame] | 337 | while (data_len) |
| 338 | { |
| 339 | /* grab free buffer */ |
| 340 | u32 last_empty_buffer = |
| 341 | vec_len (apm->rx_buffers[thread_index]) - 1; |
Mohsin Kazmi | 219cbcb | 2022-03-18 16:58:31 +0000 | [diff] [blame] | 342 | bi0 = apm->rx_buffers[thread_index][last_empty_buffer]; |
Damjan Marion | 8bea589 | 2022-04-04 22:40:45 +0200 | [diff] [blame] | 343 | vec_set_len (apm->rx_buffers[thread_index], |
| 344 | last_empty_buffer); |
Mohsin Kazmi | 219cbcb | 2022-03-18 16:58:31 +0000 | [diff] [blame] | 345 | n_free_bufs--; |
| 346 | |
| 347 | /* copy data */ |
| 348 | u32 bytes_to_copy = |
| 349 | data_len > n_buffer_bytes ? n_buffer_bytes : data_len; |
| 350 | u32 vlan_len = 0; |
| 351 | u32 bytes_copied = 0; |
Mohsin Kazmi | c1fd17b | 2022-03-22 21:40:04 +0000 | [diff] [blame] | 352 | |
| 353 | b0 = vlib_get_buffer (vm, bi0); |
Mohsin Kazmi | 219cbcb | 2022-03-18 16:58:31 +0000 | [diff] [blame] | 354 | b0->current_data = 0; |
Mohsin Kazmi | c1fd17b | 2022-03-22 21:40:04 +0000 | [diff] [blame] | 355 | |
Mohsin Kazmi | 219cbcb | 2022-03-18 16:58:31 +0000 | [diff] [blame] | 356 | /* Kernel removes VLAN headers, so reconstruct VLAN */ |
| 357 | if (PREDICT_FALSE (tph->tp_status & TP_STATUS_VLAN_VALID)) |
| 358 | { |
| 359 | if (PREDICT_TRUE (offset == 0)) |
| 360 | { |
| 361 | clib_memcpy_fast (vlib_buffer_get_current (b0), |
| 362 | (u8 *) tph + tph->tp_mac, |
| 363 | sizeof (ethernet_header_t)); |
| 364 | ethernet_header_t *eth = |
| 365 | vlib_buffer_get_current (b0); |
| 366 | ethernet_vlan_header_t *vlan = |
| 367 | (ethernet_vlan_header_t *) (eth + 1); |
| 368 | vlan->priority_cfi_and_id = |
| 369 | clib_host_to_net_u16 (tph->hv1.tp_vlan_tci); |
| 370 | vlan->type = eth->type; |
| 371 | eth->type = |
| 372 | clib_host_to_net_u16 (ETHERNET_TYPE_VLAN); |
| 373 | vlan_len = sizeof (ethernet_vlan_header_t); |
| 374 | bytes_copied = sizeof (ethernet_header_t); |
| 375 | } |
| 376 | } |
| 377 | clib_memcpy_fast (((u8 *) vlib_buffer_get_current (b0)) + |
| 378 | bytes_copied + vlan_len, |
| 379 | (u8 *) tph + tph->tp_mac + offset + |
| 380 | bytes_copied, |
| 381 | (bytes_to_copy - bytes_copied)); |
| 382 | |
| 383 | /* fill buffer header */ |
| 384 | b0->current_length = bytes_to_copy + vlan_len; |
| 385 | |
| 386 | if (offset == 0) |
| 387 | { |
| 388 | b0->total_length_not_including_first_buffer = 0; |
| 389 | b0->flags = VLIB_BUFFER_TOTAL_LENGTH_VALID; |
| 390 | vnet_buffer (b0)->sw_if_index[VLIB_RX] = |
| 391 | apif->sw_if_index; |
| 392 | vnet_buffer (b0)->sw_if_index[VLIB_TX] = (u32) ~0; |
Mohsin Kazmi | c1fd17b | 2022-03-22 21:40:04 +0000 | [diff] [blame] | 393 | first_b0 = b0; |
Mohsin Kazmi | 219cbcb | 2022-03-18 16:58:31 +0000 | [diff] [blame] | 394 | first_bi0 = bi0; |
Mohsin Kazmi | c1fd17b | 2022-03-22 21:40:04 +0000 | [diff] [blame] | 395 | if (is_cksum_gso_enabled) |
| 396 | { |
| 397 | if (vnet_hdr->flags & VIRTIO_NET_HDR_F_NEEDS_CSUM) |
| 398 | fill_cksum_offload (first_b0, &l4_hdr_sz, is_ip); |
| 399 | if (vnet_hdr->gso_type & (VIRTIO_NET_HDR_GSO_TCPV4 | |
| 400 | VIRTIO_NET_HDR_GSO_TCPV6)) |
| 401 | fill_gso_offload (first_b0, vnet_hdr->gso_size, |
| 402 | l4_hdr_sz); |
| 403 | } |
Mohsin Kazmi | 219cbcb | 2022-03-18 16:58:31 +0000 | [diff] [blame] | 404 | } |
| 405 | else |
Mohsin Kazmi | c1fd17b | 2022-03-22 21:40:04 +0000 | [diff] [blame] | 406 | buffer_add_to_chain (b0, first_b0, prev_b0, bi0); |
Mohsin Kazmi | 219cbcb | 2022-03-18 16:58:31 +0000 | [diff] [blame] | 407 | |
Mohsin Kazmi | c1fd17b | 2022-03-22 21:40:04 +0000 | [diff] [blame] | 408 | prev_b0 = b0; |
Mohsin Kazmi | 219cbcb | 2022-03-18 16:58:31 +0000 | [diff] [blame] | 409 | offset += bytes_to_copy; |
| 410 | data_len -= bytes_to_copy; |
| 411 | } |
| 412 | n_rx_packets++; |
| 413 | n_rx_bytes += tph->tp_snaplen; |
| 414 | to_next[0] = first_bi0; |
| 415 | to_next += 1; |
| 416 | n_left_to_next--; |
| 417 | |
| 418 | /* drop partial packets */ |
| 419 | if (PREDICT_FALSE (tph->tp_len != tph->tp_snaplen)) |
| 420 | { |
| 421 | next0 = VNET_DEVICE_INPUT_NEXT_DROP; |
| 422 | first_b0->error = |
| 423 | node->errors[AF_PACKET_INPUT_ERROR_PARTIAL_PKT]; |
| 424 | } |
| 425 | else |
| 426 | { |
| 427 | if (PREDICT_FALSE (apif->mode == AF_PACKET_IF_MODE_IP)) |
| 428 | { |
| 429 | switch (first_b0->data[0] & 0xf0) |
| 430 | { |
| 431 | case 0x40: |
| 432 | next0 = VNET_DEVICE_INPUT_NEXT_IP4_INPUT; |
| 433 | break; |
| 434 | case 0x60: |
| 435 | next0 = VNET_DEVICE_INPUT_NEXT_IP6_INPUT; |
| 436 | break; |
| 437 | default: |
| 438 | next0 = VNET_DEVICE_INPUT_NEXT_DROP; |
| 439 | break; |
| 440 | } |
| 441 | if (PREDICT_FALSE (apif->per_interface_next_index != ~0)) |
| 442 | next0 = apif->per_interface_next_index; |
| 443 | } |
| 444 | else |
| 445 | { |
| 446 | /* copy feature arc data from template */ |
| 447 | first_b0->current_config_index = bt.current_config_index; |
| 448 | vnet_buffer (first_b0)->feature_arc_index = |
| 449 | vnet_buffer (&bt)->feature_arc_index; |
| 450 | } |
| 451 | } |
| 452 | |
| 453 | /* trace */ |
| 454 | if (PREDICT_FALSE (n_trace > 0 && |
| 455 | vlib_trace_buffer (vm, node, next0, first_b0, |
| 456 | /* follow_chain */ 0))) |
| 457 | { |
| 458 | af_packet_input_trace_t *tr; |
| 459 | vlib_set_trace_count (vm, node, --n_trace); |
| 460 | tr = vlib_add_trace (vm, node, first_b0, sizeof (*tr)); |
| 461 | tr->next_index = next0; |
| 462 | tr->hw_if_index = apif->hw_if_index; |
Mohsin Kazmi | 5a7aa51 | 2022-03-25 14:27:45 +0000 | [diff] [blame] | 463 | tr->queue_id = queue_id; |
Mohsin Kazmi | 219cbcb | 2022-03-18 16:58:31 +0000 | [diff] [blame] | 464 | tr->block = block; |
| 465 | tr->block_start = bd; |
Mohsin Kazmi | c1fd17b | 2022-03-22 21:40:04 +0000 | [diff] [blame] | 466 | tr->pkt_num = bd->hdr.bh1.num_pkts - num_pkts; |
Mohsin Kazmi | 219cbcb | 2022-03-18 16:58:31 +0000 | [diff] [blame] | 467 | clib_memcpy_fast (&tr->bd, bd, sizeof (block_desc_t)); |
| 468 | clib_memcpy_fast (&tr->tph, tph, sizeof (tpacket3_hdr_t)); |
Mohsin Kazmi | c1fd17b | 2022-03-22 21:40:04 +0000 | [diff] [blame] | 469 | if (is_cksum_gso_enabled) |
| 470 | clib_memcpy_fast (&tr->vnet_hdr, vnet_hdr, |
| 471 | sizeof (vnet_virtio_net_hdr_t)); |
| 472 | else |
| 473 | clib_memset_u8 (&tr->vnet_hdr, 0, |
| 474 | sizeof (vnet_virtio_net_hdr_t)); |
Mohsin Kazmi | 219cbcb | 2022-03-18 16:58:31 +0000 | [diff] [blame] | 475 | } |
| 476 | |
| 477 | /* enque and take next packet */ |
| 478 | vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next, |
| 479 | n_left_to_next, first_bi0, |
| 480 | next0); |
| 481 | |
| 482 | /* next packet */ |
| 483 | num_pkts--; |
| 484 | rx_frame_offset += tph->tp_next_offset; |
| 485 | } |
| 486 | |
| 487 | vlib_put_next_frame (vm, node, next_index, n_left_to_next); |
| 488 | } |
| 489 | |
| 490 | if (PREDICT_TRUE (num_pkts == 0)) |
| 491 | { |
| 492 | bd->hdr.bh1.block_status = TP_STATUS_KERNEL; |
| 493 | block = (block + 1) % block_nr; |
| 494 | } |
Mohsin Kazmi | 89d74bd | 2022-03-25 00:33:27 +0000 | [diff] [blame] | 495 | else |
| 496 | { |
Mohsin Kazmi | 5a7aa51 | 2022-03-25 14:27:45 +0000 | [diff] [blame] | 497 | rx_queue->rx_frame_offset = rx_frame_offset; |
| 498 | rx_queue->num_rx_pkts = num_pkts; |
| 499 | rx_queue->is_rx_pending = 1; |
Mohsin Kazmi | 89d74bd | 2022-03-25 00:33:27 +0000 | [diff] [blame] | 500 | } |
Damjan Marion | 83243a0 | 2016-02-29 13:09:30 +0100 | [diff] [blame] | 501 | } |
| 502 | |
Mohsin Kazmi | 5a7aa51 | 2022-03-25 14:27:45 +0000 | [diff] [blame] | 503 | rx_queue->next_rx_block = block; |
Mohsin Kazmi | 89d74bd | 2022-03-25 00:33:27 +0000 | [diff] [blame] | 504 | |
| 505 | done: |
| 506 | |
Mohsin Kazmi | 89733a1 | 2022-08-30 13:29:06 +0000 | [diff] [blame] | 507 | if (apm->polling_count == 0) |
| 508 | { |
| 509 | if ((((block_desc_t *) (block_start = rx_queue->rx_ring[block])) |
| 510 | ->hdr.bh1.block_status & |
| 511 | TP_STATUS_USER) != 0) |
| 512 | vlib_node_set_state (vm, node->node_index, VLIB_NODE_STATE_POLLING); |
| 513 | else |
| 514 | vlib_node_set_state (vm, node->node_index, VLIB_NODE_STATE_INTERRUPT); |
| 515 | } |
Mohsin Kazmi | 89d74bd | 2022-03-25 00:33:27 +0000 | [diff] [blame] | 516 | |
Mohsin Kazmi | 5a7aa51 | 2022-03-25 14:27:45 +0000 | [diff] [blame] | 517 | vlib_error_count (vm, node->node_index, AF_PACKET_INPUT_ERROR_TOTAL_RECV_BLK, |
| 518 | total); |
| 519 | vlib_error_count (vm, node->node_index, AF_PACKET_INPUT_ERROR_TIMEDOUT_BLK, |
| 520 | timedout_blk); |
| 521 | |
Damjan Marion | 83243a0 | 2016-02-29 13:09:30 +0100 | [diff] [blame] | 522 | vlib_increment_combined_counter |
Damjan Marion | 00a9dca | 2016-08-17 17:05:46 +0200 | [diff] [blame] | 523 | (vnet_get_main ()->interface_main.combined_sw_if_counters |
Damjan Marion | 83243a0 | 2016-02-29 13:09:30 +0100 | [diff] [blame] | 524 | + VNET_INTERFACE_COUNTER_RX, |
Damjan Marion | 586afd7 | 2017-04-05 19:18:20 +0200 | [diff] [blame] | 525 | vlib_get_thread_index (), apif->hw_if_index, n_rx_packets, n_rx_bytes); |
Damjan Marion | 83243a0 | 2016-02-29 13:09:30 +0100 | [diff] [blame] | 526 | |
Damjan Marion | 586afd7 | 2017-04-05 19:18:20 +0200 | [diff] [blame] | 527 | vnet_device_increment_rx_packets (thread_index, n_rx_packets); |
Damjan Marion | 83243a0 | 2016-02-29 13:09:30 +0100 | [diff] [blame] | 528 | return n_rx_packets; |
| 529 | } |
| 530 | |
Filip Tehlar | 608996d | 2019-03-04 03:03:13 -0800 | [diff] [blame] | 531 | VLIB_NODE_FN (af_packet_input_node) (vlib_main_t * vm, |
| 532 | vlib_node_runtime_t * node, |
| 533 | vlib_frame_t * frame) |
Damjan Marion | 83243a0 | 2016-02-29 13:09:30 +0100 | [diff] [blame] | 534 | { |
Damjan Marion | 83243a0 | 2016-02-29 13:09:30 +0100 | [diff] [blame] | 535 | u32 n_rx_packets = 0; |
Damjan Marion | 00a9dca | 2016-08-17 17:05:46 +0200 | [diff] [blame] | 536 | af_packet_main_t *apm = &af_packet_main; |
Mohammed Hawari | 85c1943 | 2020-12-18 16:29:45 +0100 | [diff] [blame] | 537 | vnet_hw_if_rxq_poll_vector_t *pv; |
| 538 | pv = vnet_hw_if_get_rxq_poll_vector (vm, node); |
| 539 | for (int i = 0; i < vec_len (pv); i++) |
| 540 | { |
| 541 | af_packet_if_t *apif; |
| 542 | apif = vec_elt_at_index (apm->interfaces, pv[i].dev_instance); |
| 543 | if (apif->is_admin_up) |
Mohsin Kazmi | c1fd17b | 2022-03-22 21:40:04 +0000 | [diff] [blame] | 544 | { |
| 545 | if (apif->is_cksum_gso_enabled) |
Mohsin Kazmi | 5a7aa51 | 2022-03-25 14:27:45 +0000 | [diff] [blame] | 546 | n_rx_packets += af_packet_device_input_fn (vm, node, frame, apif, |
| 547 | pv[i].queue_id, 1); |
Mohsin Kazmi | c1fd17b | 2022-03-22 21:40:04 +0000 | [diff] [blame] | 548 | else |
Mohsin Kazmi | 5a7aa51 | 2022-03-25 14:27:45 +0000 | [diff] [blame] | 549 | n_rx_packets += af_packet_device_input_fn (vm, node, frame, apif, |
| 550 | pv[i].queue_id, 0); |
Mohsin Kazmi | c1fd17b | 2022-03-22 21:40:04 +0000 | [diff] [blame] | 551 | } |
Mohammed Hawari | 85c1943 | 2020-12-18 16:29:45 +0100 | [diff] [blame] | 552 | } |
Damjan Marion | 83243a0 | 2016-02-29 13:09:30 +0100 | [diff] [blame] | 553 | return n_rx_packets; |
| 554 | } |
| 555 | |
Damjan Marion | 83243a0 | 2016-02-29 13:09:30 +0100 | [diff] [blame] | 556 | VLIB_REGISTER_NODE (af_packet_input_node) = { |
Damjan Marion | 83243a0 | 2016-02-29 13:09:30 +0100 | [diff] [blame] | 557 | .name = "af-packet-input", |
Damjan Marion | 7ca5aaa | 2019-09-24 18:10:49 +0200 | [diff] [blame] | 558 | .flags = VLIB_NODE_FLAG_TRACE_SUPPORTED, |
Damjan Marion | 51327ac | 2016-11-09 11:59:42 +0100 | [diff] [blame] | 559 | .sibling_of = "device-input", |
Damjan Marion | 83243a0 | 2016-02-29 13:09:30 +0100 | [diff] [blame] | 560 | .format_trace = format_af_packet_input_trace, |
| 561 | .type = VLIB_NODE_TYPE_INPUT, |
| 562 | .state = VLIB_NODE_STATE_INTERRUPT, |
| 563 | .n_errors = AF_PACKET_INPUT_N_ERROR, |
| 564 | .error_strings = af_packet_input_error_strings, |
Damjan Marion | 83243a0 | 2016-02-29 13:09:30 +0100 | [diff] [blame] | 565 | }; |
Damjan Marion | 1c80e83 | 2016-05-11 23:07:18 +0200 | [diff] [blame] | 566 | |
Damjan Marion | 00a9dca | 2016-08-17 17:05:46 +0200 | [diff] [blame] | 567 | |
| 568 | /* |
| 569 | * fd.io coding-style-patch-verification: ON |
| 570 | * |
| 571 | * Local Variables: |
| 572 | * eval: (c-set-style "gnu") |
| 573 | * End: |
| 574 | */ |