1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2019-2020 Broadcom
14 #include "tf_device.h"
17 #include "tf_resources.h"
21 * The Session module provides session control support. A session is
22 * to the ULP layer known as a session_info instance. The session
23 * private data is the actual session.
26 * - The device and all the resources related to the device.
27 * - Any session sharing between ULP applications
32 #define TF_SESSIONS_MAX 1 /** max # sessions */
33 #define TF_SESSION_ID_INVALID 0xFFFFFFFF /** Invalid Session ID define */
36 * Number of EM entries. Static for now will be removed
37 * when parameter added at a later date. At this stage we
38 * are using fixed size entries so that each stack entry
39 * represents 4 RT (f/n)blocks. So we take the total block
40 * allocation for truflow and divide that by 4.
42 #define TF_SESSION_TOTAL_FN_BLOCKS (1024 * 8) /* 8K blocks */
43 #define TF_SESSION_EM_ENTRY_SIZE 4 /* 4 blocks per entry */
44 #define TF_SESSION_EM_POOL_SIZE \
45 (TF_SESSION_TOTAL_FN_BLOCKS / TF_SESSION_EM_ENTRY_SIZE)
50 * Shared memory containing private TruFlow session information.
51 * Through this structure the session can keep track of resource
52 * allocations and (if so configured) any shadow copy of flow
55 * Memory is assigned to the Truflow instance by way of
56 * tf_open_session. Memory is allocated and owned by i.e. ULP.
58 * Access control to this shared memory is handled by the spin_lock in
62 /** TrueFlow Version. Used to control the structure layout
63 * when sharing sessions. No guarantee that a secondary
64 * process would come from the same version of an executable.
66 struct tf_session_version ver;
68 /** Session ID, allocated by FW on tf_open_session() */
69 union tf_session_id session_id;
72 * String containing name of control channel interface to be
73 * used for this session to communicate with firmware.
75 * ctrl_chan_name will be used as part of a name for any
76 * shared memory allocation.
78 char ctrl_chan_name[TF_SESSION_NAME_MAX];
81 * Boolean controlling the use and availability of shadow
82 * copy. Shadow copy will allow the TruFlow Core to keep track
83 * of resource content on the firmware side without having to
84 * query firmware. Additional private session core_data will
85 * be allocated if this boolean is set to 'true', default
88 * Size of memory depends on the NVM Resource settings for the
94 * Session Reference Count. To keep track of functions per
95 * session the ref_count is incremented. There is also a
96 * parallel TruFlow Firmware ref_count in case the TruFlow
97 * Core goes away without informing the Firmware.
102 struct tf_dev_info dev;
104 /** Table scope array */
105 struct tf_tbl_scope_cb tbl_scopes[TF_NUM_TBL_SCOPE];
110 struct stack em_pool[TF_DIR_MAX];
114 * Session open parameter definition
116 struct tf_session_open_session_parms {
118 * [in] Pointer to the TF open session configuration
120 struct tf_open_session_parms *open_cfg;
124 * Session attach parameter definition
126 struct tf_session_attach_session_parms {
128 * [in] Pointer to the TF attach session configuration
130 struct tf_attach_session_parms *attach_cfg;
134 * Session close parameter definition
136 struct tf_session_close_session_parms {
138 union tf_session_id *session_id;
142 * @page session Session Management
144 * @ref tf_session_open_session
146 * @ref tf_session_attach_session
148 * @ref tf_session_close_session
150 * @ref tf_session_get_session
152 * @ref tf_session_get_device
154 * @ref tf_session_get_fw_session_id
158 * Creates a host session with a corresponding firmware session.
161 * Pointer to TF handle
164 * Pointer to the session open parameters
167 * - (0) if successful.
168 * - (-EINVAL) on failure.
170 int tf_session_open_session(struct tf *tfp,
171 struct tf_session_open_session_parms *parms);
174 * Attaches a previous created session.
177 * Pointer to TF handle
180 * Pointer to the session attach parameters
183 * - (0) if successful.
184 * - (-EINVAL) on failure.
186 int tf_session_attach_session(struct tf *tfp,
187 struct tf_session_attach_session_parms *parms);
190 * Closes a previous created session.
193 * Pointer to TF handle
196 * Pointer to the session close parameters.
199 * - (0) if successful.
200 * - (-EINVAL) on failure.
202 int tf_session_close_session(struct tf *tfp,
203 struct tf_session_close_session_parms *parms);
206 * Looks up the private session information from the TF session info.
209 * Pointer to TF handle
212 * Pointer pointer to the session
215 * - (0) if successful.
216 * - (-EINVAL) on failure.
218 int tf_session_get_session(struct tf *tfp,
219 struct tf_session **tfs);
222 * Looks up the device information from the TF Session.
225 * Pointer to TF handle
228 * Pointer pointer to the device
231 * - (0) if successful.
232 * - (-EINVAL) on failure.
234 int tf_session_get_device(struct tf_session *tfs,
235 struct tf_dev_info **tfd);
238 * Looks up the FW session id of the firmware connection for the
239 * requested TF handle.
242 * Pointer to TF handle
245 * Pointer to the session_id
248 * - (0) if successful.
249 * - (-EINVAL) on failure.
251 int tf_session_get_fw_session_id(struct tf *tfp,
252 uint8_t *fw_session_id);
254 #endif /* _TF_SESSION_H_ */