net/mlx5: remove excessive data prefetch
[dpdk.git] / drivers / net / mlx5 / mlx5_flow.c
index 30b8573..7ef68de 100644 (file)
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: BSD-3-Clause
  * Copyright 2016 6WIND S.A.
- * Copyright 2016 Mellanox.
+ * Copyright 2016 Mellanox Technologies, Ltd
  */
 
 #include <sys/queue.h>
@@ -44,40 +44,46 @@ struct ibv_flow_spec_counter_action {
 extern const struct eth_dev_ops mlx5_dev_ops;
 extern const struct eth_dev_ops mlx5_dev_ops_isolate;
 
+/** Structure give to the conversion functions. */
+struct mlx5_flow_data {
+       struct mlx5_flow_parse *parser; /** Parser context. */
+       struct rte_flow_error *error; /** Error context. */
+};
+
 static int
 mlx5_flow_create_eth(const struct rte_flow_item *item,
                     const void *default_mask,
-                    void *data);
+                    struct mlx5_flow_data *data);
 
 static int
 mlx5_flow_create_vlan(const struct rte_flow_item *item,
                      const void *default_mask,
-                     void *data);
+                     struct mlx5_flow_data *data);
 
 static int
 mlx5_flow_create_ipv4(const struct rte_flow_item *item,
                      const void *default_mask,
-                     void *data);
+                     struct mlx5_flow_data *data);
 
 static int
 mlx5_flow_create_ipv6(const struct rte_flow_item *item,
                      const void *default_mask,
-                     void *data);
+                     struct mlx5_flow_data *data);
 
 static int
 mlx5_flow_create_udp(const struct rte_flow_item *item,
                     const void *default_mask,
-                    void *data);
+                    struct mlx5_flow_data *data);
 
 static int
 mlx5_flow_create_tcp(const struct rte_flow_item *item,
                     const void *default_mask,
-                    void *data);
+                    struct mlx5_flow_data *data);
 
 static int
 mlx5_flow_create_vxlan(const struct rte_flow_item *item,
                       const void *default_mask,
-                      void *data);
+                      struct mlx5_flow_data *data);
 
 struct mlx5_flow_parse;
 
@@ -118,7 +124,7 @@ const struct hash_rxq_init hash_rxq_init[] = {
                                IBV_RX_HASH_SRC_PORT_TCP |
                                IBV_RX_HASH_DST_PORT_TCP),
                .dpdk_rss_hf = ETH_RSS_NONFRAG_IPV4_TCP,
-               .flow_priority = 0,
+               .flow_priority = 1,
                .ip_version = MLX5_IPV4,
        },
        [HASH_RXQ_UDPV4] = {
@@ -127,7 +133,7 @@ const struct hash_rxq_init hash_rxq_init[] = {
                                IBV_RX_HASH_SRC_PORT_UDP |
                                IBV_RX_HASH_DST_PORT_UDP),
                .dpdk_rss_hf = ETH_RSS_NONFRAG_IPV4_UDP,
-               .flow_priority = 0,
+               .flow_priority = 1,
                .ip_version = MLX5_IPV4,
        },
        [HASH_RXQ_IPV4] = {
@@ -135,7 +141,7 @@ const struct hash_rxq_init hash_rxq_init[] = {
                                IBV_RX_HASH_DST_IPV4),
                .dpdk_rss_hf = (ETH_RSS_IPV4 |
                                ETH_RSS_FRAG_IPV4),
-               .flow_priority = 1,
+               .flow_priority = 2,
                .ip_version = MLX5_IPV4,
        },
        [HASH_RXQ_TCPV6] = {
@@ -144,7 +150,7 @@ const struct hash_rxq_init hash_rxq_init[] = {
                                IBV_RX_HASH_SRC_PORT_TCP |
                                IBV_RX_HASH_DST_PORT_TCP),
                .dpdk_rss_hf = ETH_RSS_NONFRAG_IPV6_TCP,
-               .flow_priority = 0,
+               .flow_priority = 1,
                .ip_version = MLX5_IPV6,
        },
        [HASH_RXQ_UDPV6] = {
@@ -153,7 +159,7 @@ const struct hash_rxq_init hash_rxq_init[] = {
                                IBV_RX_HASH_SRC_PORT_UDP |
                                IBV_RX_HASH_DST_PORT_UDP),
                .dpdk_rss_hf = ETH_RSS_NONFRAG_IPV6_UDP,
-               .flow_priority = 0,
+               .flow_priority = 1,
                .ip_version = MLX5_IPV6,
        },
        [HASH_RXQ_IPV6] = {
@@ -161,13 +167,13 @@ const struct hash_rxq_init hash_rxq_init[] = {
                                IBV_RX_HASH_DST_IPV6),
                .dpdk_rss_hf = (ETH_RSS_IPV6 |
                                ETH_RSS_FRAG_IPV6),
-               .flow_priority = 1,
+               .flow_priority = 2,
                .ip_version = MLX5_IPV6,
        },
        [HASH_RXQ_ETH] = {
                .hash_fields = 0,
                .dpdk_rss_hf = 0,
-               .flow_priority = 2,
+               .flow_priority = 3,
        },
 };
 
