From: Ronak Doshi <doshir@vmware.com>
To: Jochen Behrens <jbehrens@vmware.com>
Cc: <dev@dpdk.org>, Ronak Doshi <doshir@vmware.com>
Subject: [PATCH next 4/7] vmxnet3: add command to set ring buffer sizes
Date: Wed, 12 Apr 2023 09:26:33 -0700 [thread overview]
Message-ID: <20230412162636.30843-5-doshir@vmware.com> (raw)
In-Reply-To: <20230412162636.30843-1-doshir@vmware.com>
This patch adds a new command to set ring buffer sizes. This is
required to pass the buffer size information to passthrough devices.
Also, ring sizes are round down to power of 2.
Signed-off-by: Ronak Doshi <doshir@vmware.com>
Acked-by: Jochen Behrens <jbehrens@vmware.com>
---
drivers/net/vmxnet3/base/vmxnet3_defs.h | 15 +++++++++++++++
drivers/net/vmxnet3/vmxnet3_ethdev.c | 18 ++++++++++++++++++
drivers/net/vmxnet3/vmxnet3_ethdev.h | 1 +
drivers/net/vmxnet3/vmxnet3_rxtx.c | 7 +++++++
4 files changed, 41 insertions(+)
diff --git a/drivers/net/vmxnet3/base/vmxnet3_defs.h b/drivers/net/vmxnet3/base/vmxnet3_defs.h
index 27f35a0062..d8cc295b08 100644
--- a/drivers/net/vmxnet3/base/vmxnet3_defs.h
+++ b/drivers/net/vmxnet3/base/vmxnet3_defs.h
@@ -105,6 +105,9 @@ typedef enum {
VMXNET3_CMD_RESERVED4,
VMXNET3_CMD_REGISTER_MEMREGS,
VMXNET3_CMD_SET_RSS_FIELDS,
+ VMXNET3_CMD_RESERVED9,
+ VMXNET3_CMD_RESERVED10,
+ VMXNET3_CMD_SET_RING_BUFFER_SIZE,
VMXNET3_CMD_FIRST_GET = 0xF00D0000,
VMXNET3_CMD_GET_QUEUE_STATUS = VMXNET3_CMD_FIRST_GET,
@@ -822,6 +825,17 @@ typedef enum Vmxnet3_RSSField {
VMXNET3_RSS_FIELDS_ESPIP6 = 0x0020,
} Vmxnet3_RSSField;
+typedef
+#include "vmware_pack_begin.h"
+struct Vmxnet3_RingBufferSize {
+ __le16 ring1BufSizeType0;
+ __le16 ring1BufSizeType1;
+ __le16 ring2BufSizeType1;
+ __le16 pad;
+}
+#include "vmware_pack_end.h"
+Vmxnet3_RingBufferSize;
+
/*
* If the command data <= 16 bytes, use the shared memory direcly.
* Otherwise, use the variable length configuration descriptor.
@@ -832,6 +846,7 @@ union Vmxnet3_CmdInfo {
Vmxnet3_VariableLenConfDesc varConf;
Vmxnet3_SetPolling setPolling;
Vmxnet3_RSSField setRSSFields;
+ Vmxnet3_RingBufferSize ringBufSize;
__le16 reserved[2];
__le64 data[2];
}
diff --git a/drivers/net/vmxnet3/vmxnet3_ethdev.c b/drivers/net/vmxnet3/vmxnet3_ethdev.c
index a04a16a3e0..72ccd0f7fc 100644
--- a/drivers/net/vmxnet3/vmxnet3_ethdev.c
+++ b/drivers/net/vmxnet3/vmxnet3_ethdev.c
@@ -1018,6 +1018,22 @@ vmxnet3_setup_driver_shared(struct rte_eth_dev *dev)
return VMXNET3_SUCCESS;
}
+static void
+vmxnet3_init_bufsize(struct vmxnet3_hw *hw)
+{
+ struct Vmxnet3_DriverShared *shared = hw->shared;
+ union Vmxnet3_CmdInfo *cmd_info = &shared->cu.cmdInfo;
+
+ if (!VMXNET3_VERSION_GE_7(hw))
+ return;
+
+ cmd_info->ringBufSize.ring1BufSizeType0 = hw->rxdata_buf_size;
+ cmd_info->ringBufSize.ring1BufSizeType1 = 0;
+ cmd_info->ringBufSize.ring2BufSizeType1 = hw->rxdata_buf_size;
+ VMXNET3_WRITE_BAR1_REG(hw, VMXNET3_REG_CMD,
+ VMXNET3_CMD_SET_RING_BUFFER_SIZE);
+}
+
/*
* Configure device link speed and setup link.
* Must be called after eth_vmxnet3_dev_init. Other wise it might fail
@@ -1101,6 +1117,8 @@ vmxnet3_dev_start(struct rte_eth_dev *dev)
return ret;
}
+ vmxnet3_init_bufsize(hw);
+
hw->adapter_stopped = FALSE;
/* Setting proper Rx Mode and issue Rx Mode Update command */
diff --git a/drivers/net/vmxnet3/vmxnet3_ethdev.h b/drivers/net/vmxnet3/vmxnet3_ethdev.h
index cabd83e7e1..2b3e2c4caa 100644
--- a/drivers/net/vmxnet3/vmxnet3_ethdev.h
+++ b/drivers/net/vmxnet3/vmxnet3_ethdev.h
@@ -96,6 +96,7 @@ struct vmxnet3_hw {
uint16_t txdata_desc_size; /* tx data ring buffer size */
uint16_t rxdata_desc_size; /* rx data ring buffer size */
+ uint16_t rxdata_buf_size; /* rx data buffer size */
uint8_t num_intrs;
diff --git a/drivers/net/vmxnet3/vmxnet3_rxtx.c b/drivers/net/vmxnet3/vmxnet3_rxtx.c
index 83daac02c4..e31878ecab 100644
--- a/drivers/net/vmxnet3/vmxnet3_rxtx.c
+++ b/drivers/net/vmxnet3/vmxnet3_rxtx.c
@@ -1113,6 +1113,8 @@ vmxnet3_dev_tx_queue_setup(struct rte_eth_dev *dev,
return -EINVAL;
} else {
ring->size = nb_desc;
+ if (VMXNET3_VERSION_GE_7(hw))
+ ring->size = rte_align32prevpow2(nb_desc);
ring->size &= ~VMXNET3_RING_SIZE_MASK;
}
comp_ring->size = data_ring->size = ring->size;
@@ -1193,6 +1195,9 @@ vmxnet3_dev_rx_queue_setup(struct rte_eth_dev *dev,
}
rxq->mp = mp;
+ /* Remember buffer size for initialization in dev start. */
+ hw->rxdata_buf_size =
+ rte_pktmbuf_data_room_size(mp) - RTE_PKTMBUF_HEADROOM;
rxq->queue_id = queue_idx;
rxq->port_id = dev->data->port_id;
rxq->shared = NULL; /* set in vmxnet3_setup_driver_shared() */
@@ -1217,6 +1222,8 @@ vmxnet3_dev_rx_queue_setup(struct rte_eth_dev *dev,
return -EINVAL;
} else {
ring0->size = nb_desc;
+ if (VMXNET3_VERSION_GE_7(hw))
+ ring0->size = rte_align32prevpow2(nb_desc);
ring0->size &= ~VMXNET3_RING_SIZE_MASK;
ring1->size = ring0->size;
}
--
2.11.0
next prev parent reply other threads:[~2023-04-17 8:15 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-12 16:26 [PATCH next 0/7] vmxnet3: upgrade to version 7 Ronak Doshi
2023-04-12 16:26 ` [PATCH next 1/7] vmxnet3: prepare for version 7 changes Ronak Doshi
2023-04-26 16:58 ` Ferruh Yigit
2023-04-12 16:26 ` [PATCH next 2/7] vmxnet3: add support for capability registers Ronak Doshi
2023-04-26 16:55 ` Ferruh Yigit
2023-04-12 16:26 ` [PATCH next 3/7] vmxnet3: add support for large passthrough BAR register Ronak Doshi
2023-04-12 16:26 ` Ronak Doshi [this message]
2023-04-26 16:58 ` [PATCH next 4/7] vmxnet3: add command to set ring buffer sizes Ferruh Yigit
2023-04-26 17:27 ` Ronak Doshi
2023-04-27 8:50 ` Ferruh Yigit
2023-04-27 15:59 ` Ronak Doshi
2023-05-03 10:03 ` Ferruh Yigit
2023-04-12 16:26 ` [PATCH next 5/7] vmxnet3: limit number of TXDs used for TSO packet Ronak Doshi
2023-04-12 16:26 ` [PATCH next 6/7] vmxnet3: avoid updating rxprod register frequently Ronak Doshi
2023-04-12 16:26 ` [PATCH next 7/7] vmxnet3: update to version 7 Ronak Doshi
2023-04-26 16:54 ` [PATCH next 0/7] vmxnet3: upgrade " Ferruh Yigit
2023-04-26 18:15 ` Ferruh Yigit
2023-04-26 18:33 ` Ronak Doshi
2023-04-27 9:15 ` Ferruh Yigit
2023-04-28 7:05 ` Ronak Doshi
2023-05-03 10:05 ` Ferruh Yigit
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230412162636.30843-5-doshir@vmware.com \
--to=doshir@vmware.com \
--cc=dev@dpdk.org \
--cc=jbehrens@vmware.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).