Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix setting host_tx_ready from initializePort() #13

Closed
wants to merge 11 commits into from
35 changes: 17 additions & 18 deletions cfgmgr/buffermgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -549,24 +549,23 @@ void BufferMgr::doTask(Consumer &consumer)
task_status = doSpeedUpdateTask(port);
}
}

switch (task_status)
{
case task_process_status::task_failed:
SWSS_LOG_ERROR("Failed to process table update");
return;
case task_process_status::task_need_retry:
SWSS_LOG_INFO("Unable to process table update. Will retry...");
++it;
break;
case task_process_status::task_invalid_entry:
SWSS_LOG_ERROR("Failed to process invalid entry, drop it");
it = consumer.m_toSync.erase(it);
break;
default:
it = consumer.m_toSync.erase(it);
break;
}
}
switch (task_status)
{
case task_process_status::task_failed:
SWSS_LOG_ERROR("Failed to process table update");
return;
case task_process_status::task_need_retry:
SWSS_LOG_INFO("Unable to process table update. Will retry...");
++it;
break;
case task_process_status::task_invalid_entry:
SWSS_LOG_ERROR("Failed to process invalid entry, drop it");
it = consumer.m_toSync.erase(it);
break;
default:
it = consumer.m_toSync.erase(it);
break;
}
}
}
10 changes: 6 additions & 4 deletions cfgmgr/coppmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ static set<string> g_copp_init_set;

void CoppMgr::parseInitFile(void)
{
std::ifstream ifs(COPP_INIT_FILE);
std::ifstream ifs(m_coppCfgfile);

if (ifs.fail())
{
SWSS_LOG_ERROR("COPP init file %s not found", COPP_INIT_FILE);
SWSS_LOG_ERROR("COPP init file %s not found", m_coppCfgfile.c_str());
return;
}
json j = json::parse(ifs);
Expand Down Expand Up @@ -293,15 +294,16 @@ bool CoppMgr::isDupEntry(const std::string &key, std::vector<FieldValueTuple> &f
return true;
}

CoppMgr::CoppMgr(DBConnector *cfgDb, DBConnector *appDb, DBConnector *stateDb, const vector<string> &tableNames) :
CoppMgr::CoppMgr(DBConnector *cfgDb, DBConnector *appDb, DBConnector *stateDb, const vector<string> &tableNames, const string copp_init_file) :
Orch(cfgDb, tableNames),
m_cfgCoppTrapTable(cfgDb, CFG_COPP_TRAP_TABLE_NAME),
m_cfgCoppGroupTable(cfgDb, CFG_COPP_GROUP_TABLE_NAME),
m_cfgFeatureTable(cfgDb, CFG_FEATURE_TABLE_NAME),
m_appCoppTable(appDb, APP_COPP_TABLE_NAME),
m_stateCoppTrapTable(stateDb, STATE_COPP_TRAP_TABLE_NAME),
m_stateCoppGroupTable(stateDb, STATE_COPP_GROUP_TABLE_NAME),
m_coppTable(appDb, APP_COPP_TABLE_NAME)
m_coppTable(appDb, APP_COPP_TABLE_NAME),
m_coppCfgfile(copp_init_file)
{
SWSS_LOG_ENTER();
parseInitFile();
Expand Down
3 changes: 2 additions & 1 deletion cfgmgr/coppmgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class CoppMgr : public Orch
{
public:
CoppMgr(DBConnector *cfgDb, DBConnector *appDb, DBConnector *stateDb,
const std::vector<std::string> &tableNames);
const std::vector<std::string> &tableNames, const std::string copp_init_file = COPP_INIT_FILE);

using Orch::doTask;
private:
Expand All @@ -75,6 +75,7 @@ class CoppMgr : public Orch
CoppCfg m_coppGroupInitCfg;
CoppCfg m_coppTrapInitCfg;
CoppCfg m_featuresCfgTable;
std::string m_coppCfgfile;


void doTask(Consumer &consumer);
Expand Down
3 changes: 2 additions & 1 deletion orchagent/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ orchagent_SOURCES = \
dash/dashaclorch.cpp \
dash/dashaclgroupmgr.cpp \
dash/dashtagmgr.cpp \
dash/pbutils.cpp
dash/pbutils.cpp \
twamporch.cpp

orchagent_SOURCES += flex_counter/flex_counter_manager.cpp flex_counter/flex_counter_stat_manager.cpp flex_counter/flow_counter_handler.cpp flex_counter/flowcounterrouteorch.cpp
orchagent_SOURCES += debug_counter/debug_counter.cpp debug_counter/drop_counter.cpp
Expand Down
2 changes: 0 additions & 2 deletions orchagent/aclorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3223,7 +3223,6 @@ void AclOrch::initDefaultTableTypes()
.withMatch(make_shared<AclTableMatch>(SAI_ACL_TABLE_ATTR_FIELD_L4_SRC_PORT))
.withMatch(make_shared<AclTableMatch>(SAI_ACL_TABLE_ATTR_FIELD_L4_DST_PORT))
.withMatch(make_shared<AclTableMatch>(SAI_ACL_TABLE_ATTR_FIELD_TCP_FLAGS))
.withMatch(make_shared<AclTableMatch>(SAI_ACL_TABLE_ATTR_FIELD_IN_PORTS))
.build()
);

Expand All @@ -3241,7 +3240,6 @@ void AclOrch::initDefaultTableTypes()
.withMatch(make_shared<AclTableMatch>(SAI_ACL_TABLE_ATTR_FIELD_L4_SRC_PORT))
.withMatch(make_shared<AclTableMatch>(SAI_ACL_TABLE_ATTR_FIELD_L4_DST_PORT))
.withMatch(make_shared<AclTableMatch>(SAI_ACL_TABLE_ATTR_FIELD_TCP_FLAGS))
.withMatch(make_shared<AclTableMatch>(SAI_ACL_TABLE_ATTR_FIELD_IN_PORTS))
.build()
);

