aboutsummaryrefslogtreecommitdiffstats
path: root/tests/honeycomb/func/mgmt-cfg-proxynd6-apihc-func.robot
blob: 4425750add9fc5878f800dc879837a440c01ab8a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# Copyright (c) 2017 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.

*** Variables ***
# Interface to run configuration tests on.
| ${interface}= | ${node['interfaces']['port1']['name']}
# IPv6 addresses to configure on DUT.
| ${dut_to_tg_if1_ip}= | 10::1
| ${dut_to_tg_if2_ip}= | 11::1
# IPv6 addresses used for TG interfaces.
| ${test_src_ip}= | 10::2
| ${test_dst_ip}= | 11::2
| ${test_dst_ip2}= | 11::3
# IPv6 subnet prefix length
| ${prefix_length}= | 64

*** Settings ***
| Resource | resources/libraries/robot/shared/default.robot
| Resource | resources/libraries/robot/honeycomb/honeycomb.robot
| Resource | resources/libraries/robot/honeycomb/interfaces.robot
| Resource | resources/libraries/robot/honeycomb/proxyarp.robot
| Resource | resources/libraries/robot/shared/testing_path.robot
| Resource | resources/libraries/robot/ip/ip6.robot
| Resource | resources/libraries/robot/shared/traffic.robot
| Resource | resources/libraries/robot/features/dhcp_proxy.robot
| Library | resources.libraries.python.Trace
| ...
| Suite Setup | Set Up Honeycomb Functional Test Suite | ${node}
| ...
| Suite Teardown | Tear Down Honeycomb Functional Test Suite | ${node}
| ...
| Force Tags | HC_FUNC
| ...
| Documentation | *Honeycomb IPv6 neighbor discovery proxy test suite.*

*** Test Cases ***
| TC01: Honeycomb can configure IPv6 ND proxy on an interface
| | [Documentation] | Check if Honeycomb can configure the IPv6 ND proxy\
| | ... | feature on an interface.
| | ...
| | Given IPv6 ND proxy from Honeycomb should be empty | ${node} | ${interface}
| | And Honeycomb configures interface state | ${node} | ${interface} | up
| | When Honeycomb configures IPv6 ND proxy on interface
| | ... | ${node} | ${interface} | ${test_dst_ip}
| | Then IPv6 ND proxy from Honeycomb should be
| | ... | ${node} | ${interface} | ${test_dst_ip}

| TC02: Honeycomb can disable IPv6 ND proxy on an interface
| | [Documentation] | Check if Honeycomb can remove IPv6 ND proxy feature\
| | ... | configuration from an interface.
| | ...
| | Given IPv6 ND proxy from Honeycomb should be
| | ... | ${node} | ${interface} | ${test_dst_ip}
| | When Honeycomb disables IPv6 ND proxy on interface | ${node} | ${interface}
| | Then IPv6 ND proxy from Honeycomb should be empty | ${node} | ${interface}

| TC03: Honeycomb can configure multiple IPv6 ND proxies on an interface
| | [Documentation] | Check if Honeycomb can configure two ND proxies\
| | ... | on one interface.
| | ...
| | [Teardown] | Honeycomb disables IPv6 ND proxy on interface
| | ... | ${node} | ${interface}
| | ...
| | Given IPv6 ND proxy from Honeycomb should be empty | ${node} | ${interface}
| | And Honeycomb configures interface state | ${node} | ${interface} | up
| | When Honeycomb configures IPv6 ND proxy on interface
| | ... | ${node} | ${interface} | ${test_dst_ip} | ${test_dst_ip2}
| | Then IPv6 ND proxy from Honeycomb should be
| | ... | ${node} | ${interface} | ${test_dst_ip} | ${test_dst_ip2}