@@ -252,7 +258,7 @@ struct mlx5_flow_items {
         */
        int (*convert)(const struct rte_flow_item *item,
                       const void *default_mask,
-                      void *data);
+                      struct mlx5_flow_data *data);
        /** Size in bytes of the destination structure. */
        const unsigned int dst_sz;
        /** List of possible following items.  */
@@ -861,8 +867,6 @@ exit_item_not_supported:
 /**
  * Allocate memory space to store verbs flow attributes.
  *
- * @param[in] priority
- *   Flow priority.
  * @param[in] size
  *   Amount of byte to allocate.
  * @param[out] error
@@ -872,9 +876,7 @@ exit_item_not_supported:
  *   A verbs flow attribute on success, NULL otherwise and rte_errno is set.
  */
 static struct ibv_flow_attr *
-mlx5_flow_convert_allocate(unsigned int priority,
-                          unsigned int size,
-                          struct rte_flow_error *error)
+mlx5_flow_convert_allocate(unsigned int size, struct rte_flow_error *error)
 {
        struct ibv_flow_attr *ibv_attr;
 
@@ -883,13 +885,43 @@ mlx5_flow_convert_allocate(unsigned int priority,
                rte_flow_error_set(error, ENOMEM,
                                   RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
                                   NULL,
-                                  "cannot allocate verbs spec attributes.");
+                                  "cannot allocate verbs spec attributes");
                return NULL;
        }
-       ibv_attr->priority = priority;
        return ibv_attr;
 }
 
+/**
+ * Make inner packet matching with an higher priority from the non Inner
+ * matching.
+ *
+ * @param[in, out] parser
+ *   Internal parser structure.
+ * @param attr
+ *   User flow attribute.
+ */
+static void
+mlx5_flow_update_priority(struct mlx5_flow_parse *parser,
+                         const struct rte_flow_attr *attr)
+{
+       unsigned int i;
+
+       if (parser->drop) {
+               parser->queue[HASH_RXQ_ETH].ibv_attr->priority =
+                       attr->priority +
+                       hash_rxq_init[HASH_RXQ_ETH].flow_priority;
+               return;
+       }
+       for (i = 0; i != hash_rxq_init_n; ++i) {
+               if (parser->queue[i].ibv_attr) {
+                       parser->queue[i].ibv_attr->priority =
+                               attr->priority +
+                               hash_rxq_init[i].flow_priority -
+                               (parser->inner ? 1 : 0);
+               }
+       }
+}
+
 /**
  * Finalise verbs flow attributes.
  *
@@ -909,7 +941,7 @@ mlx5_flow_convert_finalise(struct mlx5_flow_parse *parser)
        unsigned int i;
 
        /* Remove any other flow not matching the pattern. */
