From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 6EB70AE99 for ; Fri, 13 Jun 2014 03:59:52 +0200 (CEST) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga103.fm.intel.com with ESMTP; 12 Jun 2014 18:55:09 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.97,862,1389772800"; d="scan'208";a="354446204" Received: from fmsmsx104.amr.corp.intel.com ([10.19.9.35]) by FMSMGA003.fm.intel.com with ESMTP; 12 Jun 2014 18:56:00 -0700 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by FMSMSX104.amr.corp.intel.com (10.19.9.35) with Microsoft SMTP Server (TLS) id 14.3.123.3; Thu, 12 Jun 2014 18:59:57 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.21]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.36]) with mapi id 14.03.0123.003; Fri, 13 Jun 2014 09:59:55 +0800 From: "Ouyang, Changchun" To: Stephen Hemminger , "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH 1/2] virtio: checkpatch cleanups Thread-Index: AQHPhqeH8vgmzwLgb0aZQxIIyz7MEJtuSOsw Date: Fri, 13 Jun 2014 01:59:54 +0000 Message-ID: References: <20140612183240.1067d5be@nehalam.linuxnetplumber.net> In-Reply-To: <20140612183240.1067d5be@nehalam.linuxnetplumber.net> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH 1/2] virtio: checkpatch cleanups X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Jun 2014 01:59:53 -0000 Acked by Changchun, Ouyang -----Original Message----- From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Stephen Hemminger Sent: Friday, June 13, 2014 9:33 AM To: dev@dpdk.org Subject: [dpdk-dev] [PATCH 1/2] virtio: checkpatch cleanups This fixes style problems reported by checkpatch including: * extra whitespace * spaces before tabs * strings broken across lines * excessively long lines * missing spaces after keywords * unnecessary paren's in return statements Signed-off-by: Stephen Hemminger --- lib/librte_pmd_virtio/virtio_ethdev.c | 127 ++++++++++++++++++-----------= ----- lib/librte_pmd_virtio/virtio_ethdev.h | 2=20 lib/librte_pmd_virtio/virtio_pci.c | 4 - lib/librte_pmd_virtio/virtio_pci.h | 10 +- lib/librte_pmd_virtio/virtio_ring.h | 4 - lib/librte_pmd_virtio/virtio_rxtx.c | 32 ++++---- lib/librte_pmd_virtio/virtqueue.c | 4 - lib/librte_pmd_virtio/virtqueue.h | 35 ++++----- 8 files changed, 115 insertions(+), 103 deletions(-) --- a/lib/librte_pmd_virtio/virtio_ethdev.c 2014-06-12 17:41:20.305298960 -= 0700 +++ b/lib/librte_pmd_virtio/virtio_ethdev.c 2014-06-12 17:51:34.000000000 -= 0700 @@ -110,8 +110,9 @@ virtio_send_command(struct virtqueue *vq ctrl->status =3D status; =20 if (!vq->hw->cvq) { - PMD_INIT_LOG(ERR, "%s(): Control queue is " - "not supported by this device.\n", __func__); + PMD_INIT_LOG(ERR, + "%s(): Control queue is not supported.\n", + __func__); return -1; } =20 @@ -257,10 +258,10 @@ int virtio_dev_queue_setup(struct rte_et nb_desc =3D vq_size; if (vq_size =3D=3D 0) { PMD_INIT_LOG(ERR, "%s: virtqueue does not exist\n", __func__); - return (-EINVAL); + return -EINVAL; } else if (!rte_is_power_of_2(vq_size)) { PMD_INIT_LOG(ERR, "%s: virtqueue size is not powerof 2\n", __func__); - return (-EINVAL); + return -EINVAL; } else if (nb_desc !=3D vq_size) { PMD_INIT_LOG(ERR, "Warning: nb_desc(%d) is not equal to vq size (%d), fa= ll to vq size\n", nb_desc, vq_size); @@ -273,13 +274,13 @@ int virtio_dev_queue_setup(struct rte_et vq =3D rte_zmalloc(vq_name, sizeof(struct virtqueue) + vq_size * sizeof(struct vq_desc_extra), CACHE_LINE_SIZE); memcpy(vq->vq_name, vq_name, sizeof(vq->vq_name)); - } else if(queue_type =3D=3D VTNET_TQ) { + } else if (queue_type =3D=3D VTNET_TQ) { rte_snprintf(vq_name, sizeof(vq_name), "port%d_tvq%d", dev->data->port_id, queue_idx); vq =3D rte_zmalloc(vq_name, sizeof(struct virtqueue) + vq_size * sizeof(struct vq_desc_extra), CACHE_LINE_SIZE); memcpy(vq->vq_name, vq_name, sizeof(vq->vq_name)); - } else if(queue_type =3D=3D VTNET_CQ) { + } else if (queue_type =3D=3D VTNET_CQ) { rte_snprintf(vq_name, sizeof(vq_name), "port%d_cvq", dev->data->port_id); vq =3D rte_zmalloc(vq_name, sizeof(struct virtqueue) + @@ -311,7 +312,7 = @@ int virtio_dev_queue_setup(struct rte_et socket_id, 0, VIRTIO_PCI_VRING_ALIGN); if (mz =3D=3D NULL) { rte_free(vq); - return (-ENOMEM); + return -ENOMEM; } =20 /* @@ -319,10 +320,10 @@ int virtio_dev_queue_setup(struct rte_et * and only accepts 32 bit page frame number. * Check if the allocated physical memory exceeds 16TB. */ - if ( (mz->phys_addr + vq->vq_ring_size - 1) >> (VIRTIO_PCI_QUEUE_ADDR_SHI= FT + 32) ) { + if ((mz->phys_addr + vq->vq_ring_size - 1) >>=20 +(VIRTIO_PCI_QUEUE_ADDR_SHIFT + 32)) { PMD_INIT_LOG(ERR, "vring address shouldn't be above 16TB!\n"); rte_free(vq); - return (-ENOMEM); + return -ENOMEM; } =20 memset(mz->addr, 0, sizeof(mz->len)); @@ -429,7 +430,7 @@ static struct eth_dev_ops virtio_eth_dev /* meaningfull only to multiple queue */ .tx_queue_release =3D virtio_dev_tx_queue_release, /* collect stats per queue */ - .queue_stats_mapping_set =3D virtio_dev_queue_stats_mapping_set + .queue_stats_mapping_set =3D virtio_dev_queue_stats_mapping_set, }; =20 static inline int @@ -441,9 +442,9 @@ virtio_dev_atomic_read_link_status(struc =20 if (rte_atomic64_cmpset((uint64_t *)dst, *(uint64_t *)dst, *(uint64_t *)src) =3D=3D 0) - return (-1); + return -1; =20 - return (0); + return 0; } =20 /** @@ -467,9 +468,9 @@ virtio_dev_atomic_write_link_status(stru =20 if (rte_atomic64_cmpset((uint64_t *)dst, *(uint64_t *)dst, *(uint64_t *)src) =3D=3D 0) - return (-1); + return -1; =20 - return (0); + return 0; } =20 static void @@ -477,7 +478,7 @@ virtio_dev_stats_get(struct rte_eth_dev { struct virtio_hw *hw =3D VIRTIO_DEV_PRIVATE_TO_HW(dev->data->dev_private); - if(stats) + if (stats) memcpy(stats, &hw->eth_stats, sizeof(*stats)); } =20 @@ -516,8 +517,9 @@ static void virtio_negotiate_features(struct virtio_hw *hw) { uint32_t guest_features, mask; + mask =3D VIRTIO_NET_F_CTRL_RX | VIRTIO_NET_F_CTRL_VLAN; - mask |=3D VIRTIO_NET_F_CSUM | VIRTIO_NET_F_GUEST_CSUM ; + mask |=3D VIRTIO_NET_F_CSUM | VIRTIO_NET_F_GUEST_CSUM; =20 /* TSO and LRO are only available when their corresponding * checksum offload feature is also negotiated. @@ -559,7 +561,8 @@ parse_sysfs_value(const char *filename, char buf[BUFSIZ]; char *end =3D NULL; =20 - if ((f =3D fopen(filename, "r")) =3D=3D NULL) { + f =3D fopen(filename, "r"); + if (f =3D=3D NULL) { PMD_INIT_LOG(ERR, "%s(): cannot open sysfs value %s\n", __func__, filename); return -1; @@ -592,14 +595,14 @@ static int get_uio_dev(struct rte_pci_ad /* depending on kernel version, uio can be located in uio/uioX * or uio:uioX */ rte_snprintf(dirname, sizeof(dirname), - SYSFS_PCI_DEVICES "/" PCI_PRI_FMT "/uio", - loc->domain, loc->bus, loc->devid, loc->function); + SYSFS_PCI_DEVICES "/" PCI_PRI_FMT "/uio", + loc->domain, loc->bus, loc->devid, loc->function); dir =3D opendir(dirname); if (dir =3D=3D NULL) { /* retry with the parent directory */ rte_snprintf(dirname, sizeof(dirname), - SYSFS_PCI_DEVICES "/" PCI_PRI_FMT, - loc->domain, loc->bus, loc->devid, loc->function); + SYSFS_PCI_DEVICES "/" PCI_PRI_FMT, + loc->domain, loc->bus, loc->devid, loc->function); dir =3D opendir(dirname); =20 if (dir =3D=3D NULL) { @@ -663,23 +666,23 @@ eth_virtio_dev_init(__rte_unused struct struct virtio_hw *hw =3D VIRTIO_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private); =20 - if (RTE_PKTMBUF_HEADROOM < sizeof(struct virtio_net_hdr) ) { + if (RTE_PKTMBUF_HEADROOM < sizeof(struct virtio_net_hdr)) { PMD_INIT_LOG(ERR, "MBUF HEADROOM should be enough to hold virtio net hdr\n"); - return (-1); + return -1; } =20 - if (! (rte_eal_get_configuration()->flags & EAL_FLG_HIGH_IOPL)) { + if (!(rte_eal_get_configuration()->flags & EAL_FLG_HIGH_IOPL)) { PMD_INIT_LOG(ERR, "IOPL call failed in EAL init - cannot use virtio PMD driver\n"); - return (-1); + return -1; } =20 eth_dev->dev_ops =3D &virtio_eth_dev_ops; eth_dev->rx_pkt_burst =3D &virtio_recv_pkts; eth_dev->tx_pkt_burst =3D &virtio_xmit_pkts; =20 - if(rte_eal_process_type() =3D=3D RTE_PROC_SECONDARY) + if (rte_eal_process_type() =3D=3D RTE_PROC_SECONDARY) return 0; =20 pci_dev =3D eth_dev->pci_dev; @@ -690,7 +693,7 @@ eth_virtio_dev_init(__rte_unused struct { char dirname[PATH_MAX]; char filename[PATH_MAX]; - unsigned long start,size; + unsigned long start, size; =20 if (get_uio_dev(&pci_dev->addr, dirname, sizeof(dirname)) < 0) return -1; @@ -714,8 +717,9 @@ eth_virtio_dev_init(__rte_unused struct } pci_dev->mem_resource[0].addr =3D (void *)(uintptr_t)start; pci_dev->mem_resource[0].len =3D (uint64_t)size; - PMD_INIT_LOG(DEBUG, "PCI Port IO found start=3D0x%lx with " - "size=3D0x%lx\n", start, size); + PMD_INIT_LOG(DEBUG, + "PCI Port IO found start=3D0x%lx with size=3D0x%lx\n", + start, size); } #endif hw->io_base =3D (uint32_t)(uintptr_t)pci_dev->mem_resource[0].addr; @@ -731,7 +735,7 @@ eth_virtio_dev_init(__rte_unused struct virtio_negotiate_features(hw); =20 /* Setting up rx_header size for the device */ - if(vtpci_with_feature(hw, VIRTIO_NET_F_MRG_RXBUF)) + if (vtpci_with_feature(hw, VIRTIO_NET_F_MRG_RXBUF)) hw->vtnet_hdr_size =3D sizeof(struct virtio_net_hdr_mrg_rxbuf); else hw->vtnet_hdr_size =3D sizeof(struct virtio_net_hdr); @@ -742,15 +746,17= @@ eth_virtio_dev_init(__rte_unused struct PMD_INIT_LOG(ERR, "Failed to allocate %d bytes needed to store MAC addresses", ETHER_ADDR_LEN); - return (-ENOMEM); + return -ENOMEM; } =20 /* Copy the permanent MAC address to: virtio_hw */ virtio_get_hwaddr(hw); ether_addr_copy((struct ether_addr *) hw->mac_addr, ð_dev->data->mac_addrs[0]); - PMD_INIT_LOG(DEBUG, "PORT MAC: %02X:%02X:%02X:%02X:%02X:%02X\n", hw->mac_= addr[0], - hw->mac_addr[1],hw->mac_addr[2], hw->mac_addr[3], hw->mac_addr[4], hw->= mac_addr[5]); + PMD_INIT_LOG(DEBUG, + "PORT MAC: %02X:%02X:%02X:%02X:%02X:%02X\n", + hw->mac_addr[0], hw->mac_addr[1], hw->mac_addr[2], + hw->mac_addr[3], hw->mac_addr[4], hw->mac_addr[5]); =20 if (vtpci_with_feature(hw, VIRTIO_NET_F_CTRL_VQ)) { config =3D &local_config; @@ -758,16 +764,16 @@ eth_virtio_dev_init(__rte_unused struct if (vtpci_with_feature(hw, VIRTIO_NET_F_STATUS)) { offset_conf +=3D sizeof(config->status); } else { - PMD_INIT_LOG(DEBUG, "VIRTIO_NET_F_STATUS is " - "not supported\n"); + PMD_INIT_LOG(DEBUG, + "VIRTIO_NET_F_STATUS is not supported\n"); config->status =3D 0; } =20 if (vtpci_with_feature(hw, VIRTIO_NET_F_MQ)) { offset_conf +=3D sizeof(config->max_virtqueue_pairs); } else { - PMD_INIT_LOG(DEBUG, "VIRTIO_NET_F_MQ is " - "not supported\n"); + PMD_INIT_LOG(DEBUG, + "VIRTIO_NET_F_MQ is not supported\n"); config->max_virtqueue_pairs =3D 1; } =20 @@ -828,7 +834,7 @@ static int rte_virtio_pmd_init(const char *name __rte_unused, const char *param __rte= _unused) { rte_eth_driver_register(&rte_virtio_pmd); - return (0); + return 0; } =20 /* @@ -851,7 +857,7 @@ virtio_dev_tx_queue_release(__rte_unused static int virtio_dev_configure(__rte_unused struct rte_eth_dev *dev) { - return (0); + return 0; } =20 =20 @@ -877,13 +883,13 @@ virtio_dev_start(struct rte_eth_dev *dev virtio_dev_rxtx_start(dev); =20 /* Check VIRTIO_NET_F_STATUS for link status*/ - if(vtpci_with_feature(hw, VIRTIO_NET_F_STATUS)) { + if (vtpci_with_feature(hw, VIRTIO_NET_F_STATUS)) { vtpci_read_dev_config(hw, offsetof(struct virtio_net_config, status), &status, sizeof(status)); - if((status & VIRTIO_NET_S_LINK_UP) =3D=3D 0) { + if ((status & VIRTIO_NET_S_LINK_UP) =3D=3D 0) { PMD_INIT_LOG(ERR, "Port: %d Link is DOWN\n", dev->data->port_id); - return (-EIO); + return -EIO; } else { PMD_INIT_LOG(DEBUG, "Port: %d Link is UP\n", dev->data->port_id); } @@ -920,9 +926,10 @@ static void virtio_dev_free_mbufs(struct { struct rte_mbuf *buf; int i, mbuf_num =3D 0; + for (i =3D 0; i < dev->data->nb_rx_queues; i++) { - PMD_INIT_LOG(DEBUG, "Before freeing rxq[%d] used and " - "unused buf\n", i); + PMD_INIT_LOG(DEBUG, + "Before freeing rxq[%d] used and unused buf\n", i); VIRTQUEUE_DUMP((struct virtqueue *)dev->data->rx_queues[i]); =20 while ((buf =3D (struct rte_mbuf *)virtqueue_detatch_unused( @@ -932,14 = +939,15 @@ static void virtio_dev_free_mbufs(struct } =20 PMD_INIT_LOG(DEBUG, "free %d mbufs\n", mbuf_num); - PMD_INIT_LOG(DEBUG, "After freeing rxq[%d] used and " - "unused buf\n", i); + PMD_INIT_LOG(DEBUG, + "After freeing rxq[%d] used and unused buf\n", i); VIRTQUEUE_DUMP((struct virtqueue *)dev->data->rx_queues[i]); } =20 for (i =3D 0; i < dev->data->nb_tx_queues; i++) { - PMD_INIT_LOG(DEBUG, "Before freeing txq[%d] used and " - "unused bufs\n", i); + PMD_INIT_LOG(DEBUG, + "Before freeing txq[%d] used and unused bufs\n", + i); VIRTQUEUE_DUMP((struct virtqueue *)dev->data->tx_queues[i]); =20 mbuf_num =3D 0; @@ -980,34 +988,37 @@ virtio_dev_link_update(struct rte_eth_de memset(&link, 0, sizeof(link)); virtio_dev_atomic_read_link_status(dev, &link); old =3D link; - link.link_duplex =3D FULL_DUPLEX ; - link.link_speed =3D SPEED_10G ; - if(vtpci_with_feature(hw, VIRTIO_NET_F_STATUS)) { + link.link_duplex =3D FULL_DUPLEX; + link.link_speed =3D SPEED_10G; + if (vtpci_with_feature(hw, VIRTIO_NET_F_STATUS)) { PMD_INIT_LOG(DEBUG, "Get link status from hw\n"); vtpci_read_dev_config(hw, offsetof(struct virtio_net_config, status), &status, sizeof(status)); - if((status & VIRTIO_NET_S_LINK_UP) =3D=3D 0) { + if ((status & VIRTIO_NET_S_LINK_UP) =3D=3D 0) { link.link_status =3D 0; - PMD_INIT_LOG(DEBUG, "Port %d is down\n",dev->data->port_id); + PMD_INIT_LOG(DEBUG, "Port %d is down\n", + dev->data->port_id); } else { link.link_status =3D 1; - PMD_INIT_LOG(DEBUG, "Port %d is up\n",dev->data->port_id); + PMD_INIT_LOG(DEBUG, "Port %d is up\n", + dev->data->port_id); } } else { - link.link_status =3D 1; //Link up + link.link_status =3D 1; /* Link up */ } virtio_dev_atomic_write_link_status(dev, &link); - if(old.link_status =3D=3D link.link_status) - return (-1); + if (old.link_status =3D=3D link.link_status) + return -1; /*changed*/ - return (0); + return 0; } =20 static void virtio_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_= info) { struct virtio_hw *hw =3D VIRTIO_DEV_PRIVATE_TO_HW(dev->data->dev_private)= ; + dev_info->driver_name =3D dev->driver->pci_drv.name; dev_info->max_rx_queues =3D (uint16_t)hw->max_rx_queues; dev_info->max_tx_queues =3D (uint16_t)hw->max_tx_queues; --- a/lib/librte_pmd_virtio/virtio_ethdev.h 2014-06-12 17:41:20.305298960 -= 0700 +++ b/lib/librte_pmd_virtio/virtio_ethdev.h 2014-06-12 17:41:20.297298905 -= 0700 @@ -123,7 +123,7 @@ struct virtio_adapter { * via tcp_lro_rx(). */ #define VTNET_LRO_FEATURES (VIRTIO_NET_F_GUEST_TSO4 | \ - VIRTIO_NET_F_GUEST_TSO6 | VIRTIO_NET_F_GUEST_ECN) + VIRTIO_NET_F_GUEST_TSO6 | VIRTIO_NET_F_GUEST_ECN) =20 =20 #endif /* _VIRTIO_ETHDEV_H_ */ --- a/lib/librte_pmd_virtio/virtio_pci.c 2014-06-12 17:41:20.305298960 -070= 0 +++ b/lib/librte_pmd_virtio/virtio_pci.c 2014-06-12 17:41:20.297298905 -070= 0 @@ -92,7 +92,7 @@ vtpci_negotiate_features(struct virtio_h features =3D (hw->host_features) & guest_features; =20 VIRTIO_WRITE_REG_4(hw, VIRTIO_PCI_GUEST_FEATURES, features); - return (features); + return features; } =20 =20 @@ -116,7 +116,7 @@ vtpci_reinit_complete(struct virtio_hw * uint8_t vtpc= i_get_status(struct virtio_hw *hw) { - return (VIRTIO_READ_REG_1(hw, VIRTIO_PCI_STATUS)); + return VIRTIO_READ_REG_1(hw, VIRTIO_PCI_STATUS); } =20 void --- a/lib/librte_pmd_virtio/virtio_ring.h 2014-06-12 17:41:20.305298960 -07= 00 +++ b/lib/librte_pmd_virtio/virtio_ring.h 2014-06-12 17:47:23.323539780 -07= 00 @@ -133,7 +133,7 @@ vring_size(unsigned int num, unsigned lo size =3D RTE_ALIGN_CEIL(size, align); size +=3D sizeof(struct vring_used) + (num * sizeof(struct vring_used_elem)); - return (size); + return size; } =20 static inline void @@ -145,7 +145,7 @@ vring_init(struct vring *vr, unsigned in vr->avail =3D (struct vring_avail *) (p + num * sizeof(struct vring_desc)); vr->used =3D (void *) - RTE_ALIGN_CEIL( (uintptr_t)(&vr->avail->ring[num]), align); + RTE_ALIGN_CEIL((uintptr_t)(&vr->avail->ring[num]), align); } =20 /* --- a/lib/librte_pmd_virtio/virtio_rxtx.c 2014-06-12 17:41:20.305298960 -07= 00 +++ b/lib/librte_pmd_virtio/virtio_rxtx.c 2014-06-12 17:49:48.428390399 -07= 00 @@ -54,7 +54,7 @@ #include "virtio_ethdev.h" #include "virtqueue.h" =20 -#ifdef RTE_LIBRTE_VIRTIO_DEBUG_DUMP +#ifdef RTE_LIBRTE_VIRTIO_DEBUG_DUMP #define VIRTIO_DUMP_PACKET(m, len) rte_pktmbuf_dump(m, len) #else #defin= e VIRTIO_DUMP_PACKET(m, len) do { } while (0) @@ -68,7 +68,7 @@ rte_rxmbuf= _alloc(struct rte_mempool *mp) m =3D __rte_mbuf_raw_alloc(mp); __rte_mbuf_sanity_check_raw(m, RTE_MBUF_PKT, 0); =20 - return (m); + return m; } =20 static void @@ -175,6 +175,7 @@ virtio_dev_rxtx_start(struct rte_eth_dev * */ int i; + PMD_INIT_FUNC_TRACE(); =20 /* Start rx vring. */ @@ -214,7 +215,7 @@ virtio_dev_rx_queue_setup(struct rte_eth vq->mpool =3D mp; =20 dev->data->rx_queues[queue_idx] =3D vq; - return (0); + return 0; } =20 /* @@ -244,7 +245,7 @@ virtio_dev_tx_queue_setup(struct rte_eth } =20 dev->data->tx_queues[queue_idx] =3D vq; - return (0); + return 0; } =20 static void @@ -285,17 +286,18 @@ virtio_recv_pkts(void *rx_queue, struct if (likely(num > DESC_PER_CACHELINE)) num =3D num - ((rxvq->vq_used_cons_idx + num) % DESC_PER_CACHELINE); =20 - if(num =3D=3D 0) return 0; + if (num =3D=3D 0) + return 0; =20 num =3D virtqueue_dequeue_burst_rx(rxvq, rcv_pkts, len, num); PMD_RX_LOG(DEBUG, "used:%d dequeue:%d\n", nb_used, num); - for (i =3D 0; i < num ; i ++) { + for (i =3D 0; i < num ; i++) { rxm =3D rcv_pkts[i]; =20 PMD_RX_LOG(DEBUG, "packet len:%d\n", len[i]); =20 if (unlikely(len[i] - < (uint32_t)hw->vtnet_hdr_size + ETHER_HDR_LEN)) { + < (uint32_t)hw->vtnet_hdr_size + ETHER_HDR_LEN)) { PMD_RX_LOG(ERR, "Packet drop\n"); nb_enqueued++; virtio_discard_rxbuf(rxvq, rxm); @@ -308,9 +310,9 @@ virtio_recv_pkts(void *rx_queue, struct rxm->pkt.nb_segs =3D 1; rxm->pkt.next =3D NULL; rxm->pkt.pkt_len =3D (uint32_t)(len[i] - - sizeof(struct virtio_net_hdr)); + - sizeof(struct virtio_net_hdr)); rxm->pkt.data_len =3D (uint16_t)(len[i] - - sizeof(struct virtio_net_hdr)); + - sizeof(struct virtio_net_hdr)); =20 VIRTIO_DUMP_PACKET(rxm, rxm->pkt.data_len); =20 @@ -336,7 +338,7 @@ virtio_recv_pkts(void *rx_queue, struct rte_pktmbuf_free_seg(new_mbuf); break; } - nb_enqueued ++; + nb_enqueued++; } if (likely(nb_enqueued)) { if (unlikely(virtqueue_kick_prepare(rxvq))) { @@ -347,7 +349,7 @@ virtio= _recv_pkts(void *rx_queue, struct =20 vq_update_avail_idx(rxvq); =20 - return (nb_rx); + return nb_rx; } =20 uint16_t @@ -362,7 +364,7 @@ virtio_xmit_pkts(void *tx_queue, struct nb_tx =3D 0; =20 if (unlikely(nb_pkts < 1)) - return (nb_pkts); + return nb_pkts; =20 PMD_TX_LOG(DEBUG, "%d packets to xmit", nb_pkts); nb_used =3D VIRTQUEUE_NUSED(txvq); @@ -378,7 +380,7 @@ virtio_xmit_pkts(void *tx_queue, struct num--; } =20 - if(!virtqueue_full(txvq)) { + if (!virtqueue_full(txvq)) { txm =3D tx_pkts[nb_tx]; /* Enqueue Packet buffers */ error =3D virtqueue_enqueue_xmit(txvq, txm); @@ -405,10 +407,10 @@ virt= io_xmit_pkts(void *tx_queue, struct hw->eth_stats.opackets +=3D nb_tx; hw->eth_stats.q_opackets[txvq->queue_id] +=3D nb_tx; =20 - if(unlikely(virtqueue_kick_prepare(txvq))) { + if (unlikely(virtqueue_kick_prepare(txvq))) { virtqueue_notify(txvq); PMD_TX_LOG(DEBUG, "Notified backend after xmit\n"); } =20 - return (nb_tx); + return nb_tx; } --- a/lib/librte_pmd_virtio/virtqueue.c 2014-06-12 17:41:20.305298960 -0700 +++ b/lib/librte_pmd_virtio/virtqueue.c 2014-06-12 17:41:20.297298905 -0700 @@ -60,11 +60,11 @@ virtqueue_detatch_unused(struct virtqueu struct rte_mbuf *cookie; int idx; =20 - for(idx =3D 0; idx < vq->vq_nentries; idx++) { + for (idx =3D 0; idx < vq->vq_nentries; idx++) { if ((cookie =3D vq->vq_descx[idx].cookie) !=3D NULL) { vq->vq_descx[idx].cookie =3D NULL; return cookie; } } - return (NULL); + return NULL; } --- a/lib/librte_pmd_virtio/virtio_pci.h 2014-06-12 17:38:02.843929358 -070= 0 +++ b/lib/librte_pmd_virtio/virtio_pci.h 2014-06-12 17:46:57.739390234 -070= 0 @@ -65,12 +65,12 @@ struct virtqueue; #define VIRTIO_PCI_QUEUE_SEL 14 /* current VQ selection (16, RW) */ #define VIRTIO_PCI_QUEUE_NOTIFY 16 /* notify host regarding VQ (16, RW) = */ #define VIRTIO_PCI_STATUS 18 /* device status register (8, RW) */ -#define VIRTIO_PCI_ISR 19 /* interrupt status register, reading - * also clears the register (8, RO) *= / +#define VIRTIO_PCI_ISR 19 /* interrupt status register, reading + * also clears the register (8, RO) */ /* Only if MSIX is enabled: */ #define VIRTIO_MSI_CONFIG_VECTOR 20 /* configuration change vector (16, R= W) */ -#define VIRTIO_MSI_QUEUE_VECTOR 22 /* vector for selected VQ notificatio= ns - (16, RW) */ +#define VIRTIO_MSI_QUEUE_VECTOR 22 /* vector for selected VQ notificatio= ns + (16, RW) */ =20 /* The bit of the ISR which indicates a device has an interrupt. */ #define VIRTIO_PCI_ISR_INTR 0x1 @@ -255,7 +255,7 @@ outl_p(unsigned int data, unsigned int p static inline= int vtpci_with_feature(struct virtio_hw *hw, uint32_t feature) { - return ((hw->guest_features & feature) !=3D 0); + return (hw->guest_features & feature) !=3D 0; } =20 /* --- a/lib/librte_pmd_virtio/virtqueue.h 2014-06-12 17:38:02.843929358 -0700 +++ b/lib/librte_pmd_virtio/virtqueue.h 2014-06-12 17:51:39.225042642 -0700 @@ -209,12 +209,12 @@ void virtqueue_dump(struct virtqueue *vq /** * Get all mbufs to be freed. */ -struct rte_mbuf * virtqueue_detatch_unused(struct virtqueue *vq); +struct rte_mbuf *virtqueue_detatch_unused(struct virtqueue *vq); =20 static inline int virtqueue_full(const struct virtqueue *vq) { - return (vq->vq_free_cnt =3D=3D 0); + return vq->vq_free_cnt =3D=3D 0; } =20 #define VIRTQUEUE_NUSED(vq) ((uint16_t)((vq)->vq_ring.used->idx - (vq)->vq= _used_cons_idx)) @@ -243,7 +243,7 @@ vq_update_avail_ring(struct virtqueue = *v } =20 static inline int __attribute__((always_inline)) -virtqueue_kick_prepare(s= truct virtqueue * vq) +virtqueue_kick_prepare(struct virtqueue *vq) { return !(vq->vq_ring.used->flags & VRING_USED_F_NO_NOTIFY); } @@ -298,18= +298,17 @@ virtqueue_enqueue_recv_refill(struct vir { struct vq_desc_extra *dxp; struct vring_desc *start_dp; - uint16_t needed; + uint16_t needed =3D 1; uint16_t head_idx, idx; - needed =3D 1; =20 if (unlikely(vq->vq_free_cnt =3D=3D 0)) - return (-ENOSPC); + return -ENOSPC; if (unlikely(vq->vq_free_cnt < needed)) - return (-EMSGSIZE); + return -EMSGSIZE; =20 head_idx =3D vq->vq_desc_head_idx; if (unlikely(head_idx >=3D vq->vq_nentries)) - return (-EFAULT); + return -EFAULT; =20 idx =3D head_idx; dxp =3D &vq->vq_descx[idx]; @@ -328,7 +327,7 @@ virtqueue_enqueue_recv_refill(struct vir vq->vq_free_cnt =3D (uint16_t)(vq->vq_free_cnt - needed); vq_update_avail_ring(vq, head_idx); =20 - return (0); + return 0; } =20 static inline int __attribute__((always_inline)) @@ -336,16 +335,16 @@ vir= tqueue_enqueue_xmit(struct virtqueue { struct vq_desc_extra *dxp; struct vring_desc *start_dp; - uint16_t needed; + uint16_t needed =3D 2; uint16_t head_idx, idx; - needed =3D 2; + if (unlikely(txvq->vq_free_cnt =3D=3D 0)) - return (-ENOSPC); + return -ENOSPC; if (unlikely(txvq->vq_free_cnt < needed)) - return (-EMSGSIZE); + return -EMSGSIZE; head_idx =3D txvq->vq_desc_head_idx; if (unlikely(head_idx >=3D txvq->vq_nentries)) - return (-EFAULT); + return -EFAULT; =20 idx =3D head_idx; dxp =3D &txvq->vq_descx[idx]; @@ -369,7 +368,7 @@ virtqueue_enqueue_xmit(struct virtqueue txvq->vq_free_cnt =3D (uint16_t)(txvq->vq_free_cnt - needed); vq_update_avail_ring(txvq, head_idx); =20 - return (0); + return 0; } =20 static inline uint16_t __attribute__((always_inline)) @@ -381,7 +380,7 @@ = virtqueue_dequeue_burst_rx(struct virtqu uint16_t i; =20 /* Caller does the check */ - for (i =3D 0; i < num ; i ++) { + for (i =3D 0; i < num; i++) { used_idx =3D (uint16_t)(vq->vq_used_cons_idx & (vq->vq_nentries - 1)); uep =3D &vq->vq_ring.used->ring[used_idx]; desc_idx =3D (uint16_t) uep->id; @@ -402,7 +401,7 @@ virtqueue_dequeue_burst_rx(struct virtqu vq->vq_descx[desc_idx].cookie =3D NULL; } =20 - return (i); + return i; } =20 static inline uint16_t __attribute__((always_inline)) @@ -420,7 +419,7 @@ = virtqueue_dequeue_pkt_tx(struct virtqueu return 0; } =20 -#ifdef RTE_LIBRTE_VIRTIO_DEBUG_DUMP +#ifdef RTE_LIBRTE_VIRTIO_DEBUG_DUMP #define VIRTQUEUE_DUMP(vq) do { \ uint16_t used_idx, nused; \ used_idx =3D (vq)->vq_ring.used->idx; \