get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 864991,
    "url": "http://patchwork.ozlabs.org/api/patches/864991/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/intel-wired-lan/patch/20180123165106.28900-13-avinash.dayanand@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": "<20180123165106.28900-13-avinash.dayanand@intel.com>",
    "list_archive_url": null,
    "date": "2018-01-23T16:51:06",
    "name": "[v3,next-queue,12/12] i40e: Add and delete cloud filter",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "b148e178b17b077a70513826148aadd0663d9d08",
    "submitter": {
        "id": 67689,
        "url": "http://patchwork.ozlabs.org/api/people/67689/?format=api",
        "name": "Dayanand, Avinash",
        "email": "avinash.dayanand@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/20180123165106.28900-13-avinash.dayanand@intel.com/mbox/",
    "series": [
        {
            "id": 24988,
            "url": "http://patchwork.ozlabs.org/api/series/24988/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/intel-wired-lan/list/?series=24988",
            "date": "2018-01-23T16:51:00",
            "name": "Enable queue channel and cloud filter support on i40evf",
            "version": 3,
            "mbox": "http://patchwork.ozlabs.org/series/24988/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/864991/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/864991/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.136; helo=silver.osuosl.org;\n\tenvelope-from=intel-wired-lan-bounces@osuosl.org;\n\treceiver=<UNKNOWN>)",
        "Received": [
            "from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136])\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 3zQzVM40q4z9s7s\n\tfor <incoming@patchwork.ozlabs.org>;\n\tWed, 24 Jan 2018 06:52:43 +1100 (AEDT)",
            "from localhost (localhost [127.0.0.1])\n\tby silver.osuosl.org (Postfix) with ESMTP id 2D2512FDA3;\n\tTue, 23 Jan 2018 19:52:42 +0000 (UTC)",
            "from silver.osuosl.org ([127.0.0.1])\n\tby localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)\n\twith ESMTP id lIIyltOTc0ln; Tue, 23 Jan 2018 19:52:39 +0000 (UTC)",
            "from ash.osuosl.org (ash.osuosl.org [140.211.166.34])\n\tby silver.osuosl.org (Postfix) with ESMTP id 568A62FD31;\n\tTue, 23 Jan 2018 19:52:39 +0000 (UTC)",
            "from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133])\n\tby ash.osuosl.org (Postfix) with ESMTP id D405D1C0521\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tTue, 23 Jan 2018 19:52:37 +0000 (UTC)",
            "from localhost (localhost [127.0.0.1])\n\tby hemlock.osuosl.org (Postfix) with ESMTP id B84A088281\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tTue, 23 Jan 2018 19:52:37 +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 pRv+Fg+N3jBo for <intel-wired-lan@lists.osuosl.org>;\n\tTue, 23 Jan 2018 19:52:25 +0000 (UTC)",
            "from mga05.intel.com (mga05.intel.com [192.55.52.43])\n\tby hemlock.osuosl.org (Postfix) with ESMTPS id 94B048828A\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tTue, 23 Jan 2018 19:52:23 +0000 (UTC)",
            "from orsmga001.jf.intel.com ([10.7.209.18])\n\tby fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t23 Jan 2018 11:52:22 -0800",
            "from avi-linux2.jf.intel.com ([10.166.244.156])\n\tby orsmga001.jf.intel.com with ESMTP; 23 Jan 2018 11:52:06 -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,402,1511856000\"; d=\"scan'208\";a=\"25768890\"",
        "From": "Avinash Dayanand <avinash.dayanand@intel.com>",
        "To": "intel-wired-lan@lists.osuosl.org",
        "Date": "Tue, 23 Jan 2018 08:51:06 -0800",
        "Message-Id": "<20180123165106.28900-13-avinash.dayanand@intel.com>",
        "X-Mailer": "git-send-email 2.9.4",
        "In-Reply-To": "<20180123165106.28900-1-avinash.dayanand@intel.com>",
        "References": "<20180123165106.28900-1-avinash.dayanand@intel.com>",
        "Subject": "[Intel-wired-lan] [PATCH v3 next-queue 12/12] i40e: Add and delete\n\tcloud 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": "This 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\nv3: fixed sparse errors.\nv2: made i40e_find_vsi_from_seid and i40e_del_all_cloud_filters functions\n    as static.\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 ebe795a..4b81a18 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 47bccc3..fcec88d 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 989664a..f5bdb82 100644\n--- a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c\n+++ b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c\n@@ -2917,6 +2917,440 @@ static int i40e_vc_disable_vlan_stripping(struct i40e_vf *vf, u8 *msg,\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 || be16_to_cpu(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 || be16_to_cpu(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+static 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+static 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  * @msg: pointer to the msg buffer\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 6e794c8..6852599 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": [
        "v3",
        "next-queue",
        "12/12"
    ]
}