tcm: Add support for BIDI operation and XDWRITE_READ_10 emulation
Subsystems (2)
PATCH v2 1/2 tcm: Add support for BIDI operation and XDWRITE_READ_10 emulation
From: Nicholas Bellinger <[email protected]>
This v2 patch series adds BIDI-COMMANDS support to TCM Core. This
includes the following for struct se_cmd to handle BIDI READ payloads using a new struct se_transport_task->t_mem_bidi_list and struct se_transport_task->t_tasks_se_bidi_num. The model employed is to keep the WRITE payload at struct se_transport_task->t_mem_list, and add a new BIDI READ payload memory list at struct se_transport_task->t_mem_bidi_list.
*) descriptor setup:
This patch adds support for XDWRITEREAD_10 within transport_generic_cmd_sequencer(), and sets up the new struct se_cmd->transport_xor_callback() completion function at transport_xor_callback(). It then updates transport_new_cmd_obj() to handle the BIDI READ case.
It also adds support for DMA_BIDIRECTIONAL to transport_generic_map_mem_to_cmd() to setup struct se_transport_task->t_mem_bidi_list for BIDI READ payloads
*) memory mapping:
This patch updates transport_generic_get_cdb_count() to accept a enum dma_data_direction parameter to handle the BIDI and the existing WRITE/READ cases for SCF_SCSI_DATA_SG_IO_CDB. This patch also updates transport_generic_map_mem_to_cmd() to accept a 'void *mem_bidi_in' and 'u32 se_mem_bidi_num' from BIDI capable TCM fabric modules.
It then updates transport_generic_get_task() and struct se_cmd->transport_get_task() to accept a enum dma_data_direction function parameter.
*) descriptor callback:
For the struct se_cmd callback, it updates transport_generic_complete_ok() to support BIDI-COMMANDS and looks for the new generic struct se_cmd->transport_complete_callback() in transport_generic_cmd_sequencer() to perform the post READ/WRITE XOR emulation. This also includes the additon of transport_memcpy_se_mem_read_contig() used to copy the WRITE scatterlists into a local contigious buffer for the XOR instructions within transport_xor_callback();
*) descriptor release:
Update transport_free_pages() to walk the new T_TASK(cmd)->t_mem_bidi_list (when available) and release struct se_mem and pages.
So far this has been tested with TCM_Loop using BSG w/ userspace code generating BIDI XDWRITE_READ_10 CDBs.
--- drivers/target/target_core_pr.c | 3 +- drivers/target/target_core_transport.c | 278 +++++++++++++++++++++++++++----- include/target/target_core_base.h | 10 +- include/target/target_core_transport.h | 10 +- 4 files changed, 254 insertions(+), 47 deletions(-)
drivers/target/target_core_pr.c +1 -2
@@ -497,8 +497,7 @@ static int core_scsi3_pr_seq_non_holder(* WRITE_EXCLUSIVE_* reservation. */ if ((we) && !(registered_nexus)) { -if ((cmd->data_direction ==DMA_TO_DEVICE ) || - (cmd->data_direction ==DMA_BIDIRECTIONAL )) { +if (cmd->data_direction ==DMA_TO_DEVICE ) {/* * Conflict for write exclusive */
drivers/target/target_core_transport.c +238 -40
445 lines not on this page · raw message
include/target/target_core_base.h +8 -2
@@ -414,11 +414,13 @@ struct se_transport_task {unsigned long long t_task_lba;int t_tasks_failed;int t_tasks_fua; + int t_tasks_bidi:1;u32 t_task_cdbs;u32 t_tasks_check;u32 t_tasks_no;u32 t_tasks_sectors;u32 t_tasks_se_num; +u32 t_tasks_se_bidi_num;u32 t_tasks_sg_chained_no;atomic_t t_fe_count;atomic_t t_se_count;
@@ -447,8 +449,10 @@ struct se_transport_task {struct scatterlist t_tasks_sg_bounce;void *t_task_buf;void *t_task_pt_buf; -struct list_head t_task_list;struct list_head *t_mem_list; +/* Used for BIDI READ */ +struct list_head *t_mem_bidi_list; +struct list_head t_task_list; }____cacheline_aligned ;struct se_task {
@@ -598,7 +602,8 @@ struct se_cmd {u32 (*transport_get_lba)(unsigned char *);unsigned long long (*transport_get_long_lba)(unsigned char *);struct se_task *(*transport_get_task)(struct se_transform_info *, -struct se_cmd *,void *); +struct se_cmd *,void *, +enum dma_data_direction );int (*transport_map_buffers_to_tasks)(struct se_cmd *);void (*transport_map_SG_segments)(struct se_unmap_sg *);void (*transport_passthrough_done)(struct se_cmd *);
@@ -607,6 +612,7 @@ struct se_cmd { struct se_unmap_sg *);void (*transport_split_cdb)(unsigned long long ,u32 *,unsigned char *);void (*transport_wait_for_tasks)(struct se_cmd *,int ,int ); +void (*transport_complete_callback)(struct se_cmd *);void (*callback)(struct se_cmd *cmd,void *callback_arg,int complete_status);void *callback_arg;
include/target/target_core_transport.h +7 -3
@@ -232,6 +232,8 @@ extern void transport_memcpy_write_contig(struct se_cmd *, struct scatterlist *, unsigned char *);extern void transport_memcpy_read_contig (struct se_cmd *,unsigned char *,struct scatterlist *); +extern void transport_memcpy_se_mem_read_contig (struct se_cmd *, +unsigned char *,struct list_head *); extern int transport_generic_passthrough_async(struct se_cmd *cmd, void(*callback)(struct se_cmd *cmd, void *callback_arg, int complete_status),
@@ -242,7 +244,8 @@ extern void transport_generic_complete_ok(struct se_cmd *);extern void transport_free_dev_tasks (struct se_cmd *);extern void transport_release_fe_cmd (struct se_cmd *);extern int transport_generic_remove (struct se_cmd *,int ,int ); -extern int transport_generic_map_mem_to_cmd (struct se_cmd *cmd,void *,u32 ); +extern int transport_generic_map_mem_to_cmd (struct se_cmd *cmd,void *,u32 , +void *,u32 );extern int transport_lun_wait_for_tasks (struct se_cmd *,struct se_lun *);extern int transport_clear_lun_from_sessions (struct se_lun *);extern int transport_check_aborted_status (struct se_cmd *,int );
@@ -271,8 +274,9 @@ extern int transport_map_mem_to_sg(struct se_task *, struct list_head *,extern void transport_do_task_sg_chain (struct se_cmd *);extern u32 transport_generic_get_cdb_count (struct se_cmd *,struct se_transform_info *, -unsigned long long ,u32 ,struct se_mem *, -struct se_mem **); +unsigned long long ,u32 , +enum dma_data_direction , +struct list_head *);extern int transport_generic_new_cmd (struct se_cmd *);extern void transport_generic_process_write (struct se_cmd *);extern int transport_generic_do_tmr (struct se_cmd *);
Signature · 1 line
1.5.6.5
Quoted 8 lines · Nicholas A. Bellinger
From: Nicholas Bellinger <[email protected]>
This v2 patch series adds BIDI-COMMANDS support to TCM Core. This
includes the following for structse_cmdto handle BIDI READ payloads using a new structse_transport_task->t_mem_bidi_listand structse_transport_task->t_tasks_se_bidi_num. The model employed is to keep the WRITE payload at structse_transport_task->t_mem_list, and add a new BIDI READ payload memory list at structse_transport_task->t_mem_bidi_list.
Sorry, this patch is a PRE rebased DUPE.. Please ignore it.
Best,
--nab