Skip to content

Commit

Permalink
ARM32 bit fixes, for 64bit printf format specifier (sonic-net#989)
Browse files Browse the repository at this point in the history
* ARM32 bit fixes, for 64bit printf format specifier

Signed-off-by: Antony Rheneus <arheneus@marvell.com>
  • Loading branch information
antony-rheneus authored and lguohan committed Jul 25, 2019
1 parent 5d04f05 commit dde876d
Show file tree
Hide file tree
Showing 20 changed files with 172 additions and 152 deletions.
21 changes: 11 additions & 10 deletions orchagent/aclorch.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <inttypes.h>
#include <limits.h>
#include <unordered_map>
#include <algorithm>
Expand Down Expand Up @@ -715,7 +716,7 @@ bool AclRule::removeCounter()

gCrmOrch->decCrmAclTableUsedCounter(CrmResourceType::CRM_ACL_COUNTER, m_tableOid);

SWSS_LOG_INFO("Removing record about the counter %lX from the DB", m_counterOid);
SWSS_LOG_INFO("Removing record about the counter %" PRIx64 " from the DB", m_counterOid);
AclOrch::getCountersTable().del(getTableId() + ":" + getId());

m_counterOid = SAI_NULL_OBJECT_ID;
Expand Down Expand Up @@ -1445,7 +1446,7 @@ bool AclTable::unbind(sai_object_id_t portOid)
sai_object_id_t member = ports[portOid];
sai_status_t status = sai_acl_api->remove_acl_table_group_member(member);
if (status != SAI_STATUS_SUCCESS) {
SWSS_LOG_ERROR("Failed to unbind table %lu as member %lu from ACL table: %d",
SWSS_LOG_ERROR("Failed to unbind table %" PRIu64 " as member %" PRIu64 " from ACL table: %d",
m_oid, member, status);
return false;
}
Expand Down Expand Up @@ -1888,14 +1889,14 @@ AclRange *AclRange::create(sai_acl_range_type_t type, int min, int max)
return NULL;
}

SWSS_LOG_INFO("Created ACL Range object. Type: %d, range %d-%d, oid: %lX", type, min, max, range_oid);
SWSS_LOG_INFO("Created ACL Range object. Type: %d, range %d-%d, oid: %" PRIx64, type, min, max, range_oid);
m_ranges[rangeProperties] = new AclRange(type, range_oid, min, max);

range_it = m_ranges.find(rangeProperties);
}
else
{
SWSS_LOG_INFO("Reusing range object oid %lX ref count increased to %d", range_it->second->m_oid, range_it->second->m_refCnt);
SWSS_LOG_INFO("Reusing range object oid %" PRIx64 " ref count increased to %d", range_it->second->m_oid, range_it->second->m_refCnt);
}

// increase range reference count
Expand Down Expand Up @@ -1947,10 +1948,10 @@ bool AclRange::remove()

if (m_refCnt == 0)
{
SWSS_LOG_INFO("Range object oid %lX ref count is %d, removing..", m_oid, m_refCnt);
SWSS_LOG_INFO("Range object oid %" PRIx64 " ref count is %d, removing..", m_oid, m_refCnt);
if (sai_acl_api->remove_acl_range(m_oid) != SAI_STATUS_SUCCESS)
{
SWSS_LOG_ERROR("Failed to delete ACL Range object oid: %lX", m_oid);
SWSS_LOG_ERROR("Failed to delete ACL Range object oid: %" PRIx64, m_oid);
return false;
}
auto range_it = m_ranges.find(make_tuple(m_type, m_min, m_max));
Expand All @@ -1960,7 +1961,7 @@ bool AclRange::remove()
}
else
{
SWSS_LOG_INFO("Range object oid %lX ref count decreased to %d", m_oid, m_refCnt);
SWSS_LOG_INFO("Range object oid %" PRIx64 " ref count decreased to %d", m_oid, m_refCnt);
}

