API refactoring : l2 (add) 64/4864/5
authorPavel Kotucek <pkotucek@cisco.com>
Wed, 25 Jan 2017 07:50:53 +0000 (08:50 +0100)
committerDamjan Marion <dmarion.lists@gmail.com>
Fri, 27 Jan 2017 01:01:36 +0000 (01:01 +0000)
Change-Id: I693a73ba9a5e3b0cb5d2a6c5d363f671e19c1f24
Signed-off-by: Pavel Kotucek <pkotucek@cisco.com>
src/vnet/l2/l2.api
src/vnet/l2/l2_api.c
src/vpp/api/api.c
src/vpp/api/vpe.api

index 5b24f25..061990c 100644 (file)
@@ -260,6 +260,71 @@ define bridge_flags_reply
   u32 resulting_feature_bitmap;
 };
 
+/** \brief L2 interface vlan tag rewrite configure request
+    @param client_index - opaque cookie to identify the sender
+    @param context - sender context, to match reply w/ request
+    @param sw_if_index - interface the operation is applied to
+    @param vtr_op - Choose from l2_vtr_op_t enum values
+    @param push_dot1q - first pushed flag dot1q id set, else dot1ad
+    @param tag1 - Needed for any push or translate vtr op
+    @param tag2 - Needed for any push 2 or translate x-2 vtr ops
+*/
+define l2_interface_vlan_tag_rewrite
+{
+  u32 client_index;
+  u32 context;
+  u32 sw_if_index;
+  u32 vtr_op;
+  u32 push_dot1q;              // ethertype of first pushed tag is dot1q/dot1ad
+  u32 tag1;                    // first pushed tag
+  u32 tag2;                    // second pushed tag
+};
+
+/** \brief L2 interface vlan tag rewrite response
+    @param context - sender context, to match reply w/ request
+    @param retval - return code for the request
+*/
+define l2_interface_vlan_tag_rewrite_reply
+{
+  u32 context;
+  i32 retval;
+};
+
+/** \brief L2 interface pbb tag rewrite configure request
+    @param client_index - opaque cookie to identify the sender
+    @param context - sender context, to match reply w/ request
+    @param sw_if_index - interface the operation is applied to
+    @param vtr_op - Choose from l2_vtr_op_t enum values
+    @param inner_tag - needed for translate_qinq vtr op only
+    @param outer_tag - needed for translate_qinq vtr op only 
+    @param b_dmac - B-tag remote mac address, needed for any push or translate_qinq vtr op
+    @param b_smac - B-tag local mac address, needed for any push or translate qinq vtr op
+    @param b_vlanid - B-tag vlanid, needed for any push or translate qinq vtr op
+    @param i_sid - I-tag service id, needed for any push or translate qinq vtr op
+*/
+define l2_interface_pbb_tag_rewrite
+{
+  u32 client_index;
+  u32 context;
+  u32 sw_if_index;
+  u32 vtr_op;
+  u16 outer_tag;
+  u8  b_dmac[6];
+  u8  b_smac[6];
+  u16 b_vlanid;
+  u32 i_sid;
+};
+
+/** \brief L2 interface pbb tag rewrite response
+    @param context - sender context, to match reply w/ request
+    @param retval - return code for the request
+*/
+define l2_interface_pbb_tag_rewrite_reply
+{
+  u32 context;
+  i32 retval;
+};
+
 /*
  * Local Variables:
  * eval: (c-set-style "gnu")
index ef33509..a3cc49b 100644 (file)
@@ -24,6 +24,7 @@
 #include <vnet/api_errno.h>
 #include <vnet/l2/l2_input.h>
 #include <vnet/l2/l2_fib.h>
+#include <vnet/l2/l2_vtr.h>
 
 #include <vnet/vnet_msg_enum.h>
 
@@ -54,7 +55,9 @@ _(BRIDGE_DOMAIN_ADD_DEL, bridge_domain_add_del)             \
 _(BRIDGE_DOMAIN_DUMP, bridge_domain_dump)                   \
 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details)             \
 _(BRIDGE_DOMAIN_SW_IF_DETAILS, bridge_domain_sw_if_details) \
-_(BRIDGE_FLAGS, bridge_flags)
+_(BRIDGE_FLAGS, bridge_flags)                               \
+_(L2_INTERFACE_VLAN_TAG_REWRITE, l2_interface_vlan_tag_rewrite) \
+_(L2_INTERFACE_PBB_TAG_REWRITE, l2_interface_pbb_tag_rewrite)
 
 static void
 send_l2_xconnect_details (unix_shared_memory_queue_t * q, u32 context,
@@ -454,6 +457,84 @@ out:
   /* *INDENT-ON* */
 }
 