Expand Down
43 changes: 43 additions & 0 deletions orchagent/bulker.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,14 @@ static inline bool operator==(const sai_inseg_entry_t& a, const sai_inseg_entry_
;
}

static inline bool operator==(const sai_neighbor_entry_t& a, const sai_neighbor_entry_t& b)
{
return a.switch_id == b.switch_id
&& a.rif_id == b.rif_id
&& a.ip_address == b.ip_address
;
}

static inline bool operator==(const sai_inbound_routing_entry_t& a, const sai_inbound_routing_entry_t& b)
{
return a.switch_id == b.switch_id
Expand Down Expand Up @@ -203,6 +211,19 @@ namespace std
}
};

template <>
struct hash<sai_neighbor_entry_t>
{
size_t operator()(const sai_neighbor_entry_t& a) const noexcept
{
size_t seed = 0;
boost::hash_combine(seed, a.switch_id);
boost::hash_combine(seed, a.rif_id);
boost::hash_combine(seed, a.ip_address);
return seed;
}
};

template <>
struct hash<sai_outbound_ca_to_pa_entry_t>
{
Expand Down Expand Up @@ -334,6 +355,19 @@ struct SaiBulkerTraits<sai_mpls_api_t>
using bulk_set_entry_attribute_fn = sai_bulk_set_inseg_entry_attribute_fn;
};

template<>
struct SaiBulkerTraits<sai_neighbor_api_t>
{
using entry_t = sai_neighbor_entry_t;
using api_t = sai_neighbor_api_t;
using create_entry_fn = sai_create_neighbor_entry_fn;
using remove_entry_fn = sai_remove_neighbor_entry_fn;
using set_entry_attribute_fn = sai_set_neighbor_entry_attribute_fn;
using bulk_create_entry_fn = sai_bulk_create_neighbor_entry_fn;
using bulk_remove_entry_fn = sai_bulk_remove_neighbor_entry_fn;
using bulk_set_entry_attribute_fn = sai_bulk_set_neighbor_entry_attribute_fn;
};

