[dpdk-dev,1/3] virtio: Change the parameter order of io_write8/16/32()

Message ID 1453108389-21006-2-git-send-email-mukawa@igel.co.jp (mailing list archive)
State Changes Requested, archived
Delegated to: Bruce Richardson
Headers

Commit Message

Tetsuya Mukawa Jan. 18, 2016, 9:13 a.m. UTC
  The patch change the parameter order of below functions.
 - io_write8()
 - io_write16()
 - io_write32()
This changig are needed to add a new layer to abstract accessing
method.

Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
---
 drivers/net/virtio/virtio_pci.c | 66 ++++++++++++++++++++---------------------
 1 file changed, 33 insertions(+), 33 deletions(-)
  

Comments

Tetsuya Mukawa Jan. 21, 2016, 11:07 a.m. UTC | #1
This patch series are not for upstreaming.

It describe how to use a new access method abstraction of "virtio-pci.c".
Because of this, some patches are not for upstreaming.

For example, below changes will be shared with Jianfeng's patches.
So these changes are just temporary.
 - "--shm" option to allocate EAL memory.
 - Some changes to access to EAL memory by virtual address.

Anyway, some changes are not for upstreaming, but virtual virtio-net PMD
should work with QEMU as described in commit log.

Tetsuya Mukawa (5):
  virtio: Change the parameter order of io_write8/16/32()
  virtio: move rte_eal_pci_unmap_device() to virtio_pci.c
  virtio: Add a new layer to abstract pci access method
  EAL: Add new EAL "--shm" option.
  virtio: Extend virtio-net PMD to support container environment

 config/common_linuxapp                     |    1 +
 drivers/net/virtio/Makefile                |    4 +
 drivers/net/virtio/qtest.c                 | 1237 ++++++++++++++++++++++++++++
 drivers/net/virtio/virtio_ethdev.c         |  454 ++++++++--
 drivers/net/virtio/virtio_ethdev.h         |   12 +
 drivers/net/virtio/virtio_pci.c            |  732 ++++++++++++----
 drivers/net/virtio/virtio_pci.h            |   39 +-
 drivers/net/virtio/virtio_rxtx.c           |    3 +-
 drivers/net/virtio/virtqueue.h             |    9 +-
 lib/librte_eal/common/eal_common_options.c |    5 +
 lib/librte_eal/common/eal_internal_cfg.h   |    1 +
 lib/librte_eal/common/eal_options.h        |    2 +
 lib/librte_eal/common/include/rte_memory.h |    5 +
 lib/librte_eal/linuxapp/eal/eal_memory.c   |   76 ++
 14 files changed, 2337 insertions(+), 243 deletions(-)
 create mode 100644 drivers/net/virtio/qtest.c
  
Tetsuya Mukawa Jan. 21, 2016, 11:10 a.m. UTC | #2
On 2016/01/21 20:07, Tetsuya Mukawa wrote:
> This patch series are not for upstreaming.
>
> It describe how to use a new access method abstraction of "virtio-pci.c".
> Because of this, some patches are not for upstreaming.
>
> For example, below changes will be shared with Jianfeng's patches.
> So these changes are just temporary.
>  - "--shm" option to allocate EAL memory.
>  - Some changes to access to EAL memory by virtual address.
>
> Anyway, some changes are not for upstreaming, but virtual virtio-net PMD
> should work with QEMU as described in commit log.
>
> Tetsuya Mukawa (5):
>   virtio: Change the parameter order of io_write8/16/32()
>   virtio: move rte_eal_pci_unmap_device() to virtio_pci.c
>   virtio: Add a new layer to abstract pci access method
>   EAL: Add new EAL "--shm" option.
>   virtio: Extend virtio-net PMD to support container environment
>
>  config/common_linuxapp                     |    1 +
>  drivers/net/virtio/Makefile                |    4 +
>  drivers/net/virtio/qtest.c                 | 1237 ++++++++++++++++++++++++++++
>  drivers/net/virtio/virtio_ethdev.c         |  454 ++++++++--
>  drivers/net/virtio/virtio_ethdev.h         |   12 +
>  drivers/net/virtio/virtio_pci.c            |  732 ++++++++++++----
>  drivers/net/virtio/virtio_pci.h            |   39 +-
>  drivers/net/virtio/virtio_rxtx.c           |    3 +-
>  drivers/net/virtio/virtqueue.h             |    9 +-
>  lib/librte_eal/common/eal_common_options.c |    5 +
>  lib/librte_eal/common/eal_internal_cfg.h   |    1 +
>  lib/librte_eal/common/eal_options.h        |    2 +
>  lib/librte_eal/common/include/rte_memory.h |    5 +
>  lib/librte_eal/linuxapp/eal/eal_memory.c   |   76 ++
>  14 files changed, 2337 insertions(+), 243 deletions(-)
>  create mode 100644 drivers/net/virtio/qtest.c
>

