Commit 13124443 authored by Arkadi Sharshevsky's avatar Arkadi Sharshevsky Committed by David S. Miller

mlxsw: spectrum_kvdl: Cosmetic kvdl allocator API change

Currently the return allocated index and err value are multiplexed.
This patch changes the API to decouple the ret value from the allocated
index.
Signed-off-by: default avatarArkadi Sharshevsky <arkadis@mellanox.com>
Reviewed-by: default avatarIdo Schimmel <idosch@mellanox.com>
Signed-off-by: default avatarJiri Pirko <jiri@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 2239cc63
...@@ -583,7 +583,8 @@ int mlxsw_sp_bridge_vrf_join(struct mlxsw_sp *mlxsw_sp, ...@@ -583,7 +583,8 @@ int mlxsw_sp_bridge_vrf_join(struct mlxsw_sp *mlxsw_sp,
void mlxsw_sp_bridge_vrf_leave(struct mlxsw_sp *mlxsw_sp, void mlxsw_sp_bridge_vrf_leave(struct mlxsw_sp *mlxsw_sp,
struct net_device *l3_dev); struct net_device *l3_dev);
int mlxsw_sp_kvdl_alloc(struct mlxsw_sp *mlxsw_sp, unsigned int entry_count); int mlxsw_sp_kvdl_alloc(struct mlxsw_sp *mlxsw_sp, unsigned int entry_count,
u32 *p_entry_index);
void mlxsw_sp_kvdl_free(struct mlxsw_sp *mlxsw_sp, int entry_index); void mlxsw_sp_kvdl_free(struct mlxsw_sp *mlxsw_sp, int entry_index);
struct mlxsw_afk *mlxsw_sp_acl_afk(struct mlxsw_sp_acl *acl); struct mlxsw_afk *mlxsw_sp_acl_afk(struct mlxsw_sp_acl *acl);
......
...@@ -595,7 +595,6 @@ static int mlxsw_sp_act_kvdl_set_add(void *priv, u32 *p_kvdl_index, ...@@ -595,7 +595,6 @@ static int mlxsw_sp_act_kvdl_set_add(void *priv, u32 *p_kvdl_index,
struct mlxsw_sp *mlxsw_sp = priv; struct mlxsw_sp *mlxsw_sp = priv;
char pefa_pl[MLXSW_REG_PEFA_LEN]; char pefa_pl[MLXSW_REG_PEFA_LEN];
u32 kvdl_index; u32 kvdl_index;
int ret;
int err; int err;
/* The first action set of a TCAM entry is stored directly in TCAM, /* The first action set of a TCAM entry is stored directly in TCAM,
...@@ -604,10 +603,10 @@ static int mlxsw_sp_act_kvdl_set_add(void *priv, u32 *p_kvdl_index, ...@@ -604,10 +603,10 @@ static int mlxsw_sp_act_kvdl_set_add(void *priv, u32 *p_kvdl_index,
if (is_first) if (is_first)
return 0; return 0;
ret = mlxsw_sp_kvdl_alloc(mlxsw_sp, MLXSW_SP_KDVL_ACT_EXT_SIZE); err = mlxsw_sp_kvdl_alloc(mlxsw_sp, MLXSW_SP_KDVL_ACT_EXT_SIZE,
if (ret < 0) &kvdl_index);
return ret; if (err)
kvdl_index = ret; return err;
mlxsw_reg_pefa_pack(pefa_pl, kvdl_index, enc_actions); mlxsw_reg_pefa_pack(pefa_pl, kvdl_index, enc_actions);
err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(pefa), pefa_pl); err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(pefa), pefa_pl);
if (err) if (err)
...@@ -636,13 +635,11 @@ static int mlxsw_sp_act_kvdl_fwd_entry_add(void *priv, u32 *p_kvdl_index, ...@@ -636,13 +635,11 @@ static int mlxsw_sp_act_kvdl_fwd_entry_add(void *priv, u32 *p_kvdl_index,
struct mlxsw_sp *mlxsw_sp = priv; struct mlxsw_sp *mlxsw_sp = priv;
char ppbs_pl[MLXSW_REG_PPBS_LEN]; char ppbs_pl[MLXSW_REG_PPBS_LEN];
u32 kvdl_index; u32 kvdl_index;
int ret;
int err; int err;
ret = mlxsw_sp_kvdl_alloc(mlxsw_sp, 1); err = mlxsw_sp_kvdl_alloc(mlxsw_sp, 1, &kvdl_index);
if (ret < 0) if (err)
return ret; return err;
kvdl_index = ret;
mlxsw_reg_ppbs_pack(ppbs_pl, kvdl_index, local_port); mlxsw_reg_ppbs_pack(ppbs_pl, kvdl_index, local_port);
err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(ppbs), ppbs_pl); err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(ppbs), ppbs_pl);
if (err) if (err)
......
...@@ -45,7 +45,8 @@ ...@@ -45,7 +45,8 @@
(MLXSW_SP_KVD_LINEAR_SIZE - MLXSW_SP_KVDL_CHUNKS_BASE) (MLXSW_SP_KVD_LINEAR_SIZE - MLXSW_SP_KVDL_CHUNKS_BASE)
#define MLXSW_SP_CHUNK_MAX 32 #define MLXSW_SP_CHUNK_MAX 32
int mlxsw_sp_kvdl_alloc(struct mlxsw_sp *mlxsw_sp, unsigned int entry_count) int mlxsw_sp_kvdl_alloc(struct mlxsw_sp *mlxsw_sp, unsigned int entry_count,
u32 *p_entry_index)
{ {
int entry_index; int entry_index;
int size; int size;
...@@ -72,7 +73,8 @@ int mlxsw_sp_kvdl_alloc(struct mlxsw_sp *mlxsw_sp, unsigned int entry_count) ...@@ -72,7 +73,8 @@ int mlxsw_sp_kvdl_alloc(struct mlxsw_sp *mlxsw_sp, unsigned int entry_count)
for (i = 0; i < type_entries; i++) for (i = 0; i < type_entries; i++)
set_bit(entry_index + i, mlxsw_sp->kvdl.usage); set_bit(entry_index + i, mlxsw_sp->kvdl.usage);
return entry_index; *p_entry_index = entry_index;
return 0;
} }
return -ENOBUFS; return -ENOBUFS;
} }
......
...@@ -1274,7 +1274,6 @@ mlxsw_sp_nexthop_group_refresh(struct mlxsw_sp *mlxsw_sp, ...@@ -1274,7 +1274,6 @@ mlxsw_sp_nexthop_group_refresh(struct mlxsw_sp *mlxsw_sp,
bool old_adj_index_valid; bool old_adj_index_valid;
u32 old_adj_index; u32 old_adj_index;
u16 old_ecmp_size; u16 old_ecmp_size;
int ret;
int i; int i;
int err; int err;
...@@ -1312,15 +1311,14 @@ mlxsw_sp_nexthop_group_refresh(struct mlxsw_sp *mlxsw_sp, ...@@ -1312,15 +1311,14 @@ mlxsw_sp_nexthop_group_refresh(struct mlxsw_sp *mlxsw_sp,
*/ */
goto set_trap; goto set_trap;
ret = mlxsw_sp_kvdl_alloc(mlxsw_sp, ecmp_size); err = mlxsw_sp_kvdl_alloc(mlxsw_sp, ecmp_size, &adj_index);
if (ret < 0) { if (err) {
/* We ran out of KVD linear space, just set the /* We ran out of KVD linear space, just set the
* trap and let everything flow through kernel. * trap and let everything flow through kernel.
*/ */
dev_warn(mlxsw_sp->bus_info->dev, "Failed to allocate KVD linear area for nexthop group.\n"); dev_warn(mlxsw_sp->bus_info->dev, "Failed to allocate KVD linear area for nexthop group.\n");
goto set_trap; goto set_trap;
} }
adj_index = ret;
old_adj_index_valid = nh_grp->adj_index_valid; old_adj_index_valid = nh_grp->adj_index_valid;
old_adj_index = nh_grp->adj_index; old_adj_index = nh_grp->adj_index;
old_ecmp_size = nh_grp->ecmp_size; old_ecmp_size = nh_grp->ecmp_size;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment