Skip to content

Commit 6a56e19

Browse files
zhengbaowendavem330
authored andcommitted
flow_offload: reject configuration of packet-per-second policing in offload drivers
A follow-up patch will allow users to configures packet-per-second policing in the software datapath. In preparation for this, teach all drivers that support offload of the policer action to reject such configuration as currently none of them support it. Signed-off-by: Baowen Zheng <baowen.zheng@corigine.com> Signed-off-by: Simon Horman <simon.horman@netronome.com> Signed-off-by: Louis Peens <louis.peens@netronome.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 2566015 commit 6a56e19

8 files changed

Lines changed: 46 additions & 1 deletion

File tree

‎drivers/net/dsa/sja1105/sja1105_flower.c‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,12 @@ int sja1105_cls_flower_add(struct dsa_switch *ds, int port,
322322
flow_action_for_each(i, act, &rule->action) {
323323
switch (act->id) {
324324
case FLOW_ACTION_POLICE:
325+
if (act->police.rate_pkt_ps) {
326+
NL_SET_ERR_MSG_MOD(extack,
327+
"QoS offload not support packets per second");
328+
goto out;
329+
}
330+
325331
rc = sja1105_flower_policer(priv, port, extack, cookie,
326332
&key,
327333
act->police.rate_bytes_ps,

‎drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_matchall.c‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ static int cxgb4_matchall_egress_validate(struct net_device *dev,
4848
flow_action_for_each(i, entry, actions) {
4949
switch (entry->id) {
5050
case FLOW_ACTION_POLICE:
51+
if (entry->police.rate_pkt_ps) {
52+
NL_SET_ERR_MSG_MOD(extack,
53+
"QoS offload not support packets per second");
54+
return -EOPNOTSUPP;
55+
}
5156
/* Convert bytes per second to bits per second */
5257
if (entry->police.rate_bytes_ps * 8 > max_link_rate) {
5358
NL_SET_ERR_MSG_MOD(extack,
@@ -145,7 +150,11 @@ static int cxgb4_matchall_alloc_tc(struct net_device *dev,
145150
flow_action_for_each(i, entry, &cls->rule->action)
146151
if (entry->id == FLOW_ACTION_POLICE)
147152
break;
148-
153+
if (entry->police.rate_pkt_ps) {
154+
NL_SET_ERR_MSG_MOD(extack,
155+
"QoS offload not support packets per second");
156+
return -EOPNOTSUPP;
157+
}
149158
/* Convert from bytes per second to Kbps */
150159
p.u.params.maxrate = div_u64(entry->police.rate_bytes_ps * 8, 1000);
151160
p.u.params.channel = pi->tx_chan;

‎drivers/net/ethernet/freescale/enetc/enetc_qos.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1221,6 +1221,11 @@ static int enetc_psfp_parse_clsflower(struct enetc_ndev_priv *priv,
12211221

12221222
/* Flow meter and max frame size */
12231223
if (entryp) {
1224+
if (entryp->police.rate_pkt_ps) {
1225+
NL_SET_ERR_MSG_MOD(extack, "QoS offload not support packets per second");
1226+
err = -EOPNOTSUPP;
1227+
goto free_sfi;
1228+
}
12241229
if (entryp->police.burst) {
12251230
fmi = kzalloc(sizeof(*fmi), GFP_KERNEL);
12261231
if (!fmi) {

‎drivers/net/ethernet/mellanox/mlx5/core/en_tc.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4538,6 +4538,10 @@ static int scan_tc_matchall_fdb_actions(struct mlx5e_priv *priv,
45384538
flow_action_for_each(i, act, flow_action) {
45394539
switch (act->id) {
45404540
case FLOW_ACTION_POLICE:
4541+
if (act->police.rate_pkt_ps) {
4542+
NL_SET_ERR_MSG_MOD(extack, "QoS offload not support packets per second");
4543+
return -EOPNOTSUPP;
4544+
}
45414545
err = apply_police_params(priv, act->police.rate_bytes_ps, extack);
45424546
if (err)
45434547
return err;

‎drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,11 @@ static int mlxsw_sp_flower_parse_actions(struct mlxsw_sp *mlxsw_sp,
190190
return -EOPNOTSUPP;
191191
}
192192

193+
if (act->police.rate_pkt_ps) {
194+
NL_SET_ERR_MSG_MOD(extack, "QoS offload not support packets per second");
195+
return -EOPNOTSUPP;
196+
}
197+
193198
/* The kernel might adjust the requested burst size so
194199
* that it is not exactly a power of two. Re-adjust it
195200
* here since the hardware only supports burst sizes

‎drivers/net/ethernet/mscc/ocelot_flower.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,11 @@ static int ocelot_flower_parse_action(struct ocelot *ocelot, int port,
220220
"Last action must be GOTO");
221221
return -EOPNOTSUPP;
222222
}
223+
if (a->police.rate_pkt_ps) {
224+
NL_SET_ERR_MSG_MOD(extack,
225+
"QoS offload not support packets per second");
226+
return -EOPNOTSUPP;
227+
}
223228
filter->action.police_ena = true;
224229
rate = a->police.rate_bytes_ps;
225230
filter->action.pol.rate = div_u64(rate, 1000) * 8;

‎drivers/net/ethernet/mscc/ocelot_net.c‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,12 @@ static int ocelot_setup_tc_cls_matchall(struct ocelot_port_private *priv,
251251
return -EEXIST;
252252
}
253253

254+
if (action->police.rate_pkt_ps) {
255+
NL_SET_ERR_MSG_MOD(extack,
256+
"QoS offload not support packets per second");
257+
return -EOPNOTSUPP;
258+
}
259+
254260
pol.rate = (u32)div_u64(action->police.rate_bytes_ps, 1000) * 8;
255261
pol.burst = action->police.burst;
256262

‎drivers/net/ethernet/netronome/nfp/flower/qos_conf.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,11 @@ nfp_flower_install_rate_limiter(struct nfp_app *app, struct net_device *netdev,
104104
return -EOPNOTSUPP;
105105
}
106106

107+
if (action->police.rate_pkt_ps) {
108+
NL_SET_ERR_MSG_MOD(extack, "unsupported offload: qos rate limit offload not support packets per second");
109+
return -EOPNOTSUPP;
110+
}
111+
107112
rate = action->police.rate_bytes_ps;
108113
burst = action->police.burst;
109114
netdev_port_id = nfp_repr_get_port_id(netdev);

0 commit comments

Comments
 (0)