* Re: [PATCH mlx5-next 11/15] RDMA/mlx5: Add vport metadata matching for IB representors
From: Leon Romanovsky @ 2019-06-19 8:12 UTC (permalink / raw)
To: Mark Bloch
Cc: Jianbo Liu, Saeed Mahameed, netdev@vger.kernel.org,
linux-rdma@vger.kernel.org, Roi Dayan
In-Reply-To: <ac23c3ea-3ea7-2a5b-5fc6-aece0aed0b54@mellanox.com>
On Wed, Jun 19, 2019 at 07:58:51AM +0000, Mark Bloch wrote:
>
>
> On 6/19/2019 00:43, Leon Romanovsky wrote:
> > On Wed, Jun 19, 2019 at 07:26:54AM +0000, Mark Bloch wrote:
> >>
> >>
> >> On 6/18/2019 23:51, Leon Romanovsky wrote:
> >>> On Wed, Jun 19, 2019 at 06:40:16AM +0000, Jianbo Liu wrote:
> >>>> The 06/19/2019 13:04, Leon Romanovsky wrote:
> >>>>> On Wed, Jun 19, 2019 at 04:44:26AM +0000, Jianbo Liu wrote:
> >>>>>> The 06/18/2019 18:19, Leon Romanovsky wrote:
> >>>>>>> On Mon, Jun 17, 2019 at 07:23:30PM +0000, Saeed Mahameed wrote:
> >>>>>>>> From: Jianbo Liu <jianbol@mellanox.com>
> >>>>>>>>
> >>>>>>>> If vport metadata matching is enabled in eswitch, the rule created
> >>>>>>>> must be changed to match on the metadata, instead of source port.
> >>>>>>>>
> >>>>>>>> Signed-off-by: Jianbo Liu <jianbol@mellanox.com>
> >>>>>>>> Reviewed-by: Roi Dayan <roid@mellanox.com>
> >>>>>>>> Reviewed-by: Mark Bloch <markb@mellanox.com>
> >>>>>>>> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
> >>>>>>>> ---
> >>>>>>>> drivers/infiniband/hw/mlx5/ib_rep.c | 11 +++++++
> >>>>>>>> drivers/infiniband/hw/mlx5/ib_rep.h | 16 ++++++++++
> >>>>>>>> drivers/infiniband/hw/mlx5/main.c | 45 +++++++++++++++++++++++------
> >>>>>>>> 3 files changed, 63 insertions(+), 9 deletions(-)
> >>>>>>>>
> >>>>>>>> diff --git a/drivers/infiniband/hw/mlx5/ib_rep.c b/drivers/infiniband/hw/mlx5/ib_rep.c
> >>>>>>>> index 22e651cb5534..d4ed611de35d 100644
> >>>>>>>> --- a/drivers/infiniband/hw/mlx5/ib_rep.c
> >>>>>>>> +++ b/drivers/infiniband/hw/mlx5/ib_rep.c
> >>>>>>>> @@ -131,6 +131,17 @@ struct mlx5_eswitch_rep *mlx5_ib_vport_rep(struct mlx5_eswitch *esw, int vport)
> >>>>>>>> return mlx5_eswitch_vport_rep(esw, vport);
> >>>>>>>> }
> >>>>>>>>
> >>>>>>>> +u32 mlx5_ib_eswitch_vport_match_metadata_enabled(struct mlx5_eswitch *esw)
> >>>>>>>> +{
> >>>>>>>> + return mlx5_eswitch_vport_match_metadata_enabled(esw);
> >>>>>>>> +}
> >>>>>>>> +
> >>>>>>>> +u32 mlx5_ib_eswitch_get_vport_metadata_for_match(struct mlx5_eswitch *esw,
> >>>>>>>> + u16 vport)
> >>>>>>>> +{
> >>>>>>>> + return mlx5_eswitch_get_vport_metadata_for_match(esw, vport);
> >>>>>>>> +}
> >>>>>>>
> >>>>>>> 1. There is no need to introduce one line functions, call to that code directly.
> >>>>>>
> >>>>>> No. They are in IB, and we don't want them be mixed up by the original
> >>>>>> functions in eswitch. Please ask Mark more about it.
> >>>>>
> >>>>> Please enlighten me.
> >>>>
> >>>> It was suggested by Mark in prevouis review.
> >>>> I think it's because there are in different modules, and better to with
> >>>> different names, so introduce there extra one line functions.
> >>>> Please correct me if I'm wrong, Mark...
> >>>
> >>> mlx5_ib is full of direct function calls to mlx5_core and it is done on
> >>> purpose for at least two reasons. First is to control in one place
> >>> all compilation options and expose proper API interface with and without
> >>> specific kernel config is on. Second is to emphasize that this is core
> >>> function and save us time in refactoring and reviewing.
> >>
> >> This was done in order to avoid #ifdef CONFIG_MLX5_ESWITCH,
> >> I want to hide (as much as possible) the interactions with the eswitch level in ib_rep.c/ib_rep.h
> >> so ib_rep.h will provide the stubs needed in case CONFIG_MLX5_ESWITCH isn't defined.
> >> (Today include/linux/mlx5/eswitch.h) doesn't provide any stubs, mlx5_eswitch_get_encap_mode()
> >> should have probably done the same.
> >
> > This is exactly the problem, eswitch.h should provide stubs for all
> > exported functions, so other clients of eswitch won't need to deal with
> > various unrelated config options.
>
> The way it works today, code in drivers/infiniband/hw/mlx5/main.c doesn't call eswitch layer directly
> but the functions in ib_rep.{c,h} as most often there is additional logic we must do before calling
> the eswitch layer.
>
> If you look at drivers/infiniband/hw/mlx5/Makefile you will see ib_rep is complied only when
> CONFIG_MLX5_ESWITCH id defined.
This simple patch + cleanup of ib_rep.h will do the trick.
diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c
index 67b9e7ac569a..b917ba28659e 100644
--- a/drivers/infiniband/hw/mlx5/main.c
+++ b/drivers/infiniband/hw/mlx5/main.c
@@ -59,7 +59,9 @@
#include <linux/in.h>
#include <linux/etherdevice.h>
#include "mlx5_ib.h"
+#if defined(CONFIG_MLX5_ESWITCH)
#include "ib_rep.h"
+#endif
#include "cmd.h"
#include "srq.h"
#include <linux/mlx5/fs_helpers.h>
@@ -6765,6 +6767,7 @@ static const struct mlx5_ib_profile pf_profile = {
mlx5_ib_stage_delay_drop_cleanup),
};
+#if defined(CONFIG_MLX5_ESWITCH)
const struct mlx5_ib_profile uplink_rep_profile = {
STAGE_CREATE(MLX5_IB_STAGE_INIT,
mlx5_ib_stage_init_init,
@@ -6812,6 +6815,7 @@
const struct mlx5_ib_profile uplink_rep_profile = {
mlx5_ib_stage_post_ib_reg_umr_init,
NULL),
};
>
> so instead of having to deal with two places that contain stubs, we need to deal with only one (ib_rep.h).
> For me it makes it easier to follow, but I can adept if you don't like it.
>
> Mark
>
> >
> >>
> >> As my long term goal is to break drivers/infiniband/hw/mlx5/main.c (that file is already 7000 LOC)
> >> I want to group together stuff in separate files.
> >
> > Yes, it is right thing to do.
> >
> >>
> >> If you prefer direct calls that's okay as well.
> >
> > Yes, please.
> >
> >>
> >> Mark
> >>
> >>>
> >>>>
> >>>>>
> >>>>>>
> >>>>>>> 2. It should be bool and not u32.
> >>>>>>>
> >>>>>>> Thanks
> >>>>>>
> >>>>>> --
> >>>>
> >>>> --
^ permalink raw reply related
* Re: [PATCH mlx5-next 11/15] RDMA/mlx5: Add vport metadata matching for IB representors
From: Mark Bloch @ 2019-06-19 7:58 UTC (permalink / raw)
To: Leon Romanovsky
Cc: Jianbo Liu, Saeed Mahameed, netdev@vger.kernel.org,
linux-rdma@vger.kernel.org, Roi Dayan
In-Reply-To: <20190619074338.GG11611@mtr-leonro.mtl.com>
On 6/19/2019 00:43, Leon Romanovsky wrote:
> On Wed, Jun 19, 2019 at 07:26:54AM +0000, Mark Bloch wrote:
>>
>>
>> On 6/18/2019 23:51, Leon Romanovsky wrote:
>>> On Wed, Jun 19, 2019 at 06:40:16AM +0000, Jianbo Liu wrote:
>>>> The 06/19/2019 13:04, Leon Romanovsky wrote:
>>>>> On Wed, Jun 19, 2019 at 04:44:26AM +0000, Jianbo Liu wrote:
>>>>>> The 06/18/2019 18:19, Leon Romanovsky wrote:
>>>>>>> On Mon, Jun 17, 2019 at 07:23:30PM +0000, Saeed Mahameed wrote:
>>>>>>>> From: Jianbo Liu <jianbol@mellanox.com>
>>>>>>>>
>>>>>>>> If vport metadata matching is enabled in eswitch, the rule created
>>>>>>>> must be changed to match on the metadata, instead of source port.
>>>>>>>>
>>>>>>>> Signed-off-by: Jianbo Liu <jianbol@mellanox.com>
>>>>>>>> Reviewed-by: Roi Dayan <roid@mellanox.com>
>>>>>>>> Reviewed-by: Mark Bloch <markb@mellanox.com>
>>>>>>>> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
>>>>>>>> ---
>>>>>>>> drivers/infiniband/hw/mlx5/ib_rep.c | 11 +++++++
>>>>>>>> drivers/infiniband/hw/mlx5/ib_rep.h | 16 ++++++++++
>>>>>>>> drivers/infiniband/hw/mlx5/main.c | 45 +++++++++++++++++++++++------
>>>>>>>> 3 files changed, 63 insertions(+), 9 deletions(-)
>>>>>>>>
>>>>>>>> diff --git a/drivers/infiniband/hw/mlx5/ib_rep.c b/drivers/infiniband/hw/mlx5/ib_rep.c
>>>>>>>> index 22e651cb5534..d4ed611de35d 100644
>>>>>>>> --- a/drivers/infiniband/hw/mlx5/ib_rep.c
>>>>>>>> +++ b/drivers/infiniband/hw/mlx5/ib_rep.c
>>>>>>>> @@ -131,6 +131,17 @@ struct mlx5_eswitch_rep *mlx5_ib_vport_rep(struct mlx5_eswitch *esw, int vport)
>>>>>>>> return mlx5_eswitch_vport_rep(esw, vport);
>>>>>>>> }
>>>>>>>>
>>>>>>>> +u32 mlx5_ib_eswitch_vport_match_metadata_enabled(struct mlx5_eswitch *esw)
>>>>>>>> +{
>>>>>>>> + return mlx5_eswitch_vport_match_metadata_enabled(esw);
>>>>>>>> +}
>>>>>>>> +
>>>>>>>> +u32 mlx5_ib_eswitch_get_vport_metadata_for_match(struct mlx5_eswitch *esw,
>>>>>>>> + u16 vport)
>>>>>>>> +{
>>>>>>>> + return mlx5_eswitch_get_vport_metadata_for_match(esw, vport);
>>>>>>>> +}
>>>>>>>
>>>>>>> 1. There is no need to introduce one line functions, call to that code directly.
>>>>>>
>>>>>> No. They are in IB, and we don't want them be mixed up by the original
>>>>>> functions in eswitch. Please ask Mark more about it.
>>>>>
>>>>> Please enlighten me.
>>>>
>>>> It was suggested by Mark in prevouis review.
>>>> I think it's because there are in different modules, and better to with
>>>> different names, so introduce there extra one line functions.
>>>> Please correct me if I'm wrong, Mark...
>>>
>>> mlx5_ib is full of direct function calls to mlx5_core and it is done on
>>> purpose for at least two reasons. First is to control in one place
>>> all compilation options and expose proper API interface with and without
>>> specific kernel config is on. Second is to emphasize that this is core
>>> function and save us time in refactoring and reviewing.
>>
>> This was done in order to avoid #ifdef CONFIG_MLX5_ESWITCH,
>> I want to hide (as much as possible) the interactions with the eswitch level in ib_rep.c/ib_rep.h
>> so ib_rep.h will provide the stubs needed in case CONFIG_MLX5_ESWITCH isn't defined.
>> (Today include/linux/mlx5/eswitch.h) doesn't provide any stubs, mlx5_eswitch_get_encap_mode()
>> should have probably done the same.
>
> This is exactly the problem, eswitch.h should provide stubs for all
> exported functions, so other clients of eswitch won't need to deal with
> various unrelated config options.
The way it works today, code in drivers/infiniband/hw/mlx5/main.c doesn't call eswitch layer directly
but the functions in ib_rep.{c,h} as most often there is additional logic we must do before calling
the eswitch layer.
If you look at drivers/infiniband/hw/mlx5/Makefile you will see ib_rep is complied only when
CONFIG_MLX5_ESWITCH id defined.
so instead of having to deal with two places that contain stubs, we need to deal with only one (ib_rep.h).
For me it makes it easier to follow, but I can adept if you don't like it.
Mark
>
>>
>> As my long term goal is to break drivers/infiniband/hw/mlx5/main.c (that file is already 7000 LOC)
>> I want to group together stuff in separate files.
>
> Yes, it is right thing to do.
>
>>
>> If you prefer direct calls that's okay as well.
>
> Yes, please.
>
>>
>> Mark
>>
>>>
>>>>
>>>>>
>>>>>>
>>>>>>> 2. It should be bool and not u32.
>>>>>>>
>>>>>>> Thanks
>>>>>>
>>>>>> --
>>>>
>>>> --
^ permalink raw reply
* [net-next, PATCH 2/2] net: netsec: remove loops in napi Rx process
From: Ilias Apalodimas @ 2019-06-19 7:57 UTC (permalink / raw)
To: jaswinder.singh
Cc: netdev, ard.biesheuvel, masahisa.kojima, davem, Ilias Apalodimas
In-Reply-To: <1560931034-6810-1-git-send-email-ilias.apalodimas@linaro.org>
netsec_process_rx was running in a loop trying to process as many packets
as possible before re-enabling interrupts. With the recent DMA changes
this is not needed anymore as we manage to consume all the budget without
looping over the function.
Since it has no performance penalty let's remove that and simplify the Rx
path a bit
Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
---
drivers/net/ethernet/socionext/netsec.c | 11 ++---------
1 file changed, 2 insertions(+), 9 deletions(-)
diff --git a/drivers/net/ethernet/socionext/netsec.c b/drivers/net/ethernet/socionext/netsec.c
index a10ef700f16d..48fd7448b513 100644
--- a/drivers/net/ethernet/socionext/netsec.c
+++ b/drivers/net/ethernet/socionext/netsec.c
@@ -820,19 +820,12 @@ static int netsec_process_rx(struct netsec_priv *priv, int budget)
static int netsec_napi_poll(struct napi_struct *napi, int budget)
{
struct netsec_priv *priv;
- int rx, done, todo;
+ int done;
priv = container_of(napi, struct netsec_priv, napi);
netsec_process_tx(priv);
-
- todo = budget;
- do {
- rx = netsec_process_rx(priv, todo);
- todo -= rx;
- } while (rx);
-
- done = budget - todo;
+ done = netsec_process_rx(priv, budget);
if (done < budget && napi_complete_done(napi, done)) {
unsigned long flags;
--
2.20.1
^ permalink raw reply related
* [net-next, PATCH 1/2] net: netsec: initialize tx ring on ndo_open
From: Ilias Apalodimas @ 2019-06-19 7:57 UTC (permalink / raw)
To: jaswinder.singh
Cc: netdev, ard.biesheuvel, masahisa.kojima, davem, Ilias Apalodimas
Since we changed the Tx ring handling and now depend not bit31 to figure
out the owner of the descriptor, we should initialize this every time
the device goes down-up instead of doing it once on driver init. If the
value is not correctly initialized the device won't have any available
descriptors
Fixes: 35e07d23473972b8876f98bcfc631ebcf779e870 ("net: socionext: remove mmio reads on Tx")
Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
---
drivers/net/ethernet/socionext/netsec.c | 32 ++++++++++++++-----------
1 file changed, 18 insertions(+), 14 deletions(-)
diff --git a/drivers/net/ethernet/socionext/netsec.c b/drivers/net/ethernet/socionext/netsec.c
index cba5881b2746..a10ef700f16d 100644
--- a/drivers/net/ethernet/socionext/netsec.c
+++ b/drivers/net/ethernet/socionext/netsec.c
@@ -1029,7 +1029,6 @@ static void netsec_free_dring(struct netsec_priv *priv, int id)
static int netsec_alloc_dring(struct netsec_priv *priv, enum ring_id id)
{
struct netsec_desc_ring *dring = &priv->desc_ring[id];
- int i;
dring->vaddr = dma_alloc_coherent(priv->dev, DESC_SZ * DESC_NUM,
&dring->desc_dma, GFP_KERNEL);
@@ -1040,19 +1039,6 @@ static int netsec_alloc_dring(struct netsec_priv *priv, enum ring_id id)
if (!dring->desc)
goto err;
- if (id == NETSEC_RING_TX) {
- for (i = 0; i < DESC_NUM; i++) {
- struct netsec_de *de;
-
- de = dring->vaddr + (DESC_SZ * i);
- /* de->attr is not going to be accessed by the NIC
- * until netsec_set_tx_de() is called.
- * No need for a dma_wmb() here
- */
- de->attr = 1U << NETSEC_TX_SHIFT_OWN_FIELD;
- }
- }
-
return 0;
err:
netsec_free_dring(priv, id);
@@ -1060,6 +1046,23 @@ static int netsec_alloc_dring(struct netsec_priv *priv, enum ring_id id)
return -ENOMEM;
}
+static void netsec_setup_tx_dring(struct netsec_priv *priv)
+{
+ struct netsec_desc_ring *dring = &priv->desc_ring[NETSEC_RING_TX];
+ int i;
+
+ for (i = 0; i < DESC_NUM; i++) {
+ struct netsec_de *de;
+
+ de = dring->vaddr + (DESC_SZ * i);
+ /* de->attr is not going to be accessed by the NIC
+ * until netsec_set_tx_de() is called.
+ * No need for a dma_wmb() here
+ */
+ de->attr = 1U << NETSEC_TX_SHIFT_OWN_FIELD;
+ }
+}
+
static int netsec_setup_rx_dring(struct netsec_priv *priv)
{
struct netsec_desc_ring *dring = &priv->desc_ring[NETSEC_RING_RX];
@@ -1361,6 +1364,7 @@ static int netsec_netdev_open(struct net_device *ndev)
pm_runtime_get_sync(priv->dev);
+ netsec_setup_tx_dring(priv);
ret = netsec_setup_rx_dring(priv);
if (ret) {
netif_err(priv, probe, priv->ndev,
--
2.20.1
^ permalink raw reply related
* Re: [PATCH mlx5-next 11/15] RDMA/mlx5: Add vport metadata matching for IB representors
From: Leon Romanovsky @ 2019-06-19 7:43 UTC (permalink / raw)
To: Mark Bloch
Cc: Jianbo Liu, Saeed Mahameed, netdev@vger.kernel.org,
linux-rdma@vger.kernel.org, Roi Dayan
In-Reply-To: <4e01d326-db6c-f746-acd6-06f65f311f5b@mellanox.com>
On Wed, Jun 19, 2019 at 07:26:54AM +0000, Mark Bloch wrote:
>
>
> On 6/18/2019 23:51, Leon Romanovsky wrote:
> > On Wed, Jun 19, 2019 at 06:40:16AM +0000, Jianbo Liu wrote:
> >> The 06/19/2019 13:04, Leon Romanovsky wrote:
> >>> On Wed, Jun 19, 2019 at 04:44:26AM +0000, Jianbo Liu wrote:
> >>>> The 06/18/2019 18:19, Leon Romanovsky wrote:
> >>>>> On Mon, Jun 17, 2019 at 07:23:30PM +0000, Saeed Mahameed wrote:
> >>>>>> From: Jianbo Liu <jianbol@mellanox.com>
> >>>>>>
> >>>>>> If vport metadata matching is enabled in eswitch, the rule created
> >>>>>> must be changed to match on the metadata, instead of source port.
> >>>>>>
> >>>>>> Signed-off-by: Jianbo Liu <jianbol@mellanox.com>
> >>>>>> Reviewed-by: Roi Dayan <roid@mellanox.com>
> >>>>>> Reviewed-by: Mark Bloch <markb@mellanox.com>
> >>>>>> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
> >>>>>> ---
> >>>>>> drivers/infiniband/hw/mlx5/ib_rep.c | 11 +++++++
> >>>>>> drivers/infiniband/hw/mlx5/ib_rep.h | 16 ++++++++++
> >>>>>> drivers/infiniband/hw/mlx5/main.c | 45 +++++++++++++++++++++++------
> >>>>>> 3 files changed, 63 insertions(+), 9 deletions(-)
> >>>>>>
> >>>>>> diff --git a/drivers/infiniband/hw/mlx5/ib_rep.c b/drivers/infiniband/hw/mlx5/ib_rep.c
> >>>>>> index 22e651cb5534..d4ed611de35d 100644
> >>>>>> --- a/drivers/infiniband/hw/mlx5/ib_rep.c
> >>>>>> +++ b/drivers/infiniband/hw/mlx5/ib_rep.c
> >>>>>> @@ -131,6 +131,17 @@ struct mlx5_eswitch_rep *mlx5_ib_vport_rep(struct mlx5_eswitch *esw, int vport)
> >>>>>> return mlx5_eswitch_vport_rep(esw, vport);
> >>>>>> }
> >>>>>>
> >>>>>> +u32 mlx5_ib_eswitch_vport_match_metadata_enabled(struct mlx5_eswitch *esw)
> >>>>>> +{
> >>>>>> + return mlx5_eswitch_vport_match_metadata_enabled(esw);
> >>>>>> +}
> >>>>>> +
> >>>>>> +u32 mlx5_ib_eswitch_get_vport_metadata_for_match(struct mlx5_eswitch *esw,
> >>>>>> + u16 vport)
> >>>>>> +{
> >>>>>> + return mlx5_eswitch_get_vport_metadata_for_match(esw, vport);
> >>>>>> +}
> >>>>>
> >>>>> 1. There is no need to introduce one line functions, call to that code directly.
> >>>>
> >>>> No. They are in IB, and we don't want them be mixed up by the original
> >>>> functions in eswitch. Please ask Mark more about it.
> >>>
> >>> Please enlighten me.
> >>
> >> It was suggested by Mark in prevouis review.
> >> I think it's because there are in different modules, and better to with
> >> different names, so introduce there extra one line functions.
> >> Please correct me if I'm wrong, Mark...
> >
> > mlx5_ib is full of direct function calls to mlx5_core and it is done on
> > purpose for at least two reasons. First is to control in one place
> > all compilation options and expose proper API interface with and without
> > specific kernel config is on. Second is to emphasize that this is core
> > function and save us time in refactoring and reviewing.
>
> This was done in order to avoid #ifdef CONFIG_MLX5_ESWITCH,
> I want to hide (as much as possible) the interactions with the eswitch level in ib_rep.c/ib_rep.h
> so ib_rep.h will provide the stubs needed in case CONFIG_MLX5_ESWITCH isn't defined.
> (Today include/linux/mlx5/eswitch.h) doesn't provide any stubs, mlx5_eswitch_get_encap_mode()
> should have probably done the same.
This is exactly the problem, eswitch.h should provide stubs for all
exported functions, so other clients of eswitch won't need to deal with
various unrelated config options.
>
> As my long term goal is to break drivers/infiniband/hw/mlx5/main.c (that file is already 7000 LOC)
> I want to group together stuff in separate files.
Yes, it is right thing to do.
>
> If you prefer direct calls that's okay as well.
Yes, please.
>
> Mark
>
> >
> >>
> >>>
> >>>>
> >>>>> 2. It should be bool and not u32.
> >>>>>
> >>>>> Thanks
> >>>>
> >>>> --
> >>
> >> --
^ permalink raw reply
* [PATCH V3] can: flexcan: fix stop mode acknowledgment
From: Joakim Zhang @ 2019-06-19 7:42 UTC (permalink / raw)
To: mkl@pengutronix.de, linux-can@vger.kernel.org
Cc: dl-linux-imx, wg@grandegger.com, netdev@vger.kernel.org,
Joakim Zhang
To enter stop mode, the CPU should manually assert a global Stop Mode
request and check the acknowledgment asserted by FlexCAN. The CPU must
only consider the FlexCAN in stop mode when both request and
acknowledgment conditions are satisfied.
Fixes: de3578c198c6 ("can: flexcan: add self wakeup support")
Reported-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Joakim Zhang <qiangqing.zhang@nxp.com>
ChangeLog:
V1->V2:
* regmap_read()-->regmap_read_poll_timeout()
V2->V3:
* change the way of error return, it will make easy for function
extension.
---
drivers/net/can/flexcan.c | 43 +++++++++++++++++++++++++++++++--------
1 file changed, 35 insertions(+), 8 deletions(-)
diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c
index e35083ff31ee..052c1981f27b 100644
--- a/drivers/net/can/flexcan.c
+++ b/drivers/net/can/flexcan.c
@@ -404,9 +404,10 @@ static void flexcan_enable_wakeup_irq(struct flexcan_priv *priv, bool enable)
priv->write(reg_mcr, ®s->mcr);
}
-static inline void flexcan_enter_stop_mode(struct flexcan_priv *priv)
+static inline int flexcan_enter_stop_mode(struct flexcan_priv *priv)
{
struct flexcan_regs __iomem *regs = priv->regs;
+ unsigned int ackval;
u32 reg_mcr;
reg_mcr = priv->read(®s->mcr);
@@ -416,20 +417,37 @@ static inline void flexcan_enter_stop_mode(struct flexcan_priv *priv)
/* enable stop request */
regmap_update_bits(priv->stm.gpr, priv->stm.req_gpr,
1 << priv->stm.req_bit, 1 << priv->stm.req_bit);
+
+ /* get stop acknowledgment */
+ if (regmap_read_poll_timeout(priv->stm.gpr, priv->stm.ack_gpr,
+ ackval, ackval & (1 << priv->stm.ack_bit),
+ 0, FLEXCAN_TIMEOUT_US))
+ return -ETIMEDOUT;
+
+ return 0;
}
-static inline void flexcan_exit_stop_mode(struct flexcan_priv *priv)
+static inline int flexcan_exit_stop_mode(struct flexcan_priv *priv)
{
struct flexcan_regs __iomem *regs = priv->regs;
+ unsigned int ackval;
u32 reg_mcr;
/* remove stop request */
regmap_update_bits(priv->stm.gpr, priv->stm.req_gpr,
1 << priv->stm.req_bit, 0);
+ /* get stop acknowledgment */
+ if (regmap_read_poll_timeout(priv->stm.gpr, priv->stm.ack_gpr,
+ ackval, !(ackval & (1 << priv->stm.ack_bit)),
+ 0, FLEXCAN_TIMEOUT_US))
+ return -ETIMEDOUT;
+
reg_mcr = priv->read(®s->mcr);
reg_mcr &= ~FLEXCAN_MCR_SLF_WAK;
priv->write(reg_mcr, ®s->mcr);
+
+ return 0;
}
static inline void flexcan_error_irq_enable(const struct flexcan_priv *priv)
@@ -1644,7 +1662,7 @@ static int __maybe_unused flexcan_suspend(struct device *device)
{
struct net_device *dev = dev_get_drvdata(device);
struct flexcan_priv *priv = netdev_priv(dev);
- int err = 0;
+ int err;
if (netif_running(dev)) {
/* if wakeup is enabled, enter stop mode
@@ -1652,27 +1670,31 @@ static int __maybe_unused flexcan_suspend(struct device *device)
*/
if (device_may_wakeup(device)) {
enable_irq_wake(dev->irq);
- flexcan_enter_stop_mode(priv);
+ err = flexcan_enter_stop_mode(priv);
+ if (err)
+ return err;
} else {
err = flexcan_chip_disable(priv);
if (err)
return err;
err = pm_runtime_force_suspend(device);
+ if (err)
+ return err;
}
netif_stop_queue(dev);
netif_device_detach(dev);
}
priv->can.state = CAN_STATE_SLEEPING;
- return err;
+ return 0;
}
static int __maybe_unused flexcan_resume(struct device *device)
{
struct net_device *dev = dev_get_drvdata(device);
struct flexcan_priv *priv = netdev_priv(dev);
- int err = 0;
+ int err;
priv->can.state = CAN_STATE_ERROR_ACTIVE;
if (netif_running(dev)) {
@@ -1686,10 +1708,12 @@ static int __maybe_unused flexcan_resume(struct device *device)
return err;
err = flexcan_chip_enable(priv);
+ if (err)
+ return err;
}
}
- return err;
+ return 0;
}
static int __maybe_unused flexcan_runtime_suspend(struct device *device)
@@ -1725,10 +1749,13 @@ static int __maybe_unused flexcan_noirq_resume(struct device *device)
{
struct net_device *dev = dev_get_drvdata(device);
struct flexcan_priv *priv = netdev_priv(dev);
+ int err;
if (netif_running(dev) && device_may_wakeup(device)) {
flexcan_enable_wakeup_irq(priv, false);
- flexcan_exit_stop_mode(priv);
+ err = flexcan_exit_stop_mode(priv);
+ if (err)
+ return err;
}
return 0;
--
2.17.1
^ permalink raw reply related
* Re: [PATCH mlx5-next 11/15] RDMA/mlx5: Add vport metadata matching for IB representors
From: Mark Bloch @ 2019-06-19 7:26 UTC (permalink / raw)
To: Leon Romanovsky, Jianbo Liu
Cc: Saeed Mahameed, netdev@vger.kernel.org,
linux-rdma@vger.kernel.org, Roi Dayan
In-Reply-To: <20190619065125.GF11611@mtr-leonro.mtl.com>
On 6/18/2019 23:51, Leon Romanovsky wrote:
> On Wed, Jun 19, 2019 at 06:40:16AM +0000, Jianbo Liu wrote:
>> The 06/19/2019 13:04, Leon Romanovsky wrote:
>>> On Wed, Jun 19, 2019 at 04:44:26AM +0000, Jianbo Liu wrote:
>>>> The 06/18/2019 18:19, Leon Romanovsky wrote:
>>>>> On Mon, Jun 17, 2019 at 07:23:30PM +0000, Saeed Mahameed wrote:
>>>>>> From: Jianbo Liu <jianbol@mellanox.com>
>>>>>>
>>>>>> If vport metadata matching is enabled in eswitch, the rule created
>>>>>> must be changed to match on the metadata, instead of source port.
>>>>>>
>>>>>> Signed-off-by: Jianbo Liu <jianbol@mellanox.com>
>>>>>> Reviewed-by: Roi Dayan <roid@mellanox.com>
>>>>>> Reviewed-by: Mark Bloch <markb@mellanox.com>
>>>>>> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
>>>>>> ---
>>>>>> drivers/infiniband/hw/mlx5/ib_rep.c | 11 +++++++
>>>>>> drivers/infiniband/hw/mlx5/ib_rep.h | 16 ++++++++++
>>>>>> drivers/infiniband/hw/mlx5/main.c | 45 +++++++++++++++++++++++------
>>>>>> 3 files changed, 63 insertions(+), 9 deletions(-)
>>>>>>
>>>>>> diff --git a/drivers/infiniband/hw/mlx5/ib_rep.c b/drivers/infiniband/hw/mlx5/ib_rep.c
>>>>>> index 22e651cb5534..d4ed611de35d 100644
>>>>>> --- a/drivers/infiniband/hw/mlx5/ib_rep.c
>>>>>> +++ b/drivers/infiniband/hw/mlx5/ib_rep.c
>>>>>> @@ -131,6 +131,17 @@ struct mlx5_eswitch_rep *mlx5_ib_vport_rep(struct mlx5_eswitch *esw, int vport)
>>>>>> return mlx5_eswitch_vport_rep(esw, vport);
>>>>>> }
>>>>>>
>>>>>> +u32 mlx5_ib_eswitch_vport_match_metadata_enabled(struct mlx5_eswitch *esw)
>>>>>> +{
>>>>>> + return mlx5_eswitch_vport_match_metadata_enabled(esw);
>>>>>> +}
>>>>>> +
>>>>>> +u32 mlx5_ib_eswitch_get_vport_metadata_for_match(struct mlx5_eswitch *esw,
>>>>>> + u16 vport)
>>>>>> +{
>>>>>> + return mlx5_eswitch_get_vport_metadata_for_match(esw, vport);
>>>>>> +}
>>>>>
>>>>> 1. There is no need to introduce one line functions, call to that code directly.
>>>>
>>>> No. They are in IB, and we don't want them be mixed up by the original
>>>> functions in eswitch. Please ask Mark more about it.
>>>
>>> Please enlighten me.
>>
>> It was suggested by Mark in prevouis review.
>> I think it's because there are in different modules, and better to with
>> different names, so introduce there extra one line functions.
>> Please correct me if I'm wrong, Mark...
>
> mlx5_ib is full of direct function calls to mlx5_core and it is done on
> purpose for at least two reasons. First is to control in one place
> all compilation options and expose proper API interface with and without
> specific kernel config is on. Second is to emphasize that this is core
> function and save us time in refactoring and reviewing.
This was done in order to avoid #ifdef CONFIG_MLX5_ESWITCH,
I want to hide (as much as possible) the interactions with the eswitch level in ib_rep.c/ib_rep.h
so ib_rep.h will provide the stubs needed in case CONFIG_MLX5_ESWITCH isn't defined.
(Today include/linux/mlx5/eswitch.h) doesn't provide any stubs, mlx5_eswitch_get_encap_mode()
should have probably done the same.
As my long term goal is to break drivers/infiniband/hw/mlx5/main.c (that file is already 7000 LOC)
I want to group together stuff in separate files.
If you prefer direct calls that's okay as well.
Mark
>
>>
>>>
>>>>
>>>>> 2. It should be bool and not u32.
>>>>>
>>>>> Thanks
>>>>
>>>> --
>>
>> --
^ permalink raw reply
* [PATCH 1/2 nf-next] netfilter: nft_meta: add NFT_META_BRI_PVID support
From: wenxu @ 2019-06-19 7:16 UTC (permalink / raw)
To: pablo, fw; +Cc: netfilter-devel, netdev
From: wenxu <wenxu@ucloud.cn>
nft add table bridge firewall
nft add chain bridge firewall zones { type filter hook prerouting priority - 300 \; }
nft add rule bridge firewall zones counter ct zone set vlan id map { 100 : 1, 200 : 2 }
As above set the bridge port with pvid, the received packet don't contain
the vlan tag which means the packet should belong to vlan 200 through pvid.
With this pacth user can get the pvid of bridge ports: "meta brpvid"
Signed-off-by: wenxu <wenxu@ucloud.cn>
---
include/uapi/linux/netfilter/nf_tables.h | 2 ++
net/netfilter/nft_meta.c | 17 +++++++++++++++++
2 files changed, 19 insertions(+)
diff --git a/include/uapi/linux/netfilter/nf_tables.h b/include/uapi/linux/netfilter/nf_tables.h
index 31a6b8f..4a16124 100644
--- a/include/uapi/linux/netfilter/nf_tables.h
+++ b/include/uapi/linux/netfilter/nf_tables.h
@@ -793,6 +793,7 @@ enum nft_exthdr_attributes {
* @NFT_META_SECPATH: boolean, secpath_exists (!!skb->sp)
* @NFT_META_IIFKIND: packet input interface kind name (dev->rtnl_link_ops->kind)
* @NFT_META_OIFKIND: packet output interface kind name (dev->rtnl_link_ops->kind)
+ * @NFT_META_BRI_PVID: packet input bridge port pvid
*/
enum nft_meta_keys {
NFT_META_LEN,
@@ -823,6 +824,7 @@ enum nft_meta_keys {
NFT_META_SECPATH,
NFT_META_IIFKIND,
NFT_META_OIFKIND,
+ NFT_META_BRI_PVID,
};
/**
diff --git a/net/netfilter/nft_meta.c b/net/netfilter/nft_meta.c
index 987d2d6..1fdb565 100644
--- a/net/netfilter/nft_meta.c
+++ b/net/netfilter/nft_meta.c
@@ -243,6 +243,18 @@ void nft_meta_get_eval(const struct nft_expr *expr,
goto err;
strncpy((char *)dest, p->br->dev->name, IFNAMSIZ);
return;
+ case NFT_META_BRI_PVID:
+ if (in == NULL || (p = br_port_get_rtnl_rcu(in)) == NULL)
+ goto err;
+ if (br_opt_get(p->br, BROPT_VLAN_ENABLED)) {
+ u16 pvid = br_get_pvid(nbp_vlan_group_rcu(p));
+
+ if (pvid) {
+ nft_reg_store16(dest, pvid);
+ return;
+ }
+ }
+ goto err;
#endif
case NFT_META_IIFKIND:
if (in == NULL || in->rtnl_link_ops == NULL)
@@ -370,6 +382,11 @@ static int nft_meta_get_init(const struct nft_ctx *ctx,
return -EOPNOTSUPP;
len = IFNAMSIZ;
break;
+ case NFT_META_BRI_PVID:
+ if (ctx->family != NFPROTO_BRIDGE)
+ return -EOPNOTSUPP;
+ len = sizeof(u16);
+ break;
#endif
default:
return -EOPNOTSUPP;
--
1.8.3.1
^ permalink raw reply related
* [PATCH 2/2 nf-next] netfilter: nft_meta: Add NFT_META_BRI_VLAN support
From: wenxu @ 2019-06-19 7:16 UTC (permalink / raw)
To: pablo, fw; +Cc: netfilter-devel, netdev
In-Reply-To: <1560928585-18352-1-git-send-email-wenxu@ucloud.cn>
From: wenxu <wenxu@ucloud.cn>
nft add table bridge firewall
nft add chain bridge firewall zones { type filter hook prerouting priority - 300 \; }
nft add rule bridge firewall zones counter ct zone set vlan id map { 100 : 1, 200 : 2 }
As above set the bridge port with pvid, the received packet don't contain
the vlan tag which means the packet should belong to vlan 200 through pvid.
With this pacth user can set the pvid in the prerouting hook before set zone
id and conntrack: "meta brvlan set meta brpvid"
Signed-off-by: wenxu <wenxu@ucloud.cn>
---
include/uapi/linux/netfilter/nf_tables.h | 2 ++
net/netfilter/nft_meta.c | 20 ++++++++++++++++++++
2 files changed, 22 insertions(+)
diff --git a/include/uapi/linux/netfilter/nf_tables.h b/include/uapi/linux/netfilter/nf_tables.h
index 4a16124..7be0307 100644
--- a/include/uapi/linux/netfilter/nf_tables.h
+++ b/include/uapi/linux/netfilter/nf_tables.h
@@ -794,6 +794,7 @@ enum nft_exthdr_attributes {
* @NFT_META_IIFKIND: packet input interface kind name (dev->rtnl_link_ops->kind)
* @NFT_META_OIFKIND: packet output interface kind name (dev->rtnl_link_ops->kind)
* @NFT_META_BRI_PVID: packet input bridge port pvid
+ * @NFT_META_BRI_VLAN: set vlan tag on packet
*/
enum nft_meta_keys {
NFT_META_LEN,
@@ -825,6 +826,7 @@ enum nft_meta_keys {
NFT_META_IIFKIND,
NFT_META_OIFKIND,
NFT_META_BRI_PVID,
+ NFT_META_BRI_VLAN,
};
/**
diff --git a/net/netfilter/nft_meta.c b/net/netfilter/nft_meta.c
index 1fdb565..5c3817b 100644
--- a/net/netfilter/nft_meta.c
+++ b/net/netfilter/nft_meta.c
@@ -282,8 +282,13 @@ static void nft_meta_set_eval(const struct nft_expr *expr,
{
const struct nft_meta *meta = nft_expr_priv(expr);
struct sk_buff *skb = pkt->skb;
+ const struct net_device *in = nft_in(pkt);
u32 *sreg = ®s->data[meta->sreg];
+#ifdef CONFIG_NF_TABLES_BRIDGE
+ const struct net_bridge_port *p;
+#endif
u32 value = *sreg;
+ u16 value16;
u8 value8;
switch (meta->key) {
@@ -306,6 +311,14 @@ static void nft_meta_set_eval(const struct nft_expr *expr,
skb->nf_trace = !!value8;
break;
+#ifdef CONFIG_NF_TABLES_BRIDGE
+ case NFT_META_BRI_VLAN:
+ value16 = nft_reg_load16(sreg);
+ if (in && (p = br_port_get_rtnl_rcu(in)) &&
+ !skb_vlan_tag_present(skb))
+ __vlan_hwaccel_put_tag(skb, p->br->vlan_proto, value16);
+ break;
+#endif
#ifdef CONFIG_NETWORK_SECMARK
case NFT_META_SECMARK:
skb->secmark = value;
@@ -481,6 +494,13 @@ static int nft_meta_set_init(const struct nft_ctx *ctx,
case NFT_META_PKTTYPE:
len = sizeof(u8);
break;
+#ifdef CONFIG_NF_TABLES_BRIDGE
+ case NFT_META_BRI_VLAN:
+ if (ctx->family != NFPROTO_BRIDGE)
+ return -EOPNOTSUPP;
+ len = sizeof(u16);
+ break;
+#endif
default:
return -EOPNOTSUPP;
}
--
1.8.3.1
^ permalink raw reply related
* Re: [PATCH] net: stmmac: add sanity check to device_property_read_u32_array call
From: Colin Ian King @ 2019-06-19 6:55 UTC (permalink / raw)
To: Martin Blumenstingl
Cc: alexandre.torgue, davem, joabreu, kernel-janitors,
linux-arm-kernel, linux-kernel, linux-stm32, mcoquelin.stm32,
netdev, peppe.cavallaro
In-Reply-To: <20190619051308.23582-1-martin.blumenstingl@googlemail.com>
On 19/06/2019 06:13, Martin Blumenstingl wrote:
> Hi Colin,
>
>> Currently the call to device_property_read_u32_array is not error checked
>> leading to potential garbage values in the delays array that are then used
>> in msleep delays. Add a sanity check to the property fetching.
>>
>> Addresses-Coverity: ("Uninitialized scalar variable")
>> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> I have also sent a patch [0] to fix initialize the array.
> can you please look at my patch so we can work out which one to use?
>
> my concern is that the "snps,reset-delays-us" property is optional,
> the current dt-bindings documentation states that it's a required
> property. in reality it isn't, there are boards (two examples are
> mentioned in my patch: [0]) without it.
>
> so I believe that the resulting behavior has to be:
> 1. don't delay if this property is missing (instead of delaying for
> <garbage value> ms)
> 2. don't error out if this property is missing
>
> your patch covers #1, can you please check whether #2 is also covered?
> I tested case #2 when submitting my patch and it worked fine (even
> though I could not reproduce the garbage values which are being read
> on some boards)
>
>
> Thank you!
> Martin
>
>
> [0] https://lkml.org/lkml/2019/4/19/638
>
Is that the correct link?
Colin
^ permalink raw reply
* [PATCH net-next v2 1/1] net: fastopen: robustness and endianness fixes for SipHash
From: Ard Biesheuvel @ 2019-06-19 6:55 UTC (permalink / raw)
To: netdev
Cc: Ard Biesheuvel, Eric Biggers, linux-crypto, herbert, edumazet,
davem, kuznet, yoshfuji, jbaron, cpaasch, David.Laight, ycheng
In-Reply-To: <20190619065510.23514-1-ard.biesheuvel@linaro.org>
Some changes to the TCP fastopen code to make it more robust
against future changes in the choice of key/cookie size, etc.
- Instead of keeping the SipHash key in an untyped u8[] buffer
and casting it to the right type upon use, use the correct
type directly. This ensures that the key will appear at the
correct alignment if we ever change the way these data
structures are allocated. (Currently, they are only allocated
via kmalloc so they always appear at the correct alignment)
- Use DIV_ROUND_UP when sizing the u64[] array to hold the
cookie, so it is always of sufficient size, even if
TCP_FASTOPEN_COOKIE_MAX is no longer a multiple of 8.
- Drop the 'len' parameter from the tcp_fastopen_reset_cipher()
function, which is no longer used.
- Add endian swabbing when setting the keys and calculating the hash,
to ensure that cookie values are the same for a given key and
source/destination address pair regardless of the endianness of
the server.
Note that none of these are functional changes wrt the current
state of the code, with the exception of the swabbing, which only
affects big endian systems.
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
include/linux/tcp.h | 2 +-
include/net/tcp.h | 8 ++--
net/ipv4/sysctl_net_ipv4.c | 3 +-
net/ipv4/tcp.c | 3 +-
net/ipv4/tcp_fastopen.c | 39 +++++++++++---------
5 files changed, 28 insertions(+), 27 deletions(-)
diff --git a/include/linux/tcp.h b/include/linux/tcp.h
index 2689b0b0b68a..f3a85a7fb4b1 100644
--- a/include/linux/tcp.h
+++ b/include/linux/tcp.h
@@ -58,7 +58,7 @@ static inline unsigned int tcp_optlen(const struct sk_buff *skb)
/* TCP Fast Open Cookie as stored in memory */
struct tcp_fastopen_cookie {
- u64 val[TCP_FASTOPEN_COOKIE_MAX / sizeof(u64)];
+ __le64 val[DIV_ROUND_UP(TCP_FASTOPEN_COOKIE_MAX, sizeof(u64))];
s8 len;
bool exp; /* In RFC6994 experimental option format */
};
diff --git a/include/net/tcp.h b/include/net/tcp.h
index 573c9e9b0d72..9d36cc88d043 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -43,6 +43,7 @@
#include <linux/seq_file.h>
#include <linux/memcontrol.h>
#include <linux/bpf-cgroup.h>
+#include <linux/siphash.h>
extern struct inet_hashinfo tcp_hashinfo;
@@ -1612,8 +1613,7 @@ void tcp_free_fastopen_req(struct tcp_sock *tp);
void tcp_fastopen_destroy_cipher(struct sock *sk);
void tcp_fastopen_ctx_destroy(struct net *net);
int tcp_fastopen_reset_cipher(struct net *net, struct sock *sk,
- void *primary_key, void *backup_key,
- unsigned int len);
+ void *primary_key, void *backup_key);
void tcp_fastopen_add_skb(struct sock *sk, struct sk_buff *skb);
struct sock *tcp_try_fastopen(struct sock *sk, struct sk_buff *skb,
struct request_sock *req,
@@ -1623,14 +1623,14 @@ void tcp_fastopen_init_key_once(struct net *net);
bool tcp_fastopen_cookie_check(struct sock *sk, u16 *mss,
struct tcp_fastopen_cookie *cookie);
bool tcp_fastopen_defer_connect(struct sock *sk, int *err);
-#define TCP_FASTOPEN_KEY_LENGTH 16
+#define TCP_FASTOPEN_KEY_LENGTH sizeof(siphash_key_t)
#define TCP_FASTOPEN_KEY_MAX 2
#define TCP_FASTOPEN_KEY_BUF_LENGTH \
(TCP_FASTOPEN_KEY_LENGTH * TCP_FASTOPEN_KEY_MAX)
/* Fastopen key context */
struct tcp_fastopen_context {
- __u8 key[TCP_FASTOPEN_KEY_MAX][TCP_FASTOPEN_KEY_LENGTH];
+ siphash_key_t key[TCP_FASTOPEN_KEY_MAX];
int num;
struct rcu_head rcu;
};
diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
index 7d802acde040..7d66306b5f39 100644
--- a/net/ipv4/sysctl_net_ipv4.c
+++ b/net/ipv4/sysctl_net_ipv4.c
@@ -365,8 +365,7 @@ static int proc_tcp_fastopen_key(struct ctl_table *table, int write,
}
}
tcp_fastopen_reset_cipher(net, NULL, key,
- backup_data ? key + 4 : NULL,
- TCP_FASTOPEN_KEY_LENGTH);
+ backup_data ? key + 4 : NULL);
}
bad_key:
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index efd7f2b1d1f0..47c217905864 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -2822,8 +2822,7 @@ static int do_tcp_setsockopt(struct sock *sk, int level,
if (optlen == TCP_FASTOPEN_KEY_BUF_LENGTH)
backup_key = key + TCP_FASTOPEN_KEY_LENGTH;
- return tcp_fastopen_reset_cipher(net, sk, key, backup_key,
- TCP_FASTOPEN_KEY_LENGTH);
+ return tcp_fastopen_reset_cipher(net, sk, key, backup_key);
}
default:
/* fallthru */
diff --git a/net/ipv4/tcp_fastopen.c b/net/ipv4/tcp_fastopen.c
index 46b67128e1ca..2f5e7b62ffe4 100644
--- a/net/ipv4/tcp_fastopen.c
+++ b/net/ipv4/tcp_fastopen.c
@@ -7,7 +7,6 @@
#include <linux/tcp.h>
#include <linux/rcupdate.h>
#include <linux/rculist.h>
-#include <linux/siphash.h>
#include <net/inetpeer.h>
#include <net/tcp.h>
@@ -31,7 +30,7 @@ void tcp_fastopen_init_key_once(struct net *net)
* for a valid cookie, so this is an acceptable risk.
*/
get_random_bytes(key, sizeof(key));
- tcp_fastopen_reset_cipher(net, NULL, key, NULL, sizeof(key));
+ tcp_fastopen_reset_cipher(net, NULL, key, NULL);
}
static void tcp_fastopen_ctx_free(struct rcu_head *head)
@@ -68,8 +67,7 @@ void tcp_fastopen_ctx_destroy(struct net *net)
}
int tcp_fastopen_reset_cipher(struct net *net, struct sock *sk,
- void *primary_key, void *backup_key,
- unsigned int len)
+ void *primary_key, void *backup_key)
{
struct tcp_fastopen_context *ctx, *octx;
struct fastopen_queue *q;
@@ -81,9 +79,15 @@ int tcp_fastopen_reset_cipher(struct net *net, struct sock *sk,
goto out;
}
- memcpy(ctx->key[0], primary_key, len);
+ ctx->key[0] = (siphash_key_t){
+ get_unaligned_le64(primary_key),
+ get_unaligned_le64(primary_key + 8)
+ };
if (backup_key) {
- memcpy(ctx->key[1], backup_key, len);
+ ctx->key[1] = (siphash_key_t){
+ get_unaligned_le64(backup_key),
+ get_unaligned_le64(backup_key + 8)
+ };
ctx->num = 2;
} else {
ctx->num = 1;
@@ -110,19 +114,18 @@ int tcp_fastopen_reset_cipher(struct net *net, struct sock *sk,
static bool __tcp_fastopen_cookie_gen_cipher(struct request_sock *req,
struct sk_buff *syn,
- const u8 *key,
+ const siphash_key_t *key,
struct tcp_fastopen_cookie *foc)
{
- BUILD_BUG_ON(TCP_FASTOPEN_KEY_LENGTH != sizeof(siphash_key_t));
BUILD_BUG_ON(TCP_FASTOPEN_COOKIE_SIZE != sizeof(u64));
if (req->rsk_ops->family == AF_INET) {
const struct iphdr *iph = ip_hdr(syn);
- foc->val[0] = siphash(&iph->saddr,
- sizeof(iph->saddr) +
- sizeof(iph->daddr),
- (const siphash_key_t *)key);
+ foc->val[0] = cpu_to_le64(siphash(&iph->saddr,
+ sizeof(iph->saddr) +
+ sizeof(iph->daddr),
+ key));
foc->len = TCP_FASTOPEN_COOKIE_SIZE;
return true;
}
@@ -130,10 +133,10 @@ static bool __tcp_fastopen_cookie_gen_cipher(struct request_sock *req,
if (req->rsk_ops->family == AF_INET6) {
const struct ipv6hdr *ip6h = ipv6_hdr(syn);
- foc->val[0] = siphash(&ip6h->saddr,
- sizeof(ip6h->saddr) +
- sizeof(ip6h->daddr),
- (const siphash_key_t *)key);
+ foc->val[0] = cpu_to_le64(siphash(&ip6h->saddr,
+ sizeof(ip6h->saddr) +
+ sizeof(ip6h->daddr),
+ key));
foc->len = TCP_FASTOPEN_COOKIE_SIZE;
return true;
}
@@ -154,7 +157,7 @@ static void tcp_fastopen_cookie_gen(struct sock *sk,
rcu_read_lock();
ctx = tcp_fastopen_get_ctx(sk);
if (ctx)
- __tcp_fastopen_cookie_gen_cipher(req, syn, ctx->key[0], foc);
+ __tcp_fastopen_cookie_gen_cipher(req, syn, &ctx->key[0], foc);
rcu_read_unlock();
}
@@ -218,7 +221,7 @@ static int tcp_fastopen_cookie_gen_check(struct sock *sk,
if (!ctx)
goto out;
for (i = 0; i < tcp_fastopen_context_len(ctx); i++) {
- __tcp_fastopen_cookie_gen_cipher(req, syn, ctx->key[i], foc);
+ __tcp_fastopen_cookie_gen_cipher(req, syn, &ctx->key[i], foc);
if (tcp_fastopen_cookie_match(foc, orig)) {
ret = i + 1;
goto out;
--
2.17.1
^ permalink raw reply related
* [PATCH net-next v2 0/1] net: fastopen: follow-up tweaks for SipHash switch
From: Ard Biesheuvel @ 2019-06-19 6:55 UTC (permalink / raw)
To: netdev
Cc: Ard Biesheuvel, Eric Biggers, linux-crypto, herbert, edumazet,
davem, kuznet, yoshfuji, jbaron, cpaasch, David.Laight, ycheng
Some fixes for the fastopen code after switching to SipHash, which were
spotted in review after the change had already been queued.
cc: Eric Biggers <ebiggers@kernel.org>
cc: linux-crypto@vger.kernel.org
cc: herbert@gondor.apana.org.au
cc: edumazet@google.com
cc: davem@davemloft.net
cc: kuznet@ms2.inr.ac.ru
cc: yoshfuji@linux-ipv6.org
cc: jbaron@akamai.com
cc: cpaasch@apple.com
cc: David.Laight@aculab.com
cc: ycheng@google.com
Ard Biesheuvel (1):
net: fastopen: robustness and endianness fixes for SipHash
include/linux/tcp.h | 2 +-
include/net/tcp.h | 8 ++--
net/ipv4/sysctl_net_ipv4.c | 3 +-
net/ipv4/tcp.c | 3 +-
net/ipv4/tcp_fastopen.c | 39 +++++++++++---------
5 files changed, 28 insertions(+), 27 deletions(-)
--
2.17.1
^ permalink raw reply
* Re: [PATCH mlx5-next 11/15] RDMA/mlx5: Add vport metadata matching for IB representors
From: Leon Romanovsky @ 2019-06-19 6:51 UTC (permalink / raw)
To: Jianbo Liu
Cc: Saeed Mahameed, netdev@vger.kernel.org,
linux-rdma@vger.kernel.org, Roi Dayan, Mark Bloch
In-Reply-To: <20190619063941.GA5176@mellanox.com>
On Wed, Jun 19, 2019 at 06:40:16AM +0000, Jianbo Liu wrote:
> The 06/19/2019 13:04, Leon Romanovsky wrote:
> > On Wed, Jun 19, 2019 at 04:44:26AM +0000, Jianbo Liu wrote:
> > > The 06/18/2019 18:19, Leon Romanovsky wrote:
> > > > On Mon, Jun 17, 2019 at 07:23:30PM +0000, Saeed Mahameed wrote:
> > > > > From: Jianbo Liu <jianbol@mellanox.com>
> > > > >
> > > > > If vport metadata matching is enabled in eswitch, the rule created
> > > > > must be changed to match on the metadata, instead of source port.
> > > > >
> > > > > Signed-off-by: Jianbo Liu <jianbol@mellanox.com>
> > > > > Reviewed-by: Roi Dayan <roid@mellanox.com>
> > > > > Reviewed-by: Mark Bloch <markb@mellanox.com>
> > > > > Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
> > > > > ---
> > > > > drivers/infiniband/hw/mlx5/ib_rep.c | 11 +++++++
> > > > > drivers/infiniband/hw/mlx5/ib_rep.h | 16 ++++++++++
> > > > > drivers/infiniband/hw/mlx5/main.c | 45 +++++++++++++++++++++++------
> > > > > 3 files changed, 63 insertions(+), 9 deletions(-)
> > > > >
> > > > > diff --git a/drivers/infiniband/hw/mlx5/ib_rep.c b/drivers/infiniband/hw/mlx5/ib_rep.c
> > > > > index 22e651cb5534..d4ed611de35d 100644
> > > > > --- a/drivers/infiniband/hw/mlx5/ib_rep.c
> > > > > +++ b/drivers/infiniband/hw/mlx5/ib_rep.c
> > > > > @@ -131,6 +131,17 @@ struct mlx5_eswitch_rep *mlx5_ib_vport_rep(struct mlx5_eswitch *esw, int vport)
> > > > > return mlx5_eswitch_vport_rep(esw, vport);
> > > > > }
> > > > >
> > > > > +u32 mlx5_ib_eswitch_vport_match_metadata_enabled(struct mlx5_eswitch *esw)
> > > > > +{
> > > > > + return mlx5_eswitch_vport_match_metadata_enabled(esw);
> > > > > +}
> > > > > +
> > > > > +u32 mlx5_ib_eswitch_get_vport_metadata_for_match(struct mlx5_eswitch *esw,
> > > > > + u16 vport)
> > > > > +{
> > > > > + return mlx5_eswitch_get_vport_metadata_for_match(esw, vport);
> > > > > +}
> > > >
> > > > 1. There is no need to introduce one line functions, call to that code directly.
> > >
> > > No. They are in IB, and we don't want them be mixed up by the original
> > > functions in eswitch. Please ask Mark more about it.
> >
> > Please enlighten me.
>
> It was suggested by Mark in prevouis review.
> I think it's because there are in different modules, and better to with
> different names, so introduce there extra one line functions.
> Please correct me if I'm wrong, Mark...
mlx5_ib is full of direct function calls to mlx5_core and it is done on
purpose for at least two reasons. First is to control in one place
all compilation options and expose proper API interface with and without
specific kernel config is on. Second is to emphasize that this is core
function and save us time in refactoring and reviewing.
>
> >
> > >
> > > > 2. It should be bool and not u32.
> > > >
> > > > Thanks
> > >
> > > --
>
> --
^ permalink raw reply
* Re: [PATCH] net: mvpp2: cls: Add pmap to fs dump
From: Maxime Chevallier @ 2019-06-19 6:49 UTC (permalink / raw)
To: Nathan Huckleberry; +Cc: davem, netdev, linux-kernel, clang-built-linux
In-Reply-To: <20190618160910.62922-1-nhuck@google.com>
Hello Nathan,
On Tue, 18 Jun 2019 09:09:10 -0700
Nathan Huckleberry <nhuck@google.com> wrote:
>There was an unused variable 'mvpp2_dbgfs_prs_pmap_fops'
>Added a usage consistent with other fops to dump pmap
>to userspace.
Thanks for sending a fix. Besides the typo preventing your patch from
compiling, you should also prefix the patch by "net: mvpp2: debugfs:"
rather than "cls", which is used for classifier patches.
Thanks,
Maxime
^ permalink raw reply
* Re: [PATCH mlx5-next 05/15] net/mlx5: E-Switch, Tag packet with vport number in VF vports and uplink ingress ACLs
From: Jianbo Liu @ 2019-06-19 6:45 UTC (permalink / raw)
To: Parav Pandit
Cc: Saeed Mahameed, Leon Romanovsky, netdev@vger.kernel.org,
linux-rdma@vger.kernel.org, Eli Britstein, Roi Dayan, Mark Bloch
In-Reply-To: <AM0PR05MB48663F4F6C7CCA9F2DA37074D1E50@AM0PR05MB4866.eurprd05.prod.outlook.com>
The 06/19/2019 13:42, Parav Pandit wrote:
>
>
> > -----Original Message-----
> > From: Jianbo Liu
> > Sent: Wednesday, June 19, 2019 10:42 AM
> > To: Parav Pandit <parav@mellanox.com>
> > Cc: Saeed Mahameed <saeedm@mellanox.com>; Leon Romanovsky
> > <leonro@mellanox.com>; netdev@vger.kernel.org; linux-
> > rdma@vger.kernel.org; Eli Britstein <elibr@mellanox.com>; Roi Dayan
> > <roid@mellanox.com>; Mark Bloch <markb@mellanox.com>
> > Subject: Re: [PATCH mlx5-next 05/15] net/mlx5: E-Switch, Tag packet with
> > vport number in VF vports and uplink ingress ACLs
> >
> > The 06/18/2019 18:31, Parav Pandit wrote:
> > >
> > >
> > > > -----Original Message-----
> > > > From: netdev-owner@vger.kernel.org <netdev-owner@vger.kernel.org> On
> > > > Behalf Of Saeed Mahameed
> > > > Sent: Tuesday, June 18, 2019 12:53 AM
> > > > To: Saeed Mahameed <saeedm@mellanox.com>; Leon Romanovsky
> > > > <leonro@mellanox.com>
> > > > Cc: netdev@vger.kernel.org; linux-rdma@vger.kernel.org; Jianbo Liu
> > > > <jianbol@mellanox.com>; Eli Britstein <elibr@mellanox.com>; Roi
> > > > Dayan <roid@mellanox.com>; Mark Bloch <markb@mellanox.com>
> > > > Subject: [PATCH mlx5-next 05/15] net/mlx5: E-Switch, Tag packet with
> > > > vport number in VF vports and uplink ingress ACLs
> > > >
> > > > From: Jianbo Liu <jianbol@mellanox.com>
> > > >
> > > > When a dual-port VHCA sends a RoCE packet on its non-native port,
> > > > and the packet arrives to its affiliated vport FDB, a mismatch might
> > > > occur on the rules that match the packet source vport as it is not
> > > > represented by single VHCA only in this case. So we change to match on
> > metadata instead of source vport.
> > > > To do that, a rule is created in all vports and uplink ingress ACLs,
> > > > to save the source vport number and vhca id in the packet's metadata
> > > > in order to match on it later.
> > > > The metadata register used is the first of the 32-bit type C
> > > > registers. It can be used for matching and header modify operations.
> > > > The higher 16 bits of this register are for vhca id, and the lower 16 ones is
> > for vport number.
> > > > This change is not for dual-port RoCE only. If HW and FW allow, the
> > > > vport metadata matching is enabled by default.
> > > >
> > > > Signed-off-by: Jianbo Liu <jianbol@mellanox.com>
> > > > Reviewed-by: Eli Britstein <elibr@mellanox.com>
> > > > Reviewed-by: Roi Dayan <roid@mellanox.com>
> > > > Reviewed-by: Mark Bloch <markb@mellanox.com>
> > > > Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
> > > > ---
> > > > .../net/ethernet/mellanox/mlx5/core/eswitch.c | 2 +
> > > > .../net/ethernet/mellanox/mlx5/core/eswitch.h | 9 +
> > > > .../mellanox/mlx5/core/eswitch_offloads.c | 183 ++++++++++++++----
> > > > include/linux/mlx5/eswitch.h | 3 +
> > > > 4 files changed, 161 insertions(+), 36 deletions(-)
> > > >
> > > > diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
> > > > b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
> > > > index a42a23e505df..1235fd84ae3a 100644
> > > > --- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
> > > > +++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
> > > > @@ -1168,6 +1168,8 @@ void esw_vport_cleanup_ingress_rules(struct
> > > > mlx5_eswitch *esw,
> > > >
> > > > vport->ingress.drop_rule = NULL;
> > > > vport->ingress.allow_rule = NULL;
> > > > +
> > > > + esw_vport_del_ingress_acl_modify_metadata(esw, vport);
> > > > }
> > > >
> > > > void esw_vport_disable_ingress_acl(struct mlx5_eswitch *esw, diff
> > > > --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
> > > > b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
> > > > index 8b9f2cf58e91..4417a195832e 100644
> > > > --- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
> > > > +++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
> > > > @@ -68,6 +68,8 @@ struct vport_ingress {
> > > > struct mlx5_flow_group *allow_spoofchk_only_grp;
> > > > struct mlx5_flow_group *allow_untagged_only_grp;
> > > > struct mlx5_flow_group *drop_grp;
> > > > + int modify_metadata_id;
> > > No need for random alignment. Just have one white space after int.
> >
> > Not random. It's to align with other lines in the this structure.
> > There are also other fileds with more than one spaces after type.
> > It looks ugly if there are different styles in the same structure.
> >
> Whatever was done in past was done.
> There will be mixed alignment anyway.
>
> > >
> > > > + struct mlx5_flow_handle *modify_metadata_rule;
> > > > struct mlx5_flow_handle *allow_rule;
> > > > struct mlx5_flow_handle *drop_rule;
> > > > struct mlx5_fc *drop_counter;
> > > > @@ -196,6 +198,10 @@ struct mlx5_esw_functions {
> > > > u16 num_vfs;
> > > > };
> > > >
> > > > +enum {
> > > > + MLX5_ESWITCH_VPORT_MATCH_METADATA = BIT(0), };
> > > > +
> > > > struct mlx5_eswitch {
> > > > struct mlx5_core_dev *dev;
> > > > struct mlx5_nb nb;
> > > > @@ -203,6 +209,7 @@ struct mlx5_eswitch {
> > > > struct hlist_head mc_table[MLX5_L2_ADDR_HASH_SIZE];
> > > > struct workqueue_struct *work_queue;
> > > > struct mlx5_vport *vports;
> > > > + u32 flags;
> > > Same as above, no need for extra aligment.
> >
> > Same reason.
> >
> > >
> > > > int total_vports;
> > > > int enabled_vports;
> > > > /* Synchronize between vport change events @@ -240,6 +247,8 @@
> > > > void esw_vport_disable_egress_acl(struct mlx5_eswitch *esw,
> > > > struct mlx5_vport *vport);
> > > > void esw_vport_disable_ingress_acl(struct mlx5_eswitch *esw,
> > > > struct mlx5_vport *vport);
> > > > +void esw_vport_del_ingress_acl_modify_metadata(struct mlx5_eswitch
> > *esw,
> > > > + struct mlx5_vport *vport);
> > > >
> > > > /* E-Switch API */
> > > > int mlx5_eswitch_init(struct mlx5_core_dev *dev); diff --git
> > > > a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
> > > > b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
> > > > index 17abb98b48af..871ae44dc132 100644
> > > > --- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
> > > > +++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
> >
> > ...
> >
> > > > +static int esw_create_offloads_acl_tables(struct mlx5_eswitch *esw) {
> > > > + struct mlx5_vport *vport;
> > > > + int i, j;
> > > > + int err;
> > > > +
> > > > + mlx5_esw_for_all_vports(esw, i, vport) {
> > > > + err = esw_vport_ingress_common_config(esw, vport);
> > > > if (err)
> > > > - goto err_egress;
> > > > + goto err_ingress;
> > > > +
> > > > + if (vport->vport >= MLX5_VPORT_FIRST_VF &&
> > > > + vport->vport <= esw->dev->priv.sriov.num_vfs) {
> > > Add an helper API mlx5_esw_is_vport(const struct mlx5_esw *esw, const
> > > struct mlx5_vport *vport) and use at two places in ingress and egress config.
> >
> > It's very simple logic, but new API make things complicated.
>
> No. it doesn't. Right API name is,
> mlx5_esw_is_vf_vport().
> mlx5_esw_is_vf_rep()...
> etc.
>
> > If adding mlx5_esw_is_vport() as you suggested, no one can know what's the meaning of
> > this function from name, and need to check the implementation again, which
> > will waste too much time.
> >
> mlx5_esw_is_vf_vport() is self-explanatory name which won't waste time.
>
> I am already having this API in my two series, but since yours is already out, it make sense to introduce in this patch.
Could you please send me? I will add to this series. Thanks!
--
^ permalink raw reply
* [PATCH net-next 8/8] selftests: tc: add ingress device matching support
From: Ido Schimmel @ 2019-06-19 6:41 UTC (permalink / raw)
To: netdev
Cc: davem, jiri, jhs, xiyou.wangcong, pablo, ecree, jakub.kicinski,
Ido Schimmel
In-Reply-To: <20190619064109.849-1-idosch@idosch.org>
From: Jiri Pirko <jiri@mellanox.com>
Extend tc_flower to test plain ingress device matching and also
tc_shblock to test ingress device matching on shared block.
Add new tc_flower_router.sh where ingress device matching on egress
(after routing) is done.
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
---
.../selftests/net/forwarding/tc_flower.sh | 26 ++-
.../net/forwarding/tc_flower_router.sh | 172 ++++++++++++++++++
.../selftests/net/forwarding/tc_shblocks.sh | 29 ++-
3 files changed, 225 insertions(+), 2 deletions(-)
create mode 100755 tools/testing/selftests/net/forwarding/tc_flower_router.sh
diff --git a/tools/testing/selftests/net/forwarding/tc_flower.sh b/tools/testing/selftests/net/forwarding/tc_flower.sh
index 124803eea4a9..058c746ee300 100755
--- a/tools/testing/selftests/net/forwarding/tc_flower.sh
+++ b/tools/testing/selftests/net/forwarding/tc_flower.sh
@@ -3,7 +3,7 @@
ALL_TESTS="match_dst_mac_test match_src_mac_test match_dst_ip_test \
match_src_ip_test match_ip_flags_test match_pcp_test match_vlan_test \
- match_ip_tos_test"
+ match_ip_tos_test match_indev_test"
NUM_NETIFS=2
source tc_common.sh
source lib.sh
@@ -310,6 +310,30 @@ match_ip_tos_test()
log_test "ip_tos match ($tcflags)"
}
+match_indev_test()
+{
+ RET=0
+
+ tc filter add dev $h2 ingress protocol ip pref 1 handle 101 flower \
+ $tcflags indev $h1 dst_mac $h2mac action drop
+ tc filter add dev $h2 ingress protocol ip pref 2 handle 102 flower \
+ $tcflags indev $h2 dst_mac $h2mac action drop
+
+ $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \
+ -t ip -q
+
+ tc_check_packets "dev $h2 ingress" 101 1
+ check_fail $? "Matched on a wrong filter"
+
+ tc_check_packets "dev $h2 ingress" 102 1
+ check_err $? "Did not match on correct filter"
+
+ tc filter del dev $h2 ingress protocol ip pref 2 handle 102 flower
+ tc filter del dev $h2 ingress protocol ip pref 1 handle 101 flower
+
+ log_test "indev match ($tcflags)"
+}
+
setup_prepare()
{
h1=${NETIFS[p1]}
diff --git a/tools/testing/selftests/net/forwarding/tc_flower_router.sh b/tools/testing/selftests/net/forwarding/tc_flower_router.sh
new file mode 100755
index 000000000000..4aee9c9e69f6
--- /dev/null
+++ b/tools/testing/selftests/net/forwarding/tc_flower_router.sh
@@ -0,0 +1,172 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0
+
+ALL_TESTS="match_indev_egress_test"
+NUM_NETIFS=6
+source tc_common.sh
+source lib.sh
+
+h1_create()
+{
+ simple_if_init $h1 192.0.1.1/24
+
+ ip route add 192.0.2.0/24 vrf v$h1 nexthop via 192.0.1.2
+ ip route add 192.0.3.0/24 vrf v$h1 nexthop via 192.0.1.2
+}
+
+h1_destroy()
+{
+ ip route del 192.0.3.0/24 vrf v$h1
+ ip route del 192.0.2.0/24 vrf v$h1
+
+ simple_if_fini $h1 192.0.1.1/24
+}
+
+h2_create()
+{
+ simple_if_init $h2 192.0.2.1/24
+
+ ip route add 192.0.1.0/24 vrf v$h2 nexthop via 192.0.2.2
+ ip route add 192.0.3.0/24 vrf v$h2 nexthop via 192.0.2.2
+}
+
+h2_destroy()
+{
+ ip route del 192.0.3.0/24 vrf v$h2
+ ip route del 192.0.1.0/24 vrf v$h2
+
+ simple_if_fini $h2 192.0.2.1/24
+}
+
+h3_create()
+{
+ simple_if_init $h3 192.0.3.1/24
+
+ ip route add 192.0.1.0/24 vrf v$h3 nexthop via 192.0.3.2
+ ip route add 192.0.2.0/24 vrf v$h3 nexthop via 192.0.3.2
+}
+
+h3_destroy()
+{
+ ip route del 192.0.2.0/24 vrf v$h3
+ ip route del 192.0.1.0/24 vrf v$h3
+
+ simple_if_fini $h3 192.0.3.1/24
+}
+
+
+router_create()
+{
+ ip link set dev $rp1 up
+ ip link set dev $rp2 up
+ ip link set dev $rp3 up
+
+ tc qdisc add dev $rp3 clsact
+
+ ip address add 192.0.1.2/24 dev $rp1
+ ip address add 192.0.2.2/24 dev $rp2
+ ip address add 192.0.3.2/24 dev $rp3
+}
+
+router_destroy()
+{
+ ip address del 192.0.3.2/24 dev $rp3
+ ip address del 192.0.2.2/24 dev $rp2
+ ip address del 192.0.1.2/24 dev $rp1
+
+ tc qdisc del dev $rp3 clsact
+
+ ip link set dev $rp3 down
+ ip link set dev $rp2 down
+ ip link set dev $rp1 down
+}
+
+match_indev_egress_test()
+{
+ RET=0
+
+ tc filter add dev $rp3 egress protocol ip pref 1 handle 101 flower \
+ $tcflags indev $rp1 dst_ip 192.0.3.1 action drop
+ tc filter add dev $rp3 egress protocol ip pref 2 handle 102 flower \
+ $tcflags indev $rp2 dst_ip 192.0.3.1 action drop
+
+ $MZ $h1 -c 1 -p 64 -a $h1mac -b $rp1mac -A 192.0.1.1 -B 192.0.3.1 \
+ -t ip -q
+
+ tc_check_packets "dev $rp3 egress" 102 1
+ check_fail $? "Matched on a wrong filter"
+
+ tc_check_packets "dev $rp3 egress" 101 1
+ check_err $? "Did not match on correct filter"
+
+ $MZ $h2 -c 1 -p 64 -a $h2mac -b $rp2mac -A 192.0.2.1 -B 192.0.3.1 \
+ -t ip -q
+
+ tc_check_packets "dev $rp3 egress" 101 2
+ check_fail $? "Matched on a wrong filter"
+
+ tc_check_packets "dev $rp3 egress" 102 1
+ check_err $? "Did not match on correct filter"
+
+ tc filter del dev $rp3 egress protocol ip pref 2 handle 102 flower
+ tc filter del dev $rp3 egress protocol ip pref 1 handle 101 flower
+
+ log_test "indev egress match ($tcflags)"
+}
+
+setup_prepare()
+{
+ h1=${NETIFS[p1]}
+ rp1=${NETIFS[p2]}
+
+ h2=${NETIFS[p3]}
+ rp2=${NETIFS[p4]}
+
+ h3=${NETIFS[p5]}
+ rp3=${NETIFS[p6]}
+
+ h1mac=$(mac_get $h1)
+ rp1mac=$(mac_get $rp1)
+ h2mac=$(mac_get $h2)
+ rp2mac=$(mac_get $rp2)
+
+ vrf_prepare
+
+ h1_create
+ h2_create
+ h3_create
+
+ router_create
+
+ forwarding_enable
+}
+
+cleanup()
+{
+ pre_cleanup
+
+ forwarding_restore
+
+ router_destroy
+
+ h3_destroy
+ h2_destroy
+ h1_destroy
+
+ vrf_cleanup
+}
+
+trap cleanup EXIT
+
+setup_prepare
+setup_wait
+
+tc_offload_check
+if [[ $? -ne 0 ]]; then
+ log_info "Could not test offloaded functionality"
+else
+ tcflags="skip_sw"
+ tests_run
+fi
+
+exit $EXIT_STATUS
diff --git a/tools/testing/selftests/net/forwarding/tc_shblocks.sh b/tools/testing/selftests/net/forwarding/tc_shblocks.sh
index 9826a446e2c0..772e00ac3230 100755
--- a/tools/testing/selftests/net/forwarding/tc_shblocks.sh
+++ b/tools/testing/selftests/net/forwarding/tc_shblocks.sh
@@ -1,7 +1,7 @@
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
-ALL_TESTS="shared_block_test"
+ALL_TESTS="shared_block_test match_indev_test"
NUM_NETIFS=4
source tc_common.sh
source lib.sh
@@ -70,6 +70,33 @@ shared_block_test()
log_test "shared block ($tcflags)"
}
+match_indev_test()
+{
+ RET=0
+
+ tc filter add block 22 protocol ip pref 1 handle 101 flower \
+ $tcflags indev $swp1 dst_mac $swmac action drop
+ tc filter add block 22 protocol ip pref 2 handle 102 flower \
+ $tcflags indev $swp2 dst_mac $swmac action drop
+
+ $MZ $h1 -c 1 -p 64 -a $h1mac -b $swmac -A 192.0.2.1 -B 192.0.2.2 \
+ -t ip -q
+
+ tc_check_packets "block 22" 101 1
+ check_err $? "Did not match first incoming packet on a block"
+
+ $MZ $h2 -c 1 -p 64 -a $h2mac -b $swmac -A 192.0.2.1 -B 192.0.2.2 \
+ -t ip -q
+
+ tc_check_packets "block 22" 102 1
+ check_err $? "Did not match second incoming packet on a block"
+
+ tc filter del block 22 protocol ip pref 1 handle 101 flower
+ tc filter del block 22 protocol ip pref 2 handle 102 flower
+
+ log_test "indev match ($tcflags)"
+}
+
setup_prepare()
{
h1=${NETIFS[p1]}
--
2.20.1
^ permalink raw reply related
* [PATCH net-next 7/8] mlxsw: spectrum_flower: Implement support for ingress device matching
From: Ido Schimmel @ 2019-06-19 6:41 UTC (permalink / raw)
To: netdev
Cc: davem, jiri, jhs, xiyou.wangcong, pablo, ecree, jakub.kicinski,
Ido Schimmel
In-Reply-To: <20190619064109.849-1-idosch@idosch.org>
From: Jiri Pirko <jiri@mellanox.com>
Benefit from the previously extended flow_dissector infrastructure and
offload matching on ingress port.
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
---
.../net/ethernet/mellanox/mlxsw/spectrum.h | 9 ++++
.../ethernet/mellanox/mlxsw/spectrum_acl.c | 9 +---
.../ethernet/mellanox/mlxsw/spectrum_flower.c | 50 ++++++++++++++++++-
3 files changed, 59 insertions(+), 9 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.h b/drivers/net/ethernet/mellanox/mlxsw/spectrum.h
index ea4d56486ea3..84f4276193b3 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.h
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.h
@@ -623,6 +623,15 @@ enum mlxsw_sp_acl_profile {
MLXSW_SP_ACL_PROFILE_MR,
};
+struct mlxsw_sp_acl_block {
+ struct list_head binding_list;
+ struct mlxsw_sp_acl_ruleset *ruleset_zero;
+ struct mlxsw_sp *mlxsw_sp;
+ unsigned int rule_count;
+ unsigned int disable_count;
+ struct net *net;
+};
+
struct mlxsw_afk *mlxsw_sp_acl_afk(struct mlxsw_sp_acl *acl);
struct mlxsw_sp *mlxsw_sp_acl_block_mlxsw_sp(struct mlxsw_sp_acl_block *block);
unsigned int mlxsw_sp_acl_block_rule_count(struct mlxsw_sp_acl_block *block);
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl.c
index a146a44634e9..e8ac90564dbe 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl.c
@@ -45,14 +45,6 @@ struct mlxsw_sp_acl_block_binding {
bool ingress;
};
-struct mlxsw_sp_acl_block {
- struct list_head binding_list;
- struct mlxsw_sp_acl_ruleset *ruleset_zero;
- struct mlxsw_sp *mlxsw_sp;
- unsigned int rule_count;
- unsigned int disable_count;
-};
-
struct mlxsw_sp_acl_ruleset_ht_key {
struct mlxsw_sp_acl_block *block;
u32 chain_index;
@@ -221,6 +213,7 @@ struct mlxsw_sp_acl_block *mlxsw_sp_acl_block_create(struct mlxsw_sp *mlxsw_sp,
return NULL;
INIT_LIST_HEAD(&block->binding_list);
block->mlxsw_sp = mlxsw_sp;
+ block->net = net;
return block;
}
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c
index 96b23c856f4d..a83e1a986ef1 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c
@@ -120,6 +120,49 @@ static int mlxsw_sp_flower_parse_actions(struct mlxsw_sp *mlxsw_sp,
return 0;
}
+static int mlxsw_sp_flower_parse_meta(struct mlxsw_sp_acl_rule_info *rulei,
+ struct tc_cls_flower_offload *f,
+ struct mlxsw_sp_acl_block *block)
+{
+ struct flow_rule *rule = tc_cls_flower_offload_flow_rule(f);
+ struct mlxsw_sp_port *mlxsw_sp_port;
+ struct net_device *ingress_dev;
+ struct flow_match_meta match;
+
+ if (!flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_META))
+ return 0;
+
+ flow_rule_match_meta(rule, &match);
+ if (match.mask->ingress_ifindex != 0xFFFFFFFF) {
+ NL_SET_ERR_MSG_MOD(f->common.extack, "Unsupported ingress ifindex mask");
+ return -EINVAL;
+ }
+
+ ingress_dev = __dev_get_by_index(block->net,
+ match.key->ingress_ifindex);
+ if (!ingress_dev) {
+ NL_SET_ERR_MSG_MOD(f->common.extack, "Can't find specified ingress port to match on");
+ return -EINVAL;
+ }
+
+ if (!mlxsw_sp_port_dev_check(ingress_dev)) {
+ NL_SET_ERR_MSG_MOD(f->common.extack, "Can't match on non-mlxsw ingress port");
+ return -EINVAL;
+ }
+
+ mlxsw_sp_port = netdev_priv(ingress_dev);
+ if (mlxsw_sp_port->mlxsw_sp != block->mlxsw_sp) {
+ NL_SET_ERR_MSG_MOD(f->common.extack, "Can't match on a port from different device");
+ return -EINVAL;
+ }
+
+ mlxsw_sp_acl_rulei_keymask_u32(rulei,
+ MLXSW_AFK_ELEMENT_SRC_SYS_PORT,
+ mlxsw_sp_port->local_port,
+ 0xFFFFFFFF);
+ return 0;
+}
+
static void mlxsw_sp_flower_parse_ipv4(struct mlxsw_sp_acl_rule_info *rulei,
struct tc_cls_flower_offload *f)
{
@@ -267,7 +310,8 @@ static int mlxsw_sp_flower_parse(struct mlxsw_sp *mlxsw_sp,
int err;
if (dissector->used_keys &
- ~(BIT(FLOW_DISSECTOR_KEY_CONTROL) |
+ ~(BIT(FLOW_DISSECTOR_KEY_META) |
+ BIT(FLOW_DISSECTOR_KEY_CONTROL) |
BIT(FLOW_DISSECTOR_KEY_BASIC) |
BIT(FLOW_DISSECTOR_KEY_ETH_ADDRS) |
BIT(FLOW_DISSECTOR_KEY_IPV4_ADDRS) |
@@ -283,6 +327,10 @@ static int mlxsw_sp_flower_parse(struct mlxsw_sp *mlxsw_sp,
mlxsw_sp_acl_rulei_priority(rulei, f->common.prio);
+ err = mlxsw_sp_flower_parse_meta(rulei, f, block);
+ if (err)
+ return err;
+
if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_CONTROL)) {
struct flow_match_control match;
--
2.20.1
^ permalink raw reply related
* [PATCH net-next 6/8] mlxsw: spectrum_acl: Fix SRC_SYS_PORT element size
From: Ido Schimmel @ 2019-06-19 6:41 UTC (permalink / raw)
To: netdev
Cc: davem, jiri, jhs, xiyou.wangcong, pablo, ecree, jakub.kicinski,
Ido Schimmel
In-Reply-To: <20190619064109.849-1-idosch@idosch.org>
From: Jiri Pirko <jiri@mellanox.com>
Fix the size of the SRC_SYS_PORT element to be 16.
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
---
drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_keys.h | 2 +-
.../net/ethernet/mellanox/mlxsw/spectrum_acl_flex_keys.c | 8 ++++----
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_keys.h b/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_keys.h
index d99a70eec357..cb229b55ecc4 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_keys.h
+++ b/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_keys.h
@@ -74,7 +74,7 @@ struct mlxsw_afk_element_info {
* define an internal storage geometry.
*/
static const struct mlxsw_afk_element_info mlxsw_afk_element_infos[] = {
- MLXSW_AFK_ELEMENT_INFO_U32(SRC_SYS_PORT, 0x00, 16, 8),
+ MLXSW_AFK_ELEMENT_INFO_U32(SRC_SYS_PORT, 0x00, 16, 16),
MLXSW_AFK_ELEMENT_INFO_BUF(DMAC_32_47, 0x04, 2),
MLXSW_AFK_ELEMENT_INFO_BUF(DMAC_0_31, 0x06, 4),
MLXSW_AFK_ELEMENT_INFO_BUF(SMAC_32_47, 0x0A, 2),
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_flex_keys.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_flex_keys.c
index 96fc981ed851..279c241f76f0 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_flex_keys.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_flex_keys.c
@@ -12,7 +12,7 @@ static struct mlxsw_afk_element_inst mlxsw_sp_afk_element_info_l2_dmac[] = {
MLXSW_AFK_ELEMENT_INST_BUF(DMAC_0_31, 0x02, 4),
MLXSW_AFK_ELEMENT_INST_U32(PCP, 0x08, 13, 3),
MLXSW_AFK_ELEMENT_INST_U32(VID, 0x08, 0, 12),
- MLXSW_AFK_ELEMENT_INST_U32(SRC_SYS_PORT, 0x0C, 0, 8),
+ MLXSW_AFK_ELEMENT_INST_U32(SRC_SYS_PORT, 0x0C, 0, 16),
};
static struct mlxsw_afk_element_inst mlxsw_sp_afk_element_info_l2_smac[] = {
@@ -20,7 +20,7 @@ static struct mlxsw_afk_element_inst mlxsw_sp_afk_element_info_l2_smac[] = {
MLXSW_AFK_ELEMENT_INST_BUF(SMAC_0_31, 0x02, 4),
MLXSW_AFK_ELEMENT_INST_U32(PCP, 0x08, 13, 3),
MLXSW_AFK_ELEMENT_INST_U32(VID, 0x08, 0, 12),
- MLXSW_AFK_ELEMENT_INST_U32(SRC_SYS_PORT, 0x0C, 0, 8),
+ MLXSW_AFK_ELEMENT_INST_U32(SRC_SYS_PORT, 0x0C, 0, 16),
};
static struct mlxsw_afk_element_inst mlxsw_sp_afk_element_info_l2_smac_ex[] = {
@@ -32,13 +32,13 @@ static struct mlxsw_afk_element_inst mlxsw_sp_afk_element_info_l2_smac_ex[] = {
static struct mlxsw_afk_element_inst mlxsw_sp_afk_element_info_ipv4_sip[] = {
MLXSW_AFK_ELEMENT_INST_BUF(SRC_IP_0_31, 0x00, 4),
MLXSW_AFK_ELEMENT_INST_U32(IP_PROTO, 0x08, 0, 8),
- MLXSW_AFK_ELEMENT_INST_U32(SRC_SYS_PORT, 0x0C, 0, 8),
+ MLXSW_AFK_ELEMENT_INST_U32(SRC_SYS_PORT, 0x0C, 0, 16),
};
static struct mlxsw_afk_element_inst mlxsw_sp_afk_element_info_ipv4_dip[] = {
MLXSW_AFK_ELEMENT_INST_BUF(DST_IP_0_31, 0x00, 4),
MLXSW_AFK_ELEMENT_INST_U32(IP_PROTO, 0x08, 0, 8),
- MLXSW_AFK_ELEMENT_INST_U32(SRC_SYS_PORT, 0x0C, 0, 8),
+ MLXSW_AFK_ELEMENT_INST_U32(SRC_SYS_PORT, 0x0C, 0, 16),
};
static struct mlxsw_afk_element_inst mlxsw_sp_afk_element_info_ipv4[] = {
--
2.20.1
^ permalink raw reply related
* [PATCH net-next 5/8] mlxsw: spectrum_acl: Avoid size check for RX_ACL_SYSTEM_PORT element
From: Ido Schimmel @ 2019-06-19 6:41 UTC (permalink / raw)
To: netdev
Cc: davem, jiri, jhs, xiyou.wangcong, pablo, ecree, jakub.kicinski,
Ido Schimmel
In-Reply-To: <20190619064109.849-1-idosch@idosch.org>
From: Jiri Pirko <jiri@mellanox.com>
RX_ACL_SYSTEM_PORT is 8 bit but SRC_SYS_PORT is 16 bits. Internally,
SRC_SYS_PORT is used to carry the value. Relax the checker in case of
RX_ACL_SYSTEM_PORT and allow different size.
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
---
.../ethernet/mellanox/mlxsw/core_acl_flex_keys.c | 5 +++--
.../ethernet/mellanox/mlxsw/core_acl_flex_keys.h | 14 +++++++++-----
.../mellanox/mlxsw/spectrum_acl_flex_keys.c | 2 +-
3 files changed, 13 insertions(+), 8 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_keys.c b/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_keys.c
index f6e44ca50cae..feb4672a5ac0 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_keys.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_keys.c
@@ -30,8 +30,9 @@ static bool mlxsw_afk_blocks_check(struct mlxsw_afk *mlxsw_afk)
elinst = &block->instances[j];
if (elinst->type != elinst->info->type ||
- elinst->item.size.bits !=
- elinst->info->item.size.bits)
+ (!elinst->avoid_size_check &&
+ elinst->item.size.bits !=
+ elinst->info->item.size.bits))
return false;
}
}
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_keys.h b/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_keys.h
index 78495826ff17..d99a70eec357 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_keys.h
+++ b/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_keys.h
@@ -110,10 +110,11 @@ struct mlxsw_afk_element_inst { /* element instance in actual block */
int u32_key_diff; /* in case value needs to be adjusted before write
* this diff is here to handle that
*/
+ bool avoid_size_check;
};
#define MLXSW_AFK_ELEMENT_INST(_type, _element, _offset, \
- _shift, _size, _u32_key_diff) \
+ _shift, _size, _u32_key_diff, _avoid_size_check) \
{ \
.info = &mlxsw_afk_element_infos[MLXSW_AFK_ELEMENT_##_element], \
.type = _type, \
@@ -124,20 +125,23 @@ struct mlxsw_afk_element_inst { /* element instance in actual block */
.name = #_element, \
}, \
.u32_key_diff = _u32_key_diff, \
+ .avoid_size_check = _avoid_size_check, \
}
#define MLXSW_AFK_ELEMENT_INST_U32(_element, _offset, _shift, _size) \
MLXSW_AFK_ELEMENT_INST(MLXSW_AFK_ELEMENT_TYPE_U32, \
- _element, _offset, _shift, _size, 0)
+ _element, _offset, _shift, _size, 0, false)
#define MLXSW_AFK_ELEMENT_INST_EXT_U32(_element, _offset, \
- _shift, _size, _key_diff) \
+ _shift, _size, _key_diff, \
+ _avoid_size_check) \
MLXSW_AFK_ELEMENT_INST(MLXSW_AFK_ELEMENT_TYPE_U32, \
- _element, _offset, _shift, _size, _key_diff)
+ _element, _offset, _shift, _size, \
+ _key_diff, _avoid_size_check)
#define MLXSW_AFK_ELEMENT_INST_BUF(_element, _offset, _size) \
MLXSW_AFK_ELEMENT_INST(MLXSW_AFK_ELEMENT_TYPE_BUF, \
- _element, _offset, 0, _size, 0)
+ _element, _offset, 0, _size, 0, false)
struct mlxsw_afk_block {
u16 encoding; /* block ID */
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_flex_keys.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_flex_keys.c
index 682c19e220fa..96fc981ed851 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_flex_keys.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_flex_keys.c
@@ -149,7 +149,7 @@ static struct mlxsw_afk_element_inst mlxsw_sp_afk_element_info_mac_4[] = {
static struct mlxsw_afk_element_inst mlxsw_sp_afk_element_info_mac_5[] = {
MLXSW_AFK_ELEMENT_INST_U32(VID, 0x04, 16, 12),
- MLXSW_AFK_ELEMENT_INST_EXT_U32(SRC_SYS_PORT, 0x04, 0, 8, -1), /* RX_ACL_SYSTEM_PORT */
+ MLXSW_AFK_ELEMENT_INST_EXT_U32(SRC_SYS_PORT, 0x04, 0, 8, -1, true), /* RX_ACL_SYSTEM_PORT */
};
static struct mlxsw_afk_element_inst mlxsw_sp_afk_element_info_ipv4_0[] = {
--
2.20.1
^ permalink raw reply related
* [PATCH net-next 4/8] mlxsw: spectrum_acl: Write RX_ACL_SYSTEM_PORT acl element correctly
From: Ido Schimmel @ 2019-06-19 6:41 UTC (permalink / raw)
To: netdev
Cc: davem, jiri, jhs, xiyou.wangcong, pablo, ecree, jakub.kicinski,
Ido Schimmel
In-Reply-To: <20190619064109.849-1-idosch@idosch.org>
From: Jiri Pirko <jiri@mellanox.com>
RX_ACL_SYSTEM_PORT is equal to SRC_SYS_PORT - 1. So before write to
block we need to adjust the key value. Introduce new "EXT" helper to
implement this.
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
---
.../ethernet/mellanox/mlxsw/core_acl_flex_keys.c | 13 +++++++------
.../ethernet/mellanox/mlxsw/core_acl_flex_keys.h | 16 +++++++++++++---
.../mellanox/mlxsw/spectrum_acl_flex_keys.c | 2 +-
3 files changed, 21 insertions(+), 10 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_keys.c b/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_keys.c
index cb3e663b1d37..f6e44ca50cae 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_keys.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_keys.c
@@ -385,12 +385,12 @@ EXPORT_SYMBOL(mlxsw_afk_values_add_buf);
static void mlxsw_sp_afk_encode_u32(const struct mlxsw_item *storage_item,
const struct mlxsw_item *output_item,
- char *storage, char *output)
+ char *storage, char *output, int diff)
{
u32 value;
value = __mlxsw_item_get32(storage, storage_item, 0);
- __mlxsw_item_set32(output, output_item, 0, value);
+ __mlxsw_item_set32(output, output_item, 0, value + diff);
}
static void mlxsw_sp_afk_encode_buf(const struct mlxsw_item *storage_item,
@@ -406,14 +406,14 @@ static void mlxsw_sp_afk_encode_buf(const struct mlxsw_item *storage_item,
static void
mlxsw_sp_afk_encode_one(const struct mlxsw_afk_element_inst *elinst,
- char *output, char *storage)
+ char *output, char *storage, int u32_diff)
{
const struct mlxsw_item *storage_item = &elinst->info->item;
const struct mlxsw_item *output_item = &elinst->item;
if (elinst->type == MLXSW_AFK_ELEMENT_TYPE_U32)
mlxsw_sp_afk_encode_u32(storage_item, output_item,
- storage, output);
+ storage, output, u32_diff);
else if (elinst->type == MLXSW_AFK_ELEMENT_TYPE_BUF)
mlxsw_sp_afk_encode_buf(storage_item, output_item,
storage, output);
@@ -446,9 +446,10 @@ void mlxsw_afk_encode(struct mlxsw_afk *mlxsw_afk,
continue;
mlxsw_sp_afk_encode_one(elinst, block_key,
- values->storage.key);
+ values->storage.key,
+ elinst->u32_key_diff);
mlxsw_sp_afk_encode_one(elinst, block_mask,
- values->storage.mask);
+ values->storage.mask, 0);
}
mlxsw_afk->ops->encode_block(key, i, block_key);
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_keys.h b/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_keys.h
index 4a625cdf3e7c..78495826ff17 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_keys.h
+++ b/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_keys.h
@@ -107,9 +107,13 @@ struct mlxsw_afk_element_inst { /* element instance in actual block */
const struct mlxsw_afk_element_info *info;
enum mlxsw_afk_element_type type;
struct mlxsw_item item; /* element geometry in block */
+ int u32_key_diff; /* in case value needs to be adjusted before write
+ * this diff is here to handle that
+ */
};
-#define MLXSW_AFK_ELEMENT_INST(_type, _element, _offset, _shift, _size) \
+#define MLXSW_AFK_ELEMENT_INST(_type, _element, _offset, \
+ _shift, _size, _u32_key_diff) \
{ \
.info = &mlxsw_afk_element_infos[MLXSW_AFK_ELEMENT_##_element], \
.type = _type, \
@@ -119,15 +123,21 @@ struct mlxsw_afk_element_inst { /* element instance in actual block */
.size = {.bits = _size}, \
.name = #_element, \
}, \
+ .u32_key_diff = _u32_key_diff, \
}
#define MLXSW_AFK_ELEMENT_INST_U32(_element, _offset, _shift, _size) \
MLXSW_AFK_ELEMENT_INST(MLXSW_AFK_ELEMENT_TYPE_U32, \
- _element, _offset, _shift, _size)
+ _element, _offset, _shift, _size, 0)
+
+#define MLXSW_AFK_ELEMENT_INST_EXT_U32(_element, _offset, \
+ _shift, _size, _key_diff) \
+ MLXSW_AFK_ELEMENT_INST(MLXSW_AFK_ELEMENT_TYPE_U32, \
+ _element, _offset, _shift, _size, _key_diff)
#define MLXSW_AFK_ELEMENT_INST_BUF(_element, _offset, _size) \
MLXSW_AFK_ELEMENT_INST(MLXSW_AFK_ELEMENT_TYPE_BUF, \
- _element, _offset, 0, _size)
+ _element, _offset, 0, _size, 0)
struct mlxsw_afk_block {
u16 encoding; /* block ID */
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_flex_keys.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_flex_keys.c
index 2a998dea4f39..682c19e220fa 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_flex_keys.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_flex_keys.c
@@ -149,7 +149,7 @@ static struct mlxsw_afk_element_inst mlxsw_sp_afk_element_info_mac_4[] = {
static struct mlxsw_afk_element_inst mlxsw_sp_afk_element_info_mac_5[] = {
MLXSW_AFK_ELEMENT_INST_U32(VID, 0x04, 16, 12),
- MLXSW_AFK_ELEMENT_INST_U32(SRC_SYS_PORT, 0x04, 0, 8), /* RX_ACL_SYSTEM_PORT */
+ MLXSW_AFK_ELEMENT_INST_EXT_U32(SRC_SYS_PORT, 0x04, 0, 8, -1), /* RX_ACL_SYSTEM_PORT */
};
static struct mlxsw_afk_element_inst mlxsw_sp_afk_element_info_ipv4_0[] = {
--
2.20.1
^ permalink raw reply related
* [PATCH net-next 3/8] net: flow_offload: implement support for meta key
From: Ido Schimmel @ 2019-06-19 6:41 UTC (permalink / raw)
To: netdev
Cc: davem, jiri, jhs, xiyou.wangcong, pablo, ecree, jakub.kicinski,
Ido Schimmel
In-Reply-To: <20190619064109.849-1-idosch@idosch.org>
From: Jiri Pirko <jiri@mellanox.com>
Implement support for previously added flow dissector meta key.
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
---
include/net/flow_offload.h | 6 ++++++
net/core/flow_offload.c | 7 +++++++
2 files changed, 13 insertions(+)
diff --git a/include/net/flow_offload.h b/include/net/flow_offload.h
index 36fdb85c974d..36127c1858a4 100644
--- a/include/net/flow_offload.h
+++ b/include/net/flow_offload.h
@@ -10,6 +10,10 @@ struct flow_match {
void *key;
};
+struct flow_match_meta {
+ struct flow_dissector_key_meta *key, *mask;
+};
+
struct flow_match_basic {
struct flow_dissector_key_basic *key, *mask;
};
@@ -64,6 +68,8 @@ struct flow_match_enc_opts {
struct flow_rule;
+void flow_rule_match_meta(const struct flow_rule *rule,
+ struct flow_match_meta *out);
void flow_rule_match_basic(const struct flow_rule *rule,
struct flow_match_basic *out);
void flow_rule_match_control(const struct flow_rule *rule,
diff --git a/net/core/flow_offload.c b/net/core/flow_offload.c
index 3d93e51b83e0..f52fe0bc4017 100644
--- a/net/core/flow_offload.c
+++ b/net/core/flow_offload.c
@@ -25,6 +25,13 @@ EXPORT_SYMBOL(flow_rule_alloc);
(__out)->key = skb_flow_dissector_target(__d, __type, (__m)->key); \
(__out)->mask = skb_flow_dissector_target(__d, __type, (__m)->mask); \
+void flow_rule_match_meta(const struct flow_rule *rule,
+ struct flow_match_meta *out)
+{
+ FLOW_DISSECTOR_MATCH(rule, FLOW_DISSECTOR_KEY_META, out);
+}
+EXPORT_SYMBOL(flow_rule_match_meta);
+
void flow_rule_match_basic(const struct flow_rule *rule,
struct flow_match_basic *out)
{
--
2.20.1
^ permalink raw reply related
* [PATCH net-next 2/8] net: sched: cls_flower: use flow_dissector for ingress ifindex
From: Ido Schimmel @ 2019-06-19 6:41 UTC (permalink / raw)
To: netdev
Cc: davem, jiri, jhs, xiyou.wangcong, pablo, ecree, jakub.kicinski,
Ido Schimmel
In-Reply-To: <20190619064109.849-1-idosch@idosch.org>
From: Jiri Pirko <jiri@mellanox.com>
Use previously introduced infra to obtain and store ingress ifindex
instead doing it locally.
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
---
net/sched/cls_flower.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/net/sched/cls_flower.c b/net/sched/cls_flower.c
index bd1767da8353..ce2e9b1c9850 100644
--- a/net/sched/cls_flower.c
+++ b/net/sched/cls_flower.c
@@ -27,7 +27,7 @@
#include <net/dst_metadata.h>
struct fl_flow_key {
- int indev_ifindex;
+ struct flow_dissector_key_meta meta;
struct flow_dissector_key_control control;
struct flow_dissector_key_control enc_control;
struct flow_dissector_key_basic basic;
@@ -284,7 +284,7 @@ static int fl_classify(struct sk_buff *skb, const struct tcf_proto *tp,
list_for_each_entry_rcu(mask, &head->masks, list) {
fl_clear_masked_range(&skb_key, mask);
- skb_key.indev_ifindex = skb->skb_iif;
+ skb_flow_dissect_meta(skb, &mask->dissector, &skb_key);
/* skb_flow_dissect() does not set n_proto in case an unknown
* protocol, so do it rather here.
*/
@@ -1026,8 +1026,8 @@ static int fl_set_key(struct net *net, struct nlattr **tb,
int err = tcf_change_indev(net, tb[TCA_FLOWER_INDEV], extack);
if (err < 0)
return err;
- key->indev_ifindex = err;
- mask->indev_ifindex = 0xffffffff;
+ key->meta.ingress_ifindex = err;
+ mask->meta.ingress_ifindex = 0xffffffff;
}
fl_set_key_val(tb, key->eth.dst, TCA_FLOWER_KEY_ETH_DST,
@@ -1281,6 +1281,8 @@ static void fl_init_dissector(struct flow_dissector *dissector,
struct flow_dissector_key keys[FLOW_DISSECTOR_KEY_MAX];
size_t cnt = 0;
+ FL_KEY_SET_IF_MASKED(mask, keys, cnt,
+ FLOW_DISSECTOR_KEY_META, meta);
FL_KEY_SET(keys, cnt, FLOW_DISSECTOR_KEY_CONTROL, control);
FL_KEY_SET(keys, cnt, FLOW_DISSECTOR_KEY_BASIC, basic);
FL_KEY_SET_IF_MASKED(mask, keys, cnt,
@@ -2122,10 +2124,10 @@ static int fl_dump_key_enc_opt(struct sk_buff *skb,
static int fl_dump_key(struct sk_buff *skb, struct net *net,
struct fl_flow_key *key, struct fl_flow_key *mask)
{
- if (mask->indev_ifindex) {
+ if (mask->meta.ingress_ifindex) {
struct net_device *dev;
- dev = __dev_get_by_index(net, key->indev_ifindex);
+ dev = __dev_get_by_index(net, key->meta.ingress_ifindex);
if (dev && nla_put_string(skb, TCA_FLOWER_INDEV, dev->name))
goto nla_put_failure;
}
--
2.20.1
^ permalink raw reply related
* [PATCH net-next 1/8] flow_dissector: add support for ingress ifindex dissection
From: Ido Schimmel @ 2019-06-19 6:41 UTC (permalink / raw)
To: netdev
Cc: davem, jiri, jhs, xiyou.wangcong, pablo, ecree, jakub.kicinski,
Ido Schimmel
In-Reply-To: <20190619064109.849-1-idosch@idosch.org>
From: Jiri Pirko <jiri@mellanox.com>
Add new key meta that contains ingress ifindex value and add a function
to dissect this from skb. The key and function is prepared to cover
other potential skb metadata values dissection.
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
---
include/linux/skbuff.h | 4 ++++
include/net/flow_dissector.h | 9 +++++++++
net/core/flow_dissector.c | 16 ++++++++++++++++
3 files changed, 29 insertions(+)
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 28bdaf978e72..b5d427b149c9 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -1320,6 +1320,10 @@ skb_flow_dissect_flow_keys_basic(const struct net *net,
data, proto, nhoff, hlen, flags);
}
+void skb_flow_dissect_meta(const struct sk_buff *skb,
+ struct flow_dissector *flow_dissector,
+ void *target_container);
+
void
skb_flow_dissect_tunnel_info(const struct sk_buff *skb,
struct flow_dissector *flow_dissector,
diff --git a/include/net/flow_dissector.h b/include/net/flow_dissector.h
index d7ce647a8ca9..02478e48fae4 100644
--- a/include/net/flow_dissector.h
+++ b/include/net/flow_dissector.h
@@ -200,6 +200,14 @@ struct flow_dissector_key_ip {
__u8 ttl;
};
+/**
+ * struct flow_dissector_key_meta:
+ * @ingress_ifindex: ingress ifindex
+ */
+struct flow_dissector_key_meta {
+ int ingress_ifindex;
+};
+
enum flow_dissector_key_id {
FLOW_DISSECTOR_KEY_CONTROL, /* struct flow_dissector_key_control */
FLOW_DISSECTOR_KEY_BASIC, /* struct flow_dissector_key_basic */
@@ -225,6 +233,7 @@ enum flow_dissector_key_id {
FLOW_DISSECTOR_KEY_CVLAN, /* struct flow_dissector_key_vlan */
FLOW_DISSECTOR_KEY_ENC_IP, /* struct flow_dissector_key_ip */
FLOW_DISSECTOR_KEY_ENC_OPTS, /* struct flow_dissector_key_enc_opts */
+ FLOW_DISSECTOR_KEY_META, /* struct flow_dissector_key_meta */
FLOW_DISSECTOR_KEY_MAX,
};
diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c
index c0559af9e5e5..01ad60b5aa75 100644
--- a/net/core/flow_dissector.c
+++ b/net/core/flow_dissector.c
@@ -199,6 +199,22 @@ __be32 __skb_flow_get_ports(const struct sk_buff *skb, int thoff, u8 ip_proto,
}
EXPORT_SYMBOL(__skb_flow_get_ports);
+void skb_flow_dissect_meta(const struct sk_buff *skb,
+ struct flow_dissector *flow_dissector,
+ void *target_container)
+{
+ struct flow_dissector_key_meta *meta;
+
+ if (!dissector_uses_key(flow_dissector, FLOW_DISSECTOR_KEY_META))
+ return;
+
+ meta = skb_flow_dissector_target(flow_dissector,
+ FLOW_DISSECTOR_KEY_META,
+ target_container);
+ meta->ingress_ifindex = skb->skb_iif;
+}
+EXPORT_SYMBOL(skb_flow_dissect_meta);
+
static void
skb_flow_dissect_set_enc_addr_type(enum flow_dissector_key_id type,
struct flow_dissector *flow_dissector,
--
2.20.1
^ permalink raw reply related
* [PATCH net-next 0/8] mlxsw: Implement flower ingress device matching offload
From: Ido Schimmel @ 2019-06-19 6:41 UTC (permalink / raw)
To: netdev
Cc: davem, jiri, jhs, xiyou.wangcong, pablo, ecree, jakub.kicinski,
Ido Schimmel
From: Ido Schimmel <idosch@mellanox.com>
Jiri says:
In case of using shared block, user might find it handy to be able to insert
filters to match on particular ingress device. This patchset exposes the
ingress ifindex through flow_dissector and flow_offload so mlxsw can use it to
push down to HW. See the selftests for examples of usage.
Jiri Pirko (8):
flow_dissector: add support for ingress ifindex dissection
net: sched: cls_flower: use flow_dissector for ingress ifindex
net: flow_offload: implement support for meta key
mlxsw: spectrum_acl: Write RX_ACL_SYSTEM_PORT acl element correctly
mlxsw: spectrum_acl: Avoid size check for RX_ACL_SYSTEM_PORT element
mlxsw: spectrum_acl: Fix SRC_SYS_PORT element size
mlxsw: spectrum_flower: Implement support for ingress device matching
selftests: tc: add ingress device matching support
.../mellanox/mlxsw/core_acl_flex_keys.c | 18 +-
.../mellanox/mlxsw/core_acl_flex_keys.h | 22 ++-
.../net/ethernet/mellanox/mlxsw/spectrum.h | 9 +
.../ethernet/mellanox/mlxsw/spectrum_acl.c | 9 +-
.../mellanox/mlxsw/spectrum_acl_flex_keys.c | 10 +-
.../ethernet/mellanox/mlxsw/spectrum_flower.c | 50 ++++-
include/linux/skbuff.h | 4 +
include/net/flow_dissector.h | 9 +
include/net/flow_offload.h | 6 +
net/core/flow_dissector.c | 16 ++
net/core/flow_offload.c | 7 +
net/sched/cls_flower.c | 14 +-
.../selftests/net/forwarding/tc_flower.sh | 26 ++-
.../net/forwarding/tc_flower_router.sh | 172 ++++++++++++++++++
.../selftests/net/forwarding/tc_shblocks.sh | 29 ++-
15 files changed, 367 insertions(+), 34 deletions(-)
create mode 100755 tools/testing/selftests/net/forwarding/tc_flower_router.sh
--
2.20.1
^ permalink raw reply
* [net v1] net: stmmac: set IC bit when transmitting frames with HW timestamp
From: Voon Weifeng @ 2019-06-19 14:41 UTC (permalink / raw)
To: David S. Miller, Maxime Coquelin
Cc: netdev, linux-kernel, Jose Abreu, Giuseppe Cavallaro, Andrew Lunn,
Florian Fainelli, Alexandre Torgue, Ong Boon Leong, Voon Weifeng
From: Roland Hii <roland.king.guan.hii@intel.com>
When transmitting certain PTP frames, e.g. SYNC and DELAY_REQ, the
PTP daemon, e.g. ptp4l, is polling the driver for the frame transmit
hardware timestamp. The polling will most likely timeout if the tx
coalesce is enabled due to the Interrupt-on-Completion (IC) bit is
not set in tx descriptor for those frames.
This patch will ignore the tx coalesce parameter and set the IC bit
when transmitting PTP frames which need to report out the frame
transmit hardware timestamp to user space.
Fixes: f748be531d70 ("net: stmmac: Rework coalesce timer and fix multi-queue races")
Signed-off-by: Roland Hii <roland.king.guan.hii@intel.com>
Signed-off-by: Ong Boon Leong <boon.leong.ong@intel.com>
Signed-off-by: Voon Weifeng <weifeng.voon@intel.com>
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 06dd51f47cfd..06358fe5b245 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -2947,12 +2947,15 @@ static netdev_tx_t stmmac_tso_xmit(struct sk_buff *skb, struct net_device *dev)
/* Manage tx mitigation */
tx_q->tx_count_frames += nfrags + 1;
- if (priv->tx_coal_frames <= tx_q->tx_count_frames) {
+ if (likely(priv->tx_coal_frames > tx_q->tx_count_frames) &&
+ !(priv->synopsys_id >= DWMAC_CORE_4_00 &&
+ (skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP) &&
+ priv->hwts_tx_en)) {
+ stmmac_tx_timer_arm(priv, queue);
+ } else {
+ tx_q->tx_count_frames = 0;
stmmac_set_tx_ic(priv, desc);
priv->xstats.tx_set_ic_bit++;
- tx_q->tx_count_frames = 0;
- } else {
- stmmac_tx_timer_arm(priv, queue);
}
skb_tx_timestamp(skb);
@@ -3166,12 +3169,15 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev)
* element in case of no SG.
*/
tx_q->tx_count_frames += nfrags + 1;
- if (priv->tx_coal_frames <= tx_q->tx_count_frames) {
+ if (likely(priv->tx_coal_frames > tx_q->tx_count_frames) &&
+ !(priv->synopsys_id >= DWMAC_CORE_4_00 &&
+ (skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP) &&
+ priv->hwts_tx_en)) {
+ stmmac_tx_timer_arm(priv, queue);
+ } else {
+ tx_q->tx_count_frames = 0;
stmmac_set_tx_ic(priv, desc);
priv->xstats.tx_set_ic_bit++;
- tx_q->tx_count_frames = 0;
- } else {
- stmmac_tx_timer_arm(priv, queue);
}
skb_tx_timestamp(skb);
--
1.9.1
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox