Skip to content

Commit c2cea72

Browse files
committed
Create counter for the queue to which the host CPU traffic is sent
Signed-off-by: Stephen Sun <[email protected]>
1 parent ea3e76f commit c2cea72

5 files changed

Lines changed: 50 additions & 6 deletions

File tree

orchagent/flexcounterorch.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,13 @@ map<string, FlexCounterQueueStates> FlexCounterOrch::getQueueConfigurations()
408408
{
409409
queuesStateVector.at(configPortName).enableQueueCounter(startIndex);
410410
}
411+
412+
Port port;
413+
gPortsOrch->getPort(configPortName, port);
414+
if (port.m_host_tx_queue_configured && port.m_host_tx_queue <= maxQueueIndex)
415+
{
416+
queuesStateVector.at(configPortName).enableQueueCounter(port.m_host_tx_queue);
417+
}
411418
} catch (std::invalid_argument const& e) {
412419
SWSS_LOG_ERROR("Invalid queue index [%s] for port [%s]", configPortQueues.c_str(), configPortName.c_str());
413420
continue;

orchagent/p4orch/tests/fake_portorch.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,11 +189,11 @@ void PortsOrch::generateQueueMapPerPort(const Port &port, FlexCounterQueueStates
189189
{
190190
}
191191

192-
void PortsOrch::createPortBufferQueueCounters(const Port &port, string queues)
192+
void PortsOrch::createPortBufferQueueCounters(const Port &port, string queues, bool skip_host_tx_queue)
193193
{
194194
}
195195

196-
void PortsOrch::removePortBufferQueueCounters(const Port &port, string queues)
196+
void PortsOrch::removePortBufferQueueCounters(const Port &port, string queues, bool skip_host_tx_queue)
197197
{
198198
}
199199

orchagent/port.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,8 @@ class Port
162162
sai_port_priority_flow_control_mode_t m_pfc_asym = SAI_PORT_PRIORITY_FLOW_CONTROL_MODE_COMBINED;
163163
uint8_t m_pfc_bitmask = 0; // PFC enable bit mask
164164
uint8_t m_pfcwd_sw_bitmask = 0; // PFC software watchdog enable
165+
uint8_t m_host_tx_queue = 0;
166+
bool m_host_tx_queue_configured = false;
165167
uint16_t m_tpid = DEFAULT_TPID;
166168
uint32_t m_nat_zone_id = 0;
167169
uint32_t m_vnid = VNID_NONE;

orchagent/portsorch.cpp

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3510,6 +3510,11 @@ bool PortsOrch::initPort(const PortConfig &port)
35103510
m_recircPortRole[alias] = role;
35113511
}
35123512

3513+
if (p.m_host_tx_queue_configured)
3514+
{
3515+
createPortBufferQueueCounters(p, to_string(p.m_host_tx_queue), false);
3516+
}
3517+
35133518
SWSS_LOG_NOTICE("Initialized port %s", alias.c_str());
35143519
}
35153520
else
@@ -3540,6 +3545,11 @@ void PortsOrch::deInitPort(string alias, sai_object_id_t port_id)
35403545
return;
35413546
}
35423547

3548+
if (p.m_host_tx_queue_configured)
3549+
{
3550+
removePortBufferQueueCounters(p, to_string(p.m_host_tx_queue), false);
3551+
}
3552+
35433553
/* remove port from flex_counter_table for updating counters */
35443554
auto flex_counters_orch = gDirectory.get<FlexCounterOrch*>();
35453555
if ((flex_counters_orch->getPortCountersState()))
@@ -5951,6 +5961,9 @@ bool PortsOrch::addHostIntfs(Port &port, string alias, sai_object_id_t &host_int
59515961
attr.id = SAI_HOSTIF_ATTR_QUEUE;
59525962
attr.value.u32 = DEFAULT_HOSTIF_TX_QUEUE;
59535963
attrs.push_back(attr);
5964+
5965+
port.m_host_tx_queue = DEFAULT_HOSTIF_TX_QUEUE;
5966+
port.m_host_tx_queue_configured = true;
59545967
}
59555968

