Show a patch.

GET /api/patches/73401/
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 73401,
    "url": "https://patches.dpdk.org/api/patches/73401/",
    "web_url": "https://patches.dpdk.org/patch/73401/",
    "project": {
        "id": 1,
        "url": "https://patches.dpdk.org/api/projects/1/",
        "name": "DPDK",
        "link_name": "dpdk",
        "list_id": "dev.dpdk.org",
        "list_email": "dev@dpdk.org",
        "web_url": "http://core.dpdk.org",
        "scm_url": "git://dpdk.org/dpdk",
        "webscm_url": "http://git.dpdk.org/dpdk"
    },
    "msgid": "<20200707092244.12791-22-hemant.agrawal@nxp.com>",
    "date": "2020-07-07T09:22:36",
    "name": "[v2,21/29] net/dpaa2: add logging of flow extracts and rules",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "59ffdf6c23c536967863abaad0488c10bac23648",
    "submitter": {
        "id": 477,
        "url": "https://patches.dpdk.org/api/people/477/",
        "name": "Hemant Agrawal",
        "email": "hemant.agrawal@nxp.com"
    },
    "delegate": {
        "id": 319,
        "url": "https://patches.dpdk.org/api/users/319/",
        "username": "fyigit",
        "first_name": "Ferruh",
        "last_name": "Yigit",
        "email": "ferruh.yigit@intel.com"
    },
    "mbox": "https://patches.dpdk.org/patch/73401/mbox/",
    "series": [
        {
            "id": 10842,
            "url": "https://patches.dpdk.org/api/series/10842/",
            "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=10842",
            "date": "2020-07-07T09:22:15",
            "name": "NXP DPAAx enhancements",
            "version": 2,
            "mbox": "https://patches.dpdk.org/series/10842/mbox/"
        }
    ],
    "comments": "https://patches.dpdk.org/api/patches/73401/comments/",
    "check": "warning",
    "checks": "https://patches.dpdk.org/api/patches/73401/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "References": "<20200527132326.1382-1-hemant.agrawal@nxp.com>\n <20200707092244.12791-1-hemant.agrawal@nxp.com>",
        "X-Mailman-Version": "2.1.15",
        "Date": "Tue,  7 Jul 2020 14:52:36 +0530",
        "X-Virus-Scanned": "ClamAV using ClamSMTP",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "X-BeenThere": "dev@dpdk.org",
        "Message-Id": "<20200707092244.12791-22-hemant.agrawal@nxp.com>",
        "X-Original-To": "patchwork@inbox.dpdk.org",
        "Received": [
            "from dpdk.org (dpdk.org [92.243.14.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id 84FF8A00BE;\n\tTue,  7 Jul 2020 11:31:29 +0200 (CEST)",
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id E0B461DDFB;\n\tTue,  7 Jul 2020 11:27:32 +0200 (CEST)",
            "from inva021.nxp.com (inva021.nxp.com [92.121.34.21])\n by dpdk.org (Postfix) with ESMTP id 61A111DD1F\n for <dev@dpdk.org>; Tue,  7 Jul 2020 11:27:13 +0200 (CEST)",
            "from inva021.nxp.com (localhost [127.0.0.1])\n by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 465DC2008EB;\n Tue,  7 Jul 2020 11:27:13 +0200 (CEST)",
            "from invc005.ap-rdc01.nxp.com (invc005.ap-rdc01.nxp.com\n [165.114.16.14])\n by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 5F4A62008CE;\n Tue,  7 Jul 2020 11:27:11 +0200 (CEST)",
            "from bf-netperf1.ap.freescale.net (bf-netperf1.ap.freescale.net\n [10.232.133.63])\n by invc005.ap-rdc01.nxp.com (Postfix) with ESMTP id 24E05402F0;\n Tue,  7 Jul 2020 17:27:09 +0800 (SGT)"
        ],
        "List-Post": "<mailto:dev@dpdk.org>",
        "X-Mailer": "git-send-email 2.17.1",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>",
        "Subject": "[dpdk-dev] [PATCH v2 21/29] net/dpaa2: add logging of flow extracts\n\tand rules",
        "Precedence": "list",
        "From": "Hemant Agrawal <hemant.agrawal@nxp.com>",
        "List-Archive": "<http://mails.dpdk.org/archives/dev/>",
        "Errors-To": "dev-bounces@dpdk.org",
        "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n <mailto:dev-request@dpdk.org?subject=subscribe>",
        "Cc": "ferruh.yigit@intel.com,\n\tJun Yang <jun.yang@nxp.com>",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "Delivered-To": "patchwork@inbox.dpdk.org",
        "In-Reply-To": "<20200707092244.12791-1-hemant.agrawal@nxp.com>",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n <mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "To": "dev@dpdk.org"
    },
    "content": "From: Jun Yang <jun.yang@nxp.com>\n\nThis patch add support for logging the flow rules.\n\nSigned-off-by: Jun Yang <jun.yang@nxp.com>\n---\n drivers/net/dpaa2/dpaa2_flow.c | 213 ++++++++++++++++++++++++++++++++-\n 1 file changed, 209 insertions(+), 4 deletions(-)",
    "diff": "diff --git a/drivers/net/dpaa2/dpaa2_flow.c b/drivers/net/dpaa2/dpaa2_flow.c\nindex bcbd5977a..95756bf7b 100644\n--- a/drivers/net/dpaa2/dpaa2_flow.c\n+++ b/drivers/net/dpaa2/dpaa2_flow.c\n@@ -29,6 +29,8 @@\n  */\n int mc_l4_port_identification;\n \n+static char *dpaa2_flow_control_log;\n+\n #define FIXED_ENTRY_SIZE 54\n \n enum flow_rule_ipaddr_type {\n@@ -149,6 +151,189 @@ static const struct rte_flow_item_gre dpaa2_flow_item_gre_mask = {\n \n #endif\n \n+static inline void dpaa2_prot_field_string(\n+\tenum net_prot prot, uint32_t field,\n+\tchar *string)\n+{\n+\tif (!dpaa2_flow_control_log)\n+\t\treturn;\n+\n+\tif (prot == NET_PROT_ETH) {\n+\t\tstrcpy(string, \"eth\");\n+\t\tif (field == NH_FLD_ETH_DA)\n+\t\t\tstrcat(string, \".dst\");\n+\t\telse if (field == NH_FLD_ETH_SA)\n+\t\t\tstrcat(string, \".src\");\n+\t\telse if (field == NH_FLD_ETH_TYPE)\n+\t\t\tstrcat(string, \".type\");\n+\t\telse\n+\t\t\tstrcat(string, \".unknown field\");\n+\t} else if (prot == NET_PROT_VLAN) {\n+\t\tstrcpy(string, \"vlan\");\n+\t\tif (field == NH_FLD_VLAN_TCI)\n+\t\t\tstrcat(string, \".tci\");\n+\t\telse\n+\t\t\tstrcat(string, \".unknown field\");\n+\t} else if (prot == NET_PROT_IP) {\n+\t\tstrcpy(string, \"ip\");\n+\t\tif (field == NH_FLD_IP_SRC)\n+\t\t\tstrcat(string, \".src\");\n+\t\telse if (field == NH_FLD_IP_DST)\n+\t\t\tstrcat(string, \".dst\");\n+\t\telse if (field == NH_FLD_IP_PROTO)\n+\t\t\tstrcat(string, \".proto\");\n+\t\telse\n+\t\t\tstrcat(string, \".unknown field\");\n+\t} else if (prot == NET_PROT_TCP) {\n+\t\tstrcpy(string, \"tcp\");\n+\t\tif (field == NH_FLD_TCP_PORT_SRC)\n+\t\t\tstrcat(string, \".src\");\n+\t\telse if (field == NH_FLD_TCP_PORT_DST)\n+\t\t\tstrcat(string, \".dst\");\n+\t\telse\n+\t\t\tstrcat(string, \".unknown field\");\n+\t} else if (prot == NET_PROT_UDP) {\n+\t\tstrcpy(string, \"udp\");\n+\t\tif (field == NH_FLD_UDP_PORT_SRC)\n+\t\t\tstrcat(string, \".src\");\n+\t\telse if (field == NH_FLD_UDP_PORT_DST)\n+\t\t\tstrcat(string, \".dst\");\n+\t\telse\n+\t\t\tstrcat(string, \".unknown field\");\n+\t} else if (prot == NET_PROT_ICMP) {\n+\t\tstrcpy(string, \"icmp\");\n+\t\tif (field == NH_FLD_ICMP_TYPE)\n+\t\t\tstrcat(string, \".type\");\n+\t\telse if (field == NH_FLD_ICMP_CODE)\n+\t\t\tstrcat(string, \".code\");\n+\t\telse\n+\t\t\tstrcat(string, \".unknown field\");\n+\t} else if (prot == NET_PROT_SCTP) {\n+\t\tstrcpy(string, \"sctp\");\n+\t\tif (field == NH_FLD_SCTP_PORT_SRC)\n+\t\t\tstrcat(string, \".src\");\n+\t\telse if (field == NH_FLD_SCTP_PORT_DST)\n+\t\t\tstrcat(string, \".dst\");\n+\t\telse\n+\t\t\tstrcat(string, \".unknown field\");\n+\t} else if (prot == NET_PROT_GRE) {\n+\t\tstrcpy(string, \"gre\");\n+\t\tif (field == NH_FLD_GRE_TYPE)\n+\t\t\tstrcat(string, \".type\");\n+\t\telse\n+\t\t\tstrcat(string, \".unknown field\");\n+\t} else {\n+\t\tstrcpy(string, \"unknown protocol\");\n+\t}\n+}\n+\n+static inline void dpaa2_flow_qos_table_extracts_log(\n+\tconst struct dpaa2_dev_priv *priv)\n+{\n+\tint idx;\n+\tchar string[32];\n+\n+\tif (!dpaa2_flow_control_log)\n+\t\treturn;\n+\n+\tprintf(\"Setup QoS table: number of extracts: %d\\r\\n\",\n+\t\t\tpriv->extract.qos_key_extract.dpkg.num_extracts);\n+\tfor (idx = 0; idx < priv->extract.qos_key_extract.dpkg.num_extracts;\n+\t\tidx++) {\n+\t\tdpaa2_prot_field_string(priv->extract.qos_key_extract.dpkg\n+\t\t\t.extracts[idx].extract.from_hdr.prot,\n+\t\t\tpriv->extract.qos_key_extract.dpkg.extracts[idx]\n+\t\t\t.extract.from_hdr.field,\n+\t\t\tstring);\n+\t\tprintf(\"%s\", string);\n+\t\tif ((idx + 1) < priv->extract.qos_key_extract.dpkg.num_extracts)\n+\t\t\tprintf(\" / \");\n+\t}\n+\tprintf(\"\\r\\n\");\n+}\n+\n+static inline void dpaa2_flow_fs_table_extracts_log(\n+\tconst struct dpaa2_dev_priv *priv, int tc_id)\n+{\n+\tint idx;\n+\tchar string[32];\n+\n+\tif (!dpaa2_flow_control_log)\n+\t\treturn;\n+\n+\tprintf(\"Setup FS table: number of extracts of TC[%d]: %d\\r\\n\",\n+\t\t\ttc_id, priv->extract.tc_key_extract[tc_id]\n+\t\t\t.dpkg.num_extracts);\n+\tfor (idx = 0; idx < priv->extract.tc_key_extract[tc_id]\n+\t\t.dpkg.num_extracts; idx++) {\n+\t\tdpaa2_prot_field_string(priv->extract.tc_key_extract[tc_id]\n+\t\t\t.dpkg.extracts[idx].extract.from_hdr.prot,\n+\t\t\tpriv->extract.tc_key_extract[tc_id].dpkg.extracts[idx]\n+\t\t\t.extract.from_hdr.field,\n+\t\t\tstring);\n+\t\tprintf(\"%s\", string);\n+\t\tif ((idx + 1) < priv->extract.tc_key_extract[tc_id]\n+\t\t\t.dpkg.num_extracts)\n+\t\t\tprintf(\" / \");\n+\t}\n+\tprintf(\"\\r\\n\");\n+}\n+\n+static inline void dpaa2_flow_qos_entry_log(\n+\tconst char *log_info, const struct rte_flow *flow, int qos_index)\n+{\n+\tint idx;\n+\tuint8_t *key, *mask;\n+\n+\tif (!dpaa2_flow_control_log)\n+\t\treturn;\n+\n+\tprintf(\"\\r\\n%s QoS entry[%d] for TC[%d], extracts size is %d\\r\\n\",\n+\t\tlog_info, qos_index, flow->tc_id, flow->qos_real_key_size);\n+\n+\tkey = (uint8_t *)(size_t)flow->qos_rule.key_iova;\n+\tmask = (uint8_t *)(size_t)flow->qos_rule.mask_iova;\n+\n+\tprintf(\"key:\\r\\n\");\n+\tfor (idx = 0; idx < flow->qos_real_key_size; idx++)\n+\t\tprintf(\"%02x \", key[idx]);\n+\n+\tprintf(\"\\r\\nmask:\\r\\n\");\n+\tfor (idx = 0; idx < flow->qos_real_key_size; idx++)\n+\t\tprintf(\"%02x \", mask[idx]);\n+\n+\tprintf(\"\\r\\n%s QoS ipsrc: %d, ipdst: %d\\r\\n\", log_info,\n+\t\tflow->ipaddr_rule.qos_ipsrc_offset,\n+\t\tflow->ipaddr_rule.qos_ipdst_offset);\n+}\n+\n+static inline void dpaa2_flow_fs_entry_log(\n+\tconst char *log_info, const struct rte_flow *flow)\n+{\n+\tint idx;\n+\tuint8_t *key, *mask;\n+\n+\tif (!dpaa2_flow_control_log)\n+\t\treturn;\n+\n+\tprintf(\"\\r\\n%s FS/TC entry[%d] of TC[%d], extracts size is %d\\r\\n\",\n+\t\tlog_info, flow->tc_index, flow->tc_id, flow->fs_real_key_size);\n+\n+\tkey = (uint8_t *)(size_t)flow->fs_rule.key_iova;\n+\tmask = (uint8_t *)(size_t)flow->fs_rule.mask_iova;\n+\n+\tprintf(\"key:\\r\\n\");\n+\tfor (idx = 0; idx < flow->fs_real_key_size; idx++)\n+\t\tprintf(\"%02x \", key[idx]);\n+\n+\tprintf(\"\\r\\nmask:\\r\\n\");\n+\tfor (idx = 0; idx < flow->fs_real_key_size; idx++)\n+\t\tprintf(\"%02x \", mask[idx]);\n+\n+\tprintf(\"\\r\\n%s FS ipsrc: %d, ipdst: %d\\r\\n\", log_info,\n+\t\tflow->ipaddr_rule.fs_ipsrc_offset,\n+\t\tflow->ipaddr_rule.fs_ipdst_offset);\n+}\n \n static inline void dpaa2_flow_extract_key_set(\n \tstruct dpaa2_key_info *key_info, int index, uint8_t size)\n@@ -2679,6 +2864,8 @@ dpaa2_flow_entry_update(\n \t\tqos_index = curr->tc_id * priv->fs_entries +\n \t\t\tcurr->tc_index;\n \n+\t\tdpaa2_flow_qos_entry_log(\"Before update\", curr, qos_index);\n+\n \t\tret = dpni_remove_qos_entry(dpni, CMD_PRI_LOW,\n \t\t\t\tpriv->token, &curr->qos_rule);\n \t\tif (ret) {\n@@ -2782,6 +2969,8 @@ dpaa2_flow_entry_update(\n \n \t\tcurr->qos_rule.key_size = FIXED_ENTRY_SIZE;\n \n+\t\tdpaa2_flow_qos_entry_log(\"Start update\", curr, qos_index);\n+\n \t\tret = dpni_add_qos_entry(dpni, CMD_PRI_LOW,\n \t\t\t\tpriv->token, &curr->qos_rule,\n \t\t\t\tcurr->tc_id, qos_index,\n@@ -2796,6 +2985,7 @@ dpaa2_flow_entry_update(\n \t\t\tcontinue;\n \t\t}\n \n+\t\tdpaa2_flow_fs_entry_log(\"Before update\", curr);\n \t\textend = -1;\n \n \t\tret = dpni_remove_fs_entry(dpni, CMD_PRI_LOW,\n@@ -2890,6 +3080,8 @@ dpaa2_flow_entry_update(\n \t\t\tcurr->fs_real_key_size += extend;\n \t\tcurr->fs_rule.key_size = FIXED_ENTRY_SIZE;\n \n+\t\tdpaa2_flow_fs_entry_log(\"Start update\", curr);\n+\n \t\tret = dpni_add_fs_entry(dpni, CMD_PRI_LOW,\n \t\t\t\tpriv->token, curr->tc_id, curr->tc_index,\n \t\t\t\t&curr->fs_rule, &curr->action_cfg);\n@@ -3043,14 +3235,18 @@ dpaa2_generic_flow_set(struct rte_flow *flow,\n \twhile (!end_of_list) {\n \t\tswitch (actions[j].type) {\n \t\tcase RTE_FLOW_ACTION_TYPE_QUEUE:\n-\t\t\tdest_queue = (const struct rte_flow_action_queue *)(actions[j].conf);\n+\t\t\tdest_queue =\n+\t\t\t\t(const struct rte_flow_action_queue *)(actions[j].conf);\n \t\t\tflow->flow_id = dest_queue->index;\n \t\t\tflow->action = RTE_FLOW_ACTION_TYPE_QUEUE;\n \t\t\tmemset(&action, 0, sizeof(struct dpni_fs_action_cfg));\n \t\t\taction.flow_id = flow->flow_id;\n \t\t\tif (is_keycfg_configured & DPAA2_QOS_TABLE_RECONFIGURE) {\n-\t\t\t\tif (dpkg_prepare_key_cfg(&priv->extract.qos_key_extract.dpkg,\n-\t\t\t\t\t(uint8_t *)(size_t)priv->extract.qos_extract_param) < 0) {\n+\t\t\t\tdpaa2_flow_qos_table_extracts_log(priv);\n+\t\t\t\tif (dpkg_prepare_key_cfg(\n+\t\t\t\t\t&priv->extract.qos_key_extract.dpkg,\n+\t\t\t\t\t(uint8_t *)(size_t)priv->extract.qos_extract_param)\n+\t\t\t\t\t< 0) {\n \t\t\t\t\tDPAA2_PMD_ERR(\n \t\t\t\t\t\"Unable to prepare extract parameters\");\n \t\t\t\t\treturn -1;\n@@ -3059,7 +3255,8 @@ dpaa2_generic_flow_set(struct rte_flow *flow,\n \t\t\t\tmemset(&qos_cfg, 0, sizeof(struct dpni_qos_tbl_cfg));\n \t\t\t\tqos_cfg.discard_on_miss = true;\n \t\t\t\tqos_cfg.keep_entries = true;\n-\t\t\t\tqos_cfg.key_cfg_iova = (size_t)priv->extract.qos_extract_param;\n+\t\t\t\tqos_cfg.key_cfg_iova =\n+\t\t\t\t\t(size_t)priv->extract.qos_extract_param;\n \t\t\t\tret = dpni_set_qos_table(dpni, CMD_PRI_LOW,\n \t\t\t\t\t\tpriv->token, &qos_cfg);\n \t\t\t\tif (ret < 0) {\n@@ -3070,6 +3267,7 @@ dpaa2_generic_flow_set(struct rte_flow *flow,\n \t\t\t\t}\n \t\t\t}\n \t\t\tif (is_keycfg_configured & DPAA2_FS_TABLE_RECONFIGURE) {\n+\t\t\t\tdpaa2_flow_fs_table_extracts_log(priv, flow->tc_id);\n \t\t\t\tif (dpkg_prepare_key_cfg(\n \t\t\t\t&priv->extract.tc_key_extract[flow->tc_id].dpkg,\n \t\t\t\t(uint8_t *)(size_t)priv->extract\n@@ -3136,6 +3334,8 @@ dpaa2_generic_flow_set(struct rte_flow *flow,\n \n \t\t\tflow->qos_rule.key_size = FIXED_ENTRY_SIZE;\n \n+\t\t\tdpaa2_flow_qos_entry_log(\"Start add\", flow, qos_index);\n+\n \t\t\tret = dpni_add_qos_entry(dpni, CMD_PRI_LOW,\n \t\t\t\t\t\tpriv->token, &flow->qos_rule,\n \t\t\t\t\t\tflow->tc_id, qos_index,\n@@ -3185,6 +3385,8 @@ dpaa2_generic_flow_set(struct rte_flow *flow,\n \n \t\t\tflow->fs_rule.key_size = FIXED_ENTRY_SIZE;\n \n+\t\t\tdpaa2_flow_fs_entry_log(\"Start add\", flow);\n+\n \t\t\tret = dpni_add_fs_entry(dpni, CMD_PRI_LOW, priv->token,\n \t\t\t\t\t\tflow->tc_id, flow->tc_index,\n \t\t\t\t\t\t&flow->fs_rule, &action);\n@@ -3483,6 +3685,9 @@ struct rte_flow *dpaa2_flow_create(struct rte_eth_dev *dev,\n \tsize_t key_iova = 0, mask_iova = 0;\n \tint ret;\n \n+\tdpaa2_flow_control_log =\n+\t\tgetenv(\"DPAA2_FLOW_CONTROL_LOG\");\n+\n \tflow = rte_zmalloc(NULL, sizeof(struct rte_flow), RTE_CACHE_LINE_SIZE);\n \tif (!flow) {\n \t\tDPAA2_PMD_ERR(\"Failure to allocate memory for flow\");\n",
    "prefixes": [
        "v2",
        "21/29"
    ]
}