All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next 0/2] mlxsw: Update main pool computation and pool size limits
@ 2019-10-23  6:04 Ido Schimmel
  2019-10-23  6:04 ` [PATCH net-next 1/2] mlxsw: spectrum: Use guaranteed buffer size as pool size limit Ido Schimmel
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Ido Schimmel @ 2019-10-23  6:04 UTC (permalink / raw)
  To: netdev; +Cc: davem, jakub.kicinski, jiri, petrm, mlxsw, Ido Schimmel

From: Ido Schimmel <idosch@mellanox.com>

Petr says:

In Spectrum ASICs, the shared buffer is an area of memory where packets are
kept until they can be transmitted. There are two resources associated with
shared buffer size: cap_total_buffer_size and cap_guaranteed_shared_buffer.
So far, mlxsw has been using the former as a limit when validating shared
buffer pool size configuration. However, the total size also includes
headrooms and reserved space, which really cannot be used for shared buffer
pools. Patch #1 mends this and has mlxsw use the guaranteed size.

To configure default pool sizes, mlxsw has historically hard-coded one or
two smallish pools, and one "main" pool that took most of the shared buffer
(that would be pool 0 on ingress and pool 4 on egress). During the
development of Spectrum-2, it became clear that the shared buffer size
keeps shrinking as bugs are identified and worked around. In order to
prevent having to tweak the size of pools 0 and 4 to catch up with updates
to values reported by the FW, patch #2 changes the way these pools are set.
Instead of hard-coding a fixed value, the main pool now takes whatever is
left from the guaranteed size after the smaller pool(s) are taken into
account.

Petr Machata (2):
  mlxsw: spectrum: Use guaranteed buffer size as pool size limit
  mlxsw: spectrum_buffers: Calculate the size of the main pool

 .../net/ethernet/mellanox/mlxsw/resources.h   |  4 +-
 .../mellanox/mlxsw/spectrum_buffers.c         | 53 +++++++++++++------
 .../ethernet/mellanox/mlxsw/spectrum_qdisc.c  |  3 +-
 3 files changed, 42 insertions(+), 18 deletions(-)

-- 
2.21.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH net-next 1/2] mlxsw: spectrum: Use guaranteed buffer size as pool size limit
  2019-10-23  6:04 [PATCH net-next 0/2] mlxsw: Update main pool computation and pool size limits Ido Schimmel
@ 2019-10-23  6:04 ` Ido Schimmel
  2019-10-23  6:05 ` [PATCH net-next 2/2] mlxsw: spectrum_buffers: Calculate the size of the main pool Ido Schimmel
  2019-10-24  4:31 ` [PATCH net-next 0/2] mlxsw: Update main pool computation and pool size limits David Miller
  2 siblings, 0 replies; 6+ messages in thread
From: Ido Schimmel @ 2019-10-23  6:04 UTC (permalink / raw)
  To: netdev; +Cc: davem, jakub.kicinski, jiri, petrm, mlxsw, Ido Schimmel

From: Petr Machata <petrm@mellanox.com>

There are two resources associated with shared buffer size:
cap_total_buffer_size, and cap_guaranteed_shared_buffer. So far, mlxsw has
been using the former as a limit to determine how large a pool size is
allowed to be. However, the total size also includes headrooms and reserved
space, which really cannot be used for shared buffer pools.

Therefore convert mlxsw to use the latter resource as a limit. Adjust
hard-coded pool sizes to be the guaranteed size minus 256000 bytes for CPU
port pool. On Spectrum-1 that actually leads to an increase. A follow-up
patch will have this size calculated automatically.

Signed-off-by: Petr Machata <petrm@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlxsw/resources.h   |  4 ++--
 .../ethernet/mellanox/mlxsw/spectrum_buffers.c    | 15 ++++++++-------
 .../net/ethernet/mellanox/mlxsw/spectrum_qdisc.c  |  3 ++-
 3 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/resources.h b/drivers/net/ethernet/mellanox/mlxsw/resources.h
