| 1858 | } |
| 1859 | |
| 1860 | int |
| 1861 | rte_eth_dev_close(uint16_t port_id) |
| 1862 | { |
| 1863 | struct rte_eth_dev *dev; |
| 1864 | int firsterr, binerr; |
| 1865 | int *lasterr = &firsterr; |
| 1866 | |
| 1867 | RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); |
| 1868 | dev = &rte_eth_devices[port_id]; |
| 1869 | |
| 1870 | /* |
| 1871 | * Secondary process needs to close device to release process private |
| 1872 | * resources. But secondary process should not be obliged to wait |
| 1873 | * for device stop before closing ethdev. |
| 1874 | */ |
| 1875 | if (rte_eal_process_type() == RTE_PROC_PRIMARY && |
| 1876 | dev->data->dev_started) { |
| 1877 | RTE_ETHDEV_LOG(ERR, "Cannot close started device (port %u)\n", |
| 1878 | port_id); |
| 1879 | return -EINVAL; |
| 1880 | } |
| 1881 | |
| 1882 | if (*dev->dev_ops->dev_close == NULL) |
| 1883 | return -ENOTSUP; |
| 1884 | *lasterr = (*dev->dev_ops->dev_close)(dev); |
| 1885 | if (*lasterr != 0) |
| 1886 | lasterr = &binerr; |
| 1887 | |
| 1888 | rte_ethdev_trace_close(port_id); |
| 1889 | *lasterr = rte_eth_dev_release_port(dev); |
| 1890 | |
| 1891 | return firsterr; |
| 1892 | } |
| 1893 | |
| 1894 | int |
| 1895 | rte_eth_dev_reset(uint16_t port_id) |