[PATCH v5 3/3] ring: add telemetry cmd for ring info
Morten Brørup
mb at smartsharesystems.com
Tue May 9 08:50:27 CEST 2023
> From: Jie Hai [mailto:haijie1 at huawei.com]
> Sent: Tuesday, 9 May 2023 03.29
>
> This patch supports dump of ring information by its name.
> An example using this command is shown below:
>
> --> /ring/info,MP_mb_pool_0
> {
> "/ring/info": {
> "name": "MP_mb_pool_0",
> "socket": 0,
> "flags": "0x0",
> "producer_type": "MP",
> "consumer_type": "MC",
> "size": 262144,
> "mask": "0x3ffff",
> "capacity": 262143,
> "used_count": 153197,
> "consumer_tail": 2259,
> "consumer_head": 2259,
> "producer_tail": 155456,
> "producer_head": 155456,
> "mz_name": "RG_MP_mb_pool_0",
> "mz_len": 2097536,
> "mz_hugepage_sz": 1073741824,
> "mz_socket_id": 0,
> "mz_flags": "0x0"
> }
> }
>
> Signed-off-by: Jie Hai <haijie1 at huawei.com>
> Reviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli at arm.com>
> Acked-by: Konstantin Ananyev <konstantin.v.ananyev at yandex.ru>
> Acked-by: Huisong Li <lihuisong at huawei.com>
> Acked-by: Chengwen Feng <fengchengwen at huawei.com>
> ---
> lib/ring/rte_ring.c | 99 +++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 99 insertions(+)
>
> diff --git a/lib/ring/rte_ring.c b/lib/ring/rte_ring.c
> index 0e83d0099363..26c8f2a2e6a2 100644
> --- a/lib/ring/rte_ring.c
> +++ b/lib/ring/rte_ring.c
> @@ -455,8 +455,107 @@ ring_handle_list(const char *cmd __rte_unused,
> return 0;
> }
>
> +static const char *
> +ring_prod_sync_type_to_name(struct rte_ring *r)
> +{
> + switch (r->prod.sync_type) {
> + case RTE_RING_SYNC_MT:
> + return "MP";
> + case RTE_RING_SYNC_ST:
> + return "SP";
> + case RTE_RING_SYNC_MT_RTS:
> + return "MP_RTS";
> + case RTE_RING_SYNC_MT_HTS:
> + return "MP_HTS";
> + default:
> + return "Unknown";
> + }
> +}
> +
> +static const char *
> +ring_cons_sync_type_to_name(struct rte_ring *r)
> +{
> + switch (r->cons.sync_type) {
> + case RTE_RING_SYNC_MT:
> + return "MC";
> + case RTE_RING_SYNC_ST:
> + return "SC";
> + case RTE_RING_SYNC_MT_RTS:
> + return "MC_RTS";
> + case RTE_RING_SYNC_MT_HTS:
> + return "MC_HTS";
> + default:
> + return "Unknown";
> + }
> +}
I considered if these two functions should be replaced by one, returning e.g. "MT" instead of "MP"/"MC"; however, the ring flags describe the sync types as e.g. "MP" and "MP RTS", so I eventually came to agree with the approach in the patch.
The structure documentation requires that the sync_type field must be in the same position, regardless which of the union's types are being used. So this is also correct.
Series-Acked-by: Morten Brørup <mb at smartsharesystems.com>
More information about the dev
mailing list