CPU Enabling: Implement rte_power_monitor API in virtio/vhost PMD
cover CPU Enabling: Implement rte_power_monitor API in virtio/vhost PMD
This patchset implements rte_power_monitor API in virtio and vhost PMD to reduce power consumption when no packet come in. This API can be called and tested in l3fwd-power after adding vhost and virtio support in l3fwd-power and ignoring the rx queue information check in queue_stopped().
Miao Li (5):
net/virtio: implement rte_power_monitor API
lib/vhost: implement rte_power_monitor API
net/vhost: implement rte_power_monitor API
lib/power: modify return of queue_stopped
examples/l3fwd-power: support virtio/vhost
drivers/net/vhost/rte_eth_vhost.c | 46 ++++++++++++++++++++++++ drivers/net/virtio/virtio_ethdev.c | 57 ++++++++++++++++++++++++++++++ examples/l3fwd-power/main.c | 15 ++++++++ lib/power/rte_power_pmd_mgmt.c | 9 +++-- lib/vhost/rte_vhost.h | 33 +++++++++++++++++ lib/vhost/version.map | 3 ++ lib/vhost/vhost.c | 30 ++++++++++++++++ 7 files changed, 191 insertions(+), 2 deletions(-)
Signature · 1 line
2.25.1
PATCH 1/5 net/virtio: implement rte_power_monitor API
This patch implements rte_power_monitor API in virtio PMD to reduce power consumption when no packet come in. According to current semantics of power monitor, this commit adds a callback function to decide whether aborts the sleep by checking current value against the expected value and virtio_get_monitor_addr to provide address to monitor. When no packet come in, the value of address will not be changed and the running core will sleep. Once packets arrive, the value of address will be changed and the running core will wakeup.
--- drivers/net/virtio/virtio_ethdev.c | 57 ++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+)
drivers/net/virtio/virtio_ethdev.c +57 -0
@@ -73,6 +73,8 @@ static int virtio_mac_addr_set(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr);static int virtio_intr_disable (struct rte_eth_dev *dev); +static int virtio_get_monitor_addr (void *rx_queue, +struct rte_power_monitor_cond *pmc); static int virtio_dev_queue_stats_mapping_set( struct rte_eth_dev *eth_dev,
@@ -975,6 +977,7 @@ static const struct eth_dev_ops virtio_eth_dev_ops = { .mac_addr_add = virtio_mac_addr_add, .mac_addr_remove = virtio_mac_addr_remove, .mac_addr_set = virtio_mac_addr_set, + .get_monitor_addr = virtio_get_monitor_addr, };/*
@@ -1306,6 +1309,60 @@ virtio_mac_addr_set(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr)return 0 ; } +#define CLB_VAL_IDX 0 +#define CLB_MSK_IDX 1 +static int +virtio_packed_monitor_callback (const uint64_t value, +const uint64_t opaque[RTE_POWER_MONITOR_OPAQUE_SZ ]) +{ +const uint64_t m = opaque[CLB_MSK_IDX ]; +const uint64_t v = opaque[CLB_VAL_IDX ]; + +return (value & m) == v ?-1 :0 ; +} + +static int +virtio_split_monitor_callback (const uint64_t value, +const uint64_t opaque[RTE_POWER_MONITOR_OPAQUE_SZ ]) +{ +const uint64_t m = opaque[CLB_MSK_IDX ]; +const uint64_t v = opaque[CLB_VAL_IDX ]; + +return (value & m) == v ?0 :-1 ; +} + +static int +virtio_get_monitor_addr (void *rx_queue,struct rte_power_monitor_cond *pmc) +{ +struct virtnet_rx *rxvq = rx_queue; +struct virtqueue *vq =virtnet_rxq_to_vq (rxvq); +struct virtio_hw *hw = vq->hw; +if (vq ==NULL ) +return -EINVAL ; +if (virtio_with_packed_queue (hw)) { +struct vring_packed_desc *desc; + desc = vq->vq_packed.ring.desc; + pmc->addr = &desc[vq->vq_used_cons_idx].flags; +if (vq->vq_packed.used_wrap_counter) + pmc->opaque[CLB_VAL_IDX ] = +VRING_PACKED_DESC_F_AVAIL_USED ; +else + pmc->opaque[CLB_VAL_IDX ] =0 ; + pmc->opaque[CLB_MSK_IDX ] =VRING_PACKED_DESC_F_AVAIL_USED ; + pmc->fn = virtio_packed_monitor_callback; + pmc->size =sizeof (uint16_t ); + }else { + pmc->addr = &vq->vq_split.ring.used->idx; + pmc->opaque[CLB_VAL_IDX ] = vq->vq_used_cons_idx + & (vq->vq_nentries -1 ); + pmc->opaque[CLB_MSK_IDX ] = vq->vq_nentries -1 ; + pmc->fn = virtio_split_monitor_callback; + pmc->size =sizeof (uint16_t ); + } + +return 0 ; +} +static int virtio_vlan_filter_set (struct rte_eth_dev *dev,uint16_t vlan_id,int on) {
Signature · 1 line
2.25.1
Re: [dpdk-dev] [PATCH 1/5] net/virtio: implement rte_power_monitor API
Hi Miao,
Quoted 81 lines
-----Original Message-----
From: Li, Miao <[email protected]>
Sent: Friday, September 10, 2021 9:06 PM
To: [email protected]
Cc: Xia, Chenbo <[email protected]>; [email protected]; Li, Miao <[email protected]>
Subject: [PATCH 1/5] net/virtio: implementrte_power_monitorAPIThis patch implements
rte_power_monitorAPI in virtio PMD to reduce power consumption when no packet come in. According to current semantics of power monitor, this commit adds a callback function to decide whether aborts the sleep by checking current value against the expected value andvirtio_get_monitor_addrto provide address to monitor. When no packet come in, the value of address will not be changed and the running core will sleep. Once packets arrive, the value of address will be changed and the running core will wakeup.Signed-off-by Miao Li <[email protected]>--- drivers/net/virtio/virtio_ethdev.c | 57 ++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+)drivers/net/virtio/virtio_ethdev.c +35
-0@@ -73,6 +73,8 @@ static int virtio_mac_addr_set(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr);static int virtio_intr_disable (struct rte_eth_dev *dev); +static int virtio_get_monitor_addr (void *rx_queue, +struct rte_power_monitor_cond *pmc); static int virtio_dev_queue_stats_mapping_set( struct rte_eth_dev *eth_dev,@@ -975,6 +977,7 @@ static const struct eth_dev_ops virtio_eth_dev_ops = { .mac_addr_add = virtio_mac_addr_add, .mac_addr_remove = virtio_mac_addr_remove, .mac_addr_set = virtio_mac_addr_set, + .get_monitor_addr = virtio_get_monitor_addr, };/* @@ -1306,6 +1309,60 @@ virtio_mac_addr_set(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr)return 0 ; } +#define CLB_VAL_IDX 0 +#define CLB_MSK_IDX 1 +static int +virtio_packed_monitor_callback (const uint64_t value, +const uint64_t opaque[RTE_POWER_MONITOR_OPAQUE_SZ ]) +{ +const uint64_t m = opaque[CLB_MSK_IDX ]; +const uint64_t v = opaque[CLB_VAL_IDX ]; + +return (value & m) == v ?-1 :0 ; +} + +static int +virtio_split_monitor_callback (const uint64_t value, +const uint64_t opaque[RTE_POWER_MONITOR_OPAQUE_SZ ]) +{ +const uint64_t m = opaque[CLB_MSK_IDX ]; +const uint64_t v = opaque[CLB_VAL_IDX ]; + +return (value & m) == v ?0 :-1 ; +} + +static int +virtio_get_monitor_addr (void *rx_queue,struct rte_power_monitor_cond *pmc) +{ +struct virtnet_rx *rxvq = rx_queue; +struct virtqueue *vq =virtnet_rxq_to_vq (rxvq); +struct virtio_hw *hw = vq->hw; +if (vq ==NULL ) +return -EINVAL ; +if (virtio_with_packed_queue (hw)) { +struct vring_packed_desc *desc;
drivers/net/virtio/virtio_ethdev.c virtio_mac_addr_set(struct rte_eth_dev *dev, struct · line 1354
Quoted 10 lines
drivers/net/virtio/virtio_ethdev.c +10
-0+ desc = vq->vq_packed.ring.desc; + pmc->addr = &desc[vq->vq_used_cons_idx].flags; +if (vq->vq_packed.used_wrap_counter) + pmc->opaque[CLB_VAL_IDX ] = +VRING_PACKED_DESC_F_AVAIL_USED ; +else + pmc->opaque[CLB_VAL_IDX ] =0 ; + pmc->opaque[CLB_MSK_IDX ] =VRING_PACKED_DESC_F_AVAIL_USED ; + pmc->fn = virtio_packed_monitor_callback; + pmc->size =sizeof (uint16_t );
I suggest to use sizeof(desc[vq->vq_used_cons_idx].flags) or sizeof(desc->flags) in case the flag type changes.
drivers/net/virtio/virtio_ethdev.c virtio_mac_addr_set(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr) · line 1360
Quoted 7 lines
drivers/net/virtio/virtio_ethdev.c +7
-0+ }else { + pmc->addr = &vq->vq_split.ring.used->idx; + pmc->opaque[CLB_VAL_IDX ] = vq->vq_used_cons_idx + & (vq->vq_nentries -1 ); + pmc->opaque[CLB_MSK_IDX ] = vq->vq_nentries -1 ; + pmc->fn = virtio_split_monitor_callback; + pmc->size =sizeof (uint16_t );
Same here.
Thanks,
Chenbo
Quoted 10 lines
drivers/net/virtio/virtio_ethdev.c +5
-0+ } + +return 0 ; +} +static int virtio_vlan_filter_set (struct rte_eth_dev *dev,uint16_t vlan_id,int on){
--
2.25.1
Re: [dpdk-dev] [PATCH 1/5] net/virtio: implement rte_power_monitor API
Hi chenbo
Quoted 101 lines
-----Original Message-----
From: Xia, Chenbo <[email protected]>
Sent: Wednesday, September 15, 2021 4:45 PM
To: Li, Miao <[email protected]>; [email protected]
Cc: [email protected]
Subject: RE: [PATCH 1/5] net/virtio: implementrte_power_monitorAPIHi Miao,
Quoted 77 lines
-----Original Message-----
From: Li, Miao <[email protected]>
Sent: Friday, September 10, 2021 9:06 PM
To: [email protected]
Cc: Xia, Chenbo <[email protected]>; [email protected]; Li, Miao <[email protected]>
Subject: [PATCH 1/5] net/virtio: implementrte_power_monitorAPIThis patch implements
rte_power_monitorAPI in virtio PMD to reduce power consumption when no packet come in. According to current semantics of power monitor, this commit adds a callback function to decide whether aborts the sleep by checking current value against the expected value andvirtio_get_monitor_addrto provide address to monitor. When no packet come in, the value of address will not be changed and the running core will sleep. Once packets arrive, the value of address will be changed and the running core will wakeup.Signed-off-by Miao Li <[email protected]>--- drivers/net/virtio/virtio_ethdev.c | 57 ++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+)drivers/net/virtio/virtio_ethdev.c +30
-0@@ -73,6 +73,8 @@ static int virtio_mac_addr_set(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr);static int virtio_intr_disable (struct rte_eth_dev *dev); +static int virtio_get_monitor_addr (void *rx_queue, +struct rte_power_monitor_cond *pmc); static int virtio_dev_queue_stats_mapping_set( struct rte_eth_dev *eth_dev,@@ -975,6 +977,7 @@ static const struct eth_dev_ops virtio_eth_dev_ops = { .mac_addr_add = virtio_mac_addr_add, .mac_addr_remove = virtio_mac_addr_remove, .mac_addr_set = virtio_mac_addr_set, + .get_monitor_addr = virtio_get_monitor_addr, };/* @@ -1306,6 +1309,60 @@ virtio_mac_addr_set(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr)return 0 ; } +#define CLB_VAL_IDX 0 +#define CLB_MSK_IDX 1 +static int +virtio_packed_monitor_callback (const uint64_t value, +const uint64_t opaque[RTE_POWER_MONITOR_OPAQUE_SZ ]) +{ +const uint64_t m = opaque[CLB_MSK_IDX ]; +const uint64_t v = opaque[CLB_VAL_IDX ]; + +return (value & m) == v ?-1 :0 ; +} + +static int +virtio_split_monitor_callback (const uint64_t value, +const uint64_t opaque[RTE_POWER_MONITOR_OPAQUE_SZ ]) +{ +const uint64_t m = opaque[CLB_MSK_IDX ]; +const uint64_t v = opaque[CLB_VAL_IDX ]; + +return (value & m) == v ?0 :-1 ; +} + +static int +virtio_get_monitor_addr (void *rx_queue,struct rte_power_monitor_cond +*pmc) { +struct virtnet_rx *rxvq = rx_queue; +struct virtqueue *vq =virtnet_rxq_to_vq (rxvq);drivers/net/virtio/virtio_ethdev.c virtio_mac_addr_set(struct rte_eth_dev *dev, · line 1349
Quoted 10 lines
drivers/net/virtio/virtio_ethdev.c +10
-0+struct virtio_hw *hw = vq->hw; +if (vq ==NULL ) +return -EINVAL ; +if (virtio_with_packed_queue (hw)) { +struct vring_packed_desc *desc; + desc = vq->vq_packed.ring.desc; + pmc->addr = &desc[vq->vq_used_cons_idx].flags; +if (vq->vq_packed.used_wrap_counter) + pmc->opaque[CLB_VAL_IDX] = +VRING_PACKED_DESC_F_AVAIL_USED;drivers/net/virtio/virtio_ethdev.c virtio_mac_addr_set(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr)
Quoted 3 lines
drivers/net/virtio/virtio_ethdev.c +3
-0+else + pmc->opaque[CLB_VAL_IDX ] =0 ; + pmc->opaque[CLB_MSK_IDX] =
VRING_PACKED_DESC_F_AVAIL_USED;
Quoted 5 lines
drivers/net/virtio/virtio_ethdev.c virtio_mac_addr_set(struct rte_eth_dev *dev, · line 1354
Quoted 2 lines
drivers/net/virtio/virtio_ethdev.c +2
-0+ pmc->fn = virtio_packed_monitor_callback; + pmc->size =sizeof (uint16_t );I suggest to use
sizeof(desc[vq->vq_used_cons_idx].flags)orsizeof(desc->flags)in case the flag type changes.
Thanks for your suggestion. I will fix it in the next version.
Quoted 10 lines
drivers/net/virtio/virtio_ethdev.c virtio_mac_addr_set(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr) · line 1360
Quoted 8 lines
drivers/net/virtio/virtio_ethdev.c +7
-0+ }else { + pmc->addr = &vq->vq_split.ring.used->idx; + pmc->opaque[CLB_VAL_IDX ] = vq->vq_used_cons_idx + & (vq->vq_nentries -1 ); + pmc->opaque[CLB_MSK_IDX ] = vq->vq_nentries -1 ; + pmc->fn = virtio_split_monitor_callback; + pmc->size =sizeof (uint16_t );Same here.
I will fix it in the next version, too.
Thanks,
Miao
Quoted 14 lines
Thanks,
ChenboQuoted 10 lines
drivers/net/virtio/virtio_ethdev.c +5
-0+ } + +return 0 ; +} +static int virtio_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, inton) {
--
2.25.1
PATCH 2/5 lib/vhost: implement rte_power_monitor API
In reply to Miao LiThis patch defines rte_vhost_power_monitor_cond which is used to pass some information to vhost driver. The information is including the address to monitor, the expected value, the mask to extract value read from 'addr', the flag used to distinguish packed ring or split ring. Vhost driver can use these information to fill rte_power_monitor_cond.
--- lib/vhost/rte_vhost.h | 33 +++++++++++++++++++++++++++++++++ lib/vhost/version.map | 3 +++ lib/vhost/vhost.c | 30 ++++++++++++++++++++++++++++++ 3 files changed, 66 insertions(+)
lib/vhost/rte_vhost.h +33 -0
@@ -38,6 +38,8 @@ extern "C" {#define RTE_VHOST_USER_ASYNC_COPY (1ULL << 7)#define RTE_VHOST_USER_NET_COMPLIANT_OL_FLAGS (1ULL << 8) +#define VHOST_POWER_MONITOR_RING_PACKED (1ULL << 0) +/* Features. */ #ifndef VIRTIO_NET_F_GUEST_ANNOUNCE #define VIRTIO_NET_F_GUEST_ANNOUNCE 21
@@ -292,6 +294,20 @@ struct vhost_device_ops {void *reserved[1 ];/**< Reserved for future extension */ }; +/** +* Power monitor condition. +*/ +struct rte_vhost_power_monitor_cond { +volatile void *addr;/**< Address to monitor for changes */ +/**< If the `mask` is non-zero, location pointed +* to by `addr` will be read and compared +* against this value. +*/ +uint64_t val; +uint64_t mask;/**< 64-bit mask to extract value read from `addr` */ +uint8_t flag;/**< if 1, vhost packed ring, otherwise split ring */ +}; +/** * Convert guest physical address to host virtual address *
@@ -914,6 +930,23 @@ int rte_vhost_vring_call(int vid, uint16_t vring_idx);*/ uint32_t rte_vhost_rx_queue_count (int vid,uint16_t qid); +/** +* Get power monitor address of the vhost device +* +* @param vid +* vhost device ID +* @param queue_id +* vhost queue ID +* @param pmc +* power monitor condition +* @return +* 0 on success, -1 on failure +*/ +__rte_experimental +int +rte_vhost_get_monitor_addr (int vid,uint16_t queue_id, +struct rte_vhost_power_monitor_cond *pmc); +/** * Get log base and log size of the vhost device *
lib/vhost/version.map +3 -0
@@ -85,4 +85,7 @@ EXPERIMENTAL { rte_vhost_async_channel_register_thread_unsafe; rte_vhost_async_channel_unregister_thread_unsafe; rte_vhost_clear_queue_thread_unsafe; + + # added in 21.11 + rte_vhost_get_monitor_addr; };
lib/vhost/vhost.c +30 -0
@@ -1886,5 +1886,35 @@ int rte_vhost_async_get_inflight(int vid, uint16_t queue_id)return ret; } +int +rte_vhost_get_monitor_addr (int vid,uint16_t queue_id, +struct rte_vhost_power_monitor_cond *pmc) +{ +struct virtio_net *dev =get_device (vid); +struct vhost_virtqueue *vq = dev->virtqueue[queue_id]; +if (vq ==NULL ) +return -1 ; +if (vq_is_packed (dev)) { +struct vring_packed_desc *desc; + desc = vq->desc_packed; + pmc->addr = &desc[vq->last_avail_idx].flags; +if (vq->avail_wrap_counter) + pmc->val =VRING_DESC_F_AVAIL ; +else + pmc->val =VRING_DESC_F_USED ; + pmc->mask =VRING_DESC_F_AVAIL |VRING_DESC_F_USED ; + pmc->flag =VHOST_POWER_MONITOR_RING_PACKED ; + }else { + pmc->addr = &vq->avail->idx; + pmc->val = vq->last_avail_idx & (vq->size -1 ); + pmc->mask = vq->size -1 ; + pmc->flag =0 ; + } +if (pmc->addr ==NULL ) +return -1 ; + +return 0 ; +} +RTE_LOG_REGISTER_SUFFIX (vhost_config_log_level, config,INFO );RTE_LOG_REGISTER_SUFFIX (vhost_data_log_level, data,WARNING );
Signature · 1 line
2.25.1
Re: [dpdk-dev] [PATCH 2/5] lib/vhost: implement rte_power_monitor API
Hi Miao,
Quoted 7 lines
-----Original Message-----
From: Li, Miao <[email protected]>
Sent: Friday, September 10, 2021 9:06 PM
To: [email protected]
Cc: Xia, Chenbo <[email protected]>; [email protected]; Li, Miao <[email protected]>
Subject: [PATCH 2/5] lib/vhost: implementrte_power_monitorAPI
Should be 'vhost: implement rte_power_monitor API'
Quoted 19 lines
This patch defines
rte_vhost_power_monitor_condwhich is used to pass some information to vhost driver. The information is including the address to monitor, the expected value, the mask to extract value read from 'addr', the flag used to distinguish packed ring or split ring. Vhost driver can use these information to fillrte_power_monitor_cond.Signed-off-by Miao Li <[email protected]>--- lib/vhost/rte_vhost.h | 33 +++++++++++++++++++++++++++++++++ lib/vhost/version.map | 3 +++ lib/vhost/vhost.c | 30 ++++++++++++++++++++++++++++++ 3 files changed, 66 insertions(+)lib/vhost/rte_vhost.h +0
-0
lib/vhost/rte_vhost.h extern "C" { · line 41
Quoted 4 lines
lib/vhost/rte_vhost.h +1
-0@@ -38,6 +38,8 @@ extern "C" {#define RTE_VHOST_USER_ASYNC_COPY (1ULL << 7)#define RTE_VHOST_USER_NET_COMPLIANT_OL_FLAGS (1ULL << 8) +#define VHOST_POWER_MONITOR_RING_PACKED (1ULL << 0)
I'd say I don't quite like introducing this flag so that vhost lib app needs to know the vring is split or packed. I have another suggestion to do the same thing, please check below comment.
Quoted 10 lines
lib/vhost/rte_vhost.h +3
-0+/* Features. */ #ifndef VIRTIO_NET_F_GUEST_ANNOUNCE #define VIRTIO_NET_F_GUEST_ANNOUNCE 21@@ -292,6 +294,20 @@ struct vhost_device_ops {void *reserved[1 ];/**< Reserved for future extension */ }; +/** +* Power monitor condition.
lib/vhost/rte_vhost.h struct vhost_device_ops { · line 308
Quoted 10 lines
lib/vhost/rte_vhost.h +10
-0+*/ +struct rte_vhost_power_monitor_cond { +volatile void *addr;/**< Address to monitor for changes */ +/**< If the `mask` is non-zero, location pointed +* to by `addr` will be read and compared +* against this value. +*/ +uint64_t val; +uint64_t mask;/**< 64-bit mask to extract value read from `addr` */ +uint8_t flag;/**< if 1, vhost packed ring, otherwise split ring */
What about define two values instead of the flag. One value for '(value & m) == v ?' is True, another for False.
Quoted 46 lines
lib/vhost/rte_vhost.h +19
-0+}; +/** * Convert guest physical address to host virtual address * @@ -914,6 +930,23 @@ int rte_vhost_vring_call(int vid, uint16_t vring_idx);*/ uint32_t rte_vhost_rx_queue_count (int vid,uint16_t qid); +/** +* Get power monitor address of the vhost device +* +* @param vid +* vhost device ID +* @param queue_id +* vhost queue ID +* @param pmc +* power monitor condition +* @return +* 0 on success, -1 on failure +*/ +__rte_experimental +int +rte_vhost_get_monitor_addr (int vid,uint16_t queue_id, +struct rte_vhost_power_monitor_cond *pmc); +/** * Get log base and log size of the vhost device * lib/vhost/version.map +3
-0@@ -85,4 +85,7 @@ EXPERIMENTAL { rte_vhost_async_channel_register_thread_unsafe; rte_vhost_async_channel_unregister_thread_unsafe; rte_vhost_clear_queue_thread_unsafe; + + # added in 21.11 + rte_vhost_get_monitor_addr; };lib/vhost/vhost.c +0
-0
lib/vhost/vhost.c int rte_vhost_async_get_inflight(int vid, uint16_t · line 1894
Quoted 9 lines
lib/vhost/vhost.c +5
-0@@ -1886,5 +1886,35 @@ int rte_vhost_async_get_inflight(int vid, uint16_t queue_id)return ret; } +int +rte_vhost_get_monitor_addr (int vid,uint16_t queue_id, +struct rte_vhost_power_monitor_cond *pmc) +{ +struct virtio_net *dev =get_device (vid);
Check dev is not NULL before accessing its member.
Quoted 11 lines
lib/vhost/vhost.c +11
-0+struct vhost_virtqueue *vq = dev->virtqueue[queue_id]; +if (vq ==NULL ) +return -1 ; +if (vq_is_packed (dev)) { +struct vring_packed_desc *desc; + desc = vq->desc_packed; + pmc->addr = &desc[vq->last_avail_idx].flags; +if (vq->avail_wrap_counter) + pmc->val =VRING_DESC_F_AVAIL ; +else + pmc->val =VRING_DESC_F_USED ;
lib/vhost/vhost.c int rte_vhost_async_get_inflight(int vid, uint16_t queue_id) · line 1914
Quoted 10 lines
lib/vhost/vhost.c +10
-0+ pmc->mask =VRING_DESC_F_AVAIL |VRING_DESC_F_USED ; + pmc->flag =VHOST_POWER_MONITOR_RING_PACKED ; + }else { + pmc->addr = &vq->avail->idx; + pmc->val = vq->last_avail_idx & (vq->size -1 ); + pmc->mask = vq->size -1 ; + pmc->flag =0 ; + } +if (pmc->addr ==NULL ) +return -1 ;
Is it possible that addr == NULL?
Thanks,
Chenbo
Quoted 8 lines
lib/vhost/vhost.c +4
-0+ +return 0 ; +} +RTE_LOG_REGISTER_SUFFIX (vhost_config_log_level, config,INFO );
RTE_LOG_REGISTER_SUFFIX(vhost_data_log_level, data, WARNING);
--
2.25.1
Re: [dpdk-dev] [PATCH 2/5] lib/vhost: implement rte_power_monitor API
Hi Chenbo,
Quoted 17 lines
-----Original Message-----
From: Xia, Chenbo <[email protected]>
Sent: Wednesday, September 15, 2021 4:52 PM
To: Li, Miao <[email protected]>; [email protected]
Cc: [email protected]
Subject: RE: [PATCH 2/5] lib/vhost: implementrte_power_monitorAPIHi Miao,
Quoted 7 lines
-----Original Message-----
From: Li, Miao <[email protected]>
Sent: Friday, September 10, 2021 9:06 PM
To: [email protected]
Cc: Xia, Chenbo <[email protected]>; [email protected]; Li, Miao <[email protected]>
Subject: [PATCH 2/5] lib/vhost: implementrte_power_monitorAPI
Quoted 1 line
Should be 'vhost: implement
rte_power_monitorAPI'
I will modify it in the next version.
Quoted 23 lines
Quoted 23 lines
This patch defines
rte_vhost_power_monitor_condwhich is used to pass some information to vhost driver. The information is including the address to monitor, the expected value, the mask to extract value read from 'addr', the flag used to distinguish packed ring or split ring. Vhost driver can use these information to fillrte_power_monitor_cond.Signed-off-by Miao Li <[email protected]>--- lib/vhost/rte_vhost.h | 33 +++++++++++++++++++++++++++++++++ lib/vhost/version.map | 3 +++ lib/vhost/vhost.c | 30 ++++++++++++++++++++++++++++++ 3 files changed, 66 insertions(+)lib/vhost/rte_vhost.h index renamed from lib/vhost/rte_vhost.h +0
-0
8d875e9322..f58643b0a3100644lib/vhost/rte_vhost.h +0
-0@@ -38,6 +38,8 @@ extern "C" {#define RTE_VHOST_USER_ASYNC_COPY (1ULL << 7)#define RTE_VHOST_USER_NET_COMPLIANT_OL_FLAGS (1ULL << 8)
Quoted 5 lines
lib/vhost/rte_vhost.h extern "C" { · line 41
Quoted 1 line
lib/vhost/rte_vhost.h +1
-0+#define VHOST_POWER_MONITOR_RING_PACKED (1ULL << 0)I'd say I don't quite like introducing this flag so that vhost lib app needs to know the vring is split or packed. I have another suggestion to do the same thing, please check below comment.
Yes, I agree with you. I will remove it in the next version.
Quoted 9 lines
lib/vhost/rte_vhost.h extern "C" {
Quoted 5 lines
lib/vhost/rte_vhost.h +1
-0+/* Features. */ #ifndef VIRTIO_NET_F_GUEST_ANNOUNCE #define VIRTIO_NET_F_GUEST_ANNOUNCE 21 @@ -292,6 +294,20 @@struct
Quoted 3 lines
vhost_device_ops{
void *reserved[1]; /**< Reserved for future extension */ };
Quoted 15 lines
lib/vhost/rte_vhost.h struct vhost_device_ops { · line 308
Quoted 12 lines
lib/vhost/rte_vhost.h +12
-0+/** +* Power monitor condition. +*/ +struct rte_vhost_power_monitor_cond { +volatile void *addr;/**< Address to monitor for changes */ +/**< If the `mask` is non-zero, location pointed +* to by `addr` will be read and compared +* against this value. +*/ +uint64_t val; +uint64_t mask;/**< 64-bit mask to extract value read from `addr` */ +uint8_t flag;/**< if 1, vhost packed ring, otherwise split ring */ What about define two values instead of the flag. One value for '(value & m) == v ?' is True, another for False.
I think one value to represent true or false is enough. I will fix it in the next version.
Quoted 52 lines
Quoted 52 lines
lib/vhost/rte_vhost.h +19
-0+}; +/** * Convert guest physical address to host virtual address * @@ -914,6 +930,23 @@ int rte_vhost_vring_call(int vid, uint16_t vring_idx);*/ uint32_t rte_vhost_rx_queue_count (int vid,uint16_t qid); +/** +* Get power monitor address of the vhost device +* +* @param vid +* vhost device ID +* @param queue_id +* vhost queue ID +* @param pmc +* power monitor condition +* @return +* 0 on success, -1 on failure +*/ +__rte_experimental +int +rte_vhost_get_monitor_addr (int vid,uint16_t queue_id, +struct rte_vhost_power_monitor_cond *pmc); +/** * Get log base and log size of the vhost device * lib/vhost/version.map index renamed from lib/vhost/version.map +0
-0
c92a9d4962..0a9667ef1e100644lib/vhost/version.map +3
-0@@ -85,4 +85,7 @@ EXPERIMENTAL { rte_vhost_async_channel_register_thread_unsafe; rte_vhost_async_channel_unregister_thread_unsafe; rte_vhost_clear_queue_thread_unsafe; + + # added in 21.11 + rte_vhost_get_monitor_addr; };lib/vhost/vhost.c index renamed from lib/vhost/vhost.c +0
-0
355ff37651..f7374d3f94100644lib/vhost/vhost.c +0
-0@@ -1886,5 +1886,35 @@ int rte_vhost_async_get_inflight(int vid,
uint16_tqueue_id)
return ret;
}
Quoted 6 lines
lib/vhost/vhost.c int rte_vhost_async_get_inflight(int vid, uint16_t queue_id) · line 1893
Quoted 4 lines
lib/vhost/vhost.c +4
-0+int +rte_vhost_get_monitor_addr (int vid,uint16_t queue_id, +struct rte_vhost_power_monitor_cond *pmc) { +struct virtio_net *dev =get_device (vid);Check dev is not NULL before accessing its member.
I will add dev and queue_id check here in the next version.
Quoted 16 lines
Quoted 16 lines
lib/vhost/vhost.c +15
-0+struct vhost_virtqueue *vq = dev->virtqueue[queue_id]; +if (vq ==NULL ) +return -1 ; +if (vq_is_packed (dev)) { +struct vring_packed_desc *desc; + desc = vq->desc_packed; + pmc->addr = &desc[vq->last_avail_idx].flags; +if (vq->avail_wrap_counter) + pmc->val =VRING_DESC_F_AVAIL ; +else + pmc->val =VRING_DESC_F_USED ; + pmc->mask =VRING_DESC_F_AVAIL |VRING_DESC_F_USED ; + pmc->flag =VHOST_POWER_MONITOR_RING_PACKED ; + }else { + pmc->addr = &vq->avail->idx;
Quoted 8 lines
lib/vhost/vhost.c int rte_vhost_async_get_inflight(int vid, uint16_t queue_id) · line 1914
Quoted 6 lines
lib/vhost/vhost.c +6
-0+ pmc->val = vq->last_avail_idx & (vq->size -1 ); + pmc->mask = vq->size -1 ; + pmc->flag =0 ; + } +if (pmc->addr ==NULL ) +return -1 ;Is it possible that addr == NULL?
Yes, it is unnecessary. I will delete it in the next version.
Thanks,
Miao
Quoted 12 lines
Thanks,
ChenboQuoted 8 lines
lib/vhost/vhost.c +4
-0+ +return 0 ; +} +RTE_LOG_REGISTER_SUFFIX (vhost_config_log_level, config,INFO );
RTE_LOG_REGISTER_SUFFIX(vhost_data_log_level, data, WARNING); --
2.25.1
PATCH 3/5 net/vhost: implement rte_power_monitor API
In reply to Miao LiThis patch implements rte_power_monitor API in vhost PMD to reduce power consumption when no packet come in. According to current semantics of power monitor, this commit adds a callback function to decide whether aborts the sleep by checking current value against the expected value and vhost_get_monitor_addr to provide address to monitor. When no packet come in, the value of address will not be changed and the running core will sleep. Once packets arrive, the value of address will be changed and the running core will wakeup.
--- drivers/net/vhost/rte_eth_vhost.c | 46 +++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+)
drivers/net/vhost/rte_eth_vhost.c +46 -0
@@ -1380,6 +1380,51 @@ eth_rx_queue_count(struct rte_eth_dev *dev, uint16_t rx_queue_id)return rte_vhost_rx_queue_count (vq->vid, vq->virtqueue_id); } +#define CLB_VAL_IDX 0 +#define CLB_MSK_IDX 1 +static int +vhost_packed_monitor_callback (const uint64_t value, +const uint64_t opaque[RTE_POWER_MONITOR_OPAQUE_SZ ]) +{ +const uint64_t m = opaque[CLB_MSK_IDX ]; +const uint64_t v = opaque[CLB_VAL_IDX ]; + +return (value & m) == v ?-1 :0 ; +} + +static int +vhost_split_monitor_callback (const uint64_t value, +const uint64_t opaque[RTE_POWER_MONITOR_OPAQUE_SZ ]) +{ +const uint64_t m = opaque[CLB_MSK_IDX ]; +const uint64_t v = opaque[CLB_VAL_IDX ]; + +return (value & m) == v ?0 :-1 ; +} + +static int +vhost_get_monitor_addr (void *rx_queue,struct rte_power_monitor_cond *pmc) +{ +struct vhost_queue *vq = rx_queue; +struct rte_vhost_power_monitor_cond vhost_pmc; +int ret; +if (vq ==NULL ) +return -EINVAL ; + ret =rte_vhost_get_monitor_addr (vq->vid, vq->virtqueue_id, + &vhost_pmc); +if (ret <0 ) +return -EINVAL ; + pmc->addr = vhost_pmc.addr; + pmc->opaque[CLB_VAL_IDX ] = vhost_pmc.val; + pmc->opaque[CLB_MSK_IDX ] = vhost_pmc.mask; +if (vhost_pmc.flag &VHOST_POWER_MONITOR_RING_PACKED ) + pmc->fn = vhost_packed_monitor_callback; +else + pmc->fn = vhost_split_monitor_callback; + pmc->size =sizeof (uint16_t ); +return 0 ; +} +static const struct eth_dev_ops ops = { .dev_start = eth_dev_start, .dev_stop = eth_dev_stop,
@@ -1399,6 +1444,7 @@ static const struct eth_dev_ops ops = { .xstats_get_names = vhost_dev_xstats_get_names, .rx_queue_intr_enable = eth_rxq_intr_enable, .rx_queue_intr_disable = eth_rxq_intr_disable, + .get_monitor_addr = vhost_get_monitor_addr, }; static int
Signature · 1 line
2.25.1
PATCH 4/5 lib/power: modify return of queue_stopped
In reply to Miao LiSince some vdevs like virtio and vhost do not support rxq_info_get and queue state inquiry, the error return value -ENOTSUP need to be ignored when queue_stopped cannot get rx queue information and rx queue state. This patch changes the return value of queue_stopped when rte_eth_rx_queue_info_get return ENOTSUP to support vdevs which cannot provide rx queue information and rx queue state enable power management.
--- lib/power/rte_power_pmd_mgmt.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
lib/power/rte_power_pmd_mgmt.c +7 -2
@@ -382,8 +382,13 @@ queue_stopped(const uint16_t port_id, const uint16_t queue_id) {struct rte_eth_rxq_info qinfo; -if (rte_eth_rx_queue_info_get (port_id, queue_id, &qinfo) <0 ) -return -1 ; +int ret =rte_eth_rx_queue_info_get (port_id, queue_id, &qinfo); +if (ret <0 ) { +if (ret == -ENOTSUP ) +return 1 ; +else +return -1 ; + }return qinfo.queue_state ==RTE_ETH_QUEUE_STATE_STOPPED ; }
Signature · 1 line
2.25.1
Re: [dpdk-dev] [PATCH 4/5] lib/power: modify return of queue_stopped
Quoted 23 lines · Miao Li
Since some vdevs like virtio and vhost do not support
rxq_info_getand queue state inquiry, the error return value-ENOTSUPneed to be ignored whenqueue_stoppedcannot get rx queue information and rx queue state. This patch changes the return value ofqueue_stoppedwhenrte_eth_rx_queue_info_getreturn ENOTSUP to support vdevs which cannot provide rx queue information and rx queue state enable power management.Signed-off-by Miao Li <[email protected]>--- lib/power/rte_power_pmd_mgmt.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)lib/power/rte_power_pmd_mgmt.c +0
-2@@ -382,8 +382,13 @@ queue_stopped(const uint16_t port_id, const uint16_t queue_id) {struct rte_eth_rxq_info qinfo; -if (rte_eth_rx_queue_info_get (port_id, queue_id, &qinfo) <0 ) -return -1 ;
lib/power/rte_power_pmd_mgmt.c queue_stopped(const uint16_t port_id, const uint16_t queue_id) · line 394
Quoted 10 lines
lib/power/rte_power_pmd_mgmt.c +7
-0+int ret =rte_eth_rx_queue_info_get (port_id, queue_id, &qinfo); +if (ret <0 ) { +if (ret == -ENOTSUP ) +return 1 ; +else +return -1 ; + }return qinfo.queue_state ==RTE_ETH_QUEUE_STATE_STOPPED ; }
This seems like a deficiency in the original implementation, good catch.
Signature · 2 lines
Thanks, Anatoly
PATCH 5/5 examples/l3fwd-power: support virtio/vhost
In reply to Miao LiThis patch adds two command line arguments which will be needed when using virtio/vhost vdev. One argument sets rx offloads capabilities DEV_RX_OFFLOAD_VLAN_STRIP. The other argument sets DCB, PSS and VMDQ off for RX side.
--- examples/l3fwd-power/main.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
examples/l3fwd-power/main.c +15 -0
@@ -1811,6 +1811,8 @@ parse_args(int argc, char **argv) {"high-perf-cores", 1, 0, 0}, {"no-numa", 0, 0, 0}, {"enable-jumbo", 0, 0, 0}, + {"vlan-strip", 0, 0, 0}, + {"rx-none", 0, 0, 0}, {CMD_LINE_OPT_EMPTY_POLL, 1, 0, 0}, {CMD_LINE_OPT_PARSE_PTYPE, 0, 0, 0}, {CMD_LINE_OPT_LEGACY, 0, 0, 0},
@@ -1986,6 +1988,19 @@ parse_args(int argc, char **argv) (unsigned int)port_conf.rxmode.max_rx_pkt_len); } +if (!strncmp (lgopts[option_index].name, +"vlan-strip" ,10 )) { +printf ("set vlan strip\n" ); + port_conf.rxmode.offloads = +DEV_RX_OFFLOAD_VLAN_STRIP ; + } + +if (!strncmp (lgopts[option_index].name, +"rx-none" ,7 )) { +printf ("none of DCB,RSS or VMDQ mode\n" ); + port_conf.rxmode.mq_mode =ETH_MQ_RX_NONE ; + } +if (!strncmp (lgopts[option_index].name,CMD_LINE_OPT_PARSE_PTYPE ,sizeof (CMD_LINE_OPT_PARSE_PTYPE ))) {
Signature · 1 line
2.25.1
Re: [dpdk-dev] [PATCH 5/5] examples/l3fwd-power: support virtio/vhost
Quoted 34 lines · Miao Li
This patch adds two command line arguments which will be needed when using virtio/vhost vdev. One argument sets rx offloads capabilities
DEV_RX_OFFLOAD_VLAN_STRIP. The other argument sets DCB, PSS and VMDQ off for RX side.Signed-off-by Miao Li <[email protected]>--- examples/l3fwd-power/main.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)examples/l3fwd-power/main.c +8
-0@@ -1811,6 +1811,8 @@ parse_args(int argc, char **argv) {"high-perf-cores", 1, 0, 0}, {"no-numa", 0, 0, 0}, {"enable-jumbo", 0, 0, 0}, + {"vlan-strip", 0, 0, 0}, + {"rx-none", 0, 0, 0}, {CMD_LINE_OPT_EMPTY_POLL, 1, 0, 0}, {CMD_LINE_OPT_PARSE_PTYPE, 0, 0, 0}, {CMD_LINE_OPT_LEGACY, 0, 0, 0},@@ -1986,6 +1988,19 @@ parse_args(int argc, char **argv) (unsigned int)port_conf.rxmode.max_rx_pkt_len); } +if (!strncmp (lgopts[option_index].name, +"vlan-strip" ,10 )) { +printf ("set vlan strip\n" ); + port_conf.rxmode.offloads = +DEV_RX_OFFLOAD_VLAN_STRIP ; + }
examples/l3fwd-power/main.c parse_args(int argc, char **argv) · line 2006
Quoted 10 lines
examples/l3fwd-power/main.c +7
-0+ +if (!strncmp (lgopts[option_index].name, +"rx-none" ,7 )) { +printf ("none of DCB,RSS or VMDQ mode\n" ); + port_conf.rxmode.mq_mode =ETH_MQ_RX_NONE ; + } +if (!strncmp (lgopts[option_index].name,CMD_LINE_OPT_PARSE_PTYPE ,sizeof (CMD_LINE_OPT_PARSE_PTYPE ))) {
Why not just rely on the capabilities exposed by the driver?
Maxime
Re: [dpdk-dev] [PATCH 5/5] examples/l3fwd-power: support virtio/vhost
In l3fwd-power, there is default port configuration which requires RSS and IPV4/UDP/TCP checksum. Once device does not support these, the l3fwd-power will exit and report an error.
Miao
-----Original Message-----
From: Maxime Coquelin <[email protected]>
Sent: Friday, September 10, 2021 3:24 PM
To: Li, Miao <[email protected]>; [email protected]
Cc: Xia, Chenbo <[email protected]>; David Marchand <[email protected]>
Subject: Re: [PATCH 5/5] examples/l3fwd-power: support virtio/vhost
Quoted 34 lines · Miao Li
This patch adds two command line arguments which will be needed when using virtio/vhost vdev. One argument sets rx offloads capabilities
DEV_RX_OFFLOAD_VLAN_STRIP. The other argument sets DCB, PSS and VMDQ off for RX side.Signed-off-by Miao Li <[email protected]>--- examples/l3fwd-power/main.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)examples/l3fwd-power/main.c +8
-0@@ -1811,6 +1811,8 @@ parse_args(int argc, char **argv) {"high-perf-cores", 1, 0, 0}, {"no-numa", 0, 0, 0}, {"enable-jumbo", 0, 0, 0}, + {"vlan-strip", 0, 0, 0}, + {"rx-none", 0, 0, 0}, {CMD_LINE_OPT_EMPTY_POLL, 1, 0, 0}, {CMD_LINE_OPT_PARSE_PTYPE, 0, 0, 0}, {CMD_LINE_OPT_LEGACY, 0, 0, 0},@@ -1986,6 +1988,19 @@ parse_args(int argc, char **argv) (unsigned int)port_conf.rxmode.max_rx_pkt_len); } +if (!strncmp (lgopts[option_index].name, +"vlan-strip" ,10 )) { +printf ("set vlan strip\n" ); + port_conf.rxmode.offloads = +DEV_RX_OFFLOAD_VLAN_STRIP ; + }
examples/l3fwd-power/main.c parse_args(int argc, char **argv) · line 2006
Quoted 10 lines
examples/l3fwd-power/main.c +7
-0+ +if (!strncmp (lgopts[option_index].name, +"rx-none" ,7 )) { +printf ("none of DCB,RSS or VMDQ mode\n" ); + port_conf.rxmode.mq_mode =ETH_MQ_RX_NONE ; + } +if (!strncmp (lgopts[option_index].name,CMD_LINE_OPT_PARSE_PTYPE ,sizeof (CMD_LINE_OPT_PARSE_PTYPE ))) {
Why not just rely on the capabilities exposed by the driver?
Maxime
Re: [dpdk-dev] [PATCH 5/5] examples/l3fwd-power: support virtio/vhost
Quoted 2 lines · Miao
In l3fwd-power, there is default port configuration which requires RSS and IPV4/UDP/TCP checksum. Once device does not support these, the l3fwd-power will exit and report an error.
Maxime suggested to update the port configuration based on its capabilities.
For RSS, it would be something like what I proposed for OVS:
https://patchwork.ozlabs.org/project/openvswitch/patch/[email protected]/
As for IPv4/UDP/TCP rx checksums, I am not sure there is any actual requirement for this app.
Probably something to investigate wrt DO_RFC_1812_CHECKS.
Signature · 1 line
David Marchand
Re: [dpdk-dev] [PATCH 5/5] examples/l3fwd-power: support virtio/vhost
Got it. I will change the codes and add the port configuration updating according to the device information. Thanks!
Miao
Quoted 28 lines
-----Original Message-----
From: David Marchand <[email protected]>
Sent: Friday, September 10, 2021 4:50 PM
To: Li, Miao <[email protected]>
Cc: Maxime Coquelin <[email protected]>; [email protected]; Xia, Chenbo <[email protected]>
Subject: Re: [dpdk-dev] [PATCH 5/5] examples/l3fwd-power: support virtio/vhostQuoted 2 lines · Miao
In l3fwd-power, there is default port configuration which requires RSS and
IPV4/UDP/TCP checksum. Once device does not support these, the l3fwd- power will exit and report an error.
Maxime suggested to update the port configuration based on its capabilities.
For RSS, it would be something like what I proposed for OVS:
https://patchwork.ozlabs.org/project/openvswitch/patch/20210830101304.1
[email protected]/As for IPv4/UDP/TCP rx checksums, I am not sure there is any actual requirement for this app.
Probably something to investigate wrtDO_RFC_1812_CHECKS.--
David Marchand
cover Implement rte_power_monitor API in virtio/vhost PMD
In reply to Miao LiThis patchset implements rte_power_monitor API in virtio and vhost PMD to reduce power consumption when no packet come in. This API can be called and tested in l3fwd-power after adding vhost and virtio support in l3fwd-power and ignoring the rx queue information check in queue_stopped().
v2:
-remove flag and add match and size in rte_vhost_power_monitor_cond -modify power callback function
-add dev and queue id check and remove unnecessary check -fix the assignment of pmc->size
-update port configuration according to the device information and
remove adding command line arguments
-modify some titles
Miao Li (5):
net/virtio: implement rte_power_monitor API
vhost: implement rte_power_monitor API
net/vhost: implement rte_power_monitor API
power: modify return of queue_stopped
examples/l3fwd-power: support virtio/vhost
drivers/net/vhost/rte_eth_vhost.c | 40 ++++++++++++++++++++++ drivers/net/virtio/virtio_ethdev.c | 53 ++++++++++++++++++++++++++++++ examples/l3fwd-power/main.c | 5 +++ lib/power/rte_power_pmd_mgmt.c | 9 +++-- lib/vhost/rte_vhost.h | 41 +++++++++++++++++++++++ lib/vhost/version.map | 3 ++ lib/vhost/vhost.c | 38 +++++++++++++++++++++ 7 files changed, 187 insertions(+), 2 deletions(-)
Signature · 1 line
2.25.1
PATCH 1/5 net/virtio: implement rte_power_monitor API
This patch implements rte_power_monitor API in virtio PMD to reduce power consumption when no packet come in. According to current semantics of power monitor, this commit adds a callback function to decide whether aborts the sleep by checking current value against the expected value and virtio_get_monitor_addr to provide address to monitor. When no packet come in, the value of address will not be changed and the running core will sleep. Once packets arrive, the value of address will be changed and the running core will wakeup.
--- drivers/net/virtio/virtio_ethdev.c | 53 ++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+)
drivers/net/virtio/virtio_ethdev.c +53 -0
@@ -73,6 +73,8 @@ static int virtio_mac_addr_set(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr);static int virtio_intr_disable (struct rte_eth_dev *dev); +static int virtio_get_monitor_addr (void *rx_queue, +struct rte_power_monitor_cond *pmc); static int virtio_dev_queue_stats_mapping_set( struct rte_eth_dev *eth_dev,
@@ -975,6 +977,7 @@ static const struct eth_dev_ops virtio_eth_dev_ops = { .mac_addr_add = virtio_mac_addr_add, .mac_addr_remove = virtio_mac_addr_remove, .mac_addr_set = virtio_mac_addr_set, + .get_monitor_addr = virtio_get_monitor_addr, };/*
@@ -1306,6 +1309,56 @@ virtio_mac_addr_set(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr)return 0 ; } +#define CLB_VAL_IDX 0 +#define CLB_MSK_IDX 1 +#define CLB_MATCH_IDX 2 +static int +virtio_monitor_callback (const uint64_t value, +const uint64_t opaque[RTE_POWER_MONITOR_OPAQUE_SZ ]) +{ +const uint64_t m = opaque[CLB_MSK_IDX ]; +const uint64_t v = opaque[CLB_VAL_IDX ]; +const uint64_t c = opaque[CLB_MATCH_IDX ]; + +if (c) +return (value & m) == v ?-1 :0 ; +else +return (value & m) == v ?0 :-1 ; +} + +static int +virtio_get_monitor_addr (void *rx_queue,struct rte_power_monitor_cond *pmc) +{ +struct virtnet_rx *rxvq = rx_queue; +struct virtqueue *vq =virtnet_rxq_to_vq (rxvq); +if (vq ==NULL ) +return -EINVAL ; +struct virtio_hw *hw = vq->hw; +if (virtio_with_packed_queue (hw)) { +struct vring_packed_desc *desc; + desc = vq->vq_packed.ring.desc; + pmc->addr = &desc[vq->vq_used_cons_idx].flags; +if (vq->vq_packed.used_wrap_counter) + pmc->opaque[CLB_VAL_IDX ] = +VRING_PACKED_DESC_F_AVAIL_USED ; +else + pmc->opaque[CLB_VAL_IDX ] =0 ; + pmc->opaque[CLB_MSK_IDX ] =VRING_PACKED_DESC_F_AVAIL_USED ; + pmc->opaque[CLB_MATCH_IDX ] =1 ; + pmc->size =sizeof (desc[vq->vq_used_cons_idx].flags); + }else { + pmc->addr = &vq->vq_split.ring.used->idx; + pmc->opaque[CLB_VAL_IDX ] = vq->vq_used_cons_idx + & (vq->vq_nentries -1 ); + pmc->opaque[CLB_MSK_IDX ] = vq->vq_nentries -1 ; + pmc->opaque[CLB_MATCH_IDX ] =0 ; + pmc->size =sizeof (vq->vq_split.ring.used->idx); + } + pmc->fn = virtio_monitor_callback; + +return 0 ; +} +static int virtio_vlan_filter_set (struct rte_eth_dev *dev,uint16_t vlan_id,int on) {
Signature · 1 line
2.25.1
PATCH 2/5 vhost: implement rte_power_monitor API
In reply to Miao LiThis patch defines rte_vhost_power_monitor_cond which is used to pass some information to vhost driver. The information is including the address to monitor, the expected value, the mask to extract value read from 'addr', the value size of monitor address, the match flag used to distinguish the value used to match something or not match someting. Vhost driver can use these information to fill rte_power_monitor_cond.
--- lib/vhost/rte_vhost.h | 41 +++++++++++++++++++++++++++++++++++++++++ lib/vhost/version.map | 3 +++ lib/vhost/vhost.c | 38 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 82 insertions(+)
lib/vhost/rte_vhost.h +41 -0
@@ -292,6 +292,30 @@ struct vhost_device_ops {void *reserved[1 ];/**< Reserved for future extension */ }; +/** +* Power monitor condition. +*/ +struct rte_vhost_power_monitor_cond { +volatile void *addr;/**< Address to monitor for changes */ +/**< If the `mask` is non-zero, location pointed +* to by `addr` will be read and compared +* against this value. +*/ +uint64_t val; +uint64_t mask;/**< 64-bit mask to extract value read from `addr` */ +/**< Data size (in bytes) that will be read from the +* monitored memory location (`addr`). Can be 1, 2, +* 4, or 8. Supplying any other value will result in +* an error. +*/ +uint8_t size; +/**< If 1, checking if `val` matches something. +* If 0, checking if `val` *doesn't* match a +* particular value. +*/ +uint8_t match; +}; +/** * Convert guest physical address to host virtual address *
@@ -914,6 +938,23 @@ int rte_vhost_vring_call(int vid, uint16_t vring_idx);*/ uint32_t rte_vhost_rx_queue_count (int vid,uint16_t qid); +/** +* Get power monitor address of the vhost device +* +* @param vid +* vhost device ID +* @param queue_id +* vhost queue ID +* @param pmc +* power monitor condition +* @return +* 0 on success, -1 on failure +*/ +__rte_experimental +int +rte_vhost_get_monitor_addr (int vid,uint16_t queue_id, +struct rte_vhost_power_monitor_cond *pmc); +/** * Get log base and log size of the vhost device *
lib/vhost/version.map +3 -0
@@ -85,4 +85,7 @@ EXPERIMENTAL { rte_vhost_async_channel_register_thread_unsafe; rte_vhost_async_channel_unregister_thread_unsafe; rte_vhost_clear_queue_thread_unsafe; + + # added in 21.11 + rte_vhost_get_monitor_addr; };
lib/vhost/vhost.c +38 -0
@@ -1886,5 +1886,43 @@ int rte_vhost_async_get_inflight(int vid, uint16_t queue_id)return ret; } +int +rte_vhost_get_monitor_addr (int vid,uint16_t queue_id, +struct rte_vhost_power_monitor_cond *pmc) +{ +struct virtio_net *dev =get_device (vid); + +if (dev ==NULL ) +return -1 ; +if (queue_id >=VHOST_MAX_VRING ) +return -1 ; + +struct vhost_virtqueue *vq = dev->virtqueue[queue_id]; + +if (vq ==NULL ) +return -1 ; + +if (vq_is_packed (dev)) { +struct vring_packed_desc *desc; + desc = vq->desc_packed; + pmc->addr = &desc[vq->last_avail_idx].flags; +if (vq->avail_wrap_counter) + pmc->val =VRING_DESC_F_AVAIL ; +else + pmc->val =VRING_DESC_F_USED ; + pmc->mask =VRING_DESC_F_AVAIL |VRING_DESC_F_USED ; + pmc->size =sizeof (desc[vq->last_avail_idx].flags); + pmc->match =1 ; + }else { + pmc->addr = &vq->avail->idx; + pmc->val = vq->last_avail_idx & (vq->size -1 ); + pmc->mask = vq->size -1 ; + pmc->size =sizeof (vq->avail->idx); + pmc->match =0 ; + } + +return 0 ; +} +RTE_LOG_REGISTER_SUFFIX (vhost_config_log_level, config,INFO );RTE_LOG_REGISTER_SUFFIX (vhost_data_log_level, data,WARNING );
Signature · 1 line
2.25.1
PATCH 3/5 net/vhost: implement rte_power_monitor API
In reply to Miao LiThis patch implements rte_power_monitor API in vhost PMD to reduce power consumption when no packet come in. According to current semantics of power monitor, this commit adds a callback function to decide whether aborts the sleep by checking current value against the expected value and vhost_get_monitor_addr to provide address to monitor. When no packet come in, the value of address will not be changed and the running core will sleep. Once packets arrive, the value of address will be changed and the running core will wakeup.
--- drivers/net/vhost/rte_eth_vhost.c | 40 +++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+)
drivers/net/vhost/rte_eth_vhost.c +40 -0
@@ -1380,6 +1380,45 @@ eth_rx_queue_count(struct rte_eth_dev *dev, uint16_t rx_queue_id)return rte_vhost_rx_queue_count (vq->vid, vq->virtqueue_id); } +#define CLB_VAL_IDX 0 +#define CLB_MSK_IDX 1 +#define CLB_MATCH_IDX 2 +static int +vhost_monitor_callback (const uint64_t value, +const uint64_t opaque[RTE_POWER_MONITOR_OPAQUE_SZ ]) +{ +const uint64_t m = opaque[CLB_MSK_IDX ]; +const uint64_t v = opaque[CLB_VAL_IDX ]; +const uint64_t c = opaque[CLB_MATCH_IDX ]; + +if (c) +return (value & m) == v ?-1 :0 ; +else +return (value & m) == v ?0 :-1 ; +} + +static int +vhost_get_monitor_addr (void *rx_queue,struct rte_power_monitor_cond *pmc) +{ +struct vhost_queue *vq = rx_queue; +struct rte_vhost_power_monitor_cond vhost_pmc; +int ret; +if (vq ==NULL ) +return -EINVAL ; + ret =rte_vhost_get_monitor_addr (vq->vid, vq->virtqueue_id, + &vhost_pmc); +if (ret <0 ) +return -EINVAL ; + pmc->addr = vhost_pmc.addr; + pmc->opaque[CLB_VAL_IDX ] = vhost_pmc.val; + pmc->opaque[CLB_MSK_IDX ] = vhost_pmc.mask; + pmc->opaque[CLB_MATCH_IDX ] = vhost_pmc.match; + pmc->size = vhost_pmc.size; + pmc->fn = vhost_monitor_callback; + +return 0 ; +} +static const struct eth_dev_ops ops = { .dev_start = eth_dev_start, .dev_stop = eth_dev_stop,
@@ -1399,6 +1438,7 @@ static const struct eth_dev_ops ops = { .xstats_get_names = vhost_dev_xstats_get_names, .rx_queue_intr_enable = eth_rxq_intr_enable, .rx_queue_intr_disable = eth_rxq_intr_disable, + .get_monitor_addr = vhost_get_monitor_addr, }; static int
Signature · 1 line
2.25.1
PATCH 4/5 power: modify return of queue_stopped
In reply to Miao LiSince some vdevs like virtio and vhost do not support rxq_info_get and queue state inquiry, the error return value -ENOTSUP need to be ignored when queue_stopped cannot get rx queue information and rx queue state. This patch changes the return value of queue_stopped when rte_eth_rx_queue_info_get return ENOTSUP to support vdevs which cannot provide rx queue information and rx queue state enable power management.
--- lib/power/rte_power_pmd_mgmt.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
lib/power/rte_power_pmd_mgmt.c +7 -2
@@ -382,8 +382,13 @@ queue_stopped(const uint16_t port_id, const uint16_t queue_id) {struct rte_eth_rxq_info qinfo; -if (rte_eth_rx_queue_info_get (port_id, queue_id, &qinfo) <0 ) -return -1 ; +int ret =rte_eth_rx_queue_info_get (port_id, queue_id, &qinfo); +if (ret <0 ) { +if (ret == -ENOTSUP ) +return 1 ; +else +return -1 ; + }return qinfo.queue_state ==RTE_ETH_QUEUE_STATE_STOPPED ; }
Signature · 1 line
2.25.1
PATCH 5/5 examples/l3fwd-power: support virtio/vhost
In reply to Miao LiIn l3fwd-power, there is default port configuration which requires RSS and IPV4/UDP/TCP checksum. Once device does not support these, the l3fwd-power will exit and report an error.
This patch updates the port configuration based on device capabilities after getting the device information to support devices like virtio and vhost.
--- examples/l3fwd-power/main.c | 5 +++++ 1 file changed, 5 insertions(+)
examples/l3fwd-power/main.c +5 -0
@@ -2637,6 +2637,11 @@ main(int argc, char **argv) local_port_conf.rx_adv_conf.rss_conf.rss_hf); } +if (local_port_conf.rx_adv_conf.rss_conf.rss_hf ==0 ) + local_port_conf.rxmode.mq_mode =ETH_MQ_RX_NONE ; + local_port_conf.rxmode.offloads &= dev_info.rx_offload_capa; + port_conf.rxmode.offloads = local_port_conf.rxmode.offloads; + ret =rte_eth_dev_configure (portid, nb_rx_queue, (uint16_t )n_tx_queue, &local_port_conf);if (ret <0 )
Signature · 1 line
2.25.1
v3 cover Implement rte_power_monitor API in virtio/vhost PMD
In reply to Miao LiThis patchset implements rte_power_monitor API in virtio and vhost PMD to reduce power consumption when no packet come in. This API can be called and tested in l3fwd-power after adding vhost and virtio support in l3fwd-power and ignoring the rx queue information check in queue_stopped().
v3:
-fix some code format issues
-fix spelling mistake
v2:
-remove flag and add match and size in rte_vhost_power_monitor_cond -modify power callback function
-add dev and queue id check and remove unnecessary check -fix the assignment of pmc->size
-update port configuration according to the device information and remove adding command line arguments
-modify some titles
Miao Li (5):
net/virtio: implement rte_power_monitor API
vhost: implement rte_power_monitor API
net/vhost: implement rte_power_monitor API
power: modify return of queue_stopped
examples/l3fwd-power: support virtio/vhost
drivers/net/vhost/rte_eth_vhost.c | 40 +++++++++++++++++++++ drivers/net/virtio/virtio_ethdev.c | 56 ++++++++++++++++++++++++++++++ examples/l3fwd-power/main.c | 5 +++ lib/power/rte_power_pmd_mgmt.c | 9 +++-- lib/vhost/rte_vhost.h | 41 ++++++++++++++++++++++ lib/vhost/version.map | 3 ++ lib/vhost/vhost.c | 38 ++++++++++++++++++++ 7 files changed, 190 insertions(+), 2 deletions(-)
Signature · 1 line
2.25.1
PATCH v3 1/5 net/virtio: implement rte_power_monitor API
This patch implements rte_power_monitor API in virtio PMD to reduce power consumption when no packet come in. According to current semantics of power monitor, this commit adds a callback function to decide whether aborts the sleep by checking current value against the expected value and virtio_get_monitor_addr to provide address to monitor. When no packet come in, the value of address will not be changed and the running core will sleep. Once packets arrive, the value of address will be changed and the running core will wakeup.
--- drivers/net/virtio/virtio_ethdev.c | 56 ++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+)
drivers/net/virtio/virtio_ethdev.c +56 -0
@@ -73,6 +73,8 @@ static int virtio_mac_addr_set(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr);static int virtio_intr_disable (struct rte_eth_dev *dev); +static int virtio_get_monitor_addr (void *rx_queue, +struct rte_power_monitor_cond *pmc); static int virtio_dev_queue_stats_mapping_set( struct rte_eth_dev *eth_dev,
@@ -975,6 +977,7 @@ static const struct eth_dev_ops virtio_eth_dev_ops = { .mac_addr_add = virtio_mac_addr_add, .mac_addr_remove = virtio_mac_addr_remove, .mac_addr_set = virtio_mac_addr_set, + .get_monitor_addr = virtio_get_monitor_addr, };/*
@@ -1306,6 +1309,59 @@ virtio_mac_addr_set(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr)return 0 ; } +#define CLB_VAL_IDX 0 +#define CLB_MSK_IDX 1 +#define CLB_MATCH_IDX 2 +static int +virtio_monitor_callback (const uint64_t value, +const uint64_t opaque[RTE_POWER_MONITOR_OPAQUE_SZ ]) +{ +const uint64_t m = opaque[CLB_MSK_IDX ]; +const uint64_t v = opaque[CLB_VAL_IDX ]; +const uint64_t c = opaque[CLB_MATCH_IDX ]; + +if (c) +return (value & m) == v ?-1 :0 ; +else +return (value & m) == v ?0 :-1 ; +} + +static int +virtio_get_monitor_addr (void *rx_queue,struct rte_power_monitor_cond *pmc) +{ +struct virtnet_rx *rxvq = rx_queue; +struct virtqueue *vq =virtnet_rxq_to_vq (rxvq); +struct virtio_hw *hw; + +if (vq ==NULL ) +return -EINVAL ; + + hw = vq->hw; +if (virtio_with_packed_queue (hw)) { +struct vring_packed_desc *desc; + desc = vq->vq_packed.ring.desc; + pmc->addr = &desc[vq->vq_used_cons_idx].flags; +if (vq->vq_packed.used_wrap_counter) + pmc->opaque[CLB_VAL_IDX ] = +VRING_PACKED_DESC_F_AVAIL_USED ; +else + pmc->opaque[CLB_VAL_IDX ] =0 ; + pmc->opaque[CLB_MSK_IDX ] =VRING_PACKED_DESC_F_AVAIL_USED ; + pmc->opaque[CLB_MATCH_IDX ] =1 ; + pmc->size =sizeof (desc[vq->vq_used_cons_idx].flags); + }else { + pmc->addr = &vq->vq_split.ring.used->idx; + pmc->opaque[CLB_VAL_IDX ] = vq->vq_used_cons_idx + & (vq->vq_nentries -1 ); + pmc->opaque[CLB_MSK_IDX ] = vq->vq_nentries -1 ; + pmc->opaque[CLB_MATCH_IDX ] =0 ; + pmc->size =sizeof (vq->vq_split.ring.used->idx); + } + pmc->fn = virtio_monitor_callback; + +return 0 ; +} +static int virtio_vlan_filter_set (struct rte_eth_dev *dev,uint16_t vlan_id,int on) {
Signature · 1 line
2.25.1
Re: [dpdk-dev] [PATCH v3 1/5] net/virtio: implement rte_power_monitor API
Quoted 104 lines
-----Original Message-----
From: Li, Miao <[email protected]>
Sent: Friday, September 24, 2021 6:23 PM
To: [email protected]
Cc: Xia, Chenbo <[email protected]>; [email protected]; Li, Miao <[email protected]>
Subject: [PATCH v3 1/5] net/virtio: implementrte_power_monitorAPIThis patch implements
rte_power_monitorAPI in virtio PMD to reduce power consumption when no packet come in. According to current semantics of power monitor, this commit adds a callback function to decide whether aborts the sleep by checking current value against the expected value andvirtio_get_monitor_addrto provide address to monitor. When no packet come in, the value of address will not be changed and the running core will sleep. Once packets arrive, the value of address will be changed and the running core will wakeup.Signed-off-by Miao Li <[email protected]>--- drivers/net/virtio/virtio_ethdev.c | 56 ++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+)drivers/net/virtio/virtio_ethdev.c +56
-0@@ -73,6 +73,8 @@ static int virtio_mac_addr_set(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr);static int virtio_intr_disable (struct rte_eth_dev *dev); +static int virtio_get_monitor_addr (void *rx_queue, +struct rte_power_monitor_cond *pmc); static int virtio_dev_queue_stats_mapping_set( struct rte_eth_dev *eth_dev,@@ -975,6 +977,7 @@ static const struct eth_dev_ops virtio_eth_dev_ops = { .mac_addr_add = virtio_mac_addr_add, .mac_addr_remove = virtio_mac_addr_remove, .mac_addr_set = virtio_mac_addr_set, + .get_monitor_addr = virtio_get_monitor_addr, };/* @@ -1306,6 +1309,59 @@ virtio_mac_addr_set(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr)return 0 ; } +#define CLB_VAL_IDX 0 +#define CLB_MSK_IDX 1 +#define CLB_MATCH_IDX 2 +static int +virtio_monitor_callback (const uint64_t value, +const uint64_t opaque[RTE_POWER_MONITOR_OPAQUE_SZ ]) +{ +const uint64_t m = opaque[CLB_MSK_IDX ]; +const uint64_t v = opaque[CLB_VAL_IDX ]; +const uint64_t c = opaque[CLB_MATCH_IDX ]; + +if (c) +return (value & m) == v ?-1 :0 ; +else +return (value & m) == v ?0 :-1 ; +} + +static int +virtio_get_monitor_addr (void *rx_queue,struct rte_power_monitor_cond *pmc) +{ +struct virtnet_rx *rxvq = rx_queue; +struct virtqueue *vq =virtnet_rxq_to_vq (rxvq); +struct virtio_hw *hw; + +if (vq ==NULL ) +return -EINVAL ; + + hw = vq->hw; +if (virtio_with_packed_queue (hw)) { +struct vring_packed_desc *desc; + desc = vq->vq_packed.ring.desc; + pmc->addr = &desc[vq->vq_used_cons_idx].flags; +if (vq->vq_packed.used_wrap_counter) + pmc->opaque[CLB_VAL_IDX ] = +VRING_PACKED_DESC_F_AVAIL_USED ; +else + pmc->opaque[CLB_VAL_IDX ] =0 ; + pmc->opaque[CLB_MSK_IDX ] =VRING_PACKED_DESC_F_AVAIL_USED ; + pmc->opaque[CLB_MATCH_IDX ] =1 ; + pmc->size =sizeof (desc[vq->vq_used_cons_idx].flags); + }else { + pmc->addr = &vq->vq_split.ring.used->idx; + pmc->opaque[CLB_VAL_IDX ] = vq->vq_used_cons_idx + & (vq->vq_nentries -1 ); + pmc->opaque[CLB_MSK_IDX ] = vq->vq_nentries -1 ; + pmc->opaque[CLB_MATCH_IDX ] =0 ; + pmc->size =sizeof (vq->vq_split.ring.used->idx); + } + pmc->fn = virtio_monitor_callback; + +return 0 ; +} +static int virtio_vlan_filter_set (struct rte_eth_dev *dev,uint16_t vlan_id,int on)
Quoted 3 lines
{
--
2.25.1
PATCH v3 2/5 vhost: implement rte_power_monitor API
In reply to Miao LiThis patch defines rte_vhost_power_monitor_cond which is used to pass some information to vhost driver. The information is including the address to monitor, the expected value, the mask to extract value read from 'addr', the value size of monitor address, the match flag used to distinguish the value used to match something or not match something. Vhost driver can use these information to fill rte_power_monitor_cond.
--- lib/vhost/rte_vhost.h | 41 +++++++++++++++++++++++++++++++++++++++++ lib/vhost/version.map | 3 +++ lib/vhost/vhost.c | 38 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 82 insertions(+)
lib/vhost/rte_vhost.h +41 -0
@@ -292,6 +292,30 @@ struct vhost_device_ops {void *reserved[1 ];/**< Reserved for future extension */ }; +/** +* Power monitor condition. +*/ +struct rte_vhost_power_monitor_cond { +volatile void *addr;/**< Address to monitor for changes */ +/**< If the `mask` is non-zero, location pointed +* to by `addr` will be read and compared +* against this value. +*/ +uint64_t val; +uint64_t mask;/**< 64-bit mask to extract value read from `addr` */ +/**< Data size (in bytes) that will be read from the +* monitored memory location (`addr`). Can be 1, 2, +* 4, or 8. Supplying any other value will result in +* an error. +*/ +uint8_t size; +/**< If 1, checking if `val` matches something. +* If 0, checking if `val` *doesn't* match a +* particular value. +*/ +uint8_t match; +}; +/** * Convert guest physical address to host virtual address *
@@ -914,6 +938,23 @@ int rte_vhost_vring_call(int vid, uint16_t vring_idx);*/ uint32_t rte_vhost_rx_queue_count (int vid,uint16_t qid); +/** +* Get power monitor address of the vhost device +* +* @param vid +* vhost device ID +* @param queue_id +* vhost queue ID +* @param pmc +* power monitor condition +* @return +* 0 on success, -1 on failure +*/ +__rte_experimental +int +rte_vhost_get_monitor_addr (int vid,uint16_t queue_id, +struct rte_vhost_power_monitor_cond *pmc); +/** * Get log base and log size of the vhost device *
lib/vhost/version.map +3 -0
@@ -85,4 +85,7 @@ EXPERIMENTAL { rte_vhost_async_channel_register_thread_unsafe; rte_vhost_async_channel_unregister_thread_unsafe; rte_vhost_clear_queue_thread_unsafe; + + # added in 21.11 + rte_vhost_get_monitor_addr; };
lib/vhost/vhost.c +38 -0
@@ -1886,5 +1886,43 @@ int rte_vhost_async_get_inflight(int vid, uint16_t queue_id)return ret; } +int +rte_vhost_get_monitor_addr (int vid,uint16_t queue_id, +struct rte_vhost_power_monitor_cond *pmc) +{ +struct virtio_net *dev =get_device (vid); +struct vhost_virtqueue *vq; + +if (dev ==NULL ) +return -1 ; +if (queue_id >=VHOST_MAX_VRING ) +return -1 ; + + vq = dev->virtqueue[queue_id]; +if (vq ==NULL ) +return -1 ; + +if (vq_is_packed (dev)) { +struct vring_packed_desc *desc; + desc = vq->desc_packed; + pmc->addr = &desc[vq->last_avail_idx].flags; +if (vq->avail_wrap_counter) + pmc->val =VRING_DESC_F_AVAIL ; +else + pmc->val =VRING_DESC_F_USED ; + pmc->mask =VRING_DESC_F_AVAIL |VRING_DESC_F_USED ; + pmc->size =sizeof (desc[vq->last_avail_idx].flags); + pmc->match =1 ; + }else { + pmc->addr = &vq->avail->idx; + pmc->val = vq->last_avail_idx & (vq->size -1 ); + pmc->mask = vq->size -1 ; + pmc->size =sizeof (vq->avail->idx); + pmc->match =0 ; + } + +return 0 ; +} +RTE_LOG_REGISTER_SUFFIX (vhost_config_log_level, config,INFO );RTE_LOG_REGISTER_SUFFIX (vhost_data_log_level, data,WARNING );
Signature · 1 line
2.25.1
Re: [dpdk-dev] [PATCH v3 2/5] vhost: implement rte_power_monitor API
Hi Miao,
Quoted 30 lines
-----Original Message-----
From: Li, Miao <[email protected]>
Sent: Friday, September 24, 2021 6:23 PM
To: [email protected]
Cc: Xia, Chenbo <[email protected]>; [email protected]; Li, Miao <[email protected]>
Subject: [PATCH v3 2/5] vhost: implementrte_power_monitorAPIThis patch defines
rte_vhost_power_monitor_condwhich is used to pass some information to vhost driver. The information is including the address to monitor, the expected value, the mask to extract value read from 'addr', the value size of monitor address, the match flag used to distinguish the value used to match something or not match something. Vhost driver can use these information to fillrte_power_monitor_cond.Signed-off-by Miao Li <[email protected]>--- lib/vhost/rte_vhost.h | 41 +++++++++++++++++++++++++++++++++++++++++ lib/vhost/version.map | 3 +++ lib/vhost/vhost.c | 38 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 82 insertions(+)lib/vhost/rte_vhost.h +0
-0@@ -292,6 +292,30 @@ struct vhost_device_ops {void *reserved[1 ];/**< Reserved for future extension */ };
lib/vhost/rte_vhost.h struct vhost_device_ops { · line 304
Quoted 10 lines
lib/vhost/rte_vhost.h +10
-0+/** +* Power monitor condition. +*/ +struct rte_vhost_power_monitor_cond { +volatile void *addr;/**< Address to monitor for changes */ +/**< If the `mask` is non-zero, location pointed +* to by `addr` will be read and compared +* against this value. +*/ +uint64_t val;
Will be read and masked, then compared with this value?
lib/vhost/rte_vhost.h struct vhost_device_ops { · line 315
Quoted 11 lines
lib/vhost/rte_vhost.h +11
-0+uint64_t mask;/**< 64-bit mask to extract value read from `addr` */ +/**< Data size (in bytes) that will be read from the +* monitored memory location (`addr`). Can be 1, 2, +* 4, or 8. Supplying any other value will result in +* an error. +*/ +uint8_t size; +/**< If 1, checking if `val` matches something. +* If 0, checking if `val` *doesn't* match a +* particular value. +*/
If 1, and masked value that read from addr equals val, drivers can exit the power-saving state.
If 0, ....
The overall comment can't make me understand how this struct is used if I read the next patch.
lib/vhost/rte_vhost.h struct vhost_device_ops { · line 316
Quoted 1 line
lib/vhost/rte_vhost.h +1
-0+uint8_t match;
The comment style is a bit messy here. You can make every comment above variable Definition (like val/size/match ) or make the first line the same as the variable line (like addr/mask).
And please update the release note(release_20_11.rst), it's a new feature.
Thanks,
Chenbo
Re: [dpdk-dev] [PATCH v3 2/5] vhost: implement rte_power_monitor API
Hi Chenbo,
Quoted 73 lines
-----Original Message-----
From: Xia, Chenbo <[email protected]>
Sent: Wednesday, September 29, 2021 11:01 AM
To: Li, Miao <[email protected]>; [email protected]
Cc: [email protected]
Subject: RE: [PATCH v3 2/5] vhost: implementrte_power_monitorAPIHi Miao,
Quoted 5 lines
-----Original Message-----
From: Li, Miao <[email protected]>
Sent: Friday, September 24, 2021 6:23 PM
To: [email protected]
Cc: Xia, Chenbo <[email protected]>; [email protected]; Li,Miao
Quoted 25 lines
<[email protected]>
Subject: [PATCH v3 2/5] vhost: implementrte_power_monitorAPIThis patch defines
rte_vhost_power_monitor_condwhich is used to pass some information to vhost driver. The information is including the address to monitor, the expected value, the mask to extract value read from 'addr', the value size of monitor address, the match flag used to distinguish the value used to match something or not match something. Vhost driver can use these information to fillrte_power_monitor_cond.Signed-off-by Miao Li <[email protected]>--- lib/vhost/rte_vhost.h | 41 +++++++++++++++++++++++++++++++++++++++++ lib/vhost/version.map | 3 +++ lib/vhost/vhost.c | 38 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 82 insertions(+)lib/vhost/rte_vhost.h +0
-0@@ -292,6 +292,30 @@ struct vhost_device_ops {void *reserved[1 ];/**< Reserved for future extension */ };lib/vhost/rte_vhost.h struct vhost_device_ops { · line 304
Quoted 10 lines
lib/vhost/rte_vhost.h +10
-0+/** +* Power monitor condition. +*/ +struct rte_vhost_power_monitor_cond { +volatile void *addr;/**< Address to monitor for changes */ +/**< If the `mask` is non-zero, location pointed +* to by `addr` will be read and compared +* against this value. +*/ +uint64_t val;Will be read and masked, then compared with this value?
lib/vhost/rte_vhost.h struct vhost_device_ops { · line 315
Quoted 11 lines
lib/vhost/rte_vhost.h +11
-0+uint64_t mask;/**< 64-bit mask to extract value read from `addr` */ +/**< Data size (in bytes) that will be read from the +* monitored memory location (`addr`). Can be 1, 2, +* 4, or 8. Supplying any other value will result in +* an error. +*/ +uint8_t size; +/**< If 1, checking if `val` matches something. +* If 0, checking if `val` *doesn't* match a +* particular value. +*/ If 1, and masked value that read from
addrequalsval, drivers can exit the power-saving state.If 0, ....
The overall comment can't make me understand how this struct is used if I read the next patch.
Quoted 6 lines
lib/vhost/rte_vhost.h struct vhost_device_ops { · line 316
Quoted 1 line
lib/vhost/rte_vhost.h +1
-0+uint8_t match;The comment style is a bit messy here. You can make every comment above variable
Definition (like val/size/match ) or make the first line the same as the variable line (like addr/mask).
I will modify them in the next version.
Quoted 2 lines
And please update the release
note(release_20_11.rst), it's a new feature.
I will update it in the next version.
Thanks,
Miao
Quoted 3 lines
Thanks,
Chenbo
PATCH v3 3/5 net/vhost: implement rte_power_monitor API
In reply to Miao LiThis patch implements rte_power_monitor API in vhost PMD to reduce power consumption when no packet come in. According to current semantics of power monitor, this commit adds a callback function to decide whether aborts the sleep by checking current value against the expected value and vhost_get_monitor_addr to provide address to monitor. When no packet come in, the value of address will not be changed and the running core will sleep. Once packets arrive, the value of address will be changed and the running core will wakeup.
--- drivers/net/vhost/rte_eth_vhost.c | 40 +++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+)
drivers/net/vhost/rte_eth_vhost.c +40 -0
@@ -1380,6 +1380,45 @@ eth_rx_queue_count(struct rte_eth_dev *dev, uint16_t rx_queue_id)return rte_vhost_rx_queue_count (vq->vid, vq->virtqueue_id); } +#define CLB_VAL_IDX 0 +#define CLB_MSK_IDX 1 +#define CLB_MATCH_IDX 2 +static int +vhost_monitor_callback (const uint64_t value, +const uint64_t opaque[RTE_POWER_MONITOR_OPAQUE_SZ ]) +{ +const uint64_t m = opaque[CLB_MSK_IDX ]; +const uint64_t v = opaque[CLB_VAL_IDX ]; +const uint64_t c = opaque[CLB_MATCH_IDX ]; + +if (c) +return (value & m) == v ?-1 :0 ; +else +return (value & m) == v ?0 :-1 ; +} + +static int +vhost_get_monitor_addr (void *rx_queue,struct rte_power_monitor_cond *pmc) +{ +struct vhost_queue *vq = rx_queue; +struct rte_vhost_power_monitor_cond vhost_pmc; +int ret; +if (vq ==NULL ) +return -EINVAL ; + ret =rte_vhost_get_monitor_addr (vq->vid, vq->virtqueue_id, + &vhost_pmc); +if (ret <0 ) +return -EINVAL ; + pmc->addr = vhost_pmc.addr; + pmc->opaque[CLB_VAL_IDX ] = vhost_pmc.val; + pmc->opaque[CLB_MSK_IDX ] = vhost_pmc.mask; + pmc->opaque[CLB_MATCH_IDX ] = vhost_pmc.match; + pmc->size = vhost_pmc.size; + pmc->fn = vhost_monitor_callback; + +return 0 ; +} +static const struct eth_dev_ops ops = { .dev_start = eth_dev_start, .dev_stop = eth_dev_stop,
@@ -1399,6 +1438,7 @@ static const struct eth_dev_ops ops = { .xstats_get_names = vhost_dev_xstats_get_names, .rx_queue_intr_enable = eth_rxq_intr_enable, .rx_queue_intr_disable = eth_rxq_intr_disable, + .get_monitor_addr = vhost_get_monitor_addr, }; static int
Signature · 1 line
2.25.1
PATCH v3 4/5 power: modify return of queue_stopped
In reply to Miao LiSince some vdevs like virtio and vhost do not support rxq_info_get and queue state inquiry, the error return value -ENOTSUP need to be ignored when queue_stopped cannot get rx queue information and rx queue state. This patch changes the return value of queue_stopped when rte_eth_rx_queue_info_get return ENOTSUP to support vdevs which cannot provide rx queue information and rx queue state enable power management.
--- lib/power/rte_power_pmd_mgmt.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
lib/power/rte_power_pmd_mgmt.c +7 -2
@@ -382,8 +382,13 @@ queue_stopped(const uint16_t port_id, const uint16_t queue_id) {struct rte_eth_rxq_info qinfo; -if (rte_eth_rx_queue_info_get (port_id, queue_id, &qinfo) <0 ) -return -1 ; +int ret =rte_eth_rx_queue_info_get (port_id, queue_id, &qinfo); +if (ret <0 ) { +if (ret == -ENOTSUP ) +return 1 ; +else +return -1 ; + }return qinfo.queue_state ==RTE_ETH_QUEUE_STATE_STOPPED ; }
Signature · 1 line
2.25.1
Re: [dpdk-dev] [PATCH v3 4/5] power: modify return of queue_stopped
Quoted 40 lines
-----Original Message-----
From: Li, Miao <[email protected]>
Sent: Friday, September 24, 2021 6:23 PM
To: [email protected]
Cc: Xia, Chenbo <[email protected]>; [email protected]; Li, Miao <[email protected]>
Subject: [PATCH v3 4/5] power: modify return ofqueue_stoppedSince some vdevs like virtio and vhost do not support
rxq_info_getand queue state inquiry, the error return value-ENOTSUPneed to be ignored whenqueue_stoppedcannot get rx queue information and rx queue state. This patch changes the return value ofqueue_stoppedwhenrte_eth_rx_queue_info_getreturn ENOTSUP to support vdevs which cannot provide rx queue information and rx queue state enable power management.Signed-off-by Miao Li <[email protected]>--- lib/power/rte_power_pmd_mgmt.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)lib/power/rte_power_pmd_mgmt.c +7
-2@@ -382,8 +382,13 @@ queue_stopped(const uint16_t port_id, const uint16_t queue_id) {struct rte_eth_rxq_info qinfo; -if (rte_eth_rx_queue_info_get (port_id, queue_id, &qinfo) <0 ) -return -1 ; +int ret =rte_eth_rx_queue_info_get (port_id, queue_id, &qinfo); +if (ret <0 ) { +if (ret == -ENOTSUP ) +return 1 ; +else +return -1 ; + }return qinfo.queue_state ==RTE_ETH_QUEUE_STATE_STOPPED ;
Quoted 3 lines
}
--
2.25.1
Anatoly's ACK is missed.
Re: [dpdk-dev] [PATCH v3 4/5] power: modify return of queue_stopped
Hi Chenbo,
Quoted 49 lines
-----Original Message-----
From: Xia, Chenbo <[email protected]>
Sent: Wednesday, September 29, 2021 11:03 AM
To: Li, Miao <[email protected]>; [email protected]
Cc: [email protected]
Subject: RE: [PATCH v3 4/5] power: modify return ofqueue_stoppedQuoted 5 lines
-----Original Message-----
From: Li, Miao <[email protected]>
Sent: Friday, September 24, 2021 6:23 PM
To: [email protected]
Cc: Xia, Chenbo <[email protected]>; [email protected]; Li,Miao
Quoted 10 lines
<[email protected]>
Subject: [PATCH v3 4/5] power: modify return ofqueue_stoppedSince some vdevs like virtio and vhost do not support
rxq_info_getand queue state inquiry, the error return value-ENOTSUPneed to be ignored whenqueue_stoppedcannot get rx queue information and rx queue state. This patch changes the return value ofqueue_stoppedwhenrte_eth_rx_queue_info_getreturn ENOTSUP to support vdevs which cannot provide rx queue information and rx queue state enable power management.Review
Quoted 6 lines
Signed-off-by Miao Li <[email protected]>--- lib/power/rte_power_pmd_mgmt.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)(quoted diff) +0
-0
b/lib/power/rte_power_pmd_mgmt.clib/power/rte_power_pmd_mgmt.c queue_stopped(const uint16_t port_id, const
Quoted 4 lines
index
0ce40f0875..39a2b4cd23100644lib/power/rte_power_pmd_mgmt.c +0
-0@@ -382,8 +382,13 @@ queue_stopped(const uint16_t port_id, const
uint16_tQuoted 14 lines
lib/power/rte_power_pmd_mgmt.c +7
-2queue_id) {struct rte_eth_rxq_info qinfo; -if (rte_eth_rx_queue_info_get (port_id, queue_id, &qinfo) <0 ) -return -1 ; +int ret =rte_eth_rx_queue_info_get (port_id, queue_id, &qinfo); +if (ret <0 ) { +if (ret == -ENOTSUP ) +return 1 ; +else +return -1 ; + }
Quoted 6 lines
Quoted 4 lines
lib/power/rte_power_pmd_mgmt.c +0
-0return qinfo.queue_state ==RTE_ETH_QUEUE_STATE_STOPPED ;}
--
2.25.1Anatoly's ACK is missed.
I will add it in the next version.
Thanks,
Miao
PATCH v3 5/5 examples/l3fwd-power: support virtio/vhost
In reply to Miao LiIn l3fwd-power, there is default port configuration which requires RSS and IPV4/UDP/TCP checksum. Once device does not support these, the l3fwd-power will exit and report an error.
This patch updates the port configuration based on device capabilities after getting the device information to support devices like virtio and vhost.
--- examples/l3fwd-power/main.c | 5 +++++ 1 file changed, 5 insertions(+)
examples/l3fwd-power/main.c +5 -0
@@ -2637,6 +2637,11 @@ main(int argc, char **argv) local_port_conf.rx_adv_conf.rss_conf.rss_hf); } +if (local_port_conf.rx_adv_conf.rss_conf.rss_hf ==0 ) + local_port_conf.rxmode.mq_mode =ETH_MQ_RX_NONE ; + local_port_conf.rxmode.offloads &= dev_info.rx_offload_capa; + port_conf.rxmode.offloads = local_port_conf.rxmode.offloads; + ret =rte_eth_dev_configure (portid, nb_rx_queue, (uint16_t )n_tx_queue, &local_port_conf);if (ret <0 )
Signature · 1 line
2.25.1
Re: [dpdk-dev] [PATCH v3 5/5] examples/l3fwd-power: support virtio/vhost
Quoted 37 lines
-----Original Message-----
From: Li, Miao <[email protected]>
Sent: Friday, September 24, 2021 6:23 PM
To: [email protected]
Cc: Xia, Chenbo <[email protected]>; [email protected]; Li, Miao <[email protected]>
Subject: [PATCH v3 5/5] examples/l3fwd-power: support virtio/vhostIn l3fwd-power, there is default port configuration which requires RSS and IPV4/UDP/TCP checksum. Once device does not support these, the l3fwd-power will exit and report an error.
This patch updates the port configuration based on device capabilities after getting the device information to support devices like virtio and vhost.Signed-off-by Miao Li <[email protected]>--- examples/l3fwd-power/main.c | 5 +++++ 1 file changed, 5 insertions(+)examples/l3fwd-power/main.c +5
-1@@ -2637,6 +2637,11 @@ main(int argc, char **argv) local_port_conf.rx_adv_conf.rss_conf.rss_hf); } +if (local_port_conf.rx_adv_conf.rss_conf.rss_hf ==0 ) + local_port_conf.rxmode.mq_mode =ETH_MQ_RX_NONE ; + local_port_conf.rxmode.offloads &= dev_info.rx_offload_capa; + port_conf.rxmode.offloads = local_port_conf.rxmode.offloads; + ret =rte_eth_dev_configure (portid, nb_rx_queue, (uint16_t )n_tx_queue, &local_port_conf);if (ret <0 ) --
Quoted 1 line
2.25.1
Just as David suggested, I think we'd better consider RFC 1812, if HW does not support RX IP CKSUM offload, check IP CKSUM in is_valid_ipv4_pkt.
Thanks,
Chenbo
Re: [dpdk-dev] [PATCH v3 5/5] examples/l3fwd-power: support virtio/vhost
Hi Chenbo,
Quoted 45 lines
-----Original Message-----
From: Xia, Chenbo <[email protected]>
Sent: Wednesday, September 29, 2021 2:53 PM
To: Li, Miao <[email protected]>; [email protected]
Cc: [email protected]; [email protected]
Subject: RE: [PATCH v3 5/5] examples/l3fwd-power: support virtio/vhostQuoted 5 lines
-----Original Message-----
From: Li, Miao <[email protected]>
Sent: Friday, September 24, 2021 6:23 PM
To: [email protected]
Cc: Xia, Chenbo <[email protected]>; [email protected]; Li,Miao
Quoted 20 lines
<[email protected]>
Subject: [PATCH v3 5/5] examples/l3fwd-power: support virtio/vhostIn l3fwd-power, there is default port configuration which requires RSS and IPV4/UDP/TCP checksum. Once device does not support these, the l3fwd-power will exit and report an error.
This patch updates the port configuration based on device capabilities after getting the device information to support devices like virtio and vhost.Signed-off-by Miao Li <[email protected]>--- examples/l3fwd-power/main.c | 5 +++++ 1 file changed, 5 insertions(+)examples/l3fwd-power/main.c +0
-0examples/l3fwd-power/main.c main(int argc, char **argv) · line 2641
Quoted 5 lines
examples/l3fwd-power/main.c +2
-0@@ -2637,6 +2637,11 @@ main(int argc, char **argv) local_port_conf.rx_adv_conf.rss_conf.rss_hf); } +if (local_port_conf.rx_adv_conf.rss_conf.rss_hf ==0 ) + local_port_conf.rxmode.mq_mode =
ETH_MQ_RX_NONE;examples/l3fwd-power/main.c main(int argc, char **argv)
Quoted 5 lines
examples/l3fwd-power/main.c +3
-0+ local_port_conf.rxmode.offloads &= dev_info.rx_offload_capa; + port_conf.rxmode.offloads = local_port_conf.rxmode.offloads; + ret = rte_eth_dev_configure(portid, nb_rx_queue, (uint16_t)n_tx_queue,
&local_port_conf);
Quoted 6 lines
Quoted 3 lines
examples/l3fwd-power/main.c +0
-1if (ret <0 ) --2.25.1
Just as David suggested, I think we'd better consider RFC 1812, if HW does not support RX IP CKSUM offload, check IP CKSUM in
is_valid_ipv4_pkt.
I will fix it in the next version.
Thanks,
Miao
Quoted 3 lines
Thanks,
Chenbo
v4 cover Implement rte_power_monitor API in virtio/vhost PMD
In reply to Miao LiThis patchset implements rte_power_monitor API in virtio and vhost PMD to reduce power consumption when no packet come in. This API can be called and tested in l3fwd-power after adding vhost and virtio support in l3fwd-power and ignoring the rx queue information check in queue_stopped().
v4:
-modify comment
-update the release note
-add IPv4 CKSUM check
v3:
-fix some code format issues
-fix spelling mistake
v2:
-remove flag and add match and size in rte_vhost_power_monitor_cond -modify power callback function
-add dev and queue id check and remove unnecessary check -fix the assignment of pmc->size
-update port configuration according to the device information and remove adding command line arguments
-modify some titles
Miao Li (5):
net/virtio: implement rte_power_monitor API
vhost: implement rte_power_monitor API
net/vhost: implement rte_power_monitor API
power: modify return of queue_stopped
examples/l3fwd-power: support virtio/vhost
doc/guides/rel_notes/release_21_11.rst | 12 ++++++ drivers/net/vhost/rte_eth_vhost.c | 40 ++++++++++++++++++ drivers/net/virtio/virtio_ethdev.c | 56 ++++++++++++++++++++++++++ examples/l3fwd-power/main.c | 9 ++++- lib/power/rte_power_pmd_mgmt.c | 9 ++++- lib/vhost/rte_vhost.h | 44 ++++++++++++++++++++ lib/vhost/version.map | 3 ++ lib/vhost/vhost.c | 38 +++++++++++++++++ 8 files changed, 208 insertions(+), 3 deletions(-)
Signature · 1 line
2.25.1
PATCH v4 1/5 net/virtio: implement rte_power_monitor API
This patch implements rte_power_monitor API in virtio PMD to reduce power consumption when no packet come in. According to current semantics of power monitor, this commit adds a callback function to decide whether aborts the sleep by checking current value against the expected value and virtio_get_monitor_addr to provide address to monitor. When no packet come in, the value of address will not be changed and the running core will sleep. Once packets arrive, the value of address will be changed and the running core will wakeup.
--- doc/guides/rel_notes/release_21_11.rst | 4 ++ drivers/net/virtio/virtio_ethdev.c | 56 ++++++++++++++++++++++++++ 2 files changed, 60 insertions(+)
doc/guides/rel_notes/release_21_11.rst +4 -0
@@ -67,6 +67,10 @@ New Features Added macros ETH_RSS_IPV4_CHKSUM and ETH_RSS_L4_CHKSUM, now IPv4 and TCP/UDP/SCTP header checksum field can be used as input set for RSS. +* **Updated virtio PMD.** + + Implement rte_power_monitor API in virtio PMD. + * **Updated Broadcom bnxt PMD.** * Added flow offload support for Thor.
drivers/net/virtio/virtio_ethdev.c +56 -0
74 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v4 2/5 vhost: implement rte_power_monitor API
In reply to Miao LiThis patch defines rte_vhost_power_monitor_cond which is used to pass some information to vhost driver. The information is including the address to monitor, the expected value, the mask to extract value read from 'addr', the value size of monitor address, the match flag used to distinguish the value used to match something or not match something. Vhost driver can use these information to fill rte_power_monitor_cond.
--- doc/guides/rel_notes/release_21_11.rst | 4 +++ lib/vhost/rte_vhost.h | 44 ++++++++++++++++++++++++++ lib/vhost/version.map | 3 ++ lib/vhost/vhost.c | 38 ++++++++++++++++++++++ 4 files changed, 89 insertions(+)
doc/guides/rel_notes/release_21_11.rst +4 -0
@@ -67,6 +67,10 @@ New Features Added macros ETH_RSS_IPV4_CHKSUM and ETH_RSS_L4_CHKSUM, now IPv4 and TCP/UDP/SCTP header checksum field can be used as input set for RSS. +* **Added power monitor API in vhost library.** + + Added an API to support power monitor in vhost library. + * **Updated virtio PMD.** Implement rte_power_monitor API in virtio PMD.
lib/vhost/rte_vhost.h +44 -0
56 lines not on this page · raw message
lib/vhost/version.map +3 -0
@@ -85,4 +85,7 @@ EXPERIMENTAL { rte_vhost_async_channel_register_thread_unsafe; rte_vhost_async_channel_unregister_thread_unsafe; rte_vhost_clear_queue_thread_unsafe; + + # added in 21.11 + rte_vhost_get_monitor_addr; };
lib/vhost/vhost.c +38 -0
@@ -1889,5 +1889,43 @@ rte_vhost_async_get_inflight(int vid, uint16_t queue_id)return ret; } +int +rte_vhost_get_monitor_addr (int vid,uint16_t queue_id, +struct rte_vhost_power_monitor_cond *pmc) +{ +struct virtio_net *dev =get_device (vid); +struct vhost_virtqueue *vq; + +if (dev ==NULL ) +return -1 ; +if (queue_id >=VHOST_MAX_VRING ) +return -1 ; + + vq = dev->virtqueue[queue_id]; +if (vq ==NULL ) +return -1 ; + +if (vq_is_packed (dev)) { +struct vring_packed_desc *desc; + desc = vq->desc_packed; + pmc->addr = &desc[vq->last_avail_idx].flags; +if (vq->avail_wrap_counter) + pmc->val =VRING_DESC_F_AVAIL ; +else + pmc->val =VRING_DESC_F_USED ; + pmc->mask =VRING_DESC_F_AVAIL |VRING_DESC_F_USED ; + pmc->size =sizeof (desc[vq->last_avail_idx].flags); + pmc->match =1 ; + }else { + pmc->addr = &vq->avail->idx; + pmc->val = vq->last_avail_idx & (vq->size -1 ); + pmc->mask = vq->size -1 ; + pmc->size =sizeof (vq->avail->idx); + pmc->match =0 ; + } + +return 0 ; +} +RTE_LOG_REGISTER_SUFFIX (vhost_config_log_level, config,INFO );RTE_LOG_REGISTER_SUFFIX (vhost_data_log_level, data,WARNING );
Signature · 1 line
2.25.1
PATCH v4 3/5 net/vhost: implement rte_power_monitor API
In reply to Miao LiThis patch implements rte_power_monitor API in vhost PMD to reduce power consumption when no packet come in. According to current semantics of power monitor, this commit adds a callback function to decide whether aborts the sleep by checking current value against the expected value and vhost_get_monitor_addr to provide address to monitor. When no packet come in, the value of address will not be changed and the running core will sleep. Once packets arrive, the value of address will be changed and the running core will wakeup.
--- doc/guides/rel_notes/release_21_11.rst | 4 +++ drivers/net/vhost/rte_eth_vhost.c | 40 ++++++++++++++++++++++++++ 2 files changed, 44 insertions(+)
doc/guides/rel_notes/release_21_11.rst +4 -0
@@ -71,6 +71,10 @@ New Features Added an API to support power monitor in vhost library. +* **Updated vhost PMD.** + + Implement rte_power_monitor API in vhost PMD. + * **Updated virtio PMD.** Implement rte_power_monitor API in virtio PMD.
drivers/net/vhost/rte_eth_vhost.c +40 -0
@@ -1380,6 +1380,45 @@ eth_rx_queue_count(struct rte_eth_dev *dev, uint16_t rx_queue_id)return rte_vhost_rx_queue_count (vq->vid, vq->virtqueue_id); } +#define CLB_VAL_IDX 0 +#define CLB_MSK_IDX 1 +#define CLB_MATCH_IDX 2 +static int +vhost_monitor_callback (const uint64_t value, +const uint64_t opaque[RTE_POWER_MONITOR_OPAQUE_SZ ]) +{ +const uint64_t m = opaque[CLB_MSK_IDX ]; +const uint64_t v = opaque[CLB_VAL_IDX ]; +const uint64_t c = opaque[CLB_MATCH_IDX ]; + +if (c) +return (value & m) == v ?-1 :0 ; +else +return (value & m) == v ?0 :-1 ; +} + +static int +vhost_get_monitor_addr (void *rx_queue,struct rte_power_monitor_cond *pmc) +{ +struct vhost_queue *vq = rx_queue; +struct rte_vhost_power_monitor_cond vhost_pmc; +int ret; +if (vq ==NULL ) +return -EINVAL ; + ret =rte_vhost_get_monitor_addr (vq->vid, vq->virtqueue_id, + &vhost_pmc); +if (ret <0 ) +return -EINVAL ; + pmc->addr = vhost_pmc.addr; + pmc->opaque[CLB_VAL_IDX ] = vhost_pmc.val; + pmc->opaque[CLB_MSK_IDX ] = vhost_pmc.mask; + pmc->opaque[CLB_MATCH_IDX ] = vhost_pmc.match; + pmc->size = vhost_pmc.size; + pmc->fn = vhost_monitor_callback; + +return 0 ; +} +static const struct eth_dev_ops ops = { .dev_start = eth_dev_start, .dev_stop = eth_dev_stop,
@@ -1399,6 +1438,7 @@ static const struct eth_dev_ops ops = { .xstats_get_names = vhost_dev_xstats_get_names, .rx_queue_intr_enable = eth_rxq_intr_enable, .rx_queue_intr_disable = eth_rxq_intr_disable, + .get_monitor_addr = vhost_get_monitor_addr, }; static int
Signature · 1 line
2.25.1
PATCH v4 4/5 power: modify return of queue_stopped
In reply to Miao LiSince some vdevs like virtio and vhost do not support rxq_info_get and queue state inquiry, the error return value -ENOTSUP need to be ignored when queue_stopped cannot get rx queue information and rx queue state. This patch changes the return value of queue_stopped when rte_eth_rx_queue_info_get return ENOTSUP to support vdevs which cannot provide rx queue information and rx queue state enable power management.
--- lib/power/rte_power_pmd_mgmt.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
lib/power/rte_power_pmd_mgmt.c +7 -2
@@ -382,8 +382,13 @@ queue_stopped(const uint16_t port_id, const uint16_t queue_id) {struct rte_eth_rxq_info qinfo; -if (rte_eth_rx_queue_info_get (port_id, queue_id, &qinfo) <0 ) -return -1 ; +int ret =rte_eth_rx_queue_info_get (port_id, queue_id, &qinfo); +if (ret <0 ) { +if (ret == -ENOTSUP ) +return 1 ; +else +return -1 ; + }return qinfo.queue_state ==RTE_ETH_QUEUE_STATE_STOPPED ; }
Signature · 1 line
2.25.1
PATCH v4 5/5 examples/l3fwd-power: support virtio/vhost
In reply to Miao LiIn l3fwd-power, there is default port configuration which requires RSS and IPV4/UDP/TCP checksum. Once device does not support these, the l3fwd-power will exit and report an error.
This patch updates the port configuration based on device capabilities after getting the device information to support devices like virtio and vhost.
--- examples/l3fwd-power/main.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
examples/l3fwd-power/main.c +8 -1
@@ -505,7 +505,9 @@ is_valid_ipv4_pkt(struct rte_ipv4_hdr *pkt, uint32_t link_len)return -1 ;/* 2. The IP checksum must be correct. */ -/* this is checked in H/W */ +/* if this is not checked in H/W, check it. */ +if ((port_conf.rxmode.offloads &DEV_RX_OFFLOAD_IPV4_CKSUM ) ==0 ) +rte_ipv4_cksum (pkt);/* * 3. The IP version number must be 4. If the version number is not 4
@@ -2637,6 +2639,11 @@ main(int argc, char **argv) local_port_conf.rx_adv_conf.rss_conf.rss_hf); } +if (local_port_conf.rx_adv_conf.rss_conf.rss_hf ==0 ) + local_port_conf.rxmode.mq_mode =ETH_MQ_RX_NONE ; + local_port_conf.rxmode.offloads &= dev_info.rx_offload_capa; + port_conf.rxmode.offloads = local_port_conf.rxmode.offloads; + ret =rte_eth_dev_configure (portid, nb_rx_queue, (uint16_t )n_tx_queue, &local_port_conf);if (ret <0 )
Signature · 1 line
2.25.1
v5 cover Implement rte_power_monitor API in virtio/vhost PMD
In reply to Miao LiThis patchset implements rte_power_monitor API in virtio and vhost PMD to reduce power consumption when no packet come in. This API can be called and tested in l3fwd-power after adding vhost and virtio support in l3fwd-power and ignoring the rx queue information check in queue_stopped().
v5:
-Rebase on lastest repo
v4:
-modify comment
-update the release note
-add IPv4 CKSUM check
v3:
-fix some code format issues
-fix spelling mistake
v2:
-remove flag and add match and size in rte_vhost_power_monitor_cond -modify power callback function
-add dev and queue id check and remove unnecessary check -fix the assignment of pmc->size
-update port configuration according to the device information and remove adding command line arguments
-modify some titles
Miao Li (5):
net/virtio: implement rte_power_monitor API
vhost: implement rte_power_monitor API
net/vhost: implement rte_power_monitor API
power: modify return of queue_stopped
examples/l3fwd-power: support virtio/vhost
doc/guides/rel_notes/release_21_11.rst | 12 ++++++ drivers/net/vhost/rte_eth_vhost.c | 40 ++++++++++++++++++ drivers/net/virtio/virtio_ethdev.c | 56 ++++++++++++++++++++++++++ examples/l3fwd-power/main.c | 9 ++++- lib/power/rte_power_pmd_mgmt.c | 9 ++++- lib/vhost/rte_vhost.h | 44 ++++++++++++++++++++ lib/vhost/version.map | 3 ++ lib/vhost/vhost.c | 38 +++++++++++++++++ 8 files changed, 208 insertions(+), 3 deletions(-)
Signature · 1 line
2.25.1
PATCH v5 1/5 net/virtio: implement rte_power_monitor API
This patch implements rte_power_monitor API in virtio PMD to reduce power consumption when no packet come in. According to current semantics of power monitor, this commit adds a callback function to decide whether aborts the sleep by checking current value against the expected value and virtio_get_monitor_addr to provide address to monitor. When no packet come in, the value of address will not be changed and the running core will sleep. Once packets arrive, the value of address will be changed and the running core will wakeup.
--- doc/guides/rel_notes/release_21_11.rst | 4 ++ drivers/net/virtio/virtio_ethdev.c | 56 ++++++++++++++++++++++++++ 2 files changed, 60 insertions(+)
doc/guides/rel_notes/release_21_11.rst +4 -0
@@ -72,6 +72,10 @@ New Features Added macros ETH_RSS_IPV4_CHKSUM and ETH_RSS_L4_CHKSUM, now IPv4 and TCP/UDP/SCTP header checksum field can be used as input set for RSS. +* **Updated virtio PMD.** + + Implement rte_power_monitor API in virtio PMD. + * **Updated af_packet ethdev driver.** * Default VLAN strip behavior was changed. VLAN tag won't be stripped
drivers/net/virtio/virtio_ethdev.c +56 -0
74 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v5 2/5 vhost: implement rte_power_monitor API
In reply to Miao LiThis patch defines rte_vhost_power_monitor_cond which is used to pass some information to vhost driver. The information is including the address to monitor, the expected value, the mask to extract value read from 'addr', the value size of monitor address, the match flag used to distinguish the value used to match something or not match something. Vhost driver can use these information to fill rte_power_monitor_cond.
--- doc/guides/rel_notes/release_21_11.rst | 4 +++ lib/vhost/rte_vhost.h | 44 ++++++++++++++++++++++++++ lib/vhost/version.map | 3 ++ lib/vhost/vhost.c | 38 ++++++++++++++++++++++ 4 files changed, 89 insertions(+)
doc/guides/rel_notes/release_21_11.rst +4 -0
@@ -72,6 +72,10 @@ New Features Added macros ETH_RSS_IPV4_CHKSUM and ETH_RSS_L4_CHKSUM, now IPv4 and TCP/UDP/SCTP header checksum field can be used as input set for RSS. +* **Added power monitor API in vhost library.** + + Added an API to support power monitor in vhost library. + * **Updated virtio PMD.** Implement rte_power_monitor API in virtio PMD.
lib/vhost/rte_vhost.h +44 -0
56 lines not on this page · raw message
lib/vhost/version.map +3 -0
@@ -85,4 +85,7 @@ EXPERIMENTAL { rte_vhost_async_channel_register_thread_unsafe; rte_vhost_async_channel_unregister_thread_unsafe; rte_vhost_clear_queue_thread_unsafe; + + # added in 21.11 + rte_vhost_get_monitor_addr; };
lib/vhost/vhost.c +38 -0
@@ -1889,5 +1889,43 @@ rte_vhost_async_get_inflight(int vid, uint16_t queue_id)return ret; } +int +rte_vhost_get_monitor_addr (int vid,uint16_t queue_id, +struct rte_vhost_power_monitor_cond *pmc) +{ +struct virtio_net *dev =get_device (vid); +struct vhost_virtqueue *vq; + +if (dev ==NULL ) +return -1 ; +if (queue_id >=VHOST_MAX_VRING ) +return -1 ; + + vq = dev->virtqueue[queue_id]; +if (vq ==NULL ) +return -1 ; + +if (vq_is_packed (dev)) { +struct vring_packed_desc *desc; + desc = vq->desc_packed; + pmc->addr = &desc[vq->last_avail_idx].flags; +if (vq->avail_wrap_counter) + pmc->val =VRING_DESC_F_AVAIL ; +else + pmc->val =VRING_DESC_F_USED ; + pmc->mask =VRING_DESC_F_AVAIL |VRING_DESC_F_USED ; + pmc->size =sizeof (desc[vq->last_avail_idx].flags); + pmc->match =1 ; + }else { + pmc->addr = &vq->avail->idx; + pmc->val = vq->last_avail_idx & (vq->size -1 ); + pmc->mask = vq->size -1 ; + pmc->size =sizeof (vq->avail->idx); + pmc->match =0 ; + } + +return 0 ; +} +RTE_LOG_REGISTER_SUFFIX (vhost_config_log_level, config,INFO );RTE_LOG_REGISTER_SUFFIX (vhost_data_log_level, data,WARNING );
Signature · 1 line
2.25.1
Re: [dpdk-dev] [PATCH v5 2/5] vhost: implement rte_power_monitor API
Hi,
Quoted 54 lines
-----Original Message-----
From: Li, Miao <[email protected]>
Sent: Friday, October 15, 2021 11:12 PM
To: [email protected]
Cc: Xia, Chenbo <[email protected]>; [email protected]; Li, Miao <[email protected]>
Subject: [PATCH v5 2/5] vhost: implementrte_power_monitorAPIThis patch defines
rte_vhost_power_monitor_condwhich is used to pass some information to vhost driver. The information is including the address to monitor, the expected value, the mask to extract value read from 'addr', the value size of monitor address, the match flag used to distinguish the value used to match something or not match something. Vhost driver can use these information to fillrte_power_monitor_cond.Signed-off-by Miao Li <[email protected]>--- doc/guides/rel_notes/release_21_11.rst | 4 +++ lib/vhost/rte_vhost.h | 44 ++++++++++++++++++++++++++ lib/vhost/version.map | 3 ++ lib/vhost/vhost.c | 38 ++++++++++++++++++++++ 4 files changed, 89 insertions(+)doc/guides/rel_notes/release_21_11.rst +4
-0@@ -72,6 +72,10 @@ New Features Added macros ETH_RSS_IPV4_CHKSUM and ETH_RSS_L4_CHKSUM, now IPv4 and TCP/UDP/SCTP header checksum field can be used as input set for RSS. +* **Added power monitor API in vhost library.** + + Added an API to support power monitor in vhost library. + * **Updated virtio PMD.** Implement rte_power_monitor API in virtio PMD.lib/vhost/rte_vhost.h +7
-0@@ -292,6 +292,33 @@ struct vhost_device_ops {void *reserved[1 ];/**< Reserved for future extension */ }; +/** +* Power monitor condition. +*/ +struct rte_vhost_power_monitor_cond { +/**< Address to monitor for changes */ +volatile void *addr; +/**< If the `mask` is non-zero, location pointed
lib/vhost/rte_vhost.h struct vhost_device_ops { · line 311
Quoted 10 lines
lib/vhost/rte_vhost.h +10
-0+* to by `addr` will be read and masked, then +* compared with this value. +*/ +uint64_t val; +/**< 64-bit mask to extract value read from `addr` */ +uint64_t mask; +/**< Data size (in bytes) that will be read from the +* monitored memory location (`addr`). Can be 1, 2, +* 4, or 8. Supplying any other value will result in +* an error.
'Can be ...' part is not necessary, as this value is defined in vhost lib and currently only has two different values for packed or split.
lib/vhost/rte_vhost.h struct vhost_device_ops { · line 315
Quoted 4 lines
lib/vhost/rte_vhost.h +4
-0+*/ +uint8_t size; +/**< If 1, and masked value that read from 'addr' equals +* 'val', the driver will skip core sleep. If 0, and
'will' -> 'should'. As it's a suggestion for vhost driver.
lib/vhost/rte_vhost.h struct vhost_device_ops { · line 317
Quoted 2 lines
lib/vhost/rte_vhost.h +2
-0+* masked value that read from 'addr' does not equal 'val', +* the driver will skip core sleep.
Ditto.
Thanks,
Chenbo
Quoted 93 lines
lib/vhost/rte_vhost.h +21
-0+*/ +uint8_t match; +}; +/** * Convert guest physical address to host virtual address * @@ -903,6 +930,23 @@ int rte_vhost_vring_call(int vid, uint16_t vring_idx);*/ uint32_t rte_vhost_rx_queue_count (int vid,uint16_t qid); +/** +* Get power monitor address of the vhost device +* +* @param vid +* vhost device ID +* @param queue_id +* vhost queue ID +* @param pmc +* power monitor condition +* @return +* 0 on success, -1 on failure +*/ +__rte_experimental +int +rte_vhost_get_monitor_addr (int vid,uint16_t queue_id, +struct rte_vhost_power_monitor_cond *pmc); +/** * Get log base and log size of the vhost device * lib/vhost/version.map +3
-0@@ -85,4 +85,7 @@ EXPERIMENTAL { rte_vhost_async_channel_register_thread_unsafe; rte_vhost_async_channel_unregister_thread_unsafe; rte_vhost_clear_queue_thread_unsafe; + + # added in 21.11 + rte_vhost_get_monitor_addr; };lib/vhost/vhost.c +38
-1@@ -1889,5 +1889,43 @@ rte_vhost_async_get_inflight(int vid, uint16_t queue_id)return ret; } +int +rte_vhost_get_monitor_addr (int vid,uint16_t queue_id, +struct rte_vhost_power_monitor_cond *pmc) +{ +struct virtio_net *dev =get_device (vid); +struct vhost_virtqueue *vq; + +if (dev ==NULL ) +return -1 ; +if (queue_id >=VHOST_MAX_VRING ) +return -1 ; + + vq = dev->virtqueue[queue_id]; +if (vq ==NULL ) +return -1 ; + +if (vq_is_packed (dev)) { +struct vring_packed_desc *desc; + desc = vq->desc_packed; + pmc->addr = &desc[vq->last_avail_idx].flags; +if (vq->avail_wrap_counter) + pmc->val =VRING_DESC_F_AVAIL ; +else + pmc->val =VRING_DESC_F_USED ; + pmc->mask =VRING_DESC_F_AVAIL |VRING_DESC_F_USED ; + pmc->size =sizeof (desc[vq->last_avail_idx].flags); + pmc->match =1 ; + }else { + pmc->addr = &vq->avail->idx; + pmc->val = vq->last_avail_idx & (vq->size -1 ); + pmc->mask = vq->size -1 ; + pmc->size =sizeof (vq->avail->idx); + pmc->match =0 ; + } + +return 0 ; +} +RTE_LOG_REGISTER_SUFFIX (vhost_config_log_level, config,INFO );RTE_LOG_REGISTER_SUFFIX (vhost_data_log_level, data,WARNING ); --2.25.1
Re: [dpdk-dev] [PATCH v5 2/5] vhost: implement rte_power_monitor API
Hi Chenbo,
Quoted 70 lines
-----Original Message-----
From: Xia, Chenbo <[email protected]>
Sent: Friday, October 15, 2021 3:38 PM
To: Li, Miao <[email protected]>; [email protected]
Cc: [email protected]
Subject: RE: [PATCH v5 2/5] vhost: implementrte_power_monitorAPIHi,
Quoted 5 lines
-----Original Message-----
From: Li, Miao <[email protected]>
Sent: Friday, October 15, 2021 11:12 PM
To: [email protected]
Cc: Xia, Chenbo <[email protected]>; [email protected]; Li,Miao
Quoted 24 lines
<[email protected]>
Subject: [PATCH v5 2/5] vhost: implementrte_power_monitorAPIThis patch defines
rte_vhost_power_monitor_condwhich is used to pass some information to vhost driver. The information is including the address to monitor, the expected value, the mask to extract value read from 'addr', the value size of monitor address, the match flag used to distinguish the value used to match something or not match something. Vhost driver can use these information to fillrte_power_monitor_cond.Signed-off-by Miao Li <[email protected]>--- doc/guides/rel_notes/release_21_11.rst | 4 +++ lib/vhost/rte_vhost.h | 44 ++++++++++++++++++++++++++ lib/vhost/version.map | 3 ++ lib/vhost/vhost.c | 38 ++++++++++++++++++++++ 4 files changed, 89 insertions(+)doc/guides/rel_notes/release_21_11.rst +0
-0doc/guides/rel_notes/release_21_11.rst New Features · line 72
Quoted 1 line
doc/guides/rel_notes/release_21_11.rst +0
-0@@ -72,6 +72,10 @@ New Features Added macros ETH_RSS_IPV4_CHKSUM and ETH_RSS_L4_CHKSUM, now IPv4and
Quoted 29 lines
doc/guides/rel_notes/release_21_11.rst +4
-0TCP/UDP/SCTP header checksum field can be used as input set for RSS. +* **Added power monitor API in vhost library.** + + Added an API to support power monitor in vhost library. + * **Updated virtio PMD.** Implement rte_power_monitor API in virtio PMD.lib/vhost/rte_vhost.h +12
-0@@ -292,6 +292,33 @@ struct vhost_device_ops {void *reserved[1 ];/**< Reserved for future extension */ }; +/** +* Power monitor condition. +*/ +struct rte_vhost_power_monitor_cond { +/**< Address to monitor for changes */ +volatile void *addr; +/**< If the `mask` is non-zero, location pointed +* to by `addr` will be read and masked, then +* compared with this value. +*/ +uint64_t val; +/**< 64-bit mask to extract value read from `addr` */
Quoted 8 lines
lib/vhost/rte_vhost.h struct vhost_device_ops { · line 311
Quoted 5 lines
lib/vhost/rte_vhost.h +5
-0+uint64_t mask; +/**< Data size (in bytes) that will be read from the +* monitored memory location (`addr`). Can be 1, 2, +* 4, or 8. Supplying any other value will result in +* an error. 'Can be ...' part is not necessary, as this value is defined in vhost lib and currently only has two different values for packed or split.
I will remove it in the next version.
Quoted 8 lines
lib/vhost/rte_vhost.h struct vhost_device_ops { · line 315
Quoted 5 lines
lib/vhost/rte_vhost.h +4
-0+*/ +uint8_t size; +/**< If 1, and masked value that read from 'addr' equals +* 'val', the driver will skip core sleep. If 0, and 'will' -> 'should'. As it's a suggestion for vhost driver.
Quoted 4 lines
lib/vhost/rte_vhost.h struct vhost_device_ops { · line 317
Quoted 2 lines
lib/vhost/rte_vhost.h +2
-0+* masked value that read from 'addr' does not equal 'val', +* the driver will skip core sleep. Ditto.
I will modify them in the next version.
Thanks,
Miao
Quoted 98 lines
Thanks,
Chenbolib/vhost/vhost.c rte_vhost_async_get_inflight(int vid, uint16_t
Quoted 48 lines
lib/vhost/rte_vhost.h +21
-0+*/ +uint8_t match; +}; +/** * Convert guest physical address to host virtual address * @@ -903,6 +930,23 @@ int rte_vhost_vring_call(int vid, uint16_t vring_idx);*/ uint32_t rte_vhost_rx_queue_count (int vid,uint16_t qid); +/** +* Get power monitor address of the vhost device +* +* @param vid +* vhost device ID +* @param queue_id +* vhost queue ID +* @param pmc +* power monitor condition +* @return +* 0 on success, -1 on failure +*/ +__rte_experimental +int +rte_vhost_get_monitor_addr (int vid,uint16_t queue_id, +struct rte_vhost_power_monitor_cond *pmc); +/** * Get log base and log size of the vhost device * lib/vhost/version.map +3
-0@@ -85,4 +85,7 @@ EXPERIMENTAL { rte_vhost_async_channel_register_thread_unsafe; rte_vhost_async_channel_unregister_thread_unsafe; rte_vhost_clear_queue_thread_unsafe; + + # added in 21.11 + rte_vhost_get_monitor_addr; };lib/vhost/vhost.c +0
-0@@ -1889,5 +1889,43 @@ rte_vhost_async_get_inflight(int vid, uint16_t
queue_id)Quoted 45 lines
lib/vhost/vhost.c +38
-1return ret; } +int +rte_vhost_get_monitor_addr (int vid,uint16_t queue_id, +struct rte_vhost_power_monitor_cond *pmc) +{ +struct virtio_net *dev =get_device (vid); +struct vhost_virtqueue *vq; + +if (dev ==NULL ) +return -1 ; +if (queue_id >=VHOST_MAX_VRING ) +return -1 ; + + vq = dev->virtqueue[queue_id]; +if (vq ==NULL ) +return -1 ; + +if (vq_is_packed (dev)) { +struct vring_packed_desc *desc; + desc = vq->desc_packed; + pmc->addr = &desc[vq->last_avail_idx].flags; +if (vq->avail_wrap_counter) + pmc->val =VRING_DESC_F_AVAIL ; +else + pmc->val =VRING_DESC_F_USED ; + pmc->mask =VRING_DESC_F_AVAIL |VRING_DESC_F_USED ; + pmc->size =sizeof (desc[vq->last_avail_idx].flags); + pmc->match =1 ; + }else { + pmc->addr = &vq->avail->idx; + pmc->val = vq->last_avail_idx & (vq->size -1 ); + pmc->mask = vq->size -1 ; + pmc->size =sizeof (vq->avail->idx); + pmc->match =0 ; + } + +return 0 ; +} +RTE_LOG_REGISTER_SUFFIX (vhost_config_log_level, config,INFO );RTE_LOG_REGISTER_SUFFIX (vhost_data_log_level, data,WARNING ); --2.25.1
PATCH v5 3/5 net/vhost: implement rte_power_monitor API
In reply to Miao LiThis patch implements rte_power_monitor API in vhost PMD to reduce power consumption when no packet come in. According to current semantics of power monitor, this commit adds a callback function to decide whether aborts the sleep by checking current value against the expected value and vhost_get_monitor_addr to provide address to monitor. When no packet come in, the value of address will not be changed and the running core will sleep. Once packets arrive, the value of address will be changed and the running core will wakeup.
--- doc/guides/rel_notes/release_21_11.rst | 4 +++ drivers/net/vhost/rte_eth_vhost.c | 40 ++++++++++++++++++++++++++ 2 files changed, 44 insertions(+)
doc/guides/rel_notes/release_21_11.rst +4 -0
@@ -76,6 +76,10 @@ New Features Added an API to support power monitor in vhost library. +* **Updated vhost PMD.** + + Implement rte_power_monitor API in vhost PMD. + * **Updated virtio PMD.** Implement rte_power_monitor API in virtio PMD.
drivers/net/vhost/rte_eth_vhost.c +40 -0
@@ -1386,6 +1386,45 @@ eth_rx_queue_count(struct rte_eth_dev *dev, uint16_t rx_queue_id)return rte_vhost_rx_queue_count (vq->vid, vq->virtqueue_id); } +#define CLB_VAL_IDX 0 +#define CLB_MSK_IDX 1 +#define CLB_MATCH_IDX 2 +static int +vhost_monitor_callback (const uint64_t value, +const uint64_t opaque[RTE_POWER_MONITOR_OPAQUE_SZ ]) +{ +const uint64_t m = opaque[CLB_MSK_IDX ]; +const uint64_t v = opaque[CLB_VAL_IDX ]; +const uint64_t c = opaque[CLB_MATCH_IDX ]; + +if (c) +return (value & m) == v ?-1 :0 ; +else +return (value & m) == v ?0 :-1 ; +} + +static int +vhost_get_monitor_addr (void *rx_queue,struct rte_power_monitor_cond *pmc) +{ +struct vhost_queue *vq = rx_queue; +struct rte_vhost_power_monitor_cond vhost_pmc; +int ret; +if (vq ==NULL ) +return -EINVAL ; + ret =rte_vhost_get_monitor_addr (vq->vid, vq->virtqueue_id, + &vhost_pmc); +if (ret <0 ) +return -EINVAL ; + pmc->addr = vhost_pmc.addr; + pmc->opaque[CLB_VAL_IDX ] = vhost_pmc.val; + pmc->opaque[CLB_MSK_IDX ] = vhost_pmc.mask; + pmc->opaque[CLB_MATCH_IDX ] = vhost_pmc.match; + pmc->size = vhost_pmc.size; + pmc->fn = vhost_monitor_callback; + +return 0 ; +} +static const struct eth_dev_ops ops = { .dev_start = eth_dev_start, .dev_stop = eth_dev_stop,
@@ -1405,6 +1444,7 @@ static const struct eth_dev_ops ops = { .xstats_get_names = vhost_dev_xstats_get_names, .rx_queue_intr_enable = eth_rxq_intr_enable, .rx_queue_intr_disable = eth_rxq_intr_disable, + .get_monitor_addr = vhost_get_monitor_addr, }; static int
Signature · 1 line
2.25.1
Re: [dpdk-dev] [PATCH v5 3/5] net/vhost: implement rte_power_monitor API
Quoted 92 lines
-----Original Message-----
From: Li, Miao <[email protected]>
Sent: Friday, October 15, 2021 11:12 PM
To: [email protected]
Cc: Xia, Chenbo <[email protected]>; [email protected]; Li, Miao <[email protected]>
Subject: [PATCH v5 3/5] net/vhost: implementrte_power_monitorAPIThis patch implements
rte_power_monitorAPI in vhost PMD to reduce power consumption when no packet come in. According to current semantics of power monitor, this commit adds a callback function to decide whether aborts the sleep by checking current value against the expected value andvhost_get_monitor_addrto provide address to monitor. When no packet come in, the value of address will not be changed and the running core will sleep. Once packets arrive, the value of address will be changed and the running core will wakeup.Signed-off-by Miao Li <[email protected]>--- doc/guides/rel_notes/release_21_11.rst | 4 +++ drivers/net/vhost/rte_eth_vhost.c | 40 ++++++++++++++++++++++++++ 2 files changed, 44 insertions(+)doc/guides/rel_notes/release_21_11.rst +4
-0@@ -76,6 +76,10 @@ New Features Added an API to support power monitor in vhost library. +* **Updated vhost PMD.** + + Implement rte_power_monitor API in vhost PMD. + * **Updated virtio PMD.** Implement rte_power_monitor API in virtio PMD.drivers/net/vhost/rte_eth_vhost.c +39
-0@@ -1386,6 +1386,45 @@ eth_rx_queue_count(struct rte_eth_dev *dev, uint16_t rx_queue_id)return rte_vhost_rx_queue_count (vq->vid, vq->virtqueue_id); } +#define CLB_VAL_IDX 0 +#define CLB_MSK_IDX 1 +#define CLB_MATCH_IDX 2 +static int +vhost_monitor_callback (const uint64_t value, +const uint64_t opaque[RTE_POWER_MONITOR_OPAQUE_SZ ]) +{ +const uint64_t m = opaque[CLB_MSK_IDX ]; +const uint64_t v = opaque[CLB_VAL_IDX ]; +const uint64_t c = opaque[CLB_MATCH_IDX ]; + +if (c) +return (value & m) == v ?-1 :0 ; +else +return (value & m) == v ?0 :-1 ; +} + +static int +vhost_get_monitor_addr (void *rx_queue,struct rte_power_monitor_cond *pmc) +{ +struct vhost_queue *vq = rx_queue; +struct rte_vhost_power_monitor_cond vhost_pmc; +int ret; +if (vq ==NULL ) +return -EINVAL ; + ret =rte_vhost_get_monitor_addr (vq->vid, vq->virtqueue_id, + &vhost_pmc); +if (ret <0 ) +return -EINVAL ; + pmc->addr = vhost_pmc.addr; + pmc->opaque[CLB_VAL_IDX ] = vhost_pmc.val; + pmc->opaque[CLB_MSK_IDX ] = vhost_pmc.mask; + pmc->opaque[CLB_MATCH_IDX ] = vhost_pmc.match; + pmc->size = vhost_pmc.size; + pmc->fn = vhost_monitor_callback; + +return 0 ; +} +static const struct eth_dev_ops ops = { .dev_start = eth_dev_start,drivers/net/vhost/rte_eth_vhost.c +0
-0.dev_stop = eth_dev_stop,
drivers/net/vhost/rte_eth_vhost.c static const struct eth_dev_ops ops = { · line 1447
Quoted 4 lines
drivers/net/vhost/rte_eth_vhost.c +1
-0@@ -1405,6 +1444,7 @@ static const struct eth_dev_ops ops = { .xstats_get_names = vhost_dev_xstats_get_names, .rx_queue_intr_enable = eth_rxq_intr_enable, .rx_queue_intr_disable = eth_rxq_intr_disable, + .get_monitor_addr = vhost_get_monitor_addr,
Please align the format with above callbacks: one space is enough after 'get_monitor_addr'
Thanks,
Chenbo
Quoted 5 lines
drivers/net/vhost/rte_eth_vhost.c +0
-1}; static int --2.25.1
Re: [dpdk-dev] [PATCH v5 3/5] net/vhost: implement rte_power_monitor API
Hi Chenbo,
Quoted 102 lines
-----Original Message-----
From: Xia, Chenbo <[email protected]>
Sent: Friday, October 15, 2021 3:40 PM
To: Li, Miao <[email protected]>; [email protected]
Cc: [email protected]
Subject: RE: [PATCH v5 3/5] net/vhost: implementrte_power_monitorAPIQuoted 5 lines
-----Original Message-----
From: Li, Miao <[email protected]>
Sent: Friday, October 15, 2021 11:12 PM
To: [email protected]
Cc: Xia, Chenbo <[email protected]>; [email protected]; Li,Miao
Quoted 8 lines
<[email protected]>
Subject: [PATCH v5 3/5] net/vhost: implementrte_power_monitorAPIThis patch implements
rte_power_monitorAPI in vhost PMD to reduce power consumption when no packet come in. According to current semantics of power monitor, this commit adds a callback function to decide whether aborts the sleep by checking current value against the expected value andvhost_get_monitor_addrto provide address to monitor. When no packetcome
drivers/net/vhost/rte_eth_vhost.c eth_rx_queue_count(struct rte_eth_dev *dev,
Quoted 32 lines
in, the value of address will not be changed and the running core will sleep. Once packets arrive, the value of address will be changed and the running core will wakeup.
Signed-off-by Miao Li <[email protected]>--- doc/guides/rel_notes/release_21_11.rst | 4 +++ drivers/net/vhost/rte_eth_vhost.c | 40 ++++++++++++++++++++++++++ 2 files changed, 44 insertions(+)doc/guides/rel_notes/release_21_11.rst +4
-0@@ -76,6 +76,10 @@ New Features Added an API to support power monitor in vhost library. +* **Updated vhost PMD.** + + Implement rte_power_monitor API in vhost PMD. + * **Updated virtio PMD.** Implement rte_power_monitor API in virtio PMD.drivers/net/vhost/rte_eth_vhost.c +0
-0@@ -1386,6 +1386,45 @@ eth_rx_queue_count(struct rte_eth_dev *dev,
uint16_tQuoted 13 lines
drivers/net/vhost/rte_eth_vhost.c +9
-0rx_queue_id)return rte_vhost_rx_queue_count (vq->vid, vq->virtqueue_id); } +#define CLB_VAL_IDX 0 +#define CLB_MSK_IDX 1 +#define CLB_MATCH_IDX 2 +static int +vhost_monitor_callback (const uint64_t value, +const uint64_t opaque[RTE_POWER_MONITOR_OPAQUE_SZ ]) +{ +const uint64_t m = opaque[CLB_MSK_IDX ]; +const uint64_t v = opaque[CLB_VAL_IDX ];drivers/net/vhost/rte_eth_vhost.c eth_rx_queue_count(struct rte_eth_dev *dev, uint16_t rx_queue_id)
Quoted 10 lines
drivers/net/vhost/rte_eth_vhost.c +10
-0+const uint64_t c = opaque[CLB_MATCH_IDX ]; + +if (c) +return (value & m) == v ?-1 :0 ; +else +return (value & m) == v ?0 :-1 ; +} + +static int +vhost_get_monitor_addr(void *rx_queue, struct rte_power_monitor_cond*pmc)
Quoted 23 lines
drivers/net/vhost/rte_eth_vhost.c +20
-0+{ +struct vhost_queue *vq = rx_queue; +struct rte_vhost_power_monitor_cond vhost_pmc; +int ret; +if (vq ==NULL ) +return -EINVAL ; + ret =rte_vhost_get_monitor_addr (vq->vid, vq->virtqueue_id, + &vhost_pmc); +if (ret <0 ) +return -EINVAL ; + pmc->addr = vhost_pmc.addr; + pmc->opaque[CLB_VAL_IDX ] = vhost_pmc.val; + pmc->opaque[CLB_MSK_IDX ] = vhost_pmc.mask; + pmc->opaque[CLB_MATCH_IDX ] = vhost_pmc.match; + pmc->size = vhost_pmc.size; + pmc->fn = vhost_monitor_callback; + +return 0 ; +} +static const struct eth_dev_ops ops = { .dev_start = eth_dev_start,.dev_stop =
eth_dev_stop,
Quoted 8 lines
drivers/net/vhost/rte_eth_vhost.c static const struct eth_dev_ops ops = { · line 1447
Quoted 5 lines
drivers/net/vhost/rte_eth_vhost.c +1
-0@@ -1405,6 +1444,7 @@ static const struct eth_dev_ops ops = { .xstats_get_names = vhost_dev_xstats_get_names, .rx_queue_intr_enable = eth_rxq_intr_enable, .rx_queue_intr_disable = eth_rxq_intr_disable, + .get_monitor_addr = vhost_get_monitor_addr,Please align the format with above callbacks: one space is enough after '
get_monitor_addr'
I will remove extra space in the next version.
Thanks,
Miao
Quoted 9 lines
Thanks,
ChenboQuoted 5 lines
drivers/net/vhost/rte_eth_vhost.c +0
-1}; static int --2.25.1
PATCH v5 4/5 power: modify return of queue_stopped
In reply to Miao LiSince some vdevs like virtio and vhost do not support rxq_info_get and queue state inquiry, the error return value -ENOTSUP need to be ignored when queue_stopped cannot get rx queue information and rx queue state. This patch changes the return value of queue_stopped when rte_eth_rx_queue_info_get return ENOTSUP to support vdevs which cannot provide rx queue information and rx queue state enable power management.
--- lib/power/rte_power_pmd_mgmt.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
lib/power/rte_power_pmd_mgmt.c +7 -2
@@ -382,8 +382,13 @@ queue_stopped(const uint16_t port_id, const uint16_t queue_id) {struct rte_eth_rxq_info qinfo; -if (rte_eth_rx_queue_info_get (port_id, queue_id, &qinfo) <0 ) -return -1 ; +int ret =rte_eth_rx_queue_info_get (port_id, queue_id, &qinfo); +if (ret <0 ) { +if (ret == -ENOTSUP ) +return 1 ; +else +return -1 ; + }return qinfo.queue_state ==RTE_ETH_QUEUE_STATE_STOPPED ; }
Signature · 1 line
2.25.1
Re: [dpdk-dev] [PATCH v5 4/5] power: modify return of queue_stopped
Quoted 8 lines
-----Original Message-----
From: Li, Miao <[email protected]>
Sent: Friday, October 15, 2021 11:12 PM
To: [email protected]
Cc: Xia, Chenbo <[email protected]>; [email protected]; Li, Miao <[email protected]>; Burakov, Anatoly <[email protected]>
Subject: [PATCH v5 4/5] power: modify return ofqueue_stopped
Quoted 5 lines
Since some vdevs like virtio and vhost do not support
rxq_info_getand queue state inquiry, the error return value-ENOTSUPneed to be ignored whenqueue_stoppedcannot get rx queue information and rx queue state. This patch changes the return value ofqueue_stoppedwhenrte_eth_rx_queue_info_getreturn ENOTSUP to support vdevs which cannot
ENOTSUP -> -ENOTSUP
With this fixed:
Quoted 31 lines
provide rx queue information and rx queue state enable power management.
Signed-off-by Miao Li <[email protected]>Acked-by Anatoly Burakov <[email protected]>--- lib/power/rte_power_pmd_mgmt.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)lib/power/rte_power_pmd_mgmt.c +7
-2@@ -382,8 +382,13 @@ queue_stopped(const uint16_t port_id, const uint16_t queue_id) {struct rte_eth_rxq_info qinfo; -if (rte_eth_rx_queue_info_get (port_id, queue_id, &qinfo) <0 ) -return -1 ; +int ret =rte_eth_rx_queue_info_get (port_id, queue_id, &qinfo); +if (ret <0 ) { +if (ret == -ENOTSUP ) +return 1 ; +else +return -1 ; + }return qinfo.queue_state ==RTE_ETH_QUEUE_STATE_STOPPED ;}
--
2.25.1
Re: [dpdk-dev] [PATCH v5 4/5] power: modify return of queue_stopped
Hi Chenbo,
Quoted 23 lines
-----Original Message-----
From: Xia, Chenbo <[email protected]>
Sent: Friday, October 15, 2021 3:47 PM
To: Li, Miao <[email protected]>; [email protected]
Cc: [email protected]; Burakov, Anatoly <[email protected]>
Subject: RE: [PATCH v5 4/5] power: modify return ofqueue_stoppedQuoted 5 lines
-----Original Message-----
From: Li, Miao <[email protected]>
Sent: Friday, October 15, 2021 11:12 PM
To: [email protected]
Cc: Xia, Chenbo <[email protected]>; [email protected]; Li,Miao
Quoted 8 lines
<[email protected]>; Burakov, Anatoly <[email protected]>
Subject: [PATCH v5 4/5] power: modify return ofqueue_stoppedSince some vdevs like virtio and vhost do not support
rxq_info_getand queue state inquiry, the error return value-ENOTSUPneed to be ignored whenqueue_stoppedcannot get rx queue information and rx queue state. This patch changes the return value ofqueue_stoppedwhenrte_eth_rx_queue_info_getreturn ENOTSUP to support vdevs which cannot
Quoted 5 lines
ENOTSUP ->
-ENOTSUPWith this fixed:
Reviewed-by Chenbo Xia <[email protected]>
I will fix it in the next version.
Thanks,
Miao
Quoted 34 lines
Review
Quoted 10 lines
provide rx queue information and rx queue state enable power management.
Signed-off-by Miao Li <[email protected]>Acked-by Anatoly Burakov <[email protected]>--- lib/power/rte_power_pmd_mgmt.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)(quoted diff) +0
-0
b/lib/power/rte_power_pmd_mgmt.clib/power/rte_power_pmd_mgmt.c queue_stopped(const uint16_t port_id, const
Quoted 4 lines
index
0ce40f0875..39a2b4cd23100644lib/power/rte_power_pmd_mgmt.c +0
-0@@ -382,8 +382,13 @@ queue_stopped(const uint16_t port_id, const
uint16_tQuoted 18 lines
lib/power/rte_power_pmd_mgmt.c +7
-2queue_id) {struct rte_eth_rxq_info qinfo; -if (rte_eth_rx_queue_info_get (port_id, queue_id, &qinfo) <0 ) -return -1 ; +int ret =rte_eth_rx_queue_info_get (port_id, queue_id, &qinfo); +if (ret <0 ) { +if (ret == -ENOTSUP ) +return 1 ; +else +return -1 ; + }return qinfo.queue_state ==RTE_ETH_QUEUE_STATE_STOPPED ;}
--
2.25.1
PATCH v5 5/5 examples/l3fwd-power: support virtio/vhost
In reply to Miao LiIn l3fwd-power, there is default port configuration which requires RSS and IPV4/UDP/TCP checksum. Once device does not support these, the l3fwd-power will exit and report an error.
This patch updates the port configuration based on device capabilities after getting the device information to support devices like virtio and vhost.
--- examples/l3fwd-power/main.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
examples/l3fwd-power/main.c +8 -1
@@ -505,7 +505,9 @@ is_valid_ipv4_pkt(struct rte_ipv4_hdr *pkt, uint32_t link_len)return -1 ;/* 2. The IP checksum must be correct. */ -/* this is checked in H/W */ +/* if this is not checked in H/W, check it. */ +if ((port_conf.rxmode.offloads &DEV_RX_OFFLOAD_IPV4_CKSUM ) ==0 ) +rte_ipv4_cksum (pkt);/* * 3. The IP version number must be 4. If the version number is not 4
@@ -2637,6 +2639,11 @@ main(int argc, char **argv) local_port_conf.rx_adv_conf.rss_conf.rss_hf); } +if (local_port_conf.rx_adv_conf.rss_conf.rss_hf ==0 ) + local_port_conf.rxmode.mq_mode =ETH_MQ_RX_NONE ; + local_port_conf.rxmode.offloads &= dev_info.rx_offload_capa; + port_conf.rxmode.offloads = local_port_conf.rxmode.offloads; + ret =rte_eth_dev_configure (portid, nb_rx_queue, (uint16_t )n_tx_queue, &local_port_conf);if (ret <0 )
Signature · 1 line
2.25.1
Re: [dpdk-dev] [PATCH v5 5/5] examples/l3fwd-power: support virtio/vhost
Quoted 25 lines
-----Original Message-----
From: Li, Miao <[email protected]>
Sent: Friday, October 15, 2021 11:12 PM
To: [email protected]
Cc: Xia, Chenbo <[email protected]>; [email protected]; Li, Miao <[email protected]>
Subject: [PATCH v5 5/5] examples/l3fwd-power: support virtio/vhostIn l3fwd-power, there is default port configuration which requires RSS and IPV4/UDP/TCP checksum. Once device does not support these, the l3fwd-power will exit and report an error.
This patch updates the port configuration based on device capabilities after getting the device information to support devices like virtio and vhost.Signed-off-by Miao Li <[email protected]>--- examples/l3fwd-power/main.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)examples/l3fwd-power/main.c +0
-0
examples/l3fwd-power/main.c is_valid_ipv4_pkt(struct rte_ipv4_hdr *pkt, uint32_t · line 511
Quoted 8 lines
examples/l3fwd-power/main.c +3
-1@@ -505,7 +505,9 @@ is_valid_ipv4_pkt(struct rte_ipv4_hdr *pkt, uint32_t link_len)return -1 ;/* 2. The IP checksum must be correct. */ -/* this is checked in H/W */ +/* if this is not checked in H/W, check it. */ +if ((port_conf.rxmode.offloads &DEV_RX_OFFLOAD_IPV4_CKSUM ) ==0 ) +rte_ipv4_cksum (pkt);
This is not correct. The correct handling should be:
1. get actual cksum from pkt and save it
2. set pkt cksum to zero
3. compute correct cksum using rte_ipv4_cksum
4. compare to know if actual cksum == correct cksum
You can refer to test_ipsec_l3_csum_verify in test_cryptodev_security_ipsec.c
Thanks,
Chenbo
Quoted 17 lines
examples/l3fwd-power/main.c +5
-1/* * 3. The IP version number must be 4. If the version number is not 4 @@ -2637,6 +2639,11 @@ main(int argc, char **argv) local_port_conf.rx_adv_conf.rss_conf.rss_hf); } +if (local_port_conf.rx_adv_conf.rss_conf.rss_hf ==0 ) + local_port_conf.rxmode.mq_mode =ETH_MQ_RX_NONE ; + local_port_conf.rxmode.offloads &= dev_info.rx_offload_capa; + port_conf.rxmode.offloads = local_port_conf.rxmode.offloads; + ret =rte_eth_dev_configure (portid, nb_rx_queue, (uint16_t )n_tx_queue, &local_port_conf);if (ret <0 ) --2.25.1
Re: [dpdk-dev] [PATCH v5 5/5] examples/l3fwd-power: support virtio/vhost
Hi Chenbo,
Quoted 49 lines
-----Original Message-----
From: Xia, Chenbo <[email protected]>
Sent: Friday, October 15, 2021 4:14 PM
To: Li, Miao <[email protected]>; [email protected]
Cc: [email protected]
Subject: RE: [PATCH v5 5/5] examples/l3fwd-power: support virtio/vhostQuoted 5 lines
-----Original Message-----
From: Li, Miao <[email protected]>
Sent: Friday, October 15, 2021 11:12 PM
To: [email protected]
Cc: Xia, Chenbo <[email protected]>; [email protected]; Li,Miao
Quoted 20 lines
<[email protected]>
Subject: [PATCH v5 5/5] examples/l3fwd-power: support virtio/vhostIn l3fwd-power, there is default port configuration which requires RSS and IPV4/UDP/TCP checksum. Once device does not support these, the l3fwd-power will exit and report an error.
This patch updates the port configuration based on device capabilities after getting the device information to support devices like virtio and vhost.Signed-off-by Miao Li <[email protected]>--- examples/l3fwd-power/main.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)examples/l3fwd-power/main.c +0
-0examples/l3fwd-power/main.c is_valid_ipv4_pkt(struct rte_ipv4_hdr *pkt, uint32_t · line 511
Quoted 8 lines
examples/l3fwd-power/main.c +3
-1@@ -505,7 +505,9 @@ is_valid_ipv4_pkt(struct rte_ipv4_hdr *pkt, uint32_t link_len)return -1 ;/* 2. The IP checksum must be correct. */ -/* this is checked in H/W */ +/* if this is not checked in H/W, check it. */ +if ((port_conf.rxmode.offloads &DEV_RX_OFFLOAD_IPV4_CKSUM ) ==0 ) +rte_ipv4_cksum (pkt);This is not correct. The correct handling should be:
1. get actual cksum from pkt and save it
2. set pkt cksum to zero
3. compute correct cksum usingrte_ipv4_cksum
4. compare to know if actual cksum == correct cksum
Quoted 4 lines
You can refer to
test_ipsec_l3_csum_verifyintest_cryptodev_security_ipsec.cThanks,
Chenbo
I will fix it in the next version.
Thanks,
Miao
Quoted 20 lines
examples/l3fwd-power/main.c main(int argc, char **argv) · line 2643
Quoted 10 lines
examples/l3fwd-power/main.c +2
-0/* * 3. The IP version number must be 4. If the version number is not 4 @@ -2637,6 +2639,11 @@ main(int argc, char **argv) local_port_conf.rx_adv_conf.rss_conf.rss_hf); } +if (local_port_conf.rx_adv_conf.rss_conf.rss_hf ==0 ) + local_port_conf.rxmode.mq_mode =
ETH_MQ_RX_NONE;examples/l3fwd-power/main.c main(int argc, char **argv)
Quoted 5 lines
examples/l3fwd-power/main.c +3
-0+ local_port_conf.rxmode.offloads &= dev_info.rx_offload_capa; + port_conf.rxmode.offloads = local_port_conf.rxmode.offloads; + ret = rte_eth_dev_configure(portid, nb_rx_queue, (uint16_t)n_tx_queue,
&local_port_conf);Quoted 3 lines
examples/l3fwd-power/main.c +0
-1if (ret <0 ) --2.25.1
v6 cover Implement rte_power_monitor API in virtio/vhost PMD
In reply to Miao LiThis patchset implements rte_power_monitor API in virtio and vhost PMD to reduce power consumption when no packet come in. This API can be called and tested in l3fwd-power after adding vhost and virtio support in l3fwd-power and ignoring the rx queue information check in queue_stopped().
v6:
-modify comment
-remove extra space
-fix IPv4 CKSUM check
v5:
-Rebase on lastest repo
v4:
-modify comment
-update the release note
-add IPv4 CKSUM check
v3:
-fix some code format issues
-fix spelling mistake
v2:
-remove flag and add match and size in rte_vhost_power_monitor_cond -modify power callback function
-add dev and queue id check and remove unnecessary check -fix the assignment of pmc->size
-update port configuration according to the device information and remove adding command line arguments
-modify some titles
Miao Li (5):
net/virtio: implement rte_power_monitor API
vhost: implement rte_power_monitor API
net/vhost: implement rte_power_monitor API
power: modify return of queue_stopped
examples/l3fwd-power: support virtio/vhost
doc/guides/rel_notes/release_21_11.rst | 12 ++++++ drivers/net/vhost/rte_eth_vhost.c | 40 ++++++++++++++++++ drivers/net/virtio/virtio_ethdev.c | 56 ++++++++++++++++++++++++++ examples/l3fwd-power/main.c | 15 ++++++- lib/power/rte_power_pmd_mgmt.c | 9 ++++- lib/vhost/rte_vhost.h | 42 +++++++++++++++++++ lib/vhost/version.map | 3 ++ lib/vhost/vhost.c | 38 +++++++++++++++++ 8 files changed, 212 insertions(+), 3 deletions(-)
Signature · 1 line
2.25.1
PATCH v6 1/5 net/virtio: implement rte_power_monitor API
This patch implements rte_power_monitor API in virtio PMD to reduce power consumption when no packet come in. According to current semantics of power monitor, this commit adds a callback function to decide whether aborts the sleep by checking current value against the expected value and virtio_get_monitor_addr to provide address to monitor. When no packet come in, the value of address will not be changed and the running core will sleep. Once packets arrive, the value of address will be changed and the running core will wakeup.
--- doc/guides/rel_notes/release_21_11.rst | 4 ++ drivers/net/virtio/virtio_ethdev.c | 56 ++++++++++++++++++++++++++ 2 files changed, 60 insertions(+)
doc/guides/rel_notes/release_21_11.rst +4 -0
@@ -72,6 +72,10 @@ New Features Added macros ETH_RSS_IPV4_CHKSUM and ETH_RSS_L4_CHKSUM, now IPv4 and TCP/UDP/SCTP header checksum field can be used as input set for RSS. +* **Updated virtio PMD.** + + Implement rte_power_monitor API in virtio PMD. + * **Updated af_packet ethdev driver.** * Default VLAN strip behavior was changed. VLAN tag won't be stripped
drivers/net/virtio/virtio_ethdev.c +56 -0
74 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v6 2/5 vhost: implement rte_power_monitor API
In reply to Miao LiThis patch defines rte_vhost_power_monitor_cond which is used to pass some information to vhost driver. The information is including the address to monitor, the expected value, the mask to extract value read from 'addr', the value size of monitor address, the match flag used to distinguish the value used to match something or not match something. Vhost driver can use these information to fill rte_power_monitor_cond.
--- doc/guides/rel_notes/release_21_11.rst | 4 +++ lib/vhost/rte_vhost.h | 42 ++++++++++++++++++++++++++ lib/vhost/version.map | 3 ++ lib/vhost/vhost.c | 38 +++++++++++++++++++++++ 4 files changed, 87 insertions(+)
doc/guides/rel_notes/release_21_11.rst +4 -0
@@ -72,6 +72,10 @@ New Features Added macros ETH_RSS_IPV4_CHKSUM and ETH_RSS_L4_CHKSUM, now IPv4 and TCP/UDP/SCTP header checksum field can be used as input set for RSS. +* **Added power monitor API in vhost library.** + + Added an API to support power monitor in vhost library. + * **Updated virtio PMD.** Implement rte_power_monitor API in virtio PMD.
lib/vhost/rte_vhost.h +42 -0
54 lines not on this page · raw message
lib/vhost/version.map +3 -0
@@ -85,4 +85,7 @@ EXPERIMENTAL { rte_vhost_async_channel_register_thread_unsafe; rte_vhost_async_channel_unregister_thread_unsafe; rte_vhost_clear_queue_thread_unsafe; + + # added in 21.11 + rte_vhost_get_monitor_addr; };
lib/vhost/vhost.c +38 -0
@@ -1889,5 +1889,43 @@ rte_vhost_async_get_inflight(int vid, uint16_t queue_id)return ret; } +int +rte_vhost_get_monitor_addr (int vid,uint16_t queue_id, +struct rte_vhost_power_monitor_cond *pmc) +{ +struct virtio_net *dev =get_device (vid); +struct vhost_virtqueue *vq; + +if (dev ==NULL ) +return -1 ; +if (queue_id >=VHOST_MAX_VRING ) +return -1 ; + + vq = dev->virtqueue[queue_id]; +if (vq ==NULL ) +return -1 ; + +if (vq_is_packed (dev)) { +struct vring_packed_desc *desc; + desc = vq->desc_packed; + pmc->addr = &desc[vq->last_avail_idx].flags; +if (vq->avail_wrap_counter) + pmc->val =VRING_DESC_F_AVAIL ; +else + pmc->val =VRING_DESC_F_USED ; + pmc->mask =VRING_DESC_F_AVAIL |VRING_DESC_F_USED ; + pmc->size =sizeof (desc[vq->last_avail_idx].flags); + pmc->match =1 ; + }else { + pmc->addr = &vq->avail->idx; + pmc->val = vq->last_avail_idx & (vq->size -1 ); + pmc->mask = vq->size -1 ; + pmc->size =sizeof (vq->avail->idx); + pmc->match =0 ; + } + +return 0 ; +} +RTE_LOG_REGISTER_SUFFIX (vhost_config_log_level, config,INFO );RTE_LOG_REGISTER_SUFFIX (vhost_data_log_level, data,WARNING );
Signature · 1 line
2.25.1
PATCH v6 3/5 net/vhost: implement rte_power_monitor API
In reply to Miao LiThis patch implements rte_power_monitor API in vhost PMD to reduce power consumption when no packet come in. According to current semantics of power monitor, this commit adds a callback function to decide whether aborts the sleep by checking current value against the expected value and vhost_get_monitor_addr to provide address to monitor. When no packet come in, the value of address will not be changed and the running core will sleep. Once packets arrive, the value of address will be changed and the running core will wakeup.
--- doc/guides/rel_notes/release_21_11.rst | 4 +++ drivers/net/vhost/rte_eth_vhost.c | 40 ++++++++++++++++++++++++++ 2 files changed, 44 insertions(+)
doc/guides/rel_notes/release_21_11.rst +4 -0
@@ -76,6 +76,10 @@ New Features Added an API to support power monitor in vhost library. +* **Updated vhost PMD.** + + Implement rte_power_monitor API in vhost PMD. + * **Updated virtio PMD.** Implement rte_power_monitor API in virtio PMD.
drivers/net/vhost/rte_eth_vhost.c +40 -0
@@ -1386,6 +1386,45 @@ eth_rx_queue_count(struct rte_eth_dev *dev, uint16_t rx_queue_id)return rte_vhost_rx_queue_count (vq->vid, vq->virtqueue_id); } +#define CLB_VAL_IDX 0 +#define CLB_MSK_IDX 1 +#define CLB_MATCH_IDX 2 +static int +vhost_monitor_callback (const uint64_t value, +const uint64_t opaque[RTE_POWER_MONITOR_OPAQUE_SZ ]) +{ +const uint64_t m = opaque[CLB_MSK_IDX ]; +const uint64_t v = opaque[CLB_VAL_IDX ]; +const uint64_t c = opaque[CLB_MATCH_IDX ]; + +if (c) +return (value & m) == v ?-1 :0 ; +else +return (value & m) == v ?0 :-1 ; +} + +static int +vhost_get_monitor_addr (void *rx_queue,struct rte_power_monitor_cond *pmc) +{ +struct vhost_queue *vq = rx_queue; +struct rte_vhost_power_monitor_cond vhost_pmc; +int ret; +if (vq ==NULL ) +return -EINVAL ; + ret =rte_vhost_get_monitor_addr (vq->vid, vq->virtqueue_id, + &vhost_pmc); +if (ret <0 ) +return -EINVAL ; + pmc->addr = vhost_pmc.addr; + pmc->opaque[CLB_VAL_IDX ] = vhost_pmc.val; + pmc->opaque[CLB_MSK_IDX ] = vhost_pmc.mask; + pmc->opaque[CLB_MATCH_IDX ] = vhost_pmc.match; + pmc->size = vhost_pmc.size; + pmc->fn = vhost_monitor_callback; + +return 0 ; +} +static const struct eth_dev_ops ops = { .dev_start = eth_dev_start, .dev_stop = eth_dev_stop,
@@ -1405,6 +1444,7 @@ static const struct eth_dev_ops ops = { .xstats_get_names = vhost_dev_xstats_get_names, .rx_queue_intr_enable = eth_rxq_intr_enable, .rx_queue_intr_disable = eth_rxq_intr_disable, + .get_monitor_addr = vhost_get_monitor_addr, }; static int
Signature · 1 line
2.25.1
PATCH v6 4/5 power: modify return of queue_stopped
In reply to Miao LiSince some vdevs like virtio and vhost do not support rxq_info_get and queue state inquiry, the error return value -ENOTSUP need to be ignored when queue_stopped cannot get rx queue information and rx queue state. This patch changes the return value of queue_stopped when rte_eth_rx_queue_info_get return -ENOTSUP to support vdevs which cannot provide rx queue information and rx queue state enable power management.
--- lib/power/rte_power_pmd_mgmt.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
lib/power/rte_power_pmd_mgmt.c +7 -2
@@ -382,8 +382,13 @@ queue_stopped(const uint16_t port_id, const uint16_t queue_id) {struct rte_eth_rxq_info qinfo; -if (rte_eth_rx_queue_info_get (port_id, queue_id, &qinfo) <0 ) -return -1 ; +int ret =rte_eth_rx_queue_info_get (port_id, queue_id, &qinfo); +if (ret <0 ) { +if (ret == -ENOTSUP ) +return 1 ; +else +return -1 ; + }return qinfo.queue_state ==RTE_ETH_QUEUE_STATE_STOPPED ; }
Signature · 1 line
2.25.1
PATCH v6 5/5 examples/l3fwd-power: support virtio/vhost
In reply to Miao LiIn l3fwd-power, there is default port configuration which requires RSS and IPV4/UDP/TCP checksum. Once device does not support these, the l3fwd-power will exit and report an error.
This patch updates the port configuration based on device capabilities after getting the device information to support devices like virtio and vhost.
--- examples/l3fwd-power/main.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
examples/l3fwd-power/main.c +14 -1
@@ -505,7 +505,15 @@ is_valid_ipv4_pkt(struct rte_ipv4_hdr *pkt, uint32_t link_len)return -1 ;/* 2. The IP checksum must be correct. */ -/* this is checked in H/W */ +/* if this is not checked in H/W, check it. */ +if ((port_conf.rxmode.offloads &DEV_RX_OFFLOAD_IPV4_CKSUM ) ==0 ){ +uint16_t actual_cksum, expected_cksum; + actual_cksum = pkt->hdr_checksum; + pkt->hdr_checksum =0 ; + expected_cksum =rte_ipv4_cksum (pkt); +if (actual_cksum != expected_cksum) +return -2 ; + }/* * 3. The IP version number must be 4. If the version number is not 4
@@ -2637,6 +2645,11 @@ main(int argc, char **argv) local_port_conf.rx_adv_conf.rss_conf.rss_hf); } +if (local_port_conf.rx_adv_conf.rss_conf.rss_hf ==0 ) + local_port_conf.rxmode.mq_mode =ETH_MQ_RX_NONE ; + local_port_conf.rxmode.offloads &= dev_info.rx_offload_capa; + port_conf.rxmode.offloads = local_port_conf.rxmode.offloads; + ret =rte_eth_dev_configure (portid, nb_rx_queue, (uint16_t )n_tx_queue, &local_port_conf);if (ret <0 )
Signature · 1 line
2.25.1
Re: [dpdk-dev] [PATCH v6 0/5] Implement rte_power_monitor API in virtio/vhost PMD
In reply to Miao LiHi,
Quoted 39 lines · Miao Li
This patchset implements
rte_power_monitorAPI in virtio and vhost PMD to reduce power consumption when no packet come in. This API can be called and tested in l3fwd-power after adding vhost and virtio support in l3fwd-power and ignoring the rx queue information check inqueue_stopped().v6:
(quoted diff) +0
-3-modify comment -remove extra space -fix IPv4 CKSUM checkv5:
-Rebase on lastest repov4:
(quoted diff) +0
-3-modify comment -update the release note -add IPv4 CKSUM checkv3:
(quoted diff) +0
-2-fix some code format issues -fix spelling mistakev2:
(quoted diff) +0
-5-remove flag and add match and size in rte_vhost_power_monitor_cond -modify power callback function -add dev and queue id check and remove unnecessary check -fix the assignment of pmc->size -update port configuration according to the device information andremove adding command line arguments
-modify some titlesMiao Li (5):
net/virtio: implementrte_power_monitorAPI
vhost: implementrte_power_monitorAPI
net/vhost: implementrte_power_monitorAPI
power: modify return ofqueue_stopped
examples/l3fwd-power: support virtio/vhost
Quoted 10 lines
doc/guides/rel_notes/release_21_11.rst | 12 ++++++ drivers/net/vhost/rte_eth_vhost.c | 40 ++++++++++++++++++ drivers/net/virtio/virtio_ethdev.c | 56 ++++++++++++++++++++++++++ examples/l3fwd-power/main.c | 15 ++++++- lib/power/rte_power_pmd_mgmt.c | 9 ++++- lib/vhost/rte_vhost.h | 42 +++++++++++++++++++ lib/vhost/version.map | 3 ++ lib/vhost/vhost.c | 38 +++++++++++++++++ 8 files changed, 212 insertions(+), 3 deletions(-)
Please run checkpatch and check-git-log scripts, there are some issues.
Thanks,
Maxime
Re: [dpdk-dev] [PATCH v6 0/5] Implement rte_power_monitor API in virtio/vhost PMD
Hi,
Quoted 50 lines
-----Original Message-----
From: Maxime Coquelin <[email protected]>
Sent: Friday, October 15, 2021 8:58 PM
To: Li, Miao <[email protected]>; [email protected]
Cc: Xia, Chenbo <[email protected]>
Subject: Re: [PATCH v6 0/5] Implementrte_power_monitorAPI in virtio/vhost PMDHi,
Quoted 39 lines · Miao Li
This patchset implements
rte_power_monitorAPI in virtio and vhost PMD to reduce power consumption when no packet come in. This API can be called and tested in l3fwd-power after adding vhost and virtio support in l3fwd-power and ignoring the rx queue information check inqueue_stopped().v6:
(quoted diff) +0
-3-modify comment -remove extra space -fix IPv4 CKSUM checkv5:
-Rebase on lastest repov4:
(quoted diff) +0
-3-modify comment -update the release note -add IPv4 CKSUM checkv3:
(quoted diff) +0
-2-fix some code format issues -fix spelling mistakev2:
(quoted diff) +0
-5-remove flag and add match and size in rte_vhost_power_monitor_cond -modify power callback function -add dev and queue id check and remove unnecessary check -fix the assignment of pmc->size -update port configuration according to the device information andremove adding command line arguments
-modify some titlesMiao Li (5):
net/virtio: implementrte_power_monitorAPI
vhost: implementrte_power_monitorAPI
net/vhost: implementrte_power_monitorAPI
power: modify return ofqueue_stopped
examples/l3fwd-power: support virtio/vhost
Quoted 12 lines
Quoted 10 lines
doc/guides/rel_notes/release_21_11.rst | 12 ++++++ drivers/net/vhost/rte_eth_vhost.c | 40 ++++++++++++++++++ drivers/net/virtio/virtio_ethdev.c | 56 ++++++++++++++++++++++++++ examples/l3fwd-power/main.c | 15 ++++++- lib/power/rte_power_pmd_mgmt.c | 9 ++++- lib/vhost/rte_vhost.h | 42 +++++++++++++++++++ lib/vhost/version.map | 3 ++ lib/vhost/vhost.c | 38 +++++++++++++++++ 8 files changed, 212 insertions(+), 3 deletions(-)Please run checkpatch and check-git-log scripts, there are some issues.
Ok, I will fix them in the next version.
Thanks,
Miao
Quoted 3 lines
Thanks,
Maxime
v7 cover Implement rte_power_monitor API in virtio/vhost PMD
In reply to Miao LiThis patchset implements rte_power_monitor API in virtio and vhost PMD to reduce power consumption when no packet come in. This API can be called and tested in l3fwd-power after adding vhost and virtio support in l3fwd-power and ignoring the rx queue information check in queue_stopped().
v7:
-fix coding style issues
-Rebase on lastest repo
v6:
-modify comment
-remove extra space
-fix IPv4 CKSUM check
v5:
-Rebase on lastest repo
v4:
-modify comment
-update the release note
-add IPv4 CKSUM check
v3:
-fix some code format issues
-fix spelling mistake
v2:
-remove flag and add match and size in rte_vhost_power_monitor_cond -modify power callback function
-add dev and queue id check and remove unnecessary check -fix the assignment of pmc->size
-update port configuration according to the device information and remove adding command line arguments
-modify some titles
Miao Li (5):
net/virtio: implement rte_power_monitor API
vhost: implement rte_power_monitor API
net/vhost: implement rte_power_monitor API
power: modify return of queue_stopped
examples/l3fwd-power: support virtio/vhost
doc/guides/rel_notes/release_21_11.rst | 12 ++++++ drivers/net/vhost/rte_eth_vhost.c | 40 ++++++++++++++++++ drivers/net/virtio/virtio_ethdev.c | 56 ++++++++++++++++++++++++++ examples/l3fwd-power/main.c | 15 ++++++- lib/power/rte_power_pmd_mgmt.c | 9 ++++- lib/vhost/rte_vhost.h | 42 +++++++++++++++++++ lib/vhost/version.map | 3 ++ lib/vhost/vhost.c | 38 +++++++++++++++++ 8 files changed, 212 insertions(+), 3 deletions(-)
Signature · 1 line
2.25.1
PATCH v7 1/5 net/virtio: implement rte_power_monitor API
This patch implements rte_power_monitor API in virtio PMD to reduce power consumption when no packet come in. According to current semantics of power monitor, this commit adds a callback function to decide whether aborts the sleep by checking current value against the expected value and virtio_get_monitor_addr to provide address to monitor. When no packet come in, the value of address will not be changed and the running core will sleep. Once packets arrive, the value of address will be changed and the running core will wakeup.
--- doc/guides/rel_notes/release_21_11.rst | 4 ++ drivers/net/virtio/virtio_ethdev.c | 56 ++++++++++++++++++++++++++ 2 files changed, 60 insertions(+)
doc/guides/rel_notes/release_21_11.rst +4 -0
@@ -80,6 +80,10 @@ New Features Added macros ETH_RSS_IPV4_CHKSUM and ETH_RSS_L4_CHKSUM, now IPv4 and TCP/UDP/SCTP header checksum field can be used as input set for RSS. +* **Updated virtio PMD.** + + Implement rte_power_monitor API in virtio PMD. + * **Updated af_packet ethdev driver.** * Default VLAN strip behavior was changed. VLAN tag won't be stripped
drivers/net/virtio/virtio_ethdev.c +56 -0
74 lines not on this page · raw message
Signature · 1 line
2.25.1
Re: [dpdk-dev] [PATCH v7 1/5] net/virtio: implement rte_power_monitor API
Quoted 1 line · Miao Li
This patch implements
rte_power_monitorAPI in virtio PMD to reduce
Hi Miao,
If there will be a new version can you please drop the "This patch implements" part, you can directly start explaining what patch does.
Quoted 10 lines
power consumption when no packet come in. According to current semantics of power monitor, this commit adds a callback function to decide whether aborts the sleep by checking current value against the expected value and
virtio_get_monitor_addrto provide address to monitor. When no packet come in, the value of address will not be changed and the running core will sleep. Once packets arrive, the value of address will be changed and the running core will wakeup.Signed-off-by Miao Li<[email protected]>Reviewed-by Chenbo Xia<[email protected]>
<...>
Re: [dpdk-dev] [PATCH v7 1/5] net/virtio: implement rte_power_monitor API
Hi,
Quoted 8 lines
-----Original Message-----
From: Yigit, Ferruh <[email protected]>
Sent: Friday, October 22, 2021 12:51 AM
To: Li, Miao <[email protected]>; [email protected]
Cc: Xia, Chenbo <[email protected]>; [email protected]
Subject: Re: [dpdk-dev] [PATCH v7 1/5] net/virtio: implementrte_power_monitorAPI
Quoted 7 lines
Quoted 1 line · Miao Li
This patch implements
rte_power_monitorAPI in virtio PMD to reduceHi Miao,
If there will be a new version can you please drop the "This patch implements" part, you can directly start explaining what patch does.
I will remove this part in the next version.
Thanks,
Miao
Quoted 15 lines
Quoted 5 lines
power consumption when no packet come in. According to current semantics of power monitor, this commit adds a callback function to decide whether aborts the sleep by checking current value against the expected value and
virtio_get_monitor_addrto provide address to monitor. When no packetcome
Quoted 6 lines
in, the value of address will not be changed and the running core will sleep. Once packets arrive, the value of address will be changed and the running core will wakeup.
Signed-off-by Miao Li<[email protected]>Reviewed-by Chenbo Xia<[email protected]><...>
Re: [dpdk-dev] [PATCH v7 1/5] net/virtio: implement rte_power_monitor API
In reply to Miao LiQuoted 9 lines · Miao Li
This patch implements
rte_power_monitorAPI in virtio PMD to reduce power consumption when no packet come in. According to current semantics of power monitor, this commit adds a callback function to decide whether aborts the sleep by checking current value against the expected value andvirtio_get_monitor_addrto provide address to monitor. When no packet come in, the value of address will not be changed and the running core will sleep. Once packets arrive, the value of address will be changed and the running core will wakeup.
A minor comment but instead of patch title mentioning what is implemented, better to describe what feature is added, like:
net/virtio: support power monitor
Quoted 12 lines
Signed-off-by Miao Li <[email protected]>Reviewed-by Chenbo Xia <[email protected]>--- doc/guides/rel_notes/release_21_11.rst | 4 ++ drivers/net/virtio/virtio_ethdev.c | 56 ++++++++++++++++++++++++++ 2 files changed, 60 insertions(+)doc/guides/rel_notes/release_21_11.rst +0
-0
doc/guides/rel_notes/release_21_11.rst New Features · line 86
Quoted 7 lines
doc/guides/rel_notes/release_21_11.rst +4
-0@@ -80,6 +80,10 @@ New Features Added macros ETH_RSS_IPV4_CHKSUM and ETH_RSS_L4_CHKSUM, now IPv4 and TCP/UDP/SCTP header checksum field can be used as input set for RSS. +* **Updated virtio PMD.** + + Implement rte_power_monitor API in virtio PMD. +
The release note updates are grouped as described in the documents section comment, and in a group it is sorted alphabetically, can you please re-arrange the update accordingly. And similar comment, instead of documenting what API implemented, you can mention what support is added.
Same comment for other patches in the set.
Re: [dpdk-dev] [PATCH v7 1/5] net/virtio: implement rte_power_monitor API
Hi,
Quoted 15 lines
-----Original Message-----
From: Yigit, Ferruh <[email protected]>
Sent: Friday, October 22, 2021 12:59 AM
To: Li, Miao <[email protected]>; [email protected]
Cc: Xia, Chenbo <[email protected]>; [email protected]
Subject: Re: [dpdk-dev] [PATCH v7 1/5] net/virtio: implementrte_power_monitorAPIQuoted 5 lines · Miao Li
This patch implements
rte_power_monitorAPI in virtio PMD to reduce power consumption when no packet come in. According to current semantics of power monitor, this commit adds a callback function to decide whether aborts the sleep by checking current value against the expected value andvirtio_get_monitor_addrto provide address to monitor. When no packetcome
Quoted 8 lines
Quoted 4 lines
in, the value of address will not be changed and the running core will sleep. Once packets arrive, the value of address will be changed and the running core will wakeup.
A minor comment but instead of patch title mentioning what is implemented, better to describe what feature is added, like:
net/virtio: support power monitor
I will modify it in the next version.
Quoted 18 lines
Review
Quoted 9 lines
Signed-off-by Miao Li <[email protected]>Reviewed-by Chenbo Xia <[email protected]>--- doc/guides/rel_notes/release_21_11.rst | 4 ++ drivers/net/virtio/virtio_ethdev.c | 56 ++++++++++++++++++++++++++ 2 files changed, 60 insertions(+)(quoted diff) +0
-0
b/doc/guides/rel_notes/release_21_11.rstdoc/guides/rel_notes/release_21_11.rst New Features · line 80
Quoted 5 lines
index
d5435a64aa..c298844898100644doc/guides/rel_notes/release_21_11.rst +0
-0@@ -80,6 +80,10 @@ New Features Added macros ETH_RSS_IPV4_CHKSUM and ETH_RSS_L4_CHKSUM, nowIPv4 and
Quoted 2 lines
doc/guides/rel_notes/release_21_11.rst +0
-0TCP/UDP/SCTP header checksum field can be used as input set for RSS.
Quoted 9 lines
doc/guides/rel_notes/release_21_11.rst New Features · line 86
Quoted 4 lines
doc/guides/rel_notes/release_21_11.rst +4
-0+* **Updated virtio PMD.** + + Implement rte_power_monitor API in virtio PMD. +The release note updates are grouped as described in the documents section comment, and in a group it is sorted alphabetically, can you please re-arrange the update accordingly. And similar comment, instead of documenting what API implemented, you can mention what support is added.
I will re-arrange the update and modify the description in the next version.
Quoted 2 lines
Same comment for other patches in the set.
I will modify them in the next version.
Thanks,
Miao
Quoted 1 line
Re: [dpdk-dev] [PATCH v7 1/5] net/virtio: implement rte_power_monitor API
Hi,
Quoted 63 lines
-----Original Message-----
From: Li, Miao
Sent: Friday, October 22, 2021 4:28 PM
To: Yigit, Ferruh <[email protected]>; [email protected]
Cc: Xia, Chenbo <[email protected]>; [email protected]
Subject: RE: [dpdk-dev] [PATCH v7 1/5] net/virtio: implementrte_power_monitorAPIHi,
Quoted 11 lines
-----Original Message-----
From: Yigit, Ferruh <[email protected]>
Sent: Friday, October 22, 2021 12:59 AM
To: Li, Miao <[email protected]>; [email protected]
Cc: Xia, Chenbo <[email protected]>; [email protected]
Subject: Re: [dpdk-dev] [PATCH v7 1/5] net/virtio: implementrte_power_monitorAPIQuoted 2 lines · Miao Li
This patch implements
rte_power_monitorAPI in virtio PMD to reduce power consumption when no packet come in. According to currentsemantics
Quoted 4 lines
Quoted 3 lines
of power monitor, this commit adds a callback function to decide whether aborts the sleep by checking current value against the expected value and
virtio_get_monitor_addrto provide address to monitor. When no packetcome
Quoted 8 lines
Quoted 4 lines
in, the value of address will not be changed and the running core will sleep. Once packets arrive, the value of address will be changed and the running core will wakeup.
A minor comment but instead of patch title mentioning what is implemented, better to describe what feature is added, like:
net/virtio: support power monitorI will modify it in the next version.
Quoted 18 lines
Review
Quoted 9 lines
Signed-off-by Miao Li <[email protected]>Reviewed-by Chenbo Xia <[email protected]>--- doc/guides/rel_notes/release_21_11.rst | 4 ++ drivers/net/virtio/virtio_ethdev.c | 56 ++++++++++++++++++++++++++ 2 files changed, 60 insertions(+)(quoted diff) +0
-0
b/doc/guides/rel_notes/release_21_11.rstdoc/guides/rel_notes/release_21_11.rst New Features · line 80
Quoted 5 lines
index
d5435a64aa..c298844898100644doc/guides/rel_notes/release_21_11.rst +0
-0@@ -80,6 +80,10 @@ New Features Added macros ETH_RSS_IPV4_CHKSUM and ETH_RSS_L4_CHKSUM, nowIPv4 and
Quoted 2 lines
doc/guides/rel_notes/release_21_11.rst +0
-0TCP/UDP/SCTP header checksum field can be used as input set for RSS.Quoted 8 lines
doc/guides/rel_notes/release_21_11.rst New Features · line 86
Quoted 4 lines
doc/guides/rel_notes/release_21_11.rst +4
-0+* **Updated virtio PMD.** + + Implement rte_power_monitor API in virtio PMD. +The release note updates are grouped as described in the documents section comment, and in a group it is sorted alphabetically, can you please re-arrange the update accordingly. And similar comment, instead of documenting what
Quoted 4 lines
API
Quoted 1 line
implemented, you can mention what support is added.
I will re-arrange the update and modify the description in the next version.
The updates are requested to be ordered alphabetically by vendor name. But Vhost/virtio do not have a vendor name. So should I order virtio/vhost by 'v'?
Thanks,
Miao
Quoted 10 lines
Quoted 3 lines
Same comment for other patches in the set.
I will modify them in the next version.
Thanks,
MiaoQuoted 1 line
Re: [dpdk-dev] [PATCH v7 1/5] net/virtio: implement rte_power_monitor API
Quoted 65 lines · Miao
Hi,
Quoted 63 lines
-----Original Message-----
From: Li, Miao
Sent: Friday, October 22, 2021 4:28 PM
To: Yigit, Ferruh <[email protected]>; [email protected]
Cc: Xia, Chenbo <[email protected]>; [email protected]
Subject: RE: [dpdk-dev] [PATCH v7 1/5] net/virtio: implementrte_power_monitorAPIHi,
Quoted 11 lines
-----Original Message-----
From: Yigit, Ferruh <[email protected]>
Sent: Friday, October 22, 2021 12:59 AM
To: Li, Miao <[email protected]>; [email protected]
Cc: Xia, Chenbo <[email protected]>; [email protected]
Subject: Re: [dpdk-dev] [PATCH v7 1/5] net/virtio: implementrte_power_monitorAPIQuoted 2 lines · Miao Li
This patch implements
rte_power_monitorAPI in virtio PMD to reduce power consumption when no packet come in. According to currentsemantics
Quoted 4 lines
Quoted 3 lines
of power monitor, this commit adds a callback function to decide whether aborts the sleep by checking current value against the expected value and
virtio_get_monitor_addrto provide address to monitor. When no packetcome
Quoted 8 lines
Quoted 4 lines
in, the value of address will not be changed and the running core will sleep. Once packets arrive, the value of address will be changed and the running core will wakeup.
A minor comment but instead of patch title mentioning what is implemented, better to describe what feature is added, like:
net/virtio: support power monitorI will modify it in the next version.
Quoted 26 lines
Review
Quoted 9 lines
Signed-off-by Miao Li <[email protected]>Reviewed-by Chenbo Xia <[email protected]>--- doc/guides/rel_notes/release_21_11.rst | 4 ++ drivers/net/virtio/virtio_ethdev.c | 56 ++++++++++++++++++++++++++ 2 files changed, 60 insertions(+)(quoted diff) +0
-0
b/doc/guides/rel_notes/release_21_11.rstdoc/guides/rel_notes/release_21_11.rst New Features · line 80
Quoted 5 lines
index
d5435a64aa..c298844898100644doc/guides/rel_notes/release_21_11.rst +0
-0@@ -80,6 +80,10 @@ New Features Added macros ETH_RSS_IPV4_CHKSUM and ETH_RSS_L4_CHKSUM, nowIPv4 and
doc/guides/rel_notes/release_21_11.rst New Features · line 86
Quoted 6 lines
doc/guides/rel_notes/release_21_11.rst +4
-0TCP/UDP/SCTP header checksum field can be used as input set for RSS. +* **Updated virtio PMD.** + + Implement rte_power_monitor API in virtio PMD. +The release note updates are grouped as described in the documents section comment, and in a group it is sorted alphabetically, can you please re-arrange the update accordingly. And similar comment, instead of documenting what
Quoted 8 lines
Quoted 4 lines
API
Quoted 1 line
implemented, you can mention what support is added.
I will re-arrange the update and modify the description in the next version.
The updates are requested to be ordered alphabetically by vendor name. But Vhost/virtio do not have a vendor name. So should I order virtio/vhost by 'v'?
I think sort it by 'v' is good, unless Maxime & Chenbo has better idea.
Re: [dpdk-dev] [PATCH v7 1/5] net/virtio: implement rte_power_monitor API
Quoted 78 lines
-----Original Message-----
From: Yigit, Ferruh <[email protected]>
Sent: Friday, October 22, 2021 5:00 PM
To: Li, Miao <[email protected]>; [email protected]
Cc: Xia, Chenbo <[email protected]>; [email protected]
Subject: Re: [dpdk-dev] [PATCH v7 1/5] net/virtio: implementrte_power_monitorAPIQuoted 64 lines · Miao
Hi,
Quoted 62 lines
-----Original Message-----
From: Li, Miao
Sent: Friday, October 22, 2021 4:28 PM
To: Yigit, Ferruh <[email protected]>; [email protected]
Cc: Xia, Chenbo <[email protected]>; [email protected]
Subject: RE: [dpdk-dev] [PATCH v7 1/5] net/virtio: implementrte_power_monitorAPIHi,
Quoted 11 lines
-----Original Message-----
From: Yigit, Ferruh <[email protected]>
Sent: Friday, October 22, 2021 12:59 AM
To: Li, Miao <[email protected]>; [email protected]
Cc: Xia, Chenbo <[email protected]>; [email protected]
Subject: Re: [dpdk-dev] [PATCH v7 1/5] net/virtio: implementrte_power_monitorAPIQuoted 2 lines · Miao Li
This patch implements
rte_power_monitorAPI in virtio PMD to reduce power consumption when no packet come in. According to currentsemantics
Quoted 4 lines
Quoted 3 lines
of power monitor, this commit adds a callback function to decide whether aborts the sleep by checking current value against the expected value and
virtio_get_monitor_addrto provide address to monitor. When no packetcome
Quoted 8 lines
Quoted 4 lines
in, the value of address will not be changed and the running core will sleep. Once packets arrive, the value of address will be changed and the running core will wakeup.
A minor comment but instead of patch title mentioning what is implemented, better to describe what feature is added, like:
net/virtio: support power monitorI will modify it in the next version.
Quoted 25 lines
Review
Quoted 9 lines
Signed-off-by Miao Li <[email protected]>Reviewed-by Chenbo Xia <[email protected]>--- doc/guides/rel_notes/release_21_11.rst | 4 ++ drivers/net/virtio/virtio_ethdev.c | 56 ++++++++++++++++++++++++++ 2 files changed, 60 insertions(+)(quoted diff) +0
-0
b/doc/guides/rel_notes/release_21_11.rstdoc/guides/rel_notes/release_21_11.rst New Features · line 80
Quoted 5 lines
index
d5435a64aa..c298844898100644doc/guides/rel_notes/release_21_11.rst +0
-0@@ -80,6 +80,10 @@ New Features Added macros ETH_RSS_IPV4_CHKSUM and ETH_RSS_L4_CHKSUM, nowIPv4 and
doc/guides/rel_notes/release_21_11.rst New Features · line 86
Quoted 6 lines
doc/guides/rel_notes/release_21_11.rst +4
-0TCP/UDP/SCTP header checksum field can be used as input set for RSS. +* **Updated virtio PMD.** + + Implement rte_power_monitor API in virtio PMD. +The release note updates are grouped as described in the documents section comment, and in a group it is sorted alphabetically, can you please re-
arrange
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
the update accordingly. And similar comment, instead of documenting what
API
Quoted 1 line
implemented, you can mention what support is added.
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
I will re-arrange the update and modify the description in the next version.
The updates are requested to be ordered alphabetically by vendor name. But Vhost/virtio do not have a vendor name. So should I order virtio/vhost by
'v'?
Quoted 1 line
I think sort it by 'v' is good, unless Maxime & Chenbo has better idea.
Good idea to sort by v, so we are aligned that we use the name 'Virtio' and 'Vhost' instead of vendor name to sort in later release.
Thanks,
Chenbo
Re: [dpdk-dev] [PATCH v7 1/5] net/virtio: implement rte_power_monitor API
In reply to Miao LiQuoted 102 lines · Miao Li
This patch implements
rte_power_monitorAPI in virtio PMD to reduce power consumption when no packet come in. According to current semantics of power monitor, this commit adds a callback function to decide whether aborts the sleep by checking current value against the expected value andvirtio_get_monitor_addrto provide address to monitor. When no packet come in, the value of address will not be changed and the running core will sleep. Once packets arrive, the value of address will be changed and the running core will wakeup.Signed-off-by Miao Li <[email protected]>Reviewed-by Chenbo Xia <[email protected]>--- doc/guides/rel_notes/release_21_11.rst | 4 ++ drivers/net/virtio/virtio_ethdev.c | 56 ++++++++++++++++++++++++++ 2 files changed, 60 insertions(+)doc/guides/rel_notes/release_21_11.rst +4
-0@@ -80,6 +80,10 @@ New Features Added macros ETH_RSS_IPV4_CHKSUM and ETH_RSS_L4_CHKSUM, now IPv4 and TCP/UDP/SCTP header checksum field can be used as input set for RSS. +* **Updated virtio PMD.** + + Implement rte_power_monitor API in virtio PMD. + * **Updated af_packet ethdev driver.** * Default VLAN strip behavior was changed. VLAN tag won't be strippeddrivers/net/virtio/virtio_ethdev.c +49
-0@@ -74,6 +74,8 @@ static int virtio_mac_addr_set(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr);static int virtio_intr_disable (struct rte_eth_dev *dev); +static int virtio_get_monitor_addr (void *rx_queue, +struct rte_power_monitor_cond *pmc); static int virtio_dev_queue_stats_mapping_set( struct rte_eth_dev *eth_dev,@@ -982,6 +984,7 @@ static const struct eth_dev_ops virtio_eth_dev_ops = { .mac_addr_add = virtio_mac_addr_add, .mac_addr_remove = virtio_mac_addr_remove, .mac_addr_set = virtio_mac_addr_set, + .get_monitor_addr = virtio_get_monitor_addr, };/* @@ -1313,6 +1316,59 @@ virtio_mac_addr_set(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr)return 0 ; } +#define CLB_VAL_IDX 0 +#define CLB_MSK_IDX 1 +#define CLB_MATCH_IDX 2 +static int +virtio_monitor_callback (const uint64_t value, +const uint64_t opaque[RTE_POWER_MONITOR_OPAQUE_SZ ]) +{ +const uint64_t m = opaque[CLB_MSK_IDX ]; +const uint64_t v = opaque[CLB_VAL_IDX ]; +const uint64_t c = opaque[CLB_MATCH_IDX ]; + +if (c) +return (value & m) == v ?-1 :0 ; +else +return (value & m) == v ?0 :-1 ; +} + +static int +virtio_get_monitor_addr (void *rx_queue,struct rte_power_monitor_cond *pmc) +{ +struct virtnet_rx *rxvq = rx_queue; +struct virtqueue *vq =virtnet_rxq_to_vq (rxvq); +struct virtio_hw *hw; + +if (vq ==NULL ) +return -EINVAL ; + + hw = vq->hw; +if (virtio_with_packed_queue (hw)) { +struct vring_packed_desc *desc; + desc = vq->vq_packed.ring.desc; + pmc->addr = &desc[vq->vq_used_cons_idx].flags; +if (vq->vq_packed.used_wrap_counter) + pmc->opaque[CLB_VAL_IDX ] = +VRING_PACKED_DESC_F_AVAIL_USED ; +else + pmc->opaque[CLB_VAL_IDX ] =0 ; + pmc->opaque[CLB_MSK_IDX ] =VRING_PACKED_DESC_F_AVAIL_USED ; + pmc->opaque[CLB_MATCH_IDX ] =1 ; + pmc->size =sizeof (desc[vq->vq_used_cons_idx].flags); + }else { + pmc->addr = &vq->vq_split.ring.used->idx; + pmc->opaque[CLB_VAL_IDX ] = vq->vq_used_cons_idx + & (vq->vq_nentries -1 ); + pmc->opaque[CLB_MSK_IDX ] = vq->vq_nentries -1 ; + pmc->opaque[CLB_MATCH_IDX ] =0 ;
drivers/net/virtio/virtio_ethdev.c virtio_mac_addr_set(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr) · line 1374
Quoted 10 lines
drivers/net/virtio/virtio_ethdev.c +7
-0+ pmc->size =sizeof (vq->vq_split.ring.used->idx); + } + pmc->fn = virtio_monitor_callback; + +return 0 ; +} +static int virtio_vlan_filter_set (struct rte_eth_dev *dev,uint16_t vlan_id,int on) {
LGTM.
PATCH v7 2/5 vhost: implement rte_power_monitor API
In reply to Miao LiThis patch defines rte_vhost_power_monitor_cond which is used to pass some information to vhost driver. The information is including the address to monitor, the expected value, the mask to extract value read from 'addr', the value size of monitor address, the match flag used to distinguish the value used to match something or not match something. Vhost driver can use these information to fill rte_power_monitor_cond.
--- doc/guides/rel_notes/release_21_11.rst | 4 +++ lib/vhost/rte_vhost.h | 42 ++++++++++++++++++++++++++ lib/vhost/version.map | 3 ++ lib/vhost/vhost.c | 38 +++++++++++++++++++++++ 4 files changed, 87 insertions(+)
doc/guides/rel_notes/release_21_11.rst +4 -0
@@ -80,6 +80,10 @@ New Features Added macros ETH_RSS_IPV4_CHKSUM and ETH_RSS_L4_CHKSUM, now IPv4 and TCP/UDP/SCTP header checksum field can be used as input set for RSS. +* **Added power monitor API in vhost library.** + + Added an API to support power monitor in vhost library. + * **Updated virtio PMD.** Implement rte_power_monitor API in virtio PMD.
lib/vhost/rte_vhost.h +42 -0
54 lines not on this page · raw message
lib/vhost/version.map +3 -0
@@ -85,4 +85,7 @@ EXPERIMENTAL { rte_vhost_async_channel_register_thread_unsafe; rte_vhost_async_channel_unregister_thread_unsafe; rte_vhost_clear_queue_thread_unsafe; + + # added in 21.11 + rte_vhost_get_monitor_addr; };
lib/vhost/vhost.c +38 -0
@@ -1889,5 +1889,43 @@ rte_vhost_async_get_inflight(int vid, uint16_t queue_id)return ret; } +int +rte_vhost_get_monitor_addr (int vid,uint16_t queue_id, +struct rte_vhost_power_monitor_cond *pmc) +{ +struct virtio_net *dev =get_device (vid); +struct vhost_virtqueue *vq; + +if (dev ==NULL ) +return -1 ; +if (queue_id >=VHOST_MAX_VRING ) +return -1 ; + + vq = dev->virtqueue[queue_id]; +if (vq ==NULL ) +return -1 ; + +if (vq_is_packed (dev)) { +struct vring_packed_desc *desc; + desc = vq->desc_packed; + pmc->addr = &desc[vq->last_avail_idx].flags; +if (vq->avail_wrap_counter) + pmc->val =VRING_DESC_F_AVAIL ; +else + pmc->val =VRING_DESC_F_USED ; + pmc->mask =VRING_DESC_F_AVAIL |VRING_DESC_F_USED ; + pmc->size =sizeof (desc[vq->last_avail_idx].flags); + pmc->match =1 ; + }else { + pmc->addr = &vq->avail->idx; + pmc->val = vq->last_avail_idx & (vq->size -1 ); + pmc->mask = vq->size -1 ; + pmc->size =sizeof (vq->avail->idx); + pmc->match =0 ; + } + +return 0 ; +} +RTE_LOG_REGISTER_SUFFIX (vhost_config_log_level, config,INFO );RTE_LOG_REGISTER_SUFFIX (vhost_data_log_level, data,WARNING );
Signature · 1 line
2.25.1
Re: [dpdk-dev] [PATCH v7 2/5] vhost: implement rte_power_monitor API
Quoted 160 lines
-----Original Message-----
From: Li, Miao <[email protected]>
Sent: Monday, October 18, 2021 10:17 PM
To: [email protected]
Cc: Xia, Chenbo <[email protected]>; [email protected]; Li, Miao <[email protected]>
Subject: [PATCH v7 2/5] vhost: implementrte_power_monitorAPIThis patch defines
rte_vhost_power_monitor_condwhich is used to pass some information to vhost driver. The information is including the address to monitor, the expected value, the mask to extract value read from 'addr', the value size of monitor address, the match flag used to distinguish the value used to match something or not match something. Vhost driver can use these information to fillrte_power_monitor_cond.Signed-off-by Miao Li <[email protected]>--- doc/guides/rel_notes/release_21_11.rst | 4 +++ lib/vhost/rte_vhost.h | 42 ++++++++++++++++++++++++++ lib/vhost/version.map | 3 ++ lib/vhost/vhost.c | 38 +++++++++++++++++++++++ 4 files changed, 87 insertions(+)doc/guides/rel_notes/release_21_11.rst +4
-0@@ -80,6 +80,10 @@ New Features Added macros ETH_RSS_IPV4_CHKSUM and ETH_RSS_L4_CHKSUM, now IPv4 and TCP/UDP/SCTP header checksum field can be used as input set for RSS. +* **Added power monitor API in vhost library.** + + Added an API to support power monitor in vhost library. + * **Updated virtio PMD.** Implement rte_power_monitor API in virtio PMD.lib/vhost/rte_vhost.h +42
-0@@ -292,6 +292,31 @@ struct vhost_device_ops {void *reserved[1 ];/**< Reserved for future extension */ }; +/** +* Power monitor condition. +*/ +struct rte_vhost_power_monitor_cond { +/**< Address to monitor for changes */ +volatile void *addr; +/**< If the `mask` is non-zero, location pointed +* to by `addr` will be read and masked, then +* compared with this value. +*/ +uint64_t val; +/**< 64-bit mask to extract value read from `addr` */ +uint64_t mask; +/**< Data size (in bytes) that will be read from the +* monitored memory location (`addr`). +*/ +uint8_t size; +/**< If 1, and masked value that read from 'addr' equals +* 'val', the driver should skip core sleep. If 0, and +* masked value that read from 'addr' does not equal 'val', +* the driver should skip core sleep. +*/ +uint8_t match; +}; +/** * Convert guest physical address to host virtual address * @@ -903,6 +928,23 @@ int rte_vhost_vring_call(int vid, uint16_t vring_idx);*/ uint32_t rte_vhost_rx_queue_count (int vid,uint16_t qid); +/** +* Get power monitor address of the vhost device +* +* @param vid +* vhost device ID +* @param queue_id +* vhost queue ID +* @param pmc +* power monitor condition +* @return +* 0 on success, -1 on failure +*/ +__rte_experimental +int +rte_vhost_get_monitor_addr (int vid,uint16_t queue_id, +struct rte_vhost_power_monitor_cond *pmc); +/** * Get log base and log size of the vhost device * lib/vhost/version.map +3
-0@@ -85,4 +85,7 @@ EXPERIMENTAL { rte_vhost_async_channel_register_thread_unsafe; rte_vhost_async_channel_unregister_thread_unsafe; rte_vhost_clear_queue_thread_unsafe; + + # added in 21.11 + rte_vhost_get_monitor_addr; };lib/vhost/vhost.c +38
-1@@ -1889,5 +1889,43 @@ rte_vhost_async_get_inflight(int vid, uint16_t queue_id)return ret; } +int +rte_vhost_get_monitor_addr (int vid,uint16_t queue_id, +struct rte_vhost_power_monitor_cond *pmc) +{ +struct virtio_net *dev =get_device (vid); +struct vhost_virtqueue *vq; + +if (dev ==NULL ) +return -1 ; +if (queue_id >=VHOST_MAX_VRING ) +return -1 ; + + vq = dev->virtqueue[queue_id]; +if (vq ==NULL ) +return -1 ; + +if (vq_is_packed (dev)) { +struct vring_packed_desc *desc; + desc = vq->desc_packed; + pmc->addr = &desc[vq->last_avail_idx].flags; +if (vq->avail_wrap_counter) + pmc->val =VRING_DESC_F_AVAIL ; +else + pmc->val =VRING_DESC_F_USED ; + pmc->mask =VRING_DESC_F_AVAIL |VRING_DESC_F_USED ; + pmc->size =sizeof (desc[vq->last_avail_idx].flags); + pmc->match =1 ; + }else { + pmc->addr = &vq->avail->idx; + pmc->val = vq->last_avail_idx & (vq->size -1 ); + pmc->mask = vq->size -1 ; + pmc->size =sizeof (vq->avail->idx); + pmc->match =0 ; + } + +return 0 ; +} +RTE_LOG_REGISTER_SUFFIX (vhost_config_log_level, config,INFO );RTE_LOG_REGISTER_SUFFIX (vhost_data_log_level, data,WARNING ); --
Quoted 1 line
2.25.1
David Hunt
Acked-byRe: [dpdk-dev] [PATCH v7 2/5] vhost: implement rte_power_monitor API
Quoted 154 lines · Chenbo
Quoted 154 lines
-----Original Message-----
From: Li, Miao <[email protected]>
Sent: Monday, October 18, 2021 10:17 PM
To: [email protected]
Cc: Xia, Chenbo <[email protected]>; [email protected]; Li, Miao <[email protected]>
Subject: [PATCH v7 2/5] vhost: implementrte_power_monitorAPIThis patch defines
rte_vhost_power_monitor_condwhich is used to pass some information to vhost driver. The information is including the address to monitor, the expected value, the mask to extract value read from 'addr', the value size of monitor address, the match flag used to distinguish the value used to match something or not match something. Vhost driver can use these information to fillrte_power_monitor_cond.Signed-off-by Miao Li <[email protected]>--- doc/guides/rel_notes/release_21_11.rst | 4 +++ lib/vhost/rte_vhost.h | 42 ++++++++++++++++++++++++++ lib/vhost/version.map | 3 ++ lib/vhost/vhost.c | 38 +++++++++++++++++++++++ 4 files changed, 87 insertions(+)doc/guides/rel_notes/release_21_11.rst +4
-0@@ -80,6 +80,10 @@ New Features Added macros ETH_RSS_IPV4_CHKSUM and ETH_RSS_L4_CHKSUM, now IPv4 and TCP/UDP/SCTP header checksum field can be used as input set for RSS. +* **Added power monitor API in vhost library.** + + Added an API to support power monitor in vhost library. + * **Updated virtio PMD.** Implement rte_power_monitor API in virtio PMD.lib/vhost/rte_vhost.h +42
-0@@ -292,6 +292,31 @@ struct vhost_device_ops {void *reserved[1 ];/**< Reserved for future extension */ }; +/** +* Power monitor condition. +*/ +struct rte_vhost_power_monitor_cond { +/**< Address to monitor for changes */ +volatile void *addr; +/**< If the `mask` is non-zero, location pointed +* to by `addr` will be read and masked, then +* compared with this value. +*/ +uint64_t val; +/**< 64-bit mask to extract value read from `addr` */ +uint64_t mask; +/**< Data size (in bytes) that will be read from the +* monitored memory location (`addr`). +*/ +uint8_t size; +/**< If 1, and masked value that read from 'addr' equals +* 'val', the driver should skip core sleep. If 0, and +* masked value that read from 'addr' does not equal 'val', +* the driver should skip core sleep. +*/ +uint8_t match; +}; +/** * Convert guest physical address to host virtual address * @@ -903,6 +928,23 @@ int rte_vhost_vring_call(int vid, uint16_t vring_idx);*/ uint32_t rte_vhost_rx_queue_count (int vid,uint16_t qid); +/** +* Get power monitor address of the vhost device +* +* @param vid +* vhost device ID +* @param queue_id +* vhost queue ID +* @param pmc +* power monitor condition +* @return +* 0 on success, -1 on failure +*/ +__rte_experimental +int +rte_vhost_get_monitor_addr (int vid,uint16_t queue_id, +struct rte_vhost_power_monitor_cond *pmc); +/** * Get log base and log size of the vhost device * lib/vhost/version.map +3
-0@@ -85,4 +85,7 @@ EXPERIMENTAL { rte_vhost_async_channel_register_thread_unsafe; rte_vhost_async_channel_unregister_thread_unsafe; rte_vhost_clear_queue_thread_unsafe; + + # added in 21.11 + rte_vhost_get_monitor_addr; };lib/vhost/vhost.c +35
-0@@ -1889,5 +1889,43 @@ rte_vhost_async_get_inflight(int vid, uint16_t queue_id)return ret; } +int +rte_vhost_get_monitor_addr (int vid,uint16_t queue_id, +struct rte_vhost_power_monitor_cond *pmc) +{ +struct virtio_net *dev =get_device (vid); +struct vhost_virtqueue *vq; + +if (dev ==NULL ) +return -1 ; +if (queue_id >=VHOST_MAX_VRING ) +return -1 ; + + vq = dev->virtqueue[queue_id]; +if (vq ==NULL ) +return -1 ; + +if (vq_is_packed (dev)) { +struct vring_packed_desc *desc; + desc = vq->desc_packed; + pmc->addr = &desc[vq->last_avail_idx].flags; +if (vq->avail_wrap_counter) + pmc->val =VRING_DESC_F_AVAIL ; +else + pmc->val =VRING_DESC_F_USED ; + pmc->mask =VRING_DESC_F_AVAIL |VRING_DESC_F_USED ; + pmc->size =sizeof (desc[vq->last_avail_idx].flags); + pmc->match =1 ; + }else { + pmc->addr = &vq->avail->idx; + pmc->val = vq->last_avail_idx & (vq->size -1 ); + pmc->mask = vq->size -1 ; + pmc->size =sizeof (vq->avail->idx); + pmc->match =0 ; + } +
Quoted 8 lines
Quoted 7 lines
lib/vhost/vhost.c +3
-1+return 0 ; +} +RTE_LOG_REGISTER_SUFFIX (vhost_config_log_level, config,INFO );RTE_LOG_REGISTER_SUFFIX (vhost_data_log_level, data,WARNING ); --2.25.1
Reviewed-by Chenbo Xia <[email protected]>
PATCH v7 3/5 net/vhost: implement rte_power_monitor API
In reply to Miao LiThis patch implements rte_power_monitor API in vhost PMD to reduce power consumption when no packet come in. According to current semantics of power monitor, this commit adds a callback function to decide whether aborts the sleep by checking current value against the expected value and vhost_get_monitor_addr to provide address to monitor. When no packet come in, the value of address will not be changed and the running core will sleep. Once packets arrive, the value of address will be changed and the running core will wakeup.
--- doc/guides/rel_notes/release_21_11.rst | 4 +++ drivers/net/vhost/rte_eth_vhost.c | 40 ++++++++++++++++++++++++++ 2 files changed, 44 insertions(+)
doc/guides/rel_notes/release_21_11.rst +4 -0
@@ -84,6 +84,10 @@ New Features Added an API to support power monitor in vhost library. +* **Updated vhost PMD.** + + Implement rte_power_monitor API in vhost PMD. + * **Updated virtio PMD.** Implement rte_power_monitor API in virtio PMD.
drivers/net/vhost/rte_eth_vhost.c +40 -0
@@ -1386,6 +1386,45 @@ eth_rx_queue_count(struct rte_eth_dev *dev, uint16_t rx_queue_id)return rte_vhost_rx_queue_count (vq->vid, vq->virtqueue_id); } +#define CLB_VAL_IDX 0 +#define CLB_MSK_IDX 1 +#define CLB_MATCH_IDX 2 +static int +vhost_monitor_callback (const uint64_t value, +const uint64_t opaque[RTE_POWER_MONITOR_OPAQUE_SZ ]) +{ +const uint64_t m = opaque[CLB_MSK_IDX ]; +const uint64_t v = opaque[CLB_VAL_IDX ]; +const uint64_t c = opaque[CLB_MATCH_IDX ]; + +if (c) +return (value & m) == v ?-1 :0 ; +else +return (value & m) == v ?0 :-1 ; +} + +static int +vhost_get_monitor_addr (void *rx_queue,struct rte_power_monitor_cond *pmc) +{ +struct vhost_queue *vq = rx_queue; +struct rte_vhost_power_monitor_cond vhost_pmc; +int ret; +if (vq ==NULL ) +return -EINVAL ; + ret =rte_vhost_get_monitor_addr (vq->vid, vq->virtqueue_id, + &vhost_pmc); +if (ret <0 ) +return -EINVAL ; + pmc->addr = vhost_pmc.addr; + pmc->opaque[CLB_VAL_IDX ] = vhost_pmc.val; + pmc->opaque[CLB_MSK_IDX ] = vhost_pmc.mask; + pmc->opaque[CLB_MATCH_IDX ] = vhost_pmc.match; + pmc->size = vhost_pmc.size; + pmc->fn = vhost_monitor_callback; + +return 0 ; +} +static const struct eth_dev_ops ops = { .dev_start = eth_dev_start, .dev_stop = eth_dev_stop,
@@ -1405,6 +1444,7 @@ static const struct eth_dev_ops ops = { .xstats_get_names = vhost_dev_xstats_get_names, .rx_queue_intr_enable = eth_rxq_intr_enable, .rx_queue_intr_disable = eth_rxq_intr_disable, + .get_monitor_addr = vhost_get_monitor_addr, }; static int
Signature · 1 line
2.25.1
Re: [dpdk-dev] [PATCH v7 3/5] net/vhost: implement rte_power_monitor API
Quoted 100 lines
-----Original Message-----
From: Li, Miao <[email protected]>
Sent: Monday, October 18, 2021 10:17 PM
To: [email protected]
Cc: Xia, Chenbo <[email protected]>; [email protected]; Li, Miao <[email protected]>
Subject: [PATCH v7 3/5] net/vhost: implementrte_power_monitorAPIThis patch implements
rte_power_monitorAPI in vhost PMD to reduce power consumption when no packet come in. According to current semantics of power monitor, this commit adds a callback function to decide whether aborts the sleep by checking current value against the expected value andvhost_get_monitor_addrto provide address to monitor. When no packet come in, the value of address will not be changed and the running core will sleep. Once packets arrive, the value of address will be changed and the running core will wakeup.Signed-off-by Miao Li <[email protected]>--- doc/guides/rel_notes/release_21_11.rst | 4 +++ drivers/net/vhost/rte_eth_vhost.c | 40 ++++++++++++++++++++++++++ 2 files changed, 44 insertions(+)doc/guides/rel_notes/release_21_11.rst +4
-0@@ -84,6 +84,10 @@ New Features Added an API to support power monitor in vhost library. +* **Updated vhost PMD.** + + Implement rte_power_monitor API in vhost PMD. + * **Updated virtio PMD.** Implement rte_power_monitor API in virtio PMD.drivers/net/vhost/rte_eth_vhost.c +39
-0@@ -1386,6 +1386,45 @@ eth_rx_queue_count(struct rte_eth_dev *dev, uint16_t rx_queue_id)return rte_vhost_rx_queue_count (vq->vid, vq->virtqueue_id); } +#define CLB_VAL_IDX 0 +#define CLB_MSK_IDX 1 +#define CLB_MATCH_IDX 2 +static int +vhost_monitor_callback (const uint64_t value, +const uint64_t opaque[RTE_POWER_MONITOR_OPAQUE_SZ ]) +{ +const uint64_t m = opaque[CLB_MSK_IDX ]; +const uint64_t v = opaque[CLB_VAL_IDX ]; +const uint64_t c = opaque[CLB_MATCH_IDX ]; + +if (c) +return (value & m) == v ?-1 :0 ; +else +return (value & m) == v ?0 :-1 ; +} + +static int +vhost_get_monitor_addr (void *rx_queue,struct rte_power_monitor_cond *pmc) +{ +struct vhost_queue *vq = rx_queue; +struct rte_vhost_power_monitor_cond vhost_pmc; +int ret; +if (vq ==NULL ) +return -EINVAL ; + ret =rte_vhost_get_monitor_addr (vq->vid, vq->virtqueue_id, + &vhost_pmc); +if (ret <0 ) +return -EINVAL ; + pmc->addr = vhost_pmc.addr; + pmc->opaque[CLB_VAL_IDX ] = vhost_pmc.val; + pmc->opaque[CLB_MSK_IDX ] = vhost_pmc.mask; + pmc->opaque[CLB_MATCH_IDX ] = vhost_pmc.match; + pmc->size = vhost_pmc.size; + pmc->fn = vhost_monitor_callback; + +return 0 ; +} +static const struct eth_dev_ops ops = { .dev_start = eth_dev_start,drivers/net/vhost/rte_eth_vhost.c +1
-1.dev_stop = eth_dev_stop,@@ -1405,6 +1444,7 @@ static const struct eth_dev_ops ops = { .xstats_get_names = vhost_dev_xstats_get_names, .rx_queue_intr_enable = eth_rxq_intr_enable, .rx_queue_intr_disable = eth_rxq_intr_disable, + .get_monitor_addr = vhost_get_monitor_addr, }; static int --
Quoted 1 line
2.25.1
David Hunt
Acked-byRe: [dpdk-dev] [PATCH v7 3/5] net/vhost: implement rte_power_monitor API
Quoted 98 lines · Chenbo
Quoted 98 lines
-----Original Message-----
From: Li, Miao <[email protected]>
Sent: Monday, October 18, 2021 10:17 PM
To: [email protected]
Cc: Xia, Chenbo <[email protected]>; [email protected]; Li, Miao <[email protected]>
Subject: [PATCH v7 3/5] net/vhost: implementrte_power_monitorAPIThis patch implements
rte_power_monitorAPI in vhost PMD to reduce power consumption when no packet come in. According to current semantics of power monitor, this commit adds a callback function to decide whether aborts the sleep by checking current value against the expected value andvhost_get_monitor_addrto provide address to monitor. When no packet come in, the value of address will not be changed and the running core will sleep. Once packets arrive, the value of address will be changed and the running core will wakeup.Signed-off-by Miao Li <[email protected]>--- doc/guides/rel_notes/release_21_11.rst | 4 +++ drivers/net/vhost/rte_eth_vhost.c | 40 ++++++++++++++++++++++++++ 2 files changed, 44 insertions(+)doc/guides/rel_notes/release_21_11.rst +4
-0@@ -84,6 +84,10 @@ New Features Added an API to support power monitor in vhost library. +* **Updated vhost PMD.** + + Implement rte_power_monitor API in vhost PMD. + * **Updated virtio PMD.** Implement rte_power_monitor API in virtio PMD.drivers/net/vhost/rte_eth_vhost.c +39
-0@@ -1386,6 +1386,45 @@ eth_rx_queue_count(struct rte_eth_dev *dev, uint16_t rx_queue_id)return rte_vhost_rx_queue_count (vq->vid, vq->virtqueue_id); } +#define CLB_VAL_IDX 0 +#define CLB_MSK_IDX 1 +#define CLB_MATCH_IDX 2 +static int +vhost_monitor_callback (const uint64_t value, +const uint64_t opaque[RTE_POWER_MONITOR_OPAQUE_SZ ]) +{ +const uint64_t m = opaque[CLB_MSK_IDX ]; +const uint64_t v = opaque[CLB_VAL_IDX ]; +const uint64_t c = opaque[CLB_MATCH_IDX ]; + +if (c) +return (value & m) == v ?-1 :0 ; +else +return (value & m) == v ?0 :-1 ; +} + +static int +vhost_get_monitor_addr (void *rx_queue,struct rte_power_monitor_cond *pmc) +{ +struct vhost_queue *vq = rx_queue; +struct rte_vhost_power_monitor_cond vhost_pmc; +int ret; +if (vq ==NULL ) +return -EINVAL ; + ret =rte_vhost_get_monitor_addr (vq->vid, vq->virtqueue_id, + &vhost_pmc); +if (ret <0 ) +return -EINVAL ; + pmc->addr = vhost_pmc.addr; + pmc->opaque[CLB_VAL_IDX ] = vhost_pmc.val; + pmc->opaque[CLB_MSK_IDX ] = vhost_pmc.mask; + pmc->opaque[CLB_MATCH_IDX ] = vhost_pmc.match; + pmc->size = vhost_pmc.size; + pmc->fn = vhost_monitor_callback; + +return 0 ; +} +static const struct eth_dev_ops ops = { .dev_start = eth_dev_start,.dev_stop =
eth_dev_stop,drivers/net/vhost/rte_eth_vhost.c +1
-0@@ -1405,6 +1444,7 @@ static const struct eth_dev_ops ops = { .xstats_get_names = vhost_dev_xstats_get_names, .rx_queue_intr_enable = eth_rxq_intr_enable, .rx_queue_intr_disable = eth_rxq_intr_disable, + .get_monitor_addr = vhost_get_monitor_addr, };
Quoted 4 lines
Quoted 3 lines
drivers/net/vhost/rte_eth_vhost.c +0
-1static int --2.25.1
Reviewed-by Chenbo Xia <[email protected]>
PATCH v7 4/5 power: modify return of queue_stopped
In reply to Miao LiSince some vdevs like virtio and vhost do not support rxq_info_get and queue state inquiry, the error return value -ENOTSUP need to be ignored when queue_stopped cannot get rx queue information and rx queue state. This patch changes the return value of queue_stopped when rte_eth_rx_queue_info_get return -ENOTSUP to support vdevs which cannot provide rx queue information and rx queue state enable power management.
--- lib/power/rte_power_pmd_mgmt.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
lib/power/rte_power_pmd_mgmt.c +7 -2
@@ -382,8 +382,13 @@ queue_stopped(const uint16_t port_id, const uint16_t queue_id) {struct rte_eth_rxq_info qinfo; -if (rte_eth_rx_queue_info_get (port_id, queue_id, &qinfo) <0 ) -return -1 ; +int ret =rte_eth_rx_queue_info_get (port_id, queue_id, &qinfo); +if (ret <0 ) { +if (ret == -ENOTSUP ) +return 1 ; +else +return -1 ; + }return qinfo.queue_state ==RTE_ETH_QUEUE_STATE_STOPPED ; }
Signature · 1 line
2.25.1
Re: [dpdk-dev] [PATCH v7 4/5] power: modify return of queue_stopped
Quoted 7 lines · Miao Li
Since some vdevs like virtio and vhost do not support
rxq_info_getand queue state inquiry, the error return value-ENOTSUPneed to be ignored whenqueue_stoppedcannot get rx queue information and rx queue state. This patch changes the return value ofqueue_stoppedwhenrte_eth_rx_queue_info_getreturn-ENOTSUPto support vdevs which cannot provide rx queue information and rx queue state enable power management.
Don't we want to backport this patch? In case later a patch in the main repo relies on this return type and that needs to be merged to LTS...
Also need to clarify if this is a fix or not.
Quoted 3 lines
Signed-off-by Miao Li <[email protected]>Acked-by Anatoly Burakov <[email protected]>Reviewed-by Chenbo Xia <[email protected]>
power library maintainer ack/review is missing.
Quoted 25 lines
--- lib/power/rte_power_pmd_mgmt.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)lib/power/rte_power_pmd_mgmt.c +7
-2@@ -382,8 +382,13 @@ queue_stopped(const uint16_t port_id, const uint16_t queue_id) {struct rte_eth_rxq_info qinfo; -if (rte_eth_rx_queue_info_get (port_id, queue_id, &qinfo) <0 ) -return -1 ; +int ret =rte_eth_rx_queue_info_get (port_id, queue_id, &qinfo); +if (ret <0 ) { +if (ret == -ENOTSUP ) +return 1 ; +else +return -1 ; + }return qinfo.queue_state ==RTE_ETH_QUEUE_STATE_STOPPED ; }
Re: [dpdk-dev] [PATCH v7 4/5] power: modify return of queue_stopped
Hi,
Quoted 18 lines
-----Original Message-----
From: Yigit, Ferruh <[email protected]>
Sent: Friday, October 22, 2021 12:48 AM
To: Li, Miao <[email protected]>; [email protected]; Hunt, David <[email protected]>
Cc: Xia, Chenbo <[email protected]>; [email protected]; Burakov, Anatoly <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v7 4/5] power: modify return ofqueue_stoppedQuoted 7 lines · Miao Li
Since some vdevs like virtio and vhost do not support
rxq_info_getand queue state inquiry, the error return value-ENOTSUPneed to be ignored whenqueue_stoppedcannot get rx queue information and rx queue state. This patch changes the return value ofqueue_stoppedwhenrte_eth_rx_queue_info_getreturn-ENOTSUPto support vdevs which cannot provide rx queue information and rx queue state enable power management.
Quoted 4 lines
Don't we want to backport this patch? In case later a patch in the main repo relies on this return type and that needs to be merged to LTS...
Also need to clarify if this is a fix or not.
Yes, it is a fix. I will backport this patch to LTS in the next version.
Thanks,
Miao
Quoted 34 lines
Quoted 4 lines
Signed-off-by Miao Li <[email protected]>Acked-by Anatoly Burakov <[email protected]>Reviewed-by Chenbo Xia <[email protected]>power library maintainer ack/review is missing.
Review
Quoted 5 lines
--- lib/power/rte_power_pmd_mgmt.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)(quoted diff) +0
-0
b/lib/power/rte_power_pmd_mgmt.clib/power/rte_power_pmd_mgmt.c queue_stopped(const uint16_t port_id, const
Quoted 4 lines
index
0ce40f0875..39a2b4cd23100644lib/power/rte_power_pmd_mgmt.c +0
-0@@ -382,8 +382,13 @@ queue_stopped(const uint16_t port_id, const
uint16_tqueue_id)Quoted 16 lines
lib/power/rte_power_pmd_mgmt.c +7
-2{struct rte_eth_rxq_info qinfo; -if (rte_eth_rx_queue_info_get (port_id, queue_id, &qinfo) <0 ) -return -1 ; +int ret =rte_eth_rx_queue_info_get (port_id, queue_id, &qinfo); +if (ret <0 ) { +if (ret == -ENOTSUP ) +return 1 ; +else +return -1 ; + }return qinfo.queue_state ==RTE_ETH_QUEUE_STATE_STOPPED ; }
Re: [dpdk-dev] [PATCH v7 4/5] power: modify return of queue_stopped
Quoted 20 lines · Miao
Hi,
Quoted 18 lines
-----Original Message-----
From: Yigit, Ferruh <[email protected]>
Sent: Friday, October 22, 2021 12:48 AM
To: Li, Miao <[email protected]>; [email protected]; Hunt, David <[email protected]>
Cc: Xia, Chenbo <[email protected]>; [email protected]; Burakov, Anatoly <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v7 4/5] power: modify return ofqueue_stoppedQuoted 7 lines · Miao Li
Since some vdevs like virtio and vhost do not support
rxq_info_getand queue state inquiry, the error return value-ENOTSUPneed to be ignored whenqueue_stoppedcannot get rx queue information and rx queue state. This patch changes the return value ofqueue_stoppedwhenrte_eth_rx_queue_info_getreturn-ENOTSUPto support vdevs which cannot provide rx queue information and rx queue state enable power management.
Quoted 7 lines
Quoted 4 lines
Don't we want to backport this patch? In case later a patch in the main repo relies on this return type and that needs to be merged to LTS...
Also need to clarify if this is a fix or not.
Yes, it is a fix. I will backport this patch to LTS in the next version.
If so can you please update the Fixes and stable tags?
This way it will be part of backporting process.
Quoted 38 lines
Thanks,
MiaoQuoted 34 lines
Quoted 4 lines
Signed-off-by Miao Li <[email protected]>Acked-by Anatoly Burakov <[email protected]>Reviewed-by Chenbo Xia <[email protected]>power library maintainer ack/review is missing.
Review
Quoted 5 lines
--- lib/power/rte_power_pmd_mgmt.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)(quoted diff) +0
-0
b/lib/power/rte_power_pmd_mgmt.clib/power/rte_power_pmd_mgmt.c queue_stopped(const uint16_t port_id, const
Quoted 4 lines
index
0ce40f0875..39a2b4cd23100644lib/power/rte_power_pmd_mgmt.c +0
-0@@ -382,8 +382,13 @@ queue_stopped(const uint16_t port_id, const
uint16_tqueue_id)Quoted 16 lines
lib/power/rte_power_pmd_mgmt.c +7
-2{struct rte_eth_rxq_info qinfo; -if (rte_eth_rx_queue_info_get (port_id, queue_id, &qinfo) <0 ) -return -1 ; +int ret =rte_eth_rx_queue_info_get (port_id, queue_id, &qinfo); +if (ret <0 ) { +if (ret == -ENOTSUP ) +return 1 ; +else +return -1 ; + }return qinfo.queue_state ==RTE_ETH_QUEUE_STATE_STOPPED ; }
Re: [dpdk-dev] [PATCH v7 4/5] power: modify return of queue_stopped
Hi,
Quoted 35 lines
-----Original Message-----
From: Yigit, Ferruh <[email protected]>
Sent: Friday, October 22, 2021 5:01 PM
To: Li, Miao <[email protected]>; [email protected]; Hunt, David <[email protected]>
Cc: Xia, Chenbo <[email protected]>; [email protected]; Burakov, Anatoly <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v7 4/5] power: modify return ofqueue_stoppedQuoted 10 lines · Miao
Hi,
Quoted 8 lines
-----Original Message-----
From: Yigit, Ferruh <[email protected]>
Sent: Friday, October 22, 2021 12:48 AM
To: Li, Miao <[email protected]>; [email protected]; Hunt, David <[email protected]>
Cc: Xia, Chenbo <[email protected]>; [email protected]; Burakov, Anatoly <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v7 4/5] power: modify return of
queue_stoppedQuoted 7 lines
Quoted 7 lines · Miao Li
Quoted 5 lines
Since some vdevs like virtio and vhost do not support
rxq_info_getand queue state inquiry, the error return value-ENOTSUPneed to be ignored whenqueue_stoppedcannot get rx queue information and rx queue state. This patch changes the return value ofqueue_stoppedwhenrte_eth_rx_queue_info_getreturn-ENOTSUPto support vdevs whichcannot
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines
provide rx queue information and rx queue state enable power management.
Don't we want to backport this patch? In case later a patch in the main repo relies on this return type and that needs to be merged to LTS...
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
Also need to clarify if this is a fix or not.
Yes, it is a fix. I will backport this patch to LTS in the next version.
If so can you please update the Fixes and stable tags?
This way it will be part of backporting process.
I will update them in the next version.
Thanks,
Miao
Quoted 39 lines
Quoted 39 lines
Thanks,
MiaoQuoted 34 lines
Quoted 4 lines
Signed-off-by Miao Li <[email protected]>Acked-by Anatoly Burakov <[email protected]>Reviewed-by Chenbo Xia <[email protected]>power library maintainer ack/review is missing.
Review
Quoted 5 lines
--- lib/power/rte_power_pmd_mgmt.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)(quoted diff) +0
-0
b/lib/power/rte_power_pmd_mgmt.clib/power/rte_power_pmd_mgmt.c queue_stopped(const uint16_t port_id, const
Quoted 4 lines
index
0ce40f0875..39a2b4cd23100644lib/power/rte_power_pmd_mgmt.c +0
-0@@ -382,8 +382,13 @@ queue_stopped(const uint16_t port_id, const
uint16_tqueue_id)Quoted 16 lines
lib/power/rte_power_pmd_mgmt.c +7
-2{struct rte_eth_rxq_info qinfo; -if (rte_eth_rx_queue_info_get (port_id, queue_id, &qinfo) <0 ) -return -1 ; +int ret =rte_eth_rx_queue_info_get (port_id, queue_id, &qinfo); +if (ret <0 ) { +if (ret == -ENOTSUP ) +return 1 ; +else +return -1 ; + }return qinfo.queue_state ==RTE_ETH_QUEUE_STATE_STOPPED ; }
Re: [dpdk-dev] [PATCH v7 4/5] power: modify return of queue_stopped
In reply to Ferruh YigitQuoted 12 lines · Ferruh Yigit
Quoted 7 lines · Miao Li
Since some vdevs like virtio and vhost do not support
rxq_info_getand queue state inquiry, the error return value-ENOTSUPneed to be ignored whenqueue_stoppedcannot get rx queue information and rx queue state. This patch changes the return value ofqueue_stoppedwhenrte_eth_rx_queue_info_getreturn-ENOTSUPto support vdevs which cannot provide rx queue information and rx queue state enable power management.Don't we want to backport this patch? In case later a patch in the main repo relies on this return type and that needs to be merged to LTS...
Quoted 7 lines
Also need to clarify if this is a fix or not.
Quoted 3 lines
Signed-off-by Miao Li <[email protected]>Acked-by Anatoly Burakov <[email protected]>Reviewed-by Chenbo Xia <[email protected]>power library maintainer ack/review is missing.
Hi Ferruh,
Anatoly's Ack is good on this, he's very familiar with this code. Rgds,
Dave.
--snip--
PATCH v7 5/5 examples/l3fwd-power: support virtio/vhost
In reply to Miao LiIn l3fwd-power, there is default port configuration which requires RSS and IPV4/UDP/TCP checksum. Once device does not support these, the l3fwd-power will exit and report an error.
This patch updates the port configuration based on device capabilities after getting the device information to support devices like virtio and vhost.
--- examples/l3fwd-power/main.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
examples/l3fwd-power/main.c +14 -1
@@ -505,7 +505,15 @@ is_valid_ipv4_pkt(struct rte_ipv4_hdr *pkt, uint32_t link_len)return -1 ;/* 2. The IP checksum must be correct. */ -/* this is checked in H/W */ +/* if this is not checked in H/W, check it. */ +if ((port_conf.rxmode.offloads &DEV_RX_OFFLOAD_IPV4_CKSUM ) ==0 ) { +uint16_t actual_cksum, expected_cksum; + actual_cksum = pkt->hdr_checksum; + pkt->hdr_checksum =0 ; + expected_cksum =rte_ipv4_cksum (pkt); +if (actual_cksum != expected_cksum) +return -2 ; + }/* * 3. The IP version number must be 4. If the version number is not 4
@@ -2637,6 +2645,11 @@ main(int argc, char **argv) local_port_conf.rx_adv_conf.rss_conf.rss_hf); } +if (local_port_conf.rx_adv_conf.rss_conf.rss_hf ==0 ) + local_port_conf.rxmode.mq_mode =ETH_MQ_RX_NONE ; + local_port_conf.rxmode.offloads &= dev_info.rx_offload_capa; + port_conf.rxmode.offloads = local_port_conf.rxmode.offloads; + ret =rte_eth_dev_configure (portid, nb_rx_queue, (uint16_t )n_tx_queue, &local_port_conf);if (ret <0 )
Signature · 1 line
2.25.1
Re: [dpdk-dev] [PATCH v7 5/5] examples/l3fwd-power: support virtio/vhost
Quoted 55 lines
-----Original Message-----
From: Li, Miao <[email protected]>
Sent: Monday, October 18, 2021 10:17 PM
To: [email protected]
Cc: Xia, Chenbo <[email protected]>; [email protected]; Li, Miao <[email protected]>
Subject: [PATCH v7 5/5] examples/l3fwd-power: support virtio/vhostIn l3fwd-power, there is default port configuration which requires RSS and IPV4/UDP/TCP checksum. Once device does not support these, the l3fwd-power will exit and report an error.
This patch updates the port configuration based on device capabilities after getting the device information to support devices like virtio and vhost.Signed-off-by Miao Li <[email protected]>--- examples/l3fwd-power/main.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)examples/l3fwd-power/main.c +9
-1@@ -505,7 +505,15 @@ is_valid_ipv4_pkt(struct rte_ipv4_hdr *pkt, uint32_t link_len)return -1 ;/* 2. The IP checksum must be correct. */ -/* this is checked in H/W */ +/* if this is not checked in H/W, check it. */ +if ((port_conf.rxmode.offloads &DEV_RX_OFFLOAD_IPV4_CKSUM ) ==0 ) { +uint16_t actual_cksum, expected_cksum; + actual_cksum = pkt->hdr_checksum; + pkt->hdr_checksum =0 ; + expected_cksum =rte_ipv4_cksum (pkt); +if (actual_cksum != expected_cksum) +return -2 ; + }/* examples/l3fwd-power/main.c +5
-1* 3. The IP version number must be 4. If the version number is not 4 @@ -2637,6 +2645,11 @@ main(int argc, char **argv) local_port_conf.rx_adv_conf.rss_conf.rss_hf); } +if (local_port_conf.rx_adv_conf.rss_conf.rss_hf ==0 ) + local_port_conf.rxmode.mq_mode =ETH_MQ_RX_NONE ; + local_port_conf.rxmode.offloads &= dev_info.rx_offload_capa; + port_conf.rxmode.offloads = local_port_conf.rxmode.offloads; + ret =rte_eth_dev_configure (portid, nb_rx_queue, (uint16_t )n_tx_queue, &local_port_conf);if (ret <0 ) --
Quoted 1 line
2.25.1
David Hunt
Acked-byRe: [dpdk-dev] [PATCH v7 5/5] examples/l3fwd-power: support virtio/vhost
Quoted 46 lines · Chenbo
Quoted 46 lines
-----Original Message-----
From: Li, Miao <[email protected]>
Sent: Monday, October 18, 2021 10:17 PM
To: [email protected]
Cc: Xia, Chenbo <[email protected]>; [email protected]; Li, Miao <[email protected]>
Subject: [PATCH v7 5/5] examples/l3fwd-power: support virtio/vhostIn l3fwd-power, there is default port configuration which requires RSS and IPV4/UDP/TCP checksum. Once device does not support these, the l3fwd-power will exit and report an error.
This patch updates the port configuration based on device capabilities after getting the device information to support devices like virtio and vhost.Signed-off-by Miao Li <[email protected]>--- examples/l3fwd-power/main.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)examples/l3fwd-power/main.c +9
-1@@ -505,7 +505,15 @@ is_valid_ipv4_pkt(struct rte_ipv4_hdr *pkt, uint32_t link_len)return -1 ;/* 2. The IP checksum must be correct. */ -/* this is checked in H/W */ +/* if this is not checked in H/W, check it. */ +if ((port_conf.rxmode.offloads &DEV_RX_OFFLOAD_IPV4_CKSUM ) ==0 ) { +uint16_t actual_cksum, expected_cksum; + actual_cksum = pkt->hdr_checksum; + pkt->hdr_checksum =0 ; + expected_cksum =rte_ipv4_cksum (pkt); +if (actual_cksum != expected_cksum) +return -2 ; + }/* * 3. The IP version number must be 4. If the version number is not 4
examples/l3fwd-power/main.c +0
-0@@ -2637,6 +2645,11 @@ main(int argc, char **argv) local_port_conf.rx_adv_conf.rss_conf.rss_hf); }
Quoted 11 lines
Quoted 10 lines
examples/l3fwd-power/main.c +5
-1+if (local_port_conf.rx_adv_conf.rss_conf.rss_hf ==0 ) + local_port_conf.rxmode.mq_mode =ETH_MQ_RX_NONE ; + local_port_conf.rxmode.offloads &= dev_info.rx_offload_capa; + port_conf.rxmode.offloads = local_port_conf.rxmode.offloads; + ret =rte_eth_dev_configure (portid, nb_rx_queue, (uint16_t )n_tx_queue, &local_port_conf);if (ret <0 ) --2.25.1
Reviewed-by Chenbo Xia <[email protected]>
LGTM.
Re: [dpdk-dev] [PATCH v7 5/5] examples/l3fwd-power: support virtio/vhost
In reply to Miao LiQuoted 10 lines · Miao Li
In l3fwd-power, there is default port configuration which requires RSS and IPV4/UDP/TCP checksum. Once device does not support these, the l3fwd-power will exit and report an error.
This patch updates the port configuration based on device capabilities after getting the device information to support devices like virtio and vhost.Signed-off-by Miao Li<[email protected]>--- examples/l3fwd-power/main.c | 15 ++++++++++++++-
'examples/l3fwd-power' maintainer ack is required.
Maxime Coquelin
AppliedRe: [dpdk-dev] [PATCH v7 0/5] Implement rte_power_monitor API in virtio/vhost PMD
In reply to Miao LiQuoted 43 lines · Miao Li
This patchset implements
rte_power_monitorAPI in virtio and vhost PMD to reduce power consumption when no packet come in. This API can be called and tested in l3fwd-power after adding vhost and virtio support in l3fwd-power and ignoring the rx queue information check inqueue_stopped().v7:
(quoted diff) +0
-2-fix coding style issues -Rebase on lastest repov6:
(quoted diff) +0
-3-modify comment -remove extra space -fix IPv4 CKSUM checkv5:
-Rebase on lastest repov4:
(quoted diff) +0
-3-modify comment -update the release note -add IPv4 CKSUM checkv3:
(quoted diff) +0
-2-fix some code format issues -fix spelling mistakev2:
(quoted diff) +0
-5-remove flag and add match and size in rte_vhost_power_monitor_cond -modify power callback function -add dev and queue id check and remove unnecessary check -fix the assignment of pmc->size -update port configuration according to the device information andremove adding command line arguments
-modify some titlesMiao Li (5):
net/virtio: implementrte_power_monitorAPI
vhost: implementrte_power_monitorAPI
net/vhost: implementrte_power_monitorAPI
power: modify return ofqueue_stopped
examples/l3fwd-power: support virtio/vhost
Quoted 10 lines
doc/guides/rel_notes/release_21_11.rst | 12 ++++++ drivers/net/vhost/rte_eth_vhost.c | 40 ++++++++++++++++++ drivers/net/virtio/virtio_ethdev.c | 56 ++++++++++++++++++++++++++ examples/l3fwd-power/main.c | 15 ++++++- lib/power/rte_power_pmd_mgmt.c | 9 ++++- lib/vhost/rte_vhost.h | 42 +++++++++++++++++++ lib/vhost/version.map | 3 ++ lib/vhost/vhost.c | 38 +++++++++++++++++ 8 files changed, 212 insertions(+), 3 deletions(-)
Applied to dpdk-next-virtio/main.
Thanks,
Maxime
v8 cover Support power monitor in virtio/vhost PMD
In reply to Miao LiThis patchset implements rte_power_monitor API in virtio and vhost PMD to reduce power consumption when no packet come in. This API can be called and tested in l3fwd-power after adding vhost and virtio support in l3fwd-power and ignoring the rx queue information check in queue_stopped().
v8:
-rebase on lastest repo
-update the release note
-modify some titles
-update commit log
-add the fixes and stable tags
v7:
-fix coding style issues
-rebase on lastest repo
v6:
-modify comment
-remove extra space
-fix IPv4 CKSUM check
v5:
-rebase on lastest repo
v4:
-modify comment
-update the release note
-add IPv4 CKSUM check
v3:
-fix some code format issues
-fix spelling mistake
v2:
-remove flag and add match and size in rte_vhost_power_monitor_cond -modify power callback function
-add dev and queue id check and remove unnecessary check -fix the assignment of pmc->size
-update port configuration according to the device information and remove adding command line arguments
-modify some titles
Miao Li (5):
net/virtio: support power monitor
vhost: add power monitor support API
net/vhost: support power monitor
power: modify return of queue_stopped
examples/l3fwd-power: support virtio/vhost
doc/guides/rel_notes/release_21_11.rst | 12 ++++++ drivers/net/vhost/rte_eth_vhost.c | 40 ++++++++++++++++++ drivers/net/virtio/virtio_ethdev.c | 56 ++++++++++++++++++++++++++ examples/l3fwd-power/main.c | 15 ++++++- lib/power/rte_power_pmd_mgmt.c | 9 ++++- lib/vhost/rte_vhost.h | 42 +++++++++++++++++++ lib/vhost/version.map | 3 ++ lib/vhost/vhost.c | 38 +++++++++++++++++ 8 files changed, 212 insertions(+), 3 deletions(-)
Signature · 1 line
2.25.1
PATCH v8 1/5 net/virtio: support power monitor
According to current semantics of power monitor, this commit adds a callback function to decide whether aborts the sleep by checking current value against the expected value and virtio_get_monitor_addr to provide address to monitor. When no packet come in, the value of address will not be changed and the running core will sleep. Once packets arrive, the value of address will be changed and the running core will wakeup.
--- doc/guides/rel_notes/release_21_11.rst | 4 ++ drivers/net/virtio/virtio_ethdev.c | 56 ++++++++++++++++++++++++++ 2 files changed, 60 insertions(+)
doc/guides/rel_notes/release_21_11.rst +4 -0
@@ -197,6 +197,10 @@ New Features * Added port representors support on SN1000 SmartNICs * Added flow API transfer proxy support +* **Updated virtio PMD.** + + Add power monitor support in virtio PMD. + * **Updated Marvell cnxk crypto PMD.** * Added AES-CBC SHA1-HMAC support in lookaside protocol (IPsec) for CN10K.
drivers/net/virtio/virtio_ethdev.c +56 -0
74 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v8 2/5 vhost: add power monitor support API
In reply to Miao LiThis commit defines rte_vhost_power_monitor_cond which is used to pass some information to vhost driver. The information is including the address to monitor, the expected value, the mask to extract value read from 'addr', the value size of monitor address, the match flag used to distinguish the value used to match something or not match something. Vhost driver can use these information to fill rte_power_monitor_cond.
--- doc/guides/rel_notes/release_21_11.rst | 4 +++ lib/vhost/rte_vhost.h | 42 ++++++++++++++++++++++++++ lib/vhost/version.map | 3 ++ lib/vhost/vhost.c | 38 +++++++++++++++++++++++ 4 files changed, 87 insertions(+)
doc/guides/rel_notes/release_21_11.rst +4 -0
@@ -197,6 +197,10 @@ New Features * Added port representors support on SN1000 SmartNICs * Added flow API transfer proxy support +* **Added power monitor API in vhost library.** + + Added an API to support power monitor in vhost library. + * **Updated virtio PMD.** Add power monitor support in virtio PMD.
lib/vhost/rte_vhost.h +42 -0
54 lines not on this page · raw message
lib/vhost/version.map +3 -0
@@ -85,4 +85,7 @@ EXPERIMENTAL { rte_vhost_async_channel_register_thread_unsafe; rte_vhost_async_channel_unregister_thread_unsafe; rte_vhost_clear_queue_thread_unsafe; + + # added in 21.11 + rte_vhost_get_monitor_addr; };
lib/vhost/vhost.c +38 -0
@@ -1892,5 +1892,43 @@ rte_vhost_async_get_inflight(int vid, uint16_t queue_id)return ret; } +int +rte_vhost_get_monitor_addr (int vid,uint16_t queue_id, +struct rte_vhost_power_monitor_cond *pmc) +{ +struct virtio_net *dev =get_device (vid); +struct vhost_virtqueue *vq; + +if (dev ==NULL ) +return -1 ; +if (queue_id >=VHOST_MAX_VRING ) +return -1 ; + + vq = dev->virtqueue[queue_id]; +if (vq ==NULL ) +return -1 ; + +if (vq_is_packed (dev)) { +struct vring_packed_desc *desc; + desc = vq->desc_packed; + pmc->addr = &desc[vq->last_avail_idx].flags; +if (vq->avail_wrap_counter) + pmc->val =VRING_DESC_F_AVAIL ; +else + pmc->val =VRING_DESC_F_USED ; + pmc->mask =VRING_DESC_F_AVAIL |VRING_DESC_F_USED ; + pmc->size =sizeof (desc[vq->last_avail_idx].flags); + pmc->match =1 ; + }else { + pmc->addr = &vq->avail->idx; + pmc->val = vq->last_avail_idx & (vq->size -1 ); + pmc->mask = vq->size -1 ; + pmc->size =sizeof (vq->avail->idx); + pmc->match =0 ; + } + +return 0 ; +} +RTE_LOG_REGISTER_SUFFIX (vhost_config_log_level, config,INFO );RTE_LOG_REGISTER_SUFFIX (vhost_data_log_level, data,WARNING );
Signature · 1 line
2.25.1
PATCH v8 3/5 net/vhost: support power monitor
In reply to Miao LiAccording to current semantics of power monitor, this commit adds a callback function to decide whether aborts the sleep by checking current value against the expected value and vhost_get_monitor_addr to provide address to monitor. When no packet come in, the value of address will not be changed and the running core will sleep. Once packets arrive, the value of address will be changed and the running core will wakeup.
--- doc/guides/rel_notes/release_21_11.rst | 4 +++ drivers/net/vhost/rte_eth_vhost.c | 40 ++++++++++++++++++++++++++ 2 files changed, 44 insertions(+)
doc/guides/rel_notes/release_21_11.rst +4 -0
@@ -201,6 +201,10 @@ New Features Added an API to support power monitor in vhost library. +* **Updated vhost PMD.** + + Add power monitor support in vhost PMD. + * **Updated virtio PMD.** Add power monitor support in virtio PMD.
drivers/net/vhost/rte_eth_vhost.c +40 -0
@@ -1380,6 +1380,45 @@ eth_rx_queue_count(void *rx_queue)return rte_vhost_rx_queue_count (vq->vid, vq->virtqueue_id); } +#define CLB_VAL_IDX 0 +#define CLB_MSK_IDX 1 +#define CLB_MATCH_IDX 2 +static int +vhost_monitor_callback (const uint64_t value, +const uint64_t opaque[RTE_POWER_MONITOR_OPAQUE_SZ ]) +{ +const uint64_t m = opaque[CLB_MSK_IDX ]; +const uint64_t v = opaque[CLB_VAL_IDX ]; +const uint64_t c = opaque[CLB_MATCH_IDX ]; + +if (c) +return (value & m) == v ?-1 :0 ; +else +return (value & m) == v ?0 :-1 ; +} + +static int +vhost_get_monitor_addr (void *rx_queue,struct rte_power_monitor_cond *pmc) +{ +struct vhost_queue *vq = rx_queue; +struct rte_vhost_power_monitor_cond vhost_pmc; +int ret; +if (vq ==NULL ) +return -EINVAL ; + ret =rte_vhost_get_monitor_addr (vq->vid, vq->virtqueue_id, + &vhost_pmc); +if (ret <0 ) +return -EINVAL ; + pmc->addr = vhost_pmc.addr; + pmc->opaque[CLB_VAL_IDX ] = vhost_pmc.val; + pmc->opaque[CLB_MSK_IDX ] = vhost_pmc.mask; + pmc->opaque[CLB_MATCH_IDX ] = vhost_pmc.match; + pmc->size = vhost_pmc.size; + pmc->fn = vhost_monitor_callback; + +return 0 ; +} +static const struct eth_dev_ops ops = { .dev_start = eth_dev_start, .dev_stop = eth_dev_stop,
@@ -1399,6 +1438,7 @@ static const struct eth_dev_ops ops = { .xstats_get_names = vhost_dev_xstats_get_names, .rx_queue_intr_enable = eth_rxq_intr_enable, .rx_queue_intr_disable = eth_rxq_intr_disable, + .get_monitor_addr = vhost_get_monitor_addr, }; static int
Signature · 1 line
2.25.1
PATCH v8 4/5 power: modify return of queue_stopped
In reply to Miao LiSince some vdevs like virtio and vhost do not support rxq_info_get and queue state inquiry, the error return value -ENOTSUP need to be ignored when queue_stopped cannot get rx queue information and rx queue state. This patch changes the return value of queue_stopped when rte_eth_rx_queue_info_get return -ENOTSUP to support vdevs which cannot provide rx queue information and rx queue state enable power management.
--- lib/power/rte_power_pmd_mgmt.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
lib/power/rte_power_pmd_mgmt.c +7 -2
@@ -382,8 +382,13 @@ queue_stopped(const uint16_t port_id, const uint16_t queue_id) {struct rte_eth_rxq_info qinfo; -if (rte_eth_rx_queue_info_get (port_id, queue_id, &qinfo) <0 ) -return -1 ; +int ret =rte_eth_rx_queue_info_get (port_id, queue_id, &qinfo); +if (ret <0 ) { +if (ret == -ENOTSUP ) +return 1 ; +else +return -1 ; + }return qinfo.queue_state ==RTE_ETH_QUEUE_STATE_STOPPED ; }
Signature · 1 line
2.25.1
PATCH v8 5/5 examples/l3fwd-power: support virtio/vhost
In reply to Miao LiIn l3fwd-power, there is default port configuration which requires RSS and IPV4/UDP/TCP checksum. Once device does not support these, the l3fwd-power will exit and report an error.
This patch updates the port configuration based on device capabilities after getting the device information to support devices like virtio and vhost.
--- examples/l3fwd-power/main.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
examples/l3fwd-power/main.c +14 -1
@@ -505,7 +505,15 @@ is_valid_ipv4_pkt(struct rte_ipv4_hdr *pkt, uint32_t link_len)return -1 ;/* 2. The IP checksum must be correct. */ -/* this is checked in H/W */ +/* if this is not checked in H/W, check it. */ +if ((port_conf.rxmode.offloads &DEV_RX_OFFLOAD_IPV4_CKSUM ) ==0 ) { +uint16_t actual_cksum, expected_cksum; + actual_cksum = pkt->hdr_checksum; + pkt->hdr_checksum =0 ; + expected_cksum =rte_ipv4_cksum (pkt); +if (actual_cksum != expected_cksum) +return -2 ; + }/* * 3. The IP version number must be 4. If the version number is not 4
@@ -2652,6 +2660,11 @@ main(int argc, char **argv) local_port_conf.rx_adv_conf.rss_conf.rss_hf); } +if (local_port_conf.rx_adv_conf.rss_conf.rss_hf ==0 ) + local_port_conf.rxmode.mq_mode =ETH_MQ_RX_NONE ; + local_port_conf.rxmode.offloads &= dev_info.rx_offload_capa; + port_conf.rxmode.offloads = local_port_conf.rxmode.offloads; + ret =rte_eth_dev_configure (portid, nb_rx_queue, (uint16_t )n_tx_queue, &local_port_conf);if (ret <0 )
Signature · 1 line
2.25.1
Re: [dpdk-dev] [PATCH v8 5/5] examples/l3fwd-power: support virtio/vhost
examples/l3fwd-power/main.c is_valid_ipv4_pkt(struct rte_ipv4_hdr *pkt, uint32_t link_len) · line 509
Quoted 3 lines · Miao Li
examples/l3fwd-power/main.c +2
-1-/* this is checked in H/W */ +/* if this is not checked in H/W, check it. */ +if ((port_conf.rxmode.offloads &DEV_RX_OFFLOAD_IPV4_CKSUM ) ==0 ) {
s/DEV_RX_OFFLOAD_IPV4_CKSUM/RTE_ETH_RX_OFFLOAD_IPV4_CKSUM/
Quoted 11 lines
examples/l3fwd-power/main.c +7
-0+uint16_t actual_cksum, expected_cksum; + actual_cksum = pkt->hdr_checksum; + pkt->hdr_checksum =0 ; + expected_cksum =rte_ipv4_cksum (pkt); +if (actual_cksum != expected_cksum) +return -2 ; + }/* * 3. The IP version number must be 4. If the version number is not 4
examples/l3fwd-power/main.c main(int argc, char **argv) · line 2664
Quoted 5 lines
examples/l3fwd-power/main.c +2
-0@@ -2652,6 +2660,11 @@ main(int argc, char **argv) local_port_conf.rx_adv_conf.rss_conf.rss_hf); } +if (local_port_conf.rx_adv_conf.rss_conf.rss_hf ==0 ) + local_port_conf.rxmode.mq_mode =ETH_MQ_RX_NONE ;
s/ETH_MQ_RX_NONE/RTE_ETH_MQ_RX_NONE/
Both will be updated in next-net
Re: [dpdk-dev] [PATCH v8 0/5] Support power monitor in virtio/vhost PMD
In reply to Miao LiHi Ferruh,
Quoted 15 lines
-----Original Message-----
From: Li, Miao <[email protected]>
Sent: Monday, October 25, 2021 10:47 PM
To: [email protected]
Cc: Xia, Chenbo <[email protected]>; [email protected]; Li, Miao <[email protected]>
Subject: [PATCH v8 0/5] Support power monitor in virtio/vhost PMDThis patchset implements
rte_power_monitorAPI in virtio and vhost PMD to reduce power consumption when no packet come in. This API can be called and tested in l3fwd-power after adding vhost and virtio support in l3fwd-power and ignoring the rx queue information check inqueue_stopped().v8:
Review
Quoted 5 lines
(quoted diff) +0
-5-rebase on lastest repo -update the release note -modify some titles -update commit log -add the fixes and stable tags
The new version LGTM. Will you pick up directly to next-net if you also think it's good?
Thanks,
Chenbo
Quoted 2 lines
--
2.25.1
Re: [dpdk-dev] [PATCH v8 0/5] Support power monitor in virtio/vhost PMD
Hi Chenbo,
Quoted 16 lines · Chenbo
Hi Ferruh,
Quoted 14 lines
-----Original Message-----
From: Li, Miao <[email protected]>
Sent: Monday, October 25, 2021 10:47 PM
To: [email protected]
Cc: Xia, Chenbo <[email protected]>; [email protected]; Li, Miao <[email protected]>
Subject: [PATCH v8 0/5] Support power monitor in virtio/vhost PMDThis patchset implements
rte_power_monitorAPI in virtio and vhost PMD to reduce power consumption when no packet come in. This API can be called and tested in l3fwd-power after adding vhost and virtio support in l3fwd-power and ignoring the rx queue information check inqueue_stopped().
Quoted 9 lines
Review
Quoted 6 lines
v8:
(quoted diff) +0
-5-rebase on lastest repo -update the release note -modify some titles -update commit log -add the fixes and stable tagsThe new version LGTM. Will you pick up directly to next-net if you also think it's good?
I will pick it in my next pull request for -rc2.
Thanks,
Maxime
Quoted 6 lines
Thanks,
ChenboQuoted 2 lines
--
2.25.1
Maxime Coquelin
AppliedRe: [dpdk-dev] [PATCH v8 0/5] Support power monitor in virtio/vhost PMD
In reply to Miao LiQuoted 50 lines · Miao Li
This patchset implements
rte_power_monitorAPI in virtio and vhost PMD to reduce power consumption when no packet come in. This API can be called and tested in l3fwd-power after adding vhost and virtio support in l3fwd-power and ignoring the rx queue information check inqueue_stopped().v8:
(quoted diff) +0
-5-rebase on lastest repo -update the release note -modify some titles -update commit log -add the fixes and stable tagsv7:
(quoted diff) +0
-2-fix coding style issues -rebase on lastest repov6:
(quoted diff) +0
-3-modify comment -remove extra space -fix IPv4 CKSUM checkv5:
-rebase on lastest repov4:
(quoted diff) +0
-3-modify comment -update the release note -add IPv4 CKSUM checkv3:
(quoted diff) +0
-2-fix some code format issues -fix spelling mistakev2:
(quoted diff) +0
-5-remove flag and add match and size in rte_vhost_power_monitor_cond -modify power callback function -add dev and queue id check and remove unnecessary check -fix the assignment of pmc->size -update port configuration according to the device information andremove adding command line arguments
-modify some titlesMiao Li (5):
net/virtio: support power monitor
vhost: add power monitor support API
net/vhost: support power monitor
power: modify return ofqueue_stopped
examples/l3fwd-power: support virtio/vhost
Quoted 10 lines
doc/guides/rel_notes/release_21_11.rst | 12 ++++++ drivers/net/vhost/rte_eth_vhost.c | 40 ++++++++++++++++++ drivers/net/virtio/virtio_ethdev.c | 56 ++++++++++++++++++++++++++ examples/l3fwd-power/main.c | 15 ++++++- lib/power/rte_power_pmd_mgmt.c | 9 ++++- lib/vhost/rte_vhost.h | 42 +++++++++++++++++++ lib/vhost/version.map | 3 ++ lib/vhost/vhost.c | 38 +++++++++++++++++ 8 files changed, 212 insertions(+), 3 deletions(-)
Applied to dpdk-next-virtio/main.
Thanks,
Maxime