From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 593BDA052A; Tue, 26 Jan 2021 11:19:34 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B00FF141378; Tue, 26 Jan 2021 11:17:41 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mails.dpdk.org (Postfix) with ESMTP id C7B12141373 for ; Tue, 26 Jan 2021 11:17:37 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1611656257; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=G9QYHRxM9DCSojXGYSNWjVprQtg7C5HuZ2qiGPgAAT8=; b=C7pqkO0tjp5h0WiqP9GHdbvvgUg1nI6dwFewnZqVxjjb8WQIZgJpCbO40x9oIUWPkq54f0 WWQ8KfQ6SIfGeCfhw09Q/xUx58MZWkvPPnqYCUWbbYgFWxmdjXejb/2oWx69Pa//L5/Ptb kLGc8BGsfX6xhgjRT1puIZ+G3vQc8WI= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-580-fob_8ov4NUukf_2Yty8pZg-1; Tue, 26 Jan 2021 05:17:35 -0500 X-MC-Unique: fob_8ov4NUukf_2Yty8pZg-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3E11A1005504; Tue, 26 Jan 2021 10:17:34 +0000 (UTC) Received: from max-t490s.redhat.com (unknown [10.36.110.31]) by smtp.corp.redhat.com (Postfix) with ESMTP id C4C4D710DC; Tue, 26 Jan 2021 10:17:32 +0000 (UTC) From: Maxime Coquelin To: dev@dpdk.org, chenbo.xia@intel.com, olivier.matz@6wind.com, amorenoz@redhat.com, david.marchand@redhat.com Cc: Maxime Coquelin Date: Tue, 26 Jan 2021 11:16:11 +0100 Message-Id: <20210126101639.250481-17-maxime.coquelin@redhat.com> In-Reply-To: <20210126101639.250481-1-maxime.coquelin@redhat.com> References: <20210126101639.250481-1-maxime.coquelin@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=maxime.coquelin@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII" Subject: [dpdk-dev] [PATCH v4 16/44] net/virtio: pack virtio HW struct X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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" This patch improves the virtio_hw struct packing, going from 88 down to 80 bytes with a 6 bytes hole in the end of the first cacheline. Fields only used in the slow path are placed in the end, so that hot path only uses the first cacheline. The patch also changes booleans fields to uint8_t type, and fix inconsistencies in their assignments. Signed-off-by: Maxime Coquelin Reviewed-by: Chenbo Xia --- drivers/net/virtio/virtio_ethdev.c | 12 ++++---- drivers/net/virtio/virtio_pci.h | 45 +++++++++++++++--------------- drivers/net/virtio/virtqueue.h | 2 +- 3 files changed, 29 insertions(+), 30 deletions(-) diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c index c46fe4adf6..c1d7b14dda 100644 --- a/drivers/net/virtio/virtio_ethdev.c +++ b/drivers/net/virtio/virtio_ethdev.c @@ -699,7 +699,7 @@ virtio_dev_close(struct rte_eth_dev *dev) if (!hw->opened) return 0; - hw->opened = false; + hw->opened = 0; /* reset the NIC */ if (dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC) @@ -1864,7 +1864,7 @@ eth_virtio_dev_init(struct rte_eth_dev *eth_dev) } } - hw->opened = true; + hw->opened = 1; return 0; @@ -1973,7 +1973,7 @@ virtio_dev_devargs_parse(struct rte_devargs *devargs, uint32_t *speed, int *vect return ret; } -static bool +static uint8_t rx_offload_enabled(struct virtio_hw *hw) { return vtpci_with_feature(hw, VIRTIO_NET_F_GUEST_CSUM) || @@ -1981,7 +1981,7 @@ rx_offload_enabled(struct virtio_hw *hw) vtpci_with_feature(hw, VIRTIO_NET_F_GUEST_TSO6); } -static bool +static uint8_t tx_offload_enabled(struct virtio_hw *hw) { return vtpci_with_feature(hw, VIRTIO_NET_F_CSUM) || @@ -2267,7 +2267,7 @@ virtio_dev_start(struct rte_eth_dev *dev) } set_rxtx_funcs(dev); - hw->started = true; + hw->started = 1; /* Initialize Link state */ virtio_dev_link_update(dev, 0); @@ -2336,7 +2336,7 @@ virtio_dev_stop(struct rte_eth_dev *dev) rte_spinlock_lock(&hw->state_lock); if (!hw->started) goto out_unlock; - hw->started = false; + hw->started = 0; if (intr_conf->lsc || intr_conf->rxq) { virtio_intr_disable(dev); diff --git a/drivers/net/virtio/virtio_pci.h b/drivers/net/virtio/virtio_pci.h index 4f3690032b..15f8144fc6 100644 --- a/drivers/net/virtio/virtio_pci.h +++ b/drivers/net/virtio/virtio_pci.h @@ -247,26 +247,25 @@ struct virtio_pci_ops { struct virtio_net_config; struct virtio_hw { - struct virtnet_ctl *cvq; - uint64_t req_guest_features; - uint64_t guest_features; - uint32_t max_queue_pairs; - bool started; - uint16_t max_mtu; - uint16_t vtnet_hdr_size; - uint8_t vlan_strip; - uint8_t use_msix; - uint8_t use_vec_rx; - uint8_t use_vec_tx; - uint8_t use_inorder_rx; - uint8_t use_inorder_tx; - uint8_t weak_barriers; - bool has_tx_offload; - bool has_rx_offload; - uint16_t port_id; - uint8_t mac_addr[RTE_ETHER_ADDR_LEN]; - uint32_t speed; /* link speed in MB */ - uint8_t duplex; + struct virtqueue **vqs; + uint64_t guest_features; + uint16_t vtnet_hdr_size; + uint8_t started; + uint8_t weak_barriers; + uint8_t vlan_strip; + uint8_t has_tx_offload; + uint8_t has_rx_offload; + uint8_t use_vec_rx; + uint8_t use_vec_tx; + uint8_t use_inorder_rx; + uint8_t use_inorder_tx; + uint8_t opened; + uint16_t port_id; + uint8_t mac_addr[RTE_ETHER_ADDR_LEN]; + uint32_t speed; /* link speed in MB */ + uint8_t duplex; + uint8_t use_msix; + uint16_t max_mtu; /* * App management thread and virtio interrupt handler thread * both can change device state, this lock is meant to avoid @@ -274,9 +273,9 @@ struct virtio_hw { */ rte_spinlock_t state_lock; struct rte_mbuf **inject_pkts; - bool opened; - - struct virtqueue **vqs; + uint16_t max_queue_pairs; + uint64_t req_guest_features; + struct virtnet_ctl *cvq; }; struct virtio_pci_dev { diff --git a/drivers/net/virtio/virtqueue.h b/drivers/net/virtio/virtqueue.h index 7611317581..3a9ce29069 100644 --- a/drivers/net/virtio/virtqueue.h +++ b/drivers/net/virtio/virtqueue.h @@ -615,7 +615,7 @@ virtqueue_notify(struct virtqueue *vq) static inline void virtqueue_xmit_offload(struct virtio_net_hdr *hdr, struct rte_mbuf *cookie, - bool offload) + uint8_t offload) { if (offload) { if (cookie->ol_flags & PKT_TX_TCP_SEG) -- 2.29.2