-       if (parser->queues_n == 1) {
+       if (parser->queues_n == 1 && !parser->rss_conf.rss_hf) {
                for (i = 0; i != hash_rxq_init_n; ++i) {
                        if (i == HASH_RXQ_ETH)
                                continue;
@@ -1065,22 +1097,16 @@ mlx5_flow_convert(struct rte_eth_dev *dev,
         * Allocate the memory space to store verbs specifications.
         */
        if (parser->drop) {
-               unsigned int priority =
-                       attr->priority +
-                       hash_rxq_init[HASH_RXQ_ETH].flow_priority;
                unsigned int offset = parser->queue[HASH_RXQ_ETH].offset;
 
                parser->queue[HASH_RXQ_ETH].ibv_attr =
-                       mlx5_flow_convert_allocate(priority, offset, error);
+                       mlx5_flow_convert_allocate(offset, error);
                if (!parser->queue[HASH_RXQ_ETH].ibv_attr)
                        goto exit_enomem;
                parser->queue[HASH_RXQ_ETH].offset =
                        sizeof(struct ibv_flow_attr);
        } else {
                for (i = 0; i != hash_rxq_init_n; ++i) {
-                       unsigned int priority =
-                               attr->priority +
-                               hash_rxq_init[i].flow_priority;
                        unsigned int offset;
 
                        if (!(parser->rss_conf.rss_hf &
@@ -1089,8 +1115,7 @@ mlx5_flow_convert(struct rte_eth_dev *dev,
                                continue;
                        offset = parser->queue[i].offset;
                        parser->queue[i].ibv_attr =
-                               mlx5_flow_convert_allocate(priority,
-                                                          offset, error);
+                               mlx5_flow_convert_allocate(offset, error);
                        if (!parser->queue[i].ibv_attr)
                                goto exit_enomem;
                        parser->queue[i].offset = sizeof(struct ibv_flow_attr);
@@ -1099,6 +1124,11 @@ mlx5_flow_convert(struct rte_eth_dev *dev,
        /* Third step. Conversion parse, fill the specifications. */
        parser->inner = 0;
        for (; items->type != RTE_FLOW_ITEM_TYPE_END; ++items) {
+               struct mlx5_flow_data data = {
+                       .parser = parser,
+                       .error = error,
+               };
+
                if (items->type == RTE_FLOW_ITEM_TYPE_VOID)
                        continue;
                cur_item = &mlx5_flow_items[items->type];
@@ -1106,13 +1136,9 @@ mlx5_flow_convert(struct rte_eth_dev *dev,
                                        (cur_item->default_mask ?
                                         cur_item->default_mask :
                                         cur_item->mask),
-                                       parser);
-               if (ret) {
-                       rte_flow_error_set(error, rte_errno,
-                                          RTE_FLOW_ERROR_TYPE_ITEM,
-                                          items, "item not supported");
+                                        &data);
+               if (ret)
                        goto exit_free;
-               }
        }
        if (parser->mark)
                mlx5_flow_create_flag_mark(parser, parser->mark_id);
@@ -1125,13 +1151,9 @@ mlx5_flow_convert(struct rte_eth_dev *dev,
         * Last step. Complete missing specification to reach the RSS
         * configuration.
         */
-       if (!parser->drop) {
+       if (!parser->drop)
                mlx5_flow_convert_finalise(parser);
-       } else {
-               parser->queue[HASH_RXQ_ETH].ibv_attr->priority =
-                       attr->priority +
-                       hash_rxq_init[parser->layer].flow_priority;
-       }
+       mlx5_flow_update_priority(parser, attr);
 exit_free:
        /* Only verification is expected, all resources should be released. */
        if (!parser->create) {
@@ -1151,11 +1173,11 @@ exit_enomem:
                }
        }
        rte_flow_error_set(error, ENOMEM, RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
-                          NULL, "cannot allocate verbs spec attributes.");
+                          NULL, "cannot allocate verbs spec attributes");
        return -rte_errno;
 exit_count_error:
        rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
-                          NULL, "cannot create counter.");
+                          NULL, "cannot create counter");
        return -rte_errno;
 }
 
@@ -1209,11 +1231,11 @@ mlx5_flow_create_copy(struct mlx5_flow_parse *parser, void *src,
 static int
 mlx5_flow_create_eth(const struct rte_flow_item *item,
                     const void *default_mask,
-                    void *data)
+                    struct mlx5_flow_data *data)
 {
        const struct rte_flow_item_eth *spec = item->spec;
        const struct rte_flow_item_eth *mask = item->mask;
-       struct mlx5_flow_parse *parser = (struct mlx5_flow_parse *)data;
+       struct mlx5_flow_parse *parser = data->parser;
        const unsigned int eth_size = sizeof(struct ibv_flow_spec_eth);
        struct ibv_flow_spec_eth eth = {
                .type = parser->inner | IBV_FLOW_SPEC_ETH,
@@ -1261,11 +1283,11 @@ mlx5_flow_create_eth(const struct rte_flow_item *item,
 static int
 mlx5_flow_create_vlan(const struct rte_flow_item *item,
                      const void *default_mask,
-                     void *data)
+                     struct mlx5_flow_data *data)
 {
        const struct rte_flow_item_vlan *spec = item->spec;
        const struct rte_flow_item_vlan *mask = item->mask;
-       struct mlx5_flow_parse *parser = (struct mlx5_flow_parse *)data;
+       struct mlx5_flow_parse *parser = data->parser;
        struct ibv_flow_spec_eth *eth;
        const unsigned int eth_size = sizeof(struct ibv_flow_spec_eth);
 
@@ -1283,9 +1305,18 @@ mlx5_flow_create_vlan(const struct rte_flow_item *item,
                        eth->val.vlan_tag = spec->tci;
                        eth->mask.vlan_tag = mask->tci;
                        eth->val.vlan_tag &= eth->mask.vlan_tag;
+                       /*
+                        * From verbs perspective an empty VLAN is equivalent
+                        * to a packet without VLAN layer.
+                        */
+                       if (!eth->mask.vlan_tag)
+                               goto error;
                }
+               return 0;
        }
-       return 0;
+error:
+       return rte_flow_error_set(data->error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM,
+                                 item, "VLAN cannot be empty");
 }
 
 /**
@@ -1304,11 +1335,11 @@ mlx5_flow_create_vlan(const struct rte_flow_item *item,
 static int
 mlx5_flow_create_ipv4(const struct rte_flow_item *item,
                      const void *default_mask,
-                     void *data)
+                     struct mlx5_flow_data *data)
 {
        const struct rte_flow_item_ipv4 *spec = item->spec;
        const struct rte_flow_item_ipv4 *mask = item->mask;
-       struct mlx5_flow_parse *parser = (struct mlx5_flow_parse *)data;
+       struct mlx5_flow_parse *parser = data->parser;
        unsigned int ipv4_size = sizeof(struct ibv_flow_spec_ipv4_ext);
        struct ibv_flow_spec_ipv4_ext ipv4 = {
                .type = parser->inner | IBV_FLOW_SPEC_IPV4_EXT,
@@ -1359,11 +1390,11 @@ mlx5_flow_create_ipv4(const struct rte_flow_item *item,
 static int
 mlx5_flow_create_ipv6(const struct rte_flow_item *item,
                      const void *default_mask,
-                     void *data)
+                     struct mlx5_flow_data *data)
 {
        const struct rte_flow_item_ipv6 *spec = item->spec;
        const struct rte_flow_item_ipv6 *mask = item->mask;
-       struct mlx5_flow_parse *parser = (struct mlx5_flow_parse *)data;
+       struct mlx5_flow_parse *parser = data->parser;
        unsigned int ipv6_size = sizeof(struct ibv_flow_spec_ipv6);
        struct ibv_flow_spec_ipv6 ipv6 = {
                .type = parser->inner | IBV_FLOW_SPEC_IPV6,
@@ -1434,11 +1465,11 @@ mlx5_flow_create_ipv6(const struct rte_flow_item *item,
 static int
 mlx5_flow_create_udp(const struct rte_flow_item *item,
                     const void *default_mask,
-                    void *data)
+                    struct mlx5_flow_data *data)
 {
        const struct rte_flow_item_udp *spec = item->spec;
        const struct rte_flow_item_udp *mask = item->mask;
-       struct mlx5_flow_parse *parser = (struct mlx5_flow_parse *)data;
+       struct mlx5_flow_parse *parser = data->parser;
        unsigned int udp_size = sizeof(struct ibv_flow_spec_tcp_udp);
        struct ibv_flow_spec_tcp_udp udp = {
                .type = parser->inner | IBV_FLOW_SPEC_UDP,
@@ -1483,11 +1514,11 @@ mlx5_flow_create_udp(const struct rte_flow_item *item,
 static int
 mlx5_flow_create_tcp(const struct rte_flow_item *item,
                     const void *default_mask,
-                    void *data)
+                    struct mlx5_flow_data *data)
 {
        const struct rte_flow_item_tcp *spec = item->spec;
        const struct rte_flow_item_tcp *mask = item->mask;
-       struct mlx5_flow_parse *parser = (struct mlx5_flow_parse *)data;
+       struct mlx5_flow_parse *parser = data->parser;
        unsigned int tcp_size = sizeof(struct ibv_flow_spec_tcp_udp);
        struct ibv_flow_spec_tcp_udp tcp = {
                .type = parser->inner | IBV_FLOW_SPEC_TCP,
@@ -1532,11 +1563,11 @@ mlx5_flow_create_tcp(const struct rte_flow_item *item,
 static int
 mlx5_flow_create_vxlan(const struct rte_flow_item *item,
                       const void *default_mask,
-                      void *data)
+                      struct mlx5_flow_data *data)
 {
        const struct rte_flow_item_vxlan *spec = item->spec;
        const struct rte_flow_item_vxlan *mask = item->mask;
-       struct mlx5_flow_parse *parser = (struct mlx5_flow_parse *)data;
+       struct mlx5_flow_parse *parser = data->parser;
        unsigned int size = sizeof(struct ibv_flow_spec_tunnel);
        struct ibv_flow_spec_tunnel vxlan = {
                .type = parser->inner | IBV_FLOW_SPEC_VXLAN_TUNNEL,
@@ -1567,10 +1598,11 @@ mlx5_flow_create_vxlan(const struct rte_flow_item *item,
         * before will also match this rule.
         * To avoid such situation, VNI 0 is currently refused.
         */
-       if (!vxlan.val.tunnel_id) {
-               rte_errno = EINVAL;
-               return -rte_errno;
-       }
+       if (!vxlan.val.tunnel_id)
+               return rte_flow_error_set(data->error, EINVAL,
+                                         RTE_FLOW_ERROR_TYPE_ITEM,
+                                         item,
+                                         "VxLAN vni cannot be 0");
        mlx5_flow_create_copy(parser, &vxlan, size);
        return 0;
 }
@@ -1818,10 +1850,11 @@ mlx5_flow_create_action_queue(struct rte_eth_dev *dev,
                        goto error;
                }
                ++flows_n;
-               DEBUG("%p type %d QP %p ibv_flow %p",
-                     (void *)flow, i,
-                     (void *)flow->frxq[i].hrxq,
-                     (void *)flow->frxq[i].ibv_flow);
+               DRV_LOG(DEBUG, "port %u %p type %d QP %p ibv_flow %p",
+                       dev->data->port_id,
+                       (void *)flow, i,
+                       (void *)flow->frxq[i].hrxq,
+                       (void *)flow->frxq[i].ibv_flow);
        }
        if (!flows_n) {
                rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_HANDLE,
@@ -1921,10 +1954,12 @@ mlx5_flow_list_create(struct rte_eth_dev *dev,
        if (ret)
                goto exit;
        TAILQ_INSERT_TAIL(list, flow, next);
-       DEBUG("Flow created %p", (void *)flow);
+       DRV_LOG(DEBUG, "port %u flow created %p", dev->data->port_id,
+               (void *)flow);
        return flow;
 exit:
-       ERROR("flow creation error: %s", error->message);
+       DRV_LOG(ERR, "port %u flow creation error: %s", dev->data->port_id,
+               error->message);
        for (i = 0; i != hash_rxq_init_n; ++i) {
                if (parser.queue[i].ibv_attr)
                        rte_free(parser.queue[i].ibv_attr);
@@ -2042,7 +2077,8 @@ free:
                flow->cs = NULL;
        }
        TAILQ_REMOVE(list, flow, next);
-       DEBUG("Flow destroyed %p", (void *)flow);
+       DRV_LOG(DEBUG, "port %u flow destroyed %p", dev->data->port_id,
+               (void *)flow);
        rte_free(flow);
 }
 
@@ -2084,13 +2120,16 @@ mlx5_flow_create_drop_queue(struct rte_eth_dev *dev)
        assert(priv->ctx);
        fdq = rte_calloc(__func__, 1, sizeof(*fdq), 0);
        if (!fdq) {
-               WARN("cannot allocate memory for drop queue");
+               DRV_LOG(WARNING,
+                       "port %u cannot allocate memory for drop queue",
+                       dev->data->port_id);
                rte_errno = ENOMEM;
                return -rte_errno;
        }
        fdq->cq = mlx5_glue->create_cq(priv->ctx, 1, NULL, NULL, 0);
        if (!fdq->cq) {
-               WARN("cannot allocate CQ for drop queue");
+               DRV_LOG(WARNING, "port %u cannot allocate CQ for drop queue",
+                       dev->data->port_id);
                rte_errno = errno;
                goto error;
        }
@@ -2104,7 +2143,8 @@ mlx5_flow_create_drop_queue(struct rte_eth_dev *dev)
                        .cq = fdq->cq,
                 });
        if (!fdq->wq) {
-               WARN("cannot allocate WQ for drop queue");
+               DRV_LOG(WARNING, "port %u cannot allocate WQ for drop queue",
+                       dev->data->port_id);
                rte_errno = errno;
                goto error;
        }
@@ -2116,7 +2156,10 @@ mlx5_flow_create_drop_queue(struct rte_eth_dev *dev)
                        .comp_mask = 0,
                 });
        if (!fdq->ind_table) {
-               WARN("cannot allocate indirection table for drop queue");
+               DRV_LOG(WARNING,
+                       "port %u cannot allocate indirection table for drop"
+                       " queue",
+                       dev->data->port_id);
                rte_errno = errno;
                goto error;
        }
@@ -2139,7 +2182,8 @@ mlx5_flow_create_drop_queue(struct rte_eth_dev *dev)
                        .pd = priv->pd
                 });
        if (!fdq->qp) {
-               WARN("cannot allocate QP for drop queue");
+               DRV_LOG(WARNING, "port %u cannot allocate QP for drop queue",
+                       dev->data->port_id);
                rte_errno = errno;
                goto error;
        }