index 33a9fc9ef6a4..85f919fe851b 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/resources.h
+++ b/drivers/net/ethernet/mellanox/mlxsw/resources.h
@@ -26,7 +26,7 @@ enum mlxsw_res_id {
 	MLXSW_RES_ID_MAX_LAG_MEMBERS,
 	MLXSW_RES_ID_LOCAL_PORTS_IN_1X,
 	MLXSW_RES_ID_LOCAL_PORTS_IN_2X,
-	MLXSW_RES_ID_MAX_BUFFER_SIZE,
+	MLXSW_RES_ID_GUARANTEED_SHARED_BUFFER,
 	MLXSW_RES_ID_CELL_SIZE,
 	MLXSW_RES_ID_MAX_HEADROOM_SIZE,
 	MLXSW_RES_ID_ACL_MAX_TCAM_REGIONS,
@@ -82,7 +82,7 @@ static u16 mlxsw_res_ids[] = {
 	[MLXSW_RES_ID_MAX_LAG_MEMBERS] = 0x2521,
 	[MLXSW_RES_ID_LOCAL_PORTS_IN_1X] = 0x2610,
 	[MLXSW_RES_ID_LOCAL_PORTS_IN_2X] = 0x2611,
-	[MLXSW_RES_ID_MAX_BUFFER_SIZE] = 0x2802,	/* Bytes */
+	[MLXSW_RES_ID_GUARANTEED_SHARED_BUFFER] = 0x2805,	/* Bytes */
 	[MLXSW_RES_ID_CELL_SIZE] = 0x2803,	/* Bytes */
 	[MLXSW_RES_ID_MAX_HEADROOM_SIZE] = 0x2811,	/* Bytes */
 	[MLXSW_RES_ID_ACL_MAX_TCAM_REGIONS] = 0x2901,
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c
index b9eeae37a4dc..637151682cf2 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c
@@ -421,8 +421,8 @@ static void mlxsw_sp_sb_ports_fini(struct mlxsw_sp *mlxsw_sp)
 		.freeze_size = _freeze_size,				\
 	}
 
-#define MLXSW_SP1_SB_PR_INGRESS_SIZE	12440000
-#define MLXSW_SP1_SB_PR_EGRESS_SIZE	13232000
+#define MLXSW_SP1_SB_PR_INGRESS_SIZE	13768608
+#define MLXSW_SP1_SB_PR_EGRESS_SIZE	13768608
 #define MLXSW_SP1_SB_PR_CPU_SIZE	(256 * 1000)
 
 /* Order according to mlxsw_sp1_sb_pool_dess */
@@ -445,8 +445,8 @@ static const struct mlxsw_sp_sb_pr mlxsw_sp1_sb_prs[] = {
 			   MLXSW_SP1_SB_PR_CPU_SIZE, true, false),
 };
 
-#define MLXSW_SP2_SB_PR_INGRESS_SIZE	35297568
-#define MLXSW_SP2_SB_PR_EGRESS_SIZE	35297568
+#define MLXSW_SP2_SB_PR_INGRESS_SIZE	34084800
+#define MLXSW_SP2_SB_PR_EGRESS_SIZE	34084800
 #define MLXSW_SP2_SB_PR_CPU_SIZE	(256 * 1000)
 
 /* Order according to mlxsw_sp2_sb_pool_dess */
@@ -904,7 +904,7 @@ int mlxsw_sp_buffers_init(struct mlxsw_sp *mlxsw_sp)
 	if (!MLXSW_CORE_RES_VALID(mlxsw_sp->core, CELL_SIZE))
 		return -EIO;
 
-	if (!MLXSW_CORE_RES_VALID(mlxsw_sp->core, MAX_BUFFER_SIZE))
+	if (!MLXSW_CORE_RES_VALID(mlxsw_sp->core, GUARANTEED_SHARED_BUFFER))
 		return -EIO;
 
 	if (!MLXSW_CORE_RES_VALID(mlxsw_sp->core, MAX_HEADROOM_SIZE))
