{"action":"created","comment":{"url":"https://api.github.com/repos/Azure/sonic-swss/pulls/comments/180902252","pull_request_review_id":111407587,"id":180902252,"diff_hunk":"@@ -463,6 +469,121 @@ bool PortsOrch::setPortFec(sai_object_id_t id, sai_port_fec_mode_t mode)\n     return true;\n }\n \n+bool PortsOrch::getPortPfc(sai_object_id_t portId, uint8_t *pfc_bitmask)\n+{\n+    SWSS_LOG_ENTER();\n+\n+    sai_attribute_t attr;\n+    Port p;\n+\n+    if (!getPort(portId, p))\n+    {\n+        SWSS_LOG_ERROR(\"Failed to get port object for port id 0x%lx\", portId);\n+        return false;\n+    }\n+\n+    if (p.m_pfc_asym == SAI_PORT_PRIORITY_FLOW_CONTROL_MODE_COMBINED)\n+    {\n+        attr.id = SAI_PORT_ATTR_PRIORITY_FLOW_CONTROL;\n+    }\n+    else\n+    {\n+        attr.id = SAI_PORT_ATTR_PRIORITY_FLOW_CONTROL_TX;\n+    }\n+\n+    sai_status_t status = sai_port_api->get_port_attribute(portId, 1, &attr);\n+    if (status != SAI_STATUS_SUCCESS)\n+    {\n+        SWSS_LOG_ERROR(\"Failed to get PFC value on port id 0x%lx (rc:%d)\", portId, status);\n+    }\n+\n+    *pfc_bitmask = attr.value.u8;\n+\n+    return true;\n+}\n+\n+bool PortsOrch::setPortPfc(sai_object_id_t portId, uint8_t pfc_bitmask)\n+{\n+    SWSS_LOG_ENTER();\n+\n+    sai_attribute_t attr;\n+    Port p;\n+\n+    if (!getPort(portId, p))\n+    {\n+        SWSS_LOG_ERROR(\"Failed to get port object for port id 0x%lx\", portId);\n+        return false;\n+    }\n+\n+    if (p.m_pfc_asym == SAI_PORT_PRIORITY_FLOW_CONTROL_MODE_COMBINED)\n+    {\n+        attr.id = SAI_PORT_ATTR_PRIORITY_FLOW_CONTROL;\n+    }\n+    else\n+    {\n+        attr.id = SAI_PORT_ATTR_PRIORITY_FLOW_CONTROL_TX;\n+    }\n+\n+    attr.value.u8 = pfc_bitmask;\n+\n+    sai_status_t status = sai_port_api->set_port_attribute(portId, &attr);\n+    if (status != SAI_STATUS_SUCCESS)\n+    {\n+        SWSS_LOG_ERROR(\"Failed to set PFC 0x%x to port id 0x%lx (rc:%d)\", attr.value.u8, portId, status);\n+        return false;\n+    }\n+\n+    return true;\n+}\n+\n+bool PortsOrch::setPortPfcAsym(Port &port, string pfc_asym)\n+{\n+    SWSS_LOG_ENTER();\n+\n+    sai_attribute_t attr;\n+    uint8_t pfc = 0;\n+\n+    if (!getPortPfc(port.m_port_id, &pfc))\n+    {\n+        return false;\n+    }\n+\n+    port.m_pfc_asym = pfc_asym_map.at(pfc_asym);\n+    m_portList[port.m_alias] = port;\n+\n+    attr.id = SAI_PORT_ATTR_PRIORITY_FLOW_CONTROL_MODE;\n+    attr.value.s32 = (int32_t) port.m_pfc_asym;\n+\n+    sai_status_t status = sai_port_api->set_port_attribute(port.m_port_id, &attr);\n+    if (status != SAI_STATUS_SUCCESS)\n+    {\n+        SWSS_LOG_ERROR(\"Failed to set PFC mode %d to port id 0x%lx (rc:%d)\", port.m_pfc_asym, port.m_port_id, status);\n+        return false;\n+    }\n+\n+    if (!setPortPfc(port.m_port_id, pfc))","path":"orchagent/portsorch.cpp","position":109,"original_position":109,"commit_id":"339baa2b9435777157029d832e2e765c6d691c7a","original_commit_id":"339baa2b9435777157029d832e2e765c6d691c7a","user":{"login":"sihuihan88","id":26074083,"avatar_url":"https://avatars2.githubusercontent.com/u/26074083?v=4","gravatar_id":"","url":"https://api.github.com/users/sihuihan88","html_url":"https://github.com/sihuihan88","followers_url":"https://api.github.com/users/sihuihan88/followers","following_url":"https://api.github.com/users/sihuihan88/following{/other_user}","gists_url":"https://api.github.com/users/sihuihan88/gists{/gist_id}","starred_url":"https://api.github.com/users/sihuihan88/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sihuihan88/subscriptions","organizations_url":"https://api.github.com/users/sihuihan88/orgs","repos_url":"https://api.github.com/users/sihuihan88/repos","events_url":"https://api.github.com/users/sihuihan88/events{/privacy}","received_events_url":"https://api.github.com/users/sihuihan88/received_events","type":"User","site_admin":false},"body":"Can you help me understand why set port pfc=0 here?\r\n","created_at":"2018-04-11T21:21:36Z","updated_at":"2018-04-11T22:02:03Z","html_url":"https://github.com/Azure/sonic-swss/pull/460#discussion_r180902252","pull_request_url":"https://api.github.com/repos/Azure/sonic-swss/pulls/460","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/Azure/sonic-swss/pulls/comments/180902252"},"html":{"href":"https://github.com/Azure/sonic-swss/pull/460#discussion_r180902252"},"pull_request":{"href":"https://api.github.com/repos/Azure/sonic-swss/pulls/460"}}},"pull_request":{"url":"https://api.github.com/repos/Azure/sonic-swss/pulls/460","id":178845639,"html_url":"https://github.com/Azure/sonic-swss/pull/460","diff_url":"https://github.com/Azure/sonic-swss/pull/460.diff","patch_url":"https://github.com/Azure/sonic-swss/pull/460.patch","issue_url":"https://api.github.com/repos/Azure/sonic-swss/issues/460","number":460,"state":"open","locked":false,"title":"[portsorch]: Add asymmetric PFC support","user":{"login":"volodymyrsamotiy","id":25589504,"avatar_url":"https://avatars1.githubusercontent.com/u/25589504?v=4","gravatar_id":"","url":"https://api.github.com/users/volodymyrsamotiy","html_url":"https://github.com/volodymyrsamotiy","followers_url":"https://api.github.com/users/volodymyrsamotiy/followers","following_url":"https://api.github.com/users/volodymyrsamotiy/following{/other_user}","gists_url":"https://api.github.com/users/volodymyrsamotiy/gists{/gist_id}","starred_url":"https://api.github.com/users/volodymyrsamotiy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/volodymyrsamotiy/subscriptions","organizations_url":"https://api.github.com/users/volodymyrsamotiy/orgs","repos_url":"https://api.github.com/users/volodymyrsamotiy/repos","events_url":"https://api.github.com/users/volodymyrsamotiy/events{/privacy}","received_events_url":"https://api.github.com/users/volodymyrsamotiy/received_events","type":"User","site_admin":false},"body":"* Implement asymmetric PFC feature\r\n* Implement unit test on top of virtual switch\r\n\r\nSigned-off-by: Volodymyr Samotiy <volodymyrs@mellanox.com>\r\n\r\n**What I did**\r\nAdded asymmetric PFC support\r\n**Why I did it**\r\nFeature request\r\n**How I verified it**\r\nPerformed manual tests, also implemented and ran unit test on top of virtual switch\r\n","created_at":"2018-04-02T14:03:51Z","updated_at":"2018-04-11T22:02:03Z","closed_at":null,"merged_at":null,"merge_commit_sha":"88da43d892f191b3dce2a6b129da82ba7fe2ae70","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/Azure/sonic-swss/pulls/460/commits","review_comments_url":"https://api.github.com/repos/Azure/sonic-swss/pulls/460/comments","review_comment_url":"https://api.github.com/repos/Azure/sonic-swss/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Azure/sonic-swss/issues/460/comments","statuses_url":"https://api.github.com/repos/Azure/sonic-swss/statuses/339baa2b9435777157029d832e2e765c6d691c7a","head":{"label":"volodymyrsamotiy:master","ref":"master","sha":"339baa2b9435777157029d832e2e765c6d691c7a","user":{"login":"volodymyrsamotiy","id":25589504,"avatar_url":"https://avatars1.githubusercontent.com/u/25589504?v=4","gravatar_id":"","url":"https://api.github.com/users/volodymyrsamotiy","html_url":"https://github.com/volodymyrsamotiy","followers_url":"https://api.github.com/users/volodymyrsamotiy/followers","following_url":"https://api.github.com/users/volodymyrsamotiy/following{/other_user}","gists_url":"https://api.github.com/users/volodymyrsamotiy/gists{/gist_id}","starred_url":"https://api.github.com/users/volodymyrsamotiy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/volodymyrsamotiy/subscriptions","organizations_url":"https://api.github.com/users/volodymyrsamotiy/orgs","repos_url":"https://api.github.com/users/volodymyrsamotiy/repos","events_url":"https://api.github.com/users/volodymyrsamotiy/events{/privacy}","received_events_url":"https://api.github.com/users/volodymyrsamotiy/received_events","type":"User","site_admin":false},"repo":{"id":127269973,"name":"sonic-swss","full_name":"volodymyrsamotiy/sonic-swss","owner":{"login":"volodymyrsamotiy","id":25589504,"avatar_url":"https://avatars1.githubusercontent.com/u/25589504?v=4","gravatar_id":"","url":"https://api.github.com/users/volodymyrsamotiy","html_url":"https://github.com/volodymyrsamotiy","followers_url":"https://api.github.com/users/volodymyrsamotiy/followers","following_url":"https://api.github.com/users/volodymyrsamotiy/following{/other_user}","gists_url":"https://api.github.com/users/volodymyrsamotiy/gists{/gist_id}","starred_url":"https://api.github.com/users/volodymyrsamotiy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/volodymyrsamotiy/subscriptions","organizations_url":"https://api.github.com/users/volodymyrsamotiy/orgs","repos_url":"https://api.github.com/users/volodymyrsamotiy/repos","events_url":"https://api.github.com/users/volodymyrsamotiy/events{/privacy}","received_events_url":"https://api.github.com/users/volodymyrsamotiy/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/volodymyrsamotiy/sonic-swss","description":"SONiC Switch State Service (SwSS)","fork":true,"url":"https://api.github.com/repos/volodymyrsamotiy/sonic-swss","forks_url":"https://api.github.com/repos/volodymyrsamotiy/sonic-swss/forks","keys_url":"https://api.github.com/repos/volodymyrsamotiy/sonic-swss/keys{/key_id}","collaborators_url":"https://api.github.com/repos/volodymyrsamotiy/sonic-swss/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/volodymyrsamotiy/sonic-swss/teams","hooks_url":"https://api.github.com/repos/volodymyrsamotiy/sonic-swss/hooks","issue_events_url":"https://api.github.com/repos/volodymyrsamotiy/sonic-swss/issues/events{/number}","events_url":"https://api.github.com/repos/volodymyrsamotiy/sonic-swss/events","assignees_url":"https://api.github.com/repos/volodymyrsamotiy/sonic-swss/assignees{/user}","branches_url":"https://api.github.com/repos/volodymyrsamotiy/sonic-swss/branches{/branch}","tags_url":"https://api.github.com/repos/volodymyrsamotiy/sonic-swss/tags","blobs_url":"https://api.github.com/repos/volodymyrsamotiy/sonic-swss/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/volodymyrsamotiy/sonic-swss/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/volodymyrsamotiy/sonic-swss/git/refs{/sha}","trees_url":"https://api.github.com/repos/volodymyrsamotiy/sonic-swss/git/trees{/sha}","statuses_url":"https://api.github.com/repos/volodymyrsamotiy/sonic-swss/statuses/{sha}","languages_url":"https://api.github.com/repos/volodymyrsamotiy/sonic-swss/languages","stargazers_url":"https://api.github.com/repos/volodymyrsamotiy/sonic-swss/stargazers","contributors_url":"https://api.github.com/repos/volodymyrsamotiy/sonic-swss/contributors","subscribers_url":"https://api.github.com/repos/volodymyrsamotiy/sonic-swss/subscribers","subscription_url":"https://api.github.com/repos/volodymyrsamotiy/sonic-swss/subscription","commits_url":"https://api.github.com/repos/volodymyrsamotiy/sonic-swss/commits{/sha}","git_commits_url":"https://api.github.com/repos/volodymyrsamotiy/sonic-swss/git/commits{/sha}","comments_url":"https://api.github.com/repos/volodymyrsamotiy/sonic-swss/comments{/number}","issue_comment_url":"https://api.github.com/repos/volodymyrsamotiy/sonic-swss/issues/comments{/number}","contents_url":"https://api.github.com/repos/volodymyrsamotiy/sonic-swss/contents/{+path}","compare_url":"https://api.github.com/repos/volodymyrsamotiy/sonic-swss/compare/{base}...{head}","merges_url":"https://api.github.com/repos/volodymyrsamotiy/sonic-swss/merges","archive_url":"https://api.github.com/repos/volodymyrsamotiy/sonic-swss/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/volodymyrsamotiy/sonic-swss/downloads","issues_url":"https://api.github.com/repos/volodymyrsamotiy/sonic-swss/issues{/number}","pulls_url":"https://api.github.com/repos/volodymyrsamotiy/sonic-swss/pulls{/number}","milestones_url":"https://api.github.com/repos/volodymyrsamotiy/sonic-swss/milestones{/number}","notifications_url":"https://api.github.com/repos/volodymyrsamotiy/sonic-swss/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/volodymyrsamotiy/sonic-swss/labels{/name}","releases_url":"https://api.github.com/repos/volodymyrsamotiy/sonic-swss/releases{/id}","deployments_url":"https://api.github.com/repos/volodymyrsamotiy/sonic-swss/deployments","created_at":"2018-03-29T09:36:04Z","updated_at":"2018-04-03T12:20:41Z","pushed_at":"2018-04-03T12:20:40Z","git_url":"git://github.com/volodymyrsamotiy/sonic-swss.git","ssh_url":"git@github.com:volodymyrsamotiy/sonic-swss.git","clone_url":"https://github.com/volodymyrsamotiy/sonic-swss.git","svn_url":"https://github.com/volodymyrsamotiy/sonic-swss","homepage":"https://azure.github.io/SONiC","size":1388,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"Azure:master","ref":"master","sha":"e217519c20c60f7cf4e24688dd3eca6d380a1dd6","user":{"login":"Azure","id":6844498,"avatar_url":"https://avatars0.githubusercontent.com/u/6844498?v=4","gravatar_id":"","url":"https://api.github.com/users/Azure","html_url":"https://github.com/Azure","followers_url":"https://api.github.com/users/Azure/followers","following_url":"https://api.github.com/users/Azure/following{/other_user}","gists_url":"https://api.github.com/users/Azure/gists{/gist_id}","starred_url":"https://api.github.com/users/Azure/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Azure/subscriptions","organizations_url":"https://api.github.com/users/Azure/orgs","repos_url":"https://api.github.com/users/Azure/repos","events_url":"https://api.github.com/users/Azure/events{/privacy}","received_events_url":"https://api.github.com/users/Azure/received_events","type":"Organization","site_admin":false},"repo":{"id":53515475,"name":"sonic-swss","full_name":"Azure/sonic-swss","owner":{"login":"Azure","id":6844498,"avatar_url":"https://avatars0.githubusercontent.com/u/6844498?v=4","gravatar_id":"","url":"https://api.github.com/users/Azure","html_url":"https://github.com/Azure","followers_url":"https://api.github.com/users/Azure/followers","following_url":"https://api.github.com/users/Azure/following{/other_user}","gists_url":"https://api.github.com/users/Azure/gists{/gist_id}","starred_url":"https://api.github.com/users/Azure/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Azure/subscriptions","organizations_url":"https://api.github.com/users/Azure/orgs","repos_url":"https://api.github.com/users/Azure/repos","events_url":"https://api.github.com/users/Azure/events{/privacy}","received_events_url":"https://api.github.com/users/Azure/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Azure/sonic-swss","description":"SONiC Switch State Service (SwSS)","fork":false,"url":"https://api.github.com/repos/Azure/sonic-swss","forks_url":"https://api.github.com/repos/Azure/sonic-swss/forks","keys_url":"https://api.github.com/repos/Azure/sonic-swss/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Azure/sonic-swss/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Azure/sonic-swss/teams","hooks_url":"https://api.github.com/repos/Azure/sonic-swss/hooks","issue_events_url":"https://api.github.com/repos/Azure/sonic-swss/issues/events{/number}","events_url":"https://api.github.com/repos/Azure/sonic-swss/events","assignees_url":"https://api.github.com/repos/Azure/sonic-swss/assignees{/user}","branches_url":"https://api.github.com/repos/Azure/sonic-swss/branches{/branch}","tags_url":"https://api.github.com/repos/Azure/sonic-swss/tags","blobs_url":"https://api.github.com/repos/Azure/sonic-swss/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Azure/sonic-swss/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Azure/sonic-swss/git/refs{/sha}","trees_url":"https://api.github.com/repos/Azure/sonic-swss/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Azure/sonic-swss/statuses/{sha}","languages_url":"https://api.github.com/repos/Azure/sonic-swss/languages","stargazers_url":"https://api.github.com/repos/Azure/sonic-swss/stargazers","contributors_url":"https://api.github.com/repos/Azure/sonic-swss/contributors","subscribers_url":"https://api.github.com/repos/Azure/sonic-swss/subscribers","subscription_url":"https://api.github.com/repos/Azure/sonic-swss/subscription","commits_url":"https://api.github.com/repos/Azure/sonic-swss/commits{/sha}","git_commits_url":"https://api.github.com/repos/Azure/sonic-swss/git/commits{/sha}","comments_url":"https://api.github.com/repos/Azure/sonic-swss/comments{/number}","issue_comment_url":"https://api.github.com/repos/Azure/sonic-swss/issues/comments{/number}","contents_url":"https://api.github.com/repos/Azure/sonic-swss/contents/{+path}","compare_url":"https://api.github.com/repos/Azure/sonic-swss/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Azure/sonic-swss/merges","archive_url":"https://api.github.com/repos/Azure/sonic-swss/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Azure/sonic-swss/downloads","issues_url":"https://api.github.com/repos/Azure/sonic-swss/issues{/number}","pulls_url":"https://api.github.com/repos/Azure/sonic-swss/pulls{/number}","milestones_url":"https://api.github.com/repos/Azure/sonic-swss/milestones{/number}","notifications_url":"https://api.github.com/repos/Azure/sonic-swss/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Azure/sonic-swss/labels{/name}","releases_url":"https://api.github.com/repos/Azure/sonic-swss/releases{/id}","deployments_url":"https://api.github.com/repos/Azure/sonic-swss/deployments","created_at":"2016-03-09T17:01:09Z","updated_at":"2018-04-11T01:44:32Z","pushed_at":"2018-04-11T21:07:51Z","git_url":"git://github.com/Azure/sonic-swss.git","ssh_url":"git@github.com:Azure/sonic-swss.git","clone_url":"https://github.com/Azure/sonic-swss.git","svn_url":"https://github.com/Azure/sonic-swss","homepage":"https://azure.github.io/SONiC","size":1396,"stargazers_count":32,"watchers_count":32,"language":"C++","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":51,"mirror_url":null,"archived":false,"open_issues_count":47,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":51,"open_issues":47,"watchers":32,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Azure/sonic-swss/pulls/460"},"html":{"href":"https://github.com/Azure/sonic-swss/pull/460"},"issue":{"href":"https://api.github.com/repos/Azure/sonic-swss/issues/460"},"comments":{"href":"https://api.github.com/repos/Azure/sonic-swss/issues/460/comments"},"review_comments":{"href":"https://api.github.com/repos/Azure/sonic-swss/pulls/460/comments"},"review_comment":{"href":"https://api.github.com/repos/Azure/sonic-swss/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Azure/sonic-swss/pulls/460/commits"},"statuses":{"href":"https://api.github.com/repos/Azure/sonic-swss/statuses/339baa2b9435777157029d832e2e765c6d691c7a"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"sihuihan88"}}