Skip to content

Commit

Permalink
net: qos: introduce a frer action to implement 802.1CB
Browse files Browse the repository at this point in the history
This patch introduce a frer action to implement frame replication and
elimination for reliability, which is defined in IEEE P802.1CB.

There are two modes for frer action: generate and push the tag, recover
and pop the tag. frer tag has three types: RTAG, HSR, and PRP. This
patch only supports RTAG now.

User can push the tag on egress port of the talker device, recover and
pop the tag on ingress port of the listener device. When it's a relay
system, push the tag on ingress port, or set individual recover on
ingress port. Set the sequence recover on egress port.

Use action "mirred" to do split function, and use "vlan-modify" to do
active stream identification function on relay system.

Below is the setting example in user space:
push rtag on relay system:
	> tc qdisc add dev swp0 clsact
	> tc filter add dev swp0 ingress protocol 802.1Q flower \
		skip_hw dst_mac 00:01:02:03:04:05 vlan_id 1 \
		action frer rtag tag-action tag-push

split stream:
	> tc filter add dev swp0 ingress protocol 802.1Q flower \
		skip_hw dst_mac 00:01:02:03:04:05 vlan_id 1 \
		action mirred egress mirror dev swp1

individual recover:
	> tc filter add dev swp0 ingress protocol 802.1Q flower
		skip_hw dst_mac 00:01:02:03:04:06 vlan_id 1 \
		action frer rtag recover \
		alg vector history-length 32 reset-time 10000

recover and pop rtag:
	> tc filter add dev swp0 egress protocol 802.1Q flower
		skip_hw dst_mac 00:01:02:03:04:06 vlan_id 1 \
		action frer rtag recover \
		alg vector history-length 32 reset-time 10000 \
		tag-action tag-pop

Signed-off-by: Xiaoliang Yang <xiaoliang.yang_1@nxp.com>
  • Loading branch information
Xiaoliang Yang authored and intel-lab-lkp committed Sep 28, 2021
1 parent a17aafa commit a48cfe8
Show file tree
Hide file tree
Showing 9 changed files with 833 additions and 0 deletions.
9 changes: 9 additions & 0 deletions include/net/flow_offload.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ enum flow_action_id {
FLOW_ACTION_MPLS_MANGLE,
FLOW_ACTION_GATE,
FLOW_ACTION_PPPOE_PUSH,
FLOW_ACTION_FRER,
NUM_FLOW_ACTIONS,
};

Expand Down Expand Up @@ -278,6 +279,14 @@ struct flow_action_entry {
struct { /* FLOW_ACTION_PPPOE_PUSH */
u16 sid;
} pppoe;
struct {
u8 tag_type;
u8 tag_action;
u8 recover;
u8 rcvy_alg;
u8 rcvy_history_len;
u8 rcvy_reset_msec;
} frer;
};
struct flow_action_cookie *cookie; /* user defined action cookie */
};
Expand Down
52 changes: 52 additions & 0 deletions include/net/tc_act/tc_frer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/* SPDX-License-Identifier: GPL-2.0-or-later */
/* Copyright 2021 NXP */

#ifndef __NET_TC_FRER_H
#define __NET_TC_FRER_H

#include <net/act_api.h>
#include <linux/tc_act/tc_frer.h>

struct tcf_frer;

struct tcf_frer_proto_ops {
int (*encode)(struct sk_buff *skb, struct tcf_frer *frer_act);
int (*decode)(struct sk_buff *skb);
void (*tag_pop)(struct sk_buff *skb, struct tcf_frer *frer_act);
};

struct tcf_frer {
struct tc_action common;
u8 tag_type;
u8 tag_action;
u8 recover;
u8 rcvy_alg;
u8 rcvy_history_len;
u64 rcvy_reset_msec;
u32 gen_seq_num;
u32 rcvy_seq_num;
u64 seq_space;
u32 seq_history;
bool take_any;
bool rcvy_take_noseq;
u32 cps_seq_rcvy_lost_pkts;
u32 cps_seq_rcvy_tagless_pkts;
u32 cps_seq_rcvy_out_of_order_pkts;
u32 cps_seq_rcvy_rogue_pkts;
u32 cps_seq_rcvy_resets;
struct hrtimer hrtimer;
const struct tcf_frer_proto_ops *proto_ops;
};

#define to_frer(a) ((struct tcf_frer *)a)

static inline bool is_tcf_frer(const struct tc_action *a)
{
#ifdef CONFIG_NET_CLS_ACT
if (a->ops && a->ops->id == TCA_ID_FRER)
return true;
#endif
return false;
}