+static void
+  vl_api_l2_interface_vlan_tag_rewrite_t_handler
+  (vl_api_l2_interface_vlan_tag_rewrite_t * mp)
+{
+  int rv = 0;
+  vl_api_l2_interface_vlan_tag_rewrite_reply_t *rmp;
+  vnet_main_t *vnm = vnet_get_main ();
+  vlib_main_t *vm = vlib_get_main ();
+  u32 vtr_op;
+
+  VALIDATE_SW_IF_INDEX (mp);
+
+  vtr_op = ntohl (mp->vtr_op);
+
+  /* The L2 code is unsuspicious */
+  switch (vtr_op)
+    {
+    case L2_VTR_DISABLED:
+    case L2_VTR_PUSH_1:
+    case L2_VTR_PUSH_2:
+    case L2_VTR_POP_1:
+    case L2_VTR_POP_2:
+    case L2_VTR_TRANSLATE_1_1:
+    case L2_VTR_TRANSLATE_1_2:
+    case L2_VTR_TRANSLATE_2_1:
+    case L2_VTR_TRANSLATE_2_2:
+      break;
+
+    default:
+      rv = VNET_API_ERROR_INVALID_VALUE;
+      goto bad_sw_if_index;
+    }
+
+  rv = l2vtr_configure (vm, vnm, ntohl (mp->sw_if_index), vtr_op,
+                       ntohl (mp->push_dot1q), ntohl (mp->tag1),
+                       ntohl (mp->tag2));
+
+  BAD_SW_IF_INDEX_LABEL;
+
+  REPLY_MACRO (VL_API_L2_INTERFACE_VLAN_TAG_REWRITE_REPLY);
+}
+
+static void
+  vl_api_l2_interface_pbb_tag_rewrite_t_handler
+  (vl_api_l2_interface_pbb_tag_rewrite_t * mp)
+{
+  vl_api_l2_interface_pbb_tag_rewrite_reply_t *rmp;
+  vnet_main_t *vnm = vnet_get_main ();
+  vlib_main_t *vm = vlib_get_main ();
+  u32 vtr_op;
+  int rv = 0;
+
+  VALIDATE_SW_IF_INDEX (mp);
+
+  vtr_op = ntohl (mp->vtr_op);
+
+  switch (vtr_op)
+    {
+    case L2_VTR_DISABLED:
+    case L2_VTR_PUSH_2:
+    case L2_VTR_POP_2:
+    case L2_VTR_TRANSLATE_2_1:
+      break;
+
+    default:
+      rv = VNET_API_ERROR_INVALID_VALUE;
+      goto bad_sw_if_index;
+    }
+
+  rv = l2pbb_configure (vm, vnm, ntohl (mp->sw_if_index), vtr_op,
+                       mp->b_dmac, mp->b_smac, ntohs (mp->b_vlanid),
+                       ntohl (mp->i_sid), ntohs (mp->outer_tag));
+
+  BAD_SW_IF_INDEX_LABEL;
+
+  REPLY_MACRO (VL_API_L2_INTERFACE_PBB_TAG_REWRITE_REPLY);
+}
+
 /*
  * l2_api_hookup
  * Add vpe's API message handlers to the table.
index 6317f55..e6227a6 100644 (file)
@@ -62,7 +62,6 @@
 #include <vnet/classify/input_acl.h>
 #include <vnet/l2/l2_classify.h>
 #include <vnet/vxlan/vxlan.h>
-#include <vnet/l2/l2_vtr.h>
 #include <vnet/vxlan-gpe/vxlan_gpe.h>
 #include <vnet/map/map.h>
 #include <vnet/cop/cop.h>
@@ -134,7 +133,6 @@ _(ADD_NODE_NEXT, add_node_next)                                             \
 _(VXLAN_ADD_DEL_TUNNEL, vxlan_add_del_tunnel)                           \
 _(VXLAN_TUNNEL_DUMP, vxlan_tunnel_dump)                                 \
 _(L2_INTERFACE_EFP_FILTER, l2_interface_efp_filter)                     \
-_(L2_INTERFACE_VLAN_TAG_REWRITE, l2_interface_vlan_tag_rewrite)         \
 _(SHOW_VERSION, show_version)                                          \
 _(VXLAN_GPE_ADD_DEL_TUNNEL, vxlan_gpe_add_del_tunnel)                   \
 _(VXLAN_GPE_TUNNEL_DUMP, vxlan_gpe_tunnel_dump)                         \
@@ -160,7 +158,6 @@ _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL,                               \
 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL,                     \
   ip_source_and_port_range_check_interface_add_del)                     \
 _(DELETE_SUBIF, delete_subif)                                           \
-_(L2_INTERFACE_PBB_TAG_REWRITE, l2_interface_pbb_tag_rewrite)           \
 _(PUNT, punt)                                                           \
 _(FEATURE_ENABLE_DISABLE, feature_enable_disable)
 
@@ -1316,48 +1313,6 @@ vl_api_l2_interface_efp_filter_t_handler (vl_api_l2_interface_efp_filter_t *
   REPLY_MACRO (VL_API_L2_INTERFACE_EFP_FILTER_REPLY);
 }
 
-static void
-  vl_api_l2_interface_vlan_tag_rewrite_t_handler
-  (vl_api_l2_interface_vlan_tag_rewrite_t * mp)
-{
-  int rv = 0;
-  vl_api_l2_interface_vlan_tag_rewrite_reply_t *rmp;
-  vnet_main_t *vnm = vnet_get_main ();
-  vlib_main_t *vm = vlib_get_main ();
-  u32 vtr_op;
-
-  VALIDATE_SW_IF_INDEX (mp);
-
-  vtr_op = ntohl (mp->vtr_op);
-
-  /* The L2 code is unsuspicious */
-  switch (vtr_op)
-    {
-    case L2_VTR_DISABLED:
-    case L2_VTR_PUSH_1:
-    case L2_VTR_PUSH_2:
-    case L2_VTR_POP_1:
-    case L2_VTR_POP_2:
-    case L2_VTR_TRANSLATE_1_1:
-    case L2_VTR_TRANSLATE_1_2:
-    case L2_VTR_TRANSLATE_2_1:
-    case L2_VTR_TRANSLATE_2_2:
-      break;
-
-    default:
-      rv = VNET_API_ERROR_INVALID_VALUE;
-      goto bad_sw_if_index;
-    }
-
-  rv = l2vtr_configure (vm, vnm, ntohl (mp->sw_if_index), vtr_op,
-                       ntohl (mp->push_dot1q), ntohl (mp->tag1),
-                       ntohl (mp->tag2));
-
-  BAD_SW_IF_INDEX_LABEL;
-
-  REPLY_MACRO (VL_API_L2_INTERFACE_VLAN_TAG_REWRITE_REPLY);
-}
-
 static void
 vl_api_show_version_t_handler (vl_api_show_version_t * mp)
 {
@@ -2497,43 +2452,6 @@ vl_api_delete_subif_t_handler (vl_api_delete_subif_t * mp)
   REPLY_MACRO (VL_API_DELETE_SUBIF_REPLY);
 }
 
