get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 1037792,
    "url": "http://patchwork.ozlabs.org/api/patches/1037792/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/intel-wired-lan/patch/20190206230826.24970-2-alice.michael@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": "<20190206230826.24970-2-alice.michael@intel.com>",
    "list_archive_url": null,
    "date": "2019-02-06T23:08:16",
    "name": "[next,S2-V2,02/12] i40e: Implement DDP support in i40e driver",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "b2a9d768756897742077cb8bb4bfb523abc28efb",
    "submitter": {
        "id": 71123,
        "url": "http://patchwork.ozlabs.org/api/people/71123/?format=api",
        "name": "Michael, Alice",
        "email": "alice.michael@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/20190206230826.24970-2-alice.michael@intel.com/mbox/",
    "series": [
        {
            "id": 90473,
            "url": "http://patchwork.ozlabs.org/api/series/90473/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/intel-wired-lan/list/?series=90473",
            "date": "2019-02-06T23:08:19",
            "name": "[next,S2-V2,01/12] i40e: Queues are reserved despite \"Invalid argument\" error.",
            "version": 1,
            "mbox": "http://patchwork.ozlabs.org/series/90473/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/1037792/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/1037792/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 43vxwj4VLkz9s4Z\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu,  7 Feb 2019 10:09:41 +1100 (AEDT)",
            "from localhost (localhost [127.0.0.1])\n\tby silver.osuosl.org (Postfix) with ESMTP id 230D131341;\n\tWed,  6 Feb 2019 23:09:40 +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 7QIK+o5DPnIl; Wed,  6 Feb 2019 23:09:34 +0000 (UTC)",
            "from ash.osuosl.org (ash.osuosl.org [140.211.166.34])\n\tby silver.osuosl.org (Postfix) with ESMTP id 79D60312B7;\n\tWed,  6 Feb 2019 23:09:33 +0000 (UTC)",
            "from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138])\n\tby ash.osuosl.org (Postfix) with ESMTP id D09481BF967\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tWed,  6 Feb 2019 23:09:20 +0000 (UTC)",
            "from localhost (localhost [127.0.0.1])\n\tby whitealder.osuosl.org (Postfix) with ESMTP id 1ADFB86506\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tWed,  6 Feb 2019 23:09:20 +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 PRTD80QaR1Xi for <intel-wired-lan@lists.osuosl.org>;\n\tWed,  6 Feb 2019 23:09:17 +0000 (UTC)",
            "from mga12.intel.com (mga12.intel.com [192.55.52.136])\n\tby whitealder.osuosl.org (Postfix) with ESMTPS id 3D09486196\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tWed,  6 Feb 2019 23:09:17 +0000 (UTC)",
            "from fmsmga002.fm.intel.com ([10.253.24.26])\n\tby fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t06 Feb 2019 15:09:17 -0800",
            "from alicemic-2.jf.intel.com ([10.166.16.121])\n\tby fmsmga002.fm.intel.com with ESMTP; 06 Feb 2019 15:09:16 -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.58,342,1544515200\"; d=\"scan'208\";a=\"141300905\"",
        "From": "Alice Michael <alice.michael@intel.com>",
        "To": "alice.michael@intel.com,\n\tintel-wired-lan@lists.osuosl.org",
        "Date": "Wed,  6 Feb 2019 15:08:16 -0800",
        "Message-Id": "<20190206230826.24970-2-alice.michael@intel.com>",
        "X-Mailer": "git-send-email 2.19.2",
        "In-Reply-To": "<20190206230826.24970-1-alice.michael@intel.com>",
        "References": "<20190206230826.24970-1-alice.michael@intel.com>",
        "MIME-Version": "1.0",
        "Subject": "[Intel-wired-lan] [next PATCH S2-V2 02/12] i40e: Implement DDP\n\tsupport in i40e driver",
        "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>",
        "Cc": "Aleksandr Loktionov <aleksandr.loktionov@intel.com>",
        "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: Aleksandr Loktionov <aleksandr.loktionov@intel.com>\n\nThis patch introduces DDP (Dynamic Device Personalization) which allows\nloading profiles that change the way internal parser interprets processed\nframes. To load DDP profiles it utilizes ethtool flash feature. The files\nwith recipes must be located in /var/lib/firmware directory. Afterwards\nthe recipe can be loaded by invoking:\n\n    ethtool -f <if_name> <file_name> 100\n    ethtool -f <if_name> - 100\n\nSee further usage details of this feature in the i40e documentation, or\nvisit\nhttps://software.intel.com/en-us/articles/dynamic-device-personalization-for-intel-ethernet-700-series\n\nThe driver shall verify DDP profile can be loaded in accordance with\nthe rules:\n* Package with Group ID 0 are exclusive and can only be loaded the first.\n* Packages with Group ID 0x01-0xFE can only be loaded simultaneously\n   with the packages from the same group.\n* Packages with Group ID 0xFF are compatible with all other packages.\n\nSigned-off-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>\n---\n drivers/net/ethernet/intel/i40e/Makefile      |   1 +\n drivers/net/ethernet/intel/i40e/i40e.h        |  25 +\n drivers/net/ethernet/intel/i40e/i40e_common.c | 253 ++++++++-\n drivers/net/ethernet/intel/i40e/i40e_ddp.c    | 481 ++++++++++++++++++\n .../net/ethernet/intel/i40e/i40e_ethtool.c    |   1 +\n drivers/net/ethernet/intel/i40e/i40e_main.c   |   1 +\n .../net/ethernet/intel/i40e/i40e_prototype.h  |   6 +\n drivers/net/ethernet/intel/i40e/i40e_type.h   |  23 +\n 8 files changed, 769 insertions(+), 22 deletions(-)\n create mode 100644 drivers/net/ethernet/intel/i40e/i40e_ddp.c",
    "diff": "diff --git a/drivers/net/ethernet/intel/i40e/Makefile b/drivers/net/ethernet/intel/i40e/Makefile\nindex 50590e8d1fd1..2f21b3e89fd0 100644\n--- a/drivers/net/ethernet/intel/i40e/Makefile\n+++ b/drivers/net/ethernet/intel/i40e/Makefile\n@@ -21,6 +21,7 @@ i40e-objs := i40e_main.o \\\n \ti40e_diag.o\t\\\n \ti40e_txrx.o\t\\\n \ti40e_ptp.o\t\\\n+\ti40e_ddp.o \\\n \ti40e_client.o   \\\n \ti40e_virtchnl_pf.o \\\n \ti40e_xsk.o\ndiff --git a/drivers/net/ethernet/intel/i40e/i40e.h b/drivers/net/ethernet/intel/i40e/i40e.h\nindex 8bab6fd90460..3bf9c50c3394 100644\n--- a/drivers/net/ethernet/intel/i40e/i40e.h\n+++ b/drivers/net/ethernet/intel/i40e/i40e.h\n@@ -322,6 +322,29 @@ struct i40e_udp_port_config {\n \tu8 filter_index;\n };\n \n+#define I40_DDP_FLASH_REGION 100\n+#define I40E_PROFILE_INFO_SIZE 48\n+#define I40E_MAX_PROFILE_NUM 16\n+#define I40E_PROFILE_LIST_SIZE \\\n+\t(I40E_PROFILE_INFO_SIZE * I40E_MAX_PROFILE_NUM + 4)\n+#define I40E_DDP_PROFILE_PATH \"intel/i40e/ddp/\"\n+#define I40E_DDP_PROFILE_NAME_MAX 64\n+\n+int i40e_ddp_load(struct net_device *netdev, const u8 *data, size_t size,\n+\t\t  bool is_add);\n+int i40e_ddp_flash(struct net_device *netdev, struct ethtool_flash *flash);\n+\n+struct i40e_ddp_profile_list {\n+\tu32 p_count;\n+\tstruct i40e_profile_info p_info[0];\n+};\n+\n+struct i40e_ddp_old_profile_list {\n+\tstruct list_head list;\n+\tsize_t old_ddp_size;\n+\tu8 old_ddp_buf[0];\n+};\n+\n /* macros related to FLX_PIT */\n #define I40E_FLEX_SET_FSIZE(fsize) (((fsize) << \\\n \t\t\t\t    I40E_PRTQF_FLX_PIT_FSIZE_SHIFT) & \\\n@@ -630,6 +653,8 @@ struct i40e_pf {\n \tu16 override_q_count;\n \tu16 last_sw_conf_flags;\n \tu16 last_sw_conf_valid_flags;\n+\t/* List to keep previous DDP profiles to be rolled back in the future */\n+\tstruct list_head ddp_old_prof;\n };\n \n /**\ndiff --git a/drivers/net/ethernet/intel/i40e/i40e_common.c b/drivers/net/ethernet/intel/i40e/i40e_common.c\nindex 97a9b1fb4763..486a406789b8 100644\n--- a/drivers/net/ethernet/intel/i40e/i40e_common.c\n+++ b/drivers/net/ethernet/intel/i40e/i40e_common.c\n@@ -5448,6 +5448,163 @@ i40e_find_segment_in_package(u32 segment_type,\n \treturn NULL;\n }\n \n+/* Get section table in profile */\n+#define I40E_SECTION_TABLE(profile, sec_tbl)\t\t\t\t\\\n+\tdo {\t\t\t\t\t\t\t\t\\\n+\t\tstruct i40e_profile_segment *p = (profile);\t\t\\\n+\t\tu32 count;\t\t\t\t\t\t\\\n+\t\tu32 *nvm;\t\t\t\t\t\t\\\n+\t\tcount = p->device_table_count;\t\t\t\t\\\n+\t\tnvm = (u32 *)&p->device_table[count];\t\t\t\\\n+\t\tsec_tbl = (struct i40e_section_table *)&nvm[nvm[0] + 1]; \\\n+\t} while (0)\n+\n+/* Get section header in profile */\n+#define I40E_SECTION_HEADER(profile, offset)\t\t\t\t\\\n+\t(struct i40e_profile_section_header *)((u8 *)(profile) + (offset))\n+\n+/**\n+ * i40e_find_section_in_profile\n+ * @section_type: the section type to search for (i.e., SECTION_TYPE_NOTE)\n+ * @profile: pointer to the i40e segment header to be searched\n+ *\n+ * This function searches i40e segment for a particular section type. On\n+ * success it returns a pointer to the section header, otherwise it will\n+ * return NULL.\n+ **/\n+struct i40e_profile_section_header *\n+i40e_find_section_in_profile(u32 section_type,\n+\t\t\t     struct i40e_profile_segment *profile)\n+{\n+\tstruct i40e_profile_section_header *sec;\n+\tstruct i40e_section_table *sec_tbl;\n+\tu32 sec_off;\n+\tu32 i;\n+\n+\tif (profile->header.type != SEGMENT_TYPE_I40E)\n+\t\treturn NULL;\n+\n+\tI40E_SECTION_TABLE(profile, sec_tbl);\n+\n+\tfor (i = 0; i < sec_tbl->section_count; i++) {\n+\t\tsec_off = sec_tbl->section_offset[i];\n+\t\tsec = I40E_SECTION_HEADER(profile, sec_off);\n+\t\tif (sec->section.type == section_type)\n+\t\t\treturn sec;\n+\t}\n+\n+\treturn NULL;\n+}\n+\n+/**\n+ * i40e_ddp_exec_aq_section - Execute generic AQ for DDP\n+ * @hw: pointer to the hw struct\n+ * @aq: command buffer containing all data to execute AQ\n+ **/\n+static enum\n+i40e_status_code i40e_ddp_exec_aq_section(struct i40e_hw *hw,\n+\t\t\t\t\t  struct i40e_profile_aq_section *aq)\n+{\n+\ti40e_status status;\n+\tstruct i40e_aq_desc desc;\n+\tu8 *msg = NULL;\n+\tu16 msglen;\n+\n+\ti40e_fill_default_direct_cmd_desc(&desc, aq->opcode);\n+\tdesc.flags |= cpu_to_le16(aq->flags);\n+\tmemcpy(desc.params.raw, aq->param, sizeof(desc.params.raw));\n+\n+\tmsglen = aq->datalen;\n+\tif (msglen) {\n+\t\tdesc.flags |= cpu_to_le16((u16)(I40E_AQ_FLAG_BUF |\n+\t\t\t\t\t\tI40E_AQ_FLAG_RD));\n+\t\tif (msglen > I40E_AQ_LARGE_BUF)\n+\t\t\tdesc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_LB);\n+\t\tdesc.datalen = cpu_to_le16(msglen);\n+\t\tmsg = &aq->data[0];\n+\t}\n+\n+\tstatus = i40e_asq_send_command(hw, &desc, msg, msglen, NULL);\n+\n+\tif (status) {\n+\t\ti40e_debug(hw, I40E_DEBUG_PACKAGE,\n+\t\t\t   \"unable to exec DDP AQ opcode %u, error %d\\n\",\n+\t\t\t   aq->opcode, status);\n+\t\treturn status;\n+\t}\n+\n+\t/* copy returned desc to aq_buf */\n+\tmemcpy(aq->param, desc.params.raw, sizeof(desc.params.raw));\n+\n+\treturn 0;\n+}\n+\n+/**\n+ * i40e_validate_profile\n+ * @hw: pointer to the hardware structure\n+ * @profile: pointer to the profile segment of the package to be validated\n+ * @track_id: package tracking id\n+ * @rollback: flag if the profile is for rollback.\n+ *\n+ * Validates supported devices and profile's sections.\n+ */\n+static enum i40e_status_code\n+i40e_validate_profile(struct i40e_hw *hw, struct i40e_profile_segment *profile,\n+\t\t      u32 track_id, bool rollback)\n+{\n+\tstruct i40e_profile_section_header *sec = NULL;\n+\ti40e_status status = 0;\n+\tstruct i40e_section_table *sec_tbl;\n+\tu32 vendor_dev_id;\n+\tu32 dev_cnt;\n+\tu32 sec_off;\n+\tu32 i;\n+\n+\tif (track_id == I40E_DDP_TRACKID_INVALID) {\n+\t\ti40e_debug(hw, I40E_DEBUG_PACKAGE, \"Invalid track_id\\n\");\n+\t\treturn I40E_NOT_SUPPORTED;\n+\t}\n+\n+\tdev_cnt = profile->device_table_count;\n+\tfor (i = 0; i < dev_cnt; i++) {\n+\t\tvendor_dev_id = profile->device_table[i].vendor_dev_id;\n+\t\tif ((vendor_dev_id >> 16) == PCI_VENDOR_ID_INTEL &&\n+\t\t    hw->device_id == (vendor_dev_id & 0xFFFF))\n+\t\t\tbreak;\n+\t}\n+\tif (dev_cnt && i == dev_cnt) {\n+\t\ti40e_debug(hw, I40E_DEBUG_PACKAGE,\n+\t\t\t   \"Device doesn't support DDP\\n\");\n+\t\treturn I40E_ERR_DEVICE_NOT_SUPPORTED;\n+\t}\n+\n+\tI40E_SECTION_TABLE(profile, sec_tbl);\n+\n+\t/* Validate sections types */\n+\tfor (i = 0; i < sec_tbl->section_count; i++) {\n+\t\tsec_off = sec_tbl->section_offset[i];\n+\t\tsec = I40E_SECTION_HEADER(profile, sec_off);\n+\t\tif (rollback) {\n+\t\t\tif (sec->section.type == SECTION_TYPE_MMIO ||\n+\t\t\t    sec->section.type == SECTION_TYPE_AQ ||\n+\t\t\t    sec->section.type == SECTION_TYPE_RB_AQ) {\n+\t\t\t\ti40e_debug(hw, I40E_DEBUG_PACKAGE,\n+\t\t\t\t\t   \"Not a roll-back package\\n\");\n+\t\t\t\treturn I40E_NOT_SUPPORTED;\n+\t\t\t}\n+\t\t} else {\n+\t\t\tif (sec->section.type == SECTION_TYPE_RB_AQ ||\n+\t\t\t    sec->section.type == SECTION_TYPE_RB_MMIO) {\n+\t\t\t\ti40e_debug(hw, I40E_DEBUG_PACKAGE,\n+\t\t\t\t\t   \"Not an original package\\n\");\n+\t\t\t\treturn I40E_NOT_SUPPORTED;\n+\t\t\t}\n+\t\t}\n+\t}\n+\n+\treturn status;\n+}\n+\n /**\n  * i40e_write_profile\n  * @hw: pointer to the hardware structure\n@@ -5463,47 +5620,99 @@ i40e_write_profile(struct i40e_hw *hw, struct i40e_profile_segment *profile,\n \ti40e_status status = 0;\n \tstruct i40e_section_table *sec_tbl;\n \tstruct i40e_profile_section_header *sec = NULL;\n-\tu32 dev_cnt;\n-\tu32 vendor_dev_id;\n-\tu32 *nvm;\n+\tstruct i40e_profile_aq_section *ddp_aq;\n \tu32 section_size = 0;\n \tu32 offset = 0, info = 0;\n+\tu32 sec_off;\n \tu32 i;\n \n-\tdev_cnt = profile->device_table_count;\n+\tstatus = i40e_validate_profile(hw, profile, track_id, false);\n+\tif (status)\n+\t\treturn status;\n \n-\tfor (i = 0; i < dev_cnt; i++) {\n-\t\tvendor_dev_id = profile->device_table[i].vendor_dev_id;\n-\t\tif ((vendor_dev_id >> 16) == PCI_VENDOR_ID_INTEL)\n-\t\t\tif (hw->device_id == (vendor_dev_id & 0xFFFF))\n+\tI40E_SECTION_TABLE(profile, sec_tbl);\n+\n+\tfor (i = 0; i < sec_tbl->section_count; i++) {\n+\t\tsec_off = sec_tbl->section_offset[i];\n+\t\tsec = I40E_SECTION_HEADER(profile, sec_off);\n+\t\t/* Process generic admin command */\n+\t\tif (sec->section.type == SECTION_TYPE_AQ) {\n+\t\t\tddp_aq = (struct i40e_profile_aq_section *)&sec[1];\n+\t\t\tstatus = i40e_ddp_exec_aq_section(hw, ddp_aq);\n+\t\t\tif (status) {\n+\t\t\t\ti40e_debug(hw, I40E_DEBUG_PACKAGE,\n+\t\t\t\t\t   \"Failed to execute aq: section %d, opcode %u\\n\",\n+\t\t\t\t\t   i, ddp_aq->opcode);\n \t\t\t\tbreak;\n+\t\t\t}\n+\t\t\tsec->section.type = SECTION_TYPE_RB_AQ;\n+\t\t}\n+\n+\t\t/* Skip any non-mmio sections */\n+\t\tif (sec->section.type != SECTION_TYPE_MMIO)\n+\t\t\tcontinue;\n+\n+\t\tsection_size = sec->section.size +\n+\t\t\tsizeof(struct i40e_profile_section_header);\n+\n+\t\t/* Write MMIO section */\n+\t\tstatus = i40e_aq_write_ddp(hw, (void *)sec, (u16)section_size,\n+\t\t\t\t\t   track_id, &offset, &info, NULL);\n+\t\tif (status) {\n+\t\t\ti40e_debug(hw, I40E_DEBUG_PACKAGE,\n+\t\t\t\t   \"Failed to write profile: section %d, offset %d, info %d\\n\",\n+\t\t\t\t   i, offset, info);\n+\t\t\tbreak;\n+\t\t}\n \t}\n-\tif (i == dev_cnt) {\n-\t\ti40e_debug(hw, I40E_DEBUG_PACKAGE, \"Device doesn't support DDP\");\n-\t\treturn I40E_ERR_DEVICE_NOT_SUPPORTED;\n-\t}\n+\treturn status;\n+}\n+\n+/**\n+ * i40e_rollback_profile\n+ * @hw: pointer to the hardware structure\n+ * @profile: pointer to the profile segment of the package to be removed\n+ * @track_id: package tracking id\n+ *\n+ * Rolls back previously loaded package.\n+ */\n+enum i40e_status_code\n+i40e_rollback_profile(struct i40e_hw *hw, struct i40e_profile_segment *profile,\n+\t\t      u32 track_id)\n+{\n+\tstruct i40e_profile_section_header *sec = NULL;\n+\ti40e_status status = 0;\n+\tstruct i40e_section_table *sec_tbl;\n+\tu32 offset = 0, info = 0;\n+\tu32 section_size = 0;\n+\tu32 sec_off;\n+\tint i;\n \n-\tnvm = (u32 *)&profile->device_table[dev_cnt];\n-\tsec_tbl = (struct i40e_section_table *)&nvm[nvm[0] + 1];\n+\tstatus = i40e_validate_profile(hw, profile, track_id, true);\n+\tif (status)\n+\t\treturn status;\n \n-\tfor (i = 0; i < sec_tbl->section_count; i++) {\n-\t\tsec = (struct i40e_profile_section_header *)((u8 *)profile +\n-\t\t\t\t\t     sec_tbl->section_offset[i]);\n+\tI40E_SECTION_TABLE(profile, sec_tbl);\n \n-\t\t/* Skip 'AQ', 'note' and 'name' sections */\n-\t\tif (sec->section.type != SECTION_TYPE_MMIO)\n+\t/* For rollback write sections in reverse */\n+\tfor (i = sec_tbl->section_count - 1; i >= 0; i--) {\n+\t\tsec_off = sec_tbl->section_offset[i];\n+\t\tsec = I40E_SECTION_HEADER(profile, sec_off);\n+\n+\t\t/* Skip any non-rollback sections */\n+\t\tif (sec->section.type != SECTION_TYPE_RB_MMIO)\n \t\t\tcontinue;\n \n \t\tsection_size = sec->section.size +\n \t\t\tsizeof(struct i40e_profile_section_header);\n \n-\t\t/* Write profile */\n+\t\t/* Write roll-back MMIO section */\n \t\tstatus = i40e_aq_write_ddp(hw, (void *)sec, (u16)section_size,\n \t\t\t\t\t   track_id, &offset, &info, NULL);\n \t\tif (status) {\n \t\t\ti40e_debug(hw, I40E_DEBUG_PACKAGE,\n-\t\t\t\t   \"Failed to write profile: offset %d, info %d\",\n-\t\t\t\t   offset, info);\n+\t\t\t\t   \"Failed to write profile: section %d, offset %d, info %d\\n\",\n+\t\t\t\t   i, offset, info);\n \t\t\tbreak;\n \t\t}\n \t}\ndiff --git a/drivers/net/ethernet/intel/i40e/i40e_ddp.c b/drivers/net/ethernet/intel/i40e/i40e_ddp.c\nnew file mode 100644\nindex 000000000000..5e08f100c413\n--- /dev/null\n+++ b/drivers/net/ethernet/intel/i40e/i40e_ddp.c\n@@ -0,0 +1,481 @@\n+// SPDX-License-Identifier: GPL-2.0\n+/* Copyright(c) 2013 - 2018 Intel Corporation. */\n+\n+#include \"i40e.h\"\n+\n+#include <linux/firmware.h>\n+\n+/**\n+ * i40e_ddp_profiles_eq - checks if DDP profiles are the equivalent\n+ * @a: new profile info\n+ * @b: old profile info\n+ *\n+ * checks if DDP profiles are the equivalent.\n+ * Returns true if profiles are the same.\n+ **/\n+static bool i40e_ddp_profiles_eq(struct i40e_profile_info *a,\n+\t\t\t\t struct i40e_profile_info *b)\n+{\n+\treturn a->track_id == b->track_id &&\n+\t\t!memcmp(&a->version, &b->version, sizeof(a->version)) &&\n+\t\t!memcmp(&a->name, &b->name, I40E_DDP_NAME_SIZE);\n+}\n+\n+/**\n+ * i40e_ddp_does_profile_exist - checks if DDP profile loaded already\n+ * @hw: HW data structure\n+ * @pinfo: DDP profile information structure\n+ *\n+ * checks if DDP profile loaded already.\n+ * Returns >0 if the profile exists.\n+ * Returns  0 if the profile is absent.\n+ * Returns <0 if error.\n+ **/\n+static int i40e_ddp_does_profile_exist(struct i40e_hw *hw,\n+\t\t\t\t       struct i40e_profile_info *pinfo)\n+{\n+\tstruct i40e_ddp_profile_list *profile_list;\n+\tu8 buff[I40E_PROFILE_LIST_SIZE];\n+\ti40e_status status;\n+\tint i;\n+\n+\tstatus = i40e_aq_get_ddp_list(hw, buff, I40E_PROFILE_LIST_SIZE, 0,\n+\t\t\t\t      NULL);\n+\tif (status)\n+\t\treturn -1;\n+\n+\tprofile_list = (struct i40e_ddp_profile_list *)buff;\n+\tfor (i = 0; i < profile_list->p_count; i++) {\n+\t\tif (i40e_ddp_profiles_eq(pinfo, &profile_list->p_info[i]))\n+\t\t\treturn 1;\n+\t}\n+\treturn 0;\n+}\n+\n+/**\n+ * i40e_ddp_profiles_overlap - checks if DDP profiles overlap.\n+ * @new: new profile info\n+ * @old: old profile info\n+ *\n+ * checks if DDP profiles overlap.\n+ * Returns true if profiles are overlap.\n+ **/\n+static bool i40e_ddp_profiles_overlap(struct i40e_profile_info *new,\n+\t\t\t\t      struct i40e_profile_info *old)\n+{\n+\tunsigned int group_id_old = (u8)((old->track_id & 0x00FF0000) >> 16);\n+\tunsigned int group_id_new = (u8)((new->track_id & 0x00FF0000) >> 16);\n+\n+\t/* 0x00 group must be only the first */\n+\tif (group_id_new == 0)\n+\t\treturn true;\n+\t/* 0xFF group is compatible with anything else */\n+\tif (group_id_new == 0xFF || group_id_old == 0xFF)\n+\t\treturn false;\n+\t/* otherwise only profiles from the same group are compatible*/\n+\treturn group_id_old != group_id_new;\n+}\n+\n+/**\n+ * i40e_ddp_does_profiles_ - checks if DDP overlaps with existing one.\n+ * @hw: HW data structure\n+ * @pinfo: DDP profile information structure\n+ *\n+ * checks if DDP profile overlaps with existing one.\n+ * Returns >0 if the profile overlaps.\n+ * Returns  0 if the profile is ok.\n+ * Returns <0 if error.\n+ **/\n+static int i40e_ddp_does_profile_overlap(struct i40e_hw *hw,\n+\t\t\t\t\t struct i40e_profile_info *pinfo)\n+{\n+\tstruct i40e_ddp_profile_list *profile_list;\n+\tu8 buff[I40E_PROFILE_LIST_SIZE];\n+\ti40e_status status;\n+\tint i;\n+\n+\tstatus = i40e_aq_get_ddp_list(hw, buff, I40E_PROFILE_LIST_SIZE, 0,\n+\t\t\t\t      NULL);\n+\tif (status)\n+\t\treturn -EIO;\n+\n+\tprofile_list = (struct i40e_ddp_profile_list *)buff;\n+\tfor (i = 0; i < profile_list->p_count; i++) {\n+\t\tif (i40e_ddp_profiles_overlap(pinfo,\n+\t\t\t\t\t      &profile_list->p_info[i]))\n+\t\t\treturn 1;\n+\t}\n+\treturn 0;\n+}\n+\n+/**\n+ * i40e_add_pinfo\n+ * @hw: pointer to the hardware structure\n+ * @profile: pointer to the profile segment of the package\n+ * @profile_info_sec: buffer for information section\n+ * @track_id: package tracking id\n+ *\n+ * Register a profile to the list of loaded profiles.\n+ */\n+static enum i40e_status_code\n+i40e_add_pinfo(struct i40e_hw *hw, struct i40e_profile_segment *profile,\n+\t       u8 *profile_info_sec, u32 track_id)\n+{\n+\tstruct i40e_profile_section_header *sec;\n+\tstruct i40e_profile_info *pinfo;\n+\ti40e_status status;\n+\tu32 offset = 0, info = 0;\n+\n+\tsec = (struct i40e_profile_section_header *)profile_info_sec;\n+\tsec->tbl_size = 1;\n+\tsec->data_end = sizeof(struct i40e_profile_section_header) +\n+\t\t\tsizeof(struct i40e_profile_info);\n+\tsec->section.type = SECTION_TYPE_INFO;\n+\tsec->section.offset = sizeof(struct i40e_profile_section_header);\n+\tsec->section.size = sizeof(struct i40e_profile_info);\n+\tpinfo = (struct i40e_profile_info *)(profile_info_sec +\n+\t\t\t\t\t     sec->section.offset);\n+\tpinfo->track_id = track_id;\n+\tpinfo->version = profile->version;\n+\tpinfo->op = I40E_DDP_ADD_TRACKID;\n+\n+\t/* Clear reserved field */\n+\tmemset(pinfo->reserved, 0, sizeof(pinfo->reserved));\n+\tmemcpy(pinfo->name, profile->name, I40E_DDP_NAME_SIZE);\n+\n+\tstatus = i40e_aq_write_ddp(hw, (void *)sec, sec->data_end,\n+\t\t\t\t   track_id, &offset, &info, NULL);\n+\treturn status;\n+}\n+\n+/**\n+ * i40e_del_pinfo - delete DDP profile info from NIC\n+ * @hw: HW data structure\n+ * @profile: DDP profile segment to be deleted\n+ * @profile_info_sec: DDP profile section header\n+ * @track_id: track ID of the profile for deletion\n+ *\n+ * Removes DDP profile from the NIC.\n+ **/\n+static enum i40e_status_code\n+i40e_del_pinfo(struct i40e_hw *hw, struct i40e_profile_segment *profile,\n+\t       u8 *profile_info_sec, u32 track_id)\n+{\n+\tstruct i40e_profile_section_header *sec;\n+\tstruct i40e_profile_info *pinfo;\n+\ti40e_status status;\n+\tu32 offset = 0, info = 0;\n+\n+\tsec = (struct i40e_profile_section_header *)profile_info_sec;\n+\tsec->tbl_size = 1;\n+\tsec->data_end = sizeof(struct i40e_profile_section_header) +\n+\t\t\tsizeof(struct i40e_profile_info);\n+\tsec->section.type = SECTION_TYPE_INFO;\n+\tsec->section.offset = sizeof(struct i40e_profile_section_header);\n+\tsec->section.size = sizeof(struct i40e_profile_info);\n+\tpinfo = (struct i40e_profile_info *)(profile_info_sec +\n+\t\t\t\t\t     sec->section.offset);\n+\tpinfo->track_id = track_id;\n+\tpinfo->version = profile->version;\n+\tpinfo->op = I40E_DDP_REMOVE_TRACKID;\n+\n+\t/* Clear reserved field */\n+\tmemset(pinfo->reserved, 0, sizeof(pinfo->reserved));\n+\tmemcpy(pinfo->name, profile->name, I40E_DDP_NAME_SIZE);\n+\n+\tstatus = i40e_aq_write_ddp(hw, (void *)sec, sec->data_end,\n+\t\t\t\t   track_id, &offset, &info, NULL);\n+\treturn status;\n+}\n+\n+/**\n+ * i40e_ddp_is_pkg_hdr_valid - performs basic pkg header integrity checks\n+ * @netdev: net device structure (for logging purposes)\n+ * @pkg_hdr: pointer to package header\n+ * @size_huge: size of the whole DDP profile package in size_t\n+ *\n+ * Checks correctness of pkg header: Version, size too big/small, and\n+ * all segment offsets alignment and boundaries. This function lets\n+ * reject non DDP profile file to be loaded by administrator mistake.\n+ **/\n+static bool i40e_ddp_is_pkg_hdr_valid(struct net_device *netdev,\n+\t\t\t\t      struct i40e_package_header *pkg_hdr,\n+\t\t\t\t      size_t size_huge)\n+{\n+\tu32 size = 0xFFFFFFFFU & size_huge;\n+\tu32 pkg_hdr_size;\n+\tu32 segment;\n+\n+\tif (!pkg_hdr)\n+\t\treturn false;\n+\n+\tif (pkg_hdr->version.major > 0) {\n+\t\tstruct i40e_ddp_version ver = pkg_hdr->version;\n+\n+\t\tnetdev_err(netdev, \"Unsupported DDP profile version %u.%u.%u.%u\",\n+\t\t\t   ver.major, ver.minor, ver.update, ver.draft);\n+\t\treturn false;\n+\t}\n+\tif (size_huge > size) {\n+\t\tnetdev_err(netdev, \"Invalid DDP profile - size is bigger than 4G\");\n+\t\treturn false;\n+\t}\n+\tif (size < (sizeof(struct i40e_package_header) +\n+\t\tsizeof(struct i40e_metadata_segment) + sizeof(u32) * 2)) {\n+\t\tnetdev_err(netdev, \"Invalid DDP profile - size is too small.\");\n+\t\treturn false;\n+\t}\n+\n+\tpkg_hdr_size = sizeof(u32) * (pkg_hdr->segment_count + 2U);\n+\tif (size < pkg_hdr_size) {\n+\t\tnetdev_err(netdev, \"Invalid DDP profile - too many segments\");\n+\t\treturn false;\n+\t}\n+\tfor (segment = 0; segment < pkg_hdr->segment_count; ++segment) {\n+\t\tu32 offset = pkg_hdr->segment_offset[segment];\n+\n+\t\tif (0xFU & offset) {\n+\t\t\tnetdev_err(netdev,\n+\t\t\t\t   \"Invalid DDP profile %u segment alignment\",\n+\t\t\t\t   segment);\n+\t\t\treturn false;\n+\t\t}\n+\t\tif (pkg_hdr_size > offset || offset >= size) {\n+\t\t\tnetdev_err(netdev,\n+\t\t\t\t   \"Invalid DDP profile %u segment offset\",\n+\t\t\t\t   segment);\n+\t\t\treturn false;\n+\t\t}\n+\t}\n+\n+\treturn true;\n+}\n+\n+/**\n+ * i40e_ddp_load - performs DDP loading\n+ * @netdev: net device structure\n+ * @data: buffer containing recipe file\n+ * @size: size of the buffer\n+ * @is_add: true when loading profile, false when rolling back the previous one\n+ *\n+ * Checks correctness and loads DDP profile to the NIC. The function is\n+ * also used for rolling back previously loaded profile.\n+ **/\n+int i40e_ddp_load(struct net_device *netdev, const u8 *data, size_t size,\n+\t\t  bool is_add)\n+{\n+\tu8 profile_info_sec[sizeof(struct i40e_profile_section_header) +\n+\t\t\t    sizeof(struct i40e_profile_info)];\n+\tstruct i40e_metadata_segment *metadata_hdr;\n+\tstruct i40e_profile_segment *profile_hdr;\n+\tstruct i40e_profile_info pinfo;\n+\tstruct i40e_package_header *pkg_hdr;\n+\ti40e_status status;\n+\tstruct i40e_netdev_priv *np = netdev_priv(netdev);\n+\tstruct i40e_vsi *vsi = np->vsi;\n+\tstruct i40e_pf *pf = vsi->back;\n+\tu32 track_id;\n+\tint istatus;\n+\n+\tpkg_hdr = (struct i40e_package_header *)data;\n+\tif (!i40e_ddp_is_pkg_hdr_valid(netdev, pkg_hdr, size))\n+\t\treturn -EINVAL;\n+\n+\tif (size < (sizeof(struct i40e_package_header) +\n+\t\t    sizeof(struct i40e_metadata_segment) + sizeof(u32) * 2)) {\n+\t\tnetdev_err(netdev, \"Invalid DDP recipe size.\");\n+\t\treturn -EINVAL;\n+\t}\n+\n+\t/* Find beginning of segment data in buffer */\n+\tmetadata_hdr = (struct i40e_metadata_segment *)\n+\t\ti40e_find_segment_in_package(SEGMENT_TYPE_METADATA, pkg_hdr);\n+\tif (!metadata_hdr) {\n+\t\tnetdev_err(netdev, \"Failed to find metadata segment in DDP recipe.\");\n+\t\treturn -EINVAL;\n+\t}\n+\n+\ttrack_id = metadata_hdr->track_id;\n+\tprofile_hdr = (struct i40e_profile_segment *)\n+\t\ti40e_find_segment_in_package(SEGMENT_TYPE_I40E, pkg_hdr);\n+\tif (!profile_hdr) {\n+\t\tnetdev_err(netdev, \"Failed to find profile segment in DDP recipe.\");\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tpinfo.track_id = track_id;\n+\tpinfo.version = profile_hdr->version;\n+\tif (is_add)\n+\t\tpinfo.op = I40E_DDP_ADD_TRACKID;\n+\telse\n+\t\tpinfo.op = I40E_DDP_REMOVE_TRACKID;\n+\n+\tmemcpy(pinfo.name, profile_hdr->name, I40E_DDP_NAME_SIZE);\n+\n+\t/* Check if profile data already exists*/\n+\tistatus = i40e_ddp_does_profile_exist(&pf->hw, &pinfo);\n+\tif (istatus < 0) {\n+\t\tnetdev_err(netdev, \"Failed to fetch loaded profiles.\");\n+\t\treturn istatus;\n+\t}\n+\tif (is_add) {\n+\t\tif (istatus > 0) {\n+\t\t\tnetdev_err(netdev, \"DDP profile already loaded.\");\n+\t\t\treturn -EINVAL;\n+\t\t}\n+\t\tistatus = i40e_ddp_does_profile_overlap(&pf->hw, &pinfo);\n+\t\tif (istatus < 0) {\n+\t\t\tnetdev_err(netdev, \"Failed to fetch loaded profiles.\");\n+\t\t\treturn istatus;\n+\t\t}\n+\t\tif (istatus > 0) {\n+\t\t\tnetdev_err(netdev, \"DDP profile overlaps with existing one.\");\n+\t\t\treturn -EINVAL;\n+\t\t}\n+\t} else {\n+\t\tif (istatus == 0) {\n+\t\t\tnetdev_err(netdev,\n+\t\t\t\t   \"DDP profile for deletion does not exist.\");\n+\t\t\treturn -EINVAL;\n+\t\t}\n+\t}\n+\n+\t/* Load profile data */\n+\tif (is_add) {\n+\t\tstatus = i40e_write_profile(&pf->hw, profile_hdr, track_id);\n+\t\tif (status) {\n+\t\t\tif (status == I40E_ERR_DEVICE_NOT_SUPPORTED) {\n+\t\t\t\tnetdev_err(netdev,\n+\t\t\t\t\t   \"Profile is not supported by the device.\");\n+\t\t\t\treturn -EPERM;\n+\t\t\t}\n+\t\t\tnetdev_err(netdev, \"Failed to write DDP profile.\");\n+\t\t\treturn -EIO;\n+\t\t}\n+\t} else {\n+\t\tstatus = i40e_rollback_profile(&pf->hw, profile_hdr, track_id);\n+\t\tif (status) {\n+\t\t\tnetdev_err(netdev, \"Failed to remove DDP profile.\");\n+\t\t\treturn -EIO;\n+\t\t}\n+\t}\n+\n+\t/* Add/remove profile to/from profile list in FW */\n+\tif (is_add) {\n+\t\tstatus = i40e_add_pinfo(&pf->hw, profile_hdr, profile_info_sec,\n+\t\t\t\t\ttrack_id);\n+\t\tif (status) {\n+\t\t\tnetdev_err(netdev, \"Failed to add DDP profile info.\");\n+\t\t\treturn -EIO;\n+\t\t}\n+\t} else {\n+\t\tstatus = i40e_del_pinfo(&pf->hw, profile_hdr, profile_info_sec,\n+\t\t\t\t\ttrack_id);\n+\t\tif (status) {\n+\t\t\tnetdev_err(netdev, \"Failed to restore DDP profile info.\");\n+\t\t\treturn -EIO;\n+\t\t}\n+\t}\n+\n+\treturn 0;\n+}\n+\n+/**\n+ * i40e_ddp_restore - restore previously loaded profile and remove from list\n+ * @pf: PF data struct\n+ *\n+ * Restores previously loaded profile stored on the list in driver memory.\n+ * After rolling back removes entry from the list.\n+ **/\n+static int i40e_ddp_restore(struct i40e_pf *pf)\n+{\n+\tstruct i40e_ddp_old_profile_list *entry;\n+\tstruct net_device *netdev = pf->vsi[pf->lan_vsi]->netdev;\n+\tint status = 0;\n+\n+\tif (!list_empty(&pf->ddp_old_prof)) {\n+\t\tentry = list_first_entry(&pf->ddp_old_prof,\n+\t\t\t\t\t struct i40e_ddp_old_profile_list,\n+\t\t\t\t\t list);\n+\t\tstatus = i40e_ddp_load(netdev, entry->old_ddp_buf,\n+\t\t\t\t       entry->old_ddp_size, false);\n+\t\tlist_del(&entry->list);\n+\t\tkfree(entry);\n+\t}\n+\treturn status;\n+}\n+\n+/**\n+ * i40e_ddp_flash - callback function for ethtool flash feature\n+ * @netdev: net device structure\n+ * @flash: kernel flash structure\n+ *\n+ * Ethtool callback function used for loading and unloading DDP profiles.\n+ **/\n+int i40e_ddp_flash(struct net_device *netdev, struct ethtool_flash *flash)\n+{\n+\tconst struct firmware *ddp_config;\n+\tstruct i40e_netdev_priv *np = netdev_priv(netdev);\n+\tstruct i40e_vsi *vsi = np->vsi;\n+\tstruct i40e_pf *pf = vsi->back;\n+\tint status = 0;\n+\n+\t/* Check for valid region first */\n+\tif (flash->region != I40_DDP_FLASH_REGION) {\n+\t\tnetdev_err(netdev, \"Requested firmware region is not recognized by this driver.\");\n+\t\treturn -EINVAL;\n+\t}\n+\tif (pf->hw.bus.func != 0) {\n+\t\tnetdev_err(netdev, \"Any DDP operation is allowed only on Phy0 NIC interface\");\n+\t\treturn -EINVAL;\n+\t}\n+\n+\t/* If the user supplied \"-\" instead of file name rollback previously\n+\t * stored profile.\n+\t */\n+\tif (strncmp(flash->data, \"-\", 2) != 0) {\n+\t\tstruct i40e_ddp_old_profile_list *list_entry;\n+\t\tchar profile_name[sizeof(I40E_DDP_PROFILE_PATH)\n+\t\t\t\t  + I40E_DDP_PROFILE_NAME_MAX];\n+\n+\t\tprofile_name[sizeof(profile_name) - 1] = 0;\n+\t\tstrncpy(profile_name, I40E_DDP_PROFILE_PATH,\n+\t\t\tsizeof(profile_name) - 1);\n+\t\tstrncat(profile_name, flash->data, I40E_DDP_PROFILE_NAME_MAX);\n+\t\t/* Load DDP recipe. */\n+\t\tstatus = request_firmware(&ddp_config, profile_name,\n+\t\t\t\t\t  &netdev->dev);\n+\t\tif (status) {\n+\t\t\tnetdev_err(netdev, \"DDP recipe file request failed.\");\n+\t\t\treturn status;\n+\t\t}\n+\n+\t\tstatus = i40e_ddp_load(netdev, ddp_config->data,\n+\t\t\t\t       ddp_config->size, true);\n+\n+\t\tif (!status) {\n+\t\t\tlist_entry =\n+\t\t\t  kzalloc(sizeof(struct i40e_ddp_old_profile_list) +\n+\t\t\t\t  ddp_config->size, GFP_KERNEL);\n+\t\t\tif (!list_entry) {\n+\t\t\t\tnetdev_info(netdev, \"Failed to allocate memory for previous DDP profile data.\");\n+\t\t\t\tnetdev_info(netdev, \"New profile loaded but roll-back will be impossible.\");\n+\t\t\t} else {\n+\t\t\t\tmemcpy(list_entry->old_ddp_buf,\n+\t\t\t\t       ddp_config->data, ddp_config->size);\n+\t\t\t\tlist_entry->old_ddp_size = ddp_config->size;\n+\t\t\t\tlist_add(&list_entry->list, &pf->ddp_old_prof);\n+\t\t\t}\n+\t\t}\n+\n+\t\trelease_firmware(ddp_config);\n+\t} else {\n+\t\tif (!list_empty(&pf->ddp_old_prof)) {\n+\t\t\tstatus = i40e_ddp_restore(pf);\n+\t\t} else {\n+\t\t\tnetdev_warn(netdev, \"There is no DDP profile to restore.\");\n+\t\t\tstatus = -ENOENT;\n+\t\t}\n+\t}\n+\treturn status;\n+}\ndiff --git a/drivers/net/ethernet/intel/i40e/i40e_ethtool.c b/drivers/net/ethernet/intel/i40e/i40e_ethtool.c\nindex 4c885801fa26..4e347637e36a 100644\n--- a/drivers/net/ethernet/intel/i40e/i40e_ethtool.c\n+++ b/drivers/net/ethernet/intel/i40e/i40e_ethtool.c\n@@ -5172,6 +5172,7 @@ static const struct ethtool_ops i40e_ethtool_ops = {\n \t.set_link_ksettings\t= i40e_set_link_ksettings,\n \t.get_fecparam = i40e_get_fec_param,\n \t.set_fecparam = i40e_set_fec_param,\n+\t.flash_device = i40e_ddp_flash,\n };\n \n void i40e_set_ethtool_ops(struct net_device *netdev)\ndiff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c\nindex 9b315230a0d6..d975e25107c1 100644\n--- a/drivers/net/ethernet/intel/i40e/i40e_main.c\n+++ b/drivers/net/ethernet/intel/i40e/i40e_main.c\n@@ -14429,6 +14429,7 @@ static int i40e_probe(struct pci_dev *pdev, const struct pci_device_id *ent)\n \n \tINIT_LIST_HEAD(&pf->l3_flex_pit_list);\n \tINIT_LIST_HEAD(&pf->l4_flex_pit_list);\n+\tINIT_LIST_HEAD(&pf->ddp_old_prof);\n \n \t/* set up the locks for the AQ, do this only once in probe\n \t * and destroy them only once in remove\ndiff --git a/drivers/net/ethernet/intel/i40e/i40e_prototype.h b/drivers/net/ethernet/intel/i40e/i40e_prototype.h\nindex e08d754824b1..663c8bf4d3d8 100644\n--- a/drivers/net/ethernet/intel/i40e/i40e_prototype.h\n+++ b/drivers/net/ethernet/intel/i40e/i40e_prototype.h\n@@ -429,10 +429,16 @@ i40e_status i40e_aq_get_ddp_list(struct i40e_hw *hw, void *buff,\n struct i40e_generic_seg_header *\n i40e_find_segment_in_package(u32 segment_type,\n \t\t\t     struct i40e_package_header *pkg_header);\n+struct i40e_profile_section_header *\n+i40e_find_section_in_profile(u32 section_type,\n+\t\t\t     struct i40e_profile_segment *profile);\n enum i40e_status_code\n i40e_write_profile(struct i40e_hw *hw, struct i40e_profile_segment *i40e_seg,\n \t\t   u32 track_id);\n enum i40e_status_code\n+i40e_rollback_profile(struct i40e_hw *hw, struct i40e_profile_segment *i40e_seg,\n+\t\t      u32 track_id);\n+enum i40e_status_code\n i40e_add_pinfo_to_list(struct i40e_hw *hw,\n \t\t       struct i40e_profile_segment *profile,\n \t\t       u8 *profile_info_sec, u32 track_id);\ndiff --git a/drivers/net/ethernet/intel/i40e/i40e_type.h b/drivers/net/ethernet/intel/i40e/i40e_type.h\nindex 2781ab91ca82..79420bcc7414 100644\n--- a/drivers/net/ethernet/intel/i40e/i40e_type.h\n+++ b/drivers/net/ethernet/intel/i40e/i40e_type.h\n@@ -1527,6 +1527,8 @@ struct i40e_generic_seg_header {\n struct i40e_metadata_segment {\n \tstruct i40e_generic_seg_header header;\n \tstruct i40e_ddp_version version;\n+#define I40E_DDP_TRACKID_RDONLY\t\t0\n+#define I40E_DDP_TRACKID_INVALID\t0xFFFFFFFF\n \tu32 track_id;\n \tchar name[I40E_DDP_NAME_SIZE];\n };\n@@ -1555,15 +1557,36 @@ struct i40e_profile_section_header {\n \tstruct {\n #define SECTION_TYPE_INFO\t0x00000010\n #define SECTION_TYPE_MMIO\t0x00000800\n+#define SECTION_TYPE_RB_MMIO\t0x00001800\n #define SECTION_TYPE_AQ\t\t0x00000801\n+#define SECTION_TYPE_RB_AQ\t0x00001801\n #define SECTION_TYPE_NOTE\t0x80000000\n #define SECTION_TYPE_NAME\t0x80000001\n+#define SECTION_TYPE_PROTO\t0x80000002\n+#define SECTION_TYPE_PCTYPE\t0x80000003\n+#define SECTION_TYPE_PTYPE\t0x80000004\n \t\tu32 type;\n \t\tu32 offset;\n \t\tu32 size;\n \t} section;\n };\n \n+struct i40e_profile_tlv_section_record {\n+\tu8 rtype;\n+\tu8 type;\n+\tu16 len;\n+\tu8 data[12];\n+};\n+\n+/* Generic AQ section in proflie */\n+struct i40e_profile_aq_section {\n+\tu16 opcode;\n+\tu16 flags;\n+\tu8  param[16];\n+\tu16 datalen;\n+\tu8  data[1];\n+};\n+\n struct i40e_profile_info {\n \tu32 track_id;\n \tstruct i40e_ddp_version version;\n",
    "prefixes": [
        "next",
        "S2-V2",
        "02/12"
    ]
}