net: devlink: report cell size of shared buffers
authorJakub Kicinski <jakub.kicinski@netronome.com>
Sat, 2 Feb 2019 01:56:28 +0000 (17:56 -0800)
committerDavid S. Miller <davem@davemloft.net>
Sun, 3 Feb 2019 19:25:34 +0000 (11:25 -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>
Reviewed-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c
drivers/net/ethernet/netronome/nfp/nfp_shared_buf.c
include/net/devlink.h
include/uapi/linux/devlink.h
net/core/devlink.c

index 12c61e0cc5705a27b05127d58274340c5e62a13f..80066f437a65e8a91c63ea7000189c62a7a4565e 100644 (file)
@@ -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;
 }
 
index 814360ed3a203cbe6bc1df44767ae31e558010a8..ea2e3f829abaf423e11001641493dfaedc573205 100644 (file)
@@ -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;
 }
index 1c8523920f661580c10ad45d53a1219138152e48..74d992a68a06493ddbf1471d300c908afcceb5ec 100644 (file)
@@ -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;
 };
 
 /**
index 7fffd879c32876af0d831f7a5896ac3c46270fbf..054b2d1a45376a24bdf11add8e8baa0fe5fa4de5 100644 (file)
@@ -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,
index eb839d74bcc07e98f218aa0ce2ecd859f3ad0678..52bf27491fb8b0928f7d4aa3a27f8b33f2561386 100644 (file)
@@ -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;