| 48 | #endif |
| 49 | |
| 50 | static uint16_t |
| 51 | ip4_lookup_node_process_scalar(struct rte_graph *graph, struct rte_node *node, |
| 52 | void **objs, uint16_t nb_objs) |
| 53 | { |
| 54 | struct rte_lpm *lpm = IP4_LOOKUP_NODE_LPM(node->ctx); |
| 55 | const int dyn = IP4_LOOKUP_NODE_PRIV1_OFF(node->ctx); |
| 56 | struct rte_ipv4_hdr *ipv4_hdr; |
| 57 | void **to_next, **from; |
| 58 | uint16_t last_spec = 0; |
| 59 | struct rte_mbuf *mbuf; |
| 60 | rte_edge_t next_index; |
| 61 | uint16_t held = 0; |
| 62 | uint32_t drop_nh; |
| 63 | int i, rc; |
| 64 | |
| 65 | /* Speculative next */ |
| 66 | next_index = RTE_NODE_IP4_LOOKUP_NEXT_REWRITE; |
| 67 | /* Drop node */ |
| 68 | drop_nh = ((uint32_t)RTE_NODE_IP4_LOOKUP_NEXT_PKT_DROP) << 16; |
| 69 | from = objs; |
| 70 | |
| 71 | /* Get stream for the speculated next node */ |
| 72 | to_next = rte_node_next_stream_get(graph, node, next_index, nb_objs); |
| 73 | for (i = 0; i < nb_objs; i++) { |
| 74 | uint32_t next_hop; |
| 75 | uint16_t next; |
| 76 | |
| 77 | mbuf = (struct rte_mbuf *)objs[i]; |
| 78 | |
| 79 | /* Extract DIP of mbuf0 */ |
| 80 | ipv4_hdr = rte_pktmbuf_mtod_offset(mbuf, struct rte_ipv4_hdr *, |
| 81 | sizeof(struct rte_ether_hdr)); |
| 82 | /* Extract cksum, ttl as ipv4 hdr is in cache */ |
| 83 | node_mbuf_priv1(mbuf, dyn)->cksum = ipv4_hdr->hdr_checksum; |
| 84 | node_mbuf_priv1(mbuf, dyn)->ttl = ipv4_hdr->time_to_live; |
| 85 | |
| 86 | rc = rte_lpm_lookup(lpm, rte_be_to_cpu_32(ipv4_hdr->dst_addr), |
| 87 | &next_hop); |
| 88 | next_hop = (rc == 0) ? next_hop : drop_nh; |
| 89 | |
| 90 | node_mbuf_priv1(mbuf, dyn)->nh = (uint16_t)next_hop; |
| 91 | next_hop = next_hop >> 16; |
| 92 | next = (uint16_t)next_hop; |
| 93 | |
| 94 | if (unlikely(next_index != next)) { |
| 95 | /* Copy things successfully speculated till now */ |
| 96 | rte_memcpy(to_next, from, last_spec * sizeof(from[0])); |
| 97 | from += last_spec; |
| 98 | to_next += last_spec; |
| 99 | held += last_spec; |
| 100 | last_spec = 0; |
| 101 | |
| 102 | rte_node_enqueue_x1(graph, node, next, from[0]); |
| 103 | from += 1; |
| 104 | } else { |
| 105 | last_spec += 1; |
| 106 | } |
| 107 | } |
nothing calls this directly
no test coverage detected