59565969
sai_status_t status = sai_hostif_api->create_hostif(&host_intfs_id, gSwitchId, (uint32_t)attrs.size(), attrs.data());
@@ -7258,6 +7271,10 @@ void PortsOrch::generateQueueMap(map<string, FlexCounterQueueStates> queuesState
72587271
{
72597272
flexCounterQueueState.enableQueueCounters(0, maxQueueNumber - 1);
72607273
}
7274+
else if (it.second.m_host_tx_queue_configured && it.second.m_host_tx_queue <= maxQueueNumber)
7275+
{
7276+
flexCounterQueueState.enableQueueCounters(it.second.m_host_tx_queue, it.second.m_host_tx_queue);
7277+
}
72617278
queuesStateVector.insert(make_pair(it.second.m_alias, flexCounterQueueState));
72627279
}
72637280
generateQueueMapPerPort(it.second, queuesStateVector.at(it.second.m_alias), false);
@@ -7396,6 +7413,10 @@ void PortsOrch::addQueueFlexCounters(map<string, FlexCounterQueueStates> queuesS
73967413
{
73977414
flexCounterQueueState.enableQueueCounters(0, maxQueueNumber - 1);
73987415
}
7416+
else if (it.second.m_host_tx_queue_configured && it.second.m_host_tx_queue <= maxQueueNumber)
7417+
{
7418+
flexCounterQueueState.enableQueueCounters(it.second.m_host_tx_queue, it.second.m_host_tx_queue);
7419+
}
73997420
queuesStateVector.insert(make_pair(it.second.m_alias, flexCounterQueueState));
74007421
}
74017422
addQueueFlexCountersPerPort(it.second, queuesStateVector.at(it.second.m_alias));
@@ -7477,6 +7498,10 @@ void PortsOrch::addQueueWatermarkFlexCounters(map<string, FlexCounterQueueStates
74777498
{
74787499
flexCounterQueueState.enableQueueCounters(0, maxQueueNumber - 1);
74797500
}
7501+
else if (it.second.m_host_tx_queue_configured && it.second.m_host_tx_queue <= maxQueueNumber)
7502+
{
7503+
flexCounterQueueState.enableQueueCounters(it.second.m_host_tx_queue, it.second.m_host_tx_queue);
7504+
}
74807505
queuesStateVector.insert(make_pair(it.second.m_alias, flexCounterQueueState));
74817506
}
74827507
addQueueWatermarkFlexCountersPerPort(it.second, queuesStateVector.at(it.second.m_alias));
@@ -7524,7 +7549,7 @@ void PortsOrch::addQueueWatermarkFlexCountersPerPortPerQueueIndex(const Port& po
75247549
startFlexCounterPolling(gSwitchId, key, counters_str, QUEUE_COUNTER_ID_LIST);
75257550
}
75267551

7527-
void PortsOrch::createPortBufferQueueCounters(const Port &port, string queues)
7552+
void PortsOrch::createPortBufferQueueCounters(const Port &port, string queues, bool skip_host_tx_queue)
75287553
{
75297554
SWSS_LOG_ENTER();
75307555

@@ -7544,6 +7569,11 @@ void PortsOrch::createPortBufferQueueCounters(const Port &port, string queues)
75447569

75457570
for (auto queueIndex = startIndex; queueIndex <= endIndex; queueIndex++)
75467571
{
7572+
if (queueIndex == (uint32_t)port.m_host_tx_queue && skip_host_tx_queue)
7573+
{
7574+
continue;
7575+
}
7576+
75477577
std::ostringstream name;
75487578
name << port.m_alias << ":" << queueIndex;
75497579

@@ -7581,7 +7611,7 @@ void PortsOrch::createPortBufferQueueCounters(const Port &port, string queues)
75817611
CounterCheckOrch::getInstance().addPort(port);
75827612
}
75837613

7584-
void PortsOrch::removePortBufferQueueCounters(const Port &port, string queues)
7614+
void PortsOrch::removePortBufferQueueCounters(const Port &port, string queues, bool skip_host_tx_queue)
75857615
{
75867616
SWSS_LOG_ENTER();
75877617

@@ -7597,6 +7627,11 @@ void PortsOrch::removePortBufferQueueCounters(const Port &port, string queues)
75977627

75987628
for (auto queueIndex = startIndex; queueIndex <= endIndex; queueIndex++)
75997629
{
7630+
if (queueIndex == (uint32_t)port.m_host_tx_queue && skip_host_tx_queue)
7631+
{
7632+
continue;
7633+
}
7634+
76007635
std::ostringstream name;
76017636
name << port.m_alias << ":" << queueIndex;
76027637
const auto id = sai_serialize_object_id(port.m_queue_ids[queueIndex]);

orchagent/portsorch.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,8 @@ class PortsOrch : public Orch, public Subject
184184

185185
void generateQueueMap(map<string, FlexCounterQueueStates> queuesStateVector);
186186
uint32_t getNumberOfPortSupportedQueueCounters(string port);
187-
void createPortBufferQueueCounters(const Port &port, string queues);
188-
void removePortBufferQueueCounters(const Port &port, string queues);
187+
void createPortBufferQueueCounters(const Port &port, string queues, bool skip_host_tx_queue=true);
188+
void removePortBufferQueueCounters(const Port &port, string queues, bool skip_host_tx_queue=true);
189189
void addQueueFlexCounters(map<string, FlexCounterQueueStates> queuesStateVector);
190190
void addQueueWatermarkFlexCounters(map<string, FlexCounterQueueStates> queuesStateVector);
191191

0 commit comments

Comments
 (0)