All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next] net: devlink: report cell size of shared buffers
@ 2019-02-02  1:56 Jakub Kicinski
  2019-02-02 12:35 ` Ido Schimmel
  2019-02-03 19:27 ` David Miller
  0 siblings, 2 replies; 4+ messages in thread
From: Jakub Kicinski @ 2019-02-02  1:56 UTC (permalink / raw)
  To: davem, jiri; +Cc: idosch, netdev, oss-drivers, Jakub Kicinski

Shared buffer allocation is usually done in cell increments.
Drivers will either round up the allocation or refuse the
configuration if it's not an exact multiple of cell size.
Drivers know exactly the cell size of shared buffer, so help
out users by providing this information in dumps.

Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: Dirk van der Merwe <dirk.vandermerwe@netronome.com>
---
 drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c | 1 +
 drivers/net/ethernet/netronome/nfp/nfp_shared_buf.c    | 1 +
 include/net/devlink.h                                  | 1 +
 include/uapi/linux/devlink.h                           | 2 ++
 net/core/devlink.c                                     | 3 +++
 5 files changed, 8 insertions(+)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c
index 12c61e0cc570..80066f437a65 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c
@@ -713,6 +713,7 @@ int mlxsw_sp_sb_pool_get(struct mlxsw_core *mlxsw_core,
 	pool_info->pool_type = (enum devlink_sb_pool_type) dir;
 	pool_info->size = mlxsw_sp_cells_bytes(mlxsw_sp, pr->size);
 	pool_info->threshold_type = (enum devlink_sb_threshold_type) pr->mode;
+	pool_info->cell_size = mlxsw_sp->sb->cell_size;
 	return 0;
 }
 
diff --git a/drivers/net/ethernet/netronome/nfp/nfp_shared_buf.c b/drivers/net/ethernet/netronome/nfp/nfp_shared_buf.c
index 814360ed3a20..ea2e3f829aba 100644
--- a/drivers/net/ethernet/netronome/nfp/nfp_shared_buf.c
+++ b/drivers/net/ethernet/netronome/nfp/nfp_shared_buf.c
@@ -48,6 +48,7 @@ int nfp_shared_buf_pool_get(struct nfp_pf *pf, unsigned int sb, u16 pool_index,
 	pool_info->pool_type = le32_to_cpu(get_data.pool_type);
 	pool_info->threshold_type = le32_to_cpu(get_data.threshold_type);
 	pool_info->size = le32_to_cpu(get_data.size) * unit_size;
+	pool_info->cell_size = unit_size;
 
 	return 0;
 }
diff --git a/include/net/devlink.h b/include/net/devlink.h
index 1c8523920f66..74d992a68a06 100644
--- a/include/net/devlink.h
+++ b/include/net/devlink.h
@@ -62,6 +62,7 @@ struct devlink_sb_pool_info {
 	enum devlink_sb_pool_type pool_type;
 	u32 size;
 	enum devlink_sb_threshold_type threshold_type;
+	u32 cell_size;
 };
 
 /**
diff --git a/include/uapi/linux/devlink.h b/include/uapi/linux/devlink.h
index 7fffd879c328..054b2d1a4537 100644
--- a/include/uapi/linux/devlink.h
+++ b/include/uapi/linux/devlink.h
@@ -300,6 +300,8 @@ enum devlink_attr {
 	DEVLINK_ATTR_INFO_VERSION_NAME,		/* string */
 	DEVLINK_ATTR_INFO_VERSION_VALUE,	/* string */
 
+	DEVLINK_ATTR_SB_POOL_CELL_SIZE,		/* u32 */
+
 	/* add new attributes above here, update the policy in devlink.c */
 
 	__DEVLINK_ATTR_MAX,
