| 1833 | } |
| 1834 | |
| 1835 | int32_t |
| 1836 | eh_devs_init(struct eh_conf *conf) |
| 1837 | { |
| 1838 | struct eventmode_conf *em_conf; |
| 1839 | uint16_t port_id; |
| 1840 | int ret; |
| 1841 | |
| 1842 | if (conf == NULL) { |
| 1843 | EH_LOG_ERR("Invalid event helper configuration"); |
| 1844 | return -EINVAL; |
| 1845 | } |
| 1846 | |
| 1847 | if (conf->mode != EH_PKT_TRANSFER_MODE_EVENT) |
| 1848 | return 0; |
| 1849 | |
| 1850 | if (conf->mode_params == NULL) { |
| 1851 | EH_LOG_ERR("Invalid event mode parameters"); |
| 1852 | return -EINVAL; |
| 1853 | } |
| 1854 | |
| 1855 | /* Get eventmode conf */ |
| 1856 | em_conf = conf->mode_params; |
| 1857 | |
| 1858 | /* Eventmode conf would need eth portmask */ |
| 1859 | em_conf->eth_portmask = conf->eth_portmask; |
| 1860 | |
| 1861 | /* Validate the requested config */ |
| 1862 | ret = eh_validate_conf(em_conf); |
| 1863 | if (ret < 0) { |
| 1864 | EH_LOG_ERR("Failed to validate the requested config %d", ret); |
| 1865 | return ret; |
| 1866 | } |
| 1867 | |
| 1868 | /* Display the current configuration */ |
| 1869 | eh_display_conf(conf); |
| 1870 | |
| 1871 | /* Stop eth devices before setting up adapter */ |
| 1872 | RTE_ETH_FOREACH_DEV(port_id) { |
| 1873 | |
| 1874 | /* Use only the ports enabled */ |
| 1875 | if ((conf->eth_portmask & (1 << port_id)) == 0) |
| 1876 | continue; |
| 1877 | |
| 1878 | ret = rte_eth_dev_stop(port_id); |
| 1879 | if (ret != 0) { |
| 1880 | EH_LOG_ERR("Failed to stop port %u, err: %d", |
| 1881 | port_id, ret); |
| 1882 | return ret; |
| 1883 | } |
| 1884 | } |
| 1885 | |
| 1886 | /* Setup eventdev */ |
| 1887 | ret = eh_initialize_eventdev(em_conf); |
| 1888 | if (ret < 0) { |
| 1889 | EH_LOG_ERR("Failed to initialize event dev %d", ret); |
| 1890 | return ret; |
| 1891 | } |
| 1892 |
no test coverage detected