[dpdk-dev,v2,2/5] net/i40e: add ppp processing

Message ID 1488526784-16621-3-git-send-email-beilei.xing@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Ferruh Yigit
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Xing, Beilei March 3, 2017, 7:39 a.m. UTC
  Add loading profile function.

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

Comments

Ferruh Yigit March 8, 2017, 12:07 p.m. UTC | #1
On 3/3/2017 7:39 AM, Beilei Xing wrote:
> Add loading profile function.
> 
> Signed-off-by: Beilei Xing <beilei.xing@intel.com>
> ---
>  drivers/net/i40e/i40e_ethdev.c  | 59 +++++++++++++++++++++++++++++++++++++++++
>  drivers/net/i40e/rte_pmd_i40e.h |  7 +++++

Also you need to update *version.map file for new API.

<...>

> +
> +int
> +i40e_process_package(uint8_t port, uint8_t *buff)

Function name is so generic, please pick another one that associated
with ppp.

Also please use defined name_space for public API: rte_pmd_i40e_<...>

> +{
> +	struct rte_eth_dev *dev = &rte_eth_devices[port];

Now this is public API to user applications, no more driver function, so
requires more attention. Input values needs to be verified before using
them.

Also you need to check if provided port_id if i40e port id.

<...>

>  
> +/**
> + * i40e_process_package - Load package
> + * @port: port id
> + * @buff: buffer of package
> + **/

Please provide proper doxygen tags, these are causing error.

> +int i40e_process_package(uint8_t port, uint8_t *buff);
> +
>  #endif /* _PMD_I40E_H_ */
>
  

Patch

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_ */