| 1830 | } |
| 1831 | |
| 1832 | int |
| 1833 | init_fwd_streams(void) |
| 1834 | { |
| 1835 | portid_t pid; |
| 1836 | struct rte_port *port; |
| 1837 | streamid_t sm_id, nb_fwd_streams_new; |
| 1838 | queueid_t q; |
| 1839 | |
| 1840 | /* set socket id according to numa or not */ |
| 1841 | RTE_ETH_FOREACH_DEV(pid) { |
| 1842 | port = &ports[pid]; |
| 1843 | if (nb_rxq > port->dev_info.max_rx_queues) { |
| 1844 | fprintf(stderr, |
| 1845 | "Fail: nb_rxq(%d) is greater than max_rx_queues(%d)\n", |
| 1846 | nb_rxq, port->dev_info.max_rx_queues); |
| 1847 | return -1; |
| 1848 | } |
| 1849 | if (nb_txq > port->dev_info.max_tx_queues) { |
| 1850 | fprintf(stderr, |
| 1851 | "Fail: nb_txq(%d) is greater than max_tx_queues(%d)\n", |
| 1852 | nb_txq, port->dev_info.max_tx_queues); |
| 1853 | return -1; |
| 1854 | } |
| 1855 | if (numa_support) { |
| 1856 | if (port_numa[pid] != NUMA_NO_CONFIG) |
| 1857 | port->socket_id = port_numa[pid]; |
| 1858 | else { |
| 1859 | port->socket_id = rte_eth_dev_socket_id(pid); |
| 1860 | |
| 1861 | /* |
| 1862 | * if socket_id is invalid, |
| 1863 | * set to the first available socket. |
| 1864 | */ |
| 1865 | if (check_socket_id(port->socket_id) < 0) |
| 1866 | port->socket_id = socket_ids[0]; |
| 1867 | } |
| 1868 | } |
| 1869 | else { |
| 1870 | if (socket_num == UMA_NO_CONFIG) |
| 1871 | port->socket_id = 0; |
| 1872 | else |
| 1873 | port->socket_id = socket_num; |
| 1874 | } |
| 1875 | } |
| 1876 | |
| 1877 | q = RTE_MAX(nb_rxq, nb_txq); |
| 1878 | if (q == 0) { |
| 1879 | fprintf(stderr, |
| 1880 | "Fail: Cannot allocate fwd streams as number of queues is 0\n"); |
| 1881 | return -1; |
| 1882 | } |
| 1883 | nb_fwd_streams_new = (streamid_t)(nb_ports * q); |
| 1884 | if (nb_fwd_streams_new == nb_fwd_streams) |
| 1885 | return 0; |
| 1886 | /* clear the old */ |
| 1887 | if (fwd_streams != NULL) { |
| 1888 | for (sm_id = 0; sm_id < nb_fwd_streams; sm_id++) { |
| 1889 | if (fwd_streams[sm_id] == NULL) |
no test coverage detected