Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Baowen Zheng and committed by
David S. Miller
6a56e199 25660156

+46 -1
+6
drivers/net/dsa/sja1105/sja1105_flower.c
··· 322 322 flow_action_for_each(i, act, &rule->action) { 323 323 switch (act->id) { 324 324 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 + 325 331 rc = sja1105_flower_policer(priv, port, extack, cookie, 326 332 &key, 327 333 act->police.rate_bytes_ps,
+10 -1
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_matchall.c
··· 48 48 flow_action_for_each(i, entry, actions) { 49 49 switch (entry->id) { 50 50 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 + } 51 56 /* Convert bytes per second to bits per second */ 52 57 if (entry->police.rate_bytes_ps * 8 > max_link_rate) { 53 58 NL_SET_ERR_MSG_MOD(extack, ··· 150 145 flow_action_for_each(i, entry, &cls->rule->action) 151 146 if (entry->id == FLOW_ACTION_POLICE) 152 147 break; 153 - 148 + if (entry->police.rate_pkt_ps) { 149 + NL_SET_ERR_MSG_MOD(extack, 150 + "QoS offload not support packets per second"); 151 + return -EOPNOTSUPP; 152 + } 154 153 /* Convert from bytes per second to Kbps */ 155 154 p.u.params.maxrate = div_u64(entry->police.rate_bytes_ps * 8, 1000); 156 155 p.u.params.channel = pi->tx_chan;
+5
drivers/net/ethernet/freescale/enetc/enetc_qos.c
··· 1221 1221 1222 1222 /* Flow meter and max frame size */ 1223 1223 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 + } 1224 1229 if (entryp->police.burst) { 1225 1230 fmi = kzalloc(sizeof(*fmi), GFP_KERNEL); 1226 1231 if (!fmi) {
+4
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
··· 4538 4538 flow_action_for_each(i, act, flow_action) { 4539 4539 switch (act->id) { 4540 4540 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 + } 4541 4545 err = apply_police_params(priv, act->police.rate_bytes_ps, extack); 4542 4546 if (err) 4543 4547 return err;
+5
drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c
··· 190 190 return -EOPNOTSUPP; 191 191 } 192 192 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 + 193 198 /* The kernel might adjust the requested burst size so 194 199 * that it is not exactly a power of two. Re-adjust it 195 200 * here since the hardware only supports burst sizes
+5
drivers/net/ethernet/mscc/ocelot_flower.c
··· 220 220 "Last action must be GOTO"); 221 221 return -EOPNOTSUPP; 222 222 } 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 + } 223 228 filter->action.police_ena = true; 224 229 rate = a->police.rate_bytes_ps; 225 230 filter->action.pol.rate = div_u64(rate, 1000) * 8;
+6
drivers/net/ethernet/mscc/ocelot_net.c
··· 251 251 return -EEXIST; 252 252 } 253 253 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 + 254 260 pol.rate = (u32)div_u64(action->police.rate_bytes_ps, 1000) * 8; 255 261 pol.burst = action->police.burst; 256 262
+5
drivers/net/ethernet/netronome/nfp/flower/qos_conf.c
··· 104 104 return -EOPNOTSUPP; 105 105 } 106 106 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 + 107 112 rate = action->police.rate_bytes_ps; 108 113 burst = action->police.burst; 109 114 netdev_port_id = nfp_repr_get_port_id(netdev);