* [patch net-next 1/4] mlxsw: resources: Add maximum buffer size
2016-11-28 17:01 [patch net-next 0/4] mlxsw: couple of enhancements and fixes Jiri Pirko
@ 2016-11-28 17:01 ` Jiri Pirko
2016-11-28 17:01 ` [patch net-next 2/4] mlxsw: spectrum_buffers: Limit size of pools Jiri Pirko
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Jiri Pirko @ 2016-11-28 17:01 UTC (permalink / raw)
To: netdev; +Cc: davem, idosch, eladr, yotamg, nogahf, arkadis, ogerlitz
From: Ido Schimmel <idosch@mellanox.com>
We need to be able to limit the size of shared buffer pools, so query
the maximum size from the device during init.
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
---
drivers/net/ethernet/mellanox/mlxsw/resources.h | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/net/ethernet/mellanox/mlxsw/resources.h b/drivers/net/ethernet/mellanox/mlxsw/resources.h
index 1c2119b..3c2171d 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/resources.h
+++ b/drivers/net/ethernet/mellanox/mlxsw/resources.h
@@ -47,6 +47,7 @@ enum mlxsw_res_id {
MLXSW_RES_ID_MAX_SYSTEM_PORT,
MLXSW_RES_ID_MAX_LAG,
MLXSW_RES_ID_MAX_LAG_MEMBERS,
+ MLXSW_RES_ID_MAX_BUFFER_SIZE,
MLXSW_RES_ID_MAX_CPU_POLICERS,
MLXSW_RES_ID_MAX_VRS,
MLXSW_RES_ID_MAX_RIFS,
@@ -70,6 +71,7 @@ static u16 mlxsw_res_ids[] = {
[MLXSW_RES_ID_MAX_SYSTEM_PORT] = 0x2502,
[MLXSW_RES_ID_MAX_LAG] = 0x2520,
[MLXSW_RES_ID_MAX_LAG_MEMBERS] = 0x2521,
+ [MLXSW_RES_ID_MAX_BUFFER_SIZE] = 0x2802, /* Bytes */
[MLXSW_RES_ID_MAX_CPU_POLICERS] = 0x2A13,
[MLXSW_RES_ID_MAX_VRS] = 0x2C01,
[MLXSW_RES_ID_MAX_RIFS] = 0x2C02,
--
2.7.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [patch net-next 2/4] mlxsw: spectrum_buffers: Limit size of pools
2016-11-28 17:01 [patch net-next 0/4] mlxsw: couple of enhancements and fixes Jiri Pirko
2016-11-28 17:01 ` [patch net-next 1/4] mlxsw: resources: Add maximum buffer size Jiri Pirko
@ 2016-11-28 17:01 ` Jiri Pirko
2016-11-28 17:01 ` [patch net-next 3/4] mlxsw: core: Add missing rollback in error path Jiri Pirko
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Jiri Pirko @ 2016-11-28 17:01 UTC (permalink / raw)
To: netdev; +Cc: davem, idosch, eladr, yotamg, nogahf, arkadis, ogerlitz
From: Ido Schimmel <idosch@mellanox.com>
The shared buffer pools are containers whose size is used to calculate
the maximum usage for packets from / to a specific port / {port, PG/TC},
when dynamic threshold is employed.
While it's perfectly fine for the sum of the pools to exceed the maximum
size of the shared buffer, a single pool cannot.
Add a check when the pool size is set and forbid sizes larger than the
maximum size of the shared buffer.
Without the patch:
$ devlink sb pool set pci/0000:03:00.0 pool 0 size 999999999 thtype
dynamic
// No error is returned
With the patch:
$ devlink sb pool set pci/0000:03:00.0 pool 0 size 999999999 thtype
dynamic
devlink answers: Invalid argument
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
---
drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c
index bcaed8a..a746826 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c
@@ -611,6 +611,9 @@ int mlxsw_sp_sb_pool_set(struct mlxsw_core *mlxsw_core,
u32 pool_size = MLXSW_SP_BYTES_TO_CELLS(size);
enum mlxsw_reg_sbpr_mode mode;
+ if (size > MLXSW_CORE_RES_GET(mlxsw_sp->core, MAX_BUFFER_SIZE))
+ return -EINVAL;
+
mode = (enum mlxsw_reg_sbpr_mode) threshold_type;
return mlxsw_sp_sb_pr_write(mlxsw_sp, pool, dir, mode, pool_size);
}
--
2.7.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [patch net-next 3/4] mlxsw: core: Add missing rollback in error path
2016-11-28 17:01 [patch net-next 0/4] mlxsw: couple of enhancements and fixes Jiri Pirko
2016-11-28 17:01 ` [patch net-next 1/4] mlxsw: resources: Add maximum buffer size Jiri Pirko
2016-11-28 17:01 ` [patch net-next 2/4] mlxsw: spectrum_buffers: Limit size of pools Jiri Pirko
@ 2016-11-28 17:01 ` Jiri Pirko
2016-11-28 17:01 ` [patch net-next 4/4] mlxsw: core: Change order of operations in removal path Jiri Pirko
2016-11-30 1:49 ` [patch net-next 0/4] mlxsw: couple of enhancements and fixes David Miller
4 siblings, 0 replies; 6+ messages in thread
From: Jiri Pirko @ 2016-11-28 17:01 UTC (permalink / raw)
To: netdev; +Cc: davem, idosch, eladr, yotamg, nogahf, arkadis, ogerlitz
From: Ido Schimmel <idosch@mellanox.com>
Without this rollback, the thermal zone is still registered during the
error path, whereas its private data is freed upon the destruction of
the underlying bus device due to the use of devm_kzalloc(). This results
in use after free.
Fix this by calling mlxsw_thermal_fini() from the appropriate place in
the error path.
Fixes: a50c1e35650b ("mlxsw: core: Implement thermal zone")
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
---
drivers/net/ethernet/mellanox/mlxsw/core.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core.c b/drivers/net/ethernet/mellanox/mlxsw/core.c
index b21f88c..7a0ad39 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/core.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/core.c
@@ -1157,6 +1157,7 @@ int mlxsw_core_bus_device_register(const struct mlxsw_bus_info *mlxsw_bus_info,
if (mlxsw_core->driver->fini)
mlxsw_core->driver->fini(mlxsw_core);
err_driver_init:
+ mlxsw_thermal_fini(mlxsw_core->thermal);
err_thermal_init:
err_hwmon_init:
devlink_unregister(devlink);
--
2.7.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [patch net-next 4/4] mlxsw: core: Change order of operations in removal path
2016-11-28 17:01 [patch net-next 0/4] mlxsw: couple of enhancements and fixes Jiri Pirko
` (2 preceding siblings ...)
2016-11-28 17:01 ` [patch net-next 3/4] mlxsw: core: Add missing rollback in error path Jiri Pirko
@ 2016-11-28 17:01 ` Jiri Pirko
2016-11-30 1:49 ` [patch net-next 0/4] mlxsw: couple of enhancements and fixes David Miller
4 siblings, 0 replies; 6+ messages in thread
From: Jiri Pirko @ 2016-11-28 17:01 UTC (permalink / raw)
To: netdev; +Cc: davem, idosch, eladr, yotamg, nogahf, arkadis, ogerlitz
From: Ido Schimmel <idosch@mellanox.com>
We call bus->init() before allocating 'lag.mapping'. Change the order of
operations in removal path to reflect that.
This makes the error path of mlxsw_core_bus_device_register() symmetric
with mlxsw_core_bus_device_unregister().
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
---
drivers/net/ethernet/mellanox/mlxsw/core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core.c b/drivers/net/ethernet/mellanox/mlxsw/core.c
index 7a0ad39..4dc028b 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/core.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/core.c
@@ -1188,8 +1188,8 @@ void mlxsw_core_bus_device_unregister(struct mlxsw_core *mlxsw_core)
mlxsw_thermal_fini(mlxsw_core->thermal);
devlink_unregister(devlink);
mlxsw_emad_fini(mlxsw_core);
- mlxsw_core->bus->fini(mlxsw_core->bus_priv);
kfree(mlxsw_core->lag.mapping);
+ mlxsw_core->bus->fini(mlxsw_core->bus_priv);
free_percpu(mlxsw_core->pcpu_stats);
devlink_free(devlink);
mlxsw_core_driver_put(device_kind);
--
2.7.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [patch net-next 0/4] mlxsw: couple of enhancements and fixes
2016-11-28 17:01 [patch net-next 0/4] mlxsw: couple of enhancements and fixes Jiri Pirko
` (3 preceding siblings ...)
2016-11-28 17:01 ` [patch net-next 4/4] mlxsw: core: Change order of operations in removal path Jiri Pirko
@ 2016-11-30 1:49 ` David Miller
4 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2016-11-30 1:49 UTC (permalink / raw)
To: jiri; +Cc: netdev, idosch, eladr, yotamg, nogahf, arkadis, ogerlitz
From: Jiri Pirko <jiri@resnulli.us>
Date: Mon, 28 Nov 2016 18:01:22 +0100
> Couple of enhancements and fixes from Ido.
Series applied, thanks Jiri.
^ permalink raw reply [flat|nested] 6+ messages in thread