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

Function rss_add_actions

dpdk/drivers/net/tap/tap_flow.c:2078–2171  ·  view source on GitHub ↗

* Add RSS hash calculations and queue selection * * @param[in, out] pmd * Pointer to internal structure. Used to set/get RSS map fd * * @param[in] rss * Pointer to RSS flow actions * * @param[out] error * Pointer to error reporting if not NULL. * * @return 0 on success, negative value on failure */

Source from the content-addressed store, hash-verified

2076 * @return 0 on success, negative value on failure
2077 */
2078static int rss_add_actions(struct rte_flow *flow, struct pmd_internals *pmd,
2079 const struct rte_flow_action_rss *rss,
2080 struct rte_flow_error *error)
2081{
2082 /* 4096 is the maximum number of instructions for a BPF program */
2083 unsigned int i;
2084 int err;
2085 struct rss_key rss_entry = { .hash_fields = 0,
2086 .key_size = 0 };
2087
2088 /* Check supported RSS features */
2089 if (rss->func != RTE_ETH_HASH_FUNCTION_DEFAULT)
2090 return rte_flow_error_set
2091 (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
2092 "non-default RSS hash functions are not supported");
2093 if (rss->level)
2094 return rte_flow_error_set
2095 (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
2096 "a nonzero RSS encapsulation level is not supported");
2097
2098 /* Get a new map key for a new RSS rule */
2099 err = bpf_rss_key(KEY_CMD_GET, &flow->key_idx);
2100 if (err < 0) {
2101 rte_flow_error_set(
2102 error, EINVAL, RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
2103 "Failed to get BPF RSS key");
2104
2105 return -1;
2106 }
2107
2108 /* Update RSS map entry with queues */
2109 rss_entry.nb_queues = rss->queue_num;
2110 for (i = 0; i < rss->queue_num; i++)
2111 rss_entry.queues[i] = rss->queue[i];
2112 rss_entry.hash_fields =
2113 (1 << HASH_FIELD_IPV4_L3_L4) | (1 << HASH_FIELD_IPV6_L3_L4);
2114
2115 /* Add this RSS entry to map */
2116 err = tap_flow_bpf_update_rss_elem(pmd->map_fd,
2117 &flow->key_idx, &rss_entry);
2118
2119 if (err) {
2120 TAP_LOG(ERR,
2121 "Failed to update BPF map entry #%u (%d): %s",
2122 flow->key_idx, errno, strerror(errno));
2123 rte_flow_error_set(
2124 error, ENOTSUP, RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
2125 "Kernel too old or not configured "
2126 "to support BPF maps updates");
2127
2128 return -ENOTSUP;
2129 }
2130
2131
2132 /*
2133 * Load bpf rules to calculate hash for this key_idx
2134 */
2135

Callers 1

priv_flow_processFunction · 0.85

Calls 5

rte_flow_error_setFunction · 0.85
bpf_rss_keyFunction · 0.85
add_actionsFunction · 0.85

Tested by

no test coverage detected