@@ -915,7 +915,7 @@ int mlxsw_sp_buffers_init(struct mlxsw_sp *mlxsw_sp)
 		return -ENOMEM;
 	mlxsw_sp->sb->cell_size = MLXSW_CORE_RES_GET(mlxsw_sp->core, CELL_SIZE);
 	mlxsw_sp->sb->sb_size = MLXSW_CORE_RES_GET(mlxsw_sp->core,
-						   MAX_BUFFER_SIZE);
+						   GUARANTEED_SHARED_BUFFER);
 	max_headroom_size = MLXSW_CORE_RES_GET(mlxsw_sp->core,
 					       MAX_HEADROOM_SIZE);
 	/* Round down, because this limit must not be overstepped. */
@@ -1013,7 +1013,8 @@ int mlxsw_sp_sb_pool_set(struct mlxsw_core *mlxsw_core,
 	mode = (enum mlxsw_reg_sbpr_mode) threshold_type;
 	pr = &mlxsw_sp->sb_vals->prs[pool_index];
 
-	if (size > MLXSW_CORE_RES_GET(mlxsw_sp->core, MAX_BUFFER_SIZE)) {
+	if (size > MLXSW_CORE_RES_GET(mlxsw_sp->core,
+				      GUARANTEED_SHARED_BUFFER)) {
 		NL_SET_ERR_MSG_MOD(extack, "Exceeded shared buffer size");
 		return -EINVAL;
 	}
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c
index bdf53cf350f6..68cc6737d45c 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c
@@ -305,7 +305,8 @@ mlxsw_sp_qdisc_red_check_params(struct mlxsw_sp_port *mlxsw_sp_port,
 			p->max);
 		return -EINVAL;
 	}
-	if (p->max > MLXSW_CORE_RES_GET(mlxsw_sp->core, MAX_BUFFER_SIZE)) {
+	if (p->max > MLXSW_CORE_RES_GET(mlxsw_sp->core,
+					GUARANTEED_SHARED_BUFFER)) {
 		dev_err(mlxsw_sp->bus_info->dev,
 			"spectrum: RED: max value %u is too big\n", p->max);
 		return -EINVAL;
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH net-next 2/2] mlxsw: spectrum_buffers: Calculate the size of the main pool
  2019-10-23  6:04 [PATCH net-next 0/2] mlxsw: Update main pool computation and pool size limits Ido Schimmel
  2019-10-23  6:04 ` [PATCH net-next 1/2] mlxsw: spectrum: Use guaranteed buffer size as pool size limit Ido Schimmel
@ 2019-10-23  6:05 ` Ido Schimmel
  2019-10-30  3:31   ` Nathan Chancellor
  2019-10-24  4:31 ` [PATCH net-next 0/2] mlxsw: Update main pool computation and pool size limits David Miller
  2 siblings, 1 reply; 6+ messages in thread
From: Ido Schimmel @ 2019-10-23  6:05 UTC (permalink / raw)
  To: netdev; +Cc: davem, jakub.kicinski, jiri, petrm, mlxsw, Ido Schimmel

From: Petr Machata <petrm@mellanox.com>

Instead of hard-coding the size of the largest pool, calculate it from the
reported guaranteed shared buffer size and sizes of other pools (currently
only the CPU port pool).

Signed-off-by: Petr Machata <petrm@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
---
 .../mellanox/mlxsw/spectrum_buffers.c         | 46 ++++++++++++++-----
 1 file changed, 34 insertions(+), 12 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c
index 637151682cf2..5fd9a72c8471 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c
@@ -35,6 +35,7 @@ struct mlxsw_sp_sb_cm {
 };
 
 #define MLXSW_SP_SB_INFI -1U
+#define MLXSW_SP_SB_REST -2U
 
 struct mlxsw_sp_sb_pm {
 	u32 min_buff;
@@ -421,19 +422,16 @@ static void mlxsw_sp_sb_ports_fini(struct mlxsw_sp *mlxsw_sp)
 		.freeze_size = _freeze_size,				\
 	}
 
-#define MLXSW_SP1_SB_PR_INGRESS_SIZE	13768608
-#define MLXSW_SP1_SB_PR_EGRESS_SIZE	13768608
 #define MLXSW_SP1_SB_PR_CPU_SIZE	(256 * 1000)
 
 /* Order according to mlxsw_sp1_sb_pool_dess */
 static const struct mlxsw_sp_sb_pr mlxsw_sp1_sb_prs[] = {
-	MLXSW_SP_SB_PR(MLXSW_REG_SBPR_MODE_DYNAMIC,
-		       MLXSW_SP1_SB_PR_INGRESS_SIZE),
+	MLXSW_SP_SB_PR(MLXSW_REG_SBPR_MODE_DYNAMIC, MLXSW_SP_SB_REST),
 	MLXSW_SP_SB_PR(MLXSW_REG_SBPR_MODE_DYNAMIC, 0),
 	MLXSW_SP_SB_PR(MLXSW_REG_SBPR_MODE_DYNAMIC, 0),
 	MLXSW_SP_SB_PR(MLXSW_REG_SBPR_MODE_DYNAMIC, 0),
-	MLXSW_SP_SB_PR_EXT(MLXSW_REG_SBPR_MODE_DYNAMIC,
-			   MLXSW_SP1_SB_PR_EGRESS_SIZE, true, false),
+	MLXSW_SP_SB_PR_EXT(MLXSW_REG_SBPR_MODE_DYNAMIC, MLXSW_SP_SB_REST,
+			   true, false),
 	MLXSW_SP_SB_PR(MLXSW_REG_SBPR_MODE_DYNAMIC, 0),
 	MLXSW_SP_SB_PR(MLXSW_REG_SBPR_MODE_DYNAMIC, 0),
 	MLXSW_SP_SB_PR(MLXSW_REG_SBPR_MODE_DYNAMIC, 0),
@@ -445,19 +443,16 @@ static const struct mlxsw_sp_sb_pr mlxsw_sp1_sb_prs[] = {
 			   MLXSW_SP1_SB_PR_CPU_SIZE, true, false),
 };
 
-#define MLXSW_SP2_SB_PR_INGRESS_SIZE	34084800
-#define MLXSW_SP2_SB_PR_EGRESS_SIZE	34084800
 #define MLXSW_SP2_SB_PR_CPU_SIZE	(256 * 1000)
 
 /* Order according to mlxsw_sp2_sb_pool_dess */
 static const struct mlxsw_sp_sb_pr mlxsw_sp2_sb_prs[] = {
-	MLXSW_SP_SB_PR(MLXSW_REG_SBPR_MODE_DYNAMIC,
-		       MLXSW_SP2_SB_PR_INGRESS_SIZE),
+	MLXSW_SP_SB_PR(MLXSW_REG_SBPR_MODE_DYNAMIC, MLXSW_SP_SB_REST),
 	MLXSW_SP_SB_PR(MLXSW_REG_SBPR_MODE_STATIC, 0),
 	MLXSW_SP_SB_PR(MLXSW_REG_SBPR_MODE_STATIC, 0),
 	MLXSW_SP_SB_PR(MLXSW_REG_SBPR_MODE_STATIC, 0),
-	MLXSW_SP_SB_PR_EXT(MLXSW_REG_SBPR_MODE_DYNAMIC,
-			   MLXSW_SP2_SB_PR_EGRESS_SIZE, true, false),
+	MLXSW_SP_SB_PR_EXT(MLXSW_REG_SBPR_MODE_DYNAMIC, MLXSW_SP_SB_REST,
+			   true, false),
 	MLXSW_SP_SB_PR(MLXSW_REG_SBPR_MODE_STATIC, 0),
 	MLXSW_SP_SB_PR(MLXSW_REG_SBPR_MODE_STATIC, 0),
 	MLXSW_SP_SB_PR(MLXSW_REG_SBPR_MODE_STATIC, 0),
@@ -471,11 +466,33 @@ static const struct mlxsw_sp_sb_pr mlxsw_sp2_sb_prs[] = {
 
 static int mlxsw_sp_sb_prs_init(struct mlxsw_sp *mlxsw_sp,
 				const struct mlxsw_sp_sb_pr *prs,
+				const struct mlxsw_sp_sb_pool_des *pool_dess,
 				size_t prs_len)
 {
+	/* Round down, unlike mlxsw_sp_bytes_cells(). */
+	u32 sb_cells = mlxsw_sp->sb->sb_size / mlxsw_sp->sb->cell_size;
+	u32 rest_cells[2] = {sb_cells, sb_cells};
 	int i;
 	int err;
 
+	/* Calculate how much space to give to the "REST" pools in either
+	 * direction.
+	 */
+	for (i = 0; i < prs_len; i++) {
+		enum mlxsw_reg_sbxx_dir dir = pool_dess[i].dir;
+		u32 size = prs[i].size;
+		u32 size_cells;
+
+		if (size == MLXSW_SP_SB_INFI || size == MLXSW_SP_SB_REST)
+			continue;
+
+		size_cells = mlxsw_sp_bytes_cells(mlxsw_sp, size);
+		if (WARN_ON_ONCE(size_cells > rest_cells[dir]))
+			continue;
+
+		rest_cells[dir] -= size_cells;
+	}
+
 	for (i = 0; i < prs_len; i++) {
 		u32 size = prs[i].size;
 		u32 size_cells;
@@ -483,6 +500,10 @@ static int mlxsw_sp_sb_prs_init(struct mlxsw_sp *mlxsw_sp,
 		if (size == MLXSW_SP_SB_INFI) {
 			err = mlxsw_sp_sb_pr_write(mlxsw_sp, i, prs[i].mode,
 						   0, true);
+		} else if (size == MLXSW_SP_SB_REST) {
+			size_cells = rest_cells[pool_dess[i].dir];
+			err = mlxsw_sp_sb_pr_write(mlxsw_sp, i, prs[i].mode,
+						   size_cells, false);
 		} else {
 			size_cells = mlxsw_sp_bytes_cells(mlxsw_sp, size);
 			err = mlxsw_sp_sb_pr_write(mlxsw_sp, i, prs[i].mode,
@@ -926,6 +947,7 @@ int mlxsw_sp_buffers_init(struct mlxsw_sp *mlxsw_sp)
 	if (err)
 		goto err_sb_ports_init;
 	err = mlxsw_sp_sb_prs_init(mlxsw_sp, mlxsw_sp->sb_vals->prs,
+				   mlxsw_sp->sb_vals->pool_dess,
 				   mlxsw_sp->sb_vals->pool_count);
 	if (err)
 		goto err_sb_prs_init;
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH net-next 0/2] mlxsw: Update main pool computation and pool size limits
  2019-10-23  6:04 [PATCH net-next 0/2] mlxsw: Update main pool computation and pool size limits Ido Schimmel
  2019-10-23  6:04 ` [PATCH net-next 1/2] mlxsw: spectrum: Use guaranteed buffer size as pool size limit Ido Schimmel
  2019-10-23  6:05 ` [PATCH net-next 2/2] mlxsw: spectrum_buffers: Calculate the size of the main pool Ido Schimmel
@ 2019-10-24  4:31 ` David Miller
  2 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2019-10-24  4:31 UTC (permalink / raw)
  To: idosch; +Cc: netdev, jakub.kicinski, jiri, petrm, mlxsw, idosch

From: Ido Schimmel <idosch@idosch.org>
Date: Wed, 23 Oct 2019 09:04:58 +0300

> From: Ido Schimmel <idosch@mellanox.com>
> 
> Petr says:
> 
> In Spectrum ASICs, the shared buffer is an area of memory where packets are
> kept until they can be transmitted. There are two resources associated with
> shared buffer size: cap_total_buffer_size and cap_guaranteed_shared_buffer.
> So far, mlxsw has been using the former as a limit when validating shared
> buffer pool size configuration. However, the total size also includes
> headrooms and reserved space, which really cannot be used for shared buffer
> pools. Patch #1 mends this and has mlxsw use the guaranteed size.
> 
> To configure default pool sizes, mlxsw has historically hard-coded one or
> two smallish pools, and one "main" pool that took most of the shared buffer
> (that would be pool 0 on ingress and pool 4 on egress). During the
> development of Spectrum-2, it became clear that the shared buffer size
> keeps shrinking as bugs are identified and worked around. In order to
> prevent having to tweak the size of pools 0 and 4 to catch up with updates
> to values reported by the FW, patch #2 changes the way these pools are set.
> Instead of hard-coding a fixed value, the main pool now takes whatever is
> left from the guaranteed size after the smaller pool(s) are taken into
> account.

Series applied, thanks.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH net-next 2/2] mlxsw: spectrum_buffers: Calculate the size of the main pool
  2019-10-23  6:05 ` [PATCH net-next 2/2] mlxsw: spectrum_buffers: Calculate the size of the main pool Ido Schimmel
@ 2019-10-30  3:31   ` Nathan Chancellor
  2019-10-30  7:57     ` Ido Schimmel
  0 siblings, 1 reply; 6+ messages in thread
From: Nathan Chancellor @ 2019-10-30  3:31 UTC (permalink / raw)
  To: Ido Schimmel
  Cc: netdev, davem, jakub.kicinski, jiri, petrm, mlxsw, Ido Schimmel

On Wed, Oct 23, 2019 at 09:05:00AM +0300, Ido Schimmel wrote:
> From: Petr Machata <petrm@mellanox.com>
> 
> Instead of hard-coding the size of the largest pool, calculate it from the
> reported guaranteed shared buffer size and sizes of other pools (currently
> only the CPU port pool).
> 
> Signed-off-by: Petr Machata <petrm@mellanox.com>
> Signed-off-by: Ido Schimmel <idosch@mellanox.com>
> ---
>  .../mellanox/mlxsw/spectrum_buffers.c         | 46 ++++++++++++++-----
>  1 file changed, 34 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c
> index 637151682cf2..5fd9a72c8471 100644
> --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c
> +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c
> @@ -35,6 +35,7 @@ struct mlxsw_sp_sb_cm {
>  };
>  
>  #define MLXSW_SP_SB_INFI -1U
> +#define MLXSW_SP_SB_REST -2U
>  
>  struct mlxsw_sp_sb_pm {
>  	u32 min_buff;
> @@ -421,19 +422,16 @@ static void mlxsw_sp_sb_ports_fini(struct mlxsw_sp *mlxsw_sp)
>  		.freeze_size = _freeze_size,				\
>  	}
>  
> -#define MLXSW_SP1_SB_PR_INGRESS_SIZE	13768608
> -#define MLXSW_SP1_SB_PR_EGRESS_SIZE	13768608
>  #define MLXSW_SP1_SB_PR_CPU_SIZE	(256 * 1000)
>  
>  /* Order according to mlxsw_sp1_sb_pool_dess */
>  static const struct mlxsw_sp_sb_pr mlxsw_sp1_sb_prs[] = {
> -	MLXSW_SP_SB_PR(MLXSW_REG_SBPR_MODE_DYNAMIC,
> -		       MLXSW_SP1_SB_PR_INGRESS_SIZE),
> +	MLXSW_SP_SB_PR(MLXSW_REG_SBPR_MODE_DYNAMIC, MLXSW_SP_SB_REST),
>  	MLXSW_SP_SB_PR(MLXSW_REG_SBPR_MODE_DYNAMIC, 0),
>  	MLXSW_SP_SB_PR(MLXSW_REG_SBPR_MODE_DYNAMIC, 0),
>  	MLXSW_SP_SB_PR(MLXSW_REG_SBPR_MODE_DYNAMIC, 0),
> -	MLXSW_SP_SB_PR_EXT(MLXSW_REG_SBPR_MODE_DYNAMIC,
> -			   MLXSW_SP1_SB_PR_EGRESS_SIZE, true, false),
> +	MLXSW_SP_SB_PR_EXT(MLXSW_REG_SBPR_MODE_DYNAMIC, MLXSW_SP_SB_REST,
> +			   true, false),
>  	MLXSW_SP_SB_PR(MLXSW_REG_SBPR_MODE_DYNAMIC, 0),
>  	MLXSW_SP_SB_PR(MLXSW_REG_SBPR_MODE_DYNAMIC, 0),
>  	MLXSW_SP_SB_PR(MLXSW_REG_SBPR_MODE_DYNAMIC, 0),
> @@ -445,19 +443,16 @@ static const struct mlxsw_sp_sb_pr mlxsw_sp1_sb_prs[] = {
>  			   MLXSW_SP1_SB_PR_CPU_SIZE, true, false),
>  };
>  
> -#define MLXSW_SP2_SB_PR_INGRESS_SIZE	34084800
> -#define MLXSW_SP2_SB_PR_EGRESS_SIZE	34084800
>  #define MLXSW_SP2_SB_PR_CPU_SIZE	(256 * 1000)
>  
>  /* Order according to mlxsw_sp2_sb_pool_dess */
>  static const struct mlxsw_sp_sb_pr mlxsw_sp2_sb_prs[] = {
> -	MLXSW_SP_SB_PR(MLXSW_REG_SBPR_MODE_DYNAMIC,
> -		       MLXSW_SP2_SB_PR_INGRESS_SIZE),
> +	MLXSW_SP_SB_PR(MLXSW_REG_SBPR_MODE_DYNAMIC, MLXSW_SP_SB_REST),
>  	MLXSW_SP_SB_PR(MLXSW_REG_SBPR_MODE_STATIC, 0),
>  	MLXSW_SP_SB_PR(MLXSW_REG_SBPR_MODE_STATIC, 0),
>  	MLXSW_SP_SB_PR(MLXSW_REG_SBPR_MODE_STATIC, 0),
> -	MLXSW_SP_SB_PR_EXT(MLXSW_REG_SBPR_MODE_DYNAMIC,
> -			   MLXSW_SP2_SB_PR_EGRESS_SIZE, true, false),
> +	MLXSW_SP_SB_PR_EXT(MLXSW_REG_SBPR_MODE_DYNAMIC, MLXSW_SP_SB_REST,
> +			   true, false),
>  	MLXSW_SP_SB_PR(MLXSW_REG_SBPR_MODE_STATIC, 0),
>  	MLXSW_SP_SB_PR(MLXSW_REG_SBPR_MODE_STATIC, 0),
>  	MLXSW_SP_SB_PR(MLXSW_REG_SBPR_MODE_STATIC, 0),
> @@ -471,11 +466,33 @@ static const struct mlxsw_sp_sb_pr mlxsw_sp2_sb_prs[] = {
>  
>  static int mlxsw_sp_sb_prs_init(struct mlxsw_sp *mlxsw_sp,
>  				const struct mlxsw_sp_sb_pr *prs,
> +				const struct mlxsw_sp_sb_pool_des *pool_dess,
>  				size_t prs_len)
>  {
> +	/* Round down, unlike mlxsw_sp_bytes_cells(). */
> +	u32 sb_cells = mlxsw_sp->sb->sb_size / mlxsw_sp->sb->cell_size;

This causes a link time error on arm32. It can be simply reproduced with
the following configs + multi_v7_defconfig:

CONFIG_MLXSW_CORE=y
CONFIG_MLXSW_PCI=y
CONFIG_NET_SWITCHDEV=y
CONFIG_VLAN_8021Q=y
CONFIG_MLXSW_SPECTRUM=y

arm-linux-gnueabi-ld: drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.o: in function `mlxsw_sp_buffers_init':
spectrum_buffers.c:(.text+0x1c88): undefined reference to `__aeabi_uldivmod'

It can be solved by something like this but I am not sure if that is
proper or not since div_u64 returns a u64, which would implicitly get
converted to u32. I can submit it as a formal patch if needed but I
figured I would reach out first in case you want to go in a different
direction.

diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c
index 33a978af80d6..968f0902e4fe 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c
@@ -470,7 +470,7 @@ static int mlxsw_sp_sb_prs_init(struct mlxsw_sp *mlxsw_sp,
 				size_t prs_len)
 {
 	/* Round down, unlike mlxsw_sp_bytes_cells(). */
-	u32 sb_cells = mlxsw_sp->sb->sb_size / mlxsw_sp->sb->cell_size;
+	u32 sb_cells = div_u64(mlxsw_sp->sb->sb_size, mlxsw_sp->sb->cell_size);
 	u32 rest_cells[2] = {sb_cells, sb_cells};
 	int i;
 	int err;

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH net-next 2/2] mlxsw: spectrum_buffers: Calculate the size of the main pool
  2019-10-30  3:31   ` Nathan Chancellor
@ 2019-10-30  7:57     ` Ido Schimmel
  0 siblings, 0 replies; 6+ messages in thread
From: Ido Schimmel @ 2019-10-30  7:57 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: netdev, davem, jakub.kicinski, jiri, petrm, mlxsw, Ido Schimmel

On Tue, Oct 29, 2019 at 08:31:54PM -0700, Nathan Chancellor wrote:
> On Wed, Oct 23, 2019 at 09:05:00AM +0300, Ido Schimmel wrote:
> >  static int mlxsw_sp_sb_prs_init(struct mlxsw_sp *mlxsw_sp,
> >  				const struct mlxsw_sp_sb_pr *prs,
> > +				const struct mlxsw_sp_sb_pool_des *pool_dess,
> >  				size_t prs_len)
> >  {
> > +	/* Round down, unlike mlxsw_sp_bytes_cells(). */
> > +	u32 sb_cells = mlxsw_sp->sb->sb_size / mlxsw_sp->sb->cell_size;
> 
> This causes a link time error on arm32. It can be simply reproduced with
> the following configs + multi_v7_defconfig:
> 
> CONFIG_MLXSW_CORE=y
> CONFIG_MLXSW_PCI=y
> CONFIG_NET_SWITCHDEV=y
> CONFIG_VLAN_8021Q=y
> CONFIG_MLXSW_SPECTRUM=y
> 
> arm-linux-gnueabi-ld: drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.o: in function `mlxsw_sp_buffers_init':
> spectrum_buffers.c:(.text+0x1c88): undefined reference to `__aeabi_uldivmod'
> 
> It can be solved by something like this but I am not sure if that is
> proper or not since div_u64 returns a u64, which would implicitly get
> converted to u32. I can submit it as a formal patch if needed but I
> figured I would reach out first in case you want to go in a different
> direction.

Yes, this looks fine to me. The value can fit in a u32. Tested on my
system without issues.

Thanks for reaching out

> 
> diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c
> index 33a978af80d6..968f0902e4fe 100644
> --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c
> +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c
> @@ -470,7 +470,7 @@ static int mlxsw_sp_sb_prs_init(struct mlxsw_sp *mlxsw_sp,
>  				size_t prs_len)
>  {
>  	/* Round down, unlike mlxsw_sp_bytes_cells(). */
> -	u32 sb_cells = mlxsw_sp->sb->sb_size / mlxsw_sp->sb->cell_size;
> +	u32 sb_cells = div_u64(mlxsw_sp->sb->sb_size, mlxsw_sp->sb->cell_size);
>  	u32 rest_cells[2] = {sb_cells, sb_cells};
>  	int i;
>  	int err;

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-10-30  7:57 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-23  6:04 [PATCH net-next 0/2] mlxsw: Update main pool computation and pool size limits Ido Schimmel
2019-10-23  6:04 ` [PATCH net-next 1/2] mlxsw: spectrum: Use guaranteed buffer size as pool size limit Ido Schimmel
2019-10-23  6:05 ` [PATCH net-next 2/2] mlxsw: spectrum_buffers: Calculate the size of the main pool Ido Schimmel
2019-10-30  3:31   ` Nathan Chancellor
2019-10-30  7:57     ` Ido Schimmel
2019-10-24  4:31 ` [PATCH net-next 0/2] mlxsw: Update main pool computation and pool size limits David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.