Add 11 trace points of control message related with flow rule pattern.

Signed-off-by: Chaoyong He <chaoyong...@corigine.com>
Reviewed-by: Long Wu <long...@corigine.com>
Reviewed-by: Peng Zhang <peng.zh...@corigine.com>
---
 drivers/net/nfp/flower/nfp_flower_cmsg.c | 152 +++++++++++++++++
 drivers/net/nfp/nfp_trace.c              |  33 ++++
 drivers/net/nfp/nfp_trace.h              | 199 +++++++++++++++++++++++
 3 files changed, 384 insertions(+)

diff --git a/drivers/net/nfp/flower/nfp_flower_cmsg.c 
b/drivers/net/nfp/flower/nfp_flower_cmsg.c
index 9035a9df4f..3b492c94ce 100644
--- a/drivers/net/nfp/flower/nfp_flower_cmsg.c
+++ b/drivers/net/nfp/flower/nfp_flower_cmsg.c
@@ -189,12 +189,164 @@ nfp_flower_cmsg_port_mod(struct nfp_app_fw_flower 
*app_fw_flower,
        return 0;
 }
 
+static bool
+nfp_flower_trace_cmsg_flow_has_tunnel(uint8_t nfp_flow_key_layer,
+               uint32_t nfp_flow_key_layer2)
+{
+       if ((nfp_flow_key_layer & NFP_FLOWER_LAYER_VXLAN) != 0)
+               return true;
+
+       if ((nfp_flow_key_layer & NFP_FLOWER_LAYER_EXT_META) == 0)
+               return false;
+
+       if ((nfp_flow_key_layer2 & (NFP_FLOWER_LAYER2_GENEVE | 
NFP_FLOWER_LAYER2_GRE)) != 0)
+               return true;
+
+       return false;
+}
+
+static void
+nfp_flower_trace_cmsg_flow_pattern(char *cmsg,
+               char *end)
+{
+       char *start_p = cmsg;
+
+       if (cmsg >= end) {
+               PMD_DRV_LOG(ERR, "Cmsg flow pattern parameter error");
+               return;
+       }
+
+       struct nfp_flower_meta_tci *meta_tci = (struct nfp_flower_meta_tci 
*)cmsg;
+       uint8_t nfp_flow_key_layer = meta_tci->nfp_flow_key_layer;
+       uint32_t nfp_flow_key_layer2 = 0;
+
+       rte_pmd_nfp_trace_cmsg_flow_pattern_meta_tci(start_p);
+       start_p += sizeof(struct nfp_flower_meta_tci);
+       if (start_p >= end)
+               goto pattern_exit;
+
+       if ((nfp_flow_key_layer & NFP_FLOWER_LAYER_EXT_META) != 0) {
+               struct nfp_flower_ext_meta *ext_meta = (struct 
nfp_flower_ext_meta *)start_p;
+               nfp_flow_key_layer2 = 
rte_be_to_cpu_32(ext_meta->nfp_flow_key_layer2);
+               rte_pmd_nfp_trace_cmsg_flow_pattern_ext_meta(start_p);
+               start_p += sizeof(struct nfp_flower_ext_meta);
+               if (start_p >= end)
+                       goto pattern_exit;
+       }
+
+       rte_pmd_nfp_trace_cmsg_flow_pattern_in_port(start_p);
+       start_p += sizeof(struct nfp_flower_in_port);
+       if (start_p >= end)
+               goto pattern_exit;
+
+       /* L2 layer */
+       if ((nfp_flow_key_layer & NFP_FLOWER_LAYER_MAC) != 0) {
+               rte_pmd_nfp_trace_cmsg_flow_pattern_mac(start_p);
+               start_p += sizeof(struct nfp_flower_mac_mpls);
+               if (start_p >= end)
+                       goto pattern_exit;
+       }
+
+       /* L4 layer comes first */
+       if ((nfp_flow_key_layer & NFP_FLOWER_LAYER_TP) != 0) {
+               rte_pmd_nfp_trace_cmsg_flow_pattern_tp(start_p);
+               start_p += sizeof(struct nfp_flower_tp_ports);
+               if (start_p >= end)
+                       goto pattern_exit;
+       }
+
+       /* No tunnel, then L3 layer */
+       if (!nfp_flower_trace_cmsg_flow_has_tunnel(nfp_flow_key_layer, 
nfp_flow_key_layer2)) {
+               if ((nfp_flow_key_layer & NFP_FLOWER_LAYER_IPV4) != 0) {
+                       rte_pmd_nfp_trace_cmsg_flow_pattern_ipv4(start_p);
+                       start_p += sizeof(struct nfp_flower_ipv4);
+                       if (start_p != end)
+                               PMD_DRV_LOG(ERR, "Cmsg flow pattern IPv4 length 
error");
+               } else {
+                       rte_pmd_nfp_trace_cmsg_flow_pattern_ipv6(start_p);
+                       start_p += sizeof(struct nfp_flower_ipv6);
+                       if (start_p != end)
+                               PMD_DRV_LOG(ERR, "Cmsg flow pattern IPv6 length 
error");
+               }
+
+               return;
+       }
+
+       /* Tunnel layer */
+       if ((nfp_flow_key_layer2 & NFP_FLOWER_LAYER2_TUN_IPV6) != 0) {
+               if ((nfp_flow_key_layer2 & NFP_FLOWER_LAYER2_GRE) != 0) {
+                       
rte_pmd_nfp_trace_cmsg_flow_pattern_ipv6_gre_tun(start_p);
+                       start_p += sizeof(struct nfp_flower_ipv6_gre_tun);
+                       if (start_p >= end)
+                               goto pattern_exit;
+               } else {
+                       
rte_pmd_nfp_trace_cmsg_flow_pattern_ipv6_udp_tun(start_p);
+                       start_p += sizeof(struct nfp_flower_ipv6_udp_tun);
+                       if (start_p >= end)
+                               goto pattern_exit;
+               }
+       } else {
+               if ((nfp_flow_key_layer2 & NFP_FLOWER_LAYER2_GRE) != 0) {
+                       
rte_pmd_nfp_trace_cmsg_flow_pattern_ipv4_gre_tun(start_p);
+                       start_p += sizeof(struct nfp_flower_ipv4_gre_tun);
+                       if (start_p >= end)
+                               goto pattern_exit;
+               } else {
+                       
rte_pmd_nfp_trace_cmsg_flow_pattern_ipv4_udp_tun(start_p);
+                       start_p += sizeof(struct nfp_flower_ipv4_udp_tun);
+                       if (start_p >= end)
+                               goto pattern_exit;
+               }
+       }
+
+       /* Inner L2 layer */
+       if ((nfp_flow_key_layer & NFP_FLOWER_LAYER_MAC) != 0) {
+               rte_pmd_nfp_trace_cmsg_flow_pattern_mac(start_p);
+               start_p += sizeof(struct nfp_flower_mac_mpls);
+               if (start_p >= end)
+                       goto pattern_exit;
+       }
+
+       /* Inner L4 layer comes first */
+       if ((nfp_flow_key_layer & NFP_FLOWER_LAYER_TP) != 0) {
+               rte_pmd_nfp_trace_cmsg_flow_pattern_tp(start_p);
+               start_p += sizeof(struct nfp_flower_tp_ports);
+               if (start_p >= end)
+                       goto pattern_exit;
+       }
+
+       /* Inner L3 layer */
+       if ((nfp_flow_key_layer & NFP_FLOWER_LAYER_IPV4) != 0) {
+               rte_pmd_nfp_trace_cmsg_flow_pattern_ipv4(start_p);
+               start_p += sizeof(struct nfp_flower_ipv4);
+               if (start_p != end) {
+                       PMD_DRV_LOG(ERR, "Cmsg flow pattern IPv4 length error");
+                       return;
+               }
+       } else {
+               rte_pmd_nfp_trace_cmsg_flow_pattern_ipv6(start_p);
+               start_p += sizeof(struct nfp_flower_ipv6);
+               if (start_p != end) {
+                       PMD_DRV_LOG(ERR, "Cmsg flow pattern IPv6 length error");
+                       return;
+               }
+       }
+
+       return;
+
+pattern_exit:
+       if (start_p != end)
+               PMD_DRV_LOG(ERR, "Cmsg flow pattern overlap");
+}
+
 static void
 nfp_flower_trace_cmsg_flow(const char *msg,
                struct nfp_fl_payload *payload)
 {
        rte_pmd_nfp_trace_cmsg_flow(msg);
        rte_pmd_nfp_trace_cmsg_flow_meta(payload->meta);
+       nfp_flower_trace_cmsg_flow_pattern(payload->unmasked_data, 
payload->mask_data);
+       nfp_flower_trace_cmsg_flow_pattern(payload->mask_data, 
payload->action_data);
 }
 
 int
diff --git a/drivers/net/nfp/nfp_trace.c b/drivers/net/nfp/nfp_trace.c
index d49fb85259..61162f7563 100644
--- a/drivers/net/nfp/nfp_trace.c
+++ b/drivers/net/nfp/nfp_trace.c
@@ -40,5 +40,38 @@ RTE_TRACE_POINT_REGISTER(rte_pmd_nfp_trace_cmsg_qos_rule,
 RTE_TRACE_POINT_REGISTER(rte_pmd_nfp_trace_cmsg_flow_meta,
                pmd.net.nfp.cmsg.flow.meta)
 
+RTE_TRACE_POINT_REGISTER(rte_pmd_nfp_trace_cmsg_flow_pattern_meta_tci,
+               pmd.net.nfp.cmsg.flow.pattern.meta_tci)
+
+RTE_TRACE_POINT_REGISTER(rte_pmd_nfp_trace_cmsg_flow_pattern_ext_meta,
+               pmd.net.nfp.cmsg.flow.pattern.ext_meta)
+
+RTE_TRACE_POINT_REGISTER(rte_pmd_nfp_trace_cmsg_flow_pattern_in_port,
+               pmd.net.nfp.cmsg.flow.pattern.in_port)
+
+RTE_TRACE_POINT_REGISTER(rte_pmd_nfp_trace_cmsg_flow_pattern_mac,
+               pmd.net.nfp.cmsg.flow.pattern.mac)
+
+RTE_TRACE_POINT_REGISTER(rte_pmd_nfp_trace_cmsg_flow_pattern_tp,
+               pmd.net.nfp.cmsg.flow.pattern.tp)
+
+RTE_TRACE_POINT_REGISTER(rte_pmd_nfp_trace_cmsg_flow_pattern_ipv4,
+               pmd.net.nfp.cmsg.flow.pattern.ipv4)
+
+RTE_TRACE_POINT_REGISTER(rte_pmd_nfp_trace_cmsg_flow_pattern_ipv6,
+               pmd.net.nfp.cmsg.flow.pattern.ipv6)
+
+RTE_TRACE_POINT_REGISTER(rte_pmd_nfp_trace_cmsg_flow_pattern_ipv4_gre_tun,
+               pmd.net.nfp.cmsg.flow.pattern.ipv4_gre_tun)
+
+RTE_TRACE_POINT_REGISTER(rte_pmd_nfp_trace_cmsg_flow_pattern_ipv4_udp_tun,
+               pmd.net.nfp.cmsg.flow.pattern.ipv4_udp_tun)
+
+RTE_TRACE_POINT_REGISTER(rte_pmd_nfp_trace_cmsg_flow_pattern_ipv6_gre_tun,
+               pmd.net.nfp.cmsg.flow.pattern.ipv6_gre_tun)
+
+RTE_TRACE_POINT_REGISTER(rte_pmd_nfp_trace_cmsg_flow_pattern_ipv6_udp_tun,
+               pmd.net.nfp.cmsg.flow.pattern.ipv6_udp_tun)
+
 RTE_TRACE_POINT_REGISTER(rte_pmd_nfp_trace_cmsg_flow,
                pmd.net.nfp.cmsg.flow)
diff --git a/drivers/net/nfp/nfp_trace.h b/drivers/net/nfp/nfp_trace.h
index e0b8b0cee9..a5a7cc8faf 100644
--- a/drivers/net/nfp/nfp_trace.h
+++ b/drivers/net/nfp/nfp_trace.h
@@ -236,6 +236,205 @@ RTE_TRACE_POINT(
        rte_trace_point_emit_u32(meta->shortcut);
 )
 
+RTE_TRACE_POINT(
+       rte_pmd_nfp_trace_cmsg_flow_pattern_meta_tci,
+       RTE_TRACE_POINT_ARGS(void *cmsg),
+
+       struct nfp_flower_meta_tci *msg = cmsg;
+
+       uint8_t nfp_flow_key_layer = msg->nfp_flow_key_layer;
+       uint8_t mask_id = msg->mask_id;
+       uint16_t tci = rte_be_to_cpu_16(msg->tci);
+
+       rte_trace_point_emit_u8(nfp_flow_key_layer);
+       rte_trace_point_emit_u8(mask_id);
+       rte_trace_point_emit_u16(tci);
+)
+
+RTE_TRACE_POINT(
+       rte_pmd_nfp_trace_cmsg_flow_pattern_ext_meta,
+       RTE_TRACE_POINT_ARGS(void *cmsg),
+
+       struct nfp_flower_ext_meta *msg = cmsg;
+
+       uint32_t nfp_flow_key_layer2 = 
rte_be_to_cpu_32(msg->nfp_flow_key_layer2);
+
+       rte_trace_point_emit_u32(nfp_flow_key_layer2);
+)
+
+RTE_TRACE_POINT(
+       rte_pmd_nfp_trace_cmsg_flow_pattern_in_port,
+       RTE_TRACE_POINT_ARGS(void *cmsg),
+
+       struct nfp_flower_in_port *msg = cmsg;
+
+       uint32_t in_port = rte_be_to_cpu_32(msg->in_port);
+
+       rte_trace_point_emit_u32(in_port);
+)
+
+RTE_TRACE_POINT(
+       rte_pmd_nfp_trace_cmsg_flow_pattern_mac,
+       RTE_TRACE_POINT_ARGS(void *cmsg),
+
+       struct nfp_flower_mac_mpls *msg = cmsg;
+
+       uint8_t mac_dst_len = RTE_ETHER_ADDR_LEN;
+       uint8_t mac_src_len = RTE_ETHER_ADDR_LEN;
+       uint8_t *mac_dst = &msg->mac_dst[0];
+       uint8_t *mac_src = &msg->mac_src[0];
+       uint32_t mpls_lse = rte_be_to_cpu_32(msg->mpls_lse);
+
+       rte_trace_point_emit_blob(mac_dst, mac_dst_len);
+       rte_trace_point_emit_blob(mac_src, mac_src_len);
+       rte_trace_point_emit_u32(mpls_lse);
+)
+
+RTE_TRACE_POINT(
+       rte_pmd_nfp_trace_cmsg_flow_pattern_tp,
+       RTE_TRACE_POINT_ARGS(void *cmsg),
+
+       struct nfp_flower_tp_ports *msg = cmsg;
+
+       uint16_t port_src = rte_be_to_cpu_16(msg->port_src);
+       uint16_t port_dst = rte_be_to_cpu_16(msg->port_dst);
+
+       rte_trace_point_emit_u16(port_src);
+       rte_trace_point_emit_u16(port_dst);
+)
+
+RTE_TRACE_POINT(
+       rte_pmd_nfp_trace_cmsg_flow_pattern_ipv4,
+       RTE_TRACE_POINT_ARGS(void *cmsg),
+
+       struct nfp_flower_ipv4 *msg = cmsg;
+
+       uint8_t tos = msg->ip_ext.tos;
+       uint8_t proto = msg->ip_ext.proto;
+       uint8_t ttl = msg->ip_ext.ttl;
+       uint8_t flags = msg->ip_ext.flags;
+       uint32_t ipv4_src = rte_be_to_cpu_16(msg->ipv4_src);
+       uint32_t ipv4_dst = rte_be_to_cpu_16(msg->ipv4_dst);
+
+       rte_trace_point_emit_u8(tos);
+       rte_trace_point_emit_u8(proto);
+       rte_trace_point_emit_u8(ttl);
+       rte_trace_point_emit_u8(flags);
+       rte_trace_point_emit_u32(ipv4_src);
+       rte_trace_point_emit_u32(ipv4_dst);
+)
+
+RTE_TRACE_POINT(
+       rte_pmd_nfp_trace_cmsg_flow_pattern_ipv6,
+       RTE_TRACE_POINT_ARGS(void *cmsg),
+
+       struct nfp_flower_ipv6 *msg = cmsg;
+
+       uint8_t tos = msg->ip_ext.tos;
+       uint8_t proto = msg->ip_ext.proto;
+       uint8_t ttl = msg->ip_ext.ttl;
+       uint8_t flags = msg->ip_ext.flags;
+       uint8_t ipv6_src_len = 16;
+       uint8_t *ipv6_src = &msg->ipv6_src[0];
+       uint8_t ipv6_dst_len = 16;
+       uint8_t *ipv6_dst = &msg->ipv6_dst[0];
+
+       rte_trace_point_emit_u8(tos);
+       rte_trace_point_emit_u8(proto);
+       rte_trace_point_emit_u8(ttl);
+       rte_trace_point_emit_u8(flags);
+       rte_trace_point_emit_blob(ipv6_src, ipv6_src_len);
+       rte_trace_point_emit_blob(ipv6_dst, ipv6_dst_len);
+)
+
+RTE_TRACE_POINT(
+       rte_pmd_nfp_trace_cmsg_flow_pattern_ipv4_gre_tun,
+       RTE_TRACE_POINT_ARGS(void *cmsg),
+
+       struct nfp_flower_ipv4_gre_tun *msg = cmsg;
+
+       uint32_t src = rte_be_to_cpu_32(msg->ipv4.src);
+       uint32_t dst = rte_be_to_cpu_32(msg->ipv4.dst);
+       uint16_t tun_flags = rte_be_to_cpu_16(msg->tun_flags);
+       uint8_t tos = msg->ip_ext.tos;
+       uint8_t ttl = msg->ip_ext.ttl;
+       uint16_t ethertype = rte_be_to_cpu_16(msg->ethertype);
+       uint32_t tun_key = rte_be_to_cpu_32(msg->tun_key);
+
+       rte_trace_point_emit_u32(src);
+       rte_trace_point_emit_u32(dst);
+       rte_trace_point_emit_u16(tun_flags);
+       rte_trace_point_emit_u8(tos);
+       rte_trace_point_emit_u8(ttl);
+       rte_trace_point_emit_u16(ethertype);
+       rte_trace_point_emit_u32(tun_key);
+)
+
+RTE_TRACE_POINT(
+       rte_pmd_nfp_trace_cmsg_flow_pattern_ipv4_udp_tun,
+       RTE_TRACE_POINT_ARGS(void *cmsg),
+
+       struct nfp_flower_ipv4_udp_tun *msg = cmsg;
+
+       uint32_t src = rte_be_to_cpu_32(msg->ipv4.src);
+       uint32_t dst = rte_be_to_cpu_32(msg->ipv4.dst);
+       uint8_t tos = msg->ip_ext.tos;
+       uint8_t ttl = msg->ip_ext.ttl;
+       uint32_t tun_id = rte_be_to_cpu_32(msg->tun_id);
+
+       rte_trace_point_emit_u32(src);
+       rte_trace_point_emit_u32(dst);
+       rte_trace_point_emit_u8(tos);
+       rte_trace_point_emit_u8(ttl);
+       rte_trace_point_emit_u32(tun_id);
+)
+
+RTE_TRACE_POINT(
+       rte_pmd_nfp_trace_cmsg_flow_pattern_ipv6_gre_tun,
+       RTE_TRACE_POINT_ARGS(void *cmsg),
+
+       struct nfp_flower_ipv6_gre_tun *msg = cmsg;
+
+       uint8_t ipv6_src_len = 16;
+       uint8_t *ipv6_src = &msg->ipv6.ipv6_src[0];
+       uint8_t ipv6_dst_len = 16;
+       uint8_t *ipv6_dst = &msg->ipv6.ipv6_dst[0];
+       uint16_t tun_flags = rte_be_to_cpu_16(msg->tun_flags);
+       uint8_t tos = msg->ip_ext.tos;
+       uint8_t ttl = msg->ip_ext.ttl;
+       uint16_t ethertype = rte_be_to_cpu_16(msg->ethertype);
+       uint32_t tun_key = rte_be_to_cpu_32(msg->tun_key);
+
+       rte_trace_point_emit_blob(ipv6_src, ipv6_src_len);
+       rte_trace_point_emit_blob(ipv6_dst, ipv6_dst_len);
+       rte_trace_point_emit_u16(tun_flags);
+       rte_trace_point_emit_u8(tos);
+       rte_trace_point_emit_u8(ttl);
+       rte_trace_point_emit_u16(ethertype);
+       rte_trace_point_emit_u32(tun_key);
+)
+
+RTE_TRACE_POINT(
+       rte_pmd_nfp_trace_cmsg_flow_pattern_ipv6_udp_tun,
+       RTE_TRACE_POINT_ARGS(void *cmsg),
+
+       struct nfp_flower_ipv6_udp_tun *msg = cmsg;
+
+       uint8_t ipv6_src_len = 16;
+       uint8_t *ipv6_src = &msg->ipv6.ipv6_src[0];
+       uint8_t ipv6_dst_len = 16;
+       uint8_t *ipv6_dst = &msg->ipv6.ipv6_dst[0];
+       uint8_t tos = msg->ip_ext.tos;
+       uint8_t ttl = msg->ip_ext.ttl;
+       uint32_t tun_id = rte_be_to_cpu_32(msg->tun_id);
+
+       rte_trace_point_emit_blob(ipv6_src, ipv6_src_len);
+       rte_trace_point_emit_blob(ipv6_dst, ipv6_dst_len);
+       rte_trace_point_emit_u8(tos);
+       rte_trace_point_emit_u8(ttl);
+       rte_trace_point_emit_u32(tun_id);
+)
+
 RTE_TRACE_POINT(
        rte_pmd_nfp_trace_cmsg_flow,
        RTE_TRACE_POINT_ARGS(const char *name),
-- 
2.39.1

Reply via email to