{"action":"created","comment":{"url":"https://api.github.com/repos/Azure/sonic-swss/pulls/comments/73718049","id":73718049,"diff_hunk":"@@ -0,0 +1,540 @@\n+#include \"sai.h\"\n+\n+#include \"copporch.h\"\n+#include \"logger.h\"\n+\n+#include <sstream>\n+#include <iostream>\n+\n+extern sai_hostif_api_t*    sai_hostif_api;\n+extern sai_policer_api_t*   sai_policer_api;\n+\n+CoppOrch::CoppOrch(DBConnector *db, string tableName) :\n+    Orch(db, tableName)\n+{\n+    SWSS_LOG_ENTER();\n+};\n+\n+bool CoppOrch::getPolicerMeter(string input, sai_meter_type_t& meter_value) const\n+{\n+    SWSS_LOG_ENTER();\n+    SWSS_LOG_DEBUG(\"copp policer meter type:%s\\n\", input.c_str());\n+    if (input == copp_policer_meter_packets)\n+    {\n+        meter_value = SAI_METER_TYPE_PACKETS;\n+    }\n+    else if (input == copp_policer_meter_bytes)\n+    {\n+        meter_value = SAI_METER_TYPE_BYTES;        \n+    }\n+    else\n+    {\n+        SWSS_LOG_DEBUG(\"invalid meter value :%s\\n\", input.c_str());\n+        return false;\n+    }\n+    return true;\n+}\n+\n+bool CoppOrch::getPolicerMode(string input, sai_policer_mode_t& mode) const\n+{\n+    SWSS_LOG_ENTER();\n+    if (input == copp_policer_mode_sr_tcm)\n+    {\n+        mode = SAI_POLICER_MODE_Sr_TCM;\n+    }\n+    else if (input == copp_policer_mode_tr_tcm)\n+    {\n+        mode = SAI_POLICER_MODE_Tr_TCM;\n+    }\n+    else if (input == copp_policer_mode_storm)\n+    {\n+        mode = SAI_POLICER_MODE_STORM_CONTROL;\n+    }\n+    else\n+    {\n+        SWSS_LOG_ERROR(\"Invalid mode specified %s\\n\", input.c_str());\n+        return false;\n+    }        \n+    return true;\n+}\n+\n+bool CoppOrch::getPlicerColor(string input, sai_policer_color_source_t& color) const\n+{\n+    SWSS_LOG_ENTER();\n+    if (input == copp_policer_color_aware)\n+    {\n+        color = SAI_POLICER_COLOR_SOURCE_AWARE;\n+    }\n+    else if (input == copp_policer_mode_tr_tcm)\n+    {\n+        color = SAI_POLICER_COLOR_SOURCE_BLIND;\n+    }\n+    else\n+    {\n+        SWSS_LOG_ERROR(\"Invalid color specified %s\\n\", input.c_str());\n+        return false;\n+    }        \n+    return true;","path":"orchagent/copporch.cpp","position":77,"original_position":77,"commit_id":"8e9fd8f5446aa19d4220188e75ed432c2a58a658","original_commit_id":"8e9fd8f5446aa19d4220188e75ed432c2a58a658","user":{"login":"lguohan","id":2293967,"avatar_url":"https://avatars.githubusercontent.com/u/2293967?v=3","gravatar_id":"","url":"https://api.github.com/users/lguohan","html_url":"https://github.com/lguohan","followers_url":"https://api.github.com/users/lguohan/followers","following_url":"https://api.github.com/users/lguohan/following{/other_user}","gists_url":"https://api.github.com/users/lguohan/gists{/gist_id}","starred_url":"https://api.github.com/users/lguohan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lguohan/subscriptions","organizations_url":"https://api.github.com/users/lguohan/orgs","repos_url":"https://api.github.com/users/lguohan/repos","events_url":"https://api.github.com/users/lguohan/events{/privacy}","received_events_url":"https://api.github.com/users/lguohan/received_events","type":"User","site_admin":false},"body":"use map to do it?","created_at":"2016-08-05T16:09:05Z","updated_at":"2016-08-05T16:09:05Z","html_url":"https://github.com/Azure/sonic-swss/pull/54#discussion_r73718049","pull_request_url":"https://api.github.com/repos/Azure/sonic-swss/pulls/54","_links":{"self":{"href":"https://api.github.com/repos/Azure/sonic-swss/pulls/comments/73718049"},"html":{"href":"https://github.com/Azure/sonic-swss/pull/54#discussion_r73718049"},"pull_request":{"href":"https://api.github.com/repos/Azure/sonic-swss/pulls/54"}}},"pull_request":{"url":"https://api.github.com/repos/Azure/sonic-swss/pulls/54","id":80007923,"html_url":"https://github.com/Azure/sonic-swss/pull/54","diff_url":"https://github.com/Azure/sonic-swss/pull/54.diff","patch_url":"https://github.com/Azure/sonic-swss/pull/54.patch","issue_url":"https://api.github.com/repos/Azure/sonic-swss/issues/54","number":54,"state":"open","locked":false,"title":"[sonic-swss] Add support for COPP","user":{"login":"hrachya-mellanox","id":12867186,"avatar_url":"https://avatars.githubusercontent.com/u/12867186?v=3","gravatar_id":"","url":"https://api.github.com/users/hrachya-mellanox","html_url":"https://github.com/hrachya-mellanox","followers_url":"https://api.github.com/users/hrachya-mellanox/followers","following_url":"https://api.github.com/users/hrachya-mellanox/following{/other_user}","gists_url":"https://api.github.com/users/hrachya-mellanox/gists{/gist_id}","starred_url":"https://api.github.com/users/hrachya-mellanox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hrachya-mellanox/subscriptions","organizations_url":"https://api.github.com/users/hrachya-mellanox/orgs","repos_url":"https://api.github.com/users/hrachya-mellanox/repos","events_url":"https://api.github.com/users/hrachya-mellanox/events{/privacy}","received_events_url":"https://api.github.com/users/hrachya-mellanox/received_events","type":"User","site_admin":false},"body":"* Added new class CoppOrch\r\n* Added schema for COPP_TABLE\r\n\r\nSigned-off-by: hrachya@mellanox.com","created_at":"2016-08-04T02:05:31Z","updated_at":"2016-08-05T16:09:05Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8fd1ecd76e85f85e2e4689aebe1c7db90674961a","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/Azure/sonic-swss/pulls/54/commits","review_comments_url":"https://api.github.com/repos/Azure/sonic-swss/pulls/54/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/54/comments","statuses_url":"https://api.github.com/repos/Azure/sonic-swss/statuses/8e9fd8f5446aa19d4220188e75ed432c2a58a658","head":{"label":"hrachya-mellanox:copp.07-29-16","ref":"copp.07-29-16","sha":"8e9fd8f5446aa19d4220188e75ed432c2a58a658","user":{"login":"hrachya-mellanox","id":12867186,"avatar_url":"https://avatars.githubusercontent.com/u/12867186?v=3","gravatar_id":"","url":"https://api.github.com/users/hrachya-mellanox","html_url":"https://github.com/hrachya-mellanox","followers_url":"https://api.github.com/users/hrachya-mellanox/followers","following_url":"https://api.github.com/users/hrachya-mellanox/following{/other_user}","gists_url":"https://api.github.com/users/hrachya-mellanox/gists{/gist_id}","starred_url":"https://api.github.com/users/hrachya-mellanox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hrachya-mellanox/subscriptions","organizations_url":"https://api.github.com/users/hrachya-mellanox/orgs","repos_url":"https://api.github.com/users/hrachya-mellanox/repos","events_url":"https://api.github.com/users/hrachya-mellanox/events{/privacy}","received_events_url":"https://api.github.com/users/hrachya-mellanox/received_events","type":"User","site_admin":false},"repo":{"id":54569590,"name":"sonic-swss","full_name":"hrachya-mellanox/sonic-swss","owner":{"login":"hrachya-mellanox","id":12867186,"avatar_url":"https://avatars.githubusercontent.com/u/12867186?v=3","gravatar_id":"","url":"https://api.github.com/users/hrachya-mellanox","html_url":"https://github.com/hrachya-mellanox","followers_url":"https://api.github.com/users/hrachya-mellanox/followers","following_url":"https://api.github.com/users/hrachya-mellanox/following{/other_user}","gists_url":"https://api.github.com/users/hrachya-mellanox/gists{/gist_id}","starred_url":"https://api.github.com/users/hrachya-mellanox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hrachya-mellanox/subscriptions","organizations_url":"https://api.github.com/users/hrachya-mellanox/orgs","repos_url":"https://api.github.com/users/hrachya-mellanox/repos","events_url":"https://api.github.com/users/hrachya-mellanox/events{/privacy}","received_events_url":"https://api.github.com/users/hrachya-mellanox/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/hrachya-mellanox/sonic-swss","description":"Public version of swss repository","fork":true,"url":"https://api.github.com/repos/hrachya-mellanox/sonic-swss","forks_url":"https://api.github.com/repos/hrachya-mellanox/sonic-swss/forks","keys_url":"https://api.github.com/repos/hrachya-mellanox/sonic-swss/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hrachya-mellanox/sonic-swss/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hrachya-mellanox/sonic-swss/teams","hooks_url":"https://api.github.com/repos/hrachya-mellanox/sonic-swss/hooks","issue_events_url":"https://api.github.com/repos/hrachya-mellanox/sonic-swss/issues/events{/number}","events_url":"https://api.github.com/repos/hrachya-mellanox/sonic-swss/events","assignees_url":"https://api.github.com/repos/hrachya-mellanox/sonic-swss/assignees{/user}","branches_url":"https://api.github.com/repos/hrachya-mellanox/sonic-swss/branches{/branch}","tags_url":"https://api.github.com/repos/hrachya-mellanox/sonic-swss/tags","blobs_url":"https://api.github.com/repos/hrachya-mellanox/sonic-swss/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hrachya-mellanox/sonic-swss/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hrachya-mellanox/sonic-swss/git/refs{/sha}","trees_url":"https://api.github.com/repos/hrachya-mellanox/sonic-swss/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hrachya-mellanox/sonic-swss/statuses/{sha}","languages_url":"https://api.github.com/repos/hrachya-mellanox/sonic-swss/languages","stargazers_url":"https://api.github.com/repos/hrachya-mellanox/sonic-swss/stargazers","contributors_url":"https://api.github.com/repos/hrachya-mellanox/sonic-swss/contributors","subscribers_url":"https://api.github.com/repos/hrachya-mellanox/sonic-swss/subscribers","subscription_url":"https://api.github.com/repos/hrachya-mellanox/sonic-swss/subscription","commits_url":"https://api.github.com/repos/hrachya-mellanox/sonic-swss/commits{/sha}","git_commits_url":"https://api.github.com/repos/hrachya-mellanox/sonic-swss/git/commits{/sha}","comments_url":"https://api.github.com/repos/hrachya-mellanox/sonic-swss/comments{/number}","issue_comment_url":"https://api.github.com/repos/hrachya-mellanox/sonic-swss/issues/comments{/number}","contents_url":"https://api.github.com/repos/hrachya-mellanox/sonic-swss/contents/{+path}","compare_url":"https://api.github.com/repos/hrachya-mellanox/sonic-swss/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hrachya-mellanox/sonic-swss/merges","archive_url":"https://api.github.com/repos/hrachya-mellanox/sonic-swss/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hrachya-mellanox/sonic-swss/downloads","issues_url":"https://api.github.com/repos/hrachya-mellanox/sonic-swss/issues{/number}","pulls_url":"https://api.github.com/repos/hrachya-mellanox/sonic-swss/pulls{/number}","milestones_url":"https://api.github.com/repos/hrachya-mellanox/sonic-swss/milestones{/number}","notifications_url":"https://api.github.com/repos/hrachya-mellanox/sonic-swss/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hrachya-mellanox/sonic-swss/labels{/name}","releases_url":"https://api.github.com/repos/hrachya-mellanox/sonic-swss/releases{/id}","deployments_url":"https://api.github.com/repos/hrachya-mellanox/sonic-swss/deployments","created_at":"2016-03-23T15:08:22Z","updated_at":"2016-03-23T15:08:24Z","pushed_at":"2016-08-04T02:21:37Z","git_url":"git://github.com/hrachya-mellanox/sonic-swss.git","ssh_url":"git@github.com:hrachya-mellanox/sonic-swss.git","clone_url":"https://github.com/hrachya-mellanox/sonic-swss.git","svn_url":"https://github.com/hrachya-mellanox/sonic-swss","homepage":null,"size":601,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"Azure:master","ref":"master","sha":"2c92bc871adecf6bf751ed85032793d8f5aa03b8","user":{"login":"Azure","id":6844498,"avatar_url":"https://avatars.githubusercontent.com/u/6844498?v=3","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://avatars.githubusercontent.com/u/6844498?v=3","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":"2016-07-28T19:34:32Z","pushed_at":"2016-08-04T02:21:38Z","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":939,"stargazers_count":17,"watchers_count":17,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":11,"mirror_url":null,"open_issues_count":5,"forks":11,"open_issues":5,"watchers":17,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Azure/sonic-swss/pulls/54"},"html":{"href":"https://github.com/Azure/sonic-swss/pull/54"},"issue":{"href":"https://api.github.com/repos/Azure/sonic-swss/issues/54"},"comments":{"href":"https://api.github.com/repos/Azure/sonic-swss/issues/54/comments"},"review_comments":{"href":"https://api.github.com/repos/Azure/sonic-swss/pulls/54/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/54/commits"},"statuses":{"href":"https://api.github.com/repos/Azure/sonic-swss/statuses/8e9fd8f5446aa19d4220188e75ed432c2a58a658"}}}}
{"actor":{"display_login":"lguohan"}}