Skip to content

net/sched: cls_api: Support hardware miss to tc action

Paul Blakey netdev 14 versions – Applied

Status from this message: This series was applied to netdev/net-next.git (master)

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v13 Latest8 patches 4 repliesApplied 8/8
  2. v12 posting 2/28 patches 0 repliesSuperseded
  3. v12 posting 1/28 patches 4 repliesSuperseded
Earlier versions · 11
VersionPostedPatchesRepliesStatus
v107 patches1 replySuperseded
v97 patches13 repliesSuperseded
v87 patches13 repliesSuperseded
v76 patches3 repliesSuperseded
v66 patches1 replySuperseded
v56 patches9 repliesSuperseded
v46 patches2 repliesSuperseded
v36 patches0 repliesSuperseded
v2 posting 2/26 patches1 replySuperseded
v2 posting 1/20 of 4 patches0 repliesSuperseded
v10 of 4 patches9 repliesSuperseded

Changes in v13 from the cover letter

Kernel bot complaint fix
Added Reviewed-By Marcelo Thanks!

Patches in v13 All 8 applied

#Subject and filesSizeRepliesApplied
1/8net/sched: Rename user cookie and act cookiedrivers/net/ethernet/mellanox/mlx5/core/en_tc.c drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c include/net/act_api.h +3 more+32 -320 repliesApplied
2/8net/sched: cls_api: Support hardware miss to tc actioninclude/linux/skbuff.h include/net/flow_offload.h include/net/pkt_cls.h +4 more+236 -270 repliesApplied
3/8net/sched: flower: Move filter handle initialization earliernet/sched/cls_flower.c+35 -274 repliesApplied
4/8net/sched: flower: Support hardware miss to tc actionnet/sched/cls_flower.c+12 -10 repliesApplied
5/8net/mlx5: Kconfig: Make tc offload depend on tc skb extensiondrivers/net/ethernet/mellanox/mlx5/core/Kconfig drivers/net/ethernet/mellanox/mlx5/core/en/rep/tc.c drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c +2 more+2 -150 repliesApplied
6/8net/mlx5: Refactor tc miss handling to a single functiondrivers/net/ethernet/mellanox/mlx5/core/en/rep/tc.c drivers/net/ethernet/mellanox/mlx5/core/en_rx.c drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +1 more+231 -2270 repliesApplied
7/8net/mlx5e: Rename CHAIN_TO_REG to MAPPED_OBJ_TO_REGdrivers/net/ethernet/mellanox/mlx5/core/en/tc/sample.c drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +2 more+14 -140 repliesApplied
8/8net/mlx5e: TC, Set CT miss to the specific ct action instancedrivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.h drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +2 more+82 -240 repliesApplied

Reviews trailers per patch

7 of 8 patches have a Reviewed-by or Acked-by.

PatchJiri PirkoSimon HormanMarcelo Ricardo LeitnerJamal Hadi SalimRoi DayanLeon RomanovskyOz Sholmo
1/8R-b
2/8R-b R-b R-b A-b
3/8R-b R-b R-b
4/8R-b R-b R-b
5/8
6/8R-b
7/8R-b R-b
8/8R-b R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 7 reviewers.

Read the v13 thread

Cover letter [PATCH net-next v13 0/8] net/sched: cls_api: Support hardware miss to tc action

Hi,

This series adds support for hardware miss to instruct tc to continue execution in a specific tc action instance on a filter's action list. The mlx5 driver patch (besides the refactors) shows its usage instead of using just chain restore.

Currently a filter's action list must be executed all together or not at all as driver are only able to tell tc to continue executing from a specific tc chain, and not a specific filter/action.

This is troublesome with regards to action CT, where new connections should be sent to software (via tc chain restore), and established connections can be handled in hardware.

