* [dpdk-dev] [PATCH] net/i40e: get information about ddp profile
@ 2017-05-26 12:41 Andrey Chilikin
2017-06-01 2:21 ` Xing, Beilei
` (7 more replies)
0 siblings, 8 replies; 13+ messages in thread
From: Andrey Chilikin @ 2017-05-26 12:41 UTC (permalink / raw)
To: dev; +Cc: beilei.xing, jingjing.wu, Andrey Chilikin
This patch adds ability to request information about dynamic device personalization profile
Signed-off-by: Andrey Chilikin <andrey.chilikin@intel.com>
---
drivers/net/i40e/rte_pmd_i40e.c | 163 ++++++++++++++++++++++++++++++++++++++-
drivers/net/i40e/rte_pmd_i40e.h | 45 +++++++++++
2 files changed, 204 insertions(+), 4 deletions(-)
diff --git a/drivers/net/i40e/rte_pmd_i40e.c b/drivers/net/i40e/rte_pmd_i40e.c
index f7ce62b..72e1564 100644
--- a/drivers/net/i40e/rte_pmd_i40e.c
+++ b/drivers/net/i40e/rte_pmd_i40e.c
@@ -1468,7 +1468,7 @@ int rte_pmd_i40e_set_vf_vlan_filter(uint8_t port, uint16_t vlan_id,
return ret;
}
-#define I40E_PROFILE_INFO_SIZE 48
+#define I40E_PROFILE_INFO_SIZE sizeof(struct rte_pmd_i40e_profile_info)
#define I40E_MAX_PROFILE_NUM 16
static void
@@ -1520,9 +1520,6 @@ int rte_pmd_i40e_set_vf_vlan_filter(uint8_t port, uint16_t vlan_id,
return status;
}
-#define I40E_PROFILE_INFO_SIZE 48
-#define I40E_MAX_PROFILE_NUM 16
-
/* Check if the profile info exists */
static int
i40e_check_profile_info(uint8_t port, uint8_t *profile_info_sec)
@@ -1682,6 +1679,164 @@ int rte_pmd_i40e_set_vf_vlan_filter(uint8_t port, uint16_t vlan_id,
return status;
}
+int rte_pmd_i40e_get_ddp_info(uint8_t *pkg_buff, uint32_t pkg_size,
+ uint8_t *info_buff, uint32_t info_size,
+ enum rte_pmd_i40e_package_info type)
+{
+ uint32_t ret_size;
+ struct i40e_package_header *pkg_hdr;
+ struct i40e_generic_seg_header *i40e_seg_hdr;
+ struct i40e_generic_seg_header *note_seg_hdr;
+ struct i40e_generic_seg_header *metadata_seg_hdr;
+
+ if (!info_buff) {
+ PMD_DRV_LOG(ERR, "Output info buff is invalid.");
+ return -EINVAL;
+ }
+
+ if (!pkg_buff || pkg_size < (sizeof(struct i40e_package_header) +
+ sizeof(struct i40e_metadata_segment) +
+ sizeof(uint32_t) * 2)) {
+ PMD_DRV_LOG(ERR, "Package buff is invalid.");
+ return -EINVAL;
+ }
+
+ pkg_hdr = (struct i40e_package_header *)pkg_buff;
+ if (pkg_hdr->segment_count < 2) {
+ PMD_DRV_LOG(ERR, "Segment_count should be 2 at least.");
+ return -EINVAL;
+ }
+
+ /* Find metadata segment */
+ metadata_seg_hdr = i40e_find_segment_in_package(SEGMENT_TYPE_METADATA,
+ pkg_hdr);
+
+ /* Find global notes segment */
+ note_seg_hdr = i40e_find_segment_in_package(SEGMENT_TYPE_NOTES,
+ pkg_hdr);
+
+ /* Find i40e profile segment */
+ i40e_seg_hdr = i40e_find_segment_in_package(SEGMENT_TYPE_I40E, pkg_hdr);
+
+ /* get global header info */
+ if (type == RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER) {
+ struct rte_pmd_i40e_profile_info *info =
+ (struct rte_pmd_i40e_profile_info *)info_buff;
+
+ if (info_size < sizeof(struct rte_pmd_i40e_profile_info)) {
+ PMD_DRV_LOG(ERR, "Output info buff size is invalid.");
+ return -EINVAL;
+ }
+
+ if (!metadata_seg_hdr) {
+ PMD_DRV_LOG(ERR, "Failed to find metadata segment header");
+ return -EINVAL;
+ }
+
+ memset(info, 0, sizeof(struct rte_pmd_i40e_profile_info));
+ info->owner = RTE_PMD_I40E_DDP_OWNER_UNKNOWN;
+ info->track_id =
+ ((struct i40e_metadata_segment *)metadata_seg_hdr)->track_id;
+
+ memcpy(info->name,
+ ((struct i40e_metadata_segment *)metadata_seg_hdr)->name,
+ I40E_DDP_NAME_SIZE);
+ memcpy(&info->version,
+ &((struct i40e_metadata_segment *)metadata_seg_hdr)->version,
+ sizeof(struct i40e_ddp_version));
+ return I40E_SUCCESS;
+ }
+
+ /* get global note size */
+ if (type == RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE) {
+ if (info_size < sizeof(uint32_t)) {
+ PMD_DRV_LOG(ERR, "Invalid information buffer size");
+ return -EINVAL;
+ }
+ if (note_seg_hdr == NULL)
+ ret_size = 0;
+ else
+ ret_size = note_seg_hdr->size;
+ *(uint32_t *)info_buff = ret_size;
+ return I40E_SUCCESS;
+ }
+
+ /* get global note */
+ if (type == RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES) {
+ if (note_seg_hdr == NULL)
+ return -ENOTSUP;
+ if (info_size < note_seg_hdr->size) {
+ PMD_DRV_LOG(ERR, "Information buffer size is too small");
+ return -EINVAL;
+ }
+ memcpy(info_buff, ¬e_seg_hdr[1], note_seg_hdr->size);
+ return I40E_SUCCESS;
+ }
+
+ /* get i40e segment header info */
+ if (type == RTE_PMD_I40E_PKG_INFO_HEADER) {
+ struct rte_pmd_i40e_profile_info *info =
+ (struct rte_pmd_i40e_profile_info *)info_buff;
+
+ if (info_size < sizeof(struct rte_pmd_i40e_profile_info)) {
+ PMD_DRV_LOG(ERR, "Output info buff size is invalid.");
+ return -EINVAL;
+ }
+
+ if (!metadata_seg_hdr) {
+ PMD_DRV_LOG(ERR, "Failed to find metadata segment header");
+ return -EINVAL;
+ }
+
+ if (!i40e_seg_hdr) {
+ PMD_DRV_LOG(ERR, "Failed to find i40e segment header");
+ return -EINVAL;
+ }
+
+ memset(info, 0, sizeof(struct rte_pmd_i40e_profile_info));
+ info->owner = RTE_PMD_I40E_DDP_OWNER_UNKNOWN;
+ info->track_id =
+ ((struct i40e_metadata_segment *)metadata_seg_hdr)->track_id;
+
+ memcpy(info->name,
+ ((struct i40e_profile_segment *)i40e_seg_hdr)->name,
+ I40E_DDP_NAME_SIZE);
+ memcpy(&info->version,
+ &((struct i40e_profile_segment *)i40e_seg_hdr)->version,
+ sizeof(struct i40e_ddp_version));
+ return I40E_SUCCESS;
+ }
+
+ /* get number of devices */
+ if (type == RTE_PMD_I40E_PKG_INFO_DEVID_NUM) {
+ if (info_size < sizeof(uint32_t)) {
+ PMD_DRV_LOG(ERR, "Invalid information buffer size");
+ return -EINVAL;
+ }
+ *(uint32_t *)info_buff =
+ ((struct i40e_profile_segment *)i40e_seg_hdr)->device_table_count;
+ return I40E_SUCCESS;
+ }
+
+ /* get list of devices */
+ if (type == RTE_PMD_I40E_PKG_INFO_DEVID_LIST) {
+ uint32_t dev_num;
+ dev_num =
+ ((struct i40e_profile_segment *)i40e_seg_hdr)->device_table_count;
+ if (info_size < sizeof(struct rte_pmd_i40e_ddp_device_id)*dev_num) {
+ PMD_DRV_LOG(ERR, "Invalid information buffer size");
+ return -EINVAL;
+ }
+ memcpy(info_buff,
+ ((struct i40e_profile_segment *)i40e_seg_hdr)->device_table,
+ sizeof(struct rte_pmd_i40e_ddp_device_id)*dev_num);
+ return I40E_SUCCESS;
+ }
+
+ PMD_DRV_LOG(ERR, "Info type %u is invalid.", type);
+ return -EINVAL;
+}
+
int
rte_pmd_i40e_get_ddp_list(uint8_t port, uint8_t *buff, uint32_t size)
{
diff --git a/drivers/net/i40e/rte_pmd_i40e.h b/drivers/net/i40e/rte_pmd_i40e.h
index 1efb2c4..0f376e2 100644
--- a/drivers/net/i40e/rte_pmd_i40e.h
+++ b/drivers/net/i40e/rte_pmd_i40e.h
@@ -74,6 +74,21 @@ enum rte_pmd_i40e_package_op {
RTE_PMD_I40E_PKG_OP_MAX = 32
};
+/**
+* Types of package information.
+*/
+enum rte_pmd_i40e_package_info {
+ RTE_PMD_I40E_PKG_INFO_UNDEFINED = 0,
+ RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER,
+ RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE,
+ RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES,
+ RTE_PMD_I40E_PKG_INFO_GLOBAL_MAX = 1024,
+ RTE_PMD_I40E_PKG_INFO_HEADER,
+ RTE_PMD_I40E_PKG_INFO_DEVID_NUM,
+ RTE_PMD_I40E_PKG_INFO_DEVID_LIST,
+ RTE_PMD_I40E_PKG_INFO_MAX = 0xFFFFFFFF
+};
+
#define RTE_PMD_I40E_DDP_NAME_SIZE 32
/**
@@ -88,6 +103,14 @@ struct rte_pmd_i40e_ddp_version {
};
/**
+* Device ID for dynamic device personalization.
+*/
+struct rte_pmd_i40e_ddp_device_id {
+ uint32_t vendor_dev_id;
+ uint32_t sub_vendor_dev_id;
+};
+
+/**
* Profile information in profile info list.
*/
struct rte_pmd_i40e_profile_info {
@@ -98,6 +121,8 @@ struct rte_pmd_i40e_profile_info {
uint8_t name[RTE_PMD_I40E_DDP_NAME_SIZE];
};
+#define RTE_PMD_I40E_DDP_OWNER_UNKNOWN 0xFF
+
/**
* Profile information list returned from HW.
*/
@@ -499,6 +524,26 @@ int rte_pmd_i40e_process_ddp_package(uint8_t port, uint8_t *buff,
enum rte_pmd_i40e_package_op op);
/**
+* rte_pmd_i40e_get_ddp_info - Get profile's info
+* @param pkg
+* buffer of package.
+* @param pkg_size
+* package buffer size
+* @param info
+* buffer for response
+* @param size
+* response buffer size
+* @param type
+* type of information requested
+* @return
+* - (0) if successful.
+* - (-EINVAL) if bad parameter.
+*/
+int rte_pmd_i40e_get_ddp_info(uint8_t *pkg, uint32_t pkg_size,
+ uint8_t *info, uint32_t size,
+ enum rte_pmd_i40e_package_info type);
+
+/**
* rte_pmd_i40e_get_ddp_list - Get loaded profile list
* @param port
* port id
--
1.7.0.7
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [dpdk-dev] [PATCH] net/i40e: get information about ddp profile
2017-05-26 12:41 [dpdk-dev] [PATCH] net/i40e: get information about ddp profile Andrey Chilikin
@ 2017-06-01 2:21 ` Xing, Beilei
2017-06-01 10:17 ` Chilikin, Andrey
2017-06-12 20:00 ` [dpdk-dev] [PATCH v2 0/2] " Andrey Chilikin
` (6 subsequent siblings)
7 siblings, 1 reply; 13+ messages in thread
From: Xing, Beilei @ 2017-06-01 2:21 UTC (permalink / raw)
To: Chilikin, Andrey, dev; +Cc: Wu, Jingjing
Hi Andrey,
> -----Original Message-----
> From: Chilikin, Andrey
> Sent: Friday, May 26, 2017 8:42 PM
> To: dev@dpdk.org
> Cc: Xing, Beilei <beilei.xing@intel.com>; Wu, Jingjing
> <jingjing.wu@intel.com>; Chilikin, Andrey <andrey.chilikin@intel.com>
> Subject: [PATCH] net/i40e: get information about ddp profile
>
> This patch adds ability to request information about dynamic device
> personalization profile
>
> Signed-off-by: Andrey Chilikin <andrey.chilikin@intel.com>
> ---
> drivers/net/i40e/rte_pmd_i40e.c | 163
> ++++++++++++++++++++++++++++++++++++++-
> drivers/net/i40e/rte_pmd_i40e.h | 45 +++++++++++
> 2 files changed, 204 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/i40e/rte_pmd_i40e.c
> b/drivers/net/i40e/rte_pmd_i40e.c index f7ce62b..72e1564 100644
> --- a/drivers/net/i40e/rte_pmd_i40e.c
> +++ b/drivers/net/i40e/rte_pmd_i40e.c
> @@ -1468,7 +1468,7 @@ int rte_pmd_i40e_set_vf_vlan_filter(uint8_t port,
> uint16_t vlan_id,
> return ret;
> }
>
> -#define I40E_PROFILE_INFO_SIZE 48
> +#define I40E_PROFILE_INFO_SIZE sizeof(struct rte_pmd_i40e_profile_info)
> #define I40E_MAX_PROFILE_NUM 16
>
> static void
> @@ -1520,9 +1520,6 @@ int rte_pmd_i40e_set_vf_vlan_filter(uint8_t port,
> uint16_t vlan_id,
> return status;
> }
>
> -#define I40E_PROFILE_INFO_SIZE 48
> -#define I40E_MAX_PROFILE_NUM 16
> -
> /* Check if the profile info exists */
> static int
> i40e_check_profile_info(uint8_t port, uint8_t *profile_info_sec) @@ -
> 1682,6 +1679,164 @@ int rte_pmd_i40e_set_vf_vlan_filter(uint8_t port,
> uint16_t vlan_id,
> return status;
> }
>
> +int rte_pmd_i40e_get_ddp_info(uint8_t *pkg_buff, uint32_t pkg_size,
> + uint8_t *info_buff, uint32_t info_size,
> + enum rte_pmd_i40e_package_info type)
> +{
> + uint32_t ret_size;
> + struct i40e_package_header *pkg_hdr;
> + struct i40e_generic_seg_header *i40e_seg_hdr;
> + struct i40e_generic_seg_header *note_seg_hdr;
> + struct i40e_generic_seg_header *metadata_seg_hdr;
> +
> + if (!info_buff) {
> + PMD_DRV_LOG(ERR, "Output info buff is invalid.");
> + return -EINVAL;
> + }
> +
> + if (!pkg_buff || pkg_size < (sizeof(struct i40e_package_header) +
> + sizeof(struct i40e_metadata_segment) +
> + sizeof(uint32_t) * 2)) {
> + PMD_DRV_LOG(ERR, "Package buff is invalid.");
> + return -EINVAL;
> + }
> +
> + pkg_hdr = (struct i40e_package_header *)pkg_buff;
> + if (pkg_hdr->segment_count < 2) {
> + PMD_DRV_LOG(ERR, "Segment_count should be 2 at least.");
> + return -EINVAL;
> + }
> +
> + /* Find metadata segment */
> + metadata_seg_hdr =
> i40e_find_segment_in_package(SEGMENT_TYPE_METADATA,
> + pkg_hdr);
> +
> + /* Find global notes segment */
> + note_seg_hdr =
> i40e_find_segment_in_package(SEGMENT_TYPE_NOTES,
> + pkg_hdr);
> +
> + /* Find i40e profile segment */
> + i40e_seg_hdr =
> i40e_find_segment_in_package(SEGMENT_TYPE_I40E,
> +pkg_hdr);
> +
> + /* get global header info */
> + if (type == RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER) {
> + struct rte_pmd_i40e_profile_info *info =
> + (struct rte_pmd_i40e_profile_info *)info_buff;
> +
> + if (info_size < sizeof(struct rte_pmd_i40e_profile_info)) {
> + PMD_DRV_LOG(ERR, "Output info buff size is
> invalid.");
> + return -EINVAL;
> + }
> +
> + if (!metadata_seg_hdr) {
> + PMD_DRV_LOG(ERR, "Failed to find metadata
> segment header");
> + return -EINVAL;
> + }
> +
> + memset(info, 0, sizeof(struct rte_pmd_i40e_profile_info));
> + info->owner = RTE_PMD_I40E_DDP_OWNER_UNKNOWN;
> + info->track_id =
> + ((struct i40e_metadata_segment
> *)metadata_seg_hdr)->track_id;
> +
> + memcpy(info->name,
> + ((struct i40e_metadata_segment
> *)metadata_seg_hdr)->name,
> + I40E_DDP_NAME_SIZE);
> + memcpy(&info->version,
> + &((struct i40e_metadata_segment
> *)metadata_seg_hdr)->version,
> + sizeof(struct i40e_ddp_version));
> + return I40E_SUCCESS;
> + }
> +
> + /* get global note size */
> + if (type == RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE) {
> + if (info_size < sizeof(uint32_t)) {
> + PMD_DRV_LOG(ERR, "Invalid information buffer
> size");
> + return -EINVAL;
> + }
> + if (note_seg_hdr == NULL)
> + ret_size = 0;
> + else
> + ret_size = note_seg_hdr->size;
> + *(uint32_t *)info_buff = ret_size;
> + return I40E_SUCCESS;
> + }
> +
> + /* get global note */
> + if (type == RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES) {
> + if (note_seg_hdr == NULL)
> + return -ENOTSUP;
> + if (info_size < note_seg_hdr->size) {
> + PMD_DRV_LOG(ERR, "Information buffer size is too
> small");
> + return -EINVAL;
> + }
> + memcpy(info_buff, ¬e_seg_hdr[1], note_seg_hdr->size);
> + return I40E_SUCCESS;
> + }
> +
> + /* get i40e segment header info */
> + if (type == RTE_PMD_I40E_PKG_INFO_HEADER) {
> + struct rte_pmd_i40e_profile_info *info =
> + (struct rte_pmd_i40e_profile_info *)info_buff;
> +
> + if (info_size < sizeof(struct rte_pmd_i40e_profile_info)) {
> + PMD_DRV_LOG(ERR, "Output info buff size is
> invalid.");
> + return -EINVAL;
> + }
> +
> + if (!metadata_seg_hdr) {
> + PMD_DRV_LOG(ERR, "Failed to find metadata
> segment header");
> + return -EINVAL;
> + }
> +
> + if (!i40e_seg_hdr) {
> + PMD_DRV_LOG(ERR, "Failed to find i40e segment
> header");
> + return -EINVAL;
> + }
> +
> + memset(info, 0, sizeof(struct rte_pmd_i40e_profile_info));
> + info->owner = RTE_PMD_I40E_DDP_OWNER_UNKNOWN;
> + info->track_id =
> + ((struct i40e_metadata_segment
> *)metadata_seg_hdr)->track_id;
> +
> + memcpy(info->name,
> + ((struct i40e_profile_segment *)i40e_seg_hdr)-
> >name,
> + I40E_DDP_NAME_SIZE);
> + memcpy(&info->version,
> + &((struct i40e_profile_segment *)i40e_seg_hdr)-
> >version,
> + sizeof(struct i40e_ddp_version));
> + return I40E_SUCCESS;
> + }
> +
> + /* get number of devices */
> + if (type == RTE_PMD_I40E_PKG_INFO_DEVID_NUM) {
> + if (info_size < sizeof(uint32_t)) {
> + PMD_DRV_LOG(ERR, "Invalid information buffer
> size");
> + return -EINVAL;
> + }
> + *(uint32_t *)info_buff =
> + ((struct i40e_profile_segment *)i40e_seg_hdr)-
> >device_table_count;
> + return I40E_SUCCESS;
> + }
> +
> + /* get list of devices */
> + if (type == RTE_PMD_I40E_PKG_INFO_DEVID_LIST) {
> + uint32_t dev_num;
> + dev_num =
> + ((struct i40e_profile_segment *)i40e_seg_hdr)-
> >device_table_count;
> + if (info_size < sizeof(struct
> rte_pmd_i40e_ddp_device_id)*dev_num) {
> + PMD_DRV_LOG(ERR, "Invalid information buffer
> size");
> + return -EINVAL;
> + }
> + memcpy(info_buff,
> + ((struct i40e_profile_segment *)i40e_seg_hdr)-
> >device_table,
> + sizeof(struct
> rte_pmd_i40e_ddp_device_id)*dev_num);
> + return I40E_SUCCESS;
> + }
> +
> + PMD_DRV_LOG(ERR, "Info type %u is invalid.", type);
> + return -EINVAL;
> +}
How about using switch case to replace above if statements?
> +
> int
> rte_pmd_i40e_get_ddp_list(uint8_t port, uint8_t *buff, uint32_t size) { diff
> --git a/drivers/net/i40e/rte_pmd_i40e.h b/drivers/net/i40e/rte_pmd_i40e.h
> index 1efb2c4..0f376e2 100644
> --- a/drivers/net/i40e/rte_pmd_i40e.h
> +++ b/drivers/net/i40e/rte_pmd_i40e.h
> @@ -74,6 +74,21 @@ enum rte_pmd_i40e_package_op {
> RTE_PMD_I40E_PKG_OP_MAX = 32
> };
>
> +/**
> +* Types of package information.
> +*/
> +enum rte_pmd_i40e_package_info {
> + RTE_PMD_I40E_PKG_INFO_UNDEFINED = 0,
> + RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER,
> + RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE,
> + RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES,
> + RTE_PMD_I40E_PKG_INFO_GLOBAL_MAX = 1024,
> + RTE_PMD_I40E_PKG_INFO_HEADER,
> + RTE_PMD_I40E_PKG_INFO_DEVID_NUM,
> + RTE_PMD_I40E_PKG_INFO_DEVID_LIST,
> + RTE_PMD_I40E_PKG_INFO_MAX = 0xFFFFFFFF };
> +
> #define RTE_PMD_I40E_DDP_NAME_SIZE 32
>
> /**
> @@ -88,6 +103,14 @@ struct rte_pmd_i40e_ddp_version { };
>
> /**
> +* Device ID for dynamic device personalization.
> +*/
> +struct rte_pmd_i40e_ddp_device_id {
> + uint32_t vendor_dev_id;
> + uint32_t sub_vendor_dev_id;
> +};
> +
> +/**
> * Profile information in profile info list.
> */
> struct rte_pmd_i40e_profile_info {
> @@ -98,6 +121,8 @@ struct rte_pmd_i40e_profile_info {
> uint8_t name[RTE_PMD_I40E_DDP_NAME_SIZE]; };
>
> +#define RTE_PMD_I40E_DDP_OWNER_UNKNOWN 0xFF
> +
> /**
> * Profile information list returned from HW.
> */
> @@ -499,6 +524,26 @@ int rte_pmd_i40e_process_ddp_package(uint8_t
> port, uint8_t *buff,
> enum rte_pmd_i40e_package_op op);
>
> /**
> +* rte_pmd_i40e_get_ddp_info - Get profile's info
> +* @param pkg
> +* buffer of package.
> +* @param pkg_size
> +* package buffer size
> +* @param info
> +* buffer for response
> +* @param size
> +* response buffer size
> +* @param type
> +* type of information requested
> +* @return
> +* - (0) if successful.
> +* - (-EINVAL) if bad parameter.
> +*/
> +int rte_pmd_i40e_get_ddp_info(uint8_t *pkg, uint32_t pkg_size,
> + uint8_t *info, uint32_t size,
> + enum rte_pmd_i40e_package_info type);
> +
> +/**
> * rte_pmd_i40e_get_ddp_list - Get loaded profile list
> * @param port
> * port id
> --
> 1.7.0.7
Will you add testpmd CLI to support getting DDP info?
Besides, API info in rte_pmd_i40e_version.map should be updated.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [dpdk-dev] [PATCH] net/i40e: get information about ddp profile
2017-06-01 2:21 ` Xing, Beilei
@ 2017-06-01 10:17 ` Chilikin, Andrey
0 siblings, 0 replies; 13+ messages in thread
From: Chilikin, Andrey @ 2017-06-01 10:17 UTC (permalink / raw)
To: Xing, Beilei, dev; +Cc: Wu, Jingjing
Hi Beilei
> -----Original Message-----
> From: Xing, Beilei
> Sent: Thursday, June 1, 2017 3:21 AM
> To: Chilikin, Andrey <andrey.chilikin@intel.com>; dev@dpdk.org
> Cc: Wu, Jingjing <jingjing.wu@intel.com>
> Subject: RE: [PATCH] net/i40e: get information about ddp profile
>
> Hi Andrey,
>
> > -----Original Message-----
> > From: Chilikin, Andrey
> > Sent: Friday, May 26, 2017 8:42 PM
> > To: dev@dpdk.org
> > Cc: Xing, Beilei <beilei.xing@intel.com>; Wu, Jingjing
> > <jingjing.wu@intel.com>; Chilikin, Andrey <andrey.chilikin@intel.com>
> > Subject: [PATCH] net/i40e: get information about ddp profile
> >
> > This patch adds ability to request information about dynamic device
> > personalization profile
> >
> > Signed-off-by: Andrey Chilikin <andrey.chilikin@intel.com>
> > ---
> > drivers/net/i40e/rte_pmd_i40e.c | 163
> > ++++++++++++++++++++++++++++++++++++++-
> > drivers/net/i40e/rte_pmd_i40e.h | 45 +++++++++++
> > 2 files changed, 204 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/net/i40e/rte_pmd_i40e.c
> > b/drivers/net/i40e/rte_pmd_i40e.c index f7ce62b..72e1564 100644
> > --- a/drivers/net/i40e/rte_pmd_i40e.c
> > +++ b/drivers/net/i40e/rte_pmd_i40e.c
> > @@ -1468,7 +1468,7 @@ int rte_pmd_i40e_set_vf_vlan_filter(uint8_t
> > port, uint16_t vlan_id,
> > return ret;
> > }
> >
> > -#define I40E_PROFILE_INFO_SIZE 48
> > +#define I40E_PROFILE_INFO_SIZE sizeof(struct
> > +rte_pmd_i40e_profile_info)
> > #define I40E_MAX_PROFILE_NUM 16
> >
> > static void
> > @@ -1520,9 +1520,6 @@ int rte_pmd_i40e_set_vf_vlan_filter(uint8_t
> > port, uint16_t vlan_id,
> > return status;
> > }
> >
> > -#define I40E_PROFILE_INFO_SIZE 48
> > -#define I40E_MAX_PROFILE_NUM 16
> > -
> > /* Check if the profile info exists */ static int
> > i40e_check_profile_info(uint8_t port, uint8_t *profile_info_sec) @@ -
> > 1682,6 +1679,164 @@ int rte_pmd_i40e_set_vf_vlan_filter(uint8_t port,
> > uint16_t vlan_id,
> > return status;
> > }
> >
> > +int rte_pmd_i40e_get_ddp_info(uint8_t *pkg_buff, uint32_t pkg_size,
> > + uint8_t *info_buff, uint32_t info_size,
> > + enum rte_pmd_i40e_package_info type) {
> > + uint32_t ret_size;
> > + struct i40e_package_header *pkg_hdr;
> > + struct i40e_generic_seg_header *i40e_seg_hdr;
> > + struct i40e_generic_seg_header *note_seg_hdr;
> > + struct i40e_generic_seg_header *metadata_seg_hdr;
> > +
> > + if (!info_buff) {
> > + PMD_DRV_LOG(ERR, "Output info buff is invalid.");
> > + return -EINVAL;
> > + }
> > +
> > + if (!pkg_buff || pkg_size < (sizeof(struct i40e_package_header) +
> > + sizeof(struct i40e_metadata_segment) +
> > + sizeof(uint32_t) * 2)) {
> > + PMD_DRV_LOG(ERR, "Package buff is invalid.");
> > + return -EINVAL;
> > + }
> > +
> > + pkg_hdr = (struct i40e_package_header *)pkg_buff;
> > + if (pkg_hdr->segment_count < 2) {
> > + PMD_DRV_LOG(ERR, "Segment_count should be 2 at least.");
> > + return -EINVAL;
> > + }
> > +
> > + /* Find metadata segment */
> > + metadata_seg_hdr =
> > i40e_find_segment_in_package(SEGMENT_TYPE_METADATA,
> > + pkg_hdr);
> > +
> > + /* Find global notes segment */
> > + note_seg_hdr =
> > i40e_find_segment_in_package(SEGMENT_TYPE_NOTES,
> > + pkg_hdr);
> > +
> > + /* Find i40e profile segment */
> > + i40e_seg_hdr =
> > i40e_find_segment_in_package(SEGMENT_TYPE_I40E,
> > +pkg_hdr);
> > +
> > + /* get global header info */
> > + if (type == RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER) {
> > + struct rte_pmd_i40e_profile_info *info =
> > + (struct rte_pmd_i40e_profile_info *)info_buff;
> > +
> > + if (info_size < sizeof(struct rte_pmd_i40e_profile_info)) {
> > + PMD_DRV_LOG(ERR, "Output info buff size is
> > invalid.");
> > + return -EINVAL;
> > + }
> > +
> > + if (!metadata_seg_hdr) {
> > + PMD_DRV_LOG(ERR, "Failed to find metadata
> > segment header");
> > + return -EINVAL;
> > + }
> > +
> > + memset(info, 0, sizeof(struct rte_pmd_i40e_profile_info));
> > + info->owner = RTE_PMD_I40E_DDP_OWNER_UNKNOWN;
> > + info->track_id =
> > + ((struct i40e_metadata_segment
> > *)metadata_seg_hdr)->track_id;
> > +
> > + memcpy(info->name,
> > + ((struct i40e_metadata_segment
> > *)metadata_seg_hdr)->name,
> > + I40E_DDP_NAME_SIZE);
> > + memcpy(&info->version,
> > + &((struct i40e_metadata_segment
> > *)metadata_seg_hdr)->version,
> > + sizeof(struct i40e_ddp_version));
> > + return I40E_SUCCESS;
> > + }
> > +
> > + /* get global note size */
> > + if (type == RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE) {
> > + if (info_size < sizeof(uint32_t)) {
> > + PMD_DRV_LOG(ERR, "Invalid information buffer
> > size");
> > + return -EINVAL;
> > + }
> > + if (note_seg_hdr == NULL)
> > + ret_size = 0;
> > + else
> > + ret_size = note_seg_hdr->size;
> > + *(uint32_t *)info_buff = ret_size;
> > + return I40E_SUCCESS;
> > + }
> > +
> > + /* get global note */
> > + if (type == RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES) {
> > + if (note_seg_hdr == NULL)
> > + return -ENOTSUP;
> > + if (info_size < note_seg_hdr->size) {
> > + PMD_DRV_LOG(ERR, "Information buffer size is too
> > small");
> > + return -EINVAL;
> > + }
> > + memcpy(info_buff, ¬e_seg_hdr[1], note_seg_hdr->size);
> > + return I40E_SUCCESS;
> > + }
> > +
> > + /* get i40e segment header info */
> > + if (type == RTE_PMD_I40E_PKG_INFO_HEADER) {
> > + struct rte_pmd_i40e_profile_info *info =
> > + (struct rte_pmd_i40e_profile_info *)info_buff;
> > +
> > + if (info_size < sizeof(struct rte_pmd_i40e_profile_info)) {
> > + PMD_DRV_LOG(ERR, "Output info buff size is
> > invalid.");
> > + return -EINVAL;
> > + }
> > +
> > + if (!metadata_seg_hdr) {
> > + PMD_DRV_LOG(ERR, "Failed to find metadata
> > segment header");
> > + return -EINVAL;
> > + }
> > +
> > + if (!i40e_seg_hdr) {
> > + PMD_DRV_LOG(ERR, "Failed to find i40e segment
> > header");
> > + return -EINVAL;
> > + }
> > +
> > + memset(info, 0, sizeof(struct rte_pmd_i40e_profile_info));
> > + info->owner = RTE_PMD_I40E_DDP_OWNER_UNKNOWN;
> > + info->track_id =
> > + ((struct i40e_metadata_segment
> > *)metadata_seg_hdr)->track_id;
> > +
> > + memcpy(info->name,
> > + ((struct i40e_profile_segment *)i40e_seg_hdr)-
> > >name,
> > + I40E_DDP_NAME_SIZE);
> > + memcpy(&info->version,
> > + &((struct i40e_profile_segment *)i40e_seg_hdr)-
> > >version,
> > + sizeof(struct i40e_ddp_version));
> > + return I40E_SUCCESS;
> > + }
> > +
> > + /* get number of devices */
> > + if (type == RTE_PMD_I40E_PKG_INFO_DEVID_NUM) {
> > + if (info_size < sizeof(uint32_t)) {
> > + PMD_DRV_LOG(ERR, "Invalid information buffer
> > size");
> > + return -EINVAL;
> > + }
> > + *(uint32_t *)info_buff =
> > + ((struct i40e_profile_segment *)i40e_seg_hdr)-
> > >device_table_count;
> > + return I40E_SUCCESS;
> > + }
> > +
> > + /* get list of devices */
> > + if (type == RTE_PMD_I40E_PKG_INFO_DEVID_LIST) {
> > + uint32_t dev_num;
> > + dev_num =
> > + ((struct i40e_profile_segment *)i40e_seg_hdr)-
> > >device_table_count;
> > + if (info_size < sizeof(struct
> > rte_pmd_i40e_ddp_device_id)*dev_num) {
> > + PMD_DRV_LOG(ERR, "Invalid information buffer
> > size");
> > + return -EINVAL;
> > + }
> > + memcpy(info_buff,
> > + ((struct i40e_profile_segment *)i40e_seg_hdr)-
> > >device_table,
> > + sizeof(struct
> > rte_pmd_i40e_ddp_device_id)*dev_num);
> > + return I40E_SUCCESS;
> > + }
> > +
> > + PMD_DRV_LOG(ERR, "Info type %u is invalid.", type);
> > + return -EINVAL;
> > +}
>
> How about using switch case to replace above if statements?
Not sure if switch case is better here as there is no post-switch processing,
each if statement has its own return and no breaks are needed.
>
> > +
> > int
> > rte_pmd_i40e_get_ddp_list(uint8_t port, uint8_t *buff, uint32_t size)
> > { diff --git a/drivers/net/i40e/rte_pmd_i40e.h
> > b/drivers/net/i40e/rte_pmd_i40e.h index 1efb2c4..0f376e2 100644
> > --- a/drivers/net/i40e/rte_pmd_i40e.h
> > +++ b/drivers/net/i40e/rte_pmd_i40e.h
> > @@ -74,6 +74,21 @@ enum rte_pmd_i40e_package_op {
> > RTE_PMD_I40E_PKG_OP_MAX = 32
> > };
> >
> > +/**
> > +* Types of package information.
> > +*/
> > +enum rte_pmd_i40e_package_info {
> > + RTE_PMD_I40E_PKG_INFO_UNDEFINED = 0,
> > + RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER,
> > + RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE,
> > + RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES,
> > + RTE_PMD_I40E_PKG_INFO_GLOBAL_MAX = 1024,
> > + RTE_PMD_I40E_PKG_INFO_HEADER,
> > + RTE_PMD_I40E_PKG_INFO_DEVID_NUM,
> > + RTE_PMD_I40E_PKG_INFO_DEVID_LIST,
> > + RTE_PMD_I40E_PKG_INFO_MAX = 0xFFFFFFFF };
> > +
> > #define RTE_PMD_I40E_DDP_NAME_SIZE 32
> >
> > /**
> > @@ -88,6 +103,14 @@ struct rte_pmd_i40e_ddp_version { };
> >
> > /**
> > +* Device ID for dynamic device personalization.
> > +*/
> > +struct rte_pmd_i40e_ddp_device_id {
> > + uint32_t vendor_dev_id;
> > + uint32_t sub_vendor_dev_id;
> > +};
> > +
> > +/**
> > * Profile information in profile info list.
> > */
> > struct rte_pmd_i40e_profile_info {
> > @@ -98,6 +121,8 @@ struct rte_pmd_i40e_profile_info {
> > uint8_t name[RTE_PMD_I40E_DDP_NAME_SIZE]; };
> >
> > +#define RTE_PMD_I40E_DDP_OWNER_UNKNOWN 0xFF
> > +
> > /**
> > * Profile information list returned from HW.
> > */
> > @@ -499,6 +524,26 @@ int rte_pmd_i40e_process_ddp_package(uint8_t
> > port, uint8_t *buff,
> > enum rte_pmd_i40e_package_op op);
> >
> > /**
> > +* rte_pmd_i40e_get_ddp_info - Get profile's info
> > +* @param pkg
> > +* buffer of package.
> > +* @param pkg_size
> > +* package buffer size
> > +* @param info
> > +* buffer for response
> > +* @param size
> > +* response buffer size
> > +* @param type
> > +* type of information requested
> > +* @return
> > +* - (0) if successful.
> > +* - (-EINVAL) if bad parameter.
> > +*/
> > +int rte_pmd_i40e_get_ddp_info(uint8_t *pkg, uint32_t pkg_size,
> > + uint8_t *info, uint32_t size,
> > + enum rte_pmd_i40e_package_info type);
> > +
> > +/**
> > * rte_pmd_i40e_get_ddp_list - Get loaded profile list
> > * @param port
> > * port id
> > --
> > 1.7.0.7
>
> Will you add testpmd CLI to support getting DDP info?
> Besides, API info in rte_pmd_i40e_version.map should be updated.
Will add to the second revision of the patch.
/Andrey
^ permalink raw reply [flat|nested] 13+ messages in thread
* [dpdk-dev] [PATCH v2 0/2] net/i40e: get information about ddp profile
2017-05-26 12:41 [dpdk-dev] [PATCH] net/i40e: get information about ddp profile Andrey Chilikin
2017-06-01 2:21 ` Xing, Beilei
@ 2017-06-12 20:00 ` Andrey Chilikin
2017-06-14 5:51 ` Xing, Beilei
2017-06-12 20:00 ` [dpdk-dev] [PATCH v2 1/2] " Andrey Chilikin
` (5 subsequent siblings)
7 siblings, 1 reply; 13+ messages in thread
From: Andrey Chilikin @ 2017-06-12 20:00 UTC (permalink / raw)
To: dev; +Cc: beilei.xing, jingjing.wu, Andrey Chilikin
This patch adds ability to request information about dynamic device
personalization profile
v2:
Add rte_pmd_i40e_get_ddp_info() function to i40e version map
Add CL to test-pmd for getting information about profile
Andrey Chilikin (2):
net/i40e: get information about ddp profile
app/testpmd: enable ddp get info feature
app/test-pmd/cmdline.c | 131 ++++++++++++++++++++++++
drivers/net/i40e/rte_pmd_i40e.c | 163 +++++++++++++++++++++++++++++-
drivers/net/i40e/rte_pmd_i40e.h | 46 +++++++++
drivers/net/i40e/rte_pmd_i40e_version.map | 7 ++
4 files changed, 343 insertions(+), 4 deletions(-)
--
2.13.0
^ permalink raw reply [flat|nested] 13+ messages in thread
* [dpdk-dev] [PATCH v2 1/2] net/i40e: get information about ddp profile
2017-05-26 12:41 [dpdk-dev] [PATCH] net/i40e: get information about ddp profile Andrey Chilikin
2017-06-01 2:21 ` Xing, Beilei
2017-06-12 20:00 ` [dpdk-dev] [PATCH v2 0/2] " Andrey Chilikin
@ 2017-06-12 20:00 ` Andrey Chilikin
2017-06-12 20:00 ` [dpdk-dev] [PATCH v2 2/2] app/testpmd: enable ddp get info feature Andrey Chilikin
` (4 subsequent siblings)
7 siblings, 0 replies; 13+ messages in thread
From: Andrey Chilikin @ 2017-06-12 20:00 UTC (permalink / raw)
To: dev; +Cc: beilei.xing, jingjing.wu, Andrey Chilikin
This patch adds ability to request information about dynamic device
personalization profile
Signed-off-by: Andrey Chilikin <andrey.chilikin@intel.com>
---
drivers/net/i40e/rte_pmd_i40e.c | 163 +++++++++++++++++++++++++++++-
drivers/net/i40e/rte_pmd_i40e.h | 46 +++++++++
drivers/net/i40e/rte_pmd_i40e_version.map | 7 ++
3 files changed, 212 insertions(+), 4 deletions(-)
diff --git a/drivers/net/i40e/rte_pmd_i40e.c b/drivers/net/i40e/rte_pmd_i40e.c
index f7ce62bb5..45cdcfaa3 100644
--- a/drivers/net/i40e/rte_pmd_i40e.c
+++ b/drivers/net/i40e/rte_pmd_i40e.c
@@ -1468,7 +1468,7 @@ rte_pmd_i40e_set_tc_strict_prio(uint8_t port, uint8_t tc_map)
return ret;
}
-#define I40E_PROFILE_INFO_SIZE 48
+#define I40E_PROFILE_INFO_SIZE sizeof(struct rte_pmd_i40e_profile_info)
#define I40E_MAX_PROFILE_NUM 16
static void
@@ -1520,9 +1520,6 @@ i40e_add_rm_profile_info(struct i40e_hw *hw, uint8_t *profile_info_sec)
return status;
}
-#define I40E_PROFILE_INFO_SIZE 48
-#define I40E_MAX_PROFILE_NUM 16
-
/* Check if the profile info exists */
static int
i40e_check_profile_info(uint8_t port, uint8_t *profile_info_sec)
@@ -1682,6 +1679,164 @@ rte_pmd_i40e_process_ddp_package(uint8_t port, uint8_t *buff,
return status;
}
+int rte_pmd_i40e_get_ddp_info(uint8_t *pkg_buff, uint32_t pkg_size,
+ uint8_t *info_buff, uint32_t info_size,
+ enum rte_pmd_i40e_package_info type)
+{
+ uint32_t ret_size;
+ struct i40e_package_header *pkg_hdr;
+ struct i40e_generic_seg_header *i40e_seg_hdr;
+ struct i40e_generic_seg_header *note_seg_hdr;
+ struct i40e_generic_seg_header *metadata_seg_hdr;
+
+ if (!info_buff) {
+ PMD_DRV_LOG(ERR, "Output info buff is invalid.");
+ return -EINVAL;
+ }
+
+ if (!pkg_buff || pkg_size < (sizeof(struct i40e_package_header) +
+ sizeof(struct i40e_metadata_segment) +
+ sizeof(uint32_t) * 2)) {
+ PMD_DRV_LOG(ERR, "Package buff is invalid.");
+ return -EINVAL;
+ }
+
+ pkg_hdr = (struct i40e_package_header *)pkg_buff;
+ if (pkg_hdr->segment_count < 2) {
+ PMD_DRV_LOG(ERR, "Segment_count should be 2 at least.");
+ return -EINVAL;
+ }
+
+ /* Find metadata segment */
+ metadata_seg_hdr = i40e_find_segment_in_package(SEGMENT_TYPE_METADATA,
+ pkg_hdr);
+
+ /* Find global notes segment */
+ note_seg_hdr = i40e_find_segment_in_package(SEGMENT_TYPE_NOTES,
+ pkg_hdr);
+
+ /* Find i40e profile segment */
+ i40e_seg_hdr = i40e_find_segment_in_package(SEGMENT_TYPE_I40E, pkg_hdr);
+
+ /* get global header info */
+ if (type == RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER) {
+ struct rte_pmd_i40e_profile_info *info =
+ (struct rte_pmd_i40e_profile_info *)info_buff;
+
+ if (info_size < sizeof(struct rte_pmd_i40e_profile_info)) {
+ PMD_DRV_LOG(ERR, "Output info buff size is invalid.");
+ return -EINVAL;
+ }
+
+ if (!metadata_seg_hdr) {
+ PMD_DRV_LOG(ERR, "Failed to find metadata segment header");
+ return -EINVAL;
+ }
+
+ memset(info, 0, sizeof(struct rte_pmd_i40e_profile_info));
+ info->owner = RTE_PMD_I40E_DDP_OWNER_UNKNOWN;
+ info->track_id =
+ ((struct i40e_metadata_segment *)metadata_seg_hdr)->track_id;
+
+ memcpy(info->name,
+ ((struct i40e_metadata_segment *)metadata_seg_hdr)->name,
+ I40E_DDP_NAME_SIZE);
+ memcpy(&info->version,
+ &((struct i40e_metadata_segment *)metadata_seg_hdr)->version,
+ sizeof(struct i40e_ddp_version));
+ return I40E_SUCCESS;
+ }
+
+ /* get global note size */
+ if (type == RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE) {
+ if (info_size < sizeof(uint32_t)) {
+ PMD_DRV_LOG(ERR, "Invalid information buffer size");
+ return -EINVAL;
+ }
+ if (note_seg_hdr == NULL)
+ ret_size = 0;
+ else
+ ret_size = note_seg_hdr->size;
+ *(uint32_t *)info_buff = ret_size;
+ return I40E_SUCCESS;
+ }
+
+ /* get global note */
+ if (type == RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES) {
+ if (note_seg_hdr == NULL)
+ return -ENOTSUP;
+ if (info_size < note_seg_hdr->size) {
+ PMD_DRV_LOG(ERR, "Information buffer size is too small");
+ return -EINVAL;
+ }
+ memcpy(info_buff, ¬e_seg_hdr[1], note_seg_hdr->size);
+ return I40E_SUCCESS;
+ }
+
+ /* get i40e segment header info */
+ if (type == RTE_PMD_I40E_PKG_INFO_HEADER) {
+ struct rte_pmd_i40e_profile_info *info =
+ (struct rte_pmd_i40e_profile_info *)info_buff;
+
+ if (info_size < sizeof(struct rte_pmd_i40e_profile_info)) {
+ PMD_DRV_LOG(ERR, "Output info buff size is invalid.");
+ return -EINVAL;
+ }
+
+ if (!metadata_seg_hdr) {
+ PMD_DRV_LOG(ERR, "Failed to find metadata segment header");
+ return -EINVAL;
+ }
+
+ if (!i40e_seg_hdr) {
+ PMD_DRV_LOG(ERR, "Failed to find i40e segment header");
+ return -EINVAL;
+ }
+
+ memset(info, 0, sizeof(struct rte_pmd_i40e_profile_info));
+ info->owner = RTE_PMD_I40E_DDP_OWNER_UNKNOWN;
+ info->track_id =
+ ((struct i40e_metadata_segment *)metadata_seg_hdr)->track_id;
+
+ memcpy(info->name,
+ ((struct i40e_profile_segment *)i40e_seg_hdr)->name,
+ I40E_DDP_NAME_SIZE);
+ memcpy(&info->version,
+ &((struct i40e_profile_segment *)i40e_seg_hdr)->version,
+ sizeof(struct i40e_ddp_version));
+ return I40E_SUCCESS;
+ }
+
+ /* get number of devices */
+ if (type == RTE_PMD_I40E_PKG_INFO_DEVID_NUM) {
+ if (info_size < sizeof(uint32_t)) {
+ PMD_DRV_LOG(ERR, "Invalid information buffer size");
+ return -EINVAL;
+ }
+ *(uint32_t *)info_buff =
+ ((struct i40e_profile_segment *)i40e_seg_hdr)->device_table_count;
+ return I40E_SUCCESS;
+ }
+
+ /* get list of devices */
+ if (type == RTE_PMD_I40E_PKG_INFO_DEVID_LIST) {
+ uint32_t dev_num;
+ dev_num =
+ ((struct i40e_profile_segment *)i40e_seg_hdr)->device_table_count;
+ if (info_size < sizeof(struct rte_pmd_i40e_ddp_device_id) * dev_num) {
+ PMD_DRV_LOG(ERR, "Invalid information buffer size");
+ return -EINVAL;
+ }
+ memcpy(info_buff,
+ ((struct i40e_profile_segment *)i40e_seg_hdr)->device_table,
+ sizeof(struct rte_pmd_i40e_ddp_device_id) * dev_num);
+ return I40E_SUCCESS;
+ }
+
+ PMD_DRV_LOG(ERR, "Info type %u is invalid.", type);
+ return -EINVAL;
+}
+
int
rte_pmd_i40e_get_ddp_list(uint8_t port, uint8_t *buff, uint32_t size)
{
diff --git a/drivers/net/i40e/rte_pmd_i40e.h b/drivers/net/i40e/rte_pmd_i40e.h
index 1efb2c4bf..11adfd0f9 100644
--- a/drivers/net/i40e/rte_pmd_i40e.h
+++ b/drivers/net/i40e/rte_pmd_i40e.h
@@ -74,6 +74,21 @@ enum rte_pmd_i40e_package_op {
RTE_PMD_I40E_PKG_OP_MAX = 32
};
+/**
+ * Types of package information.
+ */
+enum rte_pmd_i40e_package_info {
+ RTE_PMD_I40E_PKG_INFO_UNDEFINED = 0,
+ RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER,
+ RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE,
+ RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES,
+ RTE_PMD_I40E_PKG_INFO_GLOBAL_MAX = 1024,
+ RTE_PMD_I40E_PKG_INFO_HEADER,
+ RTE_PMD_I40E_PKG_INFO_DEVID_NUM,
+ RTE_PMD_I40E_PKG_INFO_DEVID_LIST,
+ RTE_PMD_I40E_PKG_INFO_MAX = 0xFFFFFFFF
+};
+
#define RTE_PMD_I40E_DDP_NAME_SIZE 32
/**
@@ -88,6 +103,14 @@ struct rte_pmd_i40e_ddp_version {
};
/**
+ * Device ID for dynamic device personalization.
+ */
+struct rte_pmd_i40e_ddp_device_id {
+ uint32_t vendor_dev_id;
+ uint32_t sub_vendor_dev_id;
+};
+
+/**
* Profile information in profile info list.
*/
struct rte_pmd_i40e_profile_info {
@@ -98,6 +121,8 @@ struct rte_pmd_i40e_profile_info {
uint8_t name[RTE_PMD_I40E_DDP_NAME_SIZE];
};
+#define RTE_PMD_I40E_DDP_OWNER_UNKNOWN 0xFF
+
/**
* Profile information list returned from HW.
*/
@@ -499,6 +524,27 @@ int rte_pmd_i40e_process_ddp_package(uint8_t port, uint8_t *buff,
enum rte_pmd_i40e_package_op op);
/**
+ * rte_pmd_i40e_get_ddp_info - Get profile's info
+ * @param pkg
+ * buffer of package.
+ * @param pkg_size
+ * package buffer size
+ * @param info
+ * buffer for response
+ * @param size
+ * response buffer size
+ * @param type
+ * type of information requested
+ * @return
+ * - (0) if successful.
+ * - (-ENOTSUP) if information type not supported by the profile.
+ * - (-EINVAL) if bad parameter.
+ */
+int rte_pmd_i40e_get_ddp_info(uint8_t *pkg, uint32_t pkg_size,
+ uint8_t *info, uint32_t size,
+ enum rte_pmd_i40e_package_info type);
+
+/**
* rte_pmd_i40e_get_ddp_list - Get loaded profile list
* @param port
* port id
diff --git a/drivers/net/i40e/rte_pmd_i40e_version.map b/drivers/net/i40e/rte_pmd_i40e_version.map
index 3b0e805df..20cc9801a 100644
--- a/drivers/net/i40e/rte_pmd_i40e_version.map
+++ b/drivers/net/i40e/rte_pmd_i40e_version.map
@@ -38,3 +38,10 @@ DPDK_17.05 {
rte_pmd_i40e_get_ddp_list;
} DPDK_17.02;
+
+DPDK_17.08 {
+ global:
+
+ rte_pmd_i40e_get_ddp_info;
+
+} DPDK_17.05;
--
2.13.0
^ permalink raw reply [flat|nested] 13+ messages in thread
* [dpdk-dev] [PATCH v2 2/2] app/testpmd: enable ddp get info feature
2017-05-26 12:41 [dpdk-dev] [PATCH] net/i40e: get information about ddp profile Andrey Chilikin
` (2 preceding siblings ...)
2017-06-12 20:00 ` [dpdk-dev] [PATCH v2 1/2] " Andrey Chilikin
@ 2017-06-12 20:00 ` Andrey Chilikin
2017-06-15 10:09 ` Ferruh Yigit
2017-06-16 9:25 ` [dpdk-dev] [PATCH v3 0/3] net/i40e: get information about ddp profile Andrey Chilikin
` (3 subsequent siblings)
7 siblings, 1 reply; 13+ messages in thread
From: Andrey Chilikin @ 2017-06-12 20:00 UTC (permalink / raw)
To: dev; +Cc: beilei.xing, jingjing.wu, Andrey Chilikin
This patch demostrates how to get information about dynamic device
personalization profile.
Command 'ddp get info (profile_path)' extracts and prints
information about the given profile.
Signed-off-by: Andrey Chilikin <andrey.chilikin@intel.com>
---
app/test-pmd/cmdline.c | 131 +++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 131 insertions(+)
diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 0afac68c7..9e7858901 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -218,6 +218,9 @@ static void cmd_help_long_parsed(void *parsed_result,
"ddp get list (port_id)\n"
" Get ddp profile info list\n\n"
+ "ddp get info (profile_path)\n"
+ " Get ddp profile information.\n\n"
+
"show vf stats (port_id) (vf_id)\n"
" Display a VF's statistics.\n\n"
@@ -12904,6 +12907,133 @@ cmdline_parse_inst_t cmd_ddp_add = {
},
};
+/* Get dynamic device personalization profile info */
+struct cmd_ddp_info_result {
+ cmdline_fixed_string_t ddp;
+ cmdline_fixed_string_t get;
+ cmdline_fixed_string_t info;
+ char filepath[];
+};
+
+cmdline_parse_token_string_t cmd_ddp_info_ddp =
+ TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
+cmdline_parse_token_string_t cmd_ddp_info_get =
+ TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
+cmdline_parse_token_string_t cmd_ddp_info_info =
+ TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
+cmdline_parse_token_string_t cmd_ddp_info_filepath =
+ TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
+
+static void
+cmd_ddp_info_parsed(
+ void *parsed_result,
+ __attribute__((unused)) struct cmdline *cl,
+ __attribute__((unused)) void *data)
+{
+ struct cmd_ddp_info_result *res = parsed_result;
+ uint8_t *pkg;
+ uint32_t pkg_size;
+ int ret = -ENOTSUP;
+#ifdef RTE_LIBRTE_I40E_PMD
+ uint32_t i;
+ uint8_t *buff;
+ uint32_t buff_size;
+ struct rte_pmd_i40e_profile_info info;
+ uint32_t dev_num;
+ struct rte_pmd_i40e_ddp_device_id *devs;
+#endif
+
+ pkg = open_ddp_package_file(res->filepath, &pkg_size);
+ if (!pkg)
+ return;
+
+#ifdef RTE_LIBRTE_I40E_PMD
+ ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
+ (uint8_t *)&info, sizeof(info),
+ RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
+ if (!ret) {
+ printf("Global Track id: 0x%x\n", info.track_id);
+ printf("Global Version: %d.%d.%d.%d\n",
+ info.version.major,
+ info.version.minor,
+ info.version.update,
+ info.version.draft);
+ printf("Global Package name: %s\n\n", info.name);
+ }
+
+ ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
+ (uint8_t *)&info, sizeof(info),
+ RTE_PMD_I40E_PKG_INFO_HEADER);
+ if (!ret) {
+ printf("i40e Profile Track id: 0x%x\n", info.track_id);
+ printf("i40e Profile Version: %d.%d.%d.%d\n",
+ info.version.major,
+ info.version.minor,
+ info.version.update,
+ info.version.draft);
+ printf("i40e Profile name: %s\n\n", info.name);
+ }
+
+ ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
+ (uint8_t *)&buff_size, sizeof(buff_size),
+ RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
+ if (!ret && buff_size) {
+ buff = (uint8_t *)malloc(buff_size);
+ if (buff) {
+ ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
+ buff, buff_size,
+ RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
+ if (!ret)
+ printf("Package Notes:\n%s\n\n", buff);
+ free(buff);
+ }
+ }
+
+ ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
+ (uint8_t *)&dev_num, sizeof(dev_num),
+ RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
+ if (!ret && dev_num) {
+ devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(dev_num *
+ sizeof(struct rte_pmd_i40e_ddp_device_id));
+ if (devs) {
+ ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
+ (uint8_t *)devs, dev_num *
+ sizeof(struct rte_pmd_i40e_ddp_device_id),
+ RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
+ if (!ret) {
+ printf("List of supported devices:\n");
+ for (i = 0; i < dev_num; i++) {
+ printf(" %04X:%04X %04X:%04X\n",
+ devs[i].vendor_dev_id >> 16,
+ devs[i].vendor_dev_id & 0xFFFF,
+ devs[i].sub_vendor_dev_id >> 16,
+ devs[i].sub_vendor_dev_id & 0xFFFF);
+ }
+ printf("\n");
+ }
+ free(devs);
+ }
+ }
+ ret = 0;
+#endif
+ if (ret == -ENOTSUP)
+ printf("Function not supported in PMD driver\n");
+ close_ddp_package_file(pkg);
+}
+
+cmdline_parse_inst_t cmd_ddp_get_info = {
+ .f = cmd_ddp_info_parsed,
+ .data = NULL,
+ .help_str = "ddp get info <profile_path>",
+ .tokens = {
+ (void *)&cmd_ddp_info_ddp,
+ (void *)&cmd_ddp_info_get,
+ (void *)&cmd_ddp_info_info,
+ (void *)&cmd_ddp_info_filepath,
+ NULL,
+ },
+};
+
/* Get dynamic device personalization profile info list*/
#define PROFILE_INFO_SIZE 48
#define MAX_PROFILE_NUM 16
@@ -13748,6 +13878,7 @@ cmdline_parse_ctx_t main_ctx[] = {
(cmdline_parse_inst_t *)&cmd_tc_min_bw,
(cmdline_parse_inst_t *)&cmd_ddp_add,
(cmdline_parse_inst_t *)&cmd_ddp_get_list,
+ (cmdline_parse_inst_t *)&cmd_ddp_get_info,
(cmdline_parse_inst_t *)&cmd_show_vf_stats,
(cmdline_parse_inst_t *)&cmd_clear_vf_stats,
(cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
--
2.13.0
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [dpdk-dev] [PATCH v2 0/2] net/i40e: get information about ddp profile
2017-06-12 20:00 ` [dpdk-dev] [PATCH v2 0/2] " Andrey Chilikin
@ 2017-06-14 5:51 ` Xing, Beilei
0 siblings, 0 replies; 13+ messages in thread
From: Xing, Beilei @ 2017-06-14 5:51 UTC (permalink / raw)
To: Chilikin, Andrey, dev; +Cc: Wu, Jingjing
Hi,
> -----Original Message-----
> From: Chilikin, Andrey
> Sent: Tuesday, June 13, 2017 4:00 AM
> To: dev@dpdk.org
> Cc: Xing, Beilei <beilei.xing@intel.com>; Wu, Jingjing <jingjing.wu@intel.com>;
> Chilikin, Andrey <andrey.chilikin@intel.com>
> Subject: [PATCH v2 0/2] net/i40e: get information about ddp profile
>
> This patch adds ability to request information about dynamic device
> personalization profile
>
> v2:
> Add rte_pmd_i40e_get_ddp_info() function to i40e version map Add CL to
> test-pmd for getting information about profile
>
> Andrey Chilikin (2):
> net/i40e: get information about ddp profile
> app/testpmd: enable ddp get info feature
>
> app/test-pmd/cmdline.c | 131
> ++++++++++++++++++++++++
> drivers/net/i40e/rte_pmd_i40e.c | 163
> +++++++++++++++++++++++++++++-
> drivers/net/i40e/rte_pmd_i40e.h | 46 +++++++++
> drivers/net/i40e/rte_pmd_i40e_version.map | 7 ++
> 4 files changed, 343 insertions(+), 4 deletions(-)
>
> --
> 2.13.0
Acked-by: Beilei Xing <beilei.xing@intel.com>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [dpdk-dev] [PATCH v2 2/2] app/testpmd: enable ddp get info feature
2017-06-12 20:00 ` [dpdk-dev] [PATCH v2 2/2] app/testpmd: enable ddp get info feature Andrey Chilikin
@ 2017-06-15 10:09 ` Ferruh Yigit
0 siblings, 0 replies; 13+ messages in thread
From: Ferruh Yigit @ 2017-06-15 10:09 UTC (permalink / raw)
To: Andrey Chilikin, dev; +Cc: beilei.xing, jingjing.wu
On 6/12/2017 9:00 PM, Andrey Chilikin wrote:
> This patch demostrates how to get information about dynamic device
> personalization profile.
> Command 'ddp get info (profile_path)' extracts and prints
> information about the given profile.
>
> Signed-off-by: Andrey Chilikin <andrey.chilikin@intel.com>
> ---
> app/test-pmd/cmdline.c | 131 +++++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 131 insertions(+)
Hi Andrey,
Can you please update testpmd documentation [1] to document new command.
Hi Beilei,
I just recognized previous ddp testpmd commands are not documented, can
you please send a separate patch to document them?
Thanks,
ferruh
[1]
doc/guides/testpmd_app_ug/testpmd_funcs.rst
^ permalink raw reply [flat|nested] 13+ messages in thread
* [dpdk-dev] [PATCH v3 0/3] net/i40e: get information about ddp profile
2017-05-26 12:41 [dpdk-dev] [PATCH] net/i40e: get information about ddp profile Andrey Chilikin
` (3 preceding siblings ...)
2017-06-12 20:00 ` [dpdk-dev] [PATCH v2 2/2] app/testpmd: enable ddp get info feature Andrey Chilikin
@ 2017-06-16 9:25 ` Andrey Chilikin
2017-06-16 12:25 ` Ferruh Yigit
2017-06-16 9:25 ` [dpdk-dev] [PATCH v3 1/3] " Andrey Chilikin
` (2 subsequent siblings)
7 siblings, 1 reply; 13+ messages in thread
From: Andrey Chilikin @ 2017-06-16 9:25 UTC (permalink / raw)
To: dev; +Cc: beilei.xing, jingjing.wu, Andrey Chilikin
This patch adds ability to request information about dynamic device
personalization profile
v3:
Add command description to test-pmd guide
v2:
Add rte_pmd_i40e_get_ddp_info() function to i40e version map
Add CL to test-pmd for getting information about profile
Andrey Chilikin (3):
net/i40e: get information about ddp profile
app/testpmd: enable ddp get info feature
doc: add new ddp get info command
app/test-pmd/cmdline.c | 131 ++++++++++++++++++++++
doc/guides/testpmd_app_ug/testpmd_funcs.rst | 7 ++
drivers/net/i40e/rte_pmd_i40e.c | 163 +++++++++++++++++++++++++++-
drivers/net/i40e/rte_pmd_i40e.h | 46 ++++++++
drivers/net/i40e/rte_pmd_i40e_version.map | 7 ++
5 files changed, 350 insertions(+), 4 deletions(-)
--
2.13.0
Acked-by: Beilei Xing <beilei.xing@intel.com>
^ permalink raw reply [flat|nested] 13+ messages in thread
* [dpdk-dev] [PATCH v3 1/3] net/i40e: get information about ddp profile
2017-05-26 12:41 [dpdk-dev] [PATCH] net/i40e: get information about ddp profile Andrey Chilikin
` (4 preceding siblings ...)
2017-06-16 9:25 ` [dpdk-dev] [PATCH v3 0/3] net/i40e: get information about ddp profile Andrey Chilikin
@ 2017-06-16 9:25 ` Andrey Chilikin
2017-06-16 9:25 ` [dpdk-dev] [PATCH v3 2/3] app/testpmd: enable ddp get info feature Andrey Chilikin
2017-06-16 9:25 ` [dpdk-dev] [PATCH v3 3/3] doc: add new ddp get info command Andrey Chilikin
7 siblings, 0 replies; 13+ messages in thread
From: Andrey Chilikin @ 2017-06-16 9:25 UTC (permalink / raw)
To: dev; +Cc: beilei.xing, jingjing.wu, Andrey Chilikin
This patch adds ability to request information about dynamic device
personalization profile
Signed-off-by: Andrey Chilikin <andrey.chilikin@intel.com>
---
drivers/net/i40e/rte_pmd_i40e.c | 163 +++++++++++++++++++++++++++++-
drivers/net/i40e/rte_pmd_i40e.h | 46 +++++++++
drivers/net/i40e/rte_pmd_i40e_version.map | 7 ++
3 files changed, 212 insertions(+), 4 deletions(-)
diff --git a/drivers/net/i40e/rte_pmd_i40e.c b/drivers/net/i40e/rte_pmd_i40e.c
index f7ce62bb5..45cdcfaa3 100644
--- a/drivers/net/i40e/rte_pmd_i40e.c
+++ b/drivers/net/i40e/rte_pmd_i40e.c
@@ -1468,7 +1468,7 @@ rte_pmd_i40e_set_tc_strict_prio(uint8_t port, uint8_t tc_map)
return ret;
}
-#define I40E_PROFILE_INFO_SIZE 48
+#define I40E_PROFILE_INFO_SIZE sizeof(struct rte_pmd_i40e_profile_info)
#define I40E_MAX_PROFILE_NUM 16
static void
@@ -1520,9 +1520,6 @@ i40e_add_rm_profile_info(struct i40e_hw *hw, uint8_t *profile_info_sec)
return status;
}
-#define I40E_PROFILE_INFO_SIZE 48
-#define I40E_MAX_PROFILE_NUM 16
-
/* Check if the profile info exists */
static int
i40e_check_profile_info(uint8_t port, uint8_t *profile_info_sec)
@@ -1682,6 +1679,164 @@ rte_pmd_i40e_process_ddp_package(uint8_t port, uint8_t *buff,
return status;
}
+int rte_pmd_i40e_get_ddp_info(uint8_t *pkg_buff, uint32_t pkg_size,
+ uint8_t *info_buff, uint32_t info_size,
+ enum rte_pmd_i40e_package_info type)
+{
+ uint32_t ret_size;
+ struct i40e_package_header *pkg_hdr;
+ struct i40e_generic_seg_header *i40e_seg_hdr;
+ struct i40e_generic_seg_header *note_seg_hdr;
+ struct i40e_generic_seg_header *metadata_seg_hdr;
+
+ if (!info_buff) {
+ PMD_DRV_LOG(ERR, "Output info buff is invalid.");
+ return -EINVAL;
+ }
+
+ if (!pkg_buff || pkg_size < (sizeof(struct i40e_package_header) +
+ sizeof(struct i40e_metadata_segment) +
+ sizeof(uint32_t) * 2)) {
+ PMD_DRV_LOG(ERR, "Package buff is invalid.");
+ return -EINVAL;
+ }
+
+ pkg_hdr = (struct i40e_package_header *)pkg_buff;
+ if (pkg_hdr->segment_count < 2) {
+ PMD_DRV_LOG(ERR, "Segment_count should be 2 at least.");
+ return -EINVAL;
+ }
+
+ /* Find metadata segment */
+ metadata_seg_hdr = i40e_find_segment_in_package(SEGMENT_TYPE_METADATA,
+ pkg_hdr);
+
+ /* Find global notes segment */
+ note_seg_hdr = i40e_find_segment_in_package(SEGMENT_TYPE_NOTES,
+ pkg_hdr);
+
+ /* Find i40e profile segment */
+ i40e_seg_hdr = i40e_find_segment_in_package(SEGMENT_TYPE_I40E, pkg_hdr);
+
+ /* get global header info */
+ if (type == RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER) {
+ struct rte_pmd_i40e_profile_info *info =
+ (struct rte_pmd_i40e_profile_info *)info_buff;
+
+ if (info_size < sizeof(struct rte_pmd_i40e_profile_info)) {
+ PMD_DRV_LOG(ERR, "Output info buff size is invalid.");
+ return -EINVAL;
+ }
+
+ if (!metadata_seg_hdr) {
+ PMD_DRV_LOG(ERR, "Failed to find metadata segment header");
+ return -EINVAL;
+ }
+
+ memset(info, 0, sizeof(struct rte_pmd_i40e_profile_info));
+ info->owner = RTE_PMD_I40E_DDP_OWNER_UNKNOWN;
+ info->track_id =
+ ((struct i40e_metadata_segment *)metadata_seg_hdr)->track_id;
+
+ memcpy(info->name,
+ ((struct i40e_metadata_segment *)metadata_seg_hdr)->name,
+ I40E_DDP_NAME_SIZE);
+ memcpy(&info->version,
+ &((struct i40e_metadata_segment *)metadata_seg_hdr)->version,
+ sizeof(struct i40e_ddp_version));
+ return I40E_SUCCESS;
+ }
+
+ /* get global note size */
+ if (type == RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE) {
+ if (info_size < sizeof(uint32_t)) {
+ PMD_DRV_LOG(ERR, "Invalid information buffer size");
+ return -EINVAL;
+ }
+ if (note_seg_hdr == NULL)
+ ret_size = 0;
+ else
+ ret_size = note_seg_hdr->size;
+ *(uint32_t *)info_buff = ret_size;
+ return I40E_SUCCESS;
+ }
+
+ /* get global note */
+ if (type == RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES) {
+ if (note_seg_hdr == NULL)
+ return -ENOTSUP;
+ if (info_size < note_seg_hdr->size) {
+ PMD_DRV_LOG(ERR, "Information buffer size is too small");
+ return -EINVAL;
+ }
+ memcpy(info_buff, ¬e_seg_hdr[1], note_seg_hdr->size);
+ return I40E_SUCCESS;
+ }
+
+ /* get i40e segment header info */
+ if (type == RTE_PMD_I40E_PKG_INFO_HEADER) {
+ struct rte_pmd_i40e_profile_info *info =
+ (struct rte_pmd_i40e_profile_info *)info_buff;
+
+ if (info_size < sizeof(struct rte_pmd_i40e_profile_info)) {
+ PMD_DRV_LOG(ERR, "Output info buff size is invalid.");
+ return -EINVAL;
+ }
+
+ if (!metadata_seg_hdr) {
+ PMD_DRV_LOG(ERR, "Failed to find metadata segment header");
+ return -EINVAL;
+ }
+
+ if (!i40e_seg_hdr) {
+ PMD_DRV_LOG(ERR, "Failed to find i40e segment header");
+ return -EINVAL;
+ }
+
+ memset(info, 0, sizeof(struct rte_pmd_i40e_profile_info));
+ info->owner = RTE_PMD_I40E_DDP_OWNER_UNKNOWN;
+ info->track_id =
+ ((struct i40e_metadata_segment *)metadata_seg_hdr)->track_id;
+
+ memcpy(info->name,
+ ((struct i40e_profile_segment *)i40e_seg_hdr)->name,
+ I40E_DDP_NAME_SIZE);
+ memcpy(&info->version,
+ &((struct i40e_profile_segment *)i40e_seg_hdr)->version,
+ sizeof(struct i40e_ddp_version));
+ return I40E_SUCCESS;
+ }
+
+ /* get number of devices */
+ if (type == RTE_PMD_I40E_PKG_INFO_DEVID_NUM) {
+ if (info_size < sizeof(uint32_t)) {
+ PMD_DRV_LOG(ERR, "Invalid information buffer size");
+ return -EINVAL;
+ }
+ *(uint32_t *)info_buff =
+ ((struct i40e_profile_segment *)i40e_seg_hdr)->device_table_count;
+ return I40E_SUCCESS;
+ }
+
+ /* get list of devices */
+ if (type == RTE_PMD_I40E_PKG_INFO_DEVID_LIST) {
+ uint32_t dev_num;
+ dev_num =
+ ((struct i40e_profile_segment *)i40e_seg_hdr)->device_table_count;
+ if (info_size < sizeof(struct rte_pmd_i40e_ddp_device_id) * dev_num) {
+ PMD_DRV_LOG(ERR, "Invalid information buffer size");
+ return -EINVAL;
+ }
+ memcpy(info_buff,
+ ((struct i40e_profile_segment *)i40e_seg_hdr)->device_table,
+ sizeof(struct rte_pmd_i40e_ddp_device_id) * dev_num);
+ return I40E_SUCCESS;
+ }
+
+ PMD_DRV_LOG(ERR, "Info type %u is invalid.", type);
+ return -EINVAL;
+}
+
int
rte_pmd_i40e_get_ddp_list(uint8_t port, uint8_t *buff, uint32_t size)
{
diff --git a/drivers/net/i40e/rte_pmd_i40e.h b/drivers/net/i40e/rte_pmd_i40e.h
index 1efb2c4bf..11adfd0f9 100644
--- a/drivers/net/i40e/rte_pmd_i40e.h
+++ b/drivers/net/i40e/rte_pmd_i40e.h
@@ -74,6 +74,21 @@ enum rte_pmd_i40e_package_op {
RTE_PMD_I40E_PKG_OP_MAX = 32
};
+/**
+ * Types of package information.
+ */
+enum rte_pmd_i40e_package_info {
+ RTE_PMD_I40E_PKG_INFO_UNDEFINED = 0,
+ RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER,
+ RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE,
+ RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES,
+ RTE_PMD_I40E_PKG_INFO_GLOBAL_MAX = 1024,
+ RTE_PMD_I40E_PKG_INFO_HEADER,
+ RTE_PMD_I40E_PKG_INFO_DEVID_NUM,
+ RTE_PMD_I40E_PKG_INFO_DEVID_LIST,
+ RTE_PMD_I40E_PKG_INFO_MAX = 0xFFFFFFFF
+};
+
#define RTE_PMD_I40E_DDP_NAME_SIZE 32
/**
@@ -88,6 +103,14 @@ struct rte_pmd_i40e_ddp_version {
};
/**
+ * Device ID for dynamic device personalization.
+ */
+struct rte_pmd_i40e_ddp_device_id {
+ uint32_t vendor_dev_id;
+ uint32_t sub_vendor_dev_id;
+};
+
+/**
* Profile information in profile info list.
*/
struct rte_pmd_i40e_profile_info {
@@ -98,6 +121,8 @@ struct rte_pmd_i40e_profile_info {
uint8_t name[RTE_PMD_I40E_DDP_NAME_SIZE];
};
+#define RTE_PMD_I40E_DDP_OWNER_UNKNOWN 0xFF
+
/**
* Profile information list returned from HW.
*/
@@ -499,6 +524,27 @@ int rte_pmd_i40e_process_ddp_package(uint8_t port, uint8_t *buff,
enum rte_pmd_i40e_package_op op);
/**
+ * rte_pmd_i40e_get_ddp_info - Get profile's info
+ * @param pkg
+ * buffer of package.
+ * @param pkg_size
+ * package buffer size
+ * @param info
+ * buffer for response
+ * @param size
+ * response buffer size
+ * @param type
+ * type of information requested
+ * @return
+ * - (0) if successful.
+ * - (-ENOTSUP) if information type not supported by the profile.
+ * - (-EINVAL) if bad parameter.
+ */
+int rte_pmd_i40e_get_ddp_info(uint8_t *pkg, uint32_t pkg_size,
+ uint8_t *info, uint32_t size,
+ enum rte_pmd_i40e_package_info type);
+
+/**
* rte_pmd_i40e_get_ddp_list - Get loaded profile list
* @param port
* port id
diff --git a/drivers/net/i40e/rte_pmd_i40e_version.map b/drivers/net/i40e/rte_pmd_i40e_version.map
index 3b0e805df..20cc9801a 100644
--- a/drivers/net/i40e/rte_pmd_i40e_version.map
+++ b/drivers/net/i40e/rte_pmd_i40e_version.map
@@ -38,3 +38,10 @@ DPDK_17.05 {
rte_pmd_i40e_get_ddp_list;
} DPDK_17.02;
+
+DPDK_17.08 {
+ global:
+
+ rte_pmd_i40e_get_ddp_info;
+
+} DPDK_17.05;
--
2.13.0
^ permalink raw reply [flat|nested] 13+ messages in thread
* [dpdk-dev] [PATCH v3 2/3] app/testpmd: enable ddp get info feature
2017-05-26 12:41 [dpdk-dev] [PATCH] net/i40e: get information about ddp profile Andrey Chilikin
` (5 preceding siblings ...)
2017-06-16 9:25 ` [dpdk-dev] [PATCH v3 1/3] " Andrey Chilikin
@ 2017-06-16 9:25 ` Andrey Chilikin
2017-06-16 9:25 ` [dpdk-dev] [PATCH v3 3/3] doc: add new ddp get info command Andrey Chilikin
7 siblings, 0 replies; 13+ messages in thread
From: Andrey Chilikin @ 2017-06-16 9:25 UTC (permalink / raw)
To: dev; +Cc: beilei.xing, jingjing.wu, Andrey Chilikin
This patch demostrates how to get information about dynamic device
personalization profile. Command 'ddp get info (path_to_profile)'
extracts and prints information about the given profile.
Signed-off-by: Andrey Chilikin <andrey.chilikin@intel.com>
---
app/test-pmd/cmdline.c | 131 +++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 131 insertions(+)
diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 0afac68c7..9e7858901 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -218,6 +218,9 @@ static void cmd_help_long_parsed(void *parsed_result,
"ddp get list (port_id)\n"
" Get ddp profile info list\n\n"
+ "ddp get info (profile_path)\n"
+ " Get ddp profile information.\n\n"
+
"show vf stats (port_id) (vf_id)\n"
" Display a VF's statistics.\n\n"
@@ -12904,6 +12907,133 @@ cmdline_parse_inst_t cmd_ddp_add = {
},
};
+/* Get dynamic device personalization profile info */
+struct cmd_ddp_info_result {
+ cmdline_fixed_string_t ddp;
+ cmdline_fixed_string_t get;
+ cmdline_fixed_string_t info;
+ char filepath[];
+};
+
+cmdline_parse_token_string_t cmd_ddp_info_ddp =
+ TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
+cmdline_parse_token_string_t cmd_ddp_info_get =
+ TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
+cmdline_parse_token_string_t cmd_ddp_info_info =
+ TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
+cmdline_parse_token_string_t cmd_ddp_info_filepath =
+ TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
+
+static void
+cmd_ddp_info_parsed(
+ void *parsed_result,
+ __attribute__((unused)) struct cmdline *cl,
+ __attribute__((unused)) void *data)
+{
+ struct cmd_ddp_info_result *res = parsed_result;
+ uint8_t *pkg;
+ uint32_t pkg_size;
+ int ret = -ENOTSUP;
+#ifdef RTE_LIBRTE_I40E_PMD
+ uint32_t i;
+ uint8_t *buff;
+ uint32_t buff_size;
+ struct rte_pmd_i40e_profile_info info;
+ uint32_t dev_num;
+ struct rte_pmd_i40e_ddp_device_id *devs;
+#endif
+
+ pkg = open_ddp_package_file(res->filepath, &pkg_size);
+ if (!pkg)
+ return;
+
+#ifdef RTE_LIBRTE_I40E_PMD
+ ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
+ (uint8_t *)&info, sizeof(info),
+ RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
+ if (!ret) {
+ printf("Global Track id: 0x%x\n", info.track_id);
+ printf("Global Version: %d.%d.%d.%d\n",
+ info.version.major,
+ info.version.minor,
+ info.version.update,
+ info.version.draft);
+ printf("Global Package name: %s\n\n", info.name);
+ }
+
+ ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
+ (uint8_t *)&info, sizeof(info),
+ RTE_PMD_I40E_PKG_INFO_HEADER);
+ if (!ret) {
+ printf("i40e Profile Track id: 0x%x\n", info.track_id);
+ printf("i40e Profile Version: %d.%d.%d.%d\n",
+ info.version.major,
+ info.version.minor,
+ info.version.update,
+ info.version.draft);
+ printf("i40e Profile name: %s\n\n", info.name);
+ }
+
+ ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
+ (uint8_t *)&buff_size, sizeof(buff_size),
+ RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
+ if (!ret && buff_size) {
+ buff = (uint8_t *)malloc(buff_size);
+ if (buff) {
+ ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
+ buff, buff_size,
+ RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
+ if (!ret)
+ printf("Package Notes:\n%s\n\n", buff);
+ free(buff);
+ }
+ }
+
+ ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
+ (uint8_t *)&dev_num, sizeof(dev_num),
+ RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
+ if (!ret && dev_num) {
+ devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(dev_num *
+ sizeof(struct rte_pmd_i40e_ddp_device_id));
+ if (devs) {
+ ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
+ (uint8_t *)devs, dev_num *
+ sizeof(struct rte_pmd_i40e_ddp_device_id),
+ RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
+ if (!ret) {
+ printf("List of supported devices:\n");
+ for (i = 0; i < dev_num; i++) {
+ printf(" %04X:%04X %04X:%04X\n",
+ devs[i].vendor_dev_id >> 16,
+ devs[i].vendor_dev_id & 0xFFFF,
+ devs[i].sub_vendor_dev_id >> 16,
+ devs[i].sub_vendor_dev_id & 0xFFFF);
+ }
+ printf("\n");
+ }
+ free(devs);
+ }
+ }
+ ret = 0;
+#endif
+ if (ret == -ENOTSUP)
+ printf("Function not supported in PMD driver\n");
+ close_ddp_package_file(pkg);
+}
+
+cmdline_parse_inst_t cmd_ddp_get_info = {
+ .f = cmd_ddp_info_parsed,
+ .data = NULL,
+ .help_str = "ddp get info <profile_path>",
+ .tokens = {
+ (void *)&cmd_ddp_info_ddp,
+ (void *)&cmd_ddp_info_get,
+ (void *)&cmd_ddp_info_info,
+ (void *)&cmd_ddp_info_filepath,
+ NULL,
+ },
+};
+
/* Get dynamic device personalization profile info list*/
#define PROFILE_INFO_SIZE 48
#define MAX_PROFILE_NUM 16
@@ -13748,6 +13878,7 @@ cmdline_parse_ctx_t main_ctx[] = {
(cmdline_parse_inst_t *)&cmd_tc_min_bw,
(cmdline_parse_inst_t *)&cmd_ddp_add,
(cmdline_parse_inst_t *)&cmd_ddp_get_list,
+ (cmdline_parse_inst_t *)&cmd_ddp_get_info,
(cmdline_parse_inst_t *)&cmd_show_vf_stats,
(cmdline_parse_inst_t *)&cmd_clear_vf_stats,
(cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
--
2.13.0
^ permalink raw reply [flat|nested] 13+ messages in thread
* [dpdk-dev] [PATCH v3 3/3] doc: add new ddp get info command
2017-05-26 12:41 [dpdk-dev] [PATCH] net/i40e: get information about ddp profile Andrey Chilikin
` (6 preceding siblings ...)
2017-06-16 9:25 ` [dpdk-dev] [PATCH v3 2/3] app/testpmd: enable ddp get info feature Andrey Chilikin
@ 2017-06-16 9:25 ` Andrey Chilikin
7 siblings, 0 replies; 13+ messages in thread
From: Andrey Chilikin @ 2017-06-16 9:25 UTC (permalink / raw)
To: dev; +Cc: beilei.xing, jingjing.wu, Andrey Chilikin
This patch adds description of new command for dynamic device
personalization profiles: ddp get info (profile_path)
Signed-off-by: Andrey Chilikin <andrey.chilikin@intel.com>
---
doc/guides/testpmd_app_ug/testpmd_funcs.rst | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
index 0e50c1071..c982cd895 100644
--- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
+++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
@@ -380,6 +380,13 @@ For example::
testpmd> read txd 0 0 4
0x00000001 - 0x24C3C440 / 0x000F0000 - 0x2330003C
+ddp get info
+~~~~~~~~~~~~
+
+Display information about dynamic device personalization profile::
+
+ testpmd> ddp get info (profile_patch)
+
show vf stats
~~~~~~~~~~~~~
--
2.13.0
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [dpdk-dev] [PATCH v3 0/3] net/i40e: get information about ddp profile
2017-06-16 9:25 ` [dpdk-dev] [PATCH v3 0/3] net/i40e: get information about ddp profile Andrey Chilikin
@ 2017-06-16 12:25 ` Ferruh Yigit
0 siblings, 0 replies; 13+ messages in thread
From: Ferruh Yigit @ 2017-06-16 12:25 UTC (permalink / raw)
To: Andrey Chilikin, dev; +Cc: beilei.xing, jingjing.wu
On 6/16/2017 10:25 AM, Andrey Chilikin wrote:
> This patch adds ability to request information about dynamic device
> personalization profile
>
> v3:
> Add command description to test-pmd guide
>
> v2:
> Add rte_pmd_i40e_get_ddp_info() function to i40e version map
> Add CL to test-pmd for getting information about profile
>
> Andrey Chilikin (3):
> net/i40e: get information about ddp profile
> app/testpmd: enable ddp get info feature
> doc: add new ddp get info command
Series applied to dpdk-next-net/master, thanks.
- Kept ACK from Beilei
- Merged 3/3 into 2/3
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2017-06-16 12:25 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-26 12:41 [dpdk-dev] [PATCH] net/i40e: get information about ddp profile Andrey Chilikin
2017-06-01 2:21 ` Xing, Beilei
2017-06-01 10:17 ` Chilikin, Andrey
2017-06-12 20:00 ` [dpdk-dev] [PATCH v2 0/2] " Andrey Chilikin
2017-06-14 5:51 ` Xing, Beilei
2017-06-12 20:00 ` [dpdk-dev] [PATCH v2 1/2] " Andrey Chilikin
2017-06-12 20:00 ` [dpdk-dev] [PATCH v2 2/2] app/testpmd: enable ddp get info feature Andrey Chilikin
2017-06-15 10:09 ` Ferruh Yigit
2017-06-16 9:25 ` [dpdk-dev] [PATCH v3 0/3] net/i40e: get information about ddp profile Andrey Chilikin
2017-06-16 12:25 ` Ferruh Yigit
2017-06-16 9:25 ` [dpdk-dev] [PATCH v3 1/3] " Andrey Chilikin
2017-06-16 9:25 ` [dpdk-dev] [PATCH v3 2/3] app/testpmd: enable ddp get info feature Andrey Chilikin
2017-06-16 9:25 ` [dpdk-dev] [PATCH v3 3/3] doc: add new ddp get info command Andrey Chilikin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).