History

net: devlink: report cell size of shared buffers

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.

Jakub Kicinski committed 7 years ago

Commit bff57311 parent a98dc6a5 files · +8 −0Browse files

Unified · Split

5 files
  1. drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c +1 −0
  2. drivers/net/ethernet/netronome/nfp/nfp_shared_buf.c +1 −0
  3. include/net/devlink.h +1 −0
  4. include/uapi/linux/devlink.h +2 −0
  5. net/core/devlink.c +3 −0
drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c+1−0
@@ -713,6 +713,7 @@ int mlxsw_sp_sb_pool_get(struct mlxsw_core *mlxsw_core, · 712 unmodified lines
713 pool_info->pool_type = (enum devlink_sb_pool_type) dir;713 pool_info->pool_type = (enum devlink_sb_pool_type) dir;
714 pool_info->size = mlxsw_sp_cells_bytes(mlxsw_sp, pr->size);714 pool_info->size = mlxsw_sp_cells_bytes(mlxsw_sp, pr->size);
715 pool_info->threshold_type = (enum devlink_sb_threshold_type) pr->mode;715 pool_info->threshold_type = (enum devlink_sb_threshold_type) pr->mode;
716 pool_info->cell_size = mlxsw_sp->sb->cell_size;
716 return 0;717 return 0;
717}718}
718 719
drivers/net/ethernet/netronome/nfp/nfp_shared_buf.c+1−0
@@ -48,6 +48,7 @@ int nfp_shared_buf_pool_get(struct nfp_pf *pf, unsigned int sb, u16 pool_index, · 47 unmodified lines
48 pool_info->pool_type = le32_to_cpu(get_data.pool_type);48 pool_info->pool_type = le32_to_cpu(get_data.pool_type);
49 pool_info->threshold_type = le32_to_cpu(get_data.threshold_type);49 pool_info->threshold_type = le32_to_cpu(get_data.threshold_type);
50 pool_info->size = le32_to_cpu(get_data.size) * unit_size;50 pool_info->size = le32_to_cpu(get_data.size) * unit_size;
51 pool_info->cell_size = unit_size;
51 52
52 return 0;53 return 0;
53}54}
include/net/devlink.h+1−0
@@ -62,6 +62,7 @@ struct devlink_sb_pool_info { · 61 unmodified lines
62 enum devlink_sb_pool_type pool_type;62 enum devlink_sb_pool_type pool_type;
63 u32 size;63 u32 size;
64 enum devlink_sb_threshold_type threshold_type;64 enum devlink_sb_threshold_type threshold_type;
65 u32 cell_size;
65};66};
66 67
67/**68/**
include/uapi/linux/devlink.h+2−0
@@ -300,6 +300,8 @@ enum devlink_attr { · 299 unmodified lines
300 DEVLINK_ATTR_INFO_VERSION_NAME, /* string */300 DEVLINK_ATTR_INFO_VERSION_NAME, /* string */
301 DEVLINK_ATTR_INFO_VERSION_VALUE, /* string */301 DEVLINK_ATTR_INFO_VERSION_VALUE, /* string */
302 302
303 DEVLINK_ATTR_SB_POOL_CELL_SIZE, /* u32 */
304
303 /* add new attributes above here, update the policy in devlink.c */305 /* add new attributes above here, update the policy in devlink.c */
304 306
305 __DEVLINK_ATTR_MAX,307 __DEVLINK_ATTR_MAX,
net/core/devlink.c+3−0
@@ -932,6 +932,9 @@ static int devlink_nl_sb_pool_fill(struct sk_buff *msg, struct devlink *devlink, · 931 unmodified lines
932 if (nla_put_u8(msg, DEVLINK_ATTR_SB_POOL_THRESHOLD_TYPE,932 if (nla_put_u8(msg, DEVLINK_ATTR_SB_POOL_THRESHOLD_TYPE,
933 pool_info.threshold_type))933 pool_info.threshold_type))
934 goto nla_put_failure;934 goto nla_put_failure;
935 if (nla_put_u32(msg, DEVLINK_ATTR_SB_POOL_CELL_SIZE,
936 pool_info.cell_size))
937 goto nla_put_failure;
935 938
936 genlmsg_end(msg, hdr);939 genlmsg_end(msg, hdr);
937 return 0;940 return 0;