template<>
struct SaiBulkerTraits<sai_dash_vnet_api_t>
{
Expand Down Expand Up @@ -811,6 +845,15 @@ inline EntityBulker<sai_mpls_api_t>::EntityBulker(sai_mpls_api_t *api, size_t ma
set_entries_attribute = api->set_inseg_entries_attribute;
}

template <>
inline EntityBulker<sai_neighbor_api_t>::EntityBulker(sai_neighbor_api_t *api, size_t max_bulk_size) :
max_bulk_size(max_bulk_size)
{
create_entries = api->create_neighbor_entries;
remove_entries = api->remove_neighbor_entries;
set_entries_attribute = api->set_neighbor_entries_attribute;
}

template <>
inline EntityBulker<sai_dash_inbound_routing_api_t>::EntityBulker(sai_dash_inbound_routing_api_t *api, size_t max_bulk_size) : max_bulk_size(max_bulk_size)
{
Expand Down
19 changes: 14 additions & 5 deletions orchagent/crmorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ const map<CrmResourceType, string> crmResTypeNameMap =
{ CrmResourceType::CRM_DASH_IPV6_ACL_GROUP, "DASH_IPV6_ACL_GROUP" },
{ CrmResourceType::CRM_DASH_IPV4_ACL_RULE, "DASH_IPV4_ACL_RULE" },
{ CrmResourceType::CRM_DASH_IPV6_ACL_RULE, "DASH_IPV6_ACL_RULE" },
{ CrmResourceType::CRM_TWAMP_ENTRY, "TWAMP_ENTRY" }
};

const map<CrmResourceType, uint32_t> crmResSaiAvailAttrMap =
Expand All @@ -84,6 +85,7 @@ const map<CrmResourceType, uint32_t> crmResSaiAvailAttrMap =
{ CrmResourceType::CRM_IPMC_ENTRY, SAI_SWITCH_ATTR_AVAILABLE_IPMC_ENTRY},
{ CrmResourceType::CRM_SNAT_ENTRY, SAI_SWITCH_ATTR_AVAILABLE_SNAT_ENTRY },
{ CrmResourceType::CRM_DNAT_ENTRY, SAI_SWITCH_ATTR_AVAILABLE_DNAT_ENTRY },
{ CrmResourceType::CRM_TWAMP_ENTRY, SAI_SWITCH_ATTR_AVAILABLE_TWAMP_SESSION }
};

const map<CrmResourceType, sai_object_type_t> crmResSaiObjAttrMap =
Expand Down Expand Up @@ -125,6 +127,7 @@ const map<CrmResourceType, sai_object_type_t> crmResSaiObjAttrMap =
{ CrmResourceType::CRM_DASH_IPV6_ACL_GROUP, (sai_object_type_t)SAI_OBJECT_TYPE_DASH_ACL_GROUP },
{ CrmResourceType::CRM_DASH_IPV4_ACL_RULE, (sai_object_type_t)SAI_OBJECT_TYPE_DASH_ACL_RULE },
{ CrmResourceType::CRM_DASH_IPV6_ACL_RULE, (sai_object_type_t)SAI_OBJECT_TYPE_DASH_ACL_RULE },
{ CrmResourceType::CRM_TWAMP_ENTRY, SAI_OBJECT_TYPE_NULL }
};

const map<CrmResourceType, sai_attr_id_t> crmResAddrFamilyAttrMap =
Expand Down Expand Up @@ -185,7 +188,8 @@ const map<string, CrmResourceType> crmThreshTypeResMap =
{ "dash_ipv4_acl_group_threshold_type", CrmResourceType::CRM_DASH_IPV4_ACL_GROUP },
{ "dash_ipv6_acl_group_threshold_type", CrmResourceType::CRM_DASH_IPV6_ACL_GROUP },
{ "dash_ipv4_acl_rule_threshold_type", CrmResourceType::CRM_DASH_IPV4_ACL_RULE },
{ "dash_ipv6_acl_rule_threshold_type", CrmResourceType::CRM_DASH_IPV6_ACL_RULE }
{ "dash_ipv6_acl_rule_threshold_type", CrmResourceType::CRM_DASH_IPV6_ACL_RULE },
{ "twamp_entry_threshold_type", CrmResourceType::CRM_TWAMP_ENTRY }
};

const map<string, CrmResourceType> crmThreshLowResMap =
Expand Down Expand Up @@ -226,7 +230,8 @@ const map<string, CrmResourceType> crmThreshLowResMap =
{ "dash_ipv4_acl_group_low_threshold", CrmResourceType::CRM_DASH_IPV4_ACL_GROUP },
{ "dash_ipv6_acl_group_low_threshold", CrmResourceType::CRM_DASH_IPV6_ACL_GROUP },
{ "dash_ipv4_acl_rule_low_threshold", CrmResourceType::CRM_DASH_IPV4_ACL_RULE },
{ "dash_ipv6_acl_rule_low_threshold", CrmResourceType::CRM_DASH_IPV6_ACL_RULE }
{ "dash_ipv6_acl_rule_low_threshold", CrmResourceType::CRM_DASH_IPV6_ACL_RULE },
{ "twamp_entry_low_threshold", CrmResourceType::CRM_TWAMP_ENTRY }
};

