* [PATCH] net/mlx5: change calculating inline room for Tx
@ 2017-04-13 17:46 Yongseok Koh
2017-04-14 6:51 ` Nélio Laranjeiro
2017-04-18 6:43 ` Nélio Laranjeiro
0 siblings, 2 replies; 5+ messages in thread
From: Yongseok Koh @ 2017-04-13 17:46 UTC (permalink / raw)
To: ferruh.yigit; +Cc: dev, adrien.mazarguil, nelio.laranjeiro, Yongseok Koh
Current implementation is error-prone if the max inline size
(txq->max_inilne) is decoupled from txq->inline_en and becomes zero. If it
becomes zero, HW can crash due to WQ overflow.
Signed-off-by: Yongseok Koh <yskoh@mellanox.com>
Acked-by: Shahaf Shuler <shahafs@mellanox.com>
---
drivers/net/mlx5/mlx5_rxtx.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/drivers/net/mlx5/mlx5_rxtx.c b/drivers/net/mlx5/mlx5_rxtx.c
index 2e208bf96..6254228a9 100644
--- a/drivers/net/mlx5/mlx5_rxtx.c
+++ b/drivers/net/mlx5/mlx5_rxtx.c
@@ -499,6 +499,8 @@ mlx5_tx_burst(void *dpdk_txq, struct rte_mbuf **pkts, uint16_t pkts_n)
unsigned int j = 0;
unsigned int k = 0;
unsigned int max;
+ unsigned int max_inline = txq->max_inline;
+ const unsigned int inline_en = !!max_inline && txq->inline_en;
uint16_t max_wqe;
unsigned int comp;
volatile struct mlx5_wqe_v *wqe = NULL;
@@ -685,14 +687,14 @@ mlx5_tx_burst(void *dpdk_txq, struct rte_mbuf **pkts, uint16_t pkts_n)
}
}
/* Inline if enough room. */
- if (txq->inline_en || tso) {
+ if (inline_en || tso) {
uintptr_t end = (uintptr_t)
(((uintptr_t)txq->wqes) +
(1 << txq->wqe_n) * MLX5_WQE_SIZE);
- unsigned int max_inline = txq->max_inline *
- RTE_CACHE_LINE_SIZE -
- (pkt_inline_sz - 2);
- uintptr_t addr_end = (addr + max_inline) &
+ unsigned int inline_room = max_inline *
+ RTE_CACHE_LINE_SIZE -
+ (pkt_inline_sz - 2);
+ uintptr_t addr_end = (addr + inline_room) &
~(RTE_CACHE_LINE_SIZE - 1);
unsigned int copy_b = (addr_end > addr) ?
RTE_MIN((addr_end - addr), length) :
--
2.11.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] net/mlx5: change calculating inline room for Tx
2017-04-13 17:46 [PATCH] net/mlx5: change calculating inline room for Tx Yongseok Koh
@ 2017-04-14 6:51 ` Nélio Laranjeiro
2017-04-14 16:52 ` Yongseok Koh
2017-04-18 6:43 ` Nélio Laranjeiro
1 sibling, 1 reply; 5+ messages in thread
From: Nélio Laranjeiro @ 2017-04-14 6:51 UTC (permalink / raw)
To: Yongseok Koh; +Cc: ferruh.yigit, dev, adrien.mazarguil
Hi Yongseok,
On Thu, Apr 13, 2017 at 10:46:51AM -0700, Yongseok Koh wrote:
> Current implementation is error-prone if the max inline size
> (txq->max_inilne) is decoupled from txq->inline_en and becomes zero. If it
> becomes zero, HW can crash due to WQ overflow.
By reading this log, it seems more to be a fix, no?
> Signed-off-by: Yongseok Koh <yskoh@mellanox.com>
> Acked-by: Shahaf Shuler <shahafs@mellanox.com>
> ---
> drivers/net/mlx5/mlx5_rxtx.c | 12 +++++++-----
> 1 file changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/net/mlx5/mlx5_rxtx.c b/drivers/net/mlx5/mlx5_rxtx.c
> index 2e208bf96..6254228a9 100644
> --- a/drivers/net/mlx5/mlx5_rxtx.c
> +++ b/drivers/net/mlx5/mlx5_rxtx.c
> @@ -499,6 +499,8 @@ mlx5_tx_burst(void *dpdk_txq, struct rte_mbuf **pkts, uint16_t pkts_n)
> unsigned int j = 0;
> unsigned int k = 0;
> unsigned int max;
> + unsigned int max_inline = txq->max_inline;
Cannot it be declared as const too? Seems it is only read in the whole
Tx burst function, as it a chance to be update in the middle?
> + const unsigned int inline_en = !!max_inline && txq->inline_en;
> uint16_t max_wqe;
> unsigned int comp;
> volatile struct mlx5_wqe_v *wqe = NULL;
> @@ -685,14 +687,14 @@ mlx5_tx_burst(void *dpdk_txq, struct rte_mbuf **pkts, uint16_t pkts_n)
> }
> }
> /* Inline if enough room. */
> - if (txq->inline_en || tso) {
> + if (inline_en || tso) {
> uintptr_t end = (uintptr_t)
> (((uintptr_t)txq->wqes) +
> (1 << txq->wqe_n) * MLX5_WQE_SIZE);
> - unsigned int max_inline = txq->max_inline *
> - RTE_CACHE_LINE_SIZE -
> - (pkt_inline_sz - 2);
> - uintptr_t addr_end = (addr + max_inline) &
> + unsigned int inline_room = max_inline *
> + RTE_CACHE_LINE_SIZE -
> + (pkt_inline_sz - 2);
> + uintptr_t addr_end = (addr + inline_room) &
> ~(RTE_CACHE_LINE_SIZE - 1);
> unsigned int copy_b = (addr_end > addr) ?
> RTE_MIN((addr_end - addr), length) :
> --
> 2.11.0
Thanks,
--
Nélio Laranjeiro
6WIND
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] net/mlx5: change calculating inline room for Tx
2017-04-14 6:51 ` Nélio Laranjeiro
@ 2017-04-14 16:52 ` Yongseok Koh
0 siblings, 0 replies; 5+ messages in thread
From: Yongseok Koh @ 2017-04-14 16:52 UTC (permalink / raw)
To: Nélio Laranjeiro; +Cc: ferruh.yigit, dev, adrien.mazarguil
On Fri, Apr 14, 2017 at 08:51:39AM +0200, Nélio Laranjeiro wrote:
> Hi Yongseok,
>
> On Thu, Apr 13, 2017 at 10:46:51AM -0700, Yongseok Koh wrote:
> > Current implementation is error-prone if the max inline size
> > (txq->max_inilne) is decoupled from txq->inline_en and becomes zero. If it
> > becomes zero, HW can crash due to WQ overflow.
>
> By reading this log, it seems more to be a fix, no?
It doesn't fix any existing bug in the code but to protect from potential
disaster by adding new features in the future. Also, there's a customer who
wants to change txq->max_inilne in runtime.
>
> > Signed-off-by: Yongseok Koh <yskoh@mellanox.com>
> > Acked-by: Shahaf Shuler <shahafs@mellanox.com>
> > ---
> > drivers/net/mlx5/mlx5_rxtx.c | 12 +++++++-----
> > 1 file changed, 7 insertions(+), 5 deletions(-)
> >
> > diff --git a/drivers/net/mlx5/mlx5_rxtx.c b/drivers/net/mlx5/mlx5_rxtx.c
> > index 2e208bf96..6254228a9 100644
> > --- a/drivers/net/mlx5/mlx5_rxtx.c
> > +++ b/drivers/net/mlx5/mlx5_rxtx.c
> > @@ -499,6 +499,8 @@ mlx5_tx_burst(void *dpdk_txq, struct rte_mbuf **pkts, uint16_t pkts_n)
> > unsigned int j = 0;
> > unsigned int k = 0;
> > unsigned int max;
> > + unsigned int max_inline = txq->max_inline;
>
> Cannot it be declared as const too? Seems it is only read in the whole
> Tx burst function, as it a chance to be update in the middle?
This is used just for calculation not for conditional expression. So, I didn't
think this makes difference.
Thanks
Yongseok
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] net/mlx5: change calculating inline room for Tx
2017-04-13 17:46 [PATCH] net/mlx5: change calculating inline room for Tx Yongseok Koh
2017-04-14 6:51 ` Nélio Laranjeiro
@ 2017-04-18 6:43 ` Nélio Laranjeiro
2017-04-18 9:35 ` Ferruh Yigit
1 sibling, 1 reply; 5+ messages in thread
From: Nélio Laranjeiro @ 2017-04-18 6:43 UTC (permalink / raw)
To: Yongseok Koh; +Cc: ferruh.yigit, dev, adrien.mazarguil
On Thu, Apr 13, 2017 at 10:46:51AM -0700, Yongseok Koh wrote:
> Current implementation is error-prone if the max inline size
> (txq->max_inilne) is decoupled from txq->inline_en and becomes zero. If it
> becomes zero, HW can crash due to WQ overflow.
>
> Signed-off-by: Yongseok Koh <yskoh@mellanox.com>
> Acked-by: Shahaf Shuler <shahafs@mellanox.com>
> ---
> drivers/net/mlx5/mlx5_rxtx.c | 12 +++++++-----
> 1 file changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/net/mlx5/mlx5_rxtx.c b/drivers/net/mlx5/mlx5_rxtx.c
> index 2e208bf96..6254228a9 100644
> --- a/drivers/net/mlx5/mlx5_rxtx.c
> +++ b/drivers/net/mlx5/mlx5_rxtx.c
> @@ -499,6 +499,8 @@ mlx5_tx_burst(void *dpdk_txq, struct rte_mbuf **pkts, uint16_t pkts_n)
> unsigned int j = 0;
> unsigned int k = 0;
> unsigned int max;
> + unsigned int max_inline = txq->max_inline;
> + const unsigned int inline_en = !!max_inline && txq->inline_en;
> uint16_t max_wqe;
> unsigned int comp;
> volatile struct mlx5_wqe_v *wqe = NULL;
> @@ -685,14 +687,14 @@ mlx5_tx_burst(void *dpdk_txq, struct rte_mbuf **pkts, uint16_t pkts_n)
> }
> }
> /* Inline if enough room. */
> - if (txq->inline_en || tso) {
> + if (inline_en || tso) {
> uintptr_t end = (uintptr_t)
> (((uintptr_t)txq->wqes) +
> (1 << txq->wqe_n) * MLX5_WQE_SIZE);
> - unsigned int max_inline = txq->max_inline *
> - RTE_CACHE_LINE_SIZE -
> - (pkt_inline_sz - 2);
> - uintptr_t addr_end = (addr + max_inline) &
> + unsigned int inline_room = max_inline *
> + RTE_CACHE_LINE_SIZE -
> + (pkt_inline_sz - 2);
> + uintptr_t addr_end = (addr + inline_room) &
> ~(RTE_CACHE_LINE_SIZE - 1);
> unsigned int copy_b = (addr_end > addr) ?
> RTE_MIN((addr_end - addr), length) :
> --
> 2.11.0
Acked-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
--
Nélio Laranjeiro
6WIND
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] net/mlx5: change calculating inline room for Tx
2017-04-18 6:43 ` Nélio Laranjeiro
@ 2017-04-18 9:35 ` Ferruh Yigit
0 siblings, 0 replies; 5+ messages in thread
From: Ferruh Yigit @ 2017-04-18 9:35 UTC (permalink / raw)
To: Nélio Laranjeiro, Yongseok Koh; +Cc: dev, adrien.mazarguil
On 4/18/2017 7:43 AM, Nélio Laranjeiro wrote:
> On Thu, Apr 13, 2017 at 10:46:51AM -0700, Yongseok Koh wrote:
>> Current implementation is error-prone if the max inline size
>> (txq->max_inilne) is decoupled from txq->inline_en and becomes zero. If it
>> becomes zero, HW can crash due to WQ overflow.
>>
>> Signed-off-by: Yongseok Koh <yskoh@mellanox.com>
>> Acked-by: Shahaf Shuler <shahafs@mellanox.com>
> Acked-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
Applied to dpdk-next-net/master, thanks.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-04-18 9:35 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-13 17:46 [PATCH] net/mlx5: change calculating inline room for Tx Yongseok Koh
2017-04-14 6:51 ` Nélio Laranjeiro
2017-04-14 16:52 ` Yongseok Koh
2017-04-18 6:43 ` Nélio Laranjeiro
2017-04-18 9:35 ` Ferruh Yigit
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.