Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
Signed-off-by: Frank Du <[email protected]>
  • Loading branch information
frankdjx committed Oct 24, 2023
1 parent 9d03b85 commit 6de82d2
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 14 deletions.
8 changes: 0 additions & 8 deletions lib/src/datapath/mt_queue.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
22 changes: 17 additions & 5 deletions lib/src/mt_flow.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand All @@ -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);
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}

Expand Down
13 changes: 12 additions & 1 deletion lib/src/mt_socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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)) {
Expand Down

0 comments on commit 6de82d2

Please sign in to comment.