1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright 2020 Mellanox Technologies, Ltd 3 */ 4 5 #include "mlx5_flow_os.h" 6 7 #include <rte_thread.h> 8 9 /* Key of thread specific flow workspace data. */ 10 static rte_thread_key key_workspace; 11 12 int 13 mlx5_flow_os_init_workspace_once(void) 14 { 15 if (rte_thread_key_create(&key_workspace, flow_release_workspace)) { 16 DRV_LOG(ERR, "Can't create flow workspace data thread key."); 17 return -ENOMEM; 18 } 19 return 0; 20 } 21 22 void * 23 mlx5_flow_os_get_specific_workspace(void) 24 { 25 return rte_thread_value_get(key_workspace); 26 } 27 28 int 29 mlx5_flow_os_set_specific_workspace(struct mlx5_flow_workspace *data) 30 { 31 return rte_thread_value_set(key_workspace, data); 32 } 33 34 void 35 mlx5_flow_os_release_workspace(void) 36 { 37 rte_thread_key_delete(key_workspace); 38 } 39