@@ -2210,7 +2254,8 @@ mlx5_flow_stop(struct rte_eth_dev *dev, struct mlx5_flows *list)
                        claim_zero(mlx5_glue->destroy_flow
                                   (flow->frxq[HASH_RXQ_ETH].ibv_flow));
                        flow->frxq[HASH_RXQ_ETH].ibv_flow = NULL;
-                       DEBUG("Flow %p removed", (void *)flow);
+                       DRV_LOG(DEBUG, "port %u flow %p removed",
+                               dev->data->port_id, (void *)flow);
                        /* Next flow. */
                        continue;
                }
@@ -2243,7 +2288,8 @@ mlx5_flow_stop(struct rte_eth_dev *dev, struct mlx5_flows *list)
                        mlx5_hrxq_release(dev, flow->frxq[i].hrxq);
                        flow->frxq[i].hrxq = NULL;
                }
-               DEBUG("Flow %p removed", (void *)flow);
+               DRV_LOG(DEBUG, "port %u flow %p removed", dev->data->port_id,
+                       (void *)flow);
        }
 }
 
@@ -2273,12 +2319,14 @@ mlx5_flow_start(struct rte_eth_dev *dev, struct mlx5_flows *list)
                                (priv->flow_drop_queue->qp,
                                 flow->frxq[HASH_RXQ_ETH].ibv_attr);
                        if (!flow->frxq[HASH_RXQ_ETH].ibv_flow) {
-                               DEBUG("Flow %p cannot be applied",
-                                     (void *)flow);
+                               DRV_LOG(DEBUG,
+                                       "port %u flow %p cannot be applied",
+                                       dev->data->port_id, (void *)flow);
                                rte_errno = EINVAL;
                                return -rte_errno;
                        }
