/* * Copyright (c) 2015 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. */ /* * interface.h: VNET interfaces/sub-interfaces * * Copyright (c) 2008 Eliot Dresselhaus * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #ifndef included_vnet_interface_h #define included_vnet_interface_h #include #include struct vnet_main_t; struct vnet_hw_interface_t; struct vnet_sw_interface_t; struct ip46_address_t; typedef enum { VNET_HW_INTERFACE_RX_MODE_UNKNOWN, VNET_HW_INTERFACE_RX_MODE_POLLING, VNET_HW_INTERFACE_RX_MODE_INTERRUPT, VNET_HW_INTERFACE_RX_MODE_ADAPTIVE, VNET_HW_INTERFACE_RX_MODE_DEFAULT, VNET_HW_INTERFACE_NUM_RX_MODES, } vnet_hw_interface_rx_mode; /* Interface up/down callback. */ typedef clib_error_t *(vnet_interface_function_t) (struct vnet_main_t * vnm, u32 if_index, u32 flags); /* Sub-interface add/del callback. */ typedef clib_error_t *(vnet_subif_add_del_function_t) (struct vnet_main_t * vnm, u32 if_index, struct vnet_sw_interface_t * template, int is_add); /* Interface set mac address callback. */ typedef clib_error_t *(vnet_interface_set_mac_address_function_t) (struct vnet_hw_interface_t * hi, const u8 * old_address, const u8 * new_address); /* Interface set rx mode callback. */ typedef clib_error_t *(vnet_interface_set_rx_mode_function_t) (struct vnet_main_t * vnm, u32 if_index, u32 queue_id, vnet_hw_interface_rx_mode mode); /* Interface set l2 mode callback. */ typedef clib_error_t *(vnet_interface_set_l2_mode_function_t) (struct vnet_main_t * vnm, struct vnet_hw_interface_t * hi, i32 l2_if_adjust); typedef enum { VNET_FLOW_DEV_OP_ADD_FLOW, VNET_FLOW_DEV_OP_DEL_FLOW, VNET_FLOW_DEV_OP_GET_COUNTER, VNET_FLOW_DEV_OP_RESET_COUNTER, } vnet_flow_dev_op_t; /* Interface flow operations callback. */ typedef int (vnet_flow_dev_ops_function_t) (struct vnet_main_t * vnm, vnet_flow_dev_op_t op, u32 hw_if_index, u32 index, uword * private_data); typedef enum vnet_interface_function_priority_t_ { VNET_ITF_FUNC_PRIORITY_LOW, VNET_ITF_FUNC_PRIORITY_HIGH, } vnet_interface_function_priority_t; #define VNET_ITF_FUNC_N_PRIO ((vnet_interface_function_priority_t)VNET_ITF_FUNC_PRIORITY_HIGH+1) typedef struct _vnet_interface_function_list_elt { struct _vnet_interface_function_list_elt *next_interface_function; clib_error_t *(*fp) (struct vnet_main_t * vnm, u32 if_index, u32 flags); } _vnet_interface_function_list_elt_t; #ifndef CLIB_MARCH_VARIANT #define _VNET_INTERFACE_FUNCTION_DECL_PRIO(f,tag,p) \ \ static void __vnet_interface_function_init_##tag##_##f (void) \ __attribute__((__constructor__)) ; \ \ static void __vnet_interface_function_init_##tag##_##f (void) \ { \ vnet_main_t * vnm = vnet_get_main(); \ static _vnet_interface_function_list_elt_t init_function; \ init_function.next_interface_function = vnm->tag##_functions[p]; \ vnm->tag##_functions[p] = &init_function; \ init_function.fp = (void *) &f; \ } \ static void __vnet_interface_function_deinit_##tag##_##f (void) \ __attribute__((__destructor__)) ; \ \ static void __vnet_interface_function_deinit_##tag##_##f (void) \ { \ vnet_main_t * vnm = vnet_get_main(); \ _vnet_interface_function_list_elt_t *next; \ if (vnm->tag##_functions[p]->fp == (void *) &f) \ { \ vnm->tag##_functions[p] = \ vnm->tag##_functions[p]->next_interface_function; \ return; \ } \ next = vnm->tag##_functions[p]; \ while (next->next_interface_function) \ { \ if (next->next_interface_function->fp == (void *) &f) \ { \ next->next_interface_function = \ next->next_interface_function->next_interface_function; \ return; \ } \ next = next->next_interface_function; \ }
<?xml version="1.0" encoding="UTF-8"?>
<!--
 Copyright (c) 2015 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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

  <parent>
    <groupId>io.fd.honeycomb.common</groupId>
    <artifactId>minimal-distribution-parent</artifactId>
    <version>1.16.12-SNAPSHOT</version>
    <relativePath>../../common/minimal-distribution-parent</relativePath>
  </parent>

  <modelVersion>4.0.0</modelVersion>
  <groupId>io.fd.honeycomb.vpp.integration</groupId>
  <artifactId>vpp-integration-distribution</artifactId>
  <version>1.16.12-SNAPSHOT</version>

  <properties>
    <main.class>io.fd.honeycomb.vpp.integration.distro.Main</main.class>
    <v3po.version>1.16.12-SNAPSHOT</v3po.version>
    <lisp.version>1.16.12-SNAPSHOT</lisp.version>
    <vpp.common.min.distro.version>1.16.12-SNAPSHOT</vpp.common.min.distro.version>
    <vppnsh.version>1.16.12-SNAPSHOT</vppnsh.version>
  </properties>

  <build>
    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
      </plugin>
      <plugin>
        <groupId>org.codehaus.gmaven</groupId>
        <artifactId>groovy-maven-plugin</artifactId>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
      </plugin>
      <plugin>
        <artifactId>maven-assembly-plugin</artifactId>
      </plugin>
    </plugins>
  </build>

  <dependencies>
    <dependency>
      <groupId>io.fd.honeycomb.vpp</groupId>
      <artifactId>minimal-distribution</artifactId>
      <version>${vpp.common.min.distro.version}</version>
    </dependency>
    <dependency>
      <groupId>io.fd.honeycomb.v3po</groupId>
      <artifactId>v3po2vpp</artifactId>
      <version>${v3po.version}</version>
    </dependency>
    <dependency>
      <groupId>io.fd.honeycomb.lisp</groupId>
      <artifactId>lisp2vpp</artifactId>
      <version>${lisp.version}</version>
    </dependency>
    <dependency>
      <groupId>io.fd.honeycomb.vppnsh</groupId>
      <artifactId>vppnsh-impl</artifactId>
      <version>${vppnsh.version}</version>
    </dependency>
  </dependencies>