diff --git a/net/core/devlink.c b/net/core/devlink.c
index eb839d74bcc0..52bf27491fb8 100644
--- a/net/core/devlink.c
+++ b/net/core/devlink.c
@@ -932,6 +932,9 @@ static int devlink_nl_sb_pool_fill(struct sk_buff *msg, struct devlink *devlink,
 	if (nla_put_u8(msg, DEVLINK_ATTR_SB_POOL_THRESHOLD_TYPE,
 		       pool_info.threshold_type))
 		goto nla_put_failure;
+	if (nla_put_u32(msg, DEVLINK_ATTR_SB_POOL_CELL_SIZE,
+			pool_info.cell_size))
+		goto nla_put_failure;
 
 	genlmsg_end(msg, hdr);
 	return 0;
-- 
2.19.2


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

* Re: [PATCH net-next] net: devlink: report cell size of shared buffers
  2019-02-02  1:56 [PATCH net-next] net: devlink: report cell size of shared buffers Jakub Kicinski
@ 2019-02-02 12:35 ` Ido Schimmel
  2019-02-02 22:00   ` Jakub Kicinski
  2019-02-03 19:27 ` David Miller
  1 sibling, 1 reply; 4+ messages in thread
From: Ido Schimmel @ 2019-02-02 12:35 UTC (permalink / raw)
  To: Jakub Kicinski; +Cc: davem, jiri, netdev, oss-drivers

On Fri, Feb 01, 2019 at 05:56:28PM -0800, Jakub Kicinski wrote:
> Shared buffer allocation is usually done in cell increments.
> Drivers will either round up the allocation or refuse the
> configuration if it's not an exact multiple of cell size.
> Drivers know exactly the cell size of shared buffer, so help
> out users by providing this information in dumps.
> 
> Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
> Reviewed-by: Dirk van der Merwe <dirk.vandermerwe@netronome.com>

Reviewed-by: Ido Schimmel <idosch@mellanox.com>

I assume you're going to patch iproute2. Consider explaining what is
cell size in devlink-sb manpage.

Thanks!

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

* Re: [PATCH net-next] net: devlink: report cell size of shared buffers
  2019-02-02 12:35 ` Ido Schimmel
@ 2019-02-02 22:00   ` Jakub Kicinski
  0 siblings, 0 replies; 4+ messages in thread
From: Jakub Kicinski @ 2019-02-02 22:00 UTC (permalink / raw)
  To: Ido Schimmel; +Cc: davem, jiri, netdev, oss-drivers

On Sat, 2 Feb 2019 12:35:51 +0000, Ido Schimmel wrote:
> On Fri, Feb 01, 2019 at 05:56:28PM -0800, Jakub Kicinski wrote:
> > Shared buffer allocation is usually done in cell increments.
> > Drivers will either round up the allocation or refuse the
> > configuration if it's not an exact multiple of cell size.
> > Drivers know exactly the cell size of shared buffer, so help
> > out users by providing this information in dumps.
> > 
> > Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
> > Reviewed-by: Dirk van der Merwe <dirk.vandermerwe@netronome.com>  
> 
> Reviewed-by: Ido Schimmel <idosch@mellanox.com>
> 
> I assume you're going to patch iproute2. Consider explaining what is
> cell size in devlink-sb manpage.

Will do, thanks!

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

* Re: [PATCH net-next] net: devlink: report cell size of shared buffers
  2019-02-02  1:56 [PATCH net-next] net: devlink: report cell size of shared buffers Jakub Kicinski
  2019-02-02 12:35 ` Ido Schimmel
@ 2019-02-03 19:27 ` David Miller
  1 sibling, 0 replies; 4+ messages in thread
From: David Miller @ 2019-02-03 19:27 UTC (permalink / raw)
  To: jakub.kicinski; +Cc: jiri, idosch, netdev, oss-drivers

From: Jakub Kicinski <jakub.kicinski@netronome.com>
Date: Fri,  1 Feb 2019 17:56:28 -0800

> Shared buffer allocation is usually done in cell increments.
> Drivers will either round up the allocation or refuse the
> configuration if it's not an exact multiple of cell size.
> Drivers know exactly the cell size of shared buffer, so help
> out users by providing this information in dumps.
> 
> Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
> Reviewed-by: Dirk van der Merwe <dirk.vandermerwe@netronome.com>

Applied, thanks.

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

end of thread, other threads:[~2019-02-03 19:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-02  1:56 [PATCH net-next] net: devlink: report cell size of shared buffers Jakub Kicinski
2019-02-02 12:35 ` Ido Schimmel
2019-02-02 22:00   ` Jakub Kicinski
2019-02-03 19:27 ` 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.