-                       DEBUG("Flow %p applied", (void *)flow);
+                       DRV_LOG(DEBUG, "port %u flow %p applied",
+                               dev->data->port_id, (void *)flow);
                        /* Next flow. */
                        continue;
                }
@@ -2300,8 +2348,9 @@ mlx5_flow_start(struct rte_eth_dev *dev, struct mlx5_flows *list)
                                              (*flow->queues),
                                              flow->queues_n);
                        if (!flow->frxq[i].hrxq) {
-                               DEBUG("Flow %p cannot be applied",
-                                     (void *)flow);
+                               DRV_LOG(DEBUG,
+                                       "port %u flow %p cannot be applied",
+                                       dev->data->port_id, (void *)flow);
                                rte_errno = EINVAL;
                                return -rte_errno;
                        }
@@ -2310,12 +2359,14 @@ flow_create:
                                mlx5_glue->create_flow(flow->frxq[i].hrxq->qp,
                                                       flow->frxq[i].ibv_attr);
                        if (!flow->frxq[i].ibv_flow) {
-                               DEBUG("Flow %p cannot be applied",
-                                     (void *)flow);
+                               DRV_LOG(DEBUG,
+                                       "port %u flow %p cannot be applied",
+                                       dev->data->port_id, (void *)flow);
                                rte_errno = EINVAL;
                                return -rte_errno;
                        }
