From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id E115E5A32 for ; Mon, 18 Jan 2016 14:45:02 +0100 (CET) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga103.jf.intel.com with ESMTP; 18 Jan 2016 05:44:44 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.22,312,1449561600"; d="scan'208";a="31544766" Received: from yliu-dev.sh.intel.com (HELO yliu-dev) ([10.239.66.49]) by fmsmga004.fm.intel.com with ESMTP; 18 Jan 2016 05:44:43 -0800 Date: Mon, 18 Jan 2016 21:46:45 +0800 From: Yuanhan Liu To: Tetsuya Mukawa Message-ID: <20160118134645.GC19531@yliu-dev.sh.intel.com> References: <1453108389-21006-1-git-send-email-mukawa@igel.co.jp> <1453108389-21006-4-git-send-email-mukawa@igel.co.jp> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1453108389-21006-4-git-send-email-mukawa@igel.co.jp> User-Agent: Mutt/1.5.23 (2014-03-12) Cc: dev@dpdk.org Subject: Re: [dpdk-dev] [PATCH 3/3] virtio: Add a new layer to abstract pci access method 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 13:45:03 -0000 On Mon, Jan 18, 2016 at 06:13:09PM +0900, Tetsuya Mukawa wrote: > +struct virtio_pci_access_ops { > + uint8_t (*legacy_read8)(struct virtio_hw *hw, uint8_t *addr); > + uint16_t (*legacy_read16)(struct virtio_hw *hw, uint16_t *addr); > + uint32_t (*legacy_read32)(struct virtio_hw *hw, uint32_t *addr); > + void (*legacy_write8)(struct virtio_hw *hw, > + uint8_t *addr, uint8_t val); > + void (*legacy_write16)(struct virtio_hw *hw, > + uint16_t *addr, uint16_t val); > + void (*legacy_write32)(struct virtio_hw *hw, > + uint32_t *addr, uint32_t val); > + > + uint8_t (*modern_read8)(struct virtio_hw *hw, uint8_t *addr); > + uint16_t (*modern_read16)(struct virtio_hw *hw, uint16_t *addr); > + uint32_t (*modern_read32)(struct virtio_hw *hw, uint32_t *addr); > + void (*modern_write8)(struct virtio_hw *hw, > + uint8_t *addr, uint8_t val); > + void (*modern_write16)(struct virtio_hw *hw, > + uint16_t *addr, uint16_t val); > + void (*modern_write32)(struct virtio_hw *hw, > + uint32_t *addr, uint32_t val); One thing about abstraction is that you need define one set of operations, instead of two similar sets. Thus, you need define following operations only: - read8 - read16 - read32 - write8 - write16 - write32 And make a proper assignment after the modern/legacy detection. > + > + int (*map_pci_cfg)(struct virtio_hw *hw); > + void (*unmap_pci_cfg)(struct virtio_hw *hw); > + void *(*get_cfg_addr)(struct virtio_hw *hw, > + struct virtio_pci_cap *cap); > + int (*read_pci_cfg)(struct virtio_hw *hw, > + void *buf, size_t len, off_t offset); It'd be good if you can post the patches that use above abstract operations, so that people can tell if they are properly defined. --yliu