diff --git a/switchapi/es2k/switch_fdb.c b/switchapi/es2k/switch_fdb.c index 1976e20..bcf0657 100644 --- a/switchapi/es2k/switch_fdb.c +++ b/switchapi/es2k/switch_fdb.c @@ -291,9 +291,19 @@ switch_status_t switch_api_l2_forward_create(const switch_device_t device, status = switch_rif_get(device, api_l2_info->rif_handle, &rif_info); CHECK_RET(status != SWITCH_STATUS_SUCCESS, status); + + /* Get appropiate port_id if not already set */ + switch_pd_to_get_port_id(&rif_info->api_rif_info); + + /* Get physical port ID from its corresponding PR VSI ID */ status = switch_pd_get_physical_port_id( device, rif_info->api_rif_info.port_id, &api_l2_info->port_id); CHECK_RET(status != SWITCH_STATUS_SUCCESS, status); + + /* Get bridge ID from its physical port ID */ + status = switch_pd_get_bridge_id(device, api_l2_info->port_id, + &api_l2_info->bridge_id); + CHECK_RET(status != SWITCH_STATUS_SUCCESS, status); } // When L2 MAC address is learnt, we will not be aware if that MAC is @@ -312,30 +322,9 @@ switch_status_t switch_api_l2_forward_create(const switch_device_t device, return status; } - status = switch_pd_l2_tx_ipv6_forward_table_entry(device, api_l2_info, - api_tunnel_info, true); - if (status != SWITCH_STATUS_SUCCESS) { - krnlmon_log_error( - "switch_api_l2_ipv6_forward_create: Failed to create platform " - "dependent" - " l2 tx forward table entry on device: %d,error: (%s)\n", - device, switch_error_to_string(status)); - return status; - } - // These FDB entries are learnt from OVS, and same FDB entry rule // should be programmed for 2_fwd_rx_with_tunnel_table too. if (api_l2_info->learn_from == SWITCH_L2_FWD_LEARN_VLAN_INTERFACE) { - status = switch_pd_sem_bypass_table_entry(device, api_l2_info, - api_tunnel_info, true); - if (status != SWITCH_STATUS_SUCCESS) { - krnlmon_log_error( - "switch_api_l2_forward_create: Failed to create platform " - "dependent sem bypass table entry on device %d: ,error :(%s)\n", - device, switch_error_to_string(status)); - return status; - } - status = switch_pd_l2_rx_forward_with_tunnel_table_entry( device, api_l2_info, true); if (status != SWITCH_STATUS_SUCCESS) { @@ -437,30 +426,10 @@ switch_status_t switch_api_l2_forward_delete( return status; } - status = switch_pd_l2_tx_ipv6_forward_table_entry(device, api_l2_info, NULL, - false); - if (status != SWITCH_STATUS_SUCCESS) { - krnlmon_log_error( - "switch_api_l2_ipv6_forward_create: Failed to delete platform " - "dependent l2 tx forward table entry on device: %d,error: (%s)", - device, switch_error_to_string(status)); - return status; - } - /* These FDB entries are learnt from OVS, and same FDB entry rule * should be deleted from 2_fwd_rx_with_tunnel_table too. */ if (l2_info->api_l2_info.learn_from == SWITCH_L2_FWD_LEARN_VLAN_INTERFACE) { - status = - switch_pd_sem_bypass_table_entry(device, api_l2_info, NULL, false); - if (status != SWITCH_STATUS_SUCCESS) { - krnlmon_log_error( - "switch_api_l2_forward_delete: Failed to delete platform " - "dependent sem bypass table entry on device %d: ,error :%s\n", - device, switch_error_to_string(status)); - return status; - } - status = switch_pd_l2_rx_forward_with_tunnel_table_entry( device, api_l2_info, false); if (status != SWITCH_STATUS_SUCCESS) { diff --git a/switchapi/es2k/switch_pd_fdb.c b/switchapi/es2k/switch_pd_fdb.c index 7d9291c..9f9a91a 100644 --- a/switchapi/es2k/switch_pd_fdb.c +++ b/switchapi/es2k/switch_pd_fdb.c @@ -119,19 +119,18 @@ switch_status_t switch_pd_l2_tx_forward_table_entry( } status = tdi_key_field_id_get(table_info_hdl, - LNW_L2_FWD_TX_TABLE_KEY_TUN_FLAG, &field_id); + LNW_L2_FWD_TX_TABLE_KEY_BRIDGE_ID, &field_id); if (status != TDI_SUCCESS) { krnlmon_log_error("Unable to get field ID for key: %s, error: %d", - LNW_L2_FWD_TX_TABLE_KEY_TUN_FLAG, status); + LNW_L2_FWD_TX_TABLE_KEY_DST_MAC, status); goto dealloc_resources; } - status = tdi_key_field_set_value(key_hdl, field_id, 0); + status = tdi_key_field_set_value_ptr( + key_hdl, field_id, (const uint8_t*)&api_l2_tx_info->bridge_id, 1); if (status != TDI_SUCCESS) { - krnlmon_log_error( - "Unable to set value for key ID: %d" - ", error: %d", - field_id, status); + krnlmon_log_error("Unable to set value for key ID: %d, error: %d", field_id, + status); goto dealloc_resources; } @@ -365,9 +364,9 @@ switch_status_t switch_pd_l2_tx_forward_table_entry( return switch_pd_tdi_status_to_status(status); } -switch_status_t switch_pd_l2_tx_ipv6_forward_table_entry( - switch_device_t device, const switch_api_l2_info_t* api_l2_tx_info, - const switch_api_tunnel_info_t* api_tunnel_info, bool entry_add) { +switch_status_t switch_pd_l2_rx_forward_table_entry( + switch_device_t device, const switch_api_l2_info_t* api_l2_rx_info, + bool entry_add) { tdi_status_t status; tdi_id_t field_id = 0; @@ -386,6 +385,9 @@ switch_status_t switch_pd_l2_tx_ipv6_forward_table_entry( const tdi_table_hdl* table_hdl = NULL; const tdi_table_info_hdl* table_info_hdl = NULL; + switch_rif_info_t* rif_info = NULL; + switch_port_t port_id; + krnlmon_log_debug("%s", __func__); status = tdi_info_get(dev_id, PROGRAM_NAME, &info_hdl); @@ -418,18 +420,17 @@ switch_status_t switch_pd_l2_tx_ipv6_forward_table_entry( goto dealloc_resources; } - status = - tdi_table_from_name_get(info_hdl, LNW_L2_FWD_TX_IPV6_TABLE, &table_hdl); + status = tdi_table_from_name_get(info_hdl, LNW_L2_FWD_RX_TABLE, &table_hdl); if (status != TDI_SUCCESS || !table_hdl) { krnlmon_log_error("Unable to get table handle for: %s, error: %d", - LNW_L2_FWD_TX_IPV6_TABLE, status); + LNW_L2_FWD_RX_TABLE, status); goto dealloc_resources; } status = tdi_table_key_allocate(table_hdl, &key_hdl); if (status != TDI_SUCCESS) { krnlmon_log_error("Unable to allocate key handle for: %s, error: %d", - LNW_L2_FWD_TX_IPV6_TABLE, status); + LNW_L2_FWD_RX_TABLE, status); goto dealloc_resources; } @@ -440,16 +441,16 @@ switch_status_t switch_pd_l2_tx_ipv6_forward_table_entry( goto dealloc_resources; } - status = tdi_key_field_id_get( - table_info_hdl, LNW_L2_FWD_TX_IPV6_TABLE_KEY_DST_MAC, &field_id); + status = tdi_key_field_id_get(table_info_hdl, LNW_L2_FWD_RX_TABLE_KEY_DST_MAC, + &field_id); if (status != TDI_SUCCESS) { krnlmon_log_error("Unable to get field ID for key: %s, error: %d", - LNW_L2_FWD_TX_IPV6_TABLE_KEY_DST_MAC, status); + LNW_L2_FWD_RX_TABLE_KEY_DST_MAC, status); goto dealloc_resources; } status = tdi_key_field_set_value_ptr( - key_hdl, field_id, (const uint8_t*)&api_l2_tx_info->dst_mac.mac_addr, + key_hdl, field_id, (const uint8_t*)&api_l2_rx_info->dst_mac.mac_addr, SWITCH_MAC_LENGTH); if (status != TDI_SUCCESS) { krnlmon_log_error("Unable to set value for key ID: %d, error: %d", field_id, @@ -457,394 +458,49 @@ switch_status_t switch_pd_l2_tx_ipv6_forward_table_entry( goto dealloc_resources; } - status = tdi_key_field_id_get( - table_info_hdl, LNW_L2_FWD_TX_IPV6_TABLE_KEY_TUN_FLAG, &field_id); - if (status != TDI_SUCCESS) { - krnlmon_log_error("Unable to get field ID for key: %s, error: %d", - LNW_L2_FWD_TX_IPV6_TABLE_KEY_TUN_FLAG, status); - goto dealloc_resources; - } - - status = tdi_key_field_set_value(key_hdl, field_id, 0); - if (status != TDI_SUCCESS) { - krnlmon_log_error( - "Unable to set value for key ID: %d" - ", error: %d", - field_id, status); - goto dealloc_resources; - } - - if (entry_add && - (api_l2_tx_info->learn_from == SWITCH_L2_FWD_LEARN_PHYSICAL_INTERFACE) && - SWITCH_RIF_HANDLE(api_l2_tx_info->rif_handle)) { - krnlmon_log_info( - "Populate l2_fwd action in %s " - "for physical port: %d", - LNW_L2_FWD_TX_IPV6_TABLE, api_l2_tx_info->port_id); - - status = tdi_action_name_to_id( - table_info_hdl, LNW_L2_FWD_TX_IPV6_TABLE_ACTION_L2_FWD, &action_id); - if (status != TDI_SUCCESS) { - krnlmon_log_error("Unable to get action allocator ID for: %s, error: %d", - LNW_L2_FWD_TX_IPV6_TABLE_ACTION_L2_FWD, status); - goto dealloc_resources; - } - - status = tdi_table_action_data_allocate(table_hdl, action_id, &data_hdl); - if (status != TDI_SUCCESS) { - krnlmon_log_error( - "Unable to get action allocator for ID: %d, " - "error: %d", - action_id, status); - goto dealloc_resources; - } - - status = tdi_data_field_id_with_action_get(table_info_hdl, - LNW_ACTION_L2_FWD_PARAM_PORT, - action_id, &data_field_id); - if (status != TDI_SUCCESS) { - krnlmon_log_error("Unable to get data field id param for: %s, error: %d", - LNW_ACTION_L2_FWD_PARAM_PORT, status); - goto dealloc_resources; - } - - status = tdi_data_field_set_value(data_hdl, data_field_id, - api_l2_tx_info->port_id); - if (status != TDI_SUCCESS) { - krnlmon_log_error("Unable to set action value for ID: %d, error: %d", - data_field_id, status); - goto dealloc_resources; - } - - status = tdi_table_entry_add(table_hdl, session, target_hdl, flags_hdl, - key_hdl, data_hdl); - if (status != TDI_SUCCESS) { - krnlmon_log_error("Unable to add %s entry, error: %d", - LNW_L2_FWD_TX_IPV6_TABLE, status); - goto dealloc_resources; - } - } else if (entry_add && SWITCH_LAG_HANDLE(api_l2_tx_info->rif_handle)) { - krnlmon_log_info("Populate l2_fwd_lag action in %s ", - LNW_L2_FWD_TX_IPV6_TABLE); - - status = tdi_action_name_to_id( - table_info_hdl, LNW_L2_FWD_TX_IPV6_TABLE_ACTION_L2_FWD_LAG, &action_id); - if (status != TDI_SUCCESS) { - krnlmon_log_error("Unable to get action allocator ID for: %s, error: %d", - LNW_L2_FWD_TX_IPV6_TABLE_ACTION_L2_FWD_LAG, status); - goto dealloc_resources; - } - - status = tdi_table_action_data_allocate(table_hdl, action_id, &data_hdl); - if (status != TDI_SUCCESS) { - krnlmon_log_error( - "Unable to get action allocator for ID: %d, " - "error: %d", - action_id, status); - goto dealloc_resources; - } - - status = tdi_data_field_id_with_action_get( - table_info_hdl, LNW_ACTION_L2_FWD_LAG_PARAM_LAG_ID, action_id, - &data_field_id); - if (status != TDI_SUCCESS) { - krnlmon_log_error("Unable to get data field id param for: %s, error: %d", - LNW_ACTION_L2_FWD_LAG_PARAM_LAG_ID, status); - goto dealloc_resources; - } - - status = tdi_data_field_set_value( - data_hdl, data_field_id, - (api_l2_tx_info->rif_handle & - ~(SWITCH_HANDLE_TYPE_LAG << SWITCH_HANDLE_TYPE_SHIFT))); - if (status != TDI_SUCCESS) { - krnlmon_log_error("Unable to set action value for ID: %d, error: %d", - data_field_id, status); - goto dealloc_resources; - } - - status = tdi_table_entry_add(table_hdl, session, target_hdl, flags_hdl, - key_hdl, data_hdl); - if (status != TDI_SUCCESS) { - krnlmon_log_error("Unable to add %s entry, error: %d", - LNW_L2_FWD_TX_IPV6_TABLE, status); - goto dealloc_resources; - } - } else { - /* Delete an entry from target */ - status = - tdi_table_entry_del(table_hdl, session, target_hdl, flags_hdl, key_hdl); - if (status != TDI_SUCCESS) { - krnlmon_log_error("Unable to delete %s table entry, error: %d", - LNW_L2_FWD_TX_IPV6_TABLE, status); - goto dealloc_resources; - } - } - -dealloc_resources: - status = tdi_switch_pd_deallocate_resources(flags_hdl, target_hdl, key_hdl, - data_hdl, session, entry_add); - return switch_pd_tdi_status_to_status(status); -} - -switch_status_t switch_pd_sem_bypass_table_entry( - switch_device_t device, const switch_api_l2_info_t* api_l2_tx_info, - const switch_api_tunnel_info_t* api_tunnel_info, bool entry_add) { - tdi_status_t status; - - tdi_id_t field_id = 0; - tdi_id_t action_id = 0; - tdi_id_t data_field_id = 0; - - tdi_dev_id_t dev_id = device; - - tdi_flags_hdl* flags_hdl = NULL; - tdi_target_hdl* target_hdl = NULL; - const tdi_device_hdl* dev_hdl = NULL; - tdi_session_hdl* session = NULL; - const tdi_info_hdl* info_hdl = NULL; - tdi_table_key_hdl* key_hdl = NULL; - tdi_table_data_hdl* data_hdl = NULL; - const tdi_table_hdl* table_hdl = NULL; - const tdi_table_info_hdl* table_info_hdl = NULL; - - switch_handle_t rif_handle; - switch_rif_info_t* rif_info = NULL; - switch_port_t port_id; - - krnlmon_log_debug("%s", __func__); - - status = tdi_info_get(dev_id, PROGRAM_NAME, &info_hdl); - if (status != TDI_SUCCESS) { - krnlmon_log_error("Failed to get tdi info handle, error: %d", status); - goto dealloc_resources; - } - - status = tdi_flags_create(0, &flags_hdl); - if (status != TDI_SUCCESS) { - krnlmon_log_error("Failed to create flags handle, error: %d", status); - goto dealloc_resources; - } - - status = tdi_device_get(dev_id, &dev_hdl); - if (status != TDI_SUCCESS) { - krnlmon_log_error("Failed to get device handle, error: %d", status); - goto dealloc_resources; - } - - status = tdi_target_create(dev_hdl, &target_hdl); - if (status != TDI_SUCCESS) { - krnlmon_log_error("Failed to create target handle, error: %d", status); - goto dealloc_resources; - } - - status = tdi_session_create(dev_hdl, &session); - if (status != TDI_SUCCESS) { - krnlmon_log_error("Failed to create tdi session, error: %d", status); - goto dealloc_resources; - } - - status = tdi_table_from_name_get(info_hdl, LNW_SEM_BYPASS_TABLE, &table_hdl); - if (status != TDI_SUCCESS || !table_hdl) { - krnlmon_log_error("Unable to get table handle for: %s, error: %d", - LNW_SEM_BYPASS_TABLE, status); + switch_status_t switch_status = + switch_rif_get(device, api_l2_rx_info->rif_handle, &rif_info); + if (switch_status != SWITCH_STATUS_SUCCESS) { + krnlmon_log_error("Unable to get rif info, error: %d", switch_status); goto dealloc_resources; } - status = tdi_table_key_allocate(table_hdl, &key_hdl); - if (status != TDI_SUCCESS) { - krnlmon_log_error("Unable to allocate key handle for: %s, error: %d", - LNW_SEM_BYPASS_TABLE, status); + switch_status = + switch_pd_get_physical_port_id(device, rif_info->api_rif_info.port_id, + (uint8_t*)&api_l2_rx_info->port_id); + if (switch_status != SWITCH_STATUS_SUCCESS) { + krnlmon_log_error("Unable to get physical port ID, error: %d", + switch_status); goto dealloc_resources; } - status = tdi_table_info_get(table_hdl, &table_info_hdl); - if (status != TDI_SUCCESS) { - krnlmon_log_error( - "Unable to get table info handle for table, " - "error: %d", - status); + status = switch_pd_get_bridge_id(device, (uint8_t)api_l2_rx_info->port_id, + (uint8_t*)&api_l2_rx_info->bridge_id); + if (switch_status != SWITCH_STATUS_SUCCESS) { + krnlmon_log_error("Unable to get bridge ID, error: %d", switch_status); goto dealloc_resources; } status = tdi_key_field_id_get(table_info_hdl, - LNW_SEM_BYPASS_TABLE_KEY_DST_MAC, &field_id); + LNW_L2_FWD_RX_TABLE_KEY_BRIDGE_ID, &field_id); if (status != TDI_SUCCESS) { krnlmon_log_error("Unable to get field ID for key: %s, error: %d", - LNW_SEM_BYPASS_TABLE_KEY_DST_MAC, status); + LNW_L2_FWD_RX_TABLE_KEY_DST_MAC, status); goto dealloc_resources; } status = tdi_key_field_set_value_ptr( - key_hdl, field_id, (const uint8_t*)&api_l2_tx_info->dst_mac.mac_addr, - SWITCH_MAC_LENGTH); - if (status != TDI_SUCCESS) { - krnlmon_log_error("Unable to set value for key ID: %d, error: %d", field_id, - status); - goto dealloc_resources; - } - - if (entry_add) { - krnlmon_log_info( - "Populate set_dest action in %s for tunnel " - "interface %x", - LNW_SEM_BYPASS_TABLE, (unsigned int)api_l2_tx_info->rif_handle); - - status = tdi_action_name_to_id( - table_info_hdl, LNW_SEM_BYPASS_TABLE_ACTION_SET_DEST, &action_id); - if (status != TDI_SUCCESS) { - krnlmon_log_error( - "Unable to get action allocator ID for: %s, " - "error: %d", - LNW_SEM_BYPASS_TABLE_ACTION_SET_DEST, status); - goto dealloc_resources; - } - - status = tdi_table_action_data_allocate(table_hdl, action_id, &data_hdl); - if (status != TDI_SUCCESS) { - krnlmon_log_error( - "Unable to get action allocator for ID: %d, " - "error: %d", - action_id, status); - goto dealloc_resources; - } - - status = tdi_data_field_id_with_action_get( - table_info_hdl, LNW_ACTION_SET_DEST_PARAM_PORT_ID, action_id, - &data_field_id); - if (status != TDI_SUCCESS) { - krnlmon_log_error( - "Unable to get data field id param for: %s, " - "error: %d", - LNW_ACTION_SET_DEST_PARAM_PORT_ID, status); - goto dealloc_resources; - } - - status = tdi_data_field_set_value(data_hdl, data_field_id, - api_l2_tx_info->port_id); - if (status != TDI_SUCCESS) { - krnlmon_log_error("Unable to set action value for ID: %d, error: %d", - data_field_id, status); - goto dealloc_resources; - } - - status = tdi_table_entry_add(table_hdl, session, target_hdl, flags_hdl, - key_hdl, data_hdl); - if (status != TDI_SUCCESS) { - krnlmon_log_error("Unable to add %s table entry, error: %d", - LNW_SEM_BYPASS_TABLE, status); - goto dealloc_resources; - } - } else { - /* Delete an entry from target */ - status = - tdi_table_entry_del(table_hdl, session, target_hdl, flags_hdl, key_hdl); - if (status != TDI_SUCCESS) { - krnlmon_log_error("Unable to delete %s entry, error: %d", - LNW_SEM_BYPASS_TABLE, status); - goto dealloc_resources; - } - } -dealloc_resources: - status = tdi_switch_pd_deallocate_resources(flags_hdl, target_hdl, key_hdl, - data_hdl, session, entry_add); - return switch_pd_tdi_status_to_status(status); -} + key_hdl, field_id, (const uint8_t*)&api_l2_rx_info->bridge_id, 1); -switch_status_t switch_pd_l2_rx_forward_table_entry( - switch_device_t device, const switch_api_l2_info_t* api_l2_rx_info, - bool entry_add) { - tdi_status_t status; - - tdi_id_t field_id = 0; - tdi_id_t action_id = 0; - tdi_id_t data_field_id = 0; - - tdi_dev_id_t dev_id = device; - - tdi_flags_hdl* flags_hdl = NULL; - tdi_target_hdl* target_hdl = NULL; - const tdi_device_hdl* dev_hdl = NULL; - tdi_session_hdl* session = NULL; - const tdi_info_hdl* info_hdl = NULL; - tdi_table_key_hdl* key_hdl = NULL; - tdi_table_data_hdl* data_hdl = NULL; - const tdi_table_hdl* table_hdl = NULL; - const tdi_table_info_hdl* table_info_hdl = NULL; - - switch_handle_t rif_handle; - switch_rif_info_t* rif_info = NULL; - switch_port_t port_id; - - krnlmon_log_debug("%s", __func__); - - status = tdi_info_get(dev_id, PROGRAM_NAME, &info_hdl); - if (status != TDI_SUCCESS) { - krnlmon_log_error("Failed to get tdi info handle, error: %d", status); - goto dealloc_resources; - } - - status = tdi_flags_create(0, &flags_hdl); - if (status != TDI_SUCCESS) { - krnlmon_log_error("Failed to create flags handle, error: %d", status); - goto dealloc_resources; - } - - status = tdi_device_get(dev_id, &dev_hdl); - if (status != TDI_SUCCESS) { - krnlmon_log_error("Failed to get device handle, error: %d", status); - goto dealloc_resources; - } - - status = tdi_target_create(dev_hdl, &target_hdl); - if (status != TDI_SUCCESS) { - krnlmon_log_error("Failed to create target handle, error: %d", status); - goto dealloc_resources; - } - - status = tdi_session_create(dev_hdl, &session); - if (status != TDI_SUCCESS) { - krnlmon_log_error("Failed to create tdi session, error: %d", status); - goto dealloc_resources; - } - - status = tdi_table_from_name_get(info_hdl, LNW_L2_FWD_RX_TABLE, &table_hdl); - if (status != TDI_SUCCESS || !table_hdl) { - krnlmon_log_error("Unable to get table handle for: %s, error: %d", - LNW_L2_FWD_RX_TABLE, status); - goto dealloc_resources; - } - - status = tdi_table_key_allocate(table_hdl, &key_hdl); - if (status != TDI_SUCCESS) { - krnlmon_log_error("Unable to allocate key handle for: %s, error: %d", - LNW_L2_FWD_RX_TABLE, status); - goto dealloc_resources; - } - - status = tdi_table_info_get(table_hdl, &table_info_hdl); - if (status != TDI_SUCCESS) { - krnlmon_log_error("Unable to get table info handle for table, error: %d", - status); - goto dealloc_resources; - } - - status = tdi_key_field_id_get(table_info_hdl, LNW_L2_FWD_RX_TABLE_KEY_DST_MAC, - &field_id); + status = tdi_key_field_id_get( + table_info_hdl, LNW_L2_FWD_RX_TABLE_KEY_SMAC_LEARNED, &field_id); if (status != TDI_SUCCESS) { krnlmon_log_error("Unable to get field ID for key: %s, error: %d", LNW_L2_FWD_RX_TABLE_KEY_DST_MAC, status); goto dealloc_resources; } - status = tdi_key_field_set_value_ptr( - key_hdl, field_id, (const uint8_t*)&api_l2_rx_info->dst_mac.mac_addr, - SWITCH_MAC_LENGTH); - if (status != TDI_SUCCESS) { - krnlmon_log_error("Unable to set value for key ID: %d, error: %d", field_id, - status); - goto dealloc_resources; - } + status = tdi_key_field_set_value(key_hdl, field_id, 1); if (entry_add && SWITCH_RIF_HANDLE(api_l2_rx_info->rif_handle)) { /* Add an entry to target */ @@ -870,14 +526,6 @@ switch_status_t switch_pd_l2_rx_forward_table_entry( goto dealloc_resources; } - rif_handle = api_l2_rx_info->rif_handle; - switch_status_t switch_status = - switch_rif_get(device, rif_handle, &rif_info); - if (switch_status != SWITCH_STATUS_SUCCESS) { - krnlmon_log_error("Unable to get rif info, error: %d", switch_status); - goto dealloc_resources; - } - /* While matching l2_fwd_rx_table should receive packet on phy-port * and send to control port. */ port_id = rif_info->api_rif_info.port_id; diff --git a/switchapi/es2k/switch_pd_fdb.h b/switchapi/es2k/switch_pd_fdb.h index 967c321..b094307 100644 --- a/switchapi/es2k/switch_pd_fdb.h +++ b/switchapi/es2k/switch_pd_fdb.h @@ -30,10 +30,6 @@ switch_status_t switch_pd_l2_tx_forward_table_entry( switch_device_t device, const switch_api_l2_info_t* api_l2_tx_info, const switch_api_tunnel_info_t* api_tunnel_info_t, bool entry_add); -switch_status_t switch_pd_l2_tx_ipv6_forward_table_entry( - switch_device_t device, const switch_api_l2_info_t* api_l2_tx_info, - const switch_api_tunnel_info_t* api_tunnel_info_t, bool entry_add); - switch_status_t switch_pd_l2_rx_forward_table_entry( switch_device_t device, const switch_api_l2_info_t* api_l2_rx_info, bool entry_add); @@ -42,10 +38,6 @@ switch_status_t switch_pd_l2_rx_forward_with_tunnel_table_entry( switch_device_t device, const switch_api_l2_info_t* api_l2_rx_info, bool entry_add); -switch_status_t switch_pd_sem_bypass_table_entry( - switch_device_t device, const switch_api_l2_info_t* api_l2_tx_info, - const switch_api_tunnel_info_t* api_tunnel_info, bool entry_add); - #ifdef __cplusplus } #endif diff --git a/switchapi/es2k/switch_pd_p4_name_mapping.h b/switchapi/es2k/switch_pd_p4_name_mapping.h index ea8f1b4..6f3170e 100644 --- a/switchapi/es2k/switch_pd_p4_name_mapping.h +++ b/switchapi/es2k/switch_pd_p4_name_mapping.h @@ -24,6 +24,7 @@ extern "C" { #endif /* __cplusplus */ +#define LNW_KEY_MATCH_PRIORITY "$MATCH_PRIORITY" /* List of tables and corresponding actions */ /* VXLAN_ENCAP_MOD_TABLE */ @@ -103,10 +104,14 @@ extern "C" { #define LNW_L2_FWD_RX_TABLE_KEY_DST_MAC "dst_mac" +#define LNW_L2_FWD_RX_TABLE_KEY_BRIDGE_ID "user_meta.pmeta.bridge_id" + +#define LNW_L2_FWD_RX_TABLE_KEY_SMAC_LEARNED "user_meta.pmeta.smac_learned" + #define LNW_L2_FWD_RX_TABLE_ACTION_L2_FWD "linux_networking_control.l2_fwd" #define LNW_ACTION_L2_FWD_PARAM_PORT "port" #define LNW_L2_FWD_RX_TABLE_ACTION_RX_L2_FWD_LAG \ - "linux_networking_control.rx_l2_fwd_lag" + "linux_networking_control.rx_l2_fwd_lag_and_recirculate" #define LNW_ACTION_RX_L2_FWD_LAG_PARAM_LAG_ID "lag_group_id" /* RX_LAG_TABLE */ @@ -114,11 +119,14 @@ extern "C" { #define LNW_RX_LAG_TABLE_KEY_PORT_ID "vmeta.common.port_id" #define LNW_RX_LAG_TABLE_KEY_LAG_ID "user_meta.cmeta.lag_group_id" - #define LNW_RX_LAG_TABLE_ACTION_SET_EGRESS_PORT \ "linux_networking_control.set_egress_port" #define LNW_ACTION_SET_EGRESS_PORT_PARAM_EGRESS_PORT "egress_port" +#define LNW_RX_LAG_TABLE_ACTION_FWD_TO_VSI "linux_networking_control.fwd_to_vsi" +#define LNW_ACTION_SET_EGRESS_PORT_PARAM_PORT "port" + +// NOP TODO /* L2_FWD_RX_WITH_TUNNEL_TABLE */ #define LNW_L2_FWD_RX_WITH_TUNNEL_TABLE \ "linux_networking_control.l2_fwd_rx_with_tunnel_table" @@ -128,10 +136,11 @@ extern "C" { #define LNW_L2_FWD_RX_WITH_TUNNEL_TABLE_ACTION_L2_FWD \ "linux_networking_control.l2_fwd" +// NOP TODO /* L2_FWD_TX_TABLE */ #define LNW_L2_FWD_TX_TABLE "linux_networking_control.l2_fwd_tx_table" +#define LNW_L2_FWD_TX_TABLE_KEY_BRIDGE_ID "user_meta.pmeta.bridge_id" #define LNW_L2_FWD_TX_TABLE_KEY_DST_MAC "dst_mac" -#define LNW_L2_FWD_TX_TABLE_KEY_TUN_FLAG "user_meta.pmeta.tun_flag1_d0" #define LNW_L2_FWD_TX_TABLE_ACTION_L2_FWD "linux_networking_control.l2_fwd" @@ -144,22 +153,11 @@ extern "C" { #define LNW_ACTION_SET_TUNNEL_PARAM_TUNNEL_ID "tunnel_id" #define LNW_ACTION_SET_TUNNEL_PARAM_DST_ADDR "dst_addr" -/* L2_FWD_TX_TABLE */ -#define LNW_L2_FWD_TX_IPV6_TABLE "linux_networking_control.l2_fwd_tx_ipv6_table" -#define LNW_L2_FWD_TX_IPV6_TABLE_KEY_DST_MAC "dst_mac" -#define LNW_L2_FWD_TX_IPV6_TABLE_KEY_TUN_FLAG "user_meta.pmeta.tun_flag1_d0" - -#define LNW_L2_FWD_TX_IPV6_TABLE_ACTION_L2_FWD "linux_networking_control.l2_fwd" - -#define LNW_L2_FWD_TX_IPV6_TABLE_ACTION_L2_FWD_LAG \ - "linux_networking_control.l2_fwd_lag" - /* NEXTHOP_TABLE */ // Verified for MEV #define LNW_NEXTHOP_TABLE "linux_networking_control.nexthop_table" #define LNW_NEXTHOP_TABLE_KEY_NEXTHOP_ID "user_meta.cmeta.nexthop_id" -#define LNW_NEXTHOP_TABLE_KEY_BIT32_ZEROS "user_meta.cmeta.bit32_zeros" #define LNW_NEXTHOP_TABLE_ACTION_SET_NEXTHOP \ "linux_networking_control.set_nexthop" @@ -242,28 +240,32 @@ extern "C" { #define LNW_IPV6_TABLE_ACTION_ECMP_V6_HASH_ACTION \ "linux_networking_control.ecmp_v6_hash_action" -/* SEM_BYPASS TABLE */ -#define LNW_SEM_BYPASS_TABLE "linux_networking_control.sem_bypass" +/* LNW_HANDLE_TX_ACC_VSI TABLE */ +#define LNW_TX_ACC_VSI_TABLE "linux_networking_control.tx_acc_vsi" + +#define LNW_TX_ACC_VSI_TABLE_KEY_META_COMMON_VSI "vmeta.common.vsi" -#define LNW_SEM_BYPASS_TABLE_KEY_DST_MAC "dst_mac" +#define LNW_TX_ACC_VSI_TABLE_KEY_ZERO_PADDING "zero_padding" -#define LNW_SEM_BYPASS_TABLE_ACTION_SET_DEST "linux_networking_control.set_dest" +#define LNW_TX_ACC_VSI_TABLE_ACTION_L2_FWD_AND_BYPASS_BRIDGE \ + "linux_networking_control.l2_fwd_and_bypass_bridge" -#define LNW_ACTION_SET_DEST_PARAM_PORT_ID "port_id" +#define ACTION_L2_FWD_AND_BYPASS_BRIDGE_PARAM_PORT "port" -/* HANDLE_TX_FROM_HOST_TO_OVS_AND_OVS_TO_WIRE_TABLE */ -#define LNW_HANDLE_TX_FROM_HOST_TO_OVS_AND_OVS_TO_WIRE_TABLE \ - "linux_networking_control.handle_tx_from_host_to_ovs_and_ovs_to_wire_table" +/* LNW_SOURCE_PORT_TO_BRIDGE_MAP TABLE */ +#define LNW_SOURCE_PORT_TO_BRIDGE_MAP_TABLE \ + "linux_networking_control.source_port_to_bridge_map" -#define LNW_HANDLE_OVS_TO_WIRE_TABLE_KEY_META_COMMON_VSI "vmeta.common.vsi" +#define LNW_SOURCE_PORT_TO_BRIDGE_MAP_TABLE_KEY_SOURCE_PORT \ + "user_meta.cmeta.source_port" -#define LNW_HANDLE_OVS_TO_WIRE_TABLE_KEY_USER_META_BIT32_ZEROS \ - "user_meta.cmeta.bit32_zeros" +#define LNW_SOURCE_PORT_TO_BRIDGE_MAP_TABLE_KEY_VID \ + "hdrs.vlan_ext[vmeta.common.depth].hdr.vid" -#define LNW_HANDLE_OVS_TO_WIRE_TABLE_ACTION_SET_DEST \ - "linux_networking_control.set_dest" +#define LNW_SOURCE_PORT_TO_BRIDGE_MAP_TABLE_ACTION_SET_BRIDGE_ID \ + "linux_networking_control.set_bridge_id" -#define LNW_HANDLE_OVS_TO_WIRE_TABLE_ACTION_SET_DEST_PARAM_PORT_ID "port_id" +#define LNW_SOURCE_PORT_TO_BRIDGE_MAP_TABLE_ACTION_PARAM_BRIDGE_ID "bridge_id" #ifdef __cplusplus } diff --git a/switchapi/es2k/switch_pd_utils.c b/switchapi/es2k/switch_pd_utils.c index c7914b0..ad9f863 100644 --- a/switchapi/es2k/switch_pd_utils.c +++ b/switchapi/es2k/switch_pd_utils.c @@ -27,9 +27,9 @@ #include "switchapi/switch_internal.h" #include "switchapi/switch_rmac_int.h" -tdi_status_t switch_pd_get_physical_port_id(switch_device_t device, - uint32_t netdev_port_id, - uint8_t* physical_port_id) { +switch_status_t switch_pd_get_physical_port_id(switch_device_t device, + uint32_t netdev_port_id, + uint8_t* physical_port_id) { tdi_status_t status; tdi_id_t field_id = 0; @@ -82,21 +82,17 @@ tdi_status_t switch_pd_get_physical_port_id(switch_device_t device, goto dealloc_resources; } - status = tdi_table_from_name_get( - info_hdl, LNW_HANDLE_TX_FROM_HOST_TO_OVS_AND_OVS_TO_WIRE_TABLE, - &table_hdl); + status = tdi_table_from_name_get(info_hdl, LNW_TX_ACC_VSI_TABLE, &table_hdl); if (status != TDI_SUCCESS || !table_hdl) { krnlmon_log_error("Unable to get table handle for: %s, error: %d", - LNW_HANDLE_TX_FROM_HOST_TO_OVS_AND_OVS_TO_WIRE_TABLE, - status); + LNW_TX_ACC_VSI_TABLE, status); goto dealloc_resources; } status = tdi_table_key_allocate(table_hdl, &key_hdl); if (status != TDI_SUCCESS) { krnlmon_log_error("Unable to allocate key handle for: %s, error: %d", - LNW_HANDLE_TX_FROM_HOST_TO_OVS_AND_OVS_TO_WIRE_TABLE, - status); + LNW_TX_ACC_VSI_TABLE, status); goto dealloc_resources; } @@ -108,11 +104,10 @@ tdi_status_t switch_pd_get_physical_port_id(switch_device_t device, } status = tdi_key_field_id_get( - table_info_hdl, LNW_HANDLE_OVS_TO_WIRE_TABLE_KEY_META_COMMON_VSI, - &field_id); + table_info_hdl, LNW_TX_ACC_VSI_TABLE_KEY_META_COMMON_VSI, &field_id); if (status != TDI_SUCCESS) { krnlmon_log_error("Unable to get field ID for key: %s, error: %d", - LNW_HANDLE_OVS_TO_WIRE_TABLE_KEY_META_COMMON_VSI, status); + LNW_TX_ACC_VSI_TABLE_KEY_META_COMMON_VSI, status); goto dealloc_resources; } @@ -120,36 +115,36 @@ tdi_status_t switch_pd_get_physical_port_id(switch_device_t device, key_hdl, field_id, netdev_port_id - SWITCH_PD_TARGET_VPORT_OFFSET); if (status != TDI_SUCCESS) { krnlmon_log_error( - "Unable to set value for key ID: %d for vxlan_encap_mod_table" + "Unable to set value for key ID: %d for %s" ", error: %d", - field_id, status); + field_id, LNW_TX_ACC_VSI_TABLE, status); goto dealloc_resources; } status = tdi_key_field_id_get( - table_info_hdl, LNW_HANDLE_OVS_TO_WIRE_TABLE_KEY_USER_META_BIT32_ZEROS, - &field_id); + table_info_hdl, LNW_TX_ACC_VSI_TABLE_KEY_ZERO_PADDING, &field_id); if (status != TDI_SUCCESS) { krnlmon_log_error("Unable to get field ID for key: %s, error: %d", - LNW_HANDLE_OVS_TO_WIRE_TABLE_KEY_USER_META_BIT32_ZEROS, - status); + LNW_TX_ACC_VSI_TABLE_KEY_ZERO_PADDING, status); goto dealloc_resources; } status = tdi_key_field_set_value(key_hdl, field_id, 0); if (status != TDI_SUCCESS) { krnlmon_log_error( - "Unable to set value for key ID: %d for vxlan_encap_mod_table" + "Unable to set value for key ID: %d for %s" ", error: %d", - field_id, status); + field_id, LNW_TX_ACC_VSI_TABLE, status); goto dealloc_resources; } status = tdi_action_name_to_id( - table_info_hdl, LNW_HANDLE_OVS_TO_WIRE_TABLE_ACTION_SET_DEST, &action_id); + table_info_hdl, LNW_TX_ACC_VSI_TABLE_ACTION_L2_FWD_AND_BYPASS_BRIDGE, + &action_id); if (status != TDI_SUCCESS) { krnlmon_log_error("Unable to get action allocator ID for: %s, error: %d", - LNW_HANDLE_OVS_TO_WIRE_TABLE_ACTION_SET_DEST, status); + LNW_TX_ACC_VSI_TABLE_ACTION_L2_FWD_AND_BYPASS_BRIDGE, + status); goto dealloc_resources; } @@ -158,7 +153,7 @@ tdi_status_t switch_pd_get_physical_port_id(switch_device_t device, krnlmon_log_error( "Unable to get action allocator for ID: %s, " "error: %d", - LNW_HANDLE_OVS_TO_WIRE_TABLE_ACTION_SET_DEST, status); + LNW_TX_ACC_VSI_TABLE_ACTION_L2_FWD_AND_BYPASS_BRIDGE, status); goto dealloc_resources; } @@ -170,13 +165,11 @@ tdi_status_t switch_pd_get_physical_port_id(switch_device_t device, } status = tdi_data_field_id_with_action_get( - table_info_hdl, - LNW_HANDLE_OVS_TO_WIRE_TABLE_ACTION_SET_DEST_PARAM_PORT_ID, action_id, + table_info_hdl, ACTION_L2_FWD_AND_BYPASS_BRIDGE_PARAM_PORT, action_id, &data_field_id); if (status != TDI_SUCCESS) { - krnlmon_log_error( - "Unable to get action allocator ID for: %s, error: %d", - LNW_HANDLE_OVS_TO_WIRE_TABLE_ACTION_SET_DEST_PARAM_PORT_ID, status); + krnlmon_log_error("Unable to get action allocator ID for: %s, error: %d", + ACTION_L2_FWD_AND_BYPASS_BRIDGE_PARAM_PORT, status); goto dealloc_resources; } // status = tdi_data_field_get_value_ptr(data_hdl, data_field_id, @@ -194,6 +187,184 @@ tdi_status_t switch_pd_get_physical_port_id(switch_device_t device, return switch_pd_tdi_status_to_status(status); } +switch_status_t switch_pd_get_bridge_id(switch_device_t device, + uint8_t physical_port_id, + uint8_t* bridge_id) { + tdi_status_t status; + + tdi_id_t field_id = 0; + tdi_id_t action_id = 0; + tdi_id_t data_field_id = 0; + + tdi_dev_id_t dev_id = device; + + tdi_flags_hdl* flags_hdl = NULL; + tdi_target_hdl* target_hdl = NULL; + const tdi_device_hdl* dev_hdl = NULL; + tdi_session_hdl* session = NULL; + const tdi_info_hdl* info_hdl = NULL; + tdi_table_key_hdl* key_hdl = NULL; + tdi_table_data_hdl* data_hdl = NULL; + const tdi_table_hdl* table_hdl = NULL; + const tdi_table_info_hdl* table_info_hdl = NULL; + uint32_t network_byte_order = 0; + uint64_t get_bridge_id = 0; + + krnlmon_log_debug("Entered: %s", __func__); + + status = tdi_info_get(dev_id, PROGRAM_NAME, &info_hdl); + if (status != TDI_SUCCESS) { + krnlmon_log_error("Failed to get tdi info handle, error: %d", status); + goto dealloc_resources; + } + + status = tdi_flags_create(0, &flags_hdl); + if (status != TDI_SUCCESS) { + krnlmon_log_error("Failed to create flags handle, error: %d", status); + goto dealloc_resources; + } + + status = tdi_device_get(dev_id, &dev_hdl); + if (status != TDI_SUCCESS) { + krnlmon_log_error("Failed to get device handle, error: %d", status); + goto dealloc_resources; + } + + status = tdi_target_create(dev_hdl, &target_hdl); + if (status != TDI_SUCCESS) { + krnlmon_log_error("Failed to create target handle, error: %d", status); + goto dealloc_resources; + } + + status = tdi_session_create(dev_hdl, &session); + if (status != TDI_SUCCESS) { + krnlmon_log_error("Failed to create tdi session, error: %d", status); + goto dealloc_resources; + } + + status = tdi_table_from_name_get( + info_hdl, LNW_SOURCE_PORT_TO_BRIDGE_MAP_TABLE, &table_hdl); + if (status != TDI_SUCCESS || !table_hdl) { + krnlmon_log_error("Unable to get table handle for: %s, error: %d", + LNW_SOURCE_PORT_TO_BRIDGE_MAP_TABLE, status); + goto dealloc_resources; + } + + status = tdi_table_key_allocate(table_hdl, &key_hdl); + if (status != TDI_SUCCESS) { + krnlmon_log_error("Unable to allocate key handle for: %s, error: %d", + LNW_SOURCE_PORT_TO_BRIDGE_MAP_TABLE, status); + goto dealloc_resources; + } + + status = tdi_table_info_get(table_hdl, &table_info_hdl); + if (status != TDI_SUCCESS) { + krnlmon_log_error("Unable to get table info handle for table, error: %d", + status); + goto dealloc_resources; + } + + status = tdi_key_field_id_get( + table_info_hdl, LNW_SOURCE_PORT_TO_BRIDGE_MAP_TABLE_KEY_SOURCE_PORT, + &field_id); + if (status != TDI_SUCCESS) { + krnlmon_log_error("Unable to get field ID for key: %s, error: %d", + LNW_SOURCE_PORT_TO_BRIDGE_MAP_TABLE_KEY_SOURCE_PORT, + status); + goto dealloc_resources; + } + + status = tdi_key_field_set_value_and_mask(key_hdl, field_id, physical_port_id, + 0xFFFF); + if (status != TDI_SUCCESS) { + krnlmon_log_error( + "Unable to set value for key ID: %d for %s" + ", error: %d", + field_id, LNW_SOURCE_PORT_TO_BRIDGE_MAP_TABLE, status); + goto dealloc_resources; + } + + status = tdi_key_field_id_get( + table_info_hdl, LNW_SOURCE_PORT_TO_BRIDGE_MAP_TABLE_KEY_VID, &field_id); + if (status != TDI_SUCCESS) { + krnlmon_log_error("Unable to get field ID for key: %s, error: %d", + LNW_SOURCE_PORT_TO_BRIDGE_MAP_TABLE_KEY_VID, status); + goto dealloc_resources; + } + + status = tdi_key_field_set_value_and_mask(key_hdl, field_id, 0, 0xFFF); + if (status != TDI_SUCCESS) { + krnlmon_log_error( + "Unable to set value for key ID: %d for %s" + ", error: %d", + field_id, LNW_SOURCE_PORT_TO_BRIDGE_MAP_TABLE, status); + goto dealloc_resources; + } + + status = + tdi_key_field_id_get(table_info_hdl, LNW_KEY_MATCH_PRIORITY, &field_id); + if (status != TDI_SUCCESS) { + krnlmon_log_error("Unable to get field ID for key: %s, error: %d", + LNW_KEY_MATCH_PRIORITY, status); + goto dealloc_resources; + } + + status = tdi_key_field_set_value(key_hdl, field_id, 16777214); + if (status != TDI_SUCCESS) { + krnlmon_log_error( + "Unable to set value for key ID: %d for %s" + ", error: %d", + field_id, LNW_SOURCE_PORT_TO_BRIDGE_MAP_TABLE, status); + goto dealloc_resources; + } + + status = tdi_action_name_to_id( + table_info_hdl, LNW_SOURCE_PORT_TO_BRIDGE_MAP_TABLE_ACTION_SET_BRIDGE_ID, + &action_id); + if (status != TDI_SUCCESS) { + krnlmon_log_error("Unable to get action allocator ID for: %s, error: %d", + LNW_SOURCE_PORT_TO_BRIDGE_MAP_TABLE_ACTION_SET_BRIDGE_ID, + status); + goto dealloc_resources; + } + + status = tdi_table_action_data_allocate(table_hdl, action_id, &data_hdl); + if (status != TDI_SUCCESS) { + krnlmon_log_error( + "Unable to get action allocator for ID: %s, " + "error: %d", + LNW_SOURCE_PORT_TO_BRIDGE_MAP_TABLE_ACTION_SET_BRIDGE_ID, status); + goto dealloc_resources; + } + + status = tdi_table_entry_get(table_hdl, session, target_hdl, flags_hdl, + key_hdl, data_hdl); + if (status != TDI_SUCCESS) { + krnlmon_log_error("Failed to get data handle for netdev: %d", status); + goto dealloc_resources; + } + + status = tdi_data_field_id_with_action_get( + table_info_hdl, + LNW_SOURCE_PORT_TO_BRIDGE_MAP_TABLE_ACTION_PARAM_BRIDGE_ID, action_id, + &data_field_id); + if (status != TDI_SUCCESS) { + krnlmon_log_error("Unable to get action allocator ID for: %s, error: %d", + ACTION_L2_FWD_AND_BYPASS_BRIDGE_PARAM_PORT, status); + goto dealloc_resources; + } + status = tdi_data_field_get_value(data_hdl, data_field_id, &get_bridge_id); + if (status != TDI_SUCCESS) { + krnlmon_log_error("Failed to get value for the handle: %d", status); + goto dealloc_resources; + } + *bridge_id = (uint8_t)(get_bridge_id & 0xff); +dealloc_resources: + status = tdi_switch_pd_deallocate_resources(flags_hdl, target_hdl, key_hdl, + data_hdl, session, true); + return switch_pd_tdi_status_to_status(status); +} + void switch_pd_to_get_port_id(switch_api_rif_info_t* port_rif_info) { switch_handle_t rmac_handle = SWITCH_API_INVALID_HANDLE; switch_status_t status = SWITCH_STATUS_SUCCESS; diff --git a/switchapi/es2k/switch_pd_utils.h b/switchapi/es2k/switch_pd_utils.h index e9eba5c..d64e205 100644 --- a/switchapi/es2k/switch_pd_utils.h +++ b/switchapi/es2k/switch_pd_utils.h @@ -41,7 +41,7 @@ extern "C" { #endif -#define PROGRAM_NAME "fxp-net_linux-networking" +#define PROGRAM_NAME "fxp-net_linux-networking-v2" // Currently this value is picked from dpdk_port_config.pb.txt #define MAX_NO_OF_PORTS 312 @@ -59,6 +59,10 @@ tdi_status_t switch_pd_get_physical_port_id(switch_device_t device, uint32_t netdev_port_id, uint8_t* physical_port_id); +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, diff --git a/switchapi/switch_fdb.h b/switchapi/switch_fdb.h index 8d1bad8..00ac974 100644 --- a/switchapi/switch_fdb.h +++ b/switchapi/switch_fdb.h @@ -102,6 +102,8 @@ typedef struct switch_api_l2_info_s { uint8_t port_id; + uint8_t bridge_id; + switch_l2_learn_from_t learn_from; switch_handle_t l2_handle; diff --git a/switchlink/switchlink_link.c b/switchlink/switchlink_link.c index 8045f1c..d8b9858 100644 --- a/switchlink/switchlink_link.c +++ b/switchlink/switchlink_link.c @@ -20,17 +20,22 @@ #include "switchlink_link.h" #include +#include +#include #include #include +#include #include #include #include #include +#include #include #include "switchlink.h" #include "switchlink_handle.h" #include "switchlink_int.h" +#include "switchlink_utils.h" #if defined(ES2K_TARGET) // ES2K creates netdevs from idpf driver/SR-IOVs. @@ -88,6 +93,50 @@ static switchlink_link_type_t get_link_type(const char* info_kind) { return link_type; } +#if defined(ES2K_TARGET) +/* + * Routine Description: + * Check if the interface driver is valid for our use case + * + * Arguments: + * [in] ifname - Interface name + * + * Return Values: + * boolean + */ +bool validate_driver_name(char* ifname) { + struct ethtool_drvinfo drv = {0}; + char drvname[32] = {0}; + struct ifreq ifr = {0}; + int fd, r = 0; + + fd = socket(AF_INET, SOCK_DGRAM, 0); + if (fd < 0) { + return false; + } + + drv.cmd = ETHTOOL_GDRVINFO; + strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); + ifr.ifr_data = (void*)&drv; + + r = ioctl(fd, SIOCETHTOOL, &ifr); + if (r) { + goto end; + } + + strncpy(drvname, drv.driver, sizeof(drvname)); + + if (!memcmp(drvname, "openvswitch", strlen(drvname)) || + !memcmp(drvname, "idpf", strlen(drvname))) { + close(fd); + return true; + } +end: + close(fd); + return false; +} +#endif + /* * Routine Description: * Processes a nested INFO_DATA attribute. @@ -349,6 +398,15 @@ void switchlink_process_link_msg(const struct nlmsghdr* nlmsg, int msgtype) { break; } +#if defined(ES2K_TARGET) + if (!validate_driver_name(attrs.ifname)) { + krnlmon_log_info( + "Ignoring interface: %s which is not created" + " by openvswitch or idpf driver", + intf_info.ifname); + break; + } +#endif snprintf(intf_info.ifname, sizeof(intf_info.ifname), "%s", attrs.ifname); intf_info.ifindex = ifmsg->ifi_index; diff --git a/switchlink/switchlink_route.c b/switchlink/switchlink_route.c index 68ef5ac..948618d 100644 --- a/switchlink/switchlink_route.c +++ b/switchlink/switchlink_route.c @@ -255,7 +255,7 @@ void switchlink_process_route_msg(const struct nlmsghdr* nlmsg, int msgtype) { intf_h = ifinfo.intf_h; } } else if (status != SWITCHLINK_DB_STATUS_SUCCESS) { - krnlmon_log_error( + krnlmon_log_debug( "route: Failed to get switchlink DB interface info, " "error: %d \n", status);