-                       DEBUG("Flow %p applied", (void *)flow);
+                       DRV_LOG(DEBUG, "port %u flow %p applied",
+                               dev->data->port_id, (void *)flow);
                }
                if (!flow->mark)
                        continue;
@@ -2341,8 +2392,8 @@ mlx5_flow_verify(struct rte_eth_dev *dev)
        int ret = 0;
 
        TAILQ_FOREACH(flow, &priv->flows, next) {
-               DEBUG("%p: flow %p still referenced", (void *)dev,
-                     (void *)flow);
+               DRV_LOG(DEBUG, "port %u flow %p still referenced",
+                       dev->data->port_id, (void *)flow);
                ++ret;
        }
        return ret;
@@ -2613,7 +2664,8 @@ mlx5_fdir_filter_convert(struct rte_eth_dev *dev,
 
        /* Validate queue number. */
        if (fdir_filter->action.rx_queue >= priv->rxqs_n) {
-               ERROR("invalid queue number %d", fdir_filter->action.rx_queue);
+               DRV_LOG(ERR, "port %u invalid queue number %d",
+                       dev->data->port_id, fdir_filter->action.rx_queue);
                rte_errno = EINVAL;
                return -rte_errno;
        }
@@ -2636,7 +2688,9 @@ mlx5_fdir_filter_convert(struct rte_eth_dev *dev,
                };
                break;
        default:
-               ERROR("invalid behavior %d", fdir_filter->action.behavior);
+               DRV_LOG(ERR, "port %u invalid behavior %d",
+                       dev->data->port_id,
+                       fdir_filter->action.behavior);
                rte_errno = ENOTSUP;
                return -rte_errno;
        }
