Skip to content

Commit a8d4879

Browse files
Geetha sowjanyadavem330
authored andcommitted
octeontx2-pf: TC flower offload support for ICMP type and code
Adds tc offload support for matching on ICMP type and code. Example usage: To enable adding tc ingress rules tc qdisc add dev eth0 ingress TC rule drop the ICMP echo reply: tc filter add dev eth0 protocol ip parent ffff: \ flower ip_proto icmp type 8 code 0 skip_sw action drop TC rule to drop ICMPv6 echo reply: tc filter add dev eth0 protocol ipv6 parent ffff: flower \ indev eth0 ip_proto icmpv6 type 128 code 0 action drop Signed-off-by: Geetha sowjanya <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent aadbd27 commit a8d4879

File tree

5 files changed

+43
-6
lines changed

5 files changed

+43
-6
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1479,6 +1479,8 @@ struct flow_msg {
14791479
#define OTX2_FLOWER_MASK_MPLS_TTL GENMASK(7, 0)
14801480
#define OTX2_FLOWER_MASK_MPLS_NON_TTL GENMASK(31, 8)
14811481
u32 mpls_lse[4];
1482+
u8 icmp_type;
1483+
u8 icmp_code;
14821484
};
14831485

14841486
struct npc_install_flow_req {

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,8 @@ enum key_fields {
214214
NPC_MPLS3_TTL,
215215
NPC_MPLS4_LBTCBOS,
216216
NPC_MPLS4_TTL,
217+
NPC_TYPE_ICMP,
218+
NPC_CODE_ICMP,
217219
NPC_HEADER_FIELDS_MAX,
218220
NPC_CHAN = NPC_HEADER_FIELDS_MAX, /* Valid when Rx */
219221
NPC_PF_FUNC, /* Valid when Tx */

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2889,6 +2889,14 @@ static void rvu_dbg_npc_mcam_show_flows(struct seq_file *s,
28892889
RVU_DBG_PRINT_MPLS_TTL(rule->packet.mpls_lse[3],
28902890
rule->mask.mpls_lse[3]);
28912891
break;
2892+
case NPC_TYPE_ICMP:
2893+
seq_printf(s, "%d ", rule->packet.icmp_type);
2894+
seq_printf(s, "mask 0x%x\n", rule->mask.icmp_type);
2895+
break;
2896+
case NPC_CODE_ICMP:
2897+
seq_printf(s, "%d ", rule->packet.icmp_code);
2898+
seq_printf(s, "mask 0x%x\n", rule->mask.icmp_code);
2899+
break;
28922900
default:
28932901
seq_puts(s, "\n");
28942902
break;

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

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ static const char * const npc_flow_names[] = {
5151
[NPC_MPLS3_TTL] = "lse depth 3 ttl",
5252
[NPC_MPLS4_LBTCBOS] = "lse depth 4 label tc bos",
5353
[NPC_MPLS4_TTL] = "lse depth 4",
54+
[NPC_TYPE_ICMP] = "icmp type",
55+
[NPC_CODE_ICMP] = "icmp code",
5456
[NPC_UNKNOWN] = "unknown",
5557
};
5658

@@ -526,6 +528,8 @@ do { \
526528
NPC_SCAN_HDR(NPC_DPORT_TCP, NPC_LID_LD, NPC_LT_LD_TCP, 2, 2);
527529
NPC_SCAN_HDR(NPC_SPORT_SCTP, NPC_LID_LD, NPC_LT_LD_SCTP, 0, 2);
528530
NPC_SCAN_HDR(NPC_DPORT_SCTP, NPC_LID_LD, NPC_LT_LD_SCTP, 2, 2);
531+
NPC_SCAN_HDR(NPC_TYPE_ICMP, NPC_LID_LD, NPC_LT_LD_ICMP, 0, 1);
532+
NPC_SCAN_HDR(NPC_CODE_ICMP, NPC_LID_LD, NPC_LT_LD_ICMP, 1, 1);
529533
NPC_SCAN_HDR(NPC_ETYPE_ETHER, NPC_LID_LA, NPC_LT_LA_ETHER, 12, 2);
530534
NPC_SCAN_HDR(NPC_ETYPE_TAG1, NPC_LID_LB, NPC_LT_LB_CTAG, 4, 2);
531535
NPC_SCAN_HDR(NPC_ETYPE_TAG2, NPC_LID_LB, NPC_LT_LB_STAG_QINQ, 8, 2);
@@ -555,7 +559,7 @@ static void npc_set_features(struct rvu *rvu, int blkaddr, u8 intf)
555559
{
556560
struct npc_mcam *mcam = &rvu->hw->mcam;
557561
u64 *features = &mcam->rx_features;
558-
u64 tcp_udp_sctp;
562+
u64 proto_flags;
559563
int hdr;
560564

561565
if (is_npc_intf_tx(intf))
@@ -566,18 +570,21 @@ static void npc_set_features(struct rvu *rvu, int blkaddr, u8 intf)
566570
*features |= BIT_ULL(hdr);
567571
}
568572

569-
tcp_udp_sctp = BIT_ULL(NPC_SPORT_TCP) | BIT_ULL(NPC_SPORT_UDP) |
573+
proto_flags = BIT_ULL(NPC_SPORT_TCP) | BIT_ULL(NPC_SPORT_UDP) |
570574
BIT_ULL(NPC_DPORT_TCP) | BIT_ULL(NPC_DPORT_UDP) |
571-
BIT_ULL(NPC_SPORT_SCTP) | BIT_ULL(NPC_DPORT_SCTP);
575+
BIT_ULL(NPC_SPORT_SCTP) | BIT_ULL(NPC_DPORT_SCTP) |
576+
BIT_ULL(NPC_SPORT_SCTP) | BIT_ULL(NPC_DPORT_SCTP) |
577+
BIT_ULL(NPC_TYPE_ICMP) | BIT_ULL(NPC_CODE_ICMP);
572578

573579
/* for tcp/udp/sctp corresponding layer type should be in the key */
574-
if (*features & tcp_udp_sctp) {
580+
if (*features & proto_flags) {
575581
if (!npc_check_field(rvu, blkaddr, NPC_LD, intf))
576-
*features &= ~tcp_udp_sctp;
582+
*features &= ~proto_flags;
577583
else
578584
*features |= BIT_ULL(NPC_IPPROTO_TCP) |
579585
BIT_ULL(NPC_IPPROTO_UDP) |
580-
BIT_ULL(NPC_IPPROTO_SCTP);
586+
BIT_ULL(NPC_IPPROTO_SCTP) |
587+
BIT_ULL(NPC_IPPROTO_ICMP);
581588
}
582589

583590
/* for AH/ICMP/ICMPv6/, check if corresponding layer type is present in the key */
@@ -971,6 +978,10 @@ do { \
971978
ntohs(mask->sport), 0);
972979
NPC_WRITE_FLOW(NPC_DPORT_SCTP, dport, ntohs(pkt->dport), 0,
973980
ntohs(mask->dport), 0);
981+
NPC_WRITE_FLOW(NPC_TYPE_ICMP, icmp_type, pkt->icmp_type, 0,
982+
mask->icmp_type, 0);
983+
NPC_WRITE_FLOW(NPC_CODE_ICMP, icmp_code, pkt->icmp_code, 0,
984+
mask->icmp_code, 0);
974985

975986
NPC_WRITE_FLOW(NPC_IPSEC_SPI, spi, ntohl(pkt->spi), 0,
976987
ntohl(mask->spi), 0);

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,7 @@ static int otx2_tc_prepare_flow(struct otx2_nic *nic, struct otx2_tc_flow *node,
522522
BIT_ULL(FLOW_DISSECTOR_KEY_PORTS) |
523523
BIT(FLOW_DISSECTOR_KEY_IPSEC) |
524524
BIT_ULL(FLOW_DISSECTOR_KEY_MPLS) |
525+
BIT_ULL(FLOW_DISSECTOR_KEY_ICMP) |
525526
BIT_ULL(FLOW_DISSECTOR_KEY_IP)))) {
526527
netdev_info(nic->netdev, "unsupported flow used key 0x%llx",
527528
dissector->used_keys);
@@ -796,6 +797,19 @@ static int otx2_tc_prepare_flow(struct otx2_nic *nic, struct otx2_tc_flow *node,
796797
}
797798
}
798799

800+
if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_ICMP)) {
801+
struct flow_match_icmp match;
802+
803+
flow_rule_match_icmp(rule, &match);
804+
805+
flow_spec->icmp_type = match.key->type;
806+
flow_mask->icmp_type = match.mask->type;
807+
req->features |= BIT_ULL(NPC_TYPE_ICMP);
808+
809+
flow_spec->icmp_code = match.key->code;
810+
flow_mask->icmp_code = match.mask->code;
811+
req->features |= BIT_ULL(NPC_CODE_ICMP);
812+
}
799813
return otx2_tc_parse_actions(nic, &rule->action, req, f, node);
800814
}
801815

0 commit comments

Comments
 (0)