| 1040 | } |
| 1041 | |
| 1042 | static int |
| 1043 | init_flow(uint16_t port_id, uint16_t tcp_port) { |
| 1044 | // struct ff_flow_cfg fcfg = ff_global_cfg.dpdk.flow_cfgs[0]; |
| 1045 | |
| 1046 | // int i; |
| 1047 | // for (i = 0; i < fcfg.nb_port; i++) { |
| 1048 | // if(!create_tcp_flow(fcfg.port_id, fcfg.tcp_ports[i])) { |
| 1049 | // return 0; |
| 1050 | // } |
| 1051 | // } |
| 1052 | |
| 1053 | if(!create_tcp_flow(port_id, tcp_port)) { |
| 1054 | rte_exit(EXIT_FAILURE, "create tcp flow failed\n"); |
| 1055 | return -1; |
| 1056 | } |
| 1057 | |
| 1058 | /* ARP rule */ |
| 1059 | struct rte_flow_attr attr = {.ingress = 1}; |
| 1060 | struct rte_flow_action_queue queue = {.index = 0}; |
| 1061 | |
| 1062 | struct rte_flow_item pattern_[2]; |
| 1063 | struct rte_flow_action action[2]; |
| 1064 | struct rte_flow_item_eth eth_type = {.type = RTE_BE16(0x0806)}; |
| 1065 | struct rte_flow_item_eth eth_mask = { |
| 1066 | .type = RTE_BE16(0xffff) |
| 1067 | }; |
| 1068 | |
| 1069 | memset(pattern_, 0, sizeof(pattern_)); |
| 1070 | memset(action, 0, sizeof(action)); |
| 1071 | |
| 1072 | pattern_[0].type = RTE_FLOW_ITEM_TYPE_ETH; |
| 1073 | pattern_[0].spec = ð_type; |
| 1074 | pattern_[0].mask = ð_mask; |
| 1075 | |
| 1076 | pattern_[1].type = RTE_FLOW_ITEM_TYPE_END; |
| 1077 | |
| 1078 | /* create the action */ |
| 1079 | action[0].type = RTE_FLOW_ACTION_TYPE_QUEUE; |
| 1080 | action[0].conf = &queue; |
| 1081 | action[1].type = RTE_FLOW_ACTION_TYPE_END; |
| 1082 | |
| 1083 | struct rte_flow *flow; |
| 1084 | struct rte_flow_error error; |
| 1085 | /* validate and create the flow rule */ |
| 1086 | if (!rte_flow_validate(port_id, &attr, pattern_, action, &error)) { |
| 1087 | flow = rte_flow_create(port_id, &attr, pattern_, action, &error); |
| 1088 | if (!flow) { |
| 1089 | return port_flow_complain(&error); |
| 1090 | } |
| 1091 | } |
| 1092 | |
| 1093 | return 1; |
| 1094 | } |
| 1095 | |
| 1096 | #endif |
| 1097 |
no test coverage detected