mbox series

[v6,net-next,00/12] allow user to offload tc action to net device

Message ID 20211209092806.12336-1-simon.horman@corigine.com (mailing list archive)
Headers show
Series allow user to offload tc action to net device | expand

Message

Simon Horman Dec. 9, 2021, 9:27 a.m. UTC
Baowen Zheng says:

Allow use of flow_indr_dev_register/flow_indr_dev_setup_offload to offload
tc actions independent of flows.

The motivation for this work is to prepare for using TC police action
instances to provide hardware offload of OVS metering feature - which calls
for policers that may be used by multiple flows and whose lifecycle is
independent of any flows that use them.

This patch includes basic changes to offload drivers to return EOPNOTSUPP
if this feature is used - it is not yet supported by any driver.

Tc cli command to offload and quote an action:

 # tc qdisc del dev $DEV ingress && sleep 1 || true
 # tc actions delete action police index 200 || true

 # tc qdisc add dev $DEV ingress
 # tc qdisc show dev $DEV ingress

 # tc actions add action police rate 100mbit burst 10000k index 200 skip_sw
 # tc -s -d actions list action police
 total acts 1

         action order 0:  police 0xc8 rate 100Mbit burst 10000Kb mtu 2Kb action reclassify 
         overhead 0b linklayer ethernet
         ref 1 bind 0  installed 142 sec used 0 sec
         Action statistics:
         Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
         backlog 0b 0p requeues 0
         skip_sw in_hw in_hw_count 1
         used_hw_stats delayed

 # tc filter add dev $DEV protocol ip parent ffff: \
         flower skip_sw ip_proto tcp action police index 200
 # tc -s -d filter show dev $DEV protocol ip parent ffff:
 filter pref 49152 flower chain 0
 filter pref 49152 flower chain 0 handle 0x1
   eth_type ipv4
   ip_proto tcp
   skip_sw
   in_hw in_hw_count 1
         action order 1:  police 0xc8 rate 100Mbit burst 10000Kb mtu 2Kb action 
         reclassify overhead 0b linklayer ethernet
         ref 2 bind 1  installed 300 sec used 0 sec
         Action statistics:
         Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
         backlog 0b 0p requeues 0
         skip_sw in_hw in_hw_count 1
         used_hw_stats delayed

 # tc filter add dev $DEV protocol ipv6 parent ffff: \
         flower skip_sw ip_proto tcp action police index 200
 # tc -s -d filter show dev $DEV protocol ipv6 parent ffff:
   filter pref 49151 flower chain 0
   filter pref 49151 flower chain 0 handle 0x1
   eth_type ipv6
   ip_proto tcp
   skip_sw
   in_hw in_hw_count 1
         action order 1:  police 0xc8 rate 100Mbit burst 10000Kb mtu 2Kb action 
         reclassify overhead 0b linklayer ethernet
         ref 3 bind 2  installed 761 sec used 0 sec
         Action statistics:
         Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
         backlog 0b 0p requeues 0
         skip_sw in_hw in_hw_count 1
         used_hw_stats delayed

 # tc -s -d actions list action police
 total acts 1

          action order 0:  police 0xc8 rate 100Mbit burst 10000Kb mtu 2Kb action reclassify overhead 0b linklayer ethernet
          ref 3 bind 2  installed 917 sec used 0 sec
          Action statistics:
          Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
          backlog 0b 0p requeues 0
          skip_sw in_hw in_hw_count 1
         used_hw_stats delayed

Changes compared to v5 patches:
* Fix issue reported by Dan Carpenter found using Smatch.

