MCPcopy Create free account
hub / github.com/F-Stack/f-stack / create_ipip_flow

Function create_ipip_flow

lib/ff_dpdk_if.c:1099–1207  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1097
1098#ifdef FF_FLOW_IPIP
1099static int
1100create_ipip_flow(uint16_t port_id) {
1101 struct rte_flow_attr attr = {.ingress = 1};
1102 struct ff_port_cfg *pconf = &ff_global_cfg.dpdk.port_cfgs[port_id];
1103 int nb_queues = pconf->nb_lcores;
1104 uint16_t queue[RTE_MAX_QUEUES_PER_PORT];
1105 // 1. Queue configuration check
1106 if (nb_queues > RTE_MAX_QUEUES_PER_PORT) {
1107 rte_exit(EXIT_FAILURE, "Queue count exceeds limit (%d > %d)\n",
1108 nb_queues, RTE_MAX_QUEUES_PER_PORT);
1109 }
1110 for (int i = 0; i < nb_queues; i++)
1111 queue[i] = i;
1112
1113 // 2. Get device info and check return value
1114 struct rte_eth_dev_info dev_info;
1115 int ret = rte_eth_dev_info_get(port_id, &dev_info);
1116 if (ret != 0) {
1117 rte_exit(EXIT_FAILURE, "Error during getting device (port %u) info: %s\n",
1118 port_id, strerror(-ret));
1119 }
1120 // 3. RSS config - key: set inner hash
1121 struct rte_flow_action_rss rss = {
1122 .func = RTE_ETH_HASH_FUNCTION_DEFAULT,
1123 .level = 2, // inner encapsulation layer RSS - hash based on inner protocol
1124 .types = RTE_ETH_RSS_NONFRAG_IPV4_TCP, // inner IPv4+TCP hash
1125 .key_len = rsskey_len,
1126 .key = rsskey,
1127 .queue_num = nb_queues,
1128 .queue = queue,
1129 };
1130 // 4. Hardware capability check and fallback handling
1131 if (!(dev_info.flow_type_rss_offloads & RTE_ETH_RSS_NONFRAG_IPV4_TCP)) {
1132 ff_log(FF_LOG_WARNING, FF_LOGTYPE_FSTACK_LIB, "I'm three,Warning: inner TCP RSS is not supported, falling back to outer RSS.\n");
1133 rss.level = 0; // fallback to outer RSS
1134 rss.types = RTE_ETH_FLOW_IPV4; // update to outer protocol type
1135 }
1136
1137 // 5. Outer IPv4 matches IPIP protocol
1138 struct rte_flow_item_ipv4 outer_ipv4_spec = {
1139 .hdr = {
1140 .next_proto_id = IPPROTO_IPIP
1141 }
1142 };
1143 struct rte_flow_item_ipv4 outer_ipv4_mask = {
1144 .hdr = {
1145 .next_proto_id = 0xFF
1146 }
1147 };
1148
1149 // 6. Pattern chain definition - match inner TCP to enable inner RSS
1150 struct rte_flow_item pattern[] = {
1151 // Outer Ethernet header (wildcard)
1152 {
1153 .type = RTE_FLOW_ITEM_TYPE_ETH,
1154 .spec = NULL,
1155 .mask = NULL
1156 },

Callers 1

ff_dpdk_initFunction · 0.85

Calls 5

rte_exitFunction · 0.85
rte_eth_dev_info_getFunction · 0.85
ff_logFunction · 0.85
rte_flow_validateFunction · 0.85
rte_flow_createFunction · 0.85

Tested by

no test coverage detected