const map<string, CrmResourceType> crmThreshHighResMap =
Expand Down Expand Up @@ -267,7 +272,8 @@ const map<string, CrmResourceType> crmThreshHighResMap =
{ "dash_ipv4_acl_group_high_threshold", CrmResourceType::CRM_DASH_IPV4_ACL_GROUP },
{ "dash_ipv6_acl_group_high_threshold", CrmResourceType::CRM_DASH_IPV6_ACL_GROUP },
{ "dash_ipv4_acl_rule_high_threshold", CrmResourceType::CRM_DASH_IPV4_ACL_RULE },
{ "dash_ipv6_acl_rule_high_threshold", CrmResourceType::CRM_DASH_IPV6_ACL_RULE }
{ "dash_ipv6_acl_rule_high_threshold", CrmResourceType::CRM_DASH_IPV6_ACL_RULE },
{ "twamp_entry_high_threshold", CrmResourceType::CRM_TWAMP_ENTRY }
};

const map<string, CrmThresholdType> crmThreshTypeMap =
Expand Down Expand Up @@ -315,7 +321,8 @@ const map<string, CrmResourceType> crmAvailCntsTableMap =
{ "crm_stats_dash_ipv4_acl_group_available", CrmResourceType::CRM_DASH_IPV4_ACL_GROUP },
{ "crm_stats_dash_ipv6_acl_group_available", CrmResourceType::CRM_DASH_IPV6_ACL_GROUP },
{ "crm_stats_dash_ipv4_acl_rule_available", CrmResourceType::CRM_DASH_IPV4_ACL_RULE },
{ "crm_stats_dash_ipv6_acl_rule_available", CrmResourceType::CRM_DASH_IPV6_ACL_RULE }
{ "crm_stats_dash_ipv6_acl_rule_available", CrmResourceType::CRM_DASH_IPV6_ACL_RULE },
{ "crm_stats_twamp_entry_available", CrmResourceType::CRM_TWAMP_ENTRY }
};

const map<string, CrmResourceType> crmUsedCntsTableMap =
Expand Down Expand Up @@ -356,7 +363,8 @@ const map<string, CrmResourceType> crmUsedCntsTableMap =
{ "crm_stats_dash_ipv4_acl_group_used", CrmResourceType::CRM_DASH_IPV4_ACL_GROUP },
{ "crm_stats_dash_ipv6_acl_group_used", CrmResourceType::CRM_DASH_IPV6_ACL_GROUP },
{ "crm_stats_dash_ipv4_acl_rule_used", CrmResourceType::CRM_DASH_IPV4_ACL_RULE },
{ "crm_stats_dash_ipv6_acl_rule_used", CrmResourceType::CRM_DASH_IPV6_ACL_RULE }
{ "crm_stats_dash_ipv6_acl_rule_used", CrmResourceType::CRM_DASH_IPV6_ACL_RULE },
{ "crm_stats_twamp_entry_used", CrmResourceType::CRM_TWAMP_ENTRY },
};

CrmOrch::CrmOrch(DBConnector *db, string tableName):
Expand Down Expand Up @@ -877,6 +885,7 @@ void CrmOrch::getResAvailableCounters()
case CrmResourceType::CRM_DASH_IPV6_OUTBOUND_CA_TO_PA:
case CrmResourceType::CRM_DASH_IPV4_ACL_GROUP:
case CrmResourceType::CRM_DASH_IPV6_ACL_GROUP:
case CrmResourceType::CRM_TWAMP_ENTRY:
{
getResAvailability(res.first, res.second);
break;
Expand Down
3 changes: 2 additions & 1 deletion orchagent/crmorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ enum class CrmResourceType
CRM_DASH_IPV4_ACL_GROUP,
CRM_DASH_IPV6_ACL_GROUP,
CRM_DASH_IPV4_ACL_RULE,
CRM_DASH_IPV6_ACL_RULE
CRM_DASH_IPV6_ACL_RULE,
CRM_TWAMP_ENTRY
};

enum class CrmThresholdType
Expand Down
37 changes: 4 additions & 33 deletions orchagent/neighorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1385,7 +1385,7 @@ void NeighOrch::doVoqSystemNeighTask(Consumer &consumer)
continue;
}

