net/virtio: fix Rx stats with altivec vectorized functions

Message ID 20190930182754.20494-1-drc@linux.vnet.ibm.com (mailing list archive)
State Accepted, archived
Delegated to: Maxime Coquelin
Headers
Series net/virtio: fix Rx stats with altivec vectorized functions |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-dpdk_compile_ovs success Compile Testing PASS
ci/iol-dpdk_compile_spdk success Compile Testing PASS
ci/Intel-compilation success Compilation OK
ci/iol-mellanox-Performance success Performance Testing PASS

Commit Message

David Christensen Sept. 30, 2019, 6:27 p.m. UTC
  With vectorized functions, only the rx stats for number of packets is
incremented.
Update also the other statistics.
Performance impact is about 2%

Fixes: fc3d66212fed ("virtio: add vector Rx")
Cc: stable@dpdk.org
Cc: thibaut.collet@6wind.com
Cc: maxime.coquelin@redhat.com
Cc: tiwei.bie@intel.com
Cc: zhihong.wang@intel.com

Signed-off-by: David Christensen <drc@linux.vnet.ibm.com>
---
 drivers/net/virtio/virtio_rxtx_simple_altivec.c | 5 +++++
 1 file changed, 5 insertions(+)
  

Comments

Maxime Coquelin Oct. 1, 2019, 10 a.m. UTC | #1
Thanks David for the fix,

On 9/30/19 8:27 PM, David Christensen wrote:
> With vectorized functions, only the rx stats for number of packets is
> incremented.
> Update also the other statistics.
> Performance impact is about 2%
> 
> Fixes: fc3d66212fed ("virtio: add vector Rx")
> Cc: stable@dpdk.org
> Cc: thibaut.collet@6wind.com
> Cc: maxime.coquelin@redhat.com
> Cc: tiwei.bie@intel.com
> Cc: zhihong.wang@intel.com

The commit message seems like a copy-paste, so claim about performance
impact may be not true, same for the Fixes line, which points to a
commit when altivec was not here yet.


I'll fix that when appyling:

Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>

Thanks,
Maxime

> Signed-off-by: David Christensen <drc@linux.vnet.ibm.com>
> ---
>  drivers/net/virtio/virtio_rxtx_simple_altivec.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/net/virtio/virtio_rxtx_simple_altivec.c b/drivers/net/virtio/virtio_rxtx_simple_altivec.c
> index 1cd732dec..f856396ab 100644
> --- a/drivers/net/virtio/virtio_rxtx_simple_altivec.c
> +++ b/drivers/net/virtio/virtio_rxtx_simple_altivec.c
> @@ -49,6 +49,7 @@ virtio_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
>  	struct vring_used_elem *rused;
>  	struct rte_mbuf **sw_ring;
>  	struct rte_mbuf **sw_ring_end;
> +	struct rte_mbuf **ref_rx_pkts;
>  	uint16_t nb_pkts_received = 0;
>  	const vector unsigned char zero = {0};
>  
> @@ -108,6 +109,7 @@ virtio_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
>  			virtqueue_notify(vq);
>  	}
>  
> +	ref_rx_pkts = rx_pkts;
>  	for (nb_pkts_received = 0;
>  		nb_pkts_received < nb_used;) {
>  		vector unsigned char desc[RTE_VIRTIO_DESC_PER_LOOP / 2];
> @@ -199,5 +201,8 @@ virtio_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
>  	vq->vq_used_cons_idx += nb_pkts_received;
>  	vq->vq_free_cnt += nb_pkts_received;
>  	rxvq->stats.packets += nb_pkts_received;
> +	for (nb_used = 0; nb_used < nb_pkts_received; nb_used++)
> +		virtio_update_packet_stats(&rxvq->stats, ref_rx_pkts[nb_used]);
> +
>  	return nb_pkts_received;
>  }
>
  
Maxime Coquelin Oct. 16, 2019, 11:11 a.m. UTC | #2
On 9/30/19 8:27 PM, David Christensen wrote:
> With vectorized functions, only the rx stats for number of packets is
> incremented.
> Update also the other statistics.
> Performance impact is about 2%
> 
> Fixes: fc3d66212fed ("virtio: add vector Rx")
> Cc: stable@dpdk.org
> Cc: thibaut.collet@6wind.com
> Cc: maxime.coquelin@redhat.com
> Cc: tiwei.bie@intel.com
> Cc: zhihong.wang@intel.com
> 
> Signed-off-by: David Christensen <drc@linux.vnet.ibm.com>
> ---
>  drivers/net/virtio/virtio_rxtx_simple_altivec.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 

Applied to dpdk-next-virtio/master.

Thanks,
Maxime
  

Patch

diff --git a/drivers/net/virtio/virtio_rxtx_simple_altivec.c b/drivers/net/virtio/virtio_rxtx_simple_altivec.c
index 1cd732dec..f856396ab 100644
--- a/drivers/net/virtio/virtio_rxtx_simple_altivec.c
+++ b/drivers/net/virtio/virtio_rxtx_simple_altivec.c
@@ -49,6 +49,7 @@  virtio_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
 	struct vring_used_elem *rused;
 	struct rte_mbuf **sw_ring;
 	struct rte_mbuf **sw_ring_end;
+	struct rte_mbuf **ref_rx_pkts;
 	uint16_t nb_pkts_received = 0;
 	const vector unsigned char zero = {0};
 
@@ -108,6 +109,7 @@  virtio_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
 			virtqueue_notify(vq);
 	}
 
+	ref_rx_pkts = rx_pkts;
 	for (nb_pkts_received = 0;
 		nb_pkts_received < nb_used;) {
 		vector unsigned char desc[RTE_VIRTIO_DESC_PER_LOOP / 2];
@@ -199,5 +201,8 @@  virtio_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
 	vq->vq_used_cons_idx += nb_pkts_received;
 	vq->vq_free_cnt += nb_pkts_received;
 	rxvq->stats.packets += nb_pkts_received;
+	for (nb_used = 0; nb_used < nb_pkts_received; nb_used++)
+		virtio_update_packet_stats(&rxvq->stats, ref_rx_pkts[nb_used]);
+
 	return nb_pkts_received;
 }