Lines Matching defs:agent

32  * Each agent is registered as a domain service using the libds library,
35 * The control domain sends requests to an agent as messages on the
36 * corresponding domain service (identified by the agent name). All requests
38 * handler function of the agent depending on the type of the message.
67 #define LDMA_MODULE "ldm-agent-daemon"
78 ldma_agent_info_t *info; /* agent information */
102 * Lookup connexion in agent connexion table.
105 ldma_connexion_lookup(ldma_agent_t *agent, ds_hdl_t hdl)
110 ASSERT(MUTEX_HELD(&agent->conn_lock));
111 for (connp = agent->conn, i = 0; i < LDOMS_MAX_DOMAINS; i++, connp++) {
119 * Add connextion to agent connexion table.
122 ldma_connexion_add(ldma_agent_t *agent, ds_hdl_t hdl, ds_domain_hdl_t dhdl,
129 (void) mutex_lock(&agent->conn_lock);
130 for (connp = agent->conn, i = 0; i < LDOMS_MAX_DOMAINS; i++, connp++) {
138 (void) mutex_unlock(&agent->conn_lock);
139 LDMA_INFO("agent %s hdl %llx already exists", agent->info->name,
145 (void) mutex_unlock(&agent->conn_lock);
146 LDMA_INFO("agent %s too many connections", agent->info->name);
150 LDMA_DBG("agent %s adding connection (%x) %llx, %llx, %d.%d",
151 agent->info->name, availp, hdl, dhdl, verp->major, verp->minor);
156 (void) mutex_unlock(&agent->conn_lock);
161 * Delete connexion from agent connexion table.
164 ldma_connexion_delete(ldma_agent_t *agent, ds_hdl_t hdl)
168 (void) mutex_lock(&agent->conn_lock);
169 if ((connp = ldma_connexion_lookup(agent, hdl)) == NULL) {
170 (void) mutex_unlock(&agent->conn_lock);
171 LDMA_INFO("agent %s connection delete failed to find %llx",
172 agent->info->name, hdl);
176 LDMA_DBG("agent %s deleting connection (%x) %llx", agent->info->name,
183 (void) mutex_unlock(&agent->conn_lock);
191 ldma_connexion_init(ldma_agent_t *agent)
196 for (connp = agent->conn, i = 0; i < LDOMS_MAX_DOMAINS; i++, connp++) {
242 * for using the service provided by an agent. An agent will only have one
249 ldma_agent_t *agent = (ldma_agent_t *)arg;
257 agent->info->name, hdl, dhdl, dname, ver->major, ver->minor);
263 if (!ldma_connexion_add(agent, hdl, dhdl, ver)) {
264 LDMA_INFO("agent %s failed to add connection from "
265 "domain %s", agent->info->name, dname);
271 * unregistered and stops using the service provided by an agent.
276 ldma_agent_t *agent = (ldma_agent_t *)arg;
278 LDMA_DBG("%s: UNREGISTER hdl=%llx", agent->info->name, hdl);
280 if (!ldma_connexion_delete(agent, hdl)) {
281 LDMA_INFO("agent %s failed to unregister handle %llx",
282 agent->info->name, hdl);
287 * Agent data callback. This callback is invoked when an agent receives a new
290 * appropriate handler function provided by the agent, depending on the message
296 ldma_agent_t *agent = (ldma_agent_t *)arg;
309 LDMA_INFO("agent %s has ignored message with an invalid "
310 "size of %d bytes", agent->info->name, len);
317 "dlen=%d", agent->info->name, hdl, request->msg_num,
320 (void) mutex_lock(&agent->conn_lock);
321 connp = ldma_connexion_lookup(agent, hdl);
326 (void) mutex_unlock(&agent->conn_lock);
331 "distrusted domain", agent->info->name, hdl);
338 for (i = 0; i < agent->info->nhandlers; i++) {
339 if (agent->info->handlers[i].msg_type == request->msg_type) {
340 handler = &agent->info->handlers[i];
346 /* this type of message is not defined by the agent */
348 agent->info->name, hdl, request->msg_type);
357 "distrusted domain", agent->info->name, hdl);
364 * This type of message is defined by the agent but it
370 agent->info->name, hdl);
375 /* invoke the message handler of the agent */
380 agent->info->name, hdl, status, (void *)reply, reply_dlen);
420 "dlen=%d", agent->info->name, hdl, reply->msg_num,
424 LDMA_ERR("agent %s has failed to send reply for request %llu",
425 agent->info->name, request->msg_num);
433 * Register an agent. Return 0 if the agent was successfully registered.
438 ldma_agent_t *agent;
442 agent = malloc(sizeof (ldma_agent_t));
443 if (agent == NULL)
446 agent->info = agent_info;
447 (void) mutex_init(&agent->conn_lock, USYNC_THREAD, NULL);
448 ldma_connexion_init(agent);
457 ds_ops.cb_arg = agent;
460 LDMA_INFO("agent %s registered", agent_info->name);
466 LDMA_ERR("agent %s has failed to register", agent_info->name);
467 free(agent);
622 /* no agent registered */
623 LDMA_ERR("Unable to register any agent");
670 * forwarded to the agent data callback (ldma_data_cb()) where it