Baowen Zheng (12):
  flow_offload: fill flags to action structure
  flow_offload: reject to offload tc actions in offload drivers
  flow_offload: add index to flow_action_entry structure
  flow_offload: return EOPNOTSUPP for the unsupported mpls action type
  flow_offload: add ops to tc_action_ops for flow action setup
  flow_offload: allow user to offload tc action to net device
  flow_offload: add skip_hw and skip_sw to control if offload the action
  flow_offload: add process to update action stats from hardware
  net: sched: save full flags for tc action
  flow_offload: add reoffload process to update hw_count
  flow_offload: validate flags of filter and actions
  selftests: tc-testing: add action offload selftest for action and
    filter

 drivers/net/dsa/ocelot/felix_vsc9959.c        |   4 +-
 drivers/net/dsa/sja1105/sja1105_flower.c      |   2 +-
 drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c  |   2 +-
 .../net/ethernet/freescale/enetc/enetc_qos.c  |   6 +-
 .../ethernet/mellanox/mlx5/core/en/rep/tc.c   |   3 +
 .../ethernet/mellanox/mlxsw/spectrum_flower.c |   2 +-
 drivers/net/ethernet/mscc/ocelot_flower.c     |   2 +-
 .../ethernet/netronome/nfp/flower/offload.c   |   3 +
 include/linux/netdevice.h                     |   1 +
 include/net/act_api.h                         |  27 +-
 include/net/flow_offload.h                    |  20 +-
 include/net/pkt_cls.h                         |  27 +-
 include/net/tc_act/tc_gate.h                  |   5 -
 include/uapi/linux/pkt_cls.h                  |   9 +-
 net/core/flow_offload.c                       |  46 +-
 net/sched/act_api.c                           | 450 +++++++++++++++++-
 net/sched/act_bpf.c                           |   2 +-
 net/sched/act_connmark.c                      |   2 +-
 net/sched/act_csum.c                          |  19 +
 net/sched/act_ct.c                            |  21 +
 net/sched/act_ctinfo.c                        |   2 +-
 net/sched/act_gact.c                          |  38 ++
 net/sched/act_gate.c                          |  51 +-
 net/sched/act_ife.c                           |   2 +-
 net/sched/act_ipt.c                           |   2 +-
 net/sched/act_mirred.c                        |  50 ++
 net/sched/act_mpls.c                          |  54 ++-
 net/sched/act_nat.c                           |   2 +-
 net/sched/act_pedit.c                         |  36 +-
 net/sched/act_police.c                        |  27 +-
 net/sched/act_sample.c                        |  32 +-
 net/sched/act_simple.c                        |   2 +-
 net/sched/act_skbedit.c                       |  38 +-
 net/sched/act_skbmod.c                        |   2 +-
 net/sched/act_tunnel_key.c                    |  54 +++
 net/sched/act_vlan.c                          |  48 ++
 net/sched/cls_api.c                           | 263 ++--------
 net/sched/cls_flower.c                        |   9 +-
 net/sched/cls_matchall.c                      |   9 +-
 net/sched/cls_u32.c                           |  12 +-
 .../tc-testing/tc-tests/actions/police.json   |  24 +
 .../tc-testing/tc-tests/filters/matchall.json |  24 +
 42 files changed, 1144 insertions(+), 290 deletions(-)

Comments

Simon Horman Dec. 9, 2021, 10:41 a.m. UTC | #1
On Thu, Dec 09, 2021 at 10:27:54AM +0100, Simon Horman wrote:
> Baowen Zheng says:

...

Sorry, I appear to have included two sets of slightly different
information in this cover letter.

Please ignore the following two paragraphs, and instead refer
to the two after that.

Ignore this:

