diff --git a/config/plugins/sonic-trimming.py b/config/plugins/sonic-trimming.py index 91e029653e..55444f5d8b 100644 --- a/config/plugins/sonic-trimming.py +++ b/config/plugins/sonic-trimming.py @@ -10,12 +10,20 @@ CFG_SWITCH_TRIMMING, STATE_SWITCH_CAPABILITY, STATE_CAP_TRIMMING_CAPABLE_KEY, + STATE_CAP_DSCP_MODE_KEY, + STATE_CAP_DSCP_MODE_DSCP_VALUE, + STATE_CAP_DSCP_MODE_FROM_TC, STATE_CAP_QUEUE_MODE_KEY, STATE_CAP_QUEUE_MODE_DYNAMIC, STATE_CAP_QUEUE_MODE_STATIC, + STATE_CAP_TC_NUM_KEY, + STATE_CAP_QUEUE_NUM_KEY, + CFG_TRIM_DSCP_VALUE_FROM_TC, CFG_TRIM_QUEUE_INDEX_DYNAMIC, CFG_TRIM_KEY, STATE_CAP_KEY, + DSCP_MIN, + DSCP_MAX, UINT32_MAX, UINT8_MAX, SYSLOG_IDENTIFIER, @@ -32,6 +40,14 @@ # Validators ---------------------------------------------------------------------------------------------------------- # +def generic_validator(ctx, db): + """ Generic configuration validator """ + entry = db.get_all(db.STATE_DB, "{}|{}".format(STATE_SWITCH_CAPABILITY, STATE_CAP_KEY)) + value = entry.get(STATE_CAP_TRIMMING_CAPABLE_KEY, "false") + + if value != "true": + ctx.fail("Failed to configure switch trimming: operation is not supported") + class SizeTypeValidator(click.ParamType): """ Size option validator """ @@ -44,10 +60,68 @@ def convert(self, value, param, ctx): class DscpTypeValidator(click.ParamType): """ Dscp option validator """ + name = "text" + + def get_metavar(self, param): + db = get_db(click.get_current_context()) + + entry = db.get_all(db.STATE_DB, "{}|{}".format(STATE_SWITCH_CAPABILITY, STATE_CAP_KEY)) + entry.setdefault(STATE_CAP_DSCP_MODE_KEY, "N/A") + + cap_list = entry[STATE_CAP_DSCP_MODE_KEY].split(',') + + if cap_list.count(STATE_CAP_DSCP_MODE_FROM_TC) == len(cap_list): + return "from-tc" + elif cap_list.count(STATE_CAP_DSCP_MODE_DSCP_VALUE) == len(cap_list): + return "INTEGER" + + return "[INTEGER|from-tc]" + + def convert(self, value, param, ctx): + db = get_db(ctx) + + entry = db.get_all(db.STATE_DB, "{}|{}".format(STATE_SWITCH_CAPABILITY, STATE_CAP_KEY)) + entry.setdefault(STATE_CAP_DSCP_MODE_KEY, "N/A") + + if not entry[STATE_CAP_DSCP_MODE_KEY]: + raise click.UsageError("Failed to configure {}: no dscp resolution mode capabilities".format( + param.get_error_hint(ctx)), ctx + ) + + verify_cap = True + + if entry[STATE_CAP_DSCP_MODE_KEY] == "N/A": + verify_cap = False + + cap_list = entry[STATE_CAP_DSCP_MODE_KEY].split(',') + + if value == CFG_TRIM_DSCP_VALUE_FROM_TC: + if verify_cap and (STATE_CAP_DSCP_MODE_FROM_TC not in cap_list): + self.fail("asymmetric dscp resolution mode is not supported", param, ctx) + else: + if verify_cap and (STATE_CAP_DSCP_MODE_DSCP_VALUE not in cap_list): + self.fail("symmetric dscp resolution mode is not supported", param, ctx) + + click.IntRange(DSCP_MIN, DSCP_MAX).convert(value, param, ctx) + + return value + + +class TcTypeValidator(click.ParamType): + """ Tc option validator """ name = "integer" def convert(self, value, param, ctx): - click.IntRange(0, UINT8_MAX).convert(value, param, ctx) + db = get_db(ctx) + + entry = db.get_all(db.STATE_DB, "{}|{}".format(STATE_SWITCH_CAPABILITY, STATE_CAP_KEY)) + entry.setdefault(STATE_CAP_TC_NUM_KEY, "N/A") + + if entry[STATE_CAP_TC_NUM_KEY] == "N/A": + click.IntRange(0, UINT8_MAX).convert(value, param, ctx) + else: + click.IntRange(0, int(entry[STATE_CAP_TC_NUM_KEY])-1).convert(value, param, ctx) + return value @@ -74,14 +148,8 @@ def convert(self, value, param, ctx): db = get_db(ctx) entry = db.get_all(db.STATE_DB, "{}|{}".format(STATE_SWITCH_CAPABILITY, STATE_CAP_KEY)) - - entry.setdefault(STATE_CAP_TRIMMING_CAPABLE_KEY, "false") entry.setdefault(STATE_CAP_QUEUE_MODE_KEY, "N/A") - - if entry[STATE_CAP_TRIMMING_CAPABLE_KEY] == "false": - raise click.UsageError("Failed to configure {}: operation is not supported".format( - param.get_error_hint(ctx)), ctx - ) + entry.setdefault(STATE_CAP_QUEUE_NUM_KEY, "N/A") if not entry[STATE_CAP_QUEUE_MODE_KEY]: raise click.UsageError("Failed to configure {}: no queue resolution mode capabilities".format( @@ -102,7 +170,10 @@ def convert(self, value, param, ctx): if verify_cap and (STATE_CAP_QUEUE_MODE_STATIC not in cap_list): self.fail("static queue resolution mode is not supported", param, ctx) - click.IntRange(0, UINT8_MAX).convert(value, param, ctx) + if entry[STATE_CAP_QUEUE_NUM_KEY] == "N/A": + click.IntRange(0, UINT8_MAX).convert(value, param, ctx) + else: + click.IntRange(0, int(entry[STATE_CAP_QUEUE_NUM_KEY])-1).convert(value, param, ctx) return value @@ -176,33 +247,41 @@ def SWITCH_TRIMMING(): @click.option( "-s", "--size", "size", help="Configures size (in bytes) to trim eligible packet", - type=SizeTypeValidator(), + type=SizeTypeValidator() ) @click.option( "-d", "--dscp", "dscp", help="Configures DSCP value assigned to a packet after trimming", - type=DscpTypeValidator(), + type=DscpTypeValidator() +) +@click.option( + "-t", "--tc", "tc", + help="Configures TC value assigned to a packet after trimming", + type=TcTypeValidator() ) @click.option( "-q", "--queue", "queue", help="Configures queue index to use for transmission of a packet after trimming", - type=QueueTypeValidator(), + type=QueueTypeValidator() ) @clicommon.pass_db @click.pass_context -def SWITCH_TRIMMING_GLOBAL(ctx, db, size, dscp, queue): +def SWITCH_TRIMMING_GLOBAL(ctx, db, size, dscp, tc, queue): """ Configure switch trimming global """ - if not (size or dscp or queue): + if not (size or dscp or tc or queue): raise click.UsageError("Failed to configure switch trimming global: no options are provided", ctx) + generic_validator(ctx, db.db) + table = CFG_SWITCH_TRIMMING key = CFG_TRIM_KEY data = { "size": size, "dscp_value": dscp, - "queue_index": queue, + "tc_value": tc, + "queue_index": queue } try: diff --git a/doc/Command-Reference.md b/doc/Command-Reference.md index 19be9bef7e..467d6448cf 100644 --- a/doc/Command-Reference.md +++ b/doc/Command-Reference.md @@ -9163,19 +9163,22 @@ This command displays switch trimming global configuration. ```bash admin@sonic:~$ show switch-trimming global +-----------------------------+---------+ - | Configuration | Value | + | Configuration | Value | +=============================+=========+ - | Packet trimming size | 200 | + | Packet trimming size | 200 | +-----------------------------+---------+ - | Packet trimming DSCP value | 20 | + | Packet trimming DSCP value | 20 | +-----------------------------+---------+ - | Packet trimming queue index | 2 | + | Packet trimming TC value | N/A | + +-----------------------------+---------+ + | Packet trimming queue index | 2 | +-----------------------------+---------+ admin@sonic:~$ show switch-trimming global --json { "size": "200", "dscp_value": "20", + "tc_value": "N/A", "queue_index": "2" } ``` @@ -9196,22 +9199,21 @@ This command is used to manage switch trimming global configuration. - Options: - _-s,--size_: size (in bytes) to trim eligible packet - _-d,--dscp_: dscp value assigned to a packet after trimming + - _-t,--tc_: tc value assigned to a packet after trimming - _-q,--queue_: queue index to use for transmission of a packet after trimming - Examples: ```bash - admin@sonic:~$ config switch-trimming global \ - --size '128' \ - --dscp '48' \ - --queue '6' + admin@sonic:~$ config switch-trimming global --size '128' --dscp '48' --queue '6' + admin@sonic:~$ config switch-trimming global --size '128' --dscp '48' --queue 'dynamic' + admin@sonic:~$ config switch-trimming global --size '128' --dscp 'from-tc' --tc '6' --queue '6' + admin@sonic:~$ config switch-trimming global --size '128' --dscp 'from-tc' --tc '6' --queue 'dynamic' ``` - Note: - At least one option must be provided + - When `--dscp` value is set to `from-tc`, the `--tc` value is used for mapping to DSCP - When `--queue` value is set to `dynamic`, the `--dscp` value is used for mapping to the queue - ```bash - admin@sonic:~$ config switch-trimming global --queue dynamic - ``` Go Back To [Beginning of the document](#) or [Beginning of this section](#packet-trimming) diff --git a/show/plugins/sonic-trimming.py b/show/plugins/sonic-trimming.py index f0fff9be1b..c6c1964670 100644 --- a/show/plugins/sonic-trimming.py +++ b/show/plugins/sonic-trimming.py @@ -9,7 +9,7 @@ from utilities_common.switch_trimming import ( CFG_SWITCH_TRIMMING, - CFG_TRIM_KEY + CFG_TRIM_KEY, ) @@ -81,6 +81,7 @@ def SWITCH_TRIMMING_GLOBAL(ctx, db, json_format): json_dict = { "size": entry.get("size", "N/A"), "dscp_value": entry.get("dscp_value", "N/A"), + "tc_value": entry.get("tc_value", "N/A"), "queue_index": entry.get("queue_index", "N/A") } click.echo(json.dumps(json_dict, indent=4)) @@ -110,6 +111,18 @@ def SWITCH_TRIMMING_GLOBAL(ctx, db, json_format): ] body.append(row) + row = [ + "Packet trimming TC value", + format_attr_value( + entry, + { + 'name': 'tc_value', + 'is-leaf-list': False + } + ) + ] + body.append(row) + row = [ "Packet trimming queue index", format_attr_value( diff --git a/tests/trimming_input/assert_show_output.py b/tests/trimming_input/assert_show_output.py index de58b5b0d0..66f0461ee8 100644 --- a/tests/trimming_input/assert_show_output.py +++ b/tests/trimming_input/assert_show_output.py @@ -14,6 +14,8 @@ +-----------------------------+---------+ | Packet trimming DSCP value | 20 | +-----------------------------+---------+ +| Packet trimming TC value | N/A | ++-----------------------------+---------+ | Packet trimming queue index | N/A | +-----------------------------+---------+ """ @@ -21,25 +23,29 @@ { "size": "200", "dscp_value": "20", + "tc_value": "N/A", "queue_index": "N/A" } """ -show_trim_queue_static = """\ +show_trim_dscp_asymmetric = """\ +-----------------------------+---------+ -| Configuration | Value | +| Configuration | Value | +=============================+=========+ -| Packet trimming size | 200 | +| Packet trimming size | 200 | +-----------------------------+---------+ -| Packet trimming DSCP value | 20 | +| Packet trimming DSCP value | from-tc | +-----------------------------+---------+ -| Packet trimming queue index | 2 | +| Packet trimming TC value | 2 | ++-----------------------------+---------+ +| Packet trimming queue index | 2 | +-----------------------------+---------+ """ -show_trim_queue_static_json = """\ +show_trim_dscp_asymmetric_json = """\ { "size": "200", - "dscp_value": "20", + "dscp_value": "from-tc", + "tc_value": "2", "queue_index": "2" } """ @@ -52,6 +58,8 @@ +-----------------------------+---------+ | Packet trimming DSCP value | 20 | +-----------------------------+---------+ +| Packet trimming TC value | N/A | ++-----------------------------+---------+ | Packet trimming queue index | dynamic | +-----------------------------+---------+ """ @@ -59,6 +67,7 @@ { "size": "200", "dscp_value": "20", + "tc_value": "N/A", "queue_index": "dynamic" } """ diff --git a/tests/trimming_input/mock_config/queue_static.json b/tests/trimming_input/mock_config/dscp_asymmetric.json similarity index 61% rename from tests/trimming_input/mock_config/queue_static.json rename to tests/trimming_input/mock_config/dscp_asymmetric.json index 58ae476c57..deba9ff852 100644 --- a/tests/trimming_input/mock_config/queue_static.json +++ b/tests/trimming_input/mock_config/dscp_asymmetric.json @@ -1,7 +1,8 @@ { "SWITCH_TRIMMING|GLOBAL": { "size": "200", - "dscp_value": "20", + "dscp_value": "from-tc", + "tc_value": "2", "queue_index": "2" } } diff --git a/tests/trimming_input/mock_state/all.json b/tests/trimming_input/mock_state/all.json index 2d77c510fe..11cd1f78a1 100644 --- a/tests/trimming_input/mock_state/all.json +++ b/tests/trimming_input/mock_state/all.json @@ -1,6 +1,9 @@ { "SWITCH_CAPABILITY|switch": { "SWITCH_TRIMMING_CAPABLE": "true", - "SWITCH|PACKET_TRIMMING_QUEUE_RESOLUTION_MODE": "STATIC,DYNAMIC" + "SWITCH|PACKET_TRIMMING_DSCP_RESOLUTION_MODE": "DSCP_VALUE,FROM_TC", + "SWITCH|PACKET_TRIMMING_QUEUE_RESOLUTION_MODE": "STATIC,DYNAMIC", + "SWITCH|NUMBER_OF_TRAFFIC_CLASSES": "16", + "SWITCH|NUMBER_OF_UNICAST_QUEUES": "8" } } diff --git a/tests/trimming_input/mock_state/dscp_asymmetric.json b/tests/trimming_input/mock_state/dscp_asymmetric.json new file mode 100644 index 0000000000..63d2b1d7cc --- /dev/null +++ b/tests/trimming_input/mock_state/dscp_asymmetric.json @@ -0,0 +1,9 @@ +{ + "SWITCH_CAPABILITY|switch": { + "SWITCH_TRIMMING_CAPABLE": "true", + "SWITCH|PACKET_TRIMMING_DSCP_RESOLUTION_MODE": "FROM_TC", + "SWITCH|PACKET_TRIMMING_QUEUE_RESOLUTION_MODE": "STATIC,DYNAMIC", + "SWITCH|NUMBER_OF_TRAFFIC_CLASSES": "16", + "SWITCH|NUMBER_OF_UNICAST_QUEUES": "8" + } +} diff --git a/tests/trimming_input/mock_state/dscp_symmetric.json b/tests/trimming_input/mock_state/dscp_symmetric.json new file mode 100644 index 0000000000..8dc0b91ec2 --- /dev/null +++ b/tests/trimming_input/mock_state/dscp_symmetric.json @@ -0,0 +1,9 @@ +{ + "SWITCH_CAPABILITY|switch": { + "SWITCH_TRIMMING_CAPABLE": "true", + "SWITCH|PACKET_TRIMMING_DSCP_RESOLUTION_MODE": "DSCP_VALUE", + "SWITCH|PACKET_TRIMMING_QUEUE_RESOLUTION_MODE": "STATIC,DYNAMIC", + "SWITCH|NUMBER_OF_TRAFFIC_CLASSES": "16", + "SWITCH|NUMBER_OF_UNICAST_QUEUES": "8" + } +} diff --git a/tests/trimming_input/mock_state/no_capabilities.json b/tests/trimming_input/mock_state/no_capabilities.json index a3e92a9639..ee12a70d93 100644 --- a/tests/trimming_input/mock_state/no_capabilities.json +++ b/tests/trimming_input/mock_state/no_capabilities.json @@ -1,6 +1,9 @@ { "SWITCH_CAPABILITY|switch": { "SWITCH_TRIMMING_CAPABLE": "true", - "SWITCH|PACKET_TRIMMING_QUEUE_RESOLUTION_MODE": "" + "SWITCH|PACKET_TRIMMING_DSCP_RESOLUTION_MODE": "", + "SWITCH|PACKET_TRIMMING_QUEUE_RESOLUTION_MODE": "", + "SWITCH|NUMBER_OF_TRAFFIC_CLASSES": "N/A", + "SWITCH|NUMBER_OF_UNICAST_QUEUES": "N/A" } } diff --git a/tests/trimming_input/mock_state/not_supported.json b/tests/trimming_input/mock_state/not_supported.json index f92c451a44..e45d204fa8 100644 --- a/tests/trimming_input/mock_state/not_supported.json +++ b/tests/trimming_input/mock_state/not_supported.json @@ -1,6 +1,9 @@ { "SWITCH_CAPABILITY|switch": { "SWITCH_TRIMMING_CAPABLE": "false", - "SWITCH|PACKET_TRIMMING_QUEUE_RESOLUTION_MODE": "" + "SWITCH|PACKET_TRIMMING_DSCP_RESOLUTION_MODE": "", + "SWITCH|PACKET_TRIMMING_QUEUE_RESOLUTION_MODE": "", + "SWITCH|NUMBER_OF_TRAFFIC_CLASSES": "N/A", + "SWITCH|NUMBER_OF_UNICAST_QUEUES": "N/A" } } diff --git a/tests/trimming_input/mock_state/queue_dynamic.json b/tests/trimming_input/mock_state/queue_dynamic.json index aa4a704bc6..eaec50ea3e 100644 --- a/tests/trimming_input/mock_state/queue_dynamic.json +++ b/tests/trimming_input/mock_state/queue_dynamic.json @@ -1,6 +1,9 @@ { "SWITCH_CAPABILITY|switch": { "SWITCH_TRIMMING_CAPABLE": "true", - "SWITCH|PACKET_TRIMMING_QUEUE_RESOLUTION_MODE": "DYNAMIC" + "SWITCH|PACKET_TRIMMING_DSCP_RESOLUTION_MODE": "DSCP_VALUE,FROM_TC", + "SWITCH|PACKET_TRIMMING_QUEUE_RESOLUTION_MODE": "DYNAMIC", + "SWITCH|NUMBER_OF_TRAFFIC_CLASSES": "16", + "SWITCH|NUMBER_OF_UNICAST_QUEUES": "8" } } diff --git a/tests/trimming_input/mock_state/queue_static.json b/tests/trimming_input/mock_state/queue_static.json index f103608fa1..e2b79161e5 100644 --- a/tests/trimming_input/mock_state/queue_static.json +++ b/tests/trimming_input/mock_state/queue_static.json @@ -1,6 +1,9 @@ { "SWITCH_CAPABILITY|switch": { "SWITCH_TRIMMING_CAPABLE": "true", - "SWITCH|PACKET_TRIMMING_QUEUE_RESOLUTION_MODE": "STATIC" + "SWITCH|PACKET_TRIMMING_DSCP_RESOLUTION_MODE": "DSCP_VALUE,FROM_TC", + "SWITCH|PACKET_TRIMMING_QUEUE_RESOLUTION_MODE": "STATIC", + "SWITCH|NUMBER_OF_TRAFFIC_CLASSES": "16", + "SWITCH|NUMBER_OF_UNICAST_QUEUES": "8" } } diff --git a/tests/trimming_test.py b/tests/trimming_test.py index 11c2741872..a3ec88f1d2 100644 --- a/tests/trimming_test.py +++ b/tests/trimming_test.py @@ -38,24 +38,36 @@ def teardown_class(cls): # ---------- CONFIG CONFIG SWITCH-TRIMMING GLOBAL ---------- # @pytest.mark.parametrize( - "size,dscp,queue", [ + "size,dscp,tc,queue", [ pytest.param( - "200", "20", "2", + "200", "20", None, "2", + id="dscp-symmetric" + ), + pytest.param( + "200", "from-tc", "2", "2", + id="dscp-asymmetric" + ), + pytest.param( + "200", "20", None, "2", id="queue-static" ), pytest.param( - "300", "30", "dynamic", + "200", "20", None, "dynamic", id="queue-dynamic" ) ] ) - def test_config_trimming(self, size, dscp, queue): + def test_config_trimming(self, size, dscp, tc, queue): db = Db() runner = CliRunner() + args = ["--size", size, "--dscp", dscp, "--queue", queue] + if tc is not None: + args.extend(["--tc", tc]) + result = runner.invoke( config.config.commands["switch-trimming"].commands["global"], - ["--size", size, "--dscp", dscp, "--queue", queue], obj=db + args, obj=db ) logger.debug("\n" + result.output) @@ -77,12 +89,30 @@ def test_config_trimming(self, size, dscp, queue): "is not in the valid range of", id="dscp-out-of-bound" ), + pytest.param( + os.path.join(mock_state_path, "all"), + ["--tc", "-1"], + "is not in the valid range of", + id="tc-out-of-bound" + ), pytest.param( os.path.join(mock_state_path, "all"), ["--queue", "-1"], "is not in the valid range of", id="queue-out-of-bound" ), + pytest.param( + os.path.join(mock_state_path, "dscp_symmetric"), + ["--dscp", "from-tc"], + "asymmetric dscp resolution mode is not supported", + id="dscp-symmetric-only" + ), + pytest.param( + os.path.join(mock_state_path, "dscp_asymmetric"), + ["--dscp", "20"], + "symmetric dscp resolution mode is not supported", + id="dscp-asymmetric-only" + ), pytest.param( os.path.join(mock_state_path, "queue_static"), ["--queue", "dynamic"], @@ -95,17 +125,29 @@ def test_config_trimming(self, size, dscp, queue): "static queue resolution mode is not supported", id="queue-dynamic-only" ), + pytest.param( + os.path.join(mock_state_path, "no_capabilities"), + ["--dscp", "from-tc"], + "no dscp resolution mode capabilities", + id="no-dscp-capabilities" + ), pytest.param( os.path.join(mock_state_path, "no_capabilities"), ["--queue", "dynamic"], "no queue resolution mode capabilities", - id="no-capabilities" + id="no-queue-capabilities" ), pytest.param( os.path.join(mock_state_path, "not_supported"), - ["--queue", "2"], + ["--size", "200"], "operation is not supported", id="not-supported" + ), + pytest.param( + os.path.join(mock_state_path, "not_supported"), + [], + "no options are provided", + id="no-options" ) ] ) @@ -128,6 +170,57 @@ def test_config_trimming_neg(self, statedb, option, pattern): # ---------- SHOW SWITCH-TRIMMING GLOBAL ---------- # + @pytest.mark.parametrize( + "statedb,pattern", [ + pytest.param( + os.path.join(mock_state_path, "dscp_asymmetric"), + "-d, --dscp from-tc", + id="dscp-asymmetric-only" + ), + pytest.param( + os.path.join(mock_state_path, "dscp_symmetric"), + "-d, --dscp INTEGER", + id="dscp-symmetric-only" + ), + pytest.param( + os.path.join(mock_state_path, "all"), + "-d, --dscp [INTEGER|from-tc]", + id="dscp-asymmetric-and-symmetric" + ), + pytest.param( + os.path.join(mock_state_path, "queue_dynamic"), + "-q, --queue dynamic", + id="queue-dynamic-only" + ), + pytest.param( + os.path.join(mock_state_path, "queue_static"), + "-q, --queue INTEGER", + id="queue-static-only" + ), + pytest.param( + os.path.join(mock_state_path, "all"), + "-q, --queue [INTEGER|dynamic]", + id="queue-dynamic-and-static" + ) + ] + ) + def test_show_trimming_meta(self, statedb, pattern): + dbconnector.dedicated_dbs["STATE_DB"] = statedb + + db = Db() + runner = CliRunner() + + result = runner.invoke( + config.config.commands["switch-trimming"].commands["global"], + ["--help"], obj=db + ) + + logger.debug("\n" + result.output) + logger.debug(result.exit_code) + + assert pattern in result.output + assert result.exit_code == SUCCESS + @pytest.mark.parametrize( "cfgdb,output", [ pytest.param( @@ -147,12 +240,12 @@ def test_config_trimming_neg(self, statedb, option, pattern): id="partial" ), pytest.param( - os.path.join(mock_config_path, "queue_static"), + os.path.join(mock_config_path, "dscp_asymmetric"), { - "plain": assert_show_output.show_trim_queue_static, - "json": assert_show_output.show_trim_queue_static_json + "plain": assert_show_output.show_trim_dscp_asymmetric, + "json": assert_show_output.show_trim_dscp_asymmetric_json }, - id="queue-static" + id="dscp-asymmetric" ), pytest.param( os.path.join(mock_config_path, "queue_dynamic"), diff --git a/utilities_common/switch_trimming.py b/utilities_common/switch_trimming.py index 761969b7c8..f80ce8ab0a 100644 --- a/utilities_common/switch_trimming.py +++ b/utilities_common/switch_trimming.py @@ -8,18 +8,27 @@ # Constants ----------------------------------------------------------------------------------------------------------- # - STATE_CAP_TRIMMING_CAPABLE_KEY = "SWITCH_TRIMMING_CAPABLE" +STATE_CAP_DSCP_MODE_KEY = "SWITCH|PACKET_TRIMMING_DSCP_RESOLUTION_MODE" STATE_CAP_QUEUE_MODE_KEY = "SWITCH|PACKET_TRIMMING_QUEUE_RESOLUTION_MODE" +STATE_CAP_TC_NUM_KEY = "SWITCH|NUMBER_OF_TRAFFIC_CLASSES" +STATE_CAP_QUEUE_NUM_KEY = "SWITCH|NUMBER_OF_UNICAST_QUEUES" + +STATE_CAP_DSCP_MODE_DSCP_VALUE = "DSCP_VALUE" +STATE_CAP_DSCP_MODE_FROM_TC = "FROM_TC" STATE_CAP_QUEUE_MODE_DYNAMIC = "DYNAMIC" STATE_CAP_QUEUE_MODE_STATIC = "STATIC" +CFG_TRIM_DSCP_VALUE_FROM_TC = "from-tc" CFG_TRIM_QUEUE_INDEX_DYNAMIC = "dynamic" CFG_TRIM_KEY = "GLOBAL" STATE_CAP_KEY = "switch" +DSCP_MIN = 0 +DSCP_MAX = 63 + UINT32_MAX = 4294967295 UINT8_MAX = 255 @@ -30,7 +39,6 @@ # Helpers ------------------------------------------------------------------------------------------------------------- # - def get_db(ctx): """ Get DB object """ return ctx.find_object(db.Db).db