[v4,1/3] net/mlx5: add a devarg to specify MPRQ stride size
Checks
Commit Message
Define a device parameter to configure log 2 of a stride size for MPRQ
- mprq_log_stride_size. User is able to specify a stride size in a range
allowed by an underlying hardware. The default stride size is defined as
2048 bytes to encompass most commonly used packet sizes in the Internet
(MTU 1518 and less) and will be used in case a maximum configured packet
size cannot fit into the largest possible stride size. Otherwise a
stride size is set to a large enough value to encompass a whole packet.
Cc: stable@dpdk.org
Signed-off-by: Alexander Kozyrev <akozyrev@mellanox.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@mellanox.com>
---
doc/guides/nics/mlx5.rst | 17 +++++++++--
doc/guides/rel_notes/release_20_05.rst | 1 +
drivers/net/mlx5/mlx5.c | 34 +++++++++++++++++-----
drivers/net/mlx5/mlx5.h | 1 +
drivers/net/mlx5/mlx5_defs.h | 3 ++
drivers/net/mlx5/mlx5_rxq.c | 52 +++++++++++++++++++++++++---------
6 files changed, 85 insertions(+), 23 deletions(-)
Comments
On 4/9/2020 11:23 PM, Alexander Kozyrev wrote:
> Define a device parameter to configure log 2 of a stride size for MPRQ
> - mprq_log_stride_size. User is able to specify a stride size in a range
> allowed by an underlying hardware. The default stride size is defined as
> 2048 bytes to encompass most commonly used packet sizes in the Internet
> (MTU 1518 and less) and will be used in case a maximum configured packet
> size cannot fit into the largest possible stride size. Otherwise a
> stride size is set to a large enough value to encompass a whole packet.
>
> Cc: stable@dpdk.org
Hi Alexander,
This is a new feature, and you are asking it for to be backported to the stable
trees.
There is no question on getting the fixes to the stable tree, but for
backporting features I would like to get the comment of the stable tree
maintainers first before merging the series.
Or if the stable tag added by mistake please let me know, I can remove them
while merging.
Thanks,
ferruh
>
> Signed-off-by: Alexander Kozyrev <akozyrev@mellanox.com>
> Acked-by: Viacheslav Ovsiienko <viacheslavo@mellanox.com>
<...>
14/04/2020 13:42, Ferruh Yigit:
> On 4/9/2020 11:23 PM, Alexander Kozyrev wrote:
> > Define a device parameter to configure log 2 of a stride size for MPRQ
> > - mprq_log_stride_size. User is able to specify a stride size in a range
> > allowed by an underlying hardware. The default stride size is defined as
> > 2048 bytes to encompass most commonly used packet sizes in the Internet
> > (MTU 1518 and less) and will be used in case a maximum configured packet
> > size cannot fit into the largest possible stride size. Otherwise a
> > stride size is set to a large enough value to encompass a whole packet.
> >
> > Cc: stable@dpdk.org
>
> Hi Alexander,
>
> This is a new feature, and you are asking it for to be backported to the stable
> trees.
>
> There is no question on getting the fixes to the stable tree, but for
> backporting features I would like to get the comment of the stable tree
> maintainers first before merging the series.
As far as I know, there is a fix hidden in this series,
for the case of jumbo frames.
In my understanding, jumbo frames cannot be fixed without a new option.
I agree it's tricky deciding what is the limit with backports.
On 4/14/2020 1:52 PM, Thomas Monjalon wrote:
> 14/04/2020 13:42, Ferruh Yigit:
>> On 4/9/2020 11:23 PM, Alexander Kozyrev wrote:
>>> Define a device parameter to configure log 2 of a stride size for MPRQ
>>> - mprq_log_stride_size. User is able to specify a stride size in a range
>>> allowed by an underlying hardware. The default stride size is defined as
>>> 2048 bytes to encompass most commonly used packet sizes in the Internet
>>> (MTU 1518 and less) and will be used in case a maximum configured packet
>>> size cannot fit into the largest possible stride size. Otherwise a
>>> stride size is set to a large enough value to encompass a whole packet.
>>>
>>> Cc: stable@dpdk.org
>>
>> Hi Alexander,
>>
>> This is a new feature, and you are asking it for to be backported to the stable
>> trees.
>>
>> There is no question on getting the fixes to the stable tree, but for
>> backporting features I would like to get the comment of the stable tree
>> maintainers first before merging the series.
>
> As far as I know, there is a fix hidden in this series,
> for the case of jumbo frames.
> In my understanding, jumbo frames cannot be fixed without a new option.
> I agree it's tricky deciding what is the limit with backports.
>
I missed the fix bit, so if there is no objection from stable tree maintainers I
will continue with the set keeping the stable tag.
On Wed, 2020-04-15 at 12:01 +0100, Ferruh Yigit wrote:
> On 4/14/2020 1:52 PM, Thomas Monjalon wrote:
> > 14/04/2020 13:42, Ferruh Yigit:
> > > On 4/9/2020 11:23 PM, Alexander Kozyrev wrote:
> > > > Define a device parameter to configure log 2 of a stride size for MPRQ
> > > > - mprq_log_stride_size. User is able to specify a stride size in a range
> > > > allowed by an underlying hardware. The default stride size is defined as
> > > > 2048 bytes to encompass most commonly used packet sizes in the Internet
> > > > (MTU 1518 and less) and will be used in case a maximum configured packet
> > > > size cannot fit into the largest possible stride size. Otherwise a
> > > > stride size is set to a large enough value to encompass a whole packet.
> > > >
> > > > Cc: stable@dpdk.org
> > >
> > > Hi Alexander,
> > >
> > > This is a new feature, and you are asking it for to be backported to the stable
> > > trees.
> > >
> > > There is no question on getting the fixes to the stable tree, but for
> > > backporting features I would like to get the comment of the stable tree
> > > maintainers first before merging the series.
> >
> > As far as I know, there is a fix hidden in this series,
> > for the case of jumbo frames.
> > In my understanding, jumbo frames cannot be fixed without a new option.
> > I agree it's tricky deciding what is the limit with backports.
> >
>
> I missed the fix bit, so if there is no objection from stable tree maintainers I
> will continue with the set keeping the stable tag.
Given it's confined to a single PMD it's fine by me, provided that:
1) Backward compatibility is maintained
2) Forward compatibility is maintained (eg: going 19.11.x to 20.02
should still work and not cause any errors)
On Wed, April 15, 2020 7:26 Luca Boccassi wrote:
> On Wed, 2020-04-15 at 12:01 +0100, Ferruh Yigit wrote:
> > On 4/14/2020 1:52 PM, Thomas Monjalon wrote:
> > > 14/04/2020 13:42, Ferruh Yigit:
> > > > On 4/9/2020 11:23 PM, Alexander Kozyrev wrote:
> > > > > Define a device parameter to configure log 2 of a stride size
> > > > > for MPRQ
> > > > > - mprq_log_stride_size. User is able to specify a stride size in
> > > > > a range allowed by an underlying hardware. The default stride
> > > > > size is defined as
> > > > > 2048 bytes to encompass most commonly used packet sizes in the
> > > > > Internet (MTU 1518 and less) and will be used in case a maximum
> > > > > configured packet size cannot fit into the largest possible
> > > > > stride size. Otherwise a stride size is set to a large enough value to
> encompass a whole packet.
> > > > >
> > > > > Cc: stable@dpdk.org
> > > >
> > > > Hi Alexander,
> > > >
> > > > This is a new feature, and you are asking it for to be backported
> > > > to the stable trees.
> > > >
> > > > There is no question on getting the fixes to the stable tree, but
> > > > for backporting features I would like to get the comment of the
> > > > stable tree maintainers first before merging the series.
> > >
> > > As far as I know, there is a fix hidden in this series, for the case
> > > of jumbo frames.
> > > In my understanding, jumbo frames cannot be fixed without a new option.
> > > I agree it's tricky deciding what is the limit with backports.
> > >
> >
> > I missed the fix bit, so if there is no objection from stable tree
> > maintainers I will continue with the set keeping the stable tag.
>
> Given it's confined to a single PMD it's fine by me, provided that:
>
> 1) Backward compatibility is maintained
> 2) Forward compatibility is maintained (eg: going 19.11.x to 20.02 should still
> work and not cause any errors)
The whole point of these patches are to fix the inability to handle 9K jumbo frames.
A new devarg is required in order not to break the backward compatibility.
So I do not expect any issues with backward/forward compatibility with these patches.
One thing I need to mention: backporting requires one small change.
Conversion from MLX5_ASSERT to assert clauses since we reworked them in 20.02.
I can provide a separate list of patches for 19.11 with this change if it works better for you.
Thank you for you assistance and let me know how we should proceed further.
On Wed, 2020-04-15 at 15:34 +0000, Alexander Kozyrev wrote:
> On Wed, April 15, 2020 7:26 Luca Boccassi wrote:
> > On Wed, 2020-04-15 at 12:01 +0100, Ferruh Yigit wrote:
> > > On 4/14/2020 1:52 PM, Thomas Monjalon wrote:
> > > > 14/04/2020 13:42, Ferruh Yigit:
> > > > > On 4/9/2020 11:23 PM, Alexander Kozyrev wrote:
> > > > > > Define a device parameter to configure log 2 of a stride size
> > > > > > for MPRQ
> > > > > > - mprq_log_stride_size. User is able to specify a stride size in
> > > > > > a range allowed by an underlying hardware. The default stride
> > > > > > size is defined as
> > > > > > 2048 bytes to encompass most commonly used packet sizes in the
> > > > > > Internet (MTU 1518 and less) and will be used in case a maximum
> > > > > > configured packet size cannot fit into the largest possible
> > > > > > stride size. Otherwise a stride size is set to a large enough value to
> > encompass a whole packet.
> > > > > > Cc: stable@dpdk.org
> > > > >
> > > > > Hi Alexander,
> > > > >
> > > > > This is a new feature, and you are asking it for to be backported
> > > > > to the stable trees.
> > > > >
> > > > > There is no question on getting the fixes to the stable tree, but
> > > > > for backporting features I would like to get the comment of the
> > > > > stable tree maintainers first before merging the series.
> > > >
> > > > As far as I know, there is a fix hidden in this series, for the case
> > > > of jumbo frames.
> > > > In my understanding, jumbo frames cannot be fixed without a new option.
> > > > I agree it's tricky deciding what is the limit with backports.
> > > >
> > >
> > > I missed the fix bit, so if there is no objection from stable tree
> > > maintainers I will continue with the set keeping the stable tag.
> >
> > Given it's confined to a single PMD it's fine by me, provided that:
> >
> > 1) Backward compatibility is maintained
> > 2) Forward compatibility is maintained (eg: going 19.11.x to 20.02 should still
> > work and not cause any errors)
>
> The whole point of these patches are to fix the inability to handle 9K jumbo frames.
> A new devarg is required in order not to break the backward compatibility.
> So I do not expect any issues with backward/forward compatibility with these patches.
> One thing I need to mention: backporting requires one small change.
> Conversion from MLX5_ASSERT to assert clauses since we reworked them in 20.02.
> I can provide a separate list of patches for 19.11 with this change if it works better for you.
> Thank you for you assistance and let me know how we should proceed further.
Ok, thanks. It's not necessary to send a series if the only change is
the assert, I can fix it myself when backporting.
@@ -408,8 +408,7 @@ Run-time configuration
A nonzero value enables configuring Multi-Packet Rx queues. Rx queue is
configured as Multi-Packet RQ if the total number of Rx queues is
- ``rxqs_min_mprq`` or more and Rx scatter isn't configured. Disabled by
- default.
+ ``rxqs_min_mprq`` or more. Disabled by default.
Multi-Packet Rx Queue (MPRQ a.k.a Striding RQ) can further save PCIe bandwidth
by posting a single large buffer for multiple packets. Instead of posting a
@@ -434,6 +433,20 @@ Run-time configuration
The size of Rx queue should be bigger than the number of strides.
+- ``mprq_log_stride_size`` parameter [int]
+
+ Log 2 of the size of a stride for Multi-Packet Rx queue. Configuring a smaller
+ stride size can save some memory and reduce probability of a depletion of all
+ available strides due to unreleased packets by an application. If configured
+ value is not in the range of device capability, the default value will be set
+ with a warning message. The default value is 11 which is 2048 bytes per a
+ stride, valid only if ``mprq_en`` is set. With ``mprq_log_stride_size`` set
+ it is possible for a pcaket to span across multiple strides. This mode allows
+ support of jumbo frames (9K) with MPRQ. The memcopy of some packets (or part
+ of a packet if Rx scatter is configured) may be required in case there is no
+ space left for a head room at the end of a stride which incurs some
+ performance penalty.
+
- ``mprq_max_memcpy_len`` parameter [int]
The maximum length of packet to memcpy in case of Multi-Packet Rx queue. Rx
@@ -62,6 +62,7 @@ New Features
* Added support for matching on IPv4 Time To Live and IPv6 Hop Limit.
* Added support for creating Relaxed Ordering Memory Regions.
+ * Added support for jumbo frame size (9K MTU) in Multi-Packet RQ mode.
* **Updated the Intel ice driver.**
@@ -63,6 +63,9 @@
/* Device parameter to configure log 2 of the number of strides for MPRQ. */
#define MLX5_RX_MPRQ_LOG_STRIDE_NUM "mprq_log_stride_num"
+/* Device parameter to configure log 2 of the stride size for MPRQ. */
+#define MLX5_RX_MPRQ_LOG_STRIDE_SIZE "mprq_log_stride_size"
+
/* Device parameter to limit the size of memcpy'd packet for MPRQ. */
#define MLX5_RX_MPRQ_MAX_MEMCPY_LEN "mprq_max_memcpy_len"
@@ -1533,6 +1536,8 @@ struct mlx5_flow_id_pool *
config->mprq.enabled = !!tmp;
} else if (strcmp(MLX5_RX_MPRQ_LOG_STRIDE_NUM, key) == 0) {
config->mprq.stride_num_n = tmp;
+ } else if (strcmp(MLX5_RX_MPRQ_LOG_STRIDE_SIZE, key) == 0) {
+ config->mprq.stride_size_n = tmp;
} else if (strcmp(MLX5_RX_MPRQ_MAX_MEMCPY_LEN, key) == 0) {
config->mprq.max_memcpy_len = tmp;
} else if (strcmp(MLX5_RXQS_MIN_MPRQ, key) == 0) {
@@ -1629,6 +1634,7 @@ struct mlx5_flow_id_pool *
MLX5_RXQ_PKT_PAD_EN,
MLX5_RX_MPRQ_EN,
MLX5_RX_MPRQ_LOG_STRIDE_NUM,
+ MLX5_RX_MPRQ_LOG_STRIDE_SIZE,
MLX5_RX_MPRQ_MAX_MEMCPY_LEN,
MLX5_RXQS_MIN_MPRQ,
MLX5_TXQ_INLINE,
@@ -2304,8 +2310,6 @@ struct mlx5_flow_id_pool *
mprq_caps.min_single_wqe_log_num_of_strides;
mprq_max_stride_num_n =
mprq_caps.max_single_wqe_log_num_of_strides;
- config.mprq.stride_num_n = RTE_MAX(MLX5_MPRQ_STRIDE_NUM_N,
- mprq_min_stride_num_n);
}
#endif
if (RTE_CACHE_LINE_SIZE == 128 &&
@@ -2619,17 +2623,32 @@ struct mlx5_flow_id_pool *
#endif
}
if (config.mprq.enabled && mprq) {
- if (config.mprq.stride_num_n > mprq_max_stride_num_n ||
- config.mprq.stride_num_n < mprq_min_stride_num_n) {
+ if (config.mprq.stride_num_n &&
+ (config.mprq.stride_num_n > mprq_max_stride_num_n ||
+ config.mprq.stride_num_n < mprq_min_stride_num_n)) {
config.mprq.stride_num_n =
- RTE_MAX(MLX5_MPRQ_STRIDE_NUM_N,
- mprq_min_stride_num_n);
+ RTE_MIN(RTE_MAX(MLX5_MPRQ_STRIDE_NUM_N,
+ mprq_min_stride_num_n),
+ mprq_max_stride_num_n);
DRV_LOG(WARNING,
"the number of strides"
" for Multi-Packet RQ is out of range,"
" setting default value (%u)",
1 << config.mprq.stride_num_n);
}
+ if (config.mprq.stride_size_n &&
+ (config.mprq.stride_size_n > mprq_max_stride_size_n ||
+ config.mprq.stride_size_n < mprq_min_stride_size_n)) {
+ config.mprq.stride_size_n =
+ RTE_MIN(RTE_MAX(MLX5_MPRQ_STRIDE_SIZE_N,
+ mprq_min_stride_size_n),
+ mprq_max_stride_size_n);
+ DRV_LOG(WARNING,
+ "the size of a stride"
+ " for Multi-Packet RQ is out of range,"
+ " setting default value (%u)",
+ 1 << config.mprq.stride_size_n);
+ }
config.mprq.min_stride_size_n = mprq_min_stride_size_n;
config.mprq.max_stride_size_n = mprq_max_stride_size_n;
} else if (config.mprq.enabled && !mprq) {
@@ -3363,7 +3382,8 @@ struct mlx5_flow_id_pool *
.mr_ext_memseg_en = 1,
.mprq = {
.enabled = 0, /* Disabled by default. */
- .stride_num_n = MLX5_MPRQ_STRIDE_NUM_N,
+ .stride_num_n = 0,
+ .stride_size_n = 0,
.max_memcpy_len = MLX5_MPRQ_MEMCPY_DEFAULT_LEN,
.min_rxqs_num = MLX5_MPRQ_MIN_RXQS,
},
@@ -179,6 +179,7 @@ struct mlx5_dev_config {
struct {
unsigned int enabled:1; /* Whether MPRQ is enabled. */
unsigned int stride_num_n; /* Number of strides. */
+ unsigned int stride_size_n; /* Size of a stride. */
unsigned int min_stride_size_n; /* Min size of a stride. */
unsigned int max_stride_size_n; /* Max size of a stride. */
unsigned int max_memcpy_len;
@@ -143,6 +143,9 @@
/* Log 2 of the default number of strides per WQE for Multi-Packet RQ. */
#define MLX5_MPRQ_STRIDE_NUM_N 6U
+/* Log 2 of the default size of a stride per WQE for Multi-Packet RQ. */
+#define MLX5_MPRQ_STRIDE_SIZE_N 11U
+
/* Two-byte shift is disabled for Multi-Packet RQ. */
#define MLX5_MPRQ_TWO_BYTE_SHIFT 0
@@ -1793,7 +1793,9 @@ struct mlx5_rxq_ctrl *
struct mlx5_priv *priv = dev->data->dev_private;
struct mlx5_rxq_ctrl *tmpl;
unsigned int mb_len = rte_pktmbuf_data_room_size(mp);
+ unsigned int mprq_stride_nums;
unsigned int mprq_stride_size;
+ unsigned int mprq_stride_cap;
struct mlx5_dev_config *config = &priv->config;
unsigned int strd_headroom_en;
/*
@@ -1856,25 +1858,40 @@ struct mlx5_rxq_ctrl *
strd_headroom_en = 1;
mprq_stride_size = non_scatter_min_mbuf_size;
}
+ mprq_stride_nums = config->mprq.stride_num_n ?
+ config->mprq.stride_num_n : MLX5_MPRQ_STRIDE_NUM_N;
+ mprq_stride_size = (mprq_stride_size <=
+ (1U << config->mprq.max_stride_size_n)) ?
+ log2above(mprq_stride_size) : MLX5_MPRQ_STRIDE_SIZE_N;
+ mprq_stride_cap = (config->mprq.stride_num_n ?
+ (1U << config->mprq.stride_num_n) : (1U << mprq_stride_nums)) *
+ (config->mprq.stride_size_n ?
+ (1U << config->mprq.stride_size_n) : (1U << mprq_stride_size));
/*
* This Rx queue can be configured as a Multi-Packet RQ if all of the
* following conditions are met:
* - MPRQ is enabled.
* - The number of descs is more than the number of strides.
- * - max_rx_pkt_len plus overhead is less than the max size of a
- * stride.
+ * - max_rx_pkt_len plus overhead is less than the max size
+ * of a stride or mprq_stride_size is specified by a user.
+ * Need to nake sure that there are enough stides to encap
+ * the maximum packet size in case mprq_stride_size is set.
* Otherwise, enable Rx scatter if necessary.
*/
- if (mprq_en &&
- desc > (1U << config->mprq.stride_num_n) &&
- mprq_stride_size <= (1U << config->mprq.max_stride_size_n)) {
+ if (mprq_en && desc > (1U << mprq_stride_nums) &&
+ (non_scatter_min_mbuf_size -
+ (lro_on_queue ? RTE_PKTMBUF_HEADROOM : 0) <=
+ (1U << config->mprq.max_stride_size_n) ||
+ (config->mprq.stride_size_n &&
+ non_scatter_min_mbuf_size <= mprq_stride_cap))) {
/* TODO: Rx scatter isn't supported yet. */
tmpl->rxq.sges_n = 0;
/* Trim the number of descs needed. */
- desc >>= config->mprq.stride_num_n;
- tmpl->rxq.strd_num_n = config->mprq.stride_num_n;
- tmpl->rxq.strd_sz_n = RTE_MAX(log2above(mprq_stride_size),
- config->mprq.min_stride_size_n);
+ desc >>= mprq_stride_nums;
+ tmpl->rxq.strd_num_n = config->mprq.stride_num_n ?
+ config->mprq.stride_num_n : mprq_stride_nums;
+ tmpl->rxq.strd_sz_n = config->mprq.stride_size_n ?
+ config->mprq.stride_size_n : mprq_stride_size;
tmpl->rxq.strd_shift_en = MLX5_MPRQ_TWO_BYTE_SHIFT;
tmpl->rxq.strd_headroom_en = strd_headroom_en;
tmpl->rxq.mprq_max_memcpy_len = RTE_MIN(first_mb_free_size,
@@ -1923,11 +1940,18 @@ struct mlx5_rxq_ctrl *
if (mprq_en && !mlx5_rxq_mprq_enabled(&tmpl->rxq))
DRV_LOG(WARNING,
"port %u MPRQ is requested but cannot be enabled"
- " (requested: desc = %u, stride_sz = %u,"
- " supported: min_stride_num = %u, max_stride_sz = %u).",
- dev->data->port_id, desc, mprq_stride_size,
- (1 << config->mprq.stride_num_n),
- (1 << config->mprq.max_stride_size_n));
+ " (requested: packet size = %u, desc = %u,"
+ " stride_sz = %u, stride_num = %u,"
+ " supported: min_stride_sz = %u, max_stride_sz = %u).",
+ dev->data->port_id, non_scatter_min_mbuf_size, desc,
+ config->mprq.stride_size_n ?
+ (1U << config->mprq.stride_size_n) :
+ (1U << mprq_stride_size),
+ config->mprq.stride_num_n ?
+ (1U << config->mprq.stride_num_n) :
+ (1U << mprq_stride_nums),
+ (1U << config->mprq.min_stride_size_n),
+ (1U << config->mprq.max_stride_size_n));
DRV_LOG(DEBUG, "port %u maximum number of segments per packet: %u",
dev->data->port_id, 1 << tmpl->rxq.sges_n);
if (desc % (1 << tmpl->rxq.sges_n)) {