From 4ad7a16a13d96b52f42e7c47706e0cbe6e64bf6a Mon Sep 17 00:00:00 2001 From: Maciej Gajdzica Date: Fri, 20 Feb 2015 16:12:39 +0000 Subject: [PATCH] virtio: fix type for queue id Changed vtpci_queue_idx type in function virtio_dev_queue_setup from uint8_t to uint16_t to prevent possible data loss. Also changed type of head variable in function virtio_send_command from uint32_t to uint16_t. Variable rcv_cnt declared in function virtio_recv_mergeable_pkts was of type uint32_t. It was used by virtqueue_dequeue_burst_rx function, which expects argument of type uint16_t. Changed rcv_cnt variable type to uint16_t to prevent possible data loss. Issues found with static code analysis tool. Signed-off-by: Maciej Gajdzica Acked-by: Changchun Ouyang --- lib/librte_pmd_virtio/virtio_ethdev.c | 4 ++-- lib/librte_pmd_virtio/virtio_ethdev.h | 2 +- lib/librte_pmd_virtio/virtio_rxtx.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/librte_pmd_virtio/virtio_ethdev.c b/lib/librte_pmd_virtio/virtio_ethdev.c index 603be2d7d3..346948f2b1 100644 --- a/lib/librte_pmd_virtio/virtio_ethdev.c +++ b/lib/librte_pmd_virtio/virtio_ethdev.c @@ -114,7 +114,7 @@ static int virtio_send_command(struct virtqueue *vq, struct virtio_pmd_ctrl *ctrl, int *dlen, int pkt_num) { - uint32_t head = vq->vq_desc_head_idx, i; + uint16_t head = vq->vq_desc_head_idx, i; int k, sum = 0; virtio_net_ctrl_ack status = ~0; struct virtio_pmd_ctrl result; @@ -241,7 +241,7 @@ virtio_set_multiple_queues(struct rte_eth_dev *dev, uint16_t nb_queues) int virtio_dev_queue_setup(struct rte_eth_dev *dev, int queue_type, uint16_t queue_idx, - uint8_t vtpci_queue_idx, + uint16_t vtpci_queue_idx, uint16_t nb_desc, unsigned int socket_id, struct virtqueue **pvq) diff --git a/lib/librte_pmd_virtio/virtio_ethdev.h b/lib/librte_pmd_virtio/virtio_ethdev.h index 74ac7e08ab..e6d4533480 100644 --- a/lib/librte_pmd_virtio/virtio_ethdev.h +++ b/lib/librte_pmd_virtio/virtio_ethdev.h @@ -88,7 +88,7 @@ void virtio_dev_rxtx_start(struct rte_eth_dev *dev); int virtio_dev_queue_setup(struct rte_eth_dev *dev, int queue_type, uint16_t queue_idx, - uint8_t vtpci_queue_idx, + uint16_t vtpci_queue_idx, uint16_t nb_desc, unsigned int socket_id, struct virtqueue **pvq); diff --git a/lib/librte_pmd_virtio/virtio_rxtx.c b/lib/librte_pmd_virtio/virtio_rxtx.c index 1d74b34e24..3ff275cba7 100644 --- a/lib/librte_pmd_virtio/virtio_rxtx.c +++ b/lib/librte_pmd_virtio/virtio_rxtx.c @@ -382,7 +382,7 @@ virtio_dev_rx_queue_setup(struct rte_eth_dev *dev, __rte_unused const struct rte_eth_rxconf *rx_conf, struct rte_mempool *mp) { - uint8_t vtpci_queue_idx = 2 * queue_idx + VTNET_SQ_RQ_QUEUE_IDX; + uint16_t vtpci_queue_idx = 2 * queue_idx + VTNET_SQ_RQ_QUEUE_IDX; struct virtqueue *vq; int ret; @@ -650,7 +650,7 @@ virtio_recv_mergeable_pkts(void *rx_queue, /* * Get extra segments for current uncompleted packet. */ - uint32_t rcv_cnt = + uint16_t rcv_cnt = RTE_MIN(seg_res, RTE_DIM(rcv_pkts)); if (likely(VIRTQUEUE_NUSED(rxvq) >= rcv_cnt)) { uint32_t rx_num = -- 2.20.1