]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
mlxsw: spectrum_flower: Offload FLOW_ACTION_PRIORITY
authorPetr Machata <petrm@mellanox.com>
Thu, 19 Mar 2020 13:47:23 +0000 (15:47 +0200)
committerDavid S. Miller <davem@davemloft.net>
Fri, 20 Mar 2020 04:09:20 +0000 (21:09 -0700)
Offload action skbedit priority when keyed to a flower classifier. The
skb->priority field in Linux is very generic, so only allow setting the
bottom 8 priorities and bounce anything else.

Signed-off-by: Petr Machata <petrm@mellanox.com>
Reviewed-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-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
drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c

index fbb76377adf8f146cb4a802778f84001f3593aee..c713bc22da7df5e120a3f537893ef4ebf86606fe 100644 (file)
@@ -1273,6 +1273,24 @@ mlxsw_afa_qos_switch_prio_pack(char *payload,
        mlxsw_afa_qos_switch_prio_set(payload, prio);
 }
 
+int mlxsw_afa_block_append_qos_switch_prio(struct mlxsw_afa_block *block,
+                                          u8 prio,
+                                          struct netlink_ext_ack *extack)
+{
+       char *act = mlxsw_afa_block_append_action(block,
+                                                 MLXSW_AFA_QOS_CODE,
+                                                 MLXSW_AFA_QOS_SIZE);
+
+       if (IS_ERR(act)) {
+               NL_SET_ERR_MSG_MOD(extack, "Cannot append QOS action");
+               return PTR_ERR(act);
+       }
+       mlxsw_afa_qos_switch_prio_pack(act, MLXSW_AFA_QOS_CMD_SET,
+                                      prio);
+       return 0;
+}
+EXPORT_SYMBOL(mlxsw_afa_block_append_qos_switch_prio);
+
 /* Forwarding Action
  * -----------------
  * Forwarding Action can be used to implement Policy Based Switching (PBS)
index 5f4c1e5051368df84f5a2440c64de26350ce9420..2125d7d6bcb0d70ab822ed3f868d2a8d12a8c708 100644 (file)
@@ -62,6 +62,9 @@ int mlxsw_afa_block_append_fwd(struct mlxsw_afa_block *block,
 int mlxsw_afa_block_append_vlan_modify(struct mlxsw_afa_block *block,
                                       u16 vid, u8 pcp, u8 et,
                                       struct netlink_ext_ack *extack);
+int mlxsw_afa_block_append_qos_switch_prio(struct mlxsw_afa_block *block,
+                                          u8 prio,
+                                          struct netlink_ext_ack *extack);
 int mlxsw_afa_block_append_allocated_counter(struct mlxsw_afa_block *block,
                                             u32 counter_index);
 int mlxsw_afa_block_append_counter(struct mlxsw_afa_block *block,
index 57d8c95e4f9f50811187cb95b4b44df218fdceba..bbd8bec8fee4c602df3205a1d81ba0a296aea60d 100644 (file)
@@ -746,6 +746,9 @@ int mlxsw_sp_acl_rulei_act_vlan(struct mlxsw_sp *mlxsw_sp,
                                struct mlxsw_sp_acl_rule_info *rulei,
                                u32 action, u16 vid, u16 proto, u8 prio,
                                struct netlink_ext_ack *extack);
+int mlxsw_sp_acl_rulei_act_priority(struct mlxsw_sp *mlxsw_sp,
+                                   struct mlxsw_sp_acl_rule_info *rulei,
+                                   u32 prio, struct netlink_ext_ack *extack);
 int mlxsw_sp_acl_rulei_act_count(struct mlxsw_sp *mlxsw_sp,
                                 struct mlxsw_sp_acl_rule_info *rulei,
                                 struct netlink_ext_ack *extack);
index 6f8d5005ff3674a8c8e77a7976e94a0c06ff4d51..01324d002680acdab77fb25c7909df76e4d68796 100644 (file)
@@ -638,6 +638,23 @@ int mlxsw_sp_acl_rulei_act_vlan(struct mlxsw_sp *mlxsw_sp,
        }
 }
 
+int mlxsw_sp_acl_rulei_act_priority(struct mlxsw_sp *mlxsw_sp,
+                                   struct mlxsw_sp_acl_rule_info *rulei,
+                                   u32 prio, struct netlink_ext_ack *extack)
+{
+       /* Even though both Linux and Spectrum switches support 16 priorities,
+        * spectrum_qdisc only processes the first eight priomap elements, and
+        * the DCB and PFC features are tied to 8 priorities as well. Therefore
+        * bounce attempts to prioritize packets to higher priorities.
+        */
+       if (prio >= IEEE_8021QAZ_MAX_TCS) {
+               NL_SET_ERR_MSG_MOD(extack, "Only priorities 0..7 are supported");
+               return -EINVAL;
+       }
+       return mlxsw_afa_block_append_qos_switch_prio(rulei->act_block, prio,
+                                                     extack);
+}
+
 int mlxsw_sp_acl_rulei_act_count(struct mlxsw_sp *mlxsw_sp,
                                 struct mlxsw_sp_acl_rule_info *rulei,
                                 struct netlink_ext_ack *extack)
index 21c4b10d106c19cdbca99090257f424ac49b6ae0..1cb023955d8f9f3287fefb2b9fcaa22477b940b8 100644 (file)
@@ -154,6 +154,10 @@ static int mlxsw_sp_flower_parse_actions(struct mlxsw_sp *mlxsw_sp,
                                                           act->id, vid,
                                                           proto, prio, extack);
                        }
+               case FLOW_ACTION_PRIORITY:
+                       return mlxsw_sp_acl_rulei_act_priority(mlxsw_sp, rulei,
+                                                              act->priority,
+                                                              extack);
                default:
                        NL_SET_ERR_MSG_MOD(extack, "Unsupported action");
                        dev_err(mlxsw_sp->bus_info->dev, "Unsupported action\n");