return true;
Expand Down Expand Up @@ -2207,7 +2208,7 @@ bool AclOrch::addAclTable(AclTable &newTable, string table_id)
if (createBindAclTable(newTable, table_oid))
{
m_AclTables[table_oid] = newTable;
SWSS_LOG_NOTICE("Created ACL table %s oid:%lx",
SWSS_LOG_NOTICE("Created ACL table %s oid:%" PRIx64,
newTable.id.c_str(), table_oid);

// Mark the existence of the mirror table
Expand Down Expand Up @@ -2820,7 +2821,7 @@ sai_status_t AclOrch::createDTelWatchListTables()

gCrmOrch->incCrmAclUsedCounter(CrmResourceType::CRM_ACL_TABLE, SAI_ACL_STAGE_INGRESS, SAI_ACL_BIND_POINT_TYPE_SWITCH);
m_AclTables[table_oid] = flowWLTable;
SWSS_LOG_INFO("Successfully created ACL table %s, oid: %lX", flowWLTable.description.c_str(), table_oid);
SWSS_LOG_INFO("Successfully created ACL table %s, oid: %" PRIx64, flowWLTable.description.c_str(), table_oid);

/* Create Drop watchlist ACL table */

Expand Down Expand Up @@ -2881,7 +2882,7 @@ sai_status_t AclOrch::createDTelWatchListTables()

gCrmOrch->incCrmAclUsedCounter(CrmResourceType::CRM_ACL_TABLE, SAI_ACL_STAGE_INGRESS, SAI_ACL_BIND_POINT_TYPE_SWITCH);
m_AclTables[table_oid] = dropWLTable;
SWSS_LOG_INFO("Successfully created ACL table %s, oid: %lX", dropWLTable.description.c_str(), table_oid);
SWSS_LOG_INFO("Successfully created ACL table %s, oid: %" PRIx64, dropWLTable.description.c_str(), table_oid);

return status;
}
Expand Down
13 changes: 7 additions & 6 deletions orchagent/bufferorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "logger.h"
#include "sai_serialize.h"

#include <inttypes.h>
#include <sstream>
#include <iostream>

Expand Down Expand Up @@ -280,10 +281,10 @@ task_process_status BufferOrch::processBufferPool(Consumer &consumer)
sai_status = sai_buffer_api->set_buffer_pool_attribute(sai_object, &attribs[0]);
if (SAI_STATUS_SUCCESS != sai_status)
{
SWSS_LOG_ERROR("Failed to modify buffer pool, name:%s, sai object:%lx, status:%d", object_name.c_str(), sai_object, sai_status);
SWSS_LOG_ERROR("Failed to modify buffer pool, name:%s, sai object:%" PRIx64 ", status:%d", object_name.c_str(), sai_object, sai_status);
return task_process_status::task_failed;
}
SWSS_LOG_DEBUG("Modified existing pool:%lx, type:%s name:%s ", sai_object, map_type_name.c_str(), object_name.c_str());
SWSS_LOG_DEBUG("Modified existing pool:%" PRIx64 ", type:%s name:%s ", sai_object, map_type_name.c_str(), object_name.c_str());
}
else
{
Expand Down Expand Up @@ -422,11 +423,11 @@ task_process_status BufferOrch::processBufferProfile(Consumer &consumer)
}
if (SAI_NULL_OBJECT_ID != sai_object)
{
SWSS_LOG_DEBUG("Modifying existing sai object:%lx ", sai_object);
SWSS_LOG_DEBUG("Modifying existing sai object:%" PRIx64, sai_object);
sai_status = sai_buffer_api->set_buffer_profile_attribute(sai_object, &attribs[0]);
if (SAI_STATUS_SUCCESS != sai_status)
{
SWSS_LOG_ERROR("Failed to modify buffer profile, name:%s, sai object:%lx, status:%d", object_name.c_str(), sai_object, sai_status);
SWSS_LOG_ERROR("Failed to modify buffer profile, name:%s, sai object:%" PRIx64 ", status:%d", object_name.c_str(), sai_object, sai_status);
return task_process_status::task_failed;
}
}
Expand Down Expand Up @@ -521,7 +522,7 @@ task_process_status BufferOrch::processQueue(Consumer &consumer)
return task_process_status::task_invalid_entry;
}
queue_id = port.m_queue_ids[ind];
SWSS_LOG_DEBUG("Applying buffer profile:0x%lx to queue index:%zd, queue sai_id:0x%lx", sai_buffer_profile, ind, queue_id);
SWSS_LOG_DEBUG("Applying buffer profile:0x%" PRIx64 " to queue index:%zd, queue sai_id:0x%" PRIx64, sai_buffer_profile, ind, queue_id);
sai_status_t sai_status = sai_queue_api->set_queue_attribute(queue_id, &attr);
if (sai_status != SAI_STATUS_SUCCESS)
{
Expand Down Expand Up @@ -608,7 +609,7 @@ task_process_status BufferOrch::processPriorityGroup(Consumer &consumer)
return task_process_status::task_invalid_entry;
}
pg_id = port.m_priority_group_ids[ind];
SWSS_LOG_DEBUG("Applying buffer profile:0x%lx to port:%s pg index:%zd, pg sai_id:0x%lx", sai_buffer_profile, port_name.c_str(), ind, pg_id);
SWSS_LOG_DEBUG("Applying buffer profile:0x%" PRIx64 " to port:%s pg index:%zd, pg sai_id:0x%" PRIx64, sai_buffer_profile, port_name.c_str(), ind, pg_id);
sai_status_t sai_status = sai_buffer_api->set_ingress_priority_group_attribute(pg_id, &attr);
if (sai_status != SAI_STATUS_SUCCESS)
{
Expand Down
11 changes: 6 additions & 5 deletions orchagent/copporch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "tokenize.h"
#include "logger.h"

#include <inttypes.h>
#include <sstream>
#include <iostream>

Expand Down Expand Up @@ -277,12 +278,12 @@ sai_object_id_t CoppOrch::getPolicer(string trap_group_name)
{
return SAI_NULL_OBJECT_ID;
}
SWSS_LOG_DEBUG("trap group id:%lx", m_trap_group_map[trap_group_name]);
SWSS_LOG_DEBUG("trap group id:%" PRIx64, m_trap_group_map[trap_group_name]);
if (m_trap_group_policer_map.find(m_trap_group_map[trap_group_name]) == m_trap_group_policer_map.end())
{
return SAI_NULL_OBJECT_ID;
}
SWSS_LOG_DEBUG("trap group policer id:%lx", m_trap_group_policer_map[m_trap_group_map[trap_group_name]]);
SWSS_LOG_DEBUG("trap group policer id:%" PRIx64, m_trap_group_policer_map[m_trap_group_map[trap_group_name]]);
return m_trap_group_policer_map[m_trap_group_map[trap_group_name]];
}