</project>
I interface */ VNET_FLOOD_CLASS_BVI, /* Always flood */ VNET_FLOOD_CLASS_NORMAL, VNET_FLOOD_CLASS_TUNNEL_MASTER, /* Does not flood when tunnel master is in the same L2 BD */ VNET_FLOOD_CLASS_TUNNEL_NORMAL, /* Never flood to this type */ VNET_FLOOD_CLASS_NO_FLOOD, } vnet_flood_class_t; /* Per protocol MTU */ typedef enum { VNET_MTU_L3, /* Default payload MTU (without L2 headers) */ VNET_MTU_IP4, /* Per-protocol MTUs overriding default */ VNET_MTU_IP6, VNET_MTU_MPLS, VNET_N_MTU } vnet_mtu_t; extern vnet_mtu_t vnet_link_to_mtu (vnet_link_t link); typedef enum vnet_sw_interface_flags_t_ { VNET_SW_INTERFACE_FLAG_NONE = 0, /* Interface is "up" meaning administratively up. Up in the sense of link state being up is maintained by hardware interface. */ VNET_SW_INTERFACE_FLAG_ADMIN_UP = (1 << 0), /* Interface is disabled for forwarding: punt all traffic to slow-path. */ VNET_SW_INTERFACE_FLAG_PUNT = (1 << 1), VNET_SW_INTERFACE_FLAG_PROXY_ARP = (1 << 2), VNET_SW_INTERFACE_FLAG_UNNUMBERED = (1 << 3), VNET_SW_INTERFACE_FLAG_BOND_SLAVE = (1 << 4), /* Interface does not appear in CLI/API */ VNET_SW_INTERFACE_FLAG_HIDDEN = (1 << 5), /* Interface in ERROR state */ VNET_SW_INTERFACE_FLAG_ERROR = (1 << 6), /* Interface has IP configured directed broadcast */ VNET_SW_INTERFACE_FLAG_DIRECTED_BCAST = (1 << 7), } __attribute__ ((packed)) vnet_sw_interface_flags_t; /* Software-interface. This corresponds to a Ethernet VLAN, ATM vc, a tunnel, etc. Configuration (e.g. IP address) gets attached to software interface. */ typedef struct { vnet_sw_interface_type_t type:16; vnet_sw_interface_flags_t flags; /* Index for this interface. */ u32 sw_if_index; /* Software interface index of super-interface; equal to sw_if_index if this interface is not a sub-interface. */ u32 sup_sw_if_index; /* this swif is unnumbered, use addresses on unnumbered_sw_if_index... */ u32 unnumbered_sw_if_index; /* VNET_SW_INTERFACE_TYPE_HARDWARE. */ u32 hw_if_index; /* MTU for network layer (not including L2 headers) */ u32 mtu[VNET_N_MTU]; /* VNET_SW_INTERFACE_TYPE_SUB. */ vnet_sub_interface_t sub; /* VNET_SW_INTERFACE_TYPE_P2P. */ vnet_p2p_sub_interface_t p2p; vnet_flood_class_t flood_class; } vnet_sw_interface_t; typedef enum { /* Simple counters. */ VNET_INTERFACE_COUNTER_DROP = 0, VNET_INTERFACE_COUNTER_PUNT = 1, VNET_INTERFACE_COUNTER_IP4 = 2, VNET_INTERFACE_COUNTER_IP6 = 3, VNET_INTERFACE_COUNTER_RX_NO_BUF = 4, VNET_INTERFACE_COUNTER_RX_MISS = 5, VNET_INTERFACE_COUNTER_RX_ERROR = 6, VNET_INTERFACE_COUNTER_TX_ERROR = 7, VNET_INTERFACE_COUNTER_MPLS = 8, VNET_N_SIMPLE_INTERFACE_COUNTER = 9, /* Combined counters. */ VNET_INTERFACE_COUNTER_RX = 0, VNET_INTERFACE_COUNTER_RX_UNICAST = 1, VNET_INTERFACE_COUNTER_RX_MULTICAST = 2, VNET_INTERFACE_COUNTER_RX_BROADCAST = 3, VNET_INTERFACE_COUNTER_TX = 4, VNET_INTERFACE_COUNTER_TX_UNICAST = 5, VNET_INTERFACE_COUNTER_TX_MULTICAST = 6, VNET_INTERFACE_COUNTER_TX_BROADCAST = 7, VNET_N_COMBINED_INTERFACE_COUNTER = 8, } vnet_interface_counter_type_t; #define foreach_rx_combined_interface_counter(_x) \ for (_x = VNET_INTERFACE_COUNTER_RX; \ _x <= VNET_INTERFACE_COUNTER_RX_BROADCAST; \ _x++) #define foreach_tx_combined_interface_counter(_x) \ for (_x = VNET_INTERFACE_COUNTER_TX; \ _x <= VNET_INTERFACE_COUNTER_TX_BROADCAST; \ _x++) #define foreach_simple_interface_counter_name \ _(DROP, drops, if) \ _(PUNT, punt, if) \ _(IP4, ip4, if) \ _(IP6, ip6, if) \ _(RX_NO_BUF, rx-no-buf, if) \ _(RX_MISS, rx-miss, if) \ _(RX_ERROR, rx-error, if) \ _(TX_ERROR, tx-error, if) #define foreach_combined_interface_counter_name \ _(RX, rx, if) \ _(RX_UNICAST, rx-unicast, if) \ _(RX_MULTICAST, rx-multicast, if) \ _(RX_BROADCAST, rx-broadcast, if) \ _(TX, tx, if) \ _(TX_UNICAST, tx-unicast-miss, if) \ _(TX_MULTICAST, tx-multicast, if) \ _(TX_BROADCAST, tx-broadcast, if) typedef enum { COLLECT_SIMPLE_STATS = 0, COLLECT_DETAILED_STATS = 1, } vnet_interface_stats_collection_mode_e; extern int collect_detailed_interface_stats_flag; static inline int collect_detailed_interface_stats (void) { return collect_detailed_interface_stats_flag; } void collect_detailed_interface_stats_flag_set (void); void collect_detailed_interface_stats_flag_clear (void); typedef struct { u32 output_node_index; u32 tx_node_index; } vnet_hw_interface_nodes_t; typedef struct { /* Hardware interfaces. */ vnet_hw_interface_t *hw_interfaces; /* Hash table mapping HW interface name to index. */ uword *hw_interface_by_name; /* Vectors if hardware interface classes and device classes. */ vnet_hw_interface_class_t *hw_interface_classes; vnet_device_class_t *device_classes; /* Hash table mapping name to hw interface/device class. */ uword *hw_interface_class_by_name; uword *device_class_by_name; /* Software interfaces. */ vnet_sw_interface_t *sw_interfaces; /* Hash table mapping sub intfc sw_if_index by sup sw_if_index and sub id */ uword *sw_if_index_by_sup_and_sub; /* Software interface counters both simple and combined packet and byte counters. */ volatile u32 *sw_if_counter_lock; vlib_simple_counter_main_t *sw_if_counters; vlib_combined_counter_main_t *combined_sw_if_counters; vnet_hw_interface_nodes_t *deleted_hw_interface_nodes; /* pcap drop tracing */ int drop_pcap_enable; pcap_main_t pcap_main; u8 *pcap_filename; u32 pcap_sw_if_index; u32 pcap_pkts_to_capture; uword *pcap_drop_filter_hash; /* feature_arc_index */ u8 output_feature_arc_index; } vnet_interface_main_t; static inline void vnet_interface_counter_lock (vnet_interface_main_t * im) { if (im->sw_if_counter_lock) while (clib_atomic_test_and_set (im->sw_if_counter_lock)) /* zzzz */ ; } static inline void vnet_interface_counter_unlock (vnet_interface_main_t * im) { if (im->sw_if_counter_lock) clib_atomic_release (im->sw_if_counter_lock); } void vnet_pcap_drop_trace_filter_add_del (u32 error_index, int is_add); int vnet_interface_name_renumber (u32 sw_if_index, u32 new_show_dev_instance); #endif /* included_vnet_interface_h */ /* * fd.io coding-style-patch-verification: ON * * Local Variables: * eval: (c-set-style "gnu") * End: */