* DPDK callback to close the device. * * Destroy all queues and objects, free memory. * * @param dev * Pointer to Ethernet device structure. */
| 2219 | * Pointer to Ethernet device structure. |
| 2220 | */ |
| 2221 | int |
| 2222 | mlx5_dev_close(struct rte_eth_dev *dev) |
| 2223 | { |
| 2224 | struct mlx5_priv *priv = dev->data->dev_private; |
| 2225 | unsigned int i; |
| 2226 | int ret; |
| 2227 | |
| 2228 | if (rte_eal_process_type() == RTE_PROC_SECONDARY) { |
| 2229 | /* Check if process_private released. */ |
| 2230 | if (!dev->process_private) |
| 2231 | return 0; |
| 2232 | mlx5_tx_uar_uninit_secondary(dev); |
| 2233 | mlx5_proc_priv_uninit(dev); |
| 2234 | rte_eth_dev_release_port(dev); |
| 2235 | return 0; |
| 2236 | } |
| 2237 | if (!priv->sh) |
| 2238 | return 0; |
| 2239 | if (priv->shared_refcnt) { |
| 2240 | DRV_LOG(ERR, "port %u is shared host in use (%u)", |
| 2241 | dev->data->port_id, priv->shared_refcnt); |
| 2242 | rte_errno = EBUSY; |
| 2243 | return -EBUSY; |
| 2244 | } |
| 2245 | DRV_LOG(DEBUG, "port %u closing device \"%s\"", |
| 2246 | dev->data->port_id, |
| 2247 | ((priv->sh->cdev->ctx != NULL) ? |
| 2248 | mlx5_os_get_ctx_device_name(priv->sh->cdev->ctx) : "")); |
| 2249 | /* |
| 2250 | * If default mreg copy action is removed at the stop stage, |
| 2251 | * the search will return none and nothing will be done anymore. |
| 2252 | */ |
| 2253 | if (priv->sh->config.dv_flow_en != 2) |
| 2254 | mlx5_flow_stop_default(dev); |
| 2255 | mlx5_traffic_disable(dev); |
| 2256 | /* |
| 2257 | * If all the flows are already flushed in the device stop stage, |
| 2258 | * then this will return directly without any action. |
| 2259 | */ |
| 2260 | mlx5_flow_list_flush(dev, MLX5_FLOW_TYPE_GEN, true); |
| 2261 | mlx5_action_handle_flush(dev); |
| 2262 | mlx5_flow_meter_flush(dev, NULL); |
| 2263 | /* Prevent crashes when queues are still in use. */ |
| 2264 | dev->rx_pkt_burst = rte_eth_pkt_burst_dummy; |
| 2265 | dev->tx_pkt_burst = rte_eth_pkt_burst_dummy; |
| 2266 | rte_wmb(); |
| 2267 | /* Disable datapath on secondary process. */ |
| 2268 | mlx5_mp_os_req_stop_rxtx(dev); |
| 2269 | /* Free the eCPRI flex parser resource. */ |
| 2270 | mlx5_flex_parser_ecpri_release(dev); |
| 2271 | mlx5_flex_item_port_cleanup(dev); |
| 2272 | mlx5_indirect_list_handles_release(dev); |
| 2273 | #ifdef HAVE_MLX5_HWS_SUPPORT |
| 2274 | flow_hw_destroy_vport_action(dev); |
| 2275 | /* dr context will be closed after mlx5_os_free_shared_dr. */ |
| 2276 | flow_hw_resource_release(dev); |
| 2277 | flow_hw_clear_port_info(dev); |
| 2278 | #endif |
no test coverage detected