]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
mlxsw: spectrum: Implement action to set FID
authorJiri Pirko <jiri@mellanox.com>
Tue, 18 Apr 2017 14:55:32 +0000 (16:55 +0200)
committerDavid S. Miller <davem@davemloft.net>
Thu, 20 Apr 2017 19:32:30 +0000 (15:32 -0400)
Implement part of multipurpose Virtual Router and Forwarding Domain
Action that takes care of setting up FID. We need to use it to be able
to forward packets using ACL action when no FID is associated on RX.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Reviewed-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.c
drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.h
drivers/net/ethernet/mellanox/mlxsw/spectrum.h
drivers/net/ethernet/mellanox/mlxsw/spectrum_acl.c

index a984c361926c7841cfcd12c9a7c5a2e17bfdc15c..46304ffb94491d26bc08b85e38249088f7f8338a 100644 (file)
@@ -811,3 +811,47 @@ int mlxsw_afa_block_append_counter(struct mlxsw_afa_block *block,
        return 0;
 }
 EXPORT_SYMBOL(mlxsw_afa_block_append_counter);
+
+/* Virtual Router and Forwarding Domain Action
+ * -------------------------------------------
+ * Virtual Switch action is used for manipulate the Virtual Router (VR),
+ * MPLS label space and the Forwarding Identifier (FID).
+ */
+
+#define MLXSW_AFA_VIRFWD_CODE 0x0E
+#define MLXSW_AFA_VIRFWD_SIZE 1
+
+enum mlxsw_afa_virfwd_fid_cmd {
+       /* Do nothing */
+       MLXSW_AFA_VIRFWD_FID_CMD_NOOP,
+       /* Set the Forwarding Identifier (FID) to fid */
+       MLXSW_AFA_VIRFWD_FID_CMD_SET,
+};
+
+/* afa_virfwd_fid_cmd */
+MLXSW_ITEM32(afa, virfwd, fid_cmd, 0x08, 29, 3);
+
+/* afa_virfwd_fid
+ * The FID value.
+ */
+MLXSW_ITEM32(afa, virfwd, fid, 0x08, 0, 16);
+
+static inline void mlxsw_afa_virfwd_pack(char *payload,
+                                        enum mlxsw_afa_virfwd_fid_cmd fid_cmd,
+                                        u16 fid)
+{
+       mlxsw_afa_virfwd_fid_cmd_set(payload, fid_cmd);
+       mlxsw_afa_virfwd_fid_set(payload, fid);
+}
+
+int mlxsw_afa_block_append_fid_set(struct mlxsw_afa_block *block, u16 fid)
+{
+       char *act = mlxsw_afa_block_append_action(block,
+                                                 MLXSW_AFA_VIRFWD_CODE,
+                                                 MLXSW_AFA_VIRFWD_SIZE);
+       if (!act)
+               return -ENOBUFS;
+       mlxsw_afa_virfwd_pack(act, MLXSW_AFA_VIRFWD_FID_CMD_SET, fid);
+       return 0;
+}
+EXPORT_SYMBOL(mlxsw_afa_block_append_fid_set);
index a03362c1ef3245cff5aba5c2dd07232614df094e..bd8b91d02880af893065c374da51965a4350d0f4 100644 (file)
@@ -66,5 +66,6 @@ int mlxsw_afa_block_append_vlan_modify(struct mlxsw_afa_block *block,
                                       u16 vid, u8 pcp, u8 et);
 int mlxsw_afa_block_append_counter(struct mlxsw_afa_block *block,
                                   u32 counter_index);
+int mlxsw_afa_block_append_fid_set(struct mlxsw_afa_block *block, u16 fid);
 
 #endif
index c245e4c3d9adc3a36a1a8451f3348eeaa68af5ce..3d32b158c07ed0ed853d186e47a3e98c86ad1fa3 100644 (file)
@@ -661,6 +661,9 @@ int mlxsw_sp_acl_rulei_act_vlan(struct mlxsw_sp *mlxsw_sp,
                                u32 action, u16 vid, u16 proto, u8 prio);
 int mlxsw_sp_acl_rulei_act_count(struct mlxsw_sp *mlxsw_sp,
                                 struct mlxsw_sp_acl_rule_info *rulei);
+int mlxsw_sp_acl_rulei_act_fid_set(struct mlxsw_sp *mlxsw_sp,
+                                  struct mlxsw_sp_acl_rule_info *rulei,
+                                  u16 fid);
 
 struct mlxsw_sp_acl_rule;
 
index d3b791f69f5bb8b0332a9321cc258a7d7573d3d3..317f7b14627f83dac576ebfca48e30f4e3b458e0 100644 (file)
@@ -403,6 +403,13 @@ int mlxsw_sp_acl_rulei_act_count(struct mlxsw_sp *mlxsw_sp,
                                              rulei->counter_index);
 }
 
+int mlxsw_sp_acl_rulei_act_fid_set(struct mlxsw_sp *mlxsw_sp,
+                                  struct mlxsw_sp_acl_rule_info *rulei,
+                                  u16 fid)
+{
+       return mlxsw_afa_block_append_fid_set(rulei->act_block, fid);
+}
+
 struct mlxsw_sp_acl_rule *
 mlxsw_sp_acl_rule_create(struct mlxsw_sp *mlxsw_sp,
                         struct mlxsw_sp_acl_ruleset *ruleset,