Hi Yuanhan and Jianfeng,

Here is example how to use this new abstraction.
Please check first 3 patches to know how to implement the abstraction.

Also please see changes for "virtio_pci.c" involved in last patch.
This is the example.

Thanks,
Tetsuya
  
Tetsuya Mukawa Jan. 28, 2016, 9:33 a.m. UTC | #3
The patches abstract pci access method of virtio-net PMD.
The patch should be on Yuanhan's below patch series.
 - [PATCH v6 0/9] virtio 1.0 enabling for virtio pmd driver.

PATCH v2 changes
 - Rebase on Yuanhan's v6 patches.
 - split virtio_pci_access_ops in 2 different structures.
 - some refactoring.


Tetsuya Mukawa (3):
  virtio: Change the parameter order of io_write8/16/32()
  virtio: move rte_eal_pci_unmap_device() to virtio_pci.c
  virtio: Add a new layer to abstract pci access method

 drivers/net/virtio/virtio_ethdev.c |   4 +-
 drivers/net/virtio/virtio_pci.c    | 554 +++++++++++++++++++++++++------------
 drivers/net/virtio/virtio_pci.h    |  23 +-
 3 files changed, 403 insertions(+), 178 deletions(-)
  

Patch

diff --git a/drivers/net/virtio/virtio_pci.c b/drivers/net/virtio/virtio_pci.c
index a9f179f..f1a6ee9 100644
--- a/drivers/net/virtio/virtio_pci.c
+++ b/drivers/net/virtio/virtio_pci.c
@@ -478,7 +478,7 @@  io_read##nr_bits(type *addr)			\
 
 #define MODERN_WRITE_DEF(nr_bits, type)		\
 static inline void				\
-io_write##nr_bits(type val, type *addr)		\
+io_write##nr_bits(type *addr, type val)		\
 {						\
 	*(volatile type *)addr = val;		\
 }
@@ -493,10 +493,10 @@  MODERN_READ_DEF (32, uint32_t)
 MODERN_WRITE_DEF(32, uint32_t)
 
 static inline void
-io_write64_twopart(uint64_t val, uint32_t *lo, uint32_t *hi)
+io_write64_twopart(uint32_t *lo, uint32_t *hi, uint64_t val)
 {
-	io_write32((uint32_t)val, lo);
-	io_write32(val >> 32,     hi);
+	io_write32(lo, (uint32_t)val);
+	io_write32(hi, val >> 32);
 }
 
 static void
@@ -526,7 +526,7 @@  modern_write_dev_config(struct virtio_hw *hw, uint64_t offset,
 	const uint8_t *p = src;
 
 	for (i = 0;  i < length; i++)
-		io_write8(*p++, (uint8_t *)hw->dev_cfg + offset + i);
+		io_write8((uint8_t *)hw->dev_cfg + offset + i, *p++);
 }
 
 static uint64_t
@@ -534,10 +534,10 @@  modern_get_features(struct virtio_hw *hw)
 {
 	uint32_t features_lo, features_hi;
 
-	io_write32(0, &hw->common_cfg->device_feature_select);
+	io_write32(&hw->common_cfg->device_feature_select, 0);
 	features_lo = io_read32(&hw->common_cfg->device_feature);
 
-	io_write32(1, &hw->common_cfg->device_feature_select);
+	io_write32(&hw->common_cfg->device_feature_select, 1);
 	features_hi = io_read32(&hw->common_cfg->device_feature);
 
 	return ((uint64_t)(features_hi) << 32) | features_lo;
@@ -546,13 +546,13 @@  modern_get_features(struct virtio_hw *hw)
 static void
 modern_set_features(struct virtio_hw *hw, uint64_t features)
 {
-	io_write32(0, &hw->common_cfg->guest_feature_select);
-	io_write32(features & ((1ULL << 32) - 1),
-		&hw->common_cfg->guest_feature);
+	io_write32(&hw->common_cfg->guest_feature_select, 0);
+	io_write32(&hw->common_cfg->guest_feature,
+		   features & ((1ULL << 32) - 1));
 
-	io_write32(1, &hw->common_cfg->guest_feature_select);
-	io_write32(features >> 32,
-		&hw->common_cfg->guest_feature);
+	io_write32(&hw->common_cfg->guest_feature_select, 1);
+	io_write32(&hw->common_cfg->guest_feature,
+		   features >> 32);
 }
 
 static uint8_t
@@ -564,7 +564,7 @@  modern_get_status(struct virtio_hw *hw)
 static void
 modern_set_status(struct virtio_hw *hw, uint8_t status)
 {
-	io_write8(status, &hw->common_cfg->device_status);
+	io_write8(&hw->common_cfg->device_status, status);
 }
 
 static void
@@ -583,14 +583,14 @@  modern_get_isr(struct virtio_hw *hw)
 static uint16_t
 modern_set_config_irq(struct virtio_hw *hw, uint16_t vec)
 {
-	io_write16(vec, &hw->common_cfg->msix_config);
+	io_write16(&hw->common_cfg->msix_config, vec);
 	return io_read16(&hw->common_cfg->msix_config);
 }
 
 static uint16_t
 modern_get_queue_num(struct virtio_hw *hw, uint16_t queue_id)
 {
-	io_write16(queue_id, &hw->common_cfg->queue_select);
+	io_write16(&hw->common_cfg->queue_select, queue_id);
 	return io_read16(&hw->common_cfg->queue_size);
 }
 
@@ -606,20 +606,20 @@  modern_setup_queue(struct virtio_hw *hw, struct virtqueue *vq)
 							 ring[vq->vq_nentries]),
 				   VIRTIO_PCI_VRING_ALIGN);
 
