mlxsw: spectrum_router: Introduce FIB entry update op
authorJiri Pirko <jiri@nvidia.com>
Tue, 10 Nov 2020 09:49:00 +0000 (11:49 +0200)
committerJakub Kicinski <kuba@kernel.org>
Thu, 12 Nov 2020 23:55:22 +0000 (15:55 -0800)
Follow-up patchset introducing XMDR implementation is going to need
to distinguish write and update ops. Therefore introduce "update op"
and call "write op" only when new FIB entry is inserted.

Signed-off-by: Jiri Pirko <jiri@nvidia.com>
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.h

index ef95d126d29aaa4672f1142fbd1d91ca39cb40c4..e692e5a39f6c28c3d31a352cd72482531d12ffb0 100644 (file)
@@ -4350,6 +4350,7 @@ mlxsw_sp_fib_entry_hw_flags_refresh(struct mlxsw_sp *mlxsw_sp,
 {
        switch (op) {
        case MLXSW_SP_FIB_ENTRY_OP_WRITE:
+       case MLXSW_SP_FIB_ENTRY_OP_UPDATE:
                mlxsw_sp_fib_entry_hw_flags_set(mlxsw_sp, fib_entry);
                break;
        case MLXSW_SP_FIB_ENTRY_OP_DELETE:
@@ -4381,6 +4382,7 @@ mlxsw_sp_router_ll_basic_fib_entry_pack(struct mlxsw_sp_fib_entry_op_ctx *op_ctx
 
        switch (op) {
        case MLXSW_SP_FIB_ENTRY_OP_WRITE:
+       case MLXSW_SP_FIB_ENTRY_OP_UPDATE:
                ralue_op = MLXSW_REG_RALUE_OP_WRITE_WRITE;
                break;
        case MLXSW_SP_FIB_ENTRY_OP_DELETE:
@@ -4699,10 +4701,12 @@ static int mlxsw_sp_fib_entry_op(struct mlxsw_sp *mlxsw_sp,
 
 static int __mlxsw_sp_fib_entry_update(struct mlxsw_sp *mlxsw_sp,
                                       struct mlxsw_sp_fib_entry_op_ctx *op_ctx,
-                                      struct mlxsw_sp_fib_entry *fib_entry)
+                                      struct mlxsw_sp_fib_entry *fib_entry,
+                                      bool is_new)
 {
        return mlxsw_sp_fib_entry_op(mlxsw_sp, op_ctx, fib_entry,
-                                    MLXSW_SP_FIB_ENTRY_OP_WRITE);
+                                    is_new ? MLXSW_SP_FIB_ENTRY_OP_WRITE :
+                                             MLXSW_SP_FIB_ENTRY_OP_UPDATE);
 }
 
 static int mlxsw_sp_fib_entry_update(struct mlxsw_sp *mlxsw_sp,
@@ -4711,7 +4715,7 @@ static int mlxsw_sp_fib_entry_update(struct mlxsw_sp *mlxsw_sp,
        struct mlxsw_sp_fib_entry_op_ctx *op_ctx = mlxsw_sp->router->ll_op_ctx;
 
        mlxsw_sp_fib_entry_op_ctx_clear(op_ctx);
-       return __mlxsw_sp_fib_entry_update(mlxsw_sp, op_ctx, fib_entry);
+       return __mlxsw_sp_fib_entry_update(mlxsw_sp, op_ctx, fib_entry, false);
 }
 
 static int mlxsw_sp_fib_entry_del(struct mlxsw_sp *mlxsw_sp,
@@ -5091,11 +5095,12 @@ static int mlxsw_sp_fib_node_entry_link(struct mlxsw_sp *mlxsw_sp,
                                        struct mlxsw_sp_fib_entry *fib_entry)
 {
        struct mlxsw_sp_fib_node *fib_node = fib_entry->fib_node;
+       bool is_new = !fib_node->fib_entry;
        int err;
 
        fib_node->fib_entry = fib_entry;
 
-       err = __mlxsw_sp_fib_entry_update(mlxsw_sp, op_ctx, fib_entry);
+       err = __mlxsw_sp_fib_entry_update(mlxsw_sp, op_ctx, fib_entry, is_new);
        if (err)
                goto err_fib_entry_update;
 
@@ -5509,7 +5514,8 @@ static int mlxsw_sp_nexthop6_group_update(struct mlxsw_sp *mlxsw_sp,
         * currently associated with it in the device's table is that
         * of the old group. Start using the new one instead.
         */
-       err = __mlxsw_sp_fib_entry_update(mlxsw_sp, op_ctx, &fib6_entry->common);
+       err = __mlxsw_sp_fib_entry_update(mlxsw_sp, op_ctx,
+                                         &fib6_entry->common, false);
        if (err)
                goto err_fib_entry_update;
 
index ed651b4200cb345dff8fcc1869ef752b50a499ee..8230f6ff02edee1d9fb195e48fcef28a50b2c891 100644 (file)
@@ -84,6 +84,7 @@ struct mlxsw_sp_fib_entry_priv {
 
 enum mlxsw_sp_fib_entry_op {
        MLXSW_SP_FIB_ENTRY_OP_WRITE,
+       MLXSW_SP_FIB_ENTRY_OP_UPDATE,
        MLXSW_SP_FIB_ENTRY_OP_DELETE,
 };