MacAddress mac_address;
MacAddress mac_address, original_mac_address;
uint32_t encap_index = 0;
for (auto i = kfvFieldsValues(t).begin();
i != kfvFieldsValues(t).end(); i++)
Expand Down Expand Up @@ -1465,42 +1465,13 @@ void NeighOrch::doVoqSystemNeighTask(Consumer &consumer)
//kernel programming.
if(ibif.m_type != Port::VLAN)
{
original_mac_address = mac_address;
mac_address = gMacAddress;

// For VS platforms, the mac of the static neigh should not be same as asic's own mac.
// This is because host originated packets will have same mac for both src and dst which
// will result in host NOT sending packet out. To address this problem which is specific
// to port type inband interfaces, set the mac to the neighbor's owner asic's mac. Since
// the owner asic's mac is not readily avaiable here, the owner asic mac is derived from
// the switch id and lower 5 bytes of asic mac which is assumed to be same for all asics
// in the VS system.
// Therefore to make VOQ chassis systems work in VS platform based setups like the setups
// using KVMs, it is required that all asics have same base mac in the format given below
// <lower 5 bytes of mac same for all asics>:<6th byte = switch_id>

string platform = getenv("ASIC_VENDOR") ? getenv("ASIC_VENDOR") : "";

// For VS platform, use the original MAC address
if (platform == VS_PLATFORM_SUBSTRING)
{
int8_t sw_id = -1;
uint8_t egress_asic_mac[ETHER_ADDR_LEN];

gMacAddress.getMac(egress_asic_mac);

if (p.m_type == Port::LAG)
{
sw_id = (int8_t) p.m_system_lag_info.switch_id;
}
else if (p.m_type == Port::PHY || p.m_type == Port::SYSTEM)
{
sw_id = (int8_t) p.m_system_port_info.switch_id;
}

if(sw_id != -1)
{
egress_asic_mac[5] = sw_id;
mac_address = MacAddress(egress_asic_mac);
}
mac_address = original_mac_address;
}
}
vector<FieldValueTuple> fvVector;
Expand Down
6 changes: 6 additions & 0 deletions orchagent/notifications.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ void on_bfd_session_state_change(uint32_t count, sai_bfd_session_state_notificat
// which causes concurrency access to the DB
}

void on_twamp_session_event(uint32_t count, sai_twamp_session_event_notification_data_t *data)
{
// don't use this event handler, because it runs by libsairedis in a separate thread
// which causes concurrency access to the DB
}

void on_switch_shutdown_request(sai_object_id_t switch_id)
{
SWSS_LOG_ENTER();
Expand Down
1 change: 1 addition & 0 deletions orchagent/notifications.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ extern "C" {
void on_fdb_event(uint32_t count, sai_fdb_event_notification_data_t *data);
void on_port_state_change(uint32_t count, sai_port_oper_status_notification_t *data);
void on_bfd_session_state_change(uint32_t count, sai_bfd_session_state_notification_t *data);
void on_twamp_session_event(uint32_t count, sai_twamp_session_event_notification_data_t *data);

// The function prototype information can be found here:
// https://github.com/sonic-net/sonic-sairedis/blob/master/meta/NotificationSwitchShutdownRequest.cpp#L49
Expand Down
5 changes: 5 additions & 0 deletions orchagent/orchdaemon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -727,6 +727,11 @@ bool OrchDaemon::init()
gP4Orch = new P4Orch(m_applDb, p4rt_tables, vrf_orch, gCoppOrch);
m_orchList.push_back(gP4Orch);

TableConnector confDbTwampTable(m_configDb, CFG_TWAMP_SESSION_TABLE_NAME);
TableConnector stateDbTwampTable(m_stateDb, STATE_TWAMP_SESSION_TABLE_NAME);
TwampOrch *twamp_orch = new TwampOrch(confDbTwampTable, stateDbTwampTable, gSwitchOrch, gPortsOrch, vrf_orch);
m_orchList.push_back(twamp_orch);

if (WarmStart::isWarmStart())
{
bool suc = warmRestoreAndSyncUp();
Expand Down
1 change: 1 addition & 0 deletions orchagent/orchdaemon.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
#include "bfdorch.h"
#include "srv6orch.h"
#include "nvgreorch.h"
#include "twamporch.h"
#include "dash/dashaclorch.h"
#include "dash/dashorch.h"
#include "dash/dashrouteorch.h"
Expand Down
Loading
Loading