Repository: sonic-net/sonic-buildimage
Pull request #22252: [Yang model] Support empty string in pfc_enable and pfc_wd_enable fields in PORT_QOS_MAP table
Author: login: stephenxs
Labels: name: Request for msft-202412 Branch
name: Approved for msft-202412 Branch
name: Included in msft-202412 Branch
Created: 2025-04-07T12:47:37Z | Merged: 2025-04-17T21:06:41Z

<!--
     Please make sure you've read and understood our contributing guidelines:
     https://github.com/Azure/SONiC/blob/gh-pages/CONTRIBUTING.md

     ** Make sure all your commits include a signature generated with `git commit -s` **

     If this is a bug fix, make sure your description includes "fixes #xxxx", or
     "closes #xxxx" or "resolves #xxxx"

     Please provide the following information:
-->

#### Why I did it

Support empty string in pfc_enable and pfc_wd_enable fields in PORT_QOS_MAP table to represent "disable PFC ".

##### Work item tracking
- Microsoft ADO **(number only)**:

#### How I did it

#### How to verify it

Unit/manul test

<!--
If PR needs to be backported, then the PR must be tested against the base branch and the earliest backport release branch and provide tested image version on these two branches. For example, if the PR is requested for master, 202211 and 202012, then the requester needs to provide test results on master and 202012.
-->

#### Which release branch to backport (provide reason below if selected)

<!--
- Note we only backport fixes to a release branch, *not* features!
- Please also provide a reason for the backporting below.
- e.g.
- [x] 202006
-->

- [ ] 201811
- [ ] 201911
- [ ] 202006
- [ ] 202012
- [ ] 202106
- [ ] 202111
- [ ] 202205
- [ ] 202211
- [ ] 202305

#### Tested branch (Please provide the tested image version)

<!--
- Please provide tested image version
- e.g.
- [x] 20201231.100
-->

- [ ] <!-- image version 1 -->
- [ ] <!-- image version 2 -->

#### Description for the changelog
<!--
Write a short (one line) summary that describes the changes in this
pull request for inclusion in the changelog:
-->

<!--
 Ensure to add label/tag for the feature raised. example - PR#2174 under sonic-utilities repo. where, Generic Config and Update feature has been labelled as GCU.
-->

#### Link to config_db schema for YANG module changes
<!--
Provide a link to config_db schema for the table for which YANG model
is defined
Link should point to correct section on https://github.com/Azure/sonic-buildimage/blob/master/src/sonic-yang-models/doc/Configuration.md
-->

#### A picture of a cute animal (not mandatory but encouraged)




Diff:
diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/qosmaps.json b/src/sonic-yang-models/tests/yang_model_tests/tests/qosmaps.json
index 2997410384d..68ec71ba3f5 100644
--- a/src/sonic-yang-models/tests/yang_model_tests/tests/qosmaps.json
+++ b/src/sonic-yang-models/tests/yang_model_tests/tests/qosmaps.json
@@ -111,6 +111,14 @@
         "eStrKey": "Pattern"
     },
 
+    "PORT_QOS_MAP_APPLY_EMPTY_PFC": {
+        "desc": "Configure port pfc enable with empty string to disable PFC on all queues."
+    },
+
+    "PORT_QOS_MAP_APPLY_EMPTY_PFCWD": {
+        "desc": "Configure port pfcwd_sw_enable with empty string to disable watchdog on all queues."
+    },
+
     "TC_TO_DSCP_MAP_CRETAE": {
         "desc": "Configure a Traffic class to DSCP map."
     },
diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/qosmaps.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/qosmaps.json
index ee0ba3fe472..3d45fe02b79 100644
--- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/qosmaps.json
+++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/qosmaps.json
@@ -881,6 +881,64 @@
         }
     },
 
