From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 1942B6895 for ; Mon, 19 May 2014 17:09:50 +0200 (CEST) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga102.fm.intel.com with ESMTP; 19 May 2014 08:09:58 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.98,868,1392192000"; d="scan'208";a="534254269" Received: from shilc102.sh.intel.com ([10.239.39.44]) by fmsmga001.fm.intel.com with ESMTP; 19 May 2014 08:09:52 -0700 Received: from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com [10.239.29.89]) by shilc102.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id s4JF9lwG030074; Mon, 19 May 2014 23:09:50 +0800 Received: from shecgisg004.sh.intel.com (localhost [127.0.0.1]) by shecgisg004.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id s4JF9iHQ019425; Mon, 19 May 2014 23:09:46 +0800 Received: (from couyang@localhost) by shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id s4JF9h1k019421; Mon, 19 May 2014 23:09:43 +0800 From: Ouyang Changchun To: dev@dpdk.org Date: Mon, 19 May 2014 23:09:37 +0800 Message-Id: <1400512177-19315-1-git-send-email-changchun.ouyang@intel.com> X-Mailer: git-send-email 1.7.0.7 Subject: [dpdk-dev] [PATCH] [PMD] [VHOST] Revert unnecessary definition and fix wrong referring in user space vhost zero copy patches 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: Mon, 19 May 2014 15:09:51 -0000 1. Revert the change of metadata macro definition for referring to headroom space in mbuf; 2. Fix wrongly referring to RX queues number in TX queues start/stop function. Signed-off-by: Ouyang Changchun --- examples/vhost/main.c | 15 +++++++++------ lib/librte_ether/rte_ethdev.c | 8 ++++---- lib/librte_mbuf/rte_mbuf.h | 17 ----------------- 3 files changed, 13 insertions(+), 27 deletions(-) diff --git a/examples/vhost/main.c b/examples/vhost/main.c index 21704f1..674608c 100644 --- a/examples/vhost/main.c +++ b/examples/vhost/main.c @@ -129,6 +129,9 @@ #define RTE_TEST_RX_DESC_DEFAULT_ZCP 32 /* legacy: 32, DPDK virt FE: 128. */ #define RTE_TEST_TX_DESC_DEFAULT_ZCP 64 /* legacy: 64, DPDK virt FE: 64. */ +/* Get first 4 bytes in mbuf headroom. */ +#define MBUF_HEADROOM_UINT32(mbuf) (*(uint32_t*)((uint8_t*)(mbuf) + sizeof(struct rte_mbuf))) + /* true if x is a power of 2 */ #define POWEROF2(x) ((((x)-1) & (x)) == 0) @@ -1638,7 +1641,7 @@ attach_rxmbuf_zcp(struct virtio_net *dev) mbuf->pkt.data = (void*)(uintptr_t)(buff_addr); mbuf->buf_physaddr = phys_addr - RTE_PKTMBUF_HEADROOM; mbuf->pkt.data_len = desc->len; - RTE_MBUF_METADATA_UINT32(mbuf, 0) = (uint32_t)desc_idx; + MBUF_HEADROOM_UINT32(mbuf) = (uint32_t)desc_idx; LOG_DEBUG(DATA, "(%"PRIu64") in attach_rxmbuf_zcp: res base idx:%d, descriptor idx:%d\n", dev->device_fh, res_base_idx, desc_idx); @@ -1700,7 +1703,7 @@ txmbuf_clean_zcp(struct virtio_net* dev, struct vpool* vpool) rte_ring_sp_enqueue(vpool->ring, mbuf); /* Update used index buffer information. */ - vq->used->ring[used_idx].id = RTE_MBUF_METADATA_UINT32(mbuf, 0); + vq->used->ring[used_idx].id = MBUF_HEADROOM_UINT32(mbuf); vq->used->ring[used_idx].len = 0; used_idx = (used_idx + 1) & (vq->size - 1); @@ -1788,7 +1791,7 @@ virtio_dev_rx_zcp(struct virtio_net *dev, struct rte_mbuf **pkts, uint32_t count /* Retrieve all of the head indexes first to avoid caching issues. */ for (head_idx = 0; head_idx < count; head_idx++) - head[head_idx] = RTE_MBUF_METADATA_UINT32((pkts[head_idx]), 0); + head[head_idx] = MBUF_HEADROOM_UINT32(pkts[head_idx]); /*Prefetch descriptor index. */ rte_prefetch0(&vq->desc[head[packet_success]]); @@ -1799,7 +1802,7 @@ virtio_dev_rx_zcp(struct virtio_net *dev, struct rte_mbuf **pkts, uint32_t count buff = pkts[packet_success]; LOG_DEBUG(DATA, "(%"PRIu64") in dev_rx_zcp: update the used idx for pkt[%d] descriptor idx: %d\n", - dev->device_fh, packet_success, RTE_MBUF_METADATA_UINT32(buff, 0)); + dev->device_fh, packet_success, MBUF_HEADROOM_UINT32(buff)); PRINT_PACKET(dev, (uintptr_t)(((uint64_t)(uintptr_t)buff->buf_addr) + RTE_PKTMBUF_HEADROOM), rte_pktmbuf_data_len(buff), 0); @@ -1901,7 +1904,7 @@ virtio_tx_route_zcp(struct virtio_net* dev, struct rte_mbuf *m, uint32_t desc_id if (unlikely(dev_ll->dev->device_fh == dev->device_fh)) { LOG_DEBUG(DATA, "(%"PRIu64") TX: Source and destination MAC addresses are the same. Dropping packet.\n", dev_ll->dev->device_fh); - RTE_MBUF_METADATA_UINT32(mbuf, 0) = (uint32_t)desc_idx; + MBUF_HEADROOM_UINT32(mbuf) = (uint32_t)desc_idx; __rte_mbuf_raw_free(mbuf); return ; } @@ -1936,7 +1939,7 @@ virtio_tx_route_zcp(struct virtio_net* dev, struct rte_mbuf *m, uint32_t desc_id mbuf->pkt.vlan_macip.f.vlan_tci = vlan_tag; mbuf->pkt.vlan_macip.f.l2_len = sizeof(struct ether_hdr); mbuf->pkt.vlan_macip.f.l3_len = sizeof(struct ipv4_hdr); - RTE_MBUF_METADATA_UINT32(mbuf, 0) = (uint32_t)desc_idx; + MBUF_HEADROOM_UINT32(mbuf) = (uint32_t)desc_idx; tx_q->m_table[len] = mbuf; len++; diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index 7faeeff..0008755 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -360,8 +360,8 @@ rte_eth_dev_tx_queue_start(uint8_t port_id, uint16_t tx_queue_id) } dev = &rte_eth_devices[port_id]; - if (tx_queue_id >= dev->data->nb_rx_queues) { - PMD_DEBUG_TRACE("Invalid RX queue_id=%d\n", tx_queue_id); + if (tx_queue_id >= dev->data->nb_tx_queues) { + PMD_DEBUG_TRACE("Invalid TX queue_id=%d\n", tx_queue_id); return (-EINVAL); } @@ -386,8 +386,8 @@ rte_eth_dev_tx_queue_stop(uint8_t port_id, uint16_t tx_queue_id) } dev = &rte_eth_devices[port_id]; - if (tx_queue_id >= dev->data->nb_rx_queues) { - PMD_DEBUG_TRACE("Invalid RX queue_id=%d\n", tx_queue_id); + if (tx_queue_id >= dev->data->nb_tx_queues) { + PMD_DEBUG_TRACE("Invalid TX queue_id=%d\n", tx_queue_id); return (-EINVAL); } diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h index baf3ca4..edffc2c 100644 --- a/lib/librte_mbuf/rte_mbuf.h +++ b/lib/librte_mbuf/rte_mbuf.h @@ -201,25 +201,8 @@ struct rte_mbuf { struct rte_ctrlmbuf ctrl; struct rte_pktmbuf pkt; }; - - union { - uint8_t metadata[0]; - uint16_t metadata16[0]; - uint32_t metadata32[0]; - uint64_t metadata64[0]; - }; } __rte_cache_aligned; -#define RTE_MBUF_METADATA_UINT8(mbuf, offset) (mbuf->metadata[offset]) -#define RTE_MBUF_METADATA_UINT16(mbuf, offset) (mbuf->metadata16[offset/sizeof(uint16_t)]) -#define RTE_MBUF_METADATA_UINT32(mbuf, offset) (mbuf->metadata32[offset/sizeof(uint32_t)]) -#define RTE_MBUF_METADATA_UINT64(mbuf, offset) (mbuf->metadata64[offset/sizeof(uint64_t)]) - -#define RTE_MBUF_METADATA_UINT8_PTR(mbuf, offset) (&mbuf->metadata[offset]) -#define RTE_MBUF_METADATA_UINT16_PTR(mbuf, offset) (&mbuf->metadata16[offset/sizeof(uint16_t)]) -#define RTE_MBUF_METADATA_UINT32_PTR(mbuf, offset) (&mbuf->metadata32[offset/sizeof(uint32_t)]) -#define RTE_MBUF_METADATA_UINT64_PTR(mbuf, offset) (&mbuf->metadata64[offset/sizeof(uint64_t)]) - /** * Given the buf_addr returns the pointer to corresponding mbuf. */ -- 1.9.0