Expand Down Expand Up @@ -456,12 +457,12 @@ task_process_status CoppOrch::processCoppRule(Consumer& consumer)
sai_object_id_t policer_id = getPolicer(trap_group_name);
if (SAI_NULL_OBJECT_ID == policer_id)
{
SWSS_LOG_WARN("Creating policer for existing Trap group:%lx (name:%s).", m_trap_group_map[trap_group_name], trap_group_name.c_str());
SWSS_LOG_WARN("Creating policer for existing Trap group:%" PRIx64 " (name:%s).", m_trap_group_map[trap_group_name], trap_group_name.c_str());
if (!createPolicer(trap_group_name, policer_attribs))
{
return task_process_status::task_failed;
}
SWSS_LOG_DEBUG("Created policer:%lx for existing trap group", policer_id);
SWSS_LOG_DEBUG("Created policer:%" PRIx64 " for existing trap group", policer_id);
}
else
{
Expand All @@ -487,7 +488,7 @@ task_process_status CoppOrch::processCoppRule(Consumer& consumer)
sai_status = sai_hostif_api->set_hostif_trap_group_attribute(m_trap_group_map[trap_group_name], &trap_gr_attr);
if (sai_status != SAI_STATUS_SUCCESS)
{
SWSS_LOG_ERROR("Failed to apply attribute:%d to trap group:%lx, name:%s, error:%d\n", trap_gr_attr.id, m_trap_group_map[trap_group_name], trap_group_name.c_str(), sai_status);
SWSS_LOG_ERROR("Failed to apply attribute:%d to trap group:%" PRIx64 ", name:%s, error:%d\n", trap_gr_attr.id, m_trap_group_map[trap_group_name], trap_group_name.c_str(), sai_status);
return task_process_status::task_failed;
}
SWSS_LOG_NOTICE("Set trap group %s to host interface", trap_group_name.c_str());
Expand Down
13 changes: 7 additions & 6 deletions orchagent/countercheckorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "notifier.h"
#include "redisclient.h"
#include "sai_serialize.h"
#include <inttypes.h>

#define COUNTER_CHECK_POLL_TIMEOUT_SEC (5 * 60)

Expand Down Expand Up @@ -61,7 +62,7 @@ void CounterCheckOrch::mcCounterCheck()
Port port;
if (!gPortsOrch->getPort(oid, port))
{
SWSS_LOG_ERROR("Invalid port oid 0x%lx", oid);
SWSS_LOG_ERROR("Invalid port oid 0x%" PRIx64, oid);
continue;
}

Expand All @@ -78,13 +79,13 @@ void CounterCheckOrch::mcCounterCheck()
bool isLossy = ((1 << prio) & pfcMask) == 0;
if (newMcCounters[prio] == numeric_limits<uint64_t>::max())
{
SWSS_LOG_WARN("Could not retreive MC counters on queue %lu port %s",
SWSS_LOG_WARN("Could not retreive MC counters on queue %" PRIu64 " port %s",
prio,
port.m_alias.c_str());
}
else if (!isLossy && mcCounters[prio] < newMcCounters[prio])
{
SWSS_LOG_WARN("Got Multicast %lu frame(s) on lossless queue %lu port %s",
SWSS_LOG_WARN("Got Multicast %" PRIu64 " frame(s) on lossless queue %" PRIu64 " port %s",
newMcCounters[prio] - mcCounters[prio],
prio,
port.m_alias.c_str());
Expand All @@ -109,7 +110,7 @@ void CounterCheckOrch::pfcFrameCounterCheck()
Port port;
if (!gPortsOrch->getPort(oid, port))
{
SWSS_LOG_ERROR("Invalid port oid 0x%lx", oid);
SWSS_LOG_ERROR("Invalid port oid 0x%" PRIx64, oid);
continue;
}

Expand All @@ -124,13 +125,13 @@ void CounterCheckOrch::pfcFrameCounterCheck()
bool isLossy = ((1 << prio) & pfcMask) == 0;
if (newCounters[prio] == numeric_limits<uint64_t>::max())
{
SWSS_LOG_WARN("Could not retreive PFC frame count on queue %lu port %s",
SWSS_LOG_WARN("Could not retreive PFC frame count on queue %" PRIu64 " port %s",
prio,
port.m_alias.c_str());
}
else if (isLossy && counters[prio] < newCounters[prio])
{
SWSS_LOG_WARN("Got PFC %lu frame(s) on lossy queue %lu port %s",
SWSS_LOG_WARN("Got PFC %" PRIu64 " frame(s) on lossy queue %" PRIu64 " port %s",
newCounters[prio] - counters[prio],
prio,
port.m_alias.c_str());
Expand Down
5 changes: 3 additions & 2 deletions orchagent/crmorch.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <sstream>
#include <inttypes.h>

#include "crmorch.h"
#include "converter.h"
Expand Down Expand Up @@ -378,7 +379,7 @@ void CrmOrch::incCrmAclTableUsedCounter(CrmResourceType resource, sai_object_id_
}
catch (...)
{
SWSS_LOG_ERROR("Failed to increment \"used\" counter for the %s CRM resource (tableId:%lx).", crmResTypeNameMap.at(resource).c_str(), tableId);
SWSS_LOG_ERROR("Failed to increment \"used\" counter for the %s CRM resource (tableId:%" PRIx64 ").", crmResTypeNameMap.at(resource).c_str(), tableId);
return;
}
}
Expand All @@ -393,7 +394,7 @@ void CrmOrch::decCrmAclTableUsedCounter(CrmResourceType resource, sai_object_id_
}
catch (...)
{
SWSS_LOG_ERROR("Failed to decrement \"used\" counter for the %s CRM resource (tableId:%lx).", crmResTypeNameMap.at(resource).c_str(), tableId);
SWSS_LOG_ERROR("Failed to decrement \"used\" counter for the %s CRM resource (tableId:%" PRIx64 ").", crmResTypeNameMap.at(resource).c_str(), tableId);
return;
}
}
Expand Down
25 changes: 13 additions & 12 deletions orchagent/fdborch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <vector>
#include <unordered_map>
#include <utility>
#include <inttypes.h>

#include "logger.h"
#include "tokenize.h"
Expand Down Expand Up @@ -63,7 +64,7 @@ bool FdbOrch::storeFdbEntryState(const FdbUpdate& update)

if (!m_portsOrch->getPort(entry.bv_id, vlan))
{
SWSS_LOG_NOTICE("FdbOrch notification: Failed to locate vlan port from bv_id 0x%lx", entry.bv_id);
SWSS_LOG_NOTICE("FdbOrch notification: Failed to locate vlan port from bv_id 0x%" PRIx64, entry.bv_id);
return false;
}

Expand All @@ -74,7 +75,7 @@ bool FdbOrch::storeFdbEntryState(const FdbUpdate& update)
{
auto inserted = m_entries.insert(entry);

SWSS_LOG_DEBUG("FdbOrch notification: mac %s was inserted into bv_id 0x%lx",
SWSS_LOG_DEBUG("FdbOrch notification: mac %s was inserted into bv_id 0x%" PRIx64,
entry.mac.to_string().c_str(), entry.bv_id);

if (!inserted.second)
Expand All @@ -95,7 +96,7 @@ bool FdbOrch::storeFdbEntryState(const FdbUpdate& update)
else
{
size_t erased = m_entries.erase(entry);
SWSS_LOG_DEBUG("FdbOrch notification: mac %s was removed from bv_id 0x%lx", entry.mac.to_string().c_str(), entry.bv_id);
SWSS_LOG_DEBUG("FdbOrch notification: mac %s was removed from bv_id 0x%" PRIx64, entry.mac.to_string().c_str(), entry.bv_id);

if (erased == 0)
{
Expand Down Expand Up @@ -123,14 +124,14 @@ void FdbOrch::update(sai_fdb_event_t type, const sai_fdb_entry_t* entry, sai_obj
case SAI_FDB_EVENT_LEARNED:
if (!m_portsOrch->getPortByBridgePortId(bridge_port_id, update.port))
{
SWSS_LOG_ERROR("Failed to get port by bridge port ID 0x%lx", bridge_port_id);
SWSS_LOG_ERROR("Failed to get port by bridge port ID 0x%" PRIx64, bridge_port_id);
return;
}

// we already have such entries
if (m_entries.find(update.entry) != m_entries.end())
{
SWSS_LOG_INFO("FdbOrch notification: mac %s is already in bv_id 0x%lx",
SWSS_LOG_INFO("FdbOrch notification: mac %s is already in bv_id 0x%" PRIx64,
update.entry.mac.to_string().c_str(), entry->bv_id);
break;
}
Expand Down Expand Up @@ -186,16 +187,16 @@ void FdbOrch::update(sai_fdb_event_t type, const sai_fdb_entry_t* entry, sai_obj
else if (bridge_port_id && entry->bv_id == SAI_NULL_OBJECT_ID)
{
/*this is a placeholder for flush port fdb case, not supported yet.*/
SWSS_LOG_ERROR("FdbOrch notification: not supported flush port fdb action, port_id = 0x%lx, bv_id = 0x%lx.", bridge_port_id, entry->bv_id);
SWSS_LOG_ERROR("FdbOrch notification: not supported flush port fdb action, port_id = 0x%" PRIx64 ", bv_id = 0x%" PRIx64 ".", bridge_port_id, entry->bv_id);
}
else if (bridge_port_id == SAI_NULL_OBJECT_ID && entry->bv_id != SAI_NULL_OBJECT_ID)
{
/*this is a placeholder for flush vlan fdb case, not supported yet.*/
SWSS_LOG_ERROR("FdbOrch notification: not supported flush vlan fdb action, port_id = 0x%lx, bv_id = 0x%lx.", bridge_port_id, entry->bv_id);
SWSS_LOG_ERROR("FdbOrch notification: not supported flush vlan fdb action, port_id = 0x%" PRIx64 ", bv_id = 0x%" PRIx64 ".", bridge_port_id, entry->bv_id);
}
else
{
SWSS_LOG_ERROR("FdbOrch notification: not supported flush fdb action, port_id = 0x%lx, bv_id = 0x%lx.", bridge_port_id, entry->bv_id);
SWSS_LOG_ERROR("FdbOrch notification: not supported flush fdb action, port_id = 0x%" PRIx64 ", bv_id = 0x%" PRIx64 ".", bridge_port_id, entry->bv_id);
}
break;
}
Expand Down Expand Up @@ -251,7 +252,7 @@ bool FdbOrch::getPort(const MacAddress& mac, uint16_t vlan, Port& port)

if (!m_portsOrch->getPortByBridgePortId(attr.value.oid, port))
{
SWSS_LOG_ERROR("Failed to get port by bridge port ID 0x%lx", attr.value.oid);
SWSS_LOG_ERROR("Failed to get port by bridge port ID 0x%" PRIx64, attr.value.oid);
return false;
}

Expand Down Expand Up @@ -445,7 +446,7 @@ bool FdbOrch::addFdbEntry(const FdbEntry& entry, const string& port_name, const
{
// FIXME: should we check that the entry are moving to another port?
// FIXME: should we check that the entry are changing its type?
SWSS_LOG_ERROR("FDB entry already exists. mac=%s bv_id=0x%lx", entry.mac.to_string().c_str(), entry.bv_id);
SWSS_LOG_ERROR("FDB entry already exists. mac=%s bv_id=0x%" PRIx64, entry.mac.to_string().c_str(), entry.bv_id);
return true;
}

Expand Down Expand Up @@ -518,7 +519,7 @@ bool FdbOrch::removeFdbEntry(const FdbEntry& entry)

if (m_entries.count(entry) == 0)
{
SWSS_LOG_ERROR("FDB entry isn't found. mac=%s bv_id=0x%lx", entry.mac.to_string().c_str(), entry.bv_id);
SWSS_LOG_ERROR("FDB entry isn't found. mac=%s bv_id=0x%" PRIx64, entry.mac.to_string().c_str(), entry.bv_id);
return true;
}

Expand All @@ -531,7 +532,7 @@ bool FdbOrch::removeFdbEntry(const FdbEntry& entry)
status = sai_fdb_api->remove_fdb_entry(&fdb_entry);
if (status != SAI_STATUS_SUCCESS)
{
SWSS_LOG_ERROR("Failed to remove FDB entry. mac=%s, bv_id=0x%lx",
SWSS_LOG_ERROR("Failed to remove FDB entry. mac=%s, bv_id=0x%" PRIx64,
entry.mac.to_string().c_str(), entry.bv_id);
return true; //FIXME: it should be based on status. Some could be retried. some not
}
Expand Down
3 changes: 2 additions & 1 deletion orchagent/intfsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <sstream>
#include <map>
#include <net/if.h>
#include <inttypes.h>

#include "sai_serialize.h"
#include "intfsorch.h"
Expand Down Expand Up @@ -856,7 +857,7 @@ void IntfsOrch::doTask(SelectableTimer &timer)
{
SWSS_LOG_ENTER();

SWSS_LOG_DEBUG("Registering %ld new intfs", m_rifsToAdd.size());
SWSS_LOG_DEBUG("Registering %" PRId64 " new intfs", m_rifsToAdd.size());
string value;
for (auto it = m_rifsToAdd.begin(); it != m_rifsToAdd.end(); )
{
Expand Down
Loading

0 comments on commit dde876d

Please sign in to comment.