examples/vdpa: support show protocol features

Message ID 20251030065715.47304-1-fengchengwen@huawei.com (mailing list archive)
State New
Delegated to: Maxime Coquelin
Headers
Series examples/vdpa: support show protocol features |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/intel-Functional success Functional PASS
ci/github-robot: build fail github build: failed
ci/aws-unit-testing success Unit Testing PASS

Commit Message

fengchengwen Oct. 30, 2025, 6:57 a.m. UTC
This commit adds show device's protocol features in list command.

Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
 doc/guides/sample_app_ug/vdpa.rst |  8 ++++----
 examples/vdpa/main.c              | 13 ++++++++++---
 2 files changed, 14 insertions(+), 7 deletions(-)
  

Comments

fengchengwen Nov. 6, 2025, 12:37 a.m. UTC | #1
ping for review / upstream

On 10/30/2025 2:57 PM, Chengwen Feng wrote:
> This commit adds show device's protocol features in list command.
> 
> Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
> ---
>  doc/guides/sample_app_ug/vdpa.rst |  8 ++++----
>  examples/vdpa/main.c              | 13 ++++++++++---
>  2 files changed, 14 insertions(+), 7 deletions(-)
> 
> diff --git a/doc/guides/sample_app_ug/vdpa.rst b/doc/guides/sample_app_ug/vdpa.rst
> index cd3ec99054..873efbf7c7 100644
> --- a/doc/guides/sample_app_ug/vdpa.rst
> +++ b/doc/guides/sample_app_ug/vdpa.rst
> @@ -70,10 +70,10 @@ Then we can create 2 vdpa ports in interactive cmdline.
>  .. code-block:: console
>  
>          vdpa> list
> -        device id       device address  queue num       supported features
> -        0               0000:06:00.3    1               0x14c238020
> -        1               0000:06:00.4    1               0x14c238020
> -        2               0000:06:00.5    1               0x14c238020
> +        device id       device address  queue num       supported features      supported protocol features
> +        0               0000:06:00.3    1               0x14c238020             0x10c33
> +        1               0000:06:00.4    1               0x14c238020             0x10c33
> +        2               0000:06:00.5    1               0x14c238020             0x10c33
>  
>          vdpa> create /tmp/vdpa-socket0 0000:06:00.3
>          vdpa> create /tmp/vdpa-socket1 0000:06:00.4
> diff --git a/examples/vdpa/main.c b/examples/vdpa/main.c
> index 289db26498..505e563a57 100644
> --- a/examples/vdpa/main.c
> +++ b/examples/vdpa/main.c
> @@ -324,11 +324,12 @@ void cmd_list_parsed(
>  {
>  	uint32_t queue_num;
>  	uint64_t features;
> +	uint64_t protocol_features;
>  	struct rte_vdpa_device *vdev;
>  	struct rte_device *dev;
>  	struct rte_dev_iterator dev_iter;
>  
> -	cmdline_printf(cl, "device name\tqueue num\tsupported features\n");
> +	cmdline_printf(cl, "device name\tqueue num\tsupported features\tsupported protocol features\n");
>  	RTE_DEV_FOREACH(dev, "class=vdpa", &dev_iter) {
>  		vdev = rte_vdpa_find_device_by_name(rte_dev_name(dev));
>  		if (!vdev)
> @@ -345,8 +346,14 @@ void cmd_list_parsed(
>  				"for device %s.\n", rte_dev_name(dev));
>  			continue;
>  		}
> -		cmdline_printf(cl, "%s\t\t%" PRIu32 "\t\t0x%" PRIx64 "\n",
> -			rte_dev_name(dev), queue_num, features);
> +		if (rte_vdpa_get_protocol_features(vdev, &protocol_features) < 0) {
> +			RTE_LOG(ERR, VDPA,
> +				"failed to get vdpa protocol features "
> +				"for device %s.\n", rte_dev_name(dev));
> +			continue;
> +		}
> +		cmdline_printf(cl, "%s\t\t%" PRIu32 "\t\t0x%" PRIx64 "\t\t0x%" PRIx64 "\n",
> +			rte_dev_name(dev), queue_num, features, protocol_features);
>  	}
>  }
>
  

Patch

diff --git a/doc/guides/sample_app_ug/vdpa.rst b/doc/guides/sample_app_ug/vdpa.rst
index cd3ec99054..873efbf7c7 100644
--- a/doc/guides/sample_app_ug/vdpa.rst
+++ b/doc/guides/sample_app_ug/vdpa.rst
@@ -70,10 +70,10 @@  Then we can create 2 vdpa ports in interactive cmdline.
 .. code-block:: console
 
         vdpa> list
-        device id       device address  queue num       supported features
-        0               0000:06:00.3    1               0x14c238020
-        1               0000:06:00.4    1               0x14c238020
-        2               0000:06:00.5    1               0x14c238020
+        device id       device address  queue num       supported features      supported protocol features
+        0               0000:06:00.3    1               0x14c238020             0x10c33
+        1               0000:06:00.4    1               0x14c238020             0x10c33
+        2               0000:06:00.5    1               0x14c238020             0x10c33
 
         vdpa> create /tmp/vdpa-socket0 0000:06:00.3
         vdpa> create /tmp/vdpa-socket1 0000:06:00.4
diff --git a/examples/vdpa/main.c b/examples/vdpa/main.c
index 289db26498..505e563a57 100644
--- a/examples/vdpa/main.c
+++ b/examples/vdpa/main.c
@@ -324,11 +324,12 @@  void cmd_list_parsed(
 {
 	uint32_t queue_num;
 	uint64_t features;
+	uint64_t protocol_features;
 	struct rte_vdpa_device *vdev;
 	struct rte_device *dev;
 	struct rte_dev_iterator dev_iter;
 
-	cmdline_printf(cl, "device name\tqueue num\tsupported features\n");
+	cmdline_printf(cl, "device name\tqueue num\tsupported features\tsupported protocol features\n");
 	RTE_DEV_FOREACH(dev, "class=vdpa", &dev_iter) {
 		vdev = rte_vdpa_find_device_by_name(rte_dev_name(dev));
 		if (!vdev)
@@ -345,8 +346,14 @@  void cmd_list_parsed(
 				"for device %s.\n", rte_dev_name(dev));
 			continue;
 		}
-		cmdline_printf(cl, "%s\t\t%" PRIu32 "\t\t0x%" PRIx64 "\n",
-			rte_dev_name(dev), queue_num, features);
+		if (rte_vdpa_get_protocol_features(vdev, &protocol_features) < 0) {
+			RTE_LOG(ERR, VDPA,
+				"failed to get vdpa protocol features "
+				"for device %s.\n", rte_dev_name(dev));
+			continue;
+		}
+		cmdline_printf(cl, "%s\t\t%" PRIu32 "\t\t0x%" PRIx64 "\t\t0x%" PRIx64 "\n",
+			rte_dev_name(dev), queue_num, features, protocol_features);
 	}
 }