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 693B2A00C2; Wed, 30 Nov 2022 16:57:09 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8A9CA42D19; Wed, 30 Nov 2022 16:56:58 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id C92AF42D15 for ; Wed, 30 Nov 2022 16:56:56 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1669823816; 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=Rw+FoZZFo+VMGNNYS+oFU8KWjXpQ462CB1y+aYfVDzM=; b=J+B+BA1a+8dgr4+y14KzR6XpHmlwY/8pN46VZ1F+tY2xWxj+M7zkOTUb4bMKvqpzCFYU2i T4u6ub7qtzgvgkGNU7NTD1KIeX3oRP5KQZy/OpBX8K5UltpC8eTgp/n8LCGX4WnKJ1rK/X kBW0qsSKIqPFpLxxiMgyoHhIOQCQ6KM= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-66-S4Gop00bOaqJgtYZWTuVxw-1; Wed, 30 Nov 2022 10:56:55 -0500 X-MC-Unique: S4Gop00bOaqJgtYZWTuVxw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 857F5101A528; Wed, 30 Nov 2022 15:56:54 +0000 (UTC) Received: from max-t490s.redhat.com (unknown [10.39.208.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 64EB640C2144; Wed, 30 Nov 2022 15:56:53 +0000 (UTC) From: Maxime Coquelin To: dev@dpdk.org, chenbo.xia@intel.com, david.marchand@redhat.com, eperezma@redhat.com Cc: Maxime Coquelin Subject: [PATCH v1 04/21] net/virtio: remove port ID info from Rx queue Date: Wed, 30 Nov 2022 16:56:22 +0100 Message-Id: <20221130155639.150553-5-maxime.coquelin@redhat.com> In-Reply-To: <20221130155639.150553-1-maxime.coquelin@redhat.com> References: <20221130155639.150553-1-maxime.coquelin@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true 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 The port ID information is duplicated in several places. This patch removes it from the virtnet_rx struct as it can be found in virtio_hw struct. Signed-off-by: Maxime Coquelin --- drivers/net/virtio/virtio_ethdev.c | 1 - drivers/net/virtio/virtio_rxtx.c | 25 ++++++++++--------------- drivers/net/virtio/virtio_rxtx.h | 1 - drivers/net/virtio/virtio_rxtx_packed.c | 3 +-- drivers/net/virtio/virtio_rxtx_simple.c | 3 ++- drivers/net/virtio/virtio_rxtx_simple.h | 5 +++-- 6 files changed, 16 insertions(+), 22 deletions(-) diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c index cead5f0884..1c68e5a283 100644 --- a/drivers/net/virtio/virtio_ethdev.c +++ b/drivers/net/virtio/virtio_ethdev.c @@ -462,7 +462,6 @@ virtio_init_queue(struct rte_eth_dev *dev, uint16_t queue_idx) vq->sw_ring = sw_ring; rxvq = &vq->rxq; - rxvq->port_id = dev->data->port_id; rxvq->mz = mz; rxvq->fake_mbuf = fake_mbuf; } else if (queue_type == VTNET_TQ) { diff --git a/drivers/net/virtio/virtio_rxtx.c b/drivers/net/virtio/virtio_rxtx.c index bd95e8ceb5..45c04aa3f8 100644 --- a/drivers/net/virtio/virtio_rxtx.c +++ b/drivers/net/virtio/virtio_rxtx.c @@ -1024,7 +1024,7 @@ virtio_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) continue; } - rxm->port = rxvq->port_id; + rxm->port = hw->port_id; rxm->data_off = RTE_PKTMBUF_HEADROOM; rxm->ol_flags = 0; rxm->vlan_tci = 0; @@ -1066,8 +1066,7 @@ virtio_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) } nb_enqueued += free_cnt; } else { - struct rte_eth_dev *dev = - &rte_eth_devices[rxvq->port_id]; + struct rte_eth_dev *dev = &rte_eth_devices[hw->port_id]; dev->data->rx_mbuf_alloc_failed += free_cnt; } } @@ -1127,7 +1126,7 @@ virtio_recv_pkts_packed(void *rx_queue, struct rte_mbuf **rx_pkts, continue; } - rxm->port = rxvq->port_id; + rxm->port = hw->port_id; rxm->data_off = RTE_PKTMBUF_HEADROOM; rxm->ol_flags = 0; rxm->vlan_tci = 0; @@ -1169,8 +1168,7 @@ virtio_recv_pkts_packed(void *rx_queue, struct rte_mbuf **rx_pkts, } nb_enqueued += free_cnt; } else { - struct rte_eth_dev *dev = - &rte_eth_devices[rxvq->port_id]; + struct rte_eth_dev *dev = &rte_eth_devices[hw->port_id]; dev->data->rx_mbuf_alloc_failed += free_cnt; } } @@ -1258,7 +1256,7 @@ virtio_recv_pkts_inorder(void *rx_queue, rxm->pkt_len = (uint32_t)(len[i] - hdr_size); rxm->data_len = (uint16_t)(len[i] - hdr_size); - rxm->port = rxvq->port_id; + rxm->port = hw->port_id; rx_pkts[nb_rx] = rxm; prev = rxm; @@ -1352,8 +1350,7 @@ virtio_recv_pkts_inorder(void *rx_queue, } nb_enqueued += free_cnt; } else { - struct rte_eth_dev *dev = - &rte_eth_devices[rxvq->port_id]; + struct rte_eth_dev *dev = &rte_eth_devices[hw->port_id]; dev->data->rx_mbuf_alloc_failed += free_cnt; } } @@ -1437,7 +1434,7 @@ virtio_recv_mergeable_pkts(void *rx_queue, rxm->pkt_len = (uint32_t)(len[i] - hdr_size); rxm->data_len = (uint16_t)(len[i] - hdr_size); - rxm->port = rxvq->port_id; + rxm->port = hw->port_id; rx_pkts[nb_rx] = rxm; prev = rxm; @@ -1530,8 +1527,7 @@ virtio_recv_mergeable_pkts(void *rx_queue, } nb_enqueued += free_cnt; } else { - struct rte_eth_dev *dev = - &rte_eth_devices[rxvq->port_id]; + struct rte_eth_dev *dev = &rte_eth_devices[hw->port_id]; dev->data->rx_mbuf_alloc_failed += free_cnt; } } @@ -1610,7 +1606,7 @@ virtio_recv_mergeable_pkts_packed(void *rx_queue, rxm->pkt_len = (uint32_t)(len[i] - hdr_size); rxm->data_len = (uint16_t)(len[i] - hdr_size); - rxm->port = rxvq->port_id; + rxm->port = hw->port_id; rx_pkts[nb_rx] = rxm; prev = rxm; @@ -1699,8 +1695,7 @@ virtio_recv_mergeable_pkts_packed(void *rx_queue, } nb_enqueued += free_cnt; } else { - struct rte_eth_dev *dev = - &rte_eth_devices[rxvq->port_id]; + struct rte_eth_dev *dev = &rte_eth_devices[hw->port_id]; dev->data->rx_mbuf_alloc_failed += free_cnt; } } diff --git a/drivers/net/virtio/virtio_rxtx.h b/drivers/net/virtio/virtio_rxtx.h index 226c722d64..97de9eb0a3 100644 --- a/drivers/net/virtio/virtio_rxtx.h +++ b/drivers/net/virtio/virtio_rxtx.h @@ -24,7 +24,6 @@ struct virtnet_rx { struct rte_mempool *mpool; /**< mempool for mbuf allocation */ uint16_t queue_id; /**< DPDK queue index. */ - uint16_t port_id; /**< Device port identifier. */ /* Statistics */ struct virtnet_stats stats; diff --git a/drivers/net/virtio/virtio_rxtx_packed.c b/drivers/net/virtio/virtio_rxtx_packed.c index 45cf39df22..5f7d4903bc 100644 --- a/drivers/net/virtio/virtio_rxtx_packed.c +++ b/drivers/net/virtio/virtio_rxtx_packed.c @@ -124,8 +124,7 @@ virtio_recv_pkts_packed_vec(void *rx_queue, free_cnt); nb_enqueued += free_cnt; } else { - struct rte_eth_dev *dev = - &rte_eth_devices[rxvq->port_id]; + struct rte_eth_dev *dev = &rte_eth_devices[hw->port_id]; dev->data->rx_mbuf_alloc_failed += free_cnt; } } diff --git a/drivers/net/virtio/virtio_rxtx_simple.c b/drivers/net/virtio/virtio_rxtx_simple.c index f248869a8f..438256970d 100644 --- a/drivers/net/virtio/virtio_rxtx_simple.c +++ b/drivers/net/virtio/virtio_rxtx_simple.c @@ -30,12 +30,13 @@ int __rte_cold virtio_rxq_vec_setup(struct virtnet_rx *rxq) { + struct virtqueue *vq = virtnet_rxq_to_vq(rxq); uintptr_t p; struct rte_mbuf mb_def = { .buf_addr = 0 }; /* zeroed mbuf */ mb_def.nb_segs = 1; mb_def.data_off = RTE_PKTMBUF_HEADROOM; - mb_def.port = rxq->port_id; + mb_def.port = vq->hw->port_id; rte_mbuf_refcnt_set(&mb_def, 1); /* prevent compiler reordering: rearm_data covers previous fields */ diff --git a/drivers/net/virtio/virtio_rxtx_simple.h b/drivers/net/virtio/virtio_rxtx_simple.h index d8f96e0434..8e235f4dbc 100644 --- a/drivers/net/virtio/virtio_rxtx_simple.h +++ b/drivers/net/virtio/virtio_rxtx_simple.h @@ -32,8 +32,9 @@ virtio_rxq_rearm_vec(struct virtnet_rx *rxvq) ret = rte_mempool_get_bulk(rxvq->mpool, (void **)sw_ring, RTE_VIRTIO_VPMD_RX_REARM_THRESH); if (unlikely(ret)) { - rte_eth_devices[rxvq->port_id].data->rx_mbuf_alloc_failed += - RTE_VIRTIO_VPMD_RX_REARM_THRESH; + struct rte_eth_dev *dev = &rte_eth_devices[vq->hw->port_id]; + + dev->data->rx_mbuf_alloc_failed += RTE_VIRTIO_VPMD_RX_REARM_THRESH; return; } -- 2.38.1