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

Function rss_enable

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

* Enable RSS on tap: create TC rules for queuing. * * @param[in, out] pmd * Pointer to private structure. * * @param[in] attr * Pointer to rte_flow to get flow group * * @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

1843 * @return 0 on success, negative value on failure.
1844 */
1845static int rss_enable(struct pmd_internals *pmd,
1846 const struct rte_flow_attr *attr,
1847 struct rte_flow_error *error)
1848{
1849 struct rte_flow *rss_flow = NULL;
1850 struct nlmsg *msg = NULL;
1851 /* 4096 is the maximum number of instructions for a BPF program */
1852 char annotation[64];
1853 int i;
1854 int err = 0;
1855
1856 /* unlimit locked memory */
1857 struct rlimit memlock_limit = {
1858 .rlim_cur = RLIM_INFINITY,
1859 .rlim_max = RLIM_INFINITY,
1860 };
1861 setrlimit(RLIMIT_MEMLOCK, &memlock_limit);
1862
1863 /* Get a new map key for a new RSS rule */
1864 err = bpf_rss_key(KEY_CMD_INIT, NULL);
1865 if (err < 0) {
1866 rte_flow_error_set(
1867 error, EINVAL, RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
1868 "Failed to initialize BPF RSS keys");
1869
1870 return -1;
1871 }
1872
1873 /*
1874 * Create BPF RSS MAP
1875 */
1876 pmd->map_fd = tap_flow_bpf_rss_map_create(sizeof(__u32), /* key size */
1877 sizeof(struct rss_key),
1878 MAX_RSS_KEYS);
1879 if (pmd->map_fd < 0) {
1880 TAP_LOG(ERR,
1881 "Failed to create BPF map (%d): %s",
1882 errno, strerror(errno));
1883 rte_flow_error_set(
1884 error, ENOTSUP, RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
1885 "Kernel too old or not configured "
1886 "to support BPF maps");
1887
1888 return -ENOTSUP;
1889 }
1890
1891 /*
1892 * Add a rule per queue to match reclassified packets and direct them to
1893 * the correct queue.
1894 */
1895 for (i = 0; i < pmd->dev->data->nb_rx_queues; i++) {
1896 pmd->bpf_fd[i] = tap_flow_bpf_cls_q(i);
1897 if (pmd->bpf_fd[i] < 0) {
1898 TAP_LOG(ERR,
1899 "Failed to load BPF section %s for queue %d",
1900 SEC_NAME_CLS_Q, i);
1901 rte_flow_error_set(
1902 error, ENOTSUP, RTE_FLOW_ERROR_TYPE_HANDLE,

Callers 1

priv_flow_processFunction · 0.85

Calls 15

bpf_rss_keyFunction · 0.85
rte_flow_error_setFunction · 0.85
tap_flow_bpf_cls_qFunction · 0.85
rte_zmallocFunction · 0.85
tc_init_msgFunction · 0.85
tap_flow_set_handleFunction · 0.85
tap_nlattr_addFunction · 0.85
tap_nlattr_nested_startFunction · 0.85
tap_nlattr_add32Function · 0.85
snprintfFunction · 0.85
add_actionsFunction · 0.85

Tested by

no test coverage detected