flow_offload: reject configuration of packet-per-second policing in offload drivers
authorBaowen Zheng <baowen.zheng@corigine.com>
Fri, 12 Mar 2021 14:08:30 +0000 (15:08 +0100)
committerDavid S. Miller <davem@davemloft.net>
Sat, 13 Mar 2021 22:18:09 +0000 (14:18 -0800)
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>
drivers/net/dsa/sja1105/sja1105_flower.c
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_matchall.c
drivers/net/ethernet/freescale/enetc/enetc_qos.c
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c
drivers/net/ethernet/mscc/ocelot_flower.c
drivers/net/ethernet/mscc/ocelot_net.c
drivers/net/ethernet/netronome/nfp/flower/qos_conf.c

index 12e76020bea37e92a7fa60158f8048287d087222..f78b767f86ee0c002f1d9855920fec4fefa7b6a6 100644 (file)
@@ -322,6 +322,12 @@ int sja1105_cls_flower_add(struct dsa_switch *ds, int port,
        flow_action_for_each(i, act, &rule->action) {
                switch (act->id) {
                case FLOW_ACTION_POLICE:
+                       if (act->police.rate_pkt_ps) {
+                               NL_SET_ERR_MSG_MOD(extack,
+                                                  "QoS offload not support packets per second");
+                               goto out;
+                       }
+
                        rc = sja1105_flower_policer(priv, port, extack, cookie,
                                                    &key,
                                                    act->police.rate_bytes_ps,
index 2e309f6673f7b9231507f37886561902bc2cfa96..28fd2de9e4cf3cc2b2481e9e65b7a401cc0c30b9 100644 (file)
@@ -48,6 +48,11 @@ static int cxgb4_matchall_egress_validate(struct net_device *dev,
        flow_action_for_each(i, entry, actions) {
                switch (entry->id) {
                case FLOW_ACTION_POLICE:
+                       if (entry->police.rate_pkt_ps) {
+                               NL_SET_ERR_MSG_MOD(extack,
+                                                  "QoS offload not support packets per second");
+                               return -EOPNOTSUPP;
+                       }
                        /* Convert bytes per second to bits per second */
                        if (entry->police.rate_bytes_ps * 8 > max_link_rate) {
                                NL_SET_ERR_MSG_MOD(extack,
@@ -145,7 +150,11 @@ static int cxgb4_matchall_alloc_tc(struct net_device *dev,
        flow_action_for_each(i, entry, &cls->rule->action)
                if (entry->id == FLOW_ACTION_POLICE)
                        break;
-
+       if (entry->police.rate_pkt_ps) {
+               NL_SET_ERR_MSG_MOD(extack,
+                                  "QoS offload not support packets per second");
+               return -EOPNOTSUPP;
+       }
        /* Convert from bytes per second to Kbps */
        p.u.params.maxrate = div_u64(entry->police.rate_bytes_ps * 8, 1000);
        p.u.params.channel = pi->tx_chan;
index a9aee219fb581d6cb68808369f56b915b39ec285..cb7fa4bceaf2f54b74b9c7b5122f80bc8d9f0d69 100644 (file)
@@ -1221,6 +1221,11 @@ static int enetc_psfp_parse_clsflower(struct enetc_ndev_priv *priv,
 
        /* Flow meter and max frame size */
        if (entryp) {
+               if (entryp->police.rate_pkt_ps) {
+                       NL_SET_ERR_MSG_MOD(extack, "QoS offload not support packets per second");
+                       err = -EOPNOTSUPP;
+                       goto free_sfi;
+               }
                if (entryp->police.burst) {
                        fmi = kzalloc(sizeof(*fmi), GFP_KERNEL);
                        if (!fmi) {
index 54ea0dae7dedb8d3c88aecb1b20c3098db6bb680..78fc27fc4e37994545fc2fa784a354d1fd792405 100644 (file)
@@ -4538,6 +4538,10 @@ static int scan_tc_matchall_fdb_actions(struct mlx5e_priv *priv,
        flow_action_for_each(i, act, flow_action) {
                switch (act->id) {
                case FLOW_ACTION_POLICE:
+                       if (act->police.rate_pkt_ps) {
+                               NL_SET_ERR_MSG_MOD(extack, "QoS offload not support packets per second");
+                               return -EOPNOTSUPP;
+                       }
                        err = apply_police_params(priv, act->police.rate_bytes_ps, extack);
                        if (err)
                                return err;
index 41855e58564b16ab0e00071eeaa304aee3313726..ea637fa552f56a03839d9c73dee02d15f0518e5c 100644 (file)
@@ -190,6 +190,11 @@ static int mlxsw_sp_flower_parse_actions(struct mlxsw_sp *mlxsw_sp,
                                return -EOPNOTSUPP;
                        }
 
+                       if (act->police.rate_pkt_ps) {
+                               NL_SET_ERR_MSG_MOD(extack, "QoS offload not support packets per second");
+                               return -EOPNOTSUPP;
+                       }
+
                        /* The kernel might adjust the requested burst size so
                         * that it is not exactly a power of two. Re-adjust it
                         * here since the hardware only supports burst sizes
index a41b458b1b3ef09fdb6933384a19ed917f104746..8b843d3c9189a43530a7e69f67c114b8c9aa9b86 100644 (file)
@@ -220,6 +220,11 @@ static int ocelot_flower_parse_action(struct ocelot *ocelot, int port,
                                                   "Last action must be GOTO");
                                return -EOPNOTSUPP;
                        }
+                       if (a->police.rate_pkt_ps) {
+                               NL_SET_ERR_MSG_MOD(extack,
+                                                  "QoS offload not support packets per second");
+                               return -EOPNOTSUPP;
+                       }
                        filter->action.police_ena = true;
                        rate = a->police.rate_bytes_ps;
                        filter->action.pol.rate = div_u64(rate, 1000) * 8;
index 12cb6867a2d08fdb34301b292c4d43e417b2b8fa..c08164cd88f4103a1428a1e49bb83c88c2b12ff2 100644 (file)
@@ -251,6 +251,12 @@ static int ocelot_setup_tc_cls_matchall(struct ocelot_port_private *priv,
                        return -EEXIST;
                }
 
+               if (action->police.rate_pkt_ps) {
+                       NL_SET_ERR_MSG_MOD(extack,
+                                          "QoS offload not support packets per second");
+                       return -EOPNOTSUPP;
+               }
+
                pol.rate = (u32)div_u64(action->police.rate_bytes_ps, 1000) * 8;
                pol.burst = action->police.burst;
 
index d4ce8f9ef3cc237f529255006c315d1f19cacbef..88bea6ad59bcba8653bef9699a1daff98aa0a484 100644 (file)
@@ -104,6 +104,11 @@ nfp_flower_install_rate_limiter(struct nfp_app *app, struct net_device *netdev,
                return -EOPNOTSUPP;
        }
 
+       if (action->police.rate_pkt_ps) {
+               NL_SET_ERR_MSG_MOD(extack, "unsupported offload: qos rate limit offload not support packets per second");
+               return -EOPNOTSUPP;
+       }
+
        rate = action->police.rate_bytes_ps;
        burst = action->police.burst;
        netdev_port_id = nfp_repr_get_port_id(netdev);