Checking for new connections is done when executing the ct action in hardware (by checking the packet's tuple against known established tuples). But if there is a packet modification (pedit) action before action CT and the checked tuple is a new connection, hardware will need to revert the previous packet modifications before sending it back to software so it can re-match the same tc filter in software and re-execute its CT action.

The following is an example configuration of stateless nat on mlx5 driver that isn't supported before this patchet:

#Setup corrosponding mlx5 VFs in namespaces

 $ ip netns add ns0
 $ ip netns add ns1
 $ ip link set dev enp8s0f0v0 netns ns0
 $ ip netns exec ns0 ifconfig enp8s0f0v0 1.1.1.1/24 up
 $ ip link set dev enp8s0f0v1 netns ns1
 $ ip netns exec ns1 ifconfig enp8s0f0v1 1.1.1.2/24 up

#Setup tc arp and ct rules on mxl5 VF representors

 $ tc qdisc add dev enp8s0f0_0 ingress
 $ tc qdisc add dev enp8s0f0_1 ingress
 $ ifconfig enp8s0f0_0 up
 $ ifconfig enp8s0f0_1 up

#Original side

 $ tc filter add dev enp8s0f0_0 ingress chain 0 proto ip flower \
    ct_state -trk ip_proto tcp dst_port 8888 \
      action pedit ex munge tcp dport set 5001 pipe \
      action csum ip tcp pipe \
      action ct pipe \
      action goto chain 1
 $ tc filter add dev enp8s0f0_0 ingress chain 1 proto ip flower \
    ct_state +trk+est \
      action mirred egress redirect dev enp8s0f0_1
 $ tc filter add dev enp8s0f0_0 ingress chain 1 proto ip flower \
    ct_state +trk+new \
      action ct commit pipe \
      action mirred egress redirect dev enp8s0f0_1
 $ tc filter add dev enp8s0f0_0 ingress chain 0 proto arp flower \
      action mirred egress redirect dev enp8s0f0_1

#Reply side

 $ tc filter add dev enp8s0f0_1 ingress chain 0 proto arp flower \
      action mirred egress redirect dev enp8s0f0_0
 $ tc filter add dev enp8s0f0_1 ingress chain 0 proto ip flower \
    ct_state -trk ip_proto tcp \ 
      action ct pipe \
      action pedit ex munge tcp sport set 8888 pipe \
      action csum ip tcp pipe \
      action mirred egress redirect dev enp8s0f0_0

#Run traffic

 $ ip netns exec ns1 iperf -s -p 5001&
 $ sleep 2 #wait for iperf to fully open
 $ ip netns exec ns0 iperf -c 1.1.1.2 -p 8888

#dump tc filter stats on enp8s0f0_0 chain 0 rule and see hardware packets:

 $ tc -s filter show dev enp8s0f0_0 ingress chain 0 proto ip | grep "hardware.*pkt"
        Sent hardware 9310116832 bytes 6149672 pkt
        Sent hardware 9310116832 bytes 6149672 pkt
        Sent hardware 9310116832 bytes 6149672 pkt

A new connection executing the first filter in hardware will first rewrite the dst port to the new port, and then the ct action is executed, because this is a new connection, hardware will need to be send this back to software, on chain 0, to execute the first filter again in software. The dst port needs to be reverted otherwise it won't re-match the old dst port in the first filter. Because of that, currently mlx5 driver will reject offloading the above action ct rule.

This series adds support for hardware partially executing a filter's action list, and letting tc software continue processing in the specific action instance where hardware left off (in the above case after the "action pedit ex munge tcp dport... of the first rule") allowing support for scenarios such as the above.

Changelog:
v1->v2:
Fixed compilation without CONFIG_NET_CLS
Cover letter re-write

v2->v3:
Unlock spin_lock on error in cls flower filter handle refactor Cover letter

v3->v4:
Silence warning by clang

v4->v5:
Cover letter example
Removed ifdef as much as possible by using inline stubs

v5->v6:
Removed new inlines in cls_api.c (bot complained in patchwork) Added reviewed-by/ack - Thanks!

v6->v7:
Removed WARN_ON from pkt path (leon)
Removed unnecessary return in void func

v7->v8:
Removed #if IS_ENABLED on skb ext adding Kconfig changes Complex variable init in seperate lines if,else if, else if ---> switch case

v8->v9:
Removed even more IS_ENABLED because of Kconfig

v9->v10:
cls_api: reading ext->chain moved to else instead (marcelo)

v10->v11:
Cover letter (marcelo)

v11->v12:
Added patch to rename current cookies, making room and less confusion with new miss_cookie.

v12->v13:
Kernel bot complaint fix
Added Reviewed-By Marcelo Thanks!

Paul Blakey (8):
net/sched: Rename user cookie and act cookie net/sched: cls_api: Support hardware miss to tc action net/sched: flower: Move filter handle initialization earlier net/sched: flower: Support hardware miss to tc action net/mlx5: Kconfig: Make tc offload depend on tc skb extension net/mlx5: Refactor tc miss handling to a single function net/mlx5e: Rename CHAIN_TO_REG to MAPPED_OBJ_TO_REG net/mlx5e: TC, Set CT miss to the specific ct action instance

 .../net/ethernet/mellanox/mlx5/core/Kconfig   |   4 +-
 .../ethernet/mellanox/mlx5/core/en/rep/tc.c   | 225 ++------------
 .../mellanox/mlx5/core/en/tc/sample.c         |   2 +-
 .../ethernet/mellanox/mlx5/core/en/tc_ct.c    |  39 +--
 .../ethernet/mellanox/mlx5/core/en/tc_ct.h    |   2 +
 .../net/ethernet/mellanox/mlx5/core/en_rx.c   |   4 +-
 .../net/ethernet/mellanox/mlx5/core/en_tc.c   | 282 ++++++++++++++++--
 .../net/ethernet/mellanox/mlx5/core/en_tc.h   |  23 +-
 .../net/ethernet/mellanox/mlx5/core/eswitch.h |   2 +
 .../mellanox/mlx5/core/lib/fs_chains.c        |  14 +-
 .../ethernet/mellanox/mlxsw/spectrum_flower.c |   2 +-
 include/linux/skbuff.h                        |   6 +-
 include/net/act_api.h                         |   2 +-
 include/net/flow_offload.h                    |   5 +-
 include/net/pkt_cls.h                         |  34 ++-
 include/net/sch_generic.h                     |   2 +
 net/openvswitch/flow.c                        |   3 +-
 net/sched/act_api.c                           |  28 +-
 net/sched/cls_api.c                           | 243 +++++++++++++--
 net/sched/cls_flower.c                        |  73 +++--
 20 files changed, 636 insertions(+), 359 deletions(-)
Signature · 1 line
2.30.1