Skip to content

Commit 04f84fc

Browse files
[portsorch]: Set default hostif TX queue (sonic-net#2697)
* [portsorch]: Set default hostif TX queue * To avoid data and control packets sharing the same TX queue and possibly leading to control packet losses, pin control traffic to queue 7 by default. * Use querySwitchCapability from SwitchOrch to check if SAI_HOSTIF_ATTR_QUEUE is supported * Add a vstest Signed-off-by: Prabhat Aravind <[email protected]>
1 parent 5bedf4e commit 04f84fc

File tree

3 files changed

+49
-0
lines changed

3 files changed

+49
-0
lines changed

orchagent/portsorch.cpp

+37
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "countercheckorch.h"
3131
#include "notifier.h"
3232
#include "fdborch.h"
33+
#include "switchorch.h"
3334
#include "stringutility.h"
3435
#include "subscriberstatetable.h"
3536

@@ -49,6 +50,7 @@ extern NeighOrch *gNeighOrch;
4950
extern CrmOrch *gCrmOrch;
5051
extern BufferOrch *gBufferOrch;
5152
extern FdbOrch *gFdbOrch;
53+
extern SwitchOrch *gSwitchOrch;
5254
extern Directory<Orch*> gDirectory;
5355
extern sai_system_port_api_t *sai_system_port_api;
5456
extern string gMySwitchType;
@@ -61,6 +63,7 @@ extern event_handle_t g_events_handle;
6163
#define VLAN_PREFIX "Vlan"
6264
#define DEFAULT_VLAN_ID 1
6365
#define MAX_VALID_VLAN_ID 4094
66+
#define DEFAULT_HOSTIF_TX_QUEUE 7
6467

6568
#define PORT_SPEED_LIST_DEFAULT_SIZE 16
6669
#define PORT_STATE_POLLING_SEC 5
@@ -2599,6 +2602,23 @@ bool PortsOrch::createVlanHostIntf(Port& vl, string hostif_name)
25992602
attr.value.chardata[SAI_HOSTIF_NAME_SIZE - 1] = '\0';
26002603
attrs.push_back(attr);
26012604

2605+
bool set_hostif_tx_queue = false;
2606+
if (gSwitchOrch->querySwitchCapability(SAI_OBJECT_TYPE_HOSTIF, SAI_HOSTIF_ATTR_QUEUE))
2607+
{
2608+
set_hostif_tx_queue = true;
2609+
}
2610+
else
2611+
{
2612+
SWSS_LOG_WARN("Hostif queue attribute not supported");
2613+
}
2614+
2615+
if (set_hostif_tx_queue)
2616+
{
2617+
attr.id = SAI_HOSTIF_ATTR_QUEUE;
2618+
attr.value.u32 = DEFAULT_HOSTIF_TX_QUEUE;
2619+
attrs.push_back(attr);
2620+
}
2621+
26022622
sai_status_t status = sai_hostif_api->create_hostif(&vl.m_vlan_info.host_intf_id, gSwitchId, (uint32_t)attrs.size(), attrs.data());
26032623
if (status != SAI_STATUS_SUCCESS)
26042624
{
@@ -4842,6 +4862,23 @@ bool PortsOrch::addHostIntfs(Port &port, string alias, sai_object_id_t &host_int
48424862
attr.value.chardata[SAI_HOSTIF_NAME_SIZE - 1] = '\0';
48434863
attrs.push_back(attr);
48444864

4865+
bool set_hostif_tx_queue = false;
4866+
if (gSwitchOrch->querySwitchCapability(SAI_OBJECT_TYPE_HOSTIF, SAI_HOSTIF_ATTR_QUEUE))
4867+
{
4868+
set_hostif_tx_queue = true;
4869+
}
4870+
else
4871+
{
4872+
SWSS_LOG_WARN("Hostif queue attribute not supported");
4873+
}
4874+
4875+
if (set_hostif_tx_queue)
4876+
{
4877+
attr.id = SAI_HOSTIF_ATTR_QUEUE;
4878+
attr.value.u32 = DEFAULT_HOSTIF_TX_QUEUE;
4879+
attrs.push_back(attr);
4880+
}
4881+
48454882
sai_status_t status = sai_hostif_api->create_hostif(&host_intfs_id, gSwitchId, (uint32_t)attrs.size(), attrs.data());
48464883
if (status != SAI_STATUS_SUCCESS)
48474884
{

tests/dvslib/dvs_vlan.py

+1
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ def verify_vlan_hostif(self, hostif_name, hostifs_oid, vlan_oid):
106106
assert hostif.get("SAI_HOSTIF_ATTR_TYPE") == "SAI_HOSTIF_TYPE_NETDEV"
107107
assert hostif.get("SAI_HOSTIF_ATTR_OBJ_ID") == vlan_oid
108108
assert hostif.get("SAI_HOSTIF_ATTR_NAME") == hostif_name
109+
assert hostif.get("SAI_HOSTIF_ATTR_QUEUE") == "7"
109110

110111
def get_and_verify_vlan_hostif_ids(self, expected_num, polling_config=PollingConfig()):
111112
hostif_entries = self.asic_db.wait_for_n_keys("ASIC_STATE:SAI_OBJECT_TYPE_HOSTIF",

tests/test_port.py

+11
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,17 @@ def test_PortIpredriver(self, dvs, testlog):
277277
if fv[0] == "SAI_PORT_ATTR_SERDES_IPREDRIVER":
278278
assert fv[1] == ipre_val_asic
279279

280+
def test_PortHostif(self, dvs):
281+
adb = swsscommon.DBConnector(1, dvs.redis_sock, 0)
282+
atbl = swsscommon.Table(adb, "ASIC_STATE:SAI_OBJECT_TYPE_HOSTIF")
283+
host_intfs = atbl.getKeys()
284+
for intf in host_intfs:
285+
status, fvs = atbl.get(intf)
286+
assert status, "Error getting value for key"
287+
attributes = dict(fvs)
288+
hostif_queue = attributes.get("SAI_HOSTIF_ATTR_QUEUE")
289+
assert hostif_queue == "7"
290+
280291

281292
# Add Dummy always-pass test at end as workaroud
282293
# for issue when Flaky fail on final test it invokes module tear-down before retrying

0 commit comments

Comments
 (0)