| TC04: VPP proxies valid ICMPv6 Neighbor Discovery request
| | [Documentation] |
| | ... | [Top] TG=DUT
| | ... | [Cfg] On DUT configure IPv6 addresses and neighbors, supress router\
| | ... | advertisement and configure IPv6 Neighbor Discovery proxy.
| | ... | [Ver] Make TG send a neighbor solicitation packet to it's other\
| | ... | interface through DUT, verify DUT responds to the packet instead\
| | ... | of forwarding it. Then exchange ICMPv6 Echo request/reply to verify\
| | ... | connectivity between interfaces.
| | ... | [Ref] RFC 4389
| | ...
| | [Teardown] | Run Keywords
| | ... | Show Packet Trace on All DUTs | ${nodes} | AND
| | ... | Honeycomb disables IPv6 ND proxy on interface
| | ... | ${dut_node} | ${dut_to_tg_if2}
| | ...
| | Given Configure path in 2-node circular topology
| | ... | ${nodes['TG']} | ${nodes['DUT1']} | ${nodes['TG']}
| | Honeycomb configures interface state | ${dut_node} | ${dut_to_tg_if1} | up
| | Honeycomb configures interface state | ${dut_node} | ${dut_to_tg_if2} | up
| | Honeycomb sets interface IPv6 address | ${dut_node}
| | ... | ${dut_to_tg_if1} | ${dut_to_tg_if1_ip} | ${prefix_length}
| | Honeycomb sets interface IPv6 address | ${dut_node}
| | ... | ${dut_to_tg_if2} | ${dut_to_tg_if2_ip} | ${prefix_length}
| | And Vpp Ra Suppress Link Layer | ${dut_node} | ${dut_to_tg_if1}
| | And Vpp Ra Suppress Link Layer | ${dut_node} | ${dut_to_tg_if2}
| | And Honeycomb adds interface IPv6 neighbor | ${dut_node} | ${dut_to_tg_if1}
| | ... | ${test_src_ip} | ${tg_to_dut_if1_mac}
| | And Honeycomb adds interface IPv6 neighbor | ${dut_node} | ${dut_to_tg_if2}
| | ... | ${test_dst_ip} | ${tg_to_dut_if2_mac}
| | When Honeycomb configures IPv6 ND proxy on interface
| | ... | ${dut_node} | ${dut_to_tg_if2} | ${test_dst_ip}
| | Then Verify IPv6ND proxy | ${tg_node}
| | ... | ${tg_to_dut_if1} | ${tg_to_dut_if2}
| | ... | ${test_src_ip} | ${test_dst_ip}
| | ... | ${tg_to_dut_if1_mac} | ${tg_to_dut_if2_mac}
| | ... | ${dut_to_tg_if1_mac} | ${dut_to_tg_if2_mac}
lass="p">(1 << DPDK_RX_F_FDIR == PKT_RX_FDIR, ""); STATIC_ASSERT ((PKT_RX_IP_CKSUM_GOOD | PKT_RX_IP_CKSUM_BAD | PKT_RX_FDIR) < 256, "dpdk flags not un lower byte, fix needed"); always_inline u32 dpdk_rx_next (vlib_node_runtime_t * node, u16 etype, u8 flags) { if (PREDICT_TRUE (etype == clib_host_to_net_u16 (ETHERNET_TYPE_IP4))) { /* keep it branchless */ u32 is_good = (flags >> DPDK_RX_F_CKSUM_GOOD) & 1; return VNET_DEVICE_INPUT_NEXT_IP4_INPUT - is_good; } else if (PREDICT_TRUE (etype == clib_host_to_net_u16 (ETHERNET_TYPE_IP6))) return VNET_DEVICE_INPUT_NEXT_IP6_INPUT; else if (PREDICT_TRUE (etype == clib_host_to_net_u16 (ETHERNET_TYPE_MPLS))) return VNET_DEVICE_INPUT_NEXT_MPLS_INPUT; else return VNET_DEVICE_INPUT_NEXT_ETHERNET_INPUT; } static_always_inline uword dpdk_process_subseq_segs (vlib_main_t * vm, vlib_buffer_t * b, struct rte_mbuf * mb, vlib_buffer_free_list_t * fl) { u8 nb_seg = 1; struct rte_mbuf *mb_seg = 0; vlib_buffer_t *b_seg, *b_chain = 0; mb_seg = mb->next; b_chain = b; if (mb->nb_segs < 2) return 0; b->flags |= VLIB_BUFFER_TOTAL_LENGTH_VALID; b->total_length_not_including_first_buffer = 0; while (nb_seg < mb->nb_segs) { ASSERT (mb_seg != 0); b_seg = vlib_buffer_from_rte_mbuf (mb_seg); vlib_buffer_init_for_free_list (b_seg, fl); ASSERT ((b_seg->flags & VLIB_BUFFER_NEXT_PRESENT) == 0); ASSERT (b_seg->current_data == 0); /* * The driver (e.g. virtio) may not put the packet data at the start * of the segment, so don't assume b_seg->current_data == 0 is correct. */ b_seg->current_data = (mb_seg->buf_addr + mb_seg->data_off) - (void *) b_seg->data; b_seg->current_length = mb_seg->data_len; b->total_length_not_including_first_buffer += mb_seg->data_len; b_chain->flags |= VLIB_BUFFER_NEXT_PRESENT; b_chain->next_buffer = vlib_get_buffer_index (vm, b_seg); b_chain = b_seg; mb_seg = mb_seg->next; nb_seg++; } return b->total_length_not_including_first_buffer; } static_always_inline void dpdk_prefetch_mbuf_x4 (struct rte_mbuf *mb[]) { CLIB_PREFETCH (mb[0], CLIB_CACHE_LINE_BYTES, LOAD); CLIB_PREFETCH (mb[1], CLIB_CACHE_LINE_BYTES, LOAD); CLIB_PREFETCH (mb[2], CLIB_CACHE_LINE_BYTES, LOAD); CLIB_PREFETCH (mb[3], CLIB_CACHE_LINE_BYTES, LOAD); } static_always_inline void dpdk_prefetch_buffer_x4 (struct rte_mbuf *mb[]) { vlib_buffer_t *b; b = vlib_buffer_from_rte_mbuf (mb[0]); CLIB_PREFETCH (b, CLIB_CACHE_LINE_BYTES, LOAD); b = vlib_buffer_from_rte_mbuf (mb[1]); CLIB_PREFETCH (b, CLIB_CACHE_LINE_BYTES, LOAD); b = vlib_buffer_from_rte_mbuf (mb[2]); CLIB_PREFETCH (b, CLIB_CACHE_LINE_BYTES, LOAD); b = vlib_buffer_from_rte_mbuf (mb[3]); CLIB_PREFETCH (b, CLIB_CACHE_LINE_BYTES, LOAD); } static_always_inline void dpdk_prefetch_buffer_data_x4 (struct rte_mbuf *mb[]) { vlib_buffer_t *b; b = vlib_buffer_from_rte_mbuf (mb[0]); CLIB_PREFETCH (b->data, CLIB_CACHE_LINE_BYTES, LOAD); b = vlib_buffer_from_rte_mbuf (mb[1]); CLIB_PREFETCH (b->data, CLIB_CACHE_LINE_BYTES, LOAD); b = vlib_buffer_from_rte_mbuf (mb[2]); CLIB_PREFETCH (b->data, CLIB_CACHE_LINE_BYTES, LOAD); b = vlib_buffer_from_rte_mbuf (mb[3]); CLIB_PREFETCH (b->data, CLIB_CACHE_LINE_BYTES, LOAD); } static inline void poll_rate_limit (dpdk_main_t * dm) { /* Limit the poll rate by sleeping for N msec between polls */ if (PREDICT_FALSE (dm->poll_sleep_usec != 0)) { struct timespec ts, tsrem; ts.tv_sec = 0; ts.tv_nsec = 1000 * dm->poll_sleep_usec; while (nanosleep (&ts, &tsrem) < 0) { ts = tsrem; } } } /** \brief Main DPDK input node @node dpdk-input This is the main DPDK input node: across each assigned interface, call rte_eth_rx_burst(...) or similar to obtain a vector of packets to process. Derive @c vlib_buffer_t metadata from <code>struct rte_mbuf</code> metadata, Depending on the resulting metadata: adjust <code>b->current_data, b->current_length </code> and dispatch directly to ip4-input-no-checksum, or ip6-input. Trace the packet if required. @param vm vlib_main_t corresponding to the current thread @param node vlib_node_runtime_t @param f vlib_frame_t input-node, not used. @par Graph mechanics: buffer metadata, next index usage @em Uses: - <code>struct rte_mbuf mb->ol_flags</code> - PKT_RX_IP_CKSUM_BAD @em Sets: - <code>b->error</code> if the packet is to be dropped immediately - <code>b->current_data, b->current_length</code> - adjusted as needed to skip the L2 header in direct-dispatch cases - <code>vnet_buffer(b)->sw_if_index[VLIB_RX]</code> - rx interface sw_if_index - <code>vnet_buffer(b)->sw_if_index[VLIB_TX] = ~0</code> - required by ipX-lookup - <code>b->flags</code> - to indicate multi-segment pkts (VLIB_BUFFER_NEXT_PRESENT), etc. <em>Next Nodes:</em> - Static arcs to: error-drop, ethernet-input, ip4-input-no-checksum, ip6-input, mpls-input - per-interface redirection, controlled by <code>xd->per_interface_next_index</code> */ static_always_inline u8 dpdk_ol_flags_extract (struct rte_mbuf **mb, u8 * flags, int count) { u8 rv = 0; int i; for (i = 0; i < count; i++) { /* all flags we are interested in are in lower 8 bits but that might change */ flags[i] = (u8) mb[i]->ol_flags; rv |= flags[i]; } return rv; } static_always_inline uword dpdk_process_rx_burst (vlib_main_t * vm, dpdk_per_thread_data_t * ptd, uword n_rx_packets, int maybe_multiseg, u8 * or_flagsp) { u32 n_left = n_rx_packets; vlib_buffer_t *b[4]; vlib_buffer_free_list_t *fl; struct rte_mbuf **mb = ptd->mbufs; uword n_bytes = 0; i16 off; u8 *flags, or_flags = 0; u16 *next; fl = vlib_buffer_get_free_list (vm, VLIB_BUFFER_DEFAULT_FREE_LIST_INDEX); mb = ptd->mbufs; flags = ptd->flags; next = ptd->next; while (n_left >= 8) { CLIB_PREFETCH (mb + 8, CLIB_CACHE_LINE_BYTES, LOAD); dpdk_prefetch_buffer_x4 (mb + 4); b[0] = vlib_buffer_from_rte_mbuf (mb[0]); b[1] = vlib_buffer_from_rte_mbuf (mb[1]); b[2] = vlib_buffer_from_rte_mbuf (mb[2]); b[3] = vlib_buffer_from_rte_mbuf (mb[3]); clib_memcpy64_x4 (b[0], b[1], b[2], b[3], &ptd->buffer_template); dpdk_prefetch_mbuf_x4 (mb + 4); or_flags |= dpdk_ol_flags_extract (mb, flags, 4); flags += 4; /* we temporary store relative offset of ethertype into next[x] so we can prefetch and get it faster later */ off = mb[0]->data_off; next[0] = off + STRUCT_OFFSET_OF (ethernet_header_t, type); off -= RTE_PKTMBUF_HEADROOM; vnet_buffer (b[0])->l2_hdr_offset = off; b[0]->current_data = off; off = mb[1]->data_off; next[1] = off + STRUCT_OFFSET_OF (ethernet_header_t, type); off -= RTE_PKTMBUF_HEADROOM; vnet_buffer (b[1])->l2_hdr_offset = off; b[1]->current_data = off; off = mb[2]->data_off; next[2] = off + STRUCT_OFFSET_OF (ethernet_header_t, type); off -= RTE_PKTMBUF_HEADROOM; vnet_buffer (b[2])->l2_hdr_offset = off; b[2]->current_data = off; off = mb[3]->data_off; next[3] = off + STRUCT_OFFSET_OF (ethernet_header_t, type); off -= RTE_PKTMBUF_HEADROOM; vnet_buffer (b[3])->l2_hdr_offset = off; b[3]->current_data = off; b[0]->current_length = mb[0]->data_len; b[1]->current_length = mb[1]->data_len; b[2]->current_length = mb[2]->data_len; b[3]->current_length = mb[3]->data_len; n_bytes += mb[0]->data_len; n_bytes += mb[1]->data_len; n_bytes += mb[2]->data_len; n_bytes += mb[3]->data_len; if (maybe_multiseg) { n_bytes += dpdk_process_subseq_segs (vm, b[0], mb[0], fl); n_bytes += dpdk_process_subseq_segs (vm, b[1], mb[1], fl); n_bytes += dpdk_process_subseq_segs (vm, b[2], mb[2], fl); n_bytes += dpdk_process_subseq_segs (vm, b[3], mb[3], fl); } VLIB_BUFFER_TRACE_TRAJECTORY_INIT (b[0]); VLIB_BUFFER_TRACE_TRAJECTORY_INIT (b[1]); VLIB_BUFFER_TRACE_TRAJECTORY_INIT (b[2]); VLIB_BUFFER_TRACE_TRAJECTORY_INIT (b[3]); /* next */ mb += 4; n_left -= 4; next += 4; } while (n_left) { b[0] = vlib_buffer_from_rte_mbuf (mb[0]); clib_memcpy (b[0], &ptd->buffer_template, 64); or_flags |= dpdk_ol_flags_extract (mb, flags, 1); flags += 1; off = mb[0]->data_off; next[0] = off + STRUCT_OFFSET_OF (ethernet_header_t, type); off -= RTE_PKTMBUF_HEADROOM; vnet_buffer (b[0])->l2_hdr_offset = off; b[0]->current_data = off; b[0]->current_length = mb[0]->data_len; n_bytes += mb[0]->data_len; if (maybe_multiseg) n_bytes += dpdk_process_subseq_segs (vm, b[0], mb[0], fl); VLIB_BUFFER_TRACE_TRAJECTORY_INIT (b[0]); /* next */ mb += 1; n_left -= 1; next += 1; } *or_flagsp = or_flags; return n_bytes; } static_always_inline void dpdk_set_next_from_etype (vlib_main_t * vm, vlib_node_runtime_t * node, dpdk_per_thread_data_t * ptd, uword n_rx_packets) { vlib_buffer_t *b[4]; i16 adv[4]; u16 etype[4]; struct rte_mbuf **mb = ptd->mbufs; u8 *flags = ptd->flags; u16 *next = ptd->next; u32 n_left = n_rx_packets; while (n_left >= 12) { dpdk_prefetch_buffer_data_x4 (mb + 8); dpdk_prefetch_buffer_x4 (mb + 8); b[0] = vlib_buffer_from_rte_mbuf (mb[0]); b[1] = vlib_buffer_from_rte_mbuf (mb[1]); b[2] = vlib_buffer_from_rte_mbuf (mb[2]); b[3] = vlib_buffer_from_rte_mbuf (mb[3]); etype[0] = *(u16 *) ((u8 *) mb[0] + next[0] + sizeof (vlib_buffer_t)); etype[1] = *(u16 *) ((u8 *) mb[1] + next[1] + sizeof (vlib_buffer_t)); etype[2] = *(u16 *) ((u8 *) mb[2] + next[2] + sizeof (vlib_buffer_t)); etype[3] = *(u16 *) ((u8 *) mb[3] + next[3] + sizeof (vlib_buffer_t)); next[0] = dpdk_rx_next (node, etype[0], flags[0]); next[1] = dpdk_rx_next (node, etype[1], flags[1]); next[2] = dpdk_rx_next (node, etype[2], flags[2]); next[3] = dpdk_rx_next (node, etype[3], flags[3]); adv[0] = device_input_next_node_advance[next[0]]; adv[1] = device_input_next_node_advance[next[1]]; adv[2] = device_input_next_node_advance[next[2]]; adv[3] = device_input_next_node_advance[next[3]]; b[0]->current_data += adv[0]; b[1]->current_data += adv[1]; b[2]->current_data += adv[2]; b[3]->current_data += adv[3]; b[0]->current_length -= adv[0]; b[1]->current_length -= adv[1]; b[2]->current_length -= adv[2]; b[3]->current_length -= adv[3]; /* next */ next += 4; mb += 4; n_left -= 4; flags += 4; } while (n_left) { b[0] = vlib_buffer_from_rte_mbuf (mb[0]); next[0] = *(u16 *) ((u8 *) mb[0] + next[0] + sizeof (vlib_buffer_t)); next[0] = dpdk_rx_next (node, next[0], flags[0]); adv[0] = device_input_next_node_advance[next[0]]; b[0]->current_data += adv[0]; b[0]->current_length -= adv[0]; /* next */ next += 1; mb += 1; n_left -= 1; flags += 1; } } static_always_inline void dpdk_process_flow_offload (dpdk_device_t * xd, dpdk_per_thread_data_t * ptd, uword n_rx_packets) { uword n; dpdk_flow_lookup_entry_t *fle; vlib_buffer_t *b0; /* TODO prefetch and quad-loop */ for (n = 0; n < n_rx_packets; n++) { if ((ptd->flags[n] & (1 << DPDK_RX_F_FDIR)) == 0) continue; fle = vec_elt_at_index (xd->flow_lookup_entries, ptd->mbufs[n]->hash.fdir.hi); if (fle->next_index != (u16) ~ 0) ptd->next[n] = fle->next_index; if (fle->flow_id != ~0) { b0 = vlib_buffer_from_rte_mbuf (ptd->mbufs[n]); b0->flow_id = fle->flow_id; } if (fle->buffer_advance != ~0) { b0 = vlib_buffer_from_rte_mbuf (ptd->mbufs[n]); vlib_buffer_advance (b0, fle->buffer_advance); } } } static_always_inline u32 dpdk_device_input (vlib_main_t * vm, dpdk_main_t * dm, dpdk_device_t * xd, vlib_node_runtime_t * node, u32 thread_index, u16 queue_id) { uword n_rx_packets = 0, n_rx_bytes; u32 n_left, n_trace; u32 *buffers; u32 next_index = VNET_DEVICE_INPUT_NEXT_ETHERNET_INPUT; struct rte_mbuf **mb; vlib_buffer_t *b0; int known_next = 0; u16 *next; u8 or_flags; u32 n; dpdk_per_thread_data_t *ptd = vec_elt_at_index (dm->per_thread_data, thread_index); vlib_buffer_t *bt = &ptd->buffer_template; if ((xd->flags & DPDK_DEVICE_FLAG_ADMIN_UP) == 0) return 0; /* get up to DPDK_RX_BURST_SZ buffers from PMD */ while (n_rx_packets < DPDK_RX_BURST_SZ) { n = rte_eth_rx_burst (xd->device_index, queue_id, ptd->mbufs + n_rx_packets, DPDK_RX_BURST_SZ - n_rx_packets); n_rx_packets += n; if (n < 32) break; } if (n_rx_packets == 0) return 0; /* Update buffer template */ vnet_buffer (bt)->sw_if_index[VLIB_RX] = xd->sw_if_index; bt->error = node->errors[DPDK_ERROR_NONE]; /* as DPDK is allocating empty buffers from mempool provided before interface start for each queue, it is safe to store this in the template */ bt->buffer_pool_index = xd->buffer_pool_for_queue[queue_id]; /* receive burst of packets from DPDK PMD */ if (PREDICT_FALSE (xd->per_interface_next_index != ~0)) { known_next = 1; next_index = xd->per_interface_next_index; } /* as all packets belong to thr same interface feature arc lookup can be don once and result stored in the buffer template */ if (PREDICT_FALSE (vnet_device_input_have_features (xd->sw_if_index))) { vnet_feature_start_device_input_x1 (xd->sw_if_index, &next_index, bt); known_next = 1; } if (xd->flags & DPDK_DEVICE_FLAG_MAYBE_MULTISEG) n_rx_bytes = dpdk_process_rx_burst (vm, ptd, n_rx_packets, 1, &or_flags); else n_rx_bytes = dpdk_process_rx_burst (vm, ptd, n_rx_packets, 0, &or_flags); if (PREDICT_FALSE (known_next)) { for (n = 0; n < n_rx_packets; n++) ptd->next[n] = next_index; vnet_buffer (bt)->feature_arc_index = 0; bt->current_config_index = 0; } else dpdk_set_next_from_etype (vm, node, ptd, n_rx_packets); /* flow offload - process if rx flow offlaod enabled and at least one packet is marked */ if (PREDICT_FALSE ((xd->flags & DPDK_DEVICE_FLAG_RX_FLOW_OFFLOAD) && (or_flags & (1 << DPDK_RX_F_FDIR)))) dpdk_process_flow_offload (xd, ptd, n_rx_packets); /* is at least one packet marked as ip4 checksum bad? */ if (PREDICT_FALSE (or_flags & (1 << DPDK_RX_F_CKSUM_BAD))) for (n = 0; n < n_rx_packets; n++) { if ((ptd->flags[n] & (1 << DPDK_RX_F_CKSUM_BAD)) == 0) continue; if (ptd->next[n] != VNET_DEVICE_INPUT_NEXT_IP4_INPUT) continue; b0 = vlib_buffer_from_rte_mbuf (ptd->mbufs[n]); b0->error = node->errors[DPDK_ERROR_IP_CHECKSUM_ERROR]; ptd->next[n] = VNET_DEVICE_INPUT_NEXT_DROP; } /* enqueue buffers to the next node */ vlib_get_buffer_indices_with_offset (vm, (void **) ptd->mbufs, ptd->buffers, n_rx_packets, sizeof (struct rte_mbuf)); vlib_buffer_enqueue_to_next (vm, node, ptd->buffers, ptd->next, n_rx_packets); /* packet trace if enabled */ if ((n_trace = vlib_get_trace_count (vm, node))) { n_left = n_rx_packets; buffers = ptd->buffers; mb = ptd->mbufs; next = ptd->next; while (n_trace && n_left) { b0 = vlib_get_buffer (vm, buffers[0]); vlib_trace_buffer (vm, node, next[0], b0, /* follow_chain */ 0); dpdk_rx_trace_t *t0 = vlib_add_trace (vm, node, b0, sizeof t0[0]); t0->queue_index = queue_id; t0->device_index = xd->device_index; t0->buffer_index = vlib_get_buffer_index (vm, b0); clib_memcpy (&t0->mb, mb[0], sizeof t0->mb); clib_memcpy (&t0->buffer, b0, sizeof b0[0] - sizeof b0->pre_data); clib_memcpy (t0->buffer.pre_data, b0->data, sizeof t0->buffer.pre_data); clib_memcpy (&t0->data, mb[0]->buf_addr + mb[0]->data_off, sizeof t0->data); n_trace--; n_left--; buffers++; mb++; next++; } vlib_set_trace_count (vm, node, n_trace); } vlib_increment_combined_counter (vnet_get_main ()->interface_main.combined_sw_if_counters + VNET_INTERFACE_COUNTER_RX, thread_index, xd->sw_if_index, n_rx_packets, n_rx_bytes); vnet_device_increment_rx_packets (thread_index, n_rx_packets); return n_rx_packets; } uword CLIB_CPU_OPTIMIZED CLIB_MULTIARCH_FN (dpdk_input) (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * f) { dpdk_main_t *dm = &dpdk_main; dpdk_device_t *xd; uword n_rx_packets = 0; vnet_device_input_runtime_t *rt = (void *) node->runtime_data; vnet_device_and_queue_t *dq; u32 thread_index = node->thread_index; /* * Poll all devices on this cpu for input/interrupts. */ /* *INDENT-OFF* */ foreach_device_and_queue (dq, rt->devices_and_queues) { xd = vec_elt_at_index(dm->devices, dq->dev_instance); if (PREDICT_FALSE (xd->flags & DPDK_DEVICE_FLAG_BOND_SLAVE)) continue; /* Do not poll slave to a bonded interface */ n_rx_packets += dpdk_device_input (vm, dm, xd, node, thread_index, dq->queue_id); } /* *INDENT-ON* */ poll_rate_limit (dm); return n_rx_packets; } #ifndef CLIB_MULTIARCH_VARIANT /* *INDENT-OFF* */ VLIB_REGISTER_NODE (dpdk_input_node) = { .function = dpdk_input, .type = VLIB_NODE_TYPE_INPUT, .name = "dpdk-input", .sibling_of = "device-input", /* Will be enabled if/when hardware is detected. */ .state = VLIB_NODE_STATE_DISABLED, .format_buffer = format_ethernet_header_with_length, .format_trace = format_dpdk_rx_trace, .n_errors = DPDK_N_ERROR, .error_strings = dpdk_error_strings, }; /* *INDENT-ON* */ vlib_node_function_t __clib_weak dpdk_input_avx512; vlib_node_function_t __clib_weak dpdk_input_avx2; #if __x86_64__ static void __clib_constructor dpdk_input_multiarch_select (void) { if (dpdk_input_avx512 && clib_cpu_supports_avx512f ()) dpdk_input_node.function = dpdk_input_avx512; else if (dpdk_input_avx2 && clib_cpu_supports_avx2 ()) dpdk_input_node.function = dpdk_input_avx2; } #endif #endif /* * fd.io coding-style-patch-verification: ON * * Local Variables: * eval: (c-set-style "gnu") * End: */