virtio: fix type for queue id
authorMaciej Gajdzica <maciejx.t.gajdzica@intel.com>
Fri, 20 Feb 2015 16:12:39 +0000 (16:12 +0000)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Mon, 30 Mar 2015 17:10:15 +0000 (19:10 +0200)
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 <maciejx.t.gajdzica@intel.com>
Acked-by: Changchun Ouyang <changchun.ouyang@intel.com>
lib/librte_pmd_virtio/virtio_ethdev.c
lib/librte_pmd_virtio/virtio_ethdev.h
lib/librte_pmd_virtio/virtio_rxtx.c

index 603be2d..346948f 100644 (file)
@@ -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)
index 74ac7e0..e6d4533 100644 (file)
@@ -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);
index 1d74b34..3ff275c 100644 (file)
@@ -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 =