@@ -2772,7 +2826,8 @@ mlx5_fdir_filter_convert(struct rte_eth_dev *dev,
                };
                break;
        default:
-               ERROR("invalid flow type%d", fdir_filter->input.flow_type);
+               DRV_LOG(ERR, "port %u invalid flow type%d",
+                       dev->data->port_id, fdir_filter->input.flow_type);
                rte_errno = ENOTSUP;
                return -rte_errno;
        }
@@ -2821,7 +2876,8 @@ mlx5_fdir_filter_add(struct rte_eth_dev *dev,
                                     attributes.items, attributes.actions,
                                     &error);
        if (flow) {
-               DEBUG("FDIR created %p", (void *)flow);
+               DRV_LOG(DEBUG, "port %u FDIR created %p", dev->data->port_id,
+                       (void *)flow);
                return 0;
        }
        return -rte_errno;
@@ -3015,8 +3071,8 @@ mlx5_fdir_ctrl_func(struct rte_eth_dev *dev, enum rte_filter_op filter_op,
                return 0;
        if (fdir_mode != RTE_FDIR_MODE_PERFECT &&
            fdir_mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
-               ERROR("%p: flow director mode %d not supported",
-                     (void *)dev, fdir_mode);
+               DRV_LOG(ERR, "port %u flow director mode %d not supported",
+                       dev->data->port_id, fdir_mode);
                rte_errno = EINVAL;
                return -rte_errno;
        }
@@ -3034,7 +3090,8 @@ mlx5_fdir_ctrl_func(struct rte_eth_dev *dev, enum rte_filter_op filter_op,
                mlx5_fdir_info_get(dev, arg);
                break;
        default:
-               DEBUG("%p: unknown operation %u", (void *)dev, filter_op);
+               DRV_LOG(DEBUG, "port %u unknown operation %u",
+                       dev->data->port_id, filter_op);
                rte_errno = EINVAL;
                return -rte_errno;
        }
@@ -3073,8 +3130,8 @@ mlx5_dev_filter_ctrl(struct rte_eth_dev *dev,
        case RTE_ETH_FILTER_FDIR:
                return mlx5_fdir_ctrl_func(dev, filter_op, arg);
        default:
-               ERROR("%p: filter type (%d) not supported",
-                     (void *)dev, filter_type);
+               DRV_LOG(ERR, "port %u filter type (%d) not supported",
+                       dev->data->port_id, filter_type);
                rte_errno = ENOTSUP;
                return -rte_errno;
        }