From 9543e29708524accce591eab3aa23270ab44ae1a Mon Sep 17 00:00:00 2001 From: Akeel Ali Date: Thu, 9 Jan 2025 12:01:13 -0500 Subject: linux-cp: Add support for LACP packets This patch adds support to mirror LACP packets between host and phy. It is needed for the Sonic-VPP project to support LAG and allow Sonic to run LACP in the control plane. The change has 3 parts: (1) Converted lip_punt_node to lip_punt_xc_inline, which now supports the creation of two distinct nodes: lip_punt_node and lip_punt_xc_node. lip_punt_node retains its original punt functionality. lip_punt_xc_node supports both punt and x-connect between host & phy. (2) Add 2 new API (and corresponding CLI) to the linux-cp plugin: (A) lcp_ethertype_enable ("lcp ethertype enable ") (B) lcp_ethertype_get ("show lcp ethertype") (3) Add UT to test the new functionality and API/CLI for LACP and LLDP. Type: improvement Change-Id: Iab66e3b29351dcf2c471babd4f1ef4bdd19da46e Signed-off-by: Akeel Ali --- src/plugins/linux-cp/lcp_interface.c | 47 ++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'src/plugins/linux-cp/lcp_interface.c') diff --git a/src/plugins/linux-cp/lcp_interface.c b/src/plugins/linux-cp/lcp_interface.c index 9a6b9b11be5..31864f791af 100644 --- a/src/plugins/linux-cp/lcp_interface.c +++ b/src/plugins/linux-cp/lcp_interface.c @@ -1230,6 +1230,53 @@ lcp_itf_pair_link_up_down (vnet_main_t *vnm, u32 hw_if_index, u32 flags) return 0; } +int +lcp_ethertype_enable (ethernet_type_t ethertype) +{ + ethernet_main_t *em = ðernet_main; + ethernet_type_info_t *eti; + vlib_main_t *vm = vlib_get_main (); + vlib_node_t *node = vlib_get_node_by_name (vm, (u8 *) "linux-cp-punt-xc"); + + if (!node) + return VNET_API_ERROR_UNIMPLEMENTED; + + eti = ethernet_get_type_info (em, ethertype); + if (!eti) + return VNET_API_ERROR_INVALID_VALUE; + + if (eti->node_index != ~0 && eti->node_index != node->index) + return VNET_API_ERROR_INVALID_REGISTRATION; + + ethernet_register_input_type (vm, ethertype, node->index); + return 0; +} + +int +lcp_ethertype_get_enabled (ethernet_type_t **ethertypes_vec) +{ + ethernet_main_t *em = ðernet_main; + ethernet_type_info_t *eti; + vlib_main_t *vm = vlib_get_main (); + vlib_node_t *node = vlib_get_node_by_name (vm, (u8 *) "linux-cp-punt-xc"); + + if (!ethertypes_vec) + return VNET_API_ERROR_INVALID_ARGUMENT; + + if (!node) + return VNET_API_ERROR_UNIMPLEMENTED; + + vec_foreach (eti, em->type_infos) + { + if (eti->node_index == node->index) + { + vec_add1 (*ethertypes_vec, eti->type); + } + } + + return 0; +} + VNET_HW_INTERFACE_LINK_UP_DOWN_FUNCTION (lcp_itf_pair_link_up_down); static clib_error_t * -- cgit