Skip to content

Commit

Permalink
Add Bazel support for switchapi/dpdk
Browse files Browse the repository at this point in the history
Signed-off-by: Derek G Foster <[email protected]>
  • Loading branch information
ffoulkes committed Mar 11, 2024
1 parent 988f808 commit 96710cb
Show file tree
Hide file tree
Showing 22 changed files with 103 additions and 44 deletions.
1 change: 1 addition & 0 deletions switchapi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ add_library(switchapi_o OBJECT
switch_lag.h
switch_neighbor.h
switch_neighbor_int.h
switch_pd_routing.h
switch_nhop.h
switch_nhop_int.h
switch_port_int.h
Expand Down
3 changes: 2 additions & 1 deletion switchapi/dpdk/switch_config.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright 2013-present Barefoot Networks, Inc.
* Copyright 2022-2023 Intel Corporation.
* Copyright 2022-2024 Intel Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -17,6 +17,7 @@

#include "switchapi/switch_config_int.h"
#include "switchapi/switch_internal.h"
#include "switchutils/switch_log.h"

#ifdef __cplusplus
extern "C" {
Expand Down
7 changes: 4 additions & 3 deletions switchapi/dpdk/switch_device.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright 2013-present Barefoot Networks, Inc.
* Copyright 2022-2023 Intel Corporation.
* Copyright 2022-2024 Intel Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -26,13 +26,14 @@
#include "switchapi/switch_rmac_int.h"
#include "switchapi/switch_table.h"
#include "switchapi/switch_vrf.h"
#include "switchutils/switch_log.h"

#undef __MODULE__
#define __MODULE__ SWITCH_API_TYPE_DEVICE

#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#endif

#define __FILE_ID__ SWITCH_DEVICE

Expand Down Expand Up @@ -620,7 +621,7 @@ switch_status_t switch_api_device_tunnel_dmac_get(switch_device_t device,
return status;
}
#ifdef __cplusplus
}
} // extern "C"
#endif