> Baowen Zheng (12):
>   flow_offload: fill flags to action structure
>   flow_offload: reject to offload tc actions in offload drivers
>   flow_offload: add index to flow_action_entry structure
>   flow_offload: return EOPNOTSUPP for the unsupported mpls action type
>   flow_offload: add ops to tc_action_ops for flow action setup
>   flow_offload: allow user to offload tc action to net device
>   flow_offload: add skip_hw and skip_sw to control if offload the action
>   flow_offload: add process to update action stats from hardware
>   net: sched: save full flags for tc action
>   flow_offload: add reoffload process to update hw_count
>   flow_offload: validate flags of filter and actions
>   selftests: tc-testing: add action offload selftest for action and
>     filter
> 
>  drivers/net/dsa/ocelot/felix_vsc9959.c        |   4 +-
>  drivers/net/dsa/sja1105/sja1105_flower.c      |   2 +-
>  drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c  |   2 +-
>  .../net/ethernet/freescale/enetc/enetc_qos.c  |   6 +-
>  .../ethernet/mellanox/mlx5/core/en/rep/tc.c   |   3 +
>  .../ethernet/mellanox/mlxsw/spectrum_flower.c |   2 +-
>  drivers/net/ethernet/mscc/ocelot_flower.c     |   2 +-
>  .../ethernet/netronome/nfp/flower/offload.c   |   3 +
>  include/linux/netdevice.h                     |   1 +
>  include/net/act_api.h                         |  27 +-
>  include/net/flow_offload.h                    |  20 +-
>  include/net/pkt_cls.h                         |  27 +-
>  include/net/tc_act/tc_gate.h                  |   5 -
>  include/uapi/linux/pkt_cls.h                  |   9 +-
>  net/core/flow_offload.c                       |  46 +-
>  net/sched/act_api.c                           | 450 +++++++++++++++++-
>  net/sched/act_bpf.c                           |   2 +-
>  net/sched/act_connmark.c                      |   2 +-
>  net/sched/act_csum.c                          |  19 +
>  net/sched/act_ct.c                            |  21 +
>  net/sched/act_ctinfo.c                        |   2 +-
>  net/sched/act_gact.c                          |  38 ++
>  net/sched/act_gate.c                          |  51 +-
>  net/sched/act_ife.c                           |   2 +-
>  net/sched/act_ipt.c                           |   2 +-
>  net/sched/act_mirred.c                        |  50 ++
>  net/sched/act_mpls.c                          |  54 ++-
>  net/sched/act_nat.c                           |   2 +-
>  net/sched/act_pedit.c                         |  36 +-
>  net/sched/act_police.c                        |  27 +-
>  net/sched/act_sample.c                        |  32 +-
>  net/sched/act_simple.c                        |   2 +-
>  net/sched/act_skbedit.c                       |  38 +-
>  net/sched/act_skbmod.c                        |   2 +-
>  net/sched/act_tunnel_key.c                    |  54 +++
>  net/sched/act_vlan.c                          |  48 ++
>  net/sched/cls_api.c                           | 263 ++--------
>  net/sched/cls_flower.c                        |   9 +-
>  net/sched/cls_matchall.c                      |   9 +-
>  net/sched/cls_u32.c                           |  12 +-
>  .../tc-testing/tc-tests/actions/police.json   |  24 +
>  .../tc-testing/tc-tests/filters/matchall.json |  24 +
>  42 files changed, 1144 insertions(+), 290 deletions(-)

Instead, refer to this:

