Skip to content

Commit

Permalink
"bf_" name change in krnlmon (#83)
Browse files Browse the repository at this point in the history
* Initial commit bf name change krnlmon

Signed-off-by: Kumar, Aashish <[email protected]>

* clangFix

Signed-off-by: Kumar, Aashish <[email protected]>

* clang fix

Signed-off-by: Kumar, Aashish <[email protected]>

* bf_type to ipu_type

Signed-off-by: Kumar, Aashish <[email protected]>

* .h cleanup

Signed-off-by: Kumar, Aashish <[email protected]>

---------

Signed-off-by: Kumar, Aashish <[email protected]>
  • Loading branch information
aashishkuma authored Feb 12, 2024
1 parent c3a4572 commit 889c17e
Show file tree
Hide file tree
Showing 15 changed files with 48 additions and 38 deletions.
2 changes: 1 addition & 1 deletion switchapi/es2k/switch_lag.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#include "switchapi/switch_lag.h"

#include "bf_types.h"
#include "ipu_types/ipu_types.h"
#include "switch_pd_utils.h"
#include "switchapi/es2k/switch_pd_lag.h"
#include "switchapi/switch_base_types.h"
Expand Down
3 changes: 1 addition & 2 deletions switchapi/es2k/switch_pd_fdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@

#include "switch_pd_fdb.h"

#include "bf_types.h"
#include "port_mgr/dpdk/bf_dpdk_port_if.h"
#include "ipu_types/ipu_types.h"
#include "switch_pd_p4_name_mapping.h"
#include "switch_pd_utils.h"
#include "switchapi/switch_base_types.h"
Expand Down
1 change: 0 additions & 1 deletion switchapi/es2k/switch_pd_routing.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

#include "switch_pd_routing.h"

#include "port_mgr/dpdk/bf_dpdk_port_if.h"
#include "switch_pd_p4_name_mapping.h"
#include "switch_pd_utils.h"
#include "switchapi/switch_base_types.h"
Expand Down
16 changes: 7 additions & 9 deletions switchapi/es2k/switch_pd_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@

#include <net/if.h>

#include "bf_rt/bf_rt_common.h"
#include "bf_types.h"
#include "port_mgr/dpdk/bf_dpdk_port_if.h"
#include "ipu_types/ipu_types.h"
#include "switch_pd_p4_name_mapping.h"
#include "switchapi/switch_base_types.h"
#include "switchapi/switch_internal.h"
Expand Down Expand Up @@ -371,14 +369,14 @@ void switch_pd_to_get_port_id(switch_api_rif_info_t* port_rif_info) {
switch_rmac_info_t* rmac_info = NULL;
switch_rmac_entry_t* rmac_entry = NULL;
switch_node_t* node = NULL;
bf_dev_id_t bf_dev_id = 0;
ipu_dev_id_t ipu_dev_id = 0;
static char mac_str[SWITCH_PD_MAC_STR_LENGTH];
bf_status_t bf_status;
ipu_status_t ipu_status;
uint32_t port_id = 0;

/*rmac_handle will have source mac info. get rmac_info from rmac_handle */
rmac_handle = port_rif_info->rmac_handle;
status = switch_rmac_get(bf_dev_id, rmac_handle, &rmac_info);
status = switch_rmac_get(ipu_dev_id, rmac_handle, &rmac_info);
if (status != SWITCH_STATUS_SUCCESS) {
krnlmon_log_error("Cannot get rmac info for handle 0x%x, error: %d",
rmac_handle, status);
Expand All @@ -399,8 +397,8 @@ void switch_pd_to_get_port_id(switch_api_rif_info_t* port_rif_info) {
rmac_entry->mac.mac_addr[4], rmac_entry->mac.mac_addr[5]);
mac_str[SWITCH_PD_MAC_STR_LENGTH - 1] = '\0';

bf_status = bf_pal_get_port_id_from_mac(bf_dev_id, mac_str, &port_id);
if (bf_status != BF_SUCCESS) {
ipu_status = ipu_pal_get_port_id_from_mac(ipu_dev_id, mac_str, &port_id);
if (ipu_status != TDI_SUCCESS) {
// First SWITCH_PD_TARGET_VPORT_OFFSET entries are reserved for
// MEV h/w ports. Hence VSI ID/Port ID should be offset with
// SWITCH_PD_TARGET_VPORT_OFFSET
Expand All @@ -413,7 +411,7 @@ void switch_pd_to_get_port_id(switch_api_rif_info_t* port_rif_info) {
"Failed to get the port ID, error: %d, Deriving "
"port ID from second byte of MAC address: "
"%s",
bf_status, mac_str);
ipu_status, mac_str);
}

port_rif_info->port_id = port_id;
Expand Down
21 changes: 10 additions & 11 deletions switchapi/es2k/switch_pd_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@
#ifndef __SWITCH_PD_UTILS_H__
#define __SWITCH_PD_UTILS_H__

#include "bf_pal/bf_pal_port_intf.h"
#include "bf_rt/bf_rt_common.h"
#include "bf_types.h"
#include "port_mgr/dpdk/bf_dpdk_port_if.h"
#include "ipu_pal/port_intf.h"
#include "ipu_types/ipu_types.h"
#include "switchapi/switch_base_types.h"
#include "switchapi/switch_handle.h"
#include "switchapi/switch_rif.h"
Expand Down Expand Up @@ -63,14 +61,15 @@ tdi_status_t switch_pd_get_bridge_id(switch_device_t device,
uint8_t physical_port_id,
uint8_t* bridge_id);

bf_status_t switch_pd_allocate_handle_session(const bf_dev_id_t device_id,
const char* pipeline_name,
bf_rt_info_hdl** bfrt_info_hdl_t,
bf_rt_session_hdl** session_t);
ipu_status_t switch_pd_allocate_handle_session(const ipu_dev_id_t device_id,
const char* pipeline_name,
tdi_info_hdl** bfrt_info_hdl_t,
tdi_session_hdl** session_t);

bf_status_t switch_pd_deallocate_handle_session(
bf_rt_table_key_hdl* key_hdl_t, bf_rt_table_data_hdl* data_hdl_t,
bf_rt_session_hdl* session_t, bool entry_type);
ipu_status_t switch_pd_deallocate_handle_session(tdi_table_key_hdl* key_hdl_t,
tdi_table_data_hdl* data_hdl_t,
tdi_session_hdl* session_t,
bool entry_type);

void switch_pd_to_get_port_id(switch_api_rif_info_t* port_rif_info);

Expand Down
2 changes: 1 addition & 1 deletion switchapi/es2k/switch_rif.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include <net/if.h>

/* Local header includes */
#include "bf_types.h"
#include "ipu_types/ipu_types.h"
#include "switch_pd_utils.h"
#include "switchapi/switch_base_types.h"
#include "switchapi/switch_device.h"
Expand Down
2 changes: 1 addition & 1 deletion switchapi/es2k/switchapi_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ switch_status_t switch_pd_status_to_status(bf_status_t pd_status) {
switch_status_t status = SWITCH_STATUS_SUCCESS;

switch (pd_status) {
case BF_SUCCESS:
case IPU_SUCCESS:
status = SWITCH_STATUS_SUCCESS;
break;

Expand Down
1 change: 0 additions & 1 deletion switchapi/switch_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#include "switchapi/switch_device_int.h"
#include "switchapi/switch_handle_int.h"
#include "switchapi/switch_status.h"
//#include "bf_types.h"
#include "switchutils/switch_utils.h"
#include "tdi/common/tdi_defs.h"

Expand Down
5 changes: 4 additions & 1 deletion switchlink/sai/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

add_library(switchlink_sai_o OBJECT
switchlink_handle_ecmp.c
switchlink_handle_lag.c
switchlink_handle_link.c
switchlink_handle_neigh.c
switchlink_handle_nexthop.c
Expand All @@ -15,6 +14,10 @@ add_library(switchlink_sai_o OBJECT
switchlink_init_sai.h
)

if(ES2K_TARGET)
target_sources(switchlink_sai_o PRIVATE switchlink_handle_lag.c)
endif()

target_include_directories(switchlink_sai_o PRIVATE
${SDE_INSTALL_DIR}/include
${SDE_INSTALL_DIR}/include/bf_types
Expand Down
16 changes: 7 additions & 9 deletions switchlink/sai/switchlink_handle_lag.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@

#include <linux/if.h>

#include "bf_pal/bf_pal_port_intf.h"
#include "bf_rt/bf_rt_common.h"
#include "bf_types.h"
#include "port_mgr/dpdk/bf_dpdk_port_if.h"
#include "ipu_pal/port_intf.h"
#include "ipu_types/ipu_types.h"
#include "switchlink_init_sai.h"

#define SWITCH_PD_MAC_STR_LENGTH 18
Expand Down Expand Up @@ -171,9 +169,9 @@ static int create_lag_member(
switchlink_handle_t* lag_member_h) {
sai_attribute_t attr_list[5];
int ac = 0;
bf_status_t bf_status;
ipu_status_t ipu_status;
uint32_t port_id = 0;
bf_dev_id_t bf_dev_id = 0;
ipu_dev_id_t ipu_dev_id = 0;
static char mac_str[SWITCH_PD_MAC_STR_LENGTH];

snprintf(mac_str, sizeof(mac_str), "%02x:%02x:%02x:%02x:%02x:%02x",
Expand All @@ -182,14 +180,14 @@ static int create_lag_member(
lag_member_intf->perm_hwaddr[4], lag_member_intf->perm_hwaddr[5]);
mac_str[SWITCH_PD_MAC_STR_LENGTH - 1] = '\0';

bf_status = bf_pal_get_port_id_from_mac(bf_dev_id, mac_str, &port_id);
if (bf_status != BF_SUCCESS) {
ipu_status = ipu_pal_get_port_id_from_mac(ipu_dev_id, mac_str, &port_id);
if (ipu_status != IPU_SUCCESS) {
port_id = lag_member_intf->perm_hwaddr[1] + SWITCH_PD_TARGET_VPORT_OFFSET;
krnlmon_log_info(
"Failed to get the port ID, error: %d, Deriving "
"port ID from second byte of MAC address: "
"%s",
bf_status, mac_str);
ipu_status, mac_str);
}

memset(attr_list, 0, sizeof(attr_list));
Expand Down
2 changes: 2 additions & 0 deletions switchlink/sai/switchlink_init_sai.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ void switchlink_init_api(void) {
krnlmon_assert(status == SAI_STATUS_SUCCESS);
status = sai_init_nhop_group_api();
krnlmon_assert(status == SAI_STATUS_SUCCESS);
#ifdef ES2K_TARGET
status = sai_init_lag_api();
krnlmon_assert(status == SAI_STATUS_SUCCESS);
#endif
return;
}
4 changes: 4 additions & 0 deletions switchlink/sai/switchlink_init_sai.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,23 @@ sai_status_t sai_init_neigh_api();
sai_status_t sai_init_route_api();
sai_status_t sai_init_nhop_api();
sai_status_t sai_init_nhop_group_api();
#ifdef ES2K_TARGET
sai_status_t sai_init_lag_api();
#endif

// SWITCHLINK_LINK_TYPE_VXLAN handlers
void switchlink_create_tunnel_interface(
switchlink_db_tunnel_interface_info_t* tnl_intf);
void switchlink_delete_tunnel_interface(uint32_t ifindex);

// SWITCHLINK_LINK_TYPE_BOND handlers
#ifdef ES2K_TARGET
void switchlink_create_lag(switchlink_db_interface_info_t* lag_intf);
void switchlink_delete_lag(uint32_t ifindex);
void switchlink_create_lag_member(
switchlink_db_lag_member_info_t* lag_member_info);
void switchlink_delete_lag_member(uint32_t ifindex);
#endif

// SWITCHLINK_LINK_TYPE_TUN handlers
void switchlink_create_interface(switchlink_db_interface_info_t* intf);
Expand Down
2 changes: 2 additions & 0 deletions switchlink/switchlink_handle.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,13 @@ extern void switchlink_create_tunnel_interface(
extern void switchlink_delete_tunnel_interface(uint32_t ifindex);

// SWITCHLINK_LINK_TYPE_BOND handlers
#ifdef ES2K_TARGET
extern void switchlink_create_lag(switchlink_db_interface_info_t* lag_info);
extern void switchlink_delete_lag(uint32_t ifindex);
extern void switchlink_create_lag_member(
switchlink_db_lag_member_info_t* lag_member_info);
extern void switchlink_delete_lag_member(uint32_t ifindex);
#endif

// SWITCHLINK_LINK_TYPE_TUN handlers
extern void switchlink_create_interface(switchlink_db_interface_info_t* intf);
Expand Down
7 changes: 6 additions & 1 deletion switchlink/switchlink_link.c
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ void switchlink_process_link_msg(const struct nlmsghdr* nlmsg, int msgtype) {
case SWITCHLINK_LINK_TYPE_TEAM:
krnlmon_log_info("LAG via teaming driver isn't supported\n");
break;
#ifdef ES2K_TARGET
case SWITCHLINK_LINK_TYPE_BOND:
snprintf(intf_info.ifname, sizeof(intf_info.ifname), "%s",
attrs.ifname);
Expand All @@ -376,6 +377,7 @@ void switchlink_process_link_msg(const struct nlmsghdr* nlmsg, int msgtype) {
intf_info.bond_mode);
}
break;
#endif
case SWITCHLINK_LINK_TYPE_ETH:
break;

Expand Down Expand Up @@ -427,6 +429,7 @@ void switchlink_process_link_msg(const struct nlmsghdr* nlmsg, int msgtype) {
break;
}
switch (slave_link_type) {
#ifdef ES2K_TARGET
case SWITCHLINK_LINK_TYPE_BOND:
snprintf(lag_member_info.ifname, sizeof(lag_member_info.ifname), "%s",
attrs.ifname);
Expand All @@ -442,6 +445,7 @@ void switchlink_process_link_msg(const struct nlmsghdr* nlmsg, int msgtype) {
switchlink_create_lag_member(&lag_member_info);
}
break;
#endif
default:
break;
}
Expand All @@ -461,7 +465,7 @@ void switchlink_process_link_msg(const struct nlmsghdr* nlmsg, int msgtype) {
} else {
krnlmon_log_debug("Unhandled link type");
}

#ifdef ES2K_TARGET
if (link_type == SWITCHLINK_LINK_TYPE_BOND) {
switchlink_delete_lag(ifmsg->ifi_index);
return;
Expand All @@ -471,6 +475,7 @@ void switchlink_process_link_msg(const struct nlmsghdr* nlmsg, int msgtype) {
switchlink_delete_lag_member(ifmsg->ifi_index);
return;
}
#endif
}
return;
}
Expand Down
2 changes: 2 additions & 0 deletions switchlink/switchlink_link_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,13 @@ std::vector<test_results> results(2);
// Test doubles (dummy functions)
//----------------------------------------------------------------------

#ifdef ES2K_TARGET
void switchlink_create_lag(switchlink_db_interface_info_t* lag_info) {}
void switchlink_delete_lag(uint32_t ifindex) {}
void switchlink_create_lag_member(
switchlink_db_lag_member_info_t* lag_member_info) {}
void switchlink_delete_lag_member(uint32_t ifindex) {}
#endif

void switchlink_create_interface(switchlink_db_interface_info_t* intf) {
struct test_results temp = {0};
Expand Down

0 comments on commit 889c17e

Please sign in to comment.