| 946 | } |
| 947 | |
| 948 | static int |
| 949 | create_tcp_flow(uint16_t port_id, uint16_t tcp_port) { |
| 950 | struct rte_flow_attr attr = {.ingress = 1}; |
| 951 | struct ff_port_cfg *pconf = &ff_global_cfg.dpdk.port_cfgs[port_id]; |
| 952 | int nb_queues = pconf->nb_lcores; |
| 953 | uint16_t queue[RTE_MAX_QUEUES_PER_PORT]; |
| 954 | int i = 0, j = 0; |
| 955 | for (i = 0, j = 0; i < nb_queues; ++i) |
| 956 | queue[j++] = i; |
| 957 | struct rte_flow_action_rss rss = { |
| 958 | .types = RTE_ETH_RSS_NONFRAG_IPV4_TCP, |
| 959 | .key_len = rsskey_len, |
| 960 | .key = rsskey, |
| 961 | .queue_num = j, |
| 962 | .queue = queue, |
| 963 | }; |
| 964 | |
| 965 | struct rte_eth_dev_info dev_info; |
| 966 | int ret = rte_eth_dev_info_get(port_id, &dev_info); |
| 967 | if (ret != 0) |
| 968 | rte_exit(EXIT_FAILURE, "Error during getting device (port %u) info: %s\n", port_id, strerror(-ret)); |
| 969 | |
| 970 | struct rte_flow_item pattern[3]; |
| 971 | struct rte_flow_action action[2]; |
| 972 | struct rte_flow_item_tcp tcp_spec; |
| 973 | struct rte_flow_item_tcp tcp_mask = { |
| 974 | .hdr = { |
| 975 | .src_port = RTE_BE16(0x0000), |
| 976 | .dst_port = RTE_BE16(0xffff), |
| 977 | }, |
| 978 | }; |
| 979 | struct rte_flow_error error; |
| 980 | |
| 981 | memset(pattern, 0, sizeof(pattern)); |
| 982 | memset(action, 0, sizeof(action)); |
| 983 | |
| 984 | /* set the dst ipv4 packet to the required value */ |
| 985 | pattern[0].type = RTE_FLOW_ITEM_TYPE_IPV4; |
| 986 | |
| 987 | memset(&tcp_spec, 0, sizeof(struct rte_flow_item_tcp)); |
| 988 | tcp_spec.hdr.dst_port = rte_cpu_to_be_16(tcp_port); |
| 989 | pattern[1].type = RTE_FLOW_ITEM_TYPE_TCP; |
| 990 | pattern[1].spec = &tcp_spec; |
| 991 | pattern[1].mask = &tcp_mask; |
| 992 | |
| 993 | /* end the pattern array */ |
| 994 | pattern[2].type = RTE_FLOW_ITEM_TYPE_END; |
| 995 | |
| 996 | /* create the action */ |
| 997 | action[0].type = RTE_FLOW_ACTION_TYPE_RSS; |
| 998 | action[0].conf = &rss; |
| 999 | action[1].type = RTE_FLOW_ACTION_TYPE_END; |
| 1000 | |
| 1001 | struct rte_flow *flow; |
| 1002 | /* validate and create the flow rule */ |
| 1003 | if (!rte_flow_validate(port_id, &attr, pattern, action, &error)) { |
| 1004 | flow = rte_flow_create(port_id, &attr, pattern, action, &error); |
| 1005 | if (!flow) { |
no test coverage detected