Skip to content

Commit 1312444

Browse files
Arkadi Sharshevskydavem330
authored andcommitted
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: Arkadi Sharshevsky <[email protected]> Reviewed-by: Ido Schimmel <[email protected]> Signed-off-by: Jiri Pirko <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 2239cc6 commit 1312444

File tree

4 files changed

+15
-17
lines changed

4 files changed

+15
-17
lines changed

drivers/net/ethernet/mellanox/mlxsw/spectrum.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,8 @@ int mlxsw_sp_bridge_vrf_join(struct mlxsw_sp *mlxsw_sp,
583583
void mlxsw_sp_bridge_vrf_leave(struct mlxsw_sp *mlxsw_sp,
584584
struct net_device *l3_dev);
585585

586-
int mlxsw_sp_kvdl_alloc(struct mlxsw_sp *mlxsw_sp, unsigned int entry_count);
586+
int mlxsw_sp_kvdl_alloc(struct mlxsw_sp *mlxsw_sp, unsigned int entry_count,
587+
u32 *p_entry_index);
587588
void mlxsw_sp_kvdl_free(struct mlxsw_sp *mlxsw_sp, int entry_index);
588589

589590
struct mlxsw_afk *mlxsw_sp_acl_afk(struct mlxsw_sp_acl *acl);

drivers/net/ethernet/mellanox/mlxsw/spectrum_acl.c

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,6 @@ static int mlxsw_sp_act_kvdl_set_add(void *priv, u32 *p_kvdl_index,
595595
struct mlxsw_sp *mlxsw_sp = priv;
596596
char pefa_pl[MLXSW_REG_PEFA_LEN];
597597
u32 kvdl_index;
598-
int ret;
599598
int err;
600599

601600
/* 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,
604603
if (is_first)
605604
return 0;
606605

607-
ret = mlxsw_sp_kvdl_alloc(mlxsw_sp, MLXSW_SP_KDVL_ACT_EXT_SIZE);
608-
if (ret < 0)
609-
return ret;
610-
kvdl_index = ret;
606+
err = mlxsw_sp_kvdl_alloc(mlxsw_sp, MLXSW_SP_KDVL_ACT_EXT_SIZE,
607+
&kvdl_index);
608+
if (err)
609+
return err;
611610
mlxsw_reg_pefa_pack(pefa_pl, kvdl_index, enc_actions);
612611
err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(pefa), pefa_pl);
613612
if (err)
@@ -636,13 +635,11 @@ static int mlxsw_sp_act_kvdl_fwd_entry_add(void *priv, u32 *p_kvdl_index,
636635
struct mlxsw_sp *mlxsw_sp = priv;
637636
char ppbs_pl[MLXSW_REG_PPBS_LEN];
638637
u32 kvdl_index;
639-
int ret;
640638
int err;
641639

642-
ret = mlxsw_sp_kvdl_alloc(mlxsw_sp, 1);
643-
if (ret < 0)
644-
return ret;
645-
kvdl_index = ret;
640+
err = mlxsw_sp_kvdl_alloc(mlxsw_sp, 1, &kvdl_index);
641+
if (err)
642+
return err;
646643
mlxsw_reg_ppbs_pack(ppbs_pl, kvdl_index, local_port);
647644
err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(ppbs), ppbs_pl);
648645
if (err)

drivers/net/ethernet/mellanox/mlxsw/spectrum_kvdl.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@
4545
(MLXSW_SP_KVD_LINEAR_SIZE - MLXSW_SP_KVDL_CHUNKS_BASE)
4646
#define MLXSW_SP_CHUNK_MAX 32
4747

48-
int mlxsw_sp_kvdl_alloc(struct mlxsw_sp *mlxsw_sp, unsigned int entry_count)
48+
int mlxsw_sp_kvdl_alloc(struct mlxsw_sp *mlxsw_sp, unsigned int entry_count,
49+
u32 *p_entry_index)
4950
{
5051
int entry_index;
5152
int size;
@@ -72,7 +73,8 @@ int mlxsw_sp_kvdl_alloc(struct mlxsw_sp *mlxsw_sp, unsigned int entry_count)
7273

7374
for (i = 0; i < type_entries; i++)
7475
set_bit(entry_index + i, mlxsw_sp->kvdl.usage);
75-
return entry_index;
76+
*p_entry_index = entry_index;
77+
return 0;
7678
}
7779
return -ENOBUFS;
7880
}

drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1274,7 +1274,6 @@ mlxsw_sp_nexthop_group_refresh(struct mlxsw_sp *mlxsw_sp,
12741274
bool old_adj_index_valid;
12751275
u32 old_adj_index;
12761276
u16 old_ecmp_size;
1277-
int ret;
12781277
int i;
12791278
int err;
12801279

@@ -1312,15 +1311,14 @@ mlxsw_sp_nexthop_group_refresh(struct mlxsw_sp *mlxsw_sp,
13121311
*/
13131312
goto set_trap;
13141313

1315-
ret = mlxsw_sp_kvdl_alloc(mlxsw_sp, ecmp_size);
1316-
if (ret < 0) {
1314+
err = mlxsw_sp_kvdl_alloc(mlxsw_sp, ecmp_size, &adj_index);
1315+
if (err) {
13171316
/* We ran out of KVD linear space, just set the
13181317
* trap and let everything flow through kernel.
13191318
*/
13201319
dev_warn(mlxsw_sp->bus_info->dev, "Failed to allocate KVD linear area for nexthop group.\n");
13211320
goto set_trap;
13221321
}
1323-
adj_index = ret;
13241322
old_adj_index_valid = nh_grp->adj_index_valid;
13251323
old_adj_index = nh_grp->adj_index;
13261324
old_ecmp_size = nh_grp->ecmp_size;

0 commit comments

Comments
 (0)