Home | History | Annotate | Download | only in proxy

Lines Matching defs:proxy

23 #define MODULE_TAG                      PROXY
48 /* ...execute proxy command synchronously */
49 static inline int xf_proxy_cmd_exec(xf_proxy_t *proxy, xf_user_msg_t *msg)
53 /* ...send command to remote proxy */
57 XF_CHK_ERR((m.address = xf_proxy_b2a(proxy, msg->buffer)) != XF_PROXY_BADADDR, -EINVAL);
59 /* ...pass command to remote proxy */
60 XF_CHK_API(xf_ipc_send(&proxy->ipc, &m, msg->buffer));
62 /* ...wait for response reception indication from proxy thread */
63 XF_CHK_API(xf_proxy_response_get(proxy, &m));
69 XF_CHK_ERR((msg->buffer = xf_proxy_a2b(proxy, m.address)) != (void *)-1, -EBADFD);
71 TRACE(EXEC, _b("proxy[%p]: command done: [%08x:%p:%u]"), proxy, msg->opcode, msg->buffer, msg->length);
78 static inline int xf_proxy_cmd(xf_proxy_t *proxy, xf_handle_t *handle, xf_user_msg_t *m)
83 msg.id = __XF_MSG_ID(__XF_AP_CLIENT(proxy->core, handle->client), m->id);
88 XF_CHK_ERR((msg.address = xf_proxy_b2a(proxy, m->buffer)) != XF_PROXY_BADADDR, -EINVAL);
91 return XF_CHK_API(xf_ipc_send(&proxy->ipc, &msg, m->buffer));
96 static inline u32 xf_client_alloc(xf_proxy_t *proxy, xf_handle_t *handle)
100 if ((client = proxy->cmap[0].next) != 0)
103 proxy->cmap[0].next = proxy->cmap[client].next;
106 handle->client = client, proxy->cmap[client].handle = handle;
113 static inline void xf_client_free(xf_proxy_t *proxy, xf_handle_t *handle)
118 proxy->cmap[client].next = proxy->cmap[0].next;
121 proxy->cmap[0].next = client;
125 static inline xf_handle_t * xf_client_lookup(xf_proxy_t *proxy, u32 client)
131 if (proxy->cmap[client].next < XF_CFG_PROXY_MAX_CLIENTS)
134 return proxy->cmap[client].handle;
138 static inline int xf_client_register(xf_proxy_t *proxy, xf_handle_t *handle, xf_id_t id, u32 core)
143 /* ...set session-id: source is local proxy, destination is remote proxy */
144 msg.id = __XF_MSG_ID(__XF_AP_PROXY(proxy->core), __XF_DSP_PROXY(core));
153 XF_CHK_API(xf_proxy_cmd_exec(proxy, &msg));
166 /* ...unregister client from remote proxy */
167 static inline int xf_client_unregister(xf_proxy_t *proxy, xf_handle_t *handle)
172 BUG(proxy->cmap[handle->client].handle != handle, _x("Invalid handle: %p"), handle);
175 msg.id = __XF_MSG_ID(__XF_AP_PROXY(proxy->core), handle->id);
180 /* ...synchronously execute command on remote proxy */
181 XF_CHK_API(xf_proxy_cmd_exec(proxy, &msg));
192 static inline int xf_proxy_buffer_alloc(xf_proxy_t *proxy, u32 length, void **buffer)
194 u32 core = proxy->core;
203 /* ...synchronously execute command on remote proxy */
204 XF_CHK_API(xf_proxy_cmd_exec(proxy, &msg));
215 TRACE(MEM, _b("proxy-%u: allocated [%p:%u]"), core, *buffer, length);
221 static inline int xf_proxy_buffer_free(xf_proxy_t *proxy, void *buffer, u32 length)
223 u32 core = proxy->core;
232 /* ...synchronously execute command on remote proxy */
233 XF_CHK_API(xf_proxy_cmd_exec(proxy, &msg));
238 TRACE(MEM, _b("proxy-%u: free [%p:%u]"), core, buffer, length);
244 * Proxy interface asynchronous receiving thread
249 xf_proxy_t *proxy = arg;
259 /* ...wait for response from remote proxy (infinite timeout) */
260 if ((r = xf_ipc_wait(&proxy->ipc, 0)) < 0)
264 while ((r = xf_ipc_recv(&proxy->ipc, &m, &msg.buffer)) == sizeof(m))
267 BUG(XF_MSG_DST_CORE(m.id) != proxy->core, _x("Invalid session-id: %X (core=%u)"), m.id, proxy->core);
280 /* ...put proxy response to local IPC queue */
281 xf_proxy_response_put(proxy, &m);
283 else if ((client = xf_client_lookup(proxy, XF_AP_CLIENT(m.id))) != NULL)
298 TRACE(ERROR, _x("abnormal proxy[%p] thread termination: %d"), proxy, r);
303 TRACE(INIT, _b("IPC proxy[%p] thread terminated: %d"), proxy, r);
309 * HiFi proxy API
312 /* ...open HiFi proxy */
313 int xf_proxy_init(xf_proxy_t *proxy, u32 core, void *p_shmem)
318 /* ...initialize proxy lock */
319 __xf_lock_init(&proxy->lock);
321 /* ...open proxy IPC interface */
322 XF_CHK_API(xf_ipc_open(&proxy->ipc, core, p_shmem));
324 /* ...save proxy core - hmm, too much core identifiers - tbd */
325 proxy->core = core;
330 proxy->cmap[i].next = i + 1;
334 proxy->cmap[i].next = 0;
337 if ((r = __xf_thread_create(&proxy->thread, xf_proxy_thread, proxy)) < 0)
340 xf_ipc_close(&proxy->ipc, core);
344 TRACE(INIT, _b("proxy-%u[%p] opened"), core, proxy);
349 /* ...close proxy handle */
350 void xf_proxy_close(xf_proxy_t *proxy)
352 u32 core = proxy->core;
354 /* ...terminate proxy thread */
355 __xf_thread_destroy(&proxy->thread);
357 /* ...close proxy IPC interface */
358 xf_ipc_close(&proxy->ipc, core);
360 TRACE(INIT, _b("proxy-%u[%p] closed"), core, proxy);
368 int xf_open(xf_proxy_t *proxy, xf_handle_t *handle, xf_id_t id, u32 core, xf_response_cb response)
372 /* ...retrieve auxiliary control buffer from proxy - need I */
373 XF_CHK_ERR(handle->aux = xf_buffer_get(proxy->aux), -EBUSY);
379 xf_proxy_lock(proxy);
382 if (xf_client_alloc(proxy, handle) == 0)
387 else if ((r = xf_client_register(proxy, handle, id, core)) < 0)
390 xf_client_free(proxy, handle);
393 xf_proxy_unlock(proxy);
398 /* ...operation failed; return buffer back to proxy pool */
405 handle->proxy = proxy;
416 xf_proxy_t *proxy = handle->proxy;
422 /* ...acquire global proxy lock */
423 xf_proxy_lock(proxy);
425 /* ...unregister component from remote DSP proxy (ignore result code) */
426 (void) xf_client_unregister(proxy, handle);
429 xf_client_free(proxy, handle);
431 /* ...release global proxy lock */
432 xf_proxy_unlock(proxy);
440 /* ...wipe out proxy pointer */
441 handle->proxy = NULL;
449 xf_proxy_t *proxy = src->proxy;
454 /* ...sanity checks - proxy pointers are same */
455 XF_CHK_ERR(proxy == dst->proxy, -EINVAL);
461 XF_CHK_ERR(b = xf_buffer_get(proxy->aux), -EBUSY);
474 msg.id = __XF_MSG_ID(__XF_AP_PROXY(proxy->core), __XF_PORT_SPEC2(src->id, src_port));
480 XF_CHK_API(xf_proxy_cmd_exec(proxy, &msg));
482 /* ...return buffer to proxy */
497 xf_proxy_t *proxy = src->proxy;
504 XF_CHK_ERR(b = xf_buffer_get(proxy->aux), -EBUSY);
513 proxy->core), __XF_PORT_SPEC2(src->id, src_port));
519 if ((r = xf_proxy_cmd_exec(proxy, &msg)) != 0)
535 /* ...return buffer to proxy */
544 xf_proxy_t *proxy = handle->proxy;
548 msg.id = __XF_MSG_ID(__XF_AP_CLIENT(proxy->core, handle->client), __XF_PORT_SPEC2(handle->id, port));
551 XF_CHK_ERR((msg.address = xf_proxy_b2a(proxy, buffer)) != XF_PROXY_BADADDR, -EINVAL);
556 return XF_CHK_API(xf_ipc_send(&proxy->ipc, &msg, buffer));
564 int xf_pool_alloc(xf_proxy_t *proxy, u32 number, u32 length, xf_pool_type_t type, xf_pool_t **pool, s32 id,
586 xf_proxy_lock(proxy);
587 r = xf_proxy_buffer_alloc(proxy, number * length, &p->p);
588 xf_proxy_unlock(proxy);
601 p->proxy = proxy;
620 TRACE(BUFFER, _b("[%p]: pool[%p] created: %u * %u"), proxy, p, p->number, p->length);
631 xf_proxy_t *proxy = pool->proxy;
635 /* ...use global proxy lock for pool operations protection */
636 xf_proxy_lock(proxy);
639 xf_proxy_buffer_free(proxy, pool->p, pool->length * pool->number);
641 /* ...release global proxy lock */
642 xf_proxy_unlock(proxy);
647 TRACE(BUFFER, _b("[%p]::pool[%p] destroyed"), proxy, pool);
655 /* ...use global proxy lock for pool operations protection */
656 xf_proxy_lock(pool->proxy);
667 xf_proxy_unlock(pool->proxy);
677 /* ...use global proxy lock for pool operations protection */
678 xf_proxy_lock(pool->proxy);
685 xf_proxy_unlock(pool->proxy);