switch_status_t switch_api_device_remove(switch_device_t device) {
Expand Down
4 changes: 3 additions & 1 deletion switchapi/dpdk/switch_fdb.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
* Copyright 2013-present Barefoot Networks, Inc.
* Copyright 2022-2023 Intel Corporation.
* Copyright 2022-2024 Intel Corporation.
* SPDX-License-Identifier: Apache 2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -23,6 +24,7 @@
#include "switchapi/switch_internal.h"
#include "switchapi/switch_rif_int.h"
#include "switchapi/switch_status.h"
#include "switchutils/switch_log.h"

switch_status_t switch_l2_hash_key_init(void* args, switch_uint8_t* key,
switch_uint32_t* len) {
Expand Down
12 changes: 3 additions & 9 deletions switchapi/dpdk/switch_handle.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
* Copyright 2013-present Barefoot Networks, Inc.
* Copyright 2022-2023 Intel Corporation.
* Copyright 2022-2024 Intel Corporation.
* SPDX-License-Identifier: Apache 2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -20,10 +21,7 @@
#include "switchapi/switch_internal.h"
#include "switchapi/switch_nhop_int.h"
#include "switchapi/switch_status.h"

#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#include "switchutils/switch_log.h"

#define __FILE_ID__ SWITCH_HANDLE

Expand Down Expand Up @@ -477,7 +475,3 @@ switch_status_t switch_api_handle_count_get(switch_device_t device,

return status;
}

#ifdef __cplusplus
}
#endif
8 changes: 3 additions & 5 deletions switchapi/dpdk/switch_id.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
* Copyright 2013-present Barefoot Networks, Inc.
* Copyright 2022-2023 Intel Corporation.
* Copyright 2022-2024 Intel Corporation.
* SPDX-License-Identifier: Apache 2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -18,10 +19,7 @@
#include "switchapi/switch_id.h"

#include "switchapi/switch_internal.h"

#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#include "switchutils/switch_log.h"

#define __FILE_ID__ SWITCH_ID

Expand Down
4 changes: 3 additions & 1 deletion switchapi/dpdk/switch_l3.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
* Copyright 2013-present Barefoot Networks, Inc.
* Copyright 2022-2023 Intel Corporation.
* Copyright 2022-2024 Intel Corporation.
* SPDX-License-Identifier: Apache 2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -21,6 +22,7 @@
#include "switchapi/switch_device.h"
#include "switchapi/switch_internal.h"
#include "switchapi/switch_nhop_int.h"
#include "switchutils/switch_log.h"

switch_status_t switch_route_table_entry_key_init(void* args,
switch_uint8_t* key,
Expand Down
4 changes: 3 additions & 1 deletion switchapi/dpdk/switch_neighbor.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
* Copyright 2013-present Barefoot Networks, Inc.
* Copyright 2022-2023 Intel Corporation.
* Copyright 2022-2024 Intel Corporation.
* SPDX-License-Identifier: Apache 2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -26,6 +27,7 @@
#include "switchapi/switch_nhop_int.h"
#include "switchapi/switch_rif_int.h"
#include "switchapi/switch_rmac_int.h"
#include "switchutils/switch_log.h"

switch_status_t switch_neighbor_init(switch_device_t device) {
switch_neighbor_context_t* neighbor_ctx = NULL;
Expand Down
4 changes: 3 additions & 1 deletion switchapi/dpdk/switch_nhop.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
* Copyright 2013-present Barefoot Networks, Inc.
* Copyright 2022-2023 Intel Corporation.
* Copyright 2022-2024 Intel Corporation.
* SPDX-License-Identifier: Apache 2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -24,6 +25,7 @@
#include "switchapi/switch_nhop_int.h"
#include "switchapi/switch_rif.h"
#include "switchapi/switch_rif_int.h"
#include "switchutils/switch_log.h"

// add corresponding delete functions

Expand Down
4 changes: 3 additions & 1 deletion switchapi/dpdk/switch_pd_fdb.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
* Copyright 2013-present Barefoot Networks, Inc.
* Copyright 2022-2023 Intel Corporation.
* Copyright 2022-2024 Intel Corporation.
* SPDX-License-Identifier: Apache 2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -25,6 +26,7 @@
#include "switchapi/switch_fdb.h"
#include "switchapi/switch_internal.h"
#include "switchapi/switch_rif_int.h"
#include "switchutils/switch_log.h"

switch_status_t switch_pd_l2_tx_forward_table_entry(
switch_device_t device, const switch_api_l2_info_t* api_l2_tx_info,
Expand Down
4 changes: 3 additions & 1 deletion switchapi/dpdk/switch_pd_routing.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
* Copyright 2013-present Barefoot Networks, Inc.
* Copyright 2022-2023 Intel Corporation.
* Copyright 2022-2024 Intel Corporation.
* SPDX-License-Identifier: Apache 2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -23,6 +24,7 @@
#include "switchapi/switch_base_types.h"
#include "switchapi/switch_internal.h"
#include "switchapi/switch_nhop_int.h"
#include "switchutils/switch_log.h"

switch_status_t switch_routing_table_entry(
switch_device_t device, const switch_pd_routing_info_t* api_routing_info,
Expand Down
4 changes: 3 additions & 1 deletion switchapi/dpdk/switch_pd_tunnel.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
* Copyright 2013-present Barefoot Networks, Inc.
* Copyright 2022-2023 Intel Corporation.
* Copyright 2022-2024 Intel Corporation.
* SPDX-License-Identifier: Apache 2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -21,6 +22,7 @@
#include "switch_pd_utils.h"
#include "switchapi/switch_internal.h"
#include "switchapi/switch_tunnel.h"
#include "switchutils/switch_log.h"

switch_status_t switch_pd_tunnel_entry(
switch_device_t device, const switch_api_tunnel_info_t* api_tunnel_info_t,
Expand Down
4 changes: 3 additions & 1 deletion switchapi/dpdk/switch_pd_utils.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
* Copyright 2013-present Barefoot Networks, Inc.
* Copyright 2022-2023 Intel Corporation.
* Copyright 2022-2024 Intel Corporation.
* SPDX-License-Identifier: Apache 2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -24,6 +25,7 @@
#include "port_mgr/dpdk/bf_dpdk_port_if.h"
#include "switchapi/switch_base_types.h"
#include "switchapi/switch_internal.h"
#include "switchutils/switch_log.h"

void switch_pd_to_get_port_id(switch_api_rif_info_t* port_rif_info) {
char if_name[16] = {0};
Expand Down
4 changes: 3 additions & 1 deletion switchapi/dpdk/switch_rif.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
* Copyright 2013-present Barefoot Networks, Inc.
* Copyright 2022-2023 Intel Corporation.
* Copyright 2022-2024 Intel Corporation.
* SPDX-License-Identifier: Apache 2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -26,6 +27,7 @@
#include "switchapi/switch_rif.h"
#include "switchapi/switch_rif_int.h"
#include "switchapi/switch_status.h"
#include "switchutils/switch_log.h"

/*
* Routine Description:
Expand Down
4 changes: 3 additions & 1 deletion switchapi/dpdk/switch_rmac.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
* Copyright 2013-present Barefoot Networks, Inc.
* Copyright 2022-2023 Intel Corporation.
* Copyright 2022-2024 Intel Corporation.
* SPDX-License-Identifier: Apache 2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -20,6 +21,7 @@
#include "switch_pd_routing.h"
#include "switchapi/switch_internal.h"
#include "switchapi/switch_rmac_int.h"
#include "switchutils/switch_log.h"

/*
* Routine Description:
Expand Down
2 changes: 1 addition & 1 deletion switchapi/switch_neighbor.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#endif

typedef enum switch_neighbor_type_s {
SWITCH_NEIGHBOR_TYPE_IP = 0x0,
Expand Down
13 changes: 4 additions & 9 deletions switchapi/switch_neighbor_int.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright 2013-present Barefoot Networks, Inc.
* Copyright 2022-2023 Intel Corporation.
* Copyright 2022-2024 Intel Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -19,17 +19,12 @@

#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#endif

#include "switch_pd_routing.h"
#include "switch_rif.h"
#include "switch_types_int.h"

#if defined(DPDK_TARGET)
#include "dpdk/switch_pd_routing.h"
#elif defined(ES2K_TARGET)
#include "es2k/switch_pd_routing.h"
#endif

#define switch_neighbor_handle_create(_device) \
switch_handle_create(_device, SWITCH_HANDLE_TYPE_NEIGHBOR, \
sizeof(switch_neighbor_info_t))
Expand Down Expand Up @@ -70,4 +65,4 @@ switch_status_t switch_neighbor_default_entries_delete(switch_device_t device);
}
#endif

#endif /* _switch_neighbor_int_h_ */
#endif // __SWITCH_NEIGHBOR_INT_H__
33 changes: 33 additions & 0 deletions switchapi/switch_pd_routing.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright 2024 Intel Corporation.
* SPDX-License-Identifier: Apache 2.0
*
* 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.
*/

// Proxy for the target-specific switch_pd_routing header file.
//
// 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).

#ifndef __SWITCHAPI_PD_ROUTING_H__
#define __SWITCHAPI_PD_ROUTING_H__

#if defined(DPDK_TARGET)
#include "dpdk/switch_pd_routing.h"
#elif defined(ES2K_TARGET)
#include "es2k/switch_pd_routing.h"
#endif

#endif // __SWITCHAPI_PD_ROUTING_H__
4 changes: 2 additions & 2 deletions switchapi/switch_table.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/*
* Copyright 2013-present Barefoot Networks, Inc.
* Copyright 2022-2023 Intel Corporation.
*
* Copyright 2022-2024 Intel Corporation.
* SPDX-License-Identifier: Apache 2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -21,6 +20,7 @@
#define __SWITCH_TABLE_H__

#include "switch_base_types.h"
#include "switchutils/switch_log.h"

#ifdef __cplusplus
extern "C" {
Expand Down
8 changes: 8 additions & 0 deletions switchlink/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ load("@rules_cc//cc:defs.bzl", "cc_library")

package(default_visibility = ["//visibility:public"])

TARGET_DEFINES = select(
{
"//:dpdk_target": ["DPDK_TARGET"],
"//:es2k_target": ["ES2K_TARGET"],
},
)

cc_library(
name = "switchlink_address",
srcs = ["switchlink_address.c"],
Expand Down Expand Up @@ -36,6 +43,7 @@ cc_library(
"switchlink_db.h",
"switchlink_db_int.h",
],
defines = TARGET_DEFINES,
deps = [
":switchlink_int",
":switchlink_link_types",
Expand Down
Loading

0 comments on commit 96710cb

Please sign in to comment.