/* spectrum_matchall.c */
 struct mlxsw_sp_mall_ops {
        int (*sample_add)(struct mlxsw_sp *mlxsw_sp,
-                         struct mlxsw_sp_port *mlxsw_sp_port, u32 rate,
-                         struct netlink_ext_ack *extack);
+                         struct mlxsw_sp_port *mlxsw_sp_port, bool ingress,
+                         u32 rate, struct netlink_ext_ack *extack);
        void (*sample_del)(struct mlxsw_sp *mlxsw_sp,
                           struct mlxsw_sp_port *mlxsw_sp_port);
 };
 
        rcu_assign_pointer(mlxsw_sp_port->sample, &mall_entry->sample);
 
        err = mlxsw_sp->mall_ops->sample_add(mlxsw_sp, mlxsw_sp_port,
+                                            mall_entry->ingress,
                                             mall_entry->sample.rate, extack);
        if (err)
                goto err_port_sample_set;
                mall_entry->mirror.to_dev = act->dev;
        } else if (act->id == FLOW_ACTION_SAMPLE &&
                   protocol == htons(ETH_P_ALL)) {
-               if (!mall_entry->ingress) {
-                       NL_SET_ERR_MSG(f->common.extack, "Sample is not supported on egress");
-                       err = -EOPNOTSUPP;
-                       goto errout;
-               }
                if (flower_prio_valid &&
                    mall_entry->priority >= flower_min_prio) {
                        NL_SET_ERR_MSG(f->common.extack, "Failed to add behind existing flower rules");
                        err = -EOPNOTSUPP;
                        goto errout;
                }
-               if (act->sample.rate > MLXSW_REG_MPSC_RATE_MAX) {
-                       NL_SET_ERR_MSG(f->common.extack, "Sample rate not supported");
-                       err = -EOPNOTSUPP;
-                       goto errout;
-               }
                mall_entry->type = MLXSW_SP_MALL_ACTION_TYPE_SAMPLE;
                mall_entry->sample.psample_group = act->sample.psample_group;
                mall_entry->sample.truncate = act->sample.truncate;
 
 static int mlxsw_sp1_mall_sample_add(struct mlxsw_sp *mlxsw_sp,
                                     struct mlxsw_sp_port *mlxsw_sp_port,
-                                    u32 rate, struct netlink_ext_ack *extack)
+                                    bool ingress, u32 rate,
+                                    struct netlink_ext_ack *extack)
 {
+       if (!ingress) {
+               NL_SET_ERR_MSG(extack, "Sampling is not supported on egress");
+               return -EOPNOTSUPP;
+       }
+
+       if (rate > MLXSW_REG_MPSC_RATE_MAX) {
+               NL_SET_ERR_MSG(extack, "Unsupported sampling rate");
+               return -EOPNOTSUPP;
+       }
+
        return mlxsw_sp_mall_port_sample_set(mlxsw_sp_port, true, rate);
 }
 
 
 static int mlxsw_sp2_mall_sample_add(struct mlxsw_sp *mlxsw_sp,
                                     struct mlxsw_sp_port *mlxsw_sp_port,
-                                    u32 rate, struct netlink_ext_ack *extack)
+                                    bool ingress, u32 rate,
+                                    struct netlink_ext_ack *extack)
 {
        struct mlxsw_sp_span_trigger_parms trigger_parms = {};
        struct mlxsw_sp_span_agent_parms agent_parms = {
        struct mlxsw_sp_port_sample *sample;
        int err;
 
+       if (!ingress) {
+               NL_SET_ERR_MSG(extack, "Sampling is not supported on egress");
+               return -EOPNOTSUPP;
+       }
+
        sample = rtnl_dereference(mlxsw_sp_port->sample);
 
        err = mlxsw_sp_span_agent_get(mlxsw_sp, &sample->span_id, &agent_parms);