[next,4/7] vmxnet3: add command to set ring buffer sizes
Checks
Commit Message
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(+)
Comments
On 4/12/2023 5:26 PM, Ronak Doshi wrote:
> 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;
> +
As far as I can see these "vmware_pack_begin.h" & "vmware_pack_end.h"
has only file license comment, and I can see this is used in a few other
type declaration.
What is the reasoning behind using these headers?
On 4/26/23, 9:58 AM, "Ferruh Yigit" <ferruh.yigit@amd.com <mailto:ferruh.yigit@amd.com>> wrote:
> As far as I can see these "vmware_pack_begin.h" & "vmware_pack_end.h"
> has only file license comment, and I can see this is used in a few other
> type declaration.
>
> What is the reasoning behind using these headers?
This has been the case since driver was added to dpdk. The information is present in README.
I did not want to change the format being used for the declarations in the driver.
Thanks,
Ronak
On 4/26/2023 6:27 PM, Ronak Doshi wrote:
>
>
> On 4/26/23, 9:58 AM, "Ferruh Yigit" <ferruh.yigit@amd.com <mailto:ferruh.yigit@amd.com>> wrote:
>
>> As far as I can see these "vmware_pack_begin.h" & "vmware_pack_end.h"
>> has only file license comment, and I can see this is used in a few other
>> type declaration.
>>
>> What is the reasoning behind using these headers?
>
> This has been the case since driver was added to dpdk. The information is present in README.
> I did not want to change the format being used for the declarations in the driver.
>
README doesn't say much.
The usage is not standard, and intention is not clear.
Can you please dig this issue more to learn the the intention, may be we
can find a better way or get rid of them completely?
Just to record, usage is:
typedef
#include "vmware_pack_begin.h"
struct Vmxnet3_RingBufferSize {
__le16 ring1BufSizeType0;
__le16 ring1BufSizeType1;
__le16 ring2BufSizeType1;
__le16 pad;
}
#include "vmware_pack_end.h"
Vmxnet3_RingBufferSize;
Content of "vmware_pack_begin.h":
```
/* SPDX-License-Identifier: BSD-3-Clause
* Copyright(c) 2010-2014 Intel Corporation
*/
```
"vmware_pack_end.h":
```
/* SPDX-License-Identifier: BSD-3-Clause
* Copyright(c) 2010-2014 Intel Corporation
*/
```
> On 4/27/23, 1:51 AM, "Ferruh Yigit" <ferruh.yigit@amd.com <mailto:ferruh.yigit@amd.com>> wrote:
>
> README doesn't say much.
>
> The usage is not standard, and intention is not clear.
> Can you please dig this issue more to learn the the intention, may be we
> can find a better way or get rid of them completely?
Sure, I can take this up, but it will be better if that is investigated and done as a separate patch
as lot of definitions include those header files. The intention of this patch series is completely different,
and I don't want to break or delay this patch series. Is that OK?
Thanks,
Ronak
On 4/27/2023 4:59 PM, Ronak Doshi wrote:
>
> > On 4/27/23, 1:51 AM, "Ferruh Yigit" <ferruh.yigit@amd.com <mailto:ferruh.yigit@amd.com>> wrote:
>>
>> README doesn't say much.
>>
>> The usage is not standard, and intention is not clear.
>> Can you please dig this issue more to learn the the intention, may be we
>> can find a better way or get rid of them completely?
>
> Sure, I can take this up, but it will be better if that is investigated and done as a separate patch
> as lot of definitions include those header files. The intention of this patch series is completely different,
> and I don't want to break or delay this patch series. Is that OK?
>
OK to address it as a separate patch, but please follow the issue.
@@ -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];
}
@@ -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 */
@@ -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;
@@ -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;
}