+static inline void dpaa2_prot_field_string(
+ enum net_prot prot, uint32_t field,
+ char *string)
+{
+ if (!dpaa2_flow_control_log)
+ return;
+
+ if (prot == NET_PROT_ETH) {
+ strcpy(string, "eth");
+ if (field == NH_FLD_ETH_DA)
+ strcat(string, ".dst");
+ else if (field == NH_FLD_ETH_SA)
+ strcat(string, ".src");
+ else if (field == NH_FLD_ETH_TYPE)
+ strcat(string, ".type");
+ else
+ strcat(string, ".unknown field");
+ } else if (prot == NET_PROT_VLAN) {
+ strcpy(string, "vlan");
+ if (field == NH_FLD_VLAN_TCI)
+ strcat(string, ".tci");
+ else
+ strcat(string, ".unknown field");
+ } else if (prot == NET_PROT_IP) {
+ strcpy(string, "ip");
+ if (field == NH_FLD_IP_SRC)
+ strcat(string, ".src");
+ else if (field == NH_FLD_IP_DST)
+ strcat(string, ".dst");
+ else if (field == NH_FLD_IP_PROTO)
+ strcat(string, ".proto");
+ else
+ strcat(string, ".unknown field");
+ } else if (prot == NET_PROT_TCP) {
+ strcpy(string, "tcp");
+ if (field == NH_FLD_TCP_PORT_SRC)
+ strcat(string, ".src");
+ else if (field == NH_FLD_TCP_PORT_DST)
+ strcat(string, ".dst");
+ else
+ strcat(string, ".unknown field");
+ } else if (prot == NET_PROT_UDP) {
+ strcpy(string, "udp");
+ if (field == NH_FLD_UDP_PORT_SRC)
+ strcat(string, ".src");
+ else if (field == NH_FLD_UDP_PORT_DST)
+ strcat(string, ".dst");
+ else
+ strcat(string, ".unknown field");
+ } else if (prot == NET_PROT_ICMP) {
+ strcpy(string, "icmp");
+ if (field == NH_FLD_ICMP_TYPE)
+ strcat(string, ".type");
+ else if (field == NH_FLD_ICMP_CODE)
+ strcat(string, ".code");
+ else
+ strcat(string, ".unknown field");
+ } else if (prot == NET_PROT_SCTP) {
+ strcpy(string, "sctp");
+ if (field == NH_FLD_SCTP_PORT_SRC)
+ strcat(string, ".src");
+ else if (field == NH_FLD_SCTP_PORT_DST)
+ strcat(string, ".dst");
+ else
+ strcat(string, ".unknown field");
+ } else if (prot == NET_PROT_GRE) {
+ strcpy(string, "gre");
+ if (field == NH_FLD_GRE_TYPE)
+ strcat(string, ".type");
+ else
+ strcat(string, ".unknown field");
+ } else {
+ strcpy(string, "unknown protocol");
+ }
+}
+
+static inline void dpaa2_flow_qos_table_extracts_log(
+ const struct dpaa2_dev_priv *priv)
+{
+ int idx;
+ char string[32];
+
+ if (!dpaa2_flow_control_log)
+ return;
+
+ printf("Setup QoS table: number of extracts: %d\r\n",
+ priv->extract.qos_key_extract.dpkg.num_extracts);
+ for (idx = 0; idx < priv->extract.qos_key_extract.dpkg.num_extracts;
+ idx++) {
+ dpaa2_prot_field_string(priv->extract.qos_key_extract.dpkg
+ .extracts[idx].extract.from_hdr.prot,
+ priv->extract.qos_key_extract.dpkg.extracts[idx]
+ .extract.from_hdr.field,
+ string);
+ printf("%s", string);
+ if ((idx + 1) < priv->extract.qos_key_extract.dpkg.num_extracts)
+ printf(" / ");
+ }
+ printf("\r\n");
+}
+
+static inline void dpaa2_flow_fs_table_extracts_log(
+ const struct dpaa2_dev_priv *priv, int tc_id)
+{
+ int idx;
+ char string[32];
+
+ if (!dpaa2_flow_control_log)
+ return;
+
+ printf("Setup FS table: number of extracts of TC[%d]: %d\r\n",
+ tc_id, priv->extract.tc_key_extract[tc_id]
+ .dpkg.num_extracts);
+ for (idx = 0; idx < priv->extract.tc_key_extract[tc_id]
+ .dpkg.num_extracts; idx++) {
+ dpaa2_prot_field_string(priv->extract.tc_key_extract[tc_id]
+ .dpkg.extracts[idx].extract.from_hdr.prot,
+ priv->extract.tc_key_extract[tc_id].dpkg.extracts[idx]
+ .extract.from_hdr.field,
+ string);
+ printf("%s", string);
+ if ((idx + 1) < priv->extract.tc_key_extract[tc_id]
+ .dpkg.num_extracts)
+ printf(" / ");
+ }
+ printf("\r\n");
+}
+
+static inline void dpaa2_flow_qos_entry_log(
+ const char *log_info, const struct rte_flow *flow, int qos_index)
+{
+ int idx;
+ uint8_t *key, *mask;
+
+ if (!dpaa2_flow_control_log)
+ return;
+
+ printf("\r\n%s QoS entry[%d] for TC[%d], extracts size is %d\r\n",
+ log_info, qos_index, flow->tc_id, flow->qos_real_key_size);
+
+ key = (uint8_t *)(size_t)flow->qos_rule.key_iova;
+ mask = (uint8_t *)(size_t)flow->qos_rule.mask_iova;
+
+ printf("key:\r\n");
+ for (idx = 0; idx < flow->qos_real_key_size; idx++)
+ printf("%02x ", key[idx]);
+
+ printf("\r\nmask:\r\n");
+ for (idx = 0; idx < flow->qos_real_key_size; idx++)
+ printf("%02x ", mask[idx]);
+
+ printf("\r\n%s QoS ipsrc: %d, ipdst: %d\r\n", log_info,
+ flow->ipaddr_rule.qos_ipsrc_offset,
+ flow->ipaddr_rule.qos_ipdst_offset);
+}
+
+static inline void dpaa2_flow_fs_entry_log(
+ const char *log_info, const struct rte_flow *flow)
+{
+ int idx;
+ uint8_t *key, *mask;
+
+ if (!dpaa2_flow_control_log)
+ return;
+
+ printf("\r\n%s FS/TC entry[%d] of TC[%d], extracts size is %d\r\n",
+ log_info, flow->tc_index, flow->tc_id, flow->fs_real_key_size);
+
+ key = (uint8_t *)(size_t)flow->fs_rule.key_iova;
+ mask = (uint8_t *)(size_t)flow->fs_rule.mask_iova;
+
+ printf("key:\r\n");
+ for (idx = 0; idx < flow->fs_real_key_size; idx++)
+ printf("%02x ", key[idx]);
+
+ printf("\r\nmask:\r\n");
+ for (idx = 0; idx < flow->fs_real_key_size; idx++)
+ printf("%02x ", mask[idx]);
+
+ printf("\r\n%s FS ipsrc: %d, ipdst: %d\r\n", log_info,
+ flow->ipaddr_rule.fs_ipsrc_offset,
+ flow->ipaddr_rule.fs_ipdst_offset);
+}