From 04f84fc4297d9b3c0e602c76be2cad282fe48fb0 Mon Sep 17 00:00:00 2001 From: prabhataravind <108555774+prabhataravind@users.noreply.github.com> Date: Thu, 20 Apr 2023 14:33:48 -0700 Subject: [PATCH] [portsorch]: Set default hostif TX queue (#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 --- orchagent/portsorch.cpp | 37 +++++++++++++++++++++++++++++++++++++ tests/dvslib/dvs_vlan.py | 1 + tests/test_port.py | 11 +++++++++++ 3 files changed, 49 insertions(+) diff --git a/orchagent/portsorch.cpp b/orchagent/portsorch.cpp index 81108593e7b0..dffb935d784f 100755 --- a/orchagent/portsorch.cpp +++ b/orchagent/portsorch.cpp @@ -30,6 +30,7 @@ #include "countercheckorch.h" #include "notifier.h" #include "fdborch.h" +#include "switchorch.h" #include "stringutility.h" #include "subscriberstatetable.h" @@ -49,6 +50,7 @@ extern NeighOrch *gNeighOrch; extern CrmOrch *gCrmOrch; extern BufferOrch *gBufferOrch; extern FdbOrch *gFdbOrch; +extern SwitchOrch *gSwitchOrch; extern Directory gDirectory; extern sai_system_port_api_t *sai_system_port_api; extern string gMySwitchType; @@ -61,6 +63,7 @@ extern event_handle_t g_events_handle; #define VLAN_PREFIX "Vlan" #define DEFAULT_VLAN_ID 1 #define MAX_VALID_VLAN_ID 4094 +#define DEFAULT_HOSTIF_TX_QUEUE 7 #define PORT_SPEED_LIST_DEFAULT_SIZE 16 #define PORT_STATE_POLLING_SEC 5 @@ -2599,6 +2602,23 @@ bool PortsOrch::createVlanHostIntf(Port& vl, string hostif_name) attr.value.chardata[SAI_HOSTIF_NAME_SIZE - 1] = '\0'; attrs.push_back(attr); + bool set_hostif_tx_queue = false; + if (gSwitchOrch->querySwitchCapability(SAI_OBJECT_TYPE_HOSTIF, SAI_HOSTIF_ATTR_QUEUE)) + { + set_hostif_tx_queue = true; + } + else + { + SWSS_LOG_WARN("Hostif queue attribute not supported"); + } + + if (set_hostif_tx_queue) + { + attr.id = SAI_HOSTIF_ATTR_QUEUE; + attr.value.u32 = DEFAULT_HOSTIF_TX_QUEUE; + attrs.push_back(attr); + } + sai_status_t status = sai_hostif_api->create_hostif(&vl.m_vlan_info.host_intf_id, gSwitchId, (uint32_t)attrs.size(), attrs.data()); if (status != SAI_STATUS_SUCCESS) { @@ -4842,6 +4862,23 @@ bool PortsOrch::addHostIntfs(Port &port, string alias, sai_object_id_t &host_int attr.value.chardata[SAI_HOSTIF_NAME_SIZE - 1] = '\0'; attrs.push_back(attr); + bool set_hostif_tx_queue = false; + if (gSwitchOrch->querySwitchCapability(SAI_OBJECT_TYPE_HOSTIF, SAI_HOSTIF_ATTR_QUEUE)) + { + set_hostif_tx_queue = true; + } + else + { + SWSS_LOG_WARN("Hostif queue attribute not supported"); + } + + if (set_hostif_tx_queue) + { + attr.id = SAI_HOSTIF_ATTR_QUEUE; + attr.value.u32 = DEFAULT_HOSTIF_TX_QUEUE; + attrs.push_back(attr); + } + sai_status_t status = sai_hostif_api->create_hostif(&host_intfs_id, gSwitchId, (uint32_t)attrs.size(), attrs.data()); if (status != SAI_STATUS_SUCCESS) { diff --git a/tests/dvslib/dvs_vlan.py b/tests/dvslib/dvs_vlan.py index 79bfbdc3c047..418f3be6661e 100644 --- a/tests/dvslib/dvs_vlan.py +++ b/tests/dvslib/dvs_vlan.py @@ -106,6 +106,7 @@ def verify_vlan_hostif(self, hostif_name, hostifs_oid, vlan_oid): assert hostif.get("SAI_HOSTIF_ATTR_TYPE") == "SAI_HOSTIF_TYPE_NETDEV" assert hostif.get("SAI_HOSTIF_ATTR_OBJ_ID") == vlan_oid assert hostif.get("SAI_HOSTIF_ATTR_NAME") == hostif_name + assert hostif.get("SAI_HOSTIF_ATTR_QUEUE") == "7" def get_and_verify_vlan_hostif_ids(self, expected_num, polling_config=PollingConfig()): hostif_entries = self.asic_db.wait_for_n_keys("ASIC_STATE:SAI_OBJECT_TYPE_HOSTIF", diff --git a/tests/test_port.py b/tests/test_port.py index c63dae5c57d1..c880a88c5a3d 100644 --- a/tests/test_port.py +++ b/tests/test_port.py @@ -277,6 +277,17 @@ def test_PortIpredriver(self, dvs, testlog): if fv[0] == "SAI_PORT_ATTR_SERDES_IPREDRIVER": assert fv[1] == ipre_val_asic + def test_PortHostif(self, dvs): + adb = swsscommon.DBConnector(1, dvs.redis_sock, 0) + atbl = swsscommon.Table(adb, "ASIC_STATE:SAI_OBJECT_TYPE_HOSTIF") + host_intfs = atbl.getKeys() + for intf in host_intfs: + status, fvs = atbl.get(intf) + assert status, "Error getting value for key" + attributes = dict(fvs) + hostif_queue = attributes.get("SAI_HOSTIF_ATTR_QUEUE") + assert hostif_queue == "7" + # Add Dummy always-pass test at end as workaroud # for issue when Flaky fail on final test it invokes module tear-down before retrying