Lines Matching full:io
34 * Provide IO object allocation.
38 * @defgroup io_alloc IO allocation
46 void ocs_mgmt_io_list(ocs_textbuf_t *textbuf, void *io);
47 void ocs_mgmt_io_get_all(ocs_textbuf_t *textbuf, void *io);
48 int ocs_mgmt_io_get(ocs_textbuf_t *textbuf, char *parent, char *name, void *io);
57 * @brief IO pool.
59 * Structure encapsulating a pool of IO objects.
65 ocs_lock_t lock; /* IO pool lock */
71 * @brief Create a pool of IO objects.
75 * "slabs" which are a fixed size. It calculates the number of IO objects that
78 * then it grabs each IO object within the slab and adds it to the free list.
79 * Individual command, response and SGL DMA buffers are allocated for each IO.
85 * | IO | |
89 * | IO |
93 * @param num_io Number of IO contexts to allocate.
94 * @param num_sgl Number of SGL entries to allocate for each IO.
107 /* Allocate the IO pool */ in ocs_io_pool_create()
110 ocs_log_err(ocs, "allocate of IO pool failed\n"); in ocs_io_pool_create()
117 /* initialize IO pool lock */ in ocs_io_pool_create()
123 ocs_io_t *io = ocs_pool_get_instance(io_pool->pool, i); in ocs_io_pool_create() local
125 io->tag = i; in ocs_io_pool_create()
126 io->instance_index = i; in ocs_io_pool_create()
127 io->ocs = ocs; in ocs_io_pool_create()
131 rc = ocs_dma_alloc(ocs, &io->cmdbuf, SCSI_CMD_BUF_LENGTH, OCS_MIN_DMA_ALIGNMENT); in ocs_io_pool_create()
140 rc = ocs_dma_alloc(ocs, &io->rspbuf, SCSI_RSP_BUF_LENGTH, OCS_MIN_DMA_ALIGNMENT); in ocs_io_pool_create()
148 io->sgl = ocs_malloc(ocs, sizeof(*io->sgl) * num_sgl, OCS_M_NOWAIT | OCS_M_ZERO); in ocs_io_pool_create()
149 if (io->sgl == NULL) { in ocs_io_pool_create()
154 io->sgl_allocated = num_sgl; in ocs_io_pool_create()
155 io->sgl_count = 0; in ocs_io_pool_create()
157 /* Make IO backend call to initialize IO */ in ocs_io_pool_create()
158 ocs_scsi_tgt_io_init(io); in ocs_io_pool_create()
159 ocs_scsi_ini_io_init(io); in ocs_io_pool_create()
161 rc = ocs_dma_alloc(ocs, &io->els_req, OCS_ELS_REQ_LEN, OCS_MIN_DMA_ALIGNMENT); in ocs_io_pool_create()
168 rc = ocs_dma_alloc(ocs, &io->els_rsp, OCS_ELS_GID_PT_RSP_LEN, OCS_MIN_DMA_ALIGNMENT); in ocs_io_pool_create()
180 * @brief Free IO objects pool
183 * The pool of IO objects are freed.
185 * @param io_pool Pointer to IO pool object.
194 ocs_io_t *io; in ocs_io_pool_free() local
199 io = ocs_pool_get_instance(io_pool->pool, i); in ocs_io_pool_free()
200 if (!io) in ocs_io_pool_free()
202 ocs_scsi_tgt_io_exit(io); in ocs_io_pool_free()
203 ocs_scsi_ini_io_exit(io); in ocs_io_pool_free()
204 if (io->sgl) { in ocs_io_pool_free()
205 ocs_free(ocs, io->sgl, sizeof(*io->sgl) * io->sgl_allocated); in ocs_io_pool_free()
207 ocs_dma_free(ocs, &io->cmdbuf); in ocs_io_pool_free()
208 ocs_dma_free(ocs, &io->rspbuf); in ocs_io_pool_free()
209 ocs_dma_free(ocs, &io->els_req); in ocs_io_pool_free()
210 ocs_dma_free(ocs, &io->els_rsp); in ocs_io_pool_free()
231 * @brief Allocate an object used to track an IO.
233 * @param io_pool Pointer to the IO pool.
240 ocs_io_t *io = NULL; in ocs_io_pool_io_alloc() local
248 if ((io = ocs_pool_get(io_pool->pool)) != NULL) { in ocs_io_pool_io_alloc()
251 io->io_type = OCS_IO_TYPE_MAX; in ocs_io_pool_io_alloc()
252 io->hio_type = OCS_HW_IO_MAX; in ocs_io_pool_io_alloc()
253 io->hio = NULL; in ocs_io_pool_io_alloc()
254 io->transferred = 0; in ocs_io_pool_io_alloc()
255 io->ocs = ocs; in ocs_io_pool_io_alloc()
256 io->timeout = 0; in ocs_io_pool_io_alloc()
257 io->sgl_count = 0; in ocs_io_pool_io_alloc()
258 io->tgt_task_tag = 0; in ocs_io_pool_io_alloc()
259 io->init_task_tag = 0; in ocs_io_pool_io_alloc()
260 io->hw_tag = 0; in ocs_io_pool_io_alloc()
261 io->display_name = "pending"; in ocs_io_pool_io_alloc()
262 io->seq_init = 0; in ocs_io_pool_io_alloc()
263 io->els_req_free = 0; in ocs_io_pool_io_alloc()
264 io->mgmt_functions = &io_mgmt_functions; in ocs_io_pool_io_alloc()
265 io->io_free = 0; in ocs_io_pool_io_alloc()
271 return io; in ocs_io_pool_io_alloc()
276 * @brief Free an object used to track an IO.
278 * @param io_pool Pointer to IO pool object.
279 * @param io Pointer to the IO object.
282 ocs_io_pool_io_free(ocs_io_pool_t *io_pool, ocs_io_t *io) in ocs_io_pool_io_free() argument
292 hio = io->hio; in ocs_io_pool_io_free()
293 io->hio = NULL; in ocs_io_pool_io_free()
294 ocs_pool_put(io_pool->pool, io); in ocs_io_pool_io_free()
300 io->io_free = 1; in ocs_io_pool_io_free()
317 ocs_io_t *io = NULL; in ocs_io_find_tgt_io() local
320 ocs_list_foreach(&node->active_ios, io) in ocs_io_find_tgt_io()
321 if ((io->cmd_tgt && (io->init_task_tag == ox_id)) && in ocs_io_find_tgt_io()
322 ((rx_id == 0xffff) || (io->tgt_task_tag == rx_id))) { in ocs_io_find_tgt_io()
326 return io; in ocs_io_find_tgt_io()
331 * @brief Return IO context given the instance index.
334 * Returns a pointer to the IO context given by the instance index.
337 * @param index IO instance index to return.
339 * @return Returns a pointer to the IO context, or NULL if not found.
350 * @brief Generate IO context ddump data.
352 * The ddump data for an IO context is generated.
355 * @param io Pointer to IO context.
361 ocs_ddump_io(ocs_textbuf_t *textbuf, ocs_io_t *io) in ocs_ddump_io() argument
363 ocs_ddump_section(textbuf, "io", io->instance_index); in ocs_ddump_io()
364 ocs_ddump_value(textbuf, "display_name", "%s", io->display_name); in ocs_ddump_io()
365 ocs_ddump_value(textbuf, "node_name", "%s", io->node->display_name); in ocs_ddump_io()
367 ocs_ddump_value(textbuf, "ref_count", "%d", ocs_ref_read_count(&io->ref)); in ocs_ddump_io()
368 ocs_ddump_value(textbuf, "io_type", "%d", io->io_type); in ocs_ddump_io()
369 ocs_ddump_value(textbuf, "hio_type", "%d", io->hio_type); in ocs_ddump_io()
370 ocs_ddump_value(textbuf, "cmd_tgt", "%d", io->cmd_tgt); in ocs_ddump_io()
371 ocs_ddump_value(textbuf, "cmd_ini", "%d", io->cmd_ini); in ocs_ddump_io()
372 ocs_ddump_value(textbuf, "send_abts", "%d", io->send_abts); in ocs_ddump_io()
373 ocs_ddump_value(textbuf, "init_task_tag", "0x%x", io->init_task_tag); in ocs_ddump_io()
374 ocs_ddump_value(textbuf, "tgt_task_tag", "0x%x", io->tgt_task_tag); in ocs_ddump_io()
375 ocs_ddump_value(textbuf, "hw_tag", "0x%x", io->hw_tag); in ocs_ddump_io()
376 ocs_ddump_value(textbuf, "tag", "0x%x", io->tag); in ocs_ddump_io()
377 ocs_ddump_value(textbuf, "timeout", "%d", io->timeout); in ocs_ddump_io()
378 ocs_ddump_value(textbuf, "tmf_cmd", "%d", io->tmf_cmd); in ocs_ddump_io()
379 ocs_ddump_value(textbuf, "abort_rx_id", "0x%x", io->abort_rx_id); in ocs_ddump_io()
381 ocs_ddump_value(textbuf, "busy", "%d", ocs_io_busy(io)); in ocs_ddump_io()
382 ocs_ddump_value(textbuf, "transferred", "%zu", io->transferred); in ocs_ddump_io()
383 ocs_ddump_value(textbuf, "auto_resp", "%d", io->auto_resp); in ocs_ddump_io()
384 ocs_ddump_value(textbuf, "exp_xfer_len", "%d", io->exp_xfer_len); in ocs_ddump_io()
385 ocs_ddump_value(textbuf, "xfer_req", "%d", io->xfer_req); in ocs_ddump_io()
386 ocs_ddump_value(textbuf, "seq_init", "%d", io->seq_init); in ocs_ddump_io()
388 ocs_ddump_value(textbuf, "alloc_link", "%d", ocs_list_on_list(&io->io_alloc_link)); in ocs_ddump_io()
389 ocs_ddump_value(textbuf, "pending_link", "%d", ocs_list_on_list(&io->io_pending_link)); in ocs_ddump_io()
390 ocs_ddump_value(textbuf, "backend_link", "%d", ocs_list_on_list(&io->link)); in ocs_ddump_io()
392 if (io->hio) { in ocs_ddump_io()
393 ocs_ddump_value(textbuf, "hw_tag", "%#x", io->hio->reqtag); in ocs_ddump_io()
394 ocs_ddump_value(textbuf, "hw_xri", "%#x", io->hio->indicator); in ocs_ddump_io()
395 ocs_ddump_value(textbuf, "hw_type", "%#x", io->hio->type); in ocs_ddump_io()
402 ocs_scsi_ini_ddump(textbuf, OCS_SCSI_DDUMP_IO, io); in ocs_ddump_io()
403 ocs_scsi_tgt_ddump(textbuf, OCS_SCSI_DDUMP_IO, io); in ocs_ddump_io()
405 ocs_ddump_endsection(textbuf, "io", io->instance_index); in ocs_ddump_io()
427 ocs_io_t *io = (ocs_io_t *) object; in ocs_mgmt_io_get() local
429 snprintf(qualifier, sizeof(qualifier), "%s/io[%d]", parent, io->instance_index); in ocs_mgmt_io_get()
437 ocs_mgmt_emit_string(textbuf, MGMT_MODE_RD, "display_name", io->display_name); in ocs_mgmt_io_get()
440 ocs_mgmt_emit_int(textbuf, MGMT_MODE_RD, "init_task_tag", "0x%x", io->init_task_tag); in ocs_mgmt_io_get()
443 ocs_mgmt_emit_int(textbuf, MGMT_MODE_RD, "tgt_task_tag", "0x%x", io->tgt_task_tag); in ocs_mgmt_io_get()
446 ocs_mgmt_emit_int(textbuf, MGMT_MODE_RD, "hw_tag", "0x%x", io->hw_tag); in ocs_mgmt_io_get()
449 ocs_mgmt_emit_int(textbuf, MGMT_MODE_RD, "tag", "0x%x", io->tag); in ocs_mgmt_io_get()
452 ocs_mgmt_emit_int(textbuf, MGMT_MODE_RD, "transferred", "%zu", io->transferred); in ocs_mgmt_io_get()
455 ocs_mgmt_emit_boolean(textbuf, MGMT_MODE_RD, "auto_resp", io->auto_resp); in ocs_mgmt_io_get()
458 ocs_mgmt_emit_int(textbuf, MGMT_MODE_RD, "exp_xfer_len", "%d", io->exp_xfer_len); in ocs_mgmt_io_get()
461 ocs_mgmt_emit_int(textbuf, MGMT_MODE_RD, "xfer_req", "%d", io->xfer_req); in ocs_mgmt_io_get()
472 ocs_io_t *io = (ocs_io_t *) object; in ocs_mgmt_io_get_all() local
474 ocs_mgmt_emit_string(textbuf, MGMT_MODE_RD, "display_name", io->display_name); in ocs_mgmt_io_get_all()
475 ocs_mgmt_emit_int(textbuf, MGMT_MODE_RD, "init_task_tag", "0x%x", io->init_task_tag); in ocs_mgmt_io_get_all()
476 ocs_mgmt_emit_int(textbuf, MGMT_MODE_RD, "tgt_task_tag", "0x%x", io->tgt_task_tag); in ocs_mgmt_io_get_all()
477 ocs_mgmt_emit_int(textbuf, MGMT_MODE_RD, "hw_tag", "0x%x", io->hw_tag); in ocs_mgmt_io_get_all()
478 ocs_mgmt_emit_int(textbuf, MGMT_MODE_RD, "tag", "0x%x", io->tag); in ocs_mgmt_io_get_all()
479 ocs_mgmt_emit_int(textbuf, MGMT_MODE_RD, "transferred", "%zu", io->transferred); in ocs_mgmt_io_get_all()
480 ocs_mgmt_emit_boolean(textbuf, MGMT_MODE_RD, "auto_resp", io->auto_resp); in ocs_mgmt_io_get_all()
481 ocs_mgmt_emit_int(textbuf, MGMT_MODE_RD, "exp_xfer_len", "%d", io->exp_xfer_len); in ocs_mgmt_io_get_all()
482 ocs_mgmt_emit_int(textbuf, MGMT_MODE_RD, "xfer_req", "%d", io->xfer_req); in ocs_mgmt_io_get_all()