summaryrefslogtreecommitdiffstats
path: root/vnet
AgeCommit message (Collapse)AuthorFilesLines
2016-06-01VPP-98 Dedicated storage for VXLAN over IPv6 hash keysChris Luke3-53/+66
When creating VXLAN over IPv6 the code was using storage for the hash key that could later be moved. Since the key is larger than the word size this was being referenced as a pointer; when the storage moves that breaks the hash. Instead allocate dedicated storage for the key. This patch also includes other minor cleanups, including using clib_memcpy in places it should be used and some whitespace fixes. Change-Id: I579f2cb515853ef56dedcca350fcad08aa6111a9 Signed-off-by: Chris Luke <chrisy@flirble.org>
2016-05-31VPP-102: vHost reconnect to previously used sockets on VPP restartJohn Lo1-0/+8
Change-Id: Ida11bddb52268e0e8513b7b379eeed6103bd48f1 Signed-off-by: John Lo <loj@cisco.com>
2016-05-31VPP97: Flooding of pkts with multiple buffers in BD with BVI crashes VPPJohn Lo2-9/+3
The loopback interface should use vnet_interface_output_no_flatten so follow-on buffers of a jumbo packet do not get put on the output frame and be sent back to ethernet-input or l2-input node. The replication_recycle_callback() function should not assume follow-on buffers of a jumbo packet are on the buffer free list. Change-Id: Ide646a6d9b43e82782c0581ea3022a9e70f82582 Signed-off-by: John Lo <loj@cisco.com>
2016-05-31Fix hash table bogus read in ip6 vxlan-gpeFlorin Coras2-13/+3
- consistent use of hash_*_mem methods. - tunnel setup copies the key from the wrong location - remove extraneous storage for keys copied from the vxlan node that is not applicable here Change-Id: I419fd30a52ba387104abe467c296de85233823d1 Signed-off-by: Florin Coras <fcoras@cisco.com> Signed-off-by: Chris Luke <chrisy@flirble.org>
2016-05-31Add CLI/API for clearing all remote mappingsFilip Tehlar2-24/+81
Change-Id: I5aef12d3a9c8daefff52e5f958c504f5d2ff9fd0 Signed-off-by: Filip Tehlar <ftehlar@cisco.com>
2016-05-31ONE-15: Fix duplicate locator, refactoring locatorAndrej Kozemcak2-244/+154
Check duplication locator and clean after locator when remove it. Refactoring locator_set code. Change-Id: Ib83cbcddc7a363a60fa5b6a366203d0dc0ea7ca6 Signed-off-by: Andrej Kozemcak <akozemca@cisco.com>
2016-05-31ONE-16: Locators are not properly cleanedFilip Tehlar1-2/+16
Change-Id: Ia6eaaa9a741e84cbd0ff957cfd9a7143a3d0a977 Signed-off-by: Filip Tehlar <ftehlar@cisco.com>
2016-05-30Add Dump API for VxLAN-GPE tunnelHongjun Ni2-31/+10
Change-Id: I4913fe6c4b1280939147887896aea9b79a9f7f10 Signed-off-by: Hongjun Ni <hongjun.ni@intel.com>
2016-05-28VPP-84 af_packet retry on EAGAIN, count on errorsChris Luke2-9/+32
When af_packet signals the kernel that there are packets in the tx ring with sendto() the kernel sometimes responds with EAGAIN. Previously the af_packet driver would treat any error from sendto() as fatal. Whilst there's not much we can do about this, count the errors and let's try to not die on the spot or sit in a loop forever. Change-Id: Id76ba5e07b744f1ed6f348ec838a1ac506a381c9 Signed-off-by: Chris Luke <chrisy@flirble.org>
2016-05-28VPP-96 ENID driver update for rx of jumbo pkts using muliple mbuf'sJohn Lo2-2/+2
Change-Id: I0e985b079da3224f4886e3ee2cece4d046e291eb Signed-off-by: John Lo <loj@cisco.com>
2016-05-26Add show command for LISP map resolversFilip Tehlar1-0/+21
Change-Id: I3ed6269f9a307b50b56ce04defc2576a139c6add Signed-off-by: Filip Tehlar <ftehlar@cisco.com>
2016-05-25Move dpdk startup config data to separate structDamjan Marion7-137/+147
This is preparation work for moving DPDK EAL and mempool initialization to vlib. Change-Id: I2dc35aa53edec0e07fc2650d630aa625831154c3 Signed-off-by: Damjan Marion <damarion@cisco.com>
2016-05-25ONE-14: Fix crash when re-enable LispAndrej Kozemcak1-4/+9
Change-Id: Ib95338d7055dea9036eddb7dff5ca7ccbcb35639 Signed-off-by: Andrej Kozemcak <akozemca@cisco.com>
2016-05-25Add Vxlan-Gpe over IPv6Hongjun Ni5-703/+964
PatchSet4: consolidate code as per comments. PatchSet3: simplify the code using ip_udp_encap_one/two PatchSet2: consolidate comments and indent style Change-Id: Ia8b43f854a46d77e838e198566200ad28fd72472 Signed-off-by: Hongjun Ni <hongjun.ni@intel.com>
2016-05-24Fix an issue in format_vxlan_gpe_tunnelHongjun Ni1-0/+4
Change-Id: Ib283c75505b787f715e34f5b325dda8a6c2fa125 Signed-off-by: Hongjun Ni <hongjun.ni@intel.com>
2016-05-23Native VPP driver for Intel Niantic family of NICsDamjan Marion5-0/+4268
Available only in vpp_lite platform Change-Id: I09d112af5f7f4521ec25196ecdd8c02c20eedd5f Signed-off-by: Damjan Marion <damarion@cisco.com>
2016-05-23Move rte_delay_us_override so it overrides DPDKTodd Foggoa2-42/+6
The current location in the vnet dynamic library does not override the dpdk weak function as intented. Moving this function to the main app allows the linker to find the non-weak symbol and override it. Change-Id: I96c6dc5af2e511cc1f84bd66419c5a4ac96a9541 Signed-off-by: Todd Foggoa <tfoggoa@cisco.com>
2016-05-23VPP-81: Print interface name after creating an interface with CLIPierre Pfister16-20/+46
When the CLI is used to create an interface, and whend the operation succeeds, the newly created interface name is printed-out. The patch includes the following interfaces types: - AF_PACKET - Vhost User - Netmap - GRE - L2TP - MPLS-GRE - Loopback Change-Id: Id518c139ec63a261eae81d2ed95c4cd1f10b5157 Signed-off-by: Pierre Pfister <ppfister@cisco.com>
2016-05-23Add LISP RTR supportFilip Tehlar4-43/+297
Change-Id: I8a3770f8f1cd1fde6765b81d35aacaaf4ff98b82 Signed-off-by: Filip Tehlar <ftehlar@cisco.com>
2016-05-19Add support for multiple microarchitectures in single binaryDamjan Marion60-14/+280
* compiler -march= parameter is changed from native to corei7 so code is always genereted with instructions which are available on the Nehalem microarchitecture (up to SSE4.2) * compiler -mtune= parameter is added so code is optimized for corei7-avx which equals to Sandy Bridge microarchitecture * set of macros is added which allows run-time detection of available cpu instructions (e.g. clib_cpu_supports_avx()) * set of macros is added which allows us to clone graph node funcitons where cloned function is optmized for different microarchitecture Those macros are using following attributes: __attribute__((flatten)) __attribute__((target("arch=core-avx2))) I.e. If applied to foo_node_fn() macro will generate cloned functions foo_node_fn_avx2() and foo_node_fn_avx512() (future) It will also generate function void * foo_node_fn_multiarch_select() which detects available instruction set and returns pointer to the best matching function clone. Change-Id: I2dce0ac92a5ede95fcb56f47f3d1f3c4c040bac0 Signed-off-by: Damjan Marion <damarion@cisco.com>
2016-05-18Add netmap APIMatus Fabian4-6/+17
JIRA: VPP-66 Change-Id: I421529fa8eafe5268745a34a4fcd40156defcdf8 Signed-off-by: Matus Fabian <matfabia@cisco.com>
2016-05-18Rework of the old PCI codeDamjan Marion1-4/+3
* adds support for VPP native PCI drivers using standard uio_pci_generic kernel driver * adds generic PCI interrupt callback * splits code to generic PCI handling and linux specific * adds new debug cli 'show pci [all]' Change-Id: I447c2285e319e9725d70688c1b70c9dedda51fdc Signed-off-by: Damjan Marion <damarion@cisco.com>
2016-05-17dpdk/build - 32bits compilationChristophe Fontaine3-27/+27
In vnet/vnet/devices/dpdk/device.c, post 2 event data instead of merging them into 1 u64. Change-Id: I8b1d61b894279fb6eb57bb82a05affc14360e6b8 Signed-off-by: Christophe Fontaine <christophe.fontaine@qosmos.com>
2016-05-17dpdk/init - Add compatibility to non numa architectureChristophe Fontaine1-4/+25
On non numa aware platforms, the path "/sys/devices/system/node/node%u" does not exist: the "free_hugepages" count is available in "/sys/kernel/mm/". Change-Id: Id62018a2bd0937d267663699c620e89d02c26a72 Signed-off-by: Christophe Fontaine <christophe.fontaine@qosmos.com>
2016-05-17Fix output feature issue where opque field is already used by previous nodeDamjan Marion2-3/+8
Change-Id: I1470993668fa8c740229149bbb227bd1e410d5ab Signed-off-by: Damjan Marion <damarion@cisco.com>
2016-05-16VPP-61 Patch2/2 Removing NSH from VPP for move to NSH_SFCKeith Burns (alagalah)10-1038/+5
Change-Id: I76359b621b2edc599cf2e9ee845d97293a5d46f7 Signed-off-by: Keith Burns (alagalah) <alagalah@gmail.com>
2016-05-16VPP-61 Patch1/2 - Remove NSH from VPPKeith Burns (alagalah)4-73/+0
- Had issues with original patch and CSIT, breaking into -- Makefile and API changes -- Follow up patch removing NSH directory Change-Id: I6c2f49a74d59b97ce4ea43799cc6f01f5cb1d5a2 Signed-off-by: Keith Burns (alagalah) <alagalah@gmail.com>
2016-05-16Add configure policer APIMatus Fabian3-43/+57
JIRA: VPP-67 Change-Id: I04560d78e2eb131cd6cc31472b70b3d3e8fdd79a Signed-off-by: Matus Fabian <matfabia@cisco.com>
2016-05-16VPP-68: L2 Rewrite: Support for chained classify tablesPierre Pfister1-0/+18
The classifying capabilities are pretty limited if only a single table can be used. This patch adds support for chained classify tables to L2 Rewrite feature. Change-Id: Ib678fe2028f17b441adb75d85bf3e31185e42c59 Signed-off-by: Pierre Pfister <ppfister@cisco.com>
2016-05-16VPP-69: Create fib or bridge domain with arbitrary IDPierre Pfister6-3/+89
It appeared to me that it might be usefull to allow users to create fibs or bridge domains without a complete knowledge of the current used IDs. These changes define fib and bridge domain constructors when the provided ID is ~0. In such a case, an unused ID is used to create a new fib or bridge domain. Change-Id: Iaba69a023296e6d17bdde45980f9db84832a3995 Signed-off-by: Pierre Pfister <ppfister@cisco.com>
2016-05-15ONE-13: Add CLI/API for LISP static remote mappingsFilip Tehlar4-1/+252
Change-Id: Ic4c717af9629541bac0a0e6c65d0157619c8f578 Signed-off-by: Filip Tehlar <ftehlar@cisco.com>
2016-05-14VPP-63: clean up config scripts, remove specific hostnamesDave Barach37-59/+45
Change-Id: Ifb77256fa691b1a90045a10448835c09b764e74f Signed-off-by: Dave Barach <dave@barachs.net>
2016-05-13ONE-7: Fix map-request encapsulationFlorin Coras1-68/+81
We now try to find the first map-resolver IP we have a route to and decide the ip lookup node according to map-resolver IP. Change-Id: I68fc12861dc1e9a203ebf6caefd4f053a741a785 Signed-off-by: Florin Coras <fcoras@cisco.com>
2016-05-13VPP43 - NSH refactoring: Added nsh-map nodesKeith Burns (alagalah)19-2440/+1672
- removed vnet/vnet/nsh-gre - removed all nsh from vnet/vnet/nsh_vxlan_gpe to vnet/vnet/nsh - moved vnet/vnet/nsh_vxlan_gpe to vnet/vnet/vxlan_gpe - added cli and binary api for VXLAN GPE tunnels - plan to move vnet/vnet/nsh to new repo (sfc_nsh) and make plugin - added cli for NSH (binary API will be done in sfc_nsh) - vnet/vnet/gre will be extended in VPP-54 Change-Id: I1d27def916532321577ccd68cb982ae0d0a07e6f Signed-off-by: Keith Burns (alagalah) <alagalah@gmail.com>
2016-05-13ONE-11: Fix bugs in LISP APIAndrej Kozemcak1-1/+1
- check input variables - in locator_set dump, add support for remote locator_set Change-Id: Ib10028e83fead358f820ae45c71b6ca4dfbe2f1e Signed-off-by: Andrej Kozemcak <akozemca@cisco.com>
2016-05-11ONE-9: Fix clang build errorsFlorin Coras2-4/+4
Change-Id: Icbf3e269471ee0fc1d21f842b2ea220328a0f891 Signed-off-by: Florin Coras <fcoras@cisco.com>
2016-05-11ONE-8: Fix adj signature issuesFlorin Coras2-29/+37
When inserting routes into ip4/6 fibs, we first added a dummy adjacency and afterwards manually updated its rewrite header to enable src/dst forwarding. The downside to this is that the adj signature is changed and therefore when deleting a route the adjacency signature is not removed from adj_index_by_signature hash resulting in crash if the same adjacency is re-inserted. This patch avoids the issue by enforcing the insertion of 'complete' adjacencies thereby obviating the need to update the rewrite header. Change-Id: Ib43bfe72a65e2cf9ef7685a99596eb1d7723e543 Signed-off-by: Florin Coras <fcoras@cisco.com>
2016-05-11ONE-6: dp is not programmed when re-enabling LISPFilip Tehlar1-6/+24
Change-Id: I4c0c5d44168da811a713943275430a378ff46929 Signed-off-by: Filip Tehlar <ftehlar@cisco.com>
2016-05-10ONE-4: Add LISP enable/disable API/CLIFilip Tehlar4-0/+147
This patch adds an enable/disable API/CLI for control plane which calls similar functions for data plane. When re-enabling it also re-populates dataplane with tunnels and interfaces. Change-Id: Id8c3d6af90ecc0be331d502756914b1f62824046 Signed-off-by: Filip Tehlar <ftehlar@cisco.com>
2016-05-09ONE-3: Delete dst route when src fib is emptyFlorin Coras1-1/+21
Properly check that src fib is empty. Change-Id: I4072169027a404cad66eaaa8450f7c18f1fa8073 Signed-off-by: Florin Coras <fcoras@cisco.com>
2016-05-09VPP-44: iOAM service and path verification using shamir's secret sharingShwetha Bhandari7-12/+1127
Change-Id: I445ad13f8f93cb75cacc94192c4ae85c8ca14e35 Signed-off-by: Shwetha Bhandari <shwethab@cisco.com>
2016-05-09ONE-5: Remove unused vnet_lisp_gpe_add_del_tunnel APIFlorin Coras2-46/+23
Change-Id: Ib22ec807d2b74b7c3cb37f66052cd07bc4d896db Signed-off-by: Florin Coras <fcoras@cisco.com>
2016-05-07VPP-45 Fix crash when GRE packet received on new i/fChris Luke1-0/+3
If a GRE tunnel is created, no other interface added and the GRE tunnel is not set "up" then a crash occurs on the first packet for this tunnel because fib_index_by_sw_if_index[] does not yet have a mapping to the fib the new interface is in. The code to set this is missing from gre/interface.c Change-Id: I567ad74a2af3ea5afe4a40ed39a1d4395642f77c Signed-off-by: Chris Luke <chrisy@flirble.org>
2016-05-06VPP-34 GRE traffic blackholes in encap directionChris Luke1-1/+12
The GRE code is missing the logic to indicate the "hardware" interface is up. The fix is to listen for admin up/down events on the "software" interface and reflect that into the hardware interface state. Change-Id: If06e4f03989b2c52c32f50c11e1943e42bb2609f Signed-off-by: Chris Luke <chrisy@flirble.org>
2016-05-06Check IP adj_index to make sure it is valid to prevent possible crashJohn Lo2-2/+6
Change-Id: I439aac05638fd40e314bec8756e42a32c436321c Signed-off-by: John Lo <loj@cisco.com>
2016-05-05Fix vpp_lite build caused by missing definition of unlikely macroDamjan Marion1-1/+1
Change-Id: I11b34e171c1c7907dd3faec219866418b4e792f6 Signed-off-by: Damjan Marion <damarion@cisco.com>
2016-05-05ONE-2: Add new LISP dump API for lisp gpeAndrej Kozemcak2-0/+14
API: lisp_gpe_enable_disable_dump Change-Id: I1c8e78f00f9a3f99c1f2f54884af565292e4ccf8 Signed-off-by: Andrej Kozemcak <akozemca@cisco.com>
2016-05-05VPP-39 - refactoring of NSH into own folderKeith Burns (alagalah)8-136/+140
- common header files and structs used in both GRE and VXLAN-GPE Change-Id: I06d0b773e936fb011408817237059f24a4beb412 Signed-off-by: Keith Burns (alagalah) <alagalah@gmail.com>
2016-05-04NETMAP: Some fixesMohsin Kazmi3-11/+36
1) Correct the NIOCRXSYNC macro on receive side from NIOCTXSYNC. 2) Flush the pending messages in the tx rings. Change-Id: I581040d03b1633a3d6fb22fa1fb285bcb7975afb Signed-off-by: Mohsin Kazmi <sykazmi@cisco.com>
2016-05-04VPP-42: VPP crashes in IPsec code when running multithreadedMatthew Smith5-33/+58
Change-Id: Ib231642cfead5f5e8e45508361a11c87aad83b51 Signed-off-by: Matthew Smith <mgsmith@netgate.com>
unction_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; \ } \ } #else /* create unused pointer to silence compiler warnings and get whole function optimized out */ #define _VNET_INTERFACE_FUNCTION_DECL_PRIO(f,tag,p) \ static __clib_unused void * __clib_unused_##f = f; #endif #define _VNET_INTERFACE_FUNCTION_DECL(f,tag) \ _VNET_INTERFACE_FUNCTION_DECL_PRIO(f,tag,VNET_ITF_FUNC_PRIORITY_LOW) #define VNET_HW_INTERFACE_ADD_DEL_FUNCTION(f) \ _VNET_INTERFACE_FUNCTION_DECL(f,hw_interface_add_del) #define VNET_HW_INTERFACE_LINK_UP_DOWN_FUNCTION(f) \ _VNET_INTERFACE_FUNCTION_DECL(f,hw_interface_link_up_down) #define VNET_HW_INTERFACE_LINK_UP_DOWN_FUNCTION_PRIO(f,p) \ _VNET_INTERFACE_FUNCTION_DECL_PRIO(f,hw_interface_link_up_down,p) #define VNET_SW_INTERFACE_MTU_CHANGE_FUNCTION(f) \ _VNET_INTERFACE_FUNCTION_DECL(f,sw_interface_mtu_change) #define VNET_SW_INTERFACE_ADD_DEL_FUNCTION(f) \ _VNET_INTERFACE_FUNCTION_DECL(f,sw_interface_add_del) #define VNET_SW_INTERFACE_ADMIN_UP_DOWN_FUNCTION(f) \ _VNET_INTERFACE_FUNCTION_DECL(f,sw_interface_admin_up_down) #define VNET_SW_INTERFACE_ADMIN_UP_DOWN_FUNCTION_PRIO(f,p) \ _VNET_INTERFACE_FUNCTION_DECL_PRIO(f,sw_interface_admin_up_down, p) /* A class of hardware interface devices. */ typedef struct _vnet_device_class { /* Index into main vector. */ u32 index; /* Device name (e.g. "FOOBAR 1234a"). */ char *name; /* Function to call when hardware interface is added/deleted. */ vnet_interface_function_t *interface_add_del_function; /* Function to bring device administratively up/down. */ vnet_interface_function_t *admin_up_down_function; /* Function to call when sub-interface is added/deleted */ vnet_subif_add_del_function_t *subif_add_del_function; /* Function to call interface rx mode is changed */ vnet_interface_set_rx_mode_function_t *rx_mode_change_function; /* Function to call interface l2 mode is changed */ vnet_interface_set_l2_mode_function_t *set_l2_mode_function; /* Redistribute flag changes/existence of this interface class. */ u32 redistribute; /* Transmit function. */ vlib_node_function_t *tx_function; /* Transmit function candidate registration with priority */ vlib_node_fn_registration_t *tx_fn_registrations; /* Error strings indexed by error code for this node. */ char **tx_function_error_strings; /* Number of error codes used by this node. */ u32 tx_function_n_errors; /* Renumber device name [only!] support, a control-plane kludge */ int (*name_renumber) (struct vnet_hw_interface_t * hi, u32 new_dev_instance); /* Interface flow offload operations */ vnet_flow_dev_ops_function_t *flow_ops_function; /* Format device instance as name. */ format_function_t *format_device_name; /* Parse function for device name. */ unformat_function_t *unformat_device_name; /* Format device verbosely for this class. */ format_function_t *format_device; /* Trace buffer format for TX function. */ format_function_t *format_tx_trace; /* Format flow offload entry */ format_function_t *format_flow; /* Function to clear hardware counters for device. */ void (*clear_counters) (u32 dev_class_instance); uword (*is_valid_class_for_interface) (struct vnet_main_t * vnm, u32 hw_if_index, u32 hw_class_index); /* Called when hardware class of an interface changes. */ void (*hw_class_change) (struct vnet_main_t * vnm, u32 hw_if_index, u32 new_hw_class_index); /* Called to redirect traffic from a specific interface instance */ void (*rx_redirect_to_node) (struct vnet_main_t * vnm, u32 hw_if_index, u32 node_index); /* Link-list of all device classes set up by constructors created below */ struct _vnet_device_class *next_class_registration; /* Function to set mac address. */ vnet_interface_set_mac_address_function_t *mac_addr_change_function; } vnet_device_class_t; #ifndef CLIB_MARCH_VARIANT #define VNET_DEVICE_CLASS(x,...) \ __VA_ARGS__ vnet_device_class_t x; \ static void __vnet_add_device_class_registration_##x (void) \ __attribute__((__constructor__)) ; \ static void __vnet_add_device_class_registration_##x (void) \ { \ vnet_main_t * vnm = vnet_get_main(); \ x.next_class_registration = vnm->device_class_registrations; \ vnm->device_class_registrations = &x; \ } \ static void __vnet_rm_device_class_registration_##x (void) \ __attribute__((__destructor__)) ; \ static void __vnet_rm_device_class_registration_##x (void) \ { \ vnet_main_t * vnm = vnet_get_main(); \ VLIB_REMOVE_FROM_LINKED_LIST (vnm->device_class_registrations, \ &x, next_class_registration); \ } \ __VA_ARGS__ vnet_device_class_t x #else /* create unused pointer to silence compiler warnings and get whole function optimized out */ #define VNET_DEVICE_CLASS(x,...) \ static __clib_unused vnet_device_class_t __clib_unused_##x #endif #define VNET_DEVICE_CLASS_TX_FN(devclass) \ uword CLIB_MARCH_SFX (devclass##_tx_fn)(); \ static vlib_node_fn_registration_t \ CLIB_MARCH_SFX(devclass##_tx_fn_registration) = \ { .function = &CLIB_MARCH_SFX (devclass##_tx_fn), }; \ \ static void __clib_constructor \ CLIB_MARCH_SFX (devclass##_tx_fn_multiarch_register) (void) \ { \ extern vnet_device_class_t devclass; \ vlib_node_fn_registration_t *r; \ r = &CLIB_MARCH_SFX (devclass##_tx_fn_registration); \ r->priority = CLIB_MARCH_FN_PRIORITY(); \ r->next_registration = devclass.tx_fn_registrations; \ devclass.tx_fn_registrations = r; \ } \ uword CLIB_CPU_OPTIMIZED CLIB_MARCH_SFX (devclass##_tx_fn) #define VLIB_DEVICE_TX_FUNCTION_CLONE_TEMPLATE(arch, fn, tgt) \ uword \ __attribute__ ((flatten)) \ __attribute__ ((target (tgt))) \ CLIB_CPU_OPTIMIZED \ fn ## _ ## arch ( vlib_main_t * vm, \ vlib_node_runtime_t * node, \ vlib_frame_t * frame) \ { return fn (vm, node, frame); } #define VLIB_DEVICE_TX_FUNCTION_MULTIARCH_CLONE(fn) \ foreach_march_variant(VLIB_DEVICE_TX_FUNCTION_CLONE_TEMPLATE, fn) #if CLIB_DEBUG > 0 #define VLIB_MULTIARCH_CLONE_AND_SELECT_FN(fn,...) #define VLIB_DEVICE_TX_FUNCTION_MULTIARCH(dev, fn) #else #define VLIB_DEVICE_TX_FUNCTION_MULTIARCH(dev, fn) \ VLIB_DEVICE_TX_FUNCTION_MULTIARCH_CLONE(fn) \ CLIB_MULTIARCH_SELECT_FN(fn, static inline) \ static void __attribute__((__constructor__)) \ __vlib_device_tx_function_multiarch_select_##dev (void) \ { dev.tx_function = fn ## _multiarch_select(); } #endif /** * Link Type: A description of the protocol of packets on the link. * On an ethernet link this maps directly into the ethertype. On a GRE tunnel * it maps to the GRE-proto, etc for other lnk types. */ typedef enum vnet_link_t_ { #if CLIB_DEBUG > 0 VNET_LINK_IP4 = 1, #else VNET_LINK_IP4 = 0, #endif VNET_LINK_IP6, VNET_LINK_MPLS, VNET_LINK_ETHERNET, VNET_LINK_ARP, VNET_LINK_NSH, } __attribute__ ((packed)) vnet_link_t; #define VNET_LINKS { \ [VNET_LINK_ETHERNET] = "ethernet", \ [VNET_LINK_IP4] = "ipv4", \ [VNET_LINK_IP6] = "ipv6", \ [VNET_LINK_MPLS] = "mpls", \ [VNET_LINK_ARP] = "arp", \ [VNET_LINK_NSH] = "nsh", \ } #define FOR_EACH_VNET_LINK(_link) \ for (_link = VNET_LINK_IP4; \ _link <= VNET_LINK_NSH; \ _link++) /** * @brief Number of link types. Not part of the enum so it does not have to be included in * switch statements */ #define VNET_LINK_NUM (VNET_LINK_NSH+1) /** * @brief Convert a link to to an Ethertype */ extern vnet_l3_packet_type_t vnet_link_to_l3_proto (vnet_link_t link); /** * @brief Attributes assignable to a HW interface Class. */ typedef enum vnet_hw_interface_class_flags_t_ { /** * @brief a point 2 point interface */ VNET_HW_INTERFACE_CLASS_FLAG_P2P = (1 << 0), } vnet_hw_interface_class_flags_t; /* Layer-2 (e.g. Ethernet) interface class. */ typedef struct _vnet_hw_interface_class { /* Index into main vector. */ u32 index; /* Class name (e.g. "Ethernet"). */ char *name; /* Flags */ vnet_hw_interface_class_flags_t flags; /* Function to call when hardware interface is added/deleted. */ vnet_interface_function_t *interface_add_del_function; /* Function to bring interface administratively up/down. */ vnet_interface_function_t *admin_up_down_function; /* Function to call when link state changes. */ vnet_interface_function_t *link_up_down_function; /* Function to call when link MAC changes. */ vnet_interface_set_mac_address_function_t *mac_addr_change_function; /* Format function to display interface name. */ format_function_t *format_interface_name; /* Format function to display interface address. */ format_function_t *format_address; /* Format packet header for this interface class. */ format_function_t *format_header; /* Format device verbosely for this class. */ format_function_t *format_device; /* Parser for hardware (e.g. ethernet) address. */ unformat_function_t *unformat_hw_address; /* Parser for packet header for e.g. rewrite string. */ unformat_function_t *unformat_header; /* Builds a rewrite string for the interface to the destination * for the payload/link type. */ u8 *(*build_rewrite) (struct vnet_main_t * vnm, u32 sw_if_index, vnet_link_t link_type, const void *dst_hw_address); /* Update an adjacency added by FIB (as opposed to via the * neighbour resolution protocol). */ void (*update_adjacency) (struct vnet_main_t * vnm, u32 sw_if_index, u32 adj_index); uword (*is_valid_class_for_interface) (struct vnet_main_t * vnm, u32 hw_if_index, u32 hw_class_index); /* Called when hw interface class is changed and old hardware instance may want to be deleted. */ void (*hw_class_change) (struct vnet_main_t * vnm, u32 hw_if_index, u32 old_class_index, u32 new_class_index); /* List of hw interface classes, built by constructors */ struct _vnet_hw_interface_class *next_class_registration; } vnet_hw_interface_class_t; /** * @brief Return a complete, zero-length (aka dummy) rewrite */ extern u8 *default_build_rewrite (struct vnet_main_t *vnm, u32 sw_if_index, vnet_link_t link_type, const void *dst_hw_address); /** * @brief Default adjacency update function */ extern void default_update_adjacency (struct vnet_main_t *vnm, u32 sw_if_index, u32 adj_index); #define VNET_HW_INTERFACE_CLASS(x,...) \ __VA_ARGS__ vnet_hw_interface_class_t x; \ static void __vnet_add_hw_interface_class_registration_##x (void) \ __attribute__((__constructor__)) ; \ static void __vnet_add_hw_interface_class_registration_##x (void) \ { \ vnet_main_t * vnm = vnet_get_main(); \ x.next_class_registration = vnm->hw_interface_class_registrations; \ vnm->hw_interface_class_registrations = &x; \ } \ static void __vnet_rm_hw_interface_class_registration_##x (void) \ __attribute__((__destructor__)) ; \ static void __vnet_rm_hw_interface_class_registration_##x (void) \ { \ vnet_main_t * vnm = vnet_get_main(); \ VLIB_REMOVE_FROM_LINKED_LIST (vnm->hw_interface_class_registrations,\ &x, next_class_registration); \ } \ __VA_ARGS__ vnet_hw_interface_class_t x typedef enum vnet_hw_interface_flags_t_ { VNET_HW_INTERFACE_FLAG_NONE, /* Hardware link state is up. */ VNET_HW_INTERFACE_FLAG_LINK_UP = (1 << 0), /* Hardware duplex state */ VNET_HW_INTERFACE_FLAG_HALF_DUPLEX = (1 << 1), VNET_HW_INTERFACE_FLAG_FULL_DUPLEX = (1 << 2), /* rx mode flags */ VNET_HW_INTERFACE_FLAG_SUPPORTS_INT_MODE = (1 << 16), /* tx checksum offload */ VNET_HW_INTERFACE_FLAG_SUPPORTS_TX_L4_CKSUM_OFFLOAD = (1 << 17), } vnet_hw_interface_flags_t; #define VNET_HW_INTERFACE_FLAG_DUPLEX_SHIFT 1 #define VNET_HW_INTERFACE_FLAG_SPEED_SHIFT 3 #define VNET_HW_INTERFACE_FLAG_DUPLEX_MASK \ (VNET_HW_INTERFACE_FLAG_HALF_DUPLEX | \ VNET_HW_INTERFACE_FLAG_FULL_DUPLEX) /* Hardware-interface. This corresponds to a physical wire that packets flow over. */ typedef struct vnet_hw_interface_t { /* Interface name. */ u8 *name; /* flags */ vnet_hw_interface_flags_t flags; /* link speed in kbps */ u32 link_speed; /* Hardware address as vector. Zero (e.g. zero-length vector) if no address for this class (e.g. PPP). */ u8 *hw_address; /* Interface is up as far as software is concerned. */ /* NAME.{output,tx} nodes for this interface. */ u32 output_node_index, tx_node_index; /* (dev_class, dev_instance) uniquely identifies hw interface. */ u32 dev_class_index; u32 dev_instance; /* (hw_class, hw_instance) uniquely identifies hw interface. */ u32 hw_class_index; u32 hw_instance; /* Hardware index for this hardware interface. */ u32 hw_if_index; /* Software index for this hardware interface. */ u32 sw_if_index; /* Next index in interface-output node for this interface used by node function vnet_per_buffer_interface_output() */ u32 output_node_next_index; /* Maximum transmit rate for this interface in bits/sec. */ f64 max_rate_bits_per_sec; /* Smallest packet size supported by this interface. */ u32 min_supported_packet_bytes; /* Largest packet size supported by this interface. */ u32 max_supported_packet_bytes; /* Smallest packet size for this interface. */ u32 min_packet_bytes; /* Largest packet size for this interface. */ u32 max_packet_bytes; /* Hash table mapping sub interface id to sw_if_index. */ uword *sub_interface_sw_if_index_by_id; /* Count of number of L2 subinterfaces */ u32 l2_if_count; /* Bonded interface info - 0 - not a bonded interface nor a slave ~0 - slave to a bonded interface others - A bonded interface with a pointer to bitmap for all slaves */ uword *bond_info; #define VNET_HW_INTERFACE_BOND_INFO_NONE ((uword *) 0) #define VNET_HW_INTERFACE_BOND_INFO_SLAVE ((uword *) ~0) /* Input node */ u32 input_node_index; /* input node cpu index by queue */ u32 *input_node_thread_index_by_queue; /* vnet_hw_interface_rx_mode by queue */ u8 *rx_mode_by_queue; vnet_hw_interface_rx_mode default_rx_mode; /* device input device_and_queue runtime index */ uword *dq_runtime_index_by_queue; } vnet_hw_interface_t; extern vnet_device_class_t vnet_local_interface_device_class; typedef enum { /* A hw interface. */ VNET_SW_INTERFACE_TYPE_HARDWARE, /* A sub-interface. */ VNET_SW_INTERFACE_TYPE_SUB, VNET_SW_INTERFACE_TYPE_P2P, VNET_SW_INTERFACE_TYPE_PIPE, } vnet_sw_interface_type_t; typedef struct { /* * Subinterface ID. A number 0-N to uniquely identify * this subinterface under the main (parent?) interface */ u32 id; /* Classification data. Used to associate packet header with subinterface. */ struct { u16 outer_vlan_id; u16 inner_vlan_id; union { u16 raw_flags; struct { u16 no_tags:1; u16 one_tag:1; u16 two_tags:1; u16 dot1ad:1; /* 0 = dot1q, 1=dot1ad */ u16 exact_match:1; u16 default_sub:1; u16 outer_vlan_id_any:1; u16 inner_vlan_id_any:1; } flags; }; } eth; } vnet_sub_interface_t; typedef struct { /* * Subinterface ID. A number 0-N to uniquely identify * this subinterface under the main interface */ u32 id; u32 pool_index; u8 client_mac[6]; } vnet_p2p_sub_interface_t; typedef enum { /* THe BVI 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) \ _(MPLS, mpls, 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: */