#endif
1 change: 1 addition & 0 deletions include/uapi/linux/if_ether.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@
#define ETH_P_EDSA 0xDADA /* Ethertype DSA [ NOT AN OFFICIALLY REGISTERED ID ] */
#define ETH_P_DSA_8021Q 0xDADB /* Fake VLAN Header for DSA [ NOT AN OFFICIALLY REGISTERED ID ] */
#define ETH_P_IFE 0xED3E /* ForCES inter-FE LFB type */
#define ETH_P_RTAG 0xF1C1 /* Redundancy Tag(IEEE 802.1CB) */
#define ETH_P_AF_IUCV 0xFBFB /* IBM af_iucv [ NOT AN OFFICIALLY REGISTERED ID ] */

#define ETH_P_802_3_MIN 0x0600 /* If the value in the ethernet type is less than this value
Expand Down
1 change: 1 addition & 0 deletions include/uapi/linux/pkt_cls.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ enum tca_id {
TCA_ID_MPLS,
TCA_ID_CT,
TCA_ID_GATE,
TCA_ID_FRER,
/* other actions go here */
__TCA_ID_MAX = 255
};
Expand Down
50 changes: 50 additions & 0 deletions include/uapi/linux/tc_act/tc_frer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
/* Copyright 2021 NXP */

#ifndef __LINUX_TC_FRER_H
#define __LINUX_TC_FRER_H

#include <linux/pkt_cls.h>

struct tc_frer {
tc_gen;
};

enum {
TCA_FRER_UNSPEC,
TCA_FRER_TM,
TCA_FRER_PARMS,
TCA_FRER_PAD,
TCA_FRER_TAG_TYPE,
TCA_FRER_TAG_ACTION,
TCA_FRER_RECOVER,
TCA_FRER_RECOVER_ALG,
TCA_FRER_RECOVER_HISTORY_LEN,
TCA_FRER_RECOVER_RESET_TM,
TCA_FRER_RECOVER_TAGLESS_PKTS,
TCA_FRER_RECOVER_OUT_OF_ORDER_PKTS,
TCA_FRER_RECOVER_ROGUE_PKTS,
TCA_FRER_RECOVER_LOST_PKTS,
TCA_FRER_RECOVER_RESETS,
__TCA_FRER_MAX,
};
#define TCA_FRER_MAX (__TCA_FRER_MAX - 1)

enum tc_frer_tag_action {
TCA_FRER_TAG_NULL,
TCA_FRER_TAG_PUSH,
TCA_FRER_TAG_POP,
};

enum tc_frer_tag_type {
TCA_FRER_TAG_RTAG,
TCA_FRER_TAG_HSR,
TCA_FRER_TAG_PRP,
};

enum tc_frer_rcvy_alg {
TCA_FRER_RCVY_VECTOR_ALG,
TCA_FRER_RCVY_MATCH_ALG,
};

#endif
13 changes: 13 additions & 0 deletions net/sched/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -997,6 +997,19 @@ config NET_ACT_GATE
To compile this code as a module, choose M here: the
module will be called act_gate.

config NET_ACT_FRER
tristate "Frame frer tc action"
depends on NET_CLS_ACT
help
Say Y here to support frame replication and elimination for
reliability, which is defined by IEEE 802.1CB.
This action allow to add a frer tag. It also allow to remove
the frer tag and drop repeat frames.

If unsure, say N.
To compile this code as a module, choose M here: the
module will be called act_frer.

config NET_IFE_SKBMARK
tristate "Support to encoding decoding skb mark on IFE action"
depends on NET_ACT_IFE
Expand Down
1 change: 1 addition & 0 deletions net/sched/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ obj-$(CONFIG_NET_IFE_SKBTCINDEX) += act_meta_skbtcindex.o
obj-$(CONFIG_NET_ACT_TUNNEL_KEY)+= act_tunnel_key.o
obj-$(CONFIG_NET_ACT_CT) += act_ct.o
obj-$(CONFIG_NET_ACT_GATE) += act_gate.o
obj-$(CONFIG_NET_ACT_FRER) += act_frer.o
obj-$(CONFIG_NET_SCH_FIFO) += sch_fifo.o
obj-$(CONFIG_NET_SCH_CBQ) += sch_cbq.o
obj-$(CONFIG_NET_SCH_HTB) += sch_htb.o
Expand Down

0 comments on commit a48cfe8

Please sign in to comment.