-static void
-  vl_api_l2_interface_pbb_tag_rewrite_t_handler
-  (vl_api_l2_interface_pbb_tag_rewrite_t * mp)
-{
-  vl_api_l2_interface_pbb_tag_rewrite_reply_t *rmp;
-  vnet_main_t *vnm = vnet_get_main ();
-  vlib_main_t *vm = vlib_get_main ();
-  u32 vtr_op;
-  int rv = 0;
-
-  VALIDATE_SW_IF_INDEX (mp);
-
-  vtr_op = ntohl (mp->vtr_op);
-
-  switch (vtr_op)
-    {
-    case L2_VTR_DISABLED:
-    case L2_VTR_PUSH_2:
-    case L2_VTR_POP_2:
-    case L2_VTR_TRANSLATE_2_1:
-      break;
-
-    default:
-      rv = VNET_API_ERROR_INVALID_VALUE;
-      goto bad_sw_if_index;
-    }
-
-  rv = l2pbb_configure (vm, vnm, ntohl (mp->sw_if_index), vtr_op,
-                       mp->b_dmac, mp->b_smac, ntohs (mp->b_vlanid),
-                       ntohl (mp->i_sid), ntohs (mp->outer_tag));
-
-  BAD_SW_IF_INDEX_LABEL;
-
-  REPLY_MACRO (VL_API_L2_INTERFACE_PBB_TAG_REWRITE_REPLY);
-
-}
-
 static void
 vl_api_punt_t_handler (vl_api_punt_t * mp)
 {
index 3a35a54..981ae25 100644 (file)
@@ -797,36 +797,6 @@ define l2_interface_efp_filter_reply
   i32 retval;
 };
 
