Add loading profile function.

Signed-off-by: Beilei Xing <beilei.x...@intel.com>
---
 drivers/net/i40e/i40e_ethdev.c  | 59 +++++++++++++++++++++++++++++++++++++++++
 drivers/net/i40e/rte_pmd_i40e.h |  7 +++++
 2 files changed, 66 insertions(+)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index ca4a87d..dae4b97 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -11456,3 +11456,62 @@ i40e_add_pinfo_to_list(struct i40e_hw *hw,
 
        return status;
 }
+
+int
+i40e_process_package(uint8_t port, uint8_t *buff)
+{
+       struct rte_eth_dev *dev = &rte_eth_devices[port];
+       struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+       struct i40e_package_header *pkg_hdr;
+       struct i40e_generic_seg_header *profile_seg_hdr;
+       struct i40e_generic_seg_header *metadata_seg_hdr;
+       uint32_t track_id;
+       uint8_t *profile_info_sec;
+       enum i40e_status_code status;
+
+       pkg_hdr = (struct i40e_package_header *)buff;
+
+       if (!pkg_hdr) {
+               PMD_DRV_LOG(ERR, "Failed to fill the package structure");
+               return -EINVAL;
+       }
+
+       /* Find metadata segment */
+       metadata_seg_hdr = i40e_find_segment_in_package(SEGMENT_TYPE_METADATA,
+                                                       pkg_hdr);
+       if (!metadata_seg_hdr) {
+               PMD_DRV_LOG(ERR, "Failed to find metadata segment header");
+               return -EINVAL;
+       }
+       track_id = ((struct i40e_metadata_segment *)metadata_seg_hdr)->track_id;
+
+       /* Find profile segment */
+       profile_seg_hdr = i40e_find_segment_in_package(SEGMENT_TYPE_I40E,
+                                                      pkg_hdr);
+       if (!profile_seg_hdr) {
+               PMD_DRV_LOG(ERR, "Failed to find profile segment header");
+               return -EINVAL;
+       }
+
+       /* Write profile to HW */
+       status = i40e_write_profile(hw,
+                           (struct i40e_profile_segment *)profile_seg_hdr,
+                           track_id);
+       if (!status)
+               printf("Write profile successfully.\n");
+
+       /* Add the profile info to the list of loaded profiles */
+       profile_info_sec = rte_zmalloc("i40e_profile_info",
+                              sizeof(struct i40e_profile_section_header) +
+                              sizeof(struct i40e_profile_info),
+                              0);
+       status = i40e_add_pinfo_to_list(hw,
+                       (struct i40e_profile_segment *)profile_seg_hdr,
+                       profile_info_sec, track_id);
+       if (!status)
+               printf("Add profile info successfully.\n");
+
+       rte_free(profile_info_sec);
+
+       return status;
+}
diff --git a/drivers/net/i40e/rte_pmd_i40e.h b/drivers/net/i40e/rte_pmd_i40e.h
index a0ad88c..7bd444c 100644
--- a/drivers/net/i40e/rte_pmd_i40e.h
+++ b/drivers/net/i40e/rte_pmd_i40e.h
@@ -332,4 +332,11 @@ int rte_pmd_i40e_get_vf_stats(uint8_t port,
 int rte_pmd_i40e_reset_vf_stats(uint8_t port,
                                uint16_t vf_id);
 
+/**
+ * i40e_process_package - Load package
+ * @port: port id
+ * @buff: buffer of package
+ **/
+int i40e_process_package(uint8_t port, uint8_t *buff);
+
 #endif /* _PMD_I40E_H_ */
-- 
2.5.5

Reply via email to