Skip to content

Commit 3b43f19

Browse files
Sai Krishnadavem330
Sai Krishna
authored andcommitted
octeontx2-pf: Add TC flower offload support for TCP flags
This patch adds TC offload support for matching TCP flags from TCP header. Example usage: tc qdisc add dev eth0 ingress TC rule to drop the TCP SYN packets: tc filter add dev eth0 ingress protocol ip flower ip_proto tcp tcp_flags 0x02/0x3f skip_sw action drop Signed-off-by: Sai Krishna <[email protected]> Reviewed-by: Simon Horman <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent caabd85 commit 3b43f19

File tree

5 files changed

+23
-2
lines changed

5 files changed

+23
-2
lines changed

drivers/net/ethernet/marvell/octeontx2/af/mbox.h

+1
Original file line numberDiff line numberDiff line change
@@ -1556,6 +1556,7 @@ struct flow_msg {
15561556
u32 mpls_lse[4];
15571557
u8 icmp_type;
15581558
u8 icmp_code;
1559+
__be16 tcp_flags;
15591560
};
15601561

15611562
struct npc_install_flow_req {

drivers/net/ethernet/marvell/octeontx2/af/npc.h

+1
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ enum key_fields {
217217
NPC_MPLS4_TTL,
218218
NPC_TYPE_ICMP,
219219
NPC_CODE_ICMP,
220+
NPC_TCP_FLAGS,
220221
NPC_HEADER_FIELDS_MAX,
221222
NPC_CHAN = NPC_HEADER_FIELDS_MAX, /* Valid when Rx */
222223
NPC_PF_FUNC, /* Valid when Tx */

drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c

+4
Original file line numberDiff line numberDiff line change
@@ -2870,6 +2870,10 @@ static void rvu_dbg_npc_mcam_show_flows(struct seq_file *s,
28702870
seq_printf(s, "%d ", ntohs(rule->packet.dport));
28712871
seq_printf(s, "mask 0x%x\n", ntohs(rule->mask.dport));
28722872
break;
2873+
case NPC_TCP_FLAGS:
2874+
seq_printf(s, "%d ", rule->packet.tcp_flags);
2875+
seq_printf(s, "mask 0x%x\n", rule->mask.tcp_flags);
2876+
break;
28732877
case NPC_IPSEC_SPI:
28742878
seq_printf(s, "0x%x ", ntohl(rule->packet.spi));
28752879
seq_printf(s, "mask 0x%x\n", ntohl(rule->mask.spi));

drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_fs.c

+6-2
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ static const char * const npc_flow_names[] = {
5353
[NPC_MPLS4_TTL] = "lse depth 4",
5454
[NPC_TYPE_ICMP] = "icmp type",
5555
[NPC_CODE_ICMP] = "icmp code",
56+
[NPC_TCP_FLAGS] = "tcp flags",
5657
[NPC_UNKNOWN] = "unknown",
5758
};
5859

@@ -530,6 +531,7 @@ do { \
530531
NPC_SCAN_HDR(NPC_DPORT_SCTP, NPC_LID_LD, NPC_LT_LD_SCTP, 2, 2);
531532
NPC_SCAN_HDR(NPC_TYPE_ICMP, NPC_LID_LD, NPC_LT_LD_ICMP, 0, 1);
532533
NPC_SCAN_HDR(NPC_CODE_ICMP, NPC_LID_LD, NPC_LT_LD_ICMP, 1, 1);
534+
NPC_SCAN_HDR(NPC_TCP_FLAGS, NPC_LID_LD, NPC_LT_LD_TCP, 12, 2);
533535
NPC_SCAN_HDR(NPC_ETYPE_ETHER, NPC_LID_LA, NPC_LT_LA_ETHER, 12, 2);
534536
NPC_SCAN_HDR(NPC_ETYPE_TAG1, NPC_LID_LB, NPC_LT_LB_CTAG, 4, 2);
535537
NPC_SCAN_HDR(NPC_ETYPE_TAG2, NPC_LID_LB, NPC_LT_LB_STAG_QINQ, 8, 2);
@@ -574,7 +576,8 @@ static void npc_set_features(struct rvu *rvu, int blkaddr, u8 intf)
574576
BIT_ULL(NPC_DPORT_TCP) | BIT_ULL(NPC_DPORT_UDP) |
575577
BIT_ULL(NPC_SPORT_SCTP) | BIT_ULL(NPC_DPORT_SCTP) |
576578
BIT_ULL(NPC_SPORT_SCTP) | BIT_ULL(NPC_DPORT_SCTP) |
577-
BIT_ULL(NPC_TYPE_ICMP) | BIT_ULL(NPC_CODE_ICMP);
579+
BIT_ULL(NPC_TYPE_ICMP) | BIT_ULL(NPC_CODE_ICMP) |
580+
BIT_ULL(NPC_TCP_FLAGS);
578581

579582
/* for tcp/udp/sctp corresponding layer type should be in the key */
580583
if (*features & proto_flags) {
@@ -982,7 +985,8 @@ do { \
982985
mask->icmp_type, 0);
983986
NPC_WRITE_FLOW(NPC_CODE_ICMP, icmp_code, pkt->icmp_code, 0,
984987
mask->icmp_code, 0);
985-
988+
NPC_WRITE_FLOW(NPC_TCP_FLAGS, tcp_flags, ntohs(pkt->tcp_flags), 0,
989+
ntohs(mask->tcp_flags), 0);
986990
NPC_WRITE_FLOW(NPC_IPSEC_SPI, spi, ntohl(pkt->spi), 0,
987991
ntohl(mask->spi), 0);
988992

drivers/net/ethernet/marvell/octeontx2/nic/otx2_tc.c

+11
Original file line numberDiff line numberDiff line change
@@ -638,6 +638,7 @@ static int otx2_tc_prepare_flow(struct otx2_nic *nic, struct otx2_tc_flow *node,
638638
BIT(FLOW_DISSECTOR_KEY_IPSEC) |
639639
BIT_ULL(FLOW_DISSECTOR_KEY_MPLS) |
640640
BIT_ULL(FLOW_DISSECTOR_KEY_ICMP) |
641+
BIT_ULL(FLOW_DISSECTOR_KEY_TCP) |
641642
BIT_ULL(FLOW_DISSECTOR_KEY_IP)))) {
642643
netdev_info(nic->netdev, "unsupported flow used key 0x%llx",
643644
dissector->used_keys);
@@ -857,6 +858,16 @@ static int otx2_tc_prepare_flow(struct otx2_nic *nic, struct otx2_tc_flow *node,
857858
}
858859
}
859860

861+
if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_TCP)) {
862+
struct flow_match_tcp match;
863+
864+
flow_rule_match_tcp(rule, &match);
865+
866+
flow_spec->tcp_flags = match.key->flags;
867+
flow_mask->tcp_flags = match.mask->flags;
868+
req->features |= BIT_ULL(NPC_TCP_FLAGS);
869+
}
870+
860871
if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_MPLS)) {
861872
struct flow_match_mpls match;
862873
u8 bit;

0 commit comments

Comments
 (0)