-	io_write16(vq->vq_queue_index, &hw->common_cfg->queue_select);
+	io_write16(&hw->common_cfg->queue_select, vq->vq_queue_index);
 
-	io_write64_twopart(desc_addr, &hw->common_cfg->queue_desc_lo,
-				      &hw->common_cfg->queue_desc_hi);
-	io_write64_twopart(avail_addr, &hw->common_cfg->queue_avail_lo,
-				       &hw->common_cfg->queue_avail_hi);
-	io_write64_twopart(used_addr, &hw->common_cfg->queue_used_lo,
-				      &hw->common_cfg->queue_used_hi);
+	io_write64_twopart(&hw->common_cfg->queue_desc_lo,
+			   &hw->common_cfg->queue_desc_hi, desc_addr);
+	io_write64_twopart(&hw->common_cfg->queue_avail_lo,
+			   &hw->common_cfg->queue_avail_hi, avail_addr);
+	io_write64_twopart(&hw->common_cfg->queue_used_lo,
+			   &hw->common_cfg->queue_used_hi, used_addr);
 
 	notify_off = io_read16(&hw->common_cfg->queue_notify_off);
 	vq->notify_addr = (void *)((uint8_t *)hw->notify_base +
 				notify_off * hw->notify_off_multiplier);
 
-	io_write16(1, &hw->common_cfg->queue_enable);
+	io_write16(&hw->common_cfg->queue_enable, 1);
 
 	PMD_INIT_LOG(DEBUG, "queue %u addresses:", vq->vq_queue_index);
 	PMD_INIT_LOG(DEBUG, "\t desc_addr: %"PRIx64, desc_addr);
@@ -632,22 +632,22 @@  modern_setup_queue(struct virtio_hw *hw, struct virtqueue *vq)
 static void
 modern_del_queue(struct virtio_hw *hw, struct virtqueue *vq)
 {
-	io_write16(vq->vq_queue_index, &hw->common_cfg->queue_select);
+	io_write16(&hw->common_cfg->queue_select, vq->vq_queue_index);
 
-	io_write64_twopart(0, &hw->common_cfg->queue_desc_lo,
-				  &hw->common_cfg->queue_desc_hi);
-	io_write64_twopart(0, &hw->common_cfg->queue_avail_lo,
-				  &hw->common_cfg->queue_avail_hi);
-	io_write64_twopart(0, &hw->common_cfg->queue_used_lo,
-				  &hw->common_cfg->queue_used_hi);
+	io_write64_twopart(&hw->common_cfg->queue_desc_lo,
+			   &hw->common_cfg->queue_desc_hi, 0);
+	io_write64_twopart(&hw->common_cfg->queue_avail_lo,
+			   &hw->common_cfg->queue_avail_hi, 0);
+	io_write64_twopart(&hw->common_cfg->queue_used_lo,
+			   &hw->common_cfg->queue_used_hi, 0);
 
-	io_write16(0, &hw->common_cfg->queue_enable);
+	io_write16(&hw->common_cfg->queue_enable, 0);
 }
 
 static void
 modern_notify_queue(struct virtio_hw *hw __rte_unused, struct virtqueue *vq)
 {
-	io_write16(1, vq->notify_addr);
+	io_write16(vq->notify_addr, 1);
 }
 
 static const struct virtio_pci_ops modern_ops = {