get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 50573,
    "url": "http://patches.dpdk.org/api/patches/50573/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20190228055650.25237-15-qi.z.zhang@intel.com/",
    "project": {
        "id": 1,
        "url": "http://patches.dpdk.org/api/projects/1/?format=api",
        "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",
        "list_archive_url": "https://inbox.dpdk.org/dev",
        "list_archive_url_format": "https://inbox.dpdk.org/dev/{}",
        "commit_url_format": ""
    },
    "msgid": "<20190228055650.25237-15-qi.z.zhang@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20190228055650.25237-15-qi.z.zhang@intel.com",
    "date": "2019-02-28T05:56:27",
    "name": "[14/37] net/ice/base: add MAC filter with marker and counter",
    "commit_ref": null,
    "pull_url": null,
    "state": "changes-requested",
    "archived": true,
    "hash": "2589b441adedf9e5443c5af738cc460025fb31ca",
    "submitter": {
        "id": 504,
        "url": "http://patches.dpdk.org/api/people/504/?format=api",
        "name": "Qi Zhang",
        "email": "qi.z.zhang@intel.com"
    },
    "delegate": {
        "id": 319,
        "url": "http://patches.dpdk.org/api/users/319/?format=api",
        "username": "fyigit",
        "first_name": "Ferruh",
        "last_name": "Yigit",
        "email": "ferruh.yigit@amd.com"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/20190228055650.25237-15-qi.z.zhang@intel.com/mbox/",
    "series": [
        {
            "id": 3567,
            "url": "http://patches.dpdk.org/api/series/3567/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=3567",
            "date": "2019-02-28T05:56:13",
            "name": "share code update.",
            "version": 1,
            "mbox": "http://patches.dpdk.org/series/3567/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/50573/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/50573/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@dpdk.org",
        "Delivered-To": "patchwork@dpdk.org",
        "Received": [
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 5A11A5B16;\n\tThu, 28 Feb 2019 06:55:32 +0100 (CET)",
            "from mga12.intel.com (mga12.intel.com [192.55.52.136])\n\tby dpdk.org (Postfix) with ESMTP id 5E8434D3A\n\tfor <dev@dpdk.org>; Thu, 28 Feb 2019 06:55:24 +0100 (CET)",
            "from fmsmga006.fm.intel.com ([10.253.24.20])\n\tby fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t27 Feb 2019 21:55:24 -0800",
            "from dpdk51.sh.intel.com ([10.67.110.190])\n\tby fmsmga006.fm.intel.com with ESMTP; 27 Feb 2019 21:55:22 -0800"
        ],
        "X-Amp-Result": "SKIPPED(no attachment in message)",
        "X-Amp-File-Uploaded": "False",
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.58,422,1544515200\"; d=\"scan'208\";a=\"322784311\"",
        "From": "Qi Zhang <qi.z.zhang@intel.com>",
        "To": "wenzhuo.lu@intel.com,\n\tqiming.yang@intel.com",
        "Cc": "paul.m.stillwell.jr@intel.com, dev@dpdk.org, ferruh.yigit@intel.com,\n\tQi Zhang <qi.z.zhang@intel.com>",
        "Date": "Thu, 28 Feb 2019 13:56:27 +0800",
        "Message-Id": "<20190228055650.25237-15-qi.z.zhang@intel.com>",
        "X-Mailer": "git-send-email 2.13.6",
        "In-Reply-To": "<20190228055650.25237-1-qi.z.zhang@intel.com>",
        "References": "<20190228055650.25237-1-qi.z.zhang@intel.com>",
        "Subject": "[dpdk-dev] [PATCH 14/37] net/ice/base: add MAC filter with marker\n\tand counter",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.15",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Archive": "<http://mails.dpdk.org/archives/dev/>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "1. ice_add_mac_with_sw_marker - add filter with software marker.\n2. ice_add_mac_with_counter - add filter with counter enabled.\n\nSigned-off-by: Paul M Stillwell Jr <paul.m.stillwell.jr@intel.com>\nSigned-off-by: Qi Zhang <qi.z.zhang@intel.com>\n---\n drivers/net/ice/base/ice_switch.c | 328 ++++++++++++++++++++++++++++++++++++++\n drivers/net/ice/base/ice_switch.h |   5 +\n 2 files changed, 333 insertions(+)",
    "diff": "diff --git a/drivers/net/ice/base/ice_switch.c b/drivers/net/ice/base/ice_switch.c\nindex e4024a0b0..bfcb33ea6 100644\n--- a/drivers/net/ice/base/ice_switch.c\n+++ b/drivers/net/ice/base/ice_switch.c\n@@ -1338,6 +1338,95 @@ ice_add_marker_act(struct ice_hw *hw, struct ice_fltr_mgmt_list_entry *m_ent,\n \treturn status;\n }\n \n+/**\n+ * ice_add_counter_act - add/update filter rule with counter action\n+ * @hw: pointer to the hardware structure\n+ * @m_ent: the management entry for which counter needs to be added\n+ * @counter_id: VLAN counter ID returned as part of allocate resource\n+ * @l_id: large action resource ID\n+ */\n+static enum ice_status\n+ice_add_counter_act(struct ice_hw *hw, struct ice_fltr_mgmt_list_entry *m_ent,\n+\t\t    u16 counter_id, u16 l_id)\n+{\n+\tstruct ice_aqc_sw_rules_elem *lg_act;\n+\tstruct ice_aqc_sw_rules_elem *rx_tx;\n+\tenum ice_status status;\n+\t/* 2 actions will be added while adding a large action counter */\n+\tconst int num_acts = 2;\n+\tu16 lg_act_size;\n+\tu16 rules_size;\n+\tu16 f_rule_id;\n+\tu32 act;\n+\tu16 id;\n+\n+\tif (m_ent->fltr_info.lkup_type != ICE_SW_LKUP_MAC)\n+\t\treturn ICE_ERR_PARAM;\n+\n+\t/* Create two back-to-back switch rules and submit them to the HW using\n+\t * one memory buffer:\n+\t * 1. Large Action\n+\t * 2. Look up Tx Rx\n+\t */\n+\tlg_act_size = (u16)ICE_SW_RULE_LG_ACT_SIZE(num_acts);\n+\trules_size = lg_act_size + ICE_SW_RULE_RX_TX_ETH_HDR_SIZE;\n+\tlg_act = (struct ice_aqc_sw_rules_elem *)ice_malloc(hw,\n+\t\t\t\t\t\t\t\t rules_size);\n+\tif (!lg_act)\n+\t\treturn ICE_ERR_NO_MEMORY;\n+\n+\trx_tx = (struct ice_aqc_sw_rules_elem *)\n+\t\t((u8 *)lg_act + lg_act_size);\n+\n+\t/* Fill in the first switch rule i.e. large action */\n+\tlg_act->type = CPU_TO_LE16(ICE_AQC_SW_RULES_T_LG_ACT);\n+\tlg_act->pdata.lg_act.index = CPU_TO_LE16(l_id);\n+\tlg_act->pdata.lg_act.size = CPU_TO_LE16(num_acts);\n+\n+\t/* First action VSI forwarding or VSI list forwarding depending on how\n+\t * many VSIs\n+\t */\n+\tid = (m_ent->vsi_count > 1) ?  m_ent->fltr_info.fwd_id.vsi_list_id :\n+\t\tm_ent->fltr_info.fwd_id.hw_vsi_id;\n+\n+\tact = ICE_LG_ACT_VSI_FORWARDING | ICE_LG_ACT_VALID_BIT;\n+\tact |= (id << ICE_LG_ACT_VSI_LIST_ID_S) &\n+\t\tICE_LG_ACT_VSI_LIST_ID_M;\n+\tif (m_ent->vsi_count > 1)\n+\t\tact |= ICE_LG_ACT_VSI_LIST;\n+\tlg_act->pdata.lg_act.act[0] = CPU_TO_LE32(act);\n+\n+\t/* Second action counter ID */\n+\tact = ICE_LG_ACT_STAT_COUNT;\n+\tact |= (counter_id << ICE_LG_ACT_STAT_COUNT_S) &\n+\t\tICE_LG_ACT_STAT_COUNT_M;\n+\tlg_act->pdata.lg_act.act[1] = CPU_TO_LE32(act);\n+\n+\t/* call the fill switch rule to fill the lookup Tx Rx structure */\n+\tice_fill_sw_rule(hw, &m_ent->fltr_info, rx_tx,\n+\t\t\t ice_aqc_opc_update_sw_rules);\n+\n+\tact = ICE_SINGLE_ACT_PTR;\n+\tact |= (l_id << ICE_SINGLE_ACT_PTR_VAL_S) & ICE_SINGLE_ACT_PTR_VAL_M;\n+\trx_tx->pdata.lkup_tx_rx.act = CPU_TO_LE32(act);\n+\n+\t/* Use the filter rule ID of the previously created rule with single\n+\t * act. Once the update happens, hardware will treat this as large\n+\t * action\n+\t */\n+\tf_rule_id = m_ent->fltr_info.fltr_rule_id;\n+\trx_tx->pdata.lkup_tx_rx.index = CPU_TO_LE16(f_rule_id);\n+\n+\tstatus = ice_aq_sw_rules(hw, lg_act, rules_size, 2,\n+\t\t\t\t ice_aqc_opc_update_sw_rules, NULL);\n+\tif (!status) {\n+\t\tm_ent->lg_act_idx = l_id;\n+\t\tm_ent->counter_index = counter_id;\n+\t}\n+\n+\tice_free(hw, lg_act);\n+\treturn status;\n+}\n \n /**\n  * ice_create_vsi_list_map\n@@ -3419,6 +3508,245 @@ enum ice_status ice_free_vlan_res_counter(struct ice_hw *hw, u16 counter_id)\n }\n \n /**\n+ * ice_alloc_res_lg_act - add large action resource\n+ * @hw: pointer to the hardware structure\n+ * @l_id: large action ID to fill it in\n+ * @num_acts: number of actions to hold with a large action entry\n+ */\n+static enum ice_status\n+ice_alloc_res_lg_act(struct ice_hw *hw, u16 *l_id, u16 num_acts)\n+{\n+\tstruct ice_aqc_alloc_free_res_elem *sw_buf;\n+\tenum ice_status status;\n+\tu16 buf_len;\n+\n+\tif (num_acts > ICE_MAX_LG_ACT || num_acts == 0)\n+\t\treturn ICE_ERR_PARAM;\n+\n+\t/* Allocate resource for large action */\n+\tbuf_len = sizeof(*sw_buf);\n+\tsw_buf = (struct ice_aqc_alloc_free_res_elem *)\n+\t\tice_malloc(hw, buf_len);\n+\tif (!sw_buf)\n+\t\treturn ICE_ERR_NO_MEMORY;\n+\n+\tsw_buf->num_elems = CPU_TO_LE16(1);\n+\n+\t/* If num_acts is 1, use ICE_AQC_RES_TYPE_WIDE_TABLE_1.\n+\t * If num_acts is 2, use ICE_AQC_RES_TYPE_WIDE_TABLE_3.\n+\t * If num_acts is greater than 2, then use\n+\t * ICE_AQC_RES_TYPE_WIDE_TABLE_4.\n+\t * The num_acts cannot exceed 4. This was ensured at the\n+\t * beginning of the function.\n+\t */\n+\tif (num_acts == 1)\n+\t\tsw_buf->res_type = CPU_TO_LE16(ICE_AQC_RES_TYPE_WIDE_TABLE_1);\n+\telse if (num_acts == 2)\n+\t\tsw_buf->res_type = CPU_TO_LE16(ICE_AQC_RES_TYPE_WIDE_TABLE_2);\n+\telse\n+\t\tsw_buf->res_type = CPU_TO_LE16(ICE_AQC_RES_TYPE_WIDE_TABLE_4);\n+\n+\tstatus = ice_aq_alloc_free_res(hw, 1, sw_buf, buf_len,\n+\t\t\t\t       ice_aqc_opc_alloc_res, NULL);\n+\tif (!status)\n+\t\t*l_id = LE16_TO_CPU(sw_buf->elem[0].e.sw_resp);\n+\n+\tice_free(hw, sw_buf);\n+\treturn status;\n+}\n+\n+/**\n+ * ice_add_mac_with_sw_marker - add filter with sw marker\n+ * @hw: pointer to the hardware structure\n+ * @f_info: filter info structure containing the MAC filter information\n+ * @sw_marker: sw marker to tag the Rx descriptor with\n+ */\n+enum ice_status\n+ice_add_mac_with_sw_marker(struct ice_hw *hw, struct ice_fltr_info *f_info,\n+\t\t\t   u16 sw_marker)\n+{\n+\tstruct ice_switch_info *sw = hw->switch_info;\n+\tstruct ice_fltr_mgmt_list_entry *m_entry;\n+\tstruct ice_fltr_list_entry fl_info;\n+\tstruct LIST_HEAD_TYPE l_head;\n+\tstruct ice_lock *rule_lock;\t/* Lock to protect filter rule list */\n+\tenum ice_status ret;\n+\tbool entry_exists;\n+\tu16 lg_act_id;\n+\n+\tif (f_info->fltr_act != ICE_FWD_TO_VSI)\n+\t\treturn ICE_ERR_PARAM;\n+\n+\tif (f_info->lkup_type != ICE_SW_LKUP_MAC)\n+\t\treturn ICE_ERR_PARAM;\n+\n+\tif (sw_marker == ICE_INVAL_SW_MARKER_ID)\n+\t\treturn ICE_ERR_PARAM;\n+\n+\tif (!ice_is_vsi_valid(hw, f_info->vsi_handle))\n+\t\treturn ICE_ERR_PARAM;\n+\tf_info->fwd_id.hw_vsi_id = ice_get_hw_vsi_num(hw, f_info->vsi_handle);\n+\n+\t/* Add filter if it doesn't exist so then the adding of large\n+\t * action always results in update\n+\t */\n+\n+\tINIT_LIST_HEAD(&l_head);\n+\tfl_info.fltr_info = *f_info;\n+\tLIST_ADD(&fl_info.list_entry, &l_head);\n+\n+\tentry_exists = false;\n+\tret = ice_add_mac(hw, &l_head);\n+\tif (ret == ICE_ERR_ALREADY_EXISTS)\n+\t\tentry_exists = true;\n+\telse if (ret)\n+\t\treturn ret;\n+\n+\trule_lock = &sw->recp_list[ICE_SW_LKUP_MAC].filt_rule_lock;\n+\tice_acquire_lock(rule_lock);\n+\t/* Get the book keeping entry for the filter */\n+\tm_entry = ice_find_rule_entry(hw, ICE_SW_LKUP_MAC, f_info);\n+\tif (!m_entry)\n+\t\tgoto exit_error;\n+\n+\t/* If counter action was enabled for this rule then don't enable\n+\t * sw marker large action\n+\t */\n+\tif (m_entry->counter_index != ICE_INVAL_COUNTER_ID) {\n+\t\tret = ICE_ERR_PARAM;\n+\t\tgoto exit_error;\n+\t}\n+\n+\t/* if same marker was added before */\n+\tif (m_entry->sw_marker_id == sw_marker) {\n+\t\tret = ICE_ERR_ALREADY_EXISTS;\n+\t\tgoto exit_error;\n+\t}\n+\n+\t/* Allocate a hardware table entry to hold large act. Three actions\n+\t * for marker based large action\n+\t */\n+\tret = ice_alloc_res_lg_act(hw, &lg_act_id, 3);\n+\tif (ret)\n+\t\tgoto exit_error;\n+\n+\tif (lg_act_id == ICE_INVAL_LG_ACT_INDEX)\n+\t\tgoto exit_error;\n+\n+\t/* Update the switch rule to add the marker action */\n+\tret = ice_add_marker_act(hw, m_entry, sw_marker, lg_act_id);\n+\tif (!ret) {\n+\t\tice_release_lock(rule_lock);\n+\t\treturn ret;\n+\t}\n+\n+exit_error:\n+\tice_release_lock(rule_lock);\n+\t/* only remove entry if it did not exist previously */\n+\tif (!entry_exists)\n+\t\tret = ice_remove_mac(hw, &l_head);\n+\n+\treturn ret;\n+}\n+\n+/**\n+ * ice_add_mac_with_counter - add filter with counter enabled\n+ * @hw: pointer to the hardware structure\n+ * @f_info: pointer to filter info structure containing the MAC filter\n+ *          information\n+ */\n+enum ice_status\n+ice_add_mac_with_counter(struct ice_hw *hw, struct ice_fltr_info *f_info)\n+{\n+\tstruct ice_switch_info *sw = hw->switch_info;\n+\tstruct ice_fltr_mgmt_list_entry *m_entry;\n+\tstruct ice_fltr_list_entry fl_info;\n+\tstruct LIST_HEAD_TYPE l_head;\n+\tstruct ice_lock *rule_lock;\t/* Lock to protect filter rule list */\n+\tenum ice_status ret;\n+\tbool entry_exist;\n+\tu16 counter_id;\n+\tu16 lg_act_id;\n+\n+\tif (f_info->fltr_act != ICE_FWD_TO_VSI)\n+\t\treturn ICE_ERR_PARAM;\n+\n+\tif (f_info->lkup_type != ICE_SW_LKUP_MAC)\n+\t\treturn ICE_ERR_PARAM;\n+\n+\tif (!ice_is_vsi_valid(hw, f_info->vsi_handle))\n+\t\treturn ICE_ERR_PARAM;\n+\tf_info->fwd_id.hw_vsi_id = ice_get_hw_vsi_num(hw, f_info->vsi_handle);\n+\n+\tentry_exist = false;\n+\n+\trule_lock = &sw->recp_list[ICE_SW_LKUP_MAC].filt_rule_lock;\n+\n+\t/* Add filter if it doesn't exist so then the adding of large\n+\t * action always results in update\n+\t */\n+\tINIT_LIST_HEAD(&l_head);\n+\n+\tfl_info.fltr_info = *f_info;\n+\tLIST_ADD(&fl_info.list_entry, &l_head);\n+\n+\tret = ice_add_mac(hw, &l_head);\n+\tif (ret == ICE_ERR_ALREADY_EXISTS)\n+\t\tentry_exist = true;\n+\telse if (ret)\n+\t\treturn ret;\n+\n+\tice_acquire_lock(rule_lock);\n+\tm_entry = ice_find_rule_entry(hw, ICE_SW_LKUP_MAC, f_info);\n+\tif (!m_entry) {\n+\t\tret = ICE_ERR_BAD_PTR;\n+\t\tgoto exit_error;\n+\t}\n+\n+\t/* Don't enable counter for a filter for which sw marker was enabled */\n+\tif (m_entry->sw_marker_id != ICE_INVAL_SW_MARKER_ID) {\n+\t\tret = ICE_ERR_PARAM;\n+\t\tgoto exit_error;\n+\t}\n+\n+\t/* If a counter was already enabled then don't need to add again */\n+\tif (m_entry->counter_index != ICE_INVAL_COUNTER_ID) {\n+\t\tret = ICE_ERR_ALREADY_EXISTS;\n+\t\tgoto exit_error;\n+\t}\n+\n+\t/* Allocate a hardware table entry to VLAN counter */\n+\tret = ice_alloc_vlan_res_counter(hw, &counter_id);\n+\tif (ret)\n+\t\tgoto exit_error;\n+\n+\t/* Allocate a hardware table entry to hold large act. Two actions for\n+\t * counter based large action\n+\t */\n+\tret = ice_alloc_res_lg_act(hw, &lg_act_id, 2);\n+\tif (ret)\n+\t\tgoto exit_error;\n+\n+\tif (lg_act_id == ICE_INVAL_LG_ACT_INDEX)\n+\t\tgoto exit_error;\n+\n+\t/* Update the switch rule to add the counter action */\n+\tret = ice_add_counter_act(hw, m_entry, counter_id, lg_act_id);\n+\tif (!ret) {\n+\t\tice_release_lock(rule_lock);\n+\t\treturn ret;\n+\t}\n+\n+exit_error:\n+\tice_release_lock(rule_lock);\n+\t/* only remove entry if it did not exist previously */\n+\tif (!entry_exist)\n+\t\tret = ice_remove_mac(hw, &l_head);\n+\n+\treturn ret;\n+}\n+\n+/**\n  * ice_replay_vsi_fltr - Replay filters for requested VSI\n  * @hw: pointer to the hardware structure\n  * @vsi_handle: driver VSI handle\ndiff --git a/drivers/net/ice/base/ice_switch.h b/drivers/net/ice/base/ice_switch.h\nindex 0d70b38f4..b396a486c 100644\n--- a/drivers/net/ice/base/ice_switch.h\n+++ b/drivers/net/ice/base/ice_switch.h\n@@ -377,6 +377,11 @@ enum ice_status\n ice_remove_mac_vlan(struct ice_hw *hw, struct LIST_HEAD_TYPE *v_list);\n #endif /* !NO_MACVLAN_SUPPORT */\n \n+enum ice_status\n+ice_add_mac_with_sw_marker(struct ice_hw *hw, struct ice_fltr_info *f_info,\n+\t\t\t   u16 sw_marker);\n+enum ice_status\n+ice_add_mac_with_counter(struct ice_hw *hw, struct ice_fltr_info *f_info);\n void ice_remove_vsi_fltr(struct ice_hw *hw, u16 vsi_handle);\n \n \n",
    "prefixes": [
        "14/37"
    ]
}