| .. | .. |
|---|
| 136 | 136 | const struct net_device *out_dev, |
|---|
| 137 | 137 | bool ingress, int *p_span_id) |
|---|
| 138 | 138 | { |
|---|
| 139 | | - struct mlxsw_sp_port *in_port; |
|---|
| 139 | + struct mlxsw_sp_span_agent_parms agent_parms = {}; |
|---|
| 140 | + struct mlxsw_sp_port *mlxsw_sp_port; |
|---|
| 140 | 141 | struct mlxsw_sp *mlxsw_sp = priv; |
|---|
| 141 | | - enum mlxsw_sp_span_type type; |
|---|
| 142 | + int err; |
|---|
| 142 | 143 | |
|---|
| 143 | | - type = ingress ? MLXSW_SP_SPAN_INGRESS : MLXSW_SP_SPAN_EGRESS; |
|---|
| 144 | | - in_port = mlxsw_sp->ports[local_in_port]; |
|---|
| 144 | + agent_parms.to_dev = out_dev; |
|---|
| 145 | + err = mlxsw_sp_span_agent_get(mlxsw_sp, p_span_id, &agent_parms); |
|---|
| 146 | + if (err) |
|---|
| 147 | + return err; |
|---|
| 145 | 148 | |
|---|
| 146 | | - return mlxsw_sp_span_mirror_add(in_port, out_dev, type, |
|---|
| 147 | | - false, p_span_id); |
|---|
| 149 | + mlxsw_sp_port = mlxsw_sp->ports[local_in_port]; |
|---|
| 150 | + err = mlxsw_sp_span_analyzed_port_get(mlxsw_sp_port, ingress); |
|---|
| 151 | + if (err) |
|---|
| 152 | + goto err_analyzed_port_get; |
|---|
| 153 | + |
|---|
| 154 | + return 0; |
|---|
| 155 | + |
|---|
| 156 | +err_analyzed_port_get: |
|---|
| 157 | + mlxsw_sp_span_agent_put(mlxsw_sp, *p_span_id); |
|---|
| 158 | + return err; |
|---|
| 148 | 159 | } |
|---|
| 149 | 160 | |
|---|
| 150 | 161 | static void |
|---|
| 151 | 162 | mlxsw_sp_act_mirror_del(void *priv, u8 local_in_port, int span_id, bool ingress) |
|---|
| 152 | 163 | { |
|---|
| 164 | + struct mlxsw_sp_port *mlxsw_sp_port; |
|---|
| 153 | 165 | struct mlxsw_sp *mlxsw_sp = priv; |
|---|
| 154 | | - struct mlxsw_sp_port *in_port; |
|---|
| 155 | | - enum mlxsw_sp_span_type type; |
|---|
| 156 | 166 | |
|---|
| 157 | | - type = ingress ? MLXSW_SP_SPAN_INGRESS : MLXSW_SP_SPAN_EGRESS; |
|---|
| 158 | | - in_port = mlxsw_sp->ports[local_in_port]; |
|---|
| 167 | + mlxsw_sp_port = mlxsw_sp->ports[local_in_port]; |
|---|
| 168 | + mlxsw_sp_span_analyzed_port_put(mlxsw_sp_port, ingress); |
|---|
| 169 | + mlxsw_sp_span_agent_put(mlxsw_sp, span_id); |
|---|
| 170 | +} |
|---|
| 159 | 171 | |
|---|
| 160 | | - mlxsw_sp_span_mirror_del(in_port, span_id, type, false); |
|---|
| 172 | +static int mlxsw_sp_act_policer_add(void *priv, u64 rate_bytes_ps, u32 burst, |
|---|
| 173 | + u16 *p_policer_index, |
|---|
| 174 | + struct netlink_ext_ack *extack) |
|---|
| 175 | +{ |
|---|
| 176 | + struct mlxsw_sp_policer_params params; |
|---|
| 177 | + struct mlxsw_sp *mlxsw_sp = priv; |
|---|
| 178 | + |
|---|
| 179 | + params.rate = rate_bytes_ps; |
|---|
| 180 | + params.burst = burst; |
|---|
| 181 | + params.bytes = true; |
|---|
| 182 | + return mlxsw_sp_policer_add(mlxsw_sp, |
|---|
| 183 | + MLXSW_SP_POLICER_TYPE_SINGLE_RATE, |
|---|
| 184 | + ¶ms, extack, p_policer_index); |
|---|
| 185 | +} |
|---|
| 186 | + |
|---|
| 187 | +static void mlxsw_sp_act_policer_del(void *priv, u16 policer_index) |
|---|
| 188 | +{ |
|---|
| 189 | + struct mlxsw_sp *mlxsw_sp = priv; |
|---|
| 190 | + |
|---|
| 191 | + mlxsw_sp_policer_del(mlxsw_sp, MLXSW_SP_POLICER_TYPE_SINGLE_RATE, |
|---|
| 192 | + policer_index); |
|---|
| 161 | 193 | } |
|---|
| 162 | 194 | |
|---|
| 163 | 195 | const struct mlxsw_afa_ops mlxsw_sp1_act_afa_ops = { |
|---|
| .. | .. |
|---|
| 170 | 202 | .counter_index_put = mlxsw_sp_act_counter_index_put, |
|---|
| 171 | 203 | .mirror_add = mlxsw_sp_act_mirror_add, |
|---|
| 172 | 204 | .mirror_del = mlxsw_sp_act_mirror_del, |
|---|
| 205 | + .policer_add = mlxsw_sp_act_policer_add, |
|---|
| 206 | + .policer_del = mlxsw_sp_act_policer_del, |
|---|
| 173 | 207 | }; |
|---|
| 174 | 208 | |
|---|
| 175 | 209 | const struct mlxsw_afa_ops mlxsw_sp2_act_afa_ops = { |
|---|
| .. | .. |
|---|
| 182 | 216 | .counter_index_put = mlxsw_sp_act_counter_index_put, |
|---|
| 183 | 217 | .mirror_add = mlxsw_sp_act_mirror_add, |
|---|
| 184 | 218 | .mirror_del = mlxsw_sp_act_mirror_del, |
|---|
| 219 | + .policer_add = mlxsw_sp_act_policer_add, |
|---|
| 220 | + .policer_del = mlxsw_sp_act_policer_del, |
|---|
| 185 | 221 | .dummy_first_set = true, |
|---|
| 186 | 222 | }; |
|---|
| 187 | 223 | |
|---|