get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 1158742,
    "url": "http://patchwork.ozlabs.org/api/patches/1158742/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/intel-wired-lan/patch/20190905153956.53086-3-anthony.l.nguyen@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": "<20190905153956.53086-3-anthony.l.nguyen@intel.com>",
    "list_archive_url": null,
    "date": "2019-09-05T15:39:53",
    "name": "[S29,3/6] ice: Implement Dynamic Device Personalization (DDP) download",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "31ee9b9e8b5abd811fa2e6021d852b6d001720e3",
    "submitter": {
        "id": 68875,
        "url": "http://patchwork.ozlabs.org/api/people/68875/?format=api",
        "name": "Tony Nguyen",
        "email": "anthony.l.nguyen@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/20190905153956.53086-3-anthony.l.nguyen@intel.com/mbox/",
    "series": [
        {
            "id": 129309,
            "url": "http://patchwork.ozlabs.org/api/series/129309/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/intel-wired-lan/list/?series=129309",
            "date": "2019-09-05T15:39:51",
            "name": "[S29,1/6] ice: send driver version to firmware",
            "version": 1,
            "mbox": "http://patchwork.ozlabs.org/series/129309/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/1158742/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/1158742/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>)",
            "ozlabs.org;\n\tdmarc=fail (p=none dis=none) header.from=intel.com"
        ],
        "Received": [
            "from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 46PdGb1TWqz9sDB\n\tfor <incoming@patchwork.ozlabs.org>;\n\tFri,  6 Sep 2019 10:09:42 +1000 (AEST)",
            "from localhost (localhost [127.0.0.1])\n\tby silver.osuosl.org (Postfix) with ESMTP id 0BC97232FA;\n\tFri,  6 Sep 2019 00:09:39 +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 urX93XNERwOK; Fri,  6 Sep 2019 00:09:26 +0000 (UTC)",
            "from ash.osuosl.org (ash.osuosl.org [140.211.166.34])\n\tby silver.osuosl.org (Postfix) with ESMTP id 71214203CC;\n\tFri,  6 Sep 2019 00:09:26 +0000 (UTC)",
            "from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138])\n\tby ash.osuosl.org (Postfix) with ESMTP id B0BD31BF9BD\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tFri,  6 Sep 2019 00:09:24 +0000 (UTC)",
            "from localhost (localhost [127.0.0.1])\n\tby whitealder.osuosl.org (Postfix) with ESMTP id 5AAE184DE1\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tFri,  6 Sep 2019 00:09:23 +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 rf7SkcJ4tNaI for <intel-wired-lan@lists.osuosl.org>;\n\tFri,  6 Sep 2019 00:09:16 +0000 (UTC)",
            "from mga12.intel.com (mga12.intel.com [192.55.52.136])\n\tby whitealder.osuosl.org (Postfix) with ESMTPS id 1183B84368\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tFri,  6 Sep 2019 00:09:16 +0000 (UTC)",
            "from orsmga002.jf.intel.com ([10.7.209.21])\n\tby fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t05 Sep 2019 17:09:15 -0700",
            "from unknown (HELO localhost.jf.intel.com) ([10.166.244.174])\n\tby orsmga002.jf.intel.com with ESMTP; 05 Sep 2019 17:09:14 -0700"
        ],
        "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.64,471,1559545200\"; d=\"scan'208\";a=\"195268845\"",
        "From": "Tony Nguyen <anthony.l.nguyen@intel.com>",
        "To": "intel-wired-lan@lists.osuosl.org",
        "Date": "Thu,  5 Sep 2019 08:39:53 -0700",
        "Message-Id": "<20190905153956.53086-3-anthony.l.nguyen@intel.com>",
        "X-Mailer": "git-send-email 2.20.1",
        "In-Reply-To": "<20190905153956.53086-1-anthony.l.nguyen@intel.com>",
        "References": "<20190905153956.53086-1-anthony.l.nguyen@intel.com>",
        "MIME-Version": "1.0",
        "Subject": "[Intel-wired-lan] [PATCH S29 3/6] ice: Implement Dynamic Device\n\tPersonalization (DDP) download",
        "X-BeenThere": "intel-wired-lan@osuosl.org",
        "X-Mailman-Version": "2.1.29",
        "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>",
        "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": "Add the required defines, structures, and functions to enable downloading\na DDP package.  Before download, checks are performed to ensure the package\nis valid and compatible.\n\nNote that package download is not yet requested by the driver as further\ninitialization is required to utilize the package.\n\nSigned-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>\n---\n drivers/net/ethernet/intel/ice/Makefile       |   1 +\n .../net/ethernet/intel/ice/ice_adminq_cmd.h   |  60 ++\n drivers/net/ethernet/intel/ice/ice_common.c   |  40 +-\n drivers/net/ethernet/intel/ice/ice_common.h   |   4 +\n .../net/ethernet/intel/ice/ice_flex_pipe.c    | 607 ++++++++++++++++++\n .../net/ethernet/intel/ice/ice_flex_pipe.h    |  25 +\n .../net/ethernet/intel/ice/ice_flex_type.h    | 372 +++++++++++\n .../net/ethernet/intel/ice/ice_hw_autogen.h   |   2 +\n drivers/net/ethernet/intel/ice/ice_type.h     |  26 +\n 9 files changed, 1136 insertions(+), 1 deletion(-)\n create mode 100644 drivers/net/ethernet/intel/ice/ice_flex_pipe.c\n create mode 100644 drivers/net/ethernet/intel/ice/ice_flex_pipe.h\n create mode 100644 drivers/net/ethernet/intel/ice/ice_flex_type.h",
    "diff": "diff --git a/drivers/net/ethernet/intel/ice/Makefile b/drivers/net/ethernet/intel/ice/Makefile\nindex 2d140ba83781..9edde960b4f2 100644\n--- a/drivers/net/ethernet/intel/ice/Makefile\n+++ b/drivers/net/ethernet/intel/ice/Makefile\n@@ -15,6 +15,7 @@ ice-y := ice_main.o\t\\\n \t ice_sched.o\t\\\n \t ice_lib.o\t\\\n \t ice_txrx.o\t\\\n+\t ice_flex_pipe.o\t\\\n \t ice_ethtool.o\n ice-$(CONFIG_PCI_IOV) += ice_virtchnl_pf.o ice_sriov.o\n ice-$(CONFIG_DCB) += ice_dcb.o ice_dcb_lib.o\ndiff --git a/drivers/net/ethernet/intel/ice/ice_adminq_cmd.h b/drivers/net/ethernet/intel/ice/ice_adminq_cmd.h\nindex 9c9791788610..023e3d2fee5f 100644\n--- a/drivers/net/ethernet/intel/ice/ice_adminq_cmd.h\n+++ b/drivers/net/ethernet/intel/ice/ice_adminq_cmd.h\n@@ -1530,6 +1530,56 @@ struct ice_aqc_get_clear_fw_log {\n \t__le32 addr_low;\n };\n \n+/* Download Package (indirect 0x0C40) */\n+/* Also used for Update Package (indirect 0x0C42) */\n+struct ice_aqc_download_pkg {\n+\tu8 flags;\n+#define ICE_AQC_DOWNLOAD_PKG_LAST_BUF\t0x01\n+\tu8 reserved[3];\n+\t__le32 reserved1;\n+\t__le32 addr_high;\n+\t__le32 addr_low;\n+};\n+\n+struct ice_aqc_download_pkg_resp {\n+\t__le32 error_offset;\n+\t__le32 error_info;\n+\t__le32 addr_high;\n+\t__le32 addr_low;\n+};\n+\n+/* Get Package Info List (indirect 0x0C43) */\n+struct ice_aqc_get_pkg_info_list {\n+\t__le32 reserved1;\n+\t__le32 reserved2;\n+\t__le32 addr_high;\n+\t__le32 addr_low;\n+};\n+\n+/* Version format for packages */\n+struct ice_pkg_ver {\n+\tu8 major;\n+\tu8 minor;\n+\tu8 update;\n+\tu8 draft;\n+};\n+\n+#define ICE_PKG_NAME_SIZE\t32\n+\n+struct ice_aqc_get_pkg_info {\n+\tstruct ice_pkg_ver ver;\n+\tchar name[ICE_PKG_NAME_SIZE];\n+\tu8 is_in_nvm;\n+\tu8 is_active;\n+\tu8 is_active_at_boot;\n+\tu8 is_modified;\n+};\n+\n+/* Get Package Info List response buffer format (0x0C43) */\n+struct ice_aqc_get_pkg_info_resp {\n+\t__le32 count;\n+\tstruct ice_aqc_get_pkg_info pkg_info[1];\n+};\n /**\n  * struct ice_aq_desc - Admin Queue (AQ) descriptor\n  * @flags: ICE_AQ_FLAG_* flags\n@@ -1592,6 +1642,7 @@ struct ice_aq_desc {\n \t\tstruct ice_aqc_add_update_free_vsi_resp add_update_free_vsi_res;\n \t\tstruct ice_aqc_fw_logging fw_logging;\n \t\tstruct ice_aqc_get_clear_fw_log get_clear_fw_log;\n+\t\tstruct ice_aqc_download_pkg download_pkg;\n \t\tstruct ice_aqc_set_mac_lb set_mac_lb;\n \t\tstruct ice_aqc_alloc_free_res_cmd sw_res_ctrl;\n \t\tstruct ice_aqc_set_event_mask set_event_mask;\n@@ -1624,6 +1675,11 @@ enum ice_aq_err {\n \tICE_AQ_RC_EEXIST\t= 13, /* Object already exists */\n \tICE_AQ_RC_ENOSPC\t= 16, /* No space left or allocation failure */\n \tICE_AQ_RC_ENOSYS\t= 17, /* Function not implemented */\n+\tICE_AQ_RC_ENOSEC\t= 24, /* Missing security manifest */\n+\tICE_AQ_RC_EBADSIG\t= 25, /* Bad RSA signature */\n+\tICE_AQ_RC_ESVN\t\t= 26, /* SVN number prohibits this package */\n+\tICE_AQ_RC_EBADMAN\t= 27, /* Manifest hash mismatch */\n+\tICE_AQ_RC_EBADBUF\t= 28, /* Buffer hash mismatches manifest */\n };\n \n /* Admin Queue command opcodes */\n@@ -1712,6 +1768,10 @@ enum ice_adminq_opc {\n \tice_aqc_opc_add_txqs\t\t\t\t= 0x0C30,\n \tice_aqc_opc_dis_txqs\t\t\t\t= 0x0C31,\n \n+\t/* package commands */\n+\tice_aqc_opc_download_pkg\t\t\t= 0x0C40,\n+\tice_aqc_opc_get_pkg_info_list\t\t\t= 0x0C43,\n+\n \t/* debug commands */\n \tice_aqc_opc_fw_logging\t\t\t\t= 0xFF09,\n \tice_aqc_opc_fw_logging_info\t\t\t= 0xFF10,\ndiff --git a/drivers/net/ethernet/intel/ice/ice_common.c b/drivers/net/ethernet/intel/ice/ice_common.c\nindex 22d2a11ef41f..20956643036c 100644\n--- a/drivers/net/ethernet/intel/ice/ice_common.c\n+++ b/drivers/net/ethernet/intel/ice/ice_common.c\n@@ -910,6 +910,7 @@ void ice_deinit_hw(struct ice_hw *hw)\n \n \tice_sched_cleanup_all(hw);\n \tice_sched_clear_agg(hw);\n+\tice_free_seg(hw);\n \n \tif (hw->port_info) {\n \t\tdevm_kfree(ice_hw_to_dev(hw), hw->port_info);\n@@ -1230,6 +1231,12 @@ ice_debug_cq(struct ice_hw *hw, u32 __maybe_unused mask, void *desc, void *buf,\n \n /* FW Admin Queue command wrappers */\n \n+/* Software lock/mutex that is meant to be held while the Global Config Lock\n+ * in firmware is acquired by the software to prevent most (but not all) types\n+ * of AQ commands from being sent to FW\n+ */\n+DEFINE_MUTEX(ice_global_cfg_lock_sw);\n+\n /**\n  * ice_aq_send_cmd - send FW Admin Queue command to FW Admin Queue\n  * @hw: pointer to the HW struct\n@@ -1244,7 +1251,38 @@ enum ice_status\n ice_aq_send_cmd(struct ice_hw *hw, struct ice_aq_desc *desc, void *buf,\n \t\tu16 buf_size, struct ice_sq_cd *cd)\n {\n-\treturn ice_sq_send_cmd(hw, &hw->adminq, desc, buf, buf_size, cd);\n+\tstruct ice_aqc_req_res *cmd = &desc->params.res_owner;\n+\tbool lock_acquired = false;\n+\tenum ice_status status;\n+\n+\t/* When a package download is in process (i.e. when the firmware's\n+\t * Global Configuration Lock resource is held), only the Download\n+\t * Package, Get Version, Get Package Info List and Release Resource\n+\t * (with resource ID set to Global Config Lock) AdminQ commands are\n+\t * allowed; all others must block until the package download completes\n+\t * and the Global Config Lock is released.  See also\n+\t * ice_acquire_global_cfg_lock().\n+\t */\n+\tswitch (le16_to_cpu(desc->opcode)) {\n+\tcase ice_aqc_opc_download_pkg:\n+\tcase ice_aqc_opc_get_pkg_info_list:\n+\tcase ice_aqc_opc_get_ver:\n+\t\tbreak;\n+\tcase ice_aqc_opc_release_res:\n+\t\tif (le16_to_cpu(cmd->res_id) == ICE_AQC_RES_ID_GLBL_LOCK)\n+\t\t\tbreak;\n+\t\t/* fall-through */\n+\tdefault:\n+\t\tmutex_lock(&ice_global_cfg_lock_sw);\n+\t\tlock_acquired = true;\n+\t\tbreak;\n+\t}\n+\n+\tstatus = ice_sq_send_cmd(hw, &hw->adminq, desc, buf, buf_size, cd);\n+\tif (lock_acquired)\n+\t\tmutex_unlock(&ice_global_cfg_lock_sw);\n+\n+\treturn status;\n }\n \n /**\ndiff --git a/drivers/net/ethernet/intel/ice/ice_common.h b/drivers/net/ethernet/intel/ice/ice_common.h\nindex 0525a051e05b..ce55f8ae6b52 100644\n--- a/drivers/net/ethernet/intel/ice/ice_common.h\n+++ b/drivers/net/ethernet/intel/ice/ice_common.h\n@@ -6,6 +6,7 @@\n \n #include \"ice.h\"\n #include \"ice_type.h\"\n+#include \"ice_flex_pipe.h\"\n #include \"ice_switch.h\"\n #include <linux/avf/virtchnl.h>\n \n@@ -66,6 +67,9 @@ void ice_fill_dflt_direct_cmd_desc(struct ice_aq_desc *desc, u16 opcode);\n extern const struct ice_ctx_ele ice_tlan_ctx_info[];\n enum ice_status\n ice_set_ctx(u8 *src_ctx, u8 *dest_ctx, const struct ice_ctx_ele *ce_info);\n+\n+extern struct mutex ice_global_cfg_lock_sw;\n+\n enum ice_status\n ice_aq_send_cmd(struct ice_hw *hw, struct ice_aq_desc *desc,\n \t\tvoid *buf, u16 buf_size, struct ice_sq_cd *cd);\ndiff --git a/drivers/net/ethernet/intel/ice/ice_flex_pipe.c b/drivers/net/ethernet/intel/ice/ice_flex_pipe.c\nnew file mode 100644\nindex 000000000000..c2a7614471ce\n--- /dev/null\n+++ b/drivers/net/ethernet/intel/ice/ice_flex_pipe.c\n@@ -0,0 +1,607 @@\n+// SPDX-License-Identifier: GPL-2.0\n+/* Copyright (c) 2019, Intel Corporation. */\n+\n+#include \"ice_common.h\"\n+#include \"ice_flex_pipe.h\"\n+\n+/**\n+ * ice_find_buf_table\n+ * @ice_seg: pointer to the ice segment\n+ *\n+ * Returns the address of the buffer table within the ice segment.\n+ */\n+static struct ice_buf_table *ice_find_buf_table(struct ice_seg *ice_seg)\n+{\n+\tstruct ice_nvm_table *nvms;\n+\n+\tnvms = (struct ice_nvm_table *)(ice_seg->device_table +\n+\t       le32_to_cpu(ice_seg->device_table_count));\n+\n+\treturn (__force struct ice_buf_table *)\n+\t       (nvms->vers + le32_to_cpu(nvms->table_count));\n+}\n+\n+/**\n+ * ice_acquire_global_cfg_lock\n+ * @hw: pointer to the HW structure\n+ * @access: access type (read or write)\n+ *\n+ * This function will request ownership of the global config lock for reading\n+ * or writing of the package. When attempting to obtain write access, the\n+ * caller must check for the following two return values:\n+ *\n+ * ICE_SUCCESS        - Means the caller has acquired the global config lock\n+ *                      and can perform writing of the package.\n+ * ICE_ERR_AQ_NO_WORK - Indicates another driver has already written the\n+ *                      package or has found that no update was necessary; in\n+ *                      this case, the caller can just skip performing any\n+ *                      update of the package.\n+ */\n+static enum ice_status\n+ice_acquire_global_cfg_lock(struct ice_hw *hw,\n+\t\t\t    enum ice_aq_res_access_type access)\n+{\n+\tenum ice_status status;\n+\n+\tstatus = ice_acquire_res(hw, ICE_GLOBAL_CFG_LOCK_RES_ID, access,\n+\t\t\t\t ICE_GLOBAL_CFG_LOCK_TIMEOUT);\n+\n+\tif (!status)\n+\t\tmutex_lock(&ice_global_cfg_lock_sw);\n+\telse if (status == ICE_ERR_AQ_NO_WORK)\n+\t\tice_debug(hw, ICE_DBG_PKG,\n+\t\t\t  \"Global config lock: No work to do\\n\");\n+\n+\treturn status;\n+}\n+\n+/**\n+ * ice_release_global_cfg_lock\n+ * @hw: pointer to the HW structure\n+ *\n+ * This function will release the global config lock.\n+ */\n+static void ice_release_global_cfg_lock(struct ice_hw *hw)\n+{\n+\tmutex_unlock(&ice_global_cfg_lock_sw);\n+\tice_release_res(hw, ICE_GLOBAL_CFG_LOCK_RES_ID);\n+}\n+\n+/**\n+ * ice_aq_download_pkg\n+ * @hw: pointer to the hardware structure\n+ * @pkg_buf: the package buffer to transfer\n+ * @buf_size: the size of the package buffer\n+ * @last_buf: last buffer indicator\n+ * @error_offset: returns error offset\n+ * @error_info: returns error information\n+ * @cd: pointer to command details structure or NULL\n+ *\n+ * Download Package (0x0C40)\n+ */\n+static enum ice_status\n+ice_aq_download_pkg(struct ice_hw *hw, struct ice_buf_hdr *pkg_buf,\n+\t\t    u16 buf_size, bool last_buf, u32 *error_offset,\n+\t\t    u32 *error_info, struct ice_sq_cd *cd)\n+{\n+\tstruct ice_aqc_download_pkg *cmd;\n+\tstruct ice_aq_desc desc;\n+\tenum ice_status status;\n+\n+\tif (error_offset)\n+\t\t*error_offset = 0;\n+\tif (error_info)\n+\t\t*error_info = 0;\n+\n+\tcmd = &desc.params.download_pkg;\n+\tice_fill_dflt_direct_cmd_desc(&desc, ice_aqc_opc_download_pkg);\n+\tdesc.flags |= cpu_to_le16(ICE_AQ_FLAG_RD);\n+\n+\tif (last_buf)\n+\t\tcmd->flags |= ICE_AQC_DOWNLOAD_PKG_LAST_BUF;\n+\n+\tstatus = ice_aq_send_cmd(hw, &desc, pkg_buf, buf_size, cd);\n+\tif (status == ICE_ERR_AQ_ERROR) {\n+\t\t/* Read error from buffer only when the FW returned an error */\n+\t\tstruct ice_aqc_download_pkg_resp *resp;\n+\n+\t\tresp = (struct ice_aqc_download_pkg_resp *)pkg_buf;\n+\t\tif (error_offset)\n+\t\t\t*error_offset = le32_to_cpu(resp->error_offset);\n+\t\tif (error_info)\n+\t\t\t*error_info = le32_to_cpu(resp->error_info);\n+\t}\n+\n+\treturn status;\n+}\n+\n+/**\n+ * ice_find_seg_in_pkg\n+ * @hw: pointer to the hardware structure\n+ * @seg_type: the segment type to search for (i.e., SEGMENT_TYPE_CPK)\n+ * @pkg_hdr: pointer to the package header to be searched\n+ *\n+ * This function searches a package file for a particular segment type. On\n+ * success it returns a pointer to the segment header, otherwise it will\n+ * return NULL.\n+ */\n+static struct ice_generic_seg_hdr *\n+ice_find_seg_in_pkg(struct ice_hw *hw, u32 seg_type,\n+\t\t    struct ice_pkg_hdr *pkg_hdr)\n+{\n+\tu32 i;\n+\n+\tice_debug(hw, ICE_DBG_PKG, \"Package format version: %d.%d.%d.%d\\n\",\n+\t\t  pkg_hdr->format_ver.major, pkg_hdr->format_ver.minor,\n+\t\t  pkg_hdr->format_ver.update, pkg_hdr->format_ver.draft);\n+\n+\t/* Search all package segments for the requested segment type */\n+\tfor (i = 0; i < le32_to_cpu(pkg_hdr->seg_count); i++) {\n+\t\tstruct ice_generic_seg_hdr *seg;\n+\n+\t\tseg = (struct ice_generic_seg_hdr *)\n+\t\t\t((u8 *)pkg_hdr + le32_to_cpu(pkg_hdr->seg_offset[i]));\n+\n+\t\tif (le32_to_cpu(seg->seg_type) == seg_type)\n+\t\t\treturn seg;\n+\t}\n+\n+\treturn NULL;\n+}\n+\n+/**\n+ * ice_dwnld_cfg_bufs\n+ * @hw: pointer to the hardware structure\n+ * @bufs: pointer to an array of buffers\n+ * @count: the number of buffers in the array\n+ *\n+ * Obtains global config lock and downloads the package configuration buffers\n+ * to the firmware. Metadata buffers are skipped, and the first metadata buffer\n+ * found indicates that the rest of the buffers are all metadata buffers.\n+ */\n+static enum ice_status\n+ice_dwnld_cfg_bufs(struct ice_hw *hw, struct ice_buf *bufs, u32 count)\n+{\n+\tenum ice_status status;\n+\tstruct ice_buf_hdr *bh;\n+\tu32 offset, info, i;\n+\n+\tif (!bufs || !count)\n+\t\treturn ICE_ERR_PARAM;\n+\n+\t/* If the first buffer's first section has its metadata bit set\n+\t * then there are no buffers to be downloaded, and the operation is\n+\t * considered a success.\n+\t */\n+\tbh = (struct ice_buf_hdr *)bufs;\n+\tif (le32_to_cpu(bh->section_entry[0].type) & ICE_METADATA_BUF)\n+\t\treturn 0;\n+\n+\t/* reset pkg_dwnld_status in case this function is called in the\n+\t * reset/rebuild flow\n+\t */\n+\thw->pkg_dwnld_status = ICE_AQ_RC_OK;\n+\n+\tstatus = ice_acquire_global_cfg_lock(hw, ICE_RES_WRITE);\n+\tif (status) {\n+\t\tif (status == ICE_ERR_AQ_NO_WORK)\n+\t\t\thw->pkg_dwnld_status = ICE_AQ_RC_EEXIST;\n+\t\telse\n+\t\t\thw->pkg_dwnld_status = hw->adminq.sq_last_status;\n+\t\treturn status;\n+\t}\n+\n+\tfor (i = 0; i < count; i++) {\n+\t\tbool last = ((i + 1) == count);\n+\n+\t\tif (!last) {\n+\t\t\t/* check next buffer for metadata flag */\n+\t\t\tbh = (struct ice_buf_hdr *)(bufs + i + 1);\n+\n+\t\t\t/* A set metadata flag in the next buffer will signal\n+\t\t\t * that the current buffer will be the last buffer\n+\t\t\t * downloaded\n+\t\t\t */\n+\t\t\tif (le16_to_cpu(bh->section_count))\n+\t\t\t\tif (le32_to_cpu(bh->section_entry[0].type) &\n+\t\t\t\t    ICE_METADATA_BUF)\n+\t\t\t\t\tlast = true;\n+\t\t}\n+\n+\t\tbh = (struct ice_buf_hdr *)(bufs + i);\n+\n+\t\tstatus = ice_aq_download_pkg(hw, bh, ICE_PKG_BUF_SIZE, last,\n+\t\t\t\t\t     &offset, &info, NULL);\n+\n+\t\t/* Save AQ status from download package */\n+\t\thw->pkg_dwnld_status = hw->adminq.sq_last_status;\n+\t\tif (status) {\n+\t\t\tice_debug(hw, ICE_DBG_PKG,\n+\t\t\t\t  \"Pkg download failed: err %d off %d inf %d\\n\",\n+\t\t\t\t  status, offset, info);\n+\n+\t\t\tbreak;\n+\t\t}\n+\n+\t\tif (last)\n+\t\t\tbreak;\n+\t}\n+\n+\tice_release_global_cfg_lock(hw);\n+\n+\treturn status;\n+}\n+\n+/**\n+ * ice_aq_get_pkg_info_list\n+ * @hw: pointer to the hardware structure\n+ * @pkg_info: the buffer which will receive the information list\n+ * @buf_size: the size of the pkg_info information buffer\n+ * @cd: pointer to command details structure or NULL\n+ *\n+ * Get Package Info List (0x0C43)\n+ */\n+static enum ice_status\n+ice_aq_get_pkg_info_list(struct ice_hw *hw,\n+\t\t\t struct ice_aqc_get_pkg_info_resp *pkg_info,\n+\t\t\t u16 buf_size, struct ice_sq_cd *cd)\n+{\n+\tstruct ice_aq_desc desc;\n+\n+\tice_fill_dflt_direct_cmd_desc(&desc, ice_aqc_opc_get_pkg_info_list);\n+\n+\treturn ice_aq_send_cmd(hw, &desc, pkg_info, buf_size, cd);\n+}\n+\n+/**\n+ * ice_download_pkg\n+ * @hw: pointer to the hardware structure\n+ * @ice_seg: pointer to the segment of the package to be downloaded\n+ *\n+ * Handles the download of a complete package.\n+ */\n+static enum ice_status\n+ice_download_pkg(struct ice_hw *hw, struct ice_seg *ice_seg)\n+{\n+\tstruct ice_buf_table *ice_buf_tbl;\n+\n+\tice_debug(hw, ICE_DBG_PKG, \"Segment version: %d.%d.%d.%d\\n\",\n+\t\t  ice_seg->hdr.seg_ver.major, ice_seg->hdr.seg_ver.minor,\n+\t\t  ice_seg->hdr.seg_ver.update, ice_seg->hdr.seg_ver.draft);\n+\n+\tice_debug(hw, ICE_DBG_PKG, \"Seg: type 0x%X, size %d, name %s\\n\",\n+\t\t  le32_to_cpu(ice_seg->hdr.seg_type),\n+\t\t  le32_to_cpu(ice_seg->hdr.seg_size), ice_seg->hdr.seg_name);\n+\n+\tice_buf_tbl = ice_find_buf_table(ice_seg);\n+\n+\tice_debug(hw, ICE_DBG_PKG, \"Seg buf count: %d\\n\",\n+\t\t  le32_to_cpu(ice_buf_tbl->buf_count));\n+\n+\treturn ice_dwnld_cfg_bufs(hw, ice_buf_tbl->buf_array,\n+\t\t\t\t  le32_to_cpu(ice_buf_tbl->buf_count));\n+}\n+\n+/**\n+ * ice_init_pkg_info\n+ * @hw: pointer to the hardware structure\n+ * @pkg_hdr: pointer to the driver's package hdr\n+ *\n+ * Saves off the package details into the HW structure.\n+ */\n+static enum ice_status\n+ice_init_pkg_info(struct ice_hw *hw, struct ice_pkg_hdr *pkg_hdr)\n+{\n+\tstruct ice_global_metadata_seg *meta_seg;\n+\tstruct ice_generic_seg_hdr *seg_hdr;\n+\n+\tif (!pkg_hdr)\n+\t\treturn ICE_ERR_PARAM;\n+\n+\tmeta_seg = (struct ice_global_metadata_seg *)\n+\t\t   ice_find_seg_in_pkg(hw, SEGMENT_TYPE_METADATA, pkg_hdr);\n+\tif (meta_seg) {\n+\t\thw->pkg_ver = meta_seg->pkg_ver;\n+\t\tmemcpy(hw->pkg_name, meta_seg->pkg_name, sizeof(hw->pkg_name));\n+\n+\t\tice_debug(hw, ICE_DBG_PKG, \"Pkg: %d.%d.%d.%d, %s\\n\",\n+\t\t\t  meta_seg->pkg_ver.major, meta_seg->pkg_ver.minor,\n+\t\t\t  meta_seg->pkg_ver.update, meta_seg->pkg_ver.draft,\n+\t\t\t  meta_seg->pkg_name);\n+\t} else {\n+\t\tice_debug(hw, ICE_DBG_INIT,\n+\t\t\t  \"Did not find metadata segment in driver package\\n\");\n+\t\treturn ICE_ERR_CFG;\n+\t}\n+\n+\tseg_hdr = ice_find_seg_in_pkg(hw, SEGMENT_TYPE_ICE, pkg_hdr);\n+\tif (seg_hdr) {\n+\t\thw->ice_pkg_ver = seg_hdr->seg_ver;\n+\t\tmemcpy(hw->ice_pkg_name, seg_hdr->seg_name,\n+\t\t       sizeof(hw->ice_pkg_name));\n+\n+\t\tice_debug(hw, ICE_DBG_PKG, \"Ice Pkg: %d.%d.%d.%d, %s\\n\",\n+\t\t\t  seg_hdr->seg_ver.major, seg_hdr->seg_ver.minor,\n+\t\t\t  seg_hdr->seg_ver.update, seg_hdr->seg_ver.draft,\n+\t\t\t  seg_hdr->seg_name);\n+\t} else {\n+\t\tice_debug(hw, ICE_DBG_INIT,\n+\t\t\t  \"Did not find ice segment in driver package\\n\");\n+\t\treturn ICE_ERR_CFG;\n+\t}\n+\n+\treturn 0;\n+}\n+\n+/**\n+ * ice_get_pkg_info\n+ * @hw: pointer to the hardware structure\n+ *\n+ * Store details of the package currently loaded in HW into the HW structure.\n+ */\n+static enum ice_status ice_get_pkg_info(struct ice_hw *hw)\n+{\n+\tstruct ice_aqc_get_pkg_info_resp *pkg_info;\n+\tenum ice_status status;\n+\tu16 size;\n+\tu32 i;\n+\n+\tsize = sizeof(*pkg_info) + (sizeof(pkg_info->pkg_info[0]) *\n+\t\t\t\t    (ICE_PKG_CNT - 1));\n+\tpkg_info = kzalloc(size, GFP_KERNEL);\n+\tif (!pkg_info)\n+\t\treturn ICE_ERR_NO_MEMORY;\n+\n+\tstatus = ice_aq_get_pkg_info_list(hw, pkg_info, size, NULL);\n+\tif (status)\n+\t\tgoto init_pkg_free_alloc;\n+\n+\tfor (i = 0; i < le32_to_cpu(pkg_info->count); i++) {\n+#define ICE_PKG_FLAG_COUNT\t4\n+\t\tchar flags[ICE_PKG_FLAG_COUNT + 1] = { 0 };\n+\t\tu8 place = 0;\n+\n+\t\tif (pkg_info->pkg_info[i].is_active) {\n+\t\t\tflags[place++] = 'A';\n+\t\t\thw->active_pkg_ver = pkg_info->pkg_info[i].ver;\n+\t\t\tmemcpy(hw->active_pkg_name,\n+\t\t\t       pkg_info->pkg_info[i].name,\n+\t\t\t       sizeof(hw->active_pkg_name));\n+\t\t\thw->active_pkg_in_nvm = pkg_info->pkg_info[i].is_in_nvm;\n+\t\t}\n+\t\tif (pkg_info->pkg_info[i].is_active_at_boot)\n+\t\t\tflags[place++] = 'B';\n+\t\tif (pkg_info->pkg_info[i].is_modified)\n+\t\t\tflags[place++] = 'M';\n+\t\tif (pkg_info->pkg_info[i].is_in_nvm)\n+\t\t\tflags[place++] = 'N';\n+\n+\t\tice_debug(hw, ICE_DBG_PKG, \"Pkg[%d]: %d.%d.%d.%d,%s,%s\\n\",\n+\t\t\t  i, pkg_info->pkg_info[i].ver.major,\n+\t\t\t  pkg_info->pkg_info[i].ver.minor,\n+\t\t\t  pkg_info->pkg_info[i].ver.update,\n+\t\t\t  pkg_info->pkg_info[i].ver.draft,\n+\t\t\t  pkg_info->pkg_info[i].name, flags);\n+\t}\n+\n+init_pkg_free_alloc:\n+\tkfree(pkg_info);\n+\n+\treturn status;\n+}\n+\n+/**\n+ * ice_verify_pkg - verify package\n+ * @pkg: pointer to the package buffer\n+ * @len: size of the package buffer\n+ *\n+ * Verifies various attributes of the package file, including length, format\n+ * version, and the requirement of at least one segment.\n+ */\n+static enum ice_status ice_verify_pkg(struct ice_pkg_hdr *pkg, u32 len)\n+{\n+\tu32 seg_count;\n+\tu32 i;\n+\n+\tif (len < sizeof(*pkg))\n+\t\treturn ICE_ERR_BUF_TOO_SHORT;\n+\n+\tif (pkg->format_ver.major != ICE_PKG_FMT_VER_MAJ ||\n+\t    pkg->format_ver.minor != ICE_PKG_FMT_VER_MNR ||\n+\t    pkg->format_ver.update != ICE_PKG_FMT_VER_UPD ||\n+\t    pkg->format_ver.draft != ICE_PKG_FMT_VER_DFT)\n+\t\treturn ICE_ERR_CFG;\n+\n+\t/* pkg must have at least one segment */\n+\tseg_count = le32_to_cpu(pkg->seg_count);\n+\tif (seg_count < 1)\n+\t\treturn ICE_ERR_CFG;\n+\n+\t/* make sure segment array fits in package length */\n+\tif (len < sizeof(*pkg) + ((seg_count - 1) * sizeof(pkg->seg_offset)))\n+\t\treturn ICE_ERR_BUF_TOO_SHORT;\n+\n+\t/* all segments must fit within length */\n+\tfor (i = 0; i < seg_count; i++) {\n+\t\tu32 off = le32_to_cpu(pkg->seg_offset[i]);\n+\t\tstruct ice_generic_seg_hdr *seg;\n+\n+\t\t/* segment header must fit */\n+\t\tif (len < off + sizeof(*seg))\n+\t\t\treturn ICE_ERR_BUF_TOO_SHORT;\n+\n+\t\tseg = (struct ice_generic_seg_hdr *)((u8 *)pkg + off);\n+\n+\t\t/* segment body must fit */\n+\t\tif (len < off + le32_to_cpu(seg->seg_size))\n+\t\t\treturn ICE_ERR_BUF_TOO_SHORT;\n+\t}\n+\n+\treturn 0;\n+}\n+\n+/**\n+ * ice_free_seg - free package segment pointer\n+ * @hw: pointer to the hardware structure\n+ *\n+ * Frees the package segment pointer in the proper manner, depending on if the\n+ * segment was allocated or just the passed in pointer was stored.\n+ */\n+void ice_free_seg(struct ice_hw *hw)\n+{\n+\tif (hw->pkg_copy) {\n+\t\tdevm_kfree(ice_hw_to_dev(hw), hw->pkg_copy);\n+\t\thw->pkg_copy = NULL;\n+\t\thw->pkg_size = 0;\n+\t}\n+\thw->seg = NULL;\n+}\n+\n+/**\n+ * ice_chk_pkg_version - check package version for compatibility with driver\n+ * @pkg_ver: pointer to a version structure to check\n+ *\n+ * Check to make sure that the package about to be downloaded is compatible with\n+ * the driver. To be compatible, the major and minor components of the package\n+ * version must match our ICE_PKG_SUPP_VER_MAJ and ICE_PKG_SUPP_VER_MNR\n+ * definitions.\n+ */\n+static enum ice_status ice_chk_pkg_version(struct ice_pkg_ver *pkg_ver)\n+{\n+\tif (pkg_ver->major != ICE_PKG_SUPP_VER_MAJ ||\n+\t    pkg_ver->minor != ICE_PKG_SUPP_VER_MNR)\n+\t\treturn ICE_ERR_NOT_SUPPORTED;\n+\n+\treturn 0;\n+}\n+\n+/**\n+ * ice_init_pkg - initialize/download package\n+ * @hw: pointer to the hardware structure\n+ * @buf: pointer to the package buffer\n+ * @len: size of the package buffer\n+ *\n+ * This function initializes a package. The package contains HW tables\n+ * required to do packet processing. First, the function extracts package\n+ * information such as version. Then it finds the ice configuration segment\n+ * within the package; this function then saves a copy of the segment pointer\n+ * within the supplied package buffer. Next, the function will cache any hints\n+ * from the package, followed by downloading the package itself. Note, that if\n+ * a previous PF driver has already downloaded the package successfully, then\n+ * the current driver will not have to download the package again.\n+ *\n+ * The local package contents will be used to query default behavior and to\n+ * update specific sections of the HW's version of the package (e.g. to update\n+ * the parse graph to understand new protocols).\n+ *\n+ * This function stores a pointer to the package buffer memory, and it is\n+ * expected that the supplied buffer will not be freed immediately. If the\n+ * package buffer needs to be freed, such as when read from a file, use\n+ * ice_copy_and_init_pkg() instead of directly calling ice_init_pkg() in this\n+ * case.\n+ */\n+enum ice_status ice_init_pkg(struct ice_hw *hw, u8 *buf, u32 len)\n+{\n+\tstruct ice_pkg_hdr *pkg;\n+\tenum ice_status status;\n+\tstruct ice_seg *seg;\n+\n+\tif (!buf || !len)\n+\t\treturn ICE_ERR_PARAM;\n+\n+\tpkg = (struct ice_pkg_hdr *)buf;\n+\tstatus = ice_verify_pkg(pkg, len);\n+\tif (status) {\n+\t\tice_debug(hw, ICE_DBG_INIT, \"failed to verify pkg (err: %d)\\n\",\n+\t\t\t  status);\n+\t\treturn status;\n+\t}\n+\n+\t/* initialize package info */\n+\tstatus = ice_init_pkg_info(hw, pkg);\n+\tif (status)\n+\t\treturn status;\n+\n+\t/* before downloading the package, check package version for\n+\t * compatibility with driver\n+\t */\n+\tstatus = ice_chk_pkg_version(&hw->pkg_ver);\n+\tif (status)\n+\t\treturn status;\n+\n+\t/* find segment in given package */\n+\tseg = (struct ice_seg *)ice_find_seg_in_pkg(hw, SEGMENT_TYPE_ICE, pkg);\n+\tif (!seg) {\n+\t\tice_debug(hw, ICE_DBG_INIT, \"no ice segment in package.\\n\");\n+\t\treturn ICE_ERR_CFG;\n+\t}\n+\n+\t/* download package */\n+\tstatus = ice_download_pkg(hw, seg);\n+\tif (status == ICE_ERR_AQ_NO_WORK) {\n+\t\tice_debug(hw, ICE_DBG_INIT,\n+\t\t\t  \"package previously loaded - no work.\\n\");\n+\t\tstatus = 0;\n+\t}\n+\n+\t/* Get information on the package currently loaded in HW, then make sure\n+\t * the driver is compatible with this version.\n+\t */\n+\tif (!status) {\n+\t\tstatus = ice_get_pkg_info(hw);\n+\t\tif (!status)\n+\t\t\tstatus = ice_chk_pkg_version(&hw->active_pkg_ver);\n+\t}\n+\n+\tif (status)\n+\t\tice_debug(hw, ICE_DBG_INIT, \"package load failed, %d\\n\",\n+\t\t\t  status);\n+\n+\treturn status;\n+}\n+\n+/**\n+ * ice_copy_and_init_pkg - initialize/download a copy of the package\n+ * @hw: pointer to the hardware structure\n+ * @buf: pointer to the package buffer\n+ * @len: size of the package buffer\n+ *\n+ * This function copies the package buffer, and then calls ice_init_pkg() to\n+ * initialize the copied package contents.\n+ *\n+ * The copying is necessary if the package buffer supplied is constant, or if\n+ * the memory may disappear shortly after calling this function.\n+ *\n+ * If the package buffer resides in the data segment and can be modified, the\n+ * caller is free to use ice_init_pkg() instead of ice_copy_and_init_pkg().\n+ *\n+ * However, if the package buffer needs to be copied first, such as when being\n+ * read from a file, the caller should use ice_copy_and_init_pkg().\n+ *\n+ * This function will first copy the package buffer, before calling\n+ * ice_init_pkg(). The caller is free to immediately destroy the original\n+ * package buffer, as the new copy will be managed by this function and\n+ * related routines.\n+ */\n+enum ice_status ice_copy_and_init_pkg(struct ice_hw *hw, const u8 *buf, u32 len)\n+{\n+\tenum ice_status status;\n+\tu8 *buf_copy;\n+\n+\tif (!buf || !len)\n+\t\treturn ICE_ERR_PARAM;\n+\n+\tbuf_copy = devm_kmemdup(ice_hw_to_dev(hw), buf, len, GFP_KERNEL);\n+\n+\tstatus = ice_init_pkg(hw, buf_copy, len);\n+\tif (status) {\n+\t\t/* Free the copy, since we failed to initialize the package */\n+\t\tdevm_kfree(ice_hw_to_dev(hw), buf_copy);\n+\t} else {\n+\t\t/* Track the copied pkg so we can free it later */\n+\t\thw->pkg_copy = buf_copy;\n+\t\thw->pkg_size = len;\n+\t}\n+\n+\treturn status;\n+}\ndiff --git a/drivers/net/ethernet/intel/ice/ice_flex_pipe.h b/drivers/net/ethernet/intel/ice/ice_flex_pipe.h\nnew file mode 100644\nindex 000000000000..3843c462bc42\n--- /dev/null\n+++ b/drivers/net/ethernet/intel/ice/ice_flex_pipe.h\n@@ -0,0 +1,25 @@\n+/* SPDX-License-Identifier: GPL-2.0 */\n+/* Copyright (c) 2019, Intel Corporation. */\n+\n+#ifndef _ICE_FLEX_PIPE_H_\n+#define _ICE_FLEX_PIPE_H_\n+\n+#include \"ice_type.h\"\n+\n+/* Package minimal version supported */\n+#define ICE_PKG_SUPP_VER_MAJ\t1\n+#define ICE_PKG_SUPP_VER_MNR\t3\n+\n+/* Package format version */\n+#define ICE_PKG_FMT_VER_MAJ\t1\n+#define ICE_PKG_FMT_VER_MNR\t0\n+#define ICE_PKG_FMT_VER_UPD\t0\n+#define ICE_PKG_FMT_VER_DFT\t0\n+\n+#define ICE_PKG_CNT 4\n+\n+enum ice_status ice_init_pkg(struct ice_hw *hw, u8 *buff, u32 len);\n+enum ice_status\n+ice_copy_and_init_pkg(struct ice_hw *hw, const u8 *buf, u32 len);\n+void ice_free_seg(struct ice_hw *hw);\n+#endif /* _ICE_FLEX_PIPE_H_ */\ndiff --git a/drivers/net/ethernet/intel/ice/ice_flex_type.h b/drivers/net/ethernet/intel/ice/ice_flex_type.h\nnew file mode 100644\nindex 000000000000..b7fb90594faf\n--- /dev/null\n+++ b/drivers/net/ethernet/intel/ice/ice_flex_type.h\n@@ -0,0 +1,372 @@\n+/* SPDX-License-Identifier: GPL-2.0 */\n+/* Copyright (c) 2019, Intel Corporation. */\n+\n+#ifndef _ICE_FLEX_TYPE_H_\n+#define _ICE_FLEX_TYPE_H_\n+/* Extraction Sequence (Field Vector) Table */\n+struct ice_fv_word {\n+\tu8 prot_id;\n+\tu16 off;\t\t/* Offset within the protocol header */\n+\tu8 resvrd;\n+} __packed;\n+\n+#define ICE_MAX_FV_WORDS 48\n+struct ice_fv {\n+\tstruct ice_fv_word ew[ICE_MAX_FV_WORDS];\n+};\n+\n+/* Package and segment headers and tables */\n+struct ice_pkg_hdr {\n+\tstruct ice_pkg_ver format_ver;\n+\t__le32 seg_count;\n+\t__le32 seg_offset[1];\n+};\n+\n+/* generic segment */\n+struct ice_generic_seg_hdr {\n+#define SEGMENT_TYPE_METADATA\t0x00000001\n+#define SEGMENT_TYPE_ICE\t0x00000010\n+\t__le32 seg_type;\n+\tstruct ice_pkg_ver seg_ver;\n+\t__le32 seg_size;\n+\tchar seg_name[ICE_PKG_NAME_SIZE];\n+};\n+\n+/* ice specific segment */\n+\n+union ice_device_id {\n+\tstruct {\n+\t\t__le16 device_id;\n+\t\t__le16 vendor_id;\n+\t} dev_vend_id;\n+\t__le32 id;\n+};\n+\n+struct ice_device_id_entry {\n+\tunion ice_device_id device;\n+\tunion ice_device_id sub_device;\n+};\n+\n+struct ice_seg {\n+\tstruct ice_generic_seg_hdr hdr;\n+\t__le32 device_table_count;\n+\tstruct ice_device_id_entry device_table[1];\n+};\n+\n+struct ice_nvm_table {\n+\t__le32 table_count;\n+\t__le32 vers[1];\n+};\n+\n+struct ice_buf {\n+#define ICE_PKG_BUF_SIZE\t4096\n+\tu8 buf[ICE_PKG_BUF_SIZE];\n+};\n+\n+struct ice_buf_table {\n+\t__le32 buf_count;\n+\tstruct ice_buf buf_array[1];\n+};\n+\n+/* global metadata specific segment */\n+struct ice_global_metadata_seg {\n+\tstruct ice_generic_seg_hdr hdr;\n+\tstruct ice_pkg_ver pkg_ver;\n+\t__le32 track_id;\n+\tchar pkg_name[ICE_PKG_NAME_SIZE];\n+};\n+\n+#define ICE_MIN_S_OFF\t\t12\n+#define ICE_MAX_S_OFF\t\t4095\n+#define ICE_MIN_S_SZ\t\t1\n+#define ICE_MAX_S_SZ\t\t4084\n+\n+/* section information */\n+struct ice_section_entry {\n+\t__le32 type;\n+\t__le16 offset;\n+\t__le16 size;\n+};\n+\n+#define ICE_MIN_S_COUNT\t\t1\n+#define ICE_MAX_S_COUNT\t\t511\n+#define ICE_MIN_S_DATA_END\t12\n+#define ICE_MAX_S_DATA_END\t4096\n+\n+#define ICE_METADATA_BUF\t0x80000000\n+\n+struct ice_buf_hdr {\n+\t__le16 section_count;\n+\t__le16 data_end;\n+\tstruct ice_section_entry section_entry[1];\n+};\n+\n+#define ICE_MAX_ENTRIES_IN_BUF(hd_sz, ent_sz) ((ICE_PKG_BUF_SIZE - \\\n+\tsizeof(struct ice_buf_hdr) - (hd_sz)) / (ent_sz))\n+\n+/* ice package section IDs */\n+#define ICE_SID_XLT1_SW\t\t\t12\n+#define ICE_SID_XLT2_SW\t\t\t13\n+#define ICE_SID_PROFID_TCAM_SW\t\t14\n+#define ICE_SID_PROFID_REDIR_SW\t\t15\n+#define ICE_SID_FLD_VEC_SW\t\t16\n+\n+#define ICE_SID_XLT1_ACL\t\t22\n+#define ICE_SID_XLT2_ACL\t\t23\n+#define ICE_SID_PROFID_TCAM_ACL\t\t24\n+#define ICE_SID_PROFID_REDIR_ACL\t25\n+#define ICE_SID_FLD_VEC_ACL\t\t26\n+\n+#define ICE_SID_XLT1_FD\t\t\t32\n+#define ICE_SID_XLT2_FD\t\t\t33\n+#define ICE_SID_PROFID_TCAM_FD\t\t34\n+#define ICE_SID_PROFID_REDIR_FD\t\t35\n+#define ICE_SID_FLD_VEC_FD\t\t36\n+\n+#define ICE_SID_XLT1_RSS\t\t42\n+#define ICE_SID_XLT2_RSS\t\t43\n+#define ICE_SID_PROFID_TCAM_RSS\t\t44\n+#define ICE_SID_PROFID_REDIR_RSS\t45\n+#define ICE_SID_FLD_VEC_RSS\t\t46\n+\n+#define ICE_SID_RXPARSER_BOOST_TCAM\t56\n+\n+#define ICE_SID_XLT1_PE\t\t\t82\n+#define ICE_SID_XLT2_PE\t\t\t83\n+#define ICE_SID_PROFID_TCAM_PE\t\t84\n+#define ICE_SID_PROFID_REDIR_PE\t\t85\n+#define ICE_SID_FLD_VEC_PE\t\t86\n+\n+/* Label Metadata section IDs */\n+#define ICE_SID_LBL_FIRST\t\t0x80000010\n+#define ICE_SID_LBL_RXPARSER_TMEM\t0x80000018\n+/* The following define MUST be updated to reflect the last label section ID */\n+#define ICE_SID_LBL_LAST\t\t0x80000038\n+\n+enum ice_block {\n+\tICE_BLK_SW = 0,\n+\tICE_BLK_ACL,\n+\tICE_BLK_FD,\n+\tICE_BLK_RSS,\n+\tICE_BLK_PE,\n+\tICE_BLK_COUNT\n+};\n+\n+/* package labels */\n+struct ice_label {\n+\t__le16 value;\n+#define ICE_PKG_LABEL_SIZE\t64\n+\tchar name[ICE_PKG_LABEL_SIZE];\n+};\n+\n+struct ice_label_section {\n+\t__le16 count;\n+\tstruct ice_label label[1];\n+};\n+\n+#define ICE_MAX_LABELS_IN_BUF ICE_MAX_ENTRIES_IN_BUF( \\\n+\tsizeof(struct ice_label_section) - sizeof(struct ice_label), \\\n+\tsizeof(struct ice_label))\n+\n+struct ice_sw_fv_section {\n+\t__le16 count;\n+\t__le16 base_offset;\n+\tstruct ice_fv fv[1];\n+};\n+\n+/* The BOOST TCAM stores the match packet header in reverse order, meaning\n+ * the fields are reversed; in addition, this means that the normally big endian\n+ * fields of the packet are now little endian.\n+ */\n+struct ice_boost_key_value {\n+#define ICE_BOOST_REMAINING_HV_KEY\t15\n+\tu8 remaining_hv_key[ICE_BOOST_REMAINING_HV_KEY];\n+\t__le16 hv_dst_port_key;\n+\t__le16 hv_src_port_key;\n+\tu8 tcam_search_key;\n+} __packed;\n+\n+struct ice_boost_key {\n+\tstruct ice_boost_key_value key;\n+\tstruct ice_boost_key_value key2;\n+};\n+\n+/* package Boost TCAM entry */\n+struct ice_boost_tcam_entry {\n+\t__le16 addr;\n+\t__le16 reserved;\n+\t/* break up the 40 bytes of key into different fields */\n+\tstruct ice_boost_key key;\n+\tu8 boost_hit_index_group;\n+\t/* The following contains bitfields which are not on byte boundaries.\n+\t * These fields are currently unused by driver software.\n+\t */\n+#define ICE_BOOST_BIT_FIELDS\t\t43\n+\tu8 bit_fields[ICE_BOOST_BIT_FIELDS];\n+};\n+\n+struct ice_boost_tcam_section {\n+\t__le16 count;\n+\t__le16 reserved;\n+\tstruct ice_boost_tcam_entry tcam[1];\n+};\n+\n+#define ICE_MAX_BST_TCAMS_IN_BUF ICE_MAX_ENTRIES_IN_BUF( \\\n+\tsizeof(struct ice_boost_tcam_section) - \\\n+\tsizeof(struct ice_boost_tcam_entry), \\\n+\tsizeof(struct ice_boost_tcam_entry))\n+\n+struct ice_xlt1_section {\n+\t__le16 count;\n+\t__le16 offset;\n+\tu8 value[1];\n+} __packed;\n+\n+struct ice_xlt2_section {\n+\t__le16 count;\n+\t__le16 offset;\n+\t__le16 value[1];\n+};\n+\n+struct ice_prof_redir_section {\n+\t__le16 count;\n+\t__le16 offset;\n+\tu8 redir_value[1];\n+};\n+\n+struct ice_pkg_enum {\n+\tstruct ice_buf_table *buf_table;\n+\tu32 buf_idx;\n+\n+\tu32 type;\n+\tstruct ice_buf_hdr *buf;\n+\tu32 sect_idx;\n+\tvoid *sect;\n+\tu32 sect_type;\n+\n+\tu32 entry_idx;\n+\tvoid *(*handler)(u32 sect_type, void *section, u32 index, u32 *offset);\n+};\n+\n+struct ice_es {\n+\tu32 sid;\n+\tu16 count;\n+\tu16 fvw;\n+\tu16 *ref_count;\n+\tstruct list_head prof_map;\n+\tstruct ice_fv_word *t;\n+\tstruct mutex prof_map_lock;\t/* protect access to profiles list */\n+\tu8 *written;\n+\tu8 reverse; /* set to true to reverse FV order */\n+};\n+\n+/* PTYPE Group management */\n+\n+/* Note: XLT1 table takes 13-bit as input, and results in an 8-bit packet type\n+ * group (PTG) ID as output.\n+ *\n+ * Note: PTG 0 is the default packet type group and it is assumed that all PTYPE\n+ * are a part of this group until moved to a new PTG.\n+ */\n+#define ICE_DEFAULT_PTG\t0\n+\n+struct ice_ptg_entry {\n+\tstruct ice_ptg_ptype *first_ptype;\n+\tu8 in_use;\n+};\n+\n+struct ice_ptg_ptype {\n+\tstruct ice_ptg_ptype *next_ptype;\n+\tu8 ptg;\n+};\n+\n+struct ice_vsig_entry {\n+\tstruct list_head prop_lst;\n+\tstruct ice_vsig_vsi *first_vsi;\n+\tu8 in_use;\n+};\n+\n+struct ice_vsig_vsi {\n+\tstruct ice_vsig_vsi *next_vsi;\n+\tu32 prop_mask;\n+\tu16 changed;\n+\tu16 vsig;\n+};\n+\n+#define ICE_XLT1_CNT\t1024\n+\n+/* XLT1 Table */\n+struct ice_xlt1 {\n+\tstruct ice_ptg_entry *ptg_tbl;\n+\tstruct ice_ptg_ptype *ptypes;\n+\tu8 *t;\n+\tu32 sid;\n+\tu16 count;\n+};\n+\n+#define ICE_MAX_VSIGS\t768\n+\n+/* VSIG bit layout:\n+ * [0:12]: incremental VSIG index 1 to ICE_MAX_VSIGS\n+ * [13:15]: PF number of device\n+ */\n+#define ICE_VSIG_IDX_M\t(0x1FFF)\n+#define ICE_PF_NUM_S\t13\n+#define ICE_PF_NUM_M\t(0x07 << ICE_PF_NUM_S)\n+#define ICE_VSIG_VALUE(vsig, pf_id) \\\n+\t(u16)((((u16)(vsig)) & ICE_VSIG_IDX_M) | \\\n+\t      (((u16)(pf_id) << ICE_PF_NUM_S) & ICE_PF_NUM_M))\n+#define ICE_DEFAULT_VSIG\t0\n+\n+/* XLT2 Table */\n+struct ice_xlt2 {\n+\tstruct ice_vsig_entry *vsig_tbl;\n+\tstruct ice_vsig_vsi *vsis;\n+\tu16 *t;\n+\tu32 sid;\n+\tu16 count;\n+};\n+\n+/* Keys are made up of two values, each one-half the size of the key.\n+ * For TCAM, the entire key is 80 bits wide (or 2, 40-bit wide values)\n+ */\n+#define ICE_TCAM_KEY_VAL_SZ\t5\n+#define ICE_TCAM_KEY_SZ\t\t(2 * ICE_TCAM_KEY_VAL_SZ)\n+\n+struct ice_prof_tcam_entry {\n+\t__le16 addr;\n+\tu8 key[ICE_TCAM_KEY_SZ];\n+\tu8 prof_id;\n+} __packed;\n+\n+struct ice_prof_id_section {\n+\t__le16 count;\n+\tstruct ice_prof_tcam_entry entry[1];\n+} __packed;\n+\n+struct ice_prof_tcam {\n+\tu32 sid;\n+\tu16 count;\n+\tu16 max_prof_id;\n+\tstruct ice_prof_tcam_entry *t;\n+\tu8 cdid_bits; /* # CDID bits to use in key, 0, 2, 4, or 8 */\n+};\n+\n+struct ice_prof_redir {\n+\tu8 *t;\n+\tu32 sid;\n+\tu16 count;\n+};\n+\n+/* Tables per block */\n+struct ice_blk_info {\n+\tstruct ice_xlt1 xlt1;\n+\tstruct ice_xlt2 xlt2;\n+\tstruct ice_prof_tcam prof;\n+\tstruct ice_prof_redir prof_redir;\n+\tstruct ice_es es;\n+\tu8 overwrite; /* set to true to allow overwrite of table entries */\n+\tu8 is_list_init;\n+};\n+\n+#endif /* _ICE_FLEX_TYPE_H_ */\ndiff --git a/drivers/net/ethernet/intel/ice/ice_hw_autogen.h b/drivers/net/ethernet/intel/ice/ice_hw_autogen.h\nindex 6f78ff5534af..152fbd556e9b 100644\n--- a/drivers/net/ethernet/intel/ice/ice_hw_autogen.h\n+++ b/drivers/net/ethernet/intel/ice/ice_hw_autogen.h\n@@ -55,6 +55,8 @@\n #define PRTDCB_GENS\t\t\t\t0x00083020\n #define PRTDCB_GENS_DCBX_STATUS_S\t\t0\n #define PRTDCB_GENS_DCBX_STATUS_M\t\tICE_M(0x7, 0)\n+#define GL_PREEXT_L2_PMASK0(_i)\t\t\t(0x0020F0FC + ((_i) * 4))\n+#define GL_PREEXT_L2_PMASK1(_i)\t\t\t(0x0020F108 + ((_i) * 4))\n #define GLFLXP_RXDID_FLAGS(_i, _j)\t\t(0x0045D000 + ((_i) * 4 + (_j) * 256))\n #define GLFLXP_RXDID_FLAGS_FLEXIFLAG_4N_S\t0\n #define GLFLXP_RXDID_FLAGS_FLEXIFLAG_4N_M\tICE_M(0x3F, 0)\ndiff --git a/drivers/net/ethernet/intel/ice/ice_type.h b/drivers/net/ethernet/intel/ice/ice_type.h\nindex 7ec8a529b5cf..6667d17a4206 100644\n--- a/drivers/net/ethernet/intel/ice/ice_type.h\n+++ b/drivers/net/ethernet/intel/ice/ice_type.h\n@@ -12,6 +12,7 @@\n #include \"ice_osdep.h\"\n #include \"ice_controlq.h\"\n #include \"ice_lan_tx_rx.h\"\n+#include \"ice_flex_type.h\"\n \n static inline bool ice_is_tc_ena(unsigned long bitmap, u8 tc)\n {\n@@ -31,6 +32,7 @@ static inline bool ice_is_tc_ena(unsigned long bitmap, u8 tc)\n #define ICE_DBG_LAN\t\tBIT_ULL(8)\n #define ICE_DBG_SW\t\tBIT_ULL(13)\n #define ICE_DBG_SCHED\t\tBIT_ULL(14)\n+#define ICE_DBG_PKG\t\tBIT_ULL(16)\n #define ICE_DBG_RES\t\tBIT_ULL(17)\n #define ICE_DBG_AQ_MSG\t\tBIT_ULL(24)\n #define ICE_DBG_AQ_CMD\t\tBIT_ULL(27)\n@@ -469,6 +471,30 @@ struct ice_hw {\n \n \tu8 ucast_shared;\t/* true if VSIs can share unicast addr */\n \n+\t/* Active package version (currently active) */\n+\tstruct ice_pkg_ver active_pkg_ver;\n+\tu8 active_pkg_name[ICE_PKG_NAME_SIZE];\n+\tu8 active_pkg_in_nvm;\n+\n+\tenum ice_aq_err pkg_dwnld_status;\n+\n+\t/* Driver's package ver - (from the Metadata seg) */\n+\tstruct ice_pkg_ver pkg_ver;\n+\tu8 pkg_name[ICE_PKG_NAME_SIZE];\n+\n+\t/* Driver's Ice package version (from the Ice seg) */\n+\tstruct ice_pkg_ver ice_pkg_ver;\n+\tu8 ice_pkg_name[ICE_PKG_NAME_SIZE];\n+\n+\t/* Pointer to the ice segment */\n+\tstruct ice_seg *seg;\n+\n+\t/* Pointer to allocated copy of pkg memory */\n+\tu8 *pkg_copy;\n+\tu32 pkg_size;\n+\n+\t/* HW block tables */\n+\tstruct ice_blk_info blk[ICE_BLK_COUNT];\n };\n \n /* Statistics collected by each port, VSI, VEB, and S-channel */\n",
    "prefixes": [
        "S29",
        "3/6"
    ]
}