-/** \brief L2 interface vlan tag rewrite configure request
-    @param client_index - opaque cookie to identify the sender
-    @param context - sender context, to match reply w/ request
-    @param sw_if_index - interface the operation is applied to
-    @param vtr_op - Choose from l2_vtr_op_t enum values
-    @param push_dot1q - first pushed flag dot1q id set, else dot1ad
-    @param tag1 - Needed for any push or translate vtr op
-    @param tag2 - Needed for any push 2 or translate x-2 vtr ops
-*/
-define l2_interface_vlan_tag_rewrite
-{
-  u32 client_index;
-  u32 context;
-  u32 sw_if_index;
-  u32 vtr_op;
-  u32 push_dot1q;              // ethertype of first pushed tag is dot1q/dot1ad
-  u32 tag1;                    // first pushed tag
-  u32 tag2;                    // second pushed tag
-};
-
-/** \brief L2 interface vlan tag rewrite response
-    @param context - sender context, to match reply w/ request
-    @param retval - return code for the request
-*/
-define l2_interface_vlan_tag_rewrite_reply
-{
-  u32 context;
-  i32 retval;
-};
-
 define create_subif
 {
   u32 client_index;
@@ -1475,41 +1445,6 @@ define delete_subif_reply {
   i32 retval;
 };
 
-/** \brief L2 interface pbb tag rewrite configure request
-    @param client_index - opaque cookie to identify the sender
-    @param context - sender context, to match reply w/ request
-    @param sw_if_index - interface the operation is applied to
-    @param vtr_op - Choose from l2_vtr_op_t enum values
-    @param inner_tag - needed for translate_qinq vtr op only
-    @param outer_tag - needed for translate_qinq vtr op only 
-    @param b_dmac - B-tag remote mac address, needed for any push or translate_qinq vtr op
-    @param b_smac - B-tag local mac address, needed for any push or translate qinq vtr op
-    @param b_vlanid - B-tag vlanid, needed for any push or translate qinq vtr op
-    @param i_sid - I-tag service id, needed for any push or translate qinq vtr op
-*/
-define l2_interface_pbb_tag_rewrite
-{
-  u32 client_index;
-  u32 context;
-  u32 sw_if_index;
-  u32 vtr_op;
-  u16 outer_tag;
-  u8  b_dmac[6];
-  u8  b_smac[6];
-  u16 b_vlanid;
-  u32 i_sid;
-};
-
-/** \brief L2 interface pbb tag rewrite response
-    @param context - sender context, to match reply w/ request
-    @param retval - return code for the request
-*/
-define l2_interface_pbb_tag_rewrite_reply
-{
-  u32 context;
-  i32 retval;
-};
-
 /** \brief Punt traffic to the host
     @param client_index - opaque cookie to identify the sender
     @param context - sender context, to match reply w/ request