-always_inline void
-get_one_tunnel_inline (lisp_gpe_main_t * lgm, vlib_buffer_t * b0,
- lisp_gpe_tunnel_t ** t0, u8 is_v4)
-{
- u32 adj_index0, tunnel_index0;
- ip_adjacency_t *adj0;
-
- /* Get adjacency and from it the tunnel_index */
- adj_index0 = vnet_buffer (b0)->ip.adj_index[VLIB_TX];
-
- if (is_v4)
- adj0 = ip_get_adjacency (lgm->lm4, adj_index0);
- else
- adj0 = ip_get_adjacency (lgm->lm6, adj_index0);
-
- tunnel_index0 = adj0->if_address_index;
- t0[0] = pool_elt_at_index (lgm->tunnels, tunnel_index0);
-
- ASSERT (t0[0] != 0);
-}
-
-always_inline void
-encap_one_inline (lisp_gpe_main_t * lgm, vlib_buffer_t * b0,
- lisp_gpe_tunnel_t * t0, u32 * next0)
-{
- ASSERT (sizeof (ip4_udp_lisp_gpe_header_t) == 36);
- ASSERT (sizeof (ip6_udp_lisp_gpe_header_t) == 56);
-
- lisp_gpe_sub_tunnel_t *st0;
- u32 *sti0;
-
- sti0 = vec_elt_at_index (t0->sub_tunnels_lbv,
- vnet_buffer (b0)->ip.flow_hash %
- t0->sub_tunnels_lbv_count);
- st0 = vec_elt_at_index (t0->sub_tunnels, sti0[0]);
- if (st0->is_ip4)
- {
- ip_udp_encap_one (lgm->vlib_main, b0, st0->rewrite, 36, 1);
- next0[0] = LISP_GPE_TX_NEXT_IP4_LOOKUP;
- }
- else
- {
- ip_udp_encap_one (lgm->vlib_main, b0, st0->rewrite, 56, 0);
- next0[0] = LISP_GPE_TX_NEXT_IP6_LOOKUP;
- }
-
- /* Reset to look up tunnel partner in the configured FIB */
- vnet_buffer (b0)->sw_if_index[VLIB_TX] = t0->encap_fib_index;
-}
-
-always_inline void
-get_two_tunnels_inline (lisp_gpe_main_t * lgm, vlib_buffer_t * b0,
- vlib_buffer_t * b1, lisp_gpe_tunnel_t ** t0,
- lisp_gpe_tunnel_t ** t1, u8 is_v4)
-{
- u32 adj_index0, adj_index1, tunnel_index0, tunnel_index1;
- ip_adjacency_t *adj0, *adj1;
-
- /* Get adjacency and from it the tunnel_index */
- adj_index0 = vnet_buffer (b0)->ip.adj_index[VLIB_TX];
- adj_index1 = vnet_buffer (b1)->ip.adj_index[VLIB_TX];
-
- if (is_v4)
- {
- adj0 = ip_get_adjacency (lgm->lm4, adj_index0);
- adj1 = ip_get_adjacency (lgm->lm4, adj_index1);
- }
- else
- {
- adj0 = ip_get_adjacency (lgm->lm6, adj_index0);
- adj1 = ip_get_adjacency (lgm->lm6, adj_index1);
- }
-
- tunnel_index0 = adj0->if_address_index;
- tunnel_index1 = adj1->if_address_index;
-
- t0[0] = pool_elt_at_index (lgm->tunnels, tunnel_index0);
- t1[0] = pool_elt_at_index (lgm->tunnels, tunnel_index1);
-
- ASSERT (t0[0] != 0);
- ASSERT (t1[0] != 0);
-}
-
-always_inline void
-encap_two_inline (lisp_gpe_main_t * lgm, vlib_buffer_t * b0,
- vlib_buffer_t * b1, lisp_gpe_tunnel_t * t0,
- lisp_gpe_tunnel_t * t1, u32 * next0, u32 * next1)
-{
- ASSERT (sizeof (ip4_udp_lisp_gpe_header_t) == 36);
- ASSERT (sizeof (ip6_udp_lisp_gpe_header_t) == 56);
-
- lisp_gpe_sub_tunnel_t *st0, *st1;
- u32 *sti0, *sti1;
- sti0 = vec_elt_at_index (t0->sub_tunnels_lbv,
- vnet_buffer (b0)->ip.flow_hash %
- t0->sub_tunnels_lbv_count);
- sti1 =
- vec_elt_at_index (t1->sub_tunnels_lbv,
- vnet_buffer (b1)->ip.flow_hash %
- t1->sub_tunnels_lbv_count);
- st0 = vec_elt_at_index (t0->sub_tunnels, sti0[0]);
- st1 = vec_elt_at_index (t1->sub_tunnels, sti1[0]);
-
- if (PREDICT_TRUE (st0->is_ip4 == st1->is_ip4))
- {
- if (st0->is_ip4)
- {
- ip_udp_encap_one (lgm->vlib_main, b0, st0->rewrite, 36, 1);
- ip_udp_encap_one (lgm->vlib_main, b1, st1->rewrite, 36, 1);
- next0[0] = next1[0] = LISP_GPE_TX_NEXT_IP4_LOOKUP;
- }
- else
- {
- ip_udp_encap_one (lgm->vlib_main, b0, st0->rewrite, 56, 0);
- ip_udp_encap_one (lgm->vlib_main, b1, st1->rewrite, 56, 0);
- next0[0] = next1[0] = LISP_GPE_TX_NEXT_IP6_LOOKUP;
- }
- }
- else
- {
- if (st0->is_ip4)
- {
- ip_udp_encap_one (lgm->vlib_main, b0, st0->rewrite, 36, 1);
- ip_udp_encap_one (lgm->vlib_main, b1, st1->rewrite, 56, 1);
- next0[0] = LISP_GPE_TX_NEXT_IP4_LOOKUP;
- next1[0] = LISP_GPE_TX_NEXT_IP6_LOOKUP;
- }
- else
- {
- ip_udp_encap_one (lgm->vlib_main, b0, st0->rewrite, 56, 1);
- ip_udp_encap_one (lgm->vlib_main, b1, st1->rewrite, 36, 1);
- next0[0] = LISP_GPE_TX_NEXT_IP6_LOOKUP;
- next1[0] = LISP_GPE_TX_NEXT_IP4_LOOKUP;
- }
- }
-
- /* Reset to look up tunnel partner in the configured FIB */
- vnet_buffer (b0)->sw_if_index[VLIB_TX] = t0->encap_fib_index;
- vnet_buffer (b1)->sw_if_index[VLIB_TX] = t1->encap_fib_index;
-}
-