39 uint8_t RSS_HKEY[] = {
40 0x6D, 0x5A, 0x6D, 0x5A, 0x6D, 0x5A, 0x6D, 0x5A, 0x6D, 0x5A, 0x6D, 0x5A, 0x6D, 0x5A, 0x6D, 0x5A,
41 0x6D, 0x5A, 0x6D, 0x5A, 0x6D, 0x5A, 0x6D, 0x5A, 0x6D, 0x5A, 0x6D, 0x5A, 0x6D, 0x5A, 0x6D, 0x5A,
42 0x6D, 0x5A, 0x6D, 0x5A, 0x6D, 0x5A, 0x6D, 0x5A,
43 0x6D, 0x5A, 0x6D, 0x5A, 0x6D, 0x5A, 0x6D, 0x5A, 0x6D, 0x5A, 0x6D, 0x5A,
58 struct rte_flow_action_rss DPDKInitRSSAction(struct rte_eth_rss_conf rss_conf, int nb_rx_queues,
59 uint16_t *queues,
enum rte_eth_hash_function func,
bool set_key)
61 struct rte_flow_action_rss rss_action_conf = { 0 };
62 rss_action_conf.func = func;
63 rss_action_conf.level = 0;
66 rss_action_conf.key = rss_conf.rss_key;
67 rss_action_conf.key_len = rss_conf.rss_key_len;
69 rss_action_conf.key = NULL;
70 rss_action_conf.key_len = 0;
73 if (nb_rx_queues != 0) {
74 for (
int i = 0; i < nb_rx_queues; ++i)
77 rss_action_conf.queue = queues;
79 rss_action_conf.queue = NULL;
81 rss_action_conf.queue_num = nb_rx_queues;
83 return rss_action_conf;
96 int DPDKCreateRSSFlowGeneric(
97 int port_id,
const char *port_name,
struct rte_flow_action_rss rss_conf)
99 struct rte_flow_attr attr = { 0 };
100 struct rte_flow_action action[] = { { 0 }, { 0 } };
101 struct rte_flow_error flow_error = { 0 };
102 struct rte_flow_item pattern[] = { { 0 }, { 0 } };
104 rss_conf.types = RTE_ETH_RSS_IPV4 | RTE_ETH_RSS_IPV6;
107 action[0].type = RTE_FLOW_ACTION_TYPE_RSS;
108 action[0].conf = &rss_conf;
109 action[1].type = RTE_FLOW_ACTION_TYPE_END;
111 pattern[0].type = RTE_FLOW_ITEM_TYPE_ETH;
112 pattern[1].type = RTE_FLOW_ITEM_TYPE_END;
114 struct rte_flow *flow = rte_flow_create(port_id, &attr, pattern, action, &flow_error);
116 SCLogError(
"%s: rte_flow rule creation error: %s", port_name, flow_error.message);
117 int ret = rte_flow_validate(port_id, &attr, pattern, action, &flow_error);
118 SCLogError(
"%s: rte_flow rule validation error: %s, errmsg: %s", port_name,
119 rte_strerror(-ret), flow_error.message);
122 SCLogDebug(
"%s: rte_flow rule created", port_name);
141 int DPDKCreateRSSFlow(
int port_id,
const char *port_name,
struct rte_flow_action_rss rss_conf,
142 uint64_t rss_type,
struct rte_flow_item *pattern)
144 struct rte_flow_attr attr = { 0 };
145 struct rte_flow_action action[] = { { 0 }, { 0 } };
146 struct rte_flow_error flow_error = { 0 };
148 rss_conf.types = rss_type;
151 action[0].type = RTE_FLOW_ACTION_TYPE_RSS;
152 action[0].conf = &rss_conf;
153 action[1].type = RTE_FLOW_ACTION_TYPE_END;
155 struct rte_flow *flow = rte_flow_create(port_id, &attr, pattern, action, &flow_error);
157 SCLogError(
"%s: rte_flow rule creation error: %s", port_name, flow_error.message);
158 int ret = rte_flow_validate(port_id, &attr, pattern, action, &flow_error);
159 SCLogError(
"%s: rte_flow rule validation error: %s, errmsg: %s", port_name,
160 rte_strerror(-ret), flow_error.message);
163 SCLogDebug(
"%s: rte_flow rule created", port_name);
180 int DPDKSetRSSFlowQueues(
int port_id,
const char *port_name,
struct rte_flow_action_rss rss_conf)
182 struct rte_flow_attr attr = { 0 };
183 struct rte_flow_item pattern[] = { { 0 } };
184 struct rte_flow_action action[] = { { 0 }, { 0 } };
185 struct rte_flow_error flow_error = { 0 };
190 pattern[0].type = RTE_FLOW_ITEM_TYPE_END;
191 action[0].type = RTE_FLOW_ACTION_TYPE_RSS;
192 action[0].conf = &rss_conf;
193 action[1].type = RTE_FLOW_ACTION_TYPE_END;
195 struct rte_flow *flow = rte_flow_create(port_id, &attr, pattern, action, &flow_error);
197 SCLogError(
"%s: rte_flow rule creation error: %s", port_name, flow_error.message);
198 int ret = rte_flow_validate(port_id, &attr, pattern, action, &flow_error);
199 SCLogError(
"%s: rte_flow rule validation error: %s, errmsg: %s", port_name,
200 rte_strerror(-ret), flow_error.message);
203 SCLogDebug(
"%s: rte_flow rule created", port_name);