EM-ODP 4.4.0
Event Machine on ODP
Loading...
Searching...
No Matches
em_hook_types.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2015, Nokia Solutions and Networks
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * * Neither the name of the copyright holder nor the names of its
15 * contributors may be used to endorse or promote products derived
16 * from this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31/**
32 * @file
33 * EM internal API hook types & definitions
34 *
35 */
36
37#ifndef EM_HOOK_TYPES_H_
38#define EM_HOOK_TYPES_H_
39
40#include <odp_api.h>
41
42#include <event_machine.h>
44
45#ifdef __cplusplus
46extern "C" {
47#endif
48
49/* Max number of API-callback hook arrays */
50#define API_HOOKS_MAX_TBL_SIZE 255
51
52/* EM API hook function types */
53#define ALLOC_HOOK 1
54#define FREE_HOOK 2
55#define SEND_HOOK 3
56/* Dispatcher callback function types */
57#define DISPATCH_CALLBACK_ENTER 4
58#define DISPATCH_CALLBACK_EXIT 5
59/* Idle hook function types */
60#define TO_IDLE_HOOK 6
61#define TO_ACTIVE_HOOK 7
62#define WHILE_IDLE_HOOK 8
63
64typedef void (*void_hook_t)(void);
65
66typedef union {
70 em_dispatch_enter_func_t disp_enter;
75 void_hook_t void_hook;
76} hook_fn_t;
77
78/**
79 * Table for storing API-callback hook function pointers.
80 */
81typedef struct {
82 /* Hook function table */
84 /* Pad size to a multiple of cache line size */
85 void *end[0] ENV_CACHE_LINE_ALIGNED;
87
88COMPILE_TIME_ASSERT(sizeof(hook_tbl_t) == ENV_CACHE_LINE_SIZE,
89 HOOK_ALIGNMENT_ERROR);
90
91/**
92 * API-callback hook functions (table of tables)
93 */
94typedef struct {
95 /** Storage for multiple hook function tables */
96 hook_tbl_t hook_tbl_storage[API_HOOKS_MAX_TBL_SIZE];
97 /** Callback table edit lock */
98 odp_ticketlock_t lock;
99 /** Index of the current active callback table */
100 int idx;
101 /* Pad size to a multiple of cache line size */
102 void *end[0] ENV_CACHE_LINE_ALIGNED;
104
105COMPILE_TIME_ASSERT(sizeof(hook_storage_t) % ENV_CACHE_LINE_SIZE == 0,
106 HOOK_STORAGE_ALIGNMENT_ERROR);
107
108COMPILE_TIME_ASSERT(sizeof(hook_storage_t) / ENV_CACHE_LINE_SIZE ==
109 API_HOOKS_MAX_TBL_SIZE + 1, HOOK_STORAGE_SIZE_ERROR);
110
111#ifdef __cplusplus
112}
113#endif
114
115#endif /* EM_HOOK_TYPES_H_ */
#define EM_CALLBACKS_MAX
void(* em_dispatch_enter_func_t)(em_eo_t eo, void **eo_ctx, em_event_t events[], int num, em_queue_t *queue, void **q_ctx)
void(* em_dispatch_exit_func_t)(em_eo_t eo)
void(* em_idle_hook_while_idle_t)(void)
void(* em_idle_hook_to_active_t)(void)
void(* em_api_hook_send_t)(const em_event_t events[], int num, em_queue_t queue, em_event_group_t event_group)
void(* em_idle_hook_to_idle_t)(uint64_t to_idle_delay_ns)
void(* em_api_hook_alloc_t)(const em_event_t events[], int num_act, int num_req, uint32_t size, em_event_type_t type, em_pool_t pool)
void(* em_api_hook_free_t)(const em_event_t events[], int num)
odp_ticketlock_t lock