+    "PORT_QOS_MAP_APPLY_EMPTY_PFC": {
+        "sonic-port:sonic-port": {
+            "sonic-port:PORT": {
+                "PORT_LIST": [
+                {
+                    "admin_status": "up",
+                    "alias": "eth0",
+                    "description": "Ethernet4",
+                    "lanes": "65",
+                    "mtu": "9000",
+                    "name": "Ethernet4",
+                    "tpid": "0x8100",
+                    "speed": "25000"
+                }
+                ]
+            }
+        },
+        "sonic-port-qos-map:sonic-port-qos-map": {
+            "sonic-port-qos-map:PORT_QOS_MAP": {
+                "PORT_QOS_MAP_LIST": [
+                    {
+                        "ifname": "Ethernet4",
+                        "pfc_enable": ""
+                    }
+                ]
+            }
+        }
+    },
+
+    "PORT_QOS_MAP_APPLY_EMPTY_PFCWD": {
+        "sonic-port:sonic-port": {
+            "sonic-port:PORT": {
+                "PORT_LIST": [
+                {
+                    "admin_status": "up",
+                    "alias": "eth0",
+                    "description": "Ethernet4",
+                    "lanes": "65",
+                    "mtu": "9000",
+                    "name": "Ethernet4",
+                    "tpid": "0x8100",
+                    "speed": "25000"
+                }
+                ]
+            }
+        },
+        "sonic-port-qos-map:sonic-port-qos-map": {
+            "sonic-port-qos-map:PORT_QOS_MAP": {
+                "PORT_QOS_MAP_LIST": [
+                    {
+                        "ifname": "Ethernet4",
+                        "pfcwd_sw_enable": ""
+                    }
+                ]
+            }
+        }
+    },
+
     "TC_TO_DSCP_MAP_CRETAE": {
         "sonic-tc-dscp-map:sonic-tc-dscp-map": {
             "sonic-tc-dscp-map:TC_TO_DSCP_MAP": {
diff --git a/src/sonic-yang-models/yang-models/sonic-port-qos-map.yang b/src/sonic-yang-models/yang-models/sonic-port-qos-map.yang
index f1b725ca889..4040ae1fbac 100644
--- a/src/sonic-yang-models/yang-models/sonic-port-qos-map.yang
+++ b/src/sonic-yang-models/yang-models/sonic-port-qos-map.yang
@@ -91,16 +91,18 @@ module sonic-port-qos-map {
 
                 leaf pfc_enable {
                     type string {
-                        pattern "[0-7](,[0-7])*";
+                        pattern "([0-7](,[0-7])*)?";
                     }
+                    description
+                        "Specify the queue(s) on which PFC is enabled. Empty string is allowed to disable PFC on all queues.";
                 }
 
                 leaf pfcwd_sw_enable {
                     type string {
-                        pattern "[0-7](,[0-7])*";
+                        pattern "([0-7](,[0-7])*)?";
                     }
                     description
-                        "Specify the queue(s) on which software pfc watchdog are enabled.";
+                        "Specify the queue(s) on which software pfc watchdog are enabled. Empty string is allowed to disable watchdog on all queues.";
                 }
 
                 leaf pfc_to_queue_map {


Reviews:
user: login: r12f
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-13T06:51:08Z
user: login: stephenxs
state: COMMENTED
author_association: COLLABORATOR
submitted_at: 2025-04-13T07:03:47Z
user: login: r12f
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-15T18:31:05Z
user: login: r12f
state: APPROVED
author_association: CONTRIBUTOR
submitted_at: 2025-04-15T18:31:09Z
user: login: r12f
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-15T18:32:41Z
user: login: kperumalbfn
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-15T19:35:51Z
user: login: stephenxs
state: COMMENTED
author_association: COLLABORATOR
submitted_at: 2025-04-15T23:26:42Z

Review comments:
diff_hunk: @@ -91,16 +91,18 @@ module sonic-port-qos-map {
 
                 leaf pfc_enable {
                     type string {
-                        pattern "[0-7](,[0-7])*";
+                        pattern "([0-7](,[0-7])*)?";
                     }
+                    description
+                        "Specify the queue(s) on which PFC is enabled. Empty string is allowed to disable PFC on all queues.";
                 }
 
                 leaf pfcwd_sw_enable {
                     type string {
-                        pattern "[0-7](,[0-7])*";
+                        pattern "([0-7](,[0-7])*)?";
                     }
                     description
-                        "Specify the queue(s) on which software pfc watchdog are enabled.";
+                        "Specify the queue(s) on which software pfc watchdog are enabled. Empty string is allowed to disable watchdog on all queues.";
                 }
 
                 leaf pfc_to_queue_map {
path: src/sonic-yang-models/yang-models/sonic-port-qos-map.yang
user: login: r12f
body: Is it possible to also help see if pfc_to_queue and pfc_to_pg map can be ignored too?
created_at: 2025-04-13T06:51:01Z
author_association: CONTRIBUTOR
diff_hunk: @@ -91,16 +91,18 @@ module sonic-port-qos-map {
 
                 leaf pfc_enable {
                     type string {
-                        pattern "[0-7](,[0-7])*";
+                        pattern "([0-7](,[0-7])*)?";
                     }
+                    description
+                        "Specify the queue(s) on which PFC is enabled. Empty string is allowed to disable PFC on all queues.";
                 }
 
                 leaf pfcwd_sw_enable {
                     type string {
-                        pattern "[0-7](,[0-7])*";
+                        pattern "([0-7](,[0-7])*)?";
                     }
                     description
-                        "Specify the queue(s) on which software pfc watchdog are enabled.";
+                        "Specify the queue(s) on which software pfc watchdog are enabled. Empty string is allowed to disable watchdog on all queues.";
                 }
 
                 leaf pfc_to_queue_map {
path: src/sonic-yang-models/yang-models/sonic-port-qos-map.yang
user: login: stephenxs
body: Hi @r12f 
Thanks for the comments 
I do not suggest doing so, because 
1. It suffices to disable PFC on both directions by clearing pfc_enable
2. The ASIC always have PFC to queue and PFC to PG mappings. Not setting them means keeping them as the default. the customer won't understand what the mappings are, which is not good

What do you think?
created_at: 2025-04-13T07:03:47Z
author_association: COLLABORATOR
diff_hunk: @@ -91,16 +91,18 @@ module sonic-port-qos-map {
 
                 leaf pfc_enable {
                     type string {
-                        pattern "[0-7](,[0-7])*";
+                        pattern "([0-7](,[0-7])*)?";
                     }
+                    description
+                        "Specify the queue(s) on which PFC is enabled. Empty string is allowed to disable PFC on all queues.";
                 }
 
                 leaf pfcwd_sw_enable {
                     type string {
-                        pattern "[0-7](,[0-7])*";
+                        pattern "([0-7](,[0-7])*)?";
                     }
                     description
-                        "Specify the queue(s) on which software pfc watchdog are enabled.";
+                        "Specify the queue(s) on which software pfc watchdog are enabled. Empty string is allowed to disable watchdog on all queues.";
                 }
 
                 leaf pfc_to_queue_map {
path: src/sonic-yang-models/yang-models/sonic-port-qos-map.yang
user: login: r12f
body: ah, Stephen, what I mean is to allow the empty list. and looks like it is ok.

created_at: 2025-04-15T18:31:05Z
author_association: CONTRIBUTOR
diff_hunk: @@ -91,16 +91,18 @@ module sonic-port-qos-map {
 
                 leaf pfc_enable {
                     type string {
-                        pattern "[0-7](,[0-7])*";
+                        pattern "([0-7](,[0-7])*)?";
                     }
+                    description
+                        "Specify the queue(s) on which PFC is enabled. Empty string is allowed to disable PFC on all queues.";
                 }
 
                 leaf pfcwd_sw_enable {
                     type string {
-                        pattern "[0-7](,[0-7])*";
+                        pattern "([0-7](,[0-7])*)?";
                     }
                     description
-                        "Specify the queue(s) on which software pfc watchdog are enabled.";
+                        "Specify the queue(s) on which software pfc watchdog are enabled. Empty string is allowed to disable watchdog on all queues.";
                 }
 
                 leaf pfc_to_queue_map {
path: src/sonic-yang-models/yang-models/sonic-port-qos-map.yang
user: login: r12f
body: @kperumalbfn for viz to make sure it matches with our generated policies.
created_at: 2025-04-15T18:32:41Z
author_association: CONTRIBUTOR
diff_hunk: @@ -91,16 +91,18 @@ module sonic-port-qos-map {
 
                 leaf pfc_enable {
                     type string {
-                        pattern "[0-7](,[0-7])*";
+                        pattern "([0-7](,[0-7])*)?";
                     }
+                    description
+                        "Specify the queue(s) on which PFC is enabled. Empty string is allowed to disable PFC on all queues.";
                 }
 
                 leaf pfcwd_sw_enable {
                     type string {
-                        pattern "[0-7](,[0-7])*";
+                        pattern "([0-7](,[0-7])*)?";
                     }
                     description
-                        "Specify the queue(s) on which software pfc watchdog are enabled.";
+                        "Specify the queue(s) on which software pfc watchdog are enabled. Empty string is allowed to disable watchdog on all queues.";
                 }
 
                 leaf pfc_to_queue_map {
path: src/sonic-yang-models/yang-models/sonic-port-qos-map.yang
user: login: kperumalbfn
body: @stephenxs could you also disable PFC in PORT_QOS_MAP SKU specific j2 configs.
created_at: 2025-04-15T19:35:51Z
author_association: CONTRIBUTOR
diff_hunk: @@ -91,16 +91,18 @@ module sonic-port-qos-map {
 
                 leaf pfc_enable {
                     type string {
-                        pattern "[0-7](,[0-7])*";
+                        pattern "([0-7](,[0-7])*)?";
                     }
+                    description
+                        "Specify the queue(s) on which PFC is enabled. Empty string is allowed to disable PFC on all queues.";
                 }
 
                 leaf pfcwd_sw_enable {
                     type string {
-                        pattern "[0-7](,[0-7])*";
+                        pattern "([0-7](,[0-7])*)?";
                     }
                     description
-                        "Specify the queue(s) on which software pfc watchdog are enabled.";
+                        "Specify the queue(s) on which software pfc watchdog are enabled. Empty string is allowed to disable watchdog on all queues.";
                 }
 
                 leaf pfc_to_queue_map {
path: src/sonic-yang-models/yang-models/sonic-port-qos-map.yang
user: login: stephenxs
body: @kperumalbfn 
Already done here by providing [generate_lossless_tc_list](https://github.com/sonic-net/sonic-buildimage/blob/master/device/mellanox/x86_64-nvidia_sn5600-r0/Mellanox-SN5600-C256S1/qos.json.j2#L214) generating empty PFC enable and PFC watchdog enable bitmaps.
created_at: 2025-04-15T23:26:42Z
author_association: COLLABORATOR

PR comments:
user: login: mssonicbld
created_at: 2025-04-07T12:48:14Z
body: /azp run Azure.sonic-buildimage
author_association: COLLABORATOR
user: login: azure-pipelines[bot]
created_at: 2025-04-07T12:48:26Z
body: <samp>
Azure Pipelines successfully started running 1 pipeline(s).<br>

</samp>
author_association: NONE
user: login: liat-grozovik
created_at: 2025-04-13T06:30:32Z
body: @qiluo-msft  @r12f can you please help to review and merge?
author_association: COLLABORATOR
user: login: liat-grozovik
created_at: 2025-04-17T15:16:10Z
body: @r12f  @kperumalbfn can you sign in so we can merge?
author_association: COLLABORATOR
user: login: mssonicbld
created_at: 2025-04-17T22:26:56Z
body: Cherry-pick PR to msft-202412: https://github.com/Azure/sonic-buildimage-msft/pull/1019
author_association: COLLABORATOR