> Baowen Zheng (12):
>   flow_offload: fill flags to action structure
>   flow_offload: reject to offload tc actions in offload drivers
>   flow_offload: add index to flow_action_entry structure
>   flow_offload: return EOPNOTSUPP for the unsupported mpls action type
>   flow_offload: add ops to tc_action_ops for flow action setup
>   flow_offload: allow user to offload tc action to net device
>   flow_offload: add skip_hw and skip_sw to control if offload the action
>   flow_offload: add process to update action stats from hardware
>   net: sched: save full flags for tc action
>   flow_offload: add reoffload process to update hw_count
>   flow_offload: validate flags of filter and actions
>   selftests: tc-testing: add action offload selftest for action and
>     filter
> 
>  drivers/net/dsa/ocelot/felix_vsc9959.c        |   4 +-
>  drivers/net/dsa/sja1105/sja1105_flower.c      |   2 +-
>  drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c  |   2 +-
>  .../net/ethernet/freescale/enetc/enetc_qos.c  |   6 +-
>  .../ethernet/mellanox/mlx5/core/en/rep/tc.c   |   3 +
>  .../ethernet/mellanox/mlxsw/spectrum_flower.c |   2 +-
>  drivers/net/ethernet/mscc/ocelot_flower.c     |   2 +-
>  .../ethernet/netronome/nfp/flower/offload.c   |   3 +
>  include/linux/netdevice.h                     |   1 +
>  include/net/act_api.h                         |  27 +-
>  include/net/flow_offload.h                    |  20 +-
>  include/net/pkt_cls.h                         |  27 +-
>  include/net/tc_act/tc_gate.h                  |   5 -
>  include/uapi/linux/pkt_cls.h                  |   9 +-
>  net/core/flow_offload.c                       |  46 +-
>  net/sched/act_api.c                           | 451 +++++++++++++++++-
>  net/sched/act_bpf.c                           |   2 +-
>  net/sched/act_connmark.c                      |   2 +-
>  net/sched/act_csum.c                          |  19 +
>  net/sched/act_ct.c                            |  21 +
>  net/sched/act_ctinfo.c                        |   2 +-
>  net/sched/act_gact.c                          |  38 ++
>  net/sched/act_gate.c                          |  51 +-
>  net/sched/act_ife.c                           |   2 +-
>  net/sched/act_ipt.c                           |   2 +-
>  net/sched/act_mirred.c                        |  50 ++
>  net/sched/act_mpls.c                          |  54 ++-
>  net/sched/act_nat.c                           |   2 +-
>  net/sched/act_pedit.c                         |  36 +-
>  net/sched/act_police.c                        |  27 +-
>  net/sched/act_sample.c                        |  32 +-
>  net/sched/act_simple.c                        |   2 +-
>  net/sched/act_skbedit.c                       |  38 +-
>  net/sched/act_skbmod.c                        |   2 +-
>  net/sched/act_tunnel_key.c                    |  54 +++
>  net/sched/act_vlan.c                          |  48 ++
>  net/sched/cls_api.c                           | 263 ++--------
>  net/sched/cls_flower.c                        |   9 +-
>  net/sched/cls_matchall.c                      |   9 +-
>  net/sched/cls_u32.c                           |  12 +-
>  .../tc-testing/tc-tests/actions/police.json   |  24 +
>  .../tc-testing/tc-tests/filters/matchall.json |  24 +
>  42 files changed, 1145 insertions(+), 290 deletions(-)
Jamal Hadi Salim Dec. 11, 2021, 7:04 p.m. UTC | #2
Hi,

I believe these patches are functionally ready. There is still some
nitpick.

On the general patch: Why not Cc the maintainers for the drivers you
are touching? I know the changes seem trivial but it is good courtesy.
 From your logs driver files touched:

    drivers/net/dsa/ocelot/felix_vsc9959.c        |   4 +-
    drivers/net/dsa/sja1105/sja1105_flower.c      |   2 +-
    drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c  |   2 +-
    .../net/ethernet/freescale/enetc/enetc_qos.c  |   6 +-
    .../ethernet/mellanox/mlx5/core/en/rep/tc.c   |   3 +
    .../ethernet/mellanox/mlxsw/spectrum_flower.c |   2 +-
    drivers/net/ethernet/mscc/ocelot_flower.c     |   2 +-
    .../ethernet/netronome/nfp/flower/offload.c   |   3 +

Also - shouldnt the history be all inclusive? You obly have V5 here.
Maybe with lore or patchwork this is no longer necessary and all
history can be retrieved in the future?

Individual patch comments to follow.

cheers,
jamal

