hisi_sas: DIF/DIX support
Subsystems (2)
v2 cover hisi_sas: DIF/DIX support
This patchset introduces support to the driver for DIF/DIX (or PI - protection information).
We will only support PI in v3 hw at the moment, even though previous hw versions also support it.
The series is broken down as follows:
- Tidy sg table size config
- Some tidy-up to accept PI support
- Add components for PI support for main and v3 driver
Difference v1->v2:
- drop scsi_prot_op_normal()
Xiang Chen (3):
scsi: hisi_sas: Relocate some code to reduce complexity
scsi: hisi_sas: Make sg_tablesize consistent value
scsi: hisi_sas: Add support for DIF/DIX feature for v3 hw
drivers/scsi/hisi_sas/hisi_sas.h | 18 +++ drivers/scsi/hisi_sas/hisi_sas_main.c | 242 ++++++++++++++++++++++++--------- drivers/scsi/hisi_sas/hisi_sas_v1_hw.c | 2 +- drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 2 +- drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 192 +++++++++++++++++++++++++- 5 files changed, 380 insertions(+), 76 deletions(-)
Signature · 1 line
1.9.1
PATCH v2 1/3 scsi: hisi_sas: Relocate some code to reduce complexity
From: Xiang Chen <[email protected]>
Relocate the codes related to dma_map/unmap in hisi_sas_task_prep() to reduce complexity, with a view to add DIF/DIX support.
--- drivers/scsi/hisi_sas/hisi_sas_main.c | 146 +++++++++++++++++++++------------- 1 file changed, 90 insertions(+), 56 deletions(-)
drivers/scsi/hisi_sas/hisi_sas_main.c +90 -56
@@ -296,6 +296,90 @@ static void hisi_sas_task_prep_abort(struct hisi_hba *hisi_hba, device_id, abort_flag, tag_to_abort); } +static void hisi_sas_dma_unmap (struct hisi_hba *hisi_hba, +struct sas_task *task,int n_elem, +int n_elem_req,int n_elem_resp) +{ +struct device *dev = hisi_hba->dev; + +if (!sas_protocol_ata (task->task_proto)) { +if (task->num_scatter) { +if (n_elem) +dma_unmap_sg (dev, task->scatter, + task->num_scatter, + task->data_dir); + }else if (task->task_proto &SAS_PROTOCOL_SMP ) { +if (n_elem_req) +dma_unmap_sg (dev, &task->smp_task.smp_req, +1 ,DMA_TO_DEVICE ); +if (n_elem_resp) +dma_unmap_sg (dev, &task->smp_task.smp_resp, +1 ,DMA_FROM_DEVICE ); + } + } +} + +static int hisi_sas_dma_map (struct hisi_hba *hisi_hba, +struct sas_task *task,int *n_elem, +int *n_elem_req,int *n_elem_resp) +{ +struct device *dev = hisi_hba->dev; +int rc; + +if (sas_protocol_ata (task->task_proto)) { + *n_elem = task->num_scatter; + }else { +unsigned int req_len, resp_len; + +if (task->num_scatter) { + *n_elem =dma_map_sg (dev, task->scatter, + task->num_scatter, task->data_dir); +if (!*n_elem) { + rc = -ENOMEM ; + goto prep_out; + } + }else if (task->task_proto &SAS_PROTOCOL_SMP ) { + *n_elem_req =dma_map_sg (dev, &task->smp_task.smp_req, +1 ,DMA_TO_DEVICE ); +if (!*n_elem_req) { + rc = -ENOMEM ; + goto prep_out; + } + req_len =sg_dma_len (&task->smp_task.smp_req); +if (req_len &0x3 ) { + rc = -EINVAL ; + goto err_out_dma_unmap; + } + *n_elem_resp =dma_map_sg (dev, &task->smp_task.smp_resp, +1 ,DMA_FROM_DEVICE ); +if (!*n_elem_resp) { + rc = -ENOMEM ; + goto err_out_dma_unmap; + } + resp_len =sg_dma_len (&task->smp_task.smp_resp); +if (resp_len &0x3 ) { + rc = -EINVAL ; + goto err_out_dma_unmap; + } + } + } + +if (*n_elem >HISI_SAS_SGE_PAGE_CNT ) { +dev_err (dev,"task prep: n_elem(%d) > HISI_SAS_SGE_PAGE_CNT" , + *n_elem); + rc = -EINVAL ; + goto err_out_dma_unmap; + } +return 0 ; + +err_out_dma_unmap: +/* It would be better to call dma_unmap_sg() here, but it's messy */ +hisi_sas_dma_unmap (hisi_hba, task, *n_elem, + *n_elem_req, *n_elem_resp); +prep_out: +return rc; +} + static int hisi_sas_task_prep(struct sas_task *task, struct hisi_sas_dq **dq_pointer, bool is_tmf, struct hisi_sas_tmf_task *tmf,
@@ -338,49 +422,10 @@ static int hisi_sas_task_prep(struct sas_task *task,return -ECOMM ; } -if (!sas_protocol_ata (task->task_proto)) { -unsigned int req_len, resp_len; - -if (task->num_scatter) { - n_elem =dma_map_sg (dev, task->scatter, - task->num_scatter, task->data_dir); -if (!n_elem) { - rc = -ENOMEM ; - goto prep_out; - } - }else if (task->task_proto &SAS_PROTOCOL_SMP ) { - n_elem_req =dma_map_sg (dev, &task->smp_task.smp_req, -1 ,DMA_TO_DEVICE ); -if (!n_elem_req) { - rc = -ENOMEM ; - goto prep_out; - } - req_len =sg_dma_len (&task->smp_task.smp_req); -if (req_len &0x3 ) { - rc = -EINVAL ; - goto err_out_dma_unmap; - } - n_elem_resp =dma_map_sg (dev, &task->smp_task.smp_resp, -1 ,DMA_FROM_DEVICE ); -if (!n_elem_resp) { - rc = -ENOMEM ; - goto err_out_dma_unmap; - } - resp_len =sg_dma_len (&task->smp_task.smp_resp); -if (resp_len &0x3 ) { - rc = -EINVAL ; - goto err_out_dma_unmap; - } - } - }else - n_elem = task->num_scatter; - -if (n_elem >HISI_SAS_SGE_PAGE_CNT ) { -dev_err (dev,"task prep: n_elem(%d) > HISI_SAS_SGE_PAGE_CNT" , - n_elem); - rc = -EINVAL ; - goto err_out_dma_unmap; - } + rc =hisi_sas_dma_map (hisi_hba, task, &n_elem, + &n_elem_req, &n_elem_resp); +if (rc <0 ) + goto prep_out;if (hisi_hba->hw->slot_index_alloc) rc = hisi_hba->hw->slot_index_alloc (hisi_hba, device);
@@ -465,19 +510,8 @@ static int hisi_sas_task_prep(struct sas_task *task, err_out_tag:hisi_sas_slot_index_free (hisi_hba, slot_idx); err_out_dma_unmap: -if (!sas_protocol_ata (task->task_proto)) { -if (task->num_scatter) { -dma_unmap_sg (dev, task->scatter, task->num_scatter, - task->data_dir); - }else if (task->task_proto &SAS_PROTOCOL_SMP ) { -if (n_elem_req) -dma_unmap_sg (dev, &task->smp_task.smp_req, -1 ,DMA_TO_DEVICE ); -if (n_elem_resp) -dma_unmap_sg (dev, &task->smp_task.smp_resp, -1 ,DMA_FROM_DEVICE ); - } - } +hisi_sas_dma_unmap (hisi_hba, task, n_elem, + n_elem_req, n_elem_resp); prep_out:dev_err (dev,"task prep: failed[%d]!\n" , rc);return rc;
Signature · 1 line
1.9.1
PATCH v2 2/3 scsi: hisi_sas: Make sg_tablesize consistent value
In reply to John GarryFrom: Xiang Chen <[email protected]>
Sht->sg_tablesize is set in the driver, and it will be assigned to shost->sg_tablesize in SCSI mid-layer. So it is not necessary to assign shost->sg_table one more time in the driver.
In addition to the change, change each scsi_host_template.sg_tablesize to HISI_SAS_SGE_PAGE_CNT instead of SG_ALL.
--- drivers/scsi/hisi_sas/hisi_sas_main.c | 1 - drivers/scsi/hisi_sas/hisi_sas_v1_hw.c | 2 +- drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 2 +- drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 3 +-- 4 files changed, 3 insertions(+), 5 deletions(-)
drivers/scsi/hisi_sas/hisi_sas_main.c +0 -1
@@ -2410,7 +2410,6 @@ int hisi_sas_probe(struct platform_device *pdev, shost->max_lun = ~0 ; shost->max_channel =1 ; shost->max_cmd_len =16 ; - shost->sg_tablesize =min_t (u16,SG_ALL ,HISI_SAS_SGE_PAGE_CNT );if (hisi_hba->hw->slot_index_alloc) { shost->can_queue = hisi_hba->hw->max_command_entries; shost->cmd_per_lun = hisi_hba->hw->max_command_entries;
drivers/scsi/hisi_sas/hisi_sas_v1_hw.c +1 -1
@@ -1815,7 +1815,7 @@ static int hisi_sas_v1_init(struct hisi_hba *hisi_hba) .change_queue_depth = sas_change_queue_depth, .bios_param = sas_bios_param, .this_id = -1, - .sg_tablesize = SG_ALL, + .sg_tablesize = HISI_SAS_SGE_PAGE_CNT, .max_sectors = SCSI_DEFAULT_MAX_SECTORS, .use_clustering = ENABLE_CLUSTERING, .eh_device_reset_handler = sas_eh_device_reset_handler,
drivers/scsi/hisi_sas/hisi_sas_v2_hw.c +1 -1
@@ -3570,7 +3570,7 @@ struct device_attribute *host_attrs_v2_hw[] = { .change_queue_depth = sas_change_queue_depth, .bios_param = sas_bios_param, .this_id = -1, - .sg_tablesize = SG_ALL, + .sg_tablesize = HISI_SAS_SGE_PAGE_CNT, .max_sectors = SCSI_DEFAULT_MAX_SECTORS, .use_clustering = ENABLE_CLUSTERING, .eh_device_reset_handler = sas_eh_device_reset_handler,
drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +1 -2
@@ -2224,7 +2224,7 @@ struct device_attribute *host_attrs_v3_hw[] = { .change_queue_depth = sas_change_queue_depth, .bios_param = sas_bios_param, .this_id = -1, - .sg_tablesize = SG_ALL, + .sg_tablesize = HISI_SAS_SGE_PAGE_CNT, .max_sectors = SCSI_DEFAULT_MAX_SECTORS, .use_clustering = ENABLE_CLUSTERING, .eh_device_reset_handler = sas_eh_device_reset_handler,
@@ -2366,7 +2366,6 @@ struct device_attribute *host_attrs_v3_hw[] = { shost->max_lun = ~0 ; shost->max_channel =1 ; shost->max_cmd_len =16 ; - shost->sg_tablesize =min_t (u16,SG_ALL ,HISI_SAS_SGE_PAGE_CNT ); shost->can_queue = hisi_hba->hw->max_command_entries -HISI_SAS_RESERVED_IPTT_CNT ; shost->cmd_per_lun = hisi_hba->hw->max_command_entries -
Signature · 1 line
1.9.1
PATCH v2 3/3 scsi: hisi_sas: Add support for DIF/DIX feature for v3 hw
In reply to John GarryFrom: Xiang Chen <[email protected]>
For v3 hw, we support DIF/DIX operation for SAS, but not SATA.
In addition, DIF CRC16 is supported.
This patchset adds the SW support for the described features. The main components are as follows:
- Allocate memory for PI
- Fill PI fields
- Fill related to DIF/DIX in DQ and protection iu memories
--- drivers/scsi/hisi_sas/hisi_sas.h | 18 ++++ drivers/scsi/hisi_sas/hisi_sas_main.c | 99 ++++++++++++++--- drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 189 ++++++++++++++++++++++++++++++++- 3 files changed, 289 insertions(+), 17 deletions(-)
drivers/scsi/hisi_sas/hisi_sas.h +18 -0
@@ -55,6 +55,11 @@#define hisi_sas_sge_addr_mem (slot) hisi_sas_sge_addr(slot->buf)#define hisi_sas_sge_addr_dma (slot) hisi_sas_sge_addr(slot->buf_dma) +#define hisi_sas_sge_dif_addr (buf) \ + (buf + offsetof(struct hisi_sas_slot_dif_buf_table, sge_dif_page)) +#define hisi_sas_sge_dif_addr_mem (slot) hisi_sas_sge_dif_addr(slot->buf) +#define hisi_sas_sge_dif_addr_dma (slot) hisi_sas_sge_dif_addr(slot->buf_dma) +#define HISI_SAS_MAX_SSP_RESP_SZ (sizeof(struct ssp_frame_hdr) + 1024)#define HISI_SAS_MAX_SMP_RESP_SZ 1028#define HISI_SAS_MAX_STP_RESP_SZ 28
@@ -197,6 +202,7 @@ struct hisi_sas_slot {struct sas_task *task;struct hisi_sas_port *port;u64 n_elem; +u64 n_elem_dif;int dlvry_queue;int dlvry_queue_slot;int cmplt_queue;
@@ -268,6 +274,8 @@ struct hisi_hba {struct pci_dev *pci_dev;struct device *dev; +bool enable_dif_dix; +void __iomem *regs;void __iomem *sgpio_regs;struct regmap *ctrl;
@@ -422,6 +430,11 @@ struct hisi_sas_sge_page {struct hisi_sas_sge sge[HISI_SAS_SGE_PAGE_CNT ]; }__aligned(16) ; +#define HISI_SAS_SGE_DIF_PAGE_CNT SG_CHUNK_SIZE +struct hisi_sas_sge_dif_page { +struct hisi_sas_sge sge[HISI_SAS_SGE_DIF_PAGE_CNT ]; +}__aligned(16) ; +struct hisi_sas_command_table_ssp {struct ssp_frame_hdr hdr;union {
@@ -452,6 +465,11 @@ struct hisi_sas_slot_buf_table {struct hisi_sas_sge_page sge_page; }; +struct hisi_sas_slot_dif_buf_table { +struct hisi_sas_slot_buf_table slot_buf; +struct hisi_sas_sge_dif_page sge_dif_page; +}; +extern struct scsi_transport_template *hisi_sas_stt;extern void hisi_sas_stop_phys (struct hisi_hba *hisi_hba);extern int hisi_sas_alloc (struct hisi_hba *hisi_hba,struct Scsi_Host *shost);
drivers/scsi/hisi_sas/hisi_sas_main.c +87 -12
168 lines not on this page · raw message
drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +184 -5
256 lines not on this page · raw message
Signature · 1 line
1.9.1