From 2ac5de8a64742d894475819f5953204ff8053f8a Mon Sep 17 00:00:00 2001 From: Derek G Foster Date: Tue, 16 Apr 2024 14:00:24 -0700 Subject: [PATCH] Combine switch_pd_routing.h header files (#122) - Combined the LNW_V2 and LNW_V3 versions of switch_pd_routing.h into a single conditionalized file. Signed-off-by: Derek G Foster --- switchapi/es2k/lnw_v2/CMakeLists.txt | 1 - switchapi/es2k/lnw_v2/switch_pd_routing.c | 2 +- switchapi/es2k/lnw_v2/switch_pd_routing.h | 105 ------------------ switchapi/es2k/lnw_v3/CMakeLists.txt | 1 - switchapi/es2k/lnw_v3/switch_pd_routing.c | 2 +- .../es2k/{lnw_v3 => }/switch_pd_routing.h | 13 ++- switchapi/switch_pd_routing.h | 17 ++- 7 files changed, 22 insertions(+), 119 deletions(-) delete mode 100644 switchapi/es2k/lnw_v2/switch_pd_routing.h rename switchapi/es2k/{lnw_v3 => }/switch_pd_routing.h (91%) diff --git a/switchapi/es2k/lnw_v2/CMakeLists.txt b/switchapi/es2k/lnw_v2/CMakeLists.txt index 57495b1..3a3f079 100644 --- a/switchapi/es2k/lnw_v2/CMakeLists.txt +++ b/switchapi/es2k/lnw_v2/CMakeLists.txt @@ -6,7 +6,6 @@ target_sources(switchapi_o PRIVATE switch_pd_p4_name_routing.h switch_pd_routing.c - switch_pd_routing.h switch_pd_lag.c switch_pd_lag.h ) diff --git a/switchapi/es2k/lnw_v2/switch_pd_routing.c b/switchapi/es2k/lnw_v2/switch_pd_routing.c index 9c0dd94..8f03e43 100644 --- a/switchapi/es2k/lnw_v2/switch_pd_routing.c +++ b/switchapi/es2k/lnw_v2/switch_pd_routing.c @@ -16,7 +16,7 @@ * limitations under the License. */ -#include "switch_pd_routing.h" +#include "switchapi/es2k/switch_pd_routing.h" #include "switchapi/es2k/switch_pd_p4_name_mapping.h" #include "switchapi/es2k/switch_pd_utils.h" diff --git a/switchapi/es2k/lnw_v2/switch_pd_routing.h b/switchapi/es2k/lnw_v2/switch_pd_routing.h deleted file mode 100644 index 3d2213c..0000000 --- a/switchapi/es2k/lnw_v2/switch_pd_routing.h +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright 2013-present Barefoot Networks, Inc. - * Copyright 2022-2023 Intel Corporation. - * - * 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. - */ - -#ifndef __SWITCH_PD_ROUTING_H__ -#define __SWITCH_PD_ROUTING_H__ - -#include "switch_pd_p4_name_routing.h" -#include "switchapi/switch_base_types.h" -#include "switchapi/switch_handle.h" -#include "switchapi/switch_l3.h" -#include "switchapi/switch_nhop.h" -#include "switchapi/switch_rmac_int.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** enum to decide the proper key and action based on ecmp or nhop - * */ -typedef enum switch_ip_table_action_s { - SWITCH_ACTION_NHOP = 0, - SWITCH_ACTION_NHOP_GROUP = 1, - SWITCH_ACTION_NONE = 2 -} switch_ip_table_action_t; - -/** - * create pd_routing structure to hold - * the data to be sent to - * the backend to update the table */ -typedef struct switch_pd_routing_info_s { - switch_handle_t neighbor_handle; - - switch_handle_t nexthop_handle; - - switch_handle_t rif_handle; - - switch_mac_addr_t dst_mac_addr; - - uint8_t port_id; - -} switch_pd_routing_info_t; - -switch_status_t switch_pd_nexthop_table_entry( - switch_device_t device, const switch_pd_routing_info_t* api_nexthop_pd_info, - bool entry_add); - -switch_status_t switch_pd_neighbor_table_entry( - switch_device_t device, - const switch_pd_routing_info_t* api_neighbor_pd_info, bool entry_add); - -switch_status_t switch_pd_rmac_table_entry(switch_device_t device, - switch_rmac_entry_t* rmac_entry, - switch_handle_t rif_handle, - bool entry_type); - -switch_status_t switch_pd_rif_mod_start_entry(switch_device_t device, - switch_rmac_entry_t* rmac_entry, - switch_handle_t rif_handle, - bool entry_add); - -switch_status_t switch_pd_rif_mod_mid_entry(switch_device_t device, - switch_rmac_entry_t* rmac_entry, - switch_handle_t rif_handle, - bool entry_add); - -switch_status_t switch_pd_rif_mod_last_entry(switch_device_t device, - switch_rmac_entry_t* rmac_entry, - switch_handle_t rif_handle, - bool entry_add); - -switch_status_t switch_pd_ipv4_table_entry( - switch_device_t device, const switch_api_route_entry_t* api_route_entry, - bool entry_add, switch_ip_table_action_t action); - -switch_status_t switch_pd_ipv6_table_entry( - switch_device_t device, const switch_api_route_entry_t* api_route_entry, - bool entry_add, switch_ip_table_action_t action); - -switch_status_t switch_pd_ecmp_hash_table_entry( - switch_device_t device, const switch_nhop_group_info_t* ecmp_info, - bool entry_add); - -switch_status_t switch_routing_table_entry( - switch_device_t device, const switch_pd_routing_info_t* api_routing_info, - bool entry_type); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/switchapi/es2k/lnw_v3/CMakeLists.txt b/switchapi/es2k/lnw_v3/CMakeLists.txt index 9fe8091..8bedce3 100644 --- a/switchapi/es2k/lnw_v3/CMakeLists.txt +++ b/switchapi/es2k/lnw_v3/CMakeLists.txt @@ -6,7 +6,6 @@ target_sources(switchapi_o PRIVATE switch_pd_p4_name_routing.h switch_pd_routing.c - switch_pd_routing.h switch_pd_lag.c switch_pd_lag.h ) diff --git a/switchapi/es2k/lnw_v3/switch_pd_routing.c b/switchapi/es2k/lnw_v3/switch_pd_routing.c index b38ab3a..733197d 100644 --- a/switchapi/es2k/lnw_v3/switch_pd_routing.c +++ b/switchapi/es2k/lnw_v3/switch_pd_routing.c @@ -16,7 +16,7 @@ * limitations under the License. */ -#include "switch_pd_routing.h" +#include "switchapi/es2k/switch_pd_routing.h" #include "switchapi/es2k/switch_pd_p4_name_mapping.h" #include "switchapi/es2k/switch_pd_utils.h" diff --git a/switchapi/es2k/lnw_v3/switch_pd_routing.h b/switchapi/es2k/switch_pd_routing.h similarity index 91% rename from switchapi/es2k/lnw_v3/switch_pd_routing.h rename to switchapi/es2k/switch_pd_routing.h index 3642419..55e4660 100644 --- a/switchapi/es2k/lnw_v3/switch_pd_routing.h +++ b/switchapi/es2k/switch_pd_routing.h @@ -19,7 +19,12 @@ #ifndef __SWITCH_PD_ROUTING_H__ #define __SWITCH_PD_ROUTING_H__ -#include "switchapi/es2k/lnw_v3/switch_pd_p4_name_routing.h" +#if defined(LNW_V2) +#include "lnw_v2/switch_pd_p4_name_routing.h" +#elif defined(LNW_V3) +#include "lnw_v3/switch_pd_p4_name_routing.h" +#endif + #include "switchapi/switch_base_types.h" #include "switchapi/switch_handle.h" #include "switchapi/switch_l3.h" @@ -59,9 +64,15 @@ switch_status_t switch_pd_nexthop_table_entry( switch_device_t device, const switch_pd_routing_info_t* api_nexthop_pd_info, bool entry_add); +#if defined(LNW_V2) +switch_status_t switch_pd_neighbor_table_entry( + switch_device_t device, + const switch_pd_routing_info_t* api_neighbor_pd_info, bool entry_add); +#elif defined(LNW_V3) switch_status_t switch_pd_ecmp_nexthop_table_entry( switch_device_t device, const switch_pd_routing_info_t* api_nexthop_pd_info, bool entry_add); +#endif switch_status_t switch_pd_rmac_table_entry(switch_device_t device, switch_rmac_entry_t* rmac_entry, diff --git a/switchapi/switch_pd_routing.h b/switchapi/switch_pd_routing.h index eded022..69f896f 100644 --- a/switchapi/switch_pd_routing.h +++ b/switchapi/switch_pd_routing.h @@ -15,11 +15,13 @@ * limitations under the License. */ -// Proxy for the target-specific switch_pd_routing header files. +// Proxy for the target-specific switch_pd_routing.h files. // -// We use a unique include guard to avoid aliasing the ones in the -// target-specific header files (which would cause their contents -// to be ignored). +// This header file encapsulates the knowledge that there are different +// versions of the header file for DPDK and ES2K. +// +// Note that it must use a different include guard than the files it +// includes (which both use the same name). #ifndef __SWITCH_PD_ROUTING_WRAPPER_H__ #define __SWITCH_PD_ROUTING_WRAPPER_H__ @@ -27,10 +29,7 @@ #if defined(DPDK_TARGET) #include "dpdk/switch_pd_routing.h" #elif defined(ES2K_TARGET) -#ifdef LNW_V2 -#include "es2k/lnw_v2/switch_pd_routing.h" -#else // LNW_V3 -#include "es2k/lnw_v3/switch_pd_routing.h" -#endif // LNW_V2 +#include "es2k/switch_pd_routing.h" #endif + #endif // __SWITCH_PD_ROUTING_WRAPPER_H__