diff --git a/lib/src/datapath/mt_queue.c b/lib/src/datapath/mt_queue.c index 4b7203890..7fdf727a0 100644 --- a/lib/src/datapath/mt_queue.c +++ b/lib/src/datapath/mt_queue.c @@ -52,14 +52,6 @@ struct mt_rxq_entry* mt_rxq_get(struct mtl_main_impl* impl, enum mtl_port port, } entry->parent = impl; - if (mt_get_user_params(impl)->flags & MTL_FLAG_RX_UDP_PORT_ONLY) { - if (!(flow->flags & MT_RXQ_FLOW_F_NO_IP)) { - info("%s(%d), enable MT_RXQ_FLOW_F_NO_IP as MTL_FLAG_RX_UDP_PORT_ONLY is set\n", - __func__, port); - flow->flags |= MT_RXQ_FLOW_F_NO_IP; - } - } - dbg("%s(%d), flags 0x%x\n", __func__, port, flow->flags); if (mt_pmd_is_kernel_socket(impl, port) || (flow->flags & MT_RXQ_FLOW_F_FORCE_SOCKET)) { entry->rx_socket_q = mt_rx_socket_get(impl, port, flow); diff --git a/lib/src/mt_flow.c b/lib/src/mt_flow.c index 029806fcc..6642c0a27 100644 --- a/lib/src/mt_flow.c +++ b/lib/src/mt_flow.c @@ -90,6 +90,7 @@ static struct rte_flow* rte_rx_flow_create(struct mt_interface* inf, uint16_t q, bool has_port_flow = true; uint16_t port_id = inf->port_id; + enum mtl_port port = inf->port; memset(&error, 0, sizeof(error)); @@ -100,6 +101,13 @@ static struct rte_flow* rte_rx_flow_create(struct mt_interface* inf, uint16_t q, /* no port flow requested */ if (flow->flags & MT_RXQ_FLOW_F_NO_PORT) has_port_flow = false; + if (mt_get_user_params(inf->parent)->flags & MTL_FLAG_RX_UDP_PORT_ONLY) { + if (has_ip_flow) { + info("%s(%d), no ip flow as MTL_FLAG_RX_UDP_PORT_ONLY is set\n", __func__, port); + has_ip_flow = false; + } + } + /* only raw flow can be applied on the hdr split queue */ if (mt_if_hdr_split_pool(inf, q)) { return rte_rx_flow_create_raw(inf, q, flow); @@ -162,7 +170,7 @@ static struct rte_flow* rte_rx_flow_create(struct mt_interface* inf, uint16_t q, ret = rte_flow_validate(port_id, &attr, pattern, action, &error); if (ret < 0) { - err("%s(%d), rte_flow_validate fail %d for queue %d, %s\n", __func__, port_id, ret, q, + err("%s(%d), rte_flow_validate fail %d for queue %d, %s\n", __func__, port, ret, q, mt_string_safe(error.message)); return NULL; } @@ -171,14 +179,18 @@ static struct rte_flow* rte_rx_flow_create(struct mt_interface* inf, uint16_t q, r_flow = rte_flow_create(port_id, &attr, pattern, action, &error); mt_pthread_mutex_unlock(&inf->vf_cmd_mutex); if (!r_flow) { - err("%s(%d), rte_flow_create fail for queue %d, %s\n", __func__, port_id, q, + err("%s(%d), rte_flow_create fail for queue %d, %s\n", __func__, port, q, mt_string_safe(error.message)); return NULL; } - uint8_t* ip = flow->dip_addr; - info("%s(%d), queue %u succ, ip %u.%u.%u.%u port %u\n", __func__, inf->port, q, ip[0], - ip[1], ip[2], ip[3], flow->dst_port); + if (has_ip_flow) { + uint8_t* ip = flow->dip_addr; + info("%s(%d), queue %u succ, ip %u.%u.%u.%u port %u\n", __func__, port, q, ip[0], + ip[1], ip[2], ip[3], flow->dst_port); + } else { + info("%s(%d), queue %u succ, port %u\n", __func__, port, q, flow->dst_port); + } return r_flow; } diff --git a/lib/src/mt_socket.c b/lib/src/mt_socket.c index 49c43d669..e14a13a4f 100644 --- a/lib/src/mt_socket.c +++ b/lib/src/mt_socket.c @@ -390,6 +390,7 @@ int mt_socket_add_flow(struct mtl_main_impl* impl, enum mtl_port port, uint16_t int flow_id = -1; uint8_t start_queue = mt_afxdp_start_queue(impl, port); const char* if_name = mt_kernel_if_name(impl, port); + bool has_ip_flow = true; if (flow->flags & MT_RXQ_FLOW_F_SYS_QUEUE) { err("%s(%d), sys_queue not supported\n", __func__, port); @@ -400,7 +401,17 @@ int mt_socket_add_flow(struct mtl_main_impl* impl, enum mtl_port port, uint16_t return -EIO; } - if (flow->flags & MT_RXQ_FLOW_F_NO_IP) { + /* no ip flow requested */ + if (flow->flags & MT_RXQ_FLOW_F_NO_IP) has_ip_flow = false; + + if (mt_get_user_params(impl)->flags & MTL_FLAG_RX_UDP_PORT_ONLY) { + if (has_ip_flow) { + info("%s(%d), no ip flow as MTL_FLAG_RX_UDP_PORT_ONLY is set\n", __func__, port); + has_ip_flow = false; + } + } + + if (!has_ip_flow) { snprintf(cmd, sizeof(cmd), "ethtool -N %s flow-type udp4 dst-port %u action %u", if_name, flow->dst_port, queue_id + start_queue); } else if (mt_is_multicast_ip(flow->dip_addr)) {