From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id 15B448D3A for ; Mon, 18 Jan 2016 18:07:55 +0100 (CET) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga104.fm.intel.com with ESMTP; 18 Jan 2016 09:07:55 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.22,313,1449561600"; d="scan'208";a="31634987" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by fmsmga004.fm.intel.com with ESMTP; 18 Jan 2016 09:07:55 -0800 Received: from shsmsx103.ccr.corp.intel.com (10.239.4.69) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.248.2; Mon, 18 Jan 2016 09:07:54 -0800 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.215]) by SHSMSX103.ccr.corp.intel.com ([169.254.4.218]) with mapi id 14.03.0248.002; Tue, 19 Jan 2016 01:07:52 +0800 From: "Xie, Huawei" To: Yuanhan Liu , "dev@dpdk.org" Thread-Topic: [PATCH v4 7/8] virtio: add 1.0 support Thread-Index: AdFSEsO9024IClH9QuSR9YlAzWxVyw== Date: Mon, 18 Jan 2016 17:07:51 +0000 Message-ID: References: <1452581944-24838-1-git-send-email-yuanhan.liu@linux.intel.com> <1452832571-6156-1-git-send-email-yuanhan.liu@linux.intel.com> <1452832571-6156-8-git-send-email-yuanhan.liu@linux.intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.4.160] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v4 7/8] virtio: add 1.0 support 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, 18 Jan 2016 17:07:56 -0000 .On 1/15/2016 12:34 PM, Yuanhan Liu wrote:=0A= > Modern (v1.0) virtio pci device defines several pci capabilities.=0A= > Each cap has a configure structure corresponding to it, and the=0A= > cap.bar and cap.offset fields tell us where to find it.=0A= >=0A= [snip]=0A= > +=0A= > +static inline void=0A= > +io_write64_twopart(uint64_t val, uint32_t *lo, uint32_t *hi)=0A= > +{=0A= > + io_write32((uint32_t)val, lo);=0A= > + io_write32(val >> 32, hi);=0A= =0A= Firstly your second iowrite32 doesn't do the conversion. The conversion=0A= is duplicated.=0A= =0A= > +}=0A= > +=0A= > +static void=0A= > +modern_read_dev_config(struct virtio_hw *hw, uint64_t offset,=0A= =0A= here and there, size_t is more accurate for offset as we get it from=0A= offsetof.=0A= =0A= > + void *dst, int length)=0A= > +{=0A= > + int i;=0A= > + uint8_t *p;=0A= > + uint8_t old_gen, new_gen;=0A= > +=0A= > + do {=0A= > + old_gen =3D io_read8(&hw->common_cfg->config_generation);=0A= > +=0A= > + p =3D dst;=0A= > + for (i =3D 0; i < length; i++)=0A= > + *p++ =3D io_read8((uint8_t *)hw->dev_cfg + offset + i);=0A= > +=0A= > + new_gen =3D io_read8(&hw->common_cfg->config_generation);=0A= > + } while (old_gen !=3D new_gen);=0A= > +}=0A= > +=0A= > +static void=0A= > +modern_write_dev_config(struct virtio_hw *hw, uint64_t offset,=0A= > + const void *src, int length)=0A= > +{=0A= > + int i;=0A= > + const uint8_t *p =3D src;=0A= > +=0A= > + for (i =3D 0; i < length; i++)=0A= > + io_write8(*p++, (uint8_t *)hw->dev_cfg + offset + i);=0A= > +}=0A= > +=0A= > +static uint64_t=0A= > +modern_get_features(struct virtio_hw *hw)=0A= > +{=0A= > + uint32_t features_lo, features_hi;=0A= > +=0A= > + io_write32(0, &hw->common_cfg->device_feature_select);=0A= > + features_lo =3D io_read32(&hw->common_cfg->device_feature);=0A= > +=0A= > + io_write32(1, &hw->common_cfg->device_feature_select);=0A= > + features_hi =3D io_read32(&hw->common_cfg->device_feature);=0A= > +=0A= > + return ((uint64_t)(features_hi) << 32) | features_lo;=0A= > +}=0A= > +=0A= > +static void=0A= > +modern_set_features(struct virtio_hw *hw, uint64_t features)=0A= > +{=0A= > + io_write32(0, &hw->common_cfg->guest_feature_select);=0A= > + io_write32(features & ((1ULL << 32) - 1),=0A= =0A= again, duplicated conversion=0A= =0A= > + &hw->common_cfg->guest_feature);=0A= > +=0A= > + io_write32(1, &hw->common_cfg->guest_feature_select);=0A= [snip]=0A=