vppinfra: Improve code portability
[vpp.git] / src / vnet / vxlan-gpe / vxlan_gpe.h
index b7e75d7..aabaafe 100644 (file)
@@ -24,6 +24,7 @@
 #include <vppinfra/hash.h>
 #include <vnet/vnet.h>
 #include <vnet/ip/ip.h>
+#include <vnet/ip/vtep.h>
 #include <vnet/l2/l2_input.h>
 #include <vnet/l2/l2_output.h>
 #include <vnet/l2/l2_bd.h>
@@ -31,7 +32,7 @@
 #include <vnet/vxlan-gpe/vxlan_gpe_packet.h>
 #include <vnet/ip/ip4_packet.h>
 #include <vnet/ip/ip6_packet.h>
-#include <vnet/udp/udp.h>
+#include <vnet/udp/udp_packet.h>
 #include <vnet/dpo/dpo.h>
 #include <vnet/adj/adj_types.h>
 
@@ -39,7 +40,6 @@
  * @brief VXLAN GPE header struct
  *
  */
-/* *INDENT-OFF* */
 typedef CLIB_PACKED (struct {
   /** 20 bytes */
   ip4_header_t ip4;
@@ -48,9 +48,7 @@ typedef CLIB_PACKED (struct {
   /** 8 bytes */
   vxlan_gpe_header_t vxlan;
 }) ip4_vxlan_gpe_header_t;
-/* *INDENT-ON* */
 
-/* *INDENT-OFF* */
 typedef CLIB_PACKED (struct {
   /** 40 bytes */
   ip6_header_t ip6;
@@ -59,15 +57,13 @@ typedef CLIB_PACKED (struct {
   /** 8 bytes */
   vxlan_gpe_header_t vxlan;
 }) ip6_vxlan_gpe_header_t;
-/* *INDENT-ON* */
 
 /**
  * @brief Key struct for IPv4 VXLAN GPE tunnel.
- * Key fields: local remote, vni
+ * Key fields: local remote, vni, udp-port
  * all fields in NET byte order
  * VNI shifted 8 bits
  */
-/* *INDENT-OFF* */
 typedef CLIB_PACKED(struct {
   union {
     struct {
@@ -75,32 +71,44 @@ typedef CLIB_PACKED(struct {
       u32 remote;
 
       u32 vni;
-      u32 pad;
+      u32 port;
     };
     u64 as_u64[2];
   };
 }) vxlan4_gpe_tunnel_key_t;
-/* *INDENT-ON* */
 
 /**
  * @brief Key struct for IPv6 VXLAN GPE tunnel.
- * Key fields: local remote, vni
+ * Key fields: local remote, vni, udp-port
  * all fields in NET byte order
  * VNI shifted 8 bits
  */
-/* *INDENT-OFF* */
 typedef CLIB_PACKED(struct {
   ip6_address_t local;
   ip6_address_t remote;
   u32 vni;
+  u32 port;
 }) vxlan6_gpe_tunnel_key_t;
-/* *INDENT-ON* */
+
+typedef union
+{
+  struct
+  {
+    u32 tunnel_index;
+    u16 next_index;
+    u8 error;
+  };
+  u64 as_u64;
+} vxlan_gpe_decap_info_t;
 
 /**
  * @brief Struct for VXLAN GPE tunnel
  */
 typedef struct
 {
+  /* Required for pool_get_aligned */
+  CLIB_CACHE_LINE_ALIGN_MARK (cacheline0);
+
   /** Rewrite string. $$$$ embed vnet_rewrite header */
   u8 *rewrite;
 
@@ -113,6 +121,10 @@ typedef struct
   ip46_address_t local;
   /** tunnel remote address */
   ip46_address_t remote;
+  /** local udp-port **/
+  u16 local_port;
+  /** remote udp-port **/
+  u16 remote_port;
 
   /* mcast packet output intfc index (used only if dst is mcast) */
   u32 mcast_sw_if_index;
@@ -152,7 +164,7 @@ typedef struct
   adj_index_t mcast_adj_index;
 
   /**
-   * The tunnel is a child of the FIB entry for its desintion. This is
+   * The tunnel is a child of the FIB entry for its destination. This is
    * so it receives updates when the forwarding information for that entry
    * changes.
    * The tunnels sibling index on the FIB entry's dependency list.
@@ -169,7 +181,7 @@ typedef struct
 _(DROP, "error-drop")                           \
 _(IP4_INPUT, "ip4-input")                       \
 _(IP6_INPUT, "ip6-input")                       \
-_(ETHERNET_INPUT, "ethernet-input")
+_(L2_INPUT, "l2-input")
 
 /** struct for next nodes for VXLAN GPE input */
 typedef enum
@@ -202,8 +214,7 @@ typedef struct
 
   /* local VTEP IPs ref count used by vxlan-bypass node to check if
      received VXLAN packet DIP matches any local VTEP address */
-  uword *vtep4;                        /* local ip4 VTEPs keyed on their ip4 addr */
-  uword *vtep6;                        /* local ip6 VTEPs keyed on their ip6 addr */
+  vtep_table_t vtep_table;
   /* mcast shared info */
   uword *mcast_shared;         /* keyed on mcast ip46 addr */
   /** Free vlib hw_if_indices */
@@ -217,6 +228,9 @@ typedef struct
   /** State convenience vnet_main_t */
   vnet_main_t *vnet_main;
 
+  /* cache for last 8 vxlan_gpe tunnel */
+  vtep4_cache_t vtep4_u512;
+
   /** List of next nodes for the decap indexed on protocol */
   uword decap_next_node_list[VXLAN_GPE_PROTOCOL_MAX];
 } vxlan_gpe_main_t;
@@ -240,6 +254,8 @@ typedef struct
   u32 encap_fib_index;
   u32 decap_fib_index;
   u32 vni;
+  u16 local_port;
+  u16 remote_port;
 } vnet_vxlan_gpe_add_del_tunnel_args_t;