From patchwork Thu Jan 21 11:07:54 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tetsuya Mukawa X-Patchwork-Id: 10031 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 3A80B8E98; Thu, 21 Jan 2016 12:08:15 +0100 (CET) Received: from mail-pa0-f49.google.com (mail-pa0-f49.google.com [209.85.220.49]) by dpdk.org (Postfix) with ESMTP id 8489E8E94 for ; Thu, 21 Jan 2016 12:08:12 +0100 (CET) Received: by mail-pa0-f49.google.com with SMTP id uo6so22208102pac.1 for ; Thu, 21 Jan 2016 03:08:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=igel-co-jp.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=m7/1f143UIw76L0ujJgpnO0iJ46xSy0DtXzg5EN8crU=; b=2PsgEzeN40Ii+nThlvnF8+lTXv/f6hgTv/4WshmY7I5QLz2tNLaiRO5fyC2hihFTxH /mJnE2wUd2bNZUNDTv5pkapPVoUuJ9ryMI8YiEz16rUUzByeNny9xebWrC85C61KWW3G QJrToYDKq71uO+rqvzui7BWXhOtBe2hHX84pCnN/zEZ+AHGU4y/mAdsW//RIXncUqbay Hdj5fNA7braD6QK4GJlG3elzaSJS4GP2OTGvFpZOl8v0/zJfAwej3cFOn3UksndpYILB 1QZC9Uzn6NOb/WQloBcuMbHUVeJvat6aefUi0+HIeQxFpzpM+I0ZhqAk7+r/KBNyx0EU jO2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=m7/1f143UIw76L0ujJgpnO0iJ46xSy0DtXzg5EN8crU=; b=NqUGp70naT4dvNdSZvPSlYx5xWoUzB6/7vqA79/NAsih6HK4HwCQZbX6f9umYr3F4X TGAGGdiHe4ku6JCQ2MWO36Ch9hta5dhMVAvTrx8jujzVsulZq0H3LRxb/0MlbhWVKCjF bmhatpRMqNzGLeJvQCofF9Pe9TwnfJKXel6OlhNnUyu5muYkYXzFNUGfzqqP296oPlvg auM0zJoh9ssx4Gp+rBl5Rf4v0O6Dg4zGO64I7eAScG4q0JClbTIQo6R1WJVf4s448Wmc MhQIIoh7CizF9SwtjSymmx5rZ+l8NZv3g9lHqe4PNc7T6aF9P1rboUs386kIXDeNEtDL w3jA== X-Gm-Message-State: ALoCoQk6eOMox6Vnf5004djT6/wlKffDACKSTgYRVs/SfIUM9YrEHHRJWyOGf+6Ky9TKwLYVfx1i2esOeHBkBack6J8C2IbLdw== X-Received: by 10.66.161.133 with SMTP id xs5mr59404641pab.70.1453374491889; Thu, 21 Jan 2016 03:08:11 -0800 (PST) Received: from localhost.localdomain (napt.igel.co.jp. [219.106.231.132]) by smtp.gmail.com with ESMTPSA id wa17sm1792640pac.38.2016.01.21.03.08.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 21 Jan 2016 03:08:11 -0800 (PST) From: Tetsuya Mukawa To: dev@dpdk.org, yuanhan.liu@linux.intel.com, jianfeng.tan@intel.com Date: Thu, 21 Jan 2016 20:07:54 +0900 Message-Id: <1453374478-30996-2-git-send-email-mukawa@igel.co.jp> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1453374478-30996-1-git-send-email-mukawa@igel.co.jp> References: <1453374478-30996-1-git-send-email-mukawa@igel.co.jp> In-Reply-To: <1453108389-21006-2-git-send-email-mukawa@igel.co.jp> References: <1453108389-21006-2-git-send-email-mukawa@igel.co.jp> Subject: [dpdk-dev] [RFC PATCH 1/5] virtio: Change the parameter order of io_write8/16/32() 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 --- drivers/net/virtio/virtio_pci.c | 66 ++++++++++++++++++++--------------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/drivers/net/virtio/virtio_pci.c b/drivers/net/virtio/virtio_pci.c index 6b87429..0aeffb7 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 IO_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 @@ IO_READ_DEF (32, uint32_t) IO_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(val & ((1ULL << 32) - 1), lo); - io_write32(val >> 32, hi); + io_write32(lo, val & ((1ULL << 32) - 1)); + io_write32(hi, val >> 32); } static void @@ -526,7 +526,7 @@ modern_write_dev_config(struct virtio_hw *hw, size_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 = {