On 2021-12-09 04:27, Simon Horman wrote:
> Baowen Zheng says:
> 
> Allow use of flow_indr_dev_register/flow_indr_dev_setup_offload to offload
> tc actions independent of flows.
> 
> The motivation for this work is to prepare for using TC police action
> instances to provide hardware offload of OVS metering feature - which calls
> for policers that may be used by multiple flows and whose lifecycle is
> independent of any flows that use them.
> 
> This patch includes basic changes to offload drivers to return EOPNOTSUPP
> if this feature is used - it is not yet supported by any driver.
> 
> Tc cli command to offload and quote an action:
> 
>   # tc qdisc del dev $DEV ingress && sleep 1 || true
>   # tc actions delete action police index 200 || true
> 
>   # tc qdisc add dev $DEV ingress
>   # tc qdisc show dev $DEV ingress
> 
>   # tc actions add action police rate 100mbit burst 10000k index 200 skip_sw
>   # tc -s -d actions list action police
>   total acts 1
> 
>           action order 0:  police 0xc8 rate 100Mbit burst 10000Kb mtu 2Kb action reclassify
>           overhead 0b linklayer ethernet
>           ref 1 bind 0  installed 142 sec used 0 sec
>           Action statistics:
>           Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
>           backlog 0b 0p requeues 0
>           skip_sw in_hw in_hw_count 1
>           used_hw_stats delayed
> 
>   # tc filter add dev $DEV protocol ip parent ffff: \
>           flower skip_sw ip_proto tcp action police index 200
>   # tc -s -d filter show dev $DEV protocol ip parent ffff:
>   filter pref 49152 flower chain 0
>   filter pref 49152 flower chain 0 handle 0x1
>     eth_type ipv4
>     ip_proto tcp
>     skip_sw
>     in_hw in_hw_count 1
>           action order 1:  police 0xc8 rate 100Mbit burst 10000Kb mtu 2Kb action
>           reclassify overhead 0b linklayer ethernet
>           ref 2 bind 1  installed 300 sec used 0 sec
>           Action statistics:
>           Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
>           backlog 0b 0p requeues 0
>           skip_sw in_hw in_hw_count 1
>           used_hw_stats delayed
> 
>   # tc filter add dev $DEV protocol ipv6 parent ffff: \
>           flower skip_sw ip_proto tcp action police index 200
>   # tc -s -d filter show dev $DEV protocol ipv6 parent ffff:
>     filter pref 49151 flower chain 0
>     filter pref 49151 flower chain 0 handle 0x1
>     eth_type ipv6
>     ip_proto tcp
>     skip_sw
>     in_hw in_hw_count 1
>           action order 1:  police 0xc8 rate 100Mbit burst 10000Kb mtu 2Kb action
>           reclassify overhead 0b linklayer ethernet
>           ref 3 bind 2  installed 761 sec used 0 sec
>           Action statistics:
>           Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
>           backlog 0b 0p requeues 0
>           skip_sw in_hw in_hw_count 1
>           used_hw_stats delayed
> 
>   # tc -s -d actions list action police
>   total acts 1
> 
>            action order 0:  police 0xc8 rate 100Mbit burst 10000Kb mtu 2Kb action reclassify overhead 0b linklayer ethernet
>            ref 3 bind 2  installed 917 sec used 0 sec
>            Action statistics:
>            Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
>            backlog 0b 0p requeues 0
>            skip_sw in_hw in_hw_count 1
>           used_hw_stats delayed
> 
> Changes compared to v5 patches:
> * Fix issue reported by Dan Carpenter found using Smatch.
> 
> Baowen Zheng (12):
>    flow_offload: fill flags to action structure
>    flow_offload: reject to offload tc actions in offload drivers
>    flow_offload: add index to flow_action_entry structure
>    flow_offload: return EOPNOTSUPP for the unsupported mpls action type
>    flow_offload: add ops to tc_action_ops for flow action setup
>    flow_offload: allow user to offload tc action to net device
>    flow_offload: add skip_hw and skip_sw to control if offload the action
>    flow_offload: add process to update action stats from hardware
>    net: sched: save full flags for tc action
>    flow_offload: add reoffload process to update hw_count
>    flow_offload: validate flags of filter and actions
>    selftests: tc-testing: add action offload selftest for action and
>      filter
> 
>   drivers/net/dsa/ocelot/felix_vsc9959.c        |   4 +-
>   drivers/net/dsa/sja1105/sja1105_flower.c      |   2 +-
>   drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c  |   2 +-
>   .../net/ethernet/freescale/enetc/enetc_qos.c  |   6 +-
>   .../ethernet/mellanox/mlx5/core/en/rep/tc.c   |   3 +
>   .../ethernet/mellanox/mlxsw/spectrum_flower.c |   2 +-
>   drivers/net/ethernet/mscc/ocelot_flower.c     |   2 +-
>   .../ethernet/netronome/nfp/flower/offload.c   |   3 +
>   include/linux/netdevice.h                     |   1 +
>   include/net/act_api.h                         |  27 +-
>   include/net/flow_offload.h                    |  20 +-
>   include/net/pkt_cls.h                         |  27 +-
>   include/net/tc_act/tc_gate.h                  |   5 -
>   include/uapi/linux/pkt_cls.h                  |   9 +-
>   net/core/flow_offload.c                       |  46 +-
>   net/sched/act_api.c                           | 450 +++++++++++++++++-
>   net/sched/act_bpf.c                           |   2 +-
>   net/sched/act_connmark.c                      |   2 +-
>   net/sched/act_csum.c                          |  19 +
>   net/sched/act_ct.c                            |  21 +
>   net/sched/act_ctinfo.c                        |   2 +-
>   net/sched/act_gact.c                          |  38 ++
>   net/sched/act_gate.c                          |  51 +-
>   net/sched/act_ife.c                           |   2 +-
>   net/sched/act_ipt.c                           |   2 +-
>   net/sched/act_mirred.c                        |  50 ++
>   net/sched/act_mpls.c                          |  54 ++-
>   net/sched/act_nat.c                           |   2 +-
>   net/sched/act_pedit.c                         |  36 +-
>   net/sched/act_police.c                        |  27 +-
>   net/sched/act_sample.c                        |  32 +-
>   net/sched/act_simple.c                        |   2 +-
>   net/sched/act_skbedit.c                       |  38 +-
>   net/sched/act_skbmod.c                        |   2 +-
>   net/sched/act_tunnel_key.c                    |  54 +++
>   net/sched/act_vlan.c                          |  48 ++
>   net/sched/cls_api.c                           | 263 ++--------
>   net/sched/cls_flower.c                        |   9 +-
>   net/sched/cls_matchall.c                      |   9 +-
>   net/sched/cls_u32.c                           |  12 +-
>   .../tc-testing/tc-tests/actions/police.json   |  24 +
>   .../tc-testing/tc-tests/filters/matchall.json |  24 +
>   42 files changed, 1144 insertions(+), 290 deletions(-)
>
Simon Horman Dec. 13, 2021, 9:16 a.m. UTC | #3
Hi Jamal,

