get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 860169,
    "url": "http://patchwork.ozlabs.org/api/patches/860169/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/intel-wired-lan/patch/20180112193251.11739-12-jeffrey.t.kirsher@intel.com/",
    "project": {
        "id": 46,
        "url": "http://patchwork.ozlabs.org/api/projects/46/?format=api",
        "name": "Intel Wired Ethernet development",
        "link_name": "intel-wired-lan",
        "list_id": "intel-wired-lan.osuosl.org",
        "list_email": "intel-wired-lan@osuosl.org",
        "web_url": "",
        "scm_url": "",
        "webscm_url": "",
        "list_archive_url": "",
        "list_archive_url_format": "",
        "commit_url_format": ""
    },
    "msgid": "<20180112193251.11739-12-jeffrey.t.kirsher@intel.com>",
    "list_archive_url": null,
    "date": "2018-01-12T19:32:51",
    "name": "[12/12] i40e: Add and delete cloud filter",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "eedfdd336fd01526e4ab325d1bcbbabd7a67c63c",
    "submitter": {
        "id": 473,
        "url": "http://patchwork.ozlabs.org/api/people/473/?format=api",
        "name": "Kirsher, Jeffrey T",
        "email": "jeffrey.t.kirsher@intel.com"
    },
    "delegate": {
        "id": 68,
        "url": "http://patchwork.ozlabs.org/api/users/68/?format=api",
        "username": "jtkirshe",
        "first_name": "Jeff",
        "last_name": "Kirsher",
        "email": "jeffrey.t.kirsher@intel.com"
    },
    "mbox": "http://patchwork.ozlabs.org/project/intel-wired-lan/patch/20180112193251.11739-12-jeffrey.t.kirsher@intel.com/mbox/",
    "series": [
        {
            "id": 23043,
            "url": "http://patchwork.ozlabs.org/api/series/23043/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/intel-wired-lan/list/?series=23043",
            "date": "2018-01-12T19:32:45",
            "name": "[01/12] i40evf: Fix link up issue when queues are disabled",
            "version": 1,
            "mbox": "http://patchwork.ozlabs.org/series/23043/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/860169/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/860169/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<intel-wired-lan-bounces@osuosl.org>",
        "X-Original-To": [
            "incoming@patchwork.ozlabs.org",
            "intel-wired-lan@lists.osuosl.org"
        ],
        "Delivered-To": [
            "patchwork-incoming@bilbo.ozlabs.org",
            "intel-wired-lan@lists.osuosl.org"
        ],
        "Authentication-Results": "ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=osuosl.org\n\t(client-ip=140.211.166.138; helo=whitealder.osuosl.org;\n\tenvelope-from=intel-wired-lan-bounces@osuosl.org;\n\treceiver=<UNKNOWN>)",
        "Received": [
            "from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3zJCZs2YPQz9s7c\n\tfor <incoming@patchwork.ozlabs.org>;\n\tSat, 13 Jan 2018 06:33:09 +1100 (AEDT)",
            "from localhost (localhost [127.0.0.1])\n\tby whitealder.osuosl.org (Postfix) with ESMTP id A113188E4C;\n\tFri, 12 Jan 2018 19:33:07 +0000 (UTC)",
            "from whitealder.osuosl.org ([127.0.0.1])\n\tby localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)\n\twith ESMTP id G39C6Q5argCt; Fri, 12 Jan 2018 19:33:02 +0000 (UTC)",
            "from ash.osuosl.org (ash.osuosl.org [140.211.166.34])\n\tby whitealder.osuosl.org (Postfix) with ESMTP id 230A088EEF;\n\tFri, 12 Jan 2018 19:32:59 +0000 (UTC)",
            "from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133])\n\tby ash.osuosl.org (Postfix) with ESMTP id 20B041CEB08\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tFri, 12 Jan 2018 19:32:53 +0000 (UTC)",
            "from localhost (localhost [127.0.0.1])\n\tby hemlock.osuosl.org (Postfix) with ESMTP id 1C7AD89ED3\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tFri, 12 Jan 2018 19:32:53 +0000 (UTC)",
            "from hemlock.osuosl.org ([127.0.0.1])\n\tby localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)\n\twith ESMTP id 27eyqcP9DBVy for <intel-wired-lan@lists.osuosl.org>;\n\tFri, 12 Jan 2018 19:32:50 +0000 (UTC)",
            "from mga02.intel.com (mga02.intel.com [134.134.136.20])\n\tby hemlock.osuosl.org (Postfix) with ESMTPS id 2E70089F17\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tFri, 12 Jan 2018 19:32:49 +0000 (UTC)",
            "from orsmga003.jf.intel.com ([10.7.209.27])\n\tby orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t12 Jan 2018 11:32:47 -0800",
            "from jtkirshe-nuc.jf.intel.com ([134.134.177.151])\n\tby orsmga003.jf.intel.com with ESMTP; 12 Jan 2018 11:32:47 -0800"
        ],
        "X-Virus-Scanned": [
            "amavisd-new at osuosl.org",
            "amavisd-new at osuosl.org"
        ],
        "X-Greylist": "domain auto-whitelisted by SQLgrey-1.7.6",
        "X-Amp-Result": "SKIPPED(no attachment in message)",
        "X-Amp-File-Uploaded": "False",
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.46,350,1511856000\"; d=\"scan'208\";a=\"19654894\"",
        "From": "Jeff Kirsher <jeffrey.t.kirsher@intel.com>",
        "To": "intel-wired-lan@lists.osuosl.org",
        "Date": "Fri, 12 Jan 2018 11:32:51 -0800",
        "Message-Id": "<20180112193251.11739-12-jeffrey.t.kirsher@intel.com>",
        "X-Mailer": "git-send-email 2.14.3",
        "In-Reply-To": "<20180112193251.11739-1-jeffrey.t.kirsher@intel.com>",
        "References": "<20180112193251.11739-1-jeffrey.t.kirsher@intel.com>",
        "Subject": "[Intel-wired-lan] [PATCH 12/12] i40e: Add and delete cloud filter",
        "X-BeenThere": "intel-wired-lan@osuosl.org",
        "X-Mailman-Version": "2.1.24",
        "Precedence": "list",
        "List-Id": "Intel Wired Ethernet Linux Kernel Driver Development\n\t<intel-wired-lan.osuosl.org>",
        "List-Unsubscribe": "<https://lists.osuosl.org/mailman/options/intel-wired-lan>, \n\t<mailto:intel-wired-lan-request@osuosl.org?subject=unsubscribe>",
        "List-Archive": "<http://lists.osuosl.org/pipermail/intel-wired-lan/>",
        "List-Post": "<mailto:intel-wired-lan@osuosl.org>",
        "List-Help": "<mailto:intel-wired-lan-request@osuosl.org?subject=help>",
        "List-Subscribe": "<https://lists.osuosl.org/mailman/listinfo/intel-wired-lan>, \n\t<mailto:intel-wired-lan-request@osuosl.org?subject=subscribe>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=\"us-ascii\"",
        "Content-Transfer-Encoding": "7bit",
        "Errors-To": "intel-wired-lan-bounces@osuosl.org",
        "Sender": "\"Intel-wired-lan\" <intel-wired-lan-bounces@osuosl.org>"
    },
    "content": "From: Avinash Dayanand <avinash.dayanand@intel.com>\n\nThis patch provides support to add or delete cloud filter for queue\nchannels created for ADq on VF.\nWe are using the HW's cloud filter feature and programming it to act\nas a TC filter applied to a group of queues.\n\nThere are two possible modes for a VF when applying a cloud filter\n1. Basic Mode:\tIntended to apply filters that don't need a VF to be\n\t\tTrusted. This would include the following\n\t\t  Dest MAC + L4 port\n\t\t  Dest MAC + VLAN + L4 port\n2. Advanced Mode: This mode is only for filters with combination that\n\t\t  requires VF to be Trusted.\n\t\t  Dest IP + L4 port\n\nWhen cloud filters are applied on a Trusted VF and for some reason\nthe same VF is later made as unTrusted then all cloud filters\nwill be deleted. All cloud filters has to be re-applied in\nsuch a case.\nCloud filters are also deleted when queue channel is deleted.\n\nTesting-Hints:",
    "diff": "=============\n1. Adding Basic Mode filter should be possible on a VF in\n\tNon-Trusted mode.\n2. In Advanced mode all filters should be able to be created.\n\nSteps:\n======\n1. Enable ADq and create TCs using TC mqprio command\n2. Apply cloud filter.\n3. Turn-off the spoof check.\n4. Pass traffic.\n\nExample:\n========\n1. tc qdisc add dev enp4s2 root mqprio num_tc 4 map 0 0 0 0 1 2 2 3\\\n\tqueues 2@0 2@2 1@4 1@5 hw 1 mode channel\n2. tc qdisc add dev enp4s2 ingress\n3. ethtool -K enp4s2 hw-tc-offload on\n4. ip link set ens261f0 vf 0 spoofchk off\n5. tc filter add dev enp4s2 protocol ip parent ffff: prio 1 flower\\\n\tdst_ip 192.168.3.5/32 ip_proto udp dst_port 25 skip_sw hw_tc 2\n\nSigned-off-by: Avinash Dayanand <avinash.dayanand@intel.com>\n---\n drivers/net/ethernet/intel/i40e/i40e.h             |   6 +\n drivers/net/ethernet/intel/i40e/i40e_main.c        |  16 +-\n drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c | 458 ++++++++++++++++++++-\n drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.h |   2 +\n 4 files changed, 470 insertions(+), 12 deletions(-)\n\ndiff --git a/drivers/net/ethernet/intel/i40e/i40e.h b/drivers/net/ethernet/intel/i40e/i40e.h\nindex ebe795a7f5f9..4b81a18972e0 100644\n--- a/drivers/net/ethernet/intel/i40e/i40e.h\n+++ b/drivers/net/ethernet/intel/i40e/i40e.h\n@@ -1108,4 +1108,10 @@ static inline bool i40e_enabled_xdp_vsi(struct i40e_vsi *vsi)\n \n int i40e_create_queue_channel(struct i40e_vsi *vsi, struct i40e_channel *ch);\n int i40e_set_bw_limit(struct i40e_vsi *vsi, u16 seid, u64 max_tx_rate);\n+int i40e_add_del_cloud_filter(struct i40e_vsi *vsi,\n+\t\t\t      struct i40e_cloud_filter *filter,\n+\t\t\t      bool add);\n+int i40e_add_del_cloud_filter_big_buf(struct i40e_vsi *vsi,\n+\t\t\t\t      struct i40e_cloud_filter *filter,\n+\t\t\t\t      bool add);\n #endif /* _I40E_H_ */\ndiff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c\nindex 47bccc3d08a6..fcec88dd467e 100644\n--- a/drivers/net/ethernet/intel/i40e/i40e_main.c\n+++ b/drivers/net/ethernet/intel/i40e/i40e_main.c\n@@ -69,12 +69,6 @@ static int i40e_reset(struct i40e_pf *pf);\n static void i40e_rebuild(struct i40e_pf *pf, bool reinit, bool lock_acquired);\n static void i40e_fdir_sb_setup(struct i40e_pf *pf);\n static int i40e_veb_get_bw_info(struct i40e_veb *veb);\n-static int i40e_add_del_cloud_filter(struct i40e_vsi *vsi,\n-\t\t\t\t     struct i40e_cloud_filter *filter,\n-\t\t\t\t     bool add);\n-static int i40e_add_del_cloud_filter_big_buf(struct i40e_vsi *vsi,\n-\t\t\t\t\t     struct i40e_cloud_filter *filter,\n-\t\t\t\t\t     bool add);\n static int i40e_get_capabilities(struct i40e_pf *pf,\n \t\t\t\t enum i40e_admin_queue_opc list_type);\n \n@@ -6922,8 +6916,8 @@ i40e_set_cld_element(struct i40e_cloud_filter *filter,\n  * Add or delete a cloud filter for a specific flow spec.\n  * Returns 0 if the filter were successfully added.\n  **/\n-static int i40e_add_del_cloud_filter(struct i40e_vsi *vsi,\n-\t\t\t\t     struct i40e_cloud_filter *filter, bool add)\n+int i40e_add_del_cloud_filter(struct i40e_vsi *vsi,\n+\t\t\t      struct i40e_cloud_filter *filter, bool add)\n {\n \tstruct i40e_aqc_cloud_filters_element_data cld_filter;\n \tstruct i40e_pf *pf = vsi->back;\n@@ -6989,9 +6983,9 @@ static int i40e_add_del_cloud_filter(struct i40e_vsi *vsi,\n  * Add or delete a cloud filter for a specific flow spec using big buffer.\n  * Returns 0 if the filter were successfully added.\n  **/\n-static int i40e_add_del_cloud_filter_big_buf(struct i40e_vsi *vsi,\n-\t\t\t\t\t     struct i40e_cloud_filter *filter,\n-\t\t\t\t\t     bool add)\n+int i40e_add_del_cloud_filter_big_buf(struct i40e_vsi *vsi,\n+\t\t\t\t      struct i40e_cloud_filter *filter,\n+\t\t\t\t      bool add)\n {\n \tstruct i40e_aqc_cloud_filters_element_bb cld_filter;\n \tstruct i40e_pf *pf = vsi->back;\ndiff --git a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c\nindex 989664a431ed..d0c8183ef726 100644\n--- a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c\n+++ b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c\n@@ -2916,6 +2916,440 @@ static int i40e_vc_disable_vlan_stripping(struct i40e_vf *vf, u8 *msg,\n \t\t\t\t       aq_ret);\n }\n \n+/**\n+ * i40e_validate_cloud_filter\n+ * @mask: mask for TC filter\n+ * @data: data for TC filter\n+ *\n+ * This function validates cloud filter programmed as TC filter for ADq\n+ **/\n+static int i40e_validate_cloud_filter(struct i40e_vf *vf,\n+\t\t\t\t      struct virtchnl_filter *tc_filter)\n+{\n+\tstruct virtchnl_l4_spec mask = tc_filter->mask.tcp_spec;\n+\tstruct virtchnl_l4_spec data = tc_filter->data.tcp_spec;\n+\tstruct i40e_pf *pf = vf->pf;\n+\tstruct i40e_vsi *vsi = NULL;\n+\tstruct i40e_mac_filter *f;\n+\tstruct hlist_node *h;\n+\tbool found = false;\n+\tint bkt;\n+\n+\tif (!tc_filter->action) {\n+\t\tdev_info(&pf->pdev->dev,\n+\t\t\t \"VF %d: Currently ADq doesn't support Drop Action\\n\",\n+\t\t\t vf->vf_id);\n+\t\tgoto err;\n+\t}\n+\n+\t/* action_meta is TC number here to which the filter is applied */\n+\tif (!tc_filter->action_meta ||\n+\t    tc_filter->action_meta > I40E_MAX_VF_VSI) {\n+\t\tdev_info(&pf->pdev->dev, \"VF %d: Invalid TC number %u\\n\",\n+\t\t\t vf->vf_id, tc_filter->action_meta);\n+\t\tgoto err;\n+\t}\n+\n+\t/* Check filter if it's programmed for advanced mode or basic mode.\n+\t * There are two ADq modes (for VF only),\n+\t * 1. Basic mode: intended to allow as many filter options as posssible\n+\t *\t\t  to be added to a VF in Non-trusted mode. Main goal is\n+\t *\t\t  to add filters to its own MAC and VLAN id.\n+\t * 2. Advanced mode: is for allowing filters to be applied other than\n+\t *\t\t  its own MAC or VLAN. This mode requires the VF to be\n+\t *\t\t  Trusted.\n+\t */\n+\tif (mask.dst_mac[0] && !mask.dst_ip[0]) {\n+\t\tvsi = pf->vsi[vf->lan_vsi_idx];\n+\t\tf = i40e_find_mac(vsi, data.dst_mac);\n+\n+\t\tif (!f) {\n+\t\t\tdev_info(&pf->pdev->dev,\n+\t\t\t\t \"Destination MAC %pM doesn't belong to VF %d\\n\",\n+\t\t\t\t data.dst_mac, vf->vf_id);\n+\t\t\tgoto err;\n+\t\t}\n+\n+\t\tif (mask.vlan_id) {\n+\t\t\thash_for_each_safe(vsi->mac_filter_hash, bkt, h, f,\n+\t\t\t\t\t   hlist) {\n+\t\t\t\tif (f->vlan == ntohs(data.vlan_id)) {\n+\t\t\t\t\tfound = true;\n+\t\t\t\t\tbreak;\n+\t\t\t\t}\n+\t\t\t}\n+\t\t\tif (!found) {\n+\t\t\t\tdev_info(&pf->pdev->dev,\n+\t\t\t\t\t \"VF %d doesn't have any VLAN id %u\\n\",\n+\t\t\t\t\t vf->vf_id, ntohs(data.vlan_id));\n+\t\t\t\tgoto err;\n+\t\t\t}\n+\t\t}\n+\t} else {\n+\t\t/* Check if VF is trusted */\n+\t\tif (!test_bit(I40E_VIRTCHNL_VF_CAP_PRIVILEGE, &vf->vf_caps)) {\n+\t\t\tdev_err(&pf->pdev->dev,\n+\t\t\t\t\"VF %d not trusted, make VF trusted to add advanced mode ADq cloud filters\\n\",\n+\t\t\t\tvf->vf_id);\n+\t\t\treturn I40E_ERR_CONFIG;\n+\t\t}\n+\t}\n+\n+\tif (mask.dst_mac[0] & data.dst_mac[0]) {\n+\t\tif (is_broadcast_ether_addr(data.dst_mac) ||\n+\t\t    is_zero_ether_addr(data.dst_mac)) {\n+\t\t\tdev_info(&pf->pdev->dev, \"VF %d: Invalid Dest MAC addr %pM\\n\",\n+\t\t\t\t vf->vf_id, data.dst_mac);\n+\t\t\tgoto err;\n+\t\t}\n+\t}\n+\n+\tif (mask.src_mac[0] & data.src_mac[0]) {\n+\t\tif (is_broadcast_ether_addr(data.src_mac) ||\n+\t\t    is_zero_ether_addr(data.src_mac)) {\n+\t\t\tdev_info(&pf->pdev->dev, \"VF %d: Invalid Source MAC addr %pM\\n\",\n+\t\t\t\t vf->vf_id, data.src_mac);\n+\t\t\tgoto err;\n+\t\t}\n+\t}\n+\n+\tif (mask.dst_port & data.dst_port) {\n+\t\tif (!data.dst_port || data.dst_port > 0xFFFF) {\n+\t\t\tdev_info(&pf->pdev->dev, \"VF %d: Invalid Dest port\\n\",\n+\t\t\t\t vf->vf_id);\n+\t\t\tgoto err;\n+\t\t}\n+\t}\n+\n+\tif (mask.src_port & data.src_port) {\n+\t\tif (!data.src_port || data.src_port > 0xFFFF) {\n+\t\t\tdev_info(&pf->pdev->dev, \"VF %d: Invalid Source port\\n\",\n+\t\t\t\t vf->vf_id);\n+\t\t\tgoto err;\n+\t\t}\n+\t}\n+\n+\tif (tc_filter->flow_type != VIRTCHNL_TCP_V6_FLOW &&\n+\t    tc_filter->flow_type != VIRTCHNL_TCP_V4_FLOW) {\n+\t\tdev_info(&pf->pdev->dev, \"VF %d: Invalid Flow type\\n\",\n+\t\t\t vf->vf_id);\n+\t\tgoto err;\n+\t}\n+\n+\tif (mask.vlan_id & data.vlan_id) {\n+\t\tif (ntohs(data.vlan_id) > I40E_MAX_VLANID) {\n+\t\t\tdev_info(&pf->pdev->dev, \"VF %d: invalid VLAN ID\\n\",\n+\t\t\t\t vf->vf_id);\n+\t\t\tgoto err;\n+\t\t}\n+\t}\n+\n+\treturn I40E_SUCCESS;\n+err:\n+\treturn I40E_ERR_CONFIG;\n+}\n+\n+/**\n+ * i40e_find_vsi_from_seid - searches for the vsi with the given seid\n+ * @vf: pointer to the VF info\n+ * @seid - seid of the vsi it is searching for\n+ **/\n+struct i40e_vsi *i40e_find_vsi_from_seid(struct i40e_vf *vf, u16 seid)\n+{\n+\tstruct i40e_pf *pf = vf->pf;\n+\tstruct i40e_vsi *vsi = NULL;\n+\tint i;\n+\n+\tfor (i = 0; i < vf->num_tc ; i++) {\n+\t\tvsi = i40e_find_vsi_from_id(pf, vf->ch[i].vsi_id);\n+\t\tif (vsi->seid == seid)\n+\t\t\treturn vsi;\n+\t}\n+\treturn NULL;\n+}\n+\n+/**\n+ * i40e_del_all_cloud_filters\n+ * @vf: pointer to the VF info\n+ *\n+ * This function deletes all cloud filters\n+ **/\n+void i40e_del_all_cloud_filters(struct i40e_vf *vf)\n+{\n+\tstruct i40e_cloud_filter *cfilter = NULL;\n+\tstruct i40e_pf *pf = vf->pf;\n+\tstruct i40e_vsi *vsi = NULL;\n+\tstruct hlist_node *node;\n+\tint ret;\n+\n+\thlist_for_each_entry_safe(cfilter, node,\n+\t\t\t\t  &vf->cloud_filter_list, cloud_node) {\n+\t\tvsi = i40e_find_vsi_from_seid(vf, cfilter->seid);\n+\n+\t\tif (!vsi) {\n+\t\t\tdev_err(&pf->pdev->dev, \"VF %d: no VSI found for matching %u seid, can't delete cloud filter\\n\",\n+\t\t\t\tvf->vf_id, cfilter->seid);\n+\t\t\tcontinue;\n+\t\t}\n+\n+\t\tif (cfilter->dst_port)\n+\t\t\tret = i40e_add_del_cloud_filter_big_buf(vsi, cfilter,\n+\t\t\t\t\t\t\t\tfalse);\n+\t\telse\n+\t\t\tret = i40e_add_del_cloud_filter(vsi, cfilter, false);\n+\t\tif (ret)\n+\t\t\tdev_err(&pf->pdev->dev,\n+\t\t\t\t\"VF %d: Failed to delete cloud filter, err %s aq_err %s\\n\",\n+\t\t\t\tvf->vf_id, i40e_stat_str(&pf->hw, ret),\n+\t\t\t\ti40e_aq_str(&pf->hw,\n+\t\t\t\t\t    pf->hw.aq.asq_last_status));\n+\n+\t\thlist_del(&cfilter->cloud_node);\n+\t\tkfree(cfilter);\n+\t\tvf->num_cloud_filters--;\n+\t}\n+}\n+\n+/**\n+ * i40e_vc_del_cloud_filter\n+ * @vf: pointer to the VF info\n+ * @msg: pointer to the msg buffer\n+ *\n+ * This function deletes a cloud filter programmed as TC filter for ADq\n+ **/\n+static int i40e_vc_del_cloud_filter(struct i40e_vf *vf, u8 *msg)\n+{\n+\tstruct virtchnl_filter *vcf = (struct virtchnl_filter *)msg;\n+\tstruct virtchnl_l4_spec mask = vcf->mask.tcp_spec;\n+\tstruct virtchnl_l4_spec tcf = vcf->data.tcp_spec;\n+\tstruct i40e_cloud_filter cfilter, *cf = NULL;\n+\tstruct i40e_pf *pf = vf->pf;\n+\tstruct i40e_vsi *vsi = NULL;\n+\tstruct hlist_node *node;\n+\ti40e_status aq_ret = 0;\n+\tint i, ret;\n+\n+\tif (!test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states)) {\n+\t\taq_ret = I40E_ERR_PARAM;\n+\t\tgoto err;\n+\t}\n+\n+\tif (!vf->adq_enabled) {\n+\t\tdev_info(&pf->pdev->dev,\n+\t\t\t \"VF %d: ADq not enabled, can't apply cloud filter\\n\",\n+\t\t\t vf->vf_id);\n+\t\taq_ret = I40E_ERR_PARAM;\n+\t\tgoto err;\n+\t}\n+\n+\tif (i40e_validate_cloud_filter(vf, vcf)) {\n+\t\tdev_info(&pf->pdev->dev,\n+\t\t\t \"VF %d: Invalid input, can't apply cloud filter\\n\",\n+\t\t\t vf->vf_id);\n+\t\t\taq_ret = I40E_ERR_PARAM;\n+\t\t\tgoto err;\n+\t}\n+\n+\tmemset(&cfilter, 0, sizeof(cfilter));\n+\t/* parse destination mac address */\n+\tfor (i = 0; i < ETH_ALEN; i++)\n+\t\tcfilter.dst_mac[i] = mask.dst_mac[i] & tcf.dst_mac[i];\n+\n+\t/* parse source mac address */\n+\tfor (i = 0; i < ETH_ALEN; i++)\n+\t\tcfilter.src_mac[i] = mask.src_mac[i] & tcf.src_mac[i];\n+\n+\tcfilter.vlan_id = mask.vlan_id & tcf.vlan_id;\n+\tcfilter.dst_port = mask.dst_port & tcf.dst_port;\n+\tcfilter.src_port = mask.src_port & tcf.src_port;\n+\n+\tswitch (vcf->flow_type) {\n+\tcase VIRTCHNL_TCP_V4_FLOW:\n+\t\tcfilter.n_proto = ETH_P_IP;\n+\t\tif (mask.dst_ip[0] & tcf.dst_ip[0])\n+\t\t\tmemcpy(&cfilter.ip.v4.dst_ip, tcf.dst_ip,\n+\t\t\t       ARRAY_SIZE(tcf.dst_ip));\n+\t\telse if (mask.src_ip[0] & tcf.dst_ip[0])\n+\t\t\tmemcpy(&cfilter.ip.v4.src_ip, tcf.src_ip,\n+\t\t\t       ARRAY_SIZE(tcf.dst_ip));\n+\t\tbreak;\n+\tcase VIRTCHNL_TCP_V6_FLOW:\n+\t\tcfilter.n_proto = ETH_P_IPV6;\n+\t\tif (mask.dst_ip[3] & tcf.dst_ip[3])\n+\t\t\tmemcpy(&cfilter.ip.v6.dst_ip6, tcf.dst_ip,\n+\t\t\t       sizeof(cfilter.ip.v6.dst_ip6));\n+\t\tif (mask.src_ip[3] & tcf.src_ip[3])\n+\t\t\tmemcpy(&cfilter.ip.v6.src_ip6, tcf.src_ip,\n+\t\t\t       sizeof(cfilter.ip.v6.src_ip6));\n+\t\tbreak;\n+\tdefault:\n+\t\t/* TC filter can be configured based on different combinations\n+\t\t * and in this case IP is not a part of filter config\n+\t\t */\n+\t\tdev_info(&pf->pdev->dev, \"VF %d: Flow type not configured\\n\",\n+\t\t\t vf->vf_id);\n+\t}\n+\n+\t/* get the vsi to which the tc belongs to */\n+\tvsi = pf->vsi[vf->ch[vcf->action_meta].vsi_idx];\n+\tcfilter.seid = vsi->seid;\n+\tcfilter.flags = vcf->field_flags;\n+\n+\t/* Deleting TC filter */\n+\tif (tcf.dst_port)\n+\t\tret = i40e_add_del_cloud_filter_big_buf(vsi, &cfilter, false);\n+\telse\n+\t\tret = i40e_add_del_cloud_filter(vsi, &cfilter, false);\n+\tif (ret) {\n+\t\tdev_err(&pf->pdev->dev,\n+\t\t\t\"VF %d: Failed to delete cloud filter, err %s aq_err %s\\n\",\n+\t\t\tvf->vf_id, i40e_stat_str(&pf->hw, ret),\n+\t\t\ti40e_aq_str(&pf->hw, pf->hw.aq.asq_last_status));\n+\t\tgoto err;\n+\t}\n+\n+\thlist_for_each_entry_safe(cf, node,\n+\t\t\t\t  &vf->cloud_filter_list, cloud_node) {\n+\t\tif (cf->seid != cfilter.seid)\n+\t\t\tcontinue;\n+\t\tif (mask.dst_port)\n+\t\t\tif (cfilter.dst_port != cf->dst_port)\n+\t\t\t\tcontinue;\n+\t\tif (mask.dst_mac[0])\n+\t\t\tif (!ether_addr_equal(cf->src_mac, cfilter.src_mac))\n+\t\t\t\tcontinue;\n+\t\t/* for ipv4 data to be valid, only first byte of mask is set */\n+\t\tif (cfilter.n_proto == ETH_P_IP && mask.dst_ip[0])\n+\t\t\tif (memcmp(&cfilter.ip.v4.dst_ip, &cf->ip.v4.dst_ip,\n+\t\t\t\t   ARRAY_SIZE(tcf.dst_ip)))\n+\t\t\t\tcontinue;\n+\t\t/* for ipv6, mask is set for all sixteen bytes (4 words) */\n+\t\tif (cfilter.n_proto == ETH_P_IPV6 && mask.dst_ip[3])\n+\t\t\tif (memcmp(&cfilter.ip.v6.dst_ip6, &cf->ip.v6.dst_ip6,\n+\t\t\t\t   sizeof(cfilter.ip.v6.src_ip6)))\n+\t\t\t\tcontinue;\n+\t\tif (mask.vlan_id)\n+\t\t\tif (cfilter.vlan_id != cf->vlan_id)\n+\t\t\t\tcontinue;\n+\n+\t\thlist_del(&cf->cloud_node);\n+\t\tkfree(cf);\n+\t\tvf->num_cloud_filters--;\n+\t}\n+\n+err:\n+\treturn i40e_vc_send_resp_to_vf(vf, VIRTCHNL_OP_DEL_CLOUD_FILTER,\n+\t\t\t\t       aq_ret);\n+}\n+\n+/**\n+ * i40e_vc_add_cloud_filter\n+ * @vf: pointer to the VF info\n+ * @msg: pointer to the msg buffer\n+ *\n+ * This function adds a cloud filter programmed as TC filter for ADq\n+ **/\n+static int i40e_vc_add_cloud_filter(struct i40e_vf *vf, u8 *msg)\n+{\n+\tstruct virtchnl_filter *vcf = (struct virtchnl_filter *)msg;\n+\tstruct virtchnl_l4_spec mask = vcf->mask.tcp_spec;\n+\tstruct virtchnl_l4_spec tcf = vcf->data.tcp_spec;\n+\tstruct i40e_cloud_filter *cfilter = NULL;\n+\tstruct i40e_pf *pf = vf->pf;\n+\tstruct i40e_vsi *vsi = NULL;\n+\ti40e_status aq_ret = 0;\n+\tint i, ret;\n+\n+\tif (!test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states)) {\n+\t\taq_ret = I40E_ERR_PARAM;\n+\t\tgoto err;\n+\t}\n+\n+\tif (!vf->adq_enabled) {\n+\t\tdev_info(&pf->pdev->dev,\n+\t\t\t \"VF %d: ADq is not enabled, can't apply cloud filter\\n\",\n+\t\t\t vf->vf_id);\n+\t\taq_ret = I40E_ERR_PARAM;\n+\t\tgoto err;\n+\t}\n+\n+\tif (i40e_validate_cloud_filter(vf, vcf)) {\n+\t\tdev_info(&pf->pdev->dev,\n+\t\t\t \"VF %d: Invalid input/s, can't apply cloud filter\\n\",\n+\t\t\t vf->vf_id);\n+\t\t\taq_ret = I40E_ERR_PARAM;\n+\t\t\tgoto err;\n+\t}\n+\n+\tcfilter = kzalloc(sizeof(*cfilter), GFP_KERNEL);\n+\tif (!cfilter)\n+\t\treturn -ENOMEM;\n+\n+\t/* parse destination mac address */\n+\tfor (i = 0; i < ETH_ALEN; i++)\n+\t\tcfilter->dst_mac[i] = mask.dst_mac[i] & tcf.dst_mac[i];\n+\n+\t/* parse source mac address */\n+\tfor (i = 0; i < ETH_ALEN; i++)\n+\t\tcfilter->src_mac[i] = mask.src_mac[i] & tcf.src_mac[i];\n+\n+\tcfilter->vlan_id = mask.vlan_id & tcf.vlan_id;\n+\tcfilter->dst_port = mask.dst_port & tcf.dst_port;\n+\tcfilter->src_port = mask.src_port & tcf.src_port;\n+\n+\tswitch (vcf->flow_type) {\n+\tcase VIRTCHNL_TCP_V4_FLOW:\n+\t\tcfilter->n_proto = ETH_P_IP;\n+\t\tif (mask.dst_ip[0] & tcf.dst_ip[0])\n+\t\t\tmemcpy(&cfilter->ip.v4.dst_ip, tcf.dst_ip,\n+\t\t\t       ARRAY_SIZE(tcf.dst_ip));\n+\t\telse if (mask.src_ip[0] & tcf.dst_ip[0])\n+\t\t\tmemcpy(&cfilter->ip.v4.src_ip, tcf.src_ip,\n+\t\t\t       ARRAY_SIZE(tcf.dst_ip));\n+\t\tbreak;\n+\tcase VIRTCHNL_TCP_V6_FLOW:\n+\t\tcfilter->n_proto = ETH_P_IPV6;\n+\t\tif (mask.dst_ip[3] & tcf.dst_ip[3])\n+\t\t\tmemcpy(&cfilter->ip.v6.dst_ip6, tcf.dst_ip,\n+\t\t\t       sizeof(cfilter->ip.v6.dst_ip6));\n+\t\tif (mask.src_ip[3] & tcf.src_ip[3])\n+\t\t\tmemcpy(&cfilter->ip.v6.src_ip6, tcf.src_ip,\n+\t\t\t       sizeof(cfilter->ip.v6.src_ip6));\n+\t\tbreak;\n+\tdefault:\n+\t\t/* TC filter can be configured based on different combinations\n+\t\t * and in this case IP is not a part of filter config\n+\t\t */\n+\t\tdev_info(&pf->pdev->dev, \"VF %d: Flow type not configured\\n\",\n+\t\t\t vf->vf_id);\n+\t}\n+\n+\t/* get the vsi to which the tc belongs to */\n+\tvsi = pf->vsi[vf->ch[vcf->action_meta].vsi_idx];\n+\tcfilter->seid = vsi->seid;\n+\tcfilter->flags = vcf->field_flags;\n+\n+\t/* Adding cloud filter programmed as TC filter */\n+\tif (tcf.dst_port)\n+\t\tret = i40e_add_del_cloud_filter_big_buf(vsi, cfilter, true);\n+\telse\n+\t\tret = i40e_add_del_cloud_filter(vsi, cfilter, true);\n+\tif (ret) {\n+\t\tdev_err(&pf->pdev->dev,\n+\t\t\t\"VF %d: Failed to add cloud filter, err %s aq_err %s\\n\",\n+\t\t\tvf->vf_id, i40e_stat_str(&pf->hw, ret),\n+\t\t\ti40e_aq_str(&pf->hw, pf->hw.aq.asq_last_status));\n+\t\tgoto err;\n+\t}\n+\n+\tINIT_HLIST_NODE(&cfilter->cloud_node);\n+\thlist_add_head(&cfilter->cloud_node, &vf->cloud_filter_list);\n+\tvf->num_cloud_filters++;\n+err:\n+\treturn i40e_vc_send_resp_to_vf(vf, VIRTCHNL_OP_ADD_CLOUD_FILTER,\n+\t\t\t\t       aq_ret);\n+}\n+\n /**\n  * i40e_vc_add_qch_msg: Add queue channel and enable ADq\n  * @vf: pointer to the VF info\n@@ -3036,6 +3470,11 @@ static int i40e_vc_add_qch_msg(struct i40e_vf *vf, u8 *msg)\n \n \t/* set this flag only after making sure all inputs are sane */\n \tvf->adq_enabled = true;\n+\t/* num_req_queues is set when user changes number of queues via ethtool\n+\t * and this causes issue for default VSI(which depends on this variable)\n+\t * when ADq is enabled, hence reset it.\n+\t */\n+\tvf->num_req_queues = 0;\n \n \t/* reset the VF in order to allocate resources */\n \ti40e_vc_notify_vf_reset(vf);\n@@ -3065,11 +3504,12 @@ static int i40e_vc_del_qch_msg(struct i40e_vf *vf, u8 *msg)\n \t}\n \n \tif (vf->adq_enabled) {\n+\t\ti40e_del_all_cloud_filters(vf);\n \t\ti40e_del_qch(vf);\n \t\tvf->adq_enabled = false;\n \t\tvf->num_tc = 0;\n \t\tdev_info(&pf->pdev->dev,\n-\t\t\t \"Deleting Queue Channels for ADq on VF %d\\n\",\n+\t\t\t \"Deleting Queue Channels and cloud filters for ADq on VF %d\\n\",\n \t\t\t vf->vf_id);\n \t} else {\n \t\tdev_info(&pf->pdev->dev, \"VF %d trying to delete queue channels but ADq isn't enabled\\n\",\n@@ -3223,6 +3663,12 @@ int i40e_vc_process_vf_msg(struct i40e_pf *pf, s16 vf_id, u32 v_opcode,\n \tcase VIRTCHNL_OP_DISABLE_CHANNELS:\n \t\tret = i40e_vc_del_qch_msg(vf, msg);\n \t\tbreak;\n+\tcase VIRTCHNL_OP_ADD_CLOUD_FILTER:\n+\t\tret = i40e_vc_add_cloud_filter(vf, msg);\n+\t\tbreak;\n+\tcase VIRTCHNL_OP_DEL_CLOUD_FILTER:\n+\t\tret = i40e_vc_del_cloud_filter(vf, msg);\n+\t\tbreak;\n \tcase VIRTCHNL_OP_UNKNOWN:\n \tdefault:\n \t\tdev_err(&pf->pdev->dev, \"Unsupported opcode %d from VF %d\\n\",\n@@ -3788,6 +4234,16 @@ int i40e_ndo_set_vf_trust(struct net_device *netdev, int vf_id, bool setting)\n \ti40e_vc_disable_vf(vf);\n \tdev_info(&pf->pdev->dev, \"VF %u is now %strusted\\n\",\n \t\t vf_id, setting ? \"\" : \"un\");\n+\n+\tif (vf->adq_enabled) {\n+\t\tif (!vf->trusted) {\n+\t\t\tdev_info(&pf->pdev->dev,\n+\t\t\t\t \"VF %u no longer Trusted, deleting all cloud filters\\n\",\n+\t\t\t\t vf_id);\n+\t\t\ti40e_del_all_cloud_filters(vf);\n+\t\t}\n+\t}\n+\n out:\n \treturn ret;\n }\ndiff --git a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.h b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.h\nindex 6e794c8a1ef3..6852599b2379 100644\n--- a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.h\n+++ b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.h\n@@ -128,6 +128,8 @@ struct i40e_vf {\n \tbool adq_enabled; /* flag to enable adq */\n \tu8 num_tc;\n \tstruct i40evf_channel ch[I40E_MAX_VF_VSI];\n+\tstruct hlist_head cloud_filter_list;\n+\tu16 num_cloud_filters;\n \n \t/* RDMA Client */\n \tstruct virtchnl_iwarp_qvlist_info *qvlist_info;\n",
    "prefixes": [
        "12/12"
    ]
}