History

Merge tag 'scsi-misc' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi

Pull SCSI updates from James Bottomley: "This consists of a small set of driver updates (lpfc, ufs, mpt3sas mpi3mr, iscsi target). Apart from that this is mostly small fixes with very few core changes (the biggest one being VPD caching)" * tag 'scsi-misc' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi: (177 commits) scsi: target: tcmu: Avoid holding XArray lock when calling lock_page scsi: elx: efct: Remove NULL check after calling container_of() scsi: dpt_i2o: Drop redundant spinlock initialization scsi: qedf: Remove redundant variable op scsi: hisi_sas: Fix memory ordering in hisi_sas_task_deliver() scsi: fnic: Replace DMA mask of 64 bits with 47 bits scsi: mpi3mr: Add target device related sysfs attributes scsi: mpi3mr: Add shost related sysfs attributes scsi: elx: efct: Remove redundant memset() statement scsi: megaraid_sas: Remove redundant memset() statement scsi: mpi3mr: Return error if dma_alloc_coherent() fails scsi: hisi_sas: Fix rescan after deleting a disk scsi: hisi_sas: Use sas_ata_wait_after_reset() in IT nexus reset scsi: libsas: Refactor sas_ata_hard_reset() scsi: mpt3sas: Update driver version to 42.100.00.00 scsi: mpt3sas: Fix junk chars displayed while printing ChipName scsi: ipr: Use kobj_to_dev() scsi: mpi3mr: Fix a NULL vs IS_ERR() bug in mpi3mr_bsg_init() scsi: bnx2fc: Avoid using get_cpu() in bnx2fc_cmd_alloc() scsi: libfc: Remove get_cpu() semantics in fc_exch_em_alloc() ...

Linus Torvalds committed 4 years ago

Commit fbe86da2 parents d722778 325d5c5169 files · +6840 −3470Browse files

Unified · Split

169 files
  1. Documentation/ABI/testing/sysfs-driver-ufs +11 −7
  2. drivers/infiniband/ulp/isert/ib_isert.c +52 −52
  3. drivers/infiniband/ulp/isert/ib_isert.h +2 −2
  4. drivers/message/fusion/mptctl.c +0 −3
  5. drivers/scsi/aacraid/aacraid.h +1 −1
  6. drivers/scsi/aha1542.c +10 −10
  7. drivers/scsi/bfa/bfad_debugfs.c +1 −2
  8. drivers/scsi/bfa/bfad_im.c +0 −1
  9. drivers/scsi/bnx2fc/bnx2fc_fcoe.c +6 −16
  10. drivers/scsi/bnx2fc/bnx2fc_io.c +6 −11
  11. drivers/scsi/dc395x.c +12 −3
  12. drivers/scsi/dpt_i2o.c +0 −1
  13. drivers/scsi/elx/efct/efct_hw.c +0 −1
  14. drivers/scsi/elx/efct/efct_io.c +0 −1
  15. drivers/scsi/elx/efct/efct_lio.c +0 −3
  16. drivers/scsi/fcoe/fcoe.c +17 −27
  17. drivers/scsi/fcoe/fcoe_ctlr.c +9 −17
  18. drivers/scsi/fcoe/fcoe_transport.c +3 −3
  19. drivers/scsi/fnic/fnic.h +1 −1
  20. drivers/scsi/fnic/fnic_debugfs.c +1 −2
  21. drivers/scsi/fnic/fnic_main.c +4 −6
  22. drivers/scsi/hisi_sas/hisi_sas_main.c +32 −36
  23. drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +8 −2
  24. drivers/scsi/hosts.c +4 −4
  25. drivers/scsi/ipr.c +6 −7
  26. drivers/scsi/libfc/fc_exch.c +1 −2
  27. drivers/scsi/libfc/fc_fcp.c +10 −19
  28. drivers/scsi/libfc/fc_lport.c +15 −15
  29. drivers/scsi/libsas/sas_ata.c +27 −14
  30. drivers/scsi/lpfc/lpfc.h +7 −3
  31. drivers/scsi/lpfc/lpfc_attr.c +41 −14
  32. drivers/scsi/lpfc/lpfc_bsg.c +36 −45
  33. drivers/scsi/lpfc/lpfc_crtn.h +4 −1
  34. drivers/scsi/lpfc/lpfc_ct.c +246 −120
  35. drivers/scsi/lpfc/lpfc_els.c +338 −377
  36. drivers/scsi/lpfc/lpfc_hbadisc.c +63 −101
  37. drivers/scsi/lpfc/lpfc_hw.h +44 −31
  38. drivers/scsi/lpfc/lpfc_hw4.h +12 −5
  39. drivers/scsi/lpfc/lpfc_init.c +131 −143
  40. drivers/scsi/lpfc/lpfc_logmsg.h +4 −4
  41. drivers/scsi/lpfc/lpfc_mbox.c +120 −83
  42. drivers/scsi/lpfc/lpfc_nportdisc.c +38 −41
  43. drivers/scsi/lpfc/lpfc_nvme.c +25 −19
  44. drivers/scsi/lpfc/lpfc_nvmet.c +37 −36
  45. drivers/scsi/lpfc/lpfc_scsi.c +34 −38
  46. drivers/scsi/lpfc/lpfc_sli.c +129 −141
  47. drivers/scsi/lpfc/lpfc_sli.h +24 −10
  48. drivers/scsi/lpfc/lpfc_sli4.h +3 −0
  49. drivers/scsi/lpfc/lpfc_version.h +1 −1
  50. drivers/scsi/lpfc/lpfc_vport.c +14 −17
  51. drivers/scsi/mac53c94.c +1 −1
  52. drivers/scsi/megaraid.c +1 −1
  53. drivers/scsi/megaraid/megaraid_sas_base.c +0 −2
  54. drivers/scsi/megaraid/megaraid_sas_fusion.c +0 −2
  55. drivers/scsi/mpi3mr/Kconfig +1 −0
  56. drivers/scsi/mpi3mr/Makefile +1 −0
  57. drivers/scsi/mpi3mr/mpi/mpi30_init.h +0 −53
  58. drivers/scsi/mpi3mr/mpi/mpi30_ioc.h +0 −27
  59. drivers/scsi/mpi3mr/mpi/mpi30_pci.h +1 −30
  60. drivers/scsi/mpi3mr/mpi3mr.h +130 −7
  61. drivers/scsi/mpi3mr/mpi3mr_app.c +1864 −0
  62. drivers/scsi/mpi3mr/mpi3mr_debug.h +31 −6
  63. drivers/scsi/mpi3mr/mpi3mr_fw.c +332 −3
  64. drivers/scsi/mpi3mr/mpi3mr_os.c +66 −5
  65. drivers/scsi/mpt3sas/mpt3sas_base.c +17 −17
  66. drivers/scsi/mpt3sas/mpt3sas_base.h +3 −3
  67. drivers/scsi/mpt3sas/mpt3sas_ctl.c +6 −5
  68. drivers/scsi/mpt3sas/mpt3sas_scsih.c +11 −13
  69. drivers/scsi/pmcraid.c +1 −1
  70. drivers/scsi/qedf/qedf_attr.c +0 −2
  71. drivers/scsi/qedf/qedf_io.c +1 −2
  72. drivers/scsi/qedf/qedf_main.c +5 −8
  73. drivers/scsi/qla2xxx/qla_edif.c +1 −2
  74. drivers/scsi/qla2xxx/qla_os.c +0 −1
  75. drivers/scsi/qla2xxx/qla_target.c +0 −2
  76. drivers/scsi/qla2xxx/qla_target.h +0 −1
  77. drivers/scsi/qla4xxx/ql4_os.c +0 −1
  78. drivers/scsi/scsi.c +79 −37
  79. drivers/scsi/scsi_debug.c +114 −35
  80. drivers/scsi/scsi_lib.c +1 −1
  81. drivers/scsi/scsi_scan.c +11 −1
  82. drivers/scsi/scsi_sysfs.c +28 −0
  83. drivers/scsi/sd.c +118 −75
  84. drivers/scsi/sd.h +26 −7
  85. drivers/scsi/sd_dif.c +3 −5
  86. drivers/scsi/sd_zbc.c +184 −52
  87. drivers/scsi/sr.c +8 −6
  88. drivers/scsi/ufs/Kconfig +1 −25
  89. drivers/scsi/ufs/cdns-pltfrm.c +1 −1
  90. drivers/scsi/ufs/tc-dwc-g210-pci.c +1 −0
  91. drivers/scsi/ufs/tc-dwc-g210-pltfrm.c +1 −0
  92. drivers/scsi/ufs/tc-dwc-g210.c +2 −0
  93. drivers/scsi/ufs/tc-dwc-g210.h +2 −0
  94. drivers/scsi/ufs/ti-j721e-ufs.c +2 −4
  95. drivers/scsi/ufs/ufs-debugfs.c +1 −0
  96. drivers/scsi/ufs/ufs-exynos.c +3 −2
  97. drivers/scsi/ufs/ufs-exynos.h +4 −4
  98. drivers/scsi/ufs/ufs-hisi.c +2 −0
  99. drivers/scsi/ufs/ufs-hwmon.c +1 −0
  100. drivers/scsi/ufs/ufs-mediatek.c +12 −19
  101. drivers/scsi/ufs/ufs-qcom-ice.c +1 −1
  102. drivers/scsi/ufs/ufs-qcom.c +25 −48
  103. drivers/scsi/ufs/ufs-qcom.h +2 −4
  104. drivers/scsi/ufs/ufs-sysfs.c +1 −0
  105. drivers/scsi/ufs/ufs-sysfs.h +2 −1
  106. drivers/scsi/ufs/ufs.h +0 −35
  107. drivers/scsi/ufs/ufs_bsg.c +6 −0
  108. drivers/scsi/ufs/ufs_bsg.h +1 −6
  109. drivers/scsi/ufs/ufs_quirks.h +3 −12
  110. drivers/scsi/ufs/ufshcd-crypto.h +4 −1
  111. drivers/scsi/ufs/ufshcd-dwc.c +2 −0
  112. drivers/scsi/ufs/ufshcd-dwc.h +2 −0
  113. drivers/scsi/ufs/ufshcd-pci.c +2 −2
  114. drivers/scsi/ufs/ufshcd-pltfrm.c +20 −18
  115. drivers/scsi/ufs/ufshcd-priv.h +298 −0
  116. drivers/scsi/ufs/ufshcd.c +116 −131
  117. drivers/scsi/ufs/ufshcd.h +80 −288
  118. drivers/scsi/ufs/ufshci.h +2 −0
  119. drivers/scsi/ufs/ufshpb.c +112 −91
  120. drivers/scsi/ufs/ufshpb.h +7 −9
  121. drivers/scsi/ufs/unipro.h +1 −17
  122. drivers/scsi/vmw_pvscsi.c +0 −1
  123. drivers/target/iscsi/cxgbit/cxgbit.h +11 −11
  124. drivers/target/iscsi/cxgbit/cxgbit_cm.c +4 −4
  125. drivers/target/iscsi/cxgbit/cxgbit_ddp.c +2 −2
  126. drivers/target/iscsi/cxgbit/cxgbit_main.c +1 −1
  127. drivers/target/iscsi/cxgbit/cxgbit_target.c +36 −36
  128. drivers/target/iscsi/iscsi_target.c +136 −136
  129. drivers/target/iscsi/iscsi_target.h +15 −15
  130. drivers/target/iscsi/iscsi_target_auth.c +5 −5
  131. drivers/target/iscsi/iscsi_target_auth.h +2 −2
  132. drivers/target/iscsi/iscsi_target_configfs.c +17 −17
  133. drivers/target/iscsi/iscsi_target_datain_values.c +14 −14
  134. drivers/target/iscsi/iscsi_target_datain_values.h +6 −6
  135. drivers/target/iscsi/iscsi_target_device.c +2 −2
  136. drivers/target/iscsi/iscsi_target_device.h +4 −4
  137. drivers/target/iscsi/iscsi_target_erl0.c +34 −34
  138. drivers/target/iscsi/iscsi_target_erl0.h +12 −12
  139. drivers/target/iscsi/iscsi_target_erl1.c +46 −46
  140. drivers/target/iscsi/iscsi_target_erl1.h +20 −20
  141. drivers/target/iscsi/iscsi_target_erl2.c +24 −24
  142. drivers/target/iscsi/iscsi_target_erl2.h +13 −13
  143. drivers/target/iscsi/iscsi_target_login.c +39 −39
  144. drivers/target/iscsi/iscsi_target_login.h +11 −11
  145. drivers/target/iscsi/iscsi_target_nego.c +30 −30
  146. drivers/target/iscsi/iscsi_target_nego.h +6 −6
  147. drivers/target/iscsi/iscsi_target_nodeattrib.c +2 −2
  148. drivers/target/iscsi/iscsi_target_parameters.c +4 −4
  149. drivers/target/iscsi/iscsi_target_parameters.h +4 −4
  150. drivers/target/iscsi/iscsi_target_seq_pdu_list.c +22 −22
  151. drivers/target/iscsi/iscsi_target_seq_pdu_list.h +5 −5
  152. drivers/target/iscsi/iscsi_target_stat.c +8 −8
  153. drivers/target/iscsi/iscsi_target_tmr.c +36 −36
  154. drivers/target/iscsi/iscsi_target_tmr.h +8 −8
  155. drivers/target/iscsi/iscsi_target_tpg.c +1 −1
  156. drivers/target/iscsi/iscsi_target_tpg.h +2 −2
  157. drivers/target/iscsi/iscsi_target_util.c +82 −82
  158. drivers/target/iscsi/iscsi_target_util.h +51 −51
  159. drivers/target/target_core_configfs.c +28 −19
  160. drivers/target/target_core_spc.c +1 −1
  161. drivers/target/target_core_user.c +42 −8
  162. include/scsi/libfcoe.h +2 −0
  163. include/scsi/libiscsi.h +3 −3
  164. include/scsi/sas_ata.h +7 −0
  165. include/scsi/scsi_device.h +8 −1
  166. include/scsi/scsi_proto.h +8 −1
  167. include/target/iscsi/iscsi_target_core.h +26 −26
  168. include/target/iscsi/iscsi_transport.h +63 −63
  169. include/uapi/scsi/scsi_bsg_mpi3mr.h +582 −0
Documentation/ABI/testing/sysfs-driver-ufs+11−7
@@ -1518,7 +1518,7 @@ Description: This entry shows the number of reads that cannot be changed to · 1517 unmodified lines
1518 1518
1519 The file is read only.1519 The file is read only.
1520 1520
1521What: /sys/class/scsi_device/*/device/hpb_stats/rb_noti_cnt1521What: /sys/class/scsi_device/*/device/hpb_stats/rcmd_noti_cnt
1522Date: June 20211522Date: June 2021
1523Contact: Daejun Park <daejun7.park@samsung.com>1523Contact: Daejun Park <daejun7.park@samsung.com>
1524Description: This entry shows the number of response UPIUs that has1524Description: This entry shows the number of response UPIUs that has
@@ -1526,19 +1526,23 @@ Description: This entry shows the number of response UPIUs that has · 1 unmodified line
1526 1526
1527 The file is read only.1527 The file is read only.
1528 1528
1529What: /sys/class/scsi_device/*/device/hpb_stats/rb_active_cnt1529What: /sys/class/scsi_device/*/device/hpb_stats/rcmd_active_cnt
1530Date: June 20211530Date: June 2021
1531Contact: Daejun Park <daejun7.park@samsung.com>1531Contact: Daejun Park <daejun7.park@samsung.com>
1532Description: This entry shows the number of active sub-regions recommended by1532Description: For the HPB device control mode, this entry shows the number of
1533 response UPIUs.1533 active sub-regions recommended by response UPIUs. For the HPB host control
1534 mode, this entry shows the number of active sub-regions recommended by the
1535 HPB host control mode heuristic algorithm.
1534 1536
1535 The file is read only.1537 The file is read only.
1536 1538
1537What: /sys/class/scsi_device/*/device/hpb_stats/rb_inactive_cnt1539What: /sys/class/scsi_device/*/device/hpb_stats/rcmd_inactive_cnt
1538Date: June 20211540Date: June 2021
1539Contact: Daejun Park <daejun7.park@samsung.com>1541Contact: Daejun Park <daejun7.park@samsung.com>
1540Description: This entry shows the number of inactive regions recommended by1542Description: For the HPB device control mode, this entry shows the number of
1541 response UPIUs.1543 inactive regions recommended by response UPIUs. For the HPB host control
1544 mode, this entry shows the number of inactive regions recommended by the
1545 HPB host control mode heuristic algorithm.
1542 1546
1543 The file is read only.1547 The file is read only.
1544 1548
drivers/infiniband/ulp/isert/ib_isert.c+52−52
@@ -46,7 +46,7 @@ static struct workqueue_struct *isert_comp_wq; · 45 unmodified lines
46static struct workqueue_struct *isert_release_wq;46static struct workqueue_struct *isert_release_wq;
47 47
48static int48static int
49isert_put_response(struct iscsi_conn *conn, struct iscsi_cmd *cmd);49isert_put_response(struct iscsit_conn *conn, struct iscsit_cmd *cmd);
50static int50static int
51isert_login_post_recv(struct isert_conn *isert_conn);51isert_login_post_recv(struct isert_conn *isert_conn);
52static int52static int
@@ -909,7 +909,7 @@ isert_login_post_recv(struct isert_conn *isert_conn) · 856 unmodified lines
909}909}
910 910
911static int911static int
912isert_put_login_tx(struct iscsi_conn *conn, struct iscsi_login *login,912isert_put_login_tx(struct iscsit_conn *conn, struct iscsi_login *login,
913 u32 length)913 u32 length)
914{914{
915 struct isert_conn *isert_conn = conn->context;915 struct isert_conn *isert_conn = conn->context;
@@ -976,7 +976,7 @@ isert_rx_login_req(struct isert_conn *isert_conn) · 60 unmodified lines
976{976{
977 struct iser_rx_desc *rx_desc = isert_conn->login_desc;977 struct iser_rx_desc *rx_desc = isert_conn->login_desc;
978 int rx_buflen = isert_conn->login_req_len;978 int rx_buflen = isert_conn->login_req_len;
979 struct iscsi_conn *conn = isert_conn->conn;979 struct iscsit_conn *conn = isert_conn->conn;
980 struct iscsi_login *login = conn->conn_login;980 struct iscsi_login *login = conn->conn_login;
981 int size;981 int size;
982 982
@@ -1020,21 +1020,21 @@ isert_rx_login_req(struct isert_conn *isert_conn) · 37 unmodified lines
1020 schedule_delayed_work(&conn->login_work, 0);1020 schedule_delayed_work(&conn->login_work, 0);
1021}1021}
1022 1022
1023static struct iscsi_cmd1023static struct iscsit_cmd
1024*isert_allocate_cmd(struct iscsi_conn *conn, struct iser_rx_desc *rx_desc)1024*isert_allocate_cmd(struct iscsit_conn *conn, struct iser_rx_desc *rx_desc)
1025{1025{
1026 struct isert_conn *isert_conn = conn->context;1026 struct isert_conn *isert_conn = conn->context;
1027 struct isert_cmd *isert_cmd;1027 struct isert_cmd *isert_cmd;
1028 struct iscsi_cmd *cmd;1028 struct iscsit_cmd *cmd;
1029 1029
1030 cmd = iscsit_allocate_cmd(conn, TASK_INTERRUPTIBLE);1030 cmd = iscsit_allocate_cmd(conn, TASK_INTERRUPTIBLE);
1031 if (!cmd) {1031 if (!cmd) {
1032 isert_err("Unable to allocate iscsi_cmd + isert_cmd\n");1032 isert_err("Unable to allocate iscsit_cmd + isert_cmd\n");
1033 return NULL;1033 return NULL;
1034 }1034 }
1035 isert_cmd = iscsit_priv_cmd(cmd);1035 isert_cmd = iscsit_priv_cmd(cmd);
1036 isert_cmd->conn = isert_conn;1036 isert_cmd->conn = isert_conn;
1037 isert_cmd->iscsi_cmd = cmd;1037 isert_cmd->iscsit_cmd = cmd;
1038 isert_cmd->rx_desc = rx_desc;1038 isert_cmd->rx_desc = rx_desc;
1039 1039
1040 return cmd;1040 return cmd;
@@ -1042,10 +1042,10 @@ static struct iscsi_cmd · 1 unmodified line
1042 1042
1043static int1043static int
1044isert_handle_scsi_cmd(struct isert_conn *isert_conn,1044isert_handle_scsi_cmd(struct isert_conn *isert_conn,
1045 struct isert_cmd *isert_cmd, struct iscsi_cmd *cmd,1045 struct isert_cmd *isert_cmd, struct iscsit_cmd *cmd,
1046 struct iser_rx_desc *rx_desc, unsigned char *buf)1046 struct iser_rx_desc *rx_desc, unsigned char *buf)
1047{1047{
1048 struct iscsi_conn *conn = isert_conn->conn;1048 struct iscsit_conn *conn = isert_conn->conn;
1049 struct iscsi_scsi_req *hdr = (struct iscsi_scsi_req *)buf;1049 struct iscsi_scsi_req *hdr = (struct iscsi_scsi_req *)buf;
1050 int imm_data, imm_data_len, unsol_data, sg_nents, rc;1050 int imm_data, imm_data_len, unsol_data, sg_nents, rc;
1051 bool dump_payload = false;1051 bool dump_payload = false;
@@ -1114,8 +1114,8 @@ isert_handle_iscsi_dataout(struct isert_conn *isert_conn, · 62 unmodified lines
1114 struct iser_rx_desc *rx_desc, unsigned char *buf)1114 struct iser_rx_desc *rx_desc, unsigned char *buf)
1115{1115{
1116 struct scatterlist *sg_start;1116 struct scatterlist *sg_start;
1117 struct iscsi_conn *conn = isert_conn->conn;1117 struct iscsit_conn *conn = isert_conn->conn;
1118 struct iscsi_cmd *cmd = NULL;1118 struct iscsit_cmd *cmd = NULL;
1119 struct iscsi_data *hdr = (struct iscsi_data *)buf;1119 struct iscsi_data *hdr = (struct iscsi_data *)buf;
1120 u32 unsol_data_len = ntoh24(hdr->dlength);1120 u32 unsol_data_len = ntoh24(hdr->dlength);
1121 int rc, sg_nents, sg_off, page_off;1121 int rc, sg_nents, sg_off, page_off;
@@ -1171,10 +1171,10 @@ isert_handle_iscsi_dataout(struct isert_conn *isert_conn, · 49 unmodified lines
1171 1171
1172static int1172static int
1173isert_handle_nop_out(struct isert_conn *isert_conn, struct isert_cmd *isert_cmd,1173isert_handle_nop_out(struct isert_conn *isert_conn, struct isert_cmd *isert_cmd,
1174 struct iscsi_cmd *cmd, struct iser_rx_desc *rx_desc,1174 struct iscsit_cmd *cmd, struct iser_rx_desc *rx_desc,
1175 unsigned char *buf)1175 unsigned char *buf)
1176{1176{
1177 struct iscsi_conn *conn = isert_conn->conn;1177 struct iscsit_conn *conn = isert_conn->conn;
1178 struct iscsi_nopout *hdr = (struct iscsi_nopout *)buf;1178 struct iscsi_nopout *hdr = (struct iscsi_nopout *)buf;
1179 int rc;1179 int rc;
1180 1180
@@ -1190,10 +1190,10 @@ isert_handle_nop_out(struct isert_conn *isert_conn, struct isert_cmd *isert_cmd, · 9 unmodified lines
1190 1190
1191static int1191static int
1192isert_handle_text_cmd(struct isert_conn *isert_conn, struct isert_cmd *isert_cmd,1192isert_handle_text_cmd(struct isert_conn *isert_conn, struct isert_cmd *isert_cmd,
1193 struct iscsi_cmd *cmd, struct iser_rx_desc *rx_desc,1193 struct iscsit_cmd *cmd, struct iser_rx_desc *rx_desc,
1194 struct iscsi_text *hdr)1194 struct iscsi_text *hdr)
1195{1195{
1196 struct iscsi_conn *conn = isert_conn->conn;1196 struct iscsit_conn *conn = isert_conn->conn;
1197 u32 payload_length = ntoh24(hdr->dlength);1197 u32 payload_length = ntoh24(hdr->dlength);
1198 int rc;1198 int rc;
1199 unsigned char *text_in = NULL;1199 unsigned char *text_in = NULL;
@@ -1220,8 +1220,8 @@ isert_rx_opcode(struct isert_conn *isert_conn, struct iser_rx_desc *rx_desc, · 20 unmodified lines
1220 uint32_t write_stag, uint64_t write_va)1220 uint32_t write_stag, uint64_t write_va)
1221{1221{
1222 struct iscsi_hdr *hdr = isert_get_iscsi_hdr(rx_desc);1222 struct iscsi_hdr *hdr = isert_get_iscsi_hdr(rx_desc);
1223 struct iscsi_conn *conn = isert_conn->conn;1223 struct iscsit_conn *conn = isert_conn->conn;
1224 struct iscsi_cmd *cmd;1224 struct iscsit_cmd *cmd;
1225 struct isert_cmd *isert_cmd;1225 struct isert_cmd *isert_cmd;
1226 int ret = -EINVAL;1226 int ret = -EINVAL;
1227 u8 opcode = (hdr->opcode & ISCSI_OPCODE_MASK);1227 u8 opcode = (hdr->opcode & ISCSI_OPCODE_MASK);
@@ -1404,7 +1404,7 @@ isert_login_recv_done(struct ib_cq *cq, struct ib_wc *wc) · 176 unmodified lines
1404static void1404static void
1405isert_rdma_rw_ctx_destroy(struct isert_cmd *cmd, struct isert_conn *conn)1405isert_rdma_rw_ctx_destroy(struct isert_cmd *cmd, struct isert_conn *conn)
1406{1406{
1407 struct se_cmd *se_cmd = &cmd->iscsi_cmd->se_cmd;1407 struct se_cmd *se_cmd = &cmd->iscsit_cmd->se_cmd;
1408 enum dma_data_direction dir = target_reverse_dma_direction(se_cmd);1408 enum dma_data_direction dir = target_reverse_dma_direction(se_cmd);
1409 1409
1410 if (!cmd->rw.nr_ops)1410 if (!cmd->rw.nr_ops)
@@ -1426,9 +1426,9 @@ isert_rdma_rw_ctx_destroy(struct isert_cmd *cmd, struct isert_conn *conn) · 15 unmodified lines
1426static void1426static void
1427isert_put_cmd(struct isert_cmd *isert_cmd, bool comp_err)1427isert_put_cmd(struct isert_cmd *isert_cmd, bool comp_err)
1428{1428{
1429 struct iscsi_cmd *cmd = isert_cmd->iscsi_cmd;1429 struct iscsit_cmd *cmd = isert_cmd->iscsit_cmd;
1430 struct isert_conn *isert_conn = isert_cmd->conn;1430 struct isert_conn *isert_conn = isert_cmd->conn;
1431 struct iscsi_conn *conn = isert_conn->conn;1431 struct iscsit_conn *conn = isert_conn->conn;
1432 struct iscsi_text_rsp *hdr;1432 struct iscsi_text_rsp *hdr;
1433 1433
1434 isert_dbg("Cmd %p\n", isert_cmd);1434 isert_dbg("Cmd %p\n", isert_cmd);
@@ -1575,7 +1575,7 @@ isert_rdma_write_done(struct ib_cq *cq, struct ib_wc *wc) · 140 unmodified lines
1575 struct isert_device *device = isert_conn->device;1575 struct isert_device *device = isert_conn->device;
1576 struct iser_tx_desc *desc = cqe_to_tx_desc(wc->wr_cqe);1576 struct iser_tx_desc *desc = cqe_to_tx_desc(wc->wr_cqe);
1577 struct isert_cmd *isert_cmd = tx_desc_to_cmd(desc);1577 struct isert_cmd *isert_cmd = tx_desc_to_cmd(desc);
1578 struct se_cmd *cmd = &isert_cmd->iscsi_cmd->se_cmd;1578 struct se_cmd *cmd = &isert_cmd->iscsit_cmd->se_cmd;
1579 int ret = 0;1579 int ret = 0;
1580 1580
1581 if (unlikely(wc->status != IB_WC_SUCCESS)) {1581 if (unlikely(wc->status != IB_WC_SUCCESS)) {
@@ -1604,7 +1604,7 @@ isert_rdma_write_done(struct ib_cq *cq, struct ib_wc *wc) · 22 unmodified lines
1604 /*1604 /*
1605 * XXX: isert_put_response() failure is not retried.1605 * XXX: isert_put_response() failure is not retried.
1606 */1606 */
1607 ret = isert_put_response(isert_conn->conn, isert_cmd->iscsi_cmd);1607 ret = isert_put_response(isert_conn->conn, isert_cmd->iscsit_cmd);
1608 if (ret)1608 if (ret)
1609 pr_warn_ratelimited("isert_put_response() ret: %d\n", ret);1609 pr_warn_ratelimited("isert_put_response() ret: %d\n", ret);
1610 }1610 }
@@ -1617,7 +1617,7 @@ isert_rdma_read_done(struct ib_cq *cq, struct ib_wc *wc) · 6 unmodified lines
1617 struct isert_device *device = isert_conn->device;1617 struct isert_device *device = isert_conn->device;
1618 struct iser_tx_desc *desc = cqe_to_tx_desc(wc->wr_cqe);1618 struct iser_tx_desc *desc = cqe_to_tx_desc(wc->wr_cqe);
1619 struct isert_cmd *isert_cmd = tx_desc_to_cmd(desc);1619 struct isert_cmd *isert_cmd = tx_desc_to_cmd(desc);
1620 struct iscsi_cmd *cmd = isert_cmd->iscsi_cmd;1620 struct iscsit_cmd *cmd = isert_cmd->iscsit_cmd;
1621 struct se_cmd *se_cmd = &cmd->se_cmd;1621 struct se_cmd *se_cmd = &cmd->se_cmd;
1622 int ret = 0;1622 int ret = 0;
1623 1623
@@ -1662,7 +1662,7 @@ isert_do_control_comp(struct work_struct *work) · 38 unmodified lines
1662 struct isert_cmd, comp_work);1662 struct isert_cmd, comp_work);
1663 struct isert_conn *isert_conn = isert_cmd->conn;1663 struct isert_conn *isert_conn = isert_cmd->conn;
1664 struct ib_device *ib_dev = isert_conn->cm_id->device;1664 struct ib_device *ib_dev = isert_conn->cm_id->device;
1665 struct iscsi_cmd *cmd = isert_cmd->iscsi_cmd;1665 struct iscsit_cmd *cmd = isert_cmd->iscsit_cmd;
1666 1666
1667 isert_dbg("Cmd %p i_state %d\n", isert_cmd, cmd->i_state);1667 isert_dbg("Cmd %p i_state %d\n", isert_cmd, cmd->i_state);
1668 1668
@@ -1720,7 +1720,7 @@ isert_send_done(struct ib_cq *cq, struct ib_wc *wc) · 51 unmodified lines
1720 1720
1721 isert_dbg("Cmd %p\n", isert_cmd);1721 isert_dbg("Cmd %p\n", isert_cmd);
1722 1722
1723 switch (isert_cmd->iscsi_cmd->i_state) {1723 switch (isert_cmd->iscsit_cmd->i_state) {
1724 case ISTATE_SEND_TASKMGTRSP:1724 case ISTATE_SEND_TASKMGTRSP:
1725 case ISTATE_SEND_LOGOUTRSP:1725 case ISTATE_SEND_LOGOUTRSP:
1726 case ISTATE_SEND_REJECT:1726 case ISTATE_SEND_REJECT:
@@ -1731,7 +1731,7 @@ isert_send_done(struct ib_cq *cq, struct ib_wc *wc) · 4 unmodified lines
1731 queue_work(isert_comp_wq, &isert_cmd->comp_work);1731 queue_work(isert_comp_wq, &isert_cmd->comp_work);
1732 return;1732 return;
1733 default:1733 default:
1734 isert_cmd->iscsi_cmd->i_state = ISTATE_SENT_STATUS;1734 isert_cmd->iscsit_cmd->i_state = ISTATE_SENT_STATUS;
1735 isert_completion_put(tx_desc, isert_cmd, ib_dev, false);1735 isert_completion_put(tx_desc, isert_cmd, ib_dev, false);
1736 break;1736 break;
1737 }1737 }
@@ -1755,7 +1755,7 @@ isert_post_response(struct isert_conn *isert_conn, struct isert_cmd *isert_cmd) · 17 unmodified lines
1755}1755}
1756 1756
1757static int1757static int
1758isert_put_response(struct iscsi_conn *conn, struct iscsi_cmd *cmd)1758isert_put_response(struct iscsit_conn *conn, struct iscsit_cmd *cmd)
1759{1759{
1760 struct isert_cmd *isert_cmd = iscsit_priv_cmd(cmd);1760 struct isert_cmd *isert_cmd = iscsit_priv_cmd(cmd);
1761 struct isert_conn *isert_conn = conn->context;1761 struct isert_conn *isert_conn = conn->context;
@@ -1806,7 +1806,7 @@ isert_put_response(struct iscsi_conn *conn, struct iscsi_cmd *cmd) · 44 unmodified lines
1806}1806}
1807 1807
1808static void1808static void
1809isert_aborted_task(struct iscsi_conn *conn, struct iscsi_cmd *cmd)1809isert_aborted_task(struct iscsit_conn *conn, struct iscsit_cmd *cmd)
1810{1810{
1811 struct isert_cmd *isert_cmd = iscsit_priv_cmd(cmd);1811 struct isert_cmd *isert_cmd = iscsit_priv_cmd(cmd);
1812 struct isert_conn *isert_conn = conn->context;1812 struct isert_conn *isert_conn = conn->context;
@@ -1822,7 +1822,7 @@ isert_aborted_task(struct iscsi_conn *conn, struct iscsi_cmd *cmd) · 9 unmodified lines
1822}1822}
1823 1823
1824static enum target_prot_op1824static enum target_prot_op
1825isert_get_sup_prot_ops(struct iscsi_conn *conn)1825isert_get_sup_prot_ops(struct iscsit_conn *conn)
1826{1826{
1827 struct isert_conn *isert_conn = conn->context;1827 struct isert_conn *isert_conn = conn->context;
1828 struct isert_device *device = isert_conn->device;1828 struct isert_device *device = isert_conn->device;
@@ -1842,7 +1842,7 @@ isert_get_sup_prot_ops(struct iscsi_conn *conn) · 13 unmodified lines
1842}1842}
1843 1843
1844static int1844static int
1845isert_put_nopin(struct iscsi_cmd *cmd, struct iscsi_conn *conn,1845isert_put_nopin(struct iscsit_cmd *cmd, struct iscsit_conn *conn,
1846 bool nopout_response)1846 bool nopout_response)
1847{1847{
1848 struct isert_cmd *isert_cmd = iscsit_priv_cmd(cmd);1848 struct isert_cmd *isert_cmd = iscsit_priv_cmd(cmd);
@@ -1862,7 +1862,7 @@ isert_put_nopin(struct iscsi_cmd *cmd, struct iscsi_conn *conn, · 13 unmodified lines
1862}1862}
1863 1863
1864static int1864static int
1865isert_put_logout_rsp(struct iscsi_cmd *cmd, struct iscsi_conn *conn)1865isert_put_logout_rsp(struct iscsit_cmd *cmd, struct iscsit_conn *conn)
1866{1866{
1867 struct isert_cmd *isert_cmd = iscsit_priv_cmd(cmd);1867 struct isert_cmd *isert_cmd = iscsit_priv_cmd(cmd);
1868 struct isert_conn *isert_conn = conn->context;1868 struct isert_conn *isert_conn = conn->context;
@@ -1880,7 +1880,7 @@ isert_put_logout_rsp(struct iscsi_cmd *cmd, struct iscsi_conn *conn) · 11 unmodified lines
1880}1880}
1881 1881
1882static int1882static int
1883isert_put_tm_rsp(struct iscsi_cmd *cmd, struct iscsi_conn *conn)1883isert_put_tm_rsp(struct iscsit_cmd *cmd, struct iscsit_conn *conn)
1884{1884{
1885 struct isert_cmd *isert_cmd = iscsit_priv_cmd(cmd);1885 struct isert_cmd *isert_cmd = iscsit_priv_cmd(cmd);
1886 struct isert_conn *isert_conn = conn->context;1886 struct isert_conn *isert_conn = conn->context;
@@ -1898,7 +1898,7 @@ isert_put_tm_rsp(struct iscsi_cmd *cmd, struct iscsi_conn *conn) · 11 unmodified lines
1898}1898}
1899 1899
1900static int1900static int
1901isert_put_reject(struct iscsi_cmd *cmd, struct iscsi_conn *conn)1901isert_put_reject(struct iscsit_cmd *cmd, struct iscsit_conn *conn)
1902{1902{
1903 struct isert_cmd *isert_cmd = iscsit_priv_cmd(cmd);1903 struct isert_cmd *isert_cmd = iscsit_priv_cmd(cmd);
1904 struct isert_conn *isert_conn = conn->context;1904 struct isert_conn *isert_conn = conn->context;
@@ -1933,7 +1933,7 @@ isert_put_reject(struct iscsi_cmd *cmd, struct iscsi_conn *conn) · 28 unmodified lines
1933}1933}
1934 1934
1935static int1935static int
1936isert_put_text_rsp(struct iscsi_cmd *cmd, struct iscsi_conn *conn)1936isert_put_text_rsp(struct iscsit_cmd *cmd, struct iscsit_conn *conn)
1937{1937{
1938 struct isert_cmd *isert_cmd = iscsit_priv_cmd(cmd);1938 struct isert_cmd *isert_cmd = iscsit_priv_cmd(cmd);
1939 struct isert_conn *isert_conn = conn->context;1939 struct isert_conn *isert_conn = conn->context;
@@ -2035,7 +2035,7 @@ static int · 95 unmodified lines
2035isert_rdma_rw_ctx_post(struct isert_cmd *cmd, struct isert_conn *conn,2035isert_rdma_rw_ctx_post(struct isert_cmd *cmd, struct isert_conn *conn,
2036 struct ib_cqe *cqe, struct ib_send_wr *chain_wr)2036 struct ib_cqe *cqe, struct ib_send_wr *chain_wr)
2037{2037{
2038 struct se_cmd *se_cmd = &cmd->iscsi_cmd->se_cmd;2038 struct se_cmd *se_cmd = &cmd->iscsit_cmd->se_cmd;
2039 enum dma_data_direction dir = target_reverse_dma_direction(se_cmd);2039 enum dma_data_direction dir = target_reverse_dma_direction(se_cmd);
2040 u8 port_num = conn->cm_id->port_num;2040 u8 port_num = conn->cm_id->port_num;
2041 u64 addr;2041 u64 addr;
@@ -2048,7 +2048,7 @@ isert_rdma_rw_ctx_post(struct isert_cmd *cmd, struct isert_conn *conn, · 6 unmodified lines
2048 if (dir == DMA_FROM_DEVICE) {2048 if (dir == DMA_FROM_DEVICE) {
2049 addr = cmd->write_va;2049 addr = cmd->write_va;
2050 rkey = cmd->write_stag;2050 rkey = cmd->write_stag;
2051 offset = cmd->iscsi_cmd->write_data_done;2051 offset = cmd->iscsit_cmd->write_data_done;
2052 } else {2052 } else {
2053 addr = cmd->read_va;2053 addr = cmd->read_va;
2054 rkey = cmd->read_stag;2054 rkey = cmd->read_stag;
@@ -2088,7 +2088,7 @@ rdma_ctx_post: · 33 unmodified lines
2088}2088}
2089 2089
2090static int2090static int
2091isert_put_datain(struct iscsi_conn *conn, struct iscsi_cmd *cmd)2091isert_put_datain(struct iscsit_conn *conn, struct iscsit_cmd *cmd)
2092{2092{
2093 struct se_cmd *se_cmd = &cmd->se_cmd;2093 struct se_cmd *se_cmd = &cmd->se_cmd;
2094 struct isert_cmd *isert_cmd = iscsit_priv_cmd(cmd);2094 struct isert_cmd *isert_cmd = iscsit_priv_cmd(cmd);
@@ -2129,7 +2129,7 @@ isert_put_datain(struct iscsi_conn *conn, struct iscsi_cmd *cmd) · 34 unmodified lines
2129}2129}
2130 2130
2131static int2131static int
2132isert_get_dataout(struct iscsi_conn *conn, struct iscsi_cmd *cmd, bool recovery)2132isert_get_dataout(struct iscsit_conn *conn, struct iscsit_cmd *cmd, bool recovery)
2133{2133{
2134 struct isert_cmd *isert_cmd = iscsit_priv_cmd(cmd);2134 struct isert_cmd *isert_cmd = iscsit_priv_cmd(cmd);
2135 int ret;2135 int ret;
@@ -2147,7 +2147,7 @@ isert_get_dataout(struct iscsi_conn *conn, struct iscsi_cmd *cmd, bool recovery) · 11 unmodified lines
2147}2147}
2148 2148
2149static int2149static int
2150isert_immediate_queue(struct iscsi_conn *conn, struct iscsi_cmd *cmd, int state)2150isert_immediate_queue(struct iscsit_conn *conn, struct iscsit_cmd *cmd, int state)
2151{2151{
2152 struct isert_cmd *isert_cmd = iscsit_priv_cmd(cmd);2152 struct isert_cmd *isert_cmd = iscsit_priv_cmd(cmd);
2153 int ret = 0;2153 int ret = 0;
@@ -2172,7 +2172,7 @@ isert_immediate_queue(struct iscsi_conn *conn, struct iscsi_cmd *cmd, int state) · 18 unmodified lines
2172}2172}
2173 2173
2174static int2174static int
2175isert_response_queue(struct iscsi_conn *conn, struct iscsi_cmd *cmd, int state)2175isert_response_queue(struct iscsit_conn *conn, struct iscsit_cmd *cmd, int state)
2176{2176{
2177 struct isert_conn *isert_conn = conn->context;2177 struct isert_conn *isert_conn = conn->context;
2178 int ret;2178 int ret;
@@ -2332,7 +2332,7 @@ isert_rdma_accept(struct isert_conn *isert_conn) · 153 unmodified lines
2332}2332}
2333 2333
2334static int2334static int
2335isert_get_login_rx(struct iscsi_conn *conn, struct iscsi_login *login)2335isert_get_login_rx(struct iscsit_conn *conn, struct iscsi_login *login)
2336{2336{
2337 struct isert_conn *isert_conn = conn->context;2337 struct isert_conn *isert_conn = conn->context;
2338 int ret;2338 int ret;
@@ -2368,7 +2368,7 @@ isert_get_login_rx(struct iscsi_conn *conn, struct iscsi_login *login) · 29 unmodified lines
2368}2368}
2369 2369
2370static void2370static void
2371isert_set_conn_info(struct iscsi_np *np, struct iscsi_conn *conn,2371isert_set_conn_info(struct iscsi_np *np, struct iscsit_conn *conn,
2372 struct isert_conn *isert_conn)2372 struct isert_conn *isert_conn)
2373{2373{
2374 struct rdma_cm_id *cm_id = isert_conn->cm_id;2374 struct rdma_cm_id *cm_id = isert_conn->cm_id;
@@ -2381,7 +2381,7 @@ isert_set_conn_info(struct iscsi_np *np, struct iscsi_conn *conn, · 6 unmodified lines
2381}2381}
2382 2382
2383static int2383static int
2384isert_accept_np(struct iscsi_np *np, struct iscsi_conn *conn)2384isert_accept_np(struct iscsi_np *np, struct iscsit_conn *conn)
2385{2385{
2386 struct isert_np *isert_np = np->np_context;2386 struct isert_np *isert_np = np->np_context;
2387 struct isert_conn *isert_conn;2387 struct isert_conn *isert_conn;
@@ -2489,7 +2489,7 @@ static void isert_release_work(struct work_struct *work) · 101 unmodified lines
2489static void2489static void
2490isert_wait4logout(struct isert_conn *isert_conn)2490isert_wait4logout(struct isert_conn *isert_conn)
2491{2491{
2492 struct iscsi_conn *conn = isert_conn->conn;2492 struct iscsit_conn *conn = isert_conn->conn;
2493 2493
2494 isert_info("conn %p\n", isert_conn);2494 isert_info("conn %p\n", isert_conn);
2495 2495
@@ -2501,9 +2501,9 @@ isert_wait4logout(struct isert_conn *isert_conn) · 5 unmodified lines
2501}2501}
2502 2502
2503static void2503static void
2504isert_wait4cmds(struct iscsi_conn *conn)2504isert_wait4cmds(struct iscsit_conn *conn)
2505{2505{
2506 isert_info("iscsi_conn %p\n", conn);2506 isert_info("iscsit_conn %p\n", conn);
2507 2507
2508 if (conn->sess) {2508 if (conn->sess) {
2509 target_stop_session(conn->sess->se_sess);2509 target_stop_session(conn->sess->se_sess);
@@ -2521,9 +2521,9 @@ isert_wait4cmds(struct iscsi_conn *conn) · 11 unmodified lines
2521 * before blocking on the target_wait_for_session_cmds2521 * before blocking on the target_wait_for_session_cmds
2522 */2522 */
2523static void2523static void
2524isert_put_unsol_pending_cmds(struct iscsi_conn *conn)2524isert_put_unsol_pending_cmds(struct iscsit_conn *conn)
2525{2525{
2526 struct iscsi_cmd *cmd, *tmp;2526 struct iscsit_cmd *cmd, *tmp;
2527 static LIST_HEAD(drop_cmd_list);2527 static LIST_HEAD(drop_cmd_list);
2528 2528
2529 spin_lock_bh(&conn->cmd_lock);2529 spin_lock_bh(&conn->cmd_lock);
@@ -2546,7 +2546,7 @@ isert_put_unsol_pending_cmds(struct iscsi_conn *conn) · 16 unmodified lines
2546 }2546 }
2547}2547}
2548 2548
2549static void isert_wait_conn(struct iscsi_conn *conn)2549static void isert_wait_conn(struct iscsit_conn *conn)
2550{2550{
2551 struct isert_conn *isert_conn = conn->context;2551 struct isert_conn *isert_conn = conn->context;
2552 2552
@@ -2564,7 +2564,7 @@ static void isert_wait_conn(struct iscsi_conn *conn) · 11 unmodified lines
2564 queue_work(isert_release_wq, &isert_conn->release_work);2564 queue_work(isert_release_wq, &isert_conn->release_work);
2565}2565}
2566 2566
2567static void isert_free_conn(struct iscsi_conn *conn)2567static void isert_free_conn(struct iscsit_conn *conn)
2568{2568{
2569 struct isert_conn *isert_conn = conn->context;2569 struct isert_conn *isert_conn = conn->context;
2570 2570
@@ -2572,7 +2572,7 @@ static void isert_free_conn(struct iscsi_conn *conn) · 1 unmodified line
2572 isert_put_conn(isert_conn);2572 isert_put_conn(isert_conn);
2573}2573}
2574 2574
2575static void isert_get_rx_pdu(struct iscsi_conn *conn)2575static void isert_get_rx_pdu(struct iscsit_conn *conn)
2576{2576{
2577 struct completion comp;2577 struct completion comp;
2578 2578
drivers/infiniband/ulp/isert/ib_isert.h+2−2
@@ -146,7 +146,7 @@ struct isert_cmd { · 145 unmodified lines
146 u64 pdu_buf_dma;146 u64 pdu_buf_dma;
147 u32 pdu_buf_len;147 u32 pdu_buf_len;
148 struct isert_conn *conn;148 struct isert_conn *conn;
149 struct iscsi_cmd *iscsi_cmd;149 struct iscsit_cmd *iscsit_cmd;
150 struct iser_tx_desc tx_desc;150 struct iser_tx_desc tx_desc;
151 struct iser_rx_desc *rx_desc;151 struct iser_rx_desc *rx_desc;
152 struct rdma_rw_ctx rw;152 struct rdma_rw_ctx rw;
@@ -173,7 +173,7 @@ struct isert_conn { · 20 unmodified lines
173 u64 login_rsp_dma;173 u64 login_rsp_dma;
174 struct iser_rx_desc *rx_descs;174 struct iser_rx_desc *rx_descs;
175 struct ib_recv_wr rx_wr[ISERT_QP_MAX_RECV_DTOS];175 struct ib_recv_wr rx_wr[ISERT_QP_MAX_RECV_DTOS];
176 struct iscsi_conn *conn;176 struct iscsit_conn *conn;
177 struct list_head node;177 struct list_head node;
178 struct completion login_comp;178 struct completion login_comp;
179 struct completion login_req_comp;179 struct completion login_req_comp;
drivers/message/fusion/mptctl.c+0−3
@@ -2334,7 +2334,6 @@ mptctl_hp_hostinfo(MPT_ADAPTER *ioc, unsigned long arg, unsigned int data_size) · 2333 unmodified lines
2334 ToolboxIstwiReadWriteRequest_t *IstwiRWRequest;2334 ToolboxIstwiReadWriteRequest_t *IstwiRWRequest;
2335 MPT_FRAME_HDR *mf = NULL;2335 MPT_FRAME_HDR *mf = NULL;
2336 unsigned long timeleft;2336 unsigned long timeleft;
2337 int retval;
2338 u32 msgcontext;2337 u32 msgcontext;
2339 2338
2340 /* Reset long to int. Should affect IA64 and SPARC only2339 /* Reset long to int. Should affect IA64 and SPARC only
@@ -2488,7 +2487,6 @@ mptctl_hp_hostinfo(MPT_ADAPTER *ioc, unsigned long arg, unsigned int data_size) · 147 unmodified lines
2488 ioc->add_sge((char *)&IstwiRWRequest->SGL,2487 ioc->add_sge((char *)&IstwiRWRequest->SGL,
2489 (MPT_SGE_FLAGS_SSIMPLE_READ|4), buf_dma);2488 (MPT_SGE_FLAGS_SSIMPLE_READ|4), buf_dma);
2490 2489
2491 retval = 0;
2492 SET_MGMT_MSG_CONTEXT(ioc->ioctl_cmds.msg_context,2490 SET_MGMT_MSG_CONTEXT(ioc->ioctl_cmds.msg_context,
2493 IstwiRWRequest->MsgContext);2491 IstwiRWRequest->MsgContext);
2494 INITIALIZE_MGMT_STATUS(ioc->ioctl_cmds.status)2492 INITIALIZE_MGMT_STATUS(ioc->ioctl_cmds.status)
@@ -2498,7 +2496,6 @@ retry_wait: · 3 unmodified lines
2498 timeleft = wait_for_completion_timeout(&ioc->ioctl_cmds.done,2496 timeleft = wait_for_completion_timeout(&ioc->ioctl_cmds.done,
2499 HZ*MPT_IOCTL_DEFAULT_TIMEOUT);2497 HZ*MPT_IOCTL_DEFAULT_TIMEOUT);
2500 if (!(ioc->ioctl_cmds.status & MPT_MGMT_STATUS_COMMAND_GOOD)) {2498 if (!(ioc->ioctl_cmds.status & MPT_MGMT_STATUS_COMMAND_GOOD)) {
2501 retval = -ETIME;
2502 printk(MYIOC_s_WARN_FMT "%s: failed\n", ioc->name, __func__);2499 printk(MYIOC_s_WARN_FMT "%s: failed\n", ioc->name, __func__);
2503 if (ioc->ioctl_cmds.status & MPT_MGMT_STATUS_DID_IOCRESET) {2500 if (ioc->ioctl_cmds.status & MPT_MGMT_STATUS_DID_IOCRESET) {
2504 mpt_free_msg_frame(ioc, mf);2501 mpt_free_msg_frame(ioc, mf);
drivers/scsi/aacraid/aacraid.h+1−1
@@ -121,7 +121,7 @@ enum { · 120 unmodified lines
121#define SA_AIF_PDEV_CHANGE (1<<4)121#define SA_AIF_PDEV_CHANGE (1<<4)
122#define SA_AIF_LDEV_CHANGE (1<<5)122#define SA_AIF_LDEV_CHANGE (1<<5)
123#define SA_AIF_BPSTAT_CHANGE (1<<30)123#define SA_AIF_BPSTAT_CHANGE (1<<30)
124#define SA_AIF_BPCFG_CHANGE (1<<31)124#define SA_AIF_BPCFG_CHANGE (1U<<31)
125 125
126#define HBA_MAX_SG_EMBEDDED 28126#define HBA_MAX_SG_EMBEDDED 28
127#define HBA_MAX_SG_SEPARATE 90127#define HBA_MAX_SG_SEPARATE 90
drivers/scsi/aha1542.c+10−10
@@ -302,7 +302,7 @@ static irqreturn_t aha1542_interrupt(int irq, void *dev_id) · 301 unmodified lines
302 if (flag & SCRD)302 if (flag & SCRD)
303 printk("SCRD ");303 printk("SCRD ");
304 printk("status %02x\n", inb(STATUS(sh->io_port)));304 printk("status %02x\n", inb(STATUS(sh->io_port)));
305 };305 }
306#endif306#endif
307 number_serviced = 0;307 number_serviced = 0;
308 308
@@ -344,7 +344,7 @@ static irqreturn_t aha1542_interrupt(int irq, void *dev_id) · 35 unmodified lines
344 if (!number_serviced)344 if (!number_serviced)
345 shost_printk(KERN_WARNING, sh, "interrupt received, but no mail.\n");345 shost_printk(KERN_WARNING, sh, "interrupt received, but no mail.\n");
346 return IRQ_HANDLED;346 return IRQ_HANDLED;
347 };347 }
348 348
349 mbo = (scsi2int(mb[mbi].ccbptr) - (unsigned long)aha1542->ccb_handle) / sizeof(struct ccb);349 mbo = (scsi2int(mb[mbi].ccbptr) - (unsigned long)aha1542->ccb_handle) / sizeof(struct ccb);
350 mbistatus = mb[mbi].status;350 mbistatus = mb[mbi].status;
@@ -408,7 +408,7 @@ static irqreturn_t aha1542_interrupt(int irq, void *dev_id) · 57 unmodified lines
408 */408 */
409 scsi_done(tmp_cmd);409 scsi_done(tmp_cmd);
410 number_serviced++;410 number_serviced++;
411 };411 }
412}412}
413 413
414static int aha1542_queuecommand(struct Scsi_Host *sh, struct scsi_cmnd *cmd)414static int aha1542_queuecommand(struct Scsi_Host *sh, struct scsi_cmnd *cmd)
@@ -534,7 +534,7 @@ static void setup_mailboxes(struct Scsi_Host *sh) · 119 unmodified lines
534 any2scsi(aha1542->mb[i].ccbptr,534 any2scsi(aha1542->mb[i].ccbptr,
535 aha1542->ccb_handle + i * sizeof(struct ccb));535 aha1542->ccb_handle + i * sizeof(struct ccb));
536 aha1542->mb[AHA1542_MAILBOXES + i].status = 0;536 aha1542->mb[AHA1542_MAILBOXES + i].status = 0;
537 };537 }
538 aha1542_intr_reset(sh->io_port); /* reset interrupts, so they don't block */538 aha1542_intr_reset(sh->io_port); /* reset interrupts, so they don't block */
539 any2scsi(mb_cmd + 2, aha1542->mb_handle);539 any2scsi(mb_cmd + 2, aha1542->mb_handle);
540 if (aha1542_out(sh->io_port, mb_cmd, 5))540 if (aha1542_out(sh->io_port, mb_cmd, 5))
@@ -549,7 +549,7 @@ static int aha1542_getconfig(struct Scsi_Host *sh) · 8 unmodified lines
549 i = inb(STATUS(sh->io_port));549 i = inb(STATUS(sh->io_port));
550 if (i & DF) {550 if (i & DF) {
551 i = inb(DATA(sh->io_port));551 i = inb(DATA(sh->io_port));
552 };552 }
553 aha1542_outb(sh->io_port, CMD_RETCONF);553 aha1542_outb(sh->io_port, CMD_RETCONF);
554 aha1542_in(sh->io_port, inquiry_result, 3, 0);554 aha1542_in(sh->io_port, inquiry_result, 3, 0);
555 if (!wait_mask(INTRFLAGS(sh->io_port), INTRMASK, HACC, 0, 0))555 if (!wait_mask(INTRFLAGS(sh->io_port), INTRMASK, HACC, 0, 0))
@@ -578,7 +578,7 @@ static int aha1542_getconfig(struct Scsi_Host *sh) · 22 unmodified lines
578 default:578 default:
579 shost_printk(KERN_ERR, sh, "Unable to determine DMA channel.\n");579 shost_printk(KERN_ERR, sh, "Unable to determine DMA channel.\n");
580 return -1;580 return -1;
581 };581 }
582 switch (inquiry_result[1]) {582 switch (inquiry_result[1]) {
583 case 0x40:583 case 0x40:
584 sh->irq = 15;584 sh->irq = 15;
@@ -601,7 +601,7 @@ static int aha1542_getconfig(struct Scsi_Host *sh) · 16 unmodified lines
601 default:601 default:
602 shost_printk(KERN_ERR, sh, "Unable to determine IRQ level.\n");602 shost_printk(KERN_ERR, sh, "Unable to determine IRQ level.\n");
603 return -1;603 return -1;
604 };604 }
605 sh->this_id = inquiry_result[2] & 7;605 sh->this_id = inquiry_result[2] & 7;
606 return 0;606 return 0;
607}607}
@@ -636,7 +636,7 @@ static int aha1542_mbenable(struct Scsi_Host *sh) · 28 unmodified lines
636 636
637 if (aha1542_out(sh->io_port, mbenable_cmd, 3))637 if (aha1542_out(sh->io_port, mbenable_cmd, 3))
638 goto fail;638 goto fail;
639 };639 }
640 while (0) {640 while (0) {
641fail:641fail:
642 shost_printk(KERN_ERR, sh, "Mailbox init failed\n");642 shost_printk(KERN_ERR, sh, "Mailbox init failed\n");
@@ -654,7 +654,7 @@ static int aha1542_query(struct Scsi_Host *sh) · 11 unmodified lines
654 i = inb(STATUS(sh->io_port));654 i = inb(STATUS(sh->io_port));
655 if (i & DF) {655 if (i & DF) {
656 i = inb(DATA(sh->io_port));656 i = inb(DATA(sh->io_port));
657 };657 }
658 aha1542_outb(sh->io_port, CMD_INQUIRY);658 aha1542_outb(sh->io_port, CMD_INQUIRY);
659 aha1542_in(sh->io_port, inquiry_result, 4, 0);659 aha1542_in(sh->io_port, inquiry_result, 4, 0);
660 if (!wait_mask(INTRFLAGS(sh->io_port), INTRMASK, HACC, 0, 0))660 if (!wait_mask(INTRFLAGS(sh->io_port), INTRMASK, HACC, 0, 0))
@@ -673,7 +673,7 @@ static int aha1542_query(struct Scsi_Host *sh) · 12 unmodified lines
673 if (inquiry_result[0] == 0x43) {673 if (inquiry_result[0] == 0x43) {
674 shost_printk(KERN_INFO, sh, "Emulation mode not supported for AHA-1740 hardware, use aha1740 driver instead.\n");674 shost_printk(KERN_INFO, sh, "Emulation mode not supported for AHA-1740 hardware, use aha1740 driver instead.\n");
675 return 1;675 return 1;
676 };676 }
677 677
678 /*678 /*
679 * Always call this - boards that do not support extended bios translation679 * Always call this - boards that do not support extended bios translation
drivers/scsi/bfa/bfad_debugfs.c+1−2
@@ -371,8 +371,7 @@ bfad_debugfs_release_fwtrc(struct inode *inode, struct file *file) · 370 unmodified lines
371 if (!fw_debug)371 if (!fw_debug)
372 return 0;372 return 0;
373 373
374 if (fw_debug->debug_buffer)374 vfree(fw_debug->debug_buffer);
375 vfree(fw_debug->debug_buffer);
376 375
377 file->private_data = NULL;376 file->private_data = NULL;
378 kfree(fw_debug);377 kfree(fw_debug);
drivers/scsi/bfa/bfad_im.c+0−1
@@ -755,7 +755,6 @@ void · 754 unmodified lines
755bfad_destroy_workq(struct bfad_im_s *im)755bfad_destroy_workq(struct bfad_im_s *im)
756{756{
757 if (im && im->drv_workq) {757 if (im && im->drv_workq) {
758 flush_workqueue(im->drv_workq);
759 destroy_workqueue(im->drv_workq);758 destroy_workqueue(im->drv_workq);
760 im->drv_workq = NULL;759 im->drv_workq = NULL;
761 }760 }
drivers/scsi/bnx2fc/bnx2fc_fcoe.c+6−16
@@ -273,7 +273,6 @@ static int bnx2fc_xmit(struct fc_lport *lport, struct fc_frame *fp) · 272 unmodified lines
273 struct fcoe_port *port;273 struct fcoe_port *port;
274 struct fcoe_hdr *hp;274 struct fcoe_hdr *hp;
275 struct bnx2fc_rport *tgt;275 struct bnx2fc_rport *tgt;
276 struct fc_stats *stats;
277 u8 sof, eof;276 u8 sof, eof;
278 u32 crc;277 u32 crc;
279 unsigned int hlen, tlen, elen;278 unsigned int hlen, tlen, elen;
@@ -399,10 +398,8 @@ static int bnx2fc_xmit(struct fc_lport *lport, struct fc_frame *fp) · 119 unmodified lines
399 }398 }
400 399
401 /*update tx stats */400 /*update tx stats */
402 stats = per_cpu_ptr(lport->stats, get_cpu());401 this_cpu_inc(lport->stats->TxFrames);
403 stats->TxFrames++;402 this_cpu_add(lport->stats->TxWords, wlen);
404 stats->TxWords += wlen;
405 put_cpu();
406 403
407 /* send down to lld */404 /* send down to lld */
408 fr_dev(fp) = lport;405 fr_dev(fp) = lport;
@@ -512,7 +509,6 @@ static void bnx2fc_recv_frame(struct sk_buff *skb) · 103 unmodified lines
512 u32 fr_len, fr_crc;509 u32 fr_len, fr_crc;
513 struct fc_lport *lport;510 struct fc_lport *lport;
514 struct fcoe_rcv_info *fr;511 struct fcoe_rcv_info *fr;
515 struct fc_stats *stats;
516 struct fc_frame_header *fh;512 struct fc_frame_header *fh;
517 struct fcoe_crc_eof crc_eof;513 struct fcoe_crc_eof crc_eof;
518 struct fc_frame *fp;514 struct fc_frame *fp;
@@ -543,10 +539,8 @@ static void bnx2fc_recv_frame(struct sk_buff *skb) · 24 unmodified lines
543 skb_pull(skb, sizeof(struct fcoe_hdr));539 skb_pull(skb, sizeof(struct fcoe_hdr));
544 fr_len = skb->len - sizeof(struct fcoe_crc_eof);540 fr_len = skb->len - sizeof(struct fcoe_crc_eof);
545 541
546 stats = per_cpu_ptr(lport->stats, get_cpu());542 this_cpu_inc(lport->stats->RxFrames);
547 stats->RxFrames++;543 this_cpu_add(lport->stats->RxWords, fr_len / FCOE_WORD_TO_BYTE);
548 stats->RxWords += fr_len / FCOE_WORD_TO_BYTE;
549 put_cpu();
550 544
551 fp = (struct fc_frame *)skb;545 fp = (struct fc_frame *)skb;
552 fc_frame_init(fp);546 fc_frame_init(fp);
@@ -633,9 +627,7 @@ static void bnx2fc_recv_frame(struct sk_buff *skb) · 80 unmodified lines
633 fr_crc = le32_to_cpu(fr_crc(fp));627 fr_crc = le32_to_cpu(fr_crc(fp));
634 628
635 if (unlikely(fr_crc != ~crc32(~0, skb->data, fr_len))) {629 if (unlikely(fr_crc != ~crc32(~0, skb->data, fr_len))) {
636 stats = per_cpu_ptr(lport->stats, get_cpu());630 crc_err = this_cpu_inc_return(lport->stats->InvalidCRCCount);
637 crc_err = (stats->InvalidCRCCount++);
638 put_cpu();
639 if (crc_err < 5)631 if (crc_err < 5)
640 printk(KERN_WARNING PFX "dropping frame with "632 printk(KERN_WARNING PFX "dropping frame with "
641 "CRC error\n");633 "CRC error\n");
@@ -964,9 +956,7 @@ static void bnx2fc_indicate_netevent(void *context, unsigned long event, · 322 unmodified lines
964 mutex_unlock(&lport->lp_mutex);956 mutex_unlock(&lport->lp_mutex);
965 fc_host_port_type(lport->host) =957 fc_host_port_type(lport->host) =
966 FC_PORTTYPE_UNKNOWN;958 FC_PORTTYPE_UNKNOWN;
967 per_cpu_ptr(lport->stats,959 this_cpu_inc(lport->stats->LinkFailureCount);
968 get_cpu())->LinkFailureCount++;
969 put_cpu();
970 fcoe_clean_pending_queue(lport);960 fcoe_clean_pending_queue(lport);
971 wait_for_upload = 1;961 wait_for_upload = 1;
972 }962 }
drivers/scsi/bnx2fc/bnx2fc_io.c+6−11
@@ -472,7 +472,7 @@ struct bnx2fc_cmd *bnx2fc_cmd_alloc(struct bnx2fc_rport *tgt) · 471 unmodified lines
472 u32 free_sqes;472 u32 free_sqes;
473 u32 max_sqes;473 u32 max_sqes;
474 u16 xid;474 u16 xid;
475 int index = get_cpu();475 int index = raw_smp_processor_id();
476 476
477 max_sqes = BNX2FC_SCSI_MAX_SQES;477 max_sqes = BNX2FC_SCSI_MAX_SQES;
478 /*478 /*
@@ -485,7 +485,6 @@ struct bnx2fc_cmd *bnx2fc_cmd_alloc(struct bnx2fc_rport *tgt) · 6 unmodified lines
485 (tgt->num_active_ios.counter >= max_sqes) ||485 (tgt->num_active_ios.counter >= max_sqes) ||
486 (free_sqes + max_sqes <= BNX2FC_SQ_WQES_MAX)) {486 (free_sqes + max_sqes <= BNX2FC_SQ_WQES_MAX)) {
487 spin_unlock_bh(&cmd_mgr->free_list_lock[index]);487 spin_unlock_bh(&cmd_mgr->free_list_lock[index]);
488 put_cpu();
489 return NULL;488 return NULL;
490 }489 }
491 490
@@ -498,7 +497,6 @@ struct bnx2fc_cmd *bnx2fc_cmd_alloc(struct bnx2fc_rport *tgt) · 6 unmodified lines
498 atomic_inc(&tgt->num_active_ios);497 atomic_inc(&tgt->num_active_ios);
499 atomic_dec(&tgt->free_sqes);498 atomic_dec(&tgt->free_sqes);
500 spin_unlock_bh(&cmd_mgr->free_list_lock[index]);499 spin_unlock_bh(&cmd_mgr->free_list_lock[index]);
501 put_cpu();
502 500
503 INIT_LIST_HEAD(&io_req->link);501 INIT_LIST_HEAD(&io_req->link);
504 502
@@ -2032,7 +2030,6 @@ int bnx2fc_post_io_req(struct bnx2fc_rport *tgt, · 1527 unmodified lines
2032 struct bnx2fc_interface *interface = port->priv;2030 struct bnx2fc_interface *interface = port->priv;
2033 struct bnx2fc_hba *hba = interface->hba;2031 struct bnx2fc_hba *hba = interface->hba;
2034 struct fc_lport *lport = port->lport;2032 struct fc_lport *lport = port->lport;
2035 struct fc_stats *stats;
2036 int task_idx, index;2033 int task_idx, index;
2037 u16 xid;2034 u16 xid;
2038 2035
@@ -2045,20 +2042,18 @@ int bnx2fc_post_io_req(struct bnx2fc_rport *tgt, · 6 unmodified lines
2045 io_req->data_xfer_len = scsi_bufflen(sc_cmd);2042 io_req->data_xfer_len = scsi_bufflen(sc_cmd);
2046 bnx2fc_priv(sc_cmd)->io_req = io_req;2043 bnx2fc_priv(sc_cmd)->io_req = io_req;
2047 2044
2048 stats = per_cpu_ptr(lport->stats, get_cpu());
2049 if (sc_cmd->sc_data_direction == DMA_FROM_DEVICE) {2045 if (sc_cmd->sc_data_direction == DMA_FROM_DEVICE) {
2050 io_req->io_req_flags = BNX2FC_READ;2046 io_req->io_req_flags = BNX2FC_READ;
2051 stats->InputRequests++;2047 this_cpu_inc(lport->stats->InputRequests);
2052 stats->InputBytes += io_req->data_xfer_len;2048 this_cpu_add(lport->stats->InputBytes, io_req->data_xfer_len);
2053 } else if (sc_cmd->sc_data_direction == DMA_TO_DEVICE) {2049 } else if (sc_cmd->sc_data_direction == DMA_TO_DEVICE) {
2054 io_req->io_req_flags = BNX2FC_WRITE;2050 io_req->io_req_flags = BNX2FC_WRITE;
2055 stats->OutputRequests++;2051 this_cpu_inc(lport->stats->OutputRequests);
2056 stats->OutputBytes += io_req->data_xfer_len;2052 this_cpu_add(lport->stats->OutputBytes, io_req->data_xfer_len);
2057 } else {2053 } else {
2058 io_req->io_req_flags = 0;2054 io_req->io_req_flags = 0;
2059 stats->ControlRequests++;2055 this_cpu_inc(lport->stats->ControlRequests);
2060 }2056 }
2061 put_cpu();
2062 2057
2063 xid = io_req->xid;2058 xid = io_req->xid;
2064 2059
drivers/scsi/dc395x.c+12−3
@@ -3585,10 +3585,19 @@ static struct DeviceCtlBlk *device_alloc(struct AdapterCtlBlk *acb, · 3584 unmodified lines
3585#endif3585#endif
3586 if (dcb->target_lun != 0) {3586 if (dcb->target_lun != 0) {
3587 /* Copy settings */3587 /* Copy settings */
3588 struct DeviceCtlBlk *p;3588 struct DeviceCtlBlk *p = NULL, *iter;
3589 list_for_each_entry(p, &acb->dcb_list, list)3589
3590 if (p->target_id == dcb->target_id)3590 list_for_each_entry(iter, &acb->dcb_list, list)
3591 if (iter->target_id == dcb->target_id) {
3592 p = iter;
3591 break;3593 break;
3594 }
3595
3596 if (!p) {
3597 kfree(dcb);
3598 return NULL;
3599 }
3600
3592 dprintkdbg(DBG_1, 3601 dprintkdbg(DBG_1,
3593 "device_alloc: <%02i-%i> copy from <%02i-%i>\n",3602 "device_alloc: <%02i-%i> copy from <%02i-%i>\n",
3594 dcb->target_id, dcb->target_lun,3603 dcb->target_id, dcb->target_lun,
drivers/scsi/dpt_i2o.c+0−1
@@ -1000,7 +1000,6 @@ static int adpt_install_hba(struct scsi_host_template* sht, struct pci_dev* pDev · 999 unmodified lines
1000 1000
1001 // Initializing the spinlocks1001 // Initializing the spinlocks
1002 spin_lock_init(&pHba->state_lock);1002 spin_lock_init(&pHba->state_lock);
1003 spin_lock_init(&adpt_post_wait_lock);
1004 1003
1005 if(raptorFlag == 0){1004 if(raptorFlag == 0){
1006 printk(KERN_INFO "Adaptec I2O RAID controller"1005 printk(KERN_INFO "Adaptec I2O RAID controller"
drivers/scsi/elx/efct/efct_hw.c+0−1
@@ -1402,7 +1402,6 @@ efct_hw_command(struct efct_hw *hw, u8 *cmd, u32 opts, void *cb, void *arg) · 1401 unmodified lines
1402 mutex_lock(&hw->bmbx_lock);1402 mutex_lock(&hw->bmbx_lock);
1403 bmbx = hw->sli.bmbx.virt;1403 bmbx = hw->sli.bmbx.virt;
1404 1404
1405 memset(bmbx, 0, SLI4_BMBX_SIZE);
1406 memcpy(bmbx, cmd, SLI4_BMBX_SIZE);1405 memcpy(bmbx, cmd, SLI4_BMBX_SIZE);
1407 1406
1408 if (sli_bmbx_command(&hw->sli) == 0) {1407 if (sli_bmbx_command(&hw->sli) == 0) {
drivers/scsi/elx/efct/efct_io.c+0−1
@@ -62,7 +62,6 @@ efct_io_pool_create(struct efct *efct, u32 num_sgl) · 61 unmodified lines
62 return NULL;62 return NULL;
63 }63 }
64 64
65 memset(io->sgl, 0, sizeof(*io->sgl) * num_sgl);
66 io->sgl_allocated = num_sgl;65 io->sgl_allocated = num_sgl;
67 io->sgl_count = 0;66 io->sgl_count = 0;
68 67
drivers/scsi/elx/efct/efct_lio.c+0−3
@@ -370,9 +370,6 @@ static int efct_lio_get_cmd_state(struct se_cmd *cmd) · 369 unmodified lines
370 container_of(cmd, struct efct_scsi_tgt_io, cmd);370 container_of(cmd, struct efct_scsi_tgt_io, cmd);
371 struct efct_io *io = container_of(ocp, struct efct_io, tgt_io);371 struct efct_io *io = container_of(ocp, struct efct_io, tgt_io);
372 372
373 if (!io)
374 return 0;
375
376 return io->tgt_io.state;373 return io->tgt_io.state;
377}374}
378 375
drivers/scsi/fcoe/fcoe.c+17−27
@@ -1434,8 +1434,7 @@ static int fcoe_rcv(struct sk_buff *skb, struct net_device *netdev, · 1433 unmodified lines
1434 1434
1435 return NET_RX_SUCCESS;1435 return NET_RX_SUCCESS;
1436err:1436err:
1437 per_cpu_ptr(lport->stats, get_cpu())->ErrorFrames++;1437 this_cpu_inc(lport->stats->ErrorFrames);
1438 put_cpu();
1439err2:1438err2:
1440 kfree_skb(skb);1439 kfree_skb(skb);
1441 return NET_RX_DROP;1440 return NET_RX_DROP;
@@ -1453,9 +1452,10 @@ static int fcoe_alloc_paged_crc_eof(struct sk_buff *skb, int tlen) · 11 unmodified lines
1453 struct fcoe_percpu_s *fps;1452 struct fcoe_percpu_s *fps;
1454 int rc;1453 int rc;
1455 1454
1456 fps = &get_cpu_var(fcoe_percpu);1455 local_lock(&fcoe_percpu.lock);
1456 fps = this_cpu_ptr(&fcoe_percpu);
1457 rc = fcoe_get_paged_crc_eof(skb, tlen, fps);1457 rc = fcoe_get_paged_crc_eof(skb, tlen, fps);
1458 put_cpu_var(fcoe_percpu);1458 local_unlock(&fcoe_percpu.lock);
1459 1459
1460 return rc;1460 return rc;
1461}1461}
@@ -1474,7 +1474,6 @@ static int fcoe_xmit(struct fc_lport *lport, struct fc_frame *fp) · 12 unmodified lines
1474 struct ethhdr *eh;1474 struct ethhdr *eh;
1475 struct fcoe_crc_eof *cp;1475 struct fcoe_crc_eof *cp;
1476 struct sk_buff *skb;1476 struct sk_buff *skb;
1477 struct fc_stats *stats;
1478 struct fc_frame_header *fh;1477 struct fc_frame_header *fh;
1479 unsigned int hlen; /* header length implies the version */1478 unsigned int hlen; /* header length implies the version */
1480 unsigned int tlen; /* trailer length */1479 unsigned int tlen; /* trailer length */
@@ -1585,10 +1584,8 @@ static int fcoe_xmit(struct fc_lport *lport, struct fc_frame *fp) · 104 unmodified lines
1585 skb_shinfo(skb)->gso_size = 0;1584 skb_shinfo(skb)->gso_size = 0;
1586 }1585 }
1587 /* update tx stats: regardless if LLD fails */1586 /* update tx stats: regardless if LLD fails */
1588 stats = per_cpu_ptr(lport->stats, get_cpu());1587 this_cpu_inc(lport->stats->TxFrames);
1589 stats->TxFrames++;1588 this_cpu_add(lport->stats->TxWords, wlen);
1590 stats->TxWords += wlen;
1591 put_cpu();
1592 1589
1593 /* send down to lld */1590 /* send down to lld */
1594 fr_dev(fp) = lport;1591 fr_dev(fp) = lport;
@@ -1610,7 +1607,6 @@ static inline int fcoe_filter_frames(struct fc_lport *lport, · 15 unmodified lines
1610 struct fcoe_interface *fcoe;1607 struct fcoe_interface *fcoe;
1611 struct fc_frame_header *fh;1608 struct fc_frame_header *fh;
1612 struct sk_buff *skb = (struct sk_buff *)fp;1609 struct sk_buff *skb = (struct sk_buff *)fp;
1613 struct fc_stats *stats;
1614 1610
1615 /*1611 /*
1616 * We only check CRC if no offload is available and if it is1612 * We only check CRC if no offload is available and if it is
@@ -1640,11 +1636,8 @@ static inline int fcoe_filter_frames(struct fc_lport *lport, · 23 unmodified lines
1640 return 0;1636 return 0;
1641 }1637 }
1642 1638
1643 stats = per_cpu_ptr(lport->stats, get_cpu());1639 if (this_cpu_inc_return(lport->stats->InvalidCRCCount) < 5)
1644 stats->InvalidCRCCount++;
1645 if (stats->InvalidCRCCount < 5)
1646 printk(KERN_WARNING "fcoe: dropping frame with CRC error\n");1640 printk(KERN_WARNING "fcoe: dropping frame with CRC error\n");
1647 put_cpu();
1648 return -EINVAL;1641 return -EINVAL;
1649}1642}
1650 1643
@@ -1657,7 +1650,6 @@ static void fcoe_recv_frame(struct sk_buff *skb) · 6 unmodified lines
1657 u32 fr_len;1650 u32 fr_len;
1658 struct fc_lport *lport;1651 struct fc_lport *lport;
1659 struct fcoe_rcv_info *fr;1652 struct fcoe_rcv_info *fr;
1660 struct fc_stats *stats;
1661 struct fcoe_crc_eof crc_eof;1653 struct fcoe_crc_eof crc_eof;
1662 struct fc_frame *fp;1654 struct fc_frame *fp;
1663 struct fcoe_hdr *hp;1655 struct fcoe_hdr *hp;
@@ -1685,9 +1677,11 @@ static void fcoe_recv_frame(struct sk_buff *skb) · 21 unmodified lines
1685 */1677 */
1686 hp = (struct fcoe_hdr *) skb_network_header(skb);1678 hp = (struct fcoe_hdr *) skb_network_header(skb);
1687 1679
1688 stats = per_cpu_ptr(lport->stats, get_cpu());
1689 if (unlikely(FC_FCOE_DECAPS_VER(hp) != FC_FCOE_VER)) {1680 if (unlikely(FC_FCOE_DECAPS_VER(hp) != FC_FCOE_VER)) {
1690 if (stats->ErrorFrames < 5)1681 struct fc_stats *stats;
1682
1683 stats = per_cpu_ptr(lport->stats, raw_smp_processor_id());
1684 if (READ_ONCE(stats->ErrorFrames) < 5)
1691 printk(KERN_WARNING "fcoe: FCoE version "1685 printk(KERN_WARNING "fcoe: FCoE version "
1692 "mismatch: The frame has "1686 "mismatch: The frame has "
1693 "version %x, but the "1687 "version %x, but the "
@@ -1700,8 +1694,8 @@ static void fcoe_recv_frame(struct sk_buff *skb) · 6 unmodified lines
1700 skb_pull(skb, sizeof(struct fcoe_hdr));1694 skb_pull(skb, sizeof(struct fcoe_hdr));
1701 fr_len = skb->len - sizeof(struct fcoe_crc_eof);1695 fr_len = skb->len - sizeof(struct fcoe_crc_eof);
1702 1696
1703 stats->RxFrames++;1697 this_cpu_inc(lport->stats->RxFrames);
1704 stats->RxWords += fr_len / FCOE_WORD_TO_BYTE;1698 this_cpu_add(lport->stats->RxWords, fr_len / FCOE_WORD_TO_BYTE);
1705 1699
1706 fp = (struct fc_frame *)skb;1700 fp = (struct fc_frame *)skb;
1707 fc_frame_init(fp);1701 fc_frame_init(fp);
@@ -1717,13 +1711,11 @@ static void fcoe_recv_frame(struct sk_buff *skb) · 9 unmodified lines
1717 goto drop;1711 goto drop;
1718 1712
1719 if (!fcoe_filter_frames(lport, fp)) {1713 if (!fcoe_filter_frames(lport, fp)) {
1720 put_cpu();
1721 fc_exch_recv(lport, fp);1714 fc_exch_recv(lport, fp);
1722 return;1715 return;
1723 }1716 }
1724drop:1717drop:
1725 stats->ErrorFrames++;1718 this_cpu_inc(lport->stats->ErrorFrames);
1726 put_cpu();
1727 kfree_skb(skb);1719 kfree_skb(skb);
1728}1720}
1729 1721
@@ -1847,7 +1839,6 @@ static int fcoe_device_notification(struct notifier_block *notifier, · 117 unmodified lines
1847 struct net_device *netdev = netdev_notifier_info_to_dev(ptr);1839 struct net_device *netdev = netdev_notifier_info_to_dev(ptr);
1848 struct fcoe_ctlr *ctlr;1840 struct fcoe_ctlr *ctlr;
1849 struct fcoe_interface *fcoe;1841 struct fcoe_interface *fcoe;
1850 struct fc_stats *stats;
1851 u32 link_possible = 1;1842 u32 link_possible = 1;
1852 u32 mfs;1843 u32 mfs;
1853 int rc = NOTIFY_OK;1844 int rc = NOTIFY_OK;
@@ -1921,9 +1912,7 @@ static int fcoe_device_notification(struct notifier_block *notifier, · 67 unmodified lines
1921 break;1912 break;
1922 case FCOE_CTLR_ENABLED:1913 case FCOE_CTLR_ENABLED:
1923 case FCOE_CTLR_UNUSED:1914 case FCOE_CTLR_UNUSED:
1924 stats = per_cpu_ptr(lport->stats, get_cpu());1915 this_cpu_inc(lport->stats->LinkFailureCount);
1925 stats->LinkFailureCount++;
1926 put_cpu();
1927 fcoe_clean_pending_queue(lport);1916 fcoe_clean_pending_queue(lport);
1928 }1917 }
1929 }1918 }
@@ -2488,6 +2477,7 @@ static int __init fcoe_init(void) · 558 unmodified lines
2488 p = per_cpu_ptr(&fcoe_percpu, cpu);2477 p = per_cpu_ptr(&fcoe_percpu, cpu);
2489 INIT_WORK(&p->work, fcoe_receive_work);2478 INIT_WORK(&p->work, fcoe_receive_work);
2490 skb_queue_head_init(&p->fcoe_rx_list);2479 skb_queue_head_init(&p->fcoe_rx_list);
2480 local_lock_init(&p->lock);
2491 }2481 }
2492 2482
2493 /* Setup link change notification */2483 /* Setup link change notification */
@@ -2580,7 +2570,7 @@ static void fcoe_flogi_resp(struct fc_seq *seq, struct fc_frame *fp, void *arg) · 86 unmodified lines
2580 /* pre-FIP */2570 /* pre-FIP */
2581 if (is_zero_ether_addr(mac))2571 if (is_zero_ether_addr(mac))
2582 fcoe_ctlr_recv_flogi(fip, lport, fp);2572 fcoe_ctlr_recv_flogi(fip, lport, fp);
2583 if (!is_zero_ether_addr(mac))2573 else
2584 fcoe_update_src_mac(lport, mac);2574 fcoe_update_src_mac(lport, mac);
2585done:2575done:
2586 fc_lport_flogi_resp(seq, fp, lport);2576 fc_lport_flogi_resp(seq, fp, lport);
drivers/scsi/fcoe/fcoe_ctlr.c+9−17
@@ -824,22 +824,21 @@ static unsigned long fcoe_ctlr_age_fcfs(struct fcoe_ctlr *fip) · 823 unmodified lines
824 unsigned long deadline;824 unsigned long deadline;
825 unsigned long sel_time = 0;825 unsigned long sel_time = 0;
826 struct list_head del_list;826 struct list_head del_list;
827 struct fc_stats *stats;
828 827
829 INIT_LIST_HEAD(&del_list);828 INIT_LIST_HEAD(&del_list);
830 829
831 stats = per_cpu_ptr(fip->lp->stats, get_cpu());
832
833 list_for_each_entry_safe(fcf, next, &fip->fcfs, list) {830 list_for_each_entry_safe(fcf, next, &fip->fcfs, list) {
834 deadline = fcf->time + fcf->fka_period + fcf->fka_period / 2;831 deadline = fcf->time + fcf->fka_period + fcf->fka_period / 2;
835 if (fip->sel_fcf == fcf) {832 if (fip->sel_fcf == fcf) {
836 if (time_after(jiffies, deadline)) {833 if (time_after(jiffies, deadline)) {
837 stats->MissDiscAdvCount++;834 u64 miss_cnt;
835
836 miss_cnt = this_cpu_inc_return(fip->lp->stats->MissDiscAdvCount);
838 printk(KERN_INFO "libfcoe: host%d: "837 printk(KERN_INFO "libfcoe: host%d: "
839 "Missing Discovery Advertisement "838 "Missing Discovery Advertisement "
840 "for fab %16.16llx count %lld\n",839 "for fab %16.16llx count %lld\n",
841 fip->lp->host->host_no, fcf->fabric_name,840 fip->lp->host->host_no, fcf->fabric_name,
842 stats->MissDiscAdvCount);841 miss_cnt);
843 } else if (time_after(next_timer, deadline))842 } else if (time_after(next_timer, deadline))
844 next_timer = deadline;843 next_timer = deadline;
845 }844 }
@@ -855,7 +854,7 @@ static unsigned long fcoe_ctlr_age_fcfs(struct fcoe_ctlr *fip) · 9 unmodified lines
855 */854 */
856 list_del(&fcf->list);855 list_del(&fcf->list);
857 list_add(&fcf->list, &del_list);856 list_add(&fcf->list, &del_list);
858 stats->VLinkFailureCount++;857 this_cpu_inc(fip->lp->stats->VLinkFailureCount);
859 } else {858 } else {
860 if (time_after(next_timer, deadline))859 if (time_after(next_timer, deadline))
861 next_timer = deadline;860 next_timer = deadline;
@@ -864,7 +863,6 @@ static unsigned long fcoe_ctlr_age_fcfs(struct fcoe_ctlr *fip) · 2 unmodified lines
864 sel_time = fcf->time;863 sel_time = fcf->time;
865 }864 }
866 }865 }
867 put_cpu();
868 866
869 list_for_each_entry_safe(fcf, next, &del_list, list) {867 list_for_each_entry_safe(fcf, next, &del_list, list) {
870 /* Removes fcf from current list */868 /* Removes fcf from current list */
@@ -1142,7 +1140,6 @@ static void fcoe_ctlr_recv_els(struct fcoe_ctlr *fip, struct sk_buff *skb) · 271 unmodified lines
1142 struct fip_desc *desc;1140 struct fip_desc *desc;
1143 struct fip_encaps *els;1141 struct fip_encaps *els;
1144 struct fcoe_fcf *sel;1142 struct fcoe_fcf *sel;
1145 struct fc_stats *stats;
1146 enum fip_desc_type els_dtype = 0;1143 enum fip_desc_type els_dtype = 0;
1147 u8 els_op;1144 u8 els_op;
1148 u8 sub;1145 u8 sub;
@@ -1286,10 +1283,8 @@ static void fcoe_ctlr_recv_els(struct fcoe_ctlr *fip, struct sk_buff *skb) · 137 unmodified lines
1286 fr_dev(fp) = lport;1283 fr_dev(fp) = lport;
1287 fr_encaps(fp) = els_dtype;1284 fr_encaps(fp) = els_dtype;
1288 1285
1289 stats = per_cpu_ptr(lport->stats, get_cpu());1286 this_cpu_inc(lport->stats->RxFrames);
1290 stats->RxFrames++;1287 this_cpu_add(lport->stats->RxWords, skb->len / FIP_BPW);
1291 stats->RxWords += skb->len / FIP_BPW;
1292 put_cpu();
1293 1288
1294 fc_exch_recv(lport, fp);1289 fc_exch_recv(lport, fp);
1295 return;1290 return;
@@ -1427,9 +1422,7 @@ static void fcoe_ctlr_recv_clr_vlink(struct fcoe_ctlr *fip, · 131 unmodified lines
1427 ntoh24(vp->fd_fc_id));1422 ntoh24(vp->fd_fc_id));
1428 if (vn_port && (vn_port == lport)) {1423 if (vn_port && (vn_port == lport)) {
1429 mutex_lock(&fip->ctlr_mutex);1424 mutex_lock(&fip->ctlr_mutex);
1430 per_cpu_ptr(lport->stats,1425 this_cpu_inc(lport->stats->VLinkFailureCount);
1431 get_cpu())->VLinkFailureCount++;
1432 put_cpu();
1433 fcoe_ctlr_reset(fip);1426 fcoe_ctlr_reset(fip);
1434 mutex_unlock(&fip->ctlr_mutex);1427 mutex_unlock(&fip->ctlr_mutex);
1435 }1428 }
@@ -1457,8 +1450,7 @@ static void fcoe_ctlr_recv_clr_vlink(struct fcoe_ctlr *fip, · 21 unmodified lines
1457 * followed by physical port1450 * followed by physical port
1458 */1451 */
1459 mutex_lock(&fip->ctlr_mutex);1452 mutex_lock(&fip->ctlr_mutex);
1460 per_cpu_ptr(lport->stats, get_cpu())->VLinkFailureCount++;1453 this_cpu_inc(lport->stats->VLinkFailureCount);
1461 put_cpu();
1462 fcoe_ctlr_reset(fip);1454 fcoe_ctlr_reset(fip);
1463 mutex_unlock(&fip->ctlr_mutex);1455 mutex_unlock(&fip->ctlr_mutex);
1464 1456
drivers/scsi/fcoe/fcoe_transport.c+3−3
@@ -183,9 +183,9 @@ void __fcoe_get_lesb(struct fc_lport *lport, · 182 unmodified lines
183 memset(lesb, 0, sizeof(*lesb));183 memset(lesb, 0, sizeof(*lesb));
184 for_each_possible_cpu(cpu) {184 for_each_possible_cpu(cpu) {
185 stats = per_cpu_ptr(lport->stats, cpu);185 stats = per_cpu_ptr(lport->stats, cpu);
186 lfc += stats->LinkFailureCount;186 lfc += READ_ONCE(stats->LinkFailureCount);
187 vlfc += stats->VLinkFailureCount;187 vlfc += READ_ONCE(stats->VLinkFailureCount);
188 mdac += stats->MissDiscAdvCount;188 mdac += READ_ONCE(stats->MissDiscAdvCount);
189 }189 }
190 lesb->lesb_link_fail = htonl(lfc);190 lesb->lesb_link_fail = htonl(lfc);
191 lesb->lesb_vlink_fail = htonl(vlfc);191 lesb->lesb_vlink_fail = htonl(vlfc);
drivers/scsi/fnic/fnic.h+1−1
@@ -39,7 +39,7 @@ · 38 unmodified lines
39 39
40#define DRV_NAME "fnic"40#define DRV_NAME "fnic"
41#define DRV_DESCRIPTION "Cisco FCoE HBA Driver"41#define DRV_DESCRIPTION "Cisco FCoE HBA Driver"
42#define DRV_VERSION "1.6.0.53"42#define DRV_VERSION "1.6.0.54"
43#define PFX DRV_NAME ": "43#define PFX DRV_NAME ": "
44#define DFX DRV_NAME "%d: "44#define DFX DRV_NAME "%d: "
45 45
drivers/scsi/fnic/fnic_debugfs.c+1−2
@@ -86,8 +86,7 @@ void fnic_debugfs_terminate(void) · 85 unmodified lines
86 debugfs_remove(fnic_trace_debugfs_root);86 debugfs_remove(fnic_trace_debugfs_root);
87 fnic_trace_debugfs_root = NULL;87 fnic_trace_debugfs_root = NULL;
88 88
89 if (fc_trc_flag)89 vfree(fc_trc_flag);
90 vfree(fc_trc_flag);
91}90}
92 91
93/*92/*
drivers/scsi/fnic/fnic_main.c+4−6
@@ -612,10 +612,10 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · 611 unmodified lines
612 pci_set_master(pdev);612 pci_set_master(pdev);
613 613
614 /* Query PCI controller on system for DMA addressing614 /* Query PCI controller on system for DMA addressing
615 * limitation for the device. Try 64-bit first, and615 * limitation for the device. Try 47-bit first, and
616 * fail to 32-bit.616 * fail to 32-bit. Cisco VIC supports 47 bits only.
617 */617 */
618 err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));618 err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(47));
619 if (err) {619 if (err) {
620 err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));620 err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
621 if (err) {621 if (err) {
@@ -1146,10 +1146,8 @@ static void __exit fnic_cleanup_module(void) · 524 unmodified lines
1146{1146{
1147 pci_unregister_driver(&fnic_driver);1147 pci_unregister_driver(&fnic_driver);
1148 destroy_workqueue(fnic_event_queue);1148 destroy_workqueue(fnic_event_queue);
1149 if (fnic_fip_queue) {1149 if (fnic_fip_queue)
1150 flush_workqueue(fnic_fip_queue);
1151 destroy_workqueue(fnic_fip_queue);1150 destroy_workqueue(fnic_fip_queue);
1152 }
1153 kmem_cache_destroy(fnic_sgl_cache[FNIC_SGL_CACHE_MAX]);1151 kmem_cache_destroy(fnic_sgl_cache[FNIC_SGL_CACHE_MAX]);
1154 kmem_cache_destroy(fnic_sgl_cache[FNIC_SGL_CACHE_DFLT]);1152 kmem_cache_destroy(fnic_sgl_cache[FNIC_SGL_CACHE_DFLT]);
1155 kmem_cache_destroy(fnic_io_req_cache);1153 kmem_cache_destroy(fnic_io_req_cache);
drivers/scsi/hisi_sas/hisi_sas_main.c+32−36
@@ -446,6 +446,8 @@ void hisi_sas_task_deliver(struct hisi_hba *hisi_hba, · 445 unmodified lines
446 return;446 return;
447 }447 }
448 448
449 /* Make slot memories observable before marking as ready */
450 smp_wmb();
449 WRITE_ONCE(slot->ready, 1);451 WRITE_ONCE(slot->ready, 1);
450 452
451 spin_lock(&dq->lock);453 spin_lock(&dq->lock);
@@ -709,8 +711,6 @@ static int hisi_sas_init_device(struct domain_device *device) · 257 unmodified lines
709 struct scsi_lun lun;711 struct scsi_lun lun;
710 int retry = HISI_SAS_DISK_RECOVER_CNT;712 int retry = HISI_SAS_DISK_RECOVER_CNT;
711 struct hisi_hba *hisi_hba = dev_to_hisi_hba(device);713 struct hisi_hba *hisi_hba = dev_to_hisi_hba(device);
712 struct device *dev = hisi_hba->dev;
713 struct sas_phy *local_phy;
714 714
715 switch (device->dev_type) {715 switch (device->dev_type) {
716 case SAS_END_DEVICE:716 case SAS_END_DEVICE:
@@ -729,30 +729,18 @@ static int hisi_sas_init_device(struct domain_device *device) · 12 unmodified lines
729 case SAS_SATA_PM_PORT:729 case SAS_SATA_PM_PORT:
730 case SAS_SATA_PENDING:730 case SAS_SATA_PENDING:
731 /*731 /*
732 * send HARD RESET to clear previous affiliation of732 * If an expander is swapped when a SATA disk is attached then
733 * STP target port733 * we should issue a hard reset to clear previous affiliation
734 * of STP target port, see SPL (chapter 6.19.4).
735 *
736 * However we don't need to issue a hard reset here for these
737 * reasons:
738 * a. When probing the device, libsas/libata already issues a
739 * hard reset in sas_probe_sata() -> ata_sas_async_probe().
740 * Note that in hisi_sas_debug_I_T_nexus_reset() we take care
741 * to issue a hard reset by checking the dev status (== INIT).
742 * b. When resetting the controller, this is simply unnecessary.
734 */743 */
735 local_phy = sas_get_local_phy(device);
736 if (!scsi_is_sas_phy_local(local_phy) &&
737 !test_bit(HISI_SAS_RESETTING_BIT, &hisi_hba->flags)) {
738 unsigned long deadline = ata_deadline(jiffies, 20000);
739 struct sata_device *sata_dev = &device->sata_dev;
740 struct ata_host *ata_host = sata_dev->ata_host;
741 struct ata_port_operations *ops = ata_host->ops;
742 struct ata_port *ap = sata_dev->ap;
743 struct ata_link *link;
744 unsigned int classes;
745
746 ata_for_each_link(link, ap, EDGE)
747 rc = ops->hardreset(link, &classes,
748 deadline);
749 }
750 sas_put_local_phy(local_phy);
751 if (rc) {
752 dev_warn(dev, "SATA disk hardreset fail: %d\n", rc);
753 return rc;
754 }
755
756 while (retry-- > 0) {744 while (retry-- > 0) {
757 rc = hisi_sas_softreset_ata_disk(device);745 rc = hisi_sas_softreset_ata_disk(device);
758 if (!rc)746 if (!rc)
@@ -768,15 +756,19 @@ static int hisi_sas_init_device(struct domain_device *device) · 9 unmodified lines
768 756
769int hisi_sas_slave_alloc(struct scsi_device *sdev)757int hisi_sas_slave_alloc(struct scsi_device *sdev)
770{758{
771 struct domain_device *ddev;759 struct domain_device *ddev = sdev_to_domain_dev(sdev);
760 struct hisi_sas_device *sas_dev = ddev->lldd_dev;
772 int rc;761 int rc;
773 762
774 rc = sas_slave_alloc(sdev);763 rc = sas_slave_alloc(sdev);
775 if (rc)764 if (rc)
776 return rc;765 return rc;
777 ddev = sdev_to_domain_dev(sdev);
778 766
779 return hisi_sas_init_device(ddev);767 rc = hisi_sas_init_device(ddev);
768 if (rc)
769 return rc;
770 sas_dev->dev_status = HISI_SAS_DEV_NORMAL;
771 return 0;
780}772}
781EXPORT_SYMBOL_GPL(hisi_sas_slave_alloc);773EXPORT_SYMBOL_GPL(hisi_sas_slave_alloc);
782 774
@@ -826,7 +818,6 @@ static int hisi_sas_dev_found(struct domain_device *device) · 43 unmodified lines
826 dev_info(dev, "dev[%d:%x] found\n",818 dev_info(dev, "dev[%d:%x] found\n",
827 sas_dev->device_id, sas_dev->dev_type);819 sas_dev->device_id, sas_dev->dev_type);
828 820
829 sas_dev->dev_status = HISI_SAS_DEV_NORMAL;
830 return 0;821 return 0;
831 822
832err_out:823err_out:
@@ -1710,13 +1701,18 @@ static int hisi_sas_debug_I_T_nexus_reset(struct domain_device *device) · 877 unmodified lines
1710 /* report PHY down if timed out */1701 /* report PHY down if timed out */
1711 if (rc == -ETIMEDOUT)1702 if (rc == -ETIMEDOUT)
1712 hisi_sas_phy_down(hisi_hba, sas_phy->id, 0, GFP_KERNEL);1703 hisi_sas_phy_down(hisi_hba, sas_phy->id, 0, GFP_KERNEL);
1713 } else if (sas_dev->dev_status != HISI_SAS_DEV_INIT) {1704 return rc;
1714 /*1705 }
1715 * If in init state, we rely on caller to wait for link to be1706
1716 * ready; otherwise, except phy reset is fail, delay.1707 if (rc)
1717 */1708 return rc;
1718 if (!rc)1709
1719 msleep(2000);1710 /* Remote phy */
1711 if (dev_is_sata(device)) {
1712 rc = sas_ata_wait_after_reset(device,
1713 HISI_SAS_WAIT_PHYUP_TIMEOUT);
1714 } else {
1715 msleep(2000);
1720 }1716 }
1721 1717
1722 return rc;1718 return rc;
drivers/scsi/hisi_sas/hisi_sas_v3_hw.c+8−2
@@ -1563,9 +1563,15 @@ static irqreturn_t phy_up_v3_hw(int phy_no, struct hisi_hba *hisi_hba) · 1562 unmodified lines
1563 1563
1564 phy->port_id = port_id;1564 phy->port_id = port_id;
1565 1565
1566 /* Call pm_runtime_put_sync() with pairs in hisi_sas_phyup_pm_work() */1566 /*
1567 * Call pm_runtime_get_noresume() which pairs with
1568 * hisi_sas_phyup_pm_work() -> pm_runtime_put_sync().
1569 * For failure call pm_runtime_put() as we are in a hardirq context.
1570 */
1567 pm_runtime_get_noresume(dev);1571 pm_runtime_get_noresume(dev);
1568 hisi_sas_notify_phy_event(phy, HISI_PHYE_PHY_UP_PM);1572 res = hisi_sas_notify_phy_event(phy, HISI_PHYE_PHY_UP_PM);
1573 if (!res)
1574 pm_runtime_put(dev);
1569 1575
1570 res = IRQ_HANDLED;1576 res = IRQ_HANDLED;
1571 1577
drivers/scsi/hosts.c+4−4
@@ -229,10 +229,6 @@ int scsi_add_host_with_dma(struct Scsi_Host *shost, struct device *dev, · 228 unmodified lines
229 if (error)229 if (error)
230 goto fail;230 goto fail;
231 231
232 error = scsi_mq_setup_tags(shost);
233 if (error)
234 goto fail;
235
236 if (!shost->shost_gendev.parent)232 if (!shost->shost_gendev.parent)
237 shost->shost_gendev.parent = dev ? dev : &platform_bus;233 shost->shost_gendev.parent = dev ? dev : &platform_bus;
238 if (!dma_dev)234 if (!dma_dev)
@@ -240,6 +236,10 @@ int scsi_add_host_with_dma(struct Scsi_Host *shost, struct device *dev, · 1 unmodified line
240 236
241 shost->dma_dev = dma_dev;237 shost->dma_dev = dma_dev;
242 238
239 error = scsi_mq_setup_tags(shost);
240 if (error)
241 goto fail;
242
243 /*243 /*
244 * Increase usage count temporarily here so that calling244 * Increase usage count temporarily here so that calling
245 * scsi_autopm_put_host() will trigger runtime idle if there is245 * scsi_autopm_put_host() will trigger runtime idle if there is
drivers/scsi/ipr.c+6−7
@@ -3456,7 +3456,7 @@ static ssize_t ipr_read_trace(struct file *filp, struct kobject *kobj, · 3455 unmodified lines
3456 struct bin_attribute *bin_attr,3456 struct bin_attribute *bin_attr,
3457 char *buf, loff_t off, size_t count)3457 char *buf, loff_t off, size_t count)
3458{3458{
3459 struct device *dev = container_of(kobj, struct device, kobj);3459 struct device *dev = kobj_to_dev(kobj);
3460 struct Scsi_Host *shost = class_to_shost(dev);3460 struct Scsi_Host *shost = class_to_shost(dev);
3461 struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata;3461 struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata;
3462 unsigned long lock_flags = 0;3462 unsigned long lock_flags = 0;
@@ -4182,7 +4182,7 @@ static ssize_t ipr_read_async_err_log(struct file *filep, struct kobject *kobj, · 719 unmodified lines
4182 struct bin_attribute *bin_attr, char *buf,4182 struct bin_attribute *bin_attr, char *buf,
4183 loff_t off, size_t count)4183 loff_t off, size_t count)
4184{4184{
4185 struct device *cdev = container_of(kobj, struct device, kobj);4185 struct device *cdev = kobj_to_dev(kobj);
4186 struct Scsi_Host *shost = class_to_shost(cdev);4186 struct Scsi_Host *shost = class_to_shost(cdev);
4187 struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata;4187 struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata;
4188 struct ipr_hostrcb *hostrcb;4188 struct ipr_hostrcb *hostrcb;
@@ -4206,7 +4206,7 @@ static ssize_t ipr_next_async_err_log(struct file *filep, struct kobject *kobj, · 17 unmodified lines
4206 struct bin_attribute *bin_attr, char *buf,4206 struct bin_attribute *bin_attr, char *buf,
4207 loff_t off, size_t count)4207 loff_t off, size_t count)
4208{4208{
4209 struct device *cdev = container_of(kobj, struct device, kobj);4209 struct device *cdev = kobj_to_dev(kobj);
4210 struct Scsi_Host *shost = class_to_shost(cdev);4210 struct Scsi_Host *shost = class_to_shost(cdev);
4211 struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata;4211 struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata;
4212 struct ipr_hostrcb *hostrcb;4212 struct ipr_hostrcb *hostrcb;
@@ -4267,7 +4267,7 @@ static ssize_t ipr_read_dump(struct file *filp, struct kobject *kobj, · 54 unmodified lines
4267 struct bin_attribute *bin_attr,4267 struct bin_attribute *bin_attr,
4268 char *buf, loff_t off, size_t count)4268 char *buf, loff_t off, size_t count)
4269{4269{
4270 struct device *cdev = container_of(kobj, struct device, kobj);4270 struct device *cdev = kobj_to_dev(kobj);
4271 struct Scsi_Host *shost = class_to_shost(cdev);4271 struct Scsi_Host *shost = class_to_shost(cdev);
4272 struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata;4272 struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata;
4273 struct ipr_dump *dump;4273 struct ipr_dump *dump;
@@ -4456,7 +4456,7 @@ static ssize_t ipr_write_dump(struct file *filp, struct kobject *kobj, · 182 unmodified lines
4456 struct bin_attribute *bin_attr,4456 struct bin_attribute *bin_attr,
4457 char *buf, loff_t off, size_t count)4457 char *buf, loff_t off, size_t count)
4458{4458{
4459 struct device *cdev = container_of(kobj, struct device, kobj);4459 struct device *cdev = kobj_to_dev(kobj);
4460 struct Scsi_Host *shost = class_to_shost(cdev);4460 struct Scsi_Host *shost = class_to_shost(cdev);
4461 struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata;4461 struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata;
4462 int rc;4462 int rc;
@@ -10092,7 +10092,6 @@ static irqreturn_t ipr_test_intr(int irq, void *devp) · 5629 unmodified lines
10092{10092{
10093 struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)devp;10093 struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)devp;
10094 unsigned long lock_flags = 0;10094 unsigned long lock_flags = 0;
10095 irqreturn_t rc = IRQ_HANDLED;
10096 10095
10097 dev_info(&ioa_cfg->pdev->dev, "Received IRQ : %d\n", irq);10096 dev_info(&ioa_cfg->pdev->dev, "Received IRQ : %d\n", irq);
10098 spin_lock_irqsave(ioa_cfg->host->host_lock, lock_flags);10097 spin_lock_irqsave(ioa_cfg->host->host_lock, lock_flags);
@@ -10101,7 +10100,7 @@ static irqreturn_t ipr_test_intr(int irq, void *devp) · 2 unmodified lines
10101 wake_up(&ioa_cfg->msi_wait_q);10100 wake_up(&ioa_cfg->msi_wait_q);
10102 10101
10103 spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags);10102 spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags);
10104 return rc;10103 return IRQ_HANDLED;
10105}10104}
10106 10105
10107/**10106/**
drivers/scsi/libfc/fc_exch.c+1−2
@@ -825,10 +825,9 @@ static struct fc_exch *fc_exch_em_alloc(struct fc_lport *lport, · 824 unmodified lines
825 }825 }
826 memset(ep, 0, sizeof(*ep));826 memset(ep, 0, sizeof(*ep));
827 827
828 cpu = get_cpu();828 cpu = raw_smp_processor_id();
829 pool = per_cpu_ptr(mp->pool, cpu);829 pool = per_cpu_ptr(mp->pool, cpu);
830 spin_lock_bh(&pool->lock);830 spin_lock_bh(&pool->lock);
831 put_cpu();
832 831
833 /* peek cache of free slot */832 /* peek cache of free slot */
834 if (pool->left != FC_XID_UNKNOWN) {833 if (pool->left != FC_XID_UNKNOWN) {
drivers/scsi/libfc/fc_fcp.c+10−19
@@ -143,8 +143,7 @@ static struct fc_fcp_pkt *fc_fcp_pkt_alloc(struct fc_lport *lport, gfp_t gfp) · 142 unmodified lines
143 INIT_LIST_HEAD(&fsp->list);143 INIT_LIST_HEAD(&fsp->list);
144 spin_lock_init(&fsp->scsi_pkt_lock);144 spin_lock_init(&fsp->scsi_pkt_lock);
145 } else {145 } else {
146 per_cpu_ptr(lport->stats, get_cpu())->FcpPktAllocFails++;146 this_cpu_inc(lport->stats->FcpPktAllocFails);
147 put_cpu();
148 }147 }
149 return fsp;148 return fsp;
150}149}
@@ -266,8 +265,7 @@ static int fc_fcp_send_abort(struct fc_fcp_pkt *fsp) · 115 unmodified lines
266 if (!fsp->seq_ptr)265 if (!fsp->seq_ptr)
267 return -EINVAL;266 return -EINVAL;
268 267
269 per_cpu_ptr(fsp->lp->stats, get_cpu())->FcpPktAborts++;268 this_cpu_inc(fsp->lp->stats->FcpPktAborts);
270 put_cpu();
271 269
272 fsp->state |= FC_SRB_ABORT_PENDING;270 fsp->state |= FC_SRB_ABORT_PENDING;
273 rc = fc_seq_exch_abort(fsp->seq_ptr, 0);271 rc = fc_seq_exch_abort(fsp->seq_ptr, 0);
@@ -436,8 +434,7 @@ static inline struct fc_frame *fc_fcp_frame_alloc(struct fc_lport *lport, · 162 unmodified lines
436 if (likely(fp))434 if (likely(fp))
437 return fp;435 return fp;
438 436
439 per_cpu_ptr(lport->stats, get_cpu())->FcpFrameAllocFails++;437 this_cpu_inc(lport->stats->FcpFrameAllocFails);
440 put_cpu();
441 /* error case */438 /* error case */
442 fc_fcp_can_queue_ramp_down(lport);439 fc_fcp_can_queue_ramp_down(lport);
443 shost_printk(KERN_ERR, lport->host,440 shost_printk(KERN_ERR, lport->host,
@@ -471,7 +468,6 @@ static void fc_fcp_recv_data(struct fc_fcp_pkt *fsp, struct fc_frame *fp) · 27 unmodified lines
471{468{
472 struct scsi_cmnd *sc = fsp->cmd;469 struct scsi_cmnd *sc = fsp->cmd;
473 struct fc_lport *lport = fsp->lp;470 struct fc_lport *lport = fsp->lp;
474 struct fc_stats *stats;
475 struct fc_frame_header *fh;471 struct fc_frame_header *fh;
476 size_t start_offset;472 size_t start_offset;
477 size_t offset;473 size_t offset;
@@ -533,14 +529,12 @@ static void fc_fcp_recv_data(struct fc_fcp_pkt *fsp, struct fc_frame *fp) · 55 unmodified lines
533 529
534 if (~crc != le32_to_cpu(fr_crc(fp))) {530 if (~crc != le32_to_cpu(fr_crc(fp))) {
535crc_err:531crc_err:
536 stats = per_cpu_ptr(lport->stats, get_cpu());532 this_cpu_inc(lport->stats->ErrorFrames);
537 stats->ErrorFrames++;
538 /* per cpu count, not total count, but OK for limit */533 /* per cpu count, not total count, but OK for limit */
539 if (stats->InvalidCRCCount++ < FC_MAX_ERROR_CNT)534 if (this_cpu_inc_return(lport->stats->InvalidCRCCount) < FC_MAX_ERROR_CNT)
540 printk(KERN_WARNING "libfc: CRC error on data "535 printk(KERN_WARNING "libfc: CRC error on data "
541 "frame for port (%6.6x)\n",536 "frame for port (%6.6x)\n",
542 lport->port_id);537 lport->port_id);
543 put_cpu();
544 /*538 /*
545 * Assume the frame is total garbage.539 * Assume the frame is total garbage.
546 * We may have copied it over the good part540 * We may have copied it over the good part
@@ -1861,7 +1855,6 @@ int fc_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *sc_cmd) · 1314 unmodified lines
1861 struct fc_fcp_pkt *fsp;1855 struct fc_fcp_pkt *fsp;
1862 int rval;1856 int rval;
1863 int rc = 0;1857 int rc = 0;
1864 struct fc_stats *stats;
1865 1858
1866 rval = fc_remote_port_chkready(rport);1859 rval = fc_remote_port_chkready(rport);
1867 if (rval) {1860 if (rval) {
@@ -1913,20 +1906,18 @@ int fc_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *sc_cmd) · 45 unmodified lines
1913 /*1906 /*
1914 * setup the data direction1907 * setup the data direction
1915 */1908 */
1916 stats = per_cpu_ptr(lport->stats, get_cpu());
1917 if (sc_cmd->sc_data_direction == DMA_FROM_DEVICE) {1909 if (sc_cmd->sc_data_direction == DMA_FROM_DEVICE) {
1918 fsp->req_flags = FC_SRB_READ;1910 fsp->req_flags = FC_SRB_READ;
1919 stats->InputRequests++;1911 this_cpu_inc(lport->stats->InputRequests);
1920 stats->InputBytes += fsp->data_len;1912 this_cpu_add(lport->stats->InputBytes, fsp->data_len);
1921 } else if (sc_cmd->sc_data_direction == DMA_TO_DEVICE) {1913 } else if (sc_cmd->sc_data_direction == DMA_TO_DEVICE) {
1922 fsp->req_flags = FC_SRB_WRITE;1914 fsp->req_flags = FC_SRB_WRITE;
1923 stats->OutputRequests++;1915 this_cpu_inc(lport->stats->OutputRequests);
1924 stats->OutputBytes += fsp->data_len;1916 this_cpu_add(lport->stats->OutputBytes, fsp->data_len);
1925 } else {1917 } else {
1926 fsp->req_flags = 0;1918 fsp->req_flags = 0;
1927 stats->ControlRequests++;1919 this_cpu_inc(lport->stats->ControlRequests);
1928 }1920 }
1929 put_cpu();
1930 1921
1931 /*1922 /*
1932 * send it to the lower layer1923 * send it to the lower layer
drivers/scsi/libfc/fc_lport.c+15−15
@@ -308,21 +308,21 @@ struct fc_host_statistics *fc_get_host_stats(struct Scsi_Host *shost) · 307 unmodified lines
308 308
309 stats = per_cpu_ptr(lport->stats, cpu);309 stats = per_cpu_ptr(lport->stats, cpu);
310 310
311 fc_stats->tx_frames += stats->TxFrames;311 fc_stats->tx_frames += READ_ONCE(stats->TxFrames);
312 fc_stats->tx_words += stats->TxWords;312 fc_stats->tx_words += READ_ONCE(stats->TxWords);
313 fc_stats->rx_frames += stats->RxFrames;313 fc_stats->rx_frames += READ_ONCE(stats->RxFrames);
314 fc_stats->rx_words += stats->RxWords;314 fc_stats->rx_words += READ_ONCE(stats->RxWords);
315 fc_stats->error_frames += stats->ErrorFrames;315 fc_stats->error_frames += READ_ONCE(stats->ErrorFrames);
316 fc_stats->invalid_crc_count += stats->InvalidCRCCount;316 fc_stats->invalid_crc_count += READ_ONCE(stats->InvalidCRCCount);
317 fc_stats->fcp_input_requests += stats->InputRequests;317 fc_stats->fcp_input_requests += READ_ONCE(stats->InputRequests);
318 fc_stats->fcp_output_requests += stats->OutputRequests;318 fc_stats->fcp_output_requests += READ_ONCE(stats->OutputRequests);
319 fc_stats->fcp_control_requests += stats->ControlRequests;319 fc_stats->fcp_control_requests += READ_ONCE(stats->ControlRequests);
320 fcp_in_bytes += stats->InputBytes;320 fcp_in_bytes += READ_ONCE(stats->InputBytes);
321 fcp_out_bytes += stats->OutputBytes;321 fcp_out_bytes += READ_ONCE(stats->OutputBytes);
322 fc_stats->fcp_packet_alloc_failures += stats->FcpPktAllocFails;322 fc_stats->fcp_packet_alloc_failures += READ_ONCE(stats->FcpPktAllocFails);
323 fc_stats->fcp_packet_aborts += stats->FcpPktAborts;323 fc_stats->fcp_packet_aborts += READ_ONCE(stats->FcpPktAborts);
324 fc_stats->fcp_frame_alloc_failures += stats->FcpFrameAllocFails;324 fc_stats->fcp_frame_alloc_failures += READ_ONCE(stats->FcpFrameAllocFails);
325 fc_stats->link_failure_count += stats->LinkFailureCount;325 fc_stats->link_failure_count += READ_ONCE(stats->LinkFailureCount);
326 }326 }
327 fc_stats->fcp_input_megabytes = div_u64(fcp_in_bytes, 1000000);327 fc_stats->fcp_input_megabytes = div_u64(fcp_in_bytes, 1000000);
328 fc_stats->fcp_output_megabytes = div_u64(fcp_out_bytes, 1000000);328 fc_stats->fcp_output_megabytes = div_u64(fcp_out_bytes, 1000000);
drivers/scsi/libsas/sas_ata.c+27−14
@@ -358,22 +358,14 @@ static int sas_ata_printk(const char *level, const struct domain_device *ddev, · 357 unmodified lines
358 return r;358 return r;
359}359}
360 360
361static int sas_ata_hard_reset(struct ata_link *link, unsigned int *class,361int sas_ata_wait_after_reset(struct domain_device *dev, unsigned long deadline)
362 unsigned long deadline)
363{362{
364 int ret = 0, res;363 struct sata_device *sata_dev = &dev->sata_dev;
365 struct sas_phy *phy;
366 struct ata_port *ap = link->ap;
367 int (*check_ready)(struct ata_link *link);364 int (*check_ready)(struct ata_link *link);
368 struct domain_device *dev = ap->private_data;365 struct ata_port *ap = sata_dev->ap;
369 struct sas_internal *i = dev_to_sas_internal(dev);366 struct ata_link *link = &ap->link;
370 367 struct sas_phy *phy;
371 res = i->dft->lldd_I_T_nexus_reset(dev);368 int ret;
372 if (res == -ENODEV)
373 return res;
374
375 if (res != TMF_RESP_FUNC_COMPLETE)
376 sas_ata_printk(KERN_DEBUG, dev, "Unable to reset ata device?\n");
377 369
378 phy = sas_get_local_phy(dev);370 phy = sas_get_local_phy(dev);
379 if (scsi_is_sas_phy_local(phy))371 if (scsi_is_sas_phy_local(phy))
@@ -386,6 +378,27 @@ static int sas_ata_hard_reset(struct ata_link *link, unsigned int *class, · 6 unmodified lines
386 if (ret && ret != -EAGAIN)378 if (ret && ret != -EAGAIN)
387 sas_ata_printk(KERN_ERR, dev, "reset failed (errno=%d)\n", ret);379 sas_ata_printk(KERN_ERR, dev, "reset failed (errno=%d)\n", ret);
388 380
381 return ret;
382}
383EXPORT_SYMBOL_GPL(sas_ata_wait_after_reset);
384
385static int sas_ata_hard_reset(struct ata_link *link, unsigned int *class,
386 unsigned long deadline)
387{
388 struct ata_port *ap = link->ap;
389 struct domain_device *dev = ap->private_data;
390 struct sas_internal *i = dev_to_sas_internal(dev);
391 int ret;
392
393 ret = i->dft->lldd_I_T_nexus_reset(dev);
394 if (ret == -ENODEV)
395 return ret;
396
397 if (ret != TMF_RESP_FUNC_COMPLETE)
398 sas_ata_printk(KERN_DEBUG, dev, "Unable to reset ata device?\n");
399
400 ret = sas_ata_wait_after_reset(dev, deadline);
401
389 *class = dev->sata_dev.class;402 *class = dev->sata_dev.class;
390 403
391 ap->cbl = ATA_CBL_SATA;404 ap->cbl = ATA_CBL_SATA;
drivers/scsi/lpfc/lpfc.h+7−3
@@ -604,6 +604,7 @@ struct lpfc_vport { · 603 unmodified lines
604#define FC_VFI_REGISTERED 0x800000 /* VFI is registered */604#define FC_VFI_REGISTERED 0x800000 /* VFI is registered */
605#define FC_FDISC_COMPLETED 0x1000000/* FDISC completed */605#define FC_FDISC_COMPLETED 0x1000000/* FDISC completed */
606#define FC_DISC_DELAYED 0x2000000/* Delay NPort discovery */606#define FC_DISC_DELAYED 0x2000000/* Delay NPort discovery */
607#define FC_RSCN_MEMENTO 0x4000000/* RSCN cmd processed */
607 608
608 uint32_t ct_flags;609 uint32_t ct_flags;
609#define FC_CT_RFF_ID 0x1 /* RFF_ID accepted by switch */610#define FC_CT_RFF_ID 0x1 /* RFF_ID accepted by switch */
@@ -611,6 +612,7 @@ struct lpfc_vport { · 1 unmodified line
611#define FC_CT_RSNN_NN 0x4 /* RSNN_NN accepted by switch */612#define FC_CT_RSNN_NN 0x4 /* RSNN_NN accepted by switch */
612#define FC_CT_RSPN_ID 0x8 /* RSPN_ID accepted by switch */613#define FC_CT_RSPN_ID 0x8 /* RSPN_ID accepted by switch */
613#define FC_CT_RFT_ID 0x10 /* RFT_ID accepted by switch */614#define FC_CT_RFT_ID 0x10 /* RFT_ID accepted by switch */
615#define FC_CT_RPRT_DEFER 0x20 /* Defer issuing FDMI RPRT */
614 616
615 struct list_head fc_nodes;617 struct list_head fc_nodes;
616 618
@@ -713,6 +715,7 @@ struct lpfc_vport { · 96 unmodified lines
713#define LPFC_VMID_QFPA_CMPL 0x4715#define LPFC_VMID_QFPA_CMPL 0x4
714#define LPFC_VMID_QOS_ENABLED 0x8716#define LPFC_VMID_QOS_ENABLED 0x8
715#define LPFC_VMID_TIMER_ENBLD 0x10717#define LPFC_VMID_TIMER_ENBLD 0x10
718#define LPFC_VMID_TYPE_PRIO 0x20
716 struct fc_qfpa_res *qfpa_res;719 struct fc_qfpa_res *qfpa_res;
717 720
718 struct fc_vport *fc_vport;721 struct fc_vport *fc_vport;
@@ -738,9 +741,8 @@ struct lpfc_vport { · 19 unmodified lines
738 struct list_head rcv_buffer_list;741 struct list_head rcv_buffer_list;
739 unsigned long rcv_buffer_time_stamp;742 unsigned long rcv_buffer_time_stamp;
740 uint32_t vport_flag;743 uint32_t vport_flag;
741#define STATIC_VPORT 1744#define STATIC_VPORT 0x1
742#define FAWWPN_SET 2745#define FAWWPN_PARAM_CHG 0x2
743#define FAWWPN_PARAM_CHG 4
744 746
745 uint16_t fdmi_num_disc;747 uint16_t fdmi_num_disc;
746 uint32_t fdmi_hba_mask;748 uint32_t fdmi_hba_mask;
@@ -1025,6 +1027,7 @@ struct lpfc_hba { · 278 unmodified lines
1025#define LS_MDS_LINK_DOWN 0x8 /* MDS Diagnostics Link Down */1027#define LS_MDS_LINK_DOWN 0x8 /* MDS Diagnostics Link Down */
1026#define LS_MDS_LOOPBACK 0x10 /* MDS Diagnostics Link Up (Loopback) */1028#define LS_MDS_LOOPBACK 0x10 /* MDS Diagnostics Link Up (Loopback) */
1027#define LS_CT_VEN_RPA 0x20 /* Vendor RPA sent to switch */1029#define LS_CT_VEN_RPA 0x20 /* Vendor RPA sent to switch */
1030#define LS_EXTERNAL_LOOPBACK 0x40 /* External loopback plug inserted */
1028 1031
1029 uint32_t hba_flag; /* hba generic flags */1032 uint32_t hba_flag; /* hba generic flags */
1030#define HBA_ERATT_HANDLED 0x1 /* This flag is set when eratt handled */1033#define HBA_ERATT_HANDLED 0x1 /* This flag is set when eratt handled */
@@ -1057,6 +1060,7 @@ struct lpfc_hba { · 26 unmodified lines
1057#define HBA_HBEAT_INP 0x4000000 /* mbox HBEAT is in progress */1060#define HBA_HBEAT_INP 0x4000000 /* mbox HBEAT is in progress */
1058#define HBA_HBEAT_TMO 0x8000000 /* HBEAT initiated after timeout */1061#define HBA_HBEAT_TMO 0x8000000 /* HBEAT initiated after timeout */
1059#define HBA_FLOGI_OUTSTANDING 0x10000000 /* FLOGI is outstanding */1062#define HBA_FLOGI_OUTSTANDING 0x10000000 /* FLOGI is outstanding */
1063#define HBA_RHBA_CMPL 0x20000000 /* RHBA FDMI command is successful */
1060 1064
1061 struct completion *fw_dump_cmpl; /* cmpl event tracker for fw_dump */1065 struct completion *fw_dump_cmpl; /* cmpl event tracker for fw_dump */
1062 uint32_t fcp_ring_in_use; /* When polling test if intr-hndlr active*/1066 uint32_t fcp_ring_in_use; /* When polling test if intr-hndlr active*/
drivers/scsi/lpfc/lpfc_attr.c+41−14
@@ -1,7 +1,7 @@
1/*******************************************************************1/*******************************************************************
2 * This file is part of the Emulex Linux Device Driver for *2 * This file is part of the Emulex Linux Device Driver for *
3 * Fibre Channel Host Bus Adapters. *3 * Fibre Channel Host Bus Adapters. *
4 * Copyright (C) 2017-2021 Broadcom. All Rights Reserved. The term *4 * Copyright (C) 2017-2022 Broadcom. All Rights Reserved. The term *
5 * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. *5 * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. *
6 * Copyright (C) 2004-2016 Emulex. All rights reserved. *6 * Copyright (C) 2004-2016 Emulex. All rights reserved. *
7 * EMULEX and SLI are trademarks of Emulex. *7 * EMULEX and SLI are trademarks of Emulex. *
@@ -1120,12 +1120,22 @@ lpfc_link_state_show(struct device *dev, struct device_attribute *attr, · 1112 unmodified lines
1120 len += scnprintf(buf + len, PAGE_SIZE-len,1120 len += scnprintf(buf + len, PAGE_SIZE-len,
1121 " Private Loop\n");1121 " Private Loop\n");
1122 } else {1122 } else {
1123 if (vport->fc_flag & FC_FABRIC)1123 if (vport->fc_flag & FC_FABRIC) {
1124 len += scnprintf(buf + len, PAGE_SIZE-len,1124 if (phba->sli_rev == LPFC_SLI_REV4 &&
1125 " Fabric\n");1125 vport->port_type == LPFC_PHYSICAL_PORT &&
1126 else1126 phba->sli4_hba.fawwpn_flag &
1127 LPFC_FAWWPN_FABRIC)
1128 len += scnprintf(buf + len,
1129 PAGE_SIZE - len,
1130 " Fabric FA-PWWN\n");
1131 else
1132 len += scnprintf(buf + len,
1133 PAGE_SIZE - len,
1134 " Fabric\n");
1135 } else {
1127 len += scnprintf(buf + len, PAGE_SIZE-len,1136 len += scnprintf(buf + len, PAGE_SIZE-len,
1128 " Point-2-Point\n");1137 " Point-2-Point\n");
1138 }
1129 }1139 }
1130 }1140 }
1131 1141
@@ -6878,17 +6888,34 @@ lpfc_get_stats(struct Scsi_Host *shost) · 5746 unmodified lines
6878 memset(hs, 0, sizeof (struct fc_host_statistics));6888 memset(hs, 0, sizeof (struct fc_host_statistics));
6879 6889
6880 hs->tx_frames = pmb->un.varRdStatus.xmitFrameCnt;6890 hs->tx_frames = pmb->un.varRdStatus.xmitFrameCnt;
6891 hs->rx_frames = pmb->un.varRdStatus.rcvFrameCnt;
6892
6881 /*6893 /*
6882 * The MBX_READ_STATUS returns tx_k_bytes which has to6894 * The MBX_READ_STATUS returns tx_k_bytes which has to be
6883 * converted to words6895 * converted to words.
6896 *
6897 * Check if extended byte flag is set, to know when to collect upper
6898 * bits of 64 bit wide statistics counter.
6884 */6899 */
6885 hs->tx_words = (uint64_t)6900 if (pmb->un.varRdStatus.xkb & RD_ST_XKB) {
6886 ((uint64_t)pmb->un.varRdStatus.xmitByteCnt6901 hs->tx_words = (u64)
6887 * (uint64_t)256);6902 ((((u64)(pmb->un.varRdStatus.xmit_xkb &
6888 hs->rx_frames = pmb->un.varRdStatus.rcvFrameCnt;6903 RD_ST_XMIT_XKB_MASK) << 32) |
6889 hs->rx_words = (uint64_t)6904 (u64)pmb->un.varRdStatus.xmitByteCnt) *
6890 ((uint64_t)pmb->un.varRdStatus.rcvByteCnt6905 (u64)256);
6891 * (uint64_t)256);6906 hs->rx_words = (u64)
6907 ((((u64)(pmb->un.varRdStatus.rcv_xkb &
6908 RD_ST_RCV_XKB_MASK) << 32) |
6909 (u64)pmb->un.varRdStatus.rcvByteCnt) *
6910 (u64)256);
6911 } else {
6912 hs->tx_words = (uint64_t)
6913 ((uint64_t)pmb->un.varRdStatus.xmitByteCnt
6914 * (uint64_t)256);
6915 hs->rx_words = (uint64_t)
6916 ((uint64_t)pmb->un.varRdStatus.rcvByteCnt
6917 * (uint64_t)256);
6918 }
6892 6919
6893 memset(pmboxq, 0, sizeof (LPFC_MBOXQ_t));6920 memset(pmboxq, 0, sizeof (LPFC_MBOXQ_t));
6894 pmb->mbxCommand = MBX_READ_LNK_STAT;6921 pmb->mbxCommand = MBX_READ_LNK_STAT;
drivers/scsi/lpfc/lpfc_bsg.c+36−45
@@ -310,7 +310,7 @@ lpfc_bsg_send_mgmt_cmd_cmp(struct lpfc_hba *phba, · 309 unmodified lines
310 int rc = 0;310 int rc = 0;
311 u32 ulp_status, ulp_word4, total_data_placed;311 u32 ulp_status, ulp_word4, total_data_placed;
312 312
313 dd_data = cmdiocbq->context1;313 dd_data = cmdiocbq->context_un.dd_data;
314 314
315 /* Determine if job has been aborted */315 /* Determine if job has been aborted */
316 spin_lock_irqsave(&phba->ct_ev_lock, flags);316 spin_lock_irqsave(&phba->ct_ev_lock, flags);
@@ -328,10 +328,10 @@ lpfc_bsg_send_mgmt_cmd_cmp(struct lpfc_hba *phba, · 11 unmodified lines
328 spin_unlock_irqrestore(&phba->hbalock, flags);328 spin_unlock_irqrestore(&phba->hbalock, flags);
329 329
330 iocb = &dd_data->context_un.iocb;330 iocb = &dd_data->context_un.iocb;
331 ndlp = iocb->cmdiocbq->context_un.ndlp;331 ndlp = iocb->cmdiocbq->ndlp;
332 rmp = iocb->rmp;332 rmp = iocb->rmp;
333 cmp = cmdiocbq->context2;333 cmp = cmdiocbq->cmd_dmabuf;
334 bmp = cmdiocbq->context3;334 bmp = cmdiocbq->bpl_dmabuf;
335 ulp_status = get_job_ulpstatus(phba, rspiocbq);335 ulp_status = get_job_ulpstatus(phba, rspiocbq);
336 ulp_word4 = get_job_word4(phba, rspiocbq);336 ulp_word4 = get_job_word4(phba, rspiocbq);
337 total_data_placed = get_job_data_placed(phba, rspiocbq);337 total_data_placed = get_job_data_placed(phba, rspiocbq);
@@ -470,14 +470,12 @@ lpfc_bsg_send_mgmt_cmd(struct bsg_job *job) · 132 unmodified lines
470 470
471 cmdiocbq->num_bdes = num_entry;471 cmdiocbq->num_bdes = num_entry;
472 cmdiocbq->vport = phba->pport;472 cmdiocbq->vport = phba->pport;
473 cmdiocbq->context2 = cmp;473 cmdiocbq->cmd_dmabuf = cmp;
474 cmdiocbq->context3 = bmp;474 cmdiocbq->bpl_dmabuf = bmp;
475 cmdiocbq->cmd_flag |= LPFC_IO_LIBDFC;475 cmdiocbq->cmd_flag |= LPFC_IO_LIBDFC;
476 476
477 cmdiocbq->cmd_cmpl = lpfc_bsg_send_mgmt_cmd_cmp;477 cmdiocbq->cmd_cmpl = lpfc_bsg_send_mgmt_cmd_cmp;
478 cmdiocbq->context1 = dd_data;478 cmdiocbq->context_un.dd_data = dd_data;
479 cmdiocbq->context2 = cmp;
480 cmdiocbq->context3 = bmp;
481 479
482 dd_data->type = TYPE_IOCB;480 dd_data->type = TYPE_IOCB;
483 dd_data->set_job = job;481 dd_data->set_job = job;
@@ -495,8 +493,8 @@ lpfc_bsg_send_mgmt_cmd(struct bsg_job *job) · 11 unmodified lines
495 readl(phba->HCregaddr); /* flush */493 readl(phba->HCregaddr); /* flush */
496 }494 }
497 495
498 cmdiocbq->context_un.ndlp = lpfc_nlp_get(ndlp);496 cmdiocbq->ndlp = lpfc_nlp_get(ndlp);
499 if (!cmdiocbq->context_un.ndlp) {497 if (!cmdiocbq->ndlp) {
500 rc = -ENODEV;498 rc = -ENODEV;
501 goto free_rmp;499 goto free_rmp;
502 }500 }
@@ -573,9 +571,9 @@ lpfc_bsg_rport_els_cmp(struct lpfc_hba *phba, · 70 unmodified lines
573 int rc = 0;571 int rc = 0;
574 u32 ulp_status, ulp_word4, total_data_placed;572 u32 ulp_status, ulp_word4, total_data_placed;
575 573
576 dd_data = cmdiocbq->context1;574 dd_data = cmdiocbq->context_un.dd_data;
577 ndlp = dd_data->context_un.iocb.ndlp;575 ndlp = dd_data->context_un.iocb.ndlp;
578 cmdiocbq->context1 = ndlp;576 cmdiocbq->ndlp = ndlp;
579 577
580 /* Determine if job has been aborted */578 /* Determine if job has been aborted */
581 spin_lock_irqsave(&phba->ct_ev_lock, flags);579 spin_lock_irqsave(&phba->ct_ev_lock, flags);
@@ -595,7 +593,7 @@ lpfc_bsg_rport_els_cmp(struct lpfc_hba *phba, · 13 unmodified lines
595 ulp_status = get_job_ulpstatus(phba, rspiocbq);593 ulp_status = get_job_ulpstatus(phba, rspiocbq);
596 ulp_word4 = get_job_word4(phba, rspiocbq);594 ulp_word4 = get_job_word4(phba, rspiocbq);
597 total_data_placed = get_job_data_placed(phba, rspiocbq);595 total_data_placed = get_job_data_placed(phba, rspiocbq);
598 pcmd = (struct lpfc_dmabuf *)cmdiocbq->context2;596 pcmd = cmdiocbq->cmd_dmabuf;
599 prsp = (struct lpfc_dmabuf *)pcmd->list.next;597 prsp = (struct lpfc_dmabuf *)pcmd->list.next;
600 598
601 /* Copy the completed job data or determine the job status if job is599 /* Copy the completed job data or determine the job status if job is
@@ -711,8 +709,8 @@ lpfc_bsg_rport_els(struct bsg_job *job) · 109 unmodified lines
711 /* Transfer the request payload to allocated command dma buffer */709 /* Transfer the request payload to allocated command dma buffer */
712 sg_copy_to_buffer(job->request_payload.sg_list,710 sg_copy_to_buffer(job->request_payload.sg_list,
713 job->request_payload.sg_cnt,711 job->request_payload.sg_cnt,
714 ((struct lpfc_dmabuf *)cmdiocbq->context2)->virt,712 cmdiocbq->cmd_dmabuf->virt,
715 job->request_payload.payload_len);713 cmdsize);
716 714
717 rpi = ndlp->nlp_rpi;715 rpi = ndlp->nlp_rpi;
718 716
@@ -722,8 +720,8 @@ lpfc_bsg_rport_els(struct bsg_job *job) · 3 unmodified lines
722 else720 else
723 cmdiocbq->iocb.ulpContext = rpi;721 cmdiocbq->iocb.ulpContext = rpi;
724 cmdiocbq->cmd_flag |= LPFC_IO_LIBDFC;722 cmdiocbq->cmd_flag |= LPFC_IO_LIBDFC;
725 cmdiocbq->context1 = dd_data;723 cmdiocbq->context_un.dd_data = dd_data;
726 cmdiocbq->context_un.ndlp = ndlp;724 cmdiocbq->ndlp = ndlp;
727 cmdiocbq->cmd_cmpl = lpfc_bsg_rport_els_cmp;725 cmdiocbq->cmd_cmpl = lpfc_bsg_rport_els_cmp;
728 dd_data->type = TYPE_IOCB;726 dd_data->type = TYPE_IOCB;
729 dd_data->set_job = job;727 dd_data->set_job = job;
@@ -742,12 +740,6 @@ lpfc_bsg_rport_els(struct bsg_job *job) · 12 unmodified lines
742 readl(phba->HCregaddr); /* flush */740 readl(phba->HCregaddr); /* flush */
743 }741 }
744 742
745 cmdiocbq->context1 = lpfc_nlp_get(ndlp);
746 if (!cmdiocbq->context1) {
747 rc = -EIO;
748 goto linkdown_err;
749 }
750
751 rc = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, cmdiocbq, 0);743 rc = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, cmdiocbq, 0);
752 if (rc == IOCB_SUCCESS) {744 if (rc == IOCB_SUCCESS) {
753 spin_lock_irqsave(&phba->hbalock, flags);745 spin_lock_irqsave(&phba->hbalock, flags);
@@ -917,8 +909,8 @@ lpfc_bsg_ct_unsol_event(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, · 163 unmodified lines
917 struct ulp_bde64 *bde;909 struct ulp_bde64 *bde;
918 dma_addr_t dma_addr;910 dma_addr_t dma_addr;
919 int i;911 int i;
920 struct lpfc_dmabuf *bdeBuf1 = piocbq->context2;912 struct lpfc_dmabuf *bdeBuf1 = piocbq->cmd_dmabuf;
921 struct lpfc_dmabuf *bdeBuf2 = piocbq->context3;913 struct lpfc_dmabuf *bdeBuf2 = piocbq->bpl_dmabuf;
922 struct lpfc_sli_ct_request *ct_req;914 struct lpfc_sli_ct_request *ct_req;
923 struct bsg_job *job = NULL;915 struct bsg_job *job = NULL;
924 struct fc_bsg_reply *bsg_reply;916 struct fc_bsg_reply *bsg_reply;
@@ -985,9 +977,8 @@ lpfc_bsg_ct_unsol_event(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, · 60 unmodified lines
985 list_for_each_entry(iocbq, &head, list) {977 list_for_each_entry(iocbq, &head, list) {
986 size = 0;978 size = 0;
987 if (phba->sli3_options & LPFC_SLI3_HBQ_ENABLED) {979 if (phba->sli3_options & LPFC_SLI3_HBQ_ENABLED) {
988 bdeBuf1 = iocbq->context2;980 bdeBuf1 = iocbq->cmd_dmabuf;
989 bdeBuf2 = iocbq->context3;981 bdeBuf2 = iocbq->bpl_dmabuf;
990
991 }982 }
992 if (phba->sli_rev == LPFC_SLI_REV4)983 if (phba->sli_rev == LPFC_SLI_REV4)
993 bde_count = iocbq->wcqe_cmpl.word3;984 bde_count = iocbq->wcqe_cmpl.word3;
@@ -1384,7 +1375,7 @@ lpfc_issue_ct_rsp_cmp(struct lpfc_hba *phba, · 390 unmodified lines
1384 int rc = 0;1375 int rc = 0;
1385 u32 ulp_status, ulp_word4;1376 u32 ulp_status, ulp_word4;
1386 1377
1387 dd_data = cmdiocbq->context1;1378 dd_data = cmdiocbq->context_un.dd_data;
1388 1379
1389 /* Determine if job has been aborted */1380 /* Determine if job has been aborted */
1390 spin_lock_irqsave(&phba->ct_ev_lock, flags);1381 spin_lock_irqsave(&phba->ct_ev_lock, flags);
@@ -1401,8 +1392,8 @@ lpfc_issue_ct_rsp_cmp(struct lpfc_hba *phba, · 10 unmodified lines
1401 spin_unlock_irqrestore(&phba->hbalock, flags);1392 spin_unlock_irqrestore(&phba->hbalock, flags);
1402 1393
1403 ndlp = dd_data->context_un.iocb.ndlp;1394 ndlp = dd_data->context_un.iocb.ndlp;
1404 cmp = cmdiocbq->context2;1395 cmp = cmdiocbq->cmd_dmabuf;
1405 bmp = cmdiocbq->context3;1396 bmp = cmdiocbq->bpl_dmabuf;
1406 1397
1407 ulp_status = get_job_ulpstatus(phba, rspiocbq);1398 ulp_status = get_job_ulpstatus(phba, rspiocbq);
1408 ulp_word4 = get_job_word4(phba, rspiocbq);1399 ulp_word4 = get_job_word4(phba, rspiocbq);
@@ -1529,10 +1520,10 @@ lpfc_issue_ct_rsp(struct lpfc_hba *phba, struct bsg_job *job, uint32_t tag, · 120 unmodified lines
1529 1520
1530 ctiocb->cmd_flag |= LPFC_IO_LIBDFC;1521 ctiocb->cmd_flag |= LPFC_IO_LIBDFC;
1531 ctiocb->vport = phba->pport;1522 ctiocb->vport = phba->pport;
1532 ctiocb->context1 = dd_data;1523 ctiocb->context_un.dd_data = dd_data;
1533 ctiocb->context2 = cmp;1524 ctiocb->cmd_dmabuf = cmp;
1534 ctiocb->context3 = bmp;1525 ctiocb->bpl_dmabuf = bmp;
1535 ctiocb->context_un.ndlp = ndlp;1526 ctiocb->ndlp = ndlp;
1536 ctiocb->cmd_cmpl = lpfc_issue_ct_rsp_cmp;1527 ctiocb->cmd_cmpl = lpfc_issue_ct_rsp_cmp;
1537 1528
1538 dd_data->type = TYPE_IOCB;1529 dd_data->type = TYPE_IOCB;
@@ -2671,7 +2662,7 @@ static int lpfcdiag_loop_get_xri(struct lpfc_hba *phba, uint16_t rpi, · 1132 unmodified lines
2671 ctreq->CommandResponse.bits.CmdRsp = ELX_LOOPBACK_XRI_SETUP;2662 ctreq->CommandResponse.bits.CmdRsp = ELX_LOOPBACK_XRI_SETUP;
2672 ctreq->CommandResponse.bits.Size = 0;2663 ctreq->CommandResponse.bits.Size = 0;
2673 2664
2674 cmdiocbq->context3 = dmabuf;2665 cmdiocbq->bpl_dmabuf = dmabuf;
2675 cmdiocbq->cmd_flag |= LPFC_IO_LIBDFC;2666 cmdiocbq->cmd_flag |= LPFC_IO_LIBDFC;
2676 cmdiocbq->vport = phba->pport;2667 cmdiocbq->vport = phba->pport;
2677 cmdiocbq->cmd_cmpl = NULL;2668 cmdiocbq->cmd_cmpl = NULL;
@@ -3231,7 +3222,7 @@ lpfc_bsg_diag_loopback_run(struct bsg_job *job) · 553 unmodified lines
3231 cmdiocbq->cmd_flag |= LPFC_IO_LOOPBACK;3222 cmdiocbq->cmd_flag |= LPFC_IO_LOOPBACK;
3232 cmdiocbq->vport = phba->pport;3223 cmdiocbq->vport = phba->pport;
3233 cmdiocbq->cmd_cmpl = NULL;3224 cmdiocbq->cmd_cmpl = NULL;
3234 cmdiocbq->context3 = txbmp;3225 cmdiocbq->bpl_dmabuf = txbmp;
3235 3226
3236 if (phba->sli_rev < LPFC_SLI_REV4) {3227 if (phba->sli_rev < LPFC_SLI_REV4) {
3237 lpfc_sli_prep_xmit_seq64(phba, cmdiocbq, txbmp, 0, txxri,3228 lpfc_sli_prep_xmit_seq64(phba, cmdiocbq, txbmp, 0, txxri,
@@ -3384,7 +3375,7 @@ job_error: · 146 unmodified lines
3384 * This is completion handler function for mailbox commands issued from3375 * This is completion handler function for mailbox commands issued from
3385 * lpfc_bsg_issue_mbox function. This function is called by the3376 * lpfc_bsg_issue_mbox function. This function is called by the
3386 * mailbox event handler function with no lock held. This function3377 * mailbox event handler function with no lock held. This function
3387 * will wake up thread waiting on the wait queue pointed by context13378 * will wake up thread waiting on the wait queue pointed by dd_data
3388 * of the mailbox.3379 * of the mailbox.
3389 **/3380 **/
3390static void3381static void
@@ -5034,9 +5025,9 @@ lpfc_bsg_menlo_cmd_cmp(struct lpfc_hba *phba, · 1643 unmodified lines
5034 unsigned int rsp_size;5025 unsigned int rsp_size;
5035 int rc = 0;5026 int rc = 0;
5036 5027
5037 dd_data = cmdiocbq->context1;5028 dd_data = cmdiocbq->context_un.dd_data;
5038 cmp = cmdiocbq->context2;5029 cmp = cmdiocbq->cmd_dmabuf;
5039 bmp = cmdiocbq->context3;5030 bmp = cmdiocbq->bpl_dmabuf;
5040 menlo = &dd_data->context_un.menlo;5031 menlo = &dd_data->context_un.menlo;
5041 rmp = menlo->rmp;5032 rmp = menlo->rmp;
5042 rsp = &rspiocbq->iocb;5033 rsp = &rspiocbq->iocb;
@@ -5233,9 +5224,9 @@ lpfc_menlo_cmd(struct bsg_job *job) · 190 unmodified lines
5233 /* We want the firmware to timeout before we do */5224 /* We want the firmware to timeout before we do */
5234 cmd->ulpTimeout = MENLO_TIMEOUT - 5;5225 cmd->ulpTimeout = MENLO_TIMEOUT - 5;
5235 cmdiocbq->cmd_cmpl = lpfc_bsg_menlo_cmd_cmp;5226 cmdiocbq->cmd_cmpl = lpfc_bsg_menlo_cmd_cmp;
5236 cmdiocbq->context1 = dd_data;5227 cmdiocbq->context_un.dd_data = dd_data;
5237 cmdiocbq->context2 = cmp;5228 cmdiocbq->cmd_dmabuf = cmp;
5238 cmdiocbq->context3 = bmp;5229 cmdiocbq->bpl_dmabuf = bmp;
5239 if (menlo_cmd->cmd == LPFC_BSG_VENDOR_MENLO_CMD) {5230 if (menlo_cmd->cmd == LPFC_BSG_VENDOR_MENLO_CMD) {
5240 cmd->ulpCommand = CMD_GEN_REQUEST64_CR;5231 cmd->ulpCommand = CMD_GEN_REQUEST64_CR;
5241 cmd->ulpPU = MENLO_PU; /* 3 */5232 cmd->ulpPU = MENLO_PU; /* 3 */
drivers/scsi/lpfc/lpfc_crtn.h+4−1
@@ -32,7 +32,9 @@ int lpfc_dump_static_vport(struct lpfc_hba *, LPFC_MBOXQ_t *, uint16_t); · 31 unmodified lines
32int lpfc_sli4_dump_cfg_rg23(struct lpfc_hba *, struct lpfcMboxq *);32int lpfc_sli4_dump_cfg_rg23(struct lpfc_hba *, struct lpfcMboxq *);
33void lpfc_read_nv(struct lpfc_hba *, LPFC_MBOXQ_t *);33void lpfc_read_nv(struct lpfc_hba *, LPFC_MBOXQ_t *);
34void lpfc_config_async(struct lpfc_hba *, LPFC_MBOXQ_t *, uint32_t);34void lpfc_config_async(struct lpfc_hba *, LPFC_MBOXQ_t *, uint32_t);
35 35int lpfc_mbox_rsrc_prep(struct lpfc_hba *phba, LPFC_MBOXQ_t *mbox);
36void lpfc_mbox_rsrc_cleanup(struct lpfc_hba *phba, LPFC_MBOXQ_t *mbox,
37 enum lpfc_mbox_ctx locked);
36void lpfc_heart_beat(struct lpfc_hba *, LPFC_MBOXQ_t *);38void lpfc_heart_beat(struct lpfc_hba *, LPFC_MBOXQ_t *);
37int lpfc_read_topology(struct lpfc_hba *, LPFC_MBOXQ_t *, struct lpfc_dmabuf *);39int lpfc_read_topology(struct lpfc_hba *, LPFC_MBOXQ_t *, struct lpfc_dmabuf *);
38void lpfc_clear_la(struct lpfc_hba *, LPFC_MBOXQ_t *);40void lpfc_clear_la(struct lpfc_hba *, LPFC_MBOXQ_t *);
@@ -432,6 +434,7 @@ void lpfc_nvmet_buf_free(struct lpfc_hba *phba, void *virtp, dma_addr_t dma); · 393 unmodified lines
432 434
433void lpfc_in_buf_free(struct lpfc_hba *, struct lpfc_dmabuf *);435void lpfc_in_buf_free(struct lpfc_hba *, struct lpfc_dmabuf *);
434void lpfc_rq_buf_free(struct lpfc_hba *phba, struct lpfc_dmabuf *mp);436void lpfc_rq_buf_free(struct lpfc_hba *phba, struct lpfc_dmabuf *mp);
437void lpfc_setup_fdmi_mask(struct lpfc_vport *vport);
435int lpfc_link_reset(struct lpfc_vport *vport);438int lpfc_link_reset(struct lpfc_vport *vport);
436 439
437/* Function prototypes. */440/* Function prototypes. */
drivers/scsi/lpfc/lpfc_ct.c+246−120
@@ -118,22 +118,22 @@ lpfc_ct_unsol_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 117 unmodified lines
118 struct lpfc_nodelist *ndlp;118 struct lpfc_nodelist *ndlp;
119 struct lpfc_dmabuf *mp, *bmp;119 struct lpfc_dmabuf *mp, *bmp;
120 120
121 ndlp = (struct lpfc_nodelist *)cmdiocb->context1;121 ndlp = cmdiocb->ndlp;
122 if (ndlp)122 if (ndlp)
123 lpfc_nlp_put(ndlp);123 lpfc_nlp_put(ndlp);
124 124
125 mp = cmdiocb->context2;125 mp = cmdiocb->rsp_dmabuf;
126 bmp = cmdiocb->context3;126 bmp = cmdiocb->bpl_dmabuf;
127 if (mp) {127 if (mp) {
128 lpfc_mbuf_free(phba, mp->virt, mp->phys);128 lpfc_mbuf_free(phba, mp->virt, mp->phys);
129 kfree(mp);129 kfree(mp);
130 cmdiocb->context2 = NULL;130 cmdiocb->rsp_dmabuf = NULL;
131 }131 }
132 132
133 if (bmp) {133 if (bmp) {
134 lpfc_mbuf_free(phba, bmp->virt, bmp->phys);134 lpfc_mbuf_free(phba, bmp->virt, bmp->phys);
135 kfree(bmp);135 kfree(bmp);
136 cmdiocb->context3 = NULL;136 cmdiocb->bpl_dmabuf = NULL;
137 }137 }
138 138
139 lpfc_sli_release_iocbq(phba, cmdiocb);139 lpfc_sli_release_iocbq(phba, cmdiocb);
@@ -232,18 +232,17 @@ lpfc_ct_reject_event(struct lpfc_nodelist *ndlp, · 92 unmodified lines
232 }232 }
233 233
234 /* Save for completion so we can release these resources */234 /* Save for completion so we can release these resources */
235 cmdiocbq->context2 = (uint8_t *)mp;235 cmdiocbq->rsp_dmabuf = mp;
236 cmdiocbq->context3 = (uint8_t *)bmp;236 cmdiocbq->bpl_dmabuf = bmp;
237 cmdiocbq->cmd_cmpl = lpfc_ct_unsol_cmpl;237 cmdiocbq->cmd_cmpl = lpfc_ct_unsol_cmpl;
238 tmo = (3 * phba->fc_ratov);238 tmo = (3 * phba->fc_ratov);
239 239
240 cmdiocbq->retry = 0;240 cmdiocbq->retry = 0;
241 cmdiocbq->vport = vport;241 cmdiocbq->vport = vport;
242 cmdiocbq->context_un.ndlp = NULL;
243 cmdiocbq->drvrTimeout = tmo + LPFC_DRVR_TIMEOUT;242 cmdiocbq->drvrTimeout = tmo + LPFC_DRVR_TIMEOUT;
244 243
245 cmdiocbq->context1 = lpfc_nlp_get(ndlp);244 cmdiocbq->ndlp = lpfc_nlp_get(ndlp);
246 if (!cmdiocbq->context1)245 if (!cmdiocbq->ndlp)
247 goto ct_no_ndlp;246 goto ct_no_ndlp;
248 247
249 rc = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, cmdiocbq, 0);248 rc = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, cmdiocbq, 0);
@@ -310,8 +309,8 @@ lpfc_ct_handle_mibreq(struct lpfc_hba *phba, struct lpfc_iocbq *ctiocbq) · 60 unmodified lines
310 return;309 return;
311 }310 }
312 311
313 ct_req = ((struct lpfc_sli_ct_request *)312 ct_req = (struct lpfc_sli_ct_request *)ctiocbq->cmd_dmabuf->virt;
314 (((struct lpfc_dmabuf *)ctiocbq->context2)->virt));313
315 mi_cmd = ct_req->CommandResponse.bits.CmdRsp;314 mi_cmd = ct_req->CommandResponse.bits.CmdRsp;
316 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,315 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
317 "6442 : MI Cmd : x%x Not Supported\n", mi_cmd);316 "6442 : MI Cmd : x%x Not Supported\n", mi_cmd);
@@ -347,14 +346,14 @@ lpfc_ct_unsol_event(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, · 29 unmodified lines
347 uint32_t size;346 uint32_t size;
348 struct list_head head;347 struct list_head head;
349 struct lpfc_sli_ct_request *ct_req;348 struct lpfc_sli_ct_request *ct_req;
350 struct lpfc_dmabuf *bdeBuf1 = ctiocbq->context2;349 struct lpfc_dmabuf *bdeBuf1 = ctiocbq->cmd_dmabuf;
351 struct lpfc_dmabuf *bdeBuf2 = ctiocbq->context3;350 struct lpfc_dmabuf *bdeBuf2 = ctiocbq->bpl_dmabuf;
352 u32 status, parameter, bde_count = 0;351 u32 status, parameter, bde_count = 0;
353 struct lpfc_wcqe_complete *wcqe_cmpl = NULL;352 struct lpfc_wcqe_complete *wcqe_cmpl = NULL;
354 353
355 ctiocbq->context1 = NULL;354 ctiocbq->cmd_dmabuf = NULL;
356 ctiocbq->context2 = NULL;355 ctiocbq->rsp_dmabuf = NULL;
357 ctiocbq->context3 = NULL;356 ctiocbq->bpl_dmabuf = NULL;
358 357
359 wcqe_cmpl = &ctiocbq->wcqe_cmpl;358 wcqe_cmpl = &ctiocbq->wcqe_cmpl;
360 status = get_job_ulpstatus(phba, ctiocbq);359 status = get_job_ulpstatus(phba, ctiocbq);
@@ -382,12 +381,11 @@ lpfc_ct_unsol_event(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, · 21 unmodified lines
382 if (bde_count == 0)381 if (bde_count == 0)
383 return;382 return;
384 383
385 ctiocbq->context2 = bdeBuf1;384 ctiocbq->cmd_dmabuf = bdeBuf1;
386 if (bde_count == 2)385 if (bde_count == 2)
387 ctiocbq->context3 = bdeBuf2;386 ctiocbq->bpl_dmabuf = bdeBuf2;
388 387
389 ct_req = ((struct lpfc_sli_ct_request *)388 ct_req = (struct lpfc_sli_ct_request *)ctiocbq->cmd_dmabuf->virt;
390 (((struct lpfc_dmabuf *)ctiocbq->context2)->virt));
391 389
392 if (ct_req->FsType == SLI_CT_MANAGEMENT_SERVICE &&390 if (ct_req->FsType == SLI_CT_MANAGEMENT_SERVICE &&
393 ct_req->FsSubType == SLI_CT_MIB_Subtypes) {391 ct_req->FsSubType == SLI_CT_MIB_Subtypes) {
@@ -408,8 +406,8 @@ lpfc_ct_unsol_event(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, · 14 unmodified lines
408 406
409 if (!bde_count)407 if (!bde_count)
410 continue;408 continue;
411 bdeBuf1 = iocb->context2;409 bdeBuf1 = iocb->cmd_dmabuf;
412 iocb->context2 = NULL;410 iocb->cmd_dmabuf = NULL;
413 if (phba->sli_rev == LPFC_SLI_REV4)411 if (phba->sli_rev == LPFC_SLI_REV4)
414 size = iocb->wqe.gen_req.bde.tus.f.bdeSize;412 size = iocb->wqe.gen_req.bde.tus.f.bdeSize;
415 else413 else
@@ -417,8 +415,8 @@ lpfc_ct_unsol_event(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, · 1 unmodified line
417 lpfc_ct_unsol_buffer(phba, ctiocbq, bdeBuf1, size);415 lpfc_ct_unsol_buffer(phba, ctiocbq, bdeBuf1, size);
418 lpfc_in_buf_free(phba, bdeBuf1);416 lpfc_in_buf_free(phba, bdeBuf1);
419 if (bde_count == 2) {417 if (bde_count == 2) {
420 bdeBuf2 = iocb->context3;418 bdeBuf2 = iocb->bpl_dmabuf;
421 iocb->context3 = NULL;419 iocb->bpl_dmabuf = NULL;
422 if (phba->sli_rev == LPFC_SLI_REV4)420 if (phba->sli_rev == LPFC_SLI_REV4)
423 size = iocb->unsol_rcv_len;421 size = iocb->unsol_rcv_len;
424 else422 else
@@ -549,24 +547,25 @@ lpfc_ct_free_iocb(struct lpfc_hba *phba, struct lpfc_iocbq *ctiocb) · 124 unmodified lines
549{547{
550 struct lpfc_dmabuf *buf_ptr;548 struct lpfc_dmabuf *buf_ptr;
551 549
552 /* I/O job is complete so context is now invalid*/550 /* IOCBQ job structure gets cleaned during release. Just release
553 ctiocb->context_un.ndlp = NULL;551 * the dma buffers here.
554 if (ctiocb->context1) {552 */
555 buf_ptr = (struct lpfc_dmabuf *) ctiocb->context1;553 if (ctiocb->cmd_dmabuf) {
554 buf_ptr = ctiocb->cmd_dmabuf;
556 lpfc_mbuf_free(phba, buf_ptr->virt, buf_ptr->phys);555 lpfc_mbuf_free(phba, buf_ptr->virt, buf_ptr->phys);
557 kfree(buf_ptr);556 kfree(buf_ptr);
558 ctiocb->context1 = NULL;557 ctiocb->cmd_dmabuf = NULL;
559 }558 }
560 if (ctiocb->context2) {559 if (ctiocb->rsp_dmabuf) {
561 lpfc_free_ct_rsp(phba, (struct lpfc_dmabuf *) ctiocb->context2);560 lpfc_free_ct_rsp(phba, ctiocb->rsp_dmabuf);
562 ctiocb->context2 = NULL;561 ctiocb->rsp_dmabuf = NULL;
563 }562 }
564 563
565 if (ctiocb->context3) {564 if (ctiocb->bpl_dmabuf) {
566 buf_ptr = (struct lpfc_dmabuf *) ctiocb->context3;565 buf_ptr = ctiocb->bpl_dmabuf;
567 lpfc_mbuf_free(phba, buf_ptr->virt, buf_ptr->phys);566 lpfc_mbuf_free(phba, buf_ptr->virt, buf_ptr->phys);
568 kfree(buf_ptr);567 kfree(buf_ptr);
569 ctiocb->context3 = NULL;568 ctiocb->bpl_dmabuf = NULL;
570 }569 }
571 lpfc_sli_release_iocbq(phba, ctiocb);570 lpfc_sli_release_iocbq(phba, ctiocb);
572 return 0;571 return 0;
@@ -605,11 +604,11 @@ lpfc_gen_req(struct lpfc_vport *vport, struct lpfc_dmabuf *bmp, · 32 unmodified lines
605 /* Update the num_entry bde count */604 /* Update the num_entry bde count */
606 geniocb->num_bdes = num_entry;605 geniocb->num_bdes = num_entry;
607 606
608 geniocb->context3 = (uint8_t *) bmp;607 geniocb->bpl_dmabuf = bmp;
609 608
610 /* Save for completion so we can release these resources */609 /* Save for completion so we can release these resources */
611 geniocb->context1 = (uint8_t *) inp;610 geniocb->cmd_dmabuf = inp;
612 geniocb->context2 = (uint8_t *) outp;611 geniocb->rsp_dmabuf = outp;
613 612
614 geniocb->event_tag = event_tag;613 geniocb->event_tag = event_tag;
615 614
@@ -635,8 +634,8 @@ lpfc_gen_req(struct lpfc_vport *vport, struct lpfc_dmabuf *bmp, · 19 unmodified lines
635 geniocb->drvrTimeout = tmo + LPFC_DRVR_TIMEOUT;634 geniocb->drvrTimeout = tmo + LPFC_DRVR_TIMEOUT;
636 geniocb->vport = vport;635 geniocb->vport = vport;
637 geniocb->retry = retry;636 geniocb->retry = retry;
638 geniocb->context_un.ndlp = lpfc_nlp_get(ndlp);637 geniocb->ndlp = lpfc_nlp_get(ndlp);
639 if (!geniocb->context_un.ndlp)638 if (!geniocb->ndlp)
640 goto out;639 goto out;
641 640
642 rc = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, geniocb, 0);641 rc = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, geniocb, 0);
@@ -926,13 +925,12 @@ lpfc_cmpl_ct_cmd_gid_ft(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 283 unmodified lines
926 int rc, type;925 int rc, type;
927 926
928 /* First save ndlp, before we overwrite it */927 /* First save ndlp, before we overwrite it */
929 ndlp = cmdiocb->context_un.ndlp;928 ndlp = cmdiocb->ndlp;
930 929
931 /* we pass cmdiocb to state machine which needs rspiocb as well */930 /* we pass cmdiocb to state machine which needs rspiocb as well */
932 cmdiocb->context_un.rsp_iocb = rspiocb;931 cmdiocb->rsp_iocb = rspiocb;
933 932 inp = cmdiocb->cmd_dmabuf;
934 inp = (struct lpfc_dmabuf *) cmdiocb->context1;933 outp = cmdiocb->rsp_dmabuf;
935 outp = (struct lpfc_dmabuf *) cmdiocb->context2;
936 934
937 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT,935 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT,
938 "GID_FT cmpl: status:x%x/x%x rtry:%d",936 "GID_FT cmpl: status:x%x/x%x rtry:%d",
@@ -962,9 +960,15 @@ lpfc_cmpl_ct_cmd_gid_ft(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 23 unmodified lines
962 }960 }
963 if (lpfc_error_lost_link(ulp_status, ulp_word4)) {961 if (lpfc_error_lost_link(ulp_status, ulp_word4)) {
964 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,962 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
965 "0226 NS query failed due to link event\n");963 "0226 NS query failed due to link event: "
964 "ulp_status x%x ulp_word4 x%x fc_flag x%x "
965 "port_state x%x gidft_inp x%x\n",
966 ulp_status, ulp_word4, vport->fc_flag,
967 vport->port_state, vport->gidft_inp);
966 if (vport->fc_flag & FC_RSCN_MODE)968 if (vport->fc_flag & FC_RSCN_MODE)
967 lpfc_els_flush_rscn(vport);969 lpfc_els_flush_rscn(vport);
970 if (vport->gidft_inp)
971 vport->gidft_inp--;
968 goto out;972 goto out;
969 }973 }
970 974
@@ -1143,12 +1147,12 @@ lpfc_cmpl_ct_cmd_gid_pt(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 172 unmodified lines
1143 int rc;1147 int rc;
1144 1148
1145 /* First save ndlp, before we overwrite it */1149 /* First save ndlp, before we overwrite it */
1146 ndlp = cmdiocb->context_un.ndlp;1150 ndlp = cmdiocb->ndlp;
1147 1151
1148 /* we pass cmdiocb to state machine which needs rspiocb as well */1152 /* we pass cmdiocb to state machine which needs rspiocb as well */
1149 cmdiocb->context_un.rsp_iocb = rspiocb;1153 cmdiocb->rsp_iocb = rspiocb;
1150 inp = (struct lpfc_dmabuf *)cmdiocb->context1;1154 inp = cmdiocb->cmd_dmabuf;
1151 outp = (struct lpfc_dmabuf *)cmdiocb->context2;1155 outp = cmdiocb->rsp_dmabuf;
1152 1156
1153 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT,1157 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT,
1154 "GID_PT cmpl: status:x%x/x%x rtry:%d",1158 "GID_PT cmpl: status:x%x/x%x rtry:%d",
@@ -1179,9 +1183,15 @@ lpfc_cmpl_ct_cmd_gid_pt(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 24 unmodified lines
1179 }1183 }
1180 if (lpfc_error_lost_link(ulp_status, ulp_word4)) {1184 if (lpfc_error_lost_link(ulp_status, ulp_word4)) {
1181 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,1185 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
1182 "4166 NS query failed due to link event\n");1186 "4166 NS query failed due to link event: "
1187 "ulp_status x%x ulp_word4 x%x fc_flag x%x "
1188 "port_state x%x gidft_inp x%x\n",
1189 ulp_status, ulp_word4, vport->fc_flag,
1190 vport->port_state, vport->gidft_inp);
1183 if (vport->fc_flag & FC_RSCN_MODE)1191 if (vport->fc_flag & FC_RSCN_MODE)
1184 lpfc_els_flush_rscn(vport);1192 lpfc_els_flush_rscn(vport);
1193 if (vport->gidft_inp)
1194 vport->gidft_inp--;
1185 goto out;1195 goto out;
1186 }1196 }
1187 1197
@@ -1346,8 +1356,8 @@ lpfc_cmpl_ct_cmd_gff_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 158 unmodified lines
1346{1356{
1347 struct lpfc_vport *vport = cmdiocb->vport;1357 struct lpfc_vport *vport = cmdiocb->vport;
1348 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);1358 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
1349 struct lpfc_dmabuf *inp = (struct lpfc_dmabuf *) cmdiocb->context1;1359 struct lpfc_dmabuf *inp = cmdiocb->cmd_dmabuf;
1350 struct lpfc_dmabuf *outp = (struct lpfc_dmabuf *) cmdiocb->context2;1360 struct lpfc_dmabuf *outp = cmdiocb->rsp_dmabuf;
1351 struct lpfc_sli_ct_request *CTrsp;1361 struct lpfc_sli_ct_request *CTrsp;
1352 int did, rc, retry;1362 int did, rc, retry;
1353 uint8_t fbits;1363 uint8_t fbits;
@@ -1426,7 +1436,7 @@ lpfc_cmpl_ct_cmd_gff_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 72 unmodified lines
1426 cmdiocb->retry, did);1436 cmdiocb->retry, did);
1427 if (rc == 0) {1437 if (rc == 0) {
1428 /* success */1438 /* success */
1429 free_ndlp = cmdiocb->context_un.ndlp;1439 free_ndlp = cmdiocb->ndlp;
1430 lpfc_ct_free_iocb(phba, cmdiocb);1440 lpfc_ct_free_iocb(phba, cmdiocb);
1431 lpfc_nlp_put(free_ndlp);1441 lpfc_nlp_put(free_ndlp);
1432 return;1442 return;
@@ -1483,7 +1493,7 @@ out: · 50 unmodified lines
1483 }1493 }
1484 1494
1485iocb_free:1495iocb_free:
1486 free_ndlp = cmdiocb->context_un.ndlp;1496 free_ndlp = cmdiocb->ndlp;
1487 lpfc_ct_free_iocb(phba, cmdiocb);1497 lpfc_ct_free_iocb(phba, cmdiocb);
1488 lpfc_nlp_put(free_ndlp);1498 lpfc_nlp_put(free_ndlp);
1489 return;1499 return;
@@ -1494,8 +1504,8 @@ lpfc_cmpl_ct_cmd_gft_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 4 unmodified lines
1494 struct lpfc_iocbq *rspiocb)1504 struct lpfc_iocbq *rspiocb)
1495{1505{
1496 struct lpfc_vport *vport = cmdiocb->vport;1506 struct lpfc_vport *vport = cmdiocb->vport;
1497 struct lpfc_dmabuf *inp = (struct lpfc_dmabuf *)cmdiocb->context1;1507 struct lpfc_dmabuf *inp = cmdiocb->cmd_dmabuf;
1498 struct lpfc_dmabuf *outp = (struct lpfc_dmabuf *)cmdiocb->context2;1508 struct lpfc_dmabuf *outp = cmdiocb->rsp_dmabuf;
1499 struct lpfc_sli_ct_request *CTrsp;1509 struct lpfc_sli_ct_request *CTrsp;
1500 int did;1510 int did;
1501 struct lpfc_nodelist *ndlp = NULL;1511 struct lpfc_nodelist *ndlp = NULL;
@@ -1519,7 +1529,7 @@ lpfc_cmpl_ct_cmd_gft_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 17 unmodified lines
1519 }1529 }
1520 1530
1521 /* Preserve the nameserver node to release the reference. */1531 /* Preserve the nameserver node to release the reference. */
1522 ns_ndlp = cmdiocb->context_un.ndlp;1532 ns_ndlp = cmdiocb->ndlp;
1523 1533
1524 if (ulp_status == IOSTAT_SUCCESS) {1534 if (ulp_status == IOSTAT_SUCCESS) {
1525 /* Good status, continue checking */1535 /* Good status, continue checking */
@@ -1605,13 +1615,13 @@ lpfc_cmpl_ct(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 79 unmodified lines
1605 u32 ulp_word4 = get_job_word4(phba, rspiocb);1615 u32 ulp_word4 = get_job_word4(phba, rspiocb);
1606 1616
1607 /* First save ndlp, before we overwrite it */1617 /* First save ndlp, before we overwrite it */
1608 ndlp = cmdiocb->context_un.ndlp;1618 ndlp = cmdiocb->ndlp;
1609 1619
1610 /* we pass cmdiocb to state machine which needs rspiocb as well */1620 /* we pass cmdiocb to state machine which needs rspiocb as well */
1611 cmdiocb->context_un.rsp_iocb = rspiocb;1621 cmdiocb->rsp_iocb = rspiocb;
1612 1622
1613 inp = (struct lpfc_dmabuf *) cmdiocb->context1;1623 inp = cmdiocb->cmd_dmabuf;
1614 outp = (struct lpfc_dmabuf *) cmdiocb->context2;1624 outp = cmdiocb->rsp_dmabuf;
1615 1625
1616 cmdcode = be16_to_cpu(((struct lpfc_sli_ct_request *) inp->virt)->1626 cmdcode = be16_to_cpu(((struct lpfc_sli_ct_request *) inp->virt)->
1617 CommandResponse.bits.CmdRsp);1627 CommandResponse.bits.CmdRsp);
@@ -1672,8 +1682,8 @@ lpfc_cmpl_ct_cmd_rft_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 54 unmodified lines
1672 struct lpfc_dmabuf *outp;1682 struct lpfc_dmabuf *outp;
1673 struct lpfc_sli_ct_request *CTrsp;1683 struct lpfc_sli_ct_request *CTrsp;
1674 1684
1675 outp = (struct lpfc_dmabuf *) cmdiocb->context2;1685 outp = cmdiocb->rsp_dmabuf;
1676 CTrsp = (struct lpfc_sli_ct_request *) outp->virt;1686 CTrsp = (struct lpfc_sli_ct_request *)outp->virt;
1677 if (CTrsp->CommandResponse.bits.CmdRsp ==1687 if (CTrsp->CommandResponse.bits.CmdRsp ==
1678 be16_to_cpu(SLI_CT_RESPONSE_FS_ACC))1688 be16_to_cpu(SLI_CT_RESPONSE_FS_ACC))
1679 vport->ct_flags |= FC_CT_RFT_ID;1689 vport->ct_flags |= FC_CT_RFT_ID;
@@ -1693,7 +1703,7 @@ lpfc_cmpl_ct_cmd_rnn_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 13 unmodified lines
1693 struct lpfc_dmabuf *outp;1703 struct lpfc_dmabuf *outp;
1694 struct lpfc_sli_ct_request *CTrsp;1704 struct lpfc_sli_ct_request *CTrsp;
1695 1705
1696 outp = (struct lpfc_dmabuf *) cmdiocb->context2;1706 outp = cmdiocb->rsp_dmabuf;
1697 CTrsp = (struct lpfc_sli_ct_request *) outp->virt;1707 CTrsp = (struct lpfc_sli_ct_request *) outp->virt;
1698 if (CTrsp->CommandResponse.bits.CmdRsp ==1708 if (CTrsp->CommandResponse.bits.CmdRsp ==
1699 be16_to_cpu(SLI_CT_RESPONSE_FS_ACC))1709 be16_to_cpu(SLI_CT_RESPONSE_FS_ACC))
@@ -1714,8 +1724,8 @@ lpfc_cmpl_ct_cmd_rspn_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 14 unmodified lines
1714 struct lpfc_dmabuf *outp;1724 struct lpfc_dmabuf *outp;
1715 struct lpfc_sli_ct_request *CTrsp;1725 struct lpfc_sli_ct_request *CTrsp;
1716 1726
1717 outp = (struct lpfc_dmabuf *) cmdiocb->context2;1727 outp = cmdiocb->rsp_dmabuf;
1718 CTrsp = (struct lpfc_sli_ct_request *) outp->virt;1728 CTrsp = (struct lpfc_sli_ct_request *)outp->virt;
1719 if (CTrsp->CommandResponse.bits.CmdRsp ==1729 if (CTrsp->CommandResponse.bits.CmdRsp ==
1720 be16_to_cpu(SLI_CT_RESPONSE_FS_ACC))1730 be16_to_cpu(SLI_CT_RESPONSE_FS_ACC))
1721 vport->ct_flags |= FC_CT_RSPN_ID;1731 vport->ct_flags |= FC_CT_RSPN_ID;
@@ -1735,7 +1745,7 @@ lpfc_cmpl_ct_cmd_rsnn_nn(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 13 unmodified lines
1735 struct lpfc_dmabuf *outp;1745 struct lpfc_dmabuf *outp;
1736 struct lpfc_sli_ct_request *CTrsp;1746 struct lpfc_sli_ct_request *CTrsp;
1737 1747
1738 outp = (struct lpfc_dmabuf *) cmdiocb->context2;1748 outp = cmdiocb->rsp_dmabuf;
1739 CTrsp = (struct lpfc_sli_ct_request *) outp->virt;1749 CTrsp = (struct lpfc_sli_ct_request *) outp->virt;
1740 if (CTrsp->CommandResponse.bits.CmdRsp ==1750 if (CTrsp->CommandResponse.bits.CmdRsp ==
1741 be16_to_cpu(SLI_CT_RESPONSE_FS_ACC))1751 be16_to_cpu(SLI_CT_RESPONSE_FS_ACC))
@@ -1768,8 +1778,8 @@ lpfc_cmpl_ct_cmd_rff_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 26 unmodified lines
1768 struct lpfc_dmabuf *outp;1778 struct lpfc_dmabuf *outp;
1769 struct lpfc_sli_ct_request *CTrsp;1779 struct lpfc_sli_ct_request *CTrsp;
1770 1780
1771 outp = (struct lpfc_dmabuf *) cmdiocb->context2;1781 outp = cmdiocb->rsp_dmabuf;
1772 CTrsp = (struct lpfc_sli_ct_request *) outp->virt;1782 CTrsp = (struct lpfc_sli_ct_request *)outp->virt;
1773 if (CTrsp->CommandResponse.bits.CmdRsp ==1783 if (CTrsp->CommandResponse.bits.CmdRsp ==
1774 be16_to_cpu(SLI_CT_RESPONSE_FS_ACC))1784 be16_to_cpu(SLI_CT_RESPONSE_FS_ACC))
1775 vport->ct_flags |= FC_CT_RFF_ID;1785 vport->ct_flags |= FC_CT_RFF_ID;
@@ -1865,7 +1875,7 @@ lpfc_get_gidft_type(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb) · 89 unmodified lines
1865 struct lpfc_dmabuf *mp;1875 struct lpfc_dmabuf *mp;
1866 uint32_t type;1876 uint32_t type;
1867 1877
1868 mp = cmdiocb->context1;1878 mp = cmdiocb->cmd_dmabuf;
1869 if (mp == NULL)1879 if (mp == NULL)
1870 return 0;1880 return 0;
1871 CtReq = (struct lpfc_sli_ct_request *)mp->virt;1881 CtReq = (struct lpfc_sli_ct_request *)mp->virt;
@@ -2018,28 +2028,30 @@ lpfc_ns_cmd(struct lpfc_vport *vport, int cmdcode, · 146 unmodified lines
2018 vport->ct_flags &= ~FC_CT_RFT_ID;2028 vport->ct_flags &= ~FC_CT_RFT_ID;
2019 CtReq->CommandResponse.bits.CmdRsp =2029 CtReq->CommandResponse.bits.CmdRsp =
2020 cpu_to_be16(SLI_CTNS_RFT_ID);2030 cpu_to_be16(SLI_CTNS_RFT_ID);
2021 CtReq->un.rft.PortId = cpu_to_be32(vport->fc_myDID);2031 CtReq->un.rft.port_id = cpu_to_be32(vport->fc_myDID);
2032
2033 /* Register Application Services type if vmid enabled. */
2034 if (phba->cfg_vmid_app_header)
2035 CtReq->un.rft.app_serv_reg =
2036 cpu_to_be32(RFT_APP_SERV_REG);
2022 2037
2023 /* Register FC4 FCP type if enabled. */2038 /* Register FC4 FCP type if enabled. */
2024 if (vport->cfg_enable_fc4_type == LPFC_ENABLE_BOTH ||2039 if (vport->cfg_enable_fc4_type == LPFC_ENABLE_BOTH ||
2025 vport->cfg_enable_fc4_type == LPFC_ENABLE_FCP)2040 vport->cfg_enable_fc4_type == LPFC_ENABLE_FCP)
2026 CtReq->un.rft.fcpReg = 1;2041 CtReq->un.rft.fcp_reg = cpu_to_be32(RFT_FCP_REG);
2027 2042
2028 /* Register NVME type if enabled. Defined LE and swapped.2043 /* Register NVME type if enabled. */
2029 * rsvd[0] is used as word1 because of the hard-coded
2030 * word0 usage in the ct_request data structure.
2031 */
2032 if (vport->cfg_enable_fc4_type == LPFC_ENABLE_BOTH ||2044 if (vport->cfg_enable_fc4_type == LPFC_ENABLE_BOTH ||
2033 vport->cfg_enable_fc4_type == LPFC_ENABLE_NVME)2045 vport->cfg_enable_fc4_type == LPFC_ENABLE_NVME)
2034 CtReq->un.rft.rsvd[0] =2046 CtReq->un.rft.nvme_reg = cpu_to_be32(RFT_NVME_REG);
2035 cpu_to_be32(LPFC_FC4_TYPE_BITMASK);
2036 2047
2037 ptr = (uint32_t *)CtReq;2048 ptr = (uint32_t *)CtReq;
2038 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,2049 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
2039 "6433 Issue RFT (%s %s): %08x %08x %08x %08x "2050 "6433 Issue RFT (%s %s %s): %08x %08x %08x "
2040 "%08x %08x %08x %08x\n",2051 "%08x %08x %08x %08x %08x\n",
2041 CtReq->un.rft.fcpReg ? "FCP" : " ",2052 CtReq->un.rft.fcp_reg ? "FCP" : " ",
2042 CtReq->un.rft.rsvd[0] ? "NVME" : " ",2053 CtReq->un.rft.nvme_reg ? "NVME" : " ",
2054 CtReq->un.rft.app_serv_reg ? "APPS" : " ",
2043 *ptr, *(ptr + 1), *(ptr + 2), *(ptr + 3),2055 *ptr, *(ptr + 1), *(ptr + 2), *(ptr + 3),
2044 *(ptr + 4), *(ptr + 5),2056 *(ptr + 4), *(ptr + 5),
2045 *(ptr + 6), *(ptr + 7));2057 *(ptr + 6), *(ptr + 7));
@@ -2155,6 +2167,41 @@ ns_cmd_exit: · 109 unmodified lines
2155 return 1;2167 return 1;
2156}2168}
2157 2169
2170/**
2171 * lpfc_fdmi_rprt_defer - Check for any deferred FDMI RPRT commands
2172 * @phba: Pointer to HBA context object.
2173 * @mask: Initial port attributes mask
2174 *
2175 * This function checks to see if any vports have deferred their FDMI RPRT.
2176 * A vports RPRT may be deferred if it is issued before the primary ports
2177 * RHBA completes.
2178 */
2179static void
2180lpfc_fdmi_rprt_defer(struct lpfc_hba *phba, uint32_t mask)
2181{
2182 struct lpfc_vport **vports;
2183 struct lpfc_vport *vport;
2184 struct lpfc_nodelist *ndlp;
2185 int i;
2186
2187 phba->hba_flag |= HBA_RHBA_CMPL;
2188 vports = lpfc_create_vport_work_array(phba);
2189 if (vports) {
2190 for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) {
2191 vport = vports[i];
2192 ndlp = lpfc_findnode_did(phba->pport, FDMI_DID);
2193 if (!ndlp)
2194 continue;
2195 if (vport->ct_flags & FC_CT_RPRT_DEFER) {
2196 vport->ct_flags &= ~FC_CT_RPRT_DEFER;
2197 vport->fdmi_port_mask = mask;
2198 lpfc_fdmi_cmd(vport, ndlp, SLI_MGMT_RPRT, 0);
2199 }
2200 }
2201 }
2202 lpfc_destroy_vport_work_array(phba, vports);
2203}
2204
2158/**2205/**
2159 * lpfc_cmpl_ct_disc_fdmi - Handle a discovery FDMI completion2206 * lpfc_cmpl_ct_disc_fdmi - Handle a discovery FDMI completion
2160 * @phba: Pointer to HBA context object.2207 * @phba: Pointer to HBA context object.
@@ -2169,8 +2216,8 @@ lpfc_cmpl_ct_disc_fdmi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 8 unmodified lines
2169 struct lpfc_iocbq *rspiocb)2216 struct lpfc_iocbq *rspiocb)
2170{2217{
2171 struct lpfc_vport *vport = cmdiocb->vport;2218 struct lpfc_vport *vport = cmdiocb->vport;
2172 struct lpfc_dmabuf *inp = cmdiocb->context1;2219 struct lpfc_dmabuf *inp = cmdiocb->cmd_dmabuf;
2173 struct lpfc_dmabuf *outp = cmdiocb->context2;2220 struct lpfc_dmabuf *outp = cmdiocb->rsp_dmabuf;
2174 struct lpfc_sli_ct_request *CTcmd = inp->virt;2221 struct lpfc_sli_ct_request *CTcmd = inp->virt;
2175 struct lpfc_sli_ct_request *CTrsp = outp->virt;2222 struct lpfc_sli_ct_request *CTrsp = outp->virt;
2176 uint16_t fdmi_cmd = CTcmd->CommandResponse.bits.CmdRsp;2223 uint16_t fdmi_cmd = CTcmd->CommandResponse.bits.CmdRsp;
@@ -2224,7 +2271,7 @@ lpfc_cmpl_ct_disc_fdmi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 47 unmodified lines
2224 ulp_word4);2271 ulp_word4);
2225 }2272 }
2226 2273
2227 free_ndlp = cmdiocb->context_un.ndlp;2274 free_ndlp = cmdiocb->ndlp;
2228 lpfc_ct_free_iocb(phba, cmdiocb);2275 lpfc_ct_free_iocb(phba, cmdiocb);
2229 lpfc_nlp_put(free_ndlp);2276 lpfc_nlp_put(free_ndlp);
2230 2277
@@ -2236,15 +2283,19 @@ lpfc_cmpl_ct_disc_fdmi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 5 unmodified lines
2236 cmd = be16_to_cpu(fdmi_cmd);2283 cmd = be16_to_cpu(fdmi_cmd);
2237 if (fdmi_rsp == cpu_to_be16(SLI_CT_RESPONSE_FS_RJT)) {2284 if (fdmi_rsp == cpu_to_be16(SLI_CT_RESPONSE_FS_RJT)) {
2238 /* FDMI rsp failed */2285 /* FDMI rsp failed */
2239 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,2286 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY | LOG_ELS,
2240 "0220 FDMI cmd failed FS_RJT Data: x%x", cmd);2287 "0220 FDMI cmd failed FS_RJT Data: x%x", cmd);
2241 2288
2242 /* Should we fallback to FDMI-2 / FDMI-1 ? */2289 /* Should we fallback to FDMI-2 / FDMI-1 ? */
2243 switch (cmd) {2290 switch (cmd) {
2244 case SLI_MGMT_RHBA:2291 case SLI_MGMT_RHBA:
2245 if (vport->fdmi_hba_mask == LPFC_FDMI2_HBA_ATTR) {2292 if (vport->fdmi_hba_mask == LPFC_FDMI2_HBA_ATTR) {
2246 /* Fallback to FDMI-1 */2293 /* Fallback to FDMI-1 for HBA attributes */
2247 vport->fdmi_hba_mask = LPFC_FDMI1_HBA_ATTR;2294 vport->fdmi_hba_mask = LPFC_FDMI1_HBA_ATTR;
2295
2296 /* If HBA attributes are FDMI1, so should
2297 * port attributes be for consistency.
2298 */
2248 vport->fdmi_port_mask = LPFC_FDMI1_PORT_ATTR;2299 vport->fdmi_port_mask = LPFC_FDMI1_PORT_ATTR;
2249 /* Start over */2300 /* Start over */
2250 lpfc_fdmi_cmd(vport, ndlp, SLI_MGMT_DHBA, 0);2301 lpfc_fdmi_cmd(vport, ndlp, SLI_MGMT_DHBA, 0);
@@ -2252,6 +2303,11 @@ lpfc_cmpl_ct_disc_fdmi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 1 unmodified line
2252 return;2303 return;
2253 2304
2254 case SLI_MGMT_RPRT:2305 case SLI_MGMT_RPRT:
2306 if (vport->port_type != LPFC_PHYSICAL_PORT) {
2307 ndlp = lpfc_findnode_did(phba->pport, FDMI_DID);
2308 if (!ndlp)
2309 return;
2310 }
2255 if (vport->fdmi_port_mask == LPFC_FDMI2_PORT_ATTR) {2311 if (vport->fdmi_port_mask == LPFC_FDMI2_PORT_ATTR) {
2256 /* Fallback to FDMI-1 */2312 /* Fallback to FDMI-1 */
2257 vport->fdmi_port_mask = LPFC_FDMI1_PORT_ATTR;2313 vport->fdmi_port_mask = LPFC_FDMI1_PORT_ATTR;
@@ -2272,9 +2328,9 @@ lpfc_cmpl_ct_disc_fdmi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 14 unmodified lines
2272 phba->link_flag &= ~LS_CT_VEN_RPA;2328 phba->link_flag &= ~LS_CT_VEN_RPA;
2273 if (phba->cmf_active_mode == LPFC_CFG_OFF)2329 if (phba->cmf_active_mode == LPFC_CFG_OFF)
2274 return;2330 return;
2275 lpfc_printf_log(phba, KERN_ERR,2331 lpfc_printf_log(phba, KERN_WARNING,
2276 LOG_DISCOVERY | LOG_ELS,2332 LOG_DISCOVERY | LOG_ELS,
2277 "6460 VEN FDMI RPA failure\n");2333 "6460 VEN FDMI RPA RJT\n");
2278 return;2334 return;
2279 }2335 }
2280 if (vport->fdmi_port_mask == LPFC_FDMI2_PORT_ATTR) {2336 if (vport->fdmi_port_mask == LPFC_FDMI2_PORT_ATTR) {
@@ -2301,6 +2357,9 @@ lpfc_cmpl_ct_disc_fdmi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 20 unmodified lines
2301 */2357 */
2302 switch (cmd) {2358 switch (cmd) {
2303 case SLI_MGMT_RHBA:2359 case SLI_MGMT_RHBA:
2360 /* Check for any RPRTs deferred till after RHBA completes */
2361 lpfc_fdmi_rprt_defer(phba, vport->fdmi_port_mask);
2362
2304 lpfc_fdmi_cmd(vport, ndlp, SLI_MGMT_RPA, 0);2363 lpfc_fdmi_cmd(vport, ndlp, SLI_MGMT_RPA, 0);
2305 break;2364 break;
2306 2365
@@ -2309,10 +2368,26 @@ lpfc_cmpl_ct_disc_fdmi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 2 unmodified lines
2309 break;2368 break;
2310 2369
2311 case SLI_MGMT_DPRT:2370 case SLI_MGMT_DPRT:
2312 if (vport->port_type == LPFC_PHYSICAL_PORT)2371 if (vport->port_type == LPFC_PHYSICAL_PORT) {
2313 lpfc_fdmi_cmd(vport, ndlp, SLI_MGMT_RHBA, 0);2372 lpfc_fdmi_cmd(vport, ndlp, SLI_MGMT_RHBA, 0);
2314 else2373 } else {
2315 lpfc_fdmi_cmd(vport, ndlp, SLI_MGMT_RPRT, 0);2374 ndlp = lpfc_findnode_did(phba->pport, FDMI_DID);
2375 if (!ndlp)
2376 return;
2377
2378 /* Only issue a RPRT for the vport if the RHBA
2379 * for the physical port completes successfully.
2380 * We may have to defer the RPRT accordingly.
2381 */
2382 if (phba->hba_flag & HBA_RHBA_CMPL) {
2383 lpfc_fdmi_cmd(vport, ndlp, SLI_MGMT_RPRT, 0);
2384 } else {
2385 lpfc_printf_vlog(vport, KERN_INFO,
2386 LOG_DISCOVERY,
2387 "6078 RPRT deferred\n");
2388 vport->ct_flags |= FC_CT_RPRT_DEFER;
2389 }
2390 }
2316 break;2391 break;
2317 case SLI_MGMT_RPA:2392 case SLI_MGMT_RPA:
2318 if (vport->port_type == LPFC_PHYSICAL_PORT &&2393 if (vport->port_type == LPFC_PHYSICAL_PORT &&
@@ -2327,7 +2402,8 @@ lpfc_cmpl_ct_disc_fdmi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 8 unmodified lines
2327 break;2402 break;
2328 }2403 }
2329 2404
2330 lpfc_printf_log(phba, KERN_INFO, LOG_CGN_MGMT,2405 lpfc_printf_log(phba, KERN_INFO,
2406 LOG_DISCOVERY | LOG_CGN_MGMT,
2331 "6210 Issue Vendor MI FDMI %x\n",2407 "6210 Issue Vendor MI FDMI %x\n",
2332 phba->sli4_hba.pc_sli4_params.mi_ver);2408 phba->sli4_hba.pc_sli4_params.mi_ver);
2333 2409
@@ -2396,6 +2472,9 @@ lpfc_fdmi_change_check(struct lpfc_vport *vport) · 62 unmodified lines
2396 phba->link_flag &= ~LS_CT_VEN_RPA;2472 phba->link_flag &= ~LS_CT_VEN_RPA;
2397 lpfc_fdmi_cmd(vport, ndlp, SLI_MGMT_DHBA, 0);2473 lpfc_fdmi_cmd(vport, ndlp, SLI_MGMT_DHBA, 0);
2398 } else {2474 } else {
2475 ndlp = lpfc_findnode_did(phba->pport, FDMI_DID);
2476 if (!ndlp)
2477 return;
2399 lpfc_fdmi_cmd(vport, ndlp, SLI_MGMT_DPRT, 0);2478 lpfc_fdmi_cmd(vport, ndlp, SLI_MGMT_DPRT, 0);
2400 }2479 }
2401 2480
@@ -2417,6 +2496,9 @@ lpfc_fdmi_change_check(struct lpfc_vport *vport) · 15 unmodified lines
2417 lpfc_fdmi_cmd(vport, ndlp, SLI_MGMT_RPA,2496 lpfc_fdmi_cmd(vport, ndlp, SLI_MGMT_RPA,
2418 LPFC_FDMI_PORT_ATTR_num_disc);2497 LPFC_FDMI_PORT_ATTR_num_disc);
2419 } else {2498 } else {
2499 ndlp = lpfc_findnode_did(phba->pport, FDMI_DID);
2500 if (!ndlp)
2501 return;
2420 lpfc_fdmi_cmd(vport, ndlp, SLI_MGMT_RPRT,2502 lpfc_fdmi_cmd(vport, ndlp, SLI_MGMT_RPRT,
2421 LPFC_FDMI_PORT_ATTR_num_disc);2503 LPFC_FDMI_PORT_ATTR_num_disc);
2422 }2504 }
@@ -2830,31 +2912,59 @@ lpfc_fdmi_port_attr_support_speed(struct lpfc_vport *vport, · 407 unmodified lines
2830 struct lpfc_hba *phba = vport->phba;2912 struct lpfc_hba *phba = vport->phba;
2831 struct lpfc_fdmi_attr_entry *ae;2913 struct lpfc_fdmi_attr_entry *ae;
2832 uint32_t size;2914 uint32_t size;
2915 u32 tcfg;
2916 u8 i, cnt;
2833 2917
2834 ae = &ad->AttrValue;2918 ae = &ad->AttrValue;
2835 2919
2836 ae->un.AttrInt = 0;2920 ae->un.AttrInt = 0;
2837 if (!(phba->hba_flag & HBA_FCOE_MODE)) {2921 if (!(phba->hba_flag & HBA_FCOE_MODE)) {
2838 if (phba->lmt & LMT_256Gb)2922 cnt = 0;
2839 ae->un.AttrInt |= HBA_PORTSPEED_256GFC;2923 if (phba->sli_rev == LPFC_SLI_REV4) {
2840 if (phba->lmt & LMT_128Gb)2924 tcfg = phba->sli4_hba.conf_trunk;
2841 ae->un.AttrInt |= HBA_PORTSPEED_128GFC;2925 for (i = 0; i < 4; i++, tcfg >>= 1)
2842 if (phba->lmt & LMT_64Gb)2926 if (tcfg & 1)
2843 ae->un.AttrInt |= HBA_PORTSPEED_64GFC;2927 cnt++;
2844 if (phba->lmt & LMT_32Gb)2928 }
2845 ae->un.AttrInt |= HBA_PORTSPEED_32GFC;2929
2846 if (phba->lmt & LMT_16Gb)2930 if (cnt > 2) { /* 4 lane trunk group */
2847 ae->un.AttrInt |= HBA_PORTSPEED_16GFC;2931 if (phba->lmt & LMT_64Gb)
2848 if (phba->lmt & LMT_10Gb)2932 ae->un.AttrInt |= HBA_PORTSPEED_256GFC;
2849 ae->un.AttrInt |= HBA_PORTSPEED_10GFC;2933 if (phba->lmt & LMT_32Gb)
2850 if (phba->lmt & LMT_8Gb)2934 ae->un.AttrInt |= HBA_PORTSPEED_128GFC;
2851 ae->un.AttrInt |= HBA_PORTSPEED_8GFC;2935 if (phba->lmt & LMT_16Gb)
2852 if (phba->lmt & LMT_4Gb)2936 ae->un.AttrInt |= HBA_PORTSPEED_64GFC;
2853 ae->un.AttrInt |= HBA_PORTSPEED_4GFC;2937 } else if (cnt) { /* 2 lane trunk group */
2854 if (phba->lmt & LMT_2Gb)2938 if (phba->lmt & LMT_128Gb)
2855 ae->un.AttrInt |= HBA_PORTSPEED_2GFC;2939 ae->un.AttrInt |= HBA_PORTSPEED_256GFC;
2856 if (phba->lmt & LMT_1Gb)2940 if (phba->lmt & LMT_64Gb)
2857 ae->un.AttrInt |= HBA_PORTSPEED_1GFC;2941 ae->un.AttrInt |= HBA_PORTSPEED_128GFC;
2942 if (phba->lmt & LMT_32Gb)
2943 ae->un.AttrInt |= HBA_PORTSPEED_64GFC;
2944 if (phba->lmt & LMT_16Gb)
2945 ae->un.AttrInt |= HBA_PORTSPEED_32GFC;
2946 } else {
2947 if (phba->lmt & LMT_256Gb)
2948 ae->un.AttrInt |= HBA_PORTSPEED_256GFC;
2949 if (phba->lmt & LMT_128Gb)
2950 ae->un.AttrInt |= HBA_PORTSPEED_128GFC;
2951 if (phba->lmt & LMT_64Gb)
2952 ae->un.AttrInt |= HBA_PORTSPEED_64GFC;
2953 if (phba->lmt & LMT_32Gb)
2954 ae->un.AttrInt |= HBA_PORTSPEED_32GFC;
2955 if (phba->lmt & LMT_16Gb)
2956 ae->un.AttrInt |= HBA_PORTSPEED_16GFC;
2957 if (phba->lmt & LMT_10Gb)
2958 ae->un.AttrInt |= HBA_PORTSPEED_10GFC;
2959 if (phba->lmt & LMT_8Gb)
2960 ae->un.AttrInt |= HBA_PORTSPEED_8GFC;
2961 if (phba->lmt & LMT_4Gb)
2962 ae->un.AttrInt |= HBA_PORTSPEED_4GFC;
2963 if (phba->lmt & LMT_2Gb)
2964 ae->un.AttrInt |= HBA_PORTSPEED_2GFC;
2965 if (phba->lmt & LMT_1Gb)
2966 ae->un.AttrInt |= HBA_PORTSPEED_1GFC;
2967 }
2858 } else {2968 } else {
2859 /* FCoE links support only one speed */2969 /* FCoE links support only one speed */
2860 switch (phba->fc_linkspeed) {2970 switch (phba->fc_linkspeed) {
@@ -3125,6 +3235,7 @@ static int · 264 unmodified lines
3125lpfc_fdmi_port_attr_active_fc4type(struct lpfc_vport *vport,3235lpfc_fdmi_port_attr_active_fc4type(struct lpfc_vport *vport,
3126 struct lpfc_fdmi_attr_def *ad)3236 struct lpfc_fdmi_attr_def *ad)
3127{3237{
3238 struct lpfc_hba *phba = vport->phba;
3128 struct lpfc_fdmi_attr_entry *ae;3239 struct lpfc_fdmi_attr_entry *ae;
3129 uint32_t size;3240 uint32_t size;
3130 3241
@@ -3135,7 +3246,8 @@ lpfc_fdmi_port_attr_active_fc4type(struct lpfc_vport *vport, · 4 unmodified lines
3135 ae->un.AttrTypes[7] = 0x01; /* Type 0x20 - CT */3246 ae->un.AttrTypes[7] = 0x01; /* Type 0x20 - CT */
3136 3247
3137 /* Check to see if NVME is configured or not */3248 /* Check to see if NVME is configured or not */
3138 if (vport->phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME)3249 if (vport == phba->pport &&
3250 phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME)
3139 ae->un.AttrTypes[6] = 0x1; /* Type 0x28 - NVME */3251 ae->un.AttrTypes[6] = 0x1; /* Type 0x28 - NVME */
3140 3252
3141 size = FOURBYTES + 32;3253 size = FOURBYTES + 32;
@@ -3459,8 +3571,10 @@ lpfc_fdmi_cmd(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, · 317 unmodified lines
3459 3571
3460 /* FDMI request */3572 /* FDMI request */
3461 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,3573 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
3462 "0218 FDMI Request Data: x%x x%x x%x\n",3574 "0218 FDMI Request x%x mask x%x Data: x%x x%x x%x\n",
3463 vport->fc_flag, vport->port_state, cmdcode);3575 cmdcode, new_mask, vport->fdmi_port_mask,
3576 vport->fc_flag, vport->port_state);
3577
3464 CtReq = (struct lpfc_sli_ct_request *)mp->virt;3578 CtReq = (struct lpfc_sli_ct_request *)mp->virt;
3465 3579
3466 /* First populate the CT_IU preamble */3580 /* First populate the CT_IU preamble */
@@ -3529,6 +3643,12 @@ hba_out: · 62 unmodified lines
3529 break;3643 break;
3530 3644
3531 case SLI_MGMT_RPRT:3645 case SLI_MGMT_RPRT:
3646 if (vport->port_type != LPFC_PHYSICAL_PORT) {
3647 ndlp = lpfc_findnode_did(phba->pport, FDMI_DID);
3648 if (!ndlp)
3649 return 0;
3650 }
3651 fallthrough;
3532 case SLI_MGMT_RPA:3652 case SLI_MGMT_RPA:
3533 pab = (struct lpfc_fdmi_reg_portattr *)&CtReq->un.PortID;3653 pab = (struct lpfc_fdmi_reg_portattr *)&CtReq->un.PortID;
3534 if (cmdcode == SLI_MGMT_RPRT) {3654 if (cmdcode == SLI_MGMT_RPRT) {
@@ -3593,6 +3713,12 @@ port_out: · 58 unmodified lines
3593 rsp_size = FC_MAX_NS_RSP;3713 rsp_size = FC_MAX_NS_RSP;
3594 fallthrough;3714 fallthrough;
3595 case SLI_MGMT_DPRT:3715 case SLI_MGMT_DPRT:
3716 if (vport->port_type != LPFC_PHYSICAL_PORT) {
3717 ndlp = lpfc_findnode_did(phba->pport, FDMI_DID);
3718 if (!ndlp)
3719 return 0;
3720 }
3721 fallthrough;
3596 case SLI_MGMT_DPA:3722 case SLI_MGMT_DPA:
3597 pe = (struct lpfc_fdmi_port_entry *)&CtReq->un.PortID;3723 pe = (struct lpfc_fdmi_port_entry *)&CtReq->un.PortID;
3598 memcpy((uint8_t *)&pe->PortName,3724 memcpy((uint8_t *)&pe->PortName,
@@ -3780,8 +3906,8 @@ lpfc_cmpl_ct_cmd_vmid(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 181 unmodified lines
3780 struct lpfc_iocbq *rspiocb)3906 struct lpfc_iocbq *rspiocb)
3781{3907{
3782 struct lpfc_vport *vport = cmdiocb->vport;3908 struct lpfc_vport *vport = cmdiocb->vport;
3783 struct lpfc_dmabuf *inp = cmdiocb->context1;3909 struct lpfc_dmabuf *inp = cmdiocb->cmd_dmabuf;
3784 struct lpfc_dmabuf *outp = cmdiocb->context2;3910 struct lpfc_dmabuf *outp = cmdiocb->rsp_dmabuf;
3785 struct lpfc_sli_ct_request *ctcmd = inp->virt;3911 struct lpfc_sli_ct_request *ctcmd = inp->virt;
3786 struct lpfc_sli_ct_request *ctrsp = outp->virt;3912 struct lpfc_sli_ct_request *ctrsp = outp->virt;
3787 u16 rsp = ctrsp->CommandResponse.bits.CmdRsp;3913 u16 rsp = ctrsp->CommandResponse.bits.CmdRsp;
drivers/scsi/lpfc/lpfc_els.c+338−377
@@ -152,7 +152,7 @@ lpfc_els_chk_latt(struct lpfc_vport *vport) · 151 unmodified lines
152 * Buffer Descriptor Entries (BDEs), allocates buffers for both command152 * Buffer Descriptor Entries (BDEs), allocates buffers for both command
153 * payload and response payload (if expected). The reference count on the153 * payload and response payload (if expected). The reference count on the
154 * ndlp is incremented by 1 and the reference to the ndlp is put into154 * ndlp is incremented by 1 and the reference to the ndlp is put into
155 * context1 of the IOCB data structure for this IOCB to hold the ndlp155 * ndlp of the IOCB data structure for this IOCB to hold the ndlp
156 * reference for the command's callback function to access later.156 * reference for the command's callback function to access later.
157 *157 *
158 * Return code158 * Return code
@@ -279,8 +279,8 @@ lpfc_prep_els_iocb(struct lpfc_vport *vport, u8 expect_rsp, · 120 unmodified lines
279 bpl->type_size |= cpu_to_le32(ULP_BDE64_TYPE_BDE_64);279 bpl->type_size |= cpu_to_le32(ULP_BDE64_TYPE_BDE_64);
280 }280 }
281 281
282 elsiocb->context2 = pcmd;282 elsiocb->cmd_dmabuf = pcmd;
283 elsiocb->context3 = pbuflist;283 elsiocb->bpl_dmabuf = pbuflist;
284 elsiocb->retry = retry;284 elsiocb->retry = retry;
285 elsiocb->vport = vport;285 elsiocb->vport = vport;
286 elsiocb->drvrTimeout = (phba->fc_ratov << 1) + LPFC_DRVR_TIMEOUT;286 elsiocb->drvrTimeout = (phba->fc_ratov << 1) + LPFC_DRVR_TIMEOUT;
@@ -345,7 +345,6 @@ lpfc_issue_fabric_reglogin(struct lpfc_vport *vport) · 58 unmodified lines
345{345{
346 struct lpfc_hba *phba = vport->phba;346 struct lpfc_hba *phba = vport->phba;
347 LPFC_MBOXQ_t *mbox;347 LPFC_MBOXQ_t *mbox;
348 struct lpfc_dmabuf *mp;
349 struct lpfc_nodelist *ndlp;348 struct lpfc_nodelist *ndlp;
350 struct serv_parm *sp;349 struct serv_parm *sp;
351 int rc;350 int rc;
@@ -395,7 +394,7 @@ lpfc_issue_fabric_reglogin(struct lpfc_vport *vport) · 43 unmodified lines
395 mbox->ctx_ndlp = lpfc_nlp_get(ndlp);394 mbox->ctx_ndlp = lpfc_nlp_get(ndlp);
396 if (!mbox->ctx_ndlp) {395 if (!mbox->ctx_ndlp) {
397 err = 6;396 err = 6;
398 goto fail_no_ndlp;397 goto fail_free_mbox;
399 }398 }
400 399
401 rc = lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT);400 rc = lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT);
@@ -411,13 +410,8 @@ fail_issue_reg_login: · 9 unmodified lines
411 * for the failed mbox command.410 * for the failed mbox command.
412 */411 */
413 lpfc_nlp_put(ndlp);412 lpfc_nlp_put(ndlp);
414fail_no_ndlp:
415 mp = (struct lpfc_dmabuf *)mbox->ctx_buf;
416 lpfc_mbuf_free(phba, mp->virt, mp->phys);
417 kfree(mp);
418fail_free_mbox:413fail_free_mbox:
419 mempool_free(mbox, phba->mbox_mem_pool);414 lpfc_mbox_rsrc_cleanup(phba, mbox, MBOX_THD_UNLOCKED);
420
421fail:415fail:
422 lpfc_vport_set_state(vport, FC_VPORT_FAILED);416 lpfc_vport_set_state(vport, FC_VPORT_FAILED);
423 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,417 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
@@ -465,45 +459,37 @@ lpfc_issue_reg_vfi(struct lpfc_vport *vport) · 41 unmodified lines
465 459
466 /* Supply CSP's only if we are fabric connect or pt-to-pt connect */460 /* Supply CSP's only if we are fabric connect or pt-to-pt connect */
467 if ((vport->fc_flag & FC_FABRIC) || (vport->fc_flag & FC_PT2PT)) {461 if ((vport->fc_flag & FC_FABRIC) || (vport->fc_flag & FC_PT2PT)) {
468 dmabuf = kzalloc(sizeof(struct lpfc_dmabuf), GFP_KERNEL);462 rc = lpfc_mbox_rsrc_prep(phba, mboxq);
469 if (!dmabuf) {463 if (rc) {
470 rc = -ENOMEM;
471 goto fail;
472 }
473 dmabuf->virt = lpfc_mbuf_alloc(phba, MEM_PRI, &dmabuf->phys);
474 if (!dmabuf->virt) {
475 rc = -ENOMEM;464 rc = -ENOMEM;
476 goto fail;465 goto fail_mbox;
477 }466 }
467 dmabuf = mboxq->ctx_buf;
478 memcpy(dmabuf->virt, &phba->fc_fabparam,468 memcpy(dmabuf->virt, &phba->fc_fabparam,
479 sizeof(struct serv_parm));469 sizeof(struct serv_parm));
480 }470 }
481 471
482 vport->port_state = LPFC_FABRIC_CFG_LINK;472 vport->port_state = LPFC_FABRIC_CFG_LINK;
483 if (dmabuf)473 if (dmabuf) {
484 lpfc_reg_vfi(mboxq, vport, dmabuf->phys);474 lpfc_reg_vfi(mboxq, vport, dmabuf->phys);
485 else475 /* lpfc_reg_vfi memsets the mailbox. Restore the ctx_buf. */
476 mboxq->ctx_buf = dmabuf;
477 } else {
486 lpfc_reg_vfi(mboxq, vport, 0);478 lpfc_reg_vfi(mboxq, vport, 0);
479 }
487 480
488 mboxq->mbox_cmpl = lpfc_mbx_cmpl_reg_vfi;481 mboxq->mbox_cmpl = lpfc_mbx_cmpl_reg_vfi;
489 mboxq->vport = vport;482 mboxq->vport = vport;
490 mboxq->ctx_buf = dmabuf;
491 rc = lpfc_sli_issue_mbox(phba, mboxq, MBX_NOWAIT);483 rc = lpfc_sli_issue_mbox(phba, mboxq, MBX_NOWAIT);
492 if (rc == MBX_NOT_FINISHED) {484 if (rc == MBX_NOT_FINISHED) {
493 rc = -ENXIO;485 rc = -ENXIO;
494 goto fail;486 goto fail_mbox;
495 }487 }
496 return 0;488 return 0;
497 489
490fail_mbox:
491 lpfc_mbox_rsrc_cleanup(phba, mboxq, MBOX_THD_UNLOCKED);
498fail:492fail:
499 if (mboxq)
500 mempool_free(mboxq, phba->mbox_mem_pool);
501 if (dmabuf) {
502 if (dmabuf->virt)
503 lpfc_mbuf_free(phba, dmabuf->virt, dmabuf->phys);
504 kfree(dmabuf);
505 }
506
507 lpfc_vport_set_state(vport, FC_VPORT_FAILED);493 lpfc_vport_set_state(vport, FC_VPORT_FAILED);
508 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,494 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
509 "0289 Issue Register VFI failed: Err %d\n", rc);495 "0289 Issue Register VFI failed: Err %d\n", rc);
@@ -959,9 +945,9 @@ lpfc_cmpl_els_flogi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 449 unmodified lines
959{945{
960 struct lpfc_vport *vport = cmdiocb->vport;946 struct lpfc_vport *vport = cmdiocb->vport;
961 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);947 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
962 struct lpfc_nodelist *ndlp = cmdiocb->context1;948 struct lpfc_nodelist *ndlp = cmdiocb->ndlp;
963 IOCB_t *irsp;949 IOCB_t *irsp;
964 struct lpfc_dmabuf *pcmd = cmdiocb->context2, *prsp;950 struct lpfc_dmabuf *pcmd = cmdiocb->cmd_dmabuf, *prsp;
965 struct serv_parm *sp;951 struct serv_parm *sp;
966 uint16_t fcf_index;952 uint16_t fcf_index;
967 int rc;953 int rc;
@@ -1119,7 +1105,8 @@ stop_rr_fcf_flogi: · 151 unmodified lines
1119 sp->cmn.priority_tagging, kref_read(&ndlp->kref));1105 sp->cmn.priority_tagging, kref_read(&ndlp->kref));
1120 1106
1121 if (sp->cmn.priority_tagging)1107 if (sp->cmn.priority_tagging)
1122 vport->vmid_flag |= LPFC_VMID_ISSUE_QFPA;1108 vport->phba->pport->vmid_flag |= (LPFC_VMID_ISSUE_QFPA |
1109 LPFC_VMID_TYPE_PRIO);
1123 1110
1124 if (vport->port_state == LPFC_FLOGI) {1111 if (vport->port_state == LPFC_FLOGI) {
1125 /*1112 /*
@@ -1232,7 +1219,7 @@ lpfc_cmpl_els_link_down(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 106 unmodified lines
1232 uint32_t cmd;1219 uint32_t cmd;
1233 u32 ulp_status, ulp_word4;1220 u32 ulp_status, ulp_word4;
1234 1221
1235 pcmd = (uint32_t *)(((struct lpfc_dmabuf *)cmdiocb->context2)->virt);1222 pcmd = (uint32_t *)cmdiocb->cmd_dmabuf->virt;
1236 cmd = *pcmd;1223 cmd = *pcmd;
1237 1224
1238 ulp_status = get_job_ulpstatus(phba, rspiocb);1225 ulp_status = get_job_ulpstatus(phba, rspiocb);
@@ -1265,7 +1252,7 @@ lpfc_cmpl_els_link_down(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 26 unmodified lines
1265 * out FLOGI ELS command with one outstanding fabric IOCB at a time.1252 * out FLOGI ELS command with one outstanding fabric IOCB at a time.
1266 *1253 *
1267 * Note that the ndlp reference count will be incremented by 1 for holding the1254 * Note that the ndlp reference count will be incremented by 1 for holding the
1268 * ndlp and the reference to ndlp will be stored into the context1 field of1255 * ndlp and the reference to ndlp will be stored into the ndlp field of
1269 * the IOCB for the completion callback function to the FLOGI ELS command.1256 * the IOCB for the completion callback function to the FLOGI ELS command.
1270 *1257 *
1271 * Return code1258 * Return code
@@ -1295,7 +1282,7 @@ lpfc_issue_els_flogi(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, · 23 unmodified lines
1295 return 1;1282 return 1;
1296 1283
1297 wqe = &elsiocb->wqe;1284 wqe = &elsiocb->wqe;
1298 pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt);1285 pcmd = (uint8_t *)elsiocb->cmd_dmabuf->virt;
1299 icmd = &elsiocb->iocb;1286 icmd = &elsiocb->iocb;
1300 1287
1301 /* For FLOGI request, remainder of payload is service parameters */1288 /* For FLOGI request, remainder of payload is service parameters */
@@ -1372,8 +1359,8 @@ lpfc_issue_els_flogi(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, · 70 unmodified lines
1372 "Issue FLOGI: opt:x%x",1359 "Issue FLOGI: opt:x%x",
1373 phba->sli3_options, 0, 0);1360 phba->sli3_options, 0, 0);
1374 1361
1375 elsiocb->context1 = lpfc_nlp_get(ndlp);1362 elsiocb->ndlp = lpfc_nlp_get(ndlp);
1376 if (!elsiocb->context1) {1363 if (!elsiocb->ndlp) {
1377 lpfc_els_free_iocb(phba, elsiocb);1364 lpfc_els_free_iocb(phba, elsiocb);
1378 return 1;1365 return 1;
1379 }1366 }
@@ -1387,6 +1374,9 @@ lpfc_issue_els_flogi(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, · 7 unmodified lines
1387 1374
1388 phba->hba_flag |= (HBA_FLOGI_ISSUED | HBA_FLOGI_OUTSTANDING);1375 phba->hba_flag |= (HBA_FLOGI_ISSUED | HBA_FLOGI_OUTSTANDING);
1389 1376
1377 /* Clear external loopback plug detected flag */
1378 phba->link_flag &= ~LS_EXTERNAL_LOOPBACK;
1379
1390 /* Check for a deferred FLOGI ACC condition */1380 /* Check for a deferred FLOGI ACC condition */
1391 if (phba->defer_flogi_acc_flag) {1381 if (phba->defer_flogi_acc_flag) {
1392 /* lookup ndlp for received FLOGI */1382 /* lookup ndlp for received FLOGI */
@@ -1474,7 +1464,7 @@ lpfc_els_abort_flogi(struct lpfc_hba *phba) · 81 unmodified lines
1474 list_for_each_entry_safe(iocb, next_iocb, &pring->txcmplq, list) {1464 list_for_each_entry_safe(iocb, next_iocb, &pring->txcmplq, list) {
1475 ulp_command = get_job_cmnd(phba, iocb);1465 ulp_command = get_job_cmnd(phba, iocb);
1476 if (ulp_command == CMD_ELS_REQUEST64_CR) {1466 if (ulp_command == CMD_ELS_REQUEST64_CR) {
1477 ndlp = (struct lpfc_nodelist *)(iocb->context1);1467 ndlp = iocb->ndlp;
1478 if (ndlp && ndlp->nlp_DID == Fabric_DID) {1468 if (ndlp && ndlp->nlp_DID == Fabric_DID) {
1479 if ((phba->pport->fc_flag & FC_PT2PT) &&1469 if ((phba->pport->fc_flag & FC_PT2PT) &&
1480 !(phba->pport->fc_flag & FC_PT2PT_PLOGI))1470 !(phba->pport->fc_flag & FC_PT2PT_PLOGI))
@@ -1531,11 +1521,16 @@ lpfc_initial_flogi(struct lpfc_vport *vport) · 50 unmodified lines
1531 lpfc_enqueue_node(vport, ndlp);1521 lpfc_enqueue_node(vport, ndlp);
1532 }1522 }
1533 1523
1524 /* Reset the Fabric flag, topology change may have happened */
1525 vport->fc_flag &= ~FC_FABRIC;
1534 if (lpfc_issue_els_flogi(vport, ndlp, 0)) {1526 if (lpfc_issue_els_flogi(vport, ndlp, 0)) {
1535 /* This decrement of reference count to node shall kick off1527 /* A node reference should be retained while registered with a
1536 * the release of the node.1528 * transport or dev-loss-evt work is pending.
1529 * Otherwise, decrement node reference to trigger release.
1537 */1530 */
1538 lpfc_nlp_put(ndlp);1531 if (!(ndlp->fc4_xpt_flags & (SCSI_XPT_REGD | NVME_XPT_REGD)) &&
1532 !(ndlp->nlp_flag & NLP_IN_DEV_LOSS))
1533 lpfc_nlp_put(ndlp);
1539 return 0;1534 return 0;
1540 }1535 }
1541 return 1;1536 return 1;
@@ -1578,10 +1573,13 @@ lpfc_initial_fdisc(struct lpfc_vport *vport) · 36 unmodified lines
1578 }1573 }
1579 1574
1580 if (lpfc_issue_els_fdisc(vport, ndlp, 0)) {1575 if (lpfc_issue_els_fdisc(vport, ndlp, 0)) {
1581 /* decrement node reference count to trigger the release of1576 /* A node reference should be retained while registered with a
1582 * the node.1577 * transport or dev-loss-evt work is pending.
1578 * Otherwise, decrement node reference to trigger release.
1583 */1579 */
1584 lpfc_nlp_put(ndlp);1580 if (!(ndlp->fc4_xpt_flags & (SCSI_XPT_REGD | NVME_XPT_REGD)) &&
1581 !(ndlp->nlp_flag & NLP_IN_DEV_LOSS))
1582 lpfc_nlp_put(ndlp);
1585 return 0;1583 return 0;
1586 }1584 }
1587 return 1;1585 return 1;
@@ -1888,6 +1886,7 @@ lpfc_end_rscn(struct lpfc_vport *vport) · 300 unmodified lines
1888 else {1886 else {
1889 spin_lock_irq(shost->host_lock);1887 spin_lock_irq(shost->host_lock);
1890 vport->fc_flag &= ~FC_RSCN_MODE;1888 vport->fc_flag &= ~FC_RSCN_MODE;
1889 vport->fc_flag |= FC_RSCN_MEMENTO;
1891 spin_unlock_irq(shost->host_lock);1890 spin_unlock_irq(shost->host_lock);
1892 }1891 }
1893 }1892 }
@@ -1910,14 +1909,14 @@ lpfc_cmpl_els_rrq(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 16 unmodified lines
1910 struct lpfc_iocbq *rspiocb)1909 struct lpfc_iocbq *rspiocb)
1911{1910{
1912 struct lpfc_vport *vport = cmdiocb->vport;1911 struct lpfc_vport *vport = cmdiocb->vport;
1913 struct lpfc_nodelist *ndlp = cmdiocb->context1;1912 struct lpfc_nodelist *ndlp = cmdiocb->ndlp;
1914 struct lpfc_node_rrq *rrq;1913 struct lpfc_node_rrq *rrq;
1915 u32 ulp_status = get_job_ulpstatus(phba, rspiocb);1914 u32 ulp_status = get_job_ulpstatus(phba, rspiocb);
1916 u32 ulp_word4 = get_job_word4(phba, rspiocb);1915 u32 ulp_word4 = get_job_word4(phba, rspiocb);
1917 1916
1918 /* we pass cmdiocb to state machine which needs rspiocb as well */1917 /* we pass cmdiocb to state machine which needs rspiocb as well */
1919 rrq = cmdiocb->context_un.rrq;1918 rrq = cmdiocb->context_un.rrq;
1920 cmdiocb->context_un.rsp_iocb = rspiocb;1919 cmdiocb->rsp_iocb = rspiocb;
1921 1920
1922 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,1921 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
1923 "RRQ cmpl: status:x%x/x%x did:x%x",1922 "RRQ cmpl: status:x%x/x%x did:x%x",
@@ -1983,9 +1982,10 @@ lpfc_cmpl_els_plogi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 59 unmodified lines
1983 int disc;1982 int disc;
1984 struct serv_parm *sp = NULL;1983 struct serv_parm *sp = NULL;
1985 u32 ulp_status, ulp_word4, did, iotag;1984 u32 ulp_status, ulp_word4, did, iotag;
1985 bool release_node = false;
1986 1986
1987 /* we pass cmdiocb to state machine which needs rspiocb as well */1987 /* we pass cmdiocb to state machine which needs rspiocb as well */
1988 cmdiocb->context_un.rsp_iocb = rspiocb;1988 cmdiocb->rsp_iocb = rspiocb;
1989 1989
1990 ulp_status = get_job_ulpstatus(phba, rspiocb);1990 ulp_status = get_job_ulpstatus(phba, rspiocb);
1991 ulp_word4 = get_job_word4(phba, rspiocb);1991 ulp_word4 = get_job_word4(phba, rspiocb);
@@ -2071,23 +2071,24 @@ lpfc_cmpl_els_plogi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 79 unmodified lines
2071 spin_unlock_irq(&ndlp->lock);2071 spin_unlock_irq(&ndlp->lock);
2072 goto out;2072 goto out;
2073 }2073 }
2074 spin_unlock_irq(&ndlp->lock);
2075 2074
2076 /* No PLOGI collision and the node is not registered with the2075 /* No PLOGI collision and the node is not registered with the
2077 * scsi or nvme transport. It is no longer an active node. Just2076 * scsi or nvme transport. It is no longer an active node. Just
2078 * start the device remove process.2077 * start the device remove process.
2079 */2078 */
2080 if (!(ndlp->fc4_xpt_flags & (SCSI_XPT_REGD | NVME_XPT_REGD))) {2079 if (!(ndlp->fc4_xpt_flags & (SCSI_XPT_REGD | NVME_XPT_REGD))) {
2081 spin_lock_irq(&ndlp->lock);
2082 ndlp->nlp_flag &= ~NLP_NPR_2B_DISC;2080 ndlp->nlp_flag &= ~NLP_NPR_2B_DISC;
2083 spin_unlock_irq(&ndlp->lock);2081 if (!(ndlp->nlp_flag & NLP_IN_DEV_LOSS))
2082 release_node = true;
2083 }
2084 spin_unlock_irq(&ndlp->lock);
2085
2086 if (release_node)
2084 lpfc_disc_state_machine(vport, ndlp, cmdiocb,2087 lpfc_disc_state_machine(vport, ndlp, cmdiocb,
2085 NLP_EVT_DEVICE_RM);2088 NLP_EVT_DEVICE_RM);
2086 }
2087 } else {2089 } else {
2088 /* Good status, call state machine */2090 /* Good status, call state machine */
2089 prsp = list_entry(((struct lpfc_dmabuf *)2091 prsp = list_entry(cmdiocb->cmd_dmabuf->list.next,
2090 cmdiocb->context2)->list.next,
2091 struct lpfc_dmabuf, list);2092 struct lpfc_dmabuf, list);
2092 ndlp = lpfc_plogi_confirm_nport(phba, prsp->virt, ndlp);2093 ndlp = lpfc_plogi_confirm_nport(phba, prsp->virt, ndlp);
2093 2094
@@ -2132,7 +2133,7 @@ out: · 38 unmodified lines
2132 2133
2133out_freeiocb:2134out_freeiocb:
2134 /* Release the reference on the original I/O request. */2135 /* Release the reference on the original I/O request. */
2135 free_ndlp = (struct lpfc_nodelist *)cmdiocb->context1;2136 free_ndlp = cmdiocb->ndlp;
2136 2137
2137 lpfc_els_free_iocb(phba, cmdiocb);2138 lpfc_els_free_iocb(phba, cmdiocb);
2138 lpfc_nlp_put(free_ndlp);2139 lpfc_nlp_put(free_ndlp);
@@ -2152,7 +2153,7 @@ out_freeiocb: · 13 unmodified lines
2152 * the lpfc_sli_issue_iocb() routine to send out PLOGI ELS command.2153 * the lpfc_sli_issue_iocb() routine to send out PLOGI ELS command.
2153 *2154 *
2154 * Note that the ndlp reference count will be incremented by 1 for holding2155 * Note that the ndlp reference count will be incremented by 1 for holding
2155 * the ndlp and the reference to ndlp will be stored into the context1 field2156 * the ndlp and the reference to ndlp will be stored into the ndlp field
2156 * of the IOCB for the completion callback function to the PLOGI ELS command.2157 * of the IOCB for the completion callback function to the PLOGI ELS command.
2157 *2158 *
2158 * Return code2159 * Return code
@@ -2203,7 +2204,7 @@ lpfc_issue_els_plogi(struct lpfc_vport *vport, uint32_t did, uint8_t retry) · 44 unmodified lines
2203 ndlp->nlp_flag &= ~NLP_FCP_PRLI_RJT;2204 ndlp->nlp_flag &= ~NLP_FCP_PRLI_RJT;
2204 spin_unlock_irq(&ndlp->lock);2205 spin_unlock_irq(&ndlp->lock);
2205 2206
2206 pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt);2207 pcmd = (uint8_t *)elsiocb->cmd_dmabuf->virt;
2207 2208
2208 /* For PLOGI request, remainder of payload is service parameters */2209 /* For PLOGI request, remainder of payload is service parameters */
2209 *((uint32_t *) (pcmd)) = ELS_CMD_PLOGI;2210 *((uint32_t *) (pcmd)) = ELS_CMD_PLOGI;
@@ -2255,8 +2256,8 @@ lpfc_issue_els_plogi(struct lpfc_vport *vport, uint32_t did, uint8_t retry) · 45 unmodified lines
2255 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,2256 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
2256 "Issue PLOGI: did:x%x refcnt %d",2257 "Issue PLOGI: did:x%x refcnt %d",
2257 did, kref_read(&ndlp->kref), 0);2258 did, kref_read(&ndlp->kref), 0);
2258 elsiocb->context1 = lpfc_nlp_get(ndlp);2259 elsiocb->ndlp = lpfc_nlp_get(ndlp);
2259 if (!elsiocb->context1) {2260 if (!elsiocb->ndlp) {
2260 lpfc_els_free_iocb(phba, elsiocb);2261 lpfc_els_free_iocb(phba, elsiocb);
2261 return 1;2262 return 1;
2262 }2263 }
@@ -2294,11 +2295,12 @@ lpfc_cmpl_els_prli(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 31 unmodified lines
2294 u32 loglevel;2295 u32 loglevel;
2295 u32 ulp_status;2296 u32 ulp_status;
2296 u32 ulp_word4;2297 u32 ulp_word4;
2298 bool release_node = false;
2297 2299
2298 /* we pass cmdiocb to state machine which needs rspiocb as well */2300 /* we pass cmdiocb to state machine which needs rspiocb as well */
2299 cmdiocb->context_un.rsp_iocb = rspiocb;2301 cmdiocb->rsp_iocb = rspiocb;
2300 2302
2301 ndlp = (struct lpfc_nodelist *) cmdiocb->context1;2303 ndlp = cmdiocb->ndlp;
2302 2304
2303 ulp_status = get_job_ulpstatus(phba, rspiocb);2305 ulp_status = get_job_ulpstatus(phba, rspiocb);
2304 ulp_word4 = get_job_word4(phba, rspiocb);2306 ulp_word4 = get_job_word4(phba, rspiocb);
@@ -2370,14 +2372,18 @@ lpfc_cmpl_els_prli(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 65 unmodified lines
2370 * it is no longer an active node. Otherwise devloss2372 * it is no longer an active node. Otherwise devloss
2371 * handles the final cleanup.2373 * handles the final cleanup.
2372 */2374 */
2375 spin_lock_irq(&ndlp->lock);
2373 if (!(ndlp->fc4_xpt_flags & (SCSI_XPT_REGD | NVME_XPT_REGD)) &&2376 if (!(ndlp->fc4_xpt_flags & (SCSI_XPT_REGD | NVME_XPT_REGD)) &&
2374 !ndlp->fc4_prli_sent) {2377 !ndlp->fc4_prli_sent) {
2375 spin_lock_irq(&ndlp->lock);
2376 ndlp->nlp_flag &= ~NLP_NPR_2B_DISC;2378 ndlp->nlp_flag &= ~NLP_NPR_2B_DISC;
2377 spin_unlock_irq(&ndlp->lock);2379 if (!(ndlp->nlp_flag & NLP_IN_DEV_LOSS))
2380 release_node = true;
2381 }
2382 spin_unlock_irq(&ndlp->lock);
2383
2384 if (release_node)
2378 lpfc_disc_state_machine(vport, ndlp, cmdiocb,2385 lpfc_disc_state_machine(vport, ndlp, cmdiocb,
2379 NLP_EVT_DEVICE_RM);2386 NLP_EVT_DEVICE_RM);
2380 }
2381 } else {2387 } else {
2382 /* Good status, call state machine. However, if another2388 /* Good status, call state machine. However, if another
2383 * PRLI is outstanding, don't call the state machine2389 * PRLI is outstanding, don't call the state machine
@@ -2407,7 +2413,7 @@ out: · 23 unmodified lines
2407 * routine lpfc_sli_issue_iocb() to send out PRLI command.2413 * routine lpfc_sli_issue_iocb() to send out PRLI command.
2408 *2414 *
2409 * Note that the ndlp reference count will be incremented by 1 for holding the2415 * Note that the ndlp reference count will be incremented by 1 for holding the
2410 * ndlp and the reference to ndlp will be stored into the context1 field of2416 * ndlp and the reference to ndlp will be stored into the ndlp field of
2411 * the IOCB for the completion callback function to the PRLI ELS command.2417 * the IOCB for the completion callback function to the PRLI ELS command.
2412 *2418 *
2413 * Return code2419 * Return code
@@ -2428,13 +2434,14 @@ lpfc_issue_els_prli(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, · 14 unmodified lines
2428 u32 local_nlp_type, elscmd;2434 u32 local_nlp_type, elscmd;
2429 2435
2430 /*2436 /*
2431 * If we are in RSCN mode, the FC4 types supported from a2437 * If discovery was kicked off from RSCN mode,
2438 * the FC4 types supported from a
2432 * previous GFT_ID command may not be accurate. So, if we2439 * previous GFT_ID command may not be accurate. So, if we
2433 * are a NVME Initiator, always look for the possibility of2440 * are a NVME Initiator, always look for the possibility of
2434 * the remote NPort beng a NVME Target.2441 * the remote NPort beng a NVME Target.
2435 */2442 */
2436 if (phba->sli_rev == LPFC_SLI_REV4 &&2443 if (phba->sli_rev == LPFC_SLI_REV4 &&
2437 vport->fc_flag & FC_RSCN_MODE &&2444 vport->fc_flag & (FC_RSCN_MODE | FC_RSCN_MEMENTO) &&
2438 vport->nvmei_support)2445 vport->nvmei_support)
2439 ndlp->nlp_fc4_type |= NLP_FC4_NVME;2446 ndlp->nlp_fc4_type |= NLP_FC4_NVME;
2440 local_nlp_type = ndlp->nlp_fc4_type;2447 local_nlp_type = ndlp->nlp_fc4_type;
@@ -2481,7 +2488,7 @@ lpfc_issue_els_prli(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, · 40 unmodified lines
2481 if (!elsiocb)2488 if (!elsiocb)
2482 return 1;2489 return 1;
2483 2490
2484 pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt);2491 pcmd = (uint8_t *)elsiocb->cmd_dmabuf->virt;
2485 2492
2486 /* For PRLI request, remainder of payload is service parameters */2493 /* For PRLI request, remainder of payload is service parameters */
2487 memset(pcmd, 0, cmdsize);2494 memset(pcmd, 0, cmdsize);
@@ -2555,33 +2562,32 @@ lpfc_issue_els_prli(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, · 67 unmodified lines
2555 2562
2556 phba->fc_stat.elsXmitPRLI++;2563 phba->fc_stat.elsXmitPRLI++;
2557 elsiocb->cmd_cmpl = lpfc_cmpl_els_prli;2564 elsiocb->cmd_cmpl = lpfc_cmpl_els_prli;
2558 spin_lock_irq(&ndlp->lock);
2559 ndlp->nlp_flag |= NLP_PRLI_SND;
2560
2561 /* The vport counters are used for lpfc_scan_finished, but
2562 * the ndlp is used to track outstanding PRLIs for different
2563 * FC4 types.
2564 */
2565 vport->fc_prli_sent++;
2566 ndlp->fc4_prli_sent++;
2567 spin_unlock_irq(&ndlp->lock);
2568 2565
2569 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,2566 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
2570 "Issue PRLI: did:x%x refcnt %d",2567 "Issue PRLI: did:x%x refcnt %d",
2571 ndlp->nlp_DID, kref_read(&ndlp->kref), 0);2568 ndlp->nlp_DID, kref_read(&ndlp->kref), 0);
2572 elsiocb->context1 = lpfc_nlp_get(ndlp);2569 elsiocb->ndlp = lpfc_nlp_get(ndlp);
2573 if (!elsiocb->context1) {2570 if (!elsiocb->ndlp) {
2574 lpfc_els_free_iocb(phba, elsiocb);2571 lpfc_els_free_iocb(phba, elsiocb);
2575 goto err;2572 return 1;
2576 }2573 }
2577 2574
2578 rc = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0);2575 rc = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0);
2579 if (rc == IOCB_ERROR) {2576 if (rc == IOCB_ERROR) {
2580 lpfc_els_free_iocb(phba, elsiocb);2577 lpfc_els_free_iocb(phba, elsiocb);
2581 lpfc_nlp_put(ndlp);2578 lpfc_nlp_put(ndlp);
2582 goto err;2579 return 1;
2583 }2580 }
2584 2581
2582 /* The vport counters are used for lpfc_scan_finished, but
2583 * the ndlp is used to track outstanding PRLIs for different
2584 * FC4 types.
2585 */
2586 spin_lock_irq(&ndlp->lock);
2587 ndlp->nlp_flag |= NLP_PRLI_SND;
2588 vport->fc_prli_sent++;
2589 ndlp->fc4_prli_sent++;
2590 spin_unlock_irq(&ndlp->lock);
2585 2591
2586 /* The driver supports 2 FC4 types. Make sure2592 /* The driver supports 2 FC4 types. Make sure
2587 * a PRLI is issued for all types before exiting.2593 * a PRLI is issued for all types before exiting.
@@ -2591,12 +2597,6 @@ lpfc_issue_els_prli(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, · 3 unmodified lines
2591 goto send_next_prli;2597 goto send_next_prli;
2592 else2598 else
2593 return 0;2599 return 0;
2594
2595err:
2596 spin_lock_irq(&ndlp->lock);
2597 ndlp->nlp_flag &= ~NLP_PRLI_SND;
2598 spin_unlock_irq(&ndlp->lock);
2599 return 1;
2600}2600}
2601 2601
2602/**2602/**
@@ -2749,11 +2749,12 @@ lpfc_cmpl_els_adisc(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 146 unmodified lines
2749 struct lpfc_nodelist *ndlp;2749 struct lpfc_nodelist *ndlp;
2750 int disc;2750 int disc;
2751 u32 ulp_status, ulp_word4, tmo;2751 u32 ulp_status, ulp_word4, tmo;
2752 bool release_node = false;
2752 2753
2753 /* we pass cmdiocb to state machine which needs rspiocb as well */2754 /* we pass cmdiocb to state machine which needs rspiocb as well */
2754 cmdiocb->context_un.rsp_iocb = rspiocb;2755 cmdiocb->rsp_iocb = rspiocb;
2755 2756
2756 ndlp = (struct lpfc_nodelist *) cmdiocb->context1;2757 ndlp = cmdiocb->ndlp;
2757 2758
2758 ulp_status = get_job_ulpstatus(phba, rspiocb);2759 ulp_status = get_job_ulpstatus(phba, rspiocb);
2759 ulp_word4 = get_job_word4(phba, rspiocb);2760 ulp_word4 = get_job_word4(phba, rspiocb);
@@ -2815,13 +2816,17 @@ lpfc_cmpl_els_adisc(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 55 unmodified lines
2815 * transport, it is no longer an active node. Otherwise2816 * transport, it is no longer an active node. Otherwise
2816 * devloss handles the final cleanup.2817 * devloss handles the final cleanup.
2817 */2818 */
2819 spin_lock_irq(&ndlp->lock);
2818 if (!(ndlp->fc4_xpt_flags & (SCSI_XPT_REGD | NVME_XPT_REGD))) {2820 if (!(ndlp->fc4_xpt_flags & (SCSI_XPT_REGD | NVME_XPT_REGD))) {
2819 spin_lock_irq(&ndlp->lock);
2820 ndlp->nlp_flag &= ~NLP_NPR_2B_DISC;2821 ndlp->nlp_flag &= ~NLP_NPR_2B_DISC;
2821 spin_unlock_irq(&ndlp->lock);2822 if (!(ndlp->nlp_flag & NLP_IN_DEV_LOSS))
2823 release_node = true;
2824 }
2825 spin_unlock_irq(&ndlp->lock);
2826
2827 if (release_node)
2822 lpfc_disc_state_machine(vport, ndlp, cmdiocb,2828 lpfc_disc_state_machine(vport, ndlp, cmdiocb,
2823 NLP_EVT_DEVICE_RM);2829 NLP_EVT_DEVICE_RM);
2824 }
2825 } else2830 } else
2826 /* Good status, call state machine */2831 /* Good status, call state machine */
2827 lpfc_disc_state_machine(vport, ndlp, cmdiocb,2832 lpfc_disc_state_machine(vport, ndlp, cmdiocb,
@@ -2848,7 +2853,7 @@ out: · 20 unmodified lines
2848 * to issue the ADISC ELS command.2853 * to issue the ADISC ELS command.
2849 *2854 *
2850 * Note that the ndlp reference count will be incremented by 1 for holding the2855 * Note that the ndlp reference count will be incremented by 1 for holding the
2851 * ndlp and the reference to ndlp will be stored into the context1 field of2856 * ndlp and the reference to ndlp will be stored into the ndlp field of
2852 * the IOCB for the completion callback function to the ADISC ELS command.2857 * the IOCB for the completion callback function to the ADISC ELS command.
2853 *2858 *
2854 * Return code2859 * Return code
@@ -2872,7 +2877,7 @@ lpfc_issue_els_adisc(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, · 17 unmodified lines
2872 if (!elsiocb)2877 if (!elsiocb)
2873 return 1;2878 return 1;
2874 2879
2875 pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt);2880 pcmd = (uint8_t *)elsiocb->cmd_dmabuf->virt;
2876 2881
2877 /* For ADISC request, remainder of payload is service parameters */2882 /* For ADISC request, remainder of payload is service parameters */
2878 *((uint32_t *) (pcmd)) = ELS_CMD_ADISC;2883 *((uint32_t *) (pcmd)) = ELS_CMD_ADISC;
@@ -2890,8 +2895,8 @@ lpfc_issue_els_adisc(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, · 11 unmodified lines
2890 spin_lock_irq(&ndlp->lock);2895 spin_lock_irq(&ndlp->lock);
2891 ndlp->nlp_flag |= NLP_ADISC_SND;2896 ndlp->nlp_flag |= NLP_ADISC_SND;
2892 spin_unlock_irq(&ndlp->lock);2897 spin_unlock_irq(&ndlp->lock);
2893 elsiocb->context1 = lpfc_nlp_get(ndlp);2898 elsiocb->ndlp = lpfc_nlp_get(ndlp);
2894 if (!elsiocb->context1) {2899 if (!elsiocb->ndlp) {
2895 lpfc_els_free_iocb(phba, elsiocb);2900 lpfc_els_free_iocb(phba, elsiocb);
2896 goto err;2901 goto err;
2897 }2902 }
@@ -2931,7 +2936,7 @@ static void · 33 unmodified lines
2931lpfc_cmpl_els_logo(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,2936lpfc_cmpl_els_logo(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
2932 struct lpfc_iocbq *rspiocb)2937 struct lpfc_iocbq *rspiocb)
2933{2938{
2934 struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *) cmdiocb->context1;2939 struct lpfc_nodelist *ndlp = cmdiocb->ndlp;
2935 struct lpfc_vport *vport = ndlp->vport;2940 struct lpfc_vport *vport = ndlp->vport;
2936 IOCB_t *irsp;2941 IOCB_t *irsp;
2937 unsigned long flags;2942 unsigned long flags;
@@ -2942,7 +2947,7 @@ lpfc_cmpl_els_logo(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 4 unmodified lines
2942 u32 tmo;2947 u32 tmo;
2943 2948
2944 /* we pass cmdiocb to state machine which needs rspiocb as well */2949 /* we pass cmdiocb to state machine which needs rspiocb as well */
2945 cmdiocb->context_un.rsp_iocb = rspiocb;2950 cmdiocb->rsp_iocb = rspiocb;
2946 2951
2947 ulp_status = get_job_ulpstatus(phba, rspiocb);2952 ulp_status = get_job_ulpstatus(phba, rspiocb);
2948 ulp_word4 = get_job_word4(phba, rspiocb);2953 ulp_word4 = get_job_word4(phba, rspiocb);
@@ -2993,7 +2998,10 @@ lpfc_cmpl_els_logo(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 44 unmodified lines
2993 ndlp->nlp_DID, ulp_status,2998 ndlp->nlp_DID, ulp_status,
2994 ulp_word4);2999 ulp_word4);
2995 3000
3001 /* Call NLP_EVT_DEVICE_RM if link is down or LOGO is aborted */
2996 if (lpfc_error_lost_link(ulp_status, ulp_word4)) {3002 if (lpfc_error_lost_link(ulp_status, ulp_word4)) {
3003 lpfc_disc_state_machine(vport, ndlp, cmdiocb,
3004 NLP_EVT_DEVICE_RM);
2997 skip_recovery = 1;3005 skip_recovery = 1;
2998 goto out;3006 goto out;
2999 }3007 }
@@ -3081,7 +3089,7 @@ out: · 81 unmodified lines
3081 * lpfc_sli_issue_iocb() routine to send out the LOGO ELS command.3089 * lpfc_sli_issue_iocb() routine to send out the LOGO ELS command.
3082 *3090 *
3083 * Note that the ndlp reference count will be incremented by 1 for holding the3091 * Note that the ndlp reference count will be incremented by 1 for holding the
3084 * ndlp and the reference to ndlp will be stored into the context1 field of3092 * ndlp and the reference to ndlp will be stored into the ndlp field of
3085 * the IOCB for the completion callback function to the LOGO ELS command.3093 * the IOCB for the completion callback function to the LOGO ELS command.
3086 *3094 *
3087 * Callers of this routine are expected to unregister the RPI first3095 * Callers of this routine are expected to unregister the RPI first
@@ -3113,7 +3121,7 @@ lpfc_issue_els_logo(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, · 25 unmodified lines
3113 if (!elsiocb)3121 if (!elsiocb)
3114 return 1;3122 return 1;
3115 3123
3116 pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt);3124 pcmd = (uint8_t *)elsiocb->cmd_dmabuf->virt;
3117 *((uint32_t *) (pcmd)) = ELS_CMD_LOGO;3125 *((uint32_t *) (pcmd)) = ELS_CMD_LOGO;
3118 pcmd += sizeof(uint32_t);3126 pcmd += sizeof(uint32_t);
3119 3127
@@ -3128,8 +3136,8 @@ lpfc_issue_els_logo(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, · 8 unmodified lines
3128 ndlp->nlp_flag |= NLP_LOGO_SND;3136 ndlp->nlp_flag |= NLP_LOGO_SND;
3129 ndlp->nlp_flag &= ~NLP_ISSUE_LOGO;3137 ndlp->nlp_flag &= ~NLP_ISSUE_LOGO;
3130 spin_unlock_irq(&ndlp->lock);3138 spin_unlock_irq(&ndlp->lock);
3131 elsiocb->context1 = lpfc_nlp_get(ndlp);3139 elsiocb->ndlp = lpfc_nlp_get(ndlp);
3132 if (!elsiocb->context1) {3140 if (!elsiocb->ndlp) {
3133 lpfc_els_free_iocb(phba, elsiocb);3141 lpfc_els_free_iocb(phba, elsiocb);
3134 goto err;3142 goto err;
3135 }3143 }
@@ -3207,7 +3215,7 @@ lpfc_cmpl_els_cmd(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 71 unmodified lines
3207 /* Check to see if link went down during discovery */3215 /* Check to see if link went down during discovery */
3208 lpfc_els_chk_latt(vport);3216 lpfc_els_chk_latt(vport);
3209 3217
3210 free_ndlp = (struct lpfc_nodelist *)cmdiocb->context1;3218 free_ndlp = cmdiocb->ndlp;
3211 3219
3212 lpfc_els_free_iocb(phba, cmdiocb);3220 lpfc_els_free_iocb(phba, cmdiocb);
3213 lpfc_nlp_put(free_ndlp);3221 lpfc_nlp_put(free_ndlp);
@@ -3234,7 +3242,6 @@ lpfc_reg_fab_ctrl_node(struct lpfc_vport *vport, struct lpfc_nodelist *fc_ndlp) · 20 unmodified lines
3234 struct lpfc_hba *phba = vport->phba;3242 struct lpfc_hba *phba = vport->phba;
3235 struct lpfc_nodelist *ns_ndlp;3243 struct lpfc_nodelist *ns_ndlp;
3236 LPFC_MBOXQ_t *mbox;3244 LPFC_MBOXQ_t *mbox;
3237 struct lpfc_dmabuf *mp;
3238 3245
3239 if (fc_ndlp->nlp_flag & NLP_RPI_REGISTERED)3246 if (fc_ndlp->nlp_flag & NLP_RPI_REGISTERED)
3240 return rc;3247 return rc;
@@ -3271,7 +3278,7 @@ lpfc_reg_fab_ctrl_node(struct lpfc_vport *vport, struct lpfc_nodelist *fc_ndlp) · 30 unmodified lines
3271 mbox->ctx_ndlp = lpfc_nlp_get(fc_ndlp);3278 mbox->ctx_ndlp = lpfc_nlp_get(fc_ndlp);
3272 if (!mbox->ctx_ndlp) {3279 if (!mbox->ctx_ndlp) {
3273 rc = -ENOMEM;3280 rc = -ENOMEM;
3274 goto out_mem;3281 goto out;
3275 }3282 }
3276 3283
3277 mbox->vport = vport;3284 mbox->vport = vport;
@@ -3279,21 +3286,15 @@ lpfc_reg_fab_ctrl_node(struct lpfc_vport *vport, struct lpfc_nodelist *fc_ndlp) · 1 unmodified line
3279 if (rc == MBX_NOT_FINISHED) {3286 if (rc == MBX_NOT_FINISHED) {
3280 rc = -ENODEV;3287 rc = -ENODEV;
3281 lpfc_nlp_put(fc_ndlp);3288 lpfc_nlp_put(fc_ndlp);
3282 goto out_mem;3289 goto out;
3283 }3290 }
3284 /* Success path. Exit. */3291 /* Success path. Exit. */
3285 lpfc_nlp_set_state(vport, fc_ndlp,3292 lpfc_nlp_set_state(vport, fc_ndlp,
3286 NLP_STE_REG_LOGIN_ISSUE);3293 NLP_STE_REG_LOGIN_ISSUE);
3287 return 0;3294 return 0;
3288 3295
3289 out_mem:
3290 fc_ndlp->nlp_flag &= ~NLP_REG_LOGIN_SEND;
3291 mp = (struct lpfc_dmabuf *)mbox->ctx_buf;
3292 lpfc_mbuf_free(phba, mp->virt, mp->phys);
3293 kfree(mp);
3294
3295 out:3296 out:
3296 mempool_free(mbox, phba->mbox_mem_pool);3297 lpfc_mbox_rsrc_cleanup(phba, mbox, MBOX_THD_UNLOCKED);
3297 lpfc_printf_vlog(vport, KERN_ERR, LOG_NODE,3298 lpfc_printf_vlog(vport, KERN_ERR, LOG_NODE,
3298 "0938 %s: failed to format reg_login "3299 "0938 %s: failed to format reg_login "
3299 "Data: x%x x%x x%x x%x\n", __func__,3300 "Data: x%x x%x x%x x%x\n", __func__,
@@ -3323,7 +3324,7 @@ lpfc_cmpl_els_disc_cmd(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 23 unmodified lines
3323 struct lpfc_dmabuf *pcmd, *prsp;3324 struct lpfc_dmabuf *pcmd, *prsp;
3324 u32 *pdata;3325 u32 *pdata;
3325 u32 cmd;3326 u32 cmd;
3326 struct lpfc_nodelist *ndlp = cmdiocb->context1;3327 struct lpfc_nodelist *ndlp = cmdiocb->ndlp;
3327 u32 ulp_status, ulp_word4, tmo, did, iotag;3328 u32 ulp_status, ulp_word4, tmo, did, iotag;
3328 3329
3329 ulp_status = get_job_ulpstatus(phba, rspiocb);3330 ulp_status = get_job_ulpstatus(phba, rspiocb);
@@ -3348,7 +3349,7 @@ lpfc_cmpl_els_disc_cmd(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 18 unmodified lines
3348 "0217 ELS cmd tag x%x completes Data: x%x x%x x%x x%x\n",3349 "0217 ELS cmd tag x%x completes Data: x%x x%x x%x x%x\n",
3349 iotag, ulp_status, ulp_word4, tmo, cmdiocb->retry);3350 iotag, ulp_status, ulp_word4, tmo, cmdiocb->retry);
3350 3351
3351 pcmd = (struct lpfc_dmabuf *)cmdiocb->context2;3352 pcmd = cmdiocb->cmd_dmabuf;
3352 if (!pcmd)3353 if (!pcmd)
3353 goto out;3354 goto out;
3354 3355
@@ -3371,7 +3372,6 @@ lpfc_cmpl_els_disc_cmd(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 16 unmodified lines
3371 lpfc_issue_els_edc(vport, cmdiocb->retry);3372 lpfc_issue_els_edc(vport, cmdiocb->retry);
3372 break;3373 break;
3373 case ELS_CMD_RDF:3374 case ELS_CMD_RDF:
3374 cmdiocb->context1 = NULL; /* save ndlp refcnt */
3375 lpfc_issue_els_rdf(vport, cmdiocb->retry);3375 lpfc_issue_els_rdf(vport, cmdiocb->retry);
3376 break;3376 break;
3377 }3377 }
@@ -3439,7 +3439,7 @@ out: · 61 unmodified lines
3439 * routine is invoked to send the SCR IOCB.3439 * routine is invoked to send the SCR IOCB.
3440 *3440 *
3441 * Note that the ndlp reference count will be incremented by 1 for holding the3441 * Note that the ndlp reference count will be incremented by 1 for holding the
3442 * ndlp and the reference to ndlp will be stored into the context1 field of3442 * ndlp and the reference to ndlp will be stored into the ndlp field of
3443 * the IOCB for the completion callback function to the SCR ELS command.3443 * the IOCB for the completion callback function to the SCR ELS command.
3444 *3444 *
3445 * Return code3445 * Return code
@@ -3481,7 +3481,7 @@ lpfc_issue_els_scr(struct lpfc_vport *vport, uint8_t retry) · 35 unmodified lines
3481 return 1;3481 return 1;
3482 }3482 }
3483 }3483 }
3484 pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt);3484 pcmd = (uint8_t *)elsiocb->cmd_dmabuf->virt;
3485 3485
3486 *((uint32_t *) (pcmd)) = ELS_CMD_SCR;3486 *((uint32_t *) (pcmd)) = ELS_CMD_SCR;
3487 pcmd += sizeof(uint32_t);3487 pcmd += sizeof(uint32_t);
@@ -3496,8 +3496,8 @@ lpfc_issue_els_scr(struct lpfc_vport *vport, uint8_t retry) · 8 unmodified lines
3496 3496
3497 phba->fc_stat.elsXmitSCR++;3497 phba->fc_stat.elsXmitSCR++;
3498 elsiocb->cmd_cmpl = lpfc_cmpl_els_disc_cmd;3498 elsiocb->cmd_cmpl = lpfc_cmpl_els_disc_cmd;
3499 elsiocb->context1 = lpfc_nlp_get(ndlp);3499 elsiocb->ndlp = lpfc_nlp_get(ndlp);
3500 if (!elsiocb->context1) {3500 if (!elsiocb->ndlp) {
3501 lpfc_els_free_iocb(phba, elsiocb);3501 lpfc_els_free_iocb(phba, elsiocb);
3502 return 1;3502 return 1;
3503 }3503 }
@@ -3528,7 +3528,7 @@ lpfc_issue_els_scr(struct lpfc_vport *vport, uint8_t retry) · 24 unmodified lines
3528 * replay the RSCN to registered recipients.3528 * replay the RSCN to registered recipients.
3529 *3529 *
3530 * Note that the ndlp reference count will be incremented by 1 for holding the3530 * Note that the ndlp reference count will be incremented by 1 for holding the
3531 * ndlp and the reference to ndlp will be stored into the context1 field of3531 * ndlp and the reference to ndlp will be stored into the ndlp field of
3532 * the IOCB for the completion callback function to the RSCN ELS command.3532 * the IOCB for the completion callback function to the RSCN ELS command.
3533 *3533 *
3534 * Return code3534 * Return code
@@ -3578,7 +3578,7 @@ lpfc_issue_els_rscn(struct lpfc_vport *vport, uint8_t retry) · 43 unmodified lines
3578 if (!elsiocb)3578 if (!elsiocb)
3579 return 1;3579 return 1;
3580 3580
3581 event = ((struct lpfc_dmabuf *)elsiocb->context2)->virt;3581 event = elsiocb->cmd_dmabuf->virt;
3582 3582
3583 event->rscn.rscn_cmd = ELS_RSCN;3583 event->rscn.rscn_cmd = ELS_RSCN;
3584 event->rscn.rscn_page_len = sizeof(struct fc_els_rscn_page);3584 event->rscn.rscn_page_len = sizeof(struct fc_els_rscn_page);
@@ -3593,8 +3593,8 @@ lpfc_issue_els_rscn(struct lpfc_vport *vport, uint8_t retry) · 8 unmodified lines
3593 3593
3594 phba->fc_stat.elsXmitRSCN++;3594 phba->fc_stat.elsXmitRSCN++;
3595 elsiocb->cmd_cmpl = lpfc_cmpl_els_cmd;3595 elsiocb->cmd_cmpl = lpfc_cmpl_els_cmd;
3596 elsiocb->context1 = lpfc_nlp_get(ndlp);3596 elsiocb->ndlp = lpfc_nlp_get(ndlp);
3597 if (!elsiocb->context1) {3597 if (!elsiocb->ndlp) {
3598 lpfc_els_free_iocb(phba, elsiocb);3598 lpfc_els_free_iocb(phba, elsiocb);
3599 return 1;3599 return 1;
3600 }3600 }
@@ -3627,7 +3627,7 @@ lpfc_issue_els_rscn(struct lpfc_vport *vport, uint8_t retry) · 26 unmodified lines
3627 * lpfc_sli_issue_iocb() routine is invoked to send the FARPR ELS command.3627 * lpfc_sli_issue_iocb() routine is invoked to send the FARPR ELS command.
3628 *3628 *
3629 * Note that the ndlp reference count will be incremented by 1 for holding the3629 * Note that the ndlp reference count will be incremented by 1 for holding the
3630 * ndlp and the reference to ndlp will be stored into the context1 field of3630 * ndlp and the reference to ndlp will be stored into the ndlp field of
3631 * the IOCB for the completion callback function to the FARPR ELS command.3631 * the IOCB for the completion callback function to the FARPR ELS command.
3632 *3632 *
3633 * Return code3633 * Return code
@@ -3662,7 +3662,7 @@ lpfc_issue_els_farpr(struct lpfc_vport *vport, uint32_t nportid, uint8_t retry) · 28 unmodified lines
3662 if (!elsiocb)3662 if (!elsiocb)
3663 return 1;3663 return 1;
3664 3664
3665 pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt);3665 pcmd = (uint8_t *)elsiocb->cmd_dmabuf->virt;
3666 3666
3667 *((uint32_t *) (pcmd)) = ELS_CMD_FARPR;3667 *((uint32_t *) (pcmd)) = ELS_CMD_FARPR;
3668 pcmd += sizeof(uint32_t);3668 pcmd += sizeof(uint32_t);
@@ -3692,8 +3692,8 @@ lpfc_issue_els_farpr(struct lpfc_vport *vport, uint32_t nportid, uint8_t retry) · 23 unmodified lines
3692 3692
3693 phba->fc_stat.elsXmitFARPR++;3693 phba->fc_stat.elsXmitFARPR++;
3694 elsiocb->cmd_cmpl = lpfc_cmpl_els_cmd;3694 elsiocb->cmd_cmpl = lpfc_cmpl_els_cmd;
3695 elsiocb->context1 = lpfc_nlp_get(ndlp);3695 elsiocb->ndlp = lpfc_nlp_get(ndlp);
3696 if (!elsiocb->context1) {3696 if (!elsiocb->ndlp) {
3697 lpfc_els_free_iocb(phba, elsiocb);3697 lpfc_els_free_iocb(phba, elsiocb);
3698 return 1;3698 return 1;
3699 }3699 }
@@ -3724,7 +3724,7 @@ lpfc_issue_els_farpr(struct lpfc_vport *vport, uint32_t nportid, uint8_t retry) · 24 unmodified lines
3724 * for diagnostic functions.3724 * for diagnostic functions.
3725 *3725 *
3726 * Note that the ndlp reference count will be incremented by 1 for holding the3726 * Note that the ndlp reference count will be incremented by 1 for holding the
3727 * ndlp and the reference to ndlp will be stored into the context1 field of3727 * ndlp and the reference to ndlp will be stored into the ndlp field of
3728 * the IOCB for the completion callback function to the RDF ELS command.3728 * the IOCB for the completion callback function to the RDF ELS command.
3729 *3729 *
3730 * Return code3730 * Return code
@@ -3761,8 +3761,7 @@ lpfc_issue_els_rdf(struct lpfc_vport *vport, uint8_t retry) · 30 unmodified lines
3761 return -ENOMEM;3761 return -ENOMEM;
3762 3762
3763 /* Configure the payload for the supported FPIN events. */3763 /* Configure the payload for the supported FPIN events. */
3764 prdf = (struct lpfc_els_rdf_req *)3764 prdf = (struct lpfc_els_rdf_req *)elsiocb->cmd_dmabuf->virt;
3765 (((struct lpfc_dmabuf *)elsiocb->context2)->virt);
3766 memset(prdf, 0, cmdsize);3765 memset(prdf, 0, cmdsize);
3767 prdf->rdf.fpin_cmd = ELS_RDF;3766 prdf->rdf.fpin_cmd = ELS_RDF;
3768 prdf->rdf.desc_len = cpu_to_be32(sizeof(struct lpfc_els_rdf_req) -3767 prdf->rdf.desc_len = cpu_to_be32(sizeof(struct lpfc_els_rdf_req) -
@@ -3783,8 +3782,8 @@ lpfc_issue_els_rdf(struct lpfc_vport *vport, uint8_t retry) · 14 unmodified lines
3783 3782
3784 phba->cgn_fpin_frequency = LPFC_FPIN_INIT_FREQ;3783 phba->cgn_fpin_frequency = LPFC_FPIN_INIT_FREQ;
3785 elsiocb->cmd_cmpl = lpfc_cmpl_els_disc_cmd;3784 elsiocb->cmd_cmpl = lpfc_cmpl_els_disc_cmd;
3786 elsiocb->context1 = lpfc_nlp_get(ndlp);3785 elsiocb->ndlp = lpfc_nlp_get(ndlp);
3787 if (!elsiocb->context1) {3786 if (!elsiocb->ndlp) {
3788 lpfc_els_free_iocb(phba, elsiocb);3787 lpfc_els_free_iocb(phba, elsiocb);
3789 return -EIO;3788 return -EIO;
3790 }3789 }
@@ -3855,9 +3854,6 @@ lpfc_least_capable_settings(struct lpfc_hba *phba, · 64 unmodified lines
3855{3854{
3856 u32 rsp_sig_cap = 0, drv_sig_cap = 0;3855 u32 rsp_sig_cap = 0, drv_sig_cap = 0;
3857 u32 rsp_sig_freq_cyc = 0, rsp_sig_freq_scale = 0;3856 u32 rsp_sig_freq_cyc = 0, rsp_sig_freq_scale = 0;
3858 struct lpfc_cgn_info *cp;
3859 u32 crc;
3860 u16 sig_freq;
3861 3857
3862 /* Get rsp signal and frequency capabilities. */3858 /* Get rsp signal and frequency capabilities. */
3863 rsp_sig_cap = be32_to_cpu(pcgd->xmt_signal_capability);3859 rsp_sig_cap = be32_to_cpu(pcgd->xmt_signal_capability);
@@ -3913,25 +3909,7 @@ lpfc_least_capable_settings(struct lpfc_hba *phba, · 49 unmodified lines
3913 }3909 }
3914 }3910 }
3915 3911
3916 if (!phba->cgn_i)3912 /* We are NOT recording signal frequency in congestion info buffer */
3917 return;
3918
3919 /* Update signal frequency in congestion info buffer */
3920 cp = (struct lpfc_cgn_info *)phba->cgn_i->virt;
3921
3922 /* Frequency (in ms) Signal Warning/Signal Congestion Notifications
3923 * are received by the HBA
3924 */
3925 sig_freq = phba->cgn_sig_freq;
3926
3927 if (phba->cgn_reg_signal == EDC_CG_SIG_WARN_ONLY)
3928 cp->cgn_warn_freq = cpu_to_le16(sig_freq);
3929 if (phba->cgn_reg_signal == EDC_CG_SIG_WARN_ALARM) {
3930 cp->cgn_alarm_freq = cpu_to_le16(sig_freq);
3931 cp->cgn_warn_freq = cpu_to_le16(sig_freq);
3932 }
3933 crc = lpfc_cgn_calc_crc32(cp, LPFC_CGN_INFO_SZ, LPFC_CGN_CRC32_SEED);
3934 cp->cgn_info_crc = cpu_to_le32(crc);
3935 return;3913 return;
3936 3914
3937out_no_support:3915out_no_support:
@@ -3973,7 +3951,7 @@ lpfc_cmpl_els_edc(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 35 unmodified lines
3973 struct lpfc_nodelist *ndlp;3951 struct lpfc_nodelist *ndlp;
3974 u32 ulp_status, ulp_word4, tmo, did, iotag;3952 u32 ulp_status, ulp_word4, tmo, did, iotag;
3975 3953
3976 ndlp = cmdiocb->context1;3954 ndlp = cmdiocb->ndlp;
3977 3955
3978 ulp_status = get_job_ulpstatus(phba, rspiocb);3956 ulp_status = get_job_ulpstatus(phba, rspiocb);
3979 ulp_word4 = get_job_word4(phba, rspiocb);3957 ulp_word4 = get_job_word4(phba, rspiocb);
@@ -3997,7 +3975,7 @@ lpfc_cmpl_els_edc(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 17 unmodified lines
3997 "4201 EDC cmd tag x%x completes Data: x%x x%x x%x\n",3975 "4201 EDC cmd tag x%x completes Data: x%x x%x x%x\n",
3998 iotag, ulp_status, ulp_word4, tmo);3976 iotag, ulp_status, ulp_word4, tmo);
3999 3977
4000 pcmd = (struct lpfc_dmabuf *)cmdiocb->context2;3978 pcmd = cmdiocb->cmd_dmabuf;
4001 if (!pcmd)3979 if (!pcmd)
4002 goto out;3980 goto out;
4003 3981
@@ -4246,7 +4224,7 @@ lpfc_issue_els_edc(struct lpfc_vport *vport, uint8_t retry) · 242 unmodified lines
4246 goto try_rdf;4224 goto try_rdf;
4247 4225
4248 /* Configure the payload for the supported Diagnostics capabilities. */4226 /* Configure the payload for the supported Diagnostics capabilities. */
4249 pcmd = (u8 *)(((struct lpfc_dmabuf *)elsiocb->context2)->virt);4227 pcmd = (u8 *)elsiocb->cmd_dmabuf->virt;
4250 memset(pcmd, 0, cmdsize);4228 memset(pcmd, 0, cmdsize);
4251 edc_req = (struct lpfc_els_edc_req *)pcmd;4229 edc_req = (struct lpfc_els_edc_req *)pcmd;
4252 edc_req->edc.desc_len = cpu_to_be32(cgn_desc_size);4230 edc_req->edc.desc_len = cpu_to_be32(cgn_desc_size);
@@ -4258,15 +4236,15 @@ lpfc_issue_els_edc(struct lpfc_vport *vport, uint8_t retry) · 5 unmodified lines
4258 4236
4259 phba->cgn_sig_freq = lpfc_fabric_cgn_frequency;4237 phba->cgn_sig_freq = lpfc_fabric_cgn_frequency;
4260 4238
4261 lpfc_printf_vlog(vport, KERN_INFO, LOG_CGN_MGMT,4239 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS | LOG_CGN_MGMT,
4262 "4623 Xmit EDC to remote "4240 "4623 Xmit EDC to remote "
4263 "NPORT x%x reg_sig x%x reg_fpin:x%x\n",4241 "NPORT x%x reg_sig x%x reg_fpin:x%x\n",
4264 ndlp->nlp_DID, phba->cgn_reg_signal,4242 ndlp->nlp_DID, phba->cgn_reg_signal,
4265 phba->cgn_reg_fpin);4243 phba->cgn_reg_fpin);
4266 4244
4267 elsiocb->cmd_cmpl = lpfc_cmpl_els_disc_cmd;4245 elsiocb->cmd_cmpl = lpfc_cmpl_els_disc_cmd;
4268 elsiocb->context1 = lpfc_nlp_get(ndlp);4246 elsiocb->ndlp = lpfc_nlp_get(ndlp);
4269 if (!elsiocb->context1) {4247 if (!elsiocb->ndlp) {
4270 lpfc_els_free_iocb(phba, elsiocb);4248 lpfc_els_free_iocb(phba, elsiocb);
4271 return -EIO;4249 return -EIO;
4272 }4250 }
@@ -4544,8 +4522,8 @@ lpfc_els_retry(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 271 unmodified lines
4544{4522{
4545 struct lpfc_vport *vport = cmdiocb->vport;4523 struct lpfc_vport *vport = cmdiocb->vport;
4546 union lpfc_wqe128 *irsp = &rspiocb->wqe;4524 union lpfc_wqe128 *irsp = &rspiocb->wqe;
4547 struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *) cmdiocb->context1;4525 struct lpfc_nodelist *ndlp = cmdiocb->ndlp;
4548 struct lpfc_dmabuf *pcmd = (struct lpfc_dmabuf *) cmdiocb->context2;4526 struct lpfc_dmabuf *pcmd = cmdiocb->cmd_dmabuf;
4549 uint32_t *elscmd;4527 uint32_t *elscmd;
4550 struct ls_rjt stat;4528 struct ls_rjt stat;
4551 int retry = 0, maxretry = lpfc_max_els_tries, delay = 0;4529 int retry = 0, maxretry = lpfc_max_els_tries, delay = 0;
@@ -4557,7 +4535,7 @@ lpfc_els_retry(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 5 unmodified lines
4557 u32 ulp_word4 = get_job_word4(phba, rspiocb);4535 u32 ulp_word4 = get_job_word4(phba, rspiocb);
4558 4536
4559 4537
4560 /* Note: context2 may be 0 for internal driver abort4538 /* Note: cmd_dmabuf may be 0 for internal driver abort
4561 * of delays ELS command.4539 * of delays ELS command.
4562 */4540 */
4563 4541
@@ -5068,10 +5046,10 @@ lpfc_els_free_bpl(struct lpfc_hba *phba, struct lpfc_dmabuf *buf_ptr) · 504 unmodified lines
5068 * command IOCB data structure contains the reference to various associated5046 * command IOCB data structure contains the reference to various associated
5069 * resources, these fields must be set to NULL if the associated reference5047 * resources, these fields must be set to NULL if the associated reference
5070 * not present:5048 * not present:
5071 * context1 - reference to ndlp5049 * cmd_dmabuf - reference to cmd.
5072 * context2 - reference to cmd5050 * cmd_dmabuf->next - reference to rsp
5073 * context2->next - reference to rsp5051 * rsp_dmabuf - unused
5074 * context3 - reference to bpl5052 * bpl_dmabuf - reference to bpl
5075 *5053 *
5076 * It first properly decrements the reference count held on ndlp for the5054 * It first properly decrements the reference count held on ndlp for the
5077 * IOCB completion callback function. If LPFC_DELAY_MEM_FREE flag is not5055 * IOCB completion callback function. If LPFC_DELAY_MEM_FREE flag is not
@@ -5091,19 +5069,19 @@ lpfc_els_free_iocb(struct lpfc_hba *phba, struct lpfc_iocbq *elsiocb) · 13 unmodified lines
5091{5069{
5092 struct lpfc_dmabuf *buf_ptr, *buf_ptr1;5070 struct lpfc_dmabuf *buf_ptr, *buf_ptr1;
5093 5071
5094 /* The I/O iocb is complete. Clear the context1 data. */5072 /* The I/O iocb is complete. Clear the node and first dmbuf */
5095 elsiocb->context1 = NULL;5073 elsiocb->ndlp = NULL;
5096 5074
5097 /* context2 = cmd, context2->next = rsp, context3 = bpl */5075 /* cmd_dmabuf = cmd, cmd_dmabuf->next = rsp, bpl_dmabuf = bpl */
5098 if (elsiocb->context2) {5076 if (elsiocb->cmd_dmabuf) {
5099 if (elsiocb->cmd_flag & LPFC_DELAY_MEM_FREE) {5077 if (elsiocb->cmd_flag & LPFC_DELAY_MEM_FREE) {
5100 /* Firmware could still be in progress of DMAing5078 /* Firmware could still be in progress of DMAing
5101 * payload, so don't free data buffer till after5079 * payload, so don't free data buffer till after
5102 * a hbeat.5080 * a hbeat.
5103 */5081 */
5104 elsiocb->cmd_flag &= ~LPFC_DELAY_MEM_FREE;5082 elsiocb->cmd_flag &= ~LPFC_DELAY_MEM_FREE;
5105 buf_ptr = elsiocb->context2;5083 buf_ptr = elsiocb->cmd_dmabuf;
5106 elsiocb->context2 = NULL;5084 elsiocb->cmd_dmabuf = NULL;
5107 if (buf_ptr) {5085 if (buf_ptr) {
5108 buf_ptr1 = NULL;5086 buf_ptr1 = NULL;
5109 spin_lock_irq(&phba->hbalock);5087 spin_lock_irq(&phba->hbalock);
@@ -5122,16 +5100,16 @@ lpfc_els_free_iocb(struct lpfc_hba *phba, struct lpfc_iocbq *elsiocb) · 12 unmodified lines
5122 spin_unlock_irq(&phba->hbalock);5100 spin_unlock_irq(&phba->hbalock);
5123 }5101 }
5124 } else {5102 } else {
5125 buf_ptr1 = (struct lpfc_dmabuf *) elsiocb->context2;5103 buf_ptr1 = elsiocb->cmd_dmabuf;
5126 lpfc_els_free_data(phba, buf_ptr1);5104 lpfc_els_free_data(phba, buf_ptr1);
5127 elsiocb->context2 = NULL;5105 elsiocb->cmd_dmabuf = NULL;
5128 }5106 }
5129 }5107 }
5130 5108
5131 if (elsiocb->context3) {5109 if (elsiocb->bpl_dmabuf) {
5132 buf_ptr = (struct lpfc_dmabuf *) elsiocb->context3;5110 buf_ptr = elsiocb->bpl_dmabuf;
5133 lpfc_els_free_bpl(phba, buf_ptr);5111 lpfc_els_free_bpl(phba, buf_ptr);
5134 elsiocb->context3 = NULL;5112 elsiocb->bpl_dmabuf = NULL;
5135 }5113 }
5136 lpfc_sli_release_iocbq(phba, elsiocb);5114 lpfc_sli_release_iocbq(phba, elsiocb);
5137 return 0;5115 return 0;
@@ -5147,7 +5125,7 @@ lpfc_els_free_iocb(struct lpfc_hba *phba, struct lpfc_iocbq *elsiocb) · 9 unmodified lines
5147 * Accept (ACC) Response ELS command. This routine is invoked to indicate5125 * Accept (ACC) Response ELS command. This routine is invoked to indicate
5148 * the completion of the LOGO process. It invokes the lpfc_nlp_not_used() to5126 * the completion of the LOGO process. It invokes the lpfc_nlp_not_used() to
5149 * release the ndlp if it has the last reference remaining (reference count5127 * release the ndlp if it has the last reference remaining (reference count
5150 * is 1). If succeeded (meaning ndlp released), it sets the IOCB context15128 * is 1). If succeeded (meaning ndlp released), it sets the iocb ndlp
5151 * field to NULL to inform the following lpfc_els_free_iocb() routine no5129 * field to NULL to inform the following lpfc_els_free_iocb() routine no
5152 * ndlp reference count needs to be decremented. Otherwise, the ndlp5130 * ndlp reference count needs to be decremented. Otherwise, the ndlp
5153 * reference use-count shall be decremented by the lpfc_els_free_iocb()5131 * reference use-count shall be decremented by the lpfc_els_free_iocb()
@@ -5158,7 +5136,7 @@ static void · 4 unmodified lines
5158lpfc_cmpl_els_logo_acc(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,5136lpfc_cmpl_els_logo_acc(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
5159 struct lpfc_iocbq *rspiocb)5137 struct lpfc_iocbq *rspiocb)
5160{5138{
5161 struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *) cmdiocb->context1;5139 struct lpfc_nodelist *ndlp = cmdiocb->ndlp;
5162 struct lpfc_vport *vport = cmdiocb->vport;5140 struct lpfc_vport *vport = cmdiocb->vport;
5163 u32 ulp_status, ulp_word4;5141 u32 ulp_status, ulp_word4;
5164 5142
@@ -5204,7 +5182,7 @@ lpfc_cmpl_els_logo_acc(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 39 unmodified lines
5204 /* Indicate the node has already released, should5182 /* Indicate the node has already released, should
5205 * not reference to it from within lpfc_els_free_iocb.5183 * not reference to it from within lpfc_els_free_iocb.
5206 */5184 */
5207 cmdiocb->context1 = NULL;5185 cmdiocb->ndlp = NULL;
5208 }5186 }
5209 }5187 }
5210 out:5188 out:
@@ -5232,14 +5210,10 @@ lpfc_cmpl_els_logo_acc(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 21 unmodified lines
5232void5210void
5233lpfc_mbx_cmpl_dflt_rpi(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)5211lpfc_mbx_cmpl_dflt_rpi(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
5234{5212{
5235 struct lpfc_dmabuf *mp = (struct lpfc_dmabuf *)(pmb->ctx_buf);5213 struct lpfc_nodelist *ndlp = pmb->ctx_ndlp;
5236 struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *)pmb->ctx_ndlp;
5237 u32 mbx_flag = pmb->mbox_flag;5214 u32 mbx_flag = pmb->mbox_flag;
5238 u32 mbx_cmd = pmb->u.mb.mbxCommand;5215 u32 mbx_cmd = pmb->u.mb.mbxCommand;
5239 5216
5240 pmb->ctx_buf = NULL;
5241 pmb->ctx_ndlp = NULL;
5242
5243 if (ndlp) {5217 if (ndlp) {
5244 lpfc_printf_vlog(ndlp->vport, KERN_INFO, LOG_NODE,5218 lpfc_printf_vlog(ndlp->vport, KERN_INFO, LOG_NODE,
5245 "0006 rpi x%x DID:%x flg:%x %d x%px "5219 "0006 rpi x%x DID:%x flg:%x %d x%px "
@@ -5262,10 +5236,7 @@ lpfc_mbx_cmpl_dflt_rpi(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) · 16 unmodified lines
5262 lpfc_drop_node(ndlp->vport, ndlp);5236 lpfc_drop_node(ndlp->vport, ndlp);
5263 }5237 }
5264 5238
5265 lpfc_mbuf_free(phba, mp->virt, mp->phys);5239 lpfc_mbox_rsrc_cleanup(phba, pmb, MBOX_THD_UNLOCKED);
5266 kfree(mp);
5267 mempool_free(pmb, phba->mbox_mem_pool);
5268 return;
5269}5240}
5270 5241
5271/**5242/**
@@ -5285,12 +5256,11 @@ static void · 13 unmodified lines
5285lpfc_cmpl_els_rsp(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,5256lpfc_cmpl_els_rsp(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
5286 struct lpfc_iocbq *rspiocb)5257 struct lpfc_iocbq *rspiocb)
5287{5258{
5288 struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *) cmdiocb->context1;5259 struct lpfc_nodelist *ndlp = cmdiocb->ndlp;
5289 struct lpfc_vport *vport = ndlp ? ndlp->vport : NULL;5260 struct lpfc_vport *vport = ndlp ? ndlp->vport : NULL;
5290 struct Scsi_Host *shost = vport ? lpfc_shost_from_vport(vport) : NULL;5261 struct Scsi_Host *shost = vport ? lpfc_shost_from_vport(vport) : NULL;
5291 IOCB_t *irsp;5262 IOCB_t *irsp;
5292 LPFC_MBOXQ_t *mbox = NULL;5263 LPFC_MBOXQ_t *mbox = NULL;
5293 struct lpfc_dmabuf *mp = NULL;
5294 u32 ulp_status, ulp_word4, tmo, did, iotag;5264 u32 ulp_status, ulp_word4, tmo, did, iotag;
5295 5265
5296 if (!vport) {5266 if (!vport) {
@@ -5316,14 +5286,8 @@ lpfc_cmpl_els_rsp(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 19 unmodified lines
5316 5286
5317 /* Check to see if link went down during discovery */5287 /* Check to see if link went down during discovery */
5318 if (!ndlp || lpfc_els_chk_latt(vport)) {5288 if (!ndlp || lpfc_els_chk_latt(vport)) {
5319 if (mbox) {5289 if (mbox)
5320 mp = (struct lpfc_dmabuf *)mbox->ctx_buf;5290 lpfc_mbox_rsrc_cleanup(phba, mbox, MBOX_THD_UNLOCKED);
5321 if (mp) {
5322 lpfc_mbuf_free(phba, mp->virt, mp->phys);
5323 kfree(mp);
5324 }
5325 mempool_free(mbox, phba->mbox_mem_pool);
5326 }
5327 goto out;5291 goto out;
5328 }5292 }
5329 5293
@@ -5354,14 +5318,7 @@ lpfc_cmpl_els_rsp(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 24 unmodified lines
5354 ndlp->nlp_state,5318 ndlp->nlp_state,
5355 ndlp->nlp_rpi,5319 ndlp->nlp_rpi,
5356 ndlp->nlp_flag);5320 ndlp->nlp_flag);
5357 mp = mbox->ctx_buf;5321 goto out_free_mbox;
5358 if (mp) {
5359 lpfc_mbuf_free(phba, mp->virt,
5360 mp->phys);
5361 kfree(mp);
5362 }
5363 mempool_free(mbox, phba->mbox_mem_pool);
5364 goto out;
5365 }5322 }
5366 }5323 }
5367 5324
@@ -5370,7 +5327,7 @@ lpfc_cmpl_els_rsp(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 2 unmodified lines
5370 */5327 */
5371 mbox->ctx_ndlp = lpfc_nlp_get(ndlp);5328 mbox->ctx_ndlp = lpfc_nlp_get(ndlp);
5372 if (!mbox->ctx_ndlp)5329 if (!mbox->ctx_ndlp)
5373 goto out;5330 goto out_free_mbox;
5374 5331
5375 mbox->vport = vport;5332 mbox->vport = vport;
5376 if (ndlp->nlp_flag & NLP_RM_DFLT_RPI) {5333 if (ndlp->nlp_flag & NLP_RM_DFLT_RPI) {
@@ -5402,12 +5359,8 @@ lpfc_cmpl_els_rsp(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 25 unmodified lines
5402 ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_state,5359 ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_state,
5403 ndlp->nlp_rpi);5360 ndlp->nlp_rpi);
5404 }5361 }
5405 mp = (struct lpfc_dmabuf *)mbox->ctx_buf;5362out_free_mbox:
5406 if (mp) {5363 lpfc_mbox_rsrc_cleanup(phba, mbox, MBOX_THD_UNLOCKED);
5407 lpfc_mbuf_free(phba, mp->virt, mp->phys);
5408 kfree(mp);
5409 }
5410 mempool_free(mbox, phba->mbox_mem_pool);
5411 }5364 }
5412out:5365out:
5413 if (ndlp && shost) {5366 if (ndlp && shost) {
@@ -5459,7 +5412,7 @@ out: · 45 unmodified lines
5459 * mailbox command to the HBA later when callback is invoked.5412 * mailbox command to the HBA later when callback is invoked.
5460 *5413 *
5461 * Note that the ndlp reference count will be incremented by 1 for holding the5414 * Note that the ndlp reference count will be incremented by 1 for holding the
5462 * ndlp and the reference to ndlp will be stored into the context1 field of5415 * ndlp and the reference to ndlp will be stored into the ndlp field of
5463 * the IOCB for the completion callback function to the corresponding5416 * the IOCB for the completion callback function to the corresponding
5464 * response ELS IOCB command.5417 * response ELS IOCB command.
5465 *5418 *
@@ -5516,7 +5469,7 @@ lpfc_els_rsp_acc(struct lpfc_vport *vport, uint32_t flag, · 50 unmodified lines
5516 oldcmd->unsli3.rcvsli3.ox_id;5469 oldcmd->unsli3.rcvsli3.ox_id;
5517 }5470 }
5518 5471
5519 pcmd = (((struct lpfc_dmabuf *) elsiocb->context2)->virt);5472 pcmd = elsiocb->cmd_dmabuf->virt;
5520 *((uint32_t *) (pcmd)) = ELS_CMD_ACC;5473 *((uint32_t *) (pcmd)) = ELS_CMD_ACC;
5521 pcmd += sizeof(uint32_t);5474 pcmd += sizeof(uint32_t);
5522 5475
@@ -5551,7 +5504,7 @@ lpfc_els_rsp_acc(struct lpfc_vport *vport, uint32_t flag, · 28 unmodified lines
5551 oldcmd->unsli3.rcvsli3.ox_id;5504 oldcmd->unsli3.rcvsli3.ox_id;
5552 }5505 }
5553 5506
5554 pcmd = (((struct lpfc_dmabuf *) elsiocb->context2)->virt);5507 pcmd = (u8 *)elsiocb->cmd_dmabuf->virt;
5555 5508
5556 if (mbox)5509 if (mbox)
5557 elsiocb->context_un.mbox = mbox;5510 elsiocb->context_un.mbox = mbox;
@@ -5629,9 +5582,9 @@ lpfc_els_rsp_acc(struct lpfc_vport *vport, uint32_t flag, · 71 unmodified lines
5629 oldcmd->unsli3.rcvsli3.ox_id;5582 oldcmd->unsli3.rcvsli3.ox_id;
5630 }5583 }
5631 5584
5632 pcmd = (((struct lpfc_dmabuf *) elsiocb->context2)->virt);5585 pcmd = (u8 *) elsiocb->cmd_dmabuf->virt;
5633 5586
5634 memcpy(pcmd, ((struct lpfc_dmabuf *) oldiocb->context2)->virt,5587 memcpy(pcmd, oldiocb->cmd_dmabuf->virt,
5635 sizeof(uint32_t) + sizeof(PRLO));5588 sizeof(uint32_t) + sizeof(PRLO));
5636 *((uint32_t *) (pcmd)) = ELS_CMD_PRLO_ACC;5589 *((uint32_t *) (pcmd)) = ELS_CMD_PRLO_ACC;
5637 els_pkt_ptr = (ELS_PKT *) pcmd;5590 els_pkt_ptr = (ELS_PKT *) pcmd;
@@ -5667,7 +5620,7 @@ lpfc_els_rsp_acc(struct lpfc_vport *vport, uint32_t flag, · 29 unmodified lines
5667 oldcmd->unsli3.rcvsli3.ox_id;5620 oldcmd->unsli3.rcvsli3.ox_id;
5668 }5621 }
5669 5622
5670 pcmd = (((struct lpfc_dmabuf *)elsiocb->context2)->virt);5623 pcmd = (u8 *)elsiocb->cmd_dmabuf->virt;
5671 rdf_resp = (struct fc_els_rdf_resp *)pcmd;5624 rdf_resp = (struct fc_els_rdf_resp *)pcmd;
5672 memset(rdf_resp, 0, sizeof(*rdf_resp));5625 memset(rdf_resp, 0, sizeof(*rdf_resp));
5673 rdf_resp->acc_hdr.la_cmd = ELS_LS_ACC;5626 rdf_resp->acc_hdr.la_cmd = ELS_LS_ACC;
@@ -5695,8 +5648,8 @@ lpfc_els_rsp_acc(struct lpfc_vport *vport, uint32_t flag, · 21 unmodified lines
5695 }5648 }
5696 5649
5697 phba->fc_stat.elsXmitACC++;5650 phba->fc_stat.elsXmitACC++;
5698 elsiocb->context1 = lpfc_nlp_get(ndlp);5651 elsiocb->ndlp = lpfc_nlp_get(ndlp);
5699 if (!elsiocb->context1) {5652 if (!elsiocb->ndlp) {
5700 lpfc_els_free_iocb(phba, elsiocb);5653 lpfc_els_free_iocb(phba, elsiocb);
5701 return 1;5654 return 1;
5702 }5655 }
@@ -5733,7 +5686,7 @@ lpfc_els_rsp_acc(struct lpfc_vport *vport, uint32_t flag, · 30 unmodified lines
5733 * to issue to the HBA later.5686 * to issue to the HBA later.
5734 *5687 *
5735 * Note that the ndlp reference count will be incremented by 1 for holding the5688 * Note that the ndlp reference count will be incremented by 1 for holding the
5736 * ndlp and the reference to ndlp will be stored into the context1 field of5689 * ndlp and the reference to ndlp will be stored into the ndlp field of
5737 * the IOCB for the completion callback function to the reject response5690 * the IOCB for the completion callback function to the reject response
5738 * ELS IOCB command.5691 * ELS IOCB command.
5739 *5692 *
@@ -5774,7 +5727,7 @@ lpfc_els_rsp_reject(struct lpfc_vport *vport, uint32_t rejectError, · 34 unmodified lines
5774 icmd->unsli3.rcvsli3.ox_id = oldcmd->unsli3.rcvsli3.ox_id;5727 icmd->unsli3.rcvsli3.ox_id = oldcmd->unsli3.rcvsli3.ox_id;
5775 }5728 }
5776 5729
5777 pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt);5730 pcmd = (uint8_t *)elsiocb->cmd_dmabuf->virt;
5778 5731
5779 *((uint32_t *) (pcmd)) = ELS_CMD_LS_RJT;5732 *((uint32_t *) (pcmd)) = ELS_CMD_LS_RJT;
5780 pcmd += sizeof(uint32_t);5733 pcmd += sizeof(uint32_t);
@@ -5797,8 +5750,8 @@ lpfc_els_rsp_reject(struct lpfc_vport *vport, uint32_t rejectError, · 16 unmodified lines
5797 5750
5798 phba->fc_stat.elsXmitLSRJT++;5751 phba->fc_stat.elsXmitLSRJT++;
5799 elsiocb->cmd_cmpl = lpfc_cmpl_els_rsp;5752 elsiocb->cmd_cmpl = lpfc_cmpl_els_rsp;
5800 elsiocb->context1 = lpfc_nlp_get(ndlp);5753 elsiocb->ndlp = lpfc_nlp_get(ndlp);
5801 if (!elsiocb->context1) {5754 if (!elsiocb->ndlp) {
5802 lpfc_els_free_iocb(phba, elsiocb);5755 lpfc_els_free_iocb(phba, elsiocb);
5803 return 1;5756 return 1;
5804 }5757 }
@@ -5870,8 +5823,7 @@ lpfc_issue_els_edc_rsp(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, · 65 unmodified lines
5870 icmd->unsli3.rcvsli3.ox_id = cmd->unsli3.rcvsli3.ox_id;5823 icmd->unsli3.rcvsli3.ox_id = cmd->unsli3.rcvsli3.ox_id;
5871 }5824 }
5872 5825
5873 pcmd = (((struct lpfc_dmabuf *)elsiocb->context2)->virt);5826 pcmd = elsiocb->cmd_dmabuf->virt;
5874
5875 memset(pcmd, 0, cmdsize);5827 memset(pcmd, 0, cmdsize);
5876 5828
5877 edc_rsp = (struct lpfc_els_edc_rsp *)pcmd;5829 edc_rsp = (struct lpfc_els_edc_rsp *)pcmd;
@@ -5891,8 +5843,8 @@ lpfc_issue_els_edc_rsp(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, · 13 unmodified lines
5891 elsiocb->cmd_cmpl = lpfc_cmpl_els_rsp;5843 elsiocb->cmd_cmpl = lpfc_cmpl_els_rsp;
5892 5844
5893 phba->fc_stat.elsXmitACC++;5845 phba->fc_stat.elsXmitACC++;
5894 elsiocb->context1 = lpfc_nlp_get(ndlp);5846 elsiocb->ndlp = lpfc_nlp_get(ndlp);
5895 if (!elsiocb->context1) {5847 if (!elsiocb->ndlp) {
5896 lpfc_els_free_iocb(phba, elsiocb);5848 lpfc_els_free_iocb(phba, elsiocb);
5897 return 1;5849 return 1;
5898 }5850 }
@@ -5927,7 +5879,7 @@ lpfc_issue_els_edc_rsp(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, · 28 unmodified lines
5927 * and invokes the lpfc_sli_issue_iocb() routine to send out the command.5879 * and invokes the lpfc_sli_issue_iocb() routine to send out the command.
5928 *5880 *
5929 * Note that the ndlp reference count will be incremented by 1 for holding the5881 * Note that the ndlp reference count will be incremented by 1 for holding the
5930 * ndlp and the reference to ndlp will be stored into the context1 field of5882 * ndlp and the reference to ndlp will be stored into the ndlp field of
5931 * the IOCB for the completion callback function to the ADISC Accept response5883 * the IOCB for the completion callback function to the ADISC Accept response
5932 * ELS IOCB command.5884 * ELS IOCB command.
5933 *5885 *
@@ -5980,7 +5932,7 @@ lpfc_els_rsp_adisc_acc(struct lpfc_vport *vport, struct lpfc_iocbq *oldiocb, · 46 unmodified lines
5980 elsiocb->iotag, ulp_context,5932 elsiocb->iotag, ulp_context,
5981 ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_state,5933 ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_state,
5982 ndlp->nlp_rpi);5934 ndlp->nlp_rpi);
5983 pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt);5935 pcmd = (uint8_t *)elsiocb->cmd_dmabuf->virt;
5984 5936
5985 *((uint32_t *) (pcmd)) = ELS_CMD_ACC;5937 *((uint32_t *) (pcmd)) = ELS_CMD_ACC;
5986 pcmd += sizeof(uint32_t);5938 pcmd += sizeof(uint32_t);
@@ -5997,8 +5949,8 @@ lpfc_els_rsp_adisc_acc(struct lpfc_vport *vport, struct lpfc_iocbq *oldiocb, · 10 unmodified lines
5997 5949
5998 phba->fc_stat.elsXmitACC++;5950 phba->fc_stat.elsXmitACC++;
5999 elsiocb->cmd_cmpl = lpfc_cmpl_els_rsp;5951 elsiocb->cmd_cmpl = lpfc_cmpl_els_rsp;
6000 elsiocb->context1 = lpfc_nlp_get(ndlp);5952 elsiocb->ndlp = lpfc_nlp_get(ndlp);
6001 if (!elsiocb->context1) {5953 if (!elsiocb->ndlp) {
6002 lpfc_els_free_iocb(phba, elsiocb);5954 lpfc_els_free_iocb(phba, elsiocb);
6003 return 1;5955 return 1;
6004 }5956 }
@@ -6024,7 +5976,7 @@ lpfc_els_rsp_adisc_acc(struct lpfc_vport *vport, struct lpfc_iocbq *oldiocb, · 19 unmodified lines
6024 * and invokes the lpfc_sli_issue_iocb() routine to send out the command.5976 * and invokes the lpfc_sli_issue_iocb() routine to send out the command.
6025 *5977 *
6026 * Note that the ndlp reference count will be incremented by 1 for holding the5978 * Note that the ndlp reference count will be incremented by 1 for holding the
6027 * ndlp and the reference to ndlp will be stored into the context1 field of5979 * ndlp and the reference to ndlp will be stored into the ndlp field of
6028 * the IOCB for the completion callback function to the PRLI Accept response5980 * the IOCB for the completion callback function to the PRLI Accept response
6029 * ELS IOCB command.5981 * ELS IOCB command.
6030 *5982 *
@@ -6054,7 +6006,7 @@ lpfc_els_rsp_prli_acc(struct lpfc_vport *vport, struct lpfc_iocbq *oldiocb, · 23 unmodified lines
6054 /* Need the incoming PRLI payload to determine if the ACC is for an6006 /* Need the incoming PRLI payload to determine if the ACC is for an
6055 * FC4 or NVME PRLI type. The PRLI type is at word 1.6007 * FC4 or NVME PRLI type. The PRLI type is at word 1.
6056 */6008 */
6057 req_buf = (struct lpfc_dmabuf *)oldiocb->context2;6009 req_buf = oldiocb->cmd_dmabuf;
6058 req_payload = (((uint32_t *)req_buf->virt) + 1);6010 req_payload = (((uint32_t *)req_buf->virt) + 1);
6059 6011
6060 /* PRLI type payload is at byte 3 for FCP or NVME. */6012 /* PRLI type payload is at byte 3 for FCP or NVME. */
@@ -6102,7 +6054,7 @@ lpfc_els_rsp_prli_acc(struct lpfc_vport *vport, struct lpfc_iocbq *oldiocb, · 41 unmodified lines
6102 elsiocb->iotag, ulp_context,6054 elsiocb->iotag, ulp_context,
6103 ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_state,6055 ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_state,
6104 ndlp->nlp_rpi);6056 ndlp->nlp_rpi);
6105 pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt);6057 pcmd = (uint8_t *)elsiocb->cmd_dmabuf->virt;
6106 memset(pcmd, 0, cmdsize);6058 memset(pcmd, 0, cmdsize);
6107 6059
6108 *((uint32_t *)(pcmd)) = elsrspcmd;6060 *((uint32_t *)(pcmd)) = elsrspcmd;
@@ -6175,8 +6127,8 @@ lpfc_els_rsp_prli_acc(struct lpfc_vport *vport, struct lpfc_iocbq *oldiocb, · 66 unmodified lines
6175 6127
6176 phba->fc_stat.elsXmitACC++;6128 phba->fc_stat.elsXmitACC++;
6177 elsiocb->cmd_cmpl = lpfc_cmpl_els_rsp;6129 elsiocb->cmd_cmpl = lpfc_cmpl_els_rsp;
6178 elsiocb->context1 = lpfc_nlp_get(ndlp);6130 elsiocb->ndlp = lpfc_nlp_get(ndlp);
6179 if (!elsiocb->context1) {6131 if (!elsiocb->ndlp) {
6180 lpfc_els_free_iocb(phba, elsiocb);6132 lpfc_els_free_iocb(phba, elsiocb);
6181 return 1;6133 return 1;
6182 }6134 }
@@ -6204,7 +6156,7 @@ lpfc_els_rsp_prli_acc(struct lpfc_vport *vport, struct lpfc_iocbq *oldiocb, · 21 unmodified lines
6204 * issue the response.6156 * issue the response.
6205 *6157 *
6206 * Note that the ndlp reference count will be incremented by 1 for holding the6158 * Note that the ndlp reference count will be incremented by 1 for holding the
6207 * ndlp and the reference to ndlp will be stored into the context1 field of6159 * ndlp and the reference to ndlp will be stored into the ndlp field of
6208 * the IOCB for the completion callback function.6160 * the IOCB for the completion callback function.
6209 *6161 *
6210 * Return code6162 * Return code
@@ -6255,7 +6207,7 @@ lpfc_els_rsp_rnid_acc(struct lpfc_vport *vport, uint8_t format, · 44 unmodified lines
6255 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,6207 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
6256 "0132 Xmit RNID ACC response tag x%x xri x%x\n",6208 "0132 Xmit RNID ACC response tag x%x xri x%x\n",
6257 elsiocb->iotag, ulp_context);6209 elsiocb->iotag, ulp_context);
6258 pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt);6210 pcmd = (uint8_t *)elsiocb->cmd_dmabuf->virt;
6259 *((uint32_t *) (pcmd)) = ELS_CMD_ACC;6211 *((uint32_t *) (pcmd)) = ELS_CMD_ACC;
6260 pcmd += sizeof(uint32_t);6212 pcmd += sizeof(uint32_t);
6261 6213
@@ -6289,8 +6241,8 @@ lpfc_els_rsp_rnid_acc(struct lpfc_vport *vport, uint8_t format, · 27 unmodified lines
6289 6241
6290 phba->fc_stat.elsXmitACC++;6242 phba->fc_stat.elsXmitACC++;
6291 elsiocb->cmd_cmpl = lpfc_cmpl_els_rsp;6243 elsiocb->cmd_cmpl = lpfc_cmpl_els_rsp;
6292 elsiocb->context1 = lpfc_nlp_get(ndlp);6244 elsiocb->ndlp = lpfc_nlp_get(ndlp);
6293 if (!elsiocb->context1) {6245 if (!elsiocb->ndlp) {
6294 lpfc_els_free_iocb(phba, elsiocb);6246 lpfc_els_free_iocb(phba, elsiocb);
6295 return 1;6247 return 1;
6296 }6248 }
@@ -6325,7 +6277,7 @@ lpfc_els_clear_rrq(struct lpfc_vport *vport, · 28 unmodified lines
6325 struct lpfc_node_rrq *prrq;6277 struct lpfc_node_rrq *prrq;
6326 6278
6327 6279
6328 pcmd = (uint8_t *) (((struct lpfc_dmabuf *) iocb->context2)->virt);6280 pcmd = (uint8_t *)iocb->cmd_dmabuf->virt;
6329 pcmd += sizeof(uint32_t);6281 pcmd += sizeof(uint32_t);
6330 rrq = (struct RRQ *)pcmd;6282 rrq = (struct RRQ *)pcmd;
6331 rrq->rrq_exchg = be32_to_cpu(rrq->rrq_exchg);6283 rrq->rrq_exchg = be32_to_cpu(rrq->rrq_exchg);
@@ -6412,7 +6364,7 @@ lpfc_els_rsp_echo_acc(struct lpfc_vport *vport, uint8_t *data, · 80 unmodified lines
6412 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,6364 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
6413 "2876 Xmit ECHO ACC response tag x%x xri x%x\n",6365 "2876 Xmit ECHO ACC response tag x%x xri x%x\n",
6414 elsiocb->iotag, ulp_context);6366 elsiocb->iotag, ulp_context);
6415 pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt);6367 pcmd = (uint8_t *)elsiocb->cmd_dmabuf->virt;
6416 *((uint32_t *) (pcmd)) = ELS_CMD_ACC;6368 *((uint32_t *) (pcmd)) = ELS_CMD_ACC;
6417 pcmd += sizeof(uint32_t);6369 pcmd += sizeof(uint32_t);
6418 memcpy(pcmd, data, cmdsize - sizeof(uint32_t));6370 memcpy(pcmd, data, cmdsize - sizeof(uint32_t));
@@ -6423,8 +6375,8 @@ lpfc_els_rsp_echo_acc(struct lpfc_vport *vport, uint8_t *data, · 4 unmodified lines
6423 6375
6424 phba->fc_stat.elsXmitACC++;6376 phba->fc_stat.elsXmitACC++;
6425 elsiocb->cmd_cmpl = lpfc_cmpl_els_rsp;6377 elsiocb->cmd_cmpl = lpfc_cmpl_els_rsp;
6426 elsiocb->context1 = lpfc_nlp_get(ndlp);6378 elsiocb->ndlp = lpfc_nlp_get(ndlp);
6427 if (!elsiocb->context1) {6379 if (!elsiocb->ndlp) {
6428 lpfc_els_free_iocb(phba, elsiocb);6380 lpfc_els_free_iocb(phba, elsiocb);
6429 return 1;6381 return 1;
6430 }6382 }
@@ -7048,9 +7000,8 @@ lpfc_els_rdp_cmpl(struct lpfc_hba *phba, struct lpfc_rdp_context *rdp_context, · 617 unmodified lines
7048 elsiocb->iotag, ulp_context,7000 elsiocb->iotag, ulp_context,
7049 ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_state,7001 ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_state,
7050 ndlp->nlp_rpi);7002 ndlp->nlp_rpi);
7051 rdp_res = (struct fc_rdp_res_frame *)7003 rdp_res = (struct fc_rdp_res_frame *)elsiocb->cmd_dmabuf->virt;
7052 (((struct lpfc_dmabuf *) elsiocb->context2)->virt);7004 pcmd = (uint8_t *)elsiocb->cmd_dmabuf->virt;
7053 pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt);
7054 memset(pcmd, 0, sizeof(struct fc_rdp_res_frame));7005 memset(pcmd, 0, sizeof(struct fc_rdp_res_frame));
7055 *((uint32_t *) (pcmd)) = ELS_CMD_ACC;7006 *((uint32_t *) (pcmd)) = ELS_CMD_ACC;
7056 7007
@@ -7101,15 +7052,14 @@ lpfc_els_rdp_cmpl(struct lpfc_hba *phba, struct lpfc_rdp_context *rdp_context, · 44 unmodified lines
7101 elsiocb->cmd_cmpl = lpfc_cmpl_els_rsp;7052 elsiocb->cmd_cmpl = lpfc_cmpl_els_rsp;
7102 7053
7103 /* Now that we know the true size of the payload, update the BPL */7054 /* Now that we know the true size of the payload, update the BPL */
7104 bpl = (struct ulp_bde64 *)7055 bpl = (struct ulp_bde64 *)elsiocb->bpl_dmabuf->virt;
7105 (((struct lpfc_dmabuf *)(elsiocb->context3))->virt);
7106 bpl->tus.f.bdeSize = len;7056 bpl->tus.f.bdeSize = len;
7107 bpl->tus.f.bdeFlags = 0;7057 bpl->tus.f.bdeFlags = 0;
7108 bpl->tus.w = le32_to_cpu(bpl->tus.w);7058 bpl->tus.w = le32_to_cpu(bpl->tus.w);
7109 7059
7110 phba->fc_stat.elsXmitACC++;7060 phba->fc_stat.elsXmitACC++;
7111 elsiocb->context1 = lpfc_nlp_get(ndlp);7061 elsiocb->ndlp = lpfc_nlp_get(ndlp);
7112 if (!elsiocb->context1) {7062 if (!elsiocb->ndlp) {
7113 lpfc_els_free_iocb(phba, elsiocb);7063 lpfc_els_free_iocb(phba, elsiocb);
7114 goto free_rdp_context;7064 goto free_rdp_context;
7115 }7065 }
@@ -7143,7 +7093,7 @@ error: · 27 unmodified lines
7143 icmd->unsli3.rcvsli3.ox_id = rdp_context->ox_id;7093 icmd->unsli3.rcvsli3.ox_id = rdp_context->ox_id;
7144 }7094 }
7145 7095
7146 pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt);7096 pcmd = (uint8_t *)elsiocb->cmd_dmabuf->virt;
7147 7097
7148 *((uint32_t *) (pcmd)) = ELS_CMD_LS_RJT;7098 *((uint32_t *) (pcmd)) = ELS_CMD_LS_RJT;
7149 stat = (struct ls_rjt *)(pcmd + sizeof(uint32_t));7099 stat = (struct ls_rjt *)(pcmd + sizeof(uint32_t));
@@ -7151,8 +7101,8 @@ error: · 1 unmodified line
7151 7101
7152 phba->fc_stat.elsXmitLSRJT++;7102 phba->fc_stat.elsXmitLSRJT++;
7153 elsiocb->cmd_cmpl = lpfc_cmpl_els_rsp;7103 elsiocb->cmd_cmpl = lpfc_cmpl_els_rsp;
7154 elsiocb->context1 = lpfc_nlp_get(ndlp);7104 elsiocb->ndlp = lpfc_nlp_get(ndlp);
7155 if (!elsiocb->context1) {7105 if (!elsiocb->ndlp) {
7156 lpfc_els_free_iocb(phba, elsiocb);7106 lpfc_els_free_iocb(phba, elsiocb);
7157 goto free_rdp_context;7107 goto free_rdp_context;
7158 }7108 }
@@ -7175,7 +7125,6 @@ static int · 16 unmodified lines
7175lpfc_get_rdp_info(struct lpfc_hba *phba, struct lpfc_rdp_context *rdp_context)7125lpfc_get_rdp_info(struct lpfc_hba *phba, struct lpfc_rdp_context *rdp_context)
7176{7126{
7177 LPFC_MBOXQ_t *mbox = NULL;7127 LPFC_MBOXQ_t *mbox = NULL;
7178 struct lpfc_dmabuf *mp;
7179 int rc;7128 int rc;
7180 7129
7181 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);7130 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
@@ -7186,21 +7135,19 @@ lpfc_get_rdp_info(struct lpfc_hba *phba, struct lpfc_rdp_context *rdp_context) · 4 unmodified lines
7186 }7135 }
7187 7136
7188 if (lpfc_sli4_dump_page_a0(phba, mbox))7137 if (lpfc_sli4_dump_page_a0(phba, mbox))
7189 goto prep_mbox_fail;7138 goto rdp_fail;
7190 mbox->vport = rdp_context->ndlp->vport;7139 mbox->vport = rdp_context->ndlp->vport;
7191 mbox->mbox_cmpl = lpfc_mbx_cmpl_rdp_page_a0;7140 mbox->mbox_cmpl = lpfc_mbx_cmpl_rdp_page_a0;
7192 mbox->ctx_ndlp = (struct lpfc_rdp_context *)rdp_context;7141 mbox->ctx_ndlp = (struct lpfc_rdp_context *)rdp_context;
7193 rc = lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT);7142 rc = lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT);
7194 if (rc == MBX_NOT_FINISHED) {7143 if (rc == MBX_NOT_FINISHED) {
7195 mp = (struct lpfc_dmabuf *)mbox->ctx_buf;7144 lpfc_mbox_rsrc_cleanup(phba, mbox, MBOX_THD_UNLOCKED);
7196 lpfc_mbuf_free(phba, mp->virt, mp->phys);7145 return 1;
7197 goto issue_mbox_fail;
7198 }7146 }
7199 7147
7200 return 0;7148 return 0;
7201 7149
7202prep_mbox_fail:7150rdp_fail:
7203issue_mbox_fail:
7204 mempool_free(mbox, phba->mbox_mem_pool);7151 mempool_free(mbox, phba->mbox_mem_pool);
7205 return 1;7152 return 1;
7206}7153}
@@ -7248,7 +7195,7 @@ lpfc_els_rcv_rdp(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, · 41 unmodified lines
7248 goto error;7195 goto error;
7249 }7196 }
7250 7197
7251 pcmd = (struct lpfc_dmabuf *) cmdiocb->context2;7198 pcmd = cmdiocb->cmd_dmabuf;
7252 rdp_req = (struct fc_rdp_req_frame *) pcmd->virt;7199 rdp_req = (struct fc_rdp_req_frame *) pcmd->virt;
7253 7200
7254 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,7201 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
@@ -7360,8 +7307,7 @@ lpfc_els_lcb_rsp(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) · 105 unmodified lines
7360 if (!elsiocb)7307 if (!elsiocb)
7361 goto free_lcb_context;7308 goto free_lcb_context;
7362 7309
7363 lcb_res = (struct fc_lcb_res_frame *)7310 lcb_res = (struct fc_lcb_res_frame *)elsiocb->cmd_dmabuf->virt;
7364 (((struct lpfc_dmabuf *)elsiocb->context2)->virt);
7365 7311
7366 memset(lcb_res, 0, sizeof(struct fc_lcb_res_frame));7312 memset(lcb_res, 0, sizeof(struct fc_lcb_res_frame));
7367 7313
@@ -7376,7 +7322,7 @@ lpfc_els_lcb_rsp(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) · 8 unmodified lines
7376 icmd->unsli3.rcvsli3.ox_id = lcb_context->ox_id;7322 icmd->unsli3.rcvsli3.ox_id = lcb_context->ox_id;
7377 }7323 }
7378 7324
7379 pcmd = (uint8_t *)(((struct lpfc_dmabuf *)elsiocb->context2)->virt);7325 pcmd = (uint8_t *)elsiocb->cmd_dmabuf->virt;
7380 *((uint32_t *)(pcmd)) = ELS_CMD_ACC;7326 *((uint32_t *)(pcmd)) = ELS_CMD_ACC;
7381 lcb_res->lcb_sub_command = lcb_context->sub_command;7327 lcb_res->lcb_sub_command = lcb_context->sub_command;
7382 lcb_res->lcb_type = lcb_context->type;7328 lcb_res->lcb_type = lcb_context->type;
@@ -7386,8 +7332,8 @@ lpfc_els_lcb_rsp(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) · 3 unmodified lines
7386 elsiocb->cmd_cmpl = lpfc_cmpl_els_rsp;7332 elsiocb->cmd_cmpl = lpfc_cmpl_els_rsp;
7387 phba->fc_stat.elsXmitACC++;7333 phba->fc_stat.elsXmitACC++;
7388 7334
7389 elsiocb->context1 = lpfc_nlp_get(ndlp);7335 elsiocb->ndlp = lpfc_nlp_get(ndlp);
7390 if (!elsiocb->context1) {7336 if (!elsiocb->ndlp) {
7391 lpfc_els_free_iocb(phba, elsiocb);7337 lpfc_els_free_iocb(phba, elsiocb);
7392 goto out;7338 goto out;
7393 }7339 }
@@ -7421,7 +7367,7 @@ error: · 27 unmodified lines
7421 icmd->unsli3.rcvsli3.ox_id = lcb_context->ox_id;7367 icmd->unsli3.rcvsli3.ox_id = lcb_context->ox_id;
7422 }7368 }
7423 7369
7424 pcmd = (uint8_t *)(((struct lpfc_dmabuf *)elsiocb->context2)->virt);7370 pcmd = (uint8_t *)elsiocb->cmd_dmabuf->virt;
7425 7371
7426 *((uint32_t *)(pcmd)) = ELS_CMD_LS_RJT;7372 *((uint32_t *)(pcmd)) = ELS_CMD_LS_RJT;
7427 stat = (struct ls_rjt *)(pcmd + sizeof(uint32_t));7373 stat = (struct ls_rjt *)(pcmd + sizeof(uint32_t));
@@ -7432,8 +7378,8 @@ error: · 4 unmodified lines
7432 7378
7433 elsiocb->cmd_cmpl = lpfc_cmpl_els_rsp;7379 elsiocb->cmd_cmpl = lpfc_cmpl_els_rsp;
7434 phba->fc_stat.elsXmitLSRJT++;7380 phba->fc_stat.elsXmitLSRJT++;
7435 elsiocb->context1 = lpfc_nlp_get(ndlp);7381 elsiocb->ndlp = lpfc_nlp_get(ndlp);
7436 if (!elsiocb->context1) {7382 if (!elsiocb->ndlp) {
7437 lpfc_els_free_iocb(phba, elsiocb);7383 lpfc_els_free_iocb(phba, elsiocb);
7438 goto free_lcb_context;7384 goto free_lcb_context;
7439 }7385 }
@@ -7545,7 +7491,7 @@ lpfc_els_rcv_lcb(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, · 105 unmodified lines
7545 u8 state, rjt_err = 0;7491 u8 state, rjt_err = 0;
7546 struct ls_rjt stat;7492 struct ls_rjt stat;
7547 7493
7548 pcmd = (struct lpfc_dmabuf *)cmdiocb->context2;7494 pcmd = cmdiocb->cmd_dmabuf;
7549 lp = (uint8_t *)pcmd->virt;7495 lp = (uint8_t *)pcmd->virt;
7550 beacon = (struct fc_lcb_request_frame *)pcmd->virt;7496 beacon = (struct fc_lcb_request_frame *)pcmd->virt;
7551 7497
@@ -7742,10 +7688,10 @@ return_did_out: · 190 unmodified lines
7742static int7688static int
7743lpfc_rscn_recovery_check(struct lpfc_vport *vport)7689lpfc_rscn_recovery_check(struct lpfc_vport *vport)
7744{7690{
7745 struct lpfc_nodelist *ndlp = NULL;7691 struct lpfc_nodelist *ndlp = NULL, *n;
7746 7692
7747 /* Move all affected nodes by pending RSCNs to NPR state. */7693 /* Move all affected nodes by pending RSCNs to NPR state. */
7748 list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) {7694 list_for_each_entry_safe(ndlp, n, &vport->fc_nodes, nlp_listp) {
7749 if ((ndlp->nlp_state == NLP_STE_UNUSED_NODE) ||7695 if ((ndlp->nlp_state == NLP_STE_UNUSED_NODE) ||
7750 !lpfc_rscn_payload_check(vport, ndlp->nlp_DID))7696 !lpfc_rscn_payload_check(vport, ndlp->nlp_DID))
7751 continue;7697 continue;
@@ -7791,7 +7737,7 @@ lpfc_send_rscn_event(struct lpfc_vport *vport, · 39 unmodified lines
7791 uint32_t payload_len;7737 uint32_t payload_len;
7792 struct lpfc_rscn_event_header *rscn_event_data;7738 struct lpfc_rscn_event_header *rscn_event_data;
7793 7739
7794 pcmd = (struct lpfc_dmabuf *) cmdiocb->context2;7740 pcmd = cmdiocb->cmd_dmabuf;
7795 payload_ptr = (uint32_t *) pcmd->virt;7741 payload_ptr = (uint32_t *) pcmd->virt;
7796 payload_len = be32_to_cpu(*payload_ptr & ~ELS_CMD_MASK);7742 payload_len = be32_to_cpu(*payload_ptr & ~ELS_CMD_MASK);
7797 7743
@@ -7851,7 +7797,7 @@ lpfc_els_rcv_rscn(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, · 53 unmodified lines
7851 int rscn_id = 0, hba_id = 0;7797 int rscn_id = 0, hba_id = 0;
7852 int i, tmo;7798 int i, tmo;
7853 7799
7854 pcmd = (struct lpfc_dmabuf *) cmdiocb->context2;7800 pcmd = cmdiocb->cmd_dmabuf;
7855 lp = (uint32_t *) pcmd->virt;7801 lp = (uint32_t *) pcmd->virt;
7856 7802
7857 payload_len = be32_to_cpu(*lp++ & ~ELS_CMD_MASK);7803 payload_len = be32_to_cpu(*lp++ & ~ELS_CMD_MASK);
@@ -7953,7 +7899,7 @@ lpfc_els_rcv_rscn(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, · 95 unmodified lines
7953 /* Get the array count after successfully have the token */7899 /* Get the array count after successfully have the token */
7954 rscn_cnt = vport->fc_rscn_id_cnt;7900 rscn_cnt = vport->fc_rscn_id_cnt;
7955 /* If we are already processing an RSCN, save the received7901 /* If we are already processing an RSCN, save the received
7956 * RSCN payload buffer, cmdiocb->context2 to process later.7902 * RSCN payload buffer, cmdiocb->cmd_dmabuf to process later.
7957 */7903 */
7958 if (vport->fc_flag & (FC_RSCN_MODE | FC_NDISC_ACTIVE)) {7904 if (vport->fc_flag & (FC_RSCN_MODE | FC_NDISC_ACTIVE)) {
7959 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,7905 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,
@@ -7972,6 +7918,7 @@ lpfc_els_rcv_rscn(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, · 12 unmodified lines
7972 if ((rscn_cnt < FC_MAX_HOLD_RSCN) &&7918 if ((rscn_cnt < FC_MAX_HOLD_RSCN) &&
7973 !(vport->fc_flag & FC_RSCN_DISCOVERY)) {7919 !(vport->fc_flag & FC_RSCN_DISCOVERY)) {
7974 vport->fc_flag |= FC_RSCN_MODE;7920 vport->fc_flag |= FC_RSCN_MODE;
7921 vport->fc_flag &= ~FC_RSCN_MEMENTO;
7975 spin_unlock_irq(shost->host_lock);7922 spin_unlock_irq(shost->host_lock);
7976 if (rscn_cnt) {7923 if (rscn_cnt) {
7977 cmd = vport->fc_rscn_id_list[rscn_cnt-1]->virt;7924 cmd = vport->fc_rscn_id_list[rscn_cnt-1]->virt;
@@ -7986,10 +7933,10 @@ lpfc_els_rcv_rscn(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, · 8 unmodified lines
7986 } else {7933 } else {
7987 vport->fc_rscn_id_list[rscn_cnt] = pcmd;7934 vport->fc_rscn_id_list[rscn_cnt] = pcmd;
7988 vport->fc_rscn_id_cnt++;7935 vport->fc_rscn_id_cnt++;
7989 /* If we zero, cmdiocb->context2, the calling7936 /* If we zero, cmdiocb->cmd_dmabuf, the calling
7990 * routine will not try to free it.7937 * routine will not try to free it.
7991 */7938 */
7992 cmdiocb->context2 = NULL;7939 cmdiocb->cmd_dmabuf = NULL;
7993 }7940 }
7994 /* Deferred RSCN */7941 /* Deferred RSCN */
7995 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,7942 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
@@ -8021,15 +7968,16 @@ lpfc_els_rcv_rscn(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, · 25 unmodified lines
8021 7968
8022 spin_lock_irq(shost->host_lock);7969 spin_lock_irq(shost->host_lock);
8023 vport->fc_flag |= FC_RSCN_MODE;7970 vport->fc_flag |= FC_RSCN_MODE;
7971 vport->fc_flag &= ~FC_RSCN_MEMENTO;
8024 spin_unlock_irq(shost->host_lock);7972 spin_unlock_irq(shost->host_lock);
8025 vport->fc_rscn_id_list[vport->fc_rscn_id_cnt++] = pcmd;7973 vport->fc_rscn_id_list[vport->fc_rscn_id_cnt++] = pcmd;
8026 /* Indicate we are done walking fc_rscn_id_list on this vport */7974 /* Indicate we are done walking fc_rscn_id_list on this vport */
8027 vport->fc_rscn_flush = 0;7975 vport->fc_rscn_flush = 0;
8028 /*7976 /*
8029 * If we zero, cmdiocb->context2, the calling routine will7977 * If we zero, cmdiocb->cmd_dmabuf, the calling routine will
8030 * not try to free it.7978 * not try to free it.
8031 */7979 */
8032 cmdiocb->context2 = NULL;7980 cmdiocb->cmd_dmabuf = NULL;
8033 lpfc_set_disctmo(vport);7981 lpfc_set_disctmo(vport);
8034 /* Send back ACC */7982 /* Send back ACC */
8035 lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL);7983 lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL);
@@ -8153,7 +8101,7 @@ lpfc_els_rcv_flogi(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, · 117 unmodified lines
8153{8101{
8154 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);8102 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
8155 struct lpfc_hba *phba = vport->phba;8103 struct lpfc_hba *phba = vport->phba;
8156 struct lpfc_dmabuf *pcmd = (struct lpfc_dmabuf *) cmdiocb->context2;8104 struct lpfc_dmabuf *pcmd = cmdiocb->cmd_dmabuf;
8157 uint32_t *lp = (uint32_t *) pcmd->virt;8105 uint32_t *lp = (uint32_t *) pcmd->virt;
8158 union lpfc_wqe128 *wqe = &cmdiocb->wqe;8106 union lpfc_wqe128 *wqe = &cmdiocb->wqe;
8159 struct serv_parm *sp;8107 struct serv_parm *sp;
@@ -8163,6 +8111,9 @@ lpfc_els_rcv_flogi(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, · 3 unmodified lines
8163 uint32_t fc_flag = 0;8111 uint32_t fc_flag = 0;
8164 uint32_t port_state = 0;8112 uint32_t port_state = 0;
8165 8113
8114 /* Clear external loopback plug detected flag */
8115 phba->link_flag &= ~LS_EXTERNAL_LOOPBACK;
8116
8166 cmd = *lp++;8117 cmd = *lp++;
8167 sp = (struct serv_parm *) lp;8118 sp = (struct serv_parm *) lp;
8168 8119
@@ -8214,6 +8165,12 @@ lpfc_els_rcv_flogi(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, · 45 unmodified lines
8214 return 1;8165 return 1;
8215 }8166 }
8216 8167
8168 /* External loopback plug insertion detected */
8169 phba->link_flag |= LS_EXTERNAL_LOOPBACK;
8170
8171 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS | LOG_LIBDFC,
8172 "1119 External Loopback plug detected\n");
8173
8217 /* abort the flogi coming back to ourselves8174 /* abort the flogi coming back to ourselves
8218 * due to external loopback on the port.8175 * due to external loopback on the port.
8219 */8176 */
@@ -8320,7 +8277,7 @@ lpfc_els_rcv_rnid(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, · 100 unmodified lines
8320 RNID *rn;8277 RNID *rn;
8321 struct ls_rjt stat;8278 struct ls_rjt stat;
8322 8279
8323 pcmd = (struct lpfc_dmabuf *) cmdiocb->context2;8280 pcmd = cmdiocb->cmd_dmabuf;
8324 lp = (uint32_t *) pcmd->virt;8281 lp = (uint32_t *) pcmd->virt;
8325 8282
8326 lp++;8283 lp++;
@@ -8361,7 +8318,7 @@ lpfc_els_rcv_echo(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, · 34 unmodified lines
8361{8318{
8362 uint8_t *pcmd;8319 uint8_t *pcmd;
8363 8320
8364 pcmd = (uint8_t *) (((struct lpfc_dmabuf *) cmdiocb->context2)->virt);8321 pcmd = (uint8_t *)cmdiocb->cmd_dmabuf->virt;
8365 8322
8366 /* skip over first word of echo command to find echo data */8323 /* skip over first word of echo command to find echo data */
8367 pcmd += sizeof(uint32_t);8324 pcmd += sizeof(uint32_t);
@@ -8437,7 +8394,7 @@ lpfc_els_rcv_rrq(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, · 69 unmodified lines
8437 * response to the RLS.8394 * response to the RLS.
8438 *8395 *
8439 * Note that the ndlp reference count will be incremented by 1 for holding the8396 * Note that the ndlp reference count will be incremented by 1 for holding the
8440 * ndlp and the reference to ndlp will be stored into the context1 field of8397 * ndlp and the reference to ndlp will be stored into the ndlp field of
8441 * the IOCB for the completion callback function to the RLS Accept Response8398 * the IOCB for the completion callback function to the RLS Accept Response
8442 * ELS IOCB command.8399 * ELS IOCB command.
8443 *8400 *
@@ -8460,7 +8417,7 @@ lpfc_els_rsp_rls_acc(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) · 16 unmodified lines
8460 8417
8461 mb = &pmb->u.mb;8418 mb = &pmb->u.mb;
8462 8419
8463 ndlp = (struct lpfc_nodelist *)pmb->ctx_ndlp;8420 ndlp = pmb->ctx_ndlp;
8464 rxid = (uint16_t)((unsigned long)(pmb->ctx_buf) & 0xffff);8421 rxid = (uint16_t)((unsigned long)(pmb->ctx_buf) & 0xffff);
8465 oxid = (uint16_t)(((unsigned long)(pmb->ctx_buf) >> 16) & 0xffff);8422 oxid = (uint16_t)(((unsigned long)(pmb->ctx_buf) >> 16) & 0xffff);
8466 pmb->ctx_buf = NULL;8423 pmb->ctx_buf = NULL;
@@ -8496,7 +8453,7 @@ lpfc_els_rsp_rls_acc(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) · 29 unmodified lines
8496 icmd->unsli3.rcvsli3.ox_id = oxid;8453 icmd->unsli3.rcvsli3.ox_id = oxid;
8497 }8454 }
8498 8455
8499 pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt);8456 pcmd = (uint8_t *)elsiocb->cmd_dmabuf->virt;
8500 *((uint32_t *) (pcmd)) = ELS_CMD_ACC;8457 *((uint32_t *) (pcmd)) = ELS_CMD_ACC;
8501 pcmd += sizeof(uint32_t); /* Skip past command */8458 pcmd += sizeof(uint32_t); /* Skip past command */
8502 rls_rsp = (struct RLS_RSP *)pcmd;8459 rls_rsp = (struct RLS_RSP *)pcmd;
@@ -8517,8 +8474,8 @@ lpfc_els_rsp_rls_acc(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) · 14 unmodified lines
8517 ndlp->nlp_rpi);8474 ndlp->nlp_rpi);
8518 elsiocb->cmd_cmpl = lpfc_cmpl_els_rsp;8475 elsiocb->cmd_cmpl = lpfc_cmpl_els_rsp;
8519 phba->fc_stat.elsXmitACC++;8476 phba->fc_stat.elsXmitACC++;
8520 elsiocb->context1 = lpfc_nlp_get(ndlp);8477 elsiocb->ndlp = lpfc_nlp_get(ndlp);
8521 if (!elsiocb->context1) {8478 if (!elsiocb->ndlp) {
8522 lpfc_els_free_iocb(phba, elsiocb);8479 lpfc_els_free_iocb(phba, elsiocb);
8523 return;8480 return;
8524 }8481 }
@@ -8609,7 +8566,7 @@ reject_out: · 84 unmodified lines
8609 * Value (RTV) unsolicited IOCB event.8566 * Value (RTV) unsolicited IOCB event.
8610 *8567 *
8611 * Note that the ndlp reference count will be incremented by 1 for holding the8568 * Note that the ndlp reference count will be incremented by 1 for holding the
8612 * ndlp and the reference to ndlp will be stored into the context1 field of8569 * ndlp and the reference to ndlp will be stored into the ndlp field of
8613 * the IOCB for the completion callback function to the RTV Accept Response8570 * the IOCB for the completion callback function to the RTV Accept Response
8614 * ELS IOCB command.8571 * ELS IOCB command.
8615 *8572 *
@@ -8644,7 +8601,7 @@ lpfc_els_rcv_rtv(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, · 28 unmodified lines
8644 if (!elsiocb)8601 if (!elsiocb)
8645 return 1;8602 return 1;
8646 8603
8647 pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt);8604 pcmd = (uint8_t *)elsiocb->cmd_dmabuf->virt;
8648 *((uint32_t *) (pcmd)) = ELS_CMD_ACC;8605 *((uint32_t *) (pcmd)) = ELS_CMD_ACC;
8649 pcmd += sizeof(uint32_t); /* Skip past command */8606 pcmd += sizeof(uint32_t); /* Skip past command */
8650 8607
@@ -8682,8 +8639,8 @@ lpfc_els_rcv_rtv(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, · 31 unmodified lines
8682 rtv_rsp->ratov, rtv_rsp->edtov, rtv_rsp->qtov);8639 rtv_rsp->ratov, rtv_rsp->edtov, rtv_rsp->qtov);
8683 elsiocb->cmd_cmpl = lpfc_cmpl_els_rsp;8640 elsiocb->cmd_cmpl = lpfc_cmpl_els_rsp;
8684 phba->fc_stat.elsXmitACC++;8641 phba->fc_stat.elsXmitACC++;
8685 elsiocb->context1 = lpfc_nlp_get(ndlp);8642 elsiocb->ndlp = lpfc_nlp_get(ndlp);
8686 if (!elsiocb->context1) {8643 if (!elsiocb->ndlp) {
8687 lpfc_els_free_iocb(phba, elsiocb);8644 lpfc_els_free_iocb(phba, elsiocb);
8688 return 0;8645 return 0;
8689 }8646 }
@@ -8739,7 +8696,7 @@ lpfc_issue_els_rrq(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, · 49 unmodified lines
8739 if (!elsiocb)8696 if (!elsiocb)
8740 return 1;8697 return 1;
8741 8698
8742 pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt);8699 pcmd = (uint8_t *)elsiocb->cmd_dmabuf->virt;
8743 8700
8744 /* For RRQ request, remainder of payload is Exchange IDs */8701 /* For RRQ request, remainder of payload is Exchange IDs */
8745 *((uint32_t *) (pcmd)) = ELS_CMD_RRQ;8702 *((uint32_t *) (pcmd)) = ELS_CMD_RRQ;
@@ -8759,17 +8716,19 @@ lpfc_issue_els_rrq(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, · 13 unmodified lines
8759 elsiocb->context_un.rrq = rrq;8716 elsiocb->context_un.rrq = rrq;
8760 elsiocb->cmd_cmpl = lpfc_cmpl_els_rrq;8717 elsiocb->cmd_cmpl = lpfc_cmpl_els_rrq;
8761 8718
8762 lpfc_nlp_get(ndlp);8719 elsiocb->ndlp = lpfc_nlp_get(ndlp);
8763 elsiocb->context1 = ndlp;8720 if (!elsiocb->ndlp)
8721 goto io_err;
8764 8722
8765 ret = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0);8723 ret = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, elsiocb, 0);
8766 if (ret == IOCB_ERROR)8724 if (ret == IOCB_ERROR) {
8725 lpfc_nlp_put(ndlp);
8767 goto io_err;8726 goto io_err;
8727 }
8768 return 0;8728 return 0;
8769 8729
8770 io_err:8730 io_err:
8771 lpfc_els_free_iocb(phba, elsiocb);8731 lpfc_els_free_iocb(phba, elsiocb);
8772 lpfc_nlp_put(ndlp);
8773 return 1;8732 return 1;
8774}8733}
8775 8734
@@ -8811,7 +8770,7 @@ lpfc_send_rrq(struct lpfc_hba *phba, struct lpfc_node_rrq *rrq) · 35 unmodified lines
8811 * It is to be called by the lpfc_els_rcv_rpl() routine to accept the RPL.8770 * It is to be called by the lpfc_els_rcv_rpl() routine to accept the RPL.
8812 *8771 *
8813 * Note that the ndlp reference count will be incremented by 1 for holding the8772 * Note that the ndlp reference count will be incremented by 1 for holding the
8814 * ndlp and the reference to ndlp will be stored into the context1 field of8773 * ndlp and the reference to ndlp will be stored into the ndlp field of
8815 * the IOCB for the completion callback function to the RPL Accept Response8774 * the IOCB for the completion callback function to the RPL Accept Response
8816 * ELS command.8775 * ELS command.
8817 *8776 *
@@ -8852,7 +8811,7 @@ lpfc_els_rsp_rpl_acc(struct lpfc_vport *vport, uint16_t cmdsize, · 34 unmodified lines
8852 icmd->unsli3.rcvsli3.ox_id = get_job_rcvoxid(phba, oldiocb);8811 icmd->unsli3.rcvsli3.ox_id = get_job_rcvoxid(phba, oldiocb);
8853 }8812 }
8854 8813
8855 pcmd = (((struct lpfc_dmabuf *) elsiocb->context2)->virt);8814 pcmd = elsiocb->cmd_dmabuf->virt;
8856 *((uint32_t *) (pcmd)) = ELS_CMD_ACC;8815 *((uint32_t *) (pcmd)) = ELS_CMD_ACC;
8857 pcmd += sizeof(uint16_t);8816 pcmd += sizeof(uint16_t);
8858 *((uint16_t *)(pcmd)) = be16_to_cpu(cmdsize);8817 *((uint16_t *)(pcmd)) = be16_to_cpu(cmdsize);
@@ -8876,8 +8835,8 @@ lpfc_els_rsp_rpl_acc(struct lpfc_vport *vport, uint16_t cmdsize, · 17 unmodified lines
8876 ndlp->nlp_rpi);8835 ndlp->nlp_rpi);
8877 elsiocb->cmd_cmpl = lpfc_cmpl_els_rsp;8836 elsiocb->cmd_cmpl = lpfc_cmpl_els_rsp;
8878 phba->fc_stat.elsXmitACC++;8837 phba->fc_stat.elsXmitACC++;
8879 elsiocb->context1 = lpfc_nlp_get(ndlp);8838 elsiocb->ndlp = lpfc_nlp_get(ndlp);
8880 if (!elsiocb->context1) {8839 if (!elsiocb->ndlp) {
8881 lpfc_els_free_iocb(phba, elsiocb);8840 lpfc_els_free_iocb(phba, elsiocb);
8882 return 1;8841 return 1;
8883 }8842 }
@@ -8932,7 +8891,7 @@ lpfc_els_rcv_rpl(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, · 48 unmodified lines
8932 return 0;8891 return 0;
8933 }8892 }
8934 8893
8935 pcmd = (struct lpfc_dmabuf *) cmdiocb->context2;8894 pcmd = cmdiocb->cmd_dmabuf;
8936 lp = (uint32_t *) pcmd->virt;8895 lp = (uint32_t *) pcmd->virt;
8937 rpl = (RPL *) (lp + 1);8896 rpl = (RPL *) (lp + 1);
8938 maxsize = be32_to_cpu(rpl->maxsize);8897 maxsize = be32_to_cpu(rpl->maxsize);
@@ -8984,7 +8943,7 @@ lpfc_els_rcv_farp(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, · 45 unmodified lines
8984 uint32_t cnt, did;8943 uint32_t cnt, did;
8985 8944
8986 did = get_job_els_rsp64_did(vport->phba, cmdiocb);8945 did = get_job_els_rsp64_did(vport->phba, cmdiocb);
8987 pcmd = (struct lpfc_dmabuf *) cmdiocb->context2;8946 pcmd = cmdiocb->cmd_dmabuf;
8988 lp = (uint32_t *) pcmd->virt;8947 lp = (uint32_t *) pcmd->virt;
8989 8948
8990 lp++;8949 lp++;
@@ -9054,8 +9013,8 @@ lpfc_els_rcv_farpr(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, · 63 unmodified lines
9054 uint32_t did;9013 uint32_t did;
9055 9014
9056 did = get_job_els_rsp64_did(vport->phba, cmdiocb);9015 did = get_job_els_rsp64_did(vport->phba, cmdiocb);
9057 pcmd = (struct lpfc_dmabuf *) cmdiocb->context2;9016 pcmd = cmdiocb->cmd_dmabuf;
9058 lp = (uint32_t *) pcmd->virt;9017 lp = (uint32_t *)pcmd->virt;
9059 9018
9060 lp++;9019 lp++;
9061 /* FARP-RSP received from DID <did> */9020 /* FARP-RSP received from DID <did> */
@@ -9095,7 +9054,7 @@ lpfc_els_rcv_fan(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, · 33 unmodified lines
9095 FAN *fp;9054 FAN *fp;
9096 9055
9097 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, "0265 FAN received\n");9056 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS, "0265 FAN received\n");
9098 lp = (uint32_t *)((struct lpfc_dmabuf *)cmdiocb->context2)->virt;9057 lp = (uint32_t *)cmdiocb->cmd_dmabuf->virt;
9099 fp = (FAN *) ++lp;9058 fp = (FAN *) ++lp;
9100 /* FAN received; Fan does not have a reply sequence */9059 /* FAN received; Fan does not have a reply sequence */
9101 if ((vport == phba->pport) &&9060 if ((vport == phba->pport) &&
@@ -9144,7 +9103,7 @@ lpfc_els_rcv_edc(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, · 42 unmodified lines
9144 int desc_cnt = 0, bytes_remain;9103 int desc_cnt = 0, bytes_remain;
9145 bool rcv_cap_desc = false;9104 bool rcv_cap_desc = false;
9146 9105
9147 payload = ((struct lpfc_dmabuf *)cmdiocb->context2)->virt;9106 payload = cmdiocb->cmd_dmabuf->virt;
9148 9107
9149 edc_req = (struct fc_els_edc *)payload;9108 edc_req = (struct fc_els_edc *)payload;
9150 bytes_remain = be32_to_cpu(edc_req->desc_len);9109 bytes_remain = be32_to_cpu(edc_req->desc_len);
@@ -9329,7 +9288,7 @@ lpfc_els_timeout_handler(struct lpfc_vport *vport) · 178 unmodified lines
9329 if (piocb->vport != vport)9288 if (piocb->vport != vport)
9330 continue;9289 continue;
9331 9290
9332 pcmd = (struct lpfc_dmabuf *) piocb->context2;9291 pcmd = piocb->cmd_dmabuf;
9333 if (pcmd)9292 if (pcmd)
9334 els_command = *(uint32_t *) (pcmd->virt);9293 els_command = *(uint32_t *) (pcmd->virt);
9335 9294
@@ -9584,7 +9543,7 @@ lpfc_send_els_failure_event(struct lpfc_hba *phba, · 248 unmodified lines
9584 uint32_t *pcmd;9543 uint32_t *pcmd;
9585 u32 ulp_status, ulp_word4;9544 u32 ulp_status, ulp_word4;
9586 9545
9587 ndlp = cmdiocbp->context1;9546 ndlp = cmdiocbp->ndlp;
9588 if (!ndlp)9547 if (!ndlp)
9589 return;9548 return;
9590 9549
@@ -9598,8 +9557,7 @@ lpfc_send_els_failure_event(struct lpfc_hba *phba, · 7 unmodified lines
9598 sizeof(struct lpfc_name));9557 sizeof(struct lpfc_name));
9599 memcpy(lsrjt_event.header.wwnn, &ndlp->nlp_nodename,9558 memcpy(lsrjt_event.header.wwnn, &ndlp->nlp_nodename,
9600 sizeof(struct lpfc_name));9559 sizeof(struct lpfc_name));
9601 pcmd = (uint32_t *) (((struct lpfc_dmabuf *)9560 pcmd = (uint32_t *)cmdiocbp->cmd_dmabuf->virt;
9602 cmdiocbp->context2)->virt);
9603 lsrjt_event.command = (pcmd != NULL) ? *pcmd : 0;9561 lsrjt_event.command = (pcmd != NULL) ? *pcmd : 0;
9604 stat.un.ls_rjt_error_be = cpu_to_be32(ulp_word4);9562 stat.un.ls_rjt_error_be = cpu_to_be32(ulp_word4);
9605 lsrjt_event.reason_code = stat.un.b.lsRjtRsnCode;9563 lsrjt_event.reason_code = stat.un.b.lsRjtRsnCode;
@@ -9940,11 +9898,14 @@ lpfc_els_rcv_fpin_cgn(struct lpfc_hba *phba, struct fc_tlv_desc *tlv) · 334 unmodified lines
9940 /* Take action here for an Alarm event */9898 /* Take action here for an Alarm event */
9941 if (phba->cmf_active_mode != LPFC_CFG_OFF) {9899 if (phba->cmf_active_mode != LPFC_CFG_OFF) {
9942 if (phba->cgn_reg_fpin & LPFC_CGN_FPIN_ALARM) {9900 if (phba->cgn_reg_fpin & LPFC_CGN_FPIN_ALARM) {
9943 /* Track of alarm cnt for cgn_info */
9944 atomic_inc(&phba->cgn_fabric_alarm_cnt);
9945 /* Track of alarm cnt for SYNC_WQE */9901 /* Track of alarm cnt for SYNC_WQE */
9946 atomic_inc(&phba->cgn_sync_alarm_cnt);9902 atomic_inc(&phba->cgn_sync_alarm_cnt);
9947 }9903 }
9904 /* Track alarm cnt for cgn_info regardless
9905 * of whether CMF is configured for Signals
9906 * or FPINs.
9907 */
9908 atomic_inc(&phba->cgn_fabric_alarm_cnt);
9948 goto cleanup;9909 goto cleanup;
9949 }9910 }
9950 break;9911 break;
@@ -9952,11 +9913,14 @@ lpfc_els_rcv_fpin_cgn(struct lpfc_hba *phba, struct fc_tlv_desc *tlv) · 1 unmodified line
9952 /* Take action here for a Warning event */9913 /* Take action here for a Warning event */
9953 if (phba->cmf_active_mode != LPFC_CFG_OFF) {9914 if (phba->cmf_active_mode != LPFC_CFG_OFF) {
9954 if (phba->cgn_reg_fpin & LPFC_CGN_FPIN_WARN) {9915 if (phba->cgn_reg_fpin & LPFC_CGN_FPIN_WARN) {
9955 /* Track of warning cnt for cgn_info */
9956 atomic_inc(&phba->cgn_fabric_warn_cnt);
9957 /* Track of warning cnt for SYNC_WQE */9916 /* Track of warning cnt for SYNC_WQE */
9958 atomic_inc(&phba->cgn_sync_warn_cnt);9917 atomic_inc(&phba->cgn_sync_warn_cnt);
9959 }9918 }
9919 /* Track warning cnt and freq for cgn_info
9920 * regardless of whether CMF is configured for
9921 * Signals or FPINs.
9922 */
9923 atomic_inc(&phba->cgn_fabric_warn_cnt);
9960cleanup:9924cleanup:
9961 /* Save frequency in ms */9925 /* Save frequency in ms */
9962 phba->cgn_fpin_frequency =9926 phba->cgn_fpin_frequency =
@@ -9965,14 +9929,10 @@ cleanup: · 2 unmodified lines
9965 if (phba->cgn_i) {9929 if (phba->cgn_i) {
9966 cp = (struct lpfc_cgn_info *)9930 cp = (struct lpfc_cgn_info *)
9967 phba->cgn_i->virt;9931 phba->cgn_i->virt;
9968 if (phba->cgn_reg_fpin &9932 cp->cgn_alarm_freq =
9969 LPFC_CGN_FPIN_ALARM)9933 cpu_to_le16(value);
9970 cp->cgn_alarm_freq =9934 cp->cgn_warn_freq =
9971 cpu_to_le16(value);9935 cpu_to_le16(value);
9972 if (phba->cgn_reg_fpin &
9973 LPFC_CGN_FPIN_WARN)
9974 cp->cgn_warn_freq =
9975 cpu_to_le16(value);
9976 crc = lpfc_cgn_calc_crc329936 crc = lpfc_cgn_calc_crc32
9977 (cp,9937 (cp,
9978 LPFC_CGN_INFO_SZ,9938 LPFC_CGN_INFO_SZ,
@@ -10133,12 +10093,12 @@ lpfc_els_unsol_buffer(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, · 154 unmodified lines
10133 struct lpfc_wcqe_complete *wcqe_cmpl = NULL;10093 struct lpfc_wcqe_complete *wcqe_cmpl = NULL;
10134 LPFC_MBOXQ_t *mbox;10094 LPFC_MBOXQ_t *mbox;
10135 10095
10136 if (!vport || !(elsiocb->context2))10096 if (!vport || !elsiocb->cmd_dmabuf)
10137 goto dropit;10097 goto dropit;
10138 10098
10139 newnode = 0;10099 newnode = 0;
10140 wcqe_cmpl = &elsiocb->wcqe_cmpl;10100 wcqe_cmpl = &elsiocb->wcqe_cmpl;
10141 payload = ((struct lpfc_dmabuf *)elsiocb->context2)->virt;10101 payload = elsiocb->cmd_dmabuf->virt;
10142 if (phba->sli_rev == LPFC_SLI_REV4)10102 if (phba->sli_rev == LPFC_SLI_REV4)
10143 payload_len = wcqe_cmpl->total_data_placed;10103 payload_len = wcqe_cmpl->total_data_placed;
10144 else10104 else
@@ -10199,8 +10159,8 @@ lpfc_els_unsol_buffer(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, · 54 unmodified lines
10199 }10159 }
10200 spin_unlock_irq(&ndlp->lock);10160 spin_unlock_irq(&ndlp->lock);
10201 10161
10202 elsiocb->context1 = lpfc_nlp_get(ndlp);10162 elsiocb->ndlp = lpfc_nlp_get(ndlp);
10203 if (!elsiocb->context1)10163 if (!elsiocb->ndlp)
10204 goto dropit;10164 goto dropit;
10205 elsiocb->vport = vport;10165 elsiocb->vport = vport;
10206 10166
@@ -10556,8 +10516,8 @@ lsrjt: · 349 unmodified lines
10556 }10516 }
10557 10517
10558 /* Release the reference on this elsiocb, not the ndlp. */10518 /* Release the reference on this elsiocb, not the ndlp. */
10559 lpfc_nlp_put(elsiocb->context1);10519 lpfc_nlp_put(elsiocb->ndlp);
10560 elsiocb->context1 = NULL;10520 elsiocb->ndlp = NULL;
10561 10521
10562 /* Special case. Driver received an unsolicited command that10522 /* Special case. Driver received an unsolicited command that
10563 * unsupportable given the driver's current state. Reset the10523 * unsupportable given the driver's current state. Reset the
@@ -10611,13 +10571,13 @@ lpfc_els_unsol_event(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, · 47 unmodified lines
10611 u32 ulp_command, status, parameter, bde_count = 0;10571 u32 ulp_command, status, parameter, bde_count = 0;
10612 IOCB_t *icmd;10572 IOCB_t *icmd;
10613 struct lpfc_wcqe_complete *wcqe_cmpl = NULL;10573 struct lpfc_wcqe_complete *wcqe_cmpl = NULL;
10614 struct lpfc_dmabuf *bdeBuf1 = elsiocb->context2;10574 struct lpfc_dmabuf *bdeBuf1 = elsiocb->cmd_dmabuf;
10615 struct lpfc_dmabuf *bdeBuf2 = elsiocb->context3;10575 struct lpfc_dmabuf *bdeBuf2 = elsiocb->bpl_dmabuf;
10616 dma_addr_t paddr;10576 dma_addr_t paddr;
10617 10577
10618 elsiocb->context1 = NULL;10578 elsiocb->cmd_dmabuf = NULL;
10619 elsiocb->context2 = NULL;10579 elsiocb->rsp_dmabuf = NULL;
10620 elsiocb->context3 = NULL;10580 elsiocb->bpl_dmabuf = NULL;
10621 10581
10622 wcqe_cmpl = &elsiocb->wcqe_cmpl;10582 wcqe_cmpl = &elsiocb->wcqe_cmpl;
10623 ulp_command = get_job_cmnd(phba, elsiocb);10583 ulp_command = get_job_cmnd(phba, elsiocb);
@@ -10661,38 +10621,39 @@ lpfc_els_unsol_event(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, · 37 unmodified lines
10661 10621
10662 /* Account for SLI2 or SLI3 and later unsolicited buffering */10622 /* Account for SLI2 or SLI3 and later unsolicited buffering */
10663 if (phba->sli3_options & LPFC_SLI3_HBQ_ENABLED) {10623 if (phba->sli3_options & LPFC_SLI3_HBQ_ENABLED) {
10664 elsiocb->context2 = bdeBuf1;10624 elsiocb->cmd_dmabuf = bdeBuf1;
10665 if (bde_count == 2)10625 if (bde_count == 2)
10666 elsiocb->context3 = bdeBuf2;10626 elsiocb->bpl_dmabuf = bdeBuf2;
10667 } else {10627 } else {
10668 icmd = &elsiocb->iocb;10628 icmd = &elsiocb->iocb;
10669 paddr = getPaddr(icmd->un.cont64[0].addrHigh,10629 paddr = getPaddr(icmd->un.cont64[0].addrHigh,
10670 icmd->un.cont64[0].addrLow);10630 icmd->un.cont64[0].addrLow);
10671 elsiocb->context2 = lpfc_sli_ringpostbuf_get(phba, pring,10631 elsiocb->cmd_dmabuf = lpfc_sli_ringpostbuf_get(phba, pring,
10672 paddr);10632 paddr);
10673 if (bde_count == 2) {10633 if (bde_count == 2) {
10674 paddr = getPaddr(icmd->un.cont64[1].addrHigh,10634 paddr = getPaddr(icmd->un.cont64[1].addrHigh,
10675 icmd->un.cont64[1].addrLow);10635 icmd->un.cont64[1].addrLow);
10676 elsiocb->context3 = lpfc_sli_ringpostbuf_get(phba,10636 elsiocb->bpl_dmabuf = lpfc_sli_ringpostbuf_get(phba,
10677 pring,10637 pring,
10678 paddr);10638 paddr);
10679 }10639 }
10680 }10640 }
10681 10641
10682 lpfc_els_unsol_buffer(phba, pring, vport, elsiocb);10642 lpfc_els_unsol_buffer(phba, pring, vport, elsiocb);
10683 /*10643 /*
10684 * The different unsolicited event handlers would tell us10644 * The different unsolicited event handlers would tell us
10685 * if they are done with "mp" by setting context2 to NULL.10645 * if they are done with "mp" by setting cmd_dmabuf to NULL.
10686 */10646 */
10687 if (elsiocb->context2) {10647 if (elsiocb->cmd_dmabuf) {
10688 lpfc_in_buf_free(phba, (struct lpfc_dmabuf *)elsiocb->context2);10648 lpfc_in_buf_free(phba, elsiocb->cmd_dmabuf);
10689 elsiocb->context2 = NULL;10649 elsiocb->cmd_dmabuf = NULL;
10690 }10650 }
10691 10651
10692 if (elsiocb->context3) {10652 if (elsiocb->bpl_dmabuf) {
10693 lpfc_in_buf_free(phba, elsiocb->context3);10653 lpfc_in_buf_free(phba, elsiocb->bpl_dmabuf);
10694 elsiocb->context3 = NULL;10654 elsiocb->bpl_dmabuf = NULL;
10695 }10655 }
10656
10696}10657}
10697 10658
10698static void10659static void
@@ -10803,7 +10764,7 @@ lpfc_cmpl_reg_new_vport(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) · 104 unmodified lines
10803{10764{
10804 struct lpfc_vport *vport = pmb->vport;10765 struct lpfc_vport *vport = pmb->vport;
10805 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);10766 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
10806 struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *)pmb->ctx_ndlp;10767 struct lpfc_nodelist *ndlp = pmb->ctx_ndlp;
10807 MAILBOX_t *mb = &pmb->u.mb;10768 MAILBOX_t *mb = &pmb->u.mb;
10808 int rc;10769 int rc;
10809 10770
@@ -11068,11 +11029,11 @@ lpfc_cmpl_els_fdisc(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 258 unmodified lines
11068{11029{
11069 struct lpfc_vport *vport = cmdiocb->vport;11030 struct lpfc_vport *vport = cmdiocb->vport;
11070 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);11031 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
11071 struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *) cmdiocb->context1;11032 struct lpfc_nodelist *ndlp = cmdiocb->ndlp;
11072 struct lpfc_nodelist *np;11033 struct lpfc_nodelist *np;
11073 struct lpfc_nodelist *next_np;11034 struct lpfc_nodelist *next_np;
11074 struct lpfc_iocbq *piocb;11035 struct lpfc_iocbq *piocb;
11075 struct lpfc_dmabuf *pcmd = cmdiocb->context2, *prsp;11036 struct lpfc_dmabuf *pcmd = cmdiocb->cmd_dmabuf, *prsp;
11076 struct serv_parm *sp;11037 struct serv_parm *sp;
11077 uint8_t fabric_param_changed;11038 uint8_t fabric_param_changed;
11078 u32 ulp_status, ulp_word4;11039 u32 ulp_status, ulp_word4;
@@ -11210,7 +11171,7 @@ out: · 131 unmodified lines
11210 * IOCB will be sent off HBA at any given time.11171 * IOCB will be sent off HBA at any given time.
11211 *11172 *
11212 * Note that the ndlp reference count will be incremented by 1 for holding the11173 * Note that the ndlp reference count will be incremented by 1 for holding the
11213 * ndlp and the reference to ndlp will be stored into the context1 field of11174 * ndlp and the reference to ndlp will be stored into the ndlp field of
11214 * the IOCB for the completion callback function to the FDISC ELS command.11175 * the IOCB for the completion callback function to the FDISC ELS command.
11215 *11176 *
11216 * Return code11177 * Return code
@@ -11255,7 +11216,7 @@ lpfc_issue_els_fdisc(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, · 38 unmodified lines
11255 icmd->ulpCt_l = 0;11216 icmd->ulpCt_l = 0;
11256 }11217 }
11257 11218
11258 pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt);11219 pcmd = (uint8_t *)elsiocb->cmd_dmabuf->virt;
11259 *((uint32_t *) (pcmd)) = ELS_CMD_FDISC;11220 *((uint32_t *) (pcmd)) = ELS_CMD_FDISC;
11260 pcmd += sizeof(uint32_t); /* CSP Word 1 */11221 pcmd += sizeof(uint32_t); /* CSP Word 1 */
11261 memcpy(pcmd, &vport->phba->pport->fc_sparam, sizeof(struct serv_parm));11222 memcpy(pcmd, &vport->phba->pport->fc_sparam, sizeof(struct serv_parm));
@@ -11287,8 +11248,8 @@ lpfc_issue_els_fdisc(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, · 25 unmodified lines
11287 "Issue FDISC: did:x%x",11248 "Issue FDISC: did:x%x",
11288 did, 0, 0);11249 did, 0, 0);
11289 11250
11290 elsiocb->context1 = lpfc_nlp_get(ndlp);11251 elsiocb->ndlp = lpfc_nlp_get(ndlp);
11291 if (!elsiocb->context1)11252 if (!elsiocb->ndlp)
11292 goto err_out;11253 goto err_out;
11293 11254
11294 rc = lpfc_issue_fabric_iocb(phba, elsiocb);11255 rc = lpfc_issue_fabric_iocb(phba, elsiocb);
@@ -11332,7 +11293,7 @@ lpfc_cmpl_els_npiv_logo(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 37 unmodified lines
11332 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);11293 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
11333 u32 ulp_status, ulp_word4, did, tmo;11294 u32 ulp_status, ulp_word4, did, tmo;
11334 11295
11335 ndlp = (struct lpfc_nodelist *)cmdiocb->context1;11296 ndlp = cmdiocb->ndlp;
11336 11297
11337 ulp_status = get_job_ulpstatus(phba, rspiocb);11298 ulp_status = get_job_ulpstatus(phba, rspiocb);
11338 ulp_word4 = get_job_word4(phba, rspiocb);11299 ulp_word4 = get_job_word4(phba, rspiocb);
@@ -11390,7 +11351,7 @@ lpfc_cmpl_els_npiv_logo(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 51 unmodified lines
11390 * This routine issues a LOGO ELS command to an @ndlp off a @vport.11351 * This routine issues a LOGO ELS command to an @ndlp off a @vport.
11391 *11352 *
11392 * Note that the ndlp reference count will be incremented by 1 for holding the11353 * Note that the ndlp reference count will be incremented by 1 for holding the
11393 * ndlp and the reference to ndlp will be stored into the context1 field of11354 * ndlp and the reference to ndlp will be stored into the ndlp field of
11394 * the IOCB for the completion callback function to the LOGO ELS command.11355 * the IOCB for the completion callback function to the LOGO ELS command.
11395 *11356 *
11396 * Return codes11357 * Return codes
@@ -11412,7 +11373,7 @@ lpfc_issue_els_npiv_logo(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp) · 15 unmodified lines
11412 if (!elsiocb)11373 if (!elsiocb)
11413 return 1;11374 return 1;
11414 11375
11415 pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt);11376 pcmd = (uint8_t *)elsiocb->cmd_dmabuf->virt;
11416 *((uint32_t *) (pcmd)) = ELS_CMD_LOGO;11377 *((uint32_t *) (pcmd)) = ELS_CMD_LOGO;
11417 pcmd += sizeof(uint32_t);11378 pcmd += sizeof(uint32_t);
11418 11379
@@ -11429,8 +11390,8 @@ lpfc_issue_els_npiv_logo(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp) · 10 unmodified lines
11429 spin_lock_irq(&ndlp->lock);11390 spin_lock_irq(&ndlp->lock);
11430 ndlp->nlp_flag |= NLP_LOGO_SND;11391 ndlp->nlp_flag |= NLP_LOGO_SND;
11431 spin_unlock_irq(&ndlp->lock);11392 spin_unlock_irq(&ndlp->lock);
11432 elsiocb->context1 = lpfc_nlp_get(ndlp);11393 elsiocb->ndlp = lpfc_nlp_get(ndlp);
11433 if (!elsiocb->context1) {11394 if (!elsiocb->ndlp) {
11434 lpfc_els_free_iocb(phba, elsiocb);11395 lpfc_els_free_iocb(phba, elsiocb);
11435 goto err;11396 goto err;
11436 }11397 }
@@ -11989,12 +11950,12 @@ lpfc_cmpl_els_qfpa(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 552 unmodified lines
11989 struct lpfc_dmabuf *prsp = NULL;11950 struct lpfc_dmabuf *prsp = NULL;
11990 struct lpfc_vmid_priority_range *vmid_range = NULL;11951 struct lpfc_vmid_priority_range *vmid_range = NULL;
11991 u32 *data;11952 u32 *data;
11992 struct lpfc_dmabuf *dmabuf = cmdiocb->context2;11953 struct lpfc_dmabuf *dmabuf = cmdiocb->cmd_dmabuf;
11993 u32 ulp_status = get_job_ulpstatus(phba, rspiocb);11954 u32 ulp_status = get_job_ulpstatus(phba, rspiocb);
11994 u32 ulp_word4 = get_job_word4(phba, rspiocb);11955 u32 ulp_word4 = get_job_word4(phba, rspiocb);
11995 u8 *pcmd, max_desc;11956 u8 *pcmd, max_desc;
11996 u32 len, i;11957 u32 len, i;
11997 struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *)cmdiocb->context1;11958 struct lpfc_nodelist *ndlp = cmdiocb->ndlp;
11998 11959
11999 prsp = list_get_first(&dmabuf->list, struct lpfc_dmabuf, list);11960 prsp = list_get_first(&dmabuf->list, struct lpfc_dmabuf, list);
12000 if (!prsp)11961 if (!prsp)
@@ -12090,15 +12051,15 @@ int lpfc_issue_els_qfpa(struct lpfc_vport *vport) · 89 unmodified lines
12090 if (!elsiocb)12051 if (!elsiocb)
12091 return -ENOMEM;12052 return -ENOMEM;
12092 12053
12093 pcmd = (u8 *)(((struct lpfc_dmabuf *)elsiocb->context2)->virt);12054 pcmd = (u8 *)elsiocb->cmd_dmabuf->virt;
12094 12055
12095 *((u32 *)(pcmd)) = ELS_CMD_QFPA;12056 *((u32 *)(pcmd)) = ELS_CMD_QFPA;
12096 pcmd += 4;12057 pcmd += 4;
12097 12058
12098 elsiocb->cmd_cmpl = lpfc_cmpl_els_qfpa;12059 elsiocb->cmd_cmpl = lpfc_cmpl_els_qfpa;
12099 12060
12100 elsiocb->context1 = lpfc_nlp_get(ndlp);12061 elsiocb->ndlp = lpfc_nlp_get(ndlp);
12101 if (!elsiocb->context1) {12062 if (!elsiocb->ndlp) {
12102 lpfc_els_free_iocb(vport->phba, elsiocb);12063 lpfc_els_free_iocb(vport->phba, elsiocb);
12103 return -ENXIO;12064 return -ENXIO;
12104 }12065 }
@@ -12145,7 +12106,7 @@ lpfc_vmid_uvem(struct lpfc_vport *vport, · 40 unmodified lines
12145 vmid_context->nlp = ndlp;12106 vmid_context->nlp = ndlp;
12146 vmid_context->instantiated = instantiated;12107 vmid_context->instantiated = instantiated;
12147 elsiocb->vmid_tag.vmid_context = vmid_context;12108 elsiocb->vmid_tag.vmid_context = vmid_context;
12148 pcmd = (u8 *)(((struct lpfc_dmabuf *)elsiocb->context2)->virt);12109 pcmd = (u8 *)elsiocb->cmd_dmabuf->virt;
12149 12110
12150 if (uuid_is_null((uuid_t *)vport->lpfc_vmid_host_uuid))12111 if (uuid_is_null((uuid_t *)vport->lpfc_vmid_host_uuid))
12151 memcpy(vport->lpfc_vmid_host_uuid, vmid->host_vmid,12112 memcpy(vport->lpfc_vmid_host_uuid, vmid->host_vmid,
@@ -12180,8 +12141,8 @@ lpfc_vmid_uvem(struct lpfc_vport *vport, · 28 unmodified lines
12180 12141
12181 elsiocb->cmd_cmpl = lpfc_cmpl_els_uvem;12142 elsiocb->cmd_cmpl = lpfc_cmpl_els_uvem;
12182 12143
12183 elsiocb->context1 = lpfc_nlp_get(ndlp);12144 elsiocb->ndlp = lpfc_nlp_get(ndlp);
12184 if (!elsiocb->context1) {12145 if (!elsiocb->ndlp) {
12185 lpfc_els_free_iocb(vport->phba, elsiocb);12146 lpfc_els_free_iocb(vport->phba, elsiocb);
12186 goto out;12147 goto out;
12187 }12148 }
@@ -12207,12 +12168,12 @@ lpfc_cmpl_els_uvem(struct lpfc_hba *phba, struct lpfc_iocbq *icmdiocb, · 19 unmodified lines
12207 struct lpfc_dmabuf *prsp = NULL;12168 struct lpfc_dmabuf *prsp = NULL;
12208 struct lpfc_vmid_context *vmid_context =12169 struct lpfc_vmid_context *vmid_context =
12209 icmdiocb->vmid_tag.vmid_context;12170 icmdiocb->vmid_tag.vmid_context;
12210 struct lpfc_nodelist *ndlp = icmdiocb->context1;12171 struct lpfc_nodelist *ndlp = icmdiocb->ndlp;
12211 u8 *pcmd;12172 u8 *pcmd;
12212 u32 *data;12173 u32 *data;
12213 u32 ulp_status = get_job_ulpstatus(phba, rspiocb);12174 u32 ulp_status = get_job_ulpstatus(phba, rspiocb);
12214 u32 ulp_word4 = get_job_word4(phba, rspiocb);12175 u32 ulp_word4 = get_job_word4(phba, rspiocb);
12215 struct lpfc_dmabuf *dmabuf = icmdiocb->context2;12176 struct lpfc_dmabuf *dmabuf = icmdiocb->cmd_dmabuf;
12216 struct lpfc_vmid *vmid;12177 struct lpfc_vmid *vmid;
12217 12178
12218 vmid = vmid_context->vmp;12179 vmid = vmid_context->vmp;
drivers/scsi/lpfc/lpfc_hbadisc.c+63−101
@@ -1183,6 +1183,7 @@ lpfc_port_link_failure(struct lpfc_vport *vport) · 1182 unmodified lines
1183void1183void
1184lpfc_linkdown_port(struct lpfc_vport *vport)1184lpfc_linkdown_port(struct lpfc_vport *vport)
1185{1185{
1186 struct lpfc_hba *phba = vport->phba;
1186 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);1187 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
1187 1188
1188 if (vport->cfg_enable_fc4_type != LPFC_ENABLE_NVME)1189 if (vport->cfg_enable_fc4_type != LPFC_ENABLE_NVME)
@@ -1200,6 +1201,13 @@ lpfc_linkdown_port(struct lpfc_vport *vport) · 11 unmodified lines
1200 vport->fc_flag &= ~FC_DISC_DELAYED;1201 vport->fc_flag &= ~FC_DISC_DELAYED;
1201 spin_unlock_irq(shost->host_lock);1202 spin_unlock_irq(shost->host_lock);
1202 del_timer_sync(&vport->delayed_disc_tmo);1203 del_timer_sync(&vport->delayed_disc_tmo);
1204
1205 if (phba->sli_rev == LPFC_SLI_REV4 &&
1206 vport->port_type == LPFC_PHYSICAL_PORT &&
1207 phba->sli4_hba.fawwpn_flag & LPFC_FAWWPN_CONFIG) {
1208 /* Assume success on link up */
1209 phba->sli4_hba.fawwpn_flag |= LPFC_FAWWPN_FABRIC;
1210 }
1203}1211}
1204 1212
1205int1213int
@@ -1221,6 +1229,9 @@ lpfc_linkdown(struct lpfc_hba *phba) · 15 unmodified lines
1221 1229
1222 phba->defer_flogi_acc_flag = false;1230 phba->defer_flogi_acc_flag = false;
1223 1231
1232 /* Clear external loopback plug detected flag */
1233 phba->link_flag &= ~LS_EXTERNAL_LOOPBACK;
1234
1224 spin_lock_irq(&phba->hbalock);1235 spin_lock_irq(&phba->hbalock);
1225 phba->fcf.fcf_flag &= ~(FCF_AVAILABLE | FCF_SCAN_DONE);1236 phba->fcf.fcf_flag &= ~(FCF_AVAILABLE | FCF_SCAN_DONE);
1226 spin_unlock_irq(&phba->hbalock);1237 spin_unlock_irq(&phba->hbalock);
@@ -1343,10 +1354,12 @@ lpfc_linkup_port(struct lpfc_vport *vport) · 116 unmodified lines
1343 1354
1344 spin_lock_irq(shost->host_lock);1355 spin_lock_irq(shost->host_lock);
1345 vport->fc_flag &= ~(FC_PT2PT | FC_PT2PT_PLOGI | FC_ABORT_DISCOVERY |1356 vport->fc_flag &= ~(FC_PT2PT | FC_PT2PT_PLOGI | FC_ABORT_DISCOVERY |
1346 FC_RSCN_MODE | FC_NLP_MORE | FC_RSCN_DISCOVERY);1357 FC_RSCN_MEMENTO | FC_RSCN_MODE |
1358 FC_NLP_MORE | FC_RSCN_DISCOVERY);
1347 vport->fc_flag |= FC_NDISC_ACTIVE;1359 vport->fc_flag |= FC_NDISC_ACTIVE;
1348 vport->fc_ns_retry = 0;1360 vport->fc_ns_retry = 0;
1349 spin_unlock_irq(shost->host_lock);1361 spin_unlock_irq(shost->host_lock);
1362 lpfc_setup_fdmi_mask(vport);
1350 1363
1351 lpfc_linkup_cleanup_nodes(vport);1364 lpfc_linkup_cleanup_nodes(vport);
1352}1365}
@@ -1378,8 +1391,8 @@ lpfc_linkup(struct lpfc_hba *phba) · 25 unmodified lines
1378 phba->pport->rcv_flogi_cnt = 0;1391 phba->pport->rcv_flogi_cnt = 0;
1379 spin_unlock_irq(shost->host_lock);1392 spin_unlock_irq(shost->host_lock);
1380 1393
1381 /* reinitialize initial FLOGI flag */1394 /* reinitialize initial HBA flag */
1382 phba->hba_flag &= ~(HBA_FLOGI_ISSUED);1395 phba->hba_flag &= ~(HBA_FLOGI_ISSUED | HBA_RHBA_CMPL);
1383 phba->defer_flogi_acc_flag = false;1396 phba->defer_flogi_acc_flag = false;
1384 1397
1385 return 0;1398 return 0;
@@ -1458,7 +1471,6 @@ lpfc_mbx_cmpl_local_config_link(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) · 72 unmodified lines
1458{1471{
1459 struct lpfc_vport *vport = pmb->vport;1472 struct lpfc_vport *vport = pmb->vport;
1460 LPFC_MBOXQ_t *sparam_mb;1473 LPFC_MBOXQ_t *sparam_mb;
1461 struct lpfc_dmabuf *sparam_mp;
1462 u16 status = pmb->u.mb.mbxStatus;1474 u16 status = pmb->u.mb.mbxStatus;
1463 int rc;1475 int rc;
1464 1476
@@ -1507,13 +1519,8 @@ lpfc_mbx_cmpl_local_config_link(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) · 42 unmodified lines
1507 sparam_mb->mbox_cmpl = lpfc_mbx_cmpl_read_sparam;1519 sparam_mb->mbox_cmpl = lpfc_mbx_cmpl_read_sparam;
1508 rc = lpfc_sli_issue_mbox(phba, sparam_mb, MBX_NOWAIT);1520 rc = lpfc_sli_issue_mbox(phba, sparam_mb, MBX_NOWAIT);
1509 if (rc == MBX_NOT_FINISHED) {1521 if (rc == MBX_NOT_FINISHED) {
1510 sparam_mp = (struct lpfc_dmabuf *)1522 lpfc_mbox_rsrc_cleanup(phba, sparam_mb,
1511 sparam_mb->ctx_buf;1523 MBOX_THD_UNLOCKED);
1512 lpfc_mbuf_free(phba, sparam_mp->virt,
1513 sparam_mp->phys);
1514 kfree(sparam_mp);
1515 sparam_mb->ctx_buf = NULL;
1516 mempool_free(sparam_mb, phba->mbox_mem_pool);
1517 goto sparam_out;1524 goto sparam_out;
1518 }1525 }
1519 1526
@@ -3312,7 +3319,6 @@ lpfc_start_fdiscs(struct lpfc_hba *phba) · 1792 unmodified lines
3312void3319void
3313lpfc_mbx_cmpl_reg_vfi(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq)3320lpfc_mbx_cmpl_reg_vfi(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq)
3314{3321{
3315 struct lpfc_dmabuf *dmabuf = mboxq->ctx_buf;
3316 struct lpfc_vport *vport = mboxq->vport;3322 struct lpfc_vport *vport = mboxq->vport;
3317 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);3323 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
3318 3324
@@ -3393,12 +3399,7 @@ lpfc_mbx_cmpl_reg_vfi(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq) · 74 unmodified lines
3393 }3399 }
3394 3400
3395out_free_mem:3401out_free_mem:
3396 mempool_free(mboxq, phba->mbox_mem_pool);3402 lpfc_mbox_rsrc_cleanup(phba, mboxq, MBOX_THD_UNLOCKED);
3397 if (dmabuf) {
3398 lpfc_mbuf_free(phba, dmabuf->virt, dmabuf->phys);
3399 kfree(dmabuf);
3400 }
3401 return;
3402}3403}
3403 3404
3404static void3405static void
@@ -3443,9 +3444,7 @@ lpfc_mbx_cmpl_read_sparam(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) · 38 unmodified lines
3443 memcpy(&phba->wwpn, &vport->fc_portname, sizeof(phba->wwnn));3444 memcpy(&phba->wwpn, &vport->fc_portname, sizeof(phba->wwnn));
3444 }3445 }
3445 3446
3446 lpfc_mbuf_free(phba, mp->virt, mp->phys);3447 lpfc_mbox_rsrc_cleanup(phba, pmb, MBOX_THD_UNLOCKED);
3447 kfree(mp);
3448 mempool_free(pmb, phba->mbox_mem_pool);
3449 3448
3450 /* Check if sending the FLOGI is being deferred to after we get3449 /* Check if sending the FLOGI is being deferred to after we get
3451 * up to date CSPs from MBX_READ_SPARAM.3450 * up to date CSPs from MBX_READ_SPARAM.
@@ -3457,12 +3456,8 @@ lpfc_mbx_cmpl_read_sparam(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) · 5 unmodified lines
3457 return;3456 return;
3458 3457
3459out:3458out:
3460 pmb->ctx_buf = NULL;3459 lpfc_mbox_rsrc_cleanup(phba, pmb, MBOX_THD_UNLOCKED);
3461 lpfc_mbuf_free(phba, mp->virt, mp->phys);
3462 kfree(mp);
3463 lpfc_issue_clear_la(phba, vport);3460 lpfc_issue_clear_la(phba, vport);
3464 mempool_free(pmb, phba->mbox_mem_pool);
3465 return;
3466}3461}
3467 3462
3468static void3463static void
@@ -3472,7 +3467,6 @@ lpfc_mbx_process_link_up(struct lpfc_hba *phba, struct lpfc_mbx_read_top *la) · 3 unmodified lines
3472 LPFC_MBOXQ_t *sparam_mbox, *cfglink_mbox = NULL;3467 LPFC_MBOXQ_t *sparam_mbox, *cfglink_mbox = NULL;
3473 struct Scsi_Host *shost;3468 struct Scsi_Host *shost;
3474 int i;3469 int i;
3475 struct lpfc_dmabuf *mp;
3476 int rc;3470 int rc;
3477 struct fcf_record *fcf_record;3471 struct fcf_record *fcf_record;
3478 uint32_t fc_flags = 0;3472 uint32_t fc_flags = 0;
@@ -3600,10 +3594,7 @@ lpfc_mbx_process_link_up(struct lpfc_hba *phba, struct lpfc_mbx_read_top *la) · 121 unmodified lines
3600 sparam_mbox->mbox_cmpl = lpfc_mbx_cmpl_read_sparam;3594 sparam_mbox->mbox_cmpl = lpfc_mbx_cmpl_read_sparam;
3601 rc = lpfc_sli_issue_mbox(phba, sparam_mbox, MBX_NOWAIT);3595 rc = lpfc_sli_issue_mbox(phba, sparam_mbox, MBX_NOWAIT);
3602 if (rc == MBX_NOT_FINISHED) {3596 if (rc == MBX_NOT_FINISHED) {
3603 mp = (struct lpfc_dmabuf *)sparam_mbox->ctx_buf;3597 lpfc_mbox_rsrc_cleanup(phba, sparam_mbox, MBOX_THD_UNLOCKED);
3604 lpfc_mbuf_free(phba, mp->virt, mp->phys);
3605 kfree(mp);
3606 mempool_free(sparam_mbox, phba->mbox_mem_pool);
3607 goto out;3598 goto out;
3608 }3599 }
3609 3600
@@ -3879,10 +3870,7 @@ lpfc_mbx_cmpl_read_topology(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) · 269 unmodified lines
3879 }3870 }
3880 3871
3881lpfc_mbx_cmpl_read_topology_free_mbuf:3872lpfc_mbx_cmpl_read_topology_free_mbuf:
3882 lpfc_mbuf_free(phba, mp->virt, mp->phys);3873 lpfc_mbox_rsrc_cleanup(phba, pmb, MBOX_THD_UNLOCKED);
3883 kfree(mp);
3884 mempool_free(pmb, phba->mbox_mem_pool);
3885 return;
3886}3874}
3887 3875
3888/*3876/*
@@ -3895,9 +3883,13 @@ void · 6 unmodified lines
3895lpfc_mbx_cmpl_reg_login(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)3883lpfc_mbx_cmpl_reg_login(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
3896{3884{
3897 struct lpfc_vport *vport = pmb->vport;3885 struct lpfc_vport *vport = pmb->vport;
3898 struct lpfc_dmabuf *mp = (struct lpfc_dmabuf *)(pmb->ctx_buf);3886 struct lpfc_dmabuf *mp = (struct lpfc_dmabuf *)pmb->ctx_buf;
3899 struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *)pmb->ctx_ndlp;3887 struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *)pmb->ctx_ndlp;
3900 3888
3889 /* The driver calls the state machine with the pmb pointer
3890 * but wants to make sure a stale ctx_buf isn't acted on.
3891 * The ctx_buf is restored later and cleaned up.
3892 */
3901 pmb->ctx_buf = NULL;3893 pmb->ctx_buf = NULL;
3902 pmb->ctx_ndlp = NULL;3894 pmb->ctx_ndlp = NULL;
3903 3895
@@ -3934,10 +3926,9 @@ lpfc_mbx_cmpl_reg_login(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) · 30 unmodified lines
3934 3926
3935 /* Call state machine */3927 /* Call state machine */
3936 lpfc_disc_state_machine(vport, ndlp, pmb, NLP_EVT_CMPL_REG_LOGIN);3928 lpfc_disc_state_machine(vport, ndlp, pmb, NLP_EVT_CMPL_REG_LOGIN);
3929 pmb->ctx_buf = mp;
3930 lpfc_mbox_rsrc_cleanup(phba, pmb, MBOX_THD_UNLOCKED);
3937 3931
3938 lpfc_mbuf_free(phba, mp->virt, mp->phys);
3939 kfree(mp);
3940 mempool_free(pmb, phba->mbox_mem_pool);
3941 /* decrement the node reference count held for this callback3932 /* decrement the node reference count held for this callback
3942 * function.3933 * function.
3943 */3934 */
@@ -4104,11 +4095,15 @@ lpfc_create_static_vport(struct lpfc_hba *phba) · 160 unmodified lines
4104 4095
4105 vport_buff = (uint8_t *) vport_info;4096 vport_buff = (uint8_t *) vport_info;
4106 do {4097 do {
4107 /* free dma buffer from previous round */4098 /* While loop iteration forces a free dma buffer from
4099 * the previous loop because the mbox is reused and
4100 * the dump routine is a single-use construct.
4101 */
4108 if (pmb->ctx_buf) {4102 if (pmb->ctx_buf) {
4109 mp = (struct lpfc_dmabuf *)pmb->ctx_buf;4103 mp = (struct lpfc_dmabuf *)pmb->ctx_buf;
4110 lpfc_mbuf_free(phba, mp->virt, mp->phys);4104 lpfc_mbuf_free(phba, mp->virt, mp->phys);
4111 kfree(mp);4105 kfree(mp);
4106 pmb->ctx_buf = NULL;
4112 }4107 }
4113 if (lpfc_dump_static_vport(phba, pmb, offset))4108 if (lpfc_dump_static_vport(phba, pmb, offset))
4114 goto out;4109 goto out;
@@ -4193,16 +4188,8 @@ lpfc_create_static_vport(struct lpfc_hba *phba) · 78 unmodified lines
4193 4188
4194out:4189out:
4195 kfree(vport_info);4190 kfree(vport_info);
4196 if (mbx_wait_rc != MBX_TIMEOUT) {4191 if (mbx_wait_rc != MBX_TIMEOUT)
4197 if (pmb->ctx_buf) {4192 lpfc_mbox_rsrc_cleanup(phba, pmb, MBOX_THD_UNLOCKED);
4198 mp = (struct lpfc_dmabuf *)pmb->ctx_buf;
4199 lpfc_mbuf_free(phba, mp->virt, mp->phys);
4200 kfree(mp);
4201 }
4202 mempool_free(pmb, phba->mbox_mem_pool);
4203 }
4204
4205 return;
4206}4193}
4207 4194
4208/*4195/*
@@ -4216,22 +4203,16 @@ lpfc_mbx_cmpl_fabric_reg_login(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) · 7 unmodified lines
4216{4203{
4217 struct lpfc_vport *vport = pmb->vport;4204 struct lpfc_vport *vport = pmb->vport;
4218 MAILBOX_t *mb = &pmb->u.mb;4205 MAILBOX_t *mb = &pmb->u.mb;
4219 struct lpfc_dmabuf *mp = (struct lpfc_dmabuf *)(pmb->ctx_buf);4206 struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *)pmb->ctx_ndlp;
4220 struct lpfc_nodelist *ndlp;
4221 struct Scsi_Host *shost;4207 struct Scsi_Host *shost;
4222 4208
4223 ndlp = (struct lpfc_nodelist *)pmb->ctx_ndlp;
4224 pmb->ctx_ndlp = NULL;4209 pmb->ctx_ndlp = NULL;
4225 pmb->ctx_buf = NULL;
4226 4210
4227 if (mb->mbxStatus) {4211 if (mb->mbxStatus) {
4228 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,4212 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
4229 "0258 Register Fabric login error: 0x%x\n",4213 "0258 Register Fabric login error: 0x%x\n",
4230 mb->mbxStatus);4214 mb->mbxStatus);
4231 lpfc_mbuf_free(phba, mp->virt, mp->phys);4215 lpfc_mbox_rsrc_cleanup(phba, pmb, MBOX_THD_UNLOCKED);
4232 kfree(mp);
4233 mempool_free(pmb, phba->mbox_mem_pool);
4234
4235 if (phba->fc_topology == LPFC_TOPOLOGY_LOOP) {4216 if (phba->fc_topology == LPFC_TOPOLOGY_LOOP) {
4236 /* FLOGI failed, use loop map to make discovery list */4217 /* FLOGI failed, use loop map to make discovery list */
4237 lpfc_disc_list_loopmap(vport);4218 lpfc_disc_list_loopmap(vport);
@@ -4273,9 +4254,7 @@ lpfc_mbx_cmpl_fabric_reg_login(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) · 35 unmodified lines
4273 lpfc_do_scr_ns_plogi(phba, vport);4254 lpfc_do_scr_ns_plogi(phba, vport);
4274 }4255 }
4275 4256
4276 lpfc_mbuf_free(phba, mp->virt, mp->phys);4257 lpfc_mbox_rsrc_cleanup(phba, pmb, MBOX_THD_UNLOCKED);
4277 kfree(mp);
4278 mempool_free(pmb, phba->mbox_mem_pool);
4279 4258
4280 /* Drop the reference count from the mbox at the end after4259 /* Drop the reference count from the mbox at the end after
4281 * all the current reference to the ndlp have been done.4260 * all the current reference to the ndlp have been done.
@@ -4369,12 +4348,10 @@ void · 87 unmodified lines
4369lpfc_mbx_cmpl_ns_reg_login(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)4348lpfc_mbx_cmpl_ns_reg_login(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
4370{4349{
4371 MAILBOX_t *mb = &pmb->u.mb;4350 MAILBOX_t *mb = &pmb->u.mb;
4372 struct lpfc_dmabuf *mp = (struct lpfc_dmabuf *)(pmb->ctx_buf);
4373 struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *)pmb->ctx_ndlp;4351 struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *)pmb->ctx_ndlp;
4374 struct lpfc_vport *vport = pmb->vport;4352 struct lpfc_vport *vport = pmb->vport;
4375 int rc;4353 int rc;
4376 4354
4377 pmb->ctx_buf = NULL;
4378 pmb->ctx_ndlp = NULL;4355 pmb->ctx_ndlp = NULL;
4379 vport->gidft_inp = 0;4356 vport->gidft_inp = 0;
4380 4357
@@ -4388,9 +4365,7 @@ out: · 7 unmodified lines
4388 * callback function.4365 * callback function.
4389 */4366 */
4390 lpfc_nlp_put(ndlp);4367 lpfc_nlp_put(ndlp);
4391 lpfc_mbuf_free(phba, mp->virt, mp->phys);4368 lpfc_mbox_rsrc_cleanup(phba, pmb, MBOX_THD_UNLOCKED);
4392 kfree(mp);
4393 mempool_free(pmb, phba->mbox_mem_pool);
4394 4369
4395 /* If the node is not registered with the scsi or nvme4370 /* If the node is not registered with the scsi or nvme
4396 * transport, remove the fabric node. The failed reg_login4371 * transport, remove the fabric node. The failed reg_login
@@ -4479,10 +4454,7 @@ out: · 82 unmodified lines
4479 * callback function.4454 * callback function.
4480 */4455 */
4481 lpfc_nlp_put(ndlp);4456 lpfc_nlp_put(ndlp);
4482 lpfc_mbuf_free(phba, mp->virt, mp->phys);4457 lpfc_mbox_rsrc_cleanup(phba, pmb, MBOX_THD_UNLOCKED);
4483 kfree(mp);
4484 mempool_free(pmb, phba->mbox_mem_pool);
4485
4486 return;4458 return;
4487}4459}
4488 4460
@@ -4496,13 +4468,9 @@ lpfc_mbx_cmpl_fc_reg_login(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) · 7 unmodified lines
4496{4468{
4497 struct lpfc_vport *vport = pmb->vport;4469 struct lpfc_vport *vport = pmb->vport;
4498 MAILBOX_t *mb = &pmb->u.mb;4470 MAILBOX_t *mb = &pmb->u.mb;
4499 struct lpfc_dmabuf *mp = (struct lpfc_dmabuf *)(pmb->ctx_buf);4471 struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *)pmb->ctx_ndlp;
4500 struct lpfc_nodelist *ndlp;
4501 4472
4502 ndlp = (struct lpfc_nodelist *)pmb->ctx_ndlp;
4503 pmb->ctx_ndlp = NULL;4473 pmb->ctx_ndlp = NULL;
4504 pmb->ctx_buf = NULL;
4505
4506 if (mb->mbxStatus) {4474 if (mb->mbxStatus) {
4507 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,4475 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
4508 "0933 %s: Register FC login error: 0x%x\n",4476 "0933 %s: Register FC login error: 0x%x\n",
@@ -4526,9 +4494,7 @@ lpfc_mbx_cmpl_fc_reg_login(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) · 17 unmodified lines
4526 lpfc_nlp_set_state(vport, ndlp, NLP_STE_UNMAPPED_NODE);4494 lpfc_nlp_set_state(vport, ndlp, NLP_STE_UNMAPPED_NODE);
4527 4495
4528 out:4496 out:
4529 lpfc_mbuf_free(phba, mp->virt, mp->phys);4497 lpfc_mbox_rsrc_cleanup(phba, pmb, MBOX_THD_UNLOCKED);
4530 kfree(mp);
4531 mempool_free(pmb, phba->mbox_mem_pool);
4532 4498
4533 /* Drop the reference count from the mbox at the end after4499 /* Drop the reference count from the mbox at the end after
4534 * all the current reference to the ndlp have been done.4500 * all the current reference to the ndlp have been done.
@@ -5155,7 +5121,7 @@ lpfc_check_sli_ndlp(struct lpfc_hba *phba, · 620 unmodified lines
5155 if (pring->ringno == LPFC_ELS_RING) {5121 if (pring->ringno == LPFC_ELS_RING) {
5156 switch (ulp_command) {5122 switch (ulp_command) {
5157 case CMD_GEN_REQUEST64_CR:5123 case CMD_GEN_REQUEST64_CR:
5158 if (iocb->context_un.ndlp == ndlp)5124 if (iocb->ndlp == ndlp)
5159 return 1;5125 return 1;
5160 fallthrough;5126 fallthrough;
5161 case CMD_ELS_REQUEST64_CR:5127 case CMD_ELS_REQUEST64_CR:
@@ -5163,7 +5129,7 @@ lpfc_check_sli_ndlp(struct lpfc_hba *phba, · 1 unmodified line
5163 return 1;5129 return 1;
5164 fallthrough;5130 fallthrough;
5165 case CMD_XMIT_ELS_RSP64_CX:5131 case CMD_XMIT_ELS_RSP64_CX:
5166 if (iocb->context1 == (uint8_t *) ndlp)5132 if (iocb->ndlp == ndlp)
5167 return 1;5133 return 1;
5168 }5134 }
5169 } else if (pring->ringno == LPFC_FCP_RING) {5135 } else if (pring->ringno == LPFC_FCP_RING) {
@@ -5273,7 +5239,6 @@ lpfc_nlp_logo_unreg(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) · 103 unmodified lines
5273 if (!ndlp)5239 if (!ndlp)
5274 return;5240 return;
5275 lpfc_issue_els_logo(vport, ndlp, 0);5241 lpfc_issue_els_logo(vport, ndlp, 0);
5276 mempool_free(pmb, phba->mbox_mem_pool);
5277 5242
5278 /* Check to see if there are any deferred events to process */5243 /* Check to see if there are any deferred events to process */
5279 if ((ndlp->nlp_flag & NLP_UNREG_INP) &&5244 if ((ndlp->nlp_flag & NLP_UNREG_INP) &&
@@ -5300,6 +5265,13 @@ lpfc_nlp_logo_unreg(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) · 20 unmodified lines
5300 ndlp->nlp_flag &= ~NLP_UNREG_INP;5265 ndlp->nlp_flag &= ~NLP_UNREG_INP;
5301 spin_unlock_irq(&ndlp->lock);5266 spin_unlock_irq(&ndlp->lock);
5302 }5267 }
5268
5269 /* The node has an outstanding reference for the unreg. Now
5270 * that the LOGO action and cleanup are finished, release
5271 * resources.
5272 */
5273 lpfc_nlp_put(ndlp);
5274 mempool_free(pmb, phba->mbox_mem_pool);
5303}5275}
5304 5276
5305/*5277/*
@@ -5569,7 +5541,6 @@ lpfc_cleanup_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp) · 263 unmodified lines
5569{5541{
5570 struct lpfc_hba *phba = vport->phba;5542 struct lpfc_hba *phba = vport->phba;
5571 LPFC_MBOXQ_t *mb, *nextmb;5543 LPFC_MBOXQ_t *mb, *nextmb;
5572 struct lpfc_dmabuf *mp;
5573 5544
5574 /* Cleanup node for NPort <nlp_DID> */5545 /* Cleanup node for NPort <nlp_DID> */
5575 lpfc_printf_vlog(vport, KERN_INFO, LOG_NODE,5546 lpfc_printf_vlog(vport, KERN_INFO, LOG_NODE,
@@ -5607,16 +5578,11 @@ lpfc_cleanup_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp) · 31 unmodified lines
5607 if ((mb->u.mb.mbxCommand == MBX_REG_LOGIN64) &&5578 if ((mb->u.mb.mbxCommand == MBX_REG_LOGIN64) &&
5608 !(mb->mbox_flag & LPFC_MBX_IMED_UNREG) &&5579 !(mb->mbox_flag & LPFC_MBX_IMED_UNREG) &&
5609 (ndlp == (struct lpfc_nodelist *)mb->ctx_ndlp)) {5580 (ndlp == (struct lpfc_nodelist *)mb->ctx_ndlp)) {
5610 mp = (struct lpfc_dmabuf *)(mb->ctx_buf);
5611 if (mp) {
5612 __lpfc_mbuf_free(phba, mp->virt, mp->phys);
5613 kfree(mp);
5614 }
5615 list_del(&mb->list);5581 list_del(&mb->list);
5616 mempool_free(mb, phba->mbox_mem_pool);5582 lpfc_mbox_rsrc_cleanup(phba, mb, MBOX_THD_LOCKED);
5617 /* We shall not invoke the lpfc_nlp_put to decrement5583
5618 * the ndlp reference count as we are in the process5584 /* Don't invoke lpfc_nlp_put. The driver is in
5619 * of lpfc_nlp_release.5585 * lpfc_nlp_release context.
5620 */5586 */
5621 }5587 }
5622 }5588 }
@@ -6098,7 +6064,7 @@ lpfc_free_tx(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp) · 475 unmodified lines
6098 */6064 */
6099 spin_lock_irq(&phba->hbalock);6065 spin_lock_irq(&phba->hbalock);
6100 list_for_each_entry_safe(iocb, next_iocb, &pring->txq, list) {6066 list_for_each_entry_safe(iocb, next_iocb, &pring->txq, list) {
6101 if (iocb->context1 != ndlp)6067 if (iocb->ndlp != ndlp)
6102 continue;6068 continue;
6103 6069
6104 ulp_command = get_job_cmnd(phba, iocb);6070 ulp_command = get_job_cmnd(phba, iocb);
@@ -6112,7 +6078,7 @@ lpfc_free_tx(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp) · 7 unmodified lines
6112 6078
6113 /* Next check the txcmplq */6079 /* Next check the txcmplq */
6114 list_for_each_entry_safe(iocb, next_iocb, &pring->txcmplq, list) {6080 list_for_each_entry_safe(iocb, next_iocb, &pring->txcmplq, list) {
6115 if (iocb->context1 != ndlp)6081 if (iocb->ndlp != ndlp)
6116 continue;6082 continue;
6117 6083
6118 ulp_command = get_job_cmnd(phba, iocb);6084 ulp_command = get_job_cmnd(phba, iocb);
@@ -6390,8 +6356,9 @@ restart_disc: · 271 unmodified lines
6390 lpfc_printf_vlog(vport, KERN_ERR,6356 lpfc_printf_vlog(vport, KERN_ERR,
6391 LOG_TRACE_EVENT,6357 LOG_TRACE_EVENT,
6392 "0231 RSCN timeout Data: x%x "6358 "0231 RSCN timeout Data: x%x "
6393 "x%x\n",6359 "x%x x%x x%x\n",
6394 vport->fc_ns_retry, LPFC_MAX_NS_RETRY);6360 vport->fc_ns_retry, LPFC_MAX_NS_RETRY,
6361 vport->port_state, vport->gidft_inp);
6395 6362
6396 /* Cleanup any outstanding ELS commands */6363 /* Cleanup any outstanding ELS commands */
6397 lpfc_els_flush_cmd(vport);6364 lpfc_els_flush_cmd(vport);
@@ -6461,11 +6428,9 @@ void · 63 unmodified lines
6461lpfc_mbx_cmpl_fdmi_reg_login(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)6428lpfc_mbx_cmpl_fdmi_reg_login(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
6462{6429{
6463 MAILBOX_t *mb = &pmb->u.mb;6430 MAILBOX_t *mb = &pmb->u.mb;
6464 struct lpfc_dmabuf *mp = (struct lpfc_dmabuf *)(pmb->ctx_buf);
6465 struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *)pmb->ctx_ndlp;6431 struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *)pmb->ctx_ndlp;
6466 struct lpfc_vport *vport = pmb->vport;6432 struct lpfc_vport *vport = pmb->vport;
6467 6433
6468 pmb->ctx_buf = NULL;
6469 pmb->ctx_ndlp = NULL;6434 pmb->ctx_ndlp = NULL;
6470 6435
6471 if (phba->sli_rev < LPFC_SLI_REV4)6436 if (phba->sli_rev < LPFC_SLI_REV4)
@@ -6496,10 +6461,7 @@ lpfc_mbx_cmpl_fdmi_reg_login(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) · 24 unmodified lines
6496 * function.6461 * function.
6497 */6462 */
6498 lpfc_nlp_put(ndlp);6463 lpfc_nlp_put(ndlp);
6499 lpfc_mbuf_free(phba, mp->virt, mp->phys);6464 lpfc_mbox_rsrc_cleanup(phba, pmb, MBOX_THD_UNLOCKED);
6500 kfree(mp);
6501 mempool_free(pmb, phba->mbox_mem_pool);
6502
6503 return;6465 return;
6504}6466}
6505 6467
drivers/scsi/lpfc/lpfc_hw.h+44−31
@@ -97,6 +97,18 @@ union CtCommandResponse { · 96 unmodified lines
97#define FC4_FEATURE_INIT 0x297#define FC4_FEATURE_INIT 0x2
98#define FC4_FEATURE_NVME_DISC 0x498#define FC4_FEATURE_NVME_DISC 0x4
99 99
100enum rft_word0 {
101 RFT_FCP_REG = (0x1 << 8),
102};
103
104enum rft_word1 {
105 RFT_NVME_REG = (0x1 << 8),
106};
107
108enum rft_word3 {
109 RFT_APP_SERV_REG = (0x1 << 0),
110};
111
100struct lpfc_sli_ct_request {112struct lpfc_sli_ct_request {
101 /* Structure is in Big Endian format */113 /* Structure is in Big Endian format */
102 union CtRevisionId RevisionId;114 union CtRevisionId RevisionId;
@@ -131,25 +143,13 @@ struct lpfc_sli_ct_request { · 28 unmodified lines
131 uint8_t Fc4Type;143 uint8_t Fc4Type;
132 } gid_ff;144 } gid_ff;
133 struct rft {145 struct rft {
134 uint32_t PortId; /* For RFT_ID requests */146 __be32 port_id; /* For RFT_ID requests */
135 147
136#ifdef __BIG_ENDIAN_BITFIELD148 __be32 fcp_reg; /* rsvd 31:9, fcp_reg 8, rsvd 7:0 */
137 uint32_t rsvd0:16;149 __be32 nvme_reg; /* rsvd 31:9, nvme_reg 8, rsvd 7:0 */
138 uint32_t rsvd1:7;150 __be32 word2;
139 uint32_t fcpReg:1; /* Type 8 */151 __be32 app_serv_reg; /* rsvd 31:1, app_serv_reg 0 */
140 uint32_t rsvd2:2;152 __be32 word[4];
141 uint32_t ipReg:1; /* Type 5 */
142 uint32_t rsvd3:5;
143#else /* __LITTLE_ENDIAN_BITFIELD */
144 uint32_t rsvd0:16;
145 uint32_t fcpReg:1; /* Type 8 */
146 uint32_t rsvd1:7;
147 uint32_t rsvd3:5;
148 uint32_t ipReg:1; /* Type 5 */
149 uint32_t rsvd2:2;
150#endif
151
152 uint32_t rsvd[7];
153 } rft;153 } rft;
154 struct rnn {154 struct rnn {
155 uint32_t PortId; /* For RNN_ID requests */155 uint32_t PortId; /* For RNN_ID requests */
@@ -511,8 +511,6 @@ struct class_parms { · 355 unmodified lines
511 uint8_t word3Reserved2; /* Fc Word 3, bit 0: 7 */511 uint8_t word3Reserved2; /* Fc Word 3, bit 0: 7 */
512};512};
513 513
514#define FAPWWN_KEY_VENDOR 0x42524344 /*valid vendor version fawwpn key*/
515
516struct serv_parm { /* Structure is in Big Endian format */514struct serv_parm { /* Structure is in Big Endian format */
517 struct csp cmn;515 struct csp cmn;
518 struct lpfc_name portName;516 struct lpfc_name portName;
@@ -2650,19 +2648,26 @@ typedef struct { · 2131 unmodified lines
2650} READ_SPARM_VAR;2648} READ_SPARM_VAR;
2651 2649
2652/* Structure for MB Command READ_STATUS (14) */2650/* Structure for MB Command READ_STATUS (14) */
2651enum read_status_word1 {
2652 RD_ST_CC = 0x01,
2653 RD_ST_XKB = 0x80,
2654};
2655
2656enum read_status_word17 {
2657 RD_ST_XMIT_XKB_MASK = 0x3fffff,
2658};
2659
2660enum read_status_word18 {
2661 RD_ST_RCV_XKB_MASK = 0x3fffff,
2662};
2653 2663
2654typedef struct {2664typedef struct {
2655#ifdef __BIG_ENDIAN_BITFIELD2665 u8 clear_counters; /* rsvd 7:1, cc 0 */
2656 uint32_t rsvd1:31;2666 u8 rsvd5;
2657 uint32_t clrCounters:1;2667 u8 rsvd6;
2658 uint16_t activeXriCnt;2668 u8 xkb; /* xkb 7, rsvd 6:0 */
2659 uint16_t activeRpiCnt;2669
2660#else /* __LITTLE_ENDIAN_BITFIELD */2670 u32 rsvd8;
2661 uint32_t clrCounters:1;
2662 uint32_t rsvd1:31;
2663 uint16_t activeRpiCnt;
2664 uint16_t activeXriCnt;
2665#endif
2666 2671
2667 uint32_t xmitByteCnt;2672 uint32_t xmitByteCnt;
2668 uint32_t rcvByteCnt;2673 uint32_t rcvByteCnt;
@@ -2674,6 +2679,14 @@ typedef struct { · 5 unmodified lines
2674 uint32_t totalRespExchanges;2679 uint32_t totalRespExchanges;
2675 uint32_t rcvPbsyCnt;2680 uint32_t rcvPbsyCnt;
2676 uint32_t rcvFbsyCnt;2681 uint32_t rcvFbsyCnt;
2682
2683 u32 drop_frame_no_rq;
2684 u32 empty_rq;
2685 u32 drop_frame_no_xri;
2686 u32 empty_xri;
2687
2688 u32 xmit_xkb; /* rsvd 31:22, xmit_xkb 21:0 */
2689 u32 rcv_xkb; /* rsvd 31:22, rcv_xkb 21:0 */
2677} READ_STATUS_VAR;2690} READ_STATUS_VAR;
2678 2691
2679/* Structure for MB Command READ_RPI (15) */2692/* Structure for MB Command READ_RPI (15) */
drivers/scsi/lpfc/lpfc_hw4.h+12−5
@@ -2893,6 +2893,9 @@ struct lpfc_mbx_read_config { · 2892 unmodified lines
2893#define lpfc_mbx_rd_conf_extnts_inuse_SHIFT 312893#define lpfc_mbx_rd_conf_extnts_inuse_SHIFT 31
2894#define lpfc_mbx_rd_conf_extnts_inuse_MASK 0x000000012894#define lpfc_mbx_rd_conf_extnts_inuse_MASK 0x00000001
2895#define lpfc_mbx_rd_conf_extnts_inuse_WORD word12895#define lpfc_mbx_rd_conf_extnts_inuse_WORD word1
2896#define lpfc_mbx_rd_conf_fawwpn_SHIFT 30
2897#define lpfc_mbx_rd_conf_fawwpn_MASK 0x00000001
2898#define lpfc_mbx_rd_conf_fawwpn_WORD word1
2896#define lpfc_mbx_rd_conf_wcs_SHIFT 28 /* warning signaling */2899#define lpfc_mbx_rd_conf_wcs_SHIFT 28 /* warning signaling */
2897#define lpfc_mbx_rd_conf_wcs_MASK 0x000000012900#define lpfc_mbx_rd_conf_wcs_MASK 0x00000001
2898#define lpfc_mbx_rd_conf_wcs_WORD word12901#define lpfc_mbx_rd_conf_wcs_WORD word1
@@ -4473,12 +4476,8 @@ struct wqe_common { · 1574 unmodified lines
4473#define wqe_cmd_type_MASK 0x0000000f4476#define wqe_cmd_type_MASK 0x0000000f
4474#define wqe_cmd_type_WORD word114477#define wqe_cmd_type_WORD word11
4475#define wqe_els_id_SHIFT 44478#define wqe_els_id_SHIFT 4
4476#define wqe_els_id_MASK 0x000000034479#define wqe_els_id_MASK 0x00000007
4477#define wqe_els_id_WORD word114480#define wqe_els_id_WORD word11
4478#define LPFC_ELS_ID_FLOGI 3
4479#define LPFC_ELS_ID_FDISC 2
4480#define LPFC_ELS_ID_LOGO 1
4481#define LPFC_ELS_ID_DEFAULT 0
4482#define wqe_irsp_SHIFT 44481#define wqe_irsp_SHIFT 4
4483#define wqe_irsp_MASK 0x000000014482#define wqe_irsp_MASK 0x00000001
4484#define wqe_irsp_WORD word114483#define wqe_irsp_WORD word11
@@ -4525,6 +4524,14 @@ struct lpfc_wqe_generic{ · 40 unmodified lines
4525 uint32_t payload[4];4524 uint32_t payload[4];
4526};4525};
4527 4526
4527enum els_request64_wqe_word11 {
4528 LPFC_ELS_ID_DEFAULT,
4529 LPFC_ELS_ID_LOGO,
4530 LPFC_ELS_ID_FDISC,
4531 LPFC_ELS_ID_FLOGI,
4532 LPFC_ELS_ID_PLOGI,
4533};
4534
4528struct els_request64_wqe {4535struct els_request64_wqe {
4529 struct ulp_bde64 bde;4536 struct ulp_bde64 bde;
4530 uint32_t payload_len;4537 uint32_t payload_len;
drivers/scsi/lpfc/lpfc_init.c+131−143
@@ -350,8 +350,7 @@ lpfc_dump_wakeup_param_cmpl(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmboxq) · 349 unmodified lines
350void350void
351lpfc_update_vport_wwn(struct lpfc_vport *vport)351lpfc_update_vport_wwn(struct lpfc_vport *vport)
352{352{
353 uint8_t vvvl = vport->fc_sparam.cmn.valid_vendor_ver_level;353 struct lpfc_hba *phba = vport->phba;
354 u32 *fawwpn_key = (u32 *)&vport->fc_sparam.un.vendorVersion[0];
355 354
356 /*355 /*
357 * If the name is empty or there exists a soft name356 * If the name is empty or there exists a soft name
@@ -370,21 +369,32 @@ lpfc_update_vport_wwn(struct lpfc_vport *vport) · 12 unmodified lines
370 */369 */
371 if (vport->fc_portname.u.wwn[0] != 0 &&370 if (vport->fc_portname.u.wwn[0] != 0 &&
372 memcmp(&vport->fc_portname, &vport->fc_sparam.portName,371 memcmp(&vport->fc_portname, &vport->fc_sparam.portName,
373 sizeof(struct lpfc_name)))372 sizeof(struct lpfc_name))) {
374 vport->vport_flag |= FAWWPN_PARAM_CHG;373 vport->vport_flag |= FAWWPN_PARAM_CHG;
375 374
376 if (vport->fc_portname.u.wwn[0] == 0 ||375 if (phba->sli_rev == LPFC_SLI_REV4 &&
377 (vvvl == 1 && cpu_to_be32(*fawwpn_key) == FAPWWN_KEY_VENDOR) ||376 vport->port_type == LPFC_PHYSICAL_PORT &&
378 vport->vport_flag & FAWWPN_SET) {377 phba->sli4_hba.fawwpn_flag & LPFC_FAWWPN_FABRIC) {
379 memcpy(&vport->fc_portname, &vport->fc_sparam.portName,378 lpfc_printf_log(phba, KERN_INFO,
380 sizeof(struct lpfc_name));379 LOG_SLI | LOG_DISCOVERY | LOG_ELS,
381 vport->vport_flag &= ~FAWWPN_SET;380 "2701 FA-PWWN change WWPN from %llx to "
382 if (vvvl == 1 && cpu_to_be32(*fawwpn_key) == FAPWWN_KEY_VENDOR)381 "%llx: vflag x%x fawwpn_flag x%x\n",
383 vport->vport_flag |= FAWWPN_SET;382 wwn_to_u64(vport->fc_portname.u.wwn),
383 wwn_to_u64
384 (vport->fc_sparam.portName.u.wwn),
385 vport->vport_flag,
386 phba->sli4_hba.fawwpn_flag);
387 memcpy(&vport->fc_portname, &vport->fc_sparam.portName,
388 sizeof(struct lpfc_name));
389 }
384 }390 }
391
392 if (vport->fc_portname.u.wwn[0] == 0)
393 memcpy(&vport->fc_portname, &vport->fc_sparam.portName,
394 sizeof(struct lpfc_name));
385 else395 else
386 memcpy(&vport->fc_sparam.portName, &vport->fc_portname,396 memcpy(&vport->fc_sparam.portName, &vport->fc_portname,
387 sizeof(struct lpfc_name));397 sizeof(struct lpfc_name));
388}398}
389 399
390/**400/**
@@ -443,15 +453,16 @@ lpfc_config_port_post(struct lpfc_hba *phba) · 52 unmodified lines
443 "READ_SPARM mbxStatus x%x\n",453 "READ_SPARM mbxStatus x%x\n",
444 mb->mbxCommand, mb->mbxStatus);454 mb->mbxCommand, mb->mbxStatus);
445 phba->link_state = LPFC_HBA_ERROR;455 phba->link_state = LPFC_HBA_ERROR;
446 mp = (struct lpfc_dmabuf *)pmb->ctx_buf;456 lpfc_mbox_rsrc_cleanup(phba, pmb, MBOX_THD_UNLOCKED);
447 mempool_free(pmb, phba->mbox_mem_pool);
448 lpfc_mbuf_free(phba, mp->virt, mp->phys);
449 kfree(mp);
450 return -EIO;457 return -EIO;
451 }458 }
452 459
453 mp = (struct lpfc_dmabuf *)pmb->ctx_buf;460 mp = (struct lpfc_dmabuf *)pmb->ctx_buf;
454 461
462 /* This dmabuf was allocated by lpfc_read_sparam. The dmabuf is no
463 * longer needed. Prevent unintended ctx_buf access as the mbox is
464 * reused.
465 */
455 memcpy(&vport->fc_sparam, mp->virt, sizeof (struct serv_parm));466 memcpy(&vport->fc_sparam, mp->virt, sizeof (struct serv_parm));
456 lpfc_mbuf_free(phba, mp->virt, mp->phys);467 lpfc_mbuf_free(phba, mp->virt, mp->phys);
457 kfree(mp);468 kfree(mp);
@@ -686,8 +697,14 @@ lpfc_sli4_refresh_params(struct lpfc_hba *phba) · 228 unmodified lines
686 return rc;697 return rc;
687 }698 }
688 mbx_sli4_parameters = &mqe->un.get_sli4_parameters.sli4_parameters;699 mbx_sli4_parameters = &mqe->un.get_sli4_parameters.sli4_parameters;
689 phba->sli4_hba.pc_sli4_params.mi_ver =700
701 /* Are we forcing MI off via module parameter? */
702 if (phba->cfg_enable_mi)
703 phba->sli4_hba.pc_sli4_params.mi_ver =
690 bf_get(cfg_mi_ver, mbx_sli4_parameters);704 bf_get(cfg_mi_ver, mbx_sli4_parameters);
705 else
706 phba->sli4_hba.pc_sli4_params.mi_ver = 0;
707
691 phba->sli4_hba.pc_sli4_params.cmf =708 phba->sli4_hba.pc_sli4_params.cmf =
692 bf_get(cfg_cmf, mbx_sli4_parameters);709 bf_get(cfg_cmf, mbx_sli4_parameters);
693 phba->sli4_hba.pc_sli4_params.pls =710 phba->sli4_hba.pc_sli4_params.pls =
@@ -2176,7 +2193,6 @@ lpfc_handle_latt(struct lpfc_hba *phba) · 1482 unmodified lines
2176 struct lpfc_sli *psli = &phba->sli;2193 struct lpfc_sli *psli = &phba->sli;
2177 LPFC_MBOXQ_t *pmb;2194 LPFC_MBOXQ_t *pmb;
2178 volatile uint32_t control;2195 volatile uint32_t control;
2179 struct lpfc_dmabuf *mp;
2180 int rc = 0;2196 int rc = 0;
2181 2197
2182 pmb = (LPFC_MBOXQ_t *)mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);2198 pmb = (LPFC_MBOXQ_t *)mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
@@ -2185,23 +2201,17 @@ lpfc_handle_latt(struct lpfc_hba *phba) · 2 unmodified lines
2185 goto lpfc_handle_latt_err_exit;2201 goto lpfc_handle_latt_err_exit;
2186 }2202 }
2187 2203
2188 mp = kmalloc(sizeof(struct lpfc_dmabuf), GFP_KERNEL);2204 rc = lpfc_mbox_rsrc_prep(phba, pmb);
2189 if (!mp) {2205 if (rc) {
2190 rc = 2;2206 rc = 2;
2191 goto lpfc_handle_latt_free_pmb;2207 mempool_free(pmb, phba->mbox_mem_pool);
2192 }2208 goto lpfc_handle_latt_err_exit;
2193
2194 mp->virt = lpfc_mbuf_alloc(phba, 0, &mp->phys);
2195 if (!mp->virt) {
2196 rc = 3;
2197 goto lpfc_handle_latt_free_mp;
2198 }2209 }
2199 2210
2200 /* Cleanup any outstanding ELS commands */2211 /* Cleanup any outstanding ELS commands */
2201 lpfc_els_flush_all_cmd(phba);2212 lpfc_els_flush_all_cmd(phba);
2202
2203 psli->slistat.link_event++;2213 psli->slistat.link_event++;
2204 lpfc_read_topology(phba, pmb, mp);2214 lpfc_read_topology(phba, pmb, (struct lpfc_dmabuf *)pmb->ctx_buf);
2205 pmb->mbox_cmpl = lpfc_mbx_cmpl_read_topology;2215 pmb->mbox_cmpl = lpfc_mbx_cmpl_read_topology;
2206 pmb->vport = vport;2216 pmb->vport = vport;
2207 /* Block ELS IOCBs until we have processed this mbox command */2217 /* Block ELS IOCBs until we have processed this mbox command */
@@ -2222,11 +2232,7 @@ lpfc_handle_latt(struct lpfc_hba *phba) · 14 unmodified lines
2222 2232
2223lpfc_handle_latt_free_mbuf:2233lpfc_handle_latt_free_mbuf:
2224 phba->sli.sli3_ring[LPFC_ELS_RING].flag &= ~LPFC_STOP_IOCB_EVENT;2234 phba->sli.sli3_ring[LPFC_ELS_RING].flag &= ~LPFC_STOP_IOCB_EVENT;
2225 lpfc_mbuf_free(phba, mp->virt, mp->phys);2235 lpfc_mbox_rsrc_cleanup(phba, pmb, MBOX_THD_UNLOCKED);
2226lpfc_handle_latt_free_mp:
2227 kfree(mp);
2228lpfc_handle_latt_free_pmb:
2229 mempool_free(pmb, phba->mbox_mem_pool);
2230lpfc_handle_latt_err_exit:2236lpfc_handle_latt_err_exit:
2231 /* Enable Link attention interrupts */2237 /* Enable Link attention interrupts */
2232 spin_lock_irq(&phba->hbalock);2238 spin_lock_irq(&phba->hbalock);
@@ -4317,9 +4323,10 @@ lpfc_sli4_io_sgl_update(struct lpfc_hba *phba) · 2084 unmodified lines
4317 4323
4318 lpfc_printf_log(phba, KERN_INFO, LOG_SLI,4324 lpfc_printf_log(phba, KERN_INFO, LOG_SLI,
4319 "6074 Current allocated XRI sgl count:%d, "4325 "6074 Current allocated XRI sgl count:%d, "
4320 "maximum XRI count:%d\n",4326 "maximum XRI count:%d els_xri_cnt:%d\n\n",
4321 phba->sli4_hba.io_xri_cnt,4327 phba->sli4_hba.io_xri_cnt,
4322 phba->sli4_hba.io_xri_max);4328 phba->sli4_hba.io_xri_max,
4329 els_xri_cnt);
4323 4330
4324 cnt = lpfc_io_buf_flush(phba, &io_sgl_list);4331 cnt = lpfc_io_buf_flush(phba, &io_sgl_list);
4325 4332
@@ -4458,12 +4465,11 @@ lpfc_new_io_buf(struct lpfc_hba *phba, int num_to_alloc) · 132 unmodified lines
4458 }4465 }
4459 pwqeq->sli4_lxritag = lxri;4466 pwqeq->sli4_lxritag = lxri;
4460 pwqeq->sli4_xritag = phba->sli4_hba.xri_ids[lxri];4467 pwqeq->sli4_xritag = phba->sli4_hba.xri_ids[lxri];
4461 pwqeq->context1 = lpfc_ncmd;
4462 4468
4463 /* Initialize local short-hand pointers. */4469 /* Initialize local short-hand pointers. */
4464 lpfc_ncmd->dma_sgl = lpfc_ncmd->data;4470 lpfc_ncmd->dma_sgl = lpfc_ncmd->data;
4465 lpfc_ncmd->dma_phys_sgl = lpfc_ncmd->dma_handle;4471 lpfc_ncmd->dma_phys_sgl = lpfc_ncmd->dma_handle;
4466 lpfc_ncmd->cur_iocbq.context1 = lpfc_ncmd;4472 lpfc_ncmd->cur_iocbq.io_buf = lpfc_ncmd;
4467 spin_lock_init(&lpfc_ncmd->buf_lock);4473 spin_lock_init(&lpfc_ncmd->buf_lock);
4468 4474
4469 /* add the nvme buffer to a post list */4475 /* add the nvme buffer to a post list */
@@ -4472,7 +4478,9 @@ lpfc_new_io_buf(struct lpfc_hba *phba, int num_to_alloc) · 2 unmodified lines
4472 }4478 }
4473 lpfc_printf_log(phba, KERN_INFO, LOG_NVME,4479 lpfc_printf_log(phba, KERN_INFO, LOG_NVME,
4474 "6114 Allocate %d out of %d requested new NVME "4480 "6114 Allocate %d out of %d requested new NVME "
4475 "buffers\n", bcnt, num_to_alloc);4481 "buffers of size x%zu bytes\n", bcnt, num_to_alloc,
4482 sizeof(*lpfc_ncmd));
4483
4476 4484
4477 /* post the list of nvme buffer sgls to port if available */4485 /* post the list of nvme buffer sgls to port if available */
4478 if (!list_empty(&post_nblist))4486 if (!list_empty(&post_nblist))
@@ -5307,7 +5315,6 @@ static void · 828 unmodified lines
5307lpfc_sli4_async_link_evt(struct lpfc_hba *phba,5315lpfc_sli4_async_link_evt(struct lpfc_hba *phba,
5308 struct lpfc_acqe_link *acqe_link)5316 struct lpfc_acqe_link *acqe_link)
5309{5317{
5310 struct lpfc_dmabuf *mp;
5311 LPFC_MBOXQ_t *pmb;5318 LPFC_MBOXQ_t *pmb;
5312 MAILBOX_t *mb;5319 MAILBOX_t *mb;
5313 struct lpfc_mbx_read_top *la;5320 struct lpfc_mbx_read_top *la;
@@ -5324,18 +5331,13 @@ lpfc_sli4_async_link_evt(struct lpfc_hba *phba, · 10 unmodified lines
5324 "0395 The mboxq allocation failed\n");5331 "0395 The mboxq allocation failed\n");
5325 return;5332 return;
5326 }5333 }
5327 mp = kmalloc(sizeof(struct lpfc_dmabuf), GFP_KERNEL);5334
5328 if (!mp) {5335 rc = lpfc_mbox_rsrc_prep(phba, pmb);
5336 if (rc) {
5329 lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT,5337 lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT,
5330 "0396 The lpfc_dmabuf allocation failed\n");5338 "0396 mailbox allocation failed\n");
5331 goto out_free_pmb;5339 goto out_free_pmb;
5332 }5340 }
5333 mp->virt = lpfc_mbuf_alloc(phba, 0, &mp->phys);
5334 if (!mp->virt) {
5335 lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT,
5336 "0397 The mbuf allocation failed\n");
5337 goto out_free_dmabuf;
5338 }
5339 5341
5340 /* Cleanup any outstanding ELS commands */5342 /* Cleanup any outstanding ELS commands */
5341 lpfc_els_flush_all_cmd(phba);5343 lpfc_els_flush_all_cmd(phba);
@@ -5347,7 +5349,7 @@ lpfc_sli4_async_link_evt(struct lpfc_hba *phba, · 5 unmodified lines
5347 phba->sli.slistat.link_event++;5349 phba->sli.slistat.link_event++;
5348 5350
5349 /* Create lpfc_handle_latt mailbox command from link ACQE */5351 /* Create lpfc_handle_latt mailbox command from link ACQE */
5350 lpfc_read_topology(phba, pmb, mp);5352 lpfc_read_topology(phba, pmb, (struct lpfc_dmabuf *)pmb->ctx_buf);
5351 pmb->mbox_cmpl = lpfc_mbx_cmpl_read_topology;5353 pmb->mbox_cmpl = lpfc_mbx_cmpl_read_topology;
5352 pmb->vport = phba->pport;5354 pmb->vport = phba->pport;
5353 5355
@@ -5385,10 +5387,8 @@ lpfc_sli4_async_link_evt(struct lpfc_hba *phba, · 31 unmodified lines
5385 */5387 */
5386 if (!(phba->hba_flag & HBA_FCOE_MODE)) {5388 if (!(phba->hba_flag & HBA_FCOE_MODE)) {
5387 rc = lpfc_sli_issue_mbox(phba, pmb, MBX_NOWAIT);5389 rc = lpfc_sli_issue_mbox(phba, pmb, MBX_NOWAIT);
5388 if (rc == MBX_NOT_FINISHED) {5390 if (rc == MBX_NOT_FINISHED)
5389 lpfc_mbuf_free(phba, mp->virt, mp->phys);5391 goto out_free_pmb;
5390 goto out_free_dmabuf;
5391 }
5392 return;5392 return;
5393 }5393 }
5394 /*5394 /*
@@ -5423,10 +5423,8 @@ lpfc_sli4_async_link_evt(struct lpfc_hba *phba, · 28 unmodified lines
5423 5423
5424 return;5424 return;
5425 5425
5426out_free_dmabuf:
5427 kfree(mp);
5428out_free_pmb:5426out_free_pmb:
5429 mempool_free(pmb, phba->mbox_mem_pool);5427 lpfc_mbox_rsrc_cleanup(phba, pmb, MBOX_THD_UNLOCKED);
5430}5428}
5431 5429
5432/**5430/**
@@ -5533,7 +5531,7 @@ lpfc_cgn_update_stat(struct lpfc_hba *phba, uint32_t dtag) · 100 unmodified lines
5533 struct tm broken;5531 struct tm broken;
5534 struct timespec64 cur_time;5532 struct timespec64 cur_time;
5535 u32 cnt;5533 u32 cnt;
5536 u16 value;5534 u32 value;
5537 5535
5538 /* Make sure we have a congestion info buffer */5536 /* Make sure we have a congestion info buffer */
5539 if (!phba->cgn_i)5537 if (!phba->cgn_i)
@@ -5866,21 +5864,8 @@ lpfc_cgn_save_evt_cnt(struct lpfc_hba *phba) · 326 unmodified lines
5866 5864
5867 /* Use the frequency found in the last rcv'ed FPIN */5865 /* Use the frequency found in the last rcv'ed FPIN */
5868 value = phba->cgn_fpin_frequency;5866 value = phba->cgn_fpin_frequency;
5869 if (phba->cgn_reg_fpin & LPFC_CGN_FPIN_WARN)5867 cp->cgn_warn_freq = cpu_to_le16(value);
5870 cp->cgn_warn_freq = cpu_to_le16(value);5868 cp->cgn_alarm_freq = cpu_to_le16(value);
5871 if (phba->cgn_reg_fpin & LPFC_CGN_FPIN_ALARM)
5872 cp->cgn_alarm_freq = cpu_to_le16(value);
5873
5874 /* Frequency (in ms) Signal Warning/Signal Congestion Notifications
5875 * are received by the HBA
5876 */
5877 value = phba->cgn_sig_freq;
5878
5879 if (phba->cgn_reg_signal == EDC_CG_SIG_WARN_ONLY ||
5880 phba->cgn_reg_signal == EDC_CG_SIG_WARN_ALARM)
5881 cp->cgn_warn_freq = cpu_to_le16(value);
5882 if (phba->cgn_reg_signal == EDC_CG_SIG_WARN_ALARM)
5883 cp->cgn_alarm_freq = cpu_to_le16(value);
5884 5869
5885 lvalue = lpfc_cgn_calc_crc32(cp, LPFC_CGN_INFO_SZ,5870 lvalue = lpfc_cgn_calc_crc32(cp, LPFC_CGN_INFO_SZ,
5886 LPFC_CGN_CRC32_SEED);5871 LPFC_CGN_CRC32_SEED);
@@ -6237,7 +6222,6 @@ lpfc_update_trunk_link_status(struct lpfc_hba *phba, · 350 unmodified lines
6237static void6222static void
6238lpfc_sli4_async_fc_evt(struct lpfc_hba *phba, struct lpfc_acqe_fc_la *acqe_fc)6223lpfc_sli4_async_fc_evt(struct lpfc_hba *phba, struct lpfc_acqe_fc_la *acqe_fc)
6239{6224{
6240 struct lpfc_dmabuf *mp;
6241 LPFC_MBOXQ_t *pmb;6225 LPFC_MBOXQ_t *pmb;
6242 MAILBOX_t *mb;6226 MAILBOX_t *mb;
6243 struct lpfc_mbx_read_top *la;6227 struct lpfc_mbx_read_top *la;
@@ -6297,18 +6281,12 @@ lpfc_sli4_async_fc_evt(struct lpfc_hba *phba, struct lpfc_acqe_fc_la *acqe_fc) · 53 unmodified lines
6297 "2897 The mboxq allocation failed\n");6281 "2897 The mboxq allocation failed\n");
6298 return;6282 return;
6299 }6283 }
6300 mp = kmalloc(sizeof(struct lpfc_dmabuf), GFP_KERNEL);6284 rc = lpfc_mbox_rsrc_prep(phba, pmb);
6301 if (!mp) {6285 if (rc) {
6302 lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT,6286 lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT,
6303 "2898 The lpfc_dmabuf allocation failed\n");6287 "2898 The mboxq prep failed\n");
6304 goto out_free_pmb;6288 goto out_free_pmb;
6305 }6289 }
6306 mp->virt = lpfc_mbuf_alloc(phba, 0, &mp->phys);
6307 if (!mp->virt) {
6308 lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT,
6309 "2899 The mbuf allocation failed\n");
6310 goto out_free_dmabuf;
6311 }
6312 6290
6313 /* Cleanup any outstanding ELS commands */6291 /* Cleanup any outstanding ELS commands */
6314 lpfc_els_flush_all_cmd(phba);6292 lpfc_els_flush_all_cmd(phba);
@@ -6320,7 +6298,7 @@ lpfc_sli4_async_fc_evt(struct lpfc_hba *phba, struct lpfc_acqe_fc_la *acqe_fc) · 5 unmodified lines
6320 phba->sli.slistat.link_event++;6298 phba->sli.slistat.link_event++;
6321 6299
6322 /* Create lpfc_handle_latt mailbox command from link ACQE */6300 /* Create lpfc_handle_latt mailbox command from link ACQE */
6323 lpfc_read_topology(phba, pmb, mp);6301 lpfc_read_topology(phba, pmb, (struct lpfc_dmabuf *)pmb->ctx_buf);
6324 pmb->mbox_cmpl = lpfc_mbx_cmpl_read_topology;6302 pmb->mbox_cmpl = lpfc_mbx_cmpl_read_topology;
6325 pmb->vport = phba->pport;6303 pmb->vport = phba->pport;
6326 6304
@@ -6364,16 +6342,12 @@ lpfc_sli4_async_fc_evt(struct lpfc_hba *phba, struct lpfc_acqe_fc_la *acqe_fc) · 37 unmodified lines
6364 }6342 }
6365 6343
6366 rc = lpfc_sli_issue_mbox(phba, pmb, MBX_NOWAIT);6344 rc = lpfc_sli_issue_mbox(phba, pmb, MBX_NOWAIT);
6367 if (rc == MBX_NOT_FINISHED) {6345 if (rc == MBX_NOT_FINISHED)
6368 lpfc_mbuf_free(phba, mp->virt, mp->phys);6346 goto out_free_pmb;
6369 goto out_free_dmabuf;
6370 }
6371 return;6347 return;
6372 6348
6373out_free_dmabuf:
6374 kfree(mp);
6375out_free_pmb:6349out_free_pmb:
6376 mempool_free(pmb, phba->mbox_mem_pool);6350 lpfc_mbox_rsrc_cleanup(phba, pmb, MBOX_THD_UNLOCKED);
6377}6351}
6378 6352
6379/**6353/**
@@ -6565,12 +6539,15 @@ lpfc_sli4_async_sli_evt(struct lpfc_hba *phba, struct lpfc_acqe_sli *acqe_sli) · 185 unmodified lines
6565 case LPFC_SLI_EVENT_TYPE_MISCONF_FAWWN:6539 case LPFC_SLI_EVENT_TYPE_MISCONF_FAWWN:
6566 /* Misconfigured WWN. Reports that the SLI Port is configured6540 /* Misconfigured WWN. Reports that the SLI Port is configured
6567 * to use FA-WWN, but the attached device doesn’t support it.6541 * to use FA-WWN, but the attached device doesn’t support it.
6568 * No driver action is required.
6569 * Event Data1 - N.A, Event Data2 - N.A6542 * Event Data1 - N.A, Event Data2 - N.A
6543 * This event only happens on the physical port.
6570 */6544 */
6571 lpfc_log_msg(phba, KERN_WARNING, LOG_SLI,6545 lpfc_log_msg(phba, KERN_WARNING, LOG_SLI | LOG_DISCOVERY,
6572 "2699 Misconfigured FA-WWN - Attached device does "6546 "2699 Misconfigured FA-PWWN - Attached device "
6573 "not support FA-WWN\n");6547 "does not support FA-PWWN\n");
6548 phba->sli4_hba.fawwpn_flag &= ~LPFC_FAWWPN_FABRIC;
6549 memset(phba->pport->fc_portname.u.wwn, 0,
6550 sizeof(struct lpfc_name));
6574 break;6551 break;
6575 case LPFC_SLI_EVENT_TYPE_EEPROM_FAILURE:6552 case LPFC_SLI_EVENT_TYPE_EEPROM_FAILURE:
6576 /* EEPROM failure. No driver action is required */6553 /* EEPROM failure. No driver action is required */
@@ -6595,9 +6572,6 @@ lpfc_sli4_async_sli_evt(struct lpfc_hba *phba, struct lpfc_acqe_sli *acqe_sli) · 18 unmodified lines
6595 /* Alarm overrides warning, so check that first */6572 /* Alarm overrides warning, so check that first */
6596 if (cgn_signal->alarm_cnt) {6573 if (cgn_signal->alarm_cnt) {
6597 if (phba->cgn_reg_signal == EDC_CG_SIG_WARN_ALARM) {6574 if (phba->cgn_reg_signal == EDC_CG_SIG_WARN_ALARM) {
6598 /* Keep track of alarm cnt for cgn_info */
6599 atomic_add(cgn_signal->alarm_cnt,
6600 &phba->cgn_fabric_alarm_cnt);
6601 /* Keep track of alarm cnt for CMF_SYNC_WQE */6575 /* Keep track of alarm cnt for CMF_SYNC_WQE */
6602 atomic_add(cgn_signal->alarm_cnt,6576 atomic_add(cgn_signal->alarm_cnt,
6603 &phba->cgn_sync_alarm_cnt);6577 &phba->cgn_sync_alarm_cnt);
@@ -6606,8 +6580,6 @@ lpfc_sli4_async_sli_evt(struct lpfc_hba *phba, struct lpfc_acqe_sli *acqe_sli) · 2 unmodified lines
6606 /* signal action needs to be taken */6580 /* signal action needs to be taken */
6607 if (phba->cgn_reg_signal == EDC_CG_SIG_WARN_ONLY ||6581 if (phba->cgn_reg_signal == EDC_CG_SIG_WARN_ONLY ||
6608 phba->cgn_reg_signal == EDC_CG_SIG_WARN_ALARM) {6582 phba->cgn_reg_signal == EDC_CG_SIG_WARN_ALARM) {
6609 /* Keep track of warning cnt for cgn_info */
6610 atomic_add(cnt, &phba->cgn_fabric_warn_cnt);
6611 /* Keep track of warning cnt for CMF_SYNC_WQE */6583 /* Keep track of warning cnt for CMF_SYNC_WQE */
6612 atomic_add(cnt, &phba->cgn_sync_warn_cnt);6584 atomic_add(cnt, &phba->cgn_sync_warn_cnt);
6613 }6585 }
@@ -8027,6 +7999,18 @@ lpfc_sli4_driver_resource_setup(struct lpfc_hba *phba) · 1413 unmodified lines
8027 rc = lpfc_sli4_read_config(phba);7999 rc = lpfc_sli4_read_config(phba);
8028 if (unlikely(rc))8000 if (unlikely(rc))
8029 goto out_free_bsmbx;8001 goto out_free_bsmbx;
8002
8003 if (phba->sli4_hba.fawwpn_flag & LPFC_FAWWPN_CONFIG) {
8004 /* Right now the link is down, if FA-PWWN is configured the
8005 * firmware will try FLOGI before the driver gets a link up.
8006 * If it fails, the driver should get a MISCONFIGURED async
8007 * event which will clear this flag. The only notification
8008 * the driver gets is if it fails, if it succeeds there is no
8009 * notification given. Assume success.
8010 */
8011 phba->sli4_hba.fawwpn_flag |= LPFC_FAWWPN_FABRIC;
8012 }
8013
8030 rc = lpfc_mem_alloc_active_rrq_pool_s4(phba);8014 rc = lpfc_mem_alloc_active_rrq_pool_s4(phba);
8031 if (unlikely(rc))8015 if (unlikely(rc))
8032 goto out_free_bsmbx;8016 goto out_free_bsmbx;
@@ -9000,6 +8984,36 @@ lpfc_hba_free(struct lpfc_hba *phba) · 967 unmodified lines
9000 return;8984 return;
9001}8985}
9002 8986
8987/**
8988 * lpfc_setup_fdmi_mask - Setup initial FDMI mask for HBA and Port attributes
8989 * @vport: pointer to lpfc vport data structure.
8990 *
8991 * This routine is will setup initial FDMI attribute masks for
8992 * FDMI2 or SmartSAN depending on module parameters. The driver will attempt
8993 * to get these attributes first before falling back, the attribute
8994 * fallback hierarchy is SmartSAN -> FDMI2 -> FMDI1
8995 **/
8996void
8997lpfc_setup_fdmi_mask(struct lpfc_vport *vport)
8998{
8999 struct lpfc_hba *phba = vport->phba;
9000
9001 vport->load_flag |= FC_ALLOW_FDMI;
9002 if (phba->cfg_enable_SmartSAN ||
9003 phba->cfg_fdmi_on == LPFC_FDMI_SUPPORT) {
9004 /* Setup appropriate attribute masks */
9005 vport->fdmi_hba_mask = LPFC_FDMI2_HBA_ATTR;
9006 if (phba->cfg_enable_SmartSAN)
9007 vport->fdmi_port_mask = LPFC_FDMI2_SMART_ATTR;
9008 else
9009 vport->fdmi_port_mask = LPFC_FDMI2_PORT_ATTR;
9010 }
9011
9012 lpfc_printf_log(phba, KERN_INFO, LOG_DISCOVERY,
9013 "6077 Setup FDMI mask: hba x%x port x%x\n",
9014 vport->fdmi_hba_mask, vport->fdmi_port_mask);
9015}
9016
9003/**9017/**
9004 * lpfc_create_shost - Create hba physical port with associated scsi host.9018 * lpfc_create_shost - Create hba physical port with associated scsi host.
9005 * @phba: pointer to lpfc hba data structure.9019 * @phba: pointer to lpfc hba data structure.
@@ -9043,21 +9057,12 @@ lpfc_create_shost(struct lpfc_hba *phba) · 37 unmodified lines
9043 /* Put reference to SCSI host to driver's device private data */9057 /* Put reference to SCSI host to driver's device private data */
9044 pci_set_drvdata(phba->pcidev, shost);9058 pci_set_drvdata(phba->pcidev, shost);
9045 9059
9060 lpfc_setup_fdmi_mask(vport);
9061
9046 /*9062 /*
9047 * At this point we are fully registered with PSA. In addition,9063 * At this point we are fully registered with PSA. In addition,
9048 * any initial discovery should be completed.9064 * any initial discovery should be completed.
9049 */9065 */
9050 vport->load_flag |= FC_ALLOW_FDMI;
9051 if (phba->cfg_enable_SmartSAN ||
9052 (phba->cfg_fdmi_on == LPFC_FDMI_SUPPORT)) {
9053
9054 /* Setup appropriate attribute masks */
9055 vport->fdmi_hba_mask = LPFC_FDMI2_HBA_ATTR;
9056 if (phba->cfg_enable_SmartSAN)
9057 vport->fdmi_port_mask = LPFC_FDMI2_SMART_ATTR;
9058 else
9059 vport->fdmi_port_mask = LPFC_FDMI2_PORT_ATTR;
9060 }
9061 return 0;9066 return 0;
9062}9067}
9063 9068
@@ -9830,7 +9835,7 @@ lpfc_sli4_read_config(struct lpfc_hba *phba) · 766 unmodified lines
9830 struct lpfc_rsrc_desc_fcfcoe *desc;9835 struct lpfc_rsrc_desc_fcfcoe *desc;
9831 char *pdesc_0;9836 char *pdesc_0;
9832 uint16_t forced_link_speed;9837 uint16_t forced_link_speed;
9833 uint32_t if_type, qmin;9838 uint32_t if_type, qmin, fawwpn;
9834 int length, i, rc = 0, rc2;9839 int length, i, rc = 0, rc2;
9835 9840
9836 pmb = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);9841 pmb = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
@@ -9872,10 +9877,23 @@ lpfc_sli4_read_config(struct lpfc_hba *phba) · 35 unmodified lines
9872 phba->sli4_hba.bbscn_params.word0 = rd_config->word8;9877 phba->sli4_hba.bbscn_params.word0 = rd_config->word8;
9873 }9878 }
9874 9879
9880 fawwpn = bf_get(lpfc_mbx_rd_conf_fawwpn, rd_config);
9881
9882 if (fawwpn) {
9883 lpfc_printf_log(phba, KERN_INFO,
9884 LOG_INIT | LOG_DISCOVERY,
9885 "2702 READ_CONFIG: FA-PWWN is "
9886 "configured on\n");
9887 phba->sli4_hba.fawwpn_flag |= LPFC_FAWWPN_CONFIG;
9888 } else {
9889 phba->sli4_hba.fawwpn_flag = 0;
9890 }
9891
9875 phba->sli4_hba.conf_trunk =9892 phba->sli4_hba.conf_trunk =
9876 bf_get(lpfc_mbx_rd_conf_trunk, rd_config);9893 bf_get(lpfc_mbx_rd_conf_trunk, rd_config);
9877 phba->sli4_hba.extents_in_use =9894 phba->sli4_hba.extents_in_use =
9878 bf_get(lpfc_mbx_rd_conf_extnts_inuse, rd_config);9895 bf_get(lpfc_mbx_rd_conf_extnts_inuse, rd_config);
9896
9879 phba->sli4_hba.max_cfg_param.max_xri =9897 phba->sli4_hba.max_cfg_param.max_xri =
9880 bf_get(lpfc_mbx_rd_conf_xri_count, rd_config);9898 bf_get(lpfc_mbx_rd_conf_xri_count, rd_config);
9881 /* Reduce resource usage in kdump environment */9899 /* Reduce resource usage in kdump environment */
@@ -14832,9 +14850,6 @@ lpfc_pci_probe_one_s4(struct pci_dev *pdev, const struct pci_device_id *pid) · 4950 unmodified lines
14832 /* Check if there are static vports to be created. */14850 /* Check if there are static vports to be created. */
14833 lpfc_create_static_vport(phba);14851 lpfc_create_static_vport(phba);
14834 14852
14835 /* Enable RAS FW log support */
14836 lpfc_sli4_ras_setup(phba);
14837
14838 timer_setup(&phba->cpuhp_poll_timer, lpfc_sli4_poll_hbtimer, 0);14853 timer_setup(&phba->cpuhp_poll_timer, lpfc_sli4_poll_hbtimer, 0);
14839 cpuhp_state_add_instance_nocalls(lpfc_cpuhp_state, &phba->cpuhp);14854 cpuhp_state_add_instance_nocalls(lpfc_cpuhp_state, &phba->cpuhp);
14840 14855
@@ -15700,34 +15715,7 @@ void lpfc_dmp_dbg(struct lpfc_hba *phba) · 859 unmodified lines
15700 unsigned int temp_idx;15715 unsigned int temp_idx;
15701 int i;15716 int i;
15702 int j = 0;15717 int j = 0;
15703 unsigned long rem_nsec, iflags;15718 unsigned long rem_nsec;
15704 bool log_verbose = false;
15705 struct lpfc_vport *port_iterator;
15706
15707 /* Don't dump messages if we explicitly set log_verbose for the
15708 * physical port or any vport.
15709 */
15710 if (phba->cfg_log_verbose)
15711 return;
15712
15713 spin_lock_irqsave(&phba->port_list_lock, iflags);
15714 list_for_each_entry(port_iterator, &phba->port_list, listentry) {
15715 if (port_iterator->load_flag & FC_UNLOADING)
15716 continue;
15717 if (scsi_host_get(lpfc_shost_from_vport(port_iterator))) {
15718 if (port_iterator->cfg_log_verbose)
15719 log_verbose = true;
15720
15721 scsi_host_put(lpfc_shost_from_vport(port_iterator));
15722
15723 if (log_verbose) {
15724 spin_unlock_irqrestore(&phba->port_list_lock,
15725 iflags);
15726 return;
15727 }
15728 }
15729 }
15730 spin_unlock_irqrestore(&phba->port_list_lock, iflags);
15731 15719
15732 if (atomic_cmpxchg(&phba->dbg_log_dmping, 0, 1) != 0)15720 if (atomic_cmpxchg(&phba->dbg_log_dmping, 0, 1) != 0)
15733 return;15721 return;
drivers/scsi/lpfc/lpfc_logmsg.h+4−4
@@ -1,7 +1,7 @@
1/*******************************************************************1/*******************************************************************
2 * This file is part of the Emulex Linux Device Driver for *2 * This file is part of the Emulex Linux Device Driver for *
3 * Fibre Channel Host Bus Adapters. *3 * Fibre Channel Host Bus Adapters. *
4 * Copyright (C) 2017-2021 Broadcom. All Rights Reserved. The term *4 * Copyright (C) 2017-2022 Broadcom. All Rights Reserved. The term *
5 * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. *5 * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. *
6 * Copyright (C) 2004-2009 Emulex. All rights reserved. *6 * Copyright (C) 2004-2009 Emulex. All rights reserved. *
7 * EMULEX and SLI are trademarks of Emulex. *7 * EMULEX and SLI are trademarks of Emulex. *
@@ -73,7 +73,7 @@ do { \ · 65 unmodified lines
73#define lpfc_printf_vlog(vport, level, mask, fmt, arg...) \73#define lpfc_printf_vlog(vport, level, mask, fmt, arg...) \
74do { \74do { \
75 { if (((mask) & (vport)->cfg_log_verbose) || (level[1] <= '3')) { \75 { if (((mask) & (vport)->cfg_log_verbose) || (level[1] <= '3')) { \
76 if ((mask) & LOG_TRACE_EVENT) \76 if ((mask) & LOG_TRACE_EVENT && !(vport)->cfg_log_verbose) \
77 lpfc_dmp_dbg((vport)->phba); \77 lpfc_dmp_dbg((vport)->phba); \
78 dev_printk(level, &((vport)->phba->pcidev)->dev, "%d:(%d):" \78 dev_printk(level, &((vport)->phba->pcidev)->dev, "%d:(%d):" \
79 fmt, (vport)->phba->brd_no, vport->vpi, ##arg); \79 fmt, (vport)->phba->brd_no, vport->vpi, ##arg); \
@@ -89,11 +89,11 @@ do { \ · 9 unmodified lines
89 (phba)->pport->cfg_log_verbose : \89 (phba)->pport->cfg_log_verbose : \
90 (phba)->cfg_log_verbose; \90 (phba)->cfg_log_verbose; \
91 if (((mask) & log_verbose) || (level[1] <= '3')) { \91 if (((mask) & log_verbose) || (level[1] <= '3')) { \
92 if ((mask) & LOG_TRACE_EVENT) \92 if ((mask) & LOG_TRACE_EVENT && !log_verbose) \
93 lpfc_dmp_dbg(phba); \93 lpfc_dmp_dbg(phba); \
94 dev_printk(level, &((phba)->pcidev)->dev, "%d:" \94 dev_printk(level, &((phba)->pcidev)->dev, "%d:" \
95 fmt, phba->brd_no, ##arg); \95 fmt, phba->brd_no, ##arg); \
96 } else if (!(phba)->cfg_log_verbose)\96 } else if (!log_verbose)\
97 lpfc_dbg_print(phba, "%d:" fmt, phba->brd_no, ##arg); \97 lpfc_dbg_print(phba, "%d:" fmt, phba->brd_no, ##arg); \
98 } \98 } \
99} while (0)99} while (0)
drivers/scsi/lpfc/lpfc_mbox.c+120−83
@@ -1,7 +1,7 @@
1/*******************************************************************1/*******************************************************************
2 * This file is part of the Emulex Linux Device Driver for *2 * This file is part of the Emulex Linux Device Driver for *
3 * Fibre Channel Host Bus Adapters. *3 * Fibre Channel Host Bus Adapters. *
4 * Copyright (C) 2017-2021 Broadcom. All Rights Reserved. The term *4 * Copyright (C) 2017-2022 Broadcom. All Rights Reserved. The term *
5 * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. *5 * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. *
6 * Copyright (C) 2004-2016 Emulex. All rights reserved. *6 * Copyright (C) 2004-2016 Emulex. All rights reserved. *
7 * EMULEX and SLI are trademarks of Emulex. *7 * EMULEX and SLI are trademarks of Emulex. *
@@ -43,6 +43,80 @@ · 35 unmodified lines
43#include "lpfc_crtn.h"43#include "lpfc_crtn.h"
44#include "lpfc_compat.h"44#include "lpfc_compat.h"
45 45
46/**
47 * lpfc_mbox_rsrc_prep - Prepare a mailbox with DMA buffer memory.
48 * @phba: pointer to lpfc hba data structure.
49 * @mbox: pointer to the driver internal queue element for mailbox command.
50 *
51 * A mailbox command consists of the pool memory for the command, @mbox, and
52 * one or more DMA buffers for the data transfer. This routine provides
53 * a standard framework for allocating the dma buffer and assigning to the
54 * @mbox. Callers should cleanup the mbox with a call to
55 * lpfc_mbox_rsrc_cleanup.
56 *
57 * The lpfc_mbuf_alloc routine acquires the hbalock so the caller is
58 * responsible to ensure the hbalock is released. Also note that the
59 * driver design is a single dmabuf/mbuf per mbox in the ctx_buf.
60 *
61 **/
62int
63lpfc_mbox_rsrc_prep(struct lpfc_hba *phba, LPFC_MBOXQ_t *mbox)
64{
65 struct lpfc_dmabuf *mp;
66
67 mp = kmalloc(sizeof(*mp), GFP_KERNEL);
68 if (!mp)
69 return -ENOMEM;
70
71 mp->virt = lpfc_mbuf_alloc(phba, 0, &mp->phys);
72 if (!mp->virt) {
73 kfree(mp);
74 return -ENOMEM;
75 }
76
77 memset(mp->virt, 0, LPFC_BPL_SIZE);
78
79 /* Initialization only. Driver does not use a list of dmabufs. */
80 INIT_LIST_HEAD(&mp->list);
81 mbox->ctx_buf = mp;
82 return 0;
83}
84
85/**
86 * lpfc_mbox_rsrc_cleanup - Free the mailbox DMA buffer and virtual memory.
87 * @phba: pointer to lpfc hba data structure.
88 * @mbox: pointer to the driver internal queue element for mailbox command.
89 * @locked: value that indicates if the hbalock is held (1) or not (0).
90 *
91 * A mailbox command consists of the pool memory for the command, @mbox, and
92 * possibly a DMA buffer for the data transfer. This routine provides
93 * a standard framework for releasing any dma buffers and freeing all
94 * memory resources in it as well as releasing the @mbox back to the @phba pool.
95 * Callers should use this routine for cleanup for all mailboxes prepped with
96 * lpfc_mbox_rsrc_prep.
97 *
98 **/
99void
100lpfc_mbox_rsrc_cleanup(struct lpfc_hba *phba, LPFC_MBOXQ_t *mbox,
101 enum lpfc_mbox_ctx locked)
102{
103 struct lpfc_dmabuf *mp;
104
105 mp = (struct lpfc_dmabuf *)mbox->ctx_buf;
106 mbox->ctx_buf = NULL;
107
108 /* Release the generic BPL buffer memory. */
109 if (mp) {
110 if (locked == MBOX_THD_LOCKED)
111 __lpfc_mbuf_free(phba, mp->virt, mp->phys);
112 else
113 lpfc_mbuf_free(phba, mp->virt, mp->phys);
114 kfree(mp);
115 }
116
117 mempool_free(mbox, phba->mbox_mem_pool);
118}
119
46/**120/**
47 * lpfc_dump_static_vport - Dump HBA's static vport information.121 * lpfc_dump_static_vport - Dump HBA's static vport information.
48 * @phba: pointer to lpfc hba data structure.122 * @phba: pointer to lpfc hba data structure.
@@ -61,6 +135,7 @@ lpfc_dump_static_vport(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb, · 12 unmodified lines
61{135{
62 MAILBOX_t *mb;136 MAILBOX_t *mb;
63 struct lpfc_dmabuf *mp;137 struct lpfc_dmabuf *mp;
138 int rc;
64 139
65 mb = &pmb->u.mb;140 mb = &pmb->u.mb;
66 141
@@ -79,22 +154,15 @@ lpfc_dump_static_vport(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb, · 12 unmodified lines
79 return 0;154 return 0;
80 }155 }
81 156
82 /* For SLI4 HBAs driver need to allocate memory */157 rc = lpfc_mbox_rsrc_prep(phba, pmb);
83 mp = kmalloc(sizeof(struct lpfc_dmabuf), GFP_KERNEL);158 if (rc) {
84 if (mp)
85 mp->virt = lpfc_mbuf_alloc(phba, 0, &mp->phys);
86
87 if (!mp || !mp->virt) {
88 kfree(mp);
89 lpfc_printf_log(phba, KERN_ERR, LOG_MBOX,159 lpfc_printf_log(phba, KERN_ERR, LOG_MBOX,
90 "2605 lpfc_dump_static_vport: memory"160 "2605 %s: memory allocation failed\n",
91 " allocation failed\n");161 __func__);
92 return 1;162 return 1;
93 }163 }
94 memset(mp->virt, 0, LPFC_BPL_SIZE);164
95 INIT_LIST_HEAD(&mp->list);165 mp = pmb->ctx_buf;
96 /* save address for completion */
97 pmb->ctx_buf = (uint8_t *)mp;
98 mb->un.varWords[3] = putPaddrLow(mp->phys);166 mb->un.varWords[3] = putPaddrLow(mp->phys);
99 mb->un.varWords[4] = putPaddrHigh(mp->phys);167 mb->un.varWords[4] = putPaddrHigh(mp->phys);
100 mb->un.varDmp.sli4_length = sizeof(struct static_vport_info);168 mb->un.varDmp.sli4_length = sizeof(struct static_vport_info);
@@ -606,26 +674,21 @@ lpfc_read_sparam(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb, int vpi) · 505 unmodified lines
606{674{
607 struct lpfc_dmabuf *mp;675 struct lpfc_dmabuf *mp;
608 MAILBOX_t *mb;676 MAILBOX_t *mb;
677 int rc;
609 678
610 mb = &pmb->u.mb;
611 memset(pmb, 0, sizeof (LPFC_MBOXQ_t));679 memset(pmb, 0, sizeof (LPFC_MBOXQ_t));
612 680
613 mb->mbxOwner = OWN_HOST;
614
615 /* Get a buffer to hold the HBAs Service Parameters */681 /* Get a buffer to hold the HBAs Service Parameters */
616 682 rc = lpfc_mbox_rsrc_prep(phba, pmb);
617 mp = kmalloc(sizeof (struct lpfc_dmabuf), GFP_KERNEL);683 if (rc) {
618 if (mp)
619 mp->virt = lpfc_mbuf_alloc(phba, 0, &mp->phys);
620 if (!mp || !mp->virt) {
621 kfree(mp);
622 mb->mbxCommand = MBX_READ_SPARM64;
623 /* READ_SPARAM: no buffers */
624 lpfc_printf_log(phba, KERN_WARNING, LOG_MBOX,684 lpfc_printf_log(phba, KERN_WARNING, LOG_MBOX,
625 "0301 READ_SPARAM: no buffers\n");685 "0301 READ_SPARAM: no buffers\n");
626 return (1);686 return 1;
627 }687 }
628 INIT_LIST_HEAD(&mp->list);688
689 mp = pmb->ctx_buf;
690 mb = &pmb->u.mb;
691 mb->mbxOwner = OWN_HOST;
629 mb->mbxCommand = MBX_READ_SPARM64;692 mb->mbxCommand = MBX_READ_SPARM64;
630 mb->un.varRdSparm.un.sp64.tus.f.bdeSize = sizeof (struct serv_parm);693 mb->un.varRdSparm.un.sp64.tus.f.bdeSize = sizeof (struct serv_parm);
631 mb->un.varRdSparm.un.sp64.addrHigh = putPaddrHigh(mp->phys);694 mb->un.varRdSparm.un.sp64.addrHigh = putPaddrHigh(mp->phys);
@@ -633,9 +696,6 @@ lpfc_read_sparam(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb, int vpi) · 1 unmodified line
633 if (phba->sli_rev >= LPFC_SLI_REV3)696 if (phba->sli_rev >= LPFC_SLI_REV3)
634 mb->un.varRdSparm.vpi = phba->vpi_ids[vpi];697 mb->un.varRdSparm.vpi = phba->vpi_ids[vpi];
635 698
636 /* save address for completion */
637 pmb->ctx_buf = mp;
638
639 return (0);699 return (0);
640}700}
641 701
@@ -756,6 +816,7 @@ lpfc_reg_rpi(struct lpfc_hba *phba, uint16_t vpi, uint32_t did, · 114 unmodified lines
756 MAILBOX_t *mb = &pmb->u.mb;816 MAILBOX_t *mb = &pmb->u.mb;
757 uint8_t *sparam;817 uint8_t *sparam;
758 struct lpfc_dmabuf *mp;818 struct lpfc_dmabuf *mp;
819 int rc;
759 820
760 memset(pmb, 0, sizeof (LPFC_MBOXQ_t));821 memset(pmb, 0, sizeof (LPFC_MBOXQ_t));
761 822
@@ -766,12 +827,10 @@ lpfc_reg_rpi(struct lpfc_hba *phba, uint16_t vpi, uint32_t did, · 4 unmodified lines
766 mb->un.varRegLogin.vpi = phba->vpi_ids[vpi];827 mb->un.varRegLogin.vpi = phba->vpi_ids[vpi];
767 mb->un.varRegLogin.did = did;828 mb->un.varRegLogin.did = did;
768 mb->mbxOwner = OWN_HOST;829 mb->mbxOwner = OWN_HOST;
830
769 /* Get a buffer to hold NPorts Service Parameters */831 /* Get a buffer to hold NPorts Service Parameters */
770 mp = kmalloc(sizeof (struct lpfc_dmabuf), GFP_KERNEL);832 rc = lpfc_mbox_rsrc_prep(phba, pmb);
771 if (mp)833 if (rc) {
772 mp->virt = lpfc_mbuf_alloc(phba, 0, &mp->phys);
773 if (!mp || !mp->virt) {
774 kfree(mp);
775 mb->mbxCommand = MBX_REG_LOGIN64;834 mb->mbxCommand = MBX_REG_LOGIN64;
776 /* REG_LOGIN: no buffers */835 /* REG_LOGIN: no buffers */
777 lpfc_printf_log(phba, KERN_WARNING, LOG_MBOX,836 lpfc_printf_log(phba, KERN_WARNING, LOG_MBOX,
@@ -779,15 +838,13 @@ lpfc_reg_rpi(struct lpfc_hba *phba, uint16_t vpi, uint32_t did, · 1 unmodified line
779 "rpi x%x\n", vpi, did, rpi);838 "rpi x%x\n", vpi, did, rpi);
780 return 1;839 return 1;
781 }840 }
782 INIT_LIST_HEAD(&mp->list);
783 sparam = mp->virt;
784 841
785 /* Copy param's into a new buffer */842 /* Copy param's into a new buffer */
843 mp = pmb->ctx_buf;
844 sparam = mp->virt;
786 memcpy(sparam, param, sizeof (struct serv_parm));845 memcpy(sparam, param, sizeof (struct serv_parm));
787 846
788 /* save address for completion */847 /* Finish initializing the mailbox. */
789 pmb->ctx_buf = (uint8_t *)mp;
790
791 mb->mbxCommand = MBX_REG_LOGIN64;848 mb->mbxCommand = MBX_REG_LOGIN64;
792 mb->un.varRegLogin.un.sp64.tus.f.bdeSize = sizeof (struct serv_parm);849 mb->un.varRegLogin.un.sp64.tus.f.bdeSize = sizeof (struct serv_parm);
793 mb->un.varRegLogin.un.sp64.addrHigh = putPaddrHigh(mp->phys);850 mb->un.varRegLogin.un.sp64.addrHigh = putPaddrHigh(mp->phys);
@@ -1723,7 +1780,9 @@ lpfc_sli4_mbx_sge_get(struct lpfcMboxq *mbox, uint32_t sgentry, · 929 unmodified lines
1723 * @phba: pointer to lpfc hba data structure.1780 * @phba: pointer to lpfc hba data structure.
1724 * @mbox: pointer to lpfc mbox command.1781 * @mbox: pointer to lpfc mbox command.
1725 *1782 *
1726 * This routine frees SLI4 specific mailbox command for sending IOCTL command.1783 * This routine cleans up and releases an SLI4 mailbox command that was
1784 * configured using lpfc_sli4_config. It accounts for the embedded and
1785 * non-embedded config types.
1727 **/1786 **/
1728void1787void
1729lpfc_sli4_mbox_cmd_free(struct lpfc_hba *phba, struct lpfcMboxq *mbox)1788lpfc_sli4_mbox_cmd_free(struct lpfc_hba *phba, struct lpfcMboxq *mbox)
@@ -2277,33 +2336,24 @@ lpfc_sli4_dump_cfg_rg23(struct lpfc_hba *phba, struct lpfcMboxq *mbox) · 547 unmodified lines
2277{2336{
2278 struct lpfc_dmabuf *mp = NULL;2337 struct lpfc_dmabuf *mp = NULL;
2279 MAILBOX_t *mb;2338 MAILBOX_t *mb;
2339 int rc;
2280 2340
2281 memset(mbox, 0, sizeof(*mbox));2341 memset(mbox, 0, sizeof(*mbox));
2282 mb = &mbox->u.mb;2342 mb = &mbox->u.mb;
2283 2343
2284 mp = kmalloc(sizeof(struct lpfc_dmabuf), GFP_KERNEL);2344 rc = lpfc_mbox_rsrc_prep(phba, mbox);
2285 if (mp)2345 if (rc) {
2286 mp->virt = lpfc_mbuf_alloc(phba, 0, &mp->phys);
2287
2288 if (!mp || !mp->virt) {
2289 kfree(mp);
2290 /* dump config region 23 failed to allocate memory */
2291 lpfc_printf_log(phba, KERN_WARNING, LOG_MBOX,2346 lpfc_printf_log(phba, KERN_WARNING, LOG_MBOX,
2292 "2569 lpfc dump config region 23: memory"2347 "2569 %s: memory allocation failed\n",
2293 " allocation failed\n");2348 __func__);
2294 return 1;2349 return 1;
2295 }2350 }
2296 2351
2297 memset(mp->virt, 0, LPFC_BPL_SIZE);
2298 INIT_LIST_HEAD(&mp->list);
2299
2300 /* save address for completion */
2301 mbox->ctx_buf = (uint8_t *)mp;
2302
2303 mb->mbxCommand = MBX_DUMP_MEMORY;2352 mb->mbxCommand = MBX_DUMP_MEMORY;
2304 mb->un.varDmp.type = DMP_NV_PARAMS;2353 mb->un.varDmp.type = DMP_NV_PARAMS;
2305 mb->un.varDmp.region_id = DMP_REGION_23;2354 mb->un.varDmp.region_id = DMP_REGION_23;
2306 mb->un.varDmp.sli4_length = DMP_RGN23_SIZE;2355 mb->un.varDmp.sli4_length = DMP_RGN23_SIZE;
2356 mp = mbox->ctx_buf;
2307 mb->un.varWords[3] = putPaddrLow(mp->phys);2357 mb->un.varWords[3] = putPaddrLow(mp->phys);
2308 mb->un.varWords[4] = putPaddrHigh(mp->phys);2358 mb->un.varWords[4] = putPaddrHigh(mp->phys);
2309 return 0;2359 return 0;
@@ -2326,7 +2376,7 @@ lpfc_mbx_cmpl_rdp_link_stat(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq) · 16 unmodified lines
2326 rc = SUCCESS;2376 rc = SUCCESS;
2327 2377
2328mbx_failed:2378mbx_failed:
2329 lpfc_sli4_mbox_cmd_free(phba, mboxq);2379 lpfc_mbox_rsrc_cleanup(phba, mboxq, MBOX_THD_UNLOCKED);
2330 rdp_context->cmpl(phba, rdp_context, rc);2380 rdp_context->cmpl(phba, rdp_context, rc);
2331}2381}
2332 2382
@@ -2338,30 +2388,25 @@ lpfc_mbx_cmpl_rdp_page_a2(struct lpfc_hba *phba, LPFC_MBOXQ_t *mbox) · 5 unmodified lines
2338 (struct lpfc_rdp_context *)(mbox->ctx_ndlp);2388 (struct lpfc_rdp_context *)(mbox->ctx_ndlp);
2339 2389
2340 if (bf_get(lpfc_mqe_status, &mbox->u.mqe))2390 if (bf_get(lpfc_mqe_status, &mbox->u.mqe))
2341 goto error_mbuf_free;2391 goto error_mbox_free;
2342 2392
2343 lpfc_sli_bemem_bcopy(mp->virt, &rdp_context->page_a2,2393 lpfc_sli_bemem_bcopy(mp->virt, &rdp_context->page_a2,
2344 DMP_SFF_PAGE_A2_SIZE);2394 DMP_SFF_PAGE_A2_SIZE);
2345 2395
2346 /* We don't need dma buffer for link stat. */
2347 lpfc_mbuf_free(phba, mp->virt, mp->phys);
2348 kfree(mp);
2349
2350 memset(mbox, 0, sizeof(*mbox));
2351 lpfc_read_lnk_stat(phba, mbox);2396 lpfc_read_lnk_stat(phba, mbox);
2352 mbox->vport = rdp_context->ndlp->vport;2397 mbox->vport = rdp_context->ndlp->vport;
2398
2399 /* Save the dma buffer for cleanup in the final completion. */
2400 mbox->ctx_buf = mp;
2353 mbox->mbox_cmpl = lpfc_mbx_cmpl_rdp_link_stat;2401 mbox->mbox_cmpl = lpfc_mbx_cmpl_rdp_link_stat;
2354 mbox->ctx_ndlp = (struct lpfc_rdp_context *)rdp_context;2402 mbox->ctx_ndlp = (struct lpfc_rdp_context *)rdp_context;
2355 if (lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT) == MBX_NOT_FINISHED)2403 if (lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT) == MBX_NOT_FINISHED)
2356 goto error_cmd_free;2404 goto error_mbox_free;
2357 2405
2358 return;2406 return;
2359 2407
2360error_mbuf_free:2408error_mbox_free:
2361 lpfc_mbuf_free(phba, mp->virt, mp->phys);2409 lpfc_mbox_rsrc_cleanup(phba, mbox, MBOX_THD_UNLOCKED);
2362 kfree(mp);
2363error_cmd_free:
2364 lpfc_sli4_mbox_cmd_free(phba, mbox);
2365 rdp_context->cmpl(phba, rdp_context, FAILURE);2410 rdp_context->cmpl(phba, rdp_context, FAILURE);
2366}2411}
2367 2412
@@ -2409,9 +2454,7 @@ lpfc_mbx_cmpl_rdp_page_a0(struct lpfc_hba *phba, LPFC_MBOXQ_t *mbox) · 41 unmodified lines
2409 return;2454 return;
2410 2455
2411error:2456error:
2412 lpfc_mbuf_free(phba, mp->virt, mp->phys);2457 lpfc_mbox_rsrc_cleanup(phba, mbox, MBOX_THD_UNLOCKED);
2413 kfree(mp);
2414 lpfc_sli4_mbox_cmd_free(phba, mbox);
2415 rdp_context->cmpl(phba, rdp_context, FAILURE);2458 rdp_context->cmpl(phba, rdp_context, FAILURE);
2416}2459}
2417 2460
@@ -2427,27 +2470,19 @@ error: · 9 unmodified lines
2427int2470int
2428lpfc_sli4_dump_page_a0(struct lpfc_hba *phba, struct lpfcMboxq *mbox)2471lpfc_sli4_dump_page_a0(struct lpfc_hba *phba, struct lpfcMboxq *mbox)
2429{2472{
2473 int rc;
2430 struct lpfc_dmabuf *mp = NULL;2474 struct lpfc_dmabuf *mp = NULL;
2431 2475
2432 memset(mbox, 0, sizeof(*mbox));2476 memset(mbox, 0, sizeof(*mbox));
2433 2477
2434 mp = kmalloc(sizeof(struct lpfc_dmabuf), GFP_KERNEL);2478 rc = lpfc_mbox_rsrc_prep(phba, mbox);
2435 if (mp)2479 if (rc) {
2436 mp->virt = lpfc_mbuf_alloc(phba, 0, &mp->phys);
2437 if (!mp || !mp->virt) {
2438 kfree(mp);
2439 lpfc_printf_log(phba, KERN_WARNING, LOG_MBOX,2480 lpfc_printf_log(phba, KERN_WARNING, LOG_MBOX,
2440 "3569 dump type 3 page 0xA0 allocation failed\n");2481 "3569 dump type 3 page 0xA0 allocation failed\n");
2441 return 1;2482 return 1;
2442 }2483 }
2443 2484
2444 memset(mp->virt, 0, LPFC_BPL_SIZE);
2445 INIT_LIST_HEAD(&mp->list);
2446
2447 bf_set(lpfc_mqe_command, &mbox->u.mqe, MBX_DUMP_MEMORY);2485 bf_set(lpfc_mqe_command, &mbox->u.mqe, MBX_DUMP_MEMORY);
2448 /* save address for completion */
2449 mbox->ctx_buf = mp;
2450
2451 bf_set(lpfc_mbx_memory_dump_type3_type,2486 bf_set(lpfc_mbx_memory_dump_type3_type,
2452 &mbox->u.mqe.un.mem_dump_type3, DMP_LMSD);2487 &mbox->u.mqe.un.mem_dump_type3, DMP_LMSD);
2453 bf_set(lpfc_mbx_memory_dump_type3_link,2488 bf_set(lpfc_mbx_memory_dump_type3_link,
@@ -2456,6 +2491,8 @@ lpfc_sli4_dump_page_a0(struct lpfc_hba *phba, struct lpfcMboxq *mbox) · 2 unmodified lines
2456 &mbox->u.mqe.un.mem_dump_type3, DMP_PAGE_A0);2491 &mbox->u.mqe.un.mem_dump_type3, DMP_PAGE_A0);
2457 bf_set(lpfc_mbx_memory_dump_type3_length,2492 bf_set(lpfc_mbx_memory_dump_type3_length,
2458 &mbox->u.mqe.un.mem_dump_type3, DMP_SFF_PAGE_A0_SIZE);2493 &mbox->u.mqe.un.mem_dump_type3, DMP_SFF_PAGE_A0_SIZE);
2494
2495 mp = mbox->ctx_buf;
2459 mbox->u.mqe.un.mem_dump_type3.addr_lo = putPaddrLow(mp->phys);2496 mbox->u.mqe.un.mem_dump_type3.addr_lo = putPaddrLow(mp->phys);
2460 mbox->u.mqe.un.mem_dump_type3.addr_hi = putPaddrHigh(mp->phys);2497 mbox->u.mqe.un.mem_dump_type3.addr_hi = putPaddrHigh(mp->phys);
2461 2498
drivers/scsi/lpfc/lpfc_nportdisc.c+38−41
@@ -173,9 +173,9 @@ lpfc_check_elscmpl_iocb(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 172 unmodified lines
173 void *ptr = NULL;173 void *ptr = NULL;
174 u32 ulp_status = get_job_ulpstatus(phba, rspiocb);174 u32 ulp_status = get_job_ulpstatus(phba, rspiocb);
175 175
176 pcmd = (struct lpfc_dmabuf *) cmdiocb->context2;176 pcmd = cmdiocb->cmd_dmabuf;
177 177
178 /* For lpfc_els_abort, context2 could be zero'ed to delay178 /* For lpfc_els_abort, cmd_dmabuf could be zero'ed to delay
179 * freeing associated memory till after ABTS completes.179 * freeing associated memory till after ABTS completes.
180 */180 */
181 if (pcmd) {181 if (pcmd) {
@@ -327,7 +327,6 @@ lpfc_rcv_plogi(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, · 145 unmodified lines
327{327{
328 struct lpfc_hba *phba = vport->phba;328 struct lpfc_hba *phba = vport->phba;
329 struct lpfc_dmabuf *pcmd;329 struct lpfc_dmabuf *pcmd;
330 struct lpfc_dmabuf *mp;
331 uint64_t nlp_portwwn = 0;330 uint64_t nlp_portwwn = 0;
332 uint32_t *lp;331 uint32_t *lp;
333 union lpfc_wqe128 *wqe;332 union lpfc_wqe128 *wqe;
@@ -343,7 +342,7 @@ lpfc_rcv_plogi(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, · 9 unmodified lines
343 u32 remote_did;342 u32 remote_did;
344 343
345 memset(&stat, 0, sizeof (struct ls_rjt));344 memset(&stat, 0, sizeof (struct ls_rjt));
346 pcmd = (struct lpfc_dmabuf *) cmdiocb->context2;345 pcmd = cmdiocb->cmd_dmabuf;
347 lp = (uint32_t *) pcmd->virt;346 lp = (uint32_t *) pcmd->virt;
348 sp = (struct serv_parm *) ((uint8_t *) lp + sizeof (uint32_t));347 sp = (struct serv_parm *) ((uint8_t *) lp + sizeof (uint32_t));
349 if (wwn_to_u64(sp->portName.u.wwn) == 0) {348 if (wwn_to_u64(sp->portName.u.wwn) == 0) {
@@ -514,6 +513,10 @@ lpfc_rcv_plogi(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, · 164 unmodified lines
514 lpfc_config_link(phba, link_mbox);513 lpfc_config_link(phba, link_mbox);
515 link_mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl;514 link_mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl;
516 link_mbox->vport = vport;515 link_mbox->vport = vport;
516
517 /* The default completion handling for CONFIG_LINK
518 * does not require the ndlp so no reference is needed.
519 */
517 link_mbox->ctx_ndlp = ndlp;520 link_mbox->ctx_ndlp = ndlp;
518 521
519 rc = lpfc_sli_issue_mbox(phba, link_mbox, MBX_NOWAIT);522 rc = lpfc_sli_issue_mbox(phba, link_mbox, MBX_NOWAIT);
@@ -592,12 +595,8 @@ lpfc_rcv_plogi(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, · 72 unmodified lines
592 * a default RPI.595 * a default RPI.
593 */596 */
594 if (phba->sli_rev == LPFC_SLI_REV4) {597 if (phba->sli_rev == LPFC_SLI_REV4) {
595 mp = (struct lpfc_dmabuf *)login_mbox->ctx_buf;598 lpfc_mbox_rsrc_cleanup(phba, login_mbox,
596 if (mp) {599 MBOX_THD_UNLOCKED);
597 lpfc_mbuf_free(phba, mp->virt, mp->phys);
598 kfree(mp);
599 }
600 mempool_free(login_mbox, phba->mbox_mem_pool);
601 login_mbox = NULL;600 login_mbox = NULL;
602 } else {601 } else {
603 /* In order to preserve RPIs, we want to cleanup602 /* In order to preserve RPIs, we want to cleanup
@@ -614,9 +613,10 @@ lpfc_rcv_plogi(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, · 10 unmodified lines
614 stat.un.b.lsRjtRsnCode = LSRJT_INVALID_CMD;613 stat.un.b.lsRjtRsnCode = LSRJT_INVALID_CMD;
615 stat.un.b.lsRjtRsnCodeExp = LSEXP_NOTHING_MORE;614 stat.un.b.lsRjtRsnCodeExp = LSEXP_NOTHING_MORE;
616 rc = lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb,615 rc = lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb,
617 ndlp, login_mbox);616 ndlp, login_mbox);
618 if (rc)617 if (rc && login_mbox)
619 mempool_free(login_mbox, phba->mbox_mem_pool);618 lpfc_mbox_rsrc_cleanup(phba, login_mbox,
619 MBOX_THD_UNLOCKED);
620 return 1;620 return 1;
621 }621 }
622 622
@@ -637,6 +637,9 @@ lpfc_rcv_plogi(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, · 14 unmodified lines
637 */637 */
638 login_mbox->mbox_cmpl = lpfc_defer_plogi_acc;638 login_mbox->mbox_cmpl = lpfc_defer_plogi_acc;
639 login_mbox->ctx_ndlp = lpfc_nlp_get(ndlp);639 login_mbox->ctx_ndlp = lpfc_nlp_get(ndlp);
640 if (!login_mbox->ctx_ndlp)
641 goto out;
642
640 login_mbox->context3 = save_iocb; /* For PLOGI ACC */643 login_mbox->context3 = save_iocb; /* For PLOGI ACC */
641 644
642 spin_lock_irq(&ndlp->lock);645 spin_lock_irq(&ndlp->lock);
@@ -645,8 +648,10 @@ lpfc_rcv_plogi(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, · 2 unmodified lines
645 648
646 /* Start the ball rolling by issuing REG_LOGIN here */649 /* Start the ball rolling by issuing REG_LOGIN here */
647 rc = lpfc_sli_issue_mbox(phba, login_mbox, MBX_NOWAIT);650 rc = lpfc_sli_issue_mbox(phba, login_mbox, MBX_NOWAIT);
648 if (rc == MBX_NOT_FINISHED)651 if (rc == MBX_NOT_FINISHED) {
652 lpfc_nlp_put(ndlp);
649 goto out;653 goto out;
654 }
650 lpfc_nlp_set_state(vport, ndlp, NLP_STE_REG_LOGIN_ISSUE);655 lpfc_nlp_set_state(vport, ndlp, NLP_STE_REG_LOGIN_ISSUE);
651 656
652 return 1;657 return 1;
@@ -710,7 +715,7 @@ lpfc_rcv_padisc(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, · 57 unmodified lines
710 uint32_t *lp;715 uint32_t *lp;
711 uint32_t cmd;716 uint32_t cmd;
712 717
713 pcmd = (struct lpfc_dmabuf *) cmdiocb->context2;718 pcmd = cmdiocb->cmd_dmabuf;
714 lp = (uint32_t *) pcmd->virt;719 lp = (uint32_t *) pcmd->virt;
715 720
716 cmd = *lp++;721 cmd = *lp++;
@@ -918,7 +923,7 @@ lpfc_rcv_prli_support_check(struct lpfc_vport *vport, · 201 unmodified lines
918 uint32_t *payload;923 uint32_t *payload;
919 uint32_t cmd;924 uint32_t cmd;
920 925
921 payload = ((struct lpfc_dmabuf *)cmdiocb->context2)->virt;926 payload = cmdiocb->cmd_dmabuf->virt;
922 cmd = *payload;927 cmd = *payload;
923 if (vport->phba->nvmet_support) {928 if (vport->phba->nvmet_support) {
924 /* Must be a NVME PRLI */929 /* Must be a NVME PRLI */
@@ -955,9 +960,9 @@ lpfc_rcv_prli(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, · 30 unmodified lines
955 struct fc_rport *rport = ndlp->rport;960 struct fc_rport *rport = ndlp->rport;
956 u32 roles;961 u32 roles;
957 962
958 pcmd = (struct lpfc_dmabuf *) cmdiocb->context2;963 pcmd = cmdiocb->cmd_dmabuf;
959 lp = (uint32_t *) pcmd->virt;964 lp = (uint32_t *)pcmd->virt;
960 npr = (PRLI *) ((uint8_t *) lp + sizeof (uint32_t));965 npr = (PRLI *)((uint8_t *)lp + sizeof(uint32_t));
961 966
962 if ((npr->prliType == PRLI_FCP_TYPE) ||967 if ((npr->prliType == PRLI_FCP_TYPE) ||
963 (npr->prliType == PRLI_NVME_TYPE)) {968 (npr->prliType == PRLI_NVME_TYPE)) {
@@ -1103,8 +1108,10 @@ lpfc_release_rpi(struct lpfc_hba *phba, struct lpfc_vport *vport, · 139 unmodified lines
1103 ndlp->nlp_rpi, ndlp->nlp_DID, ndlp->nlp_flag);1108 ndlp->nlp_rpi, ndlp->nlp_DID, ndlp->nlp_flag);
1104 1109
1105 rc = lpfc_sli_issue_mbox(phba, pmb, MBX_NOWAIT);1110 rc = lpfc_sli_issue_mbox(phba, pmb, MBX_NOWAIT);
1106 if (rc == MBX_NOT_FINISHED)1111 if (rc == MBX_NOT_FINISHED) {
1112 lpfc_nlp_put(ndlp);
1107 mempool_free(pmb, phba->mbox_mem_pool);1113 mempool_free(pmb, phba->mbox_mem_pool);
1114 }
1108 }1115 }
1109}1116}
1110 1117
@@ -1218,7 +1225,7 @@ lpfc_rcv_plogi_plogi_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, · 107 unmodified lines
1218 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);1225 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
1219 struct lpfc_hba *phba = vport->phba;1226 struct lpfc_hba *phba = vport->phba;
1220 struct lpfc_iocbq *cmdiocb = arg;1227 struct lpfc_iocbq *cmdiocb = arg;
1221 struct lpfc_dmabuf *pcmd = (struct lpfc_dmabuf *) cmdiocb->context2;1228 struct lpfc_dmabuf *pcmd = cmdiocb->cmd_dmabuf;
1222 uint32_t *lp = (uint32_t *) pcmd->virt;1229 uint32_t *lp = (uint32_t *) pcmd->virt;
1223 struct serv_parm *sp = (struct serv_parm *) (lp + 1);1230 struct serv_parm *sp = (struct serv_parm *) (lp + 1);
1224 struct ls_rjt stat;1231 struct ls_rjt stat;
@@ -1328,7 +1335,7 @@ lpfc_cmpl_plogi_plogi_issue(struct lpfc_vport *vport, · 103 unmodified lines
1328{1335{
1329 struct lpfc_hba *phba = vport->phba;1336 struct lpfc_hba *phba = vport->phba;
1330 struct lpfc_iocbq *cmdiocb, *rspiocb;1337 struct lpfc_iocbq *cmdiocb, *rspiocb;
1331 struct lpfc_dmabuf *pcmd, *prsp, *mp;1338 struct lpfc_dmabuf *pcmd, *prsp;
1332 uint32_t *lp;1339 uint32_t *lp;
1333 uint32_t vid, flag;1340 uint32_t vid, flag;
1334 struct serv_parm *sp;1341 struct serv_parm *sp;
@@ -1339,7 +1346,7 @@ lpfc_cmpl_plogi_plogi_issue(struct lpfc_vport *vport, · 4 unmodified lines
1339 u32 did;1346 u32 did;
1340 1347
1341 cmdiocb = (struct lpfc_iocbq *) arg;1348 cmdiocb = (struct lpfc_iocbq *) arg;
1342 rspiocb = cmdiocb->context_un.rsp_iocb;1349 rspiocb = cmdiocb->rsp_iocb;
1343 1350
1344 ulp_status = get_job_ulpstatus(phba, rspiocb);1351 ulp_status = get_job_ulpstatus(phba, rspiocb);
1345 1352
@@ -1351,7 +1358,7 @@ lpfc_cmpl_plogi_plogi_issue(struct lpfc_vport *vport, · 5 unmodified lines
1351 if (ulp_status)1358 if (ulp_status)
1352 goto out;1359 goto out;
1353 1360
1354 pcmd = (struct lpfc_dmabuf *) cmdiocb->context2;1361 pcmd = cmdiocb->cmd_dmabuf;
1355 1362
1356 prsp = list_get_first(&pcmd->list, struct lpfc_dmabuf, list);1363 prsp = list_get_first(&pcmd->list, struct lpfc_dmabuf, list);
1357 if (!prsp)1364 if (!prsp)
@@ -1495,11 +1502,7 @@ lpfc_cmpl_plogi_plogi_issue(struct lpfc_vport *vport, · 137 unmodified lines
1495 * command1502 * command
1496 */1503 */
1497 lpfc_nlp_put(ndlp);1504 lpfc_nlp_put(ndlp);
1498 mp = (struct lpfc_dmabuf *)mbox->ctx_buf;1505 lpfc_mbox_rsrc_cleanup(phba, mbox, MBOX_THD_UNLOCKED);
1499 lpfc_mbuf_free(phba, mp->virt, mp->phys);
1500 kfree(mp);
1501 mempool_free(mbox, phba->mbox_mem_pool);
1502
1503 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,1506 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
1504 "0134 PLOGI: cannot issue reg_login "1507 "0134 PLOGI: cannot issue reg_login "
1505 "Data: x%x x%x x%x x%x\n",1508 "Data: x%x x%x x%x x%x\n",
@@ -1697,7 +1700,7 @@ lpfc_cmpl_adisc_adisc_issue(struct lpfc_vport *vport, · 191 unmodified lines
1697 u32 ulp_status;1700 u32 ulp_status;
1698 1701
1699 cmdiocb = (struct lpfc_iocbq *) arg;1702 cmdiocb = (struct lpfc_iocbq *) arg;
1700 rspiocb = cmdiocb->context_un.rsp_iocb;1703 rspiocb = cmdiocb->rsp_iocb;
1701 1704
1702 ulp_status = get_job_ulpstatus(phba, rspiocb);1705 ulp_status = get_job_ulpstatus(phba, rspiocb);
1703 1706
@@ -1850,7 +1853,6 @@ lpfc_rcv_logo_reglogin_issue(struct lpfc_vport *vport, · 146 unmodified lines
1850 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;1853 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
1851 LPFC_MBOXQ_t *mb;1854 LPFC_MBOXQ_t *mb;
1852 LPFC_MBOXQ_t *nextmb;1855 LPFC_MBOXQ_t *nextmb;
1853 struct lpfc_dmabuf *mp;
1854 struct lpfc_nodelist *ns_ndlp;1856 struct lpfc_nodelist *ns_ndlp;
1855 1857
1856 cmdiocb = (struct lpfc_iocbq *) arg;1858 cmdiocb = (struct lpfc_iocbq *) arg;
@@ -1870,16 +1872,11 @@ lpfc_rcv_logo_reglogin_issue(struct lpfc_vport *vport, · 13 unmodified lines
1870 list_for_each_entry_safe(mb, nextmb, &phba->sli.mboxq, list) {1872 list_for_each_entry_safe(mb, nextmb, &phba->sli.mboxq, list) {
1871 if ((mb->u.mb.mbxCommand == MBX_REG_LOGIN64) &&1873 if ((mb->u.mb.mbxCommand == MBX_REG_LOGIN64) &&
1872 (ndlp == (struct lpfc_nodelist *)mb->ctx_ndlp)) {1874 (ndlp == (struct lpfc_nodelist *)mb->ctx_ndlp)) {
1873 mp = (struct lpfc_dmabuf *)(mb->ctx_buf);
1874 if (mp) {
1875 __lpfc_mbuf_free(phba, mp->virt, mp->phys);
1876 kfree(mp);
1877 }
1878 ndlp->nlp_flag &= ~NLP_REG_LOGIN_SEND;1875 ndlp->nlp_flag &= ~NLP_REG_LOGIN_SEND;
1879 lpfc_nlp_put(ndlp);1876 lpfc_nlp_put(ndlp);
1880 list_del(&mb->list);1877 list_del(&mb->list);
1881 phba->sli.mboxq_cnt--;1878 phba->sli.mboxq_cnt--;
1882 mempool_free(mb, phba->mbox_mem_pool);1879 lpfc_mbox_rsrc_cleanup(phba, mb, MBOX_THD_LOCKED);
1883 }1880 }
1884 }1881 }
1885 spin_unlock_irq(&phba->hbalock);1882 spin_unlock_irq(&phba->hbalock);
@@ -2152,7 +2149,7 @@ lpfc_cmpl_prli_prli_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, · 266 unmodified lines
2152 u32 ulp_status;2149 u32 ulp_status;
2153 2150
2154 cmdiocb = (struct lpfc_iocbq *) arg;2151 cmdiocb = (struct lpfc_iocbq *) arg;
2155 rspiocb = cmdiocb->context_un.rsp_iocb;2152 rspiocb = cmdiocb->rsp_iocb;
2156 2153
2157 ulp_status = get_job_ulpstatus(phba, rspiocb);2154 ulp_status = get_job_ulpstatus(phba, rspiocb);
2158 2155
@@ -2772,7 +2769,7 @@ lpfc_cmpl_plogi_npr_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, · 613 unmodified lines
2772 u32 ulp_status;2769 u32 ulp_status;
2773 2770
2774 cmdiocb = (struct lpfc_iocbq *) arg;2771 cmdiocb = (struct lpfc_iocbq *) arg;
2775 rspiocb = cmdiocb->context_un.rsp_iocb;2772 rspiocb = cmdiocb->rsp_iocb;
2776 2773
2777 ulp_status = get_job_ulpstatus(phba, rspiocb);2774 ulp_status = get_job_ulpstatus(phba, rspiocb);
2778 2775
@@ -2791,7 +2788,7 @@ lpfc_cmpl_prli_npr_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, · 12 unmodified lines
2791 u32 ulp_status;2788 u32 ulp_status;
2792 2789
2793 cmdiocb = (struct lpfc_iocbq *) arg;2790 cmdiocb = (struct lpfc_iocbq *) arg;
2794 rspiocb = cmdiocb->context_un.rsp_iocb;2791 rspiocb = cmdiocb->rsp_iocb;
2795 2792
2796 ulp_status = get_job_ulpstatus(phba, rspiocb);2793 ulp_status = get_job_ulpstatus(phba, rspiocb);
2797 2794
@@ -2827,7 +2824,7 @@ lpfc_cmpl_adisc_npr_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, · 29 unmodified lines
2827 u32 ulp_status;2824 u32 ulp_status;
2828 2825
2829 cmdiocb = (struct lpfc_iocbq *) arg;2826 cmdiocb = (struct lpfc_iocbq *) arg;
2830 rspiocb = cmdiocb->context_un.rsp_iocb;2827 rspiocb = cmdiocb->rsp_iocb;
2831 2828
2832 ulp_status = get_job_ulpstatus(phba, rspiocb);2829 ulp_status = get_job_ulpstatus(phba, rspiocb);
2833 2830
drivers/scsi/lpfc/lpfc_nvme.c+25−19
@@ -319,8 +319,10 @@ __lpfc_nvme_ls_req_cmp(struct lpfc_hba *phba, struct lpfc_vport *vport, · 318 unmodified lines
319 struct lpfc_nodelist *ndlp;319 struct lpfc_nodelist *ndlp;
320 uint32_t status;320 uint32_t status;
321 321
322 pnvme_lsreq = (struct nvmefc_ls_req *)cmdwqe->context2;322 pnvme_lsreq = cmdwqe->context_un.nvme_lsreq;
323 ndlp = (struct lpfc_nodelist *)cmdwqe->context1;323 ndlp = cmdwqe->ndlp;
324 buf_ptr = cmdwqe->bpl_dmabuf;
325
324 status = bf_get(lpfc_wcqe_c_status, wcqe) & LPFC_IOCB_STATUS_MASK;326 status = bf_get(lpfc_wcqe_c_status, wcqe) & LPFC_IOCB_STATUS_MASK;
325 327
326 lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME_DISC,328 lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME_DISC,
@@ -330,16 +332,16 @@ __lpfc_nvme_ls_req_cmp(struct lpfc_hba *phba, struct lpfc_vport *vport, · 3 unmodified lines
330 pnvme_lsreq, ndlp ? ndlp->nlp_DID : 0,332 pnvme_lsreq, ndlp ? ndlp->nlp_DID : 0,
331 cmdwqe->sli4_xritag, status,333 cmdwqe->sli4_xritag, status,
332 (wcqe->parameter & 0xffff),334 (wcqe->parameter & 0xffff),
333 cmdwqe, pnvme_lsreq, cmdwqe->context3, ndlp);335 cmdwqe, pnvme_lsreq, cmdwqe->bpl_dmabuf,
336 ndlp);
334 337
335 lpfc_nvmeio_data(phba, "NVMEx LS CMPL: xri x%x stat x%x parm x%x\n",338 lpfc_nvmeio_data(phba, "NVMEx LS CMPL: xri x%x stat x%x parm x%x\n",
336 cmdwqe->sli4_xritag, status, wcqe->parameter);339 cmdwqe->sli4_xritag, status, wcqe->parameter);
337 340
338 if (cmdwqe->context3) {341 if (buf_ptr) {
339 buf_ptr = (struct lpfc_dmabuf *)cmdwqe->context3;
340 lpfc_mbuf_free(phba, buf_ptr->virt, buf_ptr->phys);342 lpfc_mbuf_free(phba, buf_ptr->virt, buf_ptr->phys);
341 kfree(buf_ptr);343 kfree(buf_ptr);
342 cmdwqe->context3 = NULL;344 cmdwqe->bpl_dmabuf = NULL;
343 }345 }
344 if (pnvme_lsreq->done)346 if (pnvme_lsreq->done)
345 pnvme_lsreq->done(pnvme_lsreq, status);347 pnvme_lsreq->done(pnvme_lsreq, status);
@@ -351,7 +353,7 @@ __lpfc_nvme_ls_req_cmp(struct lpfc_hba *phba, struct lpfc_vport *vport, · 5 unmodified lines
351 cmdwqe->sli4_xritag, status);353 cmdwqe->sli4_xritag, status);
352 if (ndlp) {354 if (ndlp) {
353 lpfc_nlp_put(ndlp);355 lpfc_nlp_put(ndlp);
354 cmdwqe->context1 = NULL;356 cmdwqe->ndlp = NULL;
355 }357 }
356 lpfc_sli_release_iocbq(phba, cmdwqe);358 lpfc_sli_release_iocbq(phba, cmdwqe);
357}359}
@@ -407,19 +409,19 @@ lpfc_nvme_gen_req(struct lpfc_vport *vport, struct lpfc_dmabuf *bmp, · 49 unmodified lines
407 /* Initialize only 64 bytes */409 /* Initialize only 64 bytes */
408 memset(wqe, 0, sizeof(union lpfc_wqe));410 memset(wqe, 0, sizeof(union lpfc_wqe));
409 411
410 genwqe->context3 = (uint8_t *)bmp;412 genwqe->bpl_dmabuf = bmp;
411 genwqe->cmd_flag |= LPFC_IO_NVME_LS;413 genwqe->cmd_flag |= LPFC_IO_NVME_LS;
412 414
413 /* Save for completion so we can release these resources */415 /* Save for completion so we can release these resources */
414 genwqe->context1 = lpfc_nlp_get(ndlp);416 genwqe->ndlp = lpfc_nlp_get(ndlp);
415 if (!genwqe->context1) {417 if (!genwqe->ndlp) {
416 dev_warn(&phba->pcidev->dev,418 dev_warn(&phba->pcidev->dev,
417 "Warning: Failed node ref, not sending LS_REQ\n");419 "Warning: Failed node ref, not sending LS_REQ\n");
418 lpfc_sli_release_iocbq(phba, genwqe);420 lpfc_sli_release_iocbq(phba, genwqe);
419 return 1;421 return 1;
420 }422 }
421 423
422 genwqe->context2 = (uint8_t *)pnvme_lsreq;424 genwqe->context_un.nvme_lsreq = pnvme_lsreq;
423 /* Fill in payload, bp points to frame payload */425 /* Fill in payload, bp points to frame payload */
424 426
425 if (!tmo)427 if (!tmo)
@@ -730,7 +732,7 @@ __lpfc_nvme_ls_abort(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, · 304 unmodified lines
730 spin_lock_irq(&phba->hbalock);732 spin_lock_irq(&phba->hbalock);
731 spin_lock(&pring->ring_lock);733 spin_lock(&pring->ring_lock);
732 list_for_each_entry_safe(wqe, next_wqe, &pring->txcmplq, list) {734 list_for_each_entry_safe(wqe, next_wqe, &pring->txcmplq, list) {
733 if (wqe->context2 == pnvme_lsreq) {735 if (wqe->context_un.nvme_lsreq == pnvme_lsreq) {
734 wqe->cmd_flag |= LPFC_DRIVER_ABORTED;736 wqe->cmd_flag |= LPFC_DRIVER_ABORTED;
735 foundit = true;737 foundit = true;
736 break;738 break;
@@ -929,8 +931,7 @@ static void · 192 unmodified lines
929lpfc_nvme_io_cmd_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pwqeIn,931lpfc_nvme_io_cmd_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pwqeIn,
930 struct lpfc_iocbq *pwqeOut)932 struct lpfc_iocbq *pwqeOut)
931{933{
932 struct lpfc_io_buf *lpfc_ncmd =934 struct lpfc_io_buf *lpfc_ncmd = pwqeIn->io_buf;
933 (struct lpfc_io_buf *)pwqeIn->context1;
934 struct lpfc_wcqe_complete *wcqe = &pwqeOut->wcqe_cmpl;935 struct lpfc_wcqe_complete *wcqe = &pwqeOut->wcqe_cmpl;
935 struct lpfc_vport *vport = pwqeIn->vport;936 struct lpfc_vport *vport = pwqeIn->vport;
936 struct nvmefc_fcp_req *nCmd;937 struct nvmefc_fcp_req *nCmd;
@@ -1400,8 +1401,8 @@ lpfc_nvme_prep_io_dma(struct lpfc_vport *vport, · 463 unmodified lines
1400 if ((nseg - 1) == i)1401 if ((nseg - 1) == i)
1401 bf_set(lpfc_sli4_sge_last, sgl, 1);1402 bf_set(lpfc_sli4_sge_last, sgl, 1);
1402 1403
1403 physaddr = data_sg->dma_address;1404 physaddr = sg_dma_address(data_sg);
1404 dma_len = data_sg->length;1405 dma_len = sg_dma_len(data_sg);
1405 sgl->addr_lo = cpu_to_le32(1406 sgl->addr_lo = cpu_to_le32(
1406 putPaddrLow(physaddr));1407 putPaddrLow(physaddr));
1407 sgl->addr_hi = cpu_to_le32(1408 sgl->addr_hi = cpu_to_le32(
@@ -2356,6 +2357,11 @@ lpfc_nvme_register_port(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp) · 948 unmodified lines
2356 rpinfo.dev_loss_tmo = vport->cfg_devloss_tmo;2357 rpinfo.dev_loss_tmo = vport->cfg_devloss_tmo;
2357 2358
2358 spin_lock_irq(&ndlp->lock);2359 spin_lock_irq(&ndlp->lock);
2360
2361 /* If an oldrport exists, so does the ndlp reference. If not
2362 * a new reference is needed because either the node has never
2363 * been registered or it's been unregistered and getting deleted.
2364 */
2359 oldrport = lpfc_ndlp_get_nrport(ndlp);2365 oldrport = lpfc_ndlp_get_nrport(ndlp);
2360 if (oldrport) {2366 if (oldrport) {
2361 prev_ndlp = oldrport->ndlp;2367 prev_ndlp = oldrport->ndlp;
@@ -2466,12 +2472,12 @@ lpfc_nvme_rescan_port(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp) · 104 unmodified lines
2466 if (!nrport || !remoteport)2472 if (!nrport || !remoteport)
2467 goto rescan_exit;2473 goto rescan_exit;
2468 2474
2469 /* Only rescan if we are an NVME target in the MAPPED state */2475 /* Rescan an NVME target in MAPPED state with DISCOVERY role set */
2470 if (remoteport->port_role & FC_PORT_ROLE_NVME_DISCOVERY &&2476 if (remoteport->port_role & FC_PORT_ROLE_NVME_DISCOVERY &&
2471 ndlp->nlp_state == NLP_STE_MAPPED_NODE) {2477 ndlp->nlp_state == NLP_STE_MAPPED_NODE) {
2472 nvme_fc_rescan_remoteport(remoteport);2478 nvme_fc_rescan_remoteport(remoteport);
2473 2479
2474 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,2480 lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME_DISC,
2475 "6172 NVME rescanned DID x%06x "2481 "6172 NVME rescanned DID x%06x "
2476 "port_state x%x\n",2482 "port_state x%x\n",
2477 ndlp->nlp_DID, remoteport->port_state);2483 ndlp->nlp_DID, remoteport->port_state);
@@ -2717,7 +2723,7 @@ lpfc_nvme_cancel_iocb(struct lpfc_hba *phba, struct lpfc_iocbq *pwqeIn, · 239 unmodified lines
2717 struct lpfc_wcqe_complete wcqe;2723 struct lpfc_wcqe_complete wcqe;
2718 struct lpfc_wcqe_complete *wcqep = &wcqe;2724 struct lpfc_wcqe_complete *wcqep = &wcqe;
2719 2725
2720 lpfc_ncmd = (struct lpfc_io_buf *)pwqeIn->context1;2726 lpfc_ncmd = pwqeIn->io_buf;
2721 if (!lpfc_ncmd) {2727 if (!lpfc_ncmd) {
2722 lpfc_sli_release_iocbq(phba, pwqeIn);2728 lpfc_sli_release_iocbq(phba, pwqeIn);
2723 return;2729 return;
drivers/scsi/lpfc/lpfc_nvmet.c+37−36
@@ -295,7 +295,7 @@ void · 294 unmodified lines
295__lpfc_nvme_xmt_ls_rsp_cmp(struct lpfc_hba *phba, struct lpfc_iocbq *cmdwqe,295__lpfc_nvme_xmt_ls_rsp_cmp(struct lpfc_hba *phba, struct lpfc_iocbq *cmdwqe,
296 struct lpfc_iocbq *rspwqe)296 struct lpfc_iocbq *rspwqe)
297{297{
298 struct lpfc_async_xchg_ctx *axchg = cmdwqe->context2;298 struct lpfc_async_xchg_ctx *axchg = cmdwqe->context_un.axchg;
299 struct lpfc_wcqe_complete *wcqe = &rspwqe->wcqe_cmpl;299 struct lpfc_wcqe_complete *wcqe = &rspwqe->wcqe_cmpl;
300 struct nvmefc_ls_rsp *ls_rsp = &axchg->ls_rsp;300 struct nvmefc_ls_rsp *ls_rsp = &axchg->ls_rsp;
301 uint32_t status, result;301 uint32_t status, result;
@@ -317,9 +317,9 @@ __lpfc_nvme_xmt_ls_rsp_cmp(struct lpfc_hba *phba, struct lpfc_iocbq *cmdwqe, · 15 unmodified lines
317 "6038 NVMEx LS rsp cmpl: %d %d oxid x%x\n",317 "6038 NVMEx LS rsp cmpl: %d %d oxid x%x\n",
318 status, result, axchg->oxid);318 status, result, axchg->oxid);
319 319
320 lpfc_nlp_put(cmdwqe->context1);320 lpfc_nlp_put(cmdwqe->ndlp);
321 cmdwqe->context2 = NULL;321 cmdwqe->context_un.axchg = NULL;
322 cmdwqe->context3 = NULL;322 cmdwqe->bpl_dmabuf = NULL;
323 lpfc_sli_release_iocbq(phba, cmdwqe);323 lpfc_sli_release_iocbq(phba, cmdwqe);
324 ls_rsp->done(ls_rsp);324 ls_rsp->done(ls_rsp);
325 lpfc_printf_log(phba, KERN_INFO, LOG_NVME_DISC,325 lpfc_printf_log(phba, KERN_INFO, LOG_NVME_DISC,
@@ -728,7 +728,7 @@ lpfc_nvmet_xmt_fcp_op_cmp(struct lpfc_hba *phba, struct lpfc_iocbq *cmdwqe, · 402 unmodified lines
728 int id;728 int id;
729#endif729#endif
730 730
731 ctxp = cmdwqe->context2;731 ctxp = cmdwqe->context_un.axchg;
732 ctxp->flag &= ~LPFC_NVME_IO_INP;732 ctxp->flag &= ~LPFC_NVME_IO_INP;
733 733
734 rsp = &ctxp->hdlrctx.fcp_req;734 rsp = &ctxp->hdlrctx.fcp_req;
@@ -903,7 +903,7 @@ __lpfc_nvme_xmt_ls_rsp(struct lpfc_async_xchg_ctx *axchg, · 168 unmodified lines
903 /* Save numBdes for bpl2sgl */903 /* Save numBdes for bpl2sgl */
904 nvmewqeq->num_bdes = 1;904 nvmewqeq->num_bdes = 1;
905 nvmewqeq->hba_wqidx = 0;905 nvmewqeq->hba_wqidx = 0;
906 nvmewqeq->context3 = &dmabuf;906 nvmewqeq->bpl_dmabuf = &dmabuf;
907 dmabuf.virt = &bpl;907 dmabuf.virt = &bpl;
908 bpl.addrLow = nvmewqeq->wqe.xmit_sequence.bde.addrLow;908 bpl.addrLow = nvmewqeq->wqe.xmit_sequence.bde.addrLow;
909 bpl.addrHigh = nvmewqeq->wqe.xmit_sequence.bde.addrHigh;909 bpl.addrHigh = nvmewqeq->wqe.xmit_sequence.bde.addrHigh;
@@ -917,7 +917,7 @@ __lpfc_nvme_xmt_ls_rsp(struct lpfc_async_xchg_ctx *axchg, · 7 unmodified lines
917 */917 */
918 918
919 nvmewqeq->cmd_cmpl = xmt_ls_rsp_cmp;919 nvmewqeq->cmd_cmpl = xmt_ls_rsp_cmp;
920 nvmewqeq->context2 = axchg;920 nvmewqeq->context_un.axchg = axchg;
921 921
922 lpfc_nvmeio_data(phba, "NVMEx LS RSP: xri x%x wqidx x%x len x%x\n",922 lpfc_nvmeio_data(phba, "NVMEx LS RSP: xri x%x wqidx x%x len x%x\n",
923 axchg->oxid, nvmewqeq->hba_wqidx, ls_rsp->rsplen);923 axchg->oxid, nvmewqeq->hba_wqidx, ls_rsp->rsplen);
@@ -925,7 +925,7 @@ __lpfc_nvme_xmt_ls_rsp(struct lpfc_async_xchg_ctx *axchg, · 1 unmodified line
925 rc = lpfc_sli4_issue_wqe(phba, axchg->hdwq, nvmewqeq);925 rc = lpfc_sli4_issue_wqe(phba, axchg->hdwq, nvmewqeq);
926 926
927 /* clear to be sure there's no reference */927 /* clear to be sure there's no reference */
928 nvmewqeq->context3 = NULL;928 nvmewqeq->bpl_dmabuf = NULL;
929 929
930 if (rc == WQE_SUCCESS) {930 if (rc == WQE_SUCCESS) {
931 /*931 /*
@@ -942,7 +942,7 @@ __lpfc_nvme_xmt_ls_rsp(struct lpfc_async_xchg_ctx *axchg, · 10 unmodified lines
942 942
943 rc = -ENXIO;943 rc = -ENXIO;
944 944
945 lpfc_nlp_put(nvmewqeq->context1);945 lpfc_nlp_put(nvmewqeq->ndlp);
946 946
947out_free_buf:947out_free_buf:
948 /* Give back resources */948 /* Give back resources */
@@ -1075,7 +1075,7 @@ lpfc_nvmet_xmt_fcp_op(struct nvmet_fc_target_port *tgtport, · 126 unmodified lines
1075 }1075 }
1076 1076
1077 nvmewqeq->cmd_cmpl = lpfc_nvmet_xmt_fcp_op_cmp;1077 nvmewqeq->cmd_cmpl = lpfc_nvmet_xmt_fcp_op_cmp;
1078 nvmewqeq->context2 = ctxp;1078 nvmewqeq->context_un.axchg = ctxp;
1079 nvmewqeq->cmd_flag |= LPFC_IO_NVMET;1079 nvmewqeq->cmd_flag |= LPFC_IO_NVMET;
1080 ctxp->wqeq->hba_wqidx = rsp->hwqid;1080 ctxp->wqeq->hba_wqidx = rsp->hwqid;
1081 1081
@@ -1119,8 +1119,8 @@ lpfc_nvmet_xmt_fcp_op(struct nvmet_fc_target_port *tgtport, · 37 unmodified lines
1119 ctxp->oxid, rc);1119 ctxp->oxid, rc);
1120 1120
1121 ctxp->wqeq->hba_wqidx = 0;1121 ctxp->wqeq->hba_wqidx = 0;
1122 nvmewqeq->context2 = NULL;1122 nvmewqeq->context_un.axchg = NULL;
1123 nvmewqeq->context3 = NULL;1123 nvmewqeq->bpl_dmabuf = NULL;
1124 rc = -EBUSY;1124 rc = -EBUSY;
1125aerr:1125aerr:
1126 return rc;1126 return rc;
@@ -1590,7 +1590,7 @@ lpfc_nvmet_setup_io_context(struct lpfc_hba *phba) · 463 unmodified lines
1590 /* Initialize WQE */1590 /* Initialize WQE */
1591 memset(wqe, 0, sizeof(union lpfc_wqe));1591 memset(wqe, 0, sizeof(union lpfc_wqe));
1592 1592
1593 ctx_buf->iocbq->context1 = NULL;1593 ctx_buf->iocbq->cmd_dmabuf = NULL;
1594 spin_lock(&phba->sli4_hba.sgl_list_lock);1594 spin_lock(&phba->sli4_hba.sgl_list_lock);
1595 ctx_buf->sglq = __lpfc_sli_get_nvmet_sglq(phba, ctx_buf->iocbq);1595 ctx_buf->sglq = __lpfc_sli_get_nvmet_sglq(phba, ctx_buf->iocbq);
1596 spin_unlock(&phba->sli4_hba.sgl_list_lock);1596 spin_unlock(&phba->sli4_hba.sgl_list_lock);
@@ -2025,7 +2025,7 @@ lpfc_nvmet_wqfull_flush(struct lpfc_hba *phba, struct lpfc_queue *wq, · 428 unmodified lines
2025 &wq->wqfull_list, list) {2025 &wq->wqfull_list, list) {
2026 if (ctxp) {2026 if (ctxp) {
2027 /* Checking for a specific IO to flush */2027 /* Checking for a specific IO to flush */
2028 if (nvmewqeq->context2 == ctxp) {2028 if (nvmewqeq->context_un.axchg == ctxp) {
2029 list_del(&nvmewqeq->list);2029 list_del(&nvmewqeq->list);
2030 spin_unlock_irqrestore(&pring->ring_lock,2030 spin_unlock_irqrestore(&pring->ring_lock,
2031 iflags);2031 iflags);
@@ -2071,7 +2071,7 @@ lpfc_nvmet_wqfull_process(struct lpfc_hba *phba, · 39 unmodified lines
2071 list_remove_head(&wq->wqfull_list, nvmewqeq, struct lpfc_iocbq,2071 list_remove_head(&wq->wqfull_list, nvmewqeq, struct lpfc_iocbq,
2072 list);2072 list);
2073 spin_unlock_irqrestore(&pring->ring_lock, iflags);2073 spin_unlock_irqrestore(&pring->ring_lock, iflags);
2074 ctxp = (struct lpfc_async_xchg_ctx *)nvmewqeq->context2;2074 ctxp = nvmewqeq->context_un.axchg;
2075 rc = lpfc_sli4_issue_wqe(phba, ctxp->hdwq, nvmewqeq);2075 rc = lpfc_sli4_issue_wqe(phba, ctxp->hdwq, nvmewqeq);
2076 spin_lock_irqsave(&pring->ring_lock, iflags);2076 spin_lock_irqsave(&pring->ring_lock, iflags);
2077 if (rc == -EBUSY) {2077 if (rc == -EBUSY) {
@@ -2617,10 +2617,10 @@ lpfc_nvmet_prep_ls_wqe(struct lpfc_hba *phba, · 539 unmodified lines
2617 ctxp->wqeq = nvmewqe;2617 ctxp->wqeq = nvmewqe;
2618 2618
2619 /* prevent preparing wqe with NULL ndlp reference */2619 /* prevent preparing wqe with NULL ndlp reference */
2620 nvmewqe->context1 = lpfc_nlp_get(ndlp);2620 nvmewqe->ndlp = lpfc_nlp_get(ndlp);
2621 if (nvmewqe->context1 == NULL)2621 if (!nvmewqe->ndlp)
2622 goto nvme_wqe_free_wqeq_exit;2622 goto nvme_wqe_free_wqeq_exit;
2623 nvmewqe->context2 = ctxp;2623 nvmewqe->context_un.axchg = ctxp;
2624 2624
2625 wqe = &nvmewqe->wqe;2625 wqe = &nvmewqe->wqe;
2626 memset(wqe, 0, sizeof(union lpfc_wqe));2626 memset(wqe, 0, sizeof(union lpfc_wqe));
@@ -2692,8 +2692,9 @@ lpfc_nvmet_prep_ls_wqe(struct lpfc_hba *phba, · 65 unmodified lines
2692 return nvmewqe;2692 return nvmewqe;
2693 2693
2694nvme_wqe_free_wqeq_exit:2694nvme_wqe_free_wqeq_exit:
2695 nvmewqe->context2 = NULL;2695 nvmewqe->context_un.axchg = NULL;
2696 nvmewqe->context3 = NULL;2696 nvmewqe->ndlp = NULL;
2697 nvmewqe->bpl_dmabuf = NULL;
2697 lpfc_sli_release_iocbq(phba, nvmewqe);2698 lpfc_sli_release_iocbq(phba, nvmewqe);
2698 return NULL;2699 return NULL;
2699}2700}
@@ -2995,7 +2996,7 @@ lpfc_nvmet_prep_fcp_wqe(struct lpfc_hba *phba, · 295 unmodified lines
2995 nvmewqe->retry = 1;2996 nvmewqe->retry = 1;
2996 nvmewqe->vport = phba->pport;2997 nvmewqe->vport = phba->pport;
2997 nvmewqe->drvrTimeout = (phba->fc_ratov * 3) + LPFC_DRVR_TIMEOUT;2998 nvmewqe->drvrTimeout = (phba->fc_ratov * 3) + LPFC_DRVR_TIMEOUT;
2998 nvmewqe->context1 = ndlp;2999 nvmewqe->ndlp = ndlp;
2999 3000
3000 for_each_sg(rsp->sg, sgel, nsegs, i) {3001 for_each_sg(rsp->sg, sgel, nsegs, i) {
3001 physaddr = sg_dma_address(sgel);3002 physaddr = sg_dma_address(sgel);
@@ -3053,7 +3054,7 @@ lpfc_nvmet_sol_fcp_abort_cmp(struct lpfc_hba *phba, struct lpfc_iocbq *cmdwqe, · 51 unmodified lines
3053 bool released = false;3054 bool released = false;
3054 struct lpfc_wcqe_complete *wcqe = &rspwqe->wcqe_cmpl;3055 struct lpfc_wcqe_complete *wcqe = &rspwqe->wcqe_cmpl;
3055 3056
3056 ctxp = cmdwqe->context2;3057 ctxp = cmdwqe->context_un.axchg;
3057 result = wcqe->parameter;3058 result = wcqe->parameter;
3058 3059
3059 tgtp = (struct lpfc_nvmet_tgtport *)phba->targetport->private;3060 tgtp = (struct lpfc_nvmet_tgtport *)phba->targetport->private;
@@ -3084,8 +3085,8 @@ lpfc_nvmet_sol_fcp_abort_cmp(struct lpfc_hba *phba, struct lpfc_iocbq *cmdwqe, · 24 unmodified lines
3084 wcqe->word0, wcqe->total_data_placed,3085 wcqe->word0, wcqe->total_data_placed,
3085 result, wcqe->word3);3086 result, wcqe->word3);
3086 3087
3087 cmdwqe->context2 = NULL;3088 cmdwqe->rsp_dmabuf = NULL;
3088 cmdwqe->context3 = NULL;3089 cmdwqe->bpl_dmabuf = NULL;
3089 /*3090 /*
3090 * if transport has released ctx, then can reuse it. Otherwise,3091 * if transport has released ctx, then can reuse it. Otherwise,
3091 * will be recycled by transport release call.3092 * will be recycled by transport release call.
@@ -3123,7 +3124,7 @@ lpfc_nvmet_unsol_fcp_abort_cmp(struct lpfc_hba *phba, struct lpfc_iocbq *cmdwqe, · 31 unmodified lines
3123 bool released = false;3124 bool released = false;
3124 struct lpfc_wcqe_complete *wcqe = &rspwqe->wcqe_cmpl;3125 struct lpfc_wcqe_complete *wcqe = &rspwqe->wcqe_cmpl;
3125 3126
3126 ctxp = cmdwqe->context2;3127 ctxp = cmdwqe->context_un.axchg;
3127 result = wcqe->parameter;3128 result = wcqe->parameter;
3128 3129
3129 if (!ctxp) {3130 if (!ctxp) {
@@ -3169,8 +3170,8 @@ lpfc_nvmet_unsol_fcp_abort_cmp(struct lpfc_hba *phba, struct lpfc_iocbq *cmdwqe, · 39 unmodified lines
3169 wcqe->word0, wcqe->total_data_placed,3170 wcqe->word0, wcqe->total_data_placed,
3170 result, wcqe->word3);3171 result, wcqe->word3);
3171 3172
3172 cmdwqe->context2 = NULL;3173 cmdwqe->rsp_dmabuf = NULL;
3173 cmdwqe->context3 = NULL;3174 cmdwqe->bpl_dmabuf = NULL;
3174 /*3175 /*
3175 * if transport has released ctx, then can reuse it. Otherwise,3176 * if transport has released ctx, then can reuse it. Otherwise,
3176 * will be recycled by transport release call.3177 * will be recycled by transport release call.
@@ -3203,7 +3204,7 @@ lpfc_nvmet_xmt_ls_abort_cmp(struct lpfc_hba *phba, struct lpfc_iocbq *cmdwqe, · 26 unmodified lines
3203 uint32_t result;3204 uint32_t result;
3204 struct lpfc_wcqe_complete *wcqe = &rspwqe->wcqe_cmpl;3205 struct lpfc_wcqe_complete *wcqe = &rspwqe->wcqe_cmpl;
3205 3206
3206 ctxp = cmdwqe->context2;3207 ctxp = cmdwqe->context_un.axchg;
3207 result = wcqe->parameter;3208 result = wcqe->parameter;
3208 3209
3209 if (phba->nvmet_support) {3210 if (phba->nvmet_support) {
@@ -3234,8 +3235,8 @@ lpfc_nvmet_xmt_ls_abort_cmp(struct lpfc_hba *phba, struct lpfc_iocbq *cmdwqe, · 24 unmodified lines
3234 ctxp->oxid, ctxp->state, ctxp->entry_cnt);3235 ctxp->oxid, ctxp->state, ctxp->entry_cnt);
3235 }3236 }
3236 3237
3237 cmdwqe->context2 = NULL;3238 cmdwqe->rsp_dmabuf = NULL;
3238 cmdwqe->context3 = NULL;3239 cmdwqe->bpl_dmabuf = NULL;
3239 lpfc_sli_release_iocbq(phba, cmdwqe);3240 lpfc_sli_release_iocbq(phba, cmdwqe);
3240 kfree(ctxp);3241 kfree(ctxp);
3241}3242}
@@ -3322,9 +3323,9 @@ lpfc_nvmet_unsol_issue_abort(struct lpfc_hba *phba, · 80 unmodified lines
3322 OTHER_COMMAND);3323 OTHER_COMMAND);
3323 3324
3324 abts_wqeq->vport = phba->pport;3325 abts_wqeq->vport = phba->pport;
3325 abts_wqeq->context1 = ndlp;3326 abts_wqeq->ndlp = ndlp;
3326 abts_wqeq->context2 = ctxp;3327 abts_wqeq->context_un.axchg = ctxp;
3327 abts_wqeq->context3 = NULL;3328 abts_wqeq->bpl_dmabuf = NULL;
3328 abts_wqeq->num_bdes = 0;3329 abts_wqeq->num_bdes = 0;
3329 /* hba_wqidx should already be setup from command we are aborting */3330 /* hba_wqidx should already be setup from command we are aborting */
3330 abts_wqeq->iocb.ulpCommand = CMD_XMIT_SEQUENCE64_CR;3331 abts_wqeq->iocb.ulpCommand = CMD_XMIT_SEQUENCE64_CR;
@@ -3477,7 +3478,7 @@ lpfc_nvmet_sol_fcp_issue_abort(struct lpfc_hba *phba, · 146 unmodified lines
3477 abts_wqeq->hba_wqidx = ctxp->wqeq->hba_wqidx;3478 abts_wqeq->hba_wqidx = ctxp->wqeq->hba_wqidx;
3478 abts_wqeq->cmd_cmpl = lpfc_nvmet_sol_fcp_abort_cmp;3479 abts_wqeq->cmd_cmpl = lpfc_nvmet_sol_fcp_abort_cmp;
3479 abts_wqeq->cmd_flag |= LPFC_IO_NVME;3480 abts_wqeq->cmd_flag |= LPFC_IO_NVME;
3480 abts_wqeq->context2 = ctxp;3481 abts_wqeq->context_un.axchg = ctxp;
3481 abts_wqeq->vport = phba->pport;3482 abts_wqeq->vport = phba->pport;
3482 if (!ctxp->hdwq)3483 if (!ctxp->hdwq)
3483 ctxp->hdwq = &phba->sli4_hba.hdwq[abts_wqeq->hba_wqidx];3484 ctxp->hdwq = &phba->sli4_hba.hdwq[abts_wqeq->hba_wqidx];
@@ -3630,8 +3631,8 @@ lpfc_nvme_unsol_ls_issue_abort(struct lpfc_hba *phba, · 146 unmodified lines
3630out:3631out:
3631 if (tgtp)3632 if (tgtp)
3632 atomic_inc(&tgtp->xmt_abort_rsp_error);3633 atomic_inc(&tgtp->xmt_abort_rsp_error);
3633 abts_wqeq->context2 = NULL;3634 abts_wqeq->rsp_dmabuf = NULL;
3634 abts_wqeq->context3 = NULL;3635 abts_wqeq->bpl_dmabuf = NULL;
3635 lpfc_sli_release_iocbq(phba, abts_wqeq);3636 lpfc_sli_release_iocbq(phba, abts_wqeq);
3636 lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT,3637 lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT,
3637 "6056 Failed to Issue ABTS. Status x%x\n", rc);3638 "6056 Failed to Issue ABTS. Status x%x\n", rc);
drivers/scsi/lpfc/lpfc_scsi.c+34−38
@@ -433,7 +433,7 @@ lpfc_new_scsi_buf_s3(struct lpfc_vport *vport, int num_to_alloc) · 432 unmodified lines
433 iocb->ulpClass = CLASS3;433 iocb->ulpClass = CLASS3;
434 psb->status = IOSTAT_SUCCESS;434 psb->status = IOSTAT_SUCCESS;
435 /* Put it back into the SCSI buffer list */435 /* Put it back into the SCSI buffer list */
436 psb->cur_iocbq.context1 = psb;436 psb->cur_iocbq.io_buf = psb;
437 spin_lock_init(&psb->buf_lock);437 spin_lock_init(&psb->buf_lock);
438 lpfc_release_scsi_buf_s3(phba, psb);438 lpfc_release_scsi_buf_s3(phba, psb);
439 439
@@ -3835,7 +3835,7 @@ lpfc_update_cmf_cmpl(struct lpfc_hba *phba, · 3395 unmodified lines
3835 else3835 else
3836 time = div_u64(time + 500, 1000); /* round it */3836 time = div_u64(time + 500, 1000); /* round it */
3837 3837
3838 cgs = this_cpu_ptr(phba->cmf_stat);3838 cgs = per_cpu_ptr(phba->cmf_stat, raw_smp_processor_id());
3839 atomic64_add(size, &cgs->rcv_bytes);3839 atomic64_add(size, &cgs->rcv_bytes);
3840 atomic64_add(time, &cgs->rx_latency);3840 atomic64_add(time, &cgs->rx_latency);
3841 atomic_inc(&cgs->rx_io_cnt);3841 atomic_inc(&cgs->rx_io_cnt);
@@ -3879,7 +3879,7 @@ lpfc_update_cmf_cmd(struct lpfc_hba *phba, uint32_t size) · 37 unmodified lines
3879 atomic_set(&phba->rx_max_read_cnt, size);3879 atomic_set(&phba->rx_max_read_cnt, size);
3880 }3880 }
3881 3881
3882 cgs = this_cpu_ptr(phba->cmf_stat);3882 cgs = per_cpu_ptr(phba->cmf_stat, raw_smp_processor_id());
3883 atomic64_add(size, &cgs->total_bytes);3883 atomic64_add(size, &cgs->total_bytes);
3884 return 0;3884 return 0;
3885}3885}
@@ -4082,8 +4082,7 @@ static void · 196 unmodified lines
4082lpfc_fcp_io_cmd_wqe_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pwqeIn,4082lpfc_fcp_io_cmd_wqe_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pwqeIn,
4083 struct lpfc_iocbq *pwqeOut)4083 struct lpfc_iocbq *pwqeOut)
4084{4084{
4085 struct lpfc_io_buf *lpfc_cmd =4085 struct lpfc_io_buf *lpfc_cmd = pwqeIn->io_buf;
4086 (struct lpfc_io_buf *)pwqeIn->context1;
4087 struct lpfc_wcqe_complete *wcqe = &pwqeOut->wcqe_cmpl;4086 struct lpfc_wcqe_complete *wcqe = &pwqeOut->wcqe_cmpl;
4088 struct lpfc_vport *vport = pwqeIn->vport;4087 struct lpfc_vport *vport = pwqeIn->vport;
4089 struct lpfc_rport_data *rdata;4088 struct lpfc_rport_data *rdata;
@@ -4276,6 +4275,7 @@ lpfc_fcp_io_cmd_wqe_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pwqeIn, · 186 unmodified lines
4276 break;4275 break;
4277 }4276 }
4278 if (lpfc_cmd->result == IOERR_INVALID_RPI ||4277 if (lpfc_cmd->result == IOERR_INVALID_RPI ||
4278 lpfc_cmd->result == IOERR_LINK_DOWN ||
4279 lpfc_cmd->result == IOERR_NO_RESOURCES ||4279 lpfc_cmd->result == IOERR_NO_RESOURCES ||
4280 lpfc_cmd->result == IOERR_ABORT_REQUESTED ||4280 lpfc_cmd->result == IOERR_ABORT_REQUESTED ||
4281 lpfc_cmd->result == IOERR_RPI_SUSPENDED ||4281 lpfc_cmd->result == IOERR_RPI_SUSPENDED ||
@@ -4420,7 +4420,7 @@ lpfc_scsi_cmd_iocb_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pIocbIn, · 138 unmodified lines
4420 struct lpfc_iocbq *pIocbOut)4420 struct lpfc_iocbq *pIocbOut)
4421{4421{
4422 struct lpfc_io_buf *lpfc_cmd =4422 struct lpfc_io_buf *lpfc_cmd =
4423 (struct lpfc_io_buf *) pIocbIn->context1;4423 (struct lpfc_io_buf *) pIocbIn->io_buf;
4424 struct lpfc_vport *vport = pIocbIn->vport;4424 struct lpfc_vport *vport = pIocbIn->vport;
4425 struct lpfc_rport_data *rdata = lpfc_cmd->rdata;4425 struct lpfc_rport_data *rdata = lpfc_cmd->rdata;
4426 struct lpfc_nodelist *pnode = rdata->pnode;4426 struct lpfc_nodelist *pnode = rdata->pnode;
@@ -4743,7 +4743,7 @@ static int lpfc_scsi_prep_cmnd_buf_s3(struct lpfc_vport *vport, · 316 unmodified lines
4743 piocbq->iocb.ulpFCP2Rcvy = 0;4743 piocbq->iocb.ulpFCP2Rcvy = 0;
4744 4744
4745 piocbq->iocb.ulpClass = (pnode->nlp_fcp_info & 0x0f);4745 piocbq->iocb.ulpClass = (pnode->nlp_fcp_info & 0x0f);
4746 piocbq->context1 = lpfc_cmd;4746 piocbq->io_buf = lpfc_cmd;
4747 if (!piocbq->cmd_cmpl)4747 if (!piocbq->cmd_cmpl)
4748 piocbq->cmd_cmpl = lpfc_scsi_cmd_iocb_cmpl;4748 piocbq->cmd_cmpl = lpfc_scsi_cmd_iocb_cmpl;
4749 piocbq->iocb.ulpTimeout = tmo;4749 piocbq->iocb.ulpTimeout = tmo;
@@ -4855,8 +4855,7 @@ static int lpfc_scsi_prep_cmnd_buf_s4(struct lpfc_vport *vport, · 105 unmodified lines
4855 bf_set(wqe_reqtag, &wqe->generic.wqe_com, pwqeq->iotag);4855 bf_set(wqe_reqtag, &wqe->generic.wqe_com, pwqeq->iotag);
4856 4856
4857 pwqeq->vport = vport;4857 pwqeq->vport = vport;
4858 pwqeq->vport = vport;4858 pwqeq->io_buf = lpfc_cmd;
4859 pwqeq->context1 = lpfc_cmd;
4860 pwqeq->hba_wqidx = lpfc_cmd->hdwq_no;4859 pwqeq->hba_wqidx = lpfc_cmd->hdwq_no;
4861 pwqeq->cmd_cmpl = lpfc_fcp_io_cmd_wqe_cmpl;4860 pwqeq->cmd_cmpl = lpfc_fcp_io_cmd_wqe_cmpl;
4862 4861
@@ -5097,8 +5096,7 @@ lpfc_tskmgmt_def_cmpl(struct lpfc_hba *phba, · 234 unmodified lines
5097 struct lpfc_iocbq *cmdiocbq,5096 struct lpfc_iocbq *cmdiocbq,
5098 struct lpfc_iocbq *rspiocbq)5097 struct lpfc_iocbq *rspiocbq)
5099{5098{
5100 struct lpfc_io_buf *lpfc_cmd =5099 struct lpfc_io_buf *lpfc_cmd = cmdiocbq->io_buf;
5101 (struct lpfc_io_buf *) cmdiocbq->context1;
5102 if (lpfc_cmd)5100 if (lpfc_cmd)
5103 lpfc_release_scsi_buf(phba, lpfc_cmd);5101 lpfc_release_scsi_buf(phba, lpfc_cmd);
5104 return;5102 return;
@@ -5346,9 +5344,9 @@ static void lpfc_vmid_update_entry(struct lpfc_vport *vport, struct scsi_cmnd · 241 unmodified lines
5346{5344{
5347 u64 *lta;5345 u64 *lta;
5348 5346
5349 if (vport->vmid_priority_tagging)5347 if (vport->phba->pport->vmid_flag & LPFC_VMID_TYPE_PRIO)
5350 tag->cs_ctl_vmid = vmp->un.cs_ctl_vmid;5348 tag->cs_ctl_vmid = vmp->un.cs_ctl_vmid;
5351 else5349 else if (vport->phba->cfg_vmid_app_header)
5352 tag->app_id = vmp->un.app_id;5350 tag->app_id = vmp->un.app_id;
5353 5351
5354 if (cmd->sc_data_direction == DMA_TO_DEVICE)5352 if (cmd->sc_data_direction == DMA_TO_DEVICE)
@@ -5393,11 +5391,12 @@ static int lpfc_vmid_get_appid(struct lpfc_vport *vport, char *uuid, struct · 38 unmodified lines
5393 scsi_cmnd * cmd, union lpfc_vmid_io_tag *tag)5391 scsi_cmnd * cmd, union lpfc_vmid_io_tag *tag)
5394{5392{
5395 struct lpfc_vmid *vmp = NULL;5393 struct lpfc_vmid *vmp = NULL;
5396 int hash, len, rc, i;5394 int hash, len, rc = -EPERM, i;
5397 5395
5398 /* check if QFPA is complete */5396 /* check if QFPA is complete */
5399 if (lpfc_vmid_is_type_priority_tag(vport) && !(vport->vmid_flag &5397 if (lpfc_vmid_is_type_priority_tag(vport) &&
5400 LPFC_VMID_QFPA_CMPL)) {5398 !(vport->vmid_flag & LPFC_VMID_QFPA_CMPL) &&
5399 (vport->vmid_flag & LPFC_VMID_ISSUE_QFPA)) {
5401 vport->work_port_events |= WORKER_CHECK_VMID_ISSUE_QFPA;5400 vport->work_port_events |= WORKER_CHECK_VMID_ISSUE_QFPA;
5402 return -EAGAIN;5401 return -EAGAIN;
5403 }5402 }
@@ -5471,7 +5470,7 @@ static int lpfc_vmid_get_appid(struct lpfc_vport *vport, char *uuid, struct · 67 unmodified lines
5471 vport->vmid_inactivity_timeout ? 1 : 0;5470 vport->vmid_inactivity_timeout ? 1 : 0;
5472 5471
5473 /* if type priority tag, get next available VMID */5472 /* if type priority tag, get next available VMID */
5474 if (lpfc_vmid_is_type_priority_tag(vport))5473 if (vport->phba->pport->vmid_flag & LPFC_VMID_TYPE_PRIO)
5475 lpfc_vmid_assign_cs_ctl(vport, vmp);5474 lpfc_vmid_assign_cs_ctl(vport, vmp);
5476 5475
5477 /* allocate the per cpu variable for holding */5476 /* allocate the per cpu variable for holding */
@@ -5490,9 +5489,9 @@ static int lpfc_vmid_get_appid(struct lpfc_vport *vport, char *uuid, struct · 12 unmodified lines
5490 write_unlock(&vport->vmid_lock);5489 write_unlock(&vport->vmid_lock);
5491 5490
5492 /* complete transaction with switch */5491 /* complete transaction with switch */
5493 if (lpfc_vmid_is_type_priority_tag(vport))5492 if (vport->phba->pport->vmid_flag & LPFC_VMID_TYPE_PRIO)
5494 rc = lpfc_vmid_uvem(vport, vmp, true);5493 rc = lpfc_vmid_uvem(vport, vmp, true);
5495 else5494 else if (vport->phba->cfg_vmid_app_header)
5496 rc = lpfc_vmid_cmd(vport, SLI_CTAS_RAPP_IDENT, vmp);5495 rc = lpfc_vmid_cmd(vport, SLI_CTAS_RAPP_IDENT, vmp);
5497 if (!rc) {5496 if (!rc) {
5498 write_lock(&vport->vmid_lock);5497 write_lock(&vport->vmid_lock);
@@ -5866,25 +5865,25 @@ lpfc_abort_handler(struct scsi_cmnd *cmnd) · 367 unmodified lines
5866 if (!lpfc_cmd)5865 if (!lpfc_cmd)
5867 return ret;5866 return ret;
5868 5867
5869 spin_lock_irqsave(&phba->hbalock, flags);5868 /* Guard against IO completion being called at same time */
5869 spin_lock_irqsave(&lpfc_cmd->buf_lock, flags);
5870
5871 spin_lock(&phba->hbalock);
5870 /* driver queued commands are in process of being flushed */5872 /* driver queued commands are in process of being flushed */
5871 if (phba->hba_flag & HBA_IOQ_FLUSH) {5873 if (phba->hba_flag & HBA_IOQ_FLUSH) {
5872 lpfc_printf_vlog(vport, KERN_WARNING, LOG_FCP,5874 lpfc_printf_vlog(vport, KERN_WARNING, LOG_FCP,
5873 "3168 SCSI Layer abort requested I/O has been "5875 "3168 SCSI Layer abort requested I/O has been "
5874 "flushed by LLD.\n");5876 "flushed by LLD.\n");
5875 ret = FAILED;5877 ret = FAILED;
5876 goto out_unlock;5878 goto out_unlock_hba;
5877 }5879 }
5878 5880
5879 /* Guard against IO completion being called at same time */
5880 spin_lock(&lpfc_cmd->buf_lock);
5881
5882 if (!lpfc_cmd->pCmd) {5881 if (!lpfc_cmd->pCmd) {
5883 lpfc_printf_vlog(vport, KERN_WARNING, LOG_FCP,5882 lpfc_printf_vlog(vport, KERN_WARNING, LOG_FCP,
5884 "2873 SCSI Layer I/O Abort Request IO CMPL Status "5883 "2873 SCSI Layer I/O Abort Request IO CMPL Status "
5885 "x%x ID %d LUN %llu\n",5884 "x%x ID %d LUN %llu\n",
5886 SUCCESS, cmnd->device->id, cmnd->device->lun);5885 SUCCESS, cmnd->device->id, cmnd->device->lun);
5887 goto out_unlock_buf;5886 goto out_unlock_hba;
5888 }5887 }
5889 5888
5890 iocb = &lpfc_cmd->cur_iocbq;5889 iocb = &lpfc_cmd->cur_iocbq;
@@ -5892,7 +5891,7 @@ lpfc_abort_handler(struct scsi_cmnd *cmnd) · 1 unmodified line
5892 pring_s4 = phba->sli4_hba.hdwq[iocb->hba_wqidx].io_wq->pring;5891 pring_s4 = phba->sli4_hba.hdwq[iocb->hba_wqidx].io_wq->pring;
5893 if (!pring_s4) {5892 if (!pring_s4) {
5894 ret = FAILED;5893 ret = FAILED;
5895 goto out_unlock_buf;5894 goto out_unlock_hba;
5896 }5895 }
5897 spin_lock(&pring_s4->ring_lock);5896 spin_lock(&pring_s4->ring_lock);
5898 }5897 }
@@ -5917,7 +5916,7 @@ lpfc_abort_handler(struct scsi_cmnd *cmnd) · 18 unmodified lines
5917 goto out_unlock_ring;5916 goto out_unlock_ring;
5918 }5917 }
5919 5918
5920 BUG_ON(iocb->context1 != lpfc_cmd);5919 WARN_ON(iocb->io_buf != lpfc_cmd);
5921 5920
5922 /* abort issued in recovery is still in progress */5921 /* abort issued in recovery is still in progress */
5923 if (iocb->cmd_flag & LPFC_DRIVER_ABORTED) {5922 if (iocb->cmd_flag & LPFC_DRIVER_ABORTED) {
@@ -5925,8 +5924,8 @@ lpfc_abort_handler(struct scsi_cmnd *cmnd) · 1 unmodified line
5925 "3389 SCSI Layer I/O Abort Request is pending\n");5924 "3389 SCSI Layer I/O Abort Request is pending\n");
5926 if (phba->sli_rev == LPFC_SLI_REV4)5925 if (phba->sli_rev == LPFC_SLI_REV4)
5927 spin_unlock(&pring_s4->ring_lock);5926 spin_unlock(&pring_s4->ring_lock);
5928 spin_unlock(&lpfc_cmd->buf_lock);5927 spin_unlock(&phba->hbalock);
5929 spin_unlock_irqrestore(&phba->hbalock, flags);5928 spin_unlock_irqrestore(&lpfc_cmd->buf_lock, flags);
5930 goto wait_for_cmpl;5929 goto wait_for_cmpl;
5931 }5930 }
5932 5931
@@ -5947,15 +5946,13 @@ lpfc_abort_handler(struct scsi_cmnd *cmnd) · 14 unmodified lines
5947 if (ret_val != IOCB_SUCCESS) {5946 if (ret_val != IOCB_SUCCESS) {
5948 /* Indicate the IO is not being aborted by the driver. */5947 /* Indicate the IO is not being aborted by the driver. */
5949 lpfc_cmd->waitq = NULL;5948 lpfc_cmd->waitq = NULL;
5950 spin_unlock(&lpfc_cmd->buf_lock);
5951 spin_unlock_irqrestore(&phba->hbalock, flags);
5952 ret = FAILED;5949 ret = FAILED;
5953 goto out;5950 goto out_unlock_hba;
5954 }5951 }
5955 5952
5956 /* no longer need the lock after this point */5953 /* no longer need the lock after this point */
5957 spin_unlock(&lpfc_cmd->buf_lock);5954 spin_unlock(&phba->hbalock);
5958 spin_unlock_irqrestore(&phba->hbalock, flags);5955 spin_unlock_irqrestore(&lpfc_cmd->buf_lock, flags);
5959 5956
5960 if (phba->cfg_poll & DISABLE_FCP_RING_INT)5957 if (phba->cfg_poll & DISABLE_FCP_RING_INT)
5961 lpfc_sli_handle_fast_ring_event(phba,5958 lpfc_sli_handle_fast_ring_event(phba,
@@ -5990,10 +5987,9 @@ wait_for_cmpl: · 28 unmodified lines
5990out_unlock_ring:5987out_unlock_ring:
5991 if (phba->sli_rev == LPFC_SLI_REV4)5988 if (phba->sli_rev == LPFC_SLI_REV4)
5992 spin_unlock(&pring_s4->ring_lock);5989 spin_unlock(&pring_s4->ring_lock);
5993out_unlock_buf:5990out_unlock_hba:
5994 spin_unlock(&lpfc_cmd->buf_lock);5991 spin_unlock(&phba->hbalock);
5995out_unlock:5992 spin_unlock_irqrestore(&lpfc_cmd->buf_lock, flags);
5996 spin_unlock_irqrestore(&phba->hbalock, flags);
5997out:5993out:
5998 lpfc_printf_vlog(vport, KERN_WARNING, LOG_FCP,5994 lpfc_printf_vlog(vport, KERN_WARNING, LOG_FCP,
5999 "0749 SCSI Layer I/O Abort Request Status x%x ID %d "5995 "0749 SCSI Layer I/O Abort Request Status x%x ID %d "
drivers/scsi/lpfc/lpfc_sli.c+129−141
@@ -1254,19 +1254,19 @@ __lpfc_sli_get_els_sglq(struct lpfc_hba *phba, struct lpfc_iocbq *piocbq) · 1253 unmodified lines
1254 1254
1255 cmnd = get_job_cmnd(phba, piocbq);1255 cmnd = get_job_cmnd(phba, piocbq);
1256 1256
1257 if (piocbq->cmd_flag & LPFC_IO_FCP) {1257 if (piocbq->cmd_flag & LPFC_IO_FCP) {
1258 lpfc_cmd = (struct lpfc_io_buf *) piocbq->context1;1258 lpfc_cmd = piocbq->io_buf;
1259 ndlp = lpfc_cmd->rdata->pnode;1259 ndlp = lpfc_cmd->rdata->pnode;
1260 } else if ((cmnd == CMD_GEN_REQUEST64_CR) &&1260 } else if ((cmnd == CMD_GEN_REQUEST64_CR) &&
1261 !(piocbq->cmd_flag & LPFC_IO_LIBDFC)) {1261 !(piocbq->cmd_flag & LPFC_IO_LIBDFC)) {
1262 ndlp = piocbq->context_un.ndlp;1262 ndlp = piocbq->ndlp;
1263 } else if (piocbq->cmd_flag & LPFC_IO_LIBDFC) {1263 } else if (piocbq->cmd_flag & LPFC_IO_LIBDFC) {
1264 if (piocbq->cmd_flag & LPFC_IO_LOOPBACK)1264 if (piocbq->cmd_flag & LPFC_IO_LOOPBACK)
1265 ndlp = NULL;1265 ndlp = NULL;
1266 else1266 else
1267 ndlp = piocbq->context_un.ndlp;1267 ndlp = piocbq->ndlp;
1268 } else {1268 } else {
1269 ndlp = piocbq->context1;1269 ndlp = piocbq->ndlp;
1270 }1270 }
1271 1271
1272 spin_lock(&phba->sli4_hba.sgl_list_lock);1272 spin_lock(&phba->sli4_hba.sgl_list_lock);
@@ -1373,7 +1373,7 @@ static void · 100 unmodified lines
1373__lpfc_sli_release_iocbq_s4(struct lpfc_hba *phba, struct lpfc_iocbq *iocbq)1373__lpfc_sli_release_iocbq_s4(struct lpfc_hba *phba, struct lpfc_iocbq *iocbq)
1374{1374{
1375 struct lpfc_sglq *sglq;1375 struct lpfc_sglq *sglq;
1376 size_t start_clean = offsetof(struct lpfc_iocbq, iocb);1376 size_t start_clean = offsetof(struct lpfc_iocbq, wqe);
1377 unsigned long iflag = 0;1377 unsigned long iflag = 0;
1378 struct lpfc_sli_ring *pring;1378 struct lpfc_sli_ring *pring;
1379 1379
@@ -1996,9 +1996,9 @@ initpath: · 616 unmodified lines
1996 1996
1997 sync_buf->vport = phba->pport;1997 sync_buf->vport = phba->pport;
1998 sync_buf->cmd_cmpl = lpfc_cmf_sync_cmpl;1998 sync_buf->cmd_cmpl = lpfc_cmf_sync_cmpl;
1999 sync_buf->context1 = NULL;1999 sync_buf->cmd_dmabuf = NULL;
2000 sync_buf->context2 = NULL;2000 sync_buf->rsp_dmabuf = NULL;
2001 sync_buf->context3 = NULL;2001 sync_buf->bpl_dmabuf = NULL;
2002 sync_buf->sli4_xritag = NO_XRI;2002 sync_buf->sli4_xritag = NO_XRI;
2003 2003
2004 sync_buf->cmd_flag |= LPFC_IO_CMF;2004 sync_buf->cmd_flag |= LPFC_IO_CMF;
@@ -2848,19 +2848,11 @@ void · 843 unmodified lines
2848lpfc_sli_def_mbox_cmpl(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)2848lpfc_sli_def_mbox_cmpl(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
2849{2849{
2850 struct lpfc_vport *vport = pmb->vport;2850 struct lpfc_vport *vport = pmb->vport;
2851 struct lpfc_dmabuf *mp;
2852 struct lpfc_nodelist *ndlp;2851 struct lpfc_nodelist *ndlp;
2853 struct Scsi_Host *shost;2852 struct Scsi_Host *shost;
2854 uint16_t rpi, vpi;2853 uint16_t rpi, vpi;
2855 int rc;2854 int rc;
2856 2855
2857 mp = (struct lpfc_dmabuf *)(pmb->ctx_buf);
2858
2859 if (mp) {
2860 lpfc_mbuf_free(phba, mp->virt, mp->phys);
2861 kfree(mp);
2862 }
2863
2864 /*2856 /*
2865 * If a REG_LOGIN succeeded after node is destroyed or node2857 * If a REG_LOGIN succeeded after node is destroyed or node
2866 * is in re-discovery driver need to cleanup the RPI.2858 * is in re-discovery driver need to cleanup the RPI.
@@ -2893,8 +2885,6 @@ lpfc_sli_def_mbox_cmpl(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) · 26 unmodified lines
2893 if (pmb->u.mb.mbxCommand == MBX_REG_LOGIN64) {2885 if (pmb->u.mb.mbxCommand == MBX_REG_LOGIN64) {
2894 ndlp = (struct lpfc_nodelist *)pmb->ctx_ndlp;2886 ndlp = (struct lpfc_nodelist *)pmb->ctx_ndlp;
2895 lpfc_nlp_put(ndlp);2887 lpfc_nlp_put(ndlp);
2896 pmb->ctx_buf = NULL;
2897 pmb->ctx_ndlp = NULL;
2898 }2888 }
2899 2889
2900 if (pmb->u.mb.mbxCommand == MBX_UNREG_LOGIN) {2890 if (pmb->u.mb.mbxCommand == MBX_UNREG_LOGIN) {
@@ -2945,7 +2935,7 @@ lpfc_sli_def_mbox_cmpl(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) · 44 unmodified lines
2945 if (bf_get(lpfc_mqe_command, &pmb->u.mqe) == MBX_SLI4_CONFIG)2935 if (bf_get(lpfc_mqe_command, &pmb->u.mqe) == MBX_SLI4_CONFIG)
2946 lpfc_sli4_mbox_cmd_free(phba, pmb);2936 lpfc_sli4_mbox_cmd_free(phba, pmb);
2947 else2937 else
2948 mempool_free(pmb, phba->mbox_mem_pool);2938 lpfc_mbox_rsrc_cleanup(phba, pmb, MBOX_THD_UNLOCKED);
2949}2939}
2950 /**2940 /**
2951 * lpfc_sli4_unreg_rpi_cmpl_clr - mailbox completion handler2941 * lpfc_sli4_unreg_rpi_cmpl_clr - mailbox completion handler
@@ -3197,7 +3187,7 @@ lpfc_nvme_unsol_ls_handler(struct lpfc_hba *phba, struct lpfc_iocbq *piocb) · 245 unmodified lines
3197 uint32_t oxid, sid, did, fctl, size;3187 uint32_t oxid, sid, did, fctl, size;
3198 int ret = 1;3188 int ret = 1;
3199 3189
3200 d_buf = piocb->context2;3190 d_buf = piocb->cmd_dmabuf;
3201 3191
3202 nvmebuf = container_of(d_buf, struct hbq_dmabuf, dbuf);3192 nvmebuf = container_of(d_buf, struct hbq_dmabuf, dbuf);
3203 fc_hdr = nvmebuf->hbuf.virt;3193 fc_hdr = nvmebuf->hbuf.virt;
@@ -3478,9 +3468,9 @@ lpfc_sli_process_unsol_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, · 274 unmodified lines
3478 3468
3479 if (phba->sli3_options & LPFC_SLI3_HBQ_ENABLED) {3469 if (phba->sli3_options & LPFC_SLI3_HBQ_ENABLED) {
3480 if (irsp->ulpBdeCount != 0) {3470 if (irsp->ulpBdeCount != 0) {
3481 saveq->context2 = lpfc_sli_get_buff(phba, pring,3471 saveq->cmd_dmabuf = lpfc_sli_get_buff(phba, pring,
3482 irsp->un.ulpWord[3]);3472 irsp->un.ulpWord[3]);
3483 if (!saveq->context2)3473 if (!saveq->cmd_dmabuf)
3484 lpfc_printf_log(phba,3474 lpfc_printf_log(phba,
3485 KERN_ERR,3475 KERN_ERR,
3486 LOG_SLI,3476 LOG_SLI,
@@ -3490,9 +3480,9 @@ lpfc_sli_process_unsol_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, · 3 unmodified lines
3490 irsp->un.ulpWord[3]);3480 irsp->un.ulpWord[3]);
3491 }3481 }
3492 if (irsp->ulpBdeCount == 2) {3482 if (irsp->ulpBdeCount == 2) {
3493 saveq->context3 = lpfc_sli_get_buff(phba, pring,3483 saveq->bpl_dmabuf = lpfc_sli_get_buff(phba, pring,
3494 irsp->unsli3.sli3Words[7]);3484 irsp->unsli3.sli3Words[7]);
3495 if (!saveq->context3)3485 if (!saveq->bpl_dmabuf)
3496 lpfc_printf_log(phba,3486 lpfc_printf_log(phba,
3497 KERN_ERR,3487 KERN_ERR,
3498 LOG_SLI,3488 LOG_SLI,
@@ -3504,10 +3494,10 @@ lpfc_sli_process_unsol_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, · 5 unmodified lines
3504 list_for_each_entry(iocbq, &saveq->list, list) {3494 list_for_each_entry(iocbq, &saveq->list, list) {
3505 irsp = &iocbq->iocb;3495 irsp = &iocbq->iocb;
3506 if (irsp->ulpBdeCount != 0) {3496 if (irsp->ulpBdeCount != 0) {
3507 iocbq->context2 = lpfc_sli_get_buff(phba,3497 iocbq->cmd_dmabuf = lpfc_sli_get_buff(phba,
3508 pring,3498 pring,
3509 irsp->un.ulpWord[3]);3499 irsp->un.ulpWord[3]);
3510 if (!iocbq->context2)3500 if (!iocbq->cmd_dmabuf)
3511 lpfc_printf_log(phba,3501 lpfc_printf_log(phba,
3512 KERN_ERR,3502 KERN_ERR,
3513 LOG_SLI,3503 LOG_SLI,
@@ -3517,10 +3507,10 @@ lpfc_sli_process_unsol_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, · 3 unmodified lines
3517 irsp->un.ulpWord[3]);3507 irsp->un.ulpWord[3]);
3518 }3508 }
3519 if (irsp->ulpBdeCount == 2) {3509 if (irsp->ulpBdeCount == 2) {
3520 iocbq->context3 = lpfc_sli_get_buff(phba,3510 iocbq->bpl_dmabuf = lpfc_sli_get_buff(phba,
3521 pring,3511 pring,
3522 irsp->unsli3.sli3Words[7]);3512 irsp->unsli3.sli3Words[7]);
3523 if (!iocbq->context3)3513 if (!iocbq->bpl_dmabuf)
3524 lpfc_printf_log(phba,3514 lpfc_printf_log(phba,
3525 KERN_ERR,3515 KERN_ERR,
3526 LOG_SLI,3516 LOG_SLI,
@@ -3534,12 +3524,12 @@ lpfc_sli_process_unsol_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, · 7 unmodified lines
3534 } else {3524 } else {
3535 paddr = getPaddr(irsp->un.cont64[0].addrHigh,3525 paddr = getPaddr(irsp->un.cont64[0].addrHigh,
3536 irsp->un.cont64[0].addrLow);3526 irsp->un.cont64[0].addrLow);
3537 saveq->context2 = lpfc_sli_ringpostbuf_get(phba, pring,3527 saveq->cmd_dmabuf = lpfc_sli_ringpostbuf_get(phba, pring,
3538 paddr);3528 paddr);
3539 if (irsp->ulpBdeCount == 2) {3529 if (irsp->ulpBdeCount == 2) {
3540 paddr = getPaddr(irsp->un.cont64[1].addrHigh,3530 paddr = getPaddr(irsp->un.cont64[1].addrHigh,
3541 irsp->un.cont64[1].addrLow);3531 irsp->un.cont64[1].addrLow);
3542 saveq->context3 = lpfc_sli_ringpostbuf_get(phba,3532 saveq->bpl_dmabuf = lpfc_sli_ringpostbuf_get(phba,
3543 pring,3533 pring,
3544 paddr);3534 paddr);
3545 }3535 }
@@ -3717,7 +3707,6 @@ lpfc_sli_process_sol_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, · 171 unmodified lines
3717 struct lpfc_iocbq *saveq)3707 struct lpfc_iocbq *saveq)
3718{3708{
3719 struct lpfc_iocbq *cmdiocbp;3709 struct lpfc_iocbq *cmdiocbp;
3720 int rc = 1;
3721 unsigned long iflag;3710 unsigned long iflag;
3722 u32 ulp_command, ulp_status, ulp_word4, ulp_context, iotag;3711 u32 ulp_command, ulp_status, ulp_word4, ulp_context, iotag;
3723 3712
@@ -3857,7 +3846,7 @@ lpfc_sli_process_sol_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, · 133 unmodified lines
3857 }3846 }
3858 }3847 }
3859 3848
3860 return rc;3849 return 1;
3861}3850}
3862 3851
3863/**3852/**
@@ -5275,6 +5264,7 @@ lpfc_sli_brdrestart_s4(struct lpfc_hba *phba) · 1411 unmodified lines
5275 phba->pport->stopped = 0;5264 phba->pport->stopped = 0;
5276 phba->link_state = LPFC_INIT_START;5265 phba->link_state = LPFC_INIT_START;
5277 phba->hba_flag = 0;5266 phba->hba_flag = 0;
5267 phba->sli4_hba.fawwpn_flag = 0;
5278 spin_unlock_irq(&phba->hbalock);5268 spin_unlock_irq(&phba->hbalock);
5279 5269
5280 memset(&psli->lnk_stat_offsets, 0, sizeof(psli->lnk_stat_offsets));5270 memset(&psli->lnk_stat_offsets, 0, sizeof(psli->lnk_stat_offsets));
@@ -5851,26 +5841,20 @@ lpfc_sli4_read_fcoe_params(struct lpfc_hba *phba) · 570 unmodified lines
5851 mboxq->mcqe.trailer);5841 mboxq->mcqe.trailer);
5852 5842
5853 if (rc) {5843 if (rc) {
5854 lpfc_mbuf_free(phba, mp->virt, mp->phys);
5855 kfree(mp);
5856 rc = -EIO;5844 rc = -EIO;
5857 goto out_free_mboxq;5845 goto out_free_mboxq;
5858 }5846 }
5859 data_length = mqe->un.mb_words[5];5847 data_length = mqe->un.mb_words[5];
5860 if (data_length > DMP_RGN23_SIZE) {5848 if (data_length > DMP_RGN23_SIZE) {
5861 lpfc_mbuf_free(phba, mp->virt, mp->phys);
5862 kfree(mp);
5863 rc = -EIO;5849 rc = -EIO;
5864 goto out_free_mboxq;5850 goto out_free_mboxq;
5865 }5851 }
5866 5852
5867 lpfc_parse_fcoe_conf(phba, mp->virt, data_length);5853 lpfc_parse_fcoe_conf(phba, mp->virt, data_length);
5868 lpfc_mbuf_free(phba, mp->virt, mp->phys);
5869 kfree(mp);
5870 rc = 0;5854 rc = 0;
5871 5855
5872out_free_mboxq:5856out_free_mboxq:
5873 mempool_free(mboxq, phba->mbox_mem_pool);5857 lpfc_mbox_rsrc_cleanup(phba, mboxq, MBOX_THD_UNLOCKED);
5874 return rc;5858 return rc;
5875}5859}
5876 5860
@@ -7994,10 +7978,6 @@ lpfc_cmf_setup(struct lpfc_hba *phba) · 2117 unmodified lines
7994 7978
7995 sli4_params = &phba->sli4_hba.pc_sli4_params;7979 sli4_params = &phba->sli4_hba.pc_sli4_params;
7996 7980
7997 /* Are we forcing MI off via module parameter? */
7998 if (!phba->cfg_enable_mi)
7999 sli4_params->mi_ver = 0;
8000
8001 /* Always try to enable MI feature if we can */7981 /* Always try to enable MI feature if we can */
8002 if (sli4_params->mi_ver) {7982 if (sli4_params->mi_ver) {
8003 lpfc_set_features(phba, mboxq, LPFC_SET_ENABLE_MI);7983 lpfc_set_features(phba, mboxq, LPFC_SET_ENABLE_MI);
@@ -8543,8 +8523,9 @@ lpfc_sli4_hba_setup(struct lpfc_hba *phba) · 539 unmodified lines
8543 }8523 }
8544 8524
8545 /*8525 /*
8546 * This memory was allocated by the lpfc_read_sparam routine. Release8526 * This memory was allocated by the lpfc_read_sparam routine but is
8547 * it to the mbuf pool.8527 * no longer needed. It is released and ctx_buf NULLed to prevent
8528 * unintended pointer access as the mbox is reused.
8548 */8529 */
8549 lpfc_mbuf_free(phba, mp->virt, mp->phys);8530 lpfc_mbuf_free(phba, mp->virt, mp->phys);
8550 kfree(mp);8531 kfree(mp);
@@ -8864,6 +8845,9 @@ lpfc_sli4_hba_setup(struct lpfc_hba *phba) · 313 unmodified lines
8864 }8845 }
8865 mempool_free(mboxq, phba->mbox_mem_pool);8846 mempool_free(mboxq, phba->mbox_mem_pool);
8866 8847
8848 /* Enable RAS FW log support */
8849 lpfc_sli4_ras_setup(phba);
8850
8867 phba->hba_flag |= HBA_SETUP;8851 phba->hba_flag |= HBA_SETUP;
8868 return rc;8852 return rc;
8869 8853
@@ -10343,8 +10327,7 @@ __lpfc_sli_issue_fcp_io_s4(struct lpfc_hba *phba, uint32_t ring_number, · 1473 unmodified lines
10343 struct lpfc_iocbq *piocb, uint32_t flag)10327 struct lpfc_iocbq *piocb, uint32_t flag)
10344{10328{
10345 int rc;10329 int rc;
10346 struct lpfc_io_buf *lpfc_cmd =10330 struct lpfc_io_buf *lpfc_cmd = piocb->io_buf;
10347 (struct lpfc_io_buf *)piocb->context1;
10348 10331
10349 lpfc_prep_embed_io(phba, lpfc_cmd);10332 lpfc_prep_embed_io(phba, lpfc_cmd);
10350 rc = lpfc_sli4_issue_wqe(phba, lpfc_cmd->hdwq, piocb);10333 rc = lpfc_sli4_issue_wqe(phba, lpfc_cmd->hdwq, piocb);
@@ -10394,11 +10377,11 @@ lpfc_prep_embed_io(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd) · 43 unmodified lines
10394 10377
10395 /* add the VMID tags as per switch response */10378 /* add the VMID tags as per switch response */
10396 if (unlikely(piocb->cmd_flag & LPFC_IO_VMID)) {10379 if (unlikely(piocb->cmd_flag & LPFC_IO_VMID)) {
10397 if (phba->pport->vmid_priority_tagging) {10380 if (phba->pport->vmid_flag & LPFC_VMID_TYPE_PRIO) {
10398 bf_set(wqe_ccpe, &wqe->fcp_iwrite.wqe_com, 1);10381 bf_set(wqe_ccpe, &wqe->fcp_iwrite.wqe_com, 1);
10399 bf_set(wqe_ccp, &wqe->fcp_iwrite.wqe_com,10382 bf_set(wqe_ccp, &wqe->fcp_iwrite.wqe_com,
10400 (piocb->vmid_tag.cs_ctl_vmid));10383 (piocb->vmid_tag.cs_ctl_vmid));
10401 } else {10384 } else if (phba->cfg_vmid_app_header) {
10402 bf_set(wqe_appid, &wqe->fcp_iwrite.wqe_com, 1);10385 bf_set(wqe_appid, &wqe->fcp_iwrite.wqe_com, 1);
10403 bf_set(wqe_wqes, &wqe->fcp_iwrite.wqe_com, 1);10386 bf_set(wqe_wqes, &wqe->fcp_iwrite.wqe_com, 1);
10404 wqe->words[31] = piocb->vmid_tag.app_id;10387 wqe->words[31] = piocb->vmid_tag.app_id;
@@ -10599,6 +10582,7 @@ __lpfc_sli_prep_els_req_rsp_s4(struct lpfc_iocbq *cmdiocbq, · 194 unmodified lines
10599 struct lpfc_hba *phba = vport->phba;10582 struct lpfc_hba *phba = vport->phba;
10600 union lpfc_wqe128 *wqe;10583 union lpfc_wqe128 *wqe;
10601 struct ulp_bde64_le *bde;10584 struct ulp_bde64_le *bde;
10585 u8 els_id;
10602 10586
10603 wqe = &cmdiocbq->wqe;10587 wqe = &cmdiocbq->wqe;
10604 memset(wqe, 0, sizeof(*wqe));10588 memset(wqe, 0, sizeof(*wqe));
@@ -10611,7 +10595,7 @@ __lpfc_sli_prep_els_req_rsp_s4(struct lpfc_iocbq *cmdiocbq, · 6 unmodified lines
10611 bde->type_size |= cpu_to_le32(ULP_BDE64_TYPE_BDE_64);10595 bde->type_size |= cpu_to_le32(ULP_BDE64_TYPE_BDE_64);
10612 10596
10613 if (expect_rsp) {10597 if (expect_rsp) {
10614 bf_set(wqe_cmnd, &wqe->els_req.wqe_com, CMD_ELS_REQUEST64_CR);10598 bf_set(wqe_cmnd, &wqe->els_req.wqe_com, CMD_ELS_REQUEST64_WQE);
10615 10599
10616 /* Transfer length */10600 /* Transfer length */
10617 wqe->els_req.payload_len = cmd_size;10601 wqe->els_req.payload_len = cmd_size;
@@ -10619,6 +10603,30 @@ __lpfc_sli_prep_els_req_rsp_s4(struct lpfc_iocbq *cmdiocbq, · 1 unmodified line
10619 10603
10620 /* DID */10604 /* DID */
10621 bf_set(wqe_els_did, &wqe->els_req.wqe_dest, did);10605 bf_set(wqe_els_did, &wqe->els_req.wqe_dest, did);
10606
10607 /* Word 11 - ELS_ID */
10608 switch (elscmd) {
10609 case ELS_CMD_PLOGI:
10610 els_id = LPFC_ELS_ID_PLOGI;
10611 break;
10612 case ELS_CMD_FLOGI:
10613 els_id = LPFC_ELS_ID_FLOGI;
10614 break;
10615 case ELS_CMD_LOGO:
10616 els_id = LPFC_ELS_ID_LOGO;
10617 break;
10618 case ELS_CMD_FDISC:
10619 if (!vport->fc_myDID) {
10620 els_id = LPFC_ELS_ID_FDISC;
10621 break;
10622 }
10623 fallthrough;
10624 default:
10625 els_id = LPFC_ELS_ID_DEFAULT;
10626 break;
10627 }
10628
10629 bf_set(wqe_els_id, &wqe->els_req.wqe_com, els_id);
10622 } else {10630 } else {
10623 /* DID */10631 /* DID */
10624 bf_set(wqe_els_did, &wqe->xmit_els_rsp.wqe_dest, did);10632 bf_set(wqe_els_did, &wqe->xmit_els_rsp.wqe_dest, did);
@@ -10627,7 +10635,7 @@ __lpfc_sli_prep_els_req_rsp_s4(struct lpfc_iocbq *cmdiocbq, · 2 unmodified lines
10627 wqe->xmit_els_rsp.response_payload_len = cmd_size;10635 wqe->xmit_els_rsp.response_payload_len = cmd_size;
10628 10636
10629 bf_set(wqe_cmnd, &wqe->xmit_els_rsp.wqe_com,10637 bf_set(wqe_cmnd, &wqe->xmit_els_rsp.wqe_com,
10630 CMD_XMIT_ELS_RSP64_CX);10638 CMD_XMIT_ELS_RSP64_WQE);
10631 }10639 }
10632 10640
10633 bf_set(wqe_tmo, &wqe->generic.wqe_com, tmo);10641 bf_set(wqe_tmo, &wqe->generic.wqe_com, tmo);
@@ -10643,7 +10651,7 @@ __lpfc_sli_prep_els_req_rsp_s4(struct lpfc_iocbq *cmdiocbq, · 9 unmodified lines
10643 if (expect_rsp) {10651 if (expect_rsp) {
10644 bf_set(els_req64_sid, &wqe->els_req, vport->fc_myDID);10652 bf_set(els_req64_sid, &wqe->els_req, vport->fc_myDID);
10645 10653
10646 /* For ELS_REQUEST64_CR, use the VPI by default */10654 /* For ELS_REQUEST64_WQE, use the VPI by default */
10647 bf_set(wqe_ctxt_tag, &wqe->els_req.wqe_com,10655 bf_set(wqe_ctxt_tag, &wqe->els_req.wqe_com,
10648 phba->vpi_ids[vport->vpi]);10656 phba->vpi_ids[vport->vpi]);
10649 }10657 }
@@ -10800,24 +10808,15 @@ __lpfc_sli_prep_xmit_seq64_s4(struct lpfc_iocbq *cmdiocbq, · 150 unmodified lines
10800{10808{
10801 union lpfc_wqe128 *wqe;10809 union lpfc_wqe128 *wqe;
10802 struct ulp_bde64 *bpl;10810 struct ulp_bde64 *bpl;
10803 struct ulp_bde64_le *bde;
10804 10811
10805 wqe = &cmdiocbq->wqe;10812 wqe = &cmdiocbq->wqe;
10806 memset(wqe, 0, sizeof(*wqe));10813 memset(wqe, 0, sizeof(*wqe));
10807 10814
10808 /* Words 0 - 2 */10815 /* Words 0 - 2 */
10809 bpl = (struct ulp_bde64 *)bmp->virt;10816 bpl = (struct ulp_bde64 *)bmp->virt;
10810 if (cmdiocbq->cmd_flag & (LPFC_IO_LIBDFC | LPFC_IO_LOOPBACK)) {10817 wqe->xmit_sequence.bde.addrHigh = bpl->addrHigh;
10811 wqe->xmit_sequence.bde.addrHigh = bpl->addrHigh;10818 wqe->xmit_sequence.bde.addrLow = bpl->addrLow;
10812 wqe->xmit_sequence.bde.addrLow = bpl->addrLow;10819 wqe->xmit_sequence.bde.tus.w = bpl->tus.w;
10813 wqe->xmit_sequence.bde.tus.w = bpl->tus.w;
10814 } else {
10815 bde = (struct ulp_bde64_le *)&wqe->xmit_sequence.bde;
10816 bde->addr_low = cpu_to_le32(putPaddrLow(bmp->phys));
10817 bde->addr_high = cpu_to_le32(putPaddrHigh(bmp->phys));
10818 bde->type_size = cpu_to_le32(bpl->tus.f.bdeSize);
10819 bde->type_size |= cpu_to_le32(ULP_BDE64_TYPE_BDE_64);
10820 }
10821 10820
10822 /* Word 5 */10821 /* Word 5 */
10823 bf_set(wqe_ls, &wqe->xmit_sequence.wge_ctl, last_seq);10822 bf_set(wqe_ls, &wqe->xmit_sequence.wge_ctl, last_seq);
@@ -10990,7 +10989,7 @@ lpfc_sli4_calc_ring(struct lpfc_hba *phba, struct lpfc_iocbq *piocb) · 166 unmodified lines
10990 * be setup based on what work queue we used.10989 * be setup based on what work queue we used.
10991 */10990 */
10992 if (!(piocb->cmd_flag & LPFC_USE_FCPWQIDX)) {10991 if (!(piocb->cmd_flag & LPFC_USE_FCPWQIDX)) {
10993 lpfc_cmd = (struct lpfc_io_buf *)piocb->context1;10992 lpfc_cmd = piocb->io_buf;
10994 piocb->hba_wqidx = lpfc_cmd->hdwq_no;10993 piocb->hba_wqidx = lpfc_cmd->hdwq_no;
10995 }10994 }
10996 return phba->sli4_hba.hdwq[piocb->hba_wqidx].io_wq->pring;10995 return phba->sli4_hba.hdwq[piocb->hba_wqidx].io_wq->pring;
@@ -12064,8 +12063,9 @@ void · 1067 unmodified lines
12064lpfc_ignore_els_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,12063lpfc_ignore_els_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
12065 struct lpfc_iocbq *rspiocb)12064 struct lpfc_iocbq *rspiocb)
12066{12065{
12067 struct lpfc_nodelist *ndlp = NULL;12066 struct lpfc_nodelist *ndlp = cmdiocb->ndlp;
12068 IOCB_t *irsp;12067 IOCB_t *irsp;
12068 LPFC_MBOXQ_t *mbox;
12069 u32 ulp_command, ulp_status, ulp_word4, iotag;12069 u32 ulp_command, ulp_status, ulp_word4, iotag;
12070 12070
12071 ulp_command = get_job_cmnd(phba, cmdiocb);12071 ulp_command = get_job_cmnd(phba, cmdiocb);
@@ -12077,25 +12077,32 @@ lpfc_ignore_els_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 5 unmodified lines
12077 } else {12077 } else {
12078 irsp = &rspiocb->iocb;12078 irsp = &rspiocb->iocb;
12079 iotag = irsp->ulpIoTag;12079 iotag = irsp->ulpIoTag;
12080
12081 /* It is possible a PLOGI_RJT for NPIV ports to get aborted.
12082 * The MBX_REG_LOGIN64 mbox command is freed back to the
12083 * mbox_mem_pool here.
12084 */
12085 if (cmdiocb->context_un.mbox) {
12086 mbox = cmdiocb->context_un.mbox;
12087 lpfc_mbox_rsrc_cleanup(phba, mbox, MBOX_THD_UNLOCKED);
12088 cmdiocb->context_un.mbox = NULL;
12089 }
12080 }12090 }
12081 12091
12082 /* ELS cmd tag <ulpIoTag> completes */12092 /* ELS cmd tag <ulpIoTag> completes */
12083 lpfc_printf_log(phba, KERN_INFO, LOG_ELS,12093 lpfc_printf_log(phba, KERN_INFO, LOG_ELS,
12084 "0139 Ignoring ELS cmd code x%x completion Data: "12094 "0139 Ignoring ELS cmd code x%x completion Data: "
12085 "x%x x%x x%x\n",12095 "x%x x%x x%x x%px\n",
12086 ulp_command, ulp_status, ulp_word4, iotag);12096 ulp_command, ulp_status, ulp_word4, iotag,
12087 12097 cmdiocb->ndlp);
12088 /*12098 /*
12089 * Deref the ndlp after free_iocb. sli_release_iocb will access the ndlp12099 * Deref the ndlp after free_iocb. sli_release_iocb will access the ndlp
12090 * if exchange is busy.12100 * if exchange is busy.
12091 */12101 */
12092 if (ulp_command == CMD_GEN_REQUEST64_CR) {12102 if (ulp_command == CMD_GEN_REQUEST64_CR)
12093 ndlp = cmdiocb->context_un.ndlp;
12094 lpfc_ct_free_iocb(phba, cmdiocb);12103 lpfc_ct_free_iocb(phba, cmdiocb);
12095 } else {12104 else
12096 ndlp = (struct lpfc_nodelist *) cmdiocb->context1;
12097 lpfc_els_free_iocb(phba, cmdiocb);12105 lpfc_els_free_iocb(phba, cmdiocb);
12098 }
12099 12106
12100 lpfc_nlp_put(ndlp);12107 lpfc_nlp_put(ndlp);
12101}12108}
@@ -12176,7 +12183,7 @@ lpfc_sli_issue_abort_iotag(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, · 74 unmodified lines
12176 } else {12183 } else {
12177 iotag = cmdiocb->iocb.ulpIoTag;12184 iotag = cmdiocb->iocb.ulpIoTag;
12178 if (pring->ringno == LPFC_ELS_RING) {12185 if (pring->ringno == LPFC_ELS_RING) {
12179 ndlp = (struct lpfc_nodelist *)(cmdiocb->context1);12186 ndlp = cmdiocb->ndlp;
12180 ulp_context = ndlp->nlp_rpi;12187 ulp_context = ndlp->nlp_rpi;
12181 } else {12188 } else {
12182 ulp_context = cmdiocb->iocb.ulpContext;12189 ulp_context = cmdiocb->iocb.ulpContext;
@@ -12185,7 +12192,8 @@ lpfc_sli_issue_abort_iotag(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, · 2 unmodified lines
12185 12192
12186 if (phba->link_state < LPFC_LINK_UP ||12193 if (phba->link_state < LPFC_LINK_UP ||
12187 (phba->sli_rev == LPFC_SLI_REV4 &&12194 (phba->sli_rev == LPFC_SLI_REV4 &&
12188 phba->sli4_hba.link_state.status == LPFC_FC_LA_TYPE_LINK_DOWN))12195 phba->sli4_hba.link_state.status == LPFC_FC_LA_TYPE_LINK_DOWN) ||
12196 (phba->link_flag & LS_EXTERNAL_LOOPBACK))
12189 ia = true;12197 ia = true;
12190 else12198 else
12191 ia = false;12199 ia = false;
@@ -12634,7 +12642,7 @@ lpfc_sli_abort_taskmgmt(struct lpfc_vport *vport, struct lpfc_sli_ring *pring, · 442 unmodified lines
12634 } else {12642 } else {
12635 iotag = iocbq->iocb.ulpIoTag;12643 iotag = iocbq->iocb.ulpIoTag;
12636 if (pring->ringno == LPFC_ELS_RING) {12644 if (pring->ringno == LPFC_ELS_RING) {
12637 ndlp = (struct lpfc_nodelist *)(iocbq->context1);12645 ndlp = iocbq->ndlp;
12638 ulp_context = ndlp->nlp_rpi;12646 ulp_context = ndlp->nlp_rpi;
12639 } else {12647 } else {
12640 ulp_context = iocbq->iocb.ulpContext;12648 ulp_context = iocbq->iocb.ulpContext;
@@ -12644,7 +12652,8 @@ lpfc_sli_abort_taskmgmt(struct lpfc_vport *vport, struct lpfc_sli_ring *pring, · 3 unmodified lines
12644 ndlp = lpfc_cmd->rdata->pnode;12652 ndlp = lpfc_cmd->rdata->pnode;
12645 12653
12646 if (lpfc_is_link_up(phba) &&12654 if (lpfc_is_link_up(phba) &&
12647 (ndlp && ndlp->nlp_state == NLP_STE_MAPPED_NODE))12655 (ndlp && ndlp->nlp_state == NLP_STE_MAPPED_NODE) &&
12656 !(phba->link_flag & LS_EXTERNAL_LOOPBACK))
12648 ia = false;12657 ia = false;
12649 else12658 else
12650 ia = true;12659 ia = true;
@@ -12739,8 +12748,8 @@ lpfc_sli_wake_iocb_wait(struct lpfc_hba *phba, · 88 unmodified lines
12739 12748
12740 /* Copy the contents of the local rspiocb into the caller's buffer. */12749 /* Copy the contents of the local rspiocb into the caller's buffer. */
12741 cmdiocbq->cmd_flag |= LPFC_IO_WAKE;12750 cmdiocbq->cmd_flag |= LPFC_IO_WAKE;
12742 if (cmdiocbq->context2 && rspiocbq)12751 if (cmdiocbq->rsp_iocb && rspiocbq)
12743 memcpy((char *)cmdiocbq->context2 + offset,12752 memcpy((char *)cmdiocbq->rsp_iocb + offset,
12744 (char *)rspiocbq + offset, sizeof(*rspiocbq) - offset);12753 (char *)rspiocbq + offset, sizeof(*rspiocbq) - offset);
12745 12754
12746 /* Set the exchange busy flag for task management commands */12755 /* Set the exchange busy flag for task management commands */
@@ -12848,13 +12857,13 @@ lpfc_sli_issue_iocb_wait(struct lpfc_hba *phba, · 101 unmodified lines
12848 } else12857 } else
12849 pring = &phba->sli.sli3_ring[ring_number];12858 pring = &phba->sli.sli3_ring[ring_number];
12850 /*12859 /*
12851 * If the caller has provided a response iocbq buffer, then context212860 * If the caller has provided a response iocbq buffer, then rsp_iocb
12852 * is NULL or its an error.12861 * is NULL or its an error.
12853 */12862 */
12854 if (prspiocbq) {12863 if (prspiocbq) {
12855 if (piocb->context2)12864 if (piocb->rsp_iocb)
12856 return IOCB_ERROR;12865 return IOCB_ERROR;
12857 piocb->context2 = prspiocbq;12866 piocb->rsp_iocb = prspiocbq;
12858 }12867 }
12859 12868
12860 piocb->wait_cmd_cmpl = piocb->cmd_cmpl;12869 piocb->wait_cmd_cmpl = piocb->cmd_cmpl;
@@ -12938,7 +12947,7 @@ lpfc_sli_issue_iocb_wait(struct lpfc_hba *phba, · 77 unmodified lines
12938 }12947 }
12939 12948
12940 if (prspiocbq)12949 if (prspiocbq)
12941 piocb->context2 = NULL;12950 piocb->rsp_iocb = NULL;
12942 12951
12943 piocb->context_un.wait_queue = NULL;12952 piocb->context_un.wait_queue = NULL;
12944 piocb->cmd_cmpl = NULL;12953 piocb->cmd_cmpl = NULL;
@@ -15732,7 +15741,6 @@ lpfc_modify_hba_eq_delay(struct lpfc_hba *phba, uint32_t startq, · 2787 unmodified lines
15732 15741
15733 mbox->vport = phba->pport;15742 mbox->vport = phba->pport;
15734 mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl;15743 mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl;
15735 mbox->ctx_buf = NULL;
15736 mbox->ctx_ndlp = NULL;15744 mbox->ctx_ndlp = NULL;
15737 rc = lpfc_sli_issue_mbox(phba, mbox, MBX_POLL);15745 rc = lpfc_sli_issue_mbox(phba, mbox, MBX_POLL);
15738 shdr = (union lpfc_sli4_cfg_shdr *) &eq_delay->header.cfg_shdr;15746 shdr = (union lpfc_sli4_cfg_shdr *) &eq_delay->header.cfg_shdr;
@@ -18107,7 +18115,6 @@ lpfc_fc_frame_check(struct lpfc_hba *phba, struct fc_frame_header *fc_hdr) · 2368 unmodified lines
18107 case FC_RCTL_ELS_REP: /* extended link services reply */18115 case FC_RCTL_ELS_REP: /* extended link services reply */
18108 case FC_RCTL_ELS4_REQ: /* FC-4 ELS request */18116 case FC_RCTL_ELS4_REQ: /* FC-4 ELS request */
18109 case FC_RCTL_ELS4_REP: /* FC-4 ELS reply */18117 case FC_RCTL_ELS4_REP: /* FC-4 ELS reply */
18110 case FC_RCTL_BA_NOP: /* basic link service NOP */
18111 case FC_RCTL_BA_ABTS: /* basic link service abort */18118 case FC_RCTL_BA_ABTS: /* basic link service abort */
18112 case FC_RCTL_BA_RMC: /* remove connection */18119 case FC_RCTL_BA_RMC: /* remove connection */
18113 case FC_RCTL_BA_ACC: /* basic accept */18120 case FC_RCTL_BA_ACC: /* basic accept */
@@ -18128,6 +18135,7 @@ lpfc_fc_frame_check(struct lpfc_hba *phba, struct fc_frame_header *fc_hdr) · 14 unmodified lines
18128 fc_vft_hdr = (struct fc_vft_header *)fc_hdr;18135 fc_vft_hdr = (struct fc_vft_header *)fc_hdr;
18129 fc_hdr = &((struct fc_frame_header *)fc_vft_hdr)[1];18136 fc_hdr = &((struct fc_frame_header *)fc_vft_hdr)[1];
18130 return lpfc_fc_frame_check(phba, fc_hdr);18137 return lpfc_fc_frame_check(phba, fc_hdr);
18138 case FC_RCTL_BA_NOP: /* basic link service NOP */
18131 default:18139 default:
18132 goto drop;18140 goto drop;
18133 }18141 }
@@ -18512,11 +18520,8 @@ lpfc_sli4_seq_abort_rsp_cmpl(struct lpfc_hba *phba, · 378 unmodified lines
18512 struct lpfc_iocbq *cmd_iocbq,18520 struct lpfc_iocbq *cmd_iocbq,
18513 struct lpfc_iocbq *rsp_iocbq)18521 struct lpfc_iocbq *rsp_iocbq)
18514{18522{
18515 struct lpfc_nodelist *ndlp;
18516
18517 if (cmd_iocbq) {18523 if (cmd_iocbq) {
18518 ndlp = (struct lpfc_nodelist *)cmd_iocbq->context1;18524 lpfc_nlp_put(cmd_iocbq->ndlp);
18519 lpfc_nlp_put(ndlp);
18520 lpfc_sli_release_iocbq(phba, cmd_iocbq);18525 lpfc_sli_release_iocbq(phba, cmd_iocbq);
18521 }18526 }
18522 18527
@@ -18600,8 +18605,8 @@ lpfc_sli4_seq_abort_rsp(struct lpfc_vport *vport, · 77 unmodified lines
18600 /* Extract the F_CTL field from FC_HDR */18605 /* Extract the F_CTL field from FC_HDR */
18601 fctl = sli4_fctl_from_fc_hdr(fc_hdr);18606 fctl = sli4_fctl_from_fc_hdr(fc_hdr);
18602 18607
18603 ctiocb->context1 = lpfc_nlp_get(ndlp);18608 ctiocb->ndlp = lpfc_nlp_get(ndlp);
18604 if (!ctiocb->context1) {18609 if (!ctiocb->ndlp) {
18605 lpfc_sli_release_iocbq(phba, ctiocb);18610 lpfc_sli_release_iocbq(phba, ctiocb);
18606 return;18611 return;
18607 }18612 }
@@ -18677,13 +18682,11 @@ lpfc_sli4_seq_abort_rsp(struct lpfc_vport *vport, · 69 unmodified lines
18677 phba->sli4_hba.rpi_ids[ndlp->nlp_rpi]);18682 phba->sli4_hba.rpi_ids[ndlp->nlp_rpi]);
18678 bf_set(wqe_cmnd, &icmd->generic.wqe_com, CMD_XMIT_BLS_RSP64_CX);18683 bf_set(wqe_cmnd, &icmd->generic.wqe_com, CMD_XMIT_BLS_RSP64_CX);
18679 18684
18680
18681 /* Xmit CT abts response on exchange <xid> */18685 /* Xmit CT abts response on exchange <xid> */
18682 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,18686 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
18683 "1200 Send BLS cmd x%x on oxid x%x Data: x%x\n",18687 "1200 Send BLS cmd x%x on oxid x%x Data: x%x\n",
18684 ctiocb->abort_rctl, oxid, phba->link_state);18688 ctiocb->abort_rctl, oxid, phba->link_state);
18685 18689
18686 lpfc_sli_prep_wqe(phba, ctiocb);
18687 rc = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, ctiocb, 0);18690 rc = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, ctiocb, 0);
18688 if (rc == IOCB_ERROR) {18691 if (rc == IOCB_ERROR) {
18689 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,18692 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
@@ -18692,7 +18695,7 @@ lpfc_sli4_seq_abort_rsp(struct lpfc_vport *vport, · 2 unmodified lines
18692 ctiocb->abort_rctl, oxid,18695 ctiocb->abort_rctl, oxid,
18693 phba->link_state);18696 phba->link_state);
18694 lpfc_nlp_put(ndlp);18697 lpfc_nlp_put(ndlp);
18695 ctiocb->context1 = NULL;18698 ctiocb->ndlp = NULL;
18696 lpfc_sli_release_iocbq(phba, ctiocb);18699 lpfc_sli_release_iocbq(phba, ctiocb);
18697 }18700 }
18698}18701}
@@ -18844,8 +18847,8 @@ lpfc_prep_seq(struct lpfc_vport *vport, struct hbq_dmabuf *seq_dmabuf) · 145 unmodified lines
18844 tot_len = bf_get(lpfc_rcqe_length,18847 tot_len = bf_get(lpfc_rcqe_length,
18845 &seq_dmabuf->cq_event.cqe.rcqe_cmpl);18848 &seq_dmabuf->cq_event.cqe.rcqe_cmpl);
18846 18849
18847 first_iocbq->context2 = &seq_dmabuf->dbuf;18850 first_iocbq->cmd_dmabuf = &seq_dmabuf->dbuf;
18848 first_iocbq->context3 = NULL;18851 first_iocbq->bpl_dmabuf = NULL;
18849 /* Keep track of the BDE count */18852 /* Keep track of the BDE count */
18850 first_iocbq->wcqe_cmpl.word3 = 1;18853 first_iocbq->wcqe_cmpl.word3 = 1;
18851 18854
@@ -18869,8 +18872,8 @@ lpfc_prep_seq(struct lpfc_vport *vport, struct hbq_dmabuf *seq_dmabuf) · 17 unmodified lines
18869 lpfc_in_buf_free(vport->phba, d_buf);18872 lpfc_in_buf_free(vport->phba, d_buf);
18870 continue;18873 continue;
18871 }18874 }
18872 if (!iocbq->context3) {18875 if (!iocbq->bpl_dmabuf) {
18873 iocbq->context3 = d_buf;18876 iocbq->bpl_dmabuf = d_buf;
18874 iocbq->wcqe_cmpl.word3++;18877 iocbq->wcqe_cmpl.word3++;
18875 /* We need to get the size out of the right CQE */18878 /* We need to get the size out of the right CQE */
18876 hbq_buf = container_of(d_buf, struct hbq_dmabuf, dbuf);18879 hbq_buf = container_of(d_buf, struct hbq_dmabuf, dbuf);
@@ -18896,8 +18899,8 @@ lpfc_prep_seq(struct lpfc_vport *vport, struct hbq_dmabuf *seq_dmabuf) · 19 unmodified lines
18896 hbq_buf = container_of(d_buf, struct hbq_dmabuf, dbuf);18899 hbq_buf = container_of(d_buf, struct hbq_dmabuf, dbuf);
18897 len = bf_get(lpfc_rcqe_length,18900 len = bf_get(lpfc_rcqe_length,
18898 &hbq_buf->cq_event.cqe.rcqe_cmpl);18901 &hbq_buf->cq_event.cqe.rcqe_cmpl);
18899 iocbq->context2 = d_buf;18902 iocbq->cmd_dmabuf = d_buf;
18900 iocbq->context3 = NULL;18903 iocbq->bpl_dmabuf = NULL;
18901 iocbq->wcqe_cmpl.word3 = 1;18904 iocbq->wcqe_cmpl.word3 = 1;
18902 18905
18903 if (len > LPFC_DATA_BUF_SIZE)18906 if (len > LPFC_DATA_BUF_SIZE)
@@ -18942,12 +18945,14 @@ lpfc_sli4_send_seq_to_ulp(struct lpfc_vport *vport, · 38 unmodified lines
18942 if (!lpfc_complete_unsol_iocb(phba,18945 if (!lpfc_complete_unsol_iocb(phba,
18943 phba->sli4_hba.els_wq->pring,18946 phba->sli4_hba.els_wq->pring,
18944 iocbq, fc_hdr->fh_r_ctl,18947 iocbq, fc_hdr->fh_r_ctl,
18945 fc_hdr->fh_type))18948 fc_hdr->fh_type)) {
18946 lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT,18949 lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT,
18947 "2540 Ring %d handler: unexpected Rctl "18950 "2540 Ring %d handler: unexpected Rctl "
18948 "x%x Type x%x received\n",18951 "x%x Type x%x received\n",
18949 LPFC_ELS_RING,18952 LPFC_ELS_RING,
18950 fc_hdr->fh_r_ctl, fc_hdr->fh_type);18953 fc_hdr->fh_r_ctl, fc_hdr->fh_type);
18954 lpfc_in_buf_free(phba, &seq_dmabuf->dbuf);
18955 }
18951 18956
18952 /* Free iocb created in lpfc_prep_seq */18957 /* Free iocb created in lpfc_prep_seq */
18953 list_for_each_entry_safe(curr_iocb, next_iocb,18958 list_for_each_entry_safe(curr_iocb, next_iocb,
@@ -18962,7 +18967,7 @@ static void · 8 unmodified lines
18962lpfc_sli4_mds_loopback_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,18967lpfc_sli4_mds_loopback_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
18963 struct lpfc_iocbq *rspiocb)18968 struct lpfc_iocbq *rspiocb)
18964{18969{
18965 struct lpfc_dmabuf *pcmd = cmdiocb->context2;18970 struct lpfc_dmabuf *pcmd = cmdiocb->cmd_dmabuf;
18966 18971
18967 if (pcmd && pcmd->virt)18972 if (pcmd && pcmd->virt)
18968 dma_pool_free(phba->lpfc_drb_pool, pcmd->virt, pcmd->phys);18973 dma_pool_free(phba->lpfc_drb_pool, pcmd->virt, pcmd->phys);
@@ -19013,7 +19018,7 @@ lpfc_sli4_handle_mds_loopback(struct lpfc_vport *vport, · 44 unmodified lines
19013 /* copyin the payload */19018 /* copyin the payload */
19014 memcpy(pcmd->virt, dmabuf->dbuf.virt, frame_len);19019 memcpy(pcmd->virt, dmabuf->dbuf.virt, frame_len);
19015 19020
19016 iocbq->context2 = pcmd;19021 iocbq->cmd_dmabuf = pcmd;
19017 iocbq->vport = vport;19022 iocbq->vport = vport;
19018 iocbq->cmd_flag &= ~LPFC_FIP_ELS_ID_MASK;19023 iocbq->cmd_flag &= ~LPFC_FIP_ELS_ID_MASK;
19019 iocbq->cmd_flag |= LPFC_USE_FCPWQIDX;19024 iocbq->cmd_flag |= LPFC_USE_FCPWQIDX;
@@ -20332,11 +20337,7 @@ lpfc_sli4_get_config_region23(struct lpfc_hba *phba, char *rgn23_data) · 1312 unmodified lines
20332 }20337 }
20333 lpfc_sli_pcimem_bcopy((char *)mp->virt, rgn23_data, data_length);20338 lpfc_sli_pcimem_bcopy((char *)mp->virt, rgn23_data, data_length);
20334out:20339out:
20335 mempool_free(mboxq, phba->mbox_mem_pool);20340 lpfc_mbox_rsrc_cleanup(phba, mboxq, MBOX_THD_UNLOCKED);
20336 if (mp) {
20337 lpfc_mbuf_free(phba, mp->virt, mp->phys);
20338 kfree(mp);
20339 }
20340 return data_length;20341 return data_length;
20341}20342}
20342 20343
@@ -20651,7 +20652,6 @@ lpfc_cleanup_pending_mbox(struct lpfc_vport *vport) · 308 unmodified lines
20651{20652{
20652 struct lpfc_hba *phba = vport->phba;20653 struct lpfc_hba *phba = vport->phba;
20653 LPFC_MBOXQ_t *mb, *nextmb;20654 LPFC_MBOXQ_t *mb, *nextmb;
20654 struct lpfc_dmabuf *mp;
20655 struct lpfc_nodelist *ndlp;20655 struct lpfc_nodelist *ndlp;
20656 struct lpfc_nodelist *act_mbx_ndlp = NULL;20656 struct lpfc_nodelist *act_mbx_ndlp = NULL;
20657 LIST_HEAD(mbox_cmd_list);20657 LIST_HEAD(mbox_cmd_list);
@@ -20677,8 +20677,12 @@ lpfc_cleanup_pending_mbox(struct lpfc_vport *vport) · 19 unmodified lines
20677 mb->mbox_cmpl = lpfc_sli_def_mbox_cmpl;20677 mb->mbox_cmpl = lpfc_sli_def_mbox_cmpl;
20678 if (mb->u.mb.mbxCommand == MBX_REG_LOGIN64) {20678 if (mb->u.mb.mbxCommand == MBX_REG_LOGIN64) {
20679 act_mbx_ndlp = (struct lpfc_nodelist *)mb->ctx_ndlp;20679 act_mbx_ndlp = (struct lpfc_nodelist *)mb->ctx_ndlp;
20680 /* Put reference count for delayed processing */20680
20681 /* This reference is local to this routine. The
20682 * reference is removed at routine exit.
20683 */
20681 act_mbx_ndlp = lpfc_nlp_get(act_mbx_ndlp);20684 act_mbx_ndlp = lpfc_nlp_get(act_mbx_ndlp);
20685
20682 /* Unregister the RPI when mailbox complete */20686 /* Unregister the RPI when mailbox complete */
20683 mb->mbox_flag |= LPFC_MBX_IMED_UNREG;20687 mb->mbox_flag |= LPFC_MBX_IMED_UNREG;
20684 }20688 }
@@ -20721,12 +20725,6 @@ lpfc_cleanup_pending_mbox(struct lpfc_vport *vport) · 36 unmodified lines
20721 while (!list_empty(&mbox_cmd_list)) {20725 while (!list_empty(&mbox_cmd_list)) {
20722 list_remove_head(&mbox_cmd_list, mb, LPFC_MBOXQ_t, list);20726 list_remove_head(&mbox_cmd_list, mb, LPFC_MBOXQ_t, list);
20723 if (mb->u.mb.mbxCommand == MBX_REG_LOGIN64) {20727 if (mb->u.mb.mbxCommand == MBX_REG_LOGIN64) {
20724 mp = (struct lpfc_dmabuf *)(mb->ctx_buf);
20725 if (mp) {
20726 __lpfc_mbuf_free(phba, mp->virt, mp->phys);
20727 kfree(mp);
20728 }
20729 mb->ctx_buf = NULL;
20730 ndlp = (struct lpfc_nodelist *)mb->ctx_ndlp;20728 ndlp = (struct lpfc_nodelist *)mb->ctx_ndlp;
20731 mb->ctx_ndlp = NULL;20729 mb->ctx_ndlp = NULL;
20732 if (ndlp) {20730 if (ndlp) {
@@ -20736,7 +20734,7 @@ lpfc_cleanup_pending_mbox(struct lpfc_vport *vport) · 3 unmodified lines
20736 lpfc_nlp_put(ndlp);20734 lpfc_nlp_put(ndlp);
20737 }20735 }
20738 }20736 }
20739 mempool_free(mb, phba->mbox_mem_pool);20737 lpfc_mbox_rsrc_cleanup(phba, mb, MBOX_THD_UNLOCKED);
20740 }20738 }
20741 20739
20742 /* Release the ndlp with the cleaned-up active mailbox command */20740 /* Release the ndlp with the cleaned-up active mailbox command */
@@ -20888,8 +20886,8 @@ lpfc_wqe_bpl2sgl(struct lpfc_hba *phba, struct lpfc_iocbq *pwqeq, · 145 unmodified lines
20888 * have not been byteswapped yet so there is no20886 * have not been byteswapped yet so there is no
20889 * need to swap them back.20887 * need to swap them back.
20890 */20888 */
20891 if (pwqeq->context3)20889 if (pwqeq->bpl_dmabuf)
20892 dmabuf = (struct lpfc_dmabuf *)pwqeq->context3;20890 dmabuf = pwqeq->bpl_dmabuf;
20893 else20891 else
20894 return xritag;20892 return xritag;
20895 20893
@@ -21041,7 +21039,7 @@ lpfc_sli4_issue_wqe(struct lpfc_hba *phba, struct lpfc_sli4_hdw_queue *qp, · 145 unmodified lines
21041 wq = qp->io_wq;21039 wq = qp->io_wq;
21042 pring = wq->pring;21040 pring = wq->pring;
21043 21041
21044 ctxp = pwqe->context2;21042 ctxp = pwqe->context_un.axchg;
21045 sglq = ctxp->ctxbuf->sglq;21043 sglq = ctxp->ctxbuf->sglq;
21046 if (pwqe->sli4_xritag == NO_XRI) {21044 if (pwqe->sli4_xritag == NO_XRI) {
21047 pwqe->sli4_lxritag = sglq->sli4_lxritag;21045 pwqe->sli4_lxritag = sglq->sli4_lxritag;
@@ -21107,7 +21105,7 @@ lpfc_sli4_issue_abort_iotag(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 59 unmodified lines
21107 abtswqe = &abtsiocb->wqe;21105 abtswqe = &abtsiocb->wqe;
21108 memset(abtswqe, 0, sizeof(*abtswqe));21106 memset(abtswqe, 0, sizeof(*abtswqe));
21109 21107
21110 if (!lpfc_is_link_up(phba))21108 if (!lpfc_is_link_up(phba) || (phba->link_flag & LS_EXTERNAL_LOOPBACK))
21111 bf_set(abort_cmd_ia, &abtswqe->abort_cmd, 1);21109 bf_set(abort_cmd_ia, &abtswqe->abort_cmd, 1);
21112 bf_set(abort_cmd_criteria, &abtswqe->abort_cmd, T_XRI_TAG);21110 bf_set(abort_cmd_criteria, &abtswqe->abort_cmd, T_XRI_TAG);
21113 abtswqe->abort_cmd.rsrvd5 = 0;21111 abtswqe->abort_cmd.rsrvd5 = 0;
@@ -21883,7 +21881,6 @@ lpfc_read_object(struct lpfc_hba *phba, char *rdobject, uint32_t *datap, · 769 unmodified lines
21883 21881
21884 mbox->vport = phba->pport;21882 mbox->vport = phba->pport;
21885 mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl;21883 mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl;
21886 mbox->ctx_buf = NULL;
21887 mbox->ctx_ndlp = NULL;21884 mbox->ctx_ndlp = NULL;
21888 21885
21889 rc = lpfc_sli_issue_mbox(phba, mbox, MBX_POLL);21886 rc = lpfc_sli_issue_mbox(phba, mbox, MBX_POLL);
@@ -21920,9 +21917,12 @@ lpfc_read_object(struct lpfc_hba *phba, char *rdobject, uint32_t *datap, · 30 unmodified lines
21920 }21917 }
21921 21918
21922 exit:21919 exit:
21920 /* This is an embedded SLI4 mailbox with an external buffer allocated.
21921 * Free the pcmd and then cleanup with the correct routine.
21922 */
21923 lpfc_mbuf_free(phba, pcmd->virt, pcmd->phys);21923 lpfc_mbuf_free(phba, pcmd->virt, pcmd->phys);
21924 kfree(pcmd);21924 kfree(pcmd);
21925 mempool_free(mbox, phba->mbox_mem_pool);21925 lpfc_sli4_mbox_cmd_free(phba, mbox);
21926 return byte_cnt;21926 return byte_cnt;
21927}21927}
21928 21928
@@ -22114,7 +22114,7 @@ lpfc_get_cmd_rsp_buf_per_hdwq(struct lpfc_hba *phba, · 185 unmodified lines
22114 return NULL;22114 return NULL;
22115 }22115 }
22116 22116
22117 tmp->fcp_cmnd = dma_pool_alloc(phba->lpfc_cmd_rsp_buf_pool,22117 tmp->fcp_cmnd = dma_pool_zalloc(phba->lpfc_cmd_rsp_buf_pool,
22118 GFP_ATOMIC,22118 GFP_ATOMIC,
22119 &tmp->fcp_cmd_rsp_dma_handle);22119 &tmp->fcp_cmd_rsp_dma_handle);
22120 22120
@@ -22236,8 +22236,6 @@ lpfc_sli_prep_wqe(struct lpfc_hba *phba, struct lpfc_iocbq *job) · 115 unmodified lines
22236 u32 fip, abort_tag;22236 u32 fip, abort_tag;
22237 struct lpfc_nodelist *ndlp = NULL;22237 struct lpfc_nodelist *ndlp = NULL;
22238 union lpfc_wqe128 *wqe = &job->wqe;22238 union lpfc_wqe128 *wqe = &job->wqe;
22239 struct lpfc_dmabuf *context2;
22240 u32 els_id = LPFC_ELS_ID_DEFAULT;
22241 u8 command_type = ELS_COMMAND_NON_FIP;22239 u8 command_type = ELS_COMMAND_NON_FIP;
22242 22240
22243 fip = phba->hba_flag & HBA_FIP_SUPPORT;22241 fip = phba->hba_flag & HBA_FIP_SUPPORT;
@@ -22254,21 +22252,12 @@ lpfc_sli_prep_wqe(struct lpfc_hba *phba, struct lpfc_iocbq *job) · 10 unmodified lines
22254 22252
22255 switch (cmnd) {22253 switch (cmnd) {
22256 case CMD_ELS_REQUEST64_WQE:22254 case CMD_ELS_REQUEST64_WQE:
22257 if (job->cmd_flag & LPFC_IO_LIBDFC)22255 ndlp = job->ndlp;
22258 ndlp = job->context_un.ndlp;
22259 else
22260 ndlp = (struct lpfc_nodelist *)job->context1;
22261
22262 /* CCP CCPE PV PRI in word10 were set in the memcpy */
22263 if (command_type == ELS_COMMAND_FIP)
22264 els_id = ((job->cmd_flag & LPFC_FIP_ELS_ID_MASK)
22265 >> LPFC_FIP_ELS_ID_SHIFT);
22266 22256
22267 if_type = bf_get(lpfc_sli_intf_if_type,22257 if_type = bf_get(lpfc_sli_intf_if_type,
22268 &phba->sli4_hba.sli_intf);22258 &phba->sli4_hba.sli_intf);
22269 if (if_type >= LPFC_SLI_INTF_IF_TYPE_2) {22259 if (if_type >= LPFC_SLI_INTF_IF_TYPE_2) {
22270 context2 = (struct lpfc_dmabuf *)job->context2;22260 pcmd = (u32 *)job->cmd_dmabuf->virt;
22271 pcmd = (u32 *)context2->virt;
22272 if (pcmd && (*pcmd == ELS_CMD_FLOGI ||22261 if (pcmd && (*pcmd == ELS_CMD_FLOGI ||
22273 *pcmd == ELS_CMD_SCR ||22262 *pcmd == ELS_CMD_SCR ||
22274 *pcmd == ELS_CMD_RDF ||22263 *pcmd == ELS_CMD_RDF ||
@@ -22301,7 +22290,6 @@ lpfc_sli_prep_wqe(struct lpfc_hba *phba, struct lpfc_iocbq *job) · 26 unmodified lines
22301 bf_set(wqe_temp_rpi, &wqe->els_req.wqe_com,22290 bf_set(wqe_temp_rpi, &wqe->els_req.wqe_com,
22302 phba->sli4_hba.rpi_ids[ndlp->nlp_rpi]);22291 phba->sli4_hba.rpi_ids[ndlp->nlp_rpi]);
22303 22292
22304 bf_set(wqe_els_id, &wqe->els_req.wqe_com, els_id);
22305 bf_set(wqe_dbde, &wqe->els_req.wqe_com, 1);22293 bf_set(wqe_dbde, &wqe->els_req.wqe_com, 1);
22306 bf_set(wqe_iod, &wqe->els_req.wqe_com, LPFC_WQE_IOD_READ);22294 bf_set(wqe_iod, &wqe->els_req.wqe_com, LPFC_WQE_IOD_READ);
22307 bf_set(wqe_qosd, &wqe->els_req.wqe_com, 1);22295 bf_set(wqe_qosd, &wqe->els_req.wqe_com, 1);
@@ -22309,7 +22297,7 @@ lpfc_sli_prep_wqe(struct lpfc_hba *phba, struct lpfc_iocbq *job) · 1 unmodified line
22309 bf_set(wqe_ebde_cnt, &wqe->els_req.wqe_com, 0);22297 bf_set(wqe_ebde_cnt, &wqe->els_req.wqe_com, 0);
22310 break;22298 break;
22311 case CMD_XMIT_ELS_RSP64_WQE:22299 case CMD_XMIT_ELS_RSP64_WQE:
22312 ndlp = (struct lpfc_nodelist *)job->context1;22300 ndlp = job->ndlp;
22313 22301
22314 /* word4 */22302 /* word4 */
22315 wqe->xmit_els_rsp.word4 = 0;22303 wqe->xmit_els_rsp.word4 = 0;
drivers/scsi/lpfc/lpfc_sli.h+24−10
@@ -35,6 +35,12 @@ typedef enum _lpfc_ctx_cmd { · 34 unmodified lines
35 LPFC_CTX_HOST35 LPFC_CTX_HOST
36} lpfc_ctx_cmd;36} lpfc_ctx_cmd;
37 37
38/* Enumeration to describe the thread lock context. */
39enum lpfc_mbox_ctx {
40 MBOX_THD_UNLOCKED,
41 MBOX_THD_LOCKED
42};
43
38union lpfc_vmid_tag {44union lpfc_vmid_tag {
39 uint32_t app_id;45 uint32_t app_id;
40 uint8_t cs_ctl_vmid;46 uint8_t cs_ctl_vmid;
@@ -77,11 +83,15 @@ struct lpfc_iocbq { · 36 unmodified lines
77 83
78 u32 unsol_rcv_len; /* Receive len in usol path */84 u32 unsol_rcv_len; /* Receive len in usol path */
79 85
80 uint8_t num_bdes;86 /* Pack the u8's together and make them module-4. */
81 uint8_t abort_bls; /* ABTS by initiator or responder */87 u8 num_bdes; /* Number of BDEs */
82 u8 abort_rctl; /* ACC or RJT flag */88 u8 abort_bls; /* ABTS by initiator or responder */
83 uint8_t priority; /* OAS priority */89 u8 abort_rctl; /* ACC or RJT flag */
84 uint8_t retry; /* retry counter for IOCB cmd - if needed */90 u8 priority; /* OAS priority */
91 u8 retry; /* retry counter for IOCB cmd - if needed */
92 u8 rsvd1; /* Pad for u32 */
93 u8 rsvd2; /* Pad for u32 */
94 u8 rsvd3; /* Pad for u32 */
85 95
86 u32 cmd_flag;96 u32 cmd_flag;
87#define LPFC_IO_LIBDFC 1 /* libdfc iocb */97#define LPFC_IO_LIBDFC 1 /* libdfc iocb */
@@ -116,18 +126,22 @@ struct lpfc_iocbq { · 28 unmodified lines
116 126
117 uint32_t drvrTimeout; /* driver timeout in seconds */127 uint32_t drvrTimeout; /* driver timeout in seconds */
118 struct lpfc_vport *vport;/* virtual port pointer */128 struct lpfc_vport *vport;/* virtual port pointer */
119 void *context1; /* caller context information */129 struct lpfc_dmabuf *cmd_dmabuf;
120 void *context2; /* caller context information */130 struct lpfc_dmabuf *rsp_dmabuf;
121 void *context3; /* caller context information */131 struct lpfc_dmabuf *bpl_dmabuf;
122 uint32_t event_tag; /* LA Event tag */132 uint32_t event_tag; /* LA Event tag */
123 union {133 union {
124 wait_queue_head_t *wait_queue;134 wait_queue_head_t *wait_queue;
125 struct lpfc_iocbq *rsp_iocb;
126 struct lpfcMboxq *mbox;135 struct lpfcMboxq *mbox;
127 struct lpfc_nodelist *ndlp;
128 struct lpfc_node_rrq *rrq;136 struct lpfc_node_rrq *rrq;
137 struct nvmefc_ls_req *nvme_lsreq;
138 struct lpfc_async_xchg_ctx *axchg;
139 struct bsg_job_data *dd_data;
129 } context_un;140 } context_un;
130 141
142 struct lpfc_io_buf *io_buf;
143 struct lpfc_iocbq *rsp_iocb;
144 struct lpfc_nodelist *ndlp;
131 union lpfc_vmid_tag vmid_tag;145 union lpfc_vmid_tag vmid_tag;
132 void (*fabric_cmd_cmpl)(struct lpfc_hba *phba, struct lpfc_iocbq *cmd,146 void (*fabric_cmd_cmpl)(struct lpfc_hba *phba, struct lpfc_iocbq *cmd,
133 struct lpfc_iocbq *rsp);147 struct lpfc_iocbq *rsp);
drivers/scsi/lpfc/lpfc_sli4.h+3−0
@@ -981,6 +981,9 @@ struct lpfc_sli4_hba { · 980 unmodified lines
981#define lpfc_conf_trunk_port3_nd_MASK 0x1981#define lpfc_conf_trunk_port3_nd_MASK 0x1
982 uint8_t flash_id;982 uint8_t flash_id;
983 uint8_t asic_rev;983 uint8_t asic_rev;
984 uint16_t fawwpn_flag; /* FA-WWPN support state */
985#define LPFC_FAWWPN_CONFIG 0x1 /* FA-PWWN is configured */
986#define LPFC_FAWWPN_FABRIC 0x2 /* FA-PWWN success with Fabric */
984};987};
985 988
986enum lpfc_sge_type {989enum lpfc_sge_type {
drivers/scsi/lpfc/lpfc_version.h+1−1
@@ -20,7 +20,7 @@ · 19 unmodified lines
20 * included with this package. *20 * included with this package. *
21 *******************************************************************/21 *******************************************************************/
22 22
23#define LPFC_DRIVER_VERSION "14.2.0.1"23#define LPFC_DRIVER_VERSION "14.2.0.3"
24#define LPFC_DRIVER_NAME "lpfc"24#define LPFC_DRIVER_NAME "lpfc"
25 25
26/* Used for SLI 2/3 */26/* Used for SLI 2/3 */
drivers/scsi/lpfc/lpfc_vport.c+14−17
@@ -1,7 +1,7 @@
1/*******************************************************************1/*******************************************************************
2 * This file is part of the Emulex Linux Device Driver for *2 * This file is part of the Emulex Linux Device Driver for *
3 * Fibre Channel Host Bus Adapters. *3 * Fibre Channel Host Bus Adapters. *
4 * Copyright (C) 2017-2021 Broadcom. All Rights Reserved. The term *4 * Copyright (C) 2017-2022 Broadcom. All Rights Reserved. The term *
5 * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. *5 * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. *
6 * Copyright (C) 2004-2016 Emulex. All rights reserved. *6 * Copyright (C) 2004-2016 Emulex. All rights reserved. *
7 * EMULEX and SLI are trademarks of Emulex. *7 * EMULEX and SLI are trademarks of Emulex. *
@@ -135,12 +135,14 @@ lpfc_vport_sparm(struct lpfc_hba *phba, struct lpfc_vport *vport) · 127 unmodified lines
135 }135 }
136 136
137 /*137 /*
138 * Grab buffer pointer and clear context1 so we can use138 * Wait for the read_sparams mailbox to complete. Driver needs
139 * lpfc_sli_issue_box_wait139 * this per vport to start the FDISC. If the mailbox fails,
140 * just cleanup and return an error unless the failure is a
141 * mailbox timeout. For MBX_TIMEOUT, allow the default
142 * mbox completion handler to take care of the cleanup. This
143 * is safe as the mailbox command isn't one that triggers
144 * another mailbox.
140 */145 */
141 mp = (struct lpfc_dmabuf *)pmb->ctx_buf;
142 pmb->ctx_buf = NULL;
143
144 pmb->vport = vport;146 pmb->vport = vport;
145 rc = lpfc_sli_issue_mbox_wait(phba, pmb, phba->fc_ratov * 2);147 rc = lpfc_sli_issue_mbox_wait(phba, pmb, phba->fc_ratov * 2);
146 if (rc != MBX_SUCCESS) {148 if (rc != MBX_SUCCESS) {
@@ -148,34 +150,29 @@ lpfc_vport_sparm(struct lpfc_hba *phba, struct lpfc_vport *vport) · 1 unmodified line
148 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,150 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
149 "1830 Signal aborted mbxCmd x%x\n",151 "1830 Signal aborted mbxCmd x%x\n",
150 mb->mbxCommand);152 mb->mbxCommand);
151 lpfc_mbuf_free(phba, mp->virt, mp->phys);
152 kfree(mp);
153 if (rc != MBX_TIMEOUT)153 if (rc != MBX_TIMEOUT)
154 mempool_free(pmb, phba->mbox_mem_pool);154 lpfc_mbox_rsrc_cleanup(phba, pmb,
155 MBOX_THD_UNLOCKED);
155 return -EINTR;156 return -EINTR;
156 } else {157 } else {
157 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,158 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
158 "1818 VPort failed init, mbxCmd x%x "159 "1818 VPort failed init, mbxCmd x%x "
159 "READ_SPARM mbxStatus x%x, rc = x%x\n",160 "READ_SPARM mbxStatus x%x, rc = x%x\n",
160 mb->mbxCommand, mb->mbxStatus, rc);161 mb->mbxCommand, mb->mbxStatus, rc);
161 lpfc_mbuf_free(phba, mp->virt, mp->phys);
162 kfree(mp);
163 if (rc != MBX_TIMEOUT)162 if (rc != MBX_TIMEOUT)
164 mempool_free(pmb, phba->mbox_mem_pool);163 lpfc_mbox_rsrc_cleanup(phba, pmb,
164 MBOX_THD_UNLOCKED);
165 return -EIO;165 return -EIO;
166 }166 }
167 }167 }
168 168
169 mp = (struct lpfc_dmabuf *)pmb->ctx_buf;
169 memcpy(&vport->fc_sparam, mp->virt, sizeof (struct serv_parm));170 memcpy(&vport->fc_sparam, mp->virt, sizeof (struct serv_parm));
170 memcpy(&vport->fc_nodename, &vport->fc_sparam.nodeName,171 memcpy(&vport->fc_nodename, &vport->fc_sparam.nodeName,
171 sizeof (struct lpfc_name));172 sizeof (struct lpfc_name));
172 memcpy(&vport->fc_portname, &vport->fc_sparam.portName,173 memcpy(&vport->fc_portname, &vport->fc_sparam.portName,
173 sizeof (struct lpfc_name));174 sizeof (struct lpfc_name));
174 175 lpfc_mbox_rsrc_cleanup(phba, pmb, MBOX_THD_UNLOCKED);
175 lpfc_mbuf_free(phba, mp->virt, mp->phys);
176 kfree(mp);
177 mempool_free(pmb, phba->mbox_mem_pool);
178
179 return 0;176 return 0;
180}177}
181 178
drivers/scsi/mac53c94.c+1−1
@@ -234,7 +234,7 @@ static void mac53c94_interrupt(int irq, void *dev_id) · 233 unmodified lines
234 ++mac53c94_errors;234 ++mac53c94_errors;
235 writeb(CMD_NOP + CMD_DMA_MODE, &regs->command);235 writeb(CMD_NOP + CMD_DMA_MODE, &regs->command);
236 }236 }
237 if (cmd == 0) {237 if (!cmd) {
238 printk(KERN_DEBUG "53c94: interrupt with no command active?\n");238 printk(KERN_DEBUG "53c94: interrupt with no command active?\n");
239 return;239 return;
240 }240 }
drivers/scsi/megaraid.c+1−1
@@ -4607,7 +4607,7 @@ static int __init megaraid_init(void) · 4606 unmodified lines
4607 * major number allocation.4607 * major number allocation.
4608 */4608 */
4609 major = register_chrdev(0, "megadev_legacy", &megadev_fops);4609 major = register_chrdev(0, "megadev_legacy", &megadev_fops);
4610 if (!major) {4610 if (major < 0) {
4611 printk(KERN_WARNING4611 printk(KERN_WARNING
4612 "megaraid: failed to register char device\n");4612 "megaraid: failed to register char device\n");
4613 }4613 }
drivers/scsi/megaraid/megaraid_sas_base.c+0−2
@@ -4473,8 +4473,6 @@ int megasas_alloc_cmds(struct megasas_instance *instance) · 4472 unmodified lines
4473 return -ENOMEM;4473 return -ENOMEM;
4474 }4474 }
4475 4475
4476 memset(instance->cmd_list, 0, sizeof(struct megasas_cmd *) *max_cmd);
4477
4478 for (i = 0; i < max_cmd; i++) {4476 for (i = 0; i < max_cmd; i++) {
4479 instance->cmd_list[i] = kmalloc(sizeof(struct megasas_cmd),4477 instance->cmd_list[i] = kmalloc(sizeof(struct megasas_cmd),
4480 GFP_KERNEL);4478 GFP_KERNEL);
drivers/scsi/megaraid/megaraid_sas_fusion.c+0−2
@@ -2047,8 +2047,6 @@ map_cmd_status(struct fusion_context *fusion, · 2046 unmodified lines
2047 2047
2048 scmd->result = (DID_OK << 16) | ext_status;2048 scmd->result = (DID_OK << 16) | ext_status;
2049 if (ext_status == SAM_STAT_CHECK_CONDITION) {2049 if (ext_status == SAM_STAT_CHECK_CONDITION) {
2050 memset(scmd->sense_buffer, 0,
2051 SCSI_SENSE_BUFFERSIZE);
2052 memcpy(scmd->sense_buffer, sense,2050 memcpy(scmd->sense_buffer, sense,
2053 SCSI_SENSE_BUFFERSIZE);2051 SCSI_SENSE_BUFFERSIZE);
2054 }2052 }
drivers/scsi/mpi3mr/Kconfig+1−0
@@ -3,5 +3,6 @@ · 2 unmodified lines
3config SCSI_MPI3MR3config SCSI_MPI3MR
4 tristate "Broadcom MPI3 Storage Controller Device Driver"4 tristate "Broadcom MPI3 Storage Controller Device Driver"
5 depends on PCI && SCSI5 depends on PCI && SCSI
6 select BLK_DEV_BSGLIB
6 help7 help
7 MPI3 based Storage & RAID Controllers Driver.8 MPI3 based Storage & RAID Controllers Driver.
drivers/scsi/mpi3mr/Makefile+1−0
@@ -2,3 +2,4 @@ · 1 unmodified line
2obj-m += mpi3mr.o2obj-m += mpi3mr.o
3mpi3mr-y += mpi3mr_os.o \3mpi3mr-y += mpi3mr_os.o \
4 mpi3mr_fw.o \4 mpi3mr_fw.o \
5 mpi3mr_app.o \
drivers/scsi/mpi3mr/mpi/mpi30_init.h+0−53
@@ -115,57 +115,4 @@ struct mpi3_scsi_io_reply { · 114 unmodified lines
115#define MPI3_SCSI_RSP_ARI0_MASK (0xff000000)115#define MPI3_SCSI_RSP_ARI0_MASK (0xff000000)
116#define MPI3_SCSI_RSP_ARI0_SHIFT (24)116#define MPI3_SCSI_RSP_ARI0_SHIFT (24)
117#define MPI3_SCSI_TASKTAG_UNKNOWN (0xffff)117#define MPI3_SCSI_TASKTAG_UNKNOWN (0xffff)
118struct mpi3_scsi_task_mgmt_request {
119 __le16 host_tag;
120 u8 ioc_use_only02;
121 u8 function;
122 __le16 ioc_use_only04;
123 u8 ioc_use_only06;
124 u8 msg_flags;
125 __le16 change_count;
126 __le16 dev_handle;
127 __le16 task_host_tag;
128 u8 task_type;
129 u8 reserved0f;
130 __le16 task_request_queue_id;
131 __le16 reserved12;
132 __le32 reserved14;
133 u8 lun[8];
134};
135
136#define MPI3_SCSITASKMGMT_MSGFLAGS_DO_NOT_SEND_TASK_IU (0x08)
137#define MPI3_SCSITASKMGMT_TASKTYPE_ABORT_TASK (0x01)
138#define MPI3_SCSITASKMGMT_TASKTYPE_ABORT_TASK_SET (0x02)
139#define MPI3_SCSITASKMGMT_TASKTYPE_TARGET_RESET (0x03)
140#define MPI3_SCSITASKMGMT_TASKTYPE_LOGICAL_UNIT_RESET (0x05)
141#define MPI3_SCSITASKMGMT_TASKTYPE_CLEAR_TASK_SET (0x06)
142#define MPI3_SCSITASKMGMT_TASKTYPE_QUERY_TASK (0x07)
143#define MPI3_SCSITASKMGMT_TASKTYPE_CLEAR_ACA (0x08)
144#define MPI3_SCSITASKMGMT_TASKTYPE_QUERY_TASK_SET (0x09)
145#define MPI3_SCSITASKMGMT_TASKTYPE_QUERY_ASYNC_EVENT (0x0a)
146#define MPI3_SCSITASKMGMT_TASKTYPE_I_T_NEXUS_RESET (0x0b)
147struct mpi3_scsi_task_mgmt_reply {
148 __le16 host_tag;
149 u8 ioc_use_only02;
150 u8 function;
151 __le16 ioc_use_only04;
152 u8 ioc_use_only06;
153 u8 msg_flags;
154 __le16 ioc_use_only08;
155 __le16 ioc_status;
156 __le32 ioc_log_info;
157 __le32 termination_count;
158 __le32 response_data;
159 __le32 reserved18;
160};
161
162#define MPI3_SCSITASKMGMT_RSPCODE_TM_COMPLETE (0x00)
163#define MPI3_SCSITASKMGMT_RSPCODE_INVALID_FRAME (0x02)
164#define MPI3_SCSITASKMGMT_RSPCODE_TM_FUNCTION_NOT_SUPPORTED (0x04)
165#define MPI3_SCSITASKMGMT_RSPCODE_TM_FAILED (0x05)
166#define MPI3_SCSITASKMGMT_RSPCODE_TM_SUCCEEDED (0x08)
167#define MPI3_SCSITASKMGMT_RSPCODE_TM_INVALID_LUN (0x09)
168#define MPI3_SCSITASKMGMT_RSPCODE_TM_OVERLAPPED_TAG (0x0a)
169#define MPI3_SCSITASKMGMT_RSPCODE_IO_QUEUED_ON_IOC (0x80)
170#define MPI3_SCSITASKMGMT_RSPCODE_TM_NVME_DENIED (0x81)
171#endif118#endif
drivers/scsi/mpi3mr/mpi/mpi30_ioc.h+0−27
@@ -38,16 +38,6 @@ struct mpi3_ioc_init_request { · 37 unmodified lines
38#define MPI3_WHOINIT_ROM_BIOS (0x02)38#define MPI3_WHOINIT_ROM_BIOS (0x02)
39#define MPI3_WHOINIT_HOST_DRIVER (0x03)39#define MPI3_WHOINIT_HOST_DRIVER (0x03)
40#define MPI3_WHOINIT_MANUFACTURER (0x04)40#define MPI3_WHOINIT_MANUFACTURER (0x04)
41struct mpi3_driver_info_layout {
42 __le32 information_length;
43 u8 driver_signature[12];
44 u8 os_name[16];
45 u8 os_version[12];
46 u8 driver_name[20];
47 u8 driver_version[32];
48 u8 driver_release_date[20];
49 __le32 driver_capabilities;
50};
51 41
52struct mpi3_ioc_facts_request {42struct mpi3_ioc_facts_request {
53 __le16 host_tag;43 __le16 host_tag;
@@ -647,23 +637,6 @@ struct mpi3_event_data_diag_buffer_status_change { · 593 unmodified lines
647#define MPI3_EVENT_DIAG_BUFFER_STATUS_CHANGE_RC_RELEASED (0x01)637#define MPI3_EVENT_DIAG_BUFFER_STATUS_CHANGE_RC_RELEASED (0x01)
648#define MPI3_EVENT_DIAG_BUFFER_STATUS_CHANGE_RC_PAUSED (0x02)638#define MPI3_EVENT_DIAG_BUFFER_STATUS_CHANGE_RC_PAUSED (0x02)
649#define MPI3_EVENT_DIAG_BUFFER_STATUS_CHANGE_RC_RESUMED (0x03)639#define MPI3_EVENT_DIAG_BUFFER_STATUS_CHANGE_RC_RESUMED (0x03)
650#define MPI3_PEL_LOCALE_FLAGS_NON_BLOCKING_BOOT_EVENT (0x0200)
651#define MPI3_PEL_LOCALE_FLAGS_BLOCKING_BOOT_EVENT (0x0100)
652#define MPI3_PEL_LOCALE_FLAGS_PCIE (0x0080)
653#define MPI3_PEL_LOCALE_FLAGS_CONFIGURATION (0x0040)
654#define MPI3_PEL_LOCALE_FLAGS_CONTROLER (0x0020)
655#define MPI3_PEL_LOCALE_FLAGS_SAS (0x0010)
656#define MPI3_PEL_LOCALE_FLAGS_EPACK (0x0008)
657#define MPI3_PEL_LOCALE_FLAGS_ENCLOSURE (0x0004)
658#define MPI3_PEL_LOCALE_FLAGS_PD (0x0002)
659#define MPI3_PEL_LOCALE_FLAGS_VD (0x0001)
660#define MPI3_PEL_CLASS_DEBUG (0x00)
661#define MPI3_PEL_CLASS_PROGRESS (0x01)
662#define MPI3_PEL_CLASS_INFORMATIONAL (0x02)
663#define MPI3_PEL_CLASS_WARNING (0x03)
664#define MPI3_PEL_CLASS_CRITICAL (0x04)
665#define MPI3_PEL_CLASS_FATAL (0x05)
666#define MPI3_PEL_CLASS_FAULT (0x06)
667#define MPI3_PEL_CLEARTYPE_CLEAR (0x00)640#define MPI3_PEL_CLEARTYPE_CLEAR (0x00)
668#define MPI3_PEL_WAITTIME_INFINITE_WAIT (0x00)641#define MPI3_PEL_WAITTIME_INFINITE_WAIT (0x00)
669#define MPI3_PEL_ACTION_GET_SEQNUM (0x01)642#define MPI3_PEL_ACTION_GET_SEQNUM (0x01)
drivers/scsi/mpi3mr/mpi/mpi30_pci.h+1−30
@@ -5,24 +5,6 @@ · 4 unmodified lines
5 */5 */
6#ifndef MPI30_PCI_H6#ifndef MPI30_PCI_H
7#define MPI30_PCI_H 17#define MPI30_PCI_H 1
8#ifndef MPI3_NVME_ENCAP_CMD_MAX
9#define MPI3_NVME_ENCAP_CMD_MAX (1)
10#endif
11struct mpi3_nvme_encapsulated_request {
12 __le16 host_tag;
13 u8 ioc_use_only02;
14 u8 function;
15 __le16 ioc_use_only04;
16 u8 ioc_use_only06;
17 u8 msg_flags;
18 __le16 change_count;
19 __le16 dev_handle;
20 __le16 encapsulated_command_length;
21 __le16 flags;
22 __le32 data_length;
23 __le32 reserved14[3];
24 __le32 command[MPI3_NVME_ENCAP_CMD_MAX];
25};
26 8
27#define MPI3_NVME_FLAGS_FORCE_ADMIN_ERR_REPLY_MASK (0x0002)9#define MPI3_NVME_FLAGS_FORCE_ADMIN_ERR_REPLY_MASK (0x0002)
28#define MPI3_NVME_FLAGS_FORCE_ADMIN_ERR_REPLY_FAIL_ONLY (0x0000)10#define MPI3_NVME_FLAGS_FORCE_ADMIN_ERR_REPLY_FAIL_ONLY (0x0000)
@@ -30,16 +12,5 @@ struct mpi3_nvme_encapsulated_request { · 1 unmodified line
30#define MPI3_NVME_FLAGS_SUBMISSIONQ_MASK (0x0001)12#define MPI3_NVME_FLAGS_SUBMISSIONQ_MASK (0x0001)
31#define MPI3_NVME_FLAGS_SUBMISSIONQ_IO (0x0000)13#define MPI3_NVME_FLAGS_SUBMISSIONQ_IO (0x0000)
32#define MPI3_NVME_FLAGS_SUBMISSIONQ_ADMIN (0x0001)14#define MPI3_NVME_FLAGS_SUBMISSIONQ_ADMIN (0x0001)
33struct mpi3_nvme_encapsulated_error_reply {15
34 __le16 host_tag;
35 u8 ioc_use_only02;
36 u8 function;
37 __le16 ioc_use_only04;
38 u8 ioc_use_only06;
39 u8 msg_flags;
40 __le16 ioc_use_only08;
41 __le16 ioc_status;
42 __le32 ioc_log_info;
43 __le32 nvme_completion_entry[4];
44};
45#endif16#endif
drivers/scsi/mpi3mr/mpi3mr.h+130−7
@@ -38,6 +38,7 @@ · 37 unmodified lines
38#include <scsi/scsi_device.h>38#include <scsi/scsi_device.h>
39#include <scsi/scsi_host.h>39#include <scsi/scsi_host.h>
40#include <scsi/scsi_tcq.h>40#include <scsi/scsi_tcq.h>
41#include <uapi/scsi/scsi_bsg_mpi3mr.h>
41 42
42#include "mpi/mpi30_transport.h"43#include "mpi/mpi30_transport.h"
43#include "mpi/mpi30_cnfg.h"44#include "mpi/mpi30_cnfg.h"
@@ -52,9 +53,10 @@ · 8 unmodified lines
52extern spinlock_t mrioc_list_lock;53extern spinlock_t mrioc_list_lock;
53extern struct list_head mrioc_list;54extern struct list_head mrioc_list;
54extern int prot_mask;55extern int prot_mask;
56extern atomic64_t event_counter;
55 57
56#define MPI3MR_DRIVER_VERSION "8.0.0.68.0"58#define MPI3MR_DRIVER_VERSION "8.0.0.69.0"
57#define MPI3MR_DRIVER_RELDATE "10-February-2022"59#define MPI3MR_DRIVER_RELDATE "16-March-2022"
58 60
59#define MPI3MR_DRIVER_NAME "mpi3mr"61#define MPI3MR_DRIVER_NAME "mpi3mr"
60#define MPI3MR_DRIVER_LICENSE "GPL"62#define MPI3MR_DRIVER_LICENSE "GPL"
@@ -89,7 +91,9 @@ extern int prot_mask; · 28 unmodified lines
89/* Reserved Host Tag definitions */91/* Reserved Host Tag definitions */
90#define MPI3MR_HOSTTAG_INVALID 0xFFFF92#define MPI3MR_HOSTTAG_INVALID 0xFFFF
91#define MPI3MR_HOSTTAG_INITCMDS 193#define MPI3MR_HOSTTAG_INITCMDS 1
92#define MPI3MR_HOSTTAG_IOCTLCMDS 294#define MPI3MR_HOSTTAG_BSG_CMDS 2
95#define MPI3MR_HOSTTAG_PEL_ABORT 3
96#define MPI3MR_HOSTTAG_PEL_WAIT 4
93#define MPI3MR_HOSTTAG_BLK_TMS 597#define MPI3MR_HOSTTAG_BLK_TMS 5
94 98
95#define MPI3MR_NUM_DEVRMCMD 1699#define MPI3MR_NUM_DEVRMCMD 16
@@ -120,6 +124,9 @@ extern int prot_mask; · 24 unmodified lines
120 124
121#define MPI3MR_WATCHDOG_INTERVAL 1000 /* in milli seconds */125#define MPI3MR_WATCHDOG_INTERVAL 1000 /* in milli seconds */
122 126
127#define MPI3MR_SCMD_TIMEOUT (60 * HZ)
128#define MPI3MR_EH_SCMD_TIMEOUT (60 * HZ)
129
123/* Internal admin command state definitions*/130/* Internal admin command state definitions*/
124#define MPI3MR_CMD_NOTUSED 0x8000131#define MPI3MR_CMD_NOTUSED 0x8000
125#define MPI3MR_CMD_COMPLETE 0x0001132#define MPI3MR_CMD_COMPLETE 0x0001
@@ -148,8 +155,10 @@ extern int prot_mask; · 22 unmodified lines
148 155
149#define MPI3MR_DEFAULT_MDTS (128 * 1024)156#define MPI3MR_DEFAULT_MDTS (128 * 1024)
150#define MPI3MR_DEFAULT_PGSZEXP (12)157#define MPI3MR_DEFAULT_PGSZEXP (12)
158
151/* Command retry count definitions */159/* Command retry count definitions */
152#define MPI3MR_DEV_RMHS_RETRY_COUNT 3160#define MPI3MR_DEV_RMHS_RETRY_COUNT 3
161#define MPI3MR_PEL_RETRY_COUNT 3
153 162
154/* Default target device queue depth */163/* Default target device queue depth */
155#define MPI3MR_DEFAULT_SDEV_QD 32164#define MPI3MR_DEFAULT_SDEV_QD 32
@@ -175,6 +184,57 @@ extern int prot_mask; · 19 unmodified lines
175/* MSI Index from Reply Queue Index */184/* MSI Index from Reply Queue Index */
176#define REPLY_QUEUE_IDX_TO_MSIX_IDX(qidx, offset) (qidx + offset)185#define REPLY_QUEUE_IDX_TO_MSIX_IDX(qidx, offset) (qidx + offset)
177 186
187/*
188 * Maximum data transfer size definitions for management
189 * application commands
190 */
191#define MPI3MR_MAX_APP_XFER_SIZE (1 * 1024 * 1024)
192#define MPI3MR_MAX_APP_XFER_SEGMENTS 512
193/*
194 * 2048 sectors are for data buffers and additional 512 sectors for
195 * other buffers
196 */
197#define MPI3MR_MAX_APP_XFER_SECTORS (2048 + 512)
198
199/**
200 * struct mpi3mr_nvme_pt_sge - Structure to store SGEs for NVMe
201 * Encapsulated commands.
202 *
203 * @base_addr: Physical address
204 * @length: SGE length
205 * @rsvd: Reserved
206 * @rsvd1: Reserved
207 * @sgl_type: sgl type
208 */
209struct mpi3mr_nvme_pt_sge {
210 u64 base_addr;
211 u32 length;
212 u16 rsvd;
213 u8 rsvd1;
214 u8 sgl_type;
215};
216
217/**
218 * struct mpi3mr_buf_map - local structure to
219 * track kernel and user buffers associated with an BSG
220 * structure.
221 *
222 * @bsg_buf: BSG buffer virtual address
223 * @bsg_buf_len: BSG buffer length
224 * @kern_buf: Kernel buffer virtual address
225 * @kern_buf_len: Kernel buffer length
226 * @kern_buf_dma: Kernel buffer DMA address
227 * @data_dir: Data direction.
228 */
229struct mpi3mr_buf_map {
230 void *bsg_buf;
231 u32 bsg_buf_len;
232 void *kern_buf;
233 u32 kern_buf_len;
234 dma_addr_t kern_buf_dma;
235 u8 data_dir;
236};
237
178/* IOC State definitions */238/* IOC State definitions */
179enum mpi3mr_iocstate {239enum mpi3mr_iocstate {
180 MRIOC_STATE_READY = 1,240 MRIOC_STATE_READY = 1,
@@ -189,10 +249,10 @@ enum mpi3mr_iocstate { · 8 unmodified lines
189enum mpi3mr_reset_reason {249enum mpi3mr_reset_reason {
190 MPI3MR_RESET_FROM_BRINGUP = 1,250 MPI3MR_RESET_FROM_BRINGUP = 1,
191 MPI3MR_RESET_FROM_FAULT_WATCH = 2,251 MPI3MR_RESET_FROM_FAULT_WATCH = 2,
192 MPI3MR_RESET_FROM_IOCTL = 3,252 MPI3MR_RESET_FROM_APP = 3,
193 MPI3MR_RESET_FROM_EH_HOS = 4,253 MPI3MR_RESET_FROM_EH_HOS = 4,
194 MPI3MR_RESET_FROM_TM_TIMEOUT = 5,254 MPI3MR_RESET_FROM_TM_TIMEOUT = 5,
195 MPI3MR_RESET_FROM_IOCTL_TIMEOUT = 6,255 MPI3MR_RESET_FROM_APP_TIMEOUT = 6,
196 MPI3MR_RESET_FROM_MUR_FAILURE = 7,256 MPI3MR_RESET_FROM_MUR_FAILURE = 7,
197 MPI3MR_RESET_FROM_CTLR_CLEANUP = 8,257 MPI3MR_RESET_FROM_CTLR_CLEANUP = 8,
198 MPI3MR_RESET_FROM_CIACTIV_FAULT = 9,258 MPI3MR_RESET_FROM_CIACTIV_FAULT = 9,
@@ -543,6 +603,7 @@ struct mpi3mr_sdev_priv_data { · 344 unmodified lines
543 * @ioc_status: IOC status from the firmware603 * @ioc_status: IOC status from the firmware
544 * @ioc_loginfo:IOC log info from the firmware604 * @ioc_loginfo:IOC log info from the firmware
545 * @is_waiting: Is the command issued in block mode605 * @is_waiting: Is the command issued in block mode
606 * @is_sense: Is Sense data present
546 * @retry_count: Retry count for retriable commands607 * @retry_count: Retry count for retriable commands
547 * @host_tag: Host tag used by the command608 * @host_tag: Host tag used by the command
548 * @callback: Callback for non blocking commands609 * @callback: Callback for non blocking commands
@@ -558,6 +619,7 @@ struct mpi3mr_drv_cmd { · 9 unmodified lines
558 u16 ioc_status;619 u16 ioc_status;
559 u32 ioc_loginfo;620 u32 ioc_loginfo;
560 u8 is_waiting;621 u8 is_waiting;
622 u8 is_sense;
561 u8 retry_count;623 u8 retry_count;
562 u16 host_tag;624 u16 host_tag;
563 625
@@ -685,6 +747,7 @@ struct scmd_priv { · 121 unmodified lines
685 * @chain_bitmap_sz: Chain buffer allocator bitmap size747 * @chain_bitmap_sz: Chain buffer allocator bitmap size
686 * @chain_bitmap: Chain buffer allocator bitmap748 * @chain_bitmap: Chain buffer allocator bitmap
687 * @chain_buf_lock: Chain buffer list lock749 * @chain_buf_lock: Chain buffer list lock
750 * @bsg_cmds: Command tracker for BSG command
688 * @host_tm_cmds: Command tracker for task management commands751 * @host_tm_cmds: Command tracker for task management commands
689 * @dev_rmhs_cmds: Command tracker for device removal commands752 * @dev_rmhs_cmds: Command tracker for device removal commands
690 * @evtack_cmds: Command tracker for event ack commands753 * @evtack_cmds: Command tracker for event ack commands
@@ -704,16 +767,35 @@ struct scmd_priv { · 13 unmodified lines
704 * @reset_waitq: Controller reset wait queue767 * @reset_waitq: Controller reset wait queue
705 * @prepare_for_reset: Prepare for reset event received768 * @prepare_for_reset: Prepare for reset event received
706 * @prepare_for_reset_timeout_counter: Prepare for reset timeout769 * @prepare_for_reset_timeout_counter: Prepare for reset timeout
770 * @prp_list_virt: NVMe encapsulated PRP list virtual base
771 * @prp_list_dma: NVMe encapsulated PRP list DMA
772 * @prp_sz: NVME encapsulated PRP list size
707 * @diagsave_timeout: Diagnostic information save timeout773 * @diagsave_timeout: Diagnostic information save timeout
708 * @logging_level: Controller debug logging level774 * @logging_level: Controller debug logging level
709 * @flush_io_count: I/O count to flush after reset775 * @flush_io_count: I/O count to flush after reset
710 * @current_event: Firmware event currently in process776 * @current_event: Firmware event currently in process
711 * @driver_info: Driver, Kernel, OS information to firmware777 * @driver_info: Driver, Kernel, OS information to firmware
712 * @change_count: Topology change count778 * @change_count: Topology change count
779 * @pel_enabled: Persistent Event Log(PEL) enabled or not
780 * @pel_abort_requested: PEL abort is requested or not
781 * @pel_class: PEL Class identifier
782 * @pel_locale: PEL Locale identifier
783 * @pel_cmds: Command tracker for PEL wait command
784 * @pel_abort_cmd: Command tracker for PEL abort command
785 * @pel_newest_seqnum: Newest PEL sequenece number
786 * @pel_seqnum_virt: PEL sequence number virtual address
787 * @pel_seqnum_dma: PEL sequence number DMA address
788 * @pel_seqnum_sz: PEL sequenece number size
713 * @op_reply_q_offset: Operational reply queue offset with MSIx789 * @op_reply_q_offset: Operational reply queue offset with MSIx
714 * @default_qcount: Total Default queues790 * @default_qcount: Total Default queues
715 * @active_poll_qcount: Currently active poll queue count791 * @active_poll_qcount: Currently active poll queue count
716 * @requested_poll_qcount: User requested poll queue count792 * @requested_poll_qcount: User requested poll queue count
793 * @bsg_dev: BSG device structure
794 * @bsg_queue: Request queue for BSG device
795 * @stop_bsgs: Stop BSG request flag
796 * @logdata_buf: Circular buffer to store log data entries
797 * @logdata_buf_idx: Index of entry in buffer to store
798 * @logdata_entry_sz: log data entry size
717 */799 */
718struct mpi3mr_ioc {800struct mpi3mr_ioc {
719 struct list_head list;801 struct list_head list;
@@ -820,6 +902,7 @@ struct mpi3mr_ioc { · 100 unmodified lines
820 void *chain_bitmap;902 void *chain_bitmap;
821 spinlock_t chain_buf_lock;903 spinlock_t chain_buf_lock;
822 904
905 struct mpi3mr_drv_cmd bsg_cmds;
823 struct mpi3mr_drv_cmd host_tm_cmds;906 struct mpi3mr_drv_cmd host_tm_cmds;
824 struct mpi3mr_drv_cmd dev_rmhs_cmds[MPI3MR_NUM_DEVRMCMD];907 struct mpi3mr_drv_cmd dev_rmhs_cmds[MPI3MR_NUM_DEVRMCMD];
825 struct mpi3mr_drv_cmd evtack_cmds[MPI3MR_NUM_EVTACKCMD];908 struct mpi3mr_drv_cmd evtack_cmds[MPI3MR_NUM_EVTACKCMD];
@@ -842,6 +925,10 @@ struct mpi3mr_ioc { · 16 unmodified lines
842 u8 prepare_for_reset;925 u8 prepare_for_reset;
843 u16 prepare_for_reset_timeout_counter;926 u16 prepare_for_reset_timeout_counter;
844 927
928 void *prp_list_virt;
929 dma_addr_t prp_list_dma;
930 u32 prp_sz;
931
845 u16 diagsave_timeout;932 u16 diagsave_timeout;
846 int logging_level;933 int logging_level;
847 u16 flush_io_count;934 u16 flush_io_count;
@@ -849,11 +936,30 @@ struct mpi3mr_ioc { · 1 unmodified line
849 struct mpi3mr_fwevt *current_event;936 struct mpi3mr_fwevt *current_event;
850 struct mpi3_driver_info_layout driver_info;937 struct mpi3_driver_info_layout driver_info;
851 u16 change_count;938 u16 change_count;
852 u16 op_reply_q_offset;
853 939
940 u8 pel_enabled;
941 u8 pel_abort_requested;
942 u8 pel_class;
943 u16 pel_locale;
944 struct mpi3mr_drv_cmd pel_cmds;
945 struct mpi3mr_drv_cmd pel_abort_cmd;
946
947 u32 pel_newest_seqnum;
948 void *pel_seqnum_virt;
949 dma_addr_t pel_seqnum_dma;
950 u32 pel_seqnum_sz;
951
952 u16 op_reply_q_offset;
854 u16 default_qcount;953 u16 default_qcount;
855 u16 active_poll_qcount;954 u16 active_poll_qcount;
856 u16 requested_poll_qcount;955 u16 requested_poll_qcount;
956
957 struct device *bsg_dev;
958 struct request_queue *bsg_queue;
959 u8 stop_bsgs;
960 u8 *logdata_buf;
961 u16 logdata_buf_idx;
962 u16 logdata_entry_sz;
857};963};
858 964
859/**965/**
@@ -866,6 +972,7 @@ struct mpi3mr_ioc { · 6 unmodified lines
866 * @send_ack: Event acknowledgment required or not972 * @send_ack: Event acknowledgment required or not
867 * @process_evt: Bottomhalf processing required or not973 * @process_evt: Bottomhalf processing required or not
868 * @evt_ctx: Event context to send in Ack974 * @evt_ctx: Event context to send in Ack
975 * @event_data_size: size of the event data in bytes
869 * @pending_at_sml: waiting for device add/remove API to complete976 * @pending_at_sml: waiting for device add/remove API to complete
870 * @discard: discard this event977 * @discard: discard this event
871 * @ref_count: kref count978 * @ref_count: kref count
@@ -879,6 +986,7 @@ struct mpi3mr_fwevt { · 7 unmodified lines
879 bool send_ack;986 bool send_ack;
880 bool process_evt;987 bool process_evt;
881 u32 evt_ctx;988 u32 evt_ctx;
989 u16 event_data_size;
882 bool pending_at_sml;990 bool pending_at_sml;
883 bool discard;991 bool discard;
884 struct kref ref_count;992 struct kref ref_count;
@@ -962,5 +1070,20 @@ void mpi3mr_check_rh_fault_ioc(struct mpi3mr_ioc *mrioc, u32 reason_code); · 77 unmodified lines
962int mpi3mr_process_op_reply_q(struct mpi3mr_ioc *mrioc,1070int mpi3mr_process_op_reply_q(struct mpi3mr_ioc *mrioc,
963 struct op_reply_qinfo *op_reply_q);1071 struct op_reply_qinfo *op_reply_q);
964int mpi3mr_blk_mq_poll(struct Scsi_Host *shost, unsigned int queue_num);1072int mpi3mr_blk_mq_poll(struct Scsi_Host *shost, unsigned int queue_num);
965 1073void mpi3mr_bsg_init(struct mpi3mr_ioc *mrioc);
1074void mpi3mr_bsg_exit(struct mpi3mr_ioc *mrioc);
1075int mpi3mr_issue_tm(struct mpi3mr_ioc *mrioc, u8 tm_type,
1076 u16 handle, uint lun, u16 htag, ulong timeout,
1077 struct mpi3mr_drv_cmd *drv_cmd,
1078 u8 *resp_code, struct scsi_cmnd *scmd);
1079struct mpi3mr_tgt_dev *mpi3mr_get_tgtdev_by_handle(
1080 struct mpi3mr_ioc *mrioc, u16 handle);
1081void mpi3mr_pel_get_seqnum_complete(struct mpi3mr_ioc *mrioc,
1082 struct mpi3mr_drv_cmd *drv_cmd);
1083int mpi3mr_pel_get_seqnum_post(struct mpi3mr_ioc *mrioc,
1084 struct mpi3mr_drv_cmd *drv_cmd);
1085void mpi3mr_app_save_logdata(struct mpi3mr_ioc *mrioc, char *event_data,
1086 u16 event_data_size);
1087extern const struct attribute_group *mpi3mr_host_groups[];
1088extern const struct attribute_group *mpi3mr_dev_groups[];
966#endif /*MPI3MR_H_INCLUDED*/1089#endif /*MPI3MR_H_INCLUDED*/
drivers/scsi/mpi3mr/mpi3mr_app.c+1864−0
@@ -0,0 +1,1864 @@
1// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3 * Driver for Broadcom MPI3 Storage Controllers
4 *
5 * Copyright (C) 2017-2022 Broadcom Inc.
6 * (mailto: mpi3mr-linuxdrv.pdl@broadcom.com)
7 *
8 */
9
10#include "mpi3mr.h"
11#include <linux/bsg-lib.h>
12#include <uapi/scsi/scsi_bsg_mpi3mr.h>
13
14/**
15 * mpi3mr_bsg_pel_abort - sends PEL abort request
16 * @mrioc: Adapter instance reference
17 *
18 * This function sends PEL abort request to the firmware through
19 * admin request queue.
20 *
21 * Return: 0 on success, -1 on failure
22 */
23static int mpi3mr_bsg_pel_abort(struct mpi3mr_ioc *mrioc)
24{
25 struct mpi3_pel_req_action_abort pel_abort_req;
26 struct mpi3_pel_reply *pel_reply;
27 int retval = 0;
28 u16 pe_log_status;
29
30 if (mrioc->reset_in_progress) {
31 dprint_bsg_err(mrioc, "%s: reset in progress\n", __func__);
32 return -1;
33 }
34 if (mrioc->stop_bsgs) {
35 dprint_bsg_err(mrioc, "%s: bsgs are blocked\n", __func__);
36 return -1;
37 }
38
39 memset(&pel_abort_req, 0, sizeof(pel_abort_req));
40 mutex_lock(&mrioc->pel_abort_cmd.mutex);
41 if (mrioc->pel_abort_cmd.state & MPI3MR_CMD_PENDING) {
42 dprint_bsg_err(mrioc, "%s: command is in use\n", __func__);
43 mutex_unlock(&mrioc->pel_abort_cmd.mutex);
44 return -1;
45 }
46 mrioc->pel_abort_cmd.state = MPI3MR_CMD_PENDING;
47 mrioc->pel_abort_cmd.is_waiting = 1;
48 mrioc->pel_abort_cmd.callback = NULL;
49 pel_abort_req.host_tag = cpu_to_le16(MPI3MR_HOSTTAG_PEL_ABORT);
50 pel_abort_req.function = MPI3_FUNCTION_PERSISTENT_EVENT_LOG;
51 pel_abort_req.action = MPI3_PEL_ACTION_ABORT;
52 pel_abort_req.abort_host_tag = cpu_to_le16(MPI3MR_HOSTTAG_PEL_WAIT);
53
54 mrioc->pel_abort_requested = 1;
55 init_completion(&mrioc->pel_abort_cmd.done);
56 retval = mpi3mr_admin_request_post(mrioc, &pel_abort_req,
57 sizeof(pel_abort_req), 0);
58 if (retval) {
59 retval = -1;
60 dprint_bsg_err(mrioc, "%s: admin request post failed\n",
61 __func__);
62 mrioc->pel_abort_requested = 0;
63 goto out_unlock;
64 }
65
66 wait_for_completion_timeout(&mrioc->pel_abort_cmd.done,
67 (MPI3MR_INTADMCMD_TIMEOUT * HZ));
68 if (!(mrioc->pel_abort_cmd.state & MPI3MR_CMD_COMPLETE)) {
69 mrioc->pel_abort_cmd.is_waiting = 0;
70 dprint_bsg_err(mrioc, "%s: command timedout\n", __func__);
71 if (!(mrioc->pel_abort_cmd.state & MPI3MR_CMD_RESET))
72 mpi3mr_soft_reset_handler(mrioc,
73 MPI3MR_RESET_FROM_PELABORT_TIMEOUT, 1);
74 retval = -1;
75 goto out_unlock;
76 }
77 if ((mrioc->pel_abort_cmd.ioc_status & MPI3_IOCSTATUS_STATUS_MASK)
78 != MPI3_IOCSTATUS_SUCCESS) {
79 dprint_bsg_err(mrioc,
80 "%s: command failed, ioc_status(0x%04x) log_info(0x%08x)\n",
81 __func__, (mrioc->pel_abort_cmd.ioc_status &
82 MPI3_IOCSTATUS_STATUS_MASK),
83 mrioc->pel_abort_cmd.ioc_loginfo);
84 retval = -1;
85 goto out_unlock;
86 }
87 if (mrioc->pel_abort_cmd.state & MPI3MR_CMD_REPLY_VALID) {
88 pel_reply = (struct mpi3_pel_reply *)mrioc->pel_abort_cmd.reply;
89 pe_log_status = le16_to_cpu(pel_reply->pe_log_status);
90 if (pe_log_status != MPI3_PEL_STATUS_SUCCESS) {
91 dprint_bsg_err(mrioc,
92 "%s: command failed, pel_status(0x%04x)\n",
93 __func__, pe_log_status);
94 retval = -1;
95 }
96 }
97
98out_unlock:
99 mrioc->pel_abort_cmd.state = MPI3MR_CMD_NOTUSED;
100 mutex_unlock(&mrioc->pel_abort_cmd.mutex);
101 return retval;
102}
103/**
104 * mpi3mr_bsg_verify_adapter - verify adapter number is valid
105 * @ioc_number: Adapter number
106 *
107 * This function returns the adapter instance pointer of given
108 * adapter number. If adapter number does not match with the
109 * driver's adapter list, driver returns NULL.
110 *
111 * Return: adapter instance reference
112 */
113static struct mpi3mr_ioc *mpi3mr_bsg_verify_adapter(int ioc_number)
114{
115 struct mpi3mr_ioc *mrioc = NULL;
116
117 spin_lock(&mrioc_list_lock);
118 list_for_each_entry(mrioc, &mrioc_list, list) {
119 if (mrioc->id == ioc_number) {
120 spin_unlock(&mrioc_list_lock);
121 return mrioc;
122 }
123 }
124 spin_unlock(&mrioc_list_lock);
125 return NULL;
126}
127
128/**
129 * mpi3mr_enable_logdata - Handler for log data enable
130 * @mrioc: Adapter instance reference
131 * @job: BSG job reference
132 *
133 * This function enables log data caching in the driver if not
134 * already enabled and return the maximum number of log data
135 * entries that can be cached in the driver.
136 *
137 * Return: 0 on success and proper error codes on failure
138 */
139static long mpi3mr_enable_logdata(struct mpi3mr_ioc *mrioc,
140 struct bsg_job *job)
141{
142 struct mpi3mr_logdata_enable logdata_enable;
143
144 if (!mrioc->logdata_buf) {
145 mrioc->logdata_entry_sz =
146 (mrioc->reply_sz - (sizeof(struct mpi3_event_notification_reply) - 4))
147 + MPI3MR_BSG_LOGDATA_ENTRY_HEADER_SZ;
148 mrioc->logdata_buf_idx = 0;
149 mrioc->logdata_buf = kcalloc(MPI3MR_BSG_LOGDATA_MAX_ENTRIES,
150 mrioc->logdata_entry_sz, GFP_KERNEL);
151
152 if (!mrioc->logdata_buf)
153 return -ENOMEM;
154 }
155
156 memset(&logdata_enable, 0, sizeof(logdata_enable));
157 logdata_enable.max_entries =
158 MPI3MR_BSG_LOGDATA_MAX_ENTRIES;
159 if (job->request_payload.payload_len >= sizeof(logdata_enable)) {
160 sg_copy_from_buffer(job->request_payload.sg_list,
161 job->request_payload.sg_cnt,
162 &logdata_enable, sizeof(logdata_enable));
163 return 0;
164 }
165
166 return -EINVAL;
167}
168/**
169 * mpi3mr_get_logdata - Handler for get log data
170 * @mrioc: Adapter instance reference
171 * @job: BSG job pointer
172 * This function copies the log data entries to the user buffer
173 * when log caching is enabled in the driver.
174 *
175 * Return: 0 on success and proper error codes on failure
176 */
177static long mpi3mr_get_logdata(struct mpi3mr_ioc *mrioc,
178 struct bsg_job *job)
179{
180 u16 num_entries, sz, entry_sz = mrioc->logdata_entry_sz;
181
182 if ((!mrioc->logdata_buf) || (job->request_payload.payload_len < entry_sz))
183 return -EINVAL;
184
185 num_entries = job->request_payload.payload_len / entry_sz;
186 if (num_entries > MPI3MR_BSG_LOGDATA_MAX_ENTRIES)
187 num_entries = MPI3MR_BSG_LOGDATA_MAX_ENTRIES;
188 sz = num_entries * entry_sz;
189
190 if (job->request_payload.payload_len >= sz) {
191 sg_copy_from_buffer(job->request_payload.sg_list,
192 job->request_payload.sg_cnt,
193 mrioc->logdata_buf, sz);
194 return 0;
195 }
196 return -EINVAL;
197}
198
199/**
200 * mpi3mr_bsg_pel_enable - Handler for PEL enable driver
201 * @mrioc: Adapter instance reference
202 * @job: BSG job pointer
203 *
204 * This function is the handler for PEL enable driver.
205 * Validates the application given class and locale and if
206 * requires aborts the existing PEL wait request and/or issues
207 * new PEL wait request to the firmware and returns.
208 *
209 * Return: 0 on success and proper error codes on failure.
210 */
211static long mpi3mr_bsg_pel_enable(struct mpi3mr_ioc *mrioc,
212 struct bsg_job *job)
213{
214 long rval = -EINVAL;
215 struct mpi3mr_bsg_out_pel_enable pel_enable;
216 u8 issue_pel_wait;
217 u8 tmp_class;
218 u16 tmp_locale;
219
220 if (job->request_payload.payload_len != sizeof(pel_enable)) {
221 dprint_bsg_err(mrioc, "%s: invalid size argument\n",
222 __func__);
223 return rval;
224 }
225
226 sg_copy_to_buffer(job->request_payload.sg_list,
227 job->request_payload.sg_cnt,
228 &pel_enable, sizeof(pel_enable));
229
230 if (pel_enable.pel_class > MPI3_PEL_CLASS_FAULT) {
231 dprint_bsg_err(mrioc, "%s: out of range class %d sent\n",
232 __func__, pel_enable.pel_class);
233 rval = 0;
234 goto out;
235 }
236 if (!mrioc->pel_enabled)
237 issue_pel_wait = 1;
238 else {
239 if ((mrioc->pel_class <= pel_enable.pel_class) &&
240 !((mrioc->pel_locale & pel_enable.pel_locale) ^
241 pel_enable.pel_locale)) {
242 issue_pel_wait = 0;
243 rval = 0;
244 } else {
245 pel_enable.pel_locale |= mrioc->pel_locale;
246
247 if (mrioc->pel_class < pel_enable.pel_class)
248 pel_enable.pel_class = mrioc->pel_class;
249
250 rval = mpi3mr_bsg_pel_abort(mrioc);
251 if (rval) {
252 dprint_bsg_err(mrioc,
253 "%s: pel_abort failed, status(%ld)\n",
254 __func__, rval);
255 goto out;
256 }
257 issue_pel_wait = 1;
258 }
259 }
260 if (issue_pel_wait) {
261 tmp_class = mrioc->pel_class;
262 tmp_locale = mrioc->pel_locale;
263 mrioc->pel_class = pel_enable.pel_class;
264 mrioc->pel_locale = pel_enable.pel_locale;
265 mrioc->pel_enabled = 1;
266 rval = mpi3mr_pel_get_seqnum_post(mrioc, NULL);
267 if (rval) {
268 mrioc->pel_class = tmp_class;
269 mrioc->pel_locale = tmp_locale;
270 mrioc->pel_enabled = 0;
271 dprint_bsg_err(mrioc,
272 "%s: pel get sequence number failed, status(%ld)\n",
273 __func__, rval);
274 }
275 }
276
277out:
278 return rval;
279}
280/**
281 * mpi3mr_get_all_tgt_info - Get all target information
282 * @mrioc: Adapter instance reference
283 * @job: BSG job reference
284 *
285 * This function copies the driver managed target devices device
286 * handle, persistent ID, bus ID and taret ID to the user
287 * provided buffer for the specific controller. This function
288 * also provides the number of devices managed by the driver for
289 * the specific controller.
290 *
291 * Return: 0 on success and proper error codes on failure
292 */
293static long mpi3mr_get_all_tgt_info(struct mpi3mr_ioc *mrioc,
294 struct bsg_job *job)
295{
296 long rval = -EINVAL;
297 u16 num_devices = 0, i = 0, size;
298 unsigned long flags;
299 struct mpi3mr_tgt_dev *tgtdev;
300 struct mpi3mr_device_map_info *devmap_info = NULL;
301 struct mpi3mr_all_tgt_info *alltgt_info = NULL;
302 uint32_t min_entrylen = 0, kern_entrylen = 0, usr_entrylen = 0;
303
304 if (job->request_payload.payload_len < sizeof(u32)) {
305 dprint_bsg_err(mrioc, "%s: invalid size argument\n",
306 __func__);
307 return rval;
308 }
309
310 spin_lock_irqsave(&mrioc->tgtdev_lock, flags);
311 list_for_each_entry(tgtdev, &mrioc->tgtdev_list, list)
312 num_devices++;
313 spin_unlock_irqrestore(&mrioc->tgtdev_lock, flags);
314
315 if ((job->request_payload.payload_len == sizeof(u32)) ||
316 list_empty(&mrioc->tgtdev_list)) {
317 sg_copy_from_buffer(job->request_payload.sg_list,
318 job->request_payload.sg_cnt,
319 &num_devices, sizeof(num_devices));
320 return 0;
321 }
322
323 kern_entrylen = (num_devices - 1) * sizeof(*devmap_info);
324 size = sizeof(*alltgt_info) + kern_entrylen;
325 alltgt_info = kzalloc(size, GFP_KERNEL);
326 if (!alltgt_info)
327 return -ENOMEM;
328
329 devmap_info = alltgt_info->dmi;
330 memset((u8 *)devmap_info, 0xFF, (kern_entrylen + sizeof(*devmap_info)));
331 spin_lock_irqsave(&mrioc->tgtdev_lock, flags);
332 list_for_each_entry(tgtdev, &mrioc->tgtdev_list, list) {
333 if (i < num_devices) {
334 devmap_info[i].handle = tgtdev->dev_handle;
335 devmap_info[i].perst_id = tgtdev->perst_id;
336 if (tgtdev->host_exposed && tgtdev->starget) {
337 devmap_info[i].target_id = tgtdev->starget->id;
338 devmap_info[i].bus_id =
339 tgtdev->starget->channel;
340 }
341 i++;
342 }
343 }
344 num_devices = i;
345 spin_unlock_irqrestore(&mrioc->tgtdev_lock, flags);
346
347 memcpy(&alltgt_info->num_devices, &num_devices, sizeof(num_devices));
348
349 usr_entrylen = (job->request_payload.payload_len - sizeof(u32)) / sizeof(*devmap_info);
350 usr_entrylen *= sizeof(*devmap_info);
351 min_entrylen = min(usr_entrylen, kern_entrylen);
352 if (min_entrylen && (!memcpy(&alltgt_info->dmi, devmap_info, min_entrylen))) {
353 dprint_bsg_err(mrioc, "%s:%d: device map info copy failed\n",
354 __func__, __LINE__);
355 rval = -EFAULT;
356 goto out;
357 }
358
359 sg_copy_from_buffer(job->request_payload.sg_list,
360 job->request_payload.sg_cnt,
361 alltgt_info, job->request_payload.payload_len);
362 rval = 0;
363out:
364 kfree(alltgt_info);
365 return rval;
366}
367/**
368 * mpi3mr_get_change_count - Get topology change count
369 * @mrioc: Adapter instance reference
370 * @job: BSG job reference
371 *
372 * This function copies the toplogy change count provided by the
373 * driver in events and cached in the driver to the user
374 * provided buffer for the specific controller.
375 *
376 * Return: 0 on success and proper error codes on failure
377 */
378static long mpi3mr_get_change_count(struct mpi3mr_ioc *mrioc,
379 struct bsg_job *job)
380{
381 struct mpi3mr_change_count chgcnt;
382
383 memset(&chgcnt, 0, sizeof(chgcnt));
384 chgcnt.change_count = mrioc->change_count;
385 if (job->request_payload.payload_len >= sizeof(chgcnt)) {
386 sg_copy_from_buffer(job->request_payload.sg_list,
387 job->request_payload.sg_cnt,
388 &chgcnt, sizeof(chgcnt));
389 return 0;
390 }
391 return -EINVAL;
392}
393
394/**
395 * mpi3mr_bsg_adp_reset - Issue controller reset
396 * @mrioc: Adapter instance reference
397 * @job: BSG job reference
398 *
399 * This function identifies the user provided reset type and
400 * issues approporiate reset to the controller and wait for that
401 * to complete and reinitialize the controller and then returns
402 *
403 * Return: 0 on success and proper error codes on failure
404 */
405static long mpi3mr_bsg_adp_reset(struct mpi3mr_ioc *mrioc,
406 struct bsg_job *job)
407{
408 long rval = -EINVAL;
409 u8 save_snapdump;
410 struct mpi3mr_bsg_adp_reset adpreset;
411
412 if (job->request_payload.payload_len !=
413 sizeof(adpreset)) {
414 dprint_bsg_err(mrioc, "%s: invalid size argument\n",
415 __func__);
416 goto out;
417 }
418
419 sg_copy_to_buffer(job->request_payload.sg_list,
420 job->request_payload.sg_cnt,
421 &adpreset, sizeof(adpreset));
422
423 switch (adpreset.reset_type) {
424 case MPI3MR_BSG_ADPRESET_SOFT:
425 save_snapdump = 0;
426 break;
427 case MPI3MR_BSG_ADPRESET_DIAG_FAULT:
428 save_snapdump = 1;
429 break;
430 default:
431 dprint_bsg_err(mrioc, "%s: unknown reset_type(%d)\n",
432 __func__, adpreset.reset_type);
433 goto out;
434 }
435
436 rval = mpi3mr_soft_reset_handler(mrioc, MPI3MR_RESET_FROM_APP,
437 save_snapdump);
438
439 if (rval)
440 dprint_bsg_err(mrioc,
441 "%s: reset handler returned error(%ld) for reset type %d\n",
442 __func__, rval, adpreset.reset_type);
443out:
444 return rval;
445}
446
447/**
448 * mpi3mr_bsg_populate_adpinfo - Get adapter info command handler
449 * @mrioc: Adapter instance reference
450 * @job: BSG job reference
451 *
452 * This function provides adapter information for the given
453 * controller
454 *
455 * Return: 0 on success and proper error codes on failure
456 */
457static long mpi3mr_bsg_populate_adpinfo(struct mpi3mr_ioc *mrioc,
458 struct bsg_job *job)
459{
460 enum mpi3mr_iocstate ioc_state;
461 struct mpi3mr_bsg_in_adpinfo adpinfo;
462
463 memset(&adpinfo, 0, sizeof(adpinfo));
464 adpinfo.adp_type = MPI3MR_BSG_ADPTYPE_AVGFAMILY;
465 adpinfo.pci_dev_id = mrioc->pdev->device;
466 adpinfo.pci_dev_hw_rev = mrioc->pdev->revision;
467 adpinfo.pci_subsys_dev_id = mrioc->pdev->subsystem_device;
468 adpinfo.pci_subsys_ven_id = mrioc->pdev->subsystem_vendor;
469 adpinfo.pci_bus = mrioc->pdev->bus->number;
470 adpinfo.pci_dev = PCI_SLOT(mrioc->pdev->devfn);
471 adpinfo.pci_func = PCI_FUNC(mrioc->pdev->devfn);
472 adpinfo.pci_seg_id = pci_domain_nr(mrioc->pdev->bus);
473 adpinfo.app_intfc_ver = MPI3MR_IOCTL_VERSION;
474
475 ioc_state = mpi3mr_get_iocstate(mrioc);
476 if (ioc_state == MRIOC_STATE_UNRECOVERABLE)
477 adpinfo.adp_state = MPI3MR_BSG_ADPSTATE_UNRECOVERABLE;
478 else if ((mrioc->reset_in_progress) || (mrioc->stop_bsgs))
479 adpinfo.adp_state = MPI3MR_BSG_ADPSTATE_IN_RESET;
480 else if (ioc_state == MRIOC_STATE_FAULT)
481 adpinfo.adp_state = MPI3MR_BSG_ADPSTATE_FAULT;
482 else
483 adpinfo.adp_state = MPI3MR_BSG_ADPSTATE_OPERATIONAL;
484
485 memcpy((u8 *)&adpinfo.driver_info, (u8 *)&mrioc->driver_info,
486 sizeof(adpinfo.driver_info));
487
488 if (job->request_payload.payload_len >= sizeof(adpinfo)) {
489 sg_copy_from_buffer(job->request_payload.sg_list,
490 job->request_payload.sg_cnt,
491 &adpinfo, sizeof(adpinfo));
492 return 0;
493 }
494 return -EINVAL;
495}
496
497/**
498 * mpi3mr_bsg_process_drv_cmds - Driver Command handler
499 * @job: BSG job reference
500 *
501 * This function is the top level handler for driver commands,
502 * this does basic validation of the buffer and identifies the
503 * opcode and switches to correct sub handler.
504 *
505 * Return: 0 on success and proper error codes on failure
506 */
507static long mpi3mr_bsg_process_drv_cmds(struct bsg_job *job)
508{
509 long rval = -EINVAL;
510 struct mpi3mr_ioc *mrioc = NULL;
511 struct mpi3mr_bsg_packet *bsg_req = NULL;
512 struct mpi3mr_bsg_drv_cmd *drvrcmd = NULL;
513
514 bsg_req = job->request;
515 drvrcmd = &bsg_req->cmd.drvrcmd;
516
517 mrioc = mpi3mr_bsg_verify_adapter(drvrcmd->mrioc_id);
518 if (!mrioc)
519 return -ENODEV;
520
521 if (drvrcmd->opcode == MPI3MR_DRVBSG_OPCODE_ADPINFO) {
522 rval = mpi3mr_bsg_populate_adpinfo(mrioc, job);
523 return rval;
524 }
525
526 if (mutex_lock_interruptible(&mrioc->bsg_cmds.mutex))
527 return -ERESTARTSYS;
528
529 switch (drvrcmd->opcode) {
530 case MPI3MR_DRVBSG_OPCODE_ADPRESET:
531 rval = mpi3mr_bsg_adp_reset(mrioc, job);
532 break;
533 case MPI3MR_DRVBSG_OPCODE_ALLTGTDEVINFO:
534 rval = mpi3mr_get_all_tgt_info(mrioc, job);
535 break;
536 case MPI3MR_DRVBSG_OPCODE_GETCHGCNT:
537 rval = mpi3mr_get_change_count(mrioc, job);
538 break;
539 case MPI3MR_DRVBSG_OPCODE_LOGDATAENABLE:
540 rval = mpi3mr_enable_logdata(mrioc, job);
541 break;
542 case MPI3MR_DRVBSG_OPCODE_GETLOGDATA:
543 rval = mpi3mr_get_logdata(mrioc, job);
544 break;
545 case MPI3MR_DRVBSG_OPCODE_PELENABLE:
546 rval = mpi3mr_bsg_pel_enable(mrioc, job);
547 break;
548 case MPI3MR_DRVBSG_OPCODE_UNKNOWN:
549 default:
550 pr_err("%s: unsupported driver command opcode %d\n",
551 MPI3MR_DRIVER_NAME, drvrcmd->opcode);
552 break;
553 }
554 mutex_unlock(&mrioc->bsg_cmds.mutex);
555 return rval;
556}
557
558/**
559 * mpi3mr_bsg_build_sgl - SGL construction for MPI commands
560 * @mpi_req: MPI request
561 * @sgl_offset: offset to start sgl in the MPI request
562 * @drv_bufs: DMA address of the buffers to be placed in sgl
563 * @bufcnt: Number of DMA buffers
564 * @is_rmc: Does the buffer list has management command buffer
565 * @is_rmr: Does the buffer list has management response buffer
566 * @num_datasges: Number of data buffers in the list
567 *
568 * This function places the DMA address of the given buffers in
569 * proper format as SGEs in the given MPI request.
570 *
571 * Return: Nothing
572 */
573static void mpi3mr_bsg_build_sgl(u8 *mpi_req, uint32_t sgl_offset,
574 struct mpi3mr_buf_map *drv_bufs, u8 bufcnt, u8 is_rmc,
575 u8 is_rmr, u8 num_datasges)
576{
577 u8 *sgl = (mpi_req + sgl_offset), count = 0;
578 struct mpi3_mgmt_passthrough_request *rmgmt_req =
579 (struct mpi3_mgmt_passthrough_request *)mpi_req;
580 struct mpi3mr_buf_map *drv_buf_iter = drv_bufs;
581 u8 sgl_flags, sgl_flags_last;
582
583 sgl_flags = MPI3_SGE_FLAGS_ELEMENT_TYPE_SIMPLE |
584 MPI3_SGE_FLAGS_DLAS_SYSTEM | MPI3_SGE_FLAGS_END_OF_BUFFER;
585 sgl_flags_last = sgl_flags | MPI3_SGE_FLAGS_END_OF_LIST;
586
587 if (is_rmc) {
588 mpi3mr_add_sg_single(&rmgmt_req->command_sgl,
589 sgl_flags_last, drv_buf_iter->kern_buf_len,
590 drv_buf_iter->kern_buf_dma);
591 sgl = (u8 *)drv_buf_iter->kern_buf + drv_buf_iter->bsg_buf_len;
592 drv_buf_iter++;
593 count++;
594 if (is_rmr) {
595 mpi3mr_add_sg_single(&rmgmt_req->response_sgl,
596 sgl_flags_last, drv_buf_iter->kern_buf_len,
597 drv_buf_iter->kern_buf_dma);
598 drv_buf_iter++;
599 count++;
600 } else
601 mpi3mr_build_zero_len_sge(
602 &rmgmt_req->response_sgl);
603 }
604 if (!num_datasges) {
605 mpi3mr_build_zero_len_sge(sgl);
606 return;
607 }
608 for (; count < bufcnt; count++, drv_buf_iter++) {
609 if (drv_buf_iter->data_dir == DMA_NONE)
610 continue;
611 if (num_datasges == 1 || !is_rmc)
612 mpi3mr_add_sg_single(sgl, sgl_flags_last,
613 drv_buf_iter->kern_buf_len, drv_buf_iter->kern_buf_dma);
614 else
615 mpi3mr_add_sg_single(sgl, sgl_flags,
616 drv_buf_iter->kern_buf_len, drv_buf_iter->kern_buf_dma);
617 sgl += sizeof(struct mpi3_sge_common);
618 num_datasges--;
619 }
620}
621
622/**
623 * mpi3mr_get_nvme_data_fmt - returns the NVMe data format
624 * @nvme_encap_request: NVMe encapsulated MPI request
625 *
626 * This function returns the type of the data format specified
627 * in user provided NVMe command in NVMe encapsulated request.
628 *
629 * Return: Data format of the NVMe command (PRP/SGL etc)
630 */
631static unsigned int mpi3mr_get_nvme_data_fmt(
632 struct mpi3_nvme_encapsulated_request *nvme_encap_request)
633{
634 u8 format = 0;
635
636 format = ((nvme_encap_request->command[0] & 0xc000) >> 14);
637 return format;
638
639}
640
641/**
642 * mpi3mr_build_nvme_sgl - SGL constructor for NVME
643 * encapsulated request
644 * @mrioc: Adapter instance reference
645 * @nvme_encap_request: NVMe encapsulated MPI request
646 * @drv_bufs: DMA address of the buffers to be placed in sgl
647 * @bufcnt: Number of DMA buffers
648 *
649 * This function places the DMA address of the given buffers in
650 * proper format as SGEs in the given NVMe encapsulated request.
651 *
652 * Return: 0 on success, -1 on failure
653 */
654static int mpi3mr_build_nvme_sgl(struct mpi3mr_ioc *mrioc,
655 struct mpi3_nvme_encapsulated_request *nvme_encap_request,
656 struct mpi3mr_buf_map *drv_bufs, u8 bufcnt)
657{
658 struct mpi3mr_nvme_pt_sge *nvme_sgl;
659 u64 sgl_ptr;
660 u8 count;
661 size_t length = 0;
662 struct mpi3mr_buf_map *drv_buf_iter = drv_bufs;
663 u64 sgemod_mask = ((u64)((mrioc->facts.sge_mod_mask) <<
664 mrioc->facts.sge_mod_shift) << 32);
665 u64 sgemod_val = ((u64)(mrioc->facts.sge_mod_value) <<
666 mrioc->facts.sge_mod_shift) << 32;
667
668 /*
669 * Not all commands require a data transfer. If no data, just return
670 * without constructing any sgl.
671 */
672 for (count = 0; count < bufcnt; count++, drv_buf_iter++) {
673 if (drv_buf_iter->data_dir == DMA_NONE)
674 continue;
675 sgl_ptr = (u64)drv_buf_iter->kern_buf_dma;
676 length = drv_buf_iter->kern_buf_len;
677 break;
678 }
679 if (!length)
680 return 0;
681
682 if (sgl_ptr & sgemod_mask) {
683 dprint_bsg_err(mrioc,
684 "%s: SGL address collides with SGE modifier\n",
685 __func__);
686 return -1;
687 }
688
689 sgl_ptr &= ~sgemod_mask;
690 sgl_ptr |= sgemod_val;
691 nvme_sgl = (struct mpi3mr_nvme_pt_sge *)
692 ((u8 *)(nvme_encap_request->command) + MPI3MR_NVME_CMD_SGL_OFFSET);
693 memset(nvme_sgl, 0, sizeof(struct mpi3mr_nvme_pt_sge));
694 nvme_sgl->base_addr = sgl_ptr;
695 nvme_sgl->length = length;
696 return 0;
697}
698
699/**
700 * mpi3mr_build_nvme_prp - PRP constructor for NVME
701 * encapsulated request
702 * @mrioc: Adapter instance reference
703 * @nvme_encap_request: NVMe encapsulated MPI request
704 * @drv_bufs: DMA address of the buffers to be placed in SGL
705 * @bufcnt: Number of DMA buffers
706 *
707 * This function places the DMA address of the given buffers in
708 * proper format as PRP entries in the given NVMe encapsulated
709 * request.
710 *
711 * Return: 0 on success, -1 on failure
712 */
713static int mpi3mr_build_nvme_prp(struct mpi3mr_ioc *mrioc,
714 struct mpi3_nvme_encapsulated_request *nvme_encap_request,
715 struct mpi3mr_buf_map *drv_bufs, u8 bufcnt)
716{
717 int prp_size = MPI3MR_NVME_PRP_SIZE;
718 __le64 *prp_entry, *prp1_entry, *prp2_entry;
719 __le64 *prp_page;
720 dma_addr_t prp_entry_dma, prp_page_dma, dma_addr;
721 u32 offset, entry_len, dev_pgsz;
722 u32 page_mask_result, page_mask;
723 size_t length = 0;
724 u8 count;
725 struct mpi3mr_buf_map *drv_buf_iter = drv_bufs;
726 u64 sgemod_mask = ((u64)((mrioc->facts.sge_mod_mask) <<
727 mrioc->facts.sge_mod_shift) << 32);
728 u64 sgemod_val = ((u64)(mrioc->facts.sge_mod_value) <<
729 mrioc->facts.sge_mod_shift) << 32;
730 u16 dev_handle = nvme_encap_request->dev_handle;
731 struct mpi3mr_tgt_dev *tgtdev;
732
733 tgtdev = mpi3mr_get_tgtdev_by_handle(mrioc, dev_handle);
734 if (!tgtdev) {
735 dprint_bsg_err(mrioc, "%s: invalid device handle 0x%04x\n",
736 __func__, dev_handle);
737 return -1;
738 }
739
740 if (tgtdev->dev_spec.pcie_inf.pgsz == 0) {
741 dprint_bsg_err(mrioc,
742 "%s: NVMe device page size is zero for handle 0x%04x\n",
743 __func__, dev_handle);
744 mpi3mr_tgtdev_put(tgtdev);
745 return -1;
746 }
747
748 dev_pgsz = 1 << (tgtdev->dev_spec.pcie_inf.pgsz);
749 mpi3mr_tgtdev_put(tgtdev);
750
751 /*
752 * Not all commands require a data transfer. If no data, just return
753 * without constructing any PRP.
754 */
755 for (count = 0; count < bufcnt; count++, drv_buf_iter++) {
756 if (drv_buf_iter->data_dir == DMA_NONE)
757 continue;
758 dma_addr = drv_buf_iter->kern_buf_dma;
759 length = drv_buf_iter->kern_buf_len;
760 break;
761 }
762
763 if (!length)
764 return 0;
765
766 mrioc->prp_sz = 0;
767 mrioc->prp_list_virt = dma_alloc_coherent(&mrioc->pdev->dev,
768 dev_pgsz, &mrioc->prp_list_dma, GFP_KERNEL);
769
770 if (!mrioc->prp_list_virt)
771 return -1;
772 mrioc->prp_sz = dev_pgsz;
773
774 /*
775 * Set pointers to PRP1 and PRP2, which are in the NVMe command.
776 * PRP1 is located at a 24 byte offset from the start of the NVMe
777 * command. Then set the current PRP entry pointer to PRP1.
778 */
779 prp1_entry = (__le64 *)((u8 *)(nvme_encap_request->command) +
780 MPI3MR_NVME_CMD_PRP1_OFFSET);
781 prp2_entry = (__le64 *)((u8 *)(nvme_encap_request->command) +
782 MPI3MR_NVME_CMD_PRP2_OFFSET);
783 prp_entry = prp1_entry;
784 /*
785 * For the PRP entries, use the specially allocated buffer of
786 * contiguous memory.
787 */
788 prp_page = (__le64 *)mrioc->prp_list_virt;
789 prp_page_dma = mrioc->prp_list_dma;
790
791 /*
792 * Check if we are within 1 entry of a page boundary we don't
793 * want our first entry to be a PRP List entry.
794 */
795 page_mask = dev_pgsz - 1;
796 page_mask_result = (uintptr_t)((u8 *)prp_page + prp_size) & page_mask;
797 if (!page_mask_result) {
798 dprint_bsg_err(mrioc, "%s: PRP page is not page aligned\n",
799 __func__);
800 goto err_out;
801 }
802
803 /*
804 * Set PRP physical pointer, which initially points to the current PRP
805 * DMA memory page.
806 */
807 prp_entry_dma = prp_page_dma;
808
809
810 /* Loop while the length is not zero. */
811 while (length) {
812 page_mask_result = (prp_entry_dma + prp_size) & page_mask;
813 if (!page_mask_result && (length > dev_pgsz)) {
814 dprint_bsg_err(mrioc,
815 "%s: single PRP page is not sufficient\n",
816 __func__);
817 goto err_out;
818 }
819
820 /* Need to handle if entry will be part of a page. */
821 offset = dma_addr & page_mask;
822 entry_len = dev_pgsz - offset;
823
824 if (prp_entry == prp1_entry) {
825 /*
826 * Must fill in the first PRP pointer (PRP1) before
827 * moving on.
828 */
829 *prp1_entry = cpu_to_le64(dma_addr);
830 if (*prp1_entry & sgemod_mask) {
831 dprint_bsg_err(mrioc,
832 "%s: PRP1 address collides with SGE modifier\n",
833 __func__);
834 goto err_out;
835 }
836 *prp1_entry &= ~sgemod_mask;
837 *prp1_entry |= sgemod_val;
838
839 /*
840 * Now point to the second PRP entry within the
841 * command (PRP2).
842 */
843 prp_entry = prp2_entry;
844 } else if (prp_entry == prp2_entry) {
845 /*
846 * Should the PRP2 entry be a PRP List pointer or just
847 * a regular PRP pointer? If there is more than one
848 * more page of data, must use a PRP List pointer.
849 */
850 if (length > dev_pgsz) {
851 /*
852 * PRP2 will contain a PRP List pointer because
853 * more PRP's are needed with this command. The
854 * list will start at the beginning of the
855 * contiguous buffer.
856 */
857 *prp2_entry = cpu_to_le64(prp_entry_dma);
858 if (*prp2_entry & sgemod_mask) {
859 dprint_bsg_err(mrioc,
860 "%s: PRP list address collides with SGE modifier\n",
861 __func__);
862 goto err_out;
863 }
864 *prp2_entry &= ~sgemod_mask;
865 *prp2_entry |= sgemod_val;
866
867 /*
868 * The next PRP Entry will be the start of the
869 * first PRP List.
870 */
871 prp_entry = prp_page;
872 continue;
873 } else {
874 /*
875 * After this, the PRP Entries are complete.
876 * This command uses 2 PRP's and no PRP list.
877 */
878 *prp2_entry = cpu_to_le64(dma_addr);
879 if (*prp2_entry & sgemod_mask) {
880 dprint_bsg_err(mrioc,
881 "%s: PRP2 collides with SGE modifier\n",
882 __func__);
883 goto err_out;
884 }
885 *prp2_entry &= ~sgemod_mask;
886 *prp2_entry |= sgemod_val;
887 }
888 } else {
889 /*
890 * Put entry in list and bump the addresses.
891 *
892 * After PRP1 and PRP2 are filled in, this will fill in
893 * all remaining PRP entries in a PRP List, one per
894 * each time through the loop.
895 */
896 *prp_entry = cpu_to_le64(dma_addr);
897 if (*prp1_entry & sgemod_mask) {
898 dprint_bsg_err(mrioc,
899 "%s: PRP address collides with SGE modifier\n",
900 __func__);
901 goto err_out;
902 }
903 *prp_entry &= ~sgemod_mask;
904 *prp_entry |= sgemod_val;
905 prp_entry++;
906 prp_entry_dma++;
907 }
908
909 /*
910 * Bump the phys address of the command's data buffer by the
911 * entry_len.
912 */
913 dma_addr += entry_len;
914
915 /* decrement length accounting for last partial page. */
916 if (entry_len > length)
917 length = 0;
918 else
919 length -= entry_len;
920 }
921 return 0;
922err_out:
923 if (mrioc->prp_list_virt) {
924 dma_free_coherent(&mrioc->pdev->dev, mrioc->prp_sz,
925 mrioc->prp_list_virt, mrioc->prp_list_dma);
926 mrioc->prp_list_virt = NULL;
927 }
928 return -1;
929}
930/**
931 * mpi3mr_bsg_process_mpt_cmds - MPI Pass through BSG handler
932 * @job: BSG job reference
933 *
934 * This function is the top level handler for MPI Pass through
935 * command, this does basic validation of the input data buffers,
936 * identifies the given buffer types and MPI command, allocates
937 * DMAable memory for user given buffers, construstcs SGL
938 * properly and passes the command to the firmware.
939 *
940 * Once the MPI command is completed the driver copies the data
941 * if any and reply, sense information to user provided buffers.
942 * If the command is timed out then issues controller reset
943 * prior to returning.
944 *
945 * Return: 0 on success and proper error codes on failure
946 */
947
948static long mpi3mr_bsg_process_mpt_cmds(struct bsg_job *job, unsigned int *reply_payload_rcv_len)
949{
950 long rval = -EINVAL;
951
952 struct mpi3mr_ioc *mrioc = NULL;
953 u8 *mpi_req = NULL, *sense_buff_k = NULL;
954 u8 mpi_msg_size = 0;
955 struct mpi3mr_bsg_packet *bsg_req = NULL;
956 struct mpi3mr_bsg_mptcmd *karg;
957 struct mpi3mr_buf_entry *buf_entries = NULL;
958 struct mpi3mr_buf_map *drv_bufs = NULL, *drv_buf_iter = NULL;
959 u8 count, bufcnt = 0, is_rmcb = 0, is_rmrb = 0, din_cnt = 0, dout_cnt = 0;
960 u8 invalid_be = 0, erb_offset = 0xFF, mpirep_offset = 0xFF, sg_entries = 0;
961 u8 block_io = 0, resp_code = 0, nvme_fmt = 0;
962 struct mpi3_request_header *mpi_header = NULL;
963 struct mpi3_status_reply_descriptor *status_desc;
964 struct mpi3_scsi_task_mgmt_request *tm_req;
965 u32 erbsz = MPI3MR_SENSE_BUF_SZ, tmplen;
966 u16 dev_handle;
967 struct mpi3mr_tgt_dev *tgtdev;
968 struct mpi3mr_stgt_priv_data *stgt_priv = NULL;
969 struct mpi3mr_bsg_in_reply_buf *bsg_reply_buf = NULL;
970 u32 din_size = 0, dout_size = 0;
971 u8 *din_buf = NULL, *dout_buf = NULL;
972 u8 *sgl_iter = NULL, *sgl_din_iter = NULL, *sgl_dout_iter = NULL;
973
974 bsg_req = job->request;
975 karg = (struct mpi3mr_bsg_mptcmd *)&bsg_req->cmd.mptcmd;
976
977 mrioc = mpi3mr_bsg_verify_adapter(karg->mrioc_id);
978 if (!mrioc)
979 return -ENODEV;
980
981 if (karg->timeout < MPI3MR_APP_DEFAULT_TIMEOUT)
982 karg->timeout = MPI3MR_APP_DEFAULT_TIMEOUT;
983
984 mpi_req = kzalloc(MPI3MR_ADMIN_REQ_FRAME_SZ, GFP_KERNEL);
985 if (!mpi_req)
986 return -ENOMEM;
987 mpi_header = (struct mpi3_request_header *)mpi_req;
988
989 bufcnt = karg->buf_entry_list.num_of_entries;
990 drv_bufs = kzalloc((sizeof(*drv_bufs) * bufcnt), GFP_KERNEL);
991 if (!drv_bufs) {
992 rval = -ENOMEM;
993 goto out;
994 }
995
996 dout_buf = kzalloc(job->request_payload.payload_len,
997 GFP_KERNEL);
998 if (!dout_buf) {
999 rval = -ENOMEM;
1000 goto out;
1001 }
1002
1003 din_buf = kzalloc(job->reply_payload.payload_len,
1004 GFP_KERNEL);
1005 if (!din_buf) {
1006 rval = -ENOMEM;
1007 goto out;
1008 }
1009
1010 sg_copy_to_buffer(job->request_payload.sg_list,
1011 job->request_payload.sg_cnt,
1012 dout_buf, job->request_payload.payload_len);
1013
1014 buf_entries = karg->buf_entry_list.buf_entry;
1015 sgl_din_iter = din_buf;
1016 sgl_dout_iter = dout_buf;
1017 drv_buf_iter = drv_bufs;
1018
1019 for (count = 0; count < bufcnt; count++, buf_entries++, drv_buf_iter++) {
1020
1021 if (sgl_dout_iter > (dout_buf + job->request_payload.payload_len)) {
1022 dprint_bsg_err(mrioc, "%s: data_out buffer length mismatch\n",
1023 __func__);
1024 rval = -EINVAL;
1025 goto out;
1026 }
1027 if (sgl_din_iter > (din_buf + job->reply_payload.payload_len)) {
1028 dprint_bsg_err(mrioc, "%s: data_in buffer length mismatch\n",
1029 __func__);
1030 rval = -EINVAL;
1031 goto out;
1032 }
1033
1034 switch (buf_entries->buf_type) {
1035 case MPI3MR_BSG_BUFTYPE_RAIDMGMT_CMD:
1036 sgl_iter = sgl_dout_iter;
1037 sgl_dout_iter += buf_entries->buf_len;
1038 drv_buf_iter->data_dir = DMA_TO_DEVICE;
1039 is_rmcb = 1;
1040 if (count != 0)
1041 invalid_be = 1;
1042 break;
1043 case MPI3MR_BSG_BUFTYPE_RAIDMGMT_RESP:
1044 sgl_iter = sgl_din_iter;
1045 sgl_din_iter += buf_entries->buf_len;
1046 drv_buf_iter->data_dir = DMA_FROM_DEVICE;
1047 is_rmrb = 1;
1048 if (count != 1 || !is_rmcb)
1049 invalid_be = 1;
1050 break;
1051 case MPI3MR_BSG_BUFTYPE_DATA_IN:
1052 sgl_iter = sgl_din_iter;
1053 sgl_din_iter += buf_entries->buf_len;
1054 drv_buf_iter->data_dir = DMA_FROM_DEVICE;
1055 din_cnt++;
1056 din_size += drv_buf_iter->bsg_buf_len;
1057 if ((din_cnt > 1) && !is_rmcb)
1058 invalid_be = 1;
1059 break;
1060 case MPI3MR_BSG_BUFTYPE_DATA_OUT:
1061 sgl_iter = sgl_dout_iter;
1062 sgl_dout_iter += buf_entries->buf_len;
1063 drv_buf_iter->data_dir = DMA_TO_DEVICE;
1064 dout_cnt++;
1065 dout_size += drv_buf_iter->bsg_buf_len;
1066 if ((dout_cnt > 1) && !is_rmcb)
1067 invalid_be = 1;
1068 break;
1069 case MPI3MR_BSG_BUFTYPE_MPI_REPLY:
1070 sgl_iter = sgl_din_iter;
1071 sgl_din_iter += buf_entries->buf_len;
1072 drv_buf_iter->data_dir = DMA_NONE;
1073 mpirep_offset = count;
1074 break;
1075 case MPI3MR_BSG_BUFTYPE_ERR_RESPONSE:
1076 sgl_iter = sgl_din_iter;
1077 sgl_din_iter += buf_entries->buf_len;
1078 drv_buf_iter->data_dir = DMA_NONE;
1079 erb_offset = count;
1080 break;
1081 case MPI3MR_BSG_BUFTYPE_MPI_REQUEST:
1082 sgl_iter = sgl_dout_iter;
1083 sgl_dout_iter += buf_entries->buf_len;
1084 drv_buf_iter->data_dir = DMA_NONE;
1085 mpi_msg_size = buf_entries->buf_len;
1086 if ((!mpi_msg_size || (mpi_msg_size % 4)) ||
1087 (mpi_msg_size > MPI3MR_ADMIN_REQ_FRAME_SZ)) {
1088 dprint_bsg_err(mrioc, "%s: invalid MPI message size\n",
1089 __func__);
1090 rval = -EINVAL;
1091 goto out;
1092 }
1093 memcpy(mpi_req, sgl_iter, buf_entries->buf_len);
1094 break;
1095 default:
1096 invalid_be = 1;
1097 break;
1098 }
1099 if (invalid_be) {
1100 dprint_bsg_err(mrioc, "%s: invalid buffer entries passed\n",
1101 __func__);
1102 rval = -EINVAL;
1103 goto out;
1104 }
1105
1106 drv_buf_iter->bsg_buf = sgl_iter;
1107 drv_buf_iter->bsg_buf_len = buf_entries->buf_len;
1108
1109 }
1110 if (!is_rmcb && (dout_cnt || din_cnt)) {
1111 sg_entries = dout_cnt + din_cnt;
1112 if (((mpi_msg_size) + (sg_entries *
1113 sizeof(struct mpi3_sge_common))) > MPI3MR_ADMIN_REQ_FRAME_SZ) {
1114 dprint_bsg_err(mrioc,
1115 "%s:%d: invalid message size passed\n",
1116 __func__, __LINE__);
1117 rval = -EINVAL;
1118 goto out;
1119 }
1120 }
1121 if (din_size > MPI3MR_MAX_APP_XFER_SIZE) {
1122 dprint_bsg_err(mrioc,
1123 "%s:%d: invalid data transfer size passed for function 0x%x din_size=%d\n",
1124 __func__, __LINE__, mpi_header->function, din_size);
1125 rval = -EINVAL;
1126 goto out;
1127 }
1128 if (dout_size > MPI3MR_MAX_APP_XFER_SIZE) {
1129 dprint_bsg_err(mrioc,
1130 "%s:%d: invalid data transfer size passed for function 0x%x dout_size = %d\n",
1131 __func__, __LINE__, mpi_header->function, dout_size);
1132 rval = -EINVAL;
1133 goto out;
1134 }
1135
1136 drv_buf_iter = drv_bufs;
1137 for (count = 0; count < bufcnt; count++, drv_buf_iter++) {
1138 if (drv_buf_iter->data_dir == DMA_NONE)
1139 continue;
1140
1141 drv_buf_iter->kern_buf_len = drv_buf_iter->bsg_buf_len;
1142 if (is_rmcb && !count)
1143 drv_buf_iter->kern_buf_len += ((dout_cnt + din_cnt) *
1144 sizeof(struct mpi3_sge_common));
1145
1146 if (!drv_buf_iter->kern_buf_len)
1147 continue;
1148
1149 drv_buf_iter->kern_buf = dma_alloc_coherent(&mrioc->pdev->dev,
1150 drv_buf_iter->kern_buf_len, &drv_buf_iter->kern_buf_dma,
1151 GFP_KERNEL);
1152 if (!drv_buf_iter->kern_buf) {
1153 rval = -ENOMEM;
1154 goto out;
1155 }
1156 if (drv_buf_iter->data_dir == DMA_TO_DEVICE) {
1157 tmplen = min(drv_buf_iter->kern_buf_len,
1158 drv_buf_iter->bsg_buf_len);
1159 memcpy(drv_buf_iter->kern_buf, drv_buf_iter->bsg_buf, tmplen);
1160 }
1161 }
1162
1163 if (erb_offset != 0xFF) {
1164 sense_buff_k = kzalloc(erbsz, GFP_KERNEL);
1165 if (!sense_buff_k) {
1166 rval = -ENOMEM;
1167 goto out;
1168 }
1169 }
1170
1171 if (mutex_lock_interruptible(&mrioc->bsg_cmds.mutex)) {
1172 rval = -ERESTARTSYS;
1173 goto out;
1174 }
1175 if (mrioc->bsg_cmds.state & MPI3MR_CMD_PENDING) {
1176 rval = -EAGAIN;
1177 dprint_bsg_err(mrioc, "%s: command is in use\n", __func__);
1178 mutex_unlock(&mrioc->bsg_cmds.mutex);
1179 goto out;
1180 }
1181 if (mrioc->unrecoverable) {
1182 dprint_bsg_err(mrioc, "%s: unrecoverable controller\n",
1183 __func__);
1184 rval = -EFAULT;
1185 mutex_unlock(&mrioc->bsg_cmds.mutex);
1186 goto out;
1187 }
1188 if (mrioc->reset_in_progress) {
1189 dprint_bsg_err(mrioc, "%s: reset in progress\n", __func__);
1190 rval = -EAGAIN;
1191 mutex_unlock(&mrioc->bsg_cmds.mutex);
1192 goto out;
1193 }
1194 if (mrioc->stop_bsgs) {
1195 dprint_bsg_err(mrioc, "%s: bsgs are blocked\n", __func__);
1196 rval = -EAGAIN;
1197 mutex_unlock(&mrioc->bsg_cmds.mutex);
1198 goto out;
1199 }
1200
1201 if (mpi_header->function == MPI3_BSG_FUNCTION_NVME_ENCAPSULATED) {
1202 nvme_fmt = mpi3mr_get_nvme_data_fmt(
1203 (struct mpi3_nvme_encapsulated_request *)mpi_req);
1204 if (nvme_fmt == MPI3MR_NVME_DATA_FORMAT_PRP) {
1205 if (mpi3mr_build_nvme_prp(mrioc,
1206 (struct mpi3_nvme_encapsulated_request *)mpi_req,
1207 drv_bufs, bufcnt)) {
1208 rval = -ENOMEM;
1209 mutex_unlock(&mrioc->bsg_cmds.mutex);
1210 goto out;
1211 }
1212 } else if (nvme_fmt == MPI3MR_NVME_DATA_FORMAT_SGL1 ||
1213 nvme_fmt == MPI3MR_NVME_DATA_FORMAT_SGL2) {
1214 if (mpi3mr_build_nvme_sgl(mrioc,
1215 (struct mpi3_nvme_encapsulated_request *)mpi_req,
1216 drv_bufs, bufcnt)) {
1217 rval = -EINVAL;
1218 mutex_unlock(&mrioc->bsg_cmds.mutex);
1219 goto out;
1220 }
1221 } else {
1222 dprint_bsg_err(mrioc,
1223 "%s:invalid NVMe command format\n", __func__);
1224 rval = -EINVAL;
1225 mutex_unlock(&mrioc->bsg_cmds.mutex);
1226 goto out;
1227 }
1228 } else {
1229 mpi3mr_bsg_build_sgl(mpi_req, (mpi_msg_size),
1230 drv_bufs, bufcnt, is_rmcb, is_rmrb,
1231 (dout_cnt + din_cnt));
1232 }
1233
1234 if (mpi_header->function == MPI3_BSG_FUNCTION_SCSI_TASK_MGMT) {
1235 tm_req = (struct mpi3_scsi_task_mgmt_request *)mpi_req;
1236 if (tm_req->task_type !=
1237 MPI3_SCSITASKMGMT_TASKTYPE_ABORT_TASK) {
1238 dev_handle = tm_req->dev_handle;
1239 block_io = 1;
1240 }
1241 }
1242 if (block_io) {
1243 tgtdev = mpi3mr_get_tgtdev_by_handle(mrioc, dev_handle);
1244 if (tgtdev && tgtdev->starget && tgtdev->starget->hostdata) {
1245 stgt_priv = (struct mpi3mr_stgt_priv_data *)
1246 tgtdev->starget->hostdata;
1247 atomic_inc(&stgt_priv->block_io);
1248 mpi3mr_tgtdev_put(tgtdev);
1249 }
1250 }
1251
1252 mrioc->bsg_cmds.state = MPI3MR_CMD_PENDING;
1253 mrioc->bsg_cmds.is_waiting = 1;
1254 mrioc->bsg_cmds.callback = NULL;
1255 mrioc->bsg_cmds.is_sense = 0;
1256 mrioc->bsg_cmds.sensebuf = sense_buff_k;
1257 memset(mrioc->bsg_cmds.reply, 0, mrioc->reply_sz);
1258 mpi_header->host_tag = cpu_to_le16(MPI3MR_HOSTTAG_BSG_CMDS);
1259 if (mrioc->logging_level & MPI3_DEBUG_BSG_INFO) {
1260 dprint_bsg_info(mrioc,
1261 "%s: posting bsg request to the controller\n", __func__);
1262 dprint_dump(mpi_req, MPI3MR_ADMIN_REQ_FRAME_SZ,
1263 "bsg_mpi3_req");
1264 if (mpi_header->function == MPI3_BSG_FUNCTION_MGMT_PASSTHROUGH) {
1265 drv_buf_iter = &drv_bufs[0];
1266 dprint_dump(drv_buf_iter->kern_buf,
1267 drv_buf_iter->kern_buf_len, "mpi3_mgmt_req");
1268 }
1269 }
1270
1271 init_completion(&mrioc->bsg_cmds.done);
1272 rval = mpi3mr_admin_request_post(mrioc, mpi_req,
1273 MPI3MR_ADMIN_REQ_FRAME_SZ, 0);
1274
1275
1276 if (rval) {
1277 mrioc->bsg_cmds.is_waiting = 0;
1278 dprint_bsg_err(mrioc,
1279 "%s: posting bsg request is failed\n", __func__);
1280 rval = -EAGAIN;
1281 goto out_unlock;
1282 }
1283 wait_for_completion_timeout(&mrioc->bsg_cmds.done,
1284 (karg->timeout * HZ));
1285 if (block_io && stgt_priv)
1286 atomic_dec(&stgt_priv->block_io);
1287 if (!(mrioc->bsg_cmds.state & MPI3MR_CMD_COMPLETE)) {
1288 mrioc->bsg_cmds.is_waiting = 0;
1289 rval = -EAGAIN;
1290 if (mrioc->bsg_cmds.state & MPI3MR_CMD_RESET)
1291 goto out_unlock;
1292 dprint_bsg_err(mrioc,
1293 "%s: bsg request timedout after %d seconds\n", __func__,
1294 karg->timeout);
1295 if (mrioc->logging_level & MPI3_DEBUG_BSG_ERROR) {
1296 dprint_dump(mpi_req, MPI3MR_ADMIN_REQ_FRAME_SZ,
1297 "bsg_mpi3_req");
1298 if (mpi_header->function ==
1299 MPI3_BSG_FUNCTION_MGMT_PASSTHROUGH) {
1300 drv_buf_iter = &drv_bufs[0];
1301 dprint_dump(drv_buf_iter->kern_buf,
1302 drv_buf_iter->kern_buf_len, "mpi3_mgmt_req");
1303 }
1304 }
1305
1306 if ((mpi_header->function == MPI3_BSG_FUNCTION_NVME_ENCAPSULATED) ||
1307 (mpi_header->function == MPI3_BSG_FUNCTION_SCSI_IO))
1308 mpi3mr_issue_tm(mrioc,
1309 MPI3_SCSITASKMGMT_TASKTYPE_TARGET_RESET,
1310 mpi_header->function_dependent, 0,
1311 MPI3MR_HOSTTAG_BLK_TMS, MPI3MR_RESETTM_TIMEOUT,
1312 &mrioc->host_tm_cmds, &resp_code, NULL);
1313 if (!(mrioc->bsg_cmds.state & MPI3MR_CMD_COMPLETE) &&
1314 !(mrioc->bsg_cmds.state & MPI3MR_CMD_RESET))
1315 mpi3mr_soft_reset_handler(mrioc,
1316 MPI3MR_RESET_FROM_APP_TIMEOUT, 1);
1317 goto out_unlock;
1318 }
1319 dprint_bsg_info(mrioc, "%s: bsg request is completed\n", __func__);
1320
1321 if (mrioc->prp_list_virt) {
1322 dma_free_coherent(&mrioc->pdev->dev, mrioc->prp_sz,
1323 mrioc->prp_list_virt, mrioc->prp_list_dma);
1324 mrioc->prp_list_virt = NULL;
1325 }
1326
1327 if ((mrioc->bsg_cmds.ioc_status & MPI3_IOCSTATUS_STATUS_MASK)
1328 != MPI3_IOCSTATUS_SUCCESS) {
1329 dprint_bsg_info(mrioc,
1330 "%s: command failed, ioc_status(0x%04x) log_info(0x%08x)\n",
1331 __func__,
1332 (mrioc->bsg_cmds.ioc_status & MPI3_IOCSTATUS_STATUS_MASK),
1333 mrioc->bsg_cmds.ioc_loginfo);
1334 }
1335
1336 if ((mpirep_offset != 0xFF) &&
1337 drv_bufs[mpirep_offset].bsg_buf_len) {
1338 drv_buf_iter = &drv_bufs[mpirep_offset];
1339 drv_buf_iter->kern_buf_len = (sizeof(*bsg_reply_buf) - 1 +
1340 mrioc->reply_sz);
1341 bsg_reply_buf = kzalloc(drv_buf_iter->kern_buf_len, GFP_KERNEL);
1342
1343 if (!bsg_reply_buf) {
1344 rval = -ENOMEM;
1345 goto out_unlock;
1346 }
1347 if (mrioc->bsg_cmds.state & MPI3MR_CMD_REPLY_VALID) {
1348 bsg_reply_buf->mpi_reply_type =
1349 MPI3MR_BSG_MPI_REPLY_BUFTYPE_ADDRESS;
1350 memcpy(bsg_reply_buf->reply_buf,
1351 mrioc->bsg_cmds.reply, mrioc->reply_sz);
1352 } else {
1353 bsg_reply_buf->mpi_reply_type =
1354 MPI3MR_BSG_MPI_REPLY_BUFTYPE_STATUS;
1355 status_desc = (struct mpi3_status_reply_descriptor *)
1356 bsg_reply_buf->reply_buf;
1357 status_desc->ioc_status = mrioc->bsg_cmds.ioc_status;
1358 status_desc->ioc_log_info = mrioc->bsg_cmds.ioc_loginfo;
1359 }
1360 tmplen = min(drv_buf_iter->kern_buf_len,
1361 drv_buf_iter->bsg_buf_len);
1362 memcpy(drv_buf_iter->bsg_buf, bsg_reply_buf, tmplen);
1363 }
1364
1365 if (erb_offset != 0xFF && mrioc->bsg_cmds.sensebuf &&
1366 mrioc->bsg_cmds.is_sense) {
1367 drv_buf_iter = &drv_bufs[erb_offset];
1368 tmplen = min(erbsz, drv_buf_iter->bsg_buf_len);
1369 memcpy(drv_buf_iter->bsg_buf, sense_buff_k, tmplen);
1370 }
1371
1372 drv_buf_iter = drv_bufs;
1373 for (count = 0; count < bufcnt; count++, drv_buf_iter++) {
1374 if (drv_buf_iter->data_dir == DMA_NONE)
1375 continue;
1376 if (drv_buf_iter->data_dir == DMA_FROM_DEVICE) {
1377 tmplen = min(drv_buf_iter->kern_buf_len,
1378 drv_buf_iter->bsg_buf_len);
1379 memcpy(drv_buf_iter->bsg_buf,
1380 drv_buf_iter->kern_buf, tmplen);
1381 }
1382 }
1383
1384out_unlock:
1385 if (din_buf) {
1386 *reply_payload_rcv_len =
1387 sg_copy_from_buffer(job->reply_payload.sg_list,
1388 job->reply_payload.sg_cnt,
1389 din_buf, job->reply_payload.payload_len);
1390 }
1391 mrioc->bsg_cmds.is_sense = 0;
1392 mrioc->bsg_cmds.sensebuf = NULL;
1393 mrioc->bsg_cmds.state = MPI3MR_CMD_NOTUSED;
1394 mutex_unlock(&mrioc->bsg_cmds.mutex);
1395out:
1396 kfree(sense_buff_k);
1397 kfree(dout_buf);
1398 kfree(din_buf);
1399 kfree(mpi_req);
1400 if (drv_bufs) {
1401 drv_buf_iter = drv_bufs;
1402 for (count = 0; count < bufcnt; count++, drv_buf_iter++) {
1403 if (drv_buf_iter->kern_buf && drv_buf_iter->kern_buf_dma)
1404 dma_free_coherent(&mrioc->pdev->dev,
1405 drv_buf_iter->kern_buf_len,
1406 drv_buf_iter->kern_buf,
1407 drv_buf_iter->kern_buf_dma);
1408 }
1409 kfree(drv_bufs);
1410 }
1411 kfree(bsg_reply_buf);
1412 return rval;
1413}
1414
1415/**
1416 * mpi3mr_app_save_logdata - Save Log Data events
1417 * @mrioc: Adapter instance reference
1418 * @event_data: event data associated with log data event
1419 * @event_data_size: event data size to copy
1420 *
1421 * If log data event caching is enabled by the applicatiobns,
1422 * then this function saves the log data in the circular queue
1423 * and Sends async signal SIGIO to indicate there is an async
1424 * event from the firmware to the event monitoring applications.
1425 *
1426 * Return:Nothing
1427 */
1428void mpi3mr_app_save_logdata(struct mpi3mr_ioc *mrioc, char *event_data,
1429 u16 event_data_size)
1430{
1431 u32 index = mrioc->logdata_buf_idx, sz;
1432 struct mpi3mr_logdata_entry *entry;
1433
1434 if (!(mrioc->logdata_buf))
1435 return;
1436
1437 entry = (struct mpi3mr_logdata_entry *)
1438 (mrioc->logdata_buf + (index * mrioc->logdata_entry_sz));
1439 entry->valid_entry = 1;
1440 sz = min(mrioc->logdata_entry_sz, event_data_size);
1441 memcpy(entry->data, event_data, sz);
1442 mrioc->logdata_buf_idx =
1443 ((++index) % MPI3MR_BSG_LOGDATA_MAX_ENTRIES);
1444 atomic64_inc(&event_counter);
1445}
1446
1447/**
1448 * mpi3mr_bsg_request - bsg request entry point
1449 * @job: BSG job reference
1450 *
1451 * This is driver's entry point for bsg requests
1452 *
1453 * Return: 0 on success and proper error codes on failure
1454 */
1455static int mpi3mr_bsg_request(struct bsg_job *job)
1456{
1457 long rval = -EINVAL;
1458 unsigned int reply_payload_rcv_len = 0;
1459
1460 struct mpi3mr_bsg_packet *bsg_req = job->request;
1461
1462 switch (bsg_req->cmd_type) {
1463 case MPI3MR_DRV_CMD:
1464 rval = mpi3mr_bsg_process_drv_cmds(job);
1465 break;
1466 case MPI3MR_MPT_CMD:
1467 rval = mpi3mr_bsg_process_mpt_cmds(job, &reply_payload_rcv_len);
1468 break;
1469 default:
1470 pr_err("%s: unsupported BSG command(0x%08x)\n",
1471 MPI3MR_DRIVER_NAME, bsg_req->cmd_type);
1472 break;
1473 }
1474
1475 bsg_job_done(job, rval, reply_payload_rcv_len);
1476
1477 return 0;
1478}
1479
1480/**
1481 * mpi3mr_bsg_exit - de-registration from bsg layer
1482 *
1483 * This will be called during driver unload and all
1484 * bsg resources allocated during load will be freed.
1485 *
1486 * Return:Nothing
1487 */
1488void mpi3mr_bsg_exit(struct mpi3mr_ioc *mrioc)
1489{
1490 if (!mrioc->bsg_queue)
1491 return;
1492
1493 bsg_remove_queue(mrioc->bsg_queue);
1494 mrioc->bsg_queue = NULL;
1495
1496 device_del(mrioc->bsg_dev);
1497 put_device(mrioc->bsg_dev);
1498 kfree(mrioc->bsg_dev);
1499}
1500
1501/**
1502 * mpi3mr_bsg_node_release -release bsg device node
1503 * @dev: bsg device node
1504 *
1505 * decrements bsg dev reference count
1506 *
1507 * Return:Nothing
1508 */
1509static void mpi3mr_bsg_node_release(struct device *dev)
1510{
1511 put_device(dev);
1512}
1513
1514/**
1515 * mpi3mr_bsg_init - registration with bsg layer
1516 *
1517 * This will be called during driver load and it will
1518 * register driver with bsg layer
1519 *
1520 * Return:Nothing
1521 */
1522void mpi3mr_bsg_init(struct mpi3mr_ioc *mrioc)
1523{
1524 mrioc->bsg_dev = kzalloc(sizeof(struct device), GFP_KERNEL);
1525 if (!mrioc->bsg_dev) {
1526 ioc_err(mrioc, "bsg device mem allocation failed\n");
1527 return;
1528 }
1529
1530 device_initialize(mrioc->bsg_dev);
1531 dev_set_name(mrioc->bsg_dev, "mpi3mrctl%u", mrioc->id);
1532
1533 if (device_add(mrioc->bsg_dev)) {
1534 ioc_err(mrioc, "%s: bsg device add failed\n",
1535 dev_name(mrioc->bsg_dev));
1536 goto err_device_add;
1537 }
1538
1539 mrioc->bsg_dev->release = mpi3mr_bsg_node_release;
1540
1541 mrioc->bsg_queue = bsg_setup_queue(mrioc->bsg_dev, dev_name(mrioc->bsg_dev),
1542 mpi3mr_bsg_request, NULL, 0);
1543 if (IS_ERR(mrioc->bsg_queue)) {
1544 ioc_err(mrioc, "%s: bsg registration failed\n",
1545 dev_name(mrioc->bsg_dev));
1546 goto err_setup_queue;
1547 }
1548
1549 blk_queue_max_segments(mrioc->bsg_queue, MPI3MR_MAX_APP_XFER_SEGMENTS);
1550 blk_queue_max_hw_sectors(mrioc->bsg_queue, MPI3MR_MAX_APP_XFER_SECTORS);
1551
1552 return;
1553
1554err_setup_queue:
1555 device_del(mrioc->bsg_dev);
1556 put_device(mrioc->bsg_dev);
1557err_device_add:
1558 kfree(mrioc->bsg_dev);
1559}
1560
1561/**
1562 * version_fw_show - SysFS callback for firmware version read
1563 * @dev: class device
1564 * @attr: Device attributes
1565 * @buf: Buffer to copy
1566 *
1567 * Return: sysfs_emit() return after copying firmware version
1568 */
1569static ssize_t
1570version_fw_show(struct device *dev, struct device_attribute *attr,
1571 char *buf)
1572{
1573 struct Scsi_Host *shost = class_to_shost(dev);
1574 struct mpi3mr_ioc *mrioc = shost_priv(shost);
1575 struct mpi3mr_compimg_ver *fwver = &mrioc->facts.fw_ver;
1576
1577 return sysfs_emit(buf, "%d.%d.%d.%d.%05d-%05d\n",
1578 fwver->gen_major, fwver->gen_minor, fwver->ph_major,
1579 fwver->ph_minor, fwver->cust_id, fwver->build_num);
1580}
1581static DEVICE_ATTR_RO(version_fw);
1582
1583/**
1584 * fw_queue_depth_show - SysFS callback for firmware max cmds
1585 * @dev: class device
1586 * @attr: Device attributes
1587 * @buf: Buffer to copy
1588 *
1589 * Return: sysfs_emit() return after copying firmware max commands
1590 */
1591static ssize_t
1592fw_queue_depth_show(struct device *dev, struct device_attribute *attr,
1593 char *buf)
1594{
1595 struct Scsi_Host *shost = class_to_shost(dev);
1596 struct mpi3mr_ioc *mrioc = shost_priv(shost);
1597
1598 return sysfs_emit(buf, "%d\n", mrioc->facts.max_reqs);
1599}
1600static DEVICE_ATTR_RO(fw_queue_depth);
1601
1602/**
1603 * op_req_q_count_show - SysFS callback for request queue count
1604 * @dev: class device
1605 * @attr: Device attributes
1606 * @buf: Buffer to copy
1607 *
1608 * Return: sysfs_emit() return after copying request queue count
1609 */
1610static ssize_t
1611op_req_q_count_show(struct device *dev, struct device_attribute *attr,
1612 char *buf)
1613{
1614 struct Scsi_Host *shost = class_to_shost(dev);
1615 struct mpi3mr_ioc *mrioc = shost_priv(shost);
1616
1617 return sysfs_emit(buf, "%d\n", mrioc->num_op_req_q);
1618}
1619static DEVICE_ATTR_RO(op_req_q_count);
1620
1621/**
1622 * reply_queue_count_show - SysFS callback for reply queue count
1623 * @dev: class device
1624 * @attr: Device attributes
1625 * @buf: Buffer to copy
1626 *
1627 * Return: sysfs_emit() return after copying reply queue count
1628 */
1629static ssize_t
1630reply_queue_count_show(struct device *dev, struct device_attribute *attr,
1631 char *buf)
1632{
1633 struct Scsi_Host *shost = class_to_shost(dev);
1634 struct mpi3mr_ioc *mrioc = shost_priv(shost);
1635
1636 return sysfs_emit(buf, "%d\n", mrioc->num_op_reply_q);
1637}
1638
1639static DEVICE_ATTR_RO(reply_queue_count);
1640
1641/**
1642 * logging_level_show - Show controller debug level
1643 * @dev: class device
1644 * @attr: Device attributes
1645 * @buf: Buffer to copy
1646 *
1647 * A sysfs 'read/write' shost attribute, to show the current
1648 * debug log level used by the driver for the specific
1649 * controller.
1650 *
1651 * Return: sysfs_emit() return
1652 */
1653static ssize_t
1654logging_level_show(struct device *dev,
1655 struct device_attribute *attr, char *buf)
1656
1657{
1658 struct Scsi_Host *shost = class_to_shost(dev);
1659 struct mpi3mr_ioc *mrioc = shost_priv(shost);
1660
1661 return sysfs_emit(buf, "%08xh\n", mrioc->logging_level);
1662}
1663
1664/**
1665 * logging_level_store- Change controller debug level
1666 * @dev: class device
1667 * @attr: Device attributes
1668 * @buf: Buffer to copy
1669 * @count: size of the buffer
1670 *
1671 * A sysfs 'read/write' shost attribute, to change the current
1672 * debug log level used by the driver for the specific
1673 * controller.
1674 *
1675 * Return: strlen() return
1676 */
1677static ssize_t
1678logging_level_store(struct device *dev,
1679 struct device_attribute *attr,
1680 const char *buf, size_t count)
1681{
1682 struct Scsi_Host *shost = class_to_shost(dev);
1683 struct mpi3mr_ioc *mrioc = shost_priv(shost);
1684 int val = 0;
1685
1686 if (kstrtoint(buf, 0, &val) != 0)
1687 return -EINVAL;
1688
1689 mrioc->logging_level = val;
1690 ioc_info(mrioc, "logging_level=%08xh\n", mrioc->logging_level);
1691 return strlen(buf);
1692}
1693static DEVICE_ATTR_RW(logging_level);
1694
1695/**
1696 * adapter_state_show - SysFS callback for adapter state show
1697 * @dev: class device
1698 * @attr: Device attributes
1699 * @buf: Buffer to copy
1700 *
1701 * Return: sysfs_emit() return after copying adapter state
1702 */
1703static ssize_t
1704adp_state_show(struct device *dev, struct device_attribute *attr,
1705 char *buf)
1706{
1707 struct Scsi_Host *shost = class_to_shost(dev);
1708 struct mpi3mr_ioc *mrioc = shost_priv(shost);
1709 enum mpi3mr_iocstate ioc_state;
1710 uint8_t adp_state;
1711
1712 ioc_state = mpi3mr_get_iocstate(mrioc);
1713 if (ioc_state == MRIOC_STATE_UNRECOVERABLE)
1714 adp_state = MPI3MR_BSG_ADPSTATE_UNRECOVERABLE;
1715 else if ((mrioc->reset_in_progress) || (mrioc->stop_bsgs))
1716 adp_state = MPI3MR_BSG_ADPSTATE_IN_RESET;
1717 else if (ioc_state == MRIOC_STATE_FAULT)
1718 adp_state = MPI3MR_BSG_ADPSTATE_FAULT;
1719 else
1720 adp_state = MPI3MR_BSG_ADPSTATE_OPERATIONAL;
1721
1722 return sysfs_emit(buf, "%u\n", adp_state);
1723}
1724
1725static DEVICE_ATTR_RO(adp_state);
1726
1727static struct attribute *mpi3mr_host_attrs[] = {
1728 &dev_attr_version_fw.attr,
1729 &dev_attr_fw_queue_depth.attr,
1730 &dev_attr_op_req_q_count.attr,
1731 &dev_attr_reply_queue_count.attr,
1732 &dev_attr_logging_level.attr,
1733 &dev_attr_adp_state.attr,
1734 NULL,
1735};
1736
1737static const struct attribute_group mpi3mr_host_attr_group = {
1738 .attrs = mpi3mr_host_attrs
1739};
1740
1741const struct attribute_group *mpi3mr_host_groups[] = {
1742 &mpi3mr_host_attr_group,
1743 NULL,
1744};
1745
1746
1747/*
1748 * SCSI Device attributes under sysfs
1749 */
1750
1751/**
1752 * sas_address_show - SysFS callback for dev SASaddress display
1753 * @dev: class device
1754 * @attr: Device attributes
1755 * @buf: Buffer to copy
1756 *
1757 * Return: sysfs_emit() return after copying SAS address of the
1758 * specific SAS/SATA end device.
1759 */
1760static ssize_t
1761sas_address_show(struct device *dev, struct device_attribute *attr,
1762 char *buf)
1763{
1764 struct scsi_device *sdev = to_scsi_device(dev);
1765 struct mpi3mr_sdev_priv_data *sdev_priv_data;
1766 struct mpi3mr_stgt_priv_data *tgt_priv_data;
1767 struct mpi3mr_tgt_dev *tgtdev;
1768
1769 sdev_priv_data = sdev->hostdata;
1770 if (!sdev_priv_data)
1771 return 0;
1772
1773 tgt_priv_data = sdev_priv_data->tgt_priv_data;
1774 if (!tgt_priv_data)
1775 return 0;
1776 tgtdev = tgt_priv_data->tgt_dev;
1777 if (!tgtdev || tgtdev->dev_type != MPI3_DEVICE_DEVFORM_SAS_SATA)
1778 return 0;
1779 return sysfs_emit(buf, "0x%016llx\n",
1780 (unsigned long long)tgtdev->dev_spec.sas_sata_inf.sas_address);
1781}
1782
1783static DEVICE_ATTR_RO(sas_address);
1784
1785/**
1786 * device_handle_show - SysFS callback for device handle display
1787 * @dev: class device
1788 * @attr: Device attributes
1789 * @buf: Buffer to copy
1790 *
1791 * Return: sysfs_emit() return after copying firmware internal
1792 * device handle of the specific device.
1793 */
1794static ssize_t
1795device_handle_show(struct device *dev, struct device_attribute *attr,
1796 char *buf)
1797{
1798 struct scsi_device *sdev = to_scsi_device(dev);
1799 struct mpi3mr_sdev_priv_data *sdev_priv_data;
1800 struct mpi3mr_stgt_priv_data *tgt_priv_data;
1801 struct mpi3mr_tgt_dev *tgtdev;
1802
1803 sdev_priv_data = sdev->hostdata;
1804 if (!sdev_priv_data)
1805 return 0;
1806
1807 tgt_priv_data = sdev_priv_data->tgt_priv_data;
1808 if (!tgt_priv_data)
1809 return 0;
1810 tgtdev = tgt_priv_data->tgt_dev;
1811 if (!tgtdev)
1812 return 0;
1813 return sysfs_emit(buf, "0x%04x\n", tgtdev->dev_handle);
1814}
1815
1816static DEVICE_ATTR_RO(device_handle);
1817
1818/**
1819 * persistent_id_show - SysFS callback for persisten ID display
1820 * @dev: class device
1821 * @attr: Device attributes
1822 * @buf: Buffer to copy
1823 *
1824 * Return: sysfs_emit() return after copying persistent ID of the
1825 * of the specific device.
1826 */
1827static ssize_t
1828persistent_id_show(struct device *dev, struct device_attribute *attr,
1829 char *buf)
1830{
1831 struct scsi_device *sdev = to_scsi_device(dev);
1832 struct mpi3mr_sdev_priv_data *sdev_priv_data;
1833 struct mpi3mr_stgt_priv_data *tgt_priv_data;
1834 struct mpi3mr_tgt_dev *tgtdev;
1835
1836 sdev_priv_data = sdev->hostdata;
1837 if (!sdev_priv_data)
1838 return 0;
1839
1840 tgt_priv_data = sdev_priv_data->tgt_priv_data;
1841 if (!tgt_priv_data)
1842 return 0;
1843 tgtdev = tgt_priv_data->tgt_dev;
1844 if (!tgtdev)
1845 return 0;
1846 return sysfs_emit(buf, "%d\n", tgtdev->perst_id);
1847}
1848static DEVICE_ATTR_RO(persistent_id);
1849
1850static struct attribute *mpi3mr_dev_attrs[] = {
1851 &dev_attr_sas_address.attr,
1852 &dev_attr_device_handle.attr,
1853 &dev_attr_persistent_id.attr,
1854 NULL,
1855};
1856
1857static const struct attribute_group mpi3mr_dev_attr_group = {
1858 .attrs = mpi3mr_dev_attrs
1859};
1860
1861const struct attribute_group *mpi3mr_dev_groups[] = {
1862 &mpi3mr_dev_attr_group,
1863 NULL,
1864};
drivers/scsi/mpi3mr/mpi3mr_debug.h+31−6
@@ -23,8 +23,8 @@ · 22 unmodified lines
23#define MPI3_DEBUG_RESET 0x0000002023#define MPI3_DEBUG_RESET 0x00000020
24#define MPI3_DEBUG_SCSI_ERROR 0x0000004024#define MPI3_DEBUG_SCSI_ERROR 0x00000040
25#define MPI3_DEBUG_REPLY 0x0000008025#define MPI3_DEBUG_REPLY 0x00000080
26#define MPI3_DEBUG_IOCTL_ERROR 0x0000800026#define MPI3_DEBUG_BSG_ERROR 0x00008000
27#define MPI3_DEBUG_IOCTL_INFO 0x0001000027#define MPI3_DEBUG_BSG_INFO 0x00010000
28#define MPI3_DEBUG_SCSI_INFO 0x0002000028#define MPI3_DEBUG_SCSI_INFO 0x00020000
29#define MPI3_DEBUG 0x0100000029#define MPI3_DEBUG 0x01000000
30#define MPI3_DEBUG_SG 0x0200000030#define MPI3_DEBUG_SG 0x02000000
@@ -110,20 +110,45 @@ · 79 unmodified lines
110 } while (0)110 } while (0)
111 111
112 112
113#define dprint_ioctl_info(ioc, fmt, ...) \113#define dprint_bsg_info(ioc, fmt, ...) \
114 do { \114 do { \
115 if (ioc->logging_level & MPI3_DEBUG_IOCTL_INFO) \115 if (ioc->logging_level & MPI3_DEBUG_BSG_INFO) \
116 pr_info("%s: " fmt, (ioc)->name, ##__VA_ARGS__); \116 pr_info("%s: " fmt, (ioc)->name, ##__VA_ARGS__); \
117 } while (0)117 } while (0)
118 118
119#define dprint_ioctl_err(ioc, fmt, ...) \119#define dprint_bsg_err(ioc, fmt, ...) \
120 do { \120 do { \
121 if (ioc->logging_level & MPI3_DEBUG_IOCTL_ERROR) \121 if (ioc->logging_level & MPI3_DEBUG_BSG_ERROR) \
122 pr_info("%s: " fmt, (ioc)->name, ##__VA_ARGS__); \122 pr_info("%s: " fmt, (ioc)->name, ##__VA_ARGS__); \
123 } while (0)123 } while (0)
124 124
125#endif /* MPT3SAS_DEBUG_H_INCLUDED */125#endif /* MPT3SAS_DEBUG_H_INCLUDED */
126 126
127/**
128 * dprint_dump - print contents of a memory buffer
129 * @req: Pointer to a memory buffer
130 * @sz: Memory buffer size
131 * @namestr: Name String to identify the buffer type
132 */
133static inline void
134dprint_dump(void *req, int sz, const char *name_string)
135{
136 int i;
137 __le32 *mfp = (__le32 *)req;
138
139 sz = sz/4;
140 if (name_string)
141 pr_info("%s:\n\t", name_string);
142 else
143 pr_info("request:\n\t");
144 for (i = 0; i < sz; i++) {
145 if (i && ((i % 8) == 0))
146 pr_info("\n\t");
147 pr_info("%08x ", le32_to_cpu(mfp[i]));
148 }
149 pr_info("\n");
150}
151
127/**152/**
128 * dprint_dump_req - print message frame contents153 * dprint_dump_req - print message frame contents
129 * @req: pointer to message frame154 * @req: pointer to message frame
drivers/scsi/mpi3mr/mpi3mr_fw.c+332−3
@@ -15,6 +15,8 @@ mpi3mr_issue_reset(struct mpi3mr_ioc *mrioc, u16 reset_type, u32 reset_reason); · 14 unmodified lines
15static int mpi3mr_setup_admin_qpair(struct mpi3mr_ioc *mrioc);15static int mpi3mr_setup_admin_qpair(struct mpi3mr_ioc *mrioc);
16static void mpi3mr_process_factsdata(struct mpi3mr_ioc *mrioc,16static void mpi3mr_process_factsdata(struct mpi3mr_ioc *mrioc,
17 struct mpi3_ioc_facts_data *facts_data);17 struct mpi3_ioc_facts_data *facts_data);
18static void mpi3mr_pel_wait_complete(struct mpi3mr_ioc *mrioc,
19 struct mpi3mr_drv_cmd *drv_cmd);
18 20
19static int poll_queues;21static int poll_queues;
20module_param(poll_queues, int, 0444);22module_param(poll_queues, int, 0444);
@@ -297,8 +299,14 @@ mpi3mr_get_drv_cmd(struct mpi3mr_ioc *mrioc, u16 host_tag, · 276 unmodified lines
297 switch (host_tag) {299 switch (host_tag) {
298 case MPI3MR_HOSTTAG_INITCMDS:300 case MPI3MR_HOSTTAG_INITCMDS:
299 return &mrioc->init_cmds;301 return &mrioc->init_cmds;
302 case MPI3MR_HOSTTAG_BSG_CMDS:
303 return &mrioc->bsg_cmds;
300 case MPI3MR_HOSTTAG_BLK_TMS:304 case MPI3MR_HOSTTAG_BLK_TMS:
301 return &mrioc->host_tm_cmds;305 return &mrioc->host_tm_cmds;
306 case MPI3MR_HOSTTAG_PEL_ABORT:
307 return &mrioc->pel_abort_cmd;
308 case MPI3MR_HOSTTAG_PEL_WAIT:
309 return &mrioc->pel_cmds;
302 case MPI3MR_HOSTTAG_INVALID:310 case MPI3MR_HOSTTAG_INVALID:
303 if (def_reply && def_reply->function ==311 if (def_reply && def_reply->function ==
304 MPI3_FUNCTION_EVENT_NOTIFICATION)312 MPI3_FUNCTION_EVENT_NOTIFICATION)
@@ -865,10 +873,10 @@ static const struct { · 560 unmodified lines
865} mpi3mr_reset_reason_codes[] = {873} mpi3mr_reset_reason_codes[] = {
866 { MPI3MR_RESET_FROM_BRINGUP, "timeout in bringup" },874 { MPI3MR_RESET_FROM_BRINGUP, "timeout in bringup" },
867 { MPI3MR_RESET_FROM_FAULT_WATCH, "fault" },875 { MPI3MR_RESET_FROM_FAULT_WATCH, "fault" },
868 { MPI3MR_RESET_FROM_IOCTL, "application invocation" },876 { MPI3MR_RESET_FROM_APP, "application invocation" },
869 { MPI3MR_RESET_FROM_EH_HOS, "error handling" },877 { MPI3MR_RESET_FROM_EH_HOS, "error handling" },
870 { MPI3MR_RESET_FROM_TM_TIMEOUT, "TM timeout" },878 { MPI3MR_RESET_FROM_TM_TIMEOUT, "TM timeout" },
871 { MPI3MR_RESET_FROM_IOCTL_TIMEOUT, "IOCTL timeout" },879 { MPI3MR_RESET_FROM_APP_TIMEOUT, "application command timeout" },
872 { MPI3MR_RESET_FROM_MUR_FAILURE, "MUR failure" },880 { MPI3MR_RESET_FROM_MUR_FAILURE, "MUR failure" },
873 { MPI3MR_RESET_FROM_CTLR_CLEANUP, "timeout in controller cleanup" },881 { MPI3MR_RESET_FROM_CTLR_CLEANUP, "timeout in controller cleanup" },
874 { MPI3MR_RESET_FROM_CIACTIV_FAULT, "component image activation fault" },882 { MPI3MR_RESET_FROM_CIACTIV_FAULT, "component image activation fault" },
@@ -2813,6 +2821,10 @@ static int mpi3mr_alloc_reply_sense_bufs(struct mpi3mr_ioc *mrioc) · 1938 unmodified lines
2813 if (!mrioc->init_cmds.reply)2821 if (!mrioc->init_cmds.reply)
2814 goto out_failed;2822 goto out_failed;
2815 2823
2824 mrioc->bsg_cmds.reply = kzalloc(mrioc->reply_sz, GFP_KERNEL);
2825 if (!mrioc->bsg_cmds.reply)
2826 goto out_failed;
2827
2816 for (i = 0; i < MPI3MR_NUM_DEVRMCMD; i++) {2828 for (i = 0; i < MPI3MR_NUM_DEVRMCMD; i++) {
2817 mrioc->dev_rmhs_cmds[i].reply = kzalloc(mrioc->reply_sz,2829 mrioc->dev_rmhs_cmds[i].reply = kzalloc(mrioc->reply_sz,
2818 GFP_KERNEL);2830 GFP_KERNEL);
@@ -2831,6 +2843,14 @@ static int mpi3mr_alloc_reply_sense_bufs(struct mpi3mr_ioc *mrioc) · 12 unmodified lines
2831 if (!mrioc->host_tm_cmds.reply)2843 if (!mrioc->host_tm_cmds.reply)
2832 goto out_failed;2844 goto out_failed;
2833 2845
2846 mrioc->pel_cmds.reply = kzalloc(mrioc->reply_sz, GFP_KERNEL);
2847 if (!mrioc->pel_cmds.reply)
2848 goto out_failed;
2849
2850 mrioc->pel_abort_cmd.reply = kzalloc(mrioc->reply_sz, GFP_KERNEL);
2851 if (!mrioc->pel_abort_cmd.reply)
2852 goto out_failed;
2853
2834 mrioc->dev_handle_bitmap_sz = mrioc->facts.max_devhandle / 8;2854 mrioc->dev_handle_bitmap_sz = mrioc->facts.max_devhandle / 8;
2835 if (mrioc->facts.max_devhandle % 8)2855 if (mrioc->facts.max_devhandle % 8)
2836 mrioc->dev_handle_bitmap_sz++;2856 mrioc->dev_handle_bitmap_sz++;
@@ -3728,6 +3748,18 @@ retry_init: · 891 unmodified lines
3728 goto out_failed;3748 goto out_failed;
3729 }3749 }
3730 3750
3751 if (!mrioc->pel_seqnum_virt) {
3752 dprint_init(mrioc, "allocating memory for pel_seqnum_virt\n");
3753 mrioc->pel_seqnum_sz = sizeof(struct mpi3_pel_seq);
3754 mrioc->pel_seqnum_virt = dma_alloc_coherent(&mrioc->pdev->dev,
3755 mrioc->pel_seqnum_sz, &mrioc->pel_seqnum_dma,
3756 GFP_KERNEL);
3757 if (!mrioc->pel_seqnum_virt) {
3758 retval = -ENOMEM;
3759 goto out_failed_noretry;
3760 }
3761 }
3762
3731 retval = mpi3mr_enable_events(mrioc);3763 retval = mpi3mr_enable_events(mrioc);
3732 if (retval) {3764 if (retval) {
3733 ioc_err(mrioc, "failed to enable events %d\n",3765 ioc_err(mrioc, "failed to enable events %d\n",
@@ -3837,6 +3869,18 @@ retry_init: · 103 unmodified lines
3837 goto out_failed;3869 goto out_failed;
3838 }3870 }
3839 3871
3872 if (!mrioc->pel_seqnum_virt) {
3873 dprint_reset(mrioc, "allocating memory for pel_seqnum_virt\n");
3874 mrioc->pel_seqnum_sz = sizeof(struct mpi3_pel_seq);
3875 mrioc->pel_seqnum_virt = dma_alloc_coherent(&mrioc->pdev->dev,
3876 mrioc->pel_seqnum_sz, &mrioc->pel_seqnum_dma,
3877 GFP_KERNEL);
3878 if (!mrioc->pel_seqnum_virt) {
3879 retval = -ENOMEM;
3880 goto out_failed_noretry;
3881 }
3882 }
3883
3840 if (mrioc->shost->nr_hw_queues > mrioc->num_op_reply_q) {3884 if (mrioc->shost->nr_hw_queues > mrioc->num_op_reply_q) {
3841 ioc_err(mrioc,3885 ioc_err(mrioc,
3842 "cannot create minimum number of operational queues expected:%d created:%d\n",3886 "cannot create minimum number of operational queues expected:%d created:%d\n",
@@ -3948,8 +3992,14 @@ void mpi3mr_memset_buffers(struct mpi3mr_ioc *mrioc) · 105 unmodified lines
3948 3992
3949 if (mrioc->init_cmds.reply) {3993 if (mrioc->init_cmds.reply) {
3950 memset(mrioc->init_cmds.reply, 0, sizeof(*mrioc->init_cmds.reply));3994 memset(mrioc->init_cmds.reply, 0, sizeof(*mrioc->init_cmds.reply));
3995 memset(mrioc->bsg_cmds.reply, 0,
3996 sizeof(*mrioc->bsg_cmds.reply));
3951 memset(mrioc->host_tm_cmds.reply, 0,3997 memset(mrioc->host_tm_cmds.reply, 0,
3952 sizeof(*mrioc->host_tm_cmds.reply));3998 sizeof(*mrioc->host_tm_cmds.reply));
3999 memset(mrioc->pel_cmds.reply, 0,
4000 sizeof(*mrioc->pel_cmds.reply));
4001 memset(mrioc->pel_abort_cmd.reply, 0,
4002 sizeof(*mrioc->pel_abort_cmd.reply));
3953 for (i = 0; i < MPI3MR_NUM_DEVRMCMD; i++)4003 for (i = 0; i < MPI3MR_NUM_DEVRMCMD; i++)
3954 memset(mrioc->dev_rmhs_cmds[i].reply, 0,4004 memset(mrioc->dev_rmhs_cmds[i].reply, 0,
3955 sizeof(*mrioc->dev_rmhs_cmds[i].reply));4005 sizeof(*mrioc->dev_rmhs_cmds[i].reply));
@@ -4050,9 +4100,18 @@ void mpi3mr_free_mem(struct mpi3mr_ioc *mrioc) · 94 unmodified lines
4050 kfree(mrioc->init_cmds.reply);4100 kfree(mrioc->init_cmds.reply);
4051 mrioc->init_cmds.reply = NULL;4101 mrioc->init_cmds.reply = NULL;
4052 4102
4103 kfree(mrioc->bsg_cmds.reply);
4104 mrioc->bsg_cmds.reply = NULL;
4105
4053 kfree(mrioc->host_tm_cmds.reply);4106 kfree(mrioc->host_tm_cmds.reply);
4054 mrioc->host_tm_cmds.reply = NULL;4107 mrioc->host_tm_cmds.reply = NULL;
4055 4108
4109 kfree(mrioc->pel_cmds.reply);
4110 mrioc->pel_cmds.reply = NULL;
4111
4112 kfree(mrioc->pel_abort_cmd.reply);
4113 mrioc->pel_abort_cmd.reply = NULL;
4114
4056 for (i = 0; i < MPI3MR_NUM_EVTACKCMD; i++) {4115 for (i = 0; i < MPI3MR_NUM_EVTACKCMD; i++) {
4057 kfree(mrioc->evtack_cmds[i].reply);4116 kfree(mrioc->evtack_cmds[i].reply);
4058 mrioc->evtack_cmds[i].reply = NULL;4117 mrioc->evtack_cmds[i].reply = NULL;
@@ -4101,6 +4160,16 @@ void mpi3mr_free_mem(struct mpi3mr_ioc *mrioc) · 42 unmodified lines
4101 mrioc->admin_req_base, mrioc->admin_req_dma);4160 mrioc->admin_req_base, mrioc->admin_req_dma);
4102 mrioc->admin_req_base = NULL;4161 mrioc->admin_req_base = NULL;
4103 }4162 }
4163
4164 if (mrioc->pel_seqnum_virt) {
4165 dma_free_coherent(&mrioc->pdev->dev, mrioc->pel_seqnum_sz,
4166 mrioc->pel_seqnum_virt, mrioc->pel_seqnum_dma);
4167 mrioc->pel_seqnum_virt = NULL;
4168 }
4169
4170 kfree(mrioc->logdata_buf);
4171 mrioc->logdata_buf = NULL;
4172
4104}4173}
4105 4174
4106/**4175/**
@@ -4235,6 +4304,8 @@ static void mpi3mr_flush_drv_cmds(struct mpi3mr_ioc *mrioc) · 128 unmodified lines
4235 4304
4236 cmdptr = &mrioc->init_cmds;4305 cmdptr = &mrioc->init_cmds;
4237 mpi3mr_drv_cmd_comp_reset(mrioc, cmdptr);4306 mpi3mr_drv_cmd_comp_reset(mrioc, cmdptr);
4307 cmdptr = &mrioc->bsg_cmds;
4308 mpi3mr_drv_cmd_comp_reset(mrioc, cmdptr);
4238 cmdptr = &mrioc->host_tm_cmds;4309 cmdptr = &mrioc->host_tm_cmds;
4239 mpi3mr_drv_cmd_comp_reset(mrioc, cmdptr);4310 mpi3mr_drv_cmd_comp_reset(mrioc, cmdptr);
4240 4311
@@ -4247,6 +4318,254 @@ static void mpi3mr_flush_drv_cmds(struct mpi3mr_ioc *mrioc) · 6 unmodified lines
4247 cmdptr = &mrioc->evtack_cmds[i];4318 cmdptr = &mrioc->evtack_cmds[i];
4248 mpi3mr_drv_cmd_comp_reset(mrioc, cmdptr);4319 mpi3mr_drv_cmd_comp_reset(mrioc, cmdptr);
4249 }4320 }
4321
4322 cmdptr = &mrioc->pel_cmds;
4323 mpi3mr_drv_cmd_comp_reset(mrioc, cmdptr);
4324
4325 cmdptr = &mrioc->pel_abort_cmd;
4326 mpi3mr_drv_cmd_comp_reset(mrioc, cmdptr);
4327
4328}
4329
4330/**
4331 * mpi3mr_pel_wait_post - Issue PEL Wait
4332 * @mrioc: Adapter instance reference
4333 * @drv_cmd: Internal command tracker
4334 *
4335 * Issue PEL Wait MPI request through admin queue and return.
4336 *
4337 * Return: Nothing.
4338 */
4339static void mpi3mr_pel_wait_post(struct mpi3mr_ioc *mrioc,
4340 struct mpi3mr_drv_cmd *drv_cmd)
4341{
4342 struct mpi3_pel_req_action_wait pel_wait;
4343
4344 mrioc->pel_abort_requested = false;
4345
4346 memset(&pel_wait, 0, sizeof(pel_wait));
4347 drv_cmd->state = MPI3MR_CMD_PENDING;
4348 drv_cmd->is_waiting = 0;
4349 drv_cmd->callback = mpi3mr_pel_wait_complete;
4350 drv_cmd->ioc_status = 0;
4351 drv_cmd->ioc_loginfo = 0;
4352 pel_wait.host_tag = cpu_to_le16(MPI3MR_HOSTTAG_PEL_WAIT);
4353 pel_wait.function = MPI3_FUNCTION_PERSISTENT_EVENT_LOG;
4354 pel_wait.action = MPI3_PEL_ACTION_WAIT;
4355 pel_wait.starting_sequence_number = cpu_to_le32(mrioc->pel_newest_seqnum);
4356 pel_wait.locale = cpu_to_le16(mrioc->pel_locale);
4357 pel_wait.class = cpu_to_le16(mrioc->pel_class);
4358 pel_wait.wait_time = MPI3_PEL_WAITTIME_INFINITE_WAIT;
4359 dprint_bsg_info(mrioc, "sending pel_wait seqnum(%d), class(%d), locale(0x%08x)\n",
4360 mrioc->pel_newest_seqnum, mrioc->pel_class, mrioc->pel_locale);
4361
4362 if (mpi3mr_admin_request_post(mrioc, &pel_wait, sizeof(pel_wait), 0)) {
4363 dprint_bsg_err(mrioc,
4364 "Issuing PELWait: Admin post failed\n");
4365 drv_cmd->state = MPI3MR_CMD_NOTUSED;
4366 drv_cmd->callback = NULL;
4367 drv_cmd->retry_count = 0;
4368 mrioc->pel_enabled = false;
4369 }
4370}
4371
4372/**
4373 * mpi3mr_pel_get_seqnum_post - Issue PEL Get Sequence number
4374 * @mrioc: Adapter instance reference
4375 * @drv_cmd: Internal command tracker
4376 *
4377 * Issue PEL get sequence number MPI request through admin queue
4378 * and return.
4379 *
4380 * Return: 0 on success, non-zero on failure.
4381 */
4382int mpi3mr_pel_get_seqnum_post(struct mpi3mr_ioc *mrioc,
4383 struct mpi3mr_drv_cmd *drv_cmd)
4384{
4385 struct mpi3_pel_req_action_get_sequence_numbers pel_getseq_req;
4386 u8 sgl_flags = MPI3MR_SGEFLAGS_SYSTEM_SIMPLE_END_OF_LIST;
4387 int retval = 0;
4388
4389 memset(&pel_getseq_req, 0, sizeof(pel_getseq_req));
4390 mrioc->pel_cmds.state = MPI3MR_CMD_PENDING;
4391 mrioc->pel_cmds.is_waiting = 0;
4392 mrioc->pel_cmds.ioc_status = 0;
4393 mrioc->pel_cmds.ioc_loginfo = 0;
4394 mrioc->pel_cmds.callback = mpi3mr_pel_get_seqnum_complete;
4395 pel_getseq_req.host_tag = cpu_to_le16(MPI3MR_HOSTTAG_PEL_WAIT);
4396 pel_getseq_req.function = MPI3_FUNCTION_PERSISTENT_EVENT_LOG;
4397 pel_getseq_req.action = MPI3_PEL_ACTION_GET_SEQNUM;
4398 mpi3mr_add_sg_single(&pel_getseq_req.sgl, sgl_flags,
4399 mrioc->pel_seqnum_sz, mrioc->pel_seqnum_dma);
4400
4401 retval = mpi3mr_admin_request_post(mrioc, &pel_getseq_req,
4402 sizeof(pel_getseq_req), 0);
4403 if (retval) {
4404 if (drv_cmd) {
4405 drv_cmd->state = MPI3MR_CMD_NOTUSED;
4406 drv_cmd->callback = NULL;
4407 drv_cmd->retry_count = 0;
4408 }
4409 mrioc->pel_enabled = false;
4410 }
4411
4412 return retval;
4413}
4414
4415/**
4416 * mpi3mr_pel_wait_complete - PELWait Completion callback
4417 * @mrioc: Adapter instance reference
4418 * @drv_cmd: Internal command tracker
4419 *
4420 * This is a callback handler for the PELWait request and
4421 * firmware completes a PELWait request when it is aborted or a
4422 * new PEL entry is available. This sends AEN to the application
4423 * and if the PELwait completion is not due to PELAbort then
4424 * this will send a request for new PEL Sequence number
4425 *
4426 * Return: Nothing.
4427 */
4428static void mpi3mr_pel_wait_complete(struct mpi3mr_ioc *mrioc,
4429 struct mpi3mr_drv_cmd *drv_cmd)
4430{
4431 struct mpi3_pel_reply *pel_reply = NULL;
4432 u16 ioc_status, pe_log_status;
4433 bool do_retry = false;
4434
4435 if (drv_cmd->state & MPI3MR_CMD_RESET)
4436 goto cleanup_drv_cmd;
4437
4438 ioc_status = drv_cmd->ioc_status & MPI3_IOCSTATUS_STATUS_MASK;
4439 if (ioc_status != MPI3_IOCSTATUS_SUCCESS) {
4440 ioc_err(mrioc, "%s: Failed ioc_status(0x%04x) Loginfo(0x%08x)\n",
4441 __func__, ioc_status, drv_cmd->ioc_loginfo);
4442 dprint_bsg_err(mrioc,
4443 "pel_wait: failed with ioc_status(0x%04x), log_info(0x%08x)\n",
4444 ioc_status, drv_cmd->ioc_loginfo);
4445 do_retry = true;
4446 }
4447
4448 if (drv_cmd->state & MPI3MR_CMD_REPLY_VALID)
4449 pel_reply = (struct mpi3_pel_reply *)drv_cmd->reply;
4450
4451 if (!pel_reply) {
4452 dprint_bsg_err(mrioc,
4453 "pel_wait: failed due to no reply\n");
4454 goto out_failed;
4455 }
4456
4457 pe_log_status = le16_to_cpu(pel_reply->pe_log_status);
4458 if ((pe_log_status != MPI3_PEL_STATUS_SUCCESS) &&
4459 (pe_log_status != MPI3_PEL_STATUS_ABORTED)) {
4460 ioc_err(mrioc, "%s: Failed pe_log_status(0x%04x)\n",
4461 __func__, pe_log_status);
4462 dprint_bsg_err(mrioc,
4463 "pel_wait: failed due to pel_log_status(0x%04x)\n",
4464 pe_log_status);
4465 do_retry = true;
4466 }
4467
4468 if (do_retry) {
4469 if (drv_cmd->retry_count < MPI3MR_PEL_RETRY_COUNT) {
4470 drv_cmd->retry_count++;
4471 dprint_bsg_err(mrioc, "pel_wait: retrying(%d)\n",
4472 drv_cmd->retry_count);
4473 mpi3mr_pel_wait_post(mrioc, drv_cmd);
4474 return;
4475 }
4476 dprint_bsg_err(mrioc,
4477 "pel_wait: failed after all retries(%d)\n",
4478 drv_cmd->retry_count);
4479 goto out_failed;
4480 }
4481 atomic64_inc(&event_counter);
4482 if (!mrioc->pel_abort_requested) {
4483 mrioc->pel_cmds.retry_count = 0;
4484 mpi3mr_pel_get_seqnum_post(mrioc, &mrioc->pel_cmds);
4485 }
4486
4487 return;
4488out_failed:
4489 mrioc->pel_enabled = false;
4490cleanup_drv_cmd:
4491 drv_cmd->state = MPI3MR_CMD_NOTUSED;
4492 drv_cmd->callback = NULL;
4493 drv_cmd->retry_count = 0;
4494}
4495
4496/**
4497 * mpi3mr_pel_get_seqnum_complete - PELGetSeqNum Completion callback
4498 * @mrioc: Adapter instance reference
4499 * @drv_cmd: Internal command tracker
4500 *
4501 * This is a callback handler for the PEL get sequence number
4502 * request and a new PEL wait request will be issued to the
4503 * firmware from this
4504 *
4505 * Return: Nothing.
4506 */
4507void mpi3mr_pel_get_seqnum_complete(struct mpi3mr_ioc *mrioc,
4508 struct mpi3mr_drv_cmd *drv_cmd)
4509{
4510 struct mpi3_pel_reply *pel_reply = NULL;
4511 struct mpi3_pel_seq *pel_seqnum_virt;
4512 u16 ioc_status;
4513 bool do_retry = false;
4514
4515 pel_seqnum_virt = (struct mpi3_pel_seq *)mrioc->pel_seqnum_virt;
4516
4517 if (drv_cmd->state & MPI3MR_CMD_RESET)
4518 goto cleanup_drv_cmd;
4519
4520 ioc_status = drv_cmd->ioc_status & MPI3_IOCSTATUS_STATUS_MASK;
4521 if (ioc_status != MPI3_IOCSTATUS_SUCCESS) {
4522 dprint_bsg_err(mrioc,
4523 "pel_get_seqnum: failed with ioc_status(0x%04x), log_info(0x%08x)\n",
4524 ioc_status, drv_cmd->ioc_loginfo);
4525 do_retry = true;
4526 }
4527
4528 if (drv_cmd->state & MPI3MR_CMD_REPLY_VALID)
4529 pel_reply = (struct mpi3_pel_reply *)drv_cmd->reply;
4530 if (!pel_reply) {
4531 dprint_bsg_err(mrioc,
4532 "pel_get_seqnum: failed due to no reply\n");
4533 goto out_failed;
4534 }
4535
4536 if (le16_to_cpu(pel_reply->pe_log_status) != MPI3_PEL_STATUS_SUCCESS) {
4537 dprint_bsg_err(mrioc,
4538 "pel_get_seqnum: failed due to pel_log_status(0x%04x)\n",
4539 le16_to_cpu(pel_reply->pe_log_status));
4540 do_retry = true;
4541 }
4542
4543 if (do_retry) {
4544 if (drv_cmd->retry_count < MPI3MR_PEL_RETRY_COUNT) {
4545 drv_cmd->retry_count++;
4546 dprint_bsg_err(mrioc,
4547 "pel_get_seqnum: retrying(%d)\n",
4548 drv_cmd->retry_count);
4549 mpi3mr_pel_get_seqnum_post(mrioc, drv_cmd);
4550 return;
4551 }
4552
4553 dprint_bsg_err(mrioc,
4554 "pel_get_seqnum: failed after all retries(%d)\n",
4555 drv_cmd->retry_count);
4556 goto out_failed;
4557 }
4558 mrioc->pel_newest_seqnum = le32_to_cpu(pel_seqnum_virt->newest) + 1;
4559 drv_cmd->retry_count = 0;
4560 mpi3mr_pel_wait_post(mrioc, drv_cmd);
4561
4562 return;
4563out_failed:
4564 mrioc->pel_enabled = false;
4565cleanup_drv_cmd:
4566 drv_cmd->state = MPI3MR_CMD_NOTUSED;
4567 drv_cmd->callback = NULL;
4568 drv_cmd->retry_count = 0;
4250}4569}
4251 4570
4252/**4571/**
@@ -4258,7 +4577,7 @@ static void mpi3mr_flush_drv_cmds(struct mpi3mr_ioc *mrioc) · 5 unmodified lines
4258 * This is an handler for recovering controller by issuing soft4577 * This is an handler for recovering controller by issuing soft
4259 * reset are diag fault reset. This is a blocking function and4578 * reset are diag fault reset. This is a blocking function and
4260 * when one reset is executed if any other resets they will be4579 * when one reset is executed if any other resets they will be
4261 * blocked. All IOCTLs/IO will be blocked during the reset. If4580 * blocked. All BSG requests will be blocked during the reset. If
4262 * controller reset is successful then the controller will be4581 * controller reset is successful then the controller will be
4263 * reinitalized, otherwise the controller will be marked as not4582 * reinitalized, otherwise the controller will be marked as not
4264 * recoverable4583 * recoverable
@@ -4305,6 +4624,7 @@ int mpi3mr_soft_reset_handler(struct mpi3mr_ioc *mrioc, · 40 unmodified lines
4305 mpi3mr_reset_rc_name(reset_reason));4624 mpi3mr_reset_rc_name(reset_reason));
4306 4625
4307 mrioc->reset_in_progress = 1;4626 mrioc->reset_in_progress = 1;
4627 mrioc->stop_bsgs = 1;
4308 mrioc->prev_reset_result = -1;4628 mrioc->prev_reset_result = -1;
4309 4629
4310 if ((!snapdump) && (reset_reason != MPI3MR_RESET_FROM_FAULT_WATCH) &&4630 if ((!snapdump) && (reset_reason != MPI3MR_RESET_FROM_FAULT_WATCH) &&
@@ -4369,6 +4689,12 @@ out: · 58 unmodified lines
4369 if (!retval) {4689 if (!retval) {
4370 mrioc->diagsave_timeout = 0;4690 mrioc->diagsave_timeout = 0;
4371 mrioc->reset_in_progress = 0;4691 mrioc->reset_in_progress = 0;
4692 mrioc->pel_abort_requested = 0;
4693 if (mrioc->pel_enabled) {
4694 mrioc->pel_cmds.retry_count = 0;
4695 mpi3mr_pel_wait_post(mrioc, &mrioc->pel_cmds);
4696 }
4697
4372 mpi3mr_rfresh_tgtdevs(mrioc);4698 mpi3mr_rfresh_tgtdevs(mrioc);
4373 mrioc->ts_update_counter = 0;4699 mrioc->ts_update_counter = 0;
4374 spin_lock_irqsave(&mrioc->watchdog_lock, flags);4700 spin_lock_irqsave(&mrioc->watchdog_lock, flags);
@@ -4377,6 +4703,9 @@ out: · 2 unmodified lines
4377 &mrioc->watchdog_work,4703 &mrioc->watchdog_work,
4378 msecs_to_jiffies(MPI3MR_WATCHDOG_INTERVAL));4704 msecs_to_jiffies(MPI3MR_WATCHDOG_INTERVAL));
4379 spin_unlock_irqrestore(&mrioc->watchdog_lock, flags);4705 spin_unlock_irqrestore(&mrioc->watchdog_lock, flags);
4706 mrioc->stop_bsgs = 0;
4707 if (mrioc->pel_enabled)
4708 atomic64_inc(&event_counter);
4380 } else {4709 } else {
4381 mpi3mr_issue_reset(mrioc,4710 mpi3mr_issue_reset(mrioc,
4382 MPI3_SYSIF_HOST_DIAG_RESET_ACTION_DIAG_FAULT, reset_reason);4711 MPI3_SYSIF_HOST_DIAG_RESET_ACTION_DIAG_FAULT, reset_reason);
drivers/scsi/mpi3mr/mpi3mr_os.c+66−5
@@ -14,6 +14,7 @@ LIST_HEAD(mrioc_list); · 13 unmodified lines
14DEFINE_SPINLOCK(mrioc_list_lock);14DEFINE_SPINLOCK(mrioc_list_lock);
15static int mrioc_ids;15static int mrioc_ids;
16static int warn_non_secure_ctlr;16static int warn_non_secure_ctlr;
17atomic64_t event_counter;
17 18
18MODULE_AUTHOR(MPI3MR_DRIVER_AUTHOR);19MODULE_AUTHOR(MPI3MR_DRIVER_AUTHOR);
19MODULE_DESCRIPTION(MPI3MR_DRIVER_DESC);20MODULE_DESCRIPTION(MPI3MR_DRIVER_DESC);
@@ -634,7 +635,7 @@ found_tgtdev: · 614 unmodified lines
634 *635 *
635 * Return: Target device reference.636 * Return: Target device reference.
636 */637 */
637static struct mpi3mr_tgt_dev *mpi3mr_get_tgtdev_by_handle(638struct mpi3mr_tgt_dev *mpi3mr_get_tgtdev_by_handle(
638 struct mpi3mr_ioc *mrioc, u16 handle)639 struct mpi3mr_ioc *mrioc, u16 handle)
639{640{
640 struct mpi3mr_tgt_dev *tgtdev;641 struct mpi3mr_tgt_dev *tgtdev;
@@ -910,9 +911,11 @@ void mpi3mr_rfresh_tgtdevs(struct mpi3mr_ioc *mrioc) · 269 unmodified lines
910 911
911 list_for_each_entry_safe(tgtdev, tgtdev_next, &mrioc->tgtdev_list,912 list_for_each_entry_safe(tgtdev, tgtdev_next, &mrioc->tgtdev_list,
912 list) {913 list) {
913 if ((tgtdev->dev_handle == MPI3MR_INVALID_DEV_HANDLE) &&914 if (tgtdev->dev_handle == MPI3MR_INVALID_DEV_HANDLE) {
914 tgtdev->host_exposed) {915 dprint_reset(mrioc, "removing target device with perst_id(%d)\n",
915 mpi3mr_remove_tgtdev_from_host(mrioc, tgtdev);916 tgtdev->perst_id);
917 if (tgtdev->host_exposed)
918 mpi3mr_remove_tgtdev_from_host(mrioc, tgtdev);
916 mpi3mr_tgtdev_del_from_list(mrioc, tgtdev);919 mpi3mr_tgtdev_del_from_list(mrioc, tgtdev);
917 mpi3mr_tgtdev_put(tgtdev);920 mpi3mr_tgtdev_put(tgtdev);
918 }921 }
@@ -1415,6 +1418,23 @@ static void mpi3mr_pcietopochg_evt_bh(struct mpi3mr_ioc *mrioc, · 496 unmodified lines
1415 }1418 }
1416}1419}
1417 1420
1421/**
1422 * mpi3mr_logdata_evt_bh - Log data event bottomhalf
1423 * @mrioc: Adapter instance reference
1424 * @fwevt: Firmware event reference
1425 *
1426 * Extracts the event data and calls application interfacing
1427 * function to process the event further.
1428 *
1429 * Return: Nothing.
1430 */
1431static void mpi3mr_logdata_evt_bh(struct mpi3mr_ioc *mrioc,
1432 struct mpi3mr_fwevt *fwevt)
1433{
1434 mpi3mr_app_save_logdata(mrioc, fwevt->event_data,
1435 fwevt->event_data_size);
1436}
1437
1418/**1438/**
1419 * mpi3mr_fwevt_bh - Firmware event bottomhalf handler1439 * mpi3mr_fwevt_bh - Firmware event bottomhalf handler
1420 * @mrioc: Adapter instance reference1440 * @mrioc: Adapter instance reference
@@ -1467,6 +1487,11 @@ static void mpi3mr_fwevt_bh(struct mpi3mr_ioc *mrioc, · 46 unmodified lines
1467 mpi3mr_pcietopochg_evt_bh(mrioc, fwevt);1487 mpi3mr_pcietopochg_evt_bh(mrioc, fwevt);
1468 break;1488 break;
1469 }1489 }
1490 case MPI3_EVENT_LOG_DATA:
1491 {
1492 mpi3mr_logdata_evt_bh(mrioc, fwevt);
1493 break;
1494 }
1470 default:1495 default:
1471 break;1496 break;
1472 }1497 }
@@ -2298,6 +2323,7 @@ void mpi3mr_os_handle_events(struct mpi3mr_ioc *mrioc, · 825 unmodified lines
2298 break;2323 break;
2299 }2324 }
2300 case MPI3_EVENT_DEVICE_INFO_CHANGED:2325 case MPI3_EVENT_DEVICE_INFO_CHANGED:
2326 case MPI3_EVENT_LOG_DATA:
2301 {2327 {
2302 process_evt_bh = 1;2328 process_evt_bh = 1;
2303 break;2329 break;
@@ -2996,7 +3022,7 @@ inline void mpi3mr_poll_pend_io_completions(struct mpi3mr_ioc *mrioc) · 692 unmodified lines
2996 *3022 *
2997 * Return: 0 on success, non-zero on errors3023 * Return: 0 on success, non-zero on errors
2998 */3024 */
2999static int mpi3mr_issue_tm(struct mpi3mr_ioc *mrioc, u8 tm_type,3025int mpi3mr_issue_tm(struct mpi3mr_ioc *mrioc, u8 tm_type,
3000 u16 handle, uint lun, u16 htag, ulong timeout,3026 u16 handle, uint lun, u16 htag, ulong timeout,
3001 struct mpi3mr_drv_cmd *drv_cmd,3027 struct mpi3mr_drv_cmd *drv_cmd,
3002 u8 *resp_code, struct scsi_cmnd *scmd)3028 u8 *resp_code, struct scsi_cmnd *scmd)
@@ -3589,6 +3615,7 @@ static int mpi3mr_scan_finished(struct Scsi_Host *shost, · 586 unmodified lines
3589 3615
3590 mpi3mr_start_watchdog(mrioc);3616 mpi3mr_start_watchdog(mrioc);
3591 mrioc->is_driver_loading = 0;3617 mrioc->is_driver_loading = 0;
3618 mrioc->stop_bsgs = 0;
3592 return 1;3619 return 1;
3593}3620}
3594 3621
@@ -3700,6 +3727,10 @@ static int mpi3mr_slave_configure(struct scsi_device *sdev) · 105 unmodified lines
3700 return -ENXIO;3727 return -ENXIO;
3701 3728
3702 mpi3mr_change_queue_depth(sdev, tgt_dev->q_depth);3729 mpi3mr_change_queue_depth(sdev, tgt_dev->q_depth);
3730
3731 sdev->eh_timeout = MPI3MR_EH_SCMD_TIMEOUT;
3732 blk_queue_rq_timeout(sdev->request_queue, MPI3MR_SCMD_TIMEOUT);
3733
3703 switch (tgt_dev->dev_type) {3734 switch (tgt_dev->dev_type) {
3704 case MPI3_DEVICE_DEVFORM_PCIE:3735 case MPI3_DEVICE_DEVFORM_PCIE:
3705 /*The block layer hw sector size = 512*/3736 /*The block layer hw sector size = 512*/
@@ -3971,6 +4002,12 @@ static int mpi3mr_qcmd(struct Scsi_Host *shost, · 265 unmodified lines
3971 int iprio_class;4002 int iprio_class;
3972 u8 is_pcie_dev = 0;4003 u8 is_pcie_dev = 0;
3973 4004
4005 if (mrioc->unrecoverable) {
4006 scmd->result = DID_ERROR << 16;
4007 scsi_done(scmd);
4008 goto out;
4009 }
4010
3974 sdev_priv_data = scmd->device->hostdata;4011 sdev_priv_data = scmd->device->hostdata;
3975 if (!sdev_priv_data || !sdev_priv_data->tgt_priv_data) {4012 if (!sdev_priv_data || !sdev_priv_data->tgt_priv_data) {
3976 scmd->result = DID_NO_CONNECT << 16;4013 scmd->result = DID_NO_CONNECT << 16;
@@ -4109,6 +4146,8 @@ static struct scsi_host_template mpi3mr_driver_template = { · 132 unmodified lines
4109 .max_segment_size = 0xffffffff,4146 .max_segment_size = 0xffffffff,
4110 .track_queue_depth = 1,4147 .track_queue_depth = 1,
4111 .cmd_size = sizeof(struct scmd_priv),4148 .cmd_size = sizeof(struct scmd_priv),
4149 .shost_groups = mpi3mr_host_groups,
4150 .sdev_groups = mpi3mr_dev_groups,
4112};4151};
4113 4152
4114/**4153/**
@@ -4259,6 +4298,7 @@ mpi3mr_probe(struct pci_dev *pdev, const struct pci_device_id *id) · 144 unmodified lines
4259 mutex_init(&mrioc->reset_mutex);4298 mutex_init(&mrioc->reset_mutex);
4260 mpi3mr_init_drv_cmd(&mrioc->init_cmds, MPI3MR_HOSTTAG_INITCMDS);4299 mpi3mr_init_drv_cmd(&mrioc->init_cmds, MPI3MR_HOSTTAG_INITCMDS);
4261 mpi3mr_init_drv_cmd(&mrioc->host_tm_cmds, MPI3MR_HOSTTAG_BLK_TMS);4300 mpi3mr_init_drv_cmd(&mrioc->host_tm_cmds, MPI3MR_HOSTTAG_BLK_TMS);
4301 mpi3mr_init_drv_cmd(&mrioc->bsg_cmds, MPI3MR_HOSTTAG_BSG_CMDS);
4262 4302
4263 for (i = 0; i < MPI3MR_NUM_DEVRMCMD; i++)4303 for (i = 0; i < MPI3MR_NUM_DEVRMCMD; i++)
4264 mpi3mr_init_drv_cmd(&mrioc->dev_rmhs_cmds[i],4304 mpi3mr_init_drv_cmd(&mrioc->dev_rmhs_cmds[i],
@@ -4271,6 +4311,7 @@ mpi3mr_probe(struct pci_dev *pdev, const struct pci_device_id *id) · 6 unmodified lines
4271 mrioc->logging_level = logging_level;4311 mrioc->logging_level = logging_level;
4272 mrioc->shost = shost;4312 mrioc->shost = shost;
4273 mrioc->pdev = pdev;4313 mrioc->pdev = pdev;
4314 mrioc->stop_bsgs = 1;
4274 4315
4275 /* init shost parameters */4316 /* init shost parameters */
4276 shost->max_cmd_len = MPI3MR_MAX_CDB_LENGTH;4317 shost->max_cmd_len = MPI3MR_MAX_CDB_LENGTH;
@@ -4345,6 +4386,7 @@ mpi3mr_probe(struct pci_dev *pdev, const struct pci_device_id *id) · 68 unmodified lines
4345 }4386 }
4346 4387
4347 scsi_scan_host(shost);4388 scsi_scan_host(shost);
4389 mpi3mr_bsg_init(mrioc);
4348 return retval;4390 return retval;
4349 4391
4350addhost_failed:4392addhost_failed:
@@ -4389,6 +4431,7 @@ static void mpi3mr_remove(struct pci_dev *pdev) · 38 unmodified lines
4389 while (mrioc->reset_in_progress || mrioc->is_driver_loading)4431 while (mrioc->reset_in_progress || mrioc->is_driver_loading)
4390 ssleep(1);4432 ssleep(1);
4391 4433
4434 mpi3mr_bsg_exit(mrioc);
4392 mrioc->stop_drv_processing = 1;4435 mrioc->stop_drv_processing = 1;
4393 mpi3mr_cleanup_fwevt_list(mrioc);4436 mpi3mr_cleanup_fwevt_list(mrioc);
4394 spin_lock_irqsave(&mrioc->fwevt_lock, flags);4437 spin_lock_irqsave(&mrioc->fwevt_lock, flags);
@@ -4563,6 +4606,12 @@ static struct pci_driver mpi3mr_pci_driver = { · 168 unmodified lines
4563#endif4606#endif
4564};4607};
4565 4608
4609static ssize_t event_counter_show(struct device_driver *dd, char *buf)
4610{
4611 return sprintf(buf, "%llu\n", atomic64_read(&event_counter));
4612}
4613static DRIVER_ATTR_RO(event_counter);
4614
4566static int __init mpi3mr_init(void)4615static int __init mpi3mr_init(void)
4567{4616{
4568 int ret_val;4617 int ret_val;
@@ -4571,6 +4620,16 @@ static int __init mpi3mr_init(void) · 2 unmodified lines
4571 MPI3MR_DRIVER_VERSION);4620 MPI3MR_DRIVER_VERSION);
4572 4621
4573 ret_val = pci_register_driver(&mpi3mr_pci_driver);4622 ret_val = pci_register_driver(&mpi3mr_pci_driver);
4623 if (ret_val) {
4624 pr_err("%s failed to load due to pci register driver failure\n",
4625 MPI3MR_DRIVER_NAME);
4626 return ret_val;
4627 }
4628
4629 ret_val = driver_create_file(&mpi3mr_pci_driver.driver,
4630 &driver_attr_event_counter);
4631 if (ret_val)
4632 pci_unregister_driver(&mpi3mr_pci_driver);
4574 4633
4575 return ret_val;4634 return ret_val;
4576}4635}
@@ -4585,6 +4644,8 @@ static void __exit mpi3mr_exit(void) · 8 unmodified lines
4585 pr_info("Unloading %s version %s\n", MPI3MR_DRIVER_NAME,4644 pr_info("Unloading %s version %s\n", MPI3MR_DRIVER_NAME,
4586 MPI3MR_DRIVER_VERSION);4645 MPI3MR_DRIVER_VERSION);
4587 4646
4647 driver_remove_file(&mpi3mr_pci_driver.driver,
4648 &driver_attr_event_counter);
4588 pci_unregister_driver(&mpi3mr_pci_driver);4649 pci_unregister_driver(&mpi3mr_pci_driver);
4589}4650}
4590 4651
drivers/scsi/mpt3sas/mpt3sas_base.c+17−17
@@ -3692,10 +3692,11 @@ mpt3sas_base_map_resources(struct MPT3SAS_ADAPTER *ioc) · 3691 unmodified lines
3692 }3692 }
3693 3693
3694 for (i = 0; i < ioc->combined_reply_index_count; i++) {3694 for (i = 0; i < ioc->combined_reply_index_count; i++) {
3695 ioc->replyPostRegisterIndex[i] = (resource_size_t *)3695 ioc->replyPostRegisterIndex[i] =
3696 ((u8 __force *)&ioc->chip->Doorbell +3696 (resource_size_t __iomem *)
3697 MPI25_SUP_REPLY_POST_HOST_INDEX_OFFSET +3697 ((u8 __force *)&ioc->chip->Doorbell +
3698 (i * MPT3_SUP_REPLY_POST_HOST_INDEX_REG_OFFSET));3698 MPI25_SUP_REPLY_POST_HOST_INDEX_OFFSET +
3699 (i * MPT3_SUP_REPLY_POST_HOST_INDEX_REG_OFFSET));
3699 }3700 }
3700 }3701 }
3701 3702
@@ -4312,7 +4313,7 @@ _base_put_smid_scsi_io_atomic(struct MPT3SAS_ADAPTER *ioc, u16 smid, · 610 unmodified lines
4312 descriptor.MSIxIndex = _base_set_and_get_msix_index(ioc, smid);4313 descriptor.MSIxIndex = _base_set_and_get_msix_index(ioc, smid);
4313 descriptor.SMID = cpu_to_le16(smid);4314 descriptor.SMID = cpu_to_le16(smid);
4314 4315
4315 writel(cpu_to_le32(*request), &ioc->chip->AtomicRequestDescriptorPost);4316 writel(*request, &ioc->chip->AtomicRequestDescriptorPost);
4316}4317}
4317 4318
4318/**4319/**
@@ -4334,7 +4335,7 @@ _base_put_smid_fast_path_atomic(struct MPT3SAS_ADAPTER *ioc, u16 smid, · 15 unmodified lines
4334 descriptor.MSIxIndex = _base_set_and_get_msix_index(ioc, smid);4335 descriptor.MSIxIndex = _base_set_and_get_msix_index(ioc, smid);
4335 descriptor.SMID = cpu_to_le16(smid);4336 descriptor.SMID = cpu_to_le16(smid);
4336 4337
4337 writel(cpu_to_le32(*request), &ioc->chip->AtomicRequestDescriptorPost);4338 writel(*request, &ioc->chip->AtomicRequestDescriptorPost);
4338}4339}
4339 4340
4340/**4341/**
@@ -4357,7 +4358,7 @@ _base_put_smid_hi_priority_atomic(struct MPT3SAS_ADAPTER *ioc, u16 smid, · 16 unmodified lines
4357 descriptor.MSIxIndex = msix_task;4358 descriptor.MSIxIndex = msix_task;
4358 descriptor.SMID = cpu_to_le16(smid);4359 descriptor.SMID = cpu_to_le16(smid);
4359 4360
4360 writel(cpu_to_le32(*request), &ioc->chip->AtomicRequestDescriptorPost);4361 writel(*request, &ioc->chip->AtomicRequestDescriptorPost);
4361}4362}
4362 4363
4363/**4364/**
@@ -4378,7 +4379,7 @@ _base_put_smid_default_atomic(struct MPT3SAS_ADAPTER *ioc, u16 smid) · 14 unmodified lines
4378 descriptor.MSIxIndex = _base_set_and_get_msix_index(ioc, smid);4379 descriptor.MSIxIndex = _base_set_and_get_msix_index(ioc, smid);
4379 descriptor.SMID = cpu_to_le16(smid);4380 descriptor.SMID = cpu_to_le16(smid);
4380 4381
4381 writel(cpu_to_le32(*request), &ioc->chip->AtomicRequestDescriptorPost);4382 writel(*request, &ioc->chip->AtomicRequestDescriptorPost);
4382}4383}
4383 4384
4384/**4385/**
@@ -4752,7 +4753,7 @@ static void · 367 unmodified lines
4752_base_display_ioc_capabilities(struct MPT3SAS_ADAPTER *ioc)4753_base_display_ioc_capabilities(struct MPT3SAS_ADAPTER *ioc)
4753{4754{
4754 int i = 0;4755 int i = 0;
4755 char desc[16];4756 char desc[17] = {0};
4756 u32 iounit_pg1_flags;4757 u32 iounit_pg1_flags;
4757 u32 bios_version;4758 u32 bios_version;
4758 4759
@@ -6893,7 +6894,7 @@ _base_handshake_req_reply_wait(struct MPT3SAS_ADAPTER *ioc, int request_bytes, · 2134 unmodified lines
6893 6894
6894 /* send message 32-bits at a time */6895 /* send message 32-bits at a time */
6895 for (i = 0, failed = 0; i < request_bytes/4 && !failed; i++) {6896 for (i = 0, failed = 0; i < request_bytes/4 && !failed; i++) {
6896 writel(cpu_to_le32(request[i]), &ioc->chip->Doorbell);6897 writel(request[i], &ioc->chip->Doorbell);
6897 if ((_base_wait_for_doorbell_ack(ioc, 5)))6898 if ((_base_wait_for_doorbell_ack(ioc, 5)))
6898 failed = 1;6899 failed = 1;
6899 }6900 }
@@ -6912,16 +6913,16 @@ _base_handshake_req_reply_wait(struct MPT3SAS_ADAPTER *ioc, int request_bytes, · 12 unmodified lines
6912 }6913 }
6913 6914
6914 /* read the first two 16-bits, it gives the total length of the reply */6915 /* read the first two 16-bits, it gives the total length of the reply */
6915 reply[0] = le16_to_cpu(ioc->base_readl(&ioc->chip->Doorbell)6916 reply[0] = ioc->base_readl(&ioc->chip->Doorbell)
6916 & MPI2_DOORBELL_DATA_MASK);6917 & MPI2_DOORBELL_DATA_MASK;
6917 writel(0, &ioc->chip->HostInterruptStatus);6918 writel(0, &ioc->chip->HostInterruptStatus);
6918 if ((_base_wait_for_doorbell_int(ioc, 5))) {6919 if ((_base_wait_for_doorbell_int(ioc, 5))) {
6919 ioc_err(ioc, "doorbell handshake int failed (line=%d)\n",6920 ioc_err(ioc, "doorbell handshake int failed (line=%d)\n",
6920 __LINE__);6921 __LINE__);
6921 return -EFAULT;6922 return -EFAULT;
6922 }6923 }
6923 reply[1] = le16_to_cpu(ioc->base_readl(&ioc->chip->Doorbell)6924 reply[1] = ioc->base_readl(&ioc->chip->Doorbell)
6924 & MPI2_DOORBELL_DATA_MASK);6925 & MPI2_DOORBELL_DATA_MASK;
6925 writel(0, &ioc->chip->HostInterruptStatus);6926 writel(0, &ioc->chip->HostInterruptStatus);
6926 6927
6927 for (i = 2; i < default_reply->MsgLength * 2; i++) {6928 for (i = 2; i < default_reply->MsgLength * 2; i++) {
@@ -6933,9 +6934,8 @@ _base_handshake_req_reply_wait(struct MPT3SAS_ADAPTER *ioc, int request_bytes, · 5 unmodified lines
6933 if (i >= reply_bytes/2) /* overflow case */6934 if (i >= reply_bytes/2) /* overflow case */
6934 ioc->base_readl(&ioc->chip->Doorbell);6935 ioc->base_readl(&ioc->chip->Doorbell);
6935 else6936 else
6936 reply[i] = le16_to_cpu(6937 reply[i] = ioc->base_readl(&ioc->chip->Doorbell)
6937 ioc->base_readl(&ioc->chip->Doorbell)6938 & MPI2_DOORBELL_DATA_MASK;
6938 & MPI2_DOORBELL_DATA_MASK);
6939 writel(0, &ioc->chip->HostInterruptStatus);6939 writel(0, &ioc->chip->HostInterruptStatus);
6940 }6940 }
6941 6941
drivers/scsi/mpt3sas/mpt3sas_base.h+3−3
@@ -77,8 +77,8 @@ · 76 unmodified lines
77#define MPT3SAS_DRIVER_NAME "mpt3sas"77#define MPT3SAS_DRIVER_NAME "mpt3sas"
78#define MPT3SAS_AUTHOR "Avago Technologies <MPT-FusionLinux.pdl@avagotech.com>"78#define MPT3SAS_AUTHOR "Avago Technologies <MPT-FusionLinux.pdl@avagotech.com>"
79#define MPT3SAS_DESCRIPTION "LSI MPT Fusion SAS 3.0 Device Driver"79#define MPT3SAS_DESCRIPTION "LSI MPT Fusion SAS 3.0 Device Driver"
80#define MPT3SAS_DRIVER_VERSION "40.100.00.00"80#define MPT3SAS_DRIVER_VERSION "42.100.00.00"
81#define MPT3SAS_MAJOR_VERSION 4081#define MPT3SAS_MAJOR_VERSION 42
82#define MPT3SAS_MINOR_VERSION 10082#define MPT3SAS_MINOR_VERSION 100
83#define MPT3SAS_BUILD_VERSION 083#define MPT3SAS_BUILD_VERSION 0
84#define MPT3SAS_RELEASE_VERSION 0084#define MPT3SAS_RELEASE_VERSION 00
@@ -1588,7 +1588,7 @@ struct MPT3SAS_ADAPTER { · 1503 unmodified lines
1588 u8 combined_reply_index_count;1588 u8 combined_reply_index_count;
1589 u8 smp_affinity_enable;1589 u8 smp_affinity_enable;
1590 /* reply post register index */1590 /* reply post register index */
1591 resource_size_t **replyPostRegisterIndex;1591 resource_size_t __iomem **replyPostRegisterIndex;
1592 1592
1593 struct list_head delayed_tr_list;1593 struct list_head delayed_tr_list;
1594 struct list_head delayed_tr_volume_list;1594 struct list_head delayed_tr_volume_list;
drivers/scsi/mpt3sas/mpt3sas_ctl.c+6−5
@@ -578,7 +578,7 @@ static int · 577 unmodified lines
578_ctl_set_task_mid(struct MPT3SAS_ADAPTER *ioc, struct mpt3_ioctl_command *karg,578_ctl_set_task_mid(struct MPT3SAS_ADAPTER *ioc, struct mpt3_ioctl_command *karg,
579 Mpi2SCSITaskManagementRequest_t *tm_request)579 Mpi2SCSITaskManagementRequest_t *tm_request)
580{580{
581 u8 found = 0;581 bool found = false;
582 u16 smid;582 u16 smid;
583 u16 handle;583 u16 handle;
584 struct scsi_cmnd *scmd;584 struct scsi_cmnd *scmd;
@@ -600,6 +600,7 @@ _ctl_set_task_mid(struct MPT3SAS_ADAPTER *ioc, struct mpt3_ioctl_command *karg, · 15 unmodified lines
600 handle = le16_to_cpu(tm_request->DevHandle);600 handle = le16_to_cpu(tm_request->DevHandle);
601 for (smid = ioc->scsiio_depth; smid && !found; smid--) {601 for (smid = ioc->scsiio_depth; smid && !found; smid--) {
602 struct scsiio_tracker *st;602 struct scsiio_tracker *st;
603 __le16 task_mid;
603 604
604 scmd = mpt3sas_scsih_scsi_lookup_get(ioc, smid);605 scmd = mpt3sas_scsih_scsi_lookup_get(ioc, smid);
605 if (!scmd)606 if (!scmd)
@@ -618,10 +619,10 @@ _ctl_set_task_mid(struct MPT3SAS_ADAPTER *ioc, struct mpt3_ioctl_command *karg, · 12 unmodified lines
618 * first outstanding smid will be picked up. Otherwise,619 * first outstanding smid will be picked up. Otherwise,
619 * targeted smid will be the one.620 * targeted smid will be the one.
620 */621 */
621 if (!tm_request->TaskMID || tm_request->TaskMID == st->smid) {622 task_mid = cpu_to_le16(st->smid);
622 tm_request->TaskMID = cpu_to_le16(st->smid);623 if (!tm_request->TaskMID)
623 found = 1;624 tm_request->TaskMID = task_mid;
624 }625 found = tm_request->TaskMID == task_mid;
625 }626 }
626 627
627 if (!found) {628 if (!found) {
drivers/scsi/mpt3sas/mpt3sas_scsih.c+11−13
@@ -10926,20 +10926,20 @@ mpt3sas_scsih_event_callback(struct MPT3SAS_ADAPTER *ioc, u8 msix_index, · 10925 unmodified lines
10926 case MPI2_EVENT_LOG_ENTRY_ADDED:10926 case MPI2_EVENT_LOG_ENTRY_ADDED:
10927 {10927 {
10928 Mpi2EventDataLogEntryAdded_t *log_entry;10928 Mpi2EventDataLogEntryAdded_t *log_entry;
10929 u32 *log_code;10929 u32 log_code;
10930 10930
10931 if (!ioc->is_warpdrive)10931 if (!ioc->is_warpdrive)
10932 break;10932 break;
10933 10933
10934 log_entry = (Mpi2EventDataLogEntryAdded_t *)10934 log_entry = (Mpi2EventDataLogEntryAdded_t *)
10935 mpi_reply->EventData;10935 mpi_reply->EventData;
10936 log_code = (u32 *)log_entry->LogData;10936 log_code = le32_to_cpu(*(__le32 *)log_entry->LogData);
10937 10937
10938 if (le16_to_cpu(log_entry->LogEntryQualifier)10938 if (le16_to_cpu(log_entry->LogEntryQualifier)
10939 != MPT2_WARPDRIVE_LOGENTRY)10939 != MPT2_WARPDRIVE_LOGENTRY)
10940 break;10940 break;
10941 10941
10942 switch (le32_to_cpu(*log_code)) {10942 switch (log_code) {
10943 case MPT2_WARPDRIVE_LC_SSDT:10943 case MPT2_WARPDRIVE_LC_SSDT:
10944 ioc_warn(ioc, "WarpDrive Warning: IO Throttling has occurred in the WarpDrive subsystem. Check WarpDrive documentation for additional details.\n");10944 ioc_warn(ioc, "WarpDrive Warning: IO Throttling has occurred in the WarpDrive subsystem. Check WarpDrive documentation for additional details.\n");
10945 break;10945 break;
@@ -12588,20 +12588,18 @@ scsih_pci_mmio_enabled(struct pci_dev *pdev) · 1642 unmodified lines
12588 */12588 */
12589bool scsih_ncq_prio_supp(struct scsi_device *sdev)12589bool scsih_ncq_prio_supp(struct scsi_device *sdev)
12590{12590{
12591 unsigned char *buf;12591 struct scsi_vpd *vpd;
12592 bool ncq_prio_supp = false;12592 bool ncq_prio_supp = false;
12593 12593
12594 if (!scsi_device_supports_vpd(sdev))12594 rcu_read_lock();
12595 return ncq_prio_supp;12595 vpd = rcu_dereference(sdev->vpd_pg89);
12596 12596 if (!vpd || vpd->len < 214)
12597 buf = kmalloc(SCSI_VPD_PG_LEN, GFP_KERNEL);12597 goto out;
12598 if (!buf)
12599 return ncq_prio_supp;
12600 12598
12601 if (!scsi_get_vpd_page(sdev, 0x89, buf, SCSI_VPD_PG_LEN))12599 ncq_prio_supp = (vpd->data[213] >> 4) & 1;
12602 ncq_prio_supp = (buf[213] >> 4) & 1;12600out:
12601 rcu_read_unlock();
12603 12602
12604 kfree(buf);
12605 return ncq_prio_supp;12603 return ncq_prio_supp;
12606}12604}
12607/*12605/*
drivers/scsi/pmcraid.c+1−1
@@ -4590,7 +4590,7 @@ static int pmcraid_init_instance(struct pci_dev *pdev, struct Scsi_Host *host, · 4589 unmodified lines
4590 mapped_pci_addr + chip_cfg->ioa_host_mask_clr;4590 mapped_pci_addr + chip_cfg->ioa_host_mask_clr;
4591 pint_regs->global_interrupt_mask_reg =4591 pint_regs->global_interrupt_mask_reg =
4592 mapped_pci_addr + chip_cfg->global_intr_mask;4592 mapped_pci_addr + chip_cfg->global_intr_mask;
4593 };4593 }
4594 4594
4595 pinstance->ioa_reset_attempts = 0;4595 pinstance->ioa_reset_attempts = 0;
4596 init_waitqueue_head(&pinstance->reset_wait_q);4596 init_waitqueue_head(&pinstance->reset_wait_q);
drivers/scsi/qedf/qedf_attr.c+0−2
@@ -131,7 +131,6 @@ qedf_sysfs_write_grcdump(struct file *filep, struct kobject *kobj, · 130 unmodified lines
131 struct qedf_ctx *qedf = NULL;131 struct qedf_ctx *qedf = NULL;
132 long reading;132 long reading;
133 int ret = 0;133 int ret = 0;
134 char msg[40];
135 134
136 if (off != 0)135 if (off != 0)
137 return ret;136 return ret;
@@ -148,7 +147,6 @@ qedf_sysfs_write_grcdump(struct file *filep, struct kobject *kobj, · 10 unmodified lines
148 return ret;147 return ret;
149 }148 }
150 149
151 memset(msg, 0, sizeof(msg));
152 switch (reading) {150 switch (reading) {
153 case 0:151 case 0:
154 memset(qedf->grcdump, 0, qedf->grcdump_size);152 memset(qedf->grcdump, 0, qedf->grcdump_size);
drivers/scsi/qedf/qedf_io.c+1−2
@@ -804,7 +804,6 @@ static void qedf_trace_io(struct qedf_rport *fcport, struct qedf_ioreq *io_req, · 803 unmodified lines
804 struct qedf_io_log *io_log;804 struct qedf_io_log *io_log;
805 struct scsi_cmnd *sc_cmd = io_req->sc_cmd;805 struct scsi_cmnd *sc_cmd = io_req->sc_cmd;
806 unsigned long flags;806 unsigned long flags;
807 uint8_t op;
808 807
809 spin_lock_irqsave(&qedf->io_trace_lock, flags);808 spin_lock_irqsave(&qedf->io_trace_lock, flags);
810 809
@@ -813,7 +812,7 @@ static void qedf_trace_io(struct qedf_rport *fcport, struct qedf_ioreq *io_req, · 2 unmodified lines
813 io_log->task_id = io_req->xid;812 io_log->task_id = io_req->xid;
814 io_log->port_id = fcport->rdata->ids.port_id;813 io_log->port_id = fcport->rdata->ids.port_id;
815 io_log->lun = sc_cmd->device->lun;814 io_log->lun = sc_cmd->device->lun;
816 io_log->op = op = sc_cmd->cmnd[0];815 io_log->op = sc_cmd->cmnd[0];
817 io_log->lba[0] = sc_cmd->cmnd[2];816 io_log->lba[0] = sc_cmd->cmnd[2];
818 io_log->lba[1] = sc_cmd->cmnd[3];817 io_log->lba[1] = sc_cmd->cmnd[3];
819 io_log->lba[2] = sc_cmd->cmnd[4];818 io_log->lba[2] = sc_cmd->cmnd[4];
drivers/scsi/qedf/qedf_main.c+5−8
@@ -873,7 +873,7 @@ static int qedf_eh_device_reset(struct scsi_cmnd *sc_cmd) · 872 unmodified lines
873 873
874bool qedf_wait_for_upload(struct qedf_ctx *qedf)874bool qedf_wait_for_upload(struct qedf_ctx *qedf)
875{875{
876 struct qedf_rport *fcport = NULL;876 struct qedf_rport *fcport;
877 int wait_cnt = 120;877 int wait_cnt = 120;
878 878
879 while (wait_cnt--) {879 while (wait_cnt--) {
@@ -888,7 +888,7 @@ bool qedf_wait_for_upload(struct qedf_ctx *qedf) · 8 unmodified lines
888 888
889 rcu_read_lock();889 rcu_read_lock();
890 list_for_each_entry_rcu(fcport, &qedf->fcports, peers) {890 list_for_each_entry_rcu(fcport, &qedf->fcports, peers) {
891 if (fcport && test_bit(QEDF_RPORT_SESSION_READY,891 if (test_bit(QEDF_RPORT_SESSION_READY,
892 &fcport->flags)) {892 &fcport->flags)) {
893 if (fcport->rdata)893 if (fcport->rdata)
894 QEDF_ERR(&qedf->dbg_ctx,894 QEDF_ERR(&qedf->dbg_ctx,
@@ -899,9 +899,9 @@ bool qedf_wait_for_upload(struct qedf_ctx *qedf) · 4 unmodified lines
899 "Waiting for fcport %p.\n", fcport);899 "Waiting for fcport %p.\n", fcport);
900 }900 }
901 }901 }
902
902 rcu_read_unlock();903 rcu_read_unlock();
903 return false;904 return false;
904
905}905}
906 906
907/* Performs soft reset of qedf_ctx by simulating a link down/up */907/* Performs soft reset of qedf_ctx by simulating a link down/up */
@@ -1067,7 +1067,6 @@ static int qedf_xmit(struct fc_lport *lport, struct fc_frame *fp) · 159 unmodified lines
1067 u32 crc;1067 u32 crc;
1068 unsigned int hlen, tlen, elen;1068 unsigned int hlen, tlen, elen;
1069 int wlen;1069 int wlen;
1070 struct fc_stats *stats;
1071 struct fc_lport *tmp_lport;1070 struct fc_lport *tmp_lport;
1072 struct fc_lport *vn_port = NULL;1071 struct fc_lport *vn_port = NULL;
1073 struct qedf_rport *fcport;1072 struct qedf_rport *fcport;
@@ -1215,10 +1214,8 @@ static int qedf_xmit(struct fc_lport *lport, struct fc_frame *fp) · 141 unmodified lines
1215 hp->fcoe_sof = sof;1214 hp->fcoe_sof = sof;
1216 1215
1217 /*update tx stats */1216 /*update tx stats */
1218 stats = per_cpu_ptr(lport->stats, get_cpu());1217 this_cpu_inc(lport->stats->TxFrames);
1219 stats->TxFrames++;1218 this_cpu_add(lport->stats->TxWords, wlen);
1220 stats->TxWords += wlen;
1221 put_cpu();
1222 1219
1223 /* Get VLAN ID from skb for printing purposes */1220 /* Get VLAN ID from skb for printing purposes */
1224 __vlan_hwaccel_get_tag(skb, &vlan_tci);1221 __vlan_hwaccel_get_tag(skb, &vlan_tci);
drivers/scsi/qla2xxx/qla_edif.c+1−2
@@ -657,7 +657,6 @@ qla_edif_app_chk_sa_update(scsi_qla_host_t *vha, fc_port_t *fcport, · 656 unmodified lines
657static int657static int
658qla_edif_app_authok(scsi_qla_host_t *vha, struct bsg_job *bsg_job)658qla_edif_app_authok(scsi_qla_host_t *vha, struct bsg_job *bsg_job)
659{659{
660 int32_t rval = 0;
661 struct auth_complete_cmd appplogiok;660 struct auth_complete_cmd appplogiok;
662 struct app_plogi_reply appplogireply = {0};661 struct app_plogi_reply appplogireply = {0};
663 struct fc_bsg_reply *bsg_reply = bsg_job->reply;662 struct fc_bsg_reply *bsg_reply = bsg_job->reply;
@@ -758,7 +757,7 @@ errstate_exit: · 94 unmodified lines
758 &appplogireply,757 &appplogireply,
759 sizeof(struct app_plogi_reply));758 sizeof(struct app_plogi_reply));
760 759
761 return rval;760 return 0;
762}761}
763 762
764/**763/**
drivers/scsi/qla2xxx/qla_os.c+0−1
@@ -3933,7 +3933,6 @@ qla2x00_free_device(scsi_qla_host_t *vha) · 3932 unmodified lines
3933 3933
3934 /* Flush the work queue and remove it */3934 /* Flush the work queue and remove it */
3935 if (ha->wq) {3935 if (ha->wq) {
3936 flush_workqueue(ha->wq);
3937 destroy_workqueue(ha->wq);3936 destroy_workqueue(ha->wq);
3938 ha->wq = NULL;3937 ha->wq = NULL;
3939 }3938 }
drivers/scsi/qla2xxx/qla_target.c+0−2
@@ -3866,8 +3866,6 @@ void qlt_free_cmd(struct qla_tgt_cmd *cmd) · 3865 unmodified lines
3866 3866
3867 BUG_ON(cmd->sg_mapped);3867 BUG_ON(cmd->sg_mapped);
3868 cmd->jiffies_at_free = get_jiffies_64();3868 cmd->jiffies_at_free = get_jiffies_64();
3869 if (unlikely(cmd->free_sg))
3870 kfree(cmd->sg);
3871 3869
3872 if (!sess || !sess->se_sess) {3870 if (!sess || !sess->se_sess) {
3873 WARN_ON(1);3871 WARN_ON(1);
drivers/scsi/qla2xxx/qla_target.h+0−1
@@ -883,7 +883,6 @@ struct qla_tgt_cmd { · 882 unmodified lines
883 /* to save extra sess dereferences */883 /* to save extra sess dereferences */
884 unsigned int conf_compl_supported:1;884 unsigned int conf_compl_supported:1;
885 unsigned int sg_mapped:1;885 unsigned int sg_mapped:1;
886 unsigned int free_sg:1;
887 unsigned int write_data_transferred:1;886 unsigned int write_data_transferred:1;
888 unsigned int q_full:1;887 unsigned int q_full:1;
889 unsigned int term_exchg:1;888 unsigned int term_exchg:1;
drivers/scsi/qla4xxx/ql4_os.c+0−1
@@ -671,7 +671,6 @@ static void qla4xxx_create_chap_list(struct scsi_qla_host *ha) · 670 unmodified lines
671 goto exit_chap_list;671 goto exit_chap_list;
672 }672 }
673 673
674 memset(ha->chap_list, 0, chap_size);
675 memcpy(ha->chap_list, chap_flash_data, chap_size);674 memcpy(ha->chap_list, chap_flash_data, chap_size);
676 675
677exit_chap_list:676exit_chap_list:
drivers/scsi/scsi.c+79−37
@@ -200,11 +200,11 @@ void scsi_finish_command(struct scsi_cmnd *cmd) · 199 unmodified lines
200 200
201 201
202/*202/*
203 * 1024 is big enough for saturating fast SCSI LUNs.203 * 4096 is big enough for saturating fast SCSI LUNs.
204 */204 */
205int scsi_device_max_queue_depth(struct scsi_device *sdev)205int scsi_device_max_queue_depth(struct scsi_device *sdev)
206{206{
207 return min_t(int, sdev->host->can_queue, 1024);207 return min_t(int, sdev->host->can_queue, 4096);
208}208}
209 209
210/**210/**
@@ -321,6 +321,31 @@ static int scsi_vpd_inquiry(struct scsi_device *sdev, unsigned char *buffer, · 110 unmodified lines
321 return get_unaligned_be16(&buffer[2]) + 4;321 return get_unaligned_be16(&buffer[2]) + 4;
322}322}
323 323
324static int scsi_get_vpd_size(struct scsi_device *sdev, u8 page)
325{
326 unsigned char vpd_header[SCSI_VPD_HEADER_SIZE] __aligned(4);
327 int result;
328
329 /*
330 * Fetch the VPD page header to find out how big the page
331 * is. This is done to prevent problems on legacy devices
332 * which can not handle allocation lengths as large as
333 * potentially requested by the caller.
334 */
335 result = scsi_vpd_inquiry(sdev, vpd_header, page, sizeof(vpd_header));
336 if (result < 0)
337 return 0;
338
339 if (result < SCSI_VPD_HEADER_SIZE) {
340 dev_warn_once(&sdev->sdev_gendev,
341 "%s: short VPD page 0x%02x length: %d bytes\n",
342 __func__, page, result);
343 return 0;
344 }
345
346 return result;
347}
348
324/**349/**
325 * scsi_get_vpd_page - Get Vital Product Data from a SCSI device350 * scsi_get_vpd_page - Get Vital Product Data from a SCSI device
326 * @sdev: The device to ask351 * @sdev: The device to ask
@@ -330,47 +355,38 @@ static int scsi_vpd_inquiry(struct scsi_device *sdev, unsigned char *buffer, · 3 unmodified lines
330 *355 *
331 * SCSI devices may optionally supply Vital Product Data. Each 'page'356 * SCSI devices may optionally supply Vital Product Data. Each 'page'
332 * of VPD is defined in the appropriate SCSI document (eg SPC, SBC).357 * of VPD is defined in the appropriate SCSI document (eg SPC, SBC).
333 * If the device supports this VPD page, this routine returns a pointer358 * If the device supports this VPD page, this routine fills @buf
334 * to a buffer containing the data from that page. The caller is359 * with the data from that page and return 0. If the VPD page is not
335 * responsible for calling kfree() on this pointer when it is no longer360 * supported or its content cannot be retrieved, -EINVAL is returned.
336 * needed. If we cannot retrieve the VPD page this routine returns %NULL.
337 */361 */
338int scsi_get_vpd_page(struct scsi_device *sdev, u8 page, unsigned char *buf,362int scsi_get_vpd_page(struct scsi_device *sdev, u8 page, unsigned char *buf,
339 int buf_len)363 int buf_len)
340{364{
341 int i, result;365 int result, vpd_len;
342
343 if (sdev->skip_vpd_pages)
344 goto fail;
345
346 /* Ask for all the pages supported by this device */
347 result = scsi_vpd_inquiry(sdev, buf, 0, buf_len);
348 if (result < 4)
349 goto fail;
350 366
351 /* If the user actually wanted this page, we can skip the rest */367 if (!scsi_device_supports_vpd(sdev))
352 if (page == 0)368 return -EINVAL;
353 return 0;
354 369
355 for (i = 4; i < min(result, buf_len); i++)370 vpd_len = scsi_get_vpd_size(sdev, page);
356 if (buf[i] == page)371 if (vpd_len <= 0)
357 goto found;372 return -EINVAL;
358 373
359 if (i < result && i >= buf_len)374 vpd_len = min(vpd_len, buf_len);
360 /* ran off the end of the buffer, give us benefit of doubt */
361 goto found;
362 /* The device claims it doesn't support the requested page */
363 goto fail;
364 375
365 found:376 /*
366 result = scsi_vpd_inquiry(sdev, buf, page, buf_len);377 * Fetch the actual page. Since the appropriate size was reported
378 * by the device it is now safe to ask for something bigger.
379 */
380 memset(buf, 0, buf_len);
381 result = scsi_vpd_inquiry(sdev, buf, page, vpd_len);
367 if (result < 0)382 if (result < 0)
368 goto fail;383 return -EINVAL;
384 else if (result > vpd_len)
385 dev_warn_once(&sdev->sdev_gendev,
386 "%s: VPD page 0x%02x result %d > %d bytes\n",
387 __func__, page, result, vpd_len);
369 388
370 return 0;389 return 0;
371
372 fail:
373 return -EINVAL;
374}390}
375EXPORT_SYMBOL_GPL(scsi_get_vpd_page);391EXPORT_SYMBOL_GPL(scsi_get_vpd_page);
376 392
@@ -384,9 +400,17 @@ EXPORT_SYMBOL_GPL(scsi_get_vpd_page); · 7 unmodified lines
384static struct scsi_vpd *scsi_get_vpd_buf(struct scsi_device *sdev, u8 page)400static struct scsi_vpd *scsi_get_vpd_buf(struct scsi_device *sdev, u8 page)
385{401{
386 struct scsi_vpd *vpd_buf;402 struct scsi_vpd *vpd_buf;
387 int vpd_len = SCSI_VPD_PG_LEN, result;403 int vpd_len, result;
404
405 vpd_len = scsi_get_vpd_size(sdev, page);
406 if (vpd_len <= 0)
407 return NULL;
388 408
389retry_pg:409retry_pg:
410 /*
411 * Fetch the actual page. Since the appropriate size was reported
412 * by the device it is now safe to ask for something bigger.
413 */
390 vpd_buf = kmalloc(sizeof(*vpd_buf) + vpd_len, GFP_KERNEL);414 vpd_buf = kmalloc(sizeof(*vpd_buf) + vpd_len, GFP_KERNEL);
391 if (!vpd_buf)415 if (!vpd_buf)
392 return NULL;416 return NULL;
@@ -397,6 +421,9 @@ retry_pg: · 4 unmodified lines
397 return NULL;421 return NULL;
398 }422 }
399 if (result > vpd_len) {423 if (result > vpd_len) {
424 dev_warn_once(&sdev->sdev_gendev,
425 "%s: VPD page 0x%02x result %d > %d bytes\n",
426 __func__, page, result, vpd_len);
400 vpd_len = result;427 vpd_len = result;
401 kfree(vpd_buf);428 kfree(vpd_buf);
402 goto retry_pg;429 goto retry_pg;
@@ -456,6 +483,12 @@ void scsi_attach_vpd(struct scsi_device *sdev) · 53 unmodified lines
456 scsi_update_vpd_page(sdev, 0x83, &sdev->vpd_pg83);483 scsi_update_vpd_page(sdev, 0x83, &sdev->vpd_pg83);
457 if (vpd_buf->data[i] == 0x89)484 if (vpd_buf->data[i] == 0x89)
458 scsi_update_vpd_page(sdev, 0x89, &sdev->vpd_pg89);485 scsi_update_vpd_page(sdev, 0x89, &sdev->vpd_pg89);
486 if (vpd_buf->data[i] == 0xb0)
487 scsi_update_vpd_page(sdev, 0xb0, &sdev->vpd_pgb0);
488 if (vpd_buf->data[i] == 0xb1)
489 scsi_update_vpd_page(sdev, 0xb1, &sdev->vpd_pgb1);
490 if (vpd_buf->data[i] == 0xb2)
491 scsi_update_vpd_page(sdev, 0xb2, &sdev->vpd_pgb2);
459 }492 }
460 kfree(vpd_buf);493 kfree(vpd_buf);
461}494}
@@ -476,21 +509,30 @@ int scsi_report_opcode(struct scsi_device *sdev, unsigned char *buffer, · 14 unmodified lines
476{509{
477 unsigned char cmd[16];510 unsigned char cmd[16];
478 struct scsi_sense_hdr sshdr;511 struct scsi_sense_hdr sshdr;
479 int result;512 int result, request_len;
480 513
481 if (sdev->no_report_opcodes || sdev->scsi_level < SCSI_SPC_3)514 if (sdev->no_report_opcodes || sdev->scsi_level < SCSI_SPC_3)
482 return -EINVAL;515 return -EINVAL;
483 516
517 /* RSOC header + size of command we are asking about */
518 request_len = 4 + COMMAND_SIZE(opcode);
519 if (request_len > len) {
520 dev_warn_once(&sdev->sdev_gendev,
521 "%s: len %u bytes, opcode 0x%02x needs %u\n",
522 __func__, len, opcode, request_len);
523 return -EINVAL;
524 }
525
484 memset(cmd, 0, 16);526 memset(cmd, 0, 16);
485 cmd[0] = MAINTENANCE_IN;527 cmd[0] = MAINTENANCE_IN;
486 cmd[1] = MI_REPORT_SUPPORTED_OPERATION_CODES;528 cmd[1] = MI_REPORT_SUPPORTED_OPERATION_CODES;
487 cmd[2] = 1; /* One command format */529 cmd[2] = 1; /* One command format */
488 cmd[3] = opcode;530 cmd[3] = opcode;
489 put_unaligned_be32(len, &cmd[6]);531 put_unaligned_be32(request_len, &cmd[6]);
490 memset(buffer, 0, len);532 memset(buffer, 0, len);
491 533
492 result = scsi_execute_req(sdev, cmd, DMA_FROM_DEVICE, buffer, len,534 result = scsi_execute_req(sdev, cmd, DMA_FROM_DEVICE, buffer,
493 &sshdr, 30 * HZ, 3, NULL);535 request_len, &sshdr, 30 * HZ, 3, NULL);
494 536
495 if (result < 0)537 if (result < 0)
496 return result;538 return result;
drivers/scsi/scsi_debug.c+114−35
@@ -16,7 +16,7 @@ · 15 unmodified lines
16#define pr_fmt(fmt) KBUILD_MODNAME ":%s: " fmt, __func__16#define pr_fmt(fmt) KBUILD_MODNAME ":%s: " fmt, __func__
17 17
18#include <linux/module.h>18#include <linux/module.h>
19 19#include <linux/align.h>
20#include <linux/kernel.h>20#include <linux/kernel.h>
21#include <linux/errno.h>21#include <linux/errno.h>
22#include <linux/jiffies.h>22#include <linux/jiffies.h>
@@ -98,6 +98,7 @@ static const char *sdebug_version_date = "20210520"; · 75 unmodified lines
98#define WRITE_BOUNDARY_ASCQ 0x598#define WRITE_BOUNDARY_ASCQ 0x5
99#define READ_INVDATA_ASCQ 0x699#define READ_INVDATA_ASCQ 0x6
100#define READ_BOUNDARY_ASCQ 0x7100#define READ_BOUNDARY_ASCQ 0x7
101#define ATTEMPT_ACCESS_GAP 0x9
101#define INSUFF_ZONE_ASCQ 0xe102#define INSUFF_ZONE_ASCQ 0xe
102 103
103/* Additional Sense Code Qualifier (ASCQ) */104/* Additional Sense Code Qualifier (ASCQ) */
@@ -251,9 +252,11 @@ static const char *sdebug_version_date = "20210520"; · 147 unmodified lines
251 252
252/* Zone types (zbcr05 table 25) */253/* Zone types (zbcr05 table 25) */
253enum sdebug_z_type {254enum sdebug_z_type {
254 ZBC_ZONE_TYPE_CNV = 0x1,255 ZBC_ZTYPE_CNV = 0x1,
255 ZBC_ZONE_TYPE_SWR = 0x2,256 ZBC_ZTYPE_SWR = 0x2,
256 ZBC_ZONE_TYPE_SWP = 0x3,257 ZBC_ZTYPE_SWP = 0x3,
258 /* ZBC_ZTYPE_SOBR = 0x4, */
259 ZBC_ZTYPE_GAP = 0x5,
257};260};
258 261
259/* enumeration names taken from table 26, zbcr05 */262/* enumeration names taken from table 26, zbcr05 */
@@ -291,10 +294,12 @@ struct sdebug_dev_info { · 31 unmodified lines
291 294
292 /* For ZBC devices */295 /* For ZBC devices */
293 enum blk_zoned_model zmodel;296 enum blk_zoned_model zmodel;
297 unsigned int zcap;
294 unsigned int zsize;298 unsigned int zsize;
295 unsigned int zsize_shift;299 unsigned int zsize_shift;
296 unsigned int nr_zones;300 unsigned int nr_zones;
297 unsigned int nr_conv_zones;301 unsigned int nr_conv_zones;
302 unsigned int nr_seq_zones;
298 unsigned int nr_imp_open;303 unsigned int nr_imp_open;
299 unsigned int nr_exp_open;304 unsigned int nr_exp_open;
300 unsigned int nr_closed;305 unsigned int nr_closed;
@@ -829,6 +834,7 @@ static int dif_errors; · 528 unmodified lines
829 834
830/* ZBC global data */835/* ZBC global data */
831static bool sdeb_zbc_in_use; /* true for host-aware and host-managed disks */836static bool sdeb_zbc_in_use; /* true for host-aware and host-managed disks */
837static int sdeb_zbc_zone_cap_mb;
832static int sdeb_zbc_zone_size_mb;838static int sdeb_zbc_zone_size_mb;
833static int sdeb_zbc_max_open = DEF_ZBC_MAX_OPEN_ZONES;839static int sdeb_zbc_max_open = DEF_ZBC_MAX_OPEN_ZONES;
834static int sdeb_zbc_nr_conv = DEF_ZBC_NR_CONV_ZONES;840static int sdeb_zbc_nr_conv = DEF_ZBC_NR_CONV_ZONES;
@@ -1559,6 +1565,12 @@ static int inquiry_vpd_b6(struct sdebug_dev_info *devip, unsigned char *arr) · 724 unmodified lines
1559 put_unaligned_be32(devip->max_open, &arr[12]);1565 put_unaligned_be32(devip->max_open, &arr[12]);
1560 else1566 else
1561 put_unaligned_be32(0xffffffff, &arr[12]);1567 put_unaligned_be32(0xffffffff, &arr[12]);
1568 if (devip->zcap < devip->zsize) {
1569 arr[19] = ZBC_CONSTANT_ZONE_START_OFFSET;
1570 put_unaligned_be64(devip->zsize, &arr[20]);
1571 } else {
1572 arr[19] = 0;
1573 }
1562 return 0x3c;1574 return 0x3c;
1563}1575}
1564 1576
@@ -2711,12 +2723,38 @@ static inline bool sdebug_dev_is_zoned(struct sdebug_dev_info *devip) · 1146 unmodified lines
2711static struct sdeb_zone_state *zbc_zone(struct sdebug_dev_info *devip,2723static struct sdeb_zone_state *zbc_zone(struct sdebug_dev_info *devip,
2712 unsigned long long lba)2724 unsigned long long lba)
2713{2725{
2714 return &devip->zstate[lba >> devip->zsize_shift];2726 u32 zno = lba >> devip->zsize_shift;
2727 struct sdeb_zone_state *zsp;
2728
2729 if (devip->zcap == devip->zsize || zno < devip->nr_conv_zones)
2730 return &devip->zstate[zno];
2731
2732 /*
2733 * If the zone capacity is less than the zone size, adjust for gap
2734 * zones.
2735 */
2736 zno = 2 * zno - devip->nr_conv_zones;
2737 WARN_ONCE(zno >= devip->nr_zones, "%u > %u\n", zno, devip->nr_zones);
2738 zsp = &devip->zstate[zno];
2739 if (lba >= zsp->z_start + zsp->z_size)
2740 zsp++;
2741 WARN_ON_ONCE(lba >= zsp->z_start + zsp->z_size);
2742 return zsp;
2715}2743}
2716 2744
2717static inline bool zbc_zone_is_conv(struct sdeb_zone_state *zsp)2745static inline bool zbc_zone_is_conv(struct sdeb_zone_state *zsp)
2718{2746{
2719 return zsp->z_type == ZBC_ZONE_TYPE_CNV;2747 return zsp->z_type == ZBC_ZTYPE_CNV;
2748}
2749
2750static inline bool zbc_zone_is_gap(struct sdeb_zone_state *zsp)
2751{
2752 return zsp->z_type == ZBC_ZTYPE_GAP;
2753}
2754
2755static inline bool zbc_zone_is_seq(struct sdeb_zone_state *zsp)
2756{
2757 return !zbc_zone_is_conv(zsp) && !zbc_zone_is_gap(zsp);
2720}2758}
2721 2759
2722static void zbc_close_zone(struct sdebug_dev_info *devip,2760static void zbc_close_zone(struct sdebug_dev_info *devip,
@@ -2724,7 +2762,7 @@ static void zbc_close_zone(struct sdebug_dev_info *devip, · 1 unmodified line
2724{2762{
2725 enum sdebug_z_cond zc;2763 enum sdebug_z_cond zc;
2726 2764
2727 if (zbc_zone_is_conv(zsp))2765 if (!zbc_zone_is_seq(zsp))
2728 return;2766 return;
2729 2767
2730 zc = zsp->z_cond;2768 zc = zsp->z_cond;
@@ -2762,7 +2800,7 @@ static void zbc_open_zone(struct sdebug_dev_info *devip, · 31 unmodified lines
2762{2800{
2763 enum sdebug_z_cond zc;2801 enum sdebug_z_cond zc;
2764 2802
2765 if (zbc_zone_is_conv(zsp))2803 if (!zbc_zone_is_seq(zsp))
2766 return;2804 return;
2767 2805
2768 zc = zsp->z_cond;2806 zc = zsp->z_cond;
@@ -2794,10 +2832,10 @@ static void zbc_inc_wp(struct sdebug_dev_info *devip, · 25 unmodified lines
2794 struct sdeb_zone_state *zsp = zbc_zone(devip, lba);2832 struct sdeb_zone_state *zsp = zbc_zone(devip, lba);
2795 unsigned long long n, end, zend = zsp->z_start + zsp->z_size;2833 unsigned long long n, end, zend = zsp->z_start + zsp->z_size;
2796 2834
2797 if (zbc_zone_is_conv(zsp))2835 if (!zbc_zone_is_seq(zsp))
2798 return;2836 return;
2799 2837
2800 if (zsp->z_type == ZBC_ZONE_TYPE_SWR) {2838 if (zsp->z_type == ZBC_ZTYPE_SWR) {
2801 zsp->z_wp += num;2839 zsp->z_wp += num;
2802 if (zsp->z_wp >= zend)2840 if (zsp->z_wp >= zend)
2803 zsp->z_cond = ZC5_FULL;2841 zsp->z_cond = ZC5_FULL;
@@ -2842,9 +2880,7 @@ static int check_zbc_access_params(struct scsi_cmnd *scp, · 38 unmodified lines
2842 if (devip->zmodel == BLK_ZONED_HA)2880 if (devip->zmodel == BLK_ZONED_HA)
2843 return 0;2881 return 0;
2844 /* For host-managed, reads cannot cross zone types boundaries */2882 /* For host-managed, reads cannot cross zone types boundaries */
2845 if (zsp_end != zsp &&2883 if (zsp->z_type != zsp_end->z_type) {
2846 zbc_zone_is_conv(zsp) &&
2847 !zbc_zone_is_conv(zsp_end)) {
2848 mk_sense_buffer(scp, ILLEGAL_REQUEST,2884 mk_sense_buffer(scp, ILLEGAL_REQUEST,
2849 LBA_OUT_OF_RANGE,2885 LBA_OUT_OF_RANGE,
2850 READ_INVDATA_ASCQ);2886 READ_INVDATA_ASCQ);
@@ -2853,6 +2889,13 @@ static int check_zbc_access_params(struct scsi_cmnd *scp, · 2 unmodified lines
2853 return 0;2889 return 0;
2854 }2890 }
2855 2891
2892 /* Writing into a gap zone is not allowed */
2893 if (zbc_zone_is_gap(zsp)) {
2894 mk_sense_buffer(scp, ILLEGAL_REQUEST, LBA_OUT_OF_RANGE,
2895 ATTEMPT_ACCESS_GAP);
2896 return check_condition_result;
2897 }
2898
2856 /* No restrictions for writes within conventional zones */2899 /* No restrictions for writes within conventional zones */
2857 if (zbc_zone_is_conv(zsp)) {2900 if (zbc_zone_is_conv(zsp)) {
2858 if (!zbc_zone_is_conv(zsp_end)) {2901 if (!zbc_zone_is_conv(zsp_end)) {
@@ -2864,7 +2907,7 @@ static int check_zbc_access_params(struct scsi_cmnd *scp, · 5 unmodified lines
2864 return 0;2907 return 0;
2865 }2908 }
2866 2909
2867 if (zsp->z_type == ZBC_ZONE_TYPE_SWR) {2910 if (zsp->z_type == ZBC_ZTYPE_SWR) {
2868 /* Writes cannot cross sequential zone boundaries */2911 /* Writes cannot cross sequential zone boundaries */
2869 if (zsp_end != zsp) {2912 if (zsp_end != zsp) {
2870 mk_sense_buffer(scp, ILLEGAL_REQUEST,2913 mk_sense_buffer(scp, ILLEGAL_REQUEST,
@@ -4404,18 +4447,18 @@ cleanup: · 1533 unmodified lines
4404 4447
4405#define RZONES_DESC_HD 644448#define RZONES_DESC_HD 64
4406 4449
4407/* Report zones depending on start LBA nad reporting options */4450/* Report zones depending on start LBA and reporting options */
4408static int resp_report_zones(struct scsi_cmnd *scp,4451static int resp_report_zones(struct scsi_cmnd *scp,
4409 struct sdebug_dev_info *devip)4452 struct sdebug_dev_info *devip)
4410{4453{
4411 unsigned int i, max_zones, rep_max_zones, nrz = 0;4454 unsigned int rep_max_zones, nrz = 0;
4412 int ret = 0;4455 int ret = 0;
4413 u32 alloc_len, rep_opts, rep_len;4456 u32 alloc_len, rep_opts, rep_len;
4414 bool partial;4457 bool partial;
4415 u64 lba, zs_lba;4458 u64 lba, zs_lba;
4416 u8 *arr = NULL, *desc;4459 u8 *arr = NULL, *desc;
4417 u8 *cmd = scp->cmnd;4460 u8 *cmd = scp->cmnd;
4418 struct sdeb_zone_state *zsp;4461 struct sdeb_zone_state *zsp = NULL;
4419 struct sdeb_store_info *sip = devip2sip(devip, false);4462 struct sdeb_store_info *sip = devip2sip(devip, false);
4420 4463
4421 if (!sdebug_dev_is_zoned(devip)) {4464 if (!sdebug_dev_is_zoned(devip)) {
@@ -4434,9 +4477,7 @@ static int resp_report_zones(struct scsi_cmnd *scp, · 12 unmodified lines
4434 return check_condition_result;4477 return check_condition_result;
4435 }4478 }
4436 4479
4437 max_zones = devip->nr_zones - (zs_lba >> devip->zsize_shift);4480 rep_max_zones = (alloc_len - 64) >> ilog2(RZONES_DESC_HD);
4438 rep_max_zones = min((alloc_len - 64) >> ilog2(RZONES_DESC_HD),
4439 max_zones);
4440 4481
4441 arr = kzalloc(alloc_len, GFP_ATOMIC);4482 arr = kzalloc(alloc_len, GFP_ATOMIC);
4442 if (!arr) {4483 if (!arr) {
@@ -4448,9 +4489,9 @@ static int resp_report_zones(struct scsi_cmnd *scp, · 5 unmodified lines
4448 sdeb_read_lock(sip);4489 sdeb_read_lock(sip);
4449 4490
4450 desc = arr + 64;4491 desc = arr + 64;
4451 for (i = 0; i < max_zones; i++) {4492 for (lba = zs_lba; lba < sdebug_capacity;
4452 lba = zs_lba + devip->zsize * i;4493 lba = zsp->z_start + zsp->z_size) {
4453 if (lba > sdebug_capacity)4494 if (WARN_ONCE(zbc_zone(devip, lba) == zsp, "lba = %llu\n", lba))
4454 break;4495 break;
4455 zsp = zbc_zone(devip, lba);4496 zsp = zbc_zone(devip, lba);
4456 switch (rep_opts) {4497 switch (rep_opts) {
@@ -4495,9 +4536,14 @@ static int resp_report_zones(struct scsi_cmnd *scp, · 38 unmodified lines
4495 if (!zsp->z_non_seq_resource)4536 if (!zsp->z_non_seq_resource)
4496 continue;4537 continue;
4497 break;4538 break;
4539 case 0x3e:
4540 /* All zones except gap zones. */
4541 if (zbc_zone_is_gap(zsp))
4542 continue;
4543 break;
4498 case 0x3f:4544 case 0x3f:
4499 /* Not write pointer (conventional) zones */4545 /* Not write pointer (conventional) zones */
4500 if (!zbc_zone_is_conv(zsp))4546 if (zbc_zone_is_seq(zsp))
4501 continue;4547 continue;
4502 break;4548 break;
4503 default:4549 default:
@@ -4526,8 +4572,13 @@ static int resp_report_zones(struct scsi_cmnd *scp, · 22 unmodified lines
4526 }4572 }
4527 4573
4528 /* Report header */4574 /* Report header */
4575 /* Zone list length. */
4529 put_unaligned_be32(nrz * RZONES_DESC_HD, arr + 0);4576 put_unaligned_be32(nrz * RZONES_DESC_HD, arr + 0);
4577 /* Maximum LBA */
4530 put_unaligned_be64(sdebug_capacity - 1, arr + 8);4578 put_unaligned_be64(sdebug_capacity - 1, arr + 8);
4579 /* Zone starting LBA granularity. */
4580 if (devip->zcap < devip->zsize)
4581 put_unaligned_be64(devip->zsize, arr + 16);
4531 4582
4532 rep_len = (unsigned long)desc - (unsigned long)arr;4583 rep_len = (unsigned long)desc - (unsigned long)arr;
4533 ret = fill_from_dev_buffer(scp, arr, min_t(u32, alloc_len, rep_len));4584 ret = fill_from_dev_buffer(scp, arr, min_t(u32, alloc_len, rep_len));
@@ -4752,7 +4803,7 @@ static void zbc_rwp_zone(struct sdebug_dev_info *devip, · 218 unmodified lines
4752 enum sdebug_z_cond zc;4803 enum sdebug_z_cond zc;
4753 struct sdeb_store_info *sip = devip2sip(devip, false);4804 struct sdeb_store_info *sip = devip2sip(devip, false);
4754 4805
4755 if (zbc_zone_is_conv(zsp))4806 if (!zbc_zone_is_seq(zsp))
4756 return;4807 return;
4757 4808
4758 zc = zsp->z_cond;4809 zc = zsp->z_cond;
@@ -4942,6 +4993,7 @@ static int sdebug_device_create_zones(struct sdebug_dev_info *devip) · 183 unmodified lines
4942{4993{
4943 struct sdeb_zone_state *zsp;4994 struct sdeb_zone_state *zsp;
4944 sector_t capacity = get_sdebug_capacity();4995 sector_t capacity = get_sdebug_capacity();
4996 sector_t conv_capacity;
4945 sector_t zstart = 0;4997 sector_t zstart = 0;
4946 unsigned int i;4998 unsigned int i;
4947 4999
@@ -4976,11 +5028,30 @@ static int sdebug_device_create_zones(struct sdebug_dev_info *devip) · 28 unmodified lines
4976 devip->zsize_shift = ilog2(devip->zsize);5028 devip->zsize_shift = ilog2(devip->zsize);
4977 devip->nr_zones = (capacity + devip->zsize - 1) >> devip->zsize_shift;5029 devip->nr_zones = (capacity + devip->zsize - 1) >> devip->zsize_shift;
4978 5030
4979 if (sdeb_zbc_nr_conv >= devip->nr_zones) {5031 if (sdeb_zbc_zone_cap_mb == 0) {
5032 devip->zcap = devip->zsize;
5033 } else {
5034 devip->zcap = (sdeb_zbc_zone_cap_mb * SZ_1M) >>
5035 ilog2(sdebug_sector_size);
5036 if (devip->zcap > devip->zsize) {
5037 pr_err("Zone capacity too large\n");
5038 return -EINVAL;
5039 }
5040 }
5041
5042 conv_capacity = (sector_t)sdeb_zbc_nr_conv << devip->zsize_shift;
5043 if (conv_capacity >= capacity) {
4980 pr_err("Number of conventional zones too large\n");5044 pr_err("Number of conventional zones too large\n");
4981 return -EINVAL;5045 return -EINVAL;
4982 }5046 }
4983 devip->nr_conv_zones = sdeb_zbc_nr_conv;5047 devip->nr_conv_zones = sdeb_zbc_nr_conv;
5048 devip->nr_seq_zones = ALIGN(capacity - conv_capacity, devip->zsize) >>
5049 devip->zsize_shift;
5050 devip->nr_zones = devip->nr_conv_zones + devip->nr_seq_zones;
5051
5052 /* Add gap zones if zone capacity is smaller than the zone size */
5053 if (devip->zcap < devip->zsize)
5054 devip->nr_zones += devip->nr_seq_zones;
4984 5055
4985 if (devip->zmodel == BLK_ZONED_HM) {5056 if (devip->zmodel == BLK_ZONED_HM) {
4986 /* zbc_max_open_zones can be 0, meaning "not reported" */5057 /* zbc_max_open_zones can be 0, meaning "not reported" */
@@ -5001,23 +5072,29 @@ static int sdebug_device_create_zones(struct sdebug_dev_info *devip) · 14 unmodified lines
5001 zsp->z_start = zstart;5072 zsp->z_start = zstart;
5002 5073
5003 if (i < devip->nr_conv_zones) {5074 if (i < devip->nr_conv_zones) {
5004 zsp->z_type = ZBC_ZONE_TYPE_CNV;5075 zsp->z_type = ZBC_ZTYPE_CNV;
5005 zsp->z_cond = ZBC_NOT_WRITE_POINTER;5076 zsp->z_cond = ZBC_NOT_WRITE_POINTER;
5006 zsp->z_wp = (sector_t)-1;5077 zsp->z_wp = (sector_t)-1;
5007 } else {5078 zsp->z_size =
5079 min_t(u64, devip->zsize, capacity - zstart);
5080 } else if ((zstart & (devip->zsize - 1)) == 0) {
5008 if (devip->zmodel == BLK_ZONED_HM)5081 if (devip->zmodel == BLK_ZONED_HM)
5009 zsp->z_type = ZBC_ZONE_TYPE_SWR;5082 zsp->z_type = ZBC_ZTYPE_SWR;
5010 else5083 else
5011 zsp->z_type = ZBC_ZONE_TYPE_SWP;5084 zsp->z_type = ZBC_ZTYPE_SWP;
5012 zsp->z_cond = ZC1_EMPTY;5085 zsp->z_cond = ZC1_EMPTY;
5013 zsp->z_wp = zsp->z_start;5086 zsp->z_wp = zsp->z_start;
5087 zsp->z_size =
5088 min_t(u64, devip->zcap, capacity - zstart);
5089 } else {
5090 zsp->z_type = ZBC_ZTYPE_GAP;
5091 zsp->z_cond = ZBC_NOT_WRITE_POINTER;
5092 zsp->z_wp = (sector_t)-1;
5093 zsp->z_size = min_t(u64, devip->zsize - devip->zcap,
5094 capacity - zstart);
5014 }5095 }
5015 5096
5016 if (zsp->z_start + devip->zsize < capacity)5097 WARN_ON_ONCE((int)zsp->z_size <= 0);
5017 zsp->z_size = devip->zsize;
5018 else
5019 zsp->z_size = capacity - zsp->z_start;
5020
5021 zstart += zsp->z_size;5098 zstart += zsp->z_size;
5022 }5099 }
5023 5100
@@ -5779,6 +5856,7 @@ module_param_named(wp, sdebug_wp, bool, S_IRUGO | S_IWUSR); · 755 unmodified lines
5779module_param_named(write_same_length, sdebug_write_same_length, int,5856module_param_named(write_same_length, sdebug_write_same_length, int,
5780 S_IRUGO | S_IWUSR);5857 S_IRUGO | S_IWUSR);
5781module_param_named(zbc, sdeb_zbc_model_s, charp, S_IRUGO);5858module_param_named(zbc, sdeb_zbc_model_s, charp, S_IRUGO);
5859module_param_named(zone_cap_mb, sdeb_zbc_zone_cap_mb, int, S_IRUGO);
5782module_param_named(zone_max_open, sdeb_zbc_max_open, int, S_IRUGO);5860module_param_named(zone_max_open, sdeb_zbc_max_open, int, S_IRUGO);
5783module_param_named(zone_nr_conv, sdeb_zbc_nr_conv, int, S_IRUGO);5861module_param_named(zone_nr_conv, sdeb_zbc_nr_conv, int, S_IRUGO);
5784module_param_named(zone_size_mb, sdeb_zbc_zone_size_mb, int, S_IRUGO);5862module_param_named(zone_size_mb, sdeb_zbc_zone_size_mb, int, S_IRUGO);
@@ -5850,6 +5928,7 @@ MODULE_PARM_DESC(vpd_use_hostno, "0 -> dev ids ignore hostno (def=1 -> unique de · 65 unmodified lines
5850MODULE_PARM_DESC(wp, "Write Protect (def=0)");5928MODULE_PARM_DESC(wp, "Write Protect (def=0)");
5851MODULE_PARM_DESC(write_same_length, "Maximum blocks per WRITE SAME cmd (def=0xffff)");5929MODULE_PARM_DESC(write_same_length, "Maximum blocks per WRITE SAME cmd (def=0xffff)");
5852MODULE_PARM_DESC(zbc, "'none' [0]; 'aware' [1]; 'managed' [2] (def=0). Can have 'host-' prefix");5930MODULE_PARM_DESC(zbc, "'none' [0]; 'aware' [1]; 'managed' [2] (def=0). Can have 'host-' prefix");
5931MODULE_PARM_DESC(zone_cap_mb, "Zone capacity in MiB (def=zone size)");
5853MODULE_PARM_DESC(zone_max_open, "Maximum number of open zones; [0] for no limit (def=auto)");5932MODULE_PARM_DESC(zone_max_open, "Maximum number of open zones; [0] for no limit (def=auto)");
5854MODULE_PARM_DESC(zone_nr_conv, "Number of conventional zones (def=1)");5933MODULE_PARM_DESC(zone_nr_conv, "Number of conventional zones (def=1)");
5855MODULE_PARM_DESC(zone_size_mb, "Zone size in MiB (def=auto)");5934MODULE_PARM_DESC(zone_size_mb, "Zone size in MiB (def=auto)");
drivers/scsi/scsi_lib.c+1−1
@@ -1977,7 +1977,7 @@ int scsi_mq_setup_tags(struct Scsi_Host *shost) · 1976 unmodified lines
1977 tag_set->nr_maps = shost->nr_maps ? : 1;1977 tag_set->nr_maps = shost->nr_maps ? : 1;
1978 tag_set->queue_depth = shost->can_queue;1978 tag_set->queue_depth = shost->can_queue;
1979 tag_set->cmd_size = cmd_size;1979 tag_set->cmd_size = cmd_size;
1980 tag_set->numa_node = NUMA_NO_NODE;1980 tag_set->numa_node = dev_to_node(shost->dma_dev);
1981 tag_set->flags = BLK_MQ_F_SHOULD_MERGE;1981 tag_set->flags = BLK_MQ_F_SHOULD_MERGE;
1982 tag_set->flags |=1982 tag_set->flags |=
1983 BLK_ALLOC_POLICY_TO_MQ_FLAG(shost->hostt->tag_alloc_policy);1983 BLK_ALLOC_POLICY_TO_MQ_FLAG(shost->hostt->tag_alloc_policy);
drivers/scsi/scsi_scan.c+11−1
@@ -733,7 +733,17 @@ static int scsi_probe_lun(struct scsi_device *sdev, unsigned char *inq_result, · 732 unmodified lines
733 if (pass == 1) {733 if (pass == 1) {
734 if (BLIST_INQUIRY_36 & *bflags)734 if (BLIST_INQUIRY_36 & *bflags)
735 next_inquiry_len = 36;735 next_inquiry_len = 36;
736 else if (sdev->inquiry_len)736 /*
737 * LLD specified a maximum sdev->inquiry_len
738 * but device claims it has more data. Capping
739 * the length only makes sense for legacy
740 * devices. If a device supports SPC-4 (2014)
741 * or newer, assume that it is safe to ask for
742 * as much as the device says it supports.
743 */
744 else if (sdev->inquiry_len &&
745 response_len > sdev->inquiry_len &&
746 (inq_result[2] & 0x7) < 6) /* SPC-4 */
737 next_inquiry_len = sdev->inquiry_len;747 next_inquiry_len = sdev->inquiry_len;
738 else748 else
739 next_inquiry_len = response_len;749 next_inquiry_len = response_len;
drivers/scsi/scsi_sysfs.c+28−0
@@ -448,6 +448,7 @@ static void scsi_device_dev_release_usercontext(struct work_struct *work) · 447 unmodified lines
448 struct list_head *this, *tmp;448 struct list_head *this, *tmp;
449 struct scsi_vpd *vpd_pg80 = NULL, *vpd_pg83 = NULL;449 struct scsi_vpd *vpd_pg80 = NULL, *vpd_pg83 = NULL;
450 struct scsi_vpd *vpd_pg0 = NULL, *vpd_pg89 = NULL;450 struct scsi_vpd *vpd_pg0 = NULL, *vpd_pg89 = NULL;
451 struct scsi_vpd *vpd_pgb0 = NULL, *vpd_pgb1 = NULL, *vpd_pgb2 = NULL;
451 unsigned long flags;452 unsigned long flags;
452 struct module *mod;453 struct module *mod;
453 454
@@ -490,6 +491,12 @@ static void scsi_device_dev_release_usercontext(struct work_struct *work) · 36 unmodified lines
490 lockdep_is_held(&sdev->inquiry_mutex));491 lockdep_is_held(&sdev->inquiry_mutex));
491 vpd_pg89 = rcu_replace_pointer(sdev->vpd_pg89, vpd_pg89,492 vpd_pg89 = rcu_replace_pointer(sdev->vpd_pg89, vpd_pg89,
492 lockdep_is_held(&sdev->inquiry_mutex));493 lockdep_is_held(&sdev->inquiry_mutex));
494 vpd_pgb0 = rcu_replace_pointer(sdev->vpd_pgb0, vpd_pgb0,
495 lockdep_is_held(&sdev->inquiry_mutex));
496 vpd_pgb1 = rcu_replace_pointer(sdev->vpd_pgb1, vpd_pgb1,
497 lockdep_is_held(&sdev->inquiry_mutex));
498 vpd_pgb2 = rcu_replace_pointer(sdev->vpd_pgb2, vpd_pgb2,
499 lockdep_is_held(&sdev->inquiry_mutex));
493 mutex_unlock(&sdev->inquiry_mutex);500 mutex_unlock(&sdev->inquiry_mutex);
494 501
495 if (vpd_pg0)502 if (vpd_pg0)
@@ -500,6 +507,12 @@ static void scsi_device_dev_release_usercontext(struct work_struct *work) · 4 unmodified lines
500 kfree_rcu(vpd_pg80, rcu);507 kfree_rcu(vpd_pg80, rcu);
501 if (vpd_pg89)508 if (vpd_pg89)
502 kfree_rcu(vpd_pg89, rcu);509 kfree_rcu(vpd_pg89, rcu);
510 if (vpd_pgb0)
511 kfree_rcu(vpd_pgb0, rcu);
512 if (vpd_pgb1)
513 kfree_rcu(vpd_pgb1, rcu);
514 if (vpd_pgb2)
515 kfree_rcu(vpd_pgb2, rcu);
503 kfree(sdev->inquiry);516 kfree(sdev->inquiry);
504 kfree(sdev);517 kfree(sdev);
505 518
@@ -913,6 +926,9 @@ static struct bin_attribute dev_attr_vpd_##_page = { \ · 407 unmodified lines
913sdev_vpd_pg_attr(pg83);926sdev_vpd_pg_attr(pg83);
914sdev_vpd_pg_attr(pg80);927sdev_vpd_pg_attr(pg80);
915sdev_vpd_pg_attr(pg89);928sdev_vpd_pg_attr(pg89);
929sdev_vpd_pg_attr(pgb0);
930sdev_vpd_pg_attr(pgb1);
931sdev_vpd_pg_attr(pgb2);
916sdev_vpd_pg_attr(pg0);932sdev_vpd_pg_attr(pg0);
917 933
918static ssize_t show_inquiry(struct file *filep, struct kobject *kobj,934static ssize_t show_inquiry(struct file *filep, struct kobject *kobj,
@@ -1250,6 +1266,15 @@ static umode_t scsi_sdev_bin_attr_is_visible(struct kobject *kobj, · 331 unmodified lines
1250 if (attr == &dev_attr_vpd_pg89 && !sdev->vpd_pg89)1266 if (attr == &dev_attr_vpd_pg89 && !sdev->vpd_pg89)
1251 return 0;1267 return 0;
1252 1268
1269 if (attr == &dev_attr_vpd_pgb0 && !sdev->vpd_pgb0)
1270 return 0;
1271
1272 if (attr == &dev_attr_vpd_pgb1 && !sdev->vpd_pgb1)
1273 return 0;
1274
1275 if (attr == &dev_attr_vpd_pgb2 && !sdev->vpd_pgb2)
1276 return 0;
1277
1253 return S_IRUGO;1278 return S_IRUGO;
1254}1279}
1255 1280
@@ -1296,6 +1321,9 @@ static struct bin_attribute *scsi_sdev_bin_attrs[] = { · 40 unmodified lines
1296 &dev_attr_vpd_pg83,1321 &dev_attr_vpd_pg83,
1297 &dev_attr_vpd_pg80,1322 &dev_attr_vpd_pg80,
1298 &dev_attr_vpd_pg89,1323 &dev_attr_vpd_pg89,
1324 &dev_attr_vpd_pgb0,
1325 &dev_attr_vpd_pgb1,
1326 &dev_attr_vpd_pgb2,
1299 &dev_attr_inquiry,1327 &dev_attr_inquiry,
1300 NULL1328 NULL
1301};1329};
drivers/scsi/sd.c+118−75
@@ -2174,40 +2174,48 @@ static int sd_read_protection_type(struct scsi_disk *sdkp, unsigned char *buffer · 2173 unmodified lines
2174{2174{
2175 struct scsi_device *sdp = sdkp->device;2175 struct scsi_device *sdp = sdkp->device;
2176 u8 type;2176 u8 type;
2177 int ret = 0;
2178 2177
2179 if (scsi_device_protection(sdp) == 0 || (buffer[12] & 1) == 0) {2178 if (scsi_device_protection(sdp) == 0 || (buffer[12] & 1) == 0) {
2180 sdkp->protection_type = 0;2179 sdkp->protection_type = 0;
2181 return ret;2180 return 0;
2182 }2181 }
2183 2182
2184 type = ((buffer[12] >> 1) & 7) + 1; /* P_TYPE 0 = Type 1 */2183 type = ((buffer[12] >> 1) & 7) + 1; /* P_TYPE 0 = Type 1 */
2185 2184
2186 if (type > T10_PI_TYPE3_PROTECTION)2185 if (type > T10_PI_TYPE3_PROTECTION) {
2187 ret = -ENODEV;2186 sd_printk(KERN_ERR, sdkp, "formatted with unsupported" \
2188 else if (scsi_host_dif_capable(sdp->host, type))2187 " protection type %u. Disabling disk!\n",
2189 ret = 1;2188 type);
2190 2189 sdkp->protection_type = 0;
2191 if (sdkp->first_scan || type != sdkp->protection_type)2190 return -ENODEV;
2192 switch (ret) {2191 }
2193 case -ENODEV:
2194 sd_printk(KERN_ERR, sdkp, "formatted with unsupported" \
2195 " protection type %u. Disabling disk!\n",
2196 type);
2197 break;
2198 case 1:
2199 sd_printk(KERN_NOTICE, sdkp,
2200 "Enabling DIF Type %u protection\n", type);
2201 break;
2202 case 0:
2203 sd_printk(KERN_NOTICE, sdkp,
2204 "Disabling DIF Type %u protection\n", type);
2205 break;
2206 }
2207 2192
2208 sdkp->protection_type = type;2193 sdkp->protection_type = type;
2209 2194
2210 return ret;2195 return 0;
2196}
2197
2198static void sd_config_protection(struct scsi_disk *sdkp)
2199{
2200 struct scsi_device *sdp = sdkp->device;
2201
2202 if (!sdkp->first_scan)
2203 return;
2204
2205 sd_dif_config_host(sdkp);
2206
2207 if (!sdkp->protection_type)
2208 return;
2209
2210 if (!scsi_host_dif_capable(sdp->host, sdkp->protection_type)) {
2211 sd_printk(KERN_NOTICE, sdkp,
2212 "Disabling DIF Type %u protection\n",
2213 sdkp->protection_type);
2214 sdkp->protection_type = 0;
2215 }
2216
2217 sd_printk(KERN_NOTICE, sdkp, "Enabling DIF Type %u protection\n",
2218 sdkp->protection_type);
2211}2219}
2212 2220
2213static void read_capacity_error(struct scsi_disk *sdkp, struct scsi_device *sdp,2221static void read_capacity_error(struct scsi_disk *sdkp, struct scsi_device *sdp,
@@ -2841,40 +2849,37 @@ static void sd_read_app_tag_own(struct scsi_disk *sdkp, unsigned char *buffer) · 627 unmodified lines
2841 */2849 */
2842static void sd_read_block_limits(struct scsi_disk *sdkp)2850static void sd_read_block_limits(struct scsi_disk *sdkp)
2843{2851{
2844 unsigned int sector_sz = sdkp->device->sector_size;2852 struct scsi_vpd *vpd;
2845 const int vpd_len = 64;
2846 unsigned char *buffer = kmalloc(vpd_len, GFP_KERNEL);
2847 2853
2848 if (!buffer ||2854 rcu_read_lock();
2849 /* Block Limits VPD */
2850 scsi_get_vpd_page(sdkp->device, 0xb0, buffer, vpd_len))
2851 goto out;
2852 2855
2853 blk_queue_io_min(sdkp->disk->queue,2856 vpd = rcu_dereference(sdkp->device->vpd_pgb0);
2854 get_unaligned_be16(&buffer[6]) * sector_sz);2857 if (!vpd || vpd->len < 16)
2858 goto out;
2855 2859
2856 sdkp->max_xfer_blocks = get_unaligned_be32(&buffer[8]);2860 sdkp->min_xfer_blocks = get_unaligned_be16(&vpd->data[6]);
2857 sdkp->opt_xfer_blocks = get_unaligned_be32(&buffer[12]);2861 sdkp->max_xfer_blocks = get_unaligned_be32(&vpd->data[8]);
2862 sdkp->opt_xfer_blocks = get_unaligned_be32(&vpd->data[12]);
2858 2863
2859 if (buffer[3] == 0x3c) {2864 if (vpd->len >= 64) {
2860 unsigned int lba_count, desc_count;2865 unsigned int lba_count, desc_count;
2861 2866
2862 sdkp->max_ws_blocks = (u32)get_unaligned_be64(&buffer[36]);2867 sdkp->max_ws_blocks = (u32)get_unaligned_be64(&vpd->data[36]);
2863 2868
2864 if (!sdkp->lbpme)2869 if (!sdkp->lbpme)
2865 goto out;2870 goto out;
2866 2871
2867 lba_count = get_unaligned_be32(&buffer[20]);2872 lba_count = get_unaligned_be32(&vpd->data[20]);
2868 desc_count = get_unaligned_be32(&buffer[24]);2873 desc_count = get_unaligned_be32(&vpd->data[24]);
2869 2874
2870 if (lba_count && desc_count)2875 if (lba_count && desc_count)
2871 sdkp->max_unmap_blocks = lba_count;2876 sdkp->max_unmap_blocks = lba_count;
2872 2877
2873 sdkp->unmap_granularity = get_unaligned_be32(&buffer[28]);2878 sdkp->unmap_granularity = get_unaligned_be32(&vpd->data[28]);
2874 2879
2875 if (buffer[32] & 0x80)2880 if (vpd->data[32] & 0x80)
2876 sdkp->unmap_alignment =2881 sdkp->unmap_alignment =
2877 get_unaligned_be32(&buffer[32]) & ~(1 << 31);2882 get_unaligned_be32(&vpd->data[32]) & ~(1 << 31);
2878 2883
2879 if (!sdkp->lbpvpd) { /* LBP VPD page not provided */2884 if (!sdkp->lbpvpd) { /* LBP VPD page not provided */
2880 2885
@@ -2896,7 +2901,7 @@ static void sd_read_block_limits(struct scsi_disk *sdkp) · 15 unmodified lines
2896 }2901 }
2897 2902
2898 out:2903 out:
2899 kfree(buffer);2904 rcu_read_unlock();
2900}2905}
2901 2906
2902/**2907/**
@@ -2906,18 +2911,21 @@ static void sd_read_block_limits(struct scsi_disk *sdkp) · 3 unmodified lines
2906static void sd_read_block_characteristics(struct scsi_disk *sdkp)2911static void sd_read_block_characteristics(struct scsi_disk *sdkp)
2907{2912{
2908 struct request_queue *q = sdkp->disk->queue;2913 struct request_queue *q = sdkp->disk->queue;
2909 unsigned char *buffer;2914 struct scsi_vpd *vpd;
2910 u16 rot;2915 u16 rot;
2911 const int vpd_len = 64;2916 u8 zoned;
2912 2917
2913 buffer = kmalloc(vpd_len, GFP_KERNEL);2918 rcu_read_lock();
2919 vpd = rcu_dereference(sdkp->device->vpd_pgb1);
2914 2920
2915 if (!buffer ||2921 if (!vpd || vpd->len < 8) {
2916 /* Block Device Characteristics VPD */2922 rcu_read_unlock();
2917 scsi_get_vpd_page(sdkp->device, 0xb1, buffer, vpd_len))2923 return;
2918 goto out;2924 }
2919 2925
2920 rot = get_unaligned_be16(&buffer[4]);2926 rot = get_unaligned_be16(&vpd->data[4]);
2927 zoned = (vpd->data[8] >> 4) & 3;
2928 rcu_read_unlock();
2921 2929
2922 if (rot == 1) {2930 if (rot == 1) {
2923 blk_queue_flag_set(QUEUE_FLAG_NONROT, q);2931 blk_queue_flag_set(QUEUE_FLAG_NONROT, q);
@@ -2928,7 +2936,7 @@ static void sd_read_block_characteristics(struct scsi_disk *sdkp) · 4 unmodified lines
2928 /* Host-managed */2936 /* Host-managed */
2929 blk_queue_set_zoned(sdkp->disk, BLK_ZONED_HM);2937 blk_queue_set_zoned(sdkp->disk, BLK_ZONED_HM);
2930 } else {2938 } else {
2931 sdkp->zoned = (buffer[8] >> 4) & 3;2939 sdkp->zoned = zoned;
2932 if (sdkp->zoned == 1) {2940 if (sdkp->zoned == 1) {
2933 /* Host-aware */2941 /* Host-aware */
2934 blk_queue_set_zoned(sdkp->disk, BLK_ZONED_HA);2942 blk_queue_set_zoned(sdkp->disk, BLK_ZONED_HA);
@@ -2939,7 +2947,7 @@ static void sd_read_block_characteristics(struct scsi_disk *sdkp) · 4 unmodified lines
2939 }2947 }
2940 2948
2941 if (!sdkp->first_scan)2949 if (!sdkp->first_scan)
2942 goto out;2950 return;
2943 2951
2944 if (blk_queue_is_zoned(q)) {2952 if (blk_queue_is_zoned(q)) {
2945 sd_printk(KERN_NOTICE, sdkp, "Host-%s zoned block device\n",2953 sd_printk(KERN_NOTICE, sdkp, "Host-%s zoned block device\n",
@@ -2952,9 +2960,6 @@ static void sd_read_block_characteristics(struct scsi_disk *sdkp) · 6 unmodified lines
2952 sd_printk(KERN_NOTICE, sdkp,2960 sd_printk(KERN_NOTICE, sdkp,
2953 "Drive-managed SMR disk\n");2961 "Drive-managed SMR disk\n");
2954 }2962 }
2955
2956 out:
2957 kfree(buffer);
2958}2963}
2959 2964
2960/**2965/**
@@ -2963,24 +2968,24 @@ static void sd_read_block_characteristics(struct scsi_disk *sdkp) · 2 unmodified lines
2963 */2968 */
2964static void sd_read_block_provisioning(struct scsi_disk *sdkp)2969static void sd_read_block_provisioning(struct scsi_disk *sdkp)
2965{2970{
2966 unsigned char *buffer;2971 struct scsi_vpd *vpd;
2967 const int vpd_len = 8;
2968 2972
2969 if (sdkp->lbpme == 0)2973 if (sdkp->lbpme == 0)
2970 return;2974 return;
2971 2975
2972 buffer = kmalloc(vpd_len, GFP_KERNEL);2976 rcu_read_lock();
2977 vpd = rcu_dereference(sdkp->device->vpd_pgb2);
2973 2978
2974 if (!buffer || scsi_get_vpd_page(sdkp->device, 0xb2, buffer, vpd_len))2979 if (!vpd || vpd->len < 8) {
2975 goto out;2980 rcu_read_unlock();
2981 return;
2982 }
2976 2983
2977 sdkp->lbpvpd = 1;2984 sdkp->lbpvpd = 1;
2978 sdkp->lbpu = (buffer[5] >> 7) & 1; /* UNMAP */2985 sdkp->lbpu = (vpd->data[5] >> 7) & 1; /* UNMAP */
2979 sdkp->lbpws = (buffer[5] >> 6) & 1; /* WRITE SAME(16) with UNMAP */2986 sdkp->lbpws = (vpd->data[5] >> 6) & 1; /* WRITE SAME(16) w/ UNMAP */
2980 sdkp->lbpws10 = (buffer[5] >> 5) & 1; /* WRITE SAME(10) with UNMAP */2987 sdkp->lbpws10 = (vpd->data[5] >> 5) & 1; /* WRITE SAME(10) w/ UNMAP */
2981 2988 rcu_read_unlock();
2982 out:
2983 kfree(buffer);
2984}2989}
2985 2990
2986static void sd_read_write_same(struct scsi_disk *sdkp, unsigned char *buffer)2991static void sd_read_write_same(struct scsi_disk *sdkp, unsigned char *buffer)
@@ -2994,8 +2999,7 @@ static void sd_read_write_same(struct scsi_disk *sdkp, unsigned char *buffer) · 7 unmodified lines
2994 }2999 }
2995 3000
2996 if (scsi_report_opcode(sdev, buffer, SD_BUF_SIZE, INQUIRY) < 0) {3001 if (scsi_report_opcode(sdev, buffer, SD_BUF_SIZE, INQUIRY) < 0) {
2997 /* too large values might cause issues with arcmsr */3002 struct scsi_vpd *vpd;
2998 int vpd_buf_len = 64;
2999 3003
3000 sdev->no_report_opcodes = 1;3004 sdev->no_report_opcodes = 1;
3001 3005
@@ -3003,8 +3007,11 @@ static void sd_read_write_same(struct scsi_disk *sdkp, unsigned char *buffer) · 1 unmodified line
3003 * CODES is unsupported and the device has an ATA3007 * CODES is unsupported and the device has an ATA
3004 * Information VPD page (SAT).3008 * Information VPD page (SAT).
3005 */3009 */
3006 if (!scsi_get_vpd_page(sdev, 0x89, buffer, vpd_buf_len))3010 rcu_read_lock();
3011 vpd = rcu_dereference(sdev->vpd_pg89);
3012 if (vpd)
3007 sdev->no_write_same = 1;3013 sdev->no_write_same = 1;
3014 rcu_read_unlock();
3008 }3015 }
3009 3016
3010 if (scsi_report_opcode(sdev, buffer, SD_BUF_SIZE, WRITE_SAME_16) == 1)3017 if (scsi_report_opcode(sdev, buffer, SD_BUF_SIZE, WRITE_SAME_16) == 1)
@@ -3108,6 +3115,29 @@ out: · 97 unmodified lines
3108 kfree(buffer);3115 kfree(buffer);
3109}3116}
3110 3117
3118static bool sd_validate_min_xfer_size(struct scsi_disk *sdkp)
3119{
3120 struct scsi_device *sdp = sdkp->device;
3121 unsigned int min_xfer_bytes =
3122 logical_to_bytes(sdp, sdkp->min_xfer_blocks);
3123
3124 if (sdkp->min_xfer_blocks == 0)
3125 return false;
3126
3127 if (min_xfer_bytes & (sdkp->physical_block_size - 1)) {
3128 sd_first_printk(KERN_WARNING, sdkp,
3129 "Preferred minimum I/O size %u bytes not a " \
3130 "multiple of physical block size (%u bytes)\n",
3131 min_xfer_bytes, sdkp->physical_block_size);
3132 sdkp->min_xfer_blocks = 0;
3133 return false;
3134 }
3135
3136 sd_first_printk(KERN_INFO, sdkp, "Preferred minimum I/O size %u bytes\n",
3137 min_xfer_bytes);
3138 return true;
3139}
3140
3111/*3141/*
3112 * Determine the device's preferred I/O size for reads and writes3142 * Determine the device's preferred I/O size for reads and writes
3113 * unless the reported value is unreasonably small, large, not a3143 * unless the reported value is unreasonably small, large, not a
@@ -3119,6 +3149,8 @@ static bool sd_validate_opt_xfer_size(struct scsi_disk *sdkp, · 5 unmodified lines
3119 struct scsi_device *sdp = sdkp->device;3149 struct scsi_device *sdp = sdkp->device;
3120 unsigned int opt_xfer_bytes =3150 unsigned int opt_xfer_bytes =
3121 logical_to_bytes(sdp, sdkp->opt_xfer_blocks);3151 logical_to_bytes(sdp, sdkp->opt_xfer_blocks);
3152 unsigned int min_xfer_bytes =
3153 logical_to_bytes(sdp, sdkp->min_xfer_blocks);
3122 3154
3123 if (sdkp->opt_xfer_blocks == 0)3155 if (sdkp->opt_xfer_blocks == 0)
3124 return false;3156 return false;
@@ -3147,6 +3179,15 @@ static bool sd_validate_opt_xfer_size(struct scsi_disk *sdkp, · 22 unmodified lines
3147 return false;3179 return false;
3148 }3180 }
3149 3181
3182 if (min_xfer_bytes && opt_xfer_bytes % min_xfer_bytes) {
3183 sd_first_printk(KERN_WARNING, sdkp,
3184 "Optimal transfer size %u bytes not a " \
3185 "multiple of preferred minimum block " \
3186 "size (%u bytes)\n",
3187 opt_xfer_bytes, min_xfer_bytes);
3188 return false;
3189 }
3190
3150 if (opt_xfer_bytes & (sdkp->physical_block_size - 1)) {3191 if (opt_xfer_bytes & (sdkp->physical_block_size - 1)) {
3151 sd_first_printk(KERN_WARNING, sdkp,3192 sd_first_printk(KERN_WARNING, sdkp,
3152 "Optimal transfer size %u bytes not a " \3193 "Optimal transfer size %u bytes not a " \
@@ -3224,6 +3265,7 @@ static int sd_revalidate_disk(struct gendisk *disk) · 71 unmodified lines
3224 sd_read_app_tag_own(sdkp, buffer);3265 sd_read_app_tag_own(sdkp, buffer);
3225 sd_read_write_same(sdkp, buffer);3266 sd_read_write_same(sdkp, buffer);
3226 sd_read_security(sdkp, buffer);3267 sd_read_security(sdkp, buffer);
3268 sd_config_protection(sdkp);
3227 }3269 }
3228 3270
3229 /*3271 /*
@@ -3239,6 +3281,12 @@ static int sd_revalidate_disk(struct gendisk *disk) · 9 unmodified lines
3239 dev_max = min_not_zero(dev_max, sdkp->max_xfer_blocks);3281 dev_max = min_not_zero(dev_max, sdkp->max_xfer_blocks);
3240 q->limits.max_dev_sectors = logical_to_sectors(sdp, dev_max);3282 q->limits.max_dev_sectors = logical_to_sectors(sdp, dev_max);
3241 3283
3284 if (sd_validate_min_xfer_size(sdkp))
3285 blk_queue_io_min(sdkp->disk->queue,
3286 logical_to_bytes(sdp, sdkp->min_xfer_blocks));
3287 else
3288 blk_queue_io_min(sdkp->disk->queue, 0);
3289
3242 if (sd_validate_opt_xfer_size(sdkp, dev_max)) {3290 if (sd_validate_opt_xfer_size(sdkp, dev_max)) {
3243 q->limits.io_opt = logical_to_bytes(sdp, sdkp->opt_xfer_blocks);3291 q->limits.io_opt = logical_to_bytes(sdp, sdkp->opt_xfer_blocks);
3244 rw_max = logical_to_sectors(sdp, sdkp->opt_xfer_blocks);3292 rw_max = logical_to_sectors(sdp, sdkp->opt_xfer_blocks);
@@ -3477,11 +3525,6 @@ static int sd_probe(struct device *dev) · 232 unmodified lines
3477 goto out;3525 goto out;
3478 }3526 }
3479 3527
3480 if (sdkp->capacity)
3481 sd_dif_config_host(sdkp);
3482
3483 sd_revalidate_disk(gd);
3484
3485 if (sdkp->security) {3528 if (sdkp->security) {
3486 sdkp->opal_dev = init_opal_dev(sdkp, &sd_sec_submit);3529 sdkp->opal_dev = init_opal_dev(sdkp, &sd_sec_submit);
3487 if (sdkp->opal_dev)3530 if (sdkp->opal_dev)
drivers/scsi/sd.h+26−7
@@ -67,6 +67,20 @@ enum { · 66 unmodified lines
67 SD_ZERO_WS10_UNMAP, /* Use WRITE SAME(10) with UNMAP */67 SD_ZERO_WS10_UNMAP, /* Use WRITE SAME(10) with UNMAP */
68};68};
69 69
70/**
71 * struct zoned_disk_info - Specific properties of a ZBC SCSI device.
72 * @nr_zones: number of zones.
73 * @zone_blocks: number of logical blocks per zone.
74 *
75 * This data structure holds the ZBC SCSI device properties that are retrieved
76 * twice: a first time before the gendisk capacity is known and a second time
77 * after the gendisk capacity is known.
78 */
79struct zoned_disk_info {
80 u32 nr_zones;
81 u32 zone_blocks;
82};
83
70struct scsi_disk {84struct scsi_disk {
71 struct scsi_device *device;85 struct scsi_device *device;
72 86
@@ -78,13 +92,18 @@ struct scsi_disk { · 5 unmodified lines
78 struct gendisk *disk;92 struct gendisk *disk;
79 struct opal_dev *opal_dev;93 struct opal_dev *opal_dev;
80#ifdef CONFIG_BLK_DEV_ZONED94#ifdef CONFIG_BLK_DEV_ZONED
81 u32 nr_zones;95 /* Updated during revalidation before the gendisk capacity is known. */
82 u32 rev_nr_zones;96 struct zoned_disk_info early_zone_info;
83 u32 zone_blocks;97 /* Updated during revalidation after the gendisk capacity is known. */
84 u32 rev_zone_blocks;98 struct zoned_disk_info zone_info;
85 u32 zones_optimal_open;99 u32 zones_optimal_open;
86 u32 zones_optimal_nonseq;100 u32 zones_optimal_nonseq;
87 u32 zones_max_open;101 u32 zones_max_open;
102 /*
103 * Either zero or a power of two. If not zero it means that the offset
104 * between zone starting LBAs is constant.
105 */
106 u32 zone_starting_lba_gran;
88 u32 *zones_wp_offset;107 u32 *zones_wp_offset;
89 spinlock_t zones_wp_offset_lock;108 spinlock_t zones_wp_offset_lock;
90 u32 *rev_wp_offset;109 u32 *rev_wp_offset;
@@ -95,6 +114,7 @@ struct scsi_disk { · 4 unmodified lines
95 atomic_t openers;114 atomic_t openers;
96 sector_t capacity; /* size in logical blocks */115 sector_t capacity; /* size in logical blocks */
97 int max_retries;116 int max_retries;
117 u32 min_xfer_blocks;
98 u32 max_xfer_blocks;118 u32 max_xfer_blocks;
99 u32 opt_xfer_blocks;119 u32 opt_xfer_blocks;
100 u32 max_ws_blocks;120 u32 max_ws_blocks;
@@ -222,7 +242,7 @@ static inline int sd_is_zoned(struct scsi_disk *sdkp) · 121 unmodified lines
222#ifdef CONFIG_BLK_DEV_ZONED242#ifdef CONFIG_BLK_DEV_ZONED
223 243
224void sd_zbc_release_disk(struct scsi_disk *sdkp);244void sd_zbc_release_disk(struct scsi_disk *sdkp);
225int sd_zbc_read_zones(struct scsi_disk *sdkp, unsigned char *buffer);245int sd_zbc_read_zones(struct scsi_disk *sdkp, u8 buf[SD_BUF_SIZE]);
226int sd_zbc_revalidate_zones(struct scsi_disk *sdkp);246int sd_zbc_revalidate_zones(struct scsi_disk *sdkp);
227blk_status_t sd_zbc_setup_zone_mgmt_cmnd(struct scsi_cmnd *cmd,247blk_status_t sd_zbc_setup_zone_mgmt_cmnd(struct scsi_cmnd *cmd,
228 unsigned char op, bool all);248 unsigned char op, bool all);
@@ -238,8 +258,7 @@ blk_status_t sd_zbc_prepare_zone_append(struct scsi_cmnd *cmd, sector_t *lba, · 9 unmodified lines
238 258
239static inline void sd_zbc_release_disk(struct scsi_disk *sdkp) {}259static inline void sd_zbc_release_disk(struct scsi_disk *sdkp) {}
240 260
241static inline int sd_zbc_read_zones(struct scsi_disk *sdkp,261static inline int sd_zbc_read_zones(struct scsi_disk *sdkp, u8 buf[SD_BUF_SIZE])
242 unsigned char *buf)
243{262{
244 return 0;263 return 0;
245}264}
drivers/scsi/sd_dif.c+3−5
@@ -59,8 +59,6 @@ void sd_dif_config_host(struct scsi_disk *sdkp) · 58 unmodified lines
59 bi.profile = &t10_pi_type1_crc;59 bi.profile = &t10_pi_type1_crc;
60 60
61 bi.tuple_size = sizeof(struct t10_pi_tuple);61 bi.tuple_size = sizeof(struct t10_pi_tuple);
62 sd_printk(KERN_NOTICE, sdkp,
63 "Enabling DIX %s protection\n", bi.profile->name);
64 62
65 if (dif && type) {63 if (dif && type) {
66 bi.flags |= BLK_INTEGRITY_DEVICE_CAPABLE;64 bi.flags |= BLK_INTEGRITY_DEVICE_CAPABLE;
@@ -72,11 +70,11 @@ void sd_dif_config_host(struct scsi_disk *sdkp) · 5 unmodified lines
72 bi.tag_size = sizeof(u16) + sizeof(u32);70 bi.tag_size = sizeof(u16) + sizeof(u32);
73 else71 else
74 bi.tag_size = sizeof(u16);72 bi.tag_size = sizeof(u16);
75
76 sd_printk(KERN_NOTICE, sdkp, "DIF application tag size %u\n",
77 bi.tag_size);
78 }73 }
79 74
75 sd_printk(KERN_NOTICE, sdkp,
76 "Enabling DIX %s, application tag size %u bytes\n",
77 bi.profile->name, bi.tag_size);
80out:78out:
81 blk_integrity_register(disk, &bi);79 blk_integrity_register(disk, &bi);
82}80}
drivers/scsi/sd_zbc.c+184−52
@@ -20,6 +20,12 @@ · 19 unmodified lines
20 20
21#include "sd.h"21#include "sd.h"
22 22
23/**
24 * sd_zbc_get_zone_wp_offset - Get zone write pointer offset.
25 * @zone: Zone for which to return the write pointer offset.
26 *
27 * Return: offset of the write pointer from the start of the zone.
28 */
23static unsigned int sd_zbc_get_zone_wp_offset(struct blk_zone *zone)29static unsigned int sd_zbc_get_zone_wp_offset(struct blk_zone *zone)
24{30{
25 if (zone->type == ZBC_ZONE_TYPE_CONV)31 if (zone->type == ZBC_ZONE_TYPE_CONV)
@@ -44,13 +50,37 @@ static unsigned int sd_zbc_get_zone_wp_offset(struct blk_zone *zone) · 18 unmodified lines
44 }50 }
45}51}
46 52
47static int sd_zbc_parse_report(struct scsi_disk *sdkp, u8 *buf,53/* Whether or not a SCSI zone descriptor describes a gap zone. */
54static bool sd_zbc_is_gap_zone(const u8 buf[64])
55{
56 return (buf[0] & 0xf) == ZBC_ZONE_TYPE_GAP;
57}
58
59/**
60 * sd_zbc_parse_report - Parse a SCSI zone descriptor
61 * @sdkp: SCSI disk pointer.
62 * @buf: SCSI zone descriptor.
63 * @idx: Index of the zone relative to the first zone reported by the current
64 * sd_zbc_report_zones() call.
65 * @cb: Callback function pointer.
66 * @data: Second argument passed to @cb.
67 *
68 * Return: Value returned by @cb.
69 *
70 * Convert a SCSI zone descriptor into struct blk_zone format. Additionally,
71 * call @cb(blk_zone, @data).
72 */
73static int sd_zbc_parse_report(struct scsi_disk *sdkp, const u8 buf[64],
48 unsigned int idx, report_zones_cb cb, void *data)74 unsigned int idx, report_zones_cb cb, void *data)
49{75{
50 struct scsi_device *sdp = sdkp->device;76 struct scsi_device *sdp = sdkp->device;
51 struct blk_zone zone = { 0 };77 struct blk_zone zone = { 0 };
78 sector_t start_lba, gran;
52 int ret;79 int ret;
53 80
81 if (WARN_ON_ONCE(sd_zbc_is_gap_zone(buf)))
82 return -EINVAL;
83
54 zone.type = buf[0] & 0x0f;84 zone.type = buf[0] & 0x0f;
55 zone.cond = (buf[1] >> 4) & 0xf;85 zone.cond = (buf[1] >> 4) & 0xf;
56 if (buf[1] & 0x01)86 if (buf[1] & 0x01)
@@ -58,9 +88,27 @@ static int sd_zbc_parse_report(struct scsi_disk *sdkp, u8 *buf, · 1 unmodified line
58 if (buf[1] & 0x02)88 if (buf[1] & 0x02)
59 zone.non_seq = 1;89 zone.non_seq = 1;
60 90
61 zone.len = logical_to_sectors(sdp, get_unaligned_be64(&buf[8]));91 start_lba = get_unaligned_be64(&buf[16]);
62 zone.capacity = zone.len;92 zone.start = logical_to_sectors(sdp, start_lba);
63 zone.start = logical_to_sectors(sdp, get_unaligned_be64(&buf[16]));93 zone.capacity = logical_to_sectors(sdp, get_unaligned_be64(&buf[8]));
94 zone.len = zone.capacity;
95 if (sdkp->zone_starting_lba_gran) {
96 gran = logical_to_sectors(sdp, sdkp->zone_starting_lba_gran);
97 if (zone.len > gran) {
98 sd_printk(KERN_ERR, sdkp,
99 "Invalid zone at LBA %llu with capacity %llu and length %llu; granularity = %llu\n",
100 start_lba,
101 sectors_to_logical(sdp, zone.capacity),
102 sectors_to_logical(sdp, zone.len),
103 sectors_to_logical(sdp, gran));
104 return -EINVAL;
105 }
106 /*
107 * Use the starting LBA granularity instead of the zone length
108 * obtained from the REPORT ZONES command.
109 */
110 zone.len = gran;
111 }
64 if (zone.cond == ZBC_ZONE_COND_FULL)112 if (zone.cond == ZBC_ZONE_COND_FULL)
65 zone.wp = zone.start + zone.len;113 zone.wp = zone.start + zone.len;
66 else114 else
@@ -161,7 +209,7 @@ static void *sd_zbc_alloc_report_buffer(struct scsi_disk *sdkp, · 94 unmodified lines
161 * sure that the allocated buffer can always be mapped by limiting the209 * sure that the allocated buffer can always be mapped by limiting the
162 * number of pages allocated to the HBA max segments limit.210 * number of pages allocated to the HBA max segments limit.
163 */211 */
164 nr_zones = min(nr_zones, sdkp->nr_zones);212 nr_zones = min(nr_zones, sdkp->zone_info.nr_zones);
165 bufsize = roundup((nr_zones + 1) * 64, SECTOR_SIZE);213 bufsize = roundup((nr_zones + 1) * 64, SECTOR_SIZE);
166 bufsize = min_t(size_t, bufsize,214 bufsize = min_t(size_t, bufsize,
167 queue_max_hw_sectors(q) << SECTOR_SHIFT);215 queue_max_hw_sectors(q) << SECTOR_SHIFT);
@@ -186,16 +234,28 @@ static void *sd_zbc_alloc_report_buffer(struct scsi_disk *sdkp, · 18 unmodified lines
186 */234 */
187static inline sector_t sd_zbc_zone_sectors(struct scsi_disk *sdkp)235static inline sector_t sd_zbc_zone_sectors(struct scsi_disk *sdkp)
188{236{
189 return logical_to_sectors(sdkp->device, sdkp->zone_blocks);237 return logical_to_sectors(sdkp->device, sdkp->zone_info.zone_blocks);
190}238}
191 239
240/**
241 * sd_zbc_report_zones - SCSI .report_zones() callback.
242 * @disk: Disk to report zones for.
243 * @sector: Start sector.
244 * @nr_zones: Maximum number of zones to report.
245 * @cb: Callback function called to report zone information.
246 * @data: Second argument passed to @cb.
247 *
248 * Called by the block layer to iterate over zone information. See also the
249 * disk->fops->report_zones() calls in block/blk-zoned.c.
250 */
192int sd_zbc_report_zones(struct gendisk *disk, sector_t sector,251int sd_zbc_report_zones(struct gendisk *disk, sector_t sector,
193 unsigned int nr_zones, report_zones_cb cb, void *data)252 unsigned int nr_zones, report_zones_cb cb, void *data)
194{253{
195 struct scsi_disk *sdkp = scsi_disk(disk);254 struct scsi_disk *sdkp = scsi_disk(disk);
196 sector_t capacity = logical_to_sectors(sdkp->device, sdkp->capacity);255 sector_t lba = sectors_to_logical(sdkp->device, sector);
197 unsigned int nr, i;256 unsigned int nr, i;
198 unsigned char *buf;257 unsigned char *buf;
258 u64 zone_length, start_lba;
199 size_t offset, buflen = 0;259 size_t offset, buflen = 0;
200 int zone_idx = 0;260 int zone_idx = 0;
201 int ret;261 int ret;
@@ -204,7 +264,7 @@ int sd_zbc_report_zones(struct gendisk *disk, sector_t sector, · 2 unmodified lines
204 /* Not a zoned device */264 /* Not a zoned device */
205 return -EOPNOTSUPP;265 return -EOPNOTSUPP;
206 266
207 if (!capacity)267 if (!sdkp->capacity)
208 /* Device gone or invalid */268 /* Device gone or invalid */
209 return -ENODEV;269 return -ENODEV;
210 270
@@ -212,9 +272,8 @@ int sd_zbc_report_zones(struct gendisk *disk, sector_t sector, · 1 unmodified line
212 if (!buf)272 if (!buf)
213 return -ENOMEM;273 return -ENOMEM;
214 274
215 while (zone_idx < nr_zones && sector < capacity) {275 while (zone_idx < nr_zones && lba < sdkp->capacity) {
216 ret = sd_zbc_do_report_zones(sdkp, buf, buflen,276 ret = sd_zbc_do_report_zones(sdkp, buf, buflen, lba, true);
217 sectors_to_logical(sdkp->device, sector), true);
218 if (ret)277 if (ret)
219 goto out;278 goto out;
220 279
@@ -225,14 +284,36 @@ int sd_zbc_report_zones(struct gendisk *disk, sector_t sector, · 4 unmodified lines
225 284
226 for (i = 0; i < nr && zone_idx < nr_zones; i++) {285 for (i = 0; i < nr && zone_idx < nr_zones; i++) {
227 offset += 64;286 offset += 64;
287 start_lba = get_unaligned_be64(&buf[offset + 16]);
288 zone_length = get_unaligned_be64(&buf[offset + 8]);
289 if ((zone_idx == 0 &&
290 (lba < start_lba ||
291 lba >= start_lba + zone_length)) ||
292 (zone_idx > 0 && start_lba != lba) ||
293 start_lba + zone_length < start_lba) {
294 sd_printk(KERN_ERR, sdkp,
295 "Zone %d at LBA %llu is invalid: %llu + %llu\n",
296 zone_idx, lba, start_lba, zone_length);
297 ret = -EINVAL;
298 goto out;
299 }
300 lba = start_lba + zone_length;
301 if (sd_zbc_is_gap_zone(&buf[offset])) {
302 if (sdkp->zone_starting_lba_gran)
303 continue;
304 sd_printk(KERN_ERR, sdkp,
305 "Gap zone without constant LBA offsets\n");
306 ret = -EINVAL;
307 goto out;
308 }
309
228 ret = sd_zbc_parse_report(sdkp, buf + offset, zone_idx,310 ret = sd_zbc_parse_report(sdkp, buf + offset, zone_idx,
229 cb, data);311 cb, data);
230 if (ret)312 if (ret)
231 goto out;313 goto out;
314
232 zone_idx++;315 zone_idx++;
233 }316 }
234
235 sector += sd_zbc_zone_sectors(sdkp) * i;
236 }317 }
237 318
238 ret = zone_idx;319 ret = zone_idx;
@@ -276,6 +357,10 @@ static int sd_zbc_update_wp_offset_cb(struct blk_zone *zone, unsigned int idx, · 37 unmodified lines
276 return 0;357 return 0;
277}358}
278 359
360/*
361 * An attempt to append a zone triggered an invalid write pointer error.
362 * Reread the write pointer of the zone(s) in which the append failed.
363 */
279static void sd_zbc_update_wp_offset_workfn(struct work_struct *work)364static void sd_zbc_update_wp_offset_workfn(struct work_struct *work)
280{365{
281 struct scsi_disk *sdkp;366 struct scsi_disk *sdkp;
@@ -286,14 +371,14 @@ static void sd_zbc_update_wp_offset_workfn(struct work_struct *work) · 4 unmodified lines
286 sdkp = container_of(work, struct scsi_disk, zone_wp_offset_work);371 sdkp = container_of(work, struct scsi_disk, zone_wp_offset_work);
287 372
288 spin_lock_irqsave(&sdkp->zones_wp_offset_lock, flags);373 spin_lock_irqsave(&sdkp->zones_wp_offset_lock, flags);
289 for (zno = 0; zno < sdkp->nr_zones; zno++) {374 for (zno = 0; zno < sdkp->zone_info.nr_zones; zno++) {
290 if (sdkp->zones_wp_offset[zno] != SD_ZBC_UPDATING_WP_OFST)375 if (sdkp->zones_wp_offset[zno] != SD_ZBC_UPDATING_WP_OFST)
291 continue;376 continue;
292 377
293 spin_unlock_irqrestore(&sdkp->zones_wp_offset_lock, flags);378 spin_unlock_irqrestore(&sdkp->zones_wp_offset_lock, flags);
294 ret = sd_zbc_do_report_zones(sdkp, sdkp->zone_wp_update_buf,379 ret = sd_zbc_do_report_zones(sdkp, sdkp->zone_wp_update_buf,
295 SD_BUF_SIZE,380 SD_BUF_SIZE,
296 zno * sdkp->zone_blocks, true);381 zno * sdkp->zone_info.zone_blocks, true);
297 spin_lock_irqsave(&sdkp->zones_wp_offset_lock, flags);382 spin_lock_irqsave(&sdkp->zones_wp_offset_lock, flags);
298 if (!ret)383 if (!ret)
299 sd_zbc_parse_report(sdkp, sdkp->zone_wp_update_buf + 64,384 sd_zbc_parse_report(sdkp, sdkp->zone_wp_update_buf + 64,
@@ -360,7 +445,7 @@ blk_status_t sd_zbc_prepare_zone_append(struct scsi_cmnd *cmd, sector_t *lba, · 60 unmodified lines
360 break;445 break;
361 default:446 default:
362 wp_offset = sectors_to_logical(sdkp->device, wp_offset);447 wp_offset = sectors_to_logical(sdkp->device, wp_offset);
363 if (wp_offset + nr_blocks > sdkp->zone_blocks) {448 if (wp_offset + nr_blocks > sdkp->zone_info.zone_blocks) {
364 ret = BLK_STS_IOERR;449 ret = BLK_STS_IOERR;
365 break;450 break;
366 }451 }
@@ -489,7 +574,7 @@ static unsigned int sd_zbc_zone_wp_update(struct scsi_cmnd *cmd, · 122 unmodified lines
489 break;574 break;
490 case REQ_OP_ZONE_RESET_ALL:575 case REQ_OP_ZONE_RESET_ALL:
491 memset(sdkp->zones_wp_offset, 0,576 memset(sdkp->zones_wp_offset, 0,
492 sdkp->nr_zones * sizeof(unsigned int));577 sdkp->zone_info.nr_zones * sizeof(unsigned int));
493 break;578 break;
494 default:579 default:
495 break;580 break;
@@ -545,6 +630,7 @@ unsigned int sd_zbc_complete(struct scsi_cmnd *cmd, unsigned int good_bytes, · 49 unmodified lines
545static int sd_zbc_check_zoned_characteristics(struct scsi_disk *sdkp,630static int sd_zbc_check_zoned_characteristics(struct scsi_disk *sdkp,
546 unsigned char *buf)631 unsigned char *buf)
547{632{
633 u64 zone_starting_lba_gran;
548 634
549 if (scsi_get_vpd_page(sdkp->device, 0xb6, buf, 64)) {635 if (scsi_get_vpd_page(sdkp->device, 0xb6, buf, 64)) {
550 sd_printk(KERN_NOTICE, sdkp,636 sd_printk(KERN_NOTICE, sdkp,
@@ -558,12 +644,36 @@ static int sd_zbc_check_zoned_characteristics(struct scsi_disk *sdkp, · 7 unmodified lines
558 sdkp->zones_optimal_open = get_unaligned_be32(&buf[8]);644 sdkp->zones_optimal_open = get_unaligned_be32(&buf[8]);
559 sdkp->zones_optimal_nonseq = get_unaligned_be32(&buf[12]);645 sdkp->zones_optimal_nonseq = get_unaligned_be32(&buf[12]);
560 sdkp->zones_max_open = 0;646 sdkp->zones_max_open = 0;
561 } else {647 return 0;
562 /* Host-managed */648 }
563 sdkp->urswrz = buf[4] & 1;649
564 sdkp->zones_optimal_open = 0;650 /* Host-managed */
565 sdkp->zones_optimal_nonseq = 0;651 sdkp->urswrz = buf[4] & 1;
566 sdkp->zones_max_open = get_unaligned_be32(&buf[16]);652 sdkp->zones_optimal_open = 0;
653 sdkp->zones_optimal_nonseq = 0;
654 sdkp->zones_max_open = get_unaligned_be32(&buf[16]);
655 /* Check zone alignment method */
656 switch (buf[23] & 0xf) {
657 case 0:
658 case ZBC_CONSTANT_ZONE_LENGTH:
659 /* Use zone length */
660 break;
661 case ZBC_CONSTANT_ZONE_START_OFFSET:
662 zone_starting_lba_gran = get_unaligned_be64(&buf[24]);
663 if (zone_starting_lba_gran == 0 ||
664 !is_power_of_2(zone_starting_lba_gran) ||
665 logical_to_sectors(sdkp->device, zone_starting_lba_gran) >
666 UINT_MAX) {
667 sd_printk(KERN_ERR, sdkp,
668 "Invalid zone starting LBA granularity %llu\n",
669 zone_starting_lba_gran);
670 return -ENODEV;
671 }
672 sdkp->zone_starting_lba_gran = zone_starting_lba_gran;
673 break;
674 default:
675 sd_printk(KERN_ERR, sdkp, "Invalid zone alignment method\n");
676 return -ENODEV;
567 }677 }
568 678
569 /*679 /*
@@ -585,7 +695,7 @@ static int sd_zbc_check_zoned_characteristics(struct scsi_disk *sdkp, · 15 unmodified lines
585 * sd_zbc_check_capacity - Check the device capacity695 * sd_zbc_check_capacity - Check the device capacity
586 * @sdkp: Target disk696 * @sdkp: Target disk
587 * @buf: command buffer697 * @buf: command buffer
588 * @zblocks: zone size in number of blocks698 * @zblocks: zone size in logical blocks
589 *699 *
590 * Get the device zone size and check that the device capacity as reported700 * Get the device zone size and check that the device capacity as reported
591 * by READ CAPACITY matches the max_lba value (plus one) of the report zones701 * by READ CAPACITY matches the max_lba value (plus one) of the report zones
@@ -619,14 +729,25 @@ static int sd_zbc_check_capacity(struct scsi_disk *sdkp, unsigned char *buf, · 27 unmodified lines
619 }729 }
620 }730 }
621 731
622 /* Get the size of the first reported zone */732 if (sdkp->zone_starting_lba_gran == 0) {
623 rec = buf + 64;733 /* Get the size of the first reported zone */
624 zone_blocks = get_unaligned_be64(&rec[8]);734 rec = buf + 64;
625 if (logical_to_sectors(sdkp->device, zone_blocks) > UINT_MAX) {735 zone_blocks = get_unaligned_be64(&rec[8]);
626 if (sdkp->first_scan)736 if (logical_to_sectors(sdkp->device, zone_blocks) > UINT_MAX) {
627 sd_printk(KERN_NOTICE, sdkp,737 if (sdkp->first_scan)
628 "Zone size too large\n");738 sd_printk(KERN_NOTICE, sdkp,
629 return -EFBIG;739 "Zone size too large\n");
740 return -EFBIG;
741 }
742 } else {
743 zone_blocks = sdkp->zone_starting_lba_gran;
744 }
745
746 if (!is_power_of_2(zone_blocks)) {
747 sd_printk(KERN_ERR, sdkp,
748 "Zone size %llu is not a power of two.\n",
749 zone_blocks);
750 return -EINVAL;
630 }751 }
631 752
632 *zblocks = zone_blocks;753 *zblocks = zone_blocks;
@@ -639,16 +760,16 @@ static void sd_zbc_print_zones(struct scsi_disk *sdkp) · 6 unmodified lines
639 if (!sd_is_zoned(sdkp) || !sdkp->capacity)760 if (!sd_is_zoned(sdkp) || !sdkp->capacity)
640 return;761 return;
641 762
642 if (sdkp->capacity & (sdkp->zone_blocks - 1))763 if (sdkp->capacity & (sdkp->zone_info.zone_blocks - 1))
643 sd_printk(KERN_NOTICE, sdkp,764 sd_printk(KERN_NOTICE, sdkp,
644 "%u zones of %u logical blocks + 1 runt zone\n",765 "%u zones of %u logical blocks + 1 runt zone\n",
645 sdkp->nr_zones - 1,766 sdkp->zone_info.nr_zones - 1,
646 sdkp->zone_blocks);767 sdkp->zone_info.zone_blocks);
647 else768 else
648 sd_printk(KERN_NOTICE, sdkp,769 sd_printk(KERN_NOTICE, sdkp,
649 "%u zones of %u logical blocks\n",770 "%u zones of %u logical blocks\n",
650 sdkp->nr_zones,771 sdkp->zone_info.nr_zones,
651 sdkp->zone_blocks);772 sdkp->zone_info.zone_blocks);
652}773}
653 774
654static int sd_zbc_init_disk(struct scsi_disk *sdkp)775static int sd_zbc_init_disk(struct scsi_disk *sdkp)
@@ -675,10 +796,8 @@ static void sd_zbc_clear_zone_info(struct scsi_disk *sdkp) · 20 unmodified lines
675 kfree(sdkp->zone_wp_update_buf);796 kfree(sdkp->zone_wp_update_buf);
676 sdkp->zone_wp_update_buf = NULL;797 sdkp->zone_wp_update_buf = NULL;
677 798
678 sdkp->nr_zones = 0;799 sdkp->early_zone_info = (struct zoned_disk_info){ };
679 sdkp->rev_nr_zones = 0;800 sdkp->zone_info = (struct zoned_disk_info){ };
680 sdkp->zone_blocks = 0;
681 sdkp->rev_zone_blocks = 0;
682 801
683 mutex_unlock(&sdkp->rev_mutex);802 mutex_unlock(&sdkp->rev_mutex);
684}803}
@@ -696,12 +815,17 @@ static void sd_zbc_revalidate_zones_cb(struct gendisk *disk) · 11 unmodified lines
696 swap(sdkp->zones_wp_offset, sdkp->rev_wp_offset);815 swap(sdkp->zones_wp_offset, sdkp->rev_wp_offset);
697}816}
698 817
818/*
819 * Call blk_revalidate_disk_zones() if any of the zoned disk properties have
820 * changed that make it necessary to call that function. Called by
821 * sd_revalidate_disk() after the gendisk capacity has been set.
822 */
699int sd_zbc_revalidate_zones(struct scsi_disk *sdkp)823int sd_zbc_revalidate_zones(struct scsi_disk *sdkp)
700{824{
701 struct gendisk *disk = sdkp->disk;825 struct gendisk *disk = sdkp->disk;
702 struct request_queue *q = disk->queue;826 struct request_queue *q = disk->queue;
703 u32 zone_blocks = sdkp->rev_zone_blocks;827 u32 zone_blocks = sdkp->early_zone_info.zone_blocks;
704 unsigned int nr_zones = sdkp->rev_nr_zones;828 unsigned int nr_zones = sdkp->early_zone_info.nr_zones;
705 u32 max_append;829 u32 max_append;
706 int ret = 0;830 int ret = 0;
707 unsigned int flags;831 unsigned int flags;
@@ -732,14 +856,14 @@ int sd_zbc_revalidate_zones(struct scsi_disk *sdkp) · 24 unmodified lines
732 */856 */
733 mutex_lock(&sdkp->rev_mutex);857 mutex_lock(&sdkp->rev_mutex);
734 858
735 if (sdkp->zone_blocks == zone_blocks &&859 if (sdkp->zone_info.zone_blocks == zone_blocks &&
736 sdkp->nr_zones == nr_zones &&860 sdkp->zone_info.nr_zones == nr_zones &&
737 disk->queue->nr_zones == nr_zones)861 disk->queue->nr_zones == nr_zones)
738 goto unlock;862 goto unlock;
739 863
740 flags = memalloc_noio_save();864 flags = memalloc_noio_save();
741 sdkp->zone_blocks = zone_blocks;865 sdkp->zone_info.zone_blocks = zone_blocks;
742 sdkp->nr_zones = nr_zones;866 sdkp->zone_info.nr_zones = nr_zones;
743 sdkp->rev_wp_offset = kvcalloc(nr_zones, sizeof(u32), GFP_KERNEL);867 sdkp->rev_wp_offset = kvcalloc(nr_zones, sizeof(u32), GFP_KERNEL);
744 if (!sdkp->rev_wp_offset) {868 if (!sdkp->rev_wp_offset) {
745 ret = -ENOMEM;869 ret = -ENOMEM;
@@ -754,8 +878,7 @@ int sd_zbc_revalidate_zones(struct scsi_disk *sdkp) · 8 unmodified lines
754 sdkp->rev_wp_offset = NULL;878 sdkp->rev_wp_offset = NULL;
755 879
756 if (ret) {880 if (ret) {
757 sdkp->zone_blocks = 0;881 sdkp->zone_info = (struct zoned_disk_info){ };
758 sdkp->nr_zones = 0;
759 sdkp->capacity = 0;882 sdkp->capacity = 0;
760 goto unlock;883 goto unlock;
761 }884 }
@@ -774,7 +897,16 @@ unlock: · 12 unmodified lines
774 return ret;897 return ret;
775}898}
776 899
777int sd_zbc_read_zones(struct scsi_disk *sdkp, unsigned char *buf)900/**
901 * sd_zbc_read_zones - Read zone information and update the request queue
902 * @sdkp: SCSI disk pointer.
903 * @buf: 512 byte buffer used for storing SCSI command output.
904 *
905 * Read zone information and update the request queue zone characteristics and
906 * also the zoned device information in *sdkp. Called by sd_revalidate_disk()
907 * before the gendisk capacity has been set.
908 */
909int sd_zbc_read_zones(struct scsi_disk *sdkp, u8 buf[SD_BUF_SIZE])
778{910{
779 struct gendisk *disk = sdkp->disk;911 struct gendisk *disk = sdkp->disk;
780 struct request_queue *q = disk->queue;912 struct request_queue *q = disk->queue;
@@ -832,8 +964,8 @@ int sd_zbc_read_zones(struct scsi_disk *sdkp, unsigned char *buf) · 51 unmodified lines
832 if (blk_queue_zoned_model(q) == BLK_ZONED_HM)964 if (blk_queue_zoned_model(q) == BLK_ZONED_HM)
833 blk_queue_zone_write_granularity(q, sdkp->physical_block_size);965 blk_queue_zone_write_granularity(q, sdkp->physical_block_size);
834 966
835 sdkp->rev_nr_zones = nr_zones;967 sdkp->early_zone_info.nr_zones = nr_zones;
836 sdkp->rev_zone_blocks = zone_blocks;968 sdkp->early_zone_info.zone_blocks = zone_blocks;
837 969
838 return 0;970 return 0;
839 971
drivers/scsi/sr.c+8−6
@@ -113,7 +113,7 @@ static int sr_open(struct cdrom_device_info *, int); · 112 unmodified lines
113static void sr_release(struct cdrom_device_info *);113static void sr_release(struct cdrom_device_info *);
114 114
115static void get_sectorsize(struct scsi_cd *);115static void get_sectorsize(struct scsi_cd *);
116static void get_capabilities(struct scsi_cd *);116static int get_capabilities(struct scsi_cd *);
117 117
118static unsigned int sr_check_events(struct cdrom_device_info *cdi,118static unsigned int sr_check_events(struct cdrom_device_info *cdi,
119 unsigned int clearing, int slot);119 unsigned int clearing, int slot);
@@ -669,8 +669,9 @@ static int sr_probe(struct device *dev) · 549 unmodified lines
669 669
670 sdev->sector_size = 2048; /* A guess, just in case */670 sdev->sector_size = 2048; /* A guess, just in case */
671 671
672 /* FIXME: need to handle a get_capabilities failure properly ?? */672 error = -ENOMEM;
673 get_capabilities(cd);673 if (get_capabilities(cd))
674 goto fail_minor;
674 sr_vendor_init(cd);675 sr_vendor_init(cd);
675 676
676 set_capacity(disk, cd->capacity);677 set_capacity(disk, cd->capacity);
@@ -794,7 +795,7 @@ static void get_sectorsize(struct scsi_cd *cd) · 117 unmodified lines
794 return;795 return;
795}796}
796 797
797static void get_capabilities(struct scsi_cd *cd)798static int get_capabilities(struct scsi_cd *cd)
798{799{
799 unsigned char *buffer;800 unsigned char *buffer;
800 struct scsi_mode_data data;801 struct scsi_mode_data data;
@@ -819,7 +820,7 @@ static void get_capabilities(struct scsi_cd *cd) · 18 unmodified lines
819 buffer = kmalloc(512, GFP_KERNEL);820 buffer = kmalloc(512, GFP_KERNEL);
820 if (!buffer) {821 if (!buffer) {
821 sr_printk(KERN_ERR, cd, "out of memory.\n");822 sr_printk(KERN_ERR, cd, "out of memory.\n");
822 return;823 return -ENOMEM;
823 }824 }
824 825
825 /* eat unit attentions */826 /* eat unit attentions */
@@ -839,7 +840,7 @@ static void get_capabilities(struct scsi_cd *cd) · 13 unmodified lines
839 CDC_MRW | CDC_MRW_W | CDC_RAM);840 CDC_MRW | CDC_MRW_W | CDC_RAM);
840 kfree(buffer);841 kfree(buffer);
841 sr_printk(KERN_INFO, cd, "scsi-1 drive");842 sr_printk(KERN_INFO, cd, "scsi-1 drive");
842 return;843 return 0;
843 }844 }
844 845
845 n = data.header_length + data.block_descriptor_length;846 n = data.header_length + data.block_descriptor_length;
@@ -898,6 +899,7 @@ static void get_capabilities(struct scsi_cd *cd) · 52 unmodified lines
898 }899 }
899 900
900 kfree(buffer);901 kfree(buffer);
902 return 0;
901}903}
902 904
903/*905/*
drivers/scsi/ufs/Kconfig+1−25
@@ -1,36 +1,12 @@
1# SPDX-License-Identifier: GPL-2.0+
1#2#
2# Kernel configuration file for the UFS Host Controller3# Kernel configuration file for the UFS Host Controller
3#4#
4# This code is based on drivers/scsi/ufs/Kconfig
5# Copyright (C) 2011-2013 Samsung India Software Operations5# Copyright (C) 2011-2013 Samsung India Software Operations
6#6#
7# Authors:7# Authors:
8# Santosh Yaraganavi <santosh.sy@samsung.com>8# Santosh Yaraganavi <santosh.sy@samsung.com>
9# Vinayak Holikatti <h.vinayak@samsung.com>9# Vinayak Holikatti <h.vinayak@samsung.com>
10#
11# This program is free software; you can redistribute it and/or
12# modify it under the terms of the GNU General Public License
13# as published by the Free Software Foundation; either version 2
14# of the License, or (at your option) any later version.
15# See the COPYING file in the top-level directory or visit
16# <http://www.gnu.org/licenses/gpl-2.0.html>
17#
18# This program is distributed in the hope that it will be useful,
19# but WITHOUT ANY WARRANTY; without even the implied warranty of
20# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21# GNU General Public License for more details.
22#
23# This program is provided "AS IS" and "WITH ALL FAULTS" and
24# without warranty of any kind. You are solely responsible for
25# determining the appropriateness of using and distributing
26# the program and assume all risks associated with your exercise
27# of rights with respect to the program, including but not limited
28# to infringement of third party rights, the risks and costs of
29# program errors, damage to or loss of data, programs or equipment,
30# and unavailability or interruption of operations. Under no
31# circumstances will the contributor of this Program be liable for
32# any damages of any kind arising from your use or distribution of
33# this program.
34 10
35config SCSI_UFSHCD11config SCSI_UFSHCD
36 tristate "Universal Flash Storage Controller Driver Core"12 tristate "Universal Flash Storage Controller Driver Core"
drivers/scsi/ufs/cdns-pltfrm.c+1−1
@@ -9,6 +9,7 @@ · 8 unmodified lines
9 *9 *
10 */10 */
11 11
12#include <linux/clk.h>
12#include <linux/kernel.h>13#include <linux/kernel.h>
13#include <linux/module.h>14#include <linux/module.h>
14#include <linux/platform_device.h>15#include <linux/platform_device.h>
@@ -340,4 +341,3 @@ module_platform_driver(cdns_ufs_pltfrm_driver); · 325 unmodified lines
340MODULE_AUTHOR("Jan Kotas <jank@cadence.com>");341MODULE_AUTHOR("Jan Kotas <jank@cadence.com>");
341MODULE_DESCRIPTION("Cadence UFS host controller platform driver");342MODULE_DESCRIPTION("Cadence UFS host controller platform driver");
342MODULE_LICENSE("GPL v2");343MODULE_LICENSE("GPL v2");
343MODULE_VERSION(UFSHCD_DRIVER_VERSION);
drivers/scsi/ufs/tc-dwc-g210-pci.c+1−0
@@ -11,6 +11,7 @@ · 10 unmodified lines
11#include "ufshcd-dwc.h"11#include "ufshcd-dwc.h"
12#include "tc-dwc-g210.h"12#include "tc-dwc-g210.h"
13 13
14#include <linux/module.h>
14#include <linux/pci.h>15#include <linux/pci.h>
15#include <linux/pm_runtime.h>16#include <linux/pm_runtime.h>
16 17
drivers/scsi/ufs/tc-dwc-g210-pltfrm.c+1−0
@@ -12,6 +12,7 @@ · 11 unmodified lines
12#include <linux/platform_device.h>12#include <linux/platform_device.h>
13#include <linux/of.h>13#include <linux/of.h>
14#include <linux/delay.h>14#include <linux/delay.h>
15#include <linux/pm_runtime.h>
15 16
16#include "ufshcd-pltfrm.h"17#include "ufshcd-pltfrm.h"
17#include "ufshcd-dwc.h"18#include "ufshcd-dwc.h"
drivers/scsi/ufs/tc-dwc-g210.c+2−0
@@ -7,6 +7,8 @@ · 6 unmodified lines
7 * Authors: Joao Pinto <jpinto@synopsys.com>7 * Authors: Joao Pinto <jpinto@synopsys.com>
8 */8 */
9 9
10#include <linux/module.h>
11
10#include "ufshcd.h"12#include "ufshcd.h"
11#include "unipro.h"13#include "unipro.h"
12 14
drivers/scsi/ufs/tc-dwc-g210.h+2−0
@@ -10,6 +10,8 @@ · 9 unmodified lines
10#ifndef _TC_DWC_G210_H10#ifndef _TC_DWC_G210_H
11#define _TC_DWC_G210_H11#define _TC_DWC_G210_H
12 12
13struct ufs_hba;
14
13int tc_dwc_g210_config_40_bit(struct ufs_hba *hba);15int tc_dwc_g210_config_40_bit(struct ufs_hba *hba);
14int tc_dwc_g210_config_20_bit(struct ufs_hba *hba);16int tc_dwc_g210_config_20_bit(struct ufs_hba *hba);
15 17
drivers/scsi/ufs/ti-j721e-ufs.c+2−4
@@ -29,11 +29,9 @@ static int ti_j721e_ufs_probe(struct platform_device *pdev) · 28 unmodified lines
29 return PTR_ERR(regbase);29 return PTR_ERR(regbase);
30 30
31 pm_runtime_enable(dev);31 pm_runtime_enable(dev);
32 ret = pm_runtime_get_sync(dev);32 ret = pm_runtime_resume_and_get(dev);
33 if (ret < 0) {33 if (ret < 0)
34 pm_runtime_put_noidle(dev);
35 goto disable_pm;34 goto disable_pm;
36 }
37 35
38 /* Select MPHY refclk frequency */36 /* Select MPHY refclk frequency */
39 clk = devm_clk_get(dev, NULL);37 clk = devm_clk_get(dev, NULL);
drivers/scsi/ufs/ufs-debugfs.c+1−0
@@ -5,6 +5,7 @@ · 4 unmodified lines
5 5
6#include "ufs-debugfs.h"6#include "ufs-debugfs.h"
7#include "ufshcd.h"7#include "ufshcd.h"
8#include "ufshcd-priv.h"
8 9
9static struct dentry *ufs_debugfs_root;10static struct dentry *ufs_debugfs_root;
10 11
drivers/scsi/ufs/ufs-exynos.c+3−2
@@ -9,6 +9,7 @@ · 8 unmodified lines
9 */9 */
10 10
11#include <linux/clk.h>11#include <linux/clk.h>
12#include <linux/delay.h>
12#include <linux/module.h>13#include <linux/module.h>
13#include <linux/of.h>14#include <linux/of.h>
14#include <linux/of_address.h>15#include <linux/of_address.h>
@@ -704,7 +705,7 @@ static void exynos_ufs_establish_connt(struct exynos_ufs *ufs) · 689 unmodified lines
704 705
705 /* local unipro attributes */706 /* local unipro attributes */
706 ufshcd_dme_set(hba, UIC_ARG_MIB(N_DEVICEID), DEV_ID);707 ufshcd_dme_set(hba, UIC_ARG_MIB(N_DEVICEID), DEV_ID);
707 ufshcd_dme_set(hba, UIC_ARG_MIB(N_DEVICEID_VALID), TRUE);708 ufshcd_dme_set(hba, UIC_ARG_MIB(N_DEVICEID_VALID), true);
708 ufshcd_dme_set(hba, UIC_ARG_MIB(T_PEERDEVICEID), PEER_DEV_ID);709 ufshcd_dme_set(hba, UIC_ARG_MIB(T_PEERDEVICEID), PEER_DEV_ID);
709 ufshcd_dme_set(hba, UIC_ARG_MIB(T_PEERCPORTID), PEER_CPORT_ID);710 ufshcd_dme_set(hba, UIC_ARG_MIB(T_PEERCPORTID), PEER_CPORT_ID);
710 ufshcd_dme_set(hba, UIC_ARG_MIB(T_CPORTFLAGS), CPORT_DEF_FLAGS);711 ufshcd_dme_set(hba, UIC_ARG_MIB(T_CPORTFLAGS), CPORT_DEF_FLAGS);
@@ -1028,7 +1029,7 @@ static int exynos_ufs_post_link(struct ufs_hba *hba) · 317 unmodified lines
1028 1029
1029 if (ufs->opts & EXYNOS_UFS_OPT_SKIP_CONNECTION_ESTAB)1030 if (ufs->opts & EXYNOS_UFS_OPT_SKIP_CONNECTION_ESTAB)
1030 ufshcd_dme_set(hba,1031 ufshcd_dme_set(hba,
1031 UIC_ARG_MIB(T_DBG_SKIP_INIT_HIBERN8_EXIT), TRUE);1032 UIC_ARG_MIB(T_DBG_SKIP_INIT_HIBERN8_EXIT), true);
1032 1033
1033 if (attr->pa_granularity) {1034 if (attr->pa_granularity) {
1034 exynos_ufs_enable_dbg_mode(hba);1035 exynos_ufs_enable_dbg_mode(hba);
drivers/scsi/ufs/ufs-exynos.h+4−4
@@ -248,22 +248,22 @@ long exynos_ufs_calc_time_cntr(struct exynos_ufs *, long); · 247 unmodified lines
248 248
249static inline void exynos_ufs_enable_ov_tm(struct ufs_hba *hba)249static inline void exynos_ufs_enable_ov_tm(struct ufs_hba *hba)
250{250{
251 ufshcd_dme_set(hba, UIC_ARG_MIB(PA_DBG_OV_TM), TRUE);251 ufshcd_dme_set(hba, UIC_ARG_MIB(PA_DBG_OV_TM), true);
252}252}
253 253
254static inline void exynos_ufs_disable_ov_tm(struct ufs_hba *hba)254static inline void exynos_ufs_disable_ov_tm(struct ufs_hba *hba)
255{255{
256 ufshcd_dme_set(hba, UIC_ARG_MIB(PA_DBG_OV_TM), FALSE);256 ufshcd_dme_set(hba, UIC_ARG_MIB(PA_DBG_OV_TM), false);
257}257}
258 258
259static inline void exynos_ufs_enable_dbg_mode(struct ufs_hba *hba)259static inline void exynos_ufs_enable_dbg_mode(struct ufs_hba *hba)
260{260{
261 ufshcd_dme_set(hba, UIC_ARG_MIB(PA_DBG_MODE), TRUE);261 ufshcd_dme_set(hba, UIC_ARG_MIB(PA_DBG_MODE), true);
262}262}
263 263
264static inline void exynos_ufs_disable_dbg_mode(struct ufs_hba *hba)264static inline void exynos_ufs_disable_dbg_mode(struct ufs_hba *hba)
265{265{
266 ufshcd_dme_set(hba, UIC_ARG_MIB(PA_DBG_MODE), FALSE);266 ufshcd_dme_set(hba, UIC_ARG_MIB(PA_DBG_MODE), false);
267}267}
268 268
269#endif /* _UFS_EXYNOS_H_ */269#endif /* _UFS_EXYNOS_H_ */
drivers/scsi/ufs/ufs-hisi.c+2−0
@@ -7,6 +7,8 @@ · 6 unmodified lines
7 */7 */
8 8
9#include <linux/time.h>9#include <linux/time.h>
10#include <linux/delay.h>
11#include <linux/module.h>
10#include <linux/of.h>12#include <linux/of.h>
11#include <linux/of_address.h>13#include <linux/of_address.h>
12#include <linux/dma-mapping.h>14#include <linux/dma-mapping.h>
drivers/scsi/ufs/ufs-hwmon.c+1−0
@@ -8,6 +8,7 @@ · 7 unmodified lines
8#include <linux/units.h>8#include <linux/units.h>
9 9
10#include "ufshcd.h"10#include "ufshcd.h"
11#include "ufshcd-priv.h"
11 12
12struct ufs_hwmon_data {13struct ufs_hwmon_data {
13 struct ufs_hba *hba;14 struct ufs_hba *hba;
drivers/scsi/ufs/ufs-mediatek.c+12−19
@@ -8,6 +8,9 @@ · 7 unmodified lines
8 8
9#include <linux/arm-smccc.h>9#include <linux/arm-smccc.h>
10#include <linux/bitfield.h>10#include <linux/bitfield.h>
11#include <linux/clk.h>
12#include <linux/delay.h>
13#include <linux/module.h>
11#include <linux/of.h>14#include <linux/of.h>
12#include <linux/of_address.h>15#include <linux/of_address.h>
13#include <linux/of_device.h>16#include <linux/of_device.h>
@@ -19,7 +22,6 @@ · 5 unmodified lines
19#include <linux/soc/mediatek/mtk_sip_svc.h>22#include <linux/soc/mediatek/mtk_sip_svc.h>
20 23
21#include "ufshcd.h"24#include "ufshcd.h"
22#include "ufshcd-crypto.h"
23#include "ufshcd-pltfrm.h"25#include "ufshcd-pltfrm.h"
24#include "ufs_quirks.h"26#include "ufs_quirks.h"
25#include "unipro.h"27#include "unipro.h"
@@ -44,12 +46,14 @@ · 18 unmodified lines
44#define ufs_mtk_device_reset_ctrl(high, res) \46#define ufs_mtk_device_reset_ctrl(high, res) \
45 ufs_mtk_smc(UFS_MTK_SIP_DEVICE_RESET, high, res)47 ufs_mtk_smc(UFS_MTK_SIP_DEVICE_RESET, high, res)
46 48
47static struct ufs_dev_fix ufs_mtk_dev_fixups[] = {49static const struct ufs_dev_quirk ufs_mtk_dev_fixups[] = {
48 UFS_FIX(UFS_VENDOR_MICRON, UFS_ANY_MODEL,50 { .wmanufacturerid = UFS_VENDOR_MICRON,
49 UFS_DEVICE_QUIRK_DELAY_AFTER_LPM),51 .model = UFS_ANY_MODEL,
50 UFS_FIX(UFS_VENDOR_SKHYNIX, "H9HQ21AFAMZDAR",52 .quirk = UFS_DEVICE_QUIRK_DELAY_AFTER_LPM },
51 UFS_DEVICE_QUIRK_SUPPORT_EXTENDED_FEATURES),53 { .wmanufacturerid = UFS_VENDOR_SKHYNIX,
52 END_FIX54 .model = "H9HQ21AFAMZDAR",
55 .quirk = UFS_DEVICE_QUIRK_SUPPORT_EXTENDED_FEATURES },
56 {}
53};57};
54 58
55static const struct of_device_id ufs_mtk_of_match[] = {59static const struct of_device_id ufs_mtk_of_match[] = {
@@ -169,7 +173,6 @@ static int ufs_mtk_hce_enable_notify(struct ufs_hba *hba, · 113 unmodified lines
169 enum ufs_notify_change_status status)173 enum ufs_notify_change_status status)
170{174{
171 struct ufs_mtk_host *host = ufshcd_get_variant(hba);175 struct ufs_mtk_host *host = ufshcd_get_variant(hba);
172 unsigned long flags;
173 176
174 if (status == PRE_CHANGE) {177 if (status == PRE_CHANGE) {
175 if (host->unipro_lpm) {178 if (host->unipro_lpm) {
@@ -183,12 +186,8 @@ static int ufs_mtk_hce_enable_notify(struct ufs_hba *hba, · 7 unmodified lines
183 ufs_mtk_crypto_enable(hba);186 ufs_mtk_crypto_enable(hba);
184 187
185 if (host->caps & UFS_MTK_CAP_DISABLE_AH8) {188 if (host->caps & UFS_MTK_CAP_DISABLE_AH8) {
186 spin_lock_irqsave(hba->host->host_lock, flags);
187 ufshcd_writel(hba, 0,189 ufshcd_writel(hba, 0,
188 REG_AUTO_HIBERNATE_IDLE_TIMER);190 REG_AUTO_HIBERNATE_IDLE_TIMER);
189 spin_unlock_irqrestore(hba->host->host_lock,
190 flags);
191
192 hba->capabilities &= ~MASK_AUTO_HIBERN8_SUPPORT;191 hba->capabilities &= ~MASK_AUTO_HIBERN8_SUPPORT;
193 hba->ahit = 0;192 hba->ahit = 0;
194 }193 }
@@ -860,7 +859,6 @@ static int ufs_mtk_pre_link(struct ufs_hba *hba) · 665 unmodified lines
860 859
861static void ufs_mtk_setup_clk_gating(struct ufs_hba *hba)860static void ufs_mtk_setup_clk_gating(struct ufs_hba *hba)
862{861{
863 unsigned long flags;
864 u32 ah_ms;862 u32 ah_ms;
865 863
866 if (ufshcd_is_clkgating_allowed(hba)) {864 if (ufshcd_is_clkgating_allowed(hba)) {
@@ -869,9 +867,7 @@ static void ufs_mtk_setup_clk_gating(struct ufs_hba *hba) · 2 unmodified lines
869 hba->ahit);867 hba->ahit);
870 else868 else
871 ah_ms = 10;869 ah_ms = 10;
872 spin_lock_irqsave(hba->host->host_lock, flags);870 ufshcd_clkgate_delay_set(hba->dev, ah_ms + 5);
873 hba->clk_gating.delay_ms = ah_ms + 5;
874 spin_unlock_irqrestore(hba->host->host_lock, flags);
875 }871 }
876}872}
877 873
@@ -992,13 +988,10 @@ static void ufs_mtk_vreg_set_lpm(struct ufs_hba *hba, bool lpm) · 114 unmodified lines
992 988
993static void ufs_mtk_auto_hibern8_disable(struct ufs_hba *hba)989static void ufs_mtk_auto_hibern8_disable(struct ufs_hba *hba)
994{990{
995 unsigned long flags;
996 int ret;991 int ret;
997 992
998 /* disable auto-hibern8 */993 /* disable auto-hibern8 */
999 spin_lock_irqsave(hba->host->host_lock, flags);
1000 ufshcd_writel(hba, 0, REG_AUTO_HIBERNATE_IDLE_TIMER);994 ufshcd_writel(hba, 0, REG_AUTO_HIBERNATE_IDLE_TIMER);
1001 spin_unlock_irqrestore(hba->host->host_lock, flags);
1002 995
1003 /* wait host return to idle state when auto-hibern8 off */996 /* wait host return to idle state when auto-hibern8 off */
1004 ufs_mtk_wait_idle_state(hba, 5);997 ufs_mtk_wait_idle_state(hba, 5);
drivers/scsi/ufs/ufs-qcom-ice.c+1−1
@@ -6,10 +6,10 @@ · 5 unmodified lines
6 * Copyright 2019 Google LLC6 * Copyright 2019 Google LLC
7 */7 */
8 8
9#include <linux/delay.h>
9#include <linux/platform_device.h>10#include <linux/platform_device.h>
10#include <linux/qcom_scm.h>11#include <linux/qcom_scm.h>
11 12
12#include "ufshcd-crypto.h"
13#include "ufs-qcom.h"13#include "ufs-qcom.h"
14 14
15#define AES_256_XTS_KEY_SIZE 6415#define AES_256_XTS_KEY_SIZE 64
drivers/scsi/ufs/ufs-qcom.c+25−48
@@ -5,6 +5,9 @@ · 4 unmodified lines
5 5
6#include <linux/acpi.h>6#include <linux/acpi.h>
7#include <linux/time.h>7#include <linux/time.h>
8#include <linux/clk.h>
9#include <linux/delay.h>
10#include <linux/module.h>
8#include <linux/of.h>11#include <linux/of.h>
9#include <linux/platform_device.h>12#include <linux/platform_device.h>
10#include <linux/phy/phy.h>13#include <linux/phy/phy.h>
@@ -18,6 +21,7 @@ · 7 unmodified lines
18#include "ufs-qcom.h"21#include "ufs-qcom.h"
19#include "ufshci.h"22#include "ufshci.h"
20#include "ufs_quirks.h"23#include "ufs_quirks.h"
24
21#define UFS_QCOM_DEFAULT_DBG_PRINT_EN \25#define UFS_QCOM_DEFAULT_DBG_PRINT_EN \
22 (UFS_QCOM_DBG_PRINT_REGS_EN | UFS_QCOM_DBG_PRINT_TEST_BUS_EN)26 (UFS_QCOM_DBG_PRINT_REGS_EN | UFS_QCOM_DBG_PRINT_TEST_BUS_EN)
23 27
@@ -299,8 +303,7 @@ static int ufs_qcom_power_up_sequence(struct ufs_hba *hba) · 275 unmodified lines
299 struct ufs_qcom_host *host = ufshcd_get_variant(hba);303 struct ufs_qcom_host *host = ufshcd_get_variant(hba);
300 struct phy *phy = host->generic_phy;304 struct phy *phy = host->generic_phy;
301 int ret = 0;305 int ret = 0;
302 bool is_rate_B = (UFS_QCOM_LIMIT_HS_RATE == PA_HS_MODE_B)306 bool is_rate_B = UFS_QCOM_LIMIT_HS_RATE == PA_HS_MODE_B;
303 ? true : false;
304 307
305 /* Reset UFS Host Controller and PHY */308 /* Reset UFS Host Controller and PHY */
306 ret = ufs_qcom_host_reset(hba);309 ret = ufs_qcom_host_reset(hba);
@@ -641,12 +644,7 @@ static int ufs_qcom_resume(struct ufs_hba *hba, enum ufs_pm_op pm_op) · 334 unmodified lines
641 return err;644 return err;
642 }645 }
643 646
644 err = ufs_qcom_ice_resume(host);647 return ufs_qcom_ice_resume(host);
645 if (err)
646 return err;
647
648 hba->is_sys_suspended = false;
649 return 0;
650}648}
651 649
652static void ufs_qcom_dev_ref_clk_ctrl(struct ufs_qcom_host *host, bool enable)650static void ufs_qcom_dev_ref_clk_ctrl(struct ufs_qcom_host *host, bool enable)
@@ -687,8 +685,11 @@ static void ufs_qcom_dev_ref_clk_ctrl(struct ufs_qcom_host *host, bool enable) · 34 unmodified lines
687 685
688 writel_relaxed(temp, host->dev_ref_clk_ctrl_mmio);686 writel_relaxed(temp, host->dev_ref_clk_ctrl_mmio);
689 687
690 /* ensure that ref_clk is enabled/disabled before we return */688 /*
691 wmb();689 * Make sure the write to ref_clk reaches the destination and
690 * not stored in a Write Buffer (WB).
691 */
692 readl(host->dev_ref_clk_ctrl_mmio);
692 693
693 /*694 /*
694 * If we call hibern8 exit after this, we need to make sure that695 * If we call hibern8 exit after this, we need to make sure that
@@ -873,6 +874,7 @@ static void ufs_qcom_set_caps(struct ufs_hba *hba) · 178 unmodified lines
873 hba->caps |= UFSHCD_CAP_WB_EN;874 hba->caps |= UFSHCD_CAP_WB_EN;
874 hba->caps |= UFSHCD_CAP_CRYPTO;875 hba->caps |= UFSHCD_CAP_CRYPTO;
875 hba->caps |= UFSHCD_CAP_AGGR_POWER_COLLAPSE;876 hba->caps |= UFSHCD_CAP_AGGR_POWER_COLLAPSE;
877 hba->caps |= UFSHCD_CAP_RPM_AUTOSUSPEND;
876 878
877 if (host->hw_ver.major >= 0x2) {879 if (host->hw_ver.major >= 0x2) {
878 host->caps = UFS_QCOM_CAP_QUNIPRO |880 host->caps = UFS_QCOM_CAP_QUNIPRO |
@@ -987,13 +989,12 @@ static int ufs_qcom_init(struct ufs_hba *hba) · 108 unmodified lines
987 host->hba = hba;989 host->hba = hba;
988 ufshcd_set_variant(hba, host);990 ufshcd_set_variant(hba, host);
989 991
990 /* Setup the reset control of HCI */992 /* Setup the optional reset control of HCI */
991 host->core_reset = devm_reset_control_get(hba->dev, "rst");993 host->core_reset = devm_reset_control_get_optional(hba->dev, "rst");
992 if (IS_ERR(host->core_reset)) {994 if (IS_ERR(host->core_reset)) {
993 err = PTR_ERR(host->core_reset);995 err = dev_err_probe(dev, PTR_ERR(host->core_reset),
994 dev_warn(dev, "Failed to get reset control %d\n", err);996 "Failed to get reset control\n");
995 host->core_reset = NULL;997 goto out_variant_clear;
996 err = 0;
997 }998 }
998 999
999 /* Fire up the reset controller. Failure here is non-fatal. */1000 /* Fire up the reset controller. Failure here is non-fatal. */
@@ -1007,28 +1008,10 @@ static int ufs_qcom_init(struct ufs_hba *hba) · 7 unmodified lines
1007 err = 0;1008 err = 0;
1008 }1009 }
1009 1010
1010 /*1011 if (!has_acpi_companion(dev)) {
1011 * voting/devoting device ref_clk source is time consuming hence1012 host->generic_phy = devm_phy_get(dev, "ufsphy");
1012 * skip devoting it during aggressive clock gating. This clock1013 if (IS_ERR(host->generic_phy)) {
1013 * will still be gated off during runtime suspend.1014 err = dev_err_probe(dev, PTR_ERR(host->generic_phy), "Failed to get PHY\n");
1014 */
1015 host->generic_phy = devm_phy_get(dev, "ufsphy");
1016
1017 if (host->generic_phy == ERR_PTR(-EPROBE_DEFER)) {
1018 /*
1019 * UFS driver might be probed before the phy driver does.
1020 * In that case we would like to return EPROBE_DEFER code.
1021 */
1022 err = -EPROBE_DEFER;
1023 dev_warn(dev, "%s: required phy device. hasn't probed yet. err = %d\n",
1024 __func__, err);
1025 goto out_variant_clear;
1026 } else if (IS_ERR(host->generic_phy)) {
1027 if (has_acpi_companion(dev)) {
1028 host->generic_phy = NULL;
1029 } else {
1030 err = PTR_ERR(host->generic_phy);
1031 dev_err(dev, "%s: PHY get failed %d\n", __func__, err);
1032 goto out_variant_clear;1015 goto out_variant_clear;
1033 }1016 }
1034 }1017 }
@@ -1449,23 +1432,17 @@ static int ufs_qcom_device_reset(struct ufs_hba *hba) · 414 unmodified lines
1449 1432
1450#if IS_ENABLED(CONFIG_DEVFREQ_GOV_SIMPLE_ONDEMAND)1433#if IS_ENABLED(CONFIG_DEVFREQ_GOV_SIMPLE_ONDEMAND)
1451static void ufs_qcom_config_scaling_param(struct ufs_hba *hba,1434static void ufs_qcom_config_scaling_param(struct ufs_hba *hba,
1452 struct devfreq_dev_profile *p,1435 struct devfreq_dev_profile *p,
1453 void *data)1436 struct devfreq_simple_ondemand_data *d)
1454{1437{
1455 static struct devfreq_simple_ondemand_data *d;
1456
1457 if (!data)
1458 return;
1459
1460 d = (struct devfreq_simple_ondemand_data *)data;
1461 p->polling_ms = 60;1438 p->polling_ms = 60;
1462 d->upthreshold = 70;1439 d->upthreshold = 70;
1463 d->downdifferential = 5;1440 d->downdifferential = 5;
1464}1441}
1465#else1442#else
1466static void ufs_qcom_config_scaling_param(struct ufs_hba *hba,1443static void ufs_qcom_config_scaling_param(struct ufs_hba *hba,
1467 struct devfreq_dev_profile *p,1444 struct devfreq_dev_profile *p,
1468 void *data)1445 struct devfreq_simple_ondemand_data *data)
1469{1446{
1470}1447}
1471#endif1448#endif
drivers/scsi/ufs/ufs-qcom.h+2−4
@@ -7,6 +7,7 @@ · 6 unmodified lines
7 7
8#include <linux/reset-controller.h>8#include <linux/reset-controller.h>
9#include <linux/reset.h>9#include <linux/reset.h>
10#include "ufshcd.h"
10 11
11#define MAX_UFS_QCOM_HOSTS 112#define MAX_UFS_QCOM_HOSTS 1
12#define MAX_U32 (~(u32)0)13#define MAX_U32 (~(u32)0)
@@ -239,10 +240,7 @@ int ufs_qcom_testbus_config(struct ufs_qcom_host *host); · 226 unmodified lines
239 240
240static inline bool ufs_qcom_cap_qunipro(struct ufs_qcom_host *host)241static inline bool ufs_qcom_cap_qunipro(struct ufs_qcom_host *host)
241{242{
242 if (host->caps & UFS_QCOM_CAP_QUNIPRO)243 return host->caps & UFS_QCOM_CAP_QUNIPRO;
243 return true;
244 else
245 return false;
246}244}
247 245
248/* ufs-qcom-ice.c */246/* ufs-qcom-ice.c */
drivers/scsi/ufs/ufs-sysfs.c+1−0
@@ -8,6 +8,7 @@ · 7 unmodified lines
8 8
9#include "ufs.h"9#include "ufs.h"
10#include "ufs-sysfs.h"10#include "ufs-sysfs.h"
11#include "ufshcd-priv.h"
11 12
12static const char *ufshcd_uic_link_state_to_string(13static const char *ufshcd_uic_link_state_to_string(
13 enum uic_link_state state)14 enum uic_link_state state)
drivers/scsi/ufs/ufs-sysfs.h+2−1
@@ -7,11 +7,12 @@ · 6 unmodified lines
7 7
8#include <linux/sysfs.h>8#include <linux/sysfs.h>
9 9
10#include "ufshcd.h"10struct device;
11 11
12void ufs_sysfs_add_nodes(struct device *dev);12void ufs_sysfs_add_nodes(struct device *dev);
13void ufs_sysfs_remove_nodes(struct device *dev);13void ufs_sysfs_remove_nodes(struct device *dev);
14 14
15extern const struct attribute_group ufs_sysfs_unit_descriptor_group;15extern const struct attribute_group ufs_sysfs_unit_descriptor_group;
16extern const struct attribute_group ufs_sysfs_lun_attributes_group;16extern const struct attribute_group ufs_sysfs_lun_attributes_group;
17
17#endif18#endif
drivers/scsi/ufs/ufs.h+0−35
@@ -415,11 +415,6 @@ enum ufs_ref_clk_freq { · 414 unmodified lines
415 REF_CLK_FREQ_INVAL = -1,415 REF_CLK_FREQ_INVAL = -1,
416};416};
417 417
418struct ufs_ref_clk {
419 unsigned long freq_hz;
420 enum ufs_ref_clk_freq val;
421};
422
423/* Query response result code */418/* Query response result code */
424enum {419enum {
425 QUERY_RESULT_SUCCESS = 0x00,420 QUERY_RESULT_SUCCESS = 0x00,
@@ -562,15 +557,6 @@ struct ufs_query_res { · 136 unmodified lines
562 struct utp_upiu_query upiu_res;557 struct utp_upiu_query upiu_res;
563};558};
564 559
565#define UFS_VREG_VCC_MIN_UV 2700000 /* uV */
566#define UFS_VREG_VCC_MAX_UV 3600000 /* uV */
567#define UFS_VREG_VCC_1P8_MIN_UV 1700000 /* uV */
568#define UFS_VREG_VCC_1P8_MAX_UV 1950000 /* uV */
569#define UFS_VREG_VCCQ_MIN_UV 1140000 /* uV */
570#define UFS_VREG_VCCQ_MAX_UV 1260000 /* uV */
571#define UFS_VREG_VCCQ2_MIN_UV 1700000 /* uV */
572#define UFS_VREG_VCCQ2_MAX_UV 1950000 /* uV */
573
574/*560/*
575 * VCCQ & VCCQ2 current requirement when UFS device is in sleep state561 * VCCQ & VCCQ2 current requirement when UFS device is in sleep state
576 * and link is in Hibern8 state.562 * and link is in Hibern8 state.
@@ -582,8 +568,6 @@ struct ufs_vreg { · 5 unmodified lines
582 const char *name;568 const char *name;
583 bool always_on;569 bool always_on;
584 bool enabled;570 bool enabled;
585 int min_uV;
586 int max_uV;
587 int max_uA;571 int max_uA;
588};572};
589 573
@@ -636,23 +620,4 @@ enum ufs_trace_tsf_t { · 46 unmodified lines
636 UFS_TSF_CDB, UFS_TSF_OSF, UFS_TSF_TM_INPUT, UFS_TSF_TM_OUTPUT620 UFS_TSF_CDB, UFS_TSF_OSF, UFS_TSF_TM_INPUT, UFS_TSF_TM_OUTPUT
637};621};
638 622
639/**
640 * ufs_is_valid_unit_desc_lun - checks if the given LUN has a unit descriptor
641 * @dev_info: pointer of instance of struct ufs_dev_info
642 * @lun: LU number to check
643 * @return: true if the lun has a matching unit descriptor, false otherwise
644 */
645static inline bool ufs_is_valid_unit_desc_lun(struct ufs_dev_info *dev_info,
646 u8 lun, u8 param_offset)
647{
648 if (!dev_info || !dev_info->max_lu_supported) {
649 pr_err("Max General LU supported by UFS isn't initialized\n");
650 return false;
651 }
652 /* WB is available only for the logical unit from 0 to 7 */
653 if (param_offset == UNIT_DESC_PARAM_WB_BUF_ALLOC_UNITS)
654 return lun < UFS_UPIU_MAX_WB_LUN_ID;
655 return lun == UFS_UPIU_RPMB_WLUN || (lun < dev_info->max_lu_supported);
656}
657
658#endif /* End of Header */623#endif /* End of Header */
drivers/scsi/ufs/ufs_bsg.c+6−0
@@ -4,7 +4,13 @@ · 3 unmodified lines
4 *4 *
5 * Copyright (C) 2018 Western Digital Corporation5 * Copyright (C) 2018 Western Digital Corporation
6 */6 */
7
8#include <linux/bsg-lib.h>
9#include <scsi/scsi.h>
10#include <scsi/scsi_host.h>
7#include "ufs_bsg.h"11#include "ufs_bsg.h"
12#include "ufshcd.h"
13#include "ufshcd-priv.h"
8 14
9static int ufs_bsg_get_query_desc_size(struct ufs_hba *hba, int *desc_len,15static int ufs_bsg_get_query_desc_size(struct ufs_hba *hba, int *desc_len,
10 struct utp_upiu_query *qr)16 struct utp_upiu_query *qr)
drivers/scsi/ufs/ufs_bsg.h+1−6
@@ -5,12 +5,7 @@ · 4 unmodified lines
5#ifndef UFS_BSG_H5#ifndef UFS_BSG_H
6#define UFS_BSG_H6#define UFS_BSG_H
7 7
8#include <linux/bsg-lib.h>8struct ufs_hba;
9#include <scsi/scsi.h>
10#include <scsi/scsi_host.h>
11
12#include "ufshcd.h"
13#include "ufs.h"
14 9
15#ifdef CONFIG_SCSI_UFS_BSG10#ifdef CONFIG_SCSI_UFS_BSG
16void ufs_bsg_remove(struct ufs_hba *hba);11void ufs_bsg_remove(struct ufs_hba *hba);
drivers/scsi/ufs/ufs_quirks.h+3−12
@@ -19,25 +19,16 @@ · 18 unmodified lines
19#define UFS_VENDOR_WDC 0x14519#define UFS_VENDOR_WDC 0x145
20 20
21/**21/**
22 * ufs_dev_fix - ufs device quirk info22 * ufs_dev_quirk - ufs device quirk info
23 * @card: ufs card details23 * @card: ufs card details
24 * @quirk: device quirk24 * @quirk: device quirk
25 */25 */
26struct ufs_dev_fix {26struct ufs_dev_quirk {
27 u16 wmanufacturerid;27 u16 wmanufacturerid;
28 u8 *model;28 const u8 *model;
29 unsigned int quirk;29 unsigned int quirk;
30};30};
31 31
32#define END_FIX { }
33
34/* add specific device quirk */
35#define UFS_FIX(_vendor, _model, _quirk) { \
36 .wmanufacturerid = (_vendor),\
37 .model = (_model), \
38 .quirk = (_quirk), \
39}
40
41/*32/*
42 * Some vendor's UFS device sends back to back NACs for the DL data frames33 * Some vendor's UFS device sends back to back NACs for the DL data frames
43 * causing the host controller to raise the DFES error status. Sometimes34 * causing the host controller to raise the DFES error status. Sometimes
drivers/scsi/ufs/ufshcd-crypto.h+4−1
@@ -6,10 +6,13 @@ · 5 unmodified lines
6#ifndef _UFSHCD_CRYPTO_H6#ifndef _UFSHCD_CRYPTO_H
7#define _UFSHCD_CRYPTO_H7#define _UFSHCD_CRYPTO_H
8 8
9#ifdef CONFIG_SCSI_UFS_CRYPTO9#include <scsi/scsi_cmnd.h>
10#include "ufshcd.h"10#include "ufshcd.h"
11#include "ufshcd-priv.h"
11#include "ufshci.h"12#include "ufshci.h"
12 13
14#ifdef CONFIG_SCSI_UFS_CRYPTO
15
13static inline void ufshcd_prepare_lrbp_crypto(struct request *rq,16static inline void ufshcd_prepare_lrbp_crypto(struct request *rq,
14 struct ufshcd_lrb *lrbp)17 struct ufshcd_lrb *lrbp)
15{18{
drivers/scsi/ufs/ufshcd-dwc.c+2−0
@@ -7,6 +7,8 @@ · 6 unmodified lines
7 * Authors: Joao Pinto <jpinto@synopsys.com>7 * Authors: Joao Pinto <jpinto@synopsys.com>
8 */8 */
9 9
10#include <linux/module.h>
11
10#include "ufshcd.h"12#include "ufshcd.h"
11#include "unipro.h"13#include "unipro.h"
12 14
drivers/scsi/ufs/ufshcd-dwc.h+2−0
@@ -10,6 +10,8 @@ · 9 unmodified lines
10#ifndef _UFSHCD_DWC_H10#ifndef _UFSHCD_DWC_H
11#define _UFSHCD_DWC_H11#define _UFSHCD_DWC_H
12 12
13#include "ufshcd.h"
14
13struct ufshcd_dme_attr_val {15struct ufshcd_dme_attr_val {
14 u32 attr_sel;16 u32 attr_sel;
15 u32 mib_val;17 u32 mib_val;
drivers/scsi/ufs/ufshcd-pci.c+2−2
@@ -2,7 +2,6 @@ · 1 unmodified line
2/*2/*
3 * Universal Flash Storage Host controller PCI glue driver3 * Universal Flash Storage Host controller PCI glue driver
4 *4 *
5 * This code is based on drivers/scsi/ufs/ufshcd-pci.c
6 * Copyright (C) 2011-2013 Samsung India Software Operations5 * Copyright (C) 2011-2013 Samsung India Software Operations
7 *6 *
8 * Authors:7 * Authors:
@@ -11,6 +10,8 @@ · 2 unmodified lines
11 */10 */
12 11
13#include "ufshcd.h"12#include "ufshcd.h"
13#include <linux/delay.h>
14#include <linux/module.h>
14#include <linux/pci.h>15#include <linux/pci.h>
15#include <linux/pm_runtime.h>16#include <linux/pm_runtime.h>
16#include <linux/pm_qos.h>17#include <linux/pm_qos.h>
@@ -618,4 +619,3 @@ MODULE_AUTHOR("Santosh Yaragnavi <santosh.sy@samsung.com>"); · 601 unmodified lines
618MODULE_AUTHOR("Vinayak Holikatti <h.vinayak@samsung.com>");619MODULE_AUTHOR("Vinayak Holikatti <h.vinayak@samsung.com>");
619MODULE_DESCRIPTION("UFS host controller PCI glue driver");620MODULE_DESCRIPTION("UFS host controller PCI glue driver");
620MODULE_LICENSE("GPL");621MODULE_LICENSE("GPL");
621MODULE_VERSION(UFSHCD_DRIVER_VERSION);
drivers/scsi/ufs/ufshcd-pltfrm.c+20−18
@@ -8,6 +8,7 @@ · 7 unmodified lines
8 * Vinayak Holikatti <h.vinayak@samsung.com>8 * Vinayak Holikatti <h.vinayak@samsung.com>
9 */9 */
10 10
11#include <linux/module.h>
11#include <linux/platform_device.h>12#include <linux/platform_device.h>
12#include <linux/pm_runtime.h>13#include <linux/pm_runtime.h>
13#include <linux/of.h>14#include <linux/of.h>
@@ -297,18 +298,20 @@ EXPORT_SYMBOL_GPL(ufshcd_get_pwr_dev_param); · 283 unmodified lines
297 298
298void ufshcd_init_pwr_dev_param(struct ufs_dev_params *dev_param)299void ufshcd_init_pwr_dev_param(struct ufs_dev_params *dev_param)
299{300{
300 dev_param->tx_lanes = 2;301 *dev_param = (struct ufs_dev_params){
301 dev_param->rx_lanes = 2;302 .tx_lanes = 2,
302 dev_param->hs_rx_gear = UFS_HS_G3;303 .rx_lanes = 2,
303 dev_param->hs_tx_gear = UFS_HS_G3;304 .hs_rx_gear = UFS_HS_G3,
304 dev_param->pwm_rx_gear = UFS_PWM_G4;305 .hs_tx_gear = UFS_HS_G3,
305 dev_param->pwm_tx_gear = UFS_PWM_G4;306 .pwm_rx_gear = UFS_PWM_G4,
306 dev_param->rx_pwr_pwm = SLOW_MODE;307 .pwm_tx_gear = UFS_PWM_G4,
307 dev_param->tx_pwr_pwm = SLOW_MODE;308 .rx_pwr_pwm = SLOW_MODE,
308 dev_param->rx_pwr_hs = FAST_MODE;309 .tx_pwr_pwm = SLOW_MODE,
309 dev_param->tx_pwr_hs = FAST_MODE;310 .rx_pwr_hs = FAST_MODE,
310 dev_param->hs_rate = PA_HS_MODE_B;311 .tx_pwr_hs = FAST_MODE,
311 dev_param->desired_working_mode = UFS_HS_MODE;312 .hs_rate = PA_HS_MODE_B,
313 .desired_working_mode = UFS_HS_MODE,
314 };
312}315}
313EXPORT_SYMBOL_GPL(ufshcd_init_pwr_dev_param);316EXPORT_SYMBOL_GPL(ufshcd_init_pwr_dev_param);
314 317
@@ -341,7 +344,7 @@ int ufshcd_pltfrm_init(struct platform_device *pdev, · 26 unmodified lines
341 344
342 err = ufshcd_alloc_host(dev, &hba);345 err = ufshcd_alloc_host(dev, &hba);
343 if (err) {346 if (err) {
344 dev_err(&pdev->dev, "Allocation failed\n");347 dev_err(dev, "Allocation failed\n");
345 goto out;348 goto out;
346 }349 }
347 350
@@ -349,13 +352,13 @@ int ufshcd_pltfrm_init(struct platform_device *pdev, · 1 unmodified line
349 352
350 err = ufshcd_parse_clock_info(hba);353 err = ufshcd_parse_clock_info(hba);
351 if (err) {354 if (err) {
352 dev_err(&pdev->dev, "%s: clock parse failed %d\n",355 dev_err(dev, "%s: clock parse failed %d\n",
353 __func__, err);356 __func__, err);
354 goto dealloc_host;357 goto dealloc_host;
355 }358 }
356 err = ufshcd_parse_regulator_info(hba);359 err = ufshcd_parse_regulator_info(hba);
357 if (err) {360 if (err) {
358 dev_err(&pdev->dev, "%s: regulator init failed %d\n",361 dev_err(dev, "%s: regulator init failed %d\n",
359 __func__, err);362 __func__, err);
360 goto dealloc_host;363 goto dealloc_host;
361 }364 }
@@ -368,8 +371,8 @@ int ufshcd_pltfrm_init(struct platform_device *pdev, · 6 unmodified lines
368 goto dealloc_host;371 goto dealloc_host;
369 }372 }
370 373
371 pm_runtime_set_active(&pdev->dev);374 pm_runtime_set_active(dev);
372 pm_runtime_enable(&pdev->dev);375 pm_runtime_enable(dev);
373 376
374 return 0;377 return 0;
375 378
@@ -384,4 +387,3 @@ MODULE_AUTHOR("Santosh Yaragnavi <santosh.sy@samsung.com>"); · 8 unmodified lines
384MODULE_AUTHOR("Vinayak Holikatti <h.vinayak@samsung.com>");387MODULE_AUTHOR("Vinayak Holikatti <h.vinayak@samsung.com>");
385MODULE_DESCRIPTION("UFS host controller Platform bus based glue driver");388MODULE_DESCRIPTION("UFS host controller Platform bus based glue driver");
386MODULE_LICENSE("GPL");389MODULE_LICENSE("GPL");
387MODULE_VERSION(UFSHCD_DRIVER_VERSION);
drivers/scsi/ufs/ufshcd-priv.h+298−0
@@ -0,0 +1,298 @@
1/* SPDX-License-Identifier: GPL-2.0-or-later */
2
3#ifndef _UFSHCD_PRIV_H_
4#define _UFSHCD_PRIV_H_
5
6#include <linux/pm_runtime.h>
7#include "ufshcd.h"
8
9static inline bool ufshcd_is_user_access_allowed(struct ufs_hba *hba)
10{
11 return !hba->shutting_down;
12}
13
14void ufshcd_schedule_eh_work(struct ufs_hba *hba);
15
16static inline bool ufshcd_keep_autobkops_enabled_except_suspend(
17 struct ufs_hba *hba)
18{
19 return hba->caps & UFSHCD_CAP_KEEP_AUTO_BKOPS_ENABLED_EXCEPT_SUSPEND;
20}
21
22static inline u8 ufshcd_wb_get_query_index(struct ufs_hba *hba)
23{
24 if (hba->dev_info.wb_buffer_type == WB_BUF_MODE_LU_DEDICATED)
25 return hba->dev_info.wb_dedicated_lu;
26 return 0;
27}
28
29#ifdef CONFIG_SCSI_UFS_HWMON
30void ufs_hwmon_probe(struct ufs_hba *hba, u8 mask);
31void ufs_hwmon_remove(struct ufs_hba *hba);
32void ufs_hwmon_notify_event(struct ufs_hba *hba, u8 ee_mask);
33#else
34static inline void ufs_hwmon_probe(struct ufs_hba *hba, u8 mask) {}
35static inline void ufs_hwmon_remove(struct ufs_hba *hba) {}
36static inline void ufs_hwmon_notify_event(struct ufs_hba *hba, u8 ee_mask) {}
37#endif
38
39int ufshcd_read_desc_param(struct ufs_hba *hba,
40 enum desc_idn desc_id,
41 int desc_index,
42 u8 param_offset,
43 u8 *param_read_buf,
44 u8 param_size);
45int ufshcd_query_attr_retry(struct ufs_hba *hba, enum query_opcode opcode,
46 enum attr_idn idn, u8 index, u8 selector,
47 u32 *attr_val);
48int ufshcd_query_attr(struct ufs_hba *hba, enum query_opcode opcode,
49 enum attr_idn idn, u8 index, u8 selector, u32 *attr_val);
50int ufshcd_query_flag(struct ufs_hba *hba, enum query_opcode opcode,
51 enum flag_idn idn, u8 index, bool *flag_res);
52void ufshcd_auto_hibern8_update(struct ufs_hba *hba, u32 ahit);
53
54#define SD_ASCII_STD true
55#define SD_RAW false
56int ufshcd_read_string_desc(struct ufs_hba *hba, u8 desc_index,
57 u8 **buf, bool ascii);
58
59int ufshcd_hold(struct ufs_hba *hba, bool async);
60void ufshcd_release(struct ufs_hba *hba);
61
62void ufshcd_map_desc_id_to_length(struct ufs_hba *hba, enum desc_idn desc_id,
63 int *desc_length);
64
65int ufshcd_send_uic_cmd(struct ufs_hba *hba, struct uic_command *uic_cmd);
66
67int ufshcd_exec_raw_upiu_cmd(struct ufs_hba *hba,
68 struct utp_upiu_req *req_upiu,
69 struct utp_upiu_req *rsp_upiu,
70 int msgcode,
71 u8 *desc_buff, int *buff_len,
72 enum query_opcode desc_op);
73
74int ufshcd_wb_toggle(struct ufs_hba *hba, bool enable);
75
76/* Wrapper functions for safely calling variant operations */
77static inline const char *ufshcd_get_var_name(struct ufs_hba *hba)
78{
79 if (hba->vops)
80 return hba->vops->name;
81 return "";
82}
83
84static inline void ufshcd_vops_exit(struct ufs_hba *hba)
85{
86 if (hba->vops && hba->vops->exit)
87 return hba->vops->exit(hba);
88}
89
90static inline u32 ufshcd_vops_get_ufs_hci_version(struct ufs_hba *hba)
91{
92 if (hba->vops && hba->vops->get_ufs_hci_version)
93 return hba->vops->get_ufs_hci_version(hba);
94
95 return ufshcd_readl(hba, REG_UFS_VERSION);
96}
97
98static inline int ufshcd_vops_clk_scale_notify(struct ufs_hba *hba,
99 bool up, enum ufs_notify_change_status status)
100{
101 if (hba->vops && hba->vops->clk_scale_notify)
102 return hba->vops->clk_scale_notify(hba, up, status);
103 return 0;
104}
105
106static inline void ufshcd_vops_event_notify(struct ufs_hba *hba,
107 enum ufs_event_type evt,
108 void *data)
109{
110 if (hba->vops && hba->vops->event_notify)
111 hba->vops->event_notify(hba, evt, data);
112}
113
114static inline int ufshcd_vops_setup_clocks(struct ufs_hba *hba, bool on,
115 enum ufs_notify_change_status status)
116{
117 if (hba->vops && hba->vops->setup_clocks)
118 return hba->vops->setup_clocks(hba, on, status);
119 return 0;
120}
121
122static inline int ufshcd_vops_hce_enable_notify(struct ufs_hba *hba,
123 bool status)
124{
125 if (hba->vops && hba->vops->hce_enable_notify)
126 return hba->vops->hce_enable_notify(hba, status);
127
128 return 0;
129}
130static inline int ufshcd_vops_link_startup_notify(struct ufs_hba *hba,
131 bool status)
132{
133 if (hba->vops && hba->vops->link_startup_notify)
134 return hba->vops->link_startup_notify(hba, status);
135
136 return 0;
137}
138
139static inline int ufshcd_vops_pwr_change_notify(struct ufs_hba *hba,
140 enum ufs_notify_change_status status,
141 struct ufs_pa_layer_attr *dev_max_params,
142 struct ufs_pa_layer_attr *dev_req_params)
143{
144 if (hba->vops && hba->vops->pwr_change_notify)
145 return hba->vops->pwr_change_notify(hba, status,
146 dev_max_params, dev_req_params);
147
148 return -ENOTSUPP;
149}
150
151static inline void ufshcd_vops_setup_task_mgmt(struct ufs_hba *hba,
152 int tag, u8 tm_function)
153{
154 if (hba->vops && hba->vops->setup_task_mgmt)
155 return hba->vops->setup_task_mgmt(hba, tag, tm_function);
156}
157
158static inline void ufshcd_vops_hibern8_notify(struct ufs_hba *hba,
159 enum uic_cmd_dme cmd,
160 enum ufs_notify_change_status status)
161{
162 if (hba->vops && hba->vops->hibern8_notify)
163 return hba->vops->hibern8_notify(hba, cmd, status);
164}
165
166static inline int ufshcd_vops_apply_dev_quirks(struct ufs_hba *hba)
167{
168 if (hba->vops && hba->vops->apply_dev_quirks)
169 return hba->vops->apply_dev_quirks(hba);
170 return 0;
171}
172
173static inline void ufshcd_vops_fixup_dev_quirks(struct ufs_hba *hba)
174{
175 if (hba->vops && hba->vops->fixup_dev_quirks)
176 hba->vops->fixup_dev_quirks(hba);
177}
178
179static inline int ufshcd_vops_suspend(struct ufs_hba *hba, enum ufs_pm_op op,
180 enum ufs_notify_change_status status)
181{
182 if (hba->vops && hba->vops->suspend)
183 return hba->vops->suspend(hba, op, status);
184
185 return 0;
186}
187
188static inline int ufshcd_vops_resume(struct ufs_hba *hba, enum ufs_pm_op op)
189{
190 if (hba->vops && hba->vops->resume)
191 return hba->vops->resume(hba, op);
192
193 return 0;
194}
195
196static inline void ufshcd_vops_dbg_register_dump(struct ufs_hba *hba)
197{
198 if (hba->vops && hba->vops->dbg_register_dump)
199 hba->vops->dbg_register_dump(hba);
200}
201
202static inline int ufshcd_vops_device_reset(struct ufs_hba *hba)
203{
204 if (hba->vops && hba->vops->device_reset)
205 return hba->vops->device_reset(hba);
206
207 return -EOPNOTSUPP;
208}
209
210static inline void ufshcd_vops_config_scaling_param(struct ufs_hba *hba,
211 struct devfreq_dev_profile *p,
212 struct devfreq_simple_ondemand_data *data)
213{
214 if (hba->vops && hba->vops->config_scaling_param)
215 hba->vops->config_scaling_param(hba, p, data);
216}
217
218extern struct ufs_pm_lvl_states ufs_pm_lvl_states[];
219
220/**
221 * ufshcd_scsi_to_upiu_lun - maps scsi LUN to UPIU LUN
222 * @scsi_lun: scsi LUN id
223 *
224 * Returns UPIU LUN id
225 */
226static inline u8 ufshcd_scsi_to_upiu_lun(unsigned int scsi_lun)
227{
228 if (scsi_is_wlun(scsi_lun))
229 return (scsi_lun & UFS_UPIU_MAX_UNIT_NUM_ID)
230 | UFS_UPIU_WLUN_ID;
231 else
232 return scsi_lun & UFS_UPIU_MAX_UNIT_NUM_ID;
233}
234
235int __ufshcd_write_ee_control(struct ufs_hba *hba, u32 ee_ctrl_mask);
236int ufshcd_write_ee_control(struct ufs_hba *hba);
237int ufshcd_update_ee_control(struct ufs_hba *hba, u16 *mask, u16 *other_mask,
238 u16 set, u16 clr);
239
240static inline int ufshcd_update_ee_drv_mask(struct ufs_hba *hba,
241 u16 set, u16 clr)
242{
243 return ufshcd_update_ee_control(hba, &hba->ee_drv_mask,
244 &hba->ee_usr_mask, set, clr);
245}
246
247static inline int ufshcd_update_ee_usr_mask(struct ufs_hba *hba,
248 u16 set, u16 clr)
249{
250 return ufshcd_update_ee_control(hba, &hba->ee_usr_mask,
251 &hba->ee_drv_mask, set, clr);
252}
253
254static inline int ufshcd_rpm_get_sync(struct ufs_hba *hba)
255{
256 return pm_runtime_get_sync(&hba->ufs_device_wlun->sdev_gendev);
257}
258
259static inline int ufshcd_rpm_put_sync(struct ufs_hba *hba)
260{
261 return pm_runtime_put_sync(&hba->ufs_device_wlun->sdev_gendev);
262}
263
264static inline void ufshcd_rpm_get_noresume(struct ufs_hba *hba)
265{
266 pm_runtime_get_noresume(&hba->ufs_device_wlun->sdev_gendev);
267}
268
269static inline int ufshcd_rpm_resume(struct ufs_hba *hba)
270{
271 return pm_runtime_resume(&hba->ufs_device_wlun->sdev_gendev);
272}
273
274static inline int ufshcd_rpm_put(struct ufs_hba *hba)
275{
276 return pm_runtime_put(&hba->ufs_device_wlun->sdev_gendev);
277}
278
279/**
280 * ufs_is_valid_unit_desc_lun - checks if the given LUN has a unit descriptor
281 * @dev_info: pointer of instance of struct ufs_dev_info
282 * @lun: LU number to check
283 * @return: true if the lun has a matching unit descriptor, false otherwise
284 */
285static inline bool ufs_is_valid_unit_desc_lun(struct ufs_dev_info *dev_info,
286 u8 lun, u8 param_offset)
287{
288 if (!dev_info || !dev_info->max_lu_supported) {
289 pr_err("Max General LU supported by UFS isn't initialized\n");
290 return false;
291 }
292 /* WB is available only for the logical unit from 0 to 7 */
293 if (param_offset == UNIT_DESC_PARAM_WB_BUF_ALLOC_UNITS)
294 return lun < UFS_UPIU_MAX_WB_LUN_ID;
295 return lun == UFS_UPIU_RPMB_WLUN || (lun < dev_info->max_lu_supported);
296}
297
298#endif /* _UFSHCD_PRIV_H_ */
drivers/scsi/ufs/ufshcd.c+116−131
@@ -16,8 +16,16 @@ · 15 unmodified lines
16#include <linux/bitfield.h>16#include <linux/bitfield.h>
17#include <linux/blk-pm.h>17#include <linux/blk-pm.h>
18#include <linux/blkdev.h>18#include <linux/blkdev.h>
19#include <linux/clk.h>
20#include <linux/delay.h>
21#include <linux/interrupt.h>
22#include <linux/module.h>
23#include <linux/regulator/consumer.h>
24#include <scsi/scsi_cmnd.h>
25#include <scsi/scsi_dbg.h>
19#include <scsi/scsi_driver.h>26#include <scsi/scsi_driver.h>
20#include "ufshcd.h"27#include <scsi/scsi_eh.h>
28#include "ufshcd-priv.h"
21#include "ufs_quirks.h"29#include "ufs_quirks.h"
22#include "unipro.h"30#include "unipro.h"
23#include "ufs-sysfs.h"31#include "ufs-sysfs.h"
@@ -113,8 +121,13 @@ int ufshcd_dump_regs(struct ufs_hba *hba, size_t offset, size_t len, · 89 unmodified lines
113 if (!regs)121 if (!regs)
114 return -ENOMEM;122 return -ENOMEM;
115 123
116 for (pos = 0; pos < len; pos += 4)124 for (pos = 0; pos < len; pos += 4) {
125 if (offset == 0 &&
126 pos >= REG_UIC_ERROR_CODE_PHY_ADAPTER_LAYER &&
127 pos <= REG_UIC_ERROR_CODE_DME)
128 continue;
117 regs[pos / 4] = ufshcd_readl(hba, offset + pos);129 regs[pos / 4] = ufshcd_readl(hba, offset + pos);
130 }
118 131
119 ufshcd_hex_dump(prefix, regs, len);132 ufshcd_hex_dump(prefix, regs, len);
120 kfree(regs);133 kfree(regs);
@@ -204,26 +217,33 @@ ufs_get_desired_pm_lvl_for_dev_link_state(enum ufs_dev_pwr_mode dev_state, · 83 unmodified lines
204 return UFS_PM_LVL_0;217 return UFS_PM_LVL_0;
205}218}
206 219
207static struct ufs_dev_fix ufs_fixups[] = {220static const struct ufs_dev_quirk ufs_fixups[] = {
208 /* UFS cards deviations table */221 /* UFS cards deviations table */
209 UFS_FIX(UFS_VENDOR_MICRON, UFS_ANY_MODEL,222 { .wmanufacturerid = UFS_VENDOR_MICRON,
210 UFS_DEVICE_QUIRK_DELAY_BEFORE_LPM |223 .model = UFS_ANY_MODEL,
211 UFS_DEVICE_QUIRK_SWAP_L2P_ENTRY_FOR_HPB_READ),224 .quirk = UFS_DEVICE_QUIRK_DELAY_BEFORE_LPM |
212 UFS_FIX(UFS_VENDOR_SAMSUNG, UFS_ANY_MODEL,225 UFS_DEVICE_QUIRK_SWAP_L2P_ENTRY_FOR_HPB_READ },
213 UFS_DEVICE_QUIRK_DELAY_BEFORE_LPM |226 { .wmanufacturerid = UFS_VENDOR_SAMSUNG,
214 UFS_DEVICE_QUIRK_HOST_PA_TACTIVATE |227 .model = UFS_ANY_MODEL,
215 UFS_DEVICE_QUIRK_RECOVERY_FROM_DL_NAC_ERRORS),228 .quirk = UFS_DEVICE_QUIRK_DELAY_BEFORE_LPM |
216 UFS_FIX(UFS_VENDOR_SKHYNIX, UFS_ANY_MODEL,229 UFS_DEVICE_QUIRK_HOST_PA_TACTIVATE |
217 UFS_DEVICE_QUIRK_HOST_PA_SAVECONFIGTIME),230 UFS_DEVICE_QUIRK_RECOVERY_FROM_DL_NAC_ERRORS },
218 UFS_FIX(UFS_VENDOR_SKHYNIX, "hB8aL1" /*H28U62301AMR*/,231 { .wmanufacturerid = UFS_VENDOR_SKHYNIX,
219 UFS_DEVICE_QUIRK_HOST_VS_DEBUGSAVECONFIGTIME),232 .model = UFS_ANY_MODEL,
220 UFS_FIX(UFS_VENDOR_TOSHIBA, UFS_ANY_MODEL,233 .quirk = UFS_DEVICE_QUIRK_HOST_PA_SAVECONFIGTIME },
221 UFS_DEVICE_QUIRK_DELAY_BEFORE_LPM),234 { .wmanufacturerid = UFS_VENDOR_SKHYNIX,
222 UFS_FIX(UFS_VENDOR_TOSHIBA, "THGLF2G9C8KBADG",235 .model = "hB8aL1" /*H28U62301AMR*/,
223 UFS_DEVICE_QUIRK_PA_TACTIVATE),236 .quirk = UFS_DEVICE_QUIRK_HOST_VS_DEBUGSAVECONFIGTIME },
224 UFS_FIX(UFS_VENDOR_TOSHIBA, "THGLF2G9D8KBADG",237 { .wmanufacturerid = UFS_VENDOR_TOSHIBA,
225 UFS_DEVICE_QUIRK_PA_TACTIVATE),238 .model = UFS_ANY_MODEL,
226 END_FIX239 .quirk = UFS_DEVICE_QUIRK_DELAY_BEFORE_LPM },
240 { .wmanufacturerid = UFS_VENDOR_TOSHIBA,
241 .model = "THGLF2G9C8KBADG",
242 .quirk = UFS_DEVICE_QUIRK_PA_TACTIVATE },
243 { .wmanufacturerid = UFS_VENDOR_TOSHIBA,
244 .model = "THGLF2G9D8KBADG",
245 .quirk = UFS_DEVICE_QUIRK_PA_TACTIVATE },
246 {}
227};247};
228 248
229static irqreturn_t ufshcd_tmc_handler(struct ufs_hba *hba);249static irqreturn_t ufshcd_tmc_handler(struct ufs_hba *hba);
@@ -533,7 +553,7 @@ static void ufshcd_print_tmrs(struct ufs_hba *hba, unsigned long bitmap) · 303 unmodified lines
533 553
534static void ufshcd_print_host_state(struct ufs_hba *hba)554static void ufshcd_print_host_state(struct ufs_hba *hba)
535{555{
536 struct scsi_device *sdev_ufs = hba->sdev_ufs_device;556 struct scsi_device *sdev_ufs = hba->ufs_device_wlun;
537 557
538 dev_err(hba->dev, "UFS Host state=%d\n", hba->ufshcd_state);558 dev_err(hba->dev, "UFS Host state=%d\n", hba->ufshcd_state);
539 dev_err(hba->dev, "outstanding reqs=0x%lx tasks=0x%lx\n",559 dev_err(hba->dev, "outstanding reqs=0x%lx tasks=0x%lx\n",
@@ -639,7 +659,7 @@ EXPORT_SYMBOL_GPL(ufshcd_delay_us); · 99 unmodified lines
639 * Return:659 * Return:
640 * -ETIMEDOUT on error, zero on success.660 * -ETIMEDOUT on error, zero on success.
641 */661 */
642int ufshcd_wait_for_register(struct ufs_hba *hba, u32 reg, u32 mask,662static int ufshcd_wait_for_register(struct ufs_hba *hba, u32 reg, u32 mask,
643 u32 val, unsigned long interval_us,663 u32 val, unsigned long interval_us,
644 unsigned long timeout_ms)664 unsigned long timeout_ms)
645{665{
@@ -712,8 +732,7 @@ static inline u32 ufshcd_get_ufs_version(struct ufs_hba *hba) · 66 unmodified lines
712 */732 */
713static inline bool ufshcd_is_device_present(struct ufs_hba *hba)733static inline bool ufshcd_is_device_present(struct ufs_hba *hba)
714{734{
715 return (ufshcd_readl(hba, REG_CONTROLLER_STATUS) &735 return ufshcd_readl(hba, REG_CONTROLLER_STATUS) & DEVICE_PRESENT;
716 DEVICE_PRESENT) ? true : false;
717}736}
718 737
719/**738/**
@@ -840,7 +859,7 @@ ufshcd_get_rsp_upiu_data_seg_len(struct utp_upiu_rsp *ucd_rsp_ptr) · 120 unmodified lines
840static inline bool ufshcd_is_exception_event(struct utp_upiu_rsp *ucd_rsp_ptr)859static inline bool ufshcd_is_exception_event(struct utp_upiu_rsp *ucd_rsp_ptr)
841{860{
842 return be32_to_cpu(ucd_rsp_ptr->header.dword_2) &861 return be32_to_cpu(ucd_rsp_ptr->header.dword_2) &
843 MASK_RSP_EXCEPTION_EVENT ? true : false;862 MASK_RSP_EXCEPTION_EVENT;
844}863}
845 864
846/**865/**
@@ -911,12 +930,11 @@ static inline void ufshcd_hba_start(struct ufs_hba *hba) · 64 unmodified lines
911 * ufshcd_is_hba_active - Get controller state930 * ufshcd_is_hba_active - Get controller state
912 * @hba: per adapter instance931 * @hba: per adapter instance
913 *932 *
914 * Returns false if controller is active, true otherwise933 * Returns true if and only if the controller is active.
915 */934 */
916static inline bool ufshcd_is_hba_active(struct ufs_hba *hba)935static inline bool ufshcd_is_hba_active(struct ufs_hba *hba)
917{936{
918 return (ufshcd_readl(hba, REG_CONTROLLER_ENABLE) & CONTROLLER_ENABLE)937 return ufshcd_readl(hba, REG_CONTROLLER_ENABLE) & CONTROLLER_ENABLE;
919 ? false : true;
920}938}
921 939
922u32 ufshcd_get_local_unipro_ver(struct ufs_hba *hba)940u32 ufshcd_get_local_unipro_ver(struct ufs_hba *hba)
@@ -940,10 +958,7 @@ static bool ufshcd_is_unipro_pa_params_tuning_req(struct ufs_hba *hba) · 17 unmodified lines
940 * logic simple, we will only do manual tuning if local unipro version958 * logic simple, we will only do manual tuning if local unipro version
941 * doesn't support ver1.6 or later.959 * doesn't support ver1.6 or later.
942 */960 */
943 if (ufshcd_get_local_unipro_ver(hba) < UFS_UNIPRO_VER_1_6)961 return ufshcd_get_local_unipro_ver(hba) < UFS_UNIPRO_VER_1_6;
944 return true;
945 else
946 return false;
947}962}
948 963
949/**964/**
@@ -1350,7 +1365,7 @@ static int ufshcd_devfreq_target(struct device *dev, · 400 unmodified lines
1350 }1365 }
1351 1366
1352 /* Decide based on the rounded-off frequency and update */1367 /* Decide based on the rounded-off frequency and update */
1353 scale_up = (*freq == clki->max_freq) ? true : false;1368 scale_up = *freq == clki->max_freq;
1354 if (!scale_up)1369 if (!scale_up)
1355 *freq = clki->min_freq;1370 *freq = clki->min_freq;
1356 /* Update the frequency */1371 /* Update the frequency */
@@ -1862,18 +1877,26 @@ static ssize_t ufshcd_clkgate_delay_show(struct device *dev, · 505 unmodified lines
1862 return sysfs_emit(buf, "%lu\n", hba->clk_gating.delay_ms);1877 return sysfs_emit(buf, "%lu\n", hba->clk_gating.delay_ms);
1863}1878}
1864 1879
1880void ufshcd_clkgate_delay_set(struct device *dev, unsigned long value)
1881{
1882 struct ufs_hba *hba = dev_get_drvdata(dev);
1883 unsigned long flags;
1884
1885 spin_lock_irqsave(hba->host->host_lock, flags);
1886 hba->clk_gating.delay_ms = value;
1887 spin_unlock_irqrestore(hba->host->host_lock, flags);
1888}
1889EXPORT_SYMBOL_GPL(ufshcd_clkgate_delay_set);
1890
1865static ssize_t ufshcd_clkgate_delay_store(struct device *dev,1891static ssize_t ufshcd_clkgate_delay_store(struct device *dev,
1866 struct device_attribute *attr, const char *buf, size_t count)1892 struct device_attribute *attr, const char *buf, size_t count)
1867{1893{
1868 struct ufs_hba *hba = dev_get_drvdata(dev);1894 unsigned long value;
1869 unsigned long flags, value;
1870 1895
1871 if (kstrtoul(buf, 0, &value))1896 if (kstrtoul(buf, 0, &value))
1872 return -EINVAL;1897 return -EINVAL;
1873 1898
1874 spin_lock_irqsave(hba->host->host_lock, flags);1899 ufshcd_clkgate_delay_set(dev, value);
1875 hba->clk_gating.delay_ms = value;
1876 spin_unlock_irqrestore(hba->host->host_lock, flags);
1877 return count;1900 return count;
1878}1901}
1879 1902
@@ -2120,9 +2143,6 @@ void ufshcd_send_command(struct ufs_hba *hba, unsigned int task_tag) · 240 unmodified lines
2120 __set_bit(task_tag, &hba->outstanding_reqs);2143 __set_bit(task_tag, &hba->outstanding_reqs);
2121 ufshcd_writel(hba, 1 << task_tag, REG_UTP_TRANSFER_REQ_DOOR_BELL);2144 ufshcd_writel(hba, 1 << task_tag, REG_UTP_TRANSFER_REQ_DOOR_BELL);
2122 spin_unlock_irqrestore(&hba->outstanding_lock, flags);2145 spin_unlock_irqrestore(&hba->outstanding_lock, flags);
2123
2124 /* Make sure that doorbell is committed immediately */
2125 wmb();
2126}2146}
2127 2147
2128/**2148/**
@@ -2131,15 +2151,17 @@ void ufshcd_send_command(struct ufs_hba *hba, unsigned int task_tag) · 2 unmodified lines
2131 */2151 */
2132static inline void ufshcd_copy_sense_data(struct ufshcd_lrb *lrbp)2152static inline void ufshcd_copy_sense_data(struct ufshcd_lrb *lrbp)
2133{2153{
2154 u8 *const sense_buffer = lrbp->cmd->sense_buffer;
2134 int len;2155 int len;
2135 if (lrbp->sense_buffer &&2156
2157 if (sense_buffer &&
2136 ufshcd_get_rsp_upiu_data_seg_len(lrbp->ucd_rsp_ptr)) {2158 ufshcd_get_rsp_upiu_data_seg_len(lrbp->ucd_rsp_ptr)) {
2137 int len_to_copy;2159 int len_to_copy;
2138 2160
2139 len = be16_to_cpu(lrbp->ucd_rsp_ptr->sr.sense_data_len);2161 len = be16_to_cpu(lrbp->ucd_rsp_ptr->sr.sense_data_len);
2140 len_to_copy = min_t(int, UFS_SENSE_SIZE, len);2162 len_to_copy = min_t(int, UFS_SENSE_SIZE, len);
2141 2163
2142 memcpy(lrbp->sense_buffer, lrbp->ucd_rsp_ptr->sr.sense_data,2164 memcpy(sense_buffer, lrbp->ucd_rsp_ptr->sr.sense_data,
2143 len_to_copy);2165 len_to_copy);
2144 }2166 }
2145}2167}
@@ -2217,10 +2239,7 @@ static inline int ufshcd_hba_capabilities(struct ufs_hba *hba) · 71 unmodified lines
2217 */2239 */
2218static inline bool ufshcd_ready_for_uic_cmd(struct ufs_hba *hba)2240static inline bool ufshcd_ready_for_uic_cmd(struct ufs_hba *hba)
2219{2241{
2220 if (ufshcd_readl(hba, REG_CONTROLLER_STATUS) & UIC_COMMAND_READY)2242 return ufshcd_readl(hba, REG_CONTROLLER_STATUS) & UIC_COMMAND_READY;
2221 return true;
2222 else
2223 return false;
2224}2243}
2225 2244
2226/**2245/**
@@ -2796,11 +2815,9 @@ static int ufshcd_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd) · 569 unmodified lines
2796 lrbp = &hba->lrb[tag];2815 lrbp = &hba->lrb[tag];
2797 WARN_ON(lrbp->cmd);2816 WARN_ON(lrbp->cmd);
2798 lrbp->cmd = cmd;2817 lrbp->cmd = cmd;
2799 lrbp->sense_bufflen = UFS_SENSE_SIZE;
2800 lrbp->sense_buffer = cmd->sense_buffer;
2801 lrbp->task_tag = tag;2818 lrbp->task_tag = tag;
2802 lrbp->lun = ufshcd_scsi_to_upiu_lun(cmd->device->lun);2819 lrbp->lun = ufshcd_scsi_to_upiu_lun(cmd->device->lun);
2803 lrbp->intr_cmd = !ufshcd_is_intr_aggr_allowed(hba) ? true : false;2820 lrbp->intr_cmd = !ufshcd_is_intr_aggr_allowed(hba);
2804 2821
2805 ufshcd_prepare_lrbp_crypto(scsi_cmd_to_rq(cmd), lrbp);2822 ufshcd_prepare_lrbp_crypto(scsi_cmd_to_rq(cmd), lrbp);
2806 2823
@@ -2837,8 +2854,6 @@ static int ufshcd_compose_dev_cmd(struct ufs_hba *hba, · 30 unmodified lines
2837 struct ufshcd_lrb *lrbp, enum dev_cmd_type cmd_type, int tag)2854 struct ufshcd_lrb *lrbp, enum dev_cmd_type cmd_type, int tag)
2838{2855{
2839 lrbp->cmd = NULL;2856 lrbp->cmd = NULL;
2840 lrbp->sense_bufflen = 0;
2841 lrbp->sense_buffer = NULL;
2842 lrbp->task_tag = tag;2857 lrbp->task_tag = tag;
2843 lrbp->lun = 0; /* device management cmd is not specific to any LUN */2858 lrbp->lun = 0; /* device management cmd is not specific to any LUN */
2844 lrbp->intr_cmd = true; /* No interrupt aggregation */2859 lrbp->intr_cmd = true; /* No interrupt aggregation */
@@ -4198,7 +4213,7 @@ void ufshcd_auto_hibern8_update(struct ufs_hba *hba, u32 ahit) · 1353 unmodified lines
4198 spin_unlock_irqrestore(hba->host->host_lock, flags);4213 spin_unlock_irqrestore(hba->host->host_lock, flags);
4199 4214
4200 if (update &&4215 if (update &&
4201 !pm_runtime_suspended(&hba->sdev_ufs_device->sdev_gendev)) {4216 !pm_runtime_suspended(&hba->ufs_device_wlun->sdev_gendev)) {
4202 ufshcd_rpm_get_sync(hba);4217 ufshcd_rpm_get_sync(hba);
4203 ufshcd_hold(hba, false);4218 ufshcd_hold(hba, false);
4204 ufshcd_auto_hibern8_enable(hba);4219 ufshcd_auto_hibern8_enable(hba);
@@ -4210,14 +4225,10 @@ EXPORT_SYMBOL_GPL(ufshcd_auto_hibern8_update); · 5 unmodified lines
4210 4225
4211void ufshcd_auto_hibern8_enable(struct ufs_hba *hba)4226void ufshcd_auto_hibern8_enable(struct ufs_hba *hba)
4212{4227{
4213 unsigned long flags;
4214
4215 if (!ufshcd_is_auto_hibern8_supported(hba))4228 if (!ufshcd_is_auto_hibern8_supported(hba))
4216 return;4229 return;
4217 4230
4218 spin_lock_irqsave(hba->host->host_lock, flags);
4219 ufshcd_writel(hba, hba->ahit, REG_AUTO_HIBERNATE_IDLE_TIMER);4231 ufshcd_writel(hba, hba->ahit, REG_AUTO_HIBERNATE_IDLE_TIMER);
4220 spin_unlock_irqrestore(hba->host->host_lock, flags);
4221}4232}
4222 4233
4223 /**4234 /**
@@ -4328,18 +4339,18 @@ static int ufshcd_change_power_mode(struct ufs_hba *hba, · 104 unmodified lines
4328 pwr_mode->lane_rx);4339 pwr_mode->lane_rx);
4329 if (pwr_mode->pwr_rx == FASTAUTO_MODE ||4340 if (pwr_mode->pwr_rx == FASTAUTO_MODE ||
4330 pwr_mode->pwr_rx == FAST_MODE)4341 pwr_mode->pwr_rx == FAST_MODE)
4331 ufshcd_dme_set(hba, UIC_ARG_MIB(PA_RXTERMINATION), TRUE);4342 ufshcd_dme_set(hba, UIC_ARG_MIB(PA_RXTERMINATION), true);
4332 else4343 else
4333 ufshcd_dme_set(hba, UIC_ARG_MIB(PA_RXTERMINATION), FALSE);4344 ufshcd_dme_set(hba, UIC_ARG_MIB(PA_RXTERMINATION), false);
4334 4345
4335 ufshcd_dme_set(hba, UIC_ARG_MIB(PA_TXGEAR), pwr_mode->gear_tx);4346 ufshcd_dme_set(hba, UIC_ARG_MIB(PA_TXGEAR), pwr_mode->gear_tx);
4336 ufshcd_dme_set(hba, UIC_ARG_MIB(PA_ACTIVETXDATALANES),4347 ufshcd_dme_set(hba, UIC_ARG_MIB(PA_ACTIVETXDATALANES),
4337 pwr_mode->lane_tx);4348 pwr_mode->lane_tx);
4338 if (pwr_mode->pwr_tx == FASTAUTO_MODE ||4349 if (pwr_mode->pwr_tx == FASTAUTO_MODE ||
4339 pwr_mode->pwr_tx == FAST_MODE)4350 pwr_mode->pwr_tx == FAST_MODE)
4340 ufshcd_dme_set(hba, UIC_ARG_MIB(PA_TXTERMINATION), TRUE);4351 ufshcd_dme_set(hba, UIC_ARG_MIB(PA_TXTERMINATION), true);
4341 else4352 else
4342 ufshcd_dme_set(hba, UIC_ARG_MIB(PA_TXTERMINATION), FALSE);4353 ufshcd_dme_set(hba, UIC_ARG_MIB(PA_TXTERMINATION), false);
4343 4354
4344 if (pwr_mode->pwr_rx == FASTAUTO_MODE ||4355 if (pwr_mode->pwr_rx == FASTAUTO_MODE ||
4345 pwr_mode->pwr_tx == FASTAUTO_MODE ||4356 pwr_mode->pwr_tx == FASTAUTO_MODE ||
@@ -4438,7 +4449,7 @@ static int ufshcd_complete_dev_init(struct ufs_hba *hba) · 92 unmodified lines
4438 QUERY_FLAG_IDN_FDEVICEINIT, 0, &flag_res);4449 QUERY_FLAG_IDN_FDEVICEINIT, 0, &flag_res);
4439 if (!flag_res)4450 if (!flag_res)
4440 break;4451 break;
4441 usleep_range(5000, 10000);4452 usleep_range(500, 1000);
4442 } while (ktime_before(ktime_get(), timeout));4453 } while (ktime_before(ktime_get(), timeout));
4443 4454
4444 if (err) {4455 if (err) {
@@ -4554,7 +4565,7 @@ static int ufshcd_hba_execute_hce(struct ufs_hba *hba) · 109 unmodified lines
4554 int retry_inner;4565 int retry_inner;
4555 4566
4556start:4567start:
4557 if (!ufshcd_is_hba_active(hba))4568 if (ufshcd_is_hba_active(hba))
4558 /* change controller state to "reset state" */4569 /* change controller state to "reset state" */
4559 ufshcd_hba_stop(hba);4570 ufshcd_hba_stop(hba);
4560 4571
@@ -4580,7 +4591,7 @@ start: · 19 unmodified lines
4580 4591
4581 /* wait for the host controller to complete initialization */4592 /* wait for the host controller to complete initialization */
4582 retry_inner = 50;4593 retry_inner = 50;
4583 while (ufshcd_is_hba_active(hba)) {4594 while (!ufshcd_is_hba_active(hba)) {
4584 if (retry_inner) {4595 if (retry_inner) {
4585 retry_inner--;4596 retry_inner--;
4586 } else {4597 } else {
@@ -4914,13 +4925,13 @@ static void ufshcd_setup_links(struct ufs_hba *hba, struct scsi_device *sdev) · 327 unmodified lines
4914 * Device wlun is the supplier & rest of the luns are consumers.4925 * Device wlun is the supplier & rest of the luns are consumers.
4915 * This ensures that device wlun suspends after all other luns.4926 * This ensures that device wlun suspends after all other luns.
4916 */4927 */
4917 if (hba->sdev_ufs_device) {4928 if (hba->ufs_device_wlun) {
4918 link = device_link_add(&sdev->sdev_gendev,4929 link = device_link_add(&sdev->sdev_gendev,
4919 &hba->sdev_ufs_device->sdev_gendev,4930 &hba->ufs_device_wlun->sdev_gendev,
4920 DL_FLAG_PM_RUNTIME | DL_FLAG_RPM_ACTIVE);4931 DL_FLAG_PM_RUNTIME | DL_FLAG_RPM_ACTIVE);
4921 if (!link) {4932 if (!link) {
4922 dev_err(&sdev->sdev_gendev, "Failed establishing link - %s\n",4933 dev_err(&sdev->sdev_gendev, "Failed establishing link - %s\n",
4923 dev_name(&hba->sdev_ufs_device->sdev_gendev));4934 dev_name(&hba->ufs_device_wlun->sdev_gendev));
4924 return;4935 return;
4925 }4936 }
4926 hba->luns_avail--;4937 hba->luns_avail--;
@@ -5056,15 +5067,15 @@ static void ufshcd_slave_destroy(struct scsi_device *sdev) · 129 unmodified lines
5056 /* Drop the reference as it won't be needed anymore */5067 /* Drop the reference as it won't be needed anymore */
5057 if (ufshcd_scsi_to_upiu_lun(sdev->lun) == UFS_UPIU_UFS_DEVICE_WLUN) {5068 if (ufshcd_scsi_to_upiu_lun(sdev->lun) == UFS_UPIU_UFS_DEVICE_WLUN) {
5058 spin_lock_irqsave(hba->host->host_lock, flags);5069 spin_lock_irqsave(hba->host->host_lock, flags);
5059 hba->sdev_ufs_device = NULL;5070 hba->ufs_device_wlun = NULL;
5060 spin_unlock_irqrestore(hba->host->host_lock, flags);5071 spin_unlock_irqrestore(hba->host->host_lock, flags);
5061 } else if (hba->sdev_ufs_device) {5072 } else if (hba->ufs_device_wlun) {
5062 struct device *supplier = NULL;5073 struct device *supplier = NULL;
5063 5074
5064 /* Ensure UFS Device WLUN exists and does not disappear */5075 /* Ensure UFS Device WLUN exists and does not disappear */
5065 spin_lock_irqsave(hba->host->host_lock, flags);5076 spin_lock_irqsave(hba->host->host_lock, flags);
5066 if (hba->sdev_ufs_device) {5077 if (hba->ufs_device_wlun) {
5067 supplier = &hba->sdev_ufs_device->sdev_gendev;5078 supplier = &hba->ufs_device_wlun->sdev_gendev;
5068 get_device(supplier);5079 get_device(supplier);
5069 }5080 }
5070 spin_unlock_irqrestore(hba->host->host_lock, flags);5081 spin_unlock_irqrestore(hba->host->host_lock, flags);
@@ -5782,10 +5793,7 @@ static bool ufshcd_wb_presrv_usrspc_keep_vcc_on(struct ufs_hba *hba, · 711 unmodified lines
5782 return false;5793 return false;
5783 }5794 }
5784 /* Let it continue to flush when available buffer exceeds threshold */5795 /* Let it continue to flush when available buffer exceeds threshold */
5785 if (avail_buf < hba->vps->wb_flush_threshold)5796 return avail_buf < hba->vps->wb_flush_threshold;
5786 return true;
5787
5788 return false;
5789}5797}
5790 5798
5791static void ufshcd_wb_force_disable(struct ufs_hba *hba)5799static void ufshcd_wb_force_disable(struct ufs_hba *hba)
@@ -5864,11 +5872,8 @@ static bool ufshcd_wb_need_flush(struct ufs_hba *hba) · 72 unmodified lines
5864 return false;5872 return false;
5865 }5873 }
5866 5874
5867 if (!hba->dev_info.b_presrv_uspc_en) {5875 if (!hba->dev_info.b_presrv_uspc_en)
5868 if (avail_buf <= UFS_WB_BUF_REMAIN_PERCENT(10))5876 return avail_buf <= UFS_WB_BUF_REMAIN_PERCENT(10);
5869 return true;
5870 return false;
5871 }
5872 5877
5873 return ufshcd_wb_presrv_usrspc_keep_vcc_on(hba, avail_buf);5878 return ufshcd_wb_presrv_usrspc_keep_vcc_on(hba, avail_buf);
5874}5879}
@@ -6046,7 +6051,7 @@ static void ufshcd_clk_scaling_suspend(struct ufs_hba *hba, bool suspend) · 171 unmodified lines
6046static void ufshcd_err_handling_prepare(struct ufs_hba *hba)6051static void ufshcd_err_handling_prepare(struct ufs_hba *hba)
6047{6052{
6048 ufshcd_rpm_get_sync(hba);6053 ufshcd_rpm_get_sync(hba);
6049 if (pm_runtime_status_suspended(&hba->sdev_ufs_device->sdev_gendev) ||6054 if (pm_runtime_status_suspended(&hba->ufs_device_wlun->sdev_gendev) ||
6050 hba->is_sys_suspended) {6055 hba->is_sys_suspended) {
6051 enum ufs_pm_op pm_op;6056 enum ufs_pm_op pm_op;
6052 6057
@@ -6091,7 +6096,7 @@ static void ufshcd_err_handling_unprepare(struct ufs_hba *hba) · 38 unmodified lines
6091static inline bool ufshcd_err_handling_should_stop(struct ufs_hba *hba)6096static inline bool ufshcd_err_handling_should_stop(struct ufs_hba *hba)
6092{6097{
6093 return (!hba->is_powered || hba->shutting_down ||6098 return (!hba->is_powered || hba->shutting_down ||
6094 !hba->sdev_ufs_device ||6099 !hba->ufs_device_wlun ||
6095 hba->ufshcd_state == UFSHCD_STATE_ERROR ||6100 hba->ufshcd_state == UFSHCD_STATE_ERROR ||
6096 (!(hba->saved_err || hba->saved_uic_err || hba->force_reset ||6101 (!(hba->saved_err || hba->saved_uic_err || hba->force_reset ||
6097 ufshcd_is_link_broken(hba))));6102 ufshcd_is_link_broken(hba))));
@@ -6110,7 +6115,7 @@ static void ufshcd_recover_pm_error(struct ufs_hba *hba) · 12 unmodified lines
6110 * Set RPM status of wlun device to RPM_ACTIVE,6115 * Set RPM status of wlun device to RPM_ACTIVE,
6111 * this also clears its runtime error.6116 * this also clears its runtime error.
6112 */6117 */
6113 ret = pm_runtime_set_active(&hba->sdev_ufs_device->sdev_gendev);6118 ret = pm_runtime_set_active(&hba->ufs_device_wlun->sdev_gendev);
6114 6119
6115 /* hba device might have a runtime error otherwise */6120 /* hba device might have a runtime error otherwise */
6116 if (ret)6121 if (ret)
@@ -6815,8 +6820,6 @@ static int ufshcd_issue_devman_upiu_cmd(struct ufs_hba *hba, · 698 unmodified lines
6815 lrbp = &hba->lrb[tag];6820 lrbp = &hba->lrb[tag];
6816 WARN_ON(lrbp->cmd);6821 WARN_ON(lrbp->cmd);
6817 lrbp->cmd = NULL;6822 lrbp->cmd = NULL;
6818 lrbp->sense_bufflen = 0;
6819 lrbp->sense_buffer = NULL;
6820 lrbp->task_tag = tag;6823 lrbp->task_tag = tag;
6821 lrbp->lun = 0;6824 lrbp->lun = 0;
6822 lrbp->intr_cmd = true;6825 lrbp->intr_cmd = true;
@@ -7223,7 +7226,7 @@ static int ufshcd_host_reset_and_restore(struct ufs_hba *hba) · 400 unmodified lines
7223 * Stop the host controller and complete the requests7226 * Stop the host controller and complete the requests
7224 * cleared by h/w7227 * cleared by h/w
7225 */7228 */
7226 ufshpb_reset_host(hba);7229 ufshpb_toggle_state(hba, HPB_PRESENT, HPB_RESET);
7227 ufshcd_hba_stop(hba);7230 ufshcd_hba_stop(hba);
7228 hba->silence_err_logs = true;7231 hba->silence_err_logs = true;
7229 ufshcd_complete_requests(hba);7232 ufshcd_complete_requests(hba);
@@ -7351,7 +7354,7 @@ static u32 ufshcd_get_max_icc_level(int sup_curr_uA, u32 start_scan, char *buff) · 121 unmodified lines
7351 u16 unit;7354 u16 unit;
7352 7355
7353 for (i = start_scan; i >= 0; i--) {7356 for (i = start_scan; i >= 0; i--) {
7354 data = be16_to_cpup((__be16 *)&buff[2 * i]);7357 data = get_unaligned_be16(&buff[2 * i]);
7355 unit = (data & ATTR_ICC_LVL_UNIT_MASK) >>7358 unit = (data & ATTR_ICC_LVL_UNIT_MASK) >>
7356 ATTR_ICC_LVL_UNIT_OFFSET;7359 ATTR_ICC_LVL_UNIT_OFFSET;
7357 curr_uA = data & ATTR_ICC_LVL_VALUE_MASK;7360 curr_uA = data & ATTR_ICC_LVL_VALUE_MASK;
@@ -7506,20 +7509,20 @@ static int ufshcd_scsi_add_wlus(struct ufs_hba *hba) · 148 unmodified lines
7506 int ret = 0;7509 int ret = 0;
7507 struct scsi_device *sdev_boot, *sdev_rpmb;7510 struct scsi_device *sdev_boot, *sdev_rpmb;
7508 7511
7509 hba->sdev_ufs_device = __scsi_add_device(hba->host, 0, 0,7512 hba->ufs_device_wlun = __scsi_add_device(hba->host, 0, 0,
7510 ufshcd_upiu_wlun_to_scsi_wlun(UFS_UPIU_UFS_DEVICE_WLUN), NULL);7513 ufshcd_upiu_wlun_to_scsi_wlun(UFS_UPIU_UFS_DEVICE_WLUN), NULL);
7511 if (IS_ERR(hba->sdev_ufs_device)) {7514 if (IS_ERR(hba->ufs_device_wlun)) {
7512 ret = PTR_ERR(hba->sdev_ufs_device);7515 ret = PTR_ERR(hba->ufs_device_wlun);
7513 hba->sdev_ufs_device = NULL;7516 hba->ufs_device_wlun = NULL;
7514 goto out;7517 goto out;
7515 }7518 }
7516 scsi_device_put(hba->sdev_ufs_device);7519 scsi_device_put(hba->ufs_device_wlun);
7517 7520
7518 sdev_rpmb = __scsi_add_device(hba->host, 0, 0,7521 sdev_rpmb = __scsi_add_device(hba->host, 0, 0,
7519 ufshcd_upiu_wlun_to_scsi_wlun(UFS_UPIU_RPMB_WLUN), NULL);7522 ufshcd_upiu_wlun_to_scsi_wlun(UFS_UPIU_RPMB_WLUN), NULL);
7520 if (IS_ERR(sdev_rpmb)) {7523 if (IS_ERR(sdev_rpmb)) {
7521 ret = PTR_ERR(sdev_rpmb);7524 ret = PTR_ERR(sdev_rpmb);
7522 goto remove_sdev_ufs_device;7525 goto remove_ufs_device_wlun;
7523 }7526 }
7524 ufshcd_blk_pm_runtime_init(sdev_rpmb);7527 ufshcd_blk_pm_runtime_init(sdev_rpmb);
7525 scsi_device_put(sdev_rpmb);7528 scsi_device_put(sdev_rpmb);
@@ -7534,8 +7537,8 @@ static int ufshcd_scsi_add_wlus(struct ufs_hba *hba) · 8 unmodified lines
7534 }7537 }
7535 goto out;7538 goto out;
7536 7539
7537remove_sdev_ufs_device:7540remove_ufs_device_wlun:
7538 scsi_remove_device(hba->sdev_ufs_device);7541 scsi_remove_device(hba->ufs_device_wlun);
7539out:7542out:
7540 return ret;7543 return ret;
7541}7544}
@@ -7634,9 +7637,10 @@ static void ufshcd_temp_notif_probe(struct ufs_hba *hba, u8 *desc_buf) · 92 unmodified lines
7634 }7637 }
7635}7638}
7636 7639
7637void ufshcd_fixup_dev_quirks(struct ufs_hba *hba, struct ufs_dev_fix *fixups)7640void ufshcd_fixup_dev_quirks(struct ufs_hba *hba,
7641 const struct ufs_dev_quirk *fixups)
7638{7642{
7639 struct ufs_dev_fix *f;7643 const struct ufs_dev_quirk *f;
7640 struct ufs_dev_info *dev_info = &hba->dev_info;7644 struct ufs_dev_info *dev_info = &hba->dev_info;
7641 7645
7642 if (!fixups)7646 if (!fixups)
@@ -7956,6 +7960,11 @@ out: · 313 unmodified lines
7956 return err;7960 return err;
7957}7961}
7958 7962
7963struct ufs_ref_clk {
7964 unsigned long freq_hz;
7965 enum ufs_ref_clk_freq val;
7966};
7967
7959static struct ufs_ref_clk ufs_ref_clk_freqs[] = {7968static struct ufs_ref_clk ufs_ref_clk_freqs[] = {
7960 {19200000, REF_CLK_FREQ_19_2_MHZ},7969 {19200000, REF_CLK_FREQ_19_2_MHZ},
7961 {26000000, REF_CLK_FREQ_26_MHZ},7970 {26000000, REF_CLK_FREQ_26_MHZ},
@@ -8184,7 +8193,7 @@ static int ufshcd_probe_hba(struct ufs_hba *hba, bool init_dev_params) · 222 unmodified lines
8184 /* Enable Auto-Hibernate if configured */8193 /* Enable Auto-Hibernate if configured */
8185 ufshcd_auto_hibern8_enable(hba);8194 ufshcd_auto_hibern8_enable(hba);
8186 8195
8187 ufshpb_reset(hba);8196 ufshpb_toggle_state(hba, HPB_RESET, HPB_PRESENT);
8188out:8197out:
8189 spin_lock_irqsave(hba->host->host_lock, flags);8198 spin_lock_irqsave(hba->host->host_lock, flags);
8190 if (ret)8199 if (ret)
@@ -8319,33 +8328,10 @@ static inline int ufshcd_config_vreg_hpm(struct ufs_hba *hba, · 128 unmodified lines
8319static int ufshcd_config_vreg(struct device *dev,8328static int ufshcd_config_vreg(struct device *dev,
8320 struct ufs_vreg *vreg, bool on)8329 struct ufs_vreg *vreg, bool on)
8321{8330{
8322 int ret = 0;8331 if (regulator_count_voltages(vreg->reg) <= 0)
8323 struct regulator *reg;8332 return 0;
8324 const char *name;
8325 int min_uV, uA_load;
8326
8327 BUG_ON(!vreg);
8328
8329 reg = vreg->reg;
8330 name = vreg->name;
8331
8332 if (regulator_count_voltages(reg) > 0) {
8333 uA_load = on ? vreg->max_uA : 0;
8334 ret = ufshcd_config_vreg_load(dev, vreg, uA_load);
8335 if (ret)
8336 goto out;
8337 8333
8338 if (vreg->min_uV && vreg->max_uV) {8334 return ufshcd_config_vreg_load(dev, vreg, on ? vreg->max_uA : 0);
8339 min_uV = on ? vreg->min_uV : 0;
8340 ret = regulator_set_voltage(reg, min_uV, vreg->max_uV);
8341 if (ret)
8342 dev_err(dev,
8343 "%s: %s set voltage failed, err=%d\n",
8344 __func__, name, ret);
8345 }
8346 }
8347out:
8348 return ret;
8349}8335}
8350 8336
8351static int ufshcd_enable_vreg(struct device *dev, struct ufs_vreg *vreg)8337static int ufshcd_enable_vreg(struct device *dev, struct ufs_vreg *vreg)
@@ -8693,7 +8679,7 @@ static int ufshcd_set_dev_pwr_mode(struct ufs_hba *hba, · 341 unmodified lines
8693 int ret, retries;8679 int ret, retries;
8694 8680
8695 spin_lock_irqsave(hba->host->host_lock, flags);8681 spin_lock_irqsave(hba->host->host_lock, flags);
8696 sdp = hba->sdev_ufs_device;8682 sdp = hba->ufs_device_wlun;
8697 if (sdp) {8683 if (sdp) {
8698 ret = scsi_device_get(sdp);8684 ret = scsi_device_get(sdp);
8699 if (!ret && !scsi_device_online(sdp)) {8685 if (!ret && !scsi_device_online(sdp)) {
@@ -9257,7 +9243,7 @@ static void ufshcd_wl_shutdown(struct device *dev) · 557 unmodified lines
9257 ufshcd_rpm_get_sync(hba);9243 ufshcd_rpm_get_sync(hba);
9258 scsi_device_quiesce(sdev);9244 scsi_device_quiesce(sdev);
9259 shost_for_each_device(sdev, hba->host) {9245 shost_for_each_device(sdev, hba->host) {
9260 if (sdev == hba->sdev_ufs_device)9246 if (sdev == hba->ufs_device_wlun)
9261 continue;9247 continue;
9262 scsi_device_quiesce(sdev);9248 scsi_device_quiesce(sdev);
9263 }9249 }
@@ -9478,7 +9464,7 @@ EXPORT_SYMBOL(ufshcd_shutdown); · 214 unmodified lines
9478 */9464 */
9479void ufshcd_remove(struct ufs_hba *hba)9465void ufshcd_remove(struct ufs_hba *hba)
9480{9466{
9481 if (hba->sdev_ufs_device)9467 if (hba->ufs_device_wlun)
9482 ufshcd_rpm_get_sync(hba);9468 ufshcd_rpm_get_sync(hba);
9483 ufs_hwmon_remove(hba);9469 ufs_hwmon_remove(hba);
9484 ufs_bsg_remove(hba);9470 ufs_bsg_remove(hba);
@@ -9806,7 +9792,7 @@ EXPORT_SYMBOL_GPL(ufshcd_resume_complete); · 321 unmodified lines
9806 9792
9807static bool ufshcd_rpm_ok_for_spm(struct ufs_hba *hba)9793static bool ufshcd_rpm_ok_for_spm(struct ufs_hba *hba)
9808{9794{
9809 struct device *dev = &hba->sdev_ufs_device->sdev_gendev;9795 struct device *dev = &hba->ufs_device_wlun->sdev_gendev;
9810 enum ufs_dev_pwr_mode dev_pwr_mode;9796 enum ufs_dev_pwr_mode dev_pwr_mode;
9811 enum uic_link_state link_state;9797 enum uic_link_state link_state;
9812 unsigned long flags;9798 unsigned long flags;
@@ -9835,7 +9821,7 @@ int __ufshcd_suspend_prepare(struct device *dev, bool rpm_ok_for_spm) · 22 unmodified lines
9835 * if it's runtime suspended. But ufs doesn't follow that.9821 * if it's runtime suspended. But ufs doesn't follow that.
9836 * Refer ufshcd_resume_complete()9822 * Refer ufshcd_resume_complete()
9837 */9823 */
9838 if (hba->sdev_ufs_device) {9824 if (hba->ufs_device_wlun) {
9839 /* Prevent runtime suspend */9825 /* Prevent runtime suspend */
9840 ufshcd_rpm_get_noresume(hba);9826 ufshcd_rpm_get_noresume(hba);
9841 /*9827 /*
@@ -9956,4 +9942,3 @@ MODULE_AUTHOR("Santosh Yaragnavi <santosh.sy@samsung.com>"); · 114 unmodified lines
9956MODULE_AUTHOR("Vinayak Holikatti <h.vinayak@samsung.com>");9942MODULE_AUTHOR("Vinayak Holikatti <h.vinayak@samsung.com>");
9957MODULE_DESCRIPTION("Generic UFS host controller driver Core");9943MODULE_DESCRIPTION("Generic UFS host controller driver Core");
9958MODULE_LICENSE("GPL");9944MODULE_LICENSE("GPL");
9959MODULE_VERSION(UFSHCD_DRIVER_VERSION);
drivers/scsi/ufs/ufshcd.h+80−288
@@ -12,44 +12,18 @@ · 11 unmodified lines
12#ifndef _UFSHCD_H12#ifndef _UFSHCD_H
13#define _UFSHCD_H13#define _UFSHCD_H
14 14
15#include <linux/module.h>
16#include <linux/kernel.h>
17#include <linux/init.h>
18#include <linux/interrupt.h>
19#include <linux/io.h>
20#include <linux/delay.h>
21#include <linux/slab.h>
22#include <linux/spinlock.h>
23#include <linux/rwsem.h>
24#include <linux/workqueue.h>
25#include <linux/errno.h>
26#include <linux/types.h>
27#include <linux/wait.h>
28#include <linux/bitops.h>
29#include <linux/pm_runtime.h>
30#include <linux/clk.h>
31#include <linux/completion.h>
32#include <linux/regulator/consumer.h>
33#include <linux/bitfield.h>15#include <linux/bitfield.h>
34#include <linux/devfreq.h>
35#include <linux/blk-crypto-profile.h>16#include <linux/blk-crypto-profile.h>
17#include <linux/blk-mq.h>
18#include <linux/devfreq.h>
19#include <linux/pm_runtime.h>
20#include <scsi/scsi_device.h>
36#include "unipro.h"21#include "unipro.h"
37
38#include <asm/irq.h>
39#include <asm/byteorder.h>
40#include <scsi/scsi.h>
41#include <scsi/scsi_cmnd.h>
42#include <scsi/scsi_host.h>
43#include <scsi/scsi_tcq.h>
44#include <scsi/scsi_dbg.h>
45#include <scsi/scsi_eh.h>
46
47#include "ufs.h"22#include "ufs.h"
48#include "ufs_quirks.h"23#include "ufs_quirks.h"
49#include "ufshci.h"24#include "ufshci.h"
50 25
51#define UFSHCD "ufshcd"26#define UFSHCD "ufshcd"
52#define UFSHCD_DRIVER_VERSION "0.2"
53 27
54struct ufs_hba;28struct ufs_hba;
55 29
@@ -181,8 +155,6 @@ struct ufs_pm_lvl_states { · 125 unmodified lines
181 * @ucd_rsp_dma_addr: UPIU response dma address for debug155 * @ucd_rsp_dma_addr: UPIU response dma address for debug
182 * @ucd_req_dma_addr: UPIU request dma address for debug156 * @ucd_req_dma_addr: UPIU request dma address for debug
183 * @cmd: pointer to SCSI command157 * @cmd: pointer to SCSI command
184 * @sense_buffer: pointer to sense buffer address of the SCSI command
185 * @sense_bufflen: Length of the sense buffer
186 * @scsi_status: SCSI status of the command158 * @scsi_status: SCSI status of the command
187 * @command_type: SCSI, UFS, Query.159 * @command_type: SCSI, UFS, Query.
188 * @task_tag: Task tag of the command160 * @task_tag: Task tag of the command
@@ -206,8 +178,6 @@ struct ufshcd_lrb { · 17 unmodified lines
206 dma_addr_t ucd_prdt_dma_addr;178 dma_addr_t ucd_prdt_dma_addr;
207 179
208 struct scsi_cmnd *cmd;180 struct scsi_cmnd *cmd;
209 u8 *sense_buffer;
210 unsigned int sense_bufflen;
211 int scsi_status;181 int scsi_status;
212 182
213 int command_type;183 int command_type;
@@ -241,6 +211,7 @@ struct ufs_query { · 27 unmodified lines
241 * @type: device management command type - Query, NOP OUT211 * @type: device management command type - Query, NOP OUT
242 * @lock: lock to allow one command at a time212 * @lock: lock to allow one command at a time
243 * @complete: internal commands completion213 * @complete: internal commands completion
214 * @query: Device management query information
244 */215 */
245struct ufs_dev_cmd {216struct ufs_dev_cmd {
246 enum dev_cmd_type type;217 enum dev_cmd_type type;
@@ -258,7 +229,7 @@ struct ufs_dev_cmd { · 11 unmodified lines
258 * @min_freq: min frequency that can be used for clock scaling229 * @min_freq: min frequency that can be used for clock scaling
259 * @curr_freq: indicates the current frequency that it is set to230 * @curr_freq: indicates the current frequency that it is set to
260 * @keep_link_active: indicates that the clk should not be disabled if231 * @keep_link_active: indicates that the clk should not be disabled if
261 link is active232 * link is active
262 * @enabled: variable to check against multiple enable/disable233 * @enabled: variable to check against multiple enable/disable
263 */234 */
264struct ufs_clk_info {235struct ufs_clk_info {
@@ -313,11 +284,13 @@ struct ufs_pwr_mode_info { · 48 unmodified lines
313 * to set some things284 * to set some things
314 * @hibern8_notify: called around hibern8 enter/exit285 * @hibern8_notify: called around hibern8 enter/exit
315 * @apply_dev_quirks: called to apply device specific quirks286 * @apply_dev_quirks: called to apply device specific quirks
287 * @fixup_dev_quirks: called to modify device specific quirks
316 * @suspend: called during host controller PM callback288 * @suspend: called during host controller PM callback
317 * @resume: called during host controller PM callback289 * @resume: called during host controller PM callback
318 * @dbg_register_dump: used to dump controller debug information290 * @dbg_register_dump: used to dump controller debug information
319 * @phy_initialization: used to initialize phys291 * @phy_initialization: used to initialize phys
320 * @device_reset: called to issue a reset pulse on the UFS device292 * @device_reset: called to issue a reset pulse on the UFS device
293 * @config_scaling_param: called to configure clock scaling parameters
321 * @program_key: program or evict an inline encryption key294 * @program_key: program or evict an inline encryption key
322 * @event_notify: called to notify important events295 * @event_notify: called to notify important events
323 */296 */
@@ -352,8 +325,8 @@ struct ufs_hba_variant_ops { · 28 unmodified lines
352 int (*phy_initialization)(struct ufs_hba *);325 int (*phy_initialization)(struct ufs_hba *);
353 int (*device_reset)(struct ufs_hba *hba);326 int (*device_reset)(struct ufs_hba *hba);
354 void (*config_scaling_param)(struct ufs_hba *hba,327 void (*config_scaling_param)(struct ufs_hba *hba,
355 struct devfreq_dev_profile *profile,328 struct devfreq_dev_profile *profile,
356 void *data);329 struct devfreq_simple_ondemand_data *data);
357 int (*program_key)(struct ufs_hba *hba,330 int (*program_key)(struct ufs_hba *hba,
358 const union ufs_crypto_cfg_entry *cfg, int slot);331 const union ufs_crypto_cfg_entry *cfg, int slot);
359 void (*event_notify)(struct ufs_hba *hba,332 void (*event_notify)(struct ufs_hba *hba,
@@ -384,6 +357,7 @@ enum clk_gating_state { · 24 unmodified lines
384 * @is_initialized: Indicates whether clock gating is initialized or not357 * @is_initialized: Indicates whether clock gating is initialized or not
385 * @active_reqs: number of requests that are pending and should be waited for358 * @active_reqs: number of requests that are pending and should be waited for
386 * completion before gating clocks.359 * completion before gating clocks.
360 * @clk_gating_workq: workqueue for clock gating work.
387 */361 */
388struct ufs_clk_gating {362struct ufs_clk_gating {
389 struct delayed_work gate_work;363 struct delayed_work gate_work;
@@ -420,9 +394,9 @@ struct ufs_saved_pwr_info { · 30 unmodified lines
420 * @resume_work: worker to resume devfreq394 * @resume_work: worker to resume devfreq
421 * @min_gear: lowest HS gear to scale down to395 * @min_gear: lowest HS gear to scale down to
422 * @is_enabled: tracks if scaling is currently enabled or not, controlled by396 * @is_enabled: tracks if scaling is currently enabled or not, controlled by
423 clkscale_enable sysfs node397 * clkscale_enable sysfs node
424 * @is_allowed: tracks if scaling is currently allowed or not, used to block398 * @is_allowed: tracks if scaling is currently allowed or not, used to block
425 clock scaling which is not invoked from devfreq governor399 * clock scaling which is not invoked from devfreq governor
426 * @is_initialized: Indicates whether clock scaling is initialized or not400 * @is_initialized: Indicates whether clock scaling is initialized or not
427 * @is_busy_started: tracks if busy period has started or not401 * @is_busy_started: tracks if busy period has started or not
428 * @is_suspended: tracks if devfreq is suspended or not402 * @is_suspended: tracks if devfreq is suspended or not
@@ -449,7 +423,7 @@ struct ufs_clk_scaling { · 20 unmodified lines
449/**423/**
450 * struct ufs_event_hist - keeps history of errors424 * struct ufs_event_hist - keeps history of errors
451 * @pos: index to indicate cyclic buffer position425 * @pos: index to indicate cyclic buffer position
452 * @reg: cyclic buffer for registers value426 * @val: cyclic buffer for registers value
453 * @tstamp: cyclic buffer for time stamp427 * @tstamp: cyclic buffer for time stamp
454 * @cnt: error counter428 * @cnt: error counter
455 */429 */
@@ -468,6 +442,7 @@ struct ufs_event_hist { · 12 unmodified lines
468 * reset this after link-startup.442 * reset this after link-startup.
469 * @last_hibern8_exit_tstamp: Set time after the hibern8 exit.443 * @last_hibern8_exit_tstamp: Set time after the hibern8 exit.
470 * Clear after the first successful command completion.444 * Clear after the first successful command completion.
445 * @event: array with event history.
471 */446 */
472struct ufs_stats {447struct ufs_stats {
473 u32 last_intr_status;448 u32 last_intr_status;
@@ -737,6 +712,14 @@ struct ufs_hba_monitor { · 263 unmodified lines
737 * @utmrdl_dma_addr: UTMRDL DMA address712 * @utmrdl_dma_addr: UTMRDL DMA address
738 * @host: Scsi_Host instance of the driver713 * @host: Scsi_Host instance of the driver
739 * @dev: device handle714 * @dev: device handle
715 * @ufs_device_wlun: WLUN that controls the entire UFS device.
716 * @hwmon_device: device instance registered with the hwmon core.
717 * @curr_dev_pwr_mode: active UFS device power mode.
718 * @uic_link_state: active state of the link to the UFS device.
719 * @rpm_lvl: desired UFS power management level during runtime PM.
720 * @spm_lvl: desired UFS power management level during system PM.
721 * @pm_op_in_progress: whether or not a PM operation is in progress.
722 * @ahit: value of Auto-Hibernate Idle Timer register.
740 * @lrb: local reference block723 * @lrb: local reference block
741 * @outstanding_tasks: Bits representing outstanding task requests724 * @outstanding_tasks: Bits representing outstanding task requests
742 * @outstanding_lock: Protects @outstanding_reqs.725 * @outstanding_lock: Protects @outstanding_reqs.
@@ -747,17 +730,26 @@ struct ufs_hba_monitor { · 4 unmodified lines
747 * @reserved_slot: Used to submit device commands. Protected by @dev_cmd.lock.730 * @reserved_slot: Used to submit device commands. Protected by @dev_cmd.lock.
748 * @ufs_version: UFS Version to which controller complies731 * @ufs_version: UFS Version to which controller complies
749 * @vops: pointer to variant specific operations732 * @vops: pointer to variant specific operations
733 * @vps: pointer to variant specific parameters
750 * @priv: pointer to variant specific private data734 * @priv: pointer to variant specific private data
751 * @irq: Irq number of the controller735 * @irq: Irq number of the controller
752 * @active_uic_cmd: handle of active UIC command736 * @is_irq_enabled: whether or not the UFS controller interrupt is enabled.
753 * @uic_cmd_mutex: mutex for UIC command737 * @dev_ref_clk_freq: reference clock frequency
738 * @quirks: bitmask with information about deviations from the UFSHCI standard.
739 * @dev_quirks: bitmask with information about deviations from the UFS standard.
754 * @tmf_tag_set: TMF tag set.740 * @tmf_tag_set: TMF tag set.
755 * @tmf_queue: Used to allocate TMF tags.741 * @tmf_queue: Used to allocate TMF tags.
756 * @pwr_done: completion for power mode change742 * @tmf_rqs: array with pointers to TMF requests while these are in progress.
743 * @active_uic_cmd: handle of active UIC command
744 * @uic_cmd_mutex: mutex for UIC command
745 * @uic_async_done: completion used during UIC processing
757 * @ufshcd_state: UFSHCD state746 * @ufshcd_state: UFSHCD state
758 * @eh_flags: Error handling flags747 * @eh_flags: Error handling flags
759 * @intr_mask: Interrupt Mask Bits748 * @intr_mask: Interrupt Mask Bits
760 * @ee_ctrl_mask: Exception event control mask749 * @ee_ctrl_mask: Exception event control mask
750 * @ee_drv_mask: Exception event mask for driver
751 * @ee_usr_mask: Exception event mask for user (set via debugfs)
752 * @ee_ctrl_mutex: Used to serialize exception event information.
761 * @is_powered: flag to check if HBA is powered753 * @is_powered: flag to check if HBA is powered
762 * @shutting_down: flag to check if shutdown has been invoked754 * @shutting_down: flag to check if shutdown has been invoked
763 * @host_sem: semaphore used to serialize concurrent contexts755 * @host_sem: semaphore used to serialize concurrent contexts
@@ -768,26 +760,52 @@ struct ufs_hba_monitor { · 4 unmodified lines
768 * @uic_error: UFS interconnect layer error status760 * @uic_error: UFS interconnect layer error status
769 * @saved_err: sticky error mask761 * @saved_err: sticky error mask
770 * @saved_uic_err: sticky UIC error mask762 * @saved_uic_err: sticky UIC error mask
763 * @ufs_stats: various error counters
771 * @force_reset: flag to force eh_work perform a full reset764 * @force_reset: flag to force eh_work perform a full reset
772 * @force_pmc: flag to force a power mode change765 * @force_pmc: flag to force a power mode change
773 * @silence_err_logs: flag to silence error logs766 * @silence_err_logs: flag to silence error logs
774 * @dev_cmd: ufs device management command information767 * @dev_cmd: ufs device management command information
775 * @last_dme_cmd_tstamp: time stamp of the last completed DME command768 * @last_dme_cmd_tstamp: time stamp of the last completed DME command
769 * @nop_out_timeout: NOP OUT timeout value
770 * @dev_info: information about the UFS device
776 * @auto_bkops_enabled: to track whether bkops is enabled in device771 * @auto_bkops_enabled: to track whether bkops is enabled in device
777 * @vreg_info: UFS device voltage regulator information772 * @vreg_info: UFS device voltage regulator information
778 * @clk_list_head: UFS host controller clocks list node head773 * @clk_list_head: UFS host controller clocks list node head
774 * @req_abort_count: number of times ufshcd_abort() has been called
775 * @lanes_per_direction: number of lanes per data direction between the UFS
776 * controller and the UFS device.
779 * @pwr_info: holds current power mode777 * @pwr_info: holds current power mode
780 * @max_pwr_info: keeps the device max valid pwm778 * @max_pwr_info: keeps the device max valid pwm
781 * @clk_scaling_lock: used to serialize device commands and clock scaling779 * @clk_gating: information related to clock gating
782 * @desc_size: descriptor sizes reported by device780 * @caps: bitmask with information about UFS controller capabilities
781 * @devfreq: frequency scaling information owned by the devfreq core
782 * @clk_scaling: frequency scaling information owned by the UFS driver
783 * @is_sys_suspended: whether or not the entire system has been suspended
783 * @urgent_bkops_lvl: keeps track of urgent bkops level for device784 * @urgent_bkops_lvl: keeps track of urgent bkops level for device
784 * @is_urgent_bkops_lvl_checked: keeps track if the urgent bkops level for785 * @is_urgent_bkops_lvl_checked: keeps track if the urgent bkops level for
785 * device is known or not.786 * device is known or not.
787 * @clk_scaling_lock: used to serialize device commands and clock scaling
788 * @desc_size: descriptor sizes reported by device
786 * @scsi_block_reqs_cnt: reference counting for scsi block requests789 * @scsi_block_reqs_cnt: reference counting for scsi block requests
790 * @bsg_dev: struct device associated with the BSG queue
791 * @bsg_queue: BSG queue associated with the UFS controller
792 * @rpm_dev_flush_recheck_work: used to suspend from RPM (runtime power
793 * management) after the UFS device has finished a WriteBooster buffer
794 * flush or auto BKOP.
795 * @ufshpb_dev: information related to HPB (Host Performance Booster).
796 * @monitor: statistics about UFS commands
787 * @crypto_capabilities: Content of crypto capabilities register (0x100)797 * @crypto_capabilities: Content of crypto capabilities register (0x100)
788 * @crypto_cap_array: Array of crypto capabilities798 * @crypto_cap_array: Array of crypto capabilities
789 * @crypto_cfg_register: Start of the crypto cfg array799 * @crypto_cfg_register: Start of the crypto cfg array
790 * @crypto_profile: the crypto profile of this hba (if applicable)800 * @crypto_profile: the crypto profile of this hba (if applicable)
801 * @debugfs_root: UFS controller debugfs root directory
802 * @debugfs_ee_work: used to restore ee_ctrl_mask after a delay
803 * @debugfs_ee_rate_limit_ms: user configurable delay after which to restore
804 * ee_ctrl_mask
805 * @luns_avail: number of regular and well known LUNs supported by the UFS
806 * device
807 * @complete_put: whether or not to call ufshcd_rpm_put() from inside
808 * ufshcd_resume_complete()
791 */809 */
792struct ufs_hba {810struct ufs_hba {
793 void __iomem *mmio_base;811 void __iomem *mmio_base;
@@ -804,11 +822,7 @@ struct ufs_hba { · 10 unmodified lines
804 822
805 struct Scsi_Host *host;823 struct Scsi_Host *host;
806 struct device *dev;824 struct device *dev;
807 /*825 struct scsi_device *ufs_device_wlun;
808 * This field is to keep a reference to "scsi_device" corresponding to
809 * "UFS device" W-LU.
810 */
811 struct scsi_device *sdev_ufs_device;
812 826
813#ifdef CONFIG_SCSI_UFS_HWMON827#ifdef CONFIG_SCSI_UFS_HWMON
814 struct device *hwmon_device;828 struct device *hwmon_device;
@@ -859,9 +873,9 @@ struct ufs_hba { · 44 unmodified lines
859 enum ufshcd_state ufshcd_state;873 enum ufshcd_state ufshcd_state;
860 u32 eh_flags;874 u32 eh_flags;
861 u32 intr_mask;875 u32 intr_mask;
862 u16 ee_ctrl_mask; /* Exception event mask */876 u16 ee_ctrl_mask;
863 u16 ee_drv_mask; /* Exception event mask for driver */877 u16 ee_drv_mask;
864 u16 ee_usr_mask; /* Exception event mask for user (via debugfs) */878 u16 ee_usr_mask;
865 struct mutex ee_ctrl_mutex;879 struct mutex ee_ctrl_mutex;
866 bool is_powered;880 bool is_powered;
867 bool shutting_down;881 bool shutting_down;
@@ -983,7 +997,7 @@ static inline bool ufshcd_is_auto_hibern8_supported(struct ufs_hba *hba) · 115 unmodified lines
983 997
984static inline bool ufshcd_is_auto_hibern8_enabled(struct ufs_hba *hba)998static inline bool ufshcd_is_auto_hibern8_enabled(struct ufs_hba *hba)
985{999{
986 return FIELD_GET(UFSHCI_AHIBERN8_TIMER_MASK, hba->ahit) ? true : false;1000 return FIELD_GET(UFSHCI_AHIBERN8_TIMER_MASK, hba->ahit);
987}1001}
988 1002
989static inline bool ufshcd_is_wb_allowed(struct ufs_hba *hba)1003static inline bool ufshcd_is_wb_allowed(struct ufs_hba *hba)
@@ -991,22 +1005,17 @@ static inline bool ufshcd_is_wb_allowed(struct ufs_hba *hba) · 1 unmodified line
991 return hba->caps & UFSHCD_CAP_WB_EN;1005 return hba->caps & UFSHCD_CAP_WB_EN;
992}1006}
993 1007
994static inline bool ufshcd_is_user_access_allowed(struct ufs_hba *hba)
995{
996 return !hba->shutting_down;
997}
998
999#define ufshcd_writel(hba, val, reg) \1008#define ufshcd_writel(hba, val, reg) \
1000 writel((val), (hba)->mmio_base + (reg))1009 writel((val), (hba)->mmio_base + (reg))
1001#define ufshcd_readl(hba, reg) \1010#define ufshcd_readl(hba, reg) \
1002 readl((hba)->mmio_base + (reg))1011 readl((hba)->mmio_base + (reg))
1003 1012
1004/**1013/**
1005 * ufshcd_rmwl - read modify write into a register1014 * ufshcd_rmwl - perform read/modify/write for a controller register
1006 * @hba - per adapter instance1015 * @hba: per adapter instance
1007 * @mask - mask to apply on read value1016 * @mask: mask to apply on read value
1008 * @val - actual value to write1017 * @val: actual value to write
1009 * @reg - register address1018 * @reg: register address
1010 */1019 */
1011static inline void ufshcd_rmwl(struct ufs_hba *hba, u32 mask, u32 val, u32 reg)1020static inline void ufshcd_rmwl(struct ufs_hba *hba, u32 mask, u32 val, u32 reg)
1012{1021{
@@ -1028,9 +1037,6 @@ void ufshcd_remove(struct ufs_hba *); · 15 unmodified lines
1028int ufshcd_uic_hibern8_enter(struct ufs_hba *hba);1037int ufshcd_uic_hibern8_enter(struct ufs_hba *hba);
1029int ufshcd_uic_hibern8_exit(struct ufs_hba *hba);1038int ufshcd_uic_hibern8_exit(struct ufs_hba *hba);
1030void ufshcd_delay_us(unsigned long us, unsigned long tolerance);1039void ufshcd_delay_us(unsigned long us, unsigned long tolerance);
1031int ufshcd_wait_for_register(struct ufs_hba *hba, u32 reg, u32 mask,
1032 u32 val, unsigned long interval_us,
1033 unsigned long timeout_ms);
1034void ufshcd_parse_dev_ref_clk_freq(struct ufs_hba *hba, struct clk *refclk);1040void ufshcd_parse_dev_ref_clk_freq(struct ufs_hba *hba, struct clk *refclk);
1035void ufshcd_update_evt_hist(struct ufs_hba *hba, u32 id, u32 val);1041void ufshcd_update_evt_hist(struct ufs_hba *hba, u32 id, u32 val);
1036void ufshcd_hba_stop(struct ufs_hba *hba);1042void ufshcd_hba_stop(struct ufs_hba *hba);
@@ -1044,8 +1050,8 @@ static inline void check_upiu_size(void) · 7 unmodified lines
1044 1050
1045/**1051/**
1046 * ufshcd_set_variant - set variant specific data to the hba1052 * ufshcd_set_variant - set variant specific data to the hba
1047 * @hba - per adapter instance1053 * @hba: per adapter instance
1048 * @variant - pointer to variant specific data1054 * @variant: pointer to variant specific data
1049 */1055 */
1050static inline void ufshcd_set_variant(struct ufs_hba *hba, void *variant)1056static inline void ufshcd_set_variant(struct ufs_hba *hba, void *variant)
1051{1057{
@@ -1055,35 +1061,13 @@ static inline void ufshcd_set_variant(struct ufs_hba *hba, void *variant) · 3 unmodified lines
1055 1061
1056/**1062/**
1057 * ufshcd_get_variant - get variant specific data from the hba1063 * ufshcd_get_variant - get variant specific data from the hba
1058 * @hba - per adapter instance1064 * @hba: per adapter instance
1059 */1065 */
1060static inline void *ufshcd_get_variant(struct ufs_hba *hba)1066static inline void *ufshcd_get_variant(struct ufs_hba *hba)
1061{1067{
1062 BUG_ON(!hba);1068 BUG_ON(!hba);
1063 return hba->priv;1069 return hba->priv;
1064}1070}
1065static inline bool ufshcd_keep_autobkops_enabled_except_suspend(
1066 struct ufs_hba *hba)
1067{
1068 return hba->caps & UFSHCD_CAP_KEEP_AUTO_BKOPS_ENABLED_EXCEPT_SUSPEND;
1069}
1070
1071static inline u8 ufshcd_wb_get_query_index(struct ufs_hba *hba)
1072{
1073 if (hba->dev_info.wb_buffer_type == WB_BUF_MODE_LU_DEDICATED)
1074 return hba->dev_info.wb_dedicated_lu;
1075 return 0;
1076}
1077
1078#ifdef CONFIG_SCSI_UFS_HWMON
1079void ufs_hwmon_probe(struct ufs_hba *hba, u8 mask);
1080void ufs_hwmon_remove(struct ufs_hba *hba);
1081void ufs_hwmon_notify_event(struct ufs_hba *hba, u8 ee_mask);
1082#else
1083static inline void ufs_hwmon_probe(struct ufs_hba *hba, u8 mask) {}
1084static inline void ufs_hwmon_remove(struct ufs_hba *hba) {}
1085static inline void ufs_hwmon_notify_event(struct ufs_hba *hba, u8 ee_mask) {}
1086#endif
1087 1071
1088#ifdef CONFIG_PM1072#ifdef CONFIG_PM
1089extern int ufshcd_runtime_suspend(struct device *dev);1073extern int ufshcd_runtime_suspend(struct device *dev);
@@ -1185,7 +1169,8 @@ int ufshcd_query_flag(struct ufs_hba *hba, enum query_opcode opcode, · 95 unmodified lines
1185 1169
1186void ufshcd_auto_hibern8_enable(struct ufs_hba *hba);1170void ufshcd_auto_hibern8_enable(struct ufs_hba *hba);
1187void ufshcd_auto_hibern8_update(struct ufs_hba *hba, u32 ahit);1171void ufshcd_auto_hibern8_update(struct ufs_hba *hba, u32 ahit);
1188void ufshcd_fixup_dev_quirks(struct ufs_hba *hba, struct ufs_dev_fix *fixups);1172void ufshcd_fixup_dev_quirks(struct ufs_hba *hba,
1173 const struct ufs_dev_quirk *fixups);
1189#define SD_ASCII_STD true1174#define SD_ASCII_STD true
1190#define SD_RAW false1175#define SD_RAW false
1191int ufshcd_read_string_desc(struct ufs_hba *hba, u8 desc_index,1176int ufshcd_read_string_desc(struct ufs_hba *hba, u8 desc_index,
@@ -1194,6 +1179,8 @@ int ufshcd_read_string_desc(struct ufs_hba *hba, u8 desc_index, · 2 unmodified lines
1194int ufshcd_hold(struct ufs_hba *hba, bool async);1179int ufshcd_hold(struct ufs_hba *hba, bool async);
1195void ufshcd_release(struct ufs_hba *hba);1180void ufshcd_release(struct ufs_hba *hba);
1196 1181
1182void ufshcd_clkgate_delay_set(struct device *dev, unsigned long value);
1183
1197void ufshcd_map_desc_id_to_length(struct ufs_hba *hba, enum desc_idn desc_id,1184void ufshcd_map_desc_id_to_length(struct ufs_hba *hba, enum desc_idn desc_id,
1198 int *desc_length);1185 int *desc_length);
1199 1186
@@ -1214,13 +1201,6 @@ int __ufshcd_suspend_prepare(struct device *dev, bool rpm_ok_for_spm); · 14 unmodified lines
1214void ufshcd_resume_complete(struct device *dev);1201void ufshcd_resume_complete(struct device *dev);
1215 1202
1216/* Wrapper functions for safely calling variant operations */1203/* Wrapper functions for safely calling variant operations */
1217static inline const char *ufshcd_get_var_name(struct ufs_hba *hba)
1218{
1219 if (hba->vops)
1220 return hba->vops->name;
1221 return "";
1222}
1223
1224static inline int ufshcd_vops_init(struct ufs_hba *hba)1204static inline int ufshcd_vops_init(struct ufs_hba *hba)
1225{1205{
1226 if (hba->vops && hba->vops->init)1206 if (hba->vops && hba->vops->init)
@@ -1229,61 +1209,6 @@ static inline int ufshcd_vops_init(struct ufs_hba *hba) · 2 unmodified lines
1229 return 0;1209 return 0;
1230}1210}
1231 1211
1232static inline void ufshcd_vops_exit(struct ufs_hba *hba)
1233{
1234 if (hba->vops && hba->vops->exit)
1235 return hba->vops->exit(hba);
1236}
1237
1238static inline u32 ufshcd_vops_get_ufs_hci_version(struct ufs_hba *hba)
1239{
1240 if (hba->vops && hba->vops->get_ufs_hci_version)
1241 return hba->vops->get_ufs_hci_version(hba);
1242
1243 return ufshcd_readl(hba, REG_UFS_VERSION);
1244}
1245
1246static inline int ufshcd_vops_clk_scale_notify(struct ufs_hba *hba,
1247 bool up, enum ufs_notify_change_status status)
1248{
1249 if (hba->vops && hba->vops->clk_scale_notify)
1250 return hba->vops->clk_scale_notify(hba, up, status);
1251 return 0;
1252}
1253
1254static inline void ufshcd_vops_event_notify(struct ufs_hba *hba,
1255 enum ufs_event_type evt,
1256 void *data)
1257{
1258 if (hba->vops && hba->vops->event_notify)
1259 hba->vops->event_notify(hba, evt, data);
1260}
1261
1262static inline int ufshcd_vops_setup_clocks(struct ufs_hba *hba, bool on,
1263 enum ufs_notify_change_status status)
1264{
1265 if (hba->vops && hba->vops->setup_clocks)
1266 return hba->vops->setup_clocks(hba, on, status);
1267 return 0;
1268}
1269
1270static inline int ufshcd_vops_hce_enable_notify(struct ufs_hba *hba,
1271 bool status)
1272{
1273 if (hba->vops && hba->vops->hce_enable_notify)
1274 return hba->vops->hce_enable_notify(hba, status);
1275
1276 return 0;
1277}
1278static inline int ufshcd_vops_link_startup_notify(struct ufs_hba *hba,
1279 bool status)
1280{
1281 if (hba->vops && hba->vops->link_startup_notify)
1282 return hba->vops->link_startup_notify(hba, status);
1283
1284 return 0;
1285}
1286
1287static inline int ufshcd_vops_phy_initialization(struct ufs_hba *hba)1212static inline int ufshcd_vops_phy_initialization(struct ufs_hba *hba)
1288{1213{
1289 if (hba->vops && hba->vops->phy_initialization)1214 if (hba->vops && hba->vops->phy_initialization)
@@ -1292,102 +1217,8 @@ static inline int ufshcd_vops_phy_initialization(struct ufs_hba *hba) · 2 unmodified lines
1292 return 0;1217 return 0;
1293}1218}
1294 1219
1295static inline int ufshcd_vops_pwr_change_notify(struct ufs_hba *hba,
1296 enum ufs_notify_change_status status,
1297 struct ufs_pa_layer_attr *dev_max_params,
1298 struct ufs_pa_layer_attr *dev_req_params)
1299{
1300 if (hba->vops && hba->vops->pwr_change_notify)
1301 return hba->vops->pwr_change_notify(hba, status,
1302 dev_max_params, dev_req_params);
1303
1304 return -ENOTSUPP;
1305}
1306
1307static inline void ufshcd_vops_setup_task_mgmt(struct ufs_hba *hba,
1308 int tag, u8 tm_function)
1309{
1310 if (hba->vops && hba->vops->setup_task_mgmt)
1311 return hba->vops->setup_task_mgmt(hba, tag, tm_function);
1312}
1313
1314static inline void ufshcd_vops_hibern8_notify(struct ufs_hba *hba,
1315 enum uic_cmd_dme cmd,
1316 enum ufs_notify_change_status status)
1317{
1318 if (hba->vops && hba->vops->hibern8_notify)
1319 return hba->vops->hibern8_notify(hba, cmd, status);
1320}
1321
1322static inline int ufshcd_vops_apply_dev_quirks(struct ufs_hba *hba)
1323{
1324 if (hba->vops && hba->vops->apply_dev_quirks)
1325 return hba->vops->apply_dev_quirks(hba);
1326 return 0;
1327}
1328
1329static inline void ufshcd_vops_fixup_dev_quirks(struct ufs_hba *hba)
1330{
1331 if (hba->vops && hba->vops->fixup_dev_quirks)
1332 hba->vops->fixup_dev_quirks(hba);
1333}
1334
1335static inline int ufshcd_vops_suspend(struct ufs_hba *hba, enum ufs_pm_op op,
1336 enum ufs_notify_change_status status)
1337{
1338 if (hba->vops && hba->vops->suspend)
1339 return hba->vops->suspend(hba, op, status);
1340
1341 return 0;
1342}
1343
1344static inline int ufshcd_vops_resume(struct ufs_hba *hba, enum ufs_pm_op op)
1345{
1346 if (hba->vops && hba->vops->resume)
1347 return hba->vops->resume(hba, op);
1348
1349 return 0;
1350}
1351
1352static inline void ufshcd_vops_dbg_register_dump(struct ufs_hba *hba)
1353{
1354 if (hba->vops && hba->vops->dbg_register_dump)
1355 hba->vops->dbg_register_dump(hba);
1356}
1357
1358static inline int ufshcd_vops_device_reset(struct ufs_hba *hba)
1359{
1360 if (hba->vops && hba->vops->device_reset)
1361 return hba->vops->device_reset(hba);
1362
1363 return -EOPNOTSUPP;
1364}
1365
1366static inline void ufshcd_vops_config_scaling_param(struct ufs_hba *hba,
1367 struct devfreq_dev_profile
1368 *profile, void *data)
1369{
1370 if (hba->vops && hba->vops->config_scaling_param)
1371 hba->vops->config_scaling_param(hba, profile, data);
1372}
1373
1374extern struct ufs_pm_lvl_states ufs_pm_lvl_states[];1220extern struct ufs_pm_lvl_states ufs_pm_lvl_states[];
1375 1221
1376/*
1377 * ufshcd_scsi_to_upiu_lun - maps scsi LUN to UPIU LUN
1378 * @scsi_lun: scsi LUN id
1379 *
1380 * Returns UPIU LUN id
1381 */
1382static inline u8 ufshcd_scsi_to_upiu_lun(unsigned int scsi_lun)
1383{
1384 if (scsi_is_wlun(scsi_lun))
1385 return (scsi_lun & UFS_UPIU_MAX_UNIT_NUM_ID)
1386 | UFS_UPIU_WLUN_ID;
1387 else
1388 return scsi_lun & UFS_UPIU_MAX_UNIT_NUM_ID;
1389}
1390
1391int ufshcd_dump_regs(struct ufs_hba *hba, size_t offset, size_t len,1222int ufshcd_dump_regs(struct ufs_hba *hba, size_t offset, size_t len,
1392 const char *prefix);1223 const char *prefix);
1393 1224
@@ -1396,43 +1227,4 @@ int ufshcd_write_ee_control(struct ufs_hba *hba); · 2 unmodified lines
1396int ufshcd_update_ee_control(struct ufs_hba *hba, u16 *mask, u16 *other_mask,1227int ufshcd_update_ee_control(struct ufs_hba *hba, u16 *mask, u16 *other_mask,
1397 u16 set, u16 clr);1228 u16 set, u16 clr);
1398 1229
1399static inline int ufshcd_update_ee_drv_mask(struct ufs_hba *hba,
1400 u16 set, u16 clr)
1401{
1402 return ufshcd_update_ee_control(hba, &hba->ee_drv_mask,
1403 &hba->ee_usr_mask, set, clr);
1404}
1405
1406static inline int ufshcd_update_ee_usr_mask(struct ufs_hba *hba,
1407 u16 set, u16 clr)
1408{
1409 return ufshcd_update_ee_control(hba, &hba->ee_usr_mask,
1410 &hba->ee_drv_mask, set, clr);
1411}
1412
1413static inline int ufshcd_rpm_get_sync(struct ufs_hba *hba)
1414{
1415 return pm_runtime_get_sync(&hba->sdev_ufs_device->sdev_gendev);
1416}
1417
1418static inline int ufshcd_rpm_put_sync(struct ufs_hba *hba)
1419{
1420 return pm_runtime_put_sync(&hba->sdev_ufs_device->sdev_gendev);
1421}
1422
1423static inline void ufshcd_rpm_get_noresume(struct ufs_hba *hba)
1424{
1425 pm_runtime_get_noresume(&hba->sdev_ufs_device->sdev_gendev);
1426}
1427
1428static inline int ufshcd_rpm_resume(struct ufs_hba *hba)
1429{
1430 return pm_runtime_resume(&hba->sdev_ufs_device->sdev_gendev);
1431}
1432
1433static inline int ufshcd_rpm_put(struct ufs_hba *hba)
1434{
1435 return pm_runtime_put(&hba->sdev_ufs_device->sdev_gendev);
1436}
1437
1438#endif /* End of Header */1230#endif /* End of Header */
drivers/scsi/ufs/ufshci.h+2−0
@@ -11,6 +11,8 @@ · 10 unmodified lines
11#ifndef _UFSHCI_H11#ifndef _UFSHCI_H
12#define _UFSHCI_H12#define _UFSHCI_H
13 13
14#include <scsi/scsi_host.h>
15
14enum {16enum {
15 TASK_REQ_UPIU_SIZE_DWORDS = 8,17 TASK_REQ_UPIU_SIZE_DWORDS = 8,
16 TASK_RSP_UPIU_SIZE_DWORDS = 8,18 TASK_RSP_UPIU_SIZE_DWORDS = 8,
drivers/scsi/ufs/ufshpb.c+112−91
@@ -10,8 +10,12 @@ · 9 unmodified lines
10 */10 */
11 11
12#include <asm/unaligned.h>12#include <asm/unaligned.h>
13#include <linux/delay.h>
14#include <linux/device.h>
15#include <linux/module.h>
16#include <scsi/scsi_cmnd.h>
13 17
14#include "ufshcd.h"18#include "ufshcd-priv.h"
15#include "ufshpb.h"19#include "ufshpb.h"
16#include "../sd.h"20#include "../sd.h"
17 21
@@ -90,12 +94,8 @@ static bool ufshpb_is_general_lun(int lun) · 72 unmodified lines
90 94
91static bool ufshpb_is_pinned_region(struct ufshpb_lu *hpb, int rgn_idx)95static bool ufshpb_is_pinned_region(struct ufshpb_lu *hpb, int rgn_idx)
92{96{
93 if (hpb->lu_pinned_end != PINNED_NOT_SET &&97 return hpb->lu_pinned_end != PINNED_NOT_SET &&
94 rgn_idx >= hpb->lu_pinned_start &&98 rgn_idx >= hpb->lu_pinned_start && rgn_idx <= hpb->lu_pinned_end;
95 rgn_idx <= hpb->lu_pinned_end)
96 return true;
97
98 return false;
99}99}
100 100
101static void ufshpb_kick_map_work(struct ufshpb_lu *hpb)101static void ufshpb_kick_map_work(struct ufshpb_lu *hpb)
@@ -563,7 +563,7 @@ static void ufshpb_update_active_info(struct ufshpb_lu *hpb, int rgn_idx, · 461 unmodified lines
563 if (list_empty(&srgn->list_act_srgn))563 if (list_empty(&srgn->list_act_srgn))
564 list_add_tail(&srgn->list_act_srgn, &hpb->lh_act_srgn);564 list_add_tail(&srgn->list_act_srgn, &hpb->lh_act_srgn);
565 565
566 hpb->stats.rb_active_cnt++;566 hpb->stats.rcmd_active_cnt++;
567}567}
568 568
569static void ufshpb_update_inactive_info(struct ufshpb_lu *hpb, int rgn_idx)569static void ufshpb_update_inactive_info(struct ufshpb_lu *hpb, int rgn_idx)
@@ -580,7 +580,7 @@ static void ufshpb_update_inactive_info(struct ufshpb_lu *hpb, int rgn_idx) · 10 unmodified lines
580 if (list_empty(&rgn->list_inact_rgn))580 if (list_empty(&rgn->list_inact_rgn))
581 list_add_tail(&rgn->list_inact_rgn, &hpb->lh_inact_rgn);581 list_add_tail(&rgn->list_inact_rgn, &hpb->lh_inact_rgn);
582 582
583 hpb->stats.rb_inactive_cnt++;583 hpb->stats.rcmd_inactive_cnt++;
584}584}
585 585
586static void ufshpb_activate_subregion(struct ufshpb_lu *hpb,586static void ufshpb_activate_subregion(struct ufshpb_lu *hpb,
@@ -930,11 +930,6 @@ static int ufshpb_issue_umap_single_req(struct ufshpb_lu *hpb, · 343 unmodified lines
930 return ufshpb_issue_umap_req(hpb, rgn, true);930 return ufshpb_issue_umap_req(hpb, rgn, true);
931}931}
932 932
933static int ufshpb_issue_umap_all_req(struct ufshpb_lu *hpb)
934{
935 return ufshpb_issue_umap_req(hpb, NULL, false);
936}
937
938static void __ufshpb_evict_region(struct ufshpb_lu *hpb,933static void __ufshpb_evict_region(struct ufshpb_lu *hpb,
939 struct ufshpb_region *rgn)934 struct ufshpb_region *rgn)
940{935{
@@ -1142,6 +1137,39 @@ out: · 201 unmodified lines
1142 spin_unlock_irqrestore(&hpb->rgn_state_lock, flags);1137 spin_unlock_irqrestore(&hpb->rgn_state_lock, flags);
1143 return ret;1138 return ret;
1144}1139}
1140/**
1141 *ufshpb_submit_region_inactive() - submit a region to be inactivated later
1142 *@hpb: per-LU HPB instance
1143 *@region_index: the index associated with the region that will be inactivated later
1144 */
1145static void ufshpb_submit_region_inactive(struct ufshpb_lu *hpb, int region_index)
1146{
1147 int subregion_index;
1148 struct ufshpb_region *rgn;
1149 struct ufshpb_subregion *srgn;
1150
1151 /*
1152 * Remove this region from active region list and add it to inactive list
1153 */
1154 spin_lock(&hpb->rsp_list_lock);
1155 ufshpb_update_inactive_info(hpb, region_index);
1156 spin_unlock(&hpb->rsp_list_lock);
1157
1158 rgn = hpb->rgn_tbl + region_index;
1159
1160 /*
1161 * Set subregion state to be HPB_SRGN_INVALID, there will no HPB read on this subregion
1162 */
1163 spin_lock(&hpb->rgn_state_lock);
1164 if (rgn->rgn_state != HPB_RGN_INACTIVE) {
1165 for (subregion_index = 0; subregion_index < rgn->srgn_cnt; subregion_index++) {
1166 srgn = rgn->srgn_tbl + subregion_index;
1167 if (srgn->srgn_state == HPB_SRGN_VALID)
1168 srgn->srgn_state = HPB_SRGN_INVALID;
1169 }
1170 }
1171 spin_unlock(&hpb->rgn_state_lock);
1172}
1145 1173
1146static void ufshpb_rsp_req_region_update(struct ufshpb_lu *hpb,1174static void ufshpb_rsp_req_region_update(struct ufshpb_lu *hpb,
1147 struct utp_hpb_rsp *rsp_field)1175 struct utp_hpb_rsp *rsp_field)
@@ -1201,25 +1229,8 @@ static void ufshpb_rsp_req_region_update(struct ufshpb_lu *hpb, · 53 unmodified lines
1201 1229
1202 for (i = 0; i < rsp_field->inactive_rgn_cnt; i++) {1230 for (i = 0; i < rsp_field->inactive_rgn_cnt; i++) {
1203 rgn_i = be16_to_cpu(rsp_field->hpb_inactive_field[i]);1231 rgn_i = be16_to_cpu(rsp_field->hpb_inactive_field[i]);
1204 dev_dbg(&hpb->sdev_ufs_lu->sdev_dev,1232 dev_dbg(&hpb->sdev_ufs_lu->sdev_dev, "inactivate(%d) region %d\n", i, rgn_i);
1205 "inactivate(%d) region %d\n", i, rgn_i);1233 ufshpb_submit_region_inactive(hpb, rgn_i);
1206
1207 spin_lock(&hpb->rsp_list_lock);
1208 ufshpb_update_inactive_info(hpb, rgn_i);
1209 spin_unlock(&hpb->rsp_list_lock);
1210
1211 rgn = hpb->rgn_tbl + rgn_i;
1212
1213 spin_lock(&hpb->rgn_state_lock);
1214 if (rgn->rgn_state != HPB_RGN_INACTIVE) {
1215 for (srgn_i = 0; srgn_i < rgn->srgn_cnt; srgn_i++) {
1216 srgn = rgn->srgn_tbl + srgn_i;
1217 if (srgn->srgn_state == HPB_SRGN_VALID)
1218 srgn->srgn_state = HPB_SRGN_INVALID;
1219 }
1220 }
1221 spin_unlock(&hpb->rgn_state_lock);
1222
1223 }1234 }
1224 1235
1225out:1236out:
@@ -1230,7 +1241,10 @@ out: · 4 unmodified lines
1230 queue_work(ufshpb_wq, &hpb->map_work);1241 queue_work(ufshpb_wq, &hpb->map_work);
1231}1242}
1232 1243
1233static void ufshpb_dev_reset_handler(struct ufshpb_lu *hpb)1244/*
1245 * Set the flags of all active regions to RGN_FLAG_UPDATE to let host side reload L2P entries later
1246 */
1247static void ufshpb_set_regions_update(struct ufshpb_lu *hpb)
1234{1248{
1235 struct victim_select_info *lru_info = &hpb->lru_info;1249 struct victim_select_info *lru_info = &hpb->lru_info;
1236 struct ufshpb_region *rgn;1250 struct ufshpb_region *rgn;
@@ -1244,6 +1258,42 @@ static void ufshpb_dev_reset_handler(struct ufshpb_lu *hpb) · 7 unmodified lines
1244 spin_unlock_irqrestore(&hpb->rgn_state_lock, flags);1258 spin_unlock_irqrestore(&hpb->rgn_state_lock, flags);
1245}1259}
1246 1260
1261static void ufshpb_dev_reset_handler(struct ufs_hba *hba)
1262{
1263 struct scsi_device *sdev;
1264 struct ufshpb_lu *hpb;
1265
1266 __shost_for_each_device(sdev, hba->host) {
1267 hpb = ufshpb_get_hpb_data(sdev);
1268 if (!hpb)
1269 continue;
1270
1271 if (hpb->is_hcm) {
1272 /*
1273 * For the HPB host control mode, in case device powered up and lost HPB
1274 * information, we will set the region flag to be RGN_FLAG_UPDATE, it will
1275 * let host reload its L2P entries(reactivate region in the UFS device).
1276 */
1277 ufshpb_set_regions_update(hpb);
1278 } else {
1279 /*
1280 * For the HPB device control mode, if host side receives 02h:HPB Operation
1281 * in UPIU response, which means device recommends the host side should
1282 * inactivate all active regions. Here we add all active regions to inactive
1283 * list, they will be inactivated later in ufshpb_map_work_handler().
1284 */
1285 struct victim_select_info *lru_info = &hpb->lru_info;
1286 struct ufshpb_region *rgn;
1287
1288 list_for_each_entry(rgn, &lru_info->lh_lru_rgn, list_lru_rgn)
1289 ufshpb_submit_region_inactive(hpb, rgn->rgn_idx);
1290
1291 if (ufshpb_get_state(hpb) == HPB_PRESENT)
1292 queue_work(ufshpb_wq, &hpb->map_work);
1293 }
1294 }
1295}
1296
1247/*1297/*
1248 * This function will parse recommended active subregion information in sense1298 * This function will parse recommended active subregion information in sense
1249 * data field of response UPIU with SAM_STAT_GOOD state.1299 * data field of response UPIU with SAM_STAT_GOOD state.
@@ -1300,7 +1350,7 @@ void ufshpb_rsp_upiu(struct ufs_hba *hba, struct ufshcd_lrb *lrbp) · 50 unmodified lines
1300 if (!ufshpb_is_hpb_rsp_valid(hba, lrbp, rsp_field))1350 if (!ufshpb_is_hpb_rsp_valid(hba, lrbp, rsp_field))
1301 return;1351 return;
1302 1352
1303 hpb->stats.rb_noti_cnt++;1353 hpb->stats.rcmd_noti_cnt++;
1304 1354
1305 switch (rsp_field->hpb_op) {1355 switch (rsp_field->hpb_op) {
1306 case HPB_RSP_REQ_REGION_UPDATE:1356 case HPB_RSP_REQ_REGION_UPDATE:
@@ -1313,17 +1363,7 @@ void ufshpb_rsp_upiu(struct ufs_hba *hba, struct ufshcd_lrb *lrbp) · 6 unmodified lines
1313 case HPB_RSP_DEV_RESET:1363 case HPB_RSP_DEV_RESET:
1314 dev_warn(&hpb->sdev_ufs_lu->sdev_dev,1364 dev_warn(&hpb->sdev_ufs_lu->sdev_dev,
1315 "UFS device lost HPB information during PM.\n");1365 "UFS device lost HPB information during PM.\n");
1316 1366 ufshpb_dev_reset_handler(hba);
1317 if (hpb->is_hcm) {
1318 struct scsi_device *sdev;
1319
1320 __shost_for_each_device(sdev, hba->host) {
1321 struct ufshpb_lu *h = sdev->hostdata;
1322
1323 if (h)
1324 ufshpb_dev_reset_handler(h);
1325 }
1326 }
1327 1367
1328 break;1368 break;
1329 default:1369 default:
@@ -1713,18 +1753,18 @@ static DEVICE_ATTR_RO(__name) · 383 unmodified lines
1713 1753
1714ufshpb_sysfs_attr_show_func(hit_cnt);1754ufshpb_sysfs_attr_show_func(hit_cnt);
1715ufshpb_sysfs_attr_show_func(miss_cnt);1755ufshpb_sysfs_attr_show_func(miss_cnt);
1716ufshpb_sysfs_attr_show_func(rb_noti_cnt);1756ufshpb_sysfs_attr_show_func(rcmd_noti_cnt);
1717ufshpb_sysfs_attr_show_func(rb_active_cnt);1757ufshpb_sysfs_attr_show_func(rcmd_active_cnt);
1718ufshpb_sysfs_attr_show_func(rb_inactive_cnt);1758ufshpb_sysfs_attr_show_func(rcmd_inactive_cnt);
1719ufshpb_sysfs_attr_show_func(map_req_cnt);1759ufshpb_sysfs_attr_show_func(map_req_cnt);
1720ufshpb_sysfs_attr_show_func(umap_req_cnt);1760ufshpb_sysfs_attr_show_func(umap_req_cnt);
1721 1761
1722static struct attribute *hpb_dev_stat_attrs[] = {1762static struct attribute *hpb_dev_stat_attrs[] = {
1723 &dev_attr_hit_cnt.attr,1763 &dev_attr_hit_cnt.attr,
1724 &dev_attr_miss_cnt.attr,1764 &dev_attr_miss_cnt.attr,
1725 &dev_attr_rb_noti_cnt.attr,1765 &dev_attr_rcmd_noti_cnt.attr,
1726 &dev_attr_rb_active_cnt.attr,1766 &dev_attr_rcmd_active_cnt.attr,
1727 &dev_attr_rb_inactive_cnt.attr,1767 &dev_attr_rcmd_inactive_cnt.attr,
1728 &dev_attr_map_req_cnt.attr,1768 &dev_attr_map_req_cnt.attr,
1729 &dev_attr_umap_req_cnt.attr,1769 &dev_attr_umap_req_cnt.attr,
1730 NULL,1770 NULL,
@@ -2087,9 +2127,9 @@ static void ufshpb_stat_init(struct ufshpb_lu *hpb) · 356 unmodified lines
2087{2127{
2088 hpb->stats.hit_cnt = 0;2128 hpb->stats.hit_cnt = 0;
2089 hpb->stats.miss_cnt = 0;2129 hpb->stats.miss_cnt = 0;
2090 hpb->stats.rb_noti_cnt = 0;2130 hpb->stats.rcmd_noti_cnt = 0;
2091 hpb->stats.rb_active_cnt = 0;2131 hpb->stats.rcmd_active_cnt = 0;
2092 hpb->stats.rb_inactive_cnt = 0;2132 hpb->stats.rcmd_inactive_cnt = 0;
2093 hpb->stats.map_req_cnt = 0;2133 hpb->stats.map_req_cnt = 0;
2094 hpb->stats.umap_req_cnt = 0;2134 hpb->stats.umap_req_cnt = 0;
2095}2135}
@@ -2272,38 +2312,28 @@ out: · 176 unmodified lines
2272 return flag_res;2312 return flag_res;
2273}2313}
2274 2314
2275void ufshpb_reset(struct ufs_hba *hba)2315/**
2316 * ufshpb_toggle_state - switch HPB state of all LUs
2317 * @hba: per-adapter instance
2318 * @src: expected current HPB state
2319 * @dest: target HPB state to switch to
2320 */
2321void ufshpb_toggle_state(struct ufs_hba *hba, enum UFSHPB_STATE src, enum UFSHPB_STATE dest)
2276{2322{
2277 struct ufshpb_lu *hpb;2323 struct ufshpb_lu *hpb;
2278 struct scsi_device *sdev;2324 struct scsi_device *sdev;
2279 2325
2280 shost_for_each_device(sdev, hba->host) {2326 shost_for_each_device(sdev, hba->host) {
2281 hpb = ufshpb_get_hpb_data(sdev);2327 hpb = ufshpb_get_hpb_data(sdev);
2282 if (!hpb)
2283 continue;
2284 2328
2285 if (ufshpb_get_state(hpb) != HPB_RESET)2329 if (!hpb || ufshpb_get_state(hpb) != src)
2286 continue;2330 continue;
2331 ufshpb_set_state(hpb, dest);
2287 2332
2288 ufshpb_set_state(hpb, HPB_PRESENT);2333 if (dest == HPB_RESET) {
2289 }2334 ufshpb_cancel_jobs(hpb);
2290}2335 ufshpb_discard_rsp_lists(hpb);
2291 2336 }
2292void ufshpb_reset_host(struct ufs_hba *hba)
2293{
2294 struct ufshpb_lu *hpb;
2295 struct scsi_device *sdev;
2296
2297 shost_for_each_device(sdev, hba->host) {
2298 hpb = ufshpb_get_hpb_data(sdev);
2299 if (!hpb)
2300 continue;
2301
2302 if (ufshpb_get_state(hpb) != HPB_PRESENT)
2303 continue;
2304 ufshpb_set_state(hpb, HPB_RESET);
2305 ufshpb_cancel_jobs(hpb);
2306 ufshpb_discard_rsp_lists(hpb);
2307 }2337 }
2308}2338}
2309 2339
@@ -2314,11 +2344,9 @@ void ufshpb_suspend(struct ufs_hba *hba) · 4 unmodified lines
2314 2344
2315 shost_for_each_device(sdev, hba->host) {2345 shost_for_each_device(sdev, hba->host) {
2316 hpb = ufshpb_get_hpb_data(sdev);2346 hpb = ufshpb_get_hpb_data(sdev);
2317 if (!hpb)2347 if (!hpb || ufshpb_get_state(hpb) != HPB_PRESENT)
2318 continue;2348 continue;
2319 2349
2320 if (ufshpb_get_state(hpb) != HPB_PRESENT)
2321 continue;
2322 ufshpb_set_state(hpb, HPB_SUSPEND);2350 ufshpb_set_state(hpb, HPB_SUSPEND);
2323 ufshpb_cancel_jobs(hpb);2351 ufshpb_cancel_jobs(hpb);
2324 }2352 }
@@ -2331,20 +2359,15 @@ void ufshpb_resume(struct ufs_hba *hba) · 6 unmodified lines
2331 2359
2332 shost_for_each_device(sdev, hba->host) {2360 shost_for_each_device(sdev, hba->host) {
2333 hpb = ufshpb_get_hpb_data(sdev);2361 hpb = ufshpb_get_hpb_data(sdev);
2334 if (!hpb)2362 if (!hpb || ufshpb_get_state(hpb) != HPB_SUSPEND)
2335 continue;2363 continue;
2336 2364
2337 if ((ufshpb_get_state(hpb) != HPB_PRESENT) &&
2338 (ufshpb_get_state(hpb) != HPB_SUSPEND))
2339 continue;
2340 ufshpb_set_state(hpb, HPB_PRESENT);2365 ufshpb_set_state(hpb, HPB_PRESENT);
2341 ufshpb_kick_map_work(hpb);2366 ufshpb_kick_map_work(hpb);
2342 if (hpb->is_hcm) {2367 if (hpb->is_hcm) {
2343 unsigned int poll =2368 unsigned int poll = hpb->params.timeout_polling_interval_ms;
2344 hpb->params.timeout_polling_interval_ms;
2345 2369
2346 schedule_delayed_work(&hpb->ufshpb_read_to_work,2370 schedule_delayed_work(&hpb->ufshpb_read_to_work, msecs_to_jiffies(poll));
2347 msecs_to_jiffies(poll));
2348 }2371 }
2349 }2372 }
2350}2373}
@@ -2450,8 +2473,6 @@ static void ufshpb_hpb_lu_prepared(struct ufs_hba *hba) · 99 unmodified lines
2450 ufshpb_set_state(hpb, HPB_PRESENT);2473 ufshpb_set_state(hpb, HPB_PRESENT);
2451 if ((hpb->lu_pinned_end - hpb->lu_pinned_start) > 0)2474 if ((hpb->lu_pinned_end - hpb->lu_pinned_start) > 0)
2452 queue_work(ufshpb_wq, &hpb->map_work);2475 queue_work(ufshpb_wq, &hpb->map_work);
2453 if (!hpb->is_hcm)
2454 ufshpb_issue_umap_all_req(hpb);
2455 } else {2476 } else {
2456 dev_err(hba->dev, "destroy HPB lu %d\n", hpb->lun);2477 dev_err(hba->dev, "destroy HPB lu %d\n", hpb->lun);
2457 ufshpb_destroy_lu(hba, sdev);2478 ufshpb_destroy_lu(hba, sdev);
drivers/scsi/ufs/ufshpb.h+7−9
@@ -59,8 +59,8 @@ enum UFSHPB_MODE { · 58 unmodified lines
59};59};
60 60
61enum UFSHPB_STATE {61enum UFSHPB_STATE {
62 HPB_INIT = 0,62 HPB_INIT,
63 HPB_PRESENT = 1,63 HPB_PRESENT,
64 HPB_SUSPEND,64 HPB_SUSPEND,
65 HPB_FAILED,65 HPB_FAILED,
66 HPB_RESET,66 HPB_RESET,
@@ -211,9 +211,9 @@ struct ufshpb_params { · 144 unmodified lines
211struct ufshpb_stats {211struct ufshpb_stats {
212 u64 hit_cnt;212 u64 hit_cnt;
213 u64 miss_cnt;213 u64 miss_cnt;
214 u64 rb_noti_cnt;214 u64 rcmd_noti_cnt;
215 u64 rb_active_cnt;215 u64 rcmd_active_cnt;
216 u64 rb_inactive_cnt;216 u64 rcmd_inactive_cnt;
217 u64 map_req_cnt;217 u64 map_req_cnt;
218 u64 pre_req_cnt;218 u64 pre_req_cnt;
219 u64 umap_req_cnt;219 u64 umap_req_cnt;
@@ -288,8 +288,7 @@ static int ufshpb_prep(struct ufs_hba *hba, struct ufshcd_lrb *lrbp) { return 0; · 68 unmodified lines
288static void ufshpb_rsp_upiu(struct ufs_hba *hba, struct ufshcd_lrb *lrbp) {}288static void ufshpb_rsp_upiu(struct ufs_hba *hba, struct ufshcd_lrb *lrbp) {}
289static void ufshpb_resume(struct ufs_hba *hba) {}289static void ufshpb_resume(struct ufs_hba *hba) {}
290static void ufshpb_suspend(struct ufs_hba *hba) {}290static void ufshpb_suspend(struct ufs_hba *hba) {}
291static void ufshpb_reset(struct ufs_hba *hba) {}291static void ufshpb_toggle_state(struct ufs_hba *hba, enum UFSHPB_STATE src, enum UFSHPB_STATE dest) {}
292static void ufshpb_reset_host(struct ufs_hba *hba) {}
293static void ufshpb_init(struct ufs_hba *hba) {}292static void ufshpb_init(struct ufs_hba *hba) {}
294static void ufshpb_init_hpb_lu(struct ufs_hba *hba, struct scsi_device *sdev) {}293static void ufshpb_init_hpb_lu(struct ufs_hba *hba, struct scsi_device *sdev) {}
295static void ufshpb_destroy_lu(struct ufs_hba *hba, struct scsi_device *sdev) {}294static void ufshpb_destroy_lu(struct ufs_hba *hba, struct scsi_device *sdev) {}
@@ -303,8 +302,7 @@ int ufshpb_prep(struct ufs_hba *hba, struct ufshcd_lrb *lrbp); · 7 unmodified lines
303void ufshpb_rsp_upiu(struct ufs_hba *hba, struct ufshcd_lrb *lrbp);302void ufshpb_rsp_upiu(struct ufs_hba *hba, struct ufshcd_lrb *lrbp);
304void ufshpb_resume(struct ufs_hba *hba);303void ufshpb_resume(struct ufs_hba *hba);
305void ufshpb_suspend(struct ufs_hba *hba);304void ufshpb_suspend(struct ufs_hba *hba);
306void ufshpb_reset(struct ufs_hba *hba);305void ufshpb_toggle_state(struct ufs_hba *hba, enum UFSHPB_STATE src, enum UFSHPB_STATE dest);
307void ufshpb_reset_host(struct ufs_hba *hba);
308void ufshpb_init(struct ufs_hba *hba);306void ufshpb_init(struct ufs_hba *hba);
309void ufshpb_init_hpb_lu(struct ufs_hba *hba, struct scsi_device *sdev);307void ufshpb_init_hpb_lu(struct ufs_hba *hba, struct scsi_device *sdev);
310void ufshpb_destroy_lu(struct ufs_hba *hba, struct scsi_device *sdev);308void ufshpb_destroy_lu(struct ufs_hba *hba, struct scsi_device *sdev);
drivers/scsi/ufs/unipro.h+1−17
@@ -1,7 +1,5 @@
1/* SPDX-License-Identifier: GPL-2.0-or-later */1/* SPDX-License-Identifier: GPL-2.0-or-later */
2/*2/*
3 * drivers/scsi/ufs/unipro.h
4 *
5 * Copyright (C) 2013 Samsung Electronics Co., Ltd.3 * Copyright (C) 2013 Samsung Electronics Co., Ltd.
6 */4 */
7 5
@@ -103,7 +101,7 @@ · 95 unmodified lines
103#define UNIPRO_CB_OFFSET(x) (0x8000 | x)101#define UNIPRO_CB_OFFSET(x) (0x8000 | x)
104 102
105/*103/*
106 * PHY Adpater attributes104 * PHY Adapter attributes
107 */105 */
108#define PA_ACTIVETXDATALANES 0x1560106#define PA_ACTIVETXDATALANES 0x1560
109#define PA_ACTIVERXDATALANES 0x1580107#define PA_ACTIVERXDATALANES 0x1580
@@ -300,20 +298,6 @@ enum ufs_unipro_ver { · 190 unmodified lines
300#define T_TC0TXMAXSDUSIZE 0x4060298#define T_TC0TXMAXSDUSIZE 0x4060
301#define T_TC1TXMAXSDUSIZE 0x4061299#define T_TC1TXMAXSDUSIZE 0x4061
302 300
303#ifdef FALSE
304#undef FALSE
305#endif
306
307#ifdef TRUE
308#undef TRUE
309#endif
310
311/* Boolean attribute values */
312enum {
313 FALSE = 0,
314 TRUE,
315};
316
317/* CPort setting */301/* CPort setting */
318#define E2EFC_ON (1 << 0)302#define E2EFC_ON (1 << 0)
319#define E2EFC_OFF (0 << 0)303#define E2EFC_OFF (0 << 0)
drivers/scsi/vmw_pvscsi.c+0−1
@@ -1324,7 +1324,6 @@ static u32 pvscsi_get_max_targets(struct pvscsi_adapter *adapter) · 1323 unmodified lines
1324 * indicate success.1324 * indicate success.
1325 */1325 */
1326 header = config_page;1326 header = config_page;
1327 memset(header, 0, sizeof *header);
1328 header->hostStatus = BTSTAT_INVPARAM;1327 header->hostStatus = BTSTAT_INVPARAM;
1329 header->scsiStatus = SDSTAT_CHECK;1328 header->scsiStatus = SDSTAT_CHECK;
1330 1329
drivers/target/iscsi/cxgbit/cxgbit.h+11−11
@@ -189,7 +189,7 @@ struct cxgbit_np { · 188 unmodified lines
189struct cxgbit_sock {189struct cxgbit_sock {
190 struct cxgbit_sock_common com;190 struct cxgbit_sock_common com;
191 struct cxgbit_np *cnp;191 struct cxgbit_np *cnp;
192 struct iscsi_conn *conn;192 struct iscsit_conn *conn;
193 struct l2t_entry *l2t;193 struct l2t_entry *l2t;
194 struct dst_entry *dst;194 struct dst_entry *dst;
195 struct list_head list;195 struct list_head list;
@@ -316,32 +316,32 @@ typedef void (*cxgbit_cplhandler_func)(struct cxgbit_device *, · 120 unmodified lines
316 316
317int cxgbit_setup_np(struct iscsi_np *, struct sockaddr_storage *);317int cxgbit_setup_np(struct iscsi_np *, struct sockaddr_storage *);
318int cxgbit_setup_conn_digest(struct cxgbit_sock *);318int cxgbit_setup_conn_digest(struct cxgbit_sock *);
319int cxgbit_accept_np(struct iscsi_np *, struct iscsi_conn *);319int cxgbit_accept_np(struct iscsi_np *, struct iscsit_conn *);
320void cxgbit_free_np(struct iscsi_np *);320void cxgbit_free_np(struct iscsi_np *);
321void cxgbit_abort_conn(struct cxgbit_sock *csk);321void cxgbit_abort_conn(struct cxgbit_sock *csk);
322void cxgbit_free_conn(struct iscsi_conn *);322void cxgbit_free_conn(struct iscsit_conn *);
323extern cxgbit_cplhandler_func cxgbit_cplhandlers[NUM_CPL_CMDS];323extern cxgbit_cplhandler_func cxgbit_cplhandlers[NUM_CPL_CMDS];
324int cxgbit_get_login_rx(struct iscsi_conn *, struct iscsi_login *);324int cxgbit_get_login_rx(struct iscsit_conn *, struct iscsi_login *);
325int cxgbit_rx_data_ack(struct cxgbit_sock *);325int cxgbit_rx_data_ack(struct cxgbit_sock *);
326int cxgbit_l2t_send(struct cxgbit_device *, struct sk_buff *,326int cxgbit_l2t_send(struct cxgbit_device *, struct sk_buff *,
327 struct l2t_entry *);327 struct l2t_entry *);
328void cxgbit_push_tx_frames(struct cxgbit_sock *);328void cxgbit_push_tx_frames(struct cxgbit_sock *);
329int cxgbit_put_login_tx(struct iscsi_conn *, struct iscsi_login *, u32);329int cxgbit_put_login_tx(struct iscsit_conn *, struct iscsi_login *, u32);
330int cxgbit_xmit_pdu(struct iscsi_conn *, struct iscsi_cmd *,330int cxgbit_xmit_pdu(struct iscsit_conn *, struct iscsit_cmd *,
331 struct iscsi_datain_req *, const void *, u32);331 struct iscsi_datain_req *, const void *, u32);
332void cxgbit_get_r2t_ttt(struct iscsi_conn *, struct iscsi_cmd *,332void cxgbit_get_r2t_ttt(struct iscsit_conn *, struct iscsit_cmd *,
333 struct iscsi_r2t *);333 struct iscsi_r2t *);
334u32 cxgbit_send_tx_flowc_wr(struct cxgbit_sock *);334u32 cxgbit_send_tx_flowc_wr(struct cxgbit_sock *);
335int cxgbit_ofld_send(struct cxgbit_device *, struct sk_buff *);335int cxgbit_ofld_send(struct cxgbit_device *, struct sk_buff *);
336void cxgbit_get_rx_pdu(struct iscsi_conn *);336void cxgbit_get_rx_pdu(struct iscsit_conn *);
337int cxgbit_validate_params(struct iscsi_conn *);337int cxgbit_validate_params(struct iscsit_conn *);
338struct cxgbit_device *cxgbit_find_device(struct net_device *, u8 *);338struct cxgbit_device *cxgbit_find_device(struct net_device *, u8 *);
339 339
340/* DDP */340/* DDP */
341int cxgbit_ddp_init(struct cxgbit_device *);341int cxgbit_ddp_init(struct cxgbit_device *);
342int cxgbit_setup_conn_pgidx(struct cxgbit_sock *, u32);342int cxgbit_setup_conn_pgidx(struct cxgbit_sock *, u32);
343int cxgbit_reserve_ttt(struct cxgbit_sock *, struct iscsi_cmd *);343int cxgbit_reserve_ttt(struct cxgbit_sock *, struct iscsit_cmd *);
344void cxgbit_unmap_cmd(struct iscsi_conn *, struct iscsi_cmd *);344void cxgbit_unmap_cmd(struct iscsit_conn *, struct iscsit_cmd *);
345 345
346static inline346static inline
347struct cxgbi_ppm *cdev2ppm(struct cxgbit_device *cdev)347struct cxgbi_ppm *cdev2ppm(struct cxgbit_device *cdev)
drivers/target/iscsi/cxgbit/cxgbit_cm.c+4−4
@@ -465,7 +465,7 @@ int cxgbit_setup_np(struct iscsi_np *np, struct sockaddr_storage *ksockaddr) · 464 unmodified lines
465}465}
466 466
467static void467static void
468cxgbit_set_conn_info(struct iscsi_np *np, struct iscsi_conn *conn,468cxgbit_set_conn_info(struct iscsi_np *np, struct iscsit_conn *conn,
469 struct cxgbit_sock *csk)469 struct cxgbit_sock *csk)
470{470{
471 conn->login_family = np->np_sockaddr.ss_family;471 conn->login_family = np->np_sockaddr.ss_family;
@@ -473,7 +473,7 @@ cxgbit_set_conn_info(struct iscsi_np *np, struct iscsi_conn *conn, · 1 unmodified line
473 conn->local_sockaddr = csk->com.local_addr;473 conn->local_sockaddr = csk->com.local_addr;
474}474}
475 475
476int cxgbit_accept_np(struct iscsi_np *np, struct iscsi_conn *conn)476int cxgbit_accept_np(struct iscsi_np *np, struct iscsit_conn *conn)
477{477{
478 struct cxgbit_np *cnp = np->np_context;478 struct cxgbit_np *cnp = np->np_context;
479 struct cxgbit_sock *csk;479 struct cxgbit_sock *csk;
@@ -717,7 +717,7 @@ void cxgbit_abort_conn(struct cxgbit_sock *csk) · 237 unmodified lines
717 717
718static void __cxgbit_free_conn(struct cxgbit_sock *csk)718static void __cxgbit_free_conn(struct cxgbit_sock *csk)
719{719{
720 struct iscsi_conn *conn = csk->conn;720 struct iscsit_conn *conn = csk->conn;
721 bool release = false;721 bool release = false;
722 722
723 pr_debug("%s: state %d\n",723 pr_debug("%s: state %d\n",
@@ -751,7 +751,7 @@ static void __cxgbit_free_conn(struct cxgbit_sock *csk) · 27 unmodified lines
751 cxgbit_put_csk(csk);751 cxgbit_put_csk(csk);
752}752}
753 753
754void cxgbit_free_conn(struct iscsi_conn *conn)754void cxgbit_free_conn(struct iscsit_conn *conn)
755{755{
756 __cxgbit_free_conn(conn->context);756 __cxgbit_free_conn(conn->context);
757}757}
drivers/target/iscsi/cxgbit/cxgbit_ddp.c+2−2
@@ -227,7 +227,7 @@ rel_ppods: · 226 unmodified lines
227}227}
228 228
229void229void
230cxgbit_get_r2t_ttt(struct iscsi_conn *conn, struct iscsi_cmd *cmd,230cxgbit_get_r2t_ttt(struct iscsit_conn *conn, struct iscsit_cmd *cmd,
231 struct iscsi_r2t *r2t)231 struct iscsi_r2t *r2t)
232{232{
233 struct cxgbit_sock *csk = conn->context;233 struct cxgbit_sock *csk = conn->context;
@@ -260,7 +260,7 @@ out: · 26 unmodified lines
260 r2t->targ_xfer_tag = ttinfo->tag;260 r2t->targ_xfer_tag = ttinfo->tag;
261}261}
262 262
263void cxgbit_unmap_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd)263void cxgbit_unmap_cmd(struct iscsit_conn *conn, struct iscsit_cmd *cmd)
264{264{
265 struct cxgbit_cmd *ccmd = iscsit_priv_cmd(cmd);265 struct cxgbit_cmd *ccmd = iscsit_priv_cmd(cmd);
266 266
drivers/target/iscsi/cxgbit/cxgbit_main.c+1−1
@@ -657,7 +657,7 @@ cxgbit_dcbevent_notify(struct notifier_block *nb, unsigned long action, · 656 unmodified lines
657}657}
658#endif658#endif
659 659
660static enum target_prot_op cxgbit_get_sup_prot_ops(struct iscsi_conn *conn)660static enum target_prot_op cxgbit_get_sup_prot_ops(struct iscsit_conn *conn)
661{661{
662 return TARGET_PROT_NORMAL;662 return TARGET_PROT_NORMAL;
663}663}
drivers/target/iscsi/cxgbit/cxgbit_target.c+36−36
@@ -337,7 +337,7 @@ unlock: · 336 unmodified lines
337}337}
338 338
339static int339static int
340cxgbit_map_skb(struct iscsi_cmd *cmd, struct sk_buff *skb, u32 data_offset,340cxgbit_map_skb(struct iscsit_cmd *cmd, struct sk_buff *skb, u32 data_offset,
341 u32 data_length)341 u32 data_length)
342{342{
343 u32 i = 0, nr_frags = MAX_SKB_FRAGS;343 u32 i = 0, nr_frags = MAX_SKB_FRAGS;
@@ -390,10 +390,10 @@ cxgbit_map_skb(struct iscsi_cmd *cmd, struct sk_buff *skb, u32 data_offset, · 46 unmodified lines
390}390}
391 391
392static int392static int
393cxgbit_tx_datain_iso(struct cxgbit_sock *csk, struct iscsi_cmd *cmd,393cxgbit_tx_datain_iso(struct cxgbit_sock *csk, struct iscsit_cmd *cmd,
394 struct iscsi_datain_req *dr)394 struct iscsi_datain_req *dr)
395{395{
396 struct iscsi_conn *conn = csk->conn;396 struct iscsit_conn *conn = csk->conn;
397 struct sk_buff *skb;397 struct sk_buff *skb;
398 struct iscsi_datain datain;398 struct iscsi_datain datain;
399 struct cxgbit_iso_info iso_info;399 struct cxgbit_iso_info iso_info;
@@ -481,7 +481,7 @@ out: · 81 unmodified lines
481}481}
482 482
483static int483static int
484cxgbit_tx_datain(struct cxgbit_sock *csk, struct iscsi_cmd *cmd,484cxgbit_tx_datain(struct cxgbit_sock *csk, struct iscsit_cmd *cmd,
485 const struct iscsi_datain *datain)485 const struct iscsi_datain *datain)
486{486{
487 struct sk_buff *skb;487 struct sk_buff *skb;
@@ -510,7 +510,7 @@ cxgbit_tx_datain(struct cxgbit_sock *csk, struct iscsi_cmd *cmd, · 22 unmodified lines
510}510}
511 511
512static int512static int
513cxgbit_xmit_datain_pdu(struct iscsi_conn *conn, struct iscsi_cmd *cmd,513cxgbit_xmit_datain_pdu(struct iscsit_conn *conn, struct iscsit_cmd *cmd,
514 struct iscsi_datain_req *dr,514 struct iscsi_datain_req *dr,
515 const struct iscsi_datain *datain)515 const struct iscsi_datain *datain)
516{516{
@@ -530,7 +530,7 @@ cxgbit_xmit_datain_pdu(struct iscsi_conn *conn, struct iscsi_cmd *cmd, · 13 unmodified lines
530}530}
531 531
532static int532static int
533cxgbit_xmit_nondatain_pdu(struct iscsi_conn *conn, struct iscsi_cmd *cmd,533cxgbit_xmit_nondatain_pdu(struct iscsit_conn *conn, struct iscsit_cmd *cmd,
534 const void *data_buf, u32 data_buf_len)534 const void *data_buf, u32 data_buf_len)
535{535{
536 struct cxgbit_sock *csk = conn->context;536 struct cxgbit_sock *csk = conn->context;
@@ -560,7 +560,7 @@ cxgbit_xmit_nondatain_pdu(struct iscsi_conn *conn, struct iscsi_cmd *cmd, · 23 unmodified lines
560}560}
561 561
562int562int
563cxgbit_xmit_pdu(struct iscsi_conn *conn, struct iscsi_cmd *cmd,563cxgbit_xmit_pdu(struct iscsit_conn *conn, struct iscsit_cmd *cmd,
564 struct iscsi_datain_req *dr, const void *buf, u32 buf_len)564 struct iscsi_datain_req *dr, const void *buf, u32 buf_len)
565{565{
566 if (dr)566 if (dr)
@@ -569,7 +569,7 @@ cxgbit_xmit_pdu(struct iscsi_conn *conn, struct iscsi_cmd *cmd, · 2 unmodified lines
569 return cxgbit_xmit_nondatain_pdu(conn, cmd, buf, buf_len);569 return cxgbit_xmit_nondatain_pdu(conn, cmd, buf, buf_len);
570}570}
571 571
572int cxgbit_validate_params(struct iscsi_conn *conn)572int cxgbit_validate_params(struct iscsit_conn *conn)
573{573{
574 struct cxgbit_sock *csk = conn->context;574 struct cxgbit_sock *csk = conn->context;
575 struct cxgbit_device *cdev = csk->com.cdev;575 struct cxgbit_device *cdev = csk->com.cdev;
@@ -595,7 +595,7 @@ int cxgbit_validate_params(struct iscsi_conn *conn) · 19 unmodified lines
595 595
596static int cxgbit_set_digest(struct cxgbit_sock *csk)596static int cxgbit_set_digest(struct cxgbit_sock *csk)
597{597{
598 struct iscsi_conn *conn = csk->conn;598 struct iscsit_conn *conn = csk->conn;
599 struct iscsi_param *param;599 struct iscsi_param *param;
600 600
601 param = iscsi_find_param_from_key(HEADERDIGEST, conn->param_list);601 param = iscsi_find_param_from_key(HEADERDIGEST, conn->param_list);
@@ -627,7 +627,7 @@ static int cxgbit_set_digest(struct cxgbit_sock *csk) · 25 unmodified lines
627 627
628static int cxgbit_set_iso_npdu(struct cxgbit_sock *csk)628static int cxgbit_set_iso_npdu(struct cxgbit_sock *csk)
629{629{
630 struct iscsi_conn *conn = csk->conn;630 struct iscsit_conn *conn = csk->conn;
631 struct iscsi_conn_ops *conn_ops = conn->conn_ops;631 struct iscsi_conn_ops *conn_ops = conn->conn_ops;
632 struct iscsi_param *param;632 struct iscsi_param *param;
633 u32 mrdsl, mbl;633 u32 mrdsl, mbl;
@@ -678,7 +678,7 @@ static int cxgbit_set_iso_npdu(struct cxgbit_sock *csk) · 44 unmodified lines
678 */678 */
679static int cxgbit_seq_pdu_inorder(struct cxgbit_sock *csk)679static int cxgbit_seq_pdu_inorder(struct cxgbit_sock *csk)
680{680{
681 struct iscsi_conn *conn = csk->conn;681 struct iscsit_conn *conn = csk->conn;
682 struct iscsi_param *param;682 struct iscsi_param *param;
683 683
684 if (conn->login->leading_connection) {684 if (conn->login->leading_connection) {
@@ -712,7 +712,7 @@ static int cxgbit_seq_pdu_inorder(struct cxgbit_sock *csk) · 27 unmodified lines
712 return 0;712 return 0;
713}713}
714 714
715static int cxgbit_set_params(struct iscsi_conn *conn)715static int cxgbit_set_params(struct iscsit_conn *conn)
716{716{
717 struct cxgbit_sock *csk = conn->context;717 struct cxgbit_sock *csk = conn->context;
718 struct cxgbit_device *cdev = csk->com.cdev;718 struct cxgbit_device *cdev = csk->com.cdev;
@@ -771,7 +771,7 @@ enable_ddp: · 52 unmodified lines
771}771}
772 772
773int773int
774cxgbit_put_login_tx(struct iscsi_conn *conn, struct iscsi_login *login,774cxgbit_put_login_tx(struct iscsit_conn *conn, struct iscsi_login *login,
775 u32 length)775 u32 length)
776{776{
777 struct cxgbit_sock *csk = conn->context;777 struct cxgbit_sock *csk = conn->context;
@@ -832,16 +832,16 @@ cxgbit_skb_copy_to_sg(struct sk_buff *skb, struct scatterlist *sg, · 54 unmodified lines
832 }832 }
833}833}
834 834
835static struct iscsi_cmd *cxgbit_allocate_cmd(struct cxgbit_sock *csk)835static struct iscsit_cmd *cxgbit_allocate_cmd(struct cxgbit_sock *csk)
836{836{
837 struct iscsi_conn *conn = csk->conn;837 struct iscsit_conn *conn = csk->conn;
838 struct cxgbi_ppm *ppm = cdev2ppm(csk->com.cdev);838 struct cxgbi_ppm *ppm = cdev2ppm(csk->com.cdev);
839 struct cxgbit_cmd *ccmd;839 struct cxgbit_cmd *ccmd;
840 struct iscsi_cmd *cmd;840 struct iscsit_cmd *cmd;
841 841
842 cmd = iscsit_allocate_cmd(conn, TASK_INTERRUPTIBLE);842 cmd = iscsit_allocate_cmd(conn, TASK_INTERRUPTIBLE);
843 if (!cmd) {843 if (!cmd) {
844 pr_err("Unable to allocate iscsi_cmd + cxgbit_cmd\n");844 pr_err("Unable to allocate iscsit_cmd + cxgbit_cmd\n");
845 return NULL;845 return NULL;
846 }846 }
847 847
@@ -853,10 +853,10 @@ static struct iscsi_cmd *cxgbit_allocate_cmd(struct cxgbit_sock *csk) · 5 unmodified lines
853}853}
854 854
855static int855static int
856cxgbit_handle_immediate_data(struct iscsi_cmd *cmd, struct iscsi_scsi_req *hdr,856cxgbit_handle_immediate_data(struct iscsit_cmd *cmd, struct iscsi_scsi_req *hdr,
857 u32 length)857 u32 length)
858{858{
859 struct iscsi_conn *conn = cmd->conn;859 struct iscsit_conn *conn = cmd->conn;
860 struct cxgbit_sock *csk = conn->context;860 struct cxgbit_sock *csk = conn->context;
861 struct cxgbit_lro_pdu_cb *pdu_cb = cxgbit_rx_pdu_cb(csk->skb);861 struct cxgbit_lro_pdu_cb *pdu_cb = cxgbit_rx_pdu_cb(csk->skb);
862 862
@@ -910,10 +910,10 @@ cxgbit_handle_immediate_data(struct iscsi_cmd *cmd, struct iscsi_scsi_req *hdr, · 47 unmodified lines
910}910}
911 911
912static int912static int
913cxgbit_get_immediate_data(struct iscsi_cmd *cmd, struct iscsi_scsi_req *hdr,913cxgbit_get_immediate_data(struct iscsit_cmd *cmd, struct iscsi_scsi_req *hdr,
914 bool dump_payload)914 bool dump_payload)
915{915{
916 struct iscsi_conn *conn = cmd->conn;916 struct iscsit_conn *conn = cmd->conn;
917 int cmdsn_ret = 0, immed_ret = IMMEDIATE_DATA_NORMAL_OPERATION;917 int cmdsn_ret = 0, immed_ret = IMMEDIATE_DATA_NORMAL_OPERATION;
918 /*918 /*
919 * Special case for Unsupported SAM WRITE Opcodes and ImmediateData=Yes.919 * Special case for Unsupported SAM WRITE Opcodes and ImmediateData=Yes.
@@ -964,9 +964,9 @@ after_immediate_data: · 44 unmodified lines
964}964}
965 965
966static int966static int
967cxgbit_handle_scsi_cmd(struct cxgbit_sock *csk, struct iscsi_cmd *cmd)967cxgbit_handle_scsi_cmd(struct cxgbit_sock *csk, struct iscsit_cmd *cmd)
968{968{
969 struct iscsi_conn *conn = csk->conn;969 struct iscsit_conn *conn = csk->conn;
970 struct cxgbit_lro_pdu_cb *pdu_cb = cxgbit_rx_pdu_cb(csk->skb);970 struct cxgbit_lro_pdu_cb *pdu_cb = cxgbit_rx_pdu_cb(csk->skb);
971 struct iscsi_scsi_req *hdr = (struct iscsi_scsi_req *)pdu_cb->hdr;971 struct iscsi_scsi_req *hdr = (struct iscsi_scsi_req *)pdu_cb->hdr;
972 int rc;972 int rc;
@@ -995,8 +995,8 @@ cxgbit_handle_scsi_cmd(struct cxgbit_sock *csk, struct iscsi_cmd *cmd) · 22 unmodified lines
995static int cxgbit_handle_iscsi_dataout(struct cxgbit_sock *csk)995static int cxgbit_handle_iscsi_dataout(struct cxgbit_sock *csk)
996{996{
997 struct scatterlist *sg_start;997 struct scatterlist *sg_start;
998 struct iscsi_conn *conn = csk->conn;998 struct iscsit_conn *conn = csk->conn;
999 struct iscsi_cmd *cmd = NULL;999 struct iscsit_cmd *cmd = NULL;
1000 struct cxgbit_cmd *ccmd;1000 struct cxgbit_cmd *ccmd;
1001 struct cxgbi_task_tag_info *ttinfo;1001 struct cxgbi_task_tag_info *ttinfo;
1002 struct cxgbit_lro_pdu_cb *pdu_cb = cxgbit_rx_pdu_cb(csk->skb);1002 struct cxgbit_lro_pdu_cb *pdu_cb = cxgbit_rx_pdu_cb(csk->skb);
@@ -1084,9 +1084,9 @@ check_payload: · 81 unmodified lines
1084 return 0;1084 return 0;
1085}1085}
1086 1086
1087static int cxgbit_handle_nop_out(struct cxgbit_sock *csk, struct iscsi_cmd *cmd)1087static int cxgbit_handle_nop_out(struct cxgbit_sock *csk, struct iscsit_cmd *cmd)
1088{1088{
1089 struct iscsi_conn *conn = csk->conn;1089 struct iscsit_conn *conn = csk->conn;
1090 struct cxgbit_lro_pdu_cb *pdu_cb = cxgbit_rx_pdu_cb(csk->skb);1090 struct cxgbit_lro_pdu_cb *pdu_cb = cxgbit_rx_pdu_cb(csk->skb);
1091 struct iscsi_nopout *hdr = (struct iscsi_nopout *)pdu_cb->hdr;1091 struct iscsi_nopout *hdr = (struct iscsi_nopout *)pdu_cb->hdr;
1092 unsigned char *ping_data = NULL;1092 unsigned char *ping_data = NULL;
@@ -1134,7 +1134,7 @@ static int cxgbit_handle_nop_out(struct cxgbit_sock *csk, struct iscsi_cmd *cmd) · 41 unmodified lines
1134 1134
1135 ping_data[payload_length] = '\0';1135 ping_data[payload_length] = '\0';
1136 /*1136 /*
1137 * Attach ping data to struct iscsi_cmd->buf_ptr.1137 * Attach ping data to struct iscsit_cmd->buf_ptr.
1138 */1138 */
1139 cmd->buf_ptr = ping_data;1139 cmd->buf_ptr = ping_data;
1140 cmd->buf_ptr_size = payload_length;1140 cmd->buf_ptr_size = payload_length;
@@ -1152,9 +1152,9 @@ out: · 11 unmodified lines
1152}1152}
1153 1153
1154static int1154static int
1155cxgbit_handle_text_cmd(struct cxgbit_sock *csk, struct iscsi_cmd *cmd)1155cxgbit_handle_text_cmd(struct cxgbit_sock *csk, struct iscsit_cmd *cmd)
1156{1156{
1157 struct iscsi_conn *conn = csk->conn;1157 struct iscsit_conn *conn = csk->conn;
1158 struct cxgbit_lro_pdu_cb *pdu_cb = cxgbit_rx_pdu_cb(csk->skb);1158 struct cxgbit_lro_pdu_cb *pdu_cb = cxgbit_rx_pdu_cb(csk->skb);
1159 struct iscsi_text *hdr = (struct iscsi_text *)pdu_cb->hdr;1159 struct iscsi_text *hdr = (struct iscsi_text *)pdu_cb->hdr;
1160 u32 payload_length = pdu_cb->dlen;1160 u32 payload_length = pdu_cb->dlen;
@@ -1209,8 +1209,8 @@ static int cxgbit_target_rx_opcode(struct cxgbit_sock *csk) · 48 unmodified lines
1209{1209{
1210 struct cxgbit_lro_pdu_cb *pdu_cb = cxgbit_rx_pdu_cb(csk->skb);1210 struct cxgbit_lro_pdu_cb *pdu_cb = cxgbit_rx_pdu_cb(csk->skb);
1211 struct iscsi_hdr *hdr = (struct iscsi_hdr *)pdu_cb->hdr;1211 struct iscsi_hdr *hdr = (struct iscsi_hdr *)pdu_cb->hdr;
1212 struct iscsi_conn *conn = csk->conn;1212 struct iscsit_conn *conn = csk->conn;
1213 struct iscsi_cmd *cmd = NULL;1213 struct iscsit_cmd *cmd = NULL;
1214 u8 opcode = (hdr->opcode & ISCSI_OPCODE_MASK);1214 u8 opcode = (hdr->opcode & ISCSI_OPCODE_MASK);
1215 int ret = -EINVAL;1215 int ret = -EINVAL;
1216 1216
@@ -1286,7 +1286,7 @@ reject: · 69 unmodified lines
1286static int cxgbit_rx_opcode(struct cxgbit_sock *csk)1286static int cxgbit_rx_opcode(struct cxgbit_sock *csk)
1287{1287{
1288 struct cxgbit_lro_pdu_cb *pdu_cb = cxgbit_rx_pdu_cb(csk->skb);1288 struct cxgbit_lro_pdu_cb *pdu_cb = cxgbit_rx_pdu_cb(csk->skb);
1289 struct iscsi_conn *conn = csk->conn;1289 struct iscsit_conn *conn = csk->conn;
1290 struct iscsi_hdr *hdr = pdu_cb->hdr;1290 struct iscsi_hdr *hdr = pdu_cb->hdr;
1291 u8 opcode;1291 u8 opcode;
1292 1292
@@ -1321,7 +1321,7 @@ transport_err: · 28 unmodified lines
1321 1321
1322static int cxgbit_rx_login_pdu(struct cxgbit_sock *csk)1322static int cxgbit_rx_login_pdu(struct cxgbit_sock *csk)
1323{1323{
1324 struct iscsi_conn *conn = csk->conn;1324 struct iscsit_conn *conn = csk->conn;
1325 struct iscsi_login *login = conn->login;1325 struct iscsi_login *login = conn->login;
1326 struct cxgbit_lro_pdu_cb *pdu_cb = cxgbit_rx_pdu_cb(csk->skb);1326 struct cxgbit_lro_pdu_cb *pdu_cb = cxgbit_rx_pdu_cb(csk->skb);
1327 struct iscsi_login_req *login_req;1327 struct iscsi_login_req *login_req;
@@ -1626,7 +1626,7 @@ out: · 298 unmodified lines
1626 return -1;1626 return -1;
1627}1627}
1628 1628
1629int cxgbit_get_login_rx(struct iscsi_conn *conn, struct iscsi_login *login)1629int cxgbit_get_login_rx(struct iscsit_conn *conn, struct iscsi_login *login)
1630{1630{
1631 struct cxgbit_sock *csk = conn->context;1631 struct cxgbit_sock *csk = conn->context;
1632 int ret = -1;1632 int ret = -1;
@@ -1642,7 +1642,7 @@ int cxgbit_get_login_rx(struct iscsi_conn *conn, struct iscsi_login *login) · 9 unmodified lines
1642 return ret;1642 return ret;
1643}1643}
1644 1644
1645void cxgbit_get_rx_pdu(struct iscsi_conn *conn)1645void cxgbit_get_rx_pdu(struct iscsit_conn *conn)
1646{1646{
1647 struct cxgbit_sock *csk = conn->context;1647 struct cxgbit_sock *csk = conn->context;
1648 1648
drivers/target/iscsi/iscsi_target.c+136−136
@@ -59,7 +59,7 @@ struct kmem_cache *lio_dr_cache; · 58 unmodified lines
59struct kmem_cache *lio_ooo_cache;59struct kmem_cache *lio_ooo_cache;
60struct kmem_cache *lio_r2t_cache;60struct kmem_cache *lio_r2t_cache;
61 61
62static int iscsit_handle_immediate_data(struct iscsi_cmd *,62static int iscsit_handle_immediate_data(struct iscsit_cmd *,
63 struct iscsi_scsi_req *, u32);63 struct iscsi_scsi_req *, u32);
64 64
65struct iscsi_tiqn *iscsit_get_tiqn_for_login(unsigned char *buf)65struct iscsi_tiqn *iscsit_get_tiqn_for_login(unsigned char *buf)
@@ -472,15 +472,15 @@ int iscsit_del_np(struct iscsi_np *np) · 406 unmodified lines
472 return 0;472 return 0;
473}473}
474 474
475static void iscsit_get_rx_pdu(struct iscsi_conn *);475static void iscsit_get_rx_pdu(struct iscsit_conn *);
476 476
477int iscsit_queue_rsp(struct iscsi_conn *conn, struct iscsi_cmd *cmd)477int iscsit_queue_rsp(struct iscsit_conn *conn, struct iscsit_cmd *cmd)
478{478{
479 return iscsit_add_cmd_to_response_queue(cmd, cmd->conn, cmd->i_state);479 return iscsit_add_cmd_to_response_queue(cmd, cmd->conn, cmd->i_state);
480}480}
481EXPORT_SYMBOL(iscsit_queue_rsp);481EXPORT_SYMBOL(iscsit_queue_rsp);
482 482
483void iscsit_aborted_task(struct iscsi_conn *conn, struct iscsi_cmd *cmd)483void iscsit_aborted_task(struct iscsit_conn *conn, struct iscsit_cmd *cmd)
484{484{
485 spin_lock_bh(&conn->cmd_lock);485 spin_lock_bh(&conn->cmd_lock);
486 if (!list_empty(&cmd->i_conn_node))486 if (!list_empty(&cmd->i_conn_node))
@@ -493,10 +493,10 @@ EXPORT_SYMBOL(iscsit_aborted_task); · 6 unmodified lines
493 493
494static void iscsit_do_crypto_hash_buf(struct ahash_request *, const void *,494static void iscsit_do_crypto_hash_buf(struct ahash_request *, const void *,
495 u32, u32, const void *, void *);495 u32, u32, const void *, void *);
496static void iscsit_tx_thread_wait_for_tcp(struct iscsi_conn *);496static void iscsit_tx_thread_wait_for_tcp(struct iscsit_conn *);
497 497
498static int498static int
499iscsit_xmit_nondatain_pdu(struct iscsi_conn *conn, struct iscsi_cmd *cmd,499iscsit_xmit_nondatain_pdu(struct iscsit_conn *conn, struct iscsit_cmd *cmd,
500 const void *data_buf, u32 data_buf_len)500 const void *data_buf, u32 data_buf_len)
501{501{
502 struct iscsi_hdr *hdr = (struct iscsi_hdr *)cmd->pdu;502 struct iscsi_hdr *hdr = (struct iscsi_hdr *)cmd->pdu;
@@ -564,13 +564,13 @@ iscsit_xmit_nondatain_pdu(struct iscsi_conn *conn, struct iscsi_cmd *cmd, · 61 unmodified lines
564 return 0;564 return 0;
565}565}
566 566
567static int iscsit_map_iovec(struct iscsi_cmd *cmd, struct kvec *iov, int nvec,567static int iscsit_map_iovec(struct iscsit_cmd *cmd, struct kvec *iov, int nvec,
568 u32 data_offset, u32 data_length);568 u32 data_offset, u32 data_length);
569static void iscsit_unmap_iovec(struct iscsi_cmd *);569static void iscsit_unmap_iovec(struct iscsit_cmd *);
570static u32 iscsit_do_crypto_hash_sg(struct ahash_request *, struct iscsi_cmd *,570static u32 iscsit_do_crypto_hash_sg(struct ahash_request *, struct iscsit_cmd *,
571 u32, u32, u32, u8 *);571 u32, u32, u32, u8 *);
572static int572static int
573iscsit_xmit_datain_pdu(struct iscsi_conn *conn, struct iscsi_cmd *cmd,573iscsit_xmit_datain_pdu(struct iscsit_conn *conn, struct iscsit_cmd *cmd,
574 const struct iscsi_datain *datain)574 const struct iscsi_datain *datain)
575{575{
576 struct kvec *iov;576 struct kvec *iov;
@@ -644,7 +644,7 @@ iscsit_xmit_datain_pdu(struct iscsi_conn *conn, struct iscsi_cmd *cmd, · 67 unmodified lines
644 return 0;644 return 0;
645}645}
646 646
647static int iscsit_xmit_pdu(struct iscsi_conn *conn, struct iscsi_cmd *cmd,647static int iscsit_xmit_pdu(struct iscsit_conn *conn, struct iscsit_cmd *cmd,
648 struct iscsi_datain_req *dr, const void *buf,648 struct iscsi_datain_req *dr, const void *buf,
649 u32 buf_len)649 u32 buf_len)
650{650{
@@ -654,7 +654,7 @@ static int iscsit_xmit_pdu(struct iscsi_conn *conn, struct iscsi_cmd *cmd, · 3 unmodified lines
654 return iscsit_xmit_nondatain_pdu(conn, cmd, buf, buf_len);654 return iscsit_xmit_nondatain_pdu(conn, cmd, buf, buf_len);
655}655}
656 656
657static enum target_prot_op iscsit_get_sup_prot_ops(struct iscsi_conn *conn)657static enum target_prot_op iscsit_get_sup_prot_ops(struct iscsit_conn *conn)
658{658{
659 return TARGET_PROT_NORMAL;659 return TARGET_PROT_NORMAL;
660}660}
@@ -796,11 +796,11 @@ static void __exit iscsi_target_cleanup_module(void) · 135 unmodified lines
796}796}
797 797
798int iscsit_add_reject(798int iscsit_add_reject(
799 struct iscsi_conn *conn,799 struct iscsit_conn *conn,
800 u8 reason,800 u8 reason,
801 unsigned char *buf)801 unsigned char *buf)
802{802{
803 struct iscsi_cmd *cmd;803 struct iscsit_cmd *cmd;
804 804
805 cmd = iscsit_allocate_cmd(conn, TASK_INTERRUPTIBLE);805 cmd = iscsit_allocate_cmd(conn, TASK_INTERRUPTIBLE);
806 if (!cmd)806 if (!cmd)
@@ -828,12 +828,12 @@ int iscsit_add_reject( · 21 unmodified lines
828EXPORT_SYMBOL(iscsit_add_reject);828EXPORT_SYMBOL(iscsit_add_reject);
829 829
830static int iscsit_add_reject_from_cmd(830static int iscsit_add_reject_from_cmd(
831 struct iscsi_cmd *cmd,831 struct iscsit_cmd *cmd,
832 u8 reason,832 u8 reason,
833 bool add_to_conn,833 bool add_to_conn,
834 unsigned char *buf)834 unsigned char *buf)
835{835{
836 struct iscsi_conn *conn;836 struct iscsit_conn *conn;
837 const bool do_put = cmd->se_cmd.se_tfo != NULL;837 const bool do_put = cmd->se_cmd.se_tfo != NULL;
838 838
839 if (!cmd->conn) {839 if (!cmd->conn) {
@@ -872,13 +872,13 @@ static int iscsit_add_reject_from_cmd( · 32 unmodified lines
872 return -1;872 return -1;
873}873}
874 874
875static int iscsit_add_reject_cmd(struct iscsi_cmd *cmd, u8 reason,875static int iscsit_add_reject_cmd(struct iscsit_cmd *cmd, u8 reason,
876 unsigned char *buf)876 unsigned char *buf)
877{877{
878 return iscsit_add_reject_from_cmd(cmd, reason, true, buf);878 return iscsit_add_reject_from_cmd(cmd, reason, true, buf);
879}879}
880 880
881int iscsit_reject_cmd(struct iscsi_cmd *cmd, u8 reason, unsigned char *buf)881int iscsit_reject_cmd(struct iscsit_cmd *cmd, u8 reason, unsigned char *buf)
882{882{
883 return iscsit_add_reject_from_cmd(cmd, reason, false, buf);883 return iscsit_add_reject_from_cmd(cmd, reason, false, buf);
884}884}
@@ -888,7 +888,7 @@ EXPORT_SYMBOL(iscsit_reject_cmd); · 3 unmodified lines
888 * Map some portion of the allocated scatterlist to an iovec, suitable for888 * Map some portion of the allocated scatterlist to an iovec, suitable for
889 * kernel sockets to copy data in/out.889 * kernel sockets to copy data in/out.
890 */890 */
891static int iscsit_map_iovec(struct iscsi_cmd *cmd, struct kvec *iov, int nvec,891static int iscsit_map_iovec(struct iscsit_cmd *cmd, struct kvec *iov, int nvec,
892 u32 data_offset, u32 data_length)892 u32 data_offset, u32 data_length)
893{893{
894 u32 i = 0, orig_data_length = data_length;894 u32 i = 0, orig_data_length = data_length;
@@ -946,7 +946,7 @@ overflow: · 51 unmodified lines
946 return -1;946 return -1;
947}947}
948 948
949static void iscsit_unmap_iovec(struct iscsi_cmd *cmd)949static void iscsit_unmap_iovec(struct iscsit_cmd *cmd)
950{950{
951 u32 i;951 u32 i;
952 struct scatterlist *sg;952 struct scatterlist *sg;
@@ -957,10 +957,10 @@ static void iscsit_unmap_iovec(struct iscsi_cmd *cmd) · 4 unmodified lines
957 kunmap(sg_page(&sg[i]));957 kunmap(sg_page(&sg[i]));
958}958}
959 959
960static void iscsit_ack_from_expstatsn(struct iscsi_conn *conn, u32 exp_statsn)960static void iscsit_ack_from_expstatsn(struct iscsit_conn *conn, u32 exp_statsn)
961{961{
962 LIST_HEAD(ack_list);962 LIST_HEAD(ack_list);
963 struct iscsi_cmd *cmd, *cmd_p;963 struct iscsit_cmd *cmd, *cmd_p;
964 964
965 conn->exp_statsn = exp_statsn;965 conn->exp_statsn = exp_statsn;
966 966
@@ -987,7 +987,7 @@ static void iscsit_ack_from_expstatsn(struct iscsi_conn *conn, u32 exp_statsn) · 20 unmodified lines
987 }987 }
988}988}
989 989
990static int iscsit_allocate_iovecs(struct iscsi_cmd *cmd)990static int iscsit_allocate_iovecs(struct iscsit_cmd *cmd)
991{991{
992 u32 iov_count = max(1UL, DIV_ROUND_UP(cmd->se_cmd.data_length, PAGE_SIZE));992 u32 iov_count = max(1UL, DIV_ROUND_UP(cmd->se_cmd.data_length, PAGE_SIZE));
993 993
@@ -1000,7 +1000,7 @@ static int iscsit_allocate_iovecs(struct iscsi_cmd *cmd) · 6 unmodified lines
1000 return 0;1000 return 0;
1001}1001}
1002 1002
1003int iscsit_setup_scsi_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd,1003int iscsit_setup_scsi_cmd(struct iscsit_conn *conn, struct iscsit_cmd *cmd,
1004 unsigned char *buf)1004 unsigned char *buf)
1005{1005{
1006 int data_direction, payload_length;1006 int data_direction, payload_length;
@@ -1215,7 +1215,7 @@ attach_cmd: · 208 unmodified lines
1215}1215}
1216EXPORT_SYMBOL(iscsit_setup_scsi_cmd);1216EXPORT_SYMBOL(iscsit_setup_scsi_cmd);
1217 1217
1218void iscsit_set_unsolicited_dataout(struct iscsi_cmd *cmd)1218void iscsit_set_unsolicited_dataout(struct iscsit_cmd *cmd)
1219{1219{
1220 iscsit_set_dataout_sequence_values(cmd);1220 iscsit_set_dataout_sequence_values(cmd);
1221 1221
@@ -1225,7 +1225,7 @@ void iscsit_set_unsolicited_dataout(struct iscsi_cmd *cmd) · 3 unmodified lines
1225}1225}
1226EXPORT_SYMBOL(iscsit_set_unsolicited_dataout);1226EXPORT_SYMBOL(iscsit_set_unsolicited_dataout);
1227 1227
1228int iscsit_process_scsi_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd,1228int iscsit_process_scsi_cmd(struct iscsit_conn *conn, struct iscsit_cmd *cmd,
1229 struct iscsi_scsi_req *hdr)1229 struct iscsi_scsi_req *hdr)
1230{1230{
1231 int cmdsn_ret = 0;1231 int cmdsn_ret = 0;
@@ -1285,7 +1285,7 @@ int iscsit_process_scsi_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd, · 53 unmodified lines
1285EXPORT_SYMBOL(iscsit_process_scsi_cmd);1285EXPORT_SYMBOL(iscsit_process_scsi_cmd);
1286 1286
1287static int1287static int
1288iscsit_get_immediate_data(struct iscsi_cmd *cmd, struct iscsi_scsi_req *hdr,1288iscsit_get_immediate_data(struct iscsit_cmd *cmd, struct iscsi_scsi_req *hdr,
1289 bool dump_payload)1289 bool dump_payload)
1290{1290{
1291 int cmdsn_ret = 0, immed_ret = IMMEDIATE_DATA_NORMAL_OPERATION;1291 int cmdsn_ret = 0, immed_ret = IMMEDIATE_DATA_NORMAL_OPERATION;
@@ -1349,7 +1349,7 @@ iscsit_get_immediate_data(struct iscsi_cmd *cmd, struct iscsi_scsi_req *hdr, · 57 unmodified lines
1349}1349}
1350 1350
1351static int1351static int
1352iscsit_handle_scsi_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd,1352iscsit_handle_scsi_cmd(struct iscsit_conn *conn, struct iscsit_cmd *cmd,
1353 unsigned char *buf)1353 unsigned char *buf)
1354{1354{
1355 struct iscsi_scsi_req *hdr = (struct iscsi_scsi_req *)buf;1355 struct iscsi_scsi_req *hdr = (struct iscsi_scsi_req *)buf;
@@ -1383,7 +1383,7 @@ iscsit_handle_scsi_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd, · 27 unmodified lines
1383 1383
1384static u32 iscsit_do_crypto_hash_sg(1384static u32 iscsit_do_crypto_hash_sg(
1385 struct ahash_request *hash,1385 struct ahash_request *hash,
1386 struct iscsi_cmd *cmd,1386 struct iscsit_cmd *cmd,
1387 u32 data_offset,1387 u32 data_offset,
1388 u32 data_length,1388 u32 data_length,
1389 u32 padding,1389 u32 padding,
@@ -1455,8 +1455,8 @@ static void iscsit_do_crypto_hash_buf(struct ahash_request *hash, · 65 unmodified lines
1455}1455}
1456 1456
1457int1457int
1458__iscsit_check_dataout_hdr(struct iscsi_conn *conn, void *buf,1458__iscsit_check_dataout_hdr(struct iscsit_conn *conn, void *buf,
1459 struct iscsi_cmd *cmd, u32 payload_length,1459 struct iscsit_cmd *cmd, u32 payload_length,
1460 bool *success)1460 bool *success)
1461{1461{
1462 struct iscsi_data *hdr = buf;1462 struct iscsi_data *hdr = buf;
@@ -1559,11 +1559,11 @@ __iscsit_check_dataout_hdr(struct iscsi_conn *conn, void *buf, · 96 unmodified lines
1559EXPORT_SYMBOL(__iscsit_check_dataout_hdr);1559EXPORT_SYMBOL(__iscsit_check_dataout_hdr);
1560 1560
1561int1561int
1562iscsit_check_dataout_hdr(struct iscsi_conn *conn, void *buf,1562iscsit_check_dataout_hdr(struct iscsit_conn *conn, void *buf,
1563 struct iscsi_cmd **out_cmd)1563 struct iscsit_cmd **out_cmd)
1564{1564{
1565 struct iscsi_data *hdr = buf;1565 struct iscsi_data *hdr = buf;
1566 struct iscsi_cmd *cmd;1566 struct iscsit_cmd *cmd;
1567 u32 payload_length = ntoh24(hdr->dlength);1567 u32 payload_length = ntoh24(hdr->dlength);
1568 int rc;1568 int rc;
1569 bool success = false;1569 bool success = false;
@@ -1594,7 +1594,7 @@ iscsit_check_dataout_hdr(struct iscsi_conn *conn, void *buf, · 24 unmodified lines
1594EXPORT_SYMBOL(iscsit_check_dataout_hdr);1594EXPORT_SYMBOL(iscsit_check_dataout_hdr);
1595 1595
1596static int1596static int
1597iscsit_get_dataout(struct iscsi_conn *conn, struct iscsi_cmd *cmd,1597iscsit_get_dataout(struct iscsit_conn *conn, struct iscsit_cmd *cmd,
1598 struct iscsi_data *hdr)1598 struct iscsi_data *hdr)
1599{1599{
1600 struct kvec *iov;1600 struct kvec *iov;
@@ -1662,10 +1662,10 @@ iscsit_get_dataout(struct iscsi_conn *conn, struct iscsi_cmd *cmd, · 61 unmodified lines
1662}1662}
1663 1663
1664int1664int
1665iscsit_check_dataout_payload(struct iscsi_cmd *cmd, struct iscsi_data *hdr,1665iscsit_check_dataout_payload(struct iscsit_cmd *cmd, struct iscsi_data *hdr,
1666 bool data_crc_failed)1666 bool data_crc_failed)
1667{1667{
1668 struct iscsi_conn *conn = cmd->conn;1668 struct iscsit_conn *conn = cmd->conn;
1669 int rc, ooo_cmdsn;1669 int rc, ooo_cmdsn;
1670 /*1670 /*
1671 * Increment post receive data and CRC values or perform1671 * Increment post receive data and CRC values or perform
@@ -1700,9 +1700,9 @@ iscsit_check_dataout_payload(struct iscsi_cmd *cmd, struct iscsi_data *hdr, · 28 unmodified lines
1700}1700}
1701EXPORT_SYMBOL(iscsit_check_dataout_payload);1701EXPORT_SYMBOL(iscsit_check_dataout_payload);
1702 1702
1703static int iscsit_handle_data_out(struct iscsi_conn *conn, unsigned char *buf)1703static int iscsit_handle_data_out(struct iscsit_conn *conn, unsigned char *buf)
1704{1704{
1705 struct iscsi_cmd *cmd = NULL;1705 struct iscsit_cmd *cmd = NULL;
1706 struct iscsi_data *hdr = (struct iscsi_data *)buf;1706 struct iscsi_data *hdr = (struct iscsi_data *)buf;
1707 int rc;1707 int rc;
1708 bool data_crc_failed = false;1708 bool data_crc_failed = false;
@@ -1722,7 +1722,7 @@ static int iscsit_handle_data_out(struct iscsi_conn *conn, unsigned char *buf) · 13 unmodified lines
1722 return iscsit_check_dataout_payload(cmd, hdr, data_crc_failed);1722 return iscsit_check_dataout_payload(cmd, hdr, data_crc_failed);
1723}1723}
1724 1724
1725int iscsit_setup_nop_out(struct iscsi_conn *conn, struct iscsi_cmd *cmd,1725int iscsit_setup_nop_out(struct iscsit_conn *conn, struct iscsit_cmd *cmd,
1726 struct iscsi_nopout *hdr)1726 struct iscsi_nopout *hdr)
1727{1727{
1728 u32 payload_length = ntoh24(hdr->dlength);1728 u32 payload_length = ntoh24(hdr->dlength);
@@ -1770,7 +1770,7 @@ int iscsit_setup_nop_out(struct iscsi_conn *conn, struct iscsi_cmd *cmd, · 41 unmodified lines
1770 * This is not a response to a Unsolicited NopIN, which means1770 * This is not a response to a Unsolicited NopIN, which means
1771 * it can either be a NOPOUT ping request (with a valid ITT),1771 * it can either be a NOPOUT ping request (with a valid ITT),
1772 * or a NOPOUT not requesting a NOPIN (with a reserved ITT).1772 * or a NOPOUT not requesting a NOPIN (with a reserved ITT).
1773 * Either way, make sure we allocate an struct iscsi_cmd, as both1773 * Either way, make sure we allocate an struct iscsit_cmd, as both
1774 * can contain ping data.1774 * can contain ping data.
1775 */1775 */
1776 if (hdr->ttt == cpu_to_be32(0xFFFFFFFF)) {1776 if (hdr->ttt == cpu_to_be32(0xFFFFFFFF)) {
@@ -1789,10 +1789,10 @@ int iscsit_setup_nop_out(struct iscsi_conn *conn, struct iscsi_cmd *cmd, · 12 unmodified lines
1789}1789}
1790EXPORT_SYMBOL(iscsit_setup_nop_out);1790EXPORT_SYMBOL(iscsit_setup_nop_out);
1791 1791
1792int iscsit_process_nop_out(struct iscsi_conn *conn, struct iscsi_cmd *cmd,1792int iscsit_process_nop_out(struct iscsit_conn *conn, struct iscsit_cmd *cmd,
1793 struct iscsi_nopout *hdr)1793 struct iscsi_nopout *hdr)
1794{1794{
1795 struct iscsi_cmd *cmd_p = NULL;1795 struct iscsit_cmd *cmd_p = NULL;
1796 int cmdsn_ret = 0;1796 int cmdsn_ret = 0;
1797 /*1797 /*
1798 * Initiator is expecting a NopIN ping reply..1798 * Initiator is expecting a NopIN ping reply..
@@ -1851,7 +1851,7 @@ int iscsit_process_nop_out(struct iscsi_conn *conn, struct iscsi_cmd *cmd, · 52 unmodified lines
1851}1851}
1852EXPORT_SYMBOL(iscsit_process_nop_out);1852EXPORT_SYMBOL(iscsit_process_nop_out);
1853 1853
1854static int iscsit_handle_nop_out(struct iscsi_conn *conn, struct iscsi_cmd *cmd,1854static int iscsit_handle_nop_out(struct iscsit_conn *conn, struct iscsit_cmd *cmd,
1855 unsigned char *buf)1855 unsigned char *buf)
1856{1856{
1857 unsigned char *ping_data = NULL;1857 unsigned char *ping_data = NULL;
@@ -1936,7 +1936,7 @@ static int iscsit_handle_nop_out(struct iscsi_conn *conn, struct iscsi_cmd *cmd, · 78 unmodified lines
1936 1936
1937 ping_data[payload_length] = '\0';1937 ping_data[payload_length] = '\0';
1938 /*1938 /*
1939 * Attach ping data to struct iscsi_cmd->buf_ptr.1939 * Attach ping data to struct iscsit_cmd->buf_ptr.
1940 */1940 */
1941 cmd->buf_ptr = ping_data;1941 cmd->buf_ptr = ping_data;
1942 cmd->buf_ptr_size = payload_length;1942 cmd->buf_ptr_size = payload_length;
@@ -1978,7 +1978,7 @@ static enum tcm_tmreq_table iscsit_convert_tmf(u8 iscsi_tmf) · 35 unmodified lines
1978}1978}
1979 1979
1980int1980int
1981iscsit_handle_task_mgt_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd,1981iscsit_handle_task_mgt_cmd(struct iscsit_conn *conn, struct iscsit_cmd *cmd,
1982 unsigned char *buf)1982 unsigned char *buf)
1983{1983{
1984 struct se_tmr_req *se_tmr;1984 struct se_tmr_req *se_tmr;
@@ -2159,7 +2159,7 @@ EXPORT_SYMBOL(iscsit_handle_task_mgt_cmd); · 174 unmodified lines
2159 2159
2160/* #warning FIXME: Support Text Command parameters besides SendTargets */2160/* #warning FIXME: Support Text Command parameters besides SendTargets */
2161int2161int
2162iscsit_setup_text_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd,2162iscsit_setup_text_cmd(struct iscsit_conn *conn, struct iscsit_cmd *cmd,
2163 struct iscsi_text *hdr)2163 struct iscsi_text *hdr)
2164{2164{
2165 u32 payload_length = ntoh24(hdr->dlength);2165 u32 payload_length = ntoh24(hdr->dlength);
@@ -2199,7 +2199,7 @@ iscsit_setup_text_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd, · 33 unmodified lines
2199EXPORT_SYMBOL(iscsit_setup_text_cmd);2199EXPORT_SYMBOL(iscsit_setup_text_cmd);
2200 2200
2201int2201int
2202iscsit_process_text_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd,2202iscsit_process_text_cmd(struct iscsit_conn *conn, struct iscsit_cmd *cmd,
2203 struct iscsi_text *hdr)2203 struct iscsi_text *hdr)
2204{2204{
2205 unsigned char *text_in = cmd->text_in_ptr, *text_ptr;2205 unsigned char *text_in = cmd->text_in_ptr, *text_ptr;
@@ -2258,7 +2258,7 @@ reject: · 52 unmodified lines
2258EXPORT_SYMBOL(iscsit_process_text_cmd);2258EXPORT_SYMBOL(iscsit_process_text_cmd);
2259 2259
2260static int2260static int
2261iscsit_handle_text_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd,2261iscsit_handle_text_cmd(struct iscsit_conn *conn, struct iscsit_cmd *cmd,
2262 unsigned char *buf)2262 unsigned char *buf)
2263{2263{
2264 struct iscsi_text *hdr = (struct iscsi_text *)buf;2264 struct iscsi_text *hdr = (struct iscsi_text *)buf;
@@ -2347,10 +2347,10 @@ reject: · 82 unmodified lines
2347 return iscsit_reject_cmd(cmd, ISCSI_REASON_PROTOCOL_ERROR, buf);2347 return iscsit_reject_cmd(cmd, ISCSI_REASON_PROTOCOL_ERROR, buf);
2348}2348}
2349 2349
2350int iscsit_logout_closesession(struct iscsi_cmd *cmd, struct iscsi_conn *conn)2350int iscsit_logout_closesession(struct iscsit_cmd *cmd, struct iscsit_conn *conn)
2351{2351{
2352 struct iscsi_conn *conn_p;2352 struct iscsit_conn *conn_p;
2353 struct iscsi_session *sess = conn->sess;2353 struct iscsit_session *sess = conn->sess;
2354 2354
2355 pr_debug("Received logout request CLOSESESSION on CID: %hu"2355 pr_debug("Received logout request CLOSESESSION on CID: %hu"
2356 " for SID: %u.\n", conn->cid, conn->sess->sid);2356 " for SID: %u.\n", conn->cid, conn->sess->sid);
@@ -2377,10 +2377,10 @@ int iscsit_logout_closesession(struct iscsi_cmd *cmd, struct iscsi_conn *conn) · 20 unmodified lines
2377 return 0;2377 return 0;
2378}2378}
2379 2379
2380int iscsit_logout_closeconnection(struct iscsi_cmd *cmd, struct iscsi_conn *conn)2380int iscsit_logout_closeconnection(struct iscsit_cmd *cmd, struct iscsit_conn *conn)
2381{2381{
2382 struct iscsi_conn *l_conn;2382 struct iscsit_conn *l_conn;
2383 struct iscsi_session *sess = conn->sess;2383 struct iscsit_session *sess = conn->sess;
2384 2384
2385 pr_debug("Received logout request CLOSECONNECTION for CID:"2385 pr_debug("Received logout request CLOSECONNECTION for CID:"
2386 " %hu on CID: %hu.\n", cmd->logout_cid, conn->cid);2386 " %hu on CID: %hu.\n", cmd->logout_cid, conn->cid);
@@ -2425,9 +2425,9 @@ int iscsit_logout_closeconnection(struct iscsi_cmd *cmd, struct iscsi_conn *conn · 38 unmodified lines
2425 return 0;2425 return 0;
2426}2426}
2427 2427
2428int iscsit_logout_removeconnforrecovery(struct iscsi_cmd *cmd, struct iscsi_conn *conn)2428int iscsit_logout_removeconnforrecovery(struct iscsit_cmd *cmd, struct iscsit_conn *conn)
2429{2429{
2430 struct iscsi_session *sess = conn->sess;2430 struct iscsit_session *sess = conn->sess;
2431 2431
2432 pr_debug("Received explicit REMOVECONNFORRECOVERY logout for"2432 pr_debug("Received explicit REMOVECONNFORRECOVERY logout for"
2433 " CID: %hu on CID: %hu.\n", cmd->logout_cid, conn->cid);2433 " CID: %hu on CID: %hu.\n", cmd->logout_cid, conn->cid);
@@ -2455,7 +2455,7 @@ int iscsit_logout_removeconnforrecovery(struct iscsi_cmd *cmd, struct iscsi_conn · 21 unmodified lines
2455}2455}
2456 2456
2457int2457int
2458iscsit_handle_logout_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd,2458iscsit_handle_logout_cmd(struct iscsit_conn *conn, struct iscsit_cmd *cmd,
2459 unsigned char *buf)2459 unsigned char *buf)
2460{2460{
2461 int cmdsn_ret, logout_remove = 0;2461 int cmdsn_ret, logout_remove = 0;
@@ -2536,7 +2536,7 @@ iscsit_handle_logout_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd, · 74 unmodified lines
2536EXPORT_SYMBOL(iscsit_handle_logout_cmd);2536EXPORT_SYMBOL(iscsit_handle_logout_cmd);
2537 2537
2538int iscsit_handle_snack(2538int iscsit_handle_snack(
2539 struct iscsi_conn *conn,2539 struct iscsit_conn *conn,
2540 unsigned char *buf)2540 unsigned char *buf)
2541{2541{
2542 struct iscsi_snack *hdr;2542 struct iscsi_snack *hdr;
@@ -2590,7 +2590,7 @@ int iscsit_handle_snack( · 47 unmodified lines
2590}2590}
2591EXPORT_SYMBOL(iscsit_handle_snack);2591EXPORT_SYMBOL(iscsit_handle_snack);
2592 2592
2593static void iscsit_rx_thread_wait_for_tcp(struct iscsi_conn *conn)2593static void iscsit_rx_thread_wait_for_tcp(struct iscsit_conn *conn)
2594{2594{
2595 if ((conn->sock->sk->sk_shutdown & SEND_SHUTDOWN) ||2595 if ((conn->sock->sk->sk_shutdown & SEND_SHUTDOWN) ||
2596 (conn->sock->sk->sk_shutdown & RCV_SHUTDOWN)) {2596 (conn->sock->sk->sk_shutdown & RCV_SHUTDOWN)) {
@@ -2601,13 +2601,13 @@ static void iscsit_rx_thread_wait_for_tcp(struct iscsi_conn *conn) · 4 unmodified lines
2601}2601}
2602 2602
2603static int iscsit_handle_immediate_data(2603static int iscsit_handle_immediate_data(
2604 struct iscsi_cmd *cmd,2604 struct iscsit_cmd *cmd,
2605 struct iscsi_scsi_req *hdr,2605 struct iscsi_scsi_req *hdr,
2606 u32 length)2606 u32 length)
2607{2607{
2608 int iov_ret, rx_got = 0, rx_size = 0;2608 int iov_ret, rx_got = 0, rx_size = 0;
2609 u32 checksum, iov_count = 0, padding = 0;2609 u32 checksum, iov_count = 0, padding = 0;
2610 struct iscsi_conn *conn = cmd->conn;2610 struct iscsit_conn *conn = cmd->conn;
2611 struct kvec *iov;2611 struct kvec *iov;
2612 void *overflow_buf = NULL;2612 void *overflow_buf = NULL;
2613 2613
@@ -2708,10 +2708,10 @@ static int iscsit_handle_immediate_data( · 94 unmodified lines
2708 2708
2709/* #warning iscsi_build_conn_drop_async_message() only sends out on connections2709/* #warning iscsi_build_conn_drop_async_message() only sends out on connections
2710 with active network interface */2710 with active network interface */
2711static void iscsit_build_conn_drop_async_message(struct iscsi_conn *conn)2711static void iscsit_build_conn_drop_async_message(struct iscsit_conn *conn)
2712{2712{
2713 struct iscsi_cmd *cmd;2713 struct iscsit_cmd *cmd;
2714 struct iscsi_conn *conn_p;2714 struct iscsit_conn *conn_p;
2715 bool found = false;2715 bool found = false;
2716 2716
2717 lockdep_assert_held(&conn->sess->conn_lock);2717 lockdep_assert_held(&conn->sess->conn_lock);
@@ -2750,8 +2750,8 @@ static void iscsit_build_conn_drop_async_message(struct iscsi_conn *conn) · 32 unmodified lines
2750}2750}
2751 2751
2752static int iscsit_send_conn_drop_async_message(2752static int iscsit_send_conn_drop_async_message(
2753 struct iscsi_cmd *cmd,2753 struct iscsit_cmd *cmd,
2754 struct iscsi_conn *conn)2754 struct iscsit_conn *conn)
2755{2755{
2756 struct iscsi_async *hdr;2756 struct iscsi_async *hdr;
2757 2757
@@ -2779,7 +2779,7 @@ static int iscsit_send_conn_drop_async_message( · 21 unmodified lines
2779 return conn->conn_transport->iscsit_xmit_pdu(conn, cmd, NULL, NULL, 0);2779 return conn->conn_transport->iscsit_xmit_pdu(conn, cmd, NULL, NULL, 0);
2780}2780}
2781 2781
2782static void iscsit_tx_thread_wait_for_tcp(struct iscsi_conn *conn)2782static void iscsit_tx_thread_wait_for_tcp(struct iscsit_conn *conn)
2783{2783{
2784 if ((conn->sock->sk->sk_shutdown & SEND_SHUTDOWN) ||2784 if ((conn->sock->sk->sk_shutdown & SEND_SHUTDOWN) ||
2785 (conn->sock->sk->sk_shutdown & RCV_SHUTDOWN)) {2785 (conn->sock->sk->sk_shutdown & RCV_SHUTDOWN)) {
@@ -2790,7 +2790,7 @@ static void iscsit_tx_thread_wait_for_tcp(struct iscsi_conn *conn) · 4 unmodified lines
2790}2790}
2791 2791
2792void2792void
2793iscsit_build_datain_pdu(struct iscsi_cmd *cmd, struct iscsi_conn *conn,2793iscsit_build_datain_pdu(struct iscsit_cmd *cmd, struct iscsit_conn *conn,
2794 struct iscsi_datain *datain, struct iscsi_data_rsp *hdr,2794 struct iscsi_datain *datain, struct iscsi_data_rsp *hdr,
2795 bool set_statsn)2795 bool set_statsn)
2796{2796{
@@ -2835,7 +2835,7 @@ iscsit_build_datain_pdu(struct iscsi_cmd *cmd, struct iscsi_conn *conn, · 38 unmodified lines
2835}2835}
2836EXPORT_SYMBOL(iscsit_build_datain_pdu);2836EXPORT_SYMBOL(iscsit_build_datain_pdu);
2837 2837
2838static int iscsit_send_datain(struct iscsi_cmd *cmd, struct iscsi_conn *conn)2838static int iscsit_send_datain(struct iscsit_cmd *cmd, struct iscsit_conn *conn)
2839{2839{
2840 struct iscsi_data_rsp *hdr = (struct iscsi_data_rsp *)&cmd->pdu[0];2840 struct iscsi_data_rsp *hdr = (struct iscsi_data_rsp *)&cmd->pdu[0];
2841 struct iscsi_datain datain;2841 struct iscsi_datain datain;
@@ -2896,12 +2896,12 @@ static int iscsit_send_datain(struct iscsi_cmd *cmd, struct iscsi_conn *conn) · 54 unmodified lines
2896}2896}
2897 2897
2898int2898int
2899iscsit_build_logout_rsp(struct iscsi_cmd *cmd, struct iscsi_conn *conn,2899iscsit_build_logout_rsp(struct iscsit_cmd *cmd, struct iscsit_conn *conn,
2900 struct iscsi_logout_rsp *hdr)2900 struct iscsi_logout_rsp *hdr)
2901{2901{
2902 struct iscsi_conn *logout_conn = NULL;2902 struct iscsit_conn *logout_conn = NULL;
2903 struct iscsi_conn_recovery *cr = NULL;2903 struct iscsi_conn_recovery *cr = NULL;
2904 struct iscsi_session *sess = conn->sess;2904 struct iscsit_session *sess = conn->sess;
2905 /*2905 /*
2906 * The actual shutting down of Sessions and/or Connections2906 * The actual shutting down of Sessions and/or Connections
2907 * for CLOSESESSION and CLOSECONNECTION Logout Requests2907 * for CLOSESESSION and CLOSECONNECTION Logout Requests
@@ -2991,7 +2991,7 @@ iscsit_build_logout_rsp(struct iscsi_cmd *cmd, struct iscsi_conn *conn, · 83 unmodified lines
2991EXPORT_SYMBOL(iscsit_build_logout_rsp);2991EXPORT_SYMBOL(iscsit_build_logout_rsp);
2992 2992
2993static int2993static int
2994iscsit_send_logout(struct iscsi_cmd *cmd, struct iscsi_conn *conn)2994iscsit_send_logout(struct iscsit_cmd *cmd, struct iscsit_conn *conn)
2995{2995{
2996 int rc;2996 int rc;
2997 2997
@@ -3004,7 +3004,7 @@ iscsit_send_logout(struct iscsi_cmd *cmd, struct iscsi_conn *conn) · 6 unmodified lines
3004}3004}
3005 3005
3006void3006void
3007iscsit_build_nopin_rsp(struct iscsi_cmd *cmd, struct iscsi_conn *conn,3007iscsit_build_nopin_rsp(struct iscsit_cmd *cmd, struct iscsit_conn *conn,
3008 struct iscsi_nopin *hdr, bool nopout_response)3008 struct iscsi_nopin *hdr, bool nopout_response)
3009{3009{
3010 hdr->opcode = ISCSI_OP_NOOP_IN;3010 hdr->opcode = ISCSI_OP_NOOP_IN;
@@ -3035,8 +3035,8 @@ EXPORT_SYMBOL(iscsit_build_nopin_rsp); · 24 unmodified lines
3035 * Unsolicited NOPIN, either requesting a response or not.3035 * Unsolicited NOPIN, either requesting a response or not.
3036 */3036 */
3037static int iscsit_send_unsolicited_nopin(3037static int iscsit_send_unsolicited_nopin(
3038 struct iscsi_cmd *cmd,3038 struct iscsit_cmd *cmd,
3039 struct iscsi_conn *conn,3039 struct iscsit_conn *conn,
3040 int want_response)3040 int want_response)
3041{3041{
3042 struct iscsi_nopin *hdr = (struct iscsi_nopin *)&cmd->pdu[0];3042 struct iscsi_nopin *hdr = (struct iscsi_nopin *)&cmd->pdu[0];
@@ -3060,15 +3060,15 @@ static int iscsit_send_unsolicited_nopin( · 17 unmodified lines
3060}3060}
3061 3061
3062static int3062static int
3063iscsit_send_nopin(struct iscsi_cmd *cmd, struct iscsi_conn *conn)3063iscsit_send_nopin(struct iscsit_cmd *cmd, struct iscsit_conn *conn)
3064{3064{
3065 struct iscsi_nopin *hdr = (struct iscsi_nopin *)&cmd->pdu[0];3065 struct iscsi_nopin *hdr = (struct iscsi_nopin *)&cmd->pdu[0];
3066 3066
3067 iscsit_build_nopin_rsp(cmd, conn, hdr, true);3067 iscsit_build_nopin_rsp(cmd, conn, hdr, true);
3068 3068
3069 /*3069 /*
3070 * NOPOUT Ping Data is attached to struct iscsi_cmd->buf_ptr.3070 * NOPOUT Ping Data is attached to struct iscsit_cmd->buf_ptr.
3071 * NOPOUT DataSegmentLength is at struct iscsi_cmd->buf_ptr_size.3071 * NOPOUT DataSegmentLength is at struct iscsit_cmd->buf_ptr_size.
3072 */3072 */
3073 pr_debug("Echoing back %u bytes of ping data.\n", cmd->buf_ptr_size);3073 pr_debug("Echoing back %u bytes of ping data.\n", cmd->buf_ptr_size);
3074 3074
@@ -3078,8 +3078,8 @@ iscsit_send_nopin(struct iscsi_cmd *cmd, struct iscsi_conn *conn) · 3 unmodified lines
3078}3078}
3079 3079
3080static int iscsit_send_r2t(3080static int iscsit_send_r2t(
3081 struct iscsi_cmd *cmd,3081 struct iscsit_cmd *cmd,
3082 struct iscsi_conn *conn)3082 struct iscsit_conn *conn)
3083{3083{
3084 struct iscsi_r2t *r2t;3084 struct iscsi_r2t *r2t;
3085 struct iscsi_r2t_rsp *hdr;3085 struct iscsi_r2t_rsp *hdr;
@@ -3135,8 +3135,8 @@ static int iscsit_send_r2t( · 49 unmodified lines
3135 * connection recovery.3135 * connection recovery.
3136 */3136 */
3137int iscsit_build_r2ts_for_cmd(3137int iscsit_build_r2ts_for_cmd(
3138 struct iscsi_conn *conn,3138 struct iscsit_conn *conn,
3139 struct iscsi_cmd *cmd,3139 struct iscsit_cmd *cmd,
3140 bool recovery)3140 bool recovery)
3141{3141{
3142 int first_r2t = 1;3142 int first_r2t = 1;
@@ -3218,7 +3218,7 @@ int iscsit_build_r2ts_for_cmd( · 75 unmodified lines
3218}3218}
3219EXPORT_SYMBOL(iscsit_build_r2ts_for_cmd);3219EXPORT_SYMBOL(iscsit_build_r2ts_for_cmd);
3220 3220
3221void iscsit_build_rsp_pdu(struct iscsi_cmd *cmd, struct iscsi_conn *conn,3221void iscsit_build_rsp_pdu(struct iscsit_cmd *cmd, struct iscsit_conn *conn,
3222 bool inc_stat_sn, struct iscsi_scsi_rsp *hdr)3222 bool inc_stat_sn, struct iscsi_scsi_rsp *hdr)
3223{3223{
3224 if (inc_stat_sn)3224 if (inc_stat_sn)
@@ -3252,7 +3252,7 @@ void iscsit_build_rsp_pdu(struct iscsi_cmd *cmd, struct iscsi_conn *conn, · 27 unmodified lines
3252}3252}
3253EXPORT_SYMBOL(iscsit_build_rsp_pdu);3253EXPORT_SYMBOL(iscsit_build_rsp_pdu);
3254 3254
3255static int iscsit_send_response(struct iscsi_cmd *cmd, struct iscsi_conn *conn)3255static int iscsit_send_response(struct iscsit_cmd *cmd, struct iscsit_conn *conn)
3256{3256{
3257 struct iscsi_scsi_rsp *hdr = (struct iscsi_scsi_rsp *)&cmd->pdu[0];3257 struct iscsi_scsi_rsp *hdr = (struct iscsi_scsi_rsp *)&cmd->pdu[0];
3258 bool inc_stat_sn = (cmd->i_state == ISTATE_SEND_STATUS);3258 bool inc_stat_sn = (cmd->i_state == ISTATE_SEND_STATUS);
@@ -3309,7 +3309,7 @@ static u8 iscsit_convert_tcm_tmr_rsp(struct se_tmr_req *se_tmr) · 50 unmodified lines
3309}3309}
3310 3310
3311void3311void
3312iscsit_build_task_mgt_rsp(struct iscsi_cmd *cmd, struct iscsi_conn *conn,3312iscsit_build_task_mgt_rsp(struct iscsit_cmd *cmd, struct iscsit_conn *conn,
3313 struct iscsi_tm_rsp *hdr)3313 struct iscsi_tm_rsp *hdr)
3314{3314{
3315 struct se_tmr_req *se_tmr = cmd->se_cmd.se_tmr_req;3315 struct se_tmr_req *se_tmr = cmd->se_cmd.se_tmr_req;
@@ -3332,7 +3332,7 @@ iscsit_build_task_mgt_rsp(struct iscsi_cmd *cmd, struct iscsi_conn *conn, · 16 unmodified lines
3332EXPORT_SYMBOL(iscsit_build_task_mgt_rsp);3332EXPORT_SYMBOL(iscsit_build_task_mgt_rsp);
3333 3333
3334static int3334static int
3335iscsit_send_task_mgt_rsp(struct iscsi_cmd *cmd, struct iscsi_conn *conn)3335iscsit_send_task_mgt_rsp(struct iscsit_cmd *cmd, struct iscsit_conn *conn)
3336{3336{
3337 struct iscsi_tm_rsp *hdr = (struct iscsi_tm_rsp *)&cmd->pdu[0];3337 struct iscsi_tm_rsp *hdr = (struct iscsi_tm_rsp *)&cmd->pdu[0];
3338 3338
@@ -3344,12 +3344,12 @@ iscsit_send_task_mgt_rsp(struct iscsi_cmd *cmd, struct iscsi_conn *conn) · 5 unmodified lines
3344#define SENDTARGETS_BUF_LIMIT 32768U3344#define SENDTARGETS_BUF_LIMIT 32768U
3345 3345
3346static int3346static int
3347iscsit_build_sendtargets_response(struct iscsi_cmd *cmd,3347iscsit_build_sendtargets_response(struct iscsit_cmd *cmd,
3348 enum iscsit_transport_type network_transport,3348 enum iscsit_transport_type network_transport,
3349 int skip_bytes, bool *completed)3349 int skip_bytes, bool *completed)
3350{3350{
3351 char *payload = NULL;3351 char *payload = NULL;
3352 struct iscsi_conn *conn = cmd->conn;3352 struct iscsit_conn *conn = cmd->conn;
3353 struct iscsi_portal_group *tpg;3353 struct iscsi_portal_group *tpg;
3354 struct iscsi_tiqn *tiqn;3354 struct iscsi_tiqn *tiqn;
3355 struct iscsi_tpg_np *tpg_np;3355 struct iscsi_tpg_np *tpg_np;
@@ -3494,7 +3494,7 @@ eob: · 138 unmodified lines
3494}3494}
3495 3495
3496int3496int
3497iscsit_build_text_rsp(struct iscsi_cmd *cmd, struct iscsi_conn *conn,3497iscsit_build_text_rsp(struct iscsit_cmd *cmd, struct iscsit_conn *conn,
3498 struct iscsi_text_rsp *hdr,3498 struct iscsi_text_rsp *hdr,
3499 enum iscsit_transport_type network_transport)3499 enum iscsit_transport_type network_transport)
3500{3500{
@@ -3544,8 +3544,8 @@ iscsit_build_text_rsp(struct iscsi_cmd *cmd, struct iscsi_conn *conn, · 43 unmodified lines
3544EXPORT_SYMBOL(iscsit_build_text_rsp);3544EXPORT_SYMBOL(iscsit_build_text_rsp);
3545 3545
3546static int iscsit_send_text_rsp(3546static int iscsit_send_text_rsp(
3547 struct iscsi_cmd *cmd,3547 struct iscsit_cmd *cmd,
3548 struct iscsi_conn *conn)3548 struct iscsit_conn *conn)
3549{3549{
3550 struct iscsi_text_rsp *hdr = (struct iscsi_text_rsp *)cmd->pdu;3550 struct iscsi_text_rsp *hdr = (struct iscsi_text_rsp *)cmd->pdu;
3551 int text_length;3551 int text_length;
@@ -3561,7 +3561,7 @@ static int iscsit_send_text_rsp( · 9 unmodified lines
3561}3561}
3562 3562
3563void3563void
3564iscsit_build_reject(struct iscsi_cmd *cmd, struct iscsi_conn *conn,3564iscsit_build_reject(struct iscsit_cmd *cmd, struct iscsit_conn *conn,
3565 struct iscsi_reject *hdr)3565 struct iscsi_reject *hdr)
3566{3566{
3567 hdr->opcode = ISCSI_OP_REJECT;3567 hdr->opcode = ISCSI_OP_REJECT;
@@ -3578,8 +3578,8 @@ iscsit_build_reject(struct iscsi_cmd *cmd, struct iscsi_conn *conn, · 10 unmodified lines
3578EXPORT_SYMBOL(iscsit_build_reject);3578EXPORT_SYMBOL(iscsit_build_reject);
3579 3579
3580static int iscsit_send_reject(3580static int iscsit_send_reject(
3581 struct iscsi_cmd *cmd,3581 struct iscsit_cmd *cmd,
3582 struct iscsi_conn *conn)3582 struct iscsit_conn *conn)
3583{3583{
3584 struct iscsi_reject *hdr = (struct iscsi_reject *)&cmd->pdu[0];3584 struct iscsi_reject *hdr = (struct iscsi_reject *)&cmd->pdu[0];
3585 3585
@@ -3593,7 +3593,7 @@ static int iscsit_send_reject( · 7 unmodified lines
3593 ISCSI_HDR_LEN);3593 ISCSI_HDR_LEN);
3594}3594}
3595 3595
3596void iscsit_thread_get_cpumask(struct iscsi_conn *conn)3596void iscsit_thread_get_cpumask(struct iscsit_conn *conn)
3597{3597{
3598 int ord, cpu;3598 int ord, cpu;
3599 cpumask_var_t conn_allowed_cpumask;3599 cpumask_var_t conn_allowed_cpumask;
@@ -3636,7 +3636,7 @@ void iscsit_thread_get_cpumask(struct iscsi_conn *conn) · 36 unmodified lines
3636 cpumask_setall(conn->conn_cpumask);3636 cpumask_setall(conn->conn_cpumask);
3637}3637}
3638 3638
3639static void iscsit_thread_reschedule(struct iscsi_conn *conn)3639static void iscsit_thread_reschedule(struct iscsit_conn *conn)
3640{3640{
3641 /*3641 /*
3642 * If iscsit_global->allowed_cpumask modified, reschedule iSCSI3642 * If iscsit_global->allowed_cpumask modified, reschedule iSCSI
@@ -3653,7 +3653,7 @@ static void iscsit_thread_reschedule(struct iscsi_conn *conn) · 10 unmodified lines
3653}3653}
3654 3654
3655void iscsit_thread_check_cpumask(3655void iscsit_thread_check_cpumask(
3656 struct iscsi_conn *conn,3656 struct iscsit_conn *conn,
3657 struct task_struct *p,3657 struct task_struct *p,
3658 int mode)3658 int mode)
3659{3659{
@@ -3693,7 +3693,7 @@ void iscsit_thread_check_cpumask( · 33 unmodified lines
3693EXPORT_SYMBOL(iscsit_thread_check_cpumask);3693EXPORT_SYMBOL(iscsit_thread_check_cpumask);
3694 3694
3695int3695int
3696iscsit_immediate_queue(struct iscsi_conn *conn, struct iscsi_cmd *cmd, int state)3696iscsit_immediate_queue(struct iscsit_conn *conn, struct iscsit_cmd *cmd, int state)
3697{3697{
3698 int ret;3698 int ret;
3699 3699
@@ -3737,11 +3737,11 @@ err: · 37 unmodified lines
3737EXPORT_SYMBOL(iscsit_immediate_queue);3737EXPORT_SYMBOL(iscsit_immediate_queue);
3738 3738
3739static int3739static int
3740iscsit_handle_immediate_queue(struct iscsi_conn *conn)3740iscsit_handle_immediate_queue(struct iscsit_conn *conn)
3741{3741{
3742 struct iscsit_transport *t = conn->conn_transport;3742 struct iscsit_transport *t = conn->conn_transport;
3743 struct iscsi_queue_req *qr;3743 struct iscsi_queue_req *qr;
3744 struct iscsi_cmd *cmd;3744 struct iscsit_cmd *cmd;
3745 u8 state;3745 u8 state;
3746 int ret;3746 int ret;
3747 3747
@@ -3760,7 +3760,7 @@ iscsit_handle_immediate_queue(struct iscsi_conn *conn) · 12 unmodified lines
3760}3760}
3761 3761
3762int3762int
3763iscsit_response_queue(struct iscsi_conn *conn, struct iscsi_cmd *cmd, int state)3763iscsit_response_queue(struct iscsit_conn *conn, struct iscsit_cmd *cmd, int state)
3764{3764{
3765 int ret;3765 int ret;
3766 3766
@@ -3866,11 +3866,11 @@ err: · 99 unmodified lines
3866}3866}
3867EXPORT_SYMBOL(iscsit_response_queue);3867EXPORT_SYMBOL(iscsit_response_queue);
3868 3868
3869static int iscsit_handle_response_queue(struct iscsi_conn *conn)3869static int iscsit_handle_response_queue(struct iscsit_conn *conn)
3870{3870{
3871 struct iscsit_transport *t = conn->conn_transport;3871 struct iscsit_transport *t = conn->conn_transport;
3872 struct iscsi_queue_req *qr;3872 struct iscsi_queue_req *qr;
3873 struct iscsi_cmd *cmd;3873 struct iscsit_cmd *cmd;
3874 u8 state;3874 u8 state;
3875 int ret;3875 int ret;
3876 3876
@@ -3890,7 +3890,7 @@ static int iscsit_handle_response_queue(struct iscsi_conn *conn) · 13 unmodified lines
3890int iscsi_target_tx_thread(void *arg)3890int iscsi_target_tx_thread(void *arg)
3891{3891{
3892 int ret = 0;3892 int ret = 0;
3893 struct iscsi_conn *conn = arg;3893 struct iscsit_conn *conn = arg;
3894 bool conn_freed = false;3894 bool conn_freed = false;
3895 3895
3896 /*3896 /*
@@ -3945,10 +3945,10 @@ out: · 48 unmodified lines
3945 return 0;3945 return 0;
3946}3946}
3947 3947
3948static int iscsi_target_rx_opcode(struct iscsi_conn *conn, unsigned char *buf)3948static int iscsi_target_rx_opcode(struct iscsit_conn *conn, unsigned char *buf)
3949{3949{
3950 struct iscsi_hdr *hdr = (struct iscsi_hdr *)buf;3950 struct iscsi_hdr *hdr = (struct iscsi_hdr *)buf;
3951 struct iscsi_cmd *cmd;3951 struct iscsit_cmd *cmd;
3952 int ret = 0;3952 int ret = 0;
3953 3953
3954 switch (hdr->opcode & ISCSI_OPCODE_MASK) {3954 switch (hdr->opcode & ISCSI_OPCODE_MASK) {
@@ -4022,7 +4022,7 @@ reject: · 67 unmodified lines
4022 return iscsit_add_reject(conn, ISCSI_REASON_BOOKMARK_NO_RESOURCES, buf);4022 return iscsit_add_reject(conn, ISCSI_REASON_BOOKMARK_NO_RESOURCES, buf);
4023}4023}
4024 4024
4025static bool iscsi_target_check_conn_state(struct iscsi_conn *conn)4025static bool iscsi_target_check_conn_state(struct iscsit_conn *conn)
4026{4026{
4027 bool ret;4027 bool ret;
4028 4028
@@ -4033,7 +4033,7 @@ static bool iscsi_target_check_conn_state(struct iscsi_conn *conn) · 4 unmodified lines
4033 return ret;4033 return ret;
4034}4034}
4035 4035
4036static void iscsit_get_rx_pdu(struct iscsi_conn *conn)4036static void iscsit_get_rx_pdu(struct iscsit_conn *conn)
4037{4037{
4038 int ret;4038 int ret;
4039 u8 *buffer, opcode;4039 u8 *buffer, opcode;
@@ -4118,7 +4118,7 @@ static void iscsit_get_rx_pdu(struct iscsi_conn *conn) · 78 unmodified lines
4118int iscsi_target_rx_thread(void *arg)4118int iscsi_target_rx_thread(void *arg)
4119{4119{
4120 int rc;4120 int rc;
4121 struct iscsi_conn *conn = arg;4121 struct iscsit_conn *conn = arg;
4122 bool conn_freed = false;4122 bool conn_freed = false;
4123 4123
4124 /*4124 /*
@@ -4153,11 +4153,11 @@ out: · 28 unmodified lines
4153 return 0;4153 return 0;
4154}4154}
4155 4155
4156static void iscsit_release_commands_from_conn(struct iscsi_conn *conn)4156static void iscsit_release_commands_from_conn(struct iscsit_conn *conn)
4157{4157{
4158 LIST_HEAD(tmp_list);4158 LIST_HEAD(tmp_list);
4159 struct iscsi_cmd *cmd = NULL, *cmd_tmp = NULL;4159 struct iscsit_cmd *cmd = NULL, *cmd_tmp = NULL;
4160 struct iscsi_session *sess = conn->sess;4160 struct iscsit_session *sess = conn->sess;
4161 /*4161 /*
4162 * We expect this function to only ever be called from either RX or TX4162 * We expect this function to only ever be called from either RX or TX
4163 * thread context via iscsit_close_connection() once the other context4163 * thread context via iscsit_close_connection() once the other context
@@ -4197,9 +4197,9 @@ static void iscsit_release_commands_from_conn(struct iscsi_conn *conn) · 33 unmodified lines
4197}4197}
4198 4198
4199static void iscsit_stop_timers_for_cmds(4199static void iscsit_stop_timers_for_cmds(
4200 struct iscsi_conn *conn)4200 struct iscsit_conn *conn)
4201{4201{
4202 struct iscsi_cmd *cmd;4202 struct iscsit_cmd *cmd;
4203 4203
4204 spin_lock_bh(&conn->cmd_lock);4204 spin_lock_bh(&conn->cmd_lock);
4205 list_for_each_entry(cmd, &conn->conn_cmd_list, i_conn_node) {4205 list_for_each_entry(cmd, &conn->conn_cmd_list, i_conn_node) {
@@ -4210,10 +4210,10 @@ static void iscsit_stop_timers_for_cmds( · 4 unmodified lines
4210}4210}
4211 4211
4212int iscsit_close_connection(4212int iscsit_close_connection(
4213 struct iscsi_conn *conn)4213 struct iscsit_conn *conn)
4214{4214{
4215 int conn_logout = (conn->conn_state == TARG_CONN_STATE_IN_LOGOUT);4215 int conn_logout = (conn->conn_state == TARG_CONN_STATE_IN_LOGOUT);
4216 struct iscsi_session *sess = conn->sess;4216 struct iscsit_session *sess = conn->sess;
4217 4217
4218 pr_debug("Closing iSCSI connection CID %hu on SID:"4218 pr_debug("Closing iSCSI connection CID %hu on SID:"
4219 " %u\n", conn->cid, sess->sid);4219 " %u\n", conn->cid, sess->sid);
@@ -4226,7 +4226,7 @@ int iscsit_close_connection( · 6 unmodified lines
4226 * However for iser-target, isert_wait4logout() is using conn_logout_comp4226 * However for iser-target, isert_wait4logout() is using conn_logout_comp
4227 * to signal logout response TX interrupt completion. Go ahead and skip4227 * to signal logout response TX interrupt completion. Go ahead and skip
4228 * this for iser since isert_rx_opcode() does not wait on logout failure,4228 * this for iser since isert_rx_opcode() does not wait on logout failure,
4229 * and to avoid iscsi_conn pointer dereference in iser-target code.4229 * and to avoid iscsit_conn pointer dereference in iser-target code.
4230 */4230 */
4231 if (!conn->conn_transport->rdma_shutdown)4231 if (!conn->conn_transport->rdma_shutdown)
4232 complete(&conn->conn_logout_comp);4232 complete(&conn->conn_logout_comp);
@@ -4264,7 +4264,7 @@ int iscsit_close_connection( · 31 unmodified lines
4264 *4264 *
4265 * During normal operation clear the out of order commands (but4265 * During normal operation clear the out of order commands (but
4266 * do not free the struct iscsi_ooo_cmdsn's) and release all4266 * do not free the struct iscsi_ooo_cmdsn's) and release all
4267 * struct iscsi_cmds.4267 * struct iscsit_cmds.
4268 */4268 */
4269 if (atomic_read(&conn->connection_recovery)) {4269 if (atomic_read(&conn->connection_recovery)) {
4270 iscsit_discard_unacknowledged_ooo_cmdsns_for_conn(conn);4270 iscsit_discard_unacknowledged_ooo_cmdsns_for_conn(conn);
@@ -4450,7 +4450,7 @@ int iscsit_close_connection( · 179 unmodified lines
4450 * If the iSCSI Session for the iSCSI Initiator Node exists,4450 * If the iSCSI Session for the iSCSI Initiator Node exists,
4451 * forcefully shutdown the iSCSI NEXUS.4451 * forcefully shutdown the iSCSI NEXUS.
4452 */4452 */
4453int iscsit_close_session(struct iscsi_session *sess, bool can_sleep)4453int iscsit_close_session(struct iscsit_session *sess, bool can_sleep)
4454{4454{
4455 struct iscsi_portal_group *tpg = sess->tpg;4455 struct iscsi_portal_group *tpg = sess->tpg;
4456 struct se_portal_group *se_tpg = &tpg->tpg_se_tpg;4456 struct se_portal_group *se_tpg = &tpg->tpg_se_tpg;
@@ -4518,9 +4518,9 @@ int iscsit_close_session(struct iscsi_session *sess, bool can_sleep) · 61 unmodified lines
4518}4518}
4519 4519
4520static void iscsit_logout_post_handler_closesession(4520static void iscsit_logout_post_handler_closesession(
4521 struct iscsi_conn *conn)4521 struct iscsit_conn *conn)
4522{4522{
4523 struct iscsi_session *sess = conn->sess;4523 struct iscsit_session *sess = conn->sess;
4524 int sleep = 1;4524 int sleep = 1;
4525 /*4525 /*
4526 * Traditional iscsi/tcp will invoke this logic from TX thread4526 * Traditional iscsi/tcp will invoke this logic from TX thread
@@ -4547,7 +4547,7 @@ static void iscsit_logout_post_handler_closesession( · 20 unmodified lines
4547}4547}
4548 4548
4549static void iscsit_logout_post_handler_samecid(4549static void iscsit_logout_post_handler_samecid(
4550 struct iscsi_conn *conn)4550 struct iscsit_conn *conn)
4551{4551{
4552 int sleep = 1;4552 int sleep = 1;
4553 4553
@@ -4565,11 +4565,11 @@ static void iscsit_logout_post_handler_samecid( · 11 unmodified lines
4565}4565}
4566 4566
4567static void iscsit_logout_post_handler_diffcid(4567static void iscsit_logout_post_handler_diffcid(
4568 struct iscsi_conn *conn,4568 struct iscsit_conn *conn,
4569 u16 cid)4569 u16 cid)
4570{4570{
4571 struct iscsi_conn *l_conn;4571 struct iscsit_conn *l_conn;
4572 struct iscsi_session *sess = conn->sess;4572 struct iscsit_session *sess = conn->sess;
4573 bool conn_found = false;4573 bool conn_found = false;
4574 4574
4575 if (!sess)4575 if (!sess)
@@ -4604,8 +4604,8 @@ static void iscsit_logout_post_handler_diffcid( · 28 unmodified lines
4604 * Return of 0 causes the TX thread to restart.4604 * Return of 0 causes the TX thread to restart.
4605 */4605 */
4606int iscsit_logout_post_handler(4606int iscsit_logout_post_handler(
4607 struct iscsi_cmd *cmd,4607 struct iscsit_cmd *cmd,
4608 struct iscsi_conn *conn)4608 struct iscsit_conn *conn)
4609{4609{
4610 int ret = 0;4610 int ret = 0;
4611 4611
@@ -4661,9 +4661,9 @@ int iscsit_logout_post_handler( · 49 unmodified lines
4661}4661}
4662EXPORT_SYMBOL(iscsit_logout_post_handler);4662EXPORT_SYMBOL(iscsit_logout_post_handler);
4663 4663
4664void iscsit_fail_session(struct iscsi_session *sess)4664void iscsit_fail_session(struct iscsit_session *sess)
4665{4665{
4666 struct iscsi_conn *conn;4666 struct iscsit_conn *conn;
4667 4667
4668 spin_lock_bh(&sess->conn_lock);4668 spin_lock_bh(&sess->conn_lock);
4669 list_for_each_entry(conn, &sess->sess_conn_list, conn_list) {4669 list_for_each_entry(conn, &sess->sess_conn_list, conn_list) {
@@ -4677,12 +4677,12 @@ void iscsit_fail_session(struct iscsi_session *sess) · 7 unmodified lines
4677}4677}
4678 4678
4679void iscsit_stop_session(4679void iscsit_stop_session(
4680 struct iscsi_session *sess,4680 struct iscsit_session *sess,
4681 int session_sleep,4681 int session_sleep,
4682 int connection_sleep)4682 int connection_sleep)
4683{4683{
4684 u16 conn_count = atomic_read(&sess->nconn);4684 u16 conn_count = atomic_read(&sess->nconn);
4685 struct iscsi_conn *conn, *conn_tmp = NULL;4685 struct iscsit_conn *conn, *conn_tmp = NULL;
4686 int is_last;4686 int is_last;
4687 4687
4688 spin_lock_bh(&sess->conn_lock);4688 spin_lock_bh(&sess->conn_lock);
@@ -4724,7 +4724,7 @@ void iscsit_stop_session( · 35 unmodified lines
4724 4724
4725int iscsit_release_sessions_for_tpg(struct iscsi_portal_group *tpg, int force)4725int iscsit_release_sessions_for_tpg(struct iscsi_portal_group *tpg, int force)
4726{4726{
4727 struct iscsi_session *sess;4727 struct iscsit_session *sess;
4728 struct se_portal_group *se_tpg = &tpg->tpg_se_tpg;4728 struct se_portal_group *se_tpg = &tpg->tpg_se_tpg;
4729 struct se_session *se_sess, *se_sess_tmp;4729 struct se_session *se_sess, *se_sess_tmp;
4730 LIST_HEAD(free_list);4730 LIST_HEAD(free_list);
@@ -4738,7 +4738,7 @@ int iscsit_release_sessions_for_tpg(struct iscsi_portal_group *tpg, int force) · 7 unmodified lines
4738 4738
4739 list_for_each_entry_safe(se_sess, se_sess_tmp, &se_tpg->tpg_sess_list,4739 list_for_each_entry_safe(se_sess, se_sess_tmp, &se_tpg->tpg_sess_list,
4740 sess_list) {4740 sess_list) {
4741 sess = (struct iscsi_session *)se_sess->fabric_sess_ptr;4741 sess = (struct iscsit_session *)se_sess->fabric_sess_ptr;
4742 4742
4743 spin_lock(&sess->conn_lock);4743 spin_lock(&sess->conn_lock);
4744 if (atomic_read(&sess->session_fall_back_to_erl0) ||4744 if (atomic_read(&sess->session_fall_back_to_erl0) ||
@@ -4759,7 +4759,7 @@ int iscsit_release_sessions_for_tpg(struct iscsi_portal_group *tpg, int force) · 14 unmodified lines
4759 spin_unlock_bh(&se_tpg->session_lock);4759 spin_unlock_bh(&se_tpg->session_lock);
4760 4760
4761 list_for_each_entry_safe(se_sess, se_sess_tmp, &free_list, sess_list) {4761 list_for_each_entry_safe(se_sess, se_sess_tmp, &free_list, sess_list) {
4762 sess = (struct iscsi_session *)se_sess->fabric_sess_ptr;4762 sess = (struct iscsit_session *)se_sess->fabric_sess_ptr;
4763 4763
4764 list_del_init(&se_sess->sess_list);4764 list_del_init(&se_sess->sess_list);
4765 iscsit_stop_session(sess, 1, 1);4765 iscsit_stop_session(sess, 1, 1);
drivers/target/iscsi/iscsi_target.h+15−15
@@ -5,11 +5,11 @@ · 4 unmodified lines
5#include <linux/types.h>5#include <linux/types.h>
6#include <linux/spinlock.h>6#include <linux/spinlock.h>
7 7
8struct iscsi_cmd;8struct iscsit_cmd;
9struct iscsi_conn;9struct iscsit_conn;
10struct iscsi_np;10struct iscsi_np;
11struct iscsi_portal_group;11struct iscsi_portal_group;
12struct iscsi_session;12struct iscsit_session;
13struct iscsi_tpg_np;13struct iscsi_tpg_np;
14struct kref;14struct kref;
15struct sockaddr_storage;15struct sockaddr_storage;
@@ -30,20 +30,20 @@ extern struct iscsi_np *iscsit_add_np(struct sockaddr_storage *, · 14 unmodified lines
30extern int iscsit_reset_np_thread(struct iscsi_np *, struct iscsi_tpg_np *,30extern int iscsit_reset_np_thread(struct iscsi_np *, struct iscsi_tpg_np *,
31 struct iscsi_portal_group *, bool);31 struct iscsi_portal_group *, bool);
32extern int iscsit_del_np(struct iscsi_np *);32extern int iscsit_del_np(struct iscsi_np *);
33extern int iscsit_reject_cmd(struct iscsi_cmd *cmd, u8, unsigned char *);33extern int iscsit_reject_cmd(struct iscsit_cmd *cmd, u8, unsigned char *);
34extern void iscsit_set_unsolicited_dataout(struct iscsi_cmd *);34extern void iscsit_set_unsolicited_dataout(struct iscsit_cmd *);
35extern int iscsit_logout_closesession(struct iscsi_cmd *, struct iscsi_conn *);35extern int iscsit_logout_closesession(struct iscsit_cmd *, struct iscsit_conn *);
36extern int iscsit_logout_closeconnection(struct iscsi_cmd *, struct iscsi_conn *);36extern int iscsit_logout_closeconnection(struct iscsit_cmd *, struct iscsit_conn *);
37extern int iscsit_logout_removeconnforrecovery(struct iscsi_cmd *, struct iscsi_conn *);37extern int iscsit_logout_removeconnforrecovery(struct iscsit_cmd *, struct iscsit_conn *);
38extern int iscsit_send_async_msg(struct iscsi_conn *, u16, u8, u8);38extern int iscsit_send_async_msg(struct iscsit_conn *, u16, u8, u8);
39extern int iscsit_build_r2ts_for_cmd(struct iscsi_conn *, struct iscsi_cmd *, bool recovery);39extern int iscsit_build_r2ts_for_cmd(struct iscsit_conn *, struct iscsit_cmd *, bool recovery);
40extern void iscsit_thread_get_cpumask(struct iscsi_conn *);40extern void iscsit_thread_get_cpumask(struct iscsit_conn *);
41extern int iscsi_target_tx_thread(void *);41extern int iscsi_target_tx_thread(void *);
42extern int iscsi_target_rx_thread(void *);42extern int iscsi_target_rx_thread(void *);
43extern int iscsit_close_connection(struct iscsi_conn *);43extern int iscsit_close_connection(struct iscsit_conn *);
44extern int iscsit_close_session(struct iscsi_session *, bool can_sleep);44extern int iscsit_close_session(struct iscsit_session *, bool can_sleep);
45extern void iscsit_fail_session(struct iscsi_session *);45extern void iscsit_fail_session(struct iscsit_session *);
46extern void iscsit_stop_session(struct iscsi_session *, int, int);46extern void iscsit_stop_session(struct iscsit_session *, int, int);
47extern int iscsit_release_sessions_for_tpg(struct iscsi_portal_group *, int);47extern int iscsit_release_sessions_for_tpg(struct iscsi_portal_group *, int);
48 48
49extern struct iscsit_global *iscsit_global;49extern struct iscsit_global *iscsit_global;
drivers/target/iscsi/iscsi_target_auth.c+5−5
@@ -35,7 +35,7 @@ static char *chap_get_digest_name(const int digest_type) · 34 unmodified lines
35}35}
36 36
37static int chap_gen_challenge(37static int chap_gen_challenge(
38 struct iscsi_conn *conn,38 struct iscsit_conn *conn,
39 int caller,39 int caller,
40 char *c_str,40 char *c_str,
41 unsigned int *c_len)41 unsigned int *c_len)
@@ -128,14 +128,14 @@ out: · 86 unmodified lines
128 return r;128 return r;
129}129}
130 130
131static void chap_close(struct iscsi_conn *conn)131static void chap_close(struct iscsit_conn *conn)
132{132{
133 kfree(conn->auth_protocol);133 kfree(conn->auth_protocol);
134 conn->auth_protocol = NULL;134 conn->auth_protocol = NULL;
135}135}
136 136
137static struct iscsi_chap *chap_server_open(137static struct iscsi_chap *chap_server_open(
138 struct iscsi_conn *conn,138 struct iscsit_conn *conn,
139 struct iscsi_node_auth *auth,139 struct iscsi_node_auth *auth,
140 const char *a_str,140 const char *a_str,
141 char *aic_str,141 char *aic_str,
@@ -206,7 +206,7 @@ static struct iscsi_chap *chap_server_open( · 64 unmodified lines
206}206}
207 207
208static int chap_server_compute_hash(208static int chap_server_compute_hash(
209 struct iscsi_conn *conn,209 struct iscsit_conn *conn,
210 struct iscsi_node_auth *auth,210 struct iscsi_node_auth *auth,
211 char *nr_in_ptr,211 char *nr_in_ptr,
212 char *nr_out_ptr,212 char *nr_out_ptr,
@@ -497,7 +497,7 @@ out: · 284 unmodified lines
497}497}
498 498
499u32 chap_main_loop(499u32 chap_main_loop(
500 struct iscsi_conn *conn,500 struct iscsit_conn *conn,
501 struct iscsi_node_auth *auth,501 struct iscsi_node_auth *auth,
502 char *in_text,502 char *in_text,
503 char *out_text,503 char *out_text,
drivers/target/iscsi/iscsi_target_auth.h+2−2
@@ -27,9 +27,9 @@ · 26 unmodified lines
27#define CHAP_STAGE_SERVER_NR 527#define CHAP_STAGE_SERVER_NR 5
28 28
29struct iscsi_node_auth;29struct iscsi_node_auth;
30struct iscsi_conn;30struct iscsit_conn;
31 31
32extern u32 chap_main_loop(struct iscsi_conn *, struct iscsi_node_auth *, char *, char *,32extern u32 chap_main_loop(struct iscsit_conn *, struct iscsi_node_auth *, char *, char *,
33 int *, int *);33 int *, int *);
34 34
35struct iscsi_chap {35struct iscsi_chap {
drivers/target/iscsi/iscsi_target_configfs.c+17−17
@@ -443,7 +443,7 @@ static ssize_t iscsi_nacl_param_##name##_show(struct config_item *item, \ · 442 unmodified lines
443 char *page) \443 char *page) \
444{ \444{ \
445 struct se_node_acl *se_nacl = param_to_nacl(item); \445 struct se_node_acl *se_nacl = param_to_nacl(item); \
446 struct iscsi_session *sess; \446 struct iscsit_session *sess; \
447 struct se_session *se_sess; \447 struct se_session *se_sess; \
448 ssize_t rb; \448 ssize_t rb; \
449 \449 \
@@ -498,8 +498,8 @@ static struct configfs_attribute *lio_target_nacl_param_attrs[] = { · 48 unmodified lines
498static ssize_t lio_target_nacl_info_show(struct config_item *item, char *page)498static ssize_t lio_target_nacl_info_show(struct config_item *item, char *page)
499{499{
500 struct se_node_acl *se_nacl = acl_to_nacl(item);500 struct se_node_acl *se_nacl = acl_to_nacl(item);
501 struct iscsi_session *sess;501 struct iscsit_session *sess;
502 struct iscsi_conn *conn;502 struct iscsit_conn *conn;
503 struct se_session *se_sess;503 struct se_session *se_sess;
504 ssize_t rb = 0;504 ssize_t rb = 0;
505 u32 max_cmd_sn;505 u32 max_cmd_sn;
@@ -1344,14 +1344,14 @@ static struct configfs_attribute *lio_target_discovery_auth_attrs[] = { · 838 unmodified lines
1344 1344
1345static int iscsi_get_cmd_state(struct se_cmd *se_cmd)1345static int iscsi_get_cmd_state(struct se_cmd *se_cmd)
1346{1346{
1347 struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);1347 struct iscsit_cmd *cmd = container_of(se_cmd, struct iscsit_cmd, se_cmd);
1348 1348
1349 return cmd->i_state;1349 return cmd->i_state;
1350}1350}
1351 1351
1352static u32 lio_sess_get_index(struct se_session *se_sess)1352static u32 lio_sess_get_index(struct se_session *se_sess)
1353{1353{
1354 struct iscsi_session *sess = se_sess->fabric_sess_ptr;1354 struct iscsit_session *sess = se_sess->fabric_sess_ptr;
1355 1355
1356 return sess->session_index;1356 return sess->session_index;
1357}1357}
@@ -1361,7 +1361,7 @@ static u32 lio_sess_get_initiator_sid( · 3 unmodified lines
1361 unsigned char *buf,1361 unsigned char *buf,
1362 u32 size)1362 u32 size)
1363{1363{
1364 struct iscsi_session *sess = se_sess->fabric_sess_ptr;1364 struct iscsit_session *sess = se_sess->fabric_sess_ptr;
1365 /*1365 /*
1366 * iSCSI Initiator Session Identifier from RFC-3720.1366 * iSCSI Initiator Session Identifier from RFC-3720.
1367 */1367 */
@@ -1370,8 +1370,8 @@ static u32 lio_sess_get_initiator_sid( · 2 unmodified lines
1370 1370
1371static int lio_queue_data_in(struct se_cmd *se_cmd)1371static int lio_queue_data_in(struct se_cmd *se_cmd)
1372{1372{
1373 struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);1373 struct iscsit_cmd *cmd = container_of(se_cmd, struct iscsit_cmd, se_cmd);
1374 struct iscsi_conn *conn = cmd->conn;1374 struct iscsit_conn *conn = cmd->conn;
1375 1375
1376 cmd->i_state = ISTATE_SEND_DATAIN;1376 cmd->i_state = ISTATE_SEND_DATAIN;
1377 return conn->conn_transport->iscsit_queue_data_in(conn, cmd);1377 return conn->conn_transport->iscsit_queue_data_in(conn, cmd);
@@ -1379,8 +1379,8 @@ static int lio_queue_data_in(struct se_cmd *se_cmd) · 1 unmodified line
1379 1379
1380static int lio_write_pending(struct se_cmd *se_cmd)1380static int lio_write_pending(struct se_cmd *se_cmd)
1381{1381{
1382 struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);1382 struct iscsit_cmd *cmd = container_of(se_cmd, struct iscsit_cmd, se_cmd);
1383 struct iscsi_conn *conn = cmd->conn;1383 struct iscsit_conn *conn = cmd->conn;
1384 1384
1385 if (!cmd->immediate_data && !cmd->unsolicited_data)1385 if (!cmd->immediate_data && !cmd->unsolicited_data)
1386 return conn->conn_transport->iscsit_get_dataout(conn, cmd, false);1386 return conn->conn_transport->iscsit_get_dataout(conn, cmd, false);
@@ -1390,8 +1390,8 @@ static int lio_write_pending(struct se_cmd *se_cmd) · 3 unmodified lines
1390 1390
1391static int lio_queue_status(struct se_cmd *se_cmd)1391static int lio_queue_status(struct se_cmd *se_cmd)
1392{1392{
1393 struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);1393 struct iscsit_cmd *cmd = container_of(se_cmd, struct iscsit_cmd, se_cmd);
1394 struct iscsi_conn *conn = cmd->conn;1394 struct iscsit_conn *conn = cmd->conn;
1395 1395
1396 cmd->i_state = ISTATE_SEND_STATUS;1396 cmd->i_state = ISTATE_SEND_STATUS;
1397 1397
@@ -1403,7 +1403,7 @@ static int lio_queue_status(struct se_cmd *se_cmd) · 5 unmodified lines
1403 1403
1404static void lio_queue_tm_rsp(struct se_cmd *se_cmd)1404static void lio_queue_tm_rsp(struct se_cmd *se_cmd)
1405{1405{
1406 struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);1406 struct iscsit_cmd *cmd = container_of(se_cmd, struct iscsit_cmd, se_cmd);
1407 1407
1408 cmd->i_state = ISTATE_SEND_TASKMGTRSP;1408 cmd->i_state = ISTATE_SEND_TASKMGTRSP;
1409 iscsit_add_cmd_to_response_queue(cmd, cmd->conn, cmd->i_state);1409 iscsit_add_cmd_to_response_queue(cmd, cmd->conn, cmd->i_state);
@@ -1411,7 +1411,7 @@ static void lio_queue_tm_rsp(struct se_cmd *se_cmd) · 1 unmodified line
1411 1411
1412static void lio_aborted_task(struct se_cmd *se_cmd)1412static void lio_aborted_task(struct se_cmd *se_cmd)
1413{1413{
1414 struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);1414 struct iscsit_cmd *cmd = container_of(se_cmd, struct iscsit_cmd, se_cmd);
1415 1415
1416 cmd->conn->conn_transport->iscsit_aborted_task(cmd->conn, cmd);1416 cmd->conn->conn_transport->iscsit_aborted_task(cmd->conn, cmd);
1417}1417}
@@ -1472,11 +1472,11 @@ static int lio_tpg_check_prot_fabric_only( · 54 unmodified lines
1472 1472
1473/*1473/*
1474 * This function calls iscsit_inc_session_usage_count() on the1474 * This function calls iscsit_inc_session_usage_count() on the
1475 * struct iscsi_session in question.1475 * struct iscsit_session in question.
1476 */1476 */
1477static void lio_tpg_close_session(struct se_session *se_sess)1477static void lio_tpg_close_session(struct se_session *se_sess)
1478{1478{
1479 struct iscsi_session *sess = se_sess->fabric_sess_ptr;1479 struct iscsit_session *sess = se_sess->fabric_sess_ptr;
1480 struct se_portal_group *se_tpg = &sess->tpg->tpg_se_tpg;1480 struct se_portal_group *se_tpg = &sess->tpg->tpg_se_tpg;
1481 1481
1482 spin_lock_bh(&se_tpg->session_lock);1482 spin_lock_bh(&se_tpg->session_lock);
@@ -1526,7 +1526,7 @@ static int lio_check_stop_free(struct se_cmd *se_cmd) · 43 unmodified lines
1526 1526
1527static void lio_release_cmd(struct se_cmd *se_cmd)1527static void lio_release_cmd(struct se_cmd *se_cmd)
1528{1528{
1529 struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);1529 struct iscsit_cmd *cmd = container_of(se_cmd, struct iscsit_cmd, se_cmd);
1530 1530
1531 pr_debug("Entering lio_release_cmd for se_cmd: %p\n", se_cmd);1531 pr_debug("Entering lio_release_cmd for se_cmd: %p\n", se_cmd);
1532 iscsit_release_cmd(cmd);1532 iscsit_release_cmd(cmd);
drivers/target/iscsi/iscsi_target_datain_values.c+14−14
@@ -32,14 +32,14 @@ struct iscsi_datain_req *iscsit_allocate_datain_req(void) · 31 unmodified lines
32 return dr;32 return dr;
33}33}
34 34
35void iscsit_attach_datain_req(struct iscsi_cmd *cmd, struct iscsi_datain_req *dr)35void iscsit_attach_datain_req(struct iscsit_cmd *cmd, struct iscsi_datain_req *dr)
36{36{
37 spin_lock(&cmd->datain_lock);37 spin_lock(&cmd->datain_lock);
38 list_add_tail(&dr->cmd_datain_node, &cmd->datain_list);38 list_add_tail(&dr->cmd_datain_node, &cmd->datain_list);
39 spin_unlock(&cmd->datain_lock);39 spin_unlock(&cmd->datain_lock);
40}40}
41 41
42void iscsit_free_datain_req(struct iscsi_cmd *cmd, struct iscsi_datain_req *dr)42void iscsit_free_datain_req(struct iscsit_cmd *cmd, struct iscsi_datain_req *dr)
43{43{
44 spin_lock(&cmd->datain_lock);44 spin_lock(&cmd->datain_lock);
45 list_del(&dr->cmd_datain_node);45 list_del(&dr->cmd_datain_node);
@@ -48,7 +48,7 @@ void iscsit_free_datain_req(struct iscsi_cmd *cmd, struct iscsi_datain_req *dr) · 2 unmodified lines
48 kmem_cache_free(lio_dr_cache, dr);48 kmem_cache_free(lio_dr_cache, dr);
49}49}
50 50
51void iscsit_free_all_datain_reqs(struct iscsi_cmd *cmd)51void iscsit_free_all_datain_reqs(struct iscsit_cmd *cmd)
52{52{
53 struct iscsi_datain_req *dr, *dr_tmp;53 struct iscsi_datain_req *dr, *dr_tmp;
54 54
@@ -60,7 +60,7 @@ void iscsit_free_all_datain_reqs(struct iscsi_cmd *cmd) · 5 unmodified lines
60 spin_unlock(&cmd->datain_lock);60 spin_unlock(&cmd->datain_lock);
61}61}
62 62
63struct iscsi_datain_req *iscsit_get_datain_req(struct iscsi_cmd *cmd)63struct iscsi_datain_req *iscsit_get_datain_req(struct iscsit_cmd *cmd)
64{64{
65 if (list_empty(&cmd->datain_list)) {65 if (list_empty(&cmd->datain_list)) {
66 pr_err("cmd->datain_list is empty for ITT:"66 pr_err("cmd->datain_list is empty for ITT:"
@@ -76,11 +76,11 @@ struct iscsi_datain_req *iscsit_get_datain_req(struct iscsi_cmd *cmd) · 9 unmodified lines
76 * For Normal and Recovery DataSequenceInOrder=Yes and DataPDUInOrder=Yes.76 * For Normal and Recovery DataSequenceInOrder=Yes and DataPDUInOrder=Yes.
77 */77 */
78static struct iscsi_datain_req *iscsit_set_datain_values_yes_and_yes(78static struct iscsi_datain_req *iscsit_set_datain_values_yes_and_yes(
79 struct iscsi_cmd *cmd,79 struct iscsit_cmd *cmd,
80 struct iscsi_datain *datain)80 struct iscsi_datain *datain)
81{81{
82 u32 next_burst_len, read_data_done, read_data_left;82 u32 next_burst_len, read_data_done, read_data_left;
83 struct iscsi_conn *conn = cmd->conn;83 struct iscsit_conn *conn = cmd->conn;
84 struct iscsi_datain_req *dr;84 struct iscsi_datain_req *dr;
85 85
86 dr = iscsit_get_datain_req(cmd);86 dr = iscsit_get_datain_req(cmd);
@@ -174,11 +174,11 @@ static struct iscsi_datain_req *iscsit_set_datain_values_yes_and_yes( · 87 unmodified lines
174 * For Normal and Recovery DataSequenceInOrder=No and DataPDUInOrder=Yes.174 * For Normal and Recovery DataSequenceInOrder=No and DataPDUInOrder=Yes.
175 */175 */
176static struct iscsi_datain_req *iscsit_set_datain_values_no_and_yes(176static struct iscsi_datain_req *iscsit_set_datain_values_no_and_yes(
177 struct iscsi_cmd *cmd,177 struct iscsit_cmd *cmd,
178 struct iscsi_datain *datain)178 struct iscsi_datain *datain)
179{179{
180 u32 offset, read_data_done, read_data_left, seq_send_order;180 u32 offset, read_data_done, read_data_left, seq_send_order;
181 struct iscsi_conn *conn = cmd->conn;181 struct iscsit_conn *conn = cmd->conn;
182 struct iscsi_datain_req *dr;182 struct iscsi_datain_req *dr;
183 struct iscsi_seq *seq;183 struct iscsi_seq *seq;
184 184
@@ -295,11 +295,11 @@ static struct iscsi_datain_req *iscsit_set_datain_values_no_and_yes( · 110 unmodified lines
295 * For Normal and Recovery DataSequenceInOrder=Yes and DataPDUInOrder=No.295 * For Normal and Recovery DataSequenceInOrder=Yes and DataPDUInOrder=No.
296 */296 */
297static struct iscsi_datain_req *iscsit_set_datain_values_yes_and_no(297static struct iscsi_datain_req *iscsit_set_datain_values_yes_and_no(
298 struct iscsi_cmd *cmd,298 struct iscsit_cmd *cmd,
299 struct iscsi_datain *datain)299 struct iscsi_datain *datain)
300{300{
301 u32 next_burst_len, read_data_done, read_data_left;301 u32 next_burst_len, read_data_done, read_data_left;
302 struct iscsi_conn *conn = cmd->conn;302 struct iscsit_conn *conn = cmd->conn;
303 struct iscsi_datain_req *dr;303 struct iscsi_datain_req *dr;
304 struct iscsi_pdu *pdu;304 struct iscsi_pdu *pdu;
305 305
@@ -394,11 +394,11 @@ static struct iscsi_datain_req *iscsit_set_datain_values_yes_and_no( · 88 unmodified lines
394 * For Normal and Recovery DataSequenceInOrder=No and DataPDUInOrder=No.394 * For Normal and Recovery DataSequenceInOrder=No and DataPDUInOrder=No.
395 */395 */
396static struct iscsi_datain_req *iscsit_set_datain_values_no_and_no(396static struct iscsi_datain_req *iscsit_set_datain_values_no_and_no(
397 struct iscsi_cmd *cmd,397 struct iscsit_cmd *cmd,
398 struct iscsi_datain *datain)398 struct iscsi_datain *datain)
399{399{
400 u32 read_data_done, read_data_left, seq_send_order;400 u32 read_data_done, read_data_left, seq_send_order;
401 struct iscsi_conn *conn = cmd->conn;401 struct iscsit_conn *conn = cmd->conn;
402 struct iscsi_datain_req *dr;402 struct iscsi_datain_req *dr;
403 struct iscsi_pdu *pdu;403 struct iscsi_pdu *pdu;
404 struct iscsi_seq *seq = NULL;404 struct iscsi_seq *seq = NULL;
@@ -496,10 +496,10 @@ static struct iscsi_datain_req *iscsit_set_datain_values_no_and_no( · 91 unmodified lines
496}496}
497 497
498struct iscsi_datain_req *iscsit_get_datain_values(498struct iscsi_datain_req *iscsit_get_datain_values(
499 struct iscsi_cmd *cmd,499 struct iscsit_cmd *cmd,
500 struct iscsi_datain *datain)500 struct iscsi_datain *datain)
501{501{
502 struct iscsi_conn *conn = cmd->conn;502 struct iscsit_conn *conn = cmd->conn;
503 503
504 if (conn->sess->sess_ops->DataSequenceInOrder &&504 if (conn->sess->sess_ops->DataSequenceInOrder &&
505 conn->sess->sess_ops->DataPDUInOrder)505 conn->sess->sess_ops->DataPDUInOrder)
drivers/target/iscsi/iscsi_target_datain_values.h+6−6
@@ -2,15 +2,15 @@ · 1 unmodified line
2#ifndef ISCSI_TARGET_DATAIN_VALUES_H2#ifndef ISCSI_TARGET_DATAIN_VALUES_H
3#define ISCSI_TARGET_DATAIN_VALUES_H3#define ISCSI_TARGET_DATAIN_VALUES_H
4 4
5struct iscsi_cmd;5struct iscsit_cmd;
6struct iscsi_datain;6struct iscsi_datain;
7 7
8extern struct iscsi_datain_req *iscsit_allocate_datain_req(void);8extern struct iscsi_datain_req *iscsit_allocate_datain_req(void);
9extern void iscsit_attach_datain_req(struct iscsi_cmd *, struct iscsi_datain_req *);9extern void iscsit_attach_datain_req(struct iscsit_cmd *, struct iscsi_datain_req *);
10extern void iscsit_free_datain_req(struct iscsi_cmd *, struct iscsi_datain_req *);10extern void iscsit_free_datain_req(struct iscsit_cmd *, struct iscsi_datain_req *);
11extern void iscsit_free_all_datain_reqs(struct iscsi_cmd *);11extern void iscsit_free_all_datain_reqs(struct iscsit_cmd *);
12extern struct iscsi_datain_req *iscsit_get_datain_req(struct iscsi_cmd *);12extern struct iscsi_datain_req *iscsit_get_datain_req(struct iscsit_cmd *);
13extern struct iscsi_datain_req *iscsit_get_datain_values(struct iscsi_cmd *,13extern struct iscsi_datain_req *iscsit_get_datain_values(struct iscsit_cmd *,
14 struct iscsi_datain *);14 struct iscsi_datain *);
15 15
16#endif /*** ISCSI_TARGET_DATAIN_VALUES_H ***/16#endif /*** ISCSI_TARGET_DATAIN_VALUES_H ***/
drivers/target/iscsi/iscsi_target_device.c+2−2
@@ -17,7 +17,7 @@ · 16 unmodified lines
17#include "iscsi_target_tpg.h"17#include "iscsi_target_tpg.h"
18#include "iscsi_target_util.h"18#include "iscsi_target_util.h"
19 19
20void iscsit_determine_maxcmdsn(struct iscsi_session *sess)20void iscsit_determine_maxcmdsn(struct iscsit_session *sess)
21{21{
22 struct se_node_acl *se_nacl;22 struct se_node_acl *se_nacl;
23 23
@@ -42,7 +42,7 @@ void iscsit_determine_maxcmdsn(struct iscsi_session *sess) · 18 unmodified lines
42 atomic_add(se_nacl->queue_depth - 1, &sess->max_cmd_sn);42 atomic_add(se_nacl->queue_depth - 1, &sess->max_cmd_sn);
43}43}
44 44
45void iscsit_increment_maxcmdsn(struct iscsi_cmd *cmd, struct iscsi_session *sess)45void iscsit_increment_maxcmdsn(struct iscsit_cmd *cmd, struct iscsit_session *sess)
46{46{
47 u32 max_cmd_sn;47 u32 max_cmd_sn;
48 48
drivers/target/iscsi/iscsi_target_device.h+4−4
@@ -2,10 +2,10 @@ · 1 unmodified line
2#ifndef ISCSI_TARGET_DEVICE_H2#ifndef ISCSI_TARGET_DEVICE_H
3#define ISCSI_TARGET_DEVICE_H3#define ISCSI_TARGET_DEVICE_H
4 4
5struct iscsi_cmd;5struct iscsit_cmd;
6struct iscsi_session;6struct iscsit_session;
7 7
8extern void iscsit_determine_maxcmdsn(struct iscsi_session *);8extern void iscsit_determine_maxcmdsn(struct iscsit_session *);
9extern void iscsit_increment_maxcmdsn(struct iscsi_cmd *, struct iscsi_session *);9extern void iscsit_increment_maxcmdsn(struct iscsit_cmd *, struct iscsit_session *);
10 10
11#endif /* ISCSI_TARGET_DEVICE_H */11#endif /* ISCSI_TARGET_DEVICE_H */
drivers/target/iscsi/iscsi_target_erl0.c+34−34
@@ -24,14 +24,14 @@ · 23 unmodified lines
24#include "iscsi_target.h"24#include "iscsi_target.h"
25 25
26/*26/*
27 * Used to set values in struct iscsi_cmd that iscsit_dataout_check_sequence()27 * Used to set values in struct iscsit_cmd that iscsit_dataout_check_sequence()
28 * checks against to determine a PDU's Offset+Length is within the current28 * checks against to determine a PDU's Offset+Length is within the current
29 * DataOUT Sequence. Used for DataSequenceInOrder=Yes only.29 * DataOUT Sequence. Used for DataSequenceInOrder=Yes only.
30 */30 */
31void iscsit_set_dataout_sequence_values(31void iscsit_set_dataout_sequence_values(
32 struct iscsi_cmd *cmd)32 struct iscsit_cmd *cmd)
33{33{
34 struct iscsi_conn *conn = cmd->conn;34 struct iscsit_conn *conn = cmd->conn;
35 /*35 /*
36 * Still set seq_start_offset and seq_end_offset for Unsolicited36 * Still set seq_start_offset and seq_end_offset for Unsolicited
37 * DataOUT, even if DataSequenceInOrder=No.37 * DataOUT, even if DataSequenceInOrder=No.
@@ -63,10 +63,10 @@ void iscsit_set_dataout_sequence_values( · 25 unmodified lines
63}63}
64 64
65static int iscsit_dataout_within_command_recovery_check(65static int iscsit_dataout_within_command_recovery_check(
66 struct iscsi_cmd *cmd,66 struct iscsit_cmd *cmd,
67 unsigned char *buf)67 unsigned char *buf)
68{68{
69 struct iscsi_conn *conn = cmd->conn;69 struct iscsit_conn *conn = cmd->conn;
70 struct iscsi_data *hdr = (struct iscsi_data *) buf;70 struct iscsi_data *hdr = (struct iscsi_data *) buf;
71 u32 payload_length = ntoh24(hdr->dlength);71 u32 payload_length = ntoh24(hdr->dlength);
72 72
@@ -129,11 +129,11 @@ dump: · 56 unmodified lines
129}129}
130 130
131static int iscsit_dataout_check_unsolicited_sequence(131static int iscsit_dataout_check_unsolicited_sequence(
132 struct iscsi_cmd *cmd,132 struct iscsit_cmd *cmd,
133 unsigned char *buf)133 unsigned char *buf)
134{134{
135 u32 first_burst_len;135 u32 first_burst_len;
136 struct iscsi_conn *conn = cmd->conn;136 struct iscsit_conn *conn = cmd->conn;
137 struct iscsi_data *hdr = (struct iscsi_data *) buf;137 struct iscsi_data *hdr = (struct iscsi_data *) buf;
138 u32 payload_length = ntoh24(hdr->dlength);138 u32 payload_length = ntoh24(hdr->dlength);
139 139
@@ -204,11 +204,11 @@ out: · 64 unmodified lines
204}204}
205 205
206static int iscsit_dataout_check_sequence(206static int iscsit_dataout_check_sequence(
207 struct iscsi_cmd *cmd,207 struct iscsit_cmd *cmd,
208 unsigned char *buf)208 unsigned char *buf)
209{209{
210 u32 next_burst_len;210 u32 next_burst_len;
211 struct iscsi_conn *conn = cmd->conn;211 struct iscsit_conn *conn = cmd->conn;
212 struct iscsi_seq *seq = NULL;212 struct iscsi_seq *seq = NULL;
213 struct iscsi_data *hdr = (struct iscsi_data *) buf;213 struct iscsi_data *hdr = (struct iscsi_data *) buf;
214 u32 payload_length = ntoh24(hdr->dlength);214 u32 payload_length = ntoh24(hdr->dlength);
@@ -333,11 +333,11 @@ out: · 118 unmodified lines
333}333}
334 334
335static int iscsit_dataout_check_datasn(335static int iscsit_dataout_check_datasn(
336 struct iscsi_cmd *cmd,336 struct iscsit_cmd *cmd,
337 unsigned char *buf)337 unsigned char *buf)
338{338{
339 u32 data_sn = 0;339 u32 data_sn = 0;
340 struct iscsi_conn *conn = cmd->conn;340 struct iscsit_conn *conn = cmd->conn;
341 struct iscsi_data *hdr = (struct iscsi_data *) buf;341 struct iscsi_data *hdr = (struct iscsi_data *) buf;
342 u32 payload_length = ntoh24(hdr->dlength);342 u32 payload_length = ntoh24(hdr->dlength);
343 343
@@ -384,17 +384,17 @@ dump: · 40 unmodified lines
384}384}
385 385
386static int iscsit_dataout_pre_datapduinorder_yes(386static int iscsit_dataout_pre_datapduinorder_yes(
387 struct iscsi_cmd *cmd,387 struct iscsit_cmd *cmd,
388 unsigned char *buf)388 unsigned char *buf)
389{389{
390 int dump = 0, recovery = 0;390 int dump = 0, recovery = 0;
391 struct iscsi_conn *conn = cmd->conn;391 struct iscsit_conn *conn = cmd->conn;
392 struct iscsi_data *hdr = (struct iscsi_data *) buf;392 struct iscsi_data *hdr = (struct iscsi_data *) buf;
393 u32 payload_length = ntoh24(hdr->dlength);393 u32 payload_length = ntoh24(hdr->dlength);
394 394
395 /*395 /*
396 * For DataSequenceInOrder=Yes: If the offset is greater than the global396 * For DataSequenceInOrder=Yes: If the offset is greater than the global
397 * DataPDUInOrder=Yes offset counter in struct iscsi_cmd a protcol error has397 * DataPDUInOrder=Yes offset counter in struct iscsit_cmd a protcol error has
398 * occurred and fail the connection.398 * occurred and fail the connection.
399 *399 *
400 * For DataSequenceInOrder=No: If the offset is greater than the per400 * For DataSequenceInOrder=No: If the offset is greater than the per
@@ -446,7 +446,7 @@ dump: · 45 unmodified lines
446}446}
447 447
448static int iscsit_dataout_pre_datapduinorder_no(448static int iscsit_dataout_pre_datapduinorder_no(
449 struct iscsi_cmd *cmd,449 struct iscsit_cmd *cmd,
450 unsigned char *buf)450 unsigned char *buf)
451{451{
452 struct iscsi_pdu *pdu;452 struct iscsi_pdu *pdu;
@@ -477,7 +477,7 @@ static int iscsit_dataout_pre_datapduinorder_no( · 24 unmodified lines
477 return DATAOUT_NORMAL;477 return DATAOUT_NORMAL;
478}478}
479 479
480static int iscsit_dataout_update_r2t(struct iscsi_cmd *cmd, u32 offset, u32 length)480static int iscsit_dataout_update_r2t(struct iscsit_cmd *cmd, u32 offset, u32 length)
481{481{
482 struct iscsi_r2t *r2t;482 struct iscsi_r2t *r2t;
483 483
@@ -497,7 +497,7 @@ static int iscsit_dataout_update_r2t(struct iscsi_cmd *cmd, u32 offset, u32 leng · 13 unmodified lines
497}497}
498 498
499static int iscsit_dataout_update_datapduinorder_no(499static int iscsit_dataout_update_datapduinorder_no(
500 struct iscsi_cmd *cmd,500 struct iscsit_cmd *cmd,
501 u32 data_sn,501 u32 data_sn,
502 int f_bit)502 int f_bit)
503{503{
@@ -530,11 +530,11 @@ static int iscsit_dataout_update_datapduinorder_no( · 26 unmodified lines
530}530}
531 531
532static int iscsit_dataout_post_crc_passed(532static int iscsit_dataout_post_crc_passed(
533 struct iscsi_cmd *cmd,533 struct iscsit_cmd *cmd,
534 unsigned char *buf)534 unsigned char *buf)
535{535{
536 int ret, send_r2t = 0;536 int ret, send_r2t = 0;
537 struct iscsi_conn *conn = cmd->conn;537 struct iscsit_conn *conn = cmd->conn;
538 struct iscsi_seq *seq = NULL;538 struct iscsi_seq *seq = NULL;
539 struct iscsi_data *hdr = (struct iscsi_data *) buf;539 struct iscsi_data *hdr = (struct iscsi_data *) buf;
540 u32 payload_length = ntoh24(hdr->dlength);540 u32 payload_length = ntoh24(hdr->dlength);
@@ -641,10 +641,10 @@ static int iscsit_dataout_post_crc_passed( · 100 unmodified lines
641}641}
642 642
643static int iscsit_dataout_post_crc_failed(643static int iscsit_dataout_post_crc_failed(
644 struct iscsi_cmd *cmd,644 struct iscsit_cmd *cmd,
645 unsigned char *buf)645 unsigned char *buf)
646{646{
647 struct iscsi_conn *conn = cmd->conn;647 struct iscsit_conn *conn = cmd->conn;
648 struct iscsi_pdu *pdu;648 struct iscsi_pdu *pdu;
649 struct iscsi_data *hdr = (struct iscsi_data *) buf;649 struct iscsi_data *hdr = (struct iscsi_data *) buf;
650 u32 payload_length = ntoh24(hdr->dlength);650 u32 payload_length = ntoh24(hdr->dlength);
@@ -679,11 +679,11 @@ recover: · 28 unmodified lines
679 * and CRC computed.679 * and CRC computed.
680 */680 */
681int iscsit_check_pre_dataout(681int iscsit_check_pre_dataout(
682 struct iscsi_cmd *cmd,682 struct iscsit_cmd *cmd,
683 unsigned char *buf)683 unsigned char *buf)
684{684{
685 int ret;685 int ret;
686 struct iscsi_conn *conn = cmd->conn;686 struct iscsit_conn *conn = cmd->conn;
687 687
688 ret = iscsit_dataout_within_command_recovery_check(cmd, buf);688 ret = iscsit_dataout_within_command_recovery_check(cmd, buf);
689 if ((ret == DATAOUT_WITHIN_COMMAND_RECOVERY) ||689 if ((ret == DATAOUT_WITHIN_COMMAND_RECOVERY) ||
@@ -717,11 +717,11 @@ int iscsit_check_pre_dataout( · 27 unmodified lines
717 * and CRC computed.717 * and CRC computed.
718 */718 */
719int iscsit_check_post_dataout(719int iscsit_check_post_dataout(
720 struct iscsi_cmd *cmd,720 struct iscsit_cmd *cmd,
721 unsigned char *buf,721 unsigned char *buf,
722 u8 data_crc_failed)722 u8 data_crc_failed)
723{723{
724 struct iscsi_conn *conn = cmd->conn;724 struct iscsit_conn *conn = cmd->conn;
725 725
726 cmd->dataout_timeout_retries = 0;726 cmd->dataout_timeout_retries = 0;
727 727
@@ -743,7 +743,7 @@ int iscsit_check_post_dataout( · 15 unmodified lines
743 743
744void iscsit_handle_time2retain_timeout(struct timer_list *t)744void iscsit_handle_time2retain_timeout(struct timer_list *t)
745{745{
746 struct iscsi_session *sess = from_timer(sess, t, time2retain_timer);746 struct iscsit_session *sess = from_timer(sess, t, time2retain_timer);
747 struct iscsi_portal_group *tpg = sess->tpg;747 struct iscsi_portal_group *tpg = sess->tpg;
748 struct se_portal_group *se_tpg = &tpg->tpg_se_tpg;748 struct se_portal_group *se_tpg = &tpg->tpg_se_tpg;
749 749
@@ -768,7 +768,7 @@ void iscsit_handle_time2retain_timeout(struct timer_list *t) · 18 unmodified lines
768 iscsit_close_session(sess, false);768 iscsit_close_session(sess, false);
769}769}
770 770
771void iscsit_start_time2retain_handler(struct iscsi_session *sess)771void iscsit_start_time2retain_handler(struct iscsit_session *sess)
772{772{
773 int tpg_active;773 int tpg_active;
774 /*774 /*
@@ -794,7 +794,7 @@ void iscsit_start_time2retain_handler(struct iscsi_session *sess) · 19 unmodified lines
794 jiffies + sess->sess_ops->DefaultTime2Retain * HZ);794 jiffies + sess->sess_ops->DefaultTime2Retain * HZ);
795}795}
796 796
797int iscsit_stop_time2retain_timer(struct iscsi_session *sess)797int iscsit_stop_time2retain_timer(struct iscsit_session *sess)
798{798{
799 struct iscsi_portal_group *tpg = sess->tpg;799 struct iscsi_portal_group *tpg = sess->tpg;
800 struct se_portal_group *se_tpg = &tpg->tpg_se_tpg;800 struct se_portal_group *se_tpg = &tpg->tpg_se_tpg;
@@ -819,7 +819,7 @@ int iscsit_stop_time2retain_timer(struct iscsi_session *sess) · 18 unmodified lines
819 return 0;819 return 0;
820}820}
821 821
822void iscsit_connection_reinstatement_rcfr(struct iscsi_conn *conn)822void iscsit_connection_reinstatement_rcfr(struct iscsit_conn *conn)
823{823{
824 spin_lock_bh(&conn->state_lock);824 spin_lock_bh(&conn->state_lock);
825 if (atomic_read(&conn->connection_exit)) {825 if (atomic_read(&conn->connection_exit)) {
@@ -843,7 +843,7 @@ sleep: · 17 unmodified lines
843 complete(&conn->conn_post_wait_comp);843 complete(&conn->conn_post_wait_comp);
844}844}
845 845
846void iscsit_cause_connection_reinstatement(struct iscsi_conn *conn, int sleep)846void iscsit_cause_connection_reinstatement(struct iscsit_conn *conn, int sleep)
847{847{
848 spin_lock_bh(&conn->state_lock);848 spin_lock_bh(&conn->state_lock);
849 if (atomic_read(&conn->connection_exit)) {849 if (atomic_read(&conn->connection_exit)) {
@@ -880,7 +880,7 @@ void iscsit_cause_connection_reinstatement(struct iscsi_conn *conn, int sleep) · 30 unmodified lines
880}880}
881EXPORT_SYMBOL(iscsit_cause_connection_reinstatement);881EXPORT_SYMBOL(iscsit_cause_connection_reinstatement);
882 882
883void iscsit_fall_back_to_erl0(struct iscsi_session *sess)883void iscsit_fall_back_to_erl0(struct iscsit_session *sess)
884{884{
885 pr_debug("Falling back to ErrorRecoveryLevel=0 for SID:"885 pr_debug("Falling back to ErrorRecoveryLevel=0 for SID:"
886 " %u\n", sess->sid);886 " %u\n", sess->sid);
@@ -888,9 +888,9 @@ void iscsit_fall_back_to_erl0(struct iscsi_session *sess) · 1 unmodified line
888 atomic_set(&sess->session_fall_back_to_erl0, 1);888 atomic_set(&sess->session_fall_back_to_erl0, 1);
889}889}
890 890
891static void iscsit_handle_connection_cleanup(struct iscsi_conn *conn)891static void iscsit_handle_connection_cleanup(struct iscsit_conn *conn)
892{892{
893 struct iscsi_session *sess = conn->sess;893 struct iscsit_session *sess = conn->sess;
894 894
895 if ((sess->sess_ops->ErrorRecoveryLevel == 2) &&895 if ((sess->sess_ops->ErrorRecoveryLevel == 2) &&
896 !atomic_read(&sess->session_reinstatement) &&896 !atomic_read(&sess->session_reinstatement) &&
@@ -904,7 +904,7 @@ static void iscsit_handle_connection_cleanup(struct iscsi_conn *conn) · 7 unmodified lines
904 }904 }
905}905}
906 906
907void iscsit_take_action_for_connection_exit(struct iscsi_conn *conn, bool *conn_freed)907void iscsit_take_action_for_connection_exit(struct iscsit_conn *conn, bool *conn_freed)
908{908{
909 *conn_freed = false;909 *conn_freed = false;
910 910
drivers/target/iscsi/iscsi_target_erl0.h+12−12
@@ -4,19 +4,19 @@ · 3 unmodified lines
4 4
5#include <linux/types.h>5#include <linux/types.h>
6 6
7struct iscsi_cmd;7struct iscsit_cmd;
8struct iscsi_conn;8struct iscsit_conn;
9struct iscsi_session;9struct iscsit_session;
10 10
11extern void iscsit_set_dataout_sequence_values(struct iscsi_cmd *);11extern void iscsit_set_dataout_sequence_values(struct iscsit_cmd *);
12extern int iscsit_check_pre_dataout(struct iscsi_cmd *, unsigned char *);12extern int iscsit_check_pre_dataout(struct iscsit_cmd *, unsigned char *);
13extern int iscsit_check_post_dataout(struct iscsi_cmd *, unsigned char *, u8);13extern int iscsit_check_post_dataout(struct iscsit_cmd *, unsigned char *, u8);
14extern void iscsit_start_time2retain_handler(struct iscsi_session *);14extern void iscsit_start_time2retain_handler(struct iscsit_session *);
15extern void iscsit_handle_time2retain_timeout(struct timer_list *t);15extern void iscsit_handle_time2retain_timeout(struct timer_list *t);
16extern int iscsit_stop_time2retain_timer(struct iscsi_session *);16extern int iscsit_stop_time2retain_timer(struct iscsit_session *);
17extern void iscsit_connection_reinstatement_rcfr(struct iscsi_conn *);17extern void iscsit_connection_reinstatement_rcfr(struct iscsit_conn *);
18extern void iscsit_cause_connection_reinstatement(struct iscsi_conn *, int);18extern void iscsit_cause_connection_reinstatement(struct iscsit_conn *, int);
19extern void iscsit_fall_back_to_erl0(struct iscsi_session *);19extern void iscsit_fall_back_to_erl0(struct iscsit_session *);
20extern void iscsit_take_action_for_connection_exit(struct iscsi_conn *, bool *);20extern void iscsit_take_action_for_connection_exit(struct iscsit_conn *, bool *);
21 21
22#endif /*** ISCSI_TARGET_ERL0_H ***/22#endif /*** ISCSI_TARGET_ERL0_H ***/
drivers/target/iscsi/iscsi_target_erl1.c+46−46
@@ -36,7 +36,7 @@ · 35 unmodified lines
36 * to be dumped.36 * to be dumped.
37 */37 */
38int iscsit_dump_data_payload(38int iscsit_dump_data_payload(
39 struct iscsi_conn *conn,39 struct iscsit_conn *conn,
40 u32 buf_len,40 u32 buf_len,
41 int dump_padding_digest)41 int dump_padding_digest)
42{42{
@@ -87,7 +87,7 @@ int iscsit_dump_data_payload( · 44 unmodified lines
87 * Used for retransmitting R2Ts from a R2T SNACK request.87 * Used for retransmitting R2Ts from a R2T SNACK request.
88 */88 */
89static int iscsit_send_recovery_r2t_for_snack(89static int iscsit_send_recovery_r2t_for_snack(
90 struct iscsi_cmd *cmd,90 struct iscsit_cmd *cmd,
91 struct iscsi_r2t *r2t)91 struct iscsi_r2t *r2t)
92{92{
93 /*93 /*
@@ -109,7 +109,7 @@ static int iscsit_send_recovery_r2t_for_snack( · 15 unmodified lines
109}109}
110 110
111static int iscsit_handle_r2t_snack(111static int iscsit_handle_r2t_snack(
112 struct iscsi_cmd *cmd,112 struct iscsit_cmd *cmd,
113 unsigned char *buf,113 unsigned char *buf,
114 u32 begrun,114 u32 begrun,
115 u32 runlength)115 u32 runlength)
@@ -167,13 +167,13 @@ static int iscsit_handle_r2t_snack( · 51 unmodified lines
167 * FIXME: How is this handled for a RData SNACK?167 * FIXME: How is this handled for a RData SNACK?
168 */168 */
169int iscsit_create_recovery_datain_values_datasequenceinorder_yes(169int iscsit_create_recovery_datain_values_datasequenceinorder_yes(
170 struct iscsi_cmd *cmd,170 struct iscsit_cmd *cmd,
171 struct iscsi_datain_req *dr)171 struct iscsi_datain_req *dr)
172{172{
173 u32 data_sn = 0, data_sn_count = 0;173 u32 data_sn = 0, data_sn_count = 0;
174 u32 pdu_start = 0, seq_no = 0;174 u32 pdu_start = 0, seq_no = 0;
175 u32 begrun = dr->begrun;175 u32 begrun = dr->begrun;
176 struct iscsi_conn *conn = cmd->conn;176 struct iscsit_conn *conn = cmd->conn;
177 177
178 while (begrun > data_sn++) {178 while (begrun > data_sn++) {
179 data_sn_count++;179 data_sn_count++;
@@ -213,18 +213,18 @@ int iscsit_create_recovery_datain_values_datasequenceinorder_yes( · 33 unmodified lines
213 * FIXME: How is this handled for a RData SNACK?213 * FIXME: How is this handled for a RData SNACK?
214 */214 */
215int iscsit_create_recovery_datain_values_datasequenceinorder_no(215int iscsit_create_recovery_datain_values_datasequenceinorder_no(
216 struct iscsi_cmd *cmd,216 struct iscsit_cmd *cmd,
217 struct iscsi_datain_req *dr)217 struct iscsi_datain_req *dr)
218{218{
219 int found_seq = 0, i;219 int found_seq = 0, i;
220 u32 data_sn, read_data_done = 0, seq_send_order = 0;220 u32 data_sn, read_data_done = 0, seq_send_order = 0;
221 u32 begrun = dr->begrun;221 u32 begrun = dr->begrun;
222 u32 runlength = dr->runlength;222 u32 runlength = dr->runlength;
223 struct iscsi_conn *conn = cmd->conn;223 struct iscsit_conn *conn = cmd->conn;
224 struct iscsi_seq *first_seq = NULL, *seq = NULL;224 struct iscsi_seq *first_seq = NULL, *seq = NULL;
225 225
226 if (!cmd->seq_list) {226 if (!cmd->seq_list) {
227 pr_err("struct iscsi_cmd->seq_list is NULL!\n");227 pr_err("struct iscsit_cmd->seq_list is NULL!\n");
228 return -1;228 return -1;
229 }229 }
230 230
@@ -371,12 +371,12 @@ done: · 140 unmodified lines
371}371}
372 372
373static int iscsit_handle_recovery_datain(373static int iscsit_handle_recovery_datain(
374 struct iscsi_cmd *cmd,374 struct iscsit_cmd *cmd,
375 unsigned char *buf,375 unsigned char *buf,
376 u32 begrun,376 u32 begrun,
377 u32 runlength)377 u32 runlength)
378{378{
379 struct iscsi_conn *conn = cmd->conn;379 struct iscsit_conn *conn = cmd->conn;
380 struct iscsi_datain_req *dr;380 struct iscsi_datain_req *dr;
381 struct se_cmd *se_cmd = &cmd->se_cmd;381 struct se_cmd *se_cmd = &cmd->se_cmd;
382 382
@@ -432,14 +432,14 @@ static int iscsit_handle_recovery_datain( · 49 unmodified lines
432}432}
433 433
434int iscsit_handle_recovery_datain_or_r2t(434int iscsit_handle_recovery_datain_or_r2t(
435 struct iscsi_conn *conn,435 struct iscsit_conn *conn,
436 unsigned char *buf,436 unsigned char *buf,
437 itt_t init_task_tag,437 itt_t init_task_tag,
438 u32 targ_xfer_tag,438 u32 targ_xfer_tag,
439 u32 begrun,439 u32 begrun,
440 u32 runlength)440 u32 runlength)
441{441{
442 struct iscsi_cmd *cmd;442 struct iscsit_cmd *cmd;
443 443
444 cmd = iscsit_find_cmd_from_itt(conn, init_task_tag);444 cmd = iscsit_find_cmd_from_itt(conn, init_task_tag);
445 if (!cmd)445 if (!cmd)
@@ -465,13 +465,13 @@ int iscsit_handle_recovery_datain_or_r2t( · 19 unmodified lines
465 465
466/* #warning FIXME: Status SNACK needs to be dependent on OPCODE!!! */466/* #warning FIXME: Status SNACK needs to be dependent on OPCODE!!! */
467int iscsit_handle_status_snack(467int iscsit_handle_status_snack(
468 struct iscsi_conn *conn,468 struct iscsit_conn *conn,
469 itt_t init_task_tag,469 itt_t init_task_tag,
470 u32 targ_xfer_tag,470 u32 targ_xfer_tag,
471 u32 begrun,471 u32 begrun,
472 u32 runlength)472 u32 runlength)
473{473{
474 struct iscsi_cmd *cmd = NULL;474 struct iscsit_cmd *cmd = NULL;
475 u32 last_statsn;475 u32 last_statsn;
476 int found_cmd;476 int found_cmd;
477 477
@@ -529,12 +529,12 @@ int iscsit_handle_status_snack( · 51 unmodified lines
529}529}
530 530
531int iscsit_handle_data_ack(531int iscsit_handle_data_ack(
532 struct iscsi_conn *conn,532 struct iscsit_conn *conn,
533 u32 targ_xfer_tag,533 u32 targ_xfer_tag,
534 u32 begrun,534 u32 begrun,
535 u32 runlength)535 u32 runlength)
536{536{
537 struct iscsi_cmd *cmd = NULL;537 struct iscsit_cmd *cmd = NULL;
538 538
539 cmd = iscsit_find_cmd_from_ttt(conn, targ_xfer_tag);539 cmd = iscsit_find_cmd_from_ttt(conn, targ_xfer_tag);
540 if (!cmd) {540 if (!cmd) {
@@ -565,7 +565,7 @@ int iscsit_handle_data_ack( · 24 unmodified lines
565}565}
566 566
567static int iscsit_send_recovery_r2t(567static int iscsit_send_recovery_r2t(
568 struct iscsi_cmd *cmd,568 struct iscsit_cmd *cmd,
569 u32 offset,569 u32 offset,
570 u32 xfer_len)570 u32 xfer_len)
571{571{
@@ -579,12 +579,12 @@ static int iscsit_send_recovery_r2t( · 7 unmodified lines
579}579}
580 580
581int iscsit_dataout_datapduinorder_no_fbit(581int iscsit_dataout_datapduinorder_no_fbit(
582 struct iscsi_cmd *cmd,582 struct iscsit_cmd *cmd,
583 struct iscsi_pdu *pdu)583 struct iscsi_pdu *pdu)
584{584{
585 int i, send_recovery_r2t = 0, recovery = 0;585 int i, send_recovery_r2t = 0, recovery = 0;
586 u32 length = 0, offset = 0, pdu_count = 0, xfer_len = 0;586 u32 length = 0, offset = 0, pdu_count = 0, xfer_len = 0;
587 struct iscsi_conn *conn = cmd->conn;587 struct iscsit_conn *conn = cmd->conn;
588 struct iscsi_pdu *first_pdu = NULL;588 struct iscsi_pdu *first_pdu = NULL;
589 589
590 /*590 /*
@@ -655,14 +655,14 @@ int iscsit_dataout_datapduinorder_no_fbit( · 64 unmodified lines
655}655}
656 656
657static int iscsit_recalculate_dataout_values(657static int iscsit_recalculate_dataout_values(
658 struct iscsi_cmd *cmd,658 struct iscsit_cmd *cmd,
659 u32 pdu_offset,659 u32 pdu_offset,
660 u32 pdu_length,660 u32 pdu_length,
661 u32 *r2t_offset,661 u32 *r2t_offset,
662 u32 *r2t_length)662 u32 *r2t_length)
663{663{
664 int i;664 int i;
665 struct iscsi_conn *conn = cmd->conn;665 struct iscsit_conn *conn = cmd->conn;
666 struct iscsi_pdu *pdu = NULL;666 struct iscsi_pdu *pdu = NULL;
667 667
668 if (conn->sess->sess_ops->DataSequenceInOrder) {668 if (conn->sess->sess_ops->DataSequenceInOrder) {
@@ -732,7 +732,7 @@ static int iscsit_recalculate_dataout_values( · 63 unmodified lines
732}732}
733 733
734int iscsit_recover_dataout_sequence(734int iscsit_recover_dataout_sequence(
735 struct iscsi_cmd *cmd,735 struct iscsit_cmd *cmd,
736 u32 pdu_offset,736 u32 pdu_offset,
737 u32 pdu_length)737 u32 pdu_length)
738{738{
@@ -767,7 +767,7 @@ static struct iscsi_ooo_cmdsn *iscsit_allocate_ooo_cmdsn(void) · 28 unmodified lines
767}767}
768 768
769static int iscsit_attach_ooo_cmdsn(769static int iscsit_attach_ooo_cmdsn(
770 struct iscsi_session *sess,770 struct iscsit_session *sess,
771 struct iscsi_ooo_cmdsn *ooo_cmdsn)771 struct iscsi_ooo_cmdsn *ooo_cmdsn)
772{772{
773 struct iscsi_ooo_cmdsn *ooo_tail, *ooo_tmp;773 struct iscsi_ooo_cmdsn *ooo_tail, *ooo_tmp;
@@ -815,20 +815,20 @@ static int iscsit_attach_ooo_cmdsn( · 41 unmodified lines
815 815
816/*816/*
817 * Removes an struct iscsi_ooo_cmdsn from a session's list,817 * Removes an struct iscsi_ooo_cmdsn from a session's list,
818 * called with struct iscsi_session->cmdsn_mutex held.818 * called with struct iscsit_session->cmdsn_mutex held.
819 */819 */
820void iscsit_remove_ooo_cmdsn(820void iscsit_remove_ooo_cmdsn(
821 struct iscsi_session *sess,821 struct iscsit_session *sess,
822 struct iscsi_ooo_cmdsn *ooo_cmdsn)822 struct iscsi_ooo_cmdsn *ooo_cmdsn)
823{823{
824 list_del(&ooo_cmdsn->ooo_list);824 list_del(&ooo_cmdsn->ooo_list);
825 kmem_cache_free(lio_ooo_cache, ooo_cmdsn);825 kmem_cache_free(lio_ooo_cache, ooo_cmdsn);
826}826}
827 827
828void iscsit_clear_ooo_cmdsns_for_conn(struct iscsi_conn *conn)828void iscsit_clear_ooo_cmdsns_for_conn(struct iscsit_conn *conn)
829{829{
830 struct iscsi_ooo_cmdsn *ooo_cmdsn;830 struct iscsi_ooo_cmdsn *ooo_cmdsn;
831 struct iscsi_session *sess = conn->sess;831 struct iscsit_session *sess = conn->sess;
832 832
833 mutex_lock(&sess->cmdsn_mutex);833 mutex_lock(&sess->cmdsn_mutex);
834 list_for_each_entry(ooo_cmdsn, &sess->sess_ooo_cmdsn_list, ooo_list) {834 list_for_each_entry(ooo_cmdsn, &sess->sess_ooo_cmdsn_list, ooo_list) {
@@ -840,10 +840,10 @@ void iscsit_clear_ooo_cmdsns_for_conn(struct iscsi_conn *conn) · 5 unmodified lines
840 mutex_unlock(&sess->cmdsn_mutex);840 mutex_unlock(&sess->cmdsn_mutex);
841}841}
842 842
843int iscsit_execute_ooo_cmdsns(struct iscsi_session *sess)843int iscsit_execute_ooo_cmdsns(struct iscsit_session *sess)
844{844{
845 int ooo_count = 0;845 int ooo_count = 0;
846 struct iscsi_cmd *cmd = NULL;846 struct iscsit_cmd *cmd = NULL;
847 struct iscsi_ooo_cmdsn *ooo_cmdsn, *ooo_cmdsn_tmp;847 struct iscsi_ooo_cmdsn *ooo_cmdsn, *ooo_cmdsn_tmp;
848 848
849 lockdep_assert_held(&sess->cmdsn_mutex);849 lockdep_assert_held(&sess->cmdsn_mutex);
@@ -884,10 +884,10 @@ int iscsit_execute_ooo_cmdsns(struct iscsi_session *sess) · 34 unmodified lines
884 * 2. With no locks held directly from iscsi_handle_XXX_pdu() functions884 * 2. With no locks held directly from iscsi_handle_XXX_pdu() functions
885 * for immediate commands.885 * for immediate commands.
886 */886 */
887int iscsit_execute_cmd(struct iscsi_cmd *cmd, int ooo)887int iscsit_execute_cmd(struct iscsit_cmd *cmd, int ooo)
888{888{
889 struct se_cmd *se_cmd = &cmd->se_cmd;889 struct se_cmd *se_cmd = &cmd->se_cmd;
890 struct iscsi_conn *conn = cmd->conn;890 struct iscsit_conn *conn = cmd->conn;
891 int lr = 0;891 int lr = 0;
892 892
893 spin_lock_bh(&cmd->istate_lock);893 spin_lock_bh(&cmd->istate_lock);
@@ -994,7 +994,7 @@ int iscsit_execute_cmd(struct iscsi_cmd *cmd, int ooo) · 100 unmodified lines
994 return 0;994 return 0;
995}995}
996 996
997void iscsit_free_all_ooo_cmdsns(struct iscsi_session *sess)997void iscsit_free_all_ooo_cmdsns(struct iscsit_session *sess)
998{998{
999 struct iscsi_ooo_cmdsn *ooo_cmdsn, *ooo_cmdsn_tmp;999 struct iscsi_ooo_cmdsn *ooo_cmdsn, *ooo_cmdsn_tmp;
1000 1000
@@ -1009,8 +1009,8 @@ void iscsit_free_all_ooo_cmdsns(struct iscsi_session *sess) · 8 unmodified lines
1009}1009}
1010 1010
1011int iscsit_handle_ooo_cmdsn(1011int iscsit_handle_ooo_cmdsn(
1012 struct iscsi_session *sess,1012 struct iscsit_session *sess,
1013 struct iscsi_cmd *cmd,1013 struct iscsit_cmd *cmd,
1014 u32 cmdsn)1014 u32 cmdsn)
1015{1015{
1016 int batch = 0;1016 int batch = 0;
@@ -1049,11 +1049,11 @@ int iscsit_handle_ooo_cmdsn( · 32 unmodified lines
1049}1049}
1050 1050
1051static int iscsit_set_dataout_timeout_values(1051static int iscsit_set_dataout_timeout_values(
1052 struct iscsi_cmd *cmd,1052 struct iscsit_cmd *cmd,
1053 u32 *offset,1053 u32 *offset,
1054 u32 *length)1054 u32 *length)
1055{1055{
1056 struct iscsi_conn *conn = cmd->conn;1056 struct iscsit_conn *conn = cmd->conn;
1057 struct iscsi_r2t *r2t;1057 struct iscsi_r2t *r2t;
1058 1058
1059 if (cmd->unsolicited_data) {1059 if (cmd->unsolicited_data) {
@@ -1095,9 +1095,9 @@ void iscsit_handle_dataout_timeout(struct timer_list *t) · 35 unmodified lines
1095{1095{
1096 u32 pdu_length = 0, pdu_offset = 0;1096 u32 pdu_length = 0, pdu_offset = 0;
1097 u32 r2t_length = 0, r2t_offset = 0;1097 u32 r2t_length = 0, r2t_offset = 0;
1098 struct iscsi_cmd *cmd = from_timer(cmd, t, dataout_timer);1098 struct iscsit_cmd *cmd = from_timer(cmd, t, dataout_timer);
1099 struct iscsi_conn *conn = cmd->conn;1099 struct iscsit_conn *conn = cmd->conn;
1100 struct iscsi_session *sess = NULL;1100 struct iscsit_session *sess = NULL;
1101 struct iscsi_node_attrib *na;1101 struct iscsi_node_attrib *na;
1102 1102
1103 iscsit_inc_conn_usage_count(conn);1103 iscsit_inc_conn_usage_count(conn);
@@ -1179,10 +1179,10 @@ failure: · 75 unmodified lines
1179 iscsit_dec_conn_usage_count(conn);1179 iscsit_dec_conn_usage_count(conn);
1180}1180}
1181 1181
1182void iscsit_mod_dataout_timer(struct iscsi_cmd *cmd)1182void iscsit_mod_dataout_timer(struct iscsit_cmd *cmd)
1183{1183{
1184 struct iscsi_conn *conn = cmd->conn;1184 struct iscsit_conn *conn = cmd->conn;
1185 struct iscsi_session *sess = conn->sess;1185 struct iscsit_session *sess = conn->sess;
1186 struct iscsi_node_attrib *na = iscsit_tpg_get_node_attrib(sess);1186 struct iscsi_node_attrib *na = iscsit_tpg_get_node_attrib(sess);
1187 1187
1188 spin_lock_bh(&cmd->dataout_timeout_lock);1188 spin_lock_bh(&cmd->dataout_timeout_lock);
@@ -1199,10 +1199,10 @@ void iscsit_mod_dataout_timer(struct iscsi_cmd *cmd) · 10 unmodified lines
1199}1199}
1200 1200
1201void iscsit_start_dataout_timer(1201void iscsit_start_dataout_timer(
1202 struct iscsi_cmd *cmd,1202 struct iscsit_cmd *cmd,
1203 struct iscsi_conn *conn)1203 struct iscsit_conn *conn)
1204{1204{
1205 struct iscsi_session *sess = conn->sess;1205 struct iscsit_session *sess = conn->sess;
1206 struct iscsi_node_attrib *na = iscsit_tpg_get_node_attrib(sess);1206 struct iscsi_node_attrib *na = iscsit_tpg_get_node_attrib(sess);
1207 1207
1208 lockdep_assert_held(&cmd->dataout_timeout_lock);1208 lockdep_assert_held(&cmd->dataout_timeout_lock);
@@ -1218,7 +1218,7 @@ void iscsit_start_dataout_timer( · 9 unmodified lines
1218 mod_timer(&cmd->dataout_timer, jiffies + na->dataout_timeout * HZ);1218 mod_timer(&cmd->dataout_timer, jiffies + na->dataout_timeout * HZ);
1219}1219}
1220 1220
1221void iscsit_stop_dataout_timer(struct iscsi_cmd *cmd)1221void iscsit_stop_dataout_timer(struct iscsit_cmd *cmd)
1222{1222{
1223 spin_lock_bh(&cmd->dataout_timeout_lock);1223 spin_lock_bh(&cmd->dataout_timeout_lock);
1224 if (!(cmd->dataout_timer_flags & ISCSI_TF_RUNNING)) {1224 if (!(cmd->dataout_timer_flags & ISCSI_TF_RUNNING)) {
drivers/target/iscsi/iscsi_target_erl1.h+20−20
@@ -5,34 +5,34 @@ · 4 unmodified lines
5#include <linux/types.h>5#include <linux/types.h>
6#include <scsi/iscsi_proto.h> /* itt_t */6#include <scsi/iscsi_proto.h> /* itt_t */
7 7
8struct iscsi_cmd;8struct iscsit_cmd;
9struct iscsi_conn;9struct iscsit_conn;
10struct iscsi_datain_req;10struct iscsi_datain_req;
11struct iscsi_ooo_cmdsn;11struct iscsi_ooo_cmdsn;
12struct iscsi_pdu;12struct iscsi_pdu;
13struct iscsi_session;13struct iscsit_session;
14 14
15extern int iscsit_dump_data_payload(struct iscsi_conn *, u32, int);15extern int iscsit_dump_data_payload(struct iscsit_conn *, u32, int);
16extern int iscsit_create_recovery_datain_values_datasequenceinorder_yes(16extern int iscsit_create_recovery_datain_values_datasequenceinorder_yes(
17 struct iscsi_cmd *, struct iscsi_datain_req *);17 struct iscsit_cmd *, struct iscsi_datain_req *);
18extern int iscsit_create_recovery_datain_values_datasequenceinorder_no(18extern int iscsit_create_recovery_datain_values_datasequenceinorder_no(
19 struct iscsi_cmd *, struct iscsi_datain_req *);19 struct iscsit_cmd *, struct iscsi_datain_req *);
20extern int iscsit_handle_recovery_datain_or_r2t(struct iscsi_conn *, unsigned char *,20extern int iscsit_handle_recovery_datain_or_r2t(struct iscsit_conn *, unsigned char *,
21 itt_t, u32, u32, u32);21 itt_t, u32, u32, u32);
22extern int iscsit_handle_status_snack(struct iscsi_conn *, itt_t, u32,22extern int iscsit_handle_status_snack(struct iscsit_conn *, itt_t, u32,
23 u32, u32);23 u32, u32);
24extern int iscsit_handle_data_ack(struct iscsi_conn *, u32, u32, u32);24extern int iscsit_handle_data_ack(struct iscsit_conn *, u32, u32, u32);
25extern int iscsit_dataout_datapduinorder_no_fbit(struct iscsi_cmd *, struct iscsi_pdu *);25extern int iscsit_dataout_datapduinorder_no_fbit(struct iscsit_cmd *, struct iscsi_pdu *);
26extern int iscsit_recover_dataout_sequence(struct iscsi_cmd *, u32, u32);26extern int iscsit_recover_dataout_sequence(struct iscsit_cmd *, u32, u32);
27extern void iscsit_clear_ooo_cmdsns_for_conn(struct iscsi_conn *);27extern void iscsit_clear_ooo_cmdsns_for_conn(struct iscsit_conn *);
28extern void iscsit_free_all_ooo_cmdsns(struct iscsi_session *);28extern void iscsit_free_all_ooo_cmdsns(struct iscsit_session *);
29extern int iscsit_execute_ooo_cmdsns(struct iscsi_session *);29extern int iscsit_execute_ooo_cmdsns(struct iscsit_session *);
30extern int iscsit_execute_cmd(struct iscsi_cmd *, int);30extern int iscsit_execute_cmd(struct iscsit_cmd *, int);
31extern int iscsit_handle_ooo_cmdsn(struct iscsi_session *, struct iscsi_cmd *, u32);31extern int iscsit_handle_ooo_cmdsn(struct iscsit_session *, struct iscsit_cmd *, u32);
32extern void iscsit_remove_ooo_cmdsn(struct iscsi_session *, struct iscsi_ooo_cmdsn *);32extern void iscsit_remove_ooo_cmdsn(struct iscsit_session *, struct iscsi_ooo_cmdsn *);
33extern void iscsit_handle_dataout_timeout(struct timer_list *t);33extern void iscsit_handle_dataout_timeout(struct timer_list *t);
34extern void iscsit_mod_dataout_timer(struct iscsi_cmd *);34extern void iscsit_mod_dataout_timer(struct iscsit_cmd *);
35extern void iscsit_start_dataout_timer(struct iscsi_cmd *, struct iscsi_conn *);35extern void iscsit_start_dataout_timer(struct iscsit_cmd *, struct iscsit_conn *);
36extern void iscsit_stop_dataout_timer(struct iscsi_cmd *);36extern void iscsit_stop_dataout_timer(struct iscsit_cmd *);
37 37
38#endif /* ISCSI_TARGET_ERL1_H */38#endif /* ISCSI_TARGET_ERL1_H */
drivers/target/iscsi/iscsi_target_erl2.c+24−24
@@ -26,11 +26,11 @@ · 25 unmodified lines
26 * FIXME: Does RData SNACK apply here as well?26 * FIXME: Does RData SNACK apply here as well?
27 */27 */
28void iscsit_create_conn_recovery_datain_values(28void iscsit_create_conn_recovery_datain_values(
29 struct iscsi_cmd *cmd,29 struct iscsit_cmd *cmd,
30 __be32 exp_data_sn)30 __be32 exp_data_sn)
31{31{
32 u32 data_sn = 0;32 u32 data_sn = 0;
33 struct iscsi_conn *conn = cmd->conn;33 struct iscsit_conn *conn = cmd->conn;
34 34
35 cmd->next_burst_len = 0;35 cmd->next_burst_len = 0;
36 cmd->read_data_done = 0;36 cmd->read_data_done = 0;
@@ -54,10 +54,10 @@ void iscsit_create_conn_recovery_datain_values( · 17 unmodified lines
54}54}
55 55
56void iscsit_create_conn_recovery_dataout_values(56void iscsit_create_conn_recovery_dataout_values(
57 struct iscsi_cmd *cmd)57 struct iscsit_cmd *cmd)
58{58{
59 u32 write_data_done = 0;59 u32 write_data_done = 0;
60 struct iscsi_conn *conn = cmd->conn;60 struct iscsit_conn *conn = cmd->conn;
61 61
62 cmd->data_sn = 0;62 cmd->data_sn = 0;
63 cmd->next_burst_len = 0;63 cmd->next_burst_len = 0;
@@ -74,7 +74,7 @@ void iscsit_create_conn_recovery_dataout_values( · 10 unmodified lines
74}74}
75 75
76static int iscsit_attach_active_connection_recovery_entry(76static int iscsit_attach_active_connection_recovery_entry(
77 struct iscsi_session *sess,77 struct iscsit_session *sess,
78 struct iscsi_conn_recovery *cr)78 struct iscsi_conn_recovery *cr)
79{79{
80 spin_lock(&sess->cr_a_lock);80 spin_lock(&sess->cr_a_lock);
@@ -85,7 +85,7 @@ static int iscsit_attach_active_connection_recovery_entry( · 4 unmodified lines
85}85}
86 86
87static int iscsit_attach_inactive_connection_recovery_entry(87static int iscsit_attach_inactive_connection_recovery_entry(
88 struct iscsi_session *sess,88 struct iscsit_session *sess,
89 struct iscsi_conn_recovery *cr)89 struct iscsi_conn_recovery *cr)
90{90{
91 spin_lock(&sess->cr_i_lock);91 spin_lock(&sess->cr_i_lock);
@@ -100,7 +100,7 @@ static int iscsit_attach_inactive_connection_recovery_entry( · 8 unmodified lines
100}100}
101 101
102struct iscsi_conn_recovery *iscsit_get_inactive_connection_recovery_entry(102struct iscsi_conn_recovery *iscsit_get_inactive_connection_recovery_entry(
103 struct iscsi_session *sess,103 struct iscsit_session *sess,
104 u16 cid)104 u16 cid)
105{105{
106 struct iscsi_conn_recovery *cr;106 struct iscsi_conn_recovery *cr;
@@ -117,9 +117,9 @@ struct iscsi_conn_recovery *iscsit_get_inactive_connection_recovery_entry( · 10 unmodified lines
117 return NULL;117 return NULL;
118}118}
119 119
120void iscsit_free_connection_recovery_entries(struct iscsi_session *sess)120void iscsit_free_connection_recovery_entries(struct iscsit_session *sess)
121{121{
122 struct iscsi_cmd *cmd, *cmd_tmp;122 struct iscsit_cmd *cmd, *cmd_tmp;
123 struct iscsi_conn_recovery *cr, *cr_tmp;123 struct iscsi_conn_recovery *cr, *cr_tmp;
124 124
125 spin_lock(&sess->cr_a_lock);125 spin_lock(&sess->cr_a_lock);
@@ -169,7 +169,7 @@ void iscsit_free_connection_recovery_entries(struct iscsi_session *sess) · 43 unmodified lines
169 169
170int iscsit_remove_active_connection_recovery_entry(170int iscsit_remove_active_connection_recovery_entry(
171 struct iscsi_conn_recovery *cr,171 struct iscsi_conn_recovery *cr,
172 struct iscsi_session *sess)172 struct iscsit_session *sess)
173{173{
174 spin_lock(&sess->cr_a_lock);174 spin_lock(&sess->cr_a_lock);
175 list_del(&cr->cr_list);175 list_del(&cr->cr_list);
@@ -186,7 +186,7 @@ int iscsit_remove_active_connection_recovery_entry( · 10 unmodified lines
186 186
187static void iscsit_remove_inactive_connection_recovery_entry(187static void iscsit_remove_inactive_connection_recovery_entry(
188 struct iscsi_conn_recovery *cr,188 struct iscsi_conn_recovery *cr,
189 struct iscsi_session *sess)189 struct iscsit_session *sess)
190{190{
191 spin_lock(&sess->cr_i_lock);191 spin_lock(&sess->cr_i_lock);
192 list_del(&cr->cr_list);192 list_del(&cr->cr_list);
@@ -197,8 +197,8 @@ static void iscsit_remove_inactive_connection_recovery_entry( · 4 unmodified lines
197 * Called with cr->conn_recovery_cmd_lock help.197 * Called with cr->conn_recovery_cmd_lock help.
198 */198 */
199int iscsit_remove_cmd_from_connection_recovery(199int iscsit_remove_cmd_from_connection_recovery(
200 struct iscsi_cmd *cmd,200 struct iscsit_cmd *cmd,
201 struct iscsi_session *sess)201 struct iscsit_session *sess)
202{202{
203 struct iscsi_conn_recovery *cr;203 struct iscsi_conn_recovery *cr;
204 204
@@ -218,8 +218,8 @@ void iscsit_discard_cr_cmds_by_expstatsn( · 13 unmodified lines
218 u32 exp_statsn)218 u32 exp_statsn)
219{219{
220 u32 dropped_count = 0;220 u32 dropped_count = 0;
221 struct iscsi_cmd *cmd, *cmd_tmp;221 struct iscsit_cmd *cmd, *cmd_tmp;
222 struct iscsi_session *sess = cr->sess;222 struct iscsit_session *sess = cr->sess;
223 223
224 spin_lock(&cr->conn_recovery_cmd_lock);224 spin_lock(&cr->conn_recovery_cmd_lock);
225 list_for_each_entry_safe(cmd, cmd_tmp,225 list_for_each_entry_safe(cmd, cmd_tmp,
@@ -263,12 +263,12 @@ void iscsit_discard_cr_cmds_by_expstatsn( · 37 unmodified lines
263 }263 }
264}264}
265 265
266int iscsit_discard_unacknowledged_ooo_cmdsns_for_conn(struct iscsi_conn *conn)266int iscsit_discard_unacknowledged_ooo_cmdsns_for_conn(struct iscsit_conn *conn)
267{267{
268 u32 dropped_count = 0;268 u32 dropped_count = 0;
269 struct iscsi_cmd *cmd, *cmd_tmp;269 struct iscsit_cmd *cmd, *cmd_tmp;
270 struct iscsi_ooo_cmdsn *ooo_cmdsn, *ooo_cmdsn_tmp;270 struct iscsi_ooo_cmdsn *ooo_cmdsn, *ooo_cmdsn_tmp;
271 struct iscsi_session *sess = conn->sess;271 struct iscsit_session *sess = conn->sess;
272 272
273 mutex_lock(&sess->cmdsn_mutex);273 mutex_lock(&sess->cmdsn_mutex);
274 list_for_each_entry_safe(ooo_cmdsn, ooo_cmdsn_tmp,274 list_for_each_entry_safe(ooo_cmdsn, ooo_cmdsn_tmp,
@@ -304,16 +304,16 @@ int iscsit_discard_unacknowledged_ooo_cmdsns_for_conn(struct iscsi_conn *conn) · 29 unmodified lines
304 return 0;304 return 0;
305}305}
306 306
307int iscsit_prepare_cmds_for_reallegiance(struct iscsi_conn *conn)307int iscsit_prepare_cmds_for_reallegiance(struct iscsit_conn *conn)
308{308{
309 u32 cmd_count = 0;309 u32 cmd_count = 0;
310 struct iscsi_cmd *cmd, *cmd_tmp;310 struct iscsit_cmd *cmd, *cmd_tmp;
311 struct iscsi_conn_recovery *cr;311 struct iscsi_conn_recovery *cr;
312 312
313 /*313 /*
314 * Allocate an struct iscsi_conn_recovery for this connection.314 * Allocate an struct iscsi_conn_recovery for this connection.
315 * Each struct iscsi_cmd contains an struct iscsi_conn_recovery pointer315 * Each struct iscsit_cmd contains an struct iscsi_conn_recovery pointer
316 * (struct iscsi_cmd->cr) so we need to allocate this before preparing the316 * (struct iscsit_cmd->cr) so we need to allocate this before preparing the
317 * connection's command list for connection recovery.317 * connection's command list for connection recovery.
318 */318 */
319 cr = kzalloc(sizeof(struct iscsi_conn_recovery), GFP_KERNEL);319 cr = kzalloc(sizeof(struct iscsi_conn_recovery), GFP_KERNEL);
@@ -393,7 +393,7 @@ int iscsit_prepare_cmds_for_reallegiance(struct iscsi_conn *conn) · 73 unmodified lines
393 393
394 transport_wait_for_tasks(&cmd->se_cmd);394 transport_wait_for_tasks(&cmd->se_cmd);
395 /*395 /*
396 * Add the struct iscsi_cmd to the connection recovery cmd list396 * Add the struct iscsit_cmd to the connection recovery cmd list
397 */397 */
398 spin_lock(&cr->conn_recovery_cmd_lock);398 spin_lock(&cr->conn_recovery_cmd_lock);
399 list_add_tail(&cmd->i_conn_node, &cr->conn_recovery_cmd_list);399 list_add_tail(&cmd->i_conn_node, &cr->conn_recovery_cmd_list);
@@ -418,7 +418,7 @@ int iscsit_prepare_cmds_for_reallegiance(struct iscsi_conn *conn) · 18 unmodified lines
418 return 0;418 return 0;
419}419}
420 420
421int iscsit_connection_recovery_transport_reset(struct iscsi_conn *conn)421int iscsit_connection_recovery_transport_reset(struct iscsit_conn *conn)
422{422{
423 atomic_set(&conn->connection_recovery, 1);423 atomic_set(&conn->connection_recovery, 1);
424 424
drivers/target/iscsi/iscsi_target_erl2.h+13−13
@@ -4,23 +4,23 @@ · 3 unmodified lines
4 4
5#include <linux/types.h>5#include <linux/types.h>
6 6
7struct iscsi_cmd;7struct iscsit_cmd;
8struct iscsi_conn;8struct iscsit_conn;
9struct iscsi_conn_recovery;9struct iscsi_conn_recovery;
10struct iscsi_session;10struct iscsit_session;
11 11
12extern void iscsit_create_conn_recovery_datain_values(struct iscsi_cmd *, __be32);12extern void iscsit_create_conn_recovery_datain_values(struct iscsit_cmd *, __be32);
13extern void iscsit_create_conn_recovery_dataout_values(struct iscsi_cmd *);13extern void iscsit_create_conn_recovery_dataout_values(struct iscsit_cmd *);
14extern struct iscsi_conn_recovery *iscsit_get_inactive_connection_recovery_entry(14extern struct iscsi_conn_recovery *iscsit_get_inactive_connection_recovery_entry(
15 struct iscsi_session *, u16);15 struct iscsit_session *, u16);
16extern void iscsit_free_connection_recovery_entries(struct iscsi_session *);16extern void iscsit_free_connection_recovery_entries(struct iscsit_session *);
17extern int iscsit_remove_active_connection_recovery_entry(17extern int iscsit_remove_active_connection_recovery_entry(
18 struct iscsi_conn_recovery *, struct iscsi_session *);18 struct iscsi_conn_recovery *, struct iscsit_session *);
19extern int iscsit_remove_cmd_from_connection_recovery(struct iscsi_cmd *,19extern int iscsit_remove_cmd_from_connection_recovery(struct iscsit_cmd *,
20 struct iscsi_session *);20 struct iscsit_session *);
21extern void iscsit_discard_cr_cmds_by_expstatsn(struct iscsi_conn_recovery *, u32);21extern void iscsit_discard_cr_cmds_by_expstatsn(struct iscsi_conn_recovery *, u32);
22extern int iscsit_discard_unacknowledged_ooo_cmdsns_for_conn(struct iscsi_conn *);22extern int iscsit_discard_unacknowledged_ooo_cmdsns_for_conn(struct iscsit_conn *);
23extern int iscsit_prepare_cmds_for_reallegiance(struct iscsi_conn *);23extern int iscsit_prepare_cmds_for_reallegiance(struct iscsit_conn *);
24extern int iscsit_connection_recovery_transport_reset(struct iscsi_conn *);24extern int iscsit_connection_recovery_transport_reset(struct iscsit_conn *);
25 25
26#endif /*** ISCSI_TARGET_ERL2_H ***/26#endif /*** ISCSI_TARGET_ERL2_H ***/
drivers/target/iscsi/iscsi_target_login.c+39−39
@@ -35,7 +35,7 @@ · 34 unmodified lines
35 35
36#include <target/iscsi/iscsi_transport.h>36#include <target/iscsi/iscsi_transport.h>
37 37
38static struct iscsi_login *iscsi_login_init_conn(struct iscsi_conn *conn)38static struct iscsi_login *iscsi_login_init_conn(struct iscsit_conn *conn)
39{39{
40 struct iscsi_login *login;40 struct iscsi_login *login;
41 41
@@ -73,9 +73,9 @@ out_login: · 31 unmodified lines
73 73
74/*74/*
75 * Used by iscsi_target_nego.c:iscsi_target_locate_portal() to setup75 * Used by iscsi_target_nego.c:iscsi_target_locate_portal() to setup
76 * per struct iscsi_conn libcrypto contexts for crc32c and crc32-intel76 * per struct iscsit_conn libcrypto contexts for crc32c and crc32-intel
77 */77 */
78int iscsi_login_setup_crypto(struct iscsi_conn *conn)78int iscsi_login_setup_crypto(struct iscsit_conn *conn)
79{79{
80 struct crypto_ahash *tfm;80 struct crypto_ahash *tfm;
81 81
@@ -112,7 +112,7 @@ int iscsi_login_setup_crypto(struct iscsi_conn *conn) · 30 unmodified lines
112}112}
113 113
114static int iscsi_login_check_initiator_version(114static int iscsi_login_check_initiator_version(
115 struct iscsi_conn *conn,115 struct iscsit_conn *conn,
116 u8 version_max,116 u8 version_max,
117 u8 version_min)117 u8 version_min)
118{118{
@@ -128,12 +128,12 @@ static int iscsi_login_check_initiator_version( · 9 unmodified lines
128 return 0;128 return 0;
129}129}
130 130
131int iscsi_check_for_session_reinstatement(struct iscsi_conn *conn)131int iscsi_check_for_session_reinstatement(struct iscsit_conn *conn)
132{132{
133 int sessiontype;133 int sessiontype;
134 struct iscsi_param *initiatorname_param = NULL, *sessiontype_param = NULL;134 struct iscsi_param *initiatorname_param = NULL, *sessiontype_param = NULL;
135 struct iscsi_portal_group *tpg = conn->tpg;135 struct iscsi_portal_group *tpg = conn->tpg;
136 struct iscsi_session *sess = NULL, *sess_p = NULL;136 struct iscsit_session *sess = NULL, *sess_p = NULL;
137 struct se_portal_group *se_tpg = &tpg->tpg_se_tpg;137 struct se_portal_group *se_tpg = &tpg->tpg_se_tpg;
138 struct se_session *se_sess, *se_sess_tmp;138 struct se_session *se_sess, *se_sess_tmp;
139 139
@@ -204,8 +204,8 @@ int iscsi_check_for_session_reinstatement(struct iscsi_conn *conn) · 64 unmodified lines
204}204}
205 205
206static int iscsi_login_set_conn_values(206static int iscsi_login_set_conn_values(
207 struct iscsi_session *sess,207 struct iscsit_session *sess,
208 struct iscsi_conn *conn,208 struct iscsit_conn *conn,
209 __be16 cid)209 __be16 cid)
210{210{
211 int ret;211 int ret;
@@ -226,7 +226,7 @@ static int iscsi_login_set_conn_values( · 14 unmodified lines
226}226}
227 227
228__printf(2, 3) int iscsi_change_param_sprintf(228__printf(2, 3) int iscsi_change_param_sprintf(
229 struct iscsi_conn *conn,229 struct iscsit_conn *conn,
230 const char *fmt, ...)230 const char *fmt, ...)
231{231{
232 va_list args;232 va_list args;
@@ -253,14 +253,14 @@ EXPORT_SYMBOL(iscsi_change_param_sprintf); · 20 unmodified lines
253 * or session reinstatement.253 * or session reinstatement.
254 */254 */
255static int iscsi_login_zero_tsih_s1(255static int iscsi_login_zero_tsih_s1(
256 struct iscsi_conn *conn,256 struct iscsit_conn *conn,
257 unsigned char *buf)257 unsigned char *buf)
258{258{
259 struct iscsi_session *sess = NULL;259 struct iscsit_session *sess = NULL;
260 struct iscsi_login_req *pdu = (struct iscsi_login_req *)buf;260 struct iscsi_login_req *pdu = (struct iscsi_login_req *)buf;
261 int ret;261 int ret;
262 262
263 sess = kzalloc(sizeof(struct iscsi_session), GFP_KERNEL);263 sess = kzalloc(sizeof(struct iscsit_session), GFP_KERNEL);
264 if (!sess) {264 if (!sess) {
265 iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_TARGET_ERR,265 iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_TARGET_ERR,
266 ISCSI_LOGIN_STATUS_NO_RESOURCES);266 ISCSI_LOGIN_STATUS_NO_RESOURCES);
@@ -337,10 +337,10 @@ free_sess: · 70 unmodified lines
337}337}
338 338
339static int iscsi_login_zero_tsih_s2(339static int iscsi_login_zero_tsih_s2(
340 struct iscsi_conn *conn)340 struct iscsit_conn *conn)
341{341{
342 struct iscsi_node_attrib *na;342 struct iscsi_node_attrib *na;
343 struct iscsi_session *sess = conn->sess;343 struct iscsit_session *sess = conn->sess;
344 bool iser = false;344 bool iser = false;
345 345
346 sess->tpg = conn->tpg;346 sess->tpg = conn->tpg;
@@ -458,7 +458,7 @@ check_prot: · 111 unmodified lines
458}458}
459 459
460static int iscsi_login_non_zero_tsih_s1(460static int iscsi_login_non_zero_tsih_s1(
461 struct iscsi_conn *conn,461 struct iscsit_conn *conn,
462 unsigned char *buf)462 unsigned char *buf)
463{463{
464 struct iscsi_login_req *pdu = (struct iscsi_login_req *)buf;464 struct iscsi_login_req *pdu = (struct iscsi_login_req *)buf;
@@ -470,11 +470,11 @@ static int iscsi_login_non_zero_tsih_s1( · 5 unmodified lines
470 * Add a new connection to an existing session.470 * Add a new connection to an existing session.
471 */471 */
472static int iscsi_login_non_zero_tsih_s2(472static int iscsi_login_non_zero_tsih_s2(
473 struct iscsi_conn *conn,473 struct iscsit_conn *conn,
474 unsigned char *buf)474 unsigned char *buf)
475{475{
476 struct iscsi_portal_group *tpg = conn->tpg;476 struct iscsi_portal_group *tpg = conn->tpg;
477 struct iscsi_session *sess = NULL, *sess_p = NULL;477 struct iscsit_session *sess = NULL, *sess_p = NULL;
478 struct se_portal_group *se_tpg = &tpg->tpg_se_tpg;478 struct se_portal_group *se_tpg = &tpg->tpg_se_tpg;
479 struct se_session *se_sess, *se_sess_tmp;479 struct se_session *se_sess, *se_sess_tmp;
480 struct iscsi_login_req *pdu = (struct iscsi_login_req *)buf;480 struct iscsi_login_req *pdu = (struct iscsi_login_req *)buf;
@@ -484,7 +484,7 @@ static int iscsi_login_non_zero_tsih_s2( · 3 unmodified lines
484 list_for_each_entry_safe(se_sess, se_sess_tmp, &se_tpg->tpg_sess_list,484 list_for_each_entry_safe(se_sess, se_sess_tmp, &se_tpg->tpg_sess_list,
485 sess_list) {485 sess_list) {
486 486
487 sess_p = (struct iscsi_session *)se_sess->fabric_sess_ptr;487 sess_p = (struct iscsit_session *)se_sess->fabric_sess_ptr;
488 if (atomic_read(&sess_p->session_fall_back_to_erl0) ||488 if (atomic_read(&sess_p->session_fall_back_to_erl0) ||
489 atomic_read(&sess_p->session_logout) ||489 atomic_read(&sess_p->session_logout) ||
490 atomic_read(&sess_p->session_close) ||490 atomic_read(&sess_p->session_close) ||
@@ -546,13 +546,13 @@ static int iscsi_login_non_zero_tsih_s2( · 55 unmodified lines
546}546}
547 547
548int iscsi_login_post_auth_non_zero_tsih(548int iscsi_login_post_auth_non_zero_tsih(
549 struct iscsi_conn *conn,549 struct iscsit_conn *conn,
550 u16 cid,550 u16 cid,
551 u32 exp_statsn)551 u32 exp_statsn)
552{552{
553 struct iscsi_conn *conn_ptr = NULL;553 struct iscsit_conn *conn_ptr = NULL;
554 struct iscsi_conn_recovery *cr = NULL;554 struct iscsi_conn_recovery *cr = NULL;
555 struct iscsi_session *sess = conn->sess;555 struct iscsit_session *sess = conn->sess;
556 556
557 /*557 /*
558 * By following item 5 in the login table, if we have found558 * By following item 5 in the login table, if we have found
@@ -612,9 +612,9 @@ int iscsi_login_post_auth_non_zero_tsih( · 53 unmodified lines
612 return 0;612 return 0;
613}613}
614 614
615static void iscsi_post_login_start_timers(struct iscsi_conn *conn)615static void iscsi_post_login_start_timers(struct iscsit_conn *conn)
616{616{
617 struct iscsi_session *sess = conn->sess;617 struct iscsit_session *sess = conn->sess;
618 /*618 /*
619 * FIXME: Unsolicited NopIN support for ISER619 * FIXME: Unsolicited NopIN support for ISER
620 */620 */
@@ -625,7 +625,7 @@ static void iscsi_post_login_start_timers(struct iscsi_conn *conn) · 4 unmodified lines
625 iscsit_start_nopin_timer(conn);625 iscsit_start_nopin_timer(conn);
626}626}
627 627
628int iscsit_start_kthreads(struct iscsi_conn *conn)628int iscsit_start_kthreads(struct iscsit_conn *conn)
629{629{
630 int ret = 0;630 int ret = 0;
631 631
@@ -673,11 +673,11 @@ out_bitmap: · 41 unmodified lines
673 673
674void iscsi_post_login_handler(674void iscsi_post_login_handler(
675 struct iscsi_np *np,675 struct iscsi_np *np,
676 struct iscsi_conn *conn,676 struct iscsit_conn *conn,
677 u8 zero_tsih)677 u8 zero_tsih)
678{678{
679 int stop_timer = 0;679 int stop_timer = 0;
680 struct iscsi_session *sess = conn->sess;680 struct iscsit_session *sess = conn->sess;
681 struct se_session *se_sess = sess->se_sess;681 struct se_session *se_sess = sess->se_sess;
682 struct iscsi_portal_group *tpg = sess->tpg;682 struct iscsi_portal_group *tpg = sess->tpg;
683 struct se_portal_group *se_tpg = &tpg->tpg_se_tpg;683 struct se_portal_group *se_tpg = &tpg->tpg_se_tpg;
@@ -730,7 +730,7 @@ void iscsi_post_login_handler( · 46 unmodified lines
730 conn->conn_tx_reset_cpumask = 1;730 conn->conn_tx_reset_cpumask = 1;
731 /*731 /*
732 * Wakeup the sleeping iscsi_target_rx_thread() now that732 * Wakeup the sleeping iscsi_target_rx_thread() now that
733 * iscsi_conn is in TARG_CONN_STATE_LOGGED_IN state.733 * iscsit_conn is in TARG_CONN_STATE_LOGGED_IN state.
734 */734 */
735 complete(&conn->rx_login_comp);735 complete(&conn->rx_login_comp);
736 iscsit_dec_conn_usage_count(conn);736 iscsit_dec_conn_usage_count(conn);
@@ -792,7 +792,7 @@ void iscsi_post_login_handler( · 55 unmodified lines
792 conn->conn_tx_reset_cpumask = 1;792 conn->conn_tx_reset_cpumask = 1;
793 /*793 /*
794 * Wakeup the sleeping iscsi_target_rx_thread() now that794 * Wakeup the sleeping iscsi_target_rx_thread() now that
795 * iscsi_conn is in TARG_CONN_STATE_LOGGED_IN state.795 * iscsit_conn is in TARG_CONN_STATE_LOGGED_IN state.
796 */796 */
797 complete(&conn->rx_login_comp);797 complete(&conn->rx_login_comp);
798 iscsit_dec_conn_usage_count(conn);798 iscsit_dec_conn_usage_count(conn);
@@ -944,7 +944,7 @@ int iscsi_target_setup_login_socket( · 145 unmodified lines
944 return 0;944 return 0;
945}945}
946 946
947int iscsit_accept_np(struct iscsi_np *np, struct iscsi_conn *conn)947int iscsit_accept_np(struct iscsi_np *np, struct iscsit_conn *conn)
948{948{
949 struct socket *new_sock, *sock = np->np_socket;949 struct socket *new_sock, *sock = np->np_socket;
950 struct sockaddr_in sock_in;950 struct sockaddr_in sock_in;
@@ -1005,7 +1005,7 @@ int iscsit_accept_np(struct iscsi_np *np, struct iscsi_conn *conn) · 54 unmodified lines
1005 return 0;1005 return 0;
1006}1006}
1007 1007
1008int iscsit_get_login_rx(struct iscsi_conn *conn, struct iscsi_login *login)1008int iscsit_get_login_rx(struct iscsit_conn *conn, struct iscsi_login *login)
1009{1009{
1010 struct iscsi_login_req *login_req;1010 struct iscsi_login_req *login_req;
1011 u32 padding = 0, payload_length;1011 u32 padding = 0, payload_length;
@@ -1050,7 +1050,7 @@ int iscsit_get_login_rx(struct iscsi_conn *conn, struct iscsi_login *login) · 38 unmodified lines
1050 return 0;1050 return 0;
1051}1051}
1052 1052
1053int iscsit_put_login_tx(struct iscsi_conn *conn, struct iscsi_login *login,1053int iscsit_put_login_tx(struct iscsit_conn *conn, struct iscsi_login *login,
1054 u32 length)1054 u32 length)
1055{1055{
1056 if (iscsi_login_tx_data(conn, login->rsp, login->rsp_buf, length) < 0)1056 if (iscsi_login_tx_data(conn, login->rsp, login->rsp_buf, length) < 0)
@@ -1060,7 +1060,7 @@ int iscsit_put_login_tx(struct iscsi_conn *conn, struct iscsi_login *login, · 3 unmodified lines
1060}1060}
1061 1061
1062static int1062static int
1063iscsit_conn_set_transport(struct iscsi_conn *conn, struct iscsit_transport *t)1063iscsit_conn_set_transport(struct iscsit_conn *conn, struct iscsit_transport *t)
1064{1064{
1065 int rc;1065 int rc;
1066 1066
@@ -1079,11 +1079,11 @@ iscsit_conn_set_transport(struct iscsi_conn *conn, struct iscsit_transport *t) · 12 unmodified lines
1079 return 0;1079 return 0;
1080}1080}
1081 1081
1082static struct iscsi_conn *iscsit_alloc_conn(struct iscsi_np *np)1082static struct iscsit_conn *iscsit_alloc_conn(struct iscsi_np *np)
1083{1083{
1084 struct iscsi_conn *conn;1084 struct iscsit_conn *conn;
1085 1085
1086 conn = kzalloc(sizeof(struct iscsi_conn), GFP_KERNEL);1086 conn = kzalloc(sizeof(struct iscsit_conn), GFP_KERNEL);
1087 if (!conn) {1087 if (!conn) {
1088 pr_err("Could not allocate memory for new connection\n");1088 pr_err("Could not allocate memory for new connection\n");
1089 return NULL;1089 return NULL;
@@ -1147,7 +1147,7 @@ free_conn: · 57 unmodified lines
1147 return NULL;1147 return NULL;
1148}1148}
1149 1149
1150void iscsit_free_conn(struct iscsi_conn *conn)1150void iscsit_free_conn(struct iscsit_conn *conn)
1151{1151{
1152 free_cpumask_var(conn->allowed_cpumask);1152 free_cpumask_var(conn->allowed_cpumask);
1153 free_cpumask_var(conn->conn_cpumask);1153 free_cpumask_var(conn->conn_cpumask);
@@ -1156,7 +1156,7 @@ void iscsit_free_conn(struct iscsi_conn *conn) · 2 unmodified lines
1156 kfree(conn);1156 kfree(conn);
1157}1157}
1158 1158
1159void iscsi_target_login_sess_out(struct iscsi_conn *conn,1159void iscsi_target_login_sess_out(struct iscsit_conn *conn,
1160 bool zero_tsih, bool new_sess)1160 bool zero_tsih, bool new_sess)
1161{1161{
1162 if (!new_sess)1162 if (!new_sess)
@@ -1228,7 +1228,7 @@ static int __iscsi_target_login_thread(struct iscsi_np *np) · 65 unmodified lines
1228{1228{
1229 u8 *buffer, zero_tsih = 0;1229 u8 *buffer, zero_tsih = 0;
1230 int ret = 0, rc;1230 int ret = 0, rc;
1231 struct iscsi_conn *conn = NULL;1231 struct iscsit_conn *conn = NULL;
1232 struct iscsi_login *login;1232 struct iscsi_login *login;
1233 struct iscsi_portal_group *tpg = NULL;1233 struct iscsi_portal_group *tpg = NULL;
1234 struct iscsi_login_req *pdu;1234 struct iscsi_login_req *pdu;
@@ -1371,7 +1371,7 @@ static int __iscsi_target_login_thread(struct iscsi_np *np) · 136 unmodified lines
1371 1371
1372 tpg = conn->tpg;1372 tpg = conn->tpg;
1373 if (!tpg) {1373 if (!tpg) {
1374 pr_err("Unable to locate struct iscsi_conn->tpg\n");1374 pr_err("Unable to locate struct iscsit_conn->tpg\n");
1375 goto new_sess_out;1375 goto new_sess_out;
1376 }1376 }
1377 1377
drivers/target/iscsi/iscsi_target_login.h+11−11
@@ -4,25 +4,25 @@ · 3 unmodified lines
4 4
5#include <linux/types.h>5#include <linux/types.h>
6 6
7struct iscsi_conn;7struct iscsit_conn;
8struct iscsi_login;8struct iscsi_login;
9struct iscsi_np;9struct iscsi_np;
10struct sockaddr_storage;10struct sockaddr_storage;
11 11
12extern int iscsi_login_setup_crypto(struct iscsi_conn *);12extern int iscsi_login_setup_crypto(struct iscsit_conn *);
13extern int iscsi_check_for_session_reinstatement(struct iscsi_conn *);13extern int iscsi_check_for_session_reinstatement(struct iscsit_conn *);
14extern int iscsi_login_post_auth_non_zero_tsih(struct iscsi_conn *, u16, u32);14extern int iscsi_login_post_auth_non_zero_tsih(struct iscsit_conn *, u16, u32);
15extern int iscsit_setup_np(struct iscsi_np *,15extern int iscsit_setup_np(struct iscsi_np *,
16 struct sockaddr_storage *);16 struct sockaddr_storage *);
17extern int iscsi_target_setup_login_socket(struct iscsi_np *,17extern int iscsi_target_setup_login_socket(struct iscsi_np *,
18 struct sockaddr_storage *);18 struct sockaddr_storage *);
19extern int iscsit_accept_np(struct iscsi_np *, struct iscsi_conn *);19extern int iscsit_accept_np(struct iscsi_np *, struct iscsit_conn *);
20extern int iscsit_get_login_rx(struct iscsi_conn *, struct iscsi_login *);20extern int iscsit_get_login_rx(struct iscsit_conn *, struct iscsi_login *);
21extern int iscsit_put_login_tx(struct iscsi_conn *, struct iscsi_login *, u32);21extern int iscsit_put_login_tx(struct iscsit_conn *, struct iscsi_login *, u32);
22extern void iscsit_free_conn(struct iscsi_conn *);22extern void iscsit_free_conn(struct iscsit_conn *);
23extern int iscsit_start_kthreads(struct iscsi_conn *);23extern int iscsit_start_kthreads(struct iscsit_conn *);
24extern void iscsi_post_login_handler(struct iscsi_np *, struct iscsi_conn *, u8);24extern void iscsi_post_login_handler(struct iscsi_np *, struct iscsit_conn *, u8);
25extern void iscsi_target_login_sess_out(struct iscsi_conn *, bool, bool);25extern void iscsi_target_login_sess_out(struct iscsit_conn *, bool, bool);
26extern int iscsi_target_login_thread(void *);26extern int iscsi_target_login_thread(void *);
27extern void iscsi_handle_login_thread_timeout(struct timer_list *t);27extern void iscsi_handle_login_thread_timeout(struct timer_list *t);
28 28
drivers/target/iscsi/iscsi_target_nego.c+30−30
@@ -95,14 +95,14 @@ int extract_param( · 94 unmodified lines
95}95}
96 96
97static u32 iscsi_handle_authentication(97static u32 iscsi_handle_authentication(
98 struct iscsi_conn *conn,98 struct iscsit_conn *conn,
99 char *in_buf,99 char *in_buf,
100 char *out_buf,100 char *out_buf,
101 int in_length,101 int in_length,
102 int *out_length,102 int *out_length,
103 unsigned char *authtype)103 unsigned char *authtype)
104{104{
105 struct iscsi_session *sess = conn->sess;105 struct iscsit_session *sess = conn->sess;
106 struct iscsi_node_auth *auth;106 struct iscsi_node_auth *auth;
107 struct iscsi_node_acl *iscsi_nacl;107 struct iscsi_node_acl *iscsi_nacl;
108 struct iscsi_portal_group *iscsi_tpg;108 struct iscsi_portal_group *iscsi_tpg;
@@ -151,13 +151,13 @@ static u32 iscsi_handle_authentication( · 42 unmodified lines
151 return 2;151 return 2;
152}152}
153 153
154static void iscsi_remove_failed_auth_entry(struct iscsi_conn *conn)154static void iscsi_remove_failed_auth_entry(struct iscsit_conn *conn)
155{155{
156 kfree(conn->auth_protocol);156 kfree(conn->auth_protocol);
157}157}
158 158
159int iscsi_target_check_login_request(159int iscsi_target_check_login_request(
160 struct iscsi_conn *conn,160 struct iscsit_conn *conn,
161 struct iscsi_login *login)161 struct iscsi_login *login)
162{162{
163 int req_csg, req_nsg;163 int req_csg, req_nsg;
@@ -248,7 +248,7 @@ int iscsi_target_check_login_request( · 84 unmodified lines
248EXPORT_SYMBOL(iscsi_target_check_login_request);248EXPORT_SYMBOL(iscsi_target_check_login_request);
249 249
250static int iscsi_target_check_first_request(250static int iscsi_target_check_first_request(
251 struct iscsi_conn *conn,251 struct iscsit_conn *conn,
252 struct iscsi_login *login)252 struct iscsi_login *login)
253{253{
254 struct iscsi_param *param = NULL;254 struct iscsi_param *param = NULL;
@@ -315,7 +315,7 @@ static int iscsi_target_check_first_request( · 60 unmodified lines
315 return 0;315 return 0;
316}316}
317 317
318static int iscsi_target_do_tx_login_io(struct iscsi_conn *conn, struct iscsi_login *login)318static int iscsi_target_do_tx_login_io(struct iscsit_conn *conn, struct iscsi_login *login)
319{319{
320 u32 padding = 0;320 u32 padding = 0;
321 struct iscsi_login_rsp *login_rsp;321 struct iscsi_login_rsp *login_rsp;
@@ -382,7 +382,7 @@ err: · 60 unmodified lines
382 382
383static void iscsi_target_sk_data_ready(struct sock *sk)383static void iscsi_target_sk_data_ready(struct sock *sk)
384{384{
385 struct iscsi_conn *conn = sk->sk_user_data;385 struct iscsit_conn *conn = sk->sk_user_data;
386 bool rc;386 bool rc;
387 387
388 pr_debug("Entering iscsi_target_sk_data_ready: conn: %p\n", conn);388 pr_debug("Entering iscsi_target_sk_data_ready: conn: %p\n", conn);
@@ -421,7 +421,7 @@ static void iscsi_target_sk_data_ready(struct sock *sk) · 32 unmodified lines
421 421
422static void iscsi_target_sk_state_change(struct sock *);422static void iscsi_target_sk_state_change(struct sock *);
423 423
424static void iscsi_target_set_sock_callbacks(struct iscsi_conn *conn)424static void iscsi_target_set_sock_callbacks(struct iscsit_conn *conn)
425{425{
426 struct sock *sk;426 struct sock *sk;
427 427
@@ -443,7 +443,7 @@ static void iscsi_target_set_sock_callbacks(struct iscsi_conn *conn) · 15 unmodified lines
443 sk->sk_rcvtimeo = TA_LOGIN_TIMEOUT * HZ;443 sk->sk_rcvtimeo = TA_LOGIN_TIMEOUT * HZ;
444}444}
445 445
446static void iscsi_target_restore_sock_callbacks(struct iscsi_conn *conn)446static void iscsi_target_restore_sock_callbacks(struct iscsit_conn *conn)
447{447{
448 struct sock *sk;448 struct sock *sk;
449 449
@@ -467,7 +467,7 @@ static void iscsi_target_restore_sock_callbacks(struct iscsi_conn *conn) · 17 unmodified lines
467 sk->sk_rcvtimeo = MAX_SCHEDULE_TIMEOUT;467 sk->sk_rcvtimeo = MAX_SCHEDULE_TIMEOUT;
468}468}
469 469
470static int iscsi_target_do_login(struct iscsi_conn *, struct iscsi_login *);470static int iscsi_target_do_login(struct iscsit_conn *, struct iscsi_login *);
471 471
472static bool __iscsi_target_sk_check_close(struct sock *sk)472static bool __iscsi_target_sk_check_close(struct sock *sk)
473{473{
@@ -479,7 +479,7 @@ static bool __iscsi_target_sk_check_close(struct sock *sk) · 5 unmodified lines
479 return false;479 return false;
480}480}
481 481
482static bool iscsi_target_sk_check_close(struct iscsi_conn *conn)482static bool iscsi_target_sk_check_close(struct iscsit_conn *conn)
483{483{
484 bool state = false;484 bool state = false;
485 485
@@ -494,7 +494,7 @@ static bool iscsi_target_sk_check_close(struct iscsi_conn *conn) · 8 unmodified lines
494 return state;494 return state;
495}495}
496 496
497static bool iscsi_target_sk_check_flag(struct iscsi_conn *conn, unsigned int flag)497static bool iscsi_target_sk_check_flag(struct iscsit_conn *conn, unsigned int flag)
498{498{
499 bool state = false;499 bool state = false;
500 500
@@ -508,7 +508,7 @@ static bool iscsi_target_sk_check_flag(struct iscsi_conn *conn, unsigned int fla · 7 unmodified lines
508 return state;508 return state;
509}509}
510 510
511static bool iscsi_target_sk_check_and_clear(struct iscsi_conn *conn, unsigned int flag)511static bool iscsi_target_sk_check_and_clear(struct iscsit_conn *conn, unsigned int flag)
512{512{
513 bool state = false;513 bool state = false;
514 514
@@ -525,7 +525,7 @@ static bool iscsi_target_sk_check_and_clear(struct iscsi_conn *conn, unsigned in · 10 unmodified lines
525 return state;525 return state;
526}526}
527 527
528static void iscsi_target_login_drop(struct iscsi_conn *conn, struct iscsi_login *login)528static void iscsi_target_login_drop(struct iscsit_conn *conn, struct iscsi_login *login)
529{529{
530 bool zero_tsih = login->zero_tsih;530 bool zero_tsih = login->zero_tsih;
531 531
@@ -536,13 +536,13 @@ static void iscsi_target_login_drop(struct iscsi_conn *conn, struct iscsi_login · 4 unmodified lines
536 536
537struct conn_timeout {537struct conn_timeout {
538 struct timer_list timer;538 struct timer_list timer;
539 struct iscsi_conn *conn;539 struct iscsit_conn *conn;
540};540};
541 541
542static void iscsi_target_login_timeout(struct timer_list *t)542static void iscsi_target_login_timeout(struct timer_list *t)
543{543{
544 struct conn_timeout *timeout = from_timer(timeout, t, timer);544 struct conn_timeout *timeout = from_timer(timeout, t, timer);
545 struct iscsi_conn *conn = timeout->conn;545 struct iscsit_conn *conn = timeout->conn;
546 546
547 pr_debug("Entering iscsi_target_login_timeout >>>>>>>>>>>>>>>>>>>\n");547 pr_debug("Entering iscsi_target_login_timeout >>>>>>>>>>>>>>>>>>>\n");
548 548
@@ -555,8 +555,8 @@ static void iscsi_target_login_timeout(struct timer_list *t) · 6 unmodified lines
555 555
556static void iscsi_target_do_login_rx(struct work_struct *work)556static void iscsi_target_do_login_rx(struct work_struct *work)
557{557{
558 struct iscsi_conn *conn = container_of(work,558 struct iscsit_conn *conn = container_of(work,
559 struct iscsi_conn, login_work.work);559 struct iscsit_conn, login_work.work);
560 struct iscsi_login *login = conn->login;560 struct iscsi_login *login = conn->login;
561 struct iscsi_np *np = login->np;561 struct iscsi_np *np = login->np;
562 struct iscsi_portal_group *tpg = conn->tpg;562 struct iscsi_portal_group *tpg = conn->tpg;
@@ -662,7 +662,7 @@ err: · 99 unmodified lines
662 662
663static void iscsi_target_sk_state_change(struct sock *sk)663static void iscsi_target_sk_state_change(struct sock *sk)
664{664{
665 struct iscsi_conn *conn;665 struct iscsit_conn *conn;
666 void (*orig_state_change)(struct sock *);666 void (*orig_state_change)(struct sock *);
667 bool state;667 bool state;
668 668
@@ -741,7 +741,7 @@ static void iscsi_target_sk_state_change(struct sock *sk) · 72 unmodified lines
741 * ISID/TSIH combinations.741 * ISID/TSIH combinations.
742 */742 */
743static int iscsi_target_check_for_existing_instances(743static int iscsi_target_check_for_existing_instances(
744 struct iscsi_conn *conn,744 struct iscsit_conn *conn,
745 struct iscsi_login *login)745 struct iscsi_login *login)
746{746{
747 if (login->checked_for_existing)747 if (login->checked_for_existing)
@@ -757,7 +757,7 @@ static int iscsi_target_check_for_existing_instances( · 9 unmodified lines
757}757}
758 758
759static int iscsi_target_do_authentication(759static int iscsi_target_do_authentication(
760 struct iscsi_conn *conn,760 struct iscsit_conn *conn,
761 struct iscsi_login *login)761 struct iscsi_login *login)
762{762{
763 int authret;763 int authret;
@@ -816,7 +816,7 @@ static int iscsi_target_do_authentication( · 52 unmodified lines
816}816}
817 817
818static int iscsi_target_handle_csg_zero(818static int iscsi_target_handle_csg_zero(
819 struct iscsi_conn *conn,819 struct iscsit_conn *conn,
820 struct iscsi_login *login)820 struct iscsi_login *login)
821{821{
822 int ret;822 int ret;
@@ -906,7 +906,7 @@ do_auth: · 83 unmodified lines
906 return iscsi_target_do_authentication(conn, login);906 return iscsi_target_do_authentication(conn, login);
907}907}
908 908
909static int iscsi_target_handle_csg_one(struct iscsi_conn *conn, struct iscsi_login *login)909static int iscsi_target_handle_csg_one(struct iscsit_conn *conn, struct iscsi_login *login)
910{910{
911 int ret;911 int ret;
912 u32 payload_length;912 u32 payload_length;
@@ -968,7 +968,7 @@ static int iscsi_target_handle_csg_one(struct iscsi_conn *conn, struct iscsi_log · 55 unmodified lines
968 return 0;968 return 0;
969}969}
970 970
971static int iscsi_target_do_login(struct iscsi_conn *conn, struct iscsi_login *login)971static int iscsi_target_do_login(struct iscsit_conn *conn, struct iscsi_login *login)
972{972{
973 int pdu_count = 0;973 int pdu_count = 0;
974 struct iscsi_login_req *login_req;974 struct iscsi_login_req *login_req;
@@ -1054,12 +1054,12 @@ static void iscsi_initiatorname_tolower( · 79 unmodified lines
1054 */1054 */
1055int iscsi_target_locate_portal(1055int iscsi_target_locate_portal(
1056 struct iscsi_np *np,1056 struct iscsi_np *np,
1057 struct iscsi_conn *conn,1057 struct iscsit_conn *conn,
1058 struct iscsi_login *login)1058 struct iscsi_login *login)
1059{1059{
1060 char *i_buf = NULL, *s_buf = NULL, *t_buf = NULL;1060 char *i_buf = NULL, *s_buf = NULL, *t_buf = NULL;
1061 char *tmpbuf, *start = NULL, *end = NULL, *key, *value;1061 char *tmpbuf, *start = NULL, *end = NULL, *key, *value;
1062 struct iscsi_session *sess = conn->sess;1062 struct iscsit_session *sess = conn->sess;
1063 struct iscsi_tiqn *tiqn;1063 struct iscsi_tiqn *tiqn;
1064 struct iscsi_tpg_np *tpg_np = NULL;1064 struct iscsi_tpg_np *tpg_np = NULL;
1065 struct iscsi_login_req *login_req;1065 struct iscsi_login_req *login_req;
@@ -1232,7 +1232,7 @@ get_target: · 166 unmodified lines
1232 1232
1233 /*1233 /*
1234 * conn->sess->node_acl will be set when the referenced1234 * conn->sess->node_acl will be set when the referenced
1235 * struct iscsi_session is located from received ISID+TSIH in1235 * struct iscsit_session is located from received ISID+TSIH in
1236 * iscsi_login_non_zero_tsih_s2().1236 * iscsi_login_non_zero_tsih_s2().
1237 */1237 */
1238 if (!login->leading_connection) {1238 if (!login->leading_connection) {
@@ -1272,7 +1272,7 @@ get_target: · 33 unmodified lines
1272alloc_tags:1272alloc_tags:
1273 tag_num = max_t(u32, ISCSIT_MIN_TAGS, queue_depth);1273 tag_num = max_t(u32, ISCSIT_MIN_TAGS, queue_depth);
1274 tag_num = (tag_num * 2) + ISCSIT_EXTRA_TAGS;1274 tag_num = (tag_num * 2) + ISCSIT_EXTRA_TAGS;
1275 tag_size = sizeof(struct iscsi_cmd) + conn->conn_transport->priv_size;1275 tag_size = sizeof(struct iscsit_cmd) + conn->conn_transport->priv_size;
1276 1276
1277 ret = transport_alloc_session_tags(sess->se_sess, tag_num, tag_size);1277 ret = transport_alloc_session_tags(sess->se_sess, tag_num, tag_size);
1278 if (ret < 0) {1278 if (ret < 0) {
@@ -1287,7 +1287,7 @@ out: · 8 unmodified lines
1287 1287
1288int iscsi_target_start_negotiation(1288int iscsi_target_start_negotiation(
1289 struct iscsi_login *login,1289 struct iscsi_login *login,
1290 struct iscsi_conn *conn)1290 struct iscsit_conn *conn)
1291{1291{
1292 int ret;1292 int ret;
1293 1293
@@ -1323,7 +1323,7 @@ int iscsi_target_start_negotiation( · 29 unmodified lines
1323 return ret;1323 return ret;
1324}1324}
1325 1325
1326void iscsi_target_nego_release(struct iscsi_conn *conn)1326void iscsi_target_nego_release(struct iscsit_conn *conn)
1327{1327{
1328 struct iscsi_login *login = conn->conn_login;1328 struct iscsi_login *login = conn->conn_login;
1329 1329
drivers/target/iscsi/iscsi_target_nego.h+6−6
@@ -5,21 +5,21 @@ · 4 unmodified lines
5#define DECIMAL 05#define DECIMAL 0
6#define HEX 16#define HEX 1
7 7
8struct iscsi_conn;8struct iscsit_conn;
9struct iscsi_login;9struct iscsi_login;
10struct iscsi_np;10struct iscsi_np;
11 11
12extern void convert_null_to_semi(char *, int);12extern void convert_null_to_semi(char *, int);
13extern int extract_param(const char *, const char *, unsigned int, char *,13extern int extract_param(const char *, const char *, unsigned int, char *,
14 unsigned char *);14 unsigned char *);
15extern int iscsi_target_check_login_request(struct iscsi_conn *,15extern int iscsi_target_check_login_request(struct iscsit_conn *,
16 struct iscsi_login *);16 struct iscsi_login *);
17extern int iscsi_target_get_initial_payload(struct iscsi_conn *,17extern int iscsi_target_get_initial_payload(struct iscsit_conn *,
18 struct iscsi_login *);18 struct iscsi_login *);
19extern int iscsi_target_locate_portal(struct iscsi_np *, struct iscsi_conn *,19extern int iscsi_target_locate_portal(struct iscsi_np *, struct iscsit_conn *,
20 struct iscsi_login *);20 struct iscsi_login *);
21extern int iscsi_target_start_negotiation(21extern int iscsi_target_start_negotiation(
22 struct iscsi_login *, struct iscsi_conn *);22 struct iscsi_login *, struct iscsit_conn *);
23extern void iscsi_target_nego_release(struct iscsi_conn *);23extern void iscsi_target_nego_release(struct iscsit_conn *);
24 24
25#endif /* ISCSI_TARGET_NEGO_H */25#endif /* ISCSI_TARGET_NEGO_H */
drivers/target/iscsi/iscsi_target_nodeattrib.c+2−2
@@ -96,8 +96,8 @@ int iscsit_na_nopin_timeout( · 95 unmodified lines
96 u32 nopin_timeout)96 u32 nopin_timeout)
97{97{
98 struct iscsi_node_attrib *a = &acl->node_attrib;98 struct iscsi_node_attrib *a = &acl->node_attrib;
99 struct iscsi_session *sess;99 struct iscsit_session *sess;
100 struct iscsi_conn *conn;100 struct iscsit_conn *conn;
101 struct se_node_acl *se_nacl = &a->nacl->se_node_acl;101 struct se_node_acl *se_nacl = &a->nacl->se_node_acl;
102 struct se_session *se_sess;102 struct se_session *se_sess;
103 u32 orig_nopin_timeout = a->nopin_timeout;103 u32 orig_nopin_timeout = a->nopin_timeout;
drivers/target/iscsi/iscsi_target_parameters.c+4−4
@@ -15,7 +15,7 @@ · 14 unmodified lines
15#include "iscsi_target_parameters.h"15#include "iscsi_target_parameters.h"
16 16
17int iscsi_login_rx_data(17int iscsi_login_rx_data(
18 struct iscsi_conn *conn,18 struct iscsit_conn *conn,
19 char *buf,19 char *buf,
20 int length)20 int length)
21{21{
@@ -37,7 +37,7 @@ int iscsi_login_rx_data( · 15 unmodified lines
37}37}
38 38
39int iscsi_login_tx_data(39int iscsi_login_tx_data(
40 struct iscsi_conn *conn,40 struct iscsit_conn *conn,
41 char *pdu_buf,41 char *pdu_buf,
42 char *text_buf,42 char *text_buf,
43 int text_length)43 int text_length)
@@ -955,7 +955,7 @@ out: · 911 unmodified lines
955}955}
956 956
957static int iscsi_check_acceptor_state(struct iscsi_param *param, char *value,957static int iscsi_check_acceptor_state(struct iscsi_param *param, char *value,
958 struct iscsi_conn *conn)958 struct iscsit_conn *conn)
959{959{
960 u8 acceptor_boolean_value = 0, proposer_boolean_value = 0;960 u8 acceptor_boolean_value = 0, proposer_boolean_value = 0;
961 char *negotiated_value = NULL;961 char *negotiated_value = NULL;
@@ -1352,7 +1352,7 @@ int iscsi_decode_text_input( · 390 unmodified lines
1352 u8 sender,1352 u8 sender,
1353 char *textbuf,1353 char *textbuf,
1354 u32 length,1354 u32 length,
1355 struct iscsi_conn *conn)1355 struct iscsit_conn *conn)
1356{1356{
1357 struct iscsi_param_list *param_list = conn->param_list;1357 struct iscsi_param_list *param_list = conn->param_list;
1358 char *tmpbuf, *start = NULL, *end = NULL;1358 char *tmpbuf, *start = NULL, *end = NULL;
drivers/target/iscsi/iscsi_target_parameters.h+4−4
@@ -25,13 +25,13 @@ struct iscsi_param { · 24 unmodified lines
25 struct list_head p_list;25 struct list_head p_list;
26} ____cacheline_aligned;26} ____cacheline_aligned;
27 27
28struct iscsi_conn;28struct iscsit_conn;
29struct iscsi_conn_ops;29struct iscsi_conn_ops;
30struct iscsi_param_list;30struct iscsi_param_list;
31struct iscsi_sess_ops;31struct iscsi_sess_ops;
32 32
33extern int iscsi_login_rx_data(struct iscsi_conn *, char *, int);33extern int iscsi_login_rx_data(struct iscsit_conn *, char *, int);
34extern int iscsi_login_tx_data(struct iscsi_conn *, char *, char *, int);34extern int iscsi_login_tx_data(struct iscsit_conn *, char *, char *, int);
35extern void iscsi_dump_conn_ops(struct iscsi_conn_ops *);35extern void iscsi_dump_conn_ops(struct iscsi_conn_ops *);
36extern void iscsi_dump_sess_ops(struct iscsi_sess_ops *);36extern void iscsi_dump_sess_ops(struct iscsi_sess_ops *);
37extern void iscsi_print_params(struct iscsi_param_list *);37extern void iscsi_print_params(struct iscsi_param_list *);
@@ -45,7 +45,7 @@ extern void iscsi_release_param_list(struct iscsi_param_list *); · 7 unmodified lines
45extern struct iscsi_param *iscsi_find_param_from_key(char *, struct iscsi_param_list *);45extern struct iscsi_param *iscsi_find_param_from_key(char *, struct iscsi_param_list *);
46extern int iscsi_extract_key_value(char *, char **, char **);46extern int iscsi_extract_key_value(char *, char **, char **);
47extern int iscsi_update_param_value(struct iscsi_param *, char *);47extern int iscsi_update_param_value(struct iscsi_param *, char *);
48extern int iscsi_decode_text_input(u8, u8, char *, u32, struct iscsi_conn *);48extern int iscsi_decode_text_input(u8, u8, char *, u32, struct iscsit_conn *);
49extern int iscsi_encode_text_output(u8, u8, char *, u32 *,49extern int iscsi_encode_text_output(u8, u8, char *, u32 *,
50 struct iscsi_param_list *, bool);50 struct iscsi_param_list *, bool);
51extern int iscsi_check_negotiated_keys(struct iscsi_param_list *);51extern int iscsi_check_negotiated_keys(struct iscsi_param_list *);
drivers/target/iscsi/iscsi_target_seq_pdu_list.c+22−22
@@ -18,7 +18,7 @@ · 17 unmodified lines
18#include "iscsi_target_seq_pdu_list.h"18#include "iscsi_target_seq_pdu_list.h"
19 19
20#ifdef DEBUG20#ifdef DEBUG
21static void iscsit_dump_seq_list(struct iscsi_cmd *cmd)21static void iscsit_dump_seq_list(struct iscsit_cmd *cmd)
22{22{
23 int i;23 int i;
24 struct iscsi_seq *seq;24 struct iscsi_seq *seq;
@@ -36,7 +36,7 @@ static void iscsit_dump_seq_list(struct iscsi_cmd *cmd) · 11 unmodified lines
36 }36 }
37}37}
38 38
39static void iscsit_dump_pdu_list(struct iscsi_cmd *cmd)39static void iscsit_dump_pdu_list(struct iscsit_cmd *cmd)
40{40{
41 int i;41 int i;
42 struct iscsi_pdu *pdu;42 struct iscsi_pdu *pdu;
@@ -52,12 +52,12 @@ static void iscsit_dump_pdu_list(struct iscsi_cmd *cmd) · 9 unmodified lines
52 }52 }
53}53}
54#else54#else
55static void iscsit_dump_seq_list(struct iscsi_cmd *cmd) {}55static void iscsit_dump_seq_list(struct iscsit_cmd *cmd) {}
56static void iscsit_dump_pdu_list(struct iscsi_cmd *cmd) {}56static void iscsit_dump_pdu_list(struct iscsit_cmd *cmd) {}
57#endif57#endif
58 58
59static void iscsit_ordered_seq_lists(59static void iscsit_ordered_seq_lists(
60 struct iscsi_cmd *cmd,60 struct iscsit_cmd *cmd,
61 u8 type)61 u8 type)
62{62{
63 u32 i, seq_count = 0;63 u32 i, seq_count = 0;
@@ -70,7 +70,7 @@ static void iscsit_ordered_seq_lists( · 6 unmodified lines
70}70}
71 71
72static void iscsit_ordered_pdu_lists(72static void iscsit_ordered_pdu_lists(
73 struct iscsi_cmd *cmd,73 struct iscsit_cmd *cmd,
74 u8 type)74 u8 type)
75{75{
76 u32 i, pdu_send_order = 0, seq_no = 0;76 u32 i, pdu_send_order = 0, seq_no = 0;
@@ -117,7 +117,7 @@ redo: · 40 unmodified lines
117}117}
118 118
119static int iscsit_randomize_pdu_lists(119static int iscsit_randomize_pdu_lists(
120 struct iscsi_cmd *cmd,120 struct iscsit_cmd *cmd,
121 u8 type)121 u8 type)
122{122{
123 int i = 0;123 int i = 0;
@@ -167,7 +167,7 @@ redo: · 43 unmodified lines
167}167}
168 168
169static int iscsit_randomize_seq_lists(169static int iscsit_randomize_seq_lists(
170 struct iscsi_cmd *cmd,170 struct iscsit_cmd *cmd,
171 u8 type)171 u8 type)
172{172{
173 int i, j = 0;173 int i, j = 0;
@@ -199,7 +199,7 @@ static int iscsit_randomize_seq_lists( · 25 unmodified lines
199}199}
200 200
201static void iscsit_determine_counts_for_list(201static void iscsit_determine_counts_for_list(
202 struct iscsi_cmd *cmd,202 struct iscsit_cmd *cmd,
203 struct iscsi_build_list *bl,203 struct iscsi_build_list *bl,
204 u32 *seq_count,204 u32 *seq_count,
205 u32 *pdu_count)205 u32 *pdu_count)
@@ -208,7 +208,7 @@ static void iscsit_determine_counts_for_list( · 2 unmodified lines
208 u32 burstlength = 0, offset = 0;208 u32 burstlength = 0, offset = 0;
209 u32 unsolicited_data_length = 0;209 u32 unsolicited_data_length = 0;
210 u32 mdsl;210 u32 mdsl;
211 struct iscsi_conn *conn = cmd->conn;211 struct iscsit_conn *conn = cmd->conn;
212 212
213 if (cmd->se_cmd.data_direction == DMA_TO_DEVICE)213 if (cmd->se_cmd.data_direction == DMA_TO_DEVICE)
214 mdsl = cmd->conn->conn_ops->MaxXmitDataSegmentLength;214 mdsl = cmd->conn->conn_ops->MaxXmitDataSegmentLength;
@@ -283,13 +283,13 @@ static void iscsit_determine_counts_for_list( · 68 unmodified lines
283 * or DataPDUInOrder=No.283 * or DataPDUInOrder=No.
284 */284 */
285static int iscsit_do_build_pdu_and_seq_lists(285static int iscsit_do_build_pdu_and_seq_lists(
286 struct iscsi_cmd *cmd,286 struct iscsit_cmd *cmd,
287 struct iscsi_build_list *bl)287 struct iscsi_build_list *bl)
288{288{
289 int check_immediate = 0, datapduinorder, datasequenceinorder;289 int check_immediate = 0, datapduinorder, datasequenceinorder;
290 u32 burstlength = 0, offset = 0, i = 0, mdsl;290 u32 burstlength = 0, offset = 0, i = 0, mdsl;
291 u32 pdu_count = 0, seq_no = 0, unsolicited_data_length = 0;291 u32 pdu_count = 0, seq_no = 0, unsolicited_data_length = 0;
292 struct iscsi_conn *conn = cmd->conn;292 struct iscsit_conn *conn = cmd->conn;
293 struct iscsi_pdu *pdu = cmd->pdu_list;293 struct iscsi_pdu *pdu = cmd->pdu_list;
294 struct iscsi_seq *seq = cmd->seq_list;294 struct iscsi_seq *seq = cmd->seq_list;
295 295
@@ -484,16 +484,16 @@ static int iscsit_do_build_pdu_and_seq_lists( · 188 unmodified lines
484}484}
485 485
486int iscsit_build_pdu_and_seq_lists(486int iscsit_build_pdu_and_seq_lists(
487 struct iscsi_cmd *cmd,487 struct iscsit_cmd *cmd,
488 u32 immediate_data_length)488 u32 immediate_data_length)
489{489{
490 struct iscsi_build_list bl;490 struct iscsi_build_list bl;
491 u32 pdu_count = 0, seq_count = 1;491 u32 pdu_count = 0, seq_count = 1;
492 struct iscsi_conn *conn = cmd->conn;492 struct iscsit_conn *conn = cmd->conn;
493 struct iscsi_pdu *pdu = NULL;493 struct iscsi_pdu *pdu = NULL;
494 struct iscsi_seq *seq = NULL;494 struct iscsi_seq *seq = NULL;
495 495
496 struct iscsi_session *sess = conn->sess;496 struct iscsit_session *sess = conn->sess;
497 struct iscsi_node_attrib *na;497 struct iscsi_node_attrib *na;
498 498
499 /*499 /*
@@ -559,7 +559,7 @@ int iscsit_build_pdu_and_seq_lists( · 59 unmodified lines
559}559}
560 560
561struct iscsi_pdu *iscsit_get_pdu_holder(561struct iscsi_pdu *iscsit_get_pdu_holder(
562 struct iscsi_cmd *cmd,562 struct iscsit_cmd *cmd,
563 u32 offset,563 u32 offset,
564 u32 length)564 u32 length)
565{565{
@@ -567,7 +567,7 @@ struct iscsi_pdu *iscsit_get_pdu_holder( · 1 unmodified line
567 struct iscsi_pdu *pdu = NULL;567 struct iscsi_pdu *pdu = NULL;
568 568
569 if (!cmd->pdu_list) {569 if (!cmd->pdu_list) {
570 pr_err("struct iscsi_cmd->pdu_list is NULL!\n");570 pr_err("struct iscsit_cmd->pdu_list is NULL!\n");
571 return NULL;571 return NULL;
572 }572 }
573 573
@@ -583,15 +583,15 @@ struct iscsi_pdu *iscsit_get_pdu_holder( · 9 unmodified lines
583}583}
584 584
585struct iscsi_pdu *iscsit_get_pdu_holder_for_seq(585struct iscsi_pdu *iscsit_get_pdu_holder_for_seq(
586 struct iscsi_cmd *cmd,586 struct iscsit_cmd *cmd,
587 struct iscsi_seq *seq)587 struct iscsi_seq *seq)
588{588{
589 u32 i;589 u32 i;
590 struct iscsi_conn *conn = cmd->conn;590 struct iscsit_conn *conn = cmd->conn;
591 struct iscsi_pdu *pdu = NULL;591 struct iscsi_pdu *pdu = NULL;
592 592
593 if (!cmd->pdu_list) {593 if (!cmd->pdu_list) {
594 pr_err("struct iscsi_cmd->pdu_list is NULL!\n");594 pr_err("struct iscsit_cmd->pdu_list is NULL!\n");
595 return NULL;595 return NULL;
596 }596 }
597 597
@@ -660,14 +660,14 @@ redo: · 62 unmodified lines
660}660}
661 661
662struct iscsi_seq *iscsit_get_seq_holder(662struct iscsi_seq *iscsit_get_seq_holder(
663 struct iscsi_cmd *cmd,663 struct iscsit_cmd *cmd,
664 u32 offset,664 u32 offset,
665 u32 length)665 u32 length)
666{666{
667 u32 i;667 u32 i;
668 668
669 if (!cmd->seq_list) {669 if (!cmd->seq_list) {
670 pr_err("struct iscsi_cmd->seq_list is NULL!\n");670 pr_err("struct iscsit_cmd->seq_list is NULL!\n");
671 return NULL;671 return NULL;
672 }672 }
673 673
drivers/target/iscsi/iscsi_target_seq_pdu_list.h+5−5
@@ -82,11 +82,11 @@ struct iscsi_seq { · 81 unmodified lines
82 u32 xfer_len;82 u32 xfer_len;
83} ____cacheline_aligned;83} ____cacheline_aligned;
84 84
85struct iscsi_cmd;85struct iscsit_cmd;
86 86
87extern int iscsit_build_pdu_and_seq_lists(struct iscsi_cmd *, u32);87extern int iscsit_build_pdu_and_seq_lists(struct iscsit_cmd *, u32);
88extern struct iscsi_pdu *iscsit_get_pdu_holder(struct iscsi_cmd *, u32, u32);88extern struct iscsi_pdu *iscsit_get_pdu_holder(struct iscsit_cmd *, u32, u32);
89extern struct iscsi_pdu *iscsit_get_pdu_holder_for_seq(struct iscsi_cmd *, struct iscsi_seq *);89extern struct iscsi_pdu *iscsit_get_pdu_holder_for_seq(struct iscsit_cmd *, struct iscsi_seq *);
90extern struct iscsi_seq *iscsit_get_seq_holder(struct iscsi_cmd *, u32, u32);90extern struct iscsi_seq *iscsit_get_seq_holder(struct iscsit_cmd *, u32, u32);
91 91
92#endif /* ISCSI_SEQ_AND_PDU_LIST_H */92#endif /* ISCSI_SEQ_AND_PDU_LIST_H */
drivers/target/iscsi/iscsi_target_stat.c+8−8
@@ -599,7 +599,7 @@ static ssize_t iscsi_stat_sess_node_show(struct config_item *item, char *page) · 598 unmodified lines
599{599{
600 struct iscsi_node_acl *acl = iscsi_stat_nacl(item);600 struct iscsi_node_acl *acl = iscsi_stat_nacl(item);
601 struct se_node_acl *se_nacl = &acl->se_node_acl;601 struct se_node_acl *se_nacl = &acl->se_node_acl;
602 struct iscsi_session *sess;602 struct iscsit_session *sess;
603 struct se_session *se_sess;603 struct se_session *se_sess;
604 ssize_t ret = 0;604 ssize_t ret = 0;
605 605
@@ -620,7 +620,7 @@ static ssize_t iscsi_stat_sess_indx_show(struct config_item *item, char *page) · 14 unmodified lines
620{620{
621 struct iscsi_node_acl *acl = iscsi_stat_nacl(item);621 struct iscsi_node_acl *acl = iscsi_stat_nacl(item);
622 struct se_node_acl *se_nacl = &acl->se_node_acl;622 struct se_node_acl *se_nacl = &acl->se_node_acl;
623 struct iscsi_session *sess;623 struct iscsit_session *sess;
624 struct se_session *se_sess;624 struct se_session *se_sess;
625 ssize_t ret = 0;625 ssize_t ret = 0;
626 626
@@ -642,7 +642,7 @@ static ssize_t iscsi_stat_sess_cmd_pdus_show(struct config_item *item, · 15 unmodified lines
642{642{
643 struct iscsi_node_acl *acl = iscsi_stat_nacl(item);643 struct iscsi_node_acl *acl = iscsi_stat_nacl(item);
644 struct se_node_acl *se_nacl = &acl->se_node_acl;644 struct se_node_acl *se_nacl = &acl->se_node_acl;
645 struct iscsi_session *sess;645 struct iscsit_session *sess;
646 struct se_session *se_sess;646 struct se_session *se_sess;
647 ssize_t ret = 0;647 ssize_t ret = 0;
648 648
@@ -664,7 +664,7 @@ static ssize_t iscsi_stat_sess_rsp_pdus_show(struct config_item *item, · 15 unmodified lines
664{664{
665 struct iscsi_node_acl *acl = iscsi_stat_nacl(item);665 struct iscsi_node_acl *acl = iscsi_stat_nacl(item);
666 struct se_node_acl *se_nacl = &acl->se_node_acl;666 struct se_node_acl *se_nacl = &acl->se_node_acl;
667 struct iscsi_session *sess;667 struct iscsit_session *sess;
668 struct se_session *se_sess;668 struct se_session *se_sess;
669 ssize_t ret = 0;669 ssize_t ret = 0;
670 670
@@ -686,7 +686,7 @@ static ssize_t iscsi_stat_sess_txdata_octs_show(struct config_item *item, · 15 unmodified lines
686{686{
687 struct iscsi_node_acl *acl = iscsi_stat_nacl(item);687 struct iscsi_node_acl *acl = iscsi_stat_nacl(item);
688 struct se_node_acl *se_nacl = &acl->se_node_acl;688 struct se_node_acl *se_nacl = &acl->se_node_acl;
689 struct iscsi_session *sess;689 struct iscsit_session *sess;
690 struct se_session *se_sess;690 struct se_session *se_sess;
691 ssize_t ret = 0;691 ssize_t ret = 0;
692 692
@@ -708,7 +708,7 @@ static ssize_t iscsi_stat_sess_rxdata_octs_show(struct config_item *item, · 15 unmodified lines
708{708{
709 struct iscsi_node_acl *acl = iscsi_stat_nacl(item);709 struct iscsi_node_acl *acl = iscsi_stat_nacl(item);
710 struct se_node_acl *se_nacl = &acl->se_node_acl;710 struct se_node_acl *se_nacl = &acl->se_node_acl;
711 struct iscsi_session *sess;711 struct iscsit_session *sess;
712 struct se_session *se_sess;712 struct se_session *se_sess;
713 ssize_t ret = 0;713 ssize_t ret = 0;
714 714
@@ -730,7 +730,7 @@ static ssize_t iscsi_stat_sess_conn_digest_errors_show(struct config_item *item, · 15 unmodified lines
730{730{
731 struct iscsi_node_acl *acl = iscsi_stat_nacl(item);731 struct iscsi_node_acl *acl = iscsi_stat_nacl(item);
732 struct se_node_acl *se_nacl = &acl->se_node_acl;732 struct se_node_acl *se_nacl = &acl->se_node_acl;
733 struct iscsi_session *sess;733 struct iscsit_session *sess;
734 struct se_session *se_sess;734 struct se_session *se_sess;
735 ssize_t ret = 0;735 ssize_t ret = 0;
736 736
@@ -752,7 +752,7 @@ static ssize_t iscsi_stat_sess_conn_timeout_errors_show( · 15 unmodified lines
752{752{
753 struct iscsi_node_acl *acl = iscsi_stat_nacl(item);753 struct iscsi_node_acl *acl = iscsi_stat_nacl(item);
754 struct se_node_acl *se_nacl = &acl->se_node_acl;754 struct se_node_acl *se_nacl = &acl->se_node_acl;
755 struct iscsi_session *sess;755 struct iscsit_session *sess;
756 struct se_session *se_sess;756 struct se_session *se_sess;
757 ssize_t ret = 0;757 ssize_t ret = 0;
758 758
drivers/target/iscsi/iscsi_target_tmr.c+36−36
@@ -28,11 +28,11 @@ · 27 unmodified lines
28#include "iscsi_target.h"28#include "iscsi_target.h"
29 29
30u8 iscsit_tmr_abort_task(30u8 iscsit_tmr_abort_task(
31 struct iscsi_cmd *cmd,31 struct iscsit_cmd *cmd,
32 unsigned char *buf)32 unsigned char *buf)
33{33{
34 struct iscsi_cmd *ref_cmd;34 struct iscsit_cmd *ref_cmd;
35 struct iscsi_conn *conn = cmd->conn;35 struct iscsit_conn *conn = cmd->conn;
36 struct iscsi_tmr_req *tmr_req = cmd->tmr_req;36 struct iscsi_tmr_req *tmr_req = cmd->tmr_req;
37 struct se_tmr_req *se_tmr = cmd->se_cmd.se_tmr_req;37 struct se_tmr_req *se_tmr = cmd->se_cmd.se_tmr_req;
38 struct iscsi_tm *hdr = (struct iscsi_tm *) buf;38 struct iscsi_tm *hdr = (struct iscsi_tm *) buf;
@@ -63,11 +63,11 @@ u8 iscsit_tmr_abort_task( · 24 unmodified lines
63 * Called from iscsit_handle_task_mgt_cmd().63 * Called from iscsit_handle_task_mgt_cmd().
64 */64 */
65int iscsit_tmr_task_warm_reset(65int iscsit_tmr_task_warm_reset(
66 struct iscsi_conn *conn,66 struct iscsit_conn *conn,
67 struct iscsi_tmr_req *tmr_req,67 struct iscsi_tmr_req *tmr_req,
68 unsigned char *buf)68 unsigned char *buf)
69{69{
70 struct iscsi_session *sess = conn->sess;70 struct iscsit_session *sess = conn->sess;
71 struct iscsi_node_attrib *na = iscsit_tpg_get_node_attrib(sess);71 struct iscsi_node_attrib *na = iscsit_tpg_get_node_attrib(sess);
72 72
73 if (!na->tmr_warm_reset) {73 if (!na->tmr_warm_reset) {
@@ -83,11 +83,11 @@ int iscsit_tmr_task_warm_reset( · 9 unmodified lines
83}83}
84 84
85int iscsit_tmr_task_cold_reset(85int iscsit_tmr_task_cold_reset(
86 struct iscsi_conn *conn,86 struct iscsit_conn *conn,
87 struct iscsi_tmr_req *tmr_req,87 struct iscsi_tmr_req *tmr_req,
88 unsigned char *buf)88 unsigned char *buf)
89{89{
90 struct iscsi_session *sess = conn->sess;90 struct iscsit_session *sess = conn->sess;
91 struct iscsi_node_attrib *na = iscsit_tpg_get_node_attrib(sess);91 struct iscsi_node_attrib *na = iscsit_tpg_get_node_attrib(sess);
92 92
93 if (!na->tmr_cold_reset) {93 if (!na->tmr_cold_reset) {
@@ -103,11 +103,11 @@ int iscsit_tmr_task_cold_reset( · 9 unmodified lines
103}103}
104 104
105u8 iscsit_tmr_task_reassign(105u8 iscsit_tmr_task_reassign(
106 struct iscsi_cmd *cmd,106 struct iscsit_cmd *cmd,
107 unsigned char *buf)107 unsigned char *buf)
108{108{
109 struct iscsi_cmd *ref_cmd = NULL;109 struct iscsit_cmd *ref_cmd = NULL;
110 struct iscsi_conn *conn = cmd->conn;110 struct iscsit_conn *conn = cmd->conn;
111 struct iscsi_conn_recovery *cr = NULL;111 struct iscsi_conn_recovery *cr = NULL;
112 struct iscsi_tmr_req *tmr_req = cmd->tmr_req;112 struct iscsi_tmr_req *tmr_req = cmd->tmr_req;
113 struct se_tmr_req *se_tmr = cmd->se_cmd.se_tmr_req;113 struct se_tmr_req *se_tmr = cmd->se_cmd.se_tmr_req;
@@ -175,9 +175,9 @@ u8 iscsit_tmr_task_reassign( · 61 unmodified lines
175}175}
176 176
177static void iscsit_task_reassign_remove_cmd(177static void iscsit_task_reassign_remove_cmd(
178 struct iscsi_cmd *cmd,178 struct iscsit_cmd *cmd,
179 struct iscsi_conn_recovery *cr,179 struct iscsi_conn_recovery *cr,
180 struct iscsi_session *sess)180 struct iscsit_session *sess)
181{181{
182 int ret;182 int ret;
183 183
@@ -193,9 +193,9 @@ static void iscsit_task_reassign_remove_cmd( · 9 unmodified lines
193 193
194static int iscsit_task_reassign_complete_nop_out(194static int iscsit_task_reassign_complete_nop_out(
195 struct iscsi_tmr_req *tmr_req,195 struct iscsi_tmr_req *tmr_req,
196 struct iscsi_conn *conn)196 struct iscsit_conn *conn)
197{197{
198 struct iscsi_cmd *cmd = tmr_req->ref_cmd;198 struct iscsit_cmd *cmd = tmr_req->ref_cmd;
199 struct iscsi_conn_recovery *cr;199 struct iscsi_conn_recovery *cr;
200 200
201 if (!cmd->cr) {201 if (!cmd->cr) {
@@ -224,12 +224,12 @@ static int iscsit_task_reassign_complete_nop_out( · 22 unmodified lines
224}224}
225 225
226static int iscsit_task_reassign_complete_write(226static int iscsit_task_reassign_complete_write(
227 struct iscsi_cmd *cmd,227 struct iscsit_cmd *cmd,
228 struct iscsi_tmr_req *tmr_req)228 struct iscsi_tmr_req *tmr_req)
229{229{
230 int no_build_r2ts = 0;230 int no_build_r2ts = 0;
231 u32 length = 0, offset = 0;231 u32 length = 0, offset = 0;
232 struct iscsi_conn *conn = cmd->conn;232 struct iscsit_conn *conn = cmd->conn;
233 struct se_cmd *se_cmd = &cmd->se_cmd;233 struct se_cmd *se_cmd = &cmd->se_cmd;
234 /*234 /*
235 * The Initiator must not send a R2T SNACK with a Begrun less than235 * The Initiator must not send a R2T SNACK with a Begrun less than
@@ -296,10 +296,10 @@ static int iscsit_task_reassign_complete_write( · 60 unmodified lines
296}296}
297 297
298static int iscsit_task_reassign_complete_read(298static int iscsit_task_reassign_complete_read(
299 struct iscsi_cmd *cmd,299 struct iscsit_cmd *cmd,
300 struct iscsi_tmr_req *tmr_req)300 struct iscsi_tmr_req *tmr_req)
301{301{
302 struct iscsi_conn *conn = cmd->conn;302 struct iscsit_conn *conn = cmd->conn;
303 struct iscsi_datain_req *dr;303 struct iscsi_datain_req *dr;
304 struct se_cmd *se_cmd = &cmd->se_cmd;304 struct se_cmd *se_cmd = &cmd->se_cmd;
305 /*305 /*
@@ -349,10 +349,10 @@ static int iscsit_task_reassign_complete_read( · 43 unmodified lines
349}349}
350 350
351static int iscsit_task_reassign_complete_none(351static int iscsit_task_reassign_complete_none(
352 struct iscsi_cmd *cmd,352 struct iscsit_cmd *cmd,
353 struct iscsi_tmr_req *tmr_req)353 struct iscsi_tmr_req *tmr_req)
354{354{
355 struct iscsi_conn *conn = cmd->conn;355 struct iscsit_conn *conn = cmd->conn;
356 356
357 cmd->i_state = ISTATE_SEND_STATUS;357 cmd->i_state = ISTATE_SEND_STATUS;
358 iscsit_add_cmd_to_response_queue(cmd, conn, cmd->i_state);358 iscsit_add_cmd_to_response_queue(cmd, conn, cmd->i_state);
@@ -361,9 +361,9 @@ static int iscsit_task_reassign_complete_none( · 2 unmodified lines
361 361
362static int iscsit_task_reassign_complete_scsi_cmnd(362static int iscsit_task_reassign_complete_scsi_cmnd(
363 struct iscsi_tmr_req *tmr_req,363 struct iscsi_tmr_req *tmr_req,
364 struct iscsi_conn *conn)364 struct iscsit_conn *conn)
365{365{
366 struct iscsi_cmd *cmd = tmr_req->ref_cmd;366 struct iscsit_cmd *cmd = tmr_req->ref_cmd;
367 struct iscsi_conn_recovery *cr;367 struct iscsi_conn_recovery *cr;
368 368
369 if (!cmd->cr) {369 if (!cmd->cr) {
@@ -410,13 +410,13 @@ static int iscsit_task_reassign_complete_scsi_cmnd( · 40 unmodified lines
410 410
411static int iscsit_task_reassign_complete(411static int iscsit_task_reassign_complete(
412 struct iscsi_tmr_req *tmr_req,412 struct iscsi_tmr_req *tmr_req,
413 struct iscsi_conn *conn)413 struct iscsit_conn *conn)
414{414{
415 struct iscsi_cmd *cmd;415 struct iscsit_cmd *cmd;
416 int ret = 0;416 int ret = 0;
417 417
418 if (!tmr_req->ref_cmd) {418 if (!tmr_req->ref_cmd) {
419 pr_err("TMR Request is missing a RefCmd struct iscsi_cmd.\n");419 pr_err("TMR Request is missing a RefCmd struct iscsit_cmd.\n");
420 return -1;420 return -1;
421 }421 }
422 cmd = tmr_req->ref_cmd;422 cmd = tmr_req->ref_cmd;
@@ -451,7 +451,7 @@ static int iscsit_task_reassign_complete( · 28 unmodified lines
451 * Right now the only one that its really needed for is451 * Right now the only one that its really needed for is
452 * connection recovery releated TASK_REASSIGN.452 * connection recovery releated TASK_REASSIGN.
453 */453 */
454int iscsit_tmr_post_handler(struct iscsi_cmd *cmd, struct iscsi_conn *conn)454int iscsit_tmr_post_handler(struct iscsit_cmd *cmd, struct iscsit_conn *conn)
455{455{
456 struct iscsi_tmr_req *tmr_req = cmd->tmr_req;456 struct iscsi_tmr_req *tmr_req = cmd->tmr_req;
457 struct se_tmr_req *se_tmr = cmd->se_cmd.se_tmr_req;457 struct se_tmr_req *se_tmr = cmd->se_cmd.se_tmr_req;
@@ -469,14 +469,14 @@ EXPORT_SYMBOL(iscsit_tmr_post_handler); · 11 unmodified lines
469 */469 */
470static int iscsit_task_reassign_prepare_read(470static int iscsit_task_reassign_prepare_read(
471 struct iscsi_tmr_req *tmr_req,471 struct iscsi_tmr_req *tmr_req,
472 struct iscsi_conn *conn)472 struct iscsit_conn *conn)
473{473{
474 return 0;474 return 0;
475}475}
476 476
477static void iscsit_task_reassign_prepare_unsolicited_dataout(477static void iscsit_task_reassign_prepare_unsolicited_dataout(
478 struct iscsi_cmd *cmd,478 struct iscsit_cmd *cmd,
479 struct iscsi_conn *conn)479 struct iscsit_conn *conn)
480{480{
481 int i, j;481 int i, j;
482 struct iscsi_pdu *pdu = NULL;482 struct iscsi_pdu *pdu = NULL;
@@ -544,9 +544,9 @@ static void iscsit_task_reassign_prepare_unsolicited_dataout( · 61 unmodified lines
544 544
545static int iscsit_task_reassign_prepare_write(545static int iscsit_task_reassign_prepare_write(
546 struct iscsi_tmr_req *tmr_req,546 struct iscsi_tmr_req *tmr_req,
547 struct iscsi_conn *conn)547 struct iscsit_conn *conn)
548{548{
549 struct iscsi_cmd *cmd = tmr_req->ref_cmd;549 struct iscsit_cmd *cmd = tmr_req->ref_cmd;
550 struct iscsi_pdu *pdu = NULL;550 struct iscsi_pdu *pdu = NULL;
551 struct iscsi_r2t *r2t = NULL, *r2t_tmp;551 struct iscsi_r2t *r2t = NULL, *r2t_tmp;
552 int first_incomplete_r2t = 1, i = 0;552 int first_incomplete_r2t = 1, i = 0;
@@ -575,7 +575,7 @@ static int iscsit_task_reassign_prepare_write( · 22 unmodified lines
575 *575 *
576 * If we have not received all DataOUT in question, we must576 * If we have not received all DataOUT in question, we must
577 * make sure to make the appropriate changes to values in577 * make sure to make the appropriate changes to values in
578 * struct iscsi_cmd (and elsewhere depending on session parameters)578 * struct iscsit_cmd (and elsewhere depending on session parameters)
579 * so iscsit_build_r2ts_for_cmd() in iscsit_task_reassign_complete_write()579 * so iscsit_build_r2ts_for_cmd() in iscsit_task_reassign_complete_write()
580 * will resend a new R2T for the DataOUT sequences in question.580 * will resend a new R2T for the DataOUT sequences in question.
581 */581 */
@@ -708,7 +708,7 @@ next: · 126 unmodified lines
708 * to check that the Initiator is not requesting R2Ts for DataOUT708 * to check that the Initiator is not requesting R2Ts for DataOUT
709 * sequences it has already completed.709 * sequences it has already completed.
710 *710 *
711 * Free each R2T in question and adjust values in struct iscsi_cmd711 * Free each R2T in question and adjust values in struct iscsit_cmd
712 * accordingly so iscsit_build_r2ts_for_cmd() do the rest of712 * accordingly so iscsit_build_r2ts_for_cmd() do the rest of
713 * the work after the TMR TASK_REASSIGN Response is sent.713 * the work after the TMR TASK_REASSIGN Response is sent.
714 */714 */
@@ -773,13 +773,13 @@ drop_unacknowledged_r2ts: · 58 unmodified lines
773 773
774/*774/*
775 * Performs sanity checks TMR TASK_REASSIGN's ExpDataSN for775 * Performs sanity checks TMR TASK_REASSIGN's ExpDataSN for
776 * a given struct iscsi_cmd.776 * a given struct iscsit_cmd.
777 */777 */
778int iscsit_check_task_reassign_expdatasn(778int iscsit_check_task_reassign_expdatasn(
779 struct iscsi_tmr_req *tmr_req,779 struct iscsi_tmr_req *tmr_req,
780 struct iscsi_conn *conn)780 struct iscsit_conn *conn)
781{781{
782 struct iscsi_cmd *ref_cmd = tmr_req->ref_cmd;782 struct iscsit_cmd *ref_cmd = tmr_req->ref_cmd;
783 783
784 if (ref_cmd->iscsi_opcode != ISCSI_OP_SCSI_CMD)784 if (ref_cmd->iscsi_opcode != ISCSI_OP_SCSI_CMD)
785 return 0;785 return 0;
drivers/target/iscsi/iscsi_target_tmr.h+8−8
@@ -4,18 +4,18 @@ · 3 unmodified lines
4 4
5#include <linux/types.h>5#include <linux/types.h>
6 6
7struct iscsi_cmd;7struct iscsit_cmd;
8struct iscsi_conn;8struct iscsit_conn;
9struct iscsi_tmr_req;9struct iscsi_tmr_req;
10 10
11extern u8 iscsit_tmr_abort_task(struct iscsi_cmd *, unsigned char *);11extern u8 iscsit_tmr_abort_task(struct iscsit_cmd *, unsigned char *);
12extern int iscsit_tmr_task_warm_reset(struct iscsi_conn *, struct iscsi_tmr_req *,12extern int iscsit_tmr_task_warm_reset(struct iscsit_conn *, struct iscsi_tmr_req *,
13 unsigned char *);13 unsigned char *);
14extern int iscsit_tmr_task_cold_reset(struct iscsi_conn *, struct iscsi_tmr_req *,14extern int iscsit_tmr_task_cold_reset(struct iscsit_conn *, struct iscsi_tmr_req *,
15 unsigned char *);15 unsigned char *);
16extern u8 iscsit_tmr_task_reassign(struct iscsi_cmd *, unsigned char *);16extern u8 iscsit_tmr_task_reassign(struct iscsit_cmd *, unsigned char *);
17extern int iscsit_tmr_post_handler(struct iscsi_cmd *, struct iscsi_conn *);17extern int iscsit_tmr_post_handler(struct iscsit_cmd *, struct iscsit_conn *);
18extern int iscsit_check_task_reassign_expdatasn(struct iscsi_tmr_req *,18extern int iscsit_check_task_reassign_expdatasn(struct iscsi_tmr_req *,
19 struct iscsi_conn *);19 struct iscsit_conn *);
20 20
21#endif /* ISCSI_TARGET_TMR_H */21#endif /* ISCSI_TARGET_TMR_H */
drivers/target/iscsi/iscsi_target_tpg.c+1−1
@@ -390,7 +390,7 @@ int iscsit_tpg_disable_portal_group(struct iscsi_portal_group *tpg, int force) · 389 unmodified lines
390}390}
391 391
392struct iscsi_node_attrib *iscsit_tpg_get_node_attrib(392struct iscsi_node_attrib *iscsit_tpg_get_node_attrib(
393 struct iscsi_session *sess)393 struct iscsit_session *sess)
394{394{
395 struct se_session *se_sess = sess->se_sess;395 struct se_session *se_sess = sess->se_sess;
396 struct se_node_acl *se_nacl = se_sess->se_node_acl;396 struct se_node_acl *se_nacl = se_sess->se_node_acl;
drivers/target/iscsi/iscsi_target_tpg.h+2−2
@@ -5,7 +5,7 @@ · 4 unmodified lines
5#include <linux/types.h>5#include <linux/types.h>
6 6
7struct iscsi_np;7struct iscsi_np;
8struct iscsi_session;8struct iscsit_session;
9struct iscsi_tiqn;9struct iscsi_tiqn;
10struct iscsi_tpg_np;10struct iscsi_tpg_np;
11struct se_node_acl;11struct se_node_acl;
@@ -28,7 +28,7 @@ extern struct iscsi_node_acl *iscsit_tpg_add_initiator_node_acl( · 16 unmodified lines
28 struct iscsi_portal_group *, const char *, u32);28 struct iscsi_portal_group *, const char *, u32);
29extern void iscsit_tpg_del_initiator_node_acl(struct iscsi_portal_group *,29extern void iscsit_tpg_del_initiator_node_acl(struct iscsi_portal_group *,
30 struct se_node_acl *);30 struct se_node_acl *);
31extern struct iscsi_node_attrib *iscsit_tpg_get_node_attrib(struct iscsi_session *);31extern struct iscsi_node_attrib *iscsit_tpg_get_node_attrib(struct iscsit_session *);
32extern void iscsit_tpg_del_external_nps(struct iscsi_tpg_np *);32extern void iscsit_tpg_del_external_nps(struct iscsi_tpg_np *);
33extern struct iscsi_tpg_np *iscsit_tpg_locate_child_np(struct iscsi_tpg_np *, int);33extern struct iscsi_tpg_np *iscsit_tpg_locate_child_np(struct iscsi_tpg_np *, int);
34extern struct iscsi_tpg_np *iscsit_tpg_add_network_portal(struct iscsi_portal_group *,34extern struct iscsi_tpg_np *iscsit_tpg_add_network_portal(struct iscsi_portal_group *,
drivers/target/iscsi/iscsi_target_util.c+82−82
@@ -32,7 +32,7 @@ extern struct list_head g_tiqn_list; · 31 unmodified lines
32extern spinlock_t tiqn_lock;32extern spinlock_t tiqn_lock;
33 33
34int iscsit_add_r2t_to_list(34int iscsit_add_r2t_to_list(
35 struct iscsi_cmd *cmd,35 struct iscsit_cmd *cmd,
36 u32 offset,36 u32 offset,
37 u32 xfer_len,37 u32 xfer_len,
38 int recovery,38 int recovery,
@@ -65,7 +65,7 @@ int iscsit_add_r2t_to_list( · 26 unmodified lines
65}65}
66 66
67struct iscsi_r2t *iscsit_get_r2t_for_eos(67struct iscsi_r2t *iscsit_get_r2t_for_eos(
68 struct iscsi_cmd *cmd,68 struct iscsit_cmd *cmd,
69 u32 offset,69 u32 offset,
70 u32 length)70 u32 length)
71{71{
@@ -86,7 +86,7 @@ struct iscsi_r2t *iscsit_get_r2t_for_eos( · 14 unmodified lines
86 return NULL;86 return NULL;
87}87}
88 88
89struct iscsi_r2t *iscsit_get_r2t_from_list(struct iscsi_cmd *cmd)89struct iscsi_r2t *iscsit_get_r2t_from_list(struct iscsit_cmd *cmd)
90{90{
91 struct iscsi_r2t *r2t;91 struct iscsi_r2t *r2t;
92 92
@@ -104,7 +104,7 @@ struct iscsi_r2t *iscsit_get_r2t_from_list(struct iscsi_cmd *cmd) · 11 unmodified lines
104 return NULL;104 return NULL;
105}105}
106 106
107void iscsit_free_r2t(struct iscsi_r2t *r2t, struct iscsi_cmd *cmd)107void iscsit_free_r2t(struct iscsi_r2t *r2t, struct iscsit_cmd *cmd)
108{108{
109 lockdep_assert_held(&cmd->r2t_lock);109 lockdep_assert_held(&cmd->r2t_lock);
110 110
@@ -112,7 +112,7 @@ void iscsit_free_r2t(struct iscsi_r2t *r2t, struct iscsi_cmd *cmd) · 1 unmodified line
112 kmem_cache_free(lio_r2t_cache, r2t);112 kmem_cache_free(lio_r2t_cache, r2t);
113}113}
114 114
115void iscsit_free_r2ts_from_list(struct iscsi_cmd *cmd)115void iscsit_free_r2ts_from_list(struct iscsit_cmd *cmd)
116{116{
117 struct iscsi_r2t *r2t, *r2t_tmp;117 struct iscsi_r2t *r2t, *r2t_tmp;
118 118
@@ -152,9 +152,9 @@ static int iscsit_wait_for_tag(struct se_session *se_sess, int state, int *cpup) · 33 unmodified lines
152 * May be called from software interrupt (timer) context for allocating152 * May be called from software interrupt (timer) context for allocating
153 * iSCSI NopINs.153 * iSCSI NopINs.
154 */154 */
155struct iscsi_cmd *iscsit_allocate_cmd(struct iscsi_conn *conn, int state)155struct iscsit_cmd *iscsit_allocate_cmd(struct iscsit_conn *conn, int state)
156{156{
157 struct iscsi_cmd *cmd;157 struct iscsit_cmd *cmd;
158 struct se_session *se_sess = conn->sess->se_sess;158 struct se_session *se_sess = conn->sess->se_sess;
159 int size, tag, cpu;159 int size, tag, cpu;
160 160
@@ -164,8 +164,8 @@ struct iscsi_cmd *iscsit_allocate_cmd(struct iscsi_conn *conn, int state) · 3 unmodified lines
164 if (tag < 0)164 if (tag < 0)
165 return NULL;165 return NULL;
166 166
167 size = sizeof(struct iscsi_cmd) + conn->conn_transport->priv_size;167 size = sizeof(struct iscsit_cmd) + conn->conn_transport->priv_size;
168 cmd = (struct iscsi_cmd *)(se_sess->sess_cmd_map + (tag * size));168 cmd = (struct iscsit_cmd *)(se_sess->sess_cmd_map + (tag * size));
169 memset(cmd, 0, size);169 memset(cmd, 0, size);
170 170
171 cmd->se_cmd.map_tag = tag;171 cmd->se_cmd.map_tag = tag;
@@ -187,7 +187,7 @@ struct iscsi_cmd *iscsit_allocate_cmd(struct iscsi_conn *conn, int state) · 15 unmodified lines
187EXPORT_SYMBOL(iscsit_allocate_cmd);187EXPORT_SYMBOL(iscsit_allocate_cmd);
188 188
189struct iscsi_seq *iscsit_get_seq_holder_for_datain(189struct iscsi_seq *iscsit_get_seq_holder_for_datain(
190 struct iscsi_cmd *cmd,190 struct iscsit_cmd *cmd,
191 u32 seq_send_order)191 u32 seq_send_order)
192{192{
193 u32 i;193 u32 i;
@@ -199,12 +199,12 @@ struct iscsi_seq *iscsit_get_seq_holder_for_datain( · 5 unmodified lines
199 return NULL;199 return NULL;
200}200}
201 201
202struct iscsi_seq *iscsit_get_seq_holder_for_r2t(struct iscsi_cmd *cmd)202struct iscsi_seq *iscsit_get_seq_holder_for_r2t(struct iscsit_cmd *cmd)
203{203{
204 u32 i;204 u32 i;
205 205
206 if (!cmd->seq_list) {206 if (!cmd->seq_list) {
207 pr_err("struct iscsi_cmd->seq_list is NULL!\n");207 pr_err("struct iscsit_cmd->seq_list is NULL!\n");
208 return NULL;208 return NULL;
209 }209 }
210 210
@@ -221,7 +221,7 @@ struct iscsi_seq *iscsit_get_seq_holder_for_r2t(struct iscsi_cmd *cmd) · 10 unmodified lines
221}221}
222 222
223struct iscsi_r2t *iscsit_get_holder_for_r2tsn(223struct iscsi_r2t *iscsit_get_holder_for_r2tsn(
224 struct iscsi_cmd *cmd,224 struct iscsit_cmd *cmd,
225 u32 r2t_sn)225 u32 r2t_sn)
226{226{
227 struct iscsi_r2t *r2t;227 struct iscsi_r2t *r2t;
@@ -238,7 +238,7 @@ struct iscsi_r2t *iscsit_get_holder_for_r2tsn( · 10 unmodified lines
238 return NULL;238 return NULL;
239}239}
240 240
241static inline int iscsit_check_received_cmdsn(struct iscsi_session *sess, u32 cmdsn)241static inline int iscsit_check_received_cmdsn(struct iscsit_session *sess, u32 cmdsn)
242{242{
243 u32 max_cmdsn;243 u32 max_cmdsn;
244 int ret;244 int ret;
@@ -282,7 +282,7 @@ static inline int iscsit_check_received_cmdsn(struct iscsi_session *sess, u32 cm · 37 unmodified lines
282 * Commands may be received out of order if MC/S is in use.282 * Commands may be received out of order if MC/S is in use.
283 * Ensure they are executed in CmdSN order.283 * Ensure they are executed in CmdSN order.
284 */284 */
285int iscsit_sequence_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd,285int iscsit_sequence_cmd(struct iscsit_conn *conn, struct iscsit_cmd *cmd,
286 unsigned char *buf, __be32 cmdsn)286 unsigned char *buf, __be32 cmdsn)
287{287{
288 int ret, cmdsn_ret;288 int ret, cmdsn_ret;
@@ -333,9 +333,9 @@ int iscsit_sequence_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd, · 44 unmodified lines
333}333}
334EXPORT_SYMBOL(iscsit_sequence_cmd);334EXPORT_SYMBOL(iscsit_sequence_cmd);
335 335
336int iscsit_check_unsolicited_dataout(struct iscsi_cmd *cmd, unsigned char *buf)336int iscsit_check_unsolicited_dataout(struct iscsit_cmd *cmd, unsigned char *buf)
337{337{
338 struct iscsi_conn *conn = cmd->conn;338 struct iscsit_conn *conn = cmd->conn;
339 struct se_cmd *se_cmd = &cmd->se_cmd;339 struct se_cmd *se_cmd = &cmd->se_cmd;
340 struct iscsi_data *hdr = (struct iscsi_data *) buf;340 struct iscsi_data *hdr = (struct iscsi_data *) buf;
341 u32 payload_length = ntoh24(hdr->dlength);341 u32 payload_length = ntoh24(hdr->dlength);
@@ -377,11 +377,11 @@ int iscsit_check_unsolicited_dataout(struct iscsi_cmd *cmd, unsigned char *buf) · 35 unmodified lines
377 return 0;377 return 0;
378}378}
379 379
380struct iscsi_cmd *iscsit_find_cmd_from_itt(380struct iscsit_cmd *iscsit_find_cmd_from_itt(
381 struct iscsi_conn *conn,381 struct iscsit_conn *conn,
382 itt_t init_task_tag)382 itt_t init_task_tag)
383{383{
384 struct iscsi_cmd *cmd;384 struct iscsit_cmd *cmd;
385 385
386 spin_lock_bh(&conn->cmd_lock);386 spin_lock_bh(&conn->cmd_lock);
387 list_for_each_entry(cmd, &conn->conn_cmd_list, i_conn_node) {387 list_for_each_entry(cmd, &conn->conn_cmd_list, i_conn_node) {
@@ -398,12 +398,12 @@ struct iscsi_cmd *iscsit_find_cmd_from_itt( · 10 unmodified lines
398}398}
399EXPORT_SYMBOL(iscsit_find_cmd_from_itt);399EXPORT_SYMBOL(iscsit_find_cmd_from_itt);
400 400
401struct iscsi_cmd *iscsit_find_cmd_from_itt_or_dump(401struct iscsit_cmd *iscsit_find_cmd_from_itt_or_dump(
402 struct iscsi_conn *conn,402 struct iscsit_conn *conn,
403 itt_t init_task_tag,403 itt_t init_task_tag,
404 u32 length)404 u32 length)
405{405{
406 struct iscsi_cmd *cmd;406 struct iscsit_cmd *cmd;
407 407
408 spin_lock_bh(&conn->cmd_lock);408 spin_lock_bh(&conn->cmd_lock);
409 list_for_each_entry(cmd, &conn->conn_cmd_list, i_conn_node) {409 list_for_each_entry(cmd, &conn->conn_cmd_list, i_conn_node) {
@@ -425,11 +425,11 @@ struct iscsi_cmd *iscsit_find_cmd_from_itt_or_dump( · 15 unmodified lines
425}425}
426EXPORT_SYMBOL(iscsit_find_cmd_from_itt_or_dump);426EXPORT_SYMBOL(iscsit_find_cmd_from_itt_or_dump);
427 427
428struct iscsi_cmd *iscsit_find_cmd_from_ttt(428struct iscsit_cmd *iscsit_find_cmd_from_ttt(
429 struct iscsi_conn *conn,429 struct iscsit_conn *conn,
430 u32 targ_xfer_tag)430 u32 targ_xfer_tag)
431{431{
432 struct iscsi_cmd *cmd = NULL;432 struct iscsit_cmd *cmd = NULL;
433 433
434 spin_lock_bh(&conn->cmd_lock);434 spin_lock_bh(&conn->cmd_lock);
435 list_for_each_entry(cmd, &conn->conn_cmd_list, i_conn_node) {435 list_for_each_entry(cmd, &conn->conn_cmd_list, i_conn_node) {
@@ -446,12 +446,12 @@ struct iscsi_cmd *iscsit_find_cmd_from_ttt( · 10 unmodified lines
446}446}
447 447
448int iscsit_find_cmd_for_recovery(448int iscsit_find_cmd_for_recovery(
449 struct iscsi_session *sess,449 struct iscsit_session *sess,
450 struct iscsi_cmd **cmd_ptr,450 struct iscsit_cmd **cmd_ptr,
451 struct iscsi_conn_recovery **cr_ptr,451 struct iscsi_conn_recovery **cr_ptr,
452 itt_t init_task_tag)452 itt_t init_task_tag)
453{453{
454 struct iscsi_cmd *cmd = NULL;454 struct iscsit_cmd *cmd = NULL;
455 struct iscsi_conn_recovery *cr;455 struct iscsi_conn_recovery *cr;
456 /*456 /*
457 * Scan through the inactive connection recovery list's command list.457 * Scan through the inactive connection recovery list's command list.
@@ -498,8 +498,8 @@ int iscsit_find_cmd_for_recovery( · 40 unmodified lines
498}498}
499 499
500void iscsit_add_cmd_to_immediate_queue(500void iscsit_add_cmd_to_immediate_queue(
501 struct iscsi_cmd *cmd,501 struct iscsit_cmd *cmd,
502 struct iscsi_conn *conn,502 struct iscsit_conn *conn,
503 u8 state)503 u8 state)
504{504{
505 struct iscsi_queue_req *qr;505 struct iscsi_queue_req *qr;
@@ -524,7 +524,7 @@ void iscsit_add_cmd_to_immediate_queue( · 18 unmodified lines
524}524}
525EXPORT_SYMBOL(iscsit_add_cmd_to_immediate_queue);525EXPORT_SYMBOL(iscsit_add_cmd_to_immediate_queue);
526 526
527struct iscsi_queue_req *iscsit_get_cmd_from_immediate_queue(struct iscsi_conn *conn)527struct iscsi_queue_req *iscsit_get_cmd_from_immediate_queue(struct iscsit_conn *conn)
528{528{
529 struct iscsi_queue_req *qr;529 struct iscsi_queue_req *qr;
530 530
@@ -545,8 +545,8 @@ struct iscsi_queue_req *iscsit_get_cmd_from_immediate_queue(struct iscsi_conn *c · 14 unmodified lines
545}545}
546 546
547static void iscsit_remove_cmd_from_immediate_queue(547static void iscsit_remove_cmd_from_immediate_queue(
548 struct iscsi_cmd *cmd,548 struct iscsit_cmd *cmd,
549 struct iscsi_conn *conn)549 struct iscsit_conn *conn)
550{550{
551 struct iscsi_queue_req *qr, *qr_tmp;551 struct iscsi_queue_req *qr, *qr_tmp;
552 552
@@ -574,8 +574,8 @@ static void iscsit_remove_cmd_from_immediate_queue( · 21 unmodified lines
574}574}
575 575
576int iscsit_add_cmd_to_response_queue(576int iscsit_add_cmd_to_response_queue(
577 struct iscsi_cmd *cmd,577 struct iscsit_cmd *cmd,
578 struct iscsi_conn *conn,578 struct iscsit_conn *conn,
579 u8 state)579 u8 state)
580{580{
581 struct iscsi_queue_req *qr;581 struct iscsi_queue_req *qr;
@@ -599,7 +599,7 @@ int iscsit_add_cmd_to_response_queue( · 17 unmodified lines
599 return 0;599 return 0;
600}600}
601 601
602struct iscsi_queue_req *iscsit_get_cmd_from_response_queue(struct iscsi_conn *conn)602struct iscsi_queue_req *iscsit_get_cmd_from_response_queue(struct iscsit_conn *conn)
603{603{
604 struct iscsi_queue_req *qr;604 struct iscsi_queue_req *qr;
605 605
@@ -621,8 +621,8 @@ struct iscsi_queue_req *iscsit_get_cmd_from_response_queue(struct iscsi_conn *co · 15 unmodified lines
621}621}
622 622
623static void iscsit_remove_cmd_from_response_queue(623static void iscsit_remove_cmd_from_response_queue(
624 struct iscsi_cmd *cmd,624 struct iscsit_cmd *cmd,
625 struct iscsi_conn *conn)625 struct iscsit_conn *conn)
626{626{
627 struct iscsi_queue_req *qr, *qr_tmp;627 struct iscsi_queue_req *qr, *qr_tmp;
628 628
@@ -650,7 +650,7 @@ static void iscsit_remove_cmd_from_response_queue( · 21 unmodified lines
650 }650 }
651}651}
652 652
653bool iscsit_conn_all_queues_empty(struct iscsi_conn *conn)653bool iscsit_conn_all_queues_empty(struct iscsit_conn *conn)
654{654{
655 bool empty;655 bool empty;
656 656
@@ -668,7 +668,7 @@ bool iscsit_conn_all_queues_empty(struct iscsi_conn *conn) · 11 unmodified lines
668 return empty;668 return empty;
669}669}
670 670
671void iscsit_free_queue_reqs_for_conn(struct iscsi_conn *conn)671void iscsit_free_queue_reqs_for_conn(struct iscsit_conn *conn)
672{672{
673 struct iscsi_queue_req *qr, *qr_tmp;673 struct iscsi_queue_req *qr, *qr_tmp;
674 674
@@ -694,9 +694,9 @@ void iscsit_free_queue_reqs_for_conn(struct iscsi_conn *conn) · 19 unmodified lines
694 spin_unlock_bh(&conn->response_queue_lock);694 spin_unlock_bh(&conn->response_queue_lock);
695}695}
696 696
697void iscsit_release_cmd(struct iscsi_cmd *cmd)697void iscsit_release_cmd(struct iscsit_cmd *cmd)
698{698{
699 struct iscsi_session *sess;699 struct iscsit_session *sess;
700 struct se_cmd *se_cmd = &cmd->se_cmd;700 struct se_cmd *se_cmd = &cmd->se_cmd;
701 701
702 WARN_ON(!list_empty(&cmd->i_conn_node));702 WARN_ON(!list_empty(&cmd->i_conn_node));
@@ -720,9 +720,9 @@ void iscsit_release_cmd(struct iscsi_cmd *cmd) · 17 unmodified lines
720}720}
721EXPORT_SYMBOL(iscsit_release_cmd);721EXPORT_SYMBOL(iscsit_release_cmd);
722 722
723void __iscsit_free_cmd(struct iscsi_cmd *cmd, bool check_queues)723void __iscsit_free_cmd(struct iscsit_cmd *cmd, bool check_queues)
724{724{
725 struct iscsi_conn *conn = cmd->conn;725 struct iscsit_conn *conn = cmd->conn;
726 726
727 WARN_ON(!list_empty(&cmd->i_conn_node));727 WARN_ON(!list_empty(&cmd->i_conn_node));
728 728
@@ -742,7 +742,7 @@ void __iscsit_free_cmd(struct iscsi_cmd *cmd, bool check_queues) · 13 unmodified lines
742 conn->conn_transport->iscsit_unmap_cmd(conn, cmd);742 conn->conn_transport->iscsit_unmap_cmd(conn, cmd);
743}743}
744 744
745void iscsit_free_cmd(struct iscsi_cmd *cmd, bool shutdown)745void iscsit_free_cmd(struct iscsit_cmd *cmd, bool shutdown)
746{746{
747 struct se_cmd *se_cmd = cmd->se_cmd.se_tfo ? &cmd->se_cmd : NULL;747 struct se_cmd *se_cmd = cmd->se_cmd.se_tfo ? &cmd->se_cmd : NULL;
748 int rc;748 int rc;
@@ -762,7 +762,7 @@ void iscsit_free_cmd(struct iscsi_cmd *cmd, bool shutdown) · 13 unmodified lines
762}762}
763EXPORT_SYMBOL(iscsit_free_cmd);763EXPORT_SYMBOL(iscsit_free_cmd);
764 764
765bool iscsit_check_session_usage_count(struct iscsi_session *sess,765bool iscsit_check_session_usage_count(struct iscsit_session *sess,
766 bool can_sleep)766 bool can_sleep)
767{767{
768 spin_lock_bh(&sess->session_usage_lock);768 spin_lock_bh(&sess->session_usage_lock);
@@ -780,7 +780,7 @@ bool iscsit_check_session_usage_count(struct iscsi_session *sess, · 11 unmodified lines
780 return false;780 return false;
781}781}
782 782
783void iscsit_dec_session_usage_count(struct iscsi_session *sess)783void iscsit_dec_session_usage_count(struct iscsit_session *sess)
784{784{
785 spin_lock_bh(&sess->session_usage_lock);785 spin_lock_bh(&sess->session_usage_lock);
786 sess->session_usage_count--;786 sess->session_usage_count--;
@@ -791,16 +791,16 @@ void iscsit_dec_session_usage_count(struct iscsi_session *sess) · 4 unmodified lines
791 spin_unlock_bh(&sess->session_usage_lock);791 spin_unlock_bh(&sess->session_usage_lock);
792}792}
793 793
794void iscsit_inc_session_usage_count(struct iscsi_session *sess)794void iscsit_inc_session_usage_count(struct iscsit_session *sess)
795{795{
796 spin_lock_bh(&sess->session_usage_lock);796 spin_lock_bh(&sess->session_usage_lock);
797 sess->session_usage_count++;797 sess->session_usage_count++;
798 spin_unlock_bh(&sess->session_usage_lock);798 spin_unlock_bh(&sess->session_usage_lock);
799}799}
800 800
801struct iscsi_conn *iscsit_get_conn_from_cid(struct iscsi_session *sess, u16 cid)801struct iscsit_conn *iscsit_get_conn_from_cid(struct iscsit_session *sess, u16 cid)
802{802{
803 struct iscsi_conn *conn;803 struct iscsit_conn *conn;
804 804
805 spin_lock_bh(&sess->conn_lock);805 spin_lock_bh(&sess->conn_lock);
806 list_for_each_entry(conn, &sess->sess_conn_list, conn_list) {806 list_for_each_entry(conn, &sess->sess_conn_list, conn_list) {
@@ -816,9 +816,9 @@ struct iscsi_conn *iscsit_get_conn_from_cid(struct iscsi_session *sess, u16 cid) · 9 unmodified lines
816 return NULL;816 return NULL;
817}817}
818 818
819struct iscsi_conn *iscsit_get_conn_from_cid_rcfr(struct iscsi_session *sess, u16 cid)819struct iscsit_conn *iscsit_get_conn_from_cid_rcfr(struct iscsit_session *sess, u16 cid)
820{820{
821 struct iscsi_conn *conn;821 struct iscsit_conn *conn;
822 822
823 spin_lock_bh(&sess->conn_lock);823 spin_lock_bh(&sess->conn_lock);
824 list_for_each_entry(conn, &sess->sess_conn_list, conn_list) {824 list_for_each_entry(conn, &sess->sess_conn_list, conn_list) {
@@ -836,7 +836,7 @@ struct iscsi_conn *iscsit_get_conn_from_cid_rcfr(struct iscsi_session *sess, u16 · 11 unmodified lines
836 return NULL;836 return NULL;
837}837}
838 838
839void iscsit_check_conn_usage_count(struct iscsi_conn *conn)839void iscsit_check_conn_usage_count(struct iscsit_conn *conn)
840{840{
841 spin_lock_bh(&conn->conn_usage_lock);841 spin_lock_bh(&conn->conn_usage_lock);
842 if (conn->conn_usage_count != 0) {842 if (conn->conn_usage_count != 0) {
@@ -849,7 +849,7 @@ void iscsit_check_conn_usage_count(struct iscsi_conn *conn) · 6 unmodified lines
849 spin_unlock_bh(&conn->conn_usage_lock);849 spin_unlock_bh(&conn->conn_usage_lock);
850}850}
851 851
852void iscsit_dec_conn_usage_count(struct iscsi_conn *conn)852void iscsit_dec_conn_usage_count(struct iscsit_conn *conn)
853{853{
854 spin_lock_bh(&conn->conn_usage_lock);854 spin_lock_bh(&conn->conn_usage_lock);
855 conn->conn_usage_count--;855 conn->conn_usage_count--;
@@ -860,17 +860,17 @@ void iscsit_dec_conn_usage_count(struct iscsi_conn *conn) · 4 unmodified lines
860 spin_unlock_bh(&conn->conn_usage_lock);860 spin_unlock_bh(&conn->conn_usage_lock);
861}861}
862 862
863void iscsit_inc_conn_usage_count(struct iscsi_conn *conn)863void iscsit_inc_conn_usage_count(struct iscsit_conn *conn)
864{864{
865 spin_lock_bh(&conn->conn_usage_lock);865 spin_lock_bh(&conn->conn_usage_lock);
866 conn->conn_usage_count++;866 conn->conn_usage_count++;
867 spin_unlock_bh(&conn->conn_usage_lock);867 spin_unlock_bh(&conn->conn_usage_lock);
868}868}
869 869
870static int iscsit_add_nopin(struct iscsi_conn *conn, int want_response)870static int iscsit_add_nopin(struct iscsit_conn *conn, int want_response)
871{871{
872 u8 state;872 u8 state;
873 struct iscsi_cmd *cmd;873 struct iscsit_cmd *cmd;
874 874
875 cmd = iscsit_allocate_cmd(conn, TASK_RUNNING);875 cmd = iscsit_allocate_cmd(conn, TASK_RUNNING);
876 if (!cmd)876 if (!cmd)
@@ -895,8 +895,8 @@ static int iscsit_add_nopin(struct iscsi_conn *conn, int want_response) · 18 unmodified lines
895 895
896void iscsit_handle_nopin_response_timeout(struct timer_list *t)896void iscsit_handle_nopin_response_timeout(struct timer_list *t)
897{897{
898 struct iscsi_conn *conn = from_timer(conn, t, nopin_response_timer);898 struct iscsit_conn *conn = from_timer(conn, t, nopin_response_timer);
899 struct iscsi_session *sess = conn->sess;899 struct iscsit_session *sess = conn->sess;
900 900
901 iscsit_inc_conn_usage_count(conn);901 iscsit_inc_conn_usage_count(conn);
902 902
@@ -919,9 +919,9 @@ void iscsit_handle_nopin_response_timeout(struct timer_list *t) · 16 unmodified lines
919 iscsit_dec_conn_usage_count(conn);919 iscsit_dec_conn_usage_count(conn);
920}920}
921 921
922void iscsit_mod_nopin_response_timer(struct iscsi_conn *conn)922void iscsit_mod_nopin_response_timer(struct iscsit_conn *conn)
923{923{
924 struct iscsi_session *sess = conn->sess;924 struct iscsit_session *sess = conn->sess;
925 struct iscsi_node_attrib *na = iscsit_tpg_get_node_attrib(sess);925 struct iscsi_node_attrib *na = iscsit_tpg_get_node_attrib(sess);
926 926
927 spin_lock_bh(&conn->nopin_timer_lock);927 spin_lock_bh(&conn->nopin_timer_lock);
@@ -935,9 +935,9 @@ void iscsit_mod_nopin_response_timer(struct iscsi_conn *conn) · 7 unmodified lines
935 spin_unlock_bh(&conn->nopin_timer_lock);935 spin_unlock_bh(&conn->nopin_timer_lock);
936}936}
937 937
938void iscsit_start_nopin_response_timer(struct iscsi_conn *conn)938void iscsit_start_nopin_response_timer(struct iscsit_conn *conn)
939{939{
940 struct iscsi_session *sess = conn->sess;940 struct iscsit_session *sess = conn->sess;
941 struct iscsi_node_attrib *na = iscsit_tpg_get_node_attrib(sess);941 struct iscsi_node_attrib *na = iscsit_tpg_get_node_attrib(sess);
942 942
943 spin_lock_bh(&conn->nopin_timer_lock);943 spin_lock_bh(&conn->nopin_timer_lock);
@@ -956,7 +956,7 @@ void iscsit_start_nopin_response_timer(struct iscsi_conn *conn) · 12 unmodified lines
956 spin_unlock_bh(&conn->nopin_timer_lock);956 spin_unlock_bh(&conn->nopin_timer_lock);
957}957}
958 958
959void iscsit_stop_nopin_response_timer(struct iscsi_conn *conn)959void iscsit_stop_nopin_response_timer(struct iscsit_conn *conn)
960{960{
961 spin_lock_bh(&conn->nopin_timer_lock);961 spin_lock_bh(&conn->nopin_timer_lock);
962 if (!(conn->nopin_response_timer_flags & ISCSI_TF_RUNNING)) {962 if (!(conn->nopin_response_timer_flags & ISCSI_TF_RUNNING)) {
@@ -975,7 +975,7 @@ void iscsit_stop_nopin_response_timer(struct iscsi_conn *conn) · 12 unmodified lines
975 975
976void iscsit_handle_nopin_timeout(struct timer_list *t)976void iscsit_handle_nopin_timeout(struct timer_list *t)
977{977{
978 struct iscsi_conn *conn = from_timer(conn, t, nopin_timer);978 struct iscsit_conn *conn = from_timer(conn, t, nopin_timer);
979 979
980 iscsit_inc_conn_usage_count(conn);980 iscsit_inc_conn_usage_count(conn);
981 981
@@ -992,9 +992,9 @@ void iscsit_handle_nopin_timeout(struct timer_list *t) · 10 unmodified lines
992 iscsit_dec_conn_usage_count(conn);992 iscsit_dec_conn_usage_count(conn);
993}993}
994 994
995void __iscsit_start_nopin_timer(struct iscsi_conn *conn)995void __iscsit_start_nopin_timer(struct iscsit_conn *conn)
996{996{
997 struct iscsi_session *sess = conn->sess;997 struct iscsit_session *sess = conn->sess;
998 struct iscsi_node_attrib *na = iscsit_tpg_get_node_attrib(sess);998 struct iscsi_node_attrib *na = iscsit_tpg_get_node_attrib(sess);
999 999
1000 lockdep_assert_held(&conn->nopin_timer_lock);1000 lockdep_assert_held(&conn->nopin_timer_lock);
@@ -1016,14 +1016,14 @@ void __iscsit_start_nopin_timer(struct iscsi_conn *conn) · 15 unmodified lines
1016 " interval\n", conn->cid, na->nopin_timeout);1016 " interval\n", conn->cid, na->nopin_timeout);
1017}1017}
1018 1018
1019void iscsit_start_nopin_timer(struct iscsi_conn *conn)1019void iscsit_start_nopin_timer(struct iscsit_conn *conn)
1020{1020{
1021 spin_lock_bh(&conn->nopin_timer_lock);1021 spin_lock_bh(&conn->nopin_timer_lock);
1022 __iscsit_start_nopin_timer(conn);1022 __iscsit_start_nopin_timer(conn);
1023 spin_unlock_bh(&conn->nopin_timer_lock);1023 spin_unlock_bh(&conn->nopin_timer_lock);
1024}1024}
1025 1025
1026void iscsit_stop_nopin_timer(struct iscsi_conn *conn)1026void iscsit_stop_nopin_timer(struct iscsit_conn *conn)
1027{1027{
1028 spin_lock_bh(&conn->nopin_timer_lock);1028 spin_lock_bh(&conn->nopin_timer_lock);
1029 if (!(conn->nopin_timer_flags & ISCSI_TF_RUNNING)) {1029 if (!(conn->nopin_timer_flags & ISCSI_TF_RUNNING)) {
@@ -1041,8 +1041,8 @@ void iscsit_stop_nopin_timer(struct iscsi_conn *conn) · 11 unmodified lines
1041}1041}
1042 1042
1043int iscsit_send_tx_data(1043int iscsit_send_tx_data(
1044 struct iscsi_cmd *cmd,1044 struct iscsit_cmd *cmd,
1045 struct iscsi_conn *conn,1045 struct iscsit_conn *conn,
1046 int use_misc)1046 int use_misc)
1047{1047{
1048 int tx_sent, tx_size;1048 int tx_sent, tx_size;
@@ -1074,8 +1074,8 @@ send_data: · 25 unmodified lines
1074}1074}
1075 1075
1076int iscsit_fe_sendpage_sg(1076int iscsit_fe_sendpage_sg(
1077 struct iscsi_cmd *cmd,1077 struct iscsit_cmd *cmd,
1078 struct iscsi_conn *conn)1078 struct iscsit_conn *conn)
1079{1079{
1080 struct scatterlist *sg = cmd->first_data_sg;1080 struct scatterlist *sg = cmd->first_data_sg;
1081 struct kvec iov;1081 struct kvec iov;
@@ -1179,7 +1179,7 @@ send_datacrc: · 97 unmodified lines
1179 * Parameters: iSCSI Connection, Status Class, Status Detail.1179 * Parameters: iSCSI Connection, Status Class, Status Detail.

64 more lines aren’t shown here.

drivers/target/iscsi/iscsi_target_util.h+51−51

This diff is large: its 118 lines aren’t shown here.

drivers/target/target_core_configfs.c+28−19

This diff is large: its 101 lines aren’t shown here.

drivers/target/target_core_spc.c+1−1

This diff is large: its 9 lines aren’t shown here.

drivers/target/target_core_user.c+42−8

This diff is large: its 105 lines aren’t shown here.

include/scsi/libfcoe.h+2−0

This diff is large: its 16 lines aren’t shown here.

include/scsi/libiscsi.h+3−3

This diff is large: its 13 lines aren’t shown here.

include/scsi/sas_ata.h+7−0

This diff is large: its 21 lines aren’t shown here.

include/scsi/scsi_device.h+8−1

This diff is large: its 27 lines aren’t shown here.

include/scsi/scsi_proto.h+8−1

This diff is large: its 23 lines aren’t shown here.

include/target/iscsi/iscsi_target_core.h+26−26

This diff is large: its 181 lines aren’t shown here.

include/target/iscsi/iscsi_transport.h+63−63

This diff is large: its 200 lines aren’t shown here.

include/uapi/scsi/scsi_bsg_mpi3mr.h+582−0

This diff is large: its 583 lines aren’t shown here.