thanks for your review.
We'll work on the issues raised in this thread.

On Sat, Dec 11, 2021 at 02:04:50PM -0500, Jamal Hadi Salim wrote:
> Hi,
> 
> I believe these patches are functionally ready. There is still some
> nitpick.
> 
> On the general patch: Why not Cc the maintainers for the drivers you
> are touching? I know the changes seem trivial but it is good courtesy.

Thanks. For some reason that had not occurred to me.
I'll try to make it so in v7.

> From your logs driver files touched:
> 
>    drivers/net/dsa/ocelot/felix_vsc9959.c        |   4 +-
>    drivers/net/dsa/sja1105/sja1105_flower.c      |   2 +-
>    drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c  |   2 +-
>    .../net/ethernet/freescale/enetc/enetc_qos.c  |   6 +-
>    .../ethernet/mellanox/mlx5/core/en/rep/tc.c   |   3 +
>    .../ethernet/mellanox/mlxsw/spectrum_flower.c |   2 +-
>    drivers/net/ethernet/mscc/ocelot_flower.c     |   2 +-
>    .../ethernet/netronome/nfp/flower/offload.c   |   3 +
> 
> Also - shouldnt the history be all inclusive? You obly have V5 here.
> Maybe with lore or patchwork this is no longer necessary and all
> history can be retrieved in the future?

Sure, can do.

