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

Function mlx5_free_shared_dev_ctx

dpdk/drivers/net/mlx5/mlx5.c:1912–1993  ·  view source on GitHub ↗

* Free shared IB device context. Decrement counter and if zero free * all allocated resources and close handles. * * @param[in] sh * Pointer to mlx5_dev_ctx_shared object to free */

Source from the content-addressed store, hash-verified

1910 * Pointer to mlx5_dev_ctx_shared object to free
1911 */
1912void
1913mlx5_free_shared_dev_ctx(struct mlx5_dev_ctx_shared *sh)
1914{
1915 int ret;
1916 int i = 0;
1917
1918 pthread_mutex_lock(&mlx5_dev_ctx_list_mutex);
1919#ifdef RTE_LIBRTE_MLX5_DEBUG
1920 /* Check the object presence in the list. */
1921 struct mlx5_dev_ctx_shared *lctx;
1922
1923 LIST_FOREACH(lctx, &mlx5_dev_ctx_list, next)
1924 if (lctx == sh)
1925 break;
1926 MLX5_ASSERT(lctx);
1927 if (lctx != sh) {
1928 DRV_LOG(ERR, "Freeing non-existing shared IB context");
1929 goto exit;
1930 }
1931#endif
1932 MLX5_ASSERT(sh);
1933 MLX5_ASSERT(sh->refcnt);
1934 /* Secondary process should not free the shared context. */
1935 MLX5_ASSERT(rte_eal_process_type() == RTE_PROC_PRIMARY);
1936 if (--sh->refcnt)
1937 goto exit;
1938 /* Stop watching for mempool events and unregister all mempools. */
1939 if (!sh->cdev->config.mr_mempool_reg_en) {
1940 ret = rte_mempool_event_callback_unregister
1941 (mlx5_dev_ctx_shared_rx_mempool_event_cb, sh);
1942 if (ret == 0)
1943 rte_mempool_walk
1944 (mlx5_dev_ctx_shared_rx_mempool_unregister_cb, sh);
1945 }
1946 /* Remove context from the global device list. */
1947 LIST_REMOVE(sh, next);
1948 /* Release resources on the last device removal. */
1949 if (LIST_EMPTY(&mlx5_dev_ctx_list)) {
1950 mlx5_os_net_cleanup();
1951 mlx5_flow_os_release_workspace();
1952 }
1953 pthread_mutex_unlock(&mlx5_dev_ctx_list_mutex);
1954 if (sh->flex_parsers_dv) {
1955 mlx5_list_destroy(sh->flex_parsers_dv);
1956 sh->flex_parsers_dv = NULL;
1957 }
1958 /*
1959 * Ensure there is no async event handler installed.
1960 * Only primary process handles async device events.
1961 **/
1962 mlx5_flow_counters_mng_close(sh);
1963 if (sh->ct_mng)
1964 mlx5_flow_aso_ct_mng_close(sh);
1965 if (sh->aso_age_mng) {
1966 mlx5_flow_aso_age_mng_close(sh);
1967 sh->aso_age_mng = NULL;
1968 }
1969 if (sh->mtrmng)

Callers 3

mlx5_dev_closeFunction · 0.85
mlx5_dev_spawnFunction · 0.85
mlx5_dev_spawnFunction · 0.85

Calls 15

pthread_mutex_lockFunction · 0.85
rte_eal_process_typeFunction · 0.85
rte_mempool_walkFunction · 0.85
pthread_mutex_unlockFunction · 0.85
mlx5_list_destroyFunction · 0.85
mlx5_flow_ipool_destroyFunction · 0.85
mlx5_rxtx_uars_releaseFunction · 0.85

Tested by

no test coverage detected