From patchwork Wed Nov 28 09:46:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiao Wang X-Patchwork-Id: 48377 X-Patchwork-Delegate: maxime.coquelin@redhat.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 91FA61B48F; Wed, 28 Nov 2018 10:56:05 +0100 (CET) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id 707781B488 for ; Wed, 28 Nov 2018 10:56:01 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Nov 2018 01:56:01 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,290,1539673200"; d="scan'208";a="112891202" Received: from dpdk-xiao-1.sh.intel.com ([10.67.111.106]) by orsmga001.jf.intel.com with ESMTP; 28 Nov 2018 01:55:59 -0800 From: Xiao Wang To: tiwei.bie@intel.com, maxime.coquelin@redhat.com Cc: dev@dpdk.org, zhihong.wang@intel.com, xiaolong.ye@intel.com, Xiao Wang Date: Wed, 28 Nov 2018 17:46:05 +0800 Message-Id: <20181128094607.106173-8-xiao.w.wang@intel.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20181128094607.106173-1-xiao.w.wang@intel.com> References: <20181128094607.106173-1-xiao.w.wang@intel.com> Subject: [dpdk-dev] [PATCH 7/9] net/ifc: use lib API for used ring logging X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Vhost lib has already provided a helper for used ring logging, driver could use it to reduce code. Signed-off-by: Xiao Wang --- drivers/net/ifc/ifcvf_vdpa.c | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/drivers/net/ifc/ifcvf_vdpa.c b/drivers/net/ifc/ifcvf_vdpa.c index e9cc8d7bc..6c64ac4f7 100644 --- a/drivers/net/ifc/ifcvf_vdpa.c +++ b/drivers/net/ifc/ifcvf_vdpa.c @@ -31,6 +31,9 @@ #define PAGE_SIZE 4096 #endif +#define IFCVF_USED_RING_LEN(size) \ + ((size) * sizeof(struct vring_used_elem) + sizeof(uint16_t) * 3) + #define IFCVF_VDPA_MODE "vdpa" #define IFCVF_SW_FALLBACK_LM "swlm" @@ -288,21 +291,6 @@ vdpa_ifcvf_start(struct ifcvf_internal *internal) return ifcvf_start_hw(&internal->hw); } -static void -ifcvf_used_ring_log(struct ifcvf_hw *hw, uint32_t queue, uint8_t *log_buf) -{ - uint32_t i, size; - uint64_t pfn; - - pfn = hw->vring[queue].used / PAGE_SIZE; - size = hw->vring[queue].size * sizeof(struct vring_used_elem) + - sizeof(uint16_t) * 3; - - for (i = 0; i <= size / PAGE_SIZE; i++) - __sync_fetch_and_or_8(&log_buf[(pfn + i) / 8], - 1 << ((pfn + i) % 8)); -} - static void vdpa_ifcvf_stop(struct ifcvf_internal *internal) { @@ -311,7 +299,7 @@ vdpa_ifcvf_stop(struct ifcvf_internal *internal) int vid; uint64_t features; uint64_t log_base, log_size; - uint8_t *log_buf; + uint64_t len; vid = internal->vid; ifcvf_stop_hw(hw); @@ -330,9 +318,10 @@ vdpa_ifcvf_stop(struct ifcvf_internal *internal) * IFCVF marks dirty memory pages for only packet buffer, * SW helps to mark the used ring as dirty after device stops. */ - log_buf = (uint8_t *)(uintptr_t)log_base; - for (i = 0; i < hw->nr_vring; i++) - ifcvf_used_ring_log(hw, i, log_buf); + for (i = 0; i < hw->nr_vring; i++) { + len = IFCVF_USED_RING_LEN(hw->vring[i].size); + rte_vhost_log_used_vring(vid, i, 0, len); + } } }