...
Vlad Buslov Dec. 13, 2021, 7:21 p.m. UTC | #4
On Thu 09 Dec 2021 at 11:27, Simon Horman <simon.horman@corigine.com> wrote:
> Baowen Zheng says:
>
> Allow use of flow_indr_dev_register/flow_indr_dev_setup_offload to offload
> tc actions independent of flows.
>
> The motivation for this work is to prepare for using TC police action
> instances to provide hardware offload of OVS metering feature - which calls
> for policers that may be used by multiple flows and whose lifecycle is
> independent of any flows that use them.
>
> This patch includes basic changes to offload drivers to return EOPNOTSUPP
> if this feature is used - it is not yet supported by any driver.
>
> Tc cli command to offload and quote an action:
>
>  # tc qdisc del dev $DEV ingress && sleep 1 || true
>  # tc actions delete action police index 200 || true
>
>  # tc qdisc add dev $DEV ingress
>  # tc qdisc show dev $DEV ingress
>
>  # tc actions add action police rate 100mbit burst 10000k index 200 skip_sw
>  # tc -s -d actions list action police
>  total acts 1
>
>          action order 0:  police 0xc8 rate 100Mbit burst 10000Kb mtu 2Kb action reclassify 
>          overhead 0b linklayer ethernet
>          ref 1 bind 0  installed 142 sec used 0 sec
>          Action statistics:
>          Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
>          backlog 0b 0p requeues 0
>          skip_sw in_hw in_hw_count 1
>          used_hw_stats delayed
>
>  # tc filter add dev $DEV protocol ip parent ffff: \
>          flower skip_sw ip_proto tcp action police index 200
>  # tc -s -d filter show dev $DEV protocol ip parent ffff:
>  filter pref 49152 flower chain 0
>  filter pref 49152 flower chain 0 handle 0x1
>    eth_type ipv4
>    ip_proto tcp
>    skip_sw
>    in_hw in_hw_count 1
>          action order 1:  police 0xc8 rate 100Mbit burst 10000Kb mtu 2Kb action 
>          reclassify overhead 0b linklayer ethernet
>          ref 2 bind 1  installed 300 sec used 0 sec
>          Action statistics:
>          Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
>          backlog 0b 0p requeues 0
>          skip_sw in_hw in_hw_count 1
>          used_hw_stats delayed
>
>  # tc filter add dev $DEV protocol ipv6 parent ffff: \
>          flower skip_sw ip_proto tcp action police index 200
>  # tc -s -d filter show dev $DEV protocol ipv6 parent ffff:
>    filter pref 49151 flower chain 0
>    filter pref 49151 flower chain 0 handle 0x1
>    eth_type ipv6
>    ip_proto tcp
>    skip_sw
>    in_hw in_hw_count 1
>          action order 1:  police 0xc8 rate 100Mbit burst 10000Kb mtu 2Kb action 
>          reclassify overhead 0b linklayer ethernet
>          ref 3 bind 2  installed 761 sec used 0 sec
>          Action statistics:
>          Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
>          backlog 0b 0p requeues 0
>          skip_sw in_hw in_hw_count 1
>          used_hw_stats delayed
>
>  # tc -s -d actions list action police
>  total acts 1
>
>           action order 0:  police 0xc8 rate 100Mbit burst 10000Kb mtu 2Kb action reclassify overhead 0b linklayer ethernet
>           ref 3 bind 2  installed 917 sec used 0 sec
>           Action statistics:
>           Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
>           backlog 0b 0p requeues 0
>           skip_sw in_hw in_hw_count 1
>          used_hw_stats delayed
>
> Changes compared to v5 patches:
> * Fix issue reported by Dan Carpenter found using Smatch.

Hi,

Sorry for late response to this and previous version. From my side
series LGTM besides points raised by Jamal and Roi.

Regards,
Vlad

[...]
Simon Horman Dec. 14, 2021, 7:55 a.m. UTC | #5
On Mon, Dec 13, 2021 at 09:21:54PM +0200, Vlad Buslov wrote:
> On Thu 09 Dec 2021 at 11:27, Simon Horman <simon.horman@corigine.com> wrote:
> > Baowen Zheng says:
> >
> > Allow use of flow_indr_dev_register/flow_indr_dev_setup_offload to offload
> > tc actions independent of flows.
> >
> > The motivation for this work is to prepare for using TC police action
> > instances to provide hardware offload of OVS metering feature - which calls
> > for policers that may be used by multiple flows and whose lifecycle is
> > independent of any flows that use them.
> >
> > This patch includes basic changes to offload drivers to return EOPNOTSUPP
> > if this feature is used - it is not yet supported by any driver.
> >
> > Tc cli command to offload and quote an action:
> >
> >  # tc qdisc del dev $DEV ingress && sleep 1 || true
> >  # tc actions delete action police index 200 || true
> >
> >  # tc qdisc add dev $DEV ingress
> >  # tc qdisc show dev $DEV ingress
> >
> >  # tc actions add action police rate 100mbit burst 10000k index 200 skip_sw
> >  # tc -s -d actions list action police
> >  total acts 1
> >
> >          action order 0:  police 0xc8 rate 100Mbit burst 10000Kb mtu 2Kb action reclassify 
> >          overhead 0b linklayer ethernet
> >          ref 1 bind 0  installed 142 sec used 0 sec
> >          Action statistics:
> >          Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
> >          backlog 0b 0p requeues 0
> >          skip_sw in_hw in_hw_count 1
> >          used_hw_stats delayed
> >
> >  # tc filter add dev $DEV protocol ip parent ffff: \
> >          flower skip_sw ip_proto tcp action police index 200
> >  # tc -s -d filter show dev $DEV protocol ip parent ffff:
> >  filter pref 49152 flower chain 0
> >  filter pref 49152 flower chain 0 handle 0x1
> >    eth_type ipv4
> >    ip_proto tcp
> >    skip_sw
> >    in_hw in_hw_count 1
> >          action order 1:  police 0xc8 rate 100Mbit burst 10000Kb mtu 2Kb action 
> >          reclassify overhead 0b linklayer ethernet
> >          ref 2 bind 1  installed 300 sec used 0 sec
> >          Action statistics:
> >          Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
> >          backlog 0b 0p requeues 0
> >          skip_sw in_hw in_hw_count 1
> >          used_hw_stats delayed
> >
> >  # tc filter add dev $DEV protocol ipv6 parent ffff: \
> >          flower skip_sw ip_proto tcp action police index 200
> >  # tc -s -d filter show dev $DEV protocol ipv6 parent ffff:
> >    filter pref 49151 flower chain 0
> >    filter pref 49151 flower chain 0 handle 0x1
> >    eth_type ipv6
> >    ip_proto tcp
> >    skip_sw
> >    in_hw in_hw_count 1
> >          action order 1:  police 0xc8 rate 100Mbit burst 10000Kb mtu 2Kb action 
> >          reclassify overhead 0b linklayer ethernet
> >          ref 3 bind 2  installed 761 sec used 0 sec
> >          Action statistics:
> >          Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
> >          backlog 0b 0p requeues 0
> >          skip_sw in_hw in_hw_count 1
> >          used_hw_stats delayed
> >
> >  # tc -s -d actions list action police
> >  total acts 1
> >
> >           action order 0:  police 0xc8 rate 100Mbit burst 10000Kb mtu 2Kb action reclassify overhead 0b linklayer ethernet
> >           ref 3 bind 2  installed 917 sec used 0 sec
> >           Action statistics:
> >           Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
> >           backlog 0b 0p requeues 0
> >           skip_sw in_hw in_hw_count 1
> >          used_hw_stats delayed
> >
> > Changes compared to v5 patches:
> > * Fix issue reported by Dan Carpenter found using Smatch.
> 
> Hi,
> 
> Sorry for late response to this and previous version. From my side
> series LGTM besides points raised by Jamal and Roi.

Thanks Vlad,

we appreciate your reviews.  We'll